summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cvsignore30
-rw-r--r--COPYING340
-rw-r--r--COPYING.LIB482
-rw-r--r--ChangeLog6537
-rw-r--r--Makefile.in1821
-rw-r--r--README47
-rw-r--r--bfd/COPYING340
-rw-r--r--bfd/ChangeLog3066
-rw-r--r--bfd/ChangeLog-91937851
-rw-r--r--bfd/ChangeLog-949510043
-rw-r--r--bfd/ChangeLog-96976711
-rw-r--r--bfd/Makefile.am1065
-rw-r--r--bfd/Makefile.in1599
-rw-r--r--bfd/PORTING83
-rw-r--r--bfd/README49
-rw-r--r--bfd/TODO25
-rw-r--r--bfd/acinclude.m4104
-rw-r--r--bfd/aclocal.m4861
-rw-r--r--bfd/aix386-core.c283
-rw-r--r--bfd/aout-adobe.c527
-rw-r--r--bfd/aout-arm.c546
-rw-r--r--bfd/aout-encap.c236
-rw-r--r--bfd/aout-ns32k.c370
-rw-r--r--bfd/aout-sparcle.c32
-rw-r--r--bfd/aout-target.h650
-rw-r--r--bfd/aout-tic30.c1065
-rw-r--r--bfd/aout0.c32
-rw-r--r--bfd/aout32.c23
-rw-r--r--bfd/aout64.c31
-rw-r--r--bfd/aoutf1.h859
-rw-r--r--bfd/aoutx.h5706
-rw-r--r--bfd/archive.c2127
-rw-r--r--bfd/archures.c896
-rw-r--r--bfd/bfd-in.h727
-rw-r--r--bfd/bfd-in2.h3003
-rw-r--r--bfd/bfd.c1159
-rw-r--r--bfd/binary.c386
-rw-r--r--bfd/bout.c1534
-rw-r--r--bfd/cache.c350
-rw-r--r--bfd/cf-i386lynx.c31
-rw-r--r--bfd/cf-m68klynx.c28
-rw-r--r--bfd/cf-sparclynx.c28
-rw-r--r--bfd/cisco-core.c327
-rw-r--r--bfd/coff-a29k.c640
-rw-r--r--bfd/coff-alpha.c2402
-rw-r--r--bfd/coff-apollo.c161
-rw-r--r--bfd/coff-arm.c2557
-rw-r--r--bfd/coff-aux.c135
-rw-r--r--bfd/coff-go32.c25
-rw-r--r--bfd/coff-h8300.c1388
-rw-r--r--bfd/coff-h8500.c354
-rw-r--r--bfd/coff-i386.c637
-rw-r--r--bfd/coff-i860.c422
-rw-r--r--bfd/coff-i960.c703
-rw-r--r--bfd/coff-m68k.c480
-rw-r--r--bfd/coff-m88k.c330
-rw-r--r--bfd/coff-mcore.c703
-rw-r--r--bfd/coff-mips.c2726
-rw-r--r--bfd/coff-pmac.c27
-rw-r--r--bfd/coff-ppc.c2934
-rw-r--r--bfd/coff-rs6000.c1418
-rw-r--r--bfd/coff-sh.c2959
-rw-r--r--bfd/coff-sparc.c256
-rw-r--r--bfd/coff-stgo32.c464
-rw-r--r--bfd/coff-svm68k.c26
-rw-r--r--bfd/coff-tic30.c206
-rw-r--r--bfd/coff-tic80.c759
-rw-r--r--bfd/coff-u68k.c35
-rw-r--r--bfd/coff-w65.c445
-rw-r--r--bfd/coff-we32k.c109
-rw-r--r--bfd/coff-z8k.c280
-rw-r--r--bfd/coffcode.h4318
-rw-r--r--bfd/coffgen.c2378
-rw-r--r--bfd/cofflink.c2752
-rw-r--r--bfd/coffswap.h908
-rw-r--r--bfd/config.bfd719
-rw-r--r--bfd/config.in234
-rwxr-xr-xbfd/configure5987
-rw-r--r--bfd/configure.bat18
-rw-r--r--bfd/configure.com215
-rw-r--r--bfd/configure.host70
-rw-r--r--bfd/configure.in648
-rw-r--r--bfd/corefile.c106
-rw-r--r--bfd/cpu-a29k.c39
-rw-r--r--bfd/cpu-alpha.c51
-rw-r--r--bfd/cpu-arc.c70
-rw-r--r--bfd/cpu-arm.c134
-rw-r--r--bfd/cpu-d10v.c40
-rw-r--r--bfd/cpu-d30v.c39
-rw-r--r--bfd/cpu-fr30.c38
-rw-r--r--bfd/cpu-h8300.c134
-rw-r--r--bfd/cpu-h8500.c199
-rw-r--r--bfd/cpu-hppa.c71
-rw-r--r--bfd/cpu-i386.c70
-rw-r--r--bfd/cpu-i860.c40
-rw-r--r--bfd/cpu-i960.c166
-rw-r--r--bfd/cpu-m10200.c38
-rw-r--r--bfd/cpu-m10300.c41
-rw-r--r--bfd/cpu-m32r.c32
-rw-r--r--bfd/cpu-m68k.c42
-rw-r--r--bfd/cpu-m88k.c42
-rw-r--r--bfd/cpu-mcore.c38
-rw-r--r--bfd/cpu-mips.c88
-rw-r--r--bfd/cpu-ns32k.c846
-rw-r--r--bfd/cpu-powerpc.c124
-rw-r--r--bfd/cpu-rs6000.c70
-rw-r--r--bfd/cpu-sh.c102
-rw-r--r--bfd/cpu-sparc.c156
-rw-r--r--bfd/cpu-tic30.c39
-rw-r--r--bfd/cpu-tic80.c39
-rw-r--r--bfd/cpu-v850.c103
-rw-r--r--bfd/cpu-vax.c39
-rw-r--r--bfd/cpu-w65.c54
-rw-r--r--bfd/cpu-we32k.c39
-rw-r--r--bfd/cpu-z8k.c198
-rw-r--r--bfd/demo64.c24
-rw-r--r--bfd/dep-in.sed26
-rw-r--r--bfd/doc/ChangeLog390
-rw-r--r--bfd/doc/Makefile.am250
-rw-r--r--bfd/doc/Makefile.in600
-rw-r--r--bfd/doc/bfd.texinfo348
-rw-r--r--bfd/doc/bfdint.texi1885
-rw-r--r--bfd/doc/bfdsumm.texi148
-rw-r--r--bfd/doc/chew.c1579
-rw-r--r--bfd/doc/doc.str158
-rw-r--r--bfd/doc/makefile.vms5
-rw-r--r--bfd/doc/proto.str135
-rw-r--r--bfd/dwarf1.c576
-rw-r--r--bfd/dwarf2.c1466
-rw-r--r--bfd/ecoff.c4825
-rw-r--r--bfd/ecofflink.c2499
-rw-r--r--bfd/ecoffswap.h853
-rw-r--r--bfd/elf-bfd.h1114
-rw-r--r--bfd/elf-m10200.c1525
-rw-r--r--bfd/elf-m10300.c2821
-rw-r--r--bfd/elf.c5250
-rw-r--r--bfd/elf32-arc.c213
-rw-r--r--bfd/elf32-arm.h3010
-rw-r--r--bfd/elf32-d10v.c534
-rw-r--r--bfd/elf32-d30v.c601
-rw-r--r--bfd/elf32-fr30.c811
-rw-r--r--bfd/elf32-gen.c71
-rw-r--r--bfd/elf32-hppa.c2988
-rw-r--r--bfd/elf32-hppa.h66
-rw-r--r--bfd/elf32-i386.c1943
-rw-r--r--bfd/elf32-i860.c33
-rw-r--r--bfd/elf32-m32r.c2082
-rw-r--r--bfd/elf32-m68k.c2128
-rw-r--r--bfd/elf32-m88k.c35
-rw-r--r--bfd/elf32-mcore.c747
-rw-r--r--bfd/elf32-mips.c7800
-rw-r--r--bfd/elf32-ppc.c3848
-rw-r--r--bfd/elf32-sh.c2059
-rw-r--r--bfd/elf32-sparc.c2059
-rw-r--r--bfd/elf32-v850.c2230
-rw-r--r--bfd/elf32.c23
-rw-r--r--bfd/elf64-alpha.c4768
-rw-r--r--bfd/elf64-gen.c71
-rw-r--r--bfd/elf64-mips.c2127
-rw-r--r--bfd/elf64-sparc.c2275
-rw-r--r--bfd/elf64.c22
-rw-r--r--bfd/elfarm-nabi.c670
-rw-r--r--bfd/elfarm-oabi.c381
-rw-r--r--bfd/elfcode.h1452
-rw-r--r--bfd/elfcore.h226
-rw-r--r--bfd/elflink.c433
-rw-r--r--bfd/elflink.h6150
-rw-r--r--bfd/elfxx-target.h536
-rw-r--r--bfd/epoc-pe-arm.c30
-rw-r--r--bfd/epoc-pei-arm.c29
-rw-r--r--bfd/format.c342
-rw-r--r--bfd/freebsd.h110
-rw-r--r--bfd/gen-aout.c101
-rw-r--r--bfd/genlink.h111
-rw-r--r--bfd/go32stub.h128
-rw-r--r--bfd/hash.c734
-rw-r--r--bfd/host-aout.c83
-rw-r--r--bfd/hosts/alphalinux.h6
-rw-r--r--bfd/hosts/alphavms.h69
-rw-r--r--bfd/hosts/decstation.h17
-rw-r--r--bfd/hosts/delta68.h18
-rw-r--r--bfd/hosts/dpx2.h8
-rw-r--r--bfd/hosts/hp300bsd.h13
-rw-r--r--bfd/hosts/i386bsd.h32
-rw-r--r--bfd/hosts/i386linux.h8
-rw-r--r--bfd/hosts/i386mach3.h25
-rw-r--r--bfd/hosts/i386sco.h19
-rw-r--r--bfd/hosts/i860mach3.h27
-rw-r--r--bfd/hosts/m68kaux.h16
-rw-r--r--bfd/hosts/m68klinux.h6
-rw-r--r--bfd/hosts/m88kmach3.h11
-rw-r--r--bfd/hosts/mipsbsd.h12
-rw-r--r--bfd/hosts/mipsmach3.h10
-rw-r--r--bfd/hosts/news-mips.h12
-rw-r--r--bfd/hosts/news.h9
-rw-r--r--bfd/hosts/pc532mach.h24
-rw-r--r--bfd/hosts/riscos.h10
-rw-r--r--bfd/hosts/symmetry.h20
-rw-r--r--bfd/hosts/tahoe.h12
-rw-r--r--bfd/hosts/vaxbsd.h19
-rw-r--r--bfd/hosts/vaxult.h8
-rw-r--r--bfd/hosts/vaxult2.h8
-rw-r--r--bfd/hp300bsd.c38
-rw-r--r--bfd/hp300hpux.c870
-rw-r--r--bfd/hppa_stubs.h23
-rw-r--r--bfd/hppabsd-core.c303
-rw-r--r--bfd/hpux-core.c404
-rw-r--r--bfd/i386aout.c91
-rw-r--r--bfd/i386bsd.c46
-rw-r--r--bfd/i386dynix.c80
-rw-r--r--bfd/i386freebsd.c33
-rw-r--r--bfd/i386linux.c767
-rw-r--r--bfd/i386lynx.c562
-rw-r--r--bfd/i386mach3.c66
-rw-r--r--bfd/i386msdos.c244
-rw-r--r--bfd/i386netbsd.c33
-rw-r--r--bfd/i386os9k.c371
-rw-r--r--bfd/ieee.c3970
-rw-r--r--bfd/ihex.c1041
-rw-r--r--bfd/init.c50
-rw-r--r--bfd/irix-core.c276
-rw-r--r--bfd/libaout.h624
-rw-r--r--bfd/libbfd-in.h538
-rw-r--r--bfd/libbfd.c1263
-rw-r--r--bfd/libbfd.h885
-rw-r--r--bfd/libcoff-in.h529
-rw-r--r--bfd/libcoff.h888
-rw-r--r--bfd/libecoff.h357
-rw-r--r--bfd/libhppa.h700
-rw-r--r--bfd/libieee.h133
-rw-r--r--bfd/libnlm.h264
-rw-r--r--bfd/liboasys.h82
-rw-r--r--bfd/linker.c2804
-rw-r--r--bfd/lynx-core.c233
-rw-r--r--bfd/m68k4knetbsd.c32
-rw-r--r--bfd/m68klinux.c772
-rw-r--r--bfd/m68klynx.c54
-rw-r--r--bfd/m68knetbsd.c34
-rw-r--r--bfd/m88kmach3.c38
-rw-r--r--bfd/makefile.dos49
-rw-r--r--bfd/makefile.vms75
-rw-r--r--bfd/mipsbsd.c468
-rw-r--r--bfd/mpw-config.in86
-rw-r--r--bfd/mpw-make.sed81
-rw-r--r--bfd/netbsd-core.c251
-rw-r--r--bfd/netbsd.h122
-rw-r--r--bfd/newsos3.c40
-rw-r--r--bfd/nlm-target.h229
-rw-r--r--bfd/nlm.c55
-rw-r--r--bfd/nlm32-alpha.c892
-rw-r--r--bfd/nlm32-i386.c451
-rw-r--r--bfd/nlm32-ppc.c1045
-rw-r--r--bfd/nlm32-sparc.c440
-rw-r--r--bfd/nlm32.c21
-rw-r--r--bfd/nlm64.c21
-rw-r--r--bfd/nlmcode.h2056
-rw-r--r--bfd/nlmswap.h157
-rw-r--r--bfd/ns32k.h41
-rw-r--r--bfd/ns32knetbsd.c53
-rw-r--r--bfd/oasys.c1535
-rw-r--r--bfd/opncls.c683
-rw-r--r--bfd/osf-core.c254
-rw-r--r--bfd/pc532-mach.c121
-rw-r--r--bfd/pe-arm.c34
-rw-r--r--bfd/pe-i386.c31
-rw-r--r--bfd/pe-mcore.c36
-rw-r--r--bfd/pe-ppc.c41
-rw-r--r--bfd/pei-arm.c36
-rw-r--r--bfd/pei-i386.c35
-rw-r--r--bfd/pei-mcore.c38
-rw-r--r--bfd/pei-ppc.c47
-rw-r--r--bfd/peicode.h2144
-rw-r--r--bfd/po/Make-in251
-rw-r--r--bfd/po/POTFILES.in264
-rw-r--r--bfd/po/bfd.pot632
-rw-r--r--bfd/ppcboot.c535
-rw-r--r--bfd/ptrace-core.c230
-rw-r--r--bfd/reloc.c2842
-rw-r--r--bfd/reloc16.c334
-rw-r--r--bfd/riscix.c644
-rw-r--r--bfd/rs6000-core.c507
-rw-r--r--bfd/sco5-core.c429
-rw-r--r--bfd/section.c1075
-rw-r--r--bfd/som.c6264
-rw-r--r--bfd/som.h237
-rw-r--r--bfd/sparclinux.c770
-rw-r--r--bfd/sparclynx.c266
-rw-r--r--bfd/sparcnetbsd.c34
-rw-r--r--bfd/srec.c1377
-rw-r--r--bfd/stab-syms.c57
-rw-r--r--bfd/stabs.c651
-rw-r--r--bfd/stamp-h.in1
-rw-r--r--bfd/sunos.c2948
-rw-r--r--bfd/syms.c1253
-rw-r--r--bfd/sysdep.h144
-rw-r--r--bfd/targets.c1079
-rw-r--r--bfd/targmatch.sed32
-rw-r--r--bfd/tekhex.c1065
-rw-r--r--bfd/trad-core.c316
-rw-r--r--bfd/vaxnetbsd.c33
-rw-r--r--bfd/versados.c923
-rw-r--r--bfd/vms-gsd.c920
-rw-r--r--bfd/vms-hdr.c461
-rw-r--r--bfd/vms-misc.c1145
-rw-r--r--bfd/vms-tir.c2489
-rw-r--r--bfd/vms.c1947
-rw-r--r--bfd/vms.h675
-rw-r--r--bfd/xcofflink.c6635
-rw-r--r--config-ml.in687
-rwxr-xr-xconfig.guess1008
-rw-r--r--config.if87
-rwxr-xr-xconfig.sub1292
-rw-r--r--config/ChangeLog392
-rwxr-xr-xconfig/acinclude.m41994
-rw-r--r--config/mh-a68bsd12
-rw-r--r--config/mh-aix3861
-rw-r--r--config/mh-aix434
-rw-r--r--config/mh-apollo683
-rw-r--r--config/mh-armpic1
-rw-r--r--config/mh-cxux14
-rw-r--r--config/mh-cygwin6
-rw-r--r--config/mh-decstation5
-rw-r--r--config/mh-delta884
-rw-r--r--config/mh-dgux4
-rw-r--r--config/mh-dgux38622
-rw-r--r--config/mh-djgpp4
-rw-r--r--config/mh-elfalphapic1
-rw-r--r--config/mh-hp30013
-rw-r--r--config/mh-hpux4
-rw-r--r--config/mh-hpux84
-rw-r--r--config/mh-interix14
-rw-r--r--config/mh-irix47
-rw-r--r--config/mh-irix53
-rw-r--r--config/mh-irix67
-rw-r--r--config/mh-lynxos2
-rw-r--r--config/mh-lynxrs6k8
-rw-r--r--config/mh-m68kpic1
-rw-r--r--config/mh-mingw3212
-rw-r--r--config/mh-ncr300017
-rw-r--r--config/mh-ncrsvr439
-rw-r--r--config/mh-necv411
-rw-r--r--config/mh-papic1
-rw-r--r--config/mh-ppcpic1
-rw-r--r--config/mh-riscos15
-rw-r--r--config/mh-sco10
-rw-r--r--config/mh-solaris6
-rw-r--r--config/mh-sparcpic1
-rw-r--r--config/mh-sun33
-rw-r--r--config/mh-sysv3
-rw-r--r--config/mh-sysv411
-rw-r--r--config/mh-sysv58
-rw-r--r--config/mh-vaxult22
-rw-r--r--config/mh-x86pic1
-rw-r--r--config/mpw-mh-mpw157
-rw-r--r--config/mpw/ChangeLog53
-rw-r--r--config/mpw/MoveIfChange19
-rw-r--r--config/mpw/README23
-rw-r--r--config/mpw/forward-include3
-rw-r--r--config/mpw/g-mpw-make.sed293
-rw-r--r--config/mpw/mpw-touch7
-rw-r--r--config/mpw/mpw-true1
-rw-r--r--config/mpw/null-command1
-rw-r--r--config/mpw/open-brace4
-rw-r--r--config/mpw/tr-7to8-src9
-rw-r--r--config/mpw/true1
-rw-r--r--config/mt-armpic1
-rw-r--r--config/mt-d30v4
-rw-r--r--config/mt-elfalphapic1
-rw-r--r--config/mt-linux2
-rw-r--r--config/mt-m68kpic1
-rw-r--r--config/mt-netware1
-rw-r--r--config/mt-ospace3
-rw-r--r--config/mt-papic1
-rw-r--r--config/mt-ppcpic1
-rw-r--r--config/mt-sparcpic1
-rw-r--r--config/mt-v8104
-rw-r--r--config/mt-x86pic1
-rwxr-xr-xconfigure1595
-rw-r--r--configure.bat17
-rw-r--r--configure.in1184
-rw-r--r--etc/ChangeLog507
-rw-r--r--etc/Makefile.in156
-rw-r--r--etc/add-log.el573
-rw-r--r--etc/add-log.vi11
-rw-r--r--etc/configbuild.ein149
-rw-r--r--etc/configbuild.fig50
-rw-r--r--etc/configbuild.jinbin0 -> 11123 bytes
-rw-r--r--etc/configbuild.tin9
-rw-r--r--etc/configdev.ein185
-rw-r--r--etc/configdev.fig80
-rw-r--r--etc/configdev.jinbin0 -> 17967 bytes
-rw-r--r--etc/configdev.tin17
-rwxr-xr-xetc/configure862
-rw-r--r--etc/configure.in7
-rw-r--r--etc/configure.texi2644
-rw-r--r--etc/make-stds.texi914
-rw-r--r--etc/standards.texi3093
-rw-r--r--include/COPYING340
-rw-r--r--include/ChangeLog1527
-rw-r--r--include/ansidecl.h163
-rw-r--r--include/aout/ChangeLog178
-rw-r--r--include/aout/adobe.h297
-rw-r--r--include/aout/aout64.h475
-rw-r--r--include/aout/ar.h36
-rw-r--r--include/aout/dynix3.h71
-rw-r--r--include/aout/encap.h135
-rw-r--r--include/aout/host.h22
-rw-r--r--include/aout/hp.h82
-rw-r--r--include/aout/hp300hpux.h119
-rw-r--r--include/aout/hppa.h7
-rw-r--r--include/aout/ranlib.h62
-rw-r--r--include/aout/reloc.h66
-rw-r--r--include/aout/stab.def268
-rw-r--r--include/aout/stab_gnu.h37
-rw-r--r--include/aout/sun4.h219
-rw-r--r--include/bfdlink.h520
-rw-r--r--include/bout.h182
-rw-r--r--include/callback.h270
-rw-r--r--include/coff/ChangeLog793
-rw-r--r--include/coff/a29k.h305
-rw-r--r--include/coff/alpha.h362
-rw-r--r--include/coff/apollo.h252
-rw-r--r--include/coff/arm.h258
-rw-r--r--include/coff/aux-coff.h31
-rw-r--r--include/coff/ecoff.h421
-rw-r--r--include/coff/go32exe.h20
-rw-r--r--include/coff/h8300.h204
-rw-r--r--include/coff/h8500.h201
-rw-r--r--include/coff/i386.h228
-rw-r--r--include/coff/i860.h205
-rw-r--r--include/coff/i960.h275
-rw-r--r--include/coff/internal.h728
-rw-r--r--include/coff/m68k.h225
-rw-r--r--include/coff/m88k.h219
-rw-r--r--include/coff/mcore.h245
-rw-r--r--include/coff/mips.h369
-rw-r--r--include/coff/pe.h169
-rw-r--r--include/coff/powerpc.h199
-rw-r--r--include/coff/rs6000.h243
-rw-r--r--include/coff/sh.h269
-rw-r--r--include/coff/sparc.h210
-rw-r--r--include/coff/sym.h484
-rw-r--r--include/coff/symconst.h177
-rw-r--r--include/coff/tic30.h203
-rw-r--r--include/coff/tic80.h228
-rw-r--r--include/coff/w65.h201
-rw-r--r--include/coff/we32k.h206
-rw-r--r--include/coff/z8k.h201
-rw-r--r--include/demangle.h95
-rw-r--r--include/dis-asm.h243
-rw-r--r--include/elf/ChangeLog719
-rw-r--r--include/elf/alpha.h108
-rw-r--r--include/elf/arc.h54
-rw-r--r--include/elf/arm-oabi.h87
-rw-r--r--include/elf/arm.h96
-rw-r--r--include/elf/common.h454
-rw-r--r--include/elf/d10v.h38
-rw-r--r--include/elf/d30v.h42
-rw-r--r--include/elf/dwarf.h319
-rw-r--r--include/elf/dwarf2.h637
-rw-r--r--include/elf/external.h256
-rw-r--r--include/elf/fr30.h43
-rw-r--r--include/elf/hppa.h187
-rw-r--r--include/elf/i386.h49
-rw-r--r--include/elf/internal.h312
-rw-r--r--include/elf/m32r.h66
-rw-r--r--include/elf/m68k.h56
-rw-r--r--include/elf/mcore.h43
-rw-r--r--include/elf/mips.h860
-rw-r--r--include/elf/mn10200.h39
-rw-r--r--include/elf/mn10300.h53
-rw-r--r--include/elf/ppc.h127
-rw-r--r--include/elf/reloc-macros.h116
-rw-r--r--include/elf/sh.h55
-rw-r--r--include/elf/sparc.h156
-rw-r--r--include/elf/v850.h111
-rw-r--r--include/floatformat.h111
-rw-r--r--include/fnmatch.h70
-rw-r--r--include/fopen-bin.h27
-rw-r--r--include/fopen-same.h27
-rw-r--r--include/fopen-vms.h24
-rw-r--r--include/gdbm.h91
-rw-r--r--include/getopt.h133
-rw-r--r--include/hp-symtab.h1871
-rw-r--r--include/ieee.h139
-rw-r--r--include/libiberty.h180
-rw-r--r--include/mpw/ChangeLog61
-rw-r--r--include/mpw/README1
-rw-r--r--include/mpw/dir.h23
-rw-r--r--include/mpw/dirent.h31
-rw-r--r--include/mpw/fcntl.h124
-rw-r--r--include/mpw/grp.h10
-rw-r--r--include/mpw/mpw.h130
-rw-r--r--include/mpw/pwd.h15
-rw-r--r--include/mpw/spin.h64
-rw-r--r--include/mpw/stat.h75
-rw-r--r--include/mpw/sys/file.h1
-rw-r--r--include/mpw/sys/param.h1
-rw-r--r--include/mpw/sys/resource.h9
-rw-r--r--include/mpw/sys/stat.h44
-rw-r--r--include/mpw/sys/time.h13
-rw-r--r--include/mpw/sys/types.h15
-rw-r--r--include/mpw/utime.h7
-rw-r--r--include/mpw/varargs.h9
-rw-r--r--include/nlm/ChangeLog83
-rw-r--r--include/nlm/alpha-ext.h166
-rw-r--r--include/nlm/common.h124
-rw-r--r--include/nlm/external.h174
-rw-r--r--include/nlm/i386-ext.h116
-rw-r--r--include/nlm/internal.h309
-rw-r--r--include/nlm/ppc-ext.h163
-rw-r--r--include/nlm/sparc32-ext.h120
-rw-r--r--include/oasys.h152
-rw-r--r--include/objalloc.h116
-rw-r--r--include/obstack.h593
-rw-r--r--include/opcode/ChangeLog1873
-rw-r--r--include/opcode/a29k.h285
-rw-r--r--include/opcode/alpha.h238
-rw-r--r--include/opcode/arc.h274
-rw-r--r--include/opcode/arm.h294
-rw-r--r--include/opcode/cgen.h1380
-rw-r--r--include/opcode/convex.h1711
-rw-r--r--include/opcode/d10v.h194
-rw-r--r--include/opcode/d30v.h273
-rw-r--r--include/opcode/h8300.h604
-rw-r--r--include/opcode/hppa.h486
-rw-r--r--include/opcode/i386.h1063
-rw-r--r--include/opcode/i860.h491
-rw-r--r--include/opcode/i960.h509
-rw-r--r--include/opcode/m68k.h315
-rw-r--r--include/opcode/m88k.h923
-rw-r--r--include/opcode/mips.h723
-rw-r--r--include/opcode/mn10200.h110
-rw-r--r--include/opcode/mn10300.h138
-rw-r--r--include/opcode/np1.h422
-rw-r--r--include/opcode/ns32k.h491
-rw-r--r--include/opcode/pn.h282
-rw-r--r--include/opcode/ppc.h248
-rw-r--r--include/opcode/pyr.h287
-rw-r--r--include/opcode/sparc.h240
-rw-r--r--include/opcode/tahoe.h213
-rw-r--r--include/opcode/tic30.h691
-rw-r--r--include/opcode/tic80.h277
-rw-r--r--include/opcode/v850.h166
-rw-r--r--include/opcode/vax.h382
-rw-r--r--include/os9k.h169
-rw-r--r--include/progress.h37
-rw-r--r--include/regs/ChangeLog0
-rw-r--r--include/remote-sim.h321
-rw-r--r--include/splay-tree.h116
-rw-r--r--include/symcat.h40
-rw-r--r--include/wait.h63
-rwxr-xr-xinstall-sh251
-rw-r--r--intl/ChangeLog1022
-rw-r--r--intl/ChangeLog.Cygnus30
-rw-r--r--intl/Makefile.in214
-rw-r--r--intl/acconfig.h14
-rw-r--r--intl/aclocal.m4387
-rw-r--r--intl/bindtextdom.c199
-rw-r--r--intl/cat-compat.c262
-rw-r--r--intl/config.in128
-rwxr-xr-xintl/configure2950
-rw-r--r--intl/configure.in10
-rw-r--r--intl/dcgettext.c593
-rw-r--r--intl/dgettext.c59
-rw-r--r--intl/explodename.c181
-rw-r--r--intl/finddomain.c189
-rw-r--r--intl/gettext.c70
-rw-r--r--intl/gettext.h105
-rw-r--r--intl/gettextP.h73
-rw-r--r--intl/hash-string.h63
-rw-r--r--intl/intl-compat.c76
-rw-r--r--intl/intlh.inst.in111
-rw-r--r--intl/l10nflist.c409
-rw-r--r--intl/libgettext.h182
-rw-r--r--intl/libintl.glibc111
-rw-r--r--intl/linux-msg.sed100
-rw-r--r--intl/loadinfo.h58
-rw-r--r--intl/loadmsgcat.c199
-rw-r--r--intl/localealias.c378
-rw-r--r--intl/po2tbl.sed.in102
-rw-r--r--intl/textdomain.c106
-rw-r--r--intl/xopen-msg.sed104
-rw-r--r--libiberty/COPYING.LIB482
-rw-r--r--libiberty/ChangeLog3232
-rw-r--r--libiberty/Makefile.in247
-rw-r--r--libiberty/README65
-rw-r--r--libiberty/acconfig.h11
-rw-r--r--libiberty/alloca-conf.h24
-rw-r--r--libiberty/alloca.c505
-rw-r--r--libiberty/argv.c390
-rw-r--r--libiberty/asprintf.c57
-rw-r--r--libiberty/atexit.c18
-rw-r--r--libiberty/basename.c37
-rw-r--r--libiberty/bcmp.c49
-rw-r--r--libiberty/bcopy.c35
-rw-r--r--libiberty/bzero.c31
-rw-r--r--libiberty/calloc.c26
-rw-r--r--libiberty/choose-temp.c203
-rw-r--r--libiberty/clock.c91
-rw-r--r--libiberty/concat.c167
-rw-r--r--libiberty/config.h-vms13
-rw-r--r--libiberty/config.in203
-rw-r--r--libiberty/config.table60
-rw-r--r--libiberty/config/mh-aix9
-rw-r--r--libiberty/config/mh-beos7
-rw-r--r--libiberty/config/mh-cxux71
-rw-r--r--libiberty/config/mh-fbsd211
-rw-r--r--libiberty/config/mh-windows1
-rwxr-xr-xlibiberty/configure2850
-rw-r--r--libiberty/configure.bat14
-rw-r--r--libiberty/configure.in341
-rw-r--r--libiberty/copysign.c140
-rw-r--r--libiberty/cplus-dem.c4535
-rw-r--r--libiberty/fdmatch.c73
-rw-r--r--libiberty/floatformat.c403
-rw-r--r--libiberty/fnmatch.c225
-rw-r--r--libiberty/getcwd.c54
-rw-r--r--libiberty/getopt.c1056
-rw-r--r--libiberty/getopt1.c190
-rw-r--r--libiberty/getpagesize.c96
-rw-r--r--libiberty/getruntime.c90
-rw-r--r--libiberty/hex.c33
-rw-r--r--libiberty/index.c11
-rw-r--r--libiberty/insque.c50
-rw-r--r--libiberty/makefile.dos29
-rw-r--r--libiberty/makefile.vms33
-rw-r--r--libiberty/memchr.c60
-rw-r--r--libiberty/memcmp.c38
-rw-r--r--libiberty/memcpy.c28
-rw-r--r--libiberty/memmove.c18
-rw-r--r--libiberty/memset.c19
-rw-r--r--libiberty/mkstemps.c128
-rw-r--r--libiberty/mpw-config.in7
-rw-r--r--libiberty/mpw-make.sed51
-rw-r--r--libiberty/mpw.c1010
-rw-r--r--libiberty/msdos.c15
-rw-r--r--libiberty/objalloc.c291
-rw-r--r--libiberty/obstack.c593
-rw-r--r--libiberty/pexecute.c738
-rw-r--r--libiberty/random.c377
-rw-r--r--libiberty/rename.c22
-rw-r--r--libiberty/rindex.c11
-rw-r--r--libiberty/sigsetmask.c30
-rw-r--r--libiberty/spaces.c78
-rw-r--r--libiberty/splay-tree.c368
-rw-r--r--libiberty/strcasecmp.c82
-rw-r--r--libiberty/strchr.c34
-rw-r--r--libiberty/strdup.c10
-rw-r--r--libiberty/strerror.c831
-rw-r--r--libiberty/strncasecmp.c82
-rw-r--r--libiberty/strrchr.c34
-rw-r--r--libiberty/strsignal.c644
-rw-r--r--libiberty/strstr.c51
-rw-r--r--libiberty/strtod.c122
-rw-r--r--libiberty/strtol.c143
-rw-r--r--libiberty/strtoul.c110
-rw-r--r--libiberty/tmpnam.c39
-rw-r--r--libiberty/vasprintf.c172
-rw-r--r--libiberty/vfork.c8
-rw-r--r--libiberty/vfprintf.c21
-rw-r--r--libiberty/vmsbuild.com165
-rw-r--r--libiberty/vprintf.c15
-rw-r--r--libiberty/vsprintf.c55
-rw-r--r--libiberty/waitpid.c11
-rw-r--r--libiberty/xatexit.c82
-rw-r--r--libiberty/xexit.c36
-rw-r--r--libiberty/xmalloc.c173
-rw-r--r--libiberty/xstrdup.c22
-rw-r--r--libiberty/xstrerror.c56
-rwxr-xr-xltconfig2822
-rw-r--r--ltmain.sh3782
-rw-r--r--makeall.bat16
-rw-r--r--makefile.vms71
-rwxr-xr-xmissing190
-rwxr-xr-xmkinstalldirs36
-rwxr-xr-xmove-if-change32
-rw-r--r--mpw-README376
-rw-r--r--mpw-build.in204
-rw-r--r--mpw-config.in113
-rw-r--r--mpw-configure448
-rw-r--r--mpw-install122
-rw-r--r--opcodes/ChangeLog5033
-rw-r--r--opcodes/Makefile.am348
-rw-r--r--opcodes/Makefile.in858
-rw-r--r--opcodes/a29k-dis.c353
-rw-r--r--opcodes/acinclude.m41
-rw-r--r--opcodes/aclocal.m41111
-rw-r--r--opcodes/alpha-dis.c213
-rw-r--r--opcodes/alpha-opc.c1546
-rw-r--r--opcodes/arc-dis.c267
-rw-r--r--opcodes/arc-opc.c1131
-rw-r--r--opcodes/arm-dis.c887
-rw-r--r--opcodes/arm-opc.h281
-rw-r--r--opcodes/cgen-asm.c359
-rw-r--r--opcodes/cgen-dis.c226
-rw-r--r--opcodes/cgen-opc.c597
-rw-r--r--opcodes/config.in135
-rwxr-xr-xopcodes/configure4754
-rw-r--r--opcodes/configure.bat24
-rw-r--r--opcodes/configure.in211
-rw-r--r--opcodes/d10v-dis.c301
-rw-r--r--opcodes/d10v-opc.c334
-rw-r--r--opcodes/d30v-dis.c399
-rw-r--r--opcodes/d30v-opc.c500
-rw-r--r--opcodes/dep-in.sed20
-rw-r--r--opcodes/dis-buf.c104
-rw-r--r--opcodes/disassemble.c248
-rw-r--r--opcodes/fr30-asm.c560
-rw-r--r--opcodes/fr30-desc.c1643
-rw-r--r--opcodes/fr30-desc.h266
-rw-r--r--opcodes/fr30-dis.c630
-rw-r--r--opcodes/fr30-ibld.c1506
-rw-r--r--opcodes/fr30-opc.c1368
-rw-r--r--opcodes/fr30-opc.h150
-rw-r--r--opcodes/h8300-dis.c457
-rw-r--r--opcodes/h8500-dis.c347
-rw-r--r--opcodes/h8500-opc.h3836
-rw-r--r--opcodes/hppa-dis.c631
-rw-r--r--opcodes/i386-dis.c3268
-rw-r--r--opcodes/i960-dis.c914
-rw-r--r--opcodes/m10200-dis.c341
-rw-r--r--opcodes/m10200-opc.c360
-rw-r--r--opcodes/m10300-dis.c548
-rw-r--r--opcodes/m10300-opc.c683
-rw-r--r--opcodes/m32r-asm.c556
-rw-r--r--opcodes/m32r-desc.c1150
-rw-r--r--opcodes/m32r-desc.h219
-rw-r--r--opcodes/m32r-dis.c557
-rw-r--r--opcodes/m32r-ibld.c1120
-rw-r--r--opcodes/m32r-opc.c1331
-rw-r--r--opcodes/m32r-opc.h126
-rw-r--r--opcodes/m32r-opinst.c562
-rw-r--r--opcodes/m68k-dis.c1243
-rw-r--r--opcodes/m68k-opc.c2090
-rw-r--r--opcodes/m88k-dis.c330
-rw-r--r--opcodes/makefile.vms42
-rw-r--r--opcodes/mcore-dis.c250
-rw-r--r--opcodes/mcore-opc.h202
-rw-r--r--opcodes/mips-dis.c1068
-rw-r--r--opcodes/mips-opc.c772
-rw-r--r--opcodes/mips16-opc.c226
-rw-r--r--opcodes/mpw-config.in27
-rw-r--r--opcodes/mpw-make.sed25
-rw-r--r--opcodes/ns32k-dis.c894
-rw-r--r--opcodes/opintl.h30
-rw-r--r--opcodes/po/Make-in251
-rw-r--r--opcodes/po/POTFILES.in69
-rw-r--r--opcodes/po/opcodes.pot242
-rw-r--r--opcodes/ppc-dis.c238
-rw-r--r--opcodes/ppc-opc.c3124
-rw-r--r--opcodes/sh-dis.c387
-rw-r--r--opcodes/sh-opc.h573
-rw-r--r--opcodes/sparc-dis.c969
-rw-r--r--opcodes/sparc-opc.c1920
-rw-r--r--opcodes/stamp-h.in1
-rw-r--r--opcodes/sysdep.h42
-rw-r--r--opcodes/tic30-dis.c711
-rw-r--r--opcodes/tic80-dis.c397
-rw-r--r--opcodes/tic80-opc.c1216
-rw-r--r--opcodes/v850-dis.c381
-rw-r--r--opcodes/v850-opc.c786
-rw-r--r--opcodes/vax-dis.c299
-rw-r--r--opcodes/w65-dis.c118
-rw-r--r--opcodes/w65-opc.h548
-rw-r--r--opcodes/z8k-dis.c574
-rw-r--r--opcodes/z8k-opc.h4438
-rw-r--r--opcodes/z8kgen.c1313
-rw-r--r--setup.com8
-rwxr-xr-xsymlink-tree48
-rwxr-xr-xylwrap123
771 files changed, 426852 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 00000000000..dab6c3245ba
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,30 @@
+*-all
+*-co
+*-dirs
+*-done
+*-install-info
+*-src
+*-stamp-*
+*-tagged
+blockit
+cfg-paper.info
+config.status
+configure.aux
+configure.cp
+configure.cps
+configure.dvi
+configure.fn
+configure.fns
+configure.ky
+configure.kys
+configure.log
+configure.pg
+configure.pgs
+configure.toc
+configure.tp
+configure.tps
+configure.vr
+configure.vrs
+dir.info
+Makefile
+lost+found
diff --git a/COPYING b/COPYING
new file mode 100644
index 00000000000..60549be514a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/COPYING.LIB b/COPYING.LIB
new file mode 100644
index 00000000000..161a3d1d47b
--- /dev/null
+++ b/COPYING.LIB
@@ -0,0 +1,482 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 00000000000..2604b21d5c6
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,6537 @@
+1999-04-30 Tom Tromey <tromey@cygnus.com>
+
+ * ltmain.sh: [mode link] Always use CC given by ltconfig.
+
+1999-04-23 Tom Tromey <tromey@cygnus.com>
+
+ * ltconfig, ltmain.sh: Update to libtool 1.2f.
+
+1999-04-20 Drew Moseley <dmoseley@cygnus.com>
+
+ * configure.in (noconfigdirs): Don't build libstub for arm-elf targets.
+ (noconfigdirs): Don't build any bsp stuff for for arm-oabi targets.
+ Bad merge removed these two changes.
+
+1999-04-11 Richard Henderson <rth@cygnus.com>
+
+ * configure.in (i?86-*-beos*): Do config gperf; don't config
+ gdb, newlib, or libgloss.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * config.sub: Add support for mcore targets.
+
+1999-04-07 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (d30v-*): Use config/mt-d30v as makefile fragment,
+ not mt-ospace, in order to shut up assembler warning about using
+ symbols that are named the same as registers.
+
+1999-04-07 Drew Moseley <dmoseley@cygnus.com>
+
+ * Makefile.in (all-target-cygmon): Added all-target-bsp to the
+ dependency list for all-target-cygmon.
+
+1999-04-05 Doug Evans <devans@casey.cygnus.com>
+
+ * config-ml.in: Check $host, not $target, for selective multilibs.
+ (arm-*-*): Allow disabling of biendian, h/w fp, 26 bit apcs,
+ thumb interworking, and underscore prefix multilibs.
+
+1999-04-04 Ian Lance Taylor <ian@zembu.com>
+
+ * missing: Update to version from current automake.
+
+Fri Apr 2 15:11:32 1999 H.J. Lu (hjl@gnu.org)
+
+ * configure (gxx_include_dir): Removed.
+
+ * configure.in (gxx_include_dir): Handle it.
+ * Makefile.in: Likewise.
+
+1999-03-29 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * config.sub (mips64vr4111,mips64vr4111el) Add.
+
+1999-03-21 Ben Elliston <bje@cygnus.com>
+
+ * config.guess: Correct typo for detecting ELF on FreeBSD.
+
+Thu Mar 18 00:17:50 1999 Mark Elbrecht <snowball3@usa.net>
+
+ * config/mh-go32: Delete.
+ * config/mh-djgpp: New. Renamed from mh-go32.
+ * configure.in (pc-msdosdjgpp): Set host_makefile_frag to
+ config/mh-djgpp.
+
+Thu Mar 11 18:37:23 1999 Drew Moseley <dmoseley@cygnus.com>
+
+ * Makefile.in (all-target-bsp): Added all-gcc all-binutils and
+ all-target-newlib to dependency list for all-target-bsp.
+
+Thu Mar 11 01:19:31 1999 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * config.sub: Add i386-uwin support.
+ * config.guess: Likewise.
+
+Thu Mar 11 01:07:55 1999 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ * configure.in: cleanup, add mh-*pic handling for arm, special
+ case powerpc*-*-aix*
+
+Wed Mar 10 18:35:07 1999 Jeff Johnston <jjohnstn@cygnus.com>
+
+ * configure.in (noconfigdirs): Removed target-libgloss so libnosys.a
+ can be built.
+
+Wed Mar 10 17:39:09 1999 Drew Moseley <dmoseley@cygnus.com>
+
+ * configure.in: Added bsp support to arm-*-coff and arm-*-elf
+ targets.
+
+1999-03-02 Nick Clifton <nickc@cygnus.com>
+
+ * config.sub: Rename CYGNUS LOCAL to EGCS LOCAL
+
+Sun Feb 28 02:20:00 1999 Geoffrey Noer <noer@cygnus.com>
+
+ * config.sub: Check for "cygwin*" rather than "cygwin32*"
+
+1999-02-24 Nick Clifton <nickc@cygnus.com>
+
+ * config.sub: Fix typo in arm recognition.
+
+Wed Feb 24 13:51:40 1999 Drew Moseley <dmoseley@cygnus.com>
+
+ * configure.in (noconfigdirs): Changed target_configdirs to
+ include target-bsp only for m68k-*-elf* and m68k-*-coff*
+ rather than m68k-*-* since it is not known to work on
+ m68k-aout. Ditto for arm-*-*oabi.
+
+Wed Feb 24 12:52:17 1999 Stan Shebs <shebs@andros.cygnus.com>
+
+ * configure.in (*-*-windows*): Remove, no longer used.
+ * config/mh-windows: Ditto.
+
+1999-02-19 Ben Elliston <bje@cygnus.com>
+
+ * config.guess: Automatically recognise ELF on FreeBSD. From Niall
+ Smart and improved by Andrew Cagney.
+
+Thu Feb 18 19:55:09 1999 Marc Espie <espie@cvs.openbsd.org>
+
+ * config.guess: Recognize openbsd-*-hppa.
+
+Wed Feb 17 01:38:59 1999 H.J. Lu (hjl@gnu.org)
+
+ * Makefile.in (REALLY_SET_LIB_PATH): Append $$$(RPATH_ENVVAR)
+ only if it is not empty.
+
+1999-02-17 Nick Clifton <nickc@cygnus.com>
+
+ Patch from: Scott Bambrough <scottb@corelcomputer.com>
+
+ * config.guess: Modified to recognize uname's armv* syntax.
+
+ * config.sub: Modified to recognize uname's armv* syntax.
+
+1999-02-17 Mark Salter <msalter@cygnus.com>
+
+ * configure.in: Added target-bsp for sparclite.
+
+Mon Feb 8 14:17:24 1999 Richard Henderson <rth@cygnus.com>
+
+ * config.sub: Recognize alphapca5[67] and up to alphaev8.
+
+1999-02-08 Nick Clifton <nickc@cygnus.com>
+
+ * configure.in: Add support for strongarm port.
+ * config.sub: Add support for strongarm target.
+
+Sun Feb 7 18:01:54 1999 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * configure.in (*-*-cygwin32*): Use config/mh-cygwin instead of
+ the old name config/mh-cygwin32.
+ Enable texinfo.
+
+Thu Feb 4 20:43:25 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Do build ld for ix86 Solaris.
+
+Tue Feb 2 19:46:40 1999 Jim Wilson <wilson@cygnus.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): Set AR to $AR instead of
+ $AR_FOR_TARGET. Likewise for RANLIB.
+
+Tue Feb 2 20:05:05 1999 Catherine Moore <clm@cygnus.com>
+
+ * config.sub (oabi): Recognize.
+ * configure.in (arm-*-oabi): Handle.
+
+Sat Jan 30 06:09:00 1999 Robert Lipe (robertlipe@usa.net)
+
+ * config.guess: Improve detection of i686 on UnixWare 7.
+
+Sat Jan 30 08:04:00 1999 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * config.guess: Add support for i386-pc-interix.
+ * config.sub: Likewise.
+ * configure.in: Likewise.
+ * config/mh-interix: New file.
+
+Mon Jan 18 13:59:20 1999 Christopher Faylor <cgf@cygnus.com>
+
+ * Makefile.in: Remove unneeded all-target-libio from
+ from all-target-winsup target since it is now unneeded.
+ Add all-target-libtermcap in its place since it is now
+ needed.
+
+Wed Dec 30 20:34:52 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * configure.in: makefile stub for cygwin target is probably
+ unnecessary. Remove it for now.
+ * config/mt-cygwin: Remove.
+
+Wed Dec 30 01:13:03 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * configure.in: libtermcap.a should be built when cygwin is the
+ target as well as the host.
+ * config.guess: Allow mixed case in cygwin uname output.
+ * Makefile.in: Add libtermcap target.
+ * config/mt-cygwin: New file. libtermcap target info.
+
+Tue Dec 15 17:02:58 1998 Bob Manson <manson@charmed.cygnus.com>
+
+ * configure.in: Add cygmon for x86-coff and x86-elf. Configure
+ cygmon for all sparclite targets, regardless of object format.
+
+1998-12-15 Mark Salter <msalter@cygnus.com>
+
+ * configure.in: Added target-bsp for several target architectures.
+
+ * Makefile.in: Added rules for bsp.
+
+Wed Dec 23 00:20:50 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub: Clean up handling of hppa2.0.
+
+Tue Dec 22 23:56:31 1998 Rodney Brown (rodneybrown@pmsc.com)
+
+ * config.guess: Use C code to identify more HP machines.
+
+Thu Dec 17 01:22:30 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub: Handle hppa2.0.
+
+Fri Dec 4 01:34:02 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess: Improve detection of hppa2.0 processors.
+
+Fri Dec 4 01:33:05 1998 Niall Smart <nialls@euristix.ie>
+
+ * config.guess: Recognize FreeBSD using ELF automatically.
+
+1998-11-26 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure (skip-this-dir): Add handling for new shell script, which
+ might be created by a sub-directory's configure to indicate, this particular
+ directory is "unwanted".
+ * Makefile.in ($(CONFIGURE_TARGET_MODULES)): Likewise.
+
+
+Wed Nov 18 18:28:45 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * ltconfig: import from libtool, after changing libtool to
+ account for the cygwin name change.
+
+Wed Nov 18 18:09:14 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * Makefile.in: CC_FOR_TARGET and CXX_FOR_TARGET should also
+ include newlib/libc/sys/cygwin and newlib/libc/sys/cygwin32.
+
+Wed Nov 18 20:13:29 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * configure.in: Add libtermcap to list of cygwin dependencies.
+
+Tue Nov 17 16:57:51 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * Makefile.in: modify CC_FOR_TARGET and CXX_FOR_TARGET so that
+ they include winsup/include when it's a cygwin target.
+
+1998-11-12 Tom Tromey <tromey@cygnus.com>
+
+ * configure.in (host_tools): Added zip.
+ * Makefile.in (all-target-libjava): Depend on all-zip.
+ (all-zip): New target.
+ (ALL_MODULES): Added all-zip.
+ (NATIVE_CHECK_MODULES): Added check-zip.
+ (INSTALL_MODULES): Added install-zip.
+ (CLEAN_MODULES): Added clean-zip.
+
+Thu Nov 12 17:27:21 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * Makefile.in: lose "32" from comment about cygwin.
+
+Thu Nov 5 15:00:31 1998 Nick Clifton <nickc@cygnus.com>
+
+ * configure.in: Use -Os to build target libraries for the fr30.
+
+Wed Nov 4 18:49:43 1998 Dave Brolley <brolley@cygnus.com>
+
+ * config.sub: Add fr30.
+
+Mon Nov 2 15:19:33 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: drop "32" from config/mh-cygwin32. Check
+ cygwin* instead of cygwin32*.
+ * config.sub: Check cygwin* instead of cygwin32*.
+
+1998-10-20 Syd Polk <spolk@cygnus.com>
+
+ * Makefile.in configure.in: Add the ability to use tcl8.1 and tk8.1
+ if desired.
+
+Sun Oct 18 18:34:50 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.if (cxx_interface, libstdcxx_interface): Do not try to set
+ these if the appropriate directories and files to not exist.
+
+Wed Oct 14 10:29:06 1998 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (DEVO_SUPPORT): Add config.if.
+
+Tue Oct 13 09:17:06 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub: Bring back lost sparcv9.
+
+Wed Sep 30 22:20:50 1998 Robert Lipe <robertl@dgii.com>
+
+ * config.sub: Add support for i[34567]86-pc-udk.
+ * configure.in: Likewise.
+
+Wed Sep 30 19:23:48 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * Makefile.in: add bzip2 package building bits for user
+ tools module
+ * configure.in: ditto
+
+1998-09-30 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure.in (target_subdir): Remove duplicate line.
+
+Tue Sep 29 22:45:41 1998 Felix Lee <flee@cygnus.com>
+
+ * Makefile.in (all-automake): fix dependencies.
+
+Mon Sep 28 04:04:27 1998 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in: Minor cleanups for building in the $(target_alias)
+ subdir.
+
+1998-09-22 Jim Wilson <wilson@cygnus.com>
+
+ * Makefile.in (bootstrap): Set r and s before make all. Use
+ BASE_FLAGS_TO_PASS in make all.
+ (cross): Likewise.
+
+1998-09-20 Mark Mitchell <mark@markmitchell.com>
+
+ * Makefile.in (bootstrap): Pass TARGET_FLAGS_TO_PASS to `make all'.
+
+
+Sun Sep 20 00:13:02 1998 Richard Henderson <rth@cygnus.com>
+
+ * config.sub: Fix typo in last change.
+
+1998-09-19 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
+
+ * config.sub: Add support for C4x target.
+ * configure.in: Likewise.
+
+1998-09-13 David S. Miller <davem@pierdol.cobaltmicro.com>
+
+ * config.sub: Recognize sparcv9 just like sparc64.
+
+Wed Sep 9 15:44:52 1998 Robert Lipe <robertl@dgii.com>
+
+ * config.guess: Match "Pent II" or "PentII" for OpenServer.
+
+Tue Sep 8 01:18:39 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess: Correctly identify Pentium II sco boxes.
+
+ * config.guess: Fix "tr" code. From Weiwen Liu.
+
+Sat Sep 5 13:56:52 1998 John Hughes <john@Calva.COM>
+
+ * configure.in: Do not assume x86-svr4 or x86-unixware can handle
+ stabs.
+
+Sat Sep 5 02:12:02 1998 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (TARGET_CONFIGDIRS): Add libchill.
+ (ALL_TARGET_MODULES): Add all-target-libchill.
+ (CONFIGURE_TARGET_MODULES, CHECK_TARGET_MODULES): Similarly.
+ (INSTALL_TARGET_MODULES, CLEAN_TARGET_MODULES): Similarly.
+ (all-target-libchill): Add dependencies.
+ * configure.in (target_libs): Add libchill.
+
+Sun Aug 30 22:27:02 1998 Lutz Wohlrab <lutz.wohlrab@informatik.tu-chemnitz.de>
+
+ * config.guess: Avoid assumptions about "tr" behaves when
+ LANG is set to something other than English.
+
+Sun Aug 30 22:14:44 1998 H.J. Lu (hjl@gnu.org)
+
+ * configure (gxx_include_dir): Changed to
+ '${prefix}/include/g++'-${libstdcxx_interface}.
+
+ * config.if: New to determine the interfaces.
+
+Sun Aug 30 21:15:19 1998 Mark Klein (mklein@dis.com)
+
+ * config.guess: Detect and handle MPE/IX.
+ * config.sub: Deal with MPE/IX.
+
+Sat Aug 29 14:32:55 1998 David Edelsohn <edelsohn@mhpcc.edu>
+
+ * configure.in: Use mh-aix43.
+
+1998-07-29 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure: Fix --without/--disable cases for gxx-include-dir.
+
+Fri Aug 28 12:28:26 1998 Per Bothner <bothner@cygnus.com>
+
+ * mdata-sh: Imported. Needed for automake support.
+
+Thu Aug 13 12:49:29 1998 H.J. Lu <hjl@gnu.org>
+
+ * Makefile.in (taz): Try "chmod -R og=u ." before
+ "chmod og=u `find . -print`".
+
+Fri Jul 31 09:38:33 1998 Catherine Moore <clm@cygnus.com>
+
+ * configure.in: Add arm-elf and thumb-elf support.
+
+Mon Jul 27 16:23:58 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * Makefile.in: Undo previous patch.
+
+Fri Jul 24 19:55:24 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * Makefile.in (INSTALL_TARGET): Move EXTRA_TARGET_HOST_INSTALL_MODULES
+ to here ...
+ (install-no-fixedincludes): and here
+ (INSTALL_MODULES): ... from here.
+
+Fri Jul 24 17:01:42 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Merge with FSF.
+
+ * config.guess: Merge with FSF.
+
+Fri Jul 24 08:43:36 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * configure (extraconfigdirs): New variable.
+ (SUBDIRS): Add extraconfigdirs and recurse on them too.
+ * Makefile.in (all): Move higher in file.
+ (EXTRA_TARGET_HOST_ALL_MODULES): New variable.
+ (EXTRA_TARGET_HOST_{INSTALL,CHECK}_MODULES): New variables.
+ (ALL_MODULES): Add EXTRA_TARGET_HOST_ALL_MODULES.
+ (CROSS_CHECK_MODULES): Add EXTRA_TARGET_HOST_CHECK_MODULES.
+ (INSTALL_MODULES): Add EXTRA_TARGET_HOST_INSTALL_MODULES.
+
+1998-07-23 Brendan Kehoe <brendan@cygnus.com>
+
+ * Makefile.in (all-target-libjava): Depend on all-gcc and
+ all-target-newlib.
+ (configure-target-libjava): Depend on $(ALL_GCC).
+
+Sat Jul 18 14:32:43 CDT 1998 Robert Lipe <robertl@dgii.com>
+
+ * config.guess: (*-pc-sco3.2v5) Add detection for Pentium II.
+ (*-pc-unixware7) Add detection for Pentium II, Pentium Pro.
+
+Fri Jul 17 13:30:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ylwrap: Change absolute path checks to check for DOS style path
+ names.
+
+ * ylwrap: Don't use a full path name if the source file is in the
+ same directory. From hjl@lucon.org (H.J. Lu).
+
+ * config-ml.in: Default to being verbose, to match Feb 18 change to
+ configure.
+
+Thu Jul 16 12:29:51 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ Brought over from egcs:
+
+ Sat Jun 27 22:46:32 1998 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in (target_subdir): Set to ${target_alias} instead
+ of "libraries".
+
+ Mon Sep 1 16:45:44 1997 Jim Wilson <wilson@cygnus.com>
+
+ * configure.in (target_subdir): Set to libraries if enable_multilib.
+
+Wed Jul 15 01:00:54 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If there are any
+ multilibs, force reconfiguration the first time we create
+ multilib.out in a subdirectory, in case TARGET_SUBDIR is `.'.
+
+Tue Jul 14 23:41:03 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Strip any --no option from CONFIG_ARGUMENTS, to
+ avoid confusion with --no-recursion.
+
+Tue Jul 14 15:37:41 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: Win32 hosts shouldn't use install -x
+ * install-sh: remove -x option, and special .exe-handling
+ hack.
+
+Tue Jul 14 15:28:41 1998 Richard Henderson <rth@cygnus.com>
+
+ * config.guess: Recognize i586-pc-beos.
+ * configure.in: Don't build some bits for beos.
+
+Tue Jul 14 13:22:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: If CC is set but CFLAGS is not, and CC is gcc, make
+ CFLAGS default to -O2.
+
+ * ltmain.sh: Add some hacks to make SunOS --enable-shared work
+ when using GNU ld.
+
+Fri Jul 10 13:18:23 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltmain.sh: Correct install when using a different shell.
+
+Tue Jul 7 15:24:38 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Update to libtool 1.2b.
+
+Thu Jul 2 13:57:36 1998 Klaus Kaempf <kkaempf@rmi.de>
+
+ * makefile.vms: Update to build binutils/makefile.vms. Add install
+ target.
+
+Wed Jul 1 16:45:21 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig: Update to correct AIX handling.
+
+Sat Jun 27 22:46:32 1998 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Add TARGET_SUBDIR.
+
+ * configure.in (target_subdir): Set to ${target_alias} instead
+ of "libraries".
+
+1998-06-26 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Add gcc_version_trigger.
+ (Makefile): Depend on $(gcc_version_trigger).
+
+ * configure (gcc_version): Change default initializer to empty
+ string.
+ (gcc_version_trigger): New variable; pass this variable down
+ to subdir configures to enable them checking gcc's version
+ themselves. Emit make macros for both gcc_version vars.
+ (topsrcdir): Initialize reliably.
+ (recursion line): Remove --with-gcc-version=${gcc_version}.
+
+1998-06-24 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure (enable_version_specific_runtime_libs): Implement new flag
+ --enable-version-specific-runtime-libs which installs C++ runtime stuff
+ in $(libsubdir); emit definition in each generated Makefile.
+ (gxx_include_dir): Initialize depending on
+ $enable_version_specific_runtime_libs.
+
+1998-06-24 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure (gcc_version): Initialize properly depending on
+ how and where configure is started.
+ (recursion line): Pass a --with-gcc-version=${gcc_version}
+ to configures in subdirs.
+
+Wed Jun 24 16:01:59 1998 John Metzler <jmetzler@cygnus.com>
+
+ * configure.in (noconfigdirs): Add configure pattern for mips tx39
+ cygmon
+
+Tue Jun 23 22:42:32 1998 Mark Alexander <marka@cygnus.com>
+
+ * configure.in: Add cygmon and libstub support for mn10200.
+
+1998-06-19 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure (gcc_version): Add new variable describing the
+ particular gcc version we're building.
+ * Makefile.in (libsubdir): Add new macro for the directory
+ in which the compiler finds executables, libraries, etc.
+ (BASE_FLAGS_TO_PASS): Pass down gcc_version, target_alias
+ and libsubdir.
+
+Fri Jun 19 02:36:59 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
+
+ * Makefile.in (local-clean): remove *.log
+ (warning.log): built with warn_summary from build.log
+ (mail-report.log): run test_summary
+ (mail-report-with-warnings.log): run test_summary including
+ warning.log in the report
+
+Thu Jun 18 11:26:03 1998 Robert Lipe <robertl@dgii.com>
+
+ * config.guess: Detection of Pentium II for *-sco-3.2v5*.
+
+Mon Jun 15 14:53:54 1998 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * Makefile.in (grep): Grep no longer depends on libiberty.
+
+Fri Jun 12 14:03:34 1998 Syd Polk <spolk@cygnus.com>
+
+ * Makefile.in: all-snavigator needs all-libgui.
+
+Thu Jun 11 19:43:47 1998 Mark Alexander <marka@cygnus.com>
+
+ * configure.in: Add cygmon and libstub support for mn10300.
+
+Wed Jun 10 11:19:47 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * missing: Update to version from automake 1.3.
+
+ * ltmain.sh: On installation, don't get confused if the same name
+ appears more than once in the list of library names.
+
+Wed Jun 3 14:51:42 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Accept m68060 and m5200 as CPU names.
+
+Mon Jun 1 17:25:16 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Use && rather than using -a in test, because odd
+ strings can confuse test.
+ * configure.in: Likewise.
+
+Thu May 28 19:31:13 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Bring in Visual C++ support.
+
+Sat May 23 23:44:13 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
+
+ * Makefile.in (boostrap2-lean, bootstrap3-lean,
+ bootstrap4-lean): new targets
+
+Mon May 11 23:11:34 1998 Jeffrey A Law (law@cygnus.com)
+
+ * COPYING.LIB: Update FSF address.
+
+Fri May 8 01:30:20 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Update to libtool 1.2a.
+
+ * Makefile.in (GASB_SUPPORT_DIRS): Remove intl; already included via
+ GAS_SUPPORT_DIRS.
+
+Thu May 7 17:27:35 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Avoid producing a version number if
+ -version-info was not used.
+
+Tue May 5 18:02:24 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Add --with-newlib to CONFIG_ARGUMENTS if we are
+ building with newlib.
+
+1998-04-30 Paul Eggert <eggert@twinsun.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): Remove backslash at end;
+ Solaris `make' causes it to continue to next definition.
+
+Tue Apr 28 18:11:24 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Change alpha to alpha* in several places.
+
+Tue Apr 28 07:42:00 1998 Mark Alexander <marka@cygnus.com>
+
+ * config.sub: Recognize sparc86x.
+
+Tue Apr 28 07:35:02 1998 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (--enable-target-optspace): Remove debug echo.
+
+Thu Apr 23 21:31:16 1998 Jim Wilson <wilson@cygnus.com>
+
+ * configure: Set CXXFLAGS from CXXFLAGS, not CFLAGS.
+
+Thu Apr 23 12:26:38 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig: Update cygwin32 support.
+
+ * Makefile.in (GAS_SUPPORT_DIRS): Add intl.
+ (BINUTILS_SUPPORT_DIRS, GASB_SUPPORT_DIRS): Likewise.
+ (GDB_SUPPORT_DIRS): Likewise.
+
+Wed Apr 22 12:30:10 1998 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (target_makefile_frag): If --enable-target-optspace,
+ use -Os to compile target libraries rather than -O2. Default to
+ using -Os for d10v and m32r if --{enable,disable}-target-optspace is
+ not used.
+ * configure.in (target_cflags): Ditto for d30v.
+
+Tue Apr 21 23:06:54 1998 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in (all-bfd): Depend on all-intl.
+ (all-binutils): Likewise.
+ (all-gas): Likewise.
+ (all-gprof): Likewise.
+ (all-ld): Likewise.
+
+
+1998-04-19 Brendan Kehoe <brendan@cygnus.com>
+
+ * configure.in (host_tools): Fix typo, lbtool -> libtool.
+
+Fri Apr 17 16:20:42 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (all-bfd): Depend upon all-libiberty.
+
+ * ltconfig, ltmain.sh: Bring in newer cygwin32 support.
+
+Fri Apr 17 12:22:22 1998 Bob Manson <manson@charmed.cygnus.com>
+
+ * Makefile.in: Add libstub.
+
+ * configure.in: Ditto. Build libstub for targets that have cygmon
+ support.
+
+Tue Apr 14 18:01:55 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't set PICFLAG on ix86-cygwin32.
+
+Tue Apr 14 12:24:45 1998 J. Kean Johnston <jkj@sco.com>
+
+ * configure.in: Recognise i[3456]96-*-sysv5* as a valid host, and
+ use mh-sysv5 if specified. Support gprof on SCO Open Server.
+
+Tue Apr 14 11:33:51 1998 Krister Walfridsson <cato@df.lth.se>
+
+ * configure: Define DEFAULT_M4 by searching PATH.
+ * Makfile.in: Use DEFAULT_M4.
+
+Mon Apr 13 15:37:24 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig: Add cygwin32 support.
+
+ * Makefile.in, configure.in: Add libtool as a native only directory
+ to configure and build.
+
+Wed Apr 8 13:18:56 1998 Philippe De Muyter <phdm@macqel.be>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): XFOO lines shortened.
+
+Thu Apr 2 14:48:44 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * Makefile.in: add ash make rules
+ * configure.in: add ash to native_only and host_tools lists
+
+Thu Mar 26 12:53:20 1998 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in (all-gettext, all-intl): New targets.
+ (ALL_MODULES): Added all-gettext, all-intl.
+ (CROSS_CHECK_MODULES): Added check-gettext, check-intl.
+ (INSTALL_MODULES): Added install-gettext, install-intl.
+ (CLEAN_MODULES): Added clean-gettext, clean-intl.
+
+ * configure.in (host_tools): Added gettext.
+ (native_only): Likewise.
+ (noconfigdirs) [various cases]: Likewise.
+ (host_libs): Added intl.
+
+Wed Mar 25 11:49:12 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * Makefile.in: Revert yesterday's change.
+ (all-target-winsup): all-target-librx stays out of here.
+
+Tue Mar 24 16:58:29 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * Makefile.in (TARGET_CONFIGDIRS, ALL_TARGET_MODULES,
+ CONFIGURE_TARGET_MODULES, CHECK_TARGET_MODULES,
+ INSTALL_TARGET_MODULES, CLEAN_TARGET_MODULES, all-target-winsup):
+ Remove references to librx and libg++.
+
+Tue Mar 24 18:28:12 1998 Eric Mumpower <nocturne@cygnus.com>
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Pass $(lispdir) down to
+ recursive makes
+
+Tue Mar 24 11:37:45 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (CC_FOR_TARGET): Use $(TARGET_SUBDIR) when passing -B
+ for newlib directory.
+ (CXX_FOR_TARGET): Likewise.
+
+Mon Mar 23 11:30:21 1998 Jeffrey A Law (law@cygnus.com)
+
+ * ltconfig: Update after libtool/ltconfig.in change for
+ hpux11.
+
+Fri Mar 20 18:51:43 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Update to libtool 1.2.
+
+Fri Mar 20 09:32:14 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * Makefile.in (install-gcc): Don't specify LANGUAGES here.
+ (install-gcc-cross): Instead, override LANGUAGES here.
+
+1998-03-18 Dave Love <d.love@dl.ac.uk>
+
+ * Makefile.in ($(CONFIGURE_TARGET_MODULES)): Set CONFIG_SITE to a
+ non-existent file since /dev/null loses with bash 2.0/autoconf 2.12.
+
+Wed Mar 18 09:24:59 1998 Nick Clifton <nickc@cygnus.com>
+
+ * configure.in: Add Thumb-pe target.
+
+Tue Mar 17 16:59:00 1998 Syd Polk <spolk@cygnus.com>
+ * Makefile.in - changed sn targets to snavigator
+ * configure.in - changed sn targets to snavigator
+
+Tue Mar 17 10:33:28 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * config-ml.in: After building symlink tree call make distclean
+ if a Makefile got linked into ${ml_dir}/${ml_libdir}; this happens
+ to be the case for libiberty.
+
+Tue Mar 17 10:22:37 1998 H.J. Lu (hjl@gnu.ai.mit.edu)
+
+ * configure: When making link, also check the current
+ directory. The configure scripts may create one.
+
+Fri Mar 6 01:02:03 1998 Richard Henderson <rth@cygnus.com>
+
+ * config.sub: Accept alphapca56 and alphaev6 properly.
+
+Fri Mar 6 00:14:55 1998 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ * configure.in: Revert 3 Jan change for powerpc-linux-gnulibc1.
+
+
+Mon Feb 23 15:09:18 1998 Bruno Haible <bruno@linuix.mathematik.uni-karlsruhe.de
+
+ * config.sub (sco5): Fix typo.
+
+Mon Feb 23 14:46:06 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (INSTALL_MODULES): Move install-tcl before
+ install-itcl.
+ (install-itcl): Remove dependency on install-tcl.
+
+Mon Feb 23 09:53:28 1998 Mark Alexander <marka@cygnus.com>
+
+ * configure.in: Remove libgloss from noconfigdirs for MN10300.
+
+Fri Feb 20 16:47:24 1998 Tom Tromey <tromey@cygnus.com>
+
+ * configure: Don't let builds be done in source tree.
+
+Thu Feb 19 13:40:41 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't build libgui for a cygwin32 target when not on
+ a cygwin32 host.
+
+Wed Feb 18 12:29:00 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * configure (redirect): Set to null, so default behavior of
+ configure is now --verbose.
+
+1998-02-16 Dave Love <d.love@dl.ac.uk>
+
+ * Makefile.in ($(CONFIGURE_TARGET_MODULES)): Run configure with
+ CONFIG_SITE=/dev/null to forestall lossage with site configuration.
+
+Mon Feb 16 12:23:53 1998 Manfred Hollstein <Manfred.Hollstein@ks.sel.alcatel.de>
+
+ * Makefile.in (BASE_FLAGS_TO_PASS, EXTRA_TARGET_FLAGS): Really add
+ this change to sync Makefile.in with its ChangeLog entries.
+
+Thu Feb 12 15:03:08 1998 H.J. Lu <hjl@gnu.org>
+
+ * ltmain.sh (mkdir): Check that the directory doesn't exist
+ before we exit with error, so that we don't get races during
+ parallel builds.
+
+Sat Feb 7 15:19:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Update from libtool 1.0i.
+
+Fri Feb 6 01:33:52 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Don't pass PICFLAG and
+ PICFLAG_FOR_TARGET.
+ (EXTRA_TARGET_FLAGS): Don't pass PICFLAG_FOR_TARGET.
+
+ * configure: Emit a definition for the new macro enable_shared
+ into each Makefile.
+
+ * config/mh-sparcpic (PICFLAG): Define to properly according
+ to current multilib configuration.
+ * config/mt-sparcpic (PICFLAG_FOR_TARGET): Define to properly
+ according to current multilib configuration.
+
+Thu Feb 5 17:01:12 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * configure.in (host_tools, native_only): Add libtool.
+
+Wed Feb 4 16:53:58 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: add target-gperf to noconfigdirs for Cygwin32.
+ Fix typo in ming config comment.
+
+Wed Feb 4 18:56:13 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltconfig, ltmain.sh: Update from libtool 1.0h.
+
+Mon Feb 2 19:38:19 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Add tic30 cases, and map c30 to tic30.
+
+Fri Jan 30 17:18:32 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: Remove expect from noconfigdirs when target
+ is cygwin32. OK to build expect and dejagnu with Canadian
+ Cross.
+
+Wed Jan 28 12:58:49 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Do build expect, dejagnu, and cvssrc for a cygwin32
+ host.
+
+ * config.guess: Use ${UNAME_MACHINE} rather than i386 for cygwin32
+ and mingw32.
+
+Wed Jan 28 10:26:37 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Remove passing $(local_prefix)
+ here as it is not defined in the toplevel Makefile.
+
+Tue Jan 27 23:25:06 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure (package_makefile_rules_frag): New variable, which names
+ a file with generic rules, ...
+ Change comment to mention we now have FIVE parts.
+ * configure: Undo last change.
+
+Tue Jan 27 23:15:55 1998 Lassi A. Tuura <lat@iki.fi>
+
+ * config.guess: More accurate determination of HP processor types.
+ * config.sub: More accurate determination of HP processor types.
+
+Sat Jan 24 01:59:45 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure (package_makefile_frag): Move inserting the
+ ${package_makefile_frag} to where it should be according
+ to the comment.
+
+Fri Jan 23 00:30:21 1998 Philip Blundell <pb@nexus.co.uk>
+
+ * config.guess: Add support for Linux/ARM.
+
+Thu Jan 22 15:14:01 1998 Fred Fish <fnf@cygnus.com>
+
+ * .cvsignore: Remove *-info and *-install since they match
+ release-info and mpw-install, which we don't want to just ignore.
+
+Thu Jan 22 01:38:33 1998 Richard Henderson <rth@cygnus.com>
+
+ * configure.in: Revert 3 Jan change for alpha-linux-gnulibc1.
+
+Sat Jan 17 21:28:08 1998 Pieter Nagel <pnagel@epiuse.co.za>
+
+ * Makefile.in (FLAGS_TO_PASS): Pass down gcc_include_dir and
+ local_prefix to sub-make invocations.
+
+Sat Jan 17 21:04:59 1998 H.J. Lu (hjl@gnu.org)
+
+ * configure.in: Check makefile fragments in the source
+ directory.
+
+Fri Jan 16 00:41:37 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
+
+ * configure.in: check whether host and target makefile
+ fragments exist before adding them to *_makefile_frag
+
+Wed Jan 14 23:39:10 1998 Bob Manson <manson@charmed.cygnus.com>
+
+ * configure.in (target_configdirs): Add cygmon for sparc64-elf.
+
+Wed Jan 14 12:48:07 1998 Keith Seitz <keiths@pizza.cygnus.com>
+
+ * configure.in: Make sure we only replace RPATH_ENVVAR on
+ lines which begin with RPATH_ENVVAR, i.e. add "^" to the
+ regexp to sed.
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Pass RRPATH_ENVVAR down
+ to sub-makes.
+
+1998-01-13 Lee Iverson (leei@ai.sri.com)
+
+ * config-ml.in (multi-do): LDFLAGS must include multilib
+ designator.
+
+Tue Jan 13 01:13:24 1998 Robert Lipe (robertl@dgii.com)
+
+ * config.guess: Recognize i[3456]-i586-UnixWare7-sysv5.
+
+Sun Jan 4 01:06:55 1998 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * config.sub: Add mingw32 support.
+ * configure.in: Likewise.
+ * mh-mingw32: New file.
+
+Sat Jan 3 12:11:05 1998 Franz Sirl <franz.sirl-kernel@lauterbach.com>
+
+ * configure.in: Finalize support for {alpha|powerpc}*-*-linux-gnulibc1
+
+Sun Dec 28 11:28:58 1997 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (INSTALL_TARGET): Do install-gcc first.
+ * configure (gxx_include_dir): Provide a definition for subdirs
+ which do not use autoconf.
+
+Wed Dec 24 22:46:55 1997 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess: Sync with egcs. Picks up new alpha support,
+ BeOS & some additional linux support.
+
+Tue Dec 23 12:45:50 1997 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess: HP 9000/803 is a PA1.1 machine.
+
+
+Sun Dec 21 16:53:12 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
+
+ * configure.in (host_makefile_frag, target_makefile_frag):
+ Handle multiple config files.
+ (alpha-*-linux*): Treat alpha-*-linux* as alpha-*-linux* and
+ alpha-*-*.
+
+Thu Dec 18 13:13:03 1997 Doug Evans <devans@canuck.cygnus.com>
+
+ * mkdep: New file.
+
+Wed Dec 17 09:53:02 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (d30v-*-*): Allow configuring of libide, vmake, etc.
+
+Tue Dec 16 17:36:05 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Add libgui directory.
+ (GDB_TK): Add all-libgui.
+ * configure.in: Add libgui directory.
+ * configure: Add all-libgui to GDB_TK.
+
+Mon Dec 15 16:12:28 1997 Nick Clifton <nickc@cygnus.com>
+
+ * config-ml.in (multidirs): Add m32r to multilib list.
+
+Fri Dec 12 10:43:31 1997 Brendan Kehoe <brendan@canuck.cygnus.com>
+
+ * Makefile.in (all-target-gperf): Change dependency to
+ all-target-libstdc++.
+
+Thu Dec 11 23:30:51 1997 Fred Fish <fnf@ninemoons.com>
+
+ * config.guess: Add BeOS support.
+
+Wed Dec 10 15:10:38 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ Source directory cvs renamed to cvssrc:
+ * configure.in (host_tools): Change cvs to cvssrc.
+ (native_only): Likewise.
+ (noconfigdirs) [various cases]: Likewise.
+ * Makefile.in (ALL_MODULES): Change all-cvs to all-cvssrc.
+ (CROSS_CHECK_MODULES): Change check-cvs to check-cvssrc.
+ (INSTALL_MODULES): Change install-cvs to install-cvssrc.
+ (CLEAN_MODULES): Change clean-cvs to clean-cvssrc.
+ (all-cvssrc): Rename target from all-cvs.
+
+Wed Dec 3 07:55:59 1997 Jeffrey A Law (law@cygnus.com)
+
+ * configure (gxx_include_dir): Fix thinko.
+
+Tue Dec 2 10:55:34 1997 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (INSTALL_TARGET_CROSS): Define.
+ (install-cross, install-gcc-cross): New targets.
+
+Tue Dec 2 10:08:31 1997 Nick Clifton <nickc@cygnus.com>
+
+ * configure.in (noconfigdirs): Add support for Thumb target.
+
+ * config.sub (maybe_os): Add support for Thumb target.
+
+Sun Nov 30 16:12:27 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * Makefile.in: Add rules for cygmon.
+
+ * configure.in: Build cygmon for sparc-elf and sparclite-aout.
+
+Thu Nov 27 01:31:30 1997 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (INSTALL_TARGET): Do install-gcc first.
+ * configure (gxx_include_dir): Provide a definition for subdirs
+ which do not use autoconf.
+
+Wed Nov 26 11:53:33 1997 Keith Seitz <keiths@onions.cygnus.com>
+
+ * Makefile.in, configure, configure.in, ChangeLog: merge with foundry's
+ 11/18/97 build
+
+Wed Nov 26 16:08:50 1997 Jeffrey A Law (law@cygnus.com)
+
+ * From Franz Sirl.
+ * config.guess (powerpc*-*-linux): Handle glibc2 beta release
+ found on RedHat Linux systems.
+
+Fri Nov 21 09:51:01 1997 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess (alpha stuff): Merge with FSF to avoid incorrect
+ guesses.
+
+Thu Nov 13 11:38:37 1997 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in (i[3456]86-ncr-sysv4.3*): Tweak.
+
+Mon Nov 10 15:23:21 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * ltmain.sh: If mkdir fails, check whether the directory was created
+ anyhow by some other process.
+
+Mon Nov 10 14:38:03 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (d30v-*-*): Configure all directories.
+
+Sun Nov 9 17:36:20 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (d30v-*-*): Configure newlib, libiberty directories
+ for the D30V.
+
+Sat Nov 8 14:42:59 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (d30v-*-*): Configure target-libgloss on the D30V.
+
+Fri Nov 7 10:34:09 1997 Rob Savoye <rob@darkstar.cygnus.com>
+
+ * include/libiberty.h: Add extern "C" { so it can be used with C++
+ progrms.
+ * include/remote-sim.h: Add extern "C" { so it can be used with C++
+ programs.
+
+Thu Oct 30 11:09:29 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (d30v-*-*): Configure GCC now.
+
+Mon Oct 27 13:17:24 1997 Stan Shebs <shebs@andros.cygnus.com>
+
+ * configure.in: Remove a "second pass" of tweaking noconfigdirs,
+ is no longer needed.
+
+Mon Oct 27 12:03:53 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in: check-target-libio depends on all-target-libstdc++.
+
+Sun Oct 26 11:48:27 1997 Manfred Hollstein (manfred@s-direktnet.de)
+
+ * Makefile.in (bootstrap-lean): Combined with `normal' bootstrap
+ targets using "$@" to provide support for similar but not identical
+ targets without having to duplicate code.
+
+Mon Oct 20 15:28:49 1997 Klaus K"ampf <kkaempf@progis.de>
+
+ * makefile.vms: Fix to work with DEC C.
+
+Tue Oct 7 23:58:57 1997 Gavin Koch <gavin@cygnus.com>
+
+ * config.sub: Add mips-tx39-elf to marketing names.
+
+Tue Oct 7 14:24:41 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltmain.sh: Handle symlinks in generated script.
+
+Wed Oct 1 13:11:27 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Handle autoconf style directory options: --bindir,
+ --datadir, --includedir, --infodir, --libdir, --libexecdir,
+ --mandir, --oldincludedir, --sbindir, --sharedstatedir,
+ --sysconfdir.
+ * Makefile.in (sbindir, libexecdir, sysconfdir): New variables.
+ (sharedstatedir, localstatedir, oldincludedir): New variables.
+ (BASE_FLAGS_TO_PASS): Pass down bindir, datadir, includedir,
+ infodir, libdir, libexecdir, localstatedir, mandir, oldincludedir,
+ sbindir, sharedstatedir, and sysconfdir.
+
+Mon Sep 29 00:38:08 1997 Aaron Jackson <jackson@negril.msrce.howard.edu>
+
+ * Makefile.in (bootstrap-lean): New target.
+
+Wed Sep 24 18:06:27 1997 Stu Grossman <grossman@babylon-5.cygnus.com>
+
+ * configure.in (d30v): Remove tcl, tk, expect, gdb, itcl, tix, db,
+ sn, and gnuserv from noconfigdirs.
+
+Wed Sep 24 15:18:32 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ltmain.sh: Tweak shell pattern to avoid bug in NetBSD /bin/sh.
+
+Thu Sep 18 23:58:27 1997 Jeffrey A Law (law@cygnus.com)
+
+* Makefile.in (cross): New target.
+
+Thu Sep 18 21:43:23 1997 Alexandre Oliva <oliva@dcc.unicamp.br>
+ Jeff Law <law@cygnus.com>
+
+ * Makefile.in (bootstrap2, bootstrap3): New targets.
+ (all-bootstrap): Remove outdated and confusing target.
+ (bootstrap, bootstrap2, bootstrap3): Don't pass BOOT_CFLAGS down.
+
+
+1997-09-15 02:37 Ulrich Drepper <drepper@cygnus.com>
+
+ * config/mt-linux: Define CXXFLAGS to make sure -fvtable-thunks is
+ used.
+ * configure.in: Name Linux target fragment.
+
+ * configure: Rewrite so that project Makefile fragment is inserted
+ first and appears last in the resulting Makefile.
+
+Tue Sep 16 09:55:07 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * Makefile.in (install-itcl): Install tcl first.
+
+Sun Sep 14 20:53:42 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * config/mh-cygwin32: ok to build split texinfo files
+
+Fri Sep 12 16:19:20 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: remove bison from noconfigdirs for Cygwin32 host
+
+Thu Sep 11 16:40:46 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
+
+ * Makefile.in (local-distclean): Also remove mh-frag mt-frag.
+
+ * configure.in (skipdirs): Add target-librx for Linux.
+ (alpha-*-linux*): Use config/mh-elfalphapic and config/mt-elfalphapic.
+
+Wed Sep 10 21:29:54 1997 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (bootstrap): New target.
+
+Wed Sep 10 15:19:22 1997 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub: Accept 'amigados' for backward compatability.
+
+Mon Sep 8 20:46:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.guess: Merge with FSF.
+
+Sun Sep 7 15:55:28 1997 Gavin Koch <gavin@cygnus.com>
+
+ * config.sub: Add "marketing-names" patch.
+
+Fri Sep 5 16:11:28 1997 Joel Sherrill (joel@OARcorp.com)
+
+ * configure.in (*-*-rtems*): Do not build libgloss for rtems.
+
+Fri Sep 5 12:27:17 1997 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub: Handle v850-elf.
+
+Wed Sep 3 12:15:24 1997 Chris Provenzano <proven@cygnus.com>
+
+ * ltconfig: Set CONFIG_SHELL in libtool.
+ * ltmain.sh: Use CONFIG_SHELL instead of /bin/sh
+
+Mon Sep 1 16:45:44 1997 Jim Wilson <wilson@cygnus.com>
+
+ * configure.in (target_subdir): Set to libraries if enable_multilib.
+
+Wed Aug 27 16:15:11 1997 Jim Wilson <wilson@cygnus.com>
+
+ * config.guess: Update from gcc directory.
+
+Tue Aug 26 16:46:46 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * Makefile.in (all-sim): Depends on all-readline.
+
+Wed Aug 20 19:57:37 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (BISON, YACC): Use $$s.
+ (all-bison): Depend on all-texinfo.
+
+Tue Aug 19 01:41:32 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (BISON): Add -L flag.
+ (YACC): Likewise.
+
+Mon Aug 18 11:30:50 1997 Nick Clifton <nickc@cygnus.com>
+
+ * configure.in (noconfigdirs): Add support for v850e target.
+
+ * config.sub (maybe_os): Add support for v850e target.
+
+Mon Aug 18 11:30:50 1997 Nick Clifton <nickc@cygnus.com>
+
+ * configure.in (noconfigdirs): Add support for v850ea target.
+
+ * config.sub (maybe_os): Add support for v850ea target.
+
+Mon Aug 18 09:24:06 1997 Gavin Koch <gavin@cygnus.com>
+
+ * config.sub: Add mipstx39. Delete r3900.
+
+Mon Aug 18 17:20:10 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (all-autoconf): Depends on all-texinfo.
+
+Fri Aug 15 23:09:26 1997 Michael Meissner <meissner@cygnus.com>
+
+ * config-ml.in ({powerpc,rs6000}*-*-*): Update to current AIX and
+ eabi targets.
+
+Thu Aug 14 14:42:17 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Get CFLAGS and CXXFLAGS from Makefile, if possible.
+
+ * configure: When handling a Canadian Cross, handle YACC as well as
+ BISON. Just set BISON to bison. When setting YACC, prefer bison.
+ * Makefile.in (all-bison): Depend upon all-texinfo.
+
+Tue Aug 12 20:09:48 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (BISON): bison, not byacc or bison -y.
+ (YACC): bison -y or byacc or yacc.
+ (various): Add *-bison as appropriate.
+ (taz): No need to mess with BISON anymore.
+
+Tue Aug 12 22:33:08 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: If OSTYPE matches *win32*, try to find a good value for
+ CONFIG_SHELL.
+
+Sun Aug 10 14:41:11 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (taz): Get the version number from AM_INIT_AUTOMAKE in
+ configure.in if it is present.
+
+Sat Aug 9 00:58:01 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (LD_FOR_TARGET): Change ld.new to ld-new.
+
+Fri Aug 8 16:30:13 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.sub: Recognize `arc' cpu.
+ * configure.in: Likewise.
+ * config-ml.in: Likewise.
+
+Thu Aug 7 11:02:34 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in ($(INSTALL_X11_MODULES)): Depend upon installdirs.
+
+Wed Aug 6 16:27:29 1997 Chris Provenzano <proven@cygnus.com>
+
+ * configure: Changed sed delimiter from ':' to '|' when
+ attempting to substitute ${config_shell} for SHELL. On
+ NT ${config_shell} may contain a ':' in it.
+
+Wed Aug 6 12:29:05 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): Fix for non-bash shells.
+
+Wed Aug 6 00:42:35 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (AS_FOR_TARGET): Change as.new to as-new.
+
+Tue Aug 5 14:08:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (NM_FOR_TARGET): Change nm.new to nm-new.
+
+ * ylwrap: If the program is a relative path, force it to be
+ absolute.
+
+Tue Aug 5 12:12:44 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * configure (tooldir): Set BISON to `bison -y' and not just bison.
+
+Mon Aug 4 22:59:02 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * Makefile.in (CC_FOR_TARGET): When winsup/Makefile present,
+ correctly specify the target build directory $(TARGET_SUBDIR)/winsup
+ for libraries.
+
+Mon Aug 4 12:40:24 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): Fix handling of macros with values
+ separated by spaces.
+
+Thu Jul 31 19:49:49 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ylwrap: New file.
+ * Makefile.in (DEVO_SUPPORT): Add ylwrap.
+
+ * ltmain.sh: Handle /bin/sh at start of install program.
+
+ * Makefile.in (DEVO_SUPPORT): Add ltconfig, ltmain.sh, and missing.
+
+ * ltconfig, ltmain.sh: New files, from libtool 1.0.
+ * missing: New file, from automake 1.2.
+
+Thu Jul 24 12:57:56 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Treat tix like tk, putting it in X11_MODULES. Add
+ check-tk to CHECK_X11_MODULES.
+
+Wed Jul 23 17:03:29 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Merge with FSF.
+
+Tue Jul 22 19:08:29 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.guess: Merge with FSF.
+
+Tue Jul 22 14:50:42 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
+
+ * configure: Treat msdosdjgpp like go32.
+ * configure.in: Likewise. Don't remove gprof for go32.
+
+ * configure: Change Makefile.tem2 to Makefile.tm2.
+
+Mon Jul 21 10:31:26 1997 Stephen Peters <speters@cygnus.com>
+
+ * configure.in (noconfigdirs): For alpha-dec-osf*, don't ignore grep.
+
+Tue Jul 15 14:33:03 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * install-sh (chmodcmd): Set to null if the DST directory already
+ exists. Same as Nov 11th change.
+
+Mon Jul 14 11:01:15 1997 Martin M. Hunt <hunt@cygnus.com>
+
+ * configure (GDB_TK): Needs itcl and tix.
+
+Mon Jul 14 00:32:10 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * config.guess: Update from FSF.
+
+Fri Jul 11 11:57:11 1997 Martin M. Hunt <hunt@cygnus.com>
+
+ * Makefile.in (GDB_TK): Depend on itcl and tix.
+
+Fri Jul 4 13:25:31 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (INSTALL_PROGRAM_ARGS): New variable.
+ (INSTALL_PROGRAM): Use $(INSTALL_PROGRAM_ARGS).
+ (INSTALL_SCRIPT): New variable.
+ (BASE_FLAGS_TO_PASS): Pass down INSTALL_SCRIPT.
+ * configure.in: If host is *-*-cygwin32*, set INSTALL_PROGRAM_ARGS
+ to -x.
+ * install-sh: Add support for -x option.
+
+Mon Jun 30 15:51:30 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in, Makefile.in: Treat tix like itcl.
+
+Thu Jun 26 13:59:19 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (WINDRES): New variable.
+ (WINDRES_FOR_TARGET): New variable.
+ (BASE_FLAGS_TO_PASS): Add WINDRES_FOR_TARGET.
+ (EXTRA_HOST_FLAGS): Add WINDRES.
+ (EXTRA_TARGET_FLAGS): Add WINDRES.
+ (EXTRA_GCC_FLAGS): Add WINDRES.
+ ($(DO_X)): Pass down WINDRES.
+ ($(CONFIGURE_TARGET_MODULES)): Set WINDRES when configuring.
+ * configure: Treat WINDRES like DLLTOOL, and WINDRES_FOR_TARGET like
+ DLLTOOL_FOR_TARGET.
+
+Wed Jun 25 15:01:26 1997 Felix Lee <flee@cygnus.com>
+
+ * configure.in: configure sim before gdb for win32-x-ppc
+
+Wed Jun 25 12:18:54 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ Move gperf into the toplevel, from libg++.
+ * configure.in (target_tools): Add target-gperf.
+ (native_only): Add target-gperf.
+ * Makefile.in (all-target-gperf): New target, depend on
+ all-target-libg++.
+ (configure-target-gperf): Empty rule.
+ (ALL_TARGET_MODULES): Add all-target-gperf.
+ (CONFIGURE_TARGET_MODULES): Add configure-target-gperf.
+ (CHECK_TARGET_MODULES): Add check-target-gperf.
+ (INSTALL_TARGET_MODULES): Add install-target-gperf.
+ (CLEAN_TARGET_MODULES): Add clean-target-gperf.
+
+Mon Jun 23 10:51:53 1997 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub (mn10200): Recognize new basic machine.
+
+Thu Jun 19 14:16:42 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure.in: Don't set ENABLE_MULTILIB, so we'll be passing
+ --enable-multilib down to subdirs; setting TARGET_SUBDIR was enough.
+
+Tue Jun 17 15:31:20 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure.in: If we're building mips-sgi-irix6* native, turn on
+ ENABLE_MULTILIB and set TARGET_SUBDIR.
+
+Tue Jun 17 12:20:59 1997 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in (all-sn): Depend on all-grep.
+
+Mon Jun 16 11:11:10 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use mh-ppcpic and mt-ppcpic for powerpc*-* targets.
+
+ * configure: Set CFLAGS and CXXFLAGS, and substitute them into
+ Makefile. From Jeff Makey <jeff@cts.com>.
+ * Makefile.in: Add comment for CFLAGS and CXXFLAGS.
+
+ * Makefile.in (DISTBISONFILES): Remove.
+ (taz): Don't futz with DISTBISONFILES. Change BISON to use
+ $(DEFAULT_YACC).
+
+ * configure.in: Build itl, db, sn, etc., when building for native
+ cygwin32.
+
+ * Makefile.in (LD): New variable.
+ (EXTRA_HOST_FLAGS): Pass down LD.
+ ($(DO_X)): Likewise.
+
+Mon Jun 16 11:10:35 1997 Philip Blundell <Philip.Blundell@pobox.com>
+
+ * Makefile.in (INSTALL): Use $(SHELL) when executing install-sh.
+
+Fri Jun 13 10:22:56 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * configure.in (targargs): Strip out any supplied --build argument
+ before adding our own. Always add --build.
+
+Thu Jun 12 21:12:28 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * configure.in (targargs): Pass --build if we're doing
+ a cross-compile.
+
+Fri Jun 6 21:38:40 1997 Rob Savoye <rob@chinadoll.cygnus.com>
+
+ * configure: Use '|' instead of ":" as the seperator in
+ sed. Otherwise sed chokes on NT path names with drive
+ designators. Also look for "?:*" as the leading characters in an
+ absolute pathname.
+
+Mon Jun 2 13:05:20 1997 Gavin Koch <gavin@cygnus.com>
+
+ * config.sub: Support for r3900.
+
+Wed May 21 17:33:31 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use install-sh, not install.sh.
+
+Wed May 14 16:06:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (taz): Improve check for BISON so it doesn't try to
+ apply it twice.
+
+Fri May 9 17:22:05 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (INSTALL_MODULES): Put install-opcodes before
+ install-binutils.
+
+Thu May 8 17:29:50 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Add automake targets.
+ * configure.in (host_tools): Add automake.
+
+Tue May 6 15:49:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Default CXX to c++, not gcc.
+ * Makefile.in (CXX): Set to c++, not gcc.
+ (CXX_FOR_TARGET): When cross, transform c++, not gcc.
+
+Thu May 1 10:11:43 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * install-sh: try appending a .exe if source file doesn't
+ exist
+
+Wed Apr 30 12:05:36 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * configure.in: Turn on multilib by default.
+ (cross_only): Remove target-libiberty.
+
+ * Makefile.in (all-gcc): Don't depend on libiberty.
+
+Mon Apr 28 18:39:45 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * config.guess: improve algorithm for recognizing Gnu Hurd x86.
+
+Thu Apr 24 19:30:07 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (DEVO_SUPPORT): Add mpw-install.
+ (DISTBISONFILES): Add ld/Makefile.in
+
+Tue Apr 22 17:17:28 1997 Geoffrey Noer <noer@pizza.cygnus.com>
+
+ * configure.in: if target is cygwin32 but host isn't cygwin32,
+ don't configure gdb tcl tk expect, not just gdb.
+
+Mon Apr 21 13:33:39 1997 Tom Tromey <tromey@cygnus.com>
+
+ * configure.in: Added gnuserv everywhere sn appears.
+
+ * Makefile.in (ALL_MODULES): Added all-gnuserv.
+ (CROSS_CHECK_MODULES): Added check-gnuserv.
+ (INSTALL_MODULES): Added install-gnuserv.
+ (CLEAN_MODULES): Added clean-gnuserv.
+ (all-gnuserv): New target.
+
+Thu Apr 17 13:57:06 1997 Per Fogelstrom <pefo@openbsd.org>
+
+ * config.guess: Fixes for MIPS OpenBSD systems.
+
+Tue Apr 15 12:21:07 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (INSTALL_XFORM): Remove.
+ (BASE_FLAGS_TO_PASS): Remove INSTALL_XFORM.
+
+ * mkinstalldirs: New file, copied from automake.
+ * Makefile.in (installdirs): Rename from install-dirs. Use
+ mkinstalldirs. Change all users.
+ (DEVO_SUPPORT): Add mkinstalldirs.
+
+Mon Apr 14 11:21:38 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * install-sh: Rename from install.sh.
+ * Makefile.in (INSTALL): Change install.sh to install-sh.
+ (DEVO_SUPPORT): Likewise.
+
+ * configure: Use ${config_shell} with ${moveifchange}. From Thomas
+ Graichen <graichen@rzpd.de>.
+
+Fri Apr 11 16:37:10 1997 Niklas Hallqvist <niklas@appli.se>
+
+ * config.guess: Recognize OpenBSD systems correctly.
+
+Fri Apr 11 17:07:04 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * README, Makefile.in (ETC_SUPPORT): Remove references to
+ cfg-paper*, configure.{texi,man,info*}._
+
+Sun Apr 6 18:47:57 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * Makefile.in (all.normal): Ensure that gcc is built after all
+ the x11 - ie gdb - targets.
+
+Tue Apr 1 16:28:50 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Don't run conf-a-gas.
+
+Mon Mar 31 16:26:55 1997 Joel Sherrill <joel@oarcorp.com>
+
+ * configure.in (hppa1.1-*-rtems*): New target, like hppa-*-*elf*.
+
+Sun Mar 30 12:38:27 1997 Fred Fish <fnf@cygnus.com>
+
+ * configure.in: Remove noconfigdirs case since gdb also
+ configures and builds for tic80-coff.
+
+Fri Mar 28 18:28:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Set cache_file to config.cache.
+ * Makefile.in (local-distclean): Remove config.cache.
+
+Wed Mar 26 18:49:39 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * COPYING: Update FSF address.
+
+Wed Mar 26 10:38:25 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (tic80-*-*): Remove G++ libraries and libgloss from
+ noconfigdirs.
+
+Mon Mar 24 15:02:39 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (install-dirs): Don't crash if prefix, and hence
+ MAKEDIRS, is empty.
+
+Mon Mar 24 12:40:55 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.sub: Tweak mn10300 entry.
+
+Fri Mar 21 15:35:27 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (host_tools): Put sim before gdb, so gdb's
+ configure.tgt can determine if the simulator was configured.
+
+Sun Mar 16 16:07:08 1997 Fred Fish <fnf@cygnus.com>
+
+ * config.sub: Move BeOS $os case to be with other Cygnus
+ local cases.
+
+Sun Mar 16 01:34:55 1997 Martin Hunt <hunt@cygnus.com>
+
+ * config.sub: Remove misplaced comment that broke Linux.
+
+Sat Mar 15 22:50:15 1997 Fred Fish <fnf@cygnus.com>
+
+ * config.sub: Add BeOS support.
+
+Mon Mar 10 13:30:11 1997 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in (CHECK_X11_MODULES): Don't run check-tk.
+
+Wed Mar 5 12:09:29 1997 Martin <hunt@cygnus.com>
+
+ * configure.in (noconfigdirs): Remove tcl and tk from
+ noconfigdirs for cygwin32 builds.
+
+Fri Feb 28 18:20:15 1997 Fred Fish <fnf@cygnus.com>
+
+ * configure.in (tic80-*-*): Remove ld from noconfigdirs.
+
+Thu Feb 27 14:57:26 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (GAS_SUPPORT_DIRS, BINUTILS_SUPPORT_DIRS): Remove
+ make-all.com, use makefile.vms instead.
+
+Tue Feb 25 18:46:14 1997 Stan Shebs <shebs@andros.cygnus.com>
+
+ * config.sub: Accept -lnews*.
+
+Tue Feb 25 13:19:14 1997 Andrew Cagney <cagney@kremvax.tpgi.com.au>
+
+ * configure.in (noconfigdirs): Disable target-newlib,
+ target-examples and target-libiberty for d30v.
+
+Fri Feb 21 17:56:25 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * configure.in (noconfigdirs): Enable ld for d30v.
+
+Fri Feb 21 20:58:51 1997 Michael Meissner <meissner@cygnus.com>
+
+ * configure.in (tic80-*-*): Build compiler.
+
+Sun Feb 16 15:41:09 1997 Andrew Cagney <cagney@critters.cygnus.com>
+
+ * configure.in (d30v-*): Remove sim directory from list of
+ unsupported d30v directories
+
+Tue Feb 18 17:32:42 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * config.sub, configure.in: Add d30v target cpu.
+
+Thu Feb 13 22:04:44 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: New file.
+ * make-all.com: Remove.
+
+Wed Feb 12 12:54:18 1997 Jim Wilson <wilson@cygnus.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): Add LIBGCC2_DEBUG_CFLAGS.
+
+Sat Feb 8 20:36:49 1997 Michael Meissner <meissner@cygnus.com>
+
+ * Makefile.in (all-itcl): The rule is all-itcl, not all-tcl.
+
+Tue Feb 4 11:39:29 1997 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in (ALL_MODULES): Added all-db.
+ (CROSS_CHECK_MODULES): Addec check-db.
+ (INSTALL_MODULES): Added install-db.
+ (CLEAN_MODULES): Added clean-db.
+
+Mon Feb 3 13:29:36 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.guess: Merge with latest FSF sources.
+
+Tue Jan 28 09:20:37 1997 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in (ALL_MODULES): Added all-itcl.
+ (CROSS_CHECK_MODULES): Added check-itcl.
+ (INSTALL_MODULES): Added install-itcl.
+ (CLEAN_MODULES): Added clean-itcl.
+
+Thu Jan 23 01:44:27 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: build gdb for mn10200
+
+Fri Jan 17 15:32:15 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (all-target-winsup): Depend on all-target-libio.
+
+Mon Jan 13 22:46:54 1997 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (tic80-*-*): Turn off most targets right now.
+
+Fri Jan 3 16:04:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (MAKEINFO): Check for the existence of the Makefile,
+ rather than the makeinfo program.
+ (do-info): Depend upon all-texinfo.
+
+Tue Dec 31 16:00:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Remove uses of config/mh-linux.
+
+ * config.sub, config.guess: Merge with latest FSF sources.
+
+Fri Dec 27 23:04:33 1996 Fred Fish <fnf@cygnus.com>
+
+ * config.sub (case $basic_machine): Add tic80 entries.
+
+Fri Dec 27 12:07:59 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub, config.guess: Merge with latest FSF sources.
+
+Wed Dec 18 22:46:39 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-build.in: Build ld before gcc, use NewFolderRecursive.
+ * mpw-config.in: Test for NewFolderRecursive.
+ * mpw-install: Use symbolic name for startup filename.
+ * mpw-README: Add various additional details.
+
+Wed Dec 18 13:11:46 1996 Jim Wilson <wilson@cygnus.com>
+
+ * configure.in (mips*-sgi-irix6*): Remove binutils from noconfigdirs.
+
+Wed Dec 18 10:29:31 1996 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in: Do build gcc and the target libraries for
+ the mn10200.
+
+Wed Dec 4 16:53:05 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: don't avoid building gdb for mn10300 any more
+ * Makefile.in: double-quote GCC_FOR_TARGET line in EXTRA_GCC_FLAGS
+ instead of single-quoting it.
+
+Tue Dec 3 23:26:50 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * configure.in: Don't use --with-stabs on IRIX 6.
+
+Tue Dec 3 09:05:25 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * configure.in (m32r): Build gdb, libg++ now.
+
+Sun Dec 1 00:18:59 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.in (mips*-sgi-irix6*): Remove gdb and related
+ directories from noconfigdirs.
+
+Tue Nov 26 11:45:33 1996 Kim Knuttila <krk@cygnus.com>
+
+ * config.sub (basic_machine): added mips16 configuration
+
+Sat Nov 23 19:26:22 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.sub: Handle d10v-unknown.
+
+Sat Nov 23 10:23:01 1996 Gavin Koch <gavin@cygnus.com>
+
+ * config.sub: Handle v850-unknown.
+
+Thu Nov 21 16:19:44 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * Makefile.in: add findutils
+ * configure.in: add findutils to list of host_tools
+
+Wed Nov 20 10:09:01 1996 Jeffrey A Law (law@cygnus.com)
+
+ * config.sub: Handle mn10200 and mn10300.
+
+Tue Nov 19 16:35:14 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (d10v-*): Do not build librx.
+
+Mon Nov 18 13:28:41 1996 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in (mn10300): Build everything except gdb & libgloss.
+
+Wed Nov 13 14:59:46 1996 Per Bothner <bothner@deneb.cygnus.com>
+
+ * config.guess: Patch for Dansk Data Elektronik servers,
+ from Niels Skou Olsen <nso@dde.dk>.
+
+ For ncr, use /bin/uname rather than uname, since GNU uname does not
+ support -p. Suggested by Mark Mitchell <mmitchell@usa.net>.
+
+ Patch for MIPS R4000 running System V,
+ from Eric S. Raymond <esr@snark.thyrsus.com>.
+
+ Fix thinko for nextstep.
+
+ Patch for OSF1 in i?86, from Dan Murphy <dlm@osf.org> via Harlan Stenn.
+
+ Sat Jun 24 18:58:17 1995 Morten Welinder <terra+@cs.cmu.edu>
+ * config.guess: Guess mips-dec-mach_bsd4.3.
+
+ Thu Oct 10 04:07:04 1996 Harlan Stenn <harlan@pfcs.com>
+ * config.guess (i?86-ncr-sysv*): Emit just enough of the minor
+ release numbers.
+ * config.guess (mips-mips-riscos*): Emit just enough of the
+ release number.
+
+ Tue Oct 8 10:37:22 1996 Frank Vance <fvance@waii.com>
+ * config.guess (sparc-auspex-sunos*): Added.
+ (f300-fujitsu-*): Added.
+
+ Wed Sep 25 22:00:35 1996 Jeff Woolsey <woolsey@jlw.com>
+ * config.guess: Recognize a Tadpole as a sparc.
+
+Wed Nov 13 00:53:09 1996 David J. MacKenzie <djm@churchy.gnu.ai.mit.edu>
+
+ * config.guess: Don't assume that NextStep version is either 2 or
+ 3. NextStep 4 (aka OpenStep 4) has come out now.
+
+Mon Nov 11 23:52:03 1996 David J. MacKenzie <djm@churchy.gnu.ai.mit.edu>
+
+ * config.guess: Support Cray T90 that reports itself as "CRAY TS".
+ From Rik Faith <faith@cs.unc.edu>.
+
+Fri Nov 8 11:34:58 1996 David J. MacKenzie <djm@geech.gnu.ai.mit.edu>
+
+ * config.sub: Contributions from bug-gnu-utils to:
+ Support plain "hppa" (no version given) architecture, reported by
+ OpenStep.
+ OpenBSD like NetBSD.
+ LynxOs is not a hardware supplier.
+
+ * config.guess: Contributions from bug-gnu-utils to add support for:
+ OpenBSD like NetBSD.
+ Stratus systems.
+ More Pyramid systems.
+ i[n>4]86 Intel chips.
+ M680[n>4]0 Motorola chips.
+ Use unknown instead of lynx for hardware manufacturer.
+
+Mon Nov 11 10:09:08 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * install.sh (chmodcmd): Set to null if the DST directory already
+ exists.
+
+Mon Nov 11 10:43:41 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (powerpc*-{eabi,elf,linux,rtem,sysv,solaris}*): Do
+ not use mt-ppc target Makefile fragment any more.
+
+Sun Nov 3 19:17:07 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * configure.in (*-*-windows): Exclude everything but those dirs
+ needed to build windows.
+
+Tue Oct 29 16:41:31 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (all-target-winsup): Depend on all-target-librx.
+
+Mon Oct 28 17:32:46 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * configure.in: Exclude mmalloc from i386-windows.
+ * config/mh-windows: Add rules for building MSVC makefiles.
+
+Thu Oct 24 09:22:46 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * Undo my previous change.
+
+Thu Oct 24 12:12:04 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): Pass down GCC_FOR_TARGET
+ unconditionally.
+ (MAKEOVERRIDES): Define (revert this part of October 18 change).
+
+Thu Oct 24 09:02:07 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * Makefile.in (FLAGS_TO_PASS): Add $(HOST_FLAGS) to allow the
+ host to add it's own flags.
+ * config/mh-windows (HOST_FLAGS): Set srcroot, which is needed
+ for MSVC build procedure.
+
+Tue Oct 22 15:20:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Handle GCC_FOR_TARGET like CC_FOR_TARGET.
+
+Fri Oct 18 13:37:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (CC_FOR_TARGET): Check for xgcc, not Makefile.
+ (CXX_FOR_TARGET): Likewise.
+ (GCC_FOR_TARGET): Define.
+ (BASE_FLAGS_TO_PASS): Remove GCC_FOR_TARGET.
+ (EXTRA_GCC_FLAGS): Define GCC_FOR_TARGET based on whether
+ CC_FOR_TARGET was specified on the command line.
+ (MAKEOVERRIDES): Don't define.
+
+Thu Oct 17 10:27:56 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * configure.in (m32r): Fix spelling of libg++ libs.
+
+Thu Oct 10 10:37:17 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * config.sub (-apple*): Remove, now redundant.
+
+Thu Oct 10 12:30:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Don't get confused by CPU-VENDOR-linux-gnu.
+
+ * configure: Rework yesterday's sed script patch.
+
+ * config.sub: Merge with FSF.
+
+Wed Oct 9 17:24:59 1996 Per Bothner <bothner@deneb.cygnus.com>
+
+ * config.guess: Merge from FSF.
+
+ 1996-09-12 Richard Stallman <rms@ethanol.gnu.ai.mit.edu>
+ * config.guess: Use pc instead of unknown, for pc clone systems.
+ Change linux to linux-gnu.
+
+ Mon Jul 15 23:51:11 1996 Karl Heuer <kwzh@gnu.ai.mit.edu>
+ * config.guess: Avoid non-portable tr syntax.
+
+Wed Oct 9 06:06:46 1996 Jeffrey A Law (law@cygnus.com)
+
+ * test-build.mk (HOLES): Add "xargs" for gdb.
+
+ * configure: Avoid hpux10.20 sed bug.
+
+Tue Oct 8 08:32:48 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * configure.in config/mh-windows: Add support for windows host
+ (that is a build done under the Microsoft build environment).
+
+Tue Oct 8 10:39:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Replace all uses of srcroot with s, to shrink
+ command line lengths.
+
+ Patches from Geoffrey Noer <noer@cygnus.com>:
+ * configure.in: If configuring for newlib, pass --with-newlib to
+ subdirectories.
+ * Makefile.in (CC_FOR_TARGET): If winsup/Makefile exists, pass a
+ -Bnewlib/ and -Lwinsup to gcc.
+ (CXX_FOR_TARGET): Likewise.
+
+Mon Oct 7 10:59:35 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (ETC_SUPPORT): Add configure.
+
+Fri Oct 4 12:22:58 1996 Angela Marie Thomas (angela@cygnus.com)
+
+ * configure.in: Use config/mh-dgux386 for i[345]86-dg-dgux
+ host configuration file.
+
+Thu Oct 3 09:28:25 1996 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in: Break mn10x00 support into separate
+ mn10200 and mn10300 configurations.
+ * config.sub: Likewise.
+
+Wed Oct 2 22:27:52 1996 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in: Add lots of stuff to noconfigdirs for
+ the mn10x00 targets.
+
+ * config.sub, configure.in: Add mn10x00 support.
+
+Wed Oct 2 15:52:36 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * make-all.com: Call conf-a-gas, not config-a-gas.
+
+Tue Oct 1 01:28:41 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * configure.in (noconfigdirs): Don't build libgloss for arm-coff
+ targets.
+
+Mon Sep 30 14:24:01 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-README: Add much more detail for native PowerMac.
+ * mpw-install: New file.
+ * mpw-configure: Add --norecursion and --help options.
+ * mpw-config.in: Translate readme and install files when
+ copying to objdir.
+ * mpw-build.in: Don't always depend on byacc and flex.
+ (install-only-top): New action.
+
+Fri Sep 27 17:39:44 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * configure.in: You can now configure GDB for the v850.
+
+Tue Sep 24 19:05:12 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * configure.in (noconfigdirs): Don't configure any C++ dirs
+ if targeting D10V.
+
+Tue Sep 17 12:15:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Recognize mips64vr5000.
+
+Mon Sep 16 17:00:52 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use a single line for host_tools and native_only.
+
+Mon Sep 9 12:21:30 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.sub, configure.in: Add entries for m32r.
+
+Thu Sep 5 13:52:47 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * Makefile.in (inet-install): Don't run install-gzip.
+
+Wed Sep 4 17:26:13 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * configure.in: Don't config lots of things for *-*-windows*.
+
+Sat Aug 31 11:45:57 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Test for mpw-true, true, and null-command scripts.
+ (host_libs, host_tools): Copy from configure.in.
+ * mpw-configure: Don't complain about directories not found.
+
+Thu Aug 29 16:44:58 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (i[345]86): Recognize i686 for pentium pro.
+ (i[3456]86-*-dgux*): Use config/mh-sysv for the host configuration
+ file.
+
+ * config.guess (i[345]86): Ditto.
+
+Mon Aug 26 18:34:42 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * configure.in (noconfigdirs): Removed gdb for D10V.
+
+Thu Aug 22 17:13:52 1996 Jeffrey A Law (law@cygnus.com)
+
+ * configure.in: Remove ld, target-libio, target-libg++, and
+ target-libstdc++ from noconfigdirs.
+
+Wed Aug 21 18:56:38 1996 Fred Fish <fnf@cygnus.com>
+
+ * configure: Fix three locations where shell scripts were
+ being run directly rather than with config_shell.
+
+Tue Aug 20 13:08:47 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * configure.in (v850-*-*): Set up initial $noconfigdirs.
+ * config.sub (basic_machine): Recognize v850.
+
+Thu Aug 15 12:19:33 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Handle multiple enable/disable options and
+ pass them down recursively, handle -c and -s flags appropriately
+ depending on choice of compiler, add escape mechanism for
+ quoted arguments to gC.
+
+Mon Aug 12 13:15:13 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (powerpc*-*-*): For eabi, system V.4, Linux, and
+ solaris targets, use config/mt-ppc to set C{,XX}FLAGS_FOR_TARGETS
+ so that -mrelocatable-lib and -mno-eabi are used.
+
+ * Makefile.in (CONFIGURE_TARGET_MODULES): If target compiler does
+ not support --print-multi-lib, don't abort.
+
+Sun Aug 11 20:51:50 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * config/mh-cygwin32 (CFLAGS): Define _WIN32 to be compatible
+ with normal Windows compilation environment.
+
+Thu Aug 8 12:18:59 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * make-all.com: Run config-a-gas.
+ * setup.com: Don't copy subdirectory files around.
+
+Tue Jul 30 17:49:31 1996 Brendan Kehoe <brendan@cygnus.com>
+
+ * configure.in (*-*-ose): Remove exclusion of libgloss for this
+ target, it now compiles correctly.
+
+Sat Jul 27 15:10:43 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Generate Mac include for elf/dwarf2.h.
+
+Tue Jul 23 10:47:04 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * configure.in (d10v-*-*): Remove ld from $noconfigdirs.
+
+Mon Jul 22 13:28:51 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure.in (native_only): Add prms.
+
+Mon Jul 22 12:27:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (GAS_SUPPORT_DIRS): Add make-all.com and setup.com.
+ (BINUTILS_SUPPORT_DIRS): Likewise.
+
+Thu Jul 18 12:55:40 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (d10v-*-*): Don't configure ld or gdb until the
+ d10v support is added.
+
+Wed Jul 17 14:33:09 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * configure.in (d10v-*-*): New target.
+
+Mon Jul 15 11:53:00 1996 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess (HP 9000/811): Recognize this as a PA1.1
+ machine.
+
+Fri Jul 12 23:21:17 1996 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (do-tar-gz): New target, split out from tail end of
+ taz target. Run each command separately, don't use pipes.
+ (taz): Use it.
+
+Fri Jul 12 12:08:04 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Look for g-mpw-make.sed in config/mpw.
+ * mpw-build.in: No builds should depend on building byacc or flex,
+ they are assumed to be installed already.
+
+Fri Jul 12 09:52:52 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in (CONFIGURE_TARGET_MODULES): Set r environment
+ variable that CC_FOR_TARGET needs.
+
+Thu Jul 11 10:09:45 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in (CONFIGURE_TARGET_MODULES): Determine if the multlib
+ options have changed since the last time the subdirectory was
+ configured, and if it has, reconfigure.
+ (CLEAN_TARGET_MODULES): Delete multilib.out and tmpmulti.out, which
+ CONFIGURE_TARGET_MODULES uses to remember the old multilib options.
+
+Wed Jul 10 18:56:59 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (ALL_MODULES,CROSS_CHECK_MODULES,INSTALL_MODULES,
+ CLEAN_MODULES): Add bash.
+ (all-bash): New target.
+
+Mon Jul 8 17:33:14 1996 Jim Wilson <wilson@cygnus.com>
+
+ * configure.in (mips-sgi-irix6*): Use mh-irix6 instead of mh-irix5.
+
+Mon Jul 1 13:31:35 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.sub (basic_machine): Recognize d10v as a valid processor.
+
+Fri Jun 28 12:14:35 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Add support for --bindir.
+ * mpw-build.in: Use a GCC-specific build script for GCC actions.
+
+Wed Jun 26 17:20:12 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: add bash, time, gawk to list of hosttools and things
+ to only build for native toolchains
+
+Tue Jun 25 23:09:03 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (docdir): Remove.
+
+Tue Jun 25 19:00:08 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (datadir): Set to $(prefix)/share.
+
+Mon Jun 24 23:26:07 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: build diff and patch for cygwin32-hosted
+ toolchains.
+
+Mon Jun 24 15:01:12 1996 Joel Sherrill <joel@merlin.gcs.redstone.army.mil>
+
+ * config.sub: Accept -rtems*.
+
+Sun Jun 23 22:41:54 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: enable dosrel for cygwin32-hosted builds,
+ remove diff from the list of things not buildable
+ via Canadian Cross
+
+Sat Jun 22 11:39:01 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (TARGET_SUBDIR): Move comment to previous line so we
+ don't get ". ".
+
+Fri Jun 21 17:24:48 1996 Jim Wilson <wilson@cygnus.com>
+
+ * configure.in (mips*-sgi-irix6*): Set noconfigdirs appropriately.
+
+Thu Jun 20 16:57:40 1996 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (taz): Handle case where tex3patch didn't even get
+ checked out. Also, if it was found, put the symlink in a new util
+ subdirectory.
+
+Thu Jun 20 12:20:33 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.guess (*:Linux:*:*): Add support for PowerPC Linux.
+
+Tue Jun 18 14:24:12 1996 Klaus Kaempf (kkaempf@progis.de)
+
+ * config.sub: Recognize -openvms.
+ * configure.in (alpha*-*-*vms*): Set noconfigdirs.
+ * make-all.com, setup.com: New files.
+
+Mon Jun 17 16:34:46 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (taz): tex3patch moved to texinfo/util.
+
+Sat Jun 15 17:13:25 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: remove make from disable-if-Can-Cross list
+ enable gdb if ${host} and ${target} are cygwin32
+
+Fri Jun 7 18:16:52 1996 Harlan Stenn <harlan@pfcs.com>
+
+ * config.guess (i?86-ncr-sysv*): Emit minor release numbers.
+ Recognize the NCR 4850 machine and NCR Pentium-based platforms.
+
+Wed Jun 5 00:09:17 1996 Per Bothner <bothner@wombat.gnu.ai.mit.edu>
+
+ * config.guess: Combine mips-mips-riscos cases, and use cpp to
+ distinguish sysv/svr4/bsd variants.
+ Based on a patch from Harlan Stenn <harlan@pfcs.com>.
+
+Fri Jun 7 14:24:49 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * configure.in: Added copyright notice.
+ * move-if-change: Added copyright notice.
+
+Thu Jun 6 16:27:05 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (powerpcle-*-solaris*): Until we get shared
+ libraries working, don't build gdb, sim, make, tcl, tk, or
+ expect.
+
+Tue Jun 4 20:41:45 1996 Per Bothner <bothner@deneb.cygnus.com>
+
+ * config.guess: Merge with FSF:
+
+ Mon Jun 3 08:49:14 1996 Karl Heuer <kwzh@gnu.ai.mit.edu>
+ * config.guess (*:Linux:*:*): Add guess for sparc-unknown-linux.
+
+ Fri May 24 18:34:53 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
+ * config.guess (AViiON:dgux:*:*): Fix typo in recognizing mc88110.
+
+ Fri Apr 12 20:03:59 1996 Per Bothner <bothner@spiff.gnu.ai.mit.edu>
+ * config.guess: Combine two OSF1 rules.
+ Also recognize field test versions. From mjr@zk3.dec.com.
+ * config.guess (dgux): Use /usr/bin/uname rather than uname,
+ because GNU uname does not support -p. From pmr@pajato.com.
+
+Tue Jun 4 11:07:25 1996 Tom Tromey <tromey@csk3.cygnus.com>
+
+ * Makefile.in (MAKEDIRS): Removed $(tooldir).
+
+Tue May 28 12:30:50 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-README: Document GCCIncludes.
+
+Sun May 26 15:16:27 1996 Fred Fish <fnf@cygnus.com>
+
+ * configure.in (alpha-*-linux*): Set enable_shared to yes.
+
+Tue May 21 15:41:39 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Handle --enable-FOO and --disable-FOO.
+
+Mon May 20 10:12:29 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in (*-*-cygwin32): Configure make.
+
+Tue May 7 14:19:42 1996 Tom Tromey <tromey@snuffle.cygnus.com>
+
+ * Makefile.in (inet-install): Quote value of INSTALL_MODULES.
+
+Fri May 3 08:57:17 1996 Tom Tromey <tromey@lisa.cygnus.com>
+
+ * Makefile.in (all-inet): Depend on all-perl.
+
+ * Makefile.in (inet-install): New target.
+
+ * Makefile.in (all-inet): Depend on all-tcl.
+ (all-inet): Depend on all-send-pr.
+
+Tue Apr 30 13:55:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (powerpcle-*-solaris*): Turn off tk and tcl
+ temporarily.
+
+Thu Apr 25 11:48:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't configure --with-gnu-ld on AIX.
+
+Thu Apr 25 06:33:36 1996 Michael Meissner <meissner@wogglebug.tiac.net>
+
+ * configure.in (powerpcle-*-solaris*): Turn off gdb temporarily.
+
+Tue Apr 23 09:07:39 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * Makefile.in (ALL_MODULES): Added all-inet.
+ (CROSS_CHECK_MODULES): Added check-inet.
+ (INSTALL_MODULES): Added install-inet.
+ (CLEAN_MODULES): Added clean-inet.
+ (all-indent): New target.
+
+ * configure.in (host_tools): Added inet.
+ (native_only): Added inet.
+ (noconfigdirs): Added inet.
+
+Fri Apr 19 15:35:29 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't configure libgloss if we are not configuring
+ newlib.
+
+Wed Apr 17 19:30:01 1996 Rob Savoye <rob@chinadoll.cygnus.com>
+
+ * configure.in: Don't configure libgloss for unsupported
+ architectures.
+
+Tue Apr 16 11:17:05 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in (CLEAN_MODULES): Add clean-apache.
+
+Mon Apr 15 15:09:05 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * Makefile.in (ALL_MODULES): Include all-apache.
+ (CROSS_CHECK_MODULES): Include check-apache.
+ (INSTALL_MODULES): Include install-apache.
+ (all-apache): New target.
+
+ * configure.in: Added apache everywhere perl is seen.
+
+Mon Apr 15 14:59:13 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in: Add support for clean-{module} and
+ clean-target-{module} rules.
+
+Wed Apr 10 21:37:41 PDT 1996 Marilyn E. Sander <msander@cygnus.com>
+
+ * configure.in (*-*-ose) do not build libgloss.
+
+Mon Apr 8 16:16:20 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.guess (prep*:SunOS:5.*:*): Turn into
+ powerpele-unknown-solaris2.
+
+Mon Apr 8 14:45:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Permit --enable-shared to specify a list of
+ directories.
+
+Fri Apr 5 08:17:57 1996 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (host==solaris): Pass only the first word of $CC
+ to /usr/bin/which when checking if we're using /usr/ccs/bin/cc.
+
+Fri Apr 5 03:16:13 1996 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): pass down $(MAKE).
+
+Thu Mar 28 14:11:11 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * Makefile.in (ALL_MODULES): Include all-perl.
+ (CROSS_CHECK_MODULES): Include check-perl.
+ (INSTALL_MODULES): Include install-perl.
+ (ALL_X11_MODULES): Include all-guile.
+ (CHECK_X11_MODULES): Include check-guile.
+ (INSTALL_X11_MODULES): Include install-guile.
+ (all-perl): New target.
+ (all-guile): New target.
+
+ * configure.in (host_tools): Include perl and guile.
+ (native_only): Include perl and guile.
+ (noconfigdirs): Don't build guile and perl; no ports have been
+ done.
+
+Tue Mar 26 21:18:50 1996 Andrew Cagney <cagney@kremvax.highland.com.au>
+
+ * configure (--enable-*): Handle quoted option lists such as
+ --enable-sim-cflags='-g0 -O' better.
+
+Thu Mar 21 11:53:08 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in ({,inst}all-target): New rule so we can make and
+ install all of the target directories easily.
+
+Wed Mar 20 18:10:57 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * configure.in: Add missing global flag in sed substitution when
+ deleting `target-' from ${configdirs}.
+
+Thu Mar 14 19:15:06 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (DO_X): Don't get confused if CC contains `=' in an
+ option.
+
+ * configure.in (mips*-nec-sysvr4*): Use a host_makefile_frag of
+ config/mh-necv4.
+
+ * install.sh: Correct misspelling of transformbasename.
+
+ * config.guess: Recognize mips-*-sysv*.
+
+Mon Mar 11 15:36:42 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * config.sub: Recognize mon960.
+
+Sun Mar 10 13:18:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Restore Canadian Cross handling of BISON and LEX,
+ removed in Feb 20 change.
+
+Fri Mar 8 20:07:09 1996 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * README: Suggestions from Torbjorn Granlund <tege@matematik.su.se>:
+ Mention make install. Remove the old copyright date as well the
+ clumsy and rather pointless copyright on the README file.
+
+Fri Mar 8 17:51:35 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If there is a
+ Makefile after running symlink-tree, then run `make distclean' to
+ avoid clobbering any generated files in srcdir.
+
+Tue Mar 5 08:21:44 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (m68k-*-netbsd*): Build everything now.
+
+Wed Feb 28 12:25:46 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (taz): Fix quoting.
+
+Tue Feb 27 11:33:57 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * configure.in (sparclet-*-*): Build everything now.
+
+Tue Feb 27 14:31:51 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * configure.in (m68k-*-linux*): New host.
+
+Mon Feb 26 14:32:44 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Check for bison before byacc.
+
+Tue Feb 20 23:12:35 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * Makefile.in configure: Change the way LEX and BISON/YACC are
+ set. configure now defines DEFAULT_LEX and DEFAULT_YACC by
+ searching PATH. These are used as fallbacks by Makefile.in if
+ flex/bison/byacc aren't in objdir.
+
+Mon Feb 19 11:45:30 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Make everything which depends upon all-bfd also
+ depend upon all-opcodes, in case --with-commonbfdlib is used.
+
+Thu Feb 15 19:50:50 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (host *-*-cygwin32): Don't build gdb if we are
+ building NT native compilers on Unix.
+
+Thu Feb 15 17:42:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't get CC from the host Makefile fragment if we
+ can find gcc in PATH, or if this is a Canadian Cross. Move the
+ Solaris test for /usr/ucb/cc to the post target script, just after
+ the compiler sanity test.
+
+Wed Feb 14 16:57:40 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Merge with FSF.
+
+Tue Feb 13 14:27:48 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (RPATH_ENVVAR): New variable.
+ (REALLY_SET_LIB_PATH): Use it.
+ * configure.in: On HP/UX, set RPATH_ENVVAR to SHLIB_PATH.
+
+Mon Feb 12 15:28:49 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * config.sub, configure.in: Recognize sparclet cpu.
+
+Mon Feb 12 15:33:59 1996 Christian Bauernfeind <chrisbfd@theorie3.physik.uni-erlangen.de>
+
+ * config.guess: Support m68k-cbm-sysv4.
+
+Sat Feb 10 12:06:42 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * config.guess (*:Linux:*:*): Guess m68k-unknown-linux and
+ m68k-unknown-linuxaout from linker help string. Put quotes around
+ $ld_help_string.
+
+Thu Dec 7 09:03:24 1995 Tom Horsley <Tom.Horsley@mail.hcsc.com>
+
+ * config.guess (powerpc-harris-powerunix): Add guess for port
+ to new target.
+
+Thu Feb 8 15:37:52 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * config.guess (UNAME_VERSION): Recognize X4.x as an OSF version.
+
+Mon Feb 5 16:36:51 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: If --enable-shared was used, set SET_LIB_PATH to
+ $(REALLY_SET_LIB_PATH) in Makefile.
+ * Makefile.in (SET_LIB_PATH): New variable.
+ (REALLY_SET_LIB_PATH): New variable.
+ ($(DO_X)): Use $(SET_LIB_PATH).
+ (install.all, gcc-no-fixedincludes, $(ALL_MODULES)): Likewise.
+ ($(NATIVE_CHECK_MODULES), $(CROSS_CHECK_MODULES)): Likewise.
+ ($(INSTALL_MODULES), $(CONFIGURE_TARGET_MODULES)): Likewise.
+ ($(ALL_TARGET_MODULES), $(CHECK_TARGET_MODULES)): Likewise.
+ ($(INSTALL_TARGET_MODULES), $(ALL_X11_MODULES)): Likewise.
+ ($(CHECK_X11_MODULES), $(INSTALL_X11_MODULES)): Likewise.
+ (all-gcc, all-bootstrap, check-gcc, install-gcc): Likewise.
+ (install-dosrel): Likewise.
+ (all-opcodes): Depend upon all-libiberty.
+
+Sun Feb 4 16:51:11 1996 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * config.guess (*:CYGWIN*): New
+
+Sat Feb 3 10:42:35 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in (all-target-winsup): All all-target-libiberty.
+
+Fri Feb 2 17:58:56 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (noconfigdirs): Add missing # in front of comment.
+
+Thu Feb 1 14:38:13 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: add second pass to things added to noconfigdirs
+ so *-gm-magic can exclude libgloss properly.
+
+Thu Feb 1 11:10:16 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure (extralibs_name, rez_name): Set correctly
+ for MWC68K compiler.
+
+ * mpw-README: Add more info on the necessary build tools.
+
+Thu Feb 1 10:22:38 1996 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * configure.in, config.sub: Recognize cygwin32.
+
+Wed Jan 31 14:17:10 1996 Richard Henderson <rth@tamu.edu>
+
+ * config.guess, config.sub: Recognize A/UX.
+
+Wed Jan 31 13:52:14 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Merge with gcc/config.sub.
+
+Thu Jan 25 11:01:10 1996 Raymond Jou <rjou@mexican.cygnus.com>
+
+ * mpw-build.in (do-binutils): Add build of stamps.
+
+Thu Jan 25 17:05:26 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * config.sub: Add recognition for mips64vr4100*-* targets.
+
+Wed Jan 24 12:47:55 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * test-build.mk: Add checking of `hpux9' rather than just `hpux'.
+ Add creation of gconfigargs with `--enable-shared' turned on.
+ ($(host)-stamp-stage2-configured): Pass $(gconfigargs).
+ ($(host)-stamp-stage3-configured): Likewise.
+ (HOLES): Add chatr and ldd.
+ (i386-ncr-sysv4.3*): Add use of /usr/ccs/bin in the PATH and HOLE_DIRS.
+
+Wed Jan 24 20:32:30 1996 Torbjorn Granlund <tege@noisy.matematik.su.se>
+
+ * configure: Pass --nfp to recursive configures.
+
+Mon Jan 22 10:41:56 1996 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * Makefile.in (DLLTOOL): New.
+ (DLLTOOL_FOR_TARGET): New.
+ (EXTRA_HOST_FLAGS): Pass down DLLTOOL.
+ (EXTRA_TARGET_FLAGS): Ditto.
+ (EXTRA_GCC_FLAGS): Ditto.
+ (CONFIGURE_TARGET_MODULES): Ditto.
+ (DO_X): Ditto.
+ * configure: Add DLLTOOL.
+
+Fri Jan 19 13:30:15 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ SCO OpenServer 5 changes from Robert Lipe <robertl@dgii.com>:
+ * configure.in (i[345]86-*-sco3.2v5*): Use mh-sysv instead of
+ mh-sco, since old workarounds no longer needed, and don't
+ build ld, since libraries have weak symbols in COFF.
+
+Sun Jan 14 23:01:31 1996 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (CONFIGURE_TARGET_MODULES): Add missing ';'.
+
+Fri Jan 12 15:25:35 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Make sure that ${CC} can be used to compile an
+ executable.
+
+Wed Jan 3 17:54:41 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (newlib.tar.gz): Delete building of newlib's info files.
+
+Mon Jan 1 19:09:14 1996 Brendan Kehoe <brendan@rtl.cygnus.com>
+
+ * configure.in (noconfigdirs): Put ld or gas in this early, if the
+ user specifically used --with-gnu-ld=no or --with-gnu-as=no.
+
+Sat Dec 30 16:08:57 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * config-ml.in: Add support for
+ --disable-{softfloat,m68881,m68000,m68020} on m68*-*-*.
+ Simplify setting of multidirs from --disable-foo.
+
+Fri Dec 29 07:56:11 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Makefile.in (EXTRA_GCC_FLAGS): If any of the make variables
+ LANGUAGES, BOOT_CFLAGS, STMP_FIXPROTO, LIMITS_H_TEST,
+ LIBGCC1_TEST, LIBGCC2_CFLAGS, LIBGCC2_INCLUDES, and ENQUIRE are
+ non-empty, pass them on to the GCC make.
+ (all-bootstrap): New rule that is like all-gcc, except it executes
+ the GCC bootstrap rule instead of the GCC all rule.
+
+Wed Dec 27 15:51:48 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * config-ml.in (ml_realsrcdir): New, to account for ${subdir}.
+
+Tue Dec 26 11:45:31 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.guess (AViiON:dgux:*:*): Update from FSF to add pentium
+ DG/UX support.
+
+Fri Dec 15 10:01:27 1995 Stan Cox <coxs@dg-rtp.dg.com>
+
+ * config.sub (i*86*) Change [345] to [3456]
+
+Wed Dec 20 17:41:40 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure.in (noconfigdirs): Add gas or ld if --with-gnu-as=no or
+ --with-gnu-ld=no.
+
+Wed Dec 20 15:15:35 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config-ml.in (rs6000*, powerpc*): Add switches to control which
+ AIX multilibs get built.
+
+Mon Dec 18 17:55:46 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (i386-win32): Don't build expect if we're not
+ building the tcl subdir.
+
+Mon Dec 18 11:47:19 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * Makefile.in: (configure-target-examples, all-target-examples):
+ New targets, configure and build example programs.
+
+Fri Dec 15 16:13:03 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: If an mpw-config.in generated a file mk.sed,
+ use it as input to sedit the generated MPW makefile.
+ * mpw-README: Add a suggestion about Gestalt.h.
+
+Wed Dec 13 16:43:51 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Accept *-*-ieee*.
+
+Tue Dec 12 11:52:57 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (local-distclean): Remove $(TARGET_SUBDIR). From
+ Ronald F. Guilmette <rfg@monkeys.com>.
+
+Mon Dec 11 15:31:58 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (host==powerpc-pe): Add many directories to noconfigdirs
+ for powerpc-pe native.
+ (target==i386-win32): add tcl, make to noconfigdirs if canadian cross.
+ (target==powerpc-pe): duplicate i386-win32 entry.
+
+Sat Dec 9 14:58:28 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * configure.in (noconfigdirs): Exclude target-newlib for all versions
+ of vxworks, not just vxworks5.1.
+
+Mon Dec 4 12:05:40 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Add support for exec-prefix.
+
+Mon Dec 4 10:22:50 1995 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * config.guess: Recognize HP model 816 machines as having
+ a PA1.1 processor.
+
+Mon Dec 4 12:38:15 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Ignore new autoconf configure options.
+
+Thu Nov 30 14:45:25 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * config/mt-v810 (CC_FOR_TARGET): Add -ansi flag. NEC compiler
+ defaults to K&R mode, but doesn't have varargs.h, so we have to
+ compile in ANSI mode.
+
+Thu Nov 30 16:57:33 1995 Per Bothner <bothner@wombat.gnu.ai.mit.edu>
+
+ * config.guess: Recognize Pentium under SCO.
+ From Robert Lipe <robertl@arnet.com>.
+
+Wed Nov 29 13:49:08 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (noconfigdirs): Disable target-libio on v810-*-*.
+ * config/mt-v810 (CC_FOR_TARGET, AS_FOR_TARGET, AR_FOR_TARGET,
+ RANLIB_FOR_TARGET): Set as appropriate for NEC v810 toolchain.
+
+Wed Nov 29 12:12:01 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't configure gas for alpha-dec-osf*.
+
+Tue Nov 28 17:16:48 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Default to --with-stabs for some targets for which
+ it makes sense: mips*-*-*, alpha*-*-osf*, i[345]86*-*-sysv4* and
+ i[345]86*-*-unixware*.
+
+Mon Nov 27 13:44:15 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config-ml.in: Get list of multidirs using gcc --print-multi-lib
+ rather than basing it on the target. Simplify handling of options
+ controlling which directories to configure. Remove extraneous
+ slash in multi-clean target.
+
+Fri Nov 24 17:29:29 1995 Doug Evans <dje@deneb.cygnus.com>
+
+ * config-ml.in: Prefix more variables with ml_ so they don't collide
+ with configure's.
+
+Wed Nov 22 11:27:02 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Don't turn -v into --v.
+
+Tue Nov 21 16:48:02 1995 Doug Evans <dje@deneb.cygnus.com>
+
+ * configure.in (targargs): Fix typo.
+
+ * Makefile.in (DEVO_SUPPORT): Add symlink-tree.
+
+Tue Nov 21 14:08:28 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Strip --host and --target options from
+ CONFIG_ARGUMENTS, and always configure for --host only. Add
+ --with-cross-host option when building with a cross-compiler.
+ * configure: Canonicalize the arguments put into config.status by
+ always using `=' for an option with an argument. Pass a presumed
+ --host or --target explicitly.
+
+Fri Nov 17 17:50:30 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * config.sub: Merge -macos*, -magic*, -pe*, and -win32 cases
+ into general OS recognition case.
+
+Fri Nov 17 17:42:25 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (target_configdirs): add target-winsup only
+ for win32 target systems.
+
+Thu Nov 16 14:04:47 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (all-target-libgloss): Depend upon
+ configure-target-newlib, since when libgloss is built it looks to
+ see if the newlib directory exists.
+
+Wed Nov 15 14:47:52 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (DEVO_SUPPORT): Use config-ml.in instead of
+ cfg-ml-*.in.
+
+Wed Nov 15 11:45:23 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Handle LD and LD_FOR_TARGET when configuring a
+ Canadian Cross.
+
+Tue Nov 14 15:03:12 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * config/mh-i386win32: add LD_FOR_TARGET.
+
+Tue Nov 14 14:56:11 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (target_libs): add target-winsup.
+ (target==i386-win32): add patch diff flex make to $noconfigdirs.
+ (target==ppcle-pe): remove ld from $noconfigdirs.
+
+Tue Nov 14 01:25:50 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (CONFIGURE_TARGET_MODULES): Pass --with-target-subdir.
+ Preserve relative path names in $srcdir. Build symlink tree if
+ configuring cross target dir and srcdir=. (= no VPATH support).
+ (configure-target-libg++): Depend on configure-target-librx.
+ * cfg-ml-com.in, cfg-ml-pos.in: Deleted.
+ * config-ml.in: New file.
+ * symlink-tree: New file.
+ * configure: Ensure srcdir="." if that's what it is.
+
+Mon Nov 13 12:34:20 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-README: Clarify some phrasing, add notes about CodeWarrior
+ includes and FLEX_SKELETON setting.
+ * mpw-configure (--with-gnu-ld): New option, controls whether
+ to use PPCLink or ld with PowerMac GCC.
+ * mpw-build.in (all-grez, do-grez, install-grez): New targets.
+ * mpw-config.in: Configure grez if targeting Mac.
+
+ * config.sub: Accept pmac and pmac-mpw as names for PowerMacs,
+ accept mpw and mac-mpw as names for m68k Macs, change macos7 to
+ just macos.
+ * configure.in: Configure grez resource compiler if targeting Mac.
+ * Makefile.in (all-grez, install-grez): New targets.
+
+Wed Nov 8 17:33:51 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * configure: CXX defaults to gcc, not g++. If we find
+ gcc in the path, set CC to gcc -O2.
+
+Tue Nov 7 15:45:17 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Default ${build} correctly. Avoid picking up extra
+ spaces when reading CC and CXX from Makefile. When doing a
+ Canadian Cross, use plausible default values for numerous
+ variables.
+ * configure.in: When doing a Canadian Cross, don't try to
+ configure tools whose configure script can't handle it.
+
+Mon Nov 6 19:32:17 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * cfg-ml-com.in (sh-*-*): Add m2 and ml/m2 to multidirs.
+
+Sun Nov 5 00:15:41 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * configure: Remove dubious bug reporting address.
+
+Fri Nov 3 08:17:54 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If subdir has
+ configure script, run that instead of this directory's configure.
+ In either case, print a message that we're configuring the sub-dir.
+
+Thu Nov 2 23:23:36 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * configure.in: Before checking for the existence of various files,
+ use sed to filter out "target-".
+
+Thu Nov 2 13:24:56 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (DO_X): Split rule to decrease command line length
+ for systems with small ARG_MAX values. From phdm@info.ucl.ac.be
+ (Philippe De Muyter).
+
+Wed Nov 1 15:18:35 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Makefile.in (all-patch): depend on all-libiberty.
+
+Wed Nov 1 12:23:20 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: If the only directory in target_configdirs which
+ actually exists is libiberty, then set target_configdirs to empty,
+ to avoid trying to build a target libiberty in a gas or gdb
+ distribution.
+
+Tue Oct 31 17:52:39 1995 J.T. Conklin <jtc@slave.cygnus.com>
+
+ * configure.in (host_makefile_frag): Use m68k-sun-sunos* instead
+ of m68k-sun-* when selecting mh-sun3 to avoid matching NetBSD/sun3
+ systems.
+
+Tue Oct 31 16:57:32 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * configure.in (copy_dirs): Use sys-include instead of include
+ for --with-headers option.
+
+Tue Oct 31 10:29:36 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * Makefile.in, configure.in: Make winsup builds work with
+ new scheme.
+
+Mon Oct 30 18:57:09 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Build the linker on AIX.
+
+Mon Oct 30 12:27:16 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Add $(TARGET_SUBDIR)
+ where needed.
+
+Mon Oct 30 12:45:25 1995 Doug Evans <dje@cygnus.com>
+
+ * Makefile.in (all-gcc): Fix typo.
+
+Sat Oct 28 10:27:59 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in ($(CHECK_TARGET_MODULES)): Fix typo.
+
+Fri Oct 27 23:14:12 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * configure.in: Rename libFOO to target-libFOO, and xiberty
+ to target-xiberty, to provide more flexibility.
+ (target_subdir): Define. Create if cross.
+ Set TARGET_SUBDIR in Makefile to ${target_subdir}.
+ * Makefile.in: Rename all-libFOO -> all-target-libFOO, all-xiberty
+ -> all-target-libiberty, configure-libFOO -> configure-target-libFOO,
+ check-libFOO -> check-target-libFOO, etc.
+ ($(DO_X)): Iterate over TARGET_CONFIGDIRS after SUBDIRS.
+ ($(CONFIGURE_TARGET_MODULES), $(CHECK_TARGET_MODULES),
+ $(ALL_TARGET_MODULES), $(INSTALL_TARGET_MODULES)): Update accordingly.
+ (configure-target-XXX): Depend on $(ALL_GCC), not all-gcc, to
+ allow ALL_GCC="" to only configure.
+ (DEVO_SUPPORT): Add cfg-ml-com.in and cfg-ml-pos.in.
+ (ETC_SUPPORT, ETC_SUPPORT_PFX): Merge; update 'taz' accordingly.
+ (LIBGXX_SUPPORT_DIRS): Remove xiberty.
+
+Sat Oct 28 01:53:49 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (taz): Build "info" in etc explicitly.
+
+Fri Oct 27 09:32:30 1995 Stu Grossman (grossman@cygnus.com)
+
+ * configure.in: Make sure that CC is undefined (as opposed to
+ null) if toplevel/config/mh-{host} doesn't define it. Fixes a
+ problem with autoconf trying to configure on a host without GCC.
+
+Thu Oct 26 22:35:01 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Set host alias from choice of host compiler,
+ only use generic MPW Makefile sed if present, edit a file
+ named "hacked_Makefile.in" instead of "Makefile.in" if present.
+ * mpw-README: Add problem notes about CW6 and CW7.
+
+Thu Oct 26 05:45:10 1995 Ken Raeburn <raeburn@kr-pc.cygnus.com>
+
+ * Makefile.in (taz): Use ";" instead of ";;".
+
+Wed Oct 25 15:18:24 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in (taz): Grep for '^diststuff:' or '^info:' in
+ sub-directory Makefiles, instead of using DISTSTUFFDIRS and
+ DISTDOCDIRS.
+ (DISTSTUFFDIRS, DISTDOCDIRS): Removed - no longer used.
+ (newlib.tar.gz): Don't pass DISTDOCDIRS to recursive make.
+
+Wed Oct 25 14:43:55 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in (DISTDOCDIRS): Remove ld gprof bnutils gas libg++ gdb
+ and gnats, because they are now subsumed by DISTSTUFFDIRS.
+ Move bfd to DISTSTUFFDIRS.
+
+Tue Oct 24 18:19:09 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Makefile.in (X11_LIB): Removed.
+ (X11_FLAGS_TO_PASS): pass only X11_EXTRA_CFLAGS and X11_EXTRA_LIBS.
+
+ * configure.in (host_makefile_frag): mh-aix & mh-sun removed.
+
+Sun Oct 22 13:04:42 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cfg-ml-com.in (powerpc*): Shorten some of the multilib directory
+ names.
+
+Fri Oct 20 18:02:10 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cfg-ml-com.in (powerpc*-eabi*): Add mcall-aixdesc varients.
+
+Thu Oct 19 10:40:57 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * configure.in (i[345]86-*-win32): Always build newlib.
+ Don't configure cvs, autoconf or texinfo.
+ * Makefile.in (LD_FOR_TARGET): New.
+ (BASE_FLAGS_TO_PASS, EXTRA_TARGET_FLAGS, CONFIGURE_TARGET_MODULES):
+ Pass down LD_FOR_TARGET.
+
+Wed Oct 18 15:53:56 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * winsup: New directory.
+ * Makefile.in: Build winsup.
+ * configure.in: Winsup is configured when target is win32.
+ Can only build win32 target GDB when native.
+
+Mon Oct 16 09:42:31 1995 Jeffrey A Law (law@cygnus.com)
+
+ * config.guess: Recognize HP model 819 machines as having
+ a PA 1.1 processor.
+
+Mon Oct 16 10:49:43 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Fix sed loop which substitutes for CC and CXX to
+ avoid bug found in various sed implementations.
+
+Wed Oct 11 16:16:20 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cfg-ml-com.in (powerpc-*-eabisim): Delete separate rule for
+ simulator. Use standard powerpc-*-eabi*.
+
+Mon Oct 9 17:21:56 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Stop putting gas and binutils in noconfigdirs for
+ powerpc-*-aix* and rs6000-*-*.
+
+Mon Oct 9 12:38:40 1995 Michael Meissner <meissner@cygnus.com>
+
+ * cfg-ml-com.in (powerpc*-*-eabisim*): Add support for building
+ -mcall-aixdesc libraries.
+
+Fri Oct 6 16:17:57 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * config.sub (arm | armel | armeb): Fix shell syntax.
+
+Fri Oct 6 14:40:28 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cfg-ml-com.in ({powerpc,rs6000}-ibm-aix*): Add multilibs for
+ -msoft-float and -mcpu=common support.
+ (powerpc*-*-eabisim*): Add support for building -mcall-aix
+ libraries.
+
+Thu Oct 5 13:26:37 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure.in: Allow configuration and build of emacs19 for the alpha.
+
+Wed Oct 4 22:05:36 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (CC): Get ^CC, not just any old CC, from
+ ${host_makefile_frag}.
+
+Wed Oct 4 21:55:00 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (CC): Try to get CC from
+ ${srcdir}/${host_makefile_frag}, not ${host_makefile_frag}.
+
+Wed Oct 4 21:44:12 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Makefile.in (TARGET_CONFIGDIRS): configure targetdirs
+ only if it exists in $(srcdir).
+
+Wed Oct 4 11:52:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: If CC and CXX are not set in the environment, set
+ them, based on either an existing Makefile or on searching for gcc
+ in PATH. Substitute for CC and CXX in Makefile.
+ * configure.in: Remove libm from target_libs. Separate
+ target_configdirs from configdirs. If CC is not set in
+ environment, try to get it from a host Makefile fragment. Rewrite
+ changes of configdirs to use skipdirs instead. A few minor
+ tweaks. Take directories out of target_configdirs as they are
+ taken out of configdirs. Remove existing Makefile files from
+ subdirectories. Substitute for TARGET_CONFIGDIRS and
+ CONFIG_ARGUMENTS in Makefile.
+ * Makefile.in (TARGET_CONFIGDIRS): New variable, automatically set
+ by configure.in.
+ (CONFIG_ARGUMENTS): Likewise.
+ (CONFIGURE_TARGET_MODULES): New variable.
+ ($(DO_X)): Loop over TARGET_CONFIGDIRS as well as SUBDIRS.
+ ($(CONFIGURE_TARGET_MODULES)): New target.
+ (configure-libg++, configure-libio): New targets.
+ (all-libg++): Depend upon configure-libg++.
+ (all-libio): Depend upon configure-libio.
+ (configure-libgloss, all-libgloss): New targets.
+ (configure-libstdc++): New target.
+ (all-libstdc++): Depend upon configure-libstdc++.
+ (configure-librx, all-librx): New targets.
+ (configure-newlib): New target.
+ (all-newlib): Depend upon configure-newlib
+ (configure-xiberty): New target.
+ (all-xiberty): Depend upon configure-xiberty.
+
+Sat Sep 30 04:32:59 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in (host i[345]86-*-win32): Expand the
+ noconfigdirs again.
+
+Thu Sep 28 21:18:49 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-configure: Fix sed command file name.
+
+Thu Sep 28 17:39:56 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * configure.in (host i[345]86-*-win32): Reduce the
+ noconfigdirs again.
+
+Wed Sep 27 12:24:00 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't configure ld and gdb for powerpc*-*-winnt*
+ or powerpc*-*-pe*, since they are not yet supported.
+
+Tue Sep 26 14:30:01 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ Add PowerMac support and many other enhancements.
+ * mpw-configure: New option --cc to select compiler to use,
+ paste options set according to --cc into the generated
+ Makefile, generate the Makefile by sed'ing the Unix Makefile.in
+ if mpw-make.sed is present.
+ * mpw-config.in: Don't test for gC1, test for mpw-touch,
+ add forward includes for PowerPC include files.
+ * mpw-build.in: Build using Makefile.PPC if present.
+ (do-byacc, etc): Remove separate version resource builds.
+ (do-gas): Build "stamps" before "all".
+ (do-gcc): Build "stamps-h" and "stamps-c" before "all".
+ * mpw-README: Update to reflect --cc option, PowerMac support,
+ and recently-reported compatibility problems.
+
+Fri Sep 22 12:15:42 1995 Doug Evans <dje@deneb.cygnus.com>
+
+ * cfg-ml-com.in (m68*-*-*): Only build multilibs for
+ embedded m68k systems (-aout, -coff, -elf, -vxworks).
+ (--with-multilib-top): Pass to recursive invocations.
+
+Tue Sep 19 13:51:05 1995 J.T. Conklin <jtc@blues.cygnus.com>
+
+ * configure.in (noconfigdirs): Disable libg++ and libstdc++ on
+ v810-*-*.
+
+Mon Sep 18 23:08:26 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (noconfigdirs): Disable bfd, binutils, gas, gcc,
+ gdb, ld and opcodes on v810-*-*.
+
+Sat Sep 16 18:31:08 PDT 1995 Angela Marie Thomas <angela@cygnus.com>
+
+ * config/mh-ncrsvr43: Removed AR_FLAGS
+
+Tue Sep 12 18:03:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (DO_X): Change do-realclean to do-maintainer-clean.
+ (local-maintainer-clean): New target.
+ (maintainer-clean): New target.
+ (realclean): Just depend upon maintainer-clean.
+
+Fri Sep 8 17:11:14 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (noconfigdirs): Disable gdb on m68k-*-netbsd*.
+
+Fri Sep 8 16:46:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Build ld in mips*-*-bsd* case.
+
+Thu Sep 7 20:03:41 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * config.sub: Accept -lites* OS. From Ian Dall.
+
+Fri Sep 1 08:06:58 1995 James G. Smith <jsmith@beauty.cygnus.com>
+
+ * config.sub: recognise mips64vr4300 and mips64vr4300el as valid
+ targets.
+
+Wed Aug 30 21:06:50 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * configure.in: treat i386-win32 canadian cross the same as
+ i386-go32 canadian cross.
+
+Thu Aug 24 14:53:20 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cfg-ml-com.in (powerpc*-*-eabisim): Add support for PowerPC
+ running under the simulator to build a reduced set of libraries.
+ (powerpc-*-eabiaix): Add fine grained multilib support added to
+ other powerpc targets yesterday.
+
+Wed Aug 23 09:41:56 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cfg-ml-com.in (powerpc*): Add support for -disable-biendian,
+ -disable-softfloat, -disable-relocatable, -disable-aix, and
+ -disable-sysv to control which multilib libraries get built.
+
+Thu Aug 17 16:03:41 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ * configure: Add Makefile.tem to list of files to remove in trap
+ handler.
+
+Mon Aug 14 19:27:56 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * config.guess (*Linux*): Add missing "exit"s.
+ Also, need specific check for alpha-unknown-linux (uses COFF).
+
+Fri Aug 11 15:38:20 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * config.guess: Merge with FSF:
+
+ Wed Jun 28 17:57:27 1995 David Edelsohn <edelsohn@mhpcc.edu>
+ * config.guess (AIX4): More robust release numbering discovery.
+
+ Thu Jun 22 19:01:24 1995 Kenneth Stailey (kstailey@eagle.dol-esa.gov)
+ * config.guess (i386-sequent-ptx): Properly get version number.
+
+ Thu Jun 22 18:36:42 1995 Uwe Seimet (seimet@iris1.chemie.uni-kl.de)
+ * config.guess (mips:*:4*:UMIPS): New case.
+
+Mon Aug 7 09:21:35 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * configure.in (i386-go32 host): Fix typo (deja-gnu -> dejagnu).
+ (i386-win32 host): Likewise. Don't build readline.
+
+Fri Aug 4 13:04:36 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (GDB_SUPPORT_DIRS): Add utils.
+ (DEVO_SUPPORT): Add mpw-README, mpw-build.in, mpw-config.h and
+ mpw-configure.
+
+Wed Aug 2 16:32:40 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * configure.in (appdirs): Use =, not ==, in test expression when
+ trying to build the text to print in the warning message for
+ Solaris users.
+
+Mon Jul 31 09:56:18 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * cfg-ml-com.in (z8k-*-coff): Add 'std' multilib build.
+
+Fri Jul 28 00:16:31 1995 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * config.guess: Recognize lynx-2.3.
+
+Thu Jul 27 15:47:59 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * config.sub (z8ksim): Deleted
+ (z8k-*-coff): New, this is the one true name of the target.
+
+Thu Jul 27 14:33:33 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * cfg-ml-pos.in (dotdot): Work around SunOS sed bug.
+
+Thu Jul 27 13:31:05 1995 Fred Fish (fnf@cygnus.com)
+
+ * config.guess (*:Linux:*:*): First try asking the linker what the
+ default object file format is (elf, aout, or coff). Then if this
+ fails, try previous methods.
+
+Thu Jul 27 11:28:17 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in: Don't build newlib for *-*-vxworks5.1.
+
+Thu Jul 27 11:18:47 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure.in: Don't build newlib for a29k-*-vxworks5.1.
+ * test-build.mk: Add setting of --with-headers for a29k-vxworks5.1.
+
+Tue Jul 25 21:25:39 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * cfg-ml-pos.in (MULTITOP): Trim excess trailing "/.".
+
+Fri Jul 21 10:41:12 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * cfg-ml-com.in: New file.
+ * cfg-ml-pos.in: New file.
+
+Wed Jul 19 00:37:27 1995 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * COPYING.NEWLIB: Add HP free copyright to list.
+
+Tue Jul 18 10:58:51 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.sub: Recognize -eabi* for the system, not just -eabi.
+
+Mon Jul 3 13:44:51 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * Makfile.in (DLLTOOL_FOR_TARGET): New name, pass it down.
+ * config.sub, configure.in (win32): New target and host.
+
+Wed Jun 28 23:57:08 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * configure.in: Add i386-pe configuration.
+
+Fri Jun 23 14:28:44 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-build.in (install): Install GDB after LD.
+
+Thu Jun 22 17:10:53 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in (elf/mips.h): Always forward-include, needed
+ for GDB to build.
+
+Wed Jun 21 15:17:30 1995 Rob Savoye <rob@darkstar.cygnus.com>
+
+ * testsuite: New directory for customer acceptance and whole tool
+ chain tests.
+
+Wed Jun 21 16:50:29 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * configure: If per-host line isn't found, but AC_OUTPUT is found
+ and a configure script exists, run it instead.
+
+Thu Jun 15 21:09:24 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * config.guess: Update from FSF, for alpha-dec-winnt3.5 and Crays.
+
+Tue Jun 13 21:43:27 1995 Rob Savoye <rob@darkstar.cygnus.com>
+
+ * configure: Set build_{cpu,vendor,os,alias} to host values when
+ --build isn't specified.
+
+Mon Jun 5 18:26:36 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in (PICFLAG, PICFLAG_FOR_TARGET): New macros.
+ (FLAGS_TO_PASS): Pass them.
+ (EXTRA_TARGET_FLAGS): Ditto.
+
+ * config/m?-*pic: Define PICFLAG* instead of LIB*FLAGS*.
+
+Wed May 31 22:27:42 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * Makefile.in (all-libg++): Depend on all-libstdc++.
+
+Thu May 25 22:40:59 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (noconfigdirs): Enable all packages for
+ i386-unknown-netbsd.
+
+Sat May 20 13:22:31 1995 Angela Marie Thomas <angela@cirdan.cygnus.com>
+
+ * configure.in (noconfigdirs): Don't configure tk for i386-go32
+ hosted builds (DOS builds)
+
+Thu May 18 18:08:49 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Changes for ARM based on patches from Richard Earnshaw:
+ * config.sub: Handle armeb and armel.
+ * configure.in: Omit arm linker only for riscix.
+
+Thu May 11 17:23:26 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * config.guess: Update from FSF.
+
+Tue May 9 15:52:05 1995 Michael Meissner <meissner@cygnus.com>
+
+ * config.sub: Recognize powerpcle as the little endian varient of
+ the PowerPC. Recgonize ppc as a PowerPC variant, and ppcle as a
+ powerpcle variant. Convert pentium into i586, not i486. Add p5
+ alias for i586. Map new x86 variants p6, k5, nexgen into i586
+ temporarily.
+
+Tue May 2 16:29:41 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * configure.in (hppa*-*-lites*): Treat like hppa*-*-*elf*.
+
+Sun Apr 30 21:38:09 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * config.sub: Accept -lites* as a basic system type.
+
+Thu Apr 27 11:33:29 1995 Michael Meissner (meissner@cygnus.com)
+
+ * config.guess (*:Linux:*:*): Check for whether the pre-BFD linker is
+ installed, and if so return linuxoldld as the system name.
+
+Wed Apr 26 10:59:02 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * config.guess: Add hppa1.1-hp-lites support.
+
+Tue Apr 25 11:08:11 1995 Rob Savoye <rob@darkstar.cygnus.com>
+
+ * configure.in: Don't build newlib for m68k-vxworks5.1.
+
+Wed Apr 19 17:02:43 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * configure.in (mips-sgi-irix6): Use mh-irix5.
+
+Fri Apr 14 15:21:17 1995 Doug Evans <dje@chestnut.cygnus.com>
+
+ * Makefile.in (all-gcc): Depend on all-ld (for libgcc1-test).
+
+Wed Apr 12 16:06:01 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * test-build.mk: Enable building of shared libraries on IRIX 5 and
+ OSF/1. Fix compiler flags.
+ * build-all.mk: Support Linux and OSF/1 3.0. Fix compiler flags.
+
+Tue Apr 11 18:55:40 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * configure.in: Recognize --with-newlib.
+ (sparc-*-sunos4*): Build sim, dejagnu, expect, tcl if cross target.
+
+Mon Apr 10 11:42:22 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ Merge in support for Mac MPW as a host.
+ (Old change descriptions retained for informational value.)
+
+ * mpw-config.in: Add generic include forwards for cpu-specific
+ include files in aout and elf directories.
+
+ * mpw-configure: Added copyright.
+ * mpw-config.in: Check for presence of required build tools.
+ (target_libs): Add newlib.
+ (target_tools): Add examples.
+ (Read Me): Generate as "Read Me for MPW" instead.
+ * mpw-build.in: Base sub-builds on all-foo instead of do-foo.
+ (all-byacc, do-byacc, all-flex, do-flex, do-newlib): New actions.
+ (do-gas, do-gcc, do-gdb, do-ld): Build Version.r first.
+
+ * mpw-configure: Remove subdir-specific makefile hackery,
+ delete mk.tmp after using it.
+
+ * mpw-build.in (all): Display start and end times.
+
+ * mpw-configure (host_canonical): Set.
+ (target_cpu): Always add to makefiles.
+ (ARCHDEFS, EMUL): Add to makefile only if nonempty.
+ (TM_FILE, XM_FILE, NM_FILE): No longer add to makefile.
+ (mpw-mh-mpw): Look for in srcdir and srcroot.
+ Use sed instead of mpw-edit-prefix to edit prefix definitions.
+
+ * mpw-build.in: (install-only): New target.
+
+ * mpw-configure (host_alias, target_alias): Rename from hostalias
+ and targetalias, add into generated Makefile.
+ (mk.tmp): If present, add into generated Makefile.
+ * mpw-build.in (all-gas): Build config.h first before gas proper.
+
+ * mpw-configure (config.status): Write only if changed.
+ * mpw-config.in (readline): Configure it (not built, just used for
+ definitions).
+
+ * mpw-config.in (elf/mips.h): Add a forward include.
+
+ * mpw-config.in: Forward-include most .h files in include into
+ extra-include.
+ (readline): Don't build.
+ mpw-build.in (install): Install GDB.
+
+ * mpw-configure (prefix, mpw_prefix): Handle it.
+ * mpw-config.in (mmalloc, readline): Don't configure.
+ * mpw-build.in (thisscript): Rename to ThisScript.
+ Use mpw-build instead of BuildProgram everywhere.
+ (mmalloc, readline): Don't build.
+ * mpw-README: New file, basic documentation about the MPW port.
+
+ * mpw-config.in: Use forward-include to create include files.
+
+ * mpw-configure: Add more things to the top of each configured
+ Makefile, including contents of config/mpw-mh-mpw.
+ * mpw-config.in (extra-include): Create this directory and fill it
+ with Posix-like include files when configuring.
+
+ * config.sub (apple, mac, mpw): Add various aliases.
+
+ * mpw-build.in: New file, top-level build script fragment for MPW.
+ * mpw-configure: New file, configure script for MPW.
+ * mpw-config.in: New file, config fragment for MPW.
+
+Fri Apr 7 19:33:16 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in (host_libs): Remove glob, since it is gone from the
+ sources.
+
+Fri Mar 31 11:36:17 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Makefile.in: define empty GDB_NLM_DEPS var.
+
+ * configure.in(target_makefile_frag): use config/mt-netware
+ for netware targets.
+
+Thu Mar 30 13:51:43 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.sub: Merge in recent FSF changes. Remove linux special
+ cases.
+
+Tue Mar 28 14:47:34 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ build-all.mk,config/mh-solaris: revert these two changes:
+
+ Tue Mar 30 10:03:09 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * build-all.mk: Use CC=cc -Xs on Solaris.
+
+ Mon Mar 29 19:59:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/mh-solaris: SunPRO C needs -Xs to be able to get a
+ working xmakefile for Emacs.
+
+Tue Mar 21 10:43:32 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * glob/*: Removed. Schauer's 24 Feb 1994 readline change made us
+ stop using it.
+ * Makefile.in: Nuke all references to glob subdirectory.
+
+Thu Mar 16 13:35:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * configure.in: Fix --enable-shared logic in per-host.
+
+Mon Mar 13 12:33:15 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in (*-hp-hpux[78]*): Use mh-hpux8.
+
+Mon Mar 6 10:21:58 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in (noconfigdirs): Don't build gas on AIX, for
+ powerpc*-*-aix* as well as for rs6000*-*-aix*.
+
+Wed Mar 1 12:51:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Fix --cache-file to work if the file argument is a
+ relative path.
+
+Tue Feb 28 17:36:07 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: If the --cache-file is used, pass it down to
+ configure in subdirectories.
+
+Mon Feb 27 12:52:46 1995 Kung Hsu <kung@mexican.cygnus.com>
+
+ * config.sub: add vxworks29k configuration.
+
+Fri Feb 10 16:12:26 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (taz): Do "diststuff" part quietly.
+
+Sun Feb 5 14:16:35 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.sub: Mini-merge with gcc/config.sub.
+
+Sat Feb 4 12:11:35 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * config.guess (IRIX): Sed - to _.
+
+Fri Feb 3 11:54:42 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * Makefile.in (source-vault, binary-vault): New targets.
+
+Thu Jan 26 13:00:11 1995 Michael Meissner <meissner@cygnus.com>
+
+ * config.sub: Recognize -eabi as a basic system type.
+
+Thu Jan 12 13:13:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * configure.in (enable_shared stuff): Fix typo.
+
+Thu Jan 12 01:36:51 1995 deanm@medulla.LABS.TEK.COM (Dean Messing)
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): Fix typo in passing LIBCXXFLAGS*.
+
+Wed Jan 11 16:29:53 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in (LIBCXXFLAGS_FOR_TARGET): Add -fno-implicit-templates.
+
+Mon Jan 9 12:48:01 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
+
+ * configure.in (rs6000-*-*): Don't build gas.
+
+Wed Jan 4 23:53:49 1995 Ian Lance Taylor <ian@tweedledumb.cygnus.com>
+
+ * Makefile.in: Use /x/x/ instead of /brokensed/brokensed/, to
+ reduce command line length.
+ (AS_FOR_TARGET): Check for as.new, not Makefile.
+ (NM_FOR_TARGET): Check for nm.new, not Makefile.
+
+Wed Jan 4 13:02:39 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * config.guess: Merge from FSF.
+
+Thu Dec 15 17:11:37 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * configure: Don't use $ when handling program_suffix.
+
+Mon Dec 12 12:09:37 1994 Stu Grossman (grossman@cygnus.com)
+
+ * configure.in: Configure tk for hppa/hpux.
+
+Fri Dec 2 15:55:38 1994 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in (LIBGXX_SUPPORT_DIRS): Add libstdc++.
+
+Tue Nov 29 19:37:56 1994 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in: Move -fno-implicit-template from CXXFLAGS
+ to LIBCXXFLAGS. Tests are better run without it.
+
+Wed Nov 23 10:29:25 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * Makefile.in (all-ispell): Depend on all-emacs19 instead of all-emacs.
+
+Mon Nov 21 11:14:01 1994 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (*-*-netware*): Don't configure xiberty.
+
+Mon Nov 14 08:49:15 1994 Stu Grossman (grossman@cygnus.com)
+
+ * configure.in: Remove tk from native_only list.
+
+Fri Nov 11 15:31:26 1994 Bill Cox (bill@rtl.cygnus.com)
+
+ * build-all.mk: Add mips-ncd-elf target to sun4 targets
+ for special NCD build.
+
+Mon Nov 7 20:58:17 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (DEVO_SUPPORT): Remove configure.bat and
+ makeall.bat, they're only useful for binutils snapshots.
+ (binutils.tar.gz, gas+binutils.tar.gz): Add configure.bat and
+ makeall.bat to specified SUPPORT_FILES.
+
+Mon Nov 7 17:25:18 1994 Bill Cox (bill@cirdan.cygnus.com)
+
+ * build-all.mk: Add Ericsson targets to sun4 and solaris
+ hosts. Add BNR's sun4 target to solaris host, so their
+ build-from-source will be tested in-house first.
+
+Sat Nov 5 18:43:30 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * Makefile.in (LIBCFLAGS): New variable.
+ (CFLAGS_FOR_TARGET): Ditto.
+ (LIBCFLAGS_FOR_TARGET): Ditto.
+ (LIBCXXFLAGS): Ditto.
+ (CXXFLAGS_FOR_TARGET): Ditto.
+ (LIBCXXFLAGS_FOR_TARGET): Ditto.
+ (BASE_FLAGS_TO_PASS): Pass them.
+ (EXTRA_TARGET_FLAGS): Ditto.
+
+ * configure.in, config/m[th]-*pic: Support --enable-shared.
+
+Sat Nov 5 15:44:00 1994 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * configure.in (target_libs): Include libstdc++ again.
+ * config.guess: Update from FSF (for FreeBSD).
+
+Thu Nov 3 16:32:30 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (DEVO_SUPPORT): Include configure.bat and
+ makeall.bat.
+ (DISTDOCDIRS): Add `etc'.
+ (ETC_SUPPORT_PFX): New variable.
+ (taz): Include anything from etc starting with a word in
+ ETC_SUPPORT_PFX.
+
+Wed Oct 26 16:19:35 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * config.sub: Update for recent FSF changes. Remove obsolete
+ h8300hds entry. Add -windows* and -osx as basic os. Minor
+ spacing changes.
+
+Thu Oct 20 18:41:56 1994 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * configure.in (target_libs): Remove libstdc++ for libg++-2.6.1.
+
+ * config.guess: Merge with FSF.
+ * configure.in: Match on i?86-ncr-sysv4.3, not i?86-ncr-sysv43.
+
+Thu Oct 20 19:26:56 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * configure: Since the "trap 0" handler will override the exit
+ status on many systems, only use it for "exit 1", and make it set
+ a non-zero exit status; reset it before "exit 0". Also, check
+ exit status of config.sub, and error out if it failed.
+
+Wed Oct 19 18:49:55 1994 Rob Savoye (rob@cygnus.com)
+
+ * Makefile.in: (ALL_TARGET_MODULES,INSTALL_TARGET_MODULES) Build
+ and install libgloss.
+
+Tue Oct 18 15:25:24 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * Makefile.in (all-binutils): Depend upon all-byacc.
+
+ * configure.in: Don't build emacs on Irix 5.
+
+Mon Oct 17 16:22:12 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
+
+ * configure.in (*-*-netware*): Add libio.
+
+Thu Oct 13 15:51:20 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * Makefile.in (ALL_TARGET_MODULES): Add libstdc++.
+ (CHECK_TARGET_MODULES): Ditto.
+ (INSTALL_TARGET_MODULES): Ditto.
+ (TARGET_LIBS): Ditto.
+ (all-libstdc++): Note dependencies.
+
+Thu Oct 13 01:43:08 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (BINUTILS_SUPPORT_DIRS): Add gas.
+
+Tue Oct 11 12:12:29 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * Makefile.in (CXXFLAGS): Use -fno-implicit-templates instead of
+ -fexternal-templates.
+
+ * configure.in (target_libs): Add libstdc++.
+ (noconfigdirs): Add libstdc++ as appropriate.
+
+Thu Oct 6 18:00:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Update from FSF.
+
+Tue Oct 4 12:05:42 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * configure: Use ${config_shell} when running ${configsub}.
+
+Mon Oct 3 14:28:34 1994 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.sub: No longer recognize h8300h.
+
+Mon Oct 3 12:40:54 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * config.sub: Remove extraneous differences between config.sub and
+ gcc/config.sub.
+
+Sat Oct 1 00:23:12 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (DISTSTUFFDIRS): Add gas.
+
+Thu Sep 22 19:04:55 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * COPYING.NEWLIB: New file.
+
+Mon Sep 19 18:25:40 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess (HP-UX): Patch from Harlan Stenn
+ <harlan@landmark.com> to also emit release level.
+
+Wed Sep 7 13:15:25 1994 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * config.guess (sun4*:SunOS:*:*): Change '-JL' to '_JL'.
+
+Tue Sep 6 23:23:18 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.sub: Merge nextstep cleanup from FSF.
+
+Mon Sep 5 05:01:30 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * configure.in (arm-*-*): Don't configure ld for this target.
+
+Thu Sep 1 09:35:00 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
+
+ * configure.in (*-*-netware): don't configure libg++, libio,
+ librx, or newlib.
+
+Wed Aug 31 13:52:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure.in (alpha-dec-osf*): Use osf*, not osf1*. Don't
+ configure ld--it works, but it doesn't support shared libraries.
+
+Sun Aug 28 18:13:45 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess (*-unknown-freebsd*): Get rid of possible
+ trailing "(Release)" in version string.
+ Patch from Paul Richards <paul@isl.cf.ac.uk>.
+
+Sat Aug 27 15:00:49 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Fix i486-ncr-sysv43 -> i486-ncr-sysv4.3.
+ Fix type: *-next-neststep -> *-next-nextstep.
+
+ * config.guess: Merge from FSF:
+
+ Fri Aug 26 18:45:25 1994 Philippe De Muyter (phdm@info.ucl.ac.be)
+
+ * config.guess: Recognize powerpc-ibm-aix3.2.5.
+
+ Wed Apr 20 06:36:32 1994 Philippe De Muyter (phdm@info.ucl.ac.be)
+
+ * config.guess: Recognize UnixWare 1.1 (UNAME_SYSTEM is SYSTEM_V
+ instead of UNIX_SV for UnixWare 1.0).
+
+Sat Aug 27 01:56:30 1994 Stu Grossman (grossman@cygnus.com)
+
+ * Makefile.in (all-gdb): Add dependencies on all-gcc and all-ld
+ to make gdb/nlm/* build after the compiler and linker.
+
+Fri Aug 26 14:30:05 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess (netbsd, freebsd, linux): Accept any machine,
+ not just i[34]86.
+ (m68k-atari-sysv4): Relocate to match FSF version.
+
+ * config.guess: More merges from the FSF:
+
+ Add a space before function call or macro invocation.
+
+ Tue May 10 16:53:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
+
+ * config.guess: Add trap cmd to remove dummy.c and dummy when
+ interrupted.
+
+ Wed Apr 20 18:07:13 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
+
+ * config.guess (dummy.c): Redirect stderr for `hostinfo' command.
+ (dummy): Redirect stderr from compilation of dummy.c.
+
+ Sat Apr 9 14:59:28 1994 Christian Kranz (kranz@sent5.uni-duisburg.de)
+
+ * config.guess: Distinguish between NeXTStep 2.1 and 3.x.
+
+Fri Aug 26 13:42:20 1994 Ken Raeburn (raeburn@kr-laptop.cygnus.com)
+
+ * configure: Accept and ignore --cache*, for compatibility with
+ new autoconf.
+
+Fri Aug 26 13:05:27 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Merge from FSF:
+
+ Thu Aug 25 20:28:51 1994 Richard Stallman <rms@mole.gnu.ai.mit.edu>
+
+ * config.guess (Pyramid*:OSx*:*:*): New case.
+ (PATH): Add /.attbin at end for finding uname.
+ (dummy.c): Handle i860-alliant-bsd. Follow whitespace conventions.
+
+ Wed Aug 17 18:21:02 1994 Tor Egge (tegge@pvv.unit.no)
+
+ * config.guess (M88*:DolphinOS:*:*): New case.
+
+ Thu Aug 11 17:00:13 1994 Stan Cox (coxs@dg-rtp.dg.com)
+
+ * config.guess (AViiON:dgux:*:*): Use TARGET_BINARY_INTERFACE
+ to select whether to use ELF or COFF.
+
+ Sun Jul 24 16:20:53 1994 Richard Stallman <rms@mole.gnu.ai.mit.edu>
+
+ * config.guess: Recognize i860-stardent-sysv and i860-unknown-sysv.
+
+ Sun May 1 10:23:10 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+ * config.guess: Guess the OS version for HPUX.
+
+ Tue Mar 1 21:53:03 1994 Karl Heuer (kwzh@hal.gnu.ai.mit.edu)
+
+ * config.guess (UNAME_VERSION): Recognize aix3.2.4 and aix3.2.5.
+
+Fri Aug 26 11:19:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure.in: Recognize --with-headers, --with-libs, and
+ --without-newlib.
+ * Makefile.in (all-xiberty): Depend upon all-ld.
+
+Wed Aug 24 12:36:50 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure.in: Change i[34]86 to i[345]86.
+
+Mon Aug 22 10:58:33 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure (version): A few more tweaks to help message.
+
+Fri Aug 19 12:40:25 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * Makefile.in: Remove (for now) librx as a host library,
+ now that we're building it for target.
+
+Fri Aug 19 10:49:17 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure: Fix up help message; from karl@owl.hq.ileaf.com
+ (Karl Berry).
+
+Tue Aug 16 16:11:08 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * configure.in: Also configure librx.
+
+Mon Aug 15 16:51:45 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * Makefile.in: Update various rules to reflect that librx
+ is now needed for libg++.
+
+Fri Aug 12 18:07:21 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * config.sub: Accept mips64orion and mips64orionel as a CPU name.
+
+Mon Aug 8 11:36:17 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * configure.in: Configure the examples directory.
+
+Thu Aug 4 16:12:36 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure: Simplify Jun 2 1994 change.
+
+Wed Aug 3 04:58:16 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * change CC to /usr/latest/bin/gcc for lynx host builds, since
+ /bin/gcc isn't good enough to build gcc.
+
+Wed Jul 27 09:07:14 1994 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (GDB_SUPPORT_FILES): Remove
+ (setup-dirs-gdb, gdb.tar.gz, make-gdb.tar.gz): Remove old rules.
+ (gdb.tar.gz): Add new rule to use standard distribution building
+ mechanism.
+
+Mon Jul 25 11:10:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Warn about use of /usr/ucb/cc on Solaris. From
+ Bill Cox <bill@cygnus.com>.
+
+Sat Jul 23 12:19:46 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Recognize ISC. Patch from kwzh@gnu.ai.mit.edu.
+
+Fri Jul 22 17:53:59 1994 Stu Grossman (grossman@cygnus.com)
+
+ * configure: Search current dir first in .gdbinit.
+
+Fri Jul 22 11:28:30 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.sub: Recognize freebsd (merged from gcc config.sub).
+
+Thu Jul 21 14:10:52 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.sub: Refer to NeXT's operating system as nextstep.
+
+ * config.sub (case $basic_machine): Re-order the cases, to match
+ the order in the FSF version (which is mostly alphabethical).
+ Merge in some additions and changes from the FSF.
+
+Sat Jul 16 12:03:08 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * config.guess: Recognize m68k-atari-sysv4 and m88k-harris-csux7.
+ * config.sub: Recognize cxux7.
+ * configure.in: Use mh-cxux for m88k-harris-cxux*.
+
+Mon Jul 11 14:37:39 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.sub: Fix typo powerpc -> powerpc-*.
+
+Sat Jul 9 13:03:43 1994 Michael Tiemann (tiemann@blues.cygnus.com)
+
+ * Makefile.in: `all-emacs19' depends on `all-byacc'.
+
+ * Makefile.in: Add all-emacs19 and install-emacs19 rules (in
+ parallel with all-emacs and install-emacs). Top-level command
+ `make all-emacs19 CC=gcc' now behaves as `make all-emacs CC=gcc'.
+
+Thu Jun 30 16:53:42 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * test-build.mk ($(host)-stamp-stage2-installed): Remove
+ $(relbindir)/make before doing ``make install'', and use
+ $(GNU_MAKE) while doing it. Avoids problem on SunOS with
+ installing over running make binary.
+ ($(host)-stamp-stage3-installed): Likewise.
+
+Tue Jun 28 13:43:25 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Recognize Mach.
+
+Mon Jun 27 16:41:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * configure: Check ${exec_prefixoption}, not ${exec_prefix}, to
+ see whether --exec-prefix was used.
+
+Sun Jun 26 21:15:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * README: Explicitly mention libg++/README. (Zoo's idea.)
+
+Tue Jun 21 12:45:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Add all-librx target similar to all-libproc.
+
+Wed Jun 8 23:11:55 1994 Stu Grossman (grossman@cygnus.com)
+
+ * config.guess: Rearrange tests for Alpha-OSF1 to properly deal
+ with post 1.2 uname bogosity.
+
+Thu Jun 9 00:27:59 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure: Remove temporary files on receipt of a signal.
+
+Tue Jun 7 12:06:24 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: If there is a package_makefile_frag, remove
+ ${subdir}/Makefile.tem after copying it in.
+
+Mon Jun 6 21:35:02 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * build_all.mk: support rs6000 lynx identifies itself as
+ rs6000-lynx-lynxos2.2.2. Also, use /usr/cygnus/progressive/bin/gcc
+ since /bin/gcc is too feeble to compile a modern gcc.
+
+Mon Jun 6 16:06:34 1994 Karen Christiansen (karen@cirdan.cygnus.com)
+
+ * brought devo/test-build.mk update-to-date with progressive/
+ test-build.mk. Add lynx targets and hppa flag info.
+
+Sat Jun 4 17:23:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * configure.in: Use mh-ncrsvr43. Patch from
+ Tom McConnell <tmcconne@sedona.intel.com>.
+
+Fri Jun 3 17:47:24 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess (i386-unknown-bsdi): No longer need to
+ check #if defined(__bsdi__) && defined(__i386__).
+
+Thu Jun 2 18:56:46 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure: Set program_transform_nameoption correctly.
+
+Thu Jun 2 10:57:06 1994 Karen Christiansen (karen@cirdan.cygnus.com)
+
+ * brought build-all.mk update-to-date with progressive build-all.mk,
+ added new targets and hppa info.
+
+Thu Jun 2 00:12:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure: If config.guess result is a prefix of the user
+ specified target, assume a native build and use the user specified
+ target as the host alias. Remove SunOS patch suffix removal hack.
+ * configure.in: Remove SunOS patch suffix removal hack.
+
+ * Makefile.in (CROSS_CHECK_MODULES): Remove check-flex, since it's
+ in NATIVE_CHECK_MODULES.
+
+Wed Jun 1 10:49:41 1994 Bill Cox (bill@rtl.cygnus.com)
+
+ * Makefile.in: Rename HOST_ONLY to NATIVE.
+ * configure: Delete SunOs patch suffix from host_canonical
+ and build_canonical variables that are prepended to Makefiles.
+ * configure.in: Add comments for easier maintenance.
+
+Tue May 31 19:39:47 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Add all-libproc target similar to all-gui.
+
+Tue May 31 17:16:33 1994 Tom Lord (lord@cygnus.com)
+
+ * Makefile.in (CHECK_MODULES): split into
+ HOST_ONLY_CHECK_MODULES and CROSS_CHECK_MODULES.
+
+Tue May 31 16:36:36 1994 Paul Eggert (eggert@twinsun.com)
+
+ * config.guess (i386-unknown-bsdi): New system to guess.
+
+Wed May 25 16:47:10 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Add all-gui target (but not yet build by "all").
+
+Thu May 26 08:53:19 1994 Bill Cox (bill@rtl.cygnus.com)
+
+ * config.sub: Move deletion of patch suffix from here...
+ * configure.in: To here, at Ian's suggestion. The top-
+ level scripts might need to know of a patch level.
+
+Wed May 25 09:15:54 1994 Bill Cox (bill@rtl.cygnus.com)
+
+ * config.sub: Strip off patch suffix so rtl is recognized
+ as a sunos4.1.3 machine, even though it's been patched.
+
+Fri May 20 08:25:49 1994 Steve Chamberlain (sac@deneb.cygnus.com)
+
+ * Makefile.in (INSTALL_LAST): Delete.
+ (INSTALL_DOSREL): New.
+
+Thu May 19 17:12:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Use ld for i[34]86-*-sysv4* and sparc-*-solaris2*.
+ Don't set use_gnu_ld to no for *-*-sysv4; that only controls
+ whether we pass down --with-gnu-ld anyhow.
+
+Thu May 19 09:29:12 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * Makefile.in (INSTALL_LAST): Change operation so it works
+ on more flavors of make.
+ * configure.in (go32): Don't build libg++ or libio.
+
+Fri May 13 13:28:34 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * Makefile.in (Move HOST_PREFIX_1 and friends up so
+ they can be overriden by templates.
+
+Sat May 7 16:46:44 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * configure.in (target==go32): Don't build gdb.
+ * dosrel: New directory.
+
+Fri May 6 14:19:25 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * configure.in (host==go32): Configure dosrel too.
+ * Makefile.in (INTALL_TARGET): Call INSTALL_LAST last.
+ (HOST_CC, HOST_PREFIX, HOST_PREFIX_1): Undefine, they should
+ be set by incoming names or templates.
+ (INSTALL_LAST): New rule.
+ * config/mh-go32: New fragment.
+
+Thu May 5 17:35:05 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * config.sub (sparclitefrw, sparclitefrwcompat): Don't set the os.
+
+Thu May 5 20:06:45 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * config/mh-lynxrs6k: Renamed from mh-lynxosrs6k, to make it
+ unique in 8.3 naming schemes.
+ * configure.in (appdirs): New variable. Currently empty, but will
+ be used in gas distribution. If nonempty, lists a set of
+ directories at least one of which must get configured, or top
+ level configuration is considered to have failed.
+ (rs6000-*-lynxos*): Use new file name.
+
+Thu May 5 13:38:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Eliminate XTRAFLAGS.
+ * Makefile.in (CC_FOR_TARGET): If newlib exists, refer to the
+ newlib include files using -idirafter, and also use -nostdinc.
+ (CXX_FOR_TARGET): Likewise.
+ (XTRAFLAGS): Removed.
+ (BASE_FLAGS_TO_PASS): Remove XTRAFLAGS_FOR_TARGET.
+ (EXTRA_HOST_FLAGS): Remove XTRAFLAGS.
+ (EXTRA_TARGET_FLAGS, EXTRA_GCC_FLAGS): Likewise.
+ ($(DO_X)): Don't pass down XTRAFLAGS.
+
+Thu May 5 00:16:36 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * configure.in (mips*-dec-bsd*): New target; do build linker.
+ (mips*-*-bsd*): New target; don't build linker.
+
+Wed May 4 20:10:10 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * configure.in: support rs6000-*-lynxos* configuration.
+ support sunos4 as a cross target.
+
+ * config.sub: look for lynx*, not lynx since the OS version may
+ legitimately be part of the name.
+
+Tue May 3 21:48:11 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * configure.in (i[34]86-*-sco*): Move to be with other i386
+ targets.
+ (romp-*-*): New target. Skip various binary utilities.
+ (vax-*-*): New target. Don't build newlib.
+ (vax-*-vms): Renamed from *-*-vms. Don't build opcodes or newlib.
+
+Thu Apr 28 15:03:05 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure.in: Only set host_makefile_frag if config
+ directory exists.
+
+Wed Apr 27 12:14:30 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * install.sh: If $dstdir exists, don't check whether each
+ component does.
+
+Tue Apr 26 18:11:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * test-build.mk (HOLES): Add sleep; used by rcs/src/conf.sh.
+
+Mon Apr 25 15:06:34 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * configure.in (*-*-lynxos*): Don't configure newlib for either
+ native or cross Lynx.
+
+Sat Apr 16 11:58:16 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * config.sub (sparc64-elf): Fix os.
+ (z8k): Remove duplicate.
+
+Thu Apr 14 23:33:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Makefile.in (gcc-no-fixedincludes): Touch gcc/include/fixed, not
+ gcc/stmp-fixproto, to try to prevent fixproto from being run.
+
+Wed Apr 13 15:14:52 1994 Bill Cox (bill@cygnus.com)
+
+ * configure: Make file links cleanly even if Lynx fails on
+ an NFS symlink (at least fail cleanly).
+
+Mon Apr 11 10:58:56 1994 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * test-build.mk (CC): For mips-sgi-irix4, change -XNh1500 to
+ -XNh2000.
+
+Sat Apr 9 15:10:45 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure: Unknown options are fatal again.
+
+Fri Apr 8 12:01:41 1994 David J. Mackenzie (djm@cygnus.com)
+
+ * configure: Ignore --x-includes and --x-libraries, for Autoconf
+ compatibility.
+
+Thu Apr 7 17:31:43 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * build-all.mk: Add `clean' target.
+
+Wed Apr 6 20:44:56 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * config.guess: Add SINIX support.
+ * configure.in: Add mips-*-sysv4* support.
+
+Mon Apr 4 17:41:44 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * build-all.mk: Document all useful targets.
+ If canonhost is sparc-sun-solaris2.3, change it to sparc-sun-solaris2.
+ If canonhost is mips-sgi-irix4.0.5H, change it to mips-sgi-irix4.
+
+Thu Mar 31 04:55:57 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure: Support --silent, --quiet.
+
+Wed Mar 30 21:37:38 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure: Support --disable-FEATURE.
+
+Tue Mar 29 19:15:05 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Recognize NCR running SVR4.3.
+
+Mon Mar 28 14:55:15 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Make BSDI generate i386-unknown-bsd386.
+ Patch from Paul Eggert <eggert@twinsun.com>.
+
+Mon Mar 28 12:54:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in (powerpc-*-aix*): Treat like rs6000-*-*.
+
+Sat Mar 26 11:25:48 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure: Make unrecognized options give nonfatal warnings
+ instead of fatal errors, and pass them to any subdirectory
+ configures in case they recognize them.
+ Make --x equivalent to --with-x.
+
+Fri Mar 25 21:52:10 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure: Add --enable-* options. Clean up usage message and
+ some comments.
+
+Thu Mar 24 09:12:53 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * Makefile.in (NM_FOR_TARGET): Build tree version is now nm.new.
+
+Sun Mar 20 11:28:22 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * configure.in (hppa*-*-*): Enable binutils.
+
+Sat Mar 19 11:50:16 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.sub: Recognize cisco.
+
+Fri Mar 18 16:42:32 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * Makefile.in (CXXFLAGS): Add -fexternal-templates.
+
+Tue Mar 15 11:25:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: about target *-hitachi-hiuxwe2, don't print more
+ than one configuration name. Add comment.
+
+Sun Mar 6 23:13:38 1994 Hisashi MINAMINO (minamino@sra.co.jp)
+
+ * config.guess: about target *-hitachi-hiuxwe2, fixed
+ machine guessing order. [Hitachi's CPU_IS_HP_MC68K
+ macro is incorrect.]
+
+Sun Mar 13 09:10:08 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (TAGS): Just build TAGS in each subdirectory, rather
+ than the "make ls" stuff which used to be here.
+
+Fri Mar 11 12:52:39 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Recognize i[34]86-unknown-freebsd.
+ From Shawn M Carey <smcarey@rodan.syr.edu>.
+
+Thu Mar 3 14:24:21 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * configure.in (noconfigdirs for alpha): Remove libg++ and libio.
+
+Wed Mar 2 13:28:48 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * config.guess: Check for ptx.
+
+Mon Feb 28 16:46:50 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * config.sub: Add os9k checking.
+
+Thu Feb 24 07:09:04 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * config.guess: Handle OSF1 running on HPPA processors
+
+Fri Feb 18 14:14:00 1994 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * configure: If subdir configure fails, print out a message with
+ subdirectory name, in case subdir's configure code didn't identify
+ itself.
+
+Fri Feb 18 12:50:15 1994 Doug Evans (dje@cygnus.com)
+
+ * configure.in: Remove embedded newlines from configdirs.
+ Avoid mismatches of substrings. Fix matching strings at end
+ of configdirs.
+
+Fri Feb 11 15:33:33 1994 Stu Grossman (grossman at cygnus.com)
+
+ * config.guess: Add Lynx/rs6000 config support.
+
+Tue Feb 8 13:41:09 1994 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * configure.in (alpha-dec-osf1*, alpha*-*-*): Build gas.
+
+Mon Feb 7 15:42:36 1994 Jeffrey A. Law (law@cygnus.com)
+
+ * configure.in (hppa*-*-osf*): Treat this just like most other
+ PA configurations (eg no binutils or ld).
+ (hppa*-*-*elf*): These configurations have binutils and ld.
+
+Sun Feb 6 16:35:07 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * config.sub (hiux): Fix typo. From m-kasahr@sramhc.sra.co.JP.
+
+Sat Feb 5 01:00:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in (rs6000-*-*): Build gas.
+
+Wed Feb 2 13:57:57 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * Makefile.in: Avoid bug in losing hpux sed.
+
+Wed Feb 2 14:53:05 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in, test-build.mk: Remove MUNCH_NM; it was only needed
+ for GDB and GDB has been fixed to not need it.
+
+Mon Jan 31 18:40:55 1994 Stu Grossman (grossman at cygnus.com)
+
+ * config/mh-lynxosrs6k: Account for lack of ranlib!
+
+Sun Jan 30 17:58:06 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * config.guess: Recognize vax hosts.
+
+Fri Jan 28 15:29:38 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * configure (while loop): Don't use "break 2" inside case
+ statement -- the case statement isn't an enclosing loop.
+
+Mon Jan 24 18:40:06 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Clean up NeXT support, to allow nextstep
+ on Intel machines. Make OS be nextstep.
+
+Sun Jan 23 18:47:22 1994 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
+
+ * config.guess: Add alternate forms for Convex.
+
+Thu Jan 20 16:13:41 1994 Stu Grossman (grossman at cygnus.com)
+
+ * configure: Completely rewrite option processing. Take
+ advantage of pattern-matching to avoid invoking test frequently.
+ Also clean up host and target defaulting logic.
+
+Mon Jan 17 15:06:56 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * Makefile.in: Replace all occurrances of "rootme" with "r" and
+ "$${rootme}" with "$$r", to increase the likelihood that the do-*
+ commands (plus user environment) will fit SCO limits.
+
+Thu Jan 6 11:20:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Don't issue warnings about directories which are
+ not being configured if -norecursion is set. Correct test for
+ --with-gnu-as and --with-gnu-ld to not get confused by substring
+ matches.
+
+ * configure.in: Don't build gas for alpha-dec-osf1*.
+
+Tue Jan 4 17:10:19 1994 Stu Grossman (grossman at cygnus.com)
+
+ * configure: Back out Per's change of 12/19/1993. It changes the
+ behavior of configure in unexpected and confusing ways.
+
+ Also, use different delim char when calculating
+ program_transform_name so that the name can contain slashes.
+
+Sat Jan 1 13:45:31 1994 Rob Savoye (rob@darkstar.cygnus.com)
+
+ * configure.in, config.sub: Add support for VSTa micro-kernel.
+
+Sat Dec 25 20:00:47 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * configure.in: Nuke hacks which were used to get a special
+ version of GAS for HPPA configurations.
+
+Sun Dec 19 20:40:44 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * configure: If only ${target_alias} is given, use that
+ as the default for ${host_alias}.
+ * configure: Add missing back-slashes before nested quotes.
+
+Wed Dec 15 18:07:18 1993 david d `zoo' zuhn (zoo@andros.cygnus.com)
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): add YACC=$(BISON)
+
+Tue Dec 14 21:25:33 1993 Per Bothner (bothner@cygnus.com)
+
+ * config.guess: Recognize some Tektronix configurations.
+ From Kaveh R. Ghazi <ghazi@noc.rutgers.edu>.
+
+Sat Dec 11 11:18:00 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * config.sub: Match any flavor of SH.
+
+Thu Dec 2 17:16:58 1993 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * configure.in: Don't try to configure newlib for Alpha.
+
+Thu Dec 2 14:35:54 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Don't build ld for Irix 5. Don't build gas,
+ libg++ or libio for any Alpha target.
+
+ * configure.in (mips*-sgi-irix5*): New target; use mh-irix5.
+ * config/mh-irix5. New file for Irix 5.
+
+Wed Dec 1 17:00:33 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * Makefile.in (GZIPPROG): Renamed from GZIP, which gzip uses for
+ default arguments -- so it tried to compress itself.
+
+Tue Nov 30 13:45:15 1993 david d `zoo' zuhn (zoo@andros.cygnus.com)
+
+ * configure.in (notsupp): ensure that a space is always at the end
+ of the configdirs list, since the grep checks for an explicit space
+
+Tue Nov 16 15:04:27 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in (target i386-sysv4.2): don't build ld, since static
+ versions of many libraries are not available.
+
+Tue Nov 16 14:28:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Recognize Apollos (using environment variables).
+ * configure.in: Don't configure ld, binutils, or gprof for Apollo.
+
+Thu Nov 11 12:03:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Recognize Sony news mips running newsos.
+
+Wed Nov 10 16:57:00 1993 Mark Eichin (eichin@cygnus.com)
+
+ * Makefile.in (all-cygnus, build-cygnus): "fi else" needs to be
+ "fi ; else" for bash.
+
+Tue Nov 9 15:54:01 1993 Mark Eichin (eichin@cygnus.com)
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): pass SHELL.
+
+Fri Nov 5 08:07:27 1993 D. V. Henkel-Wallace (gumby@blues.cygnus.com)
+
+ * config.sub: accept unixware as an alias for svr4.2.
+ Fix some inconsistancies with the gcc version.
+
+Fri Nov 5 15:14:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (DISTDOCDIRS): Add gdb.
+
+Fri Nov 5 11:59:42 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * Makefile.in (DISTDOCDIRS): Add libg++ and libio.
+
+Fri Nov 5 10:35:05 1993 Ken Raeburn (raeburn@rover.cygnus.com)
+
+ * Makefile.in (taz): Only build "info" in DISTDOCDIRS.
+ (DISTDOCDIRS): Don't assume libg++ and gdb folks necessarily want
+ this now.
+
+Thu Nov 4 18:58:23 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.sub: Accept hiux* as an OS name.
+
+ * Makefile.in: Change RUNTEST_FLAGS back to RUNTESTFLAGS per
+ etc/make-stds.texi. The underscore came from gcc, and dje now
+ agrees that RUNTESTFLAGS is the correct name.
+
+Thu Nov 4 10:49:01 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * install.sh: Remove 'set -e'. It makes any conditionals
+ in the script useless.
+
+ * config.guess: Automatically recognize arm-acorn-riscix
+ Patch from Richard Earnshaw (rwe11@cl.cam.ac.uk).
+
+Thu Nov 04 08:08:04 1993 Jeffrey Wheat (cassidy@cygnus.com)
+
+ * Makefile.in: Change RUNTESTFLAGS to RUNTEST_FLAGS
+
+Wed Nov 3 22:09:46 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * Makefile.in (DISTDOCDIRS): New variable.
+ (taz): Edit local Makefile.in sooner, instead of proto-toplev
+ Makefile.in later. Build "info" and "dvi" in DISTDOCDIRS.
+
+Wed Nov 3 21:31:52 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in (hppa target): check the source directory for the
+ pagas sub-directory
+
+Wed Nov 3 11:12:22 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * config.sub: Allow -aout* and -elf*.
+
+Wed Nov 3 11:08:33 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * configure.in: Don't build ld on i386-solaris2, same as for
+ sparc-solaris2.
+
+Tue Nov 2 14:21:25 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * Makefile.in (taz): Add texinfo/lgpl.texinfo (for libg++).
+
+Tue Nov 2 13:38:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.in: Configure gdb for alpha.
+
+Mon Nov 1 10:42:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (CXXFLAGS): Add -O.
+
+Wed Oct 27 10:45:06 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * config.guess: added support for DG Aviion
+
+Tue Oct 26 14:37:37 1993 Ken Raeburn (raeburn@rover.cygnus.com)
+
+ * configure.in: Produce warning message for subdirectories not
+ configurable for this host/target combination. Don't try to
+ configure gdb for vms.
+
+Mon Oct 25 11:22:15 1993 Ken Raeburn (raeburn@rover.cygnus.com)
+
+ * Makefile.in (taz): Replace "byacc" with "bison -y" in the
+ appropriate files before making "diststuff".
+ (DISTBISONFILES): New var: list of files to be edited.
+ (DISTSTUFFDIRS): Add binutils.
+
+Fri Oct 22 20:32:15 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * config.sub: also handle mipsel and mips64el (for little endian mips)
+
+Fri Oct 22 07:59:20 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in: Add * to end of all OS names.
+
+Thu Oct 21 11:38:28 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * configure.in: Build newlib for LynxOS native.
+
+Wed Oct 20 09:56:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Add support for delta 88k running SVR3.
+
+ * configure.in: Add comment about HP compiler vs. emacs.
+
+Tue Oct 19 16:02:22 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in: don't build ld on solaris2 (not a viable option
+ due to bugs in getpwnam & getpwuid)
+
+Tue Oct 19 15:13:56 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * configure.in: Accept alpha-dec-osf1*, not just -osf1, since
+ config.guess will produce a full version number.
+
+Tue Oct 19 15:58:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Build linker and binutils for alpha-dec-osf1.
+
+Tue Oct 19 11:41:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Remove -O from CXXFLAGS for consistency with CFLAGS,
+ and gdb/testsuite/Makefile.in.
+
+Sat Oct 9 18:39:07 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in: recognize mips*- instead of mips-
+
+Fri Oct 8 14:15:39 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * config.sub: Accept linux*coff and linux*elf as operating
+ systems.
+
+Thu Oct 7 12:57:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config.sub: Recognize mips64, and mips3 as an alias for it.
+
+Wed Oct 6 13:54:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.in: Remove alpha-dec-osf*, no longer necessary now that
+ gdb knows how to handle OSF/1 shared libraries.
+
+Tue Oct 5 11:55:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in: Recognize hppa*-*-hiux* (currently synonym for hpux).
+ * config.guess: Recognize Hitachi's HIUX.
+ * config.sub: Recognize h3050r* and hppahitachi.
+ Remove redundant cases for hp9k[23]*.
+
+Mon Oct 4 16:15:09 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in: default to '--with-gnu-as' and '--with-gnu-ld'
+ if gas and ld are in the source tree and are in ${configdirs}.
+ If ${use_gnu_as} or ${use_gnu_ld} are 'no', then don't set the
+ the --with options (but still pass them down on the command line,
+ if they were explicitly specified).
+
+Fri Sep 24 19:11:13 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure: substitute SHELL value in Makefile.in with
+ ${CONFIG_SHELL}
+
+Thu Sep 23 18:05:13 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Build gas, ld, and binutils for *-*-sysv4* and
+ *-*-solaris2* targets.
+
+Sun Sep 19 17:01:41 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in: define M4, and pass it down to sub-makes;
+ all-autoconf now depends on all-m4
+
+Sat Sep 18 00:38:23 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in ({AR,RANLIB}_FOR_TARGET): make contingent on
+ presence of {ar,ranlib} instead of a configured directory
+
+Wed Sep 15 08:41:44 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
+
+ * config.guess: Accept 34?? as well as 33?? for NCR.
+
+Mon Sep 13 12:28:43 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in: grab mt-hppa for HPPA targets; use 'gas ' instead
+ of 'gas' in sed commands, since 'gash' is now in the tree as well.
+
+Fri Sep 10 11:23:52 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure: grab values for $(CC) and $(CXX) from the
+ environment, so that someone can do "CC=gcc configure; make" and
+ have it work right (matching the way that autoconf works now)
+
+ * configure.in, Makefile.in: add support for gash, the tcl
+ interface to Galaxy
+
+ * config.guess: add NetBSD variants (hp300, x86)
+
+Thu Sep 9 16:48:52 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * install.sh: Support -d option (in the manner of SunOS 4 install,
+ as it is more deterministic than that of GNU install)
+ (chmodcmd): Set file to mode 755 by default (should also do default
+ chgrp and chown, but I don't feel like dealing with that now)
+
+Tue Sep 7 11:59:39 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * config.sub: Remove h8300hhms alias.
+
+Tue Aug 31 11:00:09 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in: Match *-*-solaris2* not *-sun-solaris2*.
+
+Mon Aug 30 18:29:10 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in (gcc-no-fixedincludes): touch stmp-fixproto as well
+ as stmp-fixinc
+
+Wed Aug 25 16:35:59 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * config.sub: recognize m88110-bug-coff.
+
+Tue Aug 24 10:23:24 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in (all-libio): all dependencies on the toolchain used
+ to build this (gcc, gas, ld, etc)
+
+Fri Aug 20 17:24:24 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Deal with OSF/1 1.3 on alpha.
+
+Thu Aug 19 11:43:04 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * install.sh: add some 'else true' clauses for portability
+
+ * configure.in: don't build libio for h8[35]00-*-* targets
+
+Tue Aug 17 19:02:31 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * Makefile.in: Add support for new libio.
+
+Sun Aug 15 20:48:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * install.sh: If one command fails, don't try the rest. Don't try
+ to remove $dsttmp (via trap) unless we have already created it.
+ If $src doesn't exist, detect it and exit with an error.
+
+ * config.guess: Recognize BSD on hp300.
+
+Wed Aug 11 18:35:13 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * config.guess: Map (9000/[34]??:HP-UX:*:*) to m68k-hp-hpux.
+ Bug report from "Hamish (H.I.) Macdonald" <hamish@bnr.ca>.
+
+Wed Aug 11 15:37:51 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * Makefile.in (all-send-pr): depends on all-prms
+
+Wed Aug 11 16:56:03 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Fix typo (9000/8??:4.3bsd -> 9000/7??:4.3bsd).
+
+Fri Aug 6 14:45:02 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config.guess: From michael@mercury.cs.mun.ca (Michael Rendell):
+ Added test for mips-mips-riscos5.
+
+Thu Aug 5 15:45:08 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.in: use mh-hp300 for 68k HP hosts
+
+Mon Aug 2 11:56:53 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure: add support for CONFIG_SHELL, so that you can use
+ some alternate shell for evaluating configure scripts
+
+Sun Aug 1 11:36:27 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * Makefile.in (make-gdb.tar.gz): Sed bug reporting address
+ in configure script to bug-gdb@prep.ai.mit.edu when building
+ distribution archive.
+ * Makefile.in (COMPRESS): Remove def.
+ * Makefile.in (gdb.tar.gz, make-gdb.tar.gz): Renamed from
+ gdb.tar.Z and make-gdb.tar.Z respectively.
+ * Makefile.in (make-gdb.tar.gz): Now only build gzip'd archive.
+ * Makefile.in (make-gdb.tar.gz): Minor changes to move closer
+ to convergence with 'taz' target in Makefile.in.
+
+Fri Jul 30 12:34:57 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * install.sh (dsttmp): use trap to ensure that tmp files go
+ away on error conditions
+
+Wed Jul 28 11:57:36 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in (BASE_FLAGS_TO_PASS): remove LOADLIBES
+
+Tue Jul 27 12:43:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (install-dirs): Deal with a prefix like /gnu;
+ its parent is '/' not ''.
+
+ * Makefile.in (DEVO_SUPPORT): Add comments about ChangeLog.
+
+Fri Jul 23 09:53:37 1993 Jason Merrill (jason@wahini.cygnus.com)
+
+ * configure: if ${newsrcdir}/configure doesn't exist, don't assume
+ that ${newsrcdir}/configure.in does.
+
+Tue Jul 20 11:28:50 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * test-build.mk: support for CONFIG_SHELL
+
+Mon Jul 19 21:54:46 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * config.sub (netware): Add as a basic system type.
+
+Wed Jul 14 12:03:11 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * Makefile.in (Makefile): depend on configure.in. Also drop the
+ $(srcdir)/ from the dependency on Makefile.in.
+
+Tue Jul 13 20:10:58 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * config.sub: Recognize h8300hhms as h8300h-hitachi-hms.
+ (h8300hhms is temporary until multi-libraries are implemented).
+ * configure.in: Handle h8300h too.
+
+Sun Jul 11 17:35:27 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Recognize dpx/2 as m68k-bull-sysv3.
+
+Thu Jul 8 18:26:12 1993 John Gilmore (gnu@cygnus.com)
+
+ * configure: Remove extraneous output when guessing host type.
+ * config.guess: Remove extraneous output when guessing using C
+ compiler rather than uname, or when guessing fails.
+
+Wed Jul 7 17:58:14 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
+
+ * Makefile.in: remove all.cross and install.cross targets
+
+ * configure: remove CROSS=-DCROSS_COMPILE and ALL=all.cross
+ definitions
+
+Tue Jul 6 10:39:44 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * configure.in (target sh): Build gprof.
+
+Thu Jul 1 16:52:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config.sub: change -solaris to -solaris2
+
+Thu Jul 1 15:46:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in: Use config/mh-riscos for mips-*-sysv*.
+
+Wed Jun 30 09:31:58 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: Correct error message for missing Makefile.in to
+ print correct directory.
+
+Tue Jun 29 13:52:16 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * install.sh: kludge around 386BSD shell bug
+
+Tue Jun 29 13:06:49 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * config.guess: Recognize NeXT.
+ * config.guess: Recognize i486-ncr-sysv4.
+ * Makefile.in (taz): rm $(TOOL)-$$VER before linking.
+
+Tue Jun 29 12:50:57 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (MAKEINFOFLAGS): New variable.
+ (FLAGS_TO_PASS): Pass MAKEINFO as MAKEINFO MAKEINFOFLAGS.
+ * build-all.mk, test-build.mk: Pass down --no-split as
+ MAKEINFOFLAGS when hosted on DOS. Compile DOS hosted without -g.
+
+Thu Jun 24 13:39:11 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in (DEVO_SUPPORT): Add COPYING COPYING.LIB install.sh.
+
+Wed Jun 23 12:59:21 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in (libg++.tar.z): New rule.
+ * Makefile.in (taz): Replace 'configure -rm' by 'make distclean'.
+ * Makefile.in (taz): Only do a single chmod.
+
+Fri Jun 18 12:03:10 1993 david d `zoo' zuhn (zoo at majipoor.cygnus.com)
+
+ * install.sh: don't use dirname anymore (replaced with sed usage)
+
+Thu Jun 17 18:43:42 1993 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in: Change extension for gzip'd files from '.z' to
+ '.gz' per new FSF standard usage.
+
+Thu Jun 17 16:58:50 1993 david d `zoo' zuhn (zoo at majipoor.cygnus.com)
+
+ * configure: put quotes around the final value of program_transform_name
+
+Tue Jun 15 16:48:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: new install.sh support; update install-info rules
+
+Wed Jun 9 12:31:34 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure.in: Build diff for crosses, but not for go32 host.
+
+ * configure.in: Build gprof only for native, and don't build it
+ for mips-*-*, rs6000-*-*, or i[34]86-*-sco*.
+
+Mon Jun 7 13:12:11 1993 david d `zoo' zuhn (zoo at deneb.cygnus.com)
+
+ * configure.in: don't build gas,ld,binutils on for *-*-sysv4
+
+Mon Jun 7 11:40:11 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * configure.in (host_tools): Add prms.
+
+Fri Jun 4 13:30:42 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: install gcc, do installation of $(INSTALL_MODULES)
+ with $(FLAGS_TO_PASS) on the command line
+
+ * config.sub: Recognize lynx and lynxos
+
+Fri Jun 4 10:59:56 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * config.sub: Accept -ecoff*, not just -ecoff.
+
+Thu Jun 3 17:38:54 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (taz): Use .gz suffix instead of .z.
+ (binutils.tar.gz, gas+binutils.tar.gz, gas.tar.gz): Fixed target
+ names.
+
+Thu Jun 3 00:27:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in (vault-install): add an 'else true' (for Ultrix)
+
+Wed Jun 2 18:19:16 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in (install-no-fixedincludes): install gcc last, so
+ that rebuilds that might happen during 'make install' don't get
+ bogus gcc include files
+
+Wed Jun 2 16:14:10 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ Change from Utah for HPPA support:
+ * config.guess: Recognize hppa1.x-hp-bsd.
+
+Wed Jun 2 11:53:33 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * config.guess: Add support for Motorola Delta 68k, up to r3v7.
+ Patch from pot@fly.cnuce.cnr.it (Francesco Potorti`).
+
+Tue Jun 1 17:48:42 1993 Rob Savoye (rob at darkstar.cygnus.com)
+
+ * config.sub: Add support for rom68k and bug boot monitors.
+
+Mon May 31 09:36:37 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * Makefile.in: Make all-opcodes depend on all-bfd.
+
+Thu May 27 08:05:31 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * config.guess: Added special check for i[34]86-univel-sysv4*.
+
+Wed May 26 16:33:40 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * config.guess: For i[34]86-unknown-sysv4 use UNAME_MACHINE for
+ the processor rather than assuming i486.
+
+Wed May 26 09:40:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.guess: Recognize SunOS6 as Solaris3.
+
+Tue May 25 23:03:11 1993 Per Bothner (bothner@cygnus.com)
+
+ * config.guess: Fix typo. Avoid #elif (not in K&R 1).
+ Recognize SunOS 5.* only (and not [6-9].*) as being Solaris2.
+
+Tue May 25 12:44:18 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * build-all.mk (all-cross): New target for Canadian Cross.
+ Added Q2 go32 targets.
+ * test-build.mk: Configure go32 cross sparclite-aout and
+ mips-idt-ecoff -with-gnu-ld. Moved build binary directory from
+ PARTIAL_HOLE_DIRS to BUILD_HOLES_DIRS.
+
+Mon May 24 15:30:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: fix Alpha GDB typo; also, don't build DejaGnu for
+ GO32 hosted toolchains
+
+Mon May 24 14:18:41 1993 Rob Savoye (rob at darkstar.cygnus.com)
+
+ * configure: change so "-exec-prefix" gets passed down rather
+ than "-exec_prefix" so autoconf generated Makefiles get the
+ exec_prefix set right.
+
+Fri May 21 10:42:25 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config.guess: get the Solaris2 minor version number
+
+ * Makefile.in: add standards.texi and make-stds.texi to ETC_SUPPORT
+
+Fri May 21 06:20:52 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * config.guess: Recognize some Sequent platforms.
+
+Thu May 20 14:33:48 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: added the vault-install target
+
+ * configure.in: actually use the Sun3 makefile fragment that's in
+ config, also added the release dir to configdirs
+
+Thu May 20 14:19:18 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (taz): Fix modes on stuff in $(TOOL) dir also.
+
+Tue May 18 20:26:41 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: remove some program from Alpha targetted toolchains
+
+Tue May 18 15:23:19 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * Makefile.in (DISTSTUFFDIRS): Renamed from PROTODIRS. Add ld and
+ gprof.
+ (taz): Run "make diststuff" in those directories instead of "make
+ proto-dir". Look for "VERSION=" only at start of line in subdir
+ Makefile. Use "gzip -9" for compression.
+ (TEXINFO_SUPPORT, DIST_SUPPORT, BINUTILS_SUPPORT_DIRS): New vars.
+ (binutils.tar.z): New target.
+
+Mon May 17 17:01:15 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * Makefile.in (taz): Include gpl.texinfo.
+
+Fri May 14 06:48:38 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * Makefile.in (setup-dirs): Merged into "taz" target.
+ (taz): Only do `proto-dir' stuff if a directory is actually needed
+ for this target.
+
+Wed May 12 13:09:44 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (MUNCH_NM): New variable, defined to be $(NM).
+ (FLAGS_TO_PASS): Pass down MUNCH_NM.
+ (HOST_CC, HOST_PREFIX, HOST_PREFIX_1): New variables.
+ (EXTRA_GCC_FLAGS): Pass down HOST_* variables.
+ (gcc-no-fixedincludes): Correct for current gcc Makefile.
+
+Tue May 11 10:14:25 1993 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (make-gdb.tar.Z): Add configure, config.guess,
+ config.sub, and move-if-change to gdb testsuite distribution
+ archive, so the testsuite can be extracted, configured, and
+ run separately from the gdb distribution. Blow away the Chill
+ tests that require a Chill compiled executable, since GNU Chill
+ is not yet publically available.
+
+Mon May 10 17:22:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * test-build.mk: set environment variables in a single command,
+ instead of a list of assignments and exports
+
+ * config.guess: recognize Alpha/OSF1 systems
+
+Mon May 10 14:55:51 1993 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * configure: Change help message to prefer --options rather than
+ -options.
+
+Mon May 10 05:58:35 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * config.sub: Convergent Tech. "miniframe" uses m68010, sez
+ zippy@ecst.csuchico.edu.
+ * config.guess: Recognize miniframe.
+
+Sun May 9 17:47:57 1993 Rob Savoye (rob at darkstar.cygnus.com)
+
+ * Makefile.in: Use srcroot to find runtest rather than rootme.
+ Pass RUNTESTFLAGS and EXPECT down in BASE_FLAGS_TO_PASS.
+
+Fri May 7 14:55:59 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * test-build.mk: Extensive additions to support building on a
+ machine other than the host.
+
+Wed May 5 08:35:04 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * configure (tooldir): Fix for i386-aix again.
+
+Mon May 3 19:00:27 1993 Per Bothner (bothner@cygnus.com)
+
+ * configure, Makefile.in: Change definition of $(tooldir)
+ to match the FSF.
+
+Fri Apr 30 15:55:21 1993 Fred Fish (fnf@cygnus.com)
+
+ * config.guess: Recognize i[34]86/SVR4.
+
+Fri Apr 30 15:52:46 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * Makefile.in (all-gdb): gdb depends on sim.
+
+Thu Apr 29 23:30:48 1993 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (gdb.tar.Z): Make prototype gdb testsuite directory
+ at the same time we make the prototype gdb directory.
+ * Makefile.in (make-gdb.tar.Z): Make the testsuite distribution
+ files at the same time as the gdb base release distribution.
+
+Thu Apr 29 12:50:37 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (check): Use individual check targets rather than
+ DO_X rule.
+ (check-gcc): Added.
+
+Thu Apr 29 09:50:07 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * config.sub: Use sysv3.2 not sysv32 for canonical OS
+ for System V release 3.2.
+
+Thu Apr 29 10:33:22 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * config.sub: Recognize hppaosf.
+ * configure.in: Do configure ld/binutils/gas for it.
+
+Tue Apr 27 06:25:34 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * configure (tooldir): Alter syntax used to set this, for systems
+ where "\$" isn't handled right, like i386-aix.
+
+Thu Apr 22 08:17:35 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: Pass program-transform-name, not
+ program_transform_name, to recursive configures.
+
+Thu Apr 22 02:58:21 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * Makefile.in (gas+binutils.tar.z): New rule for building snapshots
+ of gas+ld+binutils.
+
+Mon Apr 19 17:41:30 1993 Per Bothner (bothner@cygnus.com)
+
+ * config.guess: Recognize AIX3.2 as distinct from 3.1.
+
+Sat Apr 17 17:19:50 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: rename m88k-motorola-m88kbcs to m88k-motorola-sysv
+
+ * config/mh-delta88: remove extraneous GCC references
+
+Tue Apr 13 16:52:16 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * Makefile.in (PRMS): Set back to all-prms.
+
+Sat Apr 10 12:04:07 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * test-build.mk: Pass -with-gnu-as for known MIPS native and MIPS
+ targets, rather than for MIPS hosts.
+
+Fri Apr 9 13:51:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: add comment for --with-x default values
+
+ * config.guess: handle Motorola Delta88 box for SVR3 and SVR4.
+
+ * Makefile.in: add check-* targets for each of the directories in
+ the tree. Add a definition of RUNTEST that will use the one we
+ just built, if it exists. Pass this down via FLAGS_TO_PASS.
+
+Thu Apr 8 09:21:30 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure.in: Removed obsolete references to bfd_target and
+ target_makefile_frag.
+
+ * build-all.mk: Set assorted targets for Q2.
+ * config.sub: Recognize z8k-sim and h8300-hms.
+ * test-build.mk: Really don't pass host to configure.
+ (HOLES): Added uname.
+
+Wed Apr 7 15:48:19 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: Handle an empty program-prefix, program-suffix or
+ program-transform-name correctly.
+
+Tue Apr 6 13:48:41 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * build-all.mk: -G 8 no longer required for MIPS targets.
+ * test-build.mk: Don't pass host argument to configure; make it
+ guess.
+
+Tue Apr 6 10:36:53 1993 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (gdb.tar.Z): Fix for building gzip'd distribution.
+ * Makefile.in (COMPRESS): New macro, like GZIP.
+
+Fri Apr 2 09:02:31 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * test-build.mk: Use -with-gnu-as for mips-sgi-irix4 as well.
+
+ * build-all.mk: Set GCC to gcc -O -G 8 for MIPS targets, since gcc
+ with gas currently defaults to -G 0.
+
+Thu Apr 1 08:25:42 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (all-flex): flex depends on byacc.
+
+ * build-all.mk: If host not specified, use config.guess. Pass TAG
+ to test-build.mk as RELEASE_TAG.
+ * test-build.mk (configargs): New variable containing arguments to
+ pass to configure. Set to -with-gnu-as on mips-dec-ultrix.
+ (FLAGS_TO_PASS): Pass down RELEASE_TAG.
+
+ * config.guess: Use /bin/uname when checking -X argument on SCO,
+ to avoid invoking GNU uname which doesn't understand -X.
+
+ * test-build.mk: Don't use /usr/unsupported/bin/as on AIX.
+
+ * configure.in: Build gas for mips-*-*.
+
+Wed Mar 31 21:20:58 1993 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in (all.normal): insert missing backslash.
+
+Wed Mar 31 12:31:56 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * build-all.mk, config/mh-irix4: Bump -XNh value to 1500 to match
+ gcc requirements.
+
+ * Makefile.in: Complete overhaul to merge many almost identical
+ targets.
+
+Tue Mar 30 20:17:01 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (setup-dirs-gdb): Renamed from setup-dirs.
+ (gdb.tar.Z): Adjusted.
+
+ * Makefile.in (setup-dirs, taz): New targets; should be general
+ enough to adapt for gdb sometime. Build only .z file.
+ (gas.tar.z): New target.
+
+Tue Mar 30 10:03:09 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * build-all.mk: Use CC=cc -Xs on Solaris.
+
+Mon Mar 29 19:59:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/mh-sun3: cc needs -J to compile cp-parse.c correctly
+
+ * config/mh-solaris: SunPRO C needs -Xs to be able to get a
+ working xmakefile for Emacs.
+
+Thu Mar 25 15:14:30 1993 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in: Incorporate changes suggested by wilson@cygnus.com
+ for handling BISON for FSF releases.
+
+Thu Mar 25 06:19:48 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * configure: Actually implement the change zoo just documented.
+
+Wed Mar 24 13:02:44 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
+
+ * configure: when using config.guess, only set target_alias when
+ it's not already been set (ie, on the command line)
+
+Mon Mar 22 23:07:39 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: add installcheck target, set PRMS to install-prms
+
+Sun Mar 21 16:46:12 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure: add support for package_makefile_fragment, handle the
+ case where a directory has a configure.in file but no Makefile.in
+ more gracefully (with an actual understandable error message, even);
+ add support for --without (and add this to the usage message); also
+ explicitly add a --host=${host_alias} to the command line when
+ config.guess is used
+
+Sun Mar 21 12:11:58 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * configure: Must use both --host and --target in recursive calls.
+
+Thu Mar 18 12:31:35 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: Change deja-gnu to dejagnu.
+
+Mon Mar 15 15:44:35 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure.in (h8300-*-*, h8500-*-*): Don't build libg++.
+
+Fri Mar 12 18:30:14 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: canonicalize all instances to *-*-solaris2*,
+ also strip out a number of tools to not build for go32 host
+
+Wed Mar 10 12:08:27 1993 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * config.guess: add GPL.
+
+ * Makefile.in, config.guess, config.sub, configure: bump
+ copyrights to 93.
+
+Wed Mar 10 07:12:48 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (do-info): Removed obsolete check for existence of
+ localenv file.
+
+ * Makefile.in (MAKEOVERRIDES): Define to be empty.
+
+Wed Mar 10 03:11:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: a couple of 'else true' for decstation,
+ support for TclX
+
+ * configure.in: configure tclX too; don't remove Tk on RS/6000 anymore
+
+Tue Mar 9 16:06:12 1993 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in (setup-dirs): change invocation of make to $(MAKE).
+
+Mon Mar 8 14:52:11 1993 Ken Raeburn (raeburn@cambridge)
+
+ * config.guess: Recognize i386-ibm-aix (PS/2).
+ * configure.in: Use config/mh-aix386 file for it.
+
+Mon Mar 8 11:12:43 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (GCC_FOR_TARGET): Eliminated definition; use
+ CC_FOR_TARGET instead.
+ (BASE_FLAGS_TO_PASS): Pass GCC_FOR_TARGET=$(CC_FOR_TARGET).
+
+Wed Mar 3 16:00:28 1993 Steve Chamberlain (sac@ok.cygnus.com)
+
+ * Makefile.in: Add sim to list of directories sent with gdb
+
+Wed Mar 3 11:42:39 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * configure.in: Put back mips-dec-bsd* case.
+
+Tue Mar 2 21:15:58 1993 Fred Fish (fnf@cygnus.com)
+
+ (Ultrix 2.2 support from Michael Rendell <michael@mercury.cs.mun.ca>)
+ * configure.in (vax-*-ultrix2*): Add Ultrix 2.2 triplet.
+ * config.guess: Change 'VAX*:ULTRIX:*:*' to 'VAX*:ULTRIX*:*:*'.
+ * config/mh-vaxult2: New file.
+
+Tue Mar 2 18:11:03 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: remove no-op mips-dec-bsd* in "case $target"
+
+ * Makefile.in (dir.info): only run gen-info-dir if it exists,
+ (install-info): install dir.info only if it exists,
+ (all-expect, install-expect): pass along X11_FLAGS_TO_PASS
+
+Tue Mar 2 09:01:30 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * configure.in: For vms target, skip bfd, ld, binutils. Do build
+ gas for mips-dec-bsd.
+
+Tue Mar 2 08:35:24 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure (makesrcdir): If ${srcdir} is relative and not ".",
+ and ${subdir} is not ".", set makesrcdir based on ${invsubdir}.
+
+Tue Feb 23 14:18:28 1993 Mike Werner (mtw@poseidon.cygnus.com)
+
+ * configure.in: Added "dejagnu" to hosttools list.
+
+Mon Feb 22 23:28:38 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * config.sub, configure.in, config.guess: Add support
+ for Bosx, an AIX variant from Bull.
+ Patches from F.Pierresteguy@frcl.bull.fr.
+
+Sun Feb 21 11:15:22 1993 Mike Werner (mtw@poseidon.cygnus.com)
+
+ * devo/dejagnu: Initial creation of devo/dejagnu.
+ Migrated dejagnu testcases and support files for testing software
+ tools to reside as subdirectories, currently called "testsuite",
+ within the directory of the software tool. Migrated all programs,
+ support libraries, etc. beloging to dejagnu proper from
+ devo/deja-gnu to devo/dejagnu. These files were moved "as is"
+ with no modifications. The changes to these files which will
+ allow them to configure, build, and execute properly will be made
+ in a future update.
+
+Fri Feb 19 20:19:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * Makefile.in: Change send_pr to send-pr.
+ * configure.in: Likewise.
+ * send_pr: Renamed directory to send-pr.
+
+Fri Feb 19 19:00:13 1993 Per Bothner (bothner@cygnus.com)
+
+ * Makefile.in: Add some extra semi-colons (needed if SHELL=bash).
+
+Fri Feb 19 00:59:33 1993 John Gilmore (gnu@cygnus.com)
+
+ * README: Update for gdb-4.8 release.
+ * Makefile.in (gdb.tar.Z): Add texinfo/tex3patch. Build
+ gdb-xxx.tar.z (gzip'd) file also.
+
+Thu Feb 18 09:16:17 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: make all-diff depend on all-libiberty
+
+Tue Feb 16 16:06:31 1993 K. Richard Pixley (rich@cygnus.com)
+
+ * config.guess: add vax-ultrix in the spirit of mips-ultrix.
+
+Tue Feb 16 05:57:15 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in, Makefile.in: add hello, tar, gzip, recode, indent
+
+Tue Feb 16 00:58:20 1993 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (DEVO_SUPPORT): Remove etc directory
+ (ETC_SUPPORT): Only add the files GDB wants from etc/.
+ (gdb.tar.Z): Use ETC_SUPPORT. Use byacc when building the file.
+
+Thu Feb 11 20:14:28 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: makeinfo binary is in a new location
+
+Tue Feb 9 12:42:27 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * config.sub: Accept -ecoff as an OS.
+
+ * Makefile.in: Various changes to eliminate a level of make
+ recursion and reduce the required command line length.
+ (BASE_FLAGS_TO_PASS): New variable holding flags passed to all
+ sub-makes.
+ (EXTRA_HOST_FLAGS, EXTRA_TARGET_FLAGS, EXTRA_GCC_FLAGS): New
+ variables holding settings for specific sub-makes.
+ (FLAGS_TO_PASS, TARGET_FLAGS_TO_PASS, GCC_FLAGS_TO_PASS): Rewrote
+ in terms of BASE_FLAGS_TO_PASS.
+ (TARGET_LIBS): New variable listing directories which use
+ TARGET_FLAGS_TO_PASS.
+ (subdir_do): Eliminated.
+ (do-*): New set of targets to replace subdir_do.
+ (various): All targets which used subdir_do now depend on do-*.
+ (local-clean): Renamed from do_clean.
+ (local-distclean): New target, dependency of distclean and
+ realclean.
+ (install-info): Don't create directories. Depend on dir.info
+ rather than calling make recursively.
+ (install-dir.info): Eliminated.
+ (install-info-dirs): Create all info directories here.
+ (dir.info): Depend upon do-install-info.
+
+ * test-build.mk (HOLES): Added false.
+
+Sat Feb 6 14:05:09 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * config.guess: Recognize BSDI and BSDJ (Jolitz 386bsd).
+
+Thu Feb 4 20:49:18 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in (info): remove dependency on all-texinfo. The
+ problem was really in texinfo/C, not at this level.
+
+Thu Feb 4 13:38:41 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (info): Added dependency on all-texinfo (PR 2112).
+
+Thu Feb 4 01:50:53 1993 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (make-gdb.tar.Z): Change BISON to 'bison -y' for
+ GDB releases.
+
+Wed Feb 3 17:22:16 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure: Include srcdir in message about target of link not
+ being found. Don't convert `-' to `_' in `with' options being
+ passed to subdirs.
+
+Tue Feb 2 18:57:59 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: add uudecode to host_tools
+
+ * Makefile.in: added {all,install}-uudecode targets, added them to
+ the appropriate lists
+
+Tue Feb 2 11:45:53 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (all-gcc): Added dependency on all-gas.
+
+ * configure.in (mips-*-*): Build ld and binutils.
+
+Mon Feb 1 12:35:41 1993 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * configure: check return code from mkdir, print error message and
+ exit on failure.
+
+Sat Jan 30 16:40:28 1993 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (make-gdb.tar.Z): New location for texinfo.tex.
+
+Thu Jan 28 15:09:59 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * test-build.mk (HOLES): Added tar, cpio and uudecode.
+
+Wed Jan 27 16:50:32 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * config.sub (h8500): Recognize this as a cpu type.
+
+Sat Jan 23 20:32:01 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure: source directory missing is no longer a warning
+
+ * configure.in: recognize irix[34]* instead of irix[34]
+
+ * Makefile.in: define and pass down X11_LIB
+
+ * config/mh-sco: define X11_LIB to the mess that SCO ODT requires
+
+Sat Jan 23 13:49:40 1993 Per Bothner (bothner@cygnus.com)
+
+ * guess-systype: Renamed to ...
+ * config.guess: ... by popular request.
+ * configure.in, Makefile.in: Update accordingly.
+
+Thu Jan 21 12:20:55 1993 Per Bothner (bothner@cygnus.com)
+
+ * guess-systype: Patches from John Eaton <jwe@che.utexas.edu>:
+ + Add Convex, Cray/Unicos, and Encore/Multimax support.
+ + Execute ./dummy instead of assuming . is in PATH.
+
+Tue Jan 19 17:18:06 1993 Per Bothner (bothner@cygnus.com)
+
+ * guess-systype: New shell script. Attempts to guess the
+ canonical host name of the executing host.
+ Only a few hosts are supported so far.
+ * configure: Call guess-systype if no host is specified.
+
+Tue Jan 19 08:26:07 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (gcc-no-fixedincludes): Made to work with current
+ gcc Makefile.
+
+
+Fri Jan 15 10:27:02 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (GCC_FLAGS_TO_PASS): New variable.
+ (all-gcc, install-gcc, subdir_do): Use it.
+
+Wed Jan 13 17:06:45 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * Makefile.in: Rename uninstalled gcc driver from gcc to xgcc.
+
+Wed Jan 6 20:29:16 1993 Mike Werner (mtw@rtl.cygnus.com)
+
+ * Makefile.in: Removed explicit setting of SUBDIRS. SUBDIRS is now
+ set exclusively by configure, using configure.in .
+
+Wed Jan 6 13:44:11 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * test-build.mk: set $PATH for all builds
+
+ * Makefile.in: pass TARGET_FLAGS_TO_PASS for xiberty and libm
+
+Wed Jan 6 11:02:10 1993 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (GCC_FOR_TARGET): Supply a default that matches
+ the one used in gcc/Makefile.in, so that a null expansion doesn't
+ override the one needed to build gcc with a native cc.
+
+
+Tue Jan 5 07:55:12 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure: Accept -with arguments.
+
+Sun Jan 3 15:15:09 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * Makefile.in: added h8300sim
+
+Tue Dec 29 15:06:00 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * config/mh-sco: Don't override BISON definition.
+
+ * build-all.mk: If canonhost is i386-unknown-sco3.2v4, change it
+ to i386-sco3.2v4. Set TARGETS and CFLAGS for i386-sco3.2v4.
+ (all-cygnus, native, build-cygnus): Make
+ $(canonhost)-stamp-3stage-done, not $(host)....
+ * test-build.mk (stamp-3stage-compared): Use tail +10c for
+ i386-sco3.2v4. Added else true to if command.
+
+Mon Dec 28 12:08:56 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * config.sub: (from FSF) Sequent uses a BSD-like OS.
+
+Mon Dec 28 08:32:06 1992 Minh Tran-Le (mtranle@paris.intellicorp.com)
+
+ * configure.in (i[34]86-*-isc*): added; uses mh-sysv.
+
+Thu Dec 24 17:26:24 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: don't remove binutils from Solaris builds
+
+Thu Dec 24 14:08:38 1992 david d`zoo' zuhn (zoo@cygnus.com)
+
+ * Makefile.in: get rid of earlier definitions for *clean,
+ also handle the recursive info rule better
+
+Thu Dec 24 12:40:21 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in (mostlyclean, distclean, realclean): Fix to
+ do more-or-less the right thing.
+
+Wed Dec 16 10:25:31 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: Add lines defining CC and CXX, and use CXX rather
+ than gcc in definitions of CXX_FOR_BUILD and CXX_FOR_TARGET.
+
+Tue Dec 15 00:34:32 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: change all $(host_cpu)-$(host_vendor)-$(host_os) to
+ $(host_canonical).
+
+ * configure.in: split the configdirs list into 4 categories (native
+ v. cross, library v. tool) and handle the cross-only and native-
+ only in more reasonable (and correct!) way.
+
+Mon Dec 14 17:04:22 1992 Stu Grossman (grossman at cygnus.com)
+
+ * configure.in (hppa*-*-*): Don't remove bfd and gdb from
+ configdirs anymore.
+
+Sun Dec 13 00:37:26 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: extensive cleanup:: removed all of the explicit
+ clean-* targets, collapsed many wrappers around subdir_do into
+ one, added additional targets to satisfy standards.texi, deleted
+ some old targets, some changes for consistency
+
+Fri Dec 11 20:18:02 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: handle some programs as cross-only, and others as
+ native only
+
+ * test-build.mk: handle partial holes in a more generic manner
+
+ * Makefile.in: m4 depends on libiberty
+
+Mon Dec 7 06:43:27 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/mh-sco: don't default $(CC) to gcc
+
+Thu Dec 3 21:52:11 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: add m4, textutils, fileutils, sed, shellutils,
+ time, wdiff, and find to configdirs
+
+ * Makefile.in: all, clean, and install rules for the new programs
+ added to configure.in
+
+Mon Nov 30 14:54:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: use mh-sun for all *-sun-* hosts
+
+ * config/mh-solaris: rework standard X location to use
+ $OPENWINHOME, if defined.
+
+ * config/mh-sun: handle X11 include locations
+
+ * config/mh-decstation: define NeedFunctionPrototypes to 0, to
+ work around dain-bramaged DECwindows include files
+
+Fri Nov 27 18:35:54 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: define flags for X11 include files and library file
+ locations, pass them down to the programs that need this info
+
+ * build-all.mk: added a 'native' target, to 3stage the native toolchain
+
+ * config/{mh-hpux,mh-solaris}: define the "standard" locations for
+ the vendor supplied X11 headers and libraries
+
+Sun Nov 22 18:59:13 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: start building libg++ for HP-UX targets
+
+Wed Nov 18 19:33:11 1992 John Gilmore (gnu@cygnus.com)
+
+ * README: Update references to files moved into etc/.
+
+Sun Nov 15 09:36:08 1992 Fred Fish (fnf@cygnus.com)
+
+ * config.sub (i386sol2, i486sol2): i[34]86-unknown-solaris2.
+ * configure.in (i[34]86-*-solaris2*): Use config/mh-sysv4.
+
+Thu Nov 12 08:50:42 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: accept dash as well as underscore in long option
+ names for FSF compatibility.
+
+Wed Nov 11 08:04:37 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * config.sub: added -sco3.2v4 support from FSF.
+
+Sun Nov 8 21:14:30 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: expand the section that adds or removes
+ directories from the list of programs to build, to handle native
+ vs. cross in addition to host v. native
+
+Sat Nov 7 18:52:27 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in: Replace C++ in macro names with CXX.
+ This is less likely to break ...
+
+Sat Nov 7 15:16:58 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * test-build.mk: add -w to GNU_MAKE
+
+Fri Nov 6 23:10:37 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config.sub: remove 'sparc'-->'sparc-sun' default transformation,
+ add 'sparc' to list of recognized cpus. This needed to make
+ 'sparc-aout' expand to 'sparc-unknown-aout' instead of 'sparc-sun-aout'.
+ Delete some redundant ose68 variants. Recognize -wrs as an os,
+ then changes that into $CPU-wrs-vxworks.
+
+ * configure.in: remove most references to gdbtest, regularize
+ target based program removal
+
+ * test-build.mk: import from p3 tree (many fixes and changes)
+
+Fri Nov 6 20:59:00 1992 david d `zoo' zuhn (zoo@cygnus.com)
+
+ * Makefile.in: added rules to handle tcl, tk, and expect
+
+ * configure.in: handle those directories if they exist
+
+Thu Nov 5 14:35:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config.sub: removed bogus hppabsd and hppahpux names, since
+ "hppa" is not a valid cpu (hppa1.1 or hppa1.0 are, though)
+
+Thu Oct 29 00:12:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: all-gcc now depends on all-binutils. all-libg++
+ depends upon all-xiberty
+
+ * Makefile.in: changes from p3, including:
+
+ Thu Oct 8 15:00:17 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (XTRAFLAGS): include newlib directories if
+ newlib/Makefile exists, rather than if host != target.
+
+ Fri Sep 25 13:41:52 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: added -nostdinc to XTRAFLAGS if we are using gcc
+ from the same source tree and not building a cross-compiler. This
+ matters for the libg++ configuration if reconfiguring a tree that
+ has already been installed.
+
+ Thu Sep 10 10:35:51 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: added -I for newlib/targ-include to XTRAFLAGS, to
+ pick up the machine and system specific header files.
+
+ * Makefile.in: added AS_FOR_TARGET, passed down in
+ TARGET_FLAGS_TO_PASS. Added CC_FOR_BUILD, which is intended to be
+ the C compiler to use to create programs which are run in the
+ build environment, set it to default to $(CC), and passed it down
+ in FLAGS_TO_PASS and TARGET_FLAGS_TO_PASS.
+
+ Mon Sep 7 22:34:42 1992 Ian Lance Taylor (ian@cirdan.cygnus.com)
+
+ * Makefile.in: add $(host) = $(target) tests back to *_FOR_TARGET.
+ We need them for unusual native builds, like systems without
+ ranlib.
+
+ * configure: also define $(host_canonical) and
+ $(target_canonical), which are the full, canonical names for the
+ given host and target
+
+Sun Nov 1 16:38:17 1992 Per Bothner (bothner@cygnus.com)
+
+ * Makefile.in: Added separate definitions for C++.
+
+Fri Oct 30 11:37:52 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in (configdirs): Add deja-gnu.
+
+Fri Oct 23 00:39:18 1992 John Gilmore (gnu@cygnus.com)
+
+ * README: Update for configure.texi and gdb-4.7 release.
+
+Wed Oct 21 21:54:27 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in: Move "all" target to top of file.
+ Previously, first target was ".PHONY" which caused BSD4.4 make
+ to build .PHONY when make was run without arguments.
+
+Mon Oct 19 01:17:54 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in: Add COPYING.LIB to GDB releases, now that there's
+ Library-copylefted code in libiberty.
+
+Tue Oct 13 01:22:32 1992 John Gilmore (gnu@cygnus.com)
+
+ * config.sub: Replace m68kmote with plain old m68k.
+
+Fri Oct 9 03:14:24 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in: Remove space from blank line, avoid Make complaints.
+
+Thu Oct 8 18:41:45 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * config.sub: Complain if no argument is given. Added support for
+ 386bsd as OS and target alias.
+
+Thu Oct 8 15:07:22 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (XTRAFLAGS): include newlib directories if
+ newlib/Makefile exists, rather than if host != target.
+
+Mon Oct 5 03:00:09 1992 Mark Eichin (eichin at tweedledumber.cygnus.com)
+
+ * config.sub: recognize sparclite-wrs-vxworks.
+
+ * Makefile.in (install-xiberty): added *-xiberty make rules (from
+ p3.) Added clean-xiberty to clean.
+
+Thu Oct 1 17:59:19 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: use *-*-* instead of nested cases for host and target
+
+Tue Sep 29 14:11:18 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: added -nostdinc to XTRAFLAGS if we are using gcc
+ from the same source tree and not building a cross-compiler. This
+ matters for the libg++ configuration if reconfiguring a tree that
+ has already been installed.
+
+Sep 20 08:53:10 1992 Fred Fish (fnf@cygnus.com)
+
+ * config.sub (i486v/i486v4): Merge in from FSF version.
+
+Fri Sep 18 00:32:00 1992 Mark Eichin (eichin@cygnus.com)
+
+ * configure: only set PWD if it is already set.
+
+Thu Sep 17 23:05:53 1992 Mark Eichin (eichin@cygnus.com)
+
+ * configure: just set PWD=`pwd` at the top, since Ultrix sh
+ doesn't have unset and all success paths (and most error paths)
+ out set it anyway. (Note: should change all uses of ${PWD=`pwd`}
+ to just ${PWD} to avoid confusion.)
+
+Tue Sep 15 16:00:54 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: always set $(tooldir) to $(libdir)/$(target_alias),
+ even for a native compilation.
+
+Tue Sep 15 02:22:56 1992 John Gilmore (gnu@cygnus.com)
+
+ Changes to make the gdb.tar.Z rule work better.
+
+ * Makefile.in (GDB_SUPPORT_DIRS): Add opcodes.
+ (DEVO_SUPPORT): Add configure.texi.
+ (bfd-ilrt.tar.Z): Remove ancient rule.
+
+Thu Sep 10 10:43:19 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: added -I for newlib/targ-include to XTRAFLAGS, to
+ pick up the machine and system specific header files.
+
+ * configure.in, config.sub: added new target m68010-adobe-scout,
+ with alias of adobe68k. Changed configure.in to check for
+ -scout before -sco* to avoid a false match.
+
+ * Makefile.in: added AS_FOR_TARGET, passed down in
+ TARGET_FLAGS_TO_PASS. Added CC_FOR_BUILD, which is intended to be
+ the C compiler to use to create programs which are run in the
+ build environment, set it to default to $(CC), and passed it down
+ in FLAGS_TO_PASS and TARGET_FLAGS_TO_PASS.
+
+Wed Sep 9 12:21:42 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: added TARGET_FLAGS_TO_PASS, CC_FOR_TARGET,
+ AR_FOR_TARGET, RANLIB_FOR_TARGET, NM_FOR_TARGET. Pass
+ TARGET_FLAGS_TO_PASS, which defines CC, AR, RANLIB and NM as the
+ FOR_TARGET variants, to newlib and libg++.
+
+Tue Sep 8 17:28:30 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (all-gas, all-gdb): Require all-opcodes to be built
+ first.
+
+Wed Sep 2 02:50:05 1992 John Gilmore (gnu@cygnus.com)
+
+ * config.sub: Accept `elf' as an environment.
+
+Tue Sep 1 15:48:30 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * Makefile.in (all-opcodes): cd into the right directory
+
+Sun Aug 30 21:12:11 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure: added -program_transform_name option, used as
+ argument to sed when installing programs.
+ configure.texi: added documentation for -program_prefix,
+ -program_suffix and -program_transform_name.
+
+Thu Aug 27 21:59:44 1992 John Gilmore (gnu@cygnus.com)
+
+ * config.sub: Accept i486 where i386 ok.
+
+Thu Aug 27 13:04:42 1992 Brendan Kehoe (brendan@rtl.cygnus.com)
+
+ * config.sub: accept we32k
+
+Mon Aug 24 14:05:14 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * config.sub, configure.in: accept OSE68000 and OSE68k.
+
+ * Makefile.in: don't create all directories for ``make install'';
+ let the subdirectories create the ones they need.
+
+Tue Aug 11 23:13:17 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * COPYING: new file, GPL v2
+
+Tue Aug 4 01:12:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: use the new gen-info-dir, which needs a template
+ argument (which also lives in texinfo)
+
+ * configure.texi, standards.texi: fix INFO-DIR-ENTRY
+
+Mon Aug 3 15:41:28 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/mh-solaris: removed the -xs from CFLAGS (let the people
+ with Sun's C compiler deal with it themselved)
+
+Mon Aug 3 00:34:17 1992 Fred Fish (fnf@cygnus.com)
+
+ * config.sub (ncr3000): Change i386 to i486.
+
+Thu Jul 23 00:12:17 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: add install-rcs, install-grep to
+ install-no-fixedincludes, removed install-bison and install-libgcc
+
+Tue Jul 21 01:01:50 1992 david d `zoo' zuhn (zoo@cygnus.com)
+
+ * configure.in: grab the HPUX makefile fragment if on HPUX
+
+Mon Jul 20 11:02:09 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * Makefile.in: eradicate bison spoor (ditto libgcc).
+ configure.in: recognise m68{k,000}-ericsson-OSE.
+ es1800 is alias for m68k-ericsson-OSE
+
+Sun Jul 19 17:49:02 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: rearrange the parts that remove programs from
+ configdirs, based now on HOST==TARGET or by canonical triple.
+
+Fri Jul 17 22:52:49 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * test-build.mk: recurse explicitly with -f test-build.mk when
+ appropriate. predicate stage3 and comparison on the existence
+ of gcc. That is, if gcc isn't around, we aren't three-staging.
+ On very clean, also remove ...stamp-co. Build in-place before
+ doing other builds.
+
+Thu Jul 16 18:33:09 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * Makefile.in, configure.in: add tgas
+
+Thu Jul 16 16:05:28 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: a number of changes merged in from progressive.
+
+ * configure.in: add libm.
+
+ * .cvsignore: ignore some stuff that comes from test-build.mk.
+
+Wed Jul 8 00:01:30 1992 Stu Grossman (grossman at cygnus.com)
+
+ * config/mh-solaris: Use -xs when compiling so that Sun-C puts
+ a symbol-table into the executable.
+
+Tue Jul 7 00:24:52 1992 Fred Fish (fnf@cygnus.com)
+
+ * config.sub: Add es1800 (m68k-ericsson-es1800).
+
+Tue Jun 30 20:24:41 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * configure: Add program_suffix (parallel to program_prefix)
+ * Makefile.in: adjust directory-creating script for losing decstation
+
+Mon Jun 22 23:43:48 1992 Per Bothner (bothner@cygnus.com)
+
+ * configure: Minor $subdir-related fixes.
+
+Mon Jun 22 18:30:26 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * configure: fix various problems with propogating
+ makefile_target_frag in subdirs.
+ * configure.in: config libgcc if its there
+
+Fri Jun 19 15:19:40 1992 Stu Grossman (grossman at cygnus.com)
+
+ * config.sub: HPPA merge.
+
+Mon Jun 15 12:31:52 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install,
+ it is broken on ncr 3000's.
+
+Sun Jun 14 10:29:19 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Replace all-bison with all-byacc in all
+ dependency lines for other tools (which now use byacc).
+
+Fri Jun 12 22:21:57 1992 John Gilmore (gnu at cygnus.com)
+
+ * config.sub: Add sun4sol2 => sparc-sun-solaris2.
+
+Tue Jun 9 17:18:11 1992 Fred Fish (fnf at cygnus.com)
+
+ * config/{mh-ncr3000, mh-sysv4}: Add INSTALL.
+
+Thu Jun 4 12:07:32 1992 Mark Eichin (eichin@cygnus.com)
+
+ * Makefile.in: make gprof rules similar to byacc rules (instead of
+ vestigal $(unsubdir) that didn't work...)
+
+Thu Jun 4 00:37:05 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * config.sub: Add support for Linux.
+ * Makefile.in: Use $(FLAGS_TO_PASS) more consistently
+ (at least for libg++).
+
+Tue Jun 02 20:03:00 1992 david d `zoo' zuhn (zoo@cygnus.com)
+
+ * configure.texi: fix doc for the -nfp option to configure
+
+Tue Jun 2 17:20:52 1992 Michael Tiemann (tiemann@cygnus.com)
+
+ * Makefile.in (all-binutils): ar needs flex, so depend on all-flex.
+
+Sun May 31 15:04:08 1992 Mark Eichin (eichin at cygnus.com)
+
+ * config.sub: changed [^-]+ to [^-][^-]* so that it works under
+ Sun sed. (BSD 4.3 sed doesn't handle [^-]+ either.)
+ * configure.in: added solaris* host_makefile_frag hook.
+
+Sun May 31 01:10:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config.sub: changed recognition of m68000 so that various
+ m68k types can be specified via m680[01234]0
+
+Sat May 30 21:01:06 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config.sub (basic_machine): fix sed so that '-foo' isn't
+ completely substituted out while .+'-foo' loses the '-foo'
+
+Wed May 27 23:18:52 1992 Michael Tiemann (tiemann@rtl.cygnus.com)
+
+ * config.sub ($os): Add -aout.
+
+Fri May 22 14:00:02 1992 Per Bothner (bothner@cygnus.com)
+
+ * configure: If host_makefile_frag is absolute, don't
+ prefix ${invsubdir} (relevant to libg++ auto-configure).
+
+Thu May 21 18:00:09 1992 Michael Tiemann (tiemann@rtl.cygnus.com)
+
+ * Makefile.in (tooldir): Define it.
+ (all-ld): Depend on all-flex.
+
+Sun May 10 21:45:59 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in (check): Fix libg++ special case.
+
+Fri May 8 08:31:41 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure: do not bury `pwd` into config.status, thus do fewer
+ pwd's.
+
+ * configure: print the "Building in" message only when building in
+ other than "." AND verbose.
+
+ * configure: remove -s, rework -v to better accomodate guested
+ configures.
+
+ * standards.texi: updated to 3 may, fixed librid <-> libdir typo.
+
+Fri May 1 18:00:50 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: macroize flags passed on recursion. remove
+ fileutils.
+
+Thu Apr 30 08:56:20 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure: get makesrcdir right for subdirs deeper than 1.
+
+ * Makefile.in: pass INSTALL, INSTALL_DATA, INSTALL_PROGRAM on
+ install.
+
+Fri Apr 24 15:51:51 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: don't print subdir_do or recursion lines.
+
+Fri Apr 24 15:22:04 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * standards.texi: added menu item.
+
+ * Makefile.in: build and install standards.info.
+
+ * standards.texi: new file.
+
+Wed Apr 22 18:06:55 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * configure: test for and move config.status pieces from
+ ${subdir}/.
+
+Wed Apr 22 14:38:34 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/mh-delta88, config/mh-ncr3000: Replace MINUS_G with
+ CFLAGS per new configuration strategy.
+ * configure: Test for existance of files before trying to mv
+ them, to avoid numerous non-existance messages.
+
+Tue Apr 21 12:31:33 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure: correct final line of config.status.
+
+ * configure: patch from eggert. Avoids a protection problem if
+ the original Makefile.in is read only.
+
+ * configure: use move-if-change from gcc to create config.status.
+ Some makefiles depend on config.status to tell if a directory
+ has been reconfigured for a different host. This change
+ prevents those directories from remaking everything in the case
+ where the reconfig was only intended to rebuild a Makefile.
+
+ * configure: test for config.sub with "config.sub sun4" rather
+ than "config.sub ${host_alias}". Otherwise we can't tell a bad
+ host alias from a missing config.sub.
+
+Mon Apr 20 18:16:36 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: explicitly pass CFLAGS on recursion. no longer pass
+ MINUS_G (this can be done with CFLAGS). Default CFLAGS to -g.
+
+Fri Apr 17 18:27:51 1992 Per Bothner (bothner@cygnus.com)
+
+ * configure: mkdir ${subdir} as needed.
+
+Wed Apr 15 17:37:22 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in,configure.in: added autoconf.
+
+Wed Apr 15 17:27:34 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: no longer pass against on recursion.
+
+ * Makefile.in: added .NOEXPORT: so that stray makefile_frag
+ definitions are not inherited.
+
+ * configure: correct makesrcdir when subdir is .
+
+Tue Apr 14 11:56:09 1992 Per Bothner (bothner@cygnus.com)
+
+ * configure: Add support for 'subdirs' variable, which is
+ like 'configdirs', except that configure doesn't re-invoke
+ itself for subdirs, it just creates a Makefile for each subdir.
+ * configure.texi: Document subdirs.
+
+Mon Apr 13 18:50:16 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: added flex to configdirs
+
+Mon Apr 13 18:43:55 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: remove clean-stamps from clean.
+
+Sat Apr 11 03:52:03 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Add gdbtest to configdirs.
+
+Fri Apr 10 23:11:49 1992 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (MINUS_G): Add macro, default to -g, pass on
+ to recursive makes.
+ * configure.in: Recognize new ncr3000 config.
+
+Wed Apr 8 23:08:12 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in, configure.in: removed references to gdbm.
+
+Tue Apr 7 16:48:20 1992 Per Bothner (bothner@cygnus.com)
+
+ * config.sub: Don't canonicalize os value
+ newsos* to bsd (readline needs to check for newsos).
+ (This fix was earlier made Jan 31, but got re-broken.)
+
+Mon Apr 6 14:34:08 1992 Stu Grossman (grossman at cygnus.com)
+
+ * configure.in: sco is an os, not a vendor!
+
+ * configure: Quote $( better. Keep various shells happy.
+
+Tue Mar 31 16:32:57 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: eliminate stamp-files.
+
+Mon Mar 30 22:20:23 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: add send_pr. remove "force" from .stmp-gprof rule.
+ Supress echoing of all the "if [ -d ... $(MAKE)" lines.
+
+Wed Mar 25 15:20:04 1992 Stu Grossman (grossman@cygnus.com)
+
+ * config.sub: fix iris/iris3.
+
+Wed Mar 25 10:34:19 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure: re-add -rm.
+
+Tue Mar 24 23:50:16 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Maskefile.in: add .stmp-rcs to all.
+
+ * configure.in: remove gas from rs6000 build, use aix host fragment.
+
+Mon Mar 23 19:43:35 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure: pass down site_option during recursion.
+
+Thu Mar 19 16:49:36 1992 Stu Grossman (grossman at cygnus.com)
+
+ * Makefile.in (all.cross): Add .stmp-bfd .stmp-readline.
+
+Wed Mar 18 15:29:33 1992 Mike Stump (mrs@cygnus.com)
+
+ * configure: Change exec_prefix so that it really defaults to prefix.
+
+Sat Mar 14 17:20:38 1992 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in, configure.in: Add support for mmalloc library.
+
+Fri Mar 13 18:44:18 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: add stmp dependencies for a few more things.
+
+Thu Mar 12 04:56:24 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure: adjusted error message on objdir/srcdir configure
+ collision, per john's suggestion.
+
+ * Makefile.in: add libiberty stmp to all and all.cross.
+
+Wed Mar 11 02:07:52 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: remove force dependencies, add grep to all.
+
+Tue Mar 10 21:49:18 1992 K. Richard Pixley (rich@mars.cygnus.com)
+
+ * Makefile.in: drop flex. make stamp files work.
+
+ * configure: added test for conflicting configuration in srcdir,
+ remove trailing slashes from srcdir. Otherwise emacs gdb mode
+ gets cranky. use relative paths for configure and srcdir
+ whenever possible. Send some error messages to stderr that were
+ going to stdout.
+
+Tue Mar 10 18:01:55 1992 Per Bothner (bothner@cygnus.com)
+
+ * Makefile.in: Fix libg++ rule to check for gcc directory
+ before using gcc/gcc. Also pass XTRAFLAGS.
+
+Thu Mar 5 21:45:07 1992 K. Richard Pixley (rich@sendai)
+
+ * Makefile.in: added stmp-files so that directories aren't polled
+ when they are already built.
+
+ * configure.texi: fixed a node pointer problem.
+
+Thu Mar 5 12:05:58 1992 Stu Grossman (grossman at cygnus.com)
+
+ * config.sub configure.in config/mh-irix4 gdb/configure.in
+ gdb/mips-tdep.c gdb/mipsread.c gdb/procfs.c gdb/signame.h
+ gdb/tm-irix3.h gdb/tm-mips.h gdb/xm-irix4.h gdb/config/mt-irix3
+ gdb/config/mh-irix4 texinfo/configure.in: Port to SGI Irix-4.x.
+
+Wed Mar 4 02:57:46 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * configure: -recurring becomes -silent. corrected help message
+ for -site= option.
+
+ * Makefile.in: mkdir $(exec_prefix) and $(tooldir).
+
+Tue Mar 3 14:51:21 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * configure: when building Makefile for crosses, replace
+ tooldir and program_prefix. default srcdir from location of
+ config.sub. remove "for host in hosts" and "for target in
+ targets" loops.
+
+Wed Feb 26 19:48:25 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: Do not pass bindir or mandir to cvs.
+
+Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in, configure.in: removed traces of namesubdir,
+ -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
+ copyrights to '92, changed some from Cygnus to FSF.
+
+ * configure.texi: remove most references to multiple hosts,
+ multiple targets, subdirs, etc.
+
+ * configure.man: removed rcsid. reference config.sub not
+ config.subr.
+
+ * Makefile.in: mkdir $(infodir) on install-info.
+
+Wed Feb 19 15:41:13 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.texi: Explain better about .gdbinit and about
+ the environment that configure.in sections run in.
+
+Fri Feb 7 07:55:00 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Ultrix is only a decstation if it's a MIPS.
+
+Fri Jan 31 21:54:51 1992 John Gilmore (gnu at cygnus.com)
+
+ * README: DOC.configure => cfg-paper.texi.
+
+Fri Jan 31 21:48:18 1992 Stu Grossman (grossman at cygnus.com)
+
+ * config.sub (near case $os): Don't convert newsos* to bsd!
+
+Fri Jan 31 02:27:32 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Reinstall change from gdb-4.3 that reduces
+ the number of copies of COPYING that go into the GDB tar file.
+
+Thu Jan 30 16:17:30 1992 Stu Grossman (grossman at cygnus.com)
+
+ * bfd/configure.in, config/mh-sco, gdb/config/mh-i386sco,
+ gdb/config/mt-i386v32, gdb/configure.in, readline/configure.in:
+ Fix SCO configuration stuff.
+
+Tue Jan 28 23:51:07 1992 Per Bothner (bothner at cygnus.com)
+
+ * Makefile.in: For libg++, make sure the -I pointing
+ to the gcc directory goes *after* all the libg++-local -I flags.
+ Also, move just-gcc dependency from just-libg++ to all-libg++.
+
+Tue Jan 28 12:56:24 1992 Stu Grossman (grossman at cygnus.com)
+
+ * configure: Change -x to -f to keep Ultrix /bin/test happy.
+
+Sat Jan 18 17:45:11 1992 Stu Grossman (grossman at cygnus.com)
+
+ * Makefile.in (make-gdb.tar.Z): Remove texinfo targets.
+
+Sat Jan 18 17:03:21 1992 Fred Fish (fnf at cygnus.com)
+
+ * config.sub: Add stratus configuration frags. Also
+ submitted to FSF.
+
+Sat Jan 18 15:35:29 1992 Stu Grossman (grossman at cygnus.com)
+
+ * Makefile.in (DEV_SUPPORT): add configure.man.
+
+ * config.sub(Decode manufacturer-specific): add -none*.
+
+Fri Jan 17 17:58:05 1992 Stu Grossman (grossman at cygnus.com)
+
+ * Makefile.in: remove form feeds to make Sun's make happy.
+ (DEVO_SUPPORT): DOC.configure => cfg-paper.texi.
+
+Sat Jan 4 16:11:44 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in (AR_FLAGS): Make quieter.
+
+Thu Jan 2 22:57:12 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Add libg++.
+ * configure: When verbose, don't output the command line at each
+ level; it will be unremarkably the same as the previous version,
+ which will be the same as what the user typed.
+
+Fri Dec 27 16:26:47 1991 K. Richard Pixley (rich at cygnus.com)
+
+ * configure.in, Makefile.in: fix clean-info, add flex. add
+ fileutils.
+
+ * configure: be less sensitive to spaces in Makefile.in. Do not
+ look for sources in "..". Doing so breaks subdirectories that
+ might have their own configure. If a subdir has it's own
+ configure script, use it.
+
+Thu Dec 26 16:30:26 1991 K. Richard Pixley (rich at cygnus.com)
+
+ * cfg-paper.texi: some changes suggested by rms.
+
+Thu Dec 26 10:13:36 1991 Fred Fish (fnf at cygnus.com)
+
+ * config.sub: Merge in some small additions from the FSF version,
+ taken from the gcc distribution, to bring the Cygnus and FSF
+ versions into closer sync.
+
+Fri Dec 20 11:34:18 1991 Fred Fish (fnf at cygnus.com)
+
+ * configure.in: Changed svr4 references to sysv4.
+
+Thu Dec 19 15:54:29 1991 K. Richard Pixley (rich at cygnus.com)
+
+ * configure: added -V for version number option.
+
+Wed Dec 18 15:39:34 1991 K. Richard Pixley (rich at cygnus.com)
+
+ * DOC.configure, cfg-paper.texi: revised, updated, and texinfo'd.
+ renamed from DOC.configure to cfg-paper.texi.
+
+Mon Dec 16 23:05:19 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * configure, config.subr, config.sub: config.subr is now
+ config.sub again.
+
+Fri Dec 13 01:17:06 1991 K. Richard Pixley (rich at cygnus.com)
+
+ * configure.texi: new file, in progress.
+
+ * Makefile.in: build info file and install the man page for
+ configure.
+
+ * configure.man: new file, first cut.
+
+ * configure: find config.subr again now that configuration "none"
+ has gone. removed all traces of the -ansi option. removed all
+ traces of the -languages option.
+
+ * config.subr: resync from rms.
+
+Wed Dec 11 22:25:20 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * configure, config.sub, config.subr: merge config.sub into
+ config.subr, call the result config.subr, remove config.sub, use
+ config.subr.
+
+ * Makefile.in: revised install for dir.info.
+
+Tue Dec 10 00:04:35 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * configure.in: add decstation host makefile frag.
+
+ * Makefile.in: BISON now bison -y again. also install-gcc on
+ install. clean-gdbm on clean. infodir belongs in datadir.
+ Make directories for info install. Build dir.info here then
+ install it.
+
+Mon Dec 9 16:48:33 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: fix for bad directory tests.
+
+Sat Dec 7 00:17:01 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * configure: \{1,2\} appears to be a sysv'ism. Use a different
+ regexp. -srcdir relative was being handled incorrectly.
+
+ * Makefile.in: unwrapped some for loops so that parallel makes
+ work again and so one can focus one's attention on a particular
+ package.
+
+Fri Dec 6 00:22:08 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * configure: added PWD as a stand in for `pwd` (for speed). use
+ elif wherever possible. make -srcdir work without -objdir.
+ -objdir= commented out.
+
+Thu Dec 5 22:46:52 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * configure: +options become --options. -subdirs commented out.
+ added -host, -datadir. Renamed -destdir to -prefix. Comment in
+ Makefile now at top of generated Makefile. Removed cvs log
+ entries. added -srcdir. create .gdbinit only if there is one
+ in ${srcdir}.
+
+ * Makefile.in: idestdir and ddestdir go away. Added copyrights
+ and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
+ and mandir now keyed off datadir by default.
+
+Fri Nov 22 07:38:11 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Freshly created ChangeLog.
+
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 76
+version-control: never
+End:
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 00000000000..7f1bb8c2b29
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,1821 @@
+#
+# Makefile for directory with subdirs to build.
+# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+# Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+srcdir = .
+
+prefix = /usr/local
+exec_prefix = $(prefix)
+
+bindir=${exec_prefix}/bin
+sbindir=${exec_prefix}/sbin
+libexecdir=${exec_prefix}/libexec
+datadir=${prefix}/share
+sysconfdir=${prefix}/etc
+sharedstatedir=${prefix}/com
+localstatedir=${prefix}/var
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+oldincludedir=/usr/include
+infodir=${prefix}/info
+mandir=${prefix}/man
+gxx_include_dir=${includedir}/g++
+
+tooldir = $(exec_prefix)/$(target)
+
+program_transform_name =
+
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = $(prefix)/info
+includedir = $(prefix)/include
+# Directory in which the compiler finds executables, libraries, etc.
+libsubdir = $(libdir)/gcc-lib/$(target_alias)/$(gcc_version)
+GDB_NLM_DEPS =
+
+SHELL = /bin/sh
+
+# INSTALL_PROGRAM_ARGS is changed by configure.in to use -x for a
+# cygwin host.
+INSTALL_PROGRAM_ARGS =
+
+INSTALL = $(SHELL) $$s/install-sh -c
+INSTALL_PROGRAM = $(INSTALL) $(INSTALL_PROGRAM_ARGS)
+INSTALL_SCRIPT = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m 644
+
+INSTALL_DOSREL = install-dosrel-fake
+
+AS = as
+AR = ar
+AR_FLAGS = rc
+CC = cc
+
+# Special variables passed down in EXTRA_GCC_FLAGS. They are defined
+# here so that they can be overridden by Makefile fragments.
+HOST_CC = $(CC_FOR_BUILD)
+HOST_PREFIX =
+HOST_PREFIX_1 = loser-
+
+# These flag values are normally overridden by the configure script.
+CFLAGS = -g
+CXXFLAGS = -g -O2
+
+LIBCFLAGS = $(CFLAGS)
+CFLAGS_FOR_TARGET = $(CFLAGS)
+LDFLAGS_FOR_TARGET =
+LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
+PICFLAG =
+PICFLAG_FOR_TARGET =
+
+CHILLFLAGS = $(CFLAGS)
+CHILL_LIB = -lchill
+CXX = c++
+
+# Use -O2 to stress test the compiler.
+LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates -fexceptions
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS)
+LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates -fexceptions
+
+RANLIB = ranlib
+
+DLLTOOL = dlltool
+WINDRES = windres
+
+NM = nm
+
+LD = ld
+
+# Not plain GZIP, since gzip looks there for extra command-line options.
+GZIPPROG = gzip
+
+# These values are substituted by configure.
+DEFAULT_YACC = yacc
+DEFAULT_LEX = lex
+DEFAULT_M4 = m4
+
+BISON = `if [ -f $$r/bison/bison ] ; then \
+ echo $$r/bison/bison -L $$s/bison/ ; \
+ else \
+ echo bison ; \
+ fi`
+
+YACC = `if [ -f $$r/bison/bison ] ; then \
+ echo $$r/bison/bison -y -L $$s/bison/ ; \
+ elif [ -f $$r/byacc/byacc ] ; then \
+ echo $$r/byacc/byacc ; \
+ else \
+ echo ${DEFAULT_YACC} ; \
+ fi`
+
+LEX = `if [ -f $$r/flex/flex ] ; \
+ then echo $$r/flex/flex ; \
+ else echo ${DEFAULT_LEX} ; fi`
+
+M4 = `if [ -f $$r/m4/m4 ] ; \
+ then echo $$r/m4/m4 ; \
+ else echo ${DEFAULT_M4} ; fi`
+
+MAKEINFO = `if [ -f $$r/texinfo/makeinfo/Makefile ] ; \
+ then echo $$r/texinfo/makeinfo/makeinfo ; \
+ else echo makeinfo ; fi`
+
+# This just becomes part of the MAKEINFO definition passed down to
+# sub-makes. It lets flags be given on the command line while still
+# using the makeinfo from the object tree.
+MAKEINFOFLAGS =
+
+EXPECT = `if [ -f $$r/expect/expect ] ; \
+ then echo $$r/expect/expect ; \
+ else echo expect ; fi`
+
+RUNTEST = `if [ -f $$s/dejagnu/runtest ] ; \
+ then echo $$s/dejagnu/runtest ; \
+ else echo runtest ; fi`
+
+
+# compilers to use to create programs which must be run in the build
+# environment.
+CC_FOR_BUILD = $(CC)
+CXX_FOR_BUILD = $(CXX)
+
+SUBDIRS = "this is set via configure, don't edit this"
+OTHERS =
+
+# This is set by the configure script to the list of directories which
+# should be built using the target tools.
+
+
+TARGET_CONFIGDIRS = libiberty libgloss $(SPECIAL_LIBS) newlib libio librx libstdc++ libg++ winsup opcodes bsp libstub cygmon
+
+# Target libraries are put under this directory:
+# Changed by configure to $(target_alias) if cross.
+TARGET_SUBDIR = .
+
+# This is set by the configure script to the arguments passed to configure.
+CONFIG_ARGUMENTS =
+
+# This is set by configure to REALLY_SET_LIB_PATH if --enable-shared
+# was used.
+SET_LIB_PATH =
+
+# This is the name of the environment variable used for the path to
+# the libraries. This may be changed by configure.in.
+RPATH_ENVVAR = LD_LIBRARY_PATH
+
+# configure.in sets SET_LIB_PATH to this if --enable-shared was used.
+REALLY_SET_LIB_PATH = \
+ if [ x"$$$(RPATH_ENVVAR)" != x ]; then \
+ $(RPATH_ENVVAR)=$$r/bfd:$$r/opcodes:$$$(RPATH_ENVVAR); \
+ else \
+ $(RPATH_ENVVAR)=$$r/bfd:$$r/opcodes; \
+ fi; \
+ export $(RPATH_ENVVAR);
+
+ALL = all.normal
+INSTALL_TARGET = installdirs \
+ install-gcc \
+ $(INSTALL_MODULES) \
+ $(INSTALL_TARGET_MODULES) \
+ $(INSTALL_X11_MODULES) \
+ $(INSTALL_DOSREL)
+
+INSTALL_TARGET_CROSS = installdirs \
+ install-gcc-cross \
+ $(INSTALL_MODULES) \
+ $(INSTALL_TARGET_MODULES) \
+ $(INSTALL_X11_MODULES) \
+ $(INSTALL_DOSREL)
+
+CC_FOR_TARGET = ` \
+ if [ -f $$r/gcc/xgcc ] ; then \
+ if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
+ case "$(target_canonical)" in \
+ i[3456]86-*-cygwin*) \
+ echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/$(TARGET_SUBDIR)/newlib/ -L$$r/$(TARGET_SUBDIR)/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/winsup/include -idirafter $$s/newlib/libc/include -idirafter $$s/newlib/libc/sys/cygwin -idirafter $$s/newlib/libc/sys/cygwin32 -nostdinc; \
+ ;; \
+ *) \
+ echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \
+ ;; \
+ esac \
+ else \
+ echo $$r/gcc/xgcc -B$$r/gcc/; \
+ fi; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(CC); \
+ else \
+ t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
+ fi; \
+ fi`
+
+# If CC_FOR_TARGET is not overriden on the command line, then this
+# variable is passed down to the gcc Makefile, where it is used to
+# build libgcc2.a. We define it here so that it can itself be
+# overridden on the command line.
+GCC_FOR_TARGET = $$r/gcc/xgcc -B$$r/gcc/
+
+CHILL_FOR_TARGET = ` \
+ if [ -f $$r/gcc/xgcc ] ; then \
+ echo $$r/gcc/xgcc -B$$r/gcc/ -L$$r/gcc/ch/runtime/; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(CC); \
+ else \
+ t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
+ fi; \
+ fi`
+
+CXX_FOR_TARGET = ` \
+ if [ -f $$r/gcc/xgcc ] ; then \
+ if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
+ case "$(target_canonical)" in \
+ i[3456]86-*-cygwin*) \
+ echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/$(TARGET_SUBDIR)/newlib/ -L$$r/$(TARGET_SUBDIR)/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/winsup/include -idirafter $$s/newlib/libc/include -idirafter $$s/newlib/libc/sys/cygwin -idirafter $$s/newlib/libc/sys/cygwin32 -nostdinc; \
+ ;; \
+ *) \
+ echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \
+ ;; \
+ esac \
+ else \
+ echo $$r/gcc/xgcc -B$$r/gcc/; \
+ fi; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(CXX); \
+ else \
+ t='$(program_transform_name)'; echo c++ | sed -e 's/x/x/' $$t; \
+ fi; \
+ fi`
+
+AS_FOR_TARGET = ` \
+ if [ -f $$r/gas/as-new ] ; then \
+ echo $$r/gas/as-new ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(AS); \
+ else \
+ t='$(program_transform_name)'; echo as | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+LD_FOR_TARGET = ` \
+ if [ -f $$r/ld/ld-new ] ; then \
+ echo $$r/ld/ld-new ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(LD); \
+ else \
+ t='$(program_transform_name)'; echo ld | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+DLLTOOL_FOR_TARGET = ` \
+ if [ -f $$r/binutils/dlltool ] ; then \
+ echo $$r/binutils/dlltool ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(DLLTOOL); \
+ else \
+ t='$(program_transform_name)'; echo dlltool | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+WINDRES_FOR_TARGET = ` \
+ if [ -f $$r/binutils/windres ] ; then \
+ echo $$r/binutils/windres ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(WINDRES); \
+ else \
+ t='$(program_transform_name)'; echo windres | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+AR_FOR_TARGET = ` \
+ if [ -f $$r/binutils/ar ] ; then \
+ echo $$r/binutils/ar ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(AR); \
+ else \
+ t='$(program_transform_name)'; echo ar | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+RANLIB_FOR_TARGET = ` \
+ if [ -f $$r/binutils/ranlib ] ; then \
+ echo $$r/binutils/ranlib ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(RANLIB); \
+ else \
+ t='$(program_transform_name)'; echo ranlib | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+NM_FOR_TARGET = ` \
+ if [ -f $$r/binutils/nm-new ] ; then \
+ echo $$r/binutils/nm-new ; \
+ else \
+ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ echo $(NM); \
+ else \
+ t='$(program_transform_name)'; echo nm | sed -e 's/x/x/' $$t ; \
+ fi; \
+ fi`
+
+# The first rule in the file had better be this one. Don't put any above it.
+# This lives here to allow makefile fragments to contain dependencies.
+all: all.normal
+.PHONY: all
+
+# These can be overridden by config/mt-*.
+# The _TARGET_ is because they're specified in mt-foo.
+# The _HOST_ is because they're programs that run on the host.
+EXTRA_TARGET_HOST_ALL_MODULES =
+EXTRA_TARGET_HOST_INSTALL_MODULES =
+EXTRA_TARGET_HOST_CHECK_MODULES =
+
+#### host and target specific makefile fragments come in here.
+###
+
+# Flags to pass down to all sub-makes.
+# Please keep these in alphabetical order.
+BASE_FLAGS_TO_PASS = \
+ "AR_FLAGS=$(AR_FLAGS)" \
+ "AR_FOR_TARGET=$(AR_FOR_TARGET)" \
+ "AS_FOR_TARGET=$(AS_FOR_TARGET)" \
+ "BISON=$(BISON)" \
+ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
+ "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
+ "CFLAGS=$(CFLAGS)" \
+ "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
+ "CHILLFLAGS=$(CHILLFLAGS)" \
+ "CHILL_FOR_TARGET=$(CHILL_FOR_TARGET)" \
+ "CHILL_LIB=$(CHILL_LIB)" \
+ "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
+ "CXXFLAGS=$(CXXFLAGS)" \
+ "CXXFLAGS_FOR_TARGET=$(CXXFLAGS_FOR_TARGET)" \
+ "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
+ "DLLTOOL_FOR_TARGET=$(DLLTOOL_FOR_TARGET)" \
+ "INSTALL=$(INSTALL)" \
+ "INSTALL_DATA=$(INSTALL_DATA)" \
+ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+ "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
+ "LDFLAGS=$(LDFLAGS)" \
+ "LEX=$(LEX)" \
+ "LD_FOR_TARGET=$(LD_FOR_TARGET)" \
+ "LIBCFLAGS=$(LIBCFLAGS)" \
+ "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
+ "LIBCXXFLAGS=$(LIBCXXFLAGS)" \
+ "LIBCXXFLAGS_FOR_TARGET=$(LIBCXXFLAGS_FOR_TARGET)" \
+ "M4=$(M4)" \
+ "MAKE=$(MAKE)" \
+ "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
+ "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
+ "RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
+ "RPATH_ENVVAR=$(RPATH_ENVVAR)" \
+ "SHELL=$(SHELL)" \
+ "EXPECT=$(EXPECT)" \
+ "RUNTEST=$(RUNTEST)" \
+ "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
+ "TARGET_SUBDIR=$(TARGET_SUBDIR)" \
+ "WINDRES_FOR_TARGET=$(WINDRES_FOR_TARGET)" \
+ "YACC=$(YACC)" \
+ "bindir=$(bindir)" \
+ "datadir=$(datadir)" \
+ "exec_prefix=$(exec_prefix)" \
+ "includedir=$(includedir)" \
+ "infodir=$(infodir)" \
+ "libdir=$(libdir)" \
+ "libexecdir=$(libexecdir)" \
+ "lispdir=$(lispdir)" \
+ "localstatedir=$(localstatedir)" \
+ "mandir=$(mandir)" \
+ "oldincludedir=$(oldincludedir)" \
+ "prefix=$(prefix)" \
+ "sbindir=$(sbindir)" \
+ "sharedstatedir=$(sharedstatedir)" \
+ "sysconfdir=$(sysconfdir)" \
+ "tooldir=$(tooldir)" \
+ "gxx_include_dir=$(gxx_include_dir)" \
+ "gcc_version=$(gcc_version)" \
+ "gcc_version_trigger=$(gcc_version_trigger)" \
+ "target_alias=$(target_alias)" \
+ "libsubdir=$(libsubdir)"
+
+# Flags to pass down to most sub-makes, in which we're building with
+# the host environment.
+# If any variables are added here, they must be added to do-*, below.
+EXTRA_HOST_FLAGS = \
+ 'AR=$(AR)' \
+ 'AS=$(AS)' \
+ 'CC=$(CC)' \
+ 'CXX=$(CXX)' \
+ 'DLLTOOL=$(DLLTOOL)' \
+ 'LD=$(LD)' \
+ 'NM=$(NM)' \
+ 'RANLIB=$(RANLIB)' \
+ 'WINDRES=$(WINDRES)'
+
+FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
+
+# Flags that are concerned with the location of the X11 include files
+# and library files
+#
+# NOTE: until the top-level is getting the values via autoconf, it only
+# causes problems to have this top-level Makefile overriding the autoconf-set
+# values in child directories. Only variables that don't conflict with
+# autoconf'ed ones should be passed by X11_FLAGS_TO_PASS for now.
+#
+X11_FLAGS_TO_PASS = \
+ 'X11_EXTRA_CFLAGS=$(X11_EXTRA_CFLAGS)' \
+ 'X11_EXTRA_LIBS=$(X11_EXTRA_LIBS)'
+
+# Flags to pass down to makes which are built with the target environment.
+# The double $ decreases the length of the command line; the variables
+# are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.
+# If any variables are added here, they must be added to do-*, below.
+EXTRA_TARGET_FLAGS = \
+ 'AR=$$(AR_FOR_TARGET)' \
+ 'AS=$$(AS_FOR_TARGET)' \
+ 'CC=$$(CC_FOR_TARGET)' \
+ 'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
+ 'CXX=$$(CXX_FOR_TARGET)' \
+ 'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \
+ 'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
+ 'LD=$$(LD_FOR_TARGET)' \
+ 'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
+ 'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
+ 'NM=$$(NM_FOR_TARGET)' \
+ 'RANLIB=$$(RANLIB_FOR_TARGET)' \
+ 'WINDRES=$$(WINDRES_FOR_TARGET)'
+
+TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
+
+# Flags to pass down to gcc. gcc builds a library, libgcc.a, so it
+# unfortunately needs the native compiler and the target ar and
+# ranlib.
+# If any variables are added here, they must be added to do-*, below.
+# The HOST_* variables are a special case, which are used for the gcc
+# cross-building scheme.
+EXTRA_GCC_FLAGS = \
+ 'AR=$(AR)' \
+ 'AS=$(AS)' \
+ 'CC=$(CC)' \
+ 'CXX=$(CXX)' \
+ 'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
+ 'HOST_CC=$(CC_FOR_BUILD)' \
+ 'HOST_PREFIX=$(HOST_PREFIX)' \
+ 'HOST_PREFIX_1=$(HOST_PREFIX_1)' \
+ 'NM=$(NM)' \
+ 'RANLIB=$(RANLIB)' \
+ 'WINDRES=$$(WINDRES_FOR_TARGET)' \
+ "GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
+ "`echo 'LANGUAGES=$(LANGUAGES)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'LIBGCC1_TEST=$(LIBGCC1_TEST)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'ENQUIRE=$(ENQUIRE)' | sed -e s/.*=$$/XFOO=/`" \
+ "`echo 'BOOT_CFLAGS=$(BOOT_CFLAGS)' | sed -e s/.*=$$/XFOO=/`"
+
+GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS)
+
+# This is a list of the targets for all of the modules which are compiled
+# using $(FLAGS_TO_PASS).
+ALL_MODULES = \
+ all-apache \
+ all-ash \
+ all-autoconf \
+ all-automake \
+ all-bash \
+ all-bfd \
+ all-binutils \
+ all-bison \
+ all-byacc \
+ all-bzip2 \
+ all-cvssrc \
+ all-db \
+ all-dejagnu \
+ all-diff \
+ all-dosutils \
+ all-etc \
+ all-fileutils \
+ all-findutils \
+ all-find \
+ all-flex \
+ all-gas \
+ all-gawk \
+ all-gettext \
+ all-gnuserv \
+ all-gprof \
+ all-grep \
+ all-grez \
+ all-gzip \
+ all-hello \
+ all-indent \
+ all-inet \
+ all-intl \
+ all-ispell \
+ all-itcl \
+ all-ld \
+ all-libgui \
+ all-libiberty \
+ all-libtool \
+ all-m4 \
+ all-make \
+ all-mmalloc \
+ all-opcodes \
+ all-patch \
+ all-perl \
+ all-prms \
+ all-rcs \
+ all-readline \
+ all-release \
+ all-recode \
+ all-sed \
+ all-send-pr \
+ all-shellutils \
+ all-sim \
+ all-tar \
+ all-tcl \
+ all-tcl8.1 \
+ all-texinfo \
+ all-textutils \
+ all-tgas \
+ all-time \
+ all-uudecode \
+ all-wdiff \
+ all-zip \
+ $(EXTRA_TARGET_HOST_ALL_MODULES)
+
+# This is a list of the check targets for all of the modules which are
+# compiled using $(FLAGS_TO_PASS).
+#
+# The list is in two parts. The first lists those tools which
+# are tested as part of the host's native tool-chain, and not
+# tested in a cross configuration.
+NATIVE_CHECK_MODULES = \
+ check-bison \
+ check-byacc \
+ check-flex \
+ check-zip
+
+CROSS_CHECK_MODULES = \
+ check-apache \
+ check-ash \
+ check-autoconf \
+ check-automake \
+ check-bash \
+ check-bfd \
+ check-binutils \
+ check-bzip2 \
+ check-cvssrc \
+ check-db \
+ check-dejagnu \
+ check-diff \
+ check-etc \
+ check-fileutils \
+ check-findutils \
+ check-find \
+ check-gas \
+ check-gawk \
+ check-gettext \
+ check-gnuserv \
+ check-gprof \
+ check-grep \
+ check-gzip \
+ check-hello \
+ check-indent \
+ check-inet \
+ check-intl \
+ check-ispell \
+ check-itcl \
+ check-ld \
+ check-libgui \
+ check-libiberty \
+ check-libtool \
+ check-m4 \
+ check-make \
+ check-mmcheckoc \
+ check-opcodes \
+ check-patch \
+ check-perl \
+ check-prms \
+ check-rcs \
+ check-readline \
+ check-recode \
+ check-sed \
+ check-send-pr \
+ check-shellutils \
+ check-sim \
+ check-tar \
+ check-tcl \
+ check-texinfo \
+ check-textutils \
+ check-tgas \
+ check-time \
+ check-uudecode \
+ check-wdiff \
+ $(EXTRA_TARGET_HOST_CHECK_MODULES)
+
+CHECK_MODULES=$(NATIVE_CHECK_MODULES) $(CROSS_CHECK_MODULES)
+
+# This is a list of the install targets for all of the modules which are
+# compiled using $(FLAGS_TO_PASS).
+# We put install-opcodes before install-binutils because the installed
+# binutils might be on PATH, and they might need the shared opcodes
+# library.
+# We put install-tcl before install-itcl because itcl wants to run a
+# program on installation which uses the Tcl libraries.
+INSTALL_MODULES = \
+ install-apache \
+ install-ash \
+ install-autoconf \
+ install-automake \
+ install-bash \
+ install-bfd \
+ install-bzip2 \
+ install-opcodes \
+ install-binutils \
+ install-bison \
+ install-byacc \
+ install-cvssrc \
+ install-db \
+ install-dejagnu \
+ install-diff \
+ install-dosutils \
+ install-etc \
+ install-fileutils \
+ install-findutils \
+ install-find \
+ install-flex \
+ install-gas \
+ install-gawk \
+ install-gettext \
+ install-gnuserv \
+ install-gprof \
+ install-grep \
+ install-grez \
+ install-gzip \
+ install-hello \
+ install-indent \
+ install-inet \
+ install-intl \
+ install-ispell \
+ install-tcl \
+ install-tcl8.1 \
+ install-itcl \
+ install-ld \
+ install-libgui \
+ install-libiberty \
+ install-libtool \
+ install-m4 \
+ install-make \
+ install-mmalloc \
+ install-patch \
+ install-perl \
+ install-prms \
+ install-rcs \
+ install-readline \
+ install-recode \
+ install-sed \
+ install-send-pr \
+ install-shellutils \
+ install-sim \
+ install-tar \
+ install-texinfo \
+ install-textutils \
+ install-tgas \
+ install-time \
+ install-uudecode \
+ install-wdiff \
+ install-zip \
+ $(EXTRA_TARGET_HOST_INSTALL_MODULES)
+
+# This is a list of the targets for all of the modules which are compiled
+# using $(X11_FLAGS_TO_PASS).
+ALL_X11_MODULES = \
+ all-emacs \
+ all-emacs19 \
+ all-gdb \
+ all-expect \
+ all-gash \
+ all-guile \
+ all-tclX \
+ all-tk \
+ all-tk8.1 \
+ all-tix
+
+# This is a list of the check targets for all of the modules which are
+# compiled using $(X11_FLAGS_TO_PASS).
+CHECK_X11_MODULES = \
+ check-emacs \
+ check-gdb \
+ check-guile \
+ check-expect \
+ check-gash \
+ check-tclX \
+ check-tk \
+ check-tix
+
+# This is a list of the install targets for all the modules which are
+# compiled using $(X11_FLAGS_TO_PASS).
+INSTALL_X11_MODULES = \
+ install-emacs \
+ install-emacs19 \
+ install-gdb \
+ install-guile \
+ install-expect \
+ install-gash \
+ install-tclX \
+ install-tk \
+ install-tk8.1 \
+ install-tix
+
+# This is a list of the targets for all of the modules which are compiled
+# using $(TARGET_FLAGS_TO_PASS).
+ALL_TARGET_MODULES = \
+ all-target-libio \
+ all-target-libstdc++ \
+ all-target-librx \
+ all-target-libg++ \
+ all-target-newlib \
+ all-target-libtermcap \
+ all-target-winsup \
+ all-target-libgloss \
+ all-target-libiberty \
+ all-target-gperf \
+ all-target-examples \
+ all-target-libstub \
+ all-target-bsp \
+ all-target-cygmon
+
+# This is a list of the configure targets for all of the modules which
+# are compiled using the target tools.
+CONFIGURE_TARGET_MODULES = \
+ configure-target-libio \
+ configure-target-libstdc++ \
+ configure-target-librx \
+ configure-target-libg++ \
+ configure-target-newlib \
+ configure-target-libtermcap \
+ configure-target-winsup \
+ configure-target-libgloss \
+ configure-target-libiberty \
+ configure-target-gperf \
+ configure-target-examples \
+ configure-target-libstub \
+ configure-target-bsp \
+ configure-target-cygmon
+
+# This is a list of the check targets for all of the modules which are
+# compiled using $(TARGET_FLAGS_TO_PASS).
+CHECK_TARGET_MODULES = \
+ check-target-libio \
+ check-target-libstdc++ \
+ check-target-libg++ \
+ check-target-newlib \
+ check-target-winsup \
+ check-target-libiberty \
+ check-target-gperf
+
+# This is a list of the install targets for all of the modules which are
+# compiled using $(TARGET_FLAGS_TO_PASS).
+INSTALL_TARGET_MODULES = \
+ install-target-libio \
+ install-target-libstdc++ \
+ install-target-libg++ \
+ install-target-newlib \
+ install-target-libtermcap \
+ install-target-winsup \
+ install-target-libgloss \
+ install-target-libiberty \
+ install-target-bsp \
+ install-target-gperf
+
+# This is a list of the targets for which we can do a clean-{target}.
+CLEAN_MODULES = \
+ clean-apache \
+ clean-ash \
+ clean-autoconf \
+ clean-automake \
+ clean-bash \
+ clean-bfd \
+ clean-binutils \
+ clean-bison \
+ clean-byacc \
+ clean-bzip2 \
+ clean-cvssrc \
+ clean-db \
+ clean-dejagnu \
+ clean-diff \
+ clean-dosutils \
+ clean-etc \
+ clean-fileutils \
+ clean-findutils \
+ clean-find \
+ clean-flex \
+ clean-gas \
+ clean-gawk \
+ clean-gettext \
+ clean-gnuserv \
+ clean-gprof \
+ clean-grep \
+ clean-grez \
+ clean-gzip \
+ clean-hello \
+ clean-indent \
+ clean-inet \
+ clean-intl \
+ clean-ispell \
+ clean-itcl \
+ clean-ld \
+ clean-libgui \
+ clean-libiberty \
+ clean-libtool \
+ clean-m4 \
+ clean-make \
+ clean-mmalloc \
+ clean-opcodes \
+ clean-patch \
+ clean-perl \
+ clean-prms \
+ clean-rcs \
+ clean-readline \
+ clean-release \
+ clean-recode \
+ clean-sed \
+ clean-send-pr \
+ clean-shellutils \
+ clean-sim \
+ clean-tar \
+ clean-tcl \
+ clean-texinfo \
+ clean-textutils \
+ clean-tgas \
+ clean-time \
+ clean-uudecode \
+ clean-wdiff \
+ clean-zip
+
+# All of the target modules that can be cleaned
+CLEAN_TARGET_MODULES = \
+ clean-target-libio \
+ clean-target-libstdc++ \
+ clean-target-librx \
+ clean-target-libg++ \
+ clean-target-newlib \
+ clean-target-winsup \
+ clean-target-libgloss \
+ clean-target-libiberty \
+ clean-target-gperf \
+ clean-target-examples \
+ clean-target-libstub \
+ clean-target-bsp \
+ clean-target-cygmon
+
+# All of the x11 modules that can be cleaned
+CLEAN_X11_MODULES = \
+ clean-emacs \
+ clean-emacs19 \
+ clean-gdb \
+ clean-expect \
+ clean-gash \
+ clean-guile \
+ clean-tclX \
+ clean-tk \
+ clean-tix
+
+# The target built for a native build.
+.PHONY: all.normal
+all.normal: \
+ $(ALL_MODULES) \
+ $(ALL_X11_MODULES) \
+ $(ALL_TARGET_MODULES) \
+ all-gcc
+
+# Do a target for all the subdirectories. A ``make do-X'' will do a
+# ``make X'' in all subdirectories (because, in general, there is a
+# dependency (below) of X upon do-X, a ``make X'' will also do this,
+# but it may do additional work as well).
+# This target ensures that $(BASE_FLAGS_TO_PASS) appears only once,
+# because it is so large that it can easily overflow the command line
+# length limit on some systems.
+DO_X = \
+ do-clean \
+ do-distclean \
+ do-dvi \
+ do-info \
+ do-install-info \
+ do-installcheck \
+ do-mostlyclean \
+ do-maintainer-clean \
+ do-TAGS
+.PHONY: $(DO_X)
+$(DO_X):
+ @target=`echo $@ | sed -e 's/^do-//'`; \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ for i in $(SUBDIRS) -dummy-; do \
+ if [ -f ./$$i/Makefile ]; then \
+ case $$i in \
+ gcc) \
+ for flag in $(EXTRA_GCC_FLAGS); do \
+ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \
+ done; \
+ ;; \
+ *) \
+ for flag in $(EXTRA_HOST_FLAGS); do \
+ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \
+ done; \
+ ;; \
+ esac ; \
+ export AR AS CC CXX LD NM RANLIB DLLTOOL WINDRES; \
+ if (cd ./$$i; \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+ "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+ "RANLIB=$${RANLIB}" \
+ "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
+ $${target}); \
+ then true; else exit 1; fi; \
+ else true; fi; \
+ done
+ @target=`echo $@ | sed -e 's/^do-//'`; \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ for i in $(TARGET_CONFIGDIRS) -dummy-; do \
+ if [ -f $(TARGET_SUBDIR)/$$i/Makefile ]; then \
+ for flag in $(EXTRA_TARGET_FLAGS); do \
+ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \
+ done; \
+ export AR AS CC CXX LD NM RANLIB DLLTOOL WINDRES; \
+ if (cd $(TARGET_SUBDIR)/$$i; \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+ "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+ "RANLIB=$${RANLIB}" \
+ "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
+ $${target}); \
+ then true; else exit 1; fi; \
+ else true; fi; \
+ done
+
+# Here are the targets which correspond to the do-X targets.
+
+.PHONY: info installcheck dvi install-info
+.PHONY: clean distclean mostlyclean maintainer-clean realclean
+.PHONY: local-clean local-distclean local-maintainer-clean
+info: do-info
+installcheck: do-installcheck
+dvi: do-dvi
+
+# Make sure makeinfo is built before we do a `make info'.
+do-info: all-texinfo
+
+install-info: do-install-info dir.info
+ s=`cd $(srcdir); pwd`; export s; \
+ if [ -f dir.info ] ; then \
+ $(INSTALL_DATA) dir.info $(infodir)/dir.info ; \
+ else true ; fi
+
+local-clean:
+ -rm -f *.a TEMP errs core *.o *~ \#* TAGS *.E *.log
+
+local-distclean:
+ -rm -f Makefile config.status config.cache mh-frag mt-frag
+ -if [ "$(TARGET_SUBDIR)" != "." ]; then \
+ rm -rf $(TARGET_SUBDIR); \
+ else true; fi
+
+local-maintainer-clean:
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+clean: do-clean local-clean
+mostlyclean: do-mostlyclean local-clean
+distclean: do-distclean local-clean local-distclean
+maintainer-clean: local-maintainer-clean do-maintainer-clean local-clean
+maintainer-clean: local-distclean
+realclean: maintainer-clean
+
+# This rule is used to clean specific modules.
+.PHONY: $(CLEAN_MODULES) $(CLEAN_X11_MODULES) clean-gcc
+$(CLEAN_MODULES) $(CLEAN_X11_MODULES) clean-gcc:
+ @dir=`echo $@ | sed -e 's/clean-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) clean); \
+ else \
+ true; \
+ fi
+
+.PHONY: $(CLEAN_TARGET_MODULES)
+$(CLEAN_TARGET_MODULES):
+ @dir=`echo $@ | sed -e 's/clean-target-//'`; \
+ rm -f $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/tmpmulti.out; \
+ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) clean); \
+ else \
+ true; \
+ fi
+
+clean-target: $(CLEAN_TARGET_MODULES)
+
+# Check target.
+
+.PHONY: check
+check: $(CHECK_MODULES) \
+ $(CHECK_TARGET_MODULES) \
+ $(CHECK_X11_MODULES) \
+ check-gcc
+
+# Automated reporting of test results.
+
+warning.log: build.log
+ $(srcdir)/contrib/warn_summary build.log > $@
+
+mail-report.log:
+ if test x'$(BOOT_CFLAGS)' != x''; then \
+ BOOT_CFLAGS='$(BOOT_CFLAGS)'; export BOOT_CFLAGS; \
+ fi; \
+ $(srcdir)/contrib/test_summary -t >$@
+ chmod +x $@
+ echo If you really want to send e-mail, run ./$@ now
+
+mail-report-with-warnings.log: warning.log
+ if test x'$(BOOT_CFLAGS)' != x''; then \
+ BOOT_CFLAGS='$(BOOT_CFLAGS)'; export BOOT_CFLAGS; \
+ fi; \
+ $(srcdir)/contrib/test_summary -t -i warning.log >$@
+ chmod +x $@
+ echo If you really want to send e-mail, run ./$@ now
+
+# Installation targets.
+
+.PHONY: install install-cross uninstall source-vault binary-vault vault-install
+install: $(INSTALL_TARGET)
+install-cross: $(INSTALL_TARGET_CROSS)
+
+uninstall:
+ @echo "the uninstall target is not supported in this tree"
+
+source-vault:
+ $(MAKE) -f ./release/Build-A-Release \
+ host=$(host_alias) source-vault
+
+binary-vault:
+ $(MAKE) -f ./release/Build-A-Release \
+ host=$(host_alias) target=$(target_alias)
+
+vault-install:
+ @if [ -f ./release/vault-install ] ; then \
+ ./release/vault-install $(host_alias) $(target_alias) ; \
+ else \
+ true ; \
+ fi
+
+.PHONY: install.all
+install.all: install-no-fixedincludes
+ @if [ -f ./gcc/Makefile ] ; then \
+ r=`pwd` ; export r ; \
+ $(SET_LIB_PATH) \
+ (cd ./gcc; \
+ $(MAKE) $(FLAGS_TO_PASS) install-headers) ; \
+ else \
+ true ; \
+ fi
+
+# inet-install is used because the I*Net wants DejaGNU installed but
+# not built. Similarly, gzip is built but not installed.
+inet-install:
+ $(MAKE) INSTALL_MODULES="`echo $(INSTALL_MODULES) | sed -e 's/install-dejagnu//' -e 's/install-gzip//'`" install
+
+# install-no-fixedincludes is used because Cygnus can not distribute
+# the fixed header files.
+.PHONY: install-no-fixedincludes
+install-no-fixedincludes: \
+ installdirs \
+ $(INSTALL_MODULES) \
+ $(INSTALL_TARGET_MODULES) \
+ $(INSTALL_X11_MODULES) \
+ gcc-no-fixedincludes
+
+# Install the gcc headers files, but not the fixed include files,
+# which Cygnus is not allowed to distribute. This rule is very
+# dependent on the workings of the gcc Makefile.in.
+.PHONY: gcc-no-fixedincludes
+gcc-no-fixedincludes:
+ @if [ -f ./gcc/Makefile ]; then \
+ rm -rf gcc/tmp-include; \
+ mv gcc/include gcc/tmp-include 2>/dev/null; \
+ mkdir gcc/include; \
+ cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \
+ touch gcc/stmp-fixinc gcc/include/fixed; \
+ rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd` ; export s; \
+ $(SET_LIB_PATH) \
+ (cd ./gcc; \
+ $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
+ rm -rf gcc/include; \
+ mv gcc/tmp-include gcc/include 2>/dev/null; \
+ else true; fi
+
+
+# This rule is used to build the modules which use FLAGS_TO_PASS. To
+# build a target all-X means to cd to X and make all.
+#
+# all-gui, and all-libproc are handled specially because
+# they are still experimental, and if they fail to build, that
+# shouldn't stop "make all".
+.PHONY: $(ALL_MODULES) all-gui all-libproc
+$(ALL_MODULES) all-gui all-libproc:
+ @dir=`echo $@ | sed -e 's/all-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) all); \
+ else \
+ true; \
+ fi
+
+# These rules are used to check the modules which use FLAGS_TO_PASS.
+# To build a target check-X means to cd to X and make check. Some
+# modules are only tested in a native toolchain.
+
+.PHONY: $(CHECK_MODULES) $(NATIVE_CHECK_MODULES) $(CROSS_CHECK_MODULES)
+$(NATIVE_CHECK_MODULES):
+ @if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+ dir=`echo $@ | sed -e 's/check-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \
+ else \
+ true; \
+ fi; \
+ fi
+
+$(CROSS_CHECK_MODULES):
+ @dir=`echo $@ | sed -e 's/check-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \
+ else \
+ true; \
+ fi
+
+# This rule is used to install the modules which use FLAGS_TO_PASS.
+# To build a target install-X means to cd to X and make install.
+.PHONY: $(INSTALL_MODULES)
+$(INSTALL_MODULES): installdirs
+ @dir=`echo $@ | sed -e 's/install-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \
+ else \
+ true; \
+ fi
+
+# This rule is used to configure the modules which are built with the
+# target tools.
+.PHONY: $(CONFIGURE_TARGET_MODULES)
+$(CONFIGURE_TARGET_MODULES):
+ @dir=`echo $@ | sed -e 's/configure-target-//'`; \
+ if [ -d $(TARGET_SUBDIR)/$${dir} ]; then \
+ r=`pwd`; export r; \
+ $(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/$${dir}/tmpmulti.out 2> /dev/null; \
+ if [ -s $(TARGET_SUBDIR)/$${dir}/tmpmulti.out ]; then \
+ if [ -f $(TARGET_SUBDIR)/$${dir}/multilib.out ]; then \
+ if cmp $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/tmpmulti.out > /dev/null; then \
+ rm -f $(TARGET_SUBDIR)/$${dir}/tmpmulti.out; \
+ else \
+ echo "Multilibs changed for $${dir}, reconfiguring"; \
+ rm -f $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/Makefile; \
+ mv $(TARGET_SUBDIR)/$${dir}/tmpmulti.out $(TARGET_SUBDIR)/$${dir}/multilib.out; \
+ fi; \
+ else \
+ mv $(TARGET_SUBDIR)/$${dir}/tmpmulti.out $(TARGET_SUBDIR)/$${dir}/multilib.out; \
+ fi; \
+ fi; \
+ fi; exit 0 # break command into two pieces
+ @dir=`echo $@ | sed -e 's/configure-target-//'`; \
+ if [ ! -d $(TARGET_SUBDIR) ]; then \
+ true; \
+ elif [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \
+ true; \
+ elif echo " $(TARGET_CONFIGDIRS) " | grep " $${dir} " >/dev/null 2>&1; then \
+ if [ -d $(srcdir)/$${dir} ]; then \
+ [ -d $(TARGET_SUBDIR)/$${dir} ] || mkdir $(TARGET_SUBDIR)/$${dir};\
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ AR="$(AR_FOR_TARGET)"; export AR; \
+ AS="$(AS_FOR_TARGET)"; export AS; \
+ CC="$(CC_FOR_TARGET)"; export CC; \
+ CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+ CXX="$(CXX_FOR_TARGET)"; export CXX; \
+ CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+ DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
+ LD="$(LD_FOR_TARGET)"; export LD; \
+ LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
+ NM="$(NM_FOR_TARGET)"; export NM; \
+ RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
+ WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
+ echo Configuring in $(TARGET_SUBDIR)/$${dir}; \
+ cd $(TARGET_SUBDIR)/$${dir}; \
+ case $(srcdir) in \
+ /*) \
+ topdir=$(srcdir) ;; \
+ *) \
+ case "$(TARGET_SUBDIR)" in \
+ .) topdir="../$(srcdir)" ;; \
+ *) topdir="../../$(srcdir)" ;; \
+ esac ;; \
+ esac; \
+ if [ "$(srcdir)" = "." ] ; then \
+ if [ "$(TARGET_SUBDIR)" != "." ] ; then \
+ if $(SHELL) $$s/symlink-tree $${topdir}/$${dir} "no-such-file" ; then \
+ if [ -f Makefile ]; then \
+ if $(MAKE) distclean; then \
+ true; \
+ else \
+ exit 1; \
+ fi; \
+ else \
+ true; \
+ fi; \
+ else \
+ exit 1; \
+ fi; \
+ else \
+ true; \
+ fi; \
+ srcdiroption="--srcdir=."; \
+ libsrcdir="."; \
+ else \
+ srcdiroption="--srcdir=$${topdir}/$${dir}"; \
+ libsrcdir="$$s/$${dir}"; \
+ fi; \
+ if [ -f $${libsrcdir}/configure ] ; then \
+ rm -f no-such-file skip-this-dir; \
+ CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+ $(CONFIG_ARGUMENTS) $${srcdiroption} \
+ --with-target-subdir="$(TARGET_SUBDIR)"; \
+ else \
+ rm -f no-such-file skip-this-dir; \
+ CONFIG_SITE=no-such-file $(SHELL) $$s/configure \
+ $(CONFIG_ARGUMENTS) $${srcdiroption} \
+ --with-target-subdir="$(TARGET_SUBDIR)"; \
+ fi; \
+ if [ -f skip-this-dir ] ; then \
+ sh skip-this-dir; \
+ rm -f skip-this-dir; \
+ cd ..; rmdir $${dir} || true; \
+ else \
+ true; \
+ fi; \
+ else \
+ true; \
+ fi; \
+ else \
+ true; \
+ fi
+
+# This rule is used to build the modules which use TARGET_FLAGS_TO_PASS.
+# To build a target all-X means to cd to X and make all.
+.PHONY: $(ALL_TARGET_MODULES)
+$(ALL_TARGET_MODULES):
+ @dir=`echo $@ | sed -e 's/all-target-//'`; \
+ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) all); \
+ else \
+ true; \
+ fi
+
+# This rule is used to check the modules which use TARGET_FLAGS_TO_PASS.
+# To build a target install-X means to cd to X and make install.
+.PHONY: $(CHECK_TARGET_MODULES)
+$(CHECK_TARGET_MODULES):
+ @dir=`echo $@ | sed -e 's/check-target-//'`; \
+ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $(TARGET_SUBDIR)/$${dir};$(MAKE) $(TARGET_FLAGS_TO_PASS) check);\
+ else \
+ true; \
+ fi
+
+# This rule is used to install the modules which use
+# TARGET_FLAGS_TO_PASS. To build a target install-X means to cd to X
+# and make install.
+.PHONY: $(INSTALL_TARGET_MODULES)
+$(INSTALL_TARGET_MODULES): installdirs
+ @dir=`echo $@ | sed -e 's/install-target-//'`; \
+ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $(TARGET_SUBDIR)/$${dir}; \
+ $(MAKE) $(TARGET_FLAGS_TO_PASS) install); \
+ else \
+ true; \
+ fi
+
+# This rule is used to build the modules which use X11_FLAGS_TO_PASS.
+# To build a target all-X means to cd to X and make all.
+.PHONY: $(ALL_X11_MODULES)
+$(ALL_X11_MODULES):
+ @dir=`echo $@ | sed -e 's/all-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; \
+ $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) all); \
+ else \
+ true; \
+ fi
+
+# This rule is used to check the modules which use X11_FLAGS_TO_PASS.
+# To build a target check-X means to cd to X and make all.
+.PHONY: $(CHECK_X11_MODULES)
+$(CHECK_X11_MODULES):
+ @dir=`echo $@ | sed -e 's/check-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; \
+ $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) check); \
+ else \
+ true; \
+ fi
+
+# This rule is used to install the modules which use X11_FLAGS_TO_PASS.
+# To build a target install-X means to cd to X and make install.
+.PHONY: $(INSTALL_X11_MODULES)
+$(INSTALL_X11_MODULES): installdirs
+ @dir=`echo $@ | sed -e 's/install-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; \
+ $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install); \
+ else \
+ true; \
+ fi
+
+# gcc is the only module which uses GCC_FLAGS_TO_PASS.
+.PHONY: all-gcc
+all-gcc:
+ @if [ -f ./gcc/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) all); \
+ else \
+ true; \
+ fi
+
+# Building GCC uses some tools for rebuilding "source" files
+# like texinfo, bison/byacc, etc. So we must depend on those.
+#
+# While building GCC, it may be necessary to run various target
+# programs like the assembler, linker, etc. So we depend on
+# those too.
+#
+# In theory, on an SMP all those dependencies can be resolved
+# in parallel.
+#
+.PHONY: bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean
+bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean: all-texinfo all-bison all-byacc all-binutils all-gas all-ld
+ @r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ echo "Bootstrapping the compiler"; \
+ cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) $@
+ @r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ case "$@" in \
+ *bootstrap4-lean ) \
+ msg="Comparing stage3 and stage4 of the compiler"; \
+ compare=compare3-lean ;; \
+ *bootstrap4 ) msg="Comparing stage3 and stage4 of the compiler"; \
+ compare=compare3 ;; \
+ *-lean ) msg="Comparing stage2 and stage3 of the compiler"; \
+ compare=compare-lean ;; \
+ * ) msg="Comparing stage2 and stage3 of the compiler"; \
+ compare=compare ;; \
+ esac; \
+ $(SET_LIB_PATH) \
+ echo "$$msg"; \
+ cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) $$compare
+ @r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd` ; export s; \
+ $(SET_LIB_PATH) \
+ echo "Building runtime libraries"; \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) all
+
+.PHONY: cross
+cross: all-texinfo all-bison all-byacc all-binutils all-gas all-ld
+ @r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ echo "Building the C and C++ compiler"; \
+ cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) LANGUAGES="c c++"
+ @r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd` ; export s; \
+ $(SET_LIB_PATH) \
+ echo "Building runtime libraries"; \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) all LANGUAGES="c c++"
+
+.PHONY: check-gcc
+check-gcc:
+ @if [ -f ./gcc/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) check); \
+ else \
+ true; \
+ fi
+
+.PHONY: install-gcc
+install-gcc:
+ @if [ -f ./gcc/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
+ else \
+ true; \
+ fi
+
+.PHONY: install-gcc-cross
+install-gcc-cross:
+ @if [ -f ./gcc/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) LANGUAGES="c c++" install); \
+ else \
+ true; \
+ fi
+# EXPERIMENTAL STUFF
+# This rule is used to install the modules which use FLAGS_TO_PASS.
+# To build a target install-X means to cd to X and make install.
+.PHONY: install-dosrel
+install-dosrel: installdirs info
+ @dir=`echo $@ | sed -e 's/install-//'`; \
+ if [ -f ./$${dir}/Makefile ] ; then \
+ r=`pwd`; export r; \
+ s=`cd $(srcdir); pwd`; export s; \
+ $(SET_LIB_PATH) \
+ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \
+ else \
+ true; \
+ fi
+
+install-dosrel-fake:
+
+
+# This is a list of inter-dependencies among modules.
+all-apache:
+all-ash:
+all-autoconf: all-m4 all-texinfo
+all-automake: all-m4 all-texinfo
+all-bash:
+all-bfd: all-libiberty all-intl
+all-binutils: all-libiberty all-opcodes all-bfd all-flex all-bison all-byacc all-intl
+all-bison: all-texinfo
+configure-target-bsp: $(ALL_GCC)
+all-target-bsp: configure-target-bsp all-gcc all-binutils all-target-newlib
+all-byacc:
+all-bzip2:
+all-cvssrc:
+configure-target-cygmon: $(ALL_GCC)
+all-target-cygmon: configure-target-cygmon all-gas all-ld all-gcc all-target-libiberty all-target-newlib all-target-libio all-target-libstub all-target-bsp
+all-db:
+all-dejagnu: all-tcl all-expect all-tk
+all-diff: all-libiberty
+all-emacs:
+all-emacs19: all-bison all-byacc
+all-etc:
+configure-target-examples: $(ALL_GCC)
+all-target-examples: configure-target-examples
+all-expect: all-tcl all-tk
+all-fileutils: all-libiberty
+all-findutils:
+all-find:
+all-flex: all-libiberty all-bison all-byacc
+all-gas: all-libiberty all-opcodes all-bfd all-intl
+all-gash: all-tcl
+all-gawk:
+ALL_GCC = all-gcc
+all-gcc: all-bison all-byacc all-binutils all-gas all-ld
+all-bootstrap: all-libiberty all-bison all-byacc all-binutils all-gas all-ld
+GDB_TK = all-tk all-tcl all-itcl all-tix all-libgui
+all-gdb: all-libiberty all-opcodes all-bfd all-mmalloc all-readline all-bison all-byacc all-sim $(gdbnlmrequirements) $(GDB_TK)
+all-gettext:
+all-gnuserv:
+configure-target-gperf: $(ALL_GCC)
+all-target-gperf: configure-target-gperf all-target-libiberty all-target-libstdc++
+all-gprof: all-libiberty all-bfd all-opcodes all-intl
+all-grez: all-libiberty all-bfd all-opcodes
+all-gui: all-gdb all-libproc all-target-librx
+all-guile:
+all-gzip: all-libiberty
+all-hello: all-libiberty
+all-indent:
+all-inet: all-tcl all-send-pr all-perl
+all-intl:
+all-ispell: all-emacs19
+all-itcl: all-tcl all-tk all-tcl8.1 all-tk8.1
+all-ld: all-libiberty all-bfd all-opcodes all-bison all-byacc all-flex all-intl
+configure-target-libg++: $(ALL_GCC) configure-target-librx
+all-target-libg++: configure-target-libg++ all-gas all-ld all-gcc all-target-libiberty all-target-newlib all-target-libio all-target-librx all-target-libstdc++
+configure-target-libgloss: $(ALL_GCC)
+all-target-libgloss: configure-target-libgloss configure-target-newlib
+configure-target-libio: $(ALL_GCC)
+all-target-libio: configure-target-libio all-gas all-ld all-gcc all-target-libiberty all-target-newlib
+check-target-libio: all-target-libstdc++
+all-libgui: all-tcl all-tk all-tcl8.1 all-tk8.1 all-itcl
+all-libiberty:
+configure-target-librx: $(ALL_GCC) configure-target-newlib
+all-target-librx: configure-target-librx
+configure-target-libstdc++: $(ALL_GCC)
+all-target-libstdc++: configure-target-libstdc++ all-gas all-ld all-gcc all-target-libiberty all-target-newlib all-target-libio
+configure-target-libstub: $(ALL_GCC)
+all-target-libstub: configure-target-libstub
+all-libtool:
+all-m4: all-libiberty
+all-make: all-libiberty
+all-mmalloc:
+configure-target-newlib: $(ALL_GCC)
+configure-target-libtermcap: $(ALL_GCC)
+all-target-newlib: configure-target-newlib all-binutils all-gas all-gcc
+all-target-libtermcap: configure-target-libtermcap all-binutils all-gas all-gcc
+all-opcodes: all-bfd all-libiberty
+all-patch: all-libiberty
+all-perl:
+all-prms: all-libiberty
+all-rcs:
+all-readline:
+all-recode: all-libiberty
+all-sed: all-libiberty
+all-send-pr: all-prms
+all-shellutils:
+all-sim: all-libiberty all-bfd all-opcodes all-readline
+all-tar: all-libiberty
+all-tcl:
+all-tcl8.1:
+all-tclX: all-tcl all-tk
+all-tk: all-tcl
+all-tk8.1: all-tcl8.1
+all-texinfo: all-libiberty
+all-textutils:
+all-tgas: all-libiberty all-bfd all-opcodes
+all-time:
+all-tix: all-tcl all-tk all-tcl8.1 all-tk8.1
+all-wdiff:
+all-target-winsup: all-target-newlib all-target-libiberty all-target-libtermcap configure-target-winsup
+configure-target-winsup: configure-target-newlib
+all-uudecode: all-libiberty
+all-zip:
+configure-target-libiberty: $(ALL_GCC)
+all-target-libiberty: configure-target-libiberty all-gcc all-ld all-target-newlib
+all-target: $(ALL_TARGET_MODULES)
+install-target: $(INSTALL_TARGET_MODULES)
+### other supporting targets
+
+MAKEDIRS= \
+ $(prefix) \
+ $(exec_prefix)
+.PHONY: installdirs
+installdirs: mkinstalldirs
+ $(SHELL) $(srcdir)/mkinstalldirs $(MAKEDIRS)
+
+dir.info: do-install-info
+ if [ -f $(srcdir)/texinfo/gen-info-dir ] ; then \
+ $(srcdir)/texinfo/gen-info-dir $(infodir) $(srcdir)/texinfo/dir.info-template > dir.info.new ; \
+ mv -f dir.info.new dir.info ; \
+ else true ; \
+ fi
+
+dist:
+ @echo "Building a full distribution of this tree isn't done"
+ @echo "via 'make dist'. Check out the etc/ subdirectory"
+
+etags tags: TAGS
+
+# Right now this just builds TAGS in each subdirectory. emacs19 has the
+# ability to use several tags files at once, so there is probably no need
+# to combine them into one big TAGS file (like CVS 1.3 does). We could
+# (if we felt like it) have this Makefile write a piece of elisp which
+# the user could load to tell emacs19 where all the TAGS files we just
+# built are.
+TAGS: do-TAGS
+
+# with the gnu make, this is done automatically.
+
+Makefile: Makefile.in configure.in $(host_makefile_frag) $(target_makefile_frag) $(gcc_version_trigger)
+ $(SHELL) ./config.status
+
+#
+# Support for building net releases
+
+# Files in devo used in any net release.
+# ChangeLog omitted because it may refer to files which are not in this
+# distribution (perhaps it would be better to include it anyway).
+DEVO_SUPPORT= README Makefile.in configure configure.in \
+ config.guess config.if config.sub config move-if-change \
+ mpw-README mpw-build.in mpw-config.in mpw-configure mpw-install \
+ COPYING COPYING.LIB install-sh config-ml.in symlink-tree \
+ mkinstalldirs ltconfig ltmain.sh missing ylwrap
+
+# Files in devo/etc used in any net release.
+# ChangeLog omitted because it may refer to files which are not in this
+# distribution (perhaps it would be better to include it anyway).
+ETC_SUPPORT= Makefile.in configure configure.in standards.texi \
+ make-stds.texi standards.info*
+
+# When you use `make setup-dirs' or `make taz' you should always redefine
+# this macro.
+SUPPORT_FILES = list-of-support-files-for-tool-in-question
+
+.PHONY: taz
+
+taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) \
+ texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo
+ # Take out texinfo from a few places.
+ sed -e '/^all\.normal: /s/\all-texinfo //' \
+ -e '/^ install-texinfo /d' \
+ <Makefile.in >tmp
+ mv -f tmp Makefile.in
+ #
+ ./configure sun4
+ [ -z "$(CONFIGURE_TARGET_MODULES)" ] \
+ || $(MAKE) $(CONFIGURE_TARGET_MODULES) ALL_GCC="" \
+ CC_FOR_TARGET="$(CC)" CXX_FOR_TARGET="$(CXX)"
+ # Make links, and run "make diststuff" or "make info" when needed.
+ rm -rf proto-toplev ; mkdir proto-toplev
+ set -e ; dirs="$(TOOL) $(DEVO_SUPPORT) $(SUPPORT_FILES)" ; \
+ for d in $$dirs ; do \
+ if [ -d $$d ]; then \
+ if [ ! -f $$d/Makefile ] ; then true ; \
+ elif grep '^diststuff:' $$d/Makefile >/dev/null ; then \
+ (cd $$d ; $(MAKE) diststuff ) || exit 1 ; \
+ elif grep '^info:' $$d/Makefile >/dev/null ; then \
+ (cd $$d ; $(MAKE) info ) || exit 1 ; \
+ fi ; \
+ if [ -d $$d/proto-$$d.dir ]; then \
+ ln -s ../$$d/proto-$$d.dir proto-toplev/$$d ; \
+ else \
+ ln -s ../$$d proto-toplev/$$d ; \
+ fi ; \
+ else ln -s ../$$d proto-toplev/$$d ; fi ; \
+ done
+ cd etc ; $(MAKE) info
+ $(MAKE) distclean
+ #
+ mkdir proto-toplev/etc
+ (cd proto-toplev/etc; \
+ for i in $(ETC_SUPPORT); do \
+ ln -s ../../etc/$$i . ; \
+ done)
+ #
+ # Take out texinfo from configurable dirs
+ rm proto-toplev/configure.in
+ sed -e '/^host_tools=/s/texinfo //' \
+ <configure.in >proto-toplev/configure.in
+ #
+ mkdir proto-toplev/texinfo
+ ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/
+ ln -s ../../texinfo/gpl.texinfo proto-toplev/texinfo/
+ ln -s ../../texinfo/lgpl.texinfo proto-toplev/texinfo/
+ if test -r texinfo/util/tex3patch ; then \
+ mkdir proto-toplev/texinfo/util && \
+ ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util ; \
+ else true; fi
+ chmod -R og=u . || chmod og=u `find . -print`
+ if grep AM_INIT_AUTOMAKE $(TOOL)/configure.in >/dev/null 2>&1; then \
+ ver=`sed < $(TOOL)/configure.in -n 's/AM_INIT_AUTOMAKE[^,]*, *\([^)]*\))/\1/p'`; \
+ else \
+ ver=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'`; \
+ fi; \
+ $(MAKE) -f Makefile.in do-tar-gz TOOL=$(TOOL) VER=$$ver
+
+do-tar-gz:
+ echo "==> Making $(TOOL)-$(VER).tar.gz"
+ -rm -f $(TOOL)-$(VER)
+ ln -s proto-toplev $(TOOL)-$(VER)
+ tar cfh $(TOOL)-$(VER).tar $(TOOL)-$(VER)
+ $(GZIPPROG) -v -9 $(TOOL)-$(VER).tar
+
+TEXINFO_SUPPORT= texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo
+DIST_SUPPORT= $(DEVO_SUPPORT) $(TEXINFO_SUPPORT)
+
+.PHONY: gas.tar.gz
+GAS_SUPPORT_DIRS= bfd include libiberty opcodes intl setup.com makefile.vms
+gas.tar.gz: $(DIST_SUPPORT) $(GAS_SUPPORT_DIRS) gas
+ $(MAKE) -f Makefile.in taz TOOL=gas \
+ SUPPORT_FILES="$(GAS_SUPPORT_DIRS)"
+
+# The FSF "binutils" release includes gprof and ld.
+.PHONY: binutils.tar.gz
+BINUTILS_SUPPORT_DIRS= bfd gas include libiberty opcodes ld gprof intl setup.com makefile.vms
+binutils.tar.gz: $(DIST_SUPPORT) $(BINUTILS_SUPPORT_DIRS) binutils
+ $(MAKE) -f Makefile.in taz TOOL=binutils \
+ SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS) makeall.bat configure.bat"
+
+.PHONY: gas+binutils.tar.gz
+GASB_SUPPORT_DIRS= $(GAS_SUPPORT_DIRS) binutils ld gprof
+gas+binutils.tar.gz: $(DIST_SUPPORT) $(GASB_SUPPORT_DIRS) gas
+ $(MAKE) -f Makefile.in taz TOOL=gas \
+ SUPPORT_FILES="$(GASB_SUPPORT_DIRS) makeall.bat configure.bat"
+
+.PHONY: libg++.tar.gz
+LIBGXX_SUPPORT_DIRS=include libstdc++ libio librx libiberty
+libg++.tar.gz: $(DIST_SUPPORT) libg++
+ $(MAKE) -f Makefile.in taz TOOL=libg++ \
+ SUPPORT_FILES="$(LIBGXX_SUPPORT_DIRS)"
+
+GNATS_SUPPORT_DIRS=include libiberty send-pr
+gnats.tar.gz: $(DIST_SUPPORT) $(GNATS_SUPPORT_DIRS) gnats
+ $(MAKE) -f Makefile.in taz TOOL=gnats \
+ SUPPORT_FILES="$(GNATS_SUPPORT_DIRS)"
+
+.PHONY: gdb.tar.gz
+GDB_SUPPORT_DIRS= bfd include libiberty mmalloc opcodes readline sim utils intl
+gdb.tar.gz: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
+ $(MAKE) -f Makefile.in taz TOOL=gdb \
+ SUPPORT_FILES="$(GDB_SUPPORT_DIRS)"
+
+.PHONY: newlib.tar.gz
+NEWLIB_SUPPORT_DIRS=libgloss
+# taz configures for the sun4 target which won't configure newlib.
+# We need newlib configured so that the .info files are made.
+# Unfortunately, it is not enough to just configure newlib separately:
+# taz will build the .info files but since SUBDIRS won't contain newlib,
+# distclean won't be run (leaving Makefile, config.status, and the tmp files
+# used in building the .info files, eg: *.def, *.ref).
+# The problem isn't solvable however without a lot of extra work because
+# target libraries are built in subdir $(target_alias) which gets nuked during
+# the make distclean. For now punt on the issue of shipping newlib info files
+# with newlib net releases and wait for a day when some native target (sun4?)
+# supports newlib (if only minimally).
+newlib.tar.gz: $(DIST_SUPPORT) $(NEWLIB_SUPPORT_DIRS) newlib
+ $(MAKE) -f Makefile.in taz TOOL=newlib \
+ SUPPORT_FILES="$(NEWLIB_SUPPORT_DIRS)" \
+ DEVO_SUPPORT="$(DEVO_SUPPORT) COPYING.NEWLIB" newlib
+
+.NOEXPORT:
+MAKEOVERRIDES=
+
+# end of Makefile.in
diff --git a/README b/README
new file mode 100644
index 00000000000..eb0e436d860
--- /dev/null
+++ b/README
@@ -0,0 +1,47 @@
+ README for GNU development tools
+
+This directory contains various GNU compilers, assemblers, linkers,
+debuggers, etc., plus their support routines, definitions, and documentation.
+
+If you are receiving this as part of a GDB release, see the file gdb/README.
+If with a binutils release, see binutils/README; if with a libg++ release,
+see libg++/README, etc. That'll give you info about this
+package -- supported targets, how to use it, how to report bugs, etc.
+
+It is now possible to automatically configure and build a variety of
+tools with one command. To build all of the tools contained herein,
+run the ``configure'' script here, e.g.:
+
+ ./configure
+ make
+
+To install them (by default in /usr/local/bin, /usr/local/lib, etc),
+then do:
+ make install
+
+(If the configure script can't determine your type of computer, give it
+the name as an argument, for instance ``./configure sun4''. You can
+use the script ``config.sub'' to test whether a name is recognized; if
+it is, config.sub translates it to a triplet specifying CPU, vendor,
+and OS.)
+
+If you have more than one compiler on your system, it is often best to
+explicitly set CC in the environment before running configure, and to
+also set CC when running make. For example (assuming sh/bash/ksh):
+
+ CC=gcc ./configure
+ make
+
+A similar example using csh:
+
+ setenv CC gcc
+ ./configure
+ make
+
+Much of the code and documentation enclosed is copyright by
+the Free Software Foundation, Inc. See the file COPYING or
+COPYING.LIB in the various directories, for a description of the
+GNU General Public License terms under which you can copy the files.
+
+REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
+on where and how to report problems.
diff --git a/bfd/COPYING b/bfd/COPYING
new file mode 100644
index 00000000000..60549be514a
--- /dev/null
+++ b/bfd/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
new file mode 100644
index 00000000000..66a5b243f36
--- /dev/null
+++ b/bfd/ChangeLog
@@ -0,0 +1,3066 @@
+1999-04-29 Nick Clifton <nickc@cygnus.com>
+
+ * coff-mcore.c (coff_mcore_relocate_section): Fix typos.
+
+Fri Apr 28 16:36:19 1999 Stan Cox <scox@cygnus.com>
+
+ * elf32-sh.c (sh_elf_relocate_section): Include relocation addend
+ in relocation calculation.
+
+1999-04-26 Tom Tromey <tromey@cygnus.com>
+
+ * aclocal.m4, configure: Updated for new version of libtool.
+
+1999-04-21 Nick Clifton <nickc@cygnus.com>
+
+ * coff-mcore.c: Add support for mcore relocs.
+
+1999-04-20 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_print_private_bfd_data): Scrap the
+ incorrect use EF_MIPS_xxBITPTRS.
+
+1999-04-18 Ian Lance Taylor <ian@zembu.com>
+
+ * elf64-alpha.c (elf64_alpha_relax_section): Remove unused local
+ variable insn.
+
+ * bfd-in2.h: Rebuild.
+ * libbfd.h: Rebuild.
+
+Sat Apr 17 20:55:15 1999 Catherine Moore <clm@cygnus.com>
+
+ * coff-arm.c (coff_arm_rtype_to_howto): Remove ARM26D transform.
+ (coff_arm_relocate_section): Add ARM26D transform. Only
+ change to ARM26D for relocateable links.
+
+1999-04-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_print_private_bfd_data): New.
+ (bfd_elf32_bfd_print_private_bfd_data): New.
+
+1999-04-15 Doug Evans <devans@casey.cygnus.com>
+
+ * elf32-arm.h (elf32_arm_final_link_relocate): For R_ARM_THM_ABS5,
+ refetch addend if USE_REL, add many comments regarding current state.
+ For R_ARM_THM_PC22, refetch addend if USE_REL, simplify.
+ * elfarm-nabi.c (elf32_arm_howto_table): For R_ARM_THM_ABS5, fix
+ size and rightshift. For R_ARM_THM_PC22, fix bitsize.
+ * elfarm-oabi.c (elf32_arm_howto_table): Ditto.
+
+Wed Apr 14 14:33:08 1999 Richard Henderson <rth@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_read_ecoff_info): Zero `debug'.
+ * elf64-alpha.c (elf64_alpha_read_ecoff_info): Likewise.
+
+1999-04-13 David Mosberger <davidm@hpl.hp.com>
+
+ * dwarf2.c (decode_line_info): Don't truncate address to least
+ significant 32 bits (breaks 64 bit targets).
+ (lookup_address_in_function_table): Ditto.
+ (comp_unit_contains_address): Ditto.
+
+Tue Apr 13 21:27:19 1999 Catherine Moore <clm@cygnus.com>
+
+ * coff-arm.c (arm_emit_base_file_entry): New routine.
+ (A2T3_OFFSET): Define.
+ (T2A3_OFFSET): Define.
+ (coff_arm_relocate_section): Emit base file entries for interworking
+ stubs.
+
+1999-04-13 Philip Blundell <philb@gnu.org>
+
+ * elfarm-nabi.c (elf32_arm_howto_table): Add dummy entries for
+ relocs 17 through 19.
+
+Sun Apr 11 01:25:17 1999 Richard Henderson <rth@cygnus.com>
+
+ * elfcode.h: Remove fnmatch.h.
+ * elflink.h (elf_link_assign_sym_version): Call back to ld
+ instead of calling fnmatch.
+
+ * config.bfd (i?86-*-beoself): Include pe vecs.
+
+Sun Apr 11 01:14:06 1999 Richard Henderson <rth@cygnus.com>
+
+ * elf32-i386.c (elf_i386_finish_dynamic_sections): Allow .plt
+ to go missing.
+
+1999-04-10 Richard Henderson <rth@cygnus.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): Mind no_undefined
+ when trying to resolve dynamic symbol references.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+ * elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+ * elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+ * elflink.h (elf_link_output_extsym): Likewise.
+
+Sat Apr 10 15:12:09 1999 Richard Henderson <rth@cygnus.com>
+
+ * section.c (_bfd_strip_section_from_output): New function moved from
+ * elf64-alpha.c (elf64_alpha_strip_section_from_output): ... here.
+ * elf32-i386.c (elf_i386_size_dynamic_sections): Use it.
+ * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
+ * elf32-mips.c (mips_elf_size_dynamic_sections): Likewise.
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Likewise.
+ * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise.
+ * bfd-in2.h: Update.
+
+1999-04-09 Ian Lance Taylor <ian@zembu.com>
+
+ * elf64-sparc.c: Fix incorrect calls to bfd_check_overflow.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * coff-mcore.c: New File: Support for mcore-pe targets.
+ * cpu-mcore.c: New File: Support for mcore targets.
+ * elf32-mcore.c: New File: Support for mcore-elf target.
+ * pe-mcore.c: New File: Definitions for mcore-pe target.
+ * pei-mcore.c: New File: Definitions for mcore-pei target.
+ * Makefile.am: Add support for MCore targets.
+ * Makefile.in: Regenerate.
+ * config.bfd: Add support for MCore targets.
+ * configure.in: Add support for MCore targets.
+ * configure: Regenerate.
+ * archures.c: Add support for MCore architecture.
+ * bfd-in2.h: Regenerate.
+ * coffcode.h: Add support for mcore-pe targets.
+ * elf.c: Add support for mcore-elf target.
+ * reloc.c: Add support for MCore relocs.
+ * targets.c: Add support for MCore targets.
+
+1999-04-07 Nick Clifton <nickc@cygnus.com>
+
+ * elfarm-nabi.c (elf32_arm_howto_table): Add entries for
+ R_ARM_XPC25 and R_ARM_THM_XPC22.
+ (elf32_arm_reloc_map): Remove redundant entries.
+
+1999-04-06 Ian Lance Taylor <ian@zembu.com>
+
+ * sysdep.h (LC_MESSAGES): Never define.
+
+1999-04-06 Chris Torek <torek@bsdi.com>
+
+ * reloc.c (bfd_check_overflow): Add addrsize parameter. Change
+ all callers. Rewrite completely.
+ (_bfd_relocate_contents): Rewrite overflow checking.
+ * bfd-in2.h: Rebuild.
+
+1999-04-05 Ian Lance Taylor <ian@zembu.com>
+
+ From Gabriel Paubert <paubert@iram.es>:
+ * elf32-ppc.c (ppc_elf_howto_raw): Set R_PPC_GOT16_LO,
+ R_PPC_PLT16_LO and R_PPC_SECTOFF_LO to be complain_overflow_dont.
+ Set R_PPC_PLT16_HA, R_PPC_SECTOFF_HA and R_PPC_EMB_NADDR16_HA to
+ have a rightshift of 16 and use ppc_elf_addr16_ha_reloc.
+ * ppcboot.c (ppcboot_vec): Use little endian routines for
+ headers.
+
+ * elf.c (elfcore_strndup): Only define if it will be used.
+ * elf32-ppc.c (ppc_elf_relax_section): Remove unused locals irel
+ and irelend.
+ (ppc_elf_check_relocs): Remove unused local i.
+ (ppc_elf_gc_mark_hook): Add default case to switch.
+
+ From Bernd Nitzler <nitzler@kagcpd01.ag01.kodak.COM>:
+ * srec.c (srec_scan): Accept \r in symbol definitions.
+ (srec_object_p): Set HAS_SYMS if we saw any symbols.
+ (symbolsrec_object_p): Likewise.
+
+1999-04-04 Don Bowman <don@pixsci.com>
+
+ * config.bfd: Add mips*el-*-vxworks* and mips*-*-vxworks*.
+
+1999-04-04 Ian Lance Taylor <ian@zembu.com>
+
+ * dwarf1.c (parse_line_table): Remove unused locals last_pc and
+ last_line.
+ * elf-bfd.h (_bfd_elfcore_section_from_phdr): Declare.
+ * elf32-i386.c (elf_i386_gc_mark_hook): Add default case to
+ switch.
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Remove unused
+ local i.
+ * syms.c (_bfd_stab_section_find_nearest_line): Remove unused
+ local val.
+
+1999-03-31 Nick Clifton <nickc@cygnus.com>
+
+ * config.bfd: Add support for arm-epoc-pe target.
+ * configure.in: Add support for arm-epoc-pe target.
+ * configure: Regenerate.
+ * targets.c: Add support for arm-epoc-pe target.
+ * coff-arm.c: Allow header files to override definition of
+ TARGET_UNDERSCORE and USER_LABEL_PREFIX.
+ * pe-arm.h: Allow previous header files to override definition of
+ TARGET_LITTLE_SYM and TARGET_BIG_SYM.
+ * pei-arm.h: Allow previous header files to override definition of
+ TARGET_LITTLE_SYM and TARGET_BIG_SYM.
+ * epoc-pe-arm.c: New file. Support arm-epoc-pe target.
+ * epoc-pei-arm.c: New file. Support arm-epoc-pei target.
+
+1999-03-30 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (elf_map_symbols): Handle the case where section
+ symbols are generated for content-less sections which are
+ not mapped to the output file.
+
+ * linker.c: Replace direct references to fields in BFD structure
+ with accessor macros.
+
+ * elflink.h: Replace direct references to fields in BFD structure
+ with accessor macros.
+
+1999-03-25 Philip Blundell <pb@nexus.co.uk>
+
+ * config.bfd: Eliminate redundancy in checks for Linux/ARM.
+
+ * elf32-arm.h (elf32_arm_relocate_section): Take the rightshift into
+ account when adjusting section symbols during a partial link.
+
+1999-03-24 Nick Clifton <nickc@cygnus.com>
+
+ * coff-sparc.c (struct coff_reloc_map): Change type of field
+ 'bfd_reloc_val' to bfd_reloc_code_real_type.
+ * elf-m10200.c (struct mn10200_reloc_map): Ditto.
+ * elf-m10300.c (struct mn10300_reloc_map): Ditto.
+ * elf32-arc.c (struct arc_reloc_map): Ditto.
+ * elf32-d10v.c (struct d10v_reloc_map): Ditto.
+ * elf32-d30v.c (struct d30v_reloc_map): Ditto.
+ * elf32-fr30.c (struct fr30_reloc_map): Ditto.
+ * elf32-m32r.c (struct m32r_reloc_map): Ditto.
+ * elf32-sh.c (struct elf_reloc_map): Ditto.
+ * elf32-sparc.c (struct elf_reloc_map): Ditto.
+ * elf32-v850.c (struct v850_reloc_map): Ditto.
+ * elf64-sparc.c (struct elf_reloc_map): Ditto.
+ * elfarm-nabi.c (struct elf32_arm_reloc_map): Ditto.
+ * elfarm-oabi.c (struct elf32_arm_reloc_map): Ditto.
+
+1999-03-17 Martin Hunt <hunt@cygnus.com>
+
+ * syms.c (_bfd_stab_section_find_nearest_line): Changed this
+ function so source-level assembly works. If multiple N_SOs
+ are seen without and N_FUNs, create an indextable entry with
+ a NULL function name.
+
+1999-03-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_merge_private_bfd_data) Allow merging
+ of certian similar cpus.
+
+1999-03-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_final_write_processing):
+ Add the 5000. Change the architecture for the 5400 to mips4.
+ (elf_mips_mach): Add r5000.
+
+1999-03-11 Doug Evans <devans@casey.cygnus.com>
+
+ * cpu-i960.c (scan_i960_mach): Recognize i960:ka_sa and i960:kb_sb.
+
+1999-03-11 Nick Clifton <nickc@cygnus.com>
+
+ * binary.c (binary_set_section_contents): Generate warning about
+ huge file offsets for any section that will occupy file space, not
+ just those that are loadable.
+
+1999-02-24 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ * libbfd.h: Regenerate after Nick Clifton's Feb 17 changes.
+
+1999-02-22 Jim Lemke <jlemke@cygnus.com>
+
+ * elf32-ppc.c: Add ppc_elf_relax_section() for the ld option mpc860c0.
+
+Mon Feb 22 18:26:51 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf-bfd.h (ELF_LINK_HASH_REF_REGULAR_NONWEAK): Define.
+ * elflink.h: Revert all changes since Feb 16. Instead:
+ (elf_link_add_object_symbols): Set REF_REGULAR_NONWEAK flag if
+ appropriate. Copy it to version symbols.
+ (elf_fix_symbol_flags): Set REF_REGULAR_NONWEAK for non ELF
+ symbols if appropriate.
+ (elf_adjust_dynamic_symbol): Set REF_REGULAR_NONWEAK for weakdef
+ symbol if appropriate.
+ (elf_link_output_extsym): If symbol is marked as undefined, and
+ has no nonweak references, mark it as weak undefined.
+
+Fri Feb 19 16:01:12 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_merge_symbol): When overriding a dynamic
+ definition with a weak undefined symbol, set NEEDS_PLT if it is a
+ function.
+ (elf_link_add_object_symbols): Don't copy the other field if we
+ are overridding.
+
+Thu Feb 18 18:07:43 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_merge_symbol): Do not merge any symbol from a
+ shared object with a weak undefined symbol.
+
+1999-02-18 Nick Clifton <nickc@cygnus.com>
+
+ * elfarm-nabi.c: Set partial_inplace back to false.
+
+1999-02-17 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (TARGET_UNDERSCORE): Re-enable.
+ (USER_LABEL_PREFIX): Set to "_".
+
+ The following patches are from: Scott Bambrough
+ <scottb@corelcomputer.com>
+
+ * libaout.h (M_ARM6_NETBSD): Set to 143.
+
+ * reloc.c: Add ARM PIC relocs: BFD_RELOC_ARM_GOT12,
+ BFD_RELOC_ARM_GOT32, BFD_RELOC_ARM_JUMP_SLOT, BFD_RELOC_ARM_COPY,
+ BFD_RELOC_ARM_GLOB_DAT, BFD_RELOC_ARM_PLT32,
+ BFD_RELOC_ARM_RELATIVE, BFD_RELOC_ARM_GOTOFF, BFD_RELOC_ARM_GOTPC.
+ * bfd-in2.h: Regenerate.
+
+ * elfarm-nabi.c (elf32_arm_howto_table): Set partial_inplace to
+ 'true' as REL relocs are now being used. Add new PIC relocs:
+ R_ARM_COPY, R_ARM_GLOB_DAT, R_ARM_JUMP_SLOT, R_ARM_RELATIVE,
+ R_ARM_GOTOFF, R_ARM_GOTPC, R_ARM_GOT32, R_ARM_PLT32.
+
+ * elf32-arm.h (elf32_arm_merge_private_bfd_data): Check byte order
+ of targets.
+ (elf32_arm_final_link_relocate): Change parameters so that entire
+ reloc is passed. Add support for PIC relocs.
+ (elf32_arm_relocate_section): Pass entire reloc to
+ elf32_arm_final_link_relocate.
+ (elf32_arm_check_relocs): Handle new PIC relocs.
+ (elf32_arm_adjust_dynamic_symbol): New function.
+ (elf32_arm_size_dynamic_sections): New function.
+ (elf32_arm_discard_copies): New function.
+ (elf32_arm_finish_dynamic_symbol): New function.
+ (elf32_arm_finish_dynamic_sections): New function.
+ (ELF_MAXPAGE_SIZE): Define.
+ (bfd_elf32_bfd_reloc_type_lookup): Define.
+ (elf_backend_relocate_section): Define.
+ (elf_backend_adjust_dynamic_symbol): Define.
+ (elf_backend_create_dynamic_sections): Define.
+ (elf_backend_finish_dynamic_symbol): Define.
+ (elf_backend_finish_dynamic_sections): Define.
+ (elf_backend_size_dynamic_sections): Define.
+ (elf_backend_plt_readonly): Define.
+ (elf_backend_want_got_plt): Define.
+ (elf_backend_want_plt_sym): Define.
+
+Wed Feb 17 12:02:26 1999 Stan Cox <scox@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_section_from_shdr): Make reginfo
+ sections SEC_LINK_ONCE and SEC_LINK_DUPLICATES_SAME_SIZE.
+ (_bfd_mips_elf_fake_sections): Likewise.
+
+Wed Feb 17 12:07:23 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
+
+ * elfarm-oabi.c (bfd_elf32_arm_allocate_interworking_sections,
+ bfd_elf32_arm_get_bfd_for_interworking,
+ bfd_elf32_arm_process_before_allocation): Define to avoid clash
+ with elfarm-nabi.c.
+
+ * elf32-arm.h: Don't declare elf32_arm_info_to_howto.
+ (elf32_thumb_to_arm_stub, elf32_arm_to_thumb_stub,
+ elf32_arm_find_nearest_line): Make them static.
+
+Tue Feb 16 22:44:37 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_merge_symbol): Add pflags parameter. Change all
+ callers. Do not merge a definition from a shared object with a
+ weak undefined symbol.
+ (elf_link_add_object_symbols): Do not change the symbol type or
+ size if the old symbol overrides the new one.
+
+1999-02-08 Nick Clifton <nickc@cygnus.com>
+
+ * config.bfd: Add support for strongarm target.
+
+Mon Feb 8 11:18:14 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
+
+ * elf32-m68k.c (reloc_map): Use the correct types for the struct
+ fields instead of unsigned char.
+
+Fri Feb 5 00:22:36 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: Rebuild dependencies.
+ * Makefile.in: Rebuild.
+
+Thu Feb 4 22:30:13 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Change AC_PREREQ to 2.13. Remove AM_CYGWIN32.
+ Change AM_EXEEXT to AC_EXEEXT and AM_PROG_INSTALL to
+ AC_PROG_INSTALL. Add comments to uses of AC_DEFINE.
+ * acinclude.m4: Add comments to uses of AC_DEFINE.
+ * acconfig.h: Remove.
+ * configure: Rebuild with current autoconf/automake.
+ * aclocal.m4: Likewise.
+ * config.in: Likewise.
+ * Makefile.in: Likewise.
+
+1999-02-04 DJ Delorie <dj@cygnus.com>
+
+ * libbfd.c (real_read): don't call fread for zero bytes. This
+ covers up a bug (or misuse of bfd) that's exposed by Solaris.
+
+Thu Feb 4 12:38:10 1999 Stan Cox <scox@cygnus.com>
+
+ * elf32-mips.c (mips_elf_relocate_section): Insure that the target
+ of a jump is in the current 256 MB region.
+
+Thu Feb 4 12:15:38 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * format.c (bfd_check_format_matches): Change last patch to only
+ take effect for the binary target.
+
+Wed Feb 3 19:40:12 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_reloc_type_lookup): Add BFD_RELOC_CTOR.
+
+Wed Feb 3 15:02:44 1999 Catherine Moore <clm@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_check_relocs): New routine.
+
+Tue Feb 2 21:38:28 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * format.c (bfd_check_format_matches): If the target was
+ previously specified, don't check other targets when checking for
+ an archive file.
+
+Tue Feb 2 18:16:43 1999 Catherine Moore <clm@cygnus.com>
+
+ * elf32-arm.h (elf32_arm_reloc_map): Removed.
+ (elf32_arm_reloc_type_lookup): Removed
+ * elfarm-nabi.c (elf32_arm_reloc_map): New.
+ (elf32_arm_reloc_type_lookup): New.
+ * elfarm-oabi.c (elf32_arm_reloc_map): New.
+ (elf32_arm_reloc_type_lookup): New.
+
+Mon Feb 1 19:49:21 1999 Catherine Moore <clm@cygnus.com>
+
+ * elfarm-nabi.c: Renamed from elf32-arm-newabi.c.
+ * elfarm-oabi.c: Renamed from elf32-arm-oldabi.c
+ * Makefile.am: Use new files.
+ * Makefile.in: Regenerate.
+ * configure.in: Use new files.
+ * configure: Regenerate.
+
+1999-02-01 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_gc_mark_hook): New function.
+ (fr30_elf_gc_sweep_hook): New function.
+ (elf_backend_can_gc_sections): Define.
+
+Mon Feb 1 12:21:47 1999 Catherine Moore <clm@cygnus.com>
+
+ * targets.c (bfd_target_vector): Add bfd_elf32_littlearm_oabi_vec
+ and bfd_elf32_bigarm_oabi_vec.
+
+Mon Feb 1 11:46:31 1999 Catherine Moore <clm@cygnus.com>
+
+ * Makefile.am (elf32-arm-oldabi.lo): New.
+ (elf32-arm-newabi.lo): New.
+ * Makefile.in: Regenerate.
+ * config.bfd (thumb-*-elf): Remove definition of targ_underscore.
+ (arm-*-elf): Likewise.
+ (arm-*-oabi): New.
+ (thumb-*-oabi): New.
+ * configure: Regenerate.
+ * configure.in (bfd_elf32_littlearm_oabi_vec): New.
+ (bfd_elf32_bigarm_oabi_vec): New.
+ * elf32-arm-newabi.c: New.
+ * elf32-arm-oldabi.c: New.
+ * elf32-arm.c: Removed.
+ * elf32-arm.h: New.
+
+Mon Feb 1 11:52:12 1999 Frank Ch. Eigler <fche@cygnus.com>
+
+ * binary.c (binary_set_section_contents): Omit warnings for
+ unloadable sections.
+
+1999-01-31 Michael Meissner <meissner@cygnus.com>
+
+ * config.bfd (powerpc{,le}-*-vxworks*): Add aliases to
+ powerpc{,le}-*-eabi.
+
+1999-01-29 Nick Clifton <nickc@cygnus.com>
+
+ * dwarf2.c (read_unsigned_leb128): Remove unused variables.
+ * dwarf2.c (read_signed_leb128): Remove unused variables.
+
+Fri Jan 29 00:47:21 1999 H.J. Lu <hjl@gnu.org>
+
+ * elf.c (assign_file_positions_for_segments): Only adjust
+ p_align when needed.
+
+Thu Jan 28 20:05:22 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * binary.c (binary_set_section_contents): Don't return early for a
+ non-loadable section, in case the first section is non-loadable.
+ Don't set the low lma for a SEC_NEVER_LOAD section. From Maciej
+ W. Rozycki <macro@ds2.pg.gda.pl>.
+
+1999-01-28 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_reloc_map): Add R_FR30_GNU_VTINHERIT and
+ R_FR30_GNU_VTENTRY relocs.
+
+Thu Jan 28 11:08:16 1999 Catherine Moore <clm@cygnus.com>
+
+ * elflink.h (elf_link_output_sym): Zero syms which are
+ part of sections which have been excluded.
+
+Wed Jan 27 13:35:35 1999 Stan Cox <scox@cygnus.com>
+
+ * coff-arm.c (_bfd_coff_arm_set_private_flags): Changed F_PIC
+ to F_PIC_INT.
+ * coffcode.h (coff_set_arch_mach_hook): Removed F_ARM_2a and
+ F_ARM_3M labels. Changed F_PIC to F_PIC_INT.
+
+1999-01-27 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_howto_table): Fix name of R_FR30_48
+ relocation.
+ (fr30_final_link_relocate): Use computed value as result of
+ relocation.
+
+1999-01-26 Frank Ch. Eigler <fche@cygnus.com>
+
+ * binary.c (binary_set_section_contents): Emit warning for
+ huge file offsets due to widely-dispersed section LMAs.
+
+Mon Jan 18 03:35:35 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): If not D_PAGED,
+ align first section to largest section alignment, not first
+ section alignment.
+
+1999-01-04 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * configure.in: Require autoconf 2.12.1 or higher.
+
+Tue Dec 22 15:21:41 1998 Catherine Moore <clm@cygnus.com>
+
+ * archures.c (bfd_mach_i386_i386_intel_syntax): Define.
+ * bfd-in2.h: Likewise.
+ * cpu-i386.c (bfd_i386_arch_intel_syntax): New.
+
+1998-12-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * archures.c,bfd-in2.h (bfd_mach_mips4111): New.
+ * cpu-mips.c: Add support for and independent 4111.
+ * elf32-mips.c (elf_mips_mach): E_MIPS_MACH_4111 -> bfd_mach_mips4111.
+ (_bfd_mips_elf_final_write_processing):
+ bfd_mach_mips4111 -> E_MIPS_ARCH_3 | E_MIPS_MACH_4111.
+
+1998-12-15 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (elf_mips_abi_name): New.
+ (_bfd_mips_elf_merge_private_bfd_data): Compare EF_MIPS_ABI flags.
+
+1998-12-12 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_final_write_processing):
+ Handle bfd_mach_mips4300.
+
+1998-12-11 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf32-i386.c: Remove leaked development code from patch
+ 1998-12-10 by Richard Henderson.
+
+1998-12-10 Richard Henderson <rth@cygnus.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): Don't fail relocations
+ in debug sections for symbol defined externally.
+
+Thu Dec 10 10:58:38 1998 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
+
+ * targets.c (bfd_target_vector): Remove duplicate entry for
+ tekhex_vec.
+
+1998-12-09 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_howto_table): Set src_mask fields to 0
+ since we are using RELAs.
+
+Tue Dec 8 22:15:48 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ SCO Open Server Release 5 core file support, from Jouke Numan
+ <jnuman@hiscom.nl>:
+ * sco5-core.c: New file.
+ * configure.in (i[3456]86-*-sco3.2v5*): Use sco5-core.lo.
+ (sco5-core.lo): Define SCO5_CORE in COREFLAG.
+ * Makefile.am: Rebuild dependencies.
+ (OPTIONAL_BACKENDS): Add sco5-core.lo.
+ (OPTIONAL_BACKENDS_CFILES): Add sco5-core.c.
+ * bfd.c (struct _bfd): Add sco5_core_data field to tdata.
+ * targets.c (sco5_core_vec): Add to target list if SCO5_CORE.
+ * bfd-in2.h, configure, Makefile.in: Rebuild.
+
+Tue Dec 8 19:38:42 1998 Mark Klein <mklein@dis.com>
+
+ * config.bfd (hppa*-*-mpeix*): New target.
+ * configure.in: Add AC_HEADER_DIRENT.
+ (hppa*-*-mpeix*): New target.
+ * configure.host (hppa*-*-mpeix*): New host.
+ * hpux-core.c: Check HOST_HPPAMPEIX. Use HAVE_DIRENT_H and
+ friends rather than just including <sys/dir.h>.
+ * som.h (struct som_symbol): Add hppa_priv_level and apto
+ tc_data. Change all users.
+ (struct somdata): Add comp_unit field.
+ (obj_som_compilation_unit): Define.
+ (bfd_som_attach_compilation_unix): Declare.
+ * som.c: Check HOST_HPPAMPEIX.
+ (struct som_misc_symbol_info): Add new field priv_level.
+ (som_object_setup): Add current_offset parameter. Change all
+ callers.
+ (setup_sections): Likewise.
+ (som_object_p): For EXECLIBMAGIC, read the lst header.
+ (som_write_symbol_strings): Add compilation_unit parameter.
+ Change all callers.
+ (som_finish_writing): Write out compilation_unit.
+ (som_bfd_derive_misc_symbol_info): Set priv_level.
+ (som_build_and_write_symbol_table): Set xleast field to 3.
+ (som_slurp_symbol_table): Set symbol priv_level.
+ (bfd_som_attach_compilation_unit): New function.
+ (som_bfd_ar_write_symbol_stuff): Set xleast field to 3. Set
+ priv_level into symbol_value.
+ * configure, config.in: Rebuild.
+
+Tue Dec 8 16:21:35 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * hpux-core.c (hpux_core_core_file_p): Change call to nonexistent
+ warning function to call _bfd_error_handler instead.
+
+ * libbfd.c (COERCE32): Cast through unsigned long and long to
+ avoid bug in old version of gcc.
+
+ * elf64-alpha.c (elf64_alpha_additional_program_headers): Remove.
+ (elf_backend_additional_program_headers): Don't define.
+
+1998-12-08 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_final_link_relocate): Fix PC relative
+ relocations to include offset of 2 included in the insns, and the
+ offset of the relocs within the section.
+
+Wed Dec 2 15:03:59 1998 David Taylor <taylor@texas.cygnus.com>
+
+ The following changes were made by David Taylor
+ <taylor@texas.cygnus.com>, Edith Epstein
+ <eepstein@sophia.cygnus.com>, Jim Blandy
+ <jimb@zwingli.cygnus.com>, and Elena Zannoni
+ <ezannoni@kwikemart.cygnus.com> as part of the project to merge in
+ changes originally made by HP; HP did not create ChangeLog
+ entries.
+
+ * aclocal.m4, configure, Makefile.in: Rebuilt using latest
+ automake macro library.
+
+ * hpux-core.c (hpux_core_core_file_p): this function now
+ understands HPUX 10.30 thread info. Yes, the thread stacks can be
+ found in the corefile! Also, in hpux_core_core_file_p, if we
+ encounter a section with an unknown type, don't punt. Instead,
+ just skip it. Also, count the number of sections of known type
+ that we encounter. If we encounter at least one good one, then
+ we'll declare that the file is a core file. If we encounter any
+ unknown ones but some known ones, then we'll issue a warning (but
+ still declare it to be a core file). Also, correctly decide when a
+ file is not a core.
+ (PROC_INFO_HAS_THREAD_ID): define if CORE_ANON_SHMEM defined.
+ (CORE_ANON_SHMEM): define if not defined.
+ (hpux_core_struct): add members lwpid and user_tid.
+ (core_kernel_thread_id, core_user_thread_id): new macros.
+ (make_bfd_asection): use bfd_alloc to allocate room for a copy of
+ the name before storing it in the bfd.
+ (hpux_core_core_file_p): handle threads.
+
+ * libhppa.h (GET_FIELD): protect against redefinition.
+ (HPPA_WIDE): define.
+ (GET_FIELD): define.
+ (GET_BIT): define.
+ (MASK): define.
+ (CATENATE): define.
+ (ELEVEN): define.
+ (sign_extend): redefine.
+ (assemble_6): define.
+ (assemble_12): rewrite.
+ (assemble_16): define.
+ (assemble_16a): define.
+ (assemble_17): rewrite.
+ (assemble_22): define.
+
+1998-12-07 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_final_link_relocate): Using signed
+ relocations for signed values.
+
+Sun Dec 6 16:30:33 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * mipsbsd.c (MY(set_arch_mach)): Make static.
+ * aoutx.h (NAME(aout,machine_type)): For bfd_arch_mips, use
+ bfd_mach_mips* macros rather than simple numbers.
+
+ COFF weak symbol support, based on patches from Mark Elbrecht
+ <snowball3@usa.net>:
+ * coffcode.h (coff_slurp_symbol_table): Handle C_WEAKEXT.
+ * coffgen.c (coff_renumber_symbols): Handle weak symbols.
+ (coff_write_alien_symbol): Likewise.
+ * cofflink.c (coff_link_check_ar_symbols): Likewise.
+ (coff_link_add_symbols): Likewise.
+ (_bfd_coff_link_input_bfd): Likewise.
+ (_bfd_coff_write_global_sym): Likewise.
+
+ * elf.c (copy_private_bfd_data): Always initialize the
+ includes_phdrs field.
+
+ * elflink.h (elf_fix_symbol_flags): Check for case where a non-ELF
+ file defines a symbol first mentioned in an ELF file.
+
+ * bfd-in.h: Always define BFD_HOST_64_BIT and BFD_HOST_U_64_BIT if
+ possible, rather than only if BFD64.
+ * elflink.h (compute_bucket_count): Just check BFD_HOST_U_64_BIT,
+ not __GNUC__.
+ * bfd-in2.h: Rebuild.
+
+ * srec.c (srec_set_section_contents): Correct test to avoid
+ switching to 4 byte addresses after seeing a second section which
+ requires 3 byte addresses. From Joel Schantz
+ <joel.schantz@argosys.boeing.com>.
+
+ * config.bfd (m68*-*-gnu*): New target. From Aymeric Vincent
+ <aymeric.vincent@emi.u-bordeaux.fr>.
+
+1998-12-04 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_merge_private_bfd_data): Fix logic to
+ decide whether the output file is -mrelocatable-lib,
+ -mrelocatable, or neither. (gdb.base/nodebug.exp)
+
+1998-12-03 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c: Add support for R_FR30_48 reloc.
+ * reloc.c: Add BFD_RELOC_FR30_48 relocation.
+ * bfd-in2.h: Regenerate.
+ * libbfd.h: Regenerate
+
+Wed Dec 2 00:58:37 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_adjust_dynamic_symbol): Warn on an attempt to
+ link against a dynamic symbol with no type or size.
+
+1998-12-01 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf32-i386.c (i386_check_relocs) [R_386_32]: Don't emit
+ relocation for section which does not get loaded.
+ (elf_i386_relocate_section) [R_386_32]: Likewise.
+
+Tue Dec 1 11:33:33 1998 Jim Wilson <wilson@cygnus.com>
+
+ * coff-h8300.c (h8300_bfd_link_add_symbols): Make reloc_size,
+ reloc_count and i long instead of unsigned long. Handle error
+ return from bfd_canonicalize_reloc.
+
+1998-12-01 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_relocate_section): Detect the absence of
+ a hash table.
+
+Mon Nov 30 15:28:09 1998 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * elf32-sh.c (elf/sh.h): Include.
+ sh_reloc_type: Delete. Changed all references to elf_sh_reloc_type.
+ (sh_elf_howto_tab): Add HOWTO for R_SH_SWITCH8.
+ (sh_reloc_map): Map BFD_RELOC_8_PCREL to R_SH_SWITCH8.
+ (sh_elf_relax_delete_bytes): Handle R_SH_SWITCH8.
+ * Makefile.in: Add dependency of elf32-sh.lo on $(INCDIR)/elf/sh.h.
+
+Fri Nov 27 17:51:38 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elflink.h (compute_bucket_count): Don't allow minsize==0, it
+ causes division by zero later on.
+
+Thu Nov 26 11:19:35 1998 Dave Brolley <brolley@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_pc9_reloc,fr30_elf_pc12_reloc): Not
+ needed.
+
+1998-11-25 DJ Delorie <dj@cygnus.com>
+
+ * coff-i386.c (i3coff_object_p): Remove hack. Use new emulation
+ hook now.
+
+Tue Nov 24 10:25:27 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_relocate_section): Call
+ fr30_final_link_relocate.
+ (fr30_final_link_relocate): New function: Handle I20 and I32
+ relocs.
+ (fr30_elf_i32_reloc): New function: Handle I32 relocs.
+ (fr30_elf_pc9_reloc): New function: Handle 9_PCREL relocs.
+ (fr30_elf_pc12_reloc): New function: Handle 12_PCREL relocs.
+
+ * elf32-v850.c (v850_elf_relocate_section): Reset hi16s reloc
+ chain to empty.
+
+ The following changes are based on a patch submitted by Gianluca
+ Moro <glctr@abc.it>:
+
+ (v850_elf_perform_relocation): Only update a hi16s reloc if it has
+ not already been updated.
+ (find_remembered_hi16s_reloc): New parameter 'already_found'
+ returns state of remembered hi16s reloc.
+ (remember_hi16s_reloc): Set 'found' field to false.
+ (hi16s_location): Add 'found' field.
+
+1998-11-23 DJ Delorie <dj@cygnus.com>
+
+ * coff-i386.c (bfd_pe_dll_not_recognized_hack): the linker wants
+ to see .DLL files as unrecognized.
+ (i3coff_object_p): Sorry, had to hack it to not recognize these
+ files (pei-i386) on request.
+
+1998-11-23 DJ Delorie <dj@cygnus.com>
+
+ * opncls.c (bfd_make_readable): need more cleanup for symbols and
+ relents. Call bfd_check_format to reinitialize.
+
+Fri Nov 20 14:21:36 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_elf_relocate_section): Remove spurious
+ warnings.
+
+Thu Nov 19 14:42:15 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * aclocal.m4: regenerate
+ * configure: regenerate
+
+Tue Nov 17 20:23:35 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf-bfd.h (struct elf_link_hash_entry): Add vtable_entries_size.
+ * elf.c (_bfd_elf_link_hash_newfunc): Clear it.
+ * elflink.h (elf_gc_propagate_vtable_entries_used): Copy it, and
+ respect it as an upper bound on what memory to reference.
+ (elf_gc_smash_unused_vtentry_relocs): Likewise.
+ (elf_gc_record_vtentry): Handle as-yet undefined vtables. Set and
+ update vtable_entries_size appropriately.
+
+Tue Nov 17 15:28:31 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-fr30.c (fr30_reloc_type_lookup): Used integers to hold
+ reloc number.
+
+Mon Nov 16 22:19:21 1998 DJ Delorie <dj@cygnus.com>
+
+ * archive.c (bfd_ar_hdr_from_filesystem): support BFD_IN_MEMORY
+ bfds; they have no "file" so we fake it.
+ * bfd-in2.h: add bfd_make_writable and bfd_make_readable (regen)
+ * libbfd.c (bfd_write): Allow writing to BFD_IN_MEMORY bfds by
+ resizing the memory buffer.
+ * opncls.c (bfd_make_writable): New function; lets you write a
+ bfd_create'd bfd to an in-memory buffer.
+ (bfd_make_readable): New function; lets you read back that buffer
+ as if it were from bfd_openr. Used to build generated archive
+ members (winsup's ld's dlltool)
+
+Mon Nov 16 19:15:19 1998 Dave Brolley <brolley@cygnus.com>
+
+ * po/bfd.pot: Regenerated.
+
+Mon Nov 16 10:57:06 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (hi16s_location): Replaced fixed size array with
+ linked list.
+
+Sun Nov 15 20:28:25 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_relax_section): Search for the proper
+ element of the gotentry list for local symbols too.
+ (elf64_alpha_relocate_section): Unify local and global handling.
+ Assert that gotent->use_count > 0.
+
+Sat Nov 14 15:16:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in (vms_alpha_vec): Rename from evax_alpha_vec, and
+ update for file name changes of July 2, 1998.
+ (vms_vax_vec): New.
+ * configure: Rebuild.
+
+Thu Nov 12 19:19:54 1998 Dave Brolley <brolley@cygnus.com>
+
+ * po/bfd.pot: Regenerated.
+
+Tue Nov 10 16:17:06 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * acinclude.m4, config.bfd: detect cygwin* instead of cygwin32*.
+ * aclocal.m4, configure: regenerate
+
+Tue Nov 10 15:13:59 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (prep_headers): Add support for bfd_arch_fr30.
+
+Tue Nov 10 13:37:36 1998 Felix Lee <flee@cygnus.com>
+
+ * acinclude.m4 (BFD_HAVE_SYS_PROCFS_TYPE,
+ BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): didn't define macro when value
+ was cached.
+ * aclocal.m4, configure: regenerated.
+
+Tue Nov 10 14:31:01 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-d10v.c (reloc_type): Add R_D10V_GNU_VTINHERIT and
+ R_D10V_GNU_VTENTRY relocs.
+ (elf_d10v_howto_table): Likewise.
+ (d10v_reloc_map d10v_reloc_map): Likewise.
+ (elf32_d10v_gc_mark_hook): New.
+ (elf32_d10v_gc_sweep_hook): New.
+ (elf32_d10v_check_relocs): New.
+ (elf32_d10v_relocate_section): New.
+ (elf_backend_relocate_section): Define.
+ (elf_backend_can_gc_sections): Define.
+
+Sat Nov 7 18:07:51 1998 Peter Schauer <peter.schauer@regent.e-technik.tu-muenchen.de>
+
+ * Makefile.am (BFD32_BACKENDS): Move vms files here...
+ (BFD64_BACKENDS): ...from here.
+ (BFD32_BACKENDS_CFILES): Move vms files here...
+ (BFD64_BACKENDS_CFILES): ...from here.
+ * Makefile.in: Rebuild.
+
+Wed Nov 4 15:58:48 1998 Nick Clifton <nickc@cygnus.com>
+
+ * Makefile.am: Add FR30 target.
+ * Makefile.in: Add FR30 target.
+ * archures.c: Add support for FR30.
+ * config.bfd: Add support for FR30.
+ * configure.in: Add support for FR30.
+ * reloc.c: Add support for FR30 relocations.
+ * targets.c: Add support for FR30 relocations.
+ * bfd-in2.h: Regenerate.
+ * configure: Regenerate.
+ * libbfd.h: Regenerate.
+ * cpu-fr30.c: New file.
+ * elf32-fr30.c: New file.
+
+Mon Nov 2 14:59:33 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: detect cygwin* instead of cygwin32*
+ * configure: regenerate
+
+Sun Nov 1 19:32:28 1998 Jeffrey A Law (law@cygnus.com)
+
+ * elf-m10300.c (mn10300_elf_relax_section): Do not use alloca,
+ use bfd_malloc and free instead and check return value from bfd_malloc.
+
+Sun Nov 1 16:20:35 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd-in.h (_bfd_dwarf1_find_nearest_line): Declare.
+ * libbfd.h: Rebuild.
+
+ * elf32-mips.c (mips_elf_dynsym_sec_names): Comment out.
+ (SIZEOF_MIPS_DYNSYM_SECNAMES): Likewise.
+ (MIPS_TEXT_DYNSYM_SECN): Likewise.
+ (_bfd_mips_elf_fake_sections): Don't set sh_info field of a .hash
+ section.
+ (struct mips_elf_link_hash_table): Remove dynsym_sec_strindex
+ field.
+ (mips_elf_link_hash_table_create): Don't initialize
+ dynsym_sec_strindex.
+ (mips_elf_gc_mark_hook): Add default case to avoid warning.
+ (mips_elf_size_dynamic_sections): Generate a section symbol for
+ every output section.
+ (mips_elf_finish_dynamic_sections): Count all sections for
+ DT_MIPS_UNREFEXTNO.
+ (mips_elf_finish_dynamic_sections): Use dynamic symbols for all
+ output sections.
+
+Sun Nov 1 12:46:53 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Allocate two slots
+ for later PLT entries in large PLTs.
+ (ppc_elf_finish_dynamic_symbol): Allow for the extra slots.
+
+Sat Oct 31 20:10:09 1998 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-ppc.c (ppc_elf_reload_section): Fix typo.
+
+1998-10-26 15:58 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf-bfd.h (struct elf_link_hash_entry): Add new field elf_hash_value.
+ * elflink.h (elf_collect_hash_codes): New function. This function is
+ called for each exported symbol and we compute the ELF hash value for
+ it.
+ (compute_bucket_value): New function. It is called from
+ size_dynamic_sections to determine the hash table size. When we are
+ optimizing a better, but slower, algorithm is used.
+ (size_dynamic_sections): Call compute_bucket_value.
+
+ * elf.c (bfd_elf_hash): Optimize the hash function a bit.
+
+Mon Oct 19 20:03:21 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-sh.c: Add HOWTO entries for R_SH_GNU_VTINHERIT and
+ R_SH_GNU_VTENTRY.
+ (sh_elf_gc_mark_hook): New.
+ (sh_elf_gc_sweep_hook): New.
+ (sh_elf_check_relocs): New.
+ (elf_backend_can_gc_sections): Define.
+
+Mon Oct 19 16:57:05 1998 Felix Lee <flee@cygnus.com>
+
+ * acinclude.m4: undo previous gettext change
+ * aclocal.m4: rebuild with right version of aclocal.
+
+Mon Oct 19 01:47:21 1998 Felix Lee <flee@cygnus.com>
+
+ * acinclude.m4, aclocal.m4: move gettext-related fragments from
+ aclocal.m4 to acinclude.m4, so they don't get lost.
+
+ * elfcore.h: rewrite for better corefile support.
+ * elf.c (elfcore_*): new functions.
+ * elf-bfd.h (elf_obj_tdata): new structure members.
+ * acconfig.h, acinclude.m4, configure.in: add feature-tests for
+ flavor of procfs.
+ * aclocal.m4, config.in, configure, Makefile.in: regenerated.
+
+Fri Oct 16 14:07:45 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-m32r.c: Add HOWTO entries for R_M32R_GNU_VTINHERIT
+ and R_M32R_GNU_VTENTRY.
+ (elf_backend_can_gc_sections): Define.
+ (m32r_elf_check_relocs): New.
+ (m32r_elf_gc_mark_hook): New.
+ (m32r_elf_gc_sweep_hook): New.
+ (m32r_elf_relocate_section): Handle VT relocs.
+
+Mon Oct 12 14:18:40 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (arm_relocate_section): Remove redundant test.
+
+ * bfd-in2.h (struct reloc_howto_struct): Improve comment to make
+ cleat that the 'bitsize' field is the size of the bitfield AFTER
+ relocation not before.
+
+ * elf32-m32r.c (R_M32R_18_PCREL): Fix size of bitfield.
+
+ * coff-mips.c (mips_relocate_hi): Cope with missing refhi or reflo
+ relocs.
+
+Tue Oct 6 09:20:44 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-sparc.c: Add HOWTO entries for R_SPARC_GNU_VTINHERIT and
+ R_SPARC_GNU_VTENTRY.
+ (elf32_sparc_check_relocs): Handle them.
+ (elf32_sparc_reloc_type_lookup): Likewise.
+ (elf32_sparc_relocate_section): Likewise.
+ (elf32_sparc_gc_mark_hook): New.
+ (elf32_sparc_gc_sweep_hook): New.
+
+Mon Oct 5 14:55:30 1998 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_finish_writing): Perform some sanity checks when
+ writing an executable or shared library.
+
+Mon Oct 5 12:02:31 1998 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * dwarf1.c : New file. Adds _bfd_dwarf1_find_nearest_line.
+ * configure.in (elf): Add dwarf1.lo.
+ * elf_bfd.h (elf_ob_tdata): Add dwarf1_find_line_info.
+ * elf.c (_bfd_elf_find_nearest_line): Add call to
+ _bfd_dwarf1_find_nearest_line.
+ * elf32-mips.c (_bfd_mips_elf_find_nearest_line):
+ Add call to _bfd_dwarf1_find_nearest_line.
+ * configure: Rebuilt.
+
+Mon Oct 5 10:06:22 1998 Catherine Moore <clm@cygnus.com>
+
+ * elflink.h (elf_gc_sections): Do not allow garbage
+ collection if dynamic sections have been created.
+
+Mon Oct 5 09:07:37 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-v850.c: Add HOWTO entries for R_V850_GNU_VTINHERIT and
+ R_V850_GNU_VTENTRY.
+ (v850_elf_check_relocs): Handle VTINHERIT and VTENTRY relocs.
+ (v850_elf_perform_relocation): Likewise.
+ (v850_elf_final_link_relocate): Likewise.
+ (v850_elf_relocate_section): Likewise.
+ (v850_elf_gc_sweep_hook): New routine.
+ (v850_elf_gc_mark_hook): New routine.
+ (elf_backend_can_gc_sections): Define.
+
+Mon Oct 5 09:04:25 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-m68k.c (elf_m68k_gc_sweep_hook): Don't assume
+ that dynobj exists.
+
+Sun Oct 4 23:29:34 1998 David Edelsohn <edelsohn@mhpcc.edu>
+
+ * rs6000-core.c (rs6000coff_core_file_matches_executable_p):
+ Declare size as bfd_size_type.
+ (rs6000coff_get_section_contents): Declare count as bfd_size_type.
+
+Sun Oct 4 20:38:29 1998 Jeffrey A Law (law@cygnus.com)
+
+ * cpu-hppa.c (bfd_hppa20_arch): Define. Link it into the bfd_hppa_arch
+ structure.
+ * som.c (CPU_PA_RISC2_0): Define.
+ (_PA_RISC2_0_ID): Likewise.
+ (som_finish_writing): Use CPU_PA_RISC2_0 for the system_id as needed.
+
+Sun Oct 4 21:19:09 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): When a versioned symbol
+ has a base which is already defined, only add the referenced
+ symbol to the dynamic symbol table if it is defined or referenced
+ by a regular file.
+
+ * elf32-i386.c (elf_i386_info_to_howto_rel): Handle vtable relocs
+ correctly.
+
+1998-09-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elflink.h (elf_link_add_object_symbols): Undo last change.
+
+Wed Sep 23 16:09:31 1998 Richard Henderson <rth@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Don't record a dynamic
+ symbol for the indirect alias to a versioned symbol.
+
+Mon Sep 21 12:15:22 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-i386.c (elf32_i386_vtinherit_howto): New.
+ (elf32_i386_vtentry_howto): New.
+ (elf_i386_reloc_type_lookup): Return elf32_i386_vtentry_howto
+ or elf32_i386_vtinherit_howto on lookup.
+
+Sun Sep 20 00:48:07 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c: Include "elf/m68k.h". Remove definition of enum
+ reloc_type. Rename R_68K__max to R_68K_max.
+ (howto_table): Use _bfd_elf_rel_vtable_reloc_fn for a VTENTRY
+ reloc.
+
+Sun Sep 20 00:09:25 1998 Chris Torek <torek@bsdi.com>
+
+ * libbfd.c (bfd_getb32): Rewrite expression to get better code.
+ (bfd_getl32, bfd_getb_signed_32, bfd_getl_signed_32): Likewise.
+
+ * libbfd.c (bfd_log2): Cast to bfd_vma before shifting, not
+ after.
+
+Sat Sep 19 22:42:23 1998 Doug Rabson <dfr@nlsystems.com>
+
+ * elflink.h (elf_link_add_object_symbols): Ensure that the warning
+ message has a null byte terminator.
+
+Fri Sep 18 14:35:29 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_perform_relocation): Ignore contents of
+ word subject to R_V850_32 relocation.
+
+Thu Sep 17 17:20:36 1998 Nick Clifton <nickc@cygnus.com>
+
+ * dwarf2.c: Add comment describing problem computing line numbers
+ for undefined symbols at link time.
+
+Thu Sep 17 16:03:28 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Don't
+ transform a defweak into a plt entry.
+ (elf64_alpha_calc_dynrel_sizes): Allow room for secondary
+ plt entry references to receive a RELATIVE reloc.
+ (elf64_alpha_finish_dynamic_symbol): Fill them in.
+ (elf64_alpha_relocate_section): Assert we don't overrun
+ the allocated relocation space.
+
+Wed Sep 16 18:03:13 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (swap_out_syms): Always treat section symbols as
+ special, even if they are attached to a common section.
+
+Wed Sep 16 10:34:13 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_symbol_processing): Move symbols in
+ sections with v850 common section attributes into named v850
+ common sections.
+ (v850_elf_add_symbol_hook): Move symbols in sections with v850
+ common section attributes into named v850 common sections.
+
+Wed Sep 16 11:26:49 CDT 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-arm.c (elf32_arm_gc_mark_hook): Remove print
+ statement.
+
+1998-09-15 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Reverse output_offset
+ part of Vladimir's change of 1998-08-19. Make a R_PPC_SDAREL16
+ reloc to the wrong section a warning, not an error. .dynsbss
+ is not an output section, so there is no need to check for it.
+
+Tue Sep 15 12:40:05 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf-bfd.h: Add argument to elf_backend_get_symbol_type.
+
+Tue Sep 15 08:34:40 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf.c (swap_out_syms): Pass type to elf_backend_get_symbol_type.
+ * elf32-arm.c: Add HOWTO entries for R_ARM_GNU_VTINHERIT and
+ R_ARM_GNU_VTENTRY.
+ (elf32_arm_gc_mark_hook): New.
+ (elf32_arm_gc_sweep_hook): New.
+ (elf32_arm_check_relocs): New.
+ (elf32_arm_final_link_relocate): Handle VTINHERIT and VTENTRY
+ relocations.
+ (elf32_arm_relocate_section): Handle VTINHERIT and VTENTRY
+ relocations.
+
+1998-09-10 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): If dynobj is NULL,
+ assume there is no PLT or GOT.
+
+Wed Sep 9 14:24:12 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-arm.c (elf32_arm_find_nearest_line): New function: just
+ like _elf_bfd_find_nearest_line() except that STT_ARM_TFUNC is
+ also accepted as a function symbol type.
+
+Mon Sep 7 13:24:03 1998 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
+
+ * rs6000-core.c (_LONG_LONG): Define for AIX 4.x only.
+
+Sat Sep 5 20:40:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd-in.h (_bfd_nolink_bfd_gc_sections): Correct definition to
+ match definition of _bfd_gc_sections field.
+ * libbfd.h: Rebuild.
+
+Fri Sep 4 13:54:23 1998 David Miller <davem@dm.cobaltmicro.com>
+
+ * elf32-sparc.c (elf32_sparc_relocate_section): Properly adjust
+ the addend of a dynamic relocation referencing a section.
+ * elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+ (sparc64_elf_finish_dynamic_symbol): Fix the PLT relocation offset.
+
+Thu Sep 3 17:28:50 1998 Richard Henderson <rth@cygnus.com>
+
+ * elflink.h (bfd_elfNN_size_dynamic_sections): Verify that the
+ bed has a size_dynamic_sections routine before trying to use it.
+
+Mon Aug 31 14:49:22 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf32-mips.c (elf_mips_gnu_vtentry_howto): Use
+ _bfd_elf_rel_vtable_reloc_fn.
+
+Mon Aug 31 10:23:40 1998 Catherine Moore <clm@cygnus.com>
+
+ * Makefile.am: Add elf32-arm.c.
+ * Makefile.in: Rebuild.
+ * elf-bfd.h: Add elf_backend_get_symbol_type.
+ * elf.c (swap_out_syms): If defined, call
+ elf_backend_get_symbol_type.
+ * elf32-arm.c: Define elf_backend_get_symbol_type.
+ (elf32_arm_get_symbol-type): New routine.
+ (record_thumb_to_arm_glue): Change to use STT_ARM_TFUNC.
+ (bfd_elf32_arm_process_before_allocation): Change to
+ check for STT_ARM_TFUNC.
+ (elf32_arm_final_link_relocate): Likewise.
+ * elfxx-target.h: Add elf_backend_get_symbol_type.
+
+Fri Aug 28 19:44:07 1998 Richard Henderson <rth@cygnus.com>
+
+ * archures.c (bfd_mach_alpha_ev[456]): New.
+ * cpu-alpha.c: Rework to match these types.
+ * bfd-in2.h: Rebuild.
+
+Fri Aug 28 19:38:53 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf-bfd.h (_bfd_elf_rel_vtable_reloc_fn): Declare.
+ * elf.c (_bfd_elf_rel_vtable_reloc_fn): New.
+
+ * elf32-i386.c (elf_howto_table): Add vtable relocs.
+ (elf_i386_reloc_type_lookup): Recognize them.
+ (elf_i386_check_relocs): Pass them off to generic code.
+ (elf_i386_relocate_section): Ignore them.
+ (elf_i386_gc_mark_hook, elf_i386_gc_sweep_hook): New.
+ (elf_backend_can_gc_sections): True.
+
+Thu Aug 20 15:03:45 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-arm.c (elf32_thumb_to_arm_stub): Check sym_sec is not NULL
+ before looking at owner field.
+ (elf32_arm_to_thumb_stub): Ditto.
+ (elf32_arm_relocate_section): Compute name before calling
+ elf32_arm_final_link_relocate().
+
+Thu Aug 20 11:30:17 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * elf.c: comment and formatting cleanups.
+ * elfcore.h: ditto.
+
+Wed Aug 19 15:43:26 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * elfcode.h (elf_object_p): Reject files of header type ET_CORE
+ (core files are treated differently than object files).
+ * elf-bfd.h (_bfd_elf_write_corefile_contents,
+ bfd_elf_mkcorefile): declare.
+ * elfxx-target.h (_bfd_elf_write_corefile_contents,
+ bfd_elf_mkcorefile): add to bfd_target vector.
+ * elfcore.h (elf_core_file_p): save the program header table,
+ and set the bfd architecture from the elf file header.
+ * elf.c (bfd_elf_mkcorefile): new function.
+ (_bfd_elf_write_corefile_contents): new function.
+ (assign_file_positions_for_segments): add cases for handling
+ PT_NOTE segments. (assign_file_positions_except_relocs):
+ core files should be handled the same as exec files.
+ (prep_headers): identify core files as type ET_CORE.
+ (copy_private_bfd_data): identify the sections belonging to
+ the PT_NOTE segment.
+
+ * elf32-sparc.c (elf32_sparc_final_write_processing):
+ add break statement to default case.
+
+1998-08-19 Vladimir N. Makarov <vmakarov@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Check that output
+ section (not input) will be in sections ".sbss", ".sbss2",
+ ".sdata", and ".sdata" for R_PPC_SDAREL16, R_PPC_EMB_SDA2REL,
+ R_PPC_EMB_SDA21, R_PPC_EMB_RELSDA. In all these cases also ignore
+ output_offset for correct evaluation of addend.
+
+Tue Aug 18 11:48:12 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-arm.c: Add prefix bfd_ to elf32_arm_get_bfd_for_interworking,
+ elf32_arm_allocate_interworking_sections and
+ elf32_arm_process_before_allocation.
+
+Tue Aug 18 11:46:00 1998 Nick Clifton <nickc@cygnus.com>
+
+ * bfd-in.h: Ammend prototype for
+ elf32_arm_process_before_allocation to remove surplus third
+ argument.
+
+ * bfd-in2.h: Regenerate.
+
+Sat Aug 15 20:55:08 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_relax_section): Handle indirect symbols.
+
+Fri Aug 14 09:12:28 1998 Stan Cox <scox@cygnus.com>
+
+ * aoutx.h (aout_link_input_section_ext): Use the relocation already
+ calculated for RELOC_SPARC_REV32 case.
+
+Thu Aug 13 14:02:02 1998 Catherine Moore <clm@cygnus.com>
+
+ * bfd-in.h: Add prototypes for elf32_arm_get_bfd_for_interworking,
+ elf32_arm_allocate_interworking_sections and
+ elf32_arm_process_before_allocation.
+ * bfd-in2.h: Regenerated.
+ * elf32-arm.c Define elf32_arm_link_hash_table.
+ (insert_thumb_branch): New routine.
+ (find_thumb_glue): New routine.
+ (find_arm_glue): New routine.
+ (record_arm_to_thumb_glue): New routine.
+ (record_thumb_to_arm_glue): New routine.
+ (elf32_arm_link_hash_table_create): New routine.
+ (elf32_arm_get_bfd_for_interworking): New routine.
+ (elf32_arm_allocate_interworking_sections) New routine.
+ (elf32_arm_process_before_allocation) New routine.
+ (elf32_thumb_to_arm_stub): New routine.
+ (elf32_arm_to_thumb_stub): New routine.
+ (elf32_print_private_bfd_data): Fix typo.
+ (elf32_arm_final_link_relocate): Add argument sym_sec.
+ Check for branches to thumb symbols in case R_ARM_PC24.
+ Check for branches to arm symbols in case R_ARM_THM_PC22.
+ (elf32_arm_relocate_section): Pass symbol section to
+ elf32_arm_final_link_relocate.
+
+Wed Aug 12 19:00:39 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Generate PLT
+ entries unless the symbol is defined in the executable; in
+ particular, undefined weak symbols get a PLT entry.
+
+Wed Aug 12 14:48:33 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * libaout.h: Remove nested comment to avoid warning.
+
+Wed Aug 12 08:10:11 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-arm.c (elf32_arm_final_link_relocate): Rework
+ R_ARM_PC24 relocation.
+
+Tue Aug 11 14:42:26 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-arm.c (elf32_arm_final_link_relocate): Remove unused
+ argument is_local. Add argument sym_flags. Check sym_flags
+ in R_ARM_ABS32 case. Include addend for R_ARM_THM_PC22 case.
+ (elf32_arm_relocate_section): Don't pass local sym and pass
+ sym_flags to elf32_arm_final_link_relocate.
+
+Mon Aug 10 20:38:39 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_calc_dynrel_sizes): Correct last change
+ to not count too few relocs for dynamicly linked executables.
+
+Mon Aug 10 15:35:34 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Never consider
+ symbols without a dynamic index dynamic. Consider all weak
+ symbols dynamic.
+ (elf64_alpha_strip_section_from_output): Don't assume 1-1
+ correspondance between input and output sections.
+
+Mon Aug 10 15:31:39 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elflink.h (elf_gc_common_finalize_got_offsets): For backends
+ that use a .got.plt section start the got offset at zero.
+
+Mon Aug 10 17:31:21 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_write_processor): Correct the processor ID written
+ out for bfd_arch_m68k, accommodating change of March 25.
+
+Sun Aug 9 20:55:44 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-arm.c (elf32_arm_final_link_relocate): Rework
+ R_ARM_THM_RPC22 relocations.
+
+Sat Aug 8 15:15:30 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Undef weak symbols
+ are always dynamic.
+ (elf64_alpha_calc_dynrel_sizes): Allow enough room for RELATIVE
+ .got relocs in -Bsymbolic shared objects.
+
+Wed Aug 5 15:48:08 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-arm.c: Add private flags to ELF header.
+ (elf32_arm_print_private_bfd_data): New Function.
+ (elf32_arm_set_private_flags): New Function.
+ (elf32_arm_copy_private_flags): New Function.
+ (elf32_arm_merge_private_bfd_data): New Function.
+
+Mon Aug 3 17:10:15 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_check_relocs): Permit WPLT30 against
+ a local symbol.
+ (elf32_sparc_relocate_section): Likewise.
+
+Sun Aug 2 03:19:23 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Init sgot to NULL. Create the
+ .got if any relocation referrs to _GLOBAL_OFFSET_TABLE_.
+ (ppc_elf_relocate_section): Pull sgot and splt search to the start
+ of the function. Recognize no .plt as static linking.
+
+1998-08-01 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf32-mips.c (_bfd_mips_elf_section_from_shdr): Don't pass
+ ".liblist" string through gettext.
+
+Fri Jul 31 16:38:14 1998 Catherine Moore <clm@cygnus.com>
+
+ * Makefile.am: Add support for elf32-arm.lo.
+ * Makefile.in: Rebuild.
+ * config.bfd (arm-*-elf): Define targ_defvec and targ_selvecs.
+ (thumb-*-elf): Define targ_defvec and targ_selvecs.
+ * configure.in: Handle bfd_elf32_littlearm_vec and bfd_elf32_bigarm_vec.
+ * configure: Regenerate.
+ * elf.c: (prep_headers): Support arch_type of EM_ARM.
+ * targets.c: Support new targets bfd_elf32_bigarm_vec and
+ bfd_target bfd_elf32_littlearm_vec.
+ * elf32-arm.c: New file.
+
+Tue Jun 28 19:05:28 1998 Stan Cox <scox@cygnus.com>
+
+ * libaout.h (M_SPARCLITE_LE): New machine.
+ * sunos.c (MACHTYPE_OK): Add machine M_SPARCLITE_LE.
+ * aoutf1.h (sunos_set_arch_mach): Add machine M_SPARCLITE_LE.
+ (sunos_write_object_contents): Add machine bfd_mach_sparc_sparclite_le
+ * aoutx.h (howto_table_ext): Add relocation R_SPARC_REV32.
+ (NAME(aout,machine_type)) Add machine bfd_mach_sparc_sparclite_le
+ (aout_link_input_section_ext): Add RELOC_SPARC_REV32 support.
+ * elf32-sparc.c (_bfd_sparc_elf_howto_table, sparc_reloc_map,
+ elf32_sparc_relocate_section): Rename R_SPARC_32LE to be R_SPARC_REV32
+ * libbfd.h (bfd_reloc_code_real_names): Rename BFD_RELOC_SPARC_32LE to
+ be BFD_RELOC_SPARC_REV32.
+ * reloc.c: Ditto.
+ * config.bfd (sparc86x-*-aout): New
+
+Fri Jul 24 13:54:19 1998 Nick Clifton <nickc@cygnus.com>
+
+ * linker.c (_bfd_generic_final_link): Allocate NULL symbol before
+ actually mapping the output sections.
+
+Fri Jul 24 11:24:29 1998 Jeffrey A Law (law@cygnus.com)
+
+
+ * elf-m10300.c (mn10300_elf_howto): Add R_MN10300_24 entry.
+ (mn10300_elf_reloc_map): Similarly.
+ (mn10300_elf_final_link_relocate): Handle R_MN10300_24.
+
+Fri Jul 24 12:36:04 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (elf_mips_howto_table): Add reloc types used on
+ Irix 6.
+ (bfd_elf32_bfd_reloc_type_lookup): Add default case.
+ * elf64-mips.c: Replace all uses of mips_elf64_reloc_type with
+ elf_mips_reloc_type defined in elf/mips.h.
+
+1998-07-24 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf64-mips.c: Remove reloc_type definition completely. It's now
+ in elf/mips.h.
+
+Thu Jul 23 13:33:19 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * elf64-mips.c (mips_elf64_reloc_type): #if 0 out more relocations
+ as they are defined in elf/mips.h now.
+
+Thu Jul 23 11:29:43 1998 Jeffrey A Law (law@cygnus.com)
+
+
+ * Re-add lost change:
+ * elf-m10300.c (elf32_mn10300_link_hash_entry): Add new field
+ "movm_stack_size".
+ (mn10300_elf_relax_section): Include stack space for register saves
+ in the imm8 field of a "call" instruction.
+ (compute_function_info): Determine how much stack is allocated by
+ the movm instruction. Fix typo.
+ (elf32_mn10300_link_hash_newfunc): Initialize movm_stack_size.
+
+Thu Jul 23 11:38:05 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf_backend_got_header_size): Define as 4.
+ * elf64-sparc.c (elf_backend_got_header_size): Define as 8.
+
+1998-07-22 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf32-ppc.c: Change use of pp_reloc_type to elf_ppc_reloc_type.
+
+Wed Jul 22 16:27:18 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-hppa.h: Let ELF header define the enum containing the
+ external reloc numbers.
+ * elf32-i386.h: Likewise.
+
+1998-07-22 14:57 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf-m10300.c: Let ELF header now define the macros to get the enum.
+ * elf32-mips.c: Likewise.
+ * elf32-ppc.c: Likewise.
+
+Wed Jul 22 13:53:52 1998 Nick Clifton <nickc@cygnus.com>
+
+ * bfd-in2.h: Change type of 'class' parameter to 'unsigned int' in
+ bfd_coff_set_symbol_class(), in order to avoid K&R compatability
+ prblems.
+ * bfd-in.h: Regenerate.
+ * coffgen.c (bfd_coff_set_symbol_class): Change type of 'class'
+ parameter to 'unsigned int' to avoid K&R compatability problems.
+
+Wed Jul 22 16:43:24 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_find_nearest_line): Change filename_ptr and
+ functionname_ptr to be const. Change line_ptr to be unsigned.
+
+ * coffcode.h (coff_link_output_has_begun): Simplify handling when
+ macro is not defined. Change second parameter from bfd_link_info
+ to coff_final_link_info. Add prototype.
+ (coff_final_link_postscript): Simplify handling when macro is not
+ defined. Add prototype.
+
+1998-07-22 13:08 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf-mn10300.c: Before include system specific ELF header define
+ START_RELOC_NUMBERS, RELOC_NUMBER, and END_RELOC_NUMBERS.
+ * elf32-mips.c: Likewise.
+ * elf32-ppc.c: Likewise.
+
+Wed Jul 22 13:46:51 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf64-mips.c (mips_elf64_reloc_type): Copy Ulrich's elf32-mips.c
+ temporary patch over to elf64-mips.c as well.
+
+1998-07-21 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf32-mips.c (reloc_type): Temporarily disable definition of
+ standard relocation since they are now defined in elf/mips.h.
+
+Tue Jul 21 09:47:00 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf-m10200.c (mn10200_elf_final_link_relocate):
+ Modify range test for case R_MN10200_8.
+
+ * elf-m10300.c (mn10300_elf_final_link_relocate):
+ Modify range test for case R_MN10300_8.
+
+Mon Jul 20 18:50:54 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf-bfd.h (struct elf_backend_data): Add got_ & plt_header_size.
+ * elf32-i386.c (elf_backend_got_header_size): Define.
+ (elf_backend_plt_header_size): Define.
+ * elf32-m68k.c, elf32-mips.c, elf32-ppc.c: Likewise.
+ * elf32-sparc.c, elf64-alpha.c, elf64-sparc.c: Likewise.
+ * elfxx-target.h: Provide a default of zero.
+ * elflink.c (_bfd_elf_create_got_section): Use got_header_size.
+ * elflink.h (elf_gc_common_finalize_got_offsets): Likewise.
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't remove a PLT
+ entry from an executable, even if the plt refcount goes to 0.
+
+Mon Jul 20 12:47:26 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Also remember the
+ directory name at the line number.
+
+ * elf.c (_bfd_elf_find_nearest_line): Also consider symbols
+ with an unspecified type.
+
+Wed Jul 15 11:20:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c: Add undef of valid to avoid problem on SunOS.
+
+Tue Jul 14 15:30:59 1998 Richard Henderson <rth@cygnus.com>
+
+ * config.bfd (i?86-pc-beos{pe,elf,}*): Recognize.
+
+Tue Jul 14 11:22:21 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c (elf_m68k_check_relocs): Also reference count
+ R_68K_PCxx and R_68K_xx relocations. Make sure that
+ ELF_LINK_HASH_NEEDS_PLT is always set for a PLT reloc reference.
+ (elf_m68k_gc_sweep_hook): Also reference count R_68K_PCxx and
+ R_68K_xx relocations.
+ (elf_m68k_adjust_dynamic_symbol): Reset the plt offset of a symbol
+ that has no plt entry.
+ (elf_m68k_relocate_section): Ignore the plt offset in a static
+ link.
+ * elflink.h (elf_adjust_dynamic_symbol): Reset the plt offset for
+ an ignored symbol.
+ (elf_gc_common_finalize_got_offsets): Set the got offsets also in
+ a static link.
+
+ * elf32-m68k.c (R_68K_GNU_VTINHERIT, R_68K_GNU_VTENTRY): New reloc
+ types.
+ (howto_table, reloc_map): Add entries for them.
+ (elf_m68k_check_relocs): Handle them. Implement reference
+ counting for got and plt entries.
+ (elf_m68k_gc_mark_hook, elf_m68k_gc_sweep_hook): New functions.
+ (elf_m68k_adjust_dynamic_symbol): Handle unreferenced plt
+ symbols.
+ (rtype_to_howto_rel, elf_info_to_howto_rel): Delete.
+ (elf_m68k_relocate_section): Handle the new reloc types.
+ (bfd_elf32_bfd_final_link, elf_backend_gc_mark_hook,
+ elf_backend_gc_sweep_hook, elf_backend_can_gc_sections): Define.
+ * elflink.h (elf_link_add_object_symbols): When creating an
+ indirect reference for symbol versioning also copy the plt
+ offset.
+ (elf_fix_symbol_flags): When clearing the ELF_LINK_HASH_NEEDS_PLT
+ flag also reset the plt offset.
+ (elf_link_assign_sym_version): Likewise.
+ (elf_gc_common_finalize_got_offsets): Increment the got offset by
+ the size of the entry in bytes.
+ (elf_gc_allocate_got_offsets): Likewise.
+
+Tue Jul 14 11:18:14 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_gc_sections): Return true rather than falling off
+ the bottom.
+
+ * coffgen.c (bfd_coff_set_symbol_class): Call bfd_alloc, not
+ xmalloc.
+
+Mon Jul 13 11:06:31 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c: Supress definition of TARGET_UNDERSCORE and add a
+ comment describing when it should be enabled.
+ Changed definition of USER_LABEL_PREFIX to "", to fall into line
+ with GCC sources.
+
+Mon Jul 13 13:06:54 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_slurp_external_symbols): Handle call optimization
+ information ATN records.
+
+Fri Jul 10 16:31:06 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_slurp_external_symbols): Select an appropriate
+ section for an absolute symbol in a fully linked file. Based on
+ patch from Christian Holland <CHolland@de.lucent.com>.
+
+Wed Jul 8 11:29:56 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * coff-m88k.c (m88k_special_reloc): Don't lose the information
+ that a symbol is undefined.
+
+Tue Jul 7 21:47:02 1998 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_bfd_gc_sections): Define.
+
+Mon Jul 6 11:35:50 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (aoutarm_std_reloc_howto): Do not complain about
+ overflows in ARM_26D patches, since they have already been
+ implmented. Patch submitted by Dr. R.J. Black <rjb@dcs.gla.ac.uk>
+
+Sat Jul 4 12:25:36 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): If we have any long
+ section names, call coff_write_symbols even if there are no
+ symbols.
+
+Fri Jul 3 13:11:35 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (copy_private_bfd_data): Only set phdr_included once for a
+ PT_LOAD segment, rather than only setting it once for the entire
+ file.
+
+ * elf.c (_bfd_elf_make_section_from_shdr): When setting the LMA,
+ rather than ignoring every phdr with a p_paddr of 0, ignore all
+ the phdrs if they all have a p_paddr of 0.
+
+ * stabs.c (_bfd_write_stab_strings): Check whether the .stabstr
+ section was discarded from the link.
+
+Fri Jul 3 14:39:05 1998 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * coff-sh.c (sh_insn_uses_freg): Ignore lowest bit of register number.
+
+Fri Jul 3 14:35:48 1998 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * coff-sh.c (sh_insns_conflict): Load of fpscr conflicts with
+ floating point operations.
+
+Thu Jul 2 18:37:25 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_link_input_bfd): Skip undefined global
+ function symbols.
+
+Thu Jul 2 14:59:42 1998 Klaus Kaempf <kkaempf@rmi.de>
+
+ Merge of vax/vms (read-only) support
+ * configure.com: Support Vax target.
+ * makefile.vms: Support Vax target.
+ * vms.h: Renamed from evax.h, merged vax/vms (read-only) support.
+ * vms.c: Renamed from evax-alpha.c, merged vax/vms (read-only)
+ support.
+ * vms-hdr.c: Renamed from evax-emh.c, merged vax/vms (read-only)
+ support.
+ * vms-gsd.c: Renamed from evax-egsd.c, merged vax/vms (read-only)
+ support.
+ * vms-tir.c: Renamed from evax-etir.c, merged vax/vms (read-only)
+ support.
+ * vms-misc.c: Renamed from evax-misc.c, merged vax/vms (read-only)
+ support.
+ * libbfd.c (real_read): Use unbuffered read on VMS/Vax.
+ * targets.c (bfd_target_ovax_flavour): New flavour.
+ (vms_alpha_vec): Renamed from evax_alpha_vec.
+ (vms_vax_vec): New.
+ (target_vector): Update accordingly.
+ * config.bfd (alpha*-*-*vms*): Use vms_alpha_vec, not
+ evax_alpha_vec.
+ (vax*-*-*vms*): New target.
+ * Makefile.am: Update for renamed files. Rebuild dependencies.
+ * bfd-in2.h: Rebuild.
+ * configure.in, Makefile.in, aclocal.m4: Rebuild.
+
+Thu Jul 2 13:31:55 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ Based on patch from Matt Semersky <matts@scd.hp.com>:
+ * linker.c (_bfd_generic_final_link): Force a trailing NULL
+ pointer on abfd->outsymbols.
+ (generic_add_output_symbol): Handle NULL sym parameter.
+
+Wed Jul 1 17:05:53 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (copy_private_bfd_data): Add support for changing VMA or
+ LMA of sections.
+
+Wed Jul 1 16:58:50 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (sh_relax_delete_bytes): Correct address comparisons
+ when handling 32 bit immediate relocs.
+ * elf32-sh.c (sh_elf_relax_delete_bytes): Likewise.
+
+Tue Jun 30 09:55:03 1998 Jeffrey A Law (law@cygnus.com)
+
+ * section.c (STD_SECTION): Account for recently added gc_mark
+ field in struct asection.
+
+ * elf-m10300.c (bfd_mn10300_elf_merge_private_bfd_data): New function.
+ (bfd_elf32_bfd_merge_private_bfd_data): Define.
+
+Thu Jun 25 18:31:41 1998 Richard Henderson <rth@cygnus.com>
+
+ ELF Section-level Garbage Collection:
+ * bfd.c (bfd_gc_sections): New.
+ * aout-adobe.c: Hook to default implementation.
+ * aout-target.h, aout-tic30.c, binary.c, bout.c: Likewise.
+ * coff-alpha.c, coff-mips.c, coff-rs6000.c, coffcode.h: Likewise.
+ * evax-alpha.c, i386msdos.c, i386os9k.c, ieee.c: Likewise.
+ * ihex.c, nlm-target.h, oasys.c, ppcboot.c, srec.c: Likewise.
+ * tekhex.c, versados.c: Likewise.
+ * libbfd-in.h (_bfd_nolink_bfd_gc_sections): New.
+ * targets.c (BFD_JUMP_TABLE_LINK): Add _bfd_gc_sections.
+
+ * reloc.c (BFD_RELOC_VTABLE_INHERIT, BFD_RELOC_VTABLE_ENTRY): New.
+ (bfd_generic_gc_sections): New.
+ * section.c (SEC_KEEP): New.
+ (asection): Add gc_mark member.
+
+ * elfcode.h (elf_gc*): New name remappings.
+ * elflink.h (elf_link_input_bfd): Don't set contents on stabs
+ sections to be excluded.
+ (elf_gc_mark, elf_gc_sweep, elf_gc_sweep_symbol): New.
+ (elf_gc_propogate_vtable_entries_used): New.
+ (elf_gc_smash_unused_vtentry_relocs): New.
+ (elf_gc_sections, elf_gc_record_vtinherit, elf_gc_record_vtentry): New.
+ (elf_gc_common_finalize_got_offsets): New.
+ (elf_gc_allocate_got_offsets, elf_gc_common_final_link): New.
+ * elfxx-target.h: Add and default gc hooks.
+
+ * elf-bfd.h (struct elf_link_hash_entry): Swap got_offset/plt_offset
+ for unions.
+ (struct elf_obj_tdata): Likewise for local_got_offsets.
+ * elf.c, elf-i386.c, elf32-m68k.c, elf32-mips.c: Update all uses.
+ * elf32-ppc.c, elf32-sparc.c, elf64-alpha.c: Likewise.
+ * elf64-sparc.c, elflink.h: Likewise.
+
+ * elf-bfd.h (struct elf_link_hash_entry): Add vtable members.
+ (ELF_LINK_HASH_MARK): Define.
+ (struct elf_backend_data): Add GC hooks.
+ * elf.c (_bfd_elf_link_hash_newfunc): Zero vtable members.
+
+ * elf-m10300.c (mn10300_elf_check_relocs): New.
+ (mn10300_elf_gc_mark_hook): New.
+ (R_MN10300_GNU_VTINHERIT, R_MN10300_GNU_VTENTRY): New.
+ (elf_mn10300_howto, mn10300_reloc_map): Handle them.
+ (mn10300_elf_final_link_relocate): Likewise.
+ (mn10300_elf_relocate_section): Likewise.
+ (elf_backend_can_gc_sections): Define.
+ * elf32-mips.c (R_MIPS_GNU_VTINHERIT, R_MIPS_GNU_VTENTRY): New.
+ (elf_mips_gnu_vtinherit_howto, elf_mips_gnu_vtentry_howto): New.
+ (bfd_elf32_bfd_reloc_type_lookup): Handle them.
+ (mips_info_to_howto_rel): Likewise.
+ (mips_elf_relocate_section): Likewise.
+ (mips_elf_check_relocs): Likewise.
+ (mips_elf_gc_mark_hook, mips_elf_gc_sweep_hook): New.
+ (elf_backend_can_gc_sections): Define.
+ * elf32-ppc.c (R_PPC_GNU_VTINHERIT, R_PPC_GNU_VTENTRY): New.
+ (ppc_elf_howto_raw): Handle them.
+ (ppc_elf_reloc_type_lookup): Likewise.
+ (ppc_elf_relocate_section): Likewise.
+ (ppc_elf_check_relocs): Reference count .got and .plt entires.
+ Handle new vtable relocs.
+ (ppc_elf_adjust_dynamic_symbol): Recognize unused .plt entries.
+ (ppc_elf_gc_mark_hook, ppc_elf_gc_sweep_hook): New.
+ (elf_backend_can_gc_sections): Define.
+
+Fri Jun 26 10:48:23 1998 Jeffrey A Law (law@cygnus.com)
+
+ * archures.c (bfd_mach_mn10300): Define.
+ * elf-m10300.c: Include elf/mn10300.h
+ (elf_mn10300_mach): New function.
+ (_bfd_mn10300_elf_final_write_processing): Likewise.
+ (_bfd_mn10300_elf_object_p): Likewise.
+ (elf_backendfinal_write_processing): Define.
+ (elf_backend_object_p): Likewise.
+
+Thu Jun 25 18:31:08 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_perform_relocation): Fix HI16_S
+ relocation.
+
+Wed Jun 24 17:17:57 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_bfd_final_link): Loop over input_bfds using the
+ link_next field, not the next field.
+
+Sun Jun 21 19:38:39 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (map_sections_to_segments): Check the section address
+ against the phdr size both with and without a modulo of
+ maxpagesize.
+
+Fri Jun 19 17:08:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_size_dynamic_sections): Only strip a
+ linker created empty input section if the output section has the
+ same name.
+
+ * elflink.h (elf_link_output_extsym): Print an error message if
+ _bfd_elf_section_from_bfd_section fails.
+
+ * elf.c (_bfd_elf_section_from_bfd_section): Call bfd_set_error on
+ failure.
+
+Tue Jun 16 11:55:55 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (copy_private_bfd_data): Improve handling of Solaris
+ native linker output. Avoid putting an empty section in more than
+ one segment.
+
+Fri Jun 12 13:30:17 1998 Tom Tromey <tromey@cygnus.com>
+
+ * po/Make-in (all-yes): If maintainer mode, depend on .pot file.
+ ($(PACKAGE).pot): Unconditionally depend on POTFILES.
+
+Fri Jun 12 13:34:02 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * elf.c (swap_out_syms): New arg relocatable_p.
+ Don't add section VMA to symbols for relocatable output.
+ (_bfd_elf_compute_section_file_positions): Update call to
+ swap_out_syms.
+
+Mon Jun 8 15:20:57 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_perform_relocation): Make comparisons
+ against 'addend' be signed rather than unsigned.
+
+Sat Jun 6 00:31:21 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-m32r.c: Add prototyps for static functions.
+
+ * coff-arm.c: Add prototypes for static functions.
+
+Fri Jun 5 17:21:51 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (elf_sort_sections): Sort by LMA first then VMA, since the
+ LMA is used to order sections in a segment.
+
+ * elf32-v850.c: Add prototypes for static functions.
+ Change type of addend parameter to bfd_vma in various functions.
+
+Fri Jun 5 18:09:58 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (howto_table_ext): Change RELOC_BASE13 to use
+ complain_overflow_signed instead of complain_overflow_bitfield.
+
+Fri Jun 5 15:11:11 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf.c (elf_map_symbols): Don't add section VMA to symbol value
+ when comparing against 0.
+
+Wed Jun 3 17:52:49 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (config.status): New target.
+ * Makefile.in: Rebuild.
+
+Wed Jun 3 12:18:24 1998 Stan Cox <scox@equinox.cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Give an
+ error if previous object endianness doesn't match current object.
+
+Tue Jun 2 17:50:59 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_print_private_bfd_data): Call
+ _bfd_elf_print_private)bfd_data ().
+
+Tue Jun 2 15:29:35 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_merge_symbol): Don't always set type_change_ok
+ and size_change_ok.
+ (elf_link_add_object_symbols): Set type_change_ok and
+ size_change_ok before calling elf_merge_symbol.
+
+ * elf32-mips.c (mips_elf_relocate_section): If we issue an
+ undefined symbol error, don't also issue an overflow error.
+
+Tue Jun 2 13:51:00 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): The target of an
+ R_PPC_LOCAL24PC relocation should be local; if not, print an error
+ message instead of crashing.
+
+Mon Jun 1 18:23:12 1998 Yuli Barcohen <yuli.barcohen@telrad.co.il>
+
+ * archures.c (bfd_mach_cpu32): Define.
+ (bfd_default_scan): Add case for 68060. Fix 68332 case to use
+ bfd_mach_cpu32.
+ * cpu-m68k.c (arch_info_struct): Add m68k:cpu32.
+ * ieee.c: Include <ctype.h>.
+ (ieee_object_p): Parse out process ID string to make it more
+ likely to be acceptable for bfd_scan_arch.
+ * bfd-in2.h: Rebuild.
+
+Mon Jun 1 11:12:02 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-m32r.c (m32r_elf_print_private_bfd_data): Also call
+ _bfd_elf_print_private_bfd_data() so that the program header will
+ be displayed.
+
+Mon Jun 1 12:14:28 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (coff_swap_sym_in): Check for C_SECTION rather than
+ 0x68. Reindent. Add some comments.
+
+Fri May 29 09:58:08 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (copy_private_bfd_data): Adjust physical address of
+ segment in output BFD to contain LMAs of its sections.
+
+Tue May 26 19:37:47 1998 Stan Cox <scox@equinox.cygnus.com>
+
+ * elf32-sparc.c (_bfd_sparc_elf_howto_table, sparc_reloc_map,
+ elf32_sparc_relocate_section): Added R_SPARC_32LE for little
+ endian data 32 bit relocations.
+ (elf32_sparc_merge_private_bfd_data): Check if linking little
+ endian objects with big endian objects.
+ (elf32_sparc_object_p): Set bfd_mach_sparc_sparclite_le.
+ (elf32_sparc_final_write_processing): Set EF_SPARC_LEDATA in e_flags.
+ * libbfd.h (bfd_reloc_code_real_names): Added BFD_RELOC_SPARC_32LE.
+ * reloc.c: Same.
+ * cpu-sparc.c (arch_info_struct): Added sparc:sparclite_le
+ * archures.c (bfd_mach_sparc_sparclite_le): New.
+ * bfd-in2.h (BFD_RELOC_SPARC_32LE, bfd_mach_sparc_sparclite_le): New.
+
+Thu May 21 16:59:28 1998 Nick Clifton <nickc@cygnus.com>
+
+ * peicode.h (add_data_entry): Fix precedence of operators in if ()
+ statement.
+
+Tue May 19 18:41:19 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd-in.h: Move over patch to bfd-in2.h.
+
+ * reloc.c (bfd_check_overflow): Add casts before shifts which may
+ not fit in 32 bits.
+ (_bfd_relocate_contents): Likewise.
+
+Mon May 18 14:44:15 1998 Nick Clifton <nickc@cygnus.com>
+
+ * peicode.h (add_data_entry): If the section has no private data
+ then do not create a Data Dictionary entry for it.
+
+Mon May 18 00:09:28 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_relax_section): Set again on changes.
+ (elf64_alpha_can_merge_gots, elf64_alpha_merge_gots,
+ elf64_alpha_size_got_sections): Rewrite, handling multiple got
+ subsections during relaxation more correctly.
+
+Thu May 14 14:22:58 1998 Nick Clifton <nickc@cygnus.com>
+
+ * bfd-in2.h: Add new prototype: bfd_coff_set_symbol_class ().
+ Add extra argument to bfd_arm_process_before_allocation ().
+ * bfd-in.h: Reflect changes made in bfd-in2.h.
+ * coffgen.c (bfd_coff_set_symbol_class): New function. Set the
+ coff class of a BFD symbol.
+ * coff-arm.c: Add support for interworking between Thumb code and
+ non-interworking aware ARM code.
+
+Sun May 10 22:33:59 1998 Jeffrey A Law (law@cygnus.com)
+
+ * po/Make-in (install-info): New target.
+
+Thu May 7 17:40:56 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * filemode.c: Remove; not used.
+
+ If sysdep.h includes a header file, don't include it again:
+ * aix386-core.c: Don't include <stdio.h>, <stddef.h>, or
+ <errno.h>.
+ * aoutx.h: Don't include <string.h>. Use "sysdep.h" rather than
+ <sysdep.h>.
+ * archive.c: Don't include <string.h> or <errno.h>.
+ * evax-alpha.c; Don't include <stdio.h>.
+ * evax-egsd.c: Likewise.
+ * evax-etir.c: Likewise.
+ * evax-misc.c: Likewise.
+ * evax-emh.c: Likewise. Also, don't include <sys/types.h>.
+ * hppabsd-core.c: Don't include <stdio.h>, <sys/types.h>, or
+ <errno.h>.
+ * hpux-core.c: Likewise.
+ * netbsd-core.c: Likewise.
+ * som.c: Likewise.
+ * libbfd.c: Don't include <sys/types.h>.
+ * nlmcode.h: Don't include <string.h>.
+ * osf-core.c: Don't include <string.h> or <stdio.h>.
+ * ptrace-core.c: Don't include <stdio.h>, <sys/types.h>,
+ <errno.h>, or <unistd.h>.
+ * trad-core.c: Don't include <stdio.h> or <sys/types.h>.
+
+Thu May 7 13:12:50 1998 Klaus Kaempf <kkaempf@progis.de>
+
+ * configure.com: If the version number can not be found in
+ configure.in, set it to "unknown" rather than "2.8.1".
+
+Wed May 6 09:46:05 1998 Gavin Koch <gavin@cygnus.com>
+
+ * elf32-mips.c (elf_mips_mach): New.
+ (_bfd_mips_elf_object_p): Use elf_mips_mach.
+ (_bfd_mips_elf_final_write_processing): Use the names
+ of machines, rather than the numbers. Set both the ARCH
+ and MACH in e_flags. Handle a few more specific machines.
+ (_bfd_mips_elf_merge_private_bfd_data): Merge both
+ EF_MIPS_ARCH and EF_MIPS_MACH.
+
+Tue May 5 21:01:53 1998 Richard Henderson <rth@cygnus.com>
+
+ * syms.c (bfd_is_local_label): Revert last change.
+ * srec.c (srec_write_symbols): Discard debugging symbols.
+
+Tue May 5 23:36:06 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * som.c: Include <ctype.h>.
+ * som.h: Don't include sysdep.h.
+
+Tue May 5 18:29:24 1998 Tom Tromey <tromey@cygnus.com>
+
+ * libbfd.h: Rebuilt.
+ * libbfd-in.h: Removed gettext includes and defines.
+ * sysdep.h: Moved gettext-related includes and defines here.
+
+Tue May 5 16:47:54 1998 Richard Henderson <rth@cygnus.com>
+
+ * srec.c (srec_write_symbols): Use bfd_is_local_label rather than
+ an ad-hoc test. Kill bogus #if 0 code.
+ * syms.c (bfd_is_local_label): Consider BSF_DEBUGGING symbols local.
+
+Mon May 4 16:10:33 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_check_dynamic_reloc): Don't use the PLT address
+ when generating a normal executable for a symbol defined in a
+ regular file. When copying a reloc into the output file, adjust
+ the addend for a PC relative reloc against a global symbol.
+
+Mon May 4 10:08:18 1998 Tom Tromey <tromey@cygnus.com>
+
+ * libbfd.h: Rebuilt.
+ * libbfd-in.h (_): Define as dgettext.
+
+Mon May 4 11:02:23 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-arm.c (coff_arm_relocate_section): Cast to bfd_signed_vma,
+ not signed.
+ * peicode.h (pe_saved_coff_bfd_print_private_bfd_data): Use PARAMS
+ when declaring parameter types.
+ (pe_saved_coff_bfd_copy_private_bfd_data): Likewise.
+
+Wed Apr 29 15:35:03 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.bfd: If we include any ELF targets in targ_defvec and/or
+ targ_selvecs, then add the generic ELF targets to targ_selvecs.
+ * elf32-gen.c (dummy): New static const variable.
+ (elf_generic_info_to_howto): New static function.
+ (elf_generic_info_to_howto_rel): New static function.
+ (elf_info_to_howto): Define as elf_generic_info_to_howto.
+ (elf_info_to_howto_rel): Define as elf_generic_info_to_howto_rel.
+ * elf64-gen.c: Same changes as elf32-gen.c.
+ * elfcode.h (elf_object_p): For the generic target, ignore a
+ failure of bfd_default_set_arch_mach. Fix indentation a bit.
+
+Tue Apr 28 20:05:52 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in (WIN32LIBADD): Add -lintl on cygwin32.
+ * configure: Rebuild.
+
+Tue Apr 28 12:16:57 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * config.bfd: Update OSR5/Unixware patterns.
+
+Mon Apr 27 18:02:24 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): Allow for holes
+ between sections added by a link script.
+
+Mon Apr 27 11:49:55 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Change version number to 2.9.4
+ * configure: Rebuild.
+
+ Based on patch from H.J. Lu <hjl@gnu.org>:
+ * elf.c (bfd_elf_get_bfd_needed_list): New function.
+ * bfd-in.h (bfd_elf_get_bfd_needed_list): Declare.
+ * bfd-in2.h: Rebuild.
+
+Sat Apr 25 20:07:53 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (struct alpha_relax_info): Replace elfsym with other.
+ Change all users.
+
+Sat Apr 25 18:29:07 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (struct alpha_relax_info): Add tsec & elfsym members.
+ (elf64_alpha_relax_section): Fill them in.
+ (elf64_alpha_relax_opt_call): Implement more than a stub.
+ (elf64_alpha_add_symbol_hook): Don't set SEC_LOAD or default
+ alignment on .scommon.
+ (elf64_alpha_merge_gots): Merge use counts as well.
+
+Sat Apr 25 14:07:29 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_relax_section): Use the proper section
+ for calculating a local symbol's address.
+ (elf64_alpha_calc_got_offsets): Skip entries with 0 use count.
+ Set the .got's cooked size as well as the raw size.
+
+Fri Apr 24 09:16:00 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_print_private_bfd_data): Add
+ internationalisation of printed information.
+
+ * coff-arm.c (coff_arm_print_private_bfd_data): Add
+ internationalisation of printed information.
+
+Fri Apr 24 12:09:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * syms.c (struct indexentry): Change directory_name, file_name,
+ and function_name fields to char *.
+ (struct stab_find_info): Change cached_file_name field to char *.
+
+Thu Apr 23 08:13:04 1998 Nick Clifton <nickc@cygnus.com>
+
+ * peicode.h (dir_names): Add missing N_() macros to dir_names array.
+
+Wed Apr 22 13:06:15 1998 Tom Tromey <tromey@cygnus.com>
+
+ * po/Make-in (MKINSTALLDIRS): Don't look in $(top_srcdir).
+
+Wed Apr 22 17:48:48 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (install-data-local): Make $(includedir).
+ * Makefile.in: Rebuild.
+
+Wed Apr 22 13:06:15 1998 Tom Tromey <tromey@cygnus.com>
+
+ * libbfd-in.h: Use `gettext' and not `dgettext' for now.
+
+Wed Apr 22 12:53:40 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (INCLUDES): Add -I$(srcdir)/../intl -I../intl.
+ * Makefile.in: Rebuild.
+
+ * bfd-in2.h: Rebuild for Nick's changes.
+
+Tue Apr 21 23:11:51 1998 Richard Henderson <rth@cygnus.com>
+
+ * archive.c (_bfd_generic_read_ar_hdr_mag): Fix lossage in last
+ change wrt length == max_namelen.
+
+Tue Apr 21 21:19:36 1998 Tom Tromey <tromey@scribbles.cygnus.com>
+
+ * Many files: Added gettext invocations around user-visible
+ strings.
+ * libbfd-in.h: Added gettext includes and defines.
+ * acconfig.h (ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_STPCPY,
+ HAVE_LC_MESSAGES): Define.
+ * configure.in: Call CY_GNU_GETTEXT. Create po/Makefile.in and
+ po/Makefile.
+ * Makefile.am (SUBDIRS): Added po.
+ (POTFILES): New macro.
+ (po/POTFILES.in): New target.
+ (SOURCE_HFILES): New macro.
+ (HFILES): Use it.
+ * po/Make-in, po/POTFILES.in, po/bfd.pot: New files.
+
+Tue Apr 21 13:38:18 1998 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * elfcore.h (bfd_prstatus): Copy core_prstatus from the first
+ NT_PRSTATUS note section encountered, it contains the status of
+ the currently executing thread when the core file was written.
+
+Tue Apr 21 10:00:12 1998 Nick Clifton <nickc@cygnus.com>
+
+ * libcoff.h: Add extra parameter to
+ bfd_coff_link_output_has_begun overrideable function.
+ * cofflink.c: Pass extra parameter to
+ bfd_coff_link_output_has_begun function.
+ * bfd-in.h: Add prototypes for exported ARM interworking
+ functions.
+ * peicode.h: ARM specific code reorganised to conform to BFD
+ coding conventions.
+ * coffcode.h: ARM specific code reorganised to conform to BFD
+ coding conventions.
+ * coff-arm.c: Code reorganised to conform to the BFD coding
+ conventions. Global variables have been moved into an ARM
+ specific hash table structure and a new function:
+ bfd_arm_get_bfd_for_interworking() has been created which is
+ called from the linker scripts.
+
+Tue Apr 21 00:11:51 1998 Richard Henderson <rth@cygnus.com>
+
+ * archive.c (_bfd_generic_read_ar_hdr_mag): Simplify end-of-name test.
+
+ * elf64-alpha.c (elf64_alpha_find_reloc_at_ofs): Renamed from
+ elf64_alpha_relax_find_reloc_ofs. Changed all callers.
+ (elf64_alpha_add_symbol_hook): Put small commons in .scommon not .sbss.
+ (elf64_alpha_size_got_sections): Don't merge .got sections twice.
+
+Sat Apr 18 01:21:04 1998 Stan Cox <scox@cygnus.com>
+
+ * config.bfd: Added sparc86x support.
+
+Fri Apr 17 22:29:04 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_relocate_section): Do not complain about
+ an out of range pc-relative jump/call to an undefined weak symbol.
+
+Thu Apr 16 13:49:00 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_do_reloc_gpdisp): Do all gpdisp
+ comparisons signed.
+
+Thu Apr 16 11:43:33 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * archive.c (bfd_generic_archive_p): If a slurp subroutine returns
+ an error other than bfd_error_system_call, set the error to
+ bfd_error_wrong_format.
+
+ * targets.c (bfd_target_vector) [SELECT_VECS not defined]: Add
+ bfd_elf32_powerpcle_vec.
+
+ * elf.c (copy_private_bfd_data): If all the p_paddr fields in the
+ program segments are zero, don't set p_paddr_valid.
+
+Wed Apr 15 22:15:16 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c: Initial implementation of relaxation --
+ (struct alpha_elf_link_hash_entry): Add use_count member.
+ (elf64_alpha_check_relocs): Initialize and increment it.
+ (elf64_alpha_can_merge_gots): Check it when considering merging.
+ (elf64_alpha_merge_gots): Drop entries with zero use.
+ (elf64_alpha_calc_got_offsets_for_symbol): Likewise.
+ (elf64_alpha_always_size_sections): Split out got sizing ...
+ (elf64_alpha_size_got_sections): ... here. New function.
+ (elf64_alpha_relax_find_reloc_ofs): New function.
+ (elf64_alpha_relax_with_lituse): Likewise.
+ (elf64_alpha_relax_without_lituse): Likewise.
+ (elf64_alpha_relax_opt_call): Likewise.
+ (elf64_alpha_relax_section): Likewise.
+ (elf64_alpha_add_symbol_hook): Likewise.
+ (elf64_alpha_howto_table): Implement GPRELHIGH/LOW & IMMED_GP_16.
+ (elf64_alpha_relocate_section): Likewise.
+ (bfd_elf64_bfd_relax_section): Define.
+ (elf_backend_add_symbol_hook): Likewise.
+
+Wed Apr 15 16:08:46 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf.c (prep_headers): Use new EM_SPARCV9 symbol.
+ * elf64-sparc.c (ELF_MACHINE_CODE): Likewise.
+ (ELF_MACHINE_ALT1): New. Set to EM_OLD_SPARC64.
+
+Wed Apr 15 11:34:33 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Add -lkernel32 to WIN32LIBADD on cygwin32.
+ * configure: Rebuild.
+
+Mon Apr 13 16:46:27 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (libbfd_la_LIBADD): Add @WIN32LIBADD@.
+ (libbfd_la_LDFLAGS): Add @WIN32LDFLAGS@.
+ * configure.in: Define and substitute WIN32LDFLAGS and
+ WIN32LIBADD.
+ * aclocal.m4: Rebuild with new libtool.
+ * configure, Makefile.in: Rebuild.
+
+Fri Apr 10 13:44:27 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): Move a PE COMDAT symbol
+ before any other symbols in the same section.
+
+Wed Apr 8 14:50:23 1998 Michael Meissner <meissner@cygnus.com>
+
+ * config.bfd (powerpc*-*-*): Remove PowerPC NT support from ELF
+ systems.
+
+Tue Apr 7 16:25:31 1998 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * dwarf2.c (comp_unit): Move it earlier in the source. Add
+ addr_size.
+ (read_address): Replace 'bdf*' argument with 'comp_unit*' argument.
+ Use addr_size for address size, rather than sizeof(bfd_vma).
+ (read_attribute): Replace bdf* argument with 'comp_unit*' argument.
+ Fix call to read_address.
+ (decode_line_info): Replace bdf* argument with 'comp_unit*' argument.
+ Scrap other unneeded arguments. Fix call to read_address.
+ (scan_unit_for_functions): Fix call to read_attribute.
+ (parse_comp_unit): We now handle more values for addr_size.
+ Set addr_size in unit. Fix call to read_attribute and
+ decode_line_info.
+
+Tue Apr 7 15:44:47 1998 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * dwarf2.c (parse_comp_unit): Drop use of unit->name when it is null.
+
+Tue Apr 7 12:35:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * archures.c (bfd_default_scan): Add m68k cases back to default
+ switch, reverting patch of March 25, since IEEE support depends
+ upon them.
+
+Mon Apr 6 14:06:40 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (diststuff): New target.
+ * Makefile.in: Rebuild.
+
+Sun Apr 5 16:21:44 1998 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_bfd_ar_write_symbol_stuff): Fix computation of
+ som_offset when we have an extended name table.
+
+Sun Apr 5 16:04:39 1998 H.J. Lu <hjl@gnu.org>
+
+ * Makefile.am (stamp-lib): Check that .libs/libbfd.a exists before
+ trying to copy it.
+ * Makefile.in: Rebuild.
+
+Fri Apr 3 11:09:42 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c (elf_m68k_size_dynamic_sections): Generate section
+ symbols when creating a shared library.
+ (elf_m68k_adjust_dynindx): New function, used by above code.
+ (elf_m68k_finish_dynamic_sections): Initialize the section
+ symbols.
+ (elf_m68k_relocate_section): Change abort to BFD_ASSERT.
+
+Wed Apr 1 16:04:02 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (in_reloc_p): Use ARM_RVA32 in place of constant
+ value 11.
+
+Wed Apr 1 13:36:58 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c (elf_m68k_relocate_section, case R_68K_PLT*O): Fix
+ assertion.
+
+Tue Mar 31 00:12:12 1998 Jeffrey A Law (law@cygnus.com)
+
+ * elf-m10300.c (mn10300_elf_relax_section): Correctly handle
+ absolute symbols.
+
+Mon Mar 30 12:46:15 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set version to 2.9.1.
+ * configure: Rebuild.
+
+ * Branched binutils 2.9.
+
+Mon Mar 30 12:20:50 1998 Brent Baccala <baccala@freesoft.org>
+
+ * syms.c (ENABLE_CACHING): Define.
+ (struct indexentry): Define.
+ (struct stab_cache): Remove.
+ (cmpindexentry): New static function.
+ (struct stab_find_info): Add new fields: indextable,
+ indextablesize, cached_indexentry, cached_offset, cached_stab, and
+ cached_file_name. Remove fields: file_cache, function_cache, and
+ line_cache.
+ (_bfd_stab_section_find_nearest_line): Rewrite to build a sorted
+ index table and search it.
+
+Mon Mar 30 10:39:34 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (_bfd_elf_copy_private_section_data): Call
+ copy_private_bfd_data once we've seen the last SEC_ALLOC section.
+
+ * cpu-mips.c: Remove trailing comma at end of enumeration list.
+
+Sat Mar 28 16:33:02 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-arm.c: Define all globally visible variables and functions
+ only when COFF_WITH_PE is not defined.
+ * configure.in (armpe_little_vec, armpe_big_vec): Add
+ coff-arm.lo.
+ * configure: Rebuild.
+
+Fri Mar 27 16:06:02 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ Fix some gcc -Wall warnings:
+ * aout-arm.c (MY(fix_pcrel_26)): Add casts to avoid warnings.
+ * archive.c (_bfd_generic_read_ar_hdr_mag): Likewise.
+ * archures.c (bfd_default_scan): Likewise.
+ * bfd.c (bfd_scan_vma): Likewise.
+ * binary.c (mangle_name): Likewise
+ * coff-arm.c (aoutarm_fix_pcrel_26): Likewise.
+ * coff-sh.c (sh_relocate_section): Likewise.
+ * coff-stgo32.c (create_go32_stub): Likewise.
+ * coffcode.h (coff_slurp_line_table): Likewise.
+ * ecoff.c (_bfd_ecoff_write_armap): Likewise.
+ * elf.c (_bfd_elf_make_section_from_shdr): Likewise.
+ (assign_file_positions_for_segments): Likewise.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
+ * oasys.c (oasys_write_sections): Likewise.
+ * ppcboot.c (ppcboot_object_p): Likewise.
+ (mangle_name): Likewise.
+ * riscix.c (riscix_fix_pcrel_26): Likewise.
+ * srec.c (srec_scan): Likewise.
+ * stabs.c (_bfd_write_section_stabs): Likewise.
+ * sunos.c (sunos_add_dynamic_symbols): Likewise.
+ * aout-ns32k.c (_bfd_ns32k_relocate_contents): Add default case to
+ switch. Declare parameters for function pointers.
+ * archures.c (bfd_default_scan): Add braces to avoid ambiguous if
+ warning.
+ * elf.c (elf_sort_sections): Likewise.
+ * coff-arm.c (coff_thumb_pcrel_common): Initialize relocation.
+ Add default cases to switches.
+ (coff_arm_relocate_section): Remove unused local variables.
+ Always set rstat.
+ (coff_arm_bfd_set_private_flags): Change flag variable to type
+ flagword.
+ * coff-mips.c (mips_relocate_section): Initialize use_lo.
+ * coff-ppc.c (ppc_record_toc_entry): Change i to unsigned int.
+ (dump_toc): Change cat to const, and initialize it.
+ * coff-sh.c (sh_relax_delete_bytes): Initialize start and voff.
+ * elf32-sh.c (sh_elf_relax_delete_bytes): Likewise.
+ (sh_elf_relocate_section): Initialize r_symndx.
+ * coffcode.h (coff_compute_section_file_positions): Only declare
+ old_sofar if ALIGN_SECTIONS_IN_FILE.
+ (coff_write_object_contents): Initialize csym.
+ * coffgen.c (coff_pointerize_aux): Make type and class unsigned.
+ * cpu-ns32k.c (_bfd_ns32k_get_displacement): Add default case to
+ switch.
+ * dwarf2.c: Include libiberty.h.
+ (read_2_signed_bytes, read_4_signed_bytes): Comment out.
+ (decode_line_info): Remove unused local variables.
+ * elf32-m32r.c (m32r_elf_sda16_reloc): Likewise.
+ (m32r_elf_relocate_section): Likewise.
+ * elf32-v850.c (v850_elf_store_addend_in_insn): Likewise.
+ (v850_elf_reloc): Likewise.
+ * elf-bfd.h (elf_linker_section_t): Make alignment unsigned.
+ (struct elf_obj_tdata): Make cverdefs and cverrefs unsigned.
+ * elf.c (assign_file_positions_for_segments): Always set adjust.
+ * elf32-d30v.c (bfd_elf_d30v_reloc): Initialize tmp_addr. Fully
+ parenthesize expression.
+ * elf32-m32r.c (m32r_elf_relocate_section): Always initialize h.
+ (m32r_elf_object_p): Return a value.
+ (m32r_elf_print_private_bfd_data): Change fprintf format string.
+ * elf32-mips.c (mips_elf_final_link): Initialize last.
+ (mips_elf_finish_dynamic_sections): Initialize last and dindx.
+ * elf32-v850.c (v850_elf_object_p): Return a value.
+ (v850_elf_print_private_bfd_data): Change fprintf format string.
+ * elfcode.h (elf_slurp_symbol_table): Change symcount and i to
+ unsigned long.
+ * elflink.h (elf_link_add_object_symbols): Change vernum to
+ unsigned int, and initialize it. Change fprintf format string.
+ (NAME(bfd_elf,size_dynamic_sections)): Cast -1 to bfd_size_type
+ when setting or comparing to soname_indx.
+ (elf_create_pointer_linker_section): Change num_symbols to
+ unsigned int.
+ * libcoff-in.h (coff_data_type): Change flags to flagword.
+ * peicode.h (pe_print_idata): Initialize idx. Change j to
+ bfd_size_type. Initialize hint_member. Remove useless test to
+ time_stamp.
+ (pe_print_edata): Change num_functions and num_names in struct
+ EDT_type to unsigned long. Remove cast. Change fprintf format
+ string.
+ * ppcboot.c (ppcboot_object_p): Change i to size_t.
+ * reloc.c (bfd_get_reloc_size): Change return type to unsigned
+ int.
+ * reloc16.c (bfd_coff_reloc16_relax_section): Change shrinks to
+ int *. Update uses. Change j to long.
+ * bfd-in2.h, libcoff.h: Rebuild.
+
+Fri Mar 27 10:10:46 1998 Catherine Moore <clm@cygnus.com>
+
+ * elf32-v850.c Remove definition of USE_REL.
+ (v850_elf_info_to_howto_rela): New function.
+ (v850_elf_perform_relocation): Renamed from
+ v850_elf_store_addend_in_insn. Removed replace argument.
+ (v850_elf_reloc): store the relocation in the addend field instead
+ of the insn.
+ (v850_elf_final_link_relocate): Now calls
+ v850_elf_perform_relocation.
+ (v850_elf_relocate_section): Remove code to generate REL
+ relocations.
+
+Thu Mar 26 13:32:17 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_new_section_hook): Set the type and storage
+ class in the native symbol information allocated for a new section
+ symbol.
+
+Thu Mar 26 10:13:41 1998 Nick Clifton <nickc@cygnus.com>
+
+ * peicode.h: Chain together calls to
+ coff_bfd_copy_private_bfd_data and
+ coff_bfd_print_private_bfd_data.
+
+ * coff-arm.c: Add prototypes for
+ coff_arm_bfd_print_private_bfd_data and
+ coff_arm_bfd_copy_private_bfd_data.
+
+Wed Mar 25 15:45:55 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coffcode.h (coff_mkobject_hook): Set private falgs even for a PE
+ build.
+
+ * peicode.h: Call arm-coff private data functions after handling
+ pe private data.
+
+ * coff-arm.c: Turn statics into globals so that they can be shared
+ both pe and pei backends.
+
+Wed Mar 25 15:19:38 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutf1.h (sunos_set_arch_mach): Use bfd_mach_m68* rather than
+ plain numbers.
+ (sunos_write_object_contents): Likewise.
+ * aoutx.h (NAME(aout,machine_type)): Likewise.
+ * coffcode.h (coff_set_arch_mach_hook): Likewise.
+
+Wed Mar 25 13:59:24 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * archures.c (bfd_mach_m68*): Add definitions for various m68k
+ variants.
+ (bfd_default_scan): Remove m68k special cases.
+ * bfd-in2.h: Rebuild.
+ * mipsbsd.c (MY(write_object_contents)): Use bfd_mach_m68* rather
+ than plain numbers.
+ * sparclynx.c (NAME(lynx,set_arch_mach)): Likewise.
+ * cpu-m68k.c (arch_info_struct): Likewise. Add entry for
+ m68k:68000.
+ (bfd_m68k_arch): Set mach field to zero to signal no explicit
+ selection, change printable_name to just "m68k" and make that the
+ default instead of m68k:68020.
+
+ * aout-tic30.c (NAME): Define this to avoid multiple definitions
+ from aoutx.h.
+ (MY_get_section_contents): Define as aout_32_get_section_contents
+ rather than NAME(aout,get_section_contents).
+
+ * elf-m10300.c (elf32_mn10300_link_hash_table_create): Fix cast.
+
+ * evax-alpha.c (evax_set_arch_mach): Only accept bfd_arch_alpha
+ and call bfd_default_set_arch_mach to do the real work.
+
+Wed Mar 25 10:41:35 1998 Richard Henderson <rth@cygnus.com>
+
+ * bout.c (BALX): Include return register g14 as part of the insn.
+ (BALX_MASK): New.
+ (calljx_callback): Use it.
+
+Wed Mar 25 11:19:28 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd-in.h (BFD_ALIGN): Cast this parameter to bfd_vma.
+ * libbfd.h: Rebuild.
+
+ * elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Change
+ byte_count to unsigned int.
+ (mn10300_elf_relax_section): Initialize internal_relocs. Remove
+ unused local variables.
+
+ * evax-alpha.c (evax_close_and_cleanup): Remove unused local
+ variables er and er1.
+
+ * cpu-v850.c: Include <ctype.h>.
+ (scan): Case isdigit argument to unsigned char.
+
+ From Yan Meroth <YAN.MEROTH@st.com>:
+ * ihex.c (ihex_scan): Add extbase variable so that getting an
+ extended linear address record does not ignore any previous
+ extended address.
+ (ihex_write_object_contents): When writing out an extended linear
+ address record, zero out any previous extended address.
+
+Tue Mar 24 16:09:43 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * ieee.c (do_one): Check section before dereferencing it.
+ (ieee_canonicalize_reloc): Likewise with src->relent.sym_ptr_ptr.
+ (ieee_generic_stat_arch_elt): Likewise with abfd->my_archive.
+
+Mon Mar 23 18:51:47 1998 Joel Sherrill <joel@OARcorp.com>
+
+ * config.bfd: (sh*-*-rtems*): Switched from ELF to COFF.
+
+Mon Mar 23 14:23:36 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c: Add interworking functions to pe backends.
+
+Fri Mar 20 18:47:20 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use AM_DISABLE_SHARED.
+ * aclocal.m4, configure: Rebuild with libtool 1.2.
+
+Fri Mar 20 11:25:41 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (coff_arm_relocate_section): Better error messages
+ when interowrking conflucts occur. Courtesy of Jonathan Walton
+ and Tony Thompson.
+ (aoutarm_std_reloc_howto): Fixed bitsize fields of rightshifted
+ relocations. Patch courtesy of Jonathan Walton and Tony
+ Thompson.
+
+Fri Mar 20 02:26:43 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Revert
+ part of Feb 22 change controling when to override the existing
+ symbol with the .plt entry.
+
+Wed Mar 18 09:26:25 1998 Nick Clifton <nickc@cygnus.com>
+
+ * config.bfd (targ_cpu): Add thumb-pe target.
+
+ * coffcode.h (OTHER_GLOBAL_CLASS): Support thumb external
+ functions in PE build.
+
+Sun Mar 8 23:37:26 1998 Stan Cox <scox@equinox.cygnus.com>
+
+ * config.bfd (sparclite-*-elf*): Added.
+
+Mon Feb 23 19:31:19 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Add elf.lo to elf shell variable.
+ * Makefile.am (BFD_LIBS): Remove elf.lo.
+ (BFD_LIBS_CFILES): Remove elf.c.
+ (BFD32_BACKENDS): Add elf.lo.
+ (BFD32_BACKENDS_CFILES): Add elf.c.
+ * configure, Makefile.in: Rebuild.
+
+1998-02-23 15:53 Richard Henderson <rth@cygnus.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): A pc-relative
+ relocation against a now-local symbol should not have a dynamic
+ relocation.
+
+Mon Feb 23 16:17:08 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (coff_swap_filehdr_in): Don't set BFD flag HAS_SYMS in
+ COFF filehdr flags.
+ (pe_print_private_bfd_data): Print PE flags. From Mikey
+ <jeffdb@netzone.com>.
+
+Sun Feb 22 20:39:00 1998 Richard Henderson <rth@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Don't create
+ a plt entry when we can determine that we authoritatively define
+ the symbol.
+
+Sun Feb 22 20:33:05 1998 Richard Henderson <rth@cygnus.com>
+
+ * configure.in (COREFILE selection): Remove sparc-*-linux*. They
+ don't actually use trad-core, but a SunOS-style core file handled
+ by gdb directly.
+ * hosts/sparclinux.h: Remove.
+
+Wed Feb 18 15:31:06 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (pe_print_idata): If there is no .idata section, look
+ for the import tables in some other section. Make the initial
+ label line up better with the data. Print the import address
+ table even if there is no import name table. If the import
+ address table holds actual addresses, print them.
+
+Tue Feb 17 12:58:34 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd.c (bfd_seek): If fseek fails, save errno around call to
+ bfd_tell. If errno is EINVAL, set bfd_error_file_truncated, not
+ bfd_error_system_call.
+
+Fri Feb 13 13:11:33 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (AUTOMAKE_OPTIONS): Define.
+ * configure, Makefile.in, aclocal.m4: Rebuild with automake 1.2e.
+
+ From H.J. Lu <hjl@gnu.org>:
+ * Makefile.am (libbfd_la_LDFLAGS): Define.
+ * Makefile.in: Rebuild.
+
+Thu Feb 12 17:31:11 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ NetBSD patches from Gordon W. Ross <gwr@mc.com>:
+ * netbsd.h (MACHTYPE_OK): Define.
+ (MY(write_object_contents)): Use DEFAULT_ARCH and DEFAULT_MID when
+ calling N_SET_MACHTYPE, rather than having a switch.
+ * libaout.h (enum machine_type): Add M_PMAX_NETBSD, M_VAX_NETBSD,
+ and M_ALPHA_NETBSD.
+ * i386netbsd.c (MACHTYPE_OK): Don't define.
+ (DEFAULT_MID): Define.
+ * m68k4knetbsd.c (SEGMENT_SIZE): Don't define.
+ (MACHTYPE_OK): Don't define.
+ (DEFAULT_MID): Define.
+ * m68knetbsd.c: (MACHTYPE_OK): Don't define.
+ (DEFAULT_MID): Define.
+ * ns32knetbsd.c (MACHTYPE_OK): Don't define.
+ (DEFAULT_MID): Define.
+ * sparcnetbsd.c (MACHTYPE_OK): Don't define.
+ (DEFAULT_MID): Define.
+
+ NetBSD patches from Gordon W. Ross <gwr@mc.com>:
+ * vaxnetbsd.c: New file.
+ * netbsd-core.c: Clean up. Remove unused macros. Use netbsd
+ rather than netbsd_core.
+ * targets.c (vaxnetbsd_vec): Declare.
+ (bfd_target_vector): Add vaxnetbsd_vec. If NETBSD_CORE is
+ defined, add netbsd_core_vec.
+ * configure.in: Set COREFILE for alpha*-*-netbsd* and
+ powerpc-*-netbsd* to netbsd-core.lo. If COREFILE is
+ netbsd-core.lo, set COREFLAG to -DNETBSD_CORE.
+ * config.bfd (alpha*-*-netbsd*): New target.
+ * Makefile.am: Rebuild dependencies.
+ (BFD32_BACKENDS): Add vaxnetbsd.lo.
+ (BFD32_BACKENDS_CFILES): Add vaxnetbsd.c.
+ * configure, Makefile.in: Rebuild.
+
+ * configure.host: Remove the old shared library build stuff. We
+ now use libtool instead.
+
+Wed Feb 11 17:13:09 1998 Richard Henderson <rth@cygnus.com>
+
+ * tekhex.c (tekhex_write_object_contents): Call tekhex_init.
+
+Tue Feb 10 19:23:28 1998 H.J. Lu <hjl@gnu.org>
+
+ * configure.in: Take stab-syms.lo out of sparclinux_vec list.
+ * configure: Rebuild.
+
+Tue Feb 10 15:16:38 1998 Nick Clifton <nickc@cygnus.com>
+ * elf32-v850.c (remember_hi16s_reloc): New function.
+ (find_remembered_hi16s_reloc): New function.
+ (v850_elf_store_addend_in_insn): Use the above new functions to
+ match up HI6S relocs with LO16 relocs.
+
+Tue Feb 10 15:01:39 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Change -linux* to -linux-gnu*.
+ * config.bfd, configure.host: Likewise.
+ * configure: Rebuild.
+
+Mon Feb 9 19:40:59 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_store_addend_in_insn): Fix another
+ LO16/HI16S bug and improve comments about what is going on.
+
+Sat Feb 7 15:27:03 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure, aclocal.m4: Rebuild with new libtool.
+
+Fri Feb 6 14:48:20 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_merge_private_bfd_data): Do not complain
+ when merging v850 code into v850e/v850ea code. Do not initialise
+ output flags if the input is the default architecture.
+
+Fri Feb 6 11:50:22 1998 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mips.c (bfd_elf32_bfd_reloc_type_lookup): For BFD_RELOC_CTOR
+ get the size from bfd_arch_bits_per_address instead of directly
+ from the isa.
+
+Thu Feb 5 14:21:34 1998 Michael Meissner <meissner@cygnus.com>
+
+ * libbfd-in.h (BFD_ALIGN): If rounding up would cause the address
+ to wrap, just return all 1's bits instead.
+ * libbfd.h: Regenerate.
+
+Thu Feb 5 11:51:05 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i386.c (coff_pe_i386_relocate_section): New static function
+ if COFF_WITH_PE.
+ (coff_relocate_section): If COFF_WITH_PE, define as
+ coff_pe_i386_relocate_section.
+ * coffcode.h (coff_write_object_contents): If COFF_IMAGE_WITH_PE,
+ skip empty sections, to match coff_write_object_contents.
+
+ * elf64-mips.c (mips_elf64_swap_reloca_out): Swap out r_addend,
+ rather than swapping out r_offset twice. From Luke Deller
+ <luked@cse.unsw.edu.au>.
+
+Wed Feb 4 19:11:28 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set libtool_enable_shared rather than
+ libtool_shared. Remove diversion hack.
+ * configure, Makefile.in, doc/Makefile.in, aclocal.m4: Rebuild
+ with new libtool.
+
+Wed Feb 4 16:10:21 1998 Brent Baccala <baccala@freesoft.org>
+
+ * syms.c (struct stab_cache): Define.
+ (struct stab_find_info): Remove cached_offset, cached_stab,
+ cached_str, and cached_stroff fields. Add file_cache,
+ function_cache, and line_cache fields.
+ (_bfd_stab_section_find_nearest_line): Use extensive caching to
+ speed up searches.
+
+Wed Feb 4 13:34:22 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (pe_print_idata): Check for import of ordinal rather
+ than name.
+ (pe_print_edata): If there is no .edata section, look for the
+ export data in some other section.
+
+Mon Feb 2 20:05:42 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * configure.in: Change version to 2.8.4.
+ * configure: Regenerated.
+
+Mon Feb 2 17:39:39 1998 Steve Haworth <steve@pm.cse.rmit.EDU.AU>
+
+ Add tms320c30 support:
+ * cpu-tic30.c: New file.
+ * aout-tic30.c: New file.
+ * coff-tic30.c: New file.
+ * archures.c (bfd_arch_tic30): Define.
+ (bfd_tic30_arch): Declare.
+ (bfd_archures_list): Add bfd_tic30_arch.
+ * targets.c (bfd_target_vector): Add tic30_aout_vec and
+ tic30_coff_vec.
+ * reloc.c (BFD_RELOC_TIC30_LDP): Define.
+ * coffcode.h (coff_set_arch_mach_hook): Add tic30 case.
+ (coff_set_flags): Likewise.
+ * config.bfd (tic30-*-*aout*, tic30-*-*coff*): New targets.
+ * configure.in (tic30_aout_vec, tic30_coff_vec): New vectors.
+ * Makefile.am: Rebuild dependencies.
+ (ALL_MACHINES): Add cpu-tic30.lo.
+ (ALL_MACHINES_CFILES): Add cpu-tic30.c.
+ (BFD32_BACKENDS): Add aout-tic30.lo and coff-tic30.lo.
+ (BFD32_BACKENDS_CFILES): Add aout-tic30.c and coff-tic30.c.
+ * configure, Makefile.in, bfd-in2.h, libbfd.h: Rebuild.
+
+Mon Feb 2 12:25:12 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_store_addend_in_insn): Allow HI16_S reloc
+ to lag behind LO16 reloc by a couple of instructions.
+
+Mon Feb 2 14:09:46 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am ($(srcdir)/bfd-in2.h): Add dummy command to force
+ make to reexamine the file timestamp.
+ ($(srcdir)/libbfd.h, $(srcddir)/libcoff.h): Likewise.
+
+ * elf64-alpha.c (ELF_MAXPAGESIZE): Change to 0x10000 from
+ 0x100000.
+
+Fri Jan 30 19:07:07 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_create_dynamic_sections): New procedure
+ to create .dynsbss and .rela.sbss sections.
+ (ppc_elf_adjust_dynamic_symbol): Put space for small data to be
+ copied from dynamic objects into .sbss.
+ (ppc_elf_size_dynamic_sections): Strip .rela.sbss if we don't
+ use it. Correct typo of .rela.sdata2.
+ (ppc_elf_finish_dynamic_symbol): Generate reloc to where we
+ put the data, which may now be in .sbss.
+ (ppc_elf_relocate_section): A SDAREL16 reloc can be in dynsbss.
+ (elf_backend_create_dynamic_sections): Define as
+ ppc_elf_create_dynamic_sections.
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Don't emit R_PPC_REL* relocs
+ against _GLOBAL_OFFSET_TABLE_.
+ (ppc_elf_relocate_section): Don't emit R_PPC_REL32 relocs in
+ shared libraries which refer to local symbols. Make sure that the
+ test for allocating space for a reloc in a shared object is the
+ same as the test for emitting a reloc.
+
+Thu Jan 29 15:55:35 1998 J.J. van der Heijden <J.J.vanderHeijden@student.utwente.nl>
+
+ * config.bfd (i[3456]-*-mingw32*): New target.
+ * acinclude.m4 (BFD_BINARY_OPEN): Check for mingw32.
+ * aclocal.m4, configure: Rebuild.
+
+Wed Jan 28 13:41:26 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (_bfd_elf_close_and_cleanup): Only check the strtab if we
+ have a bfd_object.
+
+Tue Jan 27 21:43:55 1998 Richard Henderson <rth@cygnus.com>
+
+ Sparc v9 ABI compliant PLT:
+ * elf64-sparc.c (PLT_HEADER_SIZE): V9 ABI uses 4 entries.
+ (plt_templates, sparc64_elf_build_plt_entry): Delete.
+ (LARGE_PLT_THRESHOLD): New define.
+ (GOT_RESERVED_ENTRIES): V9 ABI only uses 1.
+ (sparc64_elf_build_plt): New function.
+ (sparc64_elf_plt_entry_offset): Likewise.
+ (sparc64_elf_plt_ptr_offset): Likewise.
+ (sparc64_elf_adjust_dynamic_symbol): Change h->plt_offset to
+ contain the index for convenience. Skip the initial entries
+ in .rela.plt.
+ (sparc64_elf_size_dynamic_sections): Zero the allocated contents
+ memory for the benefit of .rela.plt.
+ (sparc64_elf_relocate_section): Call sparc64_elf_plt_entry_offset.
+ (sparc64_elf_finish_dynamic_symbol): Kill template stuff. Use
+ sparc64_elf_plt_entry_offset & sparc64_elf_plt_ptr_offset for reloc.
+ (sparc64_elf_finish_dynamic_sections): DT_PLTGOT points to .plt.
+ Call sparc64_elf_build_plt.
+ (elf_backend_want_got_plt): No.
+ (elf_backend_plt_readonly): No.
+ (elf_backend_plt_alignment): 8.
+
+ * elf.c (_bfd_elf_close_and_cleanup): New function; free the shstrtab.
+ * elf-bfd.h (_bfd_elf_close_and_cleanup): Declare it.
+ * elfxx-target.h (bfd_elfNN_close_and_cleanup): Arrange for it
+ to be called.
+
+Tue Jan 27 21:45:15 1998 Jeffrey A Law (law@cygnus.com)
+
+ * archures.c (bfd_mach_mips*): Add definitions for various MIPS
+ processors.
+ * cpu-mips.c (arch_info_struct): Add mips variants.
+ * bfd-in2.h: Rebuilt.
+
+Tue Jan 27 15:06:04 1998 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (coff_arm_relocate_section): Preserve the contents of
+ t2a3_b_insn.
+
+Tue Jan 27 12:47:27 1998 Robert Lipe <robertl@dgii.com>
+
+ * config.bfd (i[3456]86-sco3.2v5*): ELF now the default.
+ (i[3456]86sco3.2v5*coff): New target.
+
+Mon Jan 26 15:41:30 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd-in2.h: Rebuild with changes to chew--tab expansion.
+
+Thu Jan 22 21:26:48 1998 Richard Henderson <rth@cygnus.com>
+
+ * bfd.c (bfd_get_error_handler): Add orthogonal function.
+ * bfd-in2.h: Regenerate.
+
+Thu Jan 22 21:13:39 1998 Richard Henderson <rth@cygnus.com>
+
+ * tekhex.c (tekhex_write_object_contents): Check for no symbols.
+
+Wed Jan 21 21:19:03 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i386.c (coff_i386_rtype_to_howto): If COFF_WITH_PE, don't
+ adjust addend for an output common symbol (from Jimmy Blair
+ <jimmyb@wrs.com>). If COFF_WITH_PE, adjust addend for PC relative
+ defined symbol to counteract adjustment made in generic relocation
+ code.
+
+ * dwarf2.c: Include sysdep.h, not stdio.h and stdlib.h.
+
+Wed Jan 21 21:16:06 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * coff-m88k.c (GET_SCNDHR_NRELOC): Fix typo in macro name.
+ (GET_SCNDHR_NLNNO): Likewise.
+
+Mon Jan 19 12:49:52 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * cpu-sh.c (arch_info_struct): Correct next field of sh3e.
+
+Wed Jan 14 17:23:27 1998 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-m32r.c: Add macros to handle NOP insertion.
+
+Wed Jan 14 16:15:22 1998 Richard Henderson <rth@cygnus.com>
+
+ * xcofflink.c (xcoff_mark_symbol): Don't mark the absolute section.
+ (xcoff_mark): Likewise.
+ (xcoff_build_ldsyms): Mark absolute symbols.
+
+Wed Jan 14 16:03:11 1998 Richard Henderson <rth@cygnus.com>
+
+ * bout.c (b_out_write_object_contents): Sort symbols before output
+ to keep {CALL,BAL}NAME symbols adjacent.
+ (b_out_symbol_cmp): New function.
+
+For older changes see ChangeLog-9697
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/ChangeLog-9193 b/bfd/ChangeLog-9193
new file mode 100644
index 00000000000..15af9319596
--- /dev/null
+++ b/bfd/ChangeLog-9193
@@ -0,0 +1,7851 @@
+Fri Dec 31 16:23:43 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Minor cleanups suggested by CodeCenter.
+ * aoutx.h, coffgen.c, ecoff.c, ecofflink.c, elf.c, libbfd.c,
+ linker.c, reloc.c, section.c, srec.c: Added /*ARGSUSED*/ as
+ appropriate.
+ * aoutx.h (struct external_exec): Removed unnecessary declaration.
+ (NAME(aout,some_aout_object_p)): Set some tdata pointers to NULL.
+ (adjust_z_magic): Removed useless variable data_vma.
+ (stringtab_init): Initialize hash_zero.
+ (add_to_stringtab): Removed unused fourth argument.
+ (NAME(aout,swap_std_reloc_out)): Removed useless variable
+ r_addend.
+ (aout_link_input_section): Added some casts.
+ * archive.c (get_extended_arelt_filename, do_slurp_coff_armap,
+ bfd_ar_hdr_from_filesystem, bsd_write_armap, coff_write_armap):
+ Minor code rewriting to make it more C like.
+ (do_slurp_bsd_armap): Added some casts.
+ * ecoff.c (ecoff_write_object_contents): Removed useless variable
+ scn_base.
+ (ecoff_write_armap): Added some casts. Use "" rather than "\0".
+ * ecofflink.c (bfd_ecoff_write_debug): Added a cast.
+ * libaout.h (struct internal_exec): Removed unnecessary
+ declaration.
+ * linker.c (_bfd_generic_indirect_link_order): Added a cast.
+ * opncls.c (new_bfd): Removed a cast.
+ * reloc.c (bfd_generic_get_relocated_section_contents): Added
+ some casts.
+ * srec.c (internal_srec_write_object_contents): Removed useless
+ variable bytes_written.
+
+Fri Dec 31 11:46:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * i386mach3.c (N_TXTADDR): Don't define after all.
+ (TEXT_START_ADDR): Don't include exec header size in value.
+
+Thu Dec 30 15:47:54 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * i386mach3.c (N_TXTADDR): Define.
+
+Thu Dec 30 13:37:24 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Extensive changes to move the bulk of the linker into BFD so that
+ more efficient backend code can be written for specific object
+ files. Only existing efficient backend is a.out.
+ * seclet.c, seclet.h: Removed.
+ * hash.c, linker.c, genlink.h: New files.
+ * bfd-in.h: Removed bfd_error_vector. Declared hash table
+ structures and functions.
+ (JUMP_TABLE): Removed bfd_seclet_link, added
+ bfd_link_hash_table_create, bfd_link_add_symbols and
+ bfd_final_link.
+ * All backends: Changed accordingly.
+ * bfd-in2.h: Rebuilt.
+ * bfd.c (struct _bfd): Added link_next and archive_pass fields.
+ Removed ld_symbols field.
+ (bfd_nonrepresentable_section, bfd_undefined_symbol,
+ bfd_reloc_value_truncated, bfd_reloc_is_dangerous,
+ bfd_error_vector): Removed.
+ (bfd_default_error_trap, bfd_error_trap,
+ bfd_error_nonrepresentabltrap): Removed.
+ (bfd_get_relocated_section_contents): Pass link_info. Pass
+ link_order instead of seclet. Pass symbols.
+ (bfd_relax_section): Pass link_info.
+ (bfd_seclet_link): Removed.
+ (bfd_link_hash_table_create, bfd_link_add_symbols,
+ bfd_final_link): New macros.
+ * libbfd-in.h: If __GNUC__ is defined and alloca is not, define
+ alloca as __builtin_alloca. Declare internal linking functions.
+ * libbfd.h: Rebuilt.
+ * libbfd.c (bfd_seek): Comment out fseek assertion. It's worked
+ for months.
+ * reloc.c (reloc_howto_type): Added error_message argument to
+ special_function field. Changed all callers and all definitions.
+ (bfd_get_reloc_size): Make argument a const pointer.
+ (bfd_perform_relocation): Add error_message argument to hold
+ string set if return value if bfd_reloc_dangerous. Changed all
+ callers.
+ (_bfd_final_link_relocate, _bfd_relocate_contents): New functions.
+ * section.c (asection): Renamed seclets_head and seclets_tail to
+ link_order_head and link_order_tail.
+ * targets.c (bfd_target): Replaced seclet argument with link_info
+ and link_order and symbols arguments in
+ bfd_get_relocated_section_contents. Added symbols argument to
+ bfd_relax_section. Removed bfd_seclet_link. Added
+ bfd_link_hash_table_create, bfd_link_add_symbols and
+ bfd_final_link.
+ * libaout.h (struct aoutdata): Added external_syms,
+ external_sym_count, external_strings, sym_hashes fields.
+ (obj_aout_external_syms, obj_aout_external_sym_count,
+ obj_aout_external_strings, obj_aout_sym_hashes): New accessor
+ macros.
+ (WRITE_HEADERS): Only output symbols if outsymbols is not NULL.
+ * aoutx.h: Wrote new back end linker routines.
+ (translate_to_native_sym_flags): Return boolean value. Don't use
+ bfd_error_vector.
+ (NAME(aout,write_syms)): Return boolean value. Check return value
+ of translate_to_native_sym_flags and bfd_write.
+ * aout-target.h (final_link_callback): New function.
+ (MY_bfd_final_link): New function.
+ * aout-adobe.c (aout_adobe_write_object_contents): Check return
+ value of aout_32_write_syms.
+ * hp300hpux.c (MY(write_object_contents)): Likewise.
+ * i386lynx.c (WRITE_HEADERS): Likewise.
+ * libaout.h (WRITE_HEADERS): Likewise.
+ * bout.c: Changed functions to use link_info->callbacks rather
+ than bfd_error_vector, and link_orders rather than seclets.
+ * coff-alpha.c: Likewise.
+ * coff-h8300.c: Likewise.
+ * coff-h8500.c: Likewise.
+ * coff-sh.c: Likewise.
+ * coff-z8k.c: Likewise.
+ * elf32-hppa.c: Likewise.
+ * reloc16.c: Likewise.
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Look
+ up _gp in the hash table rather than in outsymbols.
+ * coff-a29k.c (a29k_reloc): Pass errors back in new error_message
+ argument rather than printing them.
+ * coffcode.h (bfd_coff_reloc16_extra_cases): Take link_info and
+ link_order arguments rather than seclet. Changed all uses and
+ definitions.
+ (bfd_coff_reloc16_estimate): Pass link_info arguments. Changed
+ all uses and definitions.
+ * libcoff.h: Rebuilt.
+ * ecoff.c (ecoff_get_extr): If symbol is defined by linker, but
+ not by ECOFF, make it scAbs.
+ (ecoff_bfd_final_link): Renamed from ecoff_bfd_seclet_link and
+ rewritten.
+ * elf32-mips.c (mips_elf_final_link): Renamed from
+ mips_elf_seclet_link and rewritten.
+ * elf32-hppa.c (elf32_hppa_stub_description): Added link_info
+ field.
+ (new_stub, add_stub_by_name, hppa_elf_build_arg_reloc_stub,
+ hppa_elf_build_long_branch_stub, hppa_look_for_stubs_in_section):
+ Added link_info arguments. Changed all callers.
+ * elfcode.h (elf_slurp_symbol_table): Don't quit if outsymbols is
+ not NULL.
+ * oasys.c (oasys_write_sections): Return boolean value rather than
+ using bfd_error_vector.
+ (oasys_write_object_contents): Check return value of
+ oasys_write_sections.
+ * hosts/std-host.h: Don't declare qsort or strtol.
+ * Makefile.in: Rebuild dependencies.
+ (BFD_LIBS): Removed seclet.o. Added hash.o and linker.o.
+ (CFILES): Removed seclet.c. Added hash.c and linker.c.
+ (HFILES): Removed seclet.h. Added genlink.h.
+
+Thu Dec 30 07:41:36 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * section.c (bfd_get_section_contents): Return zero filled buffer
+ if section has no contents.
+
+Tue Dec 28 12:43:54 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf.c (bfd_elf_generic_reloc): If this is not an inplace reloc,
+ then skip bfd_perform_relocation even if the addend is non-zero.
+
+Tue Dec 21 09:22:19 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * coffcode.h (coff_write_relocs) [SWAP_OUT_RELOC_OFFSET]: Copy
+ addend to r_offset field.
+
+ * Makefile.in (CFILES): Added coff-sparc.c. Rebuild dependencies.
+
+ * coff-sparc.c (SWAP_IN_RELOC_OFFSET, SWAP_OUT_RELOC_OFFSET,
+ CALC_ADDEND): Define.
+
+ * aix386-core.c (aix386_core_file_p): Use cd_regs[0] for computing
+ the offsetof because AIX /bin/cc does not like to take the address
+ of an array. (From Minh Tran-Le.)
+
+Thu Dec 16 13:06:32 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * Thu Dec 16 15:41:06 1993 Peter Hoogenboom (hoogen@cs.utah.edu)
+
+ * elf32-hppa.c (hppa_elf_build_arg_reloc_stub): Make sure to copy
+ the return pointer into %r2 if no jump-in-call-delay-slot
+ optimization was done.
+
+ * hosts/hp300bsd.h: Correctly identify 4.3BSD vs 4.4BSD.
+
+Wed Dec 15 08:04:16 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * hosts/std-host.h: (time): Don't declare; conflicts on Mach3.
+
+ * hosts/i386mach3.h (HOST_PAGE_SIZE): Set to 1 to avoid padding.
+ (HOST_SEGMENT_SIZE): Set to 0 for same reason.
+
+ * i386mach3.c (PAGE_SIZE, SEGMENT_SIZE): Same changes as above.
+ (TEXT_START_ADDR): Correct.
+ (MY_backend_data): Define.
+
+ * aoutx.h (adjust_o_magic, adjust_z_magic, adjust_n_magic):
+ New functions; code moved from aout_<size>_adjust_sizes_and_vmas.
+
+Tue Dec 14 21:48:33 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_begin_writing): Fix thinkos in auxiliary header
+ support.
+ (bfd_som_attach_aux_hdr): Likewise.
+
+Mon Dec 13 23:34:48 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (hppa_elf_gen_reloc_type): Handle 'T' field
+ selectors for PIC code.
+
+ * som.c (hppa_som_gen_reloc_type): Handle 'T' field selectors.
+ (som_write_fixups): Handle R_DLT_REL, R_FSEL, R_RSEL, R_LSEL
+ relocations needed by PIC.
+
+Tue Dec 7 15:47:51 1993 Stu Grossman (grossman at cygnus.com)
+
+ * nlmcode.h: Fixes to avoid compiler warnings...
+
+Tue Dec 7 15:10:54 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * libnlm.h (nlm_backend_data): Removed macro definition.
+ (nlm_alpha_backend_data): Adjusted accordingly.
+
+Sun Dec 5 19:32:08 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_begin_writing): Flesh out code for handling simple
+ auxiliary headers.
+ (bfd_som_attach_aux_hdr): New function.
+
+ * som.h (struct somdata): Add fields for attaching version and
+ copyright headers. Add accessor macros.
+
+ * som.c (R_DLT_REL, R_AUX_UNWIND, R_SEC_STMT): Add protected
+ definitions for old versions of HPUX which fail to define them.
+ (som_hppa_howto_talbe): Add R_DLT_REL, R_AUX_UNWIND, and R_SEC_STMT
+ now that they're safe. Delete bogus R_STATEMENT relocations.
+
+ * som.c (som_hppa_howto_table): Add missing R_END_TRY. Delete
+ extra R_DATA_OVERRIDE.
+ (hppa_som_gen_reloc_type): Generate a relocation for the rounding
+ mode selector if needed.
+ (som_write_fixups): Handle requests for a change in the default
+ rounding mode. Rounding modes do not consume input bytes, but
+ are just markers much like R_ENTRY and R_EXIT.
+
+Sat Dec 4 19:40:32 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ Fri Dec 3 09:55:17 1993 Pete Hoogenboom (hoogen@cs.utah.edu)
+
+ * elf32-hppa.c: (hppa_elf_reloc): Do not do code reordering when
+ the branch instruction as originally been nullified.
+ hppa_elf_reloc): Avoid useless call to bfd_put_32 () in the
+ case of no code reordering due to an LDO instruction in the
+ delay slot of the branch. Make sure to relocate the correct
+ instruction. Do not perform instruction reordering for millicode
+ calls.
+ (hppa_elf_build_arg_reloc_stub): Change the relocation type
+ to R_HPPA_STUB_CALL_17 when special processing might be needed.
+ (hppa_elf_build_long_branch_stub): Prevent code reordering on
+ a call from a linker stub to another linker stub and for millicode
+ calls. Do not trash the return register for calls from one linker
+ stub to a second linker stub.
+
+ * elf32-hppa.c: (elf_hppa_howto_table): PLABEL and DLT
+ relocations are not pc-relative.
+
+ * hppa_stubs.h: (BLE_N_XXX_0_31): New instruction used in
+ linker stub code.
+ (COPY_2_31): Likewise.
+
+Fri Dec 3 18:40:58 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config/solaris2.mh (HDEFINES): Remove -Dconst=
+ * hosts/solaris.h: If not __GNUC__, define const as empty.
+
+Thu Dec 2 15:43:32 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c: Added various casts for 32/64 bit cross targeting.
+ (ecoff_mkobject_hook): Set SEC_SHARED_LIBRARY for the .reginfo
+ section so that the linker ignores it.
+ * ecofflink.c: Added various casts for 32/64 bit cross targeting.
+ (ecoff_add_bytes): Changed need argument to size_t.
+ (bfd_ecoff_debug_link_other): Check return value of
+ ecoff_add_string.
+
+ * libbfd-in.h (new_bfd): Use void rather than an empty parameter
+ list.
+ * libbfd.h: Rebuilt.
+
+ * libnlm.h (struct nlm_obj_tdata): New field backend_data.
+ (nlm_backend_data, nlm_alpha_backend_data): New accessor macros.
+ (struct nlm_backend_data): New field no_uninitialized_data.
+ (nlm_no_uninitialized_data): New accessor macro.
+ * nlmcode.h (nlm_compute_section_file_positions): Handle
+ no_uninitialized_data.
+ (nlm_external_reloc_compare): Sort relocs by address for a
+ particular symbol, to make the sort more stable.
+ (nlm_write_object_contents): Cast the arguments to qsort. Get the
+ value of a debugging symbol the same way we get the value of a
+ normal symbol.
+ * nlm32-alpha.c: Various changes. Write out GP and .lita relocs.
+ Set no_uninitialized_data to true.
+ * nlm32-i386.c (nlm32_i386_backend), nlm32-sparc.c
+ (nlm32_sparc_backend): Set no_uninitialized_data field false.
+ * nlmswap.h (nlm_swap_fixed_header_out): Zero out destination
+ before filling it in.
+
+Wed Dec 1 21:47:58 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_section_type, som_decode_symcalss): New functions.
+ (som_get_symbol_info): Use them.
+ (som_slurp_symbol_table): Set the section of common and undefined
+ symbols correctly.
+
+Wed Dec 1 14:15:10 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * elfcode.h (write_relocs): Initialize local var LAST_SYM_IDX, to
+ make gcc happy.
+
+ * mipsbsd.c: Changes from Ralph Campbell:
+ (mips_howto_table_ext): MIPS_RELOC_LO16 should use
+ complain_overflow_dont.
+ (aout_mips_*_vec): Make name use "a.out" instead of "aout", to
+ make gdb happy.
+
+ * bfd.c (bfd_errmsgs): Reword invalid-target message.
+
+ * config.bfd: For sparc*-*-coff, use sparc-coff.
+ * configure.in: Handle sparccoff_vec.
+ * targets.c (sparccoff_vec): Declare.
+
+ * reloc.c (bfd_get_reloc_size): New function.
+ (struct reloc_howto_type): Update documentation of size field.
+
+Wed Dec 1 14:39:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlm32-alpha.c: New file; preliminary Alpha NetWare support.
+ * config.bfd (alpha-*-netware*): New target; use alpha-nlm.
+ * config/alpha-nlm.mt: New file.
+ * configure.in (nlm32_alpha_vec): New vector; use nlm32-alpha.o,
+ nlm32.o, and nlm.o.
+ * Makefile.in (BFD32_BACKENDS): Added nlm32-alpha.o.
+ (CFILES): Added nlm32-alpha.c.
+ Rebuilt dependencies.
+ * targets.c (nlm32_alpha_vec): Declare.
+
+ * libnlm.h (struct nlm_backend_data): New fields
+ optional_prefix_size, nlm_backend_object_p, nlm_write_prefix,
+ nlm_set_public_section, nlm_get_public_offset. Removed unused
+ nlm_write_reloc field. Changed nlm_write_import to remove
+ unnecessary symbol argument. Renamed nlm_write_externals to
+ nlm_write_external, and changed cound argument from bfd_vma to
+ bfd_size_type.
+ (nlm_optional_prefix_size, nlm_backend_object_p_func,
+ nlm_write_prefix_func, nlm_set_public_section_func,
+ nlm_get_public_offset_func): New accessor macros.
+ (nlm_write_reloc_func): Removed.
+ (nlm_write_external_func): Adjusted for field renaming.
+ * nlm32-i386.c (nlm_i386_write_import): Renamed from
+ nlm_i386_write_reloc. Removed old nlm_i386_write_import which
+ just called old nlm_i386_write_reloc.
+ (nlm_i386_write_external): Renamed from nlm_i386_write_externals.
+ Declared. Changed second argument from bfd_vma to bfd_size_type.
+ (nlm32_i386_backend): Adjusted for changes to fields and names.
+ * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused,
+ ifdeffed out code.
+ (nlm_sparc_write_import): Removed second argument.
+ (nlm_sparc_write_external): Renamed from
+ nlm_sparc_write_externals. Changed second argument from bfd_vma
+ to bfd_size_type.
+ (nlm32_sparc_backend): Adjusted for changes to fields and names.
+ * nlmcode.h: Removed some unused code.
+ (nlm_object_p): Don't destroy tdata pointer. Call
+ backend_object_p function if it exists.
+ (nlm_slurp_symbol_table): Removed unused variable rcount. Call
+ set_public_section_func if it exists instead of checking
+ NLM_HIBIT.
+ (nlm_compute_section_file_positions): Account for
+ optional_prefix_size.
+ (nlm_write_object_contents): Account for optional_prefix_size.
+ Removed useless variable write_reloc_func. Changed declaration
+ and call of write_import_func. Call write_prefix_func if it
+ exists. Removed unused variables len and temp. Call
+ get_public_offset_func if it exists rather than setting NLM_HIBIT.
+ * nlmswap.h: Declare functions.
+
+ * bfd-in.h (uint64_typeLOW, uint64_typeHIGH): Fully parenthesize
+ for clarity.
+ (fprintf_vma, sprintf_vma): Use %lx, not %x.
+ * bfd-in2.h: Rebuilt.
+ * hosts/alphaosf.h (uint64_typeLOW, uint64_typeHIGH): Cast results
+ to unsigned long.
+
+ * config.bfd: Don't set target64 here, as the setting is ignored.
+ * configure.in (ecoffalpha_little_vec): Set target64.
+
+ * config/alphaosf.mt (TDEFINES): Removed; setting host parameters
+ in TDEFINES is wrong.
+
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents):
+ Remove unused variable output_section.
+
+Tue Nov 30 16:45:23 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * irix-core.c: New file for Irix 4 and Irix 5 core support.
+ Functions taken out of coff-mips.c. Handle vmap type VMAPFILE.
+ * coff-mips.c: Irix 4 core file support moved to irix-core.c.
+ * targets.c: If IRIX_CORE defined, include irix_core_vec in
+ target_vector.
+ * config/irix4.mh (HDEFINES): Add -DIRIX_CORE.
+ (HDEPFILES): Define to be irix-core.o.
+ * config/irix5.mh (HDEFINES): Define to be -DIRIX_CORE.
+ (HDEPFILES): Define to be irix-core.o.
+ * Makefile.in (OPTIONAL_BACKENDS): Added irix-core.o. Removed
+ sco-core.o, which no longer exists.
+ (CFILES): Added all *-core.c files.
+ Rebuilt dependencies.
+
+Wed Nov 24 02:02:41 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (map_program_segments): Restore check of file_size !=
+ mem_size, but only if SHT_PROGBITS.
+
+ * ecofflink.c: New file to hold ECOFF debug information linking
+ routines.
+ * ecoff.c (ecoff_clear_output_flags, ecoff_rel, ecoff_dump_seclet,
+ ecoff_add_string, ecoff_get_debug): Removed. Functionality now in
+ ecofflink.c.
+ (ecoff_get_extr, ecoff_set_index): New functions.
+ (ecoff_slurp_symbolic_info): Don't save raw_size.
+ (ecoff_bfd_seclet_link): Rewrote to use ecofflink.c functions.
+ (ecoff_compute_section_file_positions): Don't set EXEC_P just
+ because there is a start address.
+ (ecoff_write_object_contents): Handle external symbols here. Use
+ ecofflink.c functions to write out debugging information.
+ * elf32-mips.c (mips_elf_read_ecoff_info, mips_elf_get_extr,
+ mips_elf_set_index): New functions.
+ (mips_elf_seclet_link): Discard empty sections, the .options
+ section and .gptab sections. Handle linking .mdebug section.
+ * libecoff.h (ecoff_data_type): Removed raw_size and ifdbase.
+ * libelf.h (elf_symbol_type): Added mips_extr to tc_data union.
+ * bfd-in.h: Added prototypes for routines in ecofflink.c (some are
+ called by gas, so they are public).
+ * bfd-in2.h: Rebuilt.
+ * Makefile.in (BFD_LIBS): Added ecofflink.o.
+ (CFILES): Added ecofflink.c.
+ (ecofflink.o): New target. Rebuilt dependencies.
+
+Mon Nov 22 22:26:42 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (hppa_object_p): Also recognize SHARED_MAGIC_CNX as
+ a valid magic number if it's been defined.
+
+Mon Nov 22 14:17:36 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_mkobject): Don't create .scommon section; linker
+ no longer requires it.
+ (ecoff_bfd_seclet_link, ecoff_sizeof_headers,
+ ecoff_write_object_contents): Don't treat .scommon section
+ specially.
+
+Mon Nov 22 10:54:27 1993 Fred Fish (fnf@cygnus.com)
+
+ Merged changes from kev@spuds.geg.mot.com (Kevin A. Buettner):
+ * bfd/config/delta88.mh (HDEFINES): Define this to be -DPTRACE_CORE.
+ * bfd/config/delta88.mh (HDEPFILES): Defined to be ptrace-core.o.
+ * bfd/ptrace-core.c: New file for dealing with core files with
+ start with the ptrace_user structure found on BCS compliant systems.
+ * bfd/targets.c (ptrace_core_vec): New vector.
+
+Mon Nov 22 02:33:12 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * Minimal support for reading SOM fixup streams. Allows
+ objdump -r to do something reasonable.
+ * som.c (som_get_reloc_upper_bound): Implement.
+ (som_canonicalize_reloc): Implement.
+ (som_set_reloc_info, som_slurp_reloc_table): New functions.
+
+Sun Nov 21 13:46:55 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hosts/lynx.h (FPRINTF_ALREADY_DECLARED): Define.
+ * hosts/sparclynx.h: Include lynx.h instead of duplicating it.
+
+Fri Nov 19 14:34:04 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-a29k.c (a29k_reloc): For R_IREL, don't left shift
+ signed_value before sign extending it. Don't subtract out
+ reloc_entry->address. This makes it compatible with what gas is
+ generating.
+
+ * elfcode.h (elf_fake_sections): Accept .sbss as the name for a
+ SHT_NOBITS sections.
+ (map_program_segments): Don't leave the loop after the first
+ SHT_NOBITS section.
+ (assign_file_positions_except_relocs): Only force sh_offset and
+ sh_addr to match modulo maxpagesize for a section which is not
+ SHT_NOBITS. Changed the method used to force page alignment after
+ a SHT_NOBITS section to only do it for the last such consecutive
+ section, and to really force page alignment.
+
+Fri Nov 19 04:02:01 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * coffcode.h (coff_slurp_symbol_table): Print more verbose message
+ in the case of an unknown (or unhandled) storage class.
+
+ * config/i386-lynx.mt (TDEFINES): FPRINTF_ALREADY_DECLARED should
+ not be defined here, since it is a host attribute, not a target
+ one.
+ * config/m68k-lynx.mt, config/sparc-lynx.mt: Ditto.
+
+ * coffcode.h (coff_bfd_reloc_type_lookup): Don't define if already
+ defined.
+
+ * coff-sparc.c: Define some relocations, based on ELF relocations.
+ (enum reloc_type, bfd_coff_generic_reloc, coff_sparc_howto_table,
+ struct coff_reloc_map, sparc_reloc_map,
+ coff_sparc_reloc_type_lookup): Borrowed from elf32-sparc.c and
+ elf.c, renamed.
+ (coff_bfd_reloc_type_lookup): Define to be coff_sparc_reloc_....
+ (rtype2howto): Index into coff_sparc_howto_table using
+ dst->r_type.
+
+Thu Nov 18 11:45:39 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config.bfd (mips*-*-irix5*): New target; use mipsbelf.
+ * configure.host (mips-sgi-irix5*) New host; use irix5 (no
+ hosts/irix5.h created; just use std-host.h).
+ * config/irix5.mh: New file; like irix4.mh, but don't use -G or
+ -lmalloc.
+ * Makefile.in: Rebuilt dependencies.
+
+ * ecoffswap.h: Changed type of internal pointers for swap out
+ functions to const *.
+
+ * elf32-mips.c (mips_elf_got16_reloc): New function. Handle GOT16
+ correctly for assembler, but linker support not implemented.
+ (elf_mips_howto_table): Use mips_elf_got16_reloc for GOT16.
+ (mips_elf_sym_is_global): New function; at least on Irix 5, all
+ non section symbols are considered global.
+ (elf_backend_sym_is_global): Define.
+ (mips_elf_final_write_processing): New function. Set the MIPS
+ architecture level correctly.
+ (elf_backend_final_write_processing): Define.
+ (mips_elf_section_from_shdr): Handle SHT_MIPS_OPTIONS.
+ (mips_elf_fake_sections): Set entsize of .mdebug or .reginfo
+ section to 1. Handle .options section.
+ (mips_elf_acom_section, mips_elf_acom_symbol,
+ mips_elf_acom_symbol_ptr): New static variables, used to build a
+ generic .acommon section to hold SHN_MIPS_ACOMMON symbols.
+ (mips_elf_symbol_processing): Handle SHN_MIPS_ACOMMON symbols by
+ putting them all in a global .acommon section.
+
+ * elfcode.h (bfd_section_from_shdr): Don't dump core if target
+ section has no ELF section data.
+ (elf_make_sections): Set addralign of reloc section to 4.
+ (elf_fake_sections): Likewise.
+ (map_program_segments): Don't consider section 0.
+ (assign_file_positions_except_relocs): Don't consider section 0.
+ In the main loop, skip the symtab and strtab sections, since their
+ positions are set elsewhere.
+ (swap_out_syms): Set addralign of symtab section to 4. Set
+ addralign of strtab sections to 1.
+ (assign_file_positions_for_relocs): Don't consider section 0.
+ (write_object_contents): Don't write out section 0.
+
+ * libelf.h (struct elf_backend_data): Added fields
+ elf_backend_sym_is_global and elf_backend_final_write_processing.
+ * elf32-target.h (elf32_bed): Added corresponding initializers.
+ * elf64-target.h (elf64_bed): Likewise.
+ * elfcode.h (sym_is_global): Take abfd argument. Call
+ elf_backend_sym_is_global if it is not NULL.
+ (elf_map_symbols): Pass abfd to sym_is_global.
+ (write_object_contents): Call elf_backend_final_write_processing
+ if it is defined.
+
+Wed Nov 17 18:43:28 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libecoff.h: Include coff/ecoff.h.
+ (struct ecoff_backend_data): Move external debugging information
+ fields into a single field pointing to an ecoff_debug_swap
+ structure.
+ (ecoff_data_type): Move debugging information fields into a single
+ field pointing to an ecoff_debug_info structure.
+ * coff-alpha.c, coff-mips.c, ecoff.c: Corresponding changes.
+
+Wed Nov 17 17:38:58 1993 Sean Eric Fagan (sef@cygnus.com)
+
+ * nlmswap.h: New file to swap fixed header. Included by NLM
+ backends.
+ * libnlm.h (struct reloc_and_sec): Define.
+ (struct nlm_backend_data): Add fields fixed_header_size,
+ nlm_read_import, nlm_write_import, nlm_swap_fhdr_in,
+ nlm_swap_fhdr_out.
+ (nlm_fixed_header_size, nlm_read_import_func,
+ nlm_write_import_func, nlm_swap_fixed_header_in_func,
+ nlm_swap_fixed_header_out_func, nlm_write_external_func): New
+ accessor macros.
+ * nlmcode.h: Use new functions.
+ * nlm32-i386.c: Provide new functions.
+ * nlm32-sparc.c: New file; SPARC NLM backend.
+
+Wed Nov 17 13:56:10 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * i386lynx.c (swap_std_reloc_in, swap_ext_reloc_in): Ignore
+ garbage bits appearing in the upper end of symbolnums.
+
+ * config/sparc-lynx.mt (TDEFINES): Add -DFPRINTF_ALREADY_DECLARED.
+
+Tue Nov 16 17:03:41 1993 Stu Grossman (grossman at cygnus.com)
+
+ * lynx-core.c (lynx_core_file_p): Change bfd_zalloc to bfd_alloc.
+ * m68klynx.c: Define core file macros.
+ * hosts/i386lynx.h, hosts/m68klynx.h, hosts/lynx.h: Move all
+ non-architecture specific stuff into lynx.h.
+
+Tue Nov 16 15:45:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * i386linux.c: Define new macro ZMAGIC_DISK_BLOCK_SIZE to 1024, and
+ change PAGE_SIZE to 4096.
+
+Mon Nov 15 11:48:08 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * Makefile.in (diststuff): New target.
+
+ * VERSION: Updated.
+
+Sun Nov 14 23:33:01 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_object_setup): Do not create dummy ".text", ".data",
+ and ".bss" sections.
+ (setup_sections): Do not set SEC_HAS_CONTENTS if a section's size
+ is zero. Recognize BSS type sections and turn off SEC_LOAD and
+ SEC_DATA (so binutils/size works). Set the correct value for
+ a section's _raw_size.
+ (som_slurp_symbol_table): Program entry points, and millicode are
+ also functions. Mark them as such. Also mark L$* symbols as
+ debugging symbols.
+
+ * bfd-in2.h: Rebuilt.
+
+Sat Nov 13 15:27:15 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_reloc_type_lookup): Add missing prototype. Returns
+ a pointer to constant data. Delete bogus #define which made the
+ function useless.
+
+ * som.c (som_prep_for_fixups): New function.
+ (som_write_fixups): New function.
+ (som_write_space_strings): New function.
+ (som_write_symbol_strings): New function.
+ (som_begin_writing): New function.
+
+Fri Nov 12 15:29:36 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_write_object_contents): Do not abort. Flesh out.
+ (som_set_section_contents): Do not abort. Flesh out.
+
+ * som.c (som_write_headers): New function.
+ (som_prep_headers): New function.
+ (som_build_and_write_symbol_table): New function.
+
+ * som.c (som_sizeof_headers): Add missing prototype.
+ (som_set_arch_mach): Do not abort.
+
+ * som.c (som_count_spaces): New function.
+ (som_count_subspaces): New function.
+ (compare_syms): New function.
+ (som_compute_checksum): New function.
+
+ * som.c (hppa_som_gen_reloc_type): New function.
+ (som_bfd_reloc_type_lookup): New function.
+
+ * som.c (try_prev_fixup): New function.
+ (som_reloc_skip): New function.
+ (som_reloc_addend): New function.
+ (som_reloc_call): New function.
+
+ * som.c (som_initialize_reloc_queue): New function.
+ (som_reloc_queue_insert): Likewise.
+ (som_reloc_queue_fix): Likewise.
+ (som_reloc_queue_find): Likewise.
+
+ * som.c (som_hppa_howto_table): SOM howto relocation table.
+ (hppa_som_reloc): New function.
+
+ * som.c (struct reloc_queue): New structure to keep track of
+ the last four multibyte relocations emitted.
+ (enum pa_symbol_type): Type to fully describe the symbol types
+ associated with .import/.export assembler directives.
+
+ * som.c: Include libhppa.h
+
+ * som.c (bfd_som_set_section_attributes): New function.
+ (bfd_som_set_subsection_attributes): Likewise.
+ (bfd_som_set_symboL_type): Likewise.
+ (bfd_som_attach_unwind_info): Likewise.
+ * som.h: Declare new exported functions.
+
+ * som.h (struct som_symbol): Add new fields to hold additional
+ information needed to build/write symbol tables and fixup streams.
+ (struct som_section_data_struct): Add new fields to hold additional
+ information needed to build/write space and subspace headers.
+ (som_symbol_data): New accessor macro for SOM symbol information.
+ (R_HPPA_*): Basic relocation types to be used by the assembler.
+
+Fri Nov 12 11:00:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * trad-core.c (trad_unix_core_file_p): If new hook
+ TRAD_CORE_ALLOW_ANY_EXTRA_SIZE defined, then skip the check for the
+ corefile being too big.
+ * hosts/i386sco.h: Define it.
+
+Thu Nov 11 15:16:28 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * bfd.c (struct _bfd): Add hppabsd_core_data.
+ * targets.c (target_vector): Add hppabsd_core_vec.
+ * hpux-core.c (hpux_core_core_file_p): Fail if an unknown core
+ section is encountered during core section scanning.
+ * hppabsd-core.c: New file.
+ * config/hppabsd.mh: Enable HPPA BSD core files.
+
+ * elf32-hppa.c (hppa_elf_reloc): Remove DEFUN crud. Remove code
+ which is either commented out or ifdef'd out. Add, update and
+ clean comments. Fix various indention and spacing problems. Handle
+ problems related to using "ble" to jump to a stub rather than "bl"
+ (%r31 is trashed by "ble", but not by "bl").
+ (NEW_INSTRUCTION): Put inside curly braces.
+ (CURRENT_STUB_OFFSET): Fix indention problems.
+ (hppa_elf_build_arg_reloc_stub): Fix indention and spacing problems.
+ Add, update and clean comments. Handle "ble" %r31 lossage problems.
+ (hppa_elf_build_long_branch_stub): Likewise.
+ (hppa_look_for_stubs_in_section): Likewise.
+ (hppa_elf_stub_check): Remove obsolete function.
+
+ * hppa_stubs.h: Add new instructions to deal with %r31 lossage
+ problems. Delete unused instructions.
+
+Tue Nov 9 11:40:27 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * m68klynx.c (TARGET_IS_BIG_ENDIAN_P): Define.
+
+Tue Nov 9 11:26:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (elf_object_p): Rather than looking through an array
+ of architectures, get the ELF EM_xxx code from the backend
+ information. Let the generic ELF target match any EM_xxx code not
+ matched by another ELF target. Call elf_backend_object_p to let
+ the backend do more checks and set global information.
+ * libelf.h (struct elf_backend_data): Added elf_machine_code and
+ elf_backend_object_p fields.
+ (struct bfd_elf_arch_map): Removed.
+ (bfd_elf_arch_map, bfd_elf_arch_map_size): Don't declare.
+ * elf32-target.h, elf64-target.h: Initialize elf_machine_code
+ field with ELF_MACHINE_CODE. Initialize elf_backend_object_p
+ field with elf_backend_object_p (if it is defined).
+ * elf32-gen.c, elf32-hppa.c, elf32-i386.c, elf32-i860.c,
+ elf32-m68k.c, elf32-m88k.c, elf32-mips.c, elf32-sparc.c,
+ elf64-gen.c (ELF_MACHINE_CODE): Defined.
+ * elf32-mips.c: Include ecoffswap.h to get ECOFF swapping
+ routines.
+ (mips_elf_object_p): Set the right machine number.
+ (mips_elf_ecoff_debug_swap): Defined.
+ (elf_backend_object_p): Defined to be mips_elf_object_p.
+ (elf_backend_ecoff_debug_swap): Defined to be
+ mips_elf_ecoff_debug_swap.
+ * elf.c (bfd_elf_arch_map, bfd_elf_arch_map_size): Removed.
+
+ * libbfd-in.h (target_vector, default_vector): Declare.
+ * libbfd.h: Rebuilt.
+ * format.c (target_vector, default_vector): Don't declare.
+
+ * elf32-mips.c (elf_mips_howto_table): Don't complain on overflow
+ for R_MIPS_26. Correct overflow detection requires matching the
+ upper four bits of the destination against the PC. From Ted Lemon
+ <mellon@pepper.ncd.com>.
+
+ * bout.c (b_out_reloc_type_lookup): Return type should point to
+ const data.
+ * coff-i960.c (coff_i960_reloc_type_lookup): Likewise.
+ * elf32-hppa.c (elf_hppa_reloc_type_lookup): Likewise.
+ * mipsbsd.c (MY(reloc_howto_type_lookup)): Likewise.
+ * coff-i386.c (coff_i386_reloc): Made howto const.
+ * oasys.c (oasys_write_data): Made how const.
+
+ * libelf.h: Added some comments.
+ (struct elf_backend_data): Added elf_backend_ecoff_debug_swap
+ field. Removed unused write_relocs field.
+ * elf32-target.h: Adjusted elf_backend_data initialization
+ accordingly.
+ * elf64-target.h: Corrected elf_backend_data initialization to
+ fill in all fields and to set elf_64_p to 1.
+
+Mon Nov 8 18:13:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (bfd_section_from_shdr): Remove duplicate assignment
+ to filepos in SHT_STRTAB case.
+ (assign_file_position_for_section): Set BFD section filepos as
+ well as ELF section sh_offset.
+
+ * reloc.c: Use const instead of CONST.
+ (bfd_perform_relocation): Make variable howto a const pointer.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+
+Mon Nov 8 12:19:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (realclean): Don't remove generated headers. Reverts
+ change of 2 Jul 1993.
+
+Mon Nov 8 06:08:31 1993 D. V. Henkel-Wallace (gumby@cirdan.cygnus.com)
+
+ * configure.bfd: make unixware equivalent to sysv4.
+
+ * config/i386-nlm.mt: bring in elf config; make it the default.
+
+Sun Nov 7 20:21:38 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * libbfd.c (bfd_put_8): Add parens around reference to "val"
+ argument.
+
+Fri Nov 5 21:45:09 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * hosts/i386mach3.h (HOST_SEGMENT_SIZE),
+ i386mach3.c (SEGMENT_SIZE, TEXT_START_ADDR): Correct values (?).
+
+Fri Nov 5 15:17:57 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coffcode.h (coff_write_object_contents): Zero out internal_a.
+
+Fri Nov 5 10:41:07 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h, archive.c, archures.c, bfd.c, cache.c, coffcode.h,
+ core.c, ctor.c, format.c, init.c, libbfd.c, opncls.c, reloc.c,
+ section.c, syms.c, targets.c:
+ Doc cleanup (spelling, punctuation, grammar, formatting).
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+Thu Nov 4 14:46:14 1993 John Gilmore (gnu@rtl.cygnus.com)
+
+ * bfd-in.h (bfd_get_cacheable, bfd_set_cacheable): New accessors.
+ * bfd.c, opncls.c: Improve comments on file descriptor cacheing.
+
+Thu Nov 4 08:54:30 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * From Pete Hoogenboom (hoogen@cs.utah.edu)
+ * elf32-hppa.c (hppa_elf_get_section_contents): Fix logic error
+ in last change. Always rebuild symbol extension section the first
+ time though if output sections exist (fixes ld -r problems).
+
+Thu Nov 04 08:08:46 1993 Jeffrey Wheat (cassidy@cygnus.com)
+
+ * Makefile.in: Add .PHONY for check and installcheck rules.
+
+Tue Nov 2 14:42:27 1993 Bill Cox (bill@tarkas.cygnus.com)
+
+ * libbfd-in.h (artdata): Use long, not time_t for portability, at
+ least to HPUX. File below is a derived file.
+
+Tue Nov 2 14:42:27 1993 Bill Cox (bill@tarkas.cygnus.com)
+
+ * libbfd.h (artdata): Use long, not time_t for portability, at
+ least to HPUX.
+
+Tue Nov 2 09:32:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.bfd: Use bigmips for mips*-*-bsd*.
+
+Mon Nov 1 14:30:09 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (elf_slurp_reloca_table, elf_slurp_reloc_table):
+ Handle symbol number of zero.
+
+ * reloc.c (enum bfd_reloc_code_real): Added
+ BFD_RELOC_MIPS_LITERAL, BFD_RELOC_MIPS_GOT16,
+ BFD_RELOC_MIPS_CALL16, BFD_RELOC_MIPS_GPREL32.
+ * bfd-in2.h: Rebuilt.
+ * coff-mips.c (mips_bfd_reloc_type_lookup): Handle
+ BFD_RELOC_MIPS_LITERAL.
+ * elf32-mips.c (mips_reloc_map): Handle new relocs.
+ (mips_elf_hi16_reloc, mips_elf_lo16_reloc): Rearrange _gp_disp
+ checks slightly.
+
+ * aout-target.h (MY_bfd_debug_info_start, MY_bfd_debug_info_end,
+ MY_bfd_debug_info_accumulat [sic]): Remove unused definitions.
+ (MY_bfd_get_relocated_section_contents, MY_bfd_relax_section,
+ MY_bfd_seclet_link): Define.
+ (MY_bfd_reloc_type_lookup): Rename from
+ MY_reloc_howto_type_lookup.
+ (MY_bfd_make_debug_symbol): Rename from MY_make_debug_symbol.
+ (MY(vec)): Use JUMP_TABLE rather than listing functions.
+ * hp300hpux.c (MY_get_symtab, MY_get_symtab_upper_bound,
+ MY_canonicalize_reloc, MY_write_object_contents): Don't define in
+ terms of MY, because that causes a recusive invocation of CAT when
+ expanded within JUMP_TABLE, and ANSI compilers don't expand
+ recursive macros.
+ * mipsbsd.c (MY_bfd_reloc_type_lookup): Rename from
+ MY_reloc_howto_type_lookup, and don't define in terms of MY.
+ (MY_canonicalize_reloc): Don't define in terms of MY.
+ (aout_mips_little_vec, aout_mips_big_vec): Use JUMP_TABLE rather
+ than listing functions.
+
+Mon Nov 1 09:12:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.bfd: Use m68k-elf for m68*-*-sysv4*.
+
+Sun Oct 31 09:35:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * targets.c: Move enum target_flavour outside of struct and change
+ the name to enum bfd_flavour. This means bfd clients can use it.
+ * bfd-in.h: Add macro bfd_get_flavour.
+ * bfd-in2.h: Rebuilt.
+
+ * som.c: Add comment about how abort() on corrupt executable is evil.
+
+Sat Oct 30 12:27:09 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (aout,slurp_reloc_table): Avoid a goto.
+
+Fri Oct 29 16:04:33 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * gen-aout.c, libbfd.c: exit(1) instead of exit(-1).
+
+Fri Oct 29 13:17:21 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd-in.h: Added commands for object file flag values.
+ * bfd-in2.h: Rebuilt.
+ * elfcode.h (elf_object_p): If type is ET_DYN, set DYNAMIC flag,
+ not EXEC_P.
+ * bout.c, coff-h8300.c, coff-sh.c: Add BFD_IS_RELAXABLE to
+ object_flags field for target vector.
+ * aix386-core.c, aout-adobe.c, aout-target.h, bout.c, coff-a29k.c,
+ coff-alpha.c, coff-apollo.c, coff-h8300.c, coff-h8500.c,
+ coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c, coff-mips.c,
+ coff-rs6000.c, coff-sh.c, coff-we32k.c, coff-z8k.c, hpux-core.c,
+ ieee.c, mipsbsd.c, nlm-target.h, oasys.c, osf-core.c, som.c,
+ srec.c, tekhex.c, trad-core.c: Remove DYNAMIC from object_flags
+ field for target vector.
+
+Thu Oct 28 20:02:31 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * hosts/std-host.h: Don't declare time; causes error on mach3.
+ * configure.in (i386mach3_vec): Require aout32.o stab-syms.o.
+
+Thu Oct 28 16:33:26 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ LynxOS and Sparc LynxOS changes:
+ * config.bfd: Recognize sparc-*-lynxos*.
+ * configure.host: Recognize sparc-*-lynxos*.
+ * configure.in: Recognize Sparc Lynx vectors.
+ * targets.c (sparclynx_aout_vec): Declare.
+ (sparclynx_coff_vec): Declare.
+ (target_vector): Add them.
+ * cf-i386lynx.c: New file, renamed from i386lynx-cf.c.
+ * cf-m68klynx.c: New file, renamed from m68klynx-cf.c.
+ * cf-sparclynx.c: New file, support for coff in Sparc LynxOS.
+ * coff-sparc.c: New file, basic Sparc coff support.
+ * sparclynx.c: New file, support for a.out in Sparc LynxOS.
+ * Makefile.in: Change filenames appropriately, add Sparc rules.
+ * coffcode.h (coff_set_arch_mach_hook): Recognize Sparc magic
+ number.
+ (coff_set_flags): Use LynxOS magic number for i386, m68k, and
+ Sparc LynxOS, set Sparc magic number for Sparcs.
+ * config/m68k-lynx.mt (SELECT_VECS): Remove redundant vector.
+ * config/sparc-lynx.mt: New file.
+ * hosts/i386lynx.h: Cosmetic improvements.
+ * hosts/m68klynx.h: Add ifdefs, #define of cfree.
+ * hosts/sparclynx.h: New file.
+
+Thu Oct 28 16:23:40 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ gcc -Wall lint:
+ * coff-h8300.c (h8300_reloc16_estimate): Declare return type.
+ Remove useless statement probably left by code copy.
+ * cpu-i960.c (compatible): Fully bracket matrix initializer.
+ * elf32-hppa.c (hppa_elf_build_arg_reloc_stub): Use bfd_xmalloc
+ rather than xmalloc. Use realloc and check the return value
+ rather than xrealloc.
+ (hppa_elf_get_section_contents): Add some casts.
+ * elf32-i386.c (elf_i386_reloc_type_lookup): Remove unused
+ variable. Add default case to switch.
+ * hp300hpux.c: Declare aout_32_write_syms.
+ * i386bsd.c, i386linux.c, netbsd386.c (N_SHARED_LIB): Define as 0
+ (definition from aout/aout64.h is always 0 anyhow).
+ * i386lynx.c (swap_std_reloc_in): Remove unused variable.
+ * ieee.c (ieee_write_id): length can never be negative.
+ (read_id): Likewise.
+ (ieee_archive_p): Remove unused variable.
+ * libcoff-in.h (bfd_perform_slip): Declare.
+ * libcoff.h: Rebuilt.
+ * oasys.c (oasys_write_sections): Remove zero initialization of
+ static structure.
+ * reloc16.c: Indentation change.
+
+Wed Oct 27 16:51:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in, config/i386-mach3.mt: Update for new configuration
+ (--with-targets and so on).
+ * hosts/i386mach3.h: Declare errno.
+ * targets.c: Declare i386mach3_vec.
+
+Wed Oct 27 12:18:07 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlmcode.h (nlm_swap_auxiliary_headers_in,
+ nlm_swap_auxiliary_headers_out): Handle sharedDebugRecordOffset
+ and sharedDebugRecordCount fields.
+
+Tue Oct 26 16:21:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * targets.c (target_vector): Remove SCO_CORE. On Sep 11 1993,
+ we started using trad-core.c for SCO instead.
+
+ * targets.c (target_vector): Re-enable generic ELF and NLM targets.
+
+Tue Oct 26 16:53:12 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (assign_file_position_for_section): Align sh_offset to
+ sh_addralign (this is what UnixWare does, and it shouldn't hurt).
+
+Tue Oct 26 10:16:54 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ From Jeff Law and Pete Hoogenboom at Utah:
+
+ * elf32-hppa.h (hppa_elf_stub_finish): Add prototype.
+ (ELF32_HPPA_R_ARG_RELOC): Renamed without the ELF32 prefix
+ and moved into libhppa.h. All references changed.
+ (ELF32_HPPA_R_CONSTANT, ELF32_HPPA_R_ADDEND): Likewise.
+ (get_opcode and opcode defines): Move into libhppa.h
+ * elf32-hppa.c (hppa_elf_insn2fmt): Rename and move info
+ libhppa.h.
+ * libhppa.h (HPPA_R_*): Moved here. Reformatted slightly to make
+ for easier reading.
+ (get_opcode): Moved here. FIXME! this really should be a C function
+ inside the opcode library!
+ (bfd_hppa_insn2fmt): Likewise.
+
+ * targets.c (target_vector): Enable elf32-hppa vector.
+
+ * elf32-hppa.c (hppa_elf_get_section_contents): Add new comments
+ and clarify existing comments. Do not use DEFUN to declare this
+ function. Fix numerous indention problems. Correctly handle cases
+ where symbol extension section may need to be read from disk,
+ read from memory, or built then read from memory.
+
+ * elf32-hppa.h: Reformat with gnu-indent and hand fix numerous
+ formatting and indention problems gnu-indent can not handle.
+ Clarify some comments about relocation types. Comment basic
+ relocation "classes". Group PARAM declarations together.
+ (HPPA_SXT_{NULL, SYMNDX, RG_RELOC}): Make members of a new
+ enumerated type rather than #defines.
+
+Tue Oct 26 02:40:46 1993 Stu Grossman (grossman at cygnus.com)
+
+ * som.c (hppa_object_setup): Set SEC_CODE for .text section so
+ that GDB can figure out text_start and text_end.
+
+Mon Oct 25 16:05:23 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Fix up warnings from gcc -Wall:
+ * coffgen.c (coff_print_symbol): Use %lx and cast n_value to
+ unsigned long. Use %ld for tagndx. Use %lx for offset + vma and
+ cast it to unsigned long.
+ * ecoff.c (ecoff_emit_aggregate): Use %ld.
+ (ecoff_print_symbol): Use %ld, and cast indx and sym_base to long.
+ * coffcode.h (dummy_reloc16_estimate): Specify return type.
+
+ * libbfd.c (bfd_write): If not everything is written out, set
+ bfd_error to system_call_error. If the return value is
+ non-negative, set errno to ENOSPC (if ENOSPC is defined).
+ (bfd_seek): If the seek fails, set bfd_error to system_call_error.
+ (bfd_generic_set_section_contents): For a bad offset + count, set
+ bfd_error to bad_value.
+ * seclet.c (rel): Don't abort. Instead, return false.
+
+Mon Oct 25 09:59:37 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * aoutx.h (reloc_type_lookup): Handle BFD_RELOC_SPARC_WDISP22.
+
+Fri Oct 22 20:35:54 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * config.bfd: handle mips*-* instead of mips-*, use mips*el
+ instead of mips-*-*l
+
+Fri Oct 22 14:03:33 1993 Mark Eichin (eichin@cygnus.com)
+
+ * m68k-lynx.mt, i386-lynx.mt (TDEFINES): set
+ FPRINTF_ALREADY_DECLARED because the objdump.c declaration of
+ fprintf collides with the native one.
+
+Fri Oct 22 11:50:25 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * targets.c (target_vector): Enable MIPS ELF vectors.
+
+Fri Oct 22 07:51:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.bfd: Use bigmips for mips-sony-bsd*.
+
+ * configure.host, config.bfd: Add * to end of all OS names.
+
+Thu Oct 21 12:16:26 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * elfcode.h (FILE_ALIGN): Renamed from EALIGN, to avoid conflict
+ with Ultrix header files.
+
+ * som.h (struct som_section_data_struct): Renamed from
+ som_section_data to avoid conflict with macro by that name.
+
+ Changes from Jeff Law and Peter Hoogenboom at Utah:
+
+ * elf32-hppa.c (hppa_elf_reloc): Target register for a 'jump
+ in delay slot' optimization in combination with a long call
+ stub should always be r31.
+
+ * elf32-hppa.c: (hppa_elf_relocate_insn): To be consistent
+ across all relocation types, retrieve instruction addends from
+ the relocation entry rather than from the instruction itself.
+
+ * elf32-hppa.c: (hppa_elf_relocate_insn): Fix a relocation
+ error that only occurred when the addend of an 'addil' or
+ 'ldil' was larger than 21 bits and very close to a 2K byte
+ boundary.
+
+ * elf32-hppa.c: (hppa_elf_reloc): Handle the optimization in
+ which a jump is placed in the delay slot of a function call.
+ The jump was being accomplished via an adjustment to the
+ return pointer. This optimization would break the long call
+ stub code, if there was any.
+
+ * elf32-hppa.c: (hppa_elf_build_long_branch_stub): Corrections
+ to long branch stubs to avoid use of general register 2.
+
+ * hppa_stubs.h: New stub instructions.
+
+ * elfcode.h: Declare bfd_elf_find_section.
+
+ * som.h (som_section_data): Add new "subspace_index" field.
+
+ * som.c (setup_sections): Save the original SOM subspace index
+ in the BFD section associated with that subspace.
+ (som_get_symtab_upper_bound): Implement.
+ (som_get_symtab): Implement.
+ (som_print_symbol): Implement.
+ (som_slurp_string_table): New function to read a string table
+ from a SOM object file.
+ (som_section_from_subspace_index): New function to return the
+ section which corresponds to a SOM subspace index.
+ (som_slurp_symbol_table): New function to read the symbol
+ table from a SOM object file.
+ (som_make_empty_symbol): Check for errors from bfd_zalloc.
+ (som_new_section_hook): Initialize subspace_index field to
+ -1 instead of 0.
+
+ * som.c (som_object_setup): Fix polarity of test to set HAS_RELOC.
+ Set EXEC_P for executables.
+ (setup_sections): Correctly identify when a section has
+ relocations.
+ (log2): New function.
+ (setup_sections): Correctly convert between SOM alignments and BFD
+ alignments.
+
+ * som.c (setup_sections): Do not set SEC_ALLOC or SEC_LOAD
+ for sections which correspond to SOM spaces, doing so confuses
+ many utilities. Set assorted SEC_* flags for SOM subspaces
+ which correspond to BFD sections.
+
+ * elf32-hppa.c: (elf32_hppa_backend_fake_sections): The stab
+ string table should have sh_type == SHT_STRTAB. Add
+ processing to make it so.
+
+ * elfcode.h: (bfd_section_from_shdr): String tables (other
+ than .strtab) were not getting the file offsets recorded, so
+ they could not be read from disk.
+
+ * elfcode.h: (elf_make_sections): Leave the sh_addr field of
+ the section header and the vma field of a section at 0 if the
+ section is not part of the program execution image. (e.g.,
+ .stab)
+
+ * som.[hc]: Change target vector prefix from "hppa" to "som".
+ Consistently use obj_som prefix to access fields in backend data
+ structures. Fix all callers/references.
+
+ * som.h: Do not include files only needed for core file reading here.
+ Include a.out for both HOST_HPPAHPUX and HOST_HPPABSD. Delete
+ forward structure declarations, they are unnecessary.
+ (struct somdata): Delete aux_hdr, and hp_symbol_entry_size fields.
+ Change "symbols" to "symtab". Add "stringtab" and "reloc_filepos"
+ fields for future use. Change obj_som_* macros as appropriate.
+ (som_section_data): New structure to keep SOM specific information
+ about BFD sections (for future use).
+
+ * som.c: Provide PARAMS declarations for all functions currently
+ in this file.
+ (struct container): Delete unwanted structure definition.
+ (som_object_setup): Add comments. Use som_mkobject to allocate
+ SOM specific information in the BFD; use information from the
+ file and (possibly empty) auxiliary headers to initialize this
+ information. Delete redundant bfd_get_symcount (abfd) "calls".
+ (setup_sections): Return type is now boolean, fix return statements.
+ "Fix" handling of BSS like subspaces in the computation of the
+ containing space's size. If the subspace has relocations, set the
+ appropriate BFD section flags and record the index into and the
+ size of the fixup stream. Always return a value.
+ (som_object_p): Set bfd_error appropriately if errors are detected
+ from bfd_{read,seek} functions. Handle EXECLIBMAGIC type files.
+ Do not try to read a non-existant auxiliary header.
+ (som_mkobject): Flesh out.
+ (som_section_hook): Allocate space to hold SOM specific information
+ about sections.
+
+Thu Oct 21 12:41:34 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ gcc -Wall lint:
+ * coff-h8300.c, coffcode.h: Change shrink parameter
+ in *_reloc16_estimate to unsigned to match prototype.
+ * archive.c: Avoid "/*" in comment.
+
+Thu Oct 21 13:05:16 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * dep-in.sed: Create our own line breaks for a more aesthetic
+ Makefile.
+ * Makefile.in: Rebuilt dependencies.
+
+ * elf32-mips.c: Include "seclet.h".
+ (mips_elf_fake_sections): Force size of .reginfo section to sizeof
+ Elf32_External_RegInfo.
+ (mips_elf_seclet_link): New function. Link the .reginfo section
+ specially, and pass everything else to the generic routine.
+ (bfd_elf32_bfd_seclet_link): Define macro.
+ * elf32-target.h: If bfd_elf32_bfd_seclet_link is already defined,
+ don't override it.
+
+Wed Oct 20 12:22:37 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libnlm.h (nlm_backend_data): Added signature field.
+ (nlm_signature): New macro.
+ * nlmcode.h (nlm_object_p, nlm_write_object_contents): Use the NLM
+ signature from the backend rather than the constant NLM_SIGNATURE.
+ * nlm32-i386.c (nlm32_i386_backend): Initialize signature field.
+
+ * aoutf1.h (MACHTYPE_OK): Accept M_UNKNOWN.
+ (NAME(sunos,set_arch_mach)): Treat M_UNKNOWN as 68000, not 68020.
+
+Wed Oct 20 10:28:27 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/i386bsd.h [__bsdi__]: Define HOST_DATA_START_ADDR.
+
+Wed Oct 20 10:10:07 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * Makefile.in (HFILES): New variable, for use in "make dep".
+ (.dep): Depend on $(CFILES) and $(HFILES). Delete .dep1 and
+ remake it, so that "$?" is complete.
+ (.dep1): Don't need to remove .dep1 first.
+ (dep.sed): Depend on config.status, not Makefile.
+ (CFILES): Add nlm.c.
+
+Tue Oct 19 15:26:26 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-alpha.c: Implemented reloc handling for the linker, made
+ various other related changes.
+ * libecoff.h (ecoff_backend_data): Added rdata_in_text field.
+ Renamed finish_reloc to adjust_reloc_in. Added adjust_reloc_out
+ field.
+ (ecoff_bfd_get_relocated_section_contents): Don't define.
+ * ecoff.c (ecoff_sec_to_styp_flags, ecoff_styp_to_sec_flags):
+ Handle .lita section.
+ (ecoff_slurp_reloc_table): Handle RELOC_SECTION_FINI.
+ finish_reloc backend field renamed to adjust_reloc_in.
+ (ecoff_bfd_seclet_link): Adjust number of aux entries to
+ debug_align boundary.
+ (ecoff_compute_section_file_positions): If rdata_in_text put
+ .rdata section in text segment, not data segment. Put .pdata
+ section in text segment.
+ (ecoff_write_object_contents): Likewise. Also, call
+ adjust_reloc_out, and handle .lita, .xdata, .pdata, .fini and
+ absolute sections when writing out relocs.
+ * coffswap.h (coff_swap_aouthdr_out): For ALPHAECOFF, output 2 for
+ bldrev field, as on Alpha OSF/1. Padding field is now 2 bytes.
+ * coff-mips.c (mips_ecoff_swap_reloc_out): Added assertion.
+ (mips_adjust_reloc_in): Renamed from mips_finish_reloc.
+ (mips_adjust_reloc_out): New function (does nothing).
+ (mips_ecoff_backend_data): Initialize new fields.
+ (ecoff_bfd_get_relocation_section_contents): Define to be
+ bfd_generic_get_relocated_section_contents.
+
+ * reloc.c (bfd_perform_relocation): Added casts to avoid Alpha
+ OSF/1 cc bug.
+
+Thu Oct 14 01:10:35 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Add comments attempting to
+ explain PC relative relocations.
+
+ * coffcode.h (styp_to_sec_flags): Don't set SEC_DEBUGGING until it
+ is made to work.
+ (coff_compute_section_file_positions): Remove check for
+ USE_DISCARDED_SECTIONS_COUNT.
+ * coff-i386.c: Don't define USE_DISCARDED_SECTIONS_COUNT. Basing
+ it on host defines is wrong.
+
+ * ecoff.c (ecoff_bfd_seclet_link): Don't link a .reginfo section.
+ (ecoff_write_object_contents): Don't require the .reginfo section
+ to be a particular size.
+
+Wed Oct 13 18:39:03 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (dep-in): New rule, for editing dependencies into
+ Makefile.in in $(srcdir). Use move-if-change.
+ (.dep1, dep): Use move-if-change.
+ (CFILES): Add coff-apollo.c.
+
+ Sun Oct 10 18:02:56 1993 Troy Rollo (troy@cbme.unsw.EDU.AU)
+
+ * Makefile.in: Recognise new file, coff-apollo.o
+
+ * coff-apollo.c: New file
+
+ * coffcode.h: Recognise apollo magic numbers and writable text
+
+ * coffswap.h: Swap Apollo optional header entries
+
+ * config.bfd: Add line for Apollo
+
+ * configure.host: Replace apollo68b and apollo68v with Apollo
+
+ * configure.in: Recognise apollocoff_vec
+
+ * targets.c: Likewise
+
+ * config/apollo.mh, config/apollo.mt: New files
+
+ * hosts/apollo68.h: Remove inclusion of strings.h
+
+Wed Oct 13 14:28:17 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * coff-i386.c (i3coff_object_p): Now static.
+
+ * Makefile.in: Updated dependencies.
+ (.dep, .dep1, dep.sed): New targets, to make "make dep" work
+ better.
+ * dep-in.sed: New file.
+
+ * m68klynx-cf.c (ONLY_DECLARE_RELOCS): Define, to avoid name
+ conflicts when "--with-targets=all".
+ * coff-m68k.c (m68kcoff_howto_table, m68k_rtype2howto,
+ m68k_howto2rtype): Rename via macros to keep namespace clean.
+ * configure.in: For m68klynx_coff_vec, include coff-m68k.o for
+ now.
+
+Tue Oct 12 17:03:27 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-mips.c: Extensive additions to do relocations and to
+ handle MIPS specific sections.
+ * libelf.h (elf_backend_data): Pass fourth argument to
+ elf_backend_section_from_bfd_section to permit it to control the
+ section index to use.
+ (elf_obj_tdata): Add gp and gp_size fields.
+ (elf_gp, elf_gp_size): New accessor macros.
+ * elfcode.h: Removed a number of unused local variables.
+ (elf_fake_sections): Clear section header before calling
+ elf_backend_fake_sections, not after.
+ (prep_headers): Return true at end.
+ (elf_section_from_bfd_section): Pass retval argument to
+ elf_backend_section_from_bfd_section.
+ * elf32-hppa.c (elf32_hppa_backend_section_from_bfd_section):
+ Accept and ignore new retval argument.
+ * bfd.c: Include libelf.h.
+ (bfd_set_gp_size): Handle ELF targets.
+ * Makefile.in (bfd.o): Depends upon libelf.h.
+ (elf32-mips.o): Depends upon $(INCDIR)/elf/mips.h.
+
+Mon Oct 11 17:25:18 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_mkobject): Check bfd_make_section return value.
+ (ecoff_mkobject_hook): New function.
+ (ecoff_new_section_hook, ecoff_sizeof_headers,
+ ecoff_compute_section_file_positions, ecoff_set_section_contents,
+ ecoff_write_object_contents): Handle dummy REGINFO section.
+ (ecoff_get_section_contents): New function to handle reading
+ REGINFO section.
+ * libecoff.h (ecoff_get_section_contents): Change from macro
+ definition to function prototype.
+ (ecoff_mkobject_hook): New prototype.
+ * coff-alpha.c (alpha_ecoff_mkobject_hook): Removed.
+ (alpha_ecoff_backend_data): Use ecoff_mkobject_hook.
+ * coff-mips.c (mips_ecoff_mkobject_hook): Removed.
+ (mips_ecoff_backend_data): Use ecoff_mkobject_hook.
+
+Fri Oct 8 15:25:33 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * libbfd.c (bfd_get*32, bfd_get*64): Prevent ANSI sign extension
+ by casting the most significant byte to bfd_vma.
+
+Fri Oct 8 02:34:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.in: Do not define SELECT_VECS, SELECT_ARCHITECTURES
+ if configuring --with-targets=all.
+
+Thu Oct 7 17:34:07 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * aoutx.h (howto_table_std): Correct the "size" field in some
+ entries.
+
+ * reloc.c (reloc_howto_type): Change documentation to dispel any
+ notion that the "size" field is a power-of-two indicator.
+
+Thu Oct 7 10:50:38 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * coffswap.h: (bfd_swap_reloc_in): a symndx is signed.
+
+ Make support for relaxing more generic.
+ * reloc16.c: Add new target entry - bfd_coff_reloc16_estimate,
+ fix bit rot.
+ * libcoff.h, libcoff-in.h: declarations. Prototypes
+ * coffcode.h (bfd_coff_std_swap_table): Add calls to
+ coff_reloc_16_extra_cases and coff_reloc16_estimate.
+ (dummy_reloc16_estimate): New function.
+ * coff-h8300.c (h8300_reloc16_estimate): New function
+
+Thu Oct 7 14:24:13 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elfcode.h (EALIGN): Define, dependent on ARCH_SIZE.
+ (align_file_position): New function.
+ (elf_locate_sh): Disabled function deleted.
+ (assign_file_positions_for_symtab_and_strtabs): Align position,
+ then place symtab, then do other sections.
+ (map_program_segments): Align program header.
+ (assign_file_positions_except_relocs): Align section headers.
+ (assign_file_positions_for_relocs): Align relocation sections.
+
+Tue Oct 5 10:44:32 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.host: Recognize hppa*-*-hiux* (currently synonym for hpux).
+ Change other hppa entries to use -*- not -hp-.
+ * config.bfd: Recognize hppa*-*-hiux* (currently synonym for hpux).
+
+ * coff-rs6000.c, cpu-rs6000.c, rs6000-core.c: Change non-ASCII
+ characters in comment to octal escapes.
+
+Sun Oct 3 12:35:15 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * coff-i386lynx.c: Removed, name too long.
+ * i386lynx-cf.c: New file, was coff-i386lynx.c.
+ * configure.in: Reflect file name changes.
+ * Makefile.in: Mention Lynx-related files.
+
+ * i386lynx.c (lynx_32_swap_ext_reloc_in): get reloc bits in i386
+ Lynx-specific way.
+
+ * m68klynx-cf.c: New file, defines coff format for M68K LynxOS.
+ * m68klynx.c: Remove coff vector definition, now in m68klynx-cf.c.
+
+ * coffcode.h (sec_to_styp_flags): Set section flag to STYP_INFO
+ for .stab, .stabstr and .debug sections, and set SEC_DEBUGGING for
+ sections of type STYP_INFO. (from Minh Tran-Le)
+ (coff_compute_section_file_positions): Add discarded_sections_count
+ to abfd->section_count, which helps `strip' keep the size
+ of the executable header constant.
+ * coff-i386.c (discarded_sections_count): New variable, initialized
+ to zero. For use by `strip'. Currently being used only in aix386
+ coff, but may be useful for other coff systems. (from Minh Tran-Le)
+
+ * coffswap.h (coff_swap_filehdr_out): Added a missing cast.
+
+ * archive.c: Cosmetic improvements.
+ * opncls.c: Cosmetic improvements.
+ (new_bfd): Removed redundant structure slot init.
+
+Sat Oct 2 18:48:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config/news-mips.mh, hosts/news-mips.h: New files.
+ * configure.host: Use news-mips for mips-sony-bsd*.
+
+Fri Oct 1 13:14:17 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * configure.in: i386lynx_coff_vec requires coff-i386lynx.o.
+ * coff-i386lynx.c: New file, defines Lynx target vector and name,
+ includes coff-i386.c.
+ * coff-i386.c (i386coff_vec): Allow redefinition of target vector
+ symbol and name, if TARGET_SYM and/or TARGET_NAME are defined.
+ * i386lynx.c: Remove coff vector definition entirely.
+ (lynx_32_swap_ext_reloc_in): Define.
+ (lynx_32_swap_std_reloc_in): Define, get reloc bits in i386
+ Lynx-specific way.
+ (lynx_32_swap_ext_reloc_out): Define.
+ (lynx_32_swap_std_reloc_out): Define.
+ (lynx_32_slurp_reloc_table): Define, call Lynx swapping fns.
+ (lynx_32_squirt_out_relocs): Define, call Lynx swapping fns.
+ (lynx_32_canonicalize_reloc): Define, call Lynx swapping fns.
+ (WRITE_HEADERS): Define, call Lynx swapping fns.
+
+ * config/i386-lynx.mt (SELECT_VECS): Remove redundant vector.
+
+Thu Sep 30 17:50:52 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * reloc.c (bfd_reloc_code_type): Add linkage-table relative
+ relocations of size 8, 16, 32. Sort generic relocs by type rather
+ than size. Added a little documentation too.
+
+ * aoutx.h (howto_table_std): Add BASE16 and BASE32 relocs.
+ (TABLE_SIZE): New macro.
+ (reloc_type_lookup): Handle BFD_RELOC_{16,32}_BASEREL for std
+ relocs.
+ (swap_std_reloc_out): Write baserel relocs correctly.
+ (swap_std_reloc_in): Handle r_baserel field. Assert that
+ r_jmptable and r_relative fields are clear, and that the computed
+ index does refer to a defined entry of the howto table.
+
+Tue Sep 28 14:47:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * section.c (bfd_make_section_anyway): New function.
+ * section.c: Change comments to say several sections can have
+ the same name.
+ * bfd-in2.h: Re-generate to reflect above change.
+ * coffgen.c (make_a_section_from_file): Call bfd_make_section_anyway
+ if still no section after the bfd_coff_make_section_hook.
+ * coffcode.h: Add comment about TWO_DATA_SECS.
+
+Tue Sep 28 03:22:24 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * ecoff.c (ecoff_slurp_symbolic_info): Always determine raw_size
+ explicitly.
+ * ecoff.c (ecoff_sec_to_styp_flags, ecoff_styp_to_sec_flags): Handle
+ .fini section.
+
+Mon Sep 27 18:29:18 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * config.bfd configure.host: Match on *-lynxos* for LynxOS,
+ add m68*-*-lynxos*.
+ * configure.in : Replaced i386lynx_vec with i386lynx_aout_vec
+ and i386lynx_coff_vec.
+ Added m68klynx_aout_vec and m68klynx_coff_vec.
+ * targets.c (target_vector): Removed i386lynx_vec, added
+ {i386,m68k}lynx_{aout,coff}_vec.
+ * i386lynx.c: Added copy of i386coff.c, renamed bfd target to
+ i386lynx_coff_vec.
+ * m68klynx.c: New file.
+ * config/i386-lynx.mt: Replaced i386lynx_vec with i386lynx_aout_vec
+ and i386lynx_coff_vec.
+ * config/m68k-lynx.mt: New file.
+ * hosts/i386lynx.h: Added definition of cfree as free (from Eichin).
+ * hosts/m68klynx.h: New file.
+
+Mon Sep 27 18:00:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * archive.c: Define offsetof here.
+ * hosts/*.h: Don't define it here.
+
+Mon Sep 27 19:09:27 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (bfd_section_from_shdr): Set filepos for SHT_STRTAB
+ section.
+
+Fri Sep 24 15:47:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hpux-core.c: Add comment about hpux version 7.
+
+Fri Sep 24 16:50:26 1993 Stu Grossman (grossman at cygnus.com)
+
+ * lynx-core.c (lynx_core_file_p): Change per-thread register
+ section names from .regXXX to .reg/XXX to avoid parsing ambiguity
+ in gdb/corelow.c. Create alias .reg section for the currently
+ running thread.
+
+Fri Sep 24 13:22:32 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libecoff.h (ecoff_backend_data): Removed big_magic and
+ little_magic fields.
+ * coff-alpha.c (alpha_ecoff_backend_data): Removed initialization
+ of big_magic and little_magic.
+ * coff-mips.c (mips_ecoff_bad_format_hook): Make sure magic number
+ matches endianess of bfd.
+ (mips_ecoff_backend_data): Removed initialization of big_magic and
+ little_magic.
+ * ecoff.c (ecoff_set_arch_mach_hook): Set MIPS machine number
+ based on magic number. Support r4000 magic numbers.
+ (ecoff_get_magic): New function.
+ (ecoff_write_object_contents): Use ecoff_get_magic, not fields in
+ the backend structure.
+ * cpu-mips.c (arch_info_struct): Added case for r6000.
+
+ For MIPS configurations put both big and little endian versions in
+ the list of targets; the code is getting compiled in anyhow.
+ * bigmips.mt (SELECT_VECS): Define to be ecoff_little_vec.
+ * decstation.mt (SELECT_VECS): Define to be ecoff_big_vec.
+ * mipsbelf.mt (SELECT_VECS): Define to be bfd_elf32_littlemips_vec.
+ * mipslelf.mt (SELECT_VECS): Define to be bfd_elf32_bitmips_vec.
+ * riscos.mt (SELECT_VECS): Define to be ecoff_little_vec.
+
+Fri Sep 24 00:42:23 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * osf-core.c: New file for OSF/1 core file support.
+ * config/alphaosf.mh (HDEFINES): Add -DOSF_CORE.
+ (HDEPFILES): Set to osf-core.o.
+ * bfd-in2.h (union tdata): Add osf_core_data member.
+ * targets.c: If OSF_CORE is defined, add osf_core_vec to target list.
+ * Makefile.in (OPTIONAL_BACKENDS): Add osf-core.o.
+ (osf-core.o): New dependency.
+
+Thu Sep 23 21:04:53 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * TODO: Remove note about making --with-bfd-targets use canonical
+ target configuration name (already done); reword item about
+ separating reading and writing stuff to not refer to a
+ non-existent item.
+
+ * ecoff.h (ecoff_set_arch_mach_hook): Accept MIPS_MAGIC_LITTLE2
+ and MIPS_MAGIC_BIG2.
+
+Thu Sep 23 11:06:34 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * gen-aout.c (main): Output newline after end of comment, not
+ before. (Reported by Jonathan Stone,
+ jonathan@oscar.stanford.edu).
+
+Thu Sep 23 10:48:27 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * archive.c (compute_and_write_armap): Put weak symbols in the
+ armap.
+
+ * elfcode.h (fix_up_strtabs): Set sh_entsize for the .stab
+ section, not the .stabstr section. Set the type of the .stabstr
+ section to SHT_STRTAB.
+ (elf_section_from_bfd_section): Handle SHT_STRTAB sections.
+
+ * section.c (SEC_DEBUGGING): New section flag.
+ * elfcode.h (bfd_section_from_shdr): If section is SHT_PROGBITS,
+ and the name starts with .debug, .line or .stab, set
+ SEC_DEBUGGING. If SHT_STRTAB, check for .debug and .stab.
+ * elf32-target.h (TARGET_BIG_SYM, TARGET_LITTLE_SYM): Added
+ SEC_DEBUGGING to section_flags.
+ * elf64-target.h (TARGET_BIG_SYM, TARGET_LITTLE_SYM): Added
+ SEC_DEBUGGING and SEC_CODE to section_flags.
+ * bfd-in2.h: Updated.
+
+Wed Sep 22 16:34:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.c (tdata): Add lynx_core_data.
+
+ * ecoff.c (ecoff_compute_section_file_positions): Set filepos for
+ sections with SEC_LOAD set, even if SEC_HAS_CONTENTS is clear.
+ (ecoff_write_object_contents): Don't set scnptr to zero just
+ because size of section is zero. Needed for Irix 4.0.5F.
+
+Wed Sep 22 09:49:32 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.bfd: Use i960-bout, not i960-coff for i960-*-nindy*.
+
+Wed Sep 22 07:34:09 1993 Stu Grossman (grossman at cygnus.com)
+
+ * Makefile.in (OPTIONAL_BACKENDS): Add lynx-core.o.
+ * bfd-in2.h (tdata): Add lynx_core_data;
+ * config.bfd configure.host: Get rid of superfluous netbsd and
+ lynxos entries.
+ * configure.in: Add lynx-core.o to Lynx config.
+ * i386lynx.c: Add defs for core file support.
+ * lynx-core.c: New file with Lynx core file support.
+ * hosts/i386lynx.h: Move lots of host specific includes to here.
+ Add def of HOST_LYNX. Remove unnecessary defs.
+
+Mon Sep 20 19:18:10 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (bfd_section_from_shdr): Only set SEC_DATA for a
+ SHF_PROGBITS or SHT_STRTAB section if SEC_ALLOC is set. Never set
+ SEC_DATA for a SHF_NOBITS section.
+
+ * nlm32-i386.c (nlm_i386_mangle_relocs): Check SEC_LOAD rather
+ than SEC_CODE | SEC_DATA. Add some casts to avoid warnings.
+ * nlmcode.h: Add some casts to avoid warnings.
+ (nlm_write_object_contents): Ignore relocs for sections that are
+ neither code nor data. Just use the symbol value for debugging
+ symbols; don't offset by the section vma.
+
+Fri Sep 17 18:08:55 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Don't return an error when
+ performing a reloc against an undefined weak symbol.
+ * syms.c (bfd_print_symbol_vandf): Show value of BSF_WEAK rather
+ than obsolete BSF_EXPORT.
+
+Fri Sep 17 02:04:31 1993 John Gilmore (gnu@cygnus.com)
+
+ * hosts/{alphaosf.h, amix.h, apollo68.h, apollov68.h,
+ decstation.h, delta88.h, dgux.h, dose.h, go32.h, harris.h,
+ hp300.h, hp300bsd.h, hppabsd.h, hppahpux.h, i386aix.h, i386bsd.h,
+ i386linux.h, i386lynx.h, i386v.h, i386v4.h, irix3.h, irix4.h,
+ mipsbsd.h, ncr3000.h, rs6000.h, rtbsd.h, solaris2.h, sparc-ll.h,
+ std-host.h, stratus.h, sun3.h, sysv4.h, tahoe.h, ultra3.h,
+ vaxult.h, vaxult2.h, we32k.h}: Make sure that "offsetof" is
+ defined on all hosts, now that archive.c uses it.
+
+Thu Sep 16 18:20:30 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (elf_map_symbols): Create section symbols for all
+ sections, not just allocated sections; debugging sections can have
+ relocs.
+ (elf_symbol_from_bfd_symbol): If there is an output section, use
+ the section index from that rather than the input section.
+
+Thu Sep 16 12:20:50 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * libbfd-in.h (bfd_flush, bfd_stat): Reflect John's changes to
+ libbfd.h, which is regenerated from this file.
+
+ * bfd-in.h (symtype): Deleted typedef.
+
+Wed Sep 15 11:48:37 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libbfd.c (COERCExx): Cast x to bfd_signed_vma before doing the
+ xor and subtract. Otherwise it will not sign extend if the type
+ of bfd_vma is larger than int.
+
+ * ecoffswap.h (ecoff_swap_pdr_in): Get regoffset, iopt, fregoffset
+ and frameoffset as signed numbers. From Peter Schauer.
+
+Tue Sep 14 18:20:36 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-i386.c (elf_howto_table): Add bfd_elf_generic_reloc
+ special function for all reloc entries.
+ * elf32-target.h (TARGET_LITTLE_SYM): Add SEC_CODE to
+ section_flags.
+ * libelf.h (elf_symbol_type): Remove desc, type and other fields.
+ * Makefile.in (elf32-*.o): These depend upon elf32-target.h.
+
+Tue Sep 14 14:34:45 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * libbfd-in.h (struct artdata): Add armap_timestamp and
+ armap_datepos here too.
+
+Mon Sep 13 21:03:18 1993 John Gilmore (gnu@cacophony.cygnus.com)
+
+ Improve timestamp support in BSD archive files to avoid linker
+ warnings.
+
+ * libbfd.h (struct artdata): Add armap_timestamp and armap_datepos.
+ (bfd_flush, bfd_stat): Add prototypes.
+ * libbfd.c (bfd_flush): Add, does fflush on a BFD.
+ (bfd_stat): Add, does fstat on a BFD.
+
+ * archive.c (_bfd_write_archive_contents): At end of file writing,
+ verify and possibly update the timestamp in the armap, if a BSD
+ archive. FIXME! Kludge recognizes BSD archive, rather than
+ vectoring properly. Should add to xvec.
+ (compute_and_write_armap): Move prototype to top, avoid PROTO.
+ (bsd_write_armap): Save timestamp and file location thereof, when
+ writing the armap in a BSD file.
+ (bsd_update_armap_timestamp): New function to check and
+ rewrite the timestamp.
+
+ * hosts/std-host.h (offsetof): Define, if not already, for archive.c.
+
+Sat Sep 11 18:13:42 1993 Jim Kingdon (kingdon@poseidon.cygnus.com)
+
+ * hosts/i386sco.h: Define a bunch of stuff for core files.
+ * sco-core.c: Remove, replace by trad-core.c.
+ * trad-core.c: If HOST_STACK_START_ADDR is defined, use it.
+ * config/i386sco.mh: Use trad-core not sco-core.
+ * hosts/i386isc.h, config/i386isc.mh: Remove.
+ * configure.host: Use i386sco for isc.
+ * config/i386-sco.mt: Remove, identical to i386-coff.mt.
+ * config.bfd: Use i386-coff not i386-sco.
+
+ * config.bfd: Recognize i[34]86-*-solaris2* specifically rather
+ than using *-*-solaris2* (i486-unknown-solaris2 is i386-elf, not
+ i486-elf which doesn't exist).
+
+Fri Sep 10 12:56:36 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coffswap.h (coff_swap_aouthdr_out): For ALPHAECOFF, force
+ padding field to zero.
+
+ * config.bfd (i[34]86-*-netbsd*): New target; use i386-netbsd.
+ * configure.in: Remove bogus netbsd386 handling.
+
+ * coff-mips.c: Don't warn about overflow for MIPS_R_JMPADDR reloc.
+ Correct overflow detection requires matching the upper four bits
+ of the destination against the PC.
+
+Thu Sep 9 16:57:46 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure.in: Make 64-bit stuff work with "--with-targets=all".
+
+Tue Sep 7 14:17:02 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libbfd-in.h: Removed swapping routines declarations.
+ * bfd-in.h: Added swapping routine declarations, and renamed them
+ from _do_* to bfd_*.
+ * libbfd.c: Renamed swapping routines from _do_* to _bfd_*.
+ * Changed all callers.
+ * libbfd.h, bfd-in2.h: Rebuilt.
+
+Mon Sep 6 15:28:07 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-i386.c (elf_howto_table): Set pcrel_offset to true for
+ R_386_PC32.
+
+Fri Sep 3 13:06:12 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure.in: Reorganized setting of makefile variables so
+ 64-bit stuff works again.
+
+ * libbfd-in.h (_do_get*, _do_put*): Renamed via macros to clean up
+ namespace.
+
+ * libelf.h (elf32_symbol_type, elf64_symbol_type): Deleted
+ "native_elf_sym" field, merged to make new type "elf_symbol_type".
+ (struct elf_obj_tdata): Field symbols is now elf_symbol_type*.
+ Deleted field raw_syms.
+ (obj_symbols): Remove cast.
+ (obj_raw_syms): Deleted.
+ * elfcode.h (elf_slurp_symbol_table): Don't set raw_syms or
+ native_elf_sym fields.
+ * elf32-hppa.c: Changed uses of elf32_symbol_type to
+ elf_symbol_type.
+
+ From Pete Hoogenboom and Jeff Law:
+
+ * elf32-hppa.c (ELF_MAXPAGESIZE): Define.
+
+ * elf32-hppa.c (elf_hppa_tc_symbol): If the argument relocation
+ bits are zero (e.g., they specify no relocations), then do not
+ even bother adding their entries to the symextn section.
+
+ * elf32-hppa.c (elf_hppa_tc_symbol): Any function, regardless
+ of scope can have an argument relocation stub.
+
+ * elf32-hppa.c: (Elf32_hppa_Stub_description): Rename this
+ structure and type to elf32_hppa_stub_description. This makes
+ it consistent with the GNU coding conventions.
+ (elf32_hppa_stub_description): Added a 'next' field to allow
+ linking of stub description structures.
+ (elf32_hppa_stub_description): Added a 'stub_listP' field to
+ keep track of individual stubs.
+ (Elf32_hppa_Stub_list, Elf32_hppa_Stub_list_struct): Removed.
+ Combined with the elf32_hppa_stub_description structure.
+ (elf32_hppa_stub_name_list): New type to keep track of
+ individual stubs.
+ (add_stub): Removed.
+ (add_stub_by_name): New function.
+ (find_stub_by_name): New function.
+ (hppa_elf_build_arg_reloc_stub): Allow reusing stubs that
+ already exist.
+ (hppa_elf_build_long_branch_stub): Allow reusing stubs that
+ already exist.
+
+ * elf32-hppa.c: (retval_mismatches): The direction of argument
+ relocation was reversed.
+ (hppa_elf_build_arg_reloc_stub): Return address was not being
+ restored.
+ (hppa_elf_arg_reloc_needed_p): Add argument containing caller
+ argument relocation bits so this function can be used in the check
+ for plabel stubs.
+ (hppa_elf_stub_check): Pass caller argument relocation bits into
+ hppa_elf_arg_reloc_needed_p().
+ (hppa_look_for_stubs_in_section): Add check for plabel stubs and
+ pass caller argument relocation bits into
+ hppa_elf_arg_reloc_needed_p().
+
+Thu Sep 2 00:59:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * libhppa.h (hppa_field_adjust): Remove unused `init_value' variable.
+
+ * hosts/delta88v4.h: New for SVR4.
+ * configure.hosts: Use it.
+
+Wed Sep 1 14:23:32 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * libaout.h, netbsd386.c: Change M_I386 to M_386_NETBSD. M_I386
+ is an SCO pre-define.
+
+Tue Aug 31 12:50:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlmcode.h (nlm_object_p): Set HAS_SYMS if there are external
+ references.
+ (nlm_swap_auxiliary_headers_{in,out}): The copyright length is
+ only one byte.
+ (nlm_get_symtab_upper_bound): Include debugging symbols in symbol
+ count.
+ (nlm_slurp_symbol_table): Make symlength unsigned. Read debugging
+ symbols as BFD local symbols.
+ (nlm_write_object_contents): Don't bother writing out exported
+ symbols more than once; they now appear in the symbol table more
+ than once (with and without a prefix) if necessary. Set offset
+ values to be non-zero as NLMLINK does.
+
+Tue Aug 31 12:07:43 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * libhppa.h: Restore #undefs of e_fsel and other e_* symbols.
+
+Fri Aug 27 16:43:35 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * section.c (struct sec): Move position of user_set_vma, and
+ document it.
+ (SEC_BALIGN): Disable for now. I don't think it's currently used.
+
+ * elf32-hppa.c (elf_hppa_howto_table): Now static.
+ (symext_rootP, symext_lastP, global_value, GOT_value,
+ global_symbol, global_sym_defined, symextn_contents,
+ symextn_contents_real_size, elf_hppa_stub_rootP,
+ elf32_hppa_symextn_map, elf32_hppa_symextn_map_size): Rely on
+ default initialization.
+ (hppa_elf_gen_reloc_type): Macro "UNDEFINED" doesn't need a
+ trailing semicolon.
+ (hppa_look_for_stubs_in_section): Introduce temporaries to make
+ code more readable in 80 columns.
+
+ * libhppa.h (all functions): Now inline under GNU C.
+
+ More patches from Jeff Law:
+
+ * elf32-hppa.c (AR_WARN): Give argument which caused the
+ invalid argument relocation.
+ (AR_UNIMP): Delete unused macro.
+ (hppa_elf_set_section_contents): Always return a value.
+ (elf32_hppa_backend_table_processing): Likewise.
+ (elf32_hppa_backend_section_processing: Likewise.
+
+ * som.c: New file containing SOM specific code extracted
+ from hppa.c
+
+ * som.h: New file containing SOM specific code extracted
+ from libhppa.h
+
+ * hppa.c: Deleted.
+
+ * libhppa.h: Delete SOM specific code. Add generic PA
+ code which can be shared by both SOM and ELF backends.
+
+ * Makefile.in: Replace hppa.c with som.c. elf32-hppa.o
+ depends on libhppa.h now.
+
+ * configure.in (hppa_vec): Needs som.o module instead of
+ hppa.o.
+
+ * elf32-hppa.c: Include libhppa.h. Do not define
+ BYTES_IN_WORD.
+
+ * elf32-hppa.h (hppa_reloc_field_selector_type): Delete
+ now lives in libhppa.h.
+ (hppa_reloc_field_selector_type_alt): Likewise.
+
+ * hosts/hppabsd.h: Include <stdlib.h> and <unistd.h>. Do not
+ define malloc or free.
+
+ * config/hppa-elf.mt (SELECT_ARCHITECTURES): Don't define
+ SELECT_VECS.
+
+ * elf32-hppa.c (hppa_elf_relocate_unwind_table): Delete unused
+ variables.
+ (elf_hppa_reloc_type_lookup): Likewise.
+ (elf_hppa_tc_make_sections): Likewise.
+ (hppa_elf_arg_reloc_needed_p): Likewise.
+ (hppa_elf_build_long_branch_stub): Likewise.
+ (elf_reloc_map): Delete, no longer used.
+ (elf_hppa_reloc_map): Likewise.
+ (elf32_hppa_symextn_map_max_size): Likewise.
+ (elf32_hppa_get_sym_extn): Abort if type is bogus.
+
+ * elf32-hppa.c (elf32_hppa_backend_fake_sections): Add processing
+ of the .hppa_unwind section.
+
+Wed Aug 25 16:13:49 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * config.bfd: recognize m88110.
+
+Tue Aug 24 16:32:35 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ Merged changes from Jeff Law and Pete Hoogenboom at Utah:
+
+ * elfcode.h (elf_section_from_bfd_section): Add detection of
+ SHT_NOTE sections.
+
+ * elf32-hppa.c:
+ (hppa_elf_build_long_branch_stub,hppa_elf_long_branch_needed_p):
+ New functions for support of long branch stubs.
+ (hppa_elf_stub_check,hppa_look_for_stubs_in_section): Add
+ check for long branch stubs.
+ (hppa_look_for_stubs): Unused function. Removed.
+ (hppa_elf_set_section_contents): Implement a PA/ELF-specific
+ version of bfd_set_section_contents.
+ (hppa_elf_long_branch_needed_p): Only output debugging diagnostics
+ when BFD is configured for debugging.
+
+ * elf32-hppa.c: (elf32_hppa_get_symextn_chain): New function
+ to return a list of symbols that have non-zero argument
+ relocation bits.
+ (hppa_elf_stub_finish): Make sure stub generation is done only
+ once.
+
+ * elf32-hppa.c: (hppa_elf_stub_reloc): New function for
+ generation relocation entries within a stub.
+ (hppa_elf_build_arg_reloc_stub): Corrections to argument
+ relocation stubs.
+
+ * elf32-hppa.c: New #define's for argument relocation types.
+ (mismatches, retval_mismatches): Updated to reflect new
+ argument relocation types.
+ (CURRENT_STUB_OFFSET): New macro.
+
+ * elfcode.h (map_program_segments): Set the PF_X bit for data
+ segments.
+
+ * elf32-hppa.c: (elf_hppa_howto_table): Add
+ R_HPPA_STUB_CALL_17 for support of linker stub generation.
+ (hppa_elf_reloc): Add support of R_HPPA_STUB_CALL_17
+ relocation type.
+
+ * elf32-hppa.h: (elf32_hppa_reloc_type): Add
+ R_HPPA_STUB_CALL_17 for support of linker stub generation.
+
+ * hppa_stubs.h: Add new instructions that are used in linker
+ stub generation.
+
+ * elf32-hppa.c (hppa_elf_relocate_unwind_table): The offsets in an
+ unwind descriptor were incorrect.
+
+ * libelf.h (bfd_elf_find_section): Declare.
+
+ * elf32-hppa.c: (elf32_hppa_backend_symbol_processing): New
+ function in place of global_sym field in elf_backend_data
+ structure.
+ (elf32_hppa_backend_symbol_table_processing,
+ elf32_hppa_backend_section_processing,
+ elf32_hppa_backend_fake_sections,
+ elf32_hppa_backend_section_from_shdr,
+ elf32_hppa_backend_section_from_bfd_section): New functions to
+ provide support of symbol extension sections and argument
+ relocation stubs.
+ (elf_info_to_howto): Remove call to abort().
+
+ * elf32-target.h: Support for special processing by the backend.
+ (struct elf_backend_data): Added elf_backend_symbol_processing,
+ elf_backend_symbol_table_processing,
+ elf_backend_section_processing, elf_backend_section_from_shdr,
+ elf_backend_fake_sections, and
+ elf_backend_section_from_bfd_section fields.
+ * elfcode.h: (bfd_section_from_shdr): Add a check for
+ processor-specific section types.
+ (elf_fake_sections): Add a check for processor-specific
+ section types.
+ (bfd_elf32_write_object_contents): Add a check to see if
+ there is any final section processing to be done by the
+ backend.
+ (elf_section_from_bfd_section): Add a check for
+ processor-specific section types.
+ (elf_slurp_symbol_table): Remove reference to global_sym in the
+ elf_backend_data structure. Replace it with a call to
+ elf_backend_symbol_processing.
+ * libelf.h: Remove global_sym field in the elf_backend_data
+ structure. Replace it with a series of backend-specific
+ functions.
+
+ * elf32-hppa.c (hppa_elf_stub_branch_reloc): The formal argument
+ stub_sym should be called target_sym.
+ (hppa_elf_build_arg_reloc_stub): Refer to the stub bfd (abfd)
+ rather than the output bfd (output_bfd).
+ (hppa_elf_reloc): Get rid of references to the global_sym field in
+ the elf_backend_data structure.
+
+ * elfcode.h (elf_fake_sections): Check the correct condition for
+ .bss. Also, detect the existence of a .note section.
+
+ * elf32-hppa.c (hppa_elf_relocate_insn): r_format argument should
+ have been r_field.
+
+ * hosts/hppabsd.h (HOST_MACHINE_ARCH): Reference to bfd_arch_m68k
+ should be a reference to bfd_arch_hppa.
+
+ * hppa.c (hppa_vec): Replace bfd_false with _bfd_dummy_target in
+ the bfd_check_format structure to avoid a type mismatch.
+
+Mon Aug 23 1993 Sean Fagan (sef@cygnus.com)
+ and Jim Kingdon (kingdon@cygnus.com)
+
+ Add NetBSD support:
+ * netbsd386.c: New file.
+ * aoutx.h: Make sym_is_debugger_info true for N_FN.
+ * Makefile.in, aout-target.h, config.bfd, configure.host, configure.in,
+ libaout.h, targets.c: Other changes.
+
+Fri Aug 20 17:04:59 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config/m88k-elf.mt: New file.
+ * config.bfd: Use it for m88*-*-sysv4*.
+
+Fri Aug 20 15:16:58 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elfcode.h (elf_build_phdrs): Unused function deleted.
+ (bfd_shdr_from_section): Ditto.
+ (write_relocs): Don't change section contents for addend.
+ (elf_locate_sh): Return type is now always elf_internal_shdr,
+ since the other types were really aliases for this type anyways.
+ Don't compile this function, since it is static and doesn't appear
+ to be used in this file.
+ (sym_is_global): Return non-zero for weak symbols. Abort if
+ section pointer is null.
+ (swap_out_syms): Reorder tests so function symbols can be weak.
+ (elf_slurp_symbol_table): Don't use BSF_EXPORT.
+ (elf_slurp_reloca_table): Make RELOC_PROCESSING section smaller by
+ extracting out some common code. Abort if BFD section symbol has
+ null name.
+ (elf_slurp_reloc_table): Translate ELF section symbols into BFD
+ section symbols. Don't read section contents to fill in addend
+ field.
+
+ * elf32-i386.c (elf_howto_table): All partial_inplace fields
+ should be "true".
+
+ * Merged from OSF:
+
+ Tue Jun 15 14:38:32 1993 Michael Meissner (meissner@osf.org)
+
+ * libelf.h (struct Elf_Sym_Extra): New structure to contain ELF
+ specific information for a symbol. Put in elf_sym_num, which
+ gives the external symbol number in the elf object file, since
+ local symbols must come before global symbols.
+ (elf_sym_extra): New macro.
+ (elf_symtab_map): Delete, in favor of using Elf_Sym_Extra.
+ * elfcode.h (elf_map_symbols): Use Elf_Sym_Extra to map internal
+ symbol number to external number. Store the address of the
+ Elf_Sym_Extra field for the symbol in the udata field.
+ (elf_write_object_contents): Use Elf_Sym_Extra to map out symbols.
+
+ Sun Jun 20 16:30:11 1993 Michael Meissner (meissner@osf.org)
+
+ * elfcode.h (elf_obj_tdata): Add field to count the size of the
+ array of pointers to section symbols.
+ (elf_map_symbols): Bump the max index of the section symbols so
+ that we don't overwrite memory. Store the max index into the
+ elf_obj_tdata field.
+
+ Sat Jun 19 10:12:27 1993 Michael Meissner (meissner@osf.org)
+
+ * elfcode.h (elf_obj_tdata): Add pointer to an array of pointers
+ to the section symbols we created. Remove unused field
+ internal_syms.
+ (elf_map_symbols): Fill in array of pointers to section symbols.
+ Only create section symbols for sections that have SEC_ALLOC set,
+ and have non-zero size.
+ (elf_symbol_from_bfd_symbol): If udata is NULL, and this is a
+ section symbol, look up the section in the list of section
+ symbols, and set the udata pointer appropriately. Otherwise, if
+ udata is still NULL, fail an assertion, and use 0, instead of
+ dropping core.
+
+Fri Aug 20 12:18:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config.bfd (mips-*-elfl*, mips-*-elf*): New targets, using
+ mipslelf and mipsbelf respectively.
+ * config/mipslelf.mt, config/mipsbelf.mt: New files.
+ * elf32-mips.c: Added some reloc information.
+ * configure.in: Fixed error message.
+
+ * ecoff.c (ECOFF_LONG_SIZE): Removed. Just use constants.
+
+Thu Aug 19 09:45:51 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * Makefile.in (BFD_LIBS, ALL_MACHINES, BFD32_BACKENDS, BFD64_BACKENDS,
+ OPTIONAL_BACKENDS): Alphabetize entries and add a few missing ones.
+ * archures.c: Alphabetize decls.
+
+ * configure.in, targets.c: Add missing vectors to the tables.
+ * targets.c (target_vector) [!SELECT_VECS]: Add DEFAULT_VECTOR.
+ Remove hp300bsd_vec due to clash with sunos_big_vec.
+
+Tue Aug 17 18:12:32 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/i386{mach3,osf1mk}.h: New files, for Mach hosting.
+ * hosts/i386mach.h: removed, replaced by i386osf1mk.h.
+ * config/i386mach3.mt, i386mach3.c: New files, for Mach a.out format.
+ * Makefile.in, configure.host, config.bfd: Corresponding changes.
+ * hosts/decstation.h: Include <sys/param.h> not <machine/param.h>.
+
+Tue Aug 17 15:19:41 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coffgen.c (coff_section_symbol): If section's output_section is
+ not yet set, point to itself. This is needed because this is
+ called on the output file, not the input file.
+
+ * coff-rs6000.c (dummy_reloc, RTYPE2HOWTO): Set howto field to a
+ dummy value, rather than leaving it NULL.
+
+ * archures.c (bfd_default_set_arch_mach): Set bfd_error on
+ failure.
+ * aoutx.h (NAME(aout,set_arch_mach)): Check return value of
+ bfd_default_set_arch_mach.
+
+Tue Aug 17 09:42:16 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * config.bfd (cpu): Extract from canonical name with sed.
+ * configure.in: Don't pass it.
+
+Sun Aug 15 20:45:45 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * bfd-in.h: Remove {BYTE,WORD,LONG}_SIZE; they are pointless and
+ BYTE_SIZE conflicts with a Mach header.
+ * ecoff.c: Change LONG_SIZE to ECOFF_LONG_SIZE and define it.
+
+ * configure.host: Make sure all OS fields end in *.
+
+Fri Aug 13 16:33:33 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_slurp_reloc_table): Use bfd_abs_section for
+ RELOC_SECTION_NONE and RELOC_SECTION_ABS. If a reloc section
+ doesn't exist, don't try to create it.
+
+ * nlmcode.h (nlm_write_object_contents): procedure offsets are
+ from start of code segment, not start of file.
+ * config/i386-nlm.mt (DEFAULT_VECTOR): It's nlm32_i386_vec, not
+ bfd_nlm32_i386_vec.
+ * configure.in (SELECT_VECS switch): Likewise.
+
+Thu Aug 12 10:32:47 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * format.c (bfd_check_format): If the target matches the default
+ target, set match_count to 1, to ignore any previous matches.
+
+ * Makefile.in (BFD32_BACKENDS): Remove srec.o, add reloc16.o.
+
+ * configure.in: Add reloc16.o when we add
+ coff-h8300.o, coff-h8500.o, coff-sh.o, coff-z8k.o.
+ Makefile.in (BFD_LIBS): Remove reloc16.o.
+
+ * config/u68k-coff.mt: Fix typo, DEFAULT_TARGET for
+ DEFAULT_VECTOR.
+
+ * config/h8300-coff.mt, h8500-coff.mt, sh-coff.mt, st2000.mt,
+ z8k-coff.mt (DEFAULT_VECTOR): Define. Don't explicitly add
+ S-records via SELECT_VECS.
+
+ * targets.c (target_vector), Makefile.in (BFD_LIBS): Always
+ support S-records, for convenience.
+
+Thu Aug 12 08:30:05 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-alpha.c (alpha_howto_table, alpha_finish_reloc,
+ alpha_ecoff_swap_reloc_{in,out}, alpha_bfd_reloc_type_lookup):
+ Read and write Alpha relocs. Can't process them yet.
+ * ecoff.c (ecoff_slurp_reloc_table): Recognize new reloc sections.
+ If the section does not already exist, create it.
+
+ * ecoffswap.h (ecoff_swap_pdr_{in,out}): Handle new fields defined
+ on the Alpha.
+
+ * libecoff.h (ecoff_backend_data): Added constructor_reloc and
+ finish_reloc fields.
+ * ecoff.c: Move MIPS reloc support from here...
+ * coff-mips.c: to here.
+ * ecoff.c (ecoff_set_symbol_info): Get constructor reloc howto
+ from backend.
+ (ecoff_slurp_reloc_table): Removed MIPS specific stuff. Call
+ finish_reloc backend function.
+ (ecoff_write_object_contents): Removed MIPS specific assertions.
+ * coff-mips.c (mips_finish_reloc): New function.
+ (mips_ecoff_backend_data): Fill in new fields.
+ * coff-alpha.c (alpha_ecoff_backend_data): Use NULL for new
+ fields.
+ * targets.c: Added extern for ecoffalpha_little_vec.
+
+ * bfd.c (_bfd_host_big_endian): Removed.
+ * bfd-in.h (HOST_BYTE_ORDER_BIG_P, bfd_header_twiddle_required):
+ Removed.
+ * bfd-in2.h: Regenerated.
+
+Wed Aug 11 12:11:23 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * config.bfd: New file, broken out of configure.in.
+ * configure.in: Use it, and use standard target names for
+ --with-targets, replacing --with-bfd-targets.
+
+ * archures.c (archures_init_table): Add bfd_sh_arch.
+
+ * configure.in: Include coff-m68k.o for m68kcoffun_vec.
+ Include nlm32.o and nlm.o for bfd_nlm32_i386_vec.
+ Fix error in error message.
+
+ * oasys.c: Make bfd_error_vector extern.
+
+ * configure.in: Include stab-syms.o for a.out/b.out targets
+ and hp300{bsd,hpux}.
+
+Wed Aug 11 06:40:51 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * nlmcode.h (nlm_compute_section_file_positions): Add the .bss
+ section before setting output_has_begun.
+ (nlm_set_section_contents): Remove argument names from
+ mangle_relocs_func prototype.
+ (nlm_write_object_contents): Remove shadowing local variable.
+ Don't write out debugging symbols if debugInfoOffset is -1. Add
+ the codeImageOffset to the start, exit, and check procedure
+ offsets.
+ * nlm32-i386.c (nlm_i386_write_reloc, nlm_i386_mangle_relocs):
+ Don't check partial_inplace field; its value is irrelevant.
+
+ * Base use of sco-core on host, not target.
+ * configure.host (i[34]86-*-sco*): Use i386sco rather than i386v.
+ * config/i386-sco.mt (TDEFINES): Removed.
+ * config/i386sco.mh: New file to use sco-core.
+ * hosts/i386sco.h: New file; just includes hosts/i386v.h.
+
+ * ecoffswap.h (ecoff_swap_{hdr,ext}_{in,out}): Use signed
+ conversions for some fields.
+
+Tue Aug 10 13:32:23 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_gprel_reloc): If _gp is not defined, give an
+ error rather than aborting.
+
+ * libnlm.h (struct nlm_backend_data): Added mach field.
+ (nlm_machine): New accessor macro.
+ * nlm.c (nlm_mkobject): Set architecture and machine from backend
+ information.
+ * nlm32-i386.c (nlm32_i386_backend): Initialize new mach field.
+
+Tue Aug 10 09:31:18 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * configure.in: Replace calls to sort with shell code
+ to uniq the lists.
+
+Tue Aug 10 06:23:16 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure.in: Include aout32.o for any a.out/b.out formats.
+
+Mon Aug 9 09:37:18 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * config/i386-linux.mt (SELECT_VECS): Support bfd_elf32_i386_vec.
+ * config/m68k-elf.mt (SELECT_VECS): Support m68kcoff_vec.
+ * config/i386-elf.mt (SELECT_VECS): Support i386coff_vec.
+ * config/hppa-elf.mt (SELECT_VECS): Support hppa_vec.
+ * config/sparc-elf.mt (SELECT_VECS): Support sunos_big_vec.
+ * config/i386-sco.mt (SELECT_VECS): Don't define; Ian says it was
+ just a hack.
+
+Mon Aug 9 13:15:00 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * config/m88k-coff.mt (DEFAULT_VEC -> DEFAULT_VECTOR): renamed.
+
+Mon Aug 9 14:26:45 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * syms.c (BSF_EXPORT): Now same as BSF_GLOBAL.
+
+ * bfd.c (bfd_scan_vma): New function.
+
+Mon Aug 9 11:29:53 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd-in.h (bfd_get_architecture, bfd_get_machine): Removed
+ obsolete macros.
+ * bfd-in2.h: Updated.
+
+ * ecoff.c (ecoff_slurp_armap): Correct bug in initialization of
+ stringbase.
+
+Sun Aug 8 12:21:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * configure.in: Remove unneeded test.
+
+Sun Aug 8 12:41:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in ({dist,real}clean): Use $(MAKE), not make.
+
+Sat Aug 7 09:14:21 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * config/st2000.mt (TDEFINES): Don't define MRI; not used.
+
+ * PORTING, TODO, config/README: Update to reflect below changes.
+
+ * configure.in: Replace MINIMIZE and --with-minimal-bfd with
+ --with-bfd-targets="target1,target2,..." and the special target
+ "all" to get the previous default behavior.
+ Figure out which architecture and backend .o files are needed from
+ DEFAULT_VECTOR, SELECT_VECS, and SELECT_ARCHITECTURES as set in
+ the .mt files. Define TDEFAULTS based on them, also.
+
+ * Makefile.in: Remove references to MINIMIZE.
+ * archures.c, targets.c: Ditto.
+
+ * config/*.mt: Define DEFAULT_VECTOR, SELECT_VECS, and
+ SELECT_ARCHITECTURES as variables rather than as -D arguments to
+ TDEFAULTS.
+
+ * config/a29k-coff.mt,alphaosf.mt, i386-sco.mt, i960-bout.mt,
+ i960-coff.mt (TDEFAULTS): Don't put the default vector in
+ SELECT_VECS manually; it's automatic now.
+
+ * config/i386-sco.mt (TDEFAULTS): Don't put &sco_core_vec in
+ SELECT_VECS manually; -DSCO_CORE does it automatically now.
+
+ * config/h8300-coff.mt,h8500-coff.mt,sh-coff.mt,st2000.mt,z8k-coff.mt
+ (TDEFAULTS): Don't define BFD; not used.
+
+ * config/hppaosf.mh (HDEFINES): Don't define SELECT_ARCHITECTURES;
+ this is a host, not a target.
+
+Sat Aug 7 05:28:03 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * elfcode.h (elf_object_p): Add comment about what this function
+ does and to watch out for side effects. Add FIXME for memory leaks.
+ Fix comment about checking for matching byte order. Preserve
+ pointer to old tdata (if any), and restore it if we don't match
+ file with target vector. If we are going to use goto's, use them
+ consistently and maintainably.
+ * nlmcode.h (nlm_object_p): Expand comments about leaked memory
+ to note that the problem is even more serious than just leaked
+ memory. Replace goto with more traditional return.
+
+Fri Aug 6 12:00:03 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ Fix incorrect or useless makefile variable definitions:
+ * config/news.mt, config/u68k-coff.mt (TDEFAULTS): Use this to
+ define DEFAULT_VECTOR, instead of TDEFINES.
+ * config/i386aix.mh (MINIMIZE): Don't define.
+ * config/hppaosf.mh (MINIMIZE): Don't conditionalize.
+ * config/rs6000.mh (ALLOCA),
+ * config/i386v.mh (ALLOCA),
+ * config/i386linux.mh (ALLOCA),
+ * config/i386isc.mh (ALLOCA),
+ * config/go32.mh (EXTRALIBS): Don't define; not used.
+ * config/solaris2.mh (HDEFINES): Renamed from H_DEFINES.
+ * config/alphaosf.mt (TDEFINES): Set it, not HDEFINES.
+ * config/z8k-coff.mt (CC): Don't define. It's a target, not a host.
+
+ * config/README: New file, explaining the variables.
+
+ * targets.c (target_vector): Add hp300_bsd_vec.
+ * Makefile.in (BFD32_BACKENDS, CFILES): Add hp300bsd.
+ (hp300bsd.o): New rule.
+
+Fri Aug 6 15:13:22 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * libelf.h (NAME): Provide a default definition, that's neither
+ for 32 bits nor for 64.
+
+ Tue Jun 15 14:38:32 1993 Michael Meissner (meissner@osf.org)
+
+ * libelf.h (elf_hash): Change declaration to bfd_elf_hash, since
+ that is what is in elf.c.
+
+Fri Aug 6 12:28:38 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_set_symbol_info): Removed special handling for
+ scBss and scSBss symbols, since it was wrong.
+
+ * Makefile.in (coff-mips.o, coff-alpha.o): Don't depend on
+ coffcode.h.
+
+ * coffcode.h (sec_to_styp_flags): Inspired by mb@tti.COM (Michael
+ Bloom): Only set STYP_BSS for SEC_ALLOC sections.
+
+ * ecoff.c (ecoff_slurp_armap): From Arne Henrik Juul
+ <arnej@kari.fm.unit.no>: Handle a COFF style armap.
+
+Fri Aug 6 09:59:45 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hpux-core.c: Cast return value from bfd_zalloc.
+
+Thu Aug 5 13:22:44 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * aoutx.h (log2): Delete i387-specific code.
+
+ * Makefile.in (BFD_LIBS): Always include elf.o.
+ (BFD32_BACKENDS): Don't include elf.o here.
+ (ofiles): Delete references to ofiles2 and ofiles3.
+ (do_clean): Delete ofiles.
+ (BFDIN_H): Changed references to $(srcdir)/bfd-in2.h.
+ (stmp-bfd.h): Use bfd.h-new as temporary name, not bfd.h2.
+ (headers): Use bfd-in2.h-new as temporary name, not bfd.h-new.
+
+ * bfd-in.h: Reworded comment to make it clear that bfd-in2.h is a
+ generated file.
+
+ * reloc.c (enum bfd_reloc_code_real): Added i386-elf reloc types
+ (from Meissner's additions to bfd-in2.h).
+
+ * elf32-i386.c (ELF_MAXPAGESIZE): Define.
+
+ Merged:
+
+ Wed Jun 23 06:05:58 1993 Michael Meissner (meissner@osf.org)
+
+ * elfcode.h (elf_write_object_contents): Don't drop core if
+ elf_symbol_from returns a NULL pointer when processing a non-elf
+ symbol, use a 0 size instead.
+
+ Tue Jun 15 14:38:32 1993 Michael Meissner (meissner@osf.org)
+
+ * elfcode.h (elf_hash): Delete macro mapping elf_hash to
+ bfd_elf32_hash, since the hash table is independent of the 32/64
+ bit system.
+
+ * libelf.h (elf_hash): Change declaration to bfd_elf_hash, since
+ that is what is in elf.c.
+
+ Sat Jun 19 10:12:27 1993 Michael Meissner (meissner@osf.org)
+
+ * elf32-i386.h (reloc_type): Reformat spacing.
+ (elf_howto_table): Add the rest of the 386/ELF relocations.
+ (elf_i386_reloc_type_lookup): Ditto.
+ (elf_i386_info_to_howto): Ditto.
+ (elf_i386_info_to_howto_rel): Ditto.
+
+Thu Aug 5 10:07:43 1993 Fred Fish (fnf@cygnus.com)
+
+ * nlmcode.h (nlm_get_reloc_upper_bound): Test return value
+ of nlm_slurp_symbol_table as boolean, not pointer.
+ * nlmcode.h (nlm_canonicalize_reloc): Test return value
+ of nlm_slurp_reloc_fixups as boolean, not pointer.
+
+Wed Aug 4 16:22:55 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * config/go32.mh: remove HDEFINES; since __MSDOS__ and __GO32__
+ are now predefined by GCC
+
+Wed Aug 4 16:06:29 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * coffgen.c (coff_print_symbol): Add the section offset to the
+ line number address, so it's printed the same way as the function
+ address. Only showed up for line numbers that aren't in the first
+ section (.text).
+
+Wed Aug 4 08:33:55 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * libnlm.h (nlm_backend_data): Added nlm_mangle_relocs.
+ (nlm_mangle_relocs_func): New macro.
+ * nlm32-i386.c (nlm_i386_write_reloc): Rewrote correctly.
+ (nlm_i386_mangle_relocs): New function.
+ * nlmcode.h (nlm_compute_section_file_positions): Move all common
+ symbols into the .bss section.
+ (nlm_set_section_contents): Call the mangle_relocs function.
+ (nlm_write_object_contents): Treat a reloc against any defined
+ symbol as an internal reloc. Fix bug in external reloc counting.
+ Get the offset and debugging type right for .bss symbols. Only
+ output debugging symbols for defined symbols.
+
+ * coff-h8500.c (rtype2howto): Do an fprintf to stderr rather than
+ using printf.
+ * coff-z8k.c (rtype2howto): Likewise.
+ * coffcode.h (dummy_reloc16_extra_cases): Likewise.
+ * elf32-i386.c (TRACE): Likewise.
+ * hp300hpux.c (convert_sym_type, swap_std_reloc_in): Likewise.
+ * rs6000-core.c (rs6000coff_get_section_contents): Likewise.
+ * coffgen.c (coff_print_symbol): Do an fprintf to the file
+ argument rather than using printf.
+
+Tue Aug 3 18:17:25 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffswap.h: Added macros used when accessing several fields;
+ default is the same as before.
+ (coff_swap_aouthdr_{in,out}): Handle the Alpha ECOFF fields.
+ * coff-alpha.c: Defined macros to use the right sizes in
+ coffswap.h.
+ * libecoff.h: Backend information is now in target vector, not
+ BFD. Start of backend information is COFF backend information.
+ * coff-alpha.c, coff-mips.c: Changed accordingly.
+ * ecoff.c (ecoff_mkobject): New function.
+ (ARMAP_START): Changed into backend information, since Alpha uses
+ a different name.
+ (ecoff_slurp_armap): Don't overlay archive header.
+ * bfd.c: Include libcoff.h.
+
+Tue Aug 3 16:33:11 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * Makefile.in (install): Fix sh syntax error.
+
+ * aoutf1.h: Make bfd_error_trap extern; it's defined in bfd.c.
+
+Tue Aug 3 15:19:09 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * nlm_slurp_symbol_table: Don't use '&' on arrays.
+
+Tue Aug 3 11:06:28 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff.c: New file for generic ECOFF functions.
+ * ecoffswap.h: New file for ECOFF swapping functions which differ
+ only slightly for different targets.
+ * libecoff.h: Added prototypes for ecoff.c functions.
+ (ecoff_backend_data): New structure.
+ (ecoff_tdata): Added backend_data field. Changed external data
+ pointers to be PTR rather than to a particular struct.
+ (ecoff_symbol_struct): Moved in from coff-mips.c.
+ * coff-alpha.c, coff-mips.c: Moved common functions into ecoff.c.
+ Added ECOFF backend structures. Include ecoffswap.h.
+ * coff-msym.c: Removed; superseded by ecoffswap.h.
+ * bfd.c: Include coff/internal.h.
+ * Makefile.in (BFD_LIBS): Removed coff-mips.o and coff-msym.o.
+ Added ecoff.o.
+ (BFD64_BACKENDS): Added coff-alpha.o.
+ (CFILES): Removed coff-msym.c. Added ecoff.c.
+ (bfd.o): Added dependency on $(INCDIR)/coff/sym.h.
+ (coff-mips.o): Added dependency on ecoffswap.h and coff/ecoff.h.
+ (ecoff.o, coff-alpha.o): New targets.
+ (coff-msym.o): Removed target.
+
+Mon Aug 2 23:33:38 1993 John Gilmore (gnu@cygnus.com)
+
+ * elf32-hppa.h, hosts/*: Remove (one more time) all occurrances
+ of EXFUN in the BFD sources. Heave ho!
+
+Mon Aug 2 16:45:57 1993 Stu Grossman (grossman at cygnus.com)
+
+ * coffcode.h (coff_set_arch_mach_hook): Add check for I386LYNXMAGIC.
+
+Mon Aug 2 12:18:03 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * hosts/sun3.h: remove some more conflicting decls
+
+Mon Aug 2 11:48:23 1993 Stu Grossman (grossman at cygnus.com)
+
+ * i386lynx.c: Remove unnecessary def of N_HEADER_IN_TEXT,
+ redefine TEXT_START_ADDR to be 0.
+
+Sun Aug 1 22:54:08 1993 Stu Grossman (grossman at cygnus.com)
+
+ * configure.host, configure.in, hosts/i386lynx.h: Lynx/386
+ host and target info.
+
+Fri Jul 30 18:08:27 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlm32-i386.c: New file. First cut at i386 NLM code.
+ * libnlm.h: Added some more prototypes.
+ (struct nlm_relent): New structure.
+ (nlmNAME(symbol_type)): Added rcnt and relocs fields.
+ (struct nlm_obj_tdata): Added new fields: nlm_symbols,
+ nlm_text_low, nlm_data_low, nlm_reloc_fixups,
+ nlm_reloc_fixup_secs.
+ (struct nlm_backend_data): New structure, with accessor macros.
+ * nlmcode.h: Use NLM_HIBIT rather than MSB.
+ (nlm_object_p): Set SEC_RELOC for .text and .data. Don't set
+ SEC_DATA for .bss. Set HAS_RELOC and HAS_SYMS for abfd. Set the
+ architecture.
+ (nlm_swap_fixed_header_out, nlm_swap_variable_header_out,
+ find_nonzero, nlm_swap_auxiliary_headers_out): New outbound
+ swapping functions.
+ (nlm_get_symtab_upper_bound, nlm_slurp_symbol_table): Include
+ external references in symbol table as undefined symbols.
+ (nlm_get_symtab, nlm_slurp_symbol_table): Fill in alocation
+ argument in get_symtab rather than in slurp_symbol_table.
+ (nlm_slurp_symbol_table): Save symbol information in tdata.
+ (nlm_print_symbol): New function.
+ (nlm_slurp_reloc_fixups, nlm_get_reloc_upper_bound,
+ nlm_canonicalize_reloc): New functions to read relocs.
+ (nlm_compute_section_file_positions, nlm_set_section_contents,
+ nlm_external_reloc_compare, nlm_write_object_contents): New
+ functions to create NLM files.
+ * nlm-target.h: Define all the nlm functions here either as
+ default values or in terms of nlmNAME. Use JUMP_TABLE(nlm). Set
+ the backend_data field to TARGET_BACKEND_DATA.
+ * nlm32-gen.c, nlm64-gen.c: Don't define function macros here;
+ they are now in nlm-target.h.
+ (TARGET_BACKEND_DATA): Define as NULL.
+ * nlm.c (nlm_mkobject): Do allocate the tdata field.
+ (nlm_set_arch_mach): New function.
+ * targets.c: Added nlm32_i386_vec.
+ * Makefile.in (BFD32_BACKENDS): Added nlm32-i386.o.
+ (CFILES): Added nlm32-i386.c.
+ (nlm32-gen.o, nlm64-gen.o): Depend on nlm-target.h.
+ (nlm32-i386.o): New target.
+
+Thu Jul 29 20:20:39 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * hosts/sun3.h: remove some function decls that conflict w/ ANSI
+ C, and aren't needed anyway (return int)
+
+Wed Jul 28 15:46:38 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elfcode.h: Use casts with bfd_alloc and alloca.
+
+Tue Jul 27 12:51:43 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * nlm{32,64}-gen.c (JUMP_TABLE_PREFIX): Delete.
+ * nlm{32,64}-gen.c (JUMP_TABLE_INIT): New macro that works with
+ older cpp's, that don't do additional replacement on the JUMP_TABLE
+ macro's argument.
+ * nlm-target.h (JUMP_TABLE_INIT): Use new macro in place of
+ JUMP_TABLE macro.
+
+Mon Jul 26 17:39:01 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ Yet another trad-core variant:
+ * config/esix.mh, hosts/esix.h: New files.
+ * configure.hosts: Use them.
+
+Mon Jul 26 13:22:15 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Handle the case of
+ complain_overflow_bitfield, rightshift > bitpos, and a negative
+ number.
+
+Mon Jul 26 14:40:10 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elfcode.h: Reimplement segment writing.
+ (elf_write_phdrs): Use precomputed e_phoff rather than making
+ assumptions.
+ (elf_build_phdrs): Disabled, for now.
+ (assign_file_position_for_section): Don't change file offset for
+ SHT_NOBITS.
+ (assign_file_positions_for_symtab_and_strtabs): New function.
+ (struct seg_info): New type.
+ (map_program_segments): New function.
+ (assign_file_positions_except_relocs): For executables, leave
+ section headers &c for last, and properly align all sections with
+ flag SHF_ALLOC set.
+ (prep_headers): No longer abort when EXEC_P is set.
+ (write_shdrs_and_ehdr): Deleted all code relating to program
+ segments.
+
+ * elfcode.h (various): Deleted some unused code, and debugging
+ "malloc(0)" calls.
+ (write_relocs): Cache value of last symbol looked up, to save
+ time if the symbol is referred to repeatedly.
+ (elf_fake_sections): Check only SEC_RELOC flag, not number of
+ relocs.
+ (assign_section_numbers): Likewise.
+
+ * Makefile.in (ofiles): Stars in wildcards belong outside quotes.
+
+ * libelf.h (struct elf_backend_data): New field, maxpagesize.
+ (struct elf_obj_tdata): New field, phdr.
+ * elf32-target.h (elf32_bed): Initialize maxpagesize from
+ ELF_MAXPAGESIZE.
+ (ELF_MAXPAGESIZE): Default to 1.
+ * elf64-target.h (elf64_bed, ELF_MAXPAGESIZE): Likewise.
+ * elf32-sparc.c (ELF_MAXPAGESIZE): Define.
+ (elf_sparc_howto_table): All relocs should have pcrel_offset=true.
+ Most should have length field of `2'.
+
+ * reloc.c (bfd_perform_relocation): Handle 64-bit relocs.
+
+ * config/sparc-aout.mt (TARGET_BACKENDS): Define.
+
+Mon Jul 26 08:56:16 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure.in: Don't look in ${srcdir} for ${target_makefile_frag};
+ the top level script has already adjusted for it.
+
+Mon Jul 26 08:09:19 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * srec.c (srec_write_symbols): Get CR LF in the right order.
+
+Mon Jul 26 02:08:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/vaxbsd.h: Include std-host.h. Don't include <machine/param.h>.
+
+Sat Jul 24 16:13:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Handle case of rightshift !=
+ bitpos when overflow checking.
+
+Fri Jul 23 10:20:27 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * bfd.c (bfd_nonrepresentable_section, bfd_undefined_symbol,
+ bfd_reloc_value_truncated, bfd_reloc_is_dangerous, bfd_assert):
+ Send error messages to stderr.
+
+Thu Jul 22 15:57:29 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * nlm{32,64}-target.h: Remove.
+ * nlm-target.h: New file, merged from nlm{32,64}-target.h
+ * libnlm.h (NLM_ARCH_SIZE): Define to ARCH_SIZE.
+ * nlm.c (ARCH_SIZE): Remove define to zero.
+ * nlm32-gen.c (ARCH_SIZE): Define to 32.
+ * nlm32-gen.c (JUMP_TABLE_PREFIX): Define to nlm32.
+ * nlm{32,64}-gen.c (nlm-target.h): Include.
+ * targets.c, libnlm.h, nlm.c, nlm{32,64}-gen.c, nlm{32,64}.c,
+ nlmcode.h: Convert prefixes from bfd_nlm<size> to just
+ nlm<size>, and use macros select size.
+
+Thu Jul 22 15:40:14 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * Makefile.in (Makefile): add configure.in, drop redundant
+ $(srcdir), drop redundant ./
+
+Thu Jul 22 13:34:57 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * hpux-core.c: New file; backend for HP/UX style core files.
+ * bfd.c (struct _bfd): Renamed hppa_core_data field to
+ hpux_core_data.
+ * bfd-in2.h: Updated.
+ * hppa.c (make_bfd_asection, hppa_core_file_p,
+ hppa_core_file_failing_command, hppa_core_file_failing_signal,
+ hppa_core_file_matches_executable_p): Moved into hpux-core.c.
+ Removed from target vector.
+ * libhppa.h (struct hppa_core_struct and accessor macros): Moved
+ into hpux-core.c.
+ * targets.c: If HPUX_CORE is defined, add hpux_core_vec to
+ target list.
+ * config/hp300.mh (HDEFINES): Set to -DHPUX_CORE.
+ (HDEPFILES): Set to hpux-core.o.
+ * config/hppabsd.mh, config/hppahpux.mh: Likewise.
+ * hosts/hp300.h (HOST_HP300HPUX): Define.
+ * Makefile.in (OPTIONAL_BACKENDS): Added sco-core.o,
+ aix386-core.o, hpux-core.o.
+ (sco-core.o, aix386-core.o, hpux-core.o): New dependencies.
+
+ * reloc.c (enum complain_overflow): New enumeration with the
+ various flavours of overflow checking.
+ (srtuct reloc_howto_struct): Changed complain_on_overflow field
+ from boolean to emum complain_overflow. Removed obsolete absolute
+ field.
+ (HOWTO): Removed absolute argument.
+ (bfd_perform_relocation): Do overflow checking on all types of
+ fields.
+ * bfd-in2.h: Updated accordingly.
+ * all targets: Updated initialization of reloc howto tables.
+
+Wed Jul 21 20:34:34 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * opncls.c (bfd_create): Don't use C++ keyword "template" as a C
+ variable name.
+
+Tue Jul 20 15:02:23 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * coff-m68k.c (m68k_howto2rtype): Make arg CONST to match callers.
+
+ * elfcode.h: Fix several illegal pointer combination warnings for
+ usages of bfd_alloc and alloca.
+
+ * libnlm.h (nlm_obj_tdata): Rename hidden struct members to avoid
+ apparent Sun C preprocessor recursion. Fix access macros.
+ * nlmcode.h: Remove spurious '&' before several array references.
+
+Tue Jul 20 14:36:27 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * Rename for DOS uniqueness: coff-m68k-un.c -> coff-u68k.c
+ config/m68k-coffun.mt -> u68k-coff.mt.
+ * Makefile.in, configure.in: Corresponding changes.
+
+Tue Jul 20 16:21:52 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf32-sparc.c (elf_sparc_howto_table): Don't use "&" before
+ function name; it's valid without, and some compilers give
+ warnings with it there.
+
+Tue Jul 20 08:21:15 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * bfd-in.h: Apply some of the changes that were made to bfd-in2.h.
+ * bfd.c (union tdata): Add nlm_obj_data;
+ * targets.c (enum target_flavour): Add bfd_target_nlm_flavour.
+
+Mon Jul 19 20:46:18 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * configure.in (*-*-netware, i[34]86-*-netware): New configs.
+ * Makefile.in (BFD32_BACKENDS): Add nlm.o, nlm32.o, nlm32-gen.o.
+ * Makefile.in (BFD64_BACKENDS): Add nlm64.o, nlm64-gen.o.
+ * Makefile.in (CFILES): Add nlm{32,64}.c, nlm{32,64}-gen.c.
+ * Makefile.in (nlm.o, nlm{32,64}.o, nlm{32,64}-gen.o: New targets.
+ * bfd-in2.h (INLINE): Defines moved here.
+ * {aoutx.h, elf.c, elfcode.h}: Move INLINE defines to bfd-in2.h.
+ * libelf.h (CAT4): Move define to bfd-in2.h.
+ * bfd-in2.h (CAT4): Merge CAT4 macro with other CAT macros.
+ * bfd-in2.h (union tdata): Add nlm_obj_data.
+ * bfd-in2.h (enum target_flavour): Add bfd_target_nlm_flavour.
+ * targets.c (bfd_nlm{32,64}_{big,little}_vec): Add prototypes.
+ * targets.c (target_vector): Add bfd_nlm{32,64}_{big,little}_vec.
+ * (libnlm.h, nlm.c, nlmcode.h, nlm{32,64}-gen.c,
+ nlm{32,64}-target.h, nlm{32,64}.c, config/i386-nlm.mt): New files
+ for NLM support.
+
+Mon Jul 19 15:09:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * configure.{hosts,in}: add i[34]86-*-lynxos* support
+
+Mon Jul 19 14:53:30 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * elf.c, elfcode.h, libelf.h: Serious reorganization.
+ Deleted `thunk' structure, merged into tdata, duplicate data
+ eliminated.
+ Rearranged functions, grouping by functionality.
+ Broke up many functions in elfcode.h, re-ordered many parts of
+ file writing to handle unpredictable state of section relocation
+ table as provided by various applications.
+ Still needs cleanup: Merge functions back together, split out
+ data structure with only data that is used only when writing out
+ object file.
+
+ * elf.c (bfd_elf_generic_reloc): New function, taken from
+ coff-mips.c.
+ * elf32-sparc.c (elf_sparc_howto_table): Use it, to work around
+ bfd_perform_relocation lossage.
+
+ * Makefile.in (BFD_LIBS): Include coff-mips.o and coff-msym.o, so
+ that gdb will link.
+ (ofiles): Don't use sort or uniq; do it with sh constructs.
+
+Sun Jul 18 19:42:14 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * coffcode.h: Recognize I386PTXMAGIC.
+ * aoutf1.h, libaout.h: Add M_386_DYNIX.
+ * trad-core.c (TRAD_CORE_USER_OFFSET, TRAD_CORE_STACK_FILEPOS):
+ New macros; use it if defined.
+ * config/symmetry.mh, hosts/symmetry.h: New files.
+
+Fri Jul 16 14:56:31 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * Rename elf{32,64}-generic.c to *-gen.c for 14 char filenames.
+ * Makefile.in: Change accordingly.
+ (CFILES): Add elf64-gen.c.
+
+Fri Jul 16 09:53:23 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c: Use MIPS_AOUT_{OZ}MAGIC rather than {OZ}MAGIC.
+
+Thu Jul 15 16:02:07 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-m88k.c (howto_table): Corrected bitsize for R_PCR26L from
+ 16 to 26.
+
+Wed Jul 14 15:29:56 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hppa.c [HOST_HPPABSD]: Use hpux-style core files.
+ * libhppa.h [HOST_HPPABSD]: Include hpux version of core.h
+
+Wed Jul 14 09:30:48 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * configure.in: Recognize h8300h-*-*.
+
+Tue Jul 13 12:03:00 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * coff-h8500.c (reloc_processing, rtype2howto): New relocation
+ type R_H8500_HIGH_16.
+ * coff-sh.c (r_imm32): Get the width of the reloc right.
+
+Tue Jul 13 16:48:56 1993 Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr)
+
+ * configure.in: Add new target m68k-coffun to the dpx/2.
+ * config/m68k-coffun.mt: New file, renamed from config/dpx2.mt.
+
+Mon Jul 12 10:42:49 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * reloc.c (enum bfd_reloc_code_real): Move SPARC_BASE13 reloc into
+ sparc-aout-specific list.
+
+ * libelf.h (struct elf_obj_tdata): Add field `thunk'.
+
+ * config/sparc-elf.mt (TARGET_BACKENDS): New make variable.
+
+Thu Jul 1 14:52:47 1993 Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr)
+ and Jim Kingdon (kingdon@cygnus.com)
+
+ * elfcode.h: Use memset not bzero.
+ * trad-core.c: Don't include <sys/file.h>.
+ * i386linux.h: Include <sys/file.h>.
+ * coff-m68k-un.c: new file to handle names with underscores on
+ svr3 machines.
+ * coff-m68k.c (m68k_rtype2howto): added #ifdef ONLY_DECLARE_RELOCS
+ to not duplicate the function in the executable.
+ (TARGET_SYM, TARGET_NAME, NAMES_HAVE_UNDERSCORE): new macros needed
+ by coff-m68k-un.c.
+ * coffcode.h (MC68KBCSMAGIC): case added.
+ * targets.c: Add m68kcoffun_vec.
+ * configure.host: added support for Bull dpx/2.
+ * config/dpx2.mh, hosts/dpx2.h: new files.
+ * Makefile.in: added target coff-m68k-un.
+
+Fri Jul 9 00:43:06 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aoutf1.h: Add definition of MACHTYPE_OK.
+
+Thu Jul 8 14:37:44 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Don't subtract the addend
+ again for coff.
+
+ * syms.c, bfd-in2.h: Doc fix.
+
+ * coffcode.h (CALC_ADDEND): Check for common section using the
+ section flag as well as the symbol flag.
+
+Thu Jul 8 13:43:52 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/i386bsd.h: Conditionalize HOST_STACK_END_ADDR on __bsdi__.
+ i386bsd.c: Remove defines of N_TXT*; the versions in aout64.h should
+ be sufficient. Define TEXT_START_ADDR.
+
+Wed Jul 7 10:56:21 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * aoutx.h (translate_from_native_sym_flags): Removed statep
+ argument. Just let an indirect symbol point to the next symbol
+ without forcing the next symbol to be undefined. Changed all
+ callers.
+ * hp300hpux.c (slurp_symbol_table): Changed call to
+ translate_from_native_sym_flags.
+ * targets.c: Added hp300hpux_vec.
+ * Makefile.in (hp300hpux.o): Added dependencies.
+
+Tue Jul 6 13:24:55 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * reloc.c (enum bfd_reloc_code_real): Put simple power-of-two
+ relocs together, and add 64-bit versions.
+ (bfd_generic_get_relocated_section_contents): Argument to alloca
+ is size_t.
+
+ * libbfd.c (bfd_xmalloc_by_size_t): New function.
+ * opncls.c (bfd_cache_init, bfd_open_file): Add prototypes to
+ declarations.
+ (obstack_chunk_alloc): Use bfd_xmalloc_by_size_t.
+ (new_bfd): Prototype-style definition, using DEFUN.
+ (bfd_alloc_grow, bfd_alloc, bfd_zalloc, bfd_realloc): Size
+ argument is type size_t, not bfd_size_type.
+ * ieee.c (obstack_chunk_alloc): Use bfd_xmalloc_by_size_t.
+ * bfd.c (bfd_default_error_trap, bfd_error_trap,
+ bfd_error_nonrepresentabltrap): Prototypes.
+ * libbfd-in.h (bfd_alloc, bfd_zalloc, bfd_realloc,
+ bfd_alloc_grow): Adjusted prototypes for arg type change.
+ * archive.c (get_elt_at_filepos, do_slurp_bsd_armap, normalize,
+ do_slurp_coff_armap, bfd_construct_extended_name_table):
+ Prototypes.
+ * elfcode.h (elf_string_from_elf_strtab): Prototypes.
+ * libelf.h (elf_string_from_elf_section, elf_get_str_section):
+ Prototypes.
+
+ * Makefile.in (ALL_MACHINES): Renamed from BFD_MACHINES.
+ (ofiles): New target. Build a list of unique file names, in case
+ any got duplicated.
+ (TARGETLIB): Use list of files from ofiles.
+ * configure.in: Set BFD_MACHINES and BFD_BACKENDS depending on
+ minimal-bfd flag and target makefile frag contents.
+
+ * elfcode.h (elf_read): Delete static declaration, since function
+ has moved.
+ (elf_map_symbols): Write out section symbols for all sections, for
+ now.
+ (elf_symbol_from_bfd_symbol): Allow match if both symbols are
+ section symbols for the same section.
+ (elf_find_nearest_line): Don't print message, just return false.
+
+ * libelf.h (bfd_elf_locate_sh): Declaration deleted.
+
+Mon Jul 5 16:48:11 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * cpu-h8300.c (h8300_scan): Fix parsing of architecture string.
+
+Fri Jul 2 18:27:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (clean): Remove bfd.h and stmp-bfd.h.
+ (realclean): Remove generated headers.
+
+Fri Jul 2 14:51:51 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * section.c (bfd_set_section_content): Deny if file is not opened with
+ the proper mode, set output_has_begun if file is openened for update.
+ * aoutx.h (aout_*_set_section_content): Remove checks that are now
+ done in bfd_set_section_content.
+
+Fri Jul 2 09:25:20 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * hosts/std-host.h: Removed declarations of printf, fprintf,
+ fcntl, fread and fwrite. They are all error prone for one reason
+ or another. Changed declaration of memchr from char * to PTR.
+
+ * configure.in (mips-*-riscos*): New target; use riscos.
+ * configure.host (mips-*-riscos*): New host; use riscos.
+ * config/riscos.mh (HDEFINES): Add -G 4.
+
+ * libaout.h (GET_SWORD): Use the bfd_h_get_signed entry points
+ rather than casting the result of bfd_h_get.
+
+Fri Jul 2 10:13:48 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in, hosts/delta68.h, config/delta68.mh: Add stuff for
+ Motorola Delta 68.
+
+Wed Jun 30 06:02:43 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * targets.c (bfd_elf64_{big,little}_generic_vec): Declare, and
+ include in search list if BFD64 is defined.
+
+ * libelf.h (CAT4): Added a version for Saber-C, ANSI mode.
+ (bfd_elf64_*): Declarations for 64-bit versions of many routines.
+
+Tue Jun 29 22:50:59 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf64-target.h, elf64-generic.c: New files.
+ * Makefile.in (BFD64_BACKENDS): Include elf64-generic.o.
+ (elf64-generic.o): List dependencies.
+
+ * Makefile.in: List target `all' explicitly before host/target
+ makefile fragments are included, in case they define any new
+ targets.
+
+ * elfcode.h (ELF_R_INFO, ELF_R_SYM): Define as 32- or 64-bit
+ versions as appropriate. Uses updated.
+ (elf_debug_section): Declare before use.
+ (elf_debug_file): New function.
+ (bfd_section_from_shdr, bfd_shdr_from_section, elf_fake_sections):
+ Alignment value in section header is n_bytes, not log2.
+ (new_section_hook): Do nothing for now.
+ (bfd_section_from_shdr): Use Elf_External_Rel[a], not 32-bit
+ version explicitly.
+ (elf_core_file_p): Simplify check for correct class (word size).
+ (elf_make_sections, elf_fake_sections, elf_write_object_contents):
+ Initialize all fields when creating data structures.
+ (elf_locate_sh): Renamed from bfd_elfXX_locate_sh, made static.
+ (elf_compute_section_file_positions): Set correct class in output
+ file.
+ (elf_write_object_contents): Section symbols have empty names in
+ output file.
+
+ * libbfd.c (bfd_xmalloc, zalloc): Be sure to cast malloc, memset
+ args to size_t before call.
+ (bfd_add_to_string_table): Cast zalloc arg to bfd_size_type.
+
+Tue Jun 29 10:49:42 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_find_nearest_line): If procedure has no line
+ number information, return 0 for line number.
+
+Mon Jun 28 10:45:02 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aoutx.h (some_aout_object_p): If *oldrawptr is non-NULL, copy it
+ into *rawptr.
+
+Sun Jun 27 09:05:19 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/riscos.h: Define NBPG and UPAGES.
+
+Sun Jun 27 16:28:26 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * elfcode.h (elf_slurp_symbol_table): Don't use obj_raw_syms as
+ lvalue; it contains a cast.
+
+Fri Jun 25 17:09:55 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (hash, compare, struct stringtab_entry, add_to_stringtab):
+ Use unsigned hash values for better hashing.
+ (hash): Hash in the string length for long strings.
+
+Thu Jun 24 15:47:51 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (compare): Replace 3 if's with a subtraction.
+ (translate_to_native_sym_flags, add_to_stringtab): Reorder tests
+ in decreasing order of success, as an optimization.
+ (hash): Take a length arg; ignore chars after #25, for speed.
+ (add_to_stringtab): Pass length to hash.
+
+Thu Jun 24 17:25:51 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * elf32-sparc.c (sparc_reloc_map): Add SPARC_WDISP22 reloc.
+
+ * elfcode.h (elf_new_section_hook): Do nothing for now.
+ (elf_write_object_contents): Output common symbols the way ELF
+ wants them.
+
+Wed Jun 23 16:20:07 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * libelf.h (struct elf_obj_tdata and associated macros): Moved
+ here from elfcode.h. A couple of size-specific structure pointers
+ were changed to PTR; uses fixed appropriately.
+ (elf32_symbol_type, elf64_symbol_type): Separated definitions.
+ (bfd_elf_mkobject): Renamed from bfd_elf32_mkobject.
+ (bfd_elf32_mkobject, bfd_elf64_mkobject, elf_mkobject): New
+ temporary macros to ease name change.
+ * elf.c (elf_read, elf_mkobject, elf_get_str_section,
+ elf_string_from_elf_section, bfd_elf_find_section): Moved here
+ from elfcode.h.
+ * doc/Makefile.in (libbfd.h): Process elf.c too.
+ * Makefile.in (elf.o): Note new dependencies.
+
+ * elfcode.h: Lots of stuff moved elsewhere. Deleted some unused
+ code, tweaked some debug hooks.
+ (elf_slurp_reloca_table): Translate ELF section symbols into BFD
+ section symbols.
+
+Wed Jun 23 11:34:21 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * hosts/riscos.h: New file.
+
+Tue Jun 22 14:35:20 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * elfcode.h (bfd_section_from_shdr, case SHT_PROGBITS): Even if
+ section already exists, use its pointer to fill in rawdata slot.
+
+Tue Jun 22 16:36:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/std-host.h: Return value of puts and fputs is int not void.
+
+Tue Jun 22 14:25:58 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (howto_table_ext): Comment the field names.
+ * reloc.c (bfd_perform_relocation): Fix max and min values.
+
+Mon Jun 21 18:19:14 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * elf32-target.h, elf32-hppa.c, elfcode.h: Use new
+ size-independent elf internal data structures.
+ * elfcode.h (put_word, get_word): Define as appropriate for
+ architecture word size. Structure swapping functions changed to
+ use them as appropriate.
+
+ * configure.in: If compiling 64-bit back ends, do them before
+ 32-bit ones.
+
+ * libelf.h: Use new size-independent versions of elf internal data
+ structures.
+ (symbol_type): Reordered to put any fields dependent on target
+ size at the end.
+ (elf_backend_data): Renamed from elf##_backend_data and made
+ size-independent.
+ (elf_sect_thunk): Now size-independent.
+
+ * libbfd.c (bfd_log2): Now returns unsigned int.
+
+Mon Jun 21 12:30:47 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * Rename config/m88k-aout.mt to config/noop.mt.
+ configure.in: Use it for mips-*-bsd*.
+
+Sun Jun 20 20:32:19 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * cpu-m68k.c (arch_info_struct): Eliminate "partially bracketed
+ initializer" warning from gcc.
+ * cpu-h8500.c (arch_info_struct): Likewise.
+ * cpu-sh.c (arch_info_struct): Likewise.
+
+ * cpu-h8300.c (local_bfd_reloc_type_lookup, howto*_callback,
+ howto_*): Unused functions and variables commented out.
+ * cpu-z8k.c (local_bfd_reloc_type_lookup, howto*_callback,
+ howto_*): Likewise.
+ * cpu-h8500.c (compatible): Likewise.
+ * cpu-sh.c (compatible): Likewise.
+
+ * hp300hpux.c (swap_std_reloc_in): Delete unused variables.
+ Always set a valid length value, even for invalid input.
+
+ * srec.c (srec_write_symbols): Use sprintf_vma.
+
+ * bfd-in.h (uint64_typeLOW, uint64_typeHIGH, int64_type,
+ uint64_type): Provide default definitions.
+ * hosts/std-host.h (int64 stuff): Remove them from here.
+
+ * bfd-in.h (sprintf_vma): Define parallel to fprintf_vma.
+
+ * elf32-i386.c (elf_i386_reloc_type_lookup): Delete unused
+ variable. Added default case to switch.
+
+ * aoutx.h (translate_from_native_sym_flags): Before casting
+ pointers to integers, make sure the integer type is wide enough.
+ * coff-mips.c (ecoff_set_symbol_info): Ditto.
+
+ * section.c (bfd_get_section_contents): Since `count' is unsigned,
+ don't bother comparing for less-than-zero.
+ (bfd_set_section_contents): Ditto.
+
+ * elfcode.h (bfd_add_to_strtab): Now static.
+ (sym_is_global): New function.
+ (elf_map_symbols): Call it. Now returns void. Removed unused
+ local variable.
+ (bfd_section_from_shdr): Mark string tables other than for section
+ and symbol names as normal sections having contents.
+ (fix_up_strtabs): New function; fixes up ELF header fields for
+ stab sections with string tables associated.
+ (elf_write_object_contents): Map fix_up_strtabs over all BFD
+ sections. Reordered condition tests for symbol flags; default to
+ local-object value instead of global-object.
+ (elf_symbol_from_bfd_symbol): Hid conditionally-used variable
+ inside condition test.
+ (elf_print_symbol): Use fprintf_vma.
+ (elf_idx_of_sym, bfd_shdr_from_section): Unused functions
+ commented out.
+
+ * bfd-in.h (int64_type, uint64_type): Define these if we fall
+ back to "long long" for HOST_64_BIT.
+
+ * libelf.h (elfNAME, ElfNAME): New versions to get desired results
+ without using invalid ANSI C preprocessing tokens.
+
+ * elf32-target.h (bfd_elf32_new_section_hook): Delete macro.
+ * libelf.h (bfd_elf32_new_section_hook): Declare.
+ * elfcode.h (new_section_hook): Define here.
+
+ * hosts/sparc.h, hosts/std-host.h, hosts/i386bsd.h: Protect
+ against multiple inclusions.
+
+ * hosts/news.h: Include hosts/std-host.h, not plain std-host.h.
+
+ * Makefile.in (bfd.h): Generate into current directory by grabbing
+ 64-bit definition (if any) from sysdep.h.
+ * bfd-in.h: Put in marker for sysdep.h inclusion.
+
+Fri Jun 18 19:57:23 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Check for overflow on
+ pc-relative relocations if the howto asked for it.
+
+Fri Jun 18 16:00:20 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * Makefile.in (stmp-bfd.h): Ignore nonzero exit status from grep.
+
+Fri Jun 18 16:54:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config/riscos.m{h,t}: New files.
+ * configure.{host,in}: Use them.
+
+Fri Jun 18 12:55:10 1993 K. Richard Pixley (rich@cygnus.com)
+
+ * elf32-mips.c: comment change. This is a mips file, not 88k.
+
+Mon Jun 14 14:02:41 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * cache.c (bfd_cache_init): Increment open_files and call close_one
+ if necessary.
+ (bfd_open_file): Don't increment open_files here.
+
+Fri Jun 18 10:00:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config/delta88.mh: Don't set CC.
+
+ * Makefile.in: Add elf32-{mips,m88k,generic}.
+ elf32-{mips,m88k,generic}.c: New files.
+ targets.c (target_vector): Include bfd_elf32_{mips,m88k,generic}_vec.
+ elfcode.h (elf_object_p): Match elf32-generic for all machines which
+ don't match a different target.
+
+Fri Jun 18 03:12:12 1993 John Gilmore (gnu@cygnus.com)
+
+ Eliminate "int8_type", "int16_type", "int32_type", and their
+ variants from the BFD universe. Leave the 64-bit types for now,
+ since they are in flux.
+
+ * aoutx.h, hp300hpux.c: Eliminate needless (int32_type) casts.
+ * libaout.h (GET_SWORD): Convert (int32_type) to (int).
+ * ieee.c: Convert uint8e_type => unsigned char.
+ * oasys.c: Extensive changes to eliminate obsolete types.
+ These depend on changes in ../include/oasys.h as well.
+ * hosts/*.h: Remove declarations of all these types.
+
+Mon Jun 14 14:02:41 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * hosts/delta88.h: #if 0 out some declarations which conflict with
+ system headers.
+
+Mon Jun 14 17:08:18 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
+
+ * Makefile.in (install): remove parentdir cruft
+
+Mon Jun 14 19:04:09 1993 Stu Grossman (grossman@cygnus.com)
+
+ * hppa.c (hppa_get_symbol_info): Remove redundant copy.
+ * Expurgate random DEFUNs that have crept in.
+
+Mon Jun 14 10:23:53 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_set_symbol_info): Constructor sections should
+ only be aligned to a 4 byte boundary.
+
+Sat Jun 12 16:13:17 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * hosts/std-host.h (struct int64e_struct): Remove needless typedef
+ keyword.
+
+Fri Jun 11 14:25:34 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * aoutf1.h (sunos4_write_object_contents): set flags to 1, breaking
+ 1927 but fixing some other important things.
+
+Thu Jun 10 20:36:22 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * hosts/std-host.h (int64e_type): Fix definition.
+
+Thu Jun 10 11:48:28 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_sec_to_styp_flags): Use STYP_MIPS_INIT for
+ section named _INIT. Don't set STYP_TEXT unless SEC_CODE is set.
+ (ecoff_styp_to_sec_flags): Treat a STYP_MIPS_INIT section like
+ a STYP_TEXT section.
+
+Wed Jun 9 16:48:13 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in (install, headers): don't put comments after a tab
+ in the actions section of a rule
+
+Wed Jun 9 15:00:01 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_mkobject_hook): Mark ZMAGIC files as D_PAGED.
+ (ecoff_write_object_contents): If not D_PAGED, don't add the
+ section headers to text_size. If not D_PAGED, set the magic
+ number to OMAGIC rather than ZMAGIC. If creating a D_PAGED
+ executable, the executable must fully occupy an even number of
+ pages.
+ (ecoff_set_symbol_info, make_bfd_asection, ecoff_little_vec,
+ ecoff_big_vec): Consistently set section alignment power to 4,
+ since ECOFF sections should be multiples of 16 bytes.
+ (ecoff_little_vec, ecoff_big_vec): Added D_PAGED to object_flags.
+ Made ar_pad_char and ar_max_namelen agree for both.
+
+Tue Jun 8 20:28:02 1993 Mark Eichin (eichin at tweedledumber)
+
+ * elfcode.h (elf_slurp_symbol_table): subtract section vma from
+ symbol value, since bfd symbols are section relative, but ELF
+ symbols aren't.
+
+Tue Jun 8 12:08:27 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * cpu-i960.c, cpu-h8300.c (compatible): Make static.
+
+Tue Jun 8 14:27:56 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * hosts/news.h, config/news.mh: New files.
+
+Tue Jun 8 12:08:27 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * bfd-in2.h, archures.c (bfd_mach_h8300[h]): new defines.
+ * coff-h8300.c: More addressing modes.
+ * coffcode.h (coff_set_arch_mach_hook): Cope with H8300 magic
+ number.
+ * cpu-h8300.c: Removed disassemble stuff. (h8300_scan): Recognise
+ H8/300H name. (compatible): New function.
+ * reloc16.c (bfd_coff_reloc16_get_relocated_sec): Cope with more
+ addressing modes.
+
+Tue Jun 8 10:30:13 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_compute_section_file_positions,
+ ecoff_write_object_contents): Only round to page boundaries if
+ D_PAGED flag is set for the output BFD.
+
+Fri Jun 4 15:47:52 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * coffcode.h (get_index, coff_slurp_symbol_table): Fix pointer
+ casts to work on machine where sizeof(long) != sizeof(int) !=
+ sizeof(char *).
+ * coffgen.c (coff_get_normalized_symtab): Ditto.
+ * cpu-h8300.c coff-h8300.c: Support for H8/300-H.
+
+Fri Jun 4 15:24:27 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * coffgen.c (coff_write_symbols): For empty string table, write
+ out 4 in correct byte order. (from minyard@bnr.ca)
+
+ * elf32-hppa.c: Don't include libhppa.h for now; define
+ BYTES_IN_WORD instead, until Utah sends a better fix.
+ (hppa_elf_build_arg_reloc_stub): Use xmalloc and xrealloc instead
+ of malloc and realloc.
+
+Fri Jun 4 07:49:01 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * configure.in (mips-*-ecoffl*): New target; use decstation.
+ (mips-*-ecoff*): Added trailing '*'.
+
+ * coff-mips.c (ecoff_get_debug): Get the offset from the first PDR
+ for the FDR, not from the first PDR in the file.
+
+Thu Jun 3 16:41:10 1993 Stu Grossman (grossman@cygnus.com)
+
+ * hppa.c (hppa_get_symbol_info): New func needed for JUMP_TABLE.
+
+Thu Jun 3 15:33:57 1993 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * hppa.c (hppa_get_symbol_info): New function.
+
+Thu Jun 3 13:07:42 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elfcode.h (elf_map_symbols): Don't crash if no symbols have been
+ allocated yet.
+
+ From Peter Hoogenboom (hoogen@schafer.cs.utah.edu):
+ * libhppa.h (MAXCOMLEN): Define unconditionally.
+ (_PA_RISC_ID): Only define if not already defined.
+ * elf32-hppa.c: Include libhppa.h.
+
+ From Ralph Campbell:
+ * hosts/mipsbsd.h (HOST_DATA_START_ADDR): Delete definition.
+
+ * elf32-hppa.h (symext_rootP, symext_lastP): Delete decls.
+
+Thu Jun 3 00:23:53 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/go32.mh: define EXTRALIBES to -lm (for binutils), also
+ remove defines of __MSDOS__ and __GO32__ (these are in the
+ compiler now).
+
+Wed Jun 2 17:57:13 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ From Utah:
+ * hosts/hppabsd.h: Eliminate use of obsolete EXFUN.
+ * config/hppabsd.mh: Don't use ranlib.
+
+Tue Jun 1 04:15:57 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * elf.c: New file, for word-size independent code.
+ * elfcode.h (elf_hash): Moved to there, renamed bfd_elf_hash.
+ * Makefile.in: Include elf.o in standard objects.
+
+ * bfd-in.h (CAT3): Define here.
+ * libaout.h, libelf.h: Not here.
+
+ * libelf.h (struct strtab): Define here.
+ (bfd_elf_locate_sh): Declare here.
+ * elfcode.h (struct strtab): Definition deleted.
+
+ * reloc.c (enum bfd_reloc_code_real): Added HPPA_PCREL_CALL_12.
+
+ * Makefile.in: Make "all", not "bfd.h", be the default target.
+ (stmp-bfd.h): New target; prevents rebuilding world if bfd.h
+ hasn't really changed.
+
+ Tue May 25 12:15:15 1993 Michael Meissner (meissner@osf.org)
+
+ * elfcode.h (elf_hash): Provide elf standard hash function.
+ (various): Key off of the machines use_rela_p field to determine
+ whether to use REL or RELA relocations.
+ (elf_swap_reloc_out, elf_swap_reloc_in): New functions.
+ (elf_make_sections): Allocate a pointer to hold all data for a
+ given section, and copy each fragment into the data region.
+ Update the section's pointer with the REL implicit addends if the
+ machine uses REL relocation.
+
+ * elf32-i386.c (elf_bfd_reloc_type_lookup): Rename to
+ elf_i386_bfd_reloc_type_lookup, and use cpp to map the name back
+ into was elf32-target.h expects.
+ (elf_info_to_howto): Rename to elf_i386_info_to_howto.
+ (elf_i386_bfd_reloc_type_lookup): Add relocation support.
+ (elf_i386_info_to_howto): Add minimal relocation support.
+
+ * libelf.h (elf_backend_data): Add use_rela_p, elf_64_p,
+ elf_info_to_howto_rel fields.
+
+ * elf32-target.h (elf_bed): Add support for new fields in
+ elf_backend_data.
+
+ Sun May 30 16:38:24 1993 Peter Hoogenboom (hoogen@fast.cs.utah.edu)
+
+ * elf32-hppa.c: Add symbol extension section support, fix
+ relocation howto table, add stub generation support.
+
+ * elf32-hppa.h: Add symbol extension section support, fix
+ relocation howto table, add stub generation support.
+
+ * elfcode.h (bfd_elf_locate_sh): New function to locate ELF
+ section header.
+
+ * elfcode.h (bfd_add_to_strtab): Made non-static due to a call
+ from elf32-hppa.c.
+
+ * elfcode.h (elf_idx_of_sym): Return STN_UNDEF instead of 0 when
+ the symbol is not found.
+
+ * elfcode.h (elf_compute_section_file_positions): Not all section
+ file positions were computed.
+
+ * elfcode.h (elf_get_sect_thunk): New function.
+
+ * hppa.c (sign_ext): Reimplement.
+
+ * hppa.c (round_down,round,round_up,L,R,LS,RS,LD,RD,LR,RR): Make
+ these functions static.
+
+Tue Jun 1 14:40:41 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in (bfd.h): Move closer to headers - and after 'all'!
+
+ * aoutx.h (translate_from_native_sym_flags): Don't set
+ BSF_DEBUGGING for constructor symbols, only BSF_CONSTRUCTOR.
+ * aoutx.h (translate_to_native_sym_flags): Translate
+ constructor symbols properly.
+
+Thu May 27 16:09:04 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * archures.c (bfd_default_arch_struct): use 4 byte alignment as a
+ minimum.
+ * aout-target.h (minimum_alignment): 8 byte alignment is right.
+ (fix ld/2680)
+
+Thu May 27 13:38:47 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure.in, Makefile.in: Build bfd-in2.h in source directory,
+ from bfd-in.h and .c files. Build bfd.h in build directory,
+ substituting in requested target word size. Insert word size into
+ makefile, and maybe enable 64-bit targets.
+
+ * bfd-in.h, libbfd.c, demo64.c, targets.c: Define BFD64 if 64 bits
+ are available. Conditionalize on this. Assume HOST_64_BIT
+ will be defined if needed, so 64-bit targets are conditionalized
+ only in the Makefile.
+
+Tue May 25 14:03:56 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * libbfd.c (COERCE64): Rewrite to avoid out-of-range values.
+
+ * coff-sh.c (rtype2howto): Put error message on stderr.
+ (extra_case): Delete unused variable.
+
+ * coff-mips.c (ecoff_print_symbol): Cast bfd_vma values to long
+ before calling printf.
+
+ * elfcode.h: New file, almost completely derived from old elf32.c.
+ * elf32.c: Now just define ARCH_SIZE and include elfcode.h.
+ * Makefile.in (elf64.o): List dependencies, don't build by
+ default.
+ (elf64.c): Add to list of sources.
+ (elf32.o): Update dependencies.
+ * elf32-*.c: Updated type/macro/structure names. Cleaned up
+ namespace pollution; rename vectors.
+ * targets.c, config/*-elf.mt: Updated.
+ * All uses of 32-bit versions of structures, routines, and macros
+ renamed.
+
+ * Makefile.in (archures.o, targets.o): Depend on Makefile.
+
+Mon May 24 15:53:13 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * elf32-i386.c (enum reloc_type): No comma after last enumerator.
+
+ * elf32.c (elf_string_from_elf_section): Handle index of zero
+ specially.
+ (bfd_section_from_shdr, elf_slurp_symbol_table): Don't need to do
+ so here.
+ (elf_write_object_contents): Deleted one unused variable and
+ initialized another to avoid gcc warnings.
+ (elf_set_section_contents): Delete unused variable.
+
+Fri May 21 19:04:21 1993 Stu Grossman (grossman@cygnus.com)
+
+ * i386lynx.c: New module for Lynx variant of a.out.
+ * Makefile.in (BFD_BACKENDS CFILES depends): Add i386lynx.c.
+ * gen-aout.c: Get rid of defunct endian stuff, print out true
+ pagesize.
+ * targets.c (target_vector): Add i386lynx_vec.
+
+Fri May 21 17:02:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * configure.in: Use i386-sco.mt for i[36]86-*-isc*.
+
+Fri May 21 13:44:18 1993 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * aix386-core.c, aout-target.h, aoutx.h, coff-alpha.c,
+ coff-mips.c, coffgen.c, elf32.c, ieee.c, libaout.h, libcoff-in.h,
+ libelf.h, mipsbsd.c, oasys.c, sco-core.c, srec.c, tekhex.c,
+ trad-core.c: Define a TARGET_get_symbol_info function or macro.
+ Remove the bfd_print_symbol_nm case from TARGET_print_symbol.
+
+ * bfd-in.h: Don't define bfd_print_symbol_nm.
+ Define symbol_info type.
+ (JUMP_TABLE): Set _get_symbol_info element.
+
+ * syms.c (coff_section_type, bfd_symbol_info): New functions.
+ (bfd_decode_symclass): Use coff_section_type.
+
+ * targets.c: Add bfd_get_symbol_info call.
+
+Wed May 19 15:30:52 1993 Stu Grossman (grossman@cygnus.com)
+
+ * coff-i386.c (coff_i386_reloc): Use unsigned char to avoid
+ complaints from ancient gcc's.
+
+Wed May 19 15:51:19 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * trad-core.c: Check macro TRAD_CORE_EXTRA_SIZE_ALLOWED.
+ hosts/i386linux.h: Define it.
+
+Mon May 17 15:00:33 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * VERSION, bfd-in.h: Bump version number to 2.2.
+
+ * hppa.c (assemble_3, dis_assemble_3, assemble_12,
+ dis_assemble_12, assemble_17, dis_assemble_17, assemble_21,
+ dis_assemble_21, sign_ext, ones, sign_unext, low_sign_ext,
+ low_sign_unext, round_down, round, round_up, L, R, LS, RS, LD, RD,
+ LR, RR, hppa_field_adjust): New functions.
+
+Mon May 17 10:04:16 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_set_symbol_info): Added support for indirect
+ stabs symbols, including new indirect_ptr_ptr argument.
+ (ecoff_slurp_symbol_table): Pass new argument in calls to
+ ecoff_set_symbol_info.
+
+Fri May 14 00:05:06 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure.in: For m68k sysv systems, use m68k-coff.
+
+ * config/hppa-elf.mt (TDEFINES): Don't define DEFAULT_VECTOR here.
+ (TDEFAULTS): Define it here. Use the new name.
+
+ * elf32-hppa.c (elf_hppa_backend_data): Delete; rely on default
+ values instead.
+
+ * reloc.c (bfd_reloc_code_real_type): Add some HPPA reloc types.
+
+ * aix386-core.c (NO_GETS): Fix PROTO invocation to have correct
+ number of arguments.
+ (aix386_core_file_p): Initialize core_size to correct value.
+
+Wed May 12 14:39:59 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (CC_FOR_BUILD): New variable, set to $(CC).
+ (FLAGS_TO_PASS): Pass down CC_FOR_BUILD.
+
+ * bout.c (aout32_slurp_extended_name_table): Define to be
+ _bfd_slurp_extended_name_table rather than bfd_true.
+
+ * coff-mips.c: Include libaout.h and aout/aout64.h to get
+ definitions for N_SET[ATDB].
+ (ecoff_howto_table): Moved near top of file.
+ (ecoff_set_symbol_info): If a STABS symbol of type N_SET[ATDB] is
+ seen, cook up a constructor section of the same name and put in a
+ reloc pointing to the symbol. This lets the GNU linker build
+ global constructors and destructors without using collect.
+
+Tue May 11 00:33:31 1993 John Gilmore (gnu@cygnus.com)
+
+ * coff-m88k.c (m88kbcs_vec): Symbols have underbars.
+
+Mon May 10 05:55:45 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * hosts/miniframe.h: New file.
+ * configure.host: Use it.
+
+Sun May 9 16:36:59 1993 Fred Fish (fnf@cygnus.com)
+
+ * configure.in (hppa*-*-bsd): Change to hppa*-*-bsd*
+ * configure.in (hppa*-*-hpux): Change to hppa*-*-hpux*
+ * configure.in (m68*-hp-bsd): Change to m68*-hp-bsd*
+ * configure.in (m68*-*-hpux): Change to m68*-*-hpux*
+ * configure.in (*-*-bsd): Change to *-*-bsd*
+
+Wed May 5 16:08:32 1993 Per Bothner (bothner@cygnus.com)
+
+ * elf32-hppa.c (elf_hppa_reloc_type_lookup): Cast enums to
+ int, for the sake of the old Portable C Compiler.
+
+Mon May 3 14:37:01 1993 Stu Grossman (grossman@cygnus.com)
+
+ * Makefile.in (CFILES): Add cpu-sh.c and coff-sh.c.
+
+Mon May 3 14:03:21 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * configure.in: Get target name right for m68*-*-hpux.
+
+Sun May 2 11:39:44 1993 Fred Fish (fnf@cygnus.com)
+
+ * trad-core.c (NO_SIGNED_GET): New macro.
+ * trad-core.c (trad_core_vec): Use new NO_SIGNED_GET instead of
+ signed NO_GET, where appropriate.
+
+ * configure.in (i[34]86-*-linux*): Add; bfd_target = i386-linux.
+ * configure.in (*-*-linux*): Remove until linux port for a
+ non-i386/i486 system is actually available.
+
+Fri Apr 30 20:04:10 1993 Stu Grossman (grossman@cygnus.com)
+
+ * libhppa.h: #undef e_* symbols which come from <machine/som.h>
+ when compiling under HPUX.
+
+Fri Apr 30 17:25:23 1993 Stu Grossman (grossman@cygnus.com)
+
+ * The following patches are from Jeffrey Law <law@cs.utah.edu>.
+ * hppa.c (hppa_core_file_p): Provide a temporary dummy routine
+ for HOST_HPPABSD.
+ * bfd/hosts/hppabsd.h: Fix declarations of malloc and free.
+ * bfd/libhppa.h: Include sysdep here. Conditionalize
+ includes based on HOST_HPPAHPUX or HOST_HPPABSD.
+ Provide definitions for MAXCOMLEN and _PA_RISC_ID suitable
+ for BSD.
+
+Fri Apr 30 17:34:11 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf32-hppa.c: Don't include a.out.h. Apparently not even the
+ GNU version is needed.
+
+Fri Apr 30 09:38:59 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * coffcode.h: use dummy_reloc16_extra_cases rather than casting abort.
+
+Thu Apr 29 11:30:32 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * Makefile.in: Build elf32-hppa.o.
+
+ * syms.c (BSF_FUNCTION): New symbol flag.
+
+ * elf32-hppa.c: Fixed to work with elf32-target.h.
+
+ * hp300hpux.c (NAME, NAME_swap_exec_header_in): Fix for
+ traditional C.
+ * libaout.h (NAME): Don't define if already defined.
+
+ * libelf.h: Protect against multiple inclusions.
+ (elf_symbol_type): Moved here, added new fields.
+ (struct elf_backend_data): New field `global_sym'; I suspect this
+ may be misplaced.
+ * elf32.c (elf_symbol_type): Deleted from here.
+ (struct elf_obj_tdata): New fields raw_syms and internal_syms, to
+ point to backend versions of symbols.
+ (obj_symbols, obj_raw_syms, obj_internal_syms): New macros.
+ (elf_swap_phdr_out, elf_build_phdrs, elf_write_phdrs): New
+ functions.
+ (elf_write_object_contents): Write program headers if appropriate.
+ (bfd_section_from_shdr): Unnamed sections get empty string for
+ name, not "unnamed". Handle SHT_NOBITS separately from
+ SHT_PROGBITS, and set some different flags.
+ (elf_file_p): New routine.
+ (elf_object_p, elf_core_file_p): Call it.
+ (elf_object_p): Handle EM_HPPA.
+ (elf_symbol_from, elf_idx_of_sym): New functions.
+ (elf_make_sections): Get symbol number right for relocations. Set
+ SHF_ALLOC, SHF_WRITE, SHF_EXECINSTR when appropriate.
+ (elf_fake_sections): BSS section should be SHT_NOBITS, not
+ SHT_PROGBITS. Always generate symtab and strtab, not only if
+ relocations are needed. Set SHF_* flags as appropriate.
+ (elf_compute_section_file_positions): Handle bfd_arch_hppa.
+ (elf_write_object_contents): Fix off-by-one error in symbol count.
+ Store a correct value for the symbol; write the size field
+ properly; make some guesses about the type field. Set section
+ type correctly for string tables.
+ (section_from_elf_index): Check for absolute and common sections
+ first.
+ (elf_section_from_bfd_section): Ditto.
+ (elf_slurp_symbol_table): Use elf_symbol_type instead of asymbol.
+ Use empty string instead of "unnamed" for nameless symbols.
+ Handle STTY_FUNC type, and weirdness with "$global$" symbol for
+ HPPA (only?). Don't free raw symbols; keep the pointer around for
+ later.
+ (elf_set_arch_mach): Handle bfd_arch_hppa.
+ (elf_find_nearest_line): Just return false.
+ (elf_write_object_contents, elf_set_section_contents): Set
+ output_has_begun field after computing file positions.
+ (elf_set_section_contents): Write section contents immediately,
+ rather than caching the whole file and writing it at close time.
+
+ * libhppa.h (enum hppa_reloc_field_selector_type, enum
+ hppa_reloc_field_selector_typ_alt, enum hppa_reloc_expr_type, enum
+ hppa_reloc_expr_type_alt): New enumerator types.
+
+ * config/hppa-elf.mt,. config/hppaosf.mh: HP PA/OSF support.
+ * configure.in, configure.host: Use them.
+
+Wed Apr 28 23:21:01 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf32-target.h: Allow overrides of armap defaults.
+
+ * elf32-hppa.c, elf32-hppa.h: New files.
+
+ * config/hp300hpux.mt: New file.
+
+Tue Apr 27 05:39:40 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * aix386-core.c (NO_GETS): New macro; NO_GET for signed values.
+ (aix386_core_vec): Update for new fields.
+
+ * archive.c (bfd_generic_archive_p): Call target-specific
+ slurp_armap code, instead of bfd_slurp_armap.
+ (bfd_slurp_bsd_armap_f2): New function.
+ * libbfd-in.h (bfd_slurp_bsd_armap_f2): Declare it.
+ * aout-target.h (AR_PAD_CHAR): Define it if not already defined.
+ (vec): Use it.
+ * libaout.h (struct aoutdata): New field for subformat, for
+ differentiating between highly similar a.out formats.
+ * aoutx.h (NAME_swap_exec_header_in): New macro, defaults to local
+ version of function.
+ (swap_exec_header_in): Don't define if NAME_swap_exec_header_in is
+ already defined.
+ * hp300hpux.c: New file.
+ * Makefile.in: Include it.
+
+Mon Apr 26 13:24:43 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * Makefile.in, archures.c, coffcode.h, targets.c: Support for
+ Hitachi SH.
+
+Mon Apr 26 13:55:42 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * trad-core.c (trad_unix_core_file_p): Check the file size.
+
+Mon Apr 26 13:24:43 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-alpha.c: Remove duplicate function and add warnings.
+
+Mon Apr 26 11:25:58 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * sco-core.c (sco_core_vec): Add initializers for new target
+ fields.
+
+Sat Apr 24 21:33:45 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * coffcode.h [_LIT]: Recognize .lit section.
+
+Fri Apr 23 19:00:36 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-alpha.c, cpu-alpha.c, config/alphaosf.mt,
+ config/alphaosf.mt, hosts/alphaosf.h: New files.
+
+Fri Apr 23 16:48:46 1993 Stu Grossman (grossman@cygnus.com)
+
+ * Merge in HPPA/BSD changes from Utah.
+ * hppa.c: Use this for both HPUX & BSD.
+ * targets.c: Enable hppa_vec for both HPUX & BSD.
+ * config/hppabsd.mt: TDEFINES => TDEFAULTS.
+ * hosts/hppabsd.h: #define HOST_HPPABSD.
+
+Wed Apr 21 01:50:10 1993 John Gilmore (gnu@cygnus.com)
+
+ * libbfd.c: Whitespace changes around byteswap macros.
+ * libbfd-in.h: Whitespace changes around byteswap declarations.
+
+Tue Apr 20 15:59:07 1993 Stu Grossman (grossman@cygnus.com)
+
+ * aoutf1.h (sunos4_core_file_p): Don't default bfd_error to
+ system_error anymore. It confuses bfd_check_format().
+
+Mon Apr 19 23:03:08 1993 Stu Grossman (grossman@cygnus.com)
+
+ * bfd.c: Add sgi_core_data to tdata union.
+ * coff-mips.c: Add Irix 4.x core file support.
+ * hosts/irix4.h: #define HOST_IRIX4.
+
+Mon Apr 19 18:52:52 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * aoutx.h (translate_from_native_sym_flags): Check that the
+ symbol's section does get set.
+ (slurp_symbol_table): Zero index means null-string name.
+
+ * aoutx.h (struct stringtab_entry, struct stringtab_data): New
+ data structures.
+ (hash, stringtab_init, add_to_stringtab, emit_strtab, compare):
+ New functions.
+ (write_syms): Use them, to reduce string table size.
+
+Mon Apr 19 16:45:12 1993 Fred Fish (fnf@cygnus.com)
+
+ * trad-core.c (trad_core_vec): Add 6 new initializers to match
+ new signed get/put fields. Minor reformatting to label
+ some fields.
+
+Mon Apr 19 06:09:41 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * bfd-in.h: Insert comment about SVR3 compiler warnings.
+
+ * hosts/{hp300,i386isc,i386v}.h: Remove unused #defines of {r,}index
+ (bfd uses strchr and the broken SVR3.2 cpp loses with the defines).
+
+ * libbfd.c: bfd_put*: Remove casts to bfd_vma.
+
+Fri Apr 16 17:49:27 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * aoutf1.h (internal_sunos_core): Make c_stacktop a bfd_vma.
+ (swapcore_sparc): Make sp a bfd_vma.
+
+Thu Apr 15 09:09:18 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * libbfd.c: Add signed versions of bfd_{h_,}{get,put}_signed_<size>.
+ libbfd.c, libbfd-in.h: Add _do*signed*.
+ targets.c, all targets: Add bfd*signed*.
+ bfd-in.h: Add bfd_signed_vma. Add comments.
+
+ * bfd-in.h (bfd_error), bfd.c (bfd_errmsgs): Add file_truncated.
+
+ * format.c (bfd_check_error): Check error return from
+ _bfd_check_format routines.
+
+Wed Apr 14 23:48:25 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * rs6000-core.c (rs6000coff_core_p): Improve error checking and
+ recognize .data section if present.
+
+Thu Apr 15 01:00:29 1993 John Gilmore (gnu@cygnus.com)
+
+ * aoutx.h (aout_*_adjust_sizes_and_vmas): Avoid `sanity'
+ check for the case where the user sets the address of the BSS
+ section (and the file header can't specify this). Let the user
+ set it wherever they want, regardless of what goes in the header.
+
+ * ieee.c (ieee_slurp_sections): Pass all ieee section names
+ straight through into BFD sections. Add comments.
+
+Wed Apr 14 20:34:54 1993 John Gilmore (gnu@cygnus.com)
+
+ Cleanup in preparation for better 64-bit host support.
+
+ * bfd-in.h (bfd_64_type): Remove.
+ * libbfd.c (_do_getb64, _do_putb64): Use bfd_vma, not bfd_64_type.
+
+ * bfd-in.h (bfd_size): Remove.
+
+ * bfd-in.h (bfd_offset): Remove, after fixing ld/ldlang.[ch].
+
+ * bfd-in.h (bfd_word): Remove.
+ * reloc.c (reloc_howto_type): Replace bfd_word with bfd_vma.
+
+ * bfd-in.h (rawdata_offset): Remove.
+ * reloc.c (arelent): Replace rawdata_offset with bfd_size_type.
+ (bfd_perform_relocation): Lint.
+ (enum bfd_reloc_status): Comment cleanup.
+
+ * aout-adobe.c, cpu-h8300.c, mipsbsd.c, srec.c: lint -Wall.
+
+Tue Apr 13 11:19:52 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * aoutf1.h (swapcore_sparc): Guess the right value of USRSTACK.
+
+Mon Apr 12 14:18:00 1993 John Gilmore (gnu@cygnus.com)
+
+ * elf32.c: Clean up old comments.
+
+Fri Apr 9 10:43:20 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * config/sun3.h: String argument to fprintf is const.
+
+ * coff-mips.c: Renamed PAGE_SIZE to ROUND_SIZE, to avoid confusion
+ on systems which define PAGE_SIZE in <limits.h>.
+
+Thu Apr 8 10:28:00 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * trad-core.c (trad_unix_core_file_failing_signal): Use new macro
+ TRAD_UNIX_CORE_FILE_FAILING_SIGNAL to allow host files to specify
+ the core file failing signal.
+ * hosts/decstation.h (TRAD_UNIX_CORE_FILE_FAILING_SIGNAL): Define
+ to supply the core file failing signal.
+
+Thu Apr 8 09:17:35 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h (styp_to_sec_flags): Only set SEC_SHARED_LIBRARY for
+ a STYP_NOLOAD | STYP_BSS section if BSS_NOLOAD_IS_SHARED_LIBRARY
+ is defined. On many COFF targets STYP_BSS is always STYP_NOLOAD.
+ * coff-i386.h (BSS_NOLOAD_IS_SHARED_LIBRARY): Define.
+
+Wed Apr 7 11:33:06 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (PAGESIZE): Correct value.
+
+Tue Apr 6 12:05:44 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_find_nearest_line): Address of first PDR is
+ an offset (patch from Jean-Daniel Fekete <jdf@lri.lri.fr>).
+
+Mon Apr 5 12:07:12 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h (styp_to_sec_flags): Set SEC_SHARED_LIBRARY for a
+ STYP_NOLOAD | STYP_BSS section. Don't set SEC_NEVER_LOAD for a
+ STYP_INFO section.
+ (coff_compute_section_file_positions): Force vma and lma of _LIB
+ section to be zero.
+ (coff_set_section_contents): Count number of entries in new lma
+ field, not in vma.
+ * coffgen.c (make_a_section_from_file): Force lineno_count of
+ SEC_SHARED_LIBRARY section to be zero, since it is non-zero on the
+ SCO 3.2v4 shared library.
+ * seclet.c (rel): Copy over any section with contents, not just
+ loadable sections.
+
+ * coff-mips.c (ecoff_make_empty_symbol): Zero out newly allocated
+ symbol.
+
+ * coff-i386.c (coff_i386_reloc): New function, to generate
+ relocateable output correctly.
+ (howto_table): Use coff_i386_reloc for all reloc types.
+ (CALC_ADDEND): Use a more efficient hack to get the correct addend
+ for a common symbol.
+ (i386comm_value): Removed; no longer needed.
+
+Sun Apr 4 15:08:48 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coffcode.h (coff_set_section_contents): Don't write out
+ sections without a filepos.
+
+Fri Apr 2 14:35:05 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * seclet.c (seclet_dump_seclet): Correct SEC_HAS_CONTENTS test.
+
+Wed Mar 31 17:41:05 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * reloc.c (bfd_reloc_code_real_type): Added BFD_RELOC_MIPS_GPREL.
+ * libecoff.h (ecoff_data_type): Added gp_size field.
+ * coff-mips.c (ecoff_mkobject_hook): Initialize gp_size to 8.
+ (ecoff_set_symbol_info): Compare against gp_size, not hardcoded 8.
+ Set flags to 0 for large common symbols.
+ (ecoff_gprel_reloc): Handle non-zero addend for external symbols,
+ which can occur for gas-generated relocs.
+ (ecoff_bfd_reloc_type_lookup): Added BFD_RELOC_MIPS_GPREL case.
+ * bfd.c (bfd_get_gp_size, bfd_set_gp_size): New functions.
+ * Makefile.in (bfd.o): Now depends on coff/sym.h and libecoff.h.
+
+Tue Mar 30 09:33:16 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * srec.c (srec_set_section_contents): Use lma field for load
+ address.
+ * section.c: Add declaration of lma field to section structure.
+ * coffcode.h (coff_write_object_contents): Use lma field for load
+ address.
+ * bfd-in.h (bfd_set_section_vma): Set lma along with vma.
+
+ * aoutx.h (translate_from_native_sym_flags): Now handles indirect
+ symbols in a better way. (translate_to_native_sym_flag): Set the
+ N_INDR bit when necessary. (aout<>slurp_symbol_table): Maintain
+ indirect state.
+ * section.c: Added BFD_IND_SECTION_NAME and bfd_ind_section.
+ (bfd_make_section): Cope with new builtin section.
+ * syms.c (bfd_decode_symclass): Can now print indirect section
+ info.
+
+Wed Mar 24 13:36:33 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * aout-target.h (MY(object_p)): Fail if MACHTYPE_OK is
+ defined, and yields false.
+ * aout-mipsbsd.c, i386bsd.c: Define MACHTYPE_OK appropriately.
+
+ * archive.c (snarf_ar_hdr): Add support for reading (only,
+ so far) BSD-4.4-style extended headers.
+ * archive.c: Some more comments.
+
+Wed Mar 24 02:05:10 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
+
+ * Makefile.in: fix rule for dvi and info, so that the recursive
+ makes does the right thing, instead of always info
+
+Wed Mar 24 02:56:44 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * libbfd.c (bfd_seek): Disable optimized handling for archives and
+ archive members; they need more special reatment. For now, verify
+ that computed and actual file positions correspond.
+
+Tue Mar 23 08:45:33 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * mipsbsd.c: Renamed from aout-mipsbsd.c.
+ (set_arch_mach): Delete non-MIPS code.
+ (reloc_howto_type_lookup): Ditto.
+ * Makefile.in: Adjusted.
+
+ * libbfd.c (bfd_tell): Update `where' field.
+ (bfd_seek): Don't do anything if we're not changing the file
+ position. If FILE_OFFSET_IS_CHAR_INDEX is defined, check `where'
+ field against a SEEK_SET request. Call bfd_tell to re-update
+ `where' field when done.
+ (bfd_read, bfd_write) [FILE_OFFSET_IS_CHAR_INDEX]: Maintain
+ `where' field.
+ * hosts/sparc.h: Define FILE_OFFSET_IS_CHAR_INDEX.
+
+Mon Mar 22 23:18:10 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: added installcheck target
+
+Mon Mar 22 14:57:18 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_set_symbol_info): Relocate encapsulated stabs
+ if the type is not stNil.
+
+Tue Mar 16 10:35:27 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * elf32.c (elf_little_vec, elf_big_vec): Delete now-invalid
+ forward declarations.
+
+ * elf32-sparc.c (elf_sparc_howto_table): Don't use CONST here,
+ it's implied by the type.
+
+Fri Mar 12 18:58:08 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.host: recognize sparc-sun-solaris2* instead of sparc-sun-solaris*
+
+Tue Mar 9 09:23:12 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * rs6000-core.c: Add .ldinfo section.
+
+Fri Mar 12 11:57:52 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (MAKEOVERRIDES): Define to be empty.
+
+Fri Mar 12 08:32:11 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * section.c (bfd_set_section_contents): whitespace
+ * seclet.c (seclet_dump_seclet): Don't try and fill sections with
+ no contents.
+
+Thu Mar 11 19:26:15 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * hosts/go32.h: don't define POSIX_UTIME
+
+Tue Mar 9 10:52:01 1993 Fred Fish (fnf@cygnus.com)
+
+ * elf32.c (elf_object_p): Use ELF_ARCH stored in xvec to match
+ against machine architecture stored in the ELF header, to resolve
+ ambiguities.
+ * elf32.c (bfd_section_from_shdr): Bfd_make_section can return
+ NULL, so only use results when non-NULL.
+ * targets.c (elf32_m68k_vec, elf32_i860_vec): Add extern decls
+ and add to vector of targets.
+
+Mon Mar 8 15:13:44 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_set_symbol_info): Encapsulated STABS symbols
+ are always just debugging symbols.
+
+ * coff-mips.c (ecoff_[gs]et_sym_index): Moved macros from here...
+ libecoff.h (ecoff_[gs]et_sym_index): ...to here.
+
+Mon Mar 8 14:55:13 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hppa.c (_PA_RISC_ID): Defined if not already defined (e.g., for
+ hpux 7). Patch from friedman@gnu.ai.mit.edu.
+ (hppa_object_p): Only check for DL_MAGIC and SHL_MAGIC if they're
+ defined, which they aren't in hpux 7.0.
+
+ * aix386-core.c: Include uinfo.h and coredump.h. Patch from Minh
+ Tran-Le, tranle@intellicorp.com.
+
+Fri Mar 5 14:54:21 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_generic_reloc): If the addend is non-zero, go
+ ahead and do the relocation.
+ (ecoff_refhi_reloc): Don't to the relocation here, just remember
+ what needs to be done.
+ (ecoff_reflo_reloc): Do the REFHI relocation here.
+
+Thu Mar 4 14:44:01 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_bfd_reloc_type_lookup): New function.
+ (ecoff_write_object_contents): Added BFD_ASSERT calls to ensure
+ relocs are reasonable.
+ * coff-msym.c: Eliminated uses of DEFUN.
+ (ecoff_swap_tir_out): New function.
+
+Tue Mar 2 17:52:58 1993 Fred Fish (fnf@cygnus.com)
+
+ (Ultrix 2.2 support from Michael Rendell <michael@mercury.cs.mun.ca>)
+ * configure.host (vax-*-ultrix2*): Add triplet.
+ * hosts/vaxult2.h: New file.
+ * config/vaxult2.mh: New file.
+
+ * aoutx.h (string.h): Include for strchr and friends.
+ * archive.c (string.h): Include for memchr and friends.
+ * elf32.c (string.h): Include for strrchr and friends.
+
+Sat Feb 27 00:44:24 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * aoutf1.c (sunos4_reloc_type_lookup): Unused; deleted.
+ (MY_set_sizes): Use sunos4_set_sizes.
+
+ * elf32.c: Renamed from elf.c. Several CPU-specific functions
+ deleted, as well as elf-big and elf-little targets.
+ * libelf.h: New file.
+ * elf32-sparc.c, elf32-i386.c, elf32-i860.c, elf32-m68k.c: New
+ files, new targets.
+ * Makefile.in, config/*-elf.mt, targets.c: Adjusted.
+
+ * i386linux.c (TARGETNAME): Use hyphens instead of parentheses.
+
+ * coffcode.h (coff_compute_section_file_positions): Don't need
+ variable "old_sofar" if compiling for i960.
+
+ * reloc.c (bfd_default_reloc_type_lookup): First argument is now a
+ bfd pointer.
+ * libbfd.h: Updated.
+
+ * ieee.c (exten, envi): "static" belongs first in declaration.
+
+Fri Feb 26 17:37:34 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * srec.c: add support for symbolsrec, srecords with symbols in
+ them.
+
+Thu Feb 25 11:43:30 1993 John Gilmore (gnu@cacophony.cygnus.com)
+
+ * ieee.c: cast all arguments of ieee_write_byte to bfd_byte
+ to avoid lint complaints.
+
+Thu Feb 25 02:15:52 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf.c (elf_write_object_contents): Section ".shstrtab" should be
+ type SHT_STRTAB. Don't alter file offset for section 0.
+ (reloc_type_names): Now an array instead of a macro. Still inside
+ "#if 0", since it's used only in debugging code also in "#if 0".
+ (struct elf_reloc_map_elt, struct elf_reloc_map): New types.
+ (sort_reloc_map): New function.
+ (sparc_reloc_map): New variable.
+ (elf_bfd_reloc_type_lookup): New function.
+
+Tue Feb 23 12:17:16 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd-in.h (JUMP_TABLE): Added bfd_reloc_type_lookup and
+ bfd_make_debug_symbol; they were already in the target structure.
+ * Adjusted all uses of JUMP_TABLE.
+ * coffgen.c, libcoff-in.h (coff_bfd_make_debug_symbol): Renamed
+ from coff_make_debug_symbol.
+ * libcoff.h: Updated accordingly.
+
+ * Minor cleanups provoked by gcc warnings:
+ * aoutx.h (NAME(aout, reloc_type_lookup)),
+ cpu-h8300.c (local_bfd_reloc_type_lookup),
+ cpu-z8k.c (local_bfd_reloc_type_lookup): Added default case to
+ switches.
+ * archive.c (do_slurp_bsd_armap, do_slurp_coff_armap),
+ ieee.c (ieee_slurp_section_data),
+ elf.c (elf_make_sections, elf_fake_sections,
+ elf_compute_section_file_positions, elf_write_object_contents):
+ Removed unused variables.
+ * archures.c: Removed /* from within comment.
+ * bout.c (b_out_squirt_out_relocs): Initialize r_extern.
+ * oasys.c (oasys_write_data): Initialize i.
+
+Mon Feb 22 18:40:06 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * libcoff.h (obj_raw_syment_coun): New macro.
+ * coffgen.c (coff_get_normalized_symtab): Initialize
+ raw_syment_count.
+ * coffgen.c (coff_find_nearest_line): Numerous little fixes.
+
+Mon Feb 22 15:03:07 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (ecoff_set_symbol_info): stBlock symbols are always
+ debugging symbols.
+ (ecoff_get_debug): Offset the fdr adr by the adr of the first pdr,
+ for compatibility with tools from MIPS.
+
+ * config/bigmips.mt: New file; default vector is ecoff_big_vec.
+ * config/irix3.mt, config/irix4.mt: Removed.
+ * configure.in (mips-*-ecoff): New target; uses bigmips.mt.
+ (mips-sgi-*, mips-big-*): Use bigmips rather than irix3.
+
+Wed Feb 17 23:40:41 1993 John Gilmore (gnu@cygnus.com)
+
+ * hosts/hp300bsd.h: Add gross hack to determine whether we
+ are running on BSD 4.3 or BSD 4.4, and use appropriate include
+ files (and set other parameters) to match.
+
+Wed Feb 17 12:28:13 1993 K. Richard Pixley (rich@cygnus.com)
+
+ * trad-core.c (trad_unix_make_empty_symbol): wrap PARAMS around an
+ ansi definition which otherwise confuses non-ansi compilers.
+
+ * aout-adobe.c (aout_adobe_object_p): eliminate a warning from vax
+ ultrix cc by forward declaring getenv as is done in
+ bfd_find_target.
+
+Tue Feb 16 17:56:58 1993 K. Richard Pixley (rich@cygnus.com)
+
+ * elf.c (elf_info_to_howto): cast an enum into unsigned char
+ avoiding a fatal error in vax ultrix 4.2 cc.
+
+Tue Feb 16 00:44:54 1993 John Gilmore (gnu@cygnus.com)
+
+ * bfd-in.h, VERSION: Roll to version 2.1.
+
+Mon Feb 15 20:43:51 1993 John Gilmore (gnu@cygnus.com)
+
+ * oasys.c (oasys_write_object_contents): Lint.
+ * srec.c: Whitespace cleanup.
+
+Fri Feb 12 14:23:07 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffgen.c (coff_print_symbol): Print correct tagndx value;
+ cleaned up output formatting a bit.
+
+Fri Feb 12 08:28:56 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coffcode.h (coff_set_arch_mach_hook): *FIXME* the H8/300 is always
+ relaxable. Should be moved somewhere else.
+
+Thu Feb 11 14:09:42 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * aout-mipsbsd.c: Eliminated uses of DEFUN.
+ (aout_mips_*_vec): Added seclet_link element.
+
+ * Makefile.in (BFD_BACKENDS, CFILES, aout-mipsbsd.o): Added
+ support for aout-mipsbsd target.
+
+ * bout.c (get_value): Don't truncate 32-bit addend to 16 bits.
+
+Fri Feb 5 08:08:43 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * cpu-h8500.c (scan_mach): return false if it's not an H8/500
+
+Thu Feb 4 12:52:40 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ Add support for the H8/500
+
+ * coff-h8500.c, cpu-h8500.c, archures.c, coffcode.h, targets.c
+
+Thu Feb 4 12:35:02 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * libecoff.h: New file. Defines ECOFF backend data for gdb.
+ * coff-mips.c: Now includes libecoff.h.
+ (ecoff_data_type): Moved to libecoff.h.
+ (ecoff_slurp_symbolic_info): Made globally visible so that gdb can
+ call it. If there is ever another ECOFF target, this and the
+ swapping functions should be accessed via an ECOFF specific target
+ vector.
+ * Makefile.in (coff-mips.o): Depends on libecoff.h.
+
+Wed Feb 3 09:14:36 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h: Removed MIPS specific information, since coff-mips.c
+ no longer includes this file.
+
+ * coff-msym.c (ecoff_swap_fdr_in, ecoff_swap_ext_in): Set reserved
+ bits to 0 to make comparison test useful.
+
+ * config/irix3.mh, config/irix4.mh (HDEFINES): Set to -G 4 to
+ avoid overflowing GP accessible sections in binutils/objdump.
+
+Tue Feb 2 15:36:55 1993 Per Bothner (bothner@cygnus.com)
+
+ * aoutx.h (NAME(aout,slurp_symbol_table)): Made symbol
+ reading more robust: Fail if string index is out of string
+ table range.
+
+Tue Feb 2 11:43:25 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * bout.c (b_out_get_relocated_section_contents, cases PCREL24 and
+ PCREL13): Don't take dst_address into account; the input file has
+ already taken care of that.
+
+Tue Feb 2 11:41:06 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c: Completed support for linker and binutils.
+
+Mon Feb 1 14:45:38 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * bout.c (b_out_get_relocated_section_contents, case ABS32): Keep
+ original addend from section contents.
+
+Thu Jan 28 21:01:37 1993 John Gilmore (gnu@cygnus.com)
+
+ Fix minor bugs reported by Carl Greco, <cgreco@parrot.creighton.edu>:
+ * hosts/delta88.h (strtol): Fix prototype.
+ * config/m88k-coff.mt (SELECT_ARCHITECTURES): Fix name.
+
+Wed Jan 27 17:16:51 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf.c: Get rid of "#ifdef sparc".
+ (RELOC_TYPE_NAMES): Never used (currently), so don't include it.
+ (elf_sparc_howto_table): Renamed from elf_howto_table, and always
+ used.
+ (elf_info_to_howto): Use runtime conditionals on CPU type, not
+ compile type conditionals on host CPU.
+ (elf_little_vec, elf_big_vec): Use bfd_default_reloc_type_lookup,
+ not null pointer.
+ (reloc_type, RELOC_TYPE_NAMES): Include i386 values.
+
+Tue Jan 26 11:43:14 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * section.c (SEC_IS_COMMON): New section flag, needed for MIPS
+ ECOFF which has two common sections.
+ (bfd_com_section): Set SEC_IS_COMMON flag.
+ * bfd-in.h (bfd_is_com_section): New macro to test SEC_IS_COMMON.
+ * aoutx.h, archive.c, bout.c, coff-a29k.c, coff-m88k.c,
+ coff-mips.c, coffgen.c, ieee.c, oasys.c, reloc.c, syms.: Use
+ bfd_is_com_section macro rather than checking for equality to
+ bfd_com_section.
+
+Mon Jan 25 15:27:36 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h (_bfd_coff_mkobject_hook): Pass aouthdr argument.
+ (coff_mkobject_hook): Accept aouthdr argument.
+ * coffgen.c (coff_real_object_p): Pass aouthdr to mkobject_hook.
+ Handle NULL aouthdr argument.
+ (coff_object_p): If there is no aouthdr, pass it as NULL to
+ coff_real_object_p.
+ * libcoff.h: Rebuilt for mkobject_hook changes.
+
+ * coffswap.h (coff_swap_aouthdr_in, coff_swap_aouthdr_in): Swap
+ additional MIPS ECOFF fields.
+
+Sat Jan 23 18:36:20 PST 1993 Ralph Campbell (ralphc@pyramid.com)
+
+ * configure.host: added mips-dec-bsd*
+ * configure.in: added mips-dec-bsd*
+ * aout-mipsbsd.c: new file for mips-dec-bsd*
+ * aout-target.h: don't define '' if 'MY_BFD_TARGET' is defined.
+ * aoutx.h: added mips support.
+ * archures.c: added mips support to bfd_default_scan().
+ * cpu-mips.c: added support for R4000 (untested).
+ * libaout.h: added MIPS1 & MIPS2 magic numbers.
+ * reloc.c: fix typo's in comments. Added BFD_RELOC entries which I
+ hope will make it into include/bfd.h.
+ * targets.c: added aout_mips_*_vec.
+
+Wed Jan 20 17:15:52 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config/decstation.mt: Set DEFAULT_VECTOR to ecoff_little_vec.
+
+Tue Jan 19 09:06:14 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd-in.h (bfd_asymbol_value): Add needed parentheses.
+
+ * libcoff-in.h: Update prototype for coff_count_linenumbers.
+
+Fri Jan 15 18:13:17 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-msym.c (ecoff_swap_hdr_out, ecoff_swap_fdr_out,
+ ecoff_swap_pdr_out, ecoff_swap_sym_out, ecoff_swap_ext_out,
+ ecoff_swap_rndx_out, ecoff_swap_rfd_out, ecoff_swap_opt_in,
+ ecoff_swap_opt_out, ecoff_swap_dnr_in, ecoff_swap_dnr_out): New
+ functions.
+ * coffswap.h: If NO_COFF_RELOCS is defined, don't define
+ bfd_swap_reloc_in or coff_swap_reloc_out.
+ * coff-mips.c: Added code to link and write out symbolic debugging
+ information, and to swap relocs in and out.
+
+Thu Jan 14 15:51:58 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * libcoff.h, coffgen.c (coff_count_linenumbers), coffcode.h
+ (coff_write_object_contents): coff_count_linenumbers returns the
+ number of line number records it found.
+
+ * coffgen.c (coff_write_linenumbers): only write out line numbers
+ in the section they belong to.
+
+Mon Jan 11 18:32:22 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * targets.c (bfd_target): Added relocateable argument to
+ _bfd_get_relocated_section_contents. Added _bfd_seclet_link
+ target vector for linker use.
+ * bfd.c (bfd_seclet_link): New macro.
+ * bfd-in.h (JUMP_TABLE): Added _bfd_seclet_link.
+ * seclet.c (rel, seclet_dump_seclet): Added relocateable argument
+ and boolean return value. Made static.
+ (bfd_generic_seclet_link): Renamed from seclet_dump. Added
+ relocateable argument.
+ * reloc.c (bfd_generic_get_relocated_section_contents): Added
+ relocateable argument (if relocateable, saves relocs).
+ * bout.c (b_out_get_relocated_section_contents),
+ reloc16.c (bfd_coff_reloc16_get_relocated_section_contents): Added
+ relocateable argument (if relocateable, just calls
+ bfd_generic_get_relocated_section_contents).
+ * libcoff-in.h (bfd_coff_reloc16_get_value): Added relocateable
+ argument to prototype.
+ * All targets: Set new _bfd_seclet_link vector to
+ bfd_generic_seclet_link.
+
+Sat Jan 9 21:29:32 1993 Stu Grossman (grossman at cygnus.com)
+
+ * coffgen.c: #include seclet.h.
+
+Sat Jan 9 19:48:14 1993 Stu Grossman (grossman at cygnus.com)
+
+ * hppa.c (hppa_object_setup): Get rid of all knowledge of stabs
+ debug info. Setup info about linker symbols only, and use
+ standard bfd fields to hold the info.
+ * (hppa_object_p): Remove unneeded decls.
+ * (hppa_new_section_hook): Get rid of most of this.
+ * libhppa.h (struct hppadata): Remove ten pounds of useless ugly
+ fat. Remove all knowledge of stabs, remove redundant knowledge of
+ linker symbols.
+ * Remove macros for accessing fields which are now gone.
+
+Fri Jan 8 15:20:00 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coffcode.h (sec_to_styp_flags): allow SEC_NEVER_LOAD to turn on
+ STYP_NOLOAD bit.
+ * coff-z8k.c: delete unused reloc functions
+
+Fri Jan 8 15:47:53 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.c (struct _bfd): Added ecoff_tdata to tdata union.
+ * targets.c (enum target_flavour): Added bfd_target_ecoff_flavour.
+ * coff-msym.c: Use DEFUN for function definitons.
+ * coff-mips.c: Added code to read and print symbols, and to find
+ line numbers.
+
+ * coffcode.h: Moved many generic functions into coffgen.c. Moved
+ swapping functions into coffswap.h for ECOFF use. Moved
+ relocation functions, only used by h8300 and z8k, into reloc16.c.
+ Added hooks for coffgen.c functions to backend data structure, and
+ added hook functions. Still more could be done.
+ * coffswap.h: New file to hold COFF swapping routines.
+ * coffgen.c: New file to hold generic COFF functions.
+ * reloc16.c: New file to hold h8300 and z8k specific relocation
+ functions.
+ * libcoff-in.h: Added declarations for functions in coffgen.c.
+ * libcoff.h: Rebuilt to incorporate changes.
+ * coff-h8300.c: Function name changes.
+ * coff-z8k.c: Function name changes. Use coff_reloc16_extra_cases
+ hook rather than defining EXTRA_CASES.
+ * Makefile.in: Build new files coffgen and reloc16. Added
+ dependencies of coff-*.o on coffswap.h and seclet.h.
+
+Thu Jan 7 16:16:26 1993 Per Bothner (bothner@cygnus.com)
+
+ * ieee.c (ieee_slurp_sections): Add cast to avoid warning
+ about discarding const.
+
+Wed Jan 6 00:16:49 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * archive.c, seclet.c, elf.c use bfd_xmalloc instead of malloc
+
+Tue Jan 5 09:35:57 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * configure.in (post-target): If --with-minimal-bfd is specified,
+ set MINIMIZE=1.
+
+Mon Jan 4 07:20:01 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * srec.c (srec_write_records): one of my boards wants a CR between
+ records.
+
+Wed Dec 30 12:46:30 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * archive.c (do_slurp_coff_armap): set symdef_count correctly
+ (it broke a couple of weeks ago).
+
+Tue Dec 29 21:41:05 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * elf.c (bfd_elf_find_section): Switch back to "struct ..." for
+ return type, so libbfd.h doesn't reference undefined typedefnames.
+
+Tue Dec 29 13:54:35 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h (coff_real_object_p): use name I386AIXMAGIC rather
+ than I386SVMAGIC.
+ (coff_pointerize_aux): don't pointerize a negative tagndx
+ (sometimes generated by SCO 3.2v4 cc).
+
+ * bout.c (calljx_callback, callj_callback,
+ b_out_get_relocated_section_contents): warn if relocating against
+ an undefined symbol.
+
+Mon Dec 28 14:30:55 1992 Stu Grossman (grossman at cygnus.com)
+
+ * hppa.c: Get rid of DEFUN, use more conventional prolog stuff.
+ Make a bunch more routines be static.
+ * hppa.c (fill_spaces): Get rid of this, replace with much better
+ written setup_sections().
+ * (setup_sections): New routine to create BFD sections for each
+ space and subspace in SOM files.
+ * (hppa_object_setup): Use BFD sections created by
+ setup_sections() to locate GDB symbol table info.
+ * (make_unique_section): New routine to create a BFD section. It
+ ensures that the given name is unique, and will generate a unique
+ one if necessary.
+ * (hppa_object_p): Become much more paranoid about file header.
+ * (make_bfd_asection): Call bfd_make_section to do the dirty
+ work. Simplify code somewhat.
+ * (hppa_core_file_p): Use proper name for stack section.
+ * libhppa.h: Remove millicode_start, millicode_end decls.
+
+Mon Dec 28 11:03:22 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * Makefile.in (coff-we32k.o, coff-z8k.o): Note dependencies.
+
+ * reloc.c (bfd_perform_relocation): For normal 2- or 4-byte
+ relocs, don't bother doing the adjustment if the value to add is
+ zero.
+
+Sun Dec 27 17:45:05 1992 Fred Fish (fnf@cygnus.com)
+
+ * bfd.c (bfd_get_size): New function that gets an upper bound
+ on the possible size of any object in a bfd.
+ * elf.c (bfd_elf_find_section, elf_get_str_section,
+ elf_get_symtab_upper_bound): Rewrite to avoid NULL pointer
+ dereferences.
+ * elf.c (elf_big_vec, elf_little_vec): Document last three
+ members initialized to NULL.
+
+Thu Dec 24 17:49:09 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * hppa.c: change a 'const' to 'CONST', or else HP C compiler dies
+
+Mon Dec 21 16:33:34 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * hosts/std-host.h: New file. Attempt at a generic/default
+ set of definitions, to discourage porting to new hosts by copying.
+ * hosts/news.h: Removed.
+ * hosts/sparc.h: Use std-host.h.
+ * bfd-in.h: New macros bfd_asymbol_bfd and bfd_asymbol_flavour;
+ perhaps we can later remove the the_bfd field from each symbol.
+ * syms.c (struct symbol_cache_entry): Remove unused field
+ app_data. Add comment noting that the_bfd is almost redundant,
+ but not quite.
+ * aoutx.h, coff-a29k.c, coff-i386.c, coff-i960.c, coffcode.h:
+ Use new macros bfd_asymbol_bfd and bfd_asymbol_flavour.
+ * hppa.c (fill_spaces): Make slightly more rebust.
+ * configure.in: Allow std-host as the "default" host.
+
+Mon Dec 21 17:24:13 1992 Stu Grossman (grossman at cygnus.com)
+
+ * bfd.c: Add struct hppa_core_data to tdata union.
+ * hppa.c: Conditionalize on HOST_HPPAHPUX instead of hp9000s800.
+ Get rid of HPPA/BSD specific code. That will go somewhere else
+ someday.
+ * (fill_spaces): Don't spin forever and die if you don't find
+ $MILLICODE$ subspace.
+ * (hppa_object_p): Make sure that we have a real honest-to-cthulu
+ exec file!
+ * (hppa_core_file_failing_signal, hppa_core_file_failing_command):
+ Make these work for HPUX.
+ * (make_bfd_asection): New routine to make section creation a
+ little easier.
+ * (hppa_core_file_p): Completely rewrite, leave out bugs.
+ * libhppa.h: #include the right system files. Redefine all of
+ the structs/macros for hacking core files to use more sensible
+ HPUX core file structures.
+ * targets.c (target_vector): Conditionalize hppa_vec on
+ HOST_HPPAHPUX, not hp9000s800.
+ * hosts/hppahpux.h: #include stdlib.h to get correct decls for
+ malloc and realloc. #define HOST_HPPAHPUX.
+
+Mon Dec 21 12:40:10 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Patches from Minh Tran-le <mtranle@paris.intellicorp.com>.
+ * configure.in (i386-*-isc*, i386-*-aix*): New targets.
+ * configure.host (i386-*-isc*, i386-*-aix*): New hosts.
+ * hosts/i386isc.h, config/i386isc.mh: New files for Interactive
+ Unix.
+ * hosts/i386aix.h, config/i386aix.mh: New files for AIX on PS/2.
+ * aix386-core.c: New file for handling core files on AIX on PS/2.
+ * targets.c: if AIX386_CORE, use aix386_core_vec.
+ * coffcode.h (coff_real_object_p): check for I386SVMAGIC as well
+ as I386MAGIC.
+
+Fri Dec 18 10:20:27 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * aoutf1.h (sunos4_write_object_contents): set flags to 0, fixing
+ 1927.
+
+Thu Dec 17 19:35:32 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: added dvi target
+
+Thu Dec 17 00:36:24 1992 John Gilmore (gnu@cygnus.com)
+
+ * bfd.c: Use right name for tekhex tdata struct.
+ * tekhex.c: Insert leading_char (0) into bfd_target struct. Style.
+ * libcoff.h: Updated to get spacing change from coffcode.h.
+ * trad-core.c: leading_char is 0 (no symbols!), not '_'.
+
+Tue Dec 15 15:40:30 1992 Per Bothner (bothner@cygnus.com)
+
+ * archive.c (do_slurp_bsd_armap, do_slurp_coff_armap): New
+ functions, with the "guts" of the old bfd_slurp_bsd_armap
+ and bfd_slurp_coff_armap, but assuming we've already checked
+ if the armap is present or not.
+ Also, rewrite a bit to avoid keeping around obstack data
+ that we don't need.
+ * archive.c (snarf_ar_header, _bfd_slurp_extended_name_table):
+ Various fixes to correctly handle COFF_style archives names.
+ (Note that because these have a trailing '/', the names can
+ have embedded spaces.)
+ * archive.c (bfd_slurp_armap): New function, replaces old
+ bfd_slurp_bsd_armap and bfd_slurp_coff_armap. Recognizes
+ _either_ format, and calls do_slurp_bsd_armap or
+ do_slurp_coff_armap if either form of map is seen.
+ * libbfd-in.h: Changed bfd_slurp_bsd_armap and
+ bfd_slurp_coff_armap into macro synonyms for bfd_slurp_armap.
+ * elf.c (elf_slurp_armap, elf_write_armap): Fix.
+ * Makefile.in (AR_FLAGS): Use rc instead of non-standard qc.
+
+Mon Dec 14 17:08:08 1992 Stu Grossman (grossman at cygnus.com)
+
+ * hppa.c: #include "sysdep.h", not <sysdep.h>.
+ * libhppa.h: Make millicode_start and millicode_end be unsigned
+ int to be same type as CORE_ADDR in GDB. Why are these here?
+
+Sat Dec 12 15:54:36 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-i386.c (CALC_ADDEND): if reloc is PC relative, add the
+ vaddr of the section to the addend.
+ * targets.c: if MINIMIZE is 1, and SCO_CORE is defined, add
+ SCO_CORE to SELECT_VECS.
+ (target_vector): add sco_core_vec.
+ * sco-core.c (sco_core_vec): add leading underscore initializer.
+ * configure.in (i[34]86-*-sco*): use target i386-sco.
+ * config/i386-sco.mt: new file; define SCO_CORE.
+
+Thu Dec 10 02:13:15 1992 John Gilmore (gnu@cygnus.com)
+
+ * aout-adobe.c (aout_adobe_object_p): Fix !strcmp thinko.
+
+Fri Dec 4 14:02:49 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * coffcode.h (bfd_coff_std_swap_table): Now static and const.
+
+Thu Dec 3 16:54:58 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hosts/i386linux.h: Include unistd.h.
+
+ * aoutx.h (print_symbol): aout_stab_name returns a constant
+ string.
+ * libaout.h (aout_stab_name): Fix prototype.
+ * stab-syms.c (aout_stab_names): Array is now const.
+ (aout_stab_name): Return value is now pointer to const.
+
+ * aoutx.h, archive.c, archures.c, coffcode.h, ctor.c, reloc.c,
+ syms.c: Doc fixes.
+
+ * syms.c (asymbol): Added new field "app_data", for data
+ particular to the application. Some of the linker flags ought to
+ get moved to this field someday.
+
+ * archures.c (bfd_default_scan): Recognize a few more numbers:
+ 80486, 80960, and 960.
+
+ * bfd-in.h (COFF_SWAP_TABLE): New is just address of
+ bfd_coff_std_swap_table, cast to PTR.
+ * bfd.c (bfd_coff_swap_*): Deleted macros.
+ * targets.c (struct bfd_target): Deleted COFF-specific swapping
+ routine pointers.
+ * coffcode.h (type bfd_coff_backend_data): New structure type,
+ contains pointers to the COFF-specific swapping routines.
+ (bfd_coff_std_swap_table): New data structure, to be used when
+ NO_COFF_SYMBOLS and NO_COFF_LINENOS are not defined.
+ (bfd_coff_swap_*): New macros.
+ * coff-mips.c (mips_coff_swap_table): New data structure.
+ (ecoff_big_vec): Use it.
+ * All COFF targets: Moved COFF_SWAP_TABLE to target-specific data.
+ * All other targets: Deleted coff-specific vector entries.
+
+ * trad-core.c: Fixed some `PARAMS' uses that were missing
+ parentheses.
+
+Sun Nov 29 08:37:13 1992 Fred Fish (fnf@cygnus.com)
+
+ * aoutx.h (some_aout_object_p): Protect arg prototype in
+ callback_to_real_object_p with PARAMS macro for non-ANSI compilers.
+
+Sat Nov 28 04:01:21 1992 John Gilmore (gnu@cygnus.com)
+
+ * aout-target.h, aoutf1.h, trad-core.c, coffcode.h, libaout.h,
+ libbfd-in.h, bfd-in.h: Eliminate all PROTO calls, replace with
+ PARAMS for readability.
+
+ * aoutx.h: Add type to callback parameter.
+ * coff-mips.c: Don't call trad-core.h, not needed.
+ * trad-core.c: Incorporate trad-core.h declarations. Fix comments.
+ * trad-core.h: Eliminate, unused.
+
+Wed Nov 18 13:16:17 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * format.c (bfd_check_format): if default target isn't found
+ then look through the entire list rather than return early.
+
+Mon Nov 16 14:33:03 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/i960-coff.mt: reorder vec to match bfd_check_format (from Per)
+
+Thu Nov 12 17:01:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: pass down prefix and exec_prefix in FLAGS_TO_PASS
+
+Thu Nov 12 09:46:47 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-z8k.c: checkpoint, more addressing modes handled
+ * coffcode.h (get_value): don't truncate reloc->addend field, it's
+ a long now.
+
+Wed Nov 11 23:57:55 1992 Brendan Kehoe (brendan@cygnus.com)
+
+ * we32k.mt (TDEFAULTS): Use we32kcoff_vec, not i386coff_vec.
+
+Tue Nov 10 14:04:38 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: minor tweaks to make $(CC) command lines more consistent
+
+Mon Nov 9 23:58:17 1992 John Gilmore (gnu@cygnus.com)
+
+ * opncls.c (bfd_fdopenr, bfd_close): Add doc about cacheing
+ and about when file descriptors are closed.
+
+Sat Nov 7 00:42:20 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * bout.c (b_out_squirt_out_relocs): Make sure alignment relocs get
+ written out correctly.
+
+Thu Nov 5 15:34:19 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * section.c: New section bit SEC_SHARED_LIBRARY.
+ coffcode.h (styp_to_sec_flags): if STYP_NOLOAD && (STYP_TEXT ||
+ STYP_DATA), set SEC_SHARED_LIBRARY. This seems to be correct for
+ i386-sysv.
+
+Thu Nov 5 04:43:09 1992 John Gilmore (gnu@cygnus.com)
+
+ * target.c (struct bfd_target): Eliminate the SDEF and SDEF_FMT
+ macros; use PARAMS to declare the function pointers involved.
+
+ * bfd-in.h, bfd.c, libbfd.h, reloc.c, seclet.h, section.c,
+ targets.c: Rename struct bfd_seclet_struct to struct bfd_seclet.
+
+Thu Nov 5 02:59:09 1992 John Gilmore (gnu@cygnus.com)
+
+ Cleanup: Replace all uses of EXFUN in the BFD sources, with PARAMS.
+
+ * archures.c, reloc.c, section.c, tekhex.c: Use PARAMS in
+ declaring pointers to functions.
+ * cache.c, elf.c: Move static function decls to top, use PARAMS.
+ * seclet.h: Declare external function with PARAMS.
+
+ * doc/chew.c (exfunstuff): Eliminate.
+ (paramstuff): Replace exfunstuff with function to generate PARAMS.
+ * doc/proto.str: Use paramstuff rather than exfunstuff.
+
+ * libbfd.h: Update, based on changes in source code and chew.
+
+Wed Nov 4 22:47:29 1992 John Gilmore (gnu@cygnus.com)
+
+ * libieee.h: Add FIXME about removing limit on number of sections.
+ * bfd-in.h: Improve comments to make it clear that bfd.h is
+ the wrong place to edit this file.
+ * Makefile.in (install): Install ansidecl.h and obstack.h in the
+ same places where we install bfd.h.
+
+Wed Nov 4 13:40:23 1992 Sean Eric Fagan (sef@cygnus.com)
+
+ * coffcode.h (coff_swap_aux_out, coff_swap_aux_in): check for
+ symbol type before blindly modifying the auxent. Specifically,
+ only modify the endndx fields for types that need it, and don't
+ set the array information for non-arrays.
+
+Wed Nov 4 09:30:50 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * aoutx.h (some_aout_object_p): Section list should be set up
+ correctly anyways; don't have to set up "next" pointers manually.
+
+Mon Nov 2 12:36:14 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * config/delta88.mh, config/hp300.mh, config/hppahpux.mh,
+ config/i386v.mh: removed -DUSG from HDEFINES.
+ hosts/delta88.h, hosts/hp300.h, hosts/hppahpux.h, hosts/i386v.h:
+ defined USE_UTIME.
+ hosts/i386v.h: don't define POSIX_UTIME.
+
+Fri Oct 30 16:13:52 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * ieee.c (ieee_slurp_sections): make a private copy of the
+ section's name before truncating it.
+
+Thu Oct 29 08:30:50 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * hppa.c: add symbol_leading_char entry in transfer vec
+
+,Wed Oct 28 16:11:57 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * ieee.c (get_symbol): can now cope when two symbols of a
+ different class, but the same index number occur consecutively.
+ (get_section_entry): nicer name for sections being forward
+ referenced. (ieee_archive_p): don't free the filename string,
+ since it was never malloced.
+
+Wed Oct 28 13:42:09 1992 John Gilmore (gnu@cygnus.com)
+
+ * coffcode.h (coff_write_object_contents): Zero timestamp field.
+
+Tue Oct 27 12:24:34 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h (coff_swap_aux_out): set the fcnary info before
+ optionally setting the dimen info, since they are in the same
+ memory locations. Also zero out external auxent.
+ (coff_write_symbol): don't zero external auxent; now done in
+ coff_swap_aux_out.
+
+Fri Oct 23 13:55:35 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Check fclose return value for errors.
+ libbfd.h: bfd_cache_close now returns a boolean.
+ cache.c (bfd_cache_delete): return fclose success value.
+ (bfd_cache_close): return bfd_cache_delete return value.
+ opncls.c (bfd_close, bfd_close_all_done): return result of
+ bfd_cache_close.
+
+Fri Oct 23 10:32:36 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * seclet.c (rel): don't load sections without the SEC_LOAD bit.
+
+Thu Oct 15 10:16:35 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-m68k.c (m68k_howto2type, SELECT_RELOC): new function to
+ work out a coff relocation type from a howto's attributes rather
+ than using the input r_type field. This fixes PR1677 and allows
+ conversion of a.out relocs to coff relocs.
+
+ * coffcode.h (coff_write_relocs): if supplied a relocation
+ relative to an absolute symbol, use the right symbol index.
+
+ * reloc.c (bfd_perform_relocation): do a partial link for coff
+ relocs right.
+
+Fri Oct 23 08:15:56 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * changes to support i386-sysv with shared libraries:
+ * coffcode.h (sec_to_styp_flags): if TWO_DATA_SECS is defined,
+ check for .data2; if _LIB is defined, check for it; map
+ SEC_NEVER_LOAD to STYP_NOLOAD.
+ (styp_to_sec_flags): map STYP_NOLOAD to SEC_NEVER_LOAD.
+ (make_a_section_from_file): if TWO_DATA_SECS, accept .data2.
+ (coff_write_object_contents): force vaddr of .lib to 0; set scnptr
+ if section has contents, not just if it is loadable; if
+ TWO_DATA_SECS, check for .data2
+ (coff_set_section_contents): set vma of .lib section to number of
+ .lib sections.
+ * coff-i386.c: define TWO_DATA_SECS; use a special CALC_ADDEND;
+ don't define coff_write_armap to bsd_write_armap.
+ * hosts/i386v.h: don't include <utime.h>, since it is not provided
+ by SVR3.2.
+
+Thu Oct 22 22:40:20 1992 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * solaris2.h: Get the definition of alloca from alloca.h if we
+ aren't using gcc.
+
+Thu Oct 22 03:07:28 1992 John Gilmore (gnu@cygnus.com)
+
+ * configure.in (i960-*-{aout,bout}): Support these.
+
+Wed Oct 21 03:46:34 1992 John Gilmore (gnu@cygnus.com)
+
+ * config/a29k-aout.mt (DEFAULT_TARGET): Set to one that exists.
+
+Thu Oct 15 15:05:39 1992 Per Bothner (bothner@cygnus.com)
+
+ * apollo68.h, apollov68.h, hp300.h, i386v.h, irix3.h: Remove
+ no-longer-used definitions of L_SET and L_INCR.
+ * i386linux.h: Tweaks to smooth Linux build.
+
+Thu Oct 15 01:32:22 1992 John Gilmore (gnu@cygnus.com)
+
+ * seclet.h: Add enum tag to bfd_seclet_enum_type.
+
+ * bfd-in.h (file_ptr): Update comments, make FIXME re off_t.
+
+ * aout-adobe.c, aoutf1.h, archive.c, bout.c, coff-rs6000.c,
+ coffcode.h, elf.c, ieee.c, libaout.h, libbfd.c, oasys.c,
+ sco-core.c: Lint: Second argument of bfd_seek is always file_ptr.
+ Third argument is SEEK_SET or SEEK_CUR. Result is always 0 or -1.
+
+ * aout-adobe.c, aoutf1.h, aoutx.h, bout.c coff-m68k.c, coff-z8k.c,
+ coffcode.h, elf.c, libaout.h, libbfd-in.h, srec.c: Lint.
+
+Fri Oct 9 03:46:37 1992 John Gilmore (gnu@cygnus.com)
+
+ * configure.host: New file, contains mapping of host configs
+ to host support file names for bfd, binutils, opcodes.
+ * configure.in: Use it.
+ * i386aout.c: Cleanup, dump TARGET_IS_LITTLE_ENDIAN_P.
+ * i386bsd.c: Cleanup, reformat.
+ * config/i386-bsd.mt: Comment changes.
+ * config/i386bsd.mh: New file for core file support.
+ * hosts/i386bsd.h: Merge changes from Peter Schauer.
+ * bout.c (ALIGN): Rename to ALIGNER, since system header files
+ on BSD 4.4 define ALIGN (sigh!).
+
+Thu Oct 8 22:18:10 1992 Mark Eichin (eichin at tweedledumber.cygnus.com)
+
+ * libaout.h (aout_backend_data): added exec_header_not_counted
+ field. For ZMAGIC files only, when text_includes_header is set, by
+ default the length of the exec header is counted in the text
+ section size. For go32, exec header is mapped in but does *not*
+ contribute to the size of section.
+ * aoutx.h (aout_adjust_sizes_and_vmas): if exec_header_not_counted
+ is not set, but ztih is, add the size of the exec header to the
+ recorded size of the text section.
+ * aoutf1.h (sunos4_aout_backend): clear exec_header_not_counted.
+ * i386aout.c (i386aout_backend_data): set exec_header_not_counted.
+ Also set text_includes_header.
+ * aout-target.h (*_backend_data): cleare exec_header_not_counted
+ by default in MY(backend_data).
+
+Thu Oct 8 18:12:49 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * aout-target.h (callback): Don't define this function if it won't be
+ used.
+
+ * aoutx.h (some_aout_object_p): Restore old aout_data value if this
+ type doesn't match. Don't lose if file sections have already been
+ created.
+ (set_arch_mach): Set reloc_entry_size.
+ (slurp_symbol_table): Use bfd_h_get_{16,8} for reaeding symbol data.
+
+ * hosts/i386bsd.h: New file.
+ * configure.in: Recognize i[34]86-*-bsd host.
+
+ * aout-target.h (callback, write_object_contents): Delete unused
+ variables.
+
+ * aoutx.h (reloc_type_lookup): New function.
+ * aout-target.h (MY_reloc_howto_type_lookup): Use it as default.
+ * aoutf1.h (sunos4_reloc_type_lookup): Deleted.
+ (MY_reloc_howto_type_lookup): Don't define it.
+
+ * aoutx.h (adjust_sizes_and_vmas): Don't bother with padding for
+ OMAGIC files.
+ (slurp_symbol_table): Use header byte order, not target byte
+ order, for reading symbol data.
+
+Thu Oct 8 17:33:39 1992 John Gilmore (gnu@cygnus.com)
+
+ * configure.in: Undo some brain damage in the host section.
+ * configure.in: Reformat the target section, test many configs.
+ * Makefile.in (make): Remove obsolete `make make'.
+ * aoutx.h (some_aout_object_p): Make defines line up.
+
+Thu Oct 8 08:52:48 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ Now a bfd knows whether underscores are normally prepended
+ to symbols in its file format.
+
+ * aout-adobe.c, aout-target.h, bout.c, coff-a29k.c, coff-h8300.c,
+ coff-z8k.c: targets set so they have leading underscore
+ * coff-i386.c, coff-i960.c, coff-m68k.c, coff-mips.c, coff-m88k.c,
+ coff-rs6000.c, coff-we32k.c, elf.c, ieee.c, srec.c: targets set
+ without leading underscore flag
+ * targets.c: add symbol leading char to xvec description
+ * bfd-in.h (bfd_get_symbol_leading_char): new macro.
+
+Mon Oct 5 14:32:55 1992 Per Bothner (bothner@cygnus.com)
+
+ * archive.c: Make errno global.
+ * archive.c (_bfd_write_archive_contents): If read fails (and
+ errno!=0) set bfd_error to malformed_archive (since this probably
+ indicates a truncated archive), rather than system_call_error.
+
+Mon Oct 5 03:33:39 1992 Mark Eichin (eichin at tweedledumber.cygnus.com)
+
+ * Makefile.in: added rules for i386bsd.c
+ * i386bsd.c: new file, supporting 386bsd.
+ * configure.in: recognize i386-*-bsd target.
+ * config/i386-bsd.mt: new file - 386bsd target configuration.
+
+Thu Oct 1 17:51:07 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: re-arrange host section to use *-*-* notation,
+ clean up some of the target section as well
+
+ * seclet.c: cast result of bfd_get_relocated_section_contents to
+ avoid compiler warnings
+
+Tue Sep 29 13:24:09 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * coffcode.h (coff_section_symbol): Create section if it doesn't
+ already exist.
+
+ * bout.c: Removed some unused variables.
+
+Tue Sep 29 08:30:21 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Portability fixes from p3:
+ coffcode.h (coff_write_relocs): removed sanity check until it
+ works on all targets (per advice from sac).
+ config/hp9000.mh: new file to define USG.
+ hppa.c: #undef hppa before the JUMP_TABLE.
+ hosts/hppahpux.h: #define NATIVE_HPPAHPUX_COMPILER if not
+ __STDC__.
+ targets.c (bfd_target_list): if NATIVE_HPPAHPUX_COMPILER, make
+ local variable target volatile to avoid mysterious bug in
+ HP9000/700 cc.
+
+Sat Sep 26 03:58:49 1992 John Gilmore (gnu@cygnus.com)
+
+ * config/hppabsd.mh, config.hppahpux.mh: Remove various bogosity.
+ * hosts/hppahpux.h: Remove bcopy and index circumventions.
+
+Fri Sep 25 22:36:52 1992 John Gilmore (gnu@cygnus.com)
+
+ * coff-z8k.c (func_da, func_jr): Lint.
+ * coffcode.h: Use memset rather than bzero.
+ * elf.c: Use memcpy rather than bcopy.
+ * tekhex.c: Use memset rather than bzero.
+
+Fri Sep 25 19:14:48 1992 John Gilmore (gnu@cygnus.com)
+
+ Add Adobe a.out support.
+
+ * aout-adobe.c: New file. So far, only reads a.out.adobe. FIXME.
+ * config/adobe.mt: Add.
+ * configure.in (*-adobe-* target): Add.
+ * targets.c (a_out_adobe_vec): Add.
+ * Makefile.in: add aout-adobe.c.
+
+ * configure.in: Put two dashes in all entries to be matched.
+ Add comments to remind people to do this.
+ Reorder all entries that match manufacturer names, to occur
+ last, so they will only be matched if no more specific match
+ occurs. Remove manufacturers `aout', `bout', `coff', and `elf'.
+
+Fri Sep 25 15:03:22 1992 Brendan Kehoe (brendan@rtl.cygnus.com)
+
+ * elf.c (section_from_elf_index): Return bfd_abs_section, not 0,
+ since we should never have a NULL section.
+ (elf_slurp_symbol_table): If st_shndx doesn't match any of our
+ tests, set the section to bfd_abs_section.
+
+Fri Sep 25 11:11:57 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-z8k.c: getting closer
+ * coffcode.h (coff_get_relocated_section_contents): allow
+ EXTRA_CASES hooks for different arches to provide different reloc
+ types.
+ * seclet.h: #ifndef around it to allow multiple inclusion
+ * srec.c: minor doc fix
+
+Mon Sep 21 14:33:58 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * hosts/hp9000.h, hosts/irix3.h: changes from WRS.
+
+Sun Sep 20 08:48:25 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in: Use i386-elf for all i386/i486 sysv4 hosts, not
+ just ncr.
+
+Thu Sep 17 06:40:46 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * bout.c (b_out_slurp_reloc_table): Clear howto field before
+ filling in reloc, in case immediately following code doesn't set
+ it.
+
+Fri Sep 11 15:37:06 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * coffcode.h (coff_renumber_symbols): set the last renumbered
+ symbol pointer to NULL, as expected by coff_write_linenumbers.
+ (coff_write_relocs): apparently a non-zero addend is OK for reloc
+ type R_IHCONST used on the 29k.
+
+Thu Sep 10 13:28:24 1992 John Gilmore (gnu@cygnus.com)
+
+ * opncls.c (bfd_fdopenr): Determine whether to fdopen for
+ update, based on how the underlying file was opened. Obsoletes
+ FASCIST_FDOPEN.
+ * hosts/rs6000.h, hosts/tahoe.h, hosts/vaxbsd.h: Remove
+ all FASCIST_FDOPEN config defines.
+
+Tue Sep 8 21:37:58 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * sparc-opc.c: Moved to opcodes library, now that we have one.
+ * Makefile: Don't compile it.
+
+Tue Sep 8 10:10:34 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * aoutx.h: adjust_sizes_and_vmas did not return anything.
+
+Thu Sep 3 19:29:04 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * section.c (bfd_set_section_flags): Remove a sanity check.
+ It is unfortunately broken, and prevents strip from working.
+
+Thu Sep 3 16:14:40 1992 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * sparc-opc.c (condr): Remove extraneous, but harmless, backlash
+ created by last change.
+
+Thu Sep 3 13:52:38 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * reloc.c (reloc_howto_struct): Make size field be unsigned.
+ * bfd-in.h: Bump to version 2.0.
+
+Thu Sep 3 09:05:37 1992 Stu Grossman (grossman at cygnus.com)
+
+ * bout.c, cpu-z8k.c: Use enums when initializing structs to keep
+ braindamaged HP/Apollo compiler happy.
+
+Wed Sep 2 02:53:29 1992 John Gilmore (gnu@cygnus.com)
+
+ * format.c: Fix description of search for matching target.
+ * aoutx.h (some_aout_object_p): Set SEC_CODE and SEC_DATA.
+ * targets.c: Update description of search for matching target.
+ * Makefile.in (do_clean, clean): Fix infant mortality typo.
+ (docdir): Set to ./doc, not ${srcdir}/doc, which has no makefile.
+ (z8k and we32k files): `*.o: *.c': avoid Sun Make bug.
+
+Wed Sep 2 00:26:32 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in: Added mostlyclean/clean/distclean rules.
+
+Tue Sep 1 13:38:40 1992 Per Bothner (bothner@cygnus.com)
+
+ * targets.c (target_vector): Take out oasys (unless that is
+ the default): Because there is no magic number in archives,
+ there can be annoying target mis-matches.
+
+Mon Aug 31 10:11:37 1992 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * sparc-opc.c: Rigorously updated to match architecture manual.
+
+Mon Aug 31 08:07:58 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * aoutx.h (aout<n>swap_ext_reloc_out), bout.c
+ (b_out_squirt_out_relocs): fix bug 1506 where abs symbols attached
+ to the built-in abs_section were not written out correctly.
+
+Fri Aug 28 16:29:15 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * archive.c (bfd_slurp_bsd_armap): if the symdef_count is too
+ large, assume we're using a swapped byte order and fail with
+ wrong_format rather than dumping core.
+
+Fri Aug 28 15:38:03 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * Renamed opc-sparc.c to sparc-opc.c for systems with short
+ filename constraints.
+ * Makefile.in: Updated to reflect change.
+
+Thu Aug 27 13:05:28 1992 Brendan Kehoe (brendan@cygnus.com)
+
+ Add preliminary support for the we32k:
+
+ * Makefile.in, archures.c, coffocode.h, configure.in, targets.c:
+ Minor edits.
+ * coff-we32k.c, cpu-we32k.c, config/we32k.mt, hosts/we32k.h: New files.
+
+Wed Aug 26 14:20:16 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bout.c: added support for relaxable alignment relocs.
+
+ * seclet.c (rel, seclet_dump_seclet, seclet_dump): get the app to
+ pass down pointer to play area rather than use alloca
+
+ * cpu-z8k.c (compatible): made static to reduce name space
+ polution.
+
+Tue Aug 25 08:39:10 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ Add basic support for the z8k:
+
+ * Makefile.in, archures.c, coffcode.h, configure.in, reloc.c,
+ section.c, targets.c,
+
+ * syms.c: move mis-inserted patch.
+
+Fri Aug 14 15:39:29 PDT 1992 Howard Chu (hyc@hanauma.jpl.nasa.gov)
+
+ Documentation fixes:
+ * ctors.c, format.c, section.c, reloc.c: append " -" to item tags.
+ * reloc.c, section.c, syms.c, targets.c: add DOCDD before @node
+ comments.
+ * reloc.c: break out addend item from surrounding text.
+
+ * doc.str (DOCDD): Defined. Adds text to output.
+ (bodytext): Put bulletize before kill_bogus_lines.
+ * chew.c (bulletize): End itemization after a blank line, to
+ prevent following text from being swallowed up in an item.
+
+Mon Aug 24 20:50:22 1992 Stu Grossman (grossman at cygnus.com)
+
+ * configure.in: Add sparclite as a target.
+
+Mon Aug 24 12:06:31 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * ieee.c (ieee_get_symtab): always null terminate the symbol list,
+ lint.
+
+ * coffcode.h (coff_add_missing_symbols): if symbols don't come
+ from a coff file (csym is null), dont deref them
+
+ * ieee.c (parse_expression): get the answer right when adding an
+ abs+(sec+off), (ieee_generic_stat_arch_elt): call ieee_object_p
+ on elts so that filename is filled in.
+
+Thu Aug 20 19:05:48 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * bout.c (howto_align_table): New set of relocs, with enough
+ data for "objdump -r" to work.
+ (b_out_reloc_type_lookup): Recognize alignment relocs.
+
+Tue Aug 18 12:57:45 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: added FLAGS_TO_PASS, and used it for all recursive
+ invocations of make. Also, always create installation
+ directories.
+
+ * config/apollov68.mh: removed -g from CC definition.
+
+Mon Aug 17 13:40:08 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * config/decstation.mh (HDEFINES): Specify "-G 4" to avoid
+ overflowing gp-offset range.
+
+Mon Aug 17 11:44:28 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * srec.c (srec_set_section_contents): don't write out sections
+ without the LOAD and ALLOC attributes
+
+Mon Aug 17 11:55:07 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * archures.c, cpu-m68k.c, cpu-sparc.c: Undo 16 June changes.
+ * libaout.h (struct aout_backend_data): New callback "set_sizes".
+ * aout-target.h (callback): Don't set page/seg sizes.
+ (mkobject): Ditto.
+ (set_sizes): New routine.
+ (backend_data): Point to it.
+ * aoutf1.h (sunos4_set_sizes): Heed architecture when setting sizes.
+ (sunos4_aout_backend): Point to it.
+ * aoutx.h (set_arch_mach): Call set_sizes callback.
+
+Fri Aug 14 19:22:18 1992 Per Bothner (bothner@cygnus.com)
+
+ * aout-target.h: Make _bfd_slurp_extended_name_table be
+ the default. Given that we *write* the suckers (for long
+ archive member names), we really ought to be able to read them!
+ * trad-core.c: Don't include <machine/reg.h>. It doesn't
+ seem to be needed, and many machines don't have it.
+
+Thu Aug 13 09:53:39 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-m68k.c (vector): read and write archives in coff format.
+
+Tue Aug 11 12:19:42 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * opc-sparc.c: New file.
+
+Sat Aug 8 23:15:35 1992 Fred Fish (fnf@cygnus.com)
+
+ * bout.c (bfd_reloc_status_type, callj_callback): Cast void*
+ pointers to bfd_byte* before performing arithmetic on them. Such
+ use with bare void* pointers is a gcc extension.
+ * cache.c (bfd_cache_delete): Forward decl with prototype form.
+ * archive (normalize): Add to CONST to match actual usages with
+ CONST.
+
+Mon Aug 3 00:35:29 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in: Recognize i486 host cpu, and use i386-elf
+ for i486-ncr-sysv4.
+
+Sat Aug 1 13:49:59 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/stratus.mt (CC): Remove definition.
+ * elf.c (bfd_section_from_shdr): Test for the possibility that
+ section_from_elf_index returns NULL and don't dereference it.
+
+Mon Jul 20 02:46:09 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * add hppa_data to bfd tdata (indirectly via sef).
+
+ * config/hppahpux.mh: hpux is -DUSG (patch by sef)
+
+Sat Jul 18 15:50:11 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: error messages to stderr, not stdout
+
+Fri Jul 17 18:32:46 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * bfd.c, cache.c, coff-a29k.c, coff-i386.c, coff-i960.c,
+ coff-m68k.c, coff-m88k.c, demo64.c, libaout.h, libbfd.c,
+ oasys.c, opncls.c, sunos.c, targets.c: removed rcsid's.
+
+Fri Jul 17 17:06:56 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: recognize hppa* instead of hppa
+
+Thu Jul 16 16:39:25 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-m68k.c: added R_RELLONG_NEG reloc type, and changed
+ RTYPE2HOWTO to cope with same.
+ * reloc.c (bfd_perform_relocation): added support for size of -2
+ (subtract a word reloc type). Updated doc.
+
+Thu Jul 16 16:28:09 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: merged changes from progressive, removed rcsid.
+
+ * archures.c, archive.c, Makefile.dos: removed rcsid.
+
+Thu Jul 16 08:08:25 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd-in.h : add BFD_IS_RELAXABLE flag
+ * bout.c (bout_swap_exec_header_[in_out]): new field in exec
+ header e_relaxable, major hackery in callbacks
+ * libaout.h : add space for a_relaxable.
+ * seclet.c (rel): don't relax empty sections
+
+
+Wed Jul 15 07:57:46 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * section.c (STD_SECTION): add some casts to the initializers for
+ dumb compilers
+
+Tue Jul 14 14:06:28 1992 Stu Grossman (grossman at cygnus.com)
+
+ * rs6000-core.c (rs6000coff_core_p): Greatly simplify expression,
+ and add appropriate casts to keep (picayune) aix-cc happy.
+
+Mon Jul 13 05:06:51 1992 John Gilmore (gnu at cygnus.com)
+
+ * elf.c (elf_slurp_symbol_table): Now 2nd arg is where to write
+ symbol pointers. Punt expensive & useless bfd_realloc. Use
+ malloc for raw symbols, and free it before returning.
+ (bfd_section_from_shdr): Do not slurp symbol table until politely
+ asked. Do not even slurp string tables.
+ (elf_get_symtab_upper_bound): Count 'em without reading them.
+ (elf_get_symtab): This is how to politely ask. Schlurp!
+ This should probably just *become* elf_slurp_symbol_table, FIXME.
+
+Wed Jul 8 16:24:33 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * archive.c (bsd_write_armap): write the timestamp of the
+ archive header to be just a little bit later than the timestamp of
+ the file, otherwise the linker will complain that the index is
+ out of date.
+
+Tue Jul 7 00:23:23 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in: Add m68k-ericsson-*.
+
+Sat Jul 4 03:29:41 1992 John Gilmore (gnu at cygnus.com)
+
+ * syms.h: Define BSF_FILE, update BSF_SECTION_SYM desc.
+ * elf.c: Remove unconditional debug printf's.
+ (elf_write_object_contents, elf_slurp_symbol_table): Handle
+ BSF_SECTION_SYM <=> STT_SECTION, BSF_FILE <=> STT_FILE.
+ (elf_slurp_symbol_table): Hand out symbols in forward, not
+ reverse order. Simplify duplicate code.
+
+Fri Jul 3 20:23:34 1992 Fred Fish (fnf@cygnus.com)
+
+ * elf.c: Remove "(void)" casts from function calls where the
+ return value is ignored, in accordance with GNU coding standards.
+
+Tue Jun 30 16:49:12 1992 Fred Fish (fnf@cygnus.com)
+
+ * hppa.c: Apply John's standard fix to avoid "empty translation
+ unit" warnings from some ANSI-C compilers.
+
+Thu Jun 25 04:39:25 1992 John Gilmore (gnu at cygnus.com)
+
+ * hosts/solaris2.h: Configure same as sysv4.
+
+Tue Jun 23 21:54:44 1992 Fred Fish (fnf@cygnus.com)
+
+ * libbfd.h, libbfd-in.h (bfd_seek): Make prototype match definition.
+ * reloc.c (bfd_default_reloc_type_lookup): Make cast on return
+ type match actual return type.
+ * elf_print_symbol (section_name): Make CONST.
+
+Mon Jun 22 17:35:24 1992 Per Bothner (bothner@cygnus.com)
+
+ * i386linux.c, hosts/i386linux.h, config/i386-linux.mt:
+ New files, for Linux (a free Unix clone for 386 machines).
+ * Makefile.in, configure.in, targets.c: Update accordingly.
+
+Fri Jun 19 20:23:21 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+ Lints for bfd_reloc_code_type->bfd_reloc_code_real_type, and
+ correct calling of howto special functions and fixes from Raeburn
+ for gas<>bfdness
+ * archures.c: nuke bfd_reloc_code_type
+ * bout.c, cpu-h8300.c, coff-i960.c, coff-m88k.c: special function lint
+ * coffcode.h (styp_to_sec_flags): STYP_INFO is marked as
+ SEC_NEVER_LOAD, various other bfdgas newness
+ * reloc.c->libbfd.h: change protype of bfd_default_reloc_type_lookup
+ * targets.c: change jump table vector to above
+
+
+Fri Jun 19 19:00:45 1992 John Gilmore (gnu at cygnus.com)
+
+ * elf.c (bfd_elf_find_section): Mark as INTERNAL_FUNCTION so
+ its prototype will be included in libbfd.h. Change result type
+ to struct * (rather than equivalent typedef) so it can be used in
+ the prototype, where they typedef won't be known.
+ * libbfd.h: Updated version.
+
+Fri Jun 19 15:21:56 1992 Stu Grossman (grossman at cygnus.com)
+
+ * Makefile.in, archures.c, configure.in, cpu-hppa.c, hppa.c, libhppa.h,
+ targets.c: HPPA merge.
+
+Fri Jun 19 12:21:38 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Separate Solaris2 from SYSV4 on SPARC.
+ * config/solaris2.mh: Kludge around Sun compiler bug.
+
+Wed Jun 17 14:02:46 1992 Stu Grossman (grossman at cygnus.com)
+
+ * libaout.h (aout_backend_data): Change defs of two bitfields to
+ be unsigned chars instead to get around rs6000 compiler problem.
+
+Wed Jun 17 13:55:31 1992 Fred Fish (fnf@cygnus.com)
+
+ * elf.c (bfd_section_from_shdr, elf_slurp_symbol_table):
+ Correct misconception that there can be only one symbol table.
+ Only call elf_slurp_symbol_table on the full symbol table, not
+ the dynamic one which is only a subset of the full one.
+
+Wed Jun 17 15:54:57 1992 Ken Raeburn (Raeburn@Cygnus.COM)
+
+ * coffcode.h (coff_compute_section_file_positions): For I960,
+ don't align sections in file.
+
+Tue Jun 16 06:28:21 1992 Ken Raeburn (Raeburn@Cygnus.COM)
+
+ * targets.c (struct bfd_target): Added field for target-specific
+ (but not file-specific) data, for distinguishing minor
+ characteristics between (e.g.) a.out formats.
+
+ * section.c (struct sec): New field user_set_vma indicates vma
+ field should be heeded, not assumed to be unset.
+ (STD_SECTION): Initialize that field of standard sections to zero.
+ * bfd-in.h (bfd_set_section_vma): Set user_set_vma to true.
+
+ * coffcode.h (coff_write_relocs): Write out swapped reloc, not
+ pre-swapped version.
+
+ * archures.c (struct bfd_arch_info): Fixed order of comment and
+ field decl. New fields indicate size of page and segment for
+ architecture.
+ * cpu-m68k.c (N): Fill in values.
+ * cpu-sparc.c (arch_info_struct): Ditto.
+
+ * libaout.h (struct aout_backend_data): Various bits of data (not
+ all used currently) with characteristics of a.out implementation.
+ Important field for now is text_includes_header, indicating that
+ the text section starts immediately after the file header, which
+ gets mapped in with it.
+ (struct aout_data): New fields indicate whether vma has been
+ adjusted yet (not yet used), and what magic number will be used in
+ the output file (should go away in favor of vma_adjusted).
+ (WRITE_HEADERS): Code for dealing with section sizes and related
+ header fields replaced with call to adjust_sizes_and_vmas.
+ * aoutx.h (some_aout_object_p): Fill in magic number field.
+ Set WP_TEXT flag for ZMAGIC as well as NMAGIC files.
+ (set_arch_mach): Set page size and segment size once CPU
+ type is known.
+ (adjust_sizes_and_vmas): New function; has much code moved
+ from set_section_contents and WRITE_HEADERS. Sets or adjusts vma
+ and size parameters, as well as many header fields, after deciding
+ on magic number for output file. Checks to ensure that this
+ adjustment has only been done once.
+ (set_section_contents): Call adjust_sizes_and_vmas instead of
+ doing much of the work here.
+
+ * aout-target.h (MY_make_debug_symbol, MY_backend_data): Provide
+ default (null) values of these fields.
+ * aoutf1.h (sunos4_write_object_contents): Don't override a_text
+ value in exec header.
+ (sunos4_aout_backend, MY_backend_data): Define backend data
+ indicating file header is included in text section.
+
+ * aoutf1.h (MY_reloc_howto_type_lookup): Fix typo.
+
+ * hosts/sparc.h (abort, exit): Hide these names if compiling with
+ gcc version 2, to avoid warnings.
+
+Mon Jun 15 12:26:56 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/ncr3000.mh (INSTALL, RANLIB): Don't use /usr/ucb/install,
+ it's broken on ncr 3000's. Use simple "true" for RANLIB.
+
+Sat Jun 13 09:16:43 1992 Michael Tiemann (tiemann@rtl.cygnus.com)
+
+ * configure.in (m680[01234]0-wrs-*): Fix typo in match pattern.
+
+Fri Jun 12 19:48:34 1992 John Gilmore (gnu at cygnus.com)
+
+ * section.c (STD_SECTION): Remove extra semicolon in declarations.
+ * configure.in: Rewrite target parsing to use simple format.
+ Handle sparc-sun-solaris2 configuration.
+ * aout64.h: Avoid ANSI C brain death warning.
+ * elf.c: Avoid trigraph (???) or /* in comments.
+
+Fri Jun 12 14:51:14 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * config/sysv4.mh: new file, RANLIB=echo
+
+ * configure.in: handle Solaris2 as -sysv4 or -solaris2
+
+Thu Jun 11 00:52:03 1992 John Gilmore (gnu at cygnus.com)
+
+ * elf.c (elf_obj_tdata): Merge elf_obj_tdata_struct and
+ elf_core_tdata_struct into a single common struct. Core files
+ wouldn't have worked at all without this.
+ (bfd_elf_find_section): New function for GDB's undercover use
+ to find string sections that BFD hides from it.
+ (elf_get_str_section): Avoid multiple alloc&reads for same data;
+ lint.
+ (elf_object_p, elf_core_file_p): Allocate internal file header
+ storage dynamically.
+ * bfd.c (union {...} tdata): Remove elf_core_tdata_struct.
+ * demo64.c: Prevent "empty translation unit" warnings from idiots.
+
+Tue Jun 9 17:15:26 1992 Fred Fish (fnf at cygnus.com)
+
+ * config/{i386v4.mh, ncr3000.mh}: Update RANLIB, add INSTALL.
+
+Sat Jun 6 17:02:51 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Handle Solaris2 as *-sun-sysv4 or as *-sun-sunos5.
+
+Sun May 31 05:45:00 1992 david d `zoo' zuhn (zoo@cygnus.com)
+
+ * configure.in: handle m680[01234]0 as aliases for m68k
+
+Tue May 26 16:50:59 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-a29k.c: do byte relocs correctly
+ * coffcode.h (styp_to_sec_flags): never load INFO sections
+ * seclet.c (rel): don't relocate INFO sections
+
+Wed May 20 08:18:18 1992 Ken Raeburn (Raeburn@Cygnus.COM)
+
+ * section.c (bfd_*_symbol, bfd_*_section): Initialize statically.
+ Make the symbols unmodifiable.
+ (bfd_section_init): Deleted.
+ * init.c (bfd_init): Don't call bfd_section_init.
+
+ * section.c (bfd_set_section_contents): Ensure that range to be
+ written is within section boundaries.
+ (bfd_get_section_contents): Likewise. Don't bother dispatching if
+ size is zero.
+
+ * libbfd.c (bfd_xmalloc): Text of error message should be const.
+
+ * coff-i960.c (howto_table): Deleted.
+ (howto_rellong, howto_iprmed, howto_optcall): New vars;
+ interesting entries from old howto_table.
+ (RTYPE2HOWTO): Adjusted to use switch.
+ (coff_i960_reloc_type_lookup): New function.
+
+ * coffcode.h (coff_new_section_hook): Allocate storage for aux
+ records for section symbol.
+ (make_abs_section): Unused; deleted.
+ (renumber_symbols): Re-order symbols so undefined symbols come
+ last, as COFF format desires.
+ (coff_write_symbol): Put C_FILE symbols in debug section always.
+ (coff_section_symbol): New function; creates a symbol with the
+ same name as a section, and sets up aux records for it.
+ (coff_add_missing_symbols): New function; adds section symbols to
+ symbol table if they aren't there already. Should someday also
+ add a dummy C_FILE symbol if none is present.
+ (coff_write_object_contents): Add missing symbols before preparing
+ symbol table to be written.
+ (coff_slurp_reloc_table): Verify that symbol indices read in are
+ in a reasonable range.
+ * libcoff-in.h (struct coff_tdata): New field conv_table_size.
+ (obj_conv_table_size): Accessor macro.
+
+ * bout.c (b_out_reloc_type_lookup): New function. Handles three
+ reloc types on i960.
+
+ * bfd-in.h (bfd_get_section_name): New macro. Like
+ bfd_section_name, but returns rvalue, not lvalue.
+ (bfd_get_section_vma, bfd_get_section_alignment): Similar.
+ (bfd_get_section_flags): Now returns rvalue.
+
+ * reloc.c (enum bfd_reloc_code_real): Add several new values, some
+ general, some specific to sparc or i960.
+
+ * aoutx.h (set_section_contents): Set VMA for each section based
+ on previous section. If text section VMA doesn't appear to have
+ been set, make a best guess from the type of file.
+
+ * aout-target.h (MY_reloc_howto_type_lookup): Define as zero if
+ not defined.
+ (MY(vec)): Initialize reloc_type_lookup field.
+
+ * aoutx.h (howto_table_*): Export as aout_#_*_howto_table.
+ (bfd_error_trap, bfd_error_vector): Extern, not common.
+
+ * aoutf1.h (sunos4_reloc_type_lookup): New function. Handles a
+ few types of relocs for sparc; will need enhancement.
+
+ * bout.c (callj_callback): Use DEFUN macro in definition.
+ * coff-i960.c (optcall_callback): Likewise.
+
+ * targets.c (bfd_target): Added fields reloc_type_lookup and
+ _bfd_make_debug_symbol. Also minor comment changes.
+ * syms.c (bfd_make_debug_symbol): New dispatching macro.
+ * reloc.c (bfd_reloc_type_lookup): Take a BFD ptr as arg rather
+ than arch info, and dispatch with BFD_SEND. Callers changed.
+ * archures.c (struct bfd_arch_info): Deleted field
+ reloc_type_lookup.
+ * cpu-*.c: Don't initialize that field.
+
+ * bfd-in.h (enum bfd_error): Add new value "bad_value".
+ * bfd.c (bfd_errmsgs): Now const; added entry for bad_value.
+ (bfd_errmsg): Now returns ptr to const.
+ * bfd-in.h (bfd_errmsg): Fix prototype.
+
+ * cache.c (BFD_CACHE_MAX_OPEN): Fix typo in doc.
+ * reloc.c (bfd_generic_relax_section): Ditto.
+
+ * section.c (Section Output doc): Improve description of use of
+ output_section and output_offset.
+
+Tue May 19 23:42:10 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * sco-core.c: new file from net.
+ * aoutx.h (translate_to_native_sym_flags): bugfix from net:
+ Now we have the hairy linker, it's possible to move symbols from
+ one section into another. Actually make that work!
+
+Sat May 16 17:57:59 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * hosts/sun3.h: fix declaration of free.
+
+Tue May 12 14:08:59 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-a29k.c (perform_reloc): fix bug in jmp/call evaluation
+ * coff-h8300.c (reloc_processing): all relocs are relative to
+ section start.
+ * opncls.c: don't use fdopen on DOS systems
+
+ short patches from Glenn Kasten (glenn@ready.com)
+ * target.c: enabled oasys support
+ * oasys.c: Insert . when UNDERSCORE_HACK is enabled,
+ fix problem where a relocation which crossed a modification byte
+ boundary did not work. Fix problem where a relocation near the end
+ of a data record did not work.
+
+
+Tue May 5 18:11:25 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * archive.c (bfd_slurp_coff_armap): old versions of BFD wrote
+ archvie header string counts the endian way, this heuristic sees
+ how big an archive string to read by trying it one way and if the
+ string table is unreasonably big, trying it the other. *FIXME*.
+ * opncls.c (bfd_fdopenr): can't do fdopens on VMS
+
+Tue May 5 14:18:24 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * bfd-in.h: Increase version number to 1.97, for consistency
+ with ../binutils.
+ * Makefile.in: docdir is ./doc, not ${srcdir}/doc.
+
+Mon May 4 11:49:15 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd-in.h: bump version to 1.96
+ Major change; changed calling convention for
+ bfd_get_relocated_section_contents so that caller allocates
+ memory for section data.
+ * coffcode.h (bfd_coff_get_relocated_section_contents), reloc.c,
+ seclet.c, targets.c, bfd.c: reflect new convention.
+ * coffcode.h (styp_to_sec_flags): if styp_flags is not a special
+ case, then use reasonable default values for SEC_* flags.
+
+Fri May 1 12:58:34 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coffcode.h (coff_write_object_contents): use RELSZ to work out
+ size of output reloc struct.
+ * targets.c, Makefile.in: comment out tekhex for the moment.
+ * ieee.c: if some places where null pointers were used instead of &bfd_abs_section.
+ * configure.in: tandem target is st2000
+ * coff-m68k.c: rename static howto_table to global
+ m68kcoff_howto_table.
+ * bout.c: remove unnecessary abort
+ * coff-a29k.c: various changes to the way relocations work to cope
+ with the "new order" and latent bugs.
+ * coffcode.h: lint
+
+Wed Apr 29 12:37:07 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * aoutx.h (aout_swap_ext_reloc_out, aout_swap_std_reloc_out)
+ bout.c (b_out_squirt_out_relocs): treat abs sumbols the right way.
+ * reloc.c (bfd_perform-relocation): don't relocate refs to
+ absolute symbols if doing a partial link.
+
+Fri Apr 24 07:35:26 1992 Stu Grossman (grossman at cygnus.com)
+
+ * configure.in: Add a29k-amd-udi.
+
+Thu Apr 23 18:37:55 1992 Fred Fish (fnf@cygnus.com)
+
+ * aoutx.h (aout_<bits>_swap_exec_header_in): Zero out the
+ internal_exec structure before initializing the fields that
+ are used, so that the unused fields are in a known state.
+
+Wed Apr 22 09:36:08 1992 Fred Fish (fnf@cygnus.com)
+
+ * tekhex.c (struct data_struct): Convert from typedef that
+ typedefs nothing to a normal structure declaration.
+ * tekhex.c (pass_over): Prototype args for function that
+ second arg points to.
+
+Mon Apr 20 22:22:51 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: remove old style staging. Do not print recursion
+ lines.
+
+ * Makefile.in: rework CFLAGS so that CFLAGS can be passed from the
+ Makefile command line. Remove MINUS_G. Default CFLAGS to -g.
+ Pass CFLAGS.
+
+Fri Apr 17 09:15:31 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.c, Makefile.in: added tekhex
+ * aoutx.h (set_section_contents): pages should be padded to the
+ size of a page, not the size of a segment.
+ * configure.in: added go32 host and i386-aout target.
+ * i386aout.c, libaout.h: now works for go32 target
+ * ieee.c: fix bit rot.
+ * seclet.c: support for padding seclet type.
+
+Wed Apr 15 18:11:58 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: added .NOEXPORT:
+
+Tue Apr 14 14:34:42 1992 Fred Fish (fnf@cygnus.com)
+
+ * elf.c (bfd_add_strtab, bfd_add_2_to_strtab): CONST spreads
+ like ooze.
+ * elf.c (elf_compute_section_file_positions,
+ elf_write_object_contents): Return boolean, not NULL (which
+ can be void *).
+ * elf.c (bfd_section_from_shdr): Ifdef-out debugging code.
+ Also ifdef-out code that aborts on unhandled section types.
+
+Fri Apr 10 22:29:18 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in: Recognize ncr3000 config
+ * Makefile.in (MINUS_G): Pass on to recursive makes.
+ * hosts/ncr3000.h, config/ncr3000.mh: Add host config files.
+
+Thu Apr 2 17:42:45 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Now that we have sym.h and symconst.h, compile
+ coff-msym.c on all systems.
+ * config/{decstation.mh, irix3.mh, irix4.mh}: Remove coff-msym.o dep.
+ * coff-msym.c: Update include files and comments; add weakext bit.
+
+Wed Apr 1 23:16:38 1992 John Gilmore (gnu at cygnus.com)
+
+ * archive.c, bfd.c, bout.c, coffcode.h, init.c, reloc.c,
+ section.c, srec.c, syms.c, coff-h8300.c: Lint.
+
+Sun Mar 29 09:37:59 1992 John Gilmore (gnu at cygnus.com)
+
+ * bout.c, coff-a29k.c, coff-i960.c: Lint.
+ * configure.in: Add new host and target configs.
+ * elf.c (bfd_prstatus, bfd_fpregset): Avoid typename of register
+ structs, which vary; just use member name.
+ (elf_object_p, elf_core_file_p): Lint, fix comments.
+ * config/sparc-elf.mt, hosts/sysv4.h: New config files.
+
+Sat Mar 28 13:07:02 1992 Fred Fish (fnf@cygnus.com)
+
+ * elf.c (elf_object_p, elf_core_file_p): Fix to use only a single
+ local, disposable, copy of the external form of section header
+ table and program header table entries.
+
+Thu Mar 26 16:59:58 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Set MINIMIZE back to 0 for a real release.
+
+Tue Mar 24 15:57:03 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure.in: config/irix4.m[ht], hosts/irix4.h: add support for
+ irix4.
+
+Mon Mar 23 22:37:34 1992 Stu Grossman (grossman at cygnus.com)
+
+ * coff-msym.c (ecoff_swap_rfd_in): remove & for array ref.
+
+Tue Mar 17 14:12:25 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * bout.c (b_out_slurp_reloc_table): Use BFD_ASSERT macro,
+ not internal bfd_assert function (twice).
+
+Tue Mar 17 10:45:12 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * aout-target.h: change ar_max_namelen to 15 (the right value)
+ * coff-a29k, coffcode.h: more hangovers from the bfd_abs_section
+ change
+
+Mon Mar 16 14:57:22 1992 Steve Chamberlain (sac@rtl.cygnus.com)
+
+ * archive.c (bfd_generic_archive_p): check for bout archives too.
+ * bout.c: make it work again.
+
+Sat Mar 14 17:30:40 1992 Fred Fish (fnf@cygnus.com)
+
+ * elf.c (elf_corefile_note): Call bfd_xmalloc() instead of bare
+ malloc().
+ * reloc.c (bfd_generic_get_relocated_section_contents): Call
+ bfd_xmalloc() instead of bare malloc().
+
+Fri Mar 13 15:44:37 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: pass down MAKEINFO on info.
+
+Fri Mar 13 07:41:13 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * config/mt-<foo> now <foo>.mt, config/mh-<foo> now <foo>.mh.
+ host/h-<foo> now just <foo>.
+ * configure.in: reflect changes
+
+Thu Mar 12 11:15:02 1992 Per Bothner (bothner@cygnus.com)
+
+ * libbfd-in.h (set_tdata): Make change of Feb 27 in the
+ actual source file, not just the generated libbfd.h.
+
+Sat Mar 7 10:33:41 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * coff-i960.c (icoff_little_vec): add COFF_SWAP_TABLE so we can run
+ gdb on little-endian 960 code.
+ * archive.c (compute_and_write_armap): indirect symbols should go
+ into the archive header too.
+
+Fri Mar 6 21:55:16 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: added check target.
+
+Thu Mar 5 23:51:42 1992 John Gilmore (gnu at cygnus.com)
+
+ * coff-msym.c: Move this file from gdb/ecoff.c. It
+ handles byte-swapping for ECOFF (MIPS symbol) files.
+ * config/mh-decstation, config/mh-irix3: Add coff-msym.o
+ to the files built on MIPS-based hosts.
+ * Makefile.in: Add rule for coff-msym.
+
+Thu Mar 5 21:36:05 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: added clean-info target. MINIMIZE=1.
+
+Sun Mar 1 22:32:58 1992 Per Bothner (bothner@cygnus.com)
+
+ * coff-rs6000.c: Move core file functions into separate
+ new file rs6000-core.c. This is needed because reading
+ core files depends on native include files that conflict
+ with ../include/coff/rs6000.h.
+ * config/mh-rs6000: Add rs6000-core.o to HDEPFILES.
+
+Thu Feb 27 22:19:55 1992 Per Bothner (bothner@cygnus.com)
+
+ * aoutx.h (NAME(aout,print_symbol)): Don't print
+ symbol addresss for undefined symbols.
+ * coff-rs6000.c: Various updates (due to target-
+ independent changes).
+ * libbfd.h: Ditto (tdata field is now a union).
+ * hosts/h-sparc.h: Removed prototype for bogus function
+ 'emset' (presumably should have been 'memset' - which is there).
+
+Thu Feb 27 11:46:33 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in (mips-big-* target): Same is Iris.
+
+Thu Feb 27 09:24:56 1992 Steve Chamberlain (sac at thepub.cygnus.com)
+
+ * aoutx.h (translate_from_native_sym_flags): when creating an
+ alias symbol, fill in the section as undefined, rather than
+ leaving it blank. If an output section can't be found for a
+ symbol, then don't core dump.
+
+Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in, configure.in: removed traces of namesubdir,
+ -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
+ copyrights to '92, changed some from Cygnus to FSF.
+
+Wed Feb 26 19:40:59 1992 Steve Chamberlain (sac at thepub.cygnus.com)
+
+ * bfd.c: lint
+ * coff-h8300.c: fix stupid reloc subtraction bug
+ * coffcode.h (coff_swap_aux_out): only swap a tvndx by 2 bytes,
+ since that's how wide it is. (coff_slurp_symbol_table): always zero out
+ the symbol.flags and done_lineno fields.
+
+Tue Feb 25 14:29:24 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * coffcode.h (coff_write_symbol): write out the correct number of
+ auxents.
+ * cpu-h8300.c: fix disassembly bug
+
+Fri Feb 21 21:39:56 1992 John Gilmore (gnu at cygnus.com)
+
+ * bfd-in.h (bfd_errmsg), coffcode.h (coff_swap_aux_in,
+ section_from_bfd_index), cpu-h8300.c (howto*_callback),
+ reloc.c, section.c (bfd_map_over_sections), targets.c
+ (bfd_target_list): Protolint.
+ * libbfd.h: Update to match a libbfd-in.h from a month ago.
+
+Fri Feb 21 10:57:54 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * coffcode.h (coff_swap_aux_in): lint, (coff_print_symbol): prints
+ out tagndx too.
+ * aoutx.h (swap_std_reloc_out, swap_ext_reloc_out): use the output
+ section of a symbol rather than the section of a reffed symbol to
+ determine the r_index of an emmitted reloc.
+
+Thu Feb 20 18:10:34 1992 Per Bothner (bothner at cygnus.com)
+
+ * PORTING: New (preliminary) porting guide.
+
+Wed Feb 19 21:39:37 1992 John Gilmore (gnu at cygnus.com)
+
+ * bout.c (callj_callback), coff-a29k.c (a29k_reloc), coff-m88k.c
+ (howto_hvrt16): lint.
+
+Mon Feb 17 12:02:17 1992 Per Bothner (bothner at cygnus.com)
+
+ * hp300bsd.c (new), config/mt-hp300bsd: Make hp300bsd
+ a full configuration (with possible cross-development),
+ instead of using host-aout.c.
+
+Sun Feb 16 13:01:49 1992 Per Bothner (bothner at cygnus.com)
+
+ * aout-target.h (MY(write_object_contents):
+ Set obj_reloc_entry_size (abfd).
+ * gen-aout.c: Change to emit a .c files, not a .h file.
+
+Thu Feb 13 20:11:47 1992 Fred Fish (fnf at cygnus.com)
+
+ * elf.c (elf_slurp_symbol_table): Remove obsolete use of
+ BSF_ABSOLUTE and replace with bfd_abs_section reference.
+
+Thu Feb 13 17:22:44 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * coffcode.h (get_normalized_symtab): fixed bug where symbols
+ with more than one auxent can cause nasty core dumps.
+
+ * coffcode.h, libcoff.c: added new fielded to coff_symbol_struct
+ "done_lineno" so that a symbol which appears twice in the symbol
+ table only gets it's linenumbers relocated once. Modifed
+ (coff_write_native_symbol) and (coff_make_empty_symbol) to make
+ use of it.
+
+Tue Feb 4 15:39:55 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * aoutx.h: (translate_from_native_sym_flags): fix constructor
+ stuff to use the New Order.
+
+Fri Jan 31 01:34:45 1992 Stu Grossman (grossman at cygnus.com)
+
+ * ieee.c: Change type of envi[] to unsigned char.
+
+ * configure.in: fix vax ultrix configuration.
+
+ * elf.c (bfd_section_from_shdr): Deal with null return from
+ bfd_make_section(). (elf_object_p): Select endianess properly.
+
+Fri Jan 31 01:19:55 1992 John Gilmore (gnu at cygnus.com)
+
+ * hosts/h-tahoe.h, h-vaxbsd.h: Fix stack in core files.
+
+Thu Jan 30 23:51:07 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: host-aout.c doesn't depend on aout-params.h.
+ * aout-target.h: Use TARGET_BIG_ENDIAN_P to set up vector.
+ * host-aout.c: Don't use aout-params.h; configure these systems
+ in their xm files, not in a randomly generated file.
+ * hosts/h-hp300bsd.h, h-tahoe.h, h-vaxbsd.h, h-vaxult.h:
+ Specify byte order.
+ * hosts/h-vaxbsd.h: Define the form of exec and core files.
+
+Thu Jan 30 13:02:41 1992 Per Bothner (bothner at cygnus.com)
+
+ * config/mt-tahoe, config/mt-vax: Change DEFAULT_VECTOR to
+ host_aout_vec here as well.
+
+Thu Jan 30 11:41:45 1992 Stu Grossman (grossman at cygnus.com)
+
+ * host-aout.c: Change TARGETNAME to "a.out" to be compatible with
+ gdb. config/mt-hp300bsd: Change DEFAULT_VECTOR to host_aout_vec
+ to prevent undefined symbol.
+
+Thu Jan 30 07:26:53 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ Various lints found on PersSony
+ * aoutx.h: cast an enum
+ * coff-a29k.c: many ints in reloc structure turned to enum
+ * coffcode.h: more enums
+ * cpu-h8300.c: more enums
+ * opncls.c: more enums
+
+Thu Jan 30 01:19:56 1992 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Make Tahoe configuration work again.
+ * bfd-in.h: Remove trailing comma from enum declaration.
+ * ieee.c: Can't put byte values >0x7F into a signed char.
+
+Tue Jan 28 21:10:51 1992 Fred Fish (fnf at cygnus.com)
+
+ * Makefile.in: Add dependencies for various coff-*.o files.
+
+ * elf.c: Remove extraneous paren from core_prpsinfo and
+ core_prpstatus macros, rename core_prpstatus to core_prstatus.
+ Replace references to old section "size" member with new
+ "_raw_size" member. Implement elf_make_empty_symbol, which
+ is now used.
+
+Tue Jan 28 14:51:40 1992 Stu Grossman (grossman at cygnus.com)
+
+ * trad-core.c, bfd.c, ../include/bfd.h: Various fixes for PMAX
+ core reading.
+
+Tue Jan 28 10:46:32 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * coffcode.h (bfd_coff_relax_section): now static.
+ (bfd_coff_get_relocated_section_contents): various type lints.
+
+Mon Jan 27 19:44:08 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ New entry point in the transfer vector - bfd_relax_section.
+
+ * aout-target.h: add to vector, call generic_relax
+ * bfd-in.h: add to vector
+ * bfd.c: add #define for vector
+ * bout.c: add to vector, call generic_relax
+ * coffcode.h: add to vector, also now has coff specific relax code
+ for the relaxable H8/300 relocs. Also clean up abs section cruft.
+ * elf.c: call generic_relax
+ * ieee.c: call new vector, clean up some bugs due to the creation
+ of bfd_abs_section
+ * libbfd.h: add bfd_generic_relax_section EXFUN
+ * oasys.c: call generic_relax
+ * reloc.c: implement generic_relax
+ * seclet.c: moved much of this into coffcode.h
+ * srec.c: call generic_relax
+ * targets.c: define new transfer vector
+
+Fri Jan 24 14:40:17 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * everything: now modified to use smaller reloc type. Self hosts
+ on sun3 & sun4.
+
+Sat Jan 18 17:00:16 1992 Fred Fish (fnf at cygnus.com)
+
+ * config/mh-stratus, config/mt-i860-elf, hosts/h-stratus:
+ New files for stratus.
+
+ * configure.in: Add configuration fragments for stratus.
+
+Wed Jan 15 10:02:43 1992 Fred Fish (fnf at cygnus.com)
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Declare various filename
+ variables as CONST since they are set to point to a const char
+ string. Fixes compiler complaints.
+
+Fri Jan 10 17:44:53 1992 Fred Fish (fnf at cygnus.com)
+
+ * hosts/h-amix.h hosts/h-i386v4.h: Change abort() to a function
+ returning void.
+
+Fri Jan 10 14:33:32 1992 Per Bothner (bothner at cygnus.com)
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Recognize N_SOL
+ symbols, so that we can emit the correct file name even
+ if it's an include file.
+
+Thu Jan 2 16:43:34 1992 John Gilmore (gnu at cygnus.com)
+
+ * coff-i960.c: Add COFF_SWAP_TABLE to little_vec as well as big_vec.
+ (Reported by john@labtam.labtam.oz.au (John Carey)).
+
+Wed Jan 1 04:23:06 1992 Fred Fish (fnf at cygnus.com)
+
+ * elf.c: Change all '#if HAVE_PROCFS' to '#ifdef HAVE_PROCFS'.
+
+ * config/mh-amix, config/mh-i386v4: Remove HDEFINES that was
+ being used to -DHAVE_PROCFS.
+
+ * hosts/h-amix, hosts/h-i386v4: Add '#define HAVE_PROCFS'. Move
+ '#include "fopen-same.h"' to end of file to match other h-* files.
+
+Fri Dec 20 12:06:17 1991 Fred Fish (fnf at cygnus.com)
+
+ * configure.in: Change svr4 references to sysv4. Add case
+ "unknown" for target vendor and infer some targets based
+ on the specified operating system.
+
+Wed Dec 18 17:17:59 1991 Stu Grossman (grossman at cygnus.com)
+
+ * bfd-in.h, libaout.h: ANSIfy enums.
+
+Wed Dec 18 16:12:25 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * archive.c (normalize): created version for VMS which removes the
+ VMS directory crap from the front and end of a filename, eg turn
+ [-.foo]bar.obj;123 into bar.obj
+ (bfd_construct_extended_name_table): now writes index into an
+ extended name table in decimal - the same base used to read an
+ extended name table.
+
+Wed Dec 18 14:40:39 1991 Per Bothner (bothner at cygnus.com)
+
+ * aout-encap.c: Fix to use aout-target.h.
+ * aoutf1.h: Use standard MY_object_p and MY_callback
+ in aout-target.h. Remove target-specific versions.
+ * host-aout.c: Re-write to use aout-target.h.
+ * gen-aout.c: New files use with host-aout.c to generate
+ host-specific a.out-related parameters.
+ * Makefile.in: host-aout.o depends on aout-params.h, which is
+ generated by gen-aout.
+ * aout-target.h: Make a little more flexible.
+ * libaout.h, aout-target.h: Removed WORK_OUT_FILE_POSTIONS
+ macro. Instead, inline it in aout-target.h.
+ * newsos3.c: Define N_SHARED_LIB(x) as 0 to avoid
+ a gcc -Wall warning.
+ * archive.c: Add missing commas in DEFUN macro (2 places).
+ * elf.c, coffcode.h, aoutf1.h: Use ANSI functions instead of
+ Berkeley ones, now that libiberty has them:
+ bcopy->memcpy, bzero->memset, bcmp->memcmp.
+ * aoutx.h: Various touch-ups: Re-formatting, fix a cast,
+ remove unused variable.
+
+Tue Dec 17 19:48:59 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf.c (elf_core_file_matches_executable_p): Enclose corename
+ and execname inside HAVE_PROCFS ifdef since they are unused
+ when it is not defined.
+
+Mon Dec 16 12:00:10 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf.c: Flag all sections as either code or data. We can't
+ be sure what they are anyway, since ELF doesn't fit the
+ traditional model of text+data+bss very well. Add new local
+ function elf_read() to simplify code. Record entry point in
+ the bfd structure.
+
+Thu Dec 12 21:01:22 1991 John Gilmore (gnu at cygnus.com)
+
+ * hosts/h-*.h: Configure fopen using ../include/fopen-*.h
+ rather than N copies of the same lines.
+
+Wed Dec 11 16:39:45 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * cpu-h8300.c: disassemble branch displacements correctly
+ * coff-h8300.c: put reloc offsets out in 32bits
+
+ * makefile.dos, configdj.bat: New files from DJ
+ * cache.c: fopen with new macros is needed for DOS.
+ * ieee.c: environ renamed to envi to stop an include file
+ conflict.
+ * opncls.c, coff-rs6000.c: more fopens with macros.
+
+Tue Dec 10 04:07:24 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: infodir belongs in datadir.
+
+Sat Dec 7 16:39:23 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * Makefile.in: fix where docdir lives
+
+ * aoutx.h, archive.c, archures.c, bfd.c, cache.c, coff-m88k.c,
+ coffcode.h, core.c, ctor.c, elf.c, format.c, ieee.c, init.c,
+ libbfd.c, libbfd.h, libcoff.h, opncls.c, reloc.c, section.c,
+ srec.c, syms.c, targets.c : all new documentation and lint
+ removal.
+
+
+Sat Dec 7 07:22:09 1991 John Gilmore (gnu at cygnus.com)
+
+ * coffcode.h, srec.c: Lint.
+
+Fri Dec 6 22:58:48 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: install using INSTALL_DATA, added standards.text
+ support.
+
+ * configure.in: mark directory as target dependent. configure
+ nows works in objdir always so make file existence checks
+ against ${srcdir}.
+
+Thu Dec 5 22:46:19 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: idestdir and ddestdir go away. Added copyrights
+ and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
+ and mandir now keyed off datadir by default.
+
+Wed Dec 4 10:14:17 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * aoutf1.h (sunos_<size>_object_p, sunos4_callback): moved the
+ computation of arch and machine type so it's worked out before
+ some_aout_object_p is called.
+ * aoutx.h: (some_aout_object_p): don't set arch and mach to
+ unknown.
+ * archures.c: add extra field 'section_align_power' to hold
+ default section alignment in object files.
+ * cpu-a29k.c, cpu-h8300.c, cpu-i386.c, cpu-i960.c, cpu-m68k.c,
+ cpu-m88k.c, cpu-mips.c, cpu-rs6000.c, cpu-sparc.c, cpu-vax.c:
+ initialize the new field.
+ * bout.c (b_out_callback): replace the text size, since aout
+ fries them.
+ * aoutx.h: Documentation in the new style
+
+Wed Dec 4 02:00:30 1991 John Gilmore (gnu at cygnus.com)
+
+ * bfd.c (bfd_get_mtime): Don't cache mtime any more; only
+ use the saved value if mtime_set is already set (intended
+ for archive files, though apparently not used yet).
+
+Tue Dec 3 22:54:50 1991 John Gilmore (gnu at cygnus.com)
+
+ * targets.c: Revise comments about how to configure the target
+ vector, to match reality. Remove mention of obsolete methods.
+ Remove long lists of capitalized macros that turn into the same
+ thing in lowercase. Normal vector simply lists all known
+ lowercase xvec names; all other cases are handled by SELECT_VECS.
+
+ * config/mt-i386-coff: Set DEFAULT_VECTOR to real identifier,
+ not macro name.
+
+ * config/mt-i960-{coff,bout}: Use SELECT_VECS to make a short
+ list of supported targets.
+
+Tue Dec 3 14:06:15 1991 Per Bothner (bothner at cygnus.com)
+
+ * archive.c (bsd_write_armap): The pad byte sometimes added to
+ the string table in a __.SYMDEF member is now
+ counted as part of the size of the string table.
+ This is compatible with the old ranlib, as well as Sun's.
+
+Tue Dec 3 10:53:30 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * srec.c: Rewrote to fix many bugs; now gets the record type
+ right, doesn't choke on input, sets the start address in an S9 and
+ fills in the filename on an S0.
+
+Sat Nov 30 21:19:15 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * cpu-h8300.c: Add support for MEMIND addressing mode
+
+ * coff-a29k.c: defined RELOC_PROCESSING to take the #ifdef out of
+ coffcode.h
+ * coffcode.h: use the new macro if available
+
+ * elf.c (elf_corefile_note): cast malloc to avoid warning.
+ * Makefile.in: Fixed dependencies due to file rename
+
+ * aout-encap.c, aoutf1.h, aoutx.h, archive.c, bout.c, coff-a29k.c,
+ coff-h8300.c, coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c,
+ coff-mips.c, coff-rs6000.c, cpu-h300.c, elf.c, i386aout.c,
+ newos3.c, stab-syms.c, syms.c: All these files have had their
+ #includes altered to point to the new places.
+
+Fri Nov 29 20:04:49 1991 Fred Fish (fnf at cygnus.com)
+
+ * config/mh-i386v4, config/mh-i386-elf, hosts/h-i386v4.h: New files.
+
+ * configure.in: Add vendor "ncr" as supported per-target vendor.
+ Add svr4 case for i386 per-host case.
+
+ * elf.c (elf_object_p, elf_core_file_p): Add missing "break" to
+ ELFDATA2LSB cases.
+
+Fri Nov 29 12:16:51 1991 Per Bothner (bothner at cygnus.com)
+
+ * syms.c (bfd_decode_symclass): Return 'A'
+ for symbols that are both absolute and global.
+ * archive.c (bfd_special_undocumented_glue): Return NULL
+ if bfd_ar_hdr_from_filesystem returns NULL.
+
+Tue Nov 26 09:10:55 1991 Steve Chamberlain (sac at cygnus.com)
+
+ * Makefile.in: added coff-h8300
+ * configure.in: now h8 is a coff target
+ * cpu-h8300.c: fix various disassembly problems
+ * libcoff.h: took out some code which has been #0ed for a long
+ time.
+ * targets.c: added h8 coff
+ * coff-a29k.c, coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c
+ added new macro RTYPE2HOWTO to take a load of #ifdefs out of
+ coffcode.h
+ * coffcode.h: Started to change the way machine dependencies are
+ handled, from the nest of #ifdefs to macros defined in the
+ including coff-<foo>.c
+
+Fri Nov 22 08:11:42 1991 John Gilmore (gnu at cygnus.com)
+
+ * aoutx.h (some_aout_object_p): Set the `executable' bit
+ if the entry point is contained in the text segment, even if the
+ text segment is at location 0.
+
+ * coff-mips.c, coffcode.h: Peter Schauer's patch to kludge in
+ nonstandard MIPS sections (.rdata, .sdata, etc).
+
+ * aoutx.h, bfd.c, coffcode.h, ieee.c, oasys.c, targets.c: CONST lint.
+ * libbfd-in.h, libbfd.h, aoutx.h, coffcode.h, elf.c, libaout.h:
+ Rename ALIGN to BFD_ALIGN to avoid conflict with BSD <sys/param.h>.
+ * libbfd.c: Lint.
+ * host-aout.c, trad-core.c: Fix write_armap prototypes. Lint.
+
+Thu Nov 21 19:56:40 1991 Per Bothner (bothner at cygnus.com)
+
+ * stab-syms.c, syms.c: Moved bfd_stab_name() and bfd_stab_names[]
+ from syms.c to new file stab-syms.c. Also, since GNU extended
+ type codes such as N_SETT are no longer in ../include/stab.def,
+ include them manually.
+ * stab-syms.c, aoutx.h: Renamed bfd_stab_name() and
+ bfd_stab_names[] to aout_stab_name() and aout_stab_names[].
+ * libaout.h: Added prototype for aout_stab_name().
+ * Makefile.in: Update Makefile for new stab-syms.[co].
+
+Thu Nov 21 11:50:49 1991 John Gilmore (gnu at cygnus.com)
+
+ * libaout.h (WORK_OUT_FILE_POSITIONS): One more try at this
+ rather complicated seeming problem. Eliminate LOGICAL_ versions,
+ just make N_XXX work by excluding the header from the text segment.
+ * aoutx.h: Fix comments to match.
+
+Tue Nov 19 18:49:01 1991 Per Bothner (bothner at cygnus.com)
+
+ * libaout.h (WORK_OUT_FILE_POSITIONS): Use new LOGICAL_TXTADDR,
+ LOGICAL_TXTOFF, LOGICAL_TXTSIZE macros to figure out numbers
+ for the "logical" text segment (i.e. never consider the exec
+ header to be part of the text segment). This change is
+ needed for consistency with various other parts of bfd and ld.
+ * aoutx.h (NAME(aout,soe_aout_object_p)): Fix comment,
+ and move calculation of obj_textsec(abfd)->size to libaout.h.
+ * bfd-in.h: Removed bogus ';'.
+
+ * Makefile.in: Add MINIMIZE flag to select lean
+ or bloated target_vector.
+ * targets.c: Use new MINIMIZE macro, and add trad_core if needed.
+ * newsos3.c: Fixes to ../include/aout64.h remove need
+ for special N_TXTOFF macro, but require N_HEADER_IN_TEXT.
+
+Mon Nov 18 12:00:59 1991 Per Bothner (bothner at cygnus.com)
+
+ * aout-target.h, aoutf1.h, newsos3.c: Make aout-target.h
+ handle both little and big-endian targets, with little
+ the default unless TARGET_IS_BIG_ENDIAN_P is defined.
+ * host-aout.c: Add FIXME note.
+
+Sun Nov 17 13:29:39 1991 Per Bothner (bothner at cygnus.com)
+
+ * targets.c: Make the default target_vector contain
+ just &DEFAULT_VECTOR. This makes executables a lot smaller.
+ Old behavior can be gotten by defining ALL_TARGETS.
+ * aoutf1.h, demo64.c, i386aout.c, newsos3.c, sunos.c:
+ Factored out common code into new file aout-target.h.
+ Saves a lot of duplicate code for a.out variants.
+
+Fri Nov 15 13:00:43 1991 Per Bothner (bothner at cygnus.com)
+
+ Get 'make headers' to work when configured with +subdirs.
+ * Makefile.in: Add $(subdir) to docdir path.
+ * doc/Makefile.in (protos): Add $(srcdir) prefix
+ to name of sed scripts.
+
+Thu Nov 14 19:49:10 1991 Per Bothner (bothner at cygnus.com)
+
+ * aoutx.h (NAME(aout,print_symbol)): Fix thinko.
+ * syms.c (bfd_stab_names): Turn on new GNU_EXTRA_STABS macro
+ to include names of N_SETT etc.
+
+Thu Nov 14 19:11:13 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf.c: Add minimal support for ELF symbol tables. Generates
+ canonical bfd symbol tables from ELF symbol tables. Change the
+ name of some functions from bfd_<name> to elf_<name>.
+
+ * syms.c: Trivial fix to comment to remove a redundant "to".
+
+Wed Nov 13 17:02:01 1991 John Gilmore (gnu at cygnus.com)
+
+ * coff-{i386,m68k,m88k}.c: Change name of file format to standard
+ form that GDB recognizes as COFF.
+
+Wed Nov 13 09:09:41 1991 Steve Chamberlain (sac at cygnus.com)
+
+ * ieee.c (ieee_object_p): cast NULL correctly.
+ * configure.in: added harris host
+
+ * coff-a29k.c: Lots of changes, most from David Wood.
+
+Tue Nov 12 07:21:41 1991 John Gilmore (gnu at cygnus.com)
+
+ * coff-m88k.c (coff_write_armap): Just #undef it.
+
+Mon Nov 11 20:30:18 1991 Steve Chamberlain (sac at cygnus.com)
+
+ * Makefile.in: standardize on MINUS_G to disable debugging
+ * coff-m88k.c: create coff armaps instead of bsd ones.
+ * opncls.c (bfd_close_all_done), (bfd_close): Mask out random bits
+ when calling chmod.
+
+Mon Nov 11 19:07:32 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf.c: Additions to support ELF format core files.
+ * config/mh-amix: Add -DHAVE_PROCFS to HDEFINES, since host
+ has support for /proc (all the include files in particular).
+
+Mon Nov 11 18:36:47 1991 Per Bothner (bothner at cygnus.com)
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Handle the case
+ of two N_SO stabs, one for directory, and one for filename.
+
+ * bfd-in.h (print_vma): Factor out duplicate definition.
+
+ Exit a little more gracefully when malloc returns NULL.
+ * libbfd.c: New function bfd_xmalloc (malloc wrapper).
+ * opncls.c, syms.c, bout.c, aoutx.h: Replace malloc by bfd_xmalloc.
+ * libbfd.h: Rre-generated due to libbfd.c update.
+
+Sat Nov 9 13:45:01 1991 Fred Fish (fnf at cygnus.com)
+
+ * config/mt-m68k-elf: Define DEFAULT_VECTOR as elf_big_vec.
+
+ * elf.c (elf_object_p): Don't try to create a bfd section for
+ the first ELF section header. It is just a placeholder.
+
+Sat Nov 9 03:04:26 1991 John Gilmore (gnu at cygnus.com)
+
+ * coff-rs6000.c, config/mh-rs6000: Make it work on archive and
+ core files, when compiling native.
+ * hosts/h-rs6000.h: Define FASCIST_FDOPEN for bfd_fdopenr.
+
+ FIXME: The aoutf1.h change below needs to be reversed back
+ to the way it was.
+
+Thu Nov 7 11:03:55 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * coffcode.h: Defined new macros [PUT|GET]LINENO_LNNO for
+ manipulation of lnno fields in lineno structs in a coff-<f>.h
+ independent way. Override it in coff-<f>.h to your favourite
+ number if you don't have a 16bit lnno field. (coff_swap_lineno_in)
+ (coff_swap_lineno_out): modified to use the new macros.
+
+Mon Nov 4 11:38:33 1991 Steve Chamberlain (sac at cygnus.com)
+
+ * aoutf1.h (sunos4_callback): Now defaults to 68020 rather than
+ unknown arch when the magic number doesn't specify the
+ architecture, since some OSs (eg old sun3s) don't set the number, and
+ 020 is probably the right answer anyway.
+
+Sun Nov 3 12:07:08 1991 Per Bothner (bothner at cygnus.com)
+
+ * hosts/h-news.h, hosts/h-rtbsd.h:
+ Get rid of MISSING_VFPRINTF, since libiberty provides one.
+ * bfd-in.h (bfd_print_symbol_type_hopw enum): Add new option
+ bfd_print_symbol_nm, for use by nm.
+ * aoutx.h (NAME(aout,print_symbol)): Add code for new
+ bfd_print_symbol_nm option, to print in nm format.
+ * coffcode.h (coff_print_symbol), ieee.c (ieee_print_symbol)
+ oasys.c (oasys_print_symbol): Provide stub implementations
+ for bfd_print_symbol_nm.
+ * syms.c: New function bfd_decode_symclass, used by nm printer.
+ New function bfd_stab_name to look up string name of stab code.
+
+Sat Nov 2 14:26:03 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * Makefile.in: Added ctor.c
+ * archures.c (bfd_default_arch_struct) added
+ bfd_default_reloc_type_lookup.
+ * coffcode.h: removed a load of #if 0ed code.
+ (coff_compute_file_section_positions): now works out the section
+ alignment and size correctly in all cases.
+ (coff_get_symtab): looks for constructor symbols and calls the
+ right function when they're found. (coff_canonicalize_reloc):
+ knows when a section is full of constructors and does the right
+ thing.
+ * cpu-m88k.c: Added default_reloc_type lookup to the architecture
+ description.
+ * libbfd-in.h: (bfd_default_reloc_type_lookup) defun added.
+ * libcoff.h: removed #if 0ed code
+ * reloc.c: (bfd_reloc_code_real_type) added BFD_RELOC_CTOR for
+ arch independent constructor relocation type.
+ (bfd_reloc_type_lookup): removed the comment "this will go away"
+ since it won't. (bfd_howto_32): stolen from 88k, this is a 32bit
+ reloc which is used when BFD_RELOC_CTOR falls through to give a
+ default 32bit reloc for constructors.
+ (bfd_default_reloc_type_lookup): added.
+ * aoutf1.h: fixed SEGMENT_SIZE typo.
+
+Thu Oct 31 18:23:06 1991 John Gilmore (gnu at cygnus.com)
+
+ * coff-rs6000.c: Change name to "aixcoff-rs6000", to avoid
+ matching prefix "coff".
+ * coffcode.h (coff_swap_aux_in, coff_swap_aux_out): Handle
+ rs/6000 csect records.
+
+Sun Oct 27 16:56:58 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * coff-m88k.c, targets.c: change name of m88k_bcs to m88kbcs
+ * configure.in: add motorola delta88 cases
+ * libbfd.h, libbfd-in.h, archive.c, ieee.c, elf.c, srec.c: fix
+ write_armap prototype
+ * libbfd.c: add doc on bfd_write_bigendian_4byte_int
+
+Fri Oct 25 02:48:19 1991 John Gilmore (gnu at cygnus.com)
+
+ * Rename COFF-related files in `coff-ARCH.c' form.
+ coff-a29k.c, coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c,
+ coff-mips.c, coff-rs6000.c to be exact.
+
+ * Makefile.in: Only supply TARGET_DEFAULTS to targets.c, reducing
+ make output clutter.
+ * config/mt-*: Ditto.
+
+Thu Oct 24 22:40:07 1991 John Gilmore (gnu at cygnus.com)
+
+ RS/6000 support, by Metin G. Ozisik, Mimi Phûông-Thåo Võ, and
+ John Gilmore. Archive support from Damon A. Permezel.
+
+ * Makefile.in: Add cpu-rs6000.c and rs6000coff.c.
+ * configure.in: Add rs6000 case.
+ * targets.c: Add rs6000 vector.
+ * archures.c: Add rs6000, fix comment on romp.
+ * bfd-in.h (enum bfd_error): Add no_debug_section error.
+ * libcoff-in.h (struct coff_tdata): Remove unused string_table.
+ * bfd.c (bfd_errmsgs): Add no_debug_section error message.
+ * section.c (bfd_make_section): Return NULL on attempt to create
+ a section twice.
+ * coffcode.h (bfd_swap_reloc_in): Handle r_type and r_size.
+ (bfd_swap_aouthdr_in): Handle lots more members.
+ (make_a_section_from_file): If section has already been seen,
+ just return false rather than overwriting it.
+ (coff_real_object_p): Understand incoming magic numbers.
+ (coff_set_flags): Understand outgoing magic numbers.
+ (coff_compute_section_file_positions): outgoing aouthdr magic #.
+ (build_debug_section): Add fn for reading debug string section.
+ (get_normalized_symtab): Handle symbol names in debug string section.
+ Remove unused obj_string_table.
+ (coff_slurp_symbol_table): Handle rs6000-specific storage classes.
+ * aoutx.h (translate_from_native_sym_flags, N_SET*): Check for
+ existing section before making one.
+ * cpu-rs6000.c: New file.
+ * rs6000coff.c: New file.
+
+Thu Oct 24 02:03:24 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf.c: Add partial support for ELF format corefiles. Still needs
+ support for extracting registers from corefiles.
+
+ * config/t-m68k-elf: Set DEFAULT_VECTOR to elf_big_vec.
+
+ * config/{h-amix,h-dgux,h-irix3,h-ultra3}: For systems where
+ RANLIB is defined as echo, send the output to /dev/null to help
+ reduce clutter in the output from doing a make.
+
+Mon Oct 21 17:48:48 1991 John Gilmore (gnu at cygnus.com)
+
+ * hosts/h-vaxult.h: Remove malloc/free decls covered in stdlib.h.
+ Fix HOST_PAGE_SIZE and HOST_SEGMENT_SIZE. From David Taylor.
+
+Mon Oct 21 09:34:11 1991 Steve Chamberlain (steve at rtl.cygnus.com)
+
+ * coffcode.h (coff_compute_section_file_positions): make it pad
+ section size out if there are alignment restrictions so that the
+ image will be ok on a system where section positions are worked
+ out by accumulating sizes rather than from the section headers.
+ * targets.c (proto write_armap). Changed orl_count to unsigned.
+ * opncls.c (bfd_close_all_done). Added so that generative
+ programs like gas can close a bfd without causing bfd confusion.
+ * libbfd.h (changed becuase of protos)
+ * amdcoff.c: messed with the way that jmp displacements are
+ calcualated. This may not yet be totally correct.
+ * archive.c (coff_write_armap): rewrote the way that ranlibs are
+ written out.
+ * coffcode.h (fixup_symbol_value): now doesn't core dump if a non
+ abs symbol has no section (like a register symbol).
+ (coff_write_symbol) now zeros auxent before filling it up to help
+ with sensitive applications.
+ * libbfd.c (bfd_write_bigendian_4byte_int): added.
+
+Wed Oct 16 22:58:45 1991 John Gilmore (gnu at cygnus.com)
+
+ * bfd.c: Make sure we don't get a macro strerror().
+ * opncls.c (bfd_fdopenr): If FASCIST_FDOPEN, use "r", not "r+".
+ * trad-core.c (trad_unix_core_file_failing_command): Suppress
+ attempt to recover command, ifdef NO_CORE_COMMAND.
+ * hosts/h-tahoe.h: Add FASCIST_FDOPEN and NO_CORE_COMMAND;
+ revamp HOST_*, etc.
+ * hosts/h-i386v.h: Use <utime.h>, not <sys/utime.h>, unlike POSIX.
+
+Wed Oct 16 12:43:49 1991 Per Bothner (bothner at cygnus.com)
+
+ * archive.c (bsd_write_argmap): The size of the ranlib structures
+ should not include the size field itself.
+ * aoutx.h, libaout.h (NAME(aout, sizeof_headers)): Use
+ adata(abfd)->exec_bytes_size field instead of constant macro,
+ because aoutx.h compiles to a simple .o file shared by
+ all 32-bits a.out targets.
+
+Wed Oct 16 11:11:05 1991 John Gilmore (gnu at cygnus.com)
+
+ * configure.in: Allow i386-sco-sysv.
+ * bout.c: Remove unused i960_align; lint dummy core file handlers.
+ * cpu-h8300.c: lint.
+
+ * host-aout.c: New strategy. We use common code, include files,
+ and data structures to handle the file, but set a few parameters
+ from the host's config file (page size, text start addr, etc).
+ * libaout.h: Define HP BSD machine types.
+ * aoutf1.h: Handle reading a.outs with these types.
+
+ * trad-core.c: Pass the u.u_ar0 value as the negative of the
+ virtual-memory-address of the .reg section. We can't just make a
+ section for "all the regs and nothing else" because only GDB knows
+ exactly where the regs are (scattered around the upage and stack).
+ Clean up memory allocation. Remove big- and little-endian
+ vectors, replace with single vector; this only runs on the host,
+ in host byte order. Replace byteswap routines with aborts in case
+ anyone calls them.
+ * targets.c: There's only one trad_core_vec now.
+ * aoutf1.h (sunos_core_file_p): VMA of .reg* now needs to be 0.
+
+Tue Oct 15 08:29:03 1991 John Gilmore (gnu at cygnus.com)
+
+ * hosts/h-amix.h (free): Fix prototype.
+
+ * aoutx.h: Don't use NULL as an integer, for braindead systems
+ that declare it as (void *)0. (From Peter Schauer.)
+
+Mon Oct 14 17:20:47 1991 Per Bothner (bothner at cygnus.com)
+
+ * opncls.c (bfd_fdopenr): Add parentheses to avoid reported
+ problem with bad Ultrix system headers.
+ * aoutx.h (NAME(aout,set_section_contents)): Try to handle the
+ various kinds of alignments for the various kinds of
+ magic numbers.
+
+Mon Oct 14 14:23:10 1991 John Gilmore (gnu at cygnus.com)
+
+ * doc/Makefile: Don't assume . is on the path (from James Clark).
+
+Fri Oct 11 22:45:14 1991 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Avoid Sun Make VPATH bugs.
+ * targets.c: Declare trad_core vectors extern.
+
+Fri Oct 11 13:03:02 1991 Per Bothner (bothner at cygnus.com)
+
+ * coffcode.h: Moved ALIGN macro to libbfd.h. Removed i960_align.
+ * libbfd.h: Moved ALIGN macro here.
+ * bout.c (b_out_callback): Replace i960_align by align_power.
+
+ * libaout.h (struct aoutdata): Added fields page_size,
+ segment_size and exec_bytes_size. These help generic code
+ (in aoutx.h and libaout.h) to figure out where to align
+ the various segments in a demand paged file.
+ * libaout.h (WRITE_HEADER): Use new (struct aoutdata) fields
+ to decide if the exec header counts in a_text (text segment size).
+ Also, assume D_PAGED flag is set; don't set it here.
+ * bout.c (b_out_callback): Add initialization of
+ adata fields page_size, segment_size, and exec_bytes_size.
+ * host-aout.c (NAME(host_aout, callback) and
+ NAME(host_aout,mkobject): Ditto.
+ * i386aout.c (aout386_callback) and new aout386_mkobject): Ditto.
+ * newos3.c (newsos3_callback) and new newsos_mkobject): Ditto.
+ * aoutf1.c (sunos4_callback) and new sunos_mkobject): Ditto.
+ * aoutx.h (NAME(aout,some_aout_object_p)): Don't subtract
+ EXEC_BYTES_SIZE from the a_test size; this is only appropriate
+ for some systems (mainly sunos), so do it in the callback instead.
+ Same routine: Add stuff to the THIS_IS_ONLY_DOCUMENTATION comment.
+ * aoutx.h (NAME(aout,set_section_contents): Change the way
+ filepos and size of sections are carried out to support
+ older styles of demand paged executables.
+
+
+Fri Oct 11 12:33:36 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * bfd-in.h: Added more macros to COFF_SWAP_TABLE.
+ * bfd.c: Added macros to enable gas to swap coff records.
+ * coffcode.h: Make the coff_swap_*_out routines return the number
+ of bytes swapped, and cleaned up their prototypes.
+ * configure.in: Added ebmon/coff support
+ * ecoff.c: Changed null definitions of coff_swap_*_out to conform
+ to new prototypes
+ * targets.c: Added new entry points for coff swapping
+
+Fri Oct 11 03:01:52 1991 John Gilmore (gnu at cygnus.com)
+
+ Restructure configuration scheme for bfd, binutils, ld.
+
+ * include/sys/h-*.h: Move to bfd/hosts/h-*.h.
+ * configure.in: Revise to symlink sysdep.h to hosts/h-xxx.h.
+ Change some config names to match other dirs.
+ * *.c: Include bfd.h before sysdep.h, so ansidecl and PROTO()
+ get defined first.
+ * Makefile.in: Use -I. to get sysdep.h. Remove refs to
+ ../include/sysdep.h.
+ * cpu-i960.c: Strncmp needed a length arg.
+ * ecoff.c: Don't ever call trad_unix_core_file_p from here.
+ * i386aout.c: Remove dead N_TXTOFF override.
+ * trad-core.c: Don't disable the whole file if SUN4_SYS.
+ * config/: Rename some config files to match up h-*.h names.
+ Remove all the HOST_SYS definitions from the config files.
+ * hosts/h-amix.h, h-i386v.h: Define POSIX_UTIME, not USG.
+ * hosts/h-hp9000.h: Remove USG comment.
+ * hosts/h-rs6000.h: Include <stdlib.h> for malloc.
+ * hosts/h-news.h, h-sparc-64.h: New config files that had
+ previously been kludged in the <sysdep.h> file.
+
+Thu Oct 10 17:54:08 1991 John Gilmore (gnu at cygnus.com)
+
+ * config/*: trad-core support is HOST dependent, not target
+ dependent. Target config files only set DEFAULT_VECTOR and/or
+ other vector elements. Exception: when host-aout.c is in use,
+ in which case we're forced to assume we're native (hp, vax,
+ tahoe). Rename XDEPFILES to HDEPFILES.
+ * Makefile.in: Rename XDEPFILES.
+ * config/h-sun*: Don't force static linking.
+ * trad-core.c: Document how to use it nowadays.
+ * i386aout.c, newsos3.c: Clean up.
+ * i386coff.c: Allow 386 coff files to be used as core files too
+ (for reading core files from embedded systems).
+
+Tue Oct 8 15:30:39 1991 John Gilmore (gnu at cygnus.com)
+
+ * Add i386aout.c for a.out support on the i386.
+
+Tue Oct 8 12:18:54 1991 Roland H. Pesch (pesch at cygnus.com)
+
+ * reloc.c, section.c, syms.c, targets.c: correct info-node
+ structure in *doc* comments.
+ doc/Makefile: stop hiding complaints from makeinfo.
+
+Sun Oct 6 19:10:06 1991 John Gilmore (gnu at cygnus.com)
+
+ * aoutx.h (...some_aout_object_p): Take a third parameter,
+ the internal_exec struct, and avoid ever looking at an
+ external_exec. All callers changed to read the entire
+ external_exec struct, swap and check its magic number,
+ swap in the whole structure, and pass the swapped-in version to
+ some_aout_object_p.
+ * bout.c: Bring into modern era. Use single _object_p routine
+ for big- aand little-endian. Provide internal and external
+ exec header structs. Use separate swap-in and swap-out routines.
+
+ * libaout.h: Move struct internal_exec from ../include/aout64.h
+ to here. Add obj_symbol_entry_size to struct aoutdata.
+ * aoutx.h (...some_aout_object_p): Set obj_symbol_entry_size.
+
+ * ../include/aout64.h: Change EXTERNAL_LIST_SIZE to
+ EXTERNAL_NLIST_SIZE. Callers changed.
+
+Fri Oct 4 18:18:46 1991 John Gilmore (gnu at cygnus.com)
+
+ * bfd.c: Remove strerror() to libiberty.
+
+ * elf.c: Remove elf_set_section_contents, use generic one. Lint.
+ * libbfd-in.h, libbfd.c: Add bfd_generic_set_section_contents.
+ * libbfd.c (bfd_generic_{get,set}_section_contents): Check that
+ last byte of transfer, not first byte, is within the section.
+
+ * host-aout.c: Remove `BSD' archive support. Lint.
+
+ * archures.c: Rename `struct bfd_arch_info_struct' to `struct
+ bfd_arch_info'. Rename `typedef bfd_arch_info_struct_type' to
+ `bfd_arch_info_type'. All uses changed.
+ * reloc.c: Rename `bfd_reloc_status_enum_type' to
+ `bfd_reloc_status_type'. Rename `bfd_reloc_code_enum_real_type'
+ to `bfd_reloc_code_real_type'. (This seems to be a misnomer,
+ it needs a better name.) All uses changed.
+ * targets.c: Rename `enum target_flavour_enum' to `enum
+ target_flavour', and remove the `_enum' from all of the enum
+ values themselves. All uses changed.
+
+ * configure.in, config/h-i386mach: i386 mach host.
+ * config/t-i386-aout: Use host-aout.c.
+
+ * trad-core.c: Give it its own xvec's to make it independent
+ of other file formats.
+ * ecoff.c, host-aout.c: Remove refs to trad-core.
+ * config/t-dec3100, t-hp300bsd, t-tahoe, t-vax: Define TRAD_CORE.
+ * targets.c: #ifdef TRAD_CORE, include it in the vector.
+
+Fri Oct 4 17:38:03 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * reloc.c: Extended NEWHOWTO macro
+ * ieee.c: Changed the way 8bit pcrel is done
+ * cpu-h8300.c: got the registers in the right order
+
+Thu Oct 3 19:39:55 1991 John Gilmore (gnu at cygnus.com)
+
+ * bfd-in.h: enum boolean => enum bfd_boolean for SVR4. Gumby's
+ prediction is vindicated!
+
+ * bfd-in.h, libbfd-in.h, doc/Makefile, doc/tolibbfd, doc/intobfd:
+ Remove refs to howto.c, since Steve forgot.
+
+Thu Oct 3 07:49:21 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * elf.c: took the abort out of set_arch_mach so that objdump -i will
+ still work. Now allows any architecture/machine to be set.
+
+Wed Oct 2 13:50:35 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * howto.c deleted and moved code to reloc.c
+
+ * libbfd.h, libbfd-in.h removed $id stuff for real
+
+ * cpu-h8300.c Made it match various different spellings of h8300.
+
+ * archures.c: Took out the first char filter which made it only
+ look for a cpu/arch match when the first chars of supplied and
+ tested names were the same.
+
+ * targets.c removed oasys stuff, pending someone to fix the bugs
+ in it.
+
+
+Tue Oct 1 12:29:44 1991 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in, configure.in, targets.c, elf.c: Add preliminary
+ ELF support good enough for GDB.
+ * configure.in, config/h-amix, config/t-m68k-elf: Handle
+ m68k-cbm-svr4 host and target.
+ * config/t-m68k-coff, t-m88k-coff, t-m88k-aout: Make files nonempty
+ so `diff' and `patch' can cope.
+
+Tue Oct 1 11:24:31 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * archures.c: removed texinfo error
+
+ * init.c: added texinfo hooks, and removed initialization error
+ message.
+
+ * libcoff-in.h, libbfd-in.h removed $id field so cvs can merge
+ without complaints.
+
+Tue Oct 1 05:02:53 1991 John Gilmore (gnu at cygnus.com)
+
+ * cpu-i960.c: Avoid numerical count of initializers.
+
+ Vax Ultrix changes from David Taylor <taylor@think.com>:
+ * host-aout.c: Make little-endian vector really little-endian.
+ * configure.in: Separate vax and tahoe cases, handle ultrix.
+ * config/t-vax: Add trad-core.o.
+ * config/h-vaxult: New host system.
+
+Mon Sep 30 15:13:46 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * bfd-in.h VERSION, change version number to 0.18, this makes a
+ gap, but now is the same as the linker version number.
+
+ * cpu-a29k.c, cpu-i386.c, cpu-m68k.c, cpu-mips.c, cpu-vax.c,
+ cpu-h8300.c, cpu-i960.c, cpu-m88k.c, cpu-sparc.c: added. These
+ files will eventually contain processor specific bits for bfd,
+ like strange relocation information and dis/assembly. So far only
+ the H8 has been even partially done. This work also ties in with
+ the change in handling architectures.
+
+ * amdcoff.c: (a29k_reloc) fix error message.
+
+ * aout-f1.h: (choose_reloc_size) now calls bfd_get_arch to
+ discover the architecture of the bfd. (sunos4_callback) calls the
+ function bfd_set_arch_mach rather than stuffing stuff directly
+ into the bfd. (sunos4_write_object_contents), changed names of
+ accessor functions.
+
+ * aoutx.h: (set_arch_mach) now calls bfd_default_set_arch_mach to
+ setup the environment.
+
+ * archive.c: (bfd_slurp_coff_armap) coff archives always have the
+ headers in big endian format, regardless of the endianess of the
+ host or target.
+
+ * archures.c: totally changed. Now an architecture is represented
+ with a pointer to an info structure rather than an enumerated type
+ and a long. The old info is available as two elements in the
+ structure. Future enhancements to architecure support will
+ involve pointers to methods being placed into the info structure.
+
+ * bfd.c: changed the definition of the bfd structure for the new
+ architecture stuff.
+
+ * bout.c: (b_out_set_arch_mach) changed to use the new
+ architecture mechanism.
+
+ * coffcode.h: (coff_set_arch_mach, coff_set_flags) changed to use
+ the new architecture mechanism.
+
+ * configure.in: added h8 stuff.
+
+ * ieee.c: too many changes to note. Now ieee files written with
+ bfd gas and ld can be read by gld and ieee only linkers and
+ simulators.
+
+ * libbfd.c, libbfd.h: changed prototype of bfd_write.
+
+ * newsos3.c: (newos3_callback) now calls bfd_set_arch_mach rather
+ than fixing the structure directly.
+
+ * oasys.c: (oasys_object_p) now calls bfd_default_set_arch_mach rather
+ than fixing the structure directly.
+
+ * opncls.c: (new_bfd) makes sure that bfd_init has been called
+ before opening a bfd.
+
+ * srec.c: (srec_set_arch_mach) now calls bfd_default_set_arch_mach
+ rather than fixing the structure directly.
+
+ * targets.c: (target_vector) now by defining SELECT_VECS (perhaps
+ in the t/hmake file) a user can select which backends they want
+ linked with bfd without changing the source.
+
+ * init.c: new, looks after initializing modules.
+
+ * howto.c: for future use, will allow an application to work out
+ what cookie to use as a handle on a relcoatio howto.
+
+Mon Sep 30 13:31:15 1991 John Gilmore (gnu at cygnus.com)
+
+ * srec.c: Better error checking, partly from Peter Schauer.
+ (srec_object_p): Avoid assuming any file that starts with 'S' is
+ an S-record file! (Check for 3 uppercase-hex digits after it.)
+ (ISHEX): Define new macro for checking supposedly hex characters.
+ (pass_over): Treat as EOF any S-record line that:
+ * doesn't have hex in either size character
+ * produces a size larger than 0x7F
+ * has an unrecognized type number
+
+Thu Sep 26 15:27:29 1991 John Gilmore (gnu at cygnus.com)
+
+ * aoutf1.h, aoutx.h, bout.c, coffcode.h, host-aout.c, oasys.c,
+ opncls.c: Lint (saber actually).
+
+Thu Sep 26 11:24:24 1991 Per Bothner (bothner at cygnus.com)
+
+ * libaout.h (WRITE_HEADERS): Set header's a_text field always.
+ * newsos3.c: Fixed two types: newos3 -> newsos3.
+ * reloc.c (bfd_perform_relocation): Fix pc-relative relocation
+ to use correct segment.
+
+Mon Sep 23 18:24:34 1991 Per Bothner (bothner at cygnus.com)
+
+ * aoutx.h (print_symbol): Handle missing symbol->name.
+
+Fri Sep 20 12:26:01 1991 Stu Grossman (grossman at cygnus.com)
+
+ * aoutf1.h (swapcore_sparc): Change name of USRSTACK, fix comment
+ at top of routine.
+
+Tue Sep 17 17:23:49 1991 Stu Grossman (grossman at cygnus.com)
+
+ * oasys.c, configure.in, config/h-irix3, config/t-irix3:
+ add sgi/irix support.
+
+Thu Sep 12 14:29:09 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ Changes for the AMD 29000 Ultracomputer port from David Wood.
+ (wood@nyu.edu).
+
+ * opncls.c (bfd_fdopenr): Handle NO_FCNTL.
+
+ * Makefile.in: Make subdirs work by using $(INCDIR) in the
+ crude dependencies.
+
+ * coffcode.h (coff_real_object_p): Pass information about the
+ current file's coff symbol format to BFD via the coff_data struct.
+ (coff_find_nearest_line): obj_icof => coff_data.
+ (coff_swap_sym_{in,out}): Check that SYMNMLEN == E_SYMNMLEN.
+ (coff_swap_aux_{in,out}): Check that FILNMLEN == E_FILNMLEN
+ and DIMNUM == E_DIMNUM.
+ * configure.in: Handle a29k-*-* hosts, and targets
+ a29k-*-coff, a29k-*-aout, and a29k-*-sym1.
+ * libcoff-in.h: Add local_n_btmask, local_n_btshft,
+ local_n_tmask, local_n_tshift, local_symesz, local_auxesz,
+ local_linesz to `coff_data' (tdata) struct.
+ (coff_data, coff_data_type, coff_tdata): Rename struct icofdata.
+ * config/h-ultra3: Handle a29k-*-* hosts as Ultracomputers.
+
+Thu Sep 12 14:07:22 1991 Roland H. Pesch (pesch at cygint.cygnus.com)
+
+ * Makefile.in: $(MAKE) for make, $(docdir) for doc
+ * doc/Makefile: redundant dependencies for Sun-make VPATH bug
+
+Tue Sep 10 20:34:12 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * aoutf1.h (sunos4_core_file_p): Release the right storage in
+ error case.
+ (sunos4_core_file_matches_executable_p): Fix header comparison.
+ * aoutx.h: Avoid shifts of 32 bits, undefined in C. Lint.
+ * bout.c, icoff.c, ieee.c, libbfd.c, oasys.c: gcc -O -W lint.
+
+Wed Sep 4 00:44:52 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ Allow GDB to patch object files.
+
+ * aoutf1.h (sunos_core_file_p): Set SEC_HAS_CONTENTS on all sections.
+ * trad-core.h (trad_unix_core_file_p): Ditto.
+ * aoutx.h (aout_set_section_contents): On first output, check
+ abfd->direction and complain if erroneous.
+
+ * Makefile.in: Add crude dependencies.
+
+Tue Sep 3 13:46:19 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * config/* aoutx.h configure* shortened all the h/tmake-xxxx
+ to h/t-xxxx files so that everything will work on System V.
+
+Fri Aug 23 13:51:06 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * aoutx.h: Add information on host-aout.c and how to configure
+ to use it, to the manual.
+ * configure.in: Tix typo.
+ * ecoff.c: If compiling for DEC3100, use trad_unix core files,
+ else dummy out the core file support.
+ * trad-core.c (trad_unix_core_file_p): If HOST_DATA_START_ADDR is
+ specified, use it to locate the data section.
+ * coffcode.h (coff_write_symbols): Declare buffer as bfd_bytes
+ rather than as chars (lint).
+
+Thu Aug 22 22:20:19 1991 Stu Grossman (grossman at cygint.cygnus.com)
+
+ * aoutx.h, coffcode.h: saberized.
+
+Thu Aug 22 11:27:06 1991 Roland H. Pesch (pesch at cygint.cygnus.com)
+
+ * bfd.texinfo: some cleanup, reincorporated more intro matter from
+ bfd.doc
+ bfd.c, targets.c: minor rewording of doc segments
+
+
+Wed Aug 21 19:13:22 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * trad-core.c (trad_unix_core_file_p): Use HOST_TEXT_START_ADDR,
+ etc, rather than TEXT_START_ADDR.
+ * host-aout.c: Remove #if 0 around whole thing.
+ Update to modern (32/64-bit) a.out naming conventions.
+ Include a large chunk of ../include/a.out.gnu.h to get macros that
+ are not defined by the system include files.
+ (host_aout_{32,64}_write_object_contents): Use the WRITE_HEADERS
+ macro used by the other a.out implementations.
+ * Makefile.in: Give dependencies to OPTIONAL_BACKENDS.
+
+Wed Aug 21 14:33:06 1991 Roland H. Pesch (pesch at cygint.cygnus.com)
+
+ * Makefile.in: use targets "bfd.dvi" and "bfd.ps" instead of
+ texdoc and psdoc; make these depend on generated .texi's
+
+ * scanit, (new) unPROTO: turn PROTO macros into ANSI declarations in
+ doc
+
+ * bfd.c, reloc.c, syms.c: minor spelling/wording fixes in doc
+ portions
+
+ * Makefile.in, awkscan-ip, awkscan-p, intobfd,
+ libbfd.h, libcoff.h, tolibcoff; new bfd-in.h, libbfd-in.h,
+ libcoff-in.h: (a) use separate files for invariant parts of bfd.h,
+ libbfd.h, and libcoff.h; (b) in generated parts of same, use less
+ obtrusive marks indicating .c origins.
+
+ * bfd.texinfo: generalize most references to linker
+
+Tue Aug 20 15:18:02 1991 Roland H. Pesch (pesch at cygint.cygnus.com)
+
+ * Makefile.in: include core.p in PROTOS (building better bfd.h)
+ * archures.c: remove empty foo() definition (crept in at vn1.9)
+
+Mon Aug 19 13:48:22 1991 Roland H. Pesch (pesch at cygint.cygnus.com)
+
+ * bfd.texinfo: use @setchapternewpage on instead of lots of
+ @page's; minor rephrasing in Introduction.
+
+ * aoutx.h, archive.c, archures.c, bfd.c, bfd.texinfo, cache.c,
+ coffcode.h, core.c, format.c, ieee.c, libbfd.c, libbfd.h, libcoff.h,
+ oasys.c, opncls.c, reloc.c, section.c, syms.c, targets.c (documentation
+ segments): used BFD (caps) more consistently as a name in
+ discourse, fixed a few other minor typos and uses of fonts
+
+
+Thu Aug 8 16:47:43 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * coffcode.h: fixed bug where string table size wasn't being swapped.
+
+Thu Aug 1 16:35:28 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * section.c: added SEC_CONSTRUCTOR_TEXT|DATA|BSS flags
+
+ * syms.c: added BSF_CONSTRUCTOR, BSF_WARNING and BSF_INDIRECT
+ flags. (bfd_print_symbol_vandf) now knows what to do with the
+ above flags.
+
+ * aoutx.h: made translate_from_native_sym_flags and
+ translate_to_native_sym_flags produce the above flags.
+
+
+Wed Jul 31 09:53:52 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * all files: update copyright notices for GPL version 2.
+ Install header comments and attribute most modules to their
+ authors. BFD's name is now officially "Binary File Descriptor",
+ so remove any conflicting pejoratives.
+ archures.h: Consists solely of comments; remove it.
+
+Fri Jul 26 18:11:34 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * Makefile.in, bfd.c: Made it compile again.
+
+Fri Jul 19 08:17:09 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * newsos3.c, targets.c, coffcode.h: new patches from David Wood
+
+
+Mon Jul 15 16:27:42 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * aoutf1.h archive.c bfd.c coffcode.h core.c ecoff.c ieee.c
+ bfd.texinfo oasys.c opncls.c reloc.c srec.c: More documentation on
+ lint fixes.
+
+ * amdcoff.c bfd.texinfo Makefile.in : Folded in changes for amd
+ 29k coff by David Wood (wood@lab.ultra.nyu.edu).
+
+Thu Jul 4 09:53:16 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * Everything: created some new files, core.c format.c, reloc.c,
+ section.c and syms.c to split the functionality a bit better.
+ Cleaned up the rest of the files a bit, and added some
+ documentation.
+
+
+Mon Jul 1 13:29:47 1991 David Wood (wood at david.ultra.nya.edu)
+
+ * opncls.c, ../include/sys/h-sun3.h ../include/sys/h-sun4.h: fcntl
+ really takes 3 arguments, patched code and ammended prototypes.
+
+Fri Jun 14 13:19:40 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * ../include/bfd.h (struct bfd_target): Added new field
+ "align_power_min" which contains the minimum alignment for a
+ section. This is used in coff_new_section_hook. The field
+ insertion necessitates an update of all backends..
+
+ * aoutf1.h jump table field inserted
+
+ * archive.c(snarf_ar_hdr)(bfd_slurp_coff_armap) can now parse dgux style extended
+ filenames too.
+
+ * bout.c(b_out_squirt_out_relocs) fix to assertion tests. Jump
+ table field inserted.
+
+ * coffcode.h(just about everything) Now patches up symbol tables
+ using a different mechanism. The Intel major bug has been fixed,
+ and the linker can self host on the Aviion and be debugged with
+ gdb.
+
+ * ecoff.c: new include and jump table patch, i386coff.c: new
+ include and jump table patch, icoff.c: new include and jump table
+ patch, ieee.c: can now read archives containing ieee modules.,
+ libcoff.h: added (combined_entry_type), libieee.h: uped max
+ sections to 20, m68kcoff.c: new include and jump table patch,
+ m88kbcs.c: new include and jump table patch, oasys.c: various bugs
+ fixed. opncls.c: added bfd_alloc_grow and bfd_alloc_finish.
+ srec.c: jump table patch. trad-code.c fixed #IF typeo
+
+Fri Jun 7 12:35:46 1991 Sean Fagan (sef at cygint.cygnus.com)
+
+ * coffcode.h (coff_swap_aux_in): added else case to deal with
+ filenames less than 9 characters.
+
+
+Thu Jun 6 18:27:38 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * ../include/oasys.h oasys.c (oasys_archive_p): fixed so it works
+
+ * srec.c: now allows any number of sections to be created in a
+ file. Outputs addresses of the right length.
+
+Thu May 30 15:30:10 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * bfd.c (bfd_check_format): Fixed problem where when a defaulted
+ target didn't match, the format got set to the attempted match,
+ breaking a future test.
+
+ *../include/i386coff.h : fixed typo in type field with size
+
+ * i386coff.c icoff.c m88k-bcs.c ecoff.c ../include/bfd.h : Added
+ support in the jump table for the swapping routines exported to
+ gdb. Now gdb works with the 386.
+
+Tue May 28 17:21:43 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * Merge in changes from gdb-3.95 release.
+ Makefile.in: Allow hmake and tmake files to add OFILES.
+ aoutf1.h:
+ bfd.c: support specific targets as well as searching. When
+ searching, take default target in preference to others.
+ bfd.doc: typos
+ ieee.c, oasys.c: Avoid using the "tdata" macros left of assignment.
+ liba.out.h: Don't hard-code file offsets; use N_ macros for them.
+ libbfd.h: Support specific targets as well as searching.
+ opncls.c: Support specific targets as well as searching.
+ targets.c: Search is short-circuited if default target matches.
+ liboasys.c, libieee.c: Undo bothner changes that make macros
+ work to the left of assignment, but which depend on the
+ representations of different pointer types being the same.
+
+Fri May 24 18:56:52 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * i386coff.c: created.
+ * coffcode.h: added support for 386.
+ * Makefile.in: added support for 386.
+ * ../include/i386coff.h: created
+
+Wed May 22 07:26:38 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * coffcode.h: removed all put_x_<sizes>
+ * libbfd.c: Changed #ifdef __GNUC__ to #ifdef HOST_64_BIT, Added
+ DEFUNS
+
+
+Tue May 21 08:58:58 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+ (bothner)
+ * opncls.c: Changed obstack_chunk_alloc use xmalloc
+
+Mon May 20 17:12:17 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * everything: Removed sysdep.h from bfd.h and put back into files
+ from which it was split out. Now 64 bit version is built with a
+ -DHOST_64_BIT="long long" on the compile line.
+
+Fri May 17 19:35:26 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ Changed all the [get|put][name] routines to use [get|put]_[size
+ in bytes].
+
+ Put in support for 64 bit work. Now two versions of bfd may be
+ generated, according to the state of TARGET_64_BIT, one which is
+ 32 bit only, and one which is 64/32 bits.
+ Created new back end 'demo64' to test 64 bit functionality.
+
+ Renamed some files to work on DOS.
+
+ * archive.c: lint * bfd.c: prototypes and lint. * ecoff.c: added
+ 64bit transfer * icoff.c: added 64bit transfer * ieee.c: name
+ chage, 64 bit transfer. * liba.out.h: Split out common code from
+ sunos and newsos into liba.out. Name changes and prototype mods. *
+ libbfd.c: lint and prototypes, extra 64bit swaps. * libbfd.h:
+ prototypes for new functions. * libcoff.h: lint * libieee.h: make
+ work on DOS * liboasys.h: make work on DOS * m88k-bcs.c: Name
+ change and 64bit stuff.* newsos3.c: common code removed, new jump
+ table. * oasys.c: Name change * opncls.c: Portability fixes *
+ srec.c: Name changes * sunos.c: Removed comon code. * targets.c:
+ Added demo * aout32, aout64.c include aoutx.h * bout.c: used to
+ be called b.out.c * coffcode.h: used to be called coff-code.h, now
+ 64bit ized. * demo64.c: 64 bit a.out back end
+
+Thu May 16 16:02:07 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+ from bothner
+ * libieee.h: Make ieee_data and ieee_ar_data macros usable
+ on LHS of assignment, even when using old compilers.
+ * liboasys.h: Ditto for oasys_data and oasys_ar_data.
+ * m68kcoff.c: Add enum-to-int casts to accomodate old compilers.
+ * newsos3.c: Fix definitions of SEGMENT_SIZE and TEXT_START_ADDR.
+ * opncls.c: Define S_IXUSR, S_IXGRP, S_IXOTH if undefined.
+ * targets.c: Add declaration of newsos3_vec.
+
+Mon May 13 10:03:29 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * aout.c: fixxed some of the problems with filepos calculation.
+ (swap_ext_reloc): fixed problem with creation of relocs.
+ (aout_set_section_contents): fixed filepos problem
+
+ * coff-code.h: (swap_filehdr_in, swap_filehdr_out) add.
+ (swap_filehdr) delete. Changed all the usage of bfd_h_put_x.
+ (swap_aouthdr_in, swap_aouthdr_out) add. (swap_aouthdr) delete.
+ (coff_real_object_p) cleaned up, added MIPS. (coff_object_p)
+ cleaned up. (coff_write_object_contents) cleaned up.
+
+ * ecoff.c: Totally different. Now supports ecoff fully.
+
+ * icoff.c: fixed problems in relocation callout.
+
+ * libcoff.h: (struct icofdata) removed hdr structure from tdata.
+
+ * m68kcoff.c: updated target vector.
+
+ * sunos.c: (choose_reloc_size) added: (sunos4_callback) calls
+ choose_reloc_size. (sunos4_write_object_contents) now calls
+ choose_reloc_size so outputs relocs correctly, also calculates the
+ size of the sections correctly.
+
+
+
+Fri May 10 16:58:53 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ Merge Per Bothner's changes to modularize BFD a.out a bit.
+
+ * libbfd.h, libbfd.c (bfd_generic_get_section_contents): Add.
+ * ieee.c: Cast enums to int before comparing them, for brain-
+ dead compilers.
+ * coff-code.h: Remove coff_get_section_contents, and use the
+ generic one instead.
+
+ * aout.c: Derive new module from sunos.c, containing generic
+ support code for all kinds of a.out files.
+
+ * sunos.c: Remove all code that goes in aout.c. Split out
+ machine dependent followup in sunos4_object_p into
+ sunos4_callback. Use JUMP_TABLE(aout) for the transver vector,
+ and redefine only the names we CHANGE, not all the names. Drop
+ the little-endian vector, and rename the vector as sunos4 rather
+ than generic.
+
+ * b.out.c: Use aout.c routines for most of the work. Slight
+ changes for the new regime. Remove close_and_cleanup and
+ get_section_contents in favor of generics. New transfer vector
+ regime.
+
+ * newsos.c: New support for Sony NEWS, another a.out format.
+
+ * ecoff.c: Remove close_and_cleanup. New tvec regime.
+ * icoff.c, m88k-bcs.c: Add write_contents to tvec.
+ * ieee.c, oasys.c: Remove close_and_cleanup, add write_contents
+ to tvec.
+ * opncls.c (bfd_close): Call format-dependent write_contents
+ routine, if writing, before calling target-dependent
+ close_and_cleanup routine (which is now always generic, I think).
+ * srec.c: Use bfd_alloc instead of malloc. Remove
+ close_and_cleanup and move code from it to
+ srec_write_object_contents. Add write_contents to tvec.
+ * targets.c: Remove a.out little vector, replace a.out big
+ vector with SunOS vector. FIXME: Need Vax support again now.
+
+ * libbfd.h: Add write_contents format-dependent-vector to the
+ bfd_target vector. Supply a generic close_and_cleanup routine.
+ * liba.out.h: Handle the new aout.c split. Add prototypes for
+ all routines defined in aout.c. Rename "sunos" things to "aout"
+ things. Add a few fields where needed for various formats.
+ * Makefile.in: Add aout.c and newsos.c.
+
+ * archive.c, ieee.c, oasys.c: Lint.
+
+Fri May 10 12:34:48 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * ../include/bfd.h
+ changed forward declaration struct stat; to reduce warnings. Changed
+ comment on bfd_h_<x>_x.
+
+ * ../include/m68kcoff.h, ../include/intel-coff.h,
+ ../include/m88k-bcs.h
+ Now there are two incarnations of relocs, linenos and syments. One for
+ internal digestion, and one full of char arrays for I/O. The original
+ names have gone to detect errors.
+
+ * Makefile.in, m68kcoff.c, targets.c
+ Test new structure code with a 68k coff implementaion
+
+ * coff-code.h, icoff.c, coffswap.c, libcoff.h
+ Fixed all the places where there were problems with the size and
+ alignments of structures on disk and structures in memory. #ifed out
+ all the code in coffswap.c, since it should be done using the target
+ swap routines now.
+
+Thu May 9 11:00:45 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * ieee.c (do_one, ieee_slurp_section_data): now supports the load
+ multiple reloc command.
+
+ * sunos.c (sunos4_set_section_contents): Made it so that sections
+ are always padded to their alignment size.
+
+Sat May 4 15:49:43 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * archive.c, bfd.c, coff-code.h, opncls.c, sunos.c, trad-core.c:
+ Clean up types and such (saber C problems).
+ * ecoff.c: Clean up types and such. Remove routines that are
+ not used. Fix up reading and swapping of shorts from files.
+
+ Notes on bfd-0.5.2-patch1a, from Per Bothner:
+
+ * a.out.vax.c: Remove two bogus "static" from prototypes.
+
+ * ecoff.c: Got rid of lots of non-working junk (that had
+ been copied directly from coff-code.h).
+ Updated to be consistent with updates to icoff.c and coff-code.h.
+
+ * libbfd.h: Added definitions for S_IXUSR, S_IXGRP, and S_IXOTH
+ if they're missing (as they are in (BDS-4.3-based) NewsOS-3).
+
+ * sunos.c (n_txtoff): (Re-)Add support for sony. This is a kludge,
+ but until the target_vector is automatically generated,
+ it's as good as any. Note that the text offset is the only
+ difference between NewsOS and SunOs (including magic numbers).
+ (Most of the sunos_* routines should to renamed bsd_*
+ and move to a bsd.c file. Then (and when the target_vector
+ is automatically generated) it might make sense to create
+ a separate Sony target.)
+
+ * sysdep.h: Don't declare fread and fwrite. Causes trouble
+ on some systems, and doesn't help on others.
+ Similarly, only define X_OK if not already defined.
+
+ * trad-core.c: Don't include sys/stat.h - at least
+ on NewsOS 3, it has already been included.
+
+Tue Mar 5 01:47:57 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * coff-code.h (bfd_coff_swap_sym, bfd_coff_swap_aux,
+ bfd_coff_swap_lineno): Export the routines that byte-swap COFF
+ symbol tables if necessary when reading them in, so gdb can use
+ them. Add "bfd_coff_" to the names so they won't conflict with
+ names in calling programs. FIXME-soon: if coff-code.h is
+ included in two BFD modules, this will cause duplicate
+ definitions; the routines should be exported to a separate,
+ common, module (probably along with a mess of other ones).
+
+Sat Mar 2 12:11:26 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ Improve modtime support.
+
+ * bfd.h: Add boolean mtime_set, and declare bfd_get_mtime.
+ Remove #define for bfd_get_mtime. Remove gratuitous comment.
+ * bfd.c (bfd_get_mtime): New fn, caches mtime, gets if not cached.
+ BUG: archive members still do not get correct mod times.
+
+ Improve floating point support for core files.
+
+ * sunos.c (struct core): Change void *fpa_dummy to double fp_stuff.
+ (sunos4_core_file_p): Create a second registers section in the
+ core file, called ".reg2", for the float registers.
+
+Thu Feb 14 15:49:06 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com)
+
+ * many changes to improve archive handling; found a logic flaw in
+ bfd_check_format which only just happened to work by cooncidence.
+
+Thu Feb 14 07:53:16 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * bfd.c (bfd_perform_relocation): fixed to use output_offsets
+ correctly.
+
+ * bfd.h: changed type of udata in asymbol to void *, like it
+ should be. Added bfd_reloc_dangerous enum member.
+
+ * coff-code.h: Fixed it so that internally generated symbols get
+ their values relocated correctly in all cases. Removed calls to
+ xmalloc.
+
+ * icoff.c: Not understanding the destination symbol of a reloc is
+ not a failure any more, just 'dangerous'. This allows linking of
+ b.out and coff images.
+
+ * sunos.c: Cleaned up the way that ZMAGIC section sizes are
+ calculated.
+
+
+Tue Feb 12 13:25:46 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * sunos.c (translate_to_native_sym_flags): fixed
+ sym_pointer->n_value so that symbols on the way out get their
+ section relative values calculated correctly.
+
+ * coff-code.h (mangle_symbols): fixed problem where tags were not
+ being relocated for structs, enums, unions. Also various lints.
+
+Mon Feb 11 19:52:26 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com)
+
+ * archive.c (get_elt_at_filepos): system_call_error returned
+ incorrectly.
+
+Sun Feb 10 23:18:40 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com)
+
+ * Resolve the use of no_error and system_call_error.
+ The bfd library itself now will never set bfd_error to
+ no_error.
+
+ The code still needs to be combed to make sure all the error
+ codes are correct. I suspect they are not always set correctly.
+
+ * The names of all the messages have _ prepended because the sun
+ bundled compiler can't distinguish from a macro which takes an
+ argument and the same identifier in a non-macro context.
+
+ * The reason for the above being that entry points which used to
+ be trampoline functions are now just macros which expand to a
+ direct call through the bfd's xfer vector.
+
+ * (../include/intel-coff.h) F_AR32WR: fix this constant. Why
+ must gas have its own version of everything (the gas version
+ had the correct value)
+
+Tue Feb 5 11:46:53 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * b.out.c: Added patches supplied by chrisb@mipon2.intel.com to
+ properly support i960 architecture and output correct reloc stuff.
+
+ * bfd.h: added prototype for bfd_printable_arch_mach, added
+ BFD_FAIL
+
+ * coff-code.h: Applied patches from chrisb to support i960
+ architecture, zero relocs and swap them correcly and conditionally
+ compiled the timestamp.
+
+ * sunos.c: Made the default section alignment 2^3 so that doubles
+ are done properly. Fixed the same reloc bug that was in b.out.c
+
+ * sysdep.h: Now compiles on a Posix box
+
+Wed Jan 30 21:36:26 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * icoff.c: Fix comment on big-endian version.
+ * coff-code.h: Make HAS_RELOC really work (it's backwards from
+ F_RELFLG). Set F_AR32WR in output files if little endian
+ architecture.
+
+Tue Jan 29 20:56:10 PST 1991 steve@cygnus.com
+
+ * archures.c fixed =/== typo
+
+ * sunos.c added architecture stuff for output. Fixed
+ bug where files where vma(data) != size(text)
+ were processed wrong.
+
+ * coff-code.h added a lint cast
+
+ * (../include/a.out.sun4.h) fixed it so zmagic
+ worked
+
+Mon Jan 28 19:15:29 PST 1991 steve@cygnus.com
+
+ * archive.c removed loads of includes, and fixed bug where string
+ table didn't have a null at the end.
+
+ * bfd.c fixed includes, added symbols argument to
+ canonicalize_reloc entry point.
+
+ * libbfd.c fixed includes and added some lint patches.
+
+ * targets.c added both sorts of intel coff.
+
+ * b.out.c fixed included, changed was the canonical
+ relocs were done.
+
+ * icoff.c added support for callj and big and little
+ enidian tables.
+
+ * opncls.c added chmod+xing for files with EXEC_P set.
+
+ * sunos.c fixed includes. Changed default section
+ alignement to words. Fixed relocation stuff to work with
+ new scheme
+
+ * bfd.h various new types added, prototype for new
+ reloc calls, changed bfd->iostream to a void *
+ to including files don't need stdio.h.
+
+ * libcoff.h added conversion table to tie relocs to
+ canonical symbols
+
+ * sysdep.h created
+
+ * coff-code.h fixed includes. Added code to support
+ big and little endian formats. Various lints. Better
+ processing of symbols. Changed reloc stuff to new
+ order
+
+ * libbfd.h fixed includes
+
+
+Mon Jan 21 11:53:51 PST 1991 steve@cygnus.com
+
+ * bfd.h changed name of alignment entry in sec_struct to
+ alignment_power, because of conflicting uses within bfd.
+ Now it should be obvious that it's a 2**n alignment
+ specifier. Removed start_pad, end_alignment, block, minsize,
+ output_file_alignment, subsection_alignment and original_vma fields.
+ Added align_power() macro. Fixed bfd_section_alignment
+ acessor macros. Added bfd_symbol_same_target macro.
+
+ * b.out.c (b_out_write_object_contents) fixed to use
+ new alignment member. Fixed (callj_callback) to use section
+ relative symbols properly.
+
+ * sunos.c (sunos4_object_p) fixed to use new alignment_power.
+ Fixed (translate_from_native_sym_flags) to correctly make
+ symbols section relative.
+
+ * bfd.c (bfd_errmsg) fixed various enum cast problems.
+ (bfd_make_section) took out initialization of obsolete members.
+ (bfd_print_symbol_vandf) added
+
+ * opncls.c (bfd_create) created.
+
+ * coff-code.h (coff_new_section_hook) took away refs
+ to obsolete members. (make_a_section_from_file) added
+ conversion between alignment types. (coff_symbol_from)
+ added. (coff_count_linenumbers) only counts linenumbers
+ if symbol is of coff-type. (coff_mangle_symbols) only
+ heavily mangles symbols if symbol is coff-type.
+ (coff_write_symbols) various lints. (coff_write_object_contents)
+ various lints and modification for alignment conversion.
+ (coff_slurp_relocs) fixed for use with new asection shape.
+
+Sat Jan 19 16:10:42 PST 1991 steve@cygnus.com
+
+ * archive.c lots of lint
+
+ * b.out.c added callj relocation support, upgrated reloc howto.
+ Fixed so that asymbol and reloc records are output
+ correctly.
+
+ * bfd.c lots of lint, support for new bfd entry point
+ bfd_print_symbol.
+
+ * bfd.h changed definition of asymbol to contain pointer to
+ owning bfd, removed target dependencies.
+
+ * cache.c took out print statements, put in BFD_ASSERT calls.
+
+ * coff-code.h various lints, corrected linenumber output
+ functionality. Added support for new style asymbols and
+ bfd_print_symbol. Fixed so that asymbol and
+ reloc records are handled correctly. Added timestamp.
+
+ * icoff.c Added support for new howto shape.
+
+ * liba.out.h Added support for new asymbol shape
+
+ * libbfd.c various lints
+
+ * libbfd.h various lints
+
+ * libcoff.h added support for new asymbol shape.
+
+ * sunos.c various lints. Added support for new asymbol shape
+ and bfd_print_symbol.
+
+Wed Jan 16 21:38:09 PST 1991 steve@cygnus.com
+
+ * b.out.c removed prototype of sunos4_ennativate_symtab, lots of
+ pointer lint. Added support for callj relocation. Fixed bug where
+ the last 32 bytes of the text section were overwritten by data. Fixed bug
+ where archives of b.out didn't work due bfd_slurp_extended_name_table
+ returning false.
+
+ * sunos.c added support for n_other field. Braced the howto table so
+ that it won't be affected by any lengthing of the howto struct typedef.
+ Various lints
+
+ * bfd.h added support for n_other field, added special_function
+ reloc type, modified bfd_perform_relocation prototype. Added bfd_h_get_x
+ macros.
+
+ * bfd.c upgraded bfd_perform_relocation, various lints.
+
+Wed Jan 16 01:55:53 1991 John Gilmore (gnu at rtl)
+
+ * ChangeLog: Started ChangeLog for BFD.
+ * ToDo: Create file for suggestions.
+
+ * Makefile: Support easy loading into Saber C.
+ Add dependencies for icoff.o and bcs88kcoff.o.
+ Rename coff.c to coff-code.h. Change callers.
+
+ * bfd.c (bfd_check_format): Allow the check_format routines
+ to return the desired target vector, rather than just a Boolean.
+ bfd.h (bfd_check_format): Change function pointer return type.
+ archive.c (bfd_generic_archive_p): change callee.
+ b.out.c (b_out_little_object_p, b_out_big_object_p,
+ b_out_real_object_p): change callee.
+ libbfd.c (_bfd_dummy_target): Dummy routine replacing bfd_false
+ in check_format transfer vectors that need a filler.
+ libbfd.h (bfd_generic_archive_p, _bfd_dummy_target): Fix decls.
+ bcs88kcoff.c: change callee.
+ coff-code.h (coff_real_object_p, coff_big_object_p): change callee.
+ icoff.c: change callee.
+ sunos.c (sunos4_object_p, sunos4_core_file_p): change callee.
+
+ * libbfd.c (zalloc): It should actually zero the storage!
+ This was commented out for some reason.
+
+ * libbfd.h: Add malloc, xmalloc, memcpy, and fatal decls.
+ This is so callers can avoid <stdlib.h> which doesn't exist
+ on older systems.
+
+ * bfd.c (map_over_sections): Add debugging code, since I
+ noticed the section count for sunos core files was bad, but only
+ GDB had detected the problem.
+ (bfd_set_section_lineno_size, bfd_set_section_linenos,
+ bfd_get_section_linenos): Remove obsolete functions.
+ (bfd_apply_relocations): Use longs, not ints, for the math.
+
+ * bfd.h: Declare enum boolean and struct bfd_target as well
+ as typedefs for them. Remove obsolete
+ bfd_get_section_lineno_size.
+
+ * cache.c: Make the "fdopen" support work. Keep better track
+ of how many files are open. Centralize the opening of files
+ and be sure bfd_open[rw] actually try to open the file. Evade
+ linked list initialization problems.
+
+ * b.out.c, coff-code.h, opncls.c, sunos.c: lint.
+
+ * coff-code.h (coff_slurp_symbol_table): Null-terminate symtab names.
+
+ * cplus-dem.c: Delete file, since it is not part of BFD.
+
+ * opncls.c (bfd_openr): Eliminate misplaced #if 0 code.
+ (bfd_openr, bfd_openw): Actually open the file, give error now.
+
+ * sunos.c (sunos4_core_file_p): Set section count.
+ (sunos4_set_section_linenos, stab_names, fprint_name): Eliminiate
+ obsolete definitions.
+ (_write_symbol_table): Initialize <idx> counter.
+ (foop): Eliminate debugging code.
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/ChangeLog-9495 b/bfd/ChangeLog-9495
new file mode 100644
index 00000000000..9868583cb4b
--- /dev/null
+++ b/bfd/ChangeLog-9495
@@ -0,0 +1,10043 @@
+Thu Dec 21 12:43:49 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_howto_raw): Add a phony reloc to handle the
+ old style TOC16 references without using R_PPC_GOT.
+ (ppc_reloc_type): Ditto.
+ (ppc_elf_reloc_type_lookup): Add support for TOC16.
+ (ppc_elf_toc16_inner): Renamed from ppc_elf_got16_inner.
+ (ppc_elf_toc16_reloc): Renamed from ppc_elf_toc16_reloc.
+ (ppc_elf_got16_{inner,reloc}): Stubs for real GOT support.
+ (ppc_elf_check_relocs): New function for GOT/PLT support that is
+ work in progress.
+ (ppc_elf_adjust_dynamic_symbol): Ditto.
+ (ppc_elf_adjust_dynindx): Ditto.
+ (ppc_elf_size_dynamic_sections): Ditto.
+ (ppc_elf_finish_dynamic_symbol): Ditto.
+ (ppc_elf_finish_dynamic_sections): Ditto.
+ (ELF_DYNAMIC_INTERPRETER): Define.
+
+Wed Dec 20 19:14:18 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * elf.c (copy_private_bfd_data): When attaching sections to
+ segments ignore sections that won't be allocated. Patch from
+ Andreas Schwab.
+
+Tue Dec 19 20:01:43 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * config.bfd: Match on m68k-cbm-* only if OS doesn't match
+ anything else.
+
+Tue Dec 19 16:38:59 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i960.c (CALC_ADDEND): Define.
+ (coff_i960_relocate_section): Add the input section VMA to the
+ addend for PC relative relocs.
+
+Sun Dec 17 20:11:55 1995 Kim Knuttila <krk@cygnus.com>
+
+ * peicode.h (pe_print_pdata): Must test the entire entry for zero
+ to correctly terminate.
+
+Fri Dec 15 12:05:57 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * targets.c (enum bfd_endian): Define.
+ (bfd_target): Rename byteorder_big_p to byteorder, and change it
+ from boolean to enum bfd_endian. Change header_byteorder_big_p
+ correspondingly.
+ * bfd-in.h (bfd_big_endian, bfd_little_endian): New macros.
+ (bfd_header_big_endian, bfd_header_little_endian): New macros.
+ * bfd-in2.h: Rebuild.
+ * All targets: Change initialization of byteorder and
+ header_byteorder to use enum bfd_endian values rather than
+ booleans.
+ * All files: Change all references to byteorder_big_p and
+ header_byteorder_big_p to use new bfd_*_endian macros.
+
+ * coffgen.c (make_a_section_from_file): Set lma to s_paddr, not
+ s_vaddr.
+ * coffcode.h (coff_write_object_contents): Set s_paddr to lma, not
+ vma.
+ * ecoff.c (_bfd_ecoff_write_object_contents): Likewise.
+
+Fri Dec 15 07:32:09 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * pe[i]-i386.c (TARGET_UNDERSCORE): Define to '_'.
+
+Thu Dec 14 13:45:37 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c: Lots of minor cleanups. Make many functions return
+ errors rather than calling abort. Also:
+ (ieee_write_twobyte): Remove; change callers to call existing
+ ieee_write_2bytes function.
+ (ieee_write_expression): Don't output the section twice when
+ outputting a local symbol. Don't emit an extraneous zero if there
+ is only one term.
+ (ieee_slurp_sections): Set the lma as well as the vma.
+ (ieee_archive_p): Use bfd_alloc_grow rather than an obstack.
+
+ * ihex.c (ihex_set_arch_mach): Don't accept any architecture, just
+ a recognized one or bfd_arch_unknown.
+ (ihex_get_symtab_upper_bound): Define as bfd_0l, to permit objcopy
+ to succeed.
+ (ihex_get_symtab): Likewise.
+
+Wed Dec 13 15:44:06 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h: Include <ctype.h>.
+ (struct aout_link_includes_table): Define.
+ (struct aout_link_includes_totals): Define.
+ (struct aout_link_includes_entry): Define.
+ (aout_link_includes_lookup): Define macro.
+ (struct aout_final_link_info): Add includes field.
+ (aout_link_includes_newfunc): New static function.
+ (NAME(aout,final_link)): Initialize includes hash table.
+ (aout_link_write_symbols): Eliminate duplicate N_BINCL entries.
+
+Wed Dec 13 10:52:14 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Match on mips-*-* instead of mips-idt-ecoff.
+
+Wed Dec 13 11:07:45 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (coff_ppc_relocate_section): removed debugging code.
+
+Tue Dec 12 17:42:06 1995 Kim Knuttila <krk@cygnus.com>
+
+ * peicode.h (pe_print_reloc): New function to dump the .reloc section.
+ (pe_print_private_bfd_data): call pe_print_reloc.
+ * coffcode.h (coff_set_alignment_hook): .reloc section alignment.
+ * coff-ppc.c (in_reloc_p): Added missing non-eligible relocs. Spiffed
+ up some debugging as well.
+
+Tue Dec 12 11:34:23 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.bfd: Handle sparc-*-elf*. From Ronald F. Guilmette
+ <rfg@monkeys.com>.
+
+Fri Dec 8 17:47:07 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Set section_count to 0
+ when setting sections to NULL.
+
+Wed Dec 6 17:05:37 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (struct xcoff_loader_info): Add export_defineds
+ field.
+ (bfd_xcoff_size_dynamic_sections): Add export_defineds parameter.
+ (xcoff_build_ldsyms): If export_defineds is set, set XCOFF_EXPORT
+ for all symbols.
+ * bfd-in.h (bfd_xcoff_size_dynamic_sections): Update declaration.
+ * bfd-in2.h: Rebuild.
+
+Mon Dec 4 16:40:47 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coffcode.h (coff_set_alignment_hook): Removed some debugging printf's
+
+Mon Dec 4 11:25:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ihex.c (ihex_scan): Handle record types 4 and 5.
+ (ihex_object_p): Permit types 4 and 5.
+ (ihex_set_section_contents): Remove check for out of range
+ addresses.
+ (ihex_write_object_contents): Generate types 4 and 5.
+
+ * elflink.h (elf_link_output_extsym): Just ignore warning and
+ indirect references to symbols which don't really exist.
+
+Sun Dec 3 19:00:27 1995 Kim Knuttila <krk@cygnus.com>
+
+ * peicode.h (pe_print_idata): Minor format fixes
+ (pe_print_edata): New function. Under private printing, this formats
+ the edata section of a PE file.
+ (pe_print_private_bfd_data): Added call to pe_print_edata.
+
+Sun Dec 3 16:46:54 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
+
+ * aout-arm.c (MY_swap_std_reloc_out): Use KEEPIT to get the symbol
+ index, don't call stoi.
+
+Fri Dec 1 14:46:51 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * srec.c (srec_scan): Set lma as well as vma.
+
+ * ihex.c: New file; support for Intel Hex format.
+ * targets.c (enum bfd_flavour): Add bfd_target_ihex_flavour.
+ (ihex_vec): Declare.
+ (bfd_target_vector): Always include ihex_vec.
+ * bfd.c (struct _bfd): Add ihex_data field to tdata union.
+ * Makefile.in: Rebuild dependencies.
+ (BFD_LIBS): Add ihex.o
+ (BFD_LIBS_CFILES): Add ihex.c.
+ * bfd-in2.h: Rebuild.
+
+ * elf.c (assign_file_positions_for_segments): Sort the sections in
+ each segment.
+ (get_program_header_size): Return the right size if segment_map is
+ not NULL.
+ (copy_private_bfd_data): Don't bother to sort the sections.
+
+ * bfd.c (bfd_record_phdr): New function.
+ * bfd-in.h (bfd_record_phdr): Declare.
+ * bfd_in2.h: Rebuild.
+
+ * elf32-sparc.c (elf32_sparc_relocate_section): Remove bogus
+ BFD_ASSERT.
+
+ * libbfd.c (bfd_malloc, bfd_realloc): New functions.
+ (bfd_zmalloc): Return PTR, not char *. Take size_t, not
+ bfd_size_type.
+ * libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
+ (bfd_zmalloc): Change declaration.
+ * libbfd.h: Rebuild.
+ * Many files: Use bfd_malloc and bfd_realloc rather than malloc
+ and realloc. Don't set bfd_error_no_memory if they fail.
+
+Thu Nov 30 19:32:26 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c: Added macros to tidy up toc cell treatment. Numerous
+ uses as well. Added a new howto to deal with TOCREL16 relocs that
+ are TOCDEFN as well.
+ (coff_ppc_relocate_section): Expanded treatment of ADDR32NB relocs
+ to handle RVA relocs from dlltool.
+ (ppc_coff_rtype2howto): TOCDEFN reloc addition.
+ (coff_ppc_rtype_to_howto): TOCDEFN reloc addition.
+ (ppc_coff_reloc_type_lookup): TOCDEFN reloc addition.
+
+ * coffcode.h (coff_set_alignment_hook): check idata$X sections
+ to get the right section alignment.
+
+Thu Nov 30 16:48:18 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on
+ p_paddr if p_paddr is zero.
+ (make_mapping): Set includes_filehdr and includes_phdrs for first
+ PT_LOAD segment.
+ (map_sections_to_segments): Set includes_phdrs for PT_PHDR
+ segment.
+ (assign_file_positions_for_segments): Handle includes_filehdr and
+ includes_phdrs. Remove special handling of PT_PHDR and first
+ PT_LOAD segments.
+ (copy_private_bfd_data): Set includes_filehdr and includes_phdr
+ when appropriate. Remove special handling of PT_PHDR segment.
+ Use a more complex condition for when a section is included in a
+ segment to handle Solaris linker oddities.
+
+Thu Nov 30 11:17:33 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de>
+
+ * coff-m88k.c (howto_table): Reformatted for easier reading;
+ special_function now points to new function m88k_special_reloc.
+ (howto_hvrt16): Function previously used for handling HVRT16 relocs
+ removed.
+ (rtype2howto): Do not add reloc's r_offset to the addend, this will
+ be done correctly by m88k_special_reloc.
+ (reloc_processing): New function to be used by RELOC_PROCESSING.
+ (RELOC_PROCESSING): Define to call reloc_processing.
+
+Wed Nov 29 12:42:36 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (pe_print_idata): Call malloc rather than xmalloc.
+ (pe_print_pdata): Likewise.
+
+ * opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
+ obstack_alloc fails.
+ (bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
+ fails.
+ * libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
+ * Many files: don't set bfd_error_no_memory if one of the above
+ routines fails.
+
+ * elf.c (assign_file_positions_for_segments): Don't adjust p_paddr
+ if p_paddr_valid is set.
+ (copy_private_bfd_data): New static function.
+ (_bfd_elf_copy_private_section_data): Call copy_private_bfd_data.
+
+ * elf.c (assign_file_positions_for_segments): Fix case where extra
+ program headers were allocated.
+
+ * elf.c (_bfd_elf_print_private_bfd_data): New function.
+ * elf-bfd.h (_bfd_elf_print_private_bfd_data): Declare.
+ * elfxx-target.h (bfd_elfNN_bfd_print_private_bfd_data): Define to
+ _bfd_elf_print_private_bfd_data.
+
+ * coff-alpha.c (alpha_ecoff_swap_reloc_in): Don't abort if
+ r_symndx is RELOC_SECTION_NONE for an ALPHA_R_IGNORE reloc.
+ Change a RELOC_SECTION_LITA symndx to RELOC_SECTION_ABS.
+ (alpha_ecoff_swap_reloc_out): Change RELOC_SECTION_ABS to
+ RELOC_SECTION_LITA for ALPHA_R_IGNORE.
+ (alpha_adjust_reloc_out): For ALPHA_R_IGNORE, don't change
+ RELOC_SECTION_ABS to RELOC_SECTION_NONE.
+
+Tue Nov 28 16:59:50 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf-bfd.h (struct elf_obj_tdata): Add segment_map field.
+ * elf.c (make_mapping): New static function.
+ (map_sections_to_segments): New static function.
+ (elf_sort_sections): New static function.
+ (assign_file_positions_for_segments): New static function.
+ (map_program_segments): Remove.
+ (get_program_header_size): Remove sorted_hdrs, count, and
+ maxpagesize parameters. Simplify.
+ (assign_file_positions_except_relocs): When generating an
+ executable, use assign_file_positions_for_segments.
+ (elf_sort_hdrs): Remove.
+ (_bfd_elf_sizeof_headers): Remove eliminated parameters from call
+ to get_program_header_size.
+
+Mon Nov 27 12:27:46 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * hp300hpux.c (MY(callback)): Set lma as well as vma.
+
+ * configure, config.in: Regenerate with autoconf 2.7.
+
+ * elf32-i386.c (elf_backend_plt_readonly): Set correctly, to 1.
+ * elf32-sparc.c (elf_backend_plt_readonly): Set correctly, to 0.
+
+Wed Nov 22 12:02:09 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_new_section_hook): Handle .rconst section.
+ (ecoff_sec_to_styp_flags): Likewise.
+ (_bfd_ecoff_styp_to_sec_flags): Handle STYP_RCONST.
+ (ecoff_set_symbol_info): Handle scRConst.
+ (ecoff_slurp_reloc_table): Handle RELOC_SECTION_RCONST.
+ (ecoff_compute_section_file_positions): Handle .rconst section.
+ (_bfd_ecoff_write_object_contents): Likewise.
+ (ecoff_link_check_archive_element): Handle scRConst.
+ (ecoff_link_add_externals): Likewise.
+ (ecoff_link_write_external): Handle .rconst section.
+ (ecoff_reloc_link_order): Likewise.
+ * ecofflink.c (bfd_ecoff_debug_accumulate): Handle scRConst.
+ * coff-alpha.c (alpha_convert_external_reloc): Handle .rconst
+ section.
+ (alpha_relocate_section): Handle RELOC_SECTION_RCONST.
+
+ * sunos.c (sunos_scan_dynamic_symbol): Only set written if the
+ DEF_DYNAMIC flag is set.
+
+Tue Nov 21 13:25:29 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * host-aout.c: If TRAD_HEADER is defined, include it.
+
+Tue Nov 21 13:03:57 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aclocal.m4 (AC_PROG_CC): Remove local definition.
+ (BFD_BINARY_FOPEN): Require AC_CANONICAL_SYSTEM.
+ (BFD_NEED_DECLARATION): New function.
+ * configure.in: Use BFD_NEED_DECLARATION.
+ * acconfig.h: Put NEED_DECLARATION_* in @TOP@ section.
+ * configure, config.in: Rebuild with autoconf 2.6.
+
+ * xcofflink.c (bfd_xcoff_size_dynamic_sections): Clear
+ special_sections before returning when called with a non XCOFF
+ BFD.
+
+ * coffgen.c (coff_renumber_symbols): Sort common symbols with
+ global symbols.
+
+ * coffcode.h (coff_compute_section_file_positions): Only pad the
+ previous section to force file alignment when creating an
+ executable.
+
+Mon Nov 20 14:54:09 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_compute_section_file_positions): If
+ RS6000COFF_C, set up the .debug section.
+
+ * xcofflink.c (xcoff_link_input_bfd): Adjust the TOC anchor value
+ if it is not large enough to accomodate the entire TOC area with
+ signed 16 bit offsets.
+ (xcoff_write_global_symbol): Handle negative TOC offsets in global
+ linkage code.
+ (_bfd_ppc_xcoff_relocate_section): Adjust relocations against a
+ TOC anchor to use the TOC value used in the output file.
+
+Sat Nov 18 18:01:41 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffgen.c (_bfd_coff_get_external_symbols): Cast malloc return.
+ (_bfd_coff_read_string_table): Likewise.
+
+Sat Nov 18 19:43:04 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
+
+ * pe-arm.c: Fix typos.
+ * coff-arm.c: Likewise.
+
+Fri Nov 17 16:22:04 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (list_ele): Added "cat"egory member.
+ (record_toc): New category parameter (priv or pub).
+ (ppc_record_toc_entry): Check to see if toc bounds exceeded.
+ (ppc_process_before_allocation): Removed embrionic data-in-toc from
+ the mainline. It addes extra toc cells in error.
+ (ppc_coff_swap_sym_in_hook): Added some documentation.
+ (dump_toc): Can now diagnose "virtual toc" chicanery.
+
+Fri Nov 17 10:41:25 1995 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * elf-bfd.h (struct elf_link_hash_table): Change type of
+ dynsymcount and bucketcount fields from size_t to bfd_size_type.
+
+Fri Nov 17 10:02:58 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_pointerize_aux_hook): I960 version: don't
+ pointerize C_LEAFSTAT or C_LEAFEXT entries.
+
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Only create
+ DT_INIT and DT_FINI entries if the _init or _fini symbol is
+ defined or mentioned in a regular file.
+
+Thu Nov 16 15:16:42 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (ppc_record_data_in_toc_entry): new function
+ (coff_ppc_relocate_section): Handle TOCDEFN attribute
+ (coff_ppc_relocate_section): Correct REL24 handling
+ (ppc_process_before_allocation): Correct TOCDEFN handling
+
+ * peicode.h (dir_names): Added name descriptions
+
+Thu Nov 16 03:38:03 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * VERSION: Updated to cygnus-2.6.
+
+Wed Nov 15 19:30:07 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * targets.c (m68k4knetbsd_vec): Declare.
+
+Wed Nov 15 18:05:52 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * targets.c (bfd_target): Change type of second argument to
+ _bfd_print_private_bfd_data from void * to PTR.
+ * libbfd-in.h (_bfd_generic_bfd_print_private_bfd_data): Cast
+ using PTR rather than void *.
+ * bfd-in2, libbfd.h: Rebuild.
+ * peicode.h (pe_print_private_bfd_data): Change vfile from void *
+ to PTR.
+ * elfxx-target.h (bfd_elfNN_bfd_print_private_bfd_data): Define as
+ _bfd_generic_bfd_print_private_bfd_data rather than casting
+ bfd_true.
+
+Wed Nov 15 04:09:14 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (.dep1): Fix stupid typo in last change. Remove any
+ "DO NOT DELETE" lines or blank lines that mkdep writes on some
+ systems.
+ (BFD_LIBS_CFILES, ALL_MACHINES_CFILES, BFD32_BACKENDS_CFILES,
+ BFD64_BACKENDS_CFILES): New variables.
+ (CFILES): Use them.
+
+Tue Nov 14 11:52:23 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (coff_swap_aouthdr_out): For PPC PE, start isize at 0,
+ not at the file position of the first section.
+ * coffcode.h (coff_compute_section_file_positions): Avoid using
+ unportable #elif.
+ (coff_write_object_contents): When generating a PPC PE executable
+ with no symbols, round up the file size to a COFF_PAGE_SIZE
+ boundary.
+ * cofflink.c (_bfd_coff_final_link): If there are no symbols,
+ don't write out a string table.
+
+ * elf.c (bfd_section_from_shdr): When using a different section
+ header, pass the new one to _bfd_elf_make_section_from_shdr.
+ (elf_fake_sections): Don't set sh_info and sh_entsize fields.
+ (elf_map_symbols): Add section VMA to symbol value when comparing
+ against 0.
+ (_bfd_elf_compute_section_file_positions): Only build symbol table
+ if there are some symbols. Set file offset of symtab and strtab
+ sections.
+ (assign_file_positions_except_relocs): Remove dosyms parameter.
+ Change all callers. Never set file offset of symtab and strtab
+ sections.
+ (_bfd_elf_copy_private_section_data): New function.
+ (MAP_ONESYMTAB, MAP_DYNSYMTAB, MAP_STRTAB, MAP_SHSTRTAB): Define.
+ (_bfd_elf_copy_private_symbol_data): New function.
+ (swap_out_syms): Check for special mapping of st_shndx created by
+ copy_private_symbol_data.
+ * elfxx-target.h: Use new copy routines.
+ * elf-bfd.h (_bfd_elf_copy_private_symbol_data): Declare.
+ (_bfd_elf_copy_private_section_data): Declare.
+
+ * config.bfd (sh-*-*): Set targ_defvec to shcoff_vec.
+
+ * coffcode.h (coff_slurp_symbol_table): If COFF_WITH_PE, handle
+ C_NT_WEAK.
+
+ * coff-sh.c (shlcoff_vec): Use _bfd_generic_archive_p, not
+ _bfd_dummy_target, matching the recent change to archive
+ recognition.
+
+Mon Nov 13 13:24:38 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd.c (bfd_get_file_window): Use casts to avoid doing
+ arithmetic on PTR types.
+
+ * aout-target.h (MY(callback)): Set the lma of the sections.
+
+ * ecoff.c (ecoff_reloc_link_order): Turn a reloc against a defined
+ symbol into a reloc against the section.
+
+Mon Nov 13 07:31:35 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (ppc_coff_link_hash_entry): added support for inline
+ glue for the relocs: IMGLUE and IFGLUE.
+ (record_toc): new function - tracks toc contents
+ (ppc_mark_symbol_as_glue): new function - supports the IMGLUE reloc
+ (coff_ppc_relocate_section): Added support and fixes for IMGLUE/IFGLUE
+ (ppc_coff_rtype2howto): removed invalid IMGLUE hack
+ (coff_ppc_rtype_to_howto): removed invalid IMGLUE hack
+ (ppc_record_toc_entry): Removed a debug define (duh)
+
+ * peicode.h (coff_swap_scnhdr_out): Fixed invalid strcmp for ".reldata"
+ (pe_print_idata): New function - formats the idata section data
+ (pe_print_pdata): New function - formats the pdata section data
+ (pe_print_private_bfd_data): calls to above
+
+Sun Nov 12 12:23:24 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * Makefile.in (bfd_libs_here, etc): Provide empty definitions.
+ * coff-rs6000.c (rs6000coff_vec): Add conditional defines
+ TARGET_SYM and TARGET_NAME for vector and BFD name.
+ * coff-pmac.c (pmac_xcoff_vec): Remove.
+ (TARGET_SYM, TARGET_NAME): Define.
+ * coffcode.h (coff_set_arch_mach_hook) [POWERMAC]: Set the
+ machine to 0, not all PowerMacs are 601s.
+
+Fri Nov 10 12:10:14 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_object_p): Read in any program headers.
+ * elf.c (_bfd_elf_make_section_from_shdr): Adjust section lma
+ based on the program headers, if any.
+ (elf_fake_sections): Set sh_addr from the vma, not the lma.
+ (map_program_segments): Set p_paddr of program headers based on
+ the lma.
+
+Thu Nov 9 13:01:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * archive.c (bfd_generic_archive_p): Preserve tdata in case of
+ failure.
+
+ * aoutx.h (NAME(aout,final_link)): Report a reasonable error when
+ trying to do a relocateable link with a non-a.out object file.
+
+ * archive.c (bfd_generic_archive_p): Check the first object file
+ in an archive even if target_defaulted is set. If the object file
+ has the wrong xvec, reject it.
+
+ * aoutx.h (NAME(aout,set_section_contents)): If a section can not
+ be represented, report the name via _bfd_error_handler.
+ (translate_to_native_sym_flags): Likewise.
+ * elf32-mips.c (mips_elf_final_link): Likewise.
+ * oasys.c (oasys_write_sections): Likewise.
+
+ * coffcode.h (coff_set_alignment_hook): Write RS6000COFF_C version
+ which checks for STYP_OVRFLO sections.
+ (coff_compute_section_file_positions): If RS6000COFF_C, handle
+ reloc and lineno count overflows.
+ (coff_write_object_contents): Call coff_count_linenumbers before
+ coff_compute_section_file_positions. If RS6000COFF_C, handle
+ reloc and lineno count overflows.
+ * xcofflink.c (_bfd_xcoff_bfd_final_link): Count line numbers and
+ relocs before dealing with .pad sections. Count overflow section
+ headers when handling .pad sections.
+
+ * coffcode.h (coff_write_object_contents): Set a.out vstamp to 1
+ if RS6000COFF_C.
+
+ * xcofflink.c (XCOFF_DESCRIPTOR): Define.
+ (struct xcoff_link_hash_table): Add descriptor_section and
+ special_sections fields.
+ (_bfd_xcoff_bfd_link_hash_table_create): Initialize new fields.
+ (xcoff_link_add_symbols): Set linkage section alignment. Create
+ descriptor section. Check for magic symbol names (_text, etc.),
+ and record them in special_sections if found. Set
+ XCOFF_DESCRIPTOR flag for a function descriptor, and set its
+ descriptor field to point back to the function code symbol.
+ (xcoff_sweep): Always mark the special descriptor_section.
+ (bfd_xcoff_export_symbol): Check whether the symbol might be a
+ function descriptor, and mark it if it is.
+ (bfd_xcoff_size_dynamic_sections): Add new special_sections
+ parameter, and fill it in. Allocate space for the descriptor
+ section.
+ (xcoff_build_ldsyms): Set XCOFF_DEF_REGULAR flag when defining
+ global linkage code. If an undefined function descriptor is
+ exported, arrange to define it. Warn about any other undefined
+ exported symbol.
+ (_bfd_xcoff_bfd_final_link): Write out the descriptor section.
+ (xcoff_write_global_symbol): Create a function descriptor when
+ necessary.
+ * bfd-in.h (bfd_xcoff_size_dynamic_sections): Update declaration.
+ * bfd-in2.h: Rebuild.
+
+Thu Nov 9 08:40:23 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (ppc_coff_link_hash_entry): new types for hashing
+ (ppc_coff_link_hash_table): new types for hashing
+ (ppc_coff_link_hash_newfunc): hash entry constructor
+ (ppc_coff_link_hash_table_init): hash table initializer
+ (ppc_coff_link_hash_table_create): hash table constructor
+ (ppc_record_toc_entry): changed references to hash table
+ (coff_ppc_relocate_section): changed references to hash table
+
+ * libcoff-in.h (coff_link_hash_entry): removed toc_offset
+ * libcoff.h: Rebuild
+
+ * cofflink.c (_bfd_coff_link_hash_newfunc): removed toc_offset init
+ (coff_link_add_symbols): removed toc_offset init
+
+Thu Nov 9 04:00:38 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (.dep1): Make sure the file mkdep is to write exists
+ first.
+
+ * configure.in: Added new option --with[out]-mmap. Set USE_MMAP
+ if it is given and mmep is available.
+ * acconfig.h: Undef USE_MMAP.
+ * configure, config.in: Regenerated.
+ * aoutx.h: If USE_MMAP is not defined, do all symbol and string
+ table handling the old way.
+ (aout_get_external_symbols): Don't complain if last byte of string
+ table is nonzero.
+ * libbfd.c [HAVE_MADVISE]: Include sys/types.h and sys/mman.h.
+ (bfd_free_window) [! USE_MMAP]: Don't define.
+ (bfd_get_file_window,
+ _bfd_generic_get_section_contents_in_window) [! USE_MMAP]: Abort.
+
+Wed Nov 8 20:03:44 1995 Eric Freudenthal <freudenthal@nyu.edu>
+
+ * coff-a29k.c (SIGN_EXTEND_HWORD): Use ~0xffff rather than
+ 0xffff0000.
+
+Wed Nov 8 11:31:11 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-a29k.c (a29k_reloc): Change handling of R_IREL reloc to be
+ compatible with AMD generated COFF files. Try to support both AMD
+ and GNU formats simultaneously.
+ (coff_a29k_relocate_section): Likewise.
+
+ * libbfd.c (bfd_get_file_window): Change writable parameter from
+ int to boolean; update all callers. Pass MAP_SHARED if not
+ writable--it's required on Solaris. Cast fprintf argument to
+ avoid warning.
+ * bfd-in.h (bfd_get_file_window): Update declaration.
+ * bfd-in2.h: Rebuild.
+ * aoutx.h: Update calls to bfd_get_file_window.
+
+ * xcofflink.c (XCOFF_DEF_DYNAMIC): Rename from XCOFF_REF_DYNAMIC.
+ Change all uses.
+ (xcoff_swap_ldhdr_in): New static function.
+ (xcoff_swap_ldsym_in): New static function.
+ (xcoff_find_reloc): Handle the case of a single reloc correctly.
+ (xcoff_link_add_symbols): If we just created a descriptor, pass it
+ to _bfd_generic_link_add_one_symbol, to save a hash lookup.
+ Handle XTY_ER/XMC_XO symbols correctly.
+ (xcoff_link_add_dynamic_symbols): Rewrite to read .loader symbols
+ rather than normal symbol table.
+ (bfd_xcoff_import_symbol): It's not an error if the symbol is
+ already defined with the same absolute value.
+ (xcoff_mark): When considering called symbols, check whether the
+ descriptor is from a dynamic object, rather than the symbol
+ itself.
+ (xcoff_build_ldsyms): Likewise.
+
+ * libbfd.c (bfd_get_file_window): Change return type to boolean.
+ Cast realloc and malloc return values. If malloc or realloc fail,
+ set bfd_error_no_memory.
+ * bfd-in.h (bfd_get_file_window): Change type to boolean.
+ * bfd-in2.h: Rebuild.
+
+Tue Nov 7 11:53:48 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (ppc_record_toc_entry): new function.
+ (in_reloc_p): changed return value.
+ (coff_ppc_relocate_section): much rework.
+ (ppc_allocate_toc_section): new function.
+ (ppc_process_before_allocation): new function.
+ (ppc_coff_swap_sym_in_hook): new function.
+
+ * cofflink.c (_bfd_coff_link_hash_newfunc): initialize toc_offset.
+ (coff_link_add_symbols): initialize toc_offset.
+
+ * peicode.h (coff_swap_sym_in): Added coff_swap_sym_in_hook
+ (coff_swap_aouthdr_out): Added more sections to the data
+ dictionary for the pe file header. Also changed linker version
+ number on the ppc side.
+ (dir_names): small improvements to the dictionary printing.
+ (pe_mkobject_hook): save the file level flags.
+
+ * libcoff-in.h (coff_link_hash_entry): added toc_offset field
+ (pe_tdata): added real_flags field
+ (coff_tdata): added local_toc_sym_map and access macro
+
+ * libcoff.h (coff_link_hash_entry): added toc_offset field
+ (pe_tdata): added real_flags field
+ (coff_tdata): added local_toc_sym_map and access macro
+
+ * coffcode.h (coff_set_alignment_hook): added hook for PE.
+ (coff_mkobject): init for local_toc_sym_map
+ (coff_write_object_contents): set the internal_a.magic to
+ IMAGE_NT_OPTIONAL_HDR_MAGIC which appears to be what other
+ ppc compilers use.
+
+Tue Nov 7 13:48:58 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecofflink.c (_bfd_ecoff_locate_line): Keep looking through stabs
+ entries until both the line number address and the function name
+ address are too large.
+
+ * configure.in: Call AC_CHECK_PROG to find and cache AR.
+ * configure: Rebuilt.
+
+ * aclocal.m4 (BFD_CC_FOR_BUILD): Don't define CC_FOR_BUILD if it
+ is defined in the environment.
+
+Tue Nov 7 10:57:24 1995 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_get_section_contents_in_window): Define to use
+ generic version.
+
+Mon Nov 6 17:13:15 1995 Harry Dolan <dolan@ssd.intel.com>
+
+ * coff-i860.c: New file, based on coff-i386.c.
+ * cpu-i860.c: New file, based on cpu-i386.c.
+ * hosts/i860mach3.h: New file, based on hosts/i386mach3.h.
+ * config.bfd (i860-*-mach3*, i860-*-osf1*, i860-*-coff*): New
+ targets, using i860coff_vec.
+ * configure.in (i860-*-mach3*, i860-*-osf1*): New hosts, using
+ trad-core.o and hosts/i860mach3.h.
+ (i860coff_vec): Use coff-i860.o and cofflink.o.
+ * configure: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (ALL_MACHINES): Add cpu-i860.o.
+ (BFD32_BACKENDS): Add coff-i860.o.
+ (CFILES): Add cpu-i860.c and coff-i860.c.
+ * targets.c (i860coff_vec): Declare.
+ (bfd_target_vector): Add &i860coff_vec.
+ * archures.c (bfd_i860_arch): Declare.
+ (bfd_archures_list): Add &bfd_i860_arch.
+ * coffcode.h (coff_set_arch_mach_hook): Handle I860 magic number.
+ (coff_set_flags): Handle bfd_arch_i860.
+ (coff_write_object_contents): Handle I860 a.out magic number.
+
+Mon Nov 6 14:34:07 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_symbols): Set the alignment power of
+ the created .tc section to 2.
+ (xcoff_mark): Don't keep a .loader reloc for a call to an
+ undefined symbol when creating a shared library.
+ (xcoff_build_ldsyms): When creating a shared library, generate
+ global linkage code for a call to an undefined symbol.
+
+Sun Nov 5 21:44:13 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (CFILES): Rebuild list from BFD_LIBS, ALL_MACHINES,
+ BFD32_BACKENDS, BFD64_BACKENDS.
+ (.dep1): Put mkdep output in a separate file.
+ Rebuilt dependencies.
+
+ * ecoff.c (_bfd_ecoff_slurp_armap): Cast _bfd_read_ar_hdr return
+ value.
+
+ Permit use of mmap when available:
+
+ * configure.in: Check for mmap, madvise, mprotect.
+ * config.in, configure: Regenerated.
+
+ * libbfd.c (struct _bfd_window_internal): Define type.
+ (bfd_init_window, bfd_free_window, bfd_get_file_window): New
+ functions.
+ (ok_to_map): New static variable for debugging.
+ (_bfd_generic_get_section_contents_in_window): New function.
+ * bfd-in.h (bfd_window_internal): Declare type.
+ (bfd_window): Define type.
+ (bfd_init_window, bfd_free_window, bfd_get_file_window): Declare.
+ * libbfd-in.h (_bfd_generic_get_section_contents_in_window):
+ Declare.
+
+ * libaout.h (struct aoutdata): Add two window fields.
+ (obj_aout_sym_window, obj_aout_string_window): New macros.
+ * aoutx.h (some_aout_object_p): Initialize windows.
+ (aout_get_external_symbols): Get symbol data and strings in
+ windows instead of explicitly allocated buffers.
+ (slurp_symbol_table): Free window instead of memory.
+ (bfd_free_cached_info): Release windows instead of freeing storage
+ directly.
+ (aout_link_free_symbols): Ditto.
+
+ * targets.c (bfd_target): Add new field for
+ get_section_contents_in_window.
+ (BFD_JUMP_TABLE_GENERIC): Updated.
+ * aout-adobe.c, aout-target.h, binary.c, bout.c, coff-alpha.c,
+ coff-mips.c, elfxx-target.h, i386msdos.c, i386os9k.c, ieee.c,
+ libcoff-in.h, oasys.c, srec.c, tekhex.c, versados.c: Added new
+ macros for get_section_contents_in_window field.
+
+Sat Nov 4 12:23:26 1995 Fred Fish <fnf@cygnus.com>
+
+ * core.c: Renamed to corefile.c
+ * makefile.dos (OBJS): Change core.o to corefile.o
+ * Makefile.in (CFILES, BFD_LIBS): Use corefile.c instead of core.c
+
+Fri Nov 3 15:54:59 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_symbols): Rename local variable sub
+ to o. Clobber and restore the list of new csects around the call
+ to _bfd_generic_link_add_one_symbol, in case it wants to report a
+ linker error and the linker wants to read the symbol table. Reset
+ the line number count of a real section even if it has no relocs.
+ (_bfd_xcoff_bfd_final_link): If shared, set the DYNAMIC flag.
+
+ * coffgen.c (_bfd_coff_read_string_table): Warn if the string size
+ is too small.
+
+Thu Nov 2 23:16:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (_bfd_ppc_xcoff_relocate_section): Don't warn about
+ an undefined symbol in a shared link.
+
+ * linker.c (_bfd_generic_link_add_one_symbol): Correct type of
+ oldtype from bfd_link_order_type to bfd_link_hash_type. From
+ phdm@info.ucl.ac.be (Philippe De Muyter).
+
+Wed Nov 1 14:26:02 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de>
+
+ * coff-m88k.c (rtype2howto): New static function.
+ (RTYPE2HOWTO): Use it rather than a macro definition.
+
+ * coffcode.h (coff_write_object_contents): set internal_a.magic
+ to PAGEMAGICPEXECPAGED #if defined (M68) && !defined (LYNXOS).
+
+ * configure.in: m68*-motorola-sysv* does not use ptrace-core.o;
+ define TRAD_HEADER to new file hosts/delta68.h.
+ m88*-motorola-sysv*, however, does use ptrace-core.o.
+ * hosts/delta68.h: New file.
+
+ * ptrace-core.c (ptrace_unix_core_file_p): change bfd_zmalloc to
+ bfd_zalloc; provide proper parm abfd to calls to bfd_zalloc.
+
+Wed Nov 1 13:51:54 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * i386linux.c (MY(vec)): Declare before use.
+
+Wed Nov 1 11:45:07 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * reloc16.c (bfd_coff_reloc16_get_relocated_section_contents):
+ Pass input_bfd, not in_bfd, to bfd_coff_reloc16_extra_cases.
+
+ * elf.c (bfd_elf_set_dt_needed_name): Don't do anything if the
+ BFD is not of the right type.
+ (bfd_elf_get_needed_list): Likewise.
+ * i386linux.c (bfd_linux_size_dynamic_sections): Likewise.
+ * sunos.c (bfd_sunos_get_needed_list): Likewise.
+ * xcofflink.c (XCOFF_XVECP): Define.
+ (bfd_xcoff_link_record_set): Don't do anything if the BFD is not
+ of the right type.
+ (bfd_xcoff_import_symbol): Likewise.
+ (bfd_xcoff_export_symbol): Likewise.
+ (bfd_xcoff_link_count_reloc): Likewise.
+ (bfd_xcoff_record_link_assignment): Likewise.
+ (bfd_xcoff_size_dynamic_sections): Likewise.
+
+ * sunos.c (sunos_scan_ext_relocs): Only check the reloc symbol
+ table index against the number of symbols for a base relative
+ reloc.
+
+ * coff-rs6000.c (_bfd_xcoff_sizeof_headers): Change from macro to
+ static function.
+ * xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Set
+ full_aouthdr flag here...
+ (_bfd_xcoff_bfd_final_link): ...not here.
+
+Tue Oct 31 12:52:02 1995 Fred Fish <fnf@cygnus.com>
+
+ * libelf.h: Rename to elf-bfd.h to avoid conflict with
+ systems that have a system <libelf.h>.
+ * Makefile.in: Globally replace libelf.h with elf-bfd.h.
+ * bfd.c, elf.c, elf32-arc.c, elf32-gen.c, elf32-hppa.c,
+ elf32-hppa.h, elf32-i386.c, elf32-i860.c, elf32-m68k.c,
+ elf32-m88k.c, elf32-mips.c, elf32-ppc.c, elf32-sparc.c,
+ elf64-gen.c, elf64-sparc.c, elfcode.h, elflink.c,
+ elfxx-target.h: Include elf-bfd.h rather than libelf.h.
+ * elfxx-target.h: Change libelf.h reference to elf-bfd.h.
+
+Tue Oct 31 15:30:07 1995 David Mosberger-Tang <davidm@azstarnet.com>
+
+ * ecoff.c (ecoff_set_symbol_info): Add new parameter weak. If
+ set, set BSF_WEAK in symbol. Change all callers.
+ (ecoff_get_extr): Set weakext based on BSF_WEAK.
+ (ecoff_link_add_externals): If weakext is set, pass BSF_WEAK to
+ _bfd_generic_link_add_one_symbol.
+ (ecoff_indirect_link_order): Check that the section tdata relocs
+ are not NULL before using them.
+
+ * configure.in (alpha*-*-linux*): Set COREFILE to trad-core.o and
+ define TRAD_HEADER as hosts/alphalinux.h.
+ * configure: Rebuild.
+ * hosts/alphalinux.h: New file.
+ * trad-core.c (trad_unix_core_file_p): Cast u.u_ar0 to bfd_vma,
+ not int.
+
+Tue Oct 31 12:34:11 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_slurp_symbol_table): Accept C_BCOMM and
+ C_ECOMM storage classes.
+
+ * xcofflink.c (xcoff_mark_symbol): New static function, broken out
+ of xcoff_mark.
+ (xcoff_mark): Call xcoff_mark_symbol.
+ (bfd_xcoff_export_symbol): Call xcoff_mark_symbol.
+ (bfd_xcoff_link_count_reloc): Call xcoff_mark_symbol rather than
+ doing it by hand.
+ (xcoff_build_ldsyms): Build a .loader symbol for an export symbol.
+
+Mon Oct 30 14:53:48 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (struct xcoff_final_link_info): Add new line_filepos
+ field.
+ (xcoff_find_reloc): New static function.
+ (xcoff_link_add_symbols): Use it.
+ (_bfd_xcoff_bfd_final_link): Set finfo.line_filepos.
+ (xcoff_link_input_bfd): Handle C_BINCL and C_EINCL. Don't
+ relocate the value of C_DECL.
+
+ * elf.c (elf_fake_sections): Remove bogus BFD_ASSERT.
+
+Sat Oct 28 01:25:34 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Make
+ callback decide what goes in .relocs.
+ * pe[i]-i386.c (TARGET_UNDERSCORE): Define.
+ * peicode.h (pe_mkobject_hook): Only copy aouthdr if
+ there is one.
+
+Sat Oct 28 01:51:02 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_symbols): Handle csects in the
+ absolute section.
+
+Fri Oct 27 18:14:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c: More improvements, mostly to fix handling of
+ constructors and a few other special cases.
+ * coff-rs6000.c (rs6000coff_vec): Set symbol_leading_char back to
+ zero, reverting yesterday's change.
+ * bfd-in.h (bfd_xcoff_link_record_set): Declare.
+ (bfd_xcoff_link_count_reloc): Declare.
+ (bfd_xcoff_record_link_assignment): Declare.
+ * bfd-in2.h: Rebuild.
+
+Fri Oct 27 14:42:15 1995 Niklas Hallqvist <niklas@appli.se>
+
+ * PORTING, aout-arm.c, aout-encap.c, aout-target.h,
+ aoutx.h, gen-aout.c, host-aout.c, hp300bsd.c, i386aout.c
+ i386bsd.c, i386dynix.c, i386linux.c, i386lynx.c, i386mach3.c,
+ i386netbsd.c, m68klynx.c, m88kmach3.c, mipsbsd.c, newsos3.c,
+ ns32knetbsd.c, pc532-mach.c, riscix.c, sparclynx.c, sparcnetbsd.c:
+ Change PAGE_SIZE to TARGET_PAGE_SIZE.
+
+ * m68knetbsd.c: Ditto as well as add support for the m68k4k object
+ format.
+
+ * netbsd.h: Double ditto (incl. m68k4k support). NetBSD's text
+ segments includes the a.out header. See to that the magic number
+ *always* is big-endian.
+
+ * config.bfd: Add m68*-hp*-netbsd* case. Cross-pollinate m68k and
+ m68k4k NetBSD configurations.
+
+ * configure.in, configure: Separate i386 & mips NetBSD
+ configurations from other BSD ones. Don't assume DEC is the only
+ thing NetBSD/mips run on. Add {m68k,ns32k,sparc}-*-netbsd*
+ configurations. Add support for m68k4k NetBSD object format.
+
+ * libaout.h: Added M_68K4K_NETBSD magic.
+
+ * m68k4knetbsd.c: New file.
+
+ * hosts/{m68k,sparc}nbsd.h: Don't define HOST_BIG_ENDIAN_P.
+
+ * hosts/nbsd.h: Define HOST_BIG_ENDIAN_P according to
+ <machine/endian.h>.
+
+ * hosts/mipsnbsd.h: New file.
+
+Thu Oct 26 14:16:47 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c: Numerous changes to get closer to a working XCOFF
+ linker.
+ * libcoff-in.h (struct xcoff_tdata): Add full_aouthdr,
+ toc_section, and entry_section fields.
+ (struct xcoff_section_tdata): Remove ldrel_count field.
+ * libcoff.h: Rebuild.
+ * coffcode.h (coff_mkobject_hook): Initialize new xcoff_data
+ fields.
+ (coff_compute_section_file_positions): If RS6000COFF_C, generate
+ full a.out header if full_aouthdr is set in xcoff_data.
+ (coff_write_object_contents): Likewise. Set o_snentry and o_sntoc
+ based on sections stored in xcoff_data.
+ * coff-rs6000.c (xcoff_copy_private_bfd_data): Copy new xcoff_data
+ fields.
+ (xcoff_reloc_type_lookup): Handle BFD_RELOC_CTOR.
+ (rs6000coff_vec): Set symbol_leading_char to '.'.
+ * coffgen.c (coff_get_symbol_info): If fix_value is set, fix the
+ value stored in ret rather than returning a pointer value.
+
+Wed Oct 25 23:10:39 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.bfd (powerpc{,le}-{elf,sysv4,eabi,solaris2}): Remove MAC
+ format for now.
+
+Wed Oct 25 16:19:27 1995 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_slurp_string_table): Allocate the strings with malloc
+ since they're free'd by free_cached_info.
+ (som_slurp_symbol_table): Similarly for the symbol table.
+
+Wed Oct 25 14:59:22 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in (diststuff): Don't make headers.
+
+Wed Oct 25 11:32:54 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Rebuild dependencies.
+
+ * sunos.c (bfd_sunos_record_link_assignment): Don't do anything if
+ output_bfd is not SunOS.
+ (bfd_sunos_size_dynamic_sections): Likewise. Don't scan relocs of
+ non-SunOS input files.
+
+ * xcofflink.c: Extensive changes to support linking shared objects
+ and generating a .loader section.
+ * libcoff-in.h (struct xcoff_tdata): Add import_file_id field.
+ (struct xcoff_section_tdata): Add lineno_count, first_symndx,
+ last_symndx, and ldrel_count fields.
+ * libcoff.h: Rebuild.
+ * coff-rs6000.c (xcoff_howto_table): Correct reloc names.
+ * coffcode.h (styp_to_sec_flags): Don't set any flags if STYP_PAD
+ is set.
+ * bfd-in.h (bfd_xcoff_import_symbol): Declare.
+ (bfd_xcoff_export_symbol): Declare.
+ (bfd_xcoff_size_dynamic_sections): Declare.
+ * bfd-in2.h: Rebuild.
+
+Tue Oct 24 17:44:20 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * configure.in: Add xcofflink.o to pmac_xcoff_vec.
+ * configure: Rebuild.
+ * mpw-config.in: Add xcofflink.c.o to powerpc-apple-macos.
+ * coff-pmac.c: Include coff-rs6000.c instead of duplicating its
+ contents.
+ (pmac_xcoff_vec): Update to use new xcoff support.
+ * coff-rs6000.c (xcoff_generic_stat_arch_elt): Make static.
+ (xcoff_write_armap): Declare buf as unsigned char.
+ * xcofflink.c (xcoff_link_add_symbols): Declare a local as PTR.
+
+ * mpw-make.sed: Generalize subdir_do edit.
+
+Tue Oct 24 10:25:01 1995 Jeffrey A Law (law@cygnus.com)
+
+ * hppabsd-core.c (make_bfd_asection): Initialize asect->filepos
+ correctly. Don't initialize asect->vma.
+
+Fri Oct 20 13:23:48 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * opncls.c (_bfd_new_bfd): If _bfd_chunksize wasn't preset, use
+ something a little less than the page size.
+
+Thu Oct 19 13:06:09 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i960.c (coff_i960_adjust_symndx): Clear *adjustedp.
+
+Wed Oct 18 16:20:08 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coff-i386.c (coff_i386_reloc_type_lookup): New.
+ * coffcode.h (coff_write_object_contents): If .bss is before
+ .data us that as data_start.
+ * cofflink.c (_bfd_coff_generic_relocate_section): Get reloc
+ calc correct.
+ * peicode.h (add_data_entry): Use _cooked_size of data directory.
+ (coff_swap_outhdr_out): Hardwire in version number.
+
+Wed Oct 18 16:50:54 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * sunos.c (sunos_add_dynamic_symbols): Rename local variables
+ major and minor to *_vno, since the former are also macros in
+ SunOS header files. Cast result of bfd_alloc to appropriate
+ type.
+
+ * coffgen.c (coff_find_nearest_line): Cast used_by_bfd value
+ before assigning to sec_data.
+
+Wed Oct 18 13:25:17 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): The offset argument is
+ now relative to the section, not absolute.
+ * ecofflink.c (_bfd_ecoff_locate_line): Use the right symbol to
+ get the file name when there is a N_SO directory name. When
+ handling stabs, remember that section->vma was added to the
+ offset.
+
+Tue Oct 17 18:24:54 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (struct sunos_link_hash_table): Add needed field.
+ (sunos_link_hash_table_create): Call bfd_release, not free.
+ (sunos_link_hash_table_create): Initialize needed field.
+ (sunos_add_dynamic_symbols): Record needed objects.
+ (bfd_sunos_get_needed_list): New function.
+ * bfd-in.h (bfd_sunos_get_needed_list): Declare.
+ * bfd-in2.h: Rebuild.
+
+Mon Oct 16 14:43:59 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * libcoff-in.h (pe_data_type.in_reloc_p): New.
+
+Mon Oct 16 10:52:50 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd-in.h (struct bfd_link_needed_list): Rename from
+ bfd_elf_link_needed_list.
+ * bfd-in2.h: Rebuild.
+ * elf.c, elflink.h, libelf.h: Corresponding changes.
+
+ Add start at AIX linker support; no shared libraries yet.
+ * xcofflink.c: New file.
+ * configure.in (rs600coff_vec): Use xcofflink.o.
+ * configure: Rebuild.
+ * libcoff-in.h (struct xcoff_tdata): Add csects and debug_indices
+ fields.
+ (struct xcoff_section_tdata): Define.
+ (xcoff_section_data): Define macro.
+ (_bfd_xcoff_bfd_link_hash_table_create): Declare.
+ (_bfd_xcoff_bfd_link_add_symbols): Declare.
+ (_bfd_xcoff_bfd_final_link): Declare.
+ (_bfd_ppc_xcoff_relocate_section): Declare.
+ * libcoff.h: Rebuild.
+ * coff-rs6000.c: Clean up a bit.
+ (xcoff_mkobject): Default modtype to 1L, not RE. Initialize
+ cputype, csects, and debug_indices.
+ (xcoff_copy_private_bfd_data): Copy cputype.
+ (xcoff_howto_table): Rename from rs6000coff_howto_table.
+ (xcoff_rtype2howto): Rename from rs6000coff_rtype2howto.
+ (xcoff_reloc_type_lookup): Rename from
+ rs6000coff_reloc_type_lookup.
+ (coff_relocate_section): Define.
+ (_bfd_xcoff_sizeof_headers): Define.
+ (_bfd_xcoff_bfd_get_relocated_section_contents): Define.
+ (_bfd_xcoff_bfd_relax_section): Define.
+ (_bfd_xcoff_bfd_link_split_section): Define.
+ (rs6000coff_vec): For BFD_JUMP_TABLE_LINK, use _bfd_xcoff, not
+ coff.
+ * coffcode.h (coff_compute_section_file_positions): If AIX,
+ increment sofar by SMALL_AOUTSZ if not executable.
+ (coff_write_object_contents): If AIX, always output an a.out
+ header; if not executable, header size of SMALL_AOUTSZ.
+ * hash.c (struct bfd_strtab_hash): Add xcoff field.
+ (_bfd_stringtab_init): Initialize xcoff field.
+ (_bfd_xcoff_stringtab_init): New function.
+ (_bfd_stringtab_add): In XCOFF mode, leave two bytes for length.
+ (_bfd_stringtab_emit): In XCOFF mode, write out length.
+ * libbfd-in.h (_bfd_xcoff_stringtab_init): Declare.
+ * libbfd.h: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add xcofflink.o.
+ (CFILES): Add xcofflink.c.
+
+ * elf32-mips.c (mips_elf_symbol_processing): Set SEC_ALLOC, not
+ SEC_NO_FLAGS, for .acommon section. From Peter Schauer
+ <Peter.Schauer@Regent.E-Technik.TU-Muenchen.DE>.
+
+Sat Oct 14 21:36:02 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * coff-ppc.c (in_reloc_p): Add, clone from coff-i386.c.
+
+Fri Oct 13 17:48:43 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * acconfig.h (HAVE_SYS_PROCFS_H): Undef, with comment.
+ * config.in: Regenerated.
+
+ * opncls.c (getpagesize) [!HAVE_GETPAGESIZE]: Define as 2048.
+ (_bfd_chunksize): New variable.
+ (_bfd_new_bfd): Set it to getpagesize() if negative, and use it
+ for obstack chunk size.
+ * configure.in: Check for getpagesize.
+ * configure: Regenerated.
+
+ Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * trad-core.c (rawptr): Make it a local variable of
+ ptrace_unix_core_file_p.
+
+Fri Oct 13 11:22:01 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coff-arm.c (in_reloc_p): New.
+ * coff-i386.c (in_reloc_p): New.
+ * coffcode.h: Allways include peicode.h if COFF_WITH_PE.
+ (coff_write_object_contents): Only set has_reloc_section
+ if PE_IMAGE.
+ * cofflink.c (_bfd_coff_generic_relocate_section): Call
+ in_reloc_p to decide if reloc should be emitted.
+ * libcoff.h (pe_data_type.in_reloc_p): New.
+ * peicode.h (pe_mkobject): Initialize in_reloc_p.
+
+Wed Oct 11 00:49:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_internal_syment_name): Move to coffgen.c.
+ (_bfd_coff_read_internal_relocs): Likewise.
+ * coffgen.c (_bfd_coff_internal_syment_name): Copy from coffgen.c.
+ (_bfd_coff_read_internal_relocs): Likewise.
+
+ * elflink.h (elf_link_add_object_symbols): Correct conditions
+ under which type and size change warnings are issued.
+
+Tue Oct 10 18:32:46 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffgen.c (coff_count_linenumbers): Don't count line numbers for
+ a symbol which is not in a real section.
+ (coff_write_native_symbol): Corresponding change.
+
+ * cofflink.c (_bfd_coff_link_hash_newfunc): Rename from
+ coff_link_hash_newfunc and make non-static.
+ (_bfd_coff_link_hash_table_init): New function, broken out of
+ _bfd_coff_link_hash_table_create.
+ (_bfd_coff_link_hash_table_create): Use it.
+ (process_embedded_commands): Make static.
+ * libcoff-in.h ((_bfd_coff_link_hash_newfunc): Declare.
+ (_bfd_coff_link_hash_table_init): Declare.
+ * libcoff.h: Rebuild.
+
+ * coffcode.h (coff_mkobject_hook): If RS6000COFF_C, set cputype
+ field in XCOFF tdata.
+ (coff_set_arch_mach_hook): Check ifdef RS6000COFF_C, not ifdef
+ U802ROMAGIC, for clarity. Try to set arch and machine correctly
+ based on cputype stored in a.out header, or in n_type of initial
+ .file symbol.
+ (coff_write_object_contents): Set cputype correctly in a.out
+ header.
+ (coff_slurp_symbol_table): Add casts to file_ptr to avoid
+ warnings.
+ * coffswap.h (coff_swap_aouthdr_in): Swap in cputype field.
+ (coff_swap_aouthdr_out): Swap out cputype field. Don't clear
+ old resv1 field.
+ * libcoff-in.h (struct xcoff_tdata): Add cputype field.
+ * libcoff.h: Rebuild.
+
+ * cpu-rs6000.c (rs6000_compatible): New static function.
+ (bfd_rs6000_arch): Use it.
+ * cpu-powerpc.c (powerpc_compatible): New static function.
+ (arch_info_struct): Define various flavours of PowerPC.
+ (bfd_powerpc_arch): Use powerpc_compatible. Point at
+ arch_info_struct.
+
+Tue Oct 10 10:50:46 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (FLAGS_TO_PASS): Remove BISON.
+
+Tue Oct 10 01:28:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Don't warn about
+ changing the size or type if the old definition was weak.
+
+Mon Oct 9 11:24:08 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (combined_entry_type): Add fix_line field.
+ (coff_slurp_line_table): Warn if we try to set the lineno field of
+ a symbol twice.
+ (coff_slurp_symbol_table): If RS6000COFF_C, handle C_BINCL and
+ C_EINCL by setting fix_line. Fix C_BSTAT symbol value.
+ * coffgen.c (coff_mangle_symbols): Handle fix_line.
+ (coff_write_symbol): Only use N_DEBUG if the symbol is in the
+ absolute section.
+ (coff_print_symbol): Print fix_value symbols in a useful fashion.
+ * libcoff.h: Rebuild.
+
+ * libcoff-in.h (struct xcoff_tdata): Define.
+ (xcoff_data): Define.
+ * bfd.c (struct _bfd): Add xcoff_obj_data field to tdata union.
+ * bfd-in2.h, libcoff.h: Rebuild.
+ * coff-rs6000.c (xcoff_mkobject): New static function.
+ (coff_mkobject): Define.
+ (xcoff_copy_private_bfd_data): New static function.
+ (coff_bfd_copy_private_bfd_data): Define.
+ (rs6000coff_howto_table): Change R_TOC complain_on_overflow from
+ signed to bitfield.
+ (rs6000coff_vec): Add DYNAMIC to object_flags.
+ * coffcode.h (sec_to_styp_flags): If RS6000COFF_C, handle .pad and
+ .loader sections specially.
+ (coff_new_section_hook): If RS6000COFF_C, get the .text and .data
+ section alignment from the XCOFF tdata information.
+ (coff_mkobject_hook): If RS6000COFF_C, set DYNAMIC based on
+ F_SHROBJ, and copy the extra a.out header information into the
+ XCOFF tdata structure.
+ (coff_write_object_contents): If RS6000COFF_C, set F_SHROBJ,
+ F_DYNLOAD and the extra a.out header information.
+ (coff_slurp_symbol_table): Set BSF_NOT_AT_END for a C_EXT or
+ C_HIDEXT symbol with attached csect information.
+ * coffswap.h (coff_swap_aouthdr_in): If RS6000COFF_C, swap
+ in the o_maxdata field.
+ (coff_swap_aouthdr_out): If RS6000COFF_C, swap extra XCOFF fields.
+ * coffgen.c (coff_renumber_symbols): Don't move any symbol to the
+ end if BSF_NOT_AT_END is set.
+
+ * targets.c (bfd_target): Rename _bfd_read_ar_hdr field to
+ _bfd_read_ar_hdr_fn.
+ * libbfd-in.h (_bfd_read_ar_hdr): Update accordingly.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * archive.c (_bfd_get_elt_at_filepos): Cast _bfd_read_ar_hdr
+ return value.
+ (do_slurp_bsd_armap, do_slurp_coff_armap): Likewise.
+ (bfd_slurp_bsd_armap_f2): Likewise.
+ (_bfd_slurp_extended_name_table): Likewise.
+
+Fri Oct 6 16:18:35 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * archive.c (bfd_get_next_mapent): Return BFD_NO_MORE_SYMBOLS
+ when the symbol table is empty.
+
+ * elf32-m68k.c (elf_m68k_size_dynamic_sections): Don't reserve
+ space for section symbols, since we don't output them either.
+ (elf_m68k_adjust_dynindx): Removed.
+
+ * ptrace-core.c (rawptr): Make it a local variable of
+ ptrace_unix_core_file_p.
+
+Fri Oct 6 12:24:47 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * coff-rs6000.c (xcoff_write_archive_contents): Return false, not
+ NULL.
+
+ * config.bfd (powerpc{,le}-{elf,sysv4,eabi,solaris2}): Add NT, and
+ Mac object file formats.
+
+Fri Oct 6 12:04:02 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffgen.c (coff_fix_symbol_name): Don't try to set up file
+ auxent if there isn't one.
+ (coff_write_symbols): If there is no file auxent, use SYMNMLEN
+ rather than FILNMLEN as the maximum name length.
+
+ * coffcode.h (bfd_coff_backend_data): Add new field
+ _bfd_coff_print_aux.
+ (bfd_coff_print_aux): New static function.
+ (coff_pointerize_aux_hook (RS6000COFF_C version)): Pointerize the
+ scnlen field of an XTY_LD csect aux entry.
+ (coff_print_aux): New static function.
+ (coff_slurp_symbol_table): Don't pointerize scnlen field; now done
+ in coff_pointerize_aux_hook.
+ (bfd_coff_std_swap_table): Initialize new field.
+ * coffgen.c (coff_print_symbol): Call bfd_coff_print_aux.
+ * libcoff.h: Rebuild.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize new field.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+
+ * coffcode.h (coff_write_object_contents): On AIX, clear F_RELFLG
+ if there are symbols, for native AIX ld compatibility.
+
+ * coffcode.h (bfd_coff_backend_data): Add new field
+ _bfd_coff_pointerize_aux_hook.
+ (coff_pointerize_aux_hook): Define as a function if RS6000COFF_C
+ or I960, and as 0 otherwise.
+ (bfd_coff_std_swap_table): Initialize new field.
+ * libcoff.h: Rebuild.
+ * coffgen.c (coff_pointerize_aux): Change parameters to take
+ symbol pointer instead of type and class, and to take aux index.
+ Call _bfd_coff_pointerize_aux_hook if it is defined.
+ (coff_get_normalized_symtab): Always call coff_pointerize_aux.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize all fields.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+
+ * coff-rs6000.c: Add full support for AIX archives. Rewrite old
+ read-only/host-only support.
+
+ * coffcode.h (coff_slurp_symbol_table): Set C_HIDEXT symbols to be
+ BSF_LOCAL.
+ (OTHER_GLOBAL_CLASS): Do not define to be C_HIDEXT if
+ RS6000COFF_C.
+
+ * targets.c (bfd_target): Add _bfd_read_ar_hdr field. Modify
+ BFD_JUMP_TABLE_ARCHIVE accordingly.
+ * libbfd-in.h (_bfd_snarf_ar_hdr): Don't declare.
+ (_bfd_compute_and_write_armap): Declare.
+ (_bfd_generic_read_ar_hdr): Declare.
+ (_bfd_read_ar_hdr): Define.
+ (_bfd_noarchive_read_ar_hdr): Define.
+ (_bfd_archive_bsd_read_ar_hdr): Define.
+ (_bfd_archive_coff_read_ar_hdr): Define.
+ * archive.c: Change all callers of _bfd_snarf_ar_hdr to call
+ _bfd_read_ar_hdr instead.
+ (_bfd_generic_read_ar_hdr): Rename from _bfd_snarf_ar_hdr.
+ (_bfd_compute_and_write_armap): Rename from
+ compute_and_write_armap. Make non-static. Change all callers.
+ * ecoff.c (_bfd_ecoff_slurp_armap): Call _bfd_read_ar_hdr rather
+ than _bfd_snarf_ar_hdr.
+ * aout-target.h (MY_read_ar_hdr): Define if not defined.
+ * ieee.c (ieee_read_ar_hdr): Define.
+ * libecoff.h (_bfd_ecoff_read_ar_hdr): Define.
+ * oasys.c (oasys_read_ar_hdr): Define.
+ * som.c (som_read_ar_hdr): Define.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+Thu Oct 5 14:04:07 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * peicode.c (coff_swap_filehdr_in): If symptr is
+ zero, there aren't any symbols, even if nsyms is set.
+
+Thu Oct 5 11:45:02 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libecoff.h (struct ecoff_backend_data): Add adjust_headers
+ field.
+ * ecoff.c (ecoff_sec_to_styp_flags): Check for various Alpha
+ sections, and set styp correctly for them: .got, .hash, .dynamic,
+ .liblist, .rel.dyn, .conflic, .dynstr, .dynsym, .comment.
+ (_bfd_ecoff_styp_to_sec_flags): Check for various Alpha section
+ types.
+ (ecoff_sort_hdrs): New static function.
+ (ecoff_compute_section_file_positions): Return boolean, not void.
+ Sort the sections by VMA before looking through them. Put the
+ first non SEC_ALLOC section on a new page. Put every SEC_ALLOC
+ section on an appropriate boundary within the page.
+ (ecoff_compute_reloc_file_positions): Check return value of
+ ecoff_compute_section_file_positions.
+ (_bfd_ecoff_set_section_contents): Likewise.
+ (_bfd_ecoff_write_object_contents): Check for various Alpha
+ section types when incrementing text_size and data_size. Call
+ adjust_headers backend function if it exists.
+ * coff-alpha.c (alpha_adjust_headers): New static function.
+ (alpha_ecoff_backend_data): Initialize adjust_headers field.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+
+ * hosts/i386bsd.h: Restore file incorrectly deleted on Sep 6.
+
+Wed Oct 4 18:15:02 1995 Jeff Law (law@hurl.cygnus.com)
+
+ * rs6000-core.c (CORE_VERSION_1): Use CORE_VERSION_1 instead
+ of ALTERNATE_AIX_CORE_FORMAT.
+ * configure.in (aix4): No longer need CORE_FLAGS.
+ * configure: Updated.
+
+Wed Oct 4 15:36:36 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ NS32k changes from Ian Dall:
+ * aoutx.h (MY_final_link_relocate, MY_relocate_contents): New
+ macros.
+ (aout_link_input_section_std, aout_link_input_section_ext,
+ aout_link_reloc_link_order): Call them instead of _bfd_*
+ versions.
+ * aout-target.h (MY_exec_header_not_counted): New macro, defaults
+ to zero.
+ (backend_data): Use it instead of hardcoded zero.
+
+ * aout-ns32k.c (CTOR_TABLE_RELOC_HOWTO): New macro.
+ (MY_swap_std_reloc_out): Use udata.i for KEEPIT, don't call stoi.
+
+ * ns32knetbsd.c: Include bfd.h.
+ (MY_text_includes_header, MY_bfd_reloc_type_lookup): New macros.
+ (MY_bfd_reloc_type_lookup): Declare function too.
+ * pc532-mach.c (set_sizes): Don't declare.
+ (MY_text_includes_header, MY_exec_header_not_counted): Define.
+ (backend_data, MY_backend_data): Don't define.
+
+ * config.bfd: Treat ns32k-pc532-ux* like ns32k-pc532-mach*, and
+ ns32k-*-lites* like ns32k-*-netbsd*.
+
+ * hosts/nbsd.h: Swap order of sys/vmparam.h and sys/param.h, to
+ compile on lites.
+
+Wed Oct 4 14:15:52 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): Restore setting
+ f_timdat to 0, deleted on August 22.
+
+Tue Oct 3 16:28:32 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coffcode.h (coff_bfd_copy_private_symbol_data,
+ coff_bfd_copy_private_section_data,
+ coff_bfd_copy_private_bfd_data): ifdef to allow overrides.
+ * peicode.h (coff_bfd_copy_private_bfd_data): New
+ (pe_bfd_copy_private_bfd_data): New.
+ (coff_swap_scnhdr_in): Swap bss size into the right place.
+ (pe_print_private_bfd_data): Add some newlines.
+
+Tue Oct 3 11:53:04 1995 Jeff Law (law@hurl.cygnus.com)
+
+ * som.c (setup_sections): Don't die if a space has no subspaces.
+
+Mon Oct 2 14:08:55 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Don't let a weak
+ dynamic symbol override a common symbol. Don't change the size or
+ type if they have been set and the new symbol is not a definition.
+ Warn if the size or type changes.
+
+Sun Oct 1 01:34:41 1995 Jeff Law (law@hurl.cygnus.com)
+
+ * som.c (som_begin_writing): Don't write the symbol table or
+ symbol strings.
+ (som_finish_writing): Write them here. Place them after the
+ subspace data, but before the relocs.
+
+Fri Sep 29 11:01:55 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_add_one_symbol): Just pass false, not
+ info->shared_library, to sunos_create_dynamic_sections.
+ (sunos_scan_ext_relocs): Don't warn about a reloc in the .text
+ section.
+ (sunos_check_dynamic_reloc): Remove .text section assertion.
+
+Thu Sep 28 18:48:47 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * config.bfd: Add powerpc-*-macos*, powerpc-*-mpw*.
+ * configure, configure.in: Add pmac_xcoff_vec case.
+ * Makefile.in (BFD32_BACKENDS): Add coff-pmac.o.
+ * coff-pmac.c: New file, PowerMac XCOFF support.
+ * coffcode.h (coff_set_arch_mach_hook): Add PowerMac case.
+ * targets.c (pmac_xcoff_vec): Declare.
+
+ * mpw-config.in: Various changes to be compatible with the
+ autoconf-based configury.
+ * mpw-make.sed: New file, sed commands to translate Unix
+ makefile into MPW syntax.
+ * mpw-make.in: Remove.
+ * hosts/mpw.h: Remove.
+ * bfd-in.h, bfd-in2.h: If MPW, include the file that defines
+ true and false as enums, then define TRUE_FALSE_ALREADY_DEFINED.
+
+Thu Sep 28 17:06:23 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * binary.c (binary_get_symtab): Return an empty string on error.
+ * opncls.c (bfd_fdpenr): Change WIN32 restriction to WINGDB.
+
+Thu Sep 28 15:30:44 1995 Kim Knuttila <krk@nellie>
+
+ * coff-ppc.c: Reformatted according to gnu conventions
+ Removed irrelevant "if 0" code
+
+Thu Sep 28 11:19:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * hp300hpux.c (convert_sym_type): Treat secondary symbols as weak
+ symbols rather than as indirect symbols.
+ (MY(slurp_symbol_table)): Don't do anything special about
+ secondary symbols.
+
+ * coffcode.h (coff_new_section_hook): Make sure that the alignment
+ of .ctors and .dtors sections is no larger than 2.
+
+ * sunos.c (sunos_add_one_symbol): Don't change
+ bfd_link_hash_common to bfd_link_hash_new, since it may be on the
+ undef list.
+ (bfd_sunos_record_link_assignment): Don't put __DYNAMIC in the
+ dynamic symbols when creating a shared library.
+ (sunos_scan_ext_relocs): Handle relocs correctly when creating a
+ shared library.
+ (sunos_scan_dynamic_symbol): Don't mark the __DYNAMIC symbol as
+ written even if it is not defined in a regular object.
+ (sunos_write_dynamic_symbol): Use plt_offset for the address of
+ the jump table reloc. Add an assertion. Use RELOC_JMP_SLOT
+ rather than the constant 22.
+ (sunos_check_dynamic_reloc): Handle creating a shared library.
+ (sunos_finish_dynamic_link): Set the first entry in the GOT to
+ zero when creating a shared library.
+ * aoutx.h (NAME(aout,final_link)): If there is a symbol __DYNAMIC,
+ write it out at the start of the symbol table.
+
+ * Makefile.in (BFD32_BACKENDS): Add coff-arm.o.
+
+Thu Sep 28 00:58:05 1995 Doug Evans <dje@deneb.cygnus.com>
+
+ * config.bfd: Add arm-*-coff.
+ * configure.in, configure: Add armcoff_{little,big}_vec.
+ * targets.c (armcoff_{little,big}_vec): Declare.
+ (bfd_target_vector): Add armcoff_{little,big}_vec.
+ * coff-arm.c (armcoff_{little,big}_vec): Always define.
+
+Wed Sep 27 10:37:14 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * targets.c (bfd_find_target): Remove debugging code.
+
+Wed Sep 27 07:23:39 1995 Kim Knuttila <krk@nellie>
+
+ * coff-ppc.c, pe-ppc.c, pei-ppc.c: Initial bfd for coff/PE
+ support on powerpc.
+ * Makefile.in: added *-ppc files
+ * coffcode.h: ppc MAGIC, and use peicode.h rather than coffswap.h to
+ allow pe based .o's to be shared with other tools on ppc/NT
+ * config.bfd: added powerpc[le]-[pe|winnt] config support
+ * configure, configure.in: added bfd_powerpc[le]_pe[i]_vec
+ * peicode.h: Added more section flags for PE on ppc
+ Added coff_swap_filehdr_out to allow peicode.h to be
+ used for non-image PE files on ppc.
+ Check for image, or not, before copying pe_opthdr
+ * targets.c: Added new bfd's
+ * targets.c: Removed two inactive bfds that shouldn't have made it this
+ far.
+
+Tue Sep 26 14:06:41 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_reloc_type): Rename from reloc_type, and use
+ explicit values to initialize all relocs. Change all users.
+ (ppc_elf_brtaken_inner): New function to handle branch predicition
+ relocs.
+ (ppc_elf_brtaken_reloc): Ditto.
+ (ppc_elf_howto_raw): Use new functions. Make sure all unsupported
+ relocs use ppc_elf_unsupported_reloc.
+ (ppc_elf_merge_private_bfd_data): Keep track of whether an error
+ needs to be reported.
+ (ppc_elf_relocate_section): Support branch prediction relocs.
+
+Tue Sep 26 12:48:05 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd.c (bfd_assert): Remove \n from string passed to
+ _bfd_error_handler.
+
+ * coff-i386.c: (TWO_DATA_SECS): Don't define.
+ * coffcode.h (bfd_coff_backend_data): Remove _bfd_make_section_hook.
+ (bfd_coff_make_section_hook): Don't define.
+ (coff_make_section_hook): Remove.
+ (sec_to_styp_flags): Remove TWO_DATA_SECS case.
+ (styp_to_sec_flags): Likewise.
+ (coff_write_object_contents): Likewise.
+ (bfd_coff_std_swap_table): Don't initialize make_section_hook
+ field.
+ * libcoff.h: Rebuild.
+ * coffgen.c (make_a_section_from_file): Just call
+ bfd_make_section_anyway, not bfd_make_section or
+ bfd_coff_make_section_hook.
+ * ecoff.c (_bfd_ecoff_make_section_hook): Remove.
+ * libecoff.h (_bfd_ecoff_make_section_hook): Don't declare.
+ * coff-alpha.c (alpha_ecoff_backend_data): Don't initialize
+ make_section_hook field.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+
+ * aoutx.h (translate_from_native_sym_flags): Don't try to stuff
+ pointers into value field for warning and indirect symbols; just
+ leave the value field alone.
+ * linker.c (generic_link_add_symbol_list): Use next symbol for
+ warning and indirect symbols, rather than looking in symbol value.
+ * ecoff.c (ecoff_set_symbol_info): Remove indirect_ptr_ptr
+ parameter. Change all callers. Remove support for indirect
+ symbols; it didn't work anyhow.
+ (_bfd_ecoff_slurp_symbol_table): Remove indirect_ptr variable.
+ * syms.c: Change comments about BSF_WARNING and BSF_INDIRECT.
+ * bfd-in2.h: Rebuild.
+
+Mon Sep 25 16:04:09 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_howto_raw): For all 14-bit branch relocs,
+ go back to telling the tools this reloc operates on 32 bits.
+
+Mon Sep 25 11:48:02 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aout-adobe.c (aout_adobe_callback): Use _bfd_error_handler
+ rather than a direct fprintf.
+ * archive.c (_bfd_write_archive_contents): Likewise.
+ * coffcode.h (coff_slurp_symbol_table): Likewise.
+ * elf32-ppc.c (ppc_elf_merge_private_bfd_data): Likewise.
+ (ppc_elf_unsupported_reloc): Likewise.
+ (ppc_elf_relocate_section): Likewise.
+ * i386linux.c (linux_tally_symbols): Likewise.
+ (linux_finish_dynamic_link): Likewise.
+ * osf-core.c (osf_core_core_file_p): Likewise.
+ * rs6000-core.c (rs6000coff_get_section_contents): Likewise.
+ * som.c (som_sizeof_headers): Likewise.
+ * srec.c (srec_bad_byte): Likewise.
+ * bfd.c (bfd_assert): Likewise. Also change file to be const.
+ * libbfd-in.h (bfd_assert): Declare first parameter const.
+ * libbfd.h: Rebuild.
+ * coff-a29k.c (a29k_reloc): Don't bother to fprintf; returning
+ bfd_reloc_overflow is enough.
+ * coff-h8300.c (rtype2howto): Don't bother to fprintf; just abort.
+ * coff-h8500.c (rtype2howto): Likewise.
+ * coff-z8k.c (rtype2howto): Likewise.
+ * coffcode.h (dummy_reloc16_extra_cases): Likewise.
+ * elf.c (_bfd_elf_get_lineno): Likewise.
+ (_bfd_elf_no_info_to_howto): Likewise.
+ (_bfd_elf_no_info_to_howto_rel): Likewise.
+ * hp300hpux.c (convert_sym_type): Likewise.
+ (MY(swap_std_reloc_in)): Likewise.
+ * elf.c (bfd_section_from_shdr): Remove #if 0 sections.
+
+ * libaout.h (struct aoutdata): Add line_buf field.
+ * aoutx.h (NAME(aout,find_nearest_line)): Remove statics buffer
+ and filename_buffer. Instead, use a malloc buffer stored in the
+ new line_buf field. Remove length restrictions.
+
+ * coffgen.c (string_size): Remove static variable.
+ (debug_string_size, debug_string_section): Likewise.
+ (coff_fix_symbol_name): Add string_size_p, debug_string_section_p,
+ and debug_string_size_p parameters. Use them instead of the
+ global variables. Change all callers.
+ (coff_write_symbol): Likewise.
+ (coff_write_alien_symbol, coff_write_native_symbol): Likewise.
+ (coff_write_symbols): Add local variables to replace removed
+ global variables.
+
+ * libcoff-in.h (struct coff_section_tdata): Add offset, i,
+ function, and line_base fields.
+ * libcoff.h: Rebuild.
+ * coffgen.c (coff_find_nearest_line): Use section tdata to cache
+ information, rather than using static variables.
+
+ * sunos.c (sunos_read_dynamic_info): Adjust offsets in an NMAGIC
+ file. From Peter DeWolf <pld@amt.tay1.dec.com>.
+
+ * init.c (initialized): Remove static variable.
+ (bfd_init): Don't bother setting initialized.
+ (bfd_check_init): Remove.
+ * opncls.c (_bfd_new_bfd): Don't call bfd_check_init.
+ * libbfd.h: Rebuild.
+
+Sat Sep 23 01:22:23 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * rs6000-core.c (rs6000coff_core_p): Don't check the core file
+ size for full core dumps. Copy core file header to private data.
+ (rs6000coff_core_file_failing_command,
+ rs6000coff_core_file_failing_signal): New functions to extract
+ the file name and terminating signal from the core file.
+ * coff-rs6000.c: Use them.
+
+Fri Sep 22 17:44:47 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ Change arch info to be const, initialized at compile time.
+ * archures.c: Reindent many functions. Change CONST to const.
+ (bfd_arch_info_type): Make arch_name const. Remove disassemble;
+ nothing set it anyhow. Make next const.
+ (bfd_arch_info_list): Remove.
+ (bfd_archures_list): Rename from archures_init_table. Change from
+ a table of function pointers to a table of bfd_arch_info_type
+ structure addresses.
+ (bfd_scan_arch): Rewrite accordingly. Return a const pointer.
+ (bfd_lookup_arch): Likewise.
+ (bfd_set_arch_info): Rewrite accordingly. Change argument to be a
+ const pointer.
+ (bfd_default_arch_struct): Make const.
+ (bfd_arch_init, bfd_arch_linkin): Remove.
+ (bfd_get_arch_info): Return a const pointer.
+ * init.c (bfd_init): Don't call bfd_arch_init.
+ * bfd.c (struct _bfd): Make arch_info const.
+ * bfd-in2.h: Rebuild.
+ * libbfd.h: Rebuild.
+ * configure.in: Put & before everything in $selarchs.
+ * configure: Rebuild.
+ * cpu-*.c: Change bfd_*_arch from a function which calls
+ bfd_arch_linkin to a const structure.
+ * ieee.c (ieee_object_p): Make arch const.
+
+Fri Sep 22 16:23:18 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * reloc.c (bfd_reloc_code_type): Add relocations to support all of
+ PowerPC V.4.
+ * bfd-in2.h: Regenerate.
+ * libbfd.h: Regenerate.
+
+ * elf32-ppc.c (reloc_type): Update names to match current draft.
+ (ppc_elf_howto_raw): Mark 14 bit relocs as short sized and PC
+ relative. Update names to current V.4 draft.
+ (ppc_elf_reloc_type_lookup): Add support for more relocations.
+ (ppc_elf_relocate_section): Rename relocations to match draft.
+
+Thu Sep 21 21:53:18 1995 Michael Meissner <meissner@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_merge_private_bfd_data): Allow modules
+ compiled with -mrelocatable-lib to be linked with either normal
+ modules or -mrelocatable modules.
+
+Wed Sep 20 12:03:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): Clear the vstamp field
+ in the a.out header.
+
+ * aoutx.h (NAME(aout,swap_ext_reloc_out)): Don't set r_extern for
+ a reloc against a local symbol, even if it's not a section.
+
+Tue Sep 19 17:02:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * targets.c (bfd_target): Remove unused align_power_min field.
+ * bfd-in2.h: Rebuild.
+ * All backends: Remove initialization of align_power_min.
+
+Tue Sep 19 14:02:21 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * peicode.h (coff_swap_scnhdr_out): Get sizes for BSS right.
+
+Mon Sep 18 14:35:01 1995 Arne H. Juul <arnej@pvv.unit.no>
+
+ * config.bfd (mips-dec-netbsd*): New target.
+ * configure.host (mips-dec-netbsd*): New host.
+ * configure.in (mips-dec-netbsd*): New native.
+ * configure: Rebuild.
+
+Fri Sep 15 10:24:36 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ Make the COFF backend linker merge common types:
+ * cofflink.c (struct coff_debug_merge_element): Define.
+ (struct coff_debug_merge_type): Define.
+ (struct coff_debug_merge_hash_entry): Define.
+ (struct coff_debug_merge_hash_table): Define.
+ (coff_debug_merge_hash_table_init): Define.
+ (coff_debug_merge_hash_table_free): Define.
+ (coff_debug_merge_hash_lookup): Define.
+ (struct coff_final_link_info): Add debug_merge field.
+ (coff_debug_merge_hash_newfunc): New static function.
+ (_bfd_coff_final_link): Allocate and free debug_merge table.
+ (coff_link_input_bfd): Merge identical enum, struct and union
+ types.
+
+Thu Sep 14 14:53:58 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ Convert i960 COFF to use COFF backend linker.
+ * coff-i960.c (coff_i960_relocate): Use a coff_section_data
+ structure to store the symbol being used.
+ (coff_i960_start_final_link): New static function.
+ (coff_i960_relocate_section): New static function.
+ (coff_i960_adjust_symndx): New static function.
+ (coff_start_final_link): Define.
+ (coff_relocate_section): Define.
+ (coff_adjust_symndx): Define.
+ * coffcode.h (bfd_coff_backend_data): Add new callback function
+ _bfd_coff_start_final_link.
+ (bfd_coff_start_final_link): Define.
+ (coff_start_final_link): Define if not defined.
+ (bfd_coff_std_swap_table): Add coff_start_final_link.
+ * cofflink.c (_bfd_coff_internal_syment_name): Make globally
+ visible.
+ (_bfd_coff_final_link): Call bfd_coff_start_final_link if the
+ function callback is not NULL.
+ * libcoff-in.h (struct coff_section_tdata): Add tdata field.
+ (_bfd_coff_internal_syment_name): Declare.
+ * libcoff.h: Rebuild.
+ * configure.in (icoff_big_vec): Add cofflink.o.
+ (icoff_little_vec): Likewise.
+ * configure: Rebuild.
+
+Wed Sep 13 17:38:23 1995 Fred Fish <fnf@rtl.cygnus.com>
+
+ * Makefile.in (clean-info): Remove extraneous tab from line
+ following action.
+
+Wed Sep 13 13:27:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (coff_link_input_bfd): Fail if a section with no
+ contents has relocs.
+
+Thu Sep 12 12:45:34 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coffcode.h (coff_compute_section_file_positions): Keep the
+ raw size safe.
+ (coff_write_object_contents): Remember if it's a relocatable
+ file.
+ * libcoff-in.h (pe_data_type): New member 'has_reloc_section'
+ * peicode.h (coff_swap_filehdr_out): Clear not-reloc flag
+ if relocatable file. Swap out saved raw size.
+
+Tue Sep 12 12:14:33 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (do_maintainer_clean): Rename from do_realclean.
+ (maintainer-clean): Rename from realclean, passing
+ maintainer-clean down to subdirectories, but leave realclean as a
+ synonym.
+
+ * linker.c (_bfd_generic_link_add_one_symbol): Pass symbol name to
+ warning callback.
+
+ * dep-in.sed: Remove config.h from generated dependencies.
+
+ * sunos.c (sunos_slurp_dynamic_symtab): New static function,
+ broken out of sunos_canonicalize_dynamic_symtab.
+ (sunos_canonicalize_dynamic_symtab): Call new function
+ sunos_slurp_dynamic_symtab.
+ (sunos_add_dynamic_symbols): Add three new parameters. Return the
+ dynamic symbol table to the caller.
+ * aoutx.h (aout_link_add_symbols): Permit add_dynamic_symbols
+ callback to override the symbols being read.
+ * libaout.h (struct aout_backend_data): Add three new parameters
+ to add_dynamic_symbols callback.
+
+ Extensive minor changes to avoid various gcc warnings. Also:
+ * Makefile.in (BFD32_BACKENDS): Remove coff-arm.o.
+ * archures.c (bfd_arch_info_type): Change mach field from long to
+ unsigned long.
+ (bfd_lookup_arch): Change machine parameter from long to unsigned
+ long.
+
+Mon Sep 11 10:55:47 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_scan_std_relocs): Fix BFD_ASSERT: it's OK to find
+ a symbol with a non-zero plt_offset.
+
+Fri Sep 8 11:47:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (align_file_position): Remove; not used.
+
+ * configure.in: Only check for <sys/procfs.h> on a native system,
+ and make sure it defines prstatus_t.
+ * configure: Rebuild.
+
+Thu Sep 7 12:48:01 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_write_dynamic_symbol): Correct m68k abort test.
+
+ * config.in: Rename from config.h.in.
+ * configure.in: Call AC_CONFIG_HEADER with config.h:config.in.
+ Check for config.h:config.in when creating stamp-h.
+ * configure: Rebuild.
+ * Makefile.in (stamp-h): Depend upon config.in rather than
+ config.h.in. Set CONFIG_HEADERS to config.h:config.in when
+ calling config.status.
+
+ * Makefile.in (do_distclean): Remove config.h and stamp-h.
+ (Makefile): Just rebuild Makefile.
+ (config.h, stamp-h): New targets.
+ * configure.in: Create stamp-h when rebuilding config.h.
+ * configure: Rebuild.
+
+Wed Sep 6 15:00:33 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_CONFIG_HEADER. Substitute
+ HOST_64BIT_LONG. Check that various header files exist. Check
+ that fcntl exists. Call BFD_BINARY_FOPEN. Check whether malloc
+ and/or free need to be declared. Don't make a link to sysdep.h.
+ Define TRAD_HEADER for various hosts.
+ * configure: Rebuild.
+ * configure.host: Don't set my_host. Add definitions taken from
+ host header files for various entries. Remove entries which now
+ do nothing.
+ * acconfig.h: New file.
+ * config.h.in: New file, built by autoheader.
+ * sysdep.h: New file.
+ * Makefile.in (do_distclean): Don't remove sysdep.h.
+ (RECONFIG): Remove.
+ (LOCAL_H_DEPS): New variable.
+ ($(BFD_LIBS)): Use $(LOCAL_H_DEPS) rather than libbfd.h and
+ $(RECONFIG).
+ ($(BFD_MACHINES), $(BFD_BACKENDS)): Likewise.
+ ($(OPTIONAL_BACKENDS)): Likewise.
+ (stmp-bfd.h): Just substitute for BFD_HOST_64BIT_LONG, rather than
+ looking through sysdep.h.
+ * bfd-in.h (BFD_HOST_64BIT_LONG): Define; set by Makefile.
+ (BFD_HOST_64_BIT): Define based on BFD_HOST_64BIT_LONG.
+ (fprintf_vma, sprintf_vma): Likewise.
+ (int64_type, uint64_type): Don't define.
+ * bfd-in2.h: Rebuild.
+ * archures.c, bfd.c, srec.c: Include <ctype.h>.
+ * elfcore.h: Check HAVE_SYS_PROCFS_H rather than HAVE_PROCFS.
+ * lynx-core.c: Include stuff from old hosts/lynx.h.
+ * opncls.c (bfd_fdopenr): Check HAVE_FNCTL and defined (F_GETFL),
+ rather than NO_FCNTL.
+ * targets.c (bfd_target_list): Check HOST_HPPAHPUX and ! __STDC__
+ rather than NATIVE_HPPAHPUX_COMPILER.
+ * trad-core.c: Don't include <errno.h>. Include TRAD_HEADER if it
+ is defined.
+ * hosts/*.h: Remove all header files which merely include,
+ declare, and define things. Leave header files which define
+ information needed by trad-core.c.
+
+ * aclocal.m4 (BFD_BINARY_FOPEN): Define.
+ (BFD_CC_FOR_BUILD): Define.
+ * configure.in: Use BFD_CC_FOR_BUILD.
+ * configure: Rebuild.
+
+Tue Sep 5 19:35:28 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aclocal.m4: Don't try to grep ../Makefile if it doesn't exist.
+ * configure: Rebuild.
+
+ * coff-sparc.c (CALC_ADDEND): Don't set the addend to the value of
+ a global symbol.
+
+Tue Sep 5 12:48:26 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * config.bfd: i386pe_ve -> i386pe_vec.
+
+Mon Sep 4 14:02:43 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Incorporate host Makefile fragments by setting
+ shell variables.
+ * configure.in: Call AC_PROG_CC. Substitute CFLAGS, HDEFINES and
+ AR. Call AC_PROG_INSTALL. Substitute CC_FOR_BUILD, choosing a
+ value based on whether the code is being compiled by a cross
+ compiler. Don't substitute host_makefile_frag or frags.
+ * aclocal.m4: New file to define local AC_PROG_CC.
+ * configure: Rebuild.
+ * Makefile.in (INSTALL): Set to @INSTALL@.
+ (INSTALL_PROGRAM): Set to @INSTALL_PROGRAM@.
+ (INSTALL_DATA): Set to @INSTALL_DATA@.
+ (AR): Set to @AR@.
+ (CC): Define as @CC@.
+ (CFLAGS): Set to @CFLAGS@.
+ (CC_FOR_BUILD): Set to @CC_FOR_BUILD@.
+ (@host_makefile_frag@): Remove.
+ (ALL_CFLAGS): Change $(HDEFINES) to @HDEFINES@. Move $(CFLAGS)
+ after other options.
+ (config.status): Remove dependency upon @frags@.
+ * config/*.mh, config/README: Remove.
+
+ * config.bfd: Rewrite to incorporate the contents of the Makefile
+ fragments by setting shell variables, rather than merely returning
+ the name of a Makefile fragment.
+ * configure.in: Use shell variables set by config.bfd rather than
+ looking at the target Makefile fragment files. Don't substitute
+ target_makefile_frag. Do substitute TDEFINES.
+ * configure: Rebuild.
+ * Makefile.in (@target_makefile_frag@): Remove.
+ (ALL_CFLAGS): Change $(TDEFINES) to @TDEFINES@.
+ * config/*.mt: Remove.
+
+Mon Sep 4 03:13:28 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * configure.in: Put changequote lines around "i[345]86" patterns
+ section of core file support.
+
+Sun Sep 3 11:31:58 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_print_private_bfd_data): Define to use the
+ generic version.
+
+Fri Sep 1 17:08:40 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * peicode.h (coff_swap_aouthdr_in): Add ImageBase to
+ entry, text_start and data_start.
+
+Fri Sep 1 18:06:28 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (OFILES): Remove $(TDEPFILES).
+ * config/apollo.mt (TDEPFILES): Remove.
+ * config/README: Update.
+
+ * configure.in: For a native configuration, set COREFILE and
+ COREFLAG based on the canonical host name.
+ * configure: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (ALL_CFLAGS): Add @COREFLAG@.
+ (OFILES): Replace $(HDEPFILES) with @COREFILE@.
+ * coff-rs6000.c: Check AIX_CORE rather than HOST_AIX for core file
+ support routines. Check LYNX_CORE rather than HOST_LYNX.
+ * lynx-core.c: Check LYNX_CORE rather than HOST_LYNX.
+ * i386lynx.c: Likewise.
+ * m68klynx.c: Likewise.
+ * sparclynx.c: Likewise.
+ * rs6000-core.c: Check AIX_CORE rather than HOST_AIX.
+ * *-core.c: Comment changes.
+ * config/decstation.mh (HDEPFILES): Remove.
+ (HDEFINES): Remove -DTRAD_CORE.
+ * config/irix3.mh (RANLIB): Remove.
+ * config/irix4.mh (HDEPFILES, RANLIB): Remove.
+ (HDEFINES): Remove -DIRIX_CORE.
+ * config/riscos.mh (RANLIB, HDEPFILES): Remove.
+ (HDEFINES): Remove -DTRAD_CORE.
+ * config/ncr3000.mh (AR_FLAGS, RANLIB): Remove.
+ * config/ultra3.mh (RANLIB): Remove.
+ * config/aix4.mh, config/alphaosf.mh, config/amix.mh: Remove.
+ * config/apollo.mh, config/delta68.mh, config/delta88.mh: Remove.
+ * config/dpx2.mh, config/esix.mh, config/harris.mh: Remove.
+ * config/hp300.mh, config/hp300bsd.mh, config/hppabsd.mh: Remove.
+ * config/hppahpux.mh, config/hppaosf.mh: Remove.
+ * config/i386aix.mh, config/i386bsd.mh: Remove.
+ * config/i386linux.mh, config/i386mach3.mh: Remove.
+ * config/i386sco.mh, config/i386v.mh, config/i386v4.mh: Remove.
+ * config/irix5.mh, config/m88kmach3.mh, config/mipsbsd.mh: Remove.
+ * config/mipsmach3.mh, config/news-mips.mh: Remove.
+ * config/news.mh, config/pc532mach.mh, config/riscix.mh: Remove.
+ * config/rs600.mh, config/rs6000lynx.mh: Remove.
+ * config/solaris2.mh, config/stratus.mh: Remove.
+ * config/symmetry.mh, config/sysv4.mh, config/tahoe.mh: Remove.
+ * config/vaxbsd.mh, config/vaxult.mh, config/vaxult2.mh: Remove.
+
+Fri Sep 1 15:18:50 1995 Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>
+
+ * elflink.h (elf_bfd_final_link): Don't change a DT_INIT or
+ DT_FINI entry if the appropriate symbol is not in the hash table.
+
+ * libelf.h (struct elf_backend_data): Add create_program_headers
+ and want_hdr_in_seg fields.
+ * elfxx-target.h (elf_backend_want_hdr_in_seg): Define if not
+ defined.
+ (elf_backend_create_program_headers): Likewise.
+ (elfNN_bed): Initialize create_program_headers and
+ want_hdr_in_seg.
+ * elf.c (get_program_header_size): Call create_program_headers
+ backend routine.
+ (map_program_segments): Check want_hdr_in_seg backend field. Call
+ create_program_headers backend routine.
+
+ * elf.c (assign_file_positions_except_relocs): Align non allocated
+ sections when creating an executable.
+
+ * elfcode.h (elf_swap_phdr_in): Make non static.
+ (elf_swap_phdr_out): Make non static.
+ * libelf.h (bfd_elf32_swap_phdr_in): Declare.
+ (bfd_elf32_swap_phdr_out): Declare.
+ (bfd_elf64_swap_phdr_in): Declare.
+ (bfd_elf64_swap_phdr_out): Declare.
+
+ * ecofflink.c (ecoff_collect_shuffle): New static function.
+ (_bfd_ecoff_get_accumulated_pdr): New function.
+ (_bfd_ecoff_get_accumulated_sym): New function.
+ (_bfd_ecoff_get_accumulated_ss): New function.
+ * libbfd-in.h (_bfd_ecoff_get_accumulated_pdr): Declare.
+ (_bfd_ecoff_get_accumulated_sym): Declare.
+ (_bfd_ecoff_get_accumulated_ss): Declare.
+ * libbfd.h: Rebuild.
+
+Fri Sep 1 13:20:25 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libecoff.h (_bfd_ecoff_bfd_print_private_bfd_data): Fix typo.
+
+ * elflink.h (elf_link_add_object_symbols): Handle indirect and
+ warning symbols. If any section is named .gnu.warning.XXX, treat
+ the contents as a warning to be issued if the symbol XXX is
+ referenced.
+ (elf_link_output_extsym): For an indirect or warning symbol, just
+ output the symbol it points to.
+
+ * linker.c (_bfd_link_hash_newfunc): Don't bother to set bfd_error
+ if bfd_hash_allocate fails, since it will already be set.
+ (generic_link_hash_newfunc): Likewise.
+ (archive_hash_newfunc): Likewise.
+ (hash_entry_bfd): New static function.
+ (_bfd_generic_link_add_one_symbol): Pass new arguments to warning
+ callback. Allocate a new warning using the hash table newfunc.
+ Use bfd_hash_replace to update the entry in the hash table, rather
+ than assuming we can copy the fields with structure assignment.
+
+ * hash.c (bfd_hash_replace): New function.
+ * bfd-in.h (bfd_hash_replace): Declare.
+ * bfd-in2.h: Rebuild.
+
+Fri Sep 1 08:12:50 1995 James G. Smith <jsmith@beauty.cygnus.com>
+
+ * config.bfd: Add mips*vr4300-*-elf* target.
+ * config/mipsbvr4300.mt: Added.
+
+Thu Aug 31 16:00:53 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * Makefile.in: Update dependencies.
+ * aout-target.h (MY_bfd_print_private_bfd_data): New.
+ * bfd-in.h (PE STUFF): Deleted.
+ * bfd.c (tdata->pe_obj_data): New.
+ (bfd_print_private_bfd_data): New.
+ * coff-i386.c, coff-arm.c (coff_*-rtype_to_howto): Get image base from
+ new place.
+ * libcoff.h, libbfd.h, bfd-in2.h: Rebuilt.
+ * coffcode.h (pe_value): Delete
+ (coff_mkobject, coff_mkobject_hook): Conditionally build.
+ (coff_compute_section_file_positions): Look in new place.
+ (add_data_entry, fill_pe_header_info): Deleted.
+ (coff_write_object_contents): Remove PE stuff.
+ (coff_bfd_print_private_bfd_data): New.
+ * coffswap.h: Remove PE stuff.
+ * elfxx-target.h (bfd_elfNN_bfd_print_private_bfd_data): New.
+ * libbfd-in.h (_bfd_generic_bfd_print_private_bfd_data): New.
+ * libcoff-in.h (pe_data_type): New.
+ * libecoff.h (_bfd_ecoff_bfd_print_private_bfd_data): New.
+ * targets.c (_bfd_print_private_bfd_data): New.
+ * peicode.h: New file.
+
+Thu Aug 31 11:49:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd-in.h: Add extern "C" if __cplusplus.
+ * bfd-in2.h: Rebuild.
+
+ * coff-mips.c (mips_relocate_section): Don't convert a reloc
+ against an absolute symbol into a reloc against a section.
+
+Thu Aug 31 08:00:14 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coff-arm.c (coff_arm_reloc): Fix common size problem.
+ (i3coff_object_p): Delete.
+
+Wed Aug 30 20:41:27 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coff-arm.c (deletemeacoff_arm_reloc): Deleted.
+ (arm26): Not partial inplace.
+ * coffcode.h (coff_compute_section_file_positions): Don't
+ do page aligning if COFF_PAGE_SIZE isn't defined.
+ * coffswap.h (coff_swap_scnhdr_in): Update image base correctly.
+
+Tue Aug 29 13:50:21 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * coffcode.h (coff_compute_section_file_positions):
+ Compile even if COFF_PAGE_SIZE isn't defined.
+ * cofflink.c (_bfd_coff_generate_reloc_section): Write
+ base file info as rvas.
+ * coff-arm.c (coff_rtype_to_howto): Deal with reloc 11.
+ * coffcode.h (coff_write_object_contents): Remove #if0ed code
+ Only remove empty sections in PE inmage files.
+ * libbfd.h, bfd-in2.h: regenerated.
+ * coff-arm.c (aoutarm_std_relo): New entry at 11.
+ (arm_reloc_type_lookup) : Understand type 11.
+ * coff-i386.c (howto_table): fix name of rva type.
+ (coff-i386_rtype_to_howto): Understand R_IMAGEBASE type.
+ * coffcode.h (sec_to_styp_flags): .edata is data.
+ (coff_compute_section_file_positions): Get page size right for PE.
+ Pagesize info is only valid in PE image files.
+ (fill_pe_header_info): Fix fields.
+ (coff_write_object_contents): Remove end_of_image calc.
+ (_bfd_coff_generate_reloc_section): Remove orphaned comment.
+ * coffswap.h (coff_swap_scnhdr_in): Don't always add IMAGE_BASE.
+ Swap in PE header.
+ (coff_swap_scnhdr_out): Setup PE flags correctly.
+ * reloc.c (BFD_RELOC_RVA): New field.
+
+Thu Aug 24 17:49:59 1995 Ian Lance Taylor (ian@cygnus.com)
+
+ * cofflink.c (coff_link_input_bfd): Don't include line numbers for
+ a section if its output section has no contents.
+
+Wed Aug 23 16:48:52 1995 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff.c (_bfd_ecoff_slurp_symbolic_info): Add parentheses to FIX
+ expression to avoid compiler bug on HP-UX 9.01.
+
+Wed Aug 23 09:49:39 1995 Steve Chamberlain <sac@rtl.cygnus.com>
+
+ * coffcode.h (pe_value): Unansify.
+
+Mon Aug 21 17:49:28 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * bfd-in.h (bfd_link_subsystem): Turn enum into #defines.
+ (bfd_link_pe_info_dval): New
+ (bfd_link_stack_heap): Renamed and massaged into bfd_link_pe_info.
+ * bfd-in2.h: rebuilt.
+ * bfd.c (NT_subsystem, NT_stack_heap): Deleted.
+ * coffcode.h (pe_value): New function.
+ (fill_pe_header_info): New function.
+ (coff_write_object_contents): Use new function.
+ (coff_write_object_contents): Initialze link_data if not set.
+ * cofflink.c (coff_final_link_info): Remove pe randomness.
+ (dores_com): Update info in bfd_link_pe_info_dval.
+ (process_embedded_commands): Use the bfd_link_pe_info_dval.
+ (_bfd_coff_final_link): Remove PE stuff, initialize
+ coff_data->link_info.
+ * coffswap.h (coff_swap_[aout|filehdr]_out): Use indirect PE pointer.
+ (coff_swap_scnhdr_out): Use real imagebase.
+ * libcoff-in.h (coff_data_type.link_info): New field.
+
+Mon Aug 21 11:10:32 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * linker.c (link_action): If an undefined reference follows an
+ undefined weak reference, change the type to undefined.
+ * elflink.h (elf_link_add_archive_symbols): Don't record an
+ undefined weak reference as defined, in case it turns into a real
+ undefined reference later in the same archive.
+
+Thu Aug 17 16:29:09 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ * coff-sh.c (sh_relax_section): Cast value for used_by_bfd field
+ to PTR, not coff_section_tdata pointer, since PTR is the real type
+ of the field.
+ * cofflink.c (_bfd_coff_read_internal_relocs): Ditto.
+
+Thu Aug 17 14:44:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ Add support for linking SPARC SunOS PIC compiled code.
+ * sunos.c (SPARC_PLT_PIC_WORD0): Define.
+ (SPARC_PLT_PIC_WORD1, SPARC_PLT_PIC_WORD2): Define.
+ (struct sunos_link_hash_entry): Add got_offset and plt_offset
+ fields.
+ (struct sunos_link_hash_table): Add dynamic_sections_created and
+ dynamic_sections_needed fields.
+ (sunos_link_hash_newfunc): Initialize new fields.
+ (sunos_link_hash_table_create): Initialize new fields.
+ (sunos_create_dynamic_sections): New static function, broken out
+ of sunos_add_dynamic_symbols.
+ (sunos_add_dynamic_symbols): Call sunos_create_dynamic_sections.
+ (sunos_add_one_symbol): Call sunos_create_dynamic_sections.
+ (bfd_sunos_size_dynamic_sections): Call sunos_scan_relocs before
+ checking whether we need to set up the dynamic link information.
+ Define __GLOBAL_OFFSET_TABLE if anything referred to it.
+ (sunos_scan_std_relocs): Call sunos_create_dynamic_sections. Use
+ plt_offset field; only put symbol in .plt if it is not defined by
+ a regular object.
+ (sunos_scan_ext_relocs): Likewise. Handle base relative relocs.
+ (sunos_scan_dynamic_symbol): Store dynobj in local variable.
+ (sunos_write_dynamic_symbol): Check plt_offset rather than
+ checking whether symbol is in .plt section. If symbol is defined
+ in a regular object file, use SPARC_PLT_PIC_WORD[012], and don't
+ add a JMP_TBL reloc.
+ (sunos_check_dynamic_reloc): Add contents and relocationp fields.
+ If plt_offset is set, redirect relocation to PLT. If this is a
+ base relative reloc, redirect relocation to GOT. Check
+ dynamic_sections_needed field rather than whether dynobj is set.
+ (sunos_finish_dynamic_link): Check dynamic_sections_needed field
+ rather than whether dynobj is set. Don't die if .need and .rules
+ sections were not created.
+ * aoutx.h (howto_table_ext): Mark PC10, PC22, and JMP_TBL entries
+ PC relative. Mark PC10 complain_overflow_dont. Mark PC22 and
+ JMP_TBL complain_overflow_signed.
+ (NAME(aout,final_link)): If info->shared is set, set DYNAMIC.
+ (aout_link_input_section_std): Call check_dynamic_reloc for all
+ relocs. Pass contents and &relocation. Don't warn about an
+ undefined symbol until check_dynamic_reloc has been called. Don't
+ warn about an undefined symbol for a base relative reloc.
+ (aout_link_input_section_ext): Likewise. For a base relative
+ reloc, always treat r_index as an index into the symbol table.
+ * libaout.h (struct aout_backend_data): Add contents and
+ relocation argument to check_dynamic_reloc entry point.
+ (struct aoutdata): Add local_got_offsets field.
+
+Wed Aug 16 01:03:07 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_check_relocs): Fix bug in last change.
+
+Mon Aug 14 11:39:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,machine_type)): Handle a machine of
+ bfd_mach_sparc or bfd_mach_sparc64.
+
+ * elflink.h (elf_link_add_object_symbols): If a symbol is a weak
+ definition, add it to the dynamic symbol table if any dynamic
+ object mentions it. If we do add it, make sure we add the
+ corresponding real symbol.
+ (elf_adjust_dynamic_symbol): Adjust a weak defined symbol which we
+ put in the dynamic symbol table, even if no regular object refers
+ to it.
+ * elf32-i386.c (elf_i386_check_relocs): When creating a shared
+ library, don't allocate space for a PC relative reloc against a
+ local symbol.
+ * elf32-m68k.c (elf_m68k_check_relocs): Likewise.
+ * elf32-sparc.c (elf32_sparc_check_relocs): Likewise.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Change assertion
+ to accept symbol with weakdef set.
+ * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+ * elf32-m68k.c (elf_m68k_relocate_section): When creating a shared
+ libary, don't copy over a PC relative reloc against a local
+ symbol.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+Sun Aug 13 00:40:58 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.h (R_HPPA_BEGIN_BRTAB): Define.
+ (R_HPPA_END_BRTAB): Likewise.
+ * som.c (som_write_fixups): Handle R_BEGIN_BRTAB and R_END_BRTAB.
+
+Thu Aug 10 15:53:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffswap.h (coff_swap_aux_in): Swap the array dimensions
+ whenever x_fcnary is not being used for something else, rather
+ than only for an array.
+ (coff_swap_aux_out): Likewise.
+
+Tue Aug 8 16:34:57 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Remove most
+ of special case stuff for PE. Now handled by relocs.
+ * coff-i386.c (coff_i386_reloc): Special case of PE type 7s.
+ (howto_table): Type 7 is dir32-rva.
+
+Tue Aug 8 10:15:43 1995 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * configure.host: Recognize aix4 explicitly.
+ * rs6000-core.c (CORE_DATA_SIZE_FIELD): New macro to get a the size
+ of a core dump's data section. Provide alternate definition for aix4.
+ (SAVE_FIELD): Similarly for save state field (register info).
+ (STACK_END_ADDR): Provide definition suitable for aix4.
+ * config/{aix4.mh,aix4.mt}: New configuration files.
+ * hosts/aix4.h: Likewise.
+
+Mon Aug 7 23:03:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * som.c (som_bfd_copy_private_symbol_data): Cast initializations
+ to avoid warnings.
+
+Mon Aug 7 14:51:08 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_decode_symclass): Handle absolute symbols by checking
+ the SOM type (since they will rarely if ever be in the absolute
+ section).
+
+Wed Aug 6 09:12:50 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * archures.c (bfd_mach_sparc, bfd_mach_sparc64): Define.
+ * bfd-in2.h: Regenerated.
+ * cpu-sparc.c (sparc_arch_info): Renamed from arch_info_struct.
+ (sparc64_arch_info): New static variable.
+ (bfd_sparc_arch): Link in sparc64_arch_info.
+ * elf64-sparc.c (sparc64_elf_xxx): Renamed from elf64_xxx.
+ (sparc64_elf_object_p): New static function.
+ (elf_backend_object_p): Define.
+ * config/sparc64-elf.mt (SELECT_VECS): Add bfd_elf32_sparc_vec.
+
+Sat Aug 5 00:04:08 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som (som_get_reloc_upper_bound): Return -1 on error. Compute
+ return value with sizeof (arelent *), not sizeof (arelent).
+
+Wed Aug 2 12:32:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (bfd_section_from_shdr): If the section pointed to by the
+ sh_link field of a reloc section is not a symbol table, and the
+ file contains a single symbol table, clobber the sh_link field of
+ the reloc section to point to the symbol table.
+
+Tue Aug 1 10:09:01 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * coff-arm.c (howto reloc ARM26): Change size from 3 to 2.
+ (howto reloc ARM26D): Likewise.
+
+Mon Jul 24 14:17:50 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Use the line just before
+ the offset, not the one just after. Break out of the loop after
+ finding a function past the offset, not merely when finding a
+ function with a line defined.
+
+ * ecofflink.c (_bfd_ecoff_locate_line): When handling stabs:
+ correct setting of sym_ptr_end to consider symbols skipped when
+ setting sym_ptr; don't leave loop early unless an N_FUN is found
+ with a larger value.
+
+ * coff-sh.c (sh_coff_howtos): Mark R_SH_PCDISP8BY2 and R_SH_PCDISP
+ as PC relative. Describe R_SH_IMM16. Add entries for
+ R_SH_SWITCH16, R_SH_SWITCH32, R_SH_USES, R_SH_COUNT, and
+ R_SH_ALIGN.
+ (SWAP_IN_RELOC_OFFSET): Define.
+ (SWAP_OUT_RELOC_OFFSET): Define.
+ (CALC_ADDEND): Define.
+ (sh_reloc): Change sym_value and addr to type bfd_vma. Skip reloc
+ types other than R_SH_IMM32 and R_SH_PCDISP on an external symbol.
+ (coff_bfd_relax_section): Define.
+ (coff_bfd_get_relocated_section_contents): Define.
+ (sh_relax_section): New static function.
+ (sh_relax_delete_bytes): New static function.
+ (sh_relocate_section): Handle R_SH_PCDISP on an external symbol.
+ (sh_coff_get_relocated_section_contents): New static function.
+
+ * cofflink.c (coff_link_add_object_symbols): Call
+ _bfd_coff_get_external_symbols, not coff_link_get_symbols. Call
+ _bfd_coff_free_symbols, not coff_link_free_symbols. Call
+ _bfd_coff_read_string_table, not coff_read_string_table.
+ (coff_link_check_archive_element): Likewise.
+ (coff_link_input_bfd): Likewise.
+ (coff_link_get_symbols): Move to coffgen.c.
+ (coff_read_string_table): Likewise.
+ (coff_link_free_symbols): Likewise.
+ (_bfd_coff_internal_syment_name): New static function.
+ (coff_link_check_ar_symbols): Use _bfd_coff_internal_syment_name.
+ (coff_link_add_symbols): Likewise.
+ (coff_link_input_bfd): Likewise.
+ (_bfd_coff_generic_relocate_section): Likewise.
+ (_bfd_coff_read_internal_relocs): New function.
+ (coff_link_input_bfd): Use cached section contents if available.
+ Use _bfd_coff_read_internal_relocs.
+ * coffcode.h (coff_slurp_symbol_table): Don't call bfd_seek.
+ (coff_bfd_get_relocated_section_contents): Only define if not
+ already defined.
+ (coff_bfd_relax_section): Likewise.
+ * coffgen.c (build_string_table): Remove.
+ (_bfd_coff_get_external_symbols): New function, moved in from old
+ coff_link_get_symbols in cofflink.c.
+ (_bfd_coff_read_string_table): New function, moved in from old
+ coff_read_string_table in cofflink.c.
+ (_bfd_coff_free_symbols): New function, moved in frmo old
+ coff_link_free_symbols in cofflink.c.
+ (coff_get_normalized_symtab): Use _bfd_coff_get_external_symbols
+ rather than reading the symbols directly. To free them, call
+ _bfd_coff_free_symbols. Use _bfd_coff_read_string_table rather
+ than build_string_table.
+ * libcoff-in.h (obj_coff_keep_syms): Define.
+ (obj_coff_keep_strings): Define.
+ (coff_data_type): Add fields keep_syms and keep_strings.
+ (coff_section_tdata): Define new structure.
+ (coff_section_data): Define.
+ (_bfd_coff_get_external_symbols): Declare.
+ (_bfd_coff_read_string_table): Declare.
+ (_bfd_coff_free_symbols): Declare.
+ (_bfd_coff_read_internal_relocs): Declare.
+ * libcoff.h: Rebuild.
+
+Fri Jul 21 22:32:54 1995 Michael Meissner <meissner@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_howto_raw): Add support for R_PPC_SDAREL
+ relocation.
+ (ppc_elf_reloc_type_lookup): Ditto.
+ (ppc_elf_got16_inner): Ditto.
+ (ppc_elf_relocate_section): Ditto.
+
+Thu Jul 20 19:19:06 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (hppa_elf_gen_reloc_type): Add new (ignored)
+ argument.
+ * elf32-hppa.h: Corresponding change.
+
+Thu Jul 20 19:01:07 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * libaout.h (set_aout_section_data): New macro.
+ * sunos.c (sunos_scan_relocs): Use it.
+
+ * aout-ns32k.c (MY_swap_std_reloc_out): Undef KEEPIT before
+ defining it.
+
+Thu Jul 20 13:48:00 1995 Fred Fish <fnf@cygnus.com>
+
+ * hosts/i386v4.h (getgid, getuid): Change prototypes to be
+ compatible with Unixware 1.x and Unixware 2.x, and probably other
+ i386 svr4 versions as well.
+
+Thu Jul 20 13:41:21 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * targets.c (bfd_target_vector): Since armpe and armpei have been
+ split into big- and little-endian variants, list all of them,
+ instead of the now-nonexistant armpe[i]_vec.
+
+Thu Jul 20 00:06:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (bfd_section_from_phdr): Set lma based on p_paddr.
+ (elf_fake_sections): Set sh_addr based on lma, not vma.
+
+Wed Jul 19 15:52:01 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * coff-arm.c (TARGET_LITTLE_SYM, TARGET_BIG_SYM): Replaces TARGET_SYM.
+ * configure.in (armpe_vec, armpei_vec): Add bi-endian support.
+ * configure: "regenerated".
+ * pe-arm.c (TARGET_LITTLE_SYM, TARGET_BIG_SYM): Replaces TARGET_SYM.
+ (TARGET_LITTLE_NAME, TARGET_BIG_NAME): Replaces TARGET_NAME.
+ * pei-arm.c (TARGET_LITTLE_SYM, TARGET_BIG_SYM): Replaces TARGET_SYM.
+ (TARGET_LITTLE_NAME, TARGET_BIG_NAME): Replaces TARGET_NAME.
+ * targets.c (armpe_vec, armpei_vec): Deleted.
+ (armpe_little_vec, armpe_big_vec, armpei_little_vec, armpei_big_vec):
+ Added.
+ * config/arm-pe.mt (DEFAULT_VECTOR): Default is armpe_little_vec.
+ (SELECT_VECS): Add bi-endian support.
+
+Wed Jul 19 10:47:25 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c: Clean up and comment.
+ (r_imm32): Remove.
+ (sh_coff_howtos): New static array.
+ (SH_COFF_HOWTO_COUNT): Define.
+ (get_symbol_value): Make relocation bfd_vma rather than long.
+ (RTYPE2HOWTO): Rewrite to use sh_coff_howtos.
+ (coff_relocate_section): Define to sh_relocate_section.
+ (sh_relocate_section): New static function.
+
+Sat Jul 15 01:02:53 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.host: Add support for generic m68k SVR4 host.
+
+Fri Jul 14 13:13:55 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (KEEPIT): Change definition to udata.i.
+ (KEEPITTYPE): Remove.
+ (NAME(aout,reloc_type_lookup)): Add cases to the
+ extended reloc type switch: SPARC_GOT10, SPARC_GOT13, SPARC_GOT22,
+ SPARC_PC10, SPARC_PC22, SPARC_WPLT30.
+ (NAME(aout,swap_std_reloc_out)): Don't bother to use stoi when
+ retrieving KEEPIT value.
+ (NAME(aout,swap_ext_reloc_out)): Likewise. Also, only add in
+ output section VMA for section symbols, and check BSF_SECTION_SYM
+ to control whether to set r_extern to 1.
+
+ * syms.c: Fix comments so that `make info' works.
+
+ * elf32-mips.c (mips_elf_find_nearest_line): Set SEC_HAS_CONTENTS
+ in .mdebug section, in case backend linker has cleared it.
+
+Fri Jul 14 11:58:34 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_addr16_ha_inner): Rewrite to take just one
+ argument, the final relocated address.
+ (ppc_elf_addr16_ha_inner): Adjust ppc_elf_addr16_ha_inner caller.
+ (ppc_elf_relocate_section): Ditto.
+
+Thu Jul 13 17:22:03 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (hppa_som_gen_reloc_type): Choose a reasonable field
+ selector relocation for the difference of two symbols.
+
+Thu Jul 13 10:33:25 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,slurp_reloc_table)): Cast argument to size_t
+ for malloc.
+ * coff-mips.c (mips_relocate_section): Likewise, for memmove.
+ (mips_relax_section): Likewise, for malloc.
+ * cofflink.c (process_embedded_commands): Likewise.
+ (_bfd_coff_final_link): Likewise.
+ * ecoff.c (_bfd_ecoff_write_object_contents): Likewise.
+ (ecoff_final_link_debug_accumulate): Likewise.
+ (ecoff_indirect_link_order): Likewise, for memcpy and malloc.
+ (ecoff_reloc_link_order): Likewise, for malloc.
+ * ecofflink.c (ecoff_align_debug): Likewise, for memset.
+ (ecoff_write_symhdr): Likewise, for malloc.
+ * elf32-hppa.c (elf32_hppa_read_symext_info): Likewise.
+ * elf.c (assign_file_positions_except_relocs): Likewise, for
+ qsort.
+ * elf32-mips.c (mips_elf_read_ecoff_info): Likewise, for malloc.
+ * elfcode.h (elf_slurp_reloc_table): Likewise.
+ * elfcore.h (elf_corefile_note): Likewise.
+ * elflink.h (elf_link_add_object_symbols): Likewise.
+ (elf_link_read_relocs): Likewise.
+ (NAME(bfd_elf,size_dynamic_sections)): Likewise, for memset.
+ * i386linux.c (bfd_linux_size_dynamic_sections): Likewise.
+ * ieee.c (do_with_relocs): Likewise.
+ * linker.c (default_indirect_link_order): Likewise, for malloc.
+ * nlmcode.h (nlm_object_p): Likewise.
+ (nlm_write_object_contents): Likewise.
+ * oasys.c (oasys_set_section_contents): Likewise, for memcpy.
+ * reloc.c (bfd_generic_get_relocated_section_contents): Likewise,
+ for malloc.
+ * section.c (bfd_get_section_contents): Likewise, for memcpy.
+ * srec.c (srec_get_section_contents): Likewise.
+ (srec_set_section_contents): Likewise.
+ * sunos.c (bfd_sunos_size_dynamic_sections): Likewise, for
+ realloc and memset.
+ (sunos_scan_relocs): Likewise, for malloc.
+ (sunos_scan_dynamic_symbol): Likewise, for realloc.
+ * syms.c (_bfd_generic_read_minisymbols): Likewise, for malloc.
+ * versados.c (versados_get_section_contents): Likewise, for
+ memcpy.
+
+ * libbfd.c (real_read): Add prototype. Change argument types from
+ int to size_t.
+ (bfd_read): Cast real_read argument to size_t, not int.
+ (bfd_write): Cast fwrite argument to size_t, not int.
+
+ * elf64-gen.c (elf_info_to_howto): Fix definition for recent elf.c
+ changes.
+
+ * configure.in: Fix typo: change {$enableval} to ${enableval}.
+ * configure: Rebuild.
+
+ * Makefile.in (BFD32_BACKENDS): Add elflink.o.
+
+ * targets.c (bfd_target): Add fields _read_minisymbols and
+ _minisymbol_to_symbol.
+ (BFD_JUMP_TABLE_SYMBOLS): Add _read_minisymbols and
+ _minisymbol_to_symbol.
+ (bfd_read_minisymbols): Define.
+ (bfd_minisymbol_to_symbol): Define.
+ * syms.c (_bfd_generic_read_minisymbols): Define.
+ (_bfd_generic_minisymbol_to_symbol): Define.
+ * libbfd-in.h (_bfd_nosymbols_read_minisymbols): Define.
+ (_bfd_nosymbols_minisymbol_to_symbol): Define.
+ (_bfd_generic_read_minisymbols): Declare.
+ (_bfd_generic_minisymbol_to_symbol): Declare.
+ * bfd-in2.h: Rebuild.
+ * libbfd.h: Rebuild.
+ * aoutx.h (MINISYM_THRESHOLD): Define.
+ (NAME(aout,read_minisymbols)): New function.
+ (NAME(aout,minisymbol_to_symbol)): New function.
+ * libaout.h (NAME(aout,read_minisymbols)): Declare.
+ (NAME(aout,minisymbol_to_symbol)): Declare.
+ * aout-target.h (MY_read_minisymbols): Define.
+ (MY_minisymbol_to_symbol): Define.
+ * All targets: Define read_minisymbols and minisymbol_to_symbol.
+
+Wed Jul 12 17:55:55 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Cast return value from
+ bfd_alloc.
+
+ * elfcode.h (size_info): Don't use "&" before function names.
+
+Wed Jul 12 00:16:48 1995 Ken Raeburn <raeburn@kr-pc.cygnus.com>
+
+ * libelf.h (elf_backend_data): Use unsigned, not unsigned char,
+ for bitfields.
+
+Tue Jul 11 15:19:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (bfd_section_from_shdr): In case SHT_REL[A], only get the
+ BFD section for the sh_link section if it is a SYMTAB section.
+
+ * aoutx.h (NAME(aout,link_add_symbols)): Don't bother to check
+ that archives hold a.out objects.
+ * cf-i386lynx.c (coff_bfd_link_add_symbols): Don't define.
+ (lynx_link_add_symbols): Remove.
+ * cf-m68klynx.c (coff_bfd_link_add_symbols): Don't define.
+ (lynx_link_add_symbols): Remove.
+ * elflink.h (elf_bfd_link_add_symbols): Don't bother to check that
+ archives hold ELF objects.
+
+ * archive.c (bfd_generic_archive_p): If the archive has a map, and
+ the target was defaulted, but the first object in the archive can
+ not be matched with that target, then return a bad format error.
+
+ * elf64-sparc.c (elf_sparc_howto_table): Set howto for WDISP16 to
+ elf64_wdisp16_reloc.
+ (elf64_wdisp16_reloc): New static function.
+ (elf64_sparc_relocate_section): New static function.
+ (elf_backend_relocate_section): Define.
+
+ * libelf.h (struct elf_size_info): Change type of last argument to
+ swap_symbol_out from char * to PTR.
+ (bfd_elf32_swap_symbol_out): Update declaration.
+ (bfd_elf64_swap_symbol_out): Likewise.
+ * elfcode.h (elf_swap_symbol_out): Change type of cdst from char *
+ to PTR.
+ * elf.c (swap_out_syms): Cast to PTR, not char *, when calling
+ swap_symbol_out routine.
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Likewise.
+ (elf_link_output_sym): Likewise.
+ (elf_link_output_extsym): Likewise.
+ * elf32-sparc.c (elf32_sparc_finish_dynamic_sections): Likewise.
+
+Tue Jul 11 12:29:49 1995 Rick Sladkey <jrs@world.std.com>
+
+ * elf.c (_bfd_elf_find_nearest_line): Handle the simple case where
+ there is no debugging information.
+
+Mon Jul 10 11:45:55 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * makefile.dos (OBJS): Add binary.o and tekhex.o. From DJ
+ Delorie.
+
+Mon Jul 10 11:09:58 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * linker.c (set_symbol_from_hash): bfd_link_hash_new case: Don't
+ abort; it can happen for constructor symbols when not building
+ constructors.
+
+ * coff-i960.c (coff_i960_relocate): Correct typo: use ! on strcmp,
+ not on string.
+ * cofflink.c (_bfd_coff_generic_relocate_section): Remove unused
+ local i.
+ * coff-arm.c (coff_arm_rtype_to_howto): Don't declare.
+ (PCRELOFFSET): Define if not already defined.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add coff-arm.o
+ (CFILES): Add coff-arm.c, pe-arm.c, pei-arm.c.
+
+ * aoutx.h (NAME(aout,link_hash_table_create)): Allocate hash table
+ using bfd_alloc, not malloc.
+ * cofflink.c (_bfd_coff_link_hash_table_create): Likewise.
+ * ecoff.c (_bfd_ecoff_bfd_link_hash_table_create): Likewise.
+ * i386linux.c (linux_link_hash_table_create): Likewise.
+ * linker.c (_bfd_generic_link_hash_table_create): Likewise.
+ * sunos.c (sunos_link_hash_table_create): Likewise.
+
+ Based on patches from Eric Youngdale <eric@aib.com>:
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): If -Bsymbolic,
+ output a DT_SYMBOLIC dynamic entry.
+ (elf_adjust_dynamic_symbol): If -Bsymbolic, don't require a PLT
+ entry for a locally defined symbol.
+ * elf32-i386.c (elf_i386_relocate_section): If -Bsymbolic, do warn
+ about undefined symbols, and fill in the GOT entry for a symbol
+ defined in a regular object file.
+ (elf_i386_finish_dynamic_symbol): If -Bsymbolic, output a RELATIVE
+ reloc rather than a GLOB_DAT reloc for a symbol defined in a
+ regular object file.
+ * elf32-m68k.c (elf_m68k_relocate_section): If -Bsymbolic, do warn
+ about undefined symbols, and fill in the GOT entry for a symbol
+ defined in a regular object file.
+ (elf_m68k_finish_dynamic_symbol): If -Bsymbolic, output a RELATIVE
+ reloc rather than a GLOB_DAT reloc for a symbol defined in a
+ regular object file.
+ * elf32-sparc.c (elf32_sparc_relocate_section): If -Bsymbolic, do
+ warn about undefined symbols, and fill in the GOT entry for a
+ symbol defined in a regular object file.
+ (elf32_sparc_finish_dynamic_symbol): If -Bsymbolic, output a
+ RELATIVE reloc rather than a GLOB_DAT reloc for a symbol defined
+ in a regular object file.
+
+ * config/m68k-coff.mt (SELECT_VECS): Rename from SELECT_VECTORS.
+ Correct elements to be actual BFD vector names.
+
+ * Makefile.in (Makefile): Don't depend upon @frags@.
+ (config.status): Depend upon @frags@.
+
+Fri Jul 7 17:36:44 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffgen.c (coff_renumber_symbols): Sort defined symbols that are
+ neither BSF_FUNCTION not BSF_NOT_AT_END just before undefined
+ symbols.
+ * coffcode.h (coff_slurp_symbol_table): Set BSF_FUNCTION as well
+ as BSF_NOT_AT_END.
+
+Fri Jul 7 17:16:15 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * Makefile.in (do_mostlyclean): Remove config.log.
+ (do_distclean): Remove config.cache.
+
+Thu Jul 6 14:37:43 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): Revert May 24 patch.
+ Don't copy PC32 reloc against section into shared object.
+
+ * Makefile.in: Rebuild dependencies.
+ (CFILES): Added elflink.c.
+ (Makefile): Depend upon config.status, not configure.in.
+ (config.status): New target; depend upon configure configure.host
+ and config.bfd.
+
+Wed Jul 5 20:17:14 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * elfcore.h, elflink.h, elfcode.h, elf.c, elflink.c: Moved some
+ primarily size-independent code from elfcode.h to elf.c and new
+ file elflink.c; moved out other core- or linker-related routines
+ into other new .h files for clarity. Renamed many routines to
+ start with bfd_elf or _bfd_elf. Added a structure of
+ size-dependent but target-independent info to elfcode.h.
+ * Makefile.in: Build elflink.o. Update dependencies.
+ * libelf.h: Updated some declarations. Added a definition for the
+ new structure in elfcode.h. Added more fields to elf backend data
+ structure.
+ * elfxx-target.h: Refer to the appropriate size-dependent info.
+ * elf32-*.c: Changed some function names. Moved common
+ create_dynamic_sections code from m68k, sparc, and i386 support
+ into elflink.c. Define some new macros to fill in new fields of
+ back end data. Also clean up some "gcc -Wall" warnings regarding
+ unused or uninitialized variables.
+
+ * Makefile.in (BFD_LIBS): No, don't put elflink.o here.
+ * configure.in: Include it here whenever elf.o is specified.
+
+Wed Jul 5 10:31:47 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_object_p): Unconditionally set
+ elf_bad_symtab, since sometimes the symbol table is messed up and
+ the last symbol is global.
+
+ * ecoff.c (_bfd_ecoff_bfd_is_local_label): New function.
+ * libecoff.h (_bfd_ecoff_bfd_is_local_label): Declare.
+ * elf32-mips.c (mips_elf_is_local_label): New static function.
+ (bfd_elf32_bfd_is_local_label): Define.
+
+ * configure.in: Use $ac_config_sub, not $configsub.
+ * configure: Likewise.
+
+ Permit --enable-targets=ieee:
+ * config.bfd (*-*-ieee*): New target.
+ * config/ieee.mt: New file.
+
+Wed Jul 5 04:16:35 1995 Ken Raeburn <raeburn@kr-pc.cygnus.com>
+
+ * config/i386aix.mh (HDEFINES): Remove -DFASCIST_FDOPEN.
+
+ Autoconfiscation:
+ * configure.in, Makefile.in, doc/Makefile.in: Switch from Cygnus
+ configure to autoconf ways of processing --enable arguments,
+ setting up symlinks, incorporating makefile fragments, printing
+ messages at configuration time, setting variables in Makefile.
+ Deleted some unused variables. Check for ranlib via autoconf.
+ For now, configure script removes doc/config.status.
+ * configure: New file.
+ * dep-in.sed: Use @SRCDIR@ instead of @srcdir@, so Makefile.in
+ line doesn't get broken by configure.
+ * doc/configure.in: Removed.
+
+Tue Jul 4 12:22:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * archive.c (_bfd_construct_extended_name_table): If
+ BFD_TRADITIONAL_FORMAT is set, limit the length of all file names
+ to ar_max_namelen.
+ (bfd_dont_truncate_arname): If BFD_TRADITIONAL_FORMAT is set, call
+ bfd_bsd_truncate_arname.
+ (_bfd_write_archive_contents): Revert June 1 change.
+
+ * elfcode.h (NAME(bfd_elf,record_link_assignment)): Add provide
+ argument.
+ * bfd-in.h (bfd_elf32_record_link_assignment): Update prototype.
+ (bfd_elf64_record_link_assignment): Likewise.
+ * bfd-in2.h: Rebuild.
+
+ * libelf.h (struct elf_link_hash_table): Add needed field. Remove
+ saw_needed field.
+ * elfcode.h (elf_link_add_object_symbols): If elf_dt_needed_name
+ is an empty string, don't make a DT_NEEDED entry in the output
+ file. Record all DT_NEEDED entries found in input dynamic
+ objects.
+ (elf_link_output_extsym): Don't check saw_needed when issuing
+ warnings.
+ * elf.c (_bfd_elf_link_hash_table_init): Initialize needed, not
+ saw_needed.
+ (bfd_elf_get_needed_list): New function.
+ * bfd-in.h (struct bfd_elf_link_needed_list): Define.
+ (bfd_elf_get_needed_list): Define.
+ * bfd-in2.h: Rebuild.
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): Also initialize
+ find_buffer and fdrtab_len fields of newly allocated
+ find_line_info structure.
+
+Mon Jul 3 17:03:52 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (hppa_som_gen_reloc_type): New argument "sym_diff",
+ nonzero when we're generating relocations for an expression
+ using the difference of two symbols. All callers changed.
+ Handle difference of symbols for both R_HPPA and R_COMPLEX
+ cases.
+ (som_write_fixups): Handle R_COMP1, R_COMP2 and R_CODE_EXPR
+ fixups.
+
+Mon Jul 3 13:55:18 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * config.bfd (win32): New configuration.
+ * configure.host (pe): Changed to i386win32.
+ * config/i386pe.mh: Deleted.
+ * config/i386win32.mh: New file.
+
+Mon Jul 3 11:30:45 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): If we allocate
+ find_line_info, clear the fdrtab field.
+
+ * targets.c (enum bfd_flavour): Add bfd_target_msdos_flavour here,
+ rather than in bfd-in2.h.
+
+ * bfd.c (enum bfd_error): Define bfd_error_no_armap.
+ (bfd_errmsgs): Add string for bfd_error_no_armap.
+ * bfd-in2.h: Rebuild.
+ * ecoff.c (ecoff_link_add_archive_symbols): If an archive has no
+ armap, set bfd_error_no_armap rather than bfd_error_no_symbols.
+ * elfcode.h (elf_link_add_archive_symbols): Likewise.
+ * linker.c (_bfd_generic_link_add_archive_symbols): Likewise.
+
+ * elfcode.h (elf_link_add_object_symbols): Permit common and
+ indirect symbols in weakdefs BFD_ASSERT.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Simplify
+ BFD_ASSERT to permit some legal, but odd, cases.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+ * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
+
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add versados.o.
+ (CFILES): Add pe-i386.c, pei-i386.c, and versados.c.
+
+Sun Jul 2 17:49:32 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Cast base_file
+ to FILE * before using it.
+ * stab-syms.c: Revert yesterday's patch.
+
+Sat Jul 1 12:10:42 1995 Fred Fish <fnf@cygnus.com>
+
+ * stab-syms.c (stdio.h): Include prior to libaout.h, which
+ includes bfdlink.h, which now uses FILE.
+
+Sat Jul 1 00:11:08 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * elfxx-target.h: New file.
+
+ * libelf.h (struct elf_backend_data): Remove elf_64_p field.
+ * elfxx-target.h (elfNN_bed): Don't set it.
+
+ * elf32-target.h, elf64-target.h: Deleted.
+ * Makefile.in (elf32-target.h, elf64-target.h): Build them from
+ elfxx-target.h.
+
+Fri Jun 30 16:07:18 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Compare
+ the full text of .reloc or .edata section names.
+
+Fri Jun 30 15:47:37 1995 Fred Fish <fnf@cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section):
+ Remove extra '+'.
+
+Thu Jun 29 17:24:52 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * coff-h8300.c (COFF_LONG_FILENAMES): Define.
+
+Wed Jun 28 18:04:42 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * Makefile.in: versados.o is now conditionally built.
+ * coffcode.h (add_data_entry): New function.
+ (coff_write_object_contents): Clean up. Calculate
+ data entries.
+ * cofflink.c (_bfd_coff_generic_relocate_section):
+ .reloc and .edata sections are IMAGE_BASED too.
+ If there's a base_file then write out base information.
+ * configure.host (i386-*-pe): New.
+ * syms.c (coff_section_type): Only scan prefixes.
+ * targets.c (bfd_target_vector): Versados is now conditionally
+ built.
+ * config/m68k-coff.mt: Build versados.o
+ * hosts/i386pe.h: New file.
+
+Mon Jun 26 13:53:49 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hpa.c (elf32_hppa_relocate_section): Close comment before
+ R_PARISC_DPREL21L handling.
+
+Thu Jun 22 19:28:36 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Sun May 7 11:53:41 MDT 1995 Bryan Ford <baford@cs.utah.edu>
+
+ * config/i386-moss.mt: created.
+
+Thu Jun 22 08:56:10 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * reloc.c (bfd_perform_relocation): Add case for -ve words.
+
+Wed Jun 21 13:13:49 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_relocate_section): Don't try to apply a
+ relocation against an undefined symbols.
+
+Wed Jun 21 10:16:10 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * versados.c: Second pass/rewrite.
+
+Mon Jun 19 08:40:45 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * syms.c (coff_section_type): Compare only the front part
+ of a section name.
+
+Sat Jun 17 09:40:44 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_size_stubs): Set the size of the stub
+ section if we get an error.
+
+ * elf32-hppa.c (elf32_hppa_bfd_final_link_relocate): Don't mess
+ with the operands of an R_PARISC_DPREL21L relocation if the insn
+ is not "addil <symbol>,%r27".
+
+Fri Jun 16 15:04:47 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * bfd-in.h (NT_subsystem, NT_stack_heap): Declare but don't
+ define.
+ * bfd-in2.h: Rebuilt.
+ * bfd.c (NT_subsystem, NT_stack_heap): Define.
+
+Fri Jun 16 00:07:25 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_bfd_link_link_relocate): Use the right
+ type field (there are two!) when checking to see if $global$ is
+ defined.
+
+Thu Jun 15 14:03:47 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * bfd-in.h, bfd-in2.h (bfd_boolean): Rename bfd_true, bfd_false
+ to bfd_tttrue, bfd_fffalse so as not to conflict with functions.
+ * coffswap.h (coff_swap_scnhdr_out): Remove version that was
+ hacked for MPW C.
+ * mpw-config.in: Set shell vars instead of pasting to makefile
+ for each configuration, edit coffswap.h to make MPW C not choke.
+ (i386-unknown-coff, sh-hitachi-hms): Recognize.
+ * mpw-make.in (BFD_LIBS): Add versados.c.o.
+
+ * versados.c (versados_scan): Properly cast results from bfd_alloc.
+
+Wed Jun 14 15:27:32 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * cofflink.c (process_embedded_commands): New function
+ reads and handles .drectve sections for PE.
+ (coff_link_input_bfd): Call new function if PE.
+
+Mon Jun 12 12:09:39 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * bfd-in.h (bfd_set_section_vma): Case true to a boolean.
+ (bfd_set_cacheable): Likewise.
+ * bfd-in2.h: Rebuilt.
+
+Fri Jun 9 12:20:28 1995 Steve Chamberlain <sac@rtl.cygnus.com>
+
+ * elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical.
+
+Fri Jun 9 12:49:00 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * targets.c: Add copy_private_symbol_data and link_split_section
+ to the target vector.
+ * libbfd-in.h (_bfd_generic_bfd_copy_private_symbol_data): Define.
+ (_bfd_nolink_bfd_link_split_section): Likewise.
+ (bfd_generic_link_split_section): Declare.
+ * syms.c (bfd_copy_private_symbol_data): Define.
+ * linker.c (bf_link_split_section): Likewise.
+ * som.c (som_bfd_copy_private_symbol_data): New function
+ (som_bfd_link_split_section): Likewise.
+ * All other targets updated with default versions of new routines.
+
+ * Take out my braindamaged bfd_true/bfd_false changes from earlier
+ today. Replace with just:
+ * bfd-in.h: (TRUE_FALSE_ALREADY_DEFINED): Define this if
+ compiling with g++-2.6 or later.
+ * bfd-in2.h: Rebuilt.
+
+Fri Jun 9 07:54:29 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * versados.c (struct esd, get_4): Lint; use unsigned chars.
+
+ * coff-i960.c (coff_i960_relocate): Compare output section names
+ when converting for vxworks.
+
+Wed Jun 7 19:01:30 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * elfcode.h (elf_fake_sections): Permit .scommon or COMMON
+ sections as random SHT_NOBITS sections, in case a linker script is
+ strange.
+
+Tue Jun 6 17:29:32 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * bfd-in.h (NT_subsystem, NT_stack_heap): Moved from pe.h
+ * coff-i386.c (coff_i386_rtype_to_howto): Get PE relocs right.
+ * coffcode.h (coff_mkobject): Set pe tdata bit when using PE.
+ * cofflink.c (COFF_WITH_PE code): Test on obj_pe bit rather
+ than conditional compile.
+ * configure.in: Fix PE dependencies.
+ * libcoff-in.h (obj_pe): New.
+ (coff_tdata): Added pe entry.
+ * libcoff.h: Regenerated.
+
+Mon Jun 5 09:07:13 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * coff-a29k.c (coff_a29k_adjust_symndx): Completely parenthesize
+ macro.
+
+Mon Jun 5 02:15:20 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Linker support for m68k-elf from Andreas Schwab
+ <schwab@issan.informatik.uni-dortmund.de>:
+ * elfcode.h (elf_link_add_object_symbols): Check for NULL when
+ looping through the symbol hashes.
+ (elf_bfd_final_link): When looking for _init and _fini don't use
+ the symbol if it is imported from another object.
+ * elf32-m68k.c: Relocation type changed from REL to RELA. Regular
+ and dynamic linking support functions added, similar to other elf
+ targets.
+
+ * config.bfd (i[345]86-*-gnu*): Use ELF configuration.
+
+Fri Jun 2 18:54:59 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * versados.c: New file.
+ * bfd-in2.h (struct _bfd): New field.
+ * bfd.c (struct _bfd): New field.
+ * configure.in (versados_vec): New field.
+ * targets.c (bfd_flavor): Added versados.
+
+Thu Jun 1 13:51:49 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * coffcode.h (sec_to_styp_flags, styp_to_sec_flags,
+ coff_new_section_hook): Any section that starts ".stab"
+ is now marked as debugging.
+
+Thu Jun 1 16:15:16 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * archive.c (_bfd_write_archive_contents): Disable extended name
+ table until it can be made optional, so that native AR has half a
+ chance on SunOS and HP/UX.
+
+ * linker.c (_bfd_generic_link_output_symbols, case
+ bfd_link_hash_indirect): Add cast to correct pointer types.
+
+Sat May 27 21:37:31 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * config.bfd (m68k-bull-sysv*): Added strip_underscore=yes.
+ (m68k-est-coff): Removed. target does not effect object format.
+
+Wed May 24 10:52:01 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * linker.c (_bfd_generic_link_output_symbols): Cope with
+ indirect symbols.
+
+ * elf32-i386.c (elf_i386_relocate_section): Give error
+ message when linking to a shared reloc which isn't there.
+
+Wed May 24 10:40:00 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ Support for ARM-PE.
+
+ * Makefile.in, coffcode.h, config.bfd, configure.in, pe-arm.c,
+ pei-arm.c, coff-arm.c, reloc.c, targets.c, config/arm-pe.mt:
+ Support for ARM COFF/PE.
+
+Tue May 23 19:24:58 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * bfd.c (bfd_get_relocated_section_contents): Now a function,
+ tries calling routine from input bfd target vector for
+ bfd_indirect_link_order. Put a declaration into the header file.
+ * bfd-in2.h: Regenerated.
+ * elf32-mips.c (gprel16_with_gp): New function, split out from
+ mips_elf_gprel16_reloc.
+ (mips_elf_gprel16_reloc): Call it. If output bfd target vector
+ isn't elf flavoured, abort, since it's assumed to be elf in some
+ of this code, including the code that looks up the gp value.
+ (elf32_mips_get_relocated_section_contents): New function,
+ modified from bfd_generic_get_relocated_section_contents to deal
+ with passing gp to gprel16_with_gp.
+ (bfd_elf32_bfd_get_relocated_section_contents): New macro.
+ * elf32-target.h (bfd_elf32_bfd_get_relocated_section_contents):
+ Don't define if already defined.
+
+Tue May 23 15:58:15 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * Makefile.in: Install bfdlink.h too.
+
+Sun May 21 22:25:09 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_relocate_section): Handle undefined and
+ notsupported return codes from final_link_relocate (used when
+ $global$ is undefined or nonexistant).
+ (elf32_hppa_bfd_link_link_relocate): If $global$ exists, but is
+ not defined,then return bfd_reloc_undefined.
+
+Fri May 19 10:00:14 1995 Steve Chamberlain <sac@rtl.cygnus.com>
+
+ * coffswap.h: (IMAGE_BASE): Define to 0 if not.
+
+Thu May 18 04:24:01 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
+
+ * aoutx.h (aout_link_input_section_standard): If defined, call
+ MY_relocatable_reloc before doing a partial relocation.
+
+ * aout-arm.c: (WRITE_HEADERS): Delete.
+ (NAME): Define version to override default in aoutx.h
+ (MY(howto_table)): Reformat. Alter some entries slightly.
+ (RELOC_ARM_BITS_NEG_{BIG,LITTLE}): Define.
+ (MY(reloc_howto), MY(put_reloc), MY(relocatable_reloc)): New functions.
+ (MY_reloc_howto, MY_put_reloc, MY_relocatable_reloc): Define.
+ (MY(fix_pcrel_26)): Renamed from aoutarm_fix_pcrel_26, return
+ bfd_reloc_ok not bfd_reloc_continue.
+ (MY(fix_pcrel_26_done)): Likewise.
+ (MY(bfd_reloc_type_lookup)): Renamed from aoutarm_reloc_type_lookup.
+ (MY_bfd_link_hash_table_create, MY_bfd_link_add_symbols,
+ MY_bfd_final_link): Delete.
+ (MY_swap_std_reloc_in, MY_swap_std_reloc_out, MY_get_section_contents):
+ Define.
+ (aoutx.h): Include it.
+ (MY(swap_std_reloc_{in,out})): New functions.
+ Use RELOC_ARM_BITS_NEG_{BIG,LITTLE} to extract negative reloc bit.
+ (aoutarm_squirt_out_relocs): Delete.
+
+ From: David Taylor (dtaylor@armltd.co.uk)
+ * config/arm[lb]-aout.mt: New files.
+ * aout-arm.c: New file.
+ * config.bfd: Handle arm{,e[lb]}-*-aout
+ * configure.in: Add vetor for aout_arm_{big,little}_vec.
+ * reloc.c: New relocation types for the ARM.
+ * targets.c (aout_arm_{big,little}_vec): declare.
+
+Tue May 16 10:29:51 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
+
+ * libbfd.c (bfd_stat): If bfd_cache_lookup returns an error,
+ return an error to the caller. Call bfd_set_error on errors.
+
+Tue May 16 14:44:45 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * libcoff-in.h (coff_renumber_symbols): Modified prototypes in
+ accordance with 11 May libcoff.h change.
+
+Thu May 11 16:43:14 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ tekhex.c (first_phase): Understand type 0 symbols.
+ (tekhex_write_object_contents): Fix typo in final record.
+
+Thu May 11 16:43:14 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * coff-i960.c (optcall_callback): don't try and optimize
+ undefined refs.
+ (coff_write_relocs): Search for broken relocs on the way
+ out and fix them up.
+ (coff_renumber_symbols): Calculate and return index of
+ first undefined symbol.
+ (coff_write_object_contents): Call coff_renumber_symbols
+ and coff_write_relocs with the new args.
+ * libcoff.h: (coff_renumber_symbols, coff_renumber_symbols):
+ Modified prototypes.
+
+Thu May 11 16:43:14 1995 Steve Chamberlain <sac@slash.cygnus.com>
+ Tom Griest <griest@cs.yale.edu>
+
+ Initial support for PE format.
+
+ * Makefile.in, targets.c, configure.in, config.bfd:
+ Add support for i386-*-winnt and i386-*-pe.
+ * archive.c (do_slurp_coff_armap): Understand NTPE format
+ archives.
+ (_bfd_slurp_extended_name_table): Turn \ in a filename
+ into /.
+ * bfd-in.h (bfd_link_subsystem, _bfd_link_stack_heap): New.
+ * coff-i386.c (howto_table): Conditionalize PCRELOFFSET.
+ * coffcode.h (IMAGE_BASE): New.
+ (coff_compute_section_file_positions): Throw away .junk
+ sections for PE, align symbols.
+ (coff_write_object_contents): Throw away .junk sections
+ for PE. Remember info on .idata and .rsrc sections.
+ Fill in the PE header.
+ (coff_slurp_symbol_table): PE uses C_SECTION class.
+ * cofflink.c (_bfd_coff_final_link): Keep PE info up to date.
+ (_bfd_coff_generic_relocate_section): Cope with PE relocs.
+ * coffswap.h (coff_swap_{aout/file/scn/sym}hdr_{in/out}):
+ New code for PE headers.
+
+Tue May 9 17:01:38 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.bfd: Add little endian PowerPC support.
+ * configure.in: Ditto.
+ * targets.c: Ditto.
+ * config/ppcle-elf.mt: New file, for little endian PowerPC
+ support.
+ * config/ppc-elf.mt: Add little endian powerpc to the BFD
+ selection vectors.
+ * elf32-ppc.c (ppc_elf_merge_private_bfd_data): Complain if
+ linking a different endian object than we expect.
+ (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME): Define, to provide little
+ endian support.
+
+Tue May 2 16:32:24 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * config.bfd (hppa*-*-lites*): Treat just like hppa*-*-*elf*.
+
+Tue Apr 25 19:38:43 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * coffgen.c (make_a_section_from_file): Initialize lma same as
+ vma.
+
+Tue Apr 25 11:03:21 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * hosts/std-host.h: #include ansidecl.h 'cause PTR is used in
+ std-host.h.
+
+Mon Apr 24 23:56:44 1995 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * hosts/i386linux.h (HAVE_PROCFS): Don't define it. Added lengthy
+ comment explaining why.
+
+Mon Apr 24 10:34:02 1995 Michael Meissner <meissner@cygnus.com>
+
+ * hosts/i386linux.h (HAVE_PROCFS): If NO_PROCFS is defined, don't
+ define HAVE_PROCFS.
+
+Mon Apr 24 08:33:12 1995 Michael Meissner <meissner@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Do not continue
+ processing unknown symbols to prevent a cascade of errors.
+
+Fri Apr 21 12:48:48 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Patches from H.J. Lu for Linux ELF core file support.
+ * elfcode.h (elf_core_file_matches_executable_p) [HAVE_PROCFS]:
+ Use prpsinfo_t instead of struct prpsinfo, for consistency.
+ * hosts/i386linux.h (HAVE_PROCFS): Define.
+
+Thu Apr 20 09:07:39 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * linker.c (link_action): Do the right thing when a undefined
+ strong symbol appears after an undefined weak symbol.
+
+Fri Apr 14 16:51:17 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): New function to relocate
+ a whole section for the linker, bypassing bfd_perform_relocation.
+ (ppc_elf_reloc_type_lookup): New function to map the BFD
+ enumeration code into a howto structure.
+ (ppc_elf_howto_raw): Rename from ppc_elf_howto_table.
+ (ppc_elf_howto_table): New array that maps PowerPC relocation
+ numbers to howto structures without a linear search. Change from
+ using bfd_elf_generic_reloc to use ppc_elf_std_reloc.
+ (ppc_elf_howto_init): Initialize ppc_elf_howto_table from
+ ppc_elf_howto_raw.
+ (ppc_elf_reloc_type_lookup): Use a case statement instead of a
+ loop.
+ (ppc_elf_std_reloc): Replacement for bfd_elf_generic_reloc.
+ (ppc_elf_unsupported_reloc): Print a real error message, instead
+ of calling abort.
+ (ppc_elf_addr16_ha_inner): Abstract getting adjustment from
+ ppc_elf_addr16_ha_reloc, so ppc_elf_relocate_section can use it
+ too.
+ (ppc_elf_addr16_ha_reloc): Call it.
+ (ppc_elf_got16_inner): Abstract getting adjustment from
+ ppc_elf_got16_reloc, so ppc_elf_relocate_section can use it too.
+ (ppc_elf_got16_reloc): Call it.
+ (ppc_elf_info_to_howto): Rename from powerpc_info_to_howto.
+
+ * elfcode.h (elf_symbol_from_bfd_symbol): Omit space in debugging
+ output.
+ (elf_symbol_flags): Add debug function to decode flags so that
+ defining DEBUG to be 4 will compile again.
+ (elf_debug_section): Fix typo in debug output.
+
+Fri Apr 14 16:03:04 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * config.bfd: Add m68*-*-elf*.
+ * elf32-m68k.c: Filled out implementation, except for dynamic
+ linking support.
+ * reloc.c (enum bfd_reloc_code_real): Added *_GOT_PCREL, *_GOTOFF,
+ *_PLT_PCREL, *_PLTOFF, *_68K_* relocations for ELF.
+ * libbfd.h, bfd-in2.h: Regenerated.
+
+Thu Apr 13 14:28:04 1995 Torbjorn Granlund <tege@adder.cygnus.com>
+
+ * coff-m68k.c (COFF_DEFAULT_SECTION_ALIGNMENT_POWER): Change from
+ 1 to 2.
+ (bfd_target): Change minimum section alignment from 1 to 2.
+
+Wed Apr 12 12:40:04 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * aoutx.h (machine_type, case bfd_arch_mips): Treat R8000 like
+ R6000 and R4000 for now.
+
+Tue Apr 4 12:28:25 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: New file, MPW version of configure.in.
+ * mpw-make.in: New file, MPW version of Makefile.in.
+ * hosts/mpw.h: New file, MPW host definitions.
+ * ecoffswap.h (ecoff_swap_pdr_in, ecoff_swap_pdr_in) [MPW_C]:
+ Alternate versions without ECOFF_64 that chokes MPW C.
+ * coffswap.h (coff_swap_scnhdr_out): Add alternative version with
+ partly-expanded macros.
+
+Thu Mar 30 14:56:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * reloc.c (bfd_perform_relocation): Don't bother to check for
+ overflow if the symbol is undefined.
+
+Thu Mar 30 14:32:26 1995 H.J. Lu (hjl@nynexst.com)
+
+ * config.bfd: Change linux to default to elf. Using
+ i[345]86-*-linuxaout will build a library which defaults to a.out.
+ * config/i386-laout.mt: Rename from old config/i386-linux.mt.
+ * config/i386-linux.mt: Rename from old config/i386-lelf.mt.
+ Comment out EXTRALIBS.
+ * config/i386-lelf.mt: Remove.
+
+Wed Mar 29 12:01:30 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i960.c (coff_i960_relocate): Cache the section symbol in
+ the used_by_bfd field of the section, to avoid looping for each
+ reloc.
+
+ * cpu-h8500.c (arch_info_struct): Change name from "H8/300" to
+ "h8300" for consistency with other cpu-* files.
+
+Tue Mar 28 15:14:11 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bout.c (b_out_canonicalize_reloc): Handle SEC_CONSTRUCTOR
+ sections.
+ (b_out_get_reloc_upper_bound): Likewise.
+
+ * linker.c (generic_link_add_symbol_list): Skip constructor
+ symbols which the main linker code did not do anything with.
+ (_bfd_generic_link_output_symbols): Use udata.p if it is set,
+ rather than looking the symbol up in the hash table. Just pass
+ through constructor symbols for which udata.p is not set. If the
+ linker defined the symbol, clear the constructor flag.
+
+Tue Mar 21 10:50:32 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_set_reloc_info): Sign extend constants from
+ R_DATA_OVERRIDE fixups.
+ * libhppa.h (sign_extend): Renamed from sign_ext. Fix.
+ (low_sign_extend): Likewise.
+
+Mon Mar 20 22:39:10 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_slurp_symbol_table): Tighten test to determine
+ what symbols are section symbols.
+
+Sat Mar 18 01:54:45 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_bfd_link_add_symbols): An empty archive is OK.
+
+Fri Mar 17 16:29:02 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_copy_private_section_data): Just return true when
+ either the input or output section isn't attached to a SOM BFD.
+ (som_bfd_copy_private_bfd_data): Similarly for BFD private data.
+
+Fri Mar 17 11:50:34 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_link_add_object_symbols): Check whether a dynamic
+ object has already been included, and ignore it the second time.
+
+Wed Mar 15 11:56:40 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf_sparc_howto_table): Change R_SPARC_GOT13 from
+ complain_overflow_bitfield to complain_overflow_signed.
+
+ * libelf.h (bfd_elf32__write_relocs): Don't declare.
+ (bfd_elf64__write_relocs): Don't declare.
+
+Tue Mar 14 05:54:33 1995 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * stab-syms.c (aout_stab_name): Moved aout_stab_names to be local
+ to this function. Recoded function to stop using table, to
+ improve performance (on i486-netbsd host). Left old version
+ intact under "#if 0" for further performance testing.
+
+Mon Mar 13 13:48:49 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (write_relocs): Make static. Use PTR argument as a
+ pointer to a boolean variable set to true if something fails.
+ Cast to PTR rather than void *.
+ (sym_is_global): Rewrite for clarity.
+ (map_program_segments): If the program header size is too small,
+ call _bfd_error_handler and return failure rather than aborting.
+ (NAME(bfd_elf,write_object_contents)): Pass boolean variable when
+ calling write_relocs.
+ (elf_symbol_from_bfd_symbol): Use BFD_ASSERT rather than abort.
+ (struct elf_info_failed): Define.
+ (NAME(bfd_elf,size_dynamic_sections)): Declare variables in inner
+ blocks. Pass elf_info_failed structure when calling
+ elf_export_symbol and elf_adjust_dynamic_symbol.
+ (elf_export_symbol): Treat data argument as elf_info_failed rather
+ than bfd_link_info. Set failed field on error.
+ (elf_adjust_dynamic_symbol): Likewise.
+ (struct elf_finfo_failed): Define.
+ (elf_bfd_final_link): Pass elf_finfo_failed structure when calling
+ elf_link_output_extsym. Use BFD_ASSERT rather than abort.
+ (elf_link_output_extsym): Treat data argument as elf_finfo_failed
+ rather than elf_final_link_info. Set failed field on error.
+ (elf_link_input_bfd): Use BFD_ASSERT rather than abort.
+ (elf_reloc_link_order): Likewise.
+
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Only write
+ out PLTRELSZ, PLTREL and JMPREL relocs if there is a .rela.plt
+ section. Solaris 2.4 apparently does not handle empty reloc
+ information correctly.
+
+ * archive.c (bsd_write_armap): Cast getuid and getgid results to
+ long, and print with %ld.
+
+Fri Mar 10 16:41:05 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (translate_to_native_sym_flags): Always use the output
+ section if it is not NULL.
+
+Thu Mar 9 15:06:25 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffswap.h (coff_swap_scnhdr_out): If the line number count or
+ the reloc count does not fit, print an error and return 0.
+ * coffcode.h (coff_write_object_contents): Check return value of
+ coff_swap_scnhdr_out.
+ * ecoff.c (_bfd_ecoff_write_object_contents): Check return value
+ of bfd_coff_swap_scnhdr_out.
+
+ * bfd.c: Include <stdarg.h> or <varargs.h>, depending upon
+ ANSI_PROTOTYPES.
+ (bfd_error_handler_type): New global type.
+ (_bfd_error_program_name): New static variable.
+ (_bfd_default_error_handler): New static function.
+ (_bfd_error_handler): New BFD private global variable.
+ (bfd_set_error_handler): New globally visible function.
+ (bfd_set_error_program_name): New globally visible function.
+ * libbfd-in.h (_bfd_error_handler): Declare.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+ * aoutx.h (NAME(aout,swap_ext_reloc_in)): Add symcount parameter,
+ and use it instead of bfd_get_symcount. Check r_index after
+ setting r_extern based on whether this is a base relative reloc.
+ (NAME(aout,swap_std_reloc_IN)): Add symcount parameter, and use it
+ instead of bfd_get_symcount.
+ (NAME(aout,slurp_reloc_table)): Pass bfd_get_symcount to reloc
+ swap routines.
+ * libaout.h (NAME(aout,swap_ext_reloc_in)): Add symcount parameter
+ to declaration.
+ (NAME(aout,swap_std_reloc_in)): Likewise.
+ * sunos.c (sunos_canonicalize_dynamic_reloc): Pass
+ info->dynsym_count to reloc swap routines.
+ * aout-ns32k.c (MY_swap_std_reloc_in): Add symcount parameter.
+ * hp300hpux.c (MY(swap_std_reloc_in)): Likewise.
+ (MY(slurp_reloc_table)): Pass bfd_get_symcount to reloc swap
+ routine.
+ * i386lynx.c (NAME(lynx,swap_ext_reloc_in)): Add symcount
+ parameter.
+ (NAME(lynx,swap_std_reloc_in)): Likewise.
+ (NAME(lynx,slurp_reloc_table)): Pass bfd_get_symcount to reloc
+ swap routines.
+
+Thu Mar 9 12:04:05 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * bfd.c (bfd_merge_private_bfd_data): New function vector to be
+ called by the linker to merge any private bfd data of the input
+ files and the output file. Used by the PowerPC ELF support to
+ check whether -mrelocatable is used for all modules.
+ (bfd_set_private_flags): New function vector to be called by the
+ assembler to set private flags. Used by the PowerPC ELF support
+ to set that a particular object file was assembled with the
+ -mrelocatable option.
+
+ * targets.c (BFD_JUMP_TABLE_COPY): Add intiialization of the
+ bfd_merge_private_bfd_data and bfd_set_private_flags function
+ vectors.
+
+ * bfd-in2.h, libbfd-in.h: Rebuild with bfd.c and targets.c
+ changes.
+
+ * elf32-ppc.c (ppc_elf_set_private_flags): New function to set the
+ ELF e_flags field.
+ (ppc_elf_copy_private_bfd_data): Copy the e_flags field from the
+ input file to the output file.
+ (ppc_elf_merge_private_bfd_data): Check for a mismatch between the
+ e_flags field of all of the linker input files.
+
+ * libelf.h (elf_obj_tdata): Add ppc_flags_init field so that the
+ PowerPC support can check if compataible e_flags are present.
+
+ * aout-target.h: Add NOP for the bfd_merge_private_bfd_data
+ and bfd_set_private_flags function vectors.
+ * coffcode.h: Ditto.
+ * elf32-target.h: Ditto.
+ * elf64-target.h: Ditto.
+ * libbfd.h: Ditto.
+ * libecoff.h: Ditto.
+ * som.c: Ditto.
+
+Wed Mar 8 00:53:54 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * cpu-mips.c (arch_info_struct): Add mips:8000 entry.
+
+ * elfcode.h (swap_out_syms): Mark an undefined BSF_WEAK symbol as
+ STB_WEAK rather than STB_GLOBAL.
+
+Tue Mar 7 12:23:47 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (bfd_coff_backend_data): Add new field
+ _bfd_coff_adjust_symndx.
+ (bfd_coff_adjust_symndx): Define.
+ (coff_adjust_symndx): Define as NULL if not already defined.
+ (bfd_coff_std_swap_table): Initialize new field to
+ coff_adjust_symndx.
+ * cofflink.c (coff_link_input_bfd): Call coff_adjust_symndx if it
+ is defined.
+ * coff-a29k.c (coff_a29k_adjust_symndx): New static function.
+ (coff_adjust_symndx): Define before including coffcode.h.
+ * libcoff.h: Rebuild.
+
+ * format.c (bfd_check_format_matches): Skip binary_vec when
+ searching through bfd_target_vector.
+
+ * elfcode.h (elf_sort_hdrs): Check SHT_NOBITS before checking
+ sh_size.
+
+Mon Mar 6 23:31:36 1995 Doug Evans <dje@chestnut.cygnus.com>
+
+ * elfcode.h (elf_sort_hdrs): Keep SHT_NOBITS sections after
+ !SHT_NOBITS ones.
+
+Mon Mar 6 09:53:08 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * cpu-hppa.c (arch_info_struct): Support both PA1.0 and PA1.1
+ machine types.
+ (bfd_hppa_arch): Link in both PA1.0 and PA1.1 architecture info
+ structures.
+ * libhppa.h (enum pa_arch): New enumeration to describe the
+ different variants of the PA architecture.
+ * som.c (som_object_setup): Use new enumeration to set machine
+ type.
+ (som_finish_writing): If the machine type is PA1.1, then use the
+ PA1.1 machine identifier in the output file.
+
+Thu Mar 2 15:58:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,swap_ext_reloc_in)): Treat the index of a
+ base relative reloc as an index into the symbol table, regardless
+ of the setting of r_extern.
+ (NAME(aout,swap_std_reloc_in)): Likewise.
+
+ * aoutx.h (NAME(aout,set_section_contents)): Double check that the
+ caller is writing to a valid section.
+
+Thu Mar 2 14:37:57 1995 Bryan Ford <baford@cs.utah.edu>
+
+ * binary.c: Add support for reading binary files. Loads the raw
+ contents of the file into a data section and wraps some symbols
+ around it. The symbols `_binary_<filename>_start' and
+ `_binary_<filename>_end' indicate the start and end of the data,
+ while `_binary_<filename>_size' is an absolute symbol whose value
+ is the size of the data. <filename> is the name of the binary
+ input file, with all non-alphanumeric characters converted to
+ underscores.
+
+ * archures.c (bfd_arch_get_compatible): Assume users knows what
+ they're doing if one of the architectures is bfd_arch_unknown.
+
+Wed Mar 1 17:30:46 1995 Michael Meissner <meissner@cygnus.com>
+
+ * elf32-ppc.c (elf_powerpc_howto_table): For relocation
+ R_PPC_GOT16, change complain_on_overflow to be
+ complain_overflow_signed.
+
+Wed Mar 1 11:52:55 1995 Jason Molenda <crash@phydeaux.cygnus.com>
+
+ * configure.host: Recognize powerpc-*-aix*.
+
+Wed Mar 1 11:57:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i960.c (COFF_PAGE_SIZE): Define.
+
+ * configure.in: Rewrite output of TDEFAULTS to avoid relying on
+ semantics of single quotes in parameter substitution.
+
+Tue Feb 28 12:53:09 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_sort_hdrs): Sort empty sections before non-empty
+ sections, if they have the same VMA.
+
+ * config.bfd (i[345]86-*-linuxelf*): New target. Use i386-lelf.
+ (i[345]86-*-gnuelf*): New target. Use i386-gelf.
+ * config/i386-lelf.mt: New file.
+ * config/i386-gelf.mt: New file.
+
+Mon Feb 27 12:58:25 1995 Kung Hsu <kung@mexican.cygnus.com>
+
+ * config.bfd: add a29k-*-vxworks configuration.
+
+Wed Feb 22 14:40:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libaout.h (NAME(aout,slurp_reloc_table)): Change declaration to
+ use reloc_howto_type rather than const struct reloc_howto_struct.
+
+Tue Feb 21 18:19:22 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bout.c (b_out_slurp_reloc_table): Don't return an error if asked
+ for relocations for the .bss section.
+
+Tue Feb 21 15:13:05 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_ar_write_symbol_stuff): Handle objects with odd
+ lengths.
+
+Fri Feb 17 12:34:36 1995 Michael Meissner <meissner@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_got16_reloc): Make GOT style relocs add
+ 32768, so the GOT pointer can point to 16384 pointers, instead of
+ 8192.
+
+Fri Feb 17 11:45:38 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * hosts/sysv4.h: Include <unistd.h>, <stdlib.h>, and <time.h>.
+ Only define SEEK_SET and SEEK_CUR if they are not already defined.
+ Remove all external function declarations.
+
+ * syms.c (bfd_decode_symclass): Return 'W' for a weak symbol.
+
+ * coffgen.c (coff_real_object_p): Set start address and flags
+ before calling coff_mkobject_hook. Restore them on failure.
+ * ecoff.c (_bfd_ecoff_mkobject_hook): If not ECOFF_AOUT_ZMAGIC,
+ clear D_PAGED.
+
+ * coffgen.c: Reindented.
+
+Thu Feb 16 14:37:23 1995 Doug Evans <dje@cygnus.com>
+
+ * reloc.c (bfd_perform_relocation): Don't use bitpos in overflow
+ calculations.
+ (bfd_install_relocation): Likewise.
+
+Thu Feb 16 13:22:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * hosts/std-host.h: Remove all function declarations which return
+ int or void, except the one for free.
+
+Wed Feb 15 14:54:18 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (elf_powerpc_howto_table): Use a destination mask of
+ 0xffffffff for R_PPC_REL32, not 0.
+ (powerpc_reloc_map): Add low 16 bit, high 16 bit, and high 16 bit
+ adjusted relocations.
+
+Tue Feb 14 17:47:17 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (struct mips_elf_find_line): Define.
+ (mips_elf_find_nearest_line): New static function.
+ (bfd_elf32_find_nearest_line): Define.
+ * libelf.h (struct elf_obj_tdata): Add find_line_info field.
+
+ * ecoff.c (_bfd_ecoff_swap_tir_in): Move to ecofflink.c.
+ (_bfd_ecoff_swap_tir_out): Likewise.
+ (_bfd_ecoff_swap_rndx_in): Likewise.
+ (_bfd_ecoff_swap_rndx_out): Likewise.
+ (cmp_fdrtab_entry): Likewise.
+ (mk_fdrtab): Likewise.
+ (lookup): Likewise.
+ (_bfd_ecoff_find_nearest_line): Just call _bfd_ecoff_locate_line
+ to do most of the work. Allocate find_line_info if necessary.
+ * ecofflink.c: Include "aout/stab_gnu.h".
+ (_bfd_ecoff_swap_tir_in): Move in from ecoff.c.
+ (_bfd_ecoff_swap_tir_out): Likewise.
+ (_bfd_ecoff_swap_rndx_in): Likewise.
+ (_bfd_ecoff_swap_rndx_out): Likewise.
+ (cmp_fdrtab_entry): Likewise. Use PTR instead of void *.
+ (mk_fdrtab): Move in from ecoff.c. Add debug_info, debug_swap,
+ and line_info arguments, and use them instead of ecoff_data.
+ (fdrtab_lookup): Move in from lookup in ecoff.c. Remove abfd
+ argument, add line_info argument. Use it instead of ecoff_data.
+ (_bfd_ecoff_locate_line): New function, mostly from the old
+ _bfd_ecoff_find_nearest_line in ecoff.c.
+ * libecoff.h (ecoff_data_type): Remove find_buffer, fdrtab_len and
+ fdrtab fields, replacing them find_line_info field.
+ (_bfd_ecoff_swap_tir_in): Declare.
+ (_bfd_ecoff_swap_tir_out): Declare.
+ (_bfd_ecoff_swap_rndx_in): Declare.
+ (_bfd_ecoff_swap_rndx_out): Declare.
+ * libbfd-in.h (_bfd_ecoff_locate_line): Declare.
+ * libbfd.h: Rebuild.
+ * configure.in: Don't use ecoff.o for bfd_elf32_bigmips_vec or
+ bfd_elf32_littlemips_vec.
+ * Makefile.in: Rebuild dependencies.
+
+Tue Feb 14 14:04:22 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * libelf.h (elf_backend_data): Add fields elf_machine_alt1 and
+ elf_machine_alt2 which provide alternate versions of the machine
+ code.
+
+ * elf32-ppc.c (ELF_MACHINE_ALT1, ELF_MACHINE_ALT2): Define to
+ recognize old versions of the PowerPC machine code.
+
+ * elf32-target.h (elf32_bed): Initialize alternate machine code
+ fields defined by ELF_MACHINE_ALT1 and ELF_MACHINE_ALT2.
+
+ * elf64-target.h (elf64_bed): Initialize alternate machine code
+ fields defined by ELF_MACHINE_ALT1 and ELF_MACHINE_ALT2.
+
+ * elfcode.h (elf_object_p, elf_core_file_p): In addition to the
+ main machine code field, check the two alternate machine code
+ fields.
+
+Tue Feb 14 12:46:48 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutf1.h (MACHTYPE_OK): Don't define if already defined. Don't
+ accept M_SPARC if bfd_arch_sparc is not in the list of supported
+ architectures, and don't accept a 680x0 machine type if
+ bfd_arch_m68k is not in the list of supported architectures.
+ * aout0.c (MACHTYPE_OK): Define.
+
+Mon Feb 13 23:25:38 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,swap_ext_reloc_in)): Don't return a pointer
+ to garbage if the symbol index is out of range.
+ (NAME(aout,swap_std_reloc_in)): Likewise.
+
+Thu Feb 9 18:36:52 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (BFD32_BACKENDS): Add i386msdos.o.
+
+Thu Feb 9 12:02:35 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386linux.c (NEEDS_SHRLIB): Define.
+ (linux_tally_symbols): Crash if a NEEDS_SHRLIB symbol is
+ undefined. From hjl@nynexst.com (H.J. Lu).
+
+Wed Feb 8 17:26:00 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * linker.c (generic_link_check_archive_element): Allocate common
+ symbol information structure. Don't bother to check for common
+ symbol size overflow.
+ (_bfd_generic_link_add_one_symbol): Likewise.
+ * aoutx.h (aout_link_check_ar_symbols): Likewise.
+ * linker.c (generic_link_check_archive_element): Adjust references
+ to common symbol information for new structure.
+ (_bfd_generic_link_add_one_symbol): Likewise.
+ * aoutx.h (aout_link_check_ar_symbols): Likewise.
+ (aout_link_add_symbols): Likewise.
+ * ecoff.c (ecoff_link_add_externals): Likewise.
+ * elfcode.h (elf_link_add_object_symbols): Likewise.
+ (elf_link_output_extsym): Likewise.
+ * sunos.c (sunos_add_one_symbol): Likewise.
+
+Wed Feb 8 09:53:42 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * elfcode.h (elf_sort_hdrs): Put SHT_NOBITS sections after !SHT_NOBITS.
+
+Tue Feb 7 16:27:33 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_find_nearest_line): Just return false, don't
+ abort.
+
+Tue Feb 7 14:43:33 1995 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * ecoff.c: Reformatted some comments and brace constructs in
+ recent changes to GNU style.
+ (cmp_fdrtab_entry, mk_fdrtab, lookup): Use old-style function
+ definitions.
+
+Tue Feb 7 14:21:28 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoffswap.h (ecoff_swap_pdr_in): Zero out intern before setting
+ any of the fields.
+
+Mon Feb 6 20:01:24 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Sat Feb 4 14:20:24 1995 David Mosberger-Tang <davidm@piston.cs.arizona.edu>
+
+ * ecoffswap.h (ecoff_swap_pdr_in, ecoff_swap_pdr_out): added
+ internalizing/externalizing new "prof" field.
+
+ * libecoff.h (ecoff_tdata): added fdrtab.
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): Fixed.
+
+Mon Feb 6 14:25:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libelf.h (struct elf_link_hash_table): Add saw_needed field.
+ * elfcode.h (elf_link_add_object_symbols): Set saw_needed if
+ DT_NEEDED seen in .dynamic section.
+ (elf_link_output_extsym): Warn if an undefined symbol is
+ only referenced from a dynamic object, and not making a shared
+ object, and saw_needed is false.
+ * elf.c (_bfd_elf_link_hash_table_init): Initialize saw_needed.
+
+ * libelf.h (ELF_LINK_HASH_DEFINED_WEAK): Don't define.
+ * elfcode.h (elf_link_add_object_symbols): Don't clear or set
+ ELF_LINK_HASH_DEFINED_WEAK.
+ (elf_link_output_extsym): Don't check ELF_LINK_HASH_DEFINED_WEAK.
+
+ Distinguish a weak defined symbol from a regular defined symbol.
+ * linker.c (enum link_action): Add DEFW.
+ (link_action): Add bfd_link_hash_defweak column.
+ (_bfd_generic_link_add_one_symbol): Add DEFW case. Handle
+ bfd_link_hash_defweak in a few other cases.
+ * Many files (bfd_link_hash_undefweak): Renamed from
+ bfd_link_hash_weak.
+ * aoutx.h (aout_link_write_symbols): Handle bfd_link_hash_defweak.
+ (aout_link_write_other_symbol): Likewise.
+ (aout_link_input_section_std): Likewise.
+ (aout_link_input_section_ext): Likewise.
+ * bout.c (get_value): Likewise.
+ * coff-a29k.c (coff_a29k_relocate_section): Likewise.
+ * coff-alpha.c (alpha_convert_external_reloc): Likewise.
+ (alpha_relocate_section): Likewise.
+ * coff-mips.c (mips_relocate_section): Likewise.
+ (mips_relax_section): Likewise.
+ (bfd_mips_ecoff_create_embedded_relocs): Likewise.
+ * cofflink.c (coff_write_global_sym): Likewise.
+ (_bfd_coff_generic_relocate_section): Likewise.
+ * ecoff.c (ecoff_link_add_externals): Likewise.
+ (ecoff_link_write_external): LIkewise.
+ * elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
+ (elf32_hppa_size_stubs): Likewise.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
+ (elf_i386_relocate_section): Likewise.
+ (elf_i386_finish_dynamic_symbol): Likewise.
+ * elf32-mips.c (mips_elf_output_extsym): Likewise.
+ (mips_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+ (elf32_sparc_relocate_section): Likewise.
+ * elfcode.h (elf_link_add_object_symbols): Likewise.
+ (elf_adjust_dynamic_symbol): Likewise.
+ (elf_bfd_final_link): Likewise.
+ (elf_link_output_extsym): Likewise.
+ * i386linux.c (linux_add_one_symbol): Likewise.
+ (linux_tally_symbols): Likewise.
+ (linux_finish_dynamic_link): Likewise.
+ * linker.c (_bfd_generic_link_output_symbols): Likewise.
+ (set_symbol_from_hash): Likewise.
+ * reloc16.c (bfd_coff_reloc16_get_value): Likewise.
+ (bfd_perform_slip): Likewise.
+ * sunos.c (sunos_add_one_symbol): Likewise.
+ (sunos_scan_std_relocs): Likewise.
+ (sunos_scan_ext_relocs): Likewise.
+ (sunos_scan_dynamic_symbol): Likewise.
+ (sunos_write_dynamic_symbol): Likewise.
+
+Mon Feb 6 03:20:17 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Changes from Bryan Ford, baford@schirf.cs.utah.edu:
+ * config.bfd (i[345]86-*-msdos*): New target.
+ * configure.in (i386msdos_vec): Handle it.
+ * i386msdos.c: New file.
+ * config/i386-msdos.mt: New file.
+ * bfd.c (enum bfd_error): Added new value bfd_error_file_too_big.
+ (bfd_errmsgs): Added string to table.
+ * libaout.h (reloc_type-lookup): Declare it.
+ * targets.c (enum bfd_flavour): Added bfd_target_msdos_flavour.
+ (i386msdos_vec): Declare.
+ (bfd_target_vector): Add it to the list.
+ * bfd-in2.h: Regenerated.
+
+Wed Feb 1 01:32:14 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_set_reloc_info, case R_DATA_ONE_SYMBOL): If there's
+ nothing in R_DATA_OVERRIDE, then try to find the addend in the
+ section's contents.
+ (som_write_fixups): Ignore the addend in a R_DATA_ONE_SYMBOL fixup.
+
+ * som.c (som_object_setup): More heruistics to detect the
+ braindamaged HP OSF1 linker.
+ (setup_sections): Don't forget to free subspace_sections if we get
+ an error.
+ (som_slurp_string_table): Allocate strings on this bfd's obstack
+ rather than directly out of the heap.
+ (som_slurp_symbol_table): Likewise for the saved copy of the
+ canonical symbols.
+ (som_slurp_reloc_table): Likewise for the saved copy of the
+ canonical relocations. Free the native relocations when we're
+ done with them.
+
+Tue Jan 31 21:53:28 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * libelf.h (struct elf_obj_tdata): New member program_header_size.
+ * elfcode.h (get_program_header_size): New parameters sorted_hdrs,
+ count, and maxpagesize. All callers updated.
+ If sorted_hdrs is non-NULL, use it to compute the number of segments.
+ Save result in case called again.
+ (assign_file_positions_except_relocs): Sort headers before calling
+ get_program_header_size.
+
+Tue Jan 31 15:27:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (map_program_segments): Add sorted_hdrs parameter.
+ Search through it rather than through unsorted section headers.
+ (assign_file_positions_except_relocs): Pass sorted_hdrs to
+ map_program_segments.
+
+Mon Jan 30 22:04:53 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): Fix problems in range
+ checking. Expect argument OFFSET to be section-relative. From
+ David Mosberger-Tang, davidm@piston.cs.arizona.edu.
+
+Mon Jan 30 11:22:11 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (NAME(bfd_elf,record_link_assignment)): Don't do
+ anything if we are not linking an ELF file.
+ (NAME(bfd_elf,size_dynamic_sections)): Likewise.
+
+Sat Jan 28 12:48:57 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (compare_subspaces): New function to sort subspaces by
+ their location in the object file.
+ (setup_sections): When computing the index for each subspace,
+ handle case where setup_sections reads the subspaces in a
+ different order that they appear in the object file.
+ (som_is_space): Also examine the output section for the containing
+ section.
+ (som_is_subspace, som_is_container): Likewise.
+ (som_begin_writing): Don't prepare or write fixups here. When
+ writing the symbol strings, use the unsorted symbol table.
+ (som_write_object_contents): Don't write the symbol table here.
+ (som_finish_writing): Prepare and write the fixups here. Likewise
+ for the symbol table.
+ (som_bfd_derive_misc_symbol_info): Undefined symbols always have
+ type SS_UNSAT regardless of BSF_EXPORT.
+ (som_set_reloc_info): Unpack and attach argument location
+ information for R_PCREL_CALL and R_ABS_CALL relocations.
+
+ * som.c (som_object_setup): New heuristic to determine if the
+ entry and flags fields are switched in the exec header.
+
+Sat Jan 28 00:16:01 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_link_add_object_symbols): Use *sym_hash instead
+ of h if we might not be doing an ELF link.
+
+Fri Jan 27 16:13:42 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_final_link): If the size of an input
+ .reginfo section is zero, force it to the correct size, since the
+ linker emulation code may have clobbered it.
+
+ * elfcode.h (elf_sort_hdrs): Correct SHF_ALLOC test.
+ (assign_file_positions_except_relocs): Free sorted_hdrs.
+
+Thu Jan 26 09:00:12 1995 Steve Chamberlain <sac@splat>
+
+ * srec.c (srec_set_section_contents): Fix off by
+ one end address calculation.
+
+ * config.bfd: (m68*-est-coff): New configuration.
+
+Thu Jan 26 11:39:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_link_add_object_symbols): Only examine weakdef if
+ we are using an ELF hash table.
+
+ * aoutx.h (NAME(aout,some_aout_object_p)): Always set EXEC_P if
+ the start address is in the .text section, even if STAT_FOR_EXEC
+ is set. Just use STAT_FOR_EXEC as an additional test.
+
+Thu Jan 26 11:12:54 1995 Michael Meissner <meissner@cygnus.com>
+
+ * elfcode.h (prep_headers): Use EM_PPC instead of
+ EM_CYGNUS_POWERPC.
+
+ * elf32-ppc.c (reloc_type): Add all System V.4 and eABI
+ relocations currently defined.
+ (powerpc_reloc_map): Adjust to new relocation names.
+ (elf_powerpc_howto_table): Add most of the new relocations.
+ (ELF_MACHINE_CODE): Use EM_PPC instead of EM_CYGNUS_POWERPC.
+
+ * config.bfd: Add support for powerpc-*-eabi.
+
+ * config/ppc-elf.mt: Add rs6000 architecture support to the
+ PowerPC. Also add XCOFF support.
+
+Wed Jan 25 23:26:13 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (CALC_ADDEND): Don't define.
+ (coff_sh_relocate_section): Remove.
+ (coff_relocate_section): Use _bfd_coff_generic_relocate_section.
+
+Tue Jan 24 14:22:47 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elf32-mips.c (mips_elf_output_extsym): Set the value of the
+ ECOFF symbol from the hash table entry.
+
+Mon Jan 23 14:53:35 1995 Steve Chamberlain <sac@splat>
+
+ * coff-sh.c (coff_sh_relocate_section): Don't subtract
+ vma twice.
+
+Mon Jan 23 13:33:18 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * coff-sh.c (sh_reloc): Don't ignore the previous contents of an
+ R_SH_IMM32 reloc.
+
+ * config.bfd (i[345]86-*-gnu*): Set bfd_name to i386-gnu.
+ * config/i386-gnu.mt: New file. Include ELF support.
+
+ * opncls.c (bfd_openstreamr): Call bfd_cache_init.
+
+Fri Jan 20 11:44:45 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * sunos.c (sunos_add_one_symbol): Only set the sunos specific
+ fields if we are doing a sunos link.
+
+Wed Jan 18 12:28:17 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * cpu-h8300.c (h8300_info_struct): Change name from "H8/300" to
+ "h8300" for consistency with other cpu-* files.
+ (h8300h_info_struct): Change name from "H8/300H" to "h8300h".
+ * coff-h8300.c (special): Remove unused variable diff.
+
+Tue Jan 17 10:52:32 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * bfd-in.h (bfd_byte, reloc_howto_type): Define here, not...
+ * reloc.c (bfd_byte, reloc_howto_type): here.
+ * Changed all occurrences of ``const struct reloc_howto_struct''
+ to be ``reloc_howto_type'' instead.
+ * bfd-in2.h, libbfd.h, libcoff.h: Rebuilt.
+
+ * opncls.c (bfd_openstreamr): New function.
+ * bfd-in2.h: Rebuilt.
+
+ * elf32-mips.c (enum reloc_type): Define new relocs used on Irix.
+ (elf_mips_howto_table): Add entries for new relocs.
+ (mips_elf_section_from_shdr): Handle SHT_MIPS_MSYM,
+ SHT_MIPS_DWARF, and SHT_MIPS_EVENTS.
+ (mips_elf_fake_sections): Handle sections named .msym, .debug_*
+ and .MIPS.events.*.
+
+ * srec.c (srec_init): Remove unused local variable i.
+
+Sat Jan 14 19:09:48 1995 Steve Chamberlain <sac@jonny>
+
+ * archures.c, Makefile.in, targets.c, bfd-in2.h, coffcode.h,
+ config.bfd, configure.in, config/w65.mt: Initial support for the W65.
+
+Sun Jan 15 13:57:45 1995 Steve Chamberlain <sac@splat>
+
+ * opncls.c (bfd_fdopenr): Configure for WIN32.
+
+Thu Jan 12 16:30:47 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (diststuff): Include `headers'.
+
+ * sunos.c (m68k_plt_first_entry, sparc_plt_first_entry): Now
+ const.
+ * tekhex.c (digs): Ditto.
+ * elf32-i386.c (elf_i386_plt0_entry, elf_i386_plt_entry): Ditto.
+
+ * srec.c, tekhex.c: Include libiberty.h. Delete static array
+ hex_value and replace references to it with references to
+ hex_init, hex_p, and hex_value.
+ * Makefile.in: Updated dependencies.
+
+ * archures.c (archures_init_table): Now const.
+ (bfd_arch_init): Adjusted type of local var `ptable'.
+
+Thu Jan 12 09:33:24 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * hosts/symmetry.h: Redefine `shared' to enable compilation
+ with the native Dynix cc compiler.
+ * i386dynix.c: Include aoutx.h instead of using routines
+ from aout32.c.
+
+Wed Jan 11 21:31:41 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * reloc.c (reloc_howto_type): Make typedef include `const'.
+ * aout-ns32k.c, aoutx.h, bout.c, cf-m68klynx.c, coff-i386.c,
+ coff-i960.c, coff-m68k.c, cofflink.c, cpu-ns32k.c, ecoff.c,
+ elf32-hppa.c, elf32-i386.c, elf32-mips.c, elf32-sparc.c,
+ elfcode.h, libbfd-in.h, linker.c, mipsbsd.c, nlm32-ppc.c, oasys.c,
+ reloc.c, som.c: Don't use `const' in combination with
+ `reloc_howto_type'.
+ * bfd-in2.h, libbfd.h: Regenerated.
+
+ * ecoff.c (ecoff_type_to_string): Local variable `buffer1' doesn't
+ need to be static.
+
+Wed Jan 11 14:36:41 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * sunos.c (sunos_add_one_symbol): Don't core dump if a multiple
+ definition of an absolute symbol is encountered.
+
+ * linker.c (_bfd_generic_link_add_one_symbol): Ignore
+ redefinitions of an absolute symbol to the same value.
+
+Mon Jan 9 15:51:32 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_link_add_object_symbols): It's reasonable for no
+ flags to be set, so don't insist otherwise.
+
+Fri Jan 6 16:39:40 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_slurp_symbol_table): Don't set BSF_GLOBAL for an
+ undefined or common symbol.
+ (elf_link_add_object_symbols): Likewise.
+
+Wed Jan 4 14:14:05 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (bfd_section_from_som_symbol): Only return sections which
+ correspond to subspaces.
+
+ * som.c (som_begin_writing): Don't forget to bump the
+ total_subspaces when writing the unloadable subspaces.
+
+Wed Dec 28 20:54:47 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_write_fixups): Use SEC_HAS_CONTENTS to identify
+ bss-like sections.
+ (som_get_section_contents): Likewise.
+ (som_set_section_contents): Likewise.
+
+Tue Dec 27 14:03:47 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (setup_sections): Turn off SEC_HAS_CONTENTS for bss-like
+ sections.
+
+Tue Dec 20 15:30:12 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * coffgen.c (bfd_debug_section): Deleted.
+ (coff_section_from_bfd_index): Return absolute section for debug
+ symbol.
+ (coff_write_symbol): Set BSF_DEBUGGING for C_FILE symbols. If
+ BSF_DEBUGGING is set, set section to N_DEBUG.
+ (coff_bfd_make_debug_symbol): Use absolute section.
+
+ * elfcode.h (assign_file_positions_except_relocs): In assertion,
+ force all values to the same type.
+
+Tue Dec 20 11:11:58 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * coff-h8300.c (howto_table): All relocs get a special function.
+ (special): Never do anything when linking -r.
+
+Tue Dec 20 13:58:01 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * i386linux.c (linux_add_one_symbol): Don't do anything Linux
+ specific if this is not a Linux hash table. From Eric Youngdale
+ <eric@aib.com>.
+
+ Patches from kkojima@mix.or.jp (Kazumoto Kojima):
+ * mipsbsd.c (mips_howto_table_ext): Change sizes of memory relocs
+ apply to from two bytes to four bytes.
+ * MY(reloc_howto_type_lookup): Handle BFD_RELOC_CTOR.
+
+ * elf32-i386.c (elf_i386_relocate_section): Correct and expand the
+ list of cases for which relocation need not be computed.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+Mon Dec 19 23:09:16 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_read_symext_info): Delete do_locals and
+ do_globals arguments, always read symbol extension information for
+ globals and locals. All callers changed.
+ (elf32_hppa_size_stubs): Rework to only read symbol extension
+ information once for each input bfd. 10% improvement in linker
+ performance.
+
+Fri Dec 16 12:28:46 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_section_from_bfd_section): Check
+ bfd_is_abs_section, etc., only after checking for the section in
+ the BFD and after calling the backend routine.
+
+Wed Dec 14 20:21:58 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_map_symbols): Only use section symbols whose
+ value is the start of the section, checking output_offset when
+ using output_section. When creating a new symbol, set the value
+ to 0, since BFD symbol values are section relative.
+
+Tue Dec 13 13:31:06 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * cpu-z8k.c (arch_info_struct): Make z8002 the default
+ architecture.
+
+Fri Dec 9 12:43:05 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_bfd_link_add_symbols): If the first object in the
+ archive is not an ELF object, pass the archive to the add_symbols
+ entry point appropriate for the first object. From Eric Youngdale
+ <eric@aib.com>.
+ * aoutx.h (NAME(aout,link_add_symbols)): Similar change if the
+ first object is not an a.out object.
+
+ * elf32-i386.c (elf_i386_relocate_section): Don't compute
+ relocation in cases where we won't use it.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+Thu Dec 8 14:19:41 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * pc532-mach.c (NAME): Define to use ns32kaout prefix.
+ * ns32knetbsd.c (NAME): Ditto.
+ (ns32kaout_32_get_section_contents): Define to standard aout-32
+ version.
+
+Fri Dec 2 13:56:49 1994 Ian Lance Taylor <ian@rtl.cygnus.com>
+
+ * coff-mips.c (mips_read_relocs): New static function, broken out
+ of mips_relax_section.
+ (mips_relax_section): Call mips_read_relocs.
+ (bfd_mips_ecoff_create_embedded_relocs): New function.
+ * bfd-in.h (bfd_mnips_ecoff_create_embedded_relocs): Declare.
+ * bfd-in2.h: Rebuild.
+
+Wed Nov 30 14:12:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-sh.c: Use _bfd_dummy_target instead of no_archive.
+
+Tue Nov 29 14:00:19 1994 J.T. Conklin <jtc@.rtl.cygnus.com>
+
+ * config.bfd (i[345]86-*-freebsd*): Use i386-bsd as bfd_name.
+ * configure.host (i[345]86-*-freebsd*): Use i386bsd as my_host.
+
+Mon Nov 28 15:36:04 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
+
+ * config/m68k-nbsd.mt (DEFAULT_VECTOR): set to m68knetbsd_vec.
+ * Makefile.in: Rebuilt dependancies.
+ (CFILES): Added m68knetbsd.c.
+ (HFILES): Added netbsd.h.
+
+Wed Nov 23 19:21:41 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * coff-sh.c (shlcoff_vec): New target vector.
+ (no_archive): New function.
+ * coffcode.h (coff_set_arch_mach_hook, coff_set_flags): Handle
+ little endian SH.
+ * configure.in: Handle shl.
+ * targets.c (bfd_target_vector): Add shlcoff_vec.
+ * config/sh-coff.mt (SELECT_VECS): Handle shl_coff_vec.
+
+Wed Nov 23 10:50:13 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elfcode.h (write_relocs): Do not subtract the section's vma from
+ the reloc's offset when writing .o's. Instead add the section's
+ vma to the reloc's offset when writing an executable or shared
+ library.
+
+Tue Nov 22 23:34:37 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_bfd_final_link_relocate): Do not add
+ input_section->vma to the relocation's offset.
+
+Mon Nov 21 12:37:25 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * srec.c (srec_get_reloc_upper_bound): Define.
+ (srec_canonicalize_reloc): Define.
+ (srec_bfd_reloc_type_lookup): Define.
+ (srec_vec, symbolsrec_vec): Use BFD_JUMP_TABLE_RELOCS (srec).
+
+Sat Nov 19 03:10:51 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.host (i[345]86-*-solaris*): Use solaris2 to
+ enable extraction of procfs info from core file for GDB.
+
+Thu Nov 17 17:37:39 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * reloc.c (bfd_reloc_code_type): Add new value BFD_RELOC_12_PCREL.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+
+Thu Nov 17 13:12:08 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * bfd/elf32-hppa.c (elf32_hppa_bfd_final_link_relocated): Use the
+ vma from the output_section containing $global$ when computing
+ global_vlaue.
+
+Thu Nov 17 14:29:13 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * archive.c (_bfd_write_archive_contents): Round up the archive
+ header size of the extended name table to an even number.
+
+Wed Nov 16 16:08:06 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * coff-sh.c: Deleted some code that was commented out or inside
+ "#if 0".
+ (COFF_LONG_FILENAMES): Define.
+
+ * cpu-sh.c (arch_info_struct): Convert name to lowercase, for
+ consistency with other architectures.
+
+Sat Nov 12 23:50:10 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (elf_export_symbol): Also export symbols which are
+ referenced by a regular file.
+
+Fri Nov 11 14:29:31 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add
+ export_dynamic argument, and handle it.
+ (elf_export_symbol): New function.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration.
+ (bfd_elf64_size_dynamic_sections): Update declaration.
+ * bfd-in2.h: Rebuild.
+
+Fri Nov 11 10:35:33 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * hpux-core.c (hpux_core_struct): Delete handles for the
+ data, reg and stack sections. They're never used. Delete
+ accessor macros.
+ (make_bfd_asection): Use bfd_make_section_anyway since debugging
+ cores from dynamic executables may have several sections with the
+ same logical name.
+ (hpux_core_core_file_p): Don't save handles to data, reg and
+ stack sections. Handle CORE_TEXT, CORE_MMF and CORE_SHM.
+
+Tue Nov 8 13:03:30 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * bout.c (callj_callback): Add new argument shrinking. Change all
+ callers. Handle relocs against section symbols correctly. If not
+ shrinking, don't subtract out dstidx; the subtraction is already
+ in the object file.
+
+Sun Nov 6 12:52:00 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.h: Conditionally include <shl.h> and <dl.h>.
+
+Thu Nov 3 18:19:13 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (ALL_MACHINES): Include m68knetbsd.o.
+
+ * config/i386linux.mh (EXTRALIBS): Include -lm.
+
+ Patches from DJ Delorie:
+ * coff-go32.c: Replacement file, uses coff-i386.c with minor
+ changes.
+ * coff-i386.c (TARGET_UNDERSCORE): allow other files to override
+ underscore also
+ * makefile.dos: del ctor.o, add cofflink.o and elf32.o
+
+ * aoutx.h (adjust_o_magic): If user set data section vma, use it
+ to determine the default bss vma. Patch from Takada Hiroaki,
+ hiro@is.s.u-tokyo.ac.jp.
+ (machine_type, case bfd_arch_vax): Set *unknown to false. Patch
+ from John David Anglin <dave@hiauly1.hia.nrc.ca>.
+
+ * configure.in (tb): Rename ns32knetbsd_vec to pc532netbsd_vec,
+ since that's what it's called.
+
+Wed Nov 2 15:24:51 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * archive.c (normalize): Change to take a BFD as an argument.
+ Change VMS version to use bfd_alloc rather than malloc, so that we
+ don't lose the memory forever.
+ (_bfd_construct_extended_name_table): Check the name of an archive
+ entry which is not being extended, and correct it if it is wrong.
+ This is necessary in case the archive was constructed by another
+ program which put an entry in the extended name table which we
+ don't plan to put in ourselves. From jjc@jclark.com (James
+ Clark).
+ (bfd_dont_truncate_arname): Check return value of normalize.
+
+Mon Oct 31 14:19:08 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elf32-hppa.c (ELF32_PARISC_SX_SIZE): Define.
+ (ELF32_PARISC_SX_GET, ELF32_PARISC_SX_PUT): Define.
+ (symextn_entry): Don't define.
+ (symext_chain_size): Change type to bfd_size_type.
+ (symextn_contents): Change type to bfd_byte *.
+ (elf32_hppa_backend_begin_write_processing): Use
+ ELF32_PARISC_SX_SIZE instead of sizeof (symext_entryS).
+ (elf32_hppa_size_symext): Likewise. Also, change type of sizep to
+ bfd_size_type *.
+ (elf_hppa_tc_make_sections): Cast symextn_contents assignment to
+ bfd_byte *. Use ELF32_PARISC_SX_PUT instead of direct assignment.
+ (elf32_hppa_backend_symbol_table_processing): Use
+ ELF32_PARISC_SX_SIZE instead of sizeof (symext_entryS). Use
+ ELF32_PARISC_SX_GET insetad of direct assignment.
+ (elf32_hppa_read_symext_info): Change type of contents, and its
+ assignment cast, to bfd_byte *. Use ELF32_PARISC_SX_SIZE instead
+ of sizeof (symextn_entry). Use symext_entryS instead of
+ symextn_entry. Use ELF32_PARISC_SX_GET instead of direct
+ assignment.
+
+ * archive.c (bfd_dont_truncate_arname): Add the ar padding
+ character, if there is room for it, even if the name is the
+ maximum length.
+
+ * elfcode.h (assign_file_positions_except_relocs): Sort the ELF
+ headers by section address when assigning file positions.
+ (elf_sort_hdrs): New static function.
+
+Sun Oct 30 18:56:58 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Create DT_INIT
+ and DT_FINI dynamic entries based on the existence of _init and
+ _fini symbols, not on the .init and .fini sections. This is
+ compatible with some SVR4 linkers.
+ (elf_bfd_final_link): Corresponding change.
+
+Sat Oct 29 12:18:10 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Don't move a
+ symbol with a PLT entry into the .plt section if it is defined in
+ a regular file.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+
+ * linker.c (_bfd_generic_link_add_archive_symbols): It's not an
+ error if an empty archive has no symbol table.
+ * ecoff.c (ecoff_link_add_archive_symbols): Likewise.
+ * elfcode.h (elf_link_add_archive_symbols): Likewise.
+
+Fri Oct 28 10:08:41 1994 J.T. Conklin (jtc@rtl.cygnus.com)
+
+ NetBSD/m68k support, based on work by mikeb@snow.datametrics.com:
+ * config.bfd (m68*-*-netbsd*): Use m68k-nbsd as bfd_name.
+ * configure.in (m68knetbsd_vec): Added.
+ * targets.c (bfd_m68knetbsd_vec): Added.
+ * hosts/m68knbsd.h, config/m68k-nbsd.mt, m68knetbsd.c: New files.
+ * Makefile.in (BFD32_BACKENDS, CFILES): Add m68knetbsd.c.
+
+ miscellaneous cleanup required by all netbsd targets, based on work
+ by Andrew Cagney <cagney@highland.com.au>:
+ * netbsd.h (N_MAGIC, N_SET_MAGIC, N_GETMAGIC, N_GETMAGIC2, N_TXTADDR,
+ N_TXTOFF, N_ALIGN, N_DATADDR, N_DATOFF): Removed. Generic a.out
+ definitions work.
+ * i386nbsd.c, ns32knbsd.c, sparcnbsd.c (__LDPGSZ): Removed.
+ (MY(write_object_contents)): Use NetBSD's magic numbers
+
+Thu Oct 27 16:59:52 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * libelf.h (struct bfd_elf_section_data): Add field dynindx.
+ * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Don't finalize
+ the .dynsym, .dynstr or .hash sections until after the backend
+ size_dynamic_sections routine, so that it can add dynamic symbols
+ if it wants to.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Don't define the
+ symbol to be in the .plt section when generating a shared library
+ if it is a defined symbol.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+ (elf32_sparc_size_dynamic_sections): When generating a shared
+ library, allocate space for a dynamic symbol for each output
+ section, storing the index in the dynindx field of the ELF section
+ data. Adjust the other dynindx fields to account for this.
+ (elf32_sparc_adjust_dynindx): New static function.
+ (elf32_sparc_relocate_section): When copying a reloc into a shared
+ library, use the original addend as appropriate. Convert an
+ R_SPARC_32 reloc into an R_SPARC_RELATIVE reloc. Use the dynamic
+ symbol index of the output section, not the normal symbol index.
+ (elf32_sparc_finish_dynamic_sections): Don't die if a section does
+ not exist when setting the value of the dynamic tags. Write out
+ a dynamic symbol for each output section.
+
+Wed Oct 26 01:15:51 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_link_input_section): Don't bother to read or write
+ the relocs if there aren't any.
+
+Tue Oct 25 11:44:38 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * Makefile.in (ALL_MACHINES): Add tekhex.o.
+ * targets.c (bfd_target_vector): If SELECT_VECS is not defined,
+ include tekhex_vec.
+ * tekhex.c (NIBBLE, ISHEX): Cast array arguments to unsigned char.
+ (getvalue, getsym, out): Likewise.
+ (find_chunk): Remove unused variable s.
+ (first_phase): Remove unused variable s.
+ (pass_over): Remove unused variable address.
+ (tekhex_object_p): Remove unused variable section.
+ (move_section_contents): Change return type from boolean to void.
+ (tekhex_write_object_contents): Remove unused variables tdata and
+ list.
+
+ * linker.c (enum link_action): Add CIND.
+ (link_action): Change COMMON_ROW\indr from MDEF to CREF. Change
+ INDR_ROW\common from MDEF to CIND.
+ (_bfd_generic_link_add_one_symbol): In CREF case, handle an
+ existing symbol which is indirect rather than defined. Add new
+ CIND case.
+
+Mon Oct 24 15:33:16 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ Change S-record backend to use multiple sections to handle gaps in
+ file.
+ * srec.c (srec_data_list_struct): Move field next from last place
+ to first. Change type of data to bfd_byte *.
+ (struct srec_symbol): Define.
+ (tdata_type): Remove done_symbol_read, count, strings, symbol_idx,
+ string_size, string_idx. Change type of symbols to struct
+ srec_symbol *. Add symtail and csymbols.
+ (low, high): Remove.
+ (size_symbols, fillup_symbols, size_srec, fillup): Remove.
+ (white, skipwhite, pass_over, object_p): Remove.
+ (srec_mkobject): Call srec_init. Adjust tdata initialization for
+ field changes.
+ (srec_get_byte, srec_bad_byte): New static functions.
+ (srec_new_symbol, srec_scan): New static functions.
+ (srec_object_p): Change type of b to bfd_byte. Explicitly set
+ wrong_format error. Call srec_mkobject and srec_scan instead of
+ object_p.
+ (symbolsrec_object_p): Likewise. Also, change b to be only two
+ bytes.
+ (srec_read_section): New static function.
+ (srec_get_section_contents): Call srec_read_section rather than
+ pass_over. Handle zero length section correctly.
+ (set_set_arch_mach): Change from function to macro.
+ (srec_set_section_contents): Change data to bfd_byte *.
+ (srec_write_record): Change data, end and src to bfd_byte *.
+ (srec_write_header): Change buffer and dst to bfd_byte *.
+ (srec_write_section): Change location to bfd_byte *.
+ (srec_write_terminator): Change buffer to bfd_byte *.
+ (srec_get_symtab_upper_bound): Don't call
+ srec_get_section_contents.
+ (srec_get_symtab): Rewrite.
+
+ * ecoff.c (ecoff_set_symbol_info): Set udata.i to 0, not NULL.
+
+Fri Oct 21 16:43:13 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
+
+ * libaout.h (machine_type): added M_68K_NETBSD and M_SPARC_NETBSD.
+ * i386netbsd.c, ns32knetbsd.c, sparcnetbsd.c: removed RCS Id's.
+ changed how PAGE_SIZE and SEGMENT_SIZE are defined so they are
+ consistant with each other.
+ * netbsd.h (N_HEADER_IN_TEXT, TEXT_START_ADDR): NetBSD fits its
+ header into the start of its text segment.
+
+Fri Oct 21 17:13:07 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * targets.c (BFD_JUMP_TABLE_ARCHIVE): Add case for
+ _construct_extended_name_table.
+ (bfd_target): Add _bfd_construct_extended_name_table.
+ * archive.c (_bfd_archive_bsd_construct_extended_name_table): New
+ function.
+ (_bfd_archive_coff_construct_extended_name_table): New function.
+ (_bfd_construct_extended_name_table): Renamed by adding a leading
+ underscore, and made externally visible. Added trailing_slash
+ argument, and used it instead of elf_style. Changed type of
+ tablen to bfd_size_type *.
+ (_bfd_write_archive_contents): Use BFD_SEND to call
+ construct_extended_name_table. Use the returned name.
+ * libbfd-in.h (_bfd_construct_extended_name_table): Declare.
+ (_bfd_noarchive_construct_extended_name_table): Define.
+ (_bfd_archive_bsd_construct_extended_name_table): Declare.
+ (_bfd_archive_coff_construct_extended_name_table): Declare.
+ * bfd-in2.h: Rebuild.
+ * libbfd.h: Rebuild.
+ * som.c (som_construct_extended_name_table): New static function.
+ * aout-target.h (MY_construct_extended_name_table): Define.
+ * coff-rs6000.c (rs6000coff_construct_extended_name_table):
+ Define.
+ * ieee.c (ieee_construct_extended_name_table): Define.
+ * libecoff.h (_bfd_ecoff_construct_extended_name_table): Define.
+ * oasys.c (oasys_construct_extended_name_table): Define.
+
+ Fix the ELF linker to not require an interpreter if no dynamic
+ objects were seen, even when linking PIC code.
+ * libelf.h (ELF_LINK_HASH_NEEDS_PLT): Define.
+ (struct elf_link_hash_table): Add field dynamic_sections_created.
+ * elfcode.h (elf_link_record_dynamic_symbol): Create dynstr if it
+ doesn't already exist.
+ (elf_link_add_object_symbols): Create dynamic sections based on
+ dynamic_sections_created field, not dynobj field. Don't bother to
+ set dynobj.
+ (elf_link_create_dynamic_sections): If dynamic sections were
+ already created, don't do anything. If dynobj is already set, use
+ it; otherwise, set it to the bfd argument. Don't initialize
+ dynsymcount. Only create dynstr if it does not exist. Set
+ dynamic_sections_created to true.
+ (NAME(bfd_elf,size_dynamic_sections)): Skip most of this function
+ if no dynamic objects were seen.
+ (elf_adjust_dynamic_symbol): If a symbol has the
+ ELF_LINK_HASH_NEEDS_PLT flag set, let the backend adjust it.
+ (elf_bfd_final_link): Change most decisions based on dynobj to
+ check dynamic_sections_created instead.
+ (elf_link_output_extsym): Only handle dynamic symbols if a dynamic
+ object was seen.
+ * elf.c (_bfd_elf_link_hash_table_init): Initialize new field
+ dynamic_sections_created. Set dynsymcount to 1, not 0.
+ * elf32-i386.c (elf_i386_create_dynamic_sections): Call
+ elf_i386_create_got_section rather than creating the .got and
+ .got.plt sections.
+ (elf_i386_create_got_section): New static function.
+ (elf_i386_check_relocs): Just call elf_i386_create_got_section if
+ a GOT table is needed, not bfd_elf32_link_create_dynamic_sections.
+ Only create the .rel.got section, and only make space for a reloc,
+ for a global symbol or when generating a shared object. For a
+ R_386_PLT32 reloc, just set the ELF_LINK_HASH_NEEDS_PLT flag.
+ (elf_i386_adjust_dynamic_symbol): Rework initial assertion to
+ permit ELF_LINK_HASH_NEEDS_PLT non dynamic symbols. Create a
+ procedure linkage table entry for such symbols. But, if no
+ dynamic objects were seen, never create a PLT entry.
+ (elf_i386_size_dynamic_sections): If no dynamic objects were seen,
+ skip most of this function, and force the size of the .rel.got
+ section to zero.
+ (elf_i386_relocate_section): For a R_386_GOT32 reloc against a global
+ symbol when no dynamic object was seen, initialize the contents of
+ the .got section. For a R_386_GOT32 against a local symbol, only
+ create a R_386_RELATIVE reloc when generating a shared object.
+ Treat a R_386_PLT32 reloc against a symbol for which we did not
+ create a PLT entry as a R_386_PC32 reloc.
+ (elf_i386_finish_dynamic_sections): Only fiddle with the dynamic
+ entries and the PLT if we saw a dynamic object.
+ * elf32-sparc.c (elf_sparc_howto_table): Fix R_SPARC_PC22 by
+ setting rightshift to 10. Fix R_SPARC_WPLT20 by setting
+ rightshift to 2, size to 2, bitsize to 30, and dst_mask to
+ 0x3fffffff.
+ (elf32_sparc_create_dynamic_sections): Don't set the size of the
+ .plt section. Call elf32_sparc_create_got_section rather than
+ creating the .got section.
+ (elf32_sparc_check_relocs): Call elf32_sparc_create_got_section if
+ a GOT table is needed, not bfd_elf32_link_create_dynamic_sections.
+ Only create the .rela.got section, and only make space for a
+ reloc, for a global symbol or when generating a shared object.
+ Set the alignment of the .rela.got section to 2. For a
+ R_SPARC_WPLT30 reloc, just set the ELF_LINK_HASH_NEEDS_PLT flag.
+ (elf32_sparc_adjust_dynamic_symbol): Rework initial assertion to
+ permit ELF_LINK_HASH_NEDS_PLT non dynamic symbols. Create a
+ procedure linkage table for such symbols. But, if no dynamic
+ objects were seen, never create a PLT entry. Initialize the size
+ of the .plt section.
+ (elf32_sparc_size_dynamic_sections): If no dynamic objects were
+ seen, skip most of this function, and force the size of the
+ .rela.got section to zero. Strip empty reloc sections, and strip
+ an empty .plt section.
+ (elf32_sparc_relocate_section): For a GOT reloc against a global
+ symbol when no dynamic object was seen, initialize the contents of
+ the .got section. For a GOT reloc against a local symbol, only
+ create a R_SPARC_RELATIVE reloc when generating a shared object.
+ Treat a R_SPARC_WPLT30 reloc against a symbol for which we did not
+ create a PLT entry as a R_SPARC_WDISP30 reloc.
+ (elf32_sparc_finish_dynamic_sections): Only fiddle with the
+ dynamic entries and the PLT if we saw a dynamic object.
+
+Thu Oct 20 13:28:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (elf_map_symbols): Don't worry about section symbols
+ in a section not owned by any BFD.
+ (elf_section_from_bfd_section): Separate out loop which calls
+ backend routine. Check bfd_section and call the backend routine
+ even for a section not owned by any BFD.
+ * elf32-mips.c (mips_elf_section_from_bfd_section): Handle
+ .acommon section.
+
+Wed Oct 19 13:28:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * coffgen.c (coff_print_symbol): Make names for section number and
+ storage class slightly more verbose. It's not clear how many
+ characters I can justify using up, but before this change they
+ both were abbreviated "sc" which is (IMHO) clearly unacceptable.
+
+Wed Oct 19 01:26:39 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * binary.c (binary_set_section_contents): Set the base file
+ position from the lowest section VMA, not the start address.
+
+ * aoutx.h (NAME(aout,slurp_symbol_table)): Don't return an error
+ if there are no symbols.
+ * coffgen.c (coff_get_normalized_symtab): Likewise.
+ * hp300hpux.c (MY(slurp_symbol_table)): Likewise.
+
+Tue Oct 18 12:56:43 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * aout-target.h (MY_bfd_copy_private_section_data): Only copy
+ subformat to another bfd_target_aout_flavour file.
+
+ * binary.c: New file for raw binary output format.
+ * Makefile.in (BFD_LIBS): Add binary.o.
+ (CFILES): Add binary.c.
+ * targets.c (binary_vec): Declare.
+ (bfd_target_vector): Include binary_vec.
+
+ * srec.c (tdata_type): Add field tail.
+ (srec_mkobject): Initialize tail.
+ (srec_set_section_contents): Sort S record list by address.
+
+Mon Oct 17 11:38:16 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_map_symbols): Sort the symbols into a new array,
+ rather than messing with Elf_Sym_Extra. Store the symbol index in
+ the udata.i field.
+ (swap_out_syms): Use outbound_syms as a pointer rather than as an
+ array. Don't worry about elf_sym_num.
+ * libelf.h (struct elf_sym_extra): Don't define.
+ (Elf_Sym_Extra): Don't define.
+ (struct elf_obj_tdata): Remove sym_extra field.
+ (elf_sym_extra): Don't define.
+ * elf32-hppa.c (elf32_hppa_backend_final_write_processing): Use
+ udata.i rather than elf_sym_extra array.
+
+ * syms.c (asymbol): Change udata field into a union.
+ * bfd-in2.h: Rebuild.
+ * aoutx.h (NAME(aout,translate_symbol_table)): Use udata.p rather
+ than just udata.
+ * bout.c (perform_slip): Likewise.
+ * hp300hpux.c (MY(slurp_symbol_table)): Likewise.
+ * ieee.c (ieee_slurp_external_symbols): Likewise.
+ * linker.c (generic_link_add_symbol_list): Likewise.
+ (default_indirect_link_order): Likewise.
+ * oasys.c (oasys_slurp_symbol_table): Likewise.
+ * reloc16.c (bfd_perform_slip): Likewise.
+ * srec.c (fillup_symbols): Likewise.
+ * coffcode.h (get_index): Use udata.i rather than just udata.
+ (coff_slurp_symbol_table): Likewise.
+ * coffgen.c (set_index): Likewise.
+ * ecoff.c (ecoff_set_symbol_info): Likewise.
+ * elfcode.h (elf_symbol_from_bfd_symbol): Likewise.
+ * libecoff.h (ecoff_get_sym_index, ecoff_set_sym_index): Likewise.
+ * som.c (compare_syms): Likewise.
+ (som_prep_for_fixups): Likewise.
+ (som_write_fixups): Likewise.
+
+ Use a hash table when writing out ELF symbol names.
+ * elfcode.h (elf_stringtab_init): New static function.
+ (bfd_new_strtab, bfd_add_to_strtab, bfd_add_2_to_strtab): Remove.
+ Change all callers to use elf_stringtab_init or
+ _bfd_stringtab_add, and get stringtab lengths using
+ _bfd_stringtab_size.
+ (elf_fake_sections): Change ignored argument to pointer to
+ boolean, and set the boolean to true if an error occurs. If an
+ error has already occurred, don't do anything.
+ (assign_section_numbers): Just set sh_size, not contents.
+ (elf_compute_section_file_positions): Pass the address of a
+ boolean to elf_fake_sections. Pass the address of a
+ bfd_strtab_hash to swap_out_syms. Write out the .strtab section.
+ (prep_headers): Change shstrtab to bfd_strtab_hash.
+ (swap_out_syms): Take a pointer to a bfd_strtab_hash as an
+ argument. Set it to the symbol names.
+ (NAME(bfd_elf,write_object_contents)): Write out the section
+ header names using _bfd_stringtab_emit.
+ (elf_debug_section): Remove first argument; get the section name
+ via the bfd_section pointer. Change caller.
+ (elf_bfd_final_link): Write out the symbol names using
+ _bfd_stringtab_emit. Likewise for the .dynstr section contents.
+ Free the symbol names at the end of the function.
+ (elf_link_input_bfd): Remove the last argument, output_names,
+ from relocate_section. Save the old symbol contents before
+ calling elf_link_output_sym, and restore them afterward.
+ * libelf.h (struct elf_link_hash_table): Change dynstr field to
+ struct bfd_strtab_hash.
+ (struct elf_backend_data): Remove last argument, output_names,
+ from elf_backend_relocate_section field.
+ (struct strtab): Don't define.
+ (struct elf_obj_tdata): Change strtab_ptr field to struct
+ bfd_strtab_hash.
+ * elf32-hppa.c (elf32_hppa_relocate_section): Remove last
+ argument, output_names.
+ * elf32-i386.c (elf_i386_relocate_section): Likewise.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+ * libbfd-in.h (DEFAULT_STRING_SPACE_SIZE): Don't define.
+ (bfd_add_to_string_table): Don't declare.
+ * libbfd.h: Rebuild.
+ * libbfd.c (bfd_add_to_string_table): Remove.
+
+ * elfcode.h (elf_swap_shdr_in): Use bfd_section, not rawdata.
+ Clear contents field.
+ (bfd_section_from_shdr): In SHT_STRTAB case, check bfd_section,
+ not rawdata. Don't set rawdata if e_shstrndx. Use bfd_section
+ rather than rawdata in commented out code. In SHT_REL[A] case,
+ don't bother to check elf_section_data of section returned by
+ section_from_elf_index.
+ (elf_fake_sections): Set bfd_section, not rawdata. Don't set
+ size.
+ (elf_map_symbols): Don't set elf_num_section_syms. Don't create
+ section symbols that already exist.
+ (assign_file_position_for_section): Use bfd_section, not rawdata.
+ (section_from_elf_index): Just check bfd_section field.
+ (elf_section_from_bfd_section): Likewise.
+ (elf_debug_section): Don't print rawdata, contents, or size.
+ (elf_link_add_object_symbols): Don't error out if
+ section_from_elf_index returns NULL.
+ (elf_bfd_final_link): Check return value from
+ section_from_elf_index against NULL, not bfd_is_abs_section.
+ (elf_link_input_bfd): Don't check section_from_elf_index return
+ value.
+ * libelf.h (struct elf_obj_tdata): Remove num_section_syms field.
+ (elf_num_section_syms): Don't define.
+ * elf.c (elf_get_str_section): Store section contents in contents
+ field rather than rawdata field.
+ (elf_string_from_elf_section): Likewise.
+ (_bfd_elf_make_section_from_shdr): Store BFD section pointer in
+ bfd_section field rather than rawdata field.
+ * elf32-hppa.c (elf32_hppa_read_symext_info): Use bfd_section
+ rather than rawdata.
+ (elf32_hppa_size_stubs): Likewise.
+ (elf32_hppa_backend_symbol_table_processing): Don't set
+ symextn_hdr->size; just use sh_size.
+ * elf32-mips.c (mips_elf_final_write_processing): Use bfd_section
+ rathern than rawdata.
+ (mips_elf_section_from_shdr): Likewise.
+ (mips_elf_section_processing): Likewise.
+ (mips_elf_section_from_bfd_section): Remove rawdata check.
+
+ * srec.c (pass_over): Set the start address for S7, S8 or S9.
+
+Fri Oct 14 19:15:46 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * VERSION: Updated to 2.5.
+
+Fri Oct 14 11:07:50 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * bfd.c (bfd_scan_vma): Cast end to be non const before passing it
+ to strtoul.
+
+Thu Oct 13 14:40:41 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * bfd.c (bfd_scan_vma): Pass end argument on to strtoul.
+
+Wed Oct 12 16:46:43 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * opncls.c (bfd_realloc): Deleted, since it's broken and fixing it
+ would make it slow. Besides, it isn't used much.
+ * elfcode.h (elf_map_symbols): Always allocate new storage for the
+ symbol table.
+
+Wed Oct 12 11:54:37 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * ecoff.c (ecoff_set_symbol_info): Mark local stProc, stLabel or
+ stabs symbols as BSF_DEBUGGING.
+
+ * rs6000-core.c (rs6000coff_core_file_matches_executable_p): Make
+ str1 and str2 const pointers.
+
+ * Makefile.in (INSTALL): Use top level install.sh script.
+ * config/README (INSTALL): Remove.
+ * config/delta88.mh (INSTALL): Remove.
+ * config/i386v4.mh (INSTALL): Remove.
+ * config/irix4.mh (INSTALL): Remove.
+ * config/irix5.mh (INSTALL): Remove.
+ * config/ncrt3000.mh (INSTALL): Remove.
+
+Tue Oct 11 13:57:56 1994 Eric Youngdale (eric@andante.aib.com)
+
+ * elf32-i386.c (elf_i386_check_relocs): Make sure that a symbol
+ with a global offset table entry or a procedure linkage table
+ entry is added to the dynamic symbol table.
+ * elf32-sparc.c (elf32_sparc_check_relocs): Likewise.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): If a symbol has
+ already gotten a procedure linkage table entry, change the
+ definition to the PLT entry.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+
+Tue Oct 11 17:12:00 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * lynx-core.c (lynx_core_file_p): SPARC Lynx appears to start
+ dumping the .data section in a core file at a page boundary.
+
+Mon Oct 10 16:24:44 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * cofflink.c (_bfd_coff_final_link): Cast argument to bfd_h_put_32
+ to correct type.
+ (coff_read_string_table): Cast argument to bfd_h_get_32 to correct
+ type.
+ * elfcode.h (elf_link_output_extsym): Cast argument to
+ bfd_elf_hash to correct type.
+
+ * elf32-sparc.c (elf_sparc_howto_table): The PC10, PC22, and
+ WPLT30 relocations are PC-relative.
+
+Thu Oct 6 12:57:26 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+ * aoutx.h (adjust_o_magic): Correctly initialize vma if the vma of
+ the text section was user-defined.
+
+Wed Oct 5 14:42:12 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * archive.c (bfd_construct_extended_name_table): SVR4 uses slash
+ newline at the end of the file name, not just newline.
+
+Tue Oct 4 11:23:12 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_new_section_hook): Default section alignment
+ power to 4, rather than using align_power_min.
+
+ * coffcode.h (coff_new_section_hook): Don't use align_power_min;
+ use COFF_DEFAULT_SECTION_ALIGNMENT_POWER instead. Force the .stab
+ and .stabstr sections to be aligned to no more than 2. Remove
+ COFF_SPARC special cases.
+ * coff-a29k.c: Define COFF_DEFAULT_SECTION_ALIGNMENT_POWER.
+ * coff-apollo.c, coff-go32.c, coff-h8300.c: Likewise.
+ * coff-h8500.c, coff-i386.c, coff-i960.c, coff-m68k.c: Likewise.
+ * coff-m88k.c, coff-rs6000.c, coff-sh.c, coff-sparc.c: Likewise.
+ * coff-we32k.c, coff-z8k.c: Likewise.
+
+ * configure.in: Use ${config_shell} when running config.bfd.
+
+ * cofflink.c (coff_link_input_bfd): Don't try to convert a long
+ filename if the offset field is zero.
+
+ * elfcode.h (swap_out_syms): If the alignment of a common symbol
+ was not set, use a sensible default rather than zero.
+
+Mon Oct 3 16:04:29 1994 H.J. Lu (hjl@nynexst.com)
+
+ * opncls.c (bfd_close): Honor umask when setting execution bits.
+ (bfd_close_all_done): Likewise.
+
+Mon Oct 3 04:41:49 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * rs6000-core.c (rs6000coff_core_p): Set SEC_HAS_CONTENTS flag
+ for .stack and .ldinfo sections. Cast coredata.c_tab to a
+ file_ptr to avoid warnings from gcc.
+
+Fri Sep 30 13:11:38 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * elfcode.h (elf_bfd_final_link): Remove assertion when a non
+ SEC_IN_MEMORY section is found in dynobj. This can happen when
+ linking PIC compiled code.
+
+Thu Sep 29 15:21:44 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * reloc.c (bfd_install_relocation): Change type of "data" to
+ bfd_byte *, to go along with yesterday's change.
+
+ * elf.c (bfd_elf_print_symbol): Moved here from elf_print_symbol
+ in elfcode.h. (case bfd_print_symbol_all): Print symbol's size
+ field, except for common symbols; print their alignment.
+ * elfcode.h (elf_print_symbol): Deleted.
+ * libelf.h (bfd_elf_print_symbol): Declare.
+ (bfd_elf{32,64}_print_symbol): Replace declarations with macros.
+
+ * syms.c (bfd_print_symbol_vandf): Show BSF_LOCAL and BSF_GLOBAL
+ in one column. Use the column freed up to show BSF_FUNCTION and
+ BSF_FILE.
+
+Thu Sep 29 12:29:01 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * syms.c (stt): Add .rdata and .rodata.
+
+Wed Sep 28 13:35:05 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * reloc.c (bfd_install_relocation): Cast data_start to bfd_byte *
+ before trying to add values to it.
+
+Tue Sep 27 16:47:58 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * elf32-hppa.c (elf32_hppa_backend_final_write_processing): Cast
+ return value from elf_sym_extra.
+ (elf32_hppa_build_stubs): Cast return value from bfd_zalloc.
+ (elf32_hppa_size_stubs): Cast return value from malloc.
+
+ * gen-aout.c (main): Declare and initialize "arch".
+
+ * cofflink.c (coff_link_add_symbols): Cast return value of
+ bfd_hash_allocate.
+
+ * riscix.c (riscix_callback): Use PARAMS macro in prototype.
+
+ * reloc.c (bfd_install_relocation): New function, mostly copied
+ from bfd_perform_relocation, adjusted for the assembler's needs.
+ * bfd-in2.h: Regenerated.
+
+Mon Sep 26 11:00:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (assign_file_positions_except_relocs): Align the
+ section VMA and the file position even if D_PAGED is not set.
+
+ * bfd-in.h (bfd_seek): Change declaration to not mark fp const.
+ * bfd-in2.h: Rebuild.
+ * libbfd.c (bfd_seek): Don't mark parameters const, to avoid
+ conflicts with declaration.
+
+Fri Sep 23 15:15:31 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (map_program_segments): Don't abort if we allocated
+ too much space for the program header, only if we allocated too
+ little.
+ (assign_file_positions_except_relocs): Similar change.
+
+Tue Sep 20 13:17:07 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
+
+ * libaout.h: Fix comment.
+ * ns32knbsd.h: Changed M_NS32K_NETBSD to M_532_NETBSD to match
+ libaout.h.
+
+Tue Sep 20 15:23:21 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * Makefile.in: Rebuilt dependencies.
+ (BFD32_BACKENDS): Add sparcnetbsd.o.
+ (CFILES): Add ns32knetbsd.c and sparcnetbsd.c.
+ * targets.c: ns32knetbsd_vec was renamed to pc532netbsd_vec.
+
+ * coff-sh.c (rtype2howto): Remove; unused.
+ (coff_sh_relocate_section): Remove unused local variable rstat.
+ (reloc_processing): Comment out; unused.
+
+Fri Sep 16 12:12:27 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * aoutx.h (aout_link_write_other_symbol): If h->indx is -2, then
+ always write it out even if it would normally be stripped.
+ (aout_link_input_section_std): If we find a reloc against a
+ stripped global symbol, force it to be written out rather than
+ merely calling unattached_reloc.
+ (aout_link_input_section_ext): Likewise.
+ (aout_link_reloc_link_order): Likewise.
+
+Wed Sep 14 15:37:19 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.h (struct somdata): New field sorted_syms.
+ (obj_som_sorted_syms): Accessor macro.
+ * som.c (som_object_setup): Initialize sorted_syms to NULL.
+ (som_prep_for_fixups): Sort a copy of the BFD's symbol table;
+ store the sorted symbol table in sorted_syms.
+ (som_write_fixups): Initalize tmp_reloc to NULL to make GCC happy.
+ (som_begin_writing): Similarly for exec_header. Pass the sorted
+ symbol table to som_write_symbol_strings.
+ (som_build_and_write_symbol_table): Use the sorted symbols rather
+ than the canonical symbol table.
+
+ * som.h (som_symbol_type): Add "stringtab_offset" field.
+ * som.c (som_write_symbol_strings): Use "stringtab_offset"
+ rather than destroying the "name" field in the BFD symbol.
+ (som_build_and_write_symbol_table): Likewise.
+
+Wed Sep 14 15:06:55 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * aoutx.h (aout_link_write_symbols): Rename skip_indirect to
+ skip_next. If we find an N_WARNING symbol which has already been
+ written out, set skip_next.
+
+ * libecoff.h (struct ecoff_tdata): Add field find_buffer.
+ * ecoff.c: Include aout/stab_gnu.h.
+ (ecoff_find_nearest_line): Handle stabs debugging information.
+
+ * elfcode.h (elf_link_output_extsym): Keep a symbol marked as weak
+ even if it is referenced by another object.
+
+Tue Sep 13 17:57:00 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_fixup_formats): Case R_ENTRY (0xb3), set both
+ 'T' and 'U' to grab all the unwind information.
+ (som_set_reloc_info): Make 'U' unwind bits persist across
+ multiple SOM relocations. Set the addend field of an R_ENTRY
+ relocation to the value in 'T'; set the addend field on an
+ R_EXIT relocation to the value in 'U'.
+
+ * som.h (som_symbol_type): Delete unwind field.
+
+ * som.c (som_write_fixups): For R_ENTRY fixups, get 32bits of
+ unwind information from the addend field of the R_ENTRY, get the
+ other 32bits from the addend field of the R_EXIT.
+ (bfd_som_attach_unwind_info): Delete function and all references.
+
+ * som.h (som_symbol_type): Delete unused a.out-related fields.
+
+ * som.c (bfd_section_from_som_symbol): Use bfd_abs_section_ptr
+ instead of &bfd_abs_section.
+
+ * som.c (som_object_setup): Handle exec_entry and exec_flags being
+ switched in executables created by the OSF1 linker.
+ (som_write_fixups): Handle R_EXIT just like the R_{F,L,R}SEL
+ fixups. Support R_ALT_ENTRY (handle just like R_EXIT).
+
+Tue Sep 13 16:04:07 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * cofflink.c (coff_link_input_bfd): syment_base is unsigned
+ so can't compare -ve numbers with it.
+
+Mon Sep 12 20:31:17 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * configure.in (shcoff_vec): Use cofflink.o now.
+ * coff-sh.c: Rewritten to use new fast coff backend.
+
+Tue Sep 13 16:23:57 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * aoutx.h (NAME(aout,final_link)): Don't assume that all the input
+ files are a.out.
+
+Tue Sep 13 11:09:39 1994 J.T. Conklin (jtc@rtl.cygnus.com)
+
+ * configure.host (sparc-*-netbsd): use sparcnbsd.
+ (ns32k-*-netbsd): use ns32knbsd.
+
+ * hosts/{nbsd,i386nbsd,ns32knbsd,sparcnbsd}.h: New files, NetBSD
+ host support.
+
+ * sparcnetbsd.c: New file, adds support for NetBSD/sparc.
+ * config/sparc-nbsd.mt: Likewise.
+
+ * netbsd.h: New file, definitions common to all netbsd ports.
+ * i386netbsd.c: Use it.
+ * ns32knetbsd.c: Use it.
+
+ * Makefile.in, configure.in, targets.c, config/i386-nbsd.mt,
+ config/ns32k-nbsd.mt: canonicalize netbsd targets to conform to
+ file/variable naming conventions.
+ * i386netbsd.c: New file, renamed from netbsd386.c.
+ * ns32knetbsd.c: New file, renamed from netbsd532.c.
+
+Mon Sep 12 21:56:20 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_reloc_skip): Correct off-by-one error for 4-byte
+ R_NO_RELOCATION fixups.
+ (bfd_section_from_som_symbol): Return the absolute section if the
+ symbol isn't contained in any section in the output file.
+ (som_slurp_symbol_table): ST_PRI_PROG and ST_SEC_PROG symbols are
+ not function symbols (they are magic code labels which *can* be the
+ targets of cross space branches). $START$ is not a section symbol.
+
+Mon Sep 12 11:43:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coff-alpha.c (ecoffalpha_little_vec): Add SEC_CODE and SEC_DATA
+ to section_flags.
+ * coff-mips.c (ecoff_little_vec, ecoff_big_vec): Likewise.
+
+ * elfcode.h (swap_out_syms): Set the type of an undefined symbol
+ to STT_FUNC if the BSF_FUNCTION flag is set.
+
+ * cofflink.c (coff_link_input_bfd): If r_symndx is -1, don't
+ change it.
+ (_bfd_coff_generic_relocate_section): If r_symndx is -1, it is an
+ absolute reloc. Don't dump core using r_symndx as an array index.
+ * cf-m68klynx.c (coff_bfd_link_add_symbols): Define.
+ (lynx_link_add_symbols): New static function (copy of function in
+ coff-i386.c).
+ (coff_m68k_lynxrtype_to_howto): sym argument may be NULL.
+ * coff-i386.c (coff_i386_rtype_to_howto): Likewise.
+ * coff-a29k.c (coff_a29k_relocate_section): Handle an r_symndx
+ value of -1, meaning an absolute reloc.
+
+ * ctor.c: Remove; obsolete.
+ * Makefile.in: Rebuild dependencies.
+ (BFD_LIBS): Remove ctor.o.
+ (CFILES): Remove ctor.c.
+ * libbfd.h: Rebuild.
+
+Mon Sep 12 01:58:47 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (elf32_hppa_relocate_section): If there was a link
+ error of some sort (for example, undefined symbols), then do not
+ apply any relocs, just notify the user of the errors.
+ (elf32_hppa_backend_begin_write_processing): Do not build a symbol
+ extension section for an executable (it's useless).
+ (elf32_hppa_link_output_symbol_hook): Do nothing if there was a
+ link error of some sort (for example, undefined symbols).
+ (elf32_hppa_read_symext_info): Kludge. Turn off SEC_HAS_CONTENTS
+ for all the input symbol extension sections to keep the generic
+ BFD code happy. Temporarily turn it on to read the contents of
+ the symbol extension section.
+
+Sun Sep 11 21:58:59 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * config/hppaosf.mh (RANLIB): Do not set.
+ * config/hppabsd.mh (RANLIB): Likewise.
+
+Sun Sep 11 22:50:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * cf-i386lynx.c: Remove #if 0 code.
+ (i386_lynxos_coff_object_p): Remove unused function.
+ (coff_bfd_link_add_symbols): Define.
+ (lynx_link_add_symbols): New static function.
+ * coffcode.h (coff_bfd_link_hash_table_create): If
+ coff_relocate_section is defined, only define this if not already
+ defined.
+ (coff_bfd_link_add_symbols, coff_bfd_final_link): Likewise.
+
+ * linker.c (_bfd_generic_final_link): Handle
+ bfd_indirect_link_order explicitly, rather than via
+ _bfd_default_link_order.
+ (set_symbol_from_hash): New static function, broken out of
+ _bfd_generic_link_write_global_symbol.
+ (_bfd_generic_link_write_global_symbol): Symbol setting code moved
+ to set_symbol_from_hash; call it.
+ (default_indirect_link_order): Add generic_linker argument.
+ Change all callers. If false, set the generic symbols based on
+ the hash table entries.
+
+Fri Sep 9 11:51:49 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coffgen.c (coff_get_symtab): Reindented. Removed commented out
+ call to bfd_constructor_entry.
+
+ Convert m68k COFF to use new COFF backend linker.
+ * coff-m68k.c (coff_relocate_section): Define.
+ * cf-m68klynx.c (coff_rtype_to_howto): Define.
+ (coff_m68k_lynx_rtype_to_howto): New static function.
+ * configure.in (m68kcoff_vec): Build cofflink.o.
+ (m68kcoffun_vec, m68klynx_coff_vec): Likewise.
+
+Thu Sep 8 16:20:38 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * coff-h8300.c (h8300_reloc16_extra_cases, case RELBYTE): Flag
+ overflows correctly.
+
+Wed Sep 7 19:01:42 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * libelf.h (struct elf_backend_data): Change second argument of
+ elf_backend_final_write_processing hook to boolean.
+ (struct elf_obj_tdata): Add linker field.
+ * elfcode.h (NAME(bfd_elf,write_object_contents)): Pass value of
+ tdata linker field to final_write_processing, rather than NULL.
+ (elf_bfd_final_link): Don't call final_write_processing hook. Set
+ tdata linker field to true.
+ * elf32-mips.c (mips_elf_final_write_processing): Change type of
+ second argument to boolean.
+ * elf32-hppa.c (elf32_hppa_backend_final_write_processing):
+ Likewise.
+
+ * coff-go32.c (RTYPE2HOWTO): Fully parenthesize arguments.
+ * coff-i960.c (RTYPE2HOWTO): Likewise.
+ * coff-m88k.c (RTYPE2HOWTO): Likewise.
+ * coff-we32k.c (RTYPE2HOWTO): Likewise.
+
+ Make i386 COFF use new COFF backend linker.
+ * coff-i386.c (RTYPE2HOWTO): Fully parenthesize arguments.
+ (coff_relocate_section): Define.
+ (coff_i386_rtype_to_howto): New function.
+ * configure.in (i386coff_vec): Use cofflink.o.
+ (i386lynx_coff_vec): Likewise.
+
+ * coffcode.h (bfd_coff_backend_data): Add new field
+ _bfd_coff_rtype_to_howto.
+ (bfd_coff_rtype_to_howto): Define.
+ (coff_rtype_to_howto): Define to use RTYPE2HOWTO, if not already
+ defined.
+ (bfd_coff_std_swap_table): Initialize new field.
+ * cofflink.c (_bfd_coff_final_link): Allocate section_count + 1
+ section_info structures, since the target_index is 1 based.
+ (coff_link_input_bfd): Set *secpp to bfd_com_section_ptr for a
+ common symbol. Adjust rel_hash by the output reloc count.
+ (_bfd_coff_generic_relocate_section): New function.
+ * libcoff-in.h (_bfd_coff_generic_relocate_section): Declare.
+ * libcoff.h: Rebuild.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize new field.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+
+Tue Sep 6 23:28:52 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_derive_misc_symbol_info): Treat undefined code
+ symbols and undefined symbols which no type in the same manner
+ if the associated BFD symbol has BSF_FUNCTION set. For a defined
+ symbol which no type, select a SOM type based on the flags of the
+ section containing the symbol.
+ (som_slurp_symbol_type): Set BSF_FUNCTION for undefined ST_STUB
+ or ST_CODE symbols (importing a non-function code symbol is
+ meaningless in SOM).
+ (som_set_reloc_info): Don't set "offset" to the section's vma; it
+ should always start at zero.
+
+Tue Sep 6 14:51:11 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ Add new style linker support to COFF backend. a29k only for now.
+ * cofflink.c: New file.
+ * libcoff-in.h: Include bfdlink.h.
+ (obj_coff_external_syms, obj_coff_strings): Define accessor macro.
+ (obj_coff_sym_hashes): Define accessor macro.
+ (struct coff_tdata): Add fields external_syms, strings, and
+ sym_hashes.
+ (struct coff_link_hash_entry): Define.
+ (struct coff_link_hash_table): Define.
+ (coff_link_hash_lookup, coff_link_hash_traverse): Define.
+ (coff_hash_table): Define.
+ (_bfd_coff_link_hash_table_create): Declare.
+ (_bfd_coff_link_add_symbols, _bfd_coff_final_link): Declare.
+ * coffcode.h (bfd_coff_backend_data): Add fields _bfd_relsz,
+ _bfd_coff_swap_reloc_in, _bfd_coff_sym_is_global,
+ _bfd_coff_compute_section_file_positions,
+ _bfd_coff_relocate_section.
+ (bfd_coff_relsz, bfd_coff_swap_reloc_in): Define.
+ (bfd_coff_sym_is_global): Define.
+ (bfd_coff_compute_section_file_positions): Define.
+ (bfd_coff_relocate_section): Define.
+ (coff_mkobject_hook): Initialize obj_raw_syment_count and
+ obj_conv_table_size.
+ (coff_compute_section_file_positions): Set target_index of all
+ sections. Set output_has_begun field.
+ (coff_write_object_contents): Don't set target_index; now done by
+ coff_compute_section_file_positions. Remove obsolete handling of
+ scn_base and data_base. Don't bother to check that target_index
+ is positive, since it always is. Remove use of pad, which is
+ always zero. Check obj_raw_syment_count, not bfd_get_symcount,
+ for the number of symbols, but only write them out if
+ bfd_get_symcount is non-zero. Don't check obj_raw_syment_count
+ until after coff_write_symbols is called.
+ (coff_slurp_symbol_table): Use obj_raw_syment_count, not
+ bfd_get_symcount for the number of symbols. Don't set
+ obj_conv_table_size.
+ (coff_sym_is_global): New static function or macro.
+ (coff_slurp_reloc_table): Call coff_swap_reloc_in, not
+ bfd_swap_reloc_in.
+ (coff_bfd_link_hash_table_create): If coff_relocate_section is
+ defined, define as _bfd_coff_link_hash_table_create.
+ (coff_bfd_link_add_symbols): Similar change.
+ (coff_bfd_final_link): Similar change.
+ (coff_relocate_section): Define as NULL if not defined.
+ (bfd_coff_std_swap_table): Initialize new fields.
+ * coffgen.c (coff_real_object_p): Don't set obj_raw_syment_count
+ and obj_conv_table_size here.
+ (coff_count_linenumbers): Reindent. If bfd_get_symcount is zero,
+ add up the line numbers from the sections.
+ (coff_write_symbols): Set obj_raw_syment_count, not
+ bfd_get_symcount.
+ (coff_pointerize_aux): Don't pointerize a nonpositive x_endndx
+ field.
+ (coff_get_normalized_symtab): Use obj_raw_syment_count, not
+ bfd_get_symcount.
+ (coff_print_symbol): If auxp->fix_end, print x_endndx value.
+ * coffswap.h (coff_swap_reloc_in): Rename from bfd_swap_reloc_in.
+ Reindent. Change argument type to PTR.
+ * coff-a29k.c (coff_a29k_relocate_section): New static function.
+ (coff_relocate_section): Define.
+ * configure.in (a29kcoff_big_vec): Compile cofflink.o.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize new fields.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+ * libcoff.h: Rebuilt.
+ * Makefile.in: Rebuilt dependencies.
+ (BFD32_BACKENDS): Add cofflink.o.
+ (CFILES): Add cofflink.c.
+
+Tue Sep 6 14:00:45 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * coffgen.c (coff_print_symbol, case bfd_symbol_print_all): Check
+ for section symbol, and print its aux fields with appropriate
+ labels.
+
+ * Makefile.in (ALL_MACHINES): Added cpu-arm.o.
+
+Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+ * aoutx.h (NAME(aout,machine_type)): Recognize the ARM processor.
+ * archures.c, config.bfd, configure.host, libaout.h, reloc.c,
+ targets.c: Add support for the ARM.
+ * cpu-arm.c, riscix.c, config/riscix.mh, config/riscix.mt: New files.
+
+ * aoutx.h (add_to_stringtable): Check that str isn't a NULL pointer.
+
+Fri Sep 2 14:10:30 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * reloc.c (enum bfd_reloc_code_real): Rewrote definition to use
+ new "chew" commands for simultaneous definition of enumerator and
+ enumerator name table.
+ (bfd_get_reloc_code_name): New function, for retrieving a symbolic
+ name associated with an enumerator.
+ * libbfd.h, bfd-in2.h: Regenerated.
+
+Tue Aug 30 21:24:54 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_write_fixups, case R_ENTRY): Handle case where no
+ unwind descriptor information is available.
+
+Tue Aug 30 11:43:30 1994 Eric Youngdale (ericy@cais.cais.com)
+
+ * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add soname
+ argument, and use it to set DT_SONAME dynamic entry.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update prototype.
+ (bfd_elf64_size_dynamic_sections): Update prototype.
+ * bfd-in2.h: Rebuilt.
+
+Fri Aug 26 15:47:57 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coffgen.c (coff_real_object_p): Set obj_raw_syment_count.
+ (coff_get_normalized_symtab): Verify obj_raw_syment_count, rather
+ than setting it.
+
+Thu Aug 25 10:44:53 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * archive.c (bsd_write_armap): Remove host dependencies.
+
+ * aoutx.h (add_to_stringtab): Check for _bfd_stringtab_add error
+ before adding BYTES_IN_WORD.
+
+ * coffgen.c (coff_find_nearest_line): Look for the best C_FILE,
+ not merely the first.
+
+ * coffgen.c (coff_write_alien_symbol): If we are not using the
+ symbol, clear the name so that it is not put in the string table.
+ From Antti.Miettinen@ntc.nokia.com.
+
+Wed Aug 24 11:49:19 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coffgen.c (coff_print_symbol): Cast pointer different to long
+ and use %ld to print it.
+ * osf-core.c (osf_core_core_file_p): Remove unused variable
+ dseccnt.
+ * ecoffswap.h (ecoff_swap_ext_out): If ECOFF_64, clear remaining
+ bytes in bits2.
+
+ * configure.host, config.bfd: Change i[34]86 to i[345]86.
+ * coffgen.c (coff_real_object_p): Set obj_conv_table_size here,
+ rather than waiting until coff_slurp_symbol_table.
+ (coff_write_alien_symbol): Just ignore BSF_DEBUGGING symbols.
+ From Antti.Miettinen@ntc.nokia.com.
+
+ * section.c (bfd_make_section_anyway): Fix failure check of
+ bfd_make_empty_symbol. From Antti.Miettinen@ntc.nokia.com.
+
+ * aoutx.h (translate_to_native_sym_flags): Use the output_section
+ (and output_offset) if there is one.
+
+ * aoutx.h (aout_link_check_archive_element): Discard the symbols
+ if the archive element was not needed.
+
+ * aoutx.h (aout_get_external_symbols): Ensure that a zero string
+ index yields an empty string.
+ (aout_link_write_symbols): If info->keep_memory is false, use name
+ from original hash table entry, not from entry in *sym_hash.
+
+ * aoutx.h (struct aout_final_link_info): Add fields contents,
+ relocs, symbol_map and output_syms.
+ (NAME(aout,final_link)): Work out the largest section size, reloc
+ size, and number of symbols. Use them to preallocate buffers that
+ are large enough for all cases.
+ (aout_link_input_bfd): Use preallocated symbol_map.
+ (aout_link_write_symbols): Remove symbol_map argument; use
+ preallocated symbol_map instead. Change all callers. Use
+ preallocated output_syms.
+ (aout_link_input_section): Remove symbol_map argument. Change all
+ callers. Use preallocated contents and relocs.
+ (aout_link_input_section_std): Remove symbol_map argument; use
+ preallocated symbol_map instead. Change all callers.
+ (aout_link_input_section_ext): Likewise.
+
+Tue Aug 23 10:51:09 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * archive.c (_bfd_write_archive_contents): Don't update the
+ symbol map timestamp if there is no symbol map. From
+ schwab@issan.informatik.uni-dortmund.de (Andreas Schwab).
+
+Mon Aug 22 12:26:42 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * targets.c (BFD_JUMP_TABLE_ARCHIVE): Add _update_armap_timestamp.
+ (bfd_target): Add field _bfd_update_armap_timestamp.
+ * bfd.c (bfd_update_armap_timestamp): Define.
+ * bfd-in2.h: Rebuilt.
+ * libbfd-in.h (_bfd_noarchive_update_armap_timestamp): Define.
+ (_bfd_archive_bsd_update_armap_timestamp): Declare.
+ (_bfd_archive_coff_update_armap_timestamp): Define.
+ * libbfd.h: Rebuilt.
+ * archive.c (_bfd_write_archive_contents): Call
+ bfd_update_armap_timestamp instead of checking for a BSD archive
+ and calling bsd_update_armap_timestamp.
+ (_bfd_archive_bsd_update_armap_timestamp): Rename from
+ _bsd_update_armap_timestamp. Don't assume that armap_datepos is
+ already set.
+ * aout-target.h (MY_update_armap_timestamp): Define if not already
+ defined.
+ * coff-rs6000.c (rs6000coff_update_armap_timestamp): Define.
+ * ieee.c (ieee_update_armap_timestamp): Define.
+ * libecoff.h (_bfd_ecoff_update_armap_timestamp): Define.
+ * oasys.c (oasys_update_armap_timestamp): Define.
+ * som.c (som_update_armap_timestamp): Define.
+
+ * hash.c: Copy string hash functions from aoutx.h.
+ * aoutx.h: String hash functions moved to hash.c. Retain
+ simplified versions of add_to_stringtab and emit_stringtab.
+ Change all callers to use new function and structure names.
+ * libbfd-in.h (_bfd_stringtab_init, _bfd_stringtab_free): Declare.
+ (_bfd_stringtab_size, _bfd_stringtab_add): Declare.
+ (_bfd_stringtab_emit): Declare.
+ * libbfd.h: Rebuilt.
+
+Mon Aug 22 10:49:37 1994 Eric Youngdale (ericy@cais.cais.com)
+
+ * i386linux.c (linux_add_one_symbol): Create a fixup for any
+ defined absolute symbol, not just GOT or PLT symbols.
+ (linux_tally_symbols): Correct handling of references to defined
+ symbols.
+
+Thu Aug 18 16:29:57 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ Get ld -x -r to handle a.out set symbols correctly.
+ * aoutx.h (adjust_o_magic): If the .bss VMA was set outside of
+ BFD, pad the .data section up to the VMA of the .bss section.
+ (aout_link_add_symbols): If a set symbol does not get modified,
+ treat it as a local symbol.
+ (aout_link_write_symbols): Set the value of set symbols
+ correctly. Don't discard set symbols even if discarding local
+ symbols.
+ (aout_link_write_other_symbol): Don't abort on bfd_link_hash_new,
+ since it can now happen for set symbols.
+
+ * elfcode.h (elf_fake_sections): Just check for ".rela" and
+ ".rel", not ".rela." and ".rel."; make this work by checking
+ use_rela_p.
+ * elf32-i386.c (elf_i386_check_relocs): Just check for ".rel", not
+ ".rel."
+ (elf_i386_size_dynamic_sections): Likewise.
+ (elf_i386_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_check_relocs): Just check for
+ ".rela", not ".rela."
+ (elf32_sparc_size_dynamic_sections): Likewise.
+ (elf32_sparc_relocate_section): Likewise.
+
+Wed Aug 17 16:54:18 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * linker.c (_bfd_generic_link_add_archive_symbols): Initialize
+ PASS to the old value + 1.
+
+ * coffgen.c (coff_get_normalized_symtab): If a C_FILE symbol has
+ no aux entries, use the symbol name as the file name.
+ (coff_find_nearest_line): Look for the right C_FILE symbol, rather
+ than always using the first one. If there is a debugging symbol
+ after a function symbol, skip it. Add the section VMA to the line
+ offset, since it was subtracted out in coff_slurp_line_table.
+
+Tue Aug 16 16:53:00 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_prep_headers): If writing some form of an executable,
+ allocate and attach an exec header to the BFD private data.
+ (som_begin_writing): Don't fill fields of the exec header based
+ on BFD private data here (like the exec flags). Do not write
+ the exec header here.
+ (som_write_headers): Instead do it here.
+ * som.h (struct somdata): New field "exec_hdr" for the executable
+ file header.
+ (obj_som_exec_hdr): New accessor macro.
+
+Tue Aug 16 00:12:31 1994 Eric Youngdale (ericy@cais.cais.com)
+
+ * i386linux.c (linux_link_create_dynamic_sections): Create section
+ named .linux-dynamic, not .dynamic.
+ (linux_add_one_symbol): Use .linux-dynamic, not .dynamic.
+ (bfd_linux_size_dynamic_sections): Likewise.
+ (linux_finish_dynamic_link): Likewise.
+
+Mon Aug 15 12:16:56 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coffgen.c (STRING_SIZE_SIZE): Define.
+ (coff_fix_symbol_name): Use STRING_SIZE_SIZE, not 4.
+ (coff_write_symbols, build_string_table): Likewise.
+ (coff_get_normalized_symtab): Likewise.
+
+ * libcoff-in.h (obj_symbol_slew): Don't define.
+ (struct coff_tdata): Remove unused fields index_slew, raw_linenos,
+ and flags.
+ * libcoff.h: Rebuilt.
+ * coffcode.h (coff_mkobject): Don't initialize raw_linenos.
+ (coff_mkobject_hook): Don't initialize flags.
+
+ * aout-target.h (MY_zmagic_contiguous): Define as 0 if not already
+ defined.
+ (MY(backend_data)): Use MY_zmagic_contiguous, not hardcoded 0.
+ * i386linux.c (MY_zmagic_contiguous): Define.
+
+ * elfcode.h (bfd_section_from_shdr): If a SHT_SYMTAB section in a
+ shared object has SHF_ALLOC set, create a BFD section for it.
+ (elf_section_from_bfd_section): There may be a BFD section for a
+ SHT_SYMTAB section.
+
+ * coffcode.h (styp_to_sec_flags): Add name argument. If no flags
+ are recognized, chose section flags based on the name.
+ (bfd_coff_backend_data): _bfd_styp_to_sec_flags_hook field: Add
+ name argument.
+ (bfd_coff_styp_to_sec_flags_hook): Add name argument.
+ (coff_compute_section_file_positions): Don't adjust the section
+ position by COFF_PAGE_SIZE unless SEC_ALLOC is set.
+ * libcoff.h: Rebuilt.
+ * coffgen.c (make_a_section_from_file): Pass section name to
+ bfd_coff_styp_to_sec_flags_hook.
+ * ecoff.c (_bfd_ecoff_styp_to_sec_flags): Add unused name
+ argument.
+ * libecoff.h (_bfd_ecoff_styp_to_sec_flags): Add name argument to
+ prototype.
+
+Fri Aug 12 11:22:40 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (section_from_elf_index): Correct check for invalid
+ section index.
+
+ * elfcode.h (elf_link_add_object_symbols): If there is no symbol
+ table, try using the dynamic symbol table. From Eric Youngdale
+ <ericy@cais.cais.com>.
+
+ * configure.host (sparc-*-solaris2*): Use solaris2, not sysv4.
+ The linker depends upon configuring for solaris2.
+ * hosts/solaris2.h: New file; include hosts/sysv4.h.
+ * config/solaris2.mh: New file; copy of config/sysv4.mh.
+
+Wed Aug 10 13:09:38 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * aoutx.h (adjust_z_magic): Make sure data section is padded to
+ page boundary when the VMA is set by the calling program. From
+ Eric Youngdale <ericy@cais.cais.com>.
+
+Mon Aug 8 17:18:49 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ Update to ns32k support, from Ian Dall (dall@hfrd.dsto.gov.au).
+ * aout-ns32k.c: Add declarations that were in aout-ns32k.h, change
+ declarations to traditional form.
+ (MY_reloc_howto, MY_put_reloc): Change from macro to function.
+ (ns32k_relocate_contents): New function.
+ * aout-ns32k.h: Remove.
+ * cpu-ns32k.c: Add declarations that were in aout-ns32k.h, change
+ declarations to traditional form.
+ (ns32k_final_link_relocate): Call ns32k_relocate_contents.
+ * netbsd532.c: Reformat to standards, add copyright notice.
+ (ARCH): Don't define.
+ (aout-ns32k.h): Don't include.
+ * pc532-mach.c: Ditto.
+
+Mon Aug 8 17:55:52 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coff-i960.c (coff_i960_relocate): Don't try to convert relocs
+ against common symbols.
+
+Sat Aug 6 22:27:30 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * irix-core.c (irix_core_core_file_p): Ignore sections that
+ are not contained in the core file.
+
+Thu Aug 4 11:32:23 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coff-m68k.c (m68k_reloc_type_lookup): New function.
+ (coff_bfd_reloc_type_lookup): Define.
+ * cf-m68klynx.c (_bfd_m68kcoff_reloc_type_lookup): Define.
+
+ * elfcode.h (elf_bfd_final_link): Force the vma of sections which
+ do not have SEC_ALLOC set to be 0. This is needed to handle
+ relocs against debugging sections.
+
+Wed Aug 3 16:45:41 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coff-i960.c (coff_i960_relocate): Rewrote to change relocs
+ against locally defined symbols into relocs against section
+ symbols, for VxWorks 5.1.
+
+Wed Aug 3 10:34:37 1994 Eric Youngdale (ericy@cais.cais.com)
+
+ * i386linux.c (linux_add_one_symbol): Only handle
+ SHARABLE_CONFLICTS specially if BSF_CONSTRUCTOR is set. Set hashp
+ for a GOT or PLT symbol. Set jump field of fixup for a PLT symbol.
+ (linux_tally_symbols): Check section of real symbol. When looking
+ for a builtin fixup, check builtin and jump flags. Create no more
+ than one fixup, and always create one if the real symbol is in the
+ absolute section. Only strip absolute symbols.
+
+Wed Aug 3 05:08:24 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * coffcode.h (coff_write_object_contents): set internal_a.magic to
+ LYNXCOFFMAGIC whenever 68k, SPARC or i386 LynxOS
+ (yes, they have the same magic number!)
+
+Tue Aug 2 10:43:21 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * hp300hpux.c (BMAGIC): Define as HPUX_DOT_O_MAGIC, to make test
+ in aoutx.h work correctly.
+
+ * coff-i960.c (coff_i960_relocate): New function.
+ (howto_rellong, howto_iprmed): Use it as special_function.
+
+ * libbfd-in.h: Move declarations of bfd_read, bfd_write, bfd_seek,
+ bfd_tell, bfd_flush, and bfd_stat from here...
+ * bfd-in.h: ...to here, to make them visible to programs which
+ know more about the object file format than BFD does.
+ * libbfd.h, bfd-in2.h: Rebuilt.
+
+Mon Aug 1 17:55:53 1994 Fred Fish (fnf@cygnus.com)
+
+ * ptrace-core.c (ptrace_unix_core_file_p): Convert zalloc usage
+ to bfd_zalloc.
+
+Mon Aug 1 12:04:40 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elf64-sparc.c (ELF_MAXPAGESIZE): Define.
+
+ ELF linker patches from Eric Youngdale <ericy@cais.cais.com>.
+ * elfcode.h (elf_link_create_dynamic_sections): Set type of
+ _DYNAMIC to STT_OBJECT.
+ (NAME(bfd_elf,record_link_assignment)): Always create hash table
+ entry. Set type to STT_OBJECT.
+ (elf_link_output_extsym): Don't set type of weak defined symbol to
+ STB_WEAK if symbol was referenced.
+ (map_program_segments): Check DYNAMIC as well as EXEC_P.
+ (assign_file_positions_except_relocs): Likewise.
+ * elf32-i386.c (elf_i386_create_dynamic_sections): Set type of
+ _GLOBAL_OFFSET_TABLE to STT_OBJECT.
+ (elf_i386_check_relocs): Ignore local PLT32 relocs.
+ (elf_i386_relocate_section): Treat local PLT32 relocs as PC32.
+
+ * elfcode.h (elf_adjust_dynamic_symbol): Correct weak symbol
+ handling again.
+
+ * elfcode.h (elf_slurp_reloc_table): Don't try to read the relocs
+ if there aren't any.
+
+ * configure.host (sparc-*-solaris2*): Use sysv4, not solaris2.
+ * hosts/solaris2.h: Remove.
+ * config/solaris2.mh: Remove.
+
+Sun Jul 31 14:27:04 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c, elf32-hppa.h: Update comment reflecting which
+ HPPA ELF spec the code implements.
+
+Tue Jul 26 17:38:01 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * cpu-i960.c (MAX_ARCH): New macro.
+ (compatible): Use it in computing array bounds. Put comma after
+ last entry in array, for regularity.
+ (arch_info_struct): Adjust spacing for easier reading.
+
+ * coff-i960.c (howto_rellong, howto_iprmed, howto_optcall): Use
+ HOWTO macro.
+
+ * cpu-i960.c (JX): Define as bfd_mach_i960_jx.
+ (scan_960_mach): Recognize jx machine.
+ (MAX_ARCH): Define to be JX.
+ (compatible): Add JX row to array.
+ (arch_info_struct): Add JX entry.
+
+ * archures.c (bfd_mach_i960_jx): New macro.
+ * bfd-in2.h: Regenerated.
+
+ * coffcode.h (coff_set_arch_mach_hook): For F_I960JX, set machine
+ to bfd_mach_i960_jx.
+ (coff_set_flags): For bfd_mach_i960_jx, set F_I960JX.
+
+Tue Jul 26 11:04:00 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (elf_adjust_dynamic_symbol): When handling a weak
+ symbol, correct check to see whether the equivalent normal symbol
+ was referenced.
+
+ Add support for creating shared libraries under i386 ELF and SPARC
+ ELF. Based on patches by Eric Youngdale <ericy@cais.cais.com>.
+ * libelf.h (struct elf_link_hash_entry): Remove copy_offset field.
+ Add got_offset and plt_offset fields.
+ (ELF_LINK_HASH_REF_DYNAMIC_MULTIPLE): Don't define.
+ (ELF_LINK_HASH_DEF_DYNAMIC_MULTIPLE): Don't define.
+ (ELF_LINK_HASH_NEEDS_COPY): Define.
+ (struct elf_backend_data): Add check_relocs field.
+ (struct bfd_elf_section_data): Change relocs from PTR to
+ Elf_Internal_Rela *.
+ (struct elf_obj_tdata): Add local_got_offsets field.
+ (elf_local_got_offsets): Define accessor macro.
+ (bfd_elf32_link_create_dynamic_sections): Declare.
+ (bfd_elf32_link_record_dynamic_symbol): Declare.
+ (bfd_elf64_link_create_dynamic_sections): Declare.
+ (bfd_elf64_link_record_dynamic_symbol): Declare.
+ * elfcode.h (elf_slurp_reloc_table): Don't use the section data
+ relocs field.
+ (elf_link_record_dynamic_symbol): Make globally visible. Use
+ macro to rename to NAME(bfd_elf,link_record_dynamic_symbol).
+ (elf_link_add_object_symbols): If creating a shared library, put
+ make all local symbols dynamic. Don't bother with the
+ DYNAMIC_MULTIPLE flags. Call the check_relocs backend function if
+ it is defined.
+ (elf_link_create_dynamic_sections): Make globally visible. Use
+ macro to rename to NAME(bfd_elf,link_create_dynamic_sections). If
+ creating a shared library, make sure that _DYNAMIC is added as a
+ dynamic symbol.
+ (elf_link_read_relocs): New function.
+ (NAME(bfd_elf,record_link_assignment)): If creating a shared
+ library, always create symbols, and always make them dynamic.
+ (elf_bfd_final_link): Permit creation of shared libraries.
+ (elf_link_input_bfd): Use elf_link_read_relocs to get the relocs.
+ * elf.c (_bfd_elf_link_hash_newfunc): Don't initialize
+ copy_offset. Initialize got_offset and plt_offset.
+ * elf32-target.h (elf_backend_check_relocs): Define as 0 if not
+ defined.
+ (elf32_bed): Initialize check_relocs field.
+ * elf64-target.h (elf_backend_check_relocs): Define as 0 if not
+ defined.
+ (elf64_bed): Initialize check_relocs field.
+ * elf32-i386.c (elf_howto_table): Change R_386_PLT32 and
+ R_386_GOTPC to be pc_relative and pcrel_offset.
+ (elf_i386_pic_plt0_entry): Define.
+ (elf_i386_pic_plt_entry): Define.
+ (elf_i386_create_dynamic_sections): Create a .got.plt section, and
+ define _GLOBAL_OFFSET_TABLE_ at the start of it. If creating a
+ shared library, make sure that _GLOBAL_OFFSET_TABLE_ is added as a
+ dynamic symbol. Don't create .rel.bss if creating a shared
+ library.
+ (elf_i386_check_relocs): New function.
+ (elf_i386_adjust_dynamic_symbol): Don't make a PLT entry if the
+ symbol already has one. When making a PLT entry, set plt_offset.
+ Don't create a copy reloc when creating a shared library. Don't
+ set copy_offset, just set ELF_LINK_HASH_NEEDS_COPY.
+ (elf_i386_allocate_dynamic_section): Remove.
+ (elf_i386_size_dynamic_sections): Look through all the sections
+ rather than assuming we know their names. Remove any empty reloc
+ or plt sections. Only add a DT_DEBUG entry if not creating a
+ shared library. Only add a DT_PLTGOT entry if there is a PLT.
+ Add a DT_TEXTREL entry if required.
+ (elf_i386_relocate_section): Permit undefined symbols when
+ creating a shared library. Handle the special relocation types
+ specially.
+ (elf_i386_finish_dynamic_symbol): Create a PLT entry if plt_offset
+ is set. If creating a shared library, produce a PIC PLT entry.
+ Only mark a PLT symbol as undefined if it was not defined by a
+ regular object file. Create a GOT entry if got_offset is set.
+ Create a copy reloc if ELF_LINK_HASH_NEEDS_COPY is set.
+ (elf_i386_finish_dynamic_sections): Change the handling of
+ DT_RELSZ to simply subtract out the size of .rel.plt. If creating
+ a shared library, produce PIC PLT code.
+ (elf_backend_check_relocs): Define.
+ * elf32-sparc.c (elf_sparc_howto_table): Change R_SPARC_GOT10,
+ R_SPARC_GOT22, and R_SPARC_PC10 to not warn about reloc overflow.
+ (elf32_sparc_create_dynamic_sections): If creating a shared
+ library, make sure that _GLOBAL_OFFSET_TABLE_ is added as a
+ dynamic symbol, and set the type to STT_OBJECT. Likewise for
+ _PROCEDURE_LINKAGE_TABLE_. Don't create .rel.bss if creating a
+ shared library.
+ (elf32_sparc_check_relocs): New function.
+ (elf32_sparc_adjust_dynamic_symbol): Don't make a PLT entry if the
+ symbol already has one. When making a PLT entry, set plt_offset.
+ Don't create a copy reloc when creating a shared library. Don't
+ set copy_offset, just set ELF_LINK_HASH_NEEDS_COPY.
+ (elf32_sparc_allocate_dynamic_section): Remove.
+ (elf32_sparc_size_dynamic_sections): Look through all the sections
+ rather than assuming we know their names. Only add a DT_DEBUG
+ entry if not creating a shared library. Add a DT_TEXTREL entry if
+ required.
+ (elf32_sparc_relocate_section): Permit undefined symbols when
+ creating a shared library. Handle the special relocation types
+ specially.
+ (elf32_sparc_finish_dynamic_symbol): Create a PLT entry if plt_offset
+ is set. Only mark a PLT symbol as undefined if it was not defined
+ by a regular object file. Create a GOT entry if got_offset is
+ set. Create a copy reloc if ELF_LINK_HASH_NEEDS_COPY is set.
+ (elf32_sparc_finish_dynamic_sections): Store dynobj in a local
+ variable.
+ (elf_backend_check_relocs): Define.
+
+Mon Jul 25 12:21:07 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * configure.in (pc532mach_vec): Change to pc532machaout_vec.
+ * config.bfd (ns32k-*-netbsd*): Use ns32k-nbsd as bfd_name.
+ * Makefile.in (ALL_MACHINES): Add cpu-ns32k.o.
+ (BFD32_BACKENDS): Add aout-ns32k.o, netbsd532.o, m88kmach3.o,
+ pc532-mach.o.
+ * targets.c (pc532machaout_vec): Use instead of pc532mach_vec.
+ * config/pc532-mach.mt (DEFAULT_VECTOR): Ditto.
+ (SELECT_VECS): Remove.
+ * config/ns32k-nbsd.mt: New file, was ns32k-netbsd.mt.
+ * config/ns32k-netbsd.mt: Remove, name too long.
+
+Fri Jul 22 11:07:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * linker.c (generic_link_check_archive_element): When changing a
+ symbol to common, set the alignment.
+ (_bfd_generic_link_add_one_symbol): When creating a common symbol,
+ set the alignment.
+ * aoutx.h (aout_link_check_ar_symbols): When changing a symbol to
+ common, set the alignment.
+ (aout_link_add_symbols): Restrict the alignment of a common symbol
+ to the alignment power given by the architecture.
+ * libelf.h (struct elf_link_hash_entry): Remove align field. Add
+ copy_offset field.
+ * elfcode.h (elf_link_add_object_symbols): Store alignment in
+ new bfd_link_hash_entry field, not in elf_link_hash_entry field.
+ (elf_link_output_extsym): Similar change when getting alignment.
+ * elf.c (_bfd_elf_link_hash_newfunc): Don't initialize align. Do
+ initialize copy_offset.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use copy_offset
+ field rather than align field. Get alignment using bfd_log2
+ rather than switch.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+ * elf32-i386.c (elf_i386_finish_dynamic_symbol): Use copy_offset,
+ not align.
+ * elf32-sparc.c (elf32_sparc_finish_dynamic_symbol): Likewise.
+
+ * aoutx.h (NAME(aout,some_aout_object_p)): Just check
+ STAT_FOR_EXEC, don't check MACH.
+ * m88kmach3.c (MACH): Don't define.
+ * config/i386-mach3.mt (TDEFINES): Define STAT_FOR_EXEC.
+ * config/m88k-mach3.mt (TDEFINES): Likewise.
+ * config/mips-mach3.mt (TDEFINES): Likewise.
+
+Thu Jul 21 17:24:31 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * i386mach3.c: Reverted to version from before Jul 5 1994 changes.
+
+Thu Jul 21 12:26:01 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * reloc.c (struct reloc_howto_struct): Remove special_function1.
+ It's the wrong way to do things.
+ (HOWTO): Change accordingly.
+ (HOWTO2): Remove.
+ (_bfd_final_link_relocate): Remove references to
+ special_function1.
+ * bfd-in2.h: Rebuilt.
+ * aoutx.h (aout_link_input_section_std): Remove references to
+ special_function1.
+ (aout_link_reloc_link_order): Likewise.
+
+Wed Jul 20 15:46:44 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add rpath
+ argument. If it is not NULL, use it to set DT_RPATH.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update prototype.
+ (bfd_elf64_size_dynamic_sections): Likewise.
+ * bfd-in2.h: Rebuilt.
+
+Sat Jul 16 21:10:39 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (elf_get_dynamic_symtab_upper_bound): If there is no
+ dynamic symtab, return error.
+
+ * libelf.h (ELF_LINK_HASH_DEFINED_WEAK): Define.
+ * elfcode.h (elf_link_add_object_symbols): If symbol is defined as
+ weak, set ELF_LINK_HASH_DEFINED_WEAK.
+ (elf_link_output_extsym): If symbol is defined as weak, mark it
+ STB_WEAK.
+
+ * libelf.h (struct bfd_elf_section_data): Add relocs field.
+ (shdr_name): Remove; unused.
+ * elfcode.h (elf_slurp_reloc_table): Rewrote to handle both REL
+ and RELA relocs. Free up the unswapped relocs. Permit the relocs
+ to be cached in the section_data. Correct the reloc address.
+ (elf_slurp_reloca_table): Remove.
+ (elf_canonicalize_reloc): Rewrote.
+ (elf_link_input_bfd): Permit the relocs to be cached in the
+ section data.
+
+Sat Jul 16 13:55:38 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * config.bfd (m88*-harris-cxux*): Recognize.
+ * hosts/harris.h (POSIX_UTIME, HAVE_PROCFS): Define.
+
+ * configure.host (m68*-atari-sysv4*): New host.
+ (m68*-cbm-sysv4*): Use m68kv4 instead of amix.
+ * hosts/amix.h: Remove.
+ * hosts/m68kv4.h: New file, was amix.h.
+
+Thu Jul 14 15:12:24 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * reloc.c (enum bfd_reloc_code_real, bfd_type, struct
+ reloc_howto_struct, reloc_howto_type, HOWTO, HOWTO2): Copied
+ changes over from bfd-in2.h so they get generated properly next
+ time someone runs "make headers".
+ * bfd-in2.h: Rebuilt.
+
+ * targets.c (netbsd532_vec, pc532mach_vec): Declare const.
+ (m88kmach3_vec): Restore deleted declaration.
+
+ * configure.in: Alphabetize target vector names.
+
+ * config/pc532mach.mh: New file.
+ (HDEPFILES, HDEFINES): Define here.
+ * config/pc532-mach.mt (HDEPFILES, HDEFINES): Deleted.
+ * config/ns32k-netbsd.mt (HDEPFILES, HDEFINES): Deleted.
+
+ Sun Jul 10 00:04:20 1994 Ian Dall (dall@hfrd.dsto.gov.au)
+
+ * pc532-mach.c: New File. pc532-mach a.out format.
+
+ * netbsd532.c: New file. pc532-netbsd532 a.out format.
+
+ * hosts/pc532mach.h: New file. pc532-mach host support.
+
+ * cpu-ns32k.c: New file. ns32k support cpu specific code rather
+ than format specific code.
+
+ * config/pc532-mach.mt: New file. Support for pc532-mach target.
+
+ * config/ns32k-netbsd.mt: New file. Support for netbsd532 target.
+
+ * aout-ns32k.c, aout-ns32k.h: New files supporting aout format for
+ ns32k series.
+
+ * targets.c: Add netbsd532_vec and pc532machaout_vec into
+ bfd_target_vector array. Move netbsd386_vec to alphabetic order
+ location.
+
+ * reloc.c (_bfd_final_link_relocate) Add support for
+ special_function1 in howto.
+
+ * libaout.h: add M_NS32032, M_NS32532, M_532_NETBSD entries in
+ machine_type enum.
+
+ * configure.in: add pc532mach_vec and netbsd532_vec entries.
+
+ * config.bfd: add pc532mach host entries. Use for both
+ ns32k-pc532-mach and ns32k-pc532-netbsd.
+
+ * config.bfd: it doesn't work to use i386-mach3 for ns32k*-*-mach.
+ add ns32k-pc532-mach* and ns32k-*-netbsd* entries.
+
+ * bfd-in2.h: Add ns32k specific relocations to bfd_reloc_code_real
+ enum.
+
+ * bfd-in2.h: Add special_function1 to struct howto. Change HOWTO
+ and NEWHOWTO macros to make special_function1 NULL. Neww HOWTO2
+ macro.
+
+ * bfd-in2.h: Split definition of struct reloc_howto_struct
+ and corresponding typedef into two statements.
+
+ * bfd-in2.h: Add entry bfd_arch_ns32k to bfd_architecture enum.
+
+ * archures.c: Add bfd_ns32k_arch prototype, and entry in
+ archures_init_table.
+
+ * aoutx.h (aout_link_reloc_link_order): Allow for target dependent
+ MY_put_reloc macro. Allow for target dependent special_function1
+ to apply the relocation.
+
+ * aoutx.h (aout_link_input_section_std): Allow for target
+ dependent determination of reloc howto. Allow for target dependent
+ special_function1 to apply the relocation.
+
+ * aoutx.h (get_reloc_upper_bound): Detect bss and return 0.
+
+ * aoutx.h (slurp_reloc_table): Detect bss and succesfully read
+ zero reloc entries.
+
+ * aoutx.h (machine_type): Add bfd_arch_ns32k case.
+
+ * aoutx.h: Stat to determine executable status if STAT_FOR_EXEC
+ is defined (not just MACH). Use fstat instead of stat and check
+ for fstat error.
+
+ * aoutx.h: Allow target dependent swap_std_reloc_{in,out}.
+
+ * aoutx.h: Allow CTORS reloc info to be in target dependent reloc
+ table.
+
+ * aout-target.h: Apply SWAP_MAGIC (if defined) after
+ swap_exec_header_in, otherwise we have magic in the wrong order.
+
+Thu Jul 14 11:47:27 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * coff-sparc.c (sparccoff_vec): Have leading underscores.
+
+Tue Jul 12 12:08:10 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * aix386-core.c, aoutf1.h, cisco-core.c, elfcode.h, hppabsd-core.c,
+ hpux-core.c, irix-core.c, lynx-core.c, osf-core.c, ptrace-core.c,
+ rs6000-core.c, trad-core.c: Remove SEC_ALLOC flag from .reg
+ sections, .reg sections are not allocated and contain debug
+ information only.
+ * osf-core.c (make_bfd_asection, osf_core_core_file_p): Use
+ bfd_make_section_anyway instead of building unique section names.
+
+Tue Jul 12 11:41:22 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * libelf.h (bfd_elf32_swap_symbol_in): Declare.
+ (bfd_elf32_swap_symbol_out): Declare.
+ (bfd_elf64_swap_symbol_in, bfd_elf64_swap_symbol_out): Declare.
+ * elf32-hppa.c (elf32_hppa_args_hash_table_init): Correct cast.
+
+ * aout-encap.c (ARCH): Don't define. Obsolete.
+ * aout0.c, aoutx.h, gen-aout.c, hp300bsd.c, hp300hpux.c: Likewise.
+ * i386aout.c, i386bsd.c, i386dynix.c, i386linux.c: Likewise.
+ * i386lynx.c, m68klynx.c, mipsbsd.c, netbsd386.c: Likewise.
+ * newsos3.c, sparclynx.c, sunos.c: Likewise.
+
+Mon Jul 11 20:08:23 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * section.c (STD_SECTION): Make the sixth argument boolean, not
+ the seventh. From gary@tuva.pacsemi.oz.au (gary kopff).
+
+Sun Jul 10 09:12:02 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * aoutx.h (bfd_free_cached_info): Change name of FREE to BFCI_FREE
+ in order not to collide with LynxOS's definition of FREE in
+ /usr/include/sys/proc.h
+
+Thu Jul 7 14:18:06 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * reloc.c (bfd_perform_relocation): Don't clobber the relocation
+ value for coff-Intel-little or coff-Intel-big. Hack upon hack.
+
+Thu Jul 7 10:10:34 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * aoutx.h (howto_table_std): Add entry for GOT relocations
+ which are present in sun3 shared libraries, to avoid assertions
+ when reading the dynamic relocations.
+
+Thu Jul 7 10:19:20 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.h (R_HPPA_COMPLEX): Fix dumb typo.
+
+Wed Jul 6 19:21:57 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * hosts/sysv4.h (qsort, strtol): Don't declare.
+
+ * elfcode.h (elf_link_output_sym): Don't call output_symbol_hook
+ if it is NULL.
+
+ * elf32-mips.c (mips_elf_final_write_processing): Add ignored info
+ argument to correspond to recent libelf.h change.
+
+Wed Jul 6 00:48:57 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * coff-alpha.c (alpha_ecoff_mkobject_hook): New hook to
+ additionally copy object type information from the alpha file
+ header to the BFD flags.
+ (alpha_ecoff_backend_data): Use it.
+ (ecoffalpha_little_vec): Add DYNAMIC to object_flags.
+ * aout64.c: Fix typo in conditional QMAGIC definition.
+
+Wed Jul 6 00:13:17 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppabsd-core.c (hppabsd_core_core_file_p): Sanity check the
+ value of clicksz to help weed out non HPPA BSD core files.
+
+Tue Jul 5 13:26:02 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ Mach 3 support.
+ * config.bfd (m88*-*-mach3*, mips*-dec-mach3*, mips*-*-mach3*):
+ New targets.
+ * configure.host (i[34]86-*-mach3*, ns32k-*-mach3*): Recognize
+ "mach3" instead of "mach".
+ (m88*-*-mach3*, mips*-dec-mach3*, mips*-*-mach3*): New hosts.
+ * targets.c (m88kmach3_vec): New target vector.
+ (bfd_target_vector): Add i386mach3_vec and m88kmach3_vec, but
+ inside #if 0.
+ * aoutx.h (some_aout_object_p) [MACH]: Recognize executables by
+ checking for execute permission, instead of looking at entry
+ point.
+ * i386mach3.c: Update, define MACH, N_TXTOFF, N_TXTADDR,
+ N_SHARED_LIB, don't include aout/*.h files, etc.
+ * m88kmach3.c: New file, m88k Mach 3 target.
+ * config/m88k-mach3.mt, config/mips-mach3.mt: New files, target
+ makefile fragments.
+ * config/i386mach3.mh, config/m88kmach3.mh, config/mipsmach3.mh:
+ New files, host makefile fragments.
+ * hosts/m88kmach3.h, hosts/mipsmach3.h: New files, host definitions.
+
+Tue Jul 5 13:56:52 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * elfcode.h (swap_out_syms): Get alignment of common symbol from
+ st_value field of saved ELF symbol information, if there is any.
+
+Mon Jul 4 19:13:32 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.h (R_HPPA_COMPLEX): Define.
+ * elf32-hppa.h (R_HPPA_COMPLEX): Define.
+ (elf32_hppa_reloc_type): Delete R_PARISC_STUB_CALL_17.
+
+Fri Jul 1 12:07:41 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * Support code for enabling the new style linker for PA ELF.
+ * elfcode.h (swap_symbol_in, swap_symbol_out): Externalize.
+ (elf_compute_section_file_positions): Pass link_info to
+ the begin_write_processing hook.
+ (bfd_elf_write_object_contents): Pass NULL for new link_info
+ argument to final_write_processing hook.
+ (elf_link_output_sym): Accept new "input_section" argument for
+ the symbols's input section. All callers changed. Call the
+ link_output_symbol_hook if it's defined.
+ (elf_bfd_final_link): Call the final_write_processing hook if
+ it's defined.
+ * libelf.h (elf_backend_link_output_symbol_hook): Declare.
+ (elf_backend_begin_write_processing): Add new "info" argument.
+ (elf_backend_final_write_processing): Likewise.
+ * elf32-target.h (elf_backend_link_output_symbol_hook): Provide
+ a default definition.
+ (elf32_bed): Add elf_backend_link_output_symbol_hook.
+ * elf64-target.h: Likewise.
+
+ * Major rework of the PA ELF code. Uses the new style BFD
+ linker, major cleanups.
+ * hppa_stubs.h: Rewrite from scratch. Much smaller and simpler.
+ * elf32-hppa.h: Delete all symbol extension related code.
+ (hppa_look_for_stubs_in_section): Delete decl.
+ (elf32_hppa_size_stubs, elf32_hppa_build_stubs): New decls.
+ * elf32-hppa.c: Symbol extension stuff moved form elf32-hppa.h
+ into elf32-hppa.c. Do not include aout64.h.
+ (typdef hppa_stub_type): Delete.
+ (elf32_hppa_stub_name_list_struct): Delete.
+ (elf32_hppa_stub_description_struct): Delete.
+ (arg_reloc_type): Use simpler enumerations. All references changed.
+ (arg_location, arg_reloc_relocation): Likewise.
+ (elf32_hppa_symextn_map_struct): Delete.
+ (get_symbol_value): Delete.
+ (elf32_hppa_get_sym_extn): Delete.
+ (find_stubs, new_stubs, type_of_mismatch): Delete.
+ (find_stub_by_name, add_stub_by_name): Delete.
+ (hppa_elf_stub_finish, hppa_elf_stub_reloc): Delete.
+ (hppa_elf_arg_reloc_needed): Renamed. Simplify.
+ (hppa_elf_build_linker_stub, hppa_elf_create_stub_sec): Delete.
+ (hppa_elf_long_branch_needed_p): Delete.
+ (hppa_look_for_stubs_in_section): Delete.
+ (hppa_elf_get_section_contents): Delete.
+ (elf32_hppa_backend_symbol_processing): Delete.
+ (elf32_hppa_backend_section_processing): Delete.
+ (elf32_hppa_backend_section_from_shdr): Delete.
+ (elf32_hppa_backend_fake_sections): Delete.
+ (elf32_hppa_backend_section_from_bfd_section): Delete.
+ (NEW_INSTRUCTION): Delete.
+ (CURRENT_STUB_OFFSET): Delete.
+ (elf32_hppa_relocate_section): New function.
+ (elf32_hppa_bfd_final_link_relocate): New function.
+ (elf32_hppa_size_symext): New function.
+ (elf32_hppa_link_output_symbol_hook): New function.
+ (elf32_hppa_read_symext_info): New function.
+ (elf32_hppa_add_symbol_hook): New function.
+ (elf32_hppa_name_of_stub): New function.
+ (elf32_hppa_size_of_stub): New function.
+ (elf32_hppa_build_one_sub): New function.
+ (elf32_hppa_build_stubs): New function.
+ (elf32_hppa_size_stubs): New function.
+ (linker, stub and argument hash tables): Add appropriate
+ structures, definitions and functions to implement all three
+ hash tables.
+ (hppa_elf_relocate_insn): Don't need argument location information
+ in this function.
+ (add_entry_to_symext_chain): Accept a symbol's argument location
+ information rather than the symbol itself. All callers changed.
+ (hppa_elf_gen_reloc_type): Simplify.
+ (hppa_elf_set_section_contents): Stub section is no longer special.
+ (hppa_elf_reloc): Greatly simplify.
+ (elf32_hppa_begin_write_processing): Accept link_info argument.
+ Handle being called from the BFD backend linker.
+ (elf32_hppa_final_write_processing): Likewise.
+ (elf_hppa_tc_make_sections): No longer call stub_finish.
+
+Mon Jun 27 18:07:06 1994 Steve Chamberlain (sac@cirdan.cygnus.com)
+
+ * section.c (bfd_get_section_contents): Put in parens to get
+ precedence right.
+
+Sun Jun 26 18:08:29 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * libelf.h (relocate_section): New argument "output_names" added
+ to prototype.
+ * elfcode.h (elf_link_input_bfd): New argument "output_names"
+ added to prototype of relocate_section. Pass the output symbol
+ names to relocate_section.
+ * elf32-i386.c (elf_i386_relocate_section): Use "output_names" to
+ determine the name of a local symbol.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+Fri Jun 24 08:15:42 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ Add Solaris BCP (the part of Solaris which allows it to run
+ SunOS4 a.out files) core file handling.
+ * aoutf1.h (external_solaris_bcp_core, swapcore_solaris_bcp):
+ New structure and its swap in function.
+ (internal_sunos_core): New member c_data_addr, to receive the
+ start address of the data section in the core file.
+ (swapcore_sun3, swapcore_sparc, sunos4_core_file_p): Use it.
+ (sunos4_core_file_p): Recognize Solaris BCP core file.
+ (sunos4_core_file_matches_executable_p): Always indicate match
+ for Solaris BCP core files.
+
+Thu Jun 23 15:31:28 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ Preliminary support for generating shared libraries, from Eric
+ Youngdale <ericy@cais.cais.com>.
+ * elfcode.h (prep_headers): If DYNAMIC, set e_type to ET_DYN.
+ (elf_link_add_object_symbols): If generating a shared library,
+ create dynamic sections for first input BFD with the right format.
+ (elf_link_create_dynamic_sections): Don't create .interp section
+ if creating a shared library.
+ (elf_link_input_bfd): Skip dynamic sections in input file.
+ (elf_bfd_final_link): If creating a shared library, it's OK for
+ dynobj to have sections which are not SEC_IN_MEMORY.
+ * elf32-i386.c (elf_i386_size_dynamic_sections): Only set .interp
+ section if not creating a shared library.
+ * elf32-sparc.c (elf_sparc_size_dynamic_sections): Likewise.
+
+ * elfcode.h (elf_object_p): Don't set DYNAMIC just because there
+ is an SHT_DYNAMIC section.
+
+ * cf-i386lynx.c (i386coff_vec): Don't include DYNAMIC in
+ object_flags.
+ * coff-sparc.c (sparccoff_vec): Likewise.
+ * hppabsd-core.c (hppabsd_core_vec): Likewise.
+
+ * aoutx.h (NAME(aout,some_aout_object_p)): Don't set SEC_RELOC
+ just because DYNAMIC is set.
+
+Thu Jun 23 12:53:41 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure.in: Change --with-targets to --enable-targets and
+ --with-64-bit-bfd to --enable-64-bit-bfd.
+ * Makefile.in, mpw-make.in, targets.c: Change comments.
+
+Wed Jun 22 17:59:59 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * config.bfd (powerpc-*-elf*): New target, just like
+ powerpc-*-sysv4*.
+
+ * linker.c (FAIL): Undefine macro before defining as enum.
+
+Wed Jun 22 10:52:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * linker.c (_bfd_generic_link_add_archive_symbols): Initialize
+ pass from abfd->archive_pass, and save it there as well.
+
+ * hash.c (bfd_hash_allocate): Don't call bfd_set_error if
+ obstack_alloc returns NULL unless the size is non-zero.
+
+ * linker.c (archive_hash_allocate): Define.
+ (_bfd_generic_link_add_archive_symbols): Use archive_hash_allocate
+ rather than obstack_alloc, for clarity.
+
+ * elfcode.h (elf_get_reloc_upper_bound): Correct.
+
+ * aout64.c (BMAGIC, QMAGIC): Define if not already defined. From
+ Peter Schauer <pes@regent.e-technik.tu-muenchen.de>.
+
+ Linux ZMAGIC support from Eric Youngdale <ericy@cais.cais.com>.
+ * libaout.h (struct aoutdata): Add field zmagic_disk_block_size.
+ * aout-target.h (MY(callback)): Only set alignment according to
+ architecture if the section sizes are aligned to that alignment,
+ for backward compatibility.
+ (MY(set_sizes)): Initialize zmagic_disk_block_size field.
+ * aoutx.h (adjust_z_magic): Set ztih if using q_magic_format. Set
+ text section filepos to zmagic_disk_block_size if not ztih. Use a
+ different padding algorithm if not ztih.
+ * i386linux.c (MY_text_includes_header): Don't define.
+
+ * aoutx.h (aout_link_check_ar_symbols): Just skip N_STAB and N_FN
+ symbols; don't look them up in the hash table. From
+ ralphc@pyramid.com (Ralph Campbell).
+
+Tue Jun 21 11:47:20 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * coff-go32.c (go32coff_archive_p): Remove unused function.
+
+ * section.c (bfd_abs_section): Make const.
+ (bfd_abs_section_ptr, bfd_is_abs_section): Define.
+ (bfd_und_section): Make const.
+ (bfd_und_section_ptr, bfd_is_und_section): Define.
+ (bfd_com_section): Make const.
+ (bfd_com_section_ptr): Define.
+ (bfd_ind_section): Make const.
+ (bfd_ind_section_ptr, bfd_is_ind_section): Define.
+ (bfd_abs_symbol, bfd_com_symbol): Make const.
+ (bfd_und_symbol, bfd_ind_symbol): Likewise.
+ (global_syms): Cast initialization of section field.
+ (STD_SECTION): Define as const, and cast initializations.
+ * bfd-in2.h: Rebuilt.
+ * Many files: Change uses of bfd_abs_section, etc., to use
+ bfd_abs_section_ptr or bfd_is_abs_section, etc.
+
+Mon Jun 20 11:06:27 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * Many files: change all bfd_target vectors to be const. Change
+ all uses of bfd_target * to be const bfd_target *. Change
+ bfd_target_vector and bfd_default_vector arrays to be const
+ bfd_target * const *.
+
+ * ecoff.c, libecoff.h, ecoffswap.h, coff-alpha.c, coff-mips.c,
+ elf32-mips.c: Renamed all externally visible ECOFF routines which
+ are local to BFD to start with _bfd_ecoff instead of just ecoff.
+
+ * ecoff.c (ecoff_swap_tir_in): Change input argument to const.
+ (ecoff_swap_tir_out): Likewise.
+ (ecoff_swap_rndx_in, ecoff_swap_rndx_out): Likewise.
+ (ecoff_slurp_symbolic_info): Add new arguments to correspond to
+ read_debug_info entry point in ecoff_debug_swap structure.
+ Change all calls.
+ * libecoff.h (ecoff_slurp_symbolic_info): Change declaration.
+ * ecoffswap.h (ecoff_swap_tir_in, ecoff_swap_tir_out): Declare.
+ (ecoff_swap_rndx_in, ecoff_swap_rndx_out): Declare.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize new
+ ecoff_debug_swap fields.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+ * elf32-mips.c (mips_elf_read_ecoff_info): Undefine READ.
+ (mips_elf_ecoff_debug_swap): Initialize new ecoff_debug_swap
+ fields.
+ * configure.in (bfd_elf32_bigmips_vec): Use ecoff.o and
+ ecofflink.o.
+ (bfd_elf32_littlemips_vec): Likewise.
+ (ecoff_big_vec, ecoff_little_vec): Likewise.
+ (ecoffalpha_little_vec): Likewise.
+ * Makefile.in (BFD_LIBS): Remove ecoff.o and ecofflink.o.
+ (BFD32_BACKENDS): Add ecoff.o and ecofflink.o.
+
+ * aoutx.h (NAME(aout,final_link)): Check flavour of sub, not abfd,
+ when computing reloc sizes. From Eric Youngdale
+ <ericy@cais.cais.com>.
+ * elfcode.h (elf_bfd_final_link): Don't try to compute maximum
+ reloc count or size for a non-ELF file.
+
+ * mipsbsd.c (MY_final_link_callback): Define to avoid warning.
+
+ * hp300hpux.c (MY_final_link_callback): Define to avoid warning.
+ (BMAGIC, QMAGIC): Define; used by aoutx.h.
+ (MY(slurp_symbol_table)): Change translate_from_native_sym_flags
+ calls to use new parameters.
+
+Fri Jun 17 14:45:32 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aout-target.h (MY(callback)): Set the alignments of the text,
+ data and bss sections after determining the architecture.
+
+ * sunos.c (sunos_add_one_symbol): Treat a common symbol from a
+ dynamic object as being in the .bss section of the object, rather
+ than as being undefined.
+
+Fri Jun 17 11:16:50 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * libhppa.h (bfd_hppa_insn2fmt, hppa_rebuild_insn): Make INLINE.
+
+ * elf32-hppa.h (elf_hppa_final_processing): Delete decl.
+
+Thu Jun 16 23:36:23 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elfcode.h (elf_link_input_bfd): Don't try to read local symbols
+ if there aren't any in the input file.
+
+Thu Jun 16 14:25:22 1994 Eric Youngdale (ericy@cais.cais.com)
+
+ * i386linux.c: Many new functions and definitions for linker
+ support for Linux shared libraries.
+ * bfd-in.h (bfd_linux_size_dynamic_sections): Declare.
+ * bfd-in2.h: Rebuild.
+
+Thu Jun 16 14:23:46 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * config.bfd: If second argument is ``_'', then, instead of
+ echoing config file name, echo whether target uses leading
+ underscores on symbol names. Add appropriate settings to
+ different cases. Used by binutils/configure.in to set default for
+ c++filt.
+
+ * elfcode.h (elf_bfd_final_link): If trying to generate a shared
+ object, warn and return false.
+
+ * aoutx.h (NAME(aout,some_aout_object_p)): Accept BMAGIC objects
+ and treat them as OMAGIC.
+
+Wed Jun 15 18:02:21 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ Enable sparc v9 support for release. Note that this is still a
+ work in progress, pending release of an ABI specification.
+ * config.bfd, configure.in: Include sparc v9 elf config.
+ * elfcode.h (prep_headers): Handle sparc v9 (64 bit).
+ * reloc.c (bfd_reloc_code_real): New reloc types.
+ * elf64-sparc.c: Implement elf64-sparc target.
+ * Makefile.in, targets.c: Updated.
+
+Wed Jun 15 01:34:07 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libelf.h (struct elf_obj_tdata): New field dt_needed_name.
+ (elf_dt_needed_name): New accessor macro.
+ * elfcode.h (elf_link_add_object_symbols): If elf_dt_needed_name
+ is set, use that instead of the filename for the DT_NEEDED dynamic
+ entry.
+ * elf.c (bfd_elf_set_dt_needed_name): New function.
+ * bfd-in.h (bfd_elf_set_dt_needed_name): Declare.
+ * bfd-in2.h: Rebuilt.
+
+ * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add sinterpptr
+ argument, and set it to the .interp section.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update prototype.
+ (bfd_elf64_size_dynamic_sections): Likewise.
+ * bfd-in2.h: Rebuilt.
+
+ * coff-sparc.c (SWAP_OUT_RELOC_EXTRA): Define to clear the r_spare
+ field of the reloc rather than letting it be garbage.
+
+ * archive.c (bfd_slurp_armap): Recognize __.SYMDEF/ as well as
+ __.SYMDEF; the former was used in old Linux archives. From
+ jrs@world.std.com (Rick Sladkey).
+
+ * i386linux.c (i386linux_write_object_contents): Define; like
+ MY(write_object_contents) in aout-target.h, but set MACHTYPE to
+ M_386. From jrs@world.std.com (Rick Sladkey).
+ (MY_write_object_contents): Define.
+
+ * aoutx.h (translate_from_native_sym_flags): Treat N_SETV symbols
+ as N_DATA symbols.
+ (aout_link_add_symbols): Likewise.
+
+ * aoutx.h: Rewrite symbol duplicate elimination to use BFD hash
+ tables.
+ (struct stringtab_entry, struct stringtab_data): Remove.
+ (HASHMAXLEN, HASH_CHAR, hash, compare, log2, emit_strtab): Remove.
+ (struct strtab_hash_entry, struct strtab_hash): Define.
+ (strtab_hash_newfunc, strtab_hash_lookup): Define.
+ (stringtab_free, emit_stringtab): Define.
+ (stringtab_init, add_to_stringtab): Rewrite.
+ (NAME(aout,write_syms)): Use new stringtab code.
+ (struct aout_final_link_info, NAME(aout,final_link)): Likewise.
+ (aout_link_write_symbols, aout_link_write_other_symbol): Likewise.
+
+ * bfd-in.h (BFD_TRADITIONAL_FORMAT): Define new BFD flag to
+ request BFD to write object in the traditional format, whatever
+ that means for the particular backend.
+ * bfd-in2.h: Rebuilt.
+
+ * hash.c (bfd_hash_allocate): If obstack_alloc fails, set
+ bfd_error_no_memory.
+
+Tue Jun 14 13:00:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libaout.h (struct aoutdata): Add q_magic_format to subformat
+ enum.
+ * aout-target.h (MY_bfd_copy_private_bfd_data): Define as function
+ if not already defined. Copy subformat information.
+ (MY_text_includes_header): Define as 0 if not already defined.
+ (MY(backend_data)): Use MY_text_includes_header rather than 0.
+ (MY_final_link_callback): Rename from final_link_callback, and
+ define only if MY_final_link_callback is not already defined.
+ (MY_bfd_final_link): Rename use of final_link_callback to
+ MY_final_link_callback.
+ * aoutx.h (NAME(aout,some_aout_object_p)): Handle QMAGIC like
+ ZMAGIC, but set the subformat to q_magic_format. Abort if the
+ magic number if not recognized.
+ (adjust_z_magic): Use QMAGIC if q_magic_format.
+ * i386linux.c (MY_text_includes_header): Define as 1.
+ (i386linux_bfd_final_link): New static function.
+ (MY_bfd_final_link): Define as i386linux_bfd_final_link.
+
+ * aoutx.h (translate_to_native_sym_flags): Check both section and
+ output_section against sections of abfd.
+
+ * libecoff.h (struct ecoff_link_hash_entry): Change type of
+ written from boolean to char. Add new field small.
+ * ecoff.c (ecoff_link_hash_newfunc): Initialize written to 0
+ rather than false. Initialize small to 0.
+ (ecoff_link_add_externals): If ECOFF type is scSUndefined, set
+ small. If small is set, and hash table type is common, force the
+ symbol into a section named SCOMMON and change the ECOFF type from
+ scCommon to scSCommon.
+ (ecoff_link_write_external): Set written to 1 rather than true.
+ * coff-mips.c (mips_relocate_section): Correct JMPADDR reloc
+ overflow check to consider section VMA of input file.
+
+Mon Jun 13 14:20:07 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutf1.h (aout_32_sunos4_write_object_contents): Handle a
+ machine type of 68000.
+ * aoutx.h (NAME(aout,machine_type)): Add new argument unknown.
+ Set *unknown to true if machine type is really unknown, as opposed
+ to M_UNKNOWN for the 68000.
+ (NAME(aout,set_arch_mach)): Change NAME(aout,machine_type) call
+ accordingly.
+ * libaout.h (NAME(aout,machine_type)): Add new argument to
+ prototype.
+
+Sun Jun 12 20:21:03 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (EXEC_AUX_ID): Define based on availablity of HPUX_AUX_ID
+ or HIUX_AUX_ID.
+ (som_begin_writing): Use EXEC_AUX_ID instead of HPUX_AUX_ID.
+ (som_write_armap): Use CPU_PA_RISC1_0 as the magic number. Note
+ som.c is careful to always define CPU_PA_RISC1_0.
+
+Sat Jun 11 16:32:30 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Add weak symbols as an extension to a.out.
+ * aoutx.h (sym_in_text_section): Don't define.
+ (sym_in_data_section, sym_in_bss_section): Likewise.
+ (sym_is_undefined, sym_is_global_defn): Likewise.
+ (sym_is_debugger_info, sym_is_fortrancommon): Likewise.
+ (sym_is_absolute, sym_is_indirect): Likewise.
+ (translate_from_native_sym_flags): Rewrite for clarity. Rearrange
+ arguments and change caller. Handle weak symbols.
+ (translate_to_native_sym_flags): Likewise.
+ (aout_link_check_ar_symbols): Don't ignore weak symbols. Pull
+ object in from archive if a weak defintion is found for an
+ existing undefined symbol.
+ (aout_link_add_symbols): Put all cases in switch. Set flags of an
+ undefined symbol to 0. Handle weak symbols.
+ (aout_link_write_symbols): Handle weak symbols.
+ (aout_link_write_other_symbol): Likewise.
+ (aout_link_input_section_std): Likewise.
+ (aout_link_input_section_ext): Likewise.
+ * sunos.c (sunos_write_dynamic_symbol): Likewise.
+
+Fri Jun 10 13:25:13 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (NAME(aout,canonicalize_reloc)): Handle .bss section.
+ (NAME(aout,get_reloc_upper_bound)): Likewise.
+
+ * coff-i960.c (coff_i960_reloc_type_lookup): Add BFD_RELOC_CTOR.
+ * linker.c (_bfd_generic_link_write_global_symbol): Don't assume
+ the section of a common symbol is not NULL.
+
+Wed Jun 8 23:15:53 1994 Stu Grossman (grossman@cygnus.com)
+
+ * nlmcode.h (nlm_object_p): Set EXEC_P and start address for GDB.
+
+Wed Jun 8 23:57:34 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_get_external_symbols): Don't try to read the
+ strings if there are no symbols.
+ (aout_link_write_other_symbol): Use the output section when
+ working out the type.
+
+Tue Jun 7 13:25:08 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (assign_section_numbers): Put shstrtab, symtab and
+ strtab sections at end of file. Avoids bug in some versions of
+ SVR4 strip. From Eric Youngdale <eric@tantalus.nrl.navy.mil>.
+
+ * coffcode.h (styp_to_sec_flags): If COFF_PAGE_SIZE is defined,
+ set SEC_DEBUGGING for STYP_INFO sections.
+ (coff_compute_section_file_positions): If COFF_PAGE_SIZE is
+ defined, and D_PAGED is set, set the file position equal to the
+ section VMA modulo COFF_PAGE_SIZE.
+ * coffgen.c (coff_real_object_p): If F_EXEC is set, set D_PAGED.
+ * coff-i386.c: Set D_PAGED in BFD target.
+ (COFF_PAGE_SIZE): Define.
+ * coff-m68k.c, coff-sparc.c: Likewise.
+
+Mon Jun 6 10:57:28 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (bfd_section_from_shdr): Don't turn a reloc section
+ into a BFD section just because SHF_ALLOC is set; require that it
+ not use the normal symbol table.
+ (elf_section_from_bfd_section): Corresponding change.
+
+ Better indirect and warning symbol handling inspired by Stuart
+ Quick <stuck@cs.man.ac.uk>.
+ * linker.c (enum link_action): Add REF, MIND, CWARN, REFC.
+ (link_action): Change UNDEF_ROW/def and UNDEFW_ROW/def from NOACT
+ to REF. Change UNDEF_ROW/indr and UNDEFW_ROW/indr from CYCLE to
+ REFC. Change DEF_ROW/indr and COMMON_ROW/indr from CYCLE to MDEF.
+ Change DEFW_ROW/indr from CYCLE to NOACT. Change INDR_ROW/indr
+ from MDEF to MIND. Change INDR_ROW/warn from WARNC to CYCLE.
+ Change WARN_ROW/def and WARN_ROW/indr from MWARN to CWARN. Change
+ WARN_ROW/com from MWARN to WARN. Change WARN_ROW/warn from NOACT
+ to CYCLE. Change SET_ROW/warn from WARNC to CYCLE>
+ (_bfd_generic_link_add_one_symbol): Handle REF, MIND, CWARN and
+ REFC. If a new indirect symbol has been referenced, push the
+ reference down to the symbol it points to. FIx handling of WARN.
+ * aoutx.h (translate_from_native_sym_flags): If N_WARNING, don't
+ clobber e_type of next symbol.
+ (translate_to_native_sym_flags): Likewise.
+ (aout_link_write_symbols): Loop on bfd_link_hash_warning as well
+ as bfd_link_hash_indirect.
+
+ * libaout.h (struct aout_link_hash_entry): New field written.
+ * aoutx.h (NAME(aout,link_hash_newfunc)): Initialize written.
+ (aout_link_write_symbols): Use written, not root.written.
+ (aout_link_write_other_symbol): Likewise.
+ * sunos.c (sunos_scan_dynamic_symbol): Likewise.
+ * libecoff.h (struct ecoff_link_hash_entry): New field written.
+ * ecoff.c (ecoff_link_hash_newfunc): Initialize written.
+ (ecoff_link_write_external): use written, not root.written.
+ * genlink.h (struct generic_link_hash_entry): New field written.
+ * linker.c (_bfd_link_hash_newfunc): Don't initialize written.
+ (generic_link_hash_newfunc): Initialize written.
+ (_bfd_generic_link_output_symbols): Use written, not root.written.
+ (_bfd_generic_link_write_global_symbol): Likewise.
+ (_bfd_generic_reloc_link_order): Likewise.
+
+ * libecoff.h (ecoff_data_type): Add linker field.
+ * ecoff.c (ecoff_write_object_contents): Check new tdata linker
+ field, rather than outsymbols being non-NULL, to decide whether to
+ output the symbols and relocs.
+ (ecoff_bfd_final_link): Set new tdata linker field to true.
+
+ * ecoff.c (ecoff_bfd_copy_private_bfd_data): Don't try to copy
+ data to a non-ECOFF file.
+
+ * libbfd-in.h: Add warning that libbfd.h is a generated file.
+ * libbfd.h: Rebuilt.
+
+Sun Jun 5 15:02:30 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Changes to support ELF strip and objcopy on dynamically linked
+ files.
+ * elfcode.h (elf_fake_sections): Add prototype.
+ (bfd_section_from_shdr): Make a BFD section from an SHT_HASH
+ section, and from an SHT_DYNSYM section, and from the dynamic
+ string table section.
+ (elf_object_p): Set D_PAGED if there is a program header.
+ (elf_make_sections): Remove.
+ (fix_up_strtabs): Remove.
+ (elf_fake_sections): Rewrite. Now sets sh_entsize.
+ (assign_section_numbers): Rewrite. Now sets sh_link and sh_info
+ for all sections.
+ (elf_compute_section_file_positions): Don't call obsolete
+ functions elf_make_sections or fix_up_strtabs.
+ (swap_out_syms): Set sh_addralign to FILE_ALIGN rather than 4.
+ (NAME(bfd_elf,write_object_contents)): Permit writing DYNAMIC
+ objects.
+ (elf_section_from_bfd_section): Treat SHT_DYNSYM like other normal
+ sections. If an SHT_REL or SHT_RELA section is allocated or uses
+ an unusual symbol table, permit a BFD section to map to it.
+ Permit most SHT_STRTAB sections to have a BFD section mapped to
+ them.
+ (elf_bfd_final_link): Don't set sh_link, sh_info or sh_entsize
+ fields of dynamic sections here; do it in assign_section_numbers.
+ * elf32-target.h, elf64-target.h: Add D_PAGED to permitted object
+ flags.
+
+ * elf.c (_bfd_elf_make_section_from_shdr): Only set SEC_DATA if
+ SEC_LOAD is set, rather than checking SEC_ALLOC.
+
+ * libbfd-in.h (bfd_realloc): Change last arg to "size_t size".
+
+Fri Jun 3 10:58:02 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_write_object_contents): Don't compute the file header's
+ checksum here.
+ (som_write_headers): Instead do it here.
+
+ * libbfd.h (bfd_realloc): Change last arg to "size_t size".
+
+Thu Jun 2 17:39:22 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * hosts/sun3.h: Include <stdlib.h>. Don't declare free, exit or
+ getenv.
+
+ Add linker support for SunOS shared libraries.
+ * sunos.c: Include bfdlink.h. Add many new functions and
+ definitions for SunOS shared library support.
+ * bfd-in.h (bfd_sunos_record_link_assignment): Declare.
+ (bfd_sunos_size_dynamic_sections): Declare.
+ * bfd-in2.h: Rebuilt.
+ * aoutx.h (struct aout_link_hash_entry): Move to libaout.h.
+ (struct aout_link_hash_table): Likewise.
+ (aout_link_hash_lookup, aout_link_hash_traverse): Likewise.
+ (aout_hash_table): Likewise.
+ (NAME(aout,link_hash_newfunc)): Rename from aout_link_hash_newfunc
+ and make externally visible.
+ (NAME(aout,link_hash_table_init)): New function.
+ (NAME(aout,link_hash_table_create)): Call
+ NAME(aout,link_hash_table_init), not _bfd_link_hash_table_init.
+ (aout_link_add_symbols): Don't fail if no symbols. If it exists,
+ call add_dynamic_symbols backend entry point for dynamic objects.
+ Use add_one_symbol backend entry point if it exists.
+ (NAME(aout,final_link)): Call finish_dynamic_link backend entry
+ point, if it exists.
+ (aout_link_input_bfd): For a dynamic object, call
+ link_dynamic_object backend entry point, if it exists.
+ (aout_link_write_other_symbol): Call write_dynamic_symbol backend
+ entry point, if it exists.
+ (aout_link_input_section): Don't read the relocs if they have
+ already been read.
+ (aout_link_input_section_std): When doing a final link, for a
+ reloc against an external symbol, call check_dynamic_reloc backend
+ entry point, if it exists.
+ (aout_link_input_section_ext): Likewise.
+ * libaout.h: Protect against multiple inclusion. Include
+ bfdlink.h.
+ (struct aout_link_hash_entry): Move in from aoutx.h.
+ (struct aout_link_hash_table): Likewise.
+ (aout_link_hash_lookup, aout_link_hash_traverse): Likewise.
+ (aout_hash_table): Likewise.
+ (struct aout_backend_data): Add fields add_dynamic_symbols,
+ add_one_symbol, link_dynamic_object, write_dynamic_symbol,
+ check_dynamic_reloc, and finish_dynamic_link.
+ (struct aout_section_data_struct): Define new structure.
+ (aout_section_data): Define new accessor macro.
+ (NAME(aout,link_hash_newfunc)): Declare.
+ (NAME(aout,link_hash_table_init)): Declare.
+ * aoutf1.h (sunos4_aout_backend): Initialize new aout_backend_data
+ fields.
+ * aout-target.h (MY(backend_data)): Likewise.
+ * i386aout.c (MY(backend_data)): Likewise.
+ * i386mach3.c (MY(backend_data)): Likewise.
+ * mipsbsd.c (MY(backend_data)): Likewise.
+ * sparclynx.c (sparclynx_aout_backend): Likewise.
+
+ * aoutx.h (NAME(aout,slurp_symbol_table)): Don't zero out cached
+ until we know it is non-NULL.
+ (aout_link_write_symbols): Don't skip a warning symbol even if it
+ has already been written out. If skipping an indirect symbol,
+ skip the next symbol as well.
+
+Wed Jun 1 14:37:50 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * hosts/sun3.h: Don't declare qsort, malloc or realloc.
+
+Thu May 26 13:56:03 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * nlmcode.h (nlm_swap_auxiliary_headers_in): Cast bfd_byte pointer
+ to char pointer to avoid compiler warnings.
+
+ * dep-in.sed: Remove spaces before colons.
+
+ Merged changes back in from FSF gas release 2.3:
+
+ * Makefile.in (stmp-bfd.h): Wrap `if' block around grep
+ invocation, to avoid a bug in BSD 4.4 make.
+
+ From Ralph Campbell:
+ * mipsbsd.c (mips_fix_jmp_addr): If symbol is undefined, return an
+ error.
+ (mips_fix_hi16_s): Ditto.
+
+ Fri May 13 21:21:00 1994 DJ Delorie (dj@ctron.com)
+
+ * makefile.dos: define a default target, or archives won't work
+ due to multiple matches.
+
+ Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com)
+
+ * configure.bat: update for latest files
+ * makefile.dos: update for correct targets and sources
+ * coff-go32.c: [new] go32's COFF format (i386coff with underscores)
+ * targets.c: add go32coff target
+ * makefile.in: add coff-go32.c support
+
+Thu May 26 10:10:21 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_prep_headers): Do not set the system_id here, private
+ bfd data has not been copied yet.
+ (som_write_headers): Instead do it here.
+
+Tue May 24 16:17:18 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Make MIPS ELF use new ELF backend linker. No shared library
+ support yet.
+ * elf32-mips.c (bfd_mips_elf32_swap_gptab_in): New function.
+ (bfd_mips_elf32_swap_gptab_out): New function.
+ (mips_elf_object_p): If last symbol is LOCAL, set elf_bad_symtab.
+ (mips_elf_final_write_processing): Set sh_info field for .gptab.*
+ sections.
+ (mips_elf_fake_sections): Set sh_entsize for .gptab.* sections.
+ (mips_elf_read_ecoff_info): Read and free external symbols last,
+ not first, for clarity.
+ (struct mips_elf_link_hash_entry): Define new structure.
+ (struct mips_elf_link_hash_table): Define new structure.
+ (mips_elf_link_hash_lookup): Define new macro.
+ (mips_elf_link_hash_traverse): Define new macro.
+ (mips_elf_hash_table): Define new macro.
+ (mips_elf_link_hash_newfunc): New static function.
+ (mips_elf_link_hash_table_create): New static function.
+ (mips_elf_add_symbol_hook): New static function.
+ (struct extsym_info): Define new structure.
+ (mips_elf_get_extr, mips_elf_set_index): Remove.
+ (mips_elf_output_extsym): New static function.
+ (gptab_compare): New static function.
+ (mips_elf_final_link): Rewrite to use ELF backend linker, and to
+ merge gptab information in input files.
+ (mips_elf_relocate_hi16): New static function.
+ (mips_elf_relocate_section): New static function.
+ (bfd_elf32_bfd_link_hash_table_create): Define as macro before
+ including elf32-target.h.
+ (elf_backend_relocate_section): Likewise.
+ (elf_backend_add_symbol_hook): Likewise.
+ * elf.c (_bfd_elf_link_hash_newfunc): Rename from
+ elf_link_hash_newfunc and make globally visible. Change caller.
+ (_bfd_elf_link_hash_table_init): New function, broken out of
+ _bfd_elf_link_hash_table_create.
+ (_bfd_elf_link_hash_table_create): Use
+ _bfd_elf_link_hash_table_init.
+ * libelf.h (struct elf_obj_tdata): Add new field bad_symtab.
+ (elf_bad_symtab): Define new accessor macro.
+ (_bfd_elf_link_hash_newfunc): Declare.
+ (_bew_elf_link_hash_table_init): Declare.
+ * elfcode.h (elf_object_p): Call backend object_p hook after
+ swapping in all the section headers.
+ (map_program_segments): Correct typo: Internal for External.
+ (elf_link_add_object_symbols): If elf_bad_symtab is set, read all
+ the symbols. Skip STB_LOCAL symbols rather than giving an error.
+ (elf_bfd_final_link): If elf_bad_symtab is set, allocate space for
+ all symbols, not just locals.
+ (elf_link_output_extsym): Only skip a symbol not mentioned by a
+ regular file if it is mentioned by a dynamic object.
+ (elf_link_input_bfd): If elf_bad_symtab is set, read all the
+ symbols.
+
+Fri May 20 13:38:23 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * som.c (som_set_reloc_info): Do not set any relocation info
+ for SOM fixups which are never passed to BFD.
+
+Fri May 20 11:57:05 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-mips.c (mips_relocate_section): Add MIPS_R_JMPADDR overflow
+ checking.
+
+ * elf32-i386.c (elf_i386_size_dynamic_sections): Add DT_DEBUG to
+ the dynamic linking information for the benefit of the debugger.
+ From Peter Schauer.
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Likewise.
+
+ * elf.c (_bfd_elf_make_section_from_shdr): New function, based on
+ code repeated three times in bfd_section_from_shdr in elfcode.h.
+ * libelf.h (_bfd_elf_make_section_from_shdr): Declare.
+ * elfcode.h (bfd_section_from_shdr): Use new function
+ _bfd_elf_make_section_from_shdr to create BFD sections. If a
+ reloc section does not use the main symbol table, or it is part of
+ the process image, treat it as a normal section, not relocs.
+ * elf32-mips.c (mips_elf_section_from_shdr): Use new function
+ _bfd_elf_make_section_from_shdr.
+
+Thu May 19 11:37:11 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-target.h, elf64-target.h: Change ar_max_namelen value from
+ 15 to 14 to match SVR4 ar.
+
+ Add support for ELF shared libraries. Loosely based on work by
+ Eric Youngdale <ericy@cais.com>.
+ * libelf.h (struct elf_backend_data): Add new fields for dynamic
+ linking: elf_backend_create_dynamic_sections,
+ elf_backend_adjust_dynamic_symbol,
+ elf_backend_size_dynamic_sections,
+ elf_backend_finish_dynamic_symbol,
+ elf_backend_finish_dynamic_sections.
+ (struct elf_link_hash_entry): Change type of align field to
+ bfd_size_type. Add fields dynindx, dynstr_index, weakdef,
+ elf_link_hash_flags.
+ (struct elf_link_hash_table): Add fields dynobj, dynsymcount,
+ dynstr, bucketcount.
+ (bfd_elf32_swap_reloc_in, bfd_elf32_swap_reloc_out): Declare.
+ (bfd_elf32_swap_reloca_in, bfd_elf32_swap_reloca_out): Declare.
+ (bfd_elf32_swap_dyn_in, bfd_elf32_swap_dyn_out): Declare.
+ (bfd_elf32_add_dynamic_entry): Declare.
+ (bfd_elf64_swap_reloc_in, bfd_elf64_swap_reloc_out): Declare.
+ (bfd_elf64_swap_reloca_in, bfd_elf64_swap_reloca_out): Declare.
+ (bfd_elf64_swap_dyn_in, bfd_elf64_swap_dyn_out): Declare.
+ (bfd_elf64_add_dynamic_entry): Declare.
+ * elfcode.h (Elf_External_Dyn): Define.
+ (elf_swap_reloc_in): Define as macro using NAME. Make externally
+ visible.
+ (elf_swap_reloc_out): Likewise.
+ (elf_swap_reloca_in, elf_swap_reloca_out): Likewise.
+ (elf_swap_dyn_in, elf_swap_dyn_out): Define as macro using NAME
+ and as new externally visible function.
+ (elf_fake_sections): Set section type of dynamic sections based on
+ section names.
+ (elf_write_phdrs): Remove.
+ (assign_file_position_for_section): Add new align argument.
+ Change all callers.
+ (get_program_header_size): New static function.
+ (struct seg_info): Remove.
+ (map_program_segments): Completely rewrite.
+ (assign_file_positions_except_relocs): Completely rewrite.
+ (assign_file_positions_for_relocs): Don't set a file position for
+ sections which already have one. Don't bother to align the file
+ position here.
+ (section_from_elf_index): Handle SHT_HASH and SHT_DYNAMIC
+ section types.
+ (elf_section_from_bfd_section): Likewise.
+ (elf_slurp_symbol_table): If section_from_elf_index fails, just
+ use bfd_abs_section rather than returning an error.
+ (elf_sizeof_headers): Make useful.
+ (elf_link_record_dynamic_symbol): New static function.
+ (elf_link_add_object_symbols): Handle dynamic objects.
+ (elf_link_create_dynamic_sections): New static function.
+ (elf_add_dynamic_entry): Define as macro using NAME and as new
+ externally visible function.
+ (NAME(bfd_elf,record_link_assignment)): New function.
+ (elf_buckets): New static variable.
+ (NAME(bfd_elf,size_dynamic_sections)): New function.
+ (struct elf_final_link_info): Add dynsym_sec and hash_sec fields.
+ (elf_bfd_final_link): Handle dynamic linking. Create a section
+ symbol for all ELF sections, not all BFD sections. Store section
+ symbol index in target_index field, not index field. Traverse
+ over global symbols even if stripping.
+ (elf_link_output_extsym): Output dynamic symbols. Mark symbols
+ defined by dynamic objects as undefined.
+ (elf_link_input_bfd): Ignore dynamic objects. Use target_index
+ field for section relocs, and make sure it is set.
+ (elf_reloc_link_order): Use target_index field for section relocs,
+ and make sure it is set.
+ * elf.c (elf_link_hash_newfunc): Initialize dynindx, dynstr_index,
+ weakdef and elf_link_hash_flags fields.
+ (_bfd_elf_link_hash_table_create): Initialize dynobj, dynsymcount,
+ dynstr and bucketcount fields.
+ * elf32-target.h: Initialize new dynamic linking fields.
+ * elf64-target.h: Likewise.
+ * elf32-i386.c: New functions for dynamic linking support.
+ * elf32-sparc.c: Likewise.
+ * bfd-in.h (bfd_elf32_record_link_assignment): Declare.
+ (bfd_elf64_record_link_assignment): Declare.
+ (bfd_elf32_size_dynamic_sections): Declare.
+ (bfd_elf64_size_dynamic_sections): Declare.
+ * bfd-in2.h: Rebuilt.
+
+Wed May 18 08:29:04 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * som.c: Don't include <sys/dir.h> or <sys/user.h>.
+ (som_reloc_queue_find): Call memcmp instead of bcmp.
+ (som_bfd_reloc_type_lookup): Change first argument to bfd *.
+ (compare_syms): Change types of arguments to const void *.
+ (bfd_section_from_som_symbol): Removed unused local found.
+ (som_write_armap): Add elength, map, orl_count and int arguments.
+ (som_write_armap): Use %ld and cast to long for getuid result.
+
+Wed May 18 09:09:32 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.h (R_HPPA_ABS_CALL): Define.
+ * elf32-hppa.c (hppa_elf_gen_reloc_type): Handle absolute calls.
+
+ * som.h (R_HPPA_ABS_CALL): Define.
+ * som.c (hppa_som_gen_reloc_type): Delete complex relocation types.
+
+Tue May 17 19:33:12 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * coff-i960.c (icoff_little_vec, icoff_big_vec): Indicate leading
+ underscore, for compatibility with Intel tool chain (gnu960v2).
+
+Mon May 16 10:09:22 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * bfd-in2.h: Rebuilt.
+
+ * elf32-hppa.c: Change .hppa_linker_stubs to .PARISC.stubs,
+ likewise for other PA specific sections.
+ (hppa_elf_relocate_unwind_table): Delete unused
+ function.
+ (elf_hppa_howto_table): Completely new table based on 94-02-02
+ draft PA ELF spec. Change relocation tags appropriately
+ throughout elf32-hppa.c
+ (hppa_elf_gen_reloc_type): Rewrite and simplify based on 94-02-02
+ spec.
+ (hppa_elf_reloc): Likewise.
+ (hppa_look_for_stubs_in_section): Likewise
+ (ELF_MACHINE_CODE): Change to EM_PARISC.
+ * elf32-hppa.h: Include "elf/hppa.h". Change relocation tags
+ appropriately throughout elf32-hppa.h.
+ (elf32_hppa_reloc_type): New table based on 94-02-02 draft PA ELF
+ spec.
+ (R_HPPA_ABS_CALL, R_HPPA_COMPLEX*, R_HPPA_UNWIND): Delete definitions.
+ * elfcode.h (prep_headers): Use EM_PARISC instead of EM_HPPA.
+ * reloc.c (bfd_reloc_code_real): Delete unused HPPA relocations.
+ * som.h (R_HPPA_ABS_CALL, R_HPPA_COMPLEX): Delete definitions.
+
+ * libhppa.h (hppa_field_adjust): Avoid adding constant_value into
+ the final value twice for LR and RR field selectors.
+
+Sat May 14 09:09:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aoutx.h (add_to_stringtab): Use BFD_ASSERT not assert. This
+ avoids __eprintf troubles.
+
+Fri May 13 10:51:21 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bout.c (b_out_bfd_reloc_type_lookup): Handle BFD_RELOC_CTOR.
+
+ * config/mipsbelf.mt (SELECT_VECS): Add ecoff_big_vec and
+ ecoff_little_vec since Irix 5 supports ECOFF executables.
+
+Wed May 11 00:31:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_find_nearest_line): Handle fdr.adr != pdr.adr
+ correctly.
+
+ * Makefile.in (stmp-bfd.h): Use || instead of ; to force SunOS
+ make to invoke the shell.
+
+Tue May 10 14:23:43 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * section.c (SEC_COFF_SHARED_LIBRARY): Renamed from
+ SEC_SHARED_LIBRARY for clarity. Changed all uses.
+ * bfd-in2.h: Rebuilt.
+ * coffcode.h (sec_to_styp_flags): If SEC_COFF_SHARED_LIBRARY is
+ set, set STYP_NOLOAD.
+ * coffgen.c (coff_section_from_bfd_index): Don't get an assertion
+ failure because of a bad shared library.
+
+Mon May 9 18:53:40 1994 Bill Cox (bill@rtl.cygnus.com)
+
+ * linker.c: Add missing comment terminator.
+
+Mon May 9 11:53:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * linker.c (_bfd_generic_link_add_one_symbol): If hashp and *hashp
+ are not NULL, assume the caller has already looked up the symbol
+ in the hash table and has stored the entry in *hashp.
+ (generic_link_add_symbol_list): Set h to NULL before calling
+ _bfd_generic_link_add_one_symbol.
+ * ecoff.c (ecoff_link_add_externals): Likewise.
+
+ * elfcode.h (assign_file_positions_except_relocs): Don't require
+ page shared between .data and .bss segments to contain zeroes.
+
+ * elfcode.h: Include bfdlink.h. Added several new functions to do
+ linking.
+ (ELF_R_TYPE): Define.
+ (bfd_add_to_strtab): Return unsigned long. Change check for
+ realloc failure.
+ (elf_fake_sections): Check return value of bfd_add_to_strtab.
+ (elf_compute_section_file_positions): Add link_info argument.
+ Call elf_backend_begin_write_processing hook and prep_headers
+ here. Only call swap_out_syms if link_info is NULL. Set up
+ .shstrtab section here. Pass dosyms argument to
+ assign_file_positions_except_relocs. Set output_has_begun flag.
+ (assign_file_positions_for_symtab_and_strtabs): Add dosyms
+ argument, and use it to control setting .symtab and .strtab file
+ positions.
+ (assign_file_positions_except_relocs): Add dosyms argument, and
+ pass it on.
+ (prep_headers): Check return value of bfd_add_to_strtab.
+ (swap_out_syms): Likewise. Also, don't set up .shstrtab here.
+ (NAME(bfd_elf,write_object_contents)): Some calls moved into
+ elf_compute_section_file_positions.
+ (elf_set_section_contents): Likewise.
+ (elf_slurp_symbol_table): SHN_LORESERV corrected to SHN_LORESERVE.
+ * libelf.h: Include bfdlink.h.
+ (struct elf_backend_data): Add fields collect,
+ elf_add_symbol_hook, elf_backend_relocate_section.
+ (struct bfd_elf_section_data): Add field rel_hashes.
+ (struct elf_obj_tdata): Remove fields internal_syms and symbols.
+ Add field sym_hashes.
+ (obj_symbols, obj_internal_syms): Remove definitions.
+ (elf_sym_hashes): Define.
+ (struct elf_link_hash_entry): Define.
+ (struct elf_link_hash_table): Define.
+ (elf_link_hash_lookup): Define.
+ (elf_link_hash_traverse): Define.
+ (elf_hash_table): Define.
+ (_bfd_elf_link_hash_table_create): Declare.
+ (bfd_elf32_bfd_link_add_symbols): Declare.
+ (bfd_elf32_bfd_final_link): Declare.
+ (bfd_elf64_bfd_link_add_symbols): Declare.
+ (bfd_elf64_bfd_final_link): Declare.
+ * elf.c: Include bfdlink.h.
+ (elf_link_hash_newfunc): New function.
+ (_bfd_elf_link_hash_table_create): New function.
+ * elf32-target.h (elf_backend_relocate_section): If not defined,
+ define as 0 and use generic linker. Otherwise, use ELF backend
+ linker.
+ (elf_backend_collect): If not defined, define as false.
+ (elf_backend_add_symbol_hook): If not defined, define as 0.
+ (elf32_bed): Initialize new fields.
+ * elf64-target.h: Same changes as elf32-target.h.
+ * elf32-i386.c: Include bfdlink.h.
+ (elf_i386_relocate_section): New function.
+ (elf_backend_relocate_section): Define.
+ * elf32-sparc.c: Include bfdlink.h.
+ (elf_info_to_howto): Change type of dst from Elf32_Internal_Rela
+ to Elf_Internal_Rela (they're the same type anyhow).
+ (elf_sparc_relocate_section): New function.
+ (elf_backend_relocate_section): Define.
+ * elf32-mips.c (elf_backend_collect): Define.
+
+ * Makefile.in (stmp-bfd.h): Avoid useless make error message in a
+ different way; touch takes a numeric argument on some systems.
+
+Fri May 6 13:34:14 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlmcode.h (nlm_swap_auxiliary_headers_in): Rework custom header
+ handling for latest suggested format.
+ (nlm_swap_auxiliary_headers_out): Likewise.
+ (nlm_compute_section_file_positions): Likewise.
+
+Fri May 6 11:11:50 1994 D. V. Henkel-Wallace (gumby@rtl.cygnus.com)
+
+ * config.bfd: handle erricsson config (for OSE).
+
+Thu May 5 15:40:47 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ Patches from Ralph Campbell:
+ * mipsbsd.c (mips_fix_jmp_addr): New function.
+ (mips_fix_hi16_s): Use bfd_is_com_section.
+ (mips_howto_table_ext): Call mips_fix_jmp_addr for MIPS_RELOC_JMP.
+
+Fri May 6 11:48:55 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * config/go32.mh: XX support.
+
+ From bill
+ * Makefile.in: Build sysdep.h without causing worrying but
+ harmless error message.
+
+Wed May 4 11:09:53 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ Changed m68k-aout to set flags to 0; m68k-sunos still uses 1.
+ * aout0.c: New file.
+ * targets.c (aout0_big_vec): Declare.
+ (bfd_target_vector): Add aout0_big_vec.
+ * config.bfd (m68*-*-aout*): Use m68k-0aout, not m68k-aout.
+ * config/m68k-aout.mt (SELECT_VECS): Removed.
+ * config/m68k-0aout.mt: New file.
+ * configure.in (aout0_big_vec): New target vector: use aout0.o,
+ aout32.o and stab-syms.o.
+ * Makefile.in: Rebuilt dependencies.
+ (BFD32_BACKENDS): Add aout0.o.
+ (CFILES): Add aout0.c.
+
+ * libaout.h (struct aout_backend_data): Add field exec_hdr_flags.
+ * aout-target.h (MY_exec_hdr_flags): If not defined, define as 0.
+ MY(backend_data): Initialize exec_hdr_flags field.
+ * aoutf1.h (sunos_32_set_arch_mach): Make static.
+ (aout32_sunos4_write_object_contents): Set flags from backend
+ info.
+ (MY_exec_hdr_flags): If not defined, define as 1.
+ (sunos4_aout_backend): Initialize exec_hdr_flags field.
+ * aout-encap.c (encap_write_object_contents): Set flags from
+ backend info.
+ (MY_exec_hdr_flags): Define as N_FLAGS_COFF_ENCAPSULATE.
+ * hp300hpux.c (MY_exec_hdr_flags): Define as 0x2.
+ (MY(write_object_contents)): Set flags from backend info.
+ * i386aout.c (MY(backend_data)): Initialize exec_hdr_flags field.
+ * i386mach3.c (MY(backend_data)): Likewise.
+ * mipsbsd.c (MY(backend_data)): Likewise.
+ * sparclynx.c (NAME(aout,sparclynx_write_object_contents)): Set
+ flags from backend info.
+ (sparclynx_aout_backend): Initialize exec_hdr_flags field.
+
+Wed May 4 02:56:00 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * config.bfd (i386-*-gnu*): Treat like i386-*-mach*.
+ (m68*-apollo-*): Treat all Apollo configs the same, don't handle
+ BSD specially.
+
+Tue May 3 19:43:21 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * cache.c: Rewrote to work correctly.
+ * libbfd.h: Rebuilt.
+ * opncls.c (bfd_cache_init, bfd_open_file): Don't declare.
+ (bfd_fdopenr): Check return value of bfd_cache_init.
+
+Fri Apr 29 15:08:23 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * cf-m68klynx.c (CALC_ADDEND): Check for PC relative relocs by
+ enumerating them, since the reloc type can not serve as an index
+ into the m68k COFF howto_table.
+
+Fri Apr 29 09:42:39 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * config.bfd (*-go32): Changed to coff.
+ * coff-h8300.c (JMPL1): Get HOWTO right for 24bit branches.
+ * srec.c (srec_write_symbols): Write out the correct number of
+ symbols and don't stick in extra nulls.
+
+Tue Apr 26 15:07:24 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * cf-sparclynx.c (LYNXOS, COFF_LONG_FILENAMES): Define.
+ * coff-sparc.c (BADMAG): Recognize LYNXCOFFMAGIC.
+ (COFF_SPARC): Define.
+ * coffcode.h (coff_new_section_hook): If COFF_SPARC, set alignment
+ power of data and bss sections to 3.
+ * hosts/lynx.h (__LYNXOS): Define.
+
+Tue Apr 26 15:04:26 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (hppa_elf_reloc): Adjust the addend of relocations
+ against section symbols to avoid losing during ld -r.
+
+Tue Apr 26 12:16:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (shstrtab_length_fixed): Remove useless static
+ variable.
+ (struct elf_sect_data): Remove unused structure.
+ (elf_object_p): Free memory if error occurs. Check return value
+ of bfd_default_set_arch_mach. If elf_get_str_section fails,
+ preserve error code rather than setting wrong_format.
+ (null_shdr): Remove static variable.
+ (assign_section_numbers): Remove shstrtab_length_fixed assignment.
+ Allocate first section header on BFD obstack rather than using
+ null_shdr.
+ (bfd_prpsinfo): Remove unused local variable newsect.
+
+Mon Apr 25 15:31:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (write_relocs): Undo patch of Apr 10; breaks Solaris.
+
+ * elfcode.h (bfd_section_from_shdr): Use bfd_make_section_anyway
+ to create sections. Check return value of recursive calls.
+ (bfd_section_from_phdr): Check return value of bfd_make_section.
+ (elf_symbol_from_bfd_symbol): Likewise.
+ (elf_object_p): Check return value of bfd_section_from_shdr.
+ (section_from_elf_index): Likewise.
+ (elf_slurp_symbol_table): Check return value of
+ section_from_elf_index.
+ (bfd_prstatus): Return boolean value. Check return value of
+ bfd_make_section.
+ (bfd_fpregset): Likewise.
+ (bfd_prpsinfo): Return boolean value.
+ (elf_corefile_note): Check return values of bfd_prstatus,
+ bfd_fpregset, and bfd_prpsinfo.
+ (elf_core_file_p): Check return value of elf_corefile_note.
+
+Fri Apr 22 11:08:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Get rid of the ECOFF .reginfo section hack.
+ * ecoff.c (ecoff_mkobject_hook): Don't create a .reginfo section.
+ (ecoff_new_section_hook): Don't handle the .reginfo section.
+ (ecoff_sizeof_headers): Likewise.
+ (ecoff_get_section_contents): Likewise.
+ (ecoff_compute_section_file_positions): Likewise.
+ (ecoff_compute_reloc_file_positions): Likewise.
+ (ecoff_set_section_contents): Likewise.
+ (ecoff_write_object_contents): Likewise.
+ (ecoff_bfd_final_link): Likewise.
+ (ecoff_bfd_copy_private_bfd_data): Copy the GP value and the
+ register masks.
+ (bfd_ecoff_get_gp_value): New function.
+ (bfd_ecoff_set_gp_value): New function.
+ (bfd_ecoff_set_regmasks): New function.
+ * bfd-in.h (bfd_ecoff_get_gp_value): Declare.
+ (bfd_ecoff_set_gp_value): Declare.
+ (bfd_ecoff_set_regmasks): Declare.
+ * bfd-in2.h: Rebuilt.
+
+ Fix ECOFF objcopy to actually copy debugging information.
+ * ecoff.c (ecoff_bfd_copy_private_bfd_data): New function.
+ (ecoff_get_extr): Assume that any ECOFF symbol with local clear is
+ an external symbol, rather than checking the symbol flags. Only
+ check the flags for non-ECOFF symbols.
+ * ecofflink.c (bfd_ecoff_debug_externals): Don't crash if the
+ output_section field of the symbol section is NULL.
+ * libecoff.h (ecoff_bfd_copy_private_bfd_data): Declare as
+ function rather than defining as macro.
+
+ * ieee.c (ieee_object_p): Set bfd_error_got_wrong_format if
+ appropriate.
+
+ * targets.c (bfd_target_vector): Add bfd_elf32_powerpc_vec.
+
+ * aout-adobe.c (aout_adobe_set_arch_mach): Check return value of
+ bfd_default_set_arch_mach. Accept bfd_arch_m68k as well as
+ bfd_arch_unknown.
+ * coffcode.h (coff_set_arch_mach): Check return value of
+ bfd_default_set_arch_mach.
+ * elfcode.h (elf_set_arch_mach): Don't check a list of ELF
+ architectures, just see if the desired architecture matches what
+ the ELF backend permits.
+
+ * coffcode.h (coff_set_arch_mach_hook): Rename SHMAGIC to
+ SH_ARCH_MAGIC to match change in coff/sh.h.
+ (coff_set_flags): Likewise.
+
+ Follow convention in which each NLM header has an 8 byte stamp
+ followed by a four byte length.
+ * libnlm.h (struct nlm_obj_tdata): Rename nlm_cygnus_section_hdr
+ to nlm_cygnus_ext_header, and change type to
+ Nlm_Internal_Cygnus_Ext_Header.
+ (nlm_cygnus_ext_header): Rename from nlm_cygnus_section_header.
+ * nlmcode.h (nlm_swap_auxiliary_headers_in): Use CyGnUsEx instead
+ of CyGnUsSeCs. Rename from cygnus_section to cygnus_ext. Require
+ length word to be 8.
+ (nlm_swap_auxiliary_headers_out): Rename from cygnus_section to
+ cygnus_ext. Set length word to 8.
+ (nlm_compute_section_file_positions): Rename from cygnus_section
+ to cygnus_ext.
+
+Thu Apr 21 22:54:22 1994 Stu Grossman (grossman at cygnus.com)
+
+ * nlmcode.h (nlm_swap_auxiliary_headers_in): Keep section table
+ (from CyGnUsSeCs) in more permanent memory to keep section names
+ from getting trashed.
+
+Thu Apr 21 09:29:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * libelf.h (elf_obj_tdata): Add members for dynamic symbol table
+ handling.
+ * elfcode.h (bfd_section_from_shdr): Handle dynamic symbol table.
+ * elfcode.h (elf_slurp_symbol_table): Take additional parameter
+ to select static or dynamic symbol table and return number of
+ symbols slurped or -1 on error.
+ * elfcode.h (elf_get_symtab): Set bfd symcount from
+ elf_slurp_symbol_table result.
+ * elfcode.h (elf_get_dynamic_symtab_upper_bound,
+ elf_canonicalize_dynamic_symtab): New functions to handle dynamic
+ symbol table.
+ * elf32-target.h, elf64-target.h (BFD_JUMP_TABLE_DYNAMIC):
+ Change to handle dynamic symbol table, provide default definitions
+ for dynamic relocs.
+ * aoutx.h (howto_table_std, NAME(aout,swap_std_reloc_out),
+ NAME(aout,swap_std_reloc_in), aout_link_input_section_std,
+ aout_link_reloc_link_order): Handle r_jmptable and r_relative
+ relocations.
+
+Thu Apr 21 11:58:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Clean up uses of _bfd_dummy_target (from Peter Schauer).
+ * libbfd.c (_bfd_dummy_target): Set bfd_error_wrong_format.
+ * nlm-target.h (nlm_core_file_p): Define as _bfd_dummy_target, not
+ NULL.
+ * srec.c (srec_vec): Use _bfd_dummy_target, not NULL, in
+ _bfd_check_format.
+ (symbolsrec_vec): Likewise.
+ * tekhex.c (tekhex_vec): Likewise.
+
+ * libnlm.h (struct nlm_obj_tdata): Add nlm_cygnus_section_hdr
+ field.
+ (nlm_cygnus_section_header): New accessor macro.
+ * nlmcode.h (nlm_object_p): Free new tdata structure if failure.
+ Add fixed sections before swapping in auxiliary headers. After
+ adding sections, treat errors as real, not as wrong format.
+ (nlm_swap_auxiliary_headers_in): Swap in the sections header; add
+ sections to the BFD for each section it describes.
+ (nlm_swap_auxiliary_headers_out): Swap out the sections header.
+ (nlm_compute_section_file_positions): Account for the size of the
+ sections header.
+
+Wed Apr 20 16:45:51 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * coff-sparc.c (sparccoff_vec): Change minimum alignment power to
+ 2, so that stab sections can be multiples of 4 bytes only.
+
+ * hosts/i386aix.h: Changes to avoid prototypes conflicts with the
+ ones defined in stdlib.h. (From Minh Tran-Le.)
+
+Wed Apr 20 14:15:21 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlm32-ppc.c: Complete rewrite for new version of PowerPC
+ NetWare. Old code still present, but ifdeffed out.
+
+ * nlmcode.h (nlm_swap_auxiliary_headers_in): Don't assume a
+ particular format for the customer header. Allocate a block of
+ memory and read it into that.
+ (nlm_swap_auxiliary_headers_out): Write out the block of memory.
+ (nlm_compute_section_file_positions): Include length of customer
+ header when computing its size.
+
+Mon Apr 18 14:27:17 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_prep_headers): Get the space's number from the
+ backend private section data rather than target_index.
+ (bfd_som_set_section_attributes): Store the space's number
+ in the backend private section data rather than target_index.
+
+ * som.h (som_copyable_section_data_struct): Add space_number.
+
+Fri Apr 15 12:22:07 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-a29k.c (reloc_processing): Always set the address of a
+ R_IHCONST reloc to that of the immediately preceding R_IHIHALF.
+ gas does this anyhow, but some other assemblers seem to leave
+ garbage in the R_IHCONST address field.
+
+ * bfd/archive.c: Consistently use ARFMAG; from
+ schwab@issan.informatik.uni-dortmund.de (Andreas Schwab).
+ (_bfd_write_archive_contents): Use ARFMAG rather than '`' and
+ '\012'.
+ (bsd_write_armap): Likewise.
+ (coff_write_armap): Likewise.
+
+ * coff-mips.c (mips_relocate_section): When relaxing, adjust local
+ relocs against the .text section as required.
+ * ecofflink.c (bfd_ecoff_debug_accumulate): When relaxing, adjust
+ PDR addresses as required.
+
+ * ecoff.c (ecoff_emit_aggregate): Take fdr argument. Map fdr
+ index through rfd map if it exists. Check for a couple of cases
+ which gdb handles specially. Change all callers.
+ (ecoff_type_to_string): Take fdr argument rather than aux_ptr and
+ bigendian argument. Change all callers.
+ (ecoff_print_symbol): Handle stStruct, stUnion and stEnum.
+
+Thu Apr 14 13:05:10 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-mips.c (mips_howto_table): Add dummy entries to account for
+ numbering changes in include/coff/mips.h. Add entries for
+ MIPS_R_RELHI and MIPS_R_RELLO.
+ (mips_ecoff_swap_reloc_in): Handle an extra bit for the reloc type
+ when little endian. Treat internal MIPS_R_RELLO or MIPS_R_RELHI
+ relocs like MIPS_R_SWITCH, and convert r_offset from 24 to 32
+ bits.
+ (mips_ecoff_swap_reloc_out): Likewise.
+ (mips_adjust_reloc_in): Handle internal MIPS_R_RELLO or
+ MIPS_R_RELHI relocs like MIPS_R_SWITCH.
+ (mips_adjust_reloc_out): Likewise.
+ (mips_relhi_addr, mips_relhi_addend): New static variables.
+ (mips_relhi_reloc, mips_rello_reloc): New functions.
+ (mips_bfd_reloc_type_lookup): Turn BFD_RELOC_PCREL_HI16_S into
+ MIPS_R_RELHI and turn BFD_RELOC_PCREL_LO16 into MIPS_R_RELLO.
+ (mips_relocate_hi): Rename from mips_relocate_refhi, and add pcrel
+ argument. Changed all callers.
+ (mips_relocate_section): Rename got_reflo to got_lo and
+ reflo_int_rel to lo_int_rel. Handle MIPS_R_RELLO and MIPS_R_RELHI
+ relocs.
+ (mips_relax_section): Adjust MIPS_R_RELHI/MIPS_R_RELLO pairs when
+ expanding a PC relative call.
+
+ * reloc.c (bfd_reloc_code_real_type): Add BFD_RELOC_PCREL_HI16_S
+ and BFD_RELOC_PCREL_LO16.
+ * bfd-in2.h: Rebuilt.
+
+Wed Apr 13 11:50:07 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * coff-sparc.c (sparccoff_vec): Set minimum alignment power to 3.
+
+Tue Apr 12 13:36:20 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_write_fixups): Always emit at least
+ one relocation for any non-bss section.
+
+Mon Apr 11 14:41:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (assign_file_positions_except_relocs): Don't require
+ the file alignment to correspond to the page size when linking
+ with -N.
+
+Sun Apr 10 01:02:24 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elfcode.h (write_relocs): For rela relocations, adjust the
+ addend for relocations involving section symbols to account
+ for the lossage of 1:1 mapping from input section symbols to
+ output section symbols.
+
+Fri Apr 8 12:22:02 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (NAME(aout,make_sections)): New function.
+ (NAME(aout,some_aout_object_p)): Call NAME(aout,make_sections)
+ rather than making sections inline.
+ (NAME(aout,mkobject)): Don't make any sections.
+ (NAME(aout,adjust_sizes_and_vmas)): Call NAME(aout,make_sections).
+ (NAME(aout,final_link)): Don't dereference obj_textsec (abfd) or
+ obj_datasec (abfd) if they are NULL.
+ * libaout.h (NAME(aout,make_sections)): Declare.
+ * bout.c (b_out_mkobject): Don't make any sections.
+ (b_out_write_object_contents): Call aout_32_make_sections.
+ (b_out_set_section_contents): Likewise.
+ * i386os9k.c (os9k_mkobject): Don't make any sections.
+ (os9k_write_object_contents): Call aout_32_make_sections.
+ (os9k_set_section_contents): Likewise.
+
+ * aoutx.h (NAME(aout,new_section_hook)): Don't set N_EXT in target
+ index.
+
+Wed Apr 6 20:44:56 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * config.bfd, configure.host: Add mips-*-sysv4* support.
+
+Thu Apr 7 14:23:05 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-mips.c (mips_howto_table): Add entry for MIPS_R_SWITCH.
+ (mips_ecoff_swap_reloc_in): For MIPS_R_SWTICH, copy r_symndx into
+ r_offset and set r_symndx to RELOC_SECTION_TEXT.
+ (mips_ecoff_swap_reloc_out): For MIPS_R_SWITCH, get the r_symndx
+ value from the r_offset field.
+ (mips_adjust_reloc_in): Maximum r_type value is now MIPS_R_SWITCH.
+ For MIPS_R_SWITCH, copy the r_offset field into the addend field.
+ (mips_adjust_reloc_out): For MIPS_R_SWITCH, copy the addend field
+ into the r_offset field.
+ (mips_switch_reloc): New function.
+ (mips_bfd_reloc_type_lookup): Translate BFD_RELOC_GPREL32 into
+ MIPS_R_SWITCH.
+ (mips_relocate_section): Handle MIPS_R_SWITCH.
+ (mips_relax_section): Adjust MIPS_R_SWITCH offset if necessary.
+
+Thu Apr 7 11:10:51 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elfcode.h (elf_set_section_contents): Support calling the backend
+ function elf_backend_begin_write_processing when just beginning to
+ write an object file.
+
+ * libelf.h (elf_backend_begin_write_processing): Declare.
+
+ * elf{32,64}-target.h (elf_backend_begin_write_processing): Provide
+ a default definition.
+ (elf{32,64}_bed): Add elf_backend_begin_write_processing.
+
+ * elf32-hppa.h (elf_hppa_tc_symbol): Delete extern declaration.
+ (elf_hppa_tc_make_sections): Likewise.
+
+ * elf32-hppa.c (symext_chain_built): Delete.
+ (symext_chain_size): Renamed from symextn_contents_real_size.
+ (elf32_hppa_backend_{begin,final}_write_processing): New functions.
+ (add_entry_to_symext_chain): New function.
+ (hppa_elf_set_section_contents): Ignore writes to the symbol extension
+ section until it's been rebuilt internally.
+ (hppa_elf_get_section_contents): Symbol extension section is no
+ longer special.
+ (elf_backend_{begin,final}_write_processing): Define.
+ (elf_hppa_tc_make_sections): Simplify now that much code has
+ migrated into elf32_hppa_backend_{being,final}_write_processing.
+
+Wed Apr 6 17:24:14 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Add new target vectors to read the dynamic symbols and dynamic
+ relocs. Change a.out to use these rather than reading the dynamic
+ symbols and relocs along with the normal symbols and relocs.
+ * targets.c (bfd_target): Add fields
+ _bfd_get_dynamic_symtab_upper_bound,
+ _bfd_canonicalize_dynamic_symtab,
+ _bfd_get_dynamic_reloc_upper_bound,
+ _bfd_canonicalize_dynamic_reloc.
+ (BFD_JUMP_TABLE_DYNAMIC): Define.
+ * libbfd-in.h (_bfd_nodynamic_get_dynamic_symtab_upper_bound):
+ Define.
+ (_bfd_nodynamic_canonicalize_dynamic_symtab): Define.
+ (_bfd_nodynamic_get_dynamic_reloc_upper_bound): Define.
+ (_bfd_nodynamic_canonicalize_dynamic_reloc): Define.
+ * bfd.c (bfd_get_dynamic_symtab_upper_bound): Define.
+ (bfd_canonicalize_dynamic_symtab): Define.
+ (bfd_get_dynamic_reloc_upper_bound): Define.
+ (bfd_canonicalize_dynamic_reloc): Define.
+ * sunos.c (MY_read_dynamic_symbols): Don't define.
+ (MY_read_dynamic_relocs): Don't define.
+ (MY_get_dynamic_symtab_upper_bound): Define.
+ (MY_canonicalize_dynamic_symtab): Define.
+ (MY_get_dynamic_reloc_upper_bound): Define.
+ (MY_canonicalize_dynamic_reloc): Define.
+ (struct sunos_dynamic_info): Change type of dynsym_count and
+ dynrel_count to long. Add fields canonical_dynsym and
+ canonical_dynrel.
+ (sunos_read_dynamic_info): Check that BFD had DYNAMIC flag set.
+ Clear info->canonical_dynsym and info->canonical_dynrel.
+ (MY(read_dynamic_symbols)): Removed.
+ (MY(read_dynamic_relocs)): Removed.
+ (sunos_get_dynamic_symtab_upper_bound): New function.
+ (sunos_canonicalize_dynamic_symtab): New function.
+ (sunos_get_dynamic_reloc_upper_bound): New function.
+ (sunos_canonicalize_dynamic_reloc): New function.
+ * libaout.h: Declare struct reloc_ext_external and
+ reloc_std_external to avoid prototype problems.
+ (struct aout_backend_data): Remove fields read_dynamic_symbols and
+ read_dynamic_relocs.
+ (NAME(aout,translate_symbol_table)): Declare.
+ (NAME(aout,swap_ext_reloc_in)): Declare.
+ (NAME(aout,swap_std_reloc_in)): Declare.
+ * aoutx.h (NAME(aout,translate_symbol_table)): Renamed from
+ translate_symbol_table and made non-static. Changed all callers.
+ (NAME(aout,slurp_symbol_table)): Don't read dynamic symbols.
+ (NAME(aout,slurp_reloc_table)): Don't read dynamic relocs.
+ (NAME(aout,get_reloc_upper_bound)): Don't count dynamic relocs.
+ * aoutf1.h (aout_32_sunos4_write_object_contents): Don't bother to
+ remove dynamic symbols and relocs. They will no longer be
+ present.
+ (MY_read_dynamic_symbols): Don't define.
+ (MY_read_dynamic_relocs): Don't define.
+ (sunos4_aout_backend): Don't initialize dynamic entry points.
+ * aout-target.h (MY_read_dynamic_symbols): Don't define.
+ (MY_read_dynamic_relocs): Don't define.
+ (MY(backend_data)): Don't initialize dynamic entry points.
+ (MY_get_dynamic_symtab_upper_bound): If not defined, define to
+ _bfd_nodynamic version.
+ (MY_canonicalize_dynamic_symtab): Likewise.
+ (MY_get_dynamic_reloc_upper_bound): Likewise.
+ (MY_canonicalize_dynamic_reloc): Likewise.
+ * All backends: Added BFD_JUMP_TABLE_DYNAMIC to target vector.
+ * bfd-in2.h: Rebuilt.
+ * libbfd.h: Rebuilt.
+
+ * cf-m68klynx.c: Include sysdep.h.
+
+ * hp300hpux.c: Removed some spaces in uses of NAME to avoid
+ problems with traditional C compilers.
+
+ * targets.c (bfd_target): Rearranged fields in target vector.
+ Removed _bfd_debug_info_start, _bfd_debug_info_end and
+ _bfd_debug_info_accumulate, which were never used.
+ (BFD_JUMP_TABLE_GENERIC, BFD_JUMP_TABLE_COPY): Defined.
+ (BFD_JUMP_TABLE_CORE, BFD_JUMP_TABLE_ARCHIVE): Defined.
+ (BFD_JUMP_TABLE_SYMBOLS, BFD_JUMP_TABLE_RELOCS): Defined.
+ (BFD_JUMP_TABLE_WRITE, BFD_JUMP_TABLE_LINK): Defined.
+ * All backends: Changed to use the new BFD_JUMP_TABLE_* macros
+ rather than the single JUMP_TABLE macro. Removed many of the
+ weird macro definitions needed to support the monolithic
+ JUMP_TABLE.
+ * bfd-in.h (JUMP_TABLE): Removed.
+ * libbfd-in.h: Define a bunch of macros, and declare a few
+ functions, for use with the new BFD_JUMP_TABLE_* macros.
+ * libbfd.c (_bfd_dummy_new_section_hook): Removed.
+ (bfd_false): Set bfd_error_invalid_operation.
+ (bfd_nullvoidptr): Likewise.
+ (bfd_n1): New function.
+ (_bfd_nocore_core_file_matches_executable_p): Renamed from
+ _bfd_dummy_core_file_matches_executable_p.
+ (_bfd_nocore_core_file_failing_command): Similar rename. Set
+ bfd_error_invalid_operation.
+ (_bfd_nocore_core_file_failing_signal): Likewise.
+ (_bfd_generic_get_section_contents): Renamed from
+ bfd_generic_get_section_contents. Changed all callers.
+ (_bfd_generic_set_section_contents): Similar rename.
+ * ieee.c: #if 0 out ieee_bfd_debug_info_start,
+ ieee_bfd_debug_info_end, ieee_bfd_debug_info_accumulate. They
+ were never called.
+ * bfd-in2.h: Rebuilt.
+ * libbfd.h: Rebuilt.
+
+Tue Apr 5 22:10:04 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * Crude support for examining dynamic libraries.
+ * som.c (som_object_setup): Set DYNAMIC flag for SHL_MAGIC and
+ DL_MAGIC objects.
+ (som_prep_headers): Preserve the system_id for DYNAMIC objects.
+ Use SHL_MAGIC as the magic number of the DYNAMIC flag is set.
+ Write exec headers for DYNAMIC objects.
+ (som_begin_writing): DYNAMIC objects have the same alignment
+ restrictions as D_PAGED objects.
+ (bfd_section_from_som_symbol): Treat DYNAMIC objects like EXEC_P
+ objects.
+ (object_flags): Add DYNAMIC.
+
+Tue Apr 5 17:48:52 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * i386lynx.c, sparclynx.c (NAME): Remove embedded whitespace in
+ macro uses, confuses some non-ANSI compilers.
+
+Tue Apr 5 15:50:01 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_free_cached_info): Add missing PARAMS decl.
+ Don't free anything if we don't have a bfd_object.
+ (som_close_and_cleanup): Call som_bfd_free_cached_info.
+
+Tue Apr 5 11:22:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-mips.c (mips_elf_final_link): Don't remove empty sections.
+ It turns out not to be required on Irix 5, and it causes problems
+ if the sections happen to contain symbols.
+
+ * elfcode.h (write_shdrs_and_ehdr): Correct bfd_write check.
+
+ * aoutx.h (NAME(aout,canonicalize_reloc)): Don't error out if
+ section->relocation is NULL; malloc might have returned NULL when
+ given a zero size if there were no relocations.
+ * bout.c (b_out_canonicalize_reloc): Likewise.
+ * coffcode.h (coff_canonicalize_reloc): Likewise.
+ * ecoff.c (ecoff_canonicalize_reloc): Likewise.
+ * elfcode.h (elf_canonicalize_reloc): Likewise.
+ * mipsbsd.c (MY(canonicalize_reloc)): Likewise.
+ * i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise.
+ * nlmcode.h (nlm_canonicalize_reloc): Likewise.
+ * som.c (som_canonicalize_reloc): Likewise.
+ * hp300hpux.c (MY(slurp_reloc_table)): Likewise. Also, if malloc
+ returns NULL, don't report an error if we asked for zero bytes.
+ * i386lynx.c (NAME(lynx,slurp_reloc_table)): If malloc returns
+ NULL, don't report an error if we asked for zero bytes.
+ * nlmcode.h (nlm_slurp_reloc_fixups): Likewise.
+
+Mon Apr 4 15:30:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (NAME(aout,bfd_free_cached_info)): Don't free anything
+ if we don't have a bfd_object.
+
+ Made sure that every call to bfd_read, bfd_write, and bfd_seek
+ checks the return value and handled bfd_error correctly. These
+ changes are not itemised. Also:
+ * aoutx.h (emit_strtab): Change return type to boolean, and return
+ errors.
+ (NAME(aout,write_syms)): Check emit_strtab return value.
+ (NAME(aout,final_link)): Likewise.
+ * coffcode.h (coff_write_relocs): Change return type to boolean,
+ and return errors.
+ (coff_write_object_contents): Check coff_write_relocs return
+ value.
+ * i386os9k.c (os9k_swap_exec_header_in): Change return type to
+ boolean.
+ (os9k_object_p): Check os9k_swap_exec_header_in return value.
+ * oasys.c (oasys_read_record): Change return type to boolean.
+ (oasys_slurp_symbol_table: Check oasys_read_record return value.
+ (oasys_object_p, oasys_slurp_section_data): Likewise.
+ (oasys_write_record): Change return type to boolean.
+ (oasys_write_syms): Likewise. Also, check oasys_write_record
+ return value.
+ (oasys_write_sections): Check oasys_write_record return value.
+ (oasys_write_header): Change return type to boolean. Check
+ oasys_write_record return value.
+ (oasys_write_end, oasys_write_data): Likewise.
+ (oasys_write_object_contents): Check return values of
+ oasys_write_header, oasys_write_syms, oasys_write_data, and
+ oasys_write_end.
+ * srec.c (srec_write_record): Change return type to boolean.
+ (srec_write_header): Likewise. Also, check srec_write_record
+ return value.
+ (srec_write_section, srec_write_terminator): Likewise.
+ (srec_write_symbols): Change return type to boolean.
+ (internal_srec_write_object_contents): Check return value of
+ srec_write_symbols, srec_write_header, srec_write_section, and
+ srec_write_terminator.
+
+ * Makefile.in: Rebuilt dependencies.
+
+Mon Apr 4 10:56:45 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * aix386-core.c (aix386_bfd_is_local_label): Correct cast from
+ asection to asymbol.
+ * ptrace-core.c (ptrace_unix_bfd_is_local_label): Correct cast from
+ bfd to asymbol.
+ * trad-core.c (trad_unix_bfd_is_local_label): Correct cast from
+ asection to asymbol.
+
+Sun Apr 3 18:27:29 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_slurp_string_table): Use malloc to allocate space
+ for the cached copy of the native string table.
+ (som_slurp_symbol_table): Likewise for the native symbol table.
+ (som_slurp_reloc_table): Likewise for the native and generic
+ relocation tables.
+ (som_bfd_free_cached_info): Free the cached native strings,
+ symbols, and relocations. Also free the canonical cached
+ relocations.
+
+Fri Apr 1 12:40:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_link_write_symbols): If keep_memory is false, make
+ sure the symbol name is stored in permanent memory before adding
+ it to the string table.
+
+ * archive.c (_bfd_write_archive_contents): Once we've found an
+ object, don't bother to look for more when deciding whether to
+ build a map.
+ (compute_and_write_armap): After adding the symbols for a BFD,
+ call bfd_free_cached_info on it.
+
+ Add bfd_free_cached_info support to a.out backends.
+ * aoutx.h (aout_get_external_symbols): Renamed from
+ aout_link_get_symbols. Read strings even if symbols have been
+ read. Store string size in obj_aout_string_size.
+ (NAME(aout,slurp_symbol_table)): Call aout_get_external_symbols to
+ read the symbols. Allocate the cached symbols with malloc, not
+ bfd_alloc.
+ (NAME(aout,slurp_reloc_table)): Allocate the cached relocs with
+ malloc, not bfd_alloc.
+ (NAME(aout,bfd_free_cached_info)): New function; free cached
+ symbols and relocs.
+ * libaout.h (struct aoutdata): Add external_string_size field.
+ (obj_aout_external_string_size): New accessor macro.
+ (NAME(aout,close_and_cleanup)): Don't declare.
+ (NAME(aout,bfd_free_cached_info)): Declare.
+ (aout_32_close_and_cleanup): Don't define.
+ (aout_64_close_and_cleanup): Don't define.
+ * aout-target.h (MY_bfd_free_cached_info): If not already defined,
+ define as NAME(aout,free_cached_info).
+ (MY_close_and_cleanup): If not already defined, define as
+ MY_bfd_free_cached_info.
+ * aout-adobe.c (aout_32_close_and_cleanup): Define.
+ (aout_32_bfd_free_cached_info): Don't define.
+ * bout.c (aout_32_close_and_cleanup): Define.
+ (aout_32_bfd_free_cached_info): Don't define.
+ * hp300hpux.c (MY_bfd_free_cached_info): Define as bfd_true.
+ (MY_close_and_cleanup): Don't define.
+ * i386lynx.c (NAME(lynx,slurp_reloc_table)): Allocate the cached
+ relocs with malloc, not bfd_alloc.
+ * i386os9k.c (aout_32_close_and_cleanup): Define.
+ (aout_32_bfd_free_cached_info): Don't define.
+
+ Add a new entry point to free memory cached by a BFD.
+ * targets.c (bfd_target): Add _bfd_free_cached_info field.
+ * bfd.c (bfd_free_cached_info): Define.
+ * bfd-in.h (JUMP_TABLE): Add _bfd_free_cached_info.
+ * bfd-in2.h: Rebuilt.
+ * All backends: Initialize bfd_free_cached_info entry point to
+ bfd_true.
+
+ * elf32-hppa.c (elf_hppa_reloc_type_lookup): Correct type of
+ first, unused, argument.
+ (hppa_elf_is_local_label): Declare instead of
+ som_bfd_is_local_label.
+
+ * coff-a29k.c (a29k_reloc): Add reloc_entry->address to value of
+ absolute R_IREL reloc.
+
+Thu Mar 31 11:52:15 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Added some support for Irix 4 shared libraries.
+ * ecoff.c (ecoff_new_section_hook): Set SEC_SHARED_LIBRARY for a
+ .lib section.
+ (ecoff_sec_to_styp_flags): Set SEC_SHARED_LIBRARY if
+ STYP_ECOFF_LIB bit is set.
+ (ecoff_compute_section_file_positions): Round the contents of a
+ .lib section up to the next page boundary.
+ (ecoff_set_section_contents): If we see a .lib section, increment
+ the vma by one to count the number of shared libraries we have.
+ (ecoff_write_object_contents): Don't crash if we see a
+ STYP_ECOFF_LIB section, and don't adjust text_start or data_start
+ or bss_size either.
+
+ * coffcode.h (CALC_ADDEND): Change to fetch original symbol value
+ from original BFD, rather than using value of current BFD symbol.
+ Needed for new linker.
+ * coff-sparc.c (CALC_ADDEND): Likewise.
+
+ * ecoff.c (ecoff_write_object_contents): Set the text_start and
+ data_start entries in the optional header correctly even if a text
+ or data section starts at location zero.
+
+ * reloc.c (bfd_reloc_code_real_type): Added BFD_RELOC_26 (from sef
+ and raeburn).
+ * bfd-in2.h: Rebuilt.
+
+ * nlm32-i386.c (nlm_i386_read_import): Null terminate the symbol
+ name.
+ * nlm32-alpha.c (nlm_alpha_read_import): Likewise.
+ * nlm32-sparc.c (nlm_sparc_read_import): Likewise.
+
+ * coffgen.c (coff_write_symbol): Reindented. Changed to return
+ boolean, and changed written to unsigned int *. Check error
+ returns from called functions.
+ (coff_write_alien_symbol): Likewise.
+ (coff_write_native_symbol): Likewise.
+ (coff_write_symbols): Likewise. Reworked checks on whether to
+ write symbol name to string table for clarity and to avoid core
+ dumping when given a non COFF symbol.
+ * libcoff-in.h (coff_write_symbols): Declare as returning boolean.
+ * libcoff.h: Rebuilt.
+ * coffcode.h (coff_write_object_contents): Check return value of
+ coff_write_symbols.
+
+Wed Mar 30 16:25:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Changes to let BFD return an error indication from
+ get_symtab_upper_bound, bfd_canonicalize_symtab,
+ bfd_get_reloc_upper_bound, and bfd_canonicalize_reloc. They now
+ return long instead of unsigned int, and use -1 to indicate an
+ error. Along the way, rename get_symtab_upper_bound to
+ bfd_get_symtab_upper_bound.
+ * bfd.c (bfd_get_reloc_upper_bound): Return long, and -1 on
+ errors.
+ (bfd_canonicalize_reloc): Likewise.
+ * syms.c (bfd_get_symtab_upper_bound): Renamed from
+ get_symtab_upper_bound.
+ * targets.c (bfd_target): Renamed _get_symtab_upper_bound to
+ _bfd_get_symtab_upper_bound, and changed it and
+ _bfd_canonicalize_symtab and _get_reloc_upper_bound and
+ _bfd_canonicalize_reloc to all return long.
+ * aoutx.h (NAME(aout,get_symtab)): Return long, and -1 on errors.
+ (NAME(aout,canonicalize_reloc)): Likewise.
+ (NAME(aout,get_reloc_upper_bound)): Likewise.
+ (NAME(aout,get_symtab_upper_bound)): Likewise.
+ * bout.c (b_out_canonicalize_reloc): Likewise.
+ (b_out_get_reloc_upper_bound): Likewise.
+ * coffcode.h (coff_canonicalize_reloc): Likewise.
+ * coffgen.c (coff_get_symtab_upper_bound): Likewise.
+ (coff_get_symtab): Likewise.
+ (coff_get_reloc_upper_bound): Likewise.
+ * ecoff.c (ecoff_get_symtab_upper_bound): Likewise.
+ (ecoff_get_symtab): Likewise.
+ (ecoff_canonicalize_reloc): Likewise.
+ * elfcode.h (elf_get_symtab_upper_bound): Likewise.
+ (elf_get_reloc_upper_bound): Likewise.
+ (elf_canonicalize_reloc): Likewise.
+ (elf_get_symtab): Likewise.
+ * hp300hpux.c (MY(get_symtab)): Likewise.
+ (MY(get_symtab_upper_bound)): Likewise.
+ (MY(canonicalize_reloc)): Likewise.
+ * i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise.
+ * ieee.c (ieee_slurp_external_symbols): Change return type to
+ boolean. Check for errors from get_symbol.
+ (ieee_slurp_symbol_table): Change return type to boolean. Check
+ for errors from ieee_slurp_external_symbols.
+ (ieee_get_symtab_upper_bound): Return long, and -1 on errors.
+ (ieee_get_symtab): Likewise.
+ (ieee_get_reloc_upper_bound): Likewise.
+ (ieee_canonicalize_reloc): Likewise.
+ * mipsbsd.c (MY(canonicalize_reloc)): Likewise.
+ * nlmcode.h (nlm_get_symtab_upper_bound): Likewise.
+ (nlm_get_symtab): Likewise.
+ (nlm_get_reloc_upper_bound): Likewise.
+ (nlm_canonicalize_reloc): Likewise.
+ * oasys.c (oasys_get_symtab_upper_bound): Likewise.
+ (oasys_get_symtab): Likewise.
+ (oasys_get_reloc_upper_bound): Likewise.
+ (oasys_canonicalize_reloc): Likewise.
+ * som.c (som_get_symtab_upper_bound): Likewise.
+ (som_get_symtab): Likewise.
+ (som_get_reloc_upper_bound): Likewise.
+ (som_canonicalize_reloc): Likewise.
+ * srec.c (srec_get_symtab_upper_bound): Likewise.
+ (srec_get_symtab): Likewise.
+ (srec_get_reloc_upper_bound): Define as bfd_0l.
+ (srec_canonicalize_reloc): Likewise.
+ * tekhex.c (tekhex_get_symtab): Return long, and -1 on errors.
+ (tekhex_get_symtab_upper_bound): Likewise.
+ (tekhex_get_reloc_upper_bound): Define as bfd_0l.
+ (tekhex_canonicalize_reloc): Likewise.
+ * libaout.h (NAME(aout,get_symtab_upper_bound)): Change
+ declaration to return long.
+ (NAME(aout,get_symtab)): Likewise.
+ (NAME(aout,canonicalize_reloc)): Likewise.
+ (NAME(aout,get_reloc_upper_bound)): Likewise.
+ * libcoff-in.h (coff_get_symtab_upper_bound): Likewise.
+ (coff_get_symtab): Likewise.
+ (coff_get_reloc_upper_bound): Likewise.
+ * libecoff.h (ecoff_get_symtab_upper_bound): Likewise.
+ (ecoff_get_symtab): Likewise.
+ (ecoff_canonicalize_reloc): Likewise.
+ * libelf.h (bfd_elf32_get_symtab_upper_bound): Likewise.
+ (bfd_elf32_get_symtab): Likewise.
+ (bfd_elf32_get_reloc_upper_bound): Likewise.
+ (bfd_elf32_canonicalize_reloc): Likewise.
+ (bfd_elf64_get_symtab_upper_bound): Likewise.
+ (bfd_elf64_get_symtab): Likewise.
+ (bfd_elf64_get_reloc_upper_bound): Likewise.
+ (bfd_elf64_canonicalize_reloc): Likewise.
+ * libnlm.h (nlmNAME(get_symtab_upper_bound)): Likewise.
+ (nlmNAME(get_symtab)): Likewise.
+ (nlmNAME(get_reloc_upper_bound)): Likewise.
+ (nlmNAME(canonicalize_reloc)): Likewise.
+ * archive.c (compute_and_write_armap): Use error_return and
+ no_memory_return labels rather than freeing information in various
+ places. Change storage, symcount and src_count to long. Check
+ errors from bfd_get_symtab_upper_bound and
+ bfd_canonicalize_symtab.
+ * bout.c (b_out_relax_section): Change reloc_size to long. Check
+ for errors from bfd_get_reloc_upper_bound and
+ bfd_canonicalize_reloc.
+ (b_out_get_relocated_section_contents): Likewise.
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents):
+ Likewise.
+ * elf32-mips.c: Likewise.
+ * elf32-hppa.c (hppa_elf_stub_finish): Likewise.
+ (hppa_look_for_stubs_in_section): Check for errors from
+ bfd_get_symtab_upper_bound, bfd_canonicalize_symtab, and
+ bfd_canonicalize_reloc.
+ * ecofflink.c (bfd_ecoff_debug_accumulate_other): Check for errors
+ from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab.
+ * linker.c (generic_link_read_symbols): Likewise.
+ (_bfd_generic_final_link): Check for errors from
+ bfd_get_reloc_upper_bound and bfd_canonicalize_reloc.
+ * reloc.c (bfd_generic_get_relocated_section_contents): Likewise.
+ * reloc16.c (bfd_coff_reloc16_relax_section): Likewise.
+ (bfd_coff_reloc16_get_relocated_section_contents): Likewise.
+ * libbfd.c (bfd_0l): New function.
+ * libbfd-in.h (bfd_0l): Declare.
+ * aix386-core.c: Change get_symtab_upper_bound, get_symtab,
+ get_reloc_upper_bound, and canonicalize_reloc to use bfd_0l rather
+ than bfd_0u.
+ * cisco-core.c, hppabsd-core.c, hpux-core.c: Likewise.
+ * irix-core.c, osf-core.c, ptrace-core.c, trad-core.c: Likewise.
+ * bfd-in2.h: Rebuilt.
+ * libbfd.h: Rebuilt.
+ * libcoff.h: Rebuilt.
+
+ * nlm32-sparc.c (nlm_sparc_read_reloc): Remove unused variables
+ temp and name.
+
+Wed Mar 30 08:33:04 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/dpx2.h: Define POSIX_UTIME.
+
+Wed Mar 30 00:31:49 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * i386dynix.c, config/i386-dynix.mt: New files, handling Dynix
+ variant of a.out.
+ * configure.in, config.bfd: Use them for Dynix.
+ * Makefile.in: Add dependencies for i386dynix.o.
+ * targets.c: Add definition for i386dynix_vec.
+ * hosts/symmetry.h: Do not define TRAD_CORE_USER_OFFSET for Dynix.
+ Define HOST_DATA_START_ADDR and TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
+ for Dynix. Remove inclusion of dynix3.h, Dynix bfd is now handled by
+ i386dynix.c
+
+Mon Mar 28 12:53:27 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Makefile.in (BFD32_BACKENDS): Add coff-sparc.o.
+
+ * coffcode.h (coff_set_flags): Handle bfd_arch_powerpc like
+ bfd_arch_rs6000.
+
+ * config.bfd (powerpc-*-aix*): New target; use rs6000.mt.
+ * config/rs6000.mt (SELECT_ARCHITECTURES): Add bfd_powerpc_arch.
+
+ * aoutx.h (translate_from_native_sym_flags): Set SEC_RELOC flag
+ for generated constructor section.
+
+Sun Mar 27 16:25:22 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_begin_writing): New approach at dealing with holes
+ in executables left by the HP linker. Does not rely on subspace
+ alignments as subspaces are *NOT* guaranteed to be properly
+ aligned in an executable (can you believe that!).
+
+Sat Mar 26 10:25:43 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_get_section_contents): New function. Do not try
+ to actually read data from a section that doesn't have either
+ SEC_LOAD or SEC_DEBUGGING set (eg $BSS$) just return true.
+
+ * libbfd.c (bfd_read): Set bfd_error as appropriate for a short
+ read. (bfd_error_system_call or bfd_error_file_truncated).
+
+ * som.c: Do not blindly set bfd_error_system_call after a
+ failing bfd_read, bfd_write, or bfd_seek. In a few places
+ (like som_object_p) override the error status set by bfd_read.
+
+ * aix386-core.c, aout-encap,c archive.c, bout.c: Likewise.
+ * coff-rs6000.c, coffgen.c ecoff.c, elf.c: Likewise.
+ * elf32-hppa.c, elfcode.h, hp300hpux.c, i386lynx.c: Likewise.
+ * nlm32-alpha.c, nlm32-i386.c, nlm32-sparc.c: Likewise.
+
+ * som.c: Check return values from several bfd_{seek,read,write}
+ calls that we just assumed were not failing.
+
+Fri Mar 25 11:44:06 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hosts/sysv4.h (HAVE_PROCFS): Add comments about ptx4.
+ * config/sysv4.mh: Add comment.
+ * config/symmetry.mh: Change comment.
+ * configure.host: Use sysv4, not symmetry, for i[34]86-sequent-sysv4*.
+
+Fri Mar 25 17:10:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Changes to support linker relaxing of embedded MIPS PIC code to
+ use a five instruction sequence for function calls which are out of
+ range of the bal instruction.
+ * libecoff.h (struct ecoff_section_tdata): Define.
+ (ecoff_section_data): Define.
+ (ecoff_bfd_relax_section): Don't define.
+ * ecoff.c (ecoff_final_link_debug_accumulate): Don't read or free
+ the debugging information if it has already been read.
+ (ecoff_indirect_link_order): Handle _cooked_size being different
+ from _raw_size. Don't reread the contents or the relocs if they
+ have already been read in.
+ * coff-mips.c (mips_howto_table): Change bitsize of PCREL16 from
+ 18 to 16.
+ (PCREL16_EXPANSION_ADJUSTMENT): Define.
+ (mips_relocate_refhi): Take adjust argument.
+ (mips_relocate_section): Handle reloc offsets stored in section
+ used_by_bfd field. Call mips_relax_pcrel16 to handle details of
+ expanding an out of range PCREL16. Keep trace of adjustments
+ required by expansions. Set s and unset h when converting a reloc
+ from undefined to section. Change handling of PC relative relocs:
+ if against a section, they are correct in the object file, if
+ against an external symbol they are pcrel_offset.
+ (mips_relax_section): New function.
+ (mips_relax_pcrel16): New function.
+ (ecoff_bfd_relax_section): Define.
+ * coff-alpha.c (ecoff_bfd_relax_section): Define.
+ * ecofflink.c (bfd_ecoff_debug_accumulate): Handle adjustments
+ built by mips_relax_section when writing out addresses.
+ * elf32-mips.c (mips_elf_read_ecoff_info): Clear adjust field.
+
+ * aoutx.h (NAME(aout,find_nearest_line)): The caller expects
+ functionname_ptr to be set to a symbol name, so prepend
+ symbol_leading_char.
+
+Thu Mar 24 11:33:46 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * coff-h8300.c (h8300_reloc16_extra_cases): Add relaxing info
+ for 16bit relative branches.
+ * coff-h8500.c (r_high8, r_low16, r_high16): Don't complain on
+ overflow.
+
+Thu Mar 24 09:21:13 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_prep_for_ar_write): Ignore non-SOM objects.
+ (som_bfd_ar_write_symbol_stuff, som_write_armap): Likewise.
+
+Wed Mar 23 14:29:31 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * netbsd386.c (N_SET_FLAGS): Delete the old definition.
+
+Wed Mar 23 14:58:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Clean up the relaxing code for the new linker.
+ * targets.c (_bfd_relax_section): Take boolean *again argument
+ rather than asymbol list.
+ * bfd.c (bfd_relax_section): Change name of fourth argument from
+ symbols to again.
+ * reloc.c (bfd_generic_relax_section): Take boolean *again
+ argument rather than asymbol list. Always return true.
+ * bout.c: Include genlink.h.
+ (aligncode, perform_slip): Declare.
+ (perform_slip): Take BFD argument rather than asymbol list.
+ Changed all callers. Get the symbols from the BFD. Change the
+ hash table entry value as well as the symbol value.
+ (abs32code): Take BFD argument rather than asymbol list. Changed
+ all callers.
+ (aligncode): Likewise.
+ (b_out_relax_section): Take boolean *again argument rather than
+ asymbol list. Only return false if an error occurred. Set *again
+ to false. Get symbols from BFD.
+ * reloc16.c: Include genlink.h.
+ (bfd_perform_slip): Take BFD argument rather than asymbol list.
+ Get the symbols from the BFD. Change the hash table entry value
+ as well as the symbol value.
+ (bfd_coff_reloc16_relax_section): Take boolean *again argument
+ rather than asymbol list. Only return false if an error occurred.
+ Set *again to false. Get symbols from BFD.
+ * coffcode.h (bfd_coff_backend_data): Change
+ _bfd_coff_reloc16_estimate to take BFD argument rather than
+ asymbol list.
+ (bfd_coff_reloc16_estimate): Corresponding change.
+ (dummy_reloc16_estimate): Corresponding change.
+ * libcoff-in.h (bfd_coff_reloc16_relax_section): Change
+ declaration to take boolean * rather than asymbol list.
+ (bfd_perform_slip): Change declaration to take BFD rather than
+ asymbol list.
+ * coff-h8300.c (h300_reloc16_estimate): Take BFD argument rather
+ than asymbol list. Changed calls to bfd_perform_slip.
+ * bfd-in2.h: Rebuilt.
+ * libbfd.h: Rebuilt.
+ * libcoff.h: Rebuilt.
+ * Makefile.in: Rebuilt dependencies.
+
+ * genlink.h (_bfd_generic_link_get_symbols): Define.
+ (_bfd_generic_link_get_symcount): Define.
+ * linker.c (generic_link_read_symbols): New function.
+ (generic_link_add_object_symbols): Use it. Use
+ _bfd_generic_link_get_symbols and _bfd_generic_link_get_symcount
+ to get the symbols from the BFD.
+ (generic_link_check_archive_element): Likewise.
+ (_bfd_generic_final_link): Likewise.
+ (_bfd_generic_link_output_symbols): Likewise.
+ (default_indirect_link_order): Likewise.
+ (generic_link_add_symbol_list): Store pointer to hash table entry
+ in asymbol udata field.
+
+Tue Mar 22 13:09:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-mips.c (mips_howto_table): Add entry for new MIPS_R_PCREL16
+ reloc, used in embedded PIC code.
+ (mips_adjust_reloc_in): Change sanity check to permit new reloc.
+ (mips_bfd_reloc_type_lookup): Turn BFD_RELOC_16_PCREL_S2 into
+ MIPS_R_PCREL16.
+
+ * elf32-mips.c (mips_elf_final_link): Account for link_order
+ relocs when allocating space for relocations. Set SEC_RELOC flag
+ for any section which has relocs. Handle link_order relocs in
+ link_order loop. Use _bfd_generic_link_add_symbols_collect for
+ add_symbls entry point.
+
+ * linker.c (_bfd_generic_final_link): Set reloc_count to 0 before
+ counting relocs. Set SEC_RELOC flag for any section which has
+ relocs.
+
+ * linker.c (_bfd_default_link_order): Handle bfd_data_link_order.
+
+ * linker.c (_bfd_generic_link_add_symbols): Just call
+ generic_link_add_symbols.
+ (_bfd_generic_link_add_symbols_collect): New function, like
+ _bfd_generic_link_add_symbols but also collect constructors and
+ destructors by name as collect2 does.
+ (generic_link_add_symbols): New function, like old
+ _bfd_generic_link_add_symbols but with collect argument.
+ (generic_link_add_object_symbols): Take collect argument.
+ (generic_link_check_archive_element_no_collect): New function.
+ (generic_link_check_archive_element_collect): New function.
+ (generic_link_check_archive_element): Take collect argument.
+ (generic_link_add_symbol_list): Take collect argument.
+ (_bfd_generic_link_add_one_symbol): Rename constructor argument to
+ collect.
+ * libbfd-in.h (_bfd_generic_link_add_symbols_collect): Declare.
+ * libbfd.h: Rebuilt.
+
+Tue Mar 22 10:04:00 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * archive.c (bfd_construct_extended_name_table): Use ar_padchar
+ for first character in an extended name.
+ (_bfd_write_archive_contents): If ar_padchar == '/', then use
+ "//" as the name of the special archive member holding the
+ extended name table.
+
+Mon Mar 21 12:28:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Support for link_order types which generate relocs in order to
+ support -Ur in the linker.
+ * linker.c (generic_link_add_symbol_list): Remove bitsize argument
+ from call to _bfd_generic_link_add_one_symbol.
+ (_bfd_generic_link_add_one_symbol): Remove bitsize argument.
+ Don't pass bitsize to constructor call back. Pass BFD_RELOC_CTOR
+ instead of bitsize to add_to_set call back.
+ (_bfd_generic_final_link): Account for link_order relocs when
+ allocating space for relocations. Handle them in link_order loop.
+ (_bfd_generic_reloc_link_order): New function.
+ (_bfd_default_link_order): If a reloc_link_order is seen here,
+ abort.
+ (_bfd_count_link_order_relocs): New function.
+ * libbfd-in.h (_bfd_generic_link_add_one_symbol): Remove bitsize
+ argument from declaration.
+ (_bfd_generic_reloc_link_order): Declare.
+ (_bfd_count_link_order_relocs): Declare.
+ * libbfd.h: Rebuilt.
+ * aoutx.h (aout_link_add_symbols): Remove bitsize argument from
+ call to _bfd_generic_link_add_one_symbol.
+ (NAME(aout,final_link)): Account for link_order relocs when
+ allocating space for relocations. Handle them after handling all
+ input BFDs.
+ (aout_link_reloc_link_order): New function.
+ * ecoff.c (ecoff_link_add_externals): Remove bitsize argument from
+ call to _bfd_generic_link_add_one_symbol.
+ (ecoff_bfd_final_link): Account for link_order relocs when
+ allocating space for relocations. Handle them in link_order loop.
+ (ecoff_link_write_external): Set the storage class of a defined
+ linker created symbol based on the section it is in. Correct
+ bfd_link_hash_weak case to use .sc rather than .st.
+ (ecoff_reloc_link_order): New function.
+ * coff-alpha.c (alpha_bfd_reloc_type_lookup): Handle
+ BFD_RELOC_CTOR.
+ * coff-mips.c (mips_bfd_reloc_type_lookup): Likewise.
+
+ * sunos.c (sunos_read_dynamic_info): Remove unused locals dynsym
+ and buf.
+
+ * cisco-core.c (cisco_core_file_p): Only pass one argument to
+ bfd_zmalloc. Free a pointer, not a union.
+ (cisco_bfd_is_local_label): Correct cast from asection to asymbol.
+
+Sun Mar 20 09:24:36 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * bfd/som.c (som_begin_writing): Fix thinko (off by one error).
+
+ * som.c (bfd_section_from_som_symbol): Only to do the value
+ comparison for function symbols within executables.
+
+ * som.c (bfd_section_from_som_symbol): Renamed from
+ som_section_from_subspace_index. Pass in a native SOM symbol.
+ For executables, iterate through the sections to find out
+ which contains the symbol's address rather than using the
+ symbol_info field. (symbol_info has a different meaning for
+ dynamicly linked executables.)
+
+ * trad-core.c (trad_unix_core_file_p): Don't pass abfd to
+ bfd_zmalloc.
+
+ * som.c (som_begin_writing): Fix braino (one call to align
+ space/subspace data was done unconditionally rather than
+ just for executables.)
+
+ * som.c (som_begin_writing): Align text in all executables to
+ make HPUX kernel happy. Fixes strip/objcopy for shared
+ executables.
+
+Sat Mar 19 07:06:59 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_begin_writing): Account for alignment needs of
+ subspaces too when writing executables. Never request a negative
+ bss size. Fixes some problems with demand paged executables,
+ still having problems with pure executables and shared executables.
+
+Fri Mar 18 19:12:47 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * trad-core.c (trad_unix_core_file_p): Call bfd_zmalloc not
+ bfd_zalloc for rawptr, because later on we may call free, not
+ bfd_release, on it.
+
+ * bfd.c (struct _bfd): Add cisco_core_struct to tdata union.
+ * libbfd.c (bfd_read, bfd_seek): Add comments regarding errors.
+ * cisco-core.c: New file.
+ * Makefile.in: Change accordingly.
+ * configure.in: Recognize cisco_core_vec.
+ * config/m68k-aout.mt (SELECT_VECS): Add cisco_core_vec.
+ * targets.c: Add cisco_core_vec.
+ * bfd-in2.h: Rebuilt.
+
+Fri Mar 18 18:13:49 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.h (som_copyable_section_data_struct): New structure
+ containing all the private section information which needs
+ to be copied from input section to output section during
+ objcopy or strip.
+ (som_section_data_struct): Remove several fields now in
+ som_copyable_section_data_struct. Make the space and
+ subspace dictionaries be pointers (to save space when
+ only reading objects).
+
+ * som.c (bfd_som_set_section_attributes): Now returns a boolean;
+ some references changed. Allocate a copyable data stucture if
+ none exists. Store info into the copyable data structure.
+ (bfd_som_set_subsection_attributes): Likewise.
+ (som_is_space, som_is_subspace, som_is_container): New functions.
+ Use these instead of directly accessing private data.
+ (som_prep_headers): Allocate space and subspace headers here.
+ Fill in some fields in the space/subspace headers from the
+ copyable data.
+ (som_bfd_copy_private_section_data): Only copy the stuff
+ that we really need to make objcopy and strip work. Allocate
+ the copy_data structure for the output bfd before copying.
+
+ * som.h (struct som_exec_data): New structure to hold exec
+ info that must be preserved when running objcopy/strip.
+ (struct somdata): Add new "exec_data" field and accessor
+ macro. Add some comments on how the various fields are used.
+ (som_section_data_struct): Make is_space and is_subspace bitfields.
+ Delete unused subspace_index. All references now use the
+ target_index field within the section structure itself.
+
+ * som.c (make_unique_section): Delete unused declaration.
+ (som_bfd_copy_private_bfd_data): New function.
+ (som_object_setup): Allocate space for and save exec information
+ that needs to be copied during objcopy/strip.
+ (som_mkobject): Do not allocate space for a file header here.
+ It is not used when only reading SOM objects.
+ (som_prep_headers): Allocate space for and attach a file header
+ to the output bfd. For executables, use the saved system_id
+ value rather than trying to guess the right value. Do not abort
+ wwhen setting file_hdr->entry* for executables.
+ (som_begin_writing): For executables, set the exec_entry and
+ exec_flags fields.
+ (som_copy_private_backend_section_data): Always return a value.
+
+ * libhppa.h (PA_PAGESIZE): Define.
+
+ * som.c (SOM_ALIGN): Define.
+ (som_begin_writing): If writing an executable, initialize all
+ fields in the exec header to zero. Update fields in the exec
+ header as sizes of loadable subspaces are computed. Carefully
+ preserve alignments when building executables. Actually write the
+ exec after all the fields are filled in.
+
+ * Better long-filename handling. Reads SOM ABI compliant extended
+ names, but doesn't quite write compliant extended names yet.
+ * som.c (som_slurp_extended_name_table): Delete function. The
+ generic code will handle things correctly.
+ (som_slurp_armap): Seek to the beginning of the next member.
+ (normalize): New function.
+ (som_bfd_ar_write_symbol_stuff): Take the size of the extended
+ name table into account when computing the file offsets in the
+ SOM dictionary. Make sure to align to an even boundary.
+ (som_write_armap): Initialize the checksum to zero.
+ (ar_maxchars): Fix. Opps.
+
+Fri Mar 18 20:35:24 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * aoutx.h (reloc_type_lookup): Handle BFD_RELOC_CTOR on a 64-bit
+ machine. Handle BFD_RELOC_SPARC13 and BFD_RELOC_SPARC_BASE13.
+
+Thu Mar 17 18:26:46 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * bfd-in.h (BFD_VERSION): Use @VERSION@.
+ * Makefile.in (bfd.h): Replace it with contents of VERSION file.
+ * bfd-in2.h: Regenerated.
+
+ * trad-core.c (trad_unix_bfd_is_local_label): Fixed typo where
+ this was also named trad_unix_bfd_copy_private_bfd_data.
+
+Thu Mar 17 10:37:07 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aoutx.h, elfcode.h, coff-alpha.c, bout.c, ecoff.c, ecofflink.c,
+ elf32-hppa.c, elf32-mips.c, linker.c, som.c, sunos.c: If malloc(0)
+ returns NULL, it is not an error. It's possible that some of
+ these checks are not necessary (because the size can never be
+ zero), but putting in the checks is the conservative thing to do
+ in light of the fact that some of these malloc calls replaced
+ unchecked alloca calls, in which a zero argument would work fine.
+
+Thu Mar 17 11:44:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * osf-core.c (osf_core_bfd_copy_private_bfd_data): Remove
+ duplicate definition.
+ (osf_core_bfd_is_local_label): Define.
+
+ * reloc.c (bfd_generic_get_relocated_section_contents): Don't fail
+ if malloc (0) fails. bfd_canonicalize_reloc returning 0 is not a
+ failure indication, it merely means there are no relocs.
+
+ * elfcode.h (NAME(bfd_elf,write_object_contents)): Don't use space
+ after NAME, since SunOS /bin/cc can't handle it.
+
+Wed Mar 16 16:43:33 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * netbsd386.c (N_SET_FLAGS): Don't nuke the machine id field.
+ From sukes@glue.umd.edu (Tasuki Hirata).
+
+Wed Mar 16 07:55:54 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aoutf1.h (4 places): Use a simple #if on ARCH_SIZE, rather than
+ all that convoluted stuff with NAME, CAT3, etc. The convoluted
+ stuff broke for SunOS4 /bin/cc (due to DEFUN elimination, I guess).
+
+Wed Mar 16 00:02:05 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_prep_for_fixups): Detect section symbols based
+ on either the lack of private data or the symbol flags. Do not
+ munge section symbol names anymore -- they no longer confuse GDB.
+ (som_begin_writing): Leave space for an exec header if writing
+ an executable.
+ (som_slurp_symbol_table): Recognize both forms of section symbol
+ names "L$0\002" and "$<FOO>$". Change the name of "L$0\002"
+ section symbols to be the name of the section they represent.
+ Debugging symbols begin with "L$0\001", not just "L$".
+
+Tue Mar 15 22:58:28 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * bfd-in2.h, libbfd.h, libcoff.h: Rebuilt.
+
+ * bfd-in.h (JUMP_TABLE): Add new entries to the jump table
+ for bfd_copy_private_section_data, bfd_copy_private_bfd_data,
+ and bfd_is_local_label.
+
+ * targets.c: Add new entries to the bfd_target structure.
+
+ * bfd.c (bfd_copy_private_bfd_data): New definition.
+
+ * section.c (bfd_copy_private_section_data): New definition.
+
+ * syms.c (bfd_is_local_label): New definition.
+
+ * libbfd-in.h (bfd_generic_is_local_label): Declare.
+
+ * libbfd.c (bfd_generic_is_local_label): New function.
+
+ * *-core.c: Provide default definitions for new functions in
+ the target vector which all point to bfd_false.
+
+ * aout-target.h, coffcode.h, elf32-target.h elf64-target.h, ieee.c
+ libaout.h, libecoff.h, nlm-target.h, oasys.c, srec.c, tekhex.c
+ Default new vectors for copying private backend data to bfd_true.
+ Default new vector for determining if a symbol is a local label
+ to bfd_generic_is_local_label.
+
+ * som.c (som_bfd_copy_private_section_data): New function.
+ (som_bfd_is_local_label): New function.
+ (som_bfd_copy_private_bfd_data): For now default to bfd_true.
+
+ * elf32-hppa.c (hppa_elf_is_local_label): New function.
+
+Tue Mar 15 23:55:47 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * cf-m68klynx.c (CALC_ADDEND): Use _bfd_m68klynx_howto_table.
+
+Tue Mar 15 04:41:13 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * Most files:
+ Replace DEFUN and DEFUN_VOID with K&R-style function definition.
+ Indent some of them to GNU standards.
+
+ * aout32.c, archures.c, core.c, cpu-h8300.c, cpu-i960.c,
+ cpu-m68k.c, cpu-m88k.c, cpu-mips.c, cpu-vax.c, ctor.c, demo64.c,
+ elf32-hppa.h, gen-aout.c, host-aout.c, init.c, libhppa.h,
+ libieee.h, liboasys.h, newsos3.c, som.h, stab-syms.c, sunos.c:
+ Update copyright years.
+
+Mon Mar 14 11:41:23 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_prep_for_fixups): A relocation involving the section
+ symbol for the *ABS* section is really a relocation involving
+ no symbol.
+ (som_slurp_symbol_table): Do not set BSF_GLOBAL or BSF_EXPORT for
+ undefined symbols. Correctly distinguish between debugger symbols
+ and section symbols.
+
+ * som (setup_sections): Set SEC_DEBUGGING and the section attributes
+ for spaces and subspaces.
+
+ * som.c (som_bfd_count_ar_symbols): Fix typo.
+
+ * som.c (som_object_setup): Set EXEC_P, D_PAGED, WP_TEXT, and
+ HAS_RELOC based on the object's magic number.
+ (make_unique_section): Delete function. BFD and its users are
+ prepared to handle multiple sections with the same name.
+ (setup_sections): Allocate space on the BFD's obstack to hold
+ section names. Use bfd_make_setion_anyway rather than the
+ obsolete make_unique_section.
+ (som_prep_headers): Choose the correct SOM magic number based
+ on the BFD's flags.
+ (som_bfd_fill_in_ar_symbols): Return false, not NULL on error.
+
+Sat Mar 12 09:46:09 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * elf32-ppc.c: Renamed from elf32-powerpc.c.
+ * nlm32-ppc.c: Renamed from nlm32-powerpc.c.
+ * Makefile.in, configure.in: Corresponding changes.
+
+Fri Mar 11 22:27:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elf32-powerpc.c: Extensive changes to update to preliminary ABI.
+
+Fri Mar 11 00:34:59 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * sunos.c (sunos_read_dynamic_info): Assume that dynamic info
+ is always located at the start of the data section to allow
+ recovery of the dynamic info from a stripped executable.
+ * ecoff.c (ecoff_styp_to_sec_flags): Handle STYP_PDATA, STYP_XDATA
+ and STYP_COMMENT.
+
+Wed Mar 9 17:17:53 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * libbfd-in.h: Remove alloca cruft. It was missing some necessary
+ cruft (like the #pragma alloca for AIX).
+ In addition to that problem, the C alloca calls xmalloc, which
+ means checking for being out of memory can't work right. The
+ following changes remove all uses of alloca from BFD.
+ * hosts/solaris2.h: Remove alloca cruft.
+ * som.c: Replace alloca with a fixed size auto array.
+ * aoutx.h, elfcode.h, nlmcode.h, bout.c, coff-alpha.c, ecoff.c,
+ ecofflink.c, elf32-hppa.c, elf32-mips.c, linker.c, reloc.c, som.c,
+ sunos.c: Replace alloca with malloc and appropriate error checking and
+ freeing.
+ * linker.c: Replace alloca with obstack_alloc.
+ * libbfd.h: Rebuilt.
+
+Tue Mar 8 12:10:38 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * coff-mips.c (mips_relocate_section): Handle MIPS_R_LITERAL like
+ MIPS_R_GPREL.
+
+Sat Mar 5 14:08:54 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * elf32-hppa.h, elfcode.h: Replace uses of Elf*_Half, Elf*_Word,
+ Elf*_Off typedefs by their expansion, the typedefs have been
+ removed from include/elf/internal.h.
+ * elfcode.h (bfd_section_from_shdr): Handle SHT_DYNAMIC section like
+ SHT_PROGBITS section.
+
+Thu Mar 3 20:03:39 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.h (_PA_RISC_ID): Treat HOST_HPPAOSF just like HOST_HPPABSD.
+
+Wed Mar 2 13:28:06 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * configure.host: Recognize i[34]86-sequent-*.
+
+ * trad-core.c (trad_unix_core_file_p): A non-zero, not zero,
+ return from bfd_seek indicates an error.
+ New macro TRAD_CORE_DSIZE_INCLUDES_TSIZE to replace
+ TRAD_CORE_STACK_OFFSET.
+ * hosts/symmetry.h: Define TRAD_CORE_DSIZE_INCLUDES_TSIZE and
+ TRAD_CORE_USER_OFFSET but not HOST_STACK_OFFSET.
+
+Wed Mar 2 11:57:03 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.[ch]: Do not include libhppa.h in som.c, instead include
+ it in som.h.
+
+ * elf32-hppa.[ch]: Do not include libhppa.h in elf32-hppa.c, instead
+ include it in elf32-hppa.h.
+
+ * som.c (log2): Return -1 on error rather than aborting.
+ (setup_sections): Bubble up an error from log2.
+
+ * Changes to make HP C compiler happy in both traditional
+ and ANSI mode.
+ * som.c (hppa_som_gen_reloc_type): Use correct enum type for
+ field parameter.
+ (bfd_som_set_section_attributes): Use unsigned int rather than
+ unsigned char to avoid GNU-C extensions.
+ (bfd_som_attach_aux_hdr): Return a boolean to indicate success
+ or failure rather than aborting on failure.
+
+ * som.h (bfd_som_set_section_attributes): Fix prototype to match
+ som.c changes.
+ (bfd_som_attach_aux_hdr): Add prototype.
+ (hppa_som-gen_reloc_type): Likewise.
+
+ * elf32-hppa.c: Add a couple casts to make HP compiler happy.
+ (hppa_look_for_stubs_in_section): Do not return false on failure
+ until rest of code is ready to handle it. Abort for now.
+
+Tue Mar 1 18:33:59 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * bfd-in2.h: Rebuilt.
+
+Tue Mar 1 13:06:53 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * i386os9k.c: use new functions bfd_set_error and bfd_get_error.
+ * Makefile.in: delete an extra blank.
+ * configure.in : Add i396os9k_vec.
+
+Mon Feb 28 15:41:01 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * config.bfd : Add i386-os9k.
+ * config/i386-os9k.mt : Newly add os9k target makefile.
+
+ * i386os9k.c : new file to handle os9k format bfd.
+ * Makefile.in : Handle new file i386os9k.c
+ * targets.c : Add bfd_target_os9k_flavour and i386os9k_vec.
+ * cache.c : Initialize cache_sentinel to 0.
+
+Sun Feb 27 16:30:55 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c (mismatches, retval_mismatches): Fix mismatch
+ action in case where caller specified no argument relocation.
+ (hppa_elf_build_linker_stub): Try again to get the sym_ptr_ptr
+ right in the original relocation and the stub's relocation.
+
+ * elf32-hppa.h (hppa_look_for_stub_in_section): Fix typo. Delete
+ unused symbols argument.
+
+ * elf32-hppa.c (hppa_elf_stub_reloc): Accept asymbol ** rather
+ than asymbol * for original target symbol. All callers changed.
+ Set reloc->sym_ptr_ptr appropriately.
+ (hppa_elf_build_linker_stub): Set reloc->sym_ptr_ptr correctly.
+ (hppa_elf_look_for_stubs_in_section): No longer need symbols
+ argument. Use the output symbols when canonicalizing the relocs,
+ creating them if necessary.
+
+ * linker.c (_bfd_generic_link_output_symbols): Do not
+ rebuild/clobber the output symbols if they already exist.
+
+Sun Feb 27 15:22:36 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * targets.c (BFD_SEND, BFD_SEND_FMT): Add debugging versions that
+ check all the pointer dereferences. Enabled via DEBUG_BFD_SEND.
+ * bfd-in2.h: Rebuilt.
+
+ * srec.c (hex_value): Always set to a size of 256 bytes.
+ (srec_init): Cosmetic changes.
+
+Sun Feb 27 11:18:47 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elf32-hppa.c: Second half of major cleanup. More comments,
+ PARAMize and staticize rest of functions. Delete unused
+ functions. Delete unused/unnecessary arguments to some functions.
+ Group static vars together. Abort for bad errors until we have
+ error code propogation working. Work on spacing and indention.
+ Add FIXMEs for unresolved problems. Use enums rather than
+ #defines for lots of things. Merge two functions which build
+ linker stubs into a single function (so they can easily share a
+ ton of common code).
+
+Sat Feb 26 10:00:45 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * reloc.c (_bfd_relocate_contents): Adjust handling of overflow to
+ avoid depending upon right shifts of signed numbers, and to
+ correct handling of src_mask with lower bits zero.
+
+ * aoutx.h, archive.c: Add casts to avoid warnings from SVR4 cc.
+ * ecoff.c, ecofflink.c, ecoffswap.h, srec.c: Likewise.
+ * elf32-i386.c: Likewise.
+ * elfcode.h (bfd_section_from_shdr): Make i unsigned; remove old
+ #if 0 code.
+ (elf_write_phdrs): Make i unsigned.
+ (map_program_segments): Make i and n_left unsigned.
+ (assign_file_positions_except_relocs): Make i unsigned.
+ (write_shdrs_and_ehdr): Make count unsigned.
+ (assign_file_positions_for_relocs): Make i unsigned.
+ (NAME(bfd,elf_write_object_contents)): Make count unsigned.
+ (section_from_elf_index): Make index argument unsigned.
+
+Fri Feb 25 21:34:58 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * elfcode.h: Don't include assert.h.
+ (swap_out_syms): Use BFD_ASSERT rather than assert.
+
+ * linker.c (_bfd_generic_link_write_global_symbol): Add missing
+ break in switch.
+
+ * hosts/i386v4.h (qsort, strtol): Remove incorrect and useless
+ declarations.
+
+Fri Feb 25 16:35:57 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * libhppa.h (hppa_rebuild_insn): Moved here from elf32-hppa.c.
+
+ * elf32-hppa.h (elf_hppa_tc_symbol): Add new arguments.
+ (elf_hppa_tc_make_sections): Likewise.
+ (elf_hppa_final_processing): Add extern decl.
+
+ * elf32-hppa.c: First half of major cleanup. Add/cleanup lots of
+ comments. PARAMize some static functions. Delete unused functions.
+ Delete unused/unnecessary arguments to many functions. Group
+ static vars together. Collapse common case statements together
+ in many places. Use default case when possible instead of listing
+ each case separately. Abort for bad errors until we get error
+ code propogation working. Work on spacing and indention problems.
+ Add FIXMEs for some unresolved problems. Delete hopelessly broken
+ COMPLEX relocation support (it's never used anyway).
+ (hppa_elf_rebuild_insn): Delete. Moved into libhppa.h.
+ (elf_hppa_tc_symbol): Accept and use new arguments (symext chains).
+ (elf_hppa_tc_make_sections): Likewise.
+
+ * format.c (bfd_check_format_matches): Initialize matching_vector
+ to keep gcc -Wall quiet.
+
+ * elfcode.h (elf_slurp_reloca_table): Fix typo.
+
+ * som.c (som_get_symtab_upper_bound): Use "sizeof (asymbol *)"
+ not "sizeof (som_symbol_type *)".
+
+ * elfcode.h (elf_get_symtab_upper_bound): Use "sizeof (asymbol *)"
+ not "sizeof (asymbol"). Opps.
+
+Fri Feb 25 13:19:04 1994 Ted Lemon (mellon@pepper.ncd.com)
+
+ * bfd.c (bfd_get_gp_size): Can't return gp value on an archive.
+ (bfd_set_gp_size): Can't set gp value on an archive.
+
+Fri Feb 25 12:57:00 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * srec.c (pass_over): Don't skip too many characters when
+ end of line seen.
+
+Fri Feb 25 11:41:57 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff.c (ecoff_sizeof_headers): Align result to 16 byte
+ boundary.
+
+Thu Feb 24 07:13:22 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_derive_misc_symbol_info): Derive symbol_info
+ field for absolute symbols in the same manner as undefined
+ and common symbols.
+
+Thu Feb 24 04:29:19 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * elfcode.h (elf_core_file_p): Check for core file e_machine match
+ like in elf_object_p.
+
+Wed Feb 23 18:28:37 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elfcode.h (alloca): Delete declaration.
+
+ * som.c (som_prep_headers): Use CPU_PA_RISC1_0 for magic
+ number rather than HP9000S800_ID. Note som.c is careful
+ to make sure CPU_PA_RISC1_0 is always defined.
+
+Mon Feb 21 10:12:02 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * Makefile.in (targets.o, archures.o): Use ALL_CFLAGS to supply
+ flags to explicit compile actions.
+
+Mon Feb 21 09:50:06 1994 Ian Lance Taylor (ian@lisa.cygnus.com)
+
+ * ecofflink.c (ecoff_write_symhdr): Set symhdr->magic here.
+ * ecoff.c (ecoff_write_object_contents): Make sure .bss section
+ ends on a page boundary if there is no symbol table.
+ (ecoff_bfd_final_link): Don't set symhdr->magic here.
+
+ * hosts/hp300.h: Include <stdlib.h>; don't declare free.
+
+ * som.c (som_bfd_count_ar_symbols): Use a pointer and alloca
+ rather than an array of variable size.
+ (som_bfd_fill_in_ar_symbols): Likewise.
+ (som_bfd_ar_write_symbol_stuff): Likewise.
+
+ * coff-alpha.c (alpha_relocate_section): Rewrite mask and shift
+ operation to avoid OSF 1.3 cc bug.
+ * ecoff.c (ecoff_write_object_contents): Make text_size, data_size
+ and bss_size bfd_size_type instead of unsigned long. Make
+ text_start and data_start bfd_vma instead of unsigned long.
+ * ecofflink.c (ecoff_add_string): Remove incorrect cast of return
+ value.
+
+Sun Feb 20 16:06:54 1994 Ian Lance Taylor (ian@lisa.cygnus.com)
+
+ * linker.c (_bfd_generic_link_add_archive_symbols): Consider
+ symbols in the order they appear in the archive map.
+
+Sat Feb 19 03:17:32 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * coff-alpha.c (reloc_nil): Add forward declaration, add missing
+ error_message argument.
+ * coff-sparc.c (bfd_coff_generic_reloc): Add forward declaration,
+ add missing error_message argument.
+ * mipsbsd.c (mips_fix_hi16_s): Add forward declaration, add missing
+ error_message argument.
+
+Fri Feb 18 11:41:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Support for PowerPC NetWare.
+ * nlm32-powerpc.c: New file.
+ * config.bfd (powerpc-*-netware*): New target; use ppc-nlm.
+ * config/ppc-nlm.mt: New file.
+ * configure.in (nlm32_powerpc_vec): New target vector; use
+ nlm32-powerpc.o, nlm32.o, nlm.o.
+ * targets.c (nlm32_powerpc_vec): Declare.
+ * Makefile.in (BFD32_BACKENDS): Add nlm32-powerpc.o.
+ (CFILES): Add nlm32-powerpc.c.
+
+ Initial support for PowerPC ELF. Done without an ABI, and
+ probably to be changed when I get an ABI.
+ * config.bfd (powerpc-*-sysv4*): New target; use ppc-elf.
+ * config/ppc-elf.mt: New file.
+ * configure.in (bfd_elf32_powerpc_vec): New target vector; use
+ elf32-powerpc.o, elf32.o, elf.o.
+ * elf32-powerpc.c: New file.
+ * elfcode.h (prep_headers): Add bfd_arch_powerpc case.
+ (elf_set_arch_mach): Likewise.
+ * targets.c (bfd_elf32_powerpc_vec): Declare.
+ * Makefile.in (BFD32_BACKENDS): Add elf32-powerpc.o.
+ (CFILES): Add elf32-powerpc.c.
+ Rebuilt dependencies.
+
+Thu Feb 17 15:29:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coffgen.c (coff_write_linenumbers): Always return a value.
+
+ * elfcode.h (elf_slurp_symbol_table): Handle zero symbols
+ reasonably. Allocate x_symp using alloca.
+
+ * elfcode.h (map_program_segments): ELF program header entries
+ must be sorted by load address. This used to generate the entries
+ in reverse order.
+
+ * section.c (SEC_IN_MEMORY): Define.
+ (asection): Rename unused field otheruserdata to contents, and
+ make it char *.
+ (bfd_make_section_anyway): Initialize contents field to NULL.
+ (bfd_get_section_contents): If SEC_IN_MEMORY is set, get section
+ contents from contents field rather than from file.
+ * bfd-in2.h: Rebuilt.
+
+Thu Feb 17 08:30:53 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * bfd.c (bfd_get_error, bfd_set_error): New functions.
+ (bfd_error): Make static.
+ (bfd_error_type): Renamed from bfd_ec. Prepend "bfd_error_" to
+ all values.
+ * bfd-in2.h: Regenerated.
+ * aix386-core.c, aout-adobe.c, aout-encap.c, aout-target.h,
+ aoutf1.h, aoutx.h, archive.c, archures.c,
+ bfd.c, bout.c, cache.c, coff-alpha.c, coff-mips.c,
+ coff-rs6000.c, coffcode.h, coffgen.c, core.c, ctor.c,
+ ecoff.c, ecofflink.c, elf.c, elf32-hppa.c, elf32-mips.c,
+ elfcode.h, format.c, hash.c, hp300hpux.c, hppabsd-core.c,
+ i386lynx.c, ieee.c, libbfd.c, libelf.h, linker.c,
+ lynx-core.c, nlm.c, nlm32-alpha.c, nlm32-i386.c,
+ nlm32-sparc.c, nlmcode.h, oasys.c, opncls.c, osf-core.c,
+ ptrace-core.c, reloc16.c, rs6000-core.c, section.c, som.c,
+ srec.c, sunos.c, syms.c, targets.c, tekhex.c,
+ trad-core.c: Change callers.
+
+Tue Feb 15 22:27:27 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c: Remove FIXMEs for things which have been dealt with.
+
+Tue Feb 15 19:39:24 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * section.c (bfd_get_section_contents): Since this function reads
+ unrelocated contents, the section's raw size is always the one to
+ use for bounds checking.
+
+ * linker.c (default_indirect_link_order): In assertion, compare
+ link_order size field against cooked size, not raw size, of input
+ section.
+
+ * bout.c (b_out_get_reloc_upper_bound): For BSS section, just
+ return 0.
+ (aligncode): When shrinking, the addend should be set to the
+ current offset in the section plus the number of bytes of padding
+ that will actually be retained.
+ (b_out_relax_section): If a section contains no relocations, don't
+ bother processing them.
+ (b_out_get_relocated_section_contents): Set reloc_done. Assert
+ that bfd_get_section_contents returns true. Check that relocs are
+ properly ordered.
+ (b_out_get_relocated_section_contents, case ALIGNDONE): Assert
+ that reloc->addend falls between the current source offset and the
+ raw size of the input section.
+
+ * config.bfd: Support i960 vxworks versions > 5.0 with coff, not
+ bout. Default with no version number is still bout. Support
+ explicit i960-coff target too.
+
+ * bout.c: Changed some indentation, deleted trailing whitespace,
+ fixed some comments, removed some "#if 1" lines.
+ (output_addr): New macro.
+ (calljx_callback, callj_callback, get_value, abs32code, aligncode,
+ b_out_get_relocated_section_contents): Use it for readability.
+
+Tue Feb 15 09:00:16 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_bfd_prep_for_ar_write): Iterate through the SOM
+ symbols, not the BFD symbols.
+ (som_bfd_ar_write_symbol_stuff): Likewise.
+
+Mon Feb 14 22:55:20 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_slurp_symbol_table): Do not die if a BFD doesn't
+ have any symbols.
+
+ * Finish basic read-write support for SOM archive libraries. Bugs
+ surely remain as this hasn't been tested all that much.
+ * som.c (SOM_LST_HASH_SIZE, SOM_LST_MODULE_LIMIT): Define.
+ (struct som_misc_symbol_info): New structure to hold info necessary
+ to build both normal and library symbol tables.
+ (som_derive_misc_symbol_info): New function to derive info necessary
+ to build both normal and library symbol tables.
+ (som_build_and_write_symbol_table): Use new function to derive misc
+ symbol information.
+ (som_slurp_symbol_table): Update backend private data for symbols
+ appropriately.
+ (som_bfd_prep_for_ar_write): New function.
+ (som_bfd_ar_symbol_hash): New function.
+ (som_bfd_ar_write_symbol_stuff): New function.
+ (som_write_armap): Flesh out.
+ (som_vec): Fix ar padding character.
+
+ * som.c: Consistently use memset rather than bzero.
+
+Mon Feb 14 17:02:28 1994 Stu Grossman (grossman at cygnus.com)
+
+ * coff-rs6000.c: Add Lynx core file support, use HOST_AIX, where
+ appropriate.
+ * rs6000-core.c: Use HOST_AIX instead of COREFILES_PLEASE.
+ * config/rs6000.mh: Remove defs of ARCHIVES_PLEASE and
+ COREFILES_PLEASE.
+ * config/rs6000lynx.mh: Turn on Lynx core file support.
+ * hosts/rs6000.h: #define HOST_AIX.
+ * hosts/rs6000lynx.h: Create this to enable Lynx host support.
+
+Sun Feb 13 14:30:00 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.h (som_symbol_data): Safely access backend private data
+ for BFD symbols. All callers changed.
+
+ * Read-only SOM archive support.
+ * som.c (som_bfd_count_ar_symbols): New helper function.
+ (som_bfd_fill_in_ar_symbols): New helper function.
+ (som_slurp_armap): New function to read a SOM LST.
+
+ * som.h: Include <lst.h> and <ar.h>.
+
+Sat Feb 12 22:34:14 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * elfcode.h (elf_map_symbols): Fix typo.
+ (write_object_contents): Check return values from prep_headers and
+ elf_compute_section_file_positions.
+ (set_section_contents): Likewise.
+
+Fri Feb 11 16:56:50 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * archive.c (normalize) [VMS]: Call malloc, not bfd_xmalloc.
+ (bfd_construct_extended_name_table): Check result of normalize.
+
+Tue Feb 8 08:57:31 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ Make all callers of malloc or realloc (including via obstacks)
+ check the result for NULL. Most set bfd_error to no_memory and
+ return in that case; a few are harder to fix, and are marked
+ with "FIXME <return type>".
+
+ * elf32-hppa.c (hppa_elf_build_arg_reloc_stub
+ hppa_elf_build_long_branch_stub): Check bfd_make_empty_symbol return.
+ * linker.c (_bfd_generic_link_output_symbols
+ _bfd_generic_link_write_global_symbol): Ditto
+ * section.c (bfd_make_section_anyway): Ditto.
+
+ * tekhex.c (find_chunk tekhex_mkobject): Check bfd_alloc.
+ (first_phase): Ditto. FIXME void
+ (tekhex_make_empty_symbol): Check bfd_zalloc.
+
+ * sunos.c (sunos_read_dynamic_info): Check bfd_zalloc.
+ (MY(read_dynamic_symbols) MY(read_dynamic_relocs)): Check bfd_alloc.
+
+ * stringhash.c (_bfd_stringtab_hash_newfunc): Check bfd_hash_allocate.
+
+ * srec.c: Indent.
+ (fillup_symbols): Check bfd_alloc. FIXME void
+ (srec_mkobject srec_get_section_contents
+ srec_set_section_contents): Check bfd_alloc.
+ (srec_make_empty_symbol): Check bfd_zalloc.
+
+ * som.c (hppa_som_gen_reloc_type): Check bfd_alloc_by_size_t.
+ (make_unique_section): Check bfd_alloc.
+ (som_new_section_hook): Check bfd_zalloc.
+ (bfd_som_attach_aux_hdr): Ditto. FIXME void
+
+ * rs6000-core.c (rs6000coff_core_p): Check bfd_zalloc.
+
+ * osf-core.c (osf_core_make_empty_symbol): Check bfd_zalloc.
+ (osf_core_core_file_p): Check bfd_alloc.
+
+ * oasys.c (oasys_slurp_symbol_table oasys_archive_p
+ oasys_mkobject oasys_object_p oasys_new_section_hook
+ oasys_set_section_contents): Check bfd_alloc.
+ (oasys_slurp_section_data): Check bfd_zalloc and bfd_alloc.
+ (oasys_make_empty_symbol): Check bfd_zalloc.
+
+ * nlmcode.h (nlm_make_empty_symbol): Check bfd_zalloc.
+ (nlm_slurp_symbol_table): Check bfd_zalloc and bfd_alloc.
+
+ * nlm32-sparc.c (nlm_sparc_read_import): Check bfd_alloc.
+
+ * nlm32-i386.c (nlm_i386_read_import): Check bfd_alloc.
+
+ * nlm32-alpha.c (nlm_alpha_read_import): Check bfd_alloc.
+
+ * linker.c (_bfd_link_hash_newfunc
+ (generic_link_hash_newfunc
+ (archive_hash_newfunc
+ (_bfd_generic_link_add_one_symbol): Check bfd_hash_allocate.
+ (_bfd_generic_final_link
+ (_bfd_generic_link_output_symbols
+ (default_indirect_link_order): Check bfd_alloc.
+ (bfd_new_link_order): Check bfd_alloc_by_size_t.
+
+ * irix-core.c (irix_core_make_empty_symbol): Check bfd_zalloc.
+
+ * ieee.c: Indent.
+ (read_id get_symbol get_section_entry ieee_archive_p ieee_object_p
+ ieee_slurp_section_data ieee_new_section_hook): Check bfd_alloc.
+ (do_one): Check bfd_alloc. Return a boolean.
+ (ieee_slurp_section_data): Check it.
+ (init_for_output): Check bfd_alloc. Return a boolean.
+ (ieee_set_section_contents): Check it.
+ (do_with_relocs): Check bfd_alloc. Return a boolean.
+ (ieee_bfd_debug_info_accumulate): Ditto. FIXME void.
+ (ieee_mkobject): Check bfd_zalloc.
+ (ieee_make_empty_symbol): Check bfd_zmalloc.
+
+ * hpux-core.c (hpux_core_make_empty_symbol): Check
+ bfd_zalloc.
+
+ * hppabsd-core.c (hppabsd_core_make_empty_symbol): Check
+ bfd_zalloc.
+ (hppabsd_core_core_file_p): Check bfd_zalloc.
+
+ * hp300hpux.c (MY(slurp_symbol_table)): Check bfd_alloc.
+
+ * elfcode.h (elf_new_section_hook): Check bfd_alloc.
+ (bfd_section_from_phdr): Ditto.
+ (write_relocs): Ditto. FIXME void
+ (elf_map_symbols assign_section_numbers map_program_segments):
+ Ditto. Return a boolean.
+ (swap_out_syms): Ditto. Check elf_map_symbols.
+ (elf_slurp_symbol_table): Check bfd_zalloc.
+ (elf_slurp_reloca_table): Check bfd_alloc.
+ (elf_slurp_reloc_table): Ditto.
+ (elf_compute_section_file_positions): Check assign_section_numbers.
+ (assign_file_positions_except_relocs): Return a boolean.
+ Check map_program_segments.
+ (elf_compute_section_file_positions): Check it.
+
+ * elf32-mips.c (mips_elf_final_link): Check bfd_alloc.
+
+ * elf32-hppa.c (hppa_elf_stub_branch_reloc): Check bfd_zmalloc and
+ realloc.
+ (hppa_elf_stub_reloc): Ditto.
+ (hppa_elf_build_arg_reloc_stub): Check bfd_zalloc.
+ (hppa_elf_build_long_branch_stub): Ditto.
+ (elf32_hppa_backend_symbol_table_processing): Ditto.
+
+ * ecoff.c (ecoff_set_symbol_info): Check bfd_alloc. Return a boolean.
+ (ecoff_slurp_symbol_table): Check it.
+ (ecoff_slurp_armap): Check bfd_alloc.
+ (ecoff_write_armap): Check bfd_zalloc.
+ (ecoff_link_hash_newfunc): Check bfd_hash_allocate and
+ _bfd_link_hash_newfunc.
+ (ecoff_link_add_externals): Check bfd_alloc.
+
+ * ctor.c (bfd_constructor_entry): Check bfd_alloc.
+
+ * coffgen.c (coff_real_object_p): Check bfd_alloc.
+ (coff_renumber_symbols): Check bfd_alloc_by_size_t. Return a boolean.
+ (coff_write_symbol): Check bfd_alloc. FIXME int
+ (coff_write_linenumbers): Check bfd_alloc. Return a boolean.
+ (coff_section_symbol): Check bfd_alloc_by_size_t.
+ (coff_get_normalized_symtab): Check bfd_alloc.
+ (coff_bfd_make_debug_symbol): Check bfd_zalloc.
+ * libcoff-in.h: Change decls of coff_renumber_symbols,
+ coff_write_linenumbers.
+ * libcoff.h: Rebuilt.
+ * coffcode.h (coff_write_object_contents): Check
+ coff_renumber_symbols, coff_write_linenumbers.
+
+ * coffcode.h: Indent.
+ (coff_add_missing_symbols): Check bfd_alloc_by_size_t. Return a
+ boolean.
+ (coff_write_object_contents): Check it.
+
+ * coff-alpha.c (alpha_relocate_section): Check bfd_alloc.
+ * coff-mips.c (mips_relocate_section): Ditto.
+
+ * archive.c (bfd_slurp_bsd_armap_f2): Check bfd_alloc value.
+ (do_slurp_bsd_armap): Ditto.
+ (compute_and_write_armap): Check bfd_realloc value.
+
+ * aoutx.h (translate_from_native_sym_flags): Check bfd_alloc
+ return value. Return boolean value.
+ (NAME(aout,make_empty_symbol)): Check bfd_zalloc return value.
+ (NAME(aout,slurp_symbol_table)): Check bf_alloc and bfd_zalloc
+ return value.
+ (add_to_stringtab): Ditto. FIXME void
+ (aout_link_hash_newfunc): Check bfd_hash_allocate return value.
+ (aout_link_add_symbols): Check bfd_alloc value.
+ (translate_symbol_table): Check translate_from_native_sym_flags.
+ * hp300hpux.c (MY(slurp_symbol_table)): Ditto.
+ * aoutx.h (aout_link_hash_newfunc): Check _bfd_link_hash_newfunc.
+
+ * opncls.c (bfd_zalloc bfd_realloc): Check result of bfd_alloc.
+
+ * opncls.c (obstack_chunk_alloc): Define as malloc, not
+ bfd_xmalloc_by_size_t.
+ (_bfd_new_bfd): Check obstack_begin for 0 return.
+
+ * ieee.c (obstack_chunk_alloc): Define as malloc, not
+ bfd_xmalloc_by_size_t.
+ (ieee_archive_p): Check obstack_begin for 0 return and
+ obstack_finish for NULL return.
+
+ * hash.c (obstack_chunk_alloc): Define as malloc, not
+ bfd_xmalloc_by_size_t.
+ (bfd_hash_table_init_n): Check obstack_begin for 0 return and
+ obstack_finish for NULL return.
+ (bfd_hash_lookup): Check obstack_alloc for NULL return.
+
+ * ecofflink.c (obstack_chunk_alloc): Define as malloc, not
+ bfd_xmalloc_by_size_t.
+ bfd_ecoff_debug_accumulate
+ bfd_ecoff_debug_accumulate_other): Check obstack_alloc.
+ (add_file_shuffle add_memory_shuffle): Check obstack_alloc for
+ NULL return. Return boolean, not void.
+ (bfd_ecoff_debug_init): Check obstack_begin for 0 return.
+ (bfd_ecoff_debug_accumulate): Check add_file_shuffle
+ and add_memory_shuffle return.
+ (string_hash_newfunc): Check bfd_hash_allocate and bfd_hash_newfunc.
+ (bfd_ecoff_debug_accumulate): Check bfd_alloc.
+ (ecoff_add_string): Check add_memory_shuffle return.
+
+ * libbfd-in.h (xmalloc, bfd_xmalloc, bfd_xmalloc_by_size_t):
+ Remove decls.
+ * libbfd.h: Rebuilt.
+
+Fri Feb 11 15:35:32 1994 Stu Grossman (grossman at cygnus.com)
+
+ * configure.host: Add Lynx/rs6000 support.
+ * config/i386-nlm.mt: Enable a.out file support.
+ * config/rs6000lynx.mh: Lynx/rs6000 host support.
+
+Fri Feb 11 17:25:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * archive.c (compute_and_write_armap): Rewrite somewhat to improve
+ memory usage.
+
+Fri Feb 11 13:10:42 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * archive.c: Change all references to '\n' in archive magic
+ to '\012', for greater portability.
+ * ecoff.c (ecoff_write_armap): Ditto.
+
+Thu Feb 10 12:58:48 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_link_write_other_symbol): Check strip settings to
+ see whether symbol should be output.
+ * genlink.h (struct generic_write_global_symbol_info): Added info
+ field.
+ * linker.c (_bfd_generic_final_link): Initialize wginfo.info.
+ (_bfd_generic_link_write_global_symbol): Check strip settings to
+ see whether symbol should be output.
+ * elf32-mips.c (mips_elf_final_link): Initialize wginfo.info.
+
+Wed Feb 9 21:34:58 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_reloc_queue_find): Do not examine a NULL queue entry.
+
+ * som.c: Cast return values from BFD memory allocation routines to
+ avoid warnings from the HP compiler.
+
+Wed Feb 9 12:55:02 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-alpha.c (alpha_relocate_section): Accept a LITERAL
+ reloc on an "ldl" instruction too.
+
+ * archive.c (bfd_ar_hdr_from_filesystem): Cast status elements
+ when passing them to sprintf. Use %ld instead of %d.
+
+ * coff-rs6000.c (rs6000coff_mkarchive): Return false.
+ (rs6000_coff_snarf_ar_hdr): Don't declare errno; it's not used.
+ Also removed unused variable namelen.
+ (rs6000coff_write_armap): Declare orl_count and stridx parameters.
+
+Tue Feb 8 18:00:34 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libbfd-in.h (xmalloc): Don't declare parameter type, to avoid
+ conflicts.
+ * libbfd.h: Rebuilt.
+
+Tue Feb 8 15:55:50 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * coff-alpha.c (reloc_nil): New function.
+ (alpha_howto_table): Use it as special_function to prevent certain
+ relocs from being adjusted by bfd_perform_relocation. IGNORE
+ reloc should be partial_inplace.
+ (alpha_ecoff_get_relocated_section_contents): Accept a LITERAL
+ reloc on an "ldl" instruction too.
+
+Tue Feb 8 00:32:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * elf32-hppa.c (CURRENT_STUB_OFFSET, hppa_elf_build_arg_reloc_stub,
+ hppa_elf_build_long_branch_stub): Cast to char * instead of int
+ before performing pointer arithmetic.
+
+Mon Feb 7 20:56:27 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * config.bfd (hppa*-*-osf*): Use bfd_name hppaosf for this
+ configuration.
+ (hppa*-*-*elf*): This configuration used hppa-elf now.
+
+ * som.c: This file is also used for HOST_HPPAOSF.
+
+ * targets.c (bfd_target_vector): Enable som_vec for HOST_HPPAOSF.
+
+ * hosts/hppaosf.h: New host configuration file.
+
+ * config/hppabsd.mt (SELECT_VECS): Add bfd_elf32_hppa_vec as
+ BSD handles both SOM and ELF object files.
+
+ * config/hppaosf.mh (HDEFINES): Delete. No longer needed.
+ (RANLIB): Doesn't do anything, define it to be "echo".
+
+ * config/hppaosf.mt: New target makefile fragment for a PA running
+ OSF1.
+
+Mon Feb 7 15:02:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * archures.c (enum bfd_architecture): Added bfd_arch_powerpc.
+ (archures_init_table): If SELECT_ARCHITECTURES is not defined,
+ added bfd_powerpc_arch.
+ * bfd-in2.h: Rebuilt.
+ * cpu-powerpc.c: New file.
+ * Makefile.in (ALL_MACHINES, CFILES): Added cpu-powerpc.c.
+ Rebuilt dependencies.
+
+ * elfcode.h (bfd_section_from_shdr): Get vma and alignment_power
+ of an SHT_STRTAB section from sh_addr and sh_addralign, rather
+ than just setting them to zero.
+
+Sun Feb 6 20:04:10 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * elfcode.h (prep_headers, swap_out_syms): Check for NULL return
+ from bfd_new_strtab.
+ (elf_compute_section_file_positions): Check for false return from
+ swap_out_syms.
+
+ * linker.c (default_indirect_link_order): Check for NULL return
+ from bfd_get_relocated_section_contents.
+
+ * syms.c: Make example application in doc call xmalloc, not
+ bfd_xmalloc.
+
+ * aoutx.h (NAME(aout,slurp_symbol_table),
+ aout_link_get_symbols, NAME(aout,link_hash_table_create)):
+ * bout.c (b_out_slurp_reloc_table, b_out_squirt_out_relocs):
+ * ecoff.c (ecoff_bfd_link_hash_table_create):
+ * ecofflink.c (bfd_ecoff_debug_init):
+ * format.c (bfd_check_format_matches):
+ * linker.c (_bfd_generic_link_hash_table_create):
+ (_bfd_generic_final_link):
+ * reloc16.c (bfd_coff_reloc16_relax_section):
+ (bfd_coff_reloc16_get_relocated_section_contents):
+ * elf32-hppa.c (hppa_elf_build_arg_reloc_stub):
+ * elf32-mips.c (mips_elf_final_link):
+ * elfcode.h (bfd_new_strtab):
+ (bfd_add_2_to_strtab):
+ (elf_slurp_symbol_table):
+ (elf_corefile_note):
+ * libbfd.c (bfd_zmalloc):
+ Use malloc and check the result, instead of bfd_xmalloc.
+
+Sat Feb 5 12:39:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.bfd: Put m68*-*-sysv* line after m68*-*-sysv4*.
+
+Sat Feb 5 05:32:44 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * srec.c (srec_write_record): Put CONST keyword for "src" before
+ "unsigned", some compilers don't like it after "unsigned".
+ * libcoff.h, libcoff-in.h (bfd_perform_slip): Rename "value" to
+ "val" in prototype declaration because some compilers don't like
+ arguments whose names are the same as types.
+
+Sat Feb 5 01:14:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_link_check_ar_symbols): Correct test for whether
+ object file defines symbol. Also, if skipping a symbol, skip the
+ second symbol of a N_WARNING or N_INDR symbol as well.
+
+Fri Feb 4 23:55:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Add basic support for writing RS/6000 XCOFF files.
+ * coff-rs6000.c (dummy_reloc): Removed.
+ (rs6000coff_howto_table): Defined XCOFF relocs.
+ (RTYPE2HOWTO): Defined to use rs6000coff_rtype2howto.
+ (rs6000coff_rtype2howto): New function.
+ (coff_bfd_reloc_type_lookup): Defined to use
+ rs6000coff_reloc_type_lookup.
+ (rs6000coff_reloc_type_lookup): New function.
+ (SELECT_RELOC): Defined to set r_type and r_size fields.
+ (COFF_LONG_FILENAMES): Defined.
+ * coffcode.h (combined_entry_type): Changed fix_tag and fix_end
+ fields to bitfields. Added fields fix_value and fix_scnlen.
+ (sec_to_styp_flags): If STYP_DEBUG is defined, use it rather than
+ STYP_INFO for the type of a section named .debug.
+ (coff_add_missing_symbols): Don't define if RS6000COFF_C.
+ (coff_write_object_contents): If RS6000COFF_C, don't call
+ coff_add_missing_symbols.
+ (coff_slurp_symbol_table): If RS6000COFF_C, then if the last aux
+ entry has type STY_LD change the x_scnlen into a pointer to a
+ symbol and set fix_scnlen. Also, for a C_BSTAT symbol, change the
+ value into a pointer to a symbol and set fix_value.
+ * libcoff.h: Rebuilt.
+ * coffgen.c (coff_mangle_symbols): Reindent. If fix_value is set,
+ get the symbol offset. Likewise for fix_scnlen.
+ (string_size): Change type to bfd_size_type.
+ (debug_string_size, debug_string_section): New static variables.
+ (coff_fix_symbol_name): If bfd_coff_symname_in_debug returns true,
+ write the symbol name into the .debug section; assume that the
+ section has already been created with the right size.
+ (coff_write_symbols): Initialize debug_string_size to 0. If
+ bfd_coff_symname_in_debug returns true, don't put symbol name in
+ usual string table. After writing out all symbols, if
+ debug_string_size is not 0, check that it matches the size of the
+ .debug section.
+ (coff_get_normalized_symtab): Clear new fix_value and fix_scnlen
+ fields. If the string offset is 0, always use an empty string as
+ the name.
+ (coff_make_empty_symbol): Zero out the symbol structure.
+ * reloc.c (bfd_perform_relocation): Work around one gross hack
+ with another: actually look at the target name to avoid the broken
+ COFF check.
+ (bfd_reloc_code_real_type): Add BFD_RELOC_PPC_B26,
+ BFD_RELOC_PPC_BA26 and BFD_RELOC_PPC_TOC16.
+ * bfd-in2.h: Rebuilt.
+
+Fri Feb 4 17:28:32 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * libbfd.c (bfd_zmalloc): Call bfd_xmalloc instead of malloc.
+ (bfd_xmalloc, bfd_xmalloc_by_size_t): Functions deleted.
+ * libbfd-in.h: Define them as macros calling xmalloc and declare
+ xmalloc.
+ * libbfd.h: Rebuilt.
+
+Thu Feb 3 16:49:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecofflink.c (bfd_ecoff_debug_externals): If a small undefined
+ symbol has a value in the ECOFF symbol but not in the BFD symbol,
+ keep the value in the ECOFF symbol. This helps gas.
+
+ * linker.c (_bfd_generic_link_output_symbols,
+ _bfd_generic_link_write_global_symbol): Don't require that all
+ references to a common symbol be themselves common symbols.
+
+ * aoutx.h (aout_reloc_index_to_section): Handle N_UNDF.
+
+Wed Feb 2 20:37:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * libbfd.c, bfd-in.h, hosts/alphaosf.h, hosts/sparc-ll.h, aoutf1.h,
+ sparclynx.c, Makefile.in: Change HOST_64_BIT to BFD_HOST_64_BIT.
+ * bfd-in2.h: Rebuilt.
+
+Wed Feb 2 12:30:13 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coffswap.h (coff_swap_reloc_out): If RS6000COFF_C, handle type
+ and size correctly.
+ (coff_swap_aux_in): If RS6000COFF_C, change x_csect.x_scnlen to
+ x_csect.x_scnlen.l to match change in coff/internal.h.
+ (coff_swap_aux_out): Likewise.
+
+ * coff-mips.c (mips_ecoff_backend_data), coff-alpha.c
+ (alpha_ecoff_backend_data): Change casts of aux_in and aux_out
+ fields to match yesterday's changes.
+
+ * coffcode.h (coff_write_relocs): If SELECT_RELOC is defined, pass
+ in the internal_reloc itself, not the type.
+ * coff-apollo.c, coff-h8300.c, coff-h8500.c, coff-i386.c,
+ coff-m68k.c, coff-sh.c, coff-we32k.c, coff-z8k.c: Changed
+ definition of SELECT_RELOC accordingly.
+
+Tue Feb 1 12:05:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coffcode.h (bfd_coff_backend_data): Added new arguments to
+ _bfd_coff_swap_aux_in and _bfd_coff_swap_aux_out: aux index number
+ and number of aux entries.
+ (bfd_coff_swap_aux_in, bfd_coff_swap_aux_out): Changed
+ accordingly.
+ * libcoff.h: Rebuilt.
+ * coffswap.h (coff_swap_aux_in, coff_swap_aux_out): Accept new
+ arguments. If RS6000COFF_C, only treat C_EXT and C_HIDEXT
+ specially if this is the last aux entry.
+ * coffgen.c (coff_write_symbol, coff_get_normalized_symtab): Pass
+ new arguments to swap_aux functions.
+
+Sun Jan 30 15:14:36 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * gen-aout.c (main): Set DEFAULT_ARCH based on preprocessor macros
+ (only testing for m68k and vax at the moment); do verify that the
+ preprocessor didn't trash the arch name inside the string version.
+ Don't print out "pagesize =" line that prevents output from
+ compiling. Derive BYTES_IN_WORD and ARCH values from sizeof
+ results.
+ * Makefile.in (aout-params.h): Pass gen-aout a dummy target name.
+ (check, installcheck): Identify directory in "no testsuites"
+ message.
+
+Sun Jan 30 13:25:28 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_link_write_symbols): Write out correct value for
+ object file symbol.
+
+Fri Jan 28 18:34:05 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * hosts/vaxbsd.h (HOST_STACK_END_ADDR): Vax BSD doesn't define
+ KERNBASE, so hard-code 0x80000000 instead.
+
+Thu Jan 27 13:54:08 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * linker.c (generic_link_add_symbol_list): If symbol is common,
+ set the BSF_OLD_COMMON flag.
+
+Wed Jan 26 13:47:15 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * format.c (bfd_check_format_matches): Put the new entry in the
+ correct element of matching_vector.
+
+Tue Jan 25 11:43:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * som.c, som.h (bfd_som_set_section_attributes,
+ bfd_som_set_subsection_attributes): Change parameters from char
+ to int. Following a prototype with an old-style function definition
+ in the presence of widened parameters is a GCC-ism not supported
+ by the HP compiler in ANSI mode.
+
+Tue Jan 25 11:46:46 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * reloc.c (bfd_get_reloc_size): Size of type -2 is 4 bytes, not 2.
+
+ * hp300hpux.c (MY(write_object_contents)): Write out the symbols
+ before writing out the relocs, so that the right symbol indices
+ are used.
+
+ * archive.c (do_slurp_bsd_armap, bfd_slurp_bsd_armap_f2): Do not
+ try to overlay the internal carsyms on the external symdefs. That
+ can not work if the size of a host pointer is larger than 4 bytes.
+
+ * format.c (bfd_check_format_matches): Cast result of
+ bfd_xmalloc_by_size_t.
+ * opncls.c (_bfd_new_bfd): Avoid ANSI C prototype.
+
+ * archive.c: Reindented to GNU standards.
+
+Mon Jan 24 14:41:23 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * opncls.c (_bfd_new_bfd, _bfd_new_bfd_contained_in): Add
+ "_bfd_" to function names.
+ * archive.c (_bfd_create_empty_archive_element_shell),
+ libbfd-in.h: Change callers.
+
+ * libbfd.c (bfd_zmalloc): Renamed from zalloc.
+ * libbfd.c (bfd_add_to_string_table),
+ trad-core.c (trad_unix_core_file_p),
+ targets.c (bfd_target_list),
+ ptrace-core.c (ptrace_unix_core_file_p),
+ opncls.c (new_bfd), libbfd-in.h,
+ ieee.c (ieee_make_empty_symbol),
+ elf32-hppa.c (hppa_elf_stub_branch_reloc),
+ (hppa_elf_stub_reloc): Change callers.
+ * libbfd.h: Regenerated.
+
+ * archive.c (_bfd_look_for_bfd_in_cache): Add "_bfd_" to name.
+ (_bfd_get_elt_at_filepos),
+ coff-rs6000.c (rs6000coff_get_elt_at_filepos), libbfd-in.h:
+ Change callers.
+
+ * format.c (bfd_check_format_matches), libbfd-in.h, targets.c,
+ elfcode.h (elf_object_p): Rename target_vector to bfd_target_vector
+ and default_vector to bfd_default_vector.
+ * libbfd.h: Regenerated.
+
+ * format.c (bfd_check_format_matches): New function.
+ (bfd_check_format): Call it.
+ (bfd_matching_formats): Function removed.
+ * targets.c: Replace the vector added on Jan 21 with a count of
+ entries in default_vector.
+ * bfd-in2.h: Regenerated.
+
+Mon Jan 24 12:38:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * coff-alpha.c (alpha_ecoff_object_p): New function. Set size of
+ .pdata section based on lnnoptr field, not section header.
+ (alpha_relocate_section): Don't bother to check if r_symndx >= 0,
+ since it is unsigned.
+ (ecoffalpha_little_vec): Use alpha_ecoff_object_p rather than
+ coff_object_p.
+ * ecoff.c (ecoff_new_section_hook): Set alignment_power field of
+ .pdata section to 3.
+ (ecoff_compute_section_file_positions): Save the size of the
+ .pdata section in the line_filepos field, and actually align the
+ .pdata section to an alignment power of 4.
+ (ecoff_compute_reloc_file_positions): Set output_has_begun after
+ calling ecoff_compute_section_file_positions.
+ (ecoff_write_object_contents): Set s_lnnoptr for the .pdata
+ section from the line_filepos field. Set vstamp for the optional
+ header from the vstamp of the symbolic header.
+ (ecoff_bfd_final_link): Set vstamp of the symbolic header to the
+ vstamp used by the first object file in the link.
+
+ * ecofflink.c (ecoff_align_debug): Align RFDs to debug_align.
+
+ * linker.c (generic_link_check_achive_element): Set SEC_ALLOC flag
+ for a created common section.
+ (_bfd_generic_link_add_one_symbol): Likewise.
+
+ * elfcode.h (swap_out_syms): Use elf_section_from_bfd_section to
+ get the index of a common section, rather than always using
+ SHN_COMMON (MIPS has multiple common sections).
+
+ * elf32-hppa.c (hppa_elf_gen_reloc_type): Typo (== for =).
+
+ * bfd/aoutx.h (aout_link_input_section_std,
+ aout_link_input_section_ext): Pass additional arguments to
+ reloc_overflow callback.
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents,
+ alpha_relocat_section): Likewise.
+ * coff-h8300.c (h8300_reloc16_extra_cases): Likewise.
+ * coff-h8500.c (extra_case): Likewise.
+ * coff-mips.c (mips_relocate_section): Likewise.
+ * coff-z8k.c (extra_case): Likewise.
+ * elf32-hppa.c (hppa_elf_stub_finish): Likewise.
+ * reloc.c (bfd_generic_get_relocated_section_contents): Likewise.
+
+ * bout.c (calljx_callback, callj_callback): Use get_value to get
+ the symbol value and check for undefined symbols.
+ (get_value): If the symbol is undefined, look it up in the linker
+ hash table.
+ (b_out_get_relocated_section_contents): For PCREL24 and PCREL13
+ use get_value to get the symbol value and check for undefined
+ symbols.
+ * reloc16.c (bfd_coff_reloc16_get_value): If the symbol is
+ undefined, look it up in the linker hash table.
+
+ * aoutx.h (translate_symbol_table): The string index 0 has a
+ special meaning for normal symbols, but not for dynamic symbols.
+
+Sat Jan 22 12:26:01 1994 Stu Grossman (grossman at cygnus.com)
+
+ * sparclynx.c: Setup appropriate macros to enable core file
+ support.
+
+Fri Jan 21 16:25:35 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * targets.c: Add a vector of matching format names.
+ * format.c (bfd_matching_formats): New function to return it.
+ (bfd_check_format): Set it.
+ * bfd-in2.h: Regenerated.
+
+ * bfd-in.h: Remove decls of bfd_ec type and error printing functions.
+ Remove decl of type symclass; wasn't used.
+ * bfd.c: Document error handling, including code fragments
+ containing the error decls that were in bfd-in.h.
+ Remove DEFUNs.
+ * bfd-in2.h: Regenerated.
+
+Fri Jan 21 14:11:16 1994 Sean Fagan (sef@cygnus.com)
+
+ * nlmcode.h, liblnm.h, nlm32-alpha.c nlm32-i386.c nlm32-sparc.c:
+ The sparc (and possibly other?) NLM format requires a different
+ way to write exports, so add a write_export field to the backend
+ data (and set it to NULL for everything but the sparc).
+
+Fri Jan 21 14:11:16 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * sunos.c (MY(read_dynamic_relocs)): Compare info->dynrel with NULL,
+ not (struct external_nlist *) NULL. info->dynrel is a PTR, not
+ a struct external_nlist *.
+
+Fri Jan 21 09:29:01 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * bfd.c: Remove error strings for errors removed below.
+ * aoutx.h (translate_to_native_sym_flags), bfd-in.h (bfd_ec),
+ oasys.c (oasys_write_sections): Rename
+ bfd_error_nonrepresentable_section to nonrepresentable_section.
+ None of the other bfd error names start with "bfd_error".
+ Remove errors symbol_not_found and no_relocation_info, which seem
+ to be unused.
+ * bfd-in2.h: Regenerated.
+
+Fri Jan 21 01:11:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.c (bfd_get_gp_size): Added support for ELF.
+
+ * syms.c (BSF_DYNAMIC): New symbol flag.
+ (bfd_print_symbol_vandf): Print it.
+ * bfd-in2.h: Rebuilt.
+ * libaout.h (struct aout_backend_data): New read_dynamic_symbols
+ and read_dynamic_relocs fields.
+ (struct aoutdata): New dynamic_info field.
+ (obj_aout_dynamic_info): New accessor macro.
+ * sunos.c (struct sunos_dynamic_info): New structure.
+ (sunos_read_dynamic_info, MY(read_dynamic_symbols),
+ MY(read_dynamic_relocs)): New functions to read dynamic symbols
+ and relocs.
+ * aoutx.h (NAME(aout,some_aout_object_p)): If the object is
+ dynamically linked, set SEC_RELOC for both the .text and .data
+ sections.
+ (translate_from_native_sym_flags): Don't set BSF_LOCAL for an
+ undefined symbol.
+ (translate_symbol_table): New function, split out of
+ slurp_symbol_table; set the BSF_DYNAMIC flag appropriately.
+ (NAME(aout,slurp_symbol_table)): Read dynamic symbols, if any.
+ (NAME(aout,slurp_reloc_table)): Read dynamic relocs, if any.
+ (NAME(aout,get_reloc_upper_bound)): Include dynamic reloc count in
+ return value.
+ * aoutf1.h (NAME(aout,sunos4_write_object_contents)): Don't write
+ out dynamic symbols or relocs against reloc symbols, since they
+ are already in the .text section and we wouldn't know where to
+ write them anyhow.
+ (sunos4_aout_backend): Initialize read_dynamic_symbols and
+ read_dynamic_relocs fields.
+ * aout-target.h (MY(backend_data)): Initialize
+ read_dynamic_symbols and read_dynamic_relocs fields.
+
+Thu Jan 20 20:57:27 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * hosts/alphaosf.h (uint64e_type, uint64_type, int64_type): Delete
+ typedefs, since HOST_64_BIT will take care of defining them in
+ bfd.h.
+
+Wed Jan 19 17:28:59 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * config/alphaosf.mh (HDEFINES): Don't define HOST_64_BIT here;
+ that's dealt with elsewhere.
+ * hosts/alphaosf.h (sprintf_vma, fprintf_vma): New macros.
+ (uint64_typeHIGH, uint64_typeLOW): Comment with HOST_64_BIT so
+ they get copied to bfd.h.
+
+ * reloc.c (enum bfd_reloc_code_real): Add some Alpha relocation
+ types. Reorganized some of the existing ones.
+ * coff-alpha.c (alpha_howto_table): Construct 64-bit negative one
+ values in case of compilation on a 32-bit machine. Fix pcrel
+ fields of some reloc types.
+ (alpha_bfd_reloc_type_lookup): Handle more relocation types.
+
+ * bfd-in.h (uint64_typeHIGH, uint64_typeLOW): Supply default
+ definitions when not defined, regardless of whether uint64_type is
+ a defined macro or not.
+ (fprintf_vma, sprintf_vma): Define only if fprintf_vma is not
+ already defined.
+
+Wed Jan 19 00:02:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (translate_to_native_sym_flags): Set the type of a
+ BSF_WARNING symbol to N_WARNING.
+
+Tue Jan 18 16:43:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (aout_link_add_symbols): Increment sym_hash as well as p
+ for an indirect or warning symbol.
+ (aout_link_write_symbols): Update sym_hash with the target of an
+ indirect or warning symbol. If an indirect symbol is defined,
+ output the calculated value and don't output the target symbol.
+
+Tue Jan 18 03:54:59 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (translate_from_native_sym_flags): Give warning symbols
+ an (unused) nonzero section value, needed for check below.
+
+Mon Jan 17 15:12:07 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (translate_from_native_sym_flags,
+ aout_link_add_symbols): Treat N_SET[ABDT] | N_EXT like
+ N_SET[ABDT].
+
+Fri Jan 14 16:45:43 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * elfcode.h (elf_object_p): If there is a SHT_DYNAMIC section, set
+ the DYNAMIC flag for the BFD.
+ (NAME(bfd_elf,write_object_contents)): Don't try to write out a
+ BFD with the DYNAMIC flag set, since we don't generate the program
+ header table correctly.
+
+Fri Jan 14 01:04:36 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * elfcode.h (elf_slurp_symbol_table): Free x_symp at the end
+ of the function to avoid storage leak.
+
+Thu Jan 13 23:07:32 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_link_write_external): An ifd can be -1.
+
+Thu Jan 13 12:33:27 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_set_reloc_info): Provide a default symbol for
+ relocations which don't actually have an associated symbol.
+
+ * som.c (hppa_som_reloc): Add new "error message" argument.
+
+Wed Jan 12 13:36:43 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ Enable gdb to write to core files on more core file readers.
+ * libbfd.c (bfd_generic_set_section_contents): Remove range check
+ for section size, it is already done in bfd_set_section_contents
+ with bfd_get_section_size_now.
+ * aix386-core.c, hppabsd-core.c, hpux-core.c, irix-core.c,
+ osf-core.c, ptrace-core.c, trad-core.c (*_set_section_contents):
+ Use bfd_generic_set_section_contents instead of bfd_false.
+
+Wed Jan 12 15:31:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * linker.c: Added initial documentation.
+
+ * linker.c (default_indirect_link_order): Don't expect space for
+ output relocations if there aren't any input relocations.
+
+Tue Jan 11 14:37:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aoutx.h (NAME(aout,final_link)): Set a_entry before computing
+ file offsets.
+
+ * elfcode.h (swap_out_syms): A common symbol is STT_OBJECT, not
+ STT_NOTYPE.
+
+Tue Jan 11 09:10:56 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.bfd: Use ELF, not COFF for m88*-*-dgux*.
+ Combine m88k-*-* and m88110-*-* cases into m88*-*-*.
+
+Tue Jan 11 00:07:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecofflink.c: Extensive changes to compress and merge debugging
+ information, and to write some of out directly rather than saving
+ it in memory. Several new functions and structures, and new
+ arguments to existing functions.
+ * ecoff.c (ecoff_compute_reloc_file_positions): Compute
+ sym_filepos as well.
+ (ecoff_get_extr): Use ifdmap instead of ifdbase.
+ (ecoff_write_object_contents): Don't compute sym_filepos here.
+ Only output symbols if outsymbols is not NULL.
+ (ecoff_bfd_final_link): Adjust for changes in ecoff_debug_info and
+ bfd_ecoff_debug functions. Write out debugging information here.
+ (ecoff_final_link_debug_accumulate): Adjust for changes in
+ bfd_ecoff_debug functions.
+ (ecoff_link_write_external): Use ifdmap rather than ifdbase.
+ * elf32-mips.c (mips_elf_read_ecoff_info): Read external symbols
+ first, to put them in the first memory buffer. Clear fdr field.
+ (mips_elf_get_extr): Use pointer to unswapped external symbol.
+ (mips_elf_final_link): Adjust for changes in bfd_ecoff functions.
+ Preserve .text, .data and .bss even if they are empty. Save
+ pointer to unswapped external symbol rather than copying it.
+ Don't free up the external symbols.
+ * libelf.h (elf_symbol_type): Change mips_extr to PTR.
+ * bfd-in.h (bfd_ecoff_debug_init, bfd_ecoff_debug_free): Declare.
+ (bfd_ecoff_debug_accumulate): Update declaration.
+ (bfd_ecoff_debug_accumulate_other): Rename declaration from
+ bfd_ecoff_debug_link_other and update.
+ (bfd_ecoff_write_accumulated_debug): Declare.
+ * bfd-in2.h: Rebuilt.
+ * Makefile.in: Rebuilt dependencies.
+
+Mon Jan 10 20:46:53 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in (install): Remove "@" which follows a backslash. In
+ this position it just causes errors, not suppresses echoes.
+
+Mon Jan 10 09:06:21 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (hppa_som_gen_reloc_type): Fix handling of LT and RT
+ field selectors.
+
+Sun Jan 9 04:32:25 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * config/i386-netbsd.mt (SELECT_VECS): Include i386bsd_vec.
+
+Fri Jan 7 10:27:27 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * aoutx.h (adjust_z_magic): Don't merge the start of bss with the
+ end of data if they are not contiguous.
+
+ * aoutf1.h (sunos4_aout_backend): Comment the fields' meanings.
+
+Fri Jan 7 15:40:16 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_mkobject_hook): Don't set SEC_SHARED_LIBRARY flag
+ for .reginfo section here.
+ (ecoff_new_section_hook): Set it here instead.
+
+Fri Jan 7 10:29:27 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * bfd-in.h: (bfd_boolean): Add workaround for systems that also
+ define true and false as enums.
+ (ALMOST_STDC): Add as alternative to __STDC__.
+ * bfd-in2.h: Rebuilt.
+ * syms.c (bfd_print_symbol_vandf): Convert a PTR to FILE*.
+
+Thu Jan 6 14:24:44 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aoutx.h (translate_to_native_sym_flags): Catch the case where
+ there is no output section.
+
+Thu Jan 6 14:37:42 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * nlmcode.h (nlm_object_p): If we can't read the fixed header,
+ count it as a wrong format error, not a system call error, since
+ the object file might simply be too small.
+
+ * targets.c (target_vector): Added nlm32_alpha_vec inside #ifdef
+ BFD64.
+ * Makefile.in (BFD32_BACKENDS): Remove nlm32-alpha.o.
+ (BFD64_BACKENDS): Add nlm32-alpha.o. It depends on 64 bit
+ support, even though it is for an Alpha in 32 bit mode.
+ * configure.in (nlm32_alpha_vec): Set target64 to true.
+
+ * nlm32-gen.c, nlm64-gen.c: Removed. All nlm targets are
+ different, so there is no point to providing a generic one.
+ * libnlm.h: Don't bother to check for nlm_backend(bfd) being NULL
+ in the backend accessor macros; that should no longer be possible.
+ * targets.c (target_vector): Removed nlm32_big_generic_vec,
+ nlm64_big_generic_vec, nlm64_little_generic_vec.
+ * configure.in (nlm32_big_generic_vec, nlm32_little_generic_vec,
+ nlm64_big_generic_vec, nlm64_little_generic_vec): Removed.
+ * Makefile.in: Rebuilt dependencies, and
+ (BFD32_BACKENDS): Removed nlm32-gen.o.
+ (BFD64_BACKENDS): Removed nlm64-gen.o.
+ (CFILES): Removed nlm32-gen.c and nlm64-gen.c.
+
+ * hp300hpux.c (ARCH_SIZE): Define before including aoutx.h.
+
+ * linker.c (_bfd_generic_link_add_one_symbol): Add constructor and
+ bitsize arguments. Changed all callers (aoutx.h).
+ * libbfd-in.h (_bfd_generic_link_add_one_symbol): Add constructor
+ and bitsize arguments to declaration.
+ * libbfd.h: Rebuilt.
+
+ * ecoff.c: First cut at new style of linker backend for
+ ECOFF--added a bunch of functions. Also:
+ (ecoff_sec_to_styp_flags): Set flags for .pdata and .xdata.
+ (ecoff_slurp_symbolic_header): New function.
+ (ecoff_slurp_symbolic_info): Call ecoff_slurp_symbolic_header.
+ (ecoff_compute_reloc_file_positions): New function.
+ (ecoff_set_section_contents): Get out quickly if count is zero.
+ Check errors better.
+ (ecoff_write_object_contents): Put .xdata section in data segment.
+ Call ecoff_compute_reloc_file_positions. Don't output relocs or
+ external symbols if outsymbols is NULL.
+ (ecoff_bfd_final_link): Completely rewritten.
+ * libecoff.h: Include bfdlink.h.
+ (struct ecoff_backend_data): Add relocate_section field.
+ (ecoff_data_type): Add sym_hashes and symndx_to_section fields.
+ (struct ecoff_link_hash_entry): Define.
+ (struct ecoff_link_hash_table): Define.
+ (ecoff_bfd_link_add_symbols): Declare as function, not macro.
+ (ecoff_bfd_link_hash_table_create): Likewise.
+ * ecofflink.c (bfd_ecoff_debug_one_external): New function.
+ (bfd_ecoff_debug_externals): Call bfd_ecoff_debug_one_external.
+ * bfd-in.h (bfd_ecoff_debug_one_external): Declare.
+ * bfd-in2.h: Rebuilt.
+ * coff-alpha.c (alpha_howto_table): Mark BRADDR as
+ partial_inplace, and set the src_mask to 0x1fffff.
+ (alpha_ecoff_get_relocated_section_contents): Remove unused
+ variable gp_warned.
+ (alpha_convert_external_reloc): New static function.
+ (alpha_relocate_section): New static function.
+ (alpha_ecoff_backend_data): Initialize relocate_section field.
+ * coff-mips.c (mips_relocate_refhi): New static function.
+ (mips_relocate_section): New static function.
+ (mips_ecoff_backend_data): Initialize relocate_section field.
+
+ * reloc.c (_bfd_relocate_contents): Corrected signed overflow
+ checking when there is an addend.
+
+ * aoutx.h (NAME(aout,final_link)): Don't abort when trying to link
+ a non a.out file, just pass it to _bfd_default_link_order.
+ (aout_link_input_section_std): When doing a final PC relative link
+ against a section symbol, subtract the VMA of the input section.
+ (aout_link_input_section_ext): Likewise.
+
+ * linker.c (default_indirect_link_order): Renamed from
+ _bfd_generic_indirect_link_order and made static.
+ (_bfd_generic_final_link): Don't switch on link_order type, just
+ call _bfd_default_link_order.
+ (_bfd_default_link_order): Handle bfd_indirect_link_order type.
+ * genlink.h: Removed declaration of
+ _bfd_generic_indirect_link_order.
+ * elf32-mips.c (mips_elf_final_link): Don't switch on link_order
+ type, just call _bfd_default_link_order.
+
+Tue Jan 4 21:23:37 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * linker.c (generic_link_check_archive_element): Base the name of
+ the created common section on the name of the section the symbol
+ came from.
+ (_bfd_generic_link_add_one_symbol): (case BIG): A common symbol
+ must have a section, so don't bother to create one.
+
+Mon Jan 3 15:32:16 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aout-target.h (MY(vec)): Add DYNAMIC to mask of object flags.
+ * aoutf1.h (NAME(aout,sunos4_write_object_contents)):
+ If the DYNAMIC flag is set, set it in the exec header.
+ * aoutx.h (NAME(aout,some_aout_object_p)): If the object is
+ dynamically linked, set the DYNAMIC flag in the BFD.
+ * libaout.h (N_SET_DYNAMIC): New macro.
+ (N_DYNAMIC): Add missing 0 in mask.
+
+Mon Jan 3 11:41:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.c (ecoff_get_extr): Don't output section symbols as
+ external symbols.
+
+ * bfd-in.h, hash.c: Change bfd_hash_allocate argument from size_t
+ to unsigned int, because size_t may not be defined in bfd.h.
+ * bfd-in2.h: Rebuilt.
+
+ * bfd-in.h (bfd_get{b,l}[_signed_]{16,32,64}): Declare argument to
+ be a const pointer.
+ * bfd-in2.h: Rebuilt.
+ * libbfd.c (bfd_get{b,l}[_signed_]{16,32,64}): Declare argument to
+ be a const pointer.
+ * targets.c (bfd_target): Change swap function pointers
+ accordingly.
+ * archive.c (do_slurp_coff_armap): Change swap accordingly.
+ * aix386-core.c: Change NO_GET and NO_GETS accordingly.
+ * hppabsd-core.c, hpux-core.c, irix-core.c, osf-core.c,
+ ptrace-core.c, trad-core.c: Change NO_GET and NO_SIGNED_GET
+ accordingly.
+
+ * libbfd-in.h (struct artdata): Added tdata field.
+ (_bfd_add_bfd_to_archive_cache): Declare.
+ (_bfd_get_elt_at_filepos): Declare.
+ (_bfd_snarf_ar_hdr): Renamed from snarf_ar_hdr.
+ * libbfd.h: Rebuilt.
+ * archive.c: Cleaned up some more.
+ (_bfd_generic_mkarchive, bfd_generic_archive_p): Initialize
+ pointer elements of artdata.
+ (_bfd_add_bfd_to_archive_cache): Renamed from add_bfd_to_cache.
+ (_bfd_snarf_ar_hdr): Renamed from snarf_ar_hdr.
+ (_bfd_get_elt_at_filepos): Renamed from get_elt_at_filepos.
+ (get_extended_arelt_filename, bfd_construct_extended_name_table,
+ bfd_ar_hdr_from_filesystem, compute_and_write_armap): Made static.
+ * ecoff.c: Some comment changes.
+ (ecoff_slurp_armap): Handle rename of snarf_ar_hdr. Set
+ ardata->tdata to raw_armap.
+ (ecoff_archive_p): Initialize pointer elements of artdata.
+ * coff-rs6000.c (rs6000coff_get_elt_at_filepos): Handle rename of
+ add_bfd_to_cache.
+
+ * hash.c: Added some documentation.
+
+Mon Jan 3 11:09:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aout-target.h, netbsd386.c: Replace NO_SWAP_MAGIC with SWAP_MAGIC,
+ and do the swapping here rather than calling ntohl from the N_*
+ macros. This cleans up assumptions about the size of a host long,
+ the existence to ntohl, etc.
+
+Sat Jan 1 13:50:05 1994 Rob Savoye (rob@darkstar.cygnus.com)
+
+ * config.bfd: Add support for VSTa micro-kernel. It currently uses
+ i386-aout.
+
+Sat Jan 1 10:18:54 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * hosts/i386mach3.h (HOST_SEGMENT_SIZE): Fix value.
+ * i386mach3.c (SEGMENT_SIZE): Fix value.
+
+For older changes see ChangeLog-9193
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/ChangeLog-9697 b/bfd/ChangeLog-9697
new file mode 100644
index 00000000000..dc22c8c7c8b
--- /dev/null
+++ b/bfd/ChangeLog-9697
@@ -0,0 +1,6711 @@
+Tue Dec 30 12:45:18 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_check_relocs): If -Bsymbolic, don't
+ allocate space for a PC relative reloc against a symbol which is
+ defined in a regular file.
+ (elf32_sparc_relocate_section): If -Bsymbolic, don't copy a PC
+ relative reloc against a symbol which is defined in a regular
+ file.
+
+Mon Dec 29 18:02:28 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Jonathan Stone <jonathan@DSG.Stanford.EDU>:
+ * config.bfd (mips-dec-netbsd*): Add ECOFF vectors to
+ targ_selvecs.
+ (mips*el-*-netbsd*): Like mips-dec-netbsd*.
+ (mips*-*-netbsd*): New target.
+
+Mon Dec 29 17:13:28 1997 H.J. Lu (hjl@gnu.org)
+
+ * elflink.h (elf_link_assign_sym_version): Change error message
+ from "undefined version name" to "undefined versioned symbol
+ name".
+
+Mon Dec 29 11:41:16 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (coff_arm_relocate_section): Fix typo from previous
+ delta.
+
+Tue Dec 23 17:01:10 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Declare.
+ * libbfd.h: Rebuild.
+
+ * peicode.h (coff_swap_scnhdr_out): Set .reloc section to be
+ shared. Set stab* sections to be shared and read. Set .rsrc
+ section to be read and shared.
+
+Mon Dec 22 13:20:57 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: Rebuild dependencies.
+ (ALL_MACHINES_CFILES): Add dwarf2.lo.
+ (ALL_MACHINES_CFILES): Add dwarf2.c.
+ * Makefile.in: Rebuild.
+
+ * coff-arm.c: Don't include obstack.h.
+
+Mon Dec 22 13:04:33 1997 Joel Sherrill <joel@oarcorp.com>
+
+ * config.bfd (i[3456]86*-go32-rtems*): Fix to be the same as
+ i[3456]86-go32.
+
+Thu Dec 18 16:01:25 1997 Doug Evans <devans@canuck.cygnus.com>
+
+ * configure: Regenerate to get @SHELL@ substituted.
+
+Wed Dec 17 09:45:09 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (coff_arm_relocate_section): Only look at section
+ owner if there is one.
+
+ * elf.c (assign_file_positions_for_segments): Fail if there is not
+ enough room for the program headers.
+
+Tue Dec 16 08:09:56 1997 Gavin Koch <gavin@cygnus.com>
+
+ * elf.c (_bfd_elf_find_nearest_line): Call
+ _bfd_dwarf2_find_nearest_line first.
+ * elf32-mips.c (_bfd_mips_elf_find_nearest_line): Same.
+ * dwarf2.c: New file; implement _bfd_dwarf2_find_nearest_line.
+
+Mon Dec 15 16:08:52 1997 Nick Clifton <nickc@cygnus.com>
+
+ * archures.c: Add bfd_mach_m32r.
+
+Mon Dec 15 16:11:22 1997 Fred Fish <fnf@cygnus.com>
+
+ * coffcode.h (ALIGN_SECTIONS_IN_FILE): Define if I960 not defined.
+ (coff_compute_section_file_positions): Use ALIGN_SECTIONS_IN_FILE
+ to decide when to align the file sections for paging.
+ * coffcode.h (ALIGN_SECTIONS_IN_FILE): Undefine for TIC80COFF.
+
+Mon Dec 15 15:01:15 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-m32r.c (m32r_elf_object_p): New Function.
+ (m32r_elf_final_write_processing): New Function.
+ (m32r_elf_set_private_flags): New Function.
+ (m32r_elf_copy_private_bfd_data): New Function.
+ (m32r_elf_merge_private_bfd_data): New Function.
+ (m32r_elf_print_private_bfd_data): New Function.
+ (elf_backend_object_p): Point to m32r_object_p.
+ (elf_backend_final_write_processing): Point to
+ m32r_elf_final_write_processing.
+ (bfd_elf32_bfd_copy_private_bfd_data): Point to
+ m32r_elf_copy_private_bfd_data.
+ (bfd_elf32_bfd_merge_private_bfd_data): Point to
+ m32r_elf_merge_private_bfd_data.
+ (bfd_elf32_bfd_set_private_flags): Point to
+ m32r_elf_set_private_bfd_data.
+ (bfd_elf32_bfd_print_private_bfd_data): Point to
+ m32r_elf_print_private_bfd_data.
+
+
+ * bfd-in2.h (bfd_mach_m32r): Add identifier for M32R architecture
+ machines.
+
+Fri Dec 12 11:30:28 1997 Brendan Kehoe <brendan@canuck.cygnus.com>
+
+ * configure: Only build libbfd shared if --enable-shared's value
+ was `yes', or was set to `*bfd*'.
+ * aclocal.m4: Likewise.
+ * NOTE: this really needs to be fixed in libtool/libtool.m4, the
+ original source of this bit of code. It's not clear what the best fix
+ would be, though.
+
+Thu Dec 11 17:48:11 1997 Richard Henderson <rth@cygnus.com>
+
+ * linker.c (generic_link_add_symbol_list): Always init udata.p so
+ that the generic relaxation code can function when input and output
+ file formats are mismatched.
+
+Thu Dec 11 01:02:18 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (bfd_coff_small_swap_table): Initialize new fields.
+
+ * elf.c (assign_file_positions_for_segments): For a loadable
+ section, make sure that the load address is correct relative to
+ the load address of the segment plus the size of the segment so
+ far.
+
+ * coffcode.h (_coff_link_output_has_begun): Make static.
+ (_coff_final_link_postscript): Likewise.
+
+Wed Dec 10 23:37:11 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_input_bfd): Handle a relocateable link in
+ which a relocation refers to an indirect or warning symbol.
+
+Wed Dec 10 11:15:55 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (bfd_arm_coff_final_link): Function deleted.
+ (coff_arm_final_link_postscript): New function.
+ (coff_arm_link_output_has_begun): New function.
+
+ * libcoff.h (struct bfd_coff_backend_data): Add new fields:
+ _bfd_coff_link_output_has_begun and
+ _bfd_coff_final_link_postscript. Add new macros:
+ bfd_coff_link_output_has_begun() and
+ bfd_coff_final_link_postscript().
+
+ * cofflink.c (_bfd_coff_final_link): Insert calls to
+ bfd_coff_link_output_has_begun() and
+ bfd_coff_final_link_postscript().
+
+ * coffcode.h: Add two new fields to bfd_coff_backend_data
+ structure: _bfd_coff_link_output_has_begun and
+ _bfd_coff_final_link_postscript. Add default initialisers for
+ these fields. Add overridable aliases for the coff swap functions
+ in the backend data structure.
+
+ * elf32-v850.c: Update with patches from the branch to fix
+ HI16_S/LO16 reloc pairs.
+
+Wed Dec 10 14:06:48 1997 Michael Meissner <meissner@cygnus.com>
+
+ * elf32-d30v.c (d30v_info_to_howto_rela): New function to support
+ RELA relocations.
+ (USE_REL): Don't define any more, switch to using RELA
+ relocations.
+ (elf_info_to_howto): Define as d30v_info_to_howto_rela.
+
+Tue Dec 9 11:37:53 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * archures.c (bfd_mach_mips*): Define.
+ (bfd_default_scan): For 3000 and 4000 replace magic constant with
+ macro.
+
+ * cpu-mips.c (N): Define.
+ (bfd_mips_arch, arch_info_struct): Re-write using macro N, replace
+ numbers with bfd_mach_mips* macros.
+
+Fri Dec 5 11:13:46 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_reloc, v850_elf_store_addend_in_insn,
+ v850_elf_relocate_section): Fix reloc addend handling.
+ (v850_elf_section_from_bfd_section, v850_elf_symbol_processing,
+ v850_elf_add_symbol_hook, v850_elf_link_output_symbol_hook,
+ v850_elf_section_from_shdr, v850_elf_fake_sections): New functions
+ to create and handle special common sections.
+ (v850_elf_final_link_relocate): Fix HI16 and HI16_S relocations
+ which have data stored in the instructions.
+
+Tue Dec 2 10:26:16 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (TARGET_UNDERSCORE): Revert back to '_'
+ (USER_LABEL_PREFIX): Revert back to '_'
+
+ * config.bfd (targ_cpu): Add support for Thumb target.
+
+Mon Dec 1 20:24:18 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * coff-sh.c (sh_coff_howtos): Add R_SH_SWITCH8 entry.
+ (get_symbol_value): Handle R_SH_SWITCH8.
+ (sh_relax_delete_bytes): Likewise.
+
+Wed Nov 26 14:13:34 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (TARGET_UNDERSCORE): Changed to match definition in
+ gcc/config/arm/semi.h
+
+ * coffcode.h (coff_slurp_symbol_table): Add ARM and Thumb symbol
+ classes.
+
+Sun Nov 23 16:02:58 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * freebsd.h (SWAP_MAGIC): Read magic number little and not big
+ endian.
+
+Wed Nov 26 09:30:37 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coffcode.h (coff_mkobject_hook): Only set private flags for non
+ PE ARM ports.
+
+Tue Nov 25 15:33:23 1997 Richard Henderson <rth@cygnus.com>
+
+ * binary.c (binary_set_section_contents): Also ignore NEVER_LOAD
+ sections.
+
+Tue Nov 25 10:55:36 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (coff_arm_bfd_merge_private_bfd_data): Do not
+ complain if inout and output formats differ.
+
+Tue Nov 25 11:26:27 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (BFD32_BACKENDS): Remove tekhex.lo.
+ (BFD32_BACKENDS_CFILES): Remove tekhex.c.
+ * Makefile.in: Rebuild.
+ * aclocal.m4, configure, src/Makefile.in: Rebuild with current
+ automake and autoconf.
+
+ * coff-arm.c (arm_allocate_interworking_sections): Fix typo
+ (COFF_WITH_PR to COFF_WITH_PE).
+
+Mon Nov 24 15:47:49 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c: Make variables and some functions static, so that
+ this file can be included in multiple object files.
+ (coff_arm_bfd_final_link): Fix minor bug.
+
+Sat Nov 22 15:16:00 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c: Add support for PIC and APCS-FLOAT type binaries.
+
+ * coffcode.h: Add support for PIC and APCS-FLOAT type binaries.
+
+Sat Nov 22 16:06:56 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * evax-emh.c (_bfd_evax_write_emh): Use alloca instead of strdup.
+
+Sat Nov 22 12:29:30 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_add_one_symbol): When overriding a defined
+ symbol, set it to undefined, not new.
+
+ * elf32-sh.c (sh_elf_relax_delete_bytes): Don't kill LABEL
+ relocs.
+
+Fri Nov 21 14:14:22 1997 Richard Henderson <rth@cygnus.com>
+
+ * coff-sh.c (sh_relax_section): Force sign extention of USES r_offset.
+ (sh_relax_delete_bytes): Don't kill LABEL relocs.
+
+Mon Nov 17 15:08:38 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Fix typo.
+ (mn10300_elf_relax_section): Likewise.
+
+Sat Nov 15 15:36:07 1997 Fred Fish <fnf@cygnus.com>
+
+ * peicode.h (coff_swap_aouthdr_in): Cast second arg of
+ bfd_h_get_* calls to "bfd_byte *".
+
+Tue Nov 11 10:37:23 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf-m10300.c (elf32_mn10300_link_hash_entry): Add new field
+ "movm_stack_size".
+ (mn10300_elf_relax_section): Include stack space for register saves
+ in the imm8 field of a "call" instruction.
+ (compute_function_info): Determine how much stack is allocated by
+ the movm instruction. Fix typo.
+ (elf32_mn10300_link_hash_newfunc): Initialize movm_stack_size.
+
+Mon Nov 10 14:32:40 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Don't crash if
+ a version dependency could not be found.
+
+Tue Nov 4 12:05:56 1997 Klaus K"ampf <kkaempf@progis.de>
+
+ * configure.com: Get version info from configure.in
+
+Fri Oct 24 11:15:58 1997 Jakub Jelinek <jj@sunsite.mff.cuni.cz>
+
+ * elf64-sparc.c (sparc64_elf_merge_private_bfd_data):
+ New function. Avoid mixing US1 and HAL R1 code.
+ Set resulting memory ordering to the strongest one used.
+ (sparc64_elf_object_p): Set bfd_mach correctly.
+
+Thu Oct 23 14:09:33 1997 Richard Henderson <rth@cygnus.com>
+
+ * elf64-sparc.c (sparc64_elf_howto_table): Add UA64 & UA16.
+ (sparc64_elf_check_relocs): Handle them.
+ (sparc64_elf_relocate_section): Likewise. Before emitting a dyn reloc,
+ check alignment and transmute R_SPARC_x<->R_SPARC_UAx.
+
+Thu Oct 23 00:53:14 1997 Richard Henderson <rth@dot.cygnus.com>
+
+ * configure.in (sparc*-*-linux*): Use trad-core and ...
+ * hosts/sparclinux.h: New file.
+
+Thu Oct 23 00:25:29 1997 Richard Henderson <rth@dot.cygnus.com>
+
+ * config.bfd (sparc64-*-linux*): New target.
+
+ * elf-bfd.h (struct elf_backend_data): Add plt_alignment member.
+ * elflink.c (_bfd_elf_create_got_section): Set .got alignment based
+ on arch_size.
+ (_bfd_elf_create_dynamic_sections): Likewise for .rel* sections.
+ Set .plt alignment from new plt_alignment.
+ * elflink.h (elf_link_create_dynamic_sections): Set version section
+ alignment to LOG_FILE_ALIGN.
+ * elfxx-target.h (elf_backend_plt_alignment): Provide default.
+ (elfXX_bed): Init plt_alignment.
+
+ * elf64-sparc.c (sparc64_elf_check_relocs,
+ sparc64_elf_adjust_dynamic_symbol, sparc64_elf_size_dynamic_sections,
+ sparc64_elf_adjust_dynindx, sparc64_elf_finish_dynamic_symbol,
+ sparc64_elf_finish_dynamic_sections): New functions.
+ (sparc64_elf_howto_table): Fix a few name strings.
+ (ELF_DYNAMIC_INTERPRETER): New definition.
+ (sparc64_elf_relocate_section): Handle shared libraries.
+
+ * elf64-sparc.c (struct plt_template, plt_*_header, plt_*_entry,
+ sparc64_elf_build_plt_entry, sparc64_elf_finish_dynamic_symbol):
+ PLT definitions sparc64-linux originally choose. These will go
+ away soon in favour of the official abi definitions.
+
+Wed Oct 22 16:08:45 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (coff_small_object_p): New static function.
+ (coff_small_new_section_hook): New static function.
+ (bfd_coff_small_swap_table): New static const structure.
+ (coff_small_close_and_cleanup): Define.
+ (coff_small_bfd_free_cached_info): Define.
+ (coff_small_get_section_contents): Define.
+ (coff_small_get_section_contents_in_window): Define.
+ (shcoff_small_vec): New static structure.
+ (shlcoff_small_vec): New static structure.
+ * targets.c (bfd_target_vector): Add shcoff_small_vec and
+ shlcoff_small_vec.
+ * config.bfd (sh-*-elf*): Add shcoff_small_vec and
+ shlcoff_small_vec to targ_selvecs.
+ (sh-*-*): Likewise.
+ * configure.in: Add shcoff_small_vec and shlcoff_small_vec cases.
+ * configure: Rebuild.
+
+Mon Oct 20 15:01:27 1997 Klaus K"ampf <kkaempf@progis.de>
+
+ * evax-egsd.c: Weak symbols are global.
+
+ * evax-emh.c: Use proper casts.
+
+ * evax-egsd.c (_bfd_evax_write_egsd): Remove unneeded uname.
+
+ * evax-egsd.c: Section names and symbols have different
+ length restrictions. Add length parameter to
+ _bfd_evax_length_hash_symbol.
+ * evax-etir.c: Likewise.
+ * evax-misc.c (_bfd_evax_length_hash_symbol): Add length
+ parameter.
+ * evax.h (EOBJ_S_C_SECSIZ): Define.
+
+ * evax-alpha.c: Remove duplicate test.
+
+ * evax-emh.c: SYS$ functions are upper-case.
+
+ * evax-egsd.c: Create separate sections for common symbols.
+ * evax-etir.c: Don't output common section.
+ * evax.h: Bump up section count.
+
+ * configure.com: Use 64bit integers with DEC C.
+
+ * evax-egsd.c: Make section flags dec c compatible.
+
+Mon Oct 20 09:38:31 1997 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (normalize): Delete function.
+ (som_bfd_ar_write_symbol_stuff): New parameter elength. All callers
+ changed. Use passed in elength to determine size of the extended
+ name table instead of computing it again.
+
+Sun Oct 19 23:36:21 1997 Jim Wilson <wilson@cygnus.com>
+
+ * peicode.h (coff_swap_scnhdr_out): Use |= not = to set
+ IMAGE_SCN_MEM_READ for an unrecognized section.
+
+Sun Oct 19 21:04:56 1997 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_bfd_ar_write_symbol_stuff): Account for trailing
+ '/' in the extended name table.
+
+Fri Oct 17 00:04:13 1997 Richard Henderson <rth@cygnus.com>
+
+ * elflink.h (elf_link_assign_sym_version): For explicitly versioned
+ symbols, check globals list before matching on locals.
+
+Thu Oct 16 08:17:06 1997 Michael Meissner <meissner@cygnus.com>
+
+ * peicode.h (coff_swap_scnhdr_out,pe_print_idata): Fix mangled
+ patch.
+
+Wed Oct 15 13:45:10 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (pe_mkobject_hook): Set DLL flag.
+ (pe_bfd_copy_private_bfd_data): Copy DLL flag.
+
+ * peicode.h (coff_swap_scnhdr_out): Set IMAGE_SCN_MEM_DISCARDABLE
+ for .stab* sections. Replace strlen of constant strings with
+ number.
+
+Tue Oct 14 15:42:45 1997 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_merge_ind_symbols): New function to
+ merge got and reloc entries from ind syms to their target.
+ (elf64_alpha_always_size_sections): Call it.
+ (elf64_alpha_check_relocs): Operate on the target of indirect symbols.
+ (elf64_alpha_can_merge_gots): Likewise.
+ (elf64_alpha_merge_gots): Likewise.
+
+ * elf64-alpha.c (elf64_alpha_relocate_section): Back out HJ's change,
+ as it is insufficient to handle the relocation changes as well.
+
+Mon Oct 13 23:10:08 1997 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_calc_dynrel_sizes): Allow for RELATIVE
+ relocs for symbols in shlibs that have been forced local.
+ (elf64_alpha_relocate_section): Output RELATIVEs in .got for same.
+
+Mon Oct 13 21:24:04 1997 Richard Henderson <rth@cygnus.com>
+
+ * elf64-alpha.c (elf64_alpha_relocate_section): Use the
+ got_enties of the default symbol for the default versioned
+ symbol. Patch from hjl@gnu.ai.mit.edu, modified not to use
+ alloca in the loop.
+
+Mon Oct 13 17:37:37 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_final_link_relocate): Only use the bottom
+ 24 bits of the PC when computing a PC relative relocation.
+
+Fri Oct 10 16:01:30 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_reloc, v850_elf_final_link_relocate):
+ Correct value for maximum positive 22 bit PC relative relocation.
+ (v850_elf_final_link_relocate): Prevent overflow from HI16_S and
+ HI_16 relocations. Correct bit adjustment in TDA offsets.
+
+Thu Oct 9 16:43:39 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf64-sparc.c (sparc_elf_{hix22,lox10}_reloc): New functions.
+ (sparc64_elf_howto_table): Use them for HIX22,LOX10 relocs.
+
+Wed Oct 8 11:38:45 1997 Richard Henderson <rth@cygnus.com>
+
+ * elfcore.h (bfd_prstatus): Pedanticly, alignment_power should
+ be LOG_FILE_ALIGN.
+
+Wed Oct 8 11:36:00 1997 Richard Henderson <rth@cygnus.com>
+
+ * config.bfd: Missed one alpha* change.
+
+Tue Oct 7 13:00:17 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf32-sparc.c (_bfd_sparc_elf_howto_table): Remove BFD64 support.
+ * elf64-sparc.c (SPARC64_OLD_RELOCS): Undef.
+ (MINUS_ONE): New macro.
+ (sparc_elf_notsup_reloc): New function.
+ (sparc64_elf_howto_table): Add entries for DISP64,PLT64,HIX22,LOX10,
+ H44,M44,L44,REGISTER.
+ (sparc_reloc_map): Likewise. Map BFD_RELOC_CTOR to R_SPARC_64.
+ (init_insn_reloc): New function.
+ (sparc_elf_wdisp16_reloc): Use it.
+ (sparc64_elf_relocate_section): Add entries for OLO10,HIX22,LOX10.
+
+Tue Oct 7 11:40:37 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * som.c (som_construct_extended_name_table): Remove static
+ function, and define as macro instead.
+
+Fri Oct 3 14:02:17 1997 Richard Henderson <rth@cygnus.com>
+
+ * config.bfd: Change alpha-*-* to alpha*-*-*; config.guess now
+ recognizes alphaev5 etc.
+ * configure.host: Likewise.
+
+Fri Oct 3 11:23:47 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ Make ld -s work on AIX:
+ * xcofflink.c (xcoff_link_add_symbols): Don't create the .debug
+ section if we are stripping.
+ (bfd_xcoff_size_dynamic_sections): Don't set the .debug section
+ size if we are stripping.
+ (_bfd_xcoff_bfd_final_link): Don't set SEC_RELOC or rel_filepos,
+ and don't write out relocs, if we are stripping.
+ (xcoff_link_input_bfd): Don't set up reloc if we are stripping.
+ (xcoff_write_global_symbol): Don't write out symbol or reloc if we
+ are stripping.
+
+ * configure.in: Don't include elf.lo again for ELF targets; it's
+ always in the library anyhow.
+ * configure: Rebuild.
+
+ * bfd-in2.h: Rebuild.
+
+ * elf32-sparc.c (sparc_elf_wdisp16_reloc): Cast to bfd_byte *, not
+ char *, when calling bfd_get_32 and bfd_put_32.
+ * sunos.c (sunos_scan_dynamic_symbol): Cast contents to char *
+ when calling strcpy.
+
+Thu Oct 2 16:15:50 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * reloc.c (bfd_check_overflow): New function.
+ (bfd_perform_relocation, bfd_install_relocation): Use it.
+ (BFD_RELOC_SPARC_{DISP64,PLT64}): New relocs.
+ (BFD_RELOC_SPARC_{HIX22,LOX10,H44,M44,L44,REGISTER}): New relocs.
+ * bfd-in2.h: Regenerate.
+ * libbfd.h: Regenerate.
+
+Thu Oct 2 13:17:18 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (coff_swap_scnhdr_out): Set IMAGE_SCN_MEM_READ for an
+ unrecognized section. From Jon Thackray <jont@harlequin.co.uk>.
+
+Wed Oct 1 14:03:44 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am ($(BFD_H)): Change stmp-bfd.h to stmp-bfd-h.
+ (stmp-bfd-h): Rename from stmp-bfd.h.
+ (BFD_H_FILES, LIBBFD_H_FILES, LIBCOFF_H_FILES): New variables.
+ ($(srcdir)/bfd-in2.h): Just depend upon stmp-bin2-h.
+ (stmp-bin2-h): New target.
+ ($(srcdir)/libbfd.h): Just depend upon stmp-lbfd-h.
+ (stmp-lbfd-h): New target.
+ ($(srcdir)/libcoff.h): Just depend upon stmp-lcoff-h.
+ (stmp-lcoff-h): New target.
+ (CLEANFILES): Change stmp-bfd.h to stmp-bfd-h. Add stmp-bin2.h,
+ stmp-lbfd-h, and stmp-lcoff-h.
+ * Makefile.in: Rebuild.
+
+ * configure.in: Use a diversion to set enable_shared before the
+ arguments are parsed.
+ * configure: Rebuild.
+
+Tue Sep 30 14:18:32 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf32-sparc.c (_bfd_sparc_elf_howto_table): R_SPARC_GLOB_JMP
+ renamed to R_SPARC_UNUSED_42.
+ (sparc_reloc_map): Delete R_SPARC_GLOB_JMP entry.
+ * elf64-sparc.c (_bfd_sparc_elf_howto_table): R_SPARC_GLOB_JMP
+ renamed to R_SPARC_UNUSED_42.
+ (sparc_reloc_map): Delete R_SPARC_GLOB_JMP entry.
+ * reloc.c (BFD_RELOC_SPARC_GLOB_JMP): Delete.
+ * bfd-in2.h: Regenerated.
+ * libbfd.h: Regenerated.
+
+Thu Sep 25 12:15:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_merge_symbol): Don't check the hash creator until
+ after we have set *sym_hash.
+
+Wed Sep 24 16:52:28 1997 Joel Sherrill <joel@oarcorp.com>
+
+ * config.bfd (sh*-*-rtems*): New target, like sh-*-*elf*.
+
+Wed Sep 24 11:27:23 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (libbfd_a_SOURCES): Define.
+ * Makefile.in: Rebuild.
+
+ * configure.in: Call AC_CHECK_TOOL before AM_PROG_LIBTOOL.
+ * aclocal.m4: Rebuild with new libtool.
+ * configure: Rebuild.
+
+Tue Sep 23 19:03:13 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (map_sections_to_segments): Even if we are not demand
+ paged, don't put a loadable section after a nonloadable section.
+ (assign_file_positions_for_segments): Increment the file offset
+ for a section with contents, even if it is not loadable.
+
+Sun Sep 21 11:03:24 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_final_link_relocate): Add return code
+ indicating that __ctbp could not be found.
+
+Thu Sep 18 15:04:57 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_check_relocs): Improve error message.
+
+Wed Sep 17 09:54:51 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_final_link_relocate, v850_elf_reloc,
+ v850_elf_check_relocs, v850_elf_reloc_map, v850_elf_howto_table):
+ Add support for the CALLT relocs.
+
+ * reloc.c (COMMENT): Add BFD_RELOC_V850_CALLT_6_7_OFFSET and
+ BFD_RELOC_V850_CALLT_16_16_OFFSET.
+
+ * elf32-v850.c (v850_elf_final_link_relocate): Add checks to catch
+ relocations against non-existant symbols.
+
+Tue Sep 16 14:20:27 1997 Nick Clifton <nickc@cygnus.com>
+
+ * reloc.c: Add BFR_RELOC_V850_TDA_16_16_OFFSET.
+
+ * elf32-v850.c (v850_elf_reloc, v850_elf_final_link_relocate,
+ v850_elf_howto_table, v850_elf_reloc_map): Add support for a 16
+ bit reloc in the tiny data area.
+
+Mon Sep 15 11:27:36 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ Merged changes from Martin Hunt:
+
+ * elf32-d30v.c (bfd_elf_d30v_reloc): Change pc-relative relocs
+ over 2^32 bytes to be absolute. Needed because D30V PC doesn't
+ necessarily wrap.
+
+ * reloc.c, elf32-d30v.c (BFD_RELOC_D30V_9_PCREL,
+ BFD_RELOC_D30V_9_PCREL_R): New relocs.
+
+ * elf32-d30v.c (bfd_elf_d30v_reloc_21): New function.
+ Do 15 and 21 bit pc-relative relocations.
+ * reloc.c (BFD_RELOC_D30V_15_PCREL_R, BFD_RELOC_D30V_21_PCREL_R):
+ New relocations.
+
+ * elf32-d30v.c (bfd_elf_d30v_reloc): Addend needs to be
+ added to the relocation, not or'd.
+
+Wed Sep 10 15:17:25 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_reloc): Remove spurious error message.
+
+Wed Sep 10 11:17:50 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * archures.c (bfd_default_scan): Use strcasecmp.
+ (bfd_default_scan): Test for match with arch_name + ":" +
+ printable_name.
+ (bfd_default_scan): Test for match with printable_name - ":".
+ (bfd_default_scan): Delete w65, h8300, h8500, z8k, i960 special
+ cases. Each implements their own scan function.
+ (bfd_default_scan): Delete 386, 2900, 860, mips 2000, mips 4400
+ special cases. Since info->mach == 0. The test mach == number
+ fails.
+ (bfd_arch_list): New function, return name of all the supported
+ architectures.
+
+Tue Sep 9 10:21:56 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_print_private_bfd_data): Break after
+ decoding architecture.
+ (v850_elf_reloc): Do not complain if a R_V850_LO16 reloc has bit
+ 15 set.
+
+Sun Sep 7 12:25:22 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
+
+ * bfd/elf64-alpha.c (reloc_howto_type): Fix the howto table.
+
+Thu Sep 4 09:44:10 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: Rebuild dependencies.
+ (ALL_MACHINES_CFILES): Add cpu-v850.c.
+ (ALL_MACHINES_CFILES): Add elf32-v850.c.
+ * Makefile.in: Rebuild.
+
+ * reloc.c: Remove extraneous commas from relocation entries.
+ Remove BFD_RELOC_V850_16_PCREL.
+ * bfd-in2.h: Rebuild.
+
+ * xcofflink.c (xcoff_link_add_symbols): Put XTY_CM/XMC_TD symbols
+ in sections named .tocbss rather than .bss.
+
+Wed Sep 3 11:23:23 1997 Nick Clifton <nickc@cygnus.com>
+
+ * libbfd.h, bfd-in2.h, elf32-v850.c: Removed
+ BFD_RELOC_V850_16_PCREL.
+
+Tue Sep 2 20:44:10 1997 Fred Fish <fnf@cygnus.com>
+
+ * cofflink.c (coff_link_check_ar_symbols): Handle C_SYSTEM syms
+ the same as C_EXT syms.
+ (coff_link_add_symbols): Ditto.
+ (_bfd_coff_link_input_bfd): Ditto.
+ (_bfd_coff_write_task_globals): Add save_global_to_static. Use
+ it to preserve and restore state of global_to_static flag.
+
+Tue Sep 2 17:45:22 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_object_p): Set machine number based on
+ bits in e_flags field rather than magic numbers.
+ (v850_elf_final_write_processing, v850_elf_set_private_flags,
+ v850_elf_copy_private_bfd_data, v850_elf_merge_private_bfd_data,
+ v850_elf_print_private_bfd_data): New functions.
+
+Tue Sep 2 17:43:49 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf.c (prep_headers): Remove V850E magic number.
+ * elf.c (prep_headers): Remove V850EA magic number.
+
+Tue Sep 2 17:35:05 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cpu-arc.c (arc_get_mach): Properly scan defined mach entries.
+
+Tue Sep 2 18:29:37 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf-m10200.c (mn10200_elf_final_link_relocate): PC relative
+ instructions are relative to the next instruction, not the
+ current instruction.
+ (mn10200_elf_relax_section): Similarly.
+
+Tue Sep 2 15:45:45 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-v850.c: Use a macro to construct bfd_arch_info_type
+ entries.
+
+ * reloc.c, libbfd.h, bfd-in2.h, elf32-v850.c: Replace
+ BFD_RELOC_V850_{SDA/TDA/ZDA}_OFFSET relocs with new bit pattern
+ specific versions: BFD_RELOC_V850_{area}_{bits}_OFFSET.
+
+Thu Aug 28 17:01:09 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * cpu-v850.c: Remove "plain" from v850 printable name.
+ (scan): Use strcasecmp.
+
+ * archures.c (bfd_mach_v850): Define.
+
+ * cpu-sh.c (scan_mach): Compare with table instead of hardwired to
+ just sh/SH, use strcasecmp.
+ (arch_info_struct): Add entries for sh3 et.al.
+
+ * archures.c (bfd_mach_sh, ...): Define.
+
+Wed Aug 27 17:33:07 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * archures.c (bfd_archures_list): Always NULL terminate the list.
+
+Tue Aug 26 17:26:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: Rebuild dependencies.
+ (ALL_MACHINES_CFILES): Add cpu-arc.c.
+ (ALL_MACHINES_CFILES): Add elf32-arc.c.
+ (elf32-arc.lo): Remove explicit dependency.
+ * Makefile.in: Rebuild.
+
+ * acinclude.m4 (BFD_CC_FOR_BUILD): Set EXEEXT_FOR_BUILD.
+ * doc/Makefile.am (MKDOC): Use EXEEXT_FOR_BUILD, not EXEEXT.
+ * aclocal.m4, configure, Makefile.in, doc/Makefile.in: Rebuild.
+
+Mon Aug 25 16:14:34 1997 Christopher Provenzano <proven@cygnus.com>
+
+ * configure: Rebuild with latest devo autoconf for NT support
+
+Mon Aug 25 16:11:04 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-arm.c (compatible): If B is a default type, return A.
+
+Mon Aug 25 15:35:46 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-v850.c (scan): New function.
+ (arch_info_struct): New structure.
+ (bfd_v850_arch): Add link into arch_info_structure.
+
+ * config.bfd (targ_cpu): All v850 variants use the bfd_arch_v850
+ architecture.
+
+ * elf32-v850.c (v850_elf_object_p): New function.
+
+ * archures.c (bfd_mach_v850e): Machine value for v850e.
+
+ * bfd-in2.h (bfd_mach_v850e): Machine value for v850e.
+
+ * elf32-v850.c (ELF_MACHINE_CODE): Default to v850e machine
+ number.
+
+ * elf.c (prep_headers): Add support for v850e machine number.
+
+ * archures.c (bfd_mach_v850ea): Machine value for v850ea.
+
+ * bfd-in2.h (bfd_mach_v850ea): Machine value for v850ea.
+
+ * elf32-v850.c (ELF_MACHINE_CODE): Default to v850ea machine
+ number.
+
+ * elf.c (prep_headers): Add support for v850ea machine number.
+
+Mon Aug 25 14:07:33 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * syms.c (_bfd_stab_section_find_nearest_line): Clear the
+ cached_stab field if the offset prevents us from using the cache.
+
+Mon Aug 25 12:08:13 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aout-target.h (MY(vec)): Add SEC_CODE and SEC_DATA to section
+ flags.
+ * aout-arm.c (aout_arm_little_vec): Likewise.
+ (aout_arm_big_vec): Likewise.
+ * bout.c (b_out_vec_big_host): Likewise.
+ (b_out_vec_little_host): Likewise.
+ * mipsbsd.c (aout_mips_little_vec): Likewise.
+ (aout_mips_big_vec): Likewise.
+
+Tue Aug 19 10:09:10 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (COFF_ALIGN_IN_SFLAGS): Define to 1.
+ * coffcode.h (styp_to_sec_flags): Ignore incoming STYP_INFO
+ bit in s_flags if COFF_ALIGN_IN_S_FLAGS is defined.
+
+Tue Aug 19 08:47:17 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-i960.c (COFF_ALIGN_IN_SECTION_HEADER): Define to 1.
+ (GET_SCNHDR_ALIGN, PUT_SCNHDR_ALIGN): Define.
+ * coff-m88k.c (GET_SCNHDR_NRELOC, GET_SCNHDR_NLNNO): Define.
+ * coffcode.h (coff_set_alignment_hook): Conditionally compile in if
+ COFF_ALIGN_IN_SECTION_HEADER is defined. Convert alignment to power
+ of two for I960 only.
+ * coffswap.h (GET_SCNHDR_NRELOC, PUT_SCNHDR_NRELOC, GET_SCNDHR_NLNNO,
+ PUT_SCNHDR_NLNNO, GET_SCNHDR_FLAGS, PUT_SCNHDR_FLAGS): Provide
+ default definitions.
+ (coff_swap_scnhdr_in): Use GET_SCNHDR_FLAGS, GET_SCNHDR_NRELOC,
+ GET_SCNHDR_NLNNO, and GET_SCNHDR_ALIGN.
+ (coff_swap_scnhdr_out): Use PUT_SCNHDR_FLAGS, PUT_SCNHDR_ALIGN.
+ * Makefile.in (coff-tic80.o): Depends upon coffswap.h.
+ * coff-tic80.c (COFF_ALIGN_IN_SECTION_HEADER): Define to 1.
+ (GET_SCNHDR_FLAGS, PUT_SCNHDR_FLAGS): Define
+ * coffcode.h (coff_write_object_contents): Set alignment field in
+ section header for TIC80COFF files.
+
+Mon Aug 18 11:36:19 1997 Nick Clifton <nickc@cygnus.com>
+
+ * elf32-v850.c (v850_elf_howto_table, v850_elf_reloc_map,
+ v850_elf_check_relocs, v850_elf_reloc,
+ v850_elf_final_link_relocate): Add support for
+ BFD_RELOC_V850_16_PCREL relocation.
+
+ * reloc.c (COMMENT): Add suuport for BFD_RELOC_V850_16_PCREL
+ relocation.
+
+ * libbfd.h: Add support for BFD_RELOC_V850_16_PCREL relocation.
+
+ * bfd-in2.h: Add support for BFD_RELOC_V850_16_PCREL relocation.
+
+Mon Aug 18 11:33:56 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-v850e: New file.
+
+ * elf.c (prep_headers): Add support for v850e target.
+
+ * bfd-in2.h (bfd_architecture): Add support for v850e target.
+
+ * config.bfd: Add support for v850e target.
+
+ * archures.c: Add support for v850e target.
+
+Mon Aug 18 11:33:56 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-v850ea: New file.
+
+ * elf.c (prep_headers): Add support for v850ea target.
+
+ * bfd-in2.h (bfd_architecture): Add support for v850ea target.
+
+ * config.bfd: Add support for v850ea target.
+
+ * archures.c: Add support for v850ea target.
+
+Fri Aug 15 12:01:28 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffgen.c (coff_find_nearest_line): Correctly handle the offset
+ argument as section relative, rather than an absolute address.
+ From Jan Hoogenraad <hoogenrd@natlab.research.philips.com>.
+
+Fri Aug 15 04:58:02 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.bfd (arc-*-elf*): Add.
+ * configure.in (bfd_elf32_{little,big}arc_vec): Add.
+ * configure: Rebuild.
+ * Makefile.am (ALL_MACHINES): Add cpu-arc.lo.
+ (BFD32_BACKENDS): Add elf32-arc.lo.
+ (cpu-arc.lo,elf32-arc.lo): Add rules for.
+ * Makefile.in: Rebuild.
+ * archures.c (architecture list): Add bfd_arch_arc.
+ (bfd_archures_list): Add bfd_arc_arch.
+ (bfd_mach_arc_base): Define.
+ * reloc.c (BFD_RELOC_ARC_B22_PCREL,BFD_RELOC_ARC_B26): Add.
+ * targets.c (bfd_elf32_{little,big}arc_vec): Declare.
+ (bfd_target_vect): Add them.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * cpu-arc.c, elf32-arc.c: New files.
+ * elf.c (pre_headers): Recognize bfd_arch_arc.
+
+Tue Aug 12 11:45:18 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,final_link)): If no symbols, make sure the
+ data section is correctly rounded to a page in the file.
+
+Mon Aug 11 12:45:43 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,final_link)): Don't emit the string table if
+ there are no symbols.
+
+Sun Aug 10 14:45:56 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-stgo32.c: Rename from coff-stubgo32.c to avoid old System V
+ file system 14 character limit.
+ * Makefile.am, configure.in: Corresponding changes.
+ * Makefile.in, configure: Rebuild.
+
+Fri Aug 8 18:34:36 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: (ALL_MACHINES_CFILES): Add elf32-d10v.c.
+ Rebuild dependencies.
+ * Makefile.in: Rebuild.
+
+Wed Aug 6 18:56:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (docdir): Define.
+ * Makefile.in: Rebuild.
+
+Tue Aug 5 23:05:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Rebuild with autoconf 2.12.1.
+
+Mon Aug 4 12:00:35 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aclocal.m4, configure: Rebuild with new automake patches.
+
+Sun Aug 3 08:15:12 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * rs6000-core.c (make_bfd_asection): New function to add a section
+ to the core file bfd.
+ (rs6000coff_core_p): Use make_bfd_asection to add the core file
+ sections.
+ Use BFD routines to seek, read and stat the core file.
+ Handle .data sections from loaded objects and anonymously mmapped
+ regions, these are available in AIX 4 core files.
+
+Fri Aug 1 12:58:32 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set enable_shared before AM_PROG_LIBTOOL.
+ * acinclude.m4: Move acmacros.m4 in here. Remove AM_PROG_LIBTOOL
+ copy; use a patches libtool instead.
+ * acmacros.m4: Remove.
+ * Makefile.in, aclocal.m4, configure: Rebuild.
+
+Thu Jul 31 19:55:36 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: New file, based on old Makefile.in.
+ * acmacros.m4: New file, copied from old aclocal.m4.
+ * acinclude.m4: New file.
+ * configure.in: Call AM_PROG_LIBTOOL. Remove shared library
+ handling; now handled by libtool. Replace AC_CONFIG_HEADER with
+ AM_CONFIG_HEADER. Replace AC_PROG_INSTALL with AM_PROG_INSTALL.
+ Call AM_MAINTAINER_MODE, AM_CYGWIN32, and AM_EXEEXT. Change all
+ .o files to .lo. Remove stamp-h handling in AC_OUTPUT.
+ * acconfig.h: Mention PACKAGE and VERSION.
+ * stamp-h.in: New file.
+ * dep-in.sed: Change .o to .lo.
+ * Makefile.in: Now built with automake.
+ * aclocal.m4: Now built with aclocal.
+ * config.in, configure: Rebuild.
+ * VERSION: Remove.
+
+Thu Jul 31 12:09:20 1997 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Don't set TEXTREL
+ if there is only a relocation to a read-only but not allocatable
+ section (like .stab).
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Likewise.
+ * elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
+ * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
+ * elf32-mips.c (mips_elf_size_dynamic_sections): Likewise.
+ * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
+
+ * elf32-ppc.c (ppc_elf_howto_raw): Correct various comments.
+ (ppc_elf_create_linker_section): These sections are not
+ created by the linker (that is, they are created by the user
+ putting data in them). In particular, they can be the source
+ and target of relocations.
+ (ppc_elf_adjust_dynamic_symbol): Check postcondition of
+ bfd_elf32_link_record_dynamic_symbol. Align 16-byte common
+ objects (for instance, 'long double') to 16-byte boundaries.
+ (ppc_elf_size_dynamic_sections): Make the code that generates
+ section symbols exactly the same as for sparc, reducing the
+ number of section symbols output.
+ (ppc_elf_check_relocs): Check postcondition of
+ bfd_elf32_link_record_dynamic_symbol. Make default case the
+ same as corresponding code for sparc, fixing bug involving
+ .rela.stabs.
+ (ppc_elf_finish_dynamic_symbol): Fix case involving GOT symbols
+ forced to be local because of versioning (by replicating
+ corresponding change in sparc). Treat R_PPC_RELATIVE RELA relocs
+ as usual in ELF, not as pseudo-REL relocs (as the sparc linker
+ does).
+ (ppc_elf_relocate_section): Add handy debugging code for when
+ assertion fails. Add some more 'symbol made local because of
+ versioning' cases.
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Cope with addend when
+ processing a GOT relocation as required by ABI.
+
+Wed Jul 30 21:30:35 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elflink.h (NAME(bfd_elf,record_link_assignment)): Remove any
+ version info if this symbol came from a dynamic object.
+ (elf_link_add_object_symbols): Set the version info of a symbol
+ only if the object actually contains version definitions and
+ defines this symbol.
+
+Mon Jul 28 18:07:43 1997 Rob Savoye <rob@chinadoll.cygnus.com>
+
+ * aclocal.m4: Add CYGWIN and EXEEXT autoconf macros.
+ * configure.in: Use CYGWIN and EXEEXT autoconf macro to look for
+ win32 dependencies.
+ * configure: Regenerated with autoconf 2.12.
+ * doc/Makefile.in: Add $(EXEEXT) to chew executable.
+
+Mon Jul 28 02:50:29 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * rs6000-core.c (rs6000coff_core_p): If CORE_TRUNC is set, print
+ a warning rather than returning an error.
+
+Sun Jul 27 19:54:14 1997 Felix Lee <flee@cygnus.com>
+
+ * coffswap.h (coff_swap_aux_in): add semicolon to make MSVC happy.
+
+Fri Jul 25 14:50:08 1997 Felix Lee <flee@cygnus.com>
+
+ * cisco-core.c: define signals for wingdb.
+
+Fri Jul 25 16:27:07 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecofflink.c (bfd_ecoff_debug_accumulate): Only merge files with
+ the same number of aux entries.
+
+Fri Jul 25 08:22:15 1997 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (hppa_som_gen_reloc_type): Use R_DATA_EXPR for the
+ difference of two symbols if the relocation size is 32 bits.
+ (som_write_fixups): Handle R_DATA_EXPR.
+
+Wed Jul 23 16:08:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i386.c (coff_i386_reloc): Don't offset a common symbol by
+ its value if COFF_WITH_PE is defined.
+
+Tue Jul 22 17:19:45 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
+
+ * coff-stubgo32.c: New file.
+ * go32stub.h: New file.
+ * coff-i386.c: If COFF_GO32_EXE, include coff/go32exe.h.
+ * coffswap.h (coff_swap_filehdr_in): Invoke
+ COFF_ADJUST_FILEHDR_IN_PRE and COFF_ADJUST_FILEHDR_IN_POST if they
+ are defined.
+ (coff_swap_filehdr_out): Invoke COFF_ADJUST_FILEHDR_OUT_PRE and
+ COFF_ADJUST_FILEHDR_OUT_POST if they are defined.
+ (coff_swap_aux_in): Invoke COFF_ADJUST_AUX_IN_PRE and
+ COFF_ADJUST_AUX_IN_POST if they are defined.
+ (coff_swap_aux_out): Invoke COFF_ADJUST_AUX_OUT_PRE and
+ COFF_ADJUST_AUX_OUT_POST if they are defined.
+ (coff_swap_scnhdr_in): Invoke COFF_ADJUST_SCNHDR_IN_PRE and
+ COFF_ADJUST_SCNHDR_IN_POST if they are defined.
+ (coff_swap_scnhdr_out): Invoke COFF_ADJUST_SCNHDR_OUT_PRE and
+ COFF_ADJUST_SCNHDR_OUT_POST if they are defined.
+ * targets.c (go32stubbedcoff_vec): Declare.
+ (bfd_target_vector): Add go32stubbedcoff_vec.
+ * configure.in (go32coff_vec): New target vector.
+ (go32stubbedcoff_vec): Likewise.
+ * config.bfd (i[3456]86-*-msdosdjgpp*): New target.
+ (i[3456]86-*-go32*): Change to be like new msdosdjgpp*.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add coff-stubgo32.o.
+ (BFD32_BACKENDS_CFILES): Add coff-stubgo32.c.
+ (HFILES): Add go32stub.h.
+
+Tue Jul 22 15:09:12 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Check for fdopen.
+ * configure, config.in: Rebuild.
+ * opncls.c (bfd_fdopenr): Check HAVE_FDOPEN rather than VMS or
+ __GO32__. Reindent a bit.
+
+Sun Jul 20 20:05:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_create_dynamic_sections): Set SEC_LINKER_CREATED
+ flag for newly created sections.
+ (sunos_add_dynamic_symbols): Don't discard newly created sections
+ if shared library is dynobj.
+
+Mon Jul 14 15:33:55 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (map_sections_to_segments): When checking whether
+ including a section in a segment would force us to skip a page,
+ align the address of the next segment to avoid wraparound
+ problems.
+
+Tue Jul 8 12:11:29 1997 Fred Fish <fnf@cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): Initialize
+ target id field to TIC80_TARGET_ID.
+ * coffswap.h (coff_swap_filehdr_out): Swap out target id field
+ if used.
+ (coff_swap_filehdr_in): Swap in target id field if used.
+
+Mon Jul 7 16:41:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i386.c (coff_i386_is_local_label_name): New static function
+ if TARGET_UNDERSCORE.
+ (coff_bfd_is_local_label_name): Define if TARGET_UNDERSCORE.
+ (i386coff_vec): Add SEC_CODE and SEC_DATA to section_flags.
+
+Mon Jun 30 14:29:26 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-m68k.c (howto_table): Use complain_overflow_bitfield, not
+ complain_overflow_signed, for 32 bit PC relative relocations.
+
+Thu Jun 26 01:26:31 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): When a version
+ indirection symbol is overridden, make the original symbol point
+ at the real overriding symbol.
+
+ * elf.c (bfd_elf_string_from_elf_section): Check for an invalid
+ string index.
+
+ * elflink.h (elf_link_output_extsym): Use the right section for a
+ common symbol.
+ * elf32-mips.c (mips_elf_link_output_symbol_hook): If a common
+ symbol was in .scommon, mark it as SHN_MIPS_SCOMMON.
+
+Wed Jun 25 12:43:10 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * elflink.h (elf_merge_symbols): Resolve indirect and warning
+ symbols before checking for new symbols.
+
+ * elfcore.h (elf_corefile_note): Move out of HAVE_SYS_PROCFS_H.
+
+Tue Jun 24 11:20:43 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffgen.c (coff_object_p): Read the f_opthdr bytes from the
+ file, not aoutsz bytes (they are different in XCOFF .o files).
+
+ * xcofflink.c (xcoff_link_add_symbols): Permit symbols to be
+ redefined by objects included from archives.
+
+Mon Jun 23 18:03:27 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_merge_symbol): In the case of a new defined
+ symbol overriding an old defined symbol, return the hash table
+ entry which we modify, even if it is the target of an
+ indirection.
+ (elf_link_add_object_symbols): If the real name of the symbol gets
+ overridden, convert the versioned symbol into an indirect symbol
+ to the real symbol.
+
+ * elflink.h (elf_merge_symbol): New static function, broken out of
+ elf_link_add_object_symbols.
+ (elf_link_add_object_symbols): Call it.
+
+Sun Jun 22 19:40:57 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i386.c (i3coff_object_p): If COFF_IMAGE_WITH_PE, hack to
+ handle case where COFF filehdr does not immediately follow PE
+ header.
+ * coffgen.c (coff_object_p): Remove useless seek to current
+ location.
+
+Wed Jun 18 19:03:38 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * linker.c (link_action): Change COMMON_ROW/indr to from CREF to
+ REFC.
+
+Tue Jun 17 11:55:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_link_input_bfd): If stripping debugging
+ symbols, skip N_ABS symbols with debugging storage classes.
+
+Mon Jun 16 18:56:27 1997 Geoff Keating <geoffk@ozemail.com.au>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Don't emit R_PPC_REL*
+ relocs in shared libraries which refer to local symbols. Cope
+ with addend when processing a GOT relocation.
+
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Only create symbols
+ for sections that the linker didn't create.
+ (ppc_elf_finish_dynamic_sections): Only try to write out a section
+ symbol if it was created in ppc_elf_size_dynamic_sections.
+ (ppc_elf_relocate_section): Complain if we have to generate a reloc
+ relative to a section for which we didn't output a symbol.
+
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Clean up. PLT
+ relocs are 'rela' relocs, like everything else. .rela.plt is not
+ a read-only section, so we don't have to special-case it.
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Entries in the
+ .rela.bss section are (of course) 'rela' relocs not 'rel' relocs.
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Initialise srelgot.
+ (ppc_elf_relocate_section): @got offsets are 4 from start of the
+ actual .got section.
+ * elflink.c (_bfd_elf_create_got_section): The three reserved
+ words start from the symbol '_GLOBAL_OFFSET_TABLE_'.
+
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): '.rela' is 5
+ characters, not 4.
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Use
+ _bfd_elf_create_got_section to create the GOT rather than
+ ppc_elf_create_linker_section. Create the '.rela.got' section
+ ourselves.
+ (ppc_elf_finish_dynamic_symbol): Set up GOT relocations when a
+ symbol has a GOT entry.
+ (ppc_elf_relocate_section): Record when a symbol is used through
+ the GOT, and allocate space in the GOT for each such symbol.
+ (ppc_elf_adjust_dynamic_symbol): Delete unused .got.plt stuff.
+ (ppc_elf_create_linker_section): Delete unused LINKER_SECTION_GOT
+ stuff.
+
+ * elf32-ppc.c (ppc_elf_howto_raw): GOT16_HA relocs should be
+ treated in a similar way to ADDR16_HA relocs.
+ (ppc_elf_relocate_section): PLTREL24 relocs do not get copied into
+ shared objects; the linker must deal with them.
+ (ppc_elf_create_linker_section): Stop setting
+ _GLOBAL_OFFSET_TABLE_ to the wrong value; delete unused
+ LINKER_SECTION_PLT stuff.
+ (ppc_elf_check_relocs): Delete unused LINKER_SECTION_PLT stuff.
+ (ppc_elf_finish_dynamic_sections): Use BFD calls to get GOT
+ section, not ELF-specific calls.
+ (elf_backend_plt_not_loaded): Set to 1.
+ (elf_backend_got_symbol_offset): Set to 4.
+ * elf-bfd.h (elf_backend_data): Add 'plt_not_loaded' member
+ for when ld.so fills in the PLT; and 'got_symbol_offset' member.
+ * elflink.c (_bfd_elf_create_dynamic_sections): Apply
+ plt_not_loaded member.
+ (_bfd_elf_create_got_section): Apply got_symbol_offset.
+ * elfxx-target.h (elf_backend_plt_not_loaded): Set default to
+ 'loaded'.
+ (elf_backend_G_O_T_offset): Set default to 0.
+ (elfNN_bed): Set added fields.
+
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Was setting
+ DT_RELENT in shared objects; should be DT_RELAENT.
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Propagate
+ R_PPC_ADDR16_HA relocs to shared objects. Cope with case where
+ such a reloc (in a non-shared object) refers to a symbol that's
+ not defined.
+
+Mon Jun 16 14:42:14 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * elfcode.h (put_signed_word): Define.
+ (get_signed_word): Define.
+ (elf_swap_reloca_in): Use get_signed_word for the r_addend field.
+ (elf_swap_reloca_out): Use put_signed_word for the r_addend
+ field.
+ * elf32-m68k.c (elf_m68k_finish_dynamic_symbol): Use
+ bfd_get_signed_32 to set the r_addend field.
+ * elf64-mips.c (mips_elf64_swap_reloca_in): Use
+ bfd_h_get_signed_64 to set the r_addend field.
+
+Mon Jun 16 12:31:29 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): When generating a
+ shared library, do the relocation if the input section is not
+ allocated in memory.
+
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Call
+ elf_link_assign_sym_version before elf_adjust_dynamic_symbol.
+ (elf_fix_symbol_flags): New static function, broken out of
+ elf_adjust_dynamic_symbol.
+ (elf_adjust_dynamic_symbol): Call elf_fix_symbol_flags.
+ (elf_link_assign_sym_version): Likewise. Permit a symbol to be
+ forced local even if NEEDS_PLT is set. When forcing a symbol to
+ be local, clear NEEDS_PLT.
+ (elf_link_output_extsym): Remove unused local bed.
+
+Wed Jun 11 22:44:20 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (elf32_mn10300_link_hash_entry): New structure
+ for derived elf linker hash table entries. References to
+ elf_link_hash_entry changed appropriately.
+ (elf32_mn10300_link_hash_table): New structure for derived elf
+ linker hash table.
+ (elf32_mn10300_hash_table): Define.
+ (elf32_mn10300_link_hash_traverse): Likewise.
+ (elf32_mn10300_link_hash_newfunc): New function.
+ (elf32_mn10300_link_hash_table_create): Likewise.
+ (elf32_mn10300_finish_hash_table_entry): Likewise.
+ (mn10300_elf_relax_section): Handle "call" -> "calls", removal
+ of prologue code, and call:32->call:16 relaxing.
+ (compute_function_info: New function.
+ (bfd_elf32_bfd_ilink_hash_table_create): Define.
+
+Wed Jun 11 00:00:07 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_output_extsym): Call finish_dynamic_symbol
+ for a symbol which is being forced to be local.
+ * elf32-i386.c (elf_i386_relocate_section): Write out the
+ relocation value for a GOT reloc for a symbol which is turning
+ into a local symbol.
+ (elf_i386_finish_dynamic_symbol): If a symbol is turning into a
+ local symbol, write out a RELATIVE reloc rather than a GLOB_DAT
+ reloc.
+ * elf32-m68k.c, elf32-sparc.c: Corresponding changes.
+
+ * elf32-i386.c (elf_i386_relocate_section): Get the relocation
+ value if the symbol is turning into a local symbol.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+1997-06-10 22:58 Ulrich Drepper <drepper@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Also read verneed
+ information by calling `_bfd_elf_slurp_version_tables'.
+ (elf_link_add_object_symbols): For undefined symbols look for
+ version information in the verneed records.
+ (elf_link_add_object_symbols): Use soname of shared object
+ for verneed record if it is available.
+
+Tue Jun 10 11:13:03 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * cpu-arm.c: Add prototypes for compatible and scan.
+ * cofflink.c: Add prototype for mark_relocs.
+
+ * archive.c (bfd_special_undocumented_glue): Change filename to
+ const pointer. Add prototype.
+
+Mon Jun 9 12:34:21 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elflink.h (elf_link_add_object_symbols): Ignore relocations of
+ sections that will be discarded.
+
+1997-06-06 22:58 Ulrich Drepper <drepper@cygnus.com>
+
+ * elflink.h (elf_link_find_version_dependencies): When searching
+ for known version symbol skip non-matching verdef records, not
+ matching records.
+
+Thu Jun 5 15:52:45 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Write a long,
+ not a bfd_vma, to the base file, to match how dlltool reads it.
+
+Tue Jun 3 16:57:45 1997 Nick Clifton <nickc@cygnus.com>
+
+ * reloc.c: Add thumb relocations.
+
+ * bfd-in2.h: Add Thumb relocations.
+
+ * libbfd.h: Add Thumb relocations.
+
+Mon Jun 2 10:41:52 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * cpu-m68k.c (arch_info_struct): Fix 68060 cpu name.
+
+Fri May 30 12:46:27 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Set dynindx
+ for a section even if it is not loaded.
+
+ * cofflink.c (coff_link_add_symbols): If PE file, don't subtract
+ section VMA.
+ (_bfd_coff_link_input_bfd): Separate section VMA handling for
+ input and output files.
+ (_bfd_coff_generic_relocate_section): Check whether input file,
+ not output file, is a PE file.
+
+Wed May 28 15:48:43 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c: (coff_arm_bfd_set_private_flags): Make static.
+
+Wed May 28 16:16:04 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-i386.c (coff_i386_reloc): Don't just exit if we see an
+ R_IMAGEBASE reloc.
+
+Wed May 28 09:48:43 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-arm.c (compatible): Add test for supersets of ARM
+ architectures.
+
+Tue May 27 19:42:03 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * cofflink.c (_bfd_coff_final_link): Initialize global_to_static
+ member.
+
+Tue May 27 14:34:08 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (coff_arm_bfd_set_private_flags): Make global. It is
+ called directly by gas/config/tc-arm.c.
+
+Tue May 27 15:58:53 1997 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (PLT_ENTRY_*): Use a new thread-safe format.
+ (elf64_alpha_finish_dynamic_symbol): Fill it in properly.
+
+Mon May 26 14:05:13 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-ppc.c (coff_ppc_relocate_section): If PE file, don't add
+ section VMA.
+
+Mon May 26 10:57:48 1997 Fred Fish <fnf@cygnus.com>
+
+ * peicode.h (coff_bfd_print_private_bfd_data): #undef before #define.
+ (coff_bfd_copy_private_bfd_data): Ditto.
+ * coff-arm.c (coff_arm_bfd_merge_private_bfd_data): Make static.
+ (coff_arm_bfd_print_private_bfd_data): Ditto.
+ (coff_arm_bfd_set_private_flags): Ditto.
+ (coff_arm_bfd_copy_private_bfd_data): Ditto.
+
+Fri May 23 15:14:58 1997 Fred Fish <fnf@cygnus.com>
+
+ * libcoff-in.h (struct coff_final_link_info): Add boolean
+ global_to_static member for support of task linking.
+ (_bfd_coff_write_task_globals): Add prototype.
+ * libcoff.h: Regenerate.
+ * coffcode.h (coff_write_object_contents): Use #ifdef to
+ check RS6000COFF_C, to be consistent with all other uses
+ in this file.
+ * cofflink.c (_bfd_coff_final_link): If doing task linking,
+ call _bfd_coff_write_task_globals.
+ (_bfd_coff_link_input_bfd): If doing task linking, convert
+ global functions to static.
+ (_bfd_coff_write_global_sym): If doing task linking, convert
+ global variables to static.
+ (_bfd_coff_write_task_globals): New function.
+ * coff-tic80.c (TIC80COFF): Define this instead of just TIC80.
+ (C_AUTOARG): #undef since it clashes with C_UEXT.
+ (C_LASTENT): #undef since it clashes with C_STATLAB.
+ * coffcode.h (coff_write_object_contents): Use TIC80COFF
+ rather than TIC80.
+ (coff_slurp_symbol_table): Use C_SYSTEM. Hide C_AUTOARG use
+ when TIC80COFF defined (clashes with C_UEXT). Explicitly
+ recognize C_UEXT, C_STATLAB, and C_EXTLAB as unsupported.
+
+Fri May 23 12:38:24 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-tic80.c (tic80_howto_table): Change overflow check for most
+ PP relocations to complain_overflow_dont.
+
+Thu May 22 20:22:14 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-tic80.c (tic80_howto_table): Add PP relocations. Change
+ name of R_RELLONG to "RELLONG". Set rightshift and complain for
+ M_PPCR.
+ (ppbase_reloc, glob15_reloc): New static functions.
+ (glob16_reloc, local16_reloc): New static functions.
+ (rtype2howto): Handle all relocation types.
+ (coff_tic80_relocate_section): New static function.
+ (coff_relocate_section): Define to coff_tic80_relocate_section.
+ * Makefile.in (coff-tic80.o): Depends upon include/coff/tic80.h.
+
+Wed May 21 17:15:50 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_slurp_symbol_table): If COFF_WITH_PE or
+ COFF_IMAGE_WITH_PE, don't subtract the section VMA from the symbol
+ value.
+ * coffgen.c (fixup_symbol_value): Add abfd parameter. Change all
+ callers. If PE file, don't add section VMA.
+ (coff_write_alien_symbol): If PE file, don't add section VMA.
+ * cofflink.c (_bfd_coff_link_input_bfd): Likewise.
+ (_bfd_coff_write_global_sym): Likewise.
+ (_bfd_coff_generic_relocate_section): Likewise.
+
+ * peicode.h: Add & 0xffffffff when using ImageBase in case bfd_vma
+ is 64 bits.
+
+Wed May 21 09:58:10 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cofflink.c (mark_relocs): Add new function to mark symbols which
+ are used by relocations.
+ (_bfd_coff_link_input_bfd): Add call to mark_relocs() and code to
+ suppress the skipping of symbols that have thus been marked.
+
+Tue May 20 18:45:26 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (sh_merge_private_data): New static function.
+ (coff_bfd_merge_private_bfd_data): Define.
+
+Mon May 19 14:46:00 1997 Mark Alexander <marka@cygnus.com>
+
+ * coff-tic80.c: Remove unnecessary #ifdefs.
+ * config.bfd: Set targ_underscore to yes for tic80.
+
+Mon May 19 14:26:36 1997 Mark Alexander <marka@cygnus.com>
+
+ * coff-tic80.c (NAMES_HAVE_UNDERSCORE): Define (fixes problem
+ with unresolved external symbols in GDB).
+
+Fri May 16 10:23:03 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf-m10300.c (elf32_mn10300_relax_section): Read in all
+ the symbols associated with each BFD.
+ (mn10300_elf_relax_delete_bytes): Don't adjust the same symbol
+ more than once.
+ * elf-m10200.c: Likewise.
+ * elf32-m32r.c: Likewise.
+ * elf32-sh.c: Likewise.
+
+Fri May 16 12:10:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Don't decrease the
+ alignment of a common symbol. If two symbols that look like
+ common symbols are found in two shared libraries, and the size is
+ different, use the larger size, and warn if --warn-common. If a
+ common symbol overrides a definition in a shared library, set the
+ size to the larger size, and warn if --warn-common.
+
+Thu May 15 14:31:28 1997 Nick Clifton <nickc@cygnus.com>
+
+ * cpu-arm.c (compatible): Allow default machine to be polymorphed
+ into any other machine type.
+
+ * coffcode.h (coff_set_flags): Initialise flags variable to 0.
+
+ * coff-arm.c (coff_arm_bfd_merge_private_bfd_data): When merging
+ data into an unitialised destination set its machine type as well.
+
+Thu May 15 16:40:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Force ELF symbol size
+ to common symbol size. Consistently treat uninitialized symbols
+ in shared objects as common symbols.
+
+Fri May 9 10:15:27 1997 Nick Clifton <nickc@cygnus.com>
+
+ * archures.c (constants): Added new constants to identify the
+ type of the ARM architecture: bfd_mach_arm_2, bfd_mach_arm_2a,
+ bfd_mach_arm_3, bfd_mach_arm_3M, bfd_mach_arm_4 and bfd_mach_arm_4T.
+
+ * bfd-in2.h (constants): Added new constants to identify
+ the type of the ARM architecture: bfd_mach_arm_2, bfd_mach_arm_2a,
+ bfd_mach_arm_3, bfd_mach_arm_3M, bfd_mach_arm_4 and
+ bfd_mach_arm_4T. This file is auto-magically generated from the
+ archures.c file. This update is just to save work.
+
+ * coff-arm.c (coff_arm_bfd_merge_private_bfd_data,
+ coff_arm_bfd_print_private_bfd_data,
+ coff_arm_bfd_set_private_flags,
+ coff_arm_bfd_copy_private_bfd_data): Added these new functions.
+ (global): Macro redefinitions set up to use these new functions.
+
+ * coffcode.h (coff_mkobject_hook): Added call to
+ coff_arm_bfd_set_private_flags().
+ (coff_set_arch_mach_hook): Added code to set machine type based on
+ bits stored in internal flags.
+ (coff_set_flags): Added code to set the new bits in the flags
+ field based on the machine number.
+ (function definition macros): Made all function definition macros
+ conditional so that they can be overridden by target specific
+ files.
+
+ * cpu-arm.c (compatible): Added this function. (arch_info_struct):
+ Structure extended to include new types, one each for ARMv2,
+ ARMv2a, ARMv3, ARMv3M, ARMv4 and ARMv4T.
+
+ * libcoff-in.h (struct coff_tdata): Added flags field.
+
+Fri May 9 17:40:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.bfd (i[3456]86-*-gnu*): Don't include Mach support.
+
+ * config.bfd: Change #if 0 around uses of host_aout_vec to #if
+ HAVE_host_aout_vec.
+
+Mon May 5 13:57:32 1997 Mike Meissner <meissner@cygnus.com>
+
+ * coffgen.c (coff_find_nearest_line): If there are no syments,
+ just return false.
+
+Mon May 5 18:18:45 1997 Philip Blundell <pjb27@cam.ac.uk>
+
+ * config.bfd: cope with '*-*-linux-gnuaout' targets.
+
+Thu May 1 11:31:12 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * targmatch.sed: Add explicit \n characters to work around bug in
+ HP/UX 10.20 sed program.
+
+Wed Apr 30 12:27:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (copy_private_bfd_data): Cast csecs to avoid sign
+ extension problems.
+
+Tue Apr 22 12:06:08 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (do_maintainer_clean): Don't remove bfd-in2.h.
+
+Mon Apr 21 11:21:31 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c: Follow the last changes in elf32-i386.c:
+ (struct elf_m68k_pcrel_relocs_copied, struct
+ elf_m68k_link_hash_entry, struct elf_m68k_link_hash_table,
+ elf_m68k_link_hash_traverse, elf_m68k_hash_table,
+ elf_m68k_link_hash_newfunc, elf_m68k_link_hash_table_create,
+ elf_m68k_discard_copies, bfd_elf32_bfd_link_hash_table_create):
+ New definitions.
+ (elf_m68k_check_relocs): If linking with -Bsymbolic, don't copy
+ PC relative relocs for a global symbol defined in a regular
+ object, and count the number of PC relative relocs copied for any
+ global symbol.
+ (elf_m68k_size_dynamic_sections): If linking with -Bsymbolic,
+ traverse with elf_m68k_discard_copies.
+
+Sat Apr 19 22:50:14 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_check_relocs): Only count PC relative
+ relocs. From Jamie Lokier <jamie@rebellion.co.uk>.
+
+ * coffcode.h (coff_compute_section_file_positions): Force the
+ potential last byte in the file to be written out when
+ COFF_IMAGE_WITH_PE.
+
+Thu Apr 17 13:46:56 1997 Per Fogelstrom <pefo@openbsd.org>
+
+ * configure.host (mips*-*-openbsd*): New host.
+
+Thu Apr 17 11:10:54 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Only subtract the
+ section VMA from the symbol value if this is a fully linked file.
+
+ * elf32-i386.c (struct elf_i386_pcrel_relocs_copied): Define.
+ (struct elf_i386_link_hash_entry): Define.
+ (struct elf_i386_link_hash_table): Define.
+ (elf_i386_link_hash_traverse): Define.
+ (elf_i386_hash_table): Define.
+ (elf_i386_link_hash_newfunc): New static function.
+ (elf_i386_link_hash_table_create): New static function.
+ (elf_i386_check_relocs): If linking with -Bsymbolic, don't copy
+ PC relative relocs for a global symbol defined in a regular
+ object, and count the number of PC relative relocs copied for any
+ global symbol.
+ (elf_i386_size_dynamic_sections): If linking with -Bsymbolic,
+ traverse with elf_i386_discard_copies.
+ (elf_i386_discard_copies): New static function.
+ (bfd_elf32_bfd_link_hash_table_create): Define.
+
+ From Gordon W. Ross <gwr@mc.com>:
+ * aoutf1.h (MY_entry_is_text_address): Define if not defined.
+ (sunos4_aout_backend): Use MY_entry_is_text_address.
+
+Wed Apr 16 12:43:32 1997 Martin Hunt <hunt@cygnus.com>
+
+ * elf32-d30v.c (elf_d30v_howto_table): Changed size of
+ R_D30V_32_NORMAL to 2 (4 bytes).
+
+Wed Apr 16 14:02:29 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Gordon W. Ross <gwr@mc.com>:
+ * netbsd.h (N_SHARED_LIB): Define.
+ (SEGMENT_SIZE): Don't define.
+ * m68knetbsd.c (SEGMENT_SIZE): Don't define (revert change of
+ April 11).
+ * sparcnetbsd.c (TARGET_PAGE_SIZE): Define as 0x2000.
+ (SEGMENT_SIZE): Don't define.
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Set .rela.bss size
+ to sizeof Rela structure, not sizeof Rel structure. From Gary
+ Thomas <g.thomas@opengroup.org>.
+
+Tue Apr 15 11:50:37 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aout-target.h (MY(callback)): If entry_is_text_address, adjust
+ whenever entry is larger than text address, but only by whole
+ pages. From Gordon W. Ross <gwr@mc.com>.
+
+ * Makefile.in (install): Depend upon installdirs. Use
+ mkinstalldirs to build $(oldincludedir).
+ (installdirs): New target.
+
+ * elflink.h (elf_link_add_object_symbols): Don't call check_relocs
+ if this is a debugging section which we are stripping.
+
+Mon Apr 14 12:39:30 1997 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (elf64_alpha_object_p): Allocate the
+ alpha-specific target data struct.
+
+Mon Apr 14 11:45:46 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Thomas Graichen <graichen@rzpd.de>:
+ * Makefile.in: Always use $(SHELL) when running move-if-change.
+ * configure.in: Use ${CONFIG_SHELL} when running $ac_config_sub.
+ * configure: Rebuild.
+
+Fri Apr 11 15:43:24 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_slurp_symbol_table): Only subtract the section
+ VMA if this is an executable file or a shared object.
+
+ * targets.c (netbsd_core_vec): Declare. From Gordon W. Ross
+ <gwr@mc.com>.
+
+ * libaout.h (struct aout_backend_data): Add entry_is_text_address
+ field.
+ * aout-target.h (SEGMENT_SIZE): Define to TARGET_PAGE_SIZE at the
+ start of the file. Remove uses later on which switch using
+ ifdef.
+ (MY(callback)): Handle entry_is_text_address.
+ (MY_entry_is_text_address): Define if not defined.
+ (MY(backend_data)): Initialize new field.
+ * aoutf1.h (sunos4_aout_backend): Likewise.
+ * i386aout.c (MY(backend_data)): Likewise.
+ * i386mach3.c (MY(backend_data)): Likewise.
+ * mipsbsd.c (MY(backend_data)): Likewise.
+ * sparclynx.c (sparclynx_aout_backend): Likewise.
+ * netbsd.h (SEGMENT_SIZE): Define if not defined.
+ (MY_entry_is_text_address): Define.
+ * m68knetbsd.c (SEGMENT_SIZE): Define as 0x20000.
+
+ * xcofflink.c (bfd_xcoff_import_symbol): Handle importing a symbol
+ whose name starts with `.'.
+
+Fri Apr 11 11:57:15 1997 Niklas Hallqvist <niklas@appli.se>
+
+ * config.bfd: (i[3456]86-*-openbsd*, m68*-*-openbsd*,
+ mips*el*-*-openbsd*, mips*-*-openbsd*, ns32k-*-openbsd*,
+ powerpc-*-*bsd*, sparc-*-openbsd*): New targets.
+ * configure.in (i[3456]86-*-openbsd*, mips*-*-openbsd*,
+ m68*-*-openbsd*, ns32k-*-openbsd*, powerpc-*-*bsd*,
+ sparc-*-openbsd*): New targets.
+ * configure: Rebuild.
+
+Tue Apr 8 18:09:29 1997 Jamie Lokier <jamie@rebellion.co.uk>
+
+ * stabs.c (struct stab_section_info): New field
+ `cumulative_skips'.
+ (_bfd_link_section_stabs): Fill the above array.
+ (_bfd_stab_section_offset): Use `cumulative_skips' to
+ speed up offset calculation.
+
+Tue Apr 8 00:01:31 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf-mn10300.c (mn10300_elf_relax_section): Don't forget the
+ addend for non pc-relative relocations.
+
+ * elf-m10300.c (bfd_elf32_mn10300_reloc): Remove prototype
+ for non-existent function.
+
+ * elf-m10300.c (mn10300_elf_relax_section): New function.
+ (mn10300_elf_relax_delete_bytes): Likewise.
+ (mn10300_elf_symbol_address_p): Likewise.
+ (mn10300_elf_get_relocated_section_contents): Likewise.
+ (bfd_elf32_bfd_relax_section): Define.
+ (bfd_elf32_bfd_get_relocated_section_contents): Likewise.
+
+Mon Apr 7 16:47:09 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Set SHLIB_LIBS.
+ * configure.in: Substitute SHLIB_LIBS.
+ * configure: Rebuild.
+ * Makefile.in (SHLIB_LIBS): New variable.
+ ($(SHLIB)): Use $(SHLIB_LIBS).
+
+Mon Apr 7 10:53:52 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * bfd-in.h bfd-in2.h: add bfd_section_lma macro to correspond
+ with bfd_section_vma.
+
+Fri Apr 4 11:37:15 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Update file names for bfd_elf32_mn10[23]00_vec.
+ Correct CPU file names for mn10[23]00.
+ * configure: Rebuild.
+
+ * bfd.c (bfd_record_phdr): Cast count to size_t before
+ subtraction.
+
+ * coff-ppc.c (dump_toc): Add cast to avoid warning from SunOS cc.
+ * coff-rs6000.c (xcoff_read_ar_hdr): Likewise.
+ (xcoff_write_archive_contents): LIkewise.
+ * elf32-mips.c (_bfd_mips_elf_set_section_contents): Likewise.
+ (mips_elf_create_procedure_table): Likewise.
+ * peicode.h (pe_print_idata): Likewise.
+ (pe_print_edata, pe_print_pdata, pe_print_reloc): Likewise.
+ * xcofflink.c (xcoff_get_section_contents): Likewise.
+ (_bfd_xcoff_canonicalize_dynamic_symtab): Likewise.
+ (xcoff_link_add_symbols): Likewise.
+ (xcoff_link_add_symbols): Likewise.
+
+ * ppcboot.c (ppcboot_set_arch_mach): Make static.
+ (ppcboot_bfd_print_private_bfd_data): Likewise.
+
+ * elf32-mips.c (elf_mips_ctor64_howto): Set complain_on_overflow
+ to complain_overflow_signed.
+
+Thu Apr 3 11:51:54 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * VERSION: Set to 2.8.1.
+
+ * Branched binutils 2.8.
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Don't check SEC_ALLOC when
+ deciding whether to copy a reloc into a shared object.
+ (ppc_elf_relocate_section): Likewise. Relocate R_PPC_RELATIVE
+ relocs in unallocated sections.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Relocate
+ R_SPARC_RELATIVE relocs in unallocated sections.
+
+Wed Apr 2 16:19:41 1997 Mike Meissner <meissner@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Undo March 26 change and
+ always create got section so that the _GLOBAL_OFFSET_TABLE_ label
+ is always created.
+
+Wed Apr 2 10:49:07 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Let a common symbol
+ override an uninitialized symbol from a shared library with a
+ smaller size.
+
+ * elf-m10200.c: Rename from elf32-mn10200.c.
+ * elf-m10300.c: Rename from elf32-mn10300.c.
+ * cpu-m10200.c: Rename from cpu-mn10200.c
+ * cpu-m10300.c: Rename from cpu-mn10300.c
+ * Makefile.in: Update accordingly.
+
+ * elf32-mips.c (elf_mips_ctor64_howto): New static variable.
+ (elf_mips_isa): Move to earlier in file.
+ (mips_reloc_map): Remove BFD_RELOC_CTOR entry.
+ (bfd_elf32_bfd_reloc_type_lookup): Handle BFD_RELOC_CTOR
+ specially.
+
+ * elf32-mips.c (mips16_jump_reloc): Print a warning rather than
+ calling abort.
+
+Tue Apr 1 16:18:05 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * configure.com: New file.
+ * config.h-vms: Remove file.
+ * makefile.vms: Update for new configure scheme.
+
+Mon Mar 31 23:28:39 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * libcoff-in.h (ppc_allocate_toc_section): Declare.
+ (ppc_process_before_allocation): Declare.
+ * libcoff.h: Rebuild.
+
+ * coffcode.h (coff_mkobject_hook): Declare if not a macro.
+
+Mon Mar 31 16:29:50 1997 Joel Sherrill <joel@oarcorp.com>
+
+ * config.bfd (hppa*-*-rtems*): New target, like hppa-*-*elf*.
+
+Mon Mar 31 16:11:35 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-a29k.c (coff_a29k_relocate_section): Don't use symndx as a
+ symbol index for a R_IHCONST reloc.
+
+Mon Mar 31 15:40:59 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * targmatch.sed: Do not use \(\) recursively.
+
+Fri Mar 28 14:44:08 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * m68klinux.c (MACHTYPE_OK): Define.
+ * i386linux.c (MACHTYPE_OK): Define.
+
+Fri Mar 28 11:56:15 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From David S. Miller <davem@caip.rutgers.edu> and H.J. Lu
+ <hjl@gnu.ai.mit.edu>:
+ * sparclinux.c: New file.
+ * bfd-in.h (bfd_sparclinux_size_dynamic_sections): Declare.
+ * bfd-in2.h: Rebuild.
+ * config.bfd (sparc-*-linuxaout*, sparc-*-linux*): New targets.
+ * configure.in (sparclinux_vec): Add to list of vectors.
+ * configure: Rebuild.
+ * targets.c (sparclinux_vec): Declare.
+ (bfd_target_vector): Add sparclinux_vec.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add sparclinux.o.
+ (BFD32_BACKENDS_CFILES): Add sparclinux.c.
+
+ * coff-mips.c (mips_ecoff_backend_data): Initialize new
+ bfd_coff_backend_data field.
+ * coff-alpha.c (alpha_ecoff_backend_data): Likewise.
+
+ * config.bfd: Add bfd_elf64_{big,little}mips_vec to targ_selvecs
+ for mips*el*-*-linux* and mips*-*-linux*. From H.J. Lu
+ <hjl@lucon.org> and Ralf Baechle <ralf@gnu.ai.mit.edu>.
+
+ * bfd.c: Include "libiberty.h".
+ (strerror): Don't declare.
+ (bfd_errmsg): Call xstrerror rather than strerror.
+
+Thu Mar 27 12:55:42 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Generate a COPY
+ reloc even if the symbol is in the .bss section.
+ * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
+
+ * coffcode.h (bfd_coff_backend_data): Add new field
+ _bfd_coff_default_section_alignment_power.
+ (bfd_coff_default_section_alignment_power): Define.
+ (bfd_coff_std_swap_table): Initialize new field.
+ * libcoff.h: Rebuild.
+ * cofflink.c (coff_link_add_symbols): Limit alignment of a common
+ symbol to the default section alignment.
+
+ * COPYING: Update FSF address.
+
+Thu Mar 27 00:45:57 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * elf32-d30v.c (elf_d30v_howto_table): Fix a typo in the
+ 21-bit absolute that made it act as a relative.
+
+Wed Mar 26 14:50:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.c (_bfd_elf_create_linker_section): Don't set
+ bss_section and rel_section from existing sections.
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Only create the got section
+ if it is needed.
+
+Tue Mar 25 22:26:56 1997 Stu Grossman (grossman@critters.cygnus.com)
+
+ * aoutx.h (some_aout_object_p): Change executable test to fix
+ problems with embedded a.out systems.
+
+Tue Mar 25 14:35:37 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * stabs.c (_bfd_stab_section_offset): New function.
+ * libbfd-in.h (_bfd_stab_section_offset): Declare.
+ * libbfd.h: Rebuild.
+ * elf32-i386.c (elf_i386_relocate_section): Adjust the offset of a
+ stab reloc.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+ * elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+
+ * stabs.c (_bfd_link_section_stabs): Copy over the first header
+ symbol. Check for memory allocation failure of *psinfo.
+ (_bfd_write_section_stabs): Add psinfo parameter. Change all
+ callers. Set the value of the header symbol.
+ * libbfd-in.h (_bfd_write_section_stabs): Update declaration.
+ * libbfd.h: Rebuild.
+
+Mon Mar 24 20:07:29 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (tic80_howto_table): Add R_ABS entry.
+ (rtype2howto): Handle R_ABS reloc type. Also abort on unhandled
+ reloc types, rather than silently failing to generate an output file.
+
+Mon Mar 24 13:41:00 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * targmatch.sed: Use the hold space to put the #ifdef around the
+ the string constant.
+ * targets.c (UNSUPPORTED_TARGET): Don't define.
+ (find_target): Don't check for UNSUPPORTED_TARGET.
+ (bfd_set_default_target): Don't try to optimize by checking for
+ default.
+
+ * Makefile.in: Rebuild dependencies.
+ (ALL_MACHINES_CFILES): Add cpu-m32r.c.
+ (BFD32_BACKENDS_CFILES): Add elf32-m32r.c.
+ (elf32-m32r.o): Remove explicit target.
+
+ * config.bfd: Don't set targ_underscore for i[3456]86-*-gnu* or
+ i[3456]86-*-linux*.
+
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Don't
+ count section symbols for sections that were created by the
+ linker, or are not allocatable or not loadable.
+ (elf32_sparc_finish_dynamic_sections): Output output section
+ symbols for section for which we made space for them.
+
+Fri Mar 21 13:08:26 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): If there is
+ no .rela.plt section, don't output a DT_PLTGOT dynamic entry.
+
+Fri Mar 21 12:36:46 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf32-m32r.c (m32r_elf_howto_table): Use special function for LO16.
+ (m32r_hi16_list): New static local.
+ (m32r_elf_hi16_reloc): Don't perform reloc, just queue it up.
+ (m32r_elf_do_hi16_reloc): Delete.
+ (m32r_elf_relocate_hi16): New function.
+ (m32r_elf_lo16_reloc): New function.
+ (m32r_elf_relocate_section): For HI16 relocs, scan for corresponding
+ LO16 reloc.
+
+ Mon Mar 10 16:03:31 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * elf32-m32r.c (m32r_elf_create_linker_section): Delete.
+ (m32r_elf_add_symbol_hook): Rewrite _SDA_BASE_ support.
+ (m32r_elf_final_sda_base): New function.
+ (m32r_elf_relocate_section): Rewrite sdata support.
+ (m32r_elf_finish_dynamic_sections): Delete.
+
+Thu Mar 20 12:39:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ Based on patches from Philippe De Muyter <phdm@info.ucl.ac.be>.
+ * coff-svm68k.c: New file. Just defines some macros and includes
+ coff-m68k.c.
+ * coff-m68k.c: Add functions to handle common addends, moved in
+ from cf-m68klynx.c. Control them using COFF_COMMON_ADDEND macro.
+ Control whether relocs are visible using STATIC_RELOCS.
+ * cf-m68klynx.c: Simplify greatly: just define macros to control
+ coff-m68k.c.
+ * coff-aux.c: Likewise. Just leave add_one_symbol routine.
+ * targets. (m68ksysvcoff_vec): Declare.
+ (bfd_target_vector): Add m68ksysvcoff_vec.
+ * config.bfd (m68*-motorola-sysv*): New target.
+ * configure.in (m68ksysvcoff_vec): New vector.
+ * configure: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add coff-svm68k.o.
+ (BFD32_BACKENDS_CFILES): Add coff-svm68k.c.
+
+ * binary.c (binary_set_section_contents): Don't get misled if the
+ first section is not loadable. From Matthew L. Martin
+ <mlm@xedia.com>.
+
+ * elflink.h (elf_bfd_final_link): Set the value of a section
+ symbol to the section address unless doing a relocateable link.
+
+Tue Mar 18 23:03:17 1997 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Don't create
+ .plt entry if we've taken the function's address.
+ (elf64_alpha_merge_gots): Merge collected flags info as well.
+
+Tue Mar 18 22:40:09 1997 H.J. Lu <hjl@lucon.org>
+
+ * Many files: Add function prototypes.
+ * cpu-m68k.c (bfd_default_scan_num_mach): Don't declare.
+ * ecofflink.c: Include "libcoff.h" and "libecoff.h".
+ * elf32-ppc.c (ppc_elf_fake_sections): Make static.
+ * opncls.c (bfd_openstreamr): Change stream parameter to PTR.
+ * peicode.h: Change several void * parameters to PTR.
+ * srec.c (srec_get_symbol_info): Make static.
+ * syms.c (bfd_symbol_is_absolute): Remove.
+ * Makefile.in: Rebuild dependencies.
+
+Tue Mar 18 12:58:08 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-m32r.c (m32r_elf_is_local_label_name): Remove.
+ (bfd_elf32_bfd_is_local_label): Don't define.
+
+ * xcofflink.c (_bfd_xcoff_bfd_final_link): Call bfd_malloc rather
+ than malloc.
+
+Mon Mar 17 11:32:53 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd-in.h: Don't include obstack.h.
+ (struct bfd_hash_table): Change memory field to PTR.
+ * bfd.c (struct _bfd): Change memory field to PTR.
+ * bfd-in2.h: Rebuild.
+ * libbfd-in.h (bfd_release): Declare as function, don't define as
+ macro.
+ * libbfd.h: Rebuild.
+ * opncls.c: Include "objalloc.h" rather than "obstack.h". Use
+ objalloc routines rather than obstack routines.
+ (obstack_chunk_alloc, obstack_chunk_free): Don't define.
+ (getpagesize): Don't define.
+ (_bfd_new_bfd): Don't set _bfd_chunksize.
+ (bfd_openr): Free new bfd and objalloc on failure.
+ (bfd_fdopenr, bfd_openstreamr, bfd_openw): Likewise.
+ (bfd_alloc_size): Remove.
+ (bfd_release): New function.
+ * hash.c: Include "objalloc.h" rather than "obstack.h". Use
+ objalloc routines rather than obstack routines.
+ (obstack_chunk_alloc, obstack_chunk_free): Don't define.
+ * ecofflink.c: Include "objalloc.h" rather than "obstack.h". Use
+ objalloc routines rather than obstack routines.
+ (obstack_chunk_alloc, obstack_chunk_free): Don't define.
+ (struct accumulate): Change memory to struct objalloc *.
+ * liboasys.h (oasys_data_type): Remove oasys_obstack field.
+ * dep-in.sed: Don't remove obstack.h from dependency list.
+ * Makefile.in: Rebuild dependencies.
+ (BFD_H_DEPS): Remove obstack.h.
+ (install): Don't install obstack.h.
+ * Many files: Don't include "obstack.h".
+ * VERSION: Bump.
+
+ * opncls.c (bfd_alloc_grow, bfd_alloc_finish): Remove.
+ * libbfd-in.h (bfd_alloc_grow, bfd_alloc_finish): Don't declare.
+ * libbfd.h: Rebuild.
+ * ieee.c (ieee_archive_p): Rewrite to not use bfd_alloc_grow.
+ * sunos.c (sunos_add_dynamic_symbols): Likewise.
+ * srec.c (srec_scan): Rewrite to not use obstack_1grow.
+
+ * opncls.c (bfd_alloc): Rename from bfd_alloc_by_size_t. Remove
+ old version of bfd_alloc.
+ * libbfd-in.h (bfd_alloc_by_size_t): Don't declare.
+ * libbfd.h: Rebuild.
+ * Several files: Call bfd_alloc rather than bfd_alloc_by_size_t.
+
+Sat Mar 15 15:24:18 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_is_local_label_name): Accept the generic
+ ELF local label syntax as well.
+
+Sat Mar 15 10:16:42 1997 Fred Fish <fnf@cygnus.com>
+
+ * config.bfd (powerpc-*-beos*): New target.
+ * configure.in (powerpc-*-beos*): Add case that explicitly
+ does not set COREFILE for now. A future BeOS version is
+ expected to support core files.
+ * configure: Regenerate with autoconf.
+
+Fri Mar 14 16:43:22 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_check_relocs): Give an error if CALL16 is
+ seen with a local symbol, rather than crashing.
+
+ * elfcode.h (elf_slurp_symbol_table): Don't try to read the
+ version symbols if there aren't any.
+
+Thu Mar 13 16:38:30 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (coff_rtype_to_howto): Define
+ (coff_tic80_rtype_to_howto): Clone generic coff version and
+ add code to handle the funky TI "internal relocations".
+
+Thu Mar 13 14:08:53 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Don't warn about type
+ or size changes because of a weak symbol.
+
+ * cisco-core.c (SIGEMT): Define if not defined.
+
+Wed Mar 12 21:36:05 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Use extsymoff when
+ setting ever. Sanity check the version number. Sort out copying
+ flags and other information when adding an indirect symbol.
+ (NAME(bfd_elf,size_dynamic_sections)): Preserve any dynamic
+ symbols added by the backend. Clear the entire contents of the
+ versym section.
+ (elf_export_symbol): Ignore indirect symbols.
+ (elf_link_output_extsym): Accept a section without an owner in an
+ assert.
+ * elfcode.h (elf_slurp_symbol_table): Add a sanity check on the
+ version count. Correct the allocation of x_versymp.
+
+ * elf32-mips.c (mips_elf_add_symbol_hook): Don't set the owner of
+ the magic sections used for SHN_MIPS_TEXT and SHN_MIPS_DATA.
+ Don't return bfd_und_section_ptr when info->shared.
+ (mips_elf_final_link): Set the alignment of .rtproc to 4, not 12.
+ (mips_elf_create_dynamic_sections): Correct type: ^= for &=.
+ (mips_elf_check_relocs): Resolve an indirect symbol in
+ sym_hashes.
+ (mips_elf_finish_dynamic_symbol): Don't change SHN_ABS into
+ SHN_MIPS_TEXT or SHN_MIPS_DATA.
+
+ * elf.c (bfd_elf_print_symbol): Tweak version output slightly.
+
+Tue Mar 11 01:38:36 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Eric Youngdale <eric@andante.jic.com>:
+ * elf-bfd.h (ELF_LINK_FORCED_LOCAL): Define.
+ * elf.c (bfd_elf_print_symbol): Correct errors in last change.
+ * elflink.h (elf_link_add_object_symbols): Handle cases in which a
+ versioned symbol appears in both a regular and a shared object.
+ (elf_link_assign_sym_version): Set ELF_LINK_FORCED_LOCAL when
+ appropriate. Improve error message.
+ (struct elf_outext_info): Rename from elf_finfo_failed. Change
+ all uses. Add localsyms field.
+ (elf_bfd_final_link): When generating a shared library, call
+ elf_link_output_extsym to output all local symbols.
+ (elf_link_output_extsym): Handle symbols which were forced to
+ become local.
+
+Sun Mar 9 23:08:49 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Eric Youngdale <eric@andante.jic.com>:
+ * elf-bfd.h (elf_symbol_type): Add version field.
+ * elfcode.h (elf_slurp_symbol_table): Set version field.
+ * elflink.h (elf_link_add_object_symbols): When creating an
+ indirect symbol for a default version symbol, set DEF_DYNAMIC if
+ appropriate. Set up an indirection from the nondefault version of
+ the symbol as well.
+ (NAME(bfd_elf,size_dynamic_sections)): Call
+ elf_link_assign_sym_version before checking whether there are any
+ versions. Always record the version name as a dynamic symbol.
+ Initialize counters.
+ (elf_link_assign_sym_version): After finding a version, see if a
+ symbol should be forced to local scope. Create a new version
+ definition if appropriate.
+ (elf_link_output_extsym): Correct indirect symbol handling.
+ * elf.c (bfd_elf_print_symbol): Print version information.
+ (bfd_section_from_shdr): Turn version sections into BFD sections.
+ (elf_fake_sections): Only copy cverdefs and cverrefs into sh_info
+ if sh_info is not already set.
+ (_bfd_elf_copy_private_section_data): Copy sh_info for version
+ sections.
+ * elflink.c (_bfd_elf_link_record_dynamic_symbol): Tell
+ _bfd_stringtab_add to copy the name into permanent memory if
+ appropriate.
+
+Fri Mar 7 11:55:31 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Fully parenthesize.
+
+Fri Mar 7 10:37:30 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (bfd_coff_backend_data): Change
+ _bfd_coff_compute_section_file_positions to return a boolean
+ value. Change all callers.
+ (coff_compute_section_file_positions): Change return type to
+ boolean. If the size of the last section changed, then output a
+ zero byte at the end of the file.
+ * libcoff.h: Rebuild.
+
+ * xcofflink.c (_bfd_xcoff_bfd_final_link): Always allocate space
+ for at least 6 output symbols.
+ (xcoff_write_global_symbol): When emitting TOC entry relocs, also
+ emit a TC csect to represent the space they take up. For an XO
+ symbol, just emit a reference, not a csect.
+
+ * Makefile.in ($(SHLINK)): Just use ln -s, not ln -sf, since
+ Solaris doesn't like the combined options, and the -f is
+ unnecessary.
+ (stamp-tshlink, install): Likewise.
+
+ * elf32-mips.c (mips_elf_relocate_section): Correct R_MIPS16_26
+ handling when little endian.
+
+Thu Mar 6 13:51:51 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (mn10300_elf_final_link_relocate): New function.
+ (mn10300_elf_relocate_section): Likewise.
+ (elf_backend_relocate_section): Define.
+
+ * elf32-mn10300.c (reloc_type): Remove PCREL{8,16,32}_{1,2}BYTE
+ relocs. Replace them with generic PCREL_{8,16,32} relocs.
+ (elf32_mn10300_howto_table): Likewise.
+ (elf32_mn10300_reloc_map): Likewise.
+ (bfd_elf32_mn10300_reloc): Delete unused function.
+
+Thu Mar 6 12:19:59 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (rtype2howto): If passed a relocation type we don't
+ understand, just set the howto field to NULL, and the caller will
+ print an appropriate error message.
+ * coffcode.h (coff_slurp_reloc_table): Pull duplicate declarations and
+ code fragment out of both legs of #ifdef RELOC_PROCESSING ... #endif
+ block. Use NULL for initializations of "ptr" rather than bare 0.
+ * coff-h8300.c: Fix typo in comment.
+ * coff-h8500.c: Ditto.
+ * coff-w65.c: Ditto
+ * coff-z8k.c: Ditto.
+
+Wed Mar 5 13:59:09 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc): Fix overflow calc.
+ (m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
+ m32r_elf_get_relocated_section_contents): First pass at relax support.
+
+Mon Mar 3 13:27:09 1997 Ulrich Drepper <drepper@rtl.cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Use correct sh_size
+ entry for reading verdef records.
+ Use correct braces for computing increments of extverdaux and
+ exteverdef record pointers.
+
+Sun Mar 2 22:47:54 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (COFF_DEFAULT_SECTION_ALIGNMENT_POWER): Set this to 2
+ instead of 4.
+
+Sun Mar 2 16:25:35 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_find_version_dependencies): Check that
+ DEF_REGULAR is not set as well as checking that DEF_DYNAMIC is
+ set.
+
+Fri Feb 28 16:52:40 1997 Fred Fish <fnf@cygnus.com>
+
+ * coffcode.h (coff_set_flags): Add case for TIC80_ARCH_MAGIC.
+
+Fri Feb 28 15:06:45 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * targets.c (bfd_default_vector): Make non-const.
+ (find_target): New static function, broken out of
+ bfd_find_target.
+ (bfd_set_default_target): New function.
+ (bfd_find_target): Call find_target. When defaulting, use
+ bfd_default_vector[0] if it is not NULL.
+ * libbfd-in.h (bfd_default_vector): Adjust declaration.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+ * syms.c (bfd_is_local_label): Return false if the symbol has no
+ name.
+ * coff-i960.c (coff_i960_is_local_label_name): New function.
+ (coff_bfd_is_local_label_name): Define.
+ * coff-m68k.c (m68k_coff_is_local_label_name): New function.
+ (coff_bfd_is_local_label_name): Define.
+ * coff-rs6000.c (xcoff_is_local_label_name): New function.
+ (coff_bfd_is_local_label_name): Define.
+ * elf.c (_bfd_elf_is_local_label_name): Treat symbols beginning
+ with .. or _.L_ as local.
+ * elf32-i386.c (elf_i386_is_local_label_name): New function.
+ (bfd_elf32_bfd_is_local_label_name): Define.
+ * evax-alpha.c (evax_bfd_is_local_label_name): Treat symbols
+ beginning with $ as local.
+
+Thu Feb 27 18:36:23 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (aout_link_write_symbols): Use bfd_is_local_label_name
+ rather than comparing against info->lprefix.
+ * cofflink.c (_bfd_coff_link_input_bfd): Likewise.
+ * elflink.h (elf_link_input_bfd): Likewise.
+ * linker.c (_bfd_generic_link_output_symbols): Likewise.
+ * xcofflink.c (xcoff_link_input_bfd): Likewise.
+
+ * elfxx-target.h (bfd_elfNN_bfd_is_local_label_name): Define as
+ _bfd_elf_is_local_label_name if not already defined.
+ * elf.c (_bfd_elf_is_local_label_name): New function.
+ * elf-bfd.h (_bfd_elf_is_local_label_name): Declare.
+
+ * coff-m88k.c (coff_bfd_is_local_label_name): Define.
+ (m88k_is_local_label_name): New static function.
+
+ * coffcode.h (coff_bfd_is_local_label_name): Define as
+ _bfd_coff_is_local_label_name if not already defined.
+ * coffgen.c (_bfd_coff_is_local_label_name): New function.
+ * libcoff-in.h (_bfd_coff_is_local_label_name): Declare.
+ * libcoff.h: Rebuild.
+
+ * targets.c (BFD_JUMP_TABLE_SYMBOLS): Change _bfd_is_local_label
+ to _bfd_is_local_label_name.
+ (bfd_target): Likewise.
+ * syms.c (bfd_is_local_label): Define as function, not macro.
+ (bfd_is_local_name): Define.
+ * libbfd.c (bfd_generic_is_local_label_name): Rename from
+ bfd_generic_is_local_label, and take a string rather than a
+ symbol.
+ * libbfd-in.h (_bfd_nosymbols_bfd_is_local_label): Don't define.
+ (_bfd_nosymbols_bfd_is_local_label_name): Define.
+ (bfd_generic_is_local_label): Don't declare.
+ (bfd_generic_is_local_label_name): Declare.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * All backends: Change local_label to local_label_name.
+
+ * elf32-mips.c (struct mips_got_info): Add assigned_gotno field.
+ (mips_elf_relocate_got_local): Change return type to boolean.
+ Don't assume that the first zero entry is unassigned; instead, use
+ assigned_gotno.
+ (mips_elf_relocate_section): Check return value of
+ mips_elf_relocate_got_local.
+ (mips_elf_create_got_section): Initialize assigned_gotno field.
+
+Wed Feb 26 15:19:51 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * elf32-d30v.c (bfd_elf_d30v_reloc): Add code to do 32-bit
+ relocations.
+
+Wed Feb 26 13:33:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_input_bfd): Don't skip symbols from sections
+ that have no contents merely because linker_mark is not set.
+
+Tue Feb 25 18:51:35 1997 Stan Shebs <shebs@andros.cygnus.com>
+
+ * config.bfd (mips*-*-lnews*): New target.
+ * coff-mips.c (mips_relocate_section): Make assert compare
+ content byteorder instead of header byteorder.
+ (ecoff_biglittle_vec): New BFD, big-endian headers, little-endian
+ data.
+ * targets.c (bfd_target_vector): Add ecoff_biglittle_vec.
+ * configure.in (ecoff_biglittle_vec): Add case.
+ * configure: Update.
+
+Tue Feb 25 00:32:49 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (elf_fake_sections): Use SHT_NOTE for any section whose
+ name begins with ".note".
+ (map_sections_to_segments): Add a PT_NOTE segment for any loadable
+ section whose name begins with ".note".
+ (get_program_header_size): Corresponding change.
+
+ * elf32-mips.c (mips_elf_relocate_section): Check for misaligned
+ jal and for jal overflow.
+
+Mon Feb 24 17:53:14 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Eric Youngdale <eric@andante.jic.com>:
+ * elflink.h (elf_link_add_archive_symbols): If a default symbol is
+ not found, try looking it up again without the version name.
+ (elf_link_add_object_symbols): Always link against the dynamic
+ symbol table of a dynamic object. When linking against a dynamic
+ object, include version strings in symbol names, and set up
+ version information. Add indirect symbols for default versions.
+ (elf_link_create_dynamic_sections): Add special version sections.
+ (struct elf_assign_sym_version_info): Define.
+ (struct elf_find_verdep_info): Define.
+ (NAME(bfd_elf,size_dynamic_sections)): Add verdefs parameter. Set
+ up version sections.
+ (elf_adjust_dynamic_symbol): Ignore indirect symbols.
+ (elf_link_find_version_dependencies): New static function.
+ (elf_link_assign_sym_version): New static function.
+ (elf_link_renumber_dynsyms): New static function.
+ (struct elf_final_link_info): Add symver_sec field.
+ (elf_bfd_final_link): Initialize finfo.symver_sec. Don't count
+ local symbols of a dynamic object. Handle DT_VER* constants.
+ (elf_link_output_extsym): Simplify BFD_ASSERT checking for a
+ dynamic object. Skip indirect symbols from ELF objects. Remove
+ the version name before choosing a hash bucket. Write out the
+ version information if appropriate.
+ (elf_link_input_bfd): Check for DYNAMIC, not ET_DYN.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration.
+ (bfd_elf64_size_dynamic_sections): Likewise.
+ * bfd-in2.h: Rebuild.
+ * elf-bfd.h (struct elf_link_hash_entry): Add verinfo field.
+ Change elf_link_hash_flags to unsigned short.
+ (ELF_LINK_HIDDEN): Define.
+ (struct elf_obj_tdata): Add fields dynversym_hdr, dynverref_hdr,
+ dynverdef_hdr, dynversym_section, dynverdef_section,
+ dynverref_section, cverdefs, cverrefs, verdef, verref.
+ (elf_dynversym, elf_dynverdef, elf_dynverref): Define.
+ (_bfd_elf_swap_verdef_in, _bfd_elf_swap_verdef_out): Declare.
+ (_bfd_elf_swap_verdaux_in, _bfd_elf_swap_verdaux_out): Declare.
+ (_bfd_elf_swap_verneed_in, _bfd_elf_swap_verneed_out): Declare.
+ (_bfd_elf_swap_vernaux_in, _bfd_elf_swap_vernaux_out): Declare.
+ (_bfd_elf_swap_versym_in, _bfd_elf_swap_versym_out): Declare.
+ (_bfd_elf_slurp_version_tables): Declare.
+ * elf.c (_bfd_elf_swap_verdef_in): New function.
+ (_bfd_elf_swap_verdef_out): Likewise.
+ (_bfd_elf_swap_verdaux_in, _bfd_elf_swap_verdaux_out): Likewise.
+ (_bfd_elf_swap_verneed_in, _bfd_elf_swap_verneed_out): Likewise.
+ (_bfd_elf_swap_vernaux_in, _bfd_elf_swap_vernaux_out): Likewise.
+ (_bfd_elf_swap_versym_in, _bfd_elf_swap_versym_out): Likewise.
+ (_bfd_elf_print_private_bfd_data): Add DT_VER* constants. Print
+ version information if there is any.
+ (_bfd_elf_link_hash_newfunc): Initialize verinfo field.
+ (bfd_section_from_shdr): Handle SHT_GNU_ver* section types.
+ (elf_fake_sections): Handle .gnu.version* section names.
+ (assign_section_numbers): Handle SHT_GNU_ver* section types.
+ (_bfd_elf_slurp_version_tables): New function.
+ * elflink.c (_bfd_elf_link_record_dynamic_symbol): Don't include
+ version name in string entered in dynamic hash table.
+ * elfcode.h: Include fnmatch.h.
+ * elf32-i386.c (elf_i386_relocate_section): Handle a dynamic
+ symbol which was forced to become local.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+ * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Likewise.
+
+Fri Feb 21 16:15:18 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10200.c (mn10200_elf_final_link_relocate): Simplify
+ somewhat.
+ (mn10200_elf_relax_section): Correctly compute a symbol's value
+ when the symbol is local, but not in the same section as we are
+ relaxing. Implement abs24 -> abs16, imm24 -> imm16 and d24 -> d16
+ relaxing.
+
+Fri Feb 21 13:55:14 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * elf32-m32r.c: Rewrite to use ELF backend linker.
+ Store lower 16 bits of addend in R_M32R_HI16_[SU]LO insns.
+ Add small data area support (R_M32R_SDA16).
+ * reloc.c: Document BFD_RELOC_M32R_SDA16.
+ * bfd-in2.h,libbfd.h: Regenerated.
+
+Thu Feb 20 23:50:31 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10200.c (mn10200_elf_relax_section): New function.
+ (mn10200_elf_relax_delete_bytes): Likewise.
+ (mn10200_elf_symbol_address_p): Likewise.
+ (mn10200_elf_get_relocated_section_contents): Likewise.
+ (bfd_elf32_bfd_relax_section): Define.
+ (bfd_elf32_bfd_get_relocated_section_contents): Likewise.
+
+ * elf32-mn10200.c (mn10200_elf_final_link_relocate): New function.
+ (mn10200_elf_relocate_section): Likewise.
+ (elf_backend_relocate_section): Define.
+
+Tue Feb 18 17:22:59 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * Makefile.in, archures.c, config.bfd, configure.in, elf.c,
+ reloc.c, targets.c: New target, elf-*-D30V.
+
+ * bfd-in2.h, configure, libbfd.h: Rebuilt.
+
+ * cpu-d30v.c, elf32-d30v.c: New files.
+
+Tue Feb 18 15:31:48 1997 Fred Fish <fnf@cygnus.com>
+
+ * reloc.c (struct reloc_howto_struct): Fix typo in comment.
+ * bfd-in2.h: Regenerated.
+ * coff-tic80.c (RTYPE2HOWTO): Replace abort with real function.
+ (rtype2howto): Add function.
+ (tic80_howto_table): Add.
+
+Tue Feb 18 11:41:00 1997 Dawn Perchik <dawn@cygnus.com>
+
+ * sysdep.h: Don't define errno in MSVC if error.h is included.
+
+Tue Feb 18 10:04:13 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (v850_elf_relocate_section): Make sure r_symndx
+ is initialized before it is used.
+
+Mon Feb 17 11:28:40 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * hp300hpux.c (convert_sym_type): Don't convert a secondary common
+ symbol into a weak undefined symbol; leave it as a common symbol.
+
+Fri Feb 14 19:08:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Don't issue a warning
+ about a symbol defined in a dynamic object if it has already been
+ defined in a regular object.
+
+Thu Feb 13 20:53:22 1997 Klaus Kaempf (kkaempf@progis.de)
+
+ * makefile.vms: Add gcc flags to allow compiling with current gcc
+ snapshot
+ (targmatch.h): New dependency.
+
+ * reloc.c (BFD_RELOC_ALPHA_CODEADDR): New relocation for
+ openVMS/Alpha.
+ * evax.h (ALPHA_R_CODEADDR): New relocation.
+ * evax-alpha.c (ALPHA_R_CODEADDR): 64 bit procedure relocation for
+ openVMS/Alpha.
+ * evax-etir.c (ALPHA_R_CODEADDR): Output object code for this
+ relocation.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+ Restrict symbol length to 64 bytes, case preserving:
+ * evax-emh.c (_bfd_evax_write_emh): Remove case hacking.
+ * evax-misc.c (_bfd_evax_case_hack_symbol): Remove.
+ (_bfd_evax_length_hash_symbol): Added.
+ * evax-etir.c (_bfd_evax_write_etir): Call
+ _bfd_evax_length_hash_symbol before output of symbol.
+ * evax-egsd.c (_bfd_evax_write_egsd): Likewise.
+ * evax.h (flag_hash_long_names, flag_show_after_trunc): Remove.
+
+ * evax-emh.c: Output filename to object file without path.
+
+ * evax-egsd.c: New sections for local and global commons.
+
+ * evax-alpha.c, evax-emh.c, evax-egsd.c, evax-etir.c,
+ evax-misc.c, evax.h: Remove 8 bit characters from copyright
+ notices. Replace AXP with Alpha.
+
+Wed Feb 12 18:10:30 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_create_dynamic_sections): We need the dynamic
+ sections if we are creating a shared library.
+
+Tue Feb 11 15:45:43 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * configure.host (i386-windows): Don't set host64=true.
+
+Tue Feb 11 15:27:32 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (reloc_type): Add R_MIPS16_GPREL.
+ (elf_mips16_gprel_howto): New static variable.
+ (mips16_gprel_reloc): New static function.
+ (bfd_elf32_bfd_reloc_type_lookup): Handle BFD_RELOC_MIPS16_GPREL.
+ (mips_info_to_howto_rel): Handle R_MIPS16_GPREL.
+ (mips_elf_relocate_section): Handle R_MIPS16_GPREL.
+ * reloc.c (BFD_RELOC_MIPS16_GPREL): Define.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+Mon Feb 10 23:25:00 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * elf32-m32r.c (elf_m32r_howto_table): Change partial_inplace to true
+ for R_M32R_{16,32,24,HI16_ULO,HI16_SLO,LO16}.
+
+Fri Feb 7 12:39:11 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_input_bfd): If we've discarded a section,
+ the output section will be the absolute section; don't print an
+ assertion message for that case when doing a relocateable link.
+
+Thu Feb 6 16:55:43 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (FN_STUB, CALL_STUB, CALL_FP_STUB): Define.
+ (struct mips_elf_link_hash_entry): Add new fields fn_stub,
+ need_fn_sub, call_stub, and call_fp_stub.
+ (struct mips_elf_link_hash_table): Add field mips16_stubs_seen.
+ (mips_elf_link_hash_newfunc): Initialize new fields.
+ (mips_elf_link_hash_table_create): Likewise.
+ (mips_elf_relocate_section): Redirect relocations to use mips16
+ stubs when appropriate.
+ (mips_elf_check_relocs): Attach stub sections to the appropriate
+ symbol. Set need_fn_stub when appropriate.
+ (mips_elf_always_size_sections): New static function.
+ (mips_elf_check_mips16_stubs): New static function.
+ (elf_backend_always_size_sections): Define.
+ * elf-bfd.h (struct elf_obj_tdata): Add local_stubs field.
+
+ * elflink.h (elf_link_input_bfd): Discard local symbols that are
+ attached to sections which are not being included in the link.
+
+Wed Feb 5 13:20:17 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Ignore the
+ symbol value when computing the addend for a pc_relative
+ pcrel_offset reloc.
+
+Mon Feb 3 11:54:06 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): If doing a
+ relocateable link, just skip pc_relative pcrel_offset relocs.
+ * coff-arm.c (coff_arm_rtype_to_howto): Return a different howto
+ structure for an ARM26 reloc which can be resolved.
+ (coff_arm_adjust_symndx): Only convert ARM26 to ARM26D if the
+ reloc can be resolved.
+
+ * coff-h8300.c (h8300_reloc16_extra_cases): Correct off by one
+ error in overflow check for R_RELBYTE.
+
+Fri Jan 31 14:07:27 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_slurp_section_data): Pick up the start address.
+ From Mark Rasin <mark.rasin@telrad.co.il>.
+
+ * aoutx.h (aout_link_write_symbols): Don't apply discard_l to
+ debugging symbols.
+
+Wed Jan 29 00:00:49 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10200.c (reloc_type): Add 16bit pc-relative reloc.
+ (elf_mn10200_howto_table): Likewise.
+ (mn10200_reloc_map): Likewise.
+
+Mon Jan 27 12:07:35 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * reloc.c: Add relocs BFD_RELOC_M32R_{HI16_[US]LO,LO16}.
+ * bfd-in2.h, libbfd.h: Regenerated.
+ * elf32-m32r.c: Add support for them.
+
+Mon Jan 27 12:25:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aout-arm.c (MY_swap_std_reloc_in): Remove unused r_length.
+ * elf32-ppc.c (ppc_elf_check_relocs): Remove unused plt.
+ * elf32-v850.c (v850_elf_final_link_relocate): Remove used
+ r_format and r_pcrel. Always return a value.
+ * riscix.c (MY_final_link_callback): Define to dummy value.
+
+ * elf32-i386.c (elf_i386_size_dynamic_sections): When checking for
+ relocations against the text segment, look up the output name of
+ the reloc section.
+ * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
+ * elf32-mips.c (mips_elf_size_dynamic_sections): Likewise.
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Likewise.
+ * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
+
+Wed Jan 22 15:40:28 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (tic80coff_vec): Use correct data put/get
+ routines for little endian data.
+ * coffcode.h (coff_write_object_contents): Set magic to
+ TIC80_ARCH_MAGIC for TIc80.
+
+Tue Jan 21 12:32:43 1997 Fred Fish <fnf@cygnus.com>
+
+ * coff-tic80.c (tic80coff_vec): Change to little endian data
+ as the default.
+
+Thu Jan 16 17:45:57 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Change type of
+ auxiliary_filters parameter to be const char * const *. Accept a
+ NULL terminated array.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration.
+ (bfd_elf32_size_dynamic_sections): Update declaration.
+ * bfd-in2.h: Rebuild.
+
+Wed Jan 15 11:21:32 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Treat a
+ NOTYPE symbol in a text section as a FUNC symbol.
+
+ * coffcode.h (coff_compute_section_file_positions): Force
+ relocbase to be aligned to COFF_DEFAULT_SECTION_ALIGNMENT_POWER.
+
+Tue Jan 14 08:46:33 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * libaout.h (machine_type): Reserve several values for sparclet.
+
+Mon Jan 13 22:39:08 1997 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.bfd (tic80-*-*): Don't require 'coff'.
+
+Mon Jan 13 19:36:25 1997 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-v850.c (v850_elf_howto_table): Set the special_function
+ table to v850_elf_reloc for all non-standard relocations.
+ (v850_elf_check_relocs): Add check for h being non-null.
+ (v850_elf_reloc): Add R_V850_ZDA_OFFSET support. Use switch
+ statement instead of multiple ifs.
+ (v850_elf_relocate_section): Fix up error message, don't just call
+ abort.
+
+Mon Jan 6 13:28:35 1997 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10200.c (elf_mn10200_howto): Don't ever set partial-inplace.
+ Use bfd_elf_generic_reloc as special function for all relocs.
+ (bfd_elf32_mn10200_reloc): Remove unnecessary function.
+
+ * elf32-mn10200.c (elf_mn10200_howto): Set pcrel_offset for
+ 24bit pc-relative reloc.
+
+Fri Jan 3 16:33:00 1997 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (coff-tic80.o): Add coffcode.h to dependency list.
+ * coff-tic80.c (tic80coff_vec): Data byte order is big endian and
+ header byte order is little endian. Use correct bfd_get and
+ bfd_put routines for little endian headers.
+ * coffcode.h (coff_set_arch_mach_hook): Set arch to
+ bfd_arch_tic80 for TIC80_ARCH_MAGIC number.
+
+Fri Jan 3 16:54:08 1997 Jeffrey A Law (law@cygnus.com)
+
+ * reloc.c: Add BFD_RELOC_24.
+ * elf32-mn10200.c (enum reloc_type): Add 24bit and pcrel relocs.
+ (elf_mn10200_howto, mn10200_reloc_map): Corresponding changes.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+
+Fri Jan 3 16:58:31 1997 Richard Henderson <rth@tamu.edu>
+
+ elf64-alpha multiple .got rewrite:
+
+ * elf-bfd.h (struct elf_backend_data): Add always_size_sections entry.
+ (bfd_elf*_mkobject): Don't define here ...
+ * elfxx-target.h: ... but rather here. Default always_size_sections
+ hook to NULL.
+ * elf.c (elf_mkobject): Rename to bfd_elf_mkobject, since that was
+ what the #defines in elf-bfd.h transmuted it to anyway.
+
+ * section.c: Add SEC_LINKER_CREATED flag.
+ * bfd-in2.h: Rebuild.
+ * elf32-i386.c (elf_i386_check_relocs): Add SEC_LINKER_CREATED to
+ relocation section flags.
+ (elf_i386_size_dynamic_sections): Use SEC_LINKER_CREATED instead of
+ SEC_IN_MEMORY to recognize generated bits.
+ * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_size_dynamic_sections):
+ Likewise.
+ * elf32-mips.c (mips_elf_final_link, mips_elf_create_dynamic_sections,
+ mips_elf_create_compact_rel_section, mips_elf_create_got_section,
+ mips_elf_check_relocs, mips_elf_size_dynamic_sections): Likewise.
+ * elf32-ppc.c (ppc_elf_create_linker_section,
+ ppc_elf_size_dynamic_sections): Likewise.
+ * elf32-sparc.c (elf32_sparc_check_relocs,
+ elf32_sparc_size_dynamic_sections): Likewise.
+ * elflink.c (_bfd_elf_create_got_section): Add SEC_LINKER_CREATED to
+ section flags.
+ (_bfd_elf_create_dynamic_sections): Likewise.
+ (_bfd_elf_make_linker_section_rela): Likewise.
+ * elflink.h (elf_link_create_dynamic_sections): Likewise.
+ (bfd_elf,size_dynamic_sections): Call the always_size_sections hook.
+ (elf_bfd_final_link): Use SEC_LINKER_CREATED instead of SEC_IN_MEMORY
+ to identify generated bits.
+ (elf_link_input_bfd): Likewise.
+
+ * elf64-alpha.c: Rewrite everything touching relocations.
+
+Fri Jan 3 11:42:53 1997 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-v850.c (all functions and static variables): Go through
+ and regularize names to be of the form v850_elf_<xxx>.
+ (toplevel): Include <elf/v850.h>.
+ (enum reloc_type): Move to include/elf/v850.h.
+ (v850_elf_check_relocs): For common variables, if the variable is
+ referenced by a R_V850_{SDA,ZDA,TDA} relocation, put the variable
+ into the appropriate section.
+ (elf_backend_check_relocs): Define.
+
+Tue Dec 31 15:15:28 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-v850.c (elf_v850_howto_table): Fix some spacing.
+
+Tue Dec 31 14:44:50 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.bfd (mips*el-*-linux*): New target.
+ (mips*-*-linux*): New target.
+
+ * elf32-mips.c (_bfd_mips_elf_merge_private_bfd_data): Clean up.
+ Return a useful value.
+
+ * Makefile.in (ALL_CFLAGS): Add -D_GNU_SOURCE.
+
+ * configure.in: Check ac_cv_func_mmap_fixed_mapped, not
+ ac_cv_func_mmap.
+ * configure: Rebuild.
+ * configure.host: Use ac_cv_func_mmap_fixed_mapped instead of
+ ac_cv_func_mmap in bfd/configure.host.
+
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Add
+ filter_shlib and auxiliary_filter_shlib parameters.
+ * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_AUXILIARY and
+ DT_FILTER.
+ * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration.
+ (bfd_elf64_size_dynamic_sections): Likewise.
+ * bfd-in2.h: Rebuild.
+
+Mon Dec 30 18:48:52 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_build_ldsyms): When exporting all defined
+ symbols, don't export a symbol which is defined by an object in an
+ archive which contains shared objects.
+
+Mon Dec 30 16:12:58 1996 Fred Fish <fnf@cygnus.com>
+
+ * archures.c (enum bfd_architecture): Add bfd_arch_tic80
+ for TI TMS320c80 (MVP).
+ (bfd_archures_list): Add bfd_tic80_arch.
+ * bfd-in2.h: Regenerate by running "make headers".
+
+Sun Dec 29 16:18:52 1996 Fred Fish <fnf@cygnus.com>
+
+ * cpu-tic80.c (bfd_tic80_arch): Add struct.
+ * configure.in (case $vec): Correct typo, "tb" not "tp".
+ Also add cofflink.o for tic80coff_vec.
+ * configure: Regenerate with autoconf.
+
+Mon Dec 30 11:54:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd.c: Patch up the mmap code so that it is only built if BFD
+ is configured with --with-mmap.
+
+Sun Dec 29 10:48:57 1996 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (BFD32_BACKENDS): Add coff-tic80.o
+ (ALL_MACHINES): Add cpu-tic80.o
+ (cpu-tic80.o, coff-tic80.o): Add dependencies.
+ * coff-tic80.c: Add skeleton, cloned from another coff config.
+ * coffcode.h (coff_write_object_contents): Set magic to TIC80MAGIC
+ for TIc80.
+
+Fri Dec 27 20:56:41 1996 Fred Fish <fnf@cygnus.com>
+
+ * TODO: Correct a misspelling.
+ * coff-tic80.c: New file for TI TMS320C80 (MVP).
+ * cpu-tic80.c: New file for TI TMS320C80 (MVP).
+ * configure.in (case $vec): Add tic80coff_vec entry.
+ * configure: Regenerate with autoconf.
+ * archures.c (bfd_tic80_arch): Declare.
+ * bfd-in2.h (enum bfd_architecture): Add bfd_arch_tic80.
+ * config.bfd (case ${targ}): Add tic80*-*-coff* target.
+ * targets.c (tic80coff_vec): Add decl as extern bfd_target.
+ (bfd_target_vector): Add tic80coff_vec entry.
+
+Fri Dec 27 11:48:12 1996 H.J. Lu <hjl@lucon.org>
+
+ * elflink.h (elf_buckets): Add some more values for larger
+ binaries.
+
+Thu Dec 26 18:36:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (install): Move subdir_do out of conditional. From
+ Fred Fish <fnf@cygnus.com>.
+
+Wed Dec 18 10:04:30 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10200.c (enum reloc_type): Enable basic 8, 16, and
+ 32 bit relocs.
+ (elf_mn10200_howto_table): Likewise.
+ (mn10200_reloc_map): Likewise.
+
+Tue Dec 17 11:09:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_add_symbol_hook): Add 1 to the value of a
+ mips16 symbol during the link.
+ (mips_elf_finish_dynamic_symbol): Subtract 1 from the value of a
+ mips16 symbol.
+ (mips_elf_link_output_symbol_hook): New static function.
+ (elf_backend_link_output_symbol_hook): Define.
+
+ * elf.c (bfd_elf_print_symbol): Print the st_other field if it is
+ not zero.
+
+Mon Dec 16 14:38:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (bfd_section_from_shdr): Don't check for reloc sections
+ against SEC_DEBUGGING sections here (revert patch of December 5).
+ * elfcode.h (elf_object_p): Check for them here, instead.
+
+Sun Dec 15 14:46:06 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcode.h (elf_slurp_reloc_table): Add dynamic parameter.
+ * elf.c (_bfd_elf_canonicalize_reloc): Pass new argument to
+ slurp_reloc_table.
+ (_bfd_elf_get_dynamic_reloc_upper_bound): New function.
+ (_bfd_elf_canonicalize_dynamic_reloc): New function.
+ * elf-bfd.h (struct elf_size_info): Update declaration of
+ slurp_reloc_table.
+ (_bfd_elf_get_dynamic_reloc_upper_bound): Declare.
+ (_bfd_elf_canonicalize_dynamic_reloc): Declare.
+ * elfxx-target.h: Use new dynamic reloc routines by default.
+ * elf64-mips.c (mips_elf64_slurp_reloc_table): Add dynamic
+ parameter.
+
+Fri Dec 13 13:18:49 1996 Dan Wilder <dan@gasboy.com>
+
+ * coffcode.h (coff_set_flags): Use MC68KBCSMAGIC for bfd_arch_m68k
+ if NAMES_HAVE_UNDERSCORE is defined.
+
+Fri Dec 13 11:13:23 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * libaout.h (enum machine_type): Change M_SPARCLET from 142 to 131.
+
+Thu Dec 12 15:07:20 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Move R_PPC_PLTREL24 into the
+ supported relocs.
+
+Thu Dec 12 14:55:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Only add a weak
+ symbol if the real definition is in the dynamic symbol table.
+ After finding the real definition, then, if it is dynamic, add the
+ weak symbol to the dynamic symbol table.
+
+ * coff-aux.c (coff_m68k_aux_link_add_one_symbol): Make static.
+
+ * ppcboot.c (ppcboot_set_arch_mach): Don't define; it's a
+ function.
+ (ppcboot_bfd_print_private_bfd_data): Don't take the address of an
+ array.
+
+Tue Dec 10 23:23:52 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (reloc_type): Remove big endian mn10300 reloc
+ variants.
+ (elf32_mn10300_howto_table, mn10300_reloc_map): Likewise.
+ (bfd_elf32_mn10300_reloc): Write data in little endian format.
+ * reloc.c: Remove mn10300 big endian relocs.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+
+ * elf32-mn10200.c: Update from elf32-mn10300.c.
+
+Fri Dec 6 15:18:05 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (elf_symbol_leading_char): Define.
+
+ * elf32-mn10300.c: Add some comments.
+
+Fri Dec 6 17:16:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ihex.c (ihex_scan): Always initialize buf before jumping to
+ error_return.
+ (ihex_read_section): Likewise.
+
+Thu Dec 5 22:29:18 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (elf_mn10300_howto_table): Don't set partial-
+ inplace for most relocs.
+
+Thu Dec 5 13:24:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Calling check_relocs
+ even if SEC_ALLOC is not set.
+ * elf32-i386.c (elf_i386_check_relocs): Don't check SEC_ALLOC
+ when deciding whether to copy a reloc into a shared object.
+ (elf_i386_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_check_relocs): Likewise.
+ (elf32_sparc_relocate_section): Likewise.
+ * elf32-i386.c (elf_i386_check_relocs): Don't set SEC_ALLOC in a
+ reloc section if it is not set in the source section.
+ * elf32-sparc.c (elf32_sparc_check_relocs): Likewise.
+ * elf.c (bfd_section_from_shdr): Mark a reloc section associated
+ with a SEC_DEBUGGING section as SEC_DEBUGGING.
+
+Wed Dec 4 14:18:13 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): #if 0 code that
+ expects a .got.plt until we actually create it.
+
+Mon Dec 2 12:13:51 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_generic_relocate_section): Print an error
+ message for bfd_reloc_outofrange, rather than aborting. From
+ Philippe De Muyter <phdm@info.ucl.ac.be>.
+
+ * cofflink.c (_bfd_coff_final_link): If there aren't any relocs in
+ a relocateable link, don't try to process them. From Heinz Wrobel
+ <wrobel@lpr.e-technik.tu-muenchen.de>.
+
+Mon Dec 2 00:39:24 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (mn10300_info_howto): Renamed from
+ mn10300_info_howto_rel. Tweak reloc argument to be an
+ Elf32_Internal_Rela.
+ (USE_RELA): Define instead of USE_REL.
+ (elf_info_to_howto, elf_info_howto_rel): Corresponding changes.
+
+Sun Dec 1 00:18:59 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * configure.in, configure: Handle mips*-sgi-irix6*.
+ * irix-core.c (irix_core_core_file_p): Accept CORE_MAGICN32
+ core files.
+
+Wed Nov 27 12:10:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): Warn about a
+ relocation against a symbol defined in a section with no output
+ section.
+
+Tue Nov 26 11:07:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aclocal.m4 (BFD_CC_FOR_BUILD): Don't require AC_C_CROSS.
+ * configure, config.in: Rebuild with autoconf 2.12.
+
+ * elf-bfd.h (struct elf_link_hash_entry): Add other field.
+ * elf.c (_bfd_elf_link_hash_newfunc): Initialize other field.
+ (swap_out_syms): Set st_other from existing st_other field.
+ * elflink.h (elf_link_add_object_symbols): Store st_other in hash
+ table other field.
+ (elf_link_output_extsym): Set the other field from the global hash
+ table entry.
+ * elf32-mips.c (enum reloc_type): Add R_MIPS16_26.
+ (elf_mips16_jump_howto): New static variable.
+ (mips16_jump_reloc): New static function.
+ (bfd_elf32_bfd_reloc_type_lookup): Handle BFD_RELOC_MIPS16_JMP.
+ (mips_info_to_howto_rel): Handle R_MIPS16_26.
+ (mips_elf_relocate_section): Handle R_MIPS16_26. Handle R_MIPS_26
+ to a mips16 symbol.
+ * reloc.c (BFD_RELOC_MIPS16_JMP): Add to list of relocs.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * cpu-mips.c (arch_info_struct): Add mips:16 entry.
+
+Mon Nov 25 11:23:32 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Use long long for mips-sgi-irix6*.
+
+ * coffswap.h (coff_swap_scnhdr_out): Make line number overflow
+ only a warning. From Philippe De Muyter <phdemuyt@ulb.ac.be>.
+
+Mon Nov 25 08:52:29 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c (bfd_elf32_mn10300_reloc): New function.
+ (enum reloc_type): Add more reloc types.
+ (elf32_mn10300_howto_table): Update for new reloc types.
+ (elf32_mn10300_reloc_map): Update for new reloc types.
+ * reloc.c: Add some new relocs for the mn10300 series.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+
+Sat Nov 23 13:26:18 1996 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (setup_sections): Don't lose for a space which has
+ no data, but some symbols.
+
+Fri Nov 22 11:32:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (struct sunos_link_hash_table): Add got_needed field.
+ (sunos_link_hash_table_create): Initialize got_needed.
+ (sunos_create_dynamic_sections): Only set .got section size if it
+ is not already set. Set got_needed.
+ (bfd_sunos_size_dynamic_sections): Check got_needed. Only set
+ sdynptr, and only handle dynamic sections, if dynamic sections are
+ needed.
+ (sunos_scan_std_relocs): Pass false to create_dynamic_sections.
+ Initialize .got section.
+ (sunos_scan_ext_relocs): Likewise.
+ (sunos_write_dynamic_symbol): Set up PLT entry even if this is not
+ a dynamic symbol.
+ (sunos_finish_dynamic_link): Check got_needed. Only set up
+ dynamic linking information if needed.
+
+Thu Nov 21 10:31:31 1996 Rob Savoye (rob@cygnus.com)
+
+ * config.bfd: Added VersaDOS format to the Ericsson configuration.
+
+Wed Nov 20 16:31:31 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-mn10300.c: Rough cut at relocs for the mn10300.
+
+Wed Nov 13 08:12:38 1996 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (elf32-d10v.o): Don't depend on elf/d10v.h
+ anymore.
+
+Tue Nov 12 13:30:00 1996 Dawn Perchik <dawn@cygnus.com>
+
+ * filemode.c: Include sysdep.h.
+ * ihex.c: Add casts to eliminate compiler warnings.
+ * sunos.c: Add casts to eliminate compiler warnings.
+
+Mon Nov 11 10:37:02 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Create .got.plt
+ section.
+ (ppc_elf_check_relocs): Add support for R_PPC_LOCAL24PC. Make
+ appropriate relocations in the .so file if shared.
+ (ppc_elf_relocate_section): Ditto.
+
+Tue Oct 29 15:03:02 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf32-m32r.c (elf_m32r_howto_table, R_M32R_24): Use
+ complain_overflow_unsigned.
+
+Tue Oct 29 12:53:46 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * elf32-d10v.c (elf_d10v_howto_table): Don't complain on
+ overflows for R_D10V_16 and R_D10V_18.
+
+Tue Oct 29 13:23:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_write_section_part): Use LMA rather than VMA.
+ (do_with_relocs): Likewise.
+ (do_as_repeat): Likewise.
+ (copy_expression): Likewise.
+
+Fri Oct 25 16:56:40 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_write_external_part): Correctly record whether
+ there is an external part.
+
+Thu Oct 24 14:32:52 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (elf32_v850_bfd_final_link_relocate): Correctly
+ handle tda offsets for sld.w and sst.w instructions.
+ Fix alignment check in sld.w and sst.w tda reloc handling.
+
+Thu Oct 24 09:08:47 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * aclocal.m4, configure: Set USE_BINARY_FOPEN for *-*-windows.
+
+Wed Oct 23 00:53:16 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c: Add comments about assumptions about
+ char, short & long sizes.
+ (elf32_v850_bfd_final_link_relocate): Fix sign extension
+ problems for several relocs.
+
+ * elf32-v850.c (elf32_v850_howto_table): Fix typo in
+ R_V850_SDA_OFFSET entry.
+
+Wed Oct 23 00:20:34 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (bfd_xcoff_import_symbol): Don't allocate ldsym.
+ Store import file index in ldindx.
+ (xcoff_build_ldsyms): Assume that ldsym was not previously
+ allocated. For an imported symbol, copy ldindx into l_ifile.
+
+Tue Oct 22 19:20:38 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (elf_v850_howto_table): Fix ordering of
+ R_V850_ZDA_OFFSET and R_V850_TDA_OFFSET. Fix various
+ fields in R_V850_TDA_OFFSET.
+ (elf32_v850_bfd_final_link_relocate): Tweak pc-relative
+ relocs to work more like other relocs. Handle R_V850_TDA_OFFSET
+ relocations.
+
+ * elf32-v850.c: Include bfdlink.h.
+ (bfd_elf32_v850_reloc): Return an error if we get a reloc
+ we can't handle.
+ (elf32_v850_bfd_final_link_relocate): New function.
+ (v850_elf_relocation_section): Likewise.
+ (elf_backend_relocate_section): Define.
+
+Tue Oct 22 17:22:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * binary.c (binary_set_section_contents): Ignore sections which
+ don't have SEC_LOAD and SEC_ALLOC set.
+
+Mon Oct 21 12:13:05 1996 Jeffrey A Law (law@cygnus.com)
+
+ * linker.c (_bfd_generic_final_link): Avoid losing static
+ symbols in the .bss section.
+
+Mon Oct 21 10:54:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (elf_mips_howto_table): Describe R_MIPS_64.
+ (mips32_64bit_reloc): New static function.
+ (mips_reloc_map): Add entry for BFD_RELOC_64.
+ (mips_elf_relocate_section): Handle R_MIPS_64.
+
+ * linker.c (default_indirect_link_order): Print an error message
+ when attempting to do a relocateable link with different object
+ file formats, rather than calling abort.
+
+Thu Oct 17 10:43:29 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * reloc.c (m32r relocs): Rename them.
+ * bfd-in2.h, libbfd.h: Regenerated.
+ * elf32-m32r.c: Update.
+ (m32r_elf_10_pcrel_reloc): New function.
+ (elf_m32r_howto_table, R_M32R_10_PCREL entry): Use it.
+ (elf_m32r_howto_table, R_M32R_24 entry): Fix {src,dst}_masks.
+
+Wed Oct 16 11:24:35 1996 Jeffrey A Law (law@cygnus.com)
+
+ * linker.c (_bfd_generic_final_link): Set "linker_mark" for
+ all sections that will be included in the output file.
+ (_bfd_generic_link_output_symbols): Discard symbols in sections
+ which are being discarded.
+ * elf32-v850.c (enum reloc_type): Add R_V850_SDA_OFFSET,
+ R_V850_TDA_OFFSET and R_V850_ZDA_OFFSET.
+ (elf_v850_howto_table): Corresponding changes.
+ (elf_v850_reloc_map): Corresponding changes.
+ * reloc.c: Add additional V850 relocations.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+
+ * elf32-v850.c (bfd_elf32_v850_reloc): Mask out bits we
+ no longer want in pc-relative relocs.
+
+Tue Oct 15 22:17:37 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (bfd_elf32_v850_reloc): Don't silently
+ accept a reloc against an undefined sybmol!
+
+Tue Oct 15 16:17:28 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * elf32-v850.c: Define elf_symbol_leading_char to be '_'.
+
+Tue Oct 15 12:40:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * VERSION: Bump for new relocation.
+
+ * hosts/i386bsd.h: If NBPG is not defined, define it as
+ PAGE_SIZE, for recent versions of FreeBSD.
+
+Mon Oct 14 12:37:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Use `long long' as the 64 bit type on a Solaris
+ host, since both gcc and the SunPRO compilers support it.
+
+Mon Oct 14 11:17:24 1996 Richard Henderson <rth@tamu.edu>
+
+ * reloc.c: Create a new BFD_RELOC_ALPHA_ELF_LITERAL. It was a
+ mistake to have reused the ECOFF LITERAL for ELF since they have
+ different semantics.
+ * elf64-alpha.c (elf_reloc_map): Map from ELF_LITERAL.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+ * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Trap .got
+ section overflow.
+
+ * elf64-alpha.c (elf64_alpha_relocate_section): Do not emit a
+ dynamic relocation for an undefweak symbol when we are building
+ a static executable.
+
+Thu Oct 10 11:15:06 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed (config.bfd, targmatch.sed): Edit references to
+ point explicitly to srcdir.
+ (targmatch.h): Edit references to point explicitly to objdir.
+
+Thu Oct 10 14:14:23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.bfd: When setting targ_cpu, don't get confused by
+ linux-gnu.
+
+Tue Oct 8 08:51:19 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * configure.host: Add support for windows host (a build done
+ under the Microsoft build environment).
+
+Tue Oct 8 11:40:16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): If a symbol is a weak
+ definition in a dynamic object, add it to the dynamic symbol table
+ if any dynamic object mentions it. Reverts part of last patch.
+
+ * sunos.c (struct sunos_link_hash_table): Add got_base field.
+ (sunos_link_hash_table_create): Initialize got_base.
+ (bfd_sunos_size_dynamic_sections): If the .got section is more
+ than 0x1000 bytes, set __GLOBAL_OFFSET_TABLE_ and got_base to
+ 0x1000.
+ (sunos_check_dynamic_reloc): Subtract got_base from a base
+ relative relocation.
+
+ * elf32-mips.c (elf_mips_isa): New static function.
+ (_bfd_mips_elf_merge_private_bfd_data): Don't warn about linking
+ -mips1 and -mips2 code together, or -mips3 and -mips4 code.
+
+Mon Oct 7 11:44:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * archive.c (do_slurp_coff_armap): Only treat archive as little
+ endian for i960 COFF.
+
+Fri Oct 4 13:49:01 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_compute_section_file_positions): Adjust sofar
+ by the change in size of the section when EXEC_P is not set.
+
+ * coff-m68k.c (coff_rtype_to_howto): Define if not defined.
+ (m68kcoff_rtype_to_howto): New static function.
+ * cf-m68klynx.c (coff_m68k_lynx_rtype_to_howto): Add the section
+ VMA to the addend for a PC relative reloc.
+
+ * dep-in.sed: Rework backslash loop a bit to avoid bug in sed on
+ HP/UX 10.20.
+ * Makefile.in: Rebuild dependencies.
+
+ * dep-in.sed: Remove ../bfd/sysdep.h, since it will appear when
+ som.h is included.
+
+Fri Oct 4 11:41:39 1996 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in: Remove explicit dependencies for mn10200 and
+ mn10300 files.
+ (ALL_MACHINE_CFILES): Add cpu-mn10200.c and cpu-mn10300.c.
+ (BFD32_BACKENDS_CFILES): Add elf32-mn10200.c and elf32-mn10300.c
+ (dependencies): Rebuilt.
+
+Thu Oct 3 16:57:51 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (coff_link_add_symbols): Set obj_coff_keep_syms
+ during this function.
+
+ * elflink.c (_bfd_elf_create_linker_section): Only use an existing
+ section if the flags are compatible.
+
+ * configure.in: Add havevecs, and put it in tdefaults.
+ * mpw-config.in: Likewise.
+ * configure: Rebuild.
+ * targmatch.sed: New file; a sed script to build targmatch.h from
+ config.bfd.
+ * config.bfd: Add #if, #endif, and comments for targmatch.h.
+ * targets.c: Include "fnmatch.h".
+ (struct targmatch): Define.
+ (bfd_target_match): Define by including targmatch.h.
+ (bfd_find_target): If the target is not found by name, search for
+ it as a configuration triplet.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add aout-arm.o, aout-sparcle.o, hp300bsd.o,
+ i386dynix.o, m68k4knetbsd.o, and riscix.o.
+ (BFD32_BACKENDS_CFILES): Add aout-arm.c, aout-sparcle.c,
+ hp300bsd.c, i386dynix.c, m68k4knetbsd.c, and riscix.c.
+ (HFILES): Add targmatch.h. Also, alphabetize and reindent.
+ (CFILES): Remove i386dynix.c and hp300bsd.c.
+ (targmatch.h): New target.
+ (do_clean): Remove targmatch.h.
+
+ * configure.in: Add BFD_NEED_DECLARATION(getenv).
+ * acconfig.h: Add NEED_DECLARATION_GETENV.
+ * configure, config.in: Rebuild.
+ * sysdep.h: If NEED_DECLARATION_GETENV, declare getenv.
+ * aout-adobe.c (aout_adobe_object_p): Don't declare getenv.
+
+Thu Oct 3 09:29:09 1996 Jeffrey A Law (law@cygnus.com)
+
+ * cpu-mn10x00.c, elf32-mn10x00: Removed.
+ * cpu-mn10200.c, cpu-mn10300.c: New files.
+ * elf32-mn10200.c, elf32-mn10300.c: New files.
+ * Makefile.in: Break mn10x00 support into two separate
+ configurations, mn10200 and mn10300.
+ * archures.c, config.bfd, configure.in, elf.c, targets.c: Likewise.
+ * bfd-in2.h, configure: Rebuilt.
+
+Thu Oct 3 15:38:19 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (do_clean): Move config.log to do_distclean.
+
+Wed Oct 2 21:40:55 1996 Jeffrey A Law (law@cygnus.com)
+
+ * cpu-mn10x00.c, elf32-mn10x00.c: New files.
+ * Makefile.in (ALL_MACHINES): Add cpu-mn10x00.o.
+ (BFD32_BACKENDS): Similarly for elf32-mn10x00.o.
+ (elf32-mn10x00.o): Add dependencies.
+ * archures.c (enum bfd_architecture): Add bfd_arch_mn10x00.
+ (bfd_mn10x00_arch): Declare.
+ (bfd_archures_list): Add bfd_mn10x00_arch.
+ * config.bfd: Add mn10x00-*-*.
+ * configure.in: Add bfd_elf32_mn10x00_vec.
+ * elf.c (prep_headers): Handle bfd_arch_mn10x00.
+ * targets.c (bfd_elf32_mn10x00_vec): Declare.
+ (bfd_target_vector): Add bfd_elf32_mn10x00_vec.
+ * bfd-in2.h, configure: Rebuilt.
+
+Wed Oct 2 15:46:45 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ openVMS/Alpha: Provide filename and case_hack flags via
+ symbol table from gas.
+ Add case_hack code for symbol output from vax/vms.
+ * evax-alpha.c (evax_initialize): Remove filename handling,
+ filename is provided via symbol table.
+ (evax_get_symtab): Use local symbol count when setting up table.
+ * evax-egsd.c (_bfd_evax_slurp_egsd): Print correct name when
+ debugging.
+ (_bfd_evax_write_egsd): Skip file name symbol.
+ * evax-emh.c (get_vms_time_string): Local function now.
+ (_bfd_evax_write_emh): Extract source filename and case_hack flags
+ from symbol table.
+ * evax_write_etir (_bfd_evax_write_etir): Pass all symbol names
+ through _bfd_evax_case_hack_symbol.
+ * evax-misc.c (hash_string, _bfd_evax_case_hack_symbol): New
+ functions.
+ (_bfd_evax_basename): Removed.
+ (_bfd_get_vms_time_string): Moved to evax-emh.c.
+ * evax.h (evax_private_data_struct): Remove filename.
+ (flag_hash_long_names, flag_show_after_trunc,
+ flag_no_hash_mixed_case, vms_name_mapping): New flags for
+ vms_case_hack.
+
+Wed Oct 2 12:02:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * freebsd.h (N_GET_MAGIC_NET): Don't use ntohl.
+ (N_GETMID_NET, N_GETFLAG_NET): Likewise.
+ (NO_SWAP_MAGIC): Don't define.
+ (SWAP_MAGIC): Define.
+
+ * cofflink.c (_bfd_coff_link_input_bfd): Don't crash if there is
+ no hash table entry for a global symbol.
+
+Tue Oct 1 16:14:22 1996 Joel Sherrill <joel@oarcorp.com>
+
+ * config.bfd (mips*-*-rtems*): New target, like mips*-*-elf*.
+
+Tue Oct 1 12:31:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (coff_link_add_symbols): Don't override a meaningful
+ symbol type with T_NULL. Warn if symbol type changes. Based on
+ patch from Philippe De Muyter <phdm@info.ucl.ac.be>.
+
+ * elflink.h (elf_link_add_object_symbols): Only put a symbol from
+ a dynamic object in the dynamic symbol table if it is referenced
+ or defined by a regular object.
+
+Fri Sep 27 18:41:07 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * elf32-v850.c (bfd_elf32_v850_is_local_label): New function to
+ remove dwarf local labels. Shrinks binaries by a factor of 3!
+
+Mon Sep 23 13:33:00 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_add_symbol_hook): Create the .sbss section
+ by hand, rather than by calling bfd_make_section.
+
+Mon Sep 23 09:23:41 1996 Doug Evans <dje@seba.cygnus.com>
+
+ * reloc.c: Rename m32r relocs.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+ * elf32-m32r.c: Update.
+
+Fri Sep 20 11:43:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (aout_link_input_section_ext): When doing a relocateable
+ link, adjust the symbol index of a base relative reloc. Don't
+ change the addend of a PC relative reloc if pcrel_offset is set.
+ * sunos.c (bfd_sunos_size_dynamic_sections): Don't do anything for
+ a relocateable link.
+
+ * reloc.c (bfd_perform_relocation): Apply the relocation even if
+ it is zero, in case src_mask matters.
+ (bfd_install_relocation): Likewise.
+
+Thu Sep 19 11:03:06 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_symbols): Always initialize
+ keep_syms.
+ (_bfd_xcoff_bfd_final_link): Don't set target_index
+ to an uninitialized value.
+
+Tue Sep 17 14:18:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_slurp_line_table): Warn about illegal symbol
+ indices, rather than crashing.
+ (coff_slurp_reloc_table): Likewise. Check whether the howto field
+ is NULL.
+ * coff-sh.c (sh_relocate_section): Check for an illegal symbol
+ index.
+
+Mon Sep 16 12:39:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-arm.c (aoutarm_std_reloc_howto): Change dst_mask for ARM26D
+ reloc to 0.
+ (coff_arm_adjust_symndx): New static function.
+ (coff_adjust_symndx): Define.
+
+ * srec.c (srec_scan): Accept multiple symbols on a single line.
+ From Pascal Martin <pmartin@alsys.com>.
+
+ * README: New file.
+
+Fri Sep 13 14:32:42 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * aoutf1.h (MY_bfd_merge_private_bfd_data): Define.
+ (sunos_merge_private_bfd_data): New function.
+
+Fri Sep 13 15:50:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd.c (bfd_copy_private_bfd_data): Switch on output BFD rather
+ than input BFD.
+ (bfd_merge_private_bfd_data): Likewise.
+ * section.c (bfd_copy_private_section_data): Likewise.
+ * syms.c (bfd_copy_private_symbol_data): Likewise.
+ * bfd-in2.h: Rebuild.
+ * aout-target.h (MY_bfd_copy_private_section_data): Check that
+ both BFD's are the right flavour.
+ * ecoff.c (_bfd_ecoff_bfd_copy_private_bfd_data): Likewise.
+ * elf.c (_bfd_elf_copy_private_symbol_data): Likewise.
+ * elf32-mips.c (_bfd_mips_elf_copy_private_bfd_data): Likewise.
+ (_bfd_mips_elf_merge_private_bfd_data): Likewise.
+ * elf32-ppc.c (ppc_elf_copy_private_bfd_data): Likewise.
+ (ppc_elf_merge_private_bfd_data): Likewise.
+ * elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Likewise.
+ * peicode.h (pe_bfd_copy_private_section_data): Likewise.
+
+ * elf32-hppa.c (elf_hppa_howto_table): Fill in some fields for
+ R_PARISC_DIR32, so that _bfd_stab_section_find_nearest_line passes
+ its sanity check.
+
+Thu Sep 12 11:45:57 1996 Doug Evans <dje@seba.cygnus.com>
+
+ * reloc.c: Add m32r relocs.
+ * bfd-in2.h, libbfd.h: Rebuilt.
+ * cpu-m32r.c,elf32-m32r.c: New files.
+
+Thu Sep 12 11:10:05 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_vec): Set symbol_leading_char field to '_'.
+
+Wed Sep 11 11:57:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * tekhex.c (first_phase): Change type parameter from char to int.
+ (out): Likewise.
+ (pass_over): Change func to expect int, not char.
+
+ * elf.c (assign_file_positions_for_segments): Test SEC_ALLOC
+ rather than SEC_LOAD when aligning the file offset for the first
+ section in a segment.
+
+Tue Sep 10 16:18:30 1996 Fred Fish <fnf@cygnus.com>
+
+ * syms.c (coff_section_type): Make arg const.
+ * irix-core.c (irix_core_core_file_p): Remove extraneous extra arg
+ to make_bfd_asection().
+ * elf-bfd.h (bfd_section_from_phdr): Add prototype.
+ * elfcode.h (bfd_section_from_phdr): Remove prototype.
+ (_bfd_elf_stringtab_init): Remove prototype.
+
+ * netbsd-core.c (swap_abort): Add prototype.
+ * aix386-core.c (swap_abort): Ditto & make static
+ * hpux-core.c (swap_abort): Ditto & make static.
+ * irix-core.c (swap_abort): Ditto & make static.
+ * ptrace-core.c (swap_abort): Ditto & make static.
+ * trad-core.c (swap_abort): Ditto & make static.
+ * coffswap.h (coff_swap_reloc_in): Ditto.
+ (coff_swap_reloc_out): Ditto.
+ (coff_swap_filehdr_in): Ditto.
+ (coff_swap_filehdr_out): Ditto.
+ (coff_swap_sym_in): Ditto.
+ (coff_swap_sym_out): Ditto.
+ (coff_swap_aux_in): Ditto.
+ (coff_swap_aux_out): Ditto.
+ (coff_swap_lineno_in): Ditto.
+ (coff_swap_lineno_out): Ditto.
+ (coff_swap_aouthdr_in): Ditto.
+ (coff_swap_aouthdr_out): Ditto.
+ (coff_swap_scnhdr_in): Ditto.
+ (coff_swap_scnhdr_out): Ditto.
+ * ihex.c (ihex_sizeof_headers): Ditto.
+ * tekhex.c (getsym): Ditto.
+ (find_chunk): Ditto & make static.
+ (insert_byte): Ditto.
+ (first_phase): Ditto.
+ (pass_over): Ditto.
+ (tekhex_get_symtab): Ditto & make static.
+ (tekhex_get_symtab_upper_bound): Ditto & make static.
+ (tekhex_mkobject): Ditto.
+ (tekhex_object_p): Ditto.
+ (move_section_contents): Ditto.
+ (tekhex_get_section_contents): Ditto.
+ (tekhex_set_arch_mach): Ditto & make static.
+ (tekhex_set_section_contents): Ditto.
+ (writevalue): Ditto.
+ (writesym): Ditto.
+ (out): Ditto.
+ (tekhex_write_object_contents): Ditto.
+ (tekhex_sizeof_headers): Ditto.
+ (tekhex_make_empty_symbol): Ditto.
+ (tekhex_get_symbol_info): Ditto.
+ (tekhex_print_symbol): Ditto.
+ * irix-core.c (make_bfd_asection): Ditto.
+ (irix_core_core_file_p): Ditto.
+ (irix_core_core_file_failing_command): Ditto.
+ (irix_core_core_file_failing_signal): Ditto.
+ (irix_core_core_file_matches_executable_p): Ditto.
+ (irix_core_make_empty_symbol): Ditto.
+ * coff-mips.c (mips_bfd_reloc_type_lookup): Ditto.
+ * srec.c (srec_new_symbol): Ditto.
+ (srec_get_section_contents): Ditto.
+ (srec_set_arch_mach): Ditto.
+ (srec_set_section_contents): Ditto.
+ (internal_srec_write_object_contents): Ditto.
+ (srec_write_object_contents): Ditto.
+ (symbolsrec_write_object_contents): Ditto.
+ (srec_sizeof_headers): Ditto.
+ (srec_make_empty_symbol): Ditto.
+ (srec_get_symtab_upper_bound): Ditto.
+ (srec_get_symtab): Ditto.
+ (srec_print_symbol): Ditto and make static.
+ * elf.c (elf_read): Ditto
+ (assign_section_numbers): Ditto.
+ (elf_fake_sections): Ditto.
+ (sym_is_global): Ditto.
+ (elf_map_symbols): Ditto.
+ (get_program_header_size): Ditto.
+ * coffgen.c (make_a_section_from_file): Ditto.
+ (coff_real_object_p): Ditto.
+ (fixup_symbol_value): Ditto.
+ (build_debug_section): Ditto.
+ (copy_name): Ditto.
+ * syms.c (coff_section_type): Ditto.
+
+Mon Sep 9 22:36:01 1996 Jeffrey A Law (law@cygnus.com)
+
+ * bfd-in2.h: Rebuilt after m32r changes.
+
+Mon Sep 9 12:31:22 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.bfd,configure.in,configure: Add m32r support.
+ * Makefile.in,archures.c,elf.c,targets.c: Likewise.
+ * config.bfd: Keep target list alphabetically sorted.
+
+Mon Sep 9 11:48:41 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (bfd_elf32_v850_reloc, case R_V850_HI16): Don't forget
+ to add in the constant part found in the instruction itself.
+ (case R_V850_HI16_S): Likewise.
+
+Fri Sep 6 17:04:39 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * elf32-d10v.c (elf_d10v_howto_table): Modify the size of R_D10V_16
+ and R_D10V_18 to be 1 (word).
+
+Thu Sep 5 15:23:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * stabs.c (_bfd_link_section_stabs): If the output_section field
+ of either section is bfd_abs_section, then the linker is
+ discarding the section and we should not optimize it.
+
+Tue Sep 3 12:16:20 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (aout-sparcle.o): New target.
+ * aoutf1.h (TARGET_IS_BIG_ENDIAN_P): Don't define if little endian.
+ * config.bfd (sparclet-*-aout*): Add case.
+ * configure.in (sparcle_aout_vec): Add case.
+ * configure: Regenerated.
+ * targets.c (sparcle_aout_vec): Declare.
+ (bfd_target_vector): Add sparcle_aout_vec.
+ * aout-sparcle.c: New file.
+
+Tue Sep 3 00:57:02 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (bfd_elf32_v850_reloc): Fix handling of
+ low order sign bit propogation for R_V850_HI16_S.
+
+ * elf32-v850.c (bfd_elf32_v850_reloc): New function for
+ handling V850 specific relocs.
+ (elf_v850_howto_table): Use the new function for some
+ relocations. Twiddle masks & shifts for some relocs.
+ Set partial_inplace where needed.
+
+Mon Sep 2 12:12:34 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cpu-mips.c: Add an explicit mips:3000 entry, and change the
+ default architecture to a machine number of 0.
+ * elf32-mips.c (_bfd_mips_elf_object_p): Set the machine number
+ for E_MIPS_ARCH_1.
+ (_bfd_mips_elf_merge_private_bfd_data): If the machine number of
+ the output BFD is the default, set it from the first input BFD.
+
+Sun Sep 1 18:38:01 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (elf_v850_howto_table): All the 16bit relocs
+ insert at bitpos zero. The HI16 relocs are shifted right
+ by 16 bits. Fix src_mask for all relocs.
+ (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME): Define. The V850 is
+ little endian!
+ (TARGET_BIG_SYM, TARGET_BIG_NAME): Remove. The V850 is little
+ endian!
+
+Sun Sep 1 15:41:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rs6000-core.c (rs6000coff_core_file_matches_executable_p):
+ Rewrite to use BFD file read routines and to avoid using a fixed
+ length for the file name.
+
+Sat Aug 31 10:22:25 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-v850.c (enum reloc_type): Add R_V850_{32,16,8}.
+ (elf_v850_howto_table): Add support for R_V850_{32,16,8}.
+ (v850_reloc_map): Add translation from BFD_RELOC_{32,16,8}
+ to R_V850_{32,16,8}.
+
+Fri Aug 30 18:06:04 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * elf32-v850.c (reloc_type): Add R_V850_HI16_S.
+ (elf_v850_howto_table): Add info for HI16_S reloc.
+ (v850_reloc_map): Add HI_16_S reloc.
+ * reloc.c: Define BFD_RELOC_V850_* relocs.
+
+Fri Aug 30 11:49:19 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Add SH ELF support.
+ * elf32-sh.c: New file.
+ * elf.c (prep_headers): Handle bfd_arch_sh.
+ * elfcode.h (write_relocs): Handle absolute symbol.
+ * elf-bfd.h (_bfd_elf32_link_read_relocs): Declare.
+ (_bfd_elf64_link_read_relocs): Declare.
+ * elflink.h (NAME(_bfd_elf,link_read_relocs)): Rename from
+ elf_link_read_relocs. Make globally visible. Change all
+ callers.
+ (elf_link_input_bfd): Get external symbols from cache in
+ symtab_hdr->contents. Get contents from cache in
+ elf_section_data.
+ * elfxx-target.h (bfD_elfNN_bfd_relax_section): Only define if not
+ already defined.
+ * reloc.c: Define BFD_RELOC_SH_* relocs.
+ * libbfd-in.h (_bfd_sh_align_load_span): Declare.
+ * coff-sh.c (sh_insns_conflict): Fix a return value.
+ (_bfd_sh_align_load_span): New globally visible function, broken
+ out of sh_align_load.
+ (sh_align_load): Call _bfd_sh_align_load_span.
+ (sh_swap_insns): Change relocs parameter to PTR.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * targets.c (bfd_elf32_sh_vec): Declare.
+ (bfd_elf32_shl_vec): Declare.
+ * config.bfd (sh-*-elf*): New target.
+ * configure.in (bfd_elf32_sh_vec): New target vector.
+ (bfd_elf32_shl_vec): New target vector.
+ * configure: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add elf32-sh.o.
+ (BFD32_BACKENDS_CFILES): Add elf32-sh.c.
+
+ * elf.c (map_sections_to_segments): Check that LMA does not skip a
+ page before checking D_PAGED.
+
+ * ihex.c (ihex_scan): Removed unnecessary extbase variable.
+ (ihex_write_object_contents): Remove extbase; always use segbase
+ instead.
+
+Thu Aug 29 16:52:17 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * configure.in (i[345]86-*-*): Recognize i686 for pentium pro.
+ * configure.host (i[345]86-*-*): Ditto.
+ * config.bfd (i[345]86-*-*): Ditto.
+ * configure: Regenerate.
+
+ * config.bfd (i[3456]86-*-dgux*): Recognize as a synonym for x86
+ elf.
+
+Tue Aug 27 09:18:18 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-hppa.c (hppa_elf_gen_reloc_type): Add new argument.
+ * elf32-hppa.h (hppa_elf_gen_reloc_type): Update prototype.
+ * som.c (hppa_som_gen_reloc_type): Add new argument. If
+ we encounter an R_DATA_ONE_SYMBOL reloc against a symbol that
+ will have an ST_CODE type, change the symbol's type to ST_DATA.
+ * som.c (hppa_som_gen_reloc_type): Update prototype.
+
+Tue Aug 27 00:12:22 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_check_relocs): Set dynobj if needed for
+ R_MIPS_32 and R_MIPS_REL32. Set sgot and g as soon as possible.
+ (mips_elf_size_dynamic_sections): Don't require .got to exist.
+ (mips_elf_finish_dynamic_sections): Likewise.
+
+Thu Aug 22 10:54:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host (HLDENV): New variable to set. Set it for
+ *-*-sysv4*, since those linkers may not support -R but they always
+ support LD_RUN_PATH.
+
+ * libieee.h (NSECTIONS): Don't define.
+ (ieee_data_struct): Change section_table to asection **. Add
+ section_table_size.
+ * ieee.c (get_section_entry): If the table isn't big enough, make
+ it bigger.
+ (ieee_slurp_sections): Remove assertion about number of sections.
+ (ieee_object_p): Adjust initialization of ieee to match changes to
+ the structure.
+
+ * xcofflink.c (xcoff_mark): Don't copy relocs for undefined
+ symbols merely because we are generating a shared library.
+ (xcoff_build_ldsyms): Don't set up global linkage code for an
+ undefined symbol merely because we are generating a shared
+ library.
+
+Tue Aug 20 15:06:05 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * Makefile.in (ALL_MACHINES): Add cpu-v850.o.
+ (BFD32_BACKENDS) Add elf32-v850.o.
+ * archures.c: Add bfd_v850_arch.
+ * bfd-in2.h: Add bfd_v850_arch.
+ * config.bfd (v850-*-*): New target.
+ * configure: (bfd_elf32_v850_vec) New vector.
+ * configure.in: (bfd_elf32_v850_vec) New vector.
+ * cpu-v850.c: New file.
+ * elf.c (prep_headers): Added case bfd_arch_v850.
+ * elf32-v850.c: New file.
+ * targets.c (bfd_elf32_v850_vec): New vector.
+
+Fri Aug 16 16:25:35 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_dynamic_symbols): Create and define
+ a function code symbol for an XMC_XO symbol.
+
+Thu Aug 15 12:33:29 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Update editing of autoconf vars to reflect
+ Jul 18 configure.in change.
+ * mpw-make.sed: Update editing of include pathnames to be
+ more general, add @DASH_C_FLAG@ to explicit compile rule edit.
+
+Thu Aug 15 10:35:13 1996 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (elf64_alpha_output_extsym): The section from
+ which to offset to get the .plt entry address is ".plt".
+
+Thu Aug 15 16:40:30 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * reloc.c: (BFD_RELOC_ARM_THUMB_ADD, BFD_RELOC_ARM_THUMB_IMM,
+ BFD_RELOC_ARM_THUMB_SHIFT, BFD_RELOC_ARM_THUMB_OFFSET):
+ Added, for internal use by the ARM gas.
+ * libbfd.h: Rebuilt
+ * bfd-in2.h: Rebuilt
+
+Wed Aug 14 17:02:09 1996 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Correct typo
+ in section dynidx start.
+
+Tue Aug 13 14:35:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (_bfd_elf_make_section_from_shdr): Treat sections whose
+ name begins with .gnu.linkonce as SEC_LINK_ONCE. This is an
+ optimization for g++.
+
+Tue Aug 13 17:04:40 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_merge_private_bfd_data): If one module has
+ the -mrelocatable-lib bit set and the other doesn't, clear the
+ -mrelocatable-lib bit in the header.
+
+Sat Aug 10 22:59:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_link_add_object_symbols): Do not resolve a common
+ symbol against a STT_FUNC symbol in a shared library.
+
+Fri Aug 9 12:44:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_dynamic_symbols): If a descriptor
+ symbol is found, automatically define the corresponding function
+ code.
+
+ * cofflink.c (coff_link_add_symbols): Only set (*sym_hash)->numaux
+ if sym.n_numaux is not zero.
+ (_bfd_coff_link_input_bfd): Permit the symbol and the hash table
+ entry to disagree about the number of aux entries if the symbol
+ has zero.
+
+ * elf32-mips.c (mips_elf_check_relocs): Create the .rel.dyn
+ section if it might be needed, not just if info->shared.
+ (mips_elf_adjust_dynamic_symbol): Make room for a null element at
+ the start of .rel.dyn if we are going to use it.
+ (mips_elf_finish_dynamic_sections): Only clear the first element
+ of .rel.dyn if the size is greater than zero.
+
+Thu Aug 8 16:24:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_input_bfd): If we already called the
+ undefined_symbol callback for a symbol, then don't issue any more
+ warnings about loader relocs.
+ (_bfd_ppc_xcoff_relocate_section): Don't do any further processing
+ after calling the undefined_symbol callback.
+
+ * xcofflink.c (XCOFF_MULTIPLY_DEFINED): Define.
+ (xcoff_link_add_symbols): Permit multiple definitions of a symbol
+ as the AIX linker seems to do.
+
+Thu Aug 8 12:21:56 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * evax-alpha.c (evax_alpha_vec): Corrected flags, cleanup.
+ (evax_initialize): Remove evax_reloc_table.
+ (evax_close_and_cleanup): Ditto.
+ (reloc_nil): Ditto.
+ (alpha_howto_table): Remove ALPHA_R_SWREL32 and ALPHA_R_SWREL64
+ entries.
+ (evax_bfd_reloc_type_lookup): Ditto.
+ * evax-egsd.c (_bfd_evax_slurp_egsd): Add a few casts; set
+ cooked_size == raw_size.
+ * evax-emh.c (_bfd_evax_register_filename): Remove.
+ * evax-etir.c (etir_stc): Allow ETIR_S_C_STC_xx commands.
+ * evax-misc.c (add_new_contents): Malloc section at full size.
+ (_bfd_save_evax_section): Memcpy section contents directly.
+ * evax.h (ALPHA_R_SWREL32, ALPHA_R_SWREL64): Remove.
+ (evax_reloc_table): Remove.
+
+ * hosts/alphavms.h (O_ACCMODE): Define if needed.
+
+ * makefile.vms: Add better support for DEC C compilation
+ Add evax.h dependencies
+
+ * reloc.c (bfd_get_reloc_size): Add case for 16 byte reloc.
+ (BFD_RELOC_SWREL32,BFD_RELOC_SWREL64): Remove.
+ (BFD_RELOC_ALPHA_BASEREG): Remove.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+Thu Aug 8 08:17:32 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * archive.c (bsd_write_armap): Ifdef around calls to getuid and
+ getgid if _WIN32 is defined.
+ * opncls.c (bfd_fdopenr): Remove unnecessary WINGDB ifdef.
+
+Wed Aug 7 23:19:00 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * aoutx.h bfd-in.h bfd-in2.h opncls.c riscix.c som.c targets.c:
+ Change NO_FLAGS to BFD_NO_FLAGS to avoid conflict with an HPUX
+ include file.
+ * libbfd.c: Create dummy getpagesize() macro if HAVE_GETPAGESIZE
+ isn't defined.
+
+Wed Aug 7 14:11:44 1996 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * configure.in: Call BFD_NEEDED_DECLARATION on strstr and
+ realloc.
+ * acconfig.h (NEED_DECLARATION_STRSTR): New macro.
+ (NEED_DECLARATION_REALLOC): New macro.
+ * configure, config.in: Rebuild.
+ * sysdep.h (strstr): Declare if NEED_DECLARATION_STRSTR.
+ (realloc): Declare if NEED_DECLARATION_REALLOC.
+
+ * aclocal.m4 (BFD_NEED_DECLARATION): Include <string.h> or
+ <strings.h> if they exist.
+
+ * ieee.c (ieee_set_section_contents): Cast bfd_alloc return.
+
+Wed Aug 7 12:12:03 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cpu-i386.c (i8086_arch): Architecture info for the i8086.
+
+ Based on patches from Eric Valette <valette@crf.canon.fr>:
+ * elf32-i386.c (enum reloc_type): Add FIRST_INVALID_RELOC,
+ LAST_INVALID_RELOC, R_386_16, R_386_PC16, R_386_8, R_386_PC8.
+ (elf_howto_table): Add entries for new relocs.
+ (elf_i386_reloc_type_lookup): Handle new relocs.
+ (elf_i386_info_to_howto): Just call abort.
+ (elf_i386_info_to_howto_rel): Check that the reloc type is valid.
+ (elf_i386_relocate_section): Likewise.
+
+Tue Aug 6 12:54:56 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * elf32-d10v.c (elf_d10v_howto_table): Added R_D10V_32.
+
+Mon Aug 5 13:42:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (_bfd_elf_make_section_from_shdr): For a loadable section,
+ only get the LMA from the phdr if they are in the same part of the
+ file.
+
+ * elf.c (map_sections_to_segments): Rewrite tests for starting a
+ new segment to make them more comprehensible. If the relationship
+ between the LMA and the VMA changed, start a new segment. Don't
+ check dynsec when deciding whether to start a new segment for a
+ writeable section; -N will now handle this.
+
+Thu Aug 1 22:43:08 1996 Jeffrey A Law (law@cygnus.com)
+
+ * libhppa.h: Remove "esel" changes. Not the right approach.
+ * som.c: Corresponding changes.
+ (som_bfd_derive_misc_symbol_info): Use ST_DATA for symbols
+ which don't have a SOM symbol type associated with them.
+ Reverses a 1994 change.
+
+Wed Jul 31 15:50:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Make ld -N more reasonable for ELF:
+ * elf.c (map_sections_to_segments): If D_PAGED is not set, set
+ phdr_in_section to false, and always use a single load segment.
+ (elf_sort_sections): Sort sections by LMA after VMA.
+ (assign_file_positions_for_segments): If D_PAGED is not set, don't
+ align to maxpagesize.
+ (assign_file_positions_except_relocs): Likewise.
+ * elfcode.h (elf_object_p): If a section is loaded but not page
+ aligned, clear D_PAGED.
+
+Wed Jul 31 15:00:12 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * reloc.c: (BFD_RELOC_ARM_OFFSETIMM8, BFD_RELOC_ARM_HWLITERAL):
+ Added, for internal use by the ARM gas.
+ * libbfd.h: Rebuilt
+ * bfd-in2.h: Rebuilt
+
+Tue Jul 30 14:14:57 1996 Jeffrey A Law (law@cygnus.com)
+
+ * libhppa.h (R_HPPA_ESEL): New field selector.
+ (e_esel): Similarly.
+ * som.c (hppa_som_gen_reloc_type): If we encounter an e_esel,
+ then generate R_COMP2 (PUSH_SYM), R_DATA_EXPR fixup stream.
+ (som_write_fixups): Handle R_DATA_EXPR just like R_CODE_EXPR.
+
+Tue Jul 30 13:31:27 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Do the regular
+ archive search before looking for stripped dynamic objects.
+
+Fri Jul 26 17:51:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_build_ldsyms): Make exporting an undefined
+ symbol a warning rather than an error.
+
+Wed Jul 24 12:02:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): Track the virtual
+ memory position separately from the file position, and use it to
+ compute the alignment adjustment.
+
+Tue Jul 23 10:43:31 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * elf32-d10v.c (elf_d10v_howto_table): Changed all relocs to "long"
+ and fixed mask on R_D10V_10_PCREL_L.
+
+Mon Jul 22 15:30:30 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf64-mips.c: Include "aout/ar.h".
+ (mips_elf64_slurp_armap): New static function.
+ (mips_elf64_write_armap): New static function.
+ (bfd_elf64_archive_*): Define.
+ * elfxx-target.h (bfd_elfNN_archive_p): Define if not defined.
+ Use instead of bfd_generic_archive_p.
+ (bfd_elfNN_write_archive_contents): Define if not defined. Use
+ instead of _bfd_write_archive_contents.
+ (bfd_elfNN_mkdarchive): Define if not defined. Use instead of
+ _bfd_generic_mkarchive.
+ (TARGET_BIG_SYM): If bfd_elfNN_archive_functions is defined, use
+ bfd_elfNN_archive in BFD_JUMP_TABLE_ARCHIVE rather than
+ _bfd_archive_coff.
+ (TARGET_LITTLE_SYM): Likewise.
+ * archive.c (bfd_slurp_armap): Check for and reject an archive map
+ name of /SYM64/.
+ * Makefile.in: Rebuild dependencies.
+
+ * elf32-mips.c (_bfd_mips_elf_final_write_processing): Handle
+ SHT_MIPS_LIBLIST, SHT_MIPS_CONTENT, SHT_MIPS_SYMBOL_LIB, and
+ SHT_MIPS_EVENTS sections.
+ (_bfd_mips_elf_section_from_shdr): Handle SHT_MIPS_IFACE,
+ SHT_MIPS_CONTENT, SHT_MIPS_SYMBOL_LIB, and SHT_MIPS_EVENTS
+ sections.
+ (_bfd_mips_elf_fake_sections): Likewise.
+
+ * libecoff.h (ecoff_data_type): Add rdata_in_text field.
+ * ecoff.c (ecoff_compute_section_file_positions): Copy
+ rdata_in_text from backend info to tdata. Clear it if any data
+ section comes before .rdata.
+ (_bfd_ecoff_write_object_contents): Use rdata_in_text field in
+ tdata rather than backend info.
+
+Fri Jul 19 18:15:51 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Fix test for whether a compiler has a 64 bit
+ type. From Jim Wilson <wilson@cygnus.com>.
+
+Thu Jul 18 15:39:10 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host (mips-sgi-irix6*): New host.
+
+ * configure.in: Set and substitute VERSION, BFD_HOST_64BIT_LONG
+ (replacing HOST_64BITLONG), BFD_HOST_64_BIT_DEFINED,
+ BFD_HOST_64_BIT, and BFD_HOST_U_64_BIT. Add bfd-in2.h:bfd-in2.h
+ to AC_OUTPUT call.
+ * configure: Rebuild.
+ * bfd-in.h (BFD_ARCH_SIZE): Define as @wordsize@, not @WORDSIZE@.
+ (BFD_HOST_64_BIT): Define conditionally.
+ (BFD_HOST_U_64_BIT): Define when BFD_HOST_64_BIT is defined.
+ (bfd_vma): Typedef as BFD_HOST_U_64_BIT.
+ (symvalue, bfd_size_type): Likewise.
+ * bfd-in2.h: Rebuild.
+ * Makefile.in (do_clean): Remove bfd-tmp.h.
+ (do_distclean): Remove bfd-in3.h.
+ (stmp-bfd.h): Just do copy-if-change bfd-in3.h bfd.h.
+ (bfd-in3.h): New target.
+
+ * config.bfd (sparc-*-sysv4*): Don't build sunos_big_vec. From
+ Andrew Gierth <ANDREWG@microlise.co.uk>.
+
+ * configure.host: Set INSTALL_SHLIB.
+ * configure.in: Call AC_SUBST (INSTALL_SHLIB).
+ * configure: Rebuild.
+ * Makefile.in (install): Use @INSTALL_SHLIB@.
+
+ * config.bfd (mips*-*-irix6*): New target.
+ * configure.host: Handle Irix 6 shared library like Irix 5.
+
+ * xcofflink.c (xcoff_link_add_symbols): Don't check an XMC_TD
+ symbol for a magic name.
+ (xcoff_link_input_bfd): Don't change the reloc symbol for an
+ XMC_TD symbol.
+ (_bfd_ppc_xcoff_relocate_section): Don't get the TOC offset for an
+ XMC_TD symbol.
+
+Thu Jul 18 11:36:31 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Add ELF support to mips config, create the
+ elf32-target.h file in the object dir.
+ * mpw-make.sed: Edit elfXX-target.h refs at beginnings of lines.
+
+Wed Jul 17 18:02:32 1996 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c: Redid debug scheme - numerous fprintf's gone.
+ Also removed most abort calls, in favor of using bfd reporting.
+
+Wed Jul 17 14:51:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * Makefile.in (ALL_MACHINES): Add cpu-d10v.o.
+ (BFD32_BACKENDS) Add elf32-d10v.o.
+ * archures.c: Add bfd_d10v_arch.
+ * bfd-in2.h: Add bfd_d10v_arch.
+ * config.bfd (d10v-*-*): New target.
+ * configure: (bfd_elf32_d10v_vec) New vector.
+ * configure.in: (bfd_elf32_d10v_vec) New vector.
+ * cpu-d10v.c: New file.
+ * elf.c (prep_headers): Added case bfd_arch_d10v.
+ * elf32-d10v.c: New file.
+ * libbfd.h: Rebuild.
+ * reloc.c (BFD_RELOC_D10V_10_PCREL_R, BFD_RELOC_D10V_10_PCREL_L,
+ BFD_RELOC_D10V_18, BFD_RELOC_D10V_18_PCREL): Define.
+ * targets.c (bfd_elf32_d10v_vec): New vector.
+
+Wed Jul 17 10:58:55 1996 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (coff_ppc_relocate_section): Removed bogus fprintf
+
+Tue Jul 16 23:49:02 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * archures.c bfd-in2.h: Add bfd_mach_i386_i386 and
+ bfd_mach_i386_i8086 machine types.
+
+Wed Jul 10 12:42:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_new_section_hook): Set SEC_CODE for _INIT
+ and _FINI sections.
+
+Wed Jul 10 11:18:21 1996 Richard Henderson <rth@tamu.edu>
+
+ * coffcode.h (coff_set_section_contents): A/UX does not require
+ special handling of the _LIB section.
+
+Tue Jul 9 15:52:20 1996 Jeffrey A Law (law@cygnus.com)
+
+ * coff-h8300.c (h8300_reloc16_extra_cases): Use the correct
+ value for R_RELBYTE.
+
+ * reloc16.c (bfd_coff_reloc16_relax_section): Only "shrinks"
+ array if one was allocated.
+
+Tue Jul 9 12:21:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ From Kazumoto Kojima <kkojima@kk.info.kanagawa-u.ac.jp>:
+ * elf32-mips.c (struct mips_elf_link_hash_table): Add new fields
+ use_rld_obj_head and rld_value.
+ (mips_elf_link_hash_table_create): Initialize new fields.
+ (mips_elf_add_symbol_hook): Mark __rld_obj_head symbol as
+ dynamic.
+ (mips_elf_create_dynamic_sections): Create .rld_map section. If
+ __rld_obj_head symbol not seen, create an __rld_map symbol.
+ (mips_elf_size_dynamic_sections): Make space in .rld_map section.
+ Create a DT_MIPS_RLD_MAP entry rather than a DT_DEBUG entry.
+ (mips_elf_finish_dynamic_symbol): Save value of __rld_map or
+ __rld_obj_head symbol.
+ (mips_elf_finish_dynamic_sections): Handle DT_MIPS_RLD_MAP.
+
+Mon Jul 8 16:18:03 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_reloc_map): Remove BFD_RELOC_32_PCREL entry.
+
+ * elf32-ppc.c (ppc_elf_howto_raw): For R_PPC_ADDR16_HA, use
+ ppc_elf_addr16_ha_reloc.
+ (ppc_elf_addr16_ha_reloc): New static function.
+
+ * coff-mips.c (struct mips_hi): Define.
+ (mips_refhi_list): New static variable.
+ (mips_refhi_addr, mips_refhi_addend): Remove.
+ (mips_refhi_reloc): Maintain a list of unmatched REFHI relocs.
+ (mips_reflo_reloc): Process mips_refhi_list.
+ (mips_relhi_list): New static variable.
+ (mips_relhi_addr, mips_relhi_addend): Remove.
+ (mips_relhi_reloc): Maintain a list of unmatched RELHI relocs.
+ (mips_rello_reloc): Process mips_relhi_list.
+ (mips_relocate_section): Permit an arbitrary number of REFHI or
+ RELHI relocs before the associated REFLO or RELLO reloc.
+
+Fri Jul 5 19:27:49 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aout-target.h (MY(callback)): Set reloc_count fields.
+
+Thu Jul 4 12:00:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (sunos_add_dynamic_symbols): Don't create dynamic
+ sections unless this is a SunOS link.
+
+ * VERSION: Set to 2.7.1.
+
+ * Released binutils 2.7.
+
+Wed Jul 3 14:59:47 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386aout.c: Include "aout/aout64.h".
+ (i386aout_write_object_contents): New static function.
+ (MY_write_object_contents): Define.
+
+ * netbsd.h (MY(write_object_contents)): Make sure that
+ adjust_sizes_and_vmas is called before fiddling with the magic
+ number.
+
+Tue Jul 2 23:30:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * stabs.c (_bfd_link_section_stabs): Fix casts of psinfo.
+
+Sun Jun 30 13:34:33 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libbfd-in.h (itos, stoi): Don't define.
+ * libbfd.h: Rebuild.
+ * i386lynx.c (KEEPIT): Define as udata.i.
+ (NAME(lynx,swap_std_reloc_out)): Don't use stoi.
+ (NAME(lynx,swap_ext_reloc_out)): Likewise.
+ * riscix.c (riscix_swap_std_reloc_out): Use udata.i rather than
+ flags. Don't use stoi.
+
+ * elf32-mips.c (ELF_MAGPAGESIZE): Change definition to 0x1000.
+
+ * elf.c (map_sections_to_segments): Don't start a new segment for
+ a writable section if it's on the same page as the previous
+ segment. Reset the writable variable for a readonly section.
+
+Sat Jun 29 16:18:51 1996 Kim Knuttila <krk@cygnus.com>
+
+ * peicode.h (coff_swap_aouthdr_in): Missing initializations of
+ first_thunk_address, thunk_size, and import_table_size.
+ * peicode.h: Improved some diagnostics regarding edata sections.
+
+ * coff-ppc.c (coff_ppc_relocate_section): Earlier error check
+ on IMGLUE relocs.
+ (coff_ppc_relocate_section): Improved diagnostic for large TOCDEFN's.
+ (TARGET_LITTLE_SYM): Added missing D_PAGED.
+
+Fri Jun 28 13:48:45 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_check_ar_symbols): An undefined symbol
+ with XCOFF_DEF_DYNAMIC set is really defined.
+ (xcoff_link_check_dynamic_ar_symbols): Likewise.
+ (xcoff_link_add_symbols): Only create special sections if using an
+ XCOFF hash table.
+
+ * reloc.c (bfd_perform_relocation): Handle xcoff-powermac like
+ aixcoff-rs6000.
+ (bfd_install_relocation): Likewise.
+
+Fri Jun 28 11:17:00 1996 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (struct alpha_elf_link_hash_entry): Add flags
+ field.
+ (ALPHA_ELF_LINK_HASH_LU_ADDR): Define.
+ (ALPHA_ELF_LINK_HASH_LU_MEM): Define.
+ (ALPHA_ELF_LINK_HASH_LU_FUNC): Define.
+ (elf64_alpha_link_hash_newfunc): Initialize flags field.
+ (elf64_alpha_check_relocs): Record types of LITUSE entries that
+ are found for LITERAL relocs.
+ (elf64_alpha_adjust_dynamic_symbol): If a symbol has its address
+ taken, we cannot generate a .plt entry for the symbol.
+
+Thu Jun 27 11:24:29 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Add AC_ISC_POSIX, and check for setitimer and
+ sysconf functions (for gprof).
+ * configure, config.in: Rebuild.
+
+Wed Jun 26 16:29:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_archive_p): Check the first object file in
+ an archive if it has a map. If the object file has the wrong
+ xvec, reject it.
+
+ * coff-alpha.c (alpha_adjust_reloc_in): Set the addend for a
+ BRADDR, SREL16, SREL32, or SREL64 reloc against an external
+ symbol.
+ (alpha_relocate_section): Likewise.
+
+ * coffswap.h (coff_swap_reloc_out): Use RELSZ, not sizeof.
+ (coff_swap_filehdr_out): Use FILHSZ, not sizeof.
+ (coff_swap_sym_out): Use SYMESZ, not sizeof.
+ (coff_swap_aux_out): Use AUXESZ, not sizeof.
+ (coff_swap_lineno_out): Use LINESZ, not sizeof.
+ (coff_swap_aouthdr_out): Use AOUTSZ, not sizeof.
+ (coff_swap_scnhdr_out): Use SCNHSZ, not sizeof.
+ * peicode.h: Corresponding changes.
+
+Tue Jun 25 15:28:34 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elflink.h (elf_create_pointer_linker_section): Comment out code
+ dealing with making GOT pointers negative of the GOT symbol for
+ now.
+
+Tue Jun 25 11:41:24 1996 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Don't
+ increment the .rela.plt size until after we're done creating the
+ .plt entry.
+ (elf64_alpha_finish_dynamic_symbol): Change .plt entry to load the
+ .rela.plt offset directly rather than calculating it.
+
+Mon Jun 24 17:15:10 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in, (bindir, libdir, datadir, mandir, infodir, includedir):
+ Use autoconf-set values.
+ * doc/Makefile.in (bindir, libdir, datadir, mandir, infodir,
+ includedir, INSTALL, INSTALL_PROGRAM, INSTALL_DATA): Use autoconf-set
+ values.
+ (docdir): Deleted.
+ * configure.in (AC_PREREQ): autoconf v2.5 or higher.
+ * configure: Rebuilt.
+
+Mon Jun 24 22:50:35 1996 Jeffrey A Law (law@cygnus.com)
+
+ * som.c (som_write_fixups): Fix typo in R_END_TRY for exception
+ handling code > 1k away.
+
+Mon Jun 24 18:41:06 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elflink.h (elf_create_pointer_linker_section): If DEBUG is
+ defined, output whenever the symbol is updated.
+
+Mon Jun 24 17:58:12 1996 Jouke Numan <jnuman@bazis.nl>
+
+ * elf.c (elf_fake_sections): Don't set sh_addr of a non SEC_ALLOC
+ section to 0 if user_set_vma is set.
+ * elflink.h (elf_bfd_final_link): Likewise.
+
+Sun Jun 23 20:42:51 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ Partially undo patch of Jun 20.
+ * coffcode.h (coff_set_alignment_hook): Use COFF_IMAGE_WITH_PE.
+ (coff_compute_section_file_positions): Likewise.
+ (coff_write_object_contents): Likewise. Re-add deleted code, but
+ use #ifdef COFF_WITH_PE, not COFF_OBJ_WITH_PE.
+ * peicode.h (pe_bfd_copy_private_bfd_data): Re-add #ifdef.
+
+Fri Jun 21 17:38:15 1996 Joel Sherrill <joel@merlin.gcs.redstone.army.mil>
+
+ * config.bfd: Add support for *-*-rtems* configurations.
+
+Fri Jun 21 15:19:59 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (prep_headers): Add bfd_arch_alpha case.
+
+Fri Jun 21 12:35:27 1996 Richard Henderson <rth@tamu.edu>
+
+ * elf64-alpha.c: New file.
+ * config.bfd (alpha-*-linuxecoff*): New target.
+ (alpha-*-linux*, alpha-*-elf*): New targets.
+ * configure.in (bfd_elf64_alpha_vec): New vector.
+ * configure: Rebuild.
+ * targets.c (bfd_elf64_alpha_vec): Declare.
+ (bfd_target_vector): Add bfd_elf64_alpha_vec if BFD64.
+ * reloc.c (BFD_RELOC_ALPHA_GPDISP): Define.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD64_BACKENDS): Add elf64-alpha.o.
+ (BFD64_BACKENDS_CFILES): Add elf64-alpha.c.
+
+Thu Jun 20 18:14:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (ecoff_armap_hash): If hlog is 0, just return 0, rather
+ than relying on a right shift of 32.
+
+Thu Jun 20 11:00:57 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * coffcode.h (coff_set_alignment_hook): Change COFF_IMAGE_WITH_PE
+ ifdef to COFF_WITH_PE.
+ (coff_compute_section_file_positions): Likewise.
+ (coff_write_object_contents): Likewise. Delete COFF_OBJ_WITH_PE.
+ * pe-{arm,i386,ppc}.c (COFF_OBJ_WITH_PE): Delete.
+ * peicode.h (pe_bfd_copy_private_bfd_data): Delete ifdef
+ COFF_IMAGE_WITH_PE, always include.
+
+ * peicode.h (coff_swap_scnhdr_out): ".drectve" doesn't have trailing 0.
+
+Wed Jun 19 11:37:52 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (map_sections_to_segments): Fix up the test for -Ttext to
+ approximate the correct answer if SIZEOF_HEADERS was not used.
+
+ * binary.c (binary_set_section_contents): Set section file
+ position based on LMA rather than VMA.
+
+Wed Jun 19 11:19:25 1996 Manfred Hollstein KS/EIC5 60/3/142 #40283 <manfred@lts.sel.alcatel.de>
+
+ * linker.c (_bfd_generic_link_output_symbols): Don't output any
+ symbols if info->strip == strip_all.
+
+Tue Jun 18 15:17:36 1996 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * coff-h8300.c: Remove #if 0 code.
+ (compatable): Don't allow mixing/matching of different architectures.
+
+ * archures.c (bfd_mach_h8300s): Add.
+ * bfd-in2.h: Rebuilt.
+ * coff-h8300.c (funcvec_hash_newfunc): Handle H8/S too.
+ (BADMAG): Likewise.
+ (h8300_reloc16_estimate): Likewise.
+ (h8300_reloc16_extra_cases): Likewise.
+ (h8300_bfd_link_add_symbols): Likewise.
+ * coffcode.h (coff_set_arch_mach_hook): Likewise.
+ (coff_set_flags): Likewise.
+ * cpu-h8300.c (h8300_scan): Likewise.
+ Add H8/S to bfd_h8300_arch list.
+
+Tue Jun 18 14:42:58 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ Added support for Alpha OpenVMS:
+ * evax.h, evax-alpha.c, evax-egsd.c, evax-emh.c: New files.
+ * evax-etir.c, evax-misc.c, hosts/alphavms.h: New files.
+ * config.h-vms, makefile.vms: New files.
+ * config.bfd (alpha-*-*vms*): New target.
+ * configure.in (evax_alpha_vec): New target vector.
+ * configure: Rebuild.
+ * reloc.c (BFD_RELOC_SWREL32, BFD_RELOC_SWREL64): Define.
+ (BFD_RELOC_ALPHA_LINKAGE, BFD_RELOC_ALPHA_BASEREG): Define.
+ * targets.c (bfd_target_evax_flavour): Define.
+ (evax_alpha_vec): Declare.
+ (bfd_target_vector): Add ecoffalpha_little_vec and evax_alpha_vec
+ if BFD64 is defined.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD64_BACKENDS): Add evax-alpha.o, evax-egsd.o, evax-etir.o,
+ evax-emh.o, and evax-misc.o.
+ (BFD64_BACKENDS_CFILES): Add evax-alpha.c, evax-egsd.c,
+ evax-etir.c, evax-emh.c, and evax-misc.c.
+ (HFILES): Add evax.h.
+
+Tue Jun 18 13:54:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-h8300.c (h8300_reloc16_extra_cases): Make name a const
+ pointer.
+ (h8300_bfd_link_add_symbols): Likewise.
+
+Mon Jun 17 10:06:50 1996 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * som.h (R_HPPA_BEGIN_TRY, R_HPPA_END_TRY): Define.
+ * som.c (som_write_fixups): Handle R_BEGIN_TRY and R_END_TRY.
+
+Mon Jun 17 12:49:11 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_relocate_section): Don't create a reloc
+ for R_MIPS_REL32 and R_MIPS_32 relocs if no dynamic sections were
+ created.
+ (mips_elf_check_relocs): Only create .rel.dyn for R_MIPS_REL32 and
+ R_MIPS_32 relocs if creating a shared library.
+
+Thu Jun 13 20:14:51 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * peicode.h (add_data_entry): Use pei_section_data rather than
+ _cooked_size. Corresponds to May 13 change in coffcode.h.
+
+Thu Jun 13 10:23:40 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_final_link): Handle long section names.
+ * coffcode.h (coff_write_object_contents): If there are long
+ section names, always set the f_symptr field, even if there are no
+ symbols.
+ * peicode.h (coff_swap_filehdr_in): Don't clear the f_symptr field
+ if there are no symbols.
+
+ * coffgen.c (make_a_section_from_file): Check return value of
+ _bfd_coff_read_string_table.
+ (coff_real_object_p): Check return value of
+ make_a_section_from_file.
+ (_bfd_coff_read_string_table): Check that there are some symbols
+ before trying to read the string table size.
+
+Wed Jun 12 11:16:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_symbols): When considering whether
+ to replace a symbol in a dynamic object with a symbol from another
+ dynamic object, do the replacement if the existing symbol is
+ global linkage code.
+
+ * xcofflink.c (_bfd_ppc_xcoff_relocate_section): Check explicitly
+ for _ptrgl, and treat it as global linkage code.
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Notice if we find a
+ filename or N_SO symbol past the offset, and use it to indicate
+ that there is no line number or function when appropriate.
+
+Tue Jun 11 15:24:48 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_build_ldsyms): Set XCOFF_DEF_REGULAR for a
+ common symbol defined by the linker. Don't export function code
+ even if export_defineds is set.
+
+Mon Jun 10 11:57:27 1996 Jeffrey A Law (law@cygnus.com)
+
+ * coff-h8300.c (howto_table): Add new entries for R_BCC_INV
+ and R_JMP_DEL.
+ (rtype2howto): Handle R_BCC_INV and R_JMP_DEL.
+ (h8300_symbol_address_p): New function.
+ (h8300_reloc16_estimate): Eliminate jumps made unnecessary by
+ relaxing.
+
+Sun Jun 9 16:30:20 1996 Jeffrey A Law (law@cygnus.com)
+
+ * coff-h8300.c (h8300_reloc16_estimate): Fix many minor spacing
+ problems.
+ (h8300_reloc16_estimate, cases R_JMP1, R_JMP2): Adjust "dot"
+ correctly for the two variants. Allow relaxing if the target
+ is 128 bytes away since after relaxation it'll be 126 bytes away.
+ (h8300_reloc16_estimate, case R_PCRWORD): Correctly adjust
+ "dot" and "value". Allow relaxing if the target is 128 bytes
+ away since after relaxation it'll be 126 bytes away.
+ * reloc16.c (bfd_coff_reloc16_relax_section): Keep relaxing
+ the given section until nothing changes.
+
+Thu Jun 6 15:24:45 1996 Richard Henderson <rth@tamu.edu>
+
+ * ecoff.c (_bfd_ecoff_new_section_hook): Remove the _PDATA
+ alignment hack--we can get the lnnoptr info another way without
+ suddenly increasing the alignment requirements. Set the flags for
+ the _PDATA section.
+ (ecoff_compute_section_file_positions): Do so.
+
+Thu Jun 6 11:24:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_write_object_contents): Put a timestamp in the file
+ to keep the HP emulator database happy.
+
+ * config.bfd: Recognize powerpc-*-linux* and powerpcle-*-linux*.
+ From Kevin Buettner <kev@primenet.com>.
+
+Wed Jun 5 15:16:04 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (translate_to_native_sym_flags): Don't try to print the
+ name of a NULL section.
+
+Tue Jun 4 18:53:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * linker.c (_bfd_generic_link_add_one_symbol): If notice_all is
+ set, always call the notice callback.
+
+ * VERSION: Increment for bfdlink.h change.
+
+Mon Jun 3 11:01:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (COFF_DEFAULT_SECTION_ALIGNMENT_POWER): Set to 4.
+ (sh_relax_delete_bytes): Correct handling of differently sized
+ trailing alignment reloc.
+
+ * bfd-in.h: Use #error if BFD_HOST_64_BIT can not be defined.
+ * bfd-in2.h: Rebuild.
+ * configure.in: Warn if there is no known 64 bit type.
+ * configure: Rebuild.
+
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add ppcboot.o.
+ (BFD32_BACKENDS_CFILES): Add ppcboot.c.
+
+ * elf32-mips.c (mips_elf_size_dynamic_sections): Initialize c.
+ From Per Fogelstrom <per.fogelstrom@mailbox200.swipnet.se>.
+
+Sat Jun 1 21:49:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf64-mips.c (bfd_mips_elf64_swap_reginfo_in)
+ (bfd_mips_elf64_swap_reginfo_out): Move from here...
+ * elf32-mips.c (bfd_mips_elf64_swap_reginfo_in)
+ (bfd_mips_elf64_swap_reginfo_out): ...to here.
+
+Fri May 31 13:51:28 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf64-mips.c: Improve reloc special_functions and handling of
+ SHT_MIPS_OPTIONS section.
+ * elf32-mips.c (_bfd_mips_elf_hi16_reloc): Rename from
+ mips_elf_hi16_reloc and make globally visible.
+ (_bfd_mips_elf_lo16_reloc): Rename from mips_elf_lo16_reloc and
+ make globally visible.
+ (_bfd_mips_elf_got16_reloc): Rename from mips_elf_got16_reloc and
+ make globally visible.
+ (_bfd_mips_elf_gprel16_reloc): Rename from mips_elf_gprel16_reloc
+ and make globally visible.
+ (gprel16_with_gp): Check howto->src_mask before using value in
+ insn.
+ (_bfd_mips_elf_gprel32_reloc): Rename from mips_elf_gprel32_reloc
+ and make globally visible.
+ (gprel32_with_gp): Check howto->src_mask before fetching value.
+ (bfd_mips_elf_swap_options_in): New function.
+ (bfd_mips_elf_swap_options_out): New function.
+ (_bfd_mips_elf_set_private_flags): Rename from
+ mips_elf_set_private_flags and make globally visible.
+ (_bfd_mips_elf_copy_private_bfd_data): Rename from
+ mips_elf_copy_private_bfd_data and make globally visible.
+ (_bfd_mips_elf_merge_private_bfd_data): Rename from
+ mips_elf_merge_private_bfd_data and make globally visible.
+ (_bfd_mips_elf_section_from_shdr): Accept .MIPS.options as a name
+ for a SHT_MIPS_OPTIONS section.
+ (mips_elf32_section_from_shdr): Handle SHT_MIPS_OPTIONS section.
+ (_bfd_mips_elf_fake_sections): Consider .MIPS.options to be the
+ name of a SHT_MIPS_OPTIONS section.
+ (_bfd_mips_elf_set_section_contents): New function.
+ (mips_elf32_section_processing): Set the GP value in a
+ SHT_MIPS_OPTIONS section.
+ (_bfd_mips_elf_find_nearest_line): Rename from
+ mips_elf_find_nearest_line and make globally visible.
+ (bfd_elf32_set_section_contents): Define.
+ * elf-bfd.h (_bfd_mips_elf_hi16_reloc): Declare.
+ (_bfd_mips_elf_lo16_reloc): Declare.
+ (_bfd_mips_elf_gprel16_reloc): Declare.
+ (_bfd_mips_elf_got16_reloc): Declare.
+ (_bfd_mips_elf_gprel32_reloc): Declare.
+ (_bfd_mips_elf_set_private_flags): Declare.
+ (_bfd_mips_elf_copy_private_bfd_data): Declare.
+ (_bfd_mips_elf_merge_private_bfd_data): Declare.
+ (_bfd_mips_elf_find_nearest_line): Declare.
+ (_bfd_mips_elf_set_section_contents): Declare.
+
+ * elf32-hppa.c (elf32_hppa_info_to_howto): Rename from
+ elf_info_to_howto.
+ (elf_info_to_howto): Define.
+ * elf32-sparc.c (elf32_sparc_info_to_howto): Rename from
+ elf_info_to_howto.
+ (elf_info_to_howto): Define.
+ * elf64-sparc.c (sparc64_elf_info_to_howto): Rename from
+ elf_info_to_howto.
+ (elf_info_to_howto): Define.
+
+ * coff-w65.c (h8300_reloc16_estimate): Rename R_MOVB[12] to
+ R_MOV16B[12], to match change in coff/internal.h.
+
+Thu May 30 12:38:49 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf64-mips.c: Extensive additions to provide better support for
+ writing files and for gas.
+ * elf32-mips.c (_bfd_mips_elf_object_p): New function, broken out
+ of mips_elf_object_p.
+ (mips_elf32_object_p): Rename from mips_elf_object_p; call
+ _bfd_mips_elf_object_p.
+ (_bfd_mips_elf_final_write_processing): Rename from
+ mips_elf_final_write_processing and make globally visible.
+ (_bfd_mips_elf_fake_sections): Rename from
+ mips_elf_fake_sections and make globally visible.
+ (_bfd_mips_elf_section_from_bfd_section): Rename from
+ mips_elf_section_from_bfd_section and make globally visible.
+ (_bfd_mips_elf_section_processing): New function, broken out of
+ mips_elf_section_processing.
+ (mips_elf32_section_processing): Rename from
+ mips_elf_section_processing; call
+ _bfd_mips_elf_section_processing.
+ (_bfd_mips_elf_symbol_processing): Rename from
+ mips_elf_symbol_processing and make globally visible.
+ (_bfd_mips_elf_read_ecoff_info): Rename from
+ mips_elf_read_ecoff_info and make globally visible.
+ (mips_elf32_ecoff_debug_swap): Rename from
+ mips_elf_ecoff_debug_swap.
+ * elf.c (_bfd_elf_symbol_from_bfd_symbol): Use asymbol rather than
+ struct symbol_cache_entry.
+ (_bfd_elf_validate_reloc): New function, moved in from
+ elfcode.h:validate_reloc.
+ * elfcode.h (validate_reloc): Remove; moved into elf.c and renamed
+ to _bfd_elf_validate_reloc. Change all callers.
+ * elf-bfd.h (bfd_section_from_shdr): Declare.
+ (_bfd_elf_symbol_from_bfd_symbol): Declare.
+ (_bfd_elf_validate_reloc): Declare.
+ (_bfd_mips_elf_object_p): Declare.
+ (_bfd_mips_elf_fake_sections): Declare.
+ (_bfd_mips_elf_section_from_bfd_section): Declare.
+ (_bfd_mips_elf_section_processing): Declare.
+ (_bfd_mips_elf_symbol_processing): Declare.
+ (_bfd_mips_elf_read_ecoff_info): Declare.
+ (_bfd_mips_elf_final_write_processing): Declare.
+ * elfxx-target.h (bfd_elfNN_get_reloc_upper_bound): Don't define
+ if already defined.
+
+ * elf32-mips.c (mips_elf_object_p): Handle E_MIPS_ARCH_4.
+ (mips_elf_final_write_processing): Likewise.
+
+Wed May 29 16:15:29 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ 64-bit MIPS ELF ABI objdump support:
+ * elf64-mips.c: New file.
+ * Makefile.in: Rebuild dependencies.
+ (BFD64_BACKENDS): Add elf64-mips.o.
+ (BFD64_BACKENDS_CFILES): Add elf64-mips.c.
+ * config.bfd (mips*el-*-elf*) Add bfd_elf64_bigmips_vec and
+ bfd_elf64_littlemips_vec to targ_selvecs.
+ (mips*-*-elf*): Likewise.
+ * confingure.in: Add bfd_elf64_bigmips_vec and
+ bfd_elf64_littlemips_vec to vector switch.
+ * configure: Rebuild.
+ * elf32-mips.c (_bfd_mips_elf_section_from_shdr): New function,
+ broken out of mips_elf_section_from_shdr.
+ (mips_elf32_section_from_shdr): Rename from
+ mips_elf_section_from_shdr. Call new function.
+ (elf_backend_section_from_shdr): Update name of renamed function.
+ * elf-bfd.h (struct elf_size_info): Change second parameter of
+ write_out_phdrs to be const. Likewise for second parameter of
+ swap_symbol_out.
+ (struct bfd_elf_section_data): Add rel_hdr2 field.
+ (bfd_elf32_swap_symbol_in): Change second parameter to be const.
+ (bfd_elf32_swap_symbol_out): Likewise.
+ (bfd_elf32_swap_reloc_in): Likewise.
+ (bfd_elf32_swap_reloc_out): Likewise.
+ (bfd_elf32_swap_reloca_in): Likewise.
+ (bfd_elf32_swap_reloca_out): Likewise.
+ (bfd_elf32_swap_phdr_in): Likewise.
+ (bfd_elf32_swap_phdr_out): Likewise.
+ (bfd_elf32_swap_dyn_in): Likewise.
+ (bfd_elf32_swap_dyn_out): Likewise.
+ (bfd_elf32_slurp_symbol_table): Declare.
+ (bfd_elf32_write_shdrs_and_ehdr): Declare.
+ (bfd_elf32_write_out_phdrs): Declare.
+ (bfd_elf64_swap_symbol_in): Change second parameter to be const.
+ (bfd_elf64_swap_symbol_out): Likewise.
+ (bfd_elf64_swap_reloc_in): Likewise.
+ (bfd_elf64_swap_reloc_out): Likewise.
+ (bfd_elf64_swap_reloca_in): Likewise.
+ (bfd_elf64_swap_reloca_out): Likewise.
+ (bfd_elf64_swap_phdr_in): Likewise.
+ (bfd_elf64_swap_phdr_out): Likewise.
+ (bfd_elf64_swap_dyn_in): Likewise.
+ (bfd_elf64_swap_dyn_out): Likewise.
+ (bfd_elf64_slurp_symbol_table): Declare.
+ (bfd_elf64_write_shdrs_and_ehdr): Declare.
+ (bfd_elf64_write_out_phdrs): Declare.
+ (_bfd_mips_elf_section_from_shdr): Declare.
+ * elf.c (bfd_section_from_shdr): Remove assertion requiring
+ SHT_REL/SHT_RELA to match use_rela_p. If there is already a reloc
+ section for the section, add the new one to rel_hdr2. Increment
+ reloc_count rather than setting it.
+ * elfcode.h (elf_slurp_symbol_table): Define name as macro.
+ Remove static declaration.
+ (elf_write_shdrs_and_ehdr): Define name as macro.
+ (elf_write_out_phdrs): Likewise.
+ (elf_swap_ehdr_in, elf_swap_ehdr_out): Declare.
+ (elf_swap_shdr_in, elf_swap_shdr_out): Declare.
+ (elf_swap_symbol_in): Change second parameter to be const.
+ (elf_swap_symbol_out): Likewise.
+ (elf_swap_ehdr_in, elf_swap_ehdr_out): Likewise.
+ (elf_swap_shdr_in, elf_swap_shdr_out): Likewise.
+ (elf_swap_phdr_in, elf_swap_phdr_out): Likewise.
+ (elf_swap_reloc_in, elf_swap_reloc_out): Likewise.
+ (elf_swap_reloca_in, elf_swap_reloca_out): Likewise.
+ (elf_write_out_phdrs): Rename from write_out_phdrs. Change second
+ parameter to be const. Make non-static.
+ (elf_write_shdrs_and_ehdr): Rename from write_shdrs_and_ehdr.
+ Make non-static.
+ (elf_slurp_symbol_table): Make non-static.
+ (NAME(_bfd_elf,size_info)): Update names of renamed functions.
+ * elfxx-target.h (elf_info_to_howto): Define if not defined.
+ (elf_backend_size_info): Likewise.
+ (elfNN_bed): Use elf_backend_size_info.
+ * targets.c (bfd_elf64_bigmips_vec): Declare.
+ (bfd_elf64_littlemips_vec): Declare.
+ (bfd_target_vector): Add bfd_elf64_bigmips_vec and
+ bfd_elf64_littlemips_vec if BFD64 is defined.
+
+ * libbfd.c (bfd_get_file_window): Add cast to fprintf argument.
+
+Tue May 28 11:42:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (sh_relax_delete_bytes): Insert nop instructions, not
+ zeroes, in alignment holes.
+
+ * configure: Rebuild with autoconf 2.10.
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Make room for the
+ potential leading underscore in the allocated buffer.
+
+Fri May 24 14:28:38 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_add_symbol_hook): Do not put small common
+ symbols into .sbss if this is a relocatable link.
+
+Thu May 23 12:26:24 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (_bfd_ppc_xcoff_relocate_section): Warn about
+ undefined symbols when creating a shared library.
+
+Fri May 17 13:54:15 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c: Add a bunch of new code and static const arrays to
+ support aligning loads and stores on four byte memory boundaries.
+ Also:
+ (sh_coff_howtos): Add entries for R_SH_CODE, R_SH_DATA and
+ R_SH_LABEL.
+ (sh_relax_section): Look for R_SH_CODE relocs. If we find one,
+ call sh_align_loads.
+ (sh_relax_delete_bytes): Don't mark R_SH_CODE or R_SH_DATA relocs
+ as unused.
+
+Thu May 16 16:34:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cache.c (bfd_open_file): Unlink the file before opening it for
+ write. From Marty Leisner <leisner@sdsp.mc.xerox.com>.
+
+ * opncls.c (bfd_fdopenr): Set opened_once.
+
+Tue May 14 12:35:32 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * som.c (som_slurp_reloc_table): Clear external_relocs cache after
+ freeing it.
+
+ * libbfd.c: Remove #ifdef FILE_OFFSET_IS_CHAR_INDEX, and compile
+ the code unconditionally.
+
+Mon May 13 19:51:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libcoff-in.h (struct pei_section_tdata): Define structure.
+ (pei_section_data): Define macro.
+ * libcoff.h: Rebuild.
+ * coffcode.h (coff_set_alignment_hook): If COFF_IMAGE_WITH_PE,
+ store s_paddr field in pei_section_data.
+ (coff_compute_section_file_positions): Use pei_section_data rather
+ than _cooked_size, and don't overwrite an existing value.
+ (coff_write_object_contents): If COFF_OBJ_WITH_PE, set s_paddr to
+ 0. If COFF_IMAGE_WITH_PE, set s_paddr to pei_section_data.
+ * peicode.h (coff_bfd_copy_private_section_data): Define if
+ COFF_IMAGE_WITH_PE.
+ (pe_bfd_copy_private_section_data): New static function if
+ COFF_IMAGE_WITH_PE.
+
+Wed May 8 16:10:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * srec.c (srec_set_arch_mach): Write as a function rather than a
+ macro definition.
+
+ * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): If an archive has
+ no map, just check each member in turn to see whether it is
+ required.
+
+Wed May 8 09:17:34 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppcboot.c (ppcboot_object_p): Check for type 0x41 in partition
+ table. Call BFD_ASSERT to validate header size, instead of
+ calling fatal.
+ (ppcboot_bfd_print_private_bfd_data): Put quotes around partition
+ name.
+
+Tue May 7 16:10:19 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppcboot.c: New target for looking at PPCbug boot records.
+
+ * config{ure.in,.bfd}: Add support for ppcboot target.
+ * targets.c: Ditto.
+ * configure: Regenerate.
+
+Tue May 7 11:15:19 1996 Jeffrey A Law (law@cygnus.com)
+
+ * coff-h8300.c (howto_table): Update names to match recent
+ changes to include/coff/internal.h. Fix minor errors in the
+ existing relocs. Add R_MOVL1 and R_MOVL2.
+ (rtype2howto): Similarly.
+ (h8300_reloc16_estimate): Rewrite to simplify, fix bugs in the
+ existing relaxing code and peform more relaxing.
+ (h8300_reloc16_extra_cases): Likewise.
+
+Mon May 6 18:24:09 1996 Jeffrey A Law (law@cygnus.com)
+
+ * reloc16.c (bfd_coff_reloc16_get_value): Handle common
+ symbols correctly.
+
+Sat May 4 05:08:45 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * elfcode.h (elf_object_p): Reject generic ELF target if
+ e_machine matches an alternate machine code in a specific backend.
+
+ * netbsd-core.c (netbsd_core_vec): Remove initializer for
+ obsolete align_power_min field.
+
+Fri May 3 13:07:35 1996 Jeffrey A Law (law@cygnus.com)
+
+ * coff-h8300.c (reloc_howto_type): Add howto entry for
+ R_PCRWORD_B.
+ (rtype2howto): Handle R_PCRWORD_B.
+ (h8300_reloc16_extra_cases): Handle R_PCRWORD_B.
+ (h8300_reloc_16_estimate): Likewise. Try to turn a 16bit
+ pc-relative branch (R_PCRWORD) into an 8bit pc-relative
+ branch (R_PCWORD_B).
+
+Fri May 3 10:47:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (translate_from_native_sym_flags): Set the section for
+ BSF_CONSTRUCTOR symbols.
+
+ * cofflink.c (_bfd_coff_link_input_bfd): Correct setting of
+ last_bf_index.
+
+Wed May 1 18:39:32 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): In comdat section lookup,
+ stop looking when section is found.
+
+Wed May 1 14:17:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (STRING_SIZE_SIZE): Define.
+ (styp_to_sec_flags): Handle long symbol names when looking for the
+ section symbol.
+ (bfd_coff_backend_data): Add _bfd_coff_long_section_names field.
+ (bfd_coff_long_section_names): Define.
+ (coff_write_object_contents): Handle long section names.
+ (bfd_coff_std_swap_table): Initialize new field.
+ * libcoff.h: Rebuild.
+ * coffgen.c (make_a_section_from_file): Handle long section
+ names.
+ (coff_write_symbols): Handle long section names.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize new field.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+ * pe-arm.c (COFF_LONG_SECTION_NAMES): Define.
+ * pei-arm.c (COFF_LONG_SECTION_NAMES): Define.
+ * pe-i386.c (COFF_LONG_SECTION_NAMES): Define.
+ * pei-i386.c (COFF_LONG_SECTION_NAMES): Define.
+ * pe-ppc.c (COFF_LONG_SECTION_NAMES): Define.
+ * pei-ppc.c (COFF_LONG_SECTION_NAMES): Define.
+
+ * bout.c (b_out_callback): Set lma of sections.
+ (b_out_bfd_get_relocated_section_contents): Rename in_abfd
+ parameter to output_bfd. Used input_bfd instead of output_bfd in
+ several places.
+
+Tue Apr 30 17:56:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (translate_from_native_sym_flags): Don't create
+ SEC_CONSTRUCTOR sections.
+ * ecoff.c (ecoff_set_symbol_info): Likewise.
+
+ * elf32-mips.c (mips_elf_copy_private_bfd_data): Copy elf_gp.
+ From Don Bowman <bowman@waterloo.hp.com>.
+
+Tue Apr 30 17:06:32 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * coff-arm.c (armcoff_little_vec): If COFF_WITH_PE is defined, add
+ SEC_LINK_ONCE and SEC_LINK_DUPLICATES to section_flags.
+
+Mon Apr 29 13:15:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (struct mips_elf_link_hash_entry): Add
+ mips_32_relocs field.
+ (mips_elf_link_hash_newfunc): Initialize mips_32_relocs field.
+ (mips_elf_relocate_section): Copy R_MIPS_REL32 and R_MIPS_32
+ relocs against a global symbol which is not defined in a regular
+ file.
+ (mips_elf_check_relocs): For a R_MIPS_REL32 or R_MIPS_32 reloc
+ against a global symbol, increment mips_32_relocs.
+ (mips_elf_adjust_dynamic_symbol): If mips_32_relocs is set, and
+ the symbol is not defined in a regular file, make room in the
+ .rel.dyn section.
+
+Fri Apr 26 18:00:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (ecoff_compute_section_file_positions): Track the real
+ file position and the virtual file position separately. Set
+ filepos information bsaed on the real file position.
+ (_bfd_ecoff_set_section_contents): Handle .lib sections like the
+ Jan 23 change to coffcode.h.
+
+ * som.c (som_slurp_symbol_table): Set the symbol count to the
+ number of BFD symbols created.
+
+Fri Apr 26 12:34:29 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Forward relocations to the
+ output file if linking shared objects. Loop to check all relocs,
+ rather than returning false on first error.
+
+Thu Apr 25 13:25:12 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_create_linker_section): Add PLT case.
+ (ppc_elf_additional_program_headers): If .interp section, bump #
+ of program headers by 1.
+ (ppc_elf_adjust_dynamic_symbol): Flesh out support.
+ (ppc_elf_size_dynamic_sections): Add support for .plt section.
+ (ppc_elf_check_relocs): Print out filename in debug code. Enable
+ PLT support.
+ (ppc_elf_finish_dynamic_symbol): Add support for PLT's, beef up
+ debug output.
+ (ppc_elf_relocate_section): If the output section isn't defined,
+ don't abort, just give an error message.
+
+ * elflink.c (_bfd_elf_create_dynamic_sections): If the section
+ being created is .sdata or .sdata2, don't make the symbol dynamic.
+
+Wed Apr 24 14:04:07 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Look through the
+ members of an archive for dynamic objects with no symbols, and
+ pass them directly to check_archive_element.
+ (xcoff_link_check_ar_symbols): Pass dynamic objects to
+ xcoff_link_check_dynamic_ar_symbols.
+ (xcoff_link_check_dynamic_ar_symbols): New static function.
+
+ * coff-rs6000.c (rs6000coff_vec): Change BFD_JUMP_TABLE_DYNAMIC
+ from _bfd_nodynamic to _bfd_xcoff.
+ * libcoff-in.h (_bfd_xcoff_get_dynamic_symtab_upper_bound):
+ Declare.
+ (_bfd_xcoff_canonicalize_dynamic_symtab): Declare.
+ (_bfd_xcoff_get_dynamic_reloc_upper_bound): Declare.
+ (_bfd_xcoff_canonicalize_dynamic_reloc): Declare.
+ * libcoff.h: Rebuild.
+ * xcofflink.c (xcoff_swap_ldrel_in): New static function.
+ (xcoff_get_section_contents): New static function.
+ (_bfd_xcoff_get_dynamic_symtab_upper_bound): New function.
+ (_bfd_xcoff_canonicalize_dynamic_symtab): New function.
+ (_bfd_xcoff_get_dynamic_reloc_upper_bound): New function.
+ (xcoff_dynamic_reloc): New static variable.
+ (_bfd_xcoff_canonicalize_dynamic_reloc): New function.
+ (xcoff_link_add_dynamic_symbols): Use xcoff_get_section_contents.
+
+Tue Apr 23 12:48:42 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sparc.c (bfd_coff_generic_reloc): Return bfd_reloc_ok even
+ if reloc_entry->addend is not 0.
+ (CALC_ADDEND): Just set the addend to reloc.r_offset.
+
+Mon Apr 22 18:29:01 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf32-sparc.c (_bfd_sparc_elf_howto_table): Fix spelling of
+ R_SPARC_GLOB_JMP.
+ * elf64-sparc.c (sparc64_elf_howto_table): Likewise.
+ Add entries for R_SPARC_[56].
+ (sparc_reloc_map): Add entries for R_SPARC_[56].
+
+Mon Apr 22 15:07:24 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Optimize linking of stabs in sections as used in ELF and COFF.
+ * stabs.c: New file.
+ * libbfd-in.h (_bfd_link_section_stabs): Declare.
+ (_bfd_write_section_stabs): Declare.
+ (_bfd_write_stab_strings): Declare.
+ * libbfd.h: Rebuild.
+ * libcoff-in.h (struct coff_section_tdata): Add stab_info field.
+ (struct coff_link_hash_table): Add stab_info field.
+ * libcoff.h: Rebuild.
+ * cofflink.c (_bfd_coff_link_hash_table_init): Initialize
+ stab_info field.
+ (coff_link_add_symbols): Call _bfd_link_section_stabs if
+ appropriate.
+ (_bfd_coff_final_link): Write out stab strings hash table.
+ (_bfd_coff_link_input_bfd): Handle optimized stabs sections.
+ * coff-ppc.c (ppc_bfd_coff_final_link): Write out stab strings
+ hash table.
+ * elf-bfd.h (struct elf_link_hash_table): Add stab_info field.
+ (struct bfd_elf_section_data): Add stab_info field.
+ * elf.c (_bfd_elf_link_hash_table_init): Initialize stab_info
+ field.
+ * elflink.h (elf_link_add_object_symbols): If appropriate, call
+ _bfd_link_section_stabs.
+ (elf_bfd_final_link): Write out stab strings hash table.
+ (elf_link_input_bfd): Handle optimized stabs sections.
+ * reloc.c (_bfd_final_link_relocate): Check address against
+ _raw_size rather than _cooked_size.
+ * Makefile.in: Rebuild dependencies.
+ (BFD_LIBS): Add stabs.o
+ (BFD_LIBS_CFILES): Add stabs.c.
+
+ * VERSION: Increment for bfdlink.h change.
+
+ * coffgen.c (coff_renumber_symbols): Correct handling of
+ BSF_NOT_AT_END common symbols.
+
+Fri Apr 19 19:21:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-ppc.c (record_toc): Add cast to avoid warning.
+ (ppc_allocate_toc_section): Likewise.
+ (coff_ppc_relocate_section): Remove ANSI C string concatenation.
+ (ppc_coff_reloc_type_lookup): Remove unreached code.
+ * coffcode.h (coff_write_object_contents): Don't take the address
+ of an array.
+ * peicode.h (pe_print_idata): Add casts to avoid warning.
+ (pe_print_edata): Likewise.
+ (pe_print_reloc): Remove ANSI C string concatenation.
+
+Thu Apr 18 18:51:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libcoff-in.h (struct coff_final_link_info): Add last_bf_index
+ and last_bf fields.
+ * libcoff.h: Rebuild.
+ * coffswap.h (coff_swap_aux_in): Swap endndx field for C_FCN
+ symbols.
+ (coff_swap_aux_out): Likewise.
+ * peicode.h (coff_swap_aux_in): Likewise.
+ (coff_swap_aux_out): Likewise.
+ * coffgen.c (coff_pointerize_aux): Check endndx field for C_FCN
+ symbols.
+ * cofflink.c (_bfd_coff_final_link): Initialize last_bf_index
+ field.
+ (_bfd_coff_link_input_bfd): Check endndx field for C_FCN symbols.
+ Fix up .bf endndx link fields.
+ * coff-ppc.c (ppc_bfd_coff_final_link): Initialize last_bf_index
+ field.
+ * xcofflink.c (xcoff_link_input_bfd): Check endndx field for C_FCN
+ symbols.
+
+Wed Apr 17 12:08:24 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * pe{,i}-ppc.c (PPC_PE): Define instead of PPC, so that compiling
+ on Solaris PowerPC systems doesn't get confused.
+
+ * ccffcode.h (coff_write_object_contents): Use #ifdef PPC_PE, not
+ #ifdef PPC.
+
+ * elfcore.h (bfd_prstatus, bfd_fpregset): Add thread argument.
+ (elf_corefile_note): If HAVE_SYS_PROCFS_H is not defined, don't
+ update did_reg and did_reg2.
+
+Wed Apr 17 13:07:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_input_bfd): Check for TOC overflow.
+
+ * linker.c (_bfd_generic_link_add_one_symbol): When calling the
+ callback routines, pass h->root.string rather than name, in case
+ copy is true and name is transient.
+
+Tue Apr 16 16:36:38 1996 Stu Grossman (grossman@lisa.cygnus.com)
+
+ * elfcore.h: Add support for core files with multiple threads.
+ (Primarily for Solaris.)
+
+Tue Apr 16 13:44:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (NAME(aout,squirt_out_relocs)): Don't do anything if
+ section->orelocation is NULL.
+
+ * coffgen.c (bfd_coff_get_syment): New function.
+ (bfd_coff_get_auxent): New function.
+ * bfd-in.h (bfd_coff_get_syment): Declare.
+ (bfd_coff_get_auxent): Declare.
+ * bfd-in2.h: Rebuild.
+
+Mon Apr 15 19:06:59 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (struct mips_hi16): Define.
+ (mips_hi16_addr, mips_hi16_addend): Remove.
+ (mips_hi16_list): New static variable.
+ (mips_elf_hi16_reloc): Maintain a list of unmatched HI16 relocs.
+ (mips_elf_lo16_reloc): Process mips_hi16_list.
+ (mips_elf_relocate_section): Permit an arbitrary number of HI16
+ relocs before the associated LO16 reloc.
+
+Wed Apr 10 00:23:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * versados.c (versados_scan): Check bfd_alloc return value.
+ (versados_object_p): Check all bfd_read return values. Require
+ that lang field be less than 10, to avoid confusion with Intel Hex
+ files.
+
+ * libaout.h (WRITE_HEADERS): Write out the relocs even if there
+ aren't any symbols.
+ * aoutx.h (NAME(aout,swap_std_reloc_out)): Set r_index to N_ABS,
+ not 0, for an absolute symbol.
+ (NAME(aout,swap_ext_reloc_out)): Likewise.
+
+ * ihex.c (ihex_scan): Accept a length of 4 for record type 5.
+ (ihex_write_object_contents): For a large start address, output
+ the full 32 bit address in record type 5.
+
+ * ieee.c (ieee_write_byte): Change second parameter from bfd_byte
+ to int to avoid promotion problems in prototype.
+
+Tue Apr 9 11:44:21 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Use ${srcdir} when looking for picfrag.
+
+ * configure.host: Switch on ${libdir}, not $(libdir). From
+ alan@spri.levels.unisa.edu.au (Alan Modra).
+
+ * aoutx.h (aout_link_add_symbols): Always call add_dynamic_symbols
+ entry point, not just for DYNAMIC objects.
+ * sunos.c (sunos_add_dynamic_symbols): Always call
+ sunos_create_dynamic_sections. If called with a non DYNAMIC
+ object, don't do anything else.
+ (sunos_add_one_symbol): Don't call sunos_create_dynamic_sections.
+
+Mon Apr 8 12:09:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Permit --enable-shared to specify a list of
+ directories.
+ * configure: Rebuild.
+
+ * configure.host: Set HLDFLAGS and SHLIB_CFLAGS for *-dec-osf*
+ host when configuring with --enable-shard.
+
+Fri Apr 5 12:24:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.bfd: Add i[345]86-*-freebsdelf* target; from John Polstra
+ <jdp@polstra.com>.
+
+ * linker.c (link_action): For WARN_ROW/warn, use MWARN, not CYCLE,
+ to avoid crashing in bfd_hash_replace.
+
+ * sysdep.h: Use #ifdef, not #if.
+
+Thu Apr 4 23:32:23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.in: Rebuild.
+
+Thu Apr 4 18:49:09 1996 Fred Fish <fnf@cygnus.com>
+
+ * configure.in (mips-sony-bsd*): Fix typo in AC_DEFINE.
+ (AC_CHECK_HEADERS): Check for sys/time.h
+ (AC_HEADER_TIME): Add macro.
+ * configure: Rebuild.
+ * sysdep.h: Use TIME_WITH_SYS_TIME and HAVE_SYS_TIME_H
+ to control what combination of <time> and <sys/time.h>
+ get included.
+
+Tue Apr 2 13:11:53 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * aoutf1.h (sunos_32_set_arch_mach): Handle M_SPARCLET.
+ (aout_32_sunos4_write_object_contents): Likewise.
+ * aoutx.h (NAME(aout,machine_type)): Handle
+ bfd_mach_sparc_{sparclet,sparclite}.
+ * archures.c (bfd_mach_sparc_{sparclet,sparclite}): Define.
+ (bfd_mach_sparc_v9_p): Update.
+ * cpu-sparc.c (arch_info_struct): Add entries for sparclet,sparclite.
+ * libaout.h (enum machine_type): Add M_SPARCLET.
+ * sunos.c (MACHTYPE_OK): Define.
+ * bfd-in2.h: Regenerated.
+
+Tue Apr 2 00:33:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf-bfd.h (struct elf_link_hash_table): Add hgot field.
+ * elf.c (_bfd_elf_link_hash_table_init): Initialize hgot field.
+ * elflink.c (_bfd_elf_create_got_section): Store the
+ _GLOBAL_OFFSET_TABLE_ hash table entry in the hgot field.
+ * elf32-sparc.c (elf32_sparc_check_relocs): If the size of the
+ global offset table goes over 0x1000, set the value of
+ _GLOBAL_OFFSET_TABLE_ to 0x1000 into the section.
+ (elf32_sparc_relocate_section): Subtract the offset of
+ _GLOBAL_OFFSET_TABLE_ when handling GOT relocations.
+
+ * elfcode.h: Don't include <string.h>.
+
+Mon Apr 1 10:39:24 1996 Jeffrey A Law (law@cygnus.com)
+
+ * linker.c (_bfd_generic_link_hash_newfunc): Renamed from
+ generic_link_hash_newfunc. All references changed.
+ * genlink.h (_bfd_generic_link_hash_newfunc): Declaration
+ moved here from libbfd-in.h.
+ * libbfd-in.h: Corresponding changes.
+ * libbfd.h: Regenerated.
+
+Mon Apr 1 12:35:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (aout_link_input_section_std): When reporting an
+ overflow error, use the name of the symbol in the hash table if
+ available.
+ (aout_link_input_section_ext): Likewise.
+
+ * elflink.h (elf_adjust_dynamic_symbol): If a common symbol got
+ defined in a regular file, set ELF_LINK_HASH_DEF_REGULAR.
+
+Sun Mar 31 01:58:41 1996 steve chamberlain <sac@slash.cygnus.com>
+
+ * peicode.h (coff_swap_aouthdr_out): Delete test for .junk.
+ * coffcode.h (coff_compute_section_file_positions): Likewise.
+ (coff_write_object_contents): Likewise.
+
+Fri Mar 29 12:44:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * section.c (SEC_LINK_ONCE): Define.
+ (SEC_LINK_DUPLICATES): Define.
+ (SEC_LINK_DUPLICATES_DISCARD): Define.
+ (SEC_LINK_DUPLICATES_ONE_ONLY): Define.
+ (SEC_LINK_DUPLICATES_SAME_SIZE): Define.
+ (SEC_LINK_DUPLICATES_SAME_CONTENTS): Define.
+ * bfd-in2.h: Rebuild.
+ * coffcode.h (sec_to_styp_flags): If COFF_WITH_PE, turn
+ SEC_LINK_ONCE into IMAGE_SCN_LNK_COMDAT.
+ (styp_to_sec_flags): If COFF_WITH_PE, turn IMAGE_SCN_LNK_REMOVE
+ into SEC_EXCLUDE. If IMAGE_SCN_LNK_COMDAT is set, set
+ SEC_LINK_ONCE, and look through the symbol table for the setting
+ for SEC_LINK_DUPLICATES.
+ (coff_write_object_contents): If COFF_WITH_PE, if SEC_LINK_ONCE is
+ set for a section, find the section symbol in the symbol table,
+ and set the aux entry based on SEC_LINK_DUPLICATES.
+ * coffgen.c (coff_print_symbol): Add a space before "checksum".
+ * coff-arm.c (armcoff_big_vec): If COFF_WITH_PE is defined, add
+ SEC_LINK_ONCE and SEC_LINK_DUPLICATES to section_flags.
+ * coff-i386.c (i386coff_vec): Likewise.
+ * coff-ppc.c (TARGET_LITTLE_SYM, TARGET_BIG_SYM): Likewise.
+
+ * VERSION: Bump to 2.6.1.
+ * Makefile.in (stamp-h): Depend upon VERSION.
+
+Thu Mar 28 23:48:49 1996 Jeffrey A Law (law@cygnus.com)
+
+ * libbfd-in.h (generic_link_hash_newfunc): Add declaration.
+ * libbfd.h: Rebuilt.
+ * linker.c (generic_link_hash_newfunc): No longer static.
+ * coffcode.h (coff_bfd_link_hash_create): Allow specific targets
+ to override.
+ * coff-h8300.c: Add two derived hash tables and their associated
+ funtions and #defines for use by the h8300 linker.
+ (h8300_reloc16_extra_cases, case R_MEM_INDIRECT): Create entries in
+ the function vector as needed. Place the address of the function
+ vector entry in the location specified by the R_MEM_INDIRECT reloc.
+ Rewrite the vectors section contents as necessary.
+ (h8300_bfd_link_add_symbols): New function for the h8300 linker.
+ (coff_bfd_link_add_symbols): Define to use h8300 specific version.
+ (coff_bfd_link_hash_table_create): Likewise.
+
+Thu Mar 28 17:44:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libhppa.h: If gcc 2.7 or higher, declare all the functions with
+ __attribute__ ((__unused__)) so that -Wall doesn't warn about
+ them.
+ (hppa_rebuild_insn): Pass pointer to correct type to
+ low_sign_unext and dis_assemble_21.
+
+Thu Mar 28 11:00:36 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * config.bfd (sparc64-{sysv4*,solaris2*}): Delete.
+ Stick with sparc-*-{sysv4*,solaris2*}.
+
+Wed Mar 27 10:43:34 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * peicode.h (coff_swap_aux_in): Swap in extra PE x_scn fields.
+ (coff_swap_aux_out): Swap out extra PE x_scn fields.
+ * coffswap.h (coff_swap_aux_in): Zero out extra PE x_scn fields.
+ * coffgen.c (coff_print_symbol): If any of the extra PE x_scn
+ fields is non-zero, print them.
+
+ * coff-ppc.c (ppc_record_toc_entry): Put inside COFF_IMAGE_WITH_PE
+ ifdef. Remove unused variables.
+ (ppc_record_data_in_toc_entry): Ifdef out. Removed unused
+ variables.
+ (ppc_mark_symbol_as_glue): Put inside COFF_IMAGE_WITH_PE ifdef.
+ (get_symbol_value): Ifdef out.
+ (pe_ppc_reloc): Ifdef out. Remove unused variables.
+ (coff_ppc_relocate_section): Remove unused variables. Make
+ fprintf strings and argument types correspond. Put before_addr in
+ DEBUG_RELOC ifdef.
+ (dump_toc): Make fprintf strings and argument types correspond.
+ (ppc_process_before_allocation): Remove unused variables. Always
+ return a value.
+ (ppc_reflo_reloc): Ifdef out.
+ (ppc_addr32nb_reloc): Ifdef out.
+ (ppc_coff_rtype2howto): Make fprintf strings and argument types
+ correspond.
+ (coff_ppc_rtype_to_howto): Likewise.
+ (ppc_coff_swap_sym_in_hook): Remove unused variables.
+
+ * peicode.h (pe_print_idata): Move otherwise unused variables into
+ the #ifdef where they are used. Always return a value.
+ (pe_print_edata): Make fprintf strings and argument types
+ correspond. Always return a value.
+ (pe_print_pdata): Removed unused variable addr_value. Always
+ return a value.
+ (pe_print_reloc): Remove unused variable onaline. Make fprintf
+ strings and argument types correspond. Always return a value.
+
+ * elf32-ppc.c (ppc_elf_fake_sections): Return true.
+ (ppc_elf_finish_dynamic_symbol): Move definition of unused
+ variable rela inside #if 0 section where it is used.
+
+ * ns32k.h: New file.
+ * cpu-ns32k.h: Include ns32k.h. Rename externally visible
+ functions to start with _bfd_.
+ * aout-ns32k.c: Include ns32k.h. Change references to renamed
+ functions in cpu-ns32k.h.
+ * Makefile.in: Rebuild dependencies.
+ (HFILES): Add ns32k.h.
+
+ * section.c (struct sec): Add linker_mark field. Change
+ user_set_vma and reloc_done to be single bit fields.
+ (STD_SECTION): Update accordingly.
+ * bfd-in2.h: Rebuild.
+ * aoutx.h (NAME(aout,final_link)): Mark sections included in the
+ link.
+ (aout_link_input_bfd): Don't link unmarked sections.
+ * cofflink.c (_bfd_coff_final_link): Mark sections included in the
+ link.
+ (_bfd_coff_link_input_bfd): Don't link unmarked sections.
+ * coff-ppc.c (ppc_bfd_coff_final_link): Mark sections included in
+ the link.
+ * elflink.h (elf_bfd_final_link): Mark sections included in the
+ link.
+ (elf_link_input_bfd): Don't link unmarked sections.
+ * xcofflink.c (_bfd_xcoff_bfd_final_link): Mark sections included
+ in the link.
+ (xcoff_link_input_bfd): Don't link unmarked sections.
+
+ * coffswap.h (coff_swap_scnhdr_out): Include section name in
+ overflow error messages.
+
+Tue Mar 26 15:46:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd.c (_bfd_default_error_handler): If _bfd_error_program_name
+ is not set, print "BFD: " before the error message.
+
+ * configure.in: Use AC_CHECK_TOOL to find ar and ranlib. From
+ Miles Bader <miles@gnu.ai.mit.edu>.
+ * configure: Rebuild.
+
+Fri Mar 22 12:17:00 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_input_bfd): Fix scan for C_BINCL/C_EINCL
+ symbols.
+
+ * config.bfd: Add ieee_vec to targ_selvecs for i960 targets and
+ m68k-aout, m68k-coff, and m68k-elf targets.
+
+Fri Mar 22 11:33:44 1996 Martin Anantharaman <martin@goofy.imech.uni-duisburg.de>
+
+ * ieee.c: Changed #ifdef KEEPMINUSPCININST to #if KEEPMINUSPCININST.
+ (ieee_generic_stat_arch_elt): Restructured to prevent
+ ieee_object_p from being called repeatedly.
+
+Thu Mar 21 11:00:47 1996 steve chamberlain <sac@slash.cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): Allocate
+ buffers large enough for any FILEHDR or AOUTHDR.
+
+Thu Mar 21 16:28:17 1996 David Mosberger-Tang <davidm@azstarnet.com>
+
+ * ecofflink.c (lookup_line): New static function, renamed and
+ slighly changed from old _bfd_ecoff_locate_line.
+ (_bfd_ecoff_locate_line): Cache line number information. Use
+ lookup_line for actual lookup.
+
+Thu Mar 21 14:59:11 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * peicode.h (pe_print_pdata): Warn if the .pdata section is not a
+ multiple of 20 bytes.
+
+Thu Mar 21 13:54:40 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): Use bfd_zalloc to
+ allocate ecoff_find_line, and don't initialize by hand.
+ * elf32-mips.c (mips_elf_find_nearest_line): Use bfd_zalloc for
+ mips_elf_find_line, and don't call memset.
+
+ * coffcode.h (coff_compute_section_file_positions): If not
+ producing a final executable, don't consider sofar when aligning
+ the section to the correct size.
+
+Wed Mar 20 16:53:12 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_add_missing_symbols): Ifdef out.
+ (coff_write_object_contents): Don't call coff_add_missing_symbols.
+ * coffgen.c (coff_section_symbol): Ifdef out.
+
+Mon Mar 18 12:54:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf32-mips.c (mips_elf_gprel32_reloc): Initialize gp if
+ output_bfd is not NULL.
+
+Thu Mar 14 17:12:06 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * coffgen.c (coff_get_normalized_symtab): Call bfd_zalloc instead
+ of bfd_alloc (fixes fix_line not being initialized).
+ Delete zeroing of fix_{value,tag,end,scnlen} fields.
+
+Thu Mar 14 16:06:06 1996 Jeffrey A Law (law@cygnus.com)
+
+ * coffcode.h: Allow specific backends to override the
+ bfd_link_add_symbols routine.
+
+ * coff-h8300.c: Include genlink.h.
+ (howto_table): Add R_MEM_INDIRECT.
+ (rtype2howto): Support R_MEM_INDIRECT.
+ (h8300_reloc16_extra_cases): Handle R_MEM_INDIRECT like R_RELBYTE
+ for now.
+
+Tue Mar 12 12:41:17 1996 David Mosberger-Tang <davidm@koala.azstarnet.com>
+
+ * coff-alpha.c (alpha_relocate_section): Use
+ info->callbacks_warning, rather than _bfd_error_handler, for
+ "multiple gp" warning.
+
+Tue Mar 12 12:10:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * linker.c (bfd_wrapped_link_hash_lookup): New function.
+ (_bfd_generic_link_add_one_symbol): Remove BFD_ASSERT on hash
+ table string. Use bfd_wrapped_link_hash_lookup.
+ (_bfd_generic_link_write_global_symbol): Remove BFD_ASSERT on hash
+ table string.
+ * aoutx.h (aout_link_write_symbols): Use the name from the hash
+ table, if any, when writing out symbols.
+ (aout_link_input_section_std): Use the name from the hash table,
+ if any, when reporting undefined symbols.
+ (aout_link_input_section_ext): Likewise.
+ (aout_link_reloc_link_order): Use bfd_wrapped_link_hash_lookup.
+ * bout.c (get_value): Likewise.
+ * cofflink.c (_bfd_coff_reloc_link_order): Likewise.
+ * ecoff.c (ecoff_reloc_link_order): Likewise.
+ * elflink.h (elf_link_add_object_symbols): Likewise.
+ (elf_reloc_link_order): Likewise.
+ * linker.c (_bfd_generic_link_output_symbols): Likewise.
+ (_bfd_generic_reloc_link_order): Likewise.
+ (default_indirect_link_order): Likewise.
+ * reloc16.c (bfd_coff_reloc16_get_value): Likewise.
+ * sunos.c (sunos_add_one_symbol): Likewise.
+ * xcofflink.c (xcoff_link_add_symbols): Likewise.
+ (bfd_xcoff_link_count_reloc): Likewise.
+ (xcoff_reloc_link_order): Likewise.
+
+ * ecoffswap.h (ecoff_swap_fdr_in): If ECOFF_64, turn 0xffffffff
+ into -1 for intern->rss.
+
+ * configure: Rebuild with autoconf 2.8.
+
+Mon Mar 11 12:28:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * stab-syms.c (__define_stab_duplicate): Define.
+ (bfd_get_stab_name): Rename from aout_stab_name. Rewrite to use a
+ switch.
+ * bfd-in.h (bfd_get_stab_name): Declare.
+ * bfd-in2.h: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD_LIBS): Add stab-syms.o.
+ (BFD_LIBS_CFILES): Add stab-syms.c.
+ (BFD32_BACKENDS): Remove stab-syms.o.
+ (BFD32_BACKENDS_CFILES): Remove stab-syms.c.
+ * configure.in: Don't list stab-syms.o in bfd_backends.
+ * configure: Rebuild.
+ * libaout.h (aout_stab_name): Don't declare.
+ * aoutx.h (NAME(aout,get_symbol_info)): Call bfd_get_stab_name,
+ not aout_stab_name.
+
+Fri Mar 8 11:26:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): Adjust file offset
+ for section alignment even if SEC_LOAD is not set.
+
+Tue Mar 5 12:02:23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't set SHLIB or SHLINK to an empty string,
+ since they appear as targets in Makefile.in.
+ * configure: Rebuild.
+
+ * sunos.c (sunos_scan_ext_relocs): If not making a shared library,
+ don't fiddle with a symbol which is not defined anywhere.
+
+Mon Mar 4 12:49:16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_mark): Treat undefined imported symbols as
+ though they are defined in a shared library.
+ (xcoff_build_ldsyms): Likewise.
+
+ * coffgen.c (coff_find_nearest_line): Don't look at the line
+ numbers for the section if section->lineno is NULL.
+
+ * elf.c (_bfd_elf_symbol_from_bfd_symbol): Print a useful error
+ message rather than calling BFD_ASSERT.
+ * elfcode.h (write_relocs): Check return value of
+ _bfd_elf_symbol_from_bfd_symbol.
+
+Fri Mar 1 09:42:59 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_add_symbol_hook): Don't set SEC_LOAD flag
+ for .sbss section.
+
+Wed Feb 28 11:25:47 1996 Jeffrey A Law (law@cygnus.com)
+
+ * libhppa.h (hppa_reloc_field_selector_type): Add R_HPPA_NLSEL
+ and R_HPPA_NLRSEL.
+ (e_nsel, e_nlsel, e_nlrsel): Undefine. Add to
+ hppa_reloc_field_selector_type_alt.
+ (hppa_field_adjust): Handle e_nlsel, e_nlrsel. Fix e_nsel handling.
+ * som.c (hppa_som_gen_reloc_type): Handle N', NL' NLR' field
+ selectors.
+ (som_write_fixups): Finish handling of R_N0SEL and R_N1SEL.
+
+Wed Feb 28 11:00:24 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): Adjust the segment
+ memory size for the alignment of a SEC_ALLOC section, not just a
+ SEC_LOAD section.
+
+Tue Feb 27 14:17:31 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68klinux.c: New file.
+ * hosts/m68klinux.h: New file.
+ * config.bfd (m68*-*-linuxaout*, m68*-*-linux*): New targets.
+ * configure.in (m68*-*-linux*): New native host.
+ (m68klinux_vec): New vector.
+ * configure: Rebuild.
+ * targets.c (m68klinux_vec): Declare.
+ * i386linux.c (bfd_i386linux_size_dynamic_sections): Renamed from
+ bfd_linux_size_dynmic_sections to avoid clash with m68klinux.c.
+ * bfd-in.h (bfd_i386linux_size_dynamic_sections): Rename
+ declaration from bfd_linux_size_dynamic_sections.
+ (bfd_m68klinux_size_dynamic_sections): Declare.
+ * bfd-in2.h: Rebuild.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add m68klinux.o.
+ (BFD32_BACKENDS_CFILES): Add m68klinux.c.
+
+Tue Feb 27 11:31:34 1996 Jeffrey A Law (law@cygnus.com)
+
+ * libhppa.h (pa_arch): Add pa20.
+ (hppa_reloc_field_selector_type): Add R_HPPA_NSEL.
+ (e_nsel): Undefine. Add to hppa_reloc_field_selector_type_alt.
+ (hppa_field_adjust): Handle e_nsel.
+ * som.c: Provide default definitions for many new relocs found only
+ in hpux10 include files.
+ (som_fixup_formats): Add several new relocs from hpux10.
+ (som_hppa_howto_table): Add hpux10 relocs.
+ (som_write_fixups): Handle R_N0SEL and R_N1SEL hpux10 relocs.
+
+Mon Feb 26 12:52:48 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Edit out recent shared library support, and
+ rules to rebuild .h files using doc/chew.
+
+Mon Feb 26 14:48:39 1996 David Mosberger-Tang <davidm@AZStarNet.com>
+
+ * ecoff.c (ecoff_compute_section_file_positions): Adjust the file
+ size even of sections with no contents.
+
+Mon Feb 26 14:01:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cofflink.c (_bfd_coff_link_input_bfd): When merging, skip names
+ starting with '$' the way we skip names starting with '.'. When
+ updating x_endndx, don't be fooled by an index which has been
+ merged.
+
+ * cofflink.c (_bfd_coff_link_input_bfd): Don't try to optimize a
+ struct/union/enum type with no elements.
+
+Sat Feb 24 11:38:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd.c (bfd_errmsg): Handle a NULL return from strerror.
+
+ * archive.c (bfd_generic_archive_p): If the first file in the
+ archive can not be recognized as an object, don't assume that this
+ is the wrong format.
+
+ * elf.c (bfd_elf_set_dt_needed_name): Don't do anything if the
+ format is not bfd_object.
+ (bfd_elf_get_dt_soname): Likewise.
+
+Wed Feb 21 13:58:04 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-sh.c (sh_relax_delete_bytes): Correct range of R_SH_USES
+ reloc.
+
+Tue Feb 20 16:22:44 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * bfd.c (tdata): Add netbsd_core_data.
+ * bfd-in2.h: Regenerated.
+
+Tue Feb 20 16:50:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sunos.c (SUNOS_CONSTRUCTOR): Define.
+ (sunos_add_one_symbol): Don't let a symbol from a dynamic object
+ override a constructor symbol. Set SUNOS_CONSTRUCTOR when
+ appropriate.
+
+ * bout.c (b_out_squirt_out_relocs): Use udata.i rather than flags
+ to get the symbol index, matching 14 Jul 95 change.
+
+Tue Feb 20 08:26:27 1996 Fred Fish <fnf@phydeaux.cygnus.com>
+
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents):
+ Remove duplicate definition of gp.
+
+Mon Feb 19 12:37:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Don't
+ assume that we can set the GP value and then get the same value,
+ since it won't be true if the output file is neither ELF nor
+ ECOFF.
+ * coff-mips.c (mips_adjust_reloc_in): Don't bother to use
+ _bfd_get_gp_value here.
+ (mips_gprel_reloc): Don't assume we can set and get the GP value.
+ * elf32-mips.c (mips_elf_hi16_reloc): Get gp value from
+ mips_elf_final_gp.
+ (mips_elf_lo16_reloc): Likewise.
+ (mips_elf_final_gp): Add pgp parameter. Set it to the GP value.
+ Don't require that the BFD be ELF.
+ (mips_elf_gprel16_reloc): Get gp value from mips_elf_final_gp.
+ (mips_elf_gprel32_reloc): Likewise.
+ (mips_elf_relocate_section): Don't assume we can set and get the
+ GP value.
+ (mips_elf_finish_dynamic_symbol): Don't bother to use
+ _bfd_get_gp_value here.
+
+ * elf32-mips.c (mips_elf_create_procedure_table): Initialize sv.
+ Don't change epdr between malloc and free. Be careful not to free
+ NULL pointers. Zero out the first RPDR.
+
+ * configure.host: On Linux, only pass -rpath option if $(libdir)
+ is neither /lib nor /usr/lib. From Alan Modra
+ <alan@mullet.Levels.UniSA.Edu.Au>.
+
+ * elf-bfd.h (struct elf_obj_tdata): Rename dt_needed_name to
+ dt_name.
+ (elf_dt_name): Rename from elf_dt_needed_name.
+ * elf.c (bfd_elf_set_dt_needed_name): Use elf_dt_name, not
+ elf_dt_needed_name.
+ (bfd_elf_get_dt_soname): New function.
+ * elflink.h (elf_link_add_object_symbols): Use elf_dt_name, not
+ elf_dt_needed_name. Save the SONAME back in elf_dt_name.
+ * bfd-in.h (bfd_elf_get_dt_soname): Declare.
+ * bfd-in2.h: Rebuild.
+
+Mon Feb 19 02:50:23 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_reloc_type_lookup): Renamed from
+ _bfd_sparc_elf_reloc_type_lookup.
+ (bfd_elf32_bfd_reloc_type_lookup): Update.
+ * elf64-sparc.c (SPARC64_OLD_RELOCS): Define.
+ (sparc64_elf_howto_table): Define.
+ (sparc_reloc_map): Define.
+ (sparc64_elf_reloc_type_lookup): New function.
+ (sparc_elf_wdisp16_reloc): New function.
+ (elf_info_to_howto): Use sparc64_elf_howto_table.
+ (sparc64_elf_relocate_section): Likewise.
+ (bfd_elf64_bfd_reloc_type_lookup): Update.
+
+Sun Feb 18 15:02:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Check for 'do not mix' from native linker before
+ trying to use -rpath.
+
+Fri Feb 16 12:46:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd.c (_bfd_get_gp_value): New function.
+ (_bfd_set_gp_value): New function.
+ * libbfd-in.h (_bfd_get_gp_value): Declare.
+ (_bfd_set_gp_value): Declare.
+ * libbfd.h: Rebuild.
+ * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Use
+ _bfd_get_gp_value and _bfd_set_gp_value rather than referring
+ directly to the fields in the tdata information.
+ (alpha_relocate_section): Likewise.
+ * coff-mips.c (mips_adjust_reloc_in): Likewise.
+ (mips_gprel_reloc): Likewise.
+ (mips_relocate_section): Likewise.
+ * elf32-mips.c (mips_elf_hi16_reloc): Likewise.
+ (mips_elf_lo16_reloc): Likewise.
+ (mips_elf_final_gp): Likewise.
+ (mips_elf_gprel16_reloc): Likewise.
+ (mips_elf_gprel32_reloc): Likewise.
+ (mips_elf_relocate_section): Likewise.
+ (mips_elf_finish_dynamic_symbol): Likewise.
+
+ * bout.c (b_out_set_arch_mach): Recognize bfd_mach_i960_jx.
+
+Thu Feb 15 11:29:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_PROG_CC before configure.host.
+ * configure: Rebuild.
+ * configure.host: Don't set information which autoconf should
+ figure out, namely CC, CFLAGS, LDFLAGS, AR, and RANLIB.
+
+ * configure.host: Remove go32 and win32 host information, since it
+ should no longer be needed.
+
+ * elf.c (map_sections_to_segments): If we have a .dynamic section,
+ then start a new segment rather than put a writable section in a
+ readonly segment.
+
+ * configure.host: Set RPATH_ENVVAR.
+
+ * Makefile.in: Rebuild dependencies.
+
+ * elflink.c (_bfd_elf_create_linker_section): Remove unused
+ zero_section variable.
+
+Thu Feb 15 10:39:17 1996 H.J. Lu <hjl@zoom.com>
+
+ * Makefile.in ($(srcdir)/bfd-in2.h): Rename target from bfd-in2.h.
+ ($(srcdir)/libbfd.h): Rename from libbfd.h.
+ ($(srcdir)/libcoff.h): Rename from libcoff.h.
+
+Wed Feb 14 16:29:07 1996 Martin Anantharaman <martin@mail.imech.uni-duisburg.de>
+
+ * ieee.c (ieee_write_expression): Only use an R variable for a
+ local symbol. Don't output a zero offset. Handle a zero address.
+ (SRC_MASK, PCREL_OFFSET): Define based on KEEPMINUSPCININST.
+ (rel32_howto, rel16_howto, rel8_howto): Use SRC_MASK and
+ PCREL_OFFSET.
+ (parse_expression): Don't try to handle multiple occurrences of a
+ P variable. Handle I variables differently from X variables. Fix
+ the order of minus expressions.
+ (ieee_slurp_external_symbols): Generate an I variable for an NN
+ record. Fix handling of ATI and ATX records.
+ (ieee_slurp_sections): Only set minimal section attributes.
+ Adjust them later, based on the section contents.
+ (ieee_object_p): Read in the file until just after the ME record.
+ Call ieee_slurp_section_data to set the section flags.
+ (do_one): Add iterations parameter. Only repeat the first load
+ item. Set the section and file reloc flags.
+ (ieee_slurp_section_data): Set section flags. Pass iterations to
+ do_one.
+ (ieee_canonicalize_reloc): Handle I variables.
+ (do_with_relocs): Only emit relocation size when necessary.
+ Increase MAXRUN to 127. Change ov to be assigned, and take
+ src_mask and pcrel_offset into account.
+ (ieee_write_data_part): Skip sections that are not loaded.
+ (ieee_write_external_part): Don't output optional last entry of WX
+ records.
+ (ieee_write_me_part): Make setting of me_record neater.
+ (ieee_generic_stat_arch_elt): Get the size of an archive element.
+
+ * syms.c (stt): Add entries for zerovars, vars, and code.
+
+ * elfcode.h (validate_reloc): New static function.
+ (write_relocs): Call validate_reloc for non ELF relocs.
+
+ * elfxx-target.h (elf_symbol_leading_char): Define if not defined.
+ (TARGET_BIG_SYM): Use elf_symbol_leading_char.
+ (TARGET_LITTLE_SYM): Likewise.
+
+ * config.bfd (m68*-*-psos*): New target.
+
+Tue Feb 13 15:56:22 1996 Bryan Ford <baford@snake.cs.utah.edu>
+
+ * i386msdos.c: Remove some #if 0 code.
+ (msdos_write_object_contents): Don't include empty sections in the
+ size computation, regardless of their address.
+
+Tue Feb 13 15:36:37 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Don't segfault if dynboj
+ is NULL, ie, the -r switch is used.
+
+Tue Feb 13 14:35:15 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * reloc.c (BFD_RELOC_MIPS_GOT_HI16): Define.
+ (BFD_RELOC_MIPS_GOT_LO16): Define.
+ (BFD_RELOC_MIPS_CALL_HI16, BFD_RELOC_MIPS_CALL_LO16): Define.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * elf32-mips.c (mips_reloc_map): Map new relocs.
+
+ * configure.host: Set HDLFLAGS for *-*-hpux with --enable-shared.
+
+ * Makefile.in ($(SHLINK)): Check ts against $(SHLIB), not
+ $(SHLINK).
+
+ * ieee.c (get_symbol): Set the section to bfd_abs_section.
+ (do_with_relocs): If EXEC_P is set and there are no relocs, use a
+ simple number for the section address, rather than an expression.
+ Limit the number of bytes between relocs to MAXRUN.
+ (ieee_write_me_part): Set me_record to the file offset after the
+ start address.
+ (ieee_write_processor): New static function.
+ (ieee_write_object_contents): Use ieee_write_processor.
+
+Fri Feb 9 10:53:00 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Use ${CC-gcc} when testing for -rpath on SunOS.
+
+ * coff-aux.c: Change include of aux.h to aux-coff.h.
+
+Thu Feb 8 14:01:03 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c (elf_m68k_relocate_section): For a R_68K_RELATIVE
+ relocation put the addend both in the reloc entry and the data.
+ (elf_m68k_finish_dynamic_symbol): Likewise. Mask out marker in
+ GOT offset value.
+
+ * elf32-m68k.c (elf_m68k_relocate_section): If -Bsymbolic, resolve
+ a R_68K_PCxx reloc against a defined global symbol directly.
+ (elf_m68k_check_relocs): Don't count such a reloc.
+
+ * elf32-m68k.c (elf_m68k_check_relocs): Don't record a symbol with
+ a PLTxx reloc as dynamic. Disallow PLTxxO reloc against a local
+ symbol for now, otherwise always record the symbol as dynamic.
+ (elf_m68k_adjust_dynamic_symbol): If a symbol with a PLTxx reloc
+ is not referenced by a dynamic object, and we are not making a
+ shared object, then don't make a PLT entry. If we do make a PLT
+ entry, make sure the symbol has been recorded as dynamic.
+
+Wed Feb 7 13:56:06 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: When making a shared library, set HLDFLAGS to
+ pass an appropriate -rpath option. Use the make variable SONAME
+ as the shared library soname, rather than computing it here. On
+ SunOS, build stamp-tshlink in place of $(SHLINK).
+ * Makefile.in (SONAME): New variable.
+ ($(SHLINK)): Make a link to the transformed name, as well.
+ (stamp-tshlink): New target.
+ (install): Skip stamp-tshlink during install.
+
+Wed Feb 7 13:37:39 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_add_symbol_hook): Do not assume that the
+ linker sections have been set up yet.
+
+ * elf.c (make_mapping): Add an additional argument to suppress
+ making the first section include the program headers.
+ (map_sections_to_segments): If the user used -Ttext such that the
+ program headers are on a different page, do not set the flags
+ saying that this section includes the program headers.
+
+Tue Feb 6 14:04:49 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * configure.in (*-*-netbsd*): Set COREFILE to netbsd-core.c.
+ don't define TRAD_HEADER.
+ * configure: Rebuild.
+
+ * netbsd-core.c: New file, support for NetBSD core files.
+ * hosts/*nbsd.h: Removed.
+
+Tue Feb 6 11:47:49 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * reloc.c (BFD_RELOC_SPARC_[567]): New reloc types.
+ (BFD_RELOC_SPARC_LO7 reloc type): Deleted.
+ * libbfd.h, bfd-in2.h: Regenerated.
+ * elf32-sparc.c (_bfd_sparc_elf_reloc_type_lookup): Renamed from
+ bfd_elf32_bfd_reloc_type_lookup.
+ (reloc_type{,_names}): Deleted.
+ (_bfd_sparc_elf_howto_table): Renamed from elf_sparc_howto_table.
+ Add sparc64 relocs.
+ (sparc_reloc_map): Add sparc64 relocs.
+ (sparc_elf_notsupported_reloc): New static function.
+ (sparc_elf_wdisp16_reloc): New static function.
+ (elf32_sparc_check_relocs): Handle R_SPARC_WDISP{16,19}.
+ (elf32_sparc_relocate_section): Likewise.
+ (bfd_elf32_bfd_reloc_type_lookup): Define.
+ * elf64-sparc.c (sparc64_elf_wdisp16_reloc): Deleted.
+ (reloc_type{,_names}): Deleted.
+ (elf_sparc_howto_table): Deleted.
+ (sparc_reloc_map): Deleted.
+ (_bfd_sparc_elf_howto_table): Renamed from elf_sparc_howto_table.
+ (bfd_elf64_bfd_reloc_type_lookup): Change from function to #define.
+
+Tue Feb 6 12:12:22 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.host: Make SHLIB_CFLAGS include $(PICFLAG) on a
+ *-*-hpux* host.
+
+ * Makefile.in (program_transform_name): New variable.
+ (install): Transform library name before installing it.
+
+Mon Feb 5 10:38:27 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * archures.c (bfd_mach_i960_hx): Define.
+ * bfd-in2.h: Rebuild.
+ * cpu-i960.c (scan_960_mach): Accept machine "hx".
+ (MATRIX): Expand entries for HX.
+ (arch_info_struct): Add i960:hx entry.
+ * bout.c (b_out_set_arch_mach): Handle bfd_mach_i960_hx.
+ * coffcode.h (coff_set_arch_mach_hook): Handle F_I960HX.
+ (coff_set_flags): Handle bfd_mach_i960_hx.
+
+ Support for building as a shared library, based on patches from
+ Alan Modra <alan@spri.levels.unisa.edu.au>:
+ * configure.in: Add AC_ARG_ENABLE for shared and commonbfdlib.
+ New substitutions: ALLLIBS, PICFLAG, SHLIB, SHLIB_CC,
+ SHLIB_CFLAGS, COMMON_SHLIB, PICLIST, SHLINK.
+ * configure: Rebuild.
+ * configure.host: If --enable-shared, adjust shared library stuff
+ based on the host. If the host is SunOS, and the linker supports
+ -rpath, set HLDFLAGS to use it.
+ * Makefile.in (ALLLIBS): New variable.
+ (PICFLAG, SHLIB, SHLIB_CC, SHLIB_CFLAGS): New variables.
+ (COMMON_SHLIB, SHLINK): New variables.
+ (.c.o): If PICFLAG is set, compile twice, once PIC, once normal.
+ (STAGESTUFF): Remove variable.
+ (all): Depend upon $(ALLLIBS) and @PICLIST@ rather than
+ $(TARGETLIB).
+ (stamp-ofiles): New target, like old ofiles target, but build
+ using a temporary file and move-if-change, and touch stamp-ofiles
+ when done.
+ (ofiles): Just depend upon stamp-ofiles.
+ (stamp-piclist, piclist): New targets.
+ ($(SHLIB), $(SHLINK)): New targets.
+ (targets.o, archures.o): Build twice if PICFLAG is set.
+ (do_mostlyclean): Remove pic/*.o.
+ (do_clean): Remove stamp-ofiles, $(SHLIB), $(SHLINK), piclist, and
+ stamp-piclist.
+ (do_distclean): Remove pic and stamp-picdir.
+ (install): Install shared libraries.
+ ($(OFILES)): Depend upon stamp-picdir.
+ (stamp-picdir): New target.
+
+ * libcoff-in.h: Add comment reminding people that libcoff.h is a
+ generated file.
+ * libcoff.h: Rebuild.
+
+ * elflink.h (elf_adjust_dynamic_symbol): Don't try to get the
+ flavour of a section with no owner.
+
+ * elf32-mips.c (mips_elf_create_dynamic_sections): Clear
+ ELF_LINK_NON_ELF flag.
+ (mips_elf_create_got_section): Likewise.
+
+ * elf.c: Revert last change, since it breaks dynamic linking.
+ * elf-bfd.h (struct elf_backend_data): Remove want_hdr_in_seg
+ field.
+ * elf32-mips.c (elf_backend_want_hdr_in_seg): Don't define.
+ * elfxx-target.h (elf_backend_want_hdr_in_seg): Don't define.
+ (elfNN_bed): Don't initialize want_hdr_in_seg field.
+
+Sun Feb 4 20:45:13 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): If the backend does
+ not want the elf header or the program headers in the address
+ space, do not include them in the calculations.
+
+ * elf32-ppc.c (ppc_elf_additional_program_headers): New hook
+ function to determine if we need additional program headers.
+ (ppc_elf_modify_segment_map): Define as a NOP function for now.
+ (ppc_elf_create_linker_section): .sdata2 is a read-only section.
+
+Sat Feb 3 23:00:03 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h: Move today's libcoff.h change into coffcode.h.
+
+Sat Feb 3 15:43:44 1996 Fred Fish <fnf@cygnus.com>
+
+ * libcoff.h (bfd_coff_link_add_one_symbol): Combine macro args
+ back into one line. Some compilers (sunos 4.1.3 for example)
+ won't accept args split across more than one line.
+
+Fri Feb 2 11:42:15 1996 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * aclocal.m4 (BFD_BINARY_FOPEN): Understand cygwin32.
+ * configure: Regenerate.
+
+Fri Feb 2 12:12:16 1996 Jeffrey A Law (law@cygnus.com)
+
+ * elf32-hppa.c (elf32_hppa_backend_symbol_table_processing): Don't
+ try to do arithmetic on a void *, cast it to a unsigned char * first.
+
+Thu Feb 1 16:04:06 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf-bfd.h (ELF_LINK_NON_ELF): Define.
+ * elf.c (_bfd_elf_link_hash_newfunc): Set elf_link_hash_flags to
+ ELF_LINK_NON_ELF.
+ * elflink.h (elf_link_add_object_symbols): Reset ELF_LINK_NON_ELF
+ flag for a newly defined symbol.
+ (NAME(bfd_elf,record_link_assignment)): Likewise.
+ (elf_adjust_dynamic_symbol): If ELF_LINK_NON_ELF is set, try to
+ set the DEF or REF_REGULAR flags correctly.
+
+ * Makefile.in (bfd-in2.h): Make bfd.h, not protos, in docdir.
+ (libbfd.h, libcoff.h): Corresponding change.
+
+ * elf32-i386.c (elf_i386_check_relocs): Don't record a symbol with
+ a PLT32 reloc as dynamic.
+ (elf_i386_adjust_dynamic_symbol): If a symbol with a PLT32 reloc
+ is not referenced by a dynamic object, and we are not making a
+ shared object, then don't make a PLT entry. If we do make a PLT
+ entry, make sure the symbol has been recorded as dynamic.
+
+Wed Jan 31 17:23:32 1996 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * coff-i386.c (coff_i386_reloc_type_lookup): Add BFD_RELOC_32_PCREL.
+ * config.bfd (i[345]86-*-win32): Becomes i[345]86-*-cygwin32.
+ (powerpcle-*-cygwin32): New.
+ * peicode.h (add_data_entry): Get address from vma.
+
+Wed Jan 31 16:23:57 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elflink.c (_bfd_elf_create_linker_section): If the symbol
+ attached to the section has already been created as an undefined
+ symbol, treat it as if it hasn't been created yet.
+
+Wed Jan 31 16:16:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elflink.h (elf_bfd_final_link): Don't output initial dummy
+ symbol or section symbols if stripping all symbols and this is not
+ a relocateable link. Don't output the symbol string table if
+ there are no symbols.
+ (elf_link_flush_output_syms): Don't do anything if there are no
+ symbols to flush.
+
+Wed Jan 31 12:55:49 1996 Richard Henderson <rth@tamu.edu>
+
+ * coff-aux.c: New file.
+ * hosts/m68kaux.h: New file.
+ * config.bfd (m68*-apple-aux*): New target.
+ * configure.in (m68*-apple-aux*): New native host.
+ (m68kaux_coff_vec): New vector.
+ * configure: Rebuild.
+ * targets.c (m68kaux_coff_vec): Declare.
+ * coffcode.h (bfd_coff_backend_data): Add field
+ _bfd_coff_link_add_one_symbol.
+ (bfd_coff_link_add_one_symbol): Define.
+ (compare_arelent_ptr): New static function if TARG_AUX.
+ (coff_write_relocs): If TARG_AUX, sort the relocs.
+ (coff_write_object_contents): Set A/UX aouthdr magic number.
+ (coff_link_add_one_symbol): Define if not defined.
+ (bfd_coff_std_swap_table): Initialize new field.
+ * libcoff.h: Rebuild.
+ * cofflink.c (coff_link_add_symbols): Call
+ bfd_coff_link_add_one_symbol rather than
+ _bfd_generic_link_add_one_symbol.
+ * coff-m68k.c (COFF_PAGE_SIZE): Don't define if already defined.
+ * coff-alpha.c (alpha_ecoff_backend_data): Initialize new field.
+ * coff-mips.c (mips_ecoff_backend_data): Likewise.
+ * Makefile.in: Rebuild dependencies.
+ (BFD32_BACKENDS): Add coff-aux.o.
+ (BFD32_BACKENDS_CFILES): Add coff-aux.c.
+
+Wed Jan 31 11:37:46 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf32-m68k.c (elf_m68k_relocate_section): Fix R_68K_GOT*
+ relocation; ignore addend with R_68K_{GOT,PLT}*O relocation.
+
+Tue Jan 30 12:09:04 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (do_maintainer_clean): Remove $(srcdir)/bfd-in2.h,
+ $(srcdir)/libbfd.h and $(srcdir)/libcoff.h.
+ (maintainer-clean): Warn about deleting special files.
+ (bfd-in2.h, libbfd.h, libcoff.h): New targets.
+
+ * elf32-hppa.c (elf32_hppa_relocate_section): Handle indirect and
+ warning symbols correctly.
+ * elf32-i386.c (elf_i386_relocate_section): Likewise.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+ * elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+
+ * syms.c (_bfd_stab_section_find_nearest_line): Add casts to avoid
+ warnings.
+
+Mon Jan 29 14:27:24 1996 Kim Knuttila <krk@cygnus.com>
+
+ * libcoff-in.h: aligned newly exported names with bfd naming
+ conventions. Removed an erroneous define of POWERPC_LE_PE.
+ * libcoff.h: Rebuild.
+ * cofflink.c, coff-ppc.c: the above function name changes
+
+Mon Jan 29 13:06:28 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ From Basim Kadhim <kadhim@spock.cs.colorado.edu>:
+ * ecoff.c (struct extsym_info): Define.
+ (_bfd_ecoff_bfd_final_link): Pass a pointer to struct extsym_info
+ to ecoff_link_write_external.
+ (ecoff_link_write_external): Accept a struct extsym_info pointer.
+ Strip symbols when appropriate.
+
+ Based on patches from Ronald F. Guilmette <rfg@monkeys.com>:
+ * syms.c (BSF_OBJECT): Define.
+ (bfd_print_symbol_vandf): Print 'O' for BSF_OBJECT.
+ * bfd-in2.h: Rebuild.
+ * elfcode.h (elf_slurp_symbol_table): Set BSF_OBJECT for an
+ STT_OBJECT symbol.
+ * elf.c (swap_out_syms): Only set type to STT_OBJECT if BSF_OBJECT
+ is set.
+
+ * elf32-i386.c (elf_i386_relocate_section): If -Bsymbolic, when
+ copying relocs into a shared object, treat a defined global symbol
+ as a local symbol.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-mips.c (mips_elf_relocate_section): Likewise.
+ * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+
+ * elflink.h (elf_link_add_object_symbols): Only set weakdef to a
+ real defined symbol, not to a weak defined symbol.
+
+Mon Jan 29 11:34:36 1996 Kim Knuttila <krk@cygnus.com>
+
+ * cofflink.c: removed the POWERPC_LE_PE hack, promoted some types
+ and made a few static functions externs.
+
+ * coff-ppc.c (ppc_bfd_coff_final_link): new function, replaces the
+ POWERPC_LE_PE hack in cofflink.
+
+ * libcoff-in.h: promoted the following from cofflink.c to allow
+ _bfd_coff_final_link to be overridden - STRING_SIZE_SIZE,
+ coff_debug_merge_element, struct coff_debug_merge_type,
+ coff_debug_merge_hash_entry, coff_debug_merge_hash_table,
+ coff_debug_merge_hash_table_init, coff_debug_merge_hash_table_free,
+ coff_debug_merge_hash_lookup, coff_link_section_info,
+ coff_final_link_info, coff_debug_merge_hash_newfunc,
+ coff_write_global_sym, coff_link_input_bfd, coff_reloc_link_order.
+
+ * libcoff.h: re-gen'd
+
+Fri Jan 26 18:33:35 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * syms.c: Include "bfdlink.h".
+ (struct stab_find_info): Define.
+ (_bfd_stab_section_find_nearest_line): New function.
+ * libbfd-in.h (_bfd_stab_section_find_nearest_line): Declare.
+ * libbfd.h: Rebuild.
+ * elf-bfd.h (struct elf_obj_tdata): Add line_info field.
+ * elf.c (_bfd_elf_find_nearest_line): Try calling
+ _bfd_stab_section_find_nearest_line before searching the ELF
+ symbol table. Find the closest STT_FUNC symbol, not the last one.
+ * libcoff-in.h (coff_data_type): Add line_info field.
+ * libcoff.h: Rebuild.
+ * coffgen.c (coff_find_nearest_line): Try calling
+ _bfd_stab_section_find_nearest_line before searching the COFF
+ symbol table.
+ * Makefile.in: Rebuild dependencies.
+
+Fri Jan 26 16:11:19 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (R_PPC_EMB_SDA21 relocations): Make relocation size
+ 4 bytes, so we get the correct value when updating the register
+ field in little endian mode.
+
+Thu Jan 25 12:14:16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libcoff-in.h (struct xcoff_tdata): Remove toc_section and
+ entry_section fields. Add sntoc and snentry fields.
+ * libcoff.h: Rebuild.
+ * coffcode.h (coff_mkobject_hook): Initialize sntoc and snentry,
+ not toc_section and entry_section (the COFF file does not have any
+ sections at this point).
+ (coff_write_object_contents): Set o_snentry and o_sntoc from
+ snentry and sntoc rather than entry_section and toc_section.
+ * coff-rs6000.c (xcoff_copy_private_bfd_data): Copy sntoc and
+ snentry, not toc_section and entry_section.
+ * xcofflink.c (bfd_xcoff_size_dynamic_sections): Don't set
+ entry_section from hentry.
+ (xcoff_link_input_bfd): If a defined symbol has XCOFF_ENTRY set,
+ set snenty.
+ (xcoff_link_input_bfd): Set sntoc, not toc_section.
+ (xcoff_write_global_symbol): Get toc_section from sntoc, rather
+ than using toc_section directly.
+
+ * archures.c: Add missing `.' in enum bfd_architecture.
+ * bfd-in2.h: Rebuild.
+
+ * config.bfd (i[345]86-*-sco*elf*): Use bfd_elf32_i386_vec. From
+ Robert Lipe <robertl@arnet.com>.
+
+Thu Jan 25 12:08:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_size_dynamic_sections): Add .rela.sdata{,2}
+ to sections we allocate. Use bfd_zalloc to allocate initialial
+ sections, not bfd_alloc.
+ (ppc_elf_check_relocs): Remove BFD_ASSERTs for !shared from
+ SDA{,2}I16 relocations.
+ (ppc_elf_add_symbol_hook): Use the value of -G nn to determine
+ whether to put something in .sbss or not.
+ (ppc_elf_relocate_section): Add support for more relocations. Add
+ in sec->output_offset where appropriate. Make error messages
+ include the symbol name.
+
+ * elflink.c (_bfd_elf_create_linker_section): Lookup symbol before
+ trying to add it to the symbol table, so _GLOBAL_OFFSET_TABLE_
+ doesn't get redefined messages if -shared.
+
+ * elflink.h (elf_create_pointer_linker_section) Only bump RELA
+ section if the rel_section field has been set up.
+
+Wed Jan 24 20:40:26 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Fix typo in eabi
+ relocations.
+
+Wed Jan 24 10:38:34 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Delete checking
+ of flags, only flags used are controlled by mach number. Bump up
+ output file mach number to highest of input file mach numbers.
+ (elf32_sparc_object_p): Watch for EF_SPARC_SUN_US1.
+ (elf32_sparc_final_write_processing): Set EF_SPARC_SUN_US1 if v8plusa.
+
+ * config.bfd (sparc64-*-{sysv4*,solaris2*}): Comment out
+ bfd_elf64_sparc_vec support.
+
+Tue Jan 23 14:33:05 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_copy_private_bfd_data): Don't complain if
+ the embedded bit is set on some objects and not on others. Just
+ or it together.
+ (ppc_elf_relocate_section): Implement R_PPC_EMB_{SDA21,RELSDA}
+ relocations.
+
+Tue Jan 23 14:22:45 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_new_section_hook): Don't try to align the
+ .stabstr section.
+
+ * coffcode.h (coff_set_section_contents): Fix the handling of the
+ .lib section to work even if the entire section contents are
+ written at once. From Gvran Uddeborg <gvran@uddeborg.pp.se> and
+ Robert Lipe <robertl@arnet.com>.
+
+Mon Jan 22 18:45:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elflink.h (elf_finish_pointer_linker_section): Don't allocate
+ memory here for contents.
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Bump up _SDA_BASE_ and
+ _SDA2_BASE_ by 32768.
+ (ppc_elf_size_dynamic_sections): #if out PLT code which we haven't
+ started using. Allocate contents for .sdata and .sdata2 sections
+ also.
+ (ppc_elf_check_relocs): Use bfd_get_section_name in debug message,
+ rather than _name.
+ (ppc_elf_finish_dynamic_symbol): Remove code that attempted to
+ size _SDA{,2}_BASE_.
+ (ppc_elf_relocate_section): Change how sdata{,2} relocations are
+ done.
+
+Mon Jan 22 08:52:04 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * elflink.h (elf_finish_pointer_linker_section): Fix typo.
+
+ * archures.c (bfd_mach_sparc_v9): Renamed from bfd_mach_sparc64.
+ (bfd_mach_sparc_{v8plus,v8plusa}): Define.
+ (bfd_mach_sparc_v9a): Define.
+ (bfd_mach_sparc_v9_p): Define.
+ * bfd-in2.h: Regenerated.
+ * aoutx.h (aout,machine_type): bfd_mach_sparc64 renamed to
+ bfd_mach_sparc_v9.
+ * elf64-sparc.c (sparc64_elf_object_p): Likewise.
+ * config.bfd (sparc64-*-sysv4*,sparc64-*-solaris2*): Set targ_defvec
+ to bfd_elf32_sparc_vec.
+ * cpu-sparc.c (arch_info_struct): Renamed from sparc_arch_info.
+ Add v8plus{,a} support.
+ Add v9a support.
+ (sparc_compatible): New function.
+ * elf32-sparc.h: #include "elf/sparc.h".
+ (elf32_sparc_merge_private_bfd_data, elf32_sparc_object_p,
+ elf32_sparc_final_write_processing): New functions.
+ (bfd_elf32_bfd_merge_private_bfd_data, elf_backend_object_p,
+ elf_backend_final_write_processing): Define.
+
+Mon Jan 22 11:21:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf-bfd.h (struct elf_link_hash_entry): Add
+ linker_section_pointer field.
+ (enum elf_linker_section_enum): Enumeration for new way of
+ creating linker dynamic sections and symbols.
+ (elf_linker_section{,_pointers}): New structures for creating
+ dynamic sections and symbols.
+ (elf_obj_tdata): Add linker_section_pointers and linker_section
+ fields.
+ (elf_local_ptr_offsets,elf_linker_section): New accessor macros.
+ (_bfd_elf_create_linker_section): New declarations.
+ (_bfd_elf_find_pointer_linker_section): Ditto.
+ (bfd_elf{32,64}_{create,finish}_pointer_linker_section): Ditto.
+ (_bfd_elf_make_linker_section_rela): Ditto.
+
+ * elf.c (_bfd_elf_link_hash_newfunc): Initialize new fields.
+
+ * elf32-ppc.c (ppc_elf_create_dynamic_sections): Delete.
+ (ppc_elf_create_linker_section): New function to create the
+ sections .got, .sdata, and .sdata2.
+ (ppc_elf_size_dynamic_sections): Zap .rela.{sdata,sdata2} if
+ needed.
+ (ppc_elf_check_relocs): Support more of the eabi relocations.
+ (ppc_elf_relocate_section): Ditto.
+ (ppc_elf_finish_dynamic_symbols): Adjust _SDA{,2}_BASE_ by 32768
+ if the .sdata{,2} + .sbss{,2} section size is > 32k.
+
+ * elflink.h (elf_create_pointer_linker_section): New function to
+ create initialized pointers in dynamic linker sections.
+ (elf_finish_pointer_linker_section): Actually intialize the
+ pointers created above.
+
+ * elfcode.h (bfd_elf{32,64}_create_pointer_linker_section): New
+ macros to provide both 32 and 64 bit versions of
+ elf_create_pointer_linker_section.
+ (bfd_elf{32,64}_finish_pointer_linker_section): New macros to
+ provide both 32 and 64 bit versions of
+ elf_finish_pointer_linker_section.
+
+ * elflink.c (_bfd_elf_create_linker_section): New function to
+ create a linker section.
+ (_bfd_elf_find_pointer_linker_section): Find a unique pointer to a
+ given address in the linker pointer offsets created for a given
+ symbol.
+ (_bfd_elf_make_linker_section_rela): Make a RELA section
+ corresponding to the generated linker section.
+
+Sat Jan 20 08:36:10 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * elf32-sparc.c (ELF_MACHINE_ALT1): Define.
+
+Thu Jan 18 18:25:34 1996 Kim Knuttila <krk@cygnus.com>
+
+ * coff-ppc.c (coff_ppc_relocate_section): changed TOCDEFN relocs.
+ (coff_ppc_relocate_section): Handle special values for gcc built dlls.
+ (dump_toc): fix diagnosing code to identify out-of-toc-bounds entries.
+ Also begin the toc at 4 as an eye catcher ('31313131' marks the first
+ toc entry in an objdump) for now.
+ (ppc_do_last, ppc_get_last): New function - needed to save processing
+ the toc owner to the end.
+ (ppc_coff_swap_sym_in_hook): Removed an incorrect hack for doing the
+ toc owner last.
+
+ * cofflink.c (_bfd_coff_final_link): Added a new hack to keep the
+ toc owner from being done till last. Must define POWERPC_LE_PC
+ to enable it.
+
+ * coffcode.h (coff_set_alignment_hook): alignment setting for .stab
+
+ * peicode.h (coff_swap_scnhdr_out): set section flags for stab/str
+ to INFO.
+ (coff_swap_aouthdr_out): Removed a non-working hack for computing the
+ SizeOfImage for PowerPC. Ignore the size of the .junk section.
+
+Thu Jan 18 17:42:12 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elfcore.h: Include <signal.h> before <sys/procfs.h>.
+
+Wed Jan 17 12:40:14 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cpu-powerpc.c (arch_info_struct): Change last entry to not point
+ back to first.
+ (bfd_powerpc_arch): Point at first entry in arch_info_struct.
+
+Tue Jan 16 15:10:49 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): Don't increment file
+ offset for a segment which contains no loadable sections.
+
+Mon Jan 15 17:46:27 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * reloc.c: Add new PowerPC relocations.
+ * {bfd-in2,libbfd}.h: Regenerate.
+
+ * elf32-ppc.c (ppc_elf_howto_raw): Add more PPC relocations.
+ (ppc_elf_reloc_type_lookup): Lookup new relocations.
+
+Mon Jan 15 14:29:44 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aoutx.h (howto_table_ext): Fix RELOC_BASE10 and RELOC_BASE22
+ entries.
+
+ * sunos.c (sunos_scan_ext_relocs): Don't fail assert if
+ info->shared.
+
+ * coffgen.c (coff_find_nearest_line): Don't try to cache
+ information in sections that are not owned by a BFD. From Richard
+ Henderson <richard@atheist.tamu.edu>.
+
+ * elf32-mips.c: Numerous changes to dynamic linking code, mostly
+ from Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
+ * elflink.h (elf_link_output_extsym): Remove special check for
+ _rld_new_interface.
+
+ * ecoffswap.h: Add prototypes for static functions.
+
+Sun Jan 14 21:36:08 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_{unsupported,std}_reloc): Remove functions.
+ (ppc_elf_howto_raw): Remove ppc_elf_{unsupported,std}_reloc
+ references.
+ (ppc_elf_relocate_section): No longer allow .sdata/.sbss sections
+ to satisfy a TOC16 relocation. Rewrite unsupported relocation
+ support. Begin support for R_PPC_SDA{2,}REL.
+
+Sat Jan 13 09:36:52 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_create_dynamic_sections): New function to
+ create the .got and .got.neg sections.
+ (ppc_elf_size_dynamic_sections): Call it.
+ (ppc_elf_check_relocs): Call it.
+ (ppc_elf_size_dynamic_sections): Support .got.neg, just like .got.
+ (ppc_elf_check_relocs): Add error messages for relocations we
+ don't yet support. Do not include R_PPC_SDAREL16 like a GOT
+ relocation.
+
+Fri Jan 12 15:27:59 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf32-ppc.c (ppc_elf_fake_sections): Define, and handle the new
+ section flags for V.4 and eabi.
+
+Fri Jan 12 13:59:16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * elf.c (assign_file_positions_for_segments): If a segment
+ contains no sections, don't mark it as readable.
+
+ * elf-bfd.h (_bfd_elf_section_from_bfd_section): Declare.
+ * elfcode.h (_bfd_elf_section_from_bfd_section): Don't declare.
+
+ * elf.c (_bfd_elf_print_private_bfd_data): Dump contents of
+ dynamic section, if there is one.
+ * elf-bfd.h (struct elf_size_info): Add swap_dyn_in field.
+ (bfd_elf32_swap_dyn_in): Change type of second parameter to PTR.
+ (bfd_elf64_swap_dyn_in): Likewise.
+ * elfcode.h (elf_swap_dyn_in): Change type of second parameter to
+ PTR.
+ (NAME(_bfd_elf,size_info)): Initialize swap_dyn_in field.
+
+ * elf32-i386.c (elf_i386_size_dynamic_sections): Don't create a
+ DT_TEXTREL entry because of .rel.plt. From Martin Pirker
+ <pirker@eiunix.tuwien.ac.at>.
+
+Thu Jan 11 17:06:14 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * section.c (SEC_{EXCLUDE,SORT_ENTRIES}): New section flags for
+ PowerPC V.4 and eabi.
+ * bfd-in2.h: Regenerate.
+ * libfd.h: Regenerate.
+
+ * elfxx-target.h (TARGET_{BIG,LITTLE}_SYM): Add new flags.
+
+ * elf32-ppc.c (ppc_elf_section_from_shdr): Support SHT_ORDERED
+ section type and SHF_EXCLUDE section flag, turning them into the
+ appropriate bfd section flag.
+
+Thu Jan 11 11:23:30 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xcofflink.c (xcoff_link_add_symbols): Create the special
+ sections if we see a DYNAMIC object, in case that is the only
+ XCOFF input object we see.
+
+ * elf32-mips.c: Extensive changes for a start at dynamic linking
+ support, from Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
+
+ * elf-bfd.h (struct elf_backend_data): Add type_change_ok field.
+ (struct elf_backend_data): Remove
+ elf_backend_create_program_headers field. Add
+ elf_backend_additional_program_headers and
+ elf_backend_modify_segment_map fields.
+ * elfxx-target.h (elf_backend_type_change_ok): Define if not
+ defined.
+ (elf_backend_additional_program_headers): Likewise.
+ (elf_backend_modify_segment_map): Likewise.
+ (elf_backend_create_program_headers): Don't define.
+ (elfNN_bed): Change to account for field changes.
+ * elf.c (assign_file_positions_for_segments): Call new
+ modify_segment_map backend function. Don't call old
+ create_program_headers backend function.
+ (get_program_header_size): Call additional_program_headers rather
+ than create_program_headers.
+ * elflink.h (elf_link_add_object_symbols): Initialize
+ type_change_ok from new backend field.
+ (elf_link_output_extsym): Don't warn if _rld_new_interface is
+ defined.
+ (elf_reloc_link_order): Treat a reloc against a defined symbol as
+ a reloc against the appropriate section.
+
+ * elf-bfd.h (struct bfd_elf_section_data): Add tdata field.
+ (struct elf_obj_tdata): Rename ppc_flags_init field to flags_init.
+ (elf_flags_init): Rename from elf_ppc_flags_init.
+ * elf32-ppc.c (ppc_elf_set_private_flags): Use elf_flags_init, not
+ elf_ppc_flags_init.
+ (ppc_elf_copy_private_bfd_data): Likewise.
+ (ppc_elf_merge_private_bfd_data): Likewise.
+
+ * elf32-m68k.c (howto_table): Change src_mask to 0 for all
+ relocation entries.
+
+Tue Jan 9 15:22:53 1996 David Mosberger-Tang <davidm@azstarnet.com>
+
+ * coff-alpha.c (alpha_relocate_section): During final link, allow
+ output .lita section to be bigger than 64k by adjusting gp value
+ on a per-input section basis.
+ * libecoff.h (struct ecoff_tdata): Add issued_multiple_gp_warning
+ field.
+ (struct ecoff_section_tdata): Add gp field.
+
+Tue Jan 9 12:00:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Handle Alpha ECOFF changes in OSF/1 3.2.
+ * libecoff.h (struct ecoff_backend_data): Add get_elt_at_filepos
+ field.
+ * coff-alpha.c: Include "aout/ar.h".
+ (alpha_ecoff_get_relocated_section_contents): Don't require an
+ ALPHA_R_IGNORE reloc after an ALPHA_R_GPDISP reloc, since OSF/1
+ 3.2 doesn't generate one.
+ (alpha_relocate_section): Likewise.
+ (alpha_ecoff_slurp_armap): Define.
+ (alpha_ecoff_slurp_extended_name_table): Define.
+ (alpha_ecoff_construct_extended_name_table): Define.
+ (alpha_ecoff_truncate_arname): Define.
+ (alpha_ecoff_write_armap): Define.
+ (alpha_ecoff_generic_stat_arch_elt): Define.
+ (alpha_ecoff_update_armap_timestamp): Define.
+ (ARFZMAG): Define.
+ (alpha_ecoff_read_ar_hdr): New static function.
+ (alpha_ecoff_get_elt_at_filepos): New static function.
+ (alpha_ecoff_openr_next_archived_file): New static function.
+ (alpha_ecoff_get_elt_at_index): New static function.
+ (alpha_ecoff_backend_data): Initialize get_elt_at_filepos field.
+ (ecoffalpha_little_vec): Change BFD_JUMP_TABLE_ARCHIVE from
+ _bfd_ecoff to alpha_ecoff.
+ * ecoff.c (ecoff_link_add_archive_symbols): Use get_elt_at_filepos
+ field from backend structure, rather than always calling
+ _bfd_get_elt_at_filepos.
+ * coff-mips.c (mips_ecoff_backend_data): Initialize
+ get_elt_at_filepos field.
+ * archive.c (_bfd_generic_read_ar_hdr_mag): New function, copied
+ from _bfd_generic_read_ar_hdr with minor changes.
+ (_bfd_generic_read_ar_hdr): Use _bfd_generic_read_ar_hdr_mag.
+ * libbfd-in.h (_bfd_generic_read_ar_hdr_mag): Declare.
+ * libbfd.h: Rebuild.
+
+ * bfd-in.h (BFD_IN_MEMORY): Define.
+ * libbfd-in.h (struct bfd_in_memory): Define.
+ * libbfd.c (bfd_read): Handle BFD_IN_MEMORY flag.
+ (bfd_get_file_window): Don't try to map a BFD_IN_MEMORY file.
+ (bfd_write, bfd_stat): Abort if BFD_IN_MEMORY is set.
+ (bfd_tell, bfd_flush, bfd_seek): Handle BFD_IN_MEMORY flag.
+ * bfd.c (struct _bfd): Change iostream field from char * to PTR.
+ (bfd_get_size): Handle BFD_IN_MEMORY flag.
+ * cache.c (bfd_cache_close): Ignore BFD_IN_MEMORY files.
+ (bfd_open_file): Cast to PTR, not char *, when setting iostream.
+ (bfd_cache_lookup_worker): Abort if BFD_IN_MEMORY is set.
+ * opncls.c (bfd_fdopenr): Cast to PTR, not char *, when setting
+ iostream.
+ (bfd_openstreamr): Likewise.
+ * aoutx.h (NAME(aout,some_aout_object_p)): Only fstat iostream if
+ BFD_IN_MEMORY is not set.
+ * riscix.c (riscix_some_aout_object_p): Likewise.
+ * bfd-in2.h, libbfd.h: Rebuild.
+
+ * targets.c (bfd_target): Add _bfd_get_elt_at_index field.
+ (BFD_JUMP_TABLE_ARCHIVE): Add _get_elt_at_index.
+ (bfd_get_elt_at_index): Define.
+ * archive.c (_bfd_generic_get_elt_at_index): Rename from
+ bfd_get_elt_at_index. Change index parameter from int to
+ symindex.
+ * libbfd-in.h (_bfd_generic_get_elt_at_index): Declare.
+ (_bfd_noarchive_get_elt_at_index): Define.
+ (_bfd_archive_bsd_get_elt_at_index): Define.
+ (_bfd_archive_coff_get_elt_at_index): Define.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * aout-target.h (MY_get_elt_at_index): Define if not defined.
+ * coff-rs6000.c (xcoff_get_elt_at_index): Define.
+ * ieee.c (ieee_get_elt_at_index): Define.
+ * libecoff.h (_bfd_ecoff_get_elt_at_index): Define.
+ * oasys.c (oasys_get_elt_at_index): Define.
+ * som.c (som_get_elt_at_index): Define.
+
+ * ecoff.c (_bfd_ecoff_find_nearest_line): Don't restrict line
+ numbers to the .text section.
+
+Mon Jan 8 17:00:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_write_debug_part): Change return type to boolean.
+ If there is a SEC_DEBUGGING section, get the contents of the debug
+ information part from it.
+ (ieee_set_section_contents): Store the contents of a SEC_DEBUGGING
+ section in memory.
+ (ieee_write_object_contents): Check ieee_write_debug_part return.
+
+Thu Jan 4 17:12:37 1996 Fred Fish <fnf@cygnus.com>
+
+ * config.bfd (i[345]86-*-freebsd*): Add target.
+ * configure.in (i386freebsd_vec): Add vec.
+ * configure: Regenerate.
+ * Makefile.in (BFD32_BACKENDS): Add i386freebsd.o.
+ (BFD32_BACKENDS_CFILES): Add i386freebsd.c.
+ Rebuild dependencies..
+ * freebsd.h: New file.
+ * i386freebsd.c: New file.
+ * targets.c (i386freebsd_vec): Declare.
+ (bfd_target_vector): Add i386freebsd_vec.
+ * i386linux.c (SEGMENT_SIZE): Define as TARGET_PAGE_SIZE
+ * i386netbsd.c (SEGMENT_SIZE): Define as TARGET_PAGE_SIZE
+
+Thu Jan 4 16:27:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.c (ieee_slurp_debug): New static function.
+ (ieee_object_p): Call it.
+ (ieee_slurp_section_data): Skip debugging sections.
+ (ieee_get_reloc_upper_bound): Likewise.
+ (ieee_get_section_contents): Likewise.
+ (ieee_canonicalize_reloc): Likewise.
+ (ieee_write_section_part): Likewise.
+ (ieee_write_debug_part): Likewise.
+ (ieee_write_data_part): Likewise.
+ (init_for_output): Likewise.
+
+Wed Jan 3 19:42:47 1996 Michael Meissner <meissner@wogglebug.tiac.net>
+
+ * elf32-ppc.c (ppc_elf_relocate_section): Make @GOT relocations
+ work.
+ (ppc_elf_howto_raw): Just use bfd_elf_generic_reloc for all howto
+ relocs, since ppc_elf_relocate_section handles the linker case.
+ (ppc_elf_{addr16_ha,got16,toc16,brtaken}_reloc): Delete, no longer
+ used.
+ (ppc_elf_{addr16_ha,got16,toc16,brtaken}_inner): Merge these into
+ ppc_elf_relocate_section since that is now the only caller.
+ (ppc_elf_relocate_section): Ditto.
+
+Wed Jan 3 15:11:30 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_write_object_contents): If we don't know the
+ section of the entry point for an XCOFF executable, always set the
+ entry address to -1.
+
+Tue Jan 2 14:17:15 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * elf.c (bfd_section_from_shdr): Add support for note sections.
+
+Tue Jan 2 13:10:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfd-in.h (struct _symbol_info): Add stab_type field.
+ * bfd-in2.h: Rebuild.
+ * aoutx.h (NAME(aout,get_symbol_info)): Set stab_type.
+
+ * elf32-ppc.c: Remove trailing newline from calls to
+ _bfd_error_handler.
+ (ppc_elf_merge_private_bfd_data): Only warn about endianness
+ difference if target endianness is known.
+
+For older changes see ChangeLog-9495
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
new file mode 100644
index 00000000000..a15531171d8
--- /dev/null
+++ b/bfd/Makefile.am
@@ -0,0 +1,1065 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCDIR = $(srcdir)/../include
+CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
+DEP = mkdep
+
+SUBDIRS = doc po
+
+docdir = doc
+
+lib_LTLIBRARIES = libbfd.la
+
+# bfd.h goes here, for now
+BFD_H = bfd.h
+
+# Jim Kingdon notes:
+# Writing S-records should be included in all (or at least most)
+# *-*-coff, *-*-aout, etc., configurations, because people will want to
+# be able to use objcopy to create S-records. (S-records are not useful
+# for the debugger, so if you are downloading things as S-records you
+# need two copies of the executable, one to download and one for the
+# debugger).
+BFD_LIBS = \
+ archive.lo archures.lo bfd.lo cache.lo coffgen.lo corefile.lo \
+ format.lo init.lo libbfd.lo opncls.lo reloc.lo \
+ section.lo syms.lo targets.lo hash.lo linker.lo \
+ srec.lo binary.lo tekhex.lo ihex.lo stabs.lo stab-syms.lo
+
+BFD_LIBS_CFILES = \
+ archive.c archures.c bfd.c cache.c coffgen.c corefile.c \
+ format.c init.c libbfd.c opncls.c reloc.c \
+ section.c syms.c targets.c hash.c linker.c \
+ srec.c binary.c tekhex.c ihex.c stabs.c stab-syms.c
+
+# This list is alphabetized to make it easier to keep in sync
+# with the decls and initializer in archures.c.
+ALL_MACHINES = \
+ cpu-a29k.lo \
+ cpu-alpha.lo \
+ cpu-arc.lo \
+ cpu-arm.lo \
+ cpu-d10v.lo \
+ cpu-d30v.lo \
+ cpu-fr30.lo \
+ cpu-h8300.lo \
+ cpu-h8500.lo \
+ cpu-hppa.lo \
+ cpu-i386.lo \
+ cpu-i860.lo \
+ cpu-i960.lo \
+ cpu-m32r.lo \
+ cpu-m68k.lo \
+ cpu-m88k.lo \
+ cpu-m10200.lo \
+ cpu-m10300.lo \
+ cpu-mcore.lo \
+ cpu-mips.lo \
+ cpu-ns32k.lo \
+ cpu-powerpc.lo \
+ cpu-rs6000.lo \
+ cpu-sh.lo \
+ cpu-sparc.lo \
+ cpu-tic30.lo \
+ cpu-tic80.lo \
+ cpu-v850.lo \
+ cpu-vax.lo \
+ cpu-we32k.lo \
+ cpu-w65.lo \
+ cpu-z8k.lo
+
+ALL_MACHINES_CFILES = \
+ cpu-a29k.c \
+ cpu-alpha.c \
+ cpu-arc.c \
+ cpu-arm.c \
+ cpu-d10v.c \
+ cpu-d30v.c \
+ cpu-fr30.c \
+ cpu-h8300.c \
+ cpu-h8500.c \
+ cpu-hppa.c \
+ cpu-i386.c \
+ cpu-i860.c \
+ cpu-i960.c \
+ cpu-m32r.c \
+ cpu-m68k.c \
+ cpu-m88k.c \
+ cpu-m10200.c \
+ cpu-m10300.c \
+ cpu-mcore.c \
+ cpu-mips.c \
+ cpu-ns32k.c \
+ cpu-powerpc.c \
+ cpu-rs6000.c \
+ cpu-sh.c \
+ cpu-sparc.c \
+ cpu-tic30.c \
+ cpu-tic80.c \
+ cpu-v850.c \
+ cpu-vax.c \
+ cpu-we32k.c \
+ cpu-w65.c \
+ cpu-z8k.c
+
+# The .o files needed by all of the 32 bit vectors that are configured into
+# target_vector in targets.c if configured with --enable-targets=all.
+BFD32_BACKENDS = \
+ aout-adobe.lo \
+ aout-arm.lo \
+ aout-ns32k.lo \
+ aout-sparcle.lo \
+ aout-tic30.lo \
+ aout0.lo \
+ aout32.lo \
+ bout.lo \
+ cf-i386lynx.lo \
+ cf-m68klynx.lo \
+ cf-sparclynx.lo \
+ coff-a29k.lo \
+ coff-apollo.lo \
+ coff-arm.lo \
+ coff-aux.lo \
+ coff-h8300.lo \
+ coff-h8500.lo \
+ coff-i386.lo \
+ coff-go32.lo \
+ coff-i860.lo \
+ coff-i960.lo \
+ coff-m68k.lo \
+ coff-m88k.lo \
+ coff-mips.lo \
+ coff-pmac.lo \
+ coff-rs6000.lo \
+ coff-sh.lo \
+ coff-sparc.lo \
+ coff-stgo32.lo \
+ coff-svm68k.lo \
+ coff-tic30.lo \
+ coff-tic80.lo \
+ coff-u68k.lo \
+ coff-we32k.lo \
+ coff-w65.lo \
+ coff-z8k.lo \
+ cofflink.lo \
+ dwarf2.lo \
+ ecoff.lo \
+ ecofflink.lo \
+ elf.lo \
+ elf32-arc.lo \
+ elfarm-oabi.lo \
+ elfarm-nabi.lo \
+ elf32-d10v.lo \
+ elf32-d30v.lo \
+ elf32-fr30.lo \
+ elf32-gen.lo \
+ elf32-hppa.lo \
+ elf32-i386.lo \
+ elf32-i860.lo \
+ elf32-m32r.lo \
+ elf32-m68k.lo \
+ elf32-m88k.lo \
+ elf-m10200.lo \
+ elf-m10300.lo \
+ elf32-mcore.lo \
+ elf32-mips.lo \
+ elf32-ppc.lo \
+ elf32-sh.lo \
+ elf32-sparc.lo \
+ elf32-v850.lo \
+ elf32.lo \
+ elflink.lo \
+ hp300bsd.lo \
+ hp300hpux.lo \
+ som.lo \
+ i386aout.lo \
+ i386bsd.lo \
+ i386dynix.lo \
+ i386freebsd.lo \
+ i386linux.lo \
+ i386lynx.lo \
+ i386msdos.lo \
+ i386netbsd.lo \
+ i386mach3.lo \
+ i386os9k.lo \
+ ieee.lo \
+ m68k4knetbsd.lo \
+ m68klinux.lo \
+ m68klynx.lo \
+ m68knetbsd.lo \
+ m88kmach3.lo \
+ mipsbsd.lo \
+ newsos3.lo \
+ nlm.lo \
+ nlm32-i386.lo \
+ nlm32-sparc.lo \
+ nlm32-ppc.lo \
+ nlm32.lo \
+ ns32knetbsd.lo \
+ oasys.lo \
+ pc532-mach.lo \
+ pe-arm.lo \
+ pei-arm.lo \
+ pe-i386.lo \
+ pei-i386.lo \
+ pe-mcore.lo \
+ pei-mcore.lo \
+ pe-ppc.lo \
+ pei-ppc.lo \
+ ppcboot.lo \
+ reloc16.lo \
+ riscix.lo \
+ sparclinux.lo \
+ sparclynx.lo \
+ sparcnetbsd.lo \
+ sunos.lo \
+ vaxnetbsd.lo \
+ versados.lo \
+ vms.lo \
+ vms-gsd.lo \
+ vms-hdr.lo \
+ vms-misc.lo \
+ vms-tir.lo \
+ xcofflink.lo
+
+BFD32_BACKENDS_CFILES = \
+ aout-adobe.c \
+ aout-arm.c \
+ aout-ns32k.c \
+ aout-sparcle.c \
+ aout-tic30.c \
+ aout0.c \
+ aout32.c \
+ bout.c \
+ cf-i386lynx.c \
+ cf-m68klynx.c \
+ cf-sparclynx.c \
+ coff-a29k.c \
+ coff-apollo.c \
+ coff-arm.c \
+ coff-aux.c \
+ coff-h8300.c \
+ coff-h8500.c \
+ coff-i386.c \
+ coff-i860.c \
+ coff-go32.c \
+ coff-i960.c \
+ coff-m68k.c \
+ coff-m88k.c \
+ coff-mips.c \
+ coff-pmac.c \
+ coff-rs6000.c \
+ coff-sh.c \
+ coff-sparc.c \
+ coff-stgo32.c \
+ coff-svm68k.c \
+ coff-tic30.c \
+ coff-tic80.c \
+ coff-u68k.c \
+ coff-we32k.c \
+ coff-w65.c \
+ coff-z8k.c \
+ cofflink.c \
+ dwarf2.c \
+ ecoff.c \
+ ecofflink.c \
+ elf.c \
+ elf32-arc.c \
+ elfarm-oabi.c \
+ elfarm-nabi.c \
+ elf32-d10v.c \
+ elf32-d30v.c \
+ elf32-fr30.c \
+ elf32-gen.c \
+ elf32-hppa.c \
+ elf32-i386.c \
+ elf32-i860.c \
+ elf32-m32r.c \
+ elf32-m68k.c \
+ elf32-m88k.c \
+ elf-m10200.c \
+ elf-m10300.c \
+ elf32-mcore.c \
+ elf32-mips.c \
+ elf32-ppc.c \
+ elf32-sh.c \
+ elf32-sparc.c \
+ elf32-v850.c \
+ elf32.c \
+ elflink.c \
+ hp300bsd.c \
+ hp300hpux.c \
+ som.c \
+ i386aout.c \
+ i386bsd.c \
+ i386dynix.c \
+ i386freebsd.c \
+ i386linux.c \
+ i386lynx.c \
+ i386msdos.c \
+ i386netbsd.c \
+ i386mach3.c \
+ i386os9k.c \
+ ieee.c \
+ m68k4knetbsd.c \
+ m68klinux.c \
+ m68klynx.c \
+ m68knetbsd.c \
+ m88kmach3.c \
+ mipsbsd.c \
+ newsos3.c \
+ nlm.c \
+ nlm32-i386.c \
+ nlm32-sparc.c \
+ nlm32-ppc.c \
+ nlm32.c \
+ ns32knetbsd.c \
+ oasys.c \
+ pc532-mach.c \
+ pe-arm.c \
+ pei-arm.c \
+ pe-i386.c \
+ pei-i386.c \
+ pe-mcore.c \
+ pei-mcore.c \
+ pe-ppc.c \
+ pei-ppc.c \
+ ppcboot.c \
+ reloc16.c \
+ riscix.c \
+ sparclinux.c \
+ sparclynx.c \
+ sparcnetbsd.c \
+ sunos.c \
+ vaxnetbsd.c \
+ versados.c \
+ vms.c \
+ vms-gsd.c \
+ vms-hdr.c \
+ vms-misc.c \
+ vms-tir.c \
+ xcofflink.c
+
+# The .o files needed by all of the 64 bit vectors that are configured into
+# target_vector in targets.c if configured with --enable-targets=all
+# and --enable-64-bit-bfd.
+BFD64_BACKENDS = \
+ aout64.lo \
+ coff-alpha.lo \
+ demo64.lo \
+ elf64-alpha.lo \
+ elf64-gen.lo \
+ elf64-mips.lo \
+ elf64-sparc.lo \
+ elf64.lo \
+ nlm32-alpha.lo \
+ nlm64.lo
+
+BFD64_BACKENDS_CFILES = \
+ aout64.c \
+ coff-alpha.c \
+ demo64.c \
+ elf64-alpha.c \
+ elf64-gen.c \
+ elf64-mips.c \
+ elf64-sparc.c \
+ elf64.c \
+ nlm32-alpha.c \
+ nlm64.c
+
+OPTIONAL_BACKENDS = \
+ aix386-core.lo \
+ hpux-core.lo \
+ irix-core.lo \
+ lynx-core.lo \
+ osf-core.lo \
+ sco5-core.lo \
+ trad-core.lo \
+ cisco-core.lo
+
+OPTIONAL_BACKENDS_CFILES = \
+ aix386-core.c \
+ hpux-core.c \
+ irix-core.c \
+ lynx-core.c \
+ osf-core.c \
+ sco5-core.c \
+ trad-core.c \
+ cisco-core.c
+
+# These are defined by configure.in:
+WORDSIZE = @wordsize@
+ALL_BACKENDS = @all_backends@
+BFD_BACKENDS = @bfd_backends@
+BFD_MACHINES = @bfd_machines@
+TDEFAULTS = @tdefaults@
+
+INCLUDES = -D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) -I$(srcdir)/../intl -I../intl
+
+# C source files that correspond to .o's.
+CFILES = \
+ $(BFD_LIBS_CFILES) \
+ $(ALL_MACHINES_CFILES) \
+ $(BFD32_BACKENDS_CFILES) \
+ $(BFD64_BACKENDS_CFILES) \
+ $(OPTIONAL_BACKENDS_CFILES)
+
+## This is a list of all .h files which are in the source tree.
+SOURCE_HFILES = \
+ aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h \
+ ecoffswap.h elf32-hppa.h \
+ elfcode.h genlink.h go32stub.h hppa_stubs.h libaout.h \
+ libbfd.h libcoff.h libecoff.h elf-bfd.h libhppa.h libieee.h \
+ libnlm.h liboasys.h netbsd.h nlm-target.h nlmcode.h ns32k.h \
+ som.h vms.h
+
+HFILES = \
+ elf32-target.h elf64-target.h targmatch.h \
+ $(SOURCE_HFILES)
+
+POTFILES = $(CFILES) $(SOURCE_HFILES)
+
+po/POTFILES.in: @MAINT@ Makefile
+ for file in $(POTFILES); do echo $$file; done | sort > tmp \
+ && mv tmp $(srcdir)/po/POTFILES.in
+
+diststuff: info
+
+# Various kinds of .o files to put in libbfd.a:
+# BFD_BACKENDS Routines the configured targets need.
+# BFD_MACHINES Architecture-specific routines the configured targets need.
+# COREFILE Core file routines for a native configuration
+OFILES = $(BFD_BACKENDS) $(BFD_MACHINES) @COREFILE@
+
+stamp-ofiles: Makefile
+ rm -f tofiles
+ f=""; \
+ for i in $(OFILES) ; do \
+ case " $$f " in \
+ *" $$i "*) ;; \
+ *) f="$$f $$i" ;; \
+ esac ; \
+ done ; \
+ echo $$f > tofiles
+ $(SHELL) $(srcdir)/../move-if-change tofiles ofiles
+ touch stamp-ofiles
+
+ofiles: stamp-ofiles ; @true
+
+libbfd_la_SOURCES = $(BFD_LIBS_CFILES)
+libbfd_la_DEPENDENCIES = $(OFILES) ofiles
+libbfd_la_LIBADD = `cat ofiles` @WIN32LIBADD@
+libbfd_la_LDFLAGS = -release $(VERSION) @WIN32LDFLAGS@
+
+# libtool will build .libs/libbfd.a. We create libbfd.a in the build
+# directory so that we don't have to convert all the programs that use
+# libbfd.a simultaneously. This is a hack which should be removed if
+# everything else starts using libtool. FIXME.
+
+noinst_LIBRARIES = libbfd.a
+libbfd_a_SOURCES =
+
+stamp-lib: libbfd.la
+ if [ -f .libs/libbfd.a ]; then \
+ cp .libs/libbfd.a libbfd.tmp; \
+ $(SHELL) $(srcdir)/../move-if-change libbfd.tmp libbfd.a; \
+ else true; fi
+ touch stamp-lib
+
+libbfd.a: stamp-lib ; @true
+
+# This file holds an array associating configuration triplets and
+# vector names. It is built from config.bfd. It is not compiled by
+# itself, but is included by targets.c.
+targmatch.h: config.bfd targmatch.sed
+ rm -f targmatch.h
+ sed -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new
+ mv -f targmatch.new targmatch.h
+
+# When compiling archures.c and targets.c, supply the default target
+# info from configure.
+
+targets.lo: targets.c config.status
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/targets.c
+
+archures.lo: archures.c config.status
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/archures.c
+
+elf32-target.h : elfxx-target.h
+ rm -f elf32-target.h
+ sed -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new
+ mv -f elf32-target.new elf32-target.h
+
+elf64-target.h : elfxx-target.h
+ rm -f elf64-target.h
+ sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
+ mv -f elf64-target.new elf64-target.h
+
+BFD_H_DEPS= $(INCDIR)/ansidecl.h
+LOCAL_H_DEPS= libbfd.h sysdep.h config.h
+$(BFD_LIBS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+$(BFD_MACHINES): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+$(BFD_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+$(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+
+# Install BFD include file, and others that it needs.
+install-data-local: $(BFD_H)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(includedir)
+ $(INSTALL_DATA) $(BFD_H) $(includedir)/bfd.h
+ $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(includedir)/ansidecl.h
+ $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(includedir)/bfdlink.h
+
+# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES).
+.dep: dep.sed $(CFILES) $(HFILES) bfd.h
+ rm -f .dep1
+ $(MAKE) DEP=$(DEP) .dep1
+ sed -f dep.sed <.dep1 >.dep
+
+# This rule really wants a mkdep that runs "gcc -MM".
+# The NetBSD mkdep overwrites any existing file contents, and doesn't insert
+# the "DO NOT DELETE" line.
+# Other mkdep versions require a file that already exists, and do insert it.
+# Hence the weirdness....
+.dep1: $(CFILES)
+ rm -f .dep2 .dep2a
+ echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2
+ echo > .dep2a
+ $(DEP) -f .dep2a $(INCLUDES) $(CFLAGS) $?
+ sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2
+ rm -f .dep2a
+ $(SHELL) $(srcdir)/../move-if-change .dep2 .dep1
+
+dep.sed: dep-in.sed config.status
+ sed <$(srcdir)/dep-in.sed >dep.sed \
+ -e 's!@BFD_H@!$(BFD_H)!' \
+ -e 's!@INCDIR@!$(INCDIR)!' \
+ -e 's!@SRCDIR@!$(srcdir)!'
+
+dep: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
+ cat .dep >> tmp-Makefile
+ $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile
+
+dep-in: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
+ cat .dep >> tmp-Makefile.in
+ $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
+
+dep-am: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am
+ cat .dep >> tmp-Makefile.am
+ $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am
+
+host-aout.lo: Makefile
+
+# The following program can be used to generate a simple config file
+# which can be folded into an h-XXX file for a new host, with some editing.
+aout-params.h: gen-aout
+ ./gen-aout host > aout-params.h
+gen-aout: $(srcdir)/gen-aout.c Makefile
+ $(CC) -o gen-aout $(CFLAGS) $(LFLAGS) $(srcdir)/gen-aout.c
+
+$(BFD_H): stmp-bfd-h ; @true
+
+stmp-bfd-h: bfd-in3.h
+ rm -f bfd-tmp.h
+ cp bfd-in3.h bfd-tmp.h
+ $(SHELL) $(srcdir)/../move-if-change bfd-tmp.h $(BFD_H)
+ rm -f bfd-tmp.h
+ touch stmp-bfd-h
+
+BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c section.c archures.c \
+ reloc.c syms.c bfd.c archive.c corefile.c targets.c format.c
+LIBBFD_H_FILES = libbfd-in.h init.c libbfd.c cache.c reloc.c archures.c elf.c
+LIBCOFF_H_FILES = libcoff-in.h coffcode.h
+
+# Could really use a "copy-if-change"...
+headers:
+ (cd $(docdir); $(MAKE) protos $(FLAGS_TO_PASS))
+ cp $(docdir)/bfd.h bfd-in2.h-new
+ $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
+ cp $(docdir)/libbfd.h libbfd.h-new
+ $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
+ cp $(docdir)/libcoff.h libcoff.h-new
+ $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+
+# We only rebuild the header files automatically if we have been
+# configured with --enable-maintainer-mode.
+
+$(srcdir)/bfd-in2.h: @MAINT@ stmp-bin2-h ; @true
+stmp-bin2-h: $(BFD_H_FILES)
+ (cd $(docdir); $(MAKE) $(FLAGS_TO_PASS) bfd.h)
+ cp $(docdir)/bfd.h bfd-in2.h-new
+ $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
+ touch stmp-bin2-h
+
+$(srcdir)/libbfd.h: @MAINT@ stmp-lbfd-h ; @true
+stmp-lbfd-h: $(LIBBFD_H_FILES)
+ (cd $(docdir); $(MAKE) $(FLAGS_TO_PASS) libbfd.h)
+ cp $(docdir)/libbfd.h libbfd.h-new
+ $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
+ touch stmp-lbfd-h
+
+$(srcdir)/libcoff.h: @MAINT@ stmp-lcoff-h ; @true
+stmp-lcoff-h: $(LIBCOFF_H_FILES)
+ (cd $(docdir); $(MAKE) $(FLAGS_TO_PASS) libcoff.h)
+ cp $(docdir)/libcoff.h libcoff.h-new
+ $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+ touch stmp-lcoff-h
+
+MOSTLYCLEANFILES = elf32-target.h elf64-target.h ofiles stamp-ofiles \
+ targmatch.h
+
+CLEANFILES = bfd.h dep.sed stmp-bfd-h .dep .dep1 libbfd.a stamp-lib \
+ stmp-bin2-h stmp-lbfd-h stmp-lcoff-h
+
+# We want to rerun configure if config.bfd or configure.host change.
+config.status: $(srcdir)/configure $(srcdir)/config.bfd $(srcdir)/configure.host
+ $(SHELL) ./config.status --recheck
+
+
+elfarm-oabi.lo: elfarm-oabi.c elf32-arm.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+
+# What appears below is generated by a hacked mkdep using gcc -MM.
+elfarm-nabi.lo: elfarm-nabi.c elf32-arm.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+
+# What appears below is generated by a hacked mkdep using gcc -MM.
+
+# DO NOT DELETE THIS LINE -- mkdep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+archive.lo: archive.c $(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h
+archures.lo: archures.c
+bfd.lo: bfd.c $(INCDIR)/libiberty.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h libcoff.h \
+ libecoff.h $(INCDIR)/coff/ecoff.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
+cache.lo: cache.c
+coffgen.lo: coffgen.c $(INCDIR)/coff/internal.h libcoff.h \
+ $(INCDIR)/bfdlink.h
+corefile.lo: corefile.c
+format.lo: format.c
+init.lo: init.c
+libbfd.lo: libbfd.c
+opncls.lo: opncls.c $(INCDIR)/objalloc.h
+reloc.lo: reloc.c $(INCDIR)/bfdlink.h
+section.lo: section.c $(INCDIR)/bfdlink.h
+syms.lo: syms.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def
+targets.lo: targets.c $(INCDIR)/fnmatch.h targmatch.h
+hash.lo: hash.c $(INCDIR)/objalloc.h
+linker.lo: linker.c $(INCDIR)/bfdlink.h genlink.h
+srec.lo: srec.c $(INCDIR)/libiberty.h
+binary.lo: binary.c
+tekhex.lo: tekhex.c $(INCDIR)/libiberty.h
+ihex.lo: ihex.c $(INCDIR)/libiberty.h
+stabs.lo: stabs.c $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def
+stab-syms.lo: stab-syms.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab.def
+cpu-a29k.lo: cpu-a29k.c
+cpu-alpha.lo: cpu-alpha.c
+cpu-arc.lo: cpu-arc.c
+cpu-arm.lo: cpu-arm.c
+cpu-d10v.lo: cpu-d10v.c
+cpu-d30v.lo: cpu-d30v.c
+cpu-fr30.lo: cpu-fr30.c
+cpu-h8300.lo: cpu-h8300.c
+cpu-h8500.lo: cpu-h8500.c
+cpu-hppa.lo: cpu-hppa.c
+cpu-i386.lo: cpu-i386.c
+cpu-i860.lo: cpu-i860.c
+cpu-i960.lo: cpu-i960.c
+cpu-m32r.lo: cpu-m32r.c
+cpu-m68k.lo: cpu-m68k.c
+cpu-m88k.lo: cpu-m88k.c
+cpu-m10200.lo: cpu-m10200.c
+cpu-m10300.lo: cpu-m10300.c
+cpu-mcore.lo: cpu-mcore.c
+cpu-mips.lo: cpu-mips.c
+cpu-ns32k.lo: cpu-ns32k.c ns32k.h
+cpu-powerpc.lo: cpu-powerpc.c
+cpu-rs6000.lo: cpu-rs6000.c
+cpu-sh.lo: cpu-sh.c
+cpu-sparc.lo: cpu-sparc.c
+cpu-tic30.lo: cpu-tic30.c
+cpu-tic80.lo: cpu-tic80.c
+cpu-v850.lo: cpu-v850.c
+cpu-vax.lo: cpu-vax.c
+cpu-we32k.lo: cpu-we32k.c
+cpu-w65.lo: cpu-w65.c
+cpu-z8k.lo: cpu-z8k.c
+aout-adobe.lo: aout-adobe.c $(INCDIR)/aout/adobe.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h \
+ $(INCDIR)/bfdlink.h
+aout-arm.lo: aout-arm.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aoutx.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+aout-ns32k.lo: aout-ns32k.c $(INCDIR)/aout/aout64.h \
+ ns32k.h libaout.h $(INCDIR)/bfdlink.h
+aout-sparcle.lo: aout-sparcle.c $(INCDIR)/bfdlink.h \
+ libaout.h aoutf1.h $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+aout-tic30.lo: aout-tic30.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h aoutx.h
+aout0.lo: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+aout32.lo: aout32.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h
+bout.lo: bout.c $(INCDIR)/bfdlink.h genlink.h $(INCDIR)/bout.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h
+cf-i386lynx.lo: cf-i386lynx.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+cf-m68klynx.lo: cf-m68klynx.c coff-m68k.c $(INCDIR)/coff/m68k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+cf-sparclynx.lo: cf-sparclynx.c coff-sparc.c $(INCDIR)/coff/sparc.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-a29k.lo: coff-a29k.c $(INCDIR)/coff/a29k.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-apollo.lo: coff-apollo.c $(INCDIR)/coff/apollo.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-arm.lo: coff-arm.c $(INCDIR)/coff/arm.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-aux.lo: coff-aux.c $(INCDIR)/coff/aux-coff.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/m68k.h coff-m68k.c libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-h8300.lo: coff-h8300.c $(INCDIR)/bfdlink.h genlink.h \
+ $(INCDIR)/coff/h8300.h $(INCDIR)/coff/internal.h libcoff.h \
+ coffcode.h coffswap.h
+coff-h8500.lo: coff-h8500.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/h8500.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-i386.lo: coff-i386.c $(INCDIR)/coff/i386.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-i860.lo: coff-i860.c $(INCDIR)/coff/i860.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-go32.lo: coff-go32.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-i960.lo: coff-i960.c $(INCDIR)/coff/i960.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-m68k.lo: coff-m68k.c $(INCDIR)/coff/m68k.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-m88k.lo: coff-m88k.c $(INCDIR)/coff/m88k.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-mips.lo: coff-mips.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ $(INCDIR)/coff/mips.h libcoff.h libecoff.h coffswap.h \
+ ecoffswap.h
+coff-pmac.lo: coff-pmac.c coff-rs6000.c $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-rs6000.lo: coff-rs6000.c $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-sh.lo: coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-sparc.lo: coff-sparc.c $(INCDIR)/coff/sparc.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-stgo32.lo: coff-stgo32.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/go32exe.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h \
+ go32stub.h
+coff-svm68k.lo: coff-svm68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-tic30.lo: coff-tic30.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/tic30.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-tic80.lo: coff-tic80.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/tic80.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-u68k.lo: coff-u68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-we32k.lo: coff-we32k.c $(INCDIR)/coff/we32k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-w65.lo: coff-w65.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/w65.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-z8k.lo: coff-z8k.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/z8k.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+cofflink.lo: cofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ libcoff.h
+dwarf2.lo: dwarf2.c $(INCDIR)/libiberty.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf2.h
+ecoff.lo: ecoff.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/ar.h \
+ $(INCDIR)/aout/ranlib.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ libaout.h $(INCDIR)/aout/aout64.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ libcoff.h libecoff.h
+ecofflink.lo: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/objalloc.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ libcoff.h libecoff.h
+elf.lo: elf.c $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
+elf32-arc.lo: elf32-arc.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/arc.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elfarm-oabi.lo: elfarm-oabi.c $(INCDIR)/elf/arm-oabi.h \
+ $(INCDIR)/elf/reloc-macros.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-arm.h elf32-target.h
+elfarm-nabi.lo: elfarm-nabi.c $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h elf32-arm.h \
+ elf32-target.h
+elf32-d10v.lo: elf32-d10v.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-d30v.lo: elf32-d30v.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-fr30.lo: elf32-fr30.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/fr30.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-gen.lo: elf32-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-hppa.lo: elf32-hppa.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ elf32-hppa.h libhppa.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \
+ hppa_stubs.h elf32-target.h
+elf32-i386.lo: elf32-i386.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/i386.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-i860.lo: elf32-i860.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-m32r.lo: elf32-m32r.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/m32r.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-m68k.lo: elf32-m68k.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/m68k.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-m88k.lo: elf32-m88k.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf-m10200.lo: elf-m10200.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf-m10300.lo: elf-m10300.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/mn10300.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-mcore.lo: elf32-mcore.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/mcore.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-mips.lo: elf32-mips.c $(INCDIR)/bfdlink.h genlink.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \
+ elf32-target.h
+elf32-ppc.lo: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-sh.lo: elf32-sh.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-sparc.lo: elf32-sparc.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-v850.lo: elf32-v850.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/v850.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32.lo: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ elfcore.h elflink.h
+elflink.lo: elflink.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
+hp300bsd.lo: hp300bsd.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+hp300hpux.lo: hp300hpux.c $(INCDIR)/aout/hp300hpux.h \
+ aoutx.h $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+som.lo: som.c
+i386aout.lo: i386aout.c $(INCDIR)/aout/aout64.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386bsd.lo: i386bsd.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386dynix.lo: i386dynix.c $(INCDIR)/aout/dynix3.h aoutx.h \
+ $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+i386freebsd.lo: i386freebsd.c freebsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386linux.lo: i386linux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+i386lynx.lo: i386lynx.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386msdos.lo: i386msdos.c libaout.h $(INCDIR)/bfdlink.h
+i386netbsd.lo: i386netbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386mach3.lo: i386mach3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+i386os9k.lo: i386os9k.c $(INCDIR)/bfdlink.h libaout.h \
+ $(INCDIR)/os9k.h
+ieee.lo: ieee.c $(INCDIR)/ieee.h libieee.h
+m68k4knetbsd.lo: m68k4knetbsd.c netbsd.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+m68klinux.lo: m68klinux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+m68klynx.lo: m68klynx.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+m68knetbsd.lo: m68knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+m88kmach3.lo: m88kmach3.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+mipsbsd.lo: mipsbsd.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+newsos3.lo: newsos3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+nlm.lo: nlm.c libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h
+nlm32-i386.lo: nlm32-i386.c $(INCDIR)/nlm/i386-ext.h \
+ libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
+nlm32-sparc.lo: nlm32-sparc.c $(INCDIR)/nlm/sparc32-ext.h \
+ libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
+nlm32-ppc.lo: nlm32-ppc.c $(INCDIR)/nlm/ppc-ext.h libnlm.h \
+ $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h \
+ nlmswap.h nlm-target.h
+nlm32.lo: nlm32.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
+ $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
+ns32knetbsd.lo: ns32knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+oasys.lo: oasys.c $(INCDIR)/oasys.h liboasys.h
+pc532-mach.lo: pc532-mach.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+pe-arm.lo: pe-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-arm.lo: pei-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pe-i386.lo: pe-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-i386.lo: pei-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pe-mcore.lo: pe-mcore.c coff-mcore.c $(INCDIR)/coff/mcore.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-mcore.lo: pei-mcore.c coff-mcore.c $(INCDIR)/coff/mcore.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pe-ppc.lo: pe-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-ppc.lo: pei-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+ppcboot.lo: ppcboot.c
+reloc16.lo: reloc16.c $(INCDIR)/bfdlink.h genlink.h \
+ $(INCDIR)/coff/internal.h libcoff.h
+riscix.lo: riscix.c libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \
+ aout-target.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h
+sparclinux.lo: sparclinux.c $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ libaout.h $(INCDIR)/bfdlink.h aout-target.h
+sparclynx.lo: sparclynx.c $(INCDIR)/aout/sun4.h libaout.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+sparcnetbsd.lo: sparcnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+sunos.lo: sunos.c $(INCDIR)/bfdlink.h libaout.h aoutf1.h \
+ $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+vaxnetbsd.lo: vaxnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+versados.lo: versados.c $(INCDIR)/libiberty.h
+vms.lo: vms.c $(INCDIR)/bfdlink.h vms.h
+vms-gsd.lo: vms-gsd.c $(INCDIR)/bfdlink.h vms.h
+vms-hdr.lo: vms-hdr.c $(INCDIR)/bfdlink.h vms.h
+vms-misc.lo: vms-misc.c $(INCDIR)/bfdlink.h vms.h
+vms-tir.lo: vms-tir.c $(INCDIR)/bfdlink.h vms.h
+xcofflink.lo: xcofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ libcoff.h
+aout64.lo: aout64.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h
+coff-alpha.lo: coff-alpha.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \
+ libecoff.h coffswap.h ecoffswap.h
+demo64.lo: demo64.c aoutf1.h $(INCDIR)/aout/sun4.h \
+ libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+elf64-alpha.lo: elf64-alpha.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/alpha.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
+ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h \
+ libcoff.h libecoff.h ecoffswap.h elf64-target.h
+elf64-gen.lo: elf64-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf64-target.h
+elf64-mips.lo: elf64-mips.c $(INCDIR)/aout/ar.h $(INCDIR)/bfdlink.h \
+ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \
+ elf64-target.h
+elf64-sparc.lo: elf64-sparc.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/reloc-macros.h \
+ elf64-target.h
+elf64.lo: elf64.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ elfcore.h elflink.h
+nlm32-alpha.lo: nlm32-alpha.c $(INCDIR)/nlm/alpha-ext.h \
+ libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
+nlm64.lo: nlm64.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
+ $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
+aix386-core.lo: aix386-core.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h
+hpux-core.lo: hpux-core.c
+irix-core.lo: irix-core.c
+lynx-core.lo: lynx-core.c
+osf-core.lo: osf-core.c
+sco5-core.lo: sco5-core.c libaout.h $(INCDIR)/bfdlink.h
+trad-core.lo: trad-core.c libaout.h $(INCDIR)/bfdlink.h \
+ hosts/i386linux.h
+cisco-core.lo: cisco-core.c
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
new file mode 100644
index 00000000000..9258df13b2f
--- /dev/null
+++ b/bfd/Makefile.in
@@ -0,0 +1,1599 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = .
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+AR = @AR@
+AS = @AS@
+BFD_HOST_64BIT_LONG = @BFD_HOST_64BIT_LONG@
+BFD_HOST_64_BIT = @BFD_HOST_64_BIT@
+BFD_HOST_64_BIT_DEFINED = @BFD_HOST_64_BIT_DEFINED@
+BFD_HOST_U_64_BIT = @BFD_HOST_U_64_BIT@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+COREFILE = @COREFILE@
+COREFLAG = @COREFLAG@
+DATADIRNAME = @DATADIRNAME@
+DLLTOOL = @DLLTOOL@
+EXEEXT = @EXEEXT@
+EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GT_NO = @GT_NO@
+GT_YES = @GT_YES@
+HDEFINES = @HDEFINES@
+INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
+INSTOBJEXT = @INSTOBJEXT@
+INTLDEPS = @INTLDEPS@
+INTLLIBS = @INTLLIBS@
+INTLOBJS = @INTLOBJS@
+LD = @LD@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+NM = @NM@
+PACKAGE = @PACKAGE@
+POFILES = @POFILES@
+POSUB = @POSUB@
+RANLIB = @RANLIB@
+TDEFINES = @TDEFINES@
+USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WIN32LDFLAGS = @WIN32LDFLAGS@
+WIN32LIBADD = @WIN32LIBADD@
+all_backends = @all_backends@
+bfd_backends = @bfd_backends@
+bfd_machines = @bfd_machines@
+l = @l@
+tdefaults = @tdefaults@
+wordsize = @wordsize@
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCDIR = $(srcdir)/../include
+CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
+DEP = mkdep
+
+SUBDIRS = doc po
+
+docdir = doc
+
+lib_LTLIBRARIES = libbfd.la
+
+# bfd.h goes here, for now
+BFD_H = bfd.h
+
+# Jim Kingdon notes:
+# Writing S-records should be included in all (or at least most)
+# *-*-coff, *-*-aout, etc., configurations, because people will want to
+# be able to use objcopy to create S-records. (S-records are not useful
+# for the debugger, so if you are downloading things as S-records you
+# need two copies of the executable, one to download and one for the
+# debugger).
+BFD_LIBS = \
+ archive.lo archures.lo bfd.lo cache.lo coffgen.lo corefile.lo \
+ format.lo init.lo libbfd.lo opncls.lo reloc.lo \
+ section.lo syms.lo targets.lo hash.lo linker.lo \
+ srec.lo binary.lo tekhex.lo ihex.lo stabs.lo stab-syms.lo
+
+
+BFD_LIBS_CFILES = \
+ archive.c archures.c bfd.c cache.c coffgen.c corefile.c \
+ format.c init.c libbfd.c opncls.c reloc.c \
+ section.c syms.c targets.c hash.c linker.c \
+ srec.c binary.c tekhex.c ihex.c stabs.c stab-syms.c
+
+
+# This list is alphabetized to make it easier to keep in sync
+# with the decls and initializer in archures.c.
+ALL_MACHINES = \
+ cpu-a29k.lo \
+ cpu-alpha.lo \
+ cpu-arc.lo \
+ cpu-arm.lo \
+ cpu-d10v.lo \
+ cpu-d30v.lo \
+ cpu-fr30.lo \
+ cpu-h8300.lo \
+ cpu-h8500.lo \
+ cpu-hppa.lo \
+ cpu-i386.lo \
+ cpu-i860.lo \
+ cpu-i960.lo \
+ cpu-m32r.lo \
+ cpu-m68k.lo \
+ cpu-m88k.lo \
+ cpu-m10200.lo \
+ cpu-m10300.lo \
+ cpu-mcore.lo \
+ cpu-mips.lo \
+ cpu-ns32k.lo \
+ cpu-powerpc.lo \
+ cpu-rs6000.lo \
+ cpu-sh.lo \
+ cpu-sparc.lo \
+ cpu-tic30.lo \
+ cpu-tic80.lo \
+ cpu-v850.lo \
+ cpu-vax.lo \
+ cpu-we32k.lo \
+ cpu-w65.lo \
+ cpu-z8k.lo
+
+
+ALL_MACHINES_CFILES = \
+ cpu-a29k.c \
+ cpu-alpha.c \
+ cpu-arc.c \
+ cpu-arm.c \
+ cpu-d10v.c \
+ cpu-d30v.c \
+ cpu-fr30.c \
+ cpu-h8300.c \
+ cpu-h8500.c \
+ cpu-hppa.c \
+ cpu-i386.c \
+ cpu-i860.c \
+ cpu-i960.c \
+ cpu-m32r.c \
+ cpu-m68k.c \
+ cpu-m88k.c \
+ cpu-m10200.c \
+ cpu-m10300.c \
+ cpu-mcore.c \
+ cpu-mips.c \
+ cpu-ns32k.c \
+ cpu-powerpc.c \
+ cpu-rs6000.c \
+ cpu-sh.c \
+ cpu-sparc.c \
+ cpu-tic30.c \
+ cpu-tic80.c \
+ cpu-v850.c \
+ cpu-vax.c \
+ cpu-we32k.c \
+ cpu-w65.c \
+ cpu-z8k.c
+
+
+# The .o files needed by all of the 32 bit vectors that are configured into
+# target_vector in targets.c if configured with --enable-targets=all.
+BFD32_BACKENDS = \
+ aout-adobe.lo \
+ aout-arm.lo \
+ aout-ns32k.lo \
+ aout-sparcle.lo \
+ aout-tic30.lo \
+ aout0.lo \
+ aout32.lo \
+ bout.lo \
+ cf-i386lynx.lo \
+ cf-m68klynx.lo \
+ cf-sparclynx.lo \
+ coff-a29k.lo \
+ coff-apollo.lo \
+ coff-arm.lo \
+ coff-aux.lo \
+ coff-h8300.lo \
+ coff-h8500.lo \
+ coff-i386.lo \
+ coff-go32.lo \
+ coff-i860.lo \
+ coff-i960.lo \
+ coff-m68k.lo \
+ coff-m88k.lo \
+ coff-mips.lo \
+ coff-pmac.lo \
+ coff-rs6000.lo \
+ coff-sh.lo \
+ coff-sparc.lo \
+ coff-stgo32.lo \
+ coff-svm68k.lo \
+ coff-tic30.lo \
+ coff-tic80.lo \
+ coff-u68k.lo \
+ coff-we32k.lo \
+ coff-w65.lo \
+ coff-z8k.lo \
+ cofflink.lo \
+ dwarf2.lo \
+ ecoff.lo \
+ ecofflink.lo \
+ elf.lo \
+ elf32-arc.lo \
+ elfarm-oabi.lo \
+ elfarm-nabi.lo \
+ elf32-d10v.lo \
+ elf32-d30v.lo \
+ elf32-fr30.lo \
+ elf32-gen.lo \
+ elf32-hppa.lo \
+ elf32-i386.lo \
+ elf32-i860.lo \
+ elf32-m32r.lo \
+ elf32-m68k.lo \
+ elf32-m88k.lo \
+ elf-m10200.lo \
+ elf-m10300.lo \
+ elf32-mcore.lo \
+ elf32-mips.lo \
+ elf32-ppc.lo \
+ elf32-sh.lo \
+ elf32-sparc.lo \
+ elf32-v850.lo \
+ elf32.lo \
+ elflink.lo \
+ hp300bsd.lo \
+ hp300hpux.lo \
+ som.lo \
+ i386aout.lo \
+ i386bsd.lo \
+ i386dynix.lo \
+ i386freebsd.lo \
+ i386linux.lo \
+ i386lynx.lo \
+ i386msdos.lo \
+ i386netbsd.lo \
+ i386mach3.lo \
+ i386os9k.lo \
+ ieee.lo \
+ m68k4knetbsd.lo \
+ m68klinux.lo \
+ m68klynx.lo \
+ m68knetbsd.lo \
+ m88kmach3.lo \
+ mipsbsd.lo \
+ newsos3.lo \
+ nlm.lo \
+ nlm32-i386.lo \
+ nlm32-sparc.lo \
+ nlm32-ppc.lo \
+ nlm32.lo \
+ ns32knetbsd.lo \
+ oasys.lo \
+ pc532-mach.lo \
+ pe-arm.lo \
+ pei-arm.lo \
+ pe-i386.lo \
+ pei-i386.lo \
+ pe-mcore.lo \
+ pei-mcore.lo \
+ pe-ppc.lo \
+ pei-ppc.lo \
+ ppcboot.lo \
+ reloc16.lo \
+ riscix.lo \
+ sparclinux.lo \
+ sparclynx.lo \
+ sparcnetbsd.lo \
+ sunos.lo \
+ vaxnetbsd.lo \
+ versados.lo \
+ vms.lo \
+ vms-gsd.lo \
+ vms-hdr.lo \
+ vms-misc.lo \
+ vms-tir.lo \
+ xcofflink.lo
+
+
+BFD32_BACKENDS_CFILES = \
+ aout-adobe.c \
+ aout-arm.c \
+ aout-ns32k.c \
+ aout-sparcle.c \
+ aout-tic30.c \
+ aout0.c \
+ aout32.c \
+ bout.c \
+ cf-i386lynx.c \
+ cf-m68klynx.c \
+ cf-sparclynx.c \
+ coff-a29k.c \
+ coff-apollo.c \
+ coff-arm.c \
+ coff-aux.c \
+ coff-h8300.c \
+ coff-h8500.c \
+ coff-i386.c \
+ coff-i860.c \
+ coff-go32.c \
+ coff-i960.c \
+ coff-m68k.c \
+ coff-m88k.c \
+ coff-mips.c \
+ coff-pmac.c \
+ coff-rs6000.c \
+ coff-sh.c \
+ coff-sparc.c \
+ coff-stgo32.c \
+ coff-svm68k.c \
+ coff-tic30.c \
+ coff-tic80.c \
+ coff-u68k.c \
+ coff-we32k.c \
+ coff-w65.c \
+ coff-z8k.c \
+ cofflink.c \
+ dwarf2.c \
+ ecoff.c \
+ ecofflink.c \
+ elf.c \
+ elf32-arc.c \
+ elfarm-oabi.c \
+ elfarm-nabi.c \
+ elf32-d10v.c \
+ elf32-d30v.c \
+ elf32-fr30.c \
+ elf32-gen.c \
+ elf32-hppa.c \
+ elf32-i386.c \
+ elf32-i860.c \
+ elf32-m32r.c \
+ elf32-m68k.c \
+ elf32-m88k.c \
+ elf-m10200.c \
+ elf-m10300.c \
+ elf32-mcore.c \
+ elf32-mips.c \
+ elf32-ppc.c \
+ elf32-sh.c \
+ elf32-sparc.c \
+ elf32-v850.c \
+ elf32.c \
+ elflink.c \
+ hp300bsd.c \
+ hp300hpux.c \
+ som.c \
+ i386aout.c \
+ i386bsd.c \
+ i386dynix.c \
+ i386freebsd.c \
+ i386linux.c \
+ i386lynx.c \
+ i386msdos.c \
+ i386netbsd.c \
+ i386mach3.c \
+ i386os9k.c \
+ ieee.c \
+ m68k4knetbsd.c \
+ m68klinux.c \
+ m68klynx.c \
+ m68knetbsd.c \
+ m88kmach3.c \
+ mipsbsd.c \
+ newsos3.c \
+ nlm.c \
+ nlm32-i386.c \
+ nlm32-sparc.c \
+ nlm32-ppc.c \
+ nlm32.c \
+ ns32knetbsd.c \
+ oasys.c \
+ pc532-mach.c \
+ pe-arm.c \
+ pei-arm.c \
+ pe-i386.c \
+ pei-i386.c \
+ pe-mcore.c \
+ pei-mcore.c \
+ pe-ppc.c \
+ pei-ppc.c \
+ ppcboot.c \
+ reloc16.c \
+ riscix.c \
+ sparclinux.c \
+ sparclynx.c \
+ sparcnetbsd.c \
+ sunos.c \
+ vaxnetbsd.c \
+ versados.c \
+ vms.c \
+ vms-gsd.c \
+ vms-hdr.c \
+ vms-misc.c \
+ vms-tir.c \
+ xcofflink.c
+
+
+# The .o files needed by all of the 64 bit vectors that are configured into
+# target_vector in targets.c if configured with --enable-targets=all
+# and --enable-64-bit-bfd.
+BFD64_BACKENDS = \
+ aout64.lo \
+ coff-alpha.lo \
+ demo64.lo \
+ elf64-alpha.lo \
+ elf64-gen.lo \
+ elf64-mips.lo \
+ elf64-sparc.lo \
+ elf64.lo \
+ nlm32-alpha.lo \
+ nlm64.lo
+
+
+BFD64_BACKENDS_CFILES = \
+ aout64.c \
+ coff-alpha.c \
+ demo64.c \
+ elf64-alpha.c \
+ elf64-gen.c \
+ elf64-mips.c \
+ elf64-sparc.c \
+ elf64.c \
+ nlm32-alpha.c \
+ nlm64.c
+
+
+OPTIONAL_BACKENDS = \
+ aix386-core.lo \
+ hpux-core.lo \
+ irix-core.lo \
+ lynx-core.lo \
+ osf-core.lo \
+ sco5-core.lo \
+ trad-core.lo \
+ cisco-core.lo
+
+
+OPTIONAL_BACKENDS_CFILES = \
+ aix386-core.c \
+ hpux-core.c \
+ irix-core.c \
+ lynx-core.c \
+ osf-core.c \
+ sco5-core.c \
+ trad-core.c \
+ cisco-core.c
+
+
+# These are defined by configure.in:
+WORDSIZE = @wordsize@
+ALL_BACKENDS = @all_backends@
+BFD_BACKENDS = @bfd_backends@
+BFD_MACHINES = @bfd_machines@
+TDEFAULTS = @tdefaults@
+
+INCLUDES = -D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) -I$(srcdir)/../intl -I../intl
+
+# C source files that correspond to .o's.
+CFILES = \
+ $(BFD_LIBS_CFILES) \
+ $(ALL_MACHINES_CFILES) \
+ $(BFD32_BACKENDS_CFILES) \
+ $(BFD64_BACKENDS_CFILES) \
+ $(OPTIONAL_BACKENDS_CFILES)
+
+
+SOURCE_HFILES = \
+ aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h \
+ ecoffswap.h elf32-hppa.h \
+ elfcode.h genlink.h go32stub.h hppa_stubs.h libaout.h \
+ libbfd.h libcoff.h libecoff.h elf-bfd.h libhppa.h libieee.h \
+ libnlm.h liboasys.h netbsd.h nlm-target.h nlmcode.h ns32k.h \
+ som.h vms.h
+
+
+HFILES = \
+ elf32-target.h elf64-target.h targmatch.h \
+ $(SOURCE_HFILES)
+
+
+POTFILES = $(CFILES) $(SOURCE_HFILES)
+
+# Various kinds of .o files to put in libbfd.a:
+# BFD_BACKENDS Routines the configured targets need.
+# BFD_MACHINES Architecture-specific routines the configured targets need.
+# COREFILE Core file routines for a native configuration
+OFILES = $(BFD_BACKENDS) $(BFD_MACHINES) @COREFILE@
+
+libbfd_la_SOURCES = $(BFD_LIBS_CFILES)
+libbfd_la_DEPENDENCIES = $(OFILES) ofiles
+libbfd_la_LIBADD = `cat ofiles` @WIN32LIBADD@
+libbfd_la_LDFLAGS = -release $(VERSION) @WIN32LDFLAGS@
+
+# libtool will build .libs/libbfd.a. We create libbfd.a in the build
+# directory so that we don't have to convert all the programs that use
+# libbfd.a simultaneously. This is a hack which should be removed if
+# everything else starts using libtool. FIXME.
+
+noinst_LIBRARIES = libbfd.a
+libbfd_a_SOURCES =
+
+BFD_H_DEPS = $(INCDIR)/ansidecl.h
+LOCAL_H_DEPS = libbfd.h sysdep.h config.h
+
+BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c section.c archures.c \
+ reloc.c syms.c bfd.c archive.c corefile.c targets.c format.c
+
+LIBBFD_H_FILES = libbfd-in.h init.c libbfd.c cache.c reloc.c archures.c elf.c
+LIBCOFF_H_FILES = libcoff-in.h coffcode.h
+
+MOSTLYCLEANFILES = elf32-target.h elf64-target.h ofiles stamp-ofiles \
+ targmatch.h
+
+
+CLEANFILES = bfd.h dep.sed stmp-bfd-h .dep .dep1 libbfd.a stamp-lib \
+ stmp-bin2-h stmp-lbfd-h stmp-lcoff-h
+
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES = bfd-in3.h
+LIBRARIES = $(noinst_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I.
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libbfd_a_LIBADD =
+libbfd_a_OBJECTS =
+LTLIBRARIES = $(lib_LTLIBRARIES)
+
+libbfd_la_OBJECTS = archive.lo archures.lo bfd.lo cache.lo coffgen.lo \
+corefile.lo format.lo init.lo libbfd.lo opncls.lo reloc.lo section.lo \
+syms.lo targets.lo hash.lo linker.lo srec.lo binary.lo tekhex.lo \
+ihex.lo stabs.lo stab-syms.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = README ./stamp-h.in COPYING ChangeLog Makefile.am \
+Makefile.in TODO acinclude.m4 aclocal.m4 bfd-in2.h config.in configure \
+configure.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+SOURCES = $(libbfd_a_SOURCES) $(libbfd_la_SOURCES)
+OBJECTS = $(libbfd_a_OBJECTS) $(libbfd_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4
+ cd $(srcdir) && $(ACLOCAL)
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+ cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h
+ @if test ! -f $@; then \
+ rm -f stamp-h; \
+ $(MAKE) stamp-h; \
+ else :; fi
+stamp-h: $(srcdir)/config.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \
+ $(SHELL) ./config.status
+ @echo timestamp > stamp-h 2> /dev/null
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h.in
+ @if test ! -f $@; then \
+ rm -f $(srcdir)/stamp-h.in; \
+ $(MAKE) $(srcdir)/stamp-h.in; \
+ else :; fi
+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOHEADER)
+ @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+ -rm -f config.h
+
+maintainer-clean-hdr:
+bfd-in3.h: $(top_builddir)/config.status bfd-in2.h
+ cd $(top_builddir) && CONFIG_FILES=$@:bfd-in2.h CONFIG_HEADERS= $(SHELL) ./config.status
+
+mostlyclean-noinstLIBRARIES:
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+distclean-noinstLIBRARIES:
+
+maintainer-clean-noinstLIBRARIES:
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.c.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+mostlyclean-libLTLIBRARIES:
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+
+distclean-libLTLIBRARIES:
+
+maintainer-clean-libLTLIBRARIES:
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+libbfd.la: $(libbfd_la_OBJECTS) $(libbfd_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libbfd_la_LDFLAGS) $(libbfd_la_OBJECTS) $(libbfd_la_LIBADD) $(LIBS)
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+
+@SET_MAKE@
+
+all-recursive install-data-recursive install-exec-recursive \
+installdirs-recursive install-recursive uninstall-recursive install-info-recursive \
+check-recursive installcheck-recursive info-recursive dvi-recursive:
+ @set fnord $(MAKEFLAGS); amf=$$2; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+ @set fnord $(MAKEFLAGS); amf=$$2; \
+ dot_seen=no; \
+ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
+ rev="$$subdir $$rev"; \
+ test "$$subdir" = "." && dot_seen=yes; \
+ done; \
+ test "$$dot_seen" = "no" && rev=". $$rev"; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)config.in$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.in $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ -rm -rf $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+ mkdir $(distdir)/=build
+ mkdir $(distdir)/=inst
+ dc_install_base=`cd $(distdir)/=inst && pwd`; \
+ cd $(distdir)/=build \
+ && ../configure --srcdir=.. --prefix=$$dc_install_base \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) dist
+ -rm -rf $(distdir)
+ @banner="$(distdir).tar.gz is ready for distribution"; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"
+dist: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+dist-all: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+distdir: $(DISTFILES)
+ -rm -rf $(distdir)
+ mkdir $(distdir)
+ -chmod 777 $(distdir)
+ @for file in $(DISTFILES); do \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ cp -pr $$/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+ for subdir in $(SUBDIRS); do \
+ if test "$$subdir" = .; then :; else \
+ test -d $(distdir)/$$subdir \
+ || mkdir $(distdir)/$$subdir \
+ || exit 1; \
+ chmod 777 $(distdir)/$$subdir; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
+ || exit 1; \
+ fi; \
+ done
+info-am:
+info: info-recursive
+dvi-am:
+dvi: dvi-recursive
+check-am:
+check: check-recursive
+installcheck-am:
+installcheck: installcheck-recursive
+install-info-am:
+install-info: install-info-recursive
+all-recursive-am: config.h
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+install-exec-am: install-libLTLIBRARIES
+install-exec: install-exec-recursive
+
+install-data-am: install-data-local
+install-data: install-data-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-recursive
+uninstall-am: uninstall-libLTLIBRARIES
+uninstall: uninstall-recursive
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) config.h
+all-redirect: all-recursive-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs: installdirs-recursive
+installdirs-am:
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+
+
+mostlyclean-generic:
+ -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-hdr mostlyclean-noinstLIBRARIES \
+ mostlyclean-compile mostlyclean-libtool \
+ mostlyclean-libLTLIBRARIES mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-recursive
+
+clean-am: clean-hdr clean-noinstLIBRARIES clean-compile clean-libtool \
+ clean-libLTLIBRARIES clean-tags clean-generic \
+ mostlyclean-am
+
+clean: clean-recursive
+
+distclean-am: distclean-hdr distclean-noinstLIBRARIES distclean-compile \
+ distclean-libtool distclean-libLTLIBRARIES \
+ distclean-tags distclean-generic clean-am
+ -rm -f libtool
+
+distclean: distclean-recursive
+ -rm -f config.status
+
+maintainer-clean-am: maintainer-clean-hdr \
+ maintainer-clean-noinstLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-libLTLIBRARIES maintainer-clean-tags \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f config.status
+
+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
+mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
+clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool mostlyclean-libLTLIBRARIES \
+distclean-libLTLIBRARIES clean-libLTLIBRARIES \
+maintainer-clean-libLTLIBRARIES uninstall-libLTLIBRARIES \
+install-libLTLIBRARIES install-data-recursive uninstall-data-recursive \
+install-exec-recursive uninstall-exec-recursive installdirs-recursive \
+uninstalldirs-recursive all-recursive check-recursive \
+installcheck-recursive info-recursive dvi-recursive \
+mostlyclean-recursive distclean-recursive clean-recursive \
+maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-info-am \
+install-info all-recursive-am install-exec-am install-exec \
+install-data-local install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs-am \
+installdirs mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+po/POTFILES.in: @MAINT@ Makefile
+ for file in $(POTFILES); do echo $$file; done | sort > tmp \
+ && mv tmp $(srcdir)/po/POTFILES.in
+
+diststuff: info
+
+stamp-ofiles: Makefile
+ rm -f tofiles
+ f=""; \
+ for i in $(OFILES) ; do \
+ case " $$f " in \
+ *" $$i "*) ;; \
+ *) f="$$f $$i" ;; \
+ esac ; \
+ done ; \
+ echo $$f > tofiles
+ $(SHELL) $(srcdir)/../move-if-change tofiles ofiles
+ touch stamp-ofiles
+
+ofiles: stamp-ofiles ; @true
+
+stamp-lib: libbfd.la
+ if [ -f .libs/libbfd.a ]; then \
+ cp .libs/libbfd.a libbfd.tmp; \
+ $(SHELL) $(srcdir)/../move-if-change libbfd.tmp libbfd.a; \
+ else true; fi
+ touch stamp-lib
+
+libbfd.a: stamp-lib ; @true
+
+# This file holds an array associating configuration triplets and
+# vector names. It is built from config.bfd. It is not compiled by
+# itself, but is included by targets.c.
+targmatch.h: config.bfd targmatch.sed
+ rm -f targmatch.h
+ sed -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new
+ mv -f targmatch.new targmatch.h
+
+# When compiling archures.c and targets.c, supply the default target
+# info from configure.
+
+targets.lo: targets.c config.status
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/targets.c
+
+archures.lo: archures.c config.status
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/archures.c
+
+elf32-target.h : elfxx-target.h
+ rm -f elf32-target.h
+ sed -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new
+ mv -f elf32-target.new elf32-target.h
+
+elf64-target.h : elfxx-target.h
+ rm -f elf64-target.h
+ sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
+ mv -f elf64-target.new elf64-target.h
+$(BFD_LIBS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+$(BFD_MACHINES): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+$(BFD_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+$(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+
+# Install BFD include file, and others that it needs.
+install-data-local: $(BFD_H)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(includedir)
+ $(INSTALL_DATA) $(BFD_H) $(includedir)/bfd.h
+ $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(includedir)/ansidecl.h
+ $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(includedir)/bfdlink.h
+
+# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES).
+.dep: dep.sed $(CFILES) $(HFILES) bfd.h
+ rm -f .dep1
+ $(MAKE) DEP=$(DEP) .dep1
+ sed -f dep.sed <.dep1 >.dep
+
+# This rule really wants a mkdep that runs "gcc -MM".
+# The NetBSD mkdep overwrites any existing file contents, and doesn't insert
+# the "DO NOT DELETE" line.
+# Other mkdep versions require a file that already exists, and do insert it.
+# Hence the weirdness....
+.dep1: $(CFILES)
+ rm -f .dep2 .dep2a
+ echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2
+ echo > .dep2a
+ $(DEP) -f .dep2a $(INCLUDES) $(CFLAGS) $?
+ sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2
+ rm -f .dep2a
+ $(SHELL) $(srcdir)/../move-if-change .dep2 .dep1
+
+dep.sed: dep-in.sed config.status
+ sed <$(srcdir)/dep-in.sed >dep.sed \
+ -e 's!@BFD_H@!$(BFD_H)!' \
+ -e 's!@INCDIR@!$(INCDIR)!' \
+ -e 's!@SRCDIR@!$(srcdir)!'
+
+dep: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
+ cat .dep >> tmp-Makefile
+ $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile
+
+dep-in: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
+ cat .dep >> tmp-Makefile.in
+ $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
+
+dep-am: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am
+ cat .dep >> tmp-Makefile.am
+ $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am
+
+host-aout.lo: Makefile
+
+# The following program can be used to generate a simple config file
+# which can be folded into an h-XXX file for a new host, with some editing.
+aout-params.h: gen-aout
+ ./gen-aout host > aout-params.h
+gen-aout: $(srcdir)/gen-aout.c Makefile
+ $(CC) -o gen-aout $(CFLAGS) $(LFLAGS) $(srcdir)/gen-aout.c
+
+$(BFD_H): stmp-bfd-h ; @true
+
+stmp-bfd-h: bfd-in3.h
+ rm -f bfd-tmp.h
+ cp bfd-in3.h bfd-tmp.h
+ $(SHELL) $(srcdir)/../move-if-change bfd-tmp.h $(BFD_H)
+ rm -f bfd-tmp.h
+ touch stmp-bfd-h
+
+# Could really use a "copy-if-change"...
+headers:
+ (cd $(docdir); $(MAKE) protos $(FLAGS_TO_PASS))
+ cp $(docdir)/bfd.h bfd-in2.h-new
+ $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
+ cp $(docdir)/libbfd.h libbfd.h-new
+ $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
+ cp $(docdir)/libcoff.h libcoff.h-new
+ $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+
+# We only rebuild the header files automatically if we have been
+# configured with --enable-maintainer-mode.
+
+$(srcdir)/bfd-in2.h: @MAINT@ stmp-bin2-h ; @true
+stmp-bin2-h: $(BFD_H_FILES)
+ (cd $(docdir); $(MAKE) $(FLAGS_TO_PASS) bfd.h)
+ cp $(docdir)/bfd.h bfd-in2.h-new
+ $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
+ touch stmp-bin2-h
+
+$(srcdir)/libbfd.h: @MAINT@ stmp-lbfd-h ; @true
+stmp-lbfd-h: $(LIBBFD_H_FILES)
+ (cd $(docdir); $(MAKE) $(FLAGS_TO_PASS) libbfd.h)
+ cp $(docdir)/libbfd.h libbfd.h-new
+ $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
+ touch stmp-lbfd-h
+
+$(srcdir)/libcoff.h: @MAINT@ stmp-lcoff-h ; @true
+stmp-lcoff-h: $(LIBCOFF_H_FILES)
+ (cd $(docdir); $(MAKE) $(FLAGS_TO_PASS) libcoff.h)
+ cp $(docdir)/libcoff.h libcoff.h-new
+ $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+ touch stmp-lcoff-h
+
+# We want to rerun configure if config.bfd or configure.host change.
+config.status: $(srcdir)/configure $(srcdir)/config.bfd $(srcdir)/configure.host
+ $(SHELL) ./config.status --recheck
+
+
+elfarm-oabi.lo: elfarm-oabi.c elf32-arm.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+
+# What appears below is generated by a hacked mkdep using gcc -MM.
+elfarm-nabi.lo: elfarm-nabi.c elf32-arm.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+
+# What appears below is generated by a hacked mkdep using gcc -MM.
+
+# DO NOT DELETE THIS LINE -- mkdep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+archive.lo: archive.c $(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h
+archures.lo: archures.c
+bfd.lo: bfd.c $(INCDIR)/libiberty.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h libcoff.h \
+ libecoff.h $(INCDIR)/coff/ecoff.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
+cache.lo: cache.c
+coffgen.lo: coffgen.c $(INCDIR)/coff/internal.h libcoff.h \
+ $(INCDIR)/bfdlink.h
+corefile.lo: corefile.c
+format.lo: format.c
+init.lo: init.c
+libbfd.lo: libbfd.c
+opncls.lo: opncls.c $(INCDIR)/objalloc.h
+reloc.lo: reloc.c $(INCDIR)/bfdlink.h
+section.lo: section.c $(INCDIR)/bfdlink.h
+syms.lo: syms.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def
+targets.lo: targets.c $(INCDIR)/fnmatch.h targmatch.h
+hash.lo: hash.c $(INCDIR)/objalloc.h
+linker.lo: linker.c $(INCDIR)/bfdlink.h genlink.h
+srec.lo: srec.c $(INCDIR)/libiberty.h
+binary.lo: binary.c
+tekhex.lo: tekhex.c $(INCDIR)/libiberty.h
+ihex.lo: ihex.c $(INCDIR)/libiberty.h
+stabs.lo: stabs.c $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def
+stab-syms.lo: stab-syms.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab.def
+cpu-a29k.lo: cpu-a29k.c
+cpu-alpha.lo: cpu-alpha.c
+cpu-arc.lo: cpu-arc.c
+cpu-arm.lo: cpu-arm.c
+cpu-d10v.lo: cpu-d10v.c
+cpu-d30v.lo: cpu-d30v.c
+cpu-fr30.lo: cpu-fr30.c
+cpu-h8300.lo: cpu-h8300.c
+cpu-h8500.lo: cpu-h8500.c
+cpu-hppa.lo: cpu-hppa.c
+cpu-i386.lo: cpu-i386.c
+cpu-i860.lo: cpu-i860.c
+cpu-i960.lo: cpu-i960.c
+cpu-m32r.lo: cpu-m32r.c
+cpu-m68k.lo: cpu-m68k.c
+cpu-m88k.lo: cpu-m88k.c
+cpu-m10200.lo: cpu-m10200.c
+cpu-m10300.lo: cpu-m10300.c
+cpu-mcore.lo: cpu-mcore.c
+cpu-mips.lo: cpu-mips.c
+cpu-ns32k.lo: cpu-ns32k.c ns32k.h
+cpu-powerpc.lo: cpu-powerpc.c
+cpu-rs6000.lo: cpu-rs6000.c
+cpu-sh.lo: cpu-sh.c
+cpu-sparc.lo: cpu-sparc.c
+cpu-tic30.lo: cpu-tic30.c
+cpu-tic80.lo: cpu-tic80.c
+cpu-v850.lo: cpu-v850.c
+cpu-vax.lo: cpu-vax.c
+cpu-we32k.lo: cpu-we32k.c
+cpu-w65.lo: cpu-w65.c
+cpu-z8k.lo: cpu-z8k.c
+aout-adobe.lo: aout-adobe.c $(INCDIR)/aout/adobe.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h \
+ $(INCDIR)/bfdlink.h
+aout-arm.lo: aout-arm.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aoutx.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+aout-ns32k.lo: aout-ns32k.c $(INCDIR)/aout/aout64.h \
+ ns32k.h libaout.h $(INCDIR)/bfdlink.h
+aout-sparcle.lo: aout-sparcle.c $(INCDIR)/bfdlink.h \
+ libaout.h aoutf1.h $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+aout-tic30.lo: aout-tic30.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h aoutx.h
+aout0.lo: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+aout32.lo: aout32.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h
+bout.lo: bout.c $(INCDIR)/bfdlink.h genlink.h $(INCDIR)/bout.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h
+cf-i386lynx.lo: cf-i386lynx.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+cf-m68klynx.lo: cf-m68klynx.c coff-m68k.c $(INCDIR)/coff/m68k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+cf-sparclynx.lo: cf-sparclynx.c coff-sparc.c $(INCDIR)/coff/sparc.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-a29k.lo: coff-a29k.c $(INCDIR)/coff/a29k.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-apollo.lo: coff-apollo.c $(INCDIR)/coff/apollo.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-arm.lo: coff-arm.c $(INCDIR)/coff/arm.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-aux.lo: coff-aux.c $(INCDIR)/coff/aux-coff.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/m68k.h coff-m68k.c libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-h8300.lo: coff-h8300.c $(INCDIR)/bfdlink.h genlink.h \
+ $(INCDIR)/coff/h8300.h $(INCDIR)/coff/internal.h libcoff.h \
+ coffcode.h coffswap.h
+coff-h8500.lo: coff-h8500.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/h8500.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-i386.lo: coff-i386.c $(INCDIR)/coff/i386.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-i860.lo: coff-i860.c $(INCDIR)/coff/i860.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-go32.lo: coff-go32.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-i960.lo: coff-i960.c $(INCDIR)/coff/i960.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-m68k.lo: coff-m68k.c $(INCDIR)/coff/m68k.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-m88k.lo: coff-m88k.c $(INCDIR)/coff/m88k.h $(INCDIR)/coff/internal.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
+coff-mips.lo: coff-mips.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ $(INCDIR)/coff/mips.h libcoff.h libecoff.h coffswap.h \
+ ecoffswap.h
+coff-pmac.lo: coff-pmac.c coff-rs6000.c $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-rs6000.lo: coff-rs6000.c $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-sh.lo: coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-sparc.lo: coff-sparc.c $(INCDIR)/coff/sparc.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-stgo32.lo: coff-stgo32.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/go32exe.h \
+ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h \
+ go32stub.h
+coff-svm68k.lo: coff-svm68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-tic30.lo: coff-tic30.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/tic30.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-tic80.lo: coff-tic80.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/tic80.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-u68k.lo: coff-u68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-we32k.lo: coff-we32k.c $(INCDIR)/coff/we32k.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
+ coffcode.h coffswap.h
+coff-w65.lo: coff-w65.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/w65.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+coff-z8k.lo: coff-z8k.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/z8k.h \
+ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
+cofflink.lo: cofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ libcoff.h
+dwarf2.lo: dwarf2.c $(INCDIR)/libiberty.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf2.h
+ecoff.lo: ecoff.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/ar.h \
+ $(INCDIR)/aout/ranlib.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ libaout.h $(INCDIR)/aout/aout64.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ libcoff.h libecoff.h
+ecofflink.lo: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/objalloc.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ libcoff.h libecoff.h
+elf.lo: elf.c $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
+elf32-arc.lo: elf32-arc.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/arc.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elfarm-oabi.lo: elfarm-oabi.c $(INCDIR)/elf/arm-oabi.h \
+ $(INCDIR)/elf/reloc-macros.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-arm.h elf32-target.h
+elfarm-nabi.lo: elfarm-nabi.c $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h elf32-arm.h \
+ elf32-target.h
+elf32-d10v.lo: elf32-d10v.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-d30v.lo: elf32-d30v.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-fr30.lo: elf32-fr30.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/fr30.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-gen.lo: elf32-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-hppa.lo: elf32-hppa.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ elf32-hppa.h libhppa.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \
+ hppa_stubs.h elf32-target.h
+elf32-i386.lo: elf32-i386.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/i386.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-i860.lo: elf32-i860.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf32-m32r.lo: elf32-m32r.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/m32r.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-m68k.lo: elf32-m68k.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/m68k.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-m88k.lo: elf32-m88k.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf-m10200.lo: elf-m10200.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf32-target.h
+elf-m10300.lo: elf-m10300.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/mn10300.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-mcore.lo: elf32-mcore.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/mcore.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-mips.lo: elf32-mips.c $(INCDIR)/bfdlink.h genlink.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \
+ elf32-target.h
+elf32-ppc.lo: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-sh.lo: elf32-sh.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-sparc.lo: elf32-sparc.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-v850.lo: elf32-v850.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/v850.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32.lo: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ elfcore.h elflink.h
+elflink.lo: elflink.c $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
+hp300bsd.lo: hp300bsd.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+hp300hpux.lo: hp300hpux.c $(INCDIR)/aout/hp300hpux.h \
+ aoutx.h $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+som.lo: som.c
+i386aout.lo: i386aout.c $(INCDIR)/aout/aout64.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386bsd.lo: i386bsd.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386dynix.lo: i386dynix.c $(INCDIR)/aout/dynix3.h aoutx.h \
+ $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+i386freebsd.lo: i386freebsd.c freebsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386linux.lo: i386linux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+i386lynx.lo: i386lynx.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386msdos.lo: i386msdos.c libaout.h $(INCDIR)/bfdlink.h
+i386netbsd.lo: i386netbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+i386mach3.lo: i386mach3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+i386os9k.lo: i386os9k.c $(INCDIR)/bfdlink.h libaout.h \
+ $(INCDIR)/os9k.h
+ieee.lo: ieee.c $(INCDIR)/ieee.h libieee.h
+m68k4knetbsd.lo: m68k4knetbsd.c netbsd.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+m68klinux.lo: m68klinux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+m68klynx.lo: m68klynx.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+m68knetbsd.lo: m68knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+m88kmach3.lo: m88kmach3.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+mipsbsd.lo: mipsbsd.c libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+newsos3.lo: newsos3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
+ $(INCDIR)/bfdlink.h aout-target.h
+nlm.lo: nlm.c libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h
+nlm32-i386.lo: nlm32-i386.c $(INCDIR)/nlm/i386-ext.h \
+ libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
+nlm32-sparc.lo: nlm32-sparc.c $(INCDIR)/nlm/sparc32-ext.h \
+ libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
+nlm32-ppc.lo: nlm32-ppc.c $(INCDIR)/nlm/ppc-ext.h libnlm.h \
+ $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h \
+ nlmswap.h nlm-target.h
+nlm32.lo: nlm32.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
+ $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
+ns32knetbsd.lo: ns32knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+oasys.lo: oasys.c $(INCDIR)/oasys.h liboasys.h
+pc532-mach.lo: pc532-mach.c libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+pe-arm.lo: pe-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-arm.lo: pei-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pe-i386.lo: pe-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-i386.lo: pei-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pe-mcore.lo: pe-mcore.c coff-mcore.c $(INCDIR)/coff/mcore.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-mcore.lo: pei-mcore.c coff-mcore.c $(INCDIR)/coff/mcore.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pe-ppc.lo: pe-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+pei-ppc.lo: pei-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
+ $(INCDIR)/bfdlink.h coffcode.h peicode.h
+ppcboot.lo: ppcboot.c
+reloc16.lo: reloc16.c $(INCDIR)/bfdlink.h genlink.h \
+ $(INCDIR)/coff/internal.h libcoff.h
+riscix.lo: riscix.c libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \
+ aout-target.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h
+sparclinux.lo: sparclinux.c $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ libaout.h $(INCDIR)/bfdlink.h aout-target.h
+sparclynx.lo: sparclynx.c $(INCDIR)/aout/sun4.h libaout.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+sparcnetbsd.lo: sparcnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+sunos.lo: sunos.c $(INCDIR)/bfdlink.h libaout.h aoutf1.h \
+ $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
+vaxnetbsd.lo: vaxnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+versados.lo: versados.c $(INCDIR)/libiberty.h
+vms.lo: vms.c $(INCDIR)/bfdlink.h vms.h
+vms-gsd.lo: vms-gsd.c $(INCDIR)/bfdlink.h vms.h
+vms-hdr.lo: vms-hdr.c $(INCDIR)/bfdlink.h vms.h
+vms-misc.lo: vms-misc.c $(INCDIR)/bfdlink.h vms.h
+vms-tir.lo: vms-tir.c $(INCDIR)/bfdlink.h vms.h
+xcofflink.lo: xcofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ libcoff.h
+aout64.lo: aout64.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
+ $(INCDIR)/aout/ar.h
+coff-alpha.lo: coff-alpha.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \
+ libecoff.h coffswap.h ecoffswap.h
+demo64.lo: demo64.c aoutf1.h $(INCDIR)/aout/sun4.h \
+ libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \
+ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
+ aout-target.h
+elf64-alpha.lo: elf64-alpha.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/alpha.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
+ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h \
+ libcoff.h libecoff.h ecoffswap.h elf64-target.h
+elf64-gen.lo: elf64-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ elf64-target.h
+elf64-mips.lo: elf64-mips.c $(INCDIR)/aout/ar.h $(INCDIR)/bfdlink.h \
+ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \
+ elf64-target.h
+elf64-sparc.lo: elf64-sparc.c elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/reloc-macros.h \
+ elf64-target.h
+elf64.lo: elf64.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ elfcore.h elflink.h
+nlm32-alpha.lo: nlm32-alpha.c $(INCDIR)/nlm/alpha-ext.h \
+ libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
+ $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
+nlm64.lo: nlm64.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
+ $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
+aix386-core.lo: aix386-core.c $(INCDIR)/coff/i386.h \
+ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h
+hpux-core.lo: hpux-core.c
+irix-core.lo: irix-core.c
+lynx-core.lo: lynx-core.c
+osf-core.lo: osf-core.c
+sco5-core.lo: sco5-core.c libaout.h $(INCDIR)/bfdlink.h
+trad-core.lo: trad-core.c libaout.h $(INCDIR)/bfdlink.h \
+ hosts/i386linux.h
+cisco-core.lo: cisco-core.c
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/bfd/PORTING b/bfd/PORTING
new file mode 100644
index 00000000000..c8bfd77b96f
--- /dev/null
+++ b/bfd/PORTING
@@ -0,0 +1,83 @@
+ Preliminary Notes on Porting BFD
+ --------------------------------
+
+The 'host' is the system a tool runs *on*.
+The 'target' is the system a tool runs *for*, i.e.
+a tool can read/write the binaries of the target.
+
+Porting to a new host
+---------------------
+Pick a name for your host. Call that <host>.
+(<host> might be sun4, ...)
+Create a file hosts/<host>.mh.
+
+Porting to a new target
+-----------------------
+Pick a name for your target. Call that <target>.
+Call the name for your CPU architecture <cpu>.
+You need to create <target>.c and config/<target>.mt,
+and add a case for it to a case statements in bfd/configure.host and
+bfd/config.bfd, which associates each canonical host type with a BFD
+host type (used as the base of the makefile fragment names), and to the
+table in bfd/configure.in which associates each target vector with
+the .o files it uses.
+
+config/<target>.mt is a Makefile fragment.
+The following is usually enough:
+DEFAULT_VECTOR=<target>_vec
+SELECT_ARCHITECTURES=bfd_<cpu>_arch
+
+See the list of cpu types in archures.c, or "ls cpu-*.c".
+If your architecture is new, you need to add it to the tables
+in bfd/archures.c, opcodes/configure.in, and binutils/objdump.c.
+
+For more information about .mt and .mh files, see config/README.
+
+The file <target>.c is the hard part. It implements the
+bfd_target <target>_vec, which includes pointers to
+functions that do the actual <target>-specific methods.
+
+Porting to a <target> that uses the a.out binary format
+-------------------------------------------------------
+
+In this case, the include file aout-target.h probaby does most
+of what you need. The program gen-aout generates <target>.c for
+you automatically for many a.out systems. Do:
+ make gen-aout
+ ./gen-aout <target> > <target>.c
+(This only works if you are building on the target ("native").
+If you must make a cross-port from scratch, copy the most
+similar existing file that includes aout-target.h, and fix what is wrong.)
+
+Check the parameters in <target>.c, and fix anything that is wrong.
+(Also let us know about it; perhaps we can improve gen-aout.c.)
+
+TARGET_IS_BIG_ENDIAN_P
+ Should be defined if <target> is big-endian.
+
+N_HEADER_IN_TEXT(x)
+ See discussion in ../include/aout/aout64.h.
+
+BYTES_IN_WORD
+ Number of bytes per word. (Usually 4 but can be 8.)
+
+ARCH
+ Number of bits per word. (Usually 32, but can be 64.)
+
+ENTRY_CAN_BE_ZERO
+ Define if the extry point (start address of an
+ executable program) can be 0x0.
+
+TEXT_START_ADDR
+ The address of the start of the text segemnt in
+ virtual memory. Normally, the same as the entry point.
+
+TARGET_PAGE_SIZE
+
+SEGMENT_SIZE
+ Usually, the same as the TARGET_PAGE_SIZE.
+ Alignment needed for the data segment.
+
+TARGETNAME
+ The name of the target, for run-time lookups.
+ Usually "a.out-<target>"
diff --git a/bfd/README b/bfd/README
new file mode 100644
index 00000000000..51ce133355f
--- /dev/null
+++ b/bfd/README
@@ -0,0 +1,49 @@
+BFD is a an object file library. It permits applications to use the
+same routines to process object files regardless of their format.
+
+BFD is used by the GNU debugger, assembler, linker, and the binary
+utilities.
+
+The documentation on using BFD is scanty and may be occasionally
+incorrect. Pointers to documentation problems, or an entirely
+rewritten manual, would be appreciated.
+
+There is some BFD internals documentation in doc/bfdint.texi which may
+help programmers who want to modify BFD.
+
+BFD is normally built as part of another package. See the build
+instructions for that package, probably in a README file in the
+appropriate directory.
+
+BFD supports the following configure options:
+
+ --target=TARGET
+ The default target for which to build the library. TARGET is
+ a configuration target triplet, such as sparc-sun-solaris.
+ --enable-targets=TARGET,TARGET,TARGET...
+ Additional targets the library should support. To include
+ support for all known targets, use --enable-targets=all.
+ --enable-64-bit-bfd
+ Include support for 64 bit targets. This is automatically
+ turned on if you explicitly request a 64 bit target, but not
+ for --enable-targets=all. This requires a compiler with a 64
+ bit integer type, such as gcc.
+ --enable-shared
+ Build BFD as a shared library.
+ --with-mmap
+ Use mmap when accessing files. This is faster on some hosts,
+ but slower on others. It may not work on all hosts.
+
+Report bugs with BFD to bug-gnu-utils@gnu.org.
+
+Patches are encouraged. When sending patches, always send the output
+of diff -u or diff -c from the original file to the new file. Do not
+send default diff output. Do not make the diff from the new file to
+the original file. Remember that any patch must not break other
+systems. Remember that BFD must support cross compilation from any
+host to any target, so patches which use ``#ifdef HOST'' are not
+acceptable. Please also read the ``Reporting Bugs'' section of the
+gcc manual.
+
+Bug reports without patches will be remembered, but they may never get
+fixed until somebody volunteers to fix them.
diff --git a/bfd/TODO b/bfd/TODO
new file mode 100644
index 00000000000..7a127352521
--- /dev/null
+++ b/bfd/TODO
@@ -0,0 +1,25 @@
+Things that still need to be done: -*- Text -*-
+
+ o - A source of space lossage is that all the target-dependent code
+ is in a single bfd_target structure. Hence all the code for
+ *writing* object files is still pulled into all the applications
+ that only care about *reading* (gdb, nm, objdump), while gas has
+ to carry along all the unneeded baggage for reading objects. And
+ so on. This would be a substantial change, and the payoff would
+ not all that great (essentially none if bfd is used as a shared
+ library).
+
+ o - The storage needed by BFD data structures is also larger than strictly
+ needed. This may be difficult to do much about.
+
+ o - implement bfd_abort, which should close the bfd but not alter the
+ filesystem.
+
+ o - update the bfd doc; write a how-to-write-a-backend doc, take out
+ the stupid quips and fill in all the blanks.
+
+ o - upgrade the reloc handling as per Steve's suggestion.
+
+
+
+
diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4
new file mode 100644
index 00000000000..dbe1c30fc81
--- /dev/null
+++ b/bfd/acinclude.m4
@@ -0,0 +1,104 @@
+dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
+AC_DEFUN(BFD_BINARY_FOPEN,
+[AC_REQUIRE([AC_CANONICAL_SYSTEM])
+case "${host}" in
+changequote(,)dnl
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows)
+changequote([,])dnl
+ AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
+esac])dnl
+
+dnl Get a default for CC_FOR_BUILD to put into Makefile.
+AC_DEFUN(BFD_CC_FOR_BUILD,
+[# Put a plausible default for CC_FOR_BUILD in Makefile.
+if test -z "$CC_FOR_BUILD"; then
+ if test "x$cross_compiling" = "xno"; then
+ CC_FOR_BUILD='$(CC)'
+ else
+ CC_FOR_BUILD=gcc
+ fi
+fi
+AC_SUBST(CC_FOR_BUILD)
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+ EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+ AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
+ [cat > ac_c_test.c << 'EOF'
+int main() {
+/* Nothing needed here */
+}
+EOF
+ ${CC_FOR_BUILD} -o ac_c_test am_c_test.c 1>&5 2>&5
+ bfd_cv_build_exeext=`echo ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
+ rm -f ac_c_test*
+ test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
+ EXEEXT_FOR_BUILD=""
+ test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
+fi
+AC_SUBST(EXEEXT_FOR_BUILD)])dnl
+
+dnl See whether we need a declaration for a function.
+AC_DEFUN(BFD_NEED_DECLARATION,
+[AC_MSG_CHECKING([whether $1 must be declared])
+AC_CACHE_VAL(bfd_cv_decl_needed_$1,
+[AC_TRY_COMPILE([
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif],
+[char *(*pfn) = (char *(*)) $1],
+bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
+AC_MSG_RESULT($bfd_cv_decl_needed_$1)
+if test $bfd_cv_decl_needed_$1 = yes; then
+ AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
+ [Define if $1 is not declared in system header files.])
+fi
+])dnl
+
+dnl Check for existence of a type $1 in sys/procfs.h
+
+AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
+[AC_MSG_CHECKING([for $1 in sys/procfs.h])
+ AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
+ [AC_TRY_COMPILE([#include <sys/procfs.h>],
+ [$1 avar],
+ bfd_cv_have_sys_procfs_type_$1=yes,
+ bfd_cv_have_sys_procfs_type_$1=no
+ )])
+ if test $bfd_cv_have_sys_procfs_type_$1 = yes; then
+ AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1,
+ [Define if <sys/procfs.h> has $1.])
+ fi
+ AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_$1)
+])
+
+
+dnl Check for existence of member $2 in type $1 in sys/procfs.h
+
+AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
+[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
+ AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
+ [AC_TRY_COMPILE([#include <sys/procfs.h>],
+ [$1 avar; void* aref = (void*) &avar.$2],
+ bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
+ bfd_cv_have_sys_procfs_type_member_$1_$2=no
+ )])
+ if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then
+ AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1,
+ [Define if <sys/procfs.h> has $1.$2.])
+ fi
+ AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2)
+])
+
+
diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4
new file mode 100644
index 00000000000..43580002449
--- /dev/null
+++ b/bfd/aclocal.m4
@@ -0,0 +1,861 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
+AC_DEFUN(BFD_BINARY_FOPEN,
+[AC_REQUIRE([AC_CANONICAL_SYSTEM])
+case "${host}" in
+changequote(,)dnl
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows)
+changequote([,])dnl
+ AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
+esac])dnl
+
+dnl Get a default for CC_FOR_BUILD to put into Makefile.
+AC_DEFUN(BFD_CC_FOR_BUILD,
+[# Put a plausible default for CC_FOR_BUILD in Makefile.
+if test -z "$CC_FOR_BUILD"; then
+ if test "x$cross_compiling" = "xno"; then
+ CC_FOR_BUILD='$(CC)'
+ else
+ CC_FOR_BUILD=gcc
+ fi
+fi
+AC_SUBST(CC_FOR_BUILD)
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+ EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+ AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
+ [cat > ac_c_test.c << 'EOF'
+int main() {
+/* Nothing needed here */
+}
+EOF
+ ${CC_FOR_BUILD} -o ac_c_test am_c_test.c 1>&5 2>&5
+ bfd_cv_build_exeext=`echo ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
+ rm -f ac_c_test*
+ test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
+ EXEEXT_FOR_BUILD=""
+ test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
+fi
+AC_SUBST(EXEEXT_FOR_BUILD)])dnl
+
+dnl See whether we need a declaration for a function.
+AC_DEFUN(BFD_NEED_DECLARATION,
+[AC_MSG_CHECKING([whether $1 must be declared])
+AC_CACHE_VAL(bfd_cv_decl_needed_$1,
+[AC_TRY_COMPILE([
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif],
+[char *(*pfn) = (char *(*)) $1],
+bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
+AC_MSG_RESULT($bfd_cv_decl_needed_$1)
+if test $bfd_cv_decl_needed_$1 = yes; then
+ AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
+ [Define if $1 is not declared in system header files.])
+fi
+])dnl
+
+dnl Check for existence of a type $1 in sys/procfs.h
+
+AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
+[AC_MSG_CHECKING([for $1 in sys/procfs.h])
+ AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
+ [AC_TRY_COMPILE([#include <sys/procfs.h>],
+ [$1 avar],
+ bfd_cv_have_sys_procfs_type_$1=yes,
+ bfd_cv_have_sys_procfs_type_$1=no
+ )])
+ if test $bfd_cv_have_sys_procfs_type_$1 = yes; then
+ AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1,
+ [Define if <sys/procfs.h> has $1.])
+ fi
+ AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_$1)
+])
+
+
+dnl Check for existence of member $2 in type $1 in sys/procfs.h
+
+AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
+[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
+ AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
+ [AC_TRY_COMPILE([#include <sys/procfs.h>],
+ [$1 avar; void* aref = (void*) &avar.$2],
+ bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
+ bfd_cv_have_sys_procfs_type_member_$1_$2=no
+ )])
+ if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then
+ AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1,
+ [Define if <sys/procfs.h> has $1.$2.])
+ fi
+ AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2)
+])
+
+
+
+# Do all the work for Automake. This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "[$]*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "[$]*" != "X $srcdir/configure conftestfile" \
+ && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "[$]2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+ $1=$2
+ AC_MSG_RESULT(found)
+else
+ $1="$3/missing $2"
+ AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
+
+# serial 25 AM_PROG_LIBTOOL
+AC_DEFUN(AM_PROG_LIBTOOL,
+[AC_REQUIRE([AM_ENABLE_SHARED])dnl
+AC_REQUIRE([AM_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_RANLIB])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AM_PROG_LD])dnl
+AC_REQUIRE([AM_PROG_NM])dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+dnl
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags=
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$silent" = yes && libtool_flags="$libtool_flags --silent"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$host" in
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ CFLAGS="$CFLAGS -belf"
+ ;;
+
+*-*-cygwin*)
+ AM_SYS_LIBTOOL_CYGWIN
+ ;;
+
+esac
+
+# Actually configure libtool. ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
+DLLTOOL="$DLLTOOL" AS="$AS" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+|| AC_MSG_ERROR([libtool configure failed])
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+])
+
+# AM_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AM_ENABLE_SHARED[(DEFAULT)]
+# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
+# `yes'.
+AC_DEFUN(AM_ENABLE_SHARED,
+[define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<< --enable-shared[=PKGS] build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac],
+enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AM_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN(AM_DISABLE_SHARED,
+[AM_ENABLE_SHARED(no)])
+
+# AM_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN(AM_DISABLE_STATIC,
+[AM_ENABLE_STATIC(no)])
+
+# AM_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AM_ENABLE_STATIC[(DEFAULT)]
+# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
+# `yes'.
+AC_DEFUN(AM_ENABLE_STATIC,
+[define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<< --enable-static[=PKGS] build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac],
+enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
+])
+
+
+# AM_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN(AM_PROG_LD,
+[AC_ARG_WITH(gnu-ld,
+[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by GCC])
+ ac_prog=`($CC -print-prog-name=ld) 2>&5`
+ case "$ac_prog" in
+ # Accept absolute paths.
+changequote(,)dnl
+ /* | [A-Za-z]:\\*)
+changequote([,])dnl
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(ac_cv_path_LD,
+[if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog"; then
+ ac_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+ test "$with_gnu_ld" != no && break
+ else
+ test "$with_gnu_ld" != yes && break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_SUBST(LD)
+AM_PROG_LD_GNU
+])
+
+AC_DEFUN(AM_PROG_LD_GNU,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+ ac_cv_prog_gnu_ld=yes
+else
+ ac_cv_prog_gnu_ld=no
+fi])
+])
+
+# AM_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN(AM_PROG_NM,
+[AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(ac_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ ac_cv_path_NM="$NM"
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/nm; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -B"
+ elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -p"
+ else
+ ac_cv_path_NM="$ac_dir/nm"
+ fi
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi])
+NM="$ac_cv_path_NM"
+AC_MSG_RESULT([$NM])
+AC_SUBST(NM)
+])
+
+# AM_SYS_LIBTOOL_CYGWIN - find tools needed on cygwin
+AC_DEFUN(AM_SYS_LIBTOOL_CYGWIN,
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+AC_CHECK_TOOL(AS, as, false)
+])
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated. We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+ case " <<$>>CONFIG_HEADERS " in
+ *" <<$>>am_file "*<<)>>
+ echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+ ;;
+ esac
+ am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+
+# Add --enable-maintainer-mode option to configure.
+# From Jim Meyering
+
+# serial 1
+
+AC_DEFUN(AM_MAINTAINER_MODE,
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+ dnl maintainer-mode is disabled by default
+ AC_ARG_ENABLE(maintainer-mode,
+[ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer],
+ USE_MAINTAINER_MODE=$enableval,
+ USE_MAINTAINER_MODE=no)
+ AC_MSG_RESULT($USE_MAINTAINER_MODE)
+ AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
+ MAINT=$MAINTAINER_MODE_TRUE
+ AC_SUBST(MAINT)dnl
+]
+)
+
+# Define a conditional.
+
+AC_DEFUN(AM_CONDITIONAL,
+[AC_SUBST($1_TRUE)
+AC_SUBST($1_FALSE)
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi])
+
+# This file is derived from `gettext.m4'. The difference is that the
+# included macros assume Cygnus-style source and build trees.
+
+# Macro to add for using GNU gettext.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 3
+
+AC_DEFUN(CY_WITH_NLS,
+ [AC_MSG_CHECKING([whether NLS is requested])
+ dnl Default is enabled NLS
+ AC_ARG_ENABLE(nls,
+ [ --disable-nls do not use Native Language Support],
+ USE_NLS=$enableval, USE_NLS=yes)
+ AC_MSG_RESULT($USE_NLS)
+ AC_SUBST(USE_NLS)
+
+ USE_INCLUDED_LIBINTL=no
+
+ dnl If we use NLS figure out what method
+ if test "$USE_NLS" = "yes"; then
+ AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested])
+ AC_MSG_CHECKING([whether included gettext is requested])
+ AC_ARG_WITH(included-gettext,
+ [ --with-included-gettext use the GNU gettext library included here],
+ nls_cv_force_use_gnu_gettext=$withval,
+ nls_cv_force_use_gnu_gettext=no)
+ AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ dnl User does not insist on using GNU NLS library. Figure out what
+ dnl to use. If gettext or catgets are available (in this order) we
+ dnl use this. Else we have to fall back to GNU NLS library.
+ dnl catgets is only used if permitted by option --with-catgets.
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+ CATOBJEXT=NONE
+
+ AC_CHECK_HEADER(libintl.h,
+ [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
+ [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
+ gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
+
+ if test "$gt_cv_func_gettext_libc" != "yes"; then
+ AC_CHECK_LIB(intl, bindtextdomain,
+ [AC_CACHE_CHECK([for gettext in libintl],
+ gt_cv_func_gettext_libintl,
+ [AC_TRY_LINK([], [return (int) gettext ("")],
+ gt_cv_func_gettext_libintl=yes,
+ gt_cv_func_gettext_libintl=no)])])
+ fi
+
+ if test "$gt_cv_func_gettext_libc" = "yes" \
+ || test "$gt_cv_func_gettext_libintl" = "yes"; then
+ AC_DEFINE(HAVE_GETTEXT, 1,
+ [Define as 1 if you have gettext and don't want to use GNU gettext.])
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
+ if test "$MSGFMT" != "no"; then
+ AC_CHECK_FUNCS(dcgettext)
+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+ AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
+ return _nl_msg_cat_cntr],
+ [CATOBJEXT=.gmo
+ DATADIRNAME=share],
+ [CATOBJEXT=.mo
+ DATADIRNAME=lib])
+ INSTOBJEXT=.mo
+ fi
+ fi
+ ])
+
+ dnl In the standard gettext, we would now check for catgets.
+ dnl However, we never want to use catgets for our releases.
+
+ if test "$CATOBJEXT" = "NONE"; then
+ dnl Neither gettext nor catgets in included in the C library.
+ dnl Fall back on GNU gettext library.
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions used to generate GNU NLS library.
+ INTLOBJS="\$(GETTOBJS)"
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+ AC_SUBST(MSGFMT)
+ USE_INCLUDED_LIBINTL=yes
+ CATOBJEXT=.gmo
+ INSTOBJEXT=.mo
+ DATADIRNAME=share
+ INTLDEPS='$(top_builddir)/../intl/libintl.a'
+ INTLLIBS=$INTLDEPS
+ LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ dnl Test whether we really found GNU xgettext.
+ if test "$XGETTEXT" != ":"; then
+ dnl If it is no GNU xgettext we define it as : so that the
+ dnl Makefiles still can work.
+ if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
+ : ;
+ else
+ AC_MSG_RESULT(
+ [found xgettext programs is not GNU xgettext; ignore it])
+ XGETTEXT=":"
+ fi
+ fi
+
+ # We need to process the po/ directory.
+ POSUB=po
+ else
+ DATADIRNAME=share
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ # If this is used in GNU gettext we have to set USE_NLS to `yes'
+ # because some of the sources are only built for this goal.
+ if test "$PACKAGE" = gettext; then
+ USE_NLS=yes
+ USE_INCLUDED_LIBINTL=yes
+ fi
+
+ dnl These rules are solely for the distribution goal. While doing this
+ dnl we only have to keep exactly one list of the available catalogs
+ dnl in configure.in.
+ for lang in $ALL_LINGUAS; do
+ GMOFILES="$GMOFILES $lang.gmo"
+ POFILES="$POFILES $lang.po"
+ done
+
+ dnl Make all variables we use known to autoconf.
+ AC_SUBST(USE_INCLUDED_LIBINTL)
+ AC_SUBST(CATALOGS)
+ AC_SUBST(CATOBJEXT)
+ AC_SUBST(DATADIRNAME)
+ AC_SUBST(GMOFILES)
+ AC_SUBST(INSTOBJEXT)
+ AC_SUBST(INTLDEPS)
+ AC_SUBST(INTLLIBS)
+ AC_SUBST(INTLOBJS)
+ AC_SUBST(POFILES)
+ AC_SUBST(POSUB)
+ ])
+
+AC_DEFUN(CY_GNU_GETTEXT,
+ [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_PROG_RANLIB])dnl
+ AC_REQUIRE([AC_ISC_POSIX])dnl
+ AC_REQUIRE([AC_HEADER_STDC])dnl
+ AC_REQUIRE([AC_C_CONST])dnl
+ AC_REQUIRE([AC_C_INLINE])dnl
+ AC_REQUIRE([AC_TYPE_OFF_T])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+ AC_REQUIRE([AC_FUNC_MMAP])dnl
+
+ AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h values.h sys/param.h])
+ AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
+__argz_count __argz_stringify __argz_next])
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ AC_CHECK_FUNCS(stpcpy)
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function])
+ fi
+
+ AM_LC_MESSAGES
+ CY_WITH_NLS
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ AC_MSG_CHECKING(for catalogs to be installed)
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ AC_MSG_RESULT($LINGUAS)
+ fi
+
+ dnl Construct list of names of catalog files to be constructed.
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ dnl The reference to <locale.h> in the installed <libintl.h> file
+ dnl must be resolved because we cannot expect the users of this
+ dnl to define HAVE_LOCALE_H.
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+ AC_SUBST(INCLUDE_LOCALE_H)
+
+ dnl Determine which catalog format we have (if any is needed)
+ dnl For now we know about two different formats:
+ dnl Linux libc-5 and the normal X/Open format
+ if test -f $srcdir/po2tbl.sed.in; then
+ if test "$CATOBJEXT" = ".cat"; then
+ AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
+
+ dnl Transform the SED scripts while copying because some dumb SEDs
+ dnl cannot handle comments.
+ sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
+ fi
+ dnl po2tbl.sed is always needed.
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/po2tbl.sed.in > po2tbl.sed
+ fi
+
+ dnl In the intl/Makefile.in we have a special dependency which makes
+ dnl only sense for gettext. We comment this out for non-gettext
+ dnl packages.
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+ AC_SUBST(GT_NO)
+ AC_SUBST(GT_YES)
+
+ MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
+ AC_SUBST(MKINSTALLDIRS)
+
+ dnl *** For now the libtool support in intl/Makefile is not for real.
+ l=
+ AC_SUBST(l)
+
+ dnl Generate list of files to be processed by xgettext which will
+ dnl be included in po/Makefile. But only do this if the po directory
+ dnl exists in srcdir.
+ if test -d $srcdir/po; then
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ fi
+ ])
+
+# Search path for a program which passes the given test.
+# Ulrich Drepper <drepper@cygnus.com>, 1996.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
+dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
+AC_DEFUN(AM_PATH_PROG_WITH_TEST,
+[# Extract the first word of "$2", so it can be a program name with args.
+set dummy $2; ac_word=[$]2
+AC_MSG_CHECKING([for $ac_word])
+AC_CACHE_VAL(ac_cv_path_$1,
+[case "[$]$1" in
+ /*)
+ ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in ifelse([$5], , $PATH, [$5]); do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if [$3]; then
+ ac_cv_path_$1="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+dnl If no 4th arg is given, leave the cache variable unset,
+dnl so AC_PATH_PROGS will keep looking.
+ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
+])dnl
+ ;;
+esac])dnl
+$1="$ac_cv_path_$1"
+if test -n "[$]$1"; then
+ AC_MSG_RESULT([$]$1)
+else
+ AC_MSG_RESULT(no)
+fi
+AC_SUBST($1)dnl
+])
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+AC_DEFUN(AM_LC_MESSAGES,
+ [if test $ac_cv_header_locale_h = yes; then
+ AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
+ [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+ am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ AC_DEFINE(HAVE_LC_MESSAGES, 1,
+ [Define if your locale.h file contains LC_MESSAGES.])
+ fi
+ fi])
+
diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c
new file mode 100644
index 00000000000..a75fa94262a
--- /dev/null
+++ b/bfd/aix386-core.c
@@ -0,0 +1,283 @@
+/* BFD back-end for AIX on PS/2 core files.
+ This was based on trad-core.c, which was written by John Gilmore of
+ Cygnus Support.
+ Copyright 1988, 89, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
+ Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/i386.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#include <signal.h>
+
+#if defined (_AIX) && defined (_I386)
+#define NOCHECKS /* this is for coredump.h */
+#define _h_USER /* avoid including user.h from coredump.h */
+#include <uinfo.h>
+#include <sys/i386/coredump.h>
+#endif /* _AIX && _I386 */
+
+/* maybe this could work on some other i386 but I have not tried it
+ * mtranle@paris - Tue Sep 24 12:49:35 1991
+ */
+
+#ifndef COR_MAGIC
+# define COR_MAGIC "core"
+#endif
+
+/* need this cast because ptr is really void * */
+#define core_hdr(bfd) \
+ (((bfd->tdata.trad_core_data))->hdr)
+#define core_section(bfd,n) \
+ (((bfd)->tdata.trad_core_data)->sections[n])
+#define core_regsec(bfd) \
+ (((bfd)->tdata.trad_core_data)->reg_section)
+#define core_reg2sec(bfd) \
+ (((bfd)->tdata.trad_core_data)->reg2_section)
+
+/* These are stored in the bfd's tdata */
+struct trad_core_struct {
+ struct corehdr *hdr; /* core file header */
+ asection *reg_section;
+ asection *reg2_section;
+ asection *sections[MAX_CORE_SEGS];
+};
+
+static void swap_abort PARAMS ((void));
+
+static const bfd_target *
+aix386_core_file_p (abfd)
+ bfd *abfd;
+{
+ int i,n;
+ unsigned char longbuf[4]; /* Raw bytes of various header fields */
+ int core_size = sizeof (struct corehdr);
+ struct corehdr *core;
+ struct mergem {
+ struct trad_core_struct coredata;
+ struct corehdr internal_core;
+ } *mergem;
+
+ if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (strncmp(longbuf,COR_MAGIC,4)) return 0;
+
+ if (bfd_seek (abfd, 0L, false) < 0) return 0;
+
+ mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
+ if (mergem == NULL)
+ return 0;
+
+ core = &mergem->internal_core;
+
+ if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ bfd_release (abfd, (char *)mergem);
+ return 0;
+ }
+
+ set_tdata (abfd, &mergem->coredata);
+ core_hdr (abfd) = core;
+
+ /* create the sections. This is raunchy, but bfd_close wants to reclaim
+ them */
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_regsec (abfd) == NULL)
+ {
+ loser:
+ bfd_release (abfd, (char *)mergem);
+ return 0;
+ }
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_reg2sec (abfd) == NULL)
+ {
+ loser1:
+ bfd_release (abfd, core_regsec (abfd));
+ goto loser;
+ }
+
+ for (i=0, n=0 ; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type) ; i++)
+ {
+ if (core->cd_segs[i].cs_offset == 0)
+ continue;
+ core_section (abfd,n) =
+ (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_section (abfd,n) == NULL)
+ {
+ int j;
+ if (n > 0)
+ {
+ for (j=0; j < n; j++)
+ bfd_release (abfd, core_section(abfd, j));
+ }
+ bfd_release (abfd, (char *)mergem);
+ goto loser1;
+ }
+
+ switch (core->cd_segs[i].cs_type)
+ {
+ case COR_TYPE_DATA:
+ core_section (abfd, n)->name = ".data";
+ core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
+ SEC_HAS_CONTENTS);
+ break;
+ case COR_TYPE_STACK:
+ core_section (abfd, n)->name = ".stack";
+ core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
+ SEC_HAS_CONTENTS);
+ break;
+ case COR_TYPE_LIBDATA:
+ core_section (abfd, n)->name = ".libdata";
+ core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
+ break;
+ case COR_TYPE_WRITE:
+ core_section (abfd, n)->name = ".writeable";
+ core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
+ break;
+ case COR_TYPE_MSC:
+ core_section (abfd, n)->name = ".misc";
+ core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
+ break;
+ default:
+ core_section (abfd, n)->name = ".unknown";
+ core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
+ break;
+ }
+ core_section (abfd, n)->_raw_size = core->cd_segs[i].cs_len;
+ core_section (abfd, n)->vma = core->cd_segs[i].cs_address;
+ core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset;
+ core_section (abfd, n)->alignment_power = 2;
+ core_section (abfd, n)->next = NULL;
+ if (n > 0)
+ core_section (abfd, (n-1))->next = core_section (abfd, n);
+
+ abfd->section_count = ++n;
+ }
+
+ core_regsec (abfd)->name = ".reg";
+ core_reg2sec (abfd)->name = ".reg2";
+
+ core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
+ core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
+
+ core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
+ core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
+
+ core_regsec (abfd)->vma = -1;
+ core_reg2sec (abfd)->vma = -1;
+
+ /* We'll access the regs afresh in the core file, like any section: */
+ core_regsec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,cd_regs[0]);
+ core_reg2sec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,
+ cd_fpregs);
+
+ /* add the 2 reg fake sections to abfd */
+ abfd->section_count += 2;
+ abfd->sections = core_regsec (abfd);
+ core_regsec (abfd)->next = core_reg2sec (abfd);
+ core_reg2sec (abfd)->next = core_section (abfd, 0);
+
+ return abfd->xvec;
+}
+
+static char *
+aix386_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_hdr (abfd)->cd_comm;
+}
+
+static int
+aix386_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_hdr (abfd)->cd_cursig;
+}
+
+static boolean
+aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd;
+ bfd *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this
+ point */
+}
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((PROTO(bfd_vma, (*), ( const bfd_byte *))) swap_abort )
+#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
+#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
+
+const bfd_target aix386_core_vec =
+ {
+ "aix386-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIANG_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_GETS, NO_PUT,
+ NO_GET, NO_GETS, NO_PUT,
+ NO_GET, NO_GETS, NO_PUT, /* data */
+ NO_GET, NO_GETS, NO_PUT,
+ NO_GET, NO_GETS, NO_PUT,
+ NO_GET, NO_GETS, NO_PUT, /* hdrs */
+
+ {_bfd_dummy_target, _bfd_dummy_target,
+ _bfd_dummy_target, aix386_core_file_p},
+ {bfd_false, bfd_false, /* bfd_create_object */
+ bfd_false, bfd_false},
+ {bfd_false, bfd_false, /* bfd_write_contents */
+ bfd_false, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (aix386),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c
new file mode 100644
index 00000000000..2c11ffe9ff2
--- /dev/null
+++ b/bfd/aout-adobe.c
@@ -0,0 +1,527 @@
+/* BFD back-end for a.out.adobe binaries.
+ Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Written by Cygnus Support. Based on bout.c.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "aout/adobe.h"
+
+#include "aout/stab_gnu.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+extern const bfd_target a_out_adobe_vec; /* Forward decl */
+
+static const bfd_target *aout_adobe_callback PARAMS ((bfd *));
+
+extern boolean aout_32_slurp_symbol_table PARAMS ((bfd *abfd));
+extern boolean aout_32_write_syms PARAMS ((bfd *));
+static void aout_adobe_write_section PARAMS ((bfd *abfd, sec_ptr sect));
+
+/* Swaps the information in an executable header taken from a raw byte
+ stream memory image, into the internal exec_header structure. */
+
+void aout_adobe_swap_exec_header_in
+ PARAMS ((bfd *abfd, struct external_exec *raw_bytes,
+ struct internal_exec *execp));
+
+void
+aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* Now fill in fields in the execp, from the bytes in the raw data. */
+ execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_text = GET_WORD (abfd, bytes->e_text);
+ execp->a_data = GET_WORD (abfd, bytes->e_data);
+ execp->a_bss = GET_WORD (abfd, bytes->e_bss);
+ execp->a_syms = GET_WORD (abfd, bytes->e_syms);
+ execp->a_entry = GET_WORD (abfd, bytes->e_entry);
+ execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
+ execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
+}
+
+/* Swaps the information in an internal exec header structure into the
+ supplied buffer ready for writing to disk. */
+
+PROTO(void, aout_adobe_swap_exec_header_out,
+ (bfd *abfd,
+ struct internal_exec *execp,
+ struct external_exec *raw_bytes));
+void
+aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
+ bfd *abfd;
+ struct internal_exec *execp;
+ struct external_exec *raw_bytes;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* Now fill in fields in the raw data, from the fields in the exec struct. */
+ bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
+ PUT_WORD (abfd, execp->a_text , bytes->e_text);
+ PUT_WORD (abfd, execp->a_data , bytes->e_data);
+ PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
+ PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
+ PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
+ PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
+ PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
+}
+
+
+static const bfd_target *
+aout_adobe_object_p (abfd)
+ bfd *abfd;
+{
+ struct internal_exec anexec;
+ struct external_exec exec_bytes;
+ char *targ;
+
+ if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+
+ /* Normally we just compare for the magic number.
+ However, a bunch of Adobe tools aren't fixed up yet; they generate
+ files using ZMAGIC(!).
+ If the environment variable GNUTARGET is set to "a.out.adobe", we will
+ take just about any a.out file as an Adobe a.out file. FIXME! */
+
+ if (N_BADMAG (anexec)) {
+ targ = getenv ("GNUTARGET");
+ if (targ && !strcmp (targ, a_out_adobe_vec.name))
+ ; /* Just continue anyway, if specifically set to this format */
+ else
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ }
+
+ aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
+ return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_callback);
+}
+
+
+/* Finish up the opening of a b.out file for reading. Fill in all the
+ fields that are not handled by common code. */
+
+static const bfd_target *
+aout_adobe_callback (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+ asection *sect;
+ struct external_segdesc ext[1];
+ char *section_name;
+ char try_again[30]; /* name and number */
+ char *newname;
+ int trynum;
+ flagword flags;
+
+ /* Architecture and machine type -- unknown in this format. */
+ bfd_set_arch_mach(abfd, bfd_arch_unknown, 0);
+
+ /* The positions of the string table and symbol table. */
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+
+ /* Suck up the section information from the file, one section at a time. */
+
+ for (;;) {
+ if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ switch (ext->e_type[0]) {
+ case N_TEXT:
+ section_name = ".text";
+ flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
+ break;
+
+ case N_DATA:
+ section_name = ".data";
+ flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
+ break;
+
+ case N_BSS:
+ section_name = ".bss";
+ flags = SEC_DATA | SEC_HAS_CONTENTS;
+ break;
+
+ case 0:
+ goto no_more_sections;
+
+ default:
+ (*_bfd_error_handler)
+ (_("%s: Unknown section type in a.out.adobe file: %x\n"),
+ bfd_get_filename (abfd), ext->e_type[0]);
+ goto no_more_sections;
+ }
+
+ /* First one is called ".text" or whatever; subsequent ones are
+ ".text1", ".text2", ... */
+
+ bfd_set_error (bfd_error_no_error);
+ sect = bfd_make_section (abfd, section_name);
+ trynum = 0;
+ while (!sect) {
+ if (bfd_get_error () != bfd_error_no_error)
+ return 0; /* Some other error -- slide into the sunset */
+ sprintf (try_again, "%s%d", section_name, ++trynum);
+ sect = bfd_make_section (abfd, try_again);
+ }
+
+ /* Fix the name, if it is a sprintf'd name. */
+ if (sect->name == try_again) {
+ newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
+ if (newname == NULL)
+ return 0;
+ strcpy (newname, sect->name);
+ sect->name = newname;
+ }
+
+ /* Now set the section's attributes. */
+ bfd_set_section_flags (abfd, sect, flags);
+ sect->_raw_size = ((ext->e_size[0] << 8) /* Assumed big-endian */
+ | ext->e_size[1] << 8)
+ | ext->e_size[2];
+ sect->_cooked_size = sect->_raw_size;
+ sect->vma = bfd_h_get_32 (abfd, ext->e_virtbase);
+ sect->filepos = bfd_h_get_32 (abfd, ext->e_filebase);
+ /* FIXME XXX alignment? */
+
+ /* Set relocation information for first section of each type. */
+ if (trynum == 0) switch (ext->e_type[0]) {
+ case N_TEXT:
+ sect->rel_filepos = N_TRELOFF (*execp);
+ sect->reloc_count = execp->a_trsize;
+ break;
+
+ case N_DATA:
+ sect->rel_filepos = N_DRELOFF (*execp);
+ sect->reloc_count = execp->a_drsize;
+ break;
+ }
+ }
+no_more_sections:
+
+ adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
+ adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
+ adata(abfd).page_size = 1; /* Not applicable. */
+ adata(abfd).segment_size = 1; /* Not applicable. */
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+
+ return abfd->xvec;
+}
+
+struct bout_data_struct {
+ struct aoutdata a;
+ struct internal_exec e;
+};
+
+static boolean
+aout_adobe_mkobject (abfd)
+ bfd *abfd;
+{
+ struct bout_data_struct *rawptr;
+
+ rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
+ if (rawptr == NULL)
+ return false;
+
+ abfd->tdata.bout_data = rawptr;
+ exec_hdr (abfd) = &rawptr->e;
+
+ adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
+ adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
+ adata(abfd).page_size = 1; /* Not applicable. */
+ adata(abfd).segment_size = 1; /* Not applicable. */
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+
+ return true;
+}
+
+
+static boolean
+aout_adobe_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec swapped_hdr;
+ static struct external_segdesc sentinel[1]; /* Initialized to zero */
+ asection *sect;
+
+ exec_hdr (abfd)->a_info = ZMAGIC;
+
+ /* Calculate text size as total of text sections, etc. */
+
+ exec_hdr (abfd)->a_text = 0;
+ exec_hdr (abfd)->a_data = 0;
+ exec_hdr (abfd)->a_bss = 0;
+ exec_hdr (abfd)->a_trsize = 0;
+ exec_hdr (abfd)->a_drsize = 0;
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_CODE) {
+ exec_hdr (abfd)->a_text += sect->_raw_size;
+ exec_hdr (abfd)->a_trsize += sect->reloc_count *
+ sizeof (struct reloc_std_external);
+ } else if (sect->flags & SEC_DATA) {
+ exec_hdr (abfd)->a_data += sect->_raw_size;
+ exec_hdr (abfd)->a_drsize += sect->reloc_count *
+ sizeof (struct reloc_std_external);
+ } else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) {
+ exec_hdr (abfd)->a_bss += sect->_raw_size;
+ }
+ }
+
+ exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd)
+ * sizeof (struct external_nlist);
+ exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
+
+ aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
+
+ /* Now write out the section information. Text first, data next, rest
+ afterward. */
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_CODE) {
+ aout_adobe_write_section (abfd, sect);
+ }
+ }
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_DATA) {
+ aout_adobe_write_section (abfd, sect);
+ }
+ }
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (!(sect->flags & (SEC_CODE|SEC_DATA))) {
+ aout_adobe_write_section (abfd, sect);
+ }
+ }
+
+ /* Write final `sentinel` section header (with type of 0). */
+ if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
+ != sizeof (*sentinel))
+ return false;
+
+ /* Now write out reloc info, followed by syms and strings */
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ if (! aout_32_write_syms (abfd))
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_CODE) {
+ if (!aout_32_squirt_out_relocs (abfd, sect))
+ return false;
+ }
+ }
+
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_DATA) {
+ if (!aout_32_squirt_out_relocs (abfd, sect))
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+static void
+aout_adobe_write_section (abfd, sect)
+ bfd *abfd;
+ sec_ptr sect;
+{
+ /* FIXME XXX */
+}
+
+static boolean
+aout_adobe_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ file_ptr section_start;
+ sec_ptr sect;
+
+ if (abfd->output_has_begun == false) { /* set by bfd.c handler */
+
+ /* Assign file offsets to sections. Text sections are first, and
+ are contiguous. Then data sections. Everything else at the end. */
+
+ section_start = N_TXTOFF (ignore<-->me);
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_CODE) {
+ sect->filepos = section_start;
+ /* FIXME: Round to alignment */
+ section_start += sect->_raw_size;
+ }
+ }
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_DATA) {
+ sect->filepos = section_start;
+ /* FIXME: Round to alignment */
+ section_start += sect->_raw_size;
+ }
+ }
+
+ for (sect = abfd->sections; sect; sect = sect->next) {
+ if (sect->flags & SEC_HAS_CONTENTS &&
+ !(sect->flags & (SEC_CODE|SEC_DATA))) {
+ sect->filepos = section_start;
+ /* FIXME: Round to alignment */
+ section_start += sect->_raw_size;
+ }
+ }
+ }
+
+ /* regardless, once we know what we're doing, we might as well get going */
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
+ return false;
+
+ if (count != 0) {
+ return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
+ }
+ return true;
+}
+
+static boolean
+aout_adobe_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ if (! bfd_default_set_arch_mach (abfd, arch, machine))
+ return false;
+
+ if (arch == bfd_arch_unknown
+ || arch == bfd_arch_m68k)
+ return true;
+
+ return false;
+}
+
+static int
+aout_adobe_sizeof_headers (ignore_abfd, ignore)
+ bfd *ignore_abfd;
+ boolean ignore;
+{
+ return sizeof(struct internal_exec);
+}
+
+
+
+
+/* Build the transfer vector for Adobe A.Out files. */
+
+#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
+
+#define aout_32_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
+#define aout_32_bfd_reloc_type_lookup \
+ ((reloc_howto_type *(*) \
+ PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
+
+#define aout_32_set_arch_mach aout_adobe_set_arch_mach
+#define aout_32_set_section_contents aout_adobe_set_section_contents
+
+#define aout_32_sizeof_headers aout_adobe_sizeof_headers
+#define aout_32_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#define aout_32_bfd_relax_section bfd_generic_relax_section
+#define aout_32_bfd_gc_sections bfd_generic_gc_sections
+#define aout_32_bfd_link_hash_table_create \
+ _bfd_generic_link_hash_table_create
+#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define aout_32_bfd_final_link _bfd_generic_final_link
+#define aout_32_bfd_link_split_section _bfd_generic_link_split_section
+
+const bfd_target a_out_adobe_vec =
+{
+ "a.out.adobe", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is unknown (big assumed) */
+ BFD_ENDIAN_BIG, /* hdr byte order is big */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT ),
+ /* section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC),
+ '_', /* symbol leading char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ {_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, aout_adobe_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, aout_adobe_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (aout_32),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
+ BFD_JUMP_TABLE_SYMBOLS (aout_32),
+ BFD_JUMP_TABLE_RELOCS (aout_32),
+ BFD_JUMP_TABLE_WRITE (aout_32),
+ BFD_JUMP_TABLE_LINK (aout_32),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/aout-arm.c b/bfd/aout-arm.c
new file mode 100644
index 00000000000..beb900beaa1
--- /dev/null
+++ b/bfd/aout-arm.c
@@ -0,0 +1,546 @@
+/* BFD back-end for raw ARM a.out binaries.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#define N_TXTADDR(x) \
+ ((N_MAGIC(x) == NMAGIC) ? 0x8000 : \
+ (N_MAGIC(x) != ZMAGIC) ? 0 : \
+ (N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \
+ TEXT_START_ADDR)
+
+#define TEXT_START_ADDR 0x8000
+#define TARGET_PAGE_SIZE 0x8000
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_arm
+
+#define MY(OP) CAT(aoutarm_,OP)
+#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
+ (((x).a_info & ~006000) != OMAGIC) && \
+ ((x).a_info != NMAGIC))
+#define N_MAGIC(x) ((x).a_info & ~07200)
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#define MYARM(OP) CAT(aoutarm_,OP)
+reloc_howto_type *MYARM(bfd_reloc_type_lookup)
+ PARAMS((bfd *, bfd_reloc_code_real_type));
+static boolean MYARM(write_object_contents) PARAMS((bfd *));
+
+/* Avoid multiple defininitions from aoutx if supporting standarad a.out
+ as well as our own. */
+#define NAME(x,y) CAT3(aoutarm,_32_,y)
+
+#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
+
+#include "libaout.h"
+#include "aout/aout64.h"
+
+static bfd_reloc_status_type
+MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
+ arelent *, asymbol **,
+ bfd_size_type));
+void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *,
+ struct reloc_std_external *));
+
+reloc_howto_type MY(howto_table)[] =
+{
+ /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask
+ pcdone */
+ HOWTO (0, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true,
+ 0x000000ff, 0x000000ff, false),
+ HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true,
+ 0x0000ffff, 0x0000ffff, false),
+ HOWTO (2, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true,
+ 0xffffffff, 0xffffffff, false),
+ HOWTO (3, 2, 2, 26, true, 0, complain_overflow_signed, MY(fix_pcrel_26),
+ "ARM26", true, 0x00ffffff, 0x00ffffff, true),
+ HOWTO (4, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true,
+ 0x000000ff, 0x000000ff, true),
+ HOWTO (5, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true,
+ 0x0000ffff, 0x0000ffff, true),
+ HOWTO (6, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true,
+ 0xffffffff, 0xffffffff, true),
+ HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed,
+ MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0,
+ false),
+ {-1},
+ HOWTO (9, 0, -1, 16, false, 0, complain_overflow_bitfield, 0, "NEG16", true,
+ 0x0000ffff, 0x0000ffff, false),
+ HOWTO (10, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "NEG32", true,
+ 0xffffffff, 0xffffffff, false)
+};
+
+#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
+#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
+
+reloc_howto_type *
+MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
+ bfd *abfd;
+ struct reloc_std_external *rel;
+ int *r_index;
+ int *r_extern;
+ int *r_pcrel;
+{
+ unsigned int r_length;
+ unsigned int r_pcrel_done;
+ unsigned int r_neg;
+ int index;
+
+ *r_pcrel = 0;
+ if (bfd_header_big_endian (abfd))
+ {
+ *r_index = ((rel->r_index[0] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[2]);
+ *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
+ r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
+ r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG));
+ r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
+ >> RELOC_STD_BITS_LENGTH_SH_BIG);
+ }
+ else
+ {
+ *r_index = ((rel->r_index[2] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[0]);
+ *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
+ r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
+ r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE));
+ r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
+ >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
+ }
+ index = r_length + 4 * r_pcrel_done + 8 * r_neg;
+ if (index == 3)
+ *r_pcrel = 1;
+
+ return MY(howto_table) + index;
+}
+
+#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
+ MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
+
+void
+MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
+ bfd *abfd;
+ int r_extern;
+ int r_index;
+ long value;
+ reloc_howto_type *howto;
+ struct reloc_std_external *reloc;
+{
+ unsigned int r_length;
+ int r_pcrel;
+ int r_neg;
+
+ PUT_WORD (abfd, value, reloc->r_address);
+ r_length = howto->size ; /* Size as a power of two */
+
+ /* Special case for branch relocations. */
+ if (howto->type == 3 || howto->type == 7)
+ r_length = 3;
+
+ r_pcrel = howto->type & 4; /* PC Relative done? */
+ r_neg = howto->type & 8; /* Negative relocation */
+ if (bfd_header_big_endian (abfd))
+ {
+ reloc->r_index[0] = r_index >> 16;
+ reloc->r_index[1] = r_index >> 8;
+ reloc->r_index[2] = r_index;
+ reloc->r_type[0] =
+ ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
+ | (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
+ }
+ else
+ {
+ reloc->r_index[2] = r_index >> 16;
+ reloc->r_index[1] = r_index >> 8;
+ reloc->r_index[0] = r_index;
+ reloc->r_type[0] =
+ ((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
+ | (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
+ }
+}
+
+#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
+ MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
+
+void
+MY(relocatable_reloc)(howto, abfd, reloc, amount, r_addr)
+ reloc_howto_type *howto;
+ bfd *abfd;
+ struct reloc_std_external *reloc;
+ bfd_vma *amount;
+ bfd_vma r_addr;
+{
+ if (howto->type == 3)
+ {
+ if (reloc->r_type[0]
+ & (bfd_header_big_endian (abfd)
+ ? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE))
+ {
+ /* The reloc is still external, so don't modify anything. */
+ *amount = 0;
+ }
+ else
+ {
+ *amount -= r_addr;
+ /* Change the r_pcrel value -- on the ARM, this bit is set once the
+ relocation is done. */
+ if (bfd_header_big_endian (abfd))
+ reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG;
+ else
+ reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE;
+ }
+ }
+ else if (howto->type == 7)
+ *amount = 0;
+}
+
+#define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \
+ MY(relocatable_reloc)(HOW, BFD, REL, &(AMOUNT), ADDR)
+
+static bfd_reloc_status_type
+MY(fix_pcrel_26_done) (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* This is dead simple at present. */
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_size_type addr = reloc_entry->address;
+ long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+
+ /* If this is an undefined symbol, return error */
+ if (symbol->section == &bfd_und_section
+ && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
+
+ /* If the sections are different, and we are doing a partial relocation,
+ just ignore it for now. */
+ if (symbol->section->name != input_section->name
+ && output_bfd != (bfd *)NULL)
+ return bfd_reloc_ok;
+
+ relocation = (target & 0x00ffffff) << 2;
+ relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
+ relocation += symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+ relocation -= input_section->output_section->vma;
+ relocation -= input_section->output_offset;
+ relocation -= addr;
+ if (relocation & 3)
+ return bfd_reloc_overflow;
+
+ /* Check for overflow */
+ if (relocation & 0x02000000)
+ {
+ if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
+ flag = bfd_reloc_overflow;
+ }
+ else if (relocation & ~0x03ffffff)
+ flag = bfd_reloc_overflow;
+
+ target &= ~0x00ffffff;
+ target |= (relocation >> 2) & 0x00ffffff;
+ bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+
+ /* Now the ARM magic... Change the reloc type so that it is marked as done.
+ Strictly this is only necessary if we are doing a partial relocation. */
+ reloc_entry->howto = &MY(howto_table)[7];
+
+ return flag;
+}
+
+reloc_howto_type *
+MY(bfd_reloc_type_lookup)(abfd,code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+#define ASTD(i,j) case i: return &MY(howto_table)[j]
+ if (code == BFD_RELOC_CTOR)
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ default: return (CONST struct reloc_howto_struct *) 0;
+ }
+
+ switch (code)
+ {
+ ASTD (BFD_RELOC_16, 1);
+ ASTD (BFD_RELOC_32, 2);
+ ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
+ ASTD (BFD_RELOC_8_PCREL, 4);
+ ASTD (BFD_RELOC_16_PCREL, 5);
+ ASTD (BFD_RELOC_32_PCREL, 6);
+ default: return (CONST struct reloc_howto_struct *) 0;
+ }
+}
+
+#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
+#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
+#define MY_get_section_contents _bfd_generic_get_section_contents
+/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create */
+/* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols */
+/* #define MY_bfd_final_link _bfd_generic_final_link */
+
+#include "aoutx.h"
+
+static void
+MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct reloc_std_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ int r_index;
+ int r_extern;
+ int r_pcrel;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+
+ cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+
+ cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
+
+ MOVE_ADDRESS (0);
+}
+
+void
+MY_swap_std_reloc_out (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
+{
+ int r_index;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ int r_extern;
+ int r_length;
+ int r_pcrel;
+ int r_neg = 0; /* Negative relocs use the BASEREL bit. */
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD(abfd, g->address, natptr->r_address);
+
+ r_length = g->howto->size ; /* Size as a power of two */
+ if (r_length < 0)
+ {
+ r_length = -r_length;
+ r_neg = 1;
+ }
+
+ r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
+
+ /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
+ relocation has been done already (Only for the 26-bit one I think)???!!!
+ */
+
+ if (g->howto->type == 3)
+ {
+ r_length = 3;
+ r_pcrel = 0;
+ }
+ else if (g->howto->type == 7)
+ {
+ r_length = 3;
+ r_pcrel = 1;
+ }
+
+
+#if 0
+ /* For a standard reloc, the addend is in the object file. */
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+#endif
+
+ /* name was clobbered by aout_write_syms to be symbol index */
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here
+ */
+
+ if (bfd_is_com_section (output_section)
+ || output_section == &bfd_abs_section
+ || output_section == &bfd_und_section)
+ {
+ if (bfd_abs_section.symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+ r_extern = 1;
+ r_index = (*(g->sym_ptr_ptr))->KEEPIT;
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd))
+ {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ ( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
+ | (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
+ }
+ else
+ {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ ( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
+ | (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
+ }
+}
+
+#define MY_BFD_TARGET
+
+#include "aout-target.h"
+
+const bfd_target aout_arm_little_vec =
+{
+ "a.out-arm-little", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_LITTLE, /* target byte order (little) */
+ BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ MY_symbol_leading_char,
+ AR_PAD_CHAR, /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, MY_core_file_p},
+ {bfd_false, MY_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (MY),
+ BFD_JUMP_TABLE_COPY (MY),
+ BFD_JUMP_TABLE_CORE (MY),
+ BFD_JUMP_TABLE_ARCHIVE (MY),
+ BFD_JUMP_TABLE_SYMBOLS (MY),
+ BFD_JUMP_TABLE_RELOCS (MY),
+ BFD_JUMP_TABLE_WRITE (MY),
+ BFD_JUMP_TABLE_LINK (MY),
+ BFD_JUMP_TABLE_DYNAMIC (MY),
+
+ (PTR) MY_backend_data,
+};
+
+const bfd_target aout_arm_big_vec =
+{
+ "a.out-arm-big", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_BIG, /* target byte order (big) */
+ BFD_ENDIAN_BIG, /* target headers byte order (big) */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ MY_symbol_leading_char,
+ AR_PAD_CHAR, /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, MY_core_file_p},
+ {bfd_false, MY_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (MY),
+ BFD_JUMP_TABLE_COPY (MY),
+ BFD_JUMP_TABLE_CORE (MY),
+ BFD_JUMP_TABLE_ARCHIVE (MY),
+ BFD_JUMP_TABLE_SYMBOLS (MY),
+ BFD_JUMP_TABLE_RELOCS (MY),
+ BFD_JUMP_TABLE_WRITE (MY),
+ BFD_JUMP_TABLE_LINK (MY),
+ BFD_JUMP_TABLE_DYNAMIC (MY),
+
+ (PTR) MY_backend_data,
+};
diff --git a/bfd/aout-encap.c b/bfd/aout-encap.c
new file mode 100644
index 00000000000..c25f9037dce
--- /dev/null
+++ b/bfd/aout-encap.c
@@ -0,0 +1,236 @@
+/* BFD back-end for a.out files encapsulated with COFF headers.
+ Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */
+
+#if 0
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define TEXT_START_ADDR 0
+#define BYTES_IN_WORD 4
+#endif
+
+#include "bfd.h"
+#include <sysdep.h>
+#include "libbfd.h"
+#include <aout/aout64.h>
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+const bfd_target *encap_real_callback ();
+
+const bfd_target *
+encap_object_p (abfd)
+ bfd *abfd;
+{
+ unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
+ unsigned long magic; /* Swapped magic number */
+ short coff_magic;
+ struct external_exec exec_bytes;
+ struct internal_exec exec;
+
+ if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
+ sizeof (magicbuf))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ coff_magic = bfd_h_get_16 (abfd, magicbuf);
+ if (coff_magic != COFF_MAGIC)
+ return 0; /* Not an encap coff file */
+
+ __header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
+ (fseek ((f), HEADER_OFFSET((f)), 1))
+
+ magic = bfd_h_get_32 (abfd, magicbuf);
+
+ if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
+
+ struct external_exec exec_bytes;
+ if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+
+ return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
+}
+
+/* Finish up the reading of a encapsulated-coff a.out file header */
+const bfd_target *
+encap_real_callback (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ MY(callback)(abfd, execp);
+
+ /* If we have a coff header, it can give us better values for
+ text_start and exec_data_start. This is particularly useful
+ for remote debugging of embedded systems. */
+ if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
+ {
+ struct coffheader ch;
+ int val;
+ val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
+ if (val == -1)
+ perror_with_name (filename);
+ val = myread (execchan, &ch, sizeof (ch));
+ if (val < 0)
+ perror_with_name (filename);
+ text_start = ch.text_start;
+ exec_data_start = ch.data_start;
+ } else
+ {
+ text_start =
+ IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
+ exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
+ ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
+ }
+
+ /* Determine the architecture and machine type of the object file. */
+ bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */
+
+ return abfd->xvec;
+}
+
+/* Write an object file in Encapsulated COFF format.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+boolean
+encap_write_object_contents (abfd)
+ bfd *abfd;
+{
+ bfd_size_type data_pad = 0;
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+/****** FIXME: Fragments from the old GNU LD program for dealing with
+ encap coff. */
+struct coffheader coffheader;
+int need_coff_header;
+
+ /* Determine whether to count the header as part of
+ the text size, and initialize the text size accordingly.
+ This depends on the kind of system and on the output format selected. */
+
+ N_SET_MAGIC (outheader, magic);
+#ifdef INITIALIZE_HEADER
+ INITIALIZE_HEADER;
+#endif
+
+ text_size = sizeof (struct exec);
+#ifdef COFF_ENCAPSULATE
+ if (relocatable_output == 0 && file_table[0].just_syms_flag == 0)
+ {
+ need_coff_header = 1;
+ /* set this flag now, since it will change the values of N_TXTOFF, etc */
+ N_SET_FLAGS (outheader, aout_backend_info (abfd)->exec_hdr_flags);
+ text_size += sizeof (struct coffheader);
+ }
+#endif
+
+#ifdef COFF_ENCAPSULATE
+ if (need_coff_header)
+ {
+ /* We are encapsulating BSD format within COFF format. */
+ struct coffscn *tp, *dp, *bp;
+
+ tp = &coffheader.scns[0];
+ dp = &coffheader.scns[1];
+ bp = &coffheader.scns[2];
+
+ strcpy (tp->s_name, ".text");
+ tp->s_paddr = text_start;
+ tp->s_vaddr = text_start;
+ tp->s_size = text_size;
+ tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec);
+ tp->s_relptr = 0;
+ tp->s_lnnoptr = 0;
+ tp->s_nreloc = 0;
+ tp->s_nlnno = 0;
+ tp->s_flags = 0x20;
+ strcpy (dp->s_name, ".data");
+ dp->s_paddr = data_start;
+ dp->s_vaddr = data_start;
+ dp->s_size = data_size;
+ dp->s_scnptr = tp->s_scnptr + tp->s_size;
+ dp->s_relptr = 0;
+ dp->s_lnnoptr = 0;
+ dp->s_nreloc = 0;
+ dp->s_nlnno = 0;
+ dp->s_flags = 0x40;
+ strcpy (bp->s_name, ".bss");
+ bp->s_paddr = dp->s_vaddr + dp->s_size;
+ bp->s_vaddr = bp->s_paddr;
+ bp->s_size = bss_size;
+ bp->s_scnptr = 0;
+ bp->s_relptr = 0;
+ bp->s_lnnoptr = 0;
+ bp->s_nreloc = 0;
+ bp->s_nlnno = 0;
+ bp->s_flags = 0x80;
+
+ coffheader.f_magic = COFF_MAGIC;
+ coffheader.f_nscns = 3;
+ /* store an unlikely time so programs can
+ * tell that there is a bsd header
+ */
+ coffheader.f_timdat = 1;
+ coffheader.f_symptr = 0;
+ coffheader.f_nsyms = 0;
+ coffheader.f_opthdr = 28;
+ coffheader.f_flags = 0x103;
+ /* aouthdr */
+ coffheader.magic = ZMAGIC;
+ coffheader.vstamp = 0;
+ coffheader.tsize = tp->s_size;
+ coffheader.dsize = dp->s_size;
+ coffheader.bsize = bp->s_size;
+ coffheader.entry = outheader.a_entry;
+ coffheader.text_start = tp->s_vaddr;
+ coffheader.data_start = dp->s_vaddr;
+ }
+#endif
+
+#ifdef COFF_ENCAPSULATE
+ if (need_coff_header)
+ mywrite (&coffheader, sizeof coffheader, 1, outdesc);
+#endif
+
+#ifndef COFF_ENCAPSULATE
+ padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc);
+#endif
+
+ text_size -= N_TXTOFF (outheader);
+ WRITE_HEADERS(abfd, execp);
+ return true;
+}
+
+#define MY_write_object_content encap_write_object_contents
+#define MY_object_p encap_object_p
+#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
+
+#include "aout-target.h"
diff --git a/bfd/aout-ns32k.c b/bfd/aout-ns32k.c
new file mode 100644
index 00000000000..c1335aa84d7
--- /dev/null
+++ b/bfd/aout-ns32k.c
@@ -0,0 +1,370 @@
+/* BFD back-end for ns32k a.out-ish binaries.
+ Copyright (C) 1990, 91, 92, 94, 95, 96, 1998 Free Software Foundation, Inc.
+ Contributed by Ian Dall (idall@eleceng.adelaide.edu.au).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+
+#include "bfd.h"
+#include "aout/aout64.h"
+#include "ns32k.h"
+
+#define MYNS(OP) CAT(ns32kaout_,OP)
+reloc_howto_type *
+MYNS(bfd_reloc_type_lookup)
+ PARAMS((bfd *abfd AND
+ bfd_reloc_code_real_type code));
+
+boolean
+MYNS(write_object_contents)
+ PARAMS((bfd *abfd));
+
+/* Avoid multiple definitions from aoutx if supporting standard a.out format(s)
+ * as well as this one
+ */
+#define NAME(x,y) CAT3(ns32kaout,_32_,y)
+
+void bfd_ns32k_arch PARAMS ((void));
+
+#include "libaout.h"
+
+#define MY(OP) MYNS(OP)
+
+#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
+#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
+
+static void
+MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes,
+ arelent *cache_ptr, asymbol **symbols,
+ bfd_size_type symcount));
+
+static void
+MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g,
+ struct reloc_std_external *natptr));
+
+/* The ns32k series is ah, unusual, when it comes to relocation.
+ * There are three storage methods for relocateable objects. There
+ * are displacements, immediate operands and ordinary twos complement
+ * data. Of these, only the last fits into the standard relocation
+ * scheme. Immediate operands are stored huffman encoded and
+ * immediate operands are stored big endian (where as the natural byte
+ * order is little endian for this achitecture).
+
+ * Note that the ns32k displacement storage method is orthogonal to
+ * whether the relocation is pc relative or not. The "displacement"
+ * storage scheme is used for essentially all address constants. The
+ * displacement can be relative to zero (absolute displacement),
+ * relative to the pc (pc relative), the stack pointer, the frame
+ * pointer, the static base register and general purpose register etc.
+
+ * For example:
+ *
+ * sym1: .long . # pc relative 2's complement
+ * sym1: .long foo # 2's complement not pc relative
+ *
+ * self: movd @self, r0 # pc relative displacement
+ * movd foo, r0 # non pc relative displacement
+ *
+ * self: movd self, r0 # pc relative immediate
+ * movd foo, r0 # non pc relative immediate
+ *
+ * In addition, for historical reasons the encoding of the relocation types
+ * in the a.out format relocation entries is such that even the relocation
+ * methods which are standard are not encoded the standard way.
+ *
+ */
+
+reloc_howto_type MY(howto_table)[] =
+{
+ /* ns32k immediate operands */
+ HOWTO (BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true,
+ _bfd_ns32k_reloc_imm, "NS32K_IMM_8",
+ true, 0x000000ff,0x000000ff, false),
+ HOWTO (BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true,
+ _bfd_ns32k_reloc_imm, "NS32K_IMM_16",
+ true, 0x0000ffff,0x0000ffff, false),
+ HOWTO (BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true,
+ _bfd_ns32k_reloc_imm, "NS32K_IMM_32",
+ true, 0xffffffff,0xffffffff, false),
+ HOWTO (BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false,
+ _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_8",
+ true, 0x000000ff, 0x000000ff, false),
+ HOWTO (BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false,
+ _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_16",
+ true, 0x0000ffff,0x0000ffff, false),
+ HOWTO (BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false,
+ _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_32",
+ true, 0xffffffff,0xffffffff, false),
+
+ /* ns32k displacements */
+ HOWTO (BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true,
+ _bfd_ns32k_reloc_disp, "NS32K_DISP_8",
+ true, 0x000000ff,0x000000ff, false),
+ HOWTO (BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true,
+ _bfd_ns32k_reloc_disp, "NS32K_DISP_16",
+ true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true,
+ _bfd_ns32k_reloc_disp, "NS32K_DISP_32",
+ true, 0xffffffff, 0xffffffff, false),
+ HOWTO (BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false,
+ _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_8",
+ true, 0x000000ff,0x000000ff, false),
+ HOWTO (BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false,
+ _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_16",
+ true, 0x0000ffff,0x0000ffff, false),
+ HOWTO (BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false,
+ _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_32",
+ true, 0xffffffff,0xffffffff, false),
+
+ /* Normal 2's complement */
+ HOWTO (BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,
+ "8", true, 0x000000ff,0x000000ff, false),
+ HOWTO (BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,
+ "16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO (BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,
+ "32", true, 0xffffffff,0xffffffff, false),
+ HOWTO (BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0,
+ "PCREL_8", true, 0x000000ff,0x000000ff, false),
+ HOWTO (BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0,
+ "PCREL_16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO (BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0,
+ "PCREL_32", true, 0xffffffff,0xffffffff, false),
+};
+
+
+#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14)
+
+#define RELOC_STD_BITS_NS32K_TYPE_BIG 0x06
+#define RELOC_STD_BITS_NS32K_TYPE_LITTLE 0x60
+#define RELOC_STD_BITS_NS32K_TYPE_SH_BIG 1
+#define RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE 5
+
+reloc_howto_type *
+MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
+ bfd *abfd;
+ struct reloc_std_external *rel;
+ int *r_index;
+ int *r_extern;
+ int *r_pcrel;
+{
+ unsigned int r_length;
+ int r_ns32k_type;
+/* BFD_ASSERT(bfd_header_little_endian (abfd)); */
+ *r_index = ((rel->r_index[2] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[0] );
+ *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
+ *r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
+ r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
+ >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
+ r_ns32k_type = ((rel->r_type[0] & RELOC_STD_BITS_NS32K_TYPE_LITTLE)
+ >> RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
+ return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
+}
+
+#define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto)(BFD, REL, &IN, &EX, &PC)
+
+void
+MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
+ bfd *abfd;
+ int r_extern;
+ int r_index;
+ long value;
+ reloc_howto_type *howto;
+ struct reloc_std_external *reloc;
+{
+ unsigned int r_length;
+ int r_pcrel;
+ int r_ns32k_type;
+ PUT_WORD (abfd, value, reloc->r_address);
+ r_length = howto->size ; /* Size as a power of two */
+ r_pcrel = (int) howto->pc_relative; /* Relative to PC? */
+ r_ns32k_type = (howto - MY(howto_table) )/6;
+/* BFD_ASSERT (bfd_header_little_endian (abfd)); */
+ reloc->r_index[2] = r_index >> 16;
+ reloc->r_index[1] = r_index >> 8;
+ reloc->r_index[0] = r_index;
+ reloc->r_type[0] =
+ (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
+ | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)
+ | (r_ns32k_type << RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
+}
+
+#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
+ MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
+
+#define STAT_FOR_EXEC
+
+#define MY_final_link_relocate _bfd_ns32k_final_link_relocate
+#define MY_relocate_contents _bfd_ns32k_relocate_contents
+
+#include <aoutx.h>
+
+reloc_howto_type *
+MY(bfd_reloc_type_lookup)(abfd,code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+
+#define ENTRY(i,j) case i: return &MY(howto_table)[j]
+
+ int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
+
+ BFD_ASSERT(ext == 0);
+ if (code == BFD_RELOC_CTOR)
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ }
+ switch (code)
+ {
+ ENTRY(BFD_RELOC_NS32K_IMM_8, 0);
+ ENTRY(BFD_RELOC_NS32K_IMM_16, 1);
+ ENTRY(BFD_RELOC_NS32K_IMM_32, 2);
+ ENTRY(BFD_RELOC_NS32K_IMM_8_PCREL, 3);
+ ENTRY(BFD_RELOC_NS32K_IMM_16_PCREL, 4);
+ ENTRY(BFD_RELOC_NS32K_IMM_32_PCREL, 5);
+ ENTRY(BFD_RELOC_NS32K_DISP_8, 6);
+ ENTRY(BFD_RELOC_NS32K_DISP_16, 7);
+ ENTRY(BFD_RELOC_NS32K_DISP_32, 8);
+ ENTRY(BFD_RELOC_NS32K_DISP_8_PCREL, 9);
+ ENTRY(BFD_RELOC_NS32K_DISP_16_PCREL, 10);
+ ENTRY(BFD_RELOC_NS32K_DISP_32_PCREL, 11);
+ ENTRY(BFD_RELOC_8, 12);
+ ENTRY(BFD_RELOC_16, 13);
+ ENTRY(BFD_RELOC_32, 14);
+ ENTRY(BFD_RELOC_8_PCREL, 15);
+ ENTRY(BFD_RELOC_16_PCREL, 16);
+ ENTRY(BFD_RELOC_32_PCREL, 17);
+ default: return (reloc_howto_type *) NULL;
+ }
+#undef ENTRY
+}
+
+
+static void
+MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct reloc_std_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ int r_index;
+ int r_extern;
+ int r_pcrel;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+
+ cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+
+ /* now the fun stuff */
+
+ cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel);
+
+ MOVE_ADDRESS(0);
+}
+
+static void
+MY_swap_std_reloc_out (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
+{
+ int r_index;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ int r_extern;
+ unsigned int r_addend;
+ asection *output_section = sym->section->output_section;
+
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+
+ /* name was clobbered by aout_write_syms to be symbol index */
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ Check for that here. */
+
+ if (bfd_is_com_section (output_section)
+ || output_section == &bfd_abs_section
+ || output_section == &bfd_und_section)
+ {
+ if (bfd_abs_section.symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+ r_extern = 1;
+#undef KEEPIT
+#define KEEPIT udata.i
+ r_index = (*(g->sym_ptr_ptr))->KEEPIT;
+#undef KEEPIT
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ MY_put_reloc (abfd, r_extern, r_index, g->address, g->howto, natptr);
+}
+
+bfd_reloc_status_type
+_bfd_ns32k_relocate_contents (howto, input_bfd, relocation, location)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd_vma relocation;
+ bfd_byte *location;
+{
+ int r_ns32k_type = (howto - MY(howto_table)) / 6;
+ long (*get_data) PARAMS ((bfd_byte *, long, long));
+ int (*put_data) PARAMS ((long, bfd_byte *, long, long));
+
+ switch (r_ns32k_type)
+ {
+ case 0:
+ get_data = _bfd_ns32k_get_immediate;
+ put_data = _bfd_ns32k_put_immediate;
+ break;
+ case 1:
+ get_data = _bfd_ns32k_get_displacement;
+ put_data = _bfd_ns32k_put_displacement;
+ break;
+ case 2:
+ return _bfd_relocate_contents (howto, input_bfd, relocation,
+ location);
+ /* NOT REACHED */
+ break;
+ default:
+ return bfd_reloc_notsupported;
+ }
+ return _bfd_do_ns32k_reloc_contents (howto, input_bfd, relocation,
+ location, get_data, put_data);
+}
diff --git a/bfd/aout-sparcle.c b/bfd/aout-sparcle.c
new file mode 100644
index 00000000000..903b1367cb3
--- /dev/null
+++ b/bfd/aout-sparcle.c
@@ -0,0 +1,32 @@
+/* BFD backend for sparc little-endian aout binaries.
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGETNAME "a.out-sparc-little"
+#define MY(OP) CAT(sparcle_aout_,OP)
+
+#include "bfd.h"
+#include "bfdlink.h"
+#include "libaout.h"
+
+#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_SPARCLET)
+
+/* Include the usual a.out support. */
+#define TARGET_IS_LITTLE_ENDIAN_P
+#include "aoutf1.h"
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
new file mode 100644
index 00000000000..1aee07aada0
--- /dev/null
+++ b/bfd/aout-target.h
@@ -0,0 +1,650 @@
+/* Define a target vector and some small routines for a variant of a.out.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997
+ Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+/*#include "libaout.h"*/
+
+#ifndef SEGMENT_SIZE
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#endif
+
+extern reloc_howto_type * NAME(aout,reloc_type_lookup)
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+
+/* Set parameters about this a.out file that are machine-dependent.
+ This routine is called from some_aout_object_p just before it returns. */
+#ifndef MY_callback
+
+static const bfd_target *MY(callback) PARAMS ((bfd *));
+
+static const bfd_target *
+MY(callback) (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+ unsigned int arch_align_power;
+ unsigned long arch_align;
+
+ /* Calculate the file positions of the parts of a newly read aout header */
+ obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
+
+ /* The virtual memory addresses of the sections */
+ obj_textsec (abfd)->vma = N_TXTADDR(*execp);
+ obj_datasec (abfd)->vma = N_DATADDR(*execp);
+ obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
+
+ /* For some targets, if the entry point is not in the same page
+ as the start of the text, then adjust the VMA so that it is.
+ FIXME: Do this with a macro like SET_ARCH_MACH instead? */
+ if (aout_backend_info (abfd)->entry_is_text_address
+ && execp->a_entry > obj_textsec (abfd)->vma)
+ {
+ bfd_vma adjust;
+
+ adjust = execp->a_entry - obj_textsec (abfd)->vma;
+ /* Adjust only by whole pages. */
+ adjust &= ~(TARGET_PAGE_SIZE - 1);
+ obj_textsec (abfd)->vma += adjust;
+ obj_datasec (abfd)->vma += adjust;
+ obj_bsssec (abfd)->vma += adjust;
+ }
+
+ /* Set the load addresses to be the same as the virtual addresses. */
+ obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
+ obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
+ obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
+
+ /* The file offsets of the sections */
+ obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
+ obj_datasec (abfd)->filepos = N_DATOFF (*execp);
+
+ /* The file offsets of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
+ obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
+
+ /* The file offsets of the string table and symbol table. */
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+
+ /* Determine the architecture and machine type of the object file. */
+#ifdef SET_ARCH_MACH
+ SET_ARCH_MACH(abfd, *execp);
+#else
+ bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
+#endif
+
+ /* The number of relocation records. This must be called after
+ SET_ARCH_MACH. It assumes that SET_ARCH_MACH will set
+ obj_reloc_entry_size correctly, if the reloc size is not
+ RELOC_STD_SIZE. */
+ obj_textsec (abfd)->reloc_count =
+ execp->a_trsize / obj_reloc_entry_size (abfd);
+ obj_datasec (abfd)->reloc_count =
+ execp->a_drsize / obj_reloc_entry_size (abfd);
+
+ /* Now that we know the architecture, set the alignments of the
+ sections. This is normally done by NAME(aout,new_section_hook),
+ but when the initial sections were created the architecture had
+ not yet been set. However, for backward compatibility, we don't
+ set the alignment power any higher than as required by the size
+ of the section. */
+ arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
+ arch_align = 1 << arch_align_power;
+ if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
+ == obj_textsec (abfd)->_raw_size)
+ && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
+ == obj_datasec (abfd)->_raw_size)
+ && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
+ == obj_bsssec (abfd)->_raw_size))
+ {
+ obj_textsec (abfd)->alignment_power = arch_align_power;
+ obj_datasec (abfd)->alignment_power = arch_align_power;
+ obj_bsssec (abfd)->alignment_power = arch_align_power;
+ }
+
+ /* Don't set sizes now -- can't be sure until we know arch & mach.
+ Sizes get set in set_sizes callback, later. */
+#if 0
+ adata(abfd).page_size = TARGET_PAGE_SIZE;
+ adata(abfd).segment_size = SEGMENT_SIZE;
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+#endif
+
+ return abfd->xvec;
+}
+#endif
+
+#ifndef MY_object_p
+/* Finish up the reading of an a.out file header */
+
+static const bfd_target *MY(object_p) PARAMS ((bfd *));
+
+static const bfd_target *
+MY(object_p) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes; /* Raw exec header from file */
+ struct internal_exec exec; /* Cleaned-up exec header */
+ const bfd_target *target;
+
+ if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+#ifdef SWAP_MAGIC
+ exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
+#else
+ exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+#endif /* SWAP_MAGIC */
+
+ if (N_BADMAG (exec)) return 0;
+#ifdef MACHTYPE_OK
+ if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
+#endif
+
+ NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+
+#ifdef SWAP_MAGIC
+ /* swap_exec_header_in read in a_info with the wrong byte order */
+ exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
+#endif /* SWAP_MAGIC */
+
+ target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
+
+#ifdef ENTRY_CAN_BE_ZERO
+ /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
+ * means that it isn't obvious if EXEC_P should be set.
+ * All of the following must be true for an executable:
+ * There must be no relocations, the bfd can be neither an
+ * archive nor an archive element, and the file must be executable. */
+
+ if (exec.a_trsize + exec.a_drsize == 0
+ && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
+ {
+ struct stat buf;
+#ifndef S_IXUSR
+#define S_IXUSR 0100 /* Execute by owner. */
+#endif
+ if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
+ abfd->flags |= EXEC_P;
+ }
+#endif /* ENTRY_CAN_BE_ZERO */
+
+ return target;
+}
+#define MY_object_p MY(object_p)
+#endif
+
+
+#ifndef MY_mkobject
+
+static boolean MY(mkobject) PARAMS ((bfd *));
+
+static boolean
+MY(mkobject) (abfd)
+ bfd *abfd;
+{
+ if (NAME(aout,mkobject)(abfd) == false)
+ return false;
+#if 0 /* Sizes get set in set_sizes callback, later, after we know
+ the architecture and machine. */
+ adata(abfd).page_size = TARGET_PAGE_SIZE;
+ adata(abfd).segment_size = SEGMENT_SIZE;
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+#endif
+ return true;
+}
+#define MY_mkobject MY(mkobject)
+#endif
+
+#ifndef MY_bfd_copy_private_section_data
+
+/* Copy private section data. This actually does nothing with the
+ sections. It copies the subformat field. We copy it here, because
+ we need to know whether this is a QMAGIC file before we set the
+ section contents, and copy_private_bfd_data is not called until
+ after the section contents have been set. */
+
+static boolean MY_bfd_copy_private_section_data
+ PARAMS ((bfd *, asection *, bfd *, asection *));
+
+/*ARGSUSED*/
+static boolean
+MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
+ bfd *ibfd;
+ asection *isec;
+ bfd *obfd;
+ asection *osec;
+{
+ if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour
+ && bfd_get_flavour (obfd) == bfd_target_aout_flavour)
+ obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
+ return true;
+}
+
+#endif
+
+/* Write an object file.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+#ifndef MY_write_object_contents
+static boolean
+MY(write_object_contents) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+#if CHOOSE_RELOC_SIZE
+ CHOOSE_RELOC_SIZE(abfd);
+#else
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+#endif
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
+#define MY_write_object_contents MY(write_object_contents)
+#endif
+
+#ifndef MY_set_sizes
+
+static boolean MY(set_sizes) PARAMS ((bfd *));
+
+static boolean
+MY(set_sizes) (abfd)
+ bfd *abfd;
+{
+ adata(abfd).page_size = TARGET_PAGE_SIZE;
+ adata(abfd).segment_size = SEGMENT_SIZE;
+
+#ifdef ZMAGIC_DISK_BLOCK_SIZE
+ adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
+#else
+ adata(abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
+#endif
+
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+ return true;
+}
+#define MY_set_sizes MY(set_sizes)
+#endif
+
+#ifndef MY_exec_hdr_flags
+#define MY_exec_hdr_flags 0
+#endif
+
+#ifndef MY_backend_data
+
+#ifndef MY_zmagic_contiguous
+#define MY_zmagic_contiguous 0
+#endif
+#ifndef MY_text_includes_header
+#define MY_text_includes_header 0
+#endif
+#ifndef MY_entry_is_text_address
+#define MY_entry_is_text_address 0
+#endif
+#ifndef MY_exec_header_not_counted
+#define MY_exec_header_not_counted 0
+#endif
+#ifndef MY_add_dynamic_symbols
+#define MY_add_dynamic_symbols 0
+#endif
+#ifndef MY_add_one_symbol
+#define MY_add_one_symbol 0
+#endif
+#ifndef MY_link_dynamic_object
+#define MY_link_dynamic_object 0
+#endif
+#ifndef MY_write_dynamic_symbol
+#define MY_write_dynamic_symbol 0
+#endif
+#ifndef MY_check_dynamic_reloc
+#define MY_check_dynamic_reloc 0
+#endif
+#ifndef MY_finish_dynamic_link
+#define MY_finish_dynamic_link 0
+#endif
+
+static CONST struct aout_backend_data MY(backend_data) = {
+ MY_zmagic_contiguous,
+ MY_text_includes_header,
+ MY_entry_is_text_address,
+ MY_exec_hdr_flags,
+ 0, /* text vma? */
+ MY_set_sizes,
+ MY_exec_header_not_counted,
+ MY_add_dynamic_symbols,
+ MY_add_one_symbol,
+ MY_link_dynamic_object,
+ MY_write_dynamic_symbol,
+ MY_check_dynamic_reloc,
+ MY_finish_dynamic_link
+};
+#define MY_backend_data &MY(backend_data)
+#endif
+
+#ifndef MY_final_link_callback
+
+/* Callback for the final_link routine to set the section offsets. */
+
+static void MY_final_link_callback
+ PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+
+static void
+MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
+ bfd *abfd;
+ file_ptr *ptreloff;
+ file_ptr *pdreloff;
+ file_ptr *psymoff;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ *ptreloff = N_TRELOFF (*execp);
+ *pdreloff = N_DRELOFF (*execp);
+ *psymoff = N_SYMOFF (*execp);
+}
+
+#endif
+
+#ifndef MY_bfd_final_link
+
+/* Final link routine. We need to use a call back to get the correct
+ offsets in the output file. */
+
+static boolean MY_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *));
+
+static boolean
+MY_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
+}
+
+#endif
+
+/* We assume BFD generic archive files. */
+#ifndef MY_openr_next_archived_file
+#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
+#endif
+#ifndef MY_get_elt_at_index
+#define MY_get_elt_at_index _bfd_generic_get_elt_at_index
+#endif
+#ifndef MY_generic_stat_arch_elt
+#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#endif
+#ifndef MY_slurp_armap
+#define MY_slurp_armap bfd_slurp_bsd_armap
+#endif
+#ifndef MY_slurp_extended_name_table
+#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
+#endif
+#ifndef MY_construct_extended_name_table
+#define MY_construct_extended_name_table \
+ _bfd_archive_bsd_construct_extended_name_table
+#endif
+#ifndef MY_write_armap
+#define MY_write_armap bsd_write_armap
+#endif
+#ifndef MY_read_ar_hdr
+#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
+#endif
+#ifndef MY_truncate_arname
+#define MY_truncate_arname bfd_bsd_truncate_arname
+#endif
+#ifndef MY_update_armap_timestamp
+#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
+#endif
+
+/* No core file defined here -- configure in trad-core.c separately. */
+#ifndef MY_core_file_failing_command
+#define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
+#endif
+#ifndef MY_core_file_failing_signal
+#define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
+#endif
+#ifndef MY_core_file_matches_executable_p
+#define MY_core_file_matches_executable_p \
+ _bfd_nocore_core_file_matches_executable_p
+#endif
+#ifndef MY_core_file_p
+#define MY_core_file_p _bfd_dummy_target
+#endif
+
+#ifndef MY_bfd_debug_info_start
+#define MY_bfd_debug_info_start bfd_void
+#endif
+#ifndef MY_bfd_debug_info_end
+#define MY_bfd_debug_info_end bfd_void
+#endif
+#ifndef MY_bfd_debug_info_accumulate
+#define MY_bfd_debug_info_accumulate \
+ (void (*) PARAMS ((bfd*, struct sec *))) bfd_void
+#endif
+
+#ifndef MY_core_file_failing_command
+#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
+#endif
+#ifndef MY_core_file_failing_signal
+#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
+#endif
+#ifndef MY_core_file_matches_executable_p
+#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
+#endif
+#ifndef MY_set_section_contents
+#define MY_set_section_contents NAME(aout,set_section_contents)
+#endif
+#ifndef MY_get_section_contents
+#define MY_get_section_contents NAME(aout,get_section_contents)
+#endif
+#ifndef MY_get_section_contents_in_window
+#define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#endif
+#ifndef MY_new_section_hook
+#define MY_new_section_hook NAME(aout,new_section_hook)
+#endif
+#ifndef MY_get_symtab_upper_bound
+#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
+#endif
+#ifndef MY_get_symtab
+#define MY_get_symtab NAME(aout,get_symtab)
+#endif
+#ifndef MY_get_reloc_upper_bound
+#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
+#endif
+#ifndef MY_canonicalize_reloc
+#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
+#endif
+#ifndef MY_make_empty_symbol
+#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
+#endif
+#ifndef MY_print_symbol
+#define MY_print_symbol NAME(aout,print_symbol)
+#endif
+#ifndef MY_get_symbol_info
+#define MY_get_symbol_info NAME(aout,get_symbol_info)
+#endif
+#ifndef MY_get_lineno
+#define MY_get_lineno NAME(aout,get_lineno)
+#endif
+#ifndef MY_set_arch_mach
+#define MY_set_arch_mach NAME(aout,set_arch_mach)
+#endif
+#ifndef MY_find_nearest_line
+#define MY_find_nearest_line NAME(aout,find_nearest_line)
+#endif
+#ifndef MY_sizeof_headers
+#define MY_sizeof_headers NAME(aout,sizeof_headers)
+#endif
+#ifndef MY_bfd_get_relocated_section_contents
+#define MY_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#endif
+#ifndef MY_bfd_relax_section
+#define MY_bfd_relax_section bfd_generic_relax_section
+#endif
+#ifndef MY_bfd_gc_sections
+#define MY_bfd_gc_sections bfd_generic_gc_sections
+#endif
+#ifndef MY_bfd_reloc_type_lookup
+#define MY_bfd_reloc_type_lookup NAME(aout,reloc_type_lookup)
+#endif
+#ifndef MY_bfd_make_debug_symbol
+#define MY_bfd_make_debug_symbol 0
+#endif
+#ifndef MY_read_minisymbols
+#define MY_read_minisymbols NAME(aout,read_minisymbols)
+#endif
+#ifndef MY_minisymbol_to_symbol
+#define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
+#endif
+#ifndef MY_bfd_link_hash_table_create
+#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
+#endif
+#ifndef MY_bfd_link_add_symbols
+#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
+#endif
+#ifndef MY_bfd_link_split_section
+#define MY_bfd_link_split_section _bfd_generic_link_split_section
+#endif
+
+
+#ifndef MY_bfd_copy_private_bfd_data
+#define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
+#endif
+
+#ifndef MY_bfd_merge_private_bfd_data
+#define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#endif
+
+#ifndef MY_bfd_copy_private_symbol_data
+#define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#endif
+
+#ifndef MY_bfd_print_private_bfd_data
+#define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
+#endif
+
+#ifndef MY_bfd_set_private_flags
+#define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+#endif
+
+#ifndef MY_bfd_is_local_label_name
+#define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
+#endif
+
+#ifndef MY_bfd_free_cached_info
+#define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
+#endif
+
+#ifndef MY_close_and_cleanup
+#define MY_close_and_cleanup MY_bfd_free_cached_info
+#endif
+
+#ifndef MY_get_dynamic_symtab_upper_bound
+#define MY_get_dynamic_symtab_upper_bound \
+ _bfd_nodynamic_get_dynamic_symtab_upper_bound
+#endif
+#ifndef MY_canonicalize_dynamic_symtab
+#define MY_canonicalize_dynamic_symtab \
+ _bfd_nodynamic_canonicalize_dynamic_symtab
+#endif
+#ifndef MY_get_dynamic_reloc_upper_bound
+#define MY_get_dynamic_reloc_upper_bound \
+ _bfd_nodynamic_get_dynamic_reloc_upper_bound
+#endif
+#ifndef MY_canonicalize_dynamic_reloc
+#define MY_canonicalize_dynamic_reloc \
+ _bfd_nodynamic_canonicalize_dynamic_reloc
+#endif
+
+/* Aout symbols normally have leading underscores */
+#ifndef MY_symbol_leading_char
+#define MY_symbol_leading_char '_'
+#endif
+
+/* Aout archives normally use spaces for padding */
+#ifndef AR_PAD_CHAR
+#define AR_PAD_CHAR ' '
+#endif
+
+#ifndef MY_BFD_TARGET
+const bfd_target MY(vec) =
+{
+ TARGETNAME, /* name */
+ bfd_target_aout_flavour,
+#ifdef TARGET_IS_BIG_ENDIAN_P
+ BFD_ENDIAN_BIG, /* target byte order (big) */
+ BFD_ENDIAN_BIG, /* target headers byte order (big) */
+#else
+ BFD_ENDIAN_LITTLE, /* target byte order (little) */
+ BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
+#endif
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ MY_symbol_leading_char,
+ AR_PAD_CHAR, /* ar_pad_char */
+ 15, /* ar_max_namelen */
+#ifdef TARGET_IS_BIG_ENDIAN_P
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+#else
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+#endif
+ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, MY_core_file_p},
+ {bfd_false, MY_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (MY),
+ BFD_JUMP_TABLE_COPY (MY),
+ BFD_JUMP_TABLE_CORE (MY),
+ BFD_JUMP_TABLE_ARCHIVE (MY),
+ BFD_JUMP_TABLE_SYMBOLS (MY),
+ BFD_JUMP_TABLE_RELOCS (MY),
+ BFD_JUMP_TABLE_WRITE (MY),
+ BFD_JUMP_TABLE_LINK (MY),
+ BFD_JUMP_TABLE_DYNAMIC (MY),
+
+ (PTR) MY_backend_data,
+};
+#endif /* MY_BFD_TARGET */
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
new file mode 100644
index 00000000000..eae6cb754cb
--- /dev/null
+++ b/bfd/aout-tic30.c
@@ -0,0 +1,1065 @@
+/* BFD back-end for TMS320C30 a.out binaries.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#define TARGET_IS_BIG_ENDIAN_P
+#define N_HEADER_IN_TEXT(x) 1
+#define BYTES_IN_WORD 4
+#define TEXT_START_ADDR 1024
+#define TARGET_PAGE_SIZE 128
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_tic30
+#define ARCH_SIZE 32
+
+#define MY(OP) CAT(tic30_aout_,OP)
+#define TARGETNAME "a.out-tic30"
+#define NAME(x,y) CAT3(tic30_aout,_32_,y)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libaout.h"
+
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+
+static bfd_reloc_status_type tic30_aout_fix_16
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type tic30_aout_fix_32
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type tic30_aout_fix_pcrel_16
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *tic30_aout_reloc_howto
+ PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));
+static bfd_reloc_status_type tic30_aout_relocate_contents
+ PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
+static bfd_reloc_status_type tic30_aout_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma,
+ bfd_vma, bfd_vma));
+static const bfd_target *tic30_aout_object_p PARAMS ((bfd *));
+static boolean tic30_aout_write_object_contents PARAMS ((bfd *));
+static boolean tic30_aout_set_sizes PARAMS ((bfd *));
+
+#define MY_reloc_howto(BFD,REL,IN,EX,PC) tic30_aout_reloc_howto(BFD,REL,&IN,&EX,&PC)
+#define MY_final_link_relocate tic30_aout_final_link_relocate
+#define MY_object_p tic30_aout_object_p
+#define MY_mkobject NAME(aout,mkobject)
+#define MY_write_object_contents tic30_aout_write_object_contents
+#define MY_set_sizes tic30_aout_set_sizes
+
+#ifndef MY_exec_hdr_flags
+#define MY_exec_hdr_flags 1
+#endif
+
+#ifndef MY_backend_data
+
+#ifndef MY_zmagic_contiguous
+#define MY_zmagic_contiguous 0
+#endif
+#ifndef MY_text_includes_header
+#define MY_text_includes_header 0
+#endif
+#ifndef MY_entry_is_text_address
+#define MY_entry_is_text_address 0
+#endif
+#ifndef MY_exec_header_not_counted
+#define MY_exec_header_not_counted 1
+#endif
+#ifndef MY_add_dynamic_symbols
+#define MY_add_dynamic_symbols 0
+#endif
+#ifndef MY_add_one_symbol
+#define MY_add_one_symbol 0
+#endif
+#ifndef MY_link_dynamic_object
+#define MY_link_dynamic_object 0
+#endif
+#ifndef MY_write_dynamic_symbol
+#define MY_write_dynamic_symbol 0
+#endif
+#ifndef MY_check_dynamic_reloc
+#define MY_check_dynamic_reloc 0
+#endif
+#ifndef MY_finish_dynamic_link
+#define MY_finish_dynamic_link 0
+#endif
+
+static CONST struct aout_backend_data tic30_aout_backend_data =
+{
+ MY_zmagic_contiguous,
+ MY_text_includes_header,
+ MY_entry_is_text_address,
+ MY_exec_hdr_flags,
+ 0, /* text vma? */
+ MY_set_sizes,
+ MY_exec_header_not_counted,
+ MY_add_dynamic_symbols,
+ MY_add_one_symbol,
+ MY_link_dynamic_object,
+ MY_write_dynamic_symbol,
+ MY_check_dynamic_reloc,
+ MY_finish_dynamic_link
+};
+#define MY_backend_data &tic30_aout_backend_data
+#endif
+
+/* FIXME: This is wrong. aoutx.h should really only be included by
+ aout32.c. */
+
+#include "aoutx.h"
+
+/* This table lists the relocation types for the TMS320C30. There are
+ only a few relocations required, and all must be divided by 4 (>>
+ 2) to get the 32-bit addresses in the format the TMS320C30 likes
+ it. */
+reloc_howto_type tic30_aout_howto_table[] =
+{
+ {-1},
+ HOWTO (1, 2, 1, 16, false, 0, 0, tic30_aout_fix_16,
+ "16", false, 0x0000FFFF, 0x0000FFFF, false),
+ HOWTO (2, 2, 2, 24, false, 0, complain_overflow_bitfield, NULL,
+ "24", false, 0x00FFFFFF, 0x00FFFFFF, false),
+ HOWTO (3, 18, 3, 24, false, 0, complain_overflow_bitfield, NULL,
+ "LDP", false, 0x00FF0000, 0x000000FF, false),
+ HOWTO (4, 2, 4, 32, false, 0, complain_overflow_bitfield, tic30_aout_fix_32,
+ "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false),
+ HOWTO (5, 2, 1, 16, true, 0, complain_overflow_signed,
+ tic30_aout_fix_pcrel_16, "PCREL", true, 0x0000FFFF, 0x0000FFFF, true),
+ {-1},
+ {-1},
+ {-1},
+ {-1},
+ {-1}
+};
+
+extern reloc_howto_type *NAME (aout, reloc_type_lookup) ();
+
+reloc_howto_type *
+tic30_aout_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_8:
+ case BFD_RELOC_TIC30_LDP:
+ return &tic30_aout_howto_table[3];
+ case BFD_RELOC_16:
+ return &tic30_aout_howto_table[1];
+ case BFD_RELOC_24:
+ return &tic30_aout_howto_table[2];
+ case BFD_RELOC_16_PCREL:
+ return &tic30_aout_howto_table[5];
+ case BFD_RELOC_32:
+ return &tic30_aout_howto_table[4];
+ default:
+ return (reloc_howto_type *) NULL;
+ }
+}
+
+static reloc_howto_type *
+tic30_aout_reloc_howto (abfd, relocs, r_index, r_extern, r_pcrel)
+ bfd *abfd;
+ struct reloc_std_external *relocs;
+ int *r_index;
+ int *r_extern;
+ int *r_pcrel;
+{
+ unsigned int r_length;
+ unsigned int r_pcrel_done;
+ int index;
+
+ *r_pcrel = 0;
+ if (bfd_header_big_endian (abfd))
+ {
+ *r_index = ((relocs->r_index[0] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[2]);
+ *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
+ r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
+ r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) >> RELOC_STD_BITS_LENGTH_SH_BIG);
+ }
+ else
+ {
+ *r_index = ((relocs->r_index[2] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[0]);
+ *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
+ r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
+ r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
+ }
+ index = r_length + 4 * r_pcrel_done;
+ return tic30_aout_howto_table + index;
+}
+
+/* This function is used as a callback for 16-bit relocs. This is
+ required for relocations between segments. A line in aoutx.h
+ requires that any relocations for the data section should point to
+ the end of the aligned text section, plus an offset. By default,
+ this does not happen, therefore this function takes care of
+ that. */
+
+static bfd_reloc_status_type
+tic30_aout_fix_16 (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+
+ /* Make sure that the symbol's section is defined. */
+ if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
+ /* Get the size of the input section and turn it into the TMS320C30
+ 32-bit address format. */
+ relocation = (symbol->section->vma >> 2);
+ relocation += bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
+ bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
+ return bfd_reloc_ok;
+}
+
+/* This function does the same thing as tic30_aout_fix_16 except for 32
+ bit relocations. */
+
+static bfd_reloc_status_type
+tic30_aout_fix_32 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+
+ /* Make sure that the symbol's section is defined. */
+ if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
+ /* Get the size of the input section and turn it into the TMS320C30
+ 32-bit address format. */
+ relocation = (symbol->section->vma >> 2);
+ relocation += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ bfd_put_32 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
+ return bfd_reloc_ok;
+}
+
+/* This function is used to work out pc-relative offsets for the
+ TMS320C30. The data already placed by md_pcrel_from within gas is
+ useless for a relocation, so we just get the offset value and place
+ a version of this within the object code.
+ tic30_aout_final_link_relocate will then calculate the required
+ relocation to add on to the value in the object code. */
+
+static bfd_reloc_status_type
+tic30_aout_fix_pcrel_16 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation = 1;
+ bfd_byte offset_data = bfd_get_8 (abfd, (bfd_byte *) data + reloc_entry->address - 1);
+
+ /* The byte before the location of the fix contains bits 23-16 of
+ the pcrel instruction. Bit 21 is set for a delayed instruction
+ which requires on offset of 3 instead of 1. */
+ if (offset_data & 0x20)
+ relocation -= 3;
+ else
+ relocation -= 1;
+ bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
+ return bfd_reloc_ok;
+}
+
+/* These macros will get 24-bit values from the bfd definition.
+ Big-endian only. */
+#define bfd_getb_24(BFD,ADDR) (bfd_get_8(BFD,ADDR) << 16) | \
+ (bfd_get_8(BFD,ADDR+1) << 8) | \
+ (bfd_get_8(BFD,ADDR+2))
+
+#define bfd_putb_24(BFD,DATA,ADDR) bfd_put_8(BFD,(bfd_byte)((DATA >> 16) & 0xFF),ADDR); \
+ bfd_put_8(BFD,(bfd_byte)((DATA >> 8) & 0xFF),ADDR+1); \
+ bfd_put_8(BFD,(bfd_byte)(DATA & 0xFF),ADDR+2)
+
+/* Set parameters about this a.out file that are machine-dependent.
+ This routine is called from some_aout_object_p just before it returns. */
+
+static const bfd_target *
+tic30_aout_callback (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+ unsigned int arch_align_power;
+ unsigned long arch_align;
+
+ /* Calculate the file positions of the parts of a newly read aout header */
+ obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
+
+ /* The virtual memory addresses of the sections */
+ obj_textsec (abfd)->vma = N_TXTADDR (*execp);
+ obj_datasec (abfd)->vma = N_DATADDR (*execp);
+ obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
+
+ obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
+ obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
+ obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
+
+ /* The file offsets of the sections */
+ obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
+ obj_datasec (abfd)->filepos = N_DATOFF (*execp);
+
+ /* The file offsets of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
+ obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
+
+ /* The file offsets of the string table and symbol table. */
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+
+ /* Determine the architecture and machine type of the object file. */
+#ifdef SET_ARCH_MACH
+ SET_ARCH_MACH (abfd, *execp);
+#else
+ bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
+#endif
+
+ /* Now that we know the architecture, set the alignments of the
+ sections. This is normally done by NAME(aout,new_section_hook),
+ but when the initial sections were created the architecture had
+ not yet been set. However, for backward compatibility, we don't
+ set the alignment power any higher than as required by the size
+ of the section. */
+ arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
+ arch_align = 1 << arch_align_power;
+ if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
+ == obj_textsec (abfd)->_raw_size)
+ && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
+ == obj_datasec (abfd)->_raw_size)
+ && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
+ == obj_bsssec (abfd)->_raw_size))
+ {
+ obj_textsec (abfd)->alignment_power = arch_align_power;
+ obj_datasec (abfd)->alignment_power = arch_align_power;
+ obj_bsssec (abfd)->alignment_power = arch_align_power;
+ }
+ return abfd->xvec;
+}
+
+static bfd_reloc_status_type
+tic30_aout_final_link_relocate (howto, input_bfd, input_section, contents,
+ address, value, addend)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ bfd_vma address;
+ bfd_vma value;
+ bfd_vma addend;
+{
+ bfd_vma relocation;
+
+ if (address > input_section->_raw_size)
+ return bfd_reloc_outofrange;
+
+ relocation = value + addend;
+ if (howto->pc_relative)
+ {
+ relocation -= (input_section->output_section->vma + input_section->output_offset);
+ if (howto->pcrel_offset)
+ relocation -= address;
+ }
+ return tic30_aout_relocate_contents (howto, input_bfd, relocation,
+ contents + address);
+}
+
+bfd_reloc_status_type
+tic30_aout_relocate_contents (howto, input_bfd, relocation, location)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd_vma relocation;
+ bfd_byte *location;
+{
+ bfd_vma x;
+ boolean overflow;
+
+ if (howto->size < 0)
+ relocation = -relocation;
+
+ switch (howto->size)
+ {
+ default:
+ case 0:
+ abort ();
+ break;
+ case 1:
+ x = bfd_get_16 (input_bfd, location);
+ break;
+ case 2:
+ x = bfd_getb_24 (input_bfd, location);
+ break;
+ case 3:
+ x = bfd_get_8 (input_bfd, location);
+ break;
+ case 4:
+ x = bfd_get_32 (input_bfd, location);
+ break;
+ }
+ overflow = false;
+ if (howto->complain_on_overflow != complain_overflow_dont)
+ {
+ bfd_vma check;
+ bfd_signed_vma signed_check;
+ bfd_vma add;
+ bfd_signed_vma signed_add;
+
+ if (howto->rightshift == 0)
+ {
+ check = relocation;
+ signed_check = (bfd_signed_vma) relocation;
+ }
+ else
+ {
+ check = relocation >> howto->rightshift;
+ if ((bfd_signed_vma) relocation >= 0)
+ signed_check = check;
+ else
+ signed_check = (check | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->rightshift)));
+ }
+ add = x & howto->src_mask;
+ signed_add = add;
+ if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
+ signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
+ if (howto->bitpos == 0)
+ {
+ check += add;
+ signed_check += signed_add;
+ }
+ else
+ {
+ check += add >> howto->bitpos;
+ if (signed_add >= 0)
+ signed_check += add >> howto->bitpos;
+ else
+ signed_check += ((add >> howto->bitpos) | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->bitpos)));
+ }
+ switch (howto->complain_on_overflow)
+ {
+ case complain_overflow_signed:
+ {
+ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+ bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
+ if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
+ overflow = true;
+ }
+ break;
+ case complain_overflow_unsigned:
+ {
+ bfd_vma reloc_unsigned_max = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
+ if (check > reloc_unsigned_max)
+ overflow = true;
+ }
+ break;
+ case complain_overflow_bitfield:
+ {
+ bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
+ if ((check & ~reloc_bits) != 0 && (((bfd_vma) signed_check & ~reloc_bits) != (-1 & ~reloc_bits)))
+ overflow = true;
+ }
+ break;
+ default:
+ abort ();
+ }
+ }
+ relocation >>= (bfd_vma) howto->rightshift;
+ relocation <<= (bfd_vma) howto->bitpos;
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask));
+ switch (howto->size)
+ {
+ default:
+ case 0:
+ abort ();
+ break;
+ case 1:
+ bfd_put_16 (input_bfd, x, location);
+ break;
+ case 2:
+ bfd_putb_24 (input_bfd, x, location);
+ break;
+ case 3:
+ bfd_put_8 (input_bfd, x, location);
+ break;
+ case 4:
+ bfd_put_32 (input_bfd, x, location);
+ break;
+ }
+ return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
+}
+
+/* Finish up the reading of an a.out file header */
+
+static const bfd_target *
+tic30_aout_object_p (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes; /* Raw exec header from file */
+ struct internal_exec exec; /* Cleaned-up exec header */
+ const bfd_target *target;
+
+ if (bfd_read ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+#ifdef SWAP_MAGIC
+ exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
+#else
+ exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+#endif /* SWAP_MAGIC */
+
+ if (N_BADMAG (exec))
+ return 0;
+#ifdef MACHTYPE_OK
+ if (!(MACHTYPE_OK (N_MACHTYPE (exec))))
+ return 0;
+#endif
+
+ NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec);
+
+#ifdef SWAP_MAGIC
+ /* swap_exec_header_in read in a_info with the wrong byte order */
+ exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
+#endif /* SWAP_MAGIC */
+
+ target = NAME (aout, some_aout_object_p) (abfd, &exec, tic30_aout_callback);
+
+#ifdef ENTRY_CAN_BE_ZERO
+ /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
+ * means that it isn't obvious if EXEC_P should be set.
+ * All of the following must be true for an executable:
+ * There must be no relocations, the bfd can be neither an
+ * archive nor an archive element, and the file must be executable. */
+
+ if (exec.a_trsize + exec.a_drsize == 0
+ && bfd_get_format (abfd) == bfd_object && abfd->my_archive == NULL)
+ {
+ struct stat buf;
+#ifndef S_IXUSR
+#define S_IXUSR 0100 /* Execute by owner. */
+#endif
+ if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
+ abfd->flags |= EXEC_P;
+ }
+#endif /* ENTRY_CAN_BE_ZERO */
+
+ return target;
+}
+
+/* Copy private section data. This actually does nothing with the
+ sections. It copies the subformat field. We copy it here, because
+ we need to know whether this is a QMAGIC file before we set the
+ section contents, and copy_private_bfd_data is not called until
+ after the section contents have been set. */
+
+/*ARGSUSED */
+static boolean
+MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
+ bfd *ibfd;
+ asection *isec;
+ bfd *obfd;
+ asection *osec;
+{
+ if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
+ obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
+ return true;
+}
+
+/* Write an object file.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+static boolean
+tic30_aout_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+#if CHOOSE_RELOC_SIZE
+ CHOOSE_RELOC_SIZE (abfd);
+#else
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+#endif
+ {
+ bfd_size_type text_size; /* dummy vars */
+ file_ptr text_end;
+ if (adata (abfd).magic == undecided_magic)
+ NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
+
+ execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;
+ execp->a_entry = bfd_get_start_address (abfd);
+
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
+ NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes);
+
+ if (adata (abfd).exec_bytes_size > 0)
+ {
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+ if (bfd_write ((PTR) & exec_bytes, 1, adata (abfd).exec_bytes_size, abfd) != adata (abfd).exec_bytes_size)
+ return false;
+ }
+ /* Now write out reloc info, followed by syms and strings */
+
+ if (bfd_get_outsymbols (abfd) != (asymbol **) NULL
+ && bfd_get_symcount (abfd) != 0)
+ {
+ if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0)
+ return false;
+
+ if (!NAME (aout, write_syms) (abfd))
+ return false;
+ }
+
+ if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)
+ return false;
+ if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)
+ return false;
+ if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
+ return false;
+ }
+
+ return true;
+}
+
+static boolean
+tic30_aout_set_sizes (abfd)
+ bfd *abfd;
+{
+ adata (abfd).page_size = TARGET_PAGE_SIZE;
+
+#ifdef SEGMENT_SIZE
+ adata (abfd).segment_size = SEGMENT_SIZE;
+#else
+ adata (abfd).segment_size = TARGET_PAGE_SIZE;
+#endif
+
+#ifdef ZMAGIC_DISK_BLOCK_SIZE
+ adata (abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
+#else
+ adata (abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
+#endif
+
+ adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+
+ return true;
+}
+
+#ifndef MY_final_link_callback
+
+/* Callback for the final_link routine to set the section offsets. */
+
+static void MY_final_link_callback
+ PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+
+static void
+MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
+ bfd *abfd;
+ file_ptr *ptreloff;
+ file_ptr *pdreloff;
+ file_ptr *psymoff;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ *ptreloff = obj_datasec (abfd)->filepos + execp->a_data;
+ *pdreloff = *ptreloff + execp->a_trsize;
+ *psymoff = *pdreloff + execp->a_drsize;;
+}
+
+#endif
+
+#ifndef MY_bfd_final_link
+
+/* Final link routine. We need to use a call back to get the correct
+ offsets in the output file. */
+
+static boolean
+MY_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+ file_ptr pos;
+ bfd_vma vma = 0;
+ int pad;
+
+ /* Set the executable header size to 0, as we don't want one for an
+ output. */
+ adata (abfd).exec_bytes_size = 0;
+ pos = adata (abfd).exec_bytes_size;
+ /* Text. */
+ vma = info->create_object_symbols_section->vma;
+ pos += vma;
+ obj_textsec (abfd)->filepos = pos;
+ obj_textsec (abfd)->vma = vma;
+ obj_textsec (abfd)->user_set_vma = 1;
+ pos += obj_textsec (abfd)->_raw_size;
+ vma += obj_textsec (abfd)->_raw_size;
+
+ /* Data. */
+ if (abfd->flags & D_PAGED)
+ {
+ if (info->create_object_symbols_section->next->vma > 0)
+ obj_datasec (abfd)->vma = info->create_object_symbols_section->next->vma;
+ else
+ obj_datasec (abfd)->vma = BFD_ALIGN (vma, adata (abfd).segment_size);
+ }
+ else
+ {
+ obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
+ }
+ if (obj_datasec (abfd)->vma < vma)
+ {
+ obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
+ }
+ obj_datasec (abfd)->user_set_vma = 1;
+ vma = obj_datasec (abfd)->vma;
+ obj_datasec (abfd)->filepos = vma + adata (abfd).exec_bytes_size;
+ execp->a_text = vma - obj_textsec (abfd)->vma;
+ obj_textsec (abfd)->_raw_size = execp->a_text;
+
+ /* Since BSS follows data immediately, see if it needs alignment. */
+ vma += obj_datasec (abfd)->_raw_size;
+ pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma;
+ obj_datasec (abfd)->_raw_size += pad;
+ pos += obj_datasec (abfd)->_raw_size;
+ execp->a_data = obj_datasec (abfd)->_raw_size;
+
+ /* BSS. */
+ obj_bsssec (abfd)->vma = vma;
+ obj_bsssec (abfd)->user_set_vma = 1;
+
+ /* We are fully resized, so don't readjust in final_link. */
+ adata (abfd).magic = z_magic;
+
+ return NAME (aout, final_link) (abfd, info, MY_final_link_callback);
+}
+
+#endif
+
+enum machine_type
+tic30_aout_machine_type (arch, machine, unknown)
+ enum bfd_architecture arch;
+ unsigned long machine;
+ boolean *unknown;
+{
+ enum machine_type arch_flags;
+
+ arch_flags = M_UNKNOWN;
+ *unknown = true;
+
+ switch (arch)
+ {
+ case bfd_arch_tic30:
+ *unknown = false;
+ break;
+ default:
+ arch_flags = M_UNKNOWN;
+ }
+ if (arch_flags != M_UNKNOWN)
+ *unknown = false;
+ return arch_flags;
+}
+
+boolean
+tic30_aout_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ if (!bfd_default_set_arch_mach (abfd, arch, machine))
+ return false;
+ if (arch != bfd_arch_unknown)
+ {
+ boolean unknown;
+ tic30_aout_machine_type (arch, machine, &unknown);
+ if (unknown)
+ return false;
+ }
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ return (*aout_backend_info (abfd)->set_sizes) (abfd);
+}
+
+/* We assume BFD generic archive files. */
+#ifndef MY_openr_next_archived_file
+#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
+#endif
+#ifndef MY_get_elt_at_index
+#define MY_get_elt_at_index _bfd_generic_get_elt_at_index
+#endif
+#ifndef MY_generic_stat_arch_elt
+#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#endif
+#ifndef MY_slurp_armap
+#define MY_slurp_armap bfd_slurp_bsd_armap
+#endif
+#ifndef MY_slurp_extended_name_table
+#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
+#endif
+#ifndef MY_construct_extended_name_table
+#define MY_construct_extended_name_table \
+ _bfd_archive_bsd_construct_extended_name_table
+#endif
+#ifndef MY_write_armap
+#define MY_write_armap bsd_write_armap
+#endif
+#ifndef MY_read_ar_hdr
+#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
+#endif
+#ifndef MY_truncate_arname
+#define MY_truncate_arname bfd_bsd_truncate_arname
+#endif
+#ifndef MY_update_armap_timestamp
+#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
+#endif
+
+/* No core file defined here -- configure in trad-core.c separately. */
+#ifndef MY_core_file_failing_command
+#define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
+#endif
+#ifndef MY_core_file_failing_signal
+#define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
+#endif
+#ifndef MY_core_file_matches_executable_p
+#define MY_core_file_matches_executable_p \
+ _bfd_nocore_core_file_matches_executable_p
+#endif
+#ifndef MY_core_file_p
+#define MY_core_file_p _bfd_dummy_target
+#endif
+
+#ifndef MY_bfd_debug_info_start
+#define MY_bfd_debug_info_start bfd_void
+#endif
+#ifndef MY_bfd_debug_info_end
+#define MY_bfd_debug_info_end bfd_void
+#endif
+#ifndef MY_bfd_debug_info_accumulate
+#define MY_bfd_debug_info_accumulate \
+ (void (*) PARAMS ((bfd*, struct sec *))) bfd_void
+#endif
+
+#ifndef MY_core_file_failing_command
+#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
+#endif
+#ifndef MY_core_file_failing_signal
+#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
+#endif
+#ifndef MY_core_file_matches_executable_p
+#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
+#endif
+#ifndef MY_set_section_contents
+#define MY_set_section_contents NAME(aout,set_section_contents)
+#endif
+#ifndef MY_get_section_contents
+#define MY_get_section_contents aout_32_get_section_contents
+#endif
+#ifndef MY_get_section_contents_in_window
+#define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#endif
+#ifndef MY_new_section_hook
+#define MY_new_section_hook NAME(aout,new_section_hook)
+#endif
+#ifndef MY_get_symtab_upper_bound
+#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
+#endif
+#ifndef MY_get_symtab
+#define MY_get_symtab NAME(aout,get_symtab)
+#endif
+#ifndef MY_get_reloc_upper_bound
+#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
+#endif
+#ifndef MY_canonicalize_reloc
+#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
+#endif
+#ifndef MY_make_empty_symbol
+#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
+#endif
+#ifndef MY_print_symbol
+#define MY_print_symbol NAME(aout,print_symbol)
+#endif
+#ifndef MY_get_symbol_info
+#define MY_get_symbol_info NAME(aout,get_symbol_info)
+#endif
+#ifndef MY_get_lineno
+#define MY_get_lineno NAME(aout,get_lineno)
+#endif
+#ifndef MY_set_arch_mach
+#define MY_set_arch_mach tic30_aout_set_arch_mach
+#endif
+#ifndef MY_find_nearest_line
+#define MY_find_nearest_line NAME(aout,find_nearest_line)
+#endif
+#ifndef MY_sizeof_headers
+#define MY_sizeof_headers NAME(aout,sizeof_headers)
+#endif
+#ifndef MY_bfd_get_relocated_section_contents
+#define MY_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#endif
+#ifndef MY_bfd_relax_section
+#define MY_bfd_relax_section bfd_generic_relax_section
+#endif
+#ifndef MY_bfd_gc_sections
+#define MY_bfd_gc_sections bfd_generic_gc_sections
+#endif
+#ifndef MY_bfd_reloc_type_lookup
+#define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
+#endif
+#ifndef MY_bfd_make_debug_symbol
+#define MY_bfd_make_debug_symbol 0
+#endif
+#ifndef MY_read_minisymbols
+#define MY_read_minisymbols NAME(aout,read_minisymbols)
+#endif
+#ifndef MY_minisymbol_to_symbol
+#define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
+#endif
+#ifndef MY_bfd_link_hash_table_create
+#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
+#endif
+#ifndef MY_bfd_link_add_symbols
+#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
+#endif
+#ifndef MY_bfd_link_split_section
+#define MY_bfd_link_split_section _bfd_generic_link_split_section
+#endif
+
+
+#ifndef MY_bfd_copy_private_bfd_data
+#define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
+#endif
+
+#ifndef MY_bfd_merge_private_bfd_data
+#define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#endif
+
+#ifndef MY_bfd_copy_private_symbol_data
+#define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#endif
+
+#ifndef MY_bfd_print_private_bfd_data
+#define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
+#endif
+
+#ifndef MY_bfd_set_private_flags
+#define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+#endif
+
+#ifndef MY_bfd_is_local_label_name
+#define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
+#endif
+
+#ifndef MY_bfd_free_cached_info
+#define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
+#endif
+
+#ifndef MY_close_and_cleanup
+#define MY_close_and_cleanup MY_bfd_free_cached_info
+#endif
+
+#ifndef MY_get_dynamic_symtab_upper_bound
+#define MY_get_dynamic_symtab_upper_bound \
+ _bfd_nodynamic_get_dynamic_symtab_upper_bound
+#endif
+#ifndef MY_canonicalize_dynamic_symtab
+#define MY_canonicalize_dynamic_symtab \
+ _bfd_nodynamic_canonicalize_dynamic_symtab
+#endif
+#ifndef MY_get_dynamic_reloc_upper_bound
+#define MY_get_dynamic_reloc_upper_bound \
+ _bfd_nodynamic_get_dynamic_reloc_upper_bound
+#endif
+#ifndef MY_canonicalize_dynamic_reloc
+#define MY_canonicalize_dynamic_reloc \
+ _bfd_nodynamic_canonicalize_dynamic_reloc
+#endif
+
+/* Aout symbols normally have leading underscores */
+#ifndef MY_symbol_leading_char
+#define MY_symbol_leading_char '_'
+#endif
+
+/* Aout archives normally use spaces for padding */
+#ifndef AR_PAD_CHAR
+#define AR_PAD_CHAR ' '
+#endif
+
+#ifndef MY_BFD_TARGET
+const bfd_target tic30_aout_vec =
+{
+ TARGETNAME, /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_BIG, /* target byte order (big) */
+ BFD_ENDIAN_BIG, /* target headers byte order (big) */
+ (HAS_RELOC | /* object flags */
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ MY_symbol_leading_char,
+ AR_PAD_CHAR, /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, MY_core_file_p},
+ {bfd_false, MY_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (MY),
+ BFD_JUMP_TABLE_COPY (MY),
+ BFD_JUMP_TABLE_CORE (MY),
+ BFD_JUMP_TABLE_ARCHIVE (MY),
+ BFD_JUMP_TABLE_SYMBOLS (MY),
+ BFD_JUMP_TABLE_RELOCS (MY),
+ BFD_JUMP_TABLE_WRITE (MY),
+ BFD_JUMP_TABLE_LINK (MY),
+ BFD_JUMP_TABLE_DYNAMIC (MY),
+
+ (PTR) MY_backend_data,
+};
+#endif /* MY_BFD_TARGET */
diff --git a/bfd/aout0.c b/bfd/aout0.c
new file mode 100644
index 00000000000..5bc7ae0f67f
--- /dev/null
+++ b/bfd/aout0.c
@@ -0,0 +1,32 @@
+/* BFD backend for SunOS style a.out with flags set to 0
+ Copyright (C) 1990, 91, 92, 93, 1994 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGETNAME "a.out-zero-big"
+#define MY(OP) CAT(aout0_big_,OP)
+
+#include "bfd.h"
+
+#define MY_exec_hdr_flags 0
+
+#define MACHTYPE_OK(mtype) \
+ ((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020)
+
+/* Include the usual a.out support. */
+#include "aoutf1.h"
diff --git a/bfd/aout32.c b/bfd/aout32.c
new file mode 100644
index 00000000000..bfc40b46303
--- /dev/null
+++ b/bfd/aout32.c
@@ -0,0 +1,23 @@
+/* BFD back-end for 32-bit a.out files.
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 32
+
+#include "aoutx.h"
diff --git a/bfd/aout64.c b/bfd/aout64.c
new file mode 100644
index 00000000000..84036c885a2
--- /dev/null
+++ b/bfd/aout64.c
@@ -0,0 +1,31 @@
+/* BFD back-end for 64-bit a.out files.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 64
+
+/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
+#ifndef BMAGIC
+#define BMAGIC 0
+#endif
+#ifndef QMAGIC
+#define QMAGIC 0
+#endif
+
+#include "aoutx.h"
diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h
new file mode 100644
index 00000000000..fdf95b5b117
--- /dev/null
+++ b/bfd/aoutf1.h
@@ -0,0 +1,859 @@
+/* A.out "format 1" file handling code for BFD.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "aout/sun4.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+
+/* This is needed to reject a NewsOS file, e.g. in
+ gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
+ I needed to add M_UNKNOWN to recognize a 68000 object, so this will
+ probably no longer reject a NewsOS object. <ian@cygnus.com>. */
+#ifndef MACHTYPE_OK
+#define MACHTYPE_OK(mtype) \
+ (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
+ || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
+ && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
+#endif
+
+/*
+The file @code{aoutf1.h} contains the code for BFD's
+a.out back end. Control over the generated back end is given by these
+two preprocessor names:
+@table @code
+@item ARCH_SIZE
+This value should be either 32 or 64, depending upon the size of an
+int in the target format. It changes the sizes of the structs which
+perform the memory/disk mapping of structures.
+
+The 64 bit backend may only be used if the host compiler supports 64
+ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
+With this name defined, @emph{all} bfd operations are performed with 64bit
+arithmetic, not just those to a 64bit target.
+
+@item TARGETNAME
+The name put into the target vector.
+@item
+@end table
+
+*/
+
+/*SUPPRESS558*/
+/*SUPPRESS529*/
+
+#if ARCH_SIZE == 64
+#define sunos_set_arch_mach sunos_64_set_arch_mach
+#define sunos_write_object_contents aout_64_sunos4_write_object_contents
+#else
+#define sunos_set_arch_mach sunos_32_set_arch_mach
+#define sunos_write_object_contents aout_32_sunos4_write_object_contents
+#endif
+
+static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
+static void sunos_set_arch_mach PARAMS ((bfd *, int));
+static void choose_reloc_size PARAMS ((bfd *));
+static boolean sunos_write_object_contents PARAMS ((bfd *));
+static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));
+static char *sunos4_core_file_failing_command PARAMS ((bfd *));
+static int sunos4_core_file_failing_signal PARAMS ((bfd *));
+static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
+static boolean sunos4_set_sizes PARAMS ((bfd *));
+
+/* Merge backend data into the output file.
+ This is necessary on sparclet-aout where we want the resultant machine
+ number to be M_SPARCLET if any input file is M_SPARCLET. */
+
+#define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
+
+static boolean
+sunos_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd, *obfd;
+{
+ if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
+ || bfd_get_flavour (obfd) != bfd_target_aout_flavour)
+ return true;
+
+ if (bfd_get_arch (obfd) == bfd_arch_sparc)
+ {
+ if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
+ bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
+ }
+
+ return true;
+}
+
+/* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,
+ depending upon ARCH_SIZE. */
+
+static void
+sunos_set_arch_mach (abfd, machtype)
+ bfd *abfd;
+ int machtype;
+{
+ /* Determine the architecture and machine type of the object file. */
+ enum bfd_architecture arch;
+ long machine;
+ switch (machtype)
+ {
+
+ case M_UNKNOWN:
+ /* Some Sun3s make magic numbers without cpu types in them, so
+ we'll default to the 68000. */
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68000;
+ break;
+
+ case M_68010:
+ case M_HP200:
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68010;
+ break;
+
+ case M_68020:
+ case M_HP300:
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68020;
+ break;
+
+ case M_SPARC:
+ arch = bfd_arch_sparc;
+ machine = 0;
+ break;
+
+ case M_SPARCLET:
+ arch = bfd_arch_sparc;
+ machine = bfd_mach_sparc_sparclet;
+ break;
+
+ case M_SPARCLITE_LE:
+ arch = bfd_arch_sparc;
+ machine = bfd_mach_sparc_sparclite_le;
+ break;
+
+ case M_386:
+ case M_386_DYNIX:
+ arch = bfd_arch_i386;
+ machine = 0;
+ break;
+
+ case M_29K:
+ arch = bfd_arch_a29k;
+ machine = 0;
+ break;
+
+ case M_HPUX:
+ arch = bfd_arch_m68k;
+ machine = 0;
+ break;
+
+ default:
+ arch = bfd_arch_obscure;
+ machine = 0;
+ break;
+ }
+ bfd_set_arch_mach (abfd, arch, machine);
+}
+
+#define SET_ARCH_MACH(ABFD, EXEC) \
+ NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
+ choose_reloc_size(ABFD);
+
+/* Determine the size of a relocation entry, based on the architecture */
+static void
+choose_reloc_size (abfd)
+ bfd *abfd;
+{
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_sparc:
+ case bfd_arch_a29k:
+ obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
+ break;
+ default:
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ break;
+ }
+}
+
+/* Write an object file in SunOS format. Section contents have
+ already been written. We write the file header, symbols, and
+ relocation. The real name of this function is either
+ aout_64_sunos4_write_object_contents or
+ aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */
+
+static boolean
+sunos_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ /* Magic number, maestro, please! */
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_m68k:
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_m68000:
+ N_SET_MACHTYPE (*execp, M_UNKNOWN);
+ break;
+ case bfd_mach_m68010:
+ N_SET_MACHTYPE (*execp, M_68010);
+ break;
+ default:
+ case bfd_mach_m68020:
+ N_SET_MACHTYPE (*execp, M_68020);
+ break;
+ }
+ break;
+ case bfd_arch_sparc:
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_sparc_sparclet:
+ N_SET_MACHTYPE (*execp, M_SPARCLET);
+ break;
+ case bfd_mach_sparc_sparclite_le:
+ N_SET_MACHTYPE (*execp, M_SPARCLITE_LE);
+ break;
+ default:
+ N_SET_MACHTYPE (*execp, M_SPARC);
+ break;
+ }
+ break;
+ case bfd_arch_i386:
+ N_SET_MACHTYPE (*execp, M_386);
+ break;
+ case bfd_arch_a29k:
+ N_SET_MACHTYPE (*execp, M_29K);
+ break;
+ default:
+ N_SET_MACHTYPE (*execp, M_UNKNOWN);
+ }
+
+ choose_reloc_size (abfd);
+
+ N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
+
+ N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
+
+ WRITE_HEADERS (abfd, execp);
+
+ return true;
+}
+
+/* core files */
+
+#define CORE_MAGIC 0x080456
+#define CORE_NAMELEN 16
+
+/* The core structure is taken from the Sun documentation.
+ Unfortunately, they don't document the FPA structure, or at least I
+ can't find it easily. Fortunately the core header contains its own
+ length. So this shouldn't cause problems, except for c_ucode, which
+ so far we don't use but is easy to find with a little arithmetic. */
+
+/* But the reg structure can be gotten from the SPARC processor handbook.
+ This really should be in a GNU include file though so that gdb can use
+ the same info. */
+struct regs
+{
+ int r_psr;
+ int r_pc;
+ int r_npc;
+ int r_y;
+ int r_g1;
+ int r_g2;
+ int r_g3;
+ int r_g4;
+ int r_g5;
+ int r_g6;
+ int r_g7;
+ int r_o0;
+ int r_o1;
+ int r_o2;
+ int r_o3;
+ int r_o4;
+ int r_o5;
+ int r_o6;
+ int r_o7;
+};
+
+/* Taken from Sun documentation: */
+
+/* FIXME: It's worse than we expect. This struct contains TWO substructs
+ neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
+ even portably access the stuff in between! */
+
+struct external_sparc_core
+ {
+ int c_magic; /* Corefile magic number */
+ int c_len; /* Sizeof (struct core) */
+#define SPARC_CORE_LEN 432
+ int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
+ struct external_exec c_aouthdr; /* A.out header */
+ int c_signo; /* Killing signal, if any */
+ int c_tsize; /* Text size (bytes) */
+ int c_dsize; /* Data size (bytes) */
+ int c_ssize; /* Stack size (bytes) */
+ char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
+ double fp_stuff[1]; /* external FPU state (size unknown by us) */
+ /* The type "double" is critical here, for alignment.
+ SunOS declares a struct here, but the struct's alignment
+ is double since it contains doubles. */
+ int c_ucode; /* Exception no. from u_code */
+ /* (this member is not accessible by name since we don't
+ portably know the size of fp_stuff.) */
+ };
+
+/* Core files generated by the BCP (the part of Solaris which allows
+ it to run SunOS4 a.out files). */
+struct external_solaris_bcp_core
+ {
+ int c_magic; /* Corefile magic number */
+ int c_len; /* Sizeof (struct core) */
+#define SOLARIS_BCP_CORE_LEN 456
+ int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
+ int c_exdata_vp; /* exdata structure */
+ int c_exdata_tsize;
+ int c_exdata_dsize;
+ int c_exdata_bsize;
+ int c_exdata_lsize;
+ int c_exdata_nshlibs;
+ short c_exdata_mach;
+ short c_exdata_mag;
+ int c_exdata_toffset;
+ int c_exdata_doffset;
+ int c_exdata_loffset;
+ int c_exdata_txtorg;
+ int c_exdata_datorg;
+ int c_exdata_entloc;
+ int c_signo; /* Killing signal, if any */
+ int c_tsize; /* Text size (bytes) */
+ int c_dsize; /* Data size (bytes) */
+ int c_ssize; /* Stack size (bytes) */
+ char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
+ double fp_stuff[1]; /* external FPU state (size unknown by us) */
+ /* The type "double" is critical here, for alignment.
+ SunOS declares a struct here, but the struct's alignment
+ is double since it contains doubles. */
+ int c_ucode; /* Exception no. from u_code */
+ /* (this member is not accessible by name since we don't
+ portably know the size of fp_stuff.) */
+ };
+
+struct external_sun3_core
+ {
+ int c_magic; /* Corefile magic number */
+ int c_len; /* Sizeof (struct core) */
+#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
+ int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
+ struct external_exec c_aouthdr; /* A.out header */
+ int c_signo; /* Killing signal, if any */
+ int c_tsize; /* Text size (bytes) */
+ int c_dsize; /* Data size (bytes) */
+ int c_ssize; /* Stack size (bytes) */
+ char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
+ double fp_stuff[1]; /* external FPU state (size unknown by us) */
+ /* The type "double" is critical here, for alignment.
+ SunOS declares a struct here, but the struct's alignment
+ is double since it contains doubles. */
+ int c_ucode; /* Exception no. from u_code */
+ /* (this member is not accessible by name since we don't
+ portably know the size of fp_stuff.) */
+ };
+
+struct internal_sunos_core
+ {
+ int c_magic; /* Corefile magic number */
+ int c_len; /* Sizeof (struct core) */
+ long c_regs_pos; /* file offset of General purpose registers */
+ int c_regs_size; /* size of General purpose registers */
+ struct internal_exec c_aouthdr; /* A.out header */
+ int c_signo; /* Killing signal, if any */
+ int c_tsize; /* Text size (bytes) */
+ int c_dsize; /* Data size (bytes) */
+ bfd_vma c_data_addr; /* Data start (address) */
+ int c_ssize; /* Stack size (bytes) */
+ bfd_vma c_stacktop; /* Stack top (address) */
+ char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
+ long fp_stuff_pos; /* file offset of external FPU state (regs) */
+ int fp_stuff_size; /* Size of it */
+ int c_ucode; /* Exception no. from u_code */
+ };
+
+static void swapcore_sun3
+ PARAMS ((bfd *, char *, struct internal_sunos_core *));
+static void swapcore_sparc
+ PARAMS ((bfd *, char *, struct internal_sunos_core *));
+static void swapcore_solaris_bcp
+ PARAMS ((bfd *, char *, struct internal_sunos_core *));
+
+/* byte-swap in the Sun-3 core structure */
+static void
+swapcore_sun3 (abfd, ext, intcore)
+ bfd *abfd;
+ char *ext;
+ struct internal_sunos_core *intcore;
+{
+ struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
+
+ intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
+ intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
+ intcore->c_regs_size = sizeof (extcore->c_regs);
+#if ARCH_SIZE == 64
+ aout_64_swap_exec_header_in
+#else
+ aout_32_swap_exec_header_in
+#endif
+ (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
+ intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
+ intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
+ intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
+ intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
+ intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
+ /* FP stuff takes up whole rest of struct, except c_ucode. */
+ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
+ (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
+ /* Ucode is the last thing in the struct -- just before the end */
+ intcore->c_ucode =
+ bfd_h_get_32 (abfd,
+ intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_stacktop = 0x0E000000; /* By experimentation */
+}
+
+
+/* byte-swap in the Sparc core structure */
+static void
+swapcore_sparc (abfd, ext, intcore)
+ bfd *abfd;
+ char *ext;
+ struct internal_sunos_core *intcore;
+{
+ struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
+
+ intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
+ intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
+ intcore->c_regs_size = sizeof (extcore->c_regs);
+#if ARCH_SIZE == 64
+ aout_64_swap_exec_header_in
+#else
+ aout_32_swap_exec_header_in
+#endif
+ (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
+ intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
+ intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
+ intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
+ intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
+ intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
+ /* FP stuff takes up whole rest of struct, except c_ucode. */
+ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
+ (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
+ /* Ucode is the last thing in the struct -- just before the end */
+ intcore->c_ucode =
+ bfd_h_get_32 (abfd,
+ intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+
+ /* Supposedly the user stack grows downward from the bottom of kernel memory.
+ Presuming that this remains true, this definition will work. */
+ /* Now sun has provided us with another challenge. The value is different
+ for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
+ the other based on the current value of the stack pointer. This
+ loses (a) if the stack pointer has been clobbered, or (b) if the stack
+ is larger than 128 megabytes.
+
+ It's times like these you're glad they're switching to ELF.
+
+ Note that using include files or nlist on /vmunix would be wrong,
+ because we want the value for this core file, no matter what kind of
+ machine we were compiled on or are running on. */
+#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
+#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
+ {
+ bfd_vma sp = bfd_h_get_32
+ (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+ if (sp < SPARC_USRSTACK_SPARC10)
+ intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
+ else
+ intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
+ }
+}
+
+/* byte-swap in the Solaris BCP core structure */
+static void
+swapcore_solaris_bcp (abfd, ext, intcore)
+ bfd *abfd;
+ char *ext;
+ struct internal_sunos_core *intcore;
+{
+ struct external_solaris_bcp_core *extcore =
+ (struct external_solaris_bcp_core *) ext;
+
+ intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
+ intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
+ intcore->c_regs_size = sizeof (extcore->c_regs);
+
+ /* The Solaris BCP exdata structure does not contain an a_syms field,
+ so we are unable to synthesize an internal exec header.
+ Luckily we are able to figure out the start address of the data section,
+ which is the only thing needed from the internal exec header,
+ from the exdata structure.
+
+ As of Solaris 2.3, BCP core files for statically linked executables
+ are buggy. The exdata structure is not properly filled in, and
+ the data section is written from address zero instead of the data
+ start address. */
+ memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
+ intcore->c_data_addr =
+ bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
+ intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
+ intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
+ intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
+ intcore->fp_stuff_pos =
+ (long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
+ /* FP stuff takes up whole rest of struct, except c_ucode. */
+ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
+ (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
+ /* Ucode is the last thing in the struct -- just before the end */
+ intcore->c_ucode =
+ bfd_h_get_32 (abfd,
+ intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+
+ /* Supposedly the user stack grows downward from the bottom of kernel memory.
+ Presuming that this remains true, this definition will work. */
+ /* Now sun has provided us with another challenge. The value is different
+ for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
+ the other based on the current value of the stack pointer. This
+ loses (a) if the stack pointer has been clobbered, or (b) if the stack
+ is larger than 128 megabytes.
+
+ It's times like these you're glad they're switching to ELF.
+
+ Note that using include files or nlist on /vmunix would be wrong,
+ because we want the value for this core file, no matter what kind of
+ machine we were compiled on or are running on. */
+#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
+#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
+ {
+ bfd_vma sp = bfd_h_get_32
+ (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+ if (sp < SPARC_USRSTACK_SPARC10)
+ intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
+ else
+ intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
+ }
+}
+
+/* need this cast because ptr is really void * */
+#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
+#define core_datasec(bfd) (core_hdr(bfd)->data_section)
+#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
+#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
+#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
+
+/* These are stored in the bfd's tdata */
+struct sun_core_struct
+{
+ struct internal_sunos_core *hdr; /* core file header */
+ asection *data_section;
+ asection *stack_section;
+ asection *reg_section;
+ asection *reg2_section;
+};
+
+static const bfd_target *
+sunos4_core_file_p (abfd)
+ bfd *abfd;
+{
+ unsigned char longbuf[4]; /* Raw bytes of various header fields */
+ bfd_size_type core_size;
+ unsigned long core_mag;
+ struct internal_sunos_core *core;
+ char *extcore;
+ struct mergem
+ {
+ struct sun_core_struct suncoredata;
+ struct internal_sunos_core internal_sunos_core;
+ char external_core[1];
+ }
+ *mergem;
+
+ if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
+ sizeof (longbuf))
+ return 0;
+ core_mag = bfd_h_get_32 (abfd, longbuf);
+
+ if (core_mag != CORE_MAGIC)
+ return 0;
+
+ /* SunOS core headers can vary in length; second word is size; */
+ if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
+ sizeof (longbuf))
+ return 0;
+ core_size = bfd_h_get_32 (abfd, longbuf);
+ /* Sanity check */
+ if (core_size > 20000)
+ return 0;
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ return 0;
+
+ mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
+ if (mergem == NULL)
+ return 0;
+
+ extcore = mergem->external_core;
+
+ if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
+ {
+ bfd_release (abfd, (char *) mergem);
+ return 0;
+ }
+
+ /* Validate that it's a core file we know how to handle, due to sun
+ botching the positioning of registers and other fields in a machine
+ dependent way. */
+ core = &mergem->internal_sunos_core;
+ switch (core_size)
+ {
+ case SPARC_CORE_LEN:
+ swapcore_sparc (abfd, extcore, core);
+ break;
+ case SUN3_CORE_LEN:
+ swapcore_sun3 (abfd, extcore, core);
+ break;
+ case SOLARIS_BCP_CORE_LEN:
+ swapcore_solaris_bcp (abfd, extcore, core);
+ break;
+ default:
+ bfd_set_error (bfd_error_system_call); /* FIXME */
+ bfd_release (abfd, (char *) mergem);
+ return 0;
+ }
+
+ abfd->tdata.sun_core_data = &mergem->suncoredata;
+ abfd->tdata.sun_core_data->hdr = core;
+
+ /* create the sections. This is raunchy, but bfd_close wants to reclaim
+ them */
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_stacksec (abfd) == NULL)
+ {
+ loser:
+ bfd_release (abfd, (char *) mergem);
+ return 0;
+ }
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_datasec (abfd) == NULL)
+ {
+ loser1:
+ bfd_release (abfd, core_stacksec (abfd));
+ goto loser;
+ }
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_regsec (abfd) == NULL)
+ {
+ loser2:
+ bfd_release (abfd, core_datasec (abfd));
+ goto loser1;
+ }
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_reg2sec (abfd) == NULL)
+ {
+ bfd_release (abfd, core_regsec (abfd));
+ goto loser2;
+ }
+
+ core_stacksec (abfd)->name = ".stack";
+ core_datasec (abfd)->name = ".data";
+ core_regsec (abfd)->name = ".reg";
+ core_reg2sec (abfd)->name = ".reg2";
+
+ core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
+ core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
+
+ core_stacksec (abfd)->_raw_size = core->c_ssize;
+ core_datasec (abfd)->_raw_size = core->c_dsize;
+ core_regsec (abfd)->_raw_size = core->c_regs_size;
+ core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
+
+ core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
+ core_datasec (abfd)->vma = core->c_data_addr;
+ core_regsec (abfd)->vma = 0;
+ core_reg2sec (abfd)->vma = 0;
+
+ core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
+ core_datasec (abfd)->filepos = core->c_len;
+ /* We'll access the regs afresh in the core file, like any section: */
+ core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
+ core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;
+
+ /* Align to word at least */
+ core_stacksec (abfd)->alignment_power = 2;
+ core_datasec (abfd)->alignment_power = 2;
+ core_regsec (abfd)->alignment_power = 2;
+ core_reg2sec (abfd)->alignment_power = 2;
+
+ abfd->sections = core_stacksec (abfd);
+ core_stacksec (abfd)->next = core_datasec (abfd);
+ core_datasec (abfd)->next = core_regsec (abfd);
+ core_regsec (abfd)->next = core_reg2sec (abfd);
+
+ abfd->section_count = 4;
+
+ return abfd->xvec;
+}
+
+static char *
+sunos4_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_hdr (abfd)->hdr->c_cmdname;
+}
+
+static int
+sunos4_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_hdr (abfd)->hdr->c_signo;
+}
+
+static boolean
+sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd;
+ bfd *exec_bfd;
+{
+ if (core_bfd->xvec != exec_bfd->xvec)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return false;
+ }
+
+ /* Solaris core files do not include an aouthdr. */
+ if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
+ return true;
+
+ return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
+ (char *) exec_hdr (exec_bfd),
+ sizeof (struct internal_exec)) == 0) ? true : false;
+}
+
+#define MY_set_sizes sunos4_set_sizes
+static boolean
+sunos4_set_sizes (abfd)
+ bfd *abfd;
+{
+ switch (bfd_get_arch (abfd))
+ {
+ default:
+ return false;
+ case bfd_arch_sparc:
+ adata (abfd).page_size = 0x2000;
+ adata (abfd).segment_size = 0x2000;
+ adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+ return true;
+ case bfd_arch_m68k:
+ adata (abfd).page_size = 0x2000;
+ adata (abfd).segment_size = 0x20000;
+ adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+ return true;
+ }
+}
+
+/* We default to setting the toolversion field to 1, as is required by
+ SunOS. */
+#ifndef MY_exec_hdr_flags
+#define MY_exec_hdr_flags 1
+#endif
+
+#ifndef MY_entry_is_text_address
+#define MY_entry_is_text_address 0
+#endif
+#ifndef MY_add_dynamic_symbols
+#define MY_add_dynamic_symbols 0
+#endif
+#ifndef MY_add_one_symbol
+#define MY_add_one_symbol 0
+#endif
+#ifndef MY_link_dynamic_object
+#define MY_link_dynamic_object 0
+#endif
+#ifndef MY_write_dynamic_symbol
+#define MY_write_dynamic_symbol 0
+#endif
+#ifndef MY_check_dynamic_reloc
+#define MY_check_dynamic_reloc 0
+#endif
+#ifndef MY_finish_dynamic_link
+#define MY_finish_dynamic_link 0
+#endif
+
+static CONST struct aout_backend_data sunos4_aout_backend =
+{
+ 0, /* zmagic files are not contiguous */
+ 1, /* text includes header */
+ MY_entry_is_text_address,
+ MY_exec_hdr_flags,
+ 0, /* default text vma */
+ sunos4_set_sizes,
+ 0, /* header is counted in zmagic text */
+ MY_add_dynamic_symbols,
+ MY_add_one_symbol,
+ MY_link_dynamic_object,
+ MY_write_dynamic_symbol,
+ MY_check_dynamic_reloc,
+ MY_finish_dynamic_link
+};
+
+#define MY_core_file_failing_command sunos4_core_file_failing_command
+#define MY_core_file_failing_signal sunos4_core_file_failing_signal
+#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
+
+#define MY_bfd_debug_info_start bfd_void
+#define MY_bfd_debug_info_end bfd_void
+#define MY_bfd_debug_info_accumulate \
+ (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
+#define MY_core_file_p sunos4_core_file_p
+#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
+#define MY_backend_data &sunos4_aout_backend
+
+#ifndef TARGET_IS_LITTLE_ENDIAN_P
+#define TARGET_IS_BIG_ENDIAN_P
+#endif
+
+#include "aout-target.h"
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
new file mode 100644
index 00000000000..2704eecccfe
--- /dev/null
+++ b/bfd/aoutx.h
@@ -0,0 +1,5706 @@
+/* BFD semi-generic back-end for a.out binaries.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ a.out backends
+
+
+DESCRIPTION
+
+ BFD supports a number of different flavours of a.out format,
+ though the major differences are only the sizes of the
+ structures on disk, and the shape of the relocation
+ information.
+
+ The support is split into a basic support file @file{aoutx.h}
+ and other files which derive functions from the base. One
+ derivation file is @file{aoutf1.h} (for a.out flavour 1), and
+ adds to the basic a.out functions support for sun3, sun4, 386
+ and 29k a.out files, to create a target jump vector for a
+ specific target.
+
+ This information is further split out into more specific files
+ for each machine, including @file{sunos.c} for sun3 and sun4,
+ @file{newsos3.c} for the Sony NEWS, and @file{demo64.c} for a
+ demonstration of a 64 bit a.out format.
+
+ The base file @file{aoutx.h} defines general mechanisms for
+ reading and writing records to and from disk and various
+ other methods which BFD requires. It is included by
+ @file{aout32.c} and @file{aout64.c} to form the names
+ <<aout_32_swap_exec_header_in>>, <<aout_64_swap_exec_header_in>>, etc.
+
+ As an example, this is what goes on to make the back end for a
+ sun4, from @file{aout32.c}:
+
+| #define ARCH_SIZE 32
+| #include "aoutx.h"
+
+ Which exports names:
+
+| ...
+| aout_32_canonicalize_reloc
+| aout_32_find_nearest_line
+| aout_32_get_lineno
+| aout_32_get_reloc_upper_bound
+| ...
+
+ from @file{sunos.c}:
+
+| #define TARGET_NAME "a.out-sunos-big"
+| #define VECNAME sunos_big_vec
+| #include "aoutf1.h"
+
+ requires all the names from @file{aout32.c}, and produces the jump vector
+
+| sunos_big_vec
+
+ The file @file{host-aout.c} is a special case. It is for a large set
+ of hosts that use ``more or less standard'' a.out files, and
+ for which cross-debugging is not interesting. It uses the
+ standard 32-bit a.out support routines, but determines the
+ file offsets and addresses of the text, data, and BSS
+ sections, the machine architecture and machine type, and the
+ entry point address, in a host-dependent manner. Once these
+ values have been determined, generic code is used to handle
+ the object file.
+
+ When porting it to run on a new system, you must supply:
+
+| HOST_PAGE_SIZE
+| HOST_SEGMENT_SIZE
+| HOST_MACHINE_ARCH (optional)
+| HOST_MACHINE_MACHINE (optional)
+| HOST_TEXT_START_ADDR
+| HOST_STACK_END_ADDR
+
+ in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These
+ values, plus the structures and macros defined in @file{a.out.h} on
+ your host system, will produce a BFD target that will access
+ ordinary a.out files on your host. To configure a new machine
+ to use @file{host-aout.c}, specify:
+
+| TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
+| TDEPFILES= host-aout.o trad-core.o
+
+ in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
+ to use the
+ @file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
+ configuration is selected.
+
+*/
+
+/* Some assumptions:
+ * Any BFD with D_PAGED set is ZMAGIC, and vice versa.
+ Doesn't matter what the setting of WP_TEXT is on output, but it'll
+ get set on input.
+ * Any BFD with D_PAGED clear and WP_TEXT set is NMAGIC.
+ * Any BFD with both flags clear is OMAGIC.
+ (Just want to make these explicit, so the conditions tested in this
+ file make sense if you're more familiar with a.out than with BFD.) */
+
+#define KEEPIT udata.i
+
+#include <ctype.h>
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+
+#include "libaout.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+
+static boolean aout_get_external_symbols PARAMS ((bfd *));
+static boolean translate_from_native_sym_flags
+ PARAMS ((bfd *, aout_symbol_type *));
+static boolean translate_to_native_sym_flags
+ PARAMS ((bfd *, asymbol *, struct external_nlist *));
+static void adjust_o_magic PARAMS ((bfd *, struct internal_exec *));
+static void adjust_z_magic PARAMS ((bfd *, struct internal_exec *));
+static void adjust_n_magic PARAMS ((bfd *, struct internal_exec *));
+
+/*
+SUBSECTION
+ Relocations
+
+DESCRIPTION
+ The file @file{aoutx.h} provides for both the @emph{standard}
+ and @emph{extended} forms of a.out relocation records.
+
+ The standard records contain only an
+ address, a symbol index, and a type field. The extended records
+ (used on 29ks and sparcs) also have a full integer for an
+ addend.
+
+*/
+#ifndef CTOR_TABLE_RELOC_HOWTO
+#define CTOR_TABLE_RELOC_IDX 2
+#define CTOR_TABLE_RELOC_HOWTO(BFD) ((obj_reloc_entry_size(BFD) == RELOC_EXT_SIZE \
+ ? howto_table_ext : howto_table_std) \
+ + CTOR_TABLE_RELOC_IDX)
+#endif
+
+#ifndef MY_swap_std_reloc_in
+#define MY_swap_std_reloc_in NAME(aout,swap_std_reloc_in)
+#endif
+
+#ifndef MY_swap_std_reloc_out
+#define MY_swap_std_reloc_out NAME(aout,swap_std_reloc_out)
+#endif
+
+#ifndef MY_final_link_relocate
+#define MY_final_link_relocate _bfd_final_link_relocate
+#endif
+
+#ifndef MY_relocate_contents
+#define MY_relocate_contents _bfd_relocate_contents
+#endif
+
+#define howto_table_ext NAME(aout,ext_howto_table)
+#define howto_table_std NAME(aout,std_howto_table)
+
+reloc_howto_type howto_table_ext[] =
+{
+ /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
+ HOWTO(RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", false, 0,0x000000ff, false),
+ HOWTO(RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", false, 0,0x0000ffff, false),
+ HOWTO(RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", false, 0,0xffffffff, false),
+ HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, complain_overflow_signed,0,"DISP8", false, 0,0x000000ff, false),
+ HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, complain_overflow_signed,0,"DISP16", false, 0,0x0000ffff, false),
+ HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, complain_overflow_signed,0,"DISP32", false, 0,0xffffffff, false),
+ HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, complain_overflow_signed,0,"WDISP30", false, 0,0x3fffffff, false),
+ HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, complain_overflow_signed,0,"WDISP22", false, 0,0x003fffff, false),
+ HOWTO(RELOC_HI22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"HI22", false, 0,0x003fffff, false),
+ HOWTO(RELOC_22, 0, 2, 22, false, 0, complain_overflow_bitfield,0,"22", false, 0,0x003fffff, false),
+ HOWTO(RELOC_13, 0, 2, 13, false, 0, complain_overflow_bitfield,0,"13", false, 0,0x00001fff, false),
+ HOWTO(RELOC_LO10, 0, 2, 10, false, 0, complain_overflow_dont,0,"LO10", false, 0,0x000003ff, false),
+ HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, complain_overflow_bitfield,0,"SFA_BASE", false, 0,0xffffffff, false),
+ HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, complain_overflow_bitfield,0,"SFA_OFF13",false, 0,0xffffffff, false),
+ HOWTO(RELOC_BASE10, 0, 2, 10, false, 0, complain_overflow_dont,0,"BASE10", false, 0,0x000003ff, false),
+ HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, complain_overflow_signed,0,"BASE13", false, 0,0x00001fff, false),
+ HOWTO(RELOC_BASE22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"BASE22", false, 0,0x003fffff, false),
+ HOWTO(RELOC_PC10, 0, 2, 10, true, 0, complain_overflow_dont,0,"PC10", false, 0,0x000003ff, true),
+ HOWTO(RELOC_PC22, 10, 2, 22, true, 0, complain_overflow_signed,0,"PC22", false, 0,0x003fffff, true),
+ HOWTO(RELOC_JMP_TBL,2, 2, 30, true, 0, complain_overflow_signed,0,"JMP_TBL", false, 0,0x3fffffff, false),
+ HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, complain_overflow_bitfield,0,"SEGOFF16", false, 0,0x00000000, false),
+ HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"GLOB_DAT", false, 0,0x00000000, false),
+ HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_SLOT", false, 0,0x00000000, false),
+ HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
+ HOWTO(0, 0, 0, 0, false, 0, complain_overflow_dont, 0, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(0, 0, 0, 0, false, 0, complain_overflow_dont, 0, "R_SPARC_NONE", false,0,0x00000000,true),
+#define RELOC_SPARC_REV32 RELOC_WDISP19
+ HOWTO(RELOC_SPARC_REV32, 0, 2, 32, false, 0, complain_overflow_dont,0,"R_SPARC_REV32", false, 0,0xffffffff, false),
+};
+
+/* Convert standard reloc records to "arelent" format (incl byte swap). */
+
+reloc_howto_type howto_table_std[] = {
+ /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
+HOWTO( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),
+HOWTO( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),
+HOWTO( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),
+HOWTO( 3, 0, 4, 64, false, 0, complain_overflow_bitfield,0,"64", true, 0xdeaddead,0xdeaddead, false),
+HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, false),
+HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, false),
+HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, false),
+HOWTO( 7, 0, 4, 64, true, 0, complain_overflow_signed, 0,"DISP64", true, 0xfeedface,0xfeedface, false),
+HOWTO( 8, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"GOT_REL", false, 0,0x00000000, false),
+HOWTO( 9, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"BASE16", false,0xffffffff,0xffffffff, false),
+HOWTO(10, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"BASE32", false,0xffffffff,0xffffffff, false),
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+ HOWTO(16, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_TABLE", false, 0,0x00000000, false),
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },
+ HOWTO(32, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+ HOWTO(40, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"BASEREL", false, 0,0x00000000, false),
+};
+
+#define TABLE_SIZE(TABLE) (sizeof(TABLE)/sizeof(TABLE[0]))
+
+reloc_howto_type *
+NAME(aout,reloc_type_lookup) (abfd,code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+#define EXT(i,j) case i: return &howto_table_ext[j]
+#define STD(i,j) case i: return &howto_table_std[j]
+ int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
+ if (code == BFD_RELOC_CTOR)
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ case 64:
+ code = BFD_RELOC_64;
+ break;
+ }
+ if (ext)
+ switch (code)
+ {
+ EXT (BFD_RELOC_32, 2);
+ EXT (BFD_RELOC_HI22, 8);
+ EXT (BFD_RELOC_LO10, 11);
+ EXT (BFD_RELOC_32_PCREL_S2, 6);
+ EXT (BFD_RELOC_SPARC_WDISP22, 7);
+ EXT (BFD_RELOC_SPARC13, 10);
+ EXT (BFD_RELOC_SPARC_GOT10, 14);
+ EXT (BFD_RELOC_SPARC_BASE13, 15);
+ EXT (BFD_RELOC_SPARC_GOT13, 15);
+ EXT (BFD_RELOC_SPARC_GOT22, 16);
+ EXT (BFD_RELOC_SPARC_PC10, 17);
+ EXT (BFD_RELOC_SPARC_PC22, 18);
+ EXT (BFD_RELOC_SPARC_WPLT30, 19);
+ EXT (BFD_RELOC_SPARC_REV32, 26);
+ default: return (reloc_howto_type *) NULL;
+ }
+ else
+ /* std relocs */
+ switch (code)
+ {
+ STD (BFD_RELOC_16, 1);
+ STD (BFD_RELOC_32, 2);
+ STD (BFD_RELOC_8_PCREL, 4);
+ STD (BFD_RELOC_16_PCREL, 5);
+ STD (BFD_RELOC_32_PCREL, 6);
+ STD (BFD_RELOC_16_BASEREL, 9);
+ STD (BFD_RELOC_32_BASEREL, 10);
+ default: return (reloc_howto_type *) NULL;
+ }
+}
+
+/*
+SUBSECTION
+ Internal entry points
+
+DESCRIPTION
+ @file{aoutx.h} exports several routines for accessing the
+ contents of an a.out file, which are gathered and exported in
+ turn by various format specific files (eg sunos.c).
+
+*/
+
+/*
+FUNCTION
+ aout_@var{size}_swap_exec_header_in
+
+SYNOPSIS
+ void aout_@var{size}_swap_exec_header_in,
+ (bfd *abfd,
+ struct external_exec *raw_bytes,
+ struct internal_exec *execp);
+
+DESCRIPTION
+ Swap the information in an executable header @var{raw_bytes} taken
+ from a raw byte stream memory image into the internal exec header
+ structure @var{execp}.
+*/
+
+#ifndef NAME_swap_exec_header_in
+void
+NAME(aout,swap_exec_header_in) (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* The internal_exec structure has some fields that are unused in this
+ configuration (IE for i960), so ensure that all such uninitialized
+ fields are zero'd out. There are places where two of these structs
+ are memcmp'd, and thus the contents do matter. */
+ memset ((PTR) execp, 0, sizeof (struct internal_exec));
+ /* Now fill in fields in the execp, from the bytes in the raw data. */
+ execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_text = GET_WORD (abfd, bytes->e_text);
+ execp->a_data = GET_WORD (abfd, bytes->e_data);
+ execp->a_bss = GET_WORD (abfd, bytes->e_bss);
+ execp->a_syms = GET_WORD (abfd, bytes->e_syms);
+ execp->a_entry = GET_WORD (abfd, bytes->e_entry);
+ execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
+ execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
+}
+#define NAME_swap_exec_header_in NAME(aout,swap_exec_header_in)
+#endif
+
+/*
+FUNCTION
+ aout_@var{size}_swap_exec_header_out
+
+SYNOPSIS
+ void aout_@var{size}_swap_exec_header_out
+ (bfd *abfd,
+ struct internal_exec *execp,
+ struct external_exec *raw_bytes);
+
+DESCRIPTION
+ Swap the information in an internal exec header structure
+ @var{execp} into the buffer @var{raw_bytes} ready for writing to disk.
+*/
+void
+NAME(aout,swap_exec_header_out) (abfd, execp, raw_bytes)
+ bfd *abfd;
+ struct internal_exec *execp;
+ struct external_exec *raw_bytes;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* Now fill in fields in the raw data, from the fields in the exec struct. */
+ bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
+ PUT_WORD (abfd, execp->a_text , bytes->e_text);
+ PUT_WORD (abfd, execp->a_data , bytes->e_data);
+ PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
+ PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
+ PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
+ PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
+ PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
+}
+
+/* Make all the section for an a.out file. */
+
+boolean
+NAME(aout,make_sections) (abfd)
+ bfd *abfd;
+{
+ if (obj_textsec (abfd) == (asection *) NULL
+ && bfd_make_section (abfd, ".text") == (asection *) NULL)
+ return false;
+ if (obj_datasec (abfd) == (asection *) NULL
+ && bfd_make_section (abfd, ".data") == (asection *) NULL)
+ return false;
+ if (obj_bsssec (abfd) == (asection *) NULL
+ && bfd_make_section (abfd, ".bss") == (asection *) NULL)
+ return false;
+ return true;
+}
+
+/*
+FUNCTION
+ aout_@var{size}_some_aout_object_p
+
+SYNOPSIS
+ const bfd_target *aout_@var{size}_some_aout_object_p
+ (bfd *abfd,
+ const bfd_target *(*callback_to_real_object_p)());
+
+DESCRIPTION
+ Some a.out variant thinks that the file open in @var{abfd}
+ checking is an a.out file. Do some more checking, and set up
+ for access if it really is. Call back to the calling
+ environment's "finish up" function just before returning, to
+ handle any last-minute setup.
+*/
+
+const bfd_target *
+NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
+ bfd *abfd;
+ struct internal_exec *execp;
+ const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
+{
+ struct aout_data_struct *rawptr, *oldrawptr;
+ const bfd_target *result;
+
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
+ if (rawptr == NULL)
+ return 0;
+
+ oldrawptr = abfd->tdata.aout_data;
+ abfd->tdata.aout_data = rawptr;
+
+ /* Copy the contents of the old tdata struct.
+ In particular, we want the subformat, since for hpux it was set in
+ hp300hpux.c:swap_exec_header_in and will be used in
+ hp300hpux.c:callback. */
+ if (oldrawptr != NULL)
+ *abfd->tdata.aout_data = *oldrawptr;
+
+ abfd->tdata.aout_data->a.hdr = &rawptr->e;
+ *(abfd->tdata.aout_data->a.hdr) = *execp; /* Copy in the internal_exec struct */
+ execp = abfd->tdata.aout_data->a.hdr;
+
+ /* Set the file flags */
+ abfd->flags = BFD_NO_FLAGS;
+ if (execp->a_drsize || execp->a_trsize)
+ abfd->flags |= HAS_RELOC;
+ /* Setting of EXEC_P has been deferred to the bottom of this function */
+ if (execp->a_syms)
+ abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+ if (N_DYNAMIC(*execp))
+ abfd->flags |= DYNAMIC;
+
+ if (N_MAGIC (*execp) == ZMAGIC)
+ {
+ abfd->flags |= D_PAGED | WP_TEXT;
+ adata (abfd).magic = z_magic;
+ }
+ else if (N_MAGIC (*execp) == QMAGIC)
+ {
+ abfd->flags |= D_PAGED | WP_TEXT;
+ adata (abfd).magic = z_magic;
+ adata (abfd).subformat = q_magic_format;
+ }
+ else if (N_MAGIC (*execp) == NMAGIC)
+ {
+ abfd->flags |= WP_TEXT;
+ adata (abfd).magic = n_magic;
+ }
+ else if (N_MAGIC (*execp) == OMAGIC
+ || N_MAGIC (*execp) == BMAGIC)
+ adata (abfd).magic = o_magic;
+ else
+ {
+ /* Should have been checked with N_BADMAG before this routine
+ was called. */
+ abort ();
+ }
+
+ bfd_get_start_address (abfd) = execp->a_entry;
+
+ obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
+ bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
+
+ /* The default relocation entry size is that of traditional V7 Unix. */
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ /* The default symbol entry size is that of traditional Unix. */
+ obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
+
+#ifdef USE_MMAP
+ bfd_init_window (&obj_aout_sym_window (abfd));
+ bfd_init_window (&obj_aout_string_window (abfd));
+#endif
+ obj_aout_external_syms (abfd) = NULL;
+ obj_aout_external_strings (abfd) = NULL;
+ obj_aout_sym_hashes (abfd) = NULL;
+
+ if (! NAME(aout,make_sections) (abfd))
+ return NULL;
+
+ obj_datasec (abfd)->_raw_size = execp->a_data;
+ obj_bsssec (abfd)->_raw_size = execp->a_bss;
+
+ obj_textsec (abfd)->flags =
+ (execp->a_trsize != 0
+ ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)
+ : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));
+ obj_datasec (abfd)->flags =
+ (execp->a_drsize != 0
+ ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)
+ : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
+ obj_bsssec (abfd)->flags = SEC_ALLOC;
+
+#ifdef THIS_IS_ONLY_DOCUMENTATION
+ /* The common code can't fill in these things because they depend
+ on either the start address of the text segment, the rounding
+ up of virtual addresses between segments, or the starting file
+ position of the text segment -- all of which varies among different
+ versions of a.out. */
+
+ /* Call back to the format-dependent code to fill in the rest of the
+ fields and do any further cleanup. Things that should be filled
+ in by the callback: */
+
+ struct exec *execp = exec_hdr (abfd);
+
+ obj_textsec (abfd)->size = N_TXTSIZE(*execp);
+ obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp);
+ /* data and bss are already filled in since they're so standard */
+
+ /* The virtual memory addresses of the sections */
+ obj_textsec (abfd)->vma = N_TXTADDR(*execp);
+ obj_datasec (abfd)->vma = N_DATADDR(*execp);
+ obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
+
+ /* The file offsets of the sections */
+ obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
+ obj_datasec (abfd)->filepos = N_DATOFF(*execp);
+
+ /* The file offsets of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
+ obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
+
+ /* The file offsets of the string table and symbol table. */
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+
+ /* Determine the architecture and machine type of the object file. */
+ switch (N_MACHTYPE (*exec_hdr (abfd))) {
+ default:
+ abfd->obj_arch = bfd_arch_obscure;
+ break;
+ }
+
+ adata(abfd)->page_size = TARGET_PAGE_SIZE;
+ adata(abfd)->segment_size = SEGMENT_SIZE;
+ adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
+
+ return abfd->xvec;
+
+ /* The architecture is encoded in various ways in various a.out variants,
+ or is not encoded at all in some of them. The relocation size depends
+ on the architecture and the a.out variant. Finally, the return value
+ is the bfd_target vector in use. If an error occurs, return zero and
+ set bfd_error to the appropriate error code.
+
+ Formats such as b.out, which have additional fields in the a.out
+ header, should cope with them in this callback as well. */
+#endif /* DOCUMENTATION */
+
+ result = (*callback_to_real_object_p)(abfd);
+
+ /* Now that the segment addresses have been worked out, take a better
+ guess at whether the file is executable. If the entry point
+ is within the text segment, assume it is. (This makes files
+ executable even if their entry point address is 0, as long as
+ their text starts at zero.).
+
+ This test had to be changed to deal with systems where the text segment
+ runs at a different location than the default. The problem is that the
+ entry address can appear to be outside the text segment, thus causing an
+ erroneous conclusion that the file isn't executable.
+
+ To fix this, we now accept any non-zero entry point as an indication of
+ executability. This will work most of the time, since only the linker
+ sets the entry point, and that is likely to be non-zero for most systems. */
+
+ if (execp->a_entry != 0
+ || (execp->a_entry >= obj_textsec(abfd)->vma
+ && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
+ abfd->flags |= EXEC_P;
+#ifdef STAT_FOR_EXEC
+ else
+ {
+ struct stat stat_buf;
+
+ /* The original heuristic doesn't work in some important cases.
+ The a.out file has no information about the text start
+ address. For files (like kernels) linked to non-standard
+ addresses (ld -Ttext nnn) the entry point may not be between
+ the default text start (obj_textsec(abfd)->vma) and
+ (obj_textsec(abfd)->vma) + text size. This is not just a mach
+ issue. Many kernels are loaded at non standard addresses. */
+ if (abfd->iostream != NULL
+ && (abfd->flags & BFD_IN_MEMORY) == 0
+ && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)
+ && ((stat_buf.st_mode & 0111) != 0))
+ abfd->flags |= EXEC_P;
+ }
+#endif /* STAT_FOR_EXEC */
+
+ if (result)
+ {
+#if 0 /* These should be set correctly anyways. */
+ abfd->sections = obj_textsec (abfd);
+ obj_textsec (abfd)->next = obj_datasec (abfd);
+ obj_datasec (abfd)->next = obj_bsssec (abfd);
+#endif
+ }
+ else
+ {
+ free (rawptr);
+ abfd->tdata.aout_data = oldrawptr;
+ }
+ return result;
+}
+
+/*
+FUNCTION
+ aout_@var{size}_mkobject
+
+SYNOPSIS
+ boolean aout_@var{size}_mkobject, (bfd *abfd);
+
+DESCRIPTION
+ Initialize BFD @var{abfd} for use with a.out files.
+*/
+
+boolean
+NAME(aout,mkobject) (abfd)
+ bfd *abfd;
+{
+ struct aout_data_struct *rawptr;
+
+ bfd_set_error (bfd_error_system_call);
+
+ /* Use an intermediate variable for clarity */
+ rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
+
+ if (rawptr == NULL)
+ return false;
+
+ abfd->tdata.aout_data = rawptr;
+ exec_hdr (abfd) = &(rawptr->e);
+
+ obj_textsec (abfd) = (asection *)NULL;
+ obj_datasec (abfd) = (asection *)NULL;
+ obj_bsssec (abfd) = (asection *)NULL;
+
+ return true;
+}
+
+
+/*
+FUNCTION
+ aout_@var{size}_machine_type
+
+SYNOPSIS
+ enum machine_type aout_@var{size}_machine_type
+ (enum bfd_architecture arch,
+ unsigned long machine));
+
+DESCRIPTION
+ Keep track of machine architecture and machine type for
+ a.out's. Return the <<machine_type>> for a particular
+ architecture and machine, or <<M_UNKNOWN>> if that exact architecture
+ and machine can't be represented in a.out format.
+
+ If the architecture is understood, machine type 0 (default)
+ is always understood.
+*/
+
+enum machine_type
+NAME(aout,machine_type) (arch, machine, unknown)
+ enum bfd_architecture arch;
+ unsigned long machine;
+ boolean *unknown;
+{
+ enum machine_type arch_flags;
+
+ arch_flags = M_UNKNOWN;
+ *unknown = true;
+
+ switch (arch) {
+ case bfd_arch_sparc:
+ if (machine == 0
+ || machine == bfd_mach_sparc
+ || machine == bfd_mach_sparc_sparclite
+ || machine == bfd_mach_sparc_sparclite_le
+ || machine == bfd_mach_sparc_v9)
+ arch_flags = M_SPARC;
+ else if (machine == bfd_mach_sparc_sparclet)
+ arch_flags = M_SPARCLET;
+ break;
+
+ case bfd_arch_m68k:
+ switch (machine) {
+ case 0: arch_flags = M_68010; break;
+ case bfd_mach_m68000: arch_flags = M_UNKNOWN; *unknown = false; break;
+ case bfd_mach_m68010: arch_flags = M_68010; break;
+ case bfd_mach_m68020: arch_flags = M_68020; break;
+ default: arch_flags = M_UNKNOWN; break;
+ }
+ break;
+
+ case bfd_arch_i386:
+ if (machine == 0) arch_flags = M_386;
+ break;
+
+ case bfd_arch_a29k:
+ if (machine == 0) arch_flags = M_29K;
+ break;
+
+ case bfd_arch_arm:
+ if (machine == 0) arch_flags = M_ARM;
+ break;
+
+ case bfd_arch_mips:
+ switch (machine) {
+ case 0:
+ case bfd_mach_mips3000:
+ case bfd_mach_mips3900:
+ arch_flags = M_MIPS1;
+ break;
+ case bfd_mach_mips6000:
+ arch_flags = M_MIPS2;
+ break;
+ case bfd_mach_mips4000:
+ case bfd_mach_mips4010:
+ case bfd_mach_mips4100:
+ case bfd_mach_mips4300:
+ case bfd_mach_mips4400:
+ case bfd_mach_mips4600:
+ case bfd_mach_mips4650:
+ case bfd_mach_mips8000:
+ case bfd_mach_mips10000:
+ case bfd_mach_mips16:
+ /* FIXME: These should be MIPS3 or MIPS4. */
+ arch_flags = M_MIPS2;
+ break;
+ default:
+ arch_flags = M_UNKNOWN;
+ break;
+ }
+ break;
+
+ case bfd_arch_ns32k:
+ switch (machine) {
+ case 0: arch_flags = M_NS32532; break;
+ case 32032: arch_flags = M_NS32032; break;
+ case 32532: arch_flags = M_NS32532; break;
+ default: arch_flags = M_UNKNOWN; break;
+ }
+ break;
+
+ case bfd_arch_vax:
+ *unknown = false;
+ break;
+
+ default:
+ arch_flags = M_UNKNOWN;
+ }
+
+ if (arch_flags != M_UNKNOWN)
+ *unknown = false;
+
+ return arch_flags;
+}
+
+
+/*
+FUNCTION
+ aout_@var{size}_set_arch_mach
+
+SYNOPSIS
+ boolean aout_@var{size}_set_arch_mach,
+ (bfd *,
+ enum bfd_architecture arch,
+ unsigned long machine));
+
+DESCRIPTION
+ Set the architecture and the machine of the BFD @var{abfd} to the
+ values @var{arch} and @var{machine}. Verify that @var{abfd}'s format
+ can support the architecture required.
+*/
+
+boolean
+NAME(aout,set_arch_mach) (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ if (! bfd_default_set_arch_mach (abfd, arch, machine))
+ return false;
+
+ if (arch != bfd_arch_unknown)
+ {
+ boolean unknown;
+
+ NAME(aout,machine_type) (arch, machine, &unknown);
+ if (unknown)
+ return false;
+ }
+
+ /* Determine the size of a relocation entry */
+ switch (arch) {
+ case bfd_arch_sparc:
+ case bfd_arch_a29k:
+ case bfd_arch_mips:
+ obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
+ break;
+ default:
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ break;
+ }
+
+ return (*aout_backend_info(abfd)->set_sizes) (abfd);
+}
+
+static void
+adjust_o_magic (abfd, execp)
+ bfd *abfd;
+ struct internal_exec *execp;
+{
+ file_ptr pos = adata (abfd).exec_bytes_size;
+ bfd_vma vma = 0;
+ int pad = 0;
+
+ /* Text. */
+ obj_textsec(abfd)->filepos = pos;
+ if (!obj_textsec(abfd)->user_set_vma)
+ obj_textsec(abfd)->vma = vma;
+ else
+ vma = obj_textsec(abfd)->vma;
+
+ pos += obj_textsec(abfd)->_raw_size;
+ vma += obj_textsec(abfd)->_raw_size;
+
+ /* Data. */
+ if (!obj_datasec(abfd)->user_set_vma)
+ {
+#if 0 /* ?? Does alignment in the file image really matter? */
+ pad = align_power (vma, obj_datasec(abfd)->alignment_power) - vma;
+#endif
+ obj_textsec(abfd)->_raw_size += pad;
+ pos += pad;
+ vma += pad;
+ obj_datasec(abfd)->vma = vma;
+ }
+ else
+ vma = obj_datasec(abfd)->vma;
+ obj_datasec(abfd)->filepos = pos;
+ pos += obj_datasec(abfd)->_raw_size;
+ vma += obj_datasec(abfd)->_raw_size;
+
+ /* BSS. */
+ if (!obj_bsssec(abfd)->user_set_vma)
+ {
+#if 0
+ pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
+#endif
+ obj_datasec(abfd)->_raw_size += pad;
+ pos += pad;
+ vma += pad;
+ obj_bsssec(abfd)->vma = vma;
+ }
+ else
+ {
+ /* The VMA of the .bss section is set by the the VMA of the
+ .data section plus the size of the .data section. We may
+ need to add padding bytes to make this true. */
+ pad = obj_bsssec (abfd)->vma - vma;
+ if (pad > 0)
+ {
+ obj_datasec (abfd)->_raw_size += pad;
+ pos += pad;
+ }
+ }
+ obj_bsssec(abfd)->filepos = pos;
+
+ /* Fix up the exec header. */
+ execp->a_text = obj_textsec(abfd)->_raw_size;
+ execp->a_data = obj_datasec(abfd)->_raw_size;
+ execp->a_bss = obj_bsssec(abfd)->_raw_size;
+ N_SET_MAGIC (*execp, OMAGIC);
+}
+
+static void
+adjust_z_magic (abfd, execp)
+ bfd *abfd;
+ struct internal_exec *execp;
+{
+ bfd_size_type data_pad, text_pad;
+ file_ptr text_end;
+ CONST struct aout_backend_data *abdp;
+ int ztih; /* Nonzero if text includes exec header. */
+
+ abdp = aout_backend_info (abfd);
+
+ /* Text. */
+ ztih = (abdp != NULL
+ && (abdp->text_includes_header
+ || obj_aout_subformat (abfd) == q_magic_format));
+ obj_textsec(abfd)->filepos = (ztih
+ ? adata(abfd).exec_bytes_size
+ : adata(abfd).zmagic_disk_block_size);
+ if (! obj_textsec(abfd)->user_set_vma)
+ {
+ /* ?? Do we really need to check for relocs here? */
+ obj_textsec(abfd)->vma = ((abfd->flags & HAS_RELOC)
+ ? 0
+ : (ztih
+ ? (abdp->default_text_vma
+ + adata(abfd).exec_bytes_size)
+ : abdp->default_text_vma));
+ text_pad = 0;
+ }
+ else
+ {
+ /* The .text section is being loaded at an unusual address. We
+ may need to pad it such that the .data section starts at a page
+ boundary. */
+ if (ztih)
+ text_pad = ((obj_textsec (abfd)->filepos - obj_textsec (abfd)->vma)
+ & (adata (abfd).page_size - 1));
+ else
+ text_pad = ((- obj_textsec (abfd)->vma)
+ & (adata (abfd).page_size - 1));
+ }
+
+ /* Find start of data. */
+ if (ztih)
+ {
+ text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size;
+ text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
+ }
+ else
+ {
+ /* Note that if page_size == zmagic_disk_block_size, then
+ filepos == page_size, and this case is the same as the ztih
+ case. */
+ text_end = obj_textsec (abfd)->_raw_size;
+ text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
+ text_end += obj_textsec (abfd)->filepos;
+ }
+ obj_textsec(abfd)->_raw_size += text_pad;
+ text_end += text_pad;
+
+ /* Data. */
+ if (!obj_datasec(abfd)->user_set_vma)
+ {
+ bfd_vma vma;
+ vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size;
+ obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
+ }
+ if (abdp && abdp->zmagic_mapped_contiguous)
+ {
+ text_pad = (obj_datasec(abfd)->vma
+ - obj_textsec(abfd)->vma
+ - obj_textsec(abfd)->_raw_size);
+ obj_textsec(abfd)->_raw_size += text_pad;
+ }
+ obj_datasec(abfd)->filepos = (obj_textsec(abfd)->filepos
+ + obj_textsec(abfd)->_raw_size);
+
+ /* Fix up exec header while we're at it. */
+ execp->a_text = obj_textsec(abfd)->_raw_size;
+ if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
+ execp->a_text += adata(abfd).exec_bytes_size;
+ if (obj_aout_subformat (abfd) == q_magic_format)
+ N_SET_MAGIC (*execp, QMAGIC);
+ else
+ N_SET_MAGIC (*execp, ZMAGIC);
+
+ /* Spec says data section should be rounded up to page boundary. */
+ obj_datasec(abfd)->_raw_size
+ = align_power (obj_datasec(abfd)->_raw_size,
+ obj_bsssec(abfd)->alignment_power);
+ execp->a_data = BFD_ALIGN (obj_datasec(abfd)->_raw_size,
+ adata(abfd).page_size);
+ data_pad = execp->a_data - obj_datasec(abfd)->_raw_size;
+
+ /* BSS. */
+ if (!obj_bsssec(abfd)->user_set_vma)
+ obj_bsssec(abfd)->vma = (obj_datasec(abfd)->vma
+ + obj_datasec(abfd)->_raw_size);
+ /* If the BSS immediately follows the data section and extra space
+ in the page is left after the data section, fudge data
+ in the header so that the bss section looks smaller by that
+ amount. We'll start the bss section there, and lie to the OS.
+ (Note that a linker script, as well as the above assignment,
+ could have explicitly set the BSS vma to immediately follow
+ the data section.) */
+ if (align_power (obj_bsssec(abfd)->vma, obj_bsssec(abfd)->alignment_power)
+ == obj_datasec(abfd)->vma + obj_datasec(abfd)->_raw_size)
+ execp->a_bss = (data_pad > obj_bsssec(abfd)->_raw_size) ? 0 :
+ obj_bsssec(abfd)->_raw_size - data_pad;
+ else
+ execp->a_bss = obj_bsssec(abfd)->_raw_size;
+}
+
+static void
+adjust_n_magic (abfd, execp)
+ bfd *abfd;
+ struct internal_exec *execp;
+{
+ file_ptr pos = adata(abfd).exec_bytes_size;
+ bfd_vma vma = 0;
+ int pad;
+
+ /* Text. */
+ obj_textsec(abfd)->filepos = pos;
+ if (!obj_textsec(abfd)->user_set_vma)
+ obj_textsec(abfd)->vma = vma;
+ else
+ vma = obj_textsec(abfd)->vma;
+ pos += obj_textsec(abfd)->_raw_size;
+ vma += obj_textsec(abfd)->_raw_size;
+
+ /* Data. */
+ obj_datasec(abfd)->filepos = pos;
+ if (!obj_datasec(abfd)->user_set_vma)
+ obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
+ vma = obj_datasec(abfd)->vma;
+
+ /* Since BSS follows data immediately, see if it needs alignment. */
+ vma += obj_datasec(abfd)->_raw_size;
+ pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
+ obj_datasec(abfd)->_raw_size += pad;
+ pos += obj_datasec(abfd)->_raw_size;
+
+ /* BSS. */
+ if (!obj_bsssec(abfd)->user_set_vma)
+ obj_bsssec(abfd)->vma = vma;
+ else
+ vma = obj_bsssec(abfd)->vma;
+
+ /* Fix up exec header. */
+ execp->a_text = obj_textsec(abfd)->_raw_size;
+ execp->a_data = obj_datasec(abfd)->_raw_size;
+ execp->a_bss = obj_bsssec(abfd)->_raw_size;
+ N_SET_MAGIC (*execp, NMAGIC);
+}
+
+boolean
+NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
+ bfd *abfd;
+ bfd_size_type *text_size;
+ file_ptr *text_end;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ if (! NAME(aout,make_sections) (abfd))
+ return false;
+
+ if (adata(abfd).magic != undecided_magic)
+ return true;
+
+ obj_textsec(abfd)->_raw_size =
+ align_power(obj_textsec(abfd)->_raw_size,
+ obj_textsec(abfd)->alignment_power);
+
+ *text_size = obj_textsec (abfd)->_raw_size;
+ /* Rule (heuristic) for when to pad to a new page. Note that there
+ are (at least) two ways demand-paged (ZMAGIC) files have been
+ handled. Most Berkeley-based systems start the text segment at
+ (TARGET_PAGE_SIZE). However, newer versions of SUNOS start the text
+ segment right after the exec header; the latter is counted in the
+ text segment size, and is paged in by the kernel with the rest of
+ the text. */
+
+ /* This perhaps isn't the right way to do this, but made it simpler for me
+ to understand enough to implement it. Better would probably be to go
+ right from BFD flags to alignment/positioning characteristics. But the
+ old code was sloppy enough about handling the flags, and had enough
+ other magic, that it was a little hard for me to understand. I think
+ I understand it better now, but I haven't time to do the cleanup this
+ minute. */
+
+ if (abfd->flags & D_PAGED)
+ /* Whether or not WP_TEXT is set -- let D_PAGED override. */
+ adata(abfd).magic = z_magic;
+ else if (abfd->flags & WP_TEXT)
+ adata(abfd).magic = n_magic;
+ else
+ adata(abfd).magic = o_magic;
+
+#ifdef BFD_AOUT_DEBUG /* requires gcc2 */
+#if __GNUC__ >= 2
+ fprintf (stderr, "%s text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x,%x>\n",
+ ({ char *str;
+ switch (adata(abfd).magic) {
+ case n_magic: str = "NMAGIC"; break;
+ case o_magic: str = "OMAGIC"; break;
+ case z_magic: str = "ZMAGIC"; break;
+ default: abort ();
+ }
+ str;
+ }),
+ obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
+ obj_textsec(abfd)->alignment_power,
+ obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
+ obj_datasec(abfd)->alignment_power,
+ obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size,
+ obj_bsssec(abfd)->alignment_power);
+#endif
+#endif
+
+ switch (adata(abfd).magic)
+ {
+ case o_magic:
+ adjust_o_magic (abfd, execp);
+ break;
+ case z_magic:
+ adjust_z_magic (abfd, execp);
+ break;
+ case n_magic:
+ adjust_n_magic (abfd, execp);
+ break;
+ default:
+ abort ();
+ }
+
+#ifdef BFD_AOUT_DEBUG
+ fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
+ obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
+ obj_textsec(abfd)->filepos,
+ obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
+ obj_datasec(abfd)->filepos,
+ obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size);
+#endif
+
+ return true;
+}
+
+/*
+FUNCTION
+ aout_@var{size}_new_section_hook
+
+SYNOPSIS
+ boolean aout_@var{size}_new_section_hook,
+ (bfd *abfd,
+ asection *newsect));
+
+DESCRIPTION
+ Called by the BFD in response to a @code{bfd_make_section}
+ request.
+*/
+boolean
+NAME(aout,new_section_hook) (abfd, newsect)
+ bfd *abfd;
+ asection *newsect;
+{
+ /* align to double at least */
+ newsect->alignment_power = bfd_get_arch_info(abfd)->section_align_power;
+
+
+ if (bfd_get_format (abfd) == bfd_object)
+ {
+ if (obj_textsec(abfd) == NULL && !strcmp(newsect->name, ".text")) {
+ obj_textsec(abfd)= newsect;
+ newsect->target_index = N_TEXT;
+ return true;
+ }
+
+ if (obj_datasec(abfd) == NULL && !strcmp(newsect->name, ".data")) {
+ obj_datasec(abfd) = newsect;
+ newsect->target_index = N_DATA;
+ return true;
+ }
+
+ if (obj_bsssec(abfd) == NULL && !strcmp(newsect->name, ".bss")) {
+ obj_bsssec(abfd) = newsect;
+ newsect->target_index = N_BSS;
+ return true;
+ }
+
+ }
+
+ /* We allow more than three sections internally */
+ return true;
+}
+
+boolean
+NAME(aout,set_section_contents) (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ file_ptr text_end;
+ bfd_size_type text_size;
+
+ if (! abfd->output_has_begun)
+ {
+ if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
+ return false;
+ }
+
+ if (section == obj_bsssec (abfd))
+ {
+ bfd_set_error (bfd_error_no_contents);
+ return false;
+ }
+
+ if (section != obj_textsec (abfd)
+ && section != obj_datasec (abfd))
+ {
+ (*_bfd_error_handler)
+ (_("%s: can not represent section `%s' in a.out object file format"),
+ bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+
+ if (count != 0)
+ {
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
+ || bfd_write (location, 1, count, abfd) != count)
+ return false;
+ }
+
+ return true;
+}
+
+/* Read the external symbols from an a.out file. */
+
+static boolean
+aout_get_external_symbols (abfd)
+ bfd *abfd;
+{
+ if (obj_aout_external_syms (abfd) == (struct external_nlist *) NULL)
+ {
+ bfd_size_type count;
+ struct external_nlist *syms;
+
+ count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
+
+#ifdef USE_MMAP
+ if (bfd_get_file_window (abfd,
+ obj_sym_filepos (abfd), exec_hdr (abfd)->a_syms,
+ &obj_aout_sym_window (abfd), true) == false)
+ return false;
+ syms = (struct external_nlist *) obj_aout_sym_window (abfd).data;
+#else
+ /* We allocate using malloc to make the values easy to free
+ later on. If we put them on the objalloc it might not be
+ possible to free them. */
+ syms = ((struct external_nlist *)
+ bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
+ if (syms == (struct external_nlist *) NULL && count != 0)
+ return false;
+
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+ || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
+ != exec_hdr (abfd)->a_syms))
+ {
+ free (syms);
+ return false;
+ }
+#endif
+
+ obj_aout_external_syms (abfd) = syms;
+ obj_aout_external_sym_count (abfd) = count;
+ }
+
+ if (obj_aout_external_strings (abfd) == NULL
+ && exec_hdr (abfd)->a_syms != 0)
+ {
+ unsigned char string_chars[BYTES_IN_WORD];
+ bfd_size_type stringsize;
+ char *strings;
+
+ /* Get the size of the strings. */
+ if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
+ || (bfd_read ((PTR) string_chars, BYTES_IN_WORD, 1, abfd)
+ != BYTES_IN_WORD))
+ return false;
+ stringsize = GET_WORD (abfd, string_chars);
+
+#ifdef USE_MMAP
+ if (bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
+ &obj_aout_string_window (abfd), true) == false)
+ return false;
+ strings = (char *) obj_aout_string_window (abfd).data;
+#else
+ strings = (char *) bfd_malloc ((size_t) stringsize + 1);
+ if (strings == NULL)
+ return false;
+
+ /* Skip space for the string count in the buffer for convenience
+ when using indexes. */
+ if (bfd_read (strings + BYTES_IN_WORD, 1, stringsize - BYTES_IN_WORD,
+ abfd)
+ != stringsize - BYTES_IN_WORD)
+ {
+ free (strings);
+ return false;
+ }
+#endif
+
+ /* Ensure that a zero index yields an empty string. */
+ strings[0] = '\0';
+
+ strings[stringsize - 1] = 0;
+
+ obj_aout_external_strings (abfd) = strings;
+ obj_aout_external_string_size (abfd) = stringsize;
+ }
+
+ return true;
+}
+
+/* Translate an a.out symbol into a BFD symbol. The desc, other, type
+ and symbol->value fields of CACHE_PTR will be set from the a.out
+ nlist structure. This function is responsible for setting
+ symbol->flags and symbol->section, and adjusting symbol->value. */
+
+static boolean
+translate_from_native_sym_flags (abfd, cache_ptr)
+ bfd *abfd;
+ aout_symbol_type *cache_ptr;
+{
+ flagword visible;
+
+ if ((cache_ptr->type & N_STAB) != 0
+ || cache_ptr->type == N_FN)
+ {
+ asection *sec;
+
+ /* This is a debugging symbol. */
+
+ cache_ptr->symbol.flags = BSF_DEBUGGING;
+
+ /* Work out the symbol section. */
+ switch (cache_ptr->type & N_TYPE)
+ {
+ case N_TEXT:
+ case N_FN:
+ sec = obj_textsec (abfd);
+ break;
+ case N_DATA:
+ sec = obj_datasec (abfd);
+ break;
+ case N_BSS:
+ sec = obj_bsssec (abfd);
+ break;
+ default:
+ case N_ABS:
+ sec = bfd_abs_section_ptr;
+ break;
+ }
+
+ cache_ptr->symbol.section = sec;
+ cache_ptr->symbol.value -= sec->vma;
+
+ return true;
+ }
+
+ /* Get the default visibility. This does not apply to all types, so
+ we just hold it in a local variable to use if wanted. */
+ if ((cache_ptr->type & N_EXT) == 0)
+ visible = BSF_LOCAL;
+ else
+ visible = BSF_GLOBAL;
+
+ switch (cache_ptr->type)
+ {
+ default:
+ case N_ABS: case N_ABS | N_EXT:
+ cache_ptr->symbol.section = bfd_abs_section_ptr;
+ cache_ptr->symbol.flags = visible;
+ break;
+
+ case N_UNDF | N_EXT:
+ if (cache_ptr->symbol.value != 0)
+ {
+ /* This is a common symbol. */
+ cache_ptr->symbol.flags = BSF_GLOBAL;
+ cache_ptr->symbol.section = bfd_com_section_ptr;
+ }
+ else
+ {
+ cache_ptr->symbol.flags = 0;
+ cache_ptr->symbol.section = bfd_und_section_ptr;
+ }
+ break;
+
+ case N_TEXT: case N_TEXT | N_EXT:
+ cache_ptr->symbol.section = obj_textsec (abfd);
+ cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
+ cache_ptr->symbol.flags = visible;
+ break;
+
+ /* N_SETV symbols used to represent set vectors placed in the
+ data section. They are no longer generated. Theoretically,
+ it was possible to extract the entries and combine them with
+ new ones, although I don't know if that was ever actually
+ done. Unless that feature is restored, treat them as data
+ symbols. */
+ case N_SETV: case N_SETV | N_EXT:
+ case N_DATA: case N_DATA | N_EXT:
+ cache_ptr->symbol.section = obj_datasec (abfd);
+ cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
+ cache_ptr->symbol.flags = visible;
+ break;
+
+ case N_BSS: case N_BSS | N_EXT:
+ cache_ptr->symbol.section = obj_bsssec (abfd);
+ cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
+ cache_ptr->symbol.flags = visible;
+ break;
+
+ case N_SETA: case N_SETA | N_EXT:
+ case N_SETT: case N_SETT | N_EXT:
+ case N_SETD: case N_SETD | N_EXT:
+ case N_SETB: case N_SETB | N_EXT:
+ {
+ /* This code is no longer needed. It used to be used to make
+ the linker handle set symbols, but they are now handled in
+ the add_symbols routine instead. */
+#if 0
+ asection *section;
+ arelent_chain *reloc;
+ asection *into_section;
+
+ /* This is a set symbol. The name of the symbol is the name
+ of the set (e.g., __CTOR_LIST__). The value of the symbol
+ is the value to add to the set. We create a section with
+ the same name as the symbol, and add a reloc to insert the
+ appropriate value into the section.
+
+ This action is actually obsolete; it used to make the
+ linker do the right thing, but the linker no longer uses
+ this function. */
+
+ section = bfd_get_section_by_name (abfd, cache_ptr->symbol.name);
+ if (section == NULL)
+ {
+ char *copy;
+
+ copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
+ if (copy == NULL)
+ return false;
+
+ strcpy (copy, cache_ptr->symbol.name);
+ section = bfd_make_section (abfd, copy);
+ if (section == NULL)
+ return false;
+ }
+
+ reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
+ if (reloc == NULL)
+ return false;
+
+ /* Build a relocation entry for the constructor. */
+ switch (cache_ptr->type & N_TYPE)
+ {
+ case N_SETA:
+ into_section = bfd_abs_section_ptr;
+ cache_ptr->type = N_ABS;
+ break;
+ case N_SETT:
+ into_section = obj_textsec (abfd);
+ cache_ptr->type = N_TEXT;
+ break;
+ case N_SETD:
+ into_section = obj_datasec (abfd);
+ cache_ptr->type = N_DATA;
+ break;
+ case N_SETB:
+ into_section = obj_bsssec (abfd);
+ cache_ptr->type = N_BSS;
+ break;
+ }
+
+ /* Build a relocation pointing into the constructor section
+ pointing at the symbol in the set vector specified. */
+ reloc->relent.addend = cache_ptr->symbol.value;
+ cache_ptr->symbol.section = into_section;
+ reloc->relent.sym_ptr_ptr = into_section->symbol_ptr_ptr;
+
+ /* We modify the symbol to belong to a section depending upon
+ the name of the symbol, and add to the size of the section
+ to contain a pointer to the symbol. Build a reloc entry to
+ relocate to this symbol attached to this section. */
+ section->flags = SEC_CONSTRUCTOR | SEC_RELOC;
+
+ section->reloc_count++;
+ section->alignment_power = 2;
+
+ reloc->next = section->constructor_chain;
+ section->constructor_chain = reloc;
+ reloc->relent.address = section->_raw_size;
+ section->_raw_size += BYTES_IN_WORD;
+
+ reloc->relent.howto = CTOR_TABLE_RELOC_HOWTO(abfd);
+
+#endif /* 0 */
+
+ switch (cache_ptr->type & N_TYPE)
+ {
+ case N_SETA:
+ cache_ptr->symbol.section = bfd_abs_section_ptr;
+ break;
+ case N_SETT:
+ cache_ptr->symbol.section = obj_textsec (abfd);
+ break;
+ case N_SETD:
+ cache_ptr->symbol.section = obj_datasec (abfd);
+ break;
+ case N_SETB:
+ cache_ptr->symbol.section = obj_bsssec (abfd);
+ break;
+ }
+
+ cache_ptr->symbol.flags |= BSF_CONSTRUCTOR;
+ }
+ break;
+
+ case N_WARNING:
+ /* This symbol is the text of a warning message. The next
+ symbol is the symbol to associate the warning with. If a
+ reference is made to that symbol, a warning is issued. */
+ cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_WARNING;
+ cache_ptr->symbol.section = bfd_abs_section_ptr;
+ break;
+
+ case N_INDR: case N_INDR | N_EXT:
+ /* An indirect symbol. This consists of two symbols in a row.
+ The first symbol is the name of the indirection. The second
+ symbol is the name of the target. A reference to the first
+ symbol becomes a reference to the second. */
+ cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_INDIRECT | visible;
+ cache_ptr->symbol.section = bfd_ind_section_ptr;
+ break;
+
+ case N_WEAKU:
+ cache_ptr->symbol.section = bfd_und_section_ptr;
+ cache_ptr->symbol.flags = BSF_WEAK;
+ break;
+
+ case N_WEAKA:
+ cache_ptr->symbol.section = bfd_abs_section_ptr;
+ cache_ptr->symbol.flags = BSF_WEAK;
+ break;
+
+ case N_WEAKT:
+ cache_ptr->symbol.section = obj_textsec (abfd);
+ cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
+ cache_ptr->symbol.flags = BSF_WEAK;
+ break;
+
+ case N_WEAKD:
+ cache_ptr->symbol.section = obj_datasec (abfd);
+ cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
+ cache_ptr->symbol.flags = BSF_WEAK;
+ break;
+
+ case N_WEAKB:
+ cache_ptr->symbol.section = obj_bsssec (abfd);
+ cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
+ cache_ptr->symbol.flags = BSF_WEAK;
+ break;
+ }
+
+ return true;
+}
+
+/* Set the fields of SYM_POINTER according to CACHE_PTR. */
+
+static boolean
+translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
+ bfd *abfd;
+ asymbol *cache_ptr;
+ struct external_nlist *sym_pointer;
+{
+ bfd_vma value = cache_ptr->value;
+ asection *sec;
+ bfd_vma off;
+
+ /* Mask out any existing type bits in case copying from one section
+ to another. */
+ sym_pointer->e_type[0] &= ~N_TYPE;
+
+ sec = bfd_get_section (cache_ptr);
+ off = 0;
+
+ if (sec == NULL)
+ {
+ /* This case occurs, e.g., for the *DEBUG* section of a COFF
+ file. */
+ (*_bfd_error_handler)
+ (_("%s: can not represent section for symbol `%s' in a.out object file format"),
+ bfd_get_filename (abfd),
+ cache_ptr->name != NULL ? cache_ptr->name : _("*unknown*"));
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+
+ if (sec->output_section != NULL)
+ {
+ off = sec->output_offset;
+ sec = sec->output_section;
+ }
+
+ if (bfd_is_abs_section (sec))
+ sym_pointer->e_type[0] |= N_ABS;
+ else if (sec == obj_textsec (abfd))
+ sym_pointer->e_type[0] |= N_TEXT;
+ else if (sec == obj_datasec (abfd))
+ sym_pointer->e_type[0] |= N_DATA;
+ else if (sec == obj_bsssec (abfd))
+ sym_pointer->e_type[0] |= N_BSS;
+ else if (bfd_is_und_section (sec))
+ sym_pointer->e_type[0] = N_UNDF | N_EXT;
+ else if (bfd_is_ind_section (sec))
+ sym_pointer->e_type[0] = N_INDR;
+ else if (bfd_is_com_section (sec))
+ sym_pointer->e_type[0] = N_UNDF | N_EXT;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: can not represent section `%s' in a.out object file format"),
+ bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+
+ /* Turn the symbol from section relative to absolute again */
+ value += sec->vma + off;
+
+ if ((cache_ptr->flags & BSF_WARNING) != 0)
+ sym_pointer->e_type[0] = N_WARNING;
+
+ if ((cache_ptr->flags & BSF_DEBUGGING) != 0)
+ sym_pointer->e_type[0] = ((aout_symbol_type *) cache_ptr)->type;
+ else if ((cache_ptr->flags & BSF_GLOBAL) != 0)
+ sym_pointer->e_type[0] |= N_EXT;
+
+ if ((cache_ptr->flags & BSF_CONSTRUCTOR) != 0)
+ {
+ int type = ((aout_symbol_type *) cache_ptr)->type;
+ switch (type)
+ {
+ case N_ABS: type = N_SETA; break;
+ case N_TEXT: type = N_SETT; break;
+ case N_DATA: type = N_SETD; break;
+ case N_BSS: type = N_SETB; break;
+ }
+ sym_pointer->e_type[0] = type;
+ }
+
+ if ((cache_ptr->flags & BSF_WEAK) != 0)
+ {
+ int type;
+
+ switch (sym_pointer->e_type[0] & N_TYPE)
+ {
+ default:
+ case N_ABS: type = N_WEAKA; break;
+ case N_TEXT: type = N_WEAKT; break;
+ case N_DATA: type = N_WEAKD; break;
+ case N_BSS: type = N_WEAKB; break;
+ case N_UNDF: type = N_WEAKU; break;
+ }
+ sym_pointer->e_type[0] = type;
+ }
+
+ PUT_WORD(abfd, value, sym_pointer->e_value);
+
+ return true;
+}
+
+/* Native-level interface to symbols. */
+
+asymbol *
+NAME(aout,make_empty_symbol) (abfd)
+ bfd *abfd;
+{
+ aout_symbol_type *new =
+ (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
+ if (!new)
+ return NULL;
+ new->symbol.the_bfd = abfd;
+
+ return &new->symbol;
+}
+
+/* Translate a set of internal symbols into external symbols. */
+
+boolean
+NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic)
+ bfd *abfd;
+ aout_symbol_type *in;
+ struct external_nlist *ext;
+ bfd_size_type count;
+ char *str;
+ bfd_size_type strsize;
+ boolean dynamic;
+{
+ struct external_nlist *ext_end;
+
+ ext_end = ext + count;
+ for (; ext < ext_end; ext++, in++)
+ {
+ bfd_vma x;
+
+ x = GET_WORD (abfd, ext->e_strx);
+ in->symbol.the_bfd = abfd;
+
+ /* For the normal symbols, the zero index points at the number
+ of bytes in the string table but is to be interpreted as the
+ null string. For the dynamic symbols, the number of bytes in
+ the string table is stored in the __DYNAMIC structure and the
+ zero index points at an actual string. */
+ if (x == 0 && ! dynamic)
+ in->symbol.name = "";
+ else if (x < strsize)
+ in->symbol.name = str + x;
+ else
+ return false;
+
+ in->symbol.value = GET_SWORD (abfd, ext->e_value);
+ in->desc = bfd_h_get_16 (abfd, ext->e_desc);
+ in->other = bfd_h_get_8 (abfd, ext->e_other);
+ in->type = bfd_h_get_8 (abfd, ext->e_type);
+ in->symbol.udata.p = NULL;
+
+ if (! translate_from_native_sym_flags (abfd, in))
+ return false;
+
+ if (dynamic)
+ in->symbol.flags |= BSF_DYNAMIC;
+ }
+
+ return true;
+}
+
+/* We read the symbols into a buffer, which is discarded when this
+ function exits. We read the strings into a buffer large enough to
+ hold them all plus all the cached symbol entries. */
+
+boolean
+NAME(aout,slurp_symbol_table) (abfd)
+ bfd *abfd;
+{
+ struct external_nlist *old_external_syms;
+ aout_symbol_type *cached;
+ size_t cached_size;
+
+ /* If there's no work to be done, don't do any */
+ if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
+ return true;
+
+ old_external_syms = obj_aout_external_syms (abfd);
+
+ if (! aout_get_external_symbols (abfd))
+ return false;
+
+ cached_size = (obj_aout_external_sym_count (abfd)
+ * sizeof (aout_symbol_type));
+ cached = (aout_symbol_type *) bfd_malloc (cached_size);
+ if (cached == NULL && cached_size != 0)
+ return false;
+ if (cached_size != 0)
+ memset (cached, 0, cached_size);
+
+ /* Convert from external symbol information to internal. */
+ if (! (NAME(aout,translate_symbol_table)
+ (abfd, cached,
+ obj_aout_external_syms (abfd),
+ obj_aout_external_sym_count (abfd),
+ obj_aout_external_strings (abfd),
+ obj_aout_external_string_size (abfd),
+ false)))
+ {
+ free (cached);
+ return false;
+ }
+
+ bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
+
+ obj_aout_symbols (abfd) = cached;
+
+ /* It is very likely that anybody who calls this function will not
+ want the external symbol information, so if it was allocated
+ because of our call to aout_get_external_symbols, we free it up
+ right away to save space. */
+ if (old_external_syms == (struct external_nlist *) NULL
+ && obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
+ {
+#ifdef USE_MMAP
+ bfd_free_window (&obj_aout_sym_window (abfd));
+#else
+ free (obj_aout_external_syms (abfd));
+#endif
+ obj_aout_external_syms (abfd) = NULL;
+ }
+
+ return true;
+}
+
+/* We use a hash table when writing out symbols so that we only write
+ out a particular string once. This helps particularly when the
+ linker writes out stabs debugging entries, because each different
+ contributing object file tends to have many duplicate stabs
+ strings.
+
+ This hash table code breaks dbx on SunOS 4.1.3, so we don't do it
+ if BFD_TRADITIONAL_FORMAT is set. */
+
+static bfd_size_type add_to_stringtab
+ PARAMS ((bfd *, struct bfd_strtab_hash *, const char *, boolean));
+static boolean emit_stringtab PARAMS ((bfd *, struct bfd_strtab_hash *));
+
+/* Get the index of a string in a strtab, adding it if it is not
+ already present. */
+
+static INLINE bfd_size_type
+add_to_stringtab (abfd, tab, str, copy)
+ bfd *abfd;
+ struct bfd_strtab_hash *tab;
+ const char *str;
+ boolean copy;
+{
+ boolean hash;
+ bfd_size_type index;
+
+ /* An index of 0 always means the empty string. */
+ if (str == 0 || *str == '\0')
+ return 0;
+
+ /* Don't hash if BFD_TRADITIONAL_FORMAT is set, because SunOS dbx
+ doesn't understand a hashed string table. */
+ hash = true;
+ if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ hash = false;
+
+ index = _bfd_stringtab_add (tab, str, hash, copy);
+
+ if (index != (bfd_size_type) -1)
+ {
+ /* Add BYTES_IN_WORD to the return value to account for the
+ space taken up by the string table size. */
+ index += BYTES_IN_WORD;
+ }
+
+ return index;
+}
+
+/* Write out a strtab. ABFD is already at the right location in the
+ file. */
+
+static boolean
+emit_stringtab (abfd, tab)
+ register bfd *abfd;
+ struct bfd_strtab_hash *tab;
+{
+ bfd_byte buffer[BYTES_IN_WORD];
+
+ /* The string table starts with the size. */
+ PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
+ if (bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
+ return false;
+
+ return _bfd_stringtab_emit (abfd, tab);
+}
+
+boolean
+NAME(aout,write_syms) (abfd)
+ bfd *abfd;
+{
+ unsigned int count ;
+ asymbol **generic = bfd_get_outsymbols (abfd);
+ struct bfd_strtab_hash *strtab;
+
+ strtab = _bfd_stringtab_init ();
+ if (strtab == NULL)
+ return false;
+
+ for (count = 0; count < bfd_get_symcount (abfd); count++)
+ {
+ asymbol *g = generic[count];
+ bfd_size_type indx;
+ struct external_nlist nsp;
+
+ indx = add_to_stringtab (abfd, strtab, g->name, false);
+ if (indx == (bfd_size_type) -1)
+ goto error_return;
+ PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx);
+
+ if (bfd_asymbol_flavour(g) == abfd->xvec->flavour)
+ {
+ bfd_h_put_16(abfd, aout_symbol(g)->desc, nsp.e_desc);
+ bfd_h_put_8(abfd, aout_symbol(g)->other, nsp.e_other);
+ bfd_h_put_8(abfd, aout_symbol(g)->type, nsp.e_type);
+ }
+ else
+ {
+ bfd_h_put_16(abfd,0, nsp.e_desc);
+ bfd_h_put_8(abfd, 0, nsp.e_other);
+ bfd_h_put_8(abfd, 0, nsp.e_type);
+ }
+
+ if (! translate_to_native_sym_flags (abfd, g, &nsp))
+ goto error_return;
+
+ if (bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd)
+ != EXTERNAL_NLIST_SIZE)
+ goto error_return;
+
+ /* NB: `KEEPIT' currently overlays `udata.p', so set this only
+ here, at the end. */
+ g->KEEPIT = count;
+ }
+
+ if (! emit_stringtab (abfd, strtab))
+ goto error_return;
+
+ _bfd_stringtab_free (strtab);
+
+ return true;
+
+error_return:
+ _bfd_stringtab_free (strtab);
+ return false;
+}
+
+
+long
+NAME(aout,get_symtab) (abfd, location)
+ bfd *abfd;
+ asymbol **location;
+{
+ unsigned int counter = 0;
+ aout_symbol_type *symbase;
+
+ if (!NAME(aout,slurp_symbol_table)(abfd))
+ return -1;
+
+ for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);)
+ *(location++) = (asymbol *)( symbase++);
+ *location++ =0;
+ return bfd_get_symcount (abfd);
+}
+
+
+/* Standard reloc stuff */
+/* Output standard relocation information to a file in target byte order. */
+
+extern void NAME(aout,swap_std_reloc_out)
+ PARAMS ((bfd *, arelent *, struct reloc_std_external *));
+
+void
+NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
+{
+ int r_index;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ int r_extern;
+ unsigned int r_length;
+ int r_pcrel;
+ int r_baserel, r_jmptable, r_relative;
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD(abfd, g->address, natptr->r_address);
+
+ r_length = g->howto->size ; /* Size as a power of two */
+ r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
+ /* XXX This relies on relocs coming from a.out files. */
+ r_baserel = (g->howto->type & 8) != 0;
+ r_jmptable = (g->howto->type & 16) != 0;
+ r_relative = (g->howto->type & 32) != 0;
+
+#if 0
+ /* For a standard reloc, the addend is in the object file. */
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+#endif
+
+ /* name was clobbered by aout_write_syms to be symbol index */
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here
+ */
+
+
+ if (bfd_is_com_section (output_section)
+ || bfd_is_abs_section (output_section)
+ || bfd_is_und_section (output_section))
+ {
+ if (bfd_abs_section_ptr->symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = N_ABS;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+ r_extern = 1;
+ r_index = (*(g->sym_ptr_ptr))->KEEPIT;
+
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd)) {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ (r_extern? RELOC_STD_BITS_EXTERN_BIG: 0)
+ | (r_pcrel? RELOC_STD_BITS_PCREL_BIG: 0)
+ | (r_baserel? RELOC_STD_BITS_BASEREL_BIG: 0)
+ | (r_jmptable? RELOC_STD_BITS_JMPTABLE_BIG: 0)
+ | (r_relative? RELOC_STD_BITS_RELATIVE_BIG: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG);
+ } else {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
+ | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
+ | (r_baserel? RELOC_STD_BITS_BASEREL_LITTLE: 0)
+ | (r_jmptable? RELOC_STD_BITS_JMPTABLE_LITTLE: 0)
+ | (r_relative? RELOC_STD_BITS_RELATIVE_LITTLE: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE);
+ }
+}
+
+
+/* Extended stuff */
+/* Output extended relocation information to a file in target byte order. */
+
+extern void NAME(aout,swap_ext_reloc_out)
+ PARAMS ((bfd *, arelent *, struct reloc_ext_external *));
+
+void
+NAME(aout,swap_ext_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ register struct reloc_ext_external *natptr;
+{
+ int r_index;
+ int r_extern;
+ unsigned int r_type;
+ unsigned int r_addend;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD (abfd, g->address, natptr->r_address);
+
+ r_type = (unsigned int) g->howto->type;
+
+ r_addend = g->addend;
+ if ((sym->flags & BSF_SECTION_SYM) != 0)
+ r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here. */
+
+ if (bfd_is_abs_section (bfd_get_section (sym)))
+ {
+ r_extern = 0;
+ r_index = N_ABS;
+ }
+ else if ((sym->flags & BSF_SECTION_SYM) == 0)
+ {
+ if (bfd_is_und_section (bfd_get_section (sym))
+ || (sym->flags & BSF_GLOBAL) != 0)
+ r_extern = 1;
+ else
+ r_extern = 0;
+ r_index = (*(g->sym_ptr_ptr))->KEEPIT;
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd)) {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ ((r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0)
+ | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG));
+ } else {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0)
+ | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
+ }
+
+ PUT_WORD (abfd, r_addend, natptr->r_addend);
+}
+
+/* BFD deals internally with all things based from the section they're
+ in. so, something in 10 bytes into a text section with a base of
+ 50 would have a symbol (.text+10) and know .text vma was 50.
+
+ Aout keeps all it's symbols based from zero, so the symbol would
+ contain 60. This macro subs the base of each section from the value
+ to give the true offset from the section */
+
+
+#define MOVE_ADDRESS(ad) \
+ if (r_extern) { \
+ /* undefined symbol */ \
+ cache_ptr->sym_ptr_ptr = symbols + r_index; \
+ cache_ptr->addend = ad; \
+ } else { \
+ /* defined, section relative. replace symbol with pointer to \
+ symbol which points to section */ \
+ switch (r_index) { \
+ case N_TEXT: \
+ case N_TEXT | N_EXT: \
+ cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr; \
+ cache_ptr->addend = ad - su->textsec->vma; \
+ break; \
+ case N_DATA: \
+ case N_DATA | N_EXT: \
+ cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr; \
+ cache_ptr->addend = ad - su->datasec->vma; \
+ break; \
+ case N_BSS: \
+ case N_BSS | N_EXT: \
+ cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr; \
+ cache_ptr->addend = ad - su->bsssec->vma; \
+ break; \
+ default: \
+ case N_ABS: \
+ case N_ABS | N_EXT: \
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; \
+ cache_ptr->addend = ad; \
+ break; \
+ } \
+ } \
+
+void
+NAME(aout,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct reloc_ext_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ unsigned int r_index;
+ int r_extern;
+ unsigned int r_type;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+
+ cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd)) {
+ r_index = (bytes->r_index[0] << 16)
+ | (bytes->r_index[1] << 8)
+ | bytes->r_index[2];
+ r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
+ r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
+ >> RELOC_EXT_BITS_TYPE_SH_BIG;
+ } else {
+ r_index = (bytes->r_index[2] << 16)
+ | (bytes->r_index[1] << 8)
+ | bytes->r_index[0];
+ r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
+ r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
+ >> RELOC_EXT_BITS_TYPE_SH_LITTLE;
+ }
+
+ cache_ptr->howto = howto_table_ext + r_type;
+
+ /* Base relative relocs are always against the symbol table,
+ regardless of the setting of r_extern. r_extern just reflects
+ whether the symbol the reloc is against is local or global. */
+ if (r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22)
+ r_extern = 1;
+
+ if (r_extern && r_index > symcount)
+ {
+ /* We could arrange to return an error, but it might be useful
+ to see the file even if it is bad. */
+ r_extern = 0;
+ r_index = N_ABS;
+ }
+
+ MOVE_ADDRESS(GET_SWORD(abfd, bytes->r_addend));
+}
+
+void
+NAME(aout,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct reloc_std_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ unsigned int r_index;
+ int r_extern;
+ unsigned int r_length;
+ int r_pcrel;
+ int r_baserel, r_jmptable, r_relative;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+ unsigned int howto_idx;
+
+ cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd)) {
+ r_index = (bytes->r_index[0] << 16)
+ | (bytes->r_index[1] << 8)
+ | bytes->r_index[2];
+ r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
+ r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
+ r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
+ r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
+ r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_BIG));
+ r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
+ >> RELOC_STD_BITS_LENGTH_SH_BIG;
+ } else {
+ r_index = (bytes->r_index[2] << 16)
+ | (bytes->r_index[1] << 8)
+ | bytes->r_index[0];
+ r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
+ r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
+ r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE));
+ r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_LITTLE));
+ r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_LITTLE));
+ r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
+ >> RELOC_STD_BITS_LENGTH_SH_LITTLE;
+ }
+
+ howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel
+ + 16 * r_jmptable + 32 * r_relative;
+ BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
+ cache_ptr->howto = howto_table_std + howto_idx;
+ BFD_ASSERT (cache_ptr->howto->type != (unsigned int) -1);
+
+ /* Base relative relocs are always against the symbol table,
+ regardless of the setting of r_extern. r_extern just reflects
+ whether the symbol the reloc is against is local or global. */
+ if (r_baserel)
+ r_extern = 1;
+
+ if (r_extern && r_index > symcount)
+ {
+ /* We could arrange to return an error, but it might be useful
+ to see the file even if it is bad. */
+ r_extern = 0;
+ r_index = N_ABS;
+ }
+
+ MOVE_ADDRESS(0);
+}
+
+/* Read and swap the relocs for a section. */
+
+boolean
+NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ asymbol **symbols;
+{
+ unsigned int count;
+ bfd_size_type reloc_size;
+ PTR relocs;
+ arelent *reloc_cache;
+ size_t each_size;
+ unsigned int counter = 0;
+ arelent *cache_ptr;
+
+ if (asect->relocation)
+ return true;
+
+ if (asect->flags & SEC_CONSTRUCTOR)
+ return true;
+
+ if (asect == obj_datasec (abfd))
+ reloc_size = exec_hdr(abfd)->a_drsize;
+ else if (asect == obj_textsec (abfd))
+ reloc_size = exec_hdr(abfd)->a_trsize;
+ else if (asect == obj_bsssec (abfd))
+ reloc_size = 0;
+ else
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+ return false;
+
+ each_size = obj_reloc_entry_size (abfd);
+
+ count = reloc_size / each_size;
+
+ reloc_cache = (arelent *) bfd_malloc ((size_t) (count * sizeof (arelent)));
+ if (reloc_cache == NULL && count != 0)
+ return false;
+ memset (reloc_cache, 0, count * sizeof (arelent));
+
+ relocs = bfd_malloc ((size_t) reloc_size);
+ if (relocs == NULL && reloc_size != 0)
+ {
+ free (reloc_cache);
+ return false;
+ }
+
+ if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ {
+ free (relocs);
+ free (reloc_cache);
+ return false;
+ }
+
+ cache_ptr = reloc_cache;
+ if (each_size == RELOC_EXT_SIZE)
+ {
+ register struct reloc_ext_external *rptr =
+ (struct reloc_ext_external *) relocs;
+
+ for (; counter < count; counter++, rptr++, cache_ptr++)
+ NAME(aout,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
+ }
+ else
+ {
+ register struct reloc_std_external *rptr =
+ (struct reloc_std_external *) relocs;
+
+ for (; counter < count; counter++, rptr++, cache_ptr++)
+ MY_swap_std_reloc_in (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
+ }
+
+ free (relocs);
+
+ asect->relocation = reloc_cache;
+ asect->reloc_count = cache_ptr - reloc_cache;
+
+ return true;
+}
+
+/* Write out a relocation section into an object file. */
+
+boolean
+NAME(aout,squirt_out_relocs) (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ arelent **generic;
+ unsigned char *native, *natptr;
+ size_t each_size;
+
+ unsigned int count = section->reloc_count;
+ size_t natsize;
+
+ if (count == 0 || section->orelocation == NULL)
+ return true;
+
+ each_size = obj_reloc_entry_size (abfd);
+ natsize = each_size * count;
+ native = (unsigned char *) bfd_zalloc (abfd, natsize);
+ if (!native)
+ return false;
+
+ generic = section->orelocation;
+
+ if (each_size == RELOC_EXT_SIZE)
+ {
+ for (natptr = native;
+ count != 0;
+ --count, natptr += each_size, ++generic)
+ NAME(aout,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *)natptr);
+ }
+ else
+ {
+ for (natptr = native;
+ count != 0;
+ --count, natptr += each_size, ++generic)
+ MY_swap_std_reloc_out(abfd, *generic, (struct reloc_std_external *)natptr);
+ }
+
+ if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
+ bfd_release(abfd, native);
+ return false;
+ }
+ bfd_release (abfd, native);
+
+ return true;
+}
+
+/* This is stupid. This function should be a boolean predicate */
+long
+NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count;
+
+ if (section == obj_bsssec (abfd))
+ {
+ *relptr = NULL;
+ return 0;
+ }
+
+ if (!(tblptr || NAME(aout,slurp_reloc_table)(abfd, section, symbols)))
+ return -1;
+
+ if (section->flags & SEC_CONSTRUCTOR) {
+ arelent_chain *chain = section->constructor_chain;
+ for (count = 0; count < section->reloc_count; count ++) {
+ *relptr ++ = &chain->relent;
+ chain = chain->next;
+ }
+ }
+ else {
+ tblptr = section->relocation;
+
+ for (count = 0; count++ < section->reloc_count;)
+ {
+ *relptr++ = tblptr++;
+ }
+ }
+ *relptr = 0;
+
+ return section->reloc_count;
+}
+
+long
+NAME(aout,get_reloc_upper_bound) (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ if (bfd_get_format (abfd) != bfd_object) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+ if (asect->flags & SEC_CONSTRUCTOR) {
+ return (sizeof (arelent *) * (asect->reloc_count+1));
+ }
+
+ if (asect == obj_datasec (abfd))
+ return (sizeof (arelent *)
+ * ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd))
+ + 1));
+
+ if (asect == obj_textsec (abfd))
+ return (sizeof (arelent *)
+ * ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
+ + 1));
+
+ if (asect == obj_bsssec (abfd))
+ return sizeof (arelent *);
+
+ if (asect == obj_bsssec (abfd))
+ return 0;
+
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+}
+
+
+long
+NAME(aout,get_symtab_upper_bound) (abfd)
+ bfd *abfd;
+{
+ if (!NAME(aout,slurp_symbol_table)(abfd))
+ return -1;
+
+ return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *));
+}
+
+/*ARGSUSED*/
+ alent *
+NAME(aout,get_lineno) (ignore_abfd, ignore_symbol)
+ bfd *ignore_abfd;
+ asymbol *ignore_symbol;
+{
+return (alent *)NULL;
+}
+
+/*ARGSUSED*/
+void
+NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+
+ if (ret->type == '?')
+ {
+ int type_code = aout_symbol(symbol)->type & 0xff;
+ const char *stab_name = bfd_get_stab_name (type_code);
+ static char buf[10];
+
+ if (stab_name == NULL)
+ {
+ sprintf(buf, "(%d)", type_code);
+ stab_name = buf;
+ }
+ ret->type = '-';
+ ret->stab_type = type_code;
+ ret->stab_other = (unsigned)(aout_symbol(symbol)->other & 0xff);
+ ret->stab_desc = (unsigned)(aout_symbol(symbol)->desc & 0xffff);
+ ret->stab_name = stab_name;
+ }
+}
+
+/*ARGSUSED*/
+void
+NAME(aout,print_symbol) (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *)afile;
+
+ switch (how) {
+ case bfd_print_symbol_name:
+ if (symbol->name)
+ fprintf(file,"%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+ fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
+ (unsigned)(aout_symbol(symbol)->other & 0xff),
+ (unsigned)(aout_symbol(symbol)->type));
+ break;
+ case bfd_print_symbol_all:
+ {
+ CONST char *section_name = symbol->section->name;
+
+
+ bfd_print_symbol_vandf((PTR)file,symbol);
+
+ fprintf(file," %-5s %04x %02x %02x",
+ section_name,
+ (unsigned)(aout_symbol(symbol)->desc & 0xffff),
+ (unsigned)(aout_symbol(symbol)->other & 0xff),
+ (unsigned)(aout_symbol(symbol)->type & 0xff));
+ if (symbol->name)
+ fprintf(file," %s", symbol->name);
+ }
+ break;
+ }
+}
+
+/* If we don't have to allocate more than 1MB to hold the generic
+ symbols, we use the generic minisymbol methord: it's faster, since
+ it only translates the symbols once, not multiple times. */
+#define MINISYM_THRESHOLD (1000000 / sizeof (asymbol))
+
+/* Read minisymbols. For minisymbols, we use the unmodified a.out
+ symbols. The minisymbol_to_symbol function translates these into
+ BFD asymbol structures. */
+
+long
+NAME(aout,read_minisymbols) (abfd, dynamic, minisymsp, sizep)
+ bfd *abfd;
+ boolean dynamic;
+ PTR *minisymsp;
+ unsigned int *sizep;
+{
+ if (dynamic)
+ {
+ /* We could handle the dynamic symbols here as well, but it's
+ easier to hand them off. */
+ return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
+ }
+
+ if (! aout_get_external_symbols (abfd))
+ return -1;
+
+ if (obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
+ return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
+
+ *minisymsp = (PTR) obj_aout_external_syms (abfd);
+
+ /* By passing the external symbols back from this routine, we are
+ giving up control over the memory block. Clear
+ obj_aout_external_syms, so that we do not try to free it
+ ourselves. */
+ obj_aout_external_syms (abfd) = NULL;
+
+ *sizep = EXTERNAL_NLIST_SIZE;
+ return obj_aout_external_sym_count (abfd);
+}
+
+/* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
+ unmodified a.out symbol. The SYM argument is a structure returned
+ by bfd_make_empty_symbol, which we fill in here. */
+
+asymbol *
+NAME(aout,minisymbol_to_symbol) (abfd, dynamic, minisym, sym)
+ bfd *abfd;
+ boolean dynamic;
+ const PTR minisym;
+ asymbol *sym;
+{
+ if (dynamic
+ || obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
+ return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
+
+ memset (sym, 0, sizeof (aout_symbol_type));
+
+ /* We call translate_symbol_table to translate a single symbol. */
+ if (! (NAME(aout,translate_symbol_table)
+ (abfd,
+ (aout_symbol_type *) sym,
+ (struct external_nlist *) minisym,
+ (bfd_size_type) 1,
+ obj_aout_external_strings (abfd),
+ obj_aout_external_string_size (abfd),
+ false)))
+ return NULL;
+
+ return sym;
+}
+
+/*
+ provided a BFD, a section and an offset into the section, calculate
+ and return the name of the source file and the line nearest to the
+ wanted location.
+*/
+
+boolean
+NAME(aout,find_nearest_line)
+ (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ /* Run down the file looking for the filename, function and linenumber */
+ asymbol **p;
+ CONST char *directory_name = NULL;
+ CONST char *main_file_name = NULL;
+ CONST char *current_file_name = NULL;
+ CONST char *line_file_name = NULL; /* Value of current_file_name at line number. */
+ CONST char *line_directory_name = NULL; /* Value of directory_name at line number. */
+ bfd_vma low_line_vma = 0;
+ bfd_vma low_func_vma = 0;
+ asymbol *func = 0;
+ size_t filelen, funclen;
+ char *buf;
+
+ *filename_ptr = abfd->filename;
+ *functionname_ptr = 0;
+ *line_ptr = 0;
+ if (symbols != (asymbol **)NULL) {
+ for (p = symbols; *p; p++) {
+ aout_symbol_type *q = (aout_symbol_type *)(*p);
+ next:
+ switch (q->type){
+ case N_TEXT:
+ /* If this looks like a file name symbol, and it comes after
+ the line number we have found so far, but before the
+ offset, then we have probably not found the right line
+ number. */
+ if (q->symbol.value <= offset
+ && ((q->symbol.value > low_line_vma
+ && (line_file_name != NULL
+ || *line_ptr != 0))
+ || (q->symbol.value > low_func_vma
+ && func != NULL)))
+ {
+ const char *symname;
+
+ symname = q->symbol.name;
+ if (strcmp (symname + strlen (symname) - 2, ".o") == 0)
+ {
+ if (q->symbol.value > low_line_vma)
+ {
+ *line_ptr = 0;
+ line_file_name = NULL;
+ }
+ if (q->symbol.value > low_func_vma)
+ func = NULL;
+ }
+ }
+ break;
+
+ case N_SO:
+ /* If this symbol is less than the offset, but greater than
+ the line number we have found so far, then we have not
+ found the right line number. */
+ if (q->symbol.value <= offset)
+ {
+ if (q->symbol.value > low_line_vma)
+ {
+ *line_ptr = 0;
+ line_file_name = NULL;
+ }
+ if (q->symbol.value > low_func_vma)
+ func = NULL;
+ }
+
+ main_file_name = current_file_name = q->symbol.name;
+ /* Look ahead to next symbol to check if that too is an N_SO. */
+ p++;
+ if (*p == NULL)
+ break;
+ q = (aout_symbol_type *)(*p);
+ if (q->type != (int)N_SO)
+ goto next;
+
+ /* Found a second N_SO First is directory; second is filename. */
+ directory_name = current_file_name;
+ main_file_name = current_file_name = q->symbol.name;
+ if (obj_textsec(abfd) != section)
+ goto done;
+ break;
+ case N_SOL:
+ current_file_name = q->symbol.name;
+ break;
+
+ case N_SLINE:
+
+ case N_DSLINE:
+ case N_BSLINE:
+ /* We'll keep this if it resolves nearer than the one we have
+ already. */
+ if (q->symbol.value >= low_line_vma
+ && q->symbol.value <= offset)
+ {
+ *line_ptr = q->desc;
+ low_line_vma = q->symbol.value;
+ line_file_name = current_file_name;
+ line_directory_name = directory_name;
+ }
+ break;
+ case N_FUN:
+ {
+ /* We'll keep this if it is nearer than the one we have already */
+ if (q->symbol.value >= low_func_vma &&
+ q->symbol.value <= offset) {
+ low_func_vma = q->symbol.value;
+ func = (asymbol *)q;
+ }
+ else if (q->symbol.value > offset)
+ goto done;
+ }
+ break;
+ }
+ }
+ }
+
+ done:
+ if (*line_ptr != 0)
+ {
+ main_file_name = line_file_name;
+ directory_name = line_directory_name;
+ }
+
+ if (main_file_name == NULL
+ || main_file_name[0] == '/'
+ || directory_name == NULL)
+ filelen = 0;
+ else
+ filelen = strlen (directory_name) + strlen (main_file_name);
+ if (func == NULL)
+ funclen = 0;
+ else
+ funclen = strlen (bfd_asymbol_name (func));
+
+ if (adata (abfd).line_buf != NULL)
+ free (adata (abfd).line_buf);
+ if (filelen + funclen == 0)
+ adata (abfd).line_buf = buf = NULL;
+ else
+ {
+ buf = (char *) bfd_malloc (filelen + funclen + 3);
+ adata (abfd).line_buf = buf;
+ if (buf == NULL)
+ return false;
+ }
+
+ if (main_file_name != NULL)
+ {
+ if (main_file_name[0] == '/' || directory_name == NULL)
+ *filename_ptr = main_file_name;
+ else
+ {
+ sprintf (buf, "%s%s", directory_name, main_file_name);
+ *filename_ptr = buf;
+ buf += filelen + 1;
+ }
+ }
+
+ if (func)
+ {
+ const char *function = func->name;
+ char *p;
+
+ /* The caller expects a symbol name. We actually have a
+ function name, without the leading underscore. Put the
+ underscore back in, so that the caller gets a symbol name. */
+ if (bfd_get_symbol_leading_char (abfd) == '\0')
+ strcpy (buf, function);
+ else
+ {
+ buf[0] = bfd_get_symbol_leading_char (abfd);
+ strcpy (buf + 1, function);
+ }
+ /* Have to remove : stuff */
+ p = strchr (buf, ':');
+ if (p != NULL)
+ *p = '\0';
+ *functionname_ptr = buf;
+ }
+
+ return true;
+}
+
+/*ARGSUSED*/
+int
+NAME(aout,sizeof_headers) (abfd, execable)
+ bfd *abfd;
+ boolean execable;
+{
+ return adata(abfd).exec_bytes_size;
+}
+
+/* Free all information we have cached for this BFD. We can always
+ read it again later if we need it. */
+
+boolean
+NAME(aout,bfd_free_cached_info) (abfd)
+ bfd *abfd;
+{
+ asection *o;
+
+ if (bfd_get_format (abfd) != bfd_object)
+ return true;
+
+#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
+ BFCI_FREE (obj_aout_symbols (abfd));
+#ifdef USE_MMAP
+ obj_aout_external_syms (abfd) = 0;
+ bfd_free_window (&obj_aout_sym_window (abfd));
+ bfd_free_window (&obj_aout_string_window (abfd));
+ obj_aout_external_strings (abfd) = 0;
+#else
+ BFCI_FREE (obj_aout_external_syms (abfd));
+ BFCI_FREE (obj_aout_external_strings (abfd));
+#endif
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ BFCI_FREE (o->relocation);
+#undef BFCI_FREE
+
+ return true;
+}
+
+/* a.out link code. */
+
+static boolean aout_link_add_object_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean aout_link_check_archive_element
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *));
+static boolean aout_link_free_symbols PARAMS ((bfd *));
+static boolean aout_link_check_ar_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
+static boolean aout_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Routine to create an entry in an a.out link hash table. */
+
+struct bfd_hash_entry *
+NAME(aout,link_hash_newfunc) (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct aout_link_hash_entry *ret = (struct aout_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct aout_link_hash_entry *) NULL)
+ ret = ((struct aout_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
+ if (ret == (struct aout_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct aout_link_hash_entry *)
+ _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret)
+ {
+ /* Set local fields. */
+ ret->written = false;
+ ret->indx = -1;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize an a.out link hash table. */
+
+boolean
+NAME(aout,link_hash_table_init) (table, abfd, newfunc)
+ struct aout_link_hash_table *table;
+ bfd *abfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+}
+
+/* Create an a.out link hash table. */
+
+struct bfd_link_hash_table *
+NAME(aout,link_hash_table_create) (abfd)
+ bfd *abfd;
+{
+ struct aout_link_hash_table *ret;
+
+ ret = ((struct aout_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
+ if (ret == NULL)
+ return (struct bfd_link_hash_table *) NULL;
+ if (! NAME(aout,link_hash_table_init) (ret, abfd,
+ NAME(aout,link_hash_newfunc)))
+ {
+ free (ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+ return &ret->root;
+}
+
+/* Given an a.out BFD, add symbols to the global hash table as
+ appropriate. */
+
+boolean
+NAME(aout,link_add_symbols) (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_object:
+ return aout_link_add_object_symbols (abfd, info);
+ case bfd_archive:
+ return _bfd_generic_link_add_archive_symbols
+ (abfd, info, aout_link_check_archive_element);
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+}
+
+/* Add symbols from an a.out object file. */
+
+static boolean
+aout_link_add_object_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (! aout_get_external_symbols (abfd))
+ return false;
+ if (! aout_link_add_symbols (abfd, info))
+ return false;
+ if (! info->keep_memory)
+ {
+ if (! aout_link_free_symbols (abfd))
+ return false;
+ }
+ return true;
+}
+
+/* Check a single archive element to see if we need to include it in
+ the link. *PNEEDED is set according to whether this element is
+ needed in the link or not. This is called from
+ _bfd_generic_link_add_archive_symbols. */
+
+static boolean
+aout_link_check_archive_element (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ if (! aout_get_external_symbols (abfd))
+ return false;
+
+ if (! aout_link_check_ar_symbols (abfd, info, pneeded))
+ return false;
+
+ if (*pneeded)
+ {
+ if (! aout_link_add_symbols (abfd, info))
+ return false;
+ }
+
+ if (! info->keep_memory || ! *pneeded)
+ {
+ if (! aout_link_free_symbols (abfd))
+ return false;
+ }
+
+ return true;
+}
+
+/* Free up the internal symbols read from an a.out file. */
+
+static boolean
+aout_link_free_symbols (abfd)
+ bfd *abfd;
+{
+ if (obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
+ {
+#ifdef USE_MMAP
+ bfd_free_window (&obj_aout_sym_window (abfd));
+#else
+ free ((PTR) obj_aout_external_syms (abfd));
+#endif
+ obj_aout_external_syms (abfd) = (struct external_nlist *) NULL;
+ }
+ if (obj_aout_external_strings (abfd) != (char *) NULL)
+ {
+#ifdef USE_MMAP
+ bfd_free_window (&obj_aout_string_window (abfd));
+#else
+ free ((PTR) obj_aout_external_strings (abfd));
+#endif
+ obj_aout_external_strings (abfd) = (char *) NULL;
+ }
+ return true;
+}
+
+/* Look through the internal symbols to see if this object file should
+ be included in the link. We should include this object file if it
+ defines any symbols which are currently undefined. If this object
+ file defines a common symbol, then we may adjust the size of the
+ known symbol but we do not include the object file in the link
+ (unless there is some other reason to include it). */
+
+static boolean
+aout_link_check_ar_symbols (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ register struct external_nlist *p;
+ struct external_nlist *pend;
+ char *strings;
+
+ *pneeded = false;
+
+ /* Look through all the symbols. */
+ p = obj_aout_external_syms (abfd);
+ pend = p + obj_aout_external_sym_count (abfd);
+ strings = obj_aout_external_strings (abfd);
+ for (; p < pend; p++)
+ {
+ int type = bfd_h_get_8 (abfd, p->e_type);
+ const char *name;
+ struct bfd_link_hash_entry *h;
+
+ /* Ignore symbols that are not externally visible. This is an
+ optimization only, as we check the type more thoroughly
+ below. */
+ if (((type & N_EXT) == 0
+ || (type & N_STAB) != 0
+ || type == N_FN)
+ && type != N_WEAKA
+ && type != N_WEAKT
+ && type != N_WEAKD
+ && type != N_WEAKB)
+ {
+ if (type == N_WARNING
+ || type == N_INDR)
+ ++p;
+ continue;
+ }
+
+ name = strings + GET_WORD (abfd, p->e_strx);
+ h = bfd_link_hash_lookup (info->hash, name, false, false, true);
+
+ /* We are only interested in symbols that are currently
+ undefined or common. */
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || (h->type != bfd_link_hash_undefined
+ && h->type != bfd_link_hash_common))
+ {
+ if (type == (N_INDR | N_EXT))
+ ++p;
+ continue;
+ }
+
+ if (type == (N_TEXT | N_EXT)
+ || type == (N_DATA | N_EXT)
+ || type == (N_BSS | N_EXT)
+ || type == (N_ABS | N_EXT)
+ || type == (N_INDR | N_EXT))
+ {
+ /* This object file defines this symbol. We must link it
+ in. This is true regardless of whether the current
+ definition of the symbol is undefined or common. If the
+ current definition is common, we have a case in which we
+ have already seen an object file including
+ int a;
+ and this object file from the archive includes
+ int a = 5;
+ In such a case we must include this object file.
+
+ FIXME: The SunOS 4.1.3 linker will pull in the archive
+ element if the symbol is defined in the .data section,
+ but not if it is defined in the .text section. That
+ seems a bit crazy to me, and I haven't implemented it.
+ However, it might be correct. */
+ if (! (*info->callbacks->add_archive_element) (info, abfd, name))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+
+ if (type == (N_UNDF | N_EXT))
+ {
+ bfd_vma value;
+
+ value = GET_WORD (abfd, p->e_value);
+ if (value != 0)
+ {
+ /* This symbol is common in the object from the archive
+ file. */
+ if (h->type == bfd_link_hash_undefined)
+ {
+ bfd *symbfd;
+ unsigned int power;
+
+ symbfd = h->u.undef.abfd;
+ if (symbfd == (bfd *) NULL)
+ {
+ /* This symbol was created as undefined from
+ outside BFD. We assume that we should link
+ in the object file. This is done for the -u
+ option in the linker. */
+ if (! (*info->callbacks->add_archive_element) (info,
+ abfd,
+ name))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+ /* Turn the current link symbol into a common
+ symbol. It is already on the undefs list. */
+ h->type = bfd_link_hash_common;
+ h->u.c.p = ((struct bfd_link_hash_common_entry *)
+ bfd_hash_allocate (&info->hash->table,
+ sizeof (struct bfd_link_hash_common_entry)));
+ if (h->u.c.p == NULL)
+ return false;
+
+ h->u.c.size = value;
+
+ /* FIXME: This isn't quite right. The maximum
+ alignment of a common symbol should be set by the
+ architecture of the output file, not of the input
+ file. */
+ power = bfd_log2 (value);
+ if (power > bfd_get_arch_info (abfd)->section_align_power)
+ power = bfd_get_arch_info (abfd)->section_align_power;
+ h->u.c.p->alignment_power = power;
+
+ h->u.c.p->section = bfd_make_section_old_way (symbfd,
+ "COMMON");
+ }
+ else
+ {
+ /* Adjust the size of the common symbol if
+ necessary. */
+ if (value > h->u.c.size)
+ h->u.c.size = value;
+ }
+ }
+ }
+
+ if (type == N_WEAKA
+ || type == N_WEAKT
+ || type == N_WEAKD
+ || type == N_WEAKB)
+ {
+ /* This symbol is weak but defined. We must pull it in if
+ the current link symbol is undefined, but we don't want
+ it if the current link symbol is common. */
+ if (h->type == bfd_link_hash_undefined)
+ {
+ if (! (*info->callbacks->add_archive_element) (info, abfd, name))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+ }
+ }
+
+ /* We do not need this object file. */
+ return true;
+}
+
+/* Add all symbols from an object file to the hash table. */
+
+static boolean
+aout_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
+ const char *, flagword, asection *,
+ bfd_vma, const char *, boolean,
+ boolean,
+ struct bfd_link_hash_entry **));
+ struct external_nlist *syms;
+ bfd_size_type sym_count;
+ char *strings;
+ boolean copy;
+ struct aout_link_hash_entry **sym_hash;
+ register struct external_nlist *p;
+ struct external_nlist *pend;
+
+ syms = obj_aout_external_syms (abfd);
+ sym_count = obj_aout_external_sym_count (abfd);
+ strings = obj_aout_external_strings (abfd);
+ if (info->keep_memory)
+ copy = false;
+ else
+ copy = true;
+
+ if (aout_backend_info (abfd)->add_dynamic_symbols != NULL)
+ {
+ if (! ((*aout_backend_info (abfd)->add_dynamic_symbols)
+ (abfd, info, &syms, &sym_count, &strings)))
+ return false;
+ }
+
+ /* We keep a list of the linker hash table entries that correspond
+ to particular symbols. We could just look them up in the hash
+ table, but keeping the list is more efficient. Perhaps this
+ should be conditional on info->keep_memory. */
+ sym_hash = ((struct aout_link_hash_entry **)
+ bfd_alloc (abfd,
+ ((size_t) sym_count
+ * sizeof (struct aout_link_hash_entry *))));
+ if (sym_hash == NULL && sym_count != 0)
+ return false;
+ obj_aout_sym_hashes (abfd) = sym_hash;
+
+ add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
+ if (add_one_symbol == NULL)
+ add_one_symbol = _bfd_generic_link_add_one_symbol;
+
+ p = syms;
+ pend = p + sym_count;
+ for (; p < pend; p++, sym_hash++)
+ {
+ int type;
+ const char *name;
+ bfd_vma value;
+ asection *section;
+ flagword flags;
+ const char *string;
+
+ *sym_hash = NULL;
+
+ type = bfd_h_get_8 (abfd, p->e_type);
+
+ /* Ignore debugging symbols. */
+ if ((type & N_STAB) != 0)
+ continue;
+
+ name = strings + GET_WORD (abfd, p->e_strx);
+ value = GET_WORD (abfd, p->e_value);
+ flags = BSF_GLOBAL;
+ string = NULL;
+ switch (type)
+ {
+ default:
+ abort ();
+
+ case N_UNDF:
+ case N_ABS:
+ case N_TEXT:
+ case N_DATA:
+ case N_BSS:
+ case N_FN_SEQ:
+ case N_COMM:
+ case N_SETV:
+ case N_FN:
+ /* Ignore symbols that are not externally visible. */
+ continue;
+ case N_INDR:
+ /* Ignore local indirect symbol. */
+ ++p;
+ ++sym_hash;
+ continue;
+
+ case N_UNDF | N_EXT:
+ if (value == 0)
+ {
+ section = bfd_und_section_ptr;
+ flags = 0;
+ }
+ else
+ section = bfd_com_section_ptr;
+ break;
+ case N_ABS | N_EXT:
+ section = bfd_abs_section_ptr;
+ break;
+ case N_TEXT | N_EXT:
+ section = obj_textsec (abfd);
+ value -= bfd_get_section_vma (abfd, section);
+ break;
+ case N_DATA | N_EXT:
+ case N_SETV | N_EXT:
+ /* Treat N_SETV symbols as N_DATA symbol; see comment in
+ translate_from_native_sym_flags. */
+ section = obj_datasec (abfd);
+ value -= bfd_get_section_vma (abfd, section);
+ break;
+ case N_BSS | N_EXT:
+ section = obj_bsssec (abfd);
+ value -= bfd_get_section_vma (abfd, section);
+ break;
+ case N_INDR | N_EXT:
+ /* An indirect symbol. The next symbol is the symbol
+ which this one really is. */
+ BFD_ASSERT (p + 1 < pend);
+ ++p;
+ string = strings + GET_WORD (abfd, p->e_strx);
+ section = bfd_ind_section_ptr;
+ flags |= BSF_INDIRECT;
+ break;
+ case N_COMM | N_EXT:
+ section = bfd_com_section_ptr;
+ break;
+ case N_SETA: case N_SETA | N_EXT:
+ section = bfd_abs_section_ptr;
+ flags |= BSF_CONSTRUCTOR;
+ break;
+ case N_SETT: case N_SETT | N_EXT:
+ section = obj_textsec (abfd);
+ flags |= BSF_CONSTRUCTOR;
+ value -= bfd_get_section_vma (abfd, section);
+ break;
+ case N_SETD: case N_SETD | N_EXT:
+ section = obj_datasec (abfd);
+ flags |= BSF_CONSTRUCTOR;
+ value -= bfd_get_section_vma (abfd, section);
+ break;
+ case N_SETB: case N_SETB | N_EXT:
+ section = obj_bsssec (abfd);
+ flags |= BSF_CONSTRUCTOR;
+ value -= bfd_get_section_vma (abfd, section);
+ break;
+ case N_WARNING:
+ /* A warning symbol. The next symbol is the one to warn
+ about. */
+ BFD_ASSERT (p + 1 < pend);
+ ++p;
+ string = name;
+ name = strings + GET_WORD (abfd, p->e_strx);
+ section = bfd_und_section_ptr;
+ flags |= BSF_WARNING;
+ break;
+ case N_WEAKU:
+ section = bfd_und_section_ptr;
+ flags = BSF_WEAK;
+ break;
+ case N_WEAKA:
+ section = bfd_abs_section_ptr;
+ flags = BSF_WEAK;
+ break;
+ case N_WEAKT:
+ section = obj_textsec (abfd);
+ value -= bfd_get_section_vma (abfd, section);
+ flags = BSF_WEAK;
+ break;
+ case N_WEAKD:
+ section = obj_datasec (abfd);
+ value -= bfd_get_section_vma (abfd, section);
+ flags = BSF_WEAK;
+ break;
+ case N_WEAKB:
+ section = obj_bsssec (abfd);
+ value -= bfd_get_section_vma (abfd, section);
+ flags = BSF_WEAK;
+ break;
+ }
+
+ if (! ((*add_one_symbol)
+ (info, abfd, name, flags, section, value, string, copy, false,
+ (struct bfd_link_hash_entry **) sym_hash)))
+ return false;
+
+ /* Restrict the maximum alignment of a common symbol based on
+ the architecture, since a.out has no way to represent
+ alignment requirements of a section in a .o file. FIXME:
+ This isn't quite right: it should use the architecture of the
+ output file, not the input files. */
+ if ((*sym_hash)->root.type == bfd_link_hash_common
+ && ((*sym_hash)->root.u.c.p->alignment_power >
+ bfd_get_arch_info (abfd)->section_align_power))
+ (*sym_hash)->root.u.c.p->alignment_power =
+ bfd_get_arch_info (abfd)->section_align_power;
+
+ /* If this is a set symbol, and we are not building sets, then
+ it is possible for the hash entry to not have been set. In
+ such a case, treat the symbol as not globally defined. */
+ if ((*sym_hash)->root.type == bfd_link_hash_new)
+ {
+ BFD_ASSERT ((flags & BSF_CONSTRUCTOR) != 0);
+ *sym_hash = NULL;
+ }
+
+ if (type == (N_INDR | N_EXT) || type == N_WARNING)
+ ++sym_hash;
+ }
+
+ return true;
+}
+
+/* A hash table used for header files with N_BINCL entries. */
+
+struct aout_link_includes_table
+{
+ struct bfd_hash_table root;
+};
+
+/* A linked list of totals that we have found for a particular header
+ file. */
+
+struct aout_link_includes_totals
+{
+ struct aout_link_includes_totals *next;
+ bfd_vma total;
+};
+
+/* An entry in the header file hash table. */
+
+struct aout_link_includes_entry
+{
+ struct bfd_hash_entry root;
+ /* List of totals we have found for this file. */
+ struct aout_link_includes_totals *totals;
+};
+
+/* Look up an entry in an the header file hash table. */
+
+#define aout_link_includes_lookup(table, string, create, copy) \
+ ((struct aout_link_includes_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+/* During the final link step we need to pass around a bunch of
+ information, so we do it in an instance of this structure. */
+
+struct aout_final_link_info
+{
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* Output bfd. */
+ bfd *output_bfd;
+ /* Reloc file positions. */
+ file_ptr treloff, dreloff;
+ /* File position of symbols. */
+ file_ptr symoff;
+ /* String table. */
+ struct bfd_strtab_hash *strtab;
+ /* Header file hash table. */
+ struct aout_link_includes_table includes;
+ /* A buffer large enough to hold the contents of any section. */
+ bfd_byte *contents;
+ /* A buffer large enough to hold the relocs of any section. */
+ PTR relocs;
+ /* A buffer large enough to hold the symbol map of any input BFD. */
+ int *symbol_map;
+ /* A buffer large enough to hold output symbols of any input BFD. */
+ struct external_nlist *output_syms;
+};
+
+static struct bfd_hash_entry *aout_link_includes_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static boolean aout_link_input_bfd
+ PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
+static boolean aout_link_write_symbols
+ PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
+static boolean aout_link_write_other_symbol
+ PARAMS ((struct aout_link_hash_entry *, PTR));
+static boolean aout_link_input_section
+ PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
+ asection *input_section, file_ptr *reloff_ptr,
+ bfd_size_type rel_size));
+static boolean aout_link_input_section_std
+ PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
+ asection *input_section, struct reloc_std_external *,
+ bfd_size_type rel_size, bfd_byte *contents));
+static boolean aout_link_input_section_ext
+ PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
+ asection *input_section, struct reloc_ext_external *,
+ bfd_size_type rel_size, bfd_byte *contents));
+static INLINE asection *aout_reloc_index_to_section
+ PARAMS ((bfd *, int));
+static boolean aout_link_reloc_link_order
+ PARAMS ((struct aout_final_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* The function to create a new entry in the header file hash table. */
+
+static struct bfd_hash_entry *
+aout_link_includes_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct aout_link_includes_entry *ret =
+ (struct aout_link_includes_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct aout_link_includes_entry *) NULL)
+ ret = ((struct aout_link_includes_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct aout_link_includes_entry)));
+ if (ret == (struct aout_link_includes_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct aout_link_includes_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+ if (ret)
+ {
+ /* Set local fields. */
+ ret->totals = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Do the final link step. This is called on the output BFD. The
+ INFO structure should point to a list of BFDs linked through the
+ link_next field which can be used to find each BFD which takes part
+ in the output. Also, each section in ABFD should point to a list
+ of bfd_link_order structures which list all the input sections for
+ the output section. */
+
+boolean
+NAME(aout,final_link) (abfd, info, callback)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ void (*callback) PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+{
+ struct aout_final_link_info aout_info;
+ boolean includes_hash_initialized = false;
+ register bfd *sub;
+ bfd_size_type trsize, drsize;
+ size_t max_contents_size;
+ size_t max_relocs_size;
+ size_t max_sym_count;
+ bfd_size_type text_size;
+ file_ptr text_end;
+ register struct bfd_link_order *p;
+ asection *o;
+ boolean have_link_order_relocs;
+
+ if (info->shared)
+ abfd->flags |= DYNAMIC;
+
+ aout_info.info = info;
+ aout_info.output_bfd = abfd;
+ aout_info.contents = NULL;
+ aout_info.relocs = NULL;
+ aout_info.symbol_map = NULL;
+ aout_info.output_syms = NULL;
+
+ if (! bfd_hash_table_init_n (&aout_info.includes.root,
+ aout_link_includes_newfunc,
+ 251))
+ goto error_return;
+ includes_hash_initialized = true;
+
+ /* Figure out the largest section size. Also, if generating
+ relocateable output, count the relocs. */
+ trsize = 0;
+ drsize = 0;
+ max_contents_size = 0;
+ max_relocs_size = 0;
+ max_sym_count = 0;
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ size_t sz;
+
+ if (info->relocateable)
+ {
+ if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
+ {
+ trsize += exec_hdr (sub)->a_trsize;
+ drsize += exec_hdr (sub)->a_drsize;
+ }
+ else
+ {
+ /* FIXME: We need to identify the .text and .data sections
+ and call get_reloc_upper_bound and canonicalize_reloc to
+ work out the number of relocs needed, and then multiply
+ by the reloc size. */
+ (*_bfd_error_handler)
+ (_("%s: relocateable link from %s to %s not supported"),
+ bfd_get_filename (abfd),
+ sub->xvec->name, abfd->xvec->name);
+ bfd_set_error (bfd_error_invalid_operation);
+ goto error_return;
+ }
+ }
+
+ if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
+ {
+ sz = bfd_section_size (sub, obj_textsec (sub));
+ if (sz > max_contents_size)
+ max_contents_size = sz;
+ sz = bfd_section_size (sub, obj_datasec (sub));
+ if (sz > max_contents_size)
+ max_contents_size = sz;
+
+ sz = exec_hdr (sub)->a_trsize;
+ if (sz > max_relocs_size)
+ max_relocs_size = sz;
+ sz = exec_hdr (sub)->a_drsize;
+ if (sz > max_relocs_size)
+ max_relocs_size = sz;
+
+ sz = obj_aout_external_sym_count (sub);
+ if (sz > max_sym_count)
+ max_sym_count = sz;
+ }
+ }
+
+ if (info->relocateable)
+ {
+ if (obj_textsec (abfd) != (asection *) NULL)
+ trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
+ ->link_order_head)
+ * obj_reloc_entry_size (abfd));
+ if (obj_datasec (abfd) != (asection *) NULL)
+ drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
+ ->link_order_head)
+ * obj_reloc_entry_size (abfd));
+ }
+
+ exec_hdr (abfd)->a_trsize = trsize;
+ exec_hdr (abfd)->a_drsize = drsize;
+
+ exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
+
+ /* Adjust the section sizes and vmas according to the magic number.
+ This sets a_text, a_data and a_bss in the exec_hdr and sets the
+ filepos for each section. */
+ if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
+ goto error_return;
+
+ /* The relocation and symbol file positions differ among a.out
+ targets. We are passed a callback routine from the backend
+ specific code to handle this.
+ FIXME: At this point we do not know how much space the symbol
+ table will require. This will not work for any (nonstandard)
+ a.out target that needs to know the symbol table size before it
+ can compute the relocation file positions. This may or may not
+ be the case for the hp300hpux target, for example. */
+ (*callback) (abfd, &aout_info.treloff, &aout_info.dreloff,
+ &aout_info.symoff);
+ obj_textsec (abfd)->rel_filepos = aout_info.treloff;
+ obj_datasec (abfd)->rel_filepos = aout_info.dreloff;
+ obj_sym_filepos (abfd) = aout_info.symoff;
+
+ /* We keep a count of the symbols as we output them. */
+ obj_aout_external_sym_count (abfd) = 0;
+
+ /* We accumulate the string table as we write out the symbols. */
+ aout_info.strtab = _bfd_stringtab_init ();
+ if (aout_info.strtab == NULL)
+ goto error_return;
+
+ /* Allocate buffers to hold section contents and relocs. */
+ aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+ aout_info.relocs = (PTR) bfd_malloc (max_relocs_size);
+ aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *));
+ aout_info.output_syms = ((struct external_nlist *)
+ bfd_malloc ((max_sym_count + 1)
+ * sizeof (struct external_nlist)));
+ if ((aout_info.contents == NULL && max_contents_size != 0)
+ || (aout_info.relocs == NULL && max_relocs_size != 0)
+ || (aout_info.symbol_map == NULL && max_sym_count != 0)
+ || aout_info.output_syms == NULL)
+ goto error_return;
+
+ /* If we have a symbol named __DYNAMIC, force it out now. This is
+ required by SunOS. Doing this here rather than in sunos.c is a
+ hack, but it's easier than exporting everything which would be
+ needed. */
+ {
+ struct aout_link_hash_entry *h;
+
+ h = aout_link_hash_lookup (aout_hash_table (info), "__DYNAMIC",
+ false, false, false);
+ if (h != NULL)
+ aout_link_write_other_symbol (h, &aout_info);
+ }
+
+ /* The most time efficient way to do the link would be to read all
+ the input object files into memory and then sort out the
+ information into the output file. Unfortunately, that will
+ probably use too much memory. Another method would be to step
+ through everything that composes the text section and write it
+ out, and then everything that composes the data section and write
+ it out, and then write out the relocs, and then write out the
+ symbols. Unfortunately, that requires reading stuff from each
+ input file several times, and we will not be able to keep all the
+ input files open simultaneously, and reopening them will be slow.
+
+ What we do is basically process one input file at a time. We do
+ everything we need to do with an input file once--copy over the
+ section contents, handle the relocation information, and write
+ out the symbols--and then we throw away the information we read
+ from it. This approach requires a lot of lseeks of the output
+ file, which is unfortunate but still faster than reopening a lot
+ of files.
+
+ We use the output_has_begun field of the input BFDs to see
+ whether we have already handled it. */
+ for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
+ sub->output_has_begun = false;
+
+ /* Mark all sections which are to be included in the link. This
+ will normally be every section. We need to do this so that we
+ can identify any sections which the linker has decided to not
+ include. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order)
+ p->u.indirect.section->linker_mark = true;
+ }
+ }
+
+ have_link_order_relocs = false;
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order
+ && (bfd_get_flavour (p->u.indirect.section->owner)
+ == bfd_target_aout_flavour))
+ {
+ bfd *input_bfd;
+
+ input_bfd = p->u.indirect.section->owner;
+ if (! input_bfd->output_has_begun)
+ {
+ if (! aout_link_input_bfd (&aout_info, input_bfd))
+ goto error_return;
+ input_bfd->output_has_begun = true;
+ }
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ /* These are handled below. */
+ have_link_order_relocs = true;
+ }
+ else
+ {
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ goto error_return;
+ }
+ }
+ }
+
+ /* Write out any symbols that we have not already written out. */
+ aout_link_hash_traverse (aout_hash_table (info),
+ aout_link_write_other_symbol,
+ (PTR) &aout_info);
+
+ /* Now handle any relocs we were asked to create by the linker.
+ These did not come from any input file. We must do these after
+ we have written out all the symbols, so that we know the symbol
+ indices to use. */
+ if (have_link_order_relocs)
+ {
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ if (! aout_link_reloc_link_order (&aout_info, o, p))
+ goto error_return;
+ }
+ }
+ }
+ }
+
+ if (aout_info.contents != NULL)
+ {
+ free (aout_info.contents);
+ aout_info.contents = NULL;
+ }
+ if (aout_info.relocs != NULL)
+ {
+ free (aout_info.relocs);
+ aout_info.relocs = NULL;
+ }
+ if (aout_info.symbol_map != NULL)
+ {
+ free (aout_info.symbol_map);
+ aout_info.symbol_map = NULL;
+ }
+ if (aout_info.output_syms != NULL)
+ {
+ free (aout_info.output_syms);
+ aout_info.output_syms = NULL;
+ }
+ if (includes_hash_initialized)
+ {
+ bfd_hash_table_free (&aout_info.includes.root);
+ includes_hash_initialized = false;
+ }
+
+ /* Finish up any dynamic linking we may be doing. */
+ if (aout_backend_info (abfd)->finish_dynamic_link != NULL)
+ {
+ if (! (*aout_backend_info (abfd)->finish_dynamic_link) (abfd, info))
+ goto error_return;
+ }
+
+ /* Update the header information. */
+ abfd->symcount = obj_aout_external_sym_count (abfd);
+ exec_hdr (abfd)->a_syms = abfd->symcount * EXTERNAL_NLIST_SIZE;
+ obj_str_filepos (abfd) = obj_sym_filepos (abfd) + exec_hdr (abfd)->a_syms;
+ obj_textsec (abfd)->reloc_count =
+ exec_hdr (abfd)->a_trsize / obj_reloc_entry_size (abfd);
+ obj_datasec (abfd)->reloc_count =
+ exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd);
+
+ /* Write out the string table, unless there are no symbols. */
+ if (abfd->symcount > 0)
+ {
+ if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
+ || ! emit_stringtab (abfd, aout_info.strtab))
+ goto error_return;
+ }
+ else if (obj_textsec (abfd)->reloc_count == 0
+ && obj_datasec (abfd)->reloc_count == 0)
+ {
+ bfd_byte b;
+
+ b = 0;
+ if (bfd_seek (abfd,
+ (obj_datasec (abfd)->filepos
+ + exec_hdr (abfd)->a_data
+ - 1),
+ SEEK_SET) != 0
+ || bfd_write (&b, 1, 1, abfd) != 1)
+ goto error_return;
+ }
+
+ return true;
+
+ error_return:
+ if (aout_info.contents != NULL)
+ free (aout_info.contents);
+ if (aout_info.relocs != NULL)
+ free (aout_info.relocs);
+ if (aout_info.symbol_map != NULL)
+ free (aout_info.symbol_map);
+ if (aout_info.output_syms != NULL)
+ free (aout_info.output_syms);
+ if (includes_hash_initialized)
+ bfd_hash_table_free (&aout_info.includes.root);
+ return false;
+}
+
+/* Link an a.out input BFD into the output file. */
+
+static boolean
+aout_link_input_bfd (finfo, input_bfd)
+ struct aout_final_link_info *finfo;
+ bfd *input_bfd;
+{
+ bfd_size_type sym_count;
+
+ BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
+
+ /* If this is a dynamic object, it may need special handling. */
+ if ((input_bfd->flags & DYNAMIC) != 0
+ && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
+ {
+ return ((*aout_backend_info (input_bfd)->link_dynamic_object)
+ (finfo->info, input_bfd));
+ }
+
+ /* Get the symbols. We probably have them already, unless
+ finfo->info->keep_memory is false. */
+ if (! aout_get_external_symbols (input_bfd))
+ return false;
+
+ sym_count = obj_aout_external_sym_count (input_bfd);
+
+ /* Write out the symbols and get a map of the new indices. The map
+ is placed into finfo->symbol_map. */
+ if (! aout_link_write_symbols (finfo, input_bfd))
+ return false;
+
+ /* Relocate and write out the sections. These functions use the
+ symbol map created by aout_link_write_symbols. The linker_mark
+ field will be set if these sections are to be included in the
+ link, which will normally be the case. */
+ if (obj_textsec (input_bfd)->linker_mark)
+ {
+ if (! aout_link_input_section (finfo, input_bfd,
+ obj_textsec (input_bfd),
+ &finfo->treloff,
+ exec_hdr (input_bfd)->a_trsize))
+ return false;
+ }
+ if (obj_datasec (input_bfd)->linker_mark)
+ {
+ if (! aout_link_input_section (finfo, input_bfd,
+ obj_datasec (input_bfd),
+ &finfo->dreloff,
+ exec_hdr (input_bfd)->a_drsize))
+ return false;
+ }
+
+ /* If we are not keeping memory, we don't need the symbols any
+ longer. We still need them if we are keeping memory, because the
+ strings in the hash table point into them. */
+ if (! finfo->info->keep_memory)
+ {
+ if (! aout_link_free_symbols (input_bfd))
+ return false;
+ }
+
+ return true;
+}
+
+/* Adjust and write out the symbols for an a.out file. Set the new
+ symbol indices into a symbol_map. */
+
+static boolean
+aout_link_write_symbols (finfo, input_bfd)
+ struct aout_final_link_info *finfo;
+ bfd *input_bfd;
+{
+ bfd *output_bfd;
+ bfd_size_type sym_count;
+ char *strings;
+ enum bfd_link_strip strip;
+ enum bfd_link_discard discard;
+ struct external_nlist *outsym;
+ bfd_size_type strtab_index;
+ register struct external_nlist *sym;
+ struct external_nlist *sym_end;
+ struct aout_link_hash_entry **sym_hash;
+ int *symbol_map;
+ boolean pass;
+ boolean skip_next;
+
+ output_bfd = finfo->output_bfd;
+ sym_count = obj_aout_external_sym_count (input_bfd);
+ strings = obj_aout_external_strings (input_bfd);
+ strip = finfo->info->strip;
+ discard = finfo->info->discard;
+ outsym = finfo->output_syms;
+
+ /* First write out a symbol for this object file, unless we are
+ discarding such symbols. */
+ if (strip != strip_all
+ && (strip != strip_some
+ || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
+ false, false) != NULL)
+ && discard != discard_all)
+ {
+ bfd_h_put_8 (output_bfd, N_TEXT, outsym->e_type);
+ bfd_h_put_8 (output_bfd, 0, outsym->e_other);
+ bfd_h_put_16 (output_bfd, (bfd_vma) 0, outsym->e_desc);
+ strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
+ input_bfd->filename, false);
+ if (strtab_index == (bfd_size_type) -1)
+ return false;
+ PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
+ PUT_WORD (output_bfd,
+ (bfd_get_section_vma (output_bfd,
+ obj_textsec (input_bfd)->output_section)
+ + obj_textsec (input_bfd)->output_offset),
+ outsym->e_value);
+ ++obj_aout_external_sym_count (output_bfd);
+ ++outsym;
+ }
+
+ pass = false;
+ skip_next = false;
+ sym = obj_aout_external_syms (input_bfd);
+ sym_end = sym + sym_count;
+ sym_hash = obj_aout_sym_hashes (input_bfd);
+ symbol_map = finfo->symbol_map;
+ memset (symbol_map, 0, sym_count * sizeof *symbol_map);
+ for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
+ {
+ const char *name;
+ int type;
+ struct aout_link_hash_entry *h;
+ boolean skip;
+ asection *symsec;
+ bfd_vma val = 0;
+ boolean copy;
+
+ /* We set *symbol_map to 0 above for all symbols. If it has
+ already been set to -1 for this symbol, it means that we are
+ discarding it because it appears in a duplicate header file.
+ See the N_BINCL code below. */
+ if (*symbol_map == -1)
+ continue;
+
+ /* Initialize *symbol_map to -1, which means that the symbol was
+ not copied into the output file. We will change it later if
+ we do copy the symbol over. */
+ *symbol_map = -1;
+
+ type = bfd_h_get_8 (input_bfd, sym->e_type);
+ name = strings + GET_WORD (input_bfd, sym->e_strx);
+
+ h = NULL;
+
+ if (pass)
+ {
+ /* Pass this symbol through. It is the target of an
+ indirect or warning symbol. */
+ val = GET_WORD (input_bfd, sym->e_value);
+ pass = false;
+ }
+ else if (skip_next)
+ {
+ /* Skip this symbol, which is the target of an indirect
+ symbol that we have changed to no longer be an indirect
+ symbol. */
+ skip_next = false;
+ continue;
+ }
+ else
+ {
+ struct aout_link_hash_entry *hresolve;
+
+ /* We have saved the hash table entry for this symbol, if
+ there is one. Note that we could just look it up again
+ in the hash table, provided we first check that it is an
+ external symbol. */
+ h = *sym_hash;
+
+ /* Use the name from the hash table, in case the symbol was
+ wrapped. */
+ if (h != NULL)
+ name = h->root.root.string;
+
+ /* If this is an indirect or warning symbol, then change
+ hresolve to the base symbol. We also change *sym_hash so
+ that the relocation routines relocate against the real
+ symbol. */
+ hresolve = h;
+ if (h != (struct aout_link_hash_entry *) NULL
+ && (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning))
+ {
+ hresolve = (struct aout_link_hash_entry *) h->root.u.i.link;
+ while (hresolve->root.type == bfd_link_hash_indirect
+ || hresolve->root.type == bfd_link_hash_warning)
+ hresolve = ((struct aout_link_hash_entry *)
+ hresolve->root.u.i.link);
+ *sym_hash = hresolve;
+ }
+
+ /* If the symbol has already been written out, skip it. */
+ if (h != (struct aout_link_hash_entry *) NULL
+ && h->root.type != bfd_link_hash_warning
+ && h->written)
+ {
+ if ((type & N_TYPE) == N_INDR
+ || type == N_WARNING)
+ skip_next = true;
+ *symbol_map = h->indx;
+ continue;
+ }
+
+ /* See if we are stripping this symbol. */
+ skip = false;
+ switch (strip)
+ {
+ case strip_none:
+ break;
+ case strip_debugger:
+ if ((type & N_STAB) != 0)
+ skip = true;
+ break;
+ case strip_some:
+ if (bfd_hash_lookup (finfo->info->keep_hash, name, false, false)
+ == NULL)
+ skip = true;
+ break;
+ case strip_all:
+ skip = true;
+ break;
+ }
+ if (skip)
+ {
+ if (h != (struct aout_link_hash_entry *) NULL)
+ h->written = true;
+ continue;
+ }
+
+ /* Get the value of the symbol. */
+ if ((type & N_TYPE) == N_TEXT
+ || type == N_WEAKT)
+ symsec = obj_textsec (input_bfd);
+ else if ((type & N_TYPE) == N_DATA
+ || type == N_WEAKD)
+ symsec = obj_datasec (input_bfd);
+ else if ((type & N_TYPE) == N_BSS
+ || type == N_WEAKB)
+ symsec = obj_bsssec (input_bfd);
+ else if ((type & N_TYPE) == N_ABS
+ || type == N_WEAKA)
+ symsec = bfd_abs_section_ptr;
+ else if (((type & N_TYPE) == N_INDR
+ && (hresolve == (struct aout_link_hash_entry *) NULL
+ || (hresolve->root.type != bfd_link_hash_defined
+ && hresolve->root.type != bfd_link_hash_defweak
+ && hresolve->root.type != bfd_link_hash_common)))
+ || type == N_WARNING)
+ {
+ /* Pass the next symbol through unchanged. The
+ condition above for indirect symbols is so that if
+ the indirect symbol was defined, we output it with
+ the correct definition so the debugger will
+ understand it. */
+ pass = true;
+ val = GET_WORD (input_bfd, sym->e_value);
+ symsec = NULL;
+ }
+ else if ((type & N_STAB) != 0)
+ {
+ val = GET_WORD (input_bfd, sym->e_value);
+ symsec = NULL;
+ }
+ else
+ {
+ /* If we get here with an indirect symbol, it means that
+ we are outputting it with a real definition. In such
+ a case we do not want to output the next symbol,
+ which is the target of the indirection. */
+ if ((type & N_TYPE) == N_INDR)
+ skip_next = true;
+
+ symsec = NULL;
+
+ /* We need to get the value from the hash table. We use
+ hresolve so that if we have defined an indirect
+ symbol we output the final definition. */
+ if (h == (struct aout_link_hash_entry *) NULL)
+ {
+ switch (type & N_TYPE)
+ {
+ case N_SETT:
+ symsec = obj_textsec (input_bfd);
+ break;
+ case N_SETD:
+ symsec = obj_datasec (input_bfd);
+ break;
+ case N_SETB:
+ symsec = obj_bsssec (input_bfd);
+ break;
+ case N_SETA:
+ symsec = bfd_abs_section_ptr;
+ break;
+ default:
+ val = 0;
+ break;
+ }
+ }
+ else if (hresolve->root.type == bfd_link_hash_defined
+ || hresolve->root.type == bfd_link_hash_defweak)
+ {
+ asection *input_section;
+ asection *output_section;
+
+ /* This case usually means a common symbol which was
+ turned into a defined symbol. */
+ input_section = hresolve->root.u.def.section;
+ output_section = input_section->output_section;
+ BFD_ASSERT (bfd_is_abs_section (output_section)
+ || output_section->owner == output_bfd);
+ val = (hresolve->root.u.def.value
+ + bfd_get_section_vma (output_bfd, output_section)
+ + input_section->output_offset);
+
+ /* Get the correct type based on the section. If
+ this is a constructed set, force it to be
+ globally visible. */
+ if (type == N_SETT
+ || type == N_SETD
+ || type == N_SETB
+ || type == N_SETA)
+ type |= N_EXT;
+
+ type &=~ N_TYPE;
+
+ if (output_section == obj_textsec (output_bfd))
+ type |= (hresolve->root.type == bfd_link_hash_defined
+ ? N_TEXT
+ : N_WEAKT);
+ else if (output_section == obj_datasec (output_bfd))
+ type |= (hresolve->root.type == bfd_link_hash_defined
+ ? N_DATA
+ : N_WEAKD);
+ else if (output_section == obj_bsssec (output_bfd))
+ type |= (hresolve->root.type == bfd_link_hash_defined
+ ? N_BSS
+ : N_WEAKB);
+ else
+ type |= (hresolve->root.type == bfd_link_hash_defined
+ ? N_ABS
+ : N_WEAKA);
+ }
+ else if (hresolve->root.type == bfd_link_hash_common)
+ val = hresolve->root.u.c.size;
+ else if (hresolve->root.type == bfd_link_hash_undefweak)
+ {
+ val = 0;
+ type = N_WEAKU;
+ }
+ else
+ val = 0;
+ }
+ if (symsec != (asection *) NULL)
+ val = (symsec->output_section->vma
+ + symsec->output_offset
+ + (GET_WORD (input_bfd, sym->e_value)
+ - symsec->vma));
+
+ /* If this is a global symbol set the written flag, and if
+ it is a local symbol see if we should discard it. */
+ if (h != (struct aout_link_hash_entry *) NULL)
+ {
+ h->written = true;
+ h->indx = obj_aout_external_sym_count (output_bfd);
+ }
+ else if ((type & N_TYPE) != N_SETT
+ && (type & N_TYPE) != N_SETD
+ && (type & N_TYPE) != N_SETB
+ && (type & N_TYPE) != N_SETA)
+ {
+ switch (discard)
+ {
+ case discard_none:
+ break;
+ case discard_l:
+ if ((type & N_STAB) == 0
+ && bfd_is_local_label_name (input_bfd, name))
+ skip = true;
+ break;
+ case discard_all:
+ skip = true;
+ break;
+ }
+ if (skip)
+ {
+ pass = false;
+ continue;
+ }
+ }
+
+ /* An N_BINCL symbol indicates the start of the stabs
+ entries for a header file. We need to scan ahead to the
+ next N_EINCL symbol, ignoring nesting, adding up all the
+ characters in the symbol names, not including the file
+ numbers in types (the first number after an open
+ parenthesis). */
+ if (type == N_BINCL)
+ {
+ struct external_nlist *incl_sym;
+ int nest;
+ struct aout_link_includes_entry *incl_entry;
+ struct aout_link_includes_totals *t;
+
+ val = 0;
+ nest = 0;
+ for (incl_sym = sym + 1; incl_sym < sym_end; incl_sym++)
+ {
+ int incl_type;
+
+ incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
+ if (incl_type == N_EINCL)
+ {
+ if (nest == 0)
+ break;
+ --nest;
+ }
+ else if (incl_type == N_BINCL)
+ ++nest;
+ else if (nest == 0)
+ {
+ const char *s;
+
+ s = strings + GET_WORD (input_bfd, incl_sym->e_strx);
+ for (; *s != '\0'; s++)
+ {
+ val += *s;
+ if (*s == '(')
+ {
+ /* Skip the file number. */
+ ++s;
+ while (isdigit ((unsigned char) *s))
+ ++s;
+ --s;
+ }
+ }
+ }
+ }
+
+ /* If we have already included a header file with the
+ same value, then replace this one with an N_EXCL
+ symbol. */
+ copy = ! finfo->info->keep_memory;
+ incl_entry = aout_link_includes_lookup (&finfo->includes,
+ name, true, copy);
+ if (incl_entry == NULL)
+ return false;
+ for (t = incl_entry->totals; t != NULL; t = t->next)
+ if (t->total == val)
+ break;
+ if (t == NULL)
+ {
+ /* This is the first time we have seen this header
+ file with this set of stabs strings. */
+ t = ((struct aout_link_includes_totals *)
+ bfd_hash_allocate (&finfo->includes.root,
+ sizeof *t));
+ if (t == NULL)
+ return false;
+ t->total = val;
+ t->next = incl_entry->totals;
+ incl_entry->totals = t;
+ }
+ else
+ {
+ int *incl_map;
+
+ /* This is a duplicate header file. We must change
+ it to be an N_EXCL entry, and mark all the
+ included symbols to prevent outputting them. */
+ type = N_EXCL;
+
+ nest = 0;
+ for (incl_sym = sym + 1, incl_map = symbol_map + 1;
+ incl_sym < sym_end;
+ incl_sym++, incl_map++)
+ {
+ int incl_type;
+
+ incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
+ if (incl_type == N_EINCL)
+ {
+ if (nest == 0)
+ {
+ *incl_map = -1;
+ break;
+ }
+ --nest;
+ }
+ else if (incl_type == N_BINCL)
+ ++nest;
+ else if (nest == 0)
+ *incl_map = -1;
+ }
+ }
+ }
+ }
+
+ /* Copy this symbol into the list of symbols we are going to
+ write out. */
+ bfd_h_put_8 (output_bfd, type, outsym->e_type);
+ bfd_h_put_8 (output_bfd, bfd_h_get_8 (input_bfd, sym->e_other),
+ outsym->e_other);
+ bfd_h_put_16 (output_bfd, bfd_h_get_16 (input_bfd, sym->e_desc),
+ outsym->e_desc);
+ copy = false;
+ if (! finfo->info->keep_memory)
+ {
+ /* name points into a string table which we are going to
+ free. If there is a hash table entry, use that string.
+ Otherwise, copy name into memory. */
+ if (h != (struct aout_link_hash_entry *) NULL)
+ name = h->root.root.string;
+ else
+ copy = true;
+ }
+ strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
+ name, copy);
+ if (strtab_index == (bfd_size_type) -1)
+ return false;
+ PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
+ PUT_WORD (output_bfd, val, outsym->e_value);
+ *symbol_map = obj_aout_external_sym_count (output_bfd);
+ ++obj_aout_external_sym_count (output_bfd);
+ ++outsym;
+ }
+
+ /* Write out the output symbols we have just constructed. */
+ if (outsym > finfo->output_syms)
+ {
+ bfd_size_type outsym_count;
+
+ if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
+ return false;
+ outsym_count = outsym - finfo->output_syms;
+ if (bfd_write ((PTR) finfo->output_syms,
+ (bfd_size_type) EXTERNAL_NLIST_SIZE,
+ (bfd_size_type) outsym_count, output_bfd)
+ != outsym_count * EXTERNAL_NLIST_SIZE)
+ return false;
+ finfo->symoff += outsym_count * EXTERNAL_NLIST_SIZE;
+ }
+
+ return true;
+}
+
+/* Write out a symbol that was not associated with an a.out input
+ object. */
+
+static boolean
+aout_link_write_other_symbol (h, data)
+ struct aout_link_hash_entry *h;
+ PTR data;
+{
+ struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
+ bfd *output_bfd;
+ int type;
+ bfd_vma val;
+ struct external_nlist outsym;
+ bfd_size_type indx;
+
+ output_bfd = finfo->output_bfd;
+
+ if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
+ {
+ if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
+ (output_bfd, finfo->info, h)))
+ {
+ /* FIXME: No way to handle errors. */
+ abort ();
+ }
+ }
+
+ if (h->written)
+ return true;
+
+ h->written = true;
+
+ /* An indx of -2 means the symbol must be written. */
+ if (h->indx != -2
+ && (finfo->info->strip == strip_all
+ || (finfo->info->strip == strip_some
+ && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
+ false, false) == NULL)))
+ return true;
+
+ switch (h->root.type)
+ {
+ default:
+ abort ();
+ /* Avoid variable not initialized warnings. */
+ return true;
+ case bfd_link_hash_new:
+ /* This can happen for set symbols when sets are not being
+ built. */
+ return true;
+ case bfd_link_hash_undefined:
+ type = N_UNDF | N_EXT;
+ val = 0;
+ break;
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section->output_section;
+ BFD_ASSERT (bfd_is_abs_section (sec)
+ || sec->owner == output_bfd);
+ if (sec == obj_textsec (output_bfd))
+ type = h->root.type == bfd_link_hash_defined ? N_TEXT : N_WEAKT;
+ else if (sec == obj_datasec (output_bfd))
+ type = h->root.type == bfd_link_hash_defined ? N_DATA : N_WEAKD;
+ else if (sec == obj_bsssec (output_bfd))
+ type = h->root.type == bfd_link_hash_defined ? N_BSS : N_WEAKB;
+ else
+ type = h->root.type == bfd_link_hash_defined ? N_ABS : N_WEAKA;
+ type |= N_EXT;
+ val = (h->root.u.def.value
+ + sec->vma
+ + h->root.u.def.section->output_offset);
+ }
+ break;
+ case bfd_link_hash_common:
+ type = N_UNDF | N_EXT;
+ val = h->root.u.c.size;
+ break;
+ case bfd_link_hash_undefweak:
+ type = N_WEAKU;
+ val = 0;
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+ /* FIXME: Ignore these for now. The circumstances under which
+ they should be written out are not clear to me. */
+ return true;
+ }
+
+ bfd_h_put_8 (output_bfd, type, outsym.e_type);
+ bfd_h_put_8 (output_bfd, 0, outsym.e_other);
+ bfd_h_put_16 (output_bfd, 0, outsym.e_desc);
+ indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
+ false);
+ if (indx == (bfd_size_type) -1)
+ {
+ /* FIXME: No way to handle errors. */
+ abort ();
+ }
+ PUT_WORD (output_bfd, indx, outsym.e_strx);
+ PUT_WORD (output_bfd, val, outsym.e_value);
+
+ if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
+ || bfd_write ((PTR) &outsym, (bfd_size_type) EXTERNAL_NLIST_SIZE,
+ (bfd_size_type) 1, output_bfd) != EXTERNAL_NLIST_SIZE)
+ {
+ /* FIXME: No way to handle errors. */
+ abort ();
+ }
+
+ finfo->symoff += EXTERNAL_NLIST_SIZE;
+ h->indx = obj_aout_external_sym_count (output_bfd);
+ ++obj_aout_external_sym_count (output_bfd);
+
+ return true;
+}
+
+/* Link an a.out section into the output file. */
+
+static boolean
+aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
+ rel_size)
+ struct aout_final_link_info *finfo;
+ bfd *input_bfd;
+ asection *input_section;
+ file_ptr *reloff_ptr;
+ bfd_size_type rel_size;
+{
+ bfd_size_type input_size;
+ PTR relocs;
+
+ /* Get the section contents. */
+ input_size = bfd_section_size (input_bfd, input_section);
+ if (! bfd_get_section_contents (input_bfd, input_section,
+ (PTR) finfo->contents,
+ (file_ptr) 0, input_size))
+ return false;
+
+ /* Read in the relocs if we haven't already done it. */
+ if (aout_section_data (input_section) != NULL
+ && aout_section_data (input_section)->relocs != NULL)
+ relocs = aout_section_data (input_section)->relocs;
+ else
+ {
+ relocs = finfo->relocs;
+ if (rel_size > 0)
+ {
+ if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
+ || bfd_read (relocs, 1, rel_size, input_bfd) != rel_size)
+ return false;
+ }
+ }
+
+ /* Relocate the section contents. */
+ if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
+ {
+ if (! aout_link_input_section_std (finfo, input_bfd, input_section,
+ (struct reloc_std_external *) relocs,
+ rel_size, finfo->contents))
+ return false;
+ }
+ else
+ {
+ if (! aout_link_input_section_ext (finfo, input_bfd, input_section,
+ (struct reloc_ext_external *) relocs,
+ rel_size, finfo->contents))
+ return false;
+ }
+
+ /* Write out the section contents. */
+ if (! bfd_set_section_contents (finfo->output_bfd,
+ input_section->output_section,
+ (PTR) finfo->contents,
+ input_section->output_offset,
+ input_size))
+ return false;
+
+ /* If we are producing relocateable output, the relocs were
+ modified, and we now write them out. */
+ if (finfo->info->relocateable && rel_size > 0)
+ {
+ if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
+ return false;
+ if (bfd_write (relocs, (bfd_size_type) 1, rel_size, finfo->output_bfd)
+ != rel_size)
+ return false;
+ *reloff_ptr += rel_size;
+
+ /* Assert that the relocs have not run into the symbols, and
+ that if these are the text relocs they have not run into the
+ data relocs. */
+ BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
+ && (reloff_ptr != &finfo->treloff
+ || (*reloff_ptr
+ <= obj_datasec (finfo->output_bfd)->rel_filepos)));
+ }
+
+ return true;
+}
+
+/* Get the section corresponding to a reloc index. */
+
+static INLINE asection *
+aout_reloc_index_to_section (abfd, indx)
+ bfd *abfd;
+ int indx;
+{
+ switch (indx & N_TYPE)
+ {
+ case N_TEXT:
+ return obj_textsec (abfd);
+ case N_DATA:
+ return obj_datasec (abfd);
+ case N_BSS:
+ return obj_bsssec (abfd);
+ case N_ABS:
+ case N_UNDF:
+ return bfd_abs_section_ptr;
+ default:
+ abort ();
+ }
+}
+
+/* Relocate an a.out section using standard a.out relocs. */
+
+static boolean
+aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
+ rel_size, contents)
+ struct aout_final_link_info *finfo;
+ bfd *input_bfd;
+ asection *input_section;
+ struct reloc_std_external *relocs;
+ bfd_size_type rel_size;
+ bfd_byte *contents;
+{
+ boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
+ bfd *, asection *,
+ struct aout_link_hash_entry *,
+ PTR, bfd_byte *, boolean *,
+ bfd_vma *));
+ bfd *output_bfd;
+ boolean relocateable;
+ struct external_nlist *syms;
+ char *strings;
+ struct aout_link_hash_entry **sym_hashes;
+ int *symbol_map;
+ bfd_size_type reloc_count;
+ register struct reloc_std_external *rel;
+ struct reloc_std_external *rel_end;
+
+ output_bfd = finfo->output_bfd;
+ check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
+
+ BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE);
+ BFD_ASSERT (input_bfd->xvec->header_byteorder
+ == output_bfd->xvec->header_byteorder);
+
+ relocateable = finfo->info->relocateable;
+ syms = obj_aout_external_syms (input_bfd);
+ strings = obj_aout_external_strings (input_bfd);
+ sym_hashes = obj_aout_sym_hashes (input_bfd);
+ symbol_map = finfo->symbol_map;
+
+ reloc_count = rel_size / RELOC_STD_SIZE;
+ rel = relocs;
+ rel_end = rel + reloc_count;
+ for (; rel < rel_end; rel++)
+ {
+ bfd_vma r_addr;
+ int r_index;
+ int r_extern;
+ int r_pcrel;
+ int r_baserel = 0;
+ reloc_howto_type *howto;
+ struct aout_link_hash_entry *h = NULL;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_addr = GET_SWORD (input_bfd, rel->r_address);
+
+#ifdef MY_reloc_howto
+ howto = MY_reloc_howto(input_bfd, rel, r_index, r_extern, r_pcrel);
+#else
+ {
+ int r_jmptable;
+ int r_relative;
+ int r_length;
+ unsigned int howto_idx;
+
+ if (bfd_header_big_endian (input_bfd))
+ {
+ r_index = ((rel->r_index[0] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[2]);
+ r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
+ r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
+ r_baserel = (0 != (rel->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
+ r_jmptable= (0 != (rel->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
+ r_relative= (0 != (rel->r_type[0] & RELOC_STD_BITS_RELATIVE_BIG));
+ r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
+ >> RELOC_STD_BITS_LENGTH_SH_BIG);
+ }
+ else
+ {
+ r_index = ((rel->r_index[2] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[0]);
+ r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
+ r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
+ r_baserel = (0 != (rel->r_type[0]
+ & RELOC_STD_BITS_BASEREL_LITTLE));
+ r_jmptable= (0 != (rel->r_type[0]
+ & RELOC_STD_BITS_JMPTABLE_LITTLE));
+ r_relative= (0 != (rel->r_type[0]
+ & RELOC_STD_BITS_RELATIVE_LITTLE));
+ r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
+ >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
+ }
+
+ howto_idx = (r_length + 4 * r_pcrel + 8 * r_baserel
+ + 16 * r_jmptable + 32 * r_relative);
+ BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
+ howto = howto_table_std + howto_idx;
+ }
+#endif
+
+ if (relocateable)
+ {
+ /* We are generating a relocateable output file, and must
+ modify the reloc accordingly. */
+ if (r_extern)
+ {
+ /* If we know the symbol this relocation is against,
+ convert it into a relocation against a section. This
+ is what the native linker does. */
+ h = sym_hashes[r_index];
+ if (h != (struct aout_link_hash_entry *) NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ asection *output_section;
+
+ /* Change the r_extern value. */
+ if (bfd_header_big_endian (output_bfd))
+ rel->r_type[0] &=~ RELOC_STD_BITS_EXTERN_BIG;
+ else
+ rel->r_type[0] &=~ RELOC_STD_BITS_EXTERN_LITTLE;
+
+ /* Compute a new r_index. */
+ output_section = h->root.u.def.section->output_section;
+ if (output_section == obj_textsec (output_bfd))
+ r_index = N_TEXT;
+ else if (output_section == obj_datasec (output_bfd))
+ r_index = N_DATA;
+ else if (output_section == obj_bsssec (output_bfd))
+ r_index = N_BSS;
+ else
+ r_index = N_ABS;
+
+ /* Add the symbol value and the section VMA to the
+ addend stored in the contents. */
+ relocation = (h->root.u.def.value
+ + output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+ else
+ {
+ /* We must change r_index according to the symbol
+ map. */
+ r_index = symbol_map[r_index];
+
+ if (r_index == -1)
+ {
+ if (h != NULL)
+ {
+ /* We decided to strip this symbol, but it
+ turns out that we can't. Note that we
+ lose the other and desc information here.
+ I don't think that will ever matter for a
+ global symbol. */
+ if (h->indx < 0)
+ {
+ h->indx = -2;
+ h->written = false;
+ if (! aout_link_write_other_symbol (h,
+ (PTR) finfo))
+ return false;
+ }
+ r_index = h->indx;
+ }
+ else
+ {
+ const char *name;
+
+ name = strings + GET_WORD (input_bfd,
+ syms[r_index].e_strx);
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, input_section,
+ r_addr)))
+ return false;
+ r_index = 0;
+ }
+ }
+
+ relocation = 0;
+ }
+
+ /* Write out the new r_index value. */
+ if (bfd_header_big_endian (output_bfd))
+ {
+ rel->r_index[0] = r_index >> 16;
+ rel->r_index[1] = r_index >> 8;
+ rel->r_index[2] = r_index;
+ }
+ else
+ {
+ rel->r_index[2] = r_index >> 16;
+ rel->r_index[1] = r_index >> 8;
+ rel->r_index[0] = r_index;
+ }
+ }
+ else
+ {
+ asection *section;
+
+ /* This is a relocation against a section. We must
+ adjust by the amount that the section moved. */
+ section = aout_reloc_index_to_section (input_bfd, r_index);
+ relocation = (section->output_section->vma
+ + section->output_offset
+ - section->vma);
+ }
+
+ /* Change the address of the relocation. */
+ PUT_WORD (output_bfd,
+ r_addr + input_section->output_offset,
+ rel->r_address);
+
+ /* Adjust a PC relative relocation by removing the reference
+ to the original address in the section and including the
+ reference to the new address. */
+ if (r_pcrel)
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma);
+
+#ifdef MY_relocatable_reloc
+ MY_relocatable_reloc (howto, output_bfd, rel, relocation, r_addr);
+#endif
+
+ if (relocation == 0)
+ r = bfd_reloc_ok;
+ else
+ r = MY_relocate_contents (howto,
+ input_bfd, relocation,
+ contents + r_addr);
+ }
+ else
+ {
+ boolean hundef;
+
+ /* We are generating an executable, and must do a full
+ relocation. */
+ hundef = false;
+
+ if (r_extern)
+ {
+ h = sym_hashes[r_index];
+
+ if (h != (struct aout_link_hash_entry *) NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ relocation = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+ else if (h != (struct aout_link_hash_entry *) NULL
+ && h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ hundef = true;
+ relocation = 0;
+ }
+ }
+ else
+ {
+ asection *section;
+
+ section = aout_reloc_index_to_section (input_bfd, r_index);
+ relocation = (section->output_section->vma
+ + section->output_offset
+ - section->vma);
+ if (r_pcrel)
+ relocation += input_section->vma;
+ }
+
+ if (check_dynamic_reloc != NULL)
+ {
+ boolean skip;
+
+ if (! ((*check_dynamic_reloc)
+ (finfo->info, input_bfd, input_section, h,
+ (PTR) rel, contents, &skip, &relocation)))
+ return false;
+ if (skip)
+ continue;
+ }
+
+ /* Now warn if a global symbol is undefined. We could not
+ do this earlier, because check_dynamic_reloc might want
+ to skip this reloc. */
+ if (hundef && ! finfo->info->shared && ! r_baserel)
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
+ if (! ((*finfo->info->callbacks->undefined_symbol)
+ (finfo->info, name, input_bfd, input_section, r_addr)))
+ return false;
+ }
+
+ r = MY_final_link_relocate (howto,
+ input_bfd, input_section,
+ contents, r_addr, relocation,
+ (bfd_vma) 0);
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else if (r_extern)
+ name = strings + GET_WORD (input_bfd,
+ syms[r_index].e_strx);
+ else
+ {
+ asection *s;
+
+ s = aout_reloc_index_to_section (input_bfd, r_index);
+ name = bfd_section_name (input_bfd, s);
+ }
+ if (! ((*finfo->info->callbacks->reloc_overflow)
+ (finfo->info, name, howto->name,
+ (bfd_vma) 0, input_bfd, input_section, r_addr)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Relocate an a.out section using extended a.out relocs. */
+
+static boolean
+aout_link_input_section_ext (finfo, input_bfd, input_section, relocs,
+ rel_size, contents)
+ struct aout_final_link_info *finfo;
+ bfd *input_bfd;
+ asection *input_section;
+ struct reloc_ext_external *relocs;
+ bfd_size_type rel_size;
+ bfd_byte *contents;
+{
+ boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
+ bfd *, asection *,
+ struct aout_link_hash_entry *,
+ PTR, bfd_byte *, boolean *,
+ bfd_vma *));
+ bfd *output_bfd;
+ boolean relocateable;
+ struct external_nlist *syms;
+ char *strings;
+ struct aout_link_hash_entry **sym_hashes;
+ int *symbol_map;
+ bfd_size_type reloc_count;
+ register struct reloc_ext_external *rel;
+ struct reloc_ext_external *rel_end;
+
+ output_bfd = finfo->output_bfd;
+ check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
+
+ BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_EXT_SIZE);
+ BFD_ASSERT (input_bfd->xvec->header_byteorder
+ == output_bfd->xvec->header_byteorder);
+
+ relocateable = finfo->info->relocateable;
+ syms = obj_aout_external_syms (input_bfd);
+ strings = obj_aout_external_strings (input_bfd);
+ sym_hashes = obj_aout_sym_hashes (input_bfd);
+ symbol_map = finfo->symbol_map;
+
+ reloc_count = rel_size / RELOC_EXT_SIZE;
+ rel = relocs;
+ rel_end = rel + reloc_count;
+ for (; rel < rel_end; rel++)
+ {
+ bfd_vma r_addr;
+ int r_index;
+ int r_extern;
+ unsigned int r_type;
+ bfd_vma r_addend;
+ struct aout_link_hash_entry *h = NULL;
+ asection *r_section = NULL;
+ bfd_vma relocation;
+
+ r_addr = GET_SWORD (input_bfd, rel->r_address);
+
+ if (bfd_header_big_endian (input_bfd))
+ {
+ r_index = ((rel->r_index[0] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[2]);
+ r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
+ r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
+ >> RELOC_EXT_BITS_TYPE_SH_BIG);
+ }
+ else
+ {
+ r_index = ((rel->r_index[2] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[0]);
+ r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
+ r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
+ >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
+ }
+
+ r_addend = GET_SWORD (input_bfd, rel->r_addend);
+
+ BFD_ASSERT (r_type < TABLE_SIZE (howto_table_ext));
+
+ if (relocateable)
+ {
+ /* We are generating a relocateable output file, and must
+ modify the reloc accordingly. */
+ if (r_extern
+ || r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22)
+ {
+ /* If we know the symbol this relocation is against,
+ convert it into a relocation against a section. This
+ is what the native linker does. */
+ if (r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22)
+ h = NULL;
+ else
+ h = sym_hashes[r_index];
+ if (h != (struct aout_link_hash_entry *) NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ asection *output_section;
+
+ /* Change the r_extern value. */
+ if (bfd_header_big_endian (output_bfd))
+ rel->r_type[0] &=~ RELOC_EXT_BITS_EXTERN_BIG;
+ else
+ rel->r_type[0] &=~ RELOC_EXT_BITS_EXTERN_LITTLE;
+
+ /* Compute a new r_index. */
+ output_section = h->root.u.def.section->output_section;
+ if (output_section == obj_textsec (output_bfd))
+ r_index = N_TEXT;
+ else if (output_section == obj_datasec (output_bfd))
+ r_index = N_DATA;
+ else if (output_section == obj_bsssec (output_bfd))
+ r_index = N_BSS;
+ else
+ r_index = N_ABS;
+
+ /* Add the symbol value and the section VMA to the
+ addend. */
+ relocation = (h->root.u.def.value
+ + output_section->vma
+ + h->root.u.def.section->output_offset);
+
+ /* Now RELOCATION is the VMA of the final
+ destination. If this is a PC relative reloc,
+ then ADDEND is the negative of the source VMA.
+ We want to set ADDEND to the difference between
+ the destination VMA and the source VMA, which
+ means we must adjust RELOCATION by the change in
+ the source VMA. This is done below. */
+ }
+ else
+ {
+ /* We must change r_index according to the symbol
+ map. */
+ r_index = symbol_map[r_index];
+
+ if (r_index == -1)
+ {
+ if (h != NULL)
+ {
+ /* We decided to strip this symbol, but it
+ turns out that we can't. Note that we
+ lose the other and desc information here.
+ I don't think that will ever matter for a
+ global symbol. */
+ if (h->indx < 0)
+ {
+ h->indx = -2;
+ h->written = false;
+ if (! aout_link_write_other_symbol (h,
+ (PTR) finfo))
+ return false;
+ }
+ r_index = h->indx;
+ }
+ else
+ {
+ const char *name;
+
+ name = strings + GET_WORD (input_bfd,
+ syms[r_index].e_strx);
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, input_section,
+ r_addr)))
+ return false;
+ r_index = 0;
+ }
+ }
+
+ relocation = 0;
+
+ /* If this is a PC relative reloc, then the addend
+ is the negative of the source VMA. We must
+ adjust it by the change in the source VMA. This
+ is done below. */
+ }
+
+ /* Write out the new r_index value. */
+ if (bfd_header_big_endian (output_bfd))
+ {
+ rel->r_index[0] = r_index >> 16;
+ rel->r_index[1] = r_index >> 8;
+ rel->r_index[2] = r_index;
+ }
+ else
+ {
+ rel->r_index[2] = r_index >> 16;
+ rel->r_index[1] = r_index >> 8;
+ rel->r_index[0] = r_index;
+ }
+ }
+ else
+ {
+ /* This is a relocation against a section. We must
+ adjust by the amount that the section moved. */
+ r_section = aout_reloc_index_to_section (input_bfd, r_index);
+ relocation = (r_section->output_section->vma
+ + r_section->output_offset
+ - r_section->vma);
+
+ /* If this is a PC relative reloc, then the addend is
+ the difference in VMA between the destination and the
+ source. We have just adjusted for the change in VMA
+ of the destination, so we must also adjust by the
+ change in VMA of the source. This is done below. */
+ }
+
+ /* As described above, we must always adjust a PC relative
+ reloc by the change in VMA of the source. However, if
+ pcrel_offset is set, then the addend does not include the
+ location within the section, in which case we don't need
+ to adjust anything. */
+ if (howto_table_ext[r_type].pc_relative
+ && ! howto_table_ext[r_type].pcrel_offset)
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma);
+
+ /* Change the addend if necessary. */
+ if (relocation != 0)
+ PUT_WORD (output_bfd, r_addend + relocation, rel->r_addend);
+
+ /* Change the address of the relocation. */
+ PUT_WORD (output_bfd,
+ r_addr + input_section->output_offset,
+ rel->r_address);
+ }
+ else
+ {
+ boolean hundef;
+ bfd_reloc_status_type r;
+
+ /* We are generating an executable, and must do a full
+ relocation. */
+ hundef = false;
+
+ if (r_extern)
+ {
+ h = sym_hashes[r_index];
+
+ if (h != (struct aout_link_hash_entry *) NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ relocation = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+ else if (h != (struct aout_link_hash_entry *) NULL
+ && h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ hundef = true;
+ relocation = 0;
+ }
+ }
+ else if (r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22)
+ {
+ struct external_nlist *sym;
+ int type;
+
+ /* For base relative relocs, r_index is always an index
+ into the symbol table, even if r_extern is 0. */
+ sym = syms + r_index;
+ type = bfd_h_get_8 (input_bfd, sym->e_type);
+ if ((type & N_TYPE) == N_TEXT
+ || type == N_WEAKT)
+ r_section = obj_textsec (input_bfd);
+ else if ((type & N_TYPE) == N_DATA
+ || type == N_WEAKD)
+ r_section = obj_datasec (input_bfd);
+ else if ((type & N_TYPE) == N_BSS
+ || type == N_WEAKB)
+ r_section = obj_bsssec (input_bfd);
+ else if ((type & N_TYPE) == N_ABS
+ || type == N_WEAKA)
+ r_section = bfd_abs_section_ptr;
+ else
+ abort ();
+ relocation = (r_section->output_section->vma
+ + r_section->output_offset
+ + (GET_WORD (input_bfd, sym->e_value)
+ - r_section->vma));
+ }
+ else
+ {
+ r_section = aout_reloc_index_to_section (input_bfd, r_index);
+
+ /* If this is a PC relative reloc, then R_ADDEND is the
+ difference between the two vmas, or
+ old_dest_sec + old_dest_off - (old_src_sec + old_src_off)
+ where
+ old_dest_sec == section->vma
+ and
+ old_src_sec == input_section->vma
+ and
+ old_src_off == r_addr
+
+ _bfd_final_link_relocate expects RELOCATION +
+ R_ADDEND to be the VMA of the destination minus
+ r_addr (the minus r_addr is because this relocation
+ is not pcrel_offset, which is a bit confusing and
+ should, perhaps, be changed), or
+ new_dest_sec
+ where
+ new_dest_sec == output_section->vma + output_offset
+ We arrange for this to happen by setting RELOCATION to
+ new_dest_sec + old_src_sec - old_dest_sec
+
+ If this is not a PC relative reloc, then R_ADDEND is
+ simply the VMA of the destination, so we set
+ RELOCATION to the change in the destination VMA, or
+ new_dest_sec - old_dest_sec
+ */
+ relocation = (r_section->output_section->vma
+ + r_section->output_offset
+ - r_section->vma);
+ if (howto_table_ext[r_type].pc_relative)
+ relocation += input_section->vma;
+ }
+
+ if (check_dynamic_reloc != NULL)
+ {
+ boolean skip;
+
+ if (! ((*check_dynamic_reloc)
+ (finfo->info, input_bfd, input_section, h,
+ (PTR) rel, contents, &skip, &relocation)))
+ return false;
+ if (skip)
+ continue;
+ }
+
+ /* Now warn if a global symbol is undefined. We could not
+ do this earlier, because check_dynamic_reloc might want
+ to skip this reloc. */
+ if (hundef
+ && ! finfo->info->shared
+ && r_type != RELOC_BASE10
+ && r_type != RELOC_BASE13
+ && r_type != RELOC_BASE22)
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
+ if (! ((*finfo->info->callbacks->undefined_symbol)
+ (finfo->info, name, input_bfd, input_section, r_addr)))
+ return false;
+ }
+
+ if (r_type != RELOC_SPARC_REV32)
+ r = MY_final_link_relocate (howto_table_ext + r_type,
+ input_bfd, input_section,
+ contents, r_addr, relocation,
+ r_addend);
+ else
+ {
+ bfd_vma x;
+
+ x = bfd_get_32 (input_bfd, contents + r_addr);
+ x = x + relocation + r_addend;
+ bfd_putl32 (/*input_bfd,*/ x, contents + r_addr);
+ r = bfd_reloc_ok;
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else if (r_extern
+ || r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22)
+ name = strings + GET_WORD (input_bfd,
+ syms[r_index].e_strx);
+ else
+ {
+ asection *s;
+
+ s = aout_reloc_index_to_section (input_bfd, r_index);
+ name = bfd_section_name (input_bfd, s);
+ }
+ if (! ((*finfo->info->callbacks->reloc_overflow)
+ (finfo->info, name, howto_table_ext[r_type].name,
+ r_addend, input_bfd, input_section, r_addr)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Handle a link order which is supposed to generate a reloc. */
+
+static boolean
+aout_link_reloc_link_order (finfo, o, p)
+ struct aout_final_link_info *finfo;
+ asection *o;
+ struct bfd_link_order *p;
+{
+ struct bfd_link_order_reloc *pr;
+ int r_index;
+ int r_extern;
+ reloc_howto_type *howto;
+ file_ptr *reloff_ptr;
+ struct reloc_std_external srel;
+ struct reloc_ext_external erel;
+ PTR rel_ptr;
+
+ pr = p->u.reloc.p;
+
+ if (p->type == bfd_section_reloc_link_order)
+ {
+ r_extern = 0;
+ if (bfd_is_abs_section (pr->u.section))
+ r_index = N_ABS | N_EXT;
+ else
+ {
+ BFD_ASSERT (pr->u.section->owner == finfo->output_bfd);
+ r_index = pr->u.section->target_index;
+ }
+ }
+ else
+ {
+ struct aout_link_hash_entry *h;
+
+ BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
+ r_extern = 1;
+ h = ((struct aout_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
+ pr->u.name, false, false, true));
+ if (h != (struct aout_link_hash_entry *) NULL
+ && h->indx >= 0)
+ r_index = h->indx;
+ else if (h != NULL)
+ {
+ /* We decided to strip this symbol, but it turns out that we
+ can't. Note that we lose the other and desc information
+ here. I don't think that will ever matter for a global
+ symbol. */
+ h->indx = -2;
+ h->written = false;
+ if (! aout_link_write_other_symbol (h, (PTR) finfo))
+ return false;
+ r_index = h->indx;
+ }
+ else
+ {
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, pr->u.name, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ return false;
+ r_index = 0;
+ }
+ }
+
+ howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
+ if (howto == 0)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (o == obj_textsec (finfo->output_bfd))
+ reloff_ptr = &finfo->treloff;
+ else if (o == obj_datasec (finfo->output_bfd))
+ reloff_ptr = &finfo->dreloff;
+ else
+ abort ();
+
+ if (obj_reloc_entry_size (finfo->output_bfd) == RELOC_STD_SIZE)
+ {
+#ifdef MY_put_reloc
+ MY_put_reloc(finfo->output_bfd, r_extern, r_index, p->offset, howto,
+ &srel);
+#else
+ {
+ int r_pcrel;
+ int r_baserel;
+ int r_jmptable;
+ int r_relative;
+ int r_length;
+
+ r_pcrel = howto->pc_relative;
+ r_baserel = (howto->type & 8) != 0;
+ r_jmptable = (howto->type & 16) != 0;
+ r_relative = (howto->type & 32) != 0;
+ r_length = howto->size;
+
+ PUT_WORD (finfo->output_bfd, p->offset, srel.r_address);
+ if (bfd_header_big_endian (finfo->output_bfd))
+ {
+ srel.r_index[0] = r_index >> 16;
+ srel.r_index[1] = r_index >> 8;
+ srel.r_index[2] = r_index;
+ srel.r_type[0] =
+ ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
+ | (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)
+ | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_BIG : 0)
+ | (r_relative ? RELOC_STD_BITS_RELATIVE_BIG : 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
+ }
+ else
+ {
+ srel.r_index[2] = r_index >> 16;
+ srel.r_index[1] = r_index >> 8;
+ srel.r_index[0] = r_index;
+ srel.r_type[0] =
+ ((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
+ | (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
+ | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
+ | (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
+ }
+ }
+#endif
+ rel_ptr = (PTR) &srel;
+
+ /* We have to write the addend into the object file, since
+ standard a.out relocs are in place. It would be more
+ reliable if we had the current contents of the file here,
+ rather than assuming zeroes, but we can't read the file since
+ it was opened using bfd_openw. */
+ if (pr->addend != 0)
+ {
+ bfd_size_type size;
+ bfd_reloc_status_type r;
+ bfd_byte *buf;
+ boolean ok;
+
+ size = bfd_get_reloc_size (howto);
+ buf = (bfd_byte *) bfd_zmalloc (size);
+ if (buf == (bfd_byte *) NULL)
+ return false;
+ r = MY_relocate_contents (howto, finfo->output_bfd,
+ pr->addend, buf);
+ switch (r)
+ {
+ case bfd_reloc_ok:
+ break;
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ if (! ((*finfo->info->callbacks->reloc_overflow)
+ (finfo->info,
+ (p->type == bfd_section_reloc_link_order
+ ? bfd_section_name (finfo->output_bfd,
+ pr->u.section)
+ : pr->u.name),
+ howto->name, pr->addend, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ {
+ free (buf);
+ return false;
+ }
+ break;
+ }
+ ok = bfd_set_section_contents (finfo->output_bfd, o,
+ (PTR) buf,
+ (file_ptr) p->offset,
+ size);
+ free (buf);
+ if (! ok)
+ return false;
+ }
+ }
+ else
+ {
+ PUT_WORD (finfo->output_bfd, p->offset, erel.r_address);
+
+ if (bfd_header_big_endian (finfo->output_bfd))
+ {
+ erel.r_index[0] = r_index >> 16;
+ erel.r_index[1] = r_index >> 8;
+ erel.r_index[2] = r_index;
+ erel.r_type[0] =
+ ((r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
+ | (howto->type << RELOC_EXT_BITS_TYPE_SH_BIG));
+ }
+ else
+ {
+ erel.r_index[2] = r_index >> 16;
+ erel.r_index[1] = r_index >> 8;
+ erel.r_index[0] = r_index;
+ erel.r_type[0] =
+ (r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
+ | (howto->type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
+ }
+
+ PUT_WORD (finfo->output_bfd, pr->addend, erel.r_addend);
+
+ rel_ptr = (PTR) &erel;
+ }
+
+ if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
+ || (bfd_write (rel_ptr, (bfd_size_type) 1,
+ obj_reloc_entry_size (finfo->output_bfd),
+ finfo->output_bfd)
+ != obj_reloc_entry_size (finfo->output_bfd)))
+ return false;
+
+ *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
+
+ /* Assert that the relocs have not run into the symbols, and that n
+ the text relocs have not run into the data relocs. */
+ BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
+ && (reloff_ptr != &finfo->treloff
+ || (*reloff_ptr
+ <= obj_datasec (finfo->output_bfd)->rel_filepos)));
+
+ return true;
+}
diff --git a/bfd/archive.c b/bfd/archive.c
new file mode 100644
index 00000000000..8ac5aa4e95d
--- /dev/null
+++ b/bfd/archive.c
@@ -0,0 +1,2127 @@
+/* BFD back-end for archive files (libraries).
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+@setfilename archive-info
+SECTION
+ Archives
+
+DESCRIPTION
+ An archive (or library) is just another BFD. It has a symbol
+ table, although there's not much a user program will do with it.
+
+ The big difference between an archive BFD and an ordinary BFD
+ is that the archive doesn't have sections. Instead it has a
+ chain of BFDs that are considered its contents. These BFDs can
+ be manipulated like any other. The BFDs contained in an
+ archive opened for reading will all be opened for reading. You
+ may put either input or output BFDs into an archive opened for
+ output; they will be handled correctly when the archive is closed.
+
+ Use <<bfd_openr_next_archived_file>> to step through
+ the contents of an archive opened for input. You don't
+ have to read the entire archive if you don't want
+ to! Read it until you find what you want.
+
+ Archive contents of output BFDs are chained through the
+ <<next>> pointer in a BFD. The first one is findable through
+ the <<archive_head>> slot of the archive. Set it with
+ <<bfd_set_archive_head>> (q.v.). A given BFD may be in only one
+ open output archive at a time.
+
+ As expected, the BFD archive code is more general than the
+ archive code of any given environment. BFD archives may
+ contain files of different formats (e.g., a.out and coff) and
+ even different architectures. You may even place archives
+ recursively into archives!
+
+ This can cause unexpected confusion, since some archive
+ formats are more expressive than others. For instance, Intel
+ COFF archives can preserve long filenames; SunOS a.out archives
+ cannot. If you move a file from the first to the second
+ format and back again, the filename may be truncated.
+ Likewise, different a.out environments have different
+ conventions as to how they truncate filenames, whether they
+ preserve directory names in filenames, etc. When
+ interoperating with native tools, be sure your files are
+ homogeneous.
+
+ Beware: most of these formats do not react well to the
+ presence of spaces in filenames. We do the best we can, but
+ can't always handle this case due to restrictions in the format of
+ archives. Many Unix utilities are braindead in regards to
+ spaces and such in filenames anyway, so this shouldn't be much
+ of a restriction.
+
+ Archives are supported in BFD in <<archive.c>>.
+
+*/
+
+/* Assumes:
+ o - all archive elements start on an even boundary, newline padded;
+ o - all arch headers are char *;
+ o - all arch headers are the same size (across architectures).
+*/
+
+/* Some formats provide a way to cram a long filename into the short
+ (16 chars) space provided by a BSD archive. The trick is: make a
+ special "file" in the front of the archive, sort of like the SYMDEF
+ entry. If the filename is too long to fit, put it in the extended
+ name table, and use its index as the filename. To prevent
+ confusion prepend the index with a space. This means you can't
+ have filenames that start with a space, but then again, many Unix
+ utilities can't handle that anyway.
+
+ This scheme unfortunately requires that you stand on your head in
+ order to write an archive since you need to put a magic file at the
+ front, and need to touch every entry to do so. C'est la vie.
+
+ We support two variants of this idea:
+ The SVR4 format (extended name table is named "//"),
+ and an extended pseudo-BSD variant (extended name table is named
+ "ARFILENAMES/"). The origin of the latter format is uncertain.
+
+ BSD 4.4 uses a third scheme: It writes a long filename
+ directly after the header. This allows 'ar q' to work.
+ We currently can read BSD 4.4 archives, but not write them.
+*/
+
+/* Summary of archive member names:
+
+ Symbol table (must be first):
+ "__.SYMDEF " - Symbol table, Berkeley style, produced by ranlib.
+ "/ " - Symbol table, system 5 style.
+
+ Long name table (must be before regular file members):
+ "// " - Long name table, System 5 R4 style.
+ "ARFILENAMES/ " - Long name table, non-standard extended BSD (not BSD 4.4).
+
+ Regular file members with short names:
+ "filename.o/ " - Regular file, System 5 style (embedded spaces ok).
+ "filename.o " - Regular file, Berkeley style (no embedded spaces).
+
+ Regular files with long names (or embedded spaces, for BSD variants):
+ "/18 " - SVR4 style, name at offset 18 in name table.
+ "#1/23 " - Long name (or embedded paces) 23 characters long,
+ BSD 4.4 style, full name follows header.
+ Implemented for reading, not writing.
+ " 18 " - Long name 18 characters long, extended pseudo-BSD.
+ */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/ar.h"
+#include "aout/ranlib.h"
+#include <ctype.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+#ifdef GNU960
+#define BFD_GNU960_ARMAG(abfd) (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB)
+#endif
+
+/* Define offsetof for those systems which lack it */
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
+#endif
+
+/* We keep a cache of archive filepointers to archive elements to
+ speed up searching the archive by filepos. We only add an entry to
+ the cache when we actually read one. We also don't sort the cache;
+ it's generally short enough to search linearly.
+ Note that the pointers here point to the front of the ar_hdr, not
+ to the front of the contents!
+*/
+struct ar_cache
+{
+ file_ptr ptr;
+ bfd *arelt;
+ struct ar_cache *next;
+};
+
+#define ar_padchar(abfd) ((abfd)->xvec->ar_pad_char)
+#define ar_maxnamelen(abfd) ((abfd)->xvec->ar_max_namelen)
+
+#define arch_eltdata(bfd) ((struct areltdata *)((bfd)->arelt_data))
+#define arch_hdr(bfd) ((struct ar_hdr *)arch_eltdata(bfd)->arch_header)
+
+static char *get_extended_arelt_filename PARAMS ((bfd *arch,
+ const char *name));
+static boolean do_slurp_bsd_armap PARAMS ((bfd *abfd));
+static boolean do_slurp_coff_armap PARAMS ((bfd *abfd));
+static const char *normalize PARAMS ((bfd *, const char *file));
+static struct areltdata *bfd_ar_hdr_from_filesystem PARAMS ((bfd *abfd,
+ const char *,
+ bfd *member));
+
+boolean
+_bfd_generic_mkarchive (abfd)
+ bfd *abfd;
+{
+ abfd->tdata.aout_ar_data = ((struct artdata *)
+ bfd_zalloc (abfd, sizeof (struct artdata)));
+
+ if (bfd_ardata (abfd) == NULL)
+ return false;
+
+ bfd_ardata (abfd)->cache = NULL;
+ bfd_ardata (abfd)->archive_head = NULL;
+ bfd_ardata (abfd)->symdefs = NULL;
+ bfd_ardata (abfd)->extended_names = NULL;
+ bfd_ardata (abfd)->tdata = NULL;
+
+ return true;
+}
+
+/*
+FUNCTION
+ bfd_get_next_mapent
+
+SYNOPSIS
+ symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym);
+
+DESCRIPTION
+ Step through archive @var{abfd}'s symbol table (if it
+ has one). Successively update @var{sym} with the next symbol's
+ information, returning that symbol's (internal) index into the
+ symbol table.
+
+ Supply <<BFD_NO_MORE_SYMBOLS>> as the @var{previous} entry to get
+ the first one; returns <<BFD_NO_MORE_SYMBOLS>> when you've already
+ got the last one.
+
+ A <<carsym>> is a canonical archive symbol. The only
+ user-visible element is its name, a null-terminated string.
+*/
+
+symindex
+bfd_get_next_mapent (abfd, prev, entry)
+ bfd *abfd;
+ symindex prev;
+ carsym **entry;
+{
+ if (!bfd_has_map (abfd))
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return BFD_NO_MORE_SYMBOLS;
+ }
+
+ if (prev == BFD_NO_MORE_SYMBOLS)
+ prev = 0;
+ else
+ ++prev;
+ if (prev >= bfd_ardata (abfd)->symdef_count)
+ return BFD_NO_MORE_SYMBOLS;
+
+ *entry = (bfd_ardata (abfd)->symdefs + prev);
+ return prev;
+}
+
+/* To be called by backends only */
+
+bfd *
+_bfd_create_empty_archive_element_shell (obfd)
+ bfd *obfd;
+{
+ return _bfd_new_bfd_contained_in (obfd);
+}
+
+/*
+FUNCTION
+ bfd_set_archive_head
+
+SYNOPSIS
+ boolean bfd_set_archive_head(bfd *output, bfd *new_head);
+
+DESCRIPTION
+ Set the head of the chain of
+ BFDs contained in the archive @var{output} to @var{new_head}.
+*/
+
+boolean
+bfd_set_archive_head (output_archive, new_head)
+ bfd *output_archive;
+ bfd *new_head;
+{
+
+ output_archive->archive_head = new_head;
+ return true;
+}
+
+bfd *
+_bfd_look_for_bfd_in_cache (arch_bfd, filepos)
+ bfd *arch_bfd;
+ file_ptr filepos;
+{
+ struct ar_cache *current;
+
+ for (current = bfd_ardata (arch_bfd)->cache; current != NULL;
+ current = current->next)
+ if (current->ptr == filepos)
+ return current->arelt;
+
+ return NULL;
+}
+
+/* Kind of stupid to call cons for each one, but we don't do too many */
+boolean
+_bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
+ bfd *arch_bfd, *new_elt;
+ file_ptr filepos;
+{
+ struct ar_cache *new_cache = ((struct ar_cache *)
+ bfd_zalloc (arch_bfd,
+ sizeof (struct ar_cache)));
+
+ if (new_cache == NULL)
+ return false;
+
+ new_cache->ptr = filepos;
+ new_cache->arelt = new_elt;
+ new_cache->next = (struct ar_cache *) NULL;
+ if (bfd_ardata (arch_bfd)->cache == NULL)
+ bfd_ardata (arch_bfd)->cache = new_cache;
+ else
+ {
+ struct ar_cache *current = bfd_ardata (arch_bfd)->cache;
+
+ while (current->next != NULL)
+ current = current->next;
+ current->next = new_cache;
+ }
+
+ return true;
+}
+
+/* The name begins with space. Hence the rest of the name is an index into
+ the string table. */
+
+static char *
+get_extended_arelt_filename (arch, name)
+ bfd *arch;
+ const char *name;
+{
+ unsigned long index = 0;
+
+ /* Should extract string so that I can guarantee not to overflow into
+ the next region, but I'm too lazy. */
+ errno = 0;
+ /* Skip first char, which is '/' in SVR4 or ' ' in some other variants. */
+ index = strtol (name + 1, NULL, 10);
+ if (errno != 0)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
+
+ return bfd_ardata (arch)->extended_names + index;
+}
+
+/* This functions reads an arch header and returns an areltdata pointer, or
+ NULL on error.
+
+ Presumes the file pointer is already in the right place (ie pointing
+ to the ar_hdr in the file). Moves the file pointer; on success it
+ should be pointing to the front of the file contents; on failure it
+ could have been moved arbitrarily.
+*/
+
+PTR
+_bfd_generic_read_ar_hdr (abfd)
+ bfd *abfd;
+{
+ return _bfd_generic_read_ar_hdr_mag (abfd, (const char *) NULL);
+}
+
+/* Alpha ECOFF uses an optional different ARFMAG value, so we have a
+ variant of _bfd_generic_read_ar_hdr which accepts a magic string. */
+
+PTR
+_bfd_generic_read_ar_hdr_mag (abfd, mag)
+ bfd *abfd;
+ const char *mag;
+{
+ struct ar_hdr hdr;
+ char *hdrp = (char *) &hdr;
+ unsigned int parsed_size;
+ struct areltdata *ared;
+ char *filename = NULL;
+ unsigned int namelen = 0;
+ unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
+ char *allocptr = 0;
+
+ if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
+ != sizeof (struct ar_hdr))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return NULL;
+ }
+ if (strncmp (hdr.ar_fmag, ARFMAG, 2) != 0
+ && (mag == NULL
+ || strncmp (hdr.ar_fmag, mag, 2) != 0))
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
+
+ errno = 0;
+ parsed_size = strtol (hdr.ar_size, NULL, 10);
+ if (errno != 0)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
+
+ /* Extract the filename from the archive - there are two ways to
+ specify an extended name table, either the first char of the
+ name is a space, or it's a slash. */
+ if ((hdr.ar_name[0] == '/'
+ || (hdr.ar_name[0] == ' '
+ && memchr (hdr.ar_name, '/', ar_maxnamelen (abfd)) == NULL))
+ && bfd_ardata (abfd)->extended_names != NULL)
+ {
+ filename = get_extended_arelt_filename (abfd, hdr.ar_name);
+ if (filename == NULL)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
+ }
+ /* BSD4.4-style long filename.
+ Only implemented for reading, so far! */
+ else if (hdr.ar_name[0] == '#'
+ && hdr.ar_name[1] == '1'
+ && hdr.ar_name[2] == '/'
+ && isdigit ((unsigned char) hdr.ar_name[3]))
+ {
+ /* BSD-4.4 extended name */
+ namelen = atoi (&hdr.ar_name[3]);
+ allocsize += namelen + 1;
+ parsed_size -= namelen;
+
+ allocptr = bfd_zalloc (abfd, allocsize);
+ if (allocptr == NULL)
+ return NULL;
+ filename = (allocptr
+ + sizeof (struct areltdata)
+ + sizeof (struct ar_hdr));
+ if (bfd_read (filename, 1, namelen, abfd) != namelen)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return NULL;
+ }
+ filename[namelen] = '\0';
+ }
+ else
+ {
+ /* We judge the end of the name by looking for '/' or ' '.
+ Note: The SYSV format (terminated by '/') allows embedded
+ spaces, so only look for ' ' if we don't find '/'. */
+
+ char *e;
+ e = memchr (hdr.ar_name, '\0', ar_maxnamelen (abfd));
+ if (e == NULL)
+ {
+ e = memchr (hdr.ar_name, '/', ar_maxnamelen (abfd));
+ if (e == NULL)
+ e = memchr (hdr.ar_name, ' ', ar_maxnamelen (abfd));
+ }
+
+ if (e != NULL)
+ namelen = e - hdr.ar_name;
+ else
+ {
+ /* If we didn't find a termination character, then the name
+ must be the entire field. */
+ namelen = ar_maxnamelen (abfd);
+ }
+
+ allocsize += namelen + 1;
+ }
+
+ if (!allocptr)
+ {
+ allocptr = bfd_zalloc (abfd, allocsize);
+ if (allocptr == NULL)
+ return NULL;
+ }
+
+ ared = (struct areltdata *) allocptr;
+
+ ared->arch_header = allocptr + sizeof (struct areltdata);
+ memcpy ((char *) ared->arch_header, (char *) &hdr, sizeof (struct ar_hdr));
+ ared->parsed_size = parsed_size;
+
+ if (filename != NULL)
+ ared->filename = filename;
+ else
+ {
+ ared->filename = allocptr + (sizeof (struct areltdata) +
+ sizeof (struct ar_hdr));
+ if (namelen)
+ memcpy (ared->filename, hdr.ar_name, namelen);
+ ared->filename[namelen] = '\0';
+ }
+
+ return (PTR) ared;
+}
+
+/* This is an internal function; it's mainly used when indexing
+ through the archive symbol table, but also used to get the next
+ element, since it handles the bookkeeping so nicely for us. */
+
+bfd *
+_bfd_get_elt_at_filepos (archive, filepos)
+ bfd *archive;
+ file_ptr filepos;
+{
+ struct areltdata *new_areldata;
+ bfd *n_nfd;
+
+ n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
+ if (n_nfd)
+ return n_nfd;
+
+ if (0 > bfd_seek (archive, filepos, SEEK_SET))
+ return NULL;
+
+ if ((new_areldata = (struct areltdata *) _bfd_read_ar_hdr (archive)) == NULL)
+ return NULL;
+
+ n_nfd = _bfd_create_empty_archive_element_shell (archive);
+ if (n_nfd == NULL)
+ {
+ bfd_release (archive, (PTR) new_areldata);
+ return NULL;
+ }
+
+ n_nfd->origin = bfd_tell (archive);
+ n_nfd->arelt_data = (PTR) new_areldata;
+ n_nfd->filename = new_areldata->filename;
+
+ if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))
+ return n_nfd;
+
+ /* huh? */
+ bfd_release (archive, (PTR) n_nfd);
+ bfd_release (archive, (PTR) new_areldata);
+ return NULL;
+}
+
+/* Return the BFD which is referenced by the symbol in ABFD indexed by
+ INDEX. INDEX should have been returned by bfd_get_next_mapent. */
+
+bfd *
+_bfd_generic_get_elt_at_index (abfd, index)
+ bfd *abfd;
+ symindex index;
+{
+ carsym *entry;
+
+ entry = bfd_ardata (abfd)->symdefs + index;
+ return _bfd_get_elt_at_filepos (abfd, entry->file_offset);
+}
+
+/*
+FUNCTION
+ bfd_openr_next_archived_file
+
+SYNOPSIS
+ bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous);
+
+DESCRIPTION
+ Provided a BFD, @var{archive}, containing an archive and NULL, open
+ an input BFD on the first contained element and returns that.
+ Subsequent calls should pass
+ the archive and the previous return value to return a created
+ BFD to the next contained element. NULL is returned when there
+ are no more.
+
+*/
+
+bfd *
+bfd_openr_next_archived_file (archive, last_file)
+ bfd *archive;
+ bfd *last_file;
+{
+ if ((bfd_get_format (archive) != bfd_archive) ||
+ (archive->direction == write_direction))
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+ }
+
+ return BFD_SEND (archive,
+ openr_next_archived_file,
+ (archive,
+ last_file));
+}
+
+bfd *
+bfd_generic_openr_next_archived_file (archive, last_file)
+ bfd *archive;
+ bfd *last_file;
+{
+ file_ptr filestart;
+
+ if (!last_file)
+ filestart = bfd_ardata (archive)->first_file_filepos;
+ else
+ {
+ unsigned int size = arelt_size (last_file);
+ /* Pad to an even boundary...
+ Note that last_file->origin can be odd in the case of
+ BSD-4.4-style element with a long odd size. */
+ filestart = last_file->origin + size;
+ filestart += filestart % 2;
+ }
+
+ return _bfd_get_elt_at_filepos (archive, filestart);
+}
+
+
+const bfd_target *
+bfd_generic_archive_p (abfd)
+ bfd *abfd;
+{
+ struct artdata *tdata_hold;
+ char armag[SARMAG + 1];
+
+ tdata_hold = abfd->tdata.aout_ar_data;
+
+ if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+#ifdef GNU960
+ if (strncmp (armag, BFD_GNU960_ARMAG (abfd), SARMAG) != 0)
+ return 0;
+#else
+ if (strncmp (armag, ARMAG, SARMAG) != 0 &&
+ strncmp (armag, ARMAGB, SARMAG) != 0)
+ return 0;
+#endif
+
+ /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
+ involves a cast, we can't do it as the left operand of assignment. */
+ abfd->tdata.aout_ar_data = ((struct artdata *)
+ bfd_zalloc (abfd, sizeof (struct artdata)));
+
+ if (bfd_ardata (abfd) == NULL)
+ return NULL;
+
+ bfd_ardata (abfd)->first_file_filepos = SARMAG;
+ bfd_ardata (abfd)->cache = NULL;
+ bfd_ardata (abfd)->archive_head = NULL;
+ bfd_ardata (abfd)->symdefs = NULL;
+ bfd_ardata (abfd)->extended_names = NULL;
+ bfd_ardata (abfd)->tdata = NULL;
+
+ if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
+ {
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = tdata_hold;
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
+ {
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = tdata_hold;
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (bfd_has_map (abfd))
+ {
+ bfd *first;
+
+ /* This archive has a map, so we may presume that the contents
+ are object files. Make sure that if the first file in the
+ archive can be recognized as an object file, it is for this
+ target. If not, assume that this is the wrong format. If
+ the first file is not an object file, somebody is doing
+ something weird, and we permit it so that ar -t will work.
+
+ This is done because any normal format will recognize any
+ normal archive, regardless of the format of the object files.
+ We do accept an empty archive. */
+
+ first = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
+ if (first != NULL)
+ {
+ boolean fail;
+
+ first->target_defaulted = false;
+ fail = false;
+ if (bfd_check_format (first, bfd_object)
+ && first->xvec != abfd->xvec)
+ {
+ (void) bfd_close (first);
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = tdata_hold;
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* We ought to close first here, but we can't, because we
+ have no way to remove it from the archive cache. FIXME. */
+ }
+ }
+
+ return abfd->xvec;
+}
+
+/* Some constants for a 32 bit BSD archive structure. We do not
+ support 64 bit archives presently; so far as I know, none actually
+ exist. Supporting them would require changing these constants, and
+ changing some bfd_h_get_32 to bfd_h_get_64. */
+
+/* The size of an external symdef structure. */
+#define BSD_SYMDEF_SIZE 8
+
+/* The offset from the start of a symdef structure to the file offset. */
+#define BSD_SYMDEF_OFFSET_SIZE 4
+
+/* The size of the symdef count. */
+#define BSD_SYMDEF_COUNT_SIZE 4
+
+/* The size of the string count. */
+#define BSD_STRING_COUNT_SIZE 4
+
+/* Returns false on error, true otherwise */
+
+static boolean
+do_slurp_bsd_armap (abfd)
+ bfd *abfd;
+{
+ struct areltdata *mapdata;
+ unsigned int counter;
+ bfd_byte *raw_armap, *rbase;
+ struct artdata *ardata = bfd_ardata (abfd);
+ char *stringbase;
+ unsigned int parsed_size;
+ carsym *set;
+
+ mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (mapdata == NULL)
+ return false;
+ parsed_size = mapdata->parsed_size;
+ bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
+
+ raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
+ if (raw_armap == (bfd_byte *) NULL)
+ return false;
+
+ if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ byebye:
+ bfd_release (abfd, (PTR) raw_armap);
+ return false;
+ }
+
+ ardata->symdef_count = bfd_h_get_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
+
+ if (ardata->symdef_count * BSD_SYMDEF_SIZE >
+ parsed_size - BSD_SYMDEF_COUNT_SIZE)
+ {
+ /* Probably we're using the wrong byte ordering. */
+ bfd_set_error (bfd_error_wrong_format);
+ goto byebye;
+ }
+
+ ardata->cache = 0;
+ rbase = raw_armap + BSD_SYMDEF_COUNT_SIZE;
+ stringbase = ((char *) rbase
+ + ardata->symdef_count * BSD_SYMDEF_SIZE
+ + BSD_STRING_COUNT_SIZE);
+ ardata->symdefs = (carsym *) bfd_alloc (abfd,
+ (ardata->symdef_count
+ * sizeof (carsym)));
+ if (!ardata->symdefs)
+ return false;
+
+ for (counter = 0, set = ardata->symdefs;
+ counter < ardata->symdef_count;
+ counter++, set++, rbase += BSD_SYMDEF_SIZE)
+ {
+ set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
+ set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
+ }
+
+ ardata->first_file_filepos = bfd_tell (abfd);
+ /* Pad to an even boundary if you have to */
+ ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
+ /* FIXME, we should provide some way to free raw_ardata when
+ we are done using the strings from it. For now, it seems
+ to be allocated on an objalloc anyway... */
+ bfd_has_map (abfd) = true;
+ return true;
+}
+
+/* Returns false on error, true otherwise */
+static boolean
+do_slurp_coff_armap (abfd)
+ bfd *abfd;
+{
+ struct areltdata *mapdata;
+ int *raw_armap, *rawptr;
+ struct artdata *ardata = bfd_ardata (abfd);
+ char *stringbase;
+ unsigned int stringsize;
+ unsigned int parsed_size;
+ carsym *carsyms;
+ unsigned int nsymz; /* Number of symbols in armap. */
+ bfd_vma (*swap) PARAMS ((const bfd_byte *));
+ char int_buf[sizeof (long)];
+ unsigned int carsym_size, ptrsize, i;
+
+ mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (mapdata == NULL)
+ return false;
+ parsed_size = mapdata->parsed_size;
+ bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
+
+ if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ return false;
+ }
+ /* It seems that all numeric information in a coff archive is always
+ in big endian format, nomatter the host or target. */
+ swap = bfd_getb32;
+ nsymz = bfd_getb32 ((PTR) int_buf);
+ stringsize = parsed_size - (4 * nsymz) - 4;
+
+#if 1
+ /* ... except that some archive formats are broken, and it may be our
+ fault - the i960 little endian coff sometimes has big and sometimes
+ little, because our tools changed. Here's a horrible hack to clean
+ up the crap. */
+
+ if (stringsize > 0xfffff
+ && bfd_get_arch (abfd) == bfd_arch_i960
+ && bfd_get_flavour (abfd) == bfd_target_coff_flavour)
+ {
+ /* This looks dangerous, let's do it the other way around */
+ nsymz = bfd_getl32 ((PTR) int_buf);
+ stringsize = parsed_size - (4 * nsymz) - 4;
+ swap = bfd_getl32;
+ }
+#endif
+
+ /* The coff armap must be read sequentially. So we construct a
+ bsd-style one in core all at once, for simplicity. */
+
+ carsym_size = (nsymz * sizeof (carsym));
+ ptrsize = (4 * nsymz);
+
+ ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
+ if (ardata->symdefs == NULL)
+ return false;
+ carsyms = ardata->symdefs;
+ stringbase = ((char *) ardata->symdefs) + carsym_size;
+
+ /* Allocate and read in the raw offsets. */
+ raw_armap = (int *) bfd_alloc (abfd, ptrsize);
+ if (raw_armap == NULL)
+ goto release_symdefs;
+ if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
+ || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ goto release_raw_armap;
+ }
+
+ /* OK, build the carsyms */
+ for (i = 0; i < nsymz; i++)
+ {
+ rawptr = raw_armap + i;
+ carsyms->file_offset = swap ((PTR) rawptr);
+ carsyms->name = stringbase;
+ stringbase += strlen (stringbase) + 1;
+ carsyms++;
+ }
+ *stringbase = 0;
+
+ ardata->symdef_count = nsymz;
+ ardata->first_file_filepos = bfd_tell (abfd);
+ /* Pad to an even boundary if you have to */
+ ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
+
+
+ bfd_has_map (abfd) = true;
+ bfd_release (abfd, (PTR) raw_armap);
+
+
+ /* Check for a second archive header (as used by PE) */
+ {
+ struct areltdata *tmp;
+
+ bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
+ tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (tmp != NULL)
+ {
+ if (tmp->arch_header[0] == '/'
+ && tmp->arch_header[1] == ' ')
+ {
+ ardata->first_file_filepos +=
+ (tmp->parsed_size + sizeof(struct ar_hdr) + 1) & ~1;
+ }
+ bfd_release (abfd, tmp);
+ }
+ }
+
+ return true;
+
+release_raw_armap:
+ bfd_release (abfd, (PTR) raw_armap);
+release_symdefs:
+ bfd_release (abfd, (PTR) (ardata)->symdefs);
+ return false;
+}
+
+/* This routine can handle either coff-style or bsd-style armaps.
+ Returns false on error, true otherwise */
+
+boolean
+bfd_slurp_armap (abfd)
+ bfd *abfd;
+{
+ char nextname[17];
+ int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+
+ if (i == 0)
+ return true;
+ if (i != 16)
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ return false;
+
+ if (!strncmp (nextname, "__.SYMDEF ", 16)
+ || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
+ return do_slurp_bsd_armap (abfd);
+ else if (!strncmp (nextname, "/ ", 16))
+ return do_slurp_coff_armap (abfd);
+ else if (!strncmp (nextname, "/SYM64/ ", 16))
+ {
+ /* Irix 6 archive--must be recognized by code in elf64-mips.c. */
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ bfd_has_map (abfd) = false;
+ return true;
+}
+
+/* Returns false on error, true otherwise */
+/* flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the
+ header is in a slightly different order and the map name is '/'.
+ This flavour is used by hp300hpux. */
+
+#define HPUX_SYMDEF_COUNT_SIZE 2
+
+boolean
+bfd_slurp_bsd_armap_f2 (abfd)
+ bfd *abfd;
+{
+ struct areltdata *mapdata;
+ char nextname[17];
+ unsigned int counter;
+ bfd_byte *raw_armap, *rbase;
+ struct artdata *ardata = bfd_ardata (abfd);
+ char *stringbase;
+ unsigned int stringsize;
+ carsym *set;
+ int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+
+ if (i == 0)
+ return true;
+ if (i != 16)
+ return false;
+
+ /* The archive has at least 16 bytes in it */
+ if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)
+ return false;
+
+ if (!strncmp (nextname, "__.SYMDEF ", 16)
+ || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
+ return do_slurp_bsd_armap (abfd);
+
+ if (strncmp (nextname, "/ ", 16))
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
+
+ mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (mapdata == NULL)
+ return false;
+
+ raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
+ if (raw_armap == NULL)
+ {
+ byebye:
+ bfd_release (abfd, (PTR) mapdata);
+ return false;
+ }
+
+ if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
+ mapdata->parsed_size)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ byebyebye:
+ bfd_release (abfd, (PTR) raw_armap);
+ goto byebye;
+ }
+
+ ardata->symdef_count = bfd_h_get_16 (abfd, (PTR) raw_armap);
+
+ if (ardata->symdef_count * BSD_SYMDEF_SIZE
+ > mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)
+ {
+ /* Probably we're using the wrong byte ordering. */
+ bfd_set_error (bfd_error_wrong_format);
+ goto byebyebye;
+ }
+
+ ardata->cache = 0;
+
+ stringsize = bfd_h_get_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
+ /* skip sym count and string sz */
+ stringbase = ((char *) raw_armap
+ + HPUX_SYMDEF_COUNT_SIZE
+ + BSD_STRING_COUNT_SIZE);
+ rbase = (bfd_byte *) stringbase + stringsize;
+ ardata->symdefs = (carsym *) bfd_alloc (abfd,
+ (ardata->symdef_count
+ * BSD_SYMDEF_SIZE));
+ if (!ardata->symdefs)
+ return false;
+
+ for (counter = 0, set = ardata->symdefs;
+ counter < ardata->symdef_count;
+ counter++, set++, rbase += BSD_SYMDEF_SIZE)
+ {
+ set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
+ set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
+ }
+
+ ardata->first_file_filepos = bfd_tell (abfd);
+ /* Pad to an even boundary if you have to */
+ ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
+ /* FIXME, we should provide some way to free raw_ardata when
+ we are done using the strings from it. For now, it seems
+ to be allocated on an objalloc anyway... */
+ bfd_has_map (abfd) = true;
+ return true;
+}
+
+/** Extended name table.
+
+ Normally archives support only 14-character filenames.
+
+ Intel has extended the format: longer names are stored in a special
+ element (the first in the archive, or second if there is an armap);
+ the name in the ar_hdr is replaced by <space><index into filename
+ element>. Index is the P.R. of an int (decimal). Data General have
+ extended the format by using the prefix // for the special element */
+
+/* Returns false on error, true otherwise */
+boolean
+_bfd_slurp_extended_name_table (abfd)
+ bfd *abfd;
+{
+ char nextname[17];
+ struct areltdata *namedata;
+
+ /* FIXME: Formatting sucks here, and in case of failure of BFD_READ,
+ we probably don't want to return true. */
+ bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);
+ if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
+ {
+ if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ return false;
+
+ if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 &&
+ strncmp (nextname, "// ", 16) != 0)
+ {
+ bfd_ardata (abfd)->extended_names = NULL;
+ return true;
+ }
+
+ namedata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (namedata == NULL)
+ return false;
+
+ bfd_ardata (abfd)->extended_names =
+ bfd_zalloc (abfd, namedata->parsed_size);
+ if (bfd_ardata (abfd)->extended_names == NULL)
+ {
+ byebye:
+ bfd_release (abfd, (PTR) namedata);
+ return false;
+ }
+
+ if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
+ namedata->parsed_size, abfd) != namedata->parsed_size)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));
+ bfd_ardata (abfd)->extended_names = NULL;
+ goto byebye;
+ }
+
+ /* Since the archive is supposed to be printable if it contains
+ text, the entries in the list are newline-padded, not null
+ padded. In SVR4-style archives, the names also have a
+ trailing '/'. DOS/NT created archive often have \ in them
+ We'll fix all problems here.. */
+ {
+ char *temp = bfd_ardata (abfd)->extended_names;
+ char *limit = temp + namedata->parsed_size;
+ for (; temp < limit; ++temp) {
+ if (*temp == '\012')
+ temp[temp[-1] == '/' ? -1 : 0] = '\0';
+ if (*temp == '\\')
+ *temp = '/';
+ }
+ }
+
+ /* Pad to an even boundary if you have to */
+ bfd_ardata (abfd)->first_file_filepos = bfd_tell (abfd);
+ bfd_ardata (abfd)->first_file_filepos +=
+ (bfd_ardata (abfd)->first_file_filepos) % 2;
+
+ /* FIXME, we can't release namedata here because it was allocated
+ below extended_names on the objalloc... */
+ /* bfd_release (abfd, namedata); */
+ }
+ return true;
+}
+
+#ifdef VMS
+
+/* Return a copy of the stuff in the filename between any :]> and a
+ semicolon */
+static const char *
+normalize (abfd, file)
+ bfd *abfd;
+ const char *file;
+{
+ CONST char *first;
+ CONST char *last;
+ char *copy;
+
+ first = file + strlen (file) - 1;
+ last = first + 1;
+
+ while (first != file)
+ {
+ if (*first == ';')
+ last = first;
+ if (*first == ':' || *first == ']' || *first == '>')
+ {
+ first++;
+ break;
+ }
+ first--;
+ }
+
+ copy = (char *) bfd_alloc (abfd, last - first + 1);
+ if (copy == NULL)
+ return NULL;
+
+ memcpy (copy, first, last - first);
+ copy[last - first] = 0;
+
+ return copy;
+}
+
+#else
+static const char *
+normalize (abfd, file)
+ bfd *abfd;
+ const char *file;
+{
+ const char *filename = strrchr (file, '/');
+
+ if (filename != (char *) NULL)
+ filename++;
+ else
+ filename = file;
+ return filename;
+}
+#endif
+
+/* Build a BFD style extended name table. */
+
+boolean
+_bfd_archive_bsd_construct_extended_name_table (abfd, tabloc, tablen, name)
+ bfd *abfd;
+ char **tabloc;
+ bfd_size_type *tablen;
+ const char **name;
+{
+ *name = "ARFILENAMES/";
+ return _bfd_construct_extended_name_table (abfd, false, tabloc, tablen);
+}
+
+/* Build an SVR4 style extended name table. */
+
+boolean
+_bfd_archive_coff_construct_extended_name_table (abfd, tabloc, tablen, name)
+ bfd *abfd;
+ char **tabloc;
+ bfd_size_type *tablen;
+ const char **name;
+{
+ *name = "//";
+ return _bfd_construct_extended_name_table (abfd, true, tabloc, tablen);
+}
+
+/* Follows archive_head and produces an extended name table if
+ necessary. Returns (in tabloc) a pointer to an extended name
+ table, and in tablen the length of the table. If it makes an entry
+ it clobbers the filename so that the element may be written without
+ further massage. Returns true if it ran successfully, false if
+ something went wrong. A successful return may still involve a
+ zero-length tablen! */
+
+boolean
+_bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen)
+ bfd *abfd;
+ boolean trailing_slash;
+ char **tabloc;
+ bfd_size_type *tablen;
+{
+ unsigned int maxname = abfd->xvec->ar_max_namelen;
+ unsigned int total_namelen = 0;
+ bfd *current;
+ char *strptr;
+
+ *tablen = 0;
+
+ /* Figure out how long the table should be */
+ for (current = abfd->archive_head; current != NULL; current = current->next)
+ {
+ const char *normal;
+ unsigned int thislen;
+
+ normal = normalize (current, current->filename);
+ if (normal == NULL)
+ return false;
+
+ thislen = strlen (normal);
+
+ if (thislen > maxname
+ && (bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
+ thislen = maxname;
+
+ if (thislen > maxname)
+ {
+ /* Add one to leave room for \n. */
+ total_namelen += thislen + 1;
+ if (trailing_slash)
+ {
+ /* Leave room for trailing slash. */
+ ++total_namelen;
+ }
+ }
+ else
+ {
+ struct ar_hdr *hdr = arch_hdr (current);
+ if (strncmp (normal, hdr->ar_name, thislen) != 0
+ || (thislen < sizeof hdr->ar_name
+ && hdr->ar_name[thislen] != ar_padchar (current)))
+ {
+ /* Must have been using extended format even though it
+ didn't need to. Fix it to use normal format. */
+ memcpy (hdr->ar_name, normal, thislen);
+ if (thislen < maxname
+ || (thislen == maxname && thislen < sizeof hdr->ar_name))
+ hdr->ar_name[thislen] = ar_padchar (current);
+ }
+ }
+ }
+
+ if (total_namelen == 0)
+ return true;
+
+ *tabloc = bfd_zalloc (abfd, total_namelen);
+ if (*tabloc == NULL)
+ return false;
+
+ *tablen = total_namelen;
+ strptr = *tabloc;
+
+ for (current = abfd->archive_head; current != NULL; current =
+ current->next)
+ {
+ const char *normal;
+ unsigned int thislen;
+
+ normal = normalize (current, current->filename);
+ if (normal == NULL)
+ return false;
+
+ thislen = strlen (normal);
+ if (thislen > maxname)
+ {
+ /* Works for now; may need to be re-engineered if we
+ encounter an oddball archive format and want to
+ generalise this hack. */
+ struct ar_hdr *hdr = arch_hdr (current);
+ strcpy (strptr, normal);
+ if (! trailing_slash)
+ strptr[thislen] = '\012';
+ else
+ {
+ strptr[thislen] = '/';
+ strptr[thislen + 1] = '\012';
+ }
+ hdr->ar_name[0] = ar_padchar (current);
+ /* We know there will always be enough room (one of the few
+ cases where you may safely use sprintf). */
+ sprintf ((hdr->ar_name) + 1, "%-d", (unsigned) (strptr - *tabloc));
+ /* Kinda Kludgy. We should just use the returned value of
+ sprintf but not all implementations get this right */
+ {
+ char *temp = hdr->ar_name + 2;
+ for (; temp < hdr->ar_name + maxname; temp++)
+ if (*temp == '\0')
+ *temp = ' ';
+ }
+ strptr += thislen + 1;
+ if (trailing_slash)
+ ++strptr;
+ }
+ }
+
+ return true;
+}
+
+/** A couple of functions for creating ar_hdrs */
+
+/* Takes a filename, returns an arelt_data for it, or NULL if it can't
+ make one. The filename must refer to a filename in the filesystem.
+ The filename field of the ar_hdr will NOT be initialized. If member
+ is set, and it's an in-memory bfd, we fake it. */
+
+static struct areltdata *
+bfd_ar_hdr_from_filesystem (abfd, filename, member)
+ bfd *abfd;
+ const char *filename;
+ bfd *member;
+{
+ struct stat status;
+ struct areltdata *ared;
+ struct ar_hdr *hdr;
+ char *temp, *temp1;
+
+ if (member && (member->flags & BFD_IN_MEMORY) != 0)
+ {
+ /* Assume we just "made" the member, and fake it */
+ struct bfd_in_memory *bim = (struct bfd_in_memory *) member->iostream;
+ time(&status.st_mtime);
+ status.st_uid = getuid();
+ status.st_gid = getgid();
+ status.st_mode = 0644;
+ status.st_size = bim->size;
+ }
+ else if (stat (filename, &status) != 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+
+ ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
+ sizeof (struct areltdata));
+ if (ared == NULL)
+ return NULL;
+ hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
+
+ /* ar headers are space padded, not null padded! */
+ memset ((PTR) hdr, ' ', sizeof (struct ar_hdr));
+
+ strncpy (hdr->ar_fmag, ARFMAG, 2);
+
+ /* Goddamned sprintf doesn't permit MAXIMUM field lengths */
+ sprintf ((hdr->ar_date), "%-12ld", (long) status.st_mtime);
+ sprintf ((hdr->ar_uid), "%ld", (long) status.st_uid);
+ sprintf ((hdr->ar_gid), "%ld", (long) status.st_gid);
+ sprintf ((hdr->ar_mode), "%-8o", (unsigned int) status.st_mode);
+ sprintf ((hdr->ar_size), "%-10ld", (long) status.st_size);
+ /* Correct for a lossage in sprintf whereby it null-terminates. I cannot
+ understand how these C losers could design such a ramshackle bunch of
+ IO operations */
+ temp = (char *) hdr;
+ temp1 = temp + sizeof (struct ar_hdr) - 2;
+ for (; temp < temp1; temp++)
+ {
+ if (*temp == '\0')
+ *temp = ' ';
+ }
+ strncpy (hdr->ar_fmag, ARFMAG, 2);
+ ared->parsed_size = status.st_size;
+ ared->arch_header = (char *) hdr;
+
+ return ared;
+}
+
+/* This is magic required by the "ar" program. Since it's
+ undocumented, it's undocumented. You may think that it would take
+ a strong stomach to write this, and it does, but it takes even a
+ stronger stomach to try to code around such a thing! */
+
+struct ar_hdr *bfd_special_undocumented_glue PARAMS ((bfd *, const char *));
+
+struct ar_hdr *
+bfd_special_undocumented_glue (abfd, filename)
+ bfd *abfd;
+ const char *filename;
+{
+ struct areltdata *ar_elt = bfd_ar_hdr_from_filesystem (abfd, filename, 0);
+ if (ar_elt == NULL)
+ return NULL;
+ return (struct ar_hdr *) ar_elt->arch_header;
+}
+
+
+/* Analogous to stat call */
+int
+bfd_generic_stat_arch_elt (abfd, buf)
+ bfd *abfd;
+ struct stat *buf;
+{
+ struct ar_hdr *hdr;
+ char *aloser;
+
+ if (abfd->arelt_data == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ hdr = arch_hdr (abfd);
+
+#define foo(arelt, stelt, size) \
+ buf->stelt = strtol (hdr->arelt, &aloser, size); \
+ if (aloser == hdr->arelt) return -1;
+
+ foo (ar_date, st_mtime, 10);
+ foo (ar_uid, st_uid, 10);
+ foo (ar_gid, st_gid, 10);
+ foo (ar_mode, st_mode, 8);
+
+ buf->st_size = arch_eltdata (abfd)->parsed_size;
+
+ return 0;
+}
+
+void
+bfd_dont_truncate_arname (abfd, pathname, arhdr)
+ bfd *abfd;
+ CONST char *pathname;
+ char *arhdr;
+{
+ /* FIXME: This interacts unpleasantly with ar's quick-append option.
+ Fortunately ic960 users will never use that option. Fixing this
+ is very hard; fortunately I know how to do it and will do so once
+ intel's release is out the door. */
+
+ struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
+ size_t length;
+ const char *filename;
+ size_t maxlen = ar_maxnamelen (abfd);
+
+ if ((bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
+ {
+ bfd_bsd_truncate_arname (abfd, pathname, arhdr);
+ return;
+ }
+
+ filename = normalize (abfd, pathname);
+ if (filename == NULL)
+ {
+ /* FIXME */
+ abort ();
+ }
+
+ length = strlen (filename);
+
+ if (length <= maxlen)
+ memcpy (hdr->ar_name, filename, length);
+
+ /* Add the padding character if there is room for it. */
+ if (length < maxlen
+ || (length == maxlen && length < sizeof hdr->ar_name))
+ (hdr->ar_name)[length] = ar_padchar (abfd);
+}
+
+void
+bfd_bsd_truncate_arname (abfd, pathname, arhdr)
+ bfd *abfd;
+ CONST char *pathname;
+ char *arhdr;
+{
+ struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
+ int length;
+ CONST char *filename = strrchr (pathname, '/');
+ int maxlen = ar_maxnamelen (abfd);
+
+ if (filename == NULL)
+ filename = pathname;
+ else
+ ++filename;
+
+ length = strlen (filename);
+
+ if (length <= maxlen)
+ memcpy (hdr->ar_name, filename, length);
+ else
+ {
+ /* pathname: meet procrustes */
+ memcpy (hdr->ar_name, filename, maxlen);
+ length = maxlen;
+ }
+
+ if (length < maxlen)
+ (hdr->ar_name)[length] = ar_padchar (abfd);
+}
+
+/* Store name into ar header. Truncates the name to fit.
+ 1> strip pathname to be just the basename.
+ 2> if it's short enuf to fit, stuff it in.
+ 3> If it doesn't end with .o, truncate it to fit
+ 4> truncate it before the .o, append .o, stuff THAT in. */
+
+/* This is what gnu ar does. It's better but incompatible with the
+ bsd ar. */
+
+void
+bfd_gnu_truncate_arname (abfd, pathname, arhdr)
+ bfd *abfd;
+ CONST char *pathname;
+ char *arhdr;
+{
+ struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
+ int length;
+ CONST char *filename = strrchr (pathname, '/');
+ int maxlen = ar_maxnamelen (abfd);
+
+ if (filename == NULL)
+ filename = pathname;
+ else
+ ++filename;
+
+ length = strlen (filename);
+
+ if (length <= maxlen)
+ memcpy (hdr->ar_name, filename, length);
+ else
+ { /* pathname: meet procrustes */
+ memcpy (hdr->ar_name, filename, maxlen);
+ if ((filename[length - 2] == '.') && (filename[length - 1] == 'o'))
+ {
+ hdr->ar_name[maxlen - 2] = '.';
+ hdr->ar_name[maxlen - 1] = 'o';
+ }
+ length = maxlen;
+ }
+
+ if (length < 16)
+ (hdr->ar_name)[length] = ar_padchar (abfd);
+}
+
+/* The BFD is open for write and has its format set to bfd_archive */
+
+boolean
+_bfd_write_archive_contents (arch)
+ bfd *arch;
+{
+ bfd *current;
+ char *etable = NULL;
+ bfd_size_type elength = 0;
+ const char *ename = NULL;
+ boolean makemap = bfd_has_map (arch);
+ boolean hasobjects = false; /* if no .o's, don't bother to make a map */
+ bfd_size_type wrote;
+ unsigned int i;
+ int tries;
+
+ /* Verify the viability of all entries; if any of them live in the
+ filesystem (as opposed to living in an archive open for input)
+ then construct a fresh ar_hdr for them. */
+ for (current = arch->archive_head; current; current = current->next)
+ {
+ if (bfd_write_p (current))
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+ if (!current->arelt_data)
+ {
+ current->arelt_data =
+ (PTR) bfd_ar_hdr_from_filesystem (arch, current->filename, current);
+ if (!current->arelt_data)
+ return false;
+
+ /* Put in the file name */
+ BFD_SEND (arch, _bfd_truncate_arname, (arch,
+ current->filename,
+ (char *) arch_hdr (current)));
+ }
+
+ if (makemap && ! hasobjects)
+ { /* don't bother if we won't make a map! */
+ if ((bfd_check_format (current, bfd_object))
+#if 0 /* FIXME -- these are not set correctly */
+ && ((bfd_get_file_flags (current) & HAS_SYMS))
+#endif
+ )
+ hasobjects = true;
+ }
+ }
+
+ if (!BFD_SEND (arch, _bfd_construct_extended_name_table,
+ (arch, &etable, &elength, &ename)))
+ return false;
+
+ if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+#ifdef GNU960
+ wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
+#else
+ wrote = bfd_write (ARMAG, 1, SARMAG, arch);
+#endif
+ if (wrote != SARMAG)
+ return false;
+
+ if (makemap && hasobjects)
+ {
+ if (_bfd_compute_and_write_armap (arch, elength) != true)
+ return false;
+ }
+
+ if (elength != 0)
+ {
+ struct ar_hdr hdr;
+
+ memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
+ strcpy (hdr.ar_name, ename);
+ /* Round size up to even number in archive header. */
+ sprintf (&(hdr.ar_size[0]), "%-10d",
+ (int) ((elength + 1) & ~1));
+ strncpy (hdr.ar_fmag, ARFMAG, 2);
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+ if (((char *) (&hdr))[i] == '\0')
+ (((char *) (&hdr))[i]) = ' ';
+ if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ || bfd_write (etable, 1, elength, arch) != elength)
+ return false;
+ if ((elength % 2) == 1)
+ {
+ if (bfd_write ("\012", 1, 1, arch) != 1)
+ return false;
+ }
+ }
+
+ for (current = arch->archive_head; current; current = current->next)
+ {
+ char buffer[DEFAULT_BUFFERSIZE];
+ unsigned int remaining = arelt_size (current);
+ struct ar_hdr *hdr = arch_hdr (current);
+
+ /* write ar header */
+ if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
+ return false;
+ if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+ while (remaining)
+ {
+ unsigned int amt = DEFAULT_BUFFERSIZE;
+ if (amt > remaining)
+ amt = remaining;
+ errno = 0;
+ if (bfd_read (buffer, amt, 1, current) != amt)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ return false;
+ }
+ if (bfd_write (buffer, amt, 1, arch) != amt)
+ return false;
+ remaining -= amt;
+ }
+ if ((arelt_size (current) % 2) == 1)
+ {
+ if (bfd_write ("\012", 1, 1, arch) != 1)
+ return false;
+ }
+ }
+
+ if (makemap && hasobjects)
+ {
+ /* Verify the timestamp in the archive file. If it would not be
+ accepted by the linker, rewrite it until it would be. If
+ anything odd happens, break out and just return. (The
+ Berkeley linker checks the timestamp and refuses to read the
+ table-of-contents if it is >60 seconds less than the file's
+ modified-time. That painful hack requires this painful hack. */
+ tries = 1;
+ do
+ {
+ if (bfd_update_armap_timestamp (arch))
+ break;
+ (*_bfd_error_handler)
+ (_("Warning: writing archive was slow: rewriting timestamp\n"));
+ }
+ while (++tries < 6);
+ }
+
+ return true;
+}
+
+/* Note that the namidx for the first symbol is 0 */
+
+boolean
+_bfd_compute_and_write_armap (arch, elength)
+ bfd *arch;
+ unsigned int elength;
+{
+ char *first_name = NULL;
+ bfd *current;
+ file_ptr elt_no = 0;
+ struct orl *map = NULL;
+ int orl_max = 1024; /* fine initial default */
+ int orl_count = 0;
+ int stridx = 0; /* string index */
+ asymbol **syms = NULL;
+ long syms_max = 0;
+ boolean ret;
+
+ /* Dunno if this is the best place for this info... */
+ if (elength != 0)
+ elength += sizeof (struct ar_hdr);
+ elength += elength % 2;
+
+ map = (struct orl *) bfd_malloc (orl_max * sizeof (struct orl));
+ if (map == NULL)
+ goto error_return;
+
+ /* We put the symbol names on the arch objalloc, and then discard
+ them when done. */
+ first_name = bfd_alloc (arch, 1);
+ if (first_name == NULL)
+ goto error_return;
+
+ /* Drop all the files called __.SYMDEF, we're going to make our
+ own */
+ while (arch->archive_head &&
+ strcmp (arch->archive_head->filename, "__.SYMDEF") == 0)
+ arch->archive_head = arch->archive_head->next;
+
+ /* Map over each element */
+ for (current = arch->archive_head;
+ current != (bfd *) NULL;
+ current = current->next, elt_no++)
+ {
+ if ((bfd_check_format (current, bfd_object) == true)
+ && ((bfd_get_file_flags (current) & HAS_SYMS)))
+ {
+ long storage;
+ long symcount;
+ long src_count;
+
+ storage = bfd_get_symtab_upper_bound (current);
+ if (storage < 0)
+ goto error_return;
+
+ if (storage != 0)
+ {
+ if (storage > syms_max)
+ {
+ if (syms_max > 0)
+ free (syms);
+ syms_max = storage;
+ syms = (asymbol **) bfd_malloc ((size_t) syms_max);
+ if (syms == NULL)
+ goto error_return;
+ }
+ symcount = bfd_canonicalize_symtab (current, syms);
+ if (symcount < 0)
+ goto error_return;
+
+ /* Now map over all the symbols, picking out the ones we want */
+ for (src_count = 0; src_count < symcount; src_count++)
+ {
+ flagword flags = (syms[src_count])->flags;
+ asection *sec = syms[src_count]->section;
+
+ if ((flags & BSF_GLOBAL ||
+ flags & BSF_WEAK ||
+ flags & BSF_INDIRECT ||
+ bfd_is_com_section (sec))
+ && ! bfd_is_und_section (sec))
+ {
+ size_t namelen;
+ struct orl *new_map;
+
+ /* This symbol will go into the archive header */
+ if (orl_count == orl_max)
+ {
+ orl_max *= 2;
+ new_map =
+ ((struct orl *)
+ bfd_realloc (map, orl_max * sizeof (struct orl)));
+ if (new_map == (struct orl *) NULL)
+ goto error_return;
+
+ map = new_map;
+ }
+
+ namelen = strlen (syms[src_count]->name);
+ map[orl_count].name = ((char **)
+ bfd_alloc (arch,
+ sizeof (char *)));
+ if (map[orl_count].name == NULL)
+ goto error_return;
+ *(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
+ if (*(map[orl_count].name) == NULL)
+ goto error_return;
+ strcpy (*(map[orl_count].name), syms[src_count]->name);
+ (map[orl_count]).pos = (file_ptr) current;
+ (map[orl_count]).namidx = stridx;
+
+ stridx += namelen + 1;
+ ++orl_count;
+ }
+ }
+ }
+
+ /* Now ask the BFD to free up any cached information, so we
+ don't fill all of memory with symbol tables. */
+ if (! bfd_free_cached_info (current))
+ goto error_return;
+ }
+ }
+
+ /* OK, now we have collected all the data, let's write them out */
+ ret = BFD_SEND (arch, write_armap,
+ (arch, elength, map, orl_count, stridx));
+
+ if (syms_max > 0)
+ free (syms);
+ if (map != NULL)
+ free (map);
+ if (first_name != NULL)
+ bfd_release (arch, first_name);
+
+ return ret;
+
+ error_return:
+ if (syms_max > 0)
+ free (syms);
+ if (map != NULL)
+ free (map);
+ if (first_name != NULL)
+ bfd_release (arch, first_name);
+
+ return false;
+}
+
+boolean
+bsd_write_armap (arch, elength, map, orl_count, stridx)
+ bfd *arch;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int orl_count;
+ int stridx;
+{
+ int padit = stridx & 1;
+ unsigned int ranlibsize = orl_count * BSD_SYMDEF_SIZE;
+ unsigned int stringsize = stridx + padit;
+ /* Include 8 bytes to store ranlibsize and stringsize in output. */
+ unsigned int mapsize = ranlibsize + stringsize + 8;
+ file_ptr firstreal;
+ bfd *current = arch->archive_head;
+ bfd *last_elt = current; /* last element arch seen */
+ bfd_byte temp[4];
+ unsigned int count;
+ struct ar_hdr hdr;
+ struct stat statbuf;
+ unsigned int i;
+
+ firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
+
+ stat (arch->filename, &statbuf);
+ memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
+ sprintf (hdr.ar_name, RANLIBMAG);
+ /* Remember the timestamp, to keep it holy. But fudge it a little. */
+ bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;
+ bfd_ardata (arch)->armap_datepos = (SARMAG
+ + offsetof (struct ar_hdr, ar_date[0]));
+ sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
+#ifndef _WIN32
+ sprintf (hdr.ar_uid, "%ld", (long) getuid ());
+ sprintf (hdr.ar_gid, "%ld", (long) getgid ());
+#else
+ sprintf (hdr.ar_uid, "%ld", (long) 666);
+ sprintf (hdr.ar_gid, "%ld", (long) 42);
+#endif
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+ strncpy (hdr.ar_fmag, ARFMAG, 2);
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+ if (((char *) (&hdr))[i] == '\0')
+ (((char *) (&hdr))[i]) = ' ';
+ if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ return false;
+ bfd_h_put_32 (arch, (bfd_vma) ranlibsize, temp);
+ if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
+ return false;
+
+ for (count = 0; count < orl_count; count++)
+ {
+ bfd_byte buf[BSD_SYMDEF_SIZE];
+
+ if (((bfd *) (map[count]).pos) != last_elt)
+ {
+ do
+ {
+ firstreal += arelt_size (current) + sizeof (struct ar_hdr);
+ firstreal += firstreal % 2;
+ current = current->next;
+ }
+ while (current != (bfd *) (map[count]).pos);
+ } /* if new archive element */
+
+ last_elt = current;
+ bfd_h_put_32 (arch, map[count].namidx, buf);
+ bfd_h_put_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
+ if (bfd_write (buf, BSD_SYMDEF_SIZE, 1, arch) != BSD_SYMDEF_SIZE)
+ return false;
+ }
+
+ /* now write the strings themselves */
+ bfd_h_put_32 (arch, stringsize, temp);
+ if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
+ return false;
+ for (count = 0; count < orl_count; count++)
+ {
+ size_t len = strlen (*map[count].name) + 1;
+
+ if (bfd_write (*map[count].name, 1, len, arch) != len)
+ return false;
+ }
+
+ /* The spec sez this should be a newline. But in order to be
+ bug-compatible for sun's ar we use a null. */
+ if (padit)
+ {
+ if (bfd_write ("", 1, 1, arch) != 1)
+ return false;
+ }
+
+ return true;
+}
+
+/* At the end of archive file handling, update the timestamp in the
+ file, so the linker will accept it.
+
+ Return true if the timestamp was OK, or an unusual problem happened.
+ Return false if we updated the timestamp. */
+
+boolean
+_bfd_archive_bsd_update_armap_timestamp (arch)
+ bfd *arch;
+{
+ struct stat archstat;
+ struct ar_hdr hdr;
+ unsigned int i;
+
+ /* Flush writes, get last-write timestamp from file, and compare it
+ to the timestamp IN the file. */
+ bfd_flush (arch);
+ if (bfd_stat (arch, &archstat) == -1)
+ {
+ perror (_("Reading archive file mod timestamp"));
+ return true; /* Can't read mod time for some reason */
+ }
+ if (archstat.st_mtime <= bfd_ardata (arch)->armap_timestamp)
+ return true; /* OK by the linker's rules */
+
+ /* Update the timestamp. */
+ bfd_ardata (arch)->armap_timestamp = archstat.st_mtime + ARMAP_TIME_OFFSET;
+
+ /* Prepare an ASCII version suitable for writing. */
+ memset (hdr.ar_date, 0, sizeof (hdr.ar_date));
+ sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
+ for (i = 0; i < sizeof (hdr.ar_date); i++)
+ if (hdr.ar_date[i] == '\0')
+ (hdr.ar_date)[i] = ' ';
+
+ /* Write it into the file. */
+ bfd_ardata (arch)->armap_datepos = (SARMAG
+ + offsetof (struct ar_hdr, ar_date[0]));
+ if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
+ || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
+ != sizeof (hdr.ar_date)))
+ {
+ /* FIXME: bfd can't call perror. */
+ perror (_("Writing updated armap timestamp"));
+ return true; /* Some error while writing */
+ }
+
+ return false; /* We updated the timestamp successfully. */
+}
+
+/* A coff armap looks like :
+ lARMAG
+ struct ar_hdr with name = '/'
+ number of symbols
+ offset of file for symbol 0
+ offset of file for symbol 1
+
+ offset of file for symbol n-1
+ symbol name 0
+ symbol name 1
+
+ symbol name n-1
+*/
+
+boolean
+coff_write_armap (arch, elength, map, symbol_count, stridx)
+ bfd *arch;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int symbol_count;
+ int stridx;
+{
+ /* The size of the ranlib is the number of exported symbols in the
+ archive * the number of bytes in a int, + an int for the count */
+ unsigned int ranlibsize = (symbol_count * 4) + 4;
+ unsigned int stringsize = stridx;
+ unsigned int mapsize = stringsize + ranlibsize;
+ file_ptr archive_member_file_ptr;
+ bfd *current = arch->archive_head;
+ unsigned int count;
+ struct ar_hdr hdr;
+ unsigned int i;
+ int padit = mapsize & 1;
+
+ if (padit)
+ mapsize++;
+
+ /* work out where the first object file will go in the archive */
+ archive_member_file_ptr = (mapsize
+ + elength
+ + sizeof (struct ar_hdr)
+ + SARMAG);
+
+ memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
+ hdr.ar_name[0] = '/';
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+ sprintf (hdr.ar_date, "%ld", (long) time (NULL));
+ /* This, at least, is what Intel coff sets the values to.: */
+ sprintf ((hdr.ar_uid), "%d", 0);
+ sprintf ((hdr.ar_gid), "%d", 0);
+ sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
+ strncpy (hdr.ar_fmag, ARFMAG, 2);
+
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+ if (((char *) (&hdr))[i] == '\0')
+ (((char *) (&hdr))[i]) = ' ';
+
+ /* Write the ar header for this item and the number of symbols */
+
+ if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ return false;
+
+ bfd_write_bigendian_4byte_int (arch, symbol_count);
+
+ /* Two passes, first write the file offsets for each symbol -
+ remembering that each offset is on a two byte boundary. */
+
+ /* Write out the file offset for the file associated with each
+ symbol, and remember to keep the offsets padded out. */
+
+ current = arch->archive_head;
+ count = 0;
+ while (current != (bfd *) NULL && count < symbol_count)
+ {
+ /* For each symbol which is used defined in this object, write out
+ the object file's address in the archive */
+
+ while (((bfd *) (map[count]).pos) == current)
+ {
+ bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
+ count++;
+ }
+ /* Add size of this archive entry */
+ archive_member_file_ptr += (arelt_size (current)
+ + sizeof (struct ar_hdr));
+ /* remember aboout the even alignment */
+ archive_member_file_ptr += archive_member_file_ptr % 2;
+ current = current->next;
+ }
+
+ /* now write the strings themselves */
+ for (count = 0; count < symbol_count; count++)
+ {
+ size_t len = strlen (*map[count].name) + 1;
+
+ if (bfd_write (*map[count].name, 1, len, arch) != len)
+ return false;
+ }
+
+ /* The spec sez this should be a newline. But in order to be
+ bug-compatible for arc960 we use a null. */
+ if (padit)
+ {
+ if (bfd_write ("", 1, 1, arch) != 1)
+ return false;
+ }
+
+ return true;
+}
diff --git a/bfd/archures.c b/bfd/archures.c
new file mode 100644
index 00000000000..f2438623364
--- /dev/null
+++ b/bfd/archures.c
@@ -0,0 +1,896 @@
+/* BFD library support routines for architectures.
+ Copyright (C) 1990, 91-98, 1999 Free Software Foundation, Inc.
+ Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include <ctype.h>
+
+/*
+
+SECTION
+ Architectures
+
+ BFD keeps one atom in a BFD describing the
+ architecture of the data attached to the BFD: a pointer to a
+ <<bfd_arch_info_type>>.
+
+ Pointers to structures can be requested independently of a BFD
+ so that an architecture's information can be interrogated
+ without access to an open BFD.
+
+ The architecture information is provided by each architecture package.
+ The set of default architectures is selected by the macro
+ <<SELECT_ARCHITECTURES>>. This is normally set up in the
+ @file{config/@var{target}.mt} file of your choice. If the name is not
+ defined, then all the architectures supported are included.
+
+ When BFD starts up, all the architectures are called with an
+ initialize method. It is up to the architecture back end to
+ insert as many items into the list of architectures as it wants to;
+ generally this would be one for each machine and one for the
+ default case (an item with a machine field of 0).
+
+ BFD's idea of an architecture is implemented in @file{archures.c}.
+*/
+
+/*
+
+SUBSECTION
+ bfd_architecture
+
+DESCRIPTION
+ This enum gives the object file's CPU architecture, in a
+ global sense---i.e., what processor family does it belong to?
+ Another field indicates which processor within
+ the family is in use. The machine gives a number which
+ distinguishes different versions of the architecture,
+ containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
+ and 68020 and 68030 for Motorola 68020 and 68030.
+
+.enum bfd_architecture
+.{
+. bfd_arch_unknown, {* File arch not known *}
+. bfd_arch_obscure, {* Arch known, not one of these *}
+. bfd_arch_m68k, {* Motorola 68xxx *}
+.#define bfd_mach_m68000 1
+.#define bfd_mach_m68008 2
+.#define bfd_mach_m68010 3
+.#define bfd_mach_m68020 4
+.#define bfd_mach_m68030 5
+.#define bfd_mach_m68040 6
+.#define bfd_mach_m68060 7
+.#define bfd_mach_cpu32 8
+. bfd_arch_vax, {* DEC Vax *}
+. bfd_arch_i960, {* Intel 960 *}
+. {* The order of the following is important.
+. lower number indicates a machine type that
+. only accepts a subset of the instructions
+. available to machines with higher numbers.
+. The exception is the "ca", which is
+. incompatible with all other machines except
+. "core". *}
+.
+.#define bfd_mach_i960_core 1
+.#define bfd_mach_i960_ka_sa 2
+.#define bfd_mach_i960_kb_sb 3
+.#define bfd_mach_i960_mc 4
+.#define bfd_mach_i960_xa 5
+.#define bfd_mach_i960_ca 6
+.#define bfd_mach_i960_jx 7
+.#define bfd_mach_i960_hx 8
+.
+. bfd_arch_a29k, {* AMD 29000 *}
+. bfd_arch_sparc, {* SPARC *}
+.#define bfd_mach_sparc 1
+.{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *}
+.#define bfd_mach_sparc_sparclet 2
+.#define bfd_mach_sparc_sparclite 3
+.#define bfd_mach_sparc_v8plus 4
+.#define bfd_mach_sparc_v8plusa 5 {* with ultrasparc add'ns *}
+.#define bfd_mach_sparc_sparclite_le 6
+.#define bfd_mach_sparc_v9 7
+.#define bfd_mach_sparc_v9a 8 {* with ultrasparc add'ns *}
+.{* Nonzero if MACH has the v9 instruction set. *}
+.#define bfd_mach_sparc_v9_p(mach) \
+. ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a)
+. bfd_arch_mips, {* MIPS Rxxxx *}
+.#define bfd_mach_mips3000 3000
+.#define bfd_mach_mips3900 3900
+.#define bfd_mach_mips4000 4000
+.#define bfd_mach_mips4010 4010
+.#define bfd_mach_mips4100 4100
+.#define bfd_mach_mips4111 4111
+.#define bfd_mach_mips4300 4300
+.#define bfd_mach_mips4400 4400
+.#define bfd_mach_mips4600 4600
+.#define bfd_mach_mips4650 4650
+.#define bfd_mach_mips5000 5000
+.#define bfd_mach_mips6000 6000
+.#define bfd_mach_mips8000 8000
+.#define bfd_mach_mips10000 10000
+.#define bfd_mach_mips16 16
+. bfd_arch_i386, {* Intel 386 *}
+.#define bfd_mach_i386_i386 0
+.#define bfd_mach_i386_i8086 1
+.#define bfd_mach_i386_i386_intel_syntax 2
+. bfd_arch_we32k, {* AT&T WE32xxx *}
+. bfd_arch_tahoe, {* CCI/Harris Tahoe *}
+. bfd_arch_i860, {* Intel 860 *}
+. bfd_arch_romp, {* IBM ROMP PC/RT *}
+. bfd_arch_alliant, {* Alliant *}
+. bfd_arch_convex, {* Convex *}
+. bfd_arch_m88k, {* Motorola 88xxx *}
+. bfd_arch_pyramid, {* Pyramid Technology *}
+. bfd_arch_h8300, {* Hitachi H8/300 *}
+.#define bfd_mach_h8300 1
+.#define bfd_mach_h8300h 2
+.#define bfd_mach_h8300s 3
+. bfd_arch_powerpc, {* PowerPC *}
+. bfd_arch_rs6000, {* IBM RS/6000 *}
+. bfd_arch_hppa, {* HP PA RISC *}
+. bfd_arch_d10v, {* Mitsubishi D10V *}
+. bfd_arch_d30v, {* Mitsubishi D30V *}
+. bfd_arch_z8k, {* Zilog Z8000 *}
+.#define bfd_mach_z8001 1
+.#define bfd_mach_z8002 2
+. bfd_arch_h8500, {* Hitachi H8/500 *}
+. bfd_arch_sh, {* Hitachi SH *}
+.#define bfd_mach_sh 0
+.#define bfd_mach_sh3 0x30
+.#define bfd_mach_sh3e 0x3e
+. bfd_arch_alpha, {* Dec Alpha *}
+.#define bfd_mach_alpha_ev4 0x10
+.#define bfd_mach_alpha_ev5 0x20
+.#define bfd_mach_alpha_ev6 0x30
+. bfd_arch_arm, {* Advanced Risc Machines ARM *}
+.#define bfd_mach_arm_2 1
+.#define bfd_mach_arm_2a 2
+.#define bfd_mach_arm_3 3
+.#define bfd_mach_arm_3M 4
+.#define bfd_mach_arm_4 5
+.#define bfd_mach_arm_4T 6
+. bfd_arch_ns32k, {* National Semiconductors ns32000 *}
+. bfd_arch_w65, {* WDC 65816 *}
+. bfd_arch_tic30, {* Texas Instruments TMS320C30 *}
+. bfd_arch_tic80, {* TI TMS320c80 (MVP) *}
+. bfd_arch_v850, {* NEC V850 *}
+.#define bfd_mach_v850 0
+.#define bfd_mach_v850e 'E'
+.#define bfd_mach_v850ea 'A'
+. bfd_arch_arc, {* Argonaut RISC Core *}
+.#define bfd_mach_arc_base 0
+. bfd_arch_m32r, {* Mitsubishi M32R/D *}
+.#define bfd_mach_m32r 0 {* backwards compatibility *}
+. bfd_arch_mn10200, {* Matsushita MN10200 *}
+. bfd_arch_mn10300, {* Matsushita MN10300 *}
+.#define bfd_mach_mn10300 300
+. bfd_arch_fr30,
+.#define bfd_mach_fr30 0x46523330
+. bfd_arch_mcore,
+. bfd_arch_last
+. };
+
+
+*/
+
+/*
+
+SUBSECTION
+ bfd_arch_info
+
+DESCRIPTION
+ This structure contains information on architectures for use
+ within BFD.
+
+.
+.typedef struct bfd_arch_info
+.{
+. int bits_per_word;
+. int bits_per_address;
+. int bits_per_byte;
+. enum bfd_architecture arch;
+. unsigned long mach;
+. const char *arch_name;
+. const char *printable_name;
+. unsigned int section_align_power;
+. {* true if this is the default machine for the architecture *}
+. boolean the_default;
+. const struct bfd_arch_info * (*compatible)
+. PARAMS ((const struct bfd_arch_info *a,
+. const struct bfd_arch_info *b));
+.
+. boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
+.
+. const struct bfd_arch_info *next;
+.} bfd_arch_info_type;
+*/
+
+extern const bfd_arch_info_type bfd_a29k_arch;
+extern const bfd_arch_info_type bfd_alpha_arch;
+extern const bfd_arch_info_type bfd_arc_arch;
+extern const bfd_arch_info_type bfd_arm_arch;
+extern const bfd_arch_info_type bfd_d10v_arch;
+extern const bfd_arch_info_type bfd_d30v_arch;
+extern const bfd_arch_info_type bfd_h8300_arch;
+extern const bfd_arch_info_type bfd_h8500_arch;
+extern const bfd_arch_info_type bfd_hppa_arch;
+extern const bfd_arch_info_type bfd_i386_arch;
+extern const bfd_arch_info_type bfd_i860_arch;
+extern const bfd_arch_info_type bfd_i960_arch;
+extern const bfd_arch_info_type bfd_m32r_arch;
+extern const bfd_arch_info_type bfd_m68k_arch;
+extern const bfd_arch_info_type bfd_m88k_arch;
+extern const bfd_arch_info_type bfd_mips_arch;
+extern const bfd_arch_info_type bfd_mn10200_arch;
+extern const bfd_arch_info_type bfd_mn10300_arch;
+extern const bfd_arch_info_type bfd_powerpc_arch;
+extern const bfd_arch_info_type bfd_rs6000_arch;
+extern const bfd_arch_info_type bfd_sh_arch;
+extern const bfd_arch_info_type bfd_sparc_arch;
+extern const bfd_arch_info_type bfd_tic30_arch;
+extern const bfd_arch_info_type bfd_tic80_arch;
+extern const bfd_arch_info_type bfd_vax_arch;
+extern const bfd_arch_info_type bfd_we32k_arch;
+extern const bfd_arch_info_type bfd_z8k_arch;
+extern const bfd_arch_info_type bfd_ns32k_arch;
+extern const bfd_arch_info_type bfd_w65_arch;
+extern const bfd_arch_info_type bfd_v850_arch;
+extern const bfd_arch_info_type bfd_fr30_arch;
+extern const bfd_arch_info_type bfd_mcore_arch;
+
+static const bfd_arch_info_type * const bfd_archures_list[] =
+{
+#ifdef SELECT_ARCHITECTURES
+ SELECT_ARCHITECTURES,
+#else
+ &bfd_a29k_arch,
+ &bfd_alpha_arch,
+ &bfd_arc_arch,
+ &bfd_arm_arch,
+ &bfd_d10v_arch,
+ &bfd_d30v_arch,
+ &bfd_h8300_arch,
+ &bfd_h8500_arch,
+ &bfd_hppa_arch,
+ &bfd_i386_arch,
+ &bfd_i860_arch,
+ &bfd_i960_arch,
+ &bfd_m32r_arch,
+ &bfd_m68k_arch,
+ &bfd_m88k_arch,
+ &bfd_mips_arch,
+ &bfd_mn10200_arch,
+ &bfd_mn10300_arch,
+ &bfd_powerpc_arch,
+ &bfd_rs6000_arch,
+ &bfd_sh_arch,
+ &bfd_sparc_arch,
+ &bfd_tic30_arch,
+ &bfd_tic80_arch,
+ &bfd_vax_arch,
+ &bfd_we32k_arch,
+ &bfd_z8k_arch,
+ &bfd_ns32k_arch,
+ &bfd_w65_arch,
+ &bfd_v850_arch,
+ &bfd_fr30_arch,
+ & bfd_mcore_arch,
+#endif
+ 0
+};
+
+/*
+FUNCTION
+ bfd_printable_name
+
+SYNOPSIS
+ const char *bfd_printable_name(bfd *abfd);
+
+DESCRIPTION
+ Return a printable string representing the architecture and machine
+ from the pointer to the architecture info structure.
+
+*/
+
+const char *
+bfd_printable_name (abfd)
+ bfd *abfd;
+{
+ return abfd->arch_info->printable_name;
+}
+
+
+
+/*
+FUNCTION
+ bfd_scan_arch
+
+SYNOPSIS
+ const bfd_arch_info_type *bfd_scan_arch(const char *string);
+
+DESCRIPTION
+ Figure out if BFD supports any cpu which could be described with
+ the name @var{string}. Return a pointer to an <<arch_info>>
+ structure if a machine is found, otherwise NULL.
+
+*/
+
+const bfd_arch_info_type *
+bfd_scan_arch (string)
+ const char *string;
+{
+ const bfd_arch_info_type * const *app, *ap;
+
+ /* Look through all the installed architectures */
+ for (app = bfd_archures_list; *app != NULL; app++)
+ {
+ for (ap = *app; ap != NULL; ap = ap->next)
+ {
+ if (ap->scan (ap, string))
+ return ap;
+ }
+ }
+
+ return NULL;
+}
+
+
+
+/*
+FUNCTION
+ bfd_arch_list
+
+SYNOPSIS
+ const char **bfd_arch_list(void);
+
+DESCRIPTION
+ Return a freshly malloced NULL-terminated vector of the names
+ of all the valid BFD architectures. Do not modify the names.
+
+*/
+
+const char **
+bfd_arch_list ()
+{
+ int vec_length = 0;
+ const char **name_ptr;
+ const char **name_list;
+ const bfd_arch_info_type * const *app;
+
+ /* Determine the number of architectures */
+ vec_length = 0;
+ for (app = bfd_archures_list; *app != NULL; app++)
+ {
+ const bfd_arch_info_type *ap;
+ for (ap = *app; ap != NULL; ap = ap->next)
+ {
+ vec_length++;
+ }
+ }
+
+ name_list = (CONST char **)
+ bfd_malloc ((vec_length + 1) * sizeof (char **));
+ if (name_list == NULL)
+ return NULL;
+
+ /* Point the list at each of the names */
+ name_ptr = name_list;
+ for (app = bfd_archures_list; *app != NULL; app++)
+ {
+ const bfd_arch_info_type *ap;
+ for (ap = *app; ap != NULL; ap = ap->next)
+ {
+ *name_ptr = ap->printable_name;
+ name_ptr++;
+ }
+ }
+ *name_ptr = NULL;
+
+ return name_list;
+}
+
+
+
+/*
+FUNCTION
+ bfd_arch_get_compatible
+
+SYNOPSIS
+ const bfd_arch_info_type *bfd_arch_get_compatible(
+ const bfd *abfd,
+ const bfd *bbfd);
+
+DESCRIPTION
+ Determine whether two BFDs'
+ architectures and machine types are compatible. Calculates
+ the lowest common denominator between the two architectures
+ and machine types implied by the BFDs and returns a pointer to
+ an <<arch_info>> structure describing the compatible machine.
+*/
+
+const bfd_arch_info_type *
+bfd_arch_get_compatible (abfd, bbfd)
+ const bfd *abfd;
+ const bfd *bbfd;
+{
+ /* If either architecture is unknown, then all we can do is assume
+ the user knows what he's doing. */
+ if (abfd->arch_info->arch == bfd_arch_unknown)
+ return bbfd->arch_info;
+ if (bbfd->arch_info->arch == bfd_arch_unknown)
+ return abfd->arch_info;
+
+ /* Otherwise architecture-specific code has to decide. */
+ return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
+}
+
+
+/*
+INTERNAL_DEFINITION
+ bfd_default_arch_struct
+
+DESCRIPTION
+ The <<bfd_default_arch_struct>> is an item of
+ <<bfd_arch_info_type>> which has been initialized to a fairly
+ generic state. A BFD starts life by pointing to this
+ structure, until the correct back end has determined the real
+ architecture of the file.
+
+.extern const bfd_arch_info_type bfd_default_arch_struct;
+
+*/
+
+const bfd_arch_info_type bfd_default_arch_struct =
+{
+ 32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
+ bfd_default_compatible,
+ bfd_default_scan,
+ 0,
+};
+
+/*
+FUNCTION
+ bfd_set_arch_info
+
+SYNOPSIS
+ void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
+
+DESCRIPTION
+ Set the architecture info of @var{abfd} to @var{arg}.
+*/
+
+void
+bfd_set_arch_info (abfd, arg)
+ bfd *abfd;
+ const bfd_arch_info_type *arg;
+{
+ abfd->arch_info = arg;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_default_set_arch_mach
+
+SYNOPSIS
+ boolean bfd_default_set_arch_mach(bfd *abfd,
+ enum bfd_architecture arch,
+ unsigned long mach);
+
+DESCRIPTION
+ Set the architecture and machine type in BFD @var{abfd}
+ to @var{arch} and @var{mach}. Find the correct
+ pointer to a structure and insert it into the <<arch_info>>
+ pointer.
+*/
+
+boolean
+bfd_default_set_arch_mach (abfd, arch, mach)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long mach;
+{
+ const bfd_arch_info_type * const *app, *ap;
+
+ for (app = bfd_archures_list; *app != NULL; app++)
+ {
+ for (ap = *app; ap != NULL; ap = ap->next)
+ {
+ if (ap->arch == arch
+ && (ap->mach == mach
+ || (mach == 0 && ap->the_default)))
+ {
+ abfd->arch_info = ap;
+ return true;
+ }
+ }
+ }
+
+ abfd->arch_info = &bfd_default_arch_struct;
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+}
+
+
+/*
+FUNCTION
+ bfd_get_arch
+
+SYNOPSIS
+ enum bfd_architecture bfd_get_arch(bfd *abfd);
+
+DESCRIPTION
+ Return the enumerated type which describes the BFD @var{abfd}'s
+ architecture.
+
+*/
+
+enum bfd_architecture
+bfd_get_arch (abfd)
+ bfd *abfd;
+{
+ return abfd->arch_info->arch;
+}
+
+/*
+FUNCTION
+ bfd_get_mach
+
+SYNOPSIS
+ unsigned long bfd_get_mach(bfd *abfd);
+
+DESCRIPTION
+ Return the long type which describes the BFD @var{abfd}'s
+ machine.
+*/
+
+unsigned long
+bfd_get_mach (abfd)
+ bfd *abfd;
+{
+ return abfd->arch_info->mach;
+}
+
+/*
+FUNCTION
+ bfd_arch_bits_per_byte
+
+SYNOPSIS
+ unsigned int bfd_arch_bits_per_byte(bfd *abfd);
+
+DESCRIPTION
+ Return the number of bits in one of the BFD @var{abfd}'s
+ architecture's bytes.
+
+*/
+
+unsigned int
+bfd_arch_bits_per_byte (abfd)
+ bfd *abfd;
+{
+ return abfd->arch_info->bits_per_byte;
+}
+
+/*
+FUNCTION
+ bfd_arch_bits_per_address
+
+SYNOPSIS
+ unsigned int bfd_arch_bits_per_address(bfd *abfd);
+
+DESCRIPTION
+ Return the number of bits in one of the BFD @var{abfd}'s
+ architecture's addresses.
+*/
+
+unsigned int
+bfd_arch_bits_per_address (abfd)
+ bfd *abfd;
+{
+ return abfd->arch_info->bits_per_address;
+}
+
+
+/*
+INTERNAL_FUNCTION
+ bfd_default_compatible
+
+SYNOPSIS
+ const bfd_arch_info_type *bfd_default_compatible
+ (const bfd_arch_info_type *a,
+ const bfd_arch_info_type *b);
+
+DESCRIPTION
+ The default function for testing for compatibility.
+*/
+
+const bfd_arch_info_type *
+bfd_default_compatible (a,b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ if (a->arch != b->arch)
+ return NULL;
+
+ if (a->mach > b->mach)
+ return a;
+
+ if (b->mach > a->mach)
+ return b;
+
+ return a;
+}
+
+
+/*
+INTERNAL_FUNCTION
+ bfd_default_scan
+
+SYNOPSIS
+ boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
+
+DESCRIPTION
+ The default function for working out whether this is an
+ architecture hit and a machine hit.
+*/
+
+boolean
+bfd_default_scan (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ const char *ptr_src;
+ const char *ptr_tst;
+ unsigned long number;
+ enum bfd_architecture arch;
+ const char *printable_name_colon;
+
+ /* Exact match of the architecture name (ARCH_NAME) and also the
+ default architecture? */
+ if (strcasecmp (string, info->arch_name) == 0
+ && info->the_default)
+ return true;
+
+ /* Exact match of the machine name (PRINTABLE_NAME)? */
+ if (strcasecmp (string, info->printable_name) == 0)
+ return true;
+
+ /* Given that printable_name contains no colon, attempt to match:
+ ARCH_NAME [ ":" ] PRINTABLE_NAME? */
+ printable_name_colon = strchr (info->printable_name, ':');
+ if (printable_name_colon == NULL)
+ {
+ int strlen_arch_name = strlen (info->arch_name);
+ if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0)
+ {
+ if (string[strlen_arch_name] == ':')
+ {
+ if (strcasecmp (string + strlen_arch_name + 1,
+ info->printable_name) == 0)
+ return true;
+ }
+ else
+ {
+ if (strcasecmp (string + strlen_arch_name,
+ info->printable_name) == 0)
+ return true;
+ }
+ }
+ }
+
+ /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>;
+ Attempt to match: <arch> <mach>? */
+ if (printable_name_colon != NULL)
+ {
+ int colon_index = printable_name_colon - info->printable_name;
+ if (strncasecmp (string, info->printable_name, colon_index) == 0
+ && strcasecmp (string + colon_index,
+ info->printable_name + colon_index + 1) == 0)
+ return true;
+ }
+
+ /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Do not
+ attempt to match just <mach>, it could be ambigious. This test
+ is left until later. */
+
+ /* NOTE: The below is retained for compatibility only. Please do not
+ add to this code */
+
+ /* See how much of the supplied string matches with the
+ architecture, eg the string m68k:68020 would match the 68k entry
+ up to the :, then we get left with the machine number */
+
+ for (ptr_src = string, ptr_tst = info->arch_name;
+ *ptr_src && *ptr_tst;
+ ptr_src++, ptr_tst++)
+ {
+ if (*ptr_src != *ptr_tst) break;
+ }
+
+ /* Chewed up as much of the architecture as will match, skip any
+ colons */
+ if (*ptr_src == ':')
+ ptr_src++;
+
+ if (*ptr_src == 0)
+ {
+ /* nothing more, then only keep this one if it is the default
+ machine for this architecture */
+ return info->the_default;
+ }
+
+ number = 0;
+ while (isdigit ((unsigned char) *ptr_src))
+ {
+ number = number * 10 + *ptr_src - '0';
+ ptr_src++;
+ }
+
+ /* NOTE: The below is retained for compatibility only.
+ PLEASE DO NOT ADD TO THIS CODE. */
+
+ switch (number)
+ {
+ /* FIXME: These are needed to parse IEEE objects. */
+ case 68000:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_m68000;
+ break;
+ case 68010:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_m68010;
+ break;
+ case 68020:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_m68020;
+ break;
+ case 68030:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_m68030;
+ break;
+ case 68040:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_m68040;
+ break;
+ case 68060:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_m68060;
+ break;
+ case 68332:
+ arch = bfd_arch_m68k;
+ number = bfd_mach_cpu32;
+ break;
+
+ case 32000:
+ arch = bfd_arch_we32k;
+ break;
+
+ case 3000:
+ arch = bfd_arch_mips;
+ number = bfd_mach_mips3000;
+ break;
+
+ case 4000:
+ arch = bfd_arch_mips;
+ number = bfd_mach_mips4000;
+ break;
+
+ case 6000:
+ arch = bfd_arch_rs6000;
+ break;
+
+ default:
+ return false;
+ }
+
+ if (arch != info->arch)
+ return false;
+
+ if (number != info->mach)
+ return false;
+
+ return true;
+}
+
+
+/*
+FUNCTION
+ bfd_get_arch_info
+
+SYNOPSIS
+ const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
+
+DESCRIPTION
+ Return the architecture info struct in @var{abfd}.
+*/
+
+const bfd_arch_info_type *
+bfd_get_arch_info (abfd)
+ bfd *abfd;
+{
+ return abfd->arch_info;
+}
+
+
+/*
+FUNCTION
+ bfd_lookup_arch
+
+SYNOPSIS
+ const bfd_arch_info_type *bfd_lookup_arch
+ (enum bfd_architecture
+ arch,
+ unsigned long machine);
+
+DESCRIPTION
+ Look for the architecure info structure which matches the
+ arguments @var{arch} and @var{machine}. A machine of 0 matches the
+ machine/architecture structure which marks itself as the
+ default.
+*/
+
+const bfd_arch_info_type *
+bfd_lookup_arch (arch, machine)
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ const bfd_arch_info_type * const *app, *ap;
+
+ for (app = bfd_archures_list; *app != NULL; app++)
+ {
+ for (ap = *app; ap != NULL; ap = ap->next)
+ {
+ if (ap->arch == arch
+ && (ap->mach == machine
+ || (machine == 0 && ap->the_default)))
+ return ap;
+ }
+ }
+
+ return NULL;
+}
+
+
+/*
+FUNCTION
+ bfd_printable_arch_mach
+
+SYNOPSIS
+ const char *bfd_printable_arch_mach
+ (enum bfd_architecture arch, unsigned long machine);
+
+DESCRIPTION
+ Return a printable string representing the architecture and
+ machine type.
+
+ This routine is depreciated.
+*/
+
+const char *
+bfd_printable_arch_mach (arch, machine)
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine);
+
+ if (ap)
+ return ap->printable_name;
+ return "UNKNOWN!";
+}
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
new file mode 100644
index 00000000000..8bdbf80f1b1
--- /dev/null
+++ b/bfd/bfd-in.h
@@ -0,0 +1,727 @@
+/* Main header file for the bfd library -- portable access to object files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+
+** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
+** instead, change bfd-in.h or the other BFD source files processed to
+** generate these files.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* bfd.h -- The only header file required by users of the bfd library
+
+The bfd.h file is generated from bfd-in.h and various .c files; if you
+change it, your changes will probably be lost.
+
+All the prototypes and definitions following the comment "THE FOLLOWING
+IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
+BFD. If you change it, someone oneday will extract it from the source
+again, and your changes will be lost. To save yourself from this bind,
+change the definitions in the source in the bfd directory. Type "make
+docs" and then "make headers" in that directory, and magically this file
+will change to reflect your changes.
+
+If you don't have the tools to perform the extraction, then you are
+safe from someone on your system trampling over your header files.
+You should still maintain the equivalence between the source and this
+file though; every change you make to the .c file should be reflected
+here. */
+
+#ifndef __BFD_H_SEEN__
+#define __BFD_H_SEEN__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ansidecl.h"
+
+/* These two lines get substitutions done by commands in Makefile.in. */
+#define BFD_VERSION "@VERSION@"
+#define BFD_ARCH_SIZE @wordsize@
+#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
+#if @BFD_HOST_64_BIT_DEFINED@
+#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
+#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
+#endif
+
+#if BFD_ARCH_SIZE >= 64
+#define BFD64
+#endif
+
+#ifndef INLINE
+#if __GNUC__ >= 2
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+#endif
+
+/* forward declaration */
+typedef struct _bfd bfd;
+
+/* To squelch erroneous compiler warnings ("illegal pointer
+ combination") from the SVR3 compiler, we would like to typedef
+ boolean to int (it doesn't like functions which return boolean.
+ Making sure they are never implicitly declared to return int
+ doesn't seem to help). But this file is not configured based on
+ the host. */
+/* General rules: functions which are boolean return true on success
+ and false on failure (unless they're a predicate). -- bfd.doc */
+/* I'm sure this is going to break something and someone is going to
+ force me to change it. */
+/* typedef enum boolean {false, true} boolean; */
+/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
+/* It gets worse if the host also defines a true/false enum... -sts */
+/* And even worse if your compiler has built-in boolean types... -law */
+#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
+#define TRUE_FALSE_ALREADY_DEFINED
+#endif
+#ifdef MPW
+/* Pre-emptive strike - get the file with the enum. */
+#include <Types.h>
+#define TRUE_FALSE_ALREADY_DEFINED
+#endif /* MPW */
+#ifndef TRUE_FALSE_ALREADY_DEFINED
+typedef enum bfd_boolean {false, true} boolean;
+#define BFD_TRUE_FALSE
+#else
+/* Use enum names that will appear nowhere else. */
+typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
+#endif
+
+/* A pointer to a position in a file. */
+/* FIXME: This should be using off_t from <sys/types.h>.
+ For now, try to avoid breaking stuff by not including <sys/types.h> here.
+ This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
+ Probably the best long-term answer is to avoid using file_ptr AND off_t
+ in this header file, and to handle this in the BFD implementation
+ rather than in its interface. */
+/* typedef off_t file_ptr; */
+typedef long int file_ptr;
+
+/* Support for different sizes of target format ints and addresses.
+ If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
+ set to 1 above. Otherwise, if gcc is being used, this code will
+ use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be
+ defined above. */
+
+#ifndef BFD_HOST_64_BIT
+# if BFD_HOST_64BIT_LONG
+# define BFD_HOST_64_BIT long
+# define BFD_HOST_U_64_BIT unsigned long
+# else
+# ifdef __GNUC__
+# if __GNUC__ >= 2
+# define BFD_HOST_64_BIT long long
+# define BFD_HOST_U_64_BIT unsigned long long
+# endif /* __GNUC__ >= 2 */
+# endif /* ! defined (__GNUC__) */
+# endif /* ! BFD_HOST_64BIT_LONG */
+#endif /* ! defined (BFD_HOST_64_BIT) */
+
+#ifdef BFD64
+
+#ifndef BFD_HOST_64_BIT
+ #error No 64 bit integer type available
+#endif /* ! defined (BFD_HOST_64_BIT) */
+
+typedef BFD_HOST_U_64_BIT bfd_vma;
+typedef BFD_HOST_64_BIT bfd_signed_vma;
+typedef BFD_HOST_U_64_BIT bfd_size_type;
+typedef BFD_HOST_U_64_BIT symvalue;
+
+#ifndef fprintf_vma
+#if BFD_HOST_64BIT_LONG
+#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
+#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
+#else
+#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
+#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
+#define fprintf_vma(s,x) \
+ fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
+#define sprintf_vma(s,x) \
+ sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
+#endif
+#endif
+
+#else /* not BFD64 */
+
+/* Represent a target address. Also used as a generic unsigned type
+ which is guaranteed to be big enough to hold any arithmetic types
+ we need to deal with. */
+typedef unsigned long bfd_vma;
+
+/* A generic signed type which is guaranteed to be big enough to hold any
+ arithmetic types we need to deal with. Can be assumed to be compatible
+ with bfd_vma in the same way that signed and unsigned ints are compatible
+ (as parameters, in assignment, etc). */
+typedef long bfd_signed_vma;
+
+typedef unsigned long symvalue;
+typedef unsigned long bfd_size_type;
+
+/* Print a bfd_vma x on stream s. */
+#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
+#define sprintf_vma(s,x) sprintf(s, "%08lx", x)
+
+#endif /* not BFD64 */
+
+#define printf_vma(x) fprintf_vma(stdout,x)
+
+typedef unsigned int flagword; /* 32 bits of flags */
+typedef unsigned char bfd_byte;
+
+/** File formats */
+
+typedef enum bfd_format {
+ bfd_unknown = 0, /* file format is unknown */
+ bfd_object, /* linker/assember/compiler output */
+ bfd_archive, /* object archive file */
+ bfd_core, /* core dump */
+ bfd_type_end} /* marks the end; don't use it! */
+ bfd_format;
+
+/* Values that may appear in the flags field of a BFD. These also
+ appear in the object_flags field of the bfd_target structure, where
+ they indicate the set of flags used by that backend (not all flags
+ are meaningful for all object file formats) (FIXME: at the moment,
+ the object_flags values have mostly just been copied from backend
+ to another, and are not necessarily correct). */
+
+/* No flags. */
+#define BFD_NO_FLAGS 0x00
+
+/* BFD contains relocation entries. */
+#define HAS_RELOC 0x01
+
+/* BFD is directly executable. */
+#define EXEC_P 0x02
+
+/* BFD has line number information (basically used for F_LNNO in a
+ COFF header). */
+#define HAS_LINENO 0x04
+
+/* BFD has debugging information. */
+#define HAS_DEBUG 0x08
+
+/* BFD has symbols. */
+#define HAS_SYMS 0x10
+
+/* BFD has local symbols (basically used for F_LSYMS in a COFF
+ header). */
+#define HAS_LOCALS 0x20
+
+/* BFD is a dynamic object. */
+#define DYNAMIC 0x40
+
+/* Text section is write protected (if D_PAGED is not set, this is
+ like an a.out NMAGIC file) (the linker sets this by default, but
+ clears it for -r or -N). */
+#define WP_TEXT 0x80
+
+/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
+ linker sets this by default, but clears it for -r or -n or -N). */
+#define D_PAGED 0x100
+
+/* BFD is relaxable (this means that bfd_relax_section may be able to
+ do something) (sometimes bfd_relax_section can do something even if
+ this is not set). */
+#define BFD_IS_RELAXABLE 0x200
+
+/* This may be set before writing out a BFD to request using a
+ traditional format. For example, this is used to request that when
+ writing out an a.out object the symbols not be hashed to eliminate
+ duplicates. */
+#define BFD_TRADITIONAL_FORMAT 0x400
+
+/* This flag indicates that the BFD contents are actually cached in
+ memory. If this is set, iostream points to a bfd_in_memory struct. */
+#define BFD_IN_MEMORY 0x800
+
+/* symbols and relocation */
+
+/* A count of carsyms (canonical archive symbols). */
+typedef unsigned long symindex;
+
+/* How to perform a relocation. */
+typedef const struct reloc_howto_struct reloc_howto_type;
+
+#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
+
+/* General purpose part of a symbol X;
+ target specific parts are in libcoff.h, libaout.h, etc. */
+
+#define bfd_get_section(x) ((x)->section)
+#define bfd_get_output_section(x) ((x)->section->output_section)
+#define bfd_set_section(x,y) ((x)->section) = (y)
+#define bfd_asymbol_base(x) ((x)->section->vma)
+#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
+#define bfd_asymbol_name(x) ((x)->name)
+/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
+#define bfd_asymbol_bfd(x) ((x)->the_bfd)
+#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
+
+/* A canonical archive symbol. */
+/* This is a type pun with struct ranlib on purpose! */
+typedef struct carsym {
+ char *name;
+ file_ptr file_offset; /* look here to find the file */
+} carsym; /* to make these you call a carsymogen */
+
+
+/* Used in generating armaps (archive tables of contents).
+ Perhaps just a forward definition would do? */
+struct orl { /* output ranlib */
+ char **name; /* symbol name */
+ file_ptr pos; /* bfd* or file position */
+ int namidx; /* index into string table */
+};
+
+
+/* Linenumber stuff */
+typedef struct lineno_cache_entry {
+ unsigned int line_number; /* Linenumber from start of function*/
+ union {
+ struct symbol_cache_entry *sym; /* Function name */
+ unsigned long offset; /* Offset into section */
+ } u;
+} alent;
+
+/* object and core file sections */
+
+#define align_power(addr, align) \
+ ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
+
+typedef struct sec *sec_ptr;
+
+#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
+#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
+#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+#define bfd_section_name(bfd, ptr) ((ptr)->name)
+#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
+#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
+#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
+#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
+#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
+#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
+
+#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
+
+#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
+#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
+#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
+
+typedef struct stat stat_type;
+
+typedef enum bfd_print_symbol
+{
+ bfd_print_symbol_name,
+ bfd_print_symbol_more,
+ bfd_print_symbol_all
+} bfd_print_symbol_type;
+
+/* Information about a symbol that nm needs. */
+
+typedef struct _symbol_info
+{
+ symvalue value;
+ char type;
+ CONST char *name; /* Symbol name. */
+ unsigned char stab_type; /* Stab type. */
+ char stab_other; /* Stab other. */
+ short stab_desc; /* Stab desc. */
+ CONST char *stab_name; /* String for stab type. */
+} symbol_info;
+
+/* Get the name of a stabs type code. */
+
+extern const char *bfd_get_stab_name PARAMS ((int));
+
+/* Hash table routines. There is no way to free up a hash table. */
+
+/* An element in the hash table. Most uses will actually use a larger
+ structure, and an instance of this will be the first field. */
+
+struct bfd_hash_entry
+{
+ /* Next entry for this hash code. */
+ struct bfd_hash_entry *next;
+ /* String being hashed. */
+ const char *string;
+ /* Hash code. This is the full hash code, not the index into the
+ table. */
+ unsigned long hash;
+};
+
+/* A hash table. */
+
+struct bfd_hash_table
+{
+ /* The hash array. */
+ struct bfd_hash_entry **table;
+ /* The number of slots in the hash table. */
+ unsigned int size;
+ /* A function used to create new elements in the hash table. The
+ first entry is itself a pointer to an element. When this
+ function is first invoked, this pointer will be NULL. However,
+ having the pointer permits a hierarchy of method functions to be
+ built each of which calls the function in the superclass. Thus
+ each function should be written to allocate a new block of memory
+ only if the argument is NULL. */
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+ /* An objalloc for this hash table. This is a struct objalloc *,
+ but we use PTR to avoid requiring the inclusion of objalloc.h. */
+ PTR memory;
+};
+
+/* Initialize a hash table. */
+extern boolean bfd_hash_table_init
+ PARAMS ((struct bfd_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+/* Initialize a hash table specifying a size. */
+extern boolean bfd_hash_table_init_n
+ PARAMS ((struct bfd_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *),
+ unsigned int size));
+
+/* Free up a hash table. */
+extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
+
+/* Look up a string in a hash table. If CREATE is true, a new entry
+ will be created for this string if one does not already exist. The
+ COPY argument must be true if this routine should copy the string
+ into newly allocated memory when adding an entry. */
+extern struct bfd_hash_entry *bfd_hash_lookup
+ PARAMS ((struct bfd_hash_table *, const char *, boolean create,
+ boolean copy));
+
+/* Replace an entry in a hash table. */
+extern void bfd_hash_replace
+ PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
+ struct bfd_hash_entry *nw));
+
+/* Base method for creating a hash table entry. */
+extern struct bfd_hash_entry *bfd_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
+ const char *));
+
+/* Grab some space for a hash table entry. */
+extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
+ unsigned int));
+
+/* Traverse a hash table in a random order, calling a function on each
+ element. If the function returns false, the traversal stops. The
+ INFO argument is passed to the function. */
+extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
+ boolean (*) (struct bfd_hash_entry *,
+ PTR),
+ PTR info));
+
+/* Semi-portable string concatenation in cpp.
+ The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
+ The problem is, "32_" is not a valid preprocessing token, and we don't
+ want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
+ inner CAT macros to be evaluated first, producing still-valid pp-tokens.
+ Then the final concatenation can be done. (Sigh.) */
+#ifndef CAT
+#ifdef SABER
+#define CAT(a,b) a##b
+#define CAT3(a,b,c) a##b##c
+#define CAT4(a,b,c,d) a##b##c##d
+#else
+#if defined(__STDC__) || defined(ALMOST_STDC)
+#define CAT(a,b) a##b
+#define CAT3(a,b,c) a##b##c
+#define XCAT2(a,b) CAT(a,b)
+#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
+#else
+#define CAT(a,b) a/**/b
+#define CAT3(a,b,c) a/**/b/**/c
+#define CAT4(a,b,c,d) a/**/b/**/c/**/d
+#endif
+#endif
+#endif
+
+#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
+
+/* User program access to BFD facilities */
+
+/* Direct I/O routines, for programs which know more about the object
+ file than BFD does. Use higher level routines if possible. */
+
+extern bfd_size_type bfd_read
+ PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
+extern bfd_size_type bfd_write
+ PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
+extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
+extern long bfd_tell PARAMS ((bfd *abfd));
+extern int bfd_flush PARAMS ((bfd *abfd));
+extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
+
+
+/* Cast from const char * to char * so that caller can assign to
+ a char * without a warning. */
+#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
+#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
+#define bfd_get_format(abfd) ((abfd)->format)
+#define bfd_get_target(abfd) ((abfd)->xvec->name)
+#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
+#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
+#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
+#define bfd_header_big_endian(abfd) \
+ ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
+#define bfd_header_little_endian(abfd) \
+ ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
+#define bfd_get_file_flags(abfd) ((abfd)->flags)
+#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
+#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
+#define bfd_my_archive(abfd) ((abfd)->my_archive)
+#define bfd_has_map(abfd) ((abfd)->has_armap)
+
+#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
+#define bfd_usrdata(abfd) ((abfd)->usrdata)
+
+#define bfd_get_start_address(abfd) ((abfd)->start_address)
+#define bfd_get_symcount(abfd) ((abfd)->symcount)
+#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
+#define bfd_count_sections(abfd) ((abfd)->section_count)
+
+#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
+
+#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
+
+extern boolean bfd_record_phdr
+ PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
+ boolean, boolean, unsigned int, struct sec **));
+
+/* Byte swapping routines. */
+
+bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
+bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
+bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
+void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
+
+/* Externally visible ECOFF routines. */
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct ecoff_debug_info;
+struct ecoff_debug_swap;
+struct ecoff_extr;
+struct symbol_cache_entry;
+struct bfd_link_info;
+struct bfd_link_hash_entry;
+struct bfd_elf_version_tree;
+#endif
+extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
+extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
+extern boolean bfd_ecoff_set_regmasks
+ PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
+ unsigned long *cprmask));
+extern PTR bfd_ecoff_debug_init
+ PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ struct bfd_link_info *));
+extern void bfd_ecoff_debug_free
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_accumulate
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ bfd *input_bfd, struct ecoff_debug_info *input_debug,
+ const struct ecoff_debug_swap *input_swap,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_accumulate_other
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_externals
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ boolean relocateable,
+ boolean (*get_extr) (struct symbol_cache_entry *,
+ struct ecoff_extr *),
+ void (*set_index) (struct symbol_cache_entry *,
+ bfd_size_type)));
+extern boolean bfd_ecoff_debug_one_external
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ const char *name, struct ecoff_extr *esym));
+extern bfd_size_type bfd_ecoff_debug_size
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap));
+extern boolean bfd_ecoff_write_debug
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap, file_ptr where));
+extern boolean bfd_ecoff_write_accumulated_debug
+ PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ struct bfd_link_info *info, file_ptr where));
+extern boolean bfd_mips_ecoff_create_embedded_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
+ char **));
+
+/* Externally visible ELF routines. */
+
+struct bfd_link_needed_list
+{
+ struct bfd_link_needed_list *next;
+ bfd *by;
+ const char *name;
+};
+
+extern boolean bfd_elf32_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
+extern boolean bfd_elf64_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
+extern struct bfd_link_needed_list *bfd_elf_get_needed_list
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_elf_get_bfd_needed_list
+ PARAMS ((bfd *, struct bfd_link_needed_list **));
+extern boolean bfd_elf32_size_dynamic_sections
+ PARAMS ((bfd *, const char *, const char *, boolean, const char *,
+ const char * const *, struct bfd_link_info *, struct sec **,
+ struct bfd_elf_version_tree *));
+extern boolean bfd_elf64_size_dynamic_sections
+ PARAMS ((bfd *, const char *, const char *, boolean, const char *,
+ const char * const *, struct bfd_link_info *, struct sec **,
+ struct bfd_elf_version_tree *));
+extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
+extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
+
+/* SunOS shared library support routines for the linker. */
+
+extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_sunos_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_sunos_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
+ struct sec **));
+
+/* Linux shared library support routines for the linker. */
+
+extern boolean bfd_i386linux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_m68klinux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_sparclinux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* mmap hacks */
+
+struct _bfd_window_internal;
+typedef struct _bfd_window_internal bfd_window_internal;
+
+typedef struct _bfd_window {
+ /* What the user asked for. */
+ PTR data;
+ bfd_size_type size;
+ /* The actual window used by BFD. Small user-requested read-only
+ regions sharing a page may share a single window into the object
+ file. Read-write versions shouldn't until I've fixed things to
+ keep track of which portions have been claimed by the
+ application; don't want to give the same region back when the
+ application wants two writable copies! */
+ struct _bfd_window_internal *i;
+} bfd_window;
+
+extern void bfd_init_window PARAMS ((bfd_window *));
+extern void bfd_free_window PARAMS ((bfd_window *));
+extern boolean bfd_get_file_window
+ PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean));
+
+/* XCOFF support routines for the linker. */
+
+extern boolean bfd_xcoff_link_record_set
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
+ bfd_size_type));
+extern boolean bfd_xcoff_import_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
+ bfd_vma, const char *, const char *, const char *));
+extern boolean bfd_xcoff_export_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
+ boolean));
+extern boolean bfd_xcoff_link_count_reloc
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_xcoff_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_xcoff_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
+ unsigned long, unsigned long, unsigned long, boolean,
+ int, boolean, boolean, struct sec **));
+
+/* Externally visible COFF routines. */
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct internal_syment;
+union internal_auxent;
+#endif
+
+extern boolean bfd_coff_get_syment
+ PARAMS ((bfd *, struct symbol_cache_entry *, struct internal_syment *));
+
+extern boolean bfd_coff_get_auxent
+ PARAMS ((bfd *, struct symbol_cache_entry *, int, union internal_auxent *));
+
+extern boolean bfd_coff_set_symbol_class
+ PARAMS ((bfd *, struct symbol_cache_entry *, unsigned int));
+
+/* ARM Interworking support. Called from linker. */
+extern boolean bfd_arm_allocate_interworking_sections
+ PARAMS ((struct bfd_link_info *));
+
+extern boolean bfd_arm_process_before_allocation
+ PARAMS ((bfd *, struct bfd_link_info *, int));
+
+extern boolean bfd_arm_get_bfd_for_interworking
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* ELF ARM Interworking support. Called from linker. */
+ extern boolean bfd_elf32_arm_allocate_interworking_sections
+ PARAMS ((struct bfd_link_info *));
+
+ extern boolean bfd_elf32_arm_process_before_allocation
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+ extern boolean bfd_elf32_arm_get_bfd_for_interworking
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* And more from the source. */
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
new file mode 100644
index 00000000000..8e86304d953
--- /dev/null
+++ b/bfd/bfd-in2.h
@@ -0,0 +1,3003 @@
+/* Main header file for the bfd library -- portable access to object files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+
+** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
+** instead, change bfd-in.h or the other BFD source files processed to
+** generate these files.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* bfd.h -- The only header file required by users of the bfd library
+
+The bfd.h file is generated from bfd-in.h and various .c files; if you
+change it, your changes will probably be lost.
+
+All the prototypes and definitions following the comment "THE FOLLOWING
+IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
+BFD. If you change it, someone oneday will extract it from the source
+again, and your changes will be lost. To save yourself from this bind,
+change the definitions in the source in the bfd directory. Type "make
+docs" and then "make headers" in that directory, and magically this file
+will change to reflect your changes.
+
+If you don't have the tools to perform the extraction, then you are
+safe from someone on your system trampling over your header files.
+You should still maintain the equivalence between the source and this
+file though; every change you make to the .c file should be reflected
+here. */
+
+#ifndef __BFD_H_SEEN__
+#define __BFD_H_SEEN__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ansidecl.h"
+
+/* These two lines get substitutions done by commands in Makefile.in. */
+#define BFD_VERSION "@VERSION@"
+#define BFD_ARCH_SIZE @wordsize@
+#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
+#if @BFD_HOST_64_BIT_DEFINED@
+#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
+#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
+#endif
+
+#if BFD_ARCH_SIZE >= 64
+#define BFD64
+#endif
+
+#ifndef INLINE
+#if __GNUC__ >= 2
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+#endif
+
+/* forward declaration */
+typedef struct _bfd bfd;
+
+/* To squelch erroneous compiler warnings ("illegal pointer
+ combination") from the SVR3 compiler, we would like to typedef
+ boolean to int (it doesn't like functions which return boolean.
+ Making sure they are never implicitly declared to return int
+ doesn't seem to help). But this file is not configured based on
+ the host. */
+/* General rules: functions which are boolean return true on success
+ and false on failure (unless they're a predicate). -- bfd.doc */
+/* I'm sure this is going to break something and someone is going to
+ force me to change it. */
+/* typedef enum boolean {false, true} boolean; */
+/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
+/* It gets worse if the host also defines a true/false enum... -sts */
+/* And even worse if your compiler has built-in boolean types... -law */
+#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
+#define TRUE_FALSE_ALREADY_DEFINED
+#endif
+#ifdef MPW
+/* Pre-emptive strike - get the file with the enum. */
+#include <Types.h>
+#define TRUE_FALSE_ALREADY_DEFINED
+#endif /* MPW */
+#ifndef TRUE_FALSE_ALREADY_DEFINED
+typedef enum bfd_boolean {false, true} boolean;
+#define BFD_TRUE_FALSE
+#else
+/* Use enum names that will appear nowhere else. */
+typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
+#endif
+
+/* A pointer to a position in a file. */
+/* FIXME: This should be using off_t from <sys/types.h>.
+ For now, try to avoid breaking stuff by not including <sys/types.h> here.
+ This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
+ Probably the best long-term answer is to avoid using file_ptr AND off_t
+ in this header file, and to handle this in the BFD implementation
+ rather than in its interface. */
+/* typedef off_t file_ptr; */
+typedef long int file_ptr;
+
+/* Support for different sizes of target format ints and addresses.
+ If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
+ set to 1 above. Otherwise, if gcc is being used, this code will
+ use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be
+ defined above. */
+
+#ifndef BFD_HOST_64_BIT
+# if BFD_HOST_64BIT_LONG
+# define BFD_HOST_64_BIT long
+# define BFD_HOST_U_64_BIT unsigned long
+# else
+# ifdef __GNUC__
+# if __GNUC__ >= 2
+# define BFD_HOST_64_BIT long long
+# define BFD_HOST_U_64_BIT unsigned long long
+# endif /* __GNUC__ >= 2 */
+# endif /* ! defined (__GNUC__) */
+# endif /* ! BFD_HOST_64BIT_LONG */
+#endif /* ! defined (BFD_HOST_64_BIT) */
+
+#ifdef BFD64
+
+#ifndef BFD_HOST_64_BIT
+ #error No 64 bit integer type available
+#endif /* ! defined (BFD_HOST_64_BIT) */
+
+typedef BFD_HOST_U_64_BIT bfd_vma;
+typedef BFD_HOST_64_BIT bfd_signed_vma;
+typedef BFD_HOST_U_64_BIT bfd_size_type;
+typedef BFD_HOST_U_64_BIT symvalue;
+
+#ifndef fprintf_vma
+#if BFD_HOST_64BIT_LONG
+#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
+#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
+#else
+#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
+#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
+#define fprintf_vma(s,x) \
+ fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
+#define sprintf_vma(s,x) \
+ sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
+#endif
+#endif
+
+#else /* not BFD64 */
+
+/* Represent a target address. Also used as a generic unsigned type
+ which is guaranteed to be big enough to hold any arithmetic types
+ we need to deal with. */
+typedef unsigned long bfd_vma;
+
+/* A generic signed type which is guaranteed to be big enough to hold any
+ arithmetic types we need to deal with. Can be assumed to be compatible
+ with bfd_vma in the same way that signed and unsigned ints are compatible
+ (as parameters, in assignment, etc). */
+typedef long bfd_signed_vma;
+
+typedef unsigned long symvalue;
+typedef unsigned long bfd_size_type;
+
+/* Print a bfd_vma x on stream s. */
+#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
+#define sprintf_vma(s,x) sprintf(s, "%08lx", x)
+
+#endif /* not BFD64 */
+
+#define printf_vma(x) fprintf_vma(stdout,x)
+
+typedef unsigned int flagword; /* 32 bits of flags */
+typedef unsigned char bfd_byte;
+
+/** File formats */
+
+typedef enum bfd_format {
+ bfd_unknown = 0, /* file format is unknown */
+ bfd_object, /* linker/assember/compiler output */
+ bfd_archive, /* object archive file */
+ bfd_core, /* core dump */
+ bfd_type_end} /* marks the end; don't use it! */
+ bfd_format;
+
+/* Values that may appear in the flags field of a BFD. These also
+ appear in the object_flags field of the bfd_target structure, where
+ they indicate the set of flags used by that backend (not all flags
+ are meaningful for all object file formats) (FIXME: at the moment,
+ the object_flags values have mostly just been copied from backend
+ to another, and are not necessarily correct). */
+
+/* No flags. */
+#define BFD_NO_FLAGS 0x00
+
+/* BFD contains relocation entries. */
+#define HAS_RELOC 0x01
+
+/* BFD is directly executable. */
+#define EXEC_P 0x02
+
+/* BFD has line number information (basically used for F_LNNO in a
+ COFF header). */
+#define HAS_LINENO 0x04
+
+/* BFD has debugging information. */
+#define HAS_DEBUG 0x08
+
+/* BFD has symbols. */
+#define HAS_SYMS 0x10
+
+/* BFD has local symbols (basically used for F_LSYMS in a COFF
+ header). */
+#define HAS_LOCALS 0x20
+
+/* BFD is a dynamic object. */
+#define DYNAMIC 0x40
+
+/* Text section is write protected (if D_PAGED is not set, this is
+ like an a.out NMAGIC file) (the linker sets this by default, but
+ clears it for -r or -N). */
+#define WP_TEXT 0x80
+
+/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
+ linker sets this by default, but clears it for -r or -n or -N). */
+#define D_PAGED 0x100
+
+/* BFD is relaxable (this means that bfd_relax_section may be able to
+ do something) (sometimes bfd_relax_section can do something even if
+ this is not set). */
+#define BFD_IS_RELAXABLE 0x200
+
+/* This may be set before writing out a BFD to request using a
+ traditional format. For example, this is used to request that when
+ writing out an a.out object the symbols not be hashed to eliminate
+ duplicates. */
+#define BFD_TRADITIONAL_FORMAT 0x400
+
+/* This flag indicates that the BFD contents are actually cached in
+ memory. If this is set, iostream points to a bfd_in_memory struct. */
+#define BFD_IN_MEMORY 0x800
+
+/* symbols and relocation */
+
+/* A count of carsyms (canonical archive symbols). */
+typedef unsigned long symindex;
+
+/* How to perform a relocation. */
+typedef const struct reloc_howto_struct reloc_howto_type;
+
+#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
+
+/* General purpose part of a symbol X;
+ target specific parts are in libcoff.h, libaout.h, etc. */
+
+#define bfd_get_section(x) ((x)->section)
+#define bfd_get_output_section(x) ((x)->section->output_section)
+#define bfd_set_section(x,y) ((x)->section) = (y)
+#define bfd_asymbol_base(x) ((x)->section->vma)
+#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
+#define bfd_asymbol_name(x) ((x)->name)
+/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
+#define bfd_asymbol_bfd(x) ((x)->the_bfd)
+#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
+
+/* A canonical archive symbol. */
+/* This is a type pun with struct ranlib on purpose! */
+typedef struct carsym {
+ char *name;
+ file_ptr file_offset; /* look here to find the file */
+} carsym; /* to make these you call a carsymogen */
+
+
+/* Used in generating armaps (archive tables of contents).
+ Perhaps just a forward definition would do? */
+struct orl { /* output ranlib */
+ char **name; /* symbol name */
+ file_ptr pos; /* bfd* or file position */
+ int namidx; /* index into string table */
+};
+
+
+/* Linenumber stuff */
+typedef struct lineno_cache_entry {
+ unsigned int line_number; /* Linenumber from start of function*/
+ union {
+ struct symbol_cache_entry *sym; /* Function name */
+ unsigned long offset; /* Offset into section */
+ } u;
+} alent;
+
+/* object and core file sections */
+
+#define align_power(addr, align) \
+ ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
+
+typedef struct sec *sec_ptr;
+
+#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
+#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
+#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+#define bfd_section_name(bfd, ptr) ((ptr)->name)
+#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
+#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
+#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
+#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
+#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
+#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
+
+#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
+
+#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
+#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
+#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
+
+typedef struct stat stat_type;
+
+typedef enum bfd_print_symbol
+{
+ bfd_print_symbol_name,
+ bfd_print_symbol_more,
+ bfd_print_symbol_all
+} bfd_print_symbol_type;
+
+/* Information about a symbol that nm needs. */
+
+typedef struct _symbol_info
+{
+ symvalue value;
+ char type;
+ CONST char *name; /* Symbol name. */
+ unsigned char stab_type; /* Stab type. */
+ char stab_other; /* Stab other. */
+ short stab_desc; /* Stab desc. */
+ CONST char *stab_name; /* String for stab type. */
+} symbol_info;
+
+/* Get the name of a stabs type code. */
+
+extern const char *bfd_get_stab_name PARAMS ((int));
+
+/* Hash table routines. There is no way to free up a hash table. */
+
+/* An element in the hash table. Most uses will actually use a larger
+ structure, and an instance of this will be the first field. */
+
+struct bfd_hash_entry
+{
+ /* Next entry for this hash code. */
+ struct bfd_hash_entry *next;
+ /* String being hashed. */
+ const char *string;
+ /* Hash code. This is the full hash code, not the index into the
+ table. */
+ unsigned long hash;
+};
+
+/* A hash table. */
+
+struct bfd_hash_table
+{
+ /* The hash array. */
+ struct bfd_hash_entry **table;
+ /* The number of slots in the hash table. */
+ unsigned int size;
+ /* A function used to create new elements in the hash table. The
+ first entry is itself a pointer to an element. When this
+ function is first invoked, this pointer will be NULL. However,
+ having the pointer permits a hierarchy of method functions to be
+ built each of which calls the function in the superclass. Thus
+ each function should be written to allocate a new block of memory
+ only if the argument is NULL. */
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+ /* An objalloc for this hash table. This is a struct objalloc *,
+ but we use PTR to avoid requiring the inclusion of objalloc.h. */
+ PTR memory;
+};
+
+/* Initialize a hash table. */
+extern boolean bfd_hash_table_init
+ PARAMS ((struct bfd_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+/* Initialize a hash table specifying a size. */
+extern boolean bfd_hash_table_init_n
+ PARAMS ((struct bfd_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *),
+ unsigned int size));
+
+/* Free up a hash table. */
+extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
+
+/* Look up a string in a hash table. If CREATE is true, a new entry
+ will be created for this string if one does not already exist. The
+ COPY argument must be true if this routine should copy the string
+ into newly allocated memory when adding an entry. */
+extern struct bfd_hash_entry *bfd_hash_lookup
+ PARAMS ((struct bfd_hash_table *, const char *, boolean create,
+ boolean copy));
+
+/* Replace an entry in a hash table. */
+extern void bfd_hash_replace
+ PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
+ struct bfd_hash_entry *nw));
+
+/* Base method for creating a hash table entry. */
+extern struct bfd_hash_entry *bfd_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
+ const char *));
+
+/* Grab some space for a hash table entry. */
+extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
+ unsigned int));
+
+/* Traverse a hash table in a random order, calling a function on each
+ element. If the function returns false, the traversal stops. The
+ INFO argument is passed to the function. */
+extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
+ boolean (*) (struct bfd_hash_entry *,
+ PTR),
+ PTR info));
+
+/* Semi-portable string concatenation in cpp.
+ The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
+ The problem is, "32_" is not a valid preprocessing token, and we don't
+ want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
+ inner CAT macros to be evaluated first, producing still-valid pp-tokens.
+ Then the final concatenation can be done. (Sigh.) */
+#ifndef CAT
+#ifdef SABER
+#define CAT(a,b) a##b
+#define CAT3(a,b,c) a##b##c
+#define CAT4(a,b,c,d) a##b##c##d
+#else
+#if defined(__STDC__) || defined(ALMOST_STDC)
+#define CAT(a,b) a##b
+#define CAT3(a,b,c) a##b##c
+#define XCAT2(a,b) CAT(a,b)
+#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
+#else
+#define CAT(a,b) a/**/b
+#define CAT3(a,b,c) a/**/b/**/c
+#define CAT4(a,b,c,d) a/**/b/**/c/**/d
+#endif
+#endif
+#endif
+
+#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
+
+/* User program access to BFD facilities */
+
+/* Direct I/O routines, for programs which know more about the object
+ file than BFD does. Use higher level routines if possible. */
+
+extern bfd_size_type bfd_read
+ PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
+extern bfd_size_type bfd_write
+ PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
+extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
+extern long bfd_tell PARAMS ((bfd *abfd));
+extern int bfd_flush PARAMS ((bfd *abfd));
+extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
+
+
+/* Cast from const char * to char * so that caller can assign to
+ a char * without a warning. */
+#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
+#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
+#define bfd_get_format(abfd) ((abfd)->format)
+#define bfd_get_target(abfd) ((abfd)->xvec->name)
+#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
+#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
+#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
+#define bfd_header_big_endian(abfd) \
+ ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
+#define bfd_header_little_endian(abfd) \
+ ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
+#define bfd_get_file_flags(abfd) ((abfd)->flags)
+#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
+#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
+#define bfd_my_archive(abfd) ((abfd)->my_archive)
+#define bfd_has_map(abfd) ((abfd)->has_armap)
+
+#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
+#define bfd_usrdata(abfd) ((abfd)->usrdata)
+
+#define bfd_get_start_address(abfd) ((abfd)->start_address)
+#define bfd_get_symcount(abfd) ((abfd)->symcount)
+#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
+#define bfd_count_sections(abfd) ((abfd)->section_count)
+
+#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
+
+#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
+
+extern boolean bfd_record_phdr
+ PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
+ boolean, boolean, unsigned int, struct sec **));
+
+/* Byte swapping routines. */
+
+bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
+bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
+bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
+void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
+void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
+
+/* Externally visible ECOFF routines. */
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct ecoff_debug_info;
+struct ecoff_debug_swap;
+struct ecoff_extr;
+struct symbol_cache_entry;
+struct bfd_link_info;
+struct bfd_link_hash_entry;
+struct bfd_elf_version_tree;
+#endif
+extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
+extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
+extern boolean bfd_ecoff_set_regmasks
+ PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
+ unsigned long *cprmask));
+extern PTR bfd_ecoff_debug_init
+ PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ struct bfd_link_info *));
+extern void bfd_ecoff_debug_free
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_accumulate
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ bfd *input_bfd, struct ecoff_debug_info *input_debug,
+ const struct ecoff_debug_swap *input_swap,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_accumulate_other
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_externals
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ boolean relocateable,
+ boolean (*get_extr) (struct symbol_cache_entry *,
+ struct ecoff_extr *),
+ void (*set_index) (struct symbol_cache_entry *,
+ bfd_size_type)));
+extern boolean bfd_ecoff_debug_one_external
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ const char *name, struct ecoff_extr *esym));
+extern bfd_size_type bfd_ecoff_debug_size
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap));
+extern boolean bfd_ecoff_write_debug
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap, file_ptr where));
+extern boolean bfd_ecoff_write_accumulated_debug
+ PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ struct bfd_link_info *info, file_ptr where));
+extern boolean bfd_mips_ecoff_create_embedded_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
+ char **));
+
+/* Externally visible ELF routines. */
+
+struct bfd_link_needed_list
+{
+ struct bfd_link_needed_list *next;
+ bfd *by;
+ const char *name;
+};
+
+extern boolean bfd_elf32_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
+extern boolean bfd_elf64_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
+extern struct bfd_link_needed_list *bfd_elf_get_needed_list
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_elf_get_bfd_needed_list
+ PARAMS ((bfd *, struct bfd_link_needed_list **));
+extern boolean bfd_elf32_size_dynamic_sections
+ PARAMS ((bfd *, const char *, const char *, boolean, const char *,
+ const char * const *, struct bfd_link_info *, struct sec **,
+ struct bfd_elf_version_tree *));
+extern boolean bfd_elf64_size_dynamic_sections
+ PARAMS ((bfd *, const char *, const char *, boolean, const char *,
+ const char * const *, struct bfd_link_info *, struct sec **,
+ struct bfd_elf_version_tree *));
+extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
+extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
+
+/* SunOS shared library support routines for the linker. */
+
+extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_sunos_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_sunos_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
+ struct sec **));
+
+/* Linux shared library support routines for the linker. */
+
+extern boolean bfd_i386linux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_m68klinux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_sparclinux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* mmap hacks */
+
+struct _bfd_window_internal;
+typedef struct _bfd_window_internal bfd_window_internal;
+
+typedef struct _bfd_window {
+ /* What the user asked for. */
+ PTR data;
+ bfd_size_type size;
+ /* The actual window used by BFD. Small user-requested read-only
+ regions sharing a page may share a single window into the object
+ file. Read-write versions shouldn't until I've fixed things to
+ keep track of which portions have been claimed by the
+ application; don't want to give the same region back when the
+ application wants two writable copies! */
+ struct _bfd_window_internal *i;
+} bfd_window;
+
+extern void bfd_init_window PARAMS ((bfd_window *));
+extern void bfd_free_window PARAMS ((bfd_window *));
+extern boolean bfd_get_file_window
+ PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean));
+
+/* XCOFF support routines for the linker. */
+
+extern boolean bfd_xcoff_link_record_set
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
+ bfd_size_type));
+extern boolean bfd_xcoff_import_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
+ bfd_vma, const char *, const char *, const char *));
+extern boolean bfd_xcoff_export_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
+ boolean));
+extern boolean bfd_xcoff_link_count_reloc
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_xcoff_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_xcoff_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
+ unsigned long, unsigned long, unsigned long, boolean,
+ int, boolean, boolean, struct sec **));
+
+/* Externally visible COFF routines. */
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct internal_syment;
+union internal_auxent;
+#endif
+
+extern boolean bfd_coff_get_syment
+ PARAMS ((bfd *, struct symbol_cache_entry *, struct internal_syment *));
+
+extern boolean bfd_coff_get_auxent
+ PARAMS ((bfd *, struct symbol_cache_entry *, int, union internal_auxent *));
+
+extern boolean bfd_coff_set_symbol_class
+ PARAMS ((bfd *, struct symbol_cache_entry *, unsigned int));
+
+/* ARM Interworking support. Called from linker. */
+extern boolean bfd_arm_allocate_interworking_sections
+ PARAMS ((struct bfd_link_info *));
+
+extern boolean bfd_arm_process_before_allocation
+ PARAMS ((bfd *, struct bfd_link_info *, int));
+
+extern boolean bfd_arm_get_bfd_for_interworking
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* ELF ARM Interworking support. Called from linker. */
+ extern boolean bfd_elf32_arm_allocate_interworking_sections
+ PARAMS ((struct bfd_link_info *));
+
+ extern boolean bfd_elf32_arm_process_before_allocation
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+ extern boolean bfd_elf32_arm_get_bfd_for_interworking
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* And more from the source. */
+void
+bfd_init PARAMS ((void));
+
+bfd *
+bfd_openr PARAMS ((CONST char *filename, CONST char *target));
+
+bfd *
+bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd));
+
+bfd *
+bfd_openstreamr PARAMS ((const char *, const char *, PTR));
+
+bfd *
+bfd_openw PARAMS ((CONST char *filename, CONST char *target));
+
+boolean
+bfd_close PARAMS ((bfd *abfd));
+
+boolean
+bfd_close_all_done PARAMS ((bfd *));
+
+bfd *
+bfd_create PARAMS ((CONST char *filename, bfd *templ));
+
+boolean
+bfd_make_writable PARAMS ((bfd *abfd));
+
+boolean
+bfd_make_readable PARAMS ((bfd *abfd));
+
+
+ /* Byte swapping macros for user section data. */
+
+#define bfd_put_8(abfd, val, ptr) \
+ (*((unsigned char *)(ptr)) = (unsigned char)(val))
+#define bfd_put_signed_8 \
+ bfd_put_8
+#define bfd_get_8(abfd, ptr) \
+ (*(unsigned char *)(ptr))
+#define bfd_get_signed_8(abfd, ptr) \
+ ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
+
+#define bfd_put_16(abfd, val, ptr) \
+ BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
+#define bfd_put_signed_16 \
+ bfd_put_16
+#define bfd_get_16(abfd, ptr) \
+ BFD_SEND(abfd, bfd_getx16, (ptr))
+#define bfd_get_signed_16(abfd, ptr) \
+ BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
+
+#define bfd_put_32(abfd, val, ptr) \
+ BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
+#define bfd_put_signed_32 \
+ bfd_put_32
+#define bfd_get_32(abfd, ptr) \
+ BFD_SEND(abfd, bfd_getx32, (ptr))
+#define bfd_get_signed_32(abfd, ptr) \
+ BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
+
+#define bfd_put_64(abfd, val, ptr) \
+ BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
+#define bfd_put_signed_64 \
+ bfd_put_64
+#define bfd_get_64(abfd, ptr) \
+ BFD_SEND(abfd, bfd_getx64, (ptr))
+#define bfd_get_signed_64(abfd, ptr) \
+ BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
+
+
+ /* Byte swapping macros for file header data. */
+
+#define bfd_h_put_8(abfd, val, ptr) \
+ bfd_put_8 (abfd, val, ptr)
+#define bfd_h_put_signed_8(abfd, val, ptr) \
+ bfd_put_8 (abfd, val, ptr)
+#define bfd_h_get_8(abfd, ptr) \
+ bfd_get_8 (abfd, ptr)
+#define bfd_h_get_signed_8(abfd, ptr) \
+ bfd_get_signed_8 (abfd, ptr)
+
+#define bfd_h_put_16(abfd, val, ptr) \
+ BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
+#define bfd_h_put_signed_16 \
+ bfd_h_put_16
+#define bfd_h_get_16(abfd, ptr) \
+ BFD_SEND(abfd, bfd_h_getx16,(ptr))
+#define bfd_h_get_signed_16(abfd, ptr) \
+ BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
+
+#define bfd_h_put_32(abfd, val, ptr) \
+ BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
+#define bfd_h_put_signed_32 \
+ bfd_h_put_32
+#define bfd_h_get_32(abfd, ptr) \
+ BFD_SEND(abfd, bfd_h_getx32,(ptr))
+#define bfd_h_get_signed_32(abfd, ptr) \
+ BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
+
+#define bfd_h_put_64(abfd, val, ptr) \
+ BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
+#define bfd_h_put_signed_64 \
+ bfd_h_put_64
+#define bfd_h_get_64(abfd, ptr) \
+ BFD_SEND(abfd, bfd_h_getx64,(ptr))
+#define bfd_h_get_signed_64(abfd, ptr) \
+ BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
+
+typedef struct sec
+{
+ /* The name of the section; the name isn't a copy, the pointer is
+ the same as that passed to bfd_make_section. */
+
+ CONST char *name;
+
+ /* Which section is it; 0..nth. */
+
+ int index;
+
+ /* The next section in the list belonging to the BFD, or NULL. */
+
+ struct sec *next;
+
+ /* The field flags contains attributes of the section. Some
+ flags are read in from the object file, and some are
+ synthesized from other information. */
+
+ flagword flags;
+
+#define SEC_NO_FLAGS 0x000
+
+ /* Tells the OS to allocate space for this section when loading.
+ This is clear for a section containing debug information
+ only. */
+#define SEC_ALLOC 0x001
+
+ /* Tells the OS to load the section from the file when loading.
+ This is clear for a .bss section. */
+#define SEC_LOAD 0x002
+
+ /* The section contains data still to be relocated, so there is
+ some relocation information too. */
+#define SEC_RELOC 0x004
+
+#if 0 /* Obsolete ? */
+#define SEC_BALIGN 0x008
+#endif
+
+ /* A signal to the OS that the section contains read only
+ data. */
+#define SEC_READONLY 0x010
+
+ /* The section contains code only. */
+#define SEC_CODE 0x020
+
+ /* The section contains data only. */
+#define SEC_DATA 0x040
+
+ /* The section will reside in ROM. */
+#define SEC_ROM 0x080
+
+ /* The section contains constructor information. This section
+ type is used by the linker to create lists of constructors and
+ destructors used by <<g++>>. When a back end sees a symbol
+ which should be used in a constructor list, it creates a new
+ section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
+ the symbol to it, and builds a relocation. To build the lists
+ of constructors, all the linker has to do is catenate all the
+ sections called <<__CTOR_LIST__>> and relocate the data
+ contained within - exactly the operations it would peform on
+ standard data. */
+#define SEC_CONSTRUCTOR 0x100
+
+ /* The section is a constructor, and should be placed at the
+ end of the text, data, or bss section(?). */
+#define SEC_CONSTRUCTOR_TEXT 0x1100
+#define SEC_CONSTRUCTOR_DATA 0x2100
+#define SEC_CONSTRUCTOR_BSS 0x3100
+
+ /* The section has contents - a data section could be
+ <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
+ <<SEC_HAS_CONTENTS>> */
+#define SEC_HAS_CONTENTS 0x200
+
+ /* An instruction to the linker to not output the section
+ even if it has information which would normally be written. */
+#define SEC_NEVER_LOAD 0x400
+
+ /* The section is a COFF shared library section. This flag is
+ only for the linker. If this type of section appears in
+ the input file, the linker must copy it to the output file
+ without changing the vma or size. FIXME: Although this
+ was originally intended to be general, it really is COFF
+ specific (and the flag was renamed to indicate this). It
+ might be cleaner to have some more general mechanism to
+ allow the back end to control what the linker does with
+ sections. */
+#define SEC_COFF_SHARED_LIBRARY 0x800
+
+ /* The section contains common symbols (symbols may be defined
+ multiple times, the value of a symbol is the amount of
+ space it requires, and the largest symbol value is the one
+ used). Most targets have exactly one of these (which we
+ translate to bfd_com_section_ptr), but ECOFF has two. */
+#define SEC_IS_COMMON 0x8000
+
+ /* The section contains only debugging information. For
+ example, this is set for ELF .debug and .stab sections.
+ strip tests this flag to see if a section can be
+ discarded. */
+#define SEC_DEBUGGING 0x10000
+
+ /* The contents of this section are held in memory pointed to
+ by the contents field. This is checked by
+ bfd_get_section_contents, and the data is retrieved from
+ memory if appropriate. */
+#define SEC_IN_MEMORY 0x20000
+
+ /* The contents of this section are to be excluded by the
+ linker for executable and shared objects unless those
+ objects are to be further relocated. */
+#define SEC_EXCLUDE 0x40000
+
+ /* The contents of this section are to be sorted by the
+ based on the address specified in the associated symbol
+ table. */
+#define SEC_SORT_ENTRIES 0x80000
+
+ /* When linking, duplicate sections of the same name should be
+ discarded, rather than being combined into a single section as
+ is usually done. This is similar to how common symbols are
+ handled. See SEC_LINK_DUPLICATES below. */
+#define SEC_LINK_ONCE 0x100000
+
+ /* If SEC_LINK_ONCE is set, this bitfield describes how the linker
+ should handle duplicate sections. */
+#define SEC_LINK_DUPLICATES 0x600000
+
+ /* This value for SEC_LINK_DUPLICATES means that duplicate
+ sections with the same name should simply be discarded. */
+#define SEC_LINK_DUPLICATES_DISCARD 0x0
+
+ /* This value for SEC_LINK_DUPLICATES means that the linker
+ should warn if there are any duplicate sections, although
+ it should still only link one copy. */
+#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000
+
+ /* This value for SEC_LINK_DUPLICATES means that the linker
+ should warn if any duplicate sections are a different size. */
+#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000
+
+ /* This value for SEC_LINK_DUPLICATES means that the linker
+ should warn if any duplicate sections contain different
+ contents. */
+#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000
+
+ /* This section was created by the linker as part of dynamic
+ relocation or other arcane processing. It is skipped when
+ going through the first-pass output, trusting that someone
+ else up the line will take care of it later. */
+#define SEC_LINKER_CREATED 0x800000
+
+ /* This section should not be subject to garbage collection. */
+#define SEC_KEEP 0x1000000
+
+ /* End of section flags. */
+
+ /* Some internal packed boolean fields. */
+
+ /* See the vma field. */
+ unsigned int user_set_vma : 1;
+
+ /* Whether relocations have been processed. */
+ unsigned int reloc_done : 1;
+
+ /* A mark flag used by some of the linker backends. */
+ unsigned int linker_mark : 1;
+
+ /* A mark flag used by some linker backends for garbage collection. */
+ unsigned int gc_mark : 1;
+
+ /* End of internal packed boolean fields. */
+
+ /* The virtual memory address of the section - where it will be
+ at run time. The symbols are relocated against this. The
+ user_set_vma flag is maintained by bfd; if it's not set, the
+ backend can assign addresses (for example, in <<a.out>>, where
+ the default address for <<.data>> is dependent on the specific
+ target and various flags). */
+
+ bfd_vma vma;
+
+ /* The load address of the section - where it would be in a
+ rom image; really only used for writing section header
+ information. */
+
+ bfd_vma lma;
+
+ /* The size of the section in bytes, as it will be output.
+ contains a value even if the section has no contents (e.g., the
+ size of <<.bss>>). This will be filled in after relocation */
+
+ bfd_size_type _cooked_size;
+
+ /* The original size on disk of the section, in bytes. Normally this
+ value is the same as the size, but if some relaxing has
+ been done, then this value will be bigger. */
+
+ bfd_size_type _raw_size;
+
+ /* If this section is going to be output, then this value is the
+ offset into the output section of the first byte in the input
+ section. E.g., if this was going to start at the 100th byte in
+ the output section, this value would be 100. */
+
+ bfd_vma output_offset;
+
+ /* The output section through which to map on output. */
+
+ struct sec *output_section;
+
+ /* The alignment requirement of the section, as an exponent of 2 -
+ e.g., 3 aligns to 2^3 (or 8). */
+
+ unsigned int alignment_power;
+
+ /* If an input section, a pointer to a vector of relocation
+ records for the data in this section. */
+
+ struct reloc_cache_entry *relocation;
+
+ /* If an output section, a pointer to a vector of pointers to
+ relocation records for the data in this section. */
+
+ struct reloc_cache_entry **orelocation;
+
+ /* The number of relocation records in one of the above */
+
+ unsigned reloc_count;
+
+ /* Information below is back end specific - and not always used
+ or updated. */
+
+ /* File position of section data */
+
+ file_ptr filepos;
+
+ /* File position of relocation info */
+
+ file_ptr rel_filepos;
+
+ /* File position of line data */
+
+ file_ptr line_filepos;
+
+ /* Pointer to data for applications */
+
+ PTR userdata;
+
+ /* If the SEC_IN_MEMORY flag is set, this points to the actual
+ contents. */
+ unsigned char *contents;
+
+ /* Attached line number information */
+
+ alent *lineno;
+
+ /* Number of line number records */
+
+ unsigned int lineno_count;
+
+ /* When a section is being output, this value changes as more
+ linenumbers are written out */
+
+ file_ptr moving_line_filepos;
+
+ /* What the section number is in the target world */
+
+ int target_index;
+
+ PTR used_by_bfd;
+
+ /* If this is a constructor section then here is a list of the
+ relocations created to relocate items within it. */
+
+ struct relent_chain *constructor_chain;
+
+ /* The BFD which owns the section. */
+
+ bfd *owner;
+
+ /* A symbol which points at this section only */
+ struct symbol_cache_entry *symbol;
+ struct symbol_cache_entry **symbol_ptr_ptr;
+
+ struct bfd_link_order *link_order_head;
+ struct bfd_link_order *link_order_tail;
+} asection ;
+
+ /* These sections are global, and are managed by BFD. The application
+ and target back end are not permitted to change the values in
+ these sections. New code should use the section_ptr macros rather
+ than referring directly to the const sections. The const sections
+ may eventually vanish. */
+#define BFD_ABS_SECTION_NAME "*ABS*"
+#define BFD_UND_SECTION_NAME "*UND*"
+#define BFD_COM_SECTION_NAME "*COM*"
+#define BFD_IND_SECTION_NAME "*IND*"
+
+ /* the absolute section */
+extern const asection bfd_abs_section;
+#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
+#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
+ /* Pointer to the undefined section */
+extern const asection bfd_und_section;
+#define bfd_und_section_ptr ((asection *) &bfd_und_section)
+#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
+ /* Pointer to the common section */
+extern const asection bfd_com_section;
+#define bfd_com_section_ptr ((asection *) &bfd_com_section)
+ /* Pointer to the indirect section */
+extern const asection bfd_ind_section;
+#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
+#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
+
+extern const struct symbol_cache_entry * const bfd_abs_symbol;
+extern const struct symbol_cache_entry * const bfd_com_symbol;
+extern const struct symbol_cache_entry * const bfd_und_symbol;
+extern const struct symbol_cache_entry * const bfd_ind_symbol;
+#define bfd_get_section_size_before_reloc(section) \
+ (section->reloc_done ? (abort(),1): (section)->_raw_size)
+#define bfd_get_section_size_after_reloc(section) \
+ ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
+asection *
+bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name));
+
+asection *
+bfd_make_section_old_way PARAMS ((bfd *abfd, CONST char *name));
+
+asection *
+bfd_make_section_anyway PARAMS ((bfd *abfd, CONST char *name));
+
+asection *
+bfd_make_section PARAMS ((bfd *, CONST char *name));
+
+boolean
+bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags));
+
+void
+bfd_map_over_sections PARAMS ((bfd *abfd,
+ void (*func)(bfd *abfd,
+ asection *sect,
+ PTR obj),
+ PTR obj));
+
+boolean
+bfd_set_section_size PARAMS ((bfd *abfd, asection *sec, bfd_size_type val));
+
+boolean
+bfd_set_section_contents
+ PARAMS ((bfd *abfd,
+ asection *section,
+ PTR data,
+ file_ptr offset,
+ bfd_size_type count));
+
+boolean
+bfd_get_section_contents
+ PARAMS ((bfd *abfd, asection *section, PTR location,
+ file_ptr offset, bfd_size_type count));
+
+boolean
+bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec));
+
+#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
+ BFD_SEND (obfd, _bfd_copy_private_section_data, \
+ (ibfd, isection, obfd, osection))
+void
+_bfd_strip_section_from_output
+ PARAMS ((asection *section));
+
+enum bfd_architecture
+{
+ bfd_arch_unknown, /* File arch not known */
+ bfd_arch_obscure, /* Arch known, not one of these */
+ bfd_arch_m68k, /* Motorola 68xxx */
+#define bfd_mach_m68000 1
+#define bfd_mach_m68008 2
+#define bfd_mach_m68010 3
+#define bfd_mach_m68020 4
+#define bfd_mach_m68030 5
+#define bfd_mach_m68040 6
+#define bfd_mach_m68060 7
+#define bfd_mach_cpu32 8
+ bfd_arch_vax, /* DEC Vax */
+ bfd_arch_i960, /* Intel 960 */
+ /* The order of the following is important.
+ lower number indicates a machine type that
+ only accepts a subset of the instructions
+ available to machines with higher numbers.
+ The exception is the "ca", which is
+ incompatible with all other machines except
+ "core". */
+
+#define bfd_mach_i960_core 1
+#define bfd_mach_i960_ka_sa 2
+#define bfd_mach_i960_kb_sb 3
+#define bfd_mach_i960_mc 4
+#define bfd_mach_i960_xa 5
+#define bfd_mach_i960_ca 6
+#define bfd_mach_i960_jx 7
+#define bfd_mach_i960_hx 8
+
+ bfd_arch_a29k, /* AMD 29000 */
+ bfd_arch_sparc, /* SPARC */
+#define bfd_mach_sparc 1
+ /* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
+#define bfd_mach_sparc_sparclet 2
+#define bfd_mach_sparc_sparclite 3
+#define bfd_mach_sparc_v8plus 4
+#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns */
+#define bfd_mach_sparc_sparclite_le 6
+#define bfd_mach_sparc_v9 7
+#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns */
+ /* Nonzero if MACH has the v9 instruction set. */
+#define bfd_mach_sparc_v9_p(mach) \
+ ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a)
+ bfd_arch_mips, /* MIPS Rxxxx */
+#define bfd_mach_mips3000 3000
+#define bfd_mach_mips3900 3900
+#define bfd_mach_mips4000 4000
+#define bfd_mach_mips4010 4010
+#define bfd_mach_mips4100 4100
+#define bfd_mach_mips4111 4111
+#define bfd_mach_mips4300 4300
+#define bfd_mach_mips4400 4400
+#define bfd_mach_mips4600 4600
+#define bfd_mach_mips4650 4650
+#define bfd_mach_mips5000 5000
+#define bfd_mach_mips6000 6000
+#define bfd_mach_mips8000 8000
+#define bfd_mach_mips10000 10000
+#define bfd_mach_mips16 16
+ bfd_arch_i386, /* Intel 386 */
+#define bfd_mach_i386_i386 0
+#define bfd_mach_i386_i8086 1
+#define bfd_mach_i386_i386_intel_syntax 2
+ bfd_arch_we32k, /* AT&T WE32xxx */
+ bfd_arch_tahoe, /* CCI/Harris Tahoe */
+ bfd_arch_i860, /* Intel 860 */
+ bfd_arch_romp, /* IBM ROMP PC/RT */
+ bfd_arch_alliant, /* Alliant */
+ bfd_arch_convex, /* Convex */
+ bfd_arch_m88k, /* Motorola 88xxx */
+ bfd_arch_pyramid, /* Pyramid Technology */
+ bfd_arch_h8300, /* Hitachi H8/300 */
+#define bfd_mach_h8300 1
+#define bfd_mach_h8300h 2
+#define bfd_mach_h8300s 3
+ bfd_arch_powerpc, /* PowerPC */
+ bfd_arch_rs6000, /* IBM RS/6000 */
+ bfd_arch_hppa, /* HP PA RISC */
+ bfd_arch_d10v, /* Mitsubishi D10V */
+ bfd_arch_d30v, /* Mitsubishi D30V */
+ bfd_arch_z8k, /* Zilog Z8000 */
+#define bfd_mach_z8001 1
+#define bfd_mach_z8002 2
+ bfd_arch_h8500, /* Hitachi H8/500 */
+ bfd_arch_sh, /* Hitachi SH */
+#define bfd_mach_sh 0
+#define bfd_mach_sh3 0x30
+#define bfd_mach_sh3e 0x3e
+ bfd_arch_alpha, /* Dec Alpha */
+#define bfd_mach_alpha_ev4 0x10
+#define bfd_mach_alpha_ev5 0x20
+#define bfd_mach_alpha_ev6 0x30
+ bfd_arch_arm, /* Advanced Risc Machines ARM */
+#define bfd_mach_arm_2 1
+#define bfd_mach_arm_2a 2
+#define bfd_mach_arm_3 3
+#define bfd_mach_arm_3M 4
+#define bfd_mach_arm_4 5
+#define bfd_mach_arm_4T 6
+ bfd_arch_ns32k, /* National Semiconductors ns32000 */
+ bfd_arch_w65, /* WDC 65816 */
+ bfd_arch_tic30, /* Texas Instruments TMS320C30 */
+ bfd_arch_tic80, /* TI TMS320c80 (MVP) */
+ bfd_arch_v850, /* NEC V850 */
+#define bfd_mach_v850 0
+#define bfd_mach_v850e 'E'
+#define bfd_mach_v850ea 'A'
+ bfd_arch_arc, /* Argonaut RISC Core */
+#define bfd_mach_arc_base 0
+ bfd_arch_m32r, /* Mitsubishi M32R/D */
+#define bfd_mach_m32r 0 /* backwards compatibility */
+ bfd_arch_mn10200, /* Matsushita MN10200 */
+ bfd_arch_mn10300, /* Matsushita MN10300 */
+#define bfd_mach_mn10300 300
+ bfd_arch_fr30,
+#define bfd_mach_fr30 0x46523330
+ bfd_arch_mcore,
+ bfd_arch_last
+ };
+
+typedef struct bfd_arch_info
+{
+ int bits_per_word;
+ int bits_per_address;
+ int bits_per_byte;
+ enum bfd_architecture arch;
+ unsigned long mach;
+ const char *arch_name;
+ const char *printable_name;
+ unsigned int section_align_power;
+ /* true if this is the default machine for the architecture */
+ boolean the_default;
+ const struct bfd_arch_info * (*compatible)
+ PARAMS ((const struct bfd_arch_info *a,
+ const struct bfd_arch_info *b));
+
+ boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
+
+ const struct bfd_arch_info *next;
+} bfd_arch_info_type;
+const char *
+bfd_printable_name PARAMS ((bfd *abfd));
+
+const bfd_arch_info_type *
+bfd_scan_arch PARAMS ((const char *string));
+
+const char **
+bfd_arch_list PARAMS ((void));
+
+const bfd_arch_info_type *
+bfd_arch_get_compatible PARAMS ((
+ const bfd *abfd,
+ const bfd *bbfd));
+
+void
+bfd_set_arch_info PARAMS ((bfd *abfd, const bfd_arch_info_type *arg));
+
+enum bfd_architecture
+bfd_get_arch PARAMS ((bfd *abfd));
+
+unsigned long
+bfd_get_mach PARAMS ((bfd *abfd));
+
+unsigned int
+bfd_arch_bits_per_byte PARAMS ((bfd *abfd));
+
+unsigned int
+bfd_arch_bits_per_address PARAMS ((bfd *abfd));
+
+const bfd_arch_info_type *
+bfd_get_arch_info PARAMS ((bfd *abfd));
+
+const bfd_arch_info_type *
+bfd_lookup_arch
+ PARAMS ((enum bfd_architecture
+ arch,
+ unsigned long machine));
+
+const char *
+bfd_printable_arch_mach
+ PARAMS ((enum bfd_architecture arch, unsigned long machine));
+
+typedef enum bfd_reloc_status
+{
+ /* No errors detected */
+ bfd_reloc_ok,
+
+ /* The relocation was performed, but there was an overflow. */
+ bfd_reloc_overflow,
+
+ /* The address to relocate was not within the section supplied. */
+ bfd_reloc_outofrange,
+
+ /* Used by special functions */
+ bfd_reloc_continue,
+
+ /* Unsupported relocation size requested. */
+ bfd_reloc_notsupported,
+
+ /* Unused */
+ bfd_reloc_other,
+
+ /* The symbol to relocate against was undefined. */
+ bfd_reloc_undefined,
+
+ /* The relocation was performed, but may not be ok - presently
+ generated only when linking i960 coff files with i960 b.out
+ symbols. If this type is returned, the error_message argument
+ to bfd_perform_relocation will be set. */
+ bfd_reloc_dangerous
+ }
+ bfd_reloc_status_type;
+
+
+typedef struct reloc_cache_entry
+{
+ /* A pointer into the canonical table of pointers */
+ struct symbol_cache_entry **sym_ptr_ptr;
+
+ /* offset in section */
+ bfd_size_type address;
+
+ /* addend for relocation value */
+ bfd_vma addend;
+
+ /* Pointer to how to perform the required relocation */
+ reloc_howto_type *howto;
+
+} arelent;
+enum complain_overflow
+{
+ /* Do not complain on overflow. */
+ complain_overflow_dont,
+
+ /* Complain if the bitfield overflows, whether it is considered
+ as signed or unsigned. */
+ complain_overflow_bitfield,
+
+ /* Complain if the value overflows when considered as signed
+ number. */
+ complain_overflow_signed,
+
+ /* Complain if the value overflows when considered as an
+ unsigned number. */
+ complain_overflow_unsigned
+};
+
+struct reloc_howto_struct
+{
+ /* The type field has mainly a documentary use - the back end can
+ do what it wants with it, though normally the back end's
+ external idea of what a reloc number is stored
+ in this field. For example, a PC relative word relocation
+ in a coff environment has the type 023 - because that's
+ what the outside world calls a R_PCRWORD reloc. */
+ unsigned int type;
+
+ /* The value the final relocation is shifted right by. This drops
+ unwanted data from the relocation. */
+ unsigned int rightshift;
+
+ /* The size of the item to be relocated. This is *not* a
+ power-of-two measure. To get the number of bytes operated
+ on by a type of relocation, use bfd_get_reloc_size. */
+ int size;
+
+ /* The number of bits in the item to be relocated. This is used
+ when doing overflow checking. */
+ unsigned int bitsize;
+
+ /* Notes that the relocation is relative to the location in the
+ data section of the addend. The relocation function will
+ subtract from the relocation value the address of the location
+ being relocated. */
+ boolean pc_relative;
+
+ /* The bit position of the reloc value in the destination.
+ The relocated value is left shifted by this amount. */
+ unsigned int bitpos;
+
+ /* What type of overflow error should be checked for when
+ relocating. */
+ enum complain_overflow complain_on_overflow;
+
+ /* If this field is non null, then the supplied function is
+ called rather than the normal function. This allows really
+ strange relocation methods to be accomodated (e.g., i960 callj
+ instructions). */
+ bfd_reloc_status_type (*special_function)
+ PARAMS ((bfd *abfd,
+ arelent *reloc_entry,
+ struct symbol_cache_entry *symbol,
+ PTR data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message));
+
+ /* The textual name of the relocation type. */
+ char *name;
+
+ /* When performing a partial link, some formats must modify the
+ relocations rather than the data - this flag signals this.*/
+ boolean partial_inplace;
+
+ /* The src_mask selects which parts of the read in data
+ are to be used in the relocation sum. E.g., if this was an 8 bit
+ bit of data which we read and relocated, this would be
+ 0x000000ff. When we have relocs which have an addend, such as
+ sun4 extended relocs, the value in the offset part of a
+ relocating field is garbage so we never use it. In this case
+ the mask would be 0x00000000. */
+ bfd_vma src_mask;
+
+ /* The dst_mask selects which parts of the instruction are replaced
+ into the instruction. In most cases src_mask == dst_mask,
+ except in the above special case, where dst_mask would be
+ 0x000000ff, and src_mask would be 0x00000000. */
+ bfd_vma dst_mask;
+
+ /* When some formats create PC relative instructions, they leave
+ the value of the pc of the place being relocated in the offset
+ slot of the instruction, so that a PC relative relocation can
+ be made just by adding in an ordinary offset (e.g., sun3 a.out).
+ Some formats leave the displacement part of an instruction
+ empty (e.g., m88k bcs); this flag signals the fact.*/
+ boolean pcrel_offset;
+
+};
+#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
+ {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
+#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
+
+#define HOWTO_PREPARE(relocation, symbol) \
+ { \
+ if (symbol != (asymbol *)NULL) { \
+ if (bfd_is_com_section (symbol->section)) { \
+ relocation = 0; \
+ } \
+ else { \
+ relocation = symbol->value; \
+ } \
+ } \
+}
+unsigned int
+bfd_get_reloc_size PARAMS ((reloc_howto_type *));
+
+typedef struct relent_chain {
+ arelent relent;
+ struct relent_chain *next;
+} arelent_chain;
+bfd_reloc_status_type
+
+bfd_check_overflow
+ PARAMS ((enum complain_overflow how,
+ unsigned int bitsize,
+ unsigned int rightshift,
+ unsigned int addrsize,
+ bfd_vma relocation));
+
+bfd_reloc_status_type
+
+bfd_perform_relocation
+ PARAMS ((bfd *abfd,
+ arelent *reloc_entry,
+ PTR data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message));
+
+bfd_reloc_status_type
+
+bfd_install_relocation
+ PARAMS ((bfd *abfd,
+ arelent *reloc_entry,
+ PTR data, bfd_vma data_start,
+ asection *input_section,
+ char **error_message));
+
+enum bfd_reloc_code_real {
+ _dummy_first_bfd_reloc_code_real,
+
+
+/* Basic absolute relocations of N bits. */
+ BFD_RELOC_64,
+ BFD_RELOC_32,
+ BFD_RELOC_26,
+ BFD_RELOC_24,
+ BFD_RELOC_16,
+ BFD_RELOC_14,
+ BFD_RELOC_8,
+
+/* PC-relative relocations. Sometimes these are relative to the address
+of the relocation itself; sometimes they are relative to the start of
+the section containing the relocation. It depends on the specific target.
+
+The 24-bit relocation is used in some Intel 960 configurations. */
+ BFD_RELOC_64_PCREL,
+ BFD_RELOC_32_PCREL,
+ BFD_RELOC_24_PCREL,
+ BFD_RELOC_16_PCREL,
+ BFD_RELOC_12_PCREL,
+ BFD_RELOC_8_PCREL,
+
+/* For ELF. */
+ BFD_RELOC_32_GOT_PCREL,
+ BFD_RELOC_16_GOT_PCREL,
+ BFD_RELOC_8_GOT_PCREL,
+ BFD_RELOC_32_GOTOFF,
+ BFD_RELOC_16_GOTOFF,
+ BFD_RELOC_LO16_GOTOFF,
+ BFD_RELOC_HI16_GOTOFF,
+ BFD_RELOC_HI16_S_GOTOFF,
+ BFD_RELOC_8_GOTOFF,
+ BFD_RELOC_32_PLT_PCREL,
+ BFD_RELOC_24_PLT_PCREL,
+ BFD_RELOC_16_PLT_PCREL,
+ BFD_RELOC_8_PLT_PCREL,
+ BFD_RELOC_32_PLTOFF,
+ BFD_RELOC_16_PLTOFF,
+ BFD_RELOC_LO16_PLTOFF,
+ BFD_RELOC_HI16_PLTOFF,
+ BFD_RELOC_HI16_S_PLTOFF,
+ BFD_RELOC_8_PLTOFF,
+
+/* Relocations used by 68K ELF. */
+ BFD_RELOC_68K_GLOB_DAT,
+ BFD_RELOC_68K_JMP_SLOT,
+ BFD_RELOC_68K_RELATIVE,
+
+/* Linkage-table relative. */
+ BFD_RELOC_32_BASEREL,
+ BFD_RELOC_16_BASEREL,
+ BFD_RELOC_LO16_BASEREL,
+ BFD_RELOC_HI16_BASEREL,
+ BFD_RELOC_HI16_S_BASEREL,
+ BFD_RELOC_8_BASEREL,
+ BFD_RELOC_RVA,
+
+/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */
+ BFD_RELOC_8_FFnn,
+
+/* These PC-relative relocations are stored as word displacements --
+i.e., byte displacements shifted right two bits. The 30-bit word
+displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
+SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
+signed 16-bit displacement is used on the MIPS, and the 23-bit
+displacement is used on the Alpha. */
+ BFD_RELOC_32_PCREL_S2,
+ BFD_RELOC_16_PCREL_S2,
+ BFD_RELOC_23_PCREL_S2,
+
+/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
+the target word. These are used on the SPARC. */
+ BFD_RELOC_HI22,
+ BFD_RELOC_LO10,
+
+/* For systems that allocate a Global Pointer register, these are
+displacements off that register. These relocation types are
+handled specially, because the value the register will have is
+decided relatively late. */
+ BFD_RELOC_GPREL16,
+ BFD_RELOC_GPREL32,
+
+/* Reloc types used for i960/b.out. */
+ BFD_RELOC_I960_CALLJ,
+
+/* SPARC ELF relocations. There is probably some overlap with other
+relocation types already defined. */
+ BFD_RELOC_NONE,
+ BFD_RELOC_SPARC_WDISP22,
+ BFD_RELOC_SPARC22,
+ BFD_RELOC_SPARC13,
+ BFD_RELOC_SPARC_GOT10,
+ BFD_RELOC_SPARC_GOT13,
+ BFD_RELOC_SPARC_GOT22,
+ BFD_RELOC_SPARC_PC10,
+ BFD_RELOC_SPARC_PC22,
+ BFD_RELOC_SPARC_WPLT30,
+ BFD_RELOC_SPARC_COPY,
+ BFD_RELOC_SPARC_GLOB_DAT,
+ BFD_RELOC_SPARC_JMP_SLOT,
+ BFD_RELOC_SPARC_RELATIVE,
+ BFD_RELOC_SPARC_UA32,
+
+/* I think these are specific to SPARC a.out (e.g., Sun 4). */
+ BFD_RELOC_SPARC_BASE13,
+ BFD_RELOC_SPARC_BASE22,
+
+/* SPARC64 relocations */
+#define BFD_RELOC_SPARC_64 BFD_RELOC_64
+ BFD_RELOC_SPARC_10,
+ BFD_RELOC_SPARC_11,
+ BFD_RELOC_SPARC_OLO10,
+ BFD_RELOC_SPARC_HH22,
+ BFD_RELOC_SPARC_HM10,
+ BFD_RELOC_SPARC_LM22,
+ BFD_RELOC_SPARC_PC_HH22,
+ BFD_RELOC_SPARC_PC_HM10,
+ BFD_RELOC_SPARC_PC_LM22,
+ BFD_RELOC_SPARC_WDISP16,
+ BFD_RELOC_SPARC_WDISP19,
+ BFD_RELOC_SPARC_7,
+ BFD_RELOC_SPARC_6,
+ BFD_RELOC_SPARC_5,
+#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL
+ BFD_RELOC_SPARC_PLT64,
+ BFD_RELOC_SPARC_HIX22,
+ BFD_RELOC_SPARC_LOX10,
+ BFD_RELOC_SPARC_H44,
+ BFD_RELOC_SPARC_M44,
+ BFD_RELOC_SPARC_L44,
+ BFD_RELOC_SPARC_REGISTER,
+
+/* SPARC little endian relocation */
+ BFD_RELOC_SPARC_REV32,
+
+/* Alpha ECOFF and ELF relocations. Some of these treat the symbol or
+"addend" in some special way.
+For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
+writing; when reading, it will be the absolute section symbol. The
+addend is the displacement in bytes of the "lda" instruction from
+the "ldah" instruction (which is at the address of this reloc). */
+ BFD_RELOC_ALPHA_GPDISP_HI16,
+
+/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
+with GPDISP_HI16 relocs. The addend is ignored when writing the
+relocations out, and is filled in with the file's GP value on
+reading, for convenience. */
+ BFD_RELOC_ALPHA_GPDISP_LO16,
+
+/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
+relocation except that there is no accompanying GPDISP_LO16
+relocation. */
+ BFD_RELOC_ALPHA_GPDISP,
+
+/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
+the assembler turns it into a LDQ instruction to load the address of
+the symbol, and then fills in a register in the real instruction.
+
+The LITERAL reloc, at the LDQ instruction, refers to the .lita
+section symbol. The addend is ignored when writing, but is filled
+in with the file's GP value on reading, for convenience, as with the
+GPDISP_LO16 reloc.
+
+The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
+It should refer to the symbol to be referenced, as with 16_GOTOFF,
+but it generates output not based on the position within the .got
+section, but relative to the GP value chosen for the file during the
+final link stage.
+
+The LITUSE reloc, on the instruction using the loaded address, gives
+information to the linker that it might be able to use to optimize
+away some literal section references. The symbol is ignored (read
+as the absolute section symbol), and the "addend" indicates the type
+of instruction using the register:
+1 - "memory" fmt insn
+2 - byte-manipulation (byte offset reg)
+3 - jsr (target of branch)
+
+The GNU linker currently doesn't do any of this optimizing. */
+ BFD_RELOC_ALPHA_LITERAL,
+ BFD_RELOC_ALPHA_ELF_LITERAL,
+ BFD_RELOC_ALPHA_LITUSE,
+
+/* The HINT relocation indicates a value that should be filled into the
+"hint" field of a jmp/jsr/ret instruction, for possible branch-
+prediction logic which may be provided on some processors. */
+ BFD_RELOC_ALPHA_HINT,
+
+/* The LINKAGE relocation outputs a linkage pair in the object file,
+which is filled by the linker. */
+ BFD_RELOC_ALPHA_LINKAGE,
+
+/* The CODEADDR relocation outputs a STO_CA in the object file,
+which is filled by the linker. */
+ BFD_RELOC_ALPHA_CODEADDR,
+
+/* Bits 27..2 of the relocation address shifted right 2 bits;
+simple reloc otherwise. */
+ BFD_RELOC_MIPS_JMP,
+
+/* The MIPS16 jump instruction. */
+ BFD_RELOC_MIPS16_JMP,
+
+/* MIPS16 GP relative reloc. */
+ BFD_RELOC_MIPS16_GPREL,
+
+/* High 16 bits of 32-bit value; simple reloc. */
+ BFD_RELOC_HI16,
+
+/* High 16 bits of 32-bit value but the low 16 bits will be sign
+extended and added to form the final result. If the low 16
+bits form a negative number, we need to add one to the high value
+to compensate for the borrow when the low bits are added. */
+ BFD_RELOC_HI16_S,
+
+/* Low 16 bits. */
+ BFD_RELOC_LO16,
+
+/* Like BFD_RELOC_HI16_S, but PC relative. */
+ BFD_RELOC_PCREL_HI16_S,
+
+/* Like BFD_RELOC_LO16, but PC relative. */
+ BFD_RELOC_PCREL_LO16,
+
+/* Relocation relative to the global pointer. */
+#define BFD_RELOC_MIPS_GPREL BFD_RELOC_GPREL16
+
+/* Relocation against a MIPS literal section. */
+ BFD_RELOC_MIPS_LITERAL,
+
+/* MIPS ELF relocations. */
+ BFD_RELOC_MIPS_GOT16,
+ BFD_RELOC_MIPS_CALL16,
+#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32
+ BFD_RELOC_MIPS_GOT_HI16,
+ BFD_RELOC_MIPS_GOT_LO16,
+ BFD_RELOC_MIPS_CALL_HI16,
+ BFD_RELOC_MIPS_CALL_LO16,
+
+
+/* i386/elf relocations */
+ BFD_RELOC_386_GOT32,
+ BFD_RELOC_386_PLT32,
+ BFD_RELOC_386_COPY,
+ BFD_RELOC_386_GLOB_DAT,
+ BFD_RELOC_386_JUMP_SLOT,
+ BFD_RELOC_386_RELATIVE,
+ BFD_RELOC_386_GOTOFF,
+ BFD_RELOC_386_GOTPC,
+
+/* ns32k relocations */
+ BFD_RELOC_NS32K_IMM_8,
+ BFD_RELOC_NS32K_IMM_16,
+ BFD_RELOC_NS32K_IMM_32,
+ BFD_RELOC_NS32K_IMM_8_PCREL,
+ BFD_RELOC_NS32K_IMM_16_PCREL,
+ BFD_RELOC_NS32K_IMM_32_PCREL,
+ BFD_RELOC_NS32K_DISP_8,
+ BFD_RELOC_NS32K_DISP_16,
+ BFD_RELOC_NS32K_DISP_32,
+ BFD_RELOC_NS32K_DISP_8_PCREL,
+ BFD_RELOC_NS32K_DISP_16_PCREL,
+ BFD_RELOC_NS32K_DISP_32_PCREL,
+
+/* Power(rs6000) and PowerPC relocations. */
+ BFD_RELOC_PPC_B26,
+ BFD_RELOC_PPC_BA26,
+ BFD_RELOC_PPC_TOC16,
+ BFD_RELOC_PPC_B16,
+ BFD_RELOC_PPC_B16_BRTAKEN,
+ BFD_RELOC_PPC_B16_BRNTAKEN,
+ BFD_RELOC_PPC_BA16,
+ BFD_RELOC_PPC_BA16_BRTAKEN,
+ BFD_RELOC_PPC_BA16_BRNTAKEN,
+ BFD_RELOC_PPC_COPY,
+ BFD_RELOC_PPC_GLOB_DAT,
+ BFD_RELOC_PPC_JMP_SLOT,
+ BFD_RELOC_PPC_RELATIVE,
+ BFD_RELOC_PPC_LOCAL24PC,
+ BFD_RELOC_PPC_EMB_NADDR32,
+ BFD_RELOC_PPC_EMB_NADDR16,
+ BFD_RELOC_PPC_EMB_NADDR16_LO,
+ BFD_RELOC_PPC_EMB_NADDR16_HI,
+ BFD_RELOC_PPC_EMB_NADDR16_HA,
+ BFD_RELOC_PPC_EMB_SDAI16,
+ BFD_RELOC_PPC_EMB_SDA2I16,
+ BFD_RELOC_PPC_EMB_SDA2REL,
+ BFD_RELOC_PPC_EMB_SDA21,
+ BFD_RELOC_PPC_EMB_MRKREF,
+ BFD_RELOC_PPC_EMB_RELSEC16,
+ BFD_RELOC_PPC_EMB_RELST_LO,
+ BFD_RELOC_PPC_EMB_RELST_HI,
+ BFD_RELOC_PPC_EMB_RELST_HA,
+ BFD_RELOC_PPC_EMB_BIT_FLD,
+ BFD_RELOC_PPC_EMB_RELSDA,
+
+/* The type of reloc used to build a contructor table - at the moment
+probably a 32 bit wide absolute relocation, but the target can choose.
+It generally does map to one of the other relocation types. */
+ BFD_RELOC_CTOR,
+
+/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
+not stored in the instruction. */
+ BFD_RELOC_ARM_PCREL_BRANCH,
+
+/* These relocs are only used within the ARM assembler. They are not
+(at present) written to any object files. */
+ BFD_RELOC_ARM_IMMEDIATE,
+ BFD_RELOC_ARM_OFFSET_IMM,
+ BFD_RELOC_ARM_SHIFT_IMM,
+ BFD_RELOC_ARM_SWI,
+ BFD_RELOC_ARM_MULTI,
+ BFD_RELOC_ARM_CP_OFF_IMM,
+ BFD_RELOC_ARM_ADR_IMM,
+ BFD_RELOC_ARM_LDR_IMM,
+ BFD_RELOC_ARM_LITERAL,
+ BFD_RELOC_ARM_IN_POOL,
+ BFD_RELOC_ARM_OFFSET_IMM8,
+ BFD_RELOC_ARM_HWLITERAL,
+ BFD_RELOC_ARM_THUMB_ADD,
+ BFD_RELOC_ARM_THUMB_IMM,
+ BFD_RELOC_ARM_THUMB_SHIFT,
+ BFD_RELOC_ARM_THUMB_OFFSET,
+ BFD_RELOC_ARM_GOT12,
+ BFD_RELOC_ARM_GOT32,
+ BFD_RELOC_ARM_JUMP_SLOT,
+ BFD_RELOC_ARM_COPY,
+ BFD_RELOC_ARM_GLOB_DAT,
+ BFD_RELOC_ARM_PLT32,
+ BFD_RELOC_ARM_RELATIVE,
+ BFD_RELOC_ARM_GOTOFF,
+ BFD_RELOC_ARM_GOTPC,
+
+/* Hitachi SH relocs. Not all of these appear in object files. */
+ BFD_RELOC_SH_PCDISP8BY2,
+ BFD_RELOC_SH_PCDISP12BY2,
+ BFD_RELOC_SH_IMM4,
+ BFD_RELOC_SH_IMM4BY2,
+ BFD_RELOC_SH_IMM4BY4,
+ BFD_RELOC_SH_IMM8,
+ BFD_RELOC_SH_IMM8BY2,
+ BFD_RELOC_SH_IMM8BY4,
+ BFD_RELOC_SH_PCRELIMM8BY2,
+ BFD_RELOC_SH_PCRELIMM8BY4,
+ BFD_RELOC_SH_SWITCH16,
+ BFD_RELOC_SH_SWITCH32,
+ BFD_RELOC_SH_USES,
+ BFD_RELOC_SH_COUNT,
+ BFD_RELOC_SH_ALIGN,
+ BFD_RELOC_SH_CODE,
+ BFD_RELOC_SH_DATA,
+ BFD_RELOC_SH_LABEL,
+
+/* Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must
+be zero and is not stored in the instruction. */
+ BFD_RELOC_THUMB_PCREL_BRANCH9,
+ BFD_RELOC_THUMB_PCREL_BRANCH12,
+ BFD_RELOC_THUMB_PCREL_BRANCH23,
+
+/* Argonaut RISC Core (ARC) relocs.
+ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
+not stored in the instruction. The high 20 bits are installed in bits 26
+through 7 of the instruction. */
+ BFD_RELOC_ARC_B22_PCREL,
+
+/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not
+stored in the instruction. The high 24 bits are installed in bits 23
+through 0. */
+ BFD_RELOC_ARC_B26,
+
+/* Mitsubishi D10V relocs.
+This is a 10-bit reloc with the right 2 bits
+assumed to be 0. */
+ BFD_RELOC_D10V_10_PCREL_R,
+
+/* Mitsubishi D10V relocs.
+This is a 10-bit reloc with the right 2 bits
+assumed to be 0. This is the same as the previous reloc
+except it is in the left container, i.e.,
+shifted left 15 bits. */
+ BFD_RELOC_D10V_10_PCREL_L,
+
+/* This is an 18-bit reloc with the right 2 bits
+assumed to be 0. */
+ BFD_RELOC_D10V_18,
+
+/* This is an 18-bit reloc with the right 2 bits
+assumed to be 0. */
+ BFD_RELOC_D10V_18_PCREL,
+
+/* Mitsubishi D30V relocs.
+This is a 6-bit absolute reloc. */
+ BFD_RELOC_D30V_6,
+
+/* This is a 6-bit pc-relative reloc with
+the right 3 bits assumed to be 0. */
+ BFD_RELOC_D30V_9_PCREL,
+
+/* This is a 6-bit pc-relative reloc with
+the right 3 bits assumed to be 0. Same
+as the previous reloc but on the right side
+of the container. */
+ BFD_RELOC_D30V_9_PCREL_R,
+
+/* This is a 12-bit absolute reloc with the
+right 3 bitsassumed to be 0. */
+ BFD_RELOC_D30V_15,
+
+/* This is a 12-bit pc-relative reloc with
+the right 3 bits assumed to be 0. */
+ BFD_RELOC_D30V_15_PCREL,
+
+/* This is a 12-bit pc-relative reloc with
+the right 3 bits assumed to be 0. Same
+as the previous reloc but on the right side
+of the container. */
+ BFD_RELOC_D30V_15_PCREL_R,
+
+/* This is an 18-bit absolute reloc with
+the right 3 bits assumed to be 0. */
+ BFD_RELOC_D30V_21,
+
+/* This is an 18-bit pc-relative reloc with
+the right 3 bits assumed to be 0. */
+ BFD_RELOC_D30V_21_PCREL,
+
+/* This is an 18-bit pc-relative reloc with
+the right 3 bits assumed to be 0. Same
+as the previous reloc but on the right side
+of the container. */
+ BFD_RELOC_D30V_21_PCREL_R,
+
+/* This is a 32-bit absolute reloc. */
+ BFD_RELOC_D30V_32,
+
+/* This is a 32-bit pc-relative reloc. */
+ BFD_RELOC_D30V_32_PCREL,
+
+/* Mitsubishi M32R relocs.
+This is a 24 bit absolute address. */
+ BFD_RELOC_M32R_24,
+
+/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */
+ BFD_RELOC_M32R_10_PCREL,
+
+/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */
+ BFD_RELOC_M32R_18_PCREL,
+
+/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */
+ BFD_RELOC_M32R_26_PCREL,
+
+/* This is a 16-bit reloc containing the high 16 bits of an address
+used when the lower 16 bits are treated as unsigned. */
+ BFD_RELOC_M32R_HI16_ULO,
+
+/* This is a 16-bit reloc containing the high 16 bits of an address
+used when the lower 16 bits are treated as signed. */
+ BFD_RELOC_M32R_HI16_SLO,
+
+/* This is a 16-bit reloc containing the lower 16 bits of an address. */
+ BFD_RELOC_M32R_LO16,
+
+/* This is a 16-bit reloc containing the small data area offset for use in
+add3, load, and store instructions. */
+ BFD_RELOC_M32R_SDA16,
+
+/* This is a 9-bit reloc */
+ BFD_RELOC_V850_9_PCREL,
+
+/* This is a 22-bit reloc */
+ BFD_RELOC_V850_22_PCREL,
+
+/* This is a 16 bit offset from the short data area pointer. */
+ BFD_RELOC_V850_SDA_16_16_OFFSET,
+
+/* This is a 16 bit offset (of which only 15 bits are used) from the
+short data area pointer. */
+ BFD_RELOC_V850_SDA_15_16_OFFSET,
+
+/* This is a 16 bit offset from the zero data area pointer. */
+ BFD_RELOC_V850_ZDA_16_16_OFFSET,
+
+/* This is a 16 bit offset (of which only 15 bits are used) from the
+zero data area pointer. */
+ BFD_RELOC_V850_ZDA_15_16_OFFSET,
+
+/* This is an 8 bit offset (of which only 6 bits are used) from the
+tiny data area pointer. */
+ BFD_RELOC_V850_TDA_6_8_OFFSET,
+
+/* This is an 8bit offset (of which only 7 bits are used) from the tiny
+data area pointer. */
+ BFD_RELOC_V850_TDA_7_8_OFFSET,
+
+/* This is a 7 bit offset from the tiny data area pointer. */
+ BFD_RELOC_V850_TDA_7_7_OFFSET,
+
+/* This is a 16 bit offset from the tiny data area pointer. */
+ BFD_RELOC_V850_TDA_16_16_OFFSET,
+
+/* This is a 5 bit offset (of which only 4 bits are used) from the tiny
+data area pointer. */
+ BFD_RELOC_V850_TDA_4_5_OFFSET,
+
+/* This is a 4 bit offset from the tiny data area pointer. */
+ BFD_RELOC_V850_TDA_4_4_OFFSET,
+
+/* This is a 16 bit offset from the short data area pointer, with the
+bits placed non-contigously in the instruction. */
+ BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET,
+
+/* This is a 16 bit offset from the zero data area pointer, with the
+bits placed non-contigously in the instruction. */
+ BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET,
+
+/* This is a 6 bit offset from the call table base pointer. */
+ BFD_RELOC_V850_CALLT_6_7_OFFSET,
+
+/* This is a 16 bit offset from the call table base pointer. */
+ BFD_RELOC_V850_CALLT_16_16_OFFSET,
+
+
+/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
+instruction. */
+ BFD_RELOC_MN10300_32_PCREL,
+
+/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
+instruction. */
+ BFD_RELOC_MN10300_16_PCREL,
+
+/* This is a 8bit DP reloc for the tms320c30, where the most
+significant 8 bits of a 24 bit word are placed into the least
+significant 8 bits of the opcode. */
+ BFD_RELOC_TIC30_LDP,
+
+/* This is a 48 bit reloc for the FR30 that stores 32 bits. */
+ BFD_RELOC_FR30_48,
+
+/* This is a 32 bit reloc for the FR30 that stores 20 bits split up into
+two sections. */
+ BFD_RELOC_FR30_20,
+
+/* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
+4 bits. */
+ BFD_RELOC_FR30_6_IN_4,
+
+/* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
+into 8 bits. */
+ BFD_RELOC_FR30_8_IN_8,
+
+/* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
+into 8 bits. */
+ BFD_RELOC_FR30_9_IN_8,
+
+/* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
+into 8 bits. */
+ BFD_RELOC_FR30_10_IN_8,
+
+/* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
+short offset into 8 bits. */
+ BFD_RELOC_FR30_9_PCREL,
+
+/* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
+short offset into 11 bits. */
+ BFD_RELOC_FR30_12_PCREL,
+
+/* Motorola Mcore relocations. */
+ BFD_RELOC_MCORE_PCREL_IMM8BY4,
+ BFD_RELOC_MCORE_PCREL_IMM11BY2,
+ BFD_RELOC_MCORE_PCREL_IMM4BY2,
+ BFD_RELOC_MCORE_PCREL_32,
+ BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2,
+
+/* These two relocations are used by the linker to determine which of
+the entries in a C++ virtual function table are actually used. When
+the --gc-sections option is given, the linker will zero out the entries
+that are not used, so that the code for those functions need not be
+included in the output.
+
+VTABLE_INHERIT is a zero-space relocation used to describe to the
+linker the inheritence tree of a C++ virtual function table. The
+relocation's symbol should be the parent class' vtable, and the
+relocation should be located at the child vtable.
+
+VTABLE_ENTRY is a zero-space relocation that describes the use of a
+virtual function table entry. The reloc's symbol should refer to the
+table of the class mentioned in the code. Off of that base, an offset
+describes the entry that is being used. For Rela hosts, this offset
+is stored in the reloc's addend. For Rel hosts, we are forced to put
+this offset in the reloc's section offset. */
+ BFD_RELOC_VTABLE_INHERIT,
+ BFD_RELOC_VTABLE_ENTRY,
+ BFD_RELOC_UNUSED };
+typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
+reloc_howto_type *
+
+bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+
+const char *
+bfd_get_reloc_code_name PARAMS ((bfd_reloc_code_real_type code));
+
+
+typedef struct symbol_cache_entry
+{
+ /* A pointer to the BFD which owns the symbol. This information
+ is necessary so that a back end can work out what additional
+ information (invisible to the application writer) is carried
+ with the symbol.
+
+ This field is *almost* redundant, since you can use section->owner
+ instead, except that some symbols point to the global sections
+ bfd_{abs,com,und}_section. This could be fixed by making
+ these globals be per-bfd (or per-target-flavor). FIXME. */
+
+ struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
+
+ /* The text of the symbol. The name is left alone, and not copied; the
+ application may not alter it. */
+ CONST char *name;
+
+ /* The value of the symbol. This really should be a union of a
+ numeric value with a pointer, since some flags indicate that
+ a pointer to another symbol is stored here. */
+ symvalue value;
+
+ /* Attributes of a symbol: */
+
+#define BSF_NO_FLAGS 0x00
+
+ /* The symbol has local scope; <<static>> in <<C>>. The value
+ is the offset into the section of the data. */
+#define BSF_LOCAL 0x01
+
+ /* The symbol has global scope; initialized data in <<C>>. The
+ value is the offset into the section of the data. */
+#define BSF_GLOBAL 0x02
+
+ /* The symbol has global scope and is exported. The value is
+ the offset into the section of the data. */
+#define BSF_EXPORT BSF_GLOBAL /* no real difference */
+
+ /* A normal C symbol would be one of:
+ <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
+ <<BSF_GLOBAL>> */
+
+ /* The symbol is a debugging record. The value has an arbitary
+ meaning. */
+#define BSF_DEBUGGING 0x08
+
+ /* The symbol denotes a function entry point. Used in ELF,
+ perhaps others someday. */
+#define BSF_FUNCTION 0x10
+
+ /* Used by the linker. */
+#define BSF_KEEP 0x20
+#define BSF_KEEP_G 0x40
+
+ /* A weak global symbol, overridable without warnings by
+ a regular global symbol of the same name. */
+#define BSF_WEAK 0x80
+
+ /* This symbol was created to point to a section, e.g. ELF's
+ STT_SECTION symbols. */
+#define BSF_SECTION_SYM 0x100
+
+ /* The symbol used to be a common symbol, but now it is
+ allocated. */
+#define BSF_OLD_COMMON 0x200
+
+ /* The default value for common data. */
+#define BFD_FORT_COMM_DEFAULT_VALUE 0
+
+ /* In some files the type of a symbol sometimes alters its
+ location in an output file - ie in coff a <<ISFCN>> symbol
+ which is also <<C_EXT>> symbol appears where it was
+ declared and not at the end of a section. This bit is set
+ by the target BFD part to convey this information. */
+
+#define BSF_NOT_AT_END 0x400
+
+ /* Signal that the symbol is the label of constructor section. */
+#define BSF_CONSTRUCTOR 0x800
+
+ /* Signal that the symbol is a warning symbol. The name is a
+ warning. The name of the next symbol is the one to warn about;
+ if a reference is made to a symbol with the same name as the next
+ symbol, a warning is issued by the linker. */
+#define BSF_WARNING 0x1000
+
+ /* Signal that the symbol is indirect. This symbol is an indirect
+ pointer to the symbol with the same name as the next symbol. */
+#define BSF_INDIRECT 0x2000
+
+ /* BSF_FILE marks symbols that contain a file name. This is used
+ for ELF STT_FILE symbols. */
+#define BSF_FILE 0x4000
+
+ /* Symbol is from dynamic linking information. */
+#define BSF_DYNAMIC 0x8000
+
+ /* The symbol denotes a data object. Used in ELF, and perhaps
+ others someday. */
+#define BSF_OBJECT 0x10000
+
+ flagword flags;
+
+ /* A pointer to the section to which this symbol is
+ relative. This will always be non NULL, there are special
+ sections for undefined and absolute symbols. */
+ struct sec *section;
+
+ /* Back end special data. */
+ union
+ {
+ PTR p;
+ bfd_vma i;
+ } udata;
+
+} asymbol;
+#define bfd_get_symtab_upper_bound(abfd) \
+ BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
+boolean
+bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym));
+
+boolean
+bfd_is_local_label_name PARAMS ((bfd *abfd, const char *name));
+
+#define bfd_is_local_label_name(abfd, name) \
+ BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
+#define bfd_canonicalize_symtab(abfd, location) \
+ BFD_SEND (abfd, _bfd_canonicalize_symtab,\
+ (abfd, location))
+boolean
+bfd_set_symtab PARAMS ((bfd *abfd, asymbol **location, unsigned int count));
+
+void
+bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
+
+#define bfd_make_empty_symbol(abfd) \
+ BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
+#define bfd_make_debug_symbol(abfd,ptr,size) \
+ BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
+int
+bfd_decode_symclass PARAMS ((asymbol *symbol));
+
+void
+bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret));
+
+boolean
+bfd_copy_private_symbol_data PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym));
+
+#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
+ BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
+ (ibfd, isymbol, obfd, osymbol))
+struct _bfd
+{
+ /* The filename the application opened the BFD with. */
+ CONST char *filename;
+
+ /* A pointer to the target jump table. */
+ const struct bfd_target *xvec;
+
+ /* To avoid dragging too many header files into every file that
+ includes `<<bfd.h>>', IOSTREAM has been declared as a "char
+ *", and MTIME as a "long". Their correct types, to which they
+ are cast when used, are "FILE *" and "time_t". The iostream
+ is the result of an fopen on the filename. However, if the
+ BFD_IN_MEMORY flag is set, then iostream is actually a pointer
+ to a bfd_in_memory struct. */
+ PTR iostream;
+
+ /* Is the file descriptor being cached? That is, can it be closed as
+ needed, and re-opened when accessed later? */
+
+ boolean cacheable;
+
+ /* Marks whether there was a default target specified when the
+ BFD was opened. This is used to select which matching algorithm
+ to use to choose the back end. */
+
+ boolean target_defaulted;
+
+ /* The caching routines use these to maintain a
+ least-recently-used list of BFDs */
+
+ struct _bfd *lru_prev, *lru_next;
+
+ /* When a file is closed by the caching routines, BFD retains
+ state information on the file here: */
+
+ file_ptr where;
+
+ /* and here: (``once'' means at least once) */
+
+ boolean opened_once;
+
+ /* Set if we have a locally maintained mtime value, rather than
+ getting it from the file each time: */
+
+ boolean mtime_set;
+
+ /* File modified time, if mtime_set is true: */
+
+ long mtime;
+
+ /* Reserved for an unimplemented file locking extension.*/
+
+ int ifd;
+
+ /* The format which belongs to the BFD. (object, core, etc.) */
+
+ bfd_format format;
+
+ /* The direction the BFD was opened with*/
+
+ enum bfd_direction {no_direction = 0,
+ read_direction = 1,
+ write_direction = 2,
+ both_direction = 3} direction;
+
+ /* Format_specific flags*/
+
+ flagword flags;
+
+ /* Currently my_archive is tested before adding origin to
+ anything. I believe that this can become always an add of
+ origin, with origin set to 0 for non archive files. */
+
+ file_ptr origin;
+
+ /* Remember when output has begun, to stop strange things
+ from happening. */
+ boolean output_has_begun;
+
+ /* Pointer to linked list of sections*/
+ struct sec *sections;
+
+ /* The number of sections */
+ unsigned int section_count;
+
+ /* Stuff only useful for object files:
+ The start address. */
+ bfd_vma start_address;
+
+ /* Used for input and output*/
+ unsigned int symcount;
+
+ /* Symbol table for output BFD (with symcount entries) */
+ struct symbol_cache_entry **outsymbols;
+
+ /* Pointer to structure which contains architecture information*/
+ const struct bfd_arch_info *arch_info;
+
+ /* Stuff only useful for archives:*/
+ PTR arelt_data;
+ struct _bfd *my_archive; /* The containing archive BFD. */
+ struct _bfd *next; /* The next BFD in the archive. */
+ struct _bfd *archive_head; /* The first BFD in the archive. */
+ boolean has_armap;
+
+ /* A chain of BFD structures involved in a link. */
+ struct _bfd *link_next;
+
+ /* A field used by _bfd_generic_link_add_archive_symbols. This will
+ be used only for archive elements. */
+ int archive_pass;
+
+ /* Used by the back end to hold private data. */
+
+ union
+ {
+ struct aout_data_struct *aout_data;
+ struct artdata *aout_ar_data;
+ struct _oasys_data *oasys_obj_data;
+ struct _oasys_ar_data *oasys_ar_data;
+ struct coff_tdata *coff_obj_data;
+ struct pe_tdata *pe_obj_data;
+ struct xcoff_tdata *xcoff_obj_data;
+ struct ecoff_tdata *ecoff_obj_data;
+ struct ieee_data_struct *ieee_data;
+ struct ieee_ar_data_struct *ieee_ar_data;
+ struct srec_data_struct *srec_data;
+ 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 bout_data_struct *bout_data;
+ struct sun_core_struct *sun_core_data;
+ struct sco5_core_struct *sco5_core_data;
+ struct trad_core_struct *trad_core_data;
+ struct som_data_struct *som_data;
+ struct hpux_core_struct *hpux_core_data;
+ struct hppabsd_core_struct *hppabsd_core_data;
+ struct sgi_core_struct *sgi_core_data;
+ struct lynx_core_struct *lynx_core_data;
+ struct osf_core_struct *osf_core_data;
+ struct cisco_core_struct *cisco_core_data;
+ struct versados_data_struct *versados_data;
+ struct netbsd_core_struct *netbsd_core_data;
+ PTR any;
+ } tdata;
+
+ /* Used by the application to hold private data*/
+ PTR usrdata;
+
+ /* Where all the allocated stuff under this BFD goes. This is a
+ struct objalloc *, but we use PTR to avoid requiring the inclusion of
+ objalloc.h. */
+ PTR memory;
+};
+
+typedef enum bfd_error
+{
+ bfd_error_no_error = 0,
+ bfd_error_system_call,
+ bfd_error_invalid_target,
+ bfd_error_wrong_format,
+ bfd_error_invalid_operation,
+ bfd_error_no_memory,
+ bfd_error_no_symbols,
+ bfd_error_no_armap,
+ bfd_error_no_more_archived_files,
+ bfd_error_malformed_archive,
+ bfd_error_file_not_recognized,
+ bfd_error_file_ambiguously_recognized,
+ bfd_error_no_contents,
+ bfd_error_nonrepresentable_section,
+ bfd_error_no_debug_section,
+ bfd_error_bad_value,
+ bfd_error_file_truncated,
+ bfd_error_file_too_big,
+ bfd_error_invalid_error_code
+} bfd_error_type;
+
+bfd_error_type
+bfd_get_error PARAMS ((void));
+
+void
+bfd_set_error PARAMS ((bfd_error_type error_tag));
+
+CONST char *
+bfd_errmsg PARAMS ((bfd_error_type error_tag));
+
+void
+bfd_perror PARAMS ((CONST char *message));
+
+typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
+
+bfd_error_handler_type
+bfd_set_error_handler PARAMS ((bfd_error_handler_type));
+
+void
+bfd_set_error_program_name PARAMS ((const char *));
+
+bfd_error_handler_type
+bfd_get_error_handler PARAMS ((void));
+
+long
+bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
+
+long
+bfd_canonicalize_reloc
+ PARAMS ((bfd *abfd,
+ asection *sec,
+ arelent **loc,
+ asymbol **syms));
+
+void
+bfd_set_reloc
+ PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count)
+
+ );
+
+boolean
+bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags));
+
+boolean
+bfd_set_start_address PARAMS ((bfd *abfd, bfd_vma vma));
+
+long
+bfd_get_mtime PARAMS ((bfd *abfd));
+
+long
+bfd_get_size PARAMS ((bfd *abfd));
+
+int
+bfd_get_gp_size PARAMS ((bfd *abfd));
+
+void
+bfd_set_gp_size PARAMS ((bfd *abfd, int i));
+
+bfd_vma
+bfd_scan_vma PARAMS ((CONST char *string, CONST char **end, int base));
+
+boolean
+bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
+
+#define bfd_copy_private_bfd_data(ibfd, obfd) \
+ BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
+ (ibfd, obfd))
+boolean
+bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
+
+#define bfd_merge_private_bfd_data(ibfd, obfd) \
+ BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
+ (ibfd, obfd))
+boolean
+bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags));
+
+#define bfd_set_private_flags(abfd, flags) \
+ BFD_SEND (abfd, _bfd_set_private_flags, \
+ (abfd, flags))
+#define bfd_sizeof_headers(abfd, reloc) \
+ BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
+
+#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
+ BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
+
+ /* Do these three do anything useful at all, for any back end? */
+#define bfd_debug_info_start(abfd) \
+ BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
+
+#define bfd_debug_info_end(abfd) \
+ BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
+
+#define bfd_debug_info_accumulate(abfd, section) \
+ BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
+
+
+#define bfd_stat_arch_elt(abfd, stat) \
+ BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
+
+#define bfd_update_armap_timestamp(abfd) \
+ BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
+
+#define bfd_set_arch_mach(abfd, arch, mach)\
+ BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
+
+#define bfd_relax_section(abfd, section, link_info, again) \
+ BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
+
+#define bfd_gc_sections(abfd, link_info) \
+ BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
+
+#define bfd_link_hash_table_create(abfd) \
+ BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
+
+#define bfd_link_add_symbols(abfd, info) \
+ BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
+
+#define bfd_final_link(abfd, info) \
+ BFD_SEND (abfd, _bfd_final_link, (abfd, info))
+
+#define bfd_free_cached_info(abfd) \
+ BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
+
+#define bfd_get_dynamic_symtab_upper_bound(abfd) \
+ BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
+
+#define bfd_print_private_bfd_data(abfd, file)\
+ BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
+
+#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
+ BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
+
+#define bfd_get_dynamic_reloc_upper_bound(abfd) \
+ BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
+
+#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
+ BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
+
+extern bfd_byte *bfd_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *,
+ struct bfd_link_order *, bfd_byte *,
+ boolean, asymbol **));
+
+symindex
+bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
+
+boolean
+bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head));
+
+bfd *
+bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous));
+
+CONST char *
+bfd_core_file_failing_command PARAMS ((bfd *abfd));
+
+int
+bfd_core_file_failing_signal PARAMS ((bfd *abfd));
+
+boolean
+core_file_matches_executable_p
+ PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+
+#define BFD_SEND(bfd, message, arglist) \
+ ((*((bfd)->xvec->message)) arglist)
+
+#ifdef DEBUG_BFD_SEND
+#undef BFD_SEND
+#define BFD_SEND(bfd, message, arglist) \
+ (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
+ ((*((bfd)->xvec->message)) arglist) : \
+ (bfd_assert (__FILE__,__LINE__), NULL))
+#endif
+#define BFD_SEND_FMT(bfd, message, arglist) \
+ (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
+
+#ifdef DEBUG_BFD_SEND
+#undef BFD_SEND_FMT
+#define BFD_SEND_FMT(bfd, message, arglist) \
+ (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
+ (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
+ (bfd_assert (__FILE__,__LINE__), NULL))
+#endif
+enum bfd_flavour {
+ bfd_target_unknown_flavour,
+ bfd_target_aout_flavour,
+ bfd_target_coff_flavour,
+ bfd_target_ecoff_flavour,
+ bfd_target_elf_flavour,
+ bfd_target_ieee_flavour,
+ bfd_target_nlm_flavour,
+ bfd_target_oasys_flavour,
+ bfd_target_tekhex_flavour,
+ bfd_target_srec_flavour,
+ bfd_target_ihex_flavour,
+ bfd_target_som_flavour,
+ bfd_target_os9k_flavour,
+ bfd_target_versados_flavour,
+ bfd_target_msdos_flavour,
+ bfd_target_ovax_flavour,
+ bfd_target_evax_flavour
+};
+
+enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
+
+ /* Forward declaration. */
+typedef struct bfd_link_info _bfd_link_info;
+
+typedef struct bfd_target
+{
+ char *name;
+ enum bfd_flavour flavour;
+ enum bfd_endian byteorder;
+ enum bfd_endian header_byteorder;
+ flagword object_flags;
+ flagword section_flags;
+ char symbol_leading_char;
+ char ar_pad_char;
+ unsigned short ar_max_namelen;
+ bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
+ void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
+ void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
+ void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
+ void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
+ void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
+ void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
+ const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
+ boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
+ boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
+
+ /* Generic entry points. */
+#define BFD_JUMP_TABLE_GENERIC(NAME)\
+CAT(NAME,_close_and_cleanup),\
+CAT(NAME,_bfd_free_cached_info),\
+CAT(NAME,_new_section_hook),\
+CAT(NAME,_get_section_contents),\
+CAT(NAME,_get_section_contents_in_window)
+
+ /* Called when the BFD is being closed to do any necessary cleanup. */
+ boolean (*_close_and_cleanup) PARAMS ((bfd *));
+ /* Ask the BFD to free all cached information. */
+ boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
+ /* Called when a new section is created. */
+ boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
+ /* Read the contents of a section. */
+ boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr, bfd_size_type));
+ boolean (*_bfd_get_section_contents_in_window)
+ PARAMS ((bfd *, sec_ptr, bfd_window *,
+ file_ptr, bfd_size_type));
+
+ /* Entry points to copy private data. */
+#define BFD_JUMP_TABLE_COPY(NAME)\
+CAT(NAME,_bfd_copy_private_bfd_data),\
+CAT(NAME,_bfd_merge_private_bfd_data),\
+CAT(NAME,_bfd_copy_private_section_data),\
+CAT(NAME,_bfd_copy_private_symbol_data),\
+CAT(NAME,_bfd_set_private_flags),\
+CAT(NAME,_bfd_print_private_bfd_data)\
+ /* Called to copy BFD general private data from one object file
+ to another. */
+ boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
+ /* Called to merge BFD general private data from one object file
+ to a common output file when linking. */
+ boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
+ /* Called to copy BFD private section data from one object file
+ to another. */
+ boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
+ bfd *, sec_ptr));
+ /* Called to copy BFD private symbol data from one symbol
+ to another. */
+ boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
+ bfd *, asymbol *));
+ /* Called to set private backend flags */
+ boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
+
+ /* Called to print private BFD data */
+ boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
+
+ /* Core file entry points. */
+#define BFD_JUMP_TABLE_CORE(NAME)\
+CAT(NAME,_core_file_failing_command),\
+CAT(NAME,_core_file_failing_signal),\
+CAT(NAME,_core_file_matches_executable_p)
+ char * (*_core_file_failing_command) PARAMS ((bfd *));
+ int (*_core_file_failing_signal) PARAMS ((bfd *));
+ boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
+
+ /* Archive entry points. */
+#define BFD_JUMP_TABLE_ARCHIVE(NAME)\
+CAT(NAME,_slurp_armap),\
+CAT(NAME,_slurp_extended_name_table),\
+CAT(NAME,_construct_extended_name_table),\
+CAT(NAME,_truncate_arname),\
+CAT(NAME,_write_armap),\
+CAT(NAME,_read_ar_hdr),\
+CAT(NAME,_openr_next_archived_file),\
+CAT(NAME,_get_elt_at_index),\
+CAT(NAME,_generic_stat_arch_elt),\
+CAT(NAME,_update_armap_timestamp)
+ boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
+ boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
+ boolean (*_bfd_construct_extended_name_table)
+ PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+ void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
+ boolean (*write_armap) PARAMS ((bfd *arch,
+ unsigned int elength,
+ struct orl *map,
+ unsigned int orl_count,
+ int stridx));
+ PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
+ bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
+#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
+ bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
+ int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
+ boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
+
+ /* Entry points used for symbols. */
+#define BFD_JUMP_TABLE_SYMBOLS(NAME)\
+CAT(NAME,_get_symtab_upper_bound),\
+CAT(NAME,_get_symtab),\
+CAT(NAME,_make_empty_symbol),\
+CAT(NAME,_print_symbol),\
+CAT(NAME,_get_symbol_info),\
+CAT(NAME,_bfd_is_local_label_name),\
+CAT(NAME,_get_lineno),\
+CAT(NAME,_find_nearest_line),\
+CAT(NAME,_bfd_make_debug_symbol),\
+CAT(NAME,_read_minisymbols),\
+CAT(NAME,_minisymbol_to_symbol)
+ long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
+ long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
+ struct symbol_cache_entry **));
+ struct symbol_cache_entry *
+ (*_bfd_make_empty_symbol) PARAMS ((bfd *));
+ void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
+ struct symbol_cache_entry *,
+ bfd_print_symbol_type));
+#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
+ void (*_bfd_get_symbol_info) PARAMS ((bfd *,
+ struct symbol_cache_entry *,
+ symbol_info *));
+#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
+ boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
+
+ alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
+ boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
+ struct sec *section, struct symbol_cache_entry **symbols,
+ bfd_vma offset, CONST char **file, CONST char **func,
+ unsigned int *line));
+ /* Back-door to allow format-aware applications to create debug symbols
+ while using BFD for everything else. Currently used by the assembler
+ when creating COFF files. */
+ asymbol * (*_bfd_make_debug_symbol) PARAMS ((
+ bfd *abfd,
+ void *ptr,
+ unsigned long size));
+#define bfd_read_minisymbols(b, d, m, s) \
+ BFD_SEND (b, _read_minisymbols, (b, d, m, s))
+ long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
+ unsigned int *));
+#define bfd_minisymbol_to_symbol(b, d, m, f) \
+ BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
+ asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
+ asymbol *));
+
+ /* Routines for relocs. */
+#define BFD_JUMP_TABLE_RELOCS(NAME)\
+CAT(NAME,_get_reloc_upper_bound),\
+CAT(NAME,_canonicalize_reloc),\
+CAT(NAME,_bfd_reloc_type_lookup)
+ long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
+ long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
+ struct symbol_cache_entry **));
+ /* See documentation on reloc types. */
+ reloc_howto_type *
+ (*reloc_type_lookup) PARAMS ((bfd *abfd,
+ bfd_reloc_code_real_type code));
+
+ /* Routines used when writing an object file. */
+#define BFD_JUMP_TABLE_WRITE(NAME)\
+CAT(NAME,_set_arch_mach),\
+CAT(NAME,_set_section_contents)
+ boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
+ unsigned long));
+ boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr, bfd_size_type));
+
+ /* Routines used by the linker. */
+#define BFD_JUMP_TABLE_LINK(NAME)\
+CAT(NAME,_sizeof_headers),\
+CAT(NAME,_bfd_get_relocated_section_contents),\
+CAT(NAME,_bfd_relax_section),\
+CAT(NAME,_bfd_link_hash_table_create),\
+CAT(NAME,_bfd_link_add_symbols),\
+CAT(NAME,_bfd_final_link),\
+CAT(NAME,_bfd_link_split_section),\
+CAT(NAME,_bfd_gc_sections)
+ int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
+ bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
+ struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *data, boolean relocateable,
+ struct symbol_cache_entry **));
+
+ boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
+ struct bfd_link_info *, boolean *again));
+
+ /* Create a hash table for the linker. Different backends store
+ different information in this table. */
+ struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
+
+ /* Add symbols from this object file into the hash table. */
+ boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+
+ /* Do a link based on the link_order structures attached to each
+ section of the BFD. */
+ boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
+
+ /* Should this section be split up into smaller pieces during linking. */
+ boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
+
+ /* Remove sections that are not referenced from the output. */
+ boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
+
+ /* Routines to handle dynamic symbols and relocs. */
+#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
+CAT(NAME,_get_dynamic_symtab_upper_bound),\
+CAT(NAME,_canonicalize_dynamic_symtab),\
+CAT(NAME,_get_dynamic_reloc_upper_bound),\
+CAT(NAME,_canonicalize_dynamic_reloc)
+ /* Get the amount of memory required to hold the dynamic symbols. */
+ long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
+ /* Read in the dynamic symbols. */
+ long (*_bfd_canonicalize_dynamic_symtab)
+ PARAMS ((bfd *, struct symbol_cache_entry **));
+ /* Get the amount of memory required to hold the dynamic relocs. */
+ long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
+ /* Read in the dynamic relocs. */
+ long (*_bfd_canonicalize_dynamic_reloc)
+ PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
+
+ PTR backend_data;
+} bfd_target;
+boolean
+bfd_set_default_target PARAMS ((const char *name));
+
+const bfd_target *
+bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd));
+
+const char **
+bfd_target_list PARAMS ((void));
+
+boolean
+bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
+
+boolean
+bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching));
+
+boolean
+bfd_set_format PARAMS ((bfd *abfd, bfd_format format));
+
+CONST char *
+bfd_format_string PARAMS ((bfd_format format));
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/bfd/bfd.c b/bfd/bfd.c
new file mode 100644
index 00000000000..597e8f0bc68
--- /dev/null
+++ b/bfd/bfd.c
@@ -0,0 +1,1159 @@
+/* Generic BFD library interface and support routines.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ <<typedef bfd>>
+
+ A BFD has type <<bfd>>; objects of this type are the
+ cornerstone of any application using BFD. Using BFD
+ consists of making references though the BFD and to data in the BFD.
+
+ Here is the structure that defines the type <<bfd>>. It
+ contains the major data about the file and pointers
+ to the rest of the data.
+
+CODE_FRAGMENT
+.
+.struct _bfd
+.{
+. {* The filename the application opened the BFD with. *}
+. CONST char *filename;
+.
+. {* A pointer to the target jump table. *}
+. const struct bfd_target *xvec;
+.
+. {* To avoid dragging too many header files into every file that
+. includes `<<bfd.h>>', IOSTREAM has been declared as a "char
+. *", and MTIME as a "long". Their correct types, to which they
+. are cast when used, are "FILE *" and "time_t". The iostream
+. is the result of an fopen on the filename. However, if the
+. BFD_IN_MEMORY flag is set, then iostream is actually a pointer
+. to a bfd_in_memory struct. *}
+. PTR iostream;
+.
+. {* Is the file descriptor being cached? That is, can it be closed as
+. needed, and re-opened when accessed later? *}
+.
+. boolean cacheable;
+.
+. {* Marks whether there was a default target specified when the
+. BFD was opened. This is used to select which matching algorithm
+. to use to choose the back end. *}
+.
+. boolean target_defaulted;
+.
+. {* The caching routines use these to maintain a
+. least-recently-used list of BFDs *}
+.
+. struct _bfd *lru_prev, *lru_next;
+.
+. {* When a file is closed by the caching routines, BFD retains
+. state information on the file here: *}
+.
+. file_ptr where;
+.
+. {* and here: (``once'' means at least once) *}
+.
+. boolean opened_once;
+.
+. {* Set if we have a locally maintained mtime value, rather than
+. getting it from the file each time: *}
+.
+. boolean mtime_set;
+.
+. {* File modified time, if mtime_set is true: *}
+.
+. long mtime;
+.
+. {* Reserved for an unimplemented file locking extension.*}
+.
+. int ifd;
+.
+. {* The format which belongs to the BFD. (object, core, etc.) *}
+.
+. bfd_format format;
+.
+. {* The direction the BFD was opened with*}
+.
+. enum bfd_direction {no_direction = 0,
+. read_direction = 1,
+. write_direction = 2,
+. both_direction = 3} direction;
+.
+. {* Format_specific flags*}
+.
+. flagword flags;
+.
+. {* Currently my_archive is tested before adding origin to
+. anything. I believe that this can become always an add of
+. origin, with origin set to 0 for non archive files. *}
+.
+. file_ptr origin;
+.
+. {* Remember when output has begun, to stop strange things
+. from happening. *}
+. boolean output_has_begun;
+.
+. {* Pointer to linked list of sections*}
+. struct sec *sections;
+.
+. {* The number of sections *}
+. unsigned int section_count;
+.
+. {* Stuff only useful for object files:
+. The start address. *}
+. bfd_vma start_address;
+.
+. {* Used for input and output*}
+. unsigned int symcount;
+.
+. {* Symbol table for output BFD (with symcount entries) *}
+. struct symbol_cache_entry **outsymbols;
+.
+. {* Pointer to structure which contains architecture information*}
+. const struct bfd_arch_info *arch_info;
+.
+. {* Stuff only useful for archives:*}
+. PTR arelt_data;
+. struct _bfd *my_archive; {* The containing archive BFD. *}
+. struct _bfd *next; {* The next BFD in the archive. *}
+. struct _bfd *archive_head; {* The first BFD in the archive. *}
+. boolean has_armap;
+.
+. {* A chain of BFD structures involved in a link. *}
+. struct _bfd *link_next;
+.
+. {* A field used by _bfd_generic_link_add_archive_symbols. This will
+. be used only for archive elements. *}
+. int archive_pass;
+.
+. {* Used by the back end to hold private data. *}
+.
+. union
+. {
+. struct aout_data_struct *aout_data;
+. struct artdata *aout_ar_data;
+. struct _oasys_data *oasys_obj_data;
+. struct _oasys_ar_data *oasys_ar_data;
+. struct coff_tdata *coff_obj_data;
+. struct pe_tdata *pe_obj_data;
+. struct xcoff_tdata *xcoff_obj_data;
+. struct ecoff_tdata *ecoff_obj_data;
+. struct ieee_data_struct *ieee_data;
+. struct ieee_ar_data_struct *ieee_ar_data;
+. struct srec_data_struct *srec_data;
+. 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 bout_data_struct *bout_data;
+. struct sun_core_struct *sun_core_data;
+. struct sco5_core_struct *sco5_core_data;
+. struct trad_core_struct *trad_core_data;
+. struct som_data_struct *som_data;
+. struct hpux_core_struct *hpux_core_data;
+. struct hppabsd_core_struct *hppabsd_core_data;
+. struct sgi_core_struct *sgi_core_data;
+. struct lynx_core_struct *lynx_core_data;
+. struct osf_core_struct *osf_core_data;
+. struct cisco_core_struct *cisco_core_data;
+. struct versados_data_struct *versados_data;
+. struct netbsd_core_struct *netbsd_core_data;
+. PTR any;
+. } tdata;
+.
+. {* Used by the application to hold private data*}
+. PTR usrdata;
+.
+. {* Where all the allocated stuff under this BFD goes. This is a
+. struct objalloc *, but we use PTR to avoid requiring the inclusion of
+. objalloc.h. *}
+. PTR memory;
+.};
+.
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "libiberty.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "coff/sym.h"
+#include "libcoff.h"
+#include "libecoff.h"
+#undef obj_symbols
+#include "elf-bfd.h"
+
+#include <ctype.h>
+
+/* provide storage for subsystem, stack and heap data which may have been
+ passed in on the command line. Ld puts this data into a bfd_link_info
+ struct which ultimately gets passed in to the bfd. When it arrives, copy
+ it to the following struct so that the data will be available in coffcode.h
+ where it is needed. The typedef's used are defined in bfd.h */
+
+
+
+/*
+SECTION
+ Error reporting
+
+ Most BFD functions return nonzero on success (check their
+ individual documentation for precise semantics). On an error,
+ they call <<bfd_set_error>> to set an error condition that callers
+ can check by calling <<bfd_get_error>>.
+ If that returns <<bfd_error_system_call>>, then check
+ <<errno>>.
+
+ The easiest way to report a BFD error to the user is to
+ use <<bfd_perror>>.
+
+SUBSECTION
+ Type <<bfd_error_type>>
+
+ The values returned by <<bfd_get_error>> are defined by the
+ enumerated type <<bfd_error_type>>.
+
+CODE_FRAGMENT
+.
+.typedef enum bfd_error
+.{
+. bfd_error_no_error = 0,
+. bfd_error_system_call,
+. bfd_error_invalid_target,
+. bfd_error_wrong_format,
+. bfd_error_invalid_operation,
+. bfd_error_no_memory,
+. bfd_error_no_symbols,
+. bfd_error_no_armap,
+. bfd_error_no_more_archived_files,
+. bfd_error_malformed_archive,
+. bfd_error_file_not_recognized,
+. bfd_error_file_ambiguously_recognized,
+. bfd_error_no_contents,
+. bfd_error_nonrepresentable_section,
+. bfd_error_no_debug_section,
+. bfd_error_bad_value,
+. bfd_error_file_truncated,
+. bfd_error_file_too_big,
+. bfd_error_invalid_error_code
+.} bfd_error_type;
+.
+*/
+
+static bfd_error_type bfd_error = bfd_error_no_error;
+
+CONST char *CONST bfd_errmsgs[] = {
+ N_("No error"),
+ N_("System call error"),
+ N_("Invalid bfd target"),
+ N_("File in wrong format"),
+ N_("Invalid operation"),
+ N_("Memory exhausted"),
+ N_("No symbols"),
+ N_("Archive has no index; run ranlib to add one"),
+ N_("No more archived files"),
+ N_("Malformed archive"),
+ N_("File format not recognized"),
+ N_("File format is ambiguous"),
+ N_("Section has no contents"),
+ N_("Nonrepresentable section on output"),
+ N_("Symbol needs debug section which does not exist"),
+ N_("Bad value"),
+ N_("File truncated"),
+ N_("File too big"),
+ N_("#<Invalid error code>")
+ };
+
+/*
+FUNCTION
+ bfd_get_error
+
+SYNOPSIS
+ bfd_error_type bfd_get_error (void);
+
+DESCRIPTION
+ Return the current BFD error condition.
+*/
+
+bfd_error_type
+bfd_get_error ()
+{
+ return bfd_error;
+}
+
+/*
+FUNCTION
+ bfd_set_error
+
+SYNOPSIS
+ void bfd_set_error (bfd_error_type error_tag);
+
+DESCRIPTION
+ Set the BFD error condition to be @var{error_tag}.
+*/
+
+void
+bfd_set_error (error_tag)
+ bfd_error_type error_tag;
+{
+ bfd_error = error_tag;
+}
+
+/*
+FUNCTION
+ bfd_errmsg
+
+SYNOPSIS
+ CONST char *bfd_errmsg (bfd_error_type error_tag);
+
+DESCRIPTION
+ Return a string describing the error @var{error_tag}, or
+ the system error if @var{error_tag} is <<bfd_error_system_call>>.
+*/
+
+CONST char *
+bfd_errmsg (error_tag)
+ bfd_error_type error_tag;
+{
+#ifndef errno
+ extern int errno;
+#endif
+ if (error_tag == bfd_error_system_call)
+ return xstrerror (errno);
+
+ if ((((int)error_tag <(int) bfd_error_no_error) ||
+ ((int)error_tag > (int)bfd_error_invalid_error_code)))
+ error_tag = bfd_error_invalid_error_code;/* sanity check */
+
+ return _(bfd_errmsgs [(int)error_tag]);
+}
+
+/*
+FUNCTION
+ bfd_perror
+
+SYNOPSIS
+ void bfd_perror (CONST char *message);
+
+DESCRIPTION
+ Print to the standard error stream a string describing the
+ last BFD error that occurred, or the last system error if
+ the last BFD error was a system call failure. If @var{message}
+ is non-NULL and non-empty, the error string printed is preceded
+ by @var{message}, a colon, and a space. It is followed by a newline.
+*/
+
+void
+bfd_perror (message)
+ CONST char *message;
+{
+ if (bfd_get_error () == bfd_error_system_call)
+ perror((char *)message); /* must be system error then... */
+ else {
+ if (message == NULL || *message == '\0')
+ fprintf (stderr, "%s\n", bfd_errmsg (bfd_get_error ()));
+ else
+ fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_get_error ()));
+ }
+}
+
+/*
+SUBSECTION
+ BFD error handler
+
+ Some BFD functions want to print messages describing the
+ problem. They call a BFD error handler function. This
+ function may be overriden by the program.
+
+ The BFD error handler acts like printf.
+
+CODE_FRAGMENT
+.
+.typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
+.
+*/
+
+/* The program name used when printing BFD error messages. */
+
+static const char *_bfd_error_program_name;
+
+/* This is the default routine to handle BFD error messages. */
+
+#ifdef ANSI_PROTOTYPES
+
+static void _bfd_default_error_handler PARAMS ((const char *s, ...));
+
+static void
+_bfd_default_error_handler (const char *s, ...)
+{
+ va_list p;
+
+ if (_bfd_error_program_name != NULL)
+ fprintf (stderr, "%s: ", _bfd_error_program_name);
+ else
+ fprintf (stderr, "BFD: ");
+
+ va_start (p, s);
+
+ vfprintf (stderr, s, p);
+
+ va_end (p);
+
+ fprintf (stderr, "\n");
+}
+
+#else /* ! defined (ANSI_PROTOTYPES) */
+
+static void _bfd_default_error_handler ();
+
+static void
+_bfd_default_error_handler (va_alist)
+ va_dcl
+{
+ va_list p;
+ const char *s;
+
+ if (_bfd_error_program_name != NULL)
+ fprintf (stderr, "%s: ", _bfd_error_program_name);
+ else
+ fprintf (stderr, "BFD: ");
+
+ va_start (p);
+
+ s = va_arg (p, const char *);
+ vfprintf (stderr, s, p);
+
+ va_end (p);
+
+ fprintf (stderr, "\n");
+}
+
+#endif /* ! defined (ANSI_PROTOTYPES) */
+
+/* This is a function pointer to the routine which should handle BFD
+ error messages. It is called when a BFD routine encounters an
+ error for which it wants to print a message. Going through a
+ function pointer permits a program linked against BFD to intercept
+ the messages and deal with them itself. */
+
+bfd_error_handler_type _bfd_error_handler = _bfd_default_error_handler;
+
+/*
+FUNCTION
+ bfd_set_error_handler
+
+SYNOPSIS
+ bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
+
+DESCRIPTION
+ Set the BFD error handler function. Returns the previous
+ function.
+*/
+
+bfd_error_handler_type
+bfd_set_error_handler (pnew)
+ bfd_error_handler_type pnew;
+{
+ bfd_error_handler_type pold;
+
+ pold = _bfd_error_handler;
+ _bfd_error_handler = pnew;
+ return pold;
+}
+
+/*
+FUNCTION
+ bfd_set_error_program_name
+
+SYNOPSIS
+ void bfd_set_error_program_name (const char *);
+
+DESCRIPTION
+ Set the program name to use when printing a BFD error. This
+ is printed before the error message followed by a colon and
+ space. The string must not be changed after it is passed to
+ this function.
+*/
+
+void
+bfd_set_error_program_name (name)
+ const char *name;
+{
+ _bfd_error_program_name = name;
+}
+
+
+/*
+FUNCTION
+ bfd_get_error_handler
+
+SYNOPSIS
+ bfd_error_handler_type bfd_get_error_handler (void);
+
+DESCRIPTION
+ Return the BFD error handler function.
+*/
+
+bfd_error_handler_type
+bfd_get_error_handler ()
+{
+ return _bfd_error_handler;
+}
+
+/*
+SECTION
+ Symbols
+*/
+
+/*
+FUNCTION
+ bfd_get_reloc_upper_bound
+
+SYNOPSIS
+ long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect);
+
+DESCRIPTION
+ Return the number of bytes required to store the
+ relocation information associated with section @var{sect}
+ attached to bfd @var{abfd}. If an error occurs, return -1.
+
+*/
+
+
+long
+bfd_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ if (abfd->format != bfd_object) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect));
+}
+
+/*
+FUNCTION
+ bfd_canonicalize_reloc
+
+SYNOPSIS
+ long bfd_canonicalize_reloc
+ (bfd *abfd,
+ asection *sec,
+ arelent **loc,
+ asymbol **syms);
+
+DESCRIPTION
+ Call the back end associated with the open BFD
+ @var{abfd} and translate the external form of the relocation
+ information attached to @var{sec} into the internal canonical
+ form. Place the table into memory at @var{loc}, which has
+ been preallocated, usually by a call to
+ <<bfd_get_reloc_upper_bound>>. Returns the number of relocs, or
+ -1 on error.
+
+ The @var{syms} table is also needed for horrible internal magic
+ reasons.
+
+
+*/
+long
+bfd_canonicalize_reloc (abfd, asect, location, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ arelent **location;
+ asymbol **symbols;
+{
+ if (abfd->format != bfd_object) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+ return BFD_SEND (abfd, _bfd_canonicalize_reloc,
+ (abfd, asect, location, symbols));
+}
+
+/*
+FUNCTION
+ bfd_set_reloc
+
+SYNOPSIS
+ void bfd_set_reloc
+ (bfd *abfd, asection *sec, arelent **rel, unsigned int count)
+
+DESCRIPTION
+ Set the relocation pointer and count within
+ section @var{sec} to the values @var{rel} and @var{count}.
+ The argument @var{abfd} is ignored.
+
+*/
+/*ARGSUSED*/
+void
+bfd_set_reloc (ignore_abfd, asect, location, count)
+ bfd *ignore_abfd;
+ sec_ptr asect;
+ arelent **location;
+ unsigned int count;
+{
+ asect->orelocation = location;
+ asect->reloc_count = count;
+}
+
+/*
+FUNCTION
+ bfd_set_file_flags
+
+SYNOPSIS
+ boolean bfd_set_file_flags(bfd *abfd, flagword flags);
+
+DESCRIPTION
+ Set the flag word in the BFD @var{abfd} to the value @var{flags}.
+
+ Possible errors are:
+ o <<bfd_error_wrong_format>> - The target bfd was not of object format.
+ o <<bfd_error_invalid_operation>> - The target bfd was open for reading.
+ o <<bfd_error_invalid_operation>> -
+ The flag word contained a bit which was not applicable to the
+ type of file. E.g., an attempt was made to set the <<D_PAGED>> bit
+ on a BFD format which does not support demand paging.
+
+*/
+
+boolean
+bfd_set_file_flags (abfd, flags)
+ bfd *abfd;
+ flagword flags;
+{
+ if (abfd->format != bfd_object) {
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if (bfd_read_p (abfd)) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ bfd_get_file_flags (abfd) = flags;
+ if ((flags & bfd_applicable_file_flags (abfd)) != flags) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+return true;
+}
+
+void
+bfd_assert (file, line)
+ const char *file;
+ int line;
+{
+ (*_bfd_error_handler) (_("bfd assertion fail %s:%d"), file, line);
+}
+
+
+/*
+FUNCTION
+ bfd_set_start_address
+
+SYNOPSIS
+ boolean bfd_set_start_address(bfd *abfd, bfd_vma vma);
+
+DESCRIPTION
+ Make @var{vma} the entry point of output BFD @var{abfd}.
+
+RETURNS
+ Returns <<true>> on success, <<false>> otherwise.
+*/
+
+boolean
+bfd_set_start_address(abfd, vma)
+bfd *abfd;
+bfd_vma vma;
+{
+ abfd->start_address = vma;
+ return true;
+}
+
+
+/*
+FUNCTION
+ bfd_get_mtime
+
+SYNOPSIS
+ long bfd_get_mtime(bfd *abfd);
+
+DESCRIPTION
+ Return the file modification time (as read from the file system, or
+ from the archive header for archive members).
+
+*/
+
+long
+bfd_get_mtime (abfd)
+ bfd *abfd;
+{
+ FILE *fp;
+ struct stat buf;
+
+ if (abfd->mtime_set)
+ return abfd->mtime;
+
+ fp = bfd_cache_lookup (abfd);
+ if (0 != fstat (fileno (fp), &buf))
+ return 0;
+
+ abfd->mtime = buf.st_mtime; /* Save value in case anyone wants it */
+ return buf.st_mtime;
+}
+
+/*
+FUNCTION
+ bfd_get_size
+
+SYNOPSIS
+ long bfd_get_size(bfd *abfd);
+
+DESCRIPTION
+ Return the file size (as read from file system) for the file
+ associated with BFD @var{abfd}.
+
+ The initial motivation for, and use of, this routine is not
+ so we can get the exact size of the object the BFD applies to, since
+ that might not be generally possible (archive members for example).
+ It would be ideal if someone could eventually modify
+ it so that such results were guaranteed.
+
+ Instead, we want to ask questions like "is this NNN byte sized
+ object I'm about to try read from file offset YYY reasonable?"
+ As as example of where we might do this, some object formats
+ use string tables for which the first <<sizeof(long)>> bytes of the
+ table contain the size of the table itself, including the size bytes.
+ If an application tries to read what it thinks is one of these
+ string tables, without some way to validate the size, and for
+ some reason the size is wrong (byte swapping error, wrong location
+ for the string table, etc.), the only clue is likely to be a read
+ error when it tries to read the table, or a "virtual memory
+ exhausted" error when it tries to allocate 15 bazillon bytes
+ of space for the 15 bazillon byte table it is about to read.
+ This function at least allows us to answer the quesion, "is the
+ size reasonable?".
+*/
+
+long
+bfd_get_size (abfd)
+ bfd *abfd;
+{
+ FILE *fp;
+ struct stat buf;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ return ((struct bfd_in_memory *) abfd->iostream)->size;
+
+ fp = bfd_cache_lookup (abfd);
+ if (0 != fstat (fileno (fp), &buf))
+ return 0;
+
+ return buf.st_size;
+}
+
+/*
+FUNCTION
+ bfd_get_gp_size
+
+SYNOPSIS
+ int bfd_get_gp_size(bfd *abfd);
+
+DESCRIPTION
+ Return the maximum size of objects to be optimized using the GP
+ register under MIPS ECOFF. This is typically set by the <<-G>>
+ argument to the compiler, assembler or linker.
+*/
+
+int
+bfd_get_gp_size (abfd)
+ bfd *abfd;
+{
+ if (abfd->format == bfd_object)
+ {
+ if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+ return ecoff_data (abfd)->gp_size;
+ else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+ return elf_gp_size (abfd);
+ }
+ return 0;
+}
+
+/*
+FUNCTION
+ bfd_set_gp_size
+
+SYNOPSIS
+ void bfd_set_gp_size(bfd *abfd, int i);
+
+DESCRIPTION
+ Set the maximum size of objects to be optimized using the GP
+ register under ECOFF or MIPS ELF. This is typically set by
+ the <<-G>> argument to the compiler, assembler or linker.
+*/
+
+void
+bfd_set_gp_size (abfd, i)
+ bfd *abfd;
+ int i;
+{
+ /* Don't try to set GP size on an archive or core file! */
+ if (abfd->format != bfd_object)
+ return;
+ if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+ ecoff_data (abfd)->gp_size = i;
+ else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+ elf_gp_size (abfd) = i;
+}
+
+/* Get the GP value. This is an internal function used by some of the
+ relocation special_function routines on targets which support a GP
+ register. */
+
+bfd_vma
+_bfd_get_gp_value (abfd)
+ bfd *abfd;
+{
+ if (abfd->format == bfd_object)
+ {
+ if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+ return ecoff_data (abfd)->gp;
+ else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+ return elf_gp (abfd);
+ }
+ return 0;
+}
+
+/* Set the GP value. */
+
+void
+_bfd_set_gp_value (abfd, v)
+ bfd *abfd;
+ bfd_vma v;
+{
+ if (abfd->format != bfd_object)
+ return;
+ if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+ ecoff_data (abfd)->gp = v;
+ else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+ elf_gp (abfd) = v;
+}
+
+/*
+FUNCTION
+ bfd_scan_vma
+
+SYNOPSIS
+ bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base);
+
+DESCRIPTION
+ Convert, like <<strtoul>>, a numerical expression
+ @var{string} into a <<bfd_vma>> integer, and return that integer.
+ (Though without as many bells and whistles as <<strtoul>>.)
+ The expression is assumed to be unsigned (i.e., positive).
+ If given a @var{base}, it is used as the base for conversion.
+ A base of 0 causes the function to interpret the string
+ in hex if a leading "0x" or "0X" is found, otherwise
+ in octal if a leading zero is found, otherwise in decimal.
+
+ Overflow is not detected.
+*/
+
+bfd_vma
+bfd_scan_vma (string, end, base)
+ CONST char *string;
+ CONST char **end;
+ int base;
+{
+ bfd_vma value;
+ int digit;
+
+ /* Let the host do it if possible. */
+ if (sizeof(bfd_vma) <= sizeof(unsigned long))
+ return (bfd_vma) strtoul (string, (char **) end, base);
+
+ /* A negative base makes no sense, and we only need to go as high as hex. */
+ if ((base < 0) || (base > 16))
+ return (bfd_vma) 0;
+
+ if (base == 0)
+ {
+ if (string[0] == '0')
+ {
+ if ((string[1] == 'x') || (string[1] == 'X'))
+ base = 16;
+ /* XXX should we also allow "0b" or "0B" to set base to 2? */
+ else
+ base = 8;
+ }
+ else
+ base = 10;
+ }
+ if ((base == 16) &&
+ (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X')))
+ string += 2;
+ /* XXX should we also skip over "0b" or "0B" if base is 2? */
+
+/* Speed could be improved with a table like hex_value[] in gas. */
+#define HEX_VALUE(c) \
+ (isxdigit ((unsigned char) c) \
+ ? (isdigit ((unsigned char) c) \
+ ? (c - '0') \
+ : (10 + c - (islower ((unsigned char) c) ? 'a' : 'A'))) \
+ : 42)
+
+ for (value = 0; (digit = HEX_VALUE(*string)) < base; string++)
+ {
+ value = value * base + digit;
+ }
+
+ if (end)
+ *end = string;
+
+ return value;
+}
+
+/*
+FUNCTION
+ bfd_copy_private_bfd_data
+
+SYNOPSIS
+ boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd);
+
+DESCRIPTION
+ Copy private BFD information from the BFD @var{ibfd} to the
+ the BFD @var{obfd}. Return <<true>> on success, <<false>> on error.
+ Possible error returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{obfd}.
+
+.#define bfd_copy_private_bfd_data(ibfd, obfd) \
+. BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
+. (ibfd, obfd))
+
+*/
+
+/*
+FUNCTION
+ bfd_merge_private_bfd_data
+
+SYNOPSIS
+ boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd);
+
+DESCRIPTION
+ Merge private BFD information from the BFD @var{ibfd} to the
+ the output file BFD @var{obfd} when linking. Return <<true>>
+ on success, <<false>> on error. Possible error returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{obfd}.
+
+.#define bfd_merge_private_bfd_data(ibfd, obfd) \
+. BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
+. (ibfd, obfd))
+
+*/
+
+/*
+FUNCTION
+ bfd_set_private_flags
+
+SYNOPSIS
+ boolean bfd_set_private_flags(bfd *abfd, flagword flags);
+
+DESCRIPTION
+ Set private BFD flag information in the BFD @var{abfd}.
+ Return <<true>> on success, <<false>> on error. Possible error
+ returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{obfd}.
+
+.#define bfd_set_private_flags(abfd, flags) \
+. BFD_SEND (abfd, _bfd_set_private_flags, \
+. (abfd, flags))
+
+*/
+
+/*
+FUNCTION
+ stuff
+
+DESCRIPTION
+ Stuff which should be documented:
+
+.#define bfd_sizeof_headers(abfd, reloc) \
+. BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
+.
+.#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
+. BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
+.
+. {* Do these three do anything useful at all, for any back end? *}
+.#define bfd_debug_info_start(abfd) \
+. BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
+.
+.#define bfd_debug_info_end(abfd) \
+. BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
+.
+.#define bfd_debug_info_accumulate(abfd, section) \
+. BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
+.
+.
+.#define bfd_stat_arch_elt(abfd, stat) \
+. BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
+.
+.#define bfd_update_armap_timestamp(abfd) \
+. BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
+.
+.#define bfd_set_arch_mach(abfd, arch, mach)\
+. BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
+.
+.#define bfd_relax_section(abfd, section, link_info, again) \
+. BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
+.
+.#define bfd_gc_sections(abfd, link_info) \
+. BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
+.
+.#define bfd_link_hash_table_create(abfd) \
+. BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
+.
+.#define bfd_link_add_symbols(abfd, info) \
+. BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
+.
+.#define bfd_final_link(abfd, info) \
+. BFD_SEND (abfd, _bfd_final_link, (abfd, info))
+.
+.#define bfd_free_cached_info(abfd) \
+. BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
+.
+.#define bfd_get_dynamic_symtab_upper_bound(abfd) \
+. BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
+.
+.#define bfd_print_private_bfd_data(abfd, file)\
+. BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
+.
+.#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
+. BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
+.
+.#define bfd_get_dynamic_reloc_upper_bound(abfd) \
+. BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
+.
+.#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
+. BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
+.
+.extern bfd_byte *bfd_get_relocated_section_contents
+. PARAMS ((bfd *, struct bfd_link_info *,
+. struct bfd_link_order *, bfd_byte *,
+. boolean, asymbol **));
+.
+
+*/
+
+bfd_byte *
+bfd_get_relocated_section_contents (abfd, link_info, link_order, data,
+ relocateable, symbols)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ bfd *abfd2;
+ bfd_byte *(*fn) PARAMS ((bfd *, struct bfd_link_info *,
+ struct bfd_link_order *, bfd_byte *, boolean,
+ asymbol **));
+
+ if (link_order->type == bfd_indirect_link_order)
+ {
+ abfd2 = link_order->u.indirect.section->owner;
+ if (abfd2 == 0)
+ abfd2 = abfd;
+ }
+ else
+ abfd2 = abfd;
+ fn = abfd2->xvec->_bfd_get_relocated_section_contents;
+
+ return (*fn) (abfd, link_info, link_order, data, relocateable, symbols);
+}
+
+/* Record information about an ELF program header. */
+
+boolean
+bfd_record_phdr (abfd, type, flags_valid, flags, at_valid, at,
+ includes_filehdr, includes_phdrs, count, secs)
+ bfd *abfd;
+ unsigned long type;
+ boolean flags_valid;
+ flagword flags;
+ boolean at_valid;
+ bfd_vma at;
+ boolean includes_filehdr;
+ boolean includes_phdrs;
+ unsigned int count;
+ asection **secs;
+{
+ struct elf_segment_map *m, **pm;
+
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ return true;
+
+ m = ((struct elf_segment_map *)
+ bfd_alloc (abfd,
+ (sizeof (struct elf_segment_map)
+ + ((size_t) count - 1) * sizeof (asection *))));
+ if (m == NULL)
+ return false;
+
+ m->next = NULL;
+ m->p_type = type;
+ m->p_flags = flags;
+ m->p_paddr = at;
+ m->p_flags_valid = flags_valid;
+ m->p_paddr_valid = at_valid;
+ m->includes_filehdr = includes_filehdr;
+ m->includes_phdrs = includes_phdrs;
+ m->count = count;
+ if (count > 0)
+ memcpy (m->sections, secs, count * sizeof (asection *));
+
+ for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
+ ;
+ *pm = m;
+
+ return true;
+}
diff --git a/bfd/binary.c b/bfd/binary.c
new file mode 100644
index 00000000000..6c63fff4adf
--- /dev/null
+++ b/bfd/binary.c
@@ -0,0 +1,386 @@
+/* BFD back-end for binary objects.
+ Copyright 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This is a BFD backend which may be used to write binary objects.
+ It may only be used for output, not input. The intention is that
+ this may be used as an output format for objcopy in order to
+ generate raw binary data.
+
+ This is very simple. The only complication is that the real data
+ will start at some address X, and in some cases we will not want to
+ include X zeroes just to get to that point. Since the start
+ address is not meaningful for this object file format, we use it
+ instead to indicate the number of zeroes to skip at the start of
+ the file. objcopy cooperates by specially setting the start
+ address to zero by default. */
+
+#include <ctype.h>
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/* Any bfd we create by reading a binary file has three symbols:
+ a start symbol, an end symbol, and an absolute length symbol. */
+#define BIN_SYMS 3
+
+static boolean binary_mkobject PARAMS ((bfd *));
+static const bfd_target *binary_object_p PARAMS ((bfd *));
+static boolean binary_get_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static long binary_get_symtab_upper_bound PARAMS ((bfd *));
+static char *mangle_name PARAMS ((bfd *, char *));
+static long binary_get_symtab PARAMS ((bfd *, asymbol **));
+static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
+static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static boolean binary_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static int binary_sizeof_headers PARAMS ((bfd *, boolean));
+
+/* Create a binary object. Invoked via bfd_set_format. */
+
+static boolean
+binary_mkobject (abfd)
+ bfd *abfd;
+{
+ return true;
+}
+
+/* Any file may be considered to be a binary file, provided the target
+ was not defaulted. That is, it must be explicitly specified as
+ being binary. */
+
+static const bfd_target *
+binary_object_p (abfd)
+ bfd *abfd;
+{
+ struct stat statbuf;
+ asection *sec;
+
+ if (abfd->target_defaulted)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ abfd->symcount = BIN_SYMS;
+
+ /* Find the file size. */
+ if (bfd_stat (abfd, &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+
+ /* One data section. */
+ sec = bfd_make_section (abfd, ".data");
+ if (sec == NULL)
+ return NULL;
+ sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
+ sec->vma = 0;
+ sec->_raw_size = statbuf.st_size;
+ sec->filepos = 0;
+
+ abfd->tdata.any = (PTR) sec;
+
+ return abfd->xvec;
+}
+
+#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
+#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define binary_new_section_hook _bfd_generic_new_section_hook
+
+/* Get contents of the only section. */
+
+static boolean
+binary_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0
+ || bfd_read (location, 1, count, abfd) != count)
+ return false;
+ return true;
+}
+
+/* Return the amount of memory needed to read the symbol table. */
+
+static long
+binary_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ return (BIN_SYMS + 1) * sizeof (asymbol *);
+}
+
+/* Create a symbol name based on the bfd's filename. */
+
+static char *
+mangle_name (abfd, suffix)
+ bfd *abfd;
+ char *suffix;
+{
+ int size;
+ char *buf;
+ char *p;
+
+ size = (strlen (bfd_get_filename (abfd))
+ + strlen (suffix)
+ + sizeof "_binary__");
+
+ buf = (char *) bfd_alloc (abfd, size);
+ if (buf == NULL)
+ return "";
+
+ sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
+
+ /* Change any non-alphanumeric characters to underscores. */
+ for (p = buf; *p; p++)
+ if (! isalnum ((unsigned char) *p))
+ *p = '_';
+
+ return buf;
+}
+
+/* Return the symbol table. */
+
+static long
+binary_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ asection *sec = (asection *) abfd->tdata.any;
+ asymbol *syms;
+ unsigned int i;
+
+ syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
+ if (syms == NULL)
+ return false;
+
+ /* Start symbol. */
+ syms[0].the_bfd = abfd;
+ syms[0].name = mangle_name (abfd, "start");
+ syms[0].value = 0;
+ syms[0].flags = BSF_GLOBAL;
+ syms[0].section = sec;
+ syms[0].udata.p = NULL;
+
+ /* End symbol. */
+ syms[1].the_bfd = abfd;
+ syms[1].name = mangle_name (abfd, "end");
+ syms[1].value = sec->_raw_size;
+ syms[1].flags = BSF_GLOBAL;
+ syms[1].section = sec;
+ syms[1].udata.p = NULL;
+
+ /* Size symbol. */
+ syms[2].the_bfd = abfd;
+ syms[2].name = mangle_name (abfd, "size");
+ syms[2].value = sec->_raw_size;
+ syms[2].flags = BSF_GLOBAL;
+ syms[2].section = bfd_abs_section_ptr;
+ syms[2].udata.p = NULL;
+
+ for (i = 0; i < BIN_SYMS; i++)
+ *alocation++ = syms++;
+ *alocation = NULL;
+
+ return BIN_SYMS;
+}
+
+/* Make an empty symbol. */
+
+static asymbol *
+binary_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+}
+
+#define binary_print_symbol _bfd_nosymbols_print_symbol
+
+/* Get information about a symbol. */
+
+static void
+binary_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define binary_get_lineno _bfd_nosymbols_get_lineno
+#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define binary_read_minisymbols _bfd_generic_read_minisymbols
+#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define binary_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
+#define binary_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
+#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+/* Set the architecture of a binary file. */
+#define binary_set_arch_mach _bfd_generic_set_arch_mach
+
+/* Write section contents of a binary file. */
+
+static boolean
+binary_set_section_contents (abfd, sec, data, offset, size)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+ file_ptr offset;
+ bfd_size_type size;
+{
+ if (! abfd->output_has_begun)
+ {
+ boolean found_low;
+ bfd_vma low;
+ asection *s;
+
+ /* The lowest section LMA sets the virtual address of the start
+ of the file. We use this to set the file position of all the
+ sections. */
+ found_low = false;
+ low = 0;
+ for (s = abfd->sections; s != NULL; s = s->next)
+ if (((s->flags
+ & (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_NEVER_LOAD))
+ == (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC))
+ && (! found_low || s->lma < low))
+ {
+ low = s->lma;
+ found_low = true;
+ }
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ s->filepos = s->lma - low;
+
+ /* Skip following warning check for sections that will not
+ occupy file space. */
+ if ((s->flags
+ & (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_NEVER_LOAD))
+ != (SEC_HAS_CONTENTS | SEC_ALLOC))
+ continue;
+
+ /* If attempting to generate a binary file from a bfd with
+ LMA's all over the place, huge (sparse?) binary files may
+ result. This condition attempts to detect this situation
+ and print a warning. Better heuristics would be nice to
+ have. */
+
+ if (s->filepos < 0)
+ (*_bfd_error_handler)
+ (_("Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."),
+ bfd_get_section_name (abfd, s),
+ (unsigned long) s->filepos);
+ }
+
+ abfd->output_has_begun = true;
+ }
+
+ /* We don't want to output anything for a section that is neither
+ loaded nor allocated. The contents of such a section are not
+ meaningful in the binary format. */
+ if ((sec->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
+ return true;
+ if ((sec->flags & SEC_NEVER_LOAD) != 0)
+ return true;
+
+ return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
+}
+
+/* No space is required for header information. */
+
+static int
+binary_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+#define binary_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define binary_bfd_relax_section bfd_generic_relax_section
+#define binary_bfd_gc_sections bfd_generic_gc_sections
+#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define binary_bfd_final_link _bfd_generic_final_link
+#define binary_bfd_link_split_section _bfd_generic_link_split_section
+#define binary_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+const bfd_target binary_vec =
+{
+ "binary", /* name */
+ bfd_target_unknown_flavour, /* flavour */
+ BFD_ENDIAN_UNKNOWN, /* byteorder */
+ BFD_ENDIAN_UNKNOWN, /* header_byteorder */
+ EXEC_P, /* object_flags */
+ (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ { /* bfd_check_format */
+ _bfd_dummy_target,
+ binary_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ binary_mkobject,
+ bfd_false,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_true,
+ bfd_false,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (binary),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (binary),
+ BFD_JUMP_TABLE_RELOCS (binary),
+ BFD_JUMP_TABLE_WRITE (binary),
+ BFD_JUMP_TABLE_LINK (binary),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL
+};
diff --git a/bfd/bout.c b/bfd/bout.c
new file mode 100644
index 00000000000..4ef10f52057
--- /dev/null
+++ b/bfd/bout.c
@@ -0,0 +1,1534 @@
+/* BFD back-end for Intel 960 b.out binaries.
+ Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "genlink.h"
+#include "bout.h"
+
+#include "aout/stab_gnu.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+
+static int aligncode PARAMS ((bfd *abfd, asection *input_section,
+ arelent *r, unsigned int shrink));
+static void perform_slip PARAMS ((bfd *abfd, unsigned int slip,
+ asection *input_section, bfd_vma value));
+static boolean b_out_squirt_out_relocs PARAMS ((bfd *abfd, asection *section));
+static const bfd_target *b_out_callback PARAMS ((bfd *));
+static bfd_reloc_status_type calljx_callback
+ PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR src, PTR dst,
+ asection *));
+static bfd_reloc_status_type callj_callback
+ PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR data,
+ unsigned int srcidx, unsigned int dstidx, asection *, boolean));
+static bfd_vma get_value PARAMS ((arelent *, struct bfd_link_info *,
+ asection *));
+static int abs32code PARAMS ((bfd *, asection *, arelent *,
+ unsigned int, struct bfd_link_info *));
+static boolean b_out_bfd_relax_section PARAMS ((bfd *, asection *,
+ struct bfd_link_info *,
+ boolean *));
+static bfd_byte *b_out_bfd_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean, asymbol **));
+
+/* Swaps the information in an executable header taken from a raw byte
+ stream memory image, into the internal exec_header structure. */
+
+void
+bout_swap_exec_header_in (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* Now fill in fields in the execp, from the bytes in the raw data. */
+ execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_text = GET_WORD (abfd, bytes->e_text);
+ execp->a_data = GET_WORD (abfd, bytes->e_data);
+ execp->a_bss = GET_WORD (abfd, bytes->e_bss);
+ execp->a_syms = GET_WORD (abfd, bytes->e_syms);
+ execp->a_entry = GET_WORD (abfd, bytes->e_entry);
+ execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
+ execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
+ execp->a_tload = GET_WORD (abfd, bytes->e_tload);
+ execp->a_dload = GET_WORD (abfd, bytes->e_dload);
+ execp->a_talign = bytes->e_talign[0];
+ execp->a_dalign = bytes->e_dalign[0];
+ execp->a_balign = bytes->e_balign[0];
+ execp->a_relaxable = bytes->e_relaxable[0];
+}
+
+/* Swaps the information in an internal exec header structure into the
+ supplied buffer ready for writing to disk. */
+
+PROTO(void, bout_swap_exec_header_out,
+ (bfd *abfd,
+ struct internal_exec *execp,
+ struct external_exec *raw_bytes));
+void
+bout_swap_exec_header_out (abfd, execp, raw_bytes)
+ bfd *abfd;
+ struct internal_exec *execp;
+ struct external_exec *raw_bytes;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* Now fill in fields in the raw data, from the fields in the exec struct. */
+ bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
+ PUT_WORD (abfd, execp->a_text , bytes->e_text);
+ PUT_WORD (abfd, execp->a_data , bytes->e_data);
+ PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
+ PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
+ PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
+ PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
+ PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
+ PUT_WORD (abfd, execp->a_tload , bytes->e_tload);
+ PUT_WORD (abfd, execp->a_dload , bytes->e_dload);
+ bytes->e_talign[0] = execp->a_talign;
+ bytes->e_dalign[0] = execp->a_dalign;
+ bytes->e_balign[0] = execp->a_balign;
+ bytes->e_relaxable[0] = execp->a_relaxable;
+}
+
+
+static const bfd_target *
+b_out_object_p (abfd)
+ bfd *abfd;
+{
+ struct internal_exec anexec;
+ struct external_exec exec_bytes;
+
+ if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+
+ if (N_BADMAG (anexec)) {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ bout_swap_exec_header_in (abfd, &exec_bytes, &anexec);
+ return aout_32_some_aout_object_p (abfd, &anexec, b_out_callback);
+}
+
+
+/* Finish up the opening of a b.out file for reading. Fill in all the
+ fields that are not handled by common code. */
+
+static const bfd_target *
+b_out_callback (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+ unsigned long bss_start;
+
+ /* Architecture and machine type */
+ bfd_set_arch_mach(abfd,
+ bfd_arch_i960, /* B.out only used on i960 */
+ bfd_mach_i960_core /* Default */
+ );
+
+ /* The positions of the string table and symbol table. */
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+
+ /* The alignments of the sections */
+ obj_textsec (abfd)->alignment_power = execp->a_talign;
+ obj_datasec (abfd)->alignment_power = execp->a_dalign;
+ obj_bsssec (abfd)->alignment_power = execp->a_balign;
+
+ /* The starting addresses of the sections. */
+ obj_textsec (abfd)->vma = execp->a_tload;
+ obj_datasec (abfd)->vma = execp->a_dload;
+
+ obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
+ obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
+
+ /* And reload the sizes, since the aout module zaps them */
+ obj_textsec (abfd)->_raw_size = execp->a_text;
+
+ bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
+ obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
+
+ obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
+
+ /* The file positions of the sections */
+ obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
+ obj_datasec (abfd)->filepos = N_DATOFF(*execp);
+
+ /* The file positions of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
+ obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
+
+ adata(abfd).page_size = 1; /* Not applicable. */
+ adata(abfd).segment_size = 1; /* Not applicable. */
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+
+ if (execp->a_relaxable)
+ abfd->flags |= BFD_IS_RELAXABLE;
+ return abfd->xvec;
+}
+
+struct bout_data_struct {
+ struct aoutdata a;
+ struct internal_exec e;
+};
+
+static boolean
+b_out_mkobject (abfd)
+ bfd *abfd;
+{
+ struct bout_data_struct *rawptr;
+
+ rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
+ if (rawptr == NULL)
+ return false;
+
+ abfd->tdata.bout_data = rawptr;
+ exec_hdr (abfd) = &rawptr->e;
+
+ obj_textsec (abfd) = (asection *)NULL;
+ obj_datasec (abfd) = (asection *)NULL;
+ obj_bsssec (abfd) = (asection *)NULL;
+
+ return true;
+}
+
+static int
+b_out_symbol_cmp (a, b)
+ struct aout_symbol **a, **b;
+{
+ asection *sec;
+ bfd_vma av, bv;
+
+ /* Primary key is address */
+ sec = bfd_get_section (&(*a)->symbol);
+ av = sec->output_section->vma + sec->output_offset + (*a)->symbol.value;
+ sec = bfd_get_section (&(*b)->symbol);
+ bv = sec->output_section->vma + sec->output_offset + (*b)->symbol.value;
+
+ if (av < bv)
+ return -1;
+ if (av > bv)
+ return 1;
+
+ /* Secondary key puts CALLNAME syms last and BALNAME syms first, so
+ that they have the best chance of being contiguous. */
+ if (IS_BALNAME ((*a)->other) || IS_CALLNAME ((*b)->other))
+ return -1;
+ if (IS_CALLNAME ((*a)->other) || IS_BALNAME ((*b)->other))
+ return 1;
+
+ return 0;
+}
+
+static boolean
+b_out_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec swapped_hdr;
+
+ if (! aout_32_make_sections (abfd))
+ return false;
+
+ exec_hdr (abfd)->a_info = BMAGIC;
+
+ exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
+ exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size;
+ exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_size;
+ exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
+ exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
+ exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
+ sizeof (struct relocation_info));
+ exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) *
+ sizeof (struct relocation_info));
+
+ exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
+ exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
+ exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power;
+
+ exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma;
+ exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma;
+
+ bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
+
+ /* Now write out reloc info, followed by syms and strings */
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ /* Make sure {CALL,BAL}NAME symbols remain adjacent on output
+ by sorting. This is complicated by the fact that stabs are
+ also ordered. Solve this by shifting all stabs to the end
+ in order, then sorting the rest. */
+
+ asymbol **outsyms, **p, **q;
+
+ outsyms = bfd_get_outsymbols (abfd);
+ p = outsyms + bfd_get_symcount (abfd);
+
+ for (q = p--; p >= outsyms; p--)
+ {
+ if ((*p)->flags & BSF_DEBUGGING)
+ {
+ asymbol *t = *--q;
+ *q = *p;
+ *p = t;
+ }
+ }
+
+ if (q > outsyms)
+ qsort (outsyms, q - outsyms, sizeof(asymbol*), b_out_symbol_cmp);
+
+ /* Back to your regularly scheduled program. */
+
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ if (! aout_32_write_syms (abfd))
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET) != 0)
+ return false;
+
+ if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
+ if (bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) return false;
+ }
+ return true;
+}
+
+/** Some reloc hackery */
+
+#define CALLS 0x66003800 /* Template for 'calls' instruction */
+#define BAL 0x0b000000 /* Template for 'bal' instruction */
+#define BAL_MASK 0x00ffffff
+#define BALX 0x85f00000 /* Template for 'balx' instruction */
+#define BALX_MASK 0x0007ffff
+#define CALL 0x09000000
+#define PCREL13_MASK 0x1fff
+
+
+#define output_addr(sec) ((sec)->output_offset+(sec)->output_section->vma)
+
+/* Magic to turn callx into calljx */
+static bfd_reloc_status_type
+calljx_callback (abfd, link_info, reloc_entry, src, dst, input_section)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ arelent *reloc_entry;
+ PTR src;
+ PTR dst;
+ asection *input_section;
+{
+ int word = bfd_get_32 (abfd, src);
+ asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
+ aout_symbol_type *symbol = aout_symbol (symbol_in);
+ bfd_vma value;
+
+ value = get_value (reloc_entry, link_info, input_section);
+
+ if (IS_CALLNAME (symbol->other))
+ {
+ aout_symbol_type *balsym = symbol+1;
+ int inst = bfd_get_32 (abfd, (bfd_byte *) src-4);
+ /* The next symbol should be an N_BALNAME */
+ BFD_ASSERT (IS_BALNAME (balsym->other));
+ inst &= BALX_MASK;
+ inst |= BALX;
+ bfd_put_32 (abfd, inst, (bfd_byte *) dst-4);
+ symbol = balsym;
+ value = (symbol->symbol.value
+ + output_addr (symbol->symbol.section));
+ }
+
+ word += value + reloc_entry->addend;
+
+ bfd_put_32(abfd, word, dst);
+ return bfd_reloc_ok;
+}
+
+
+/* Magic to turn call into callj */
+static bfd_reloc_status_type
+callj_callback (abfd, link_info, reloc_entry, data, srcidx, dstidx,
+ input_section, shrinking)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ arelent *reloc_entry;
+ PTR data;
+ unsigned int srcidx;
+ unsigned int dstidx;
+ asection *input_section;
+ boolean shrinking;
+{
+ int word = bfd_get_32 (abfd, (bfd_byte *) data + srcidx);
+ asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
+ aout_symbol_type *symbol = aout_symbol (symbol_in);
+ bfd_vma value;
+
+ value = get_value (reloc_entry, link_info, input_section);
+
+ if (IS_OTHER(symbol->other))
+ {
+ /* Call to a system procedure - replace code with system
+ procedure number. */
+ word = CALLS | (symbol->other - 1);
+ }
+ else if (IS_CALLNAME(symbol->other))
+ {
+ aout_symbol_type *balsym = symbol+1;
+
+ /* The next symbol should be an N_BALNAME. */
+ BFD_ASSERT(IS_BALNAME(balsym->other));
+
+ /* We are calling a leaf, so replace the call instruction with a
+ bal. */
+ word = BAL | ((word
+ + output_addr (balsym->symbol.section)
+ + balsym->symbol.value + reloc_entry->addend
+ - dstidx
+ - output_addr (input_section))
+ & BAL_MASK);
+ }
+ else if ((symbol->symbol.flags & BSF_SECTION_SYM) != 0)
+ {
+ /* A callj against a symbol in the same section is a fully
+ resolved relative call. We don't need to do anything here.
+ If the symbol is not in the same section, I'm not sure what
+ to do; fortunately, this case will probably never arise. */
+ BFD_ASSERT (! shrinking);
+ BFD_ASSERT (symbol->symbol.section == input_section);
+ }
+ else
+ {
+ word = CALL | (((word & BAL_MASK)
+ + value
+ + reloc_entry->addend
+ - (shrinking ? dstidx : 0)
+ - output_addr (input_section))
+ & BAL_MASK);
+ }
+ bfd_put_32(abfd, word, (bfd_byte *) data + dstidx);
+ return bfd_reloc_ok;
+}
+
+/* type rshift size bitsize pcrel bitpos absolute overflow check*/
+
+#define ABS32CODE 0
+#define ABS32CODE_SHRUNK 1
+#define PCREL24 2
+#define CALLJ 3
+#define ABS32 4
+#define PCREL13 5
+#define ABS32_MAYBE_RELAXABLE 1
+#define ABS32_WAS_RELAXABLE 2
+
+#define ALIGNER 10
+#define ALIGNDONE 11
+static reloc_howto_type howto_reloc_callj =
+HOWTO(CALLJ, 0, 2, 24, true, 0, complain_overflow_signed, 0,"callj", true, 0x00ffffff, 0x00ffffff,false);
+static reloc_howto_type howto_reloc_abs32 =
+HOWTO(ABS32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"abs32", true, 0xffffffff,0xffffffff,false);
+static reloc_howto_type howto_reloc_pcrel24 =
+HOWTO(PCREL24, 0, 2, 24, true, 0, complain_overflow_signed,0,"pcrel24", true, 0x00ffffff,0x00ffffff,false);
+
+static reloc_howto_type howto_reloc_pcrel13 =
+HOWTO(PCREL13, 0, 2, 13, true, 0, complain_overflow_signed,0,"pcrel13", true, 0x00001fff,0x00001fff,false);
+
+
+static reloc_howto_type howto_reloc_abs32codeshrunk =
+HOWTO(ABS32CODE_SHRUNK, 0, 2, 24, true, 0, complain_overflow_signed, 0,"callx->callj", true, 0x00ffffff, 0x00ffffff,false);
+
+static reloc_howto_type howto_reloc_abs32code =
+HOWTO(ABS32CODE, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"callx", true, 0xffffffff,0xffffffff,false);
+
+static reloc_howto_type howto_align_table[] = {
+ HOWTO (ALIGNER, 0, 0x1, 0, false, 0, complain_overflow_dont, 0, "align16", false, 0, 0, false),
+ HOWTO (ALIGNER, 0, 0x3, 0, false, 0, complain_overflow_dont, 0, "align32", false, 0, 0, false),
+ HOWTO (ALIGNER, 0, 0x7, 0, false, 0, complain_overflow_dont, 0, "align64", false, 0, 0, false),
+ HOWTO (ALIGNER, 0, 0xf, 0, false, 0, complain_overflow_dont, 0, "align128", false, 0, 0, false),
+};
+
+static reloc_howto_type howto_done_align_table[] = {
+ HOWTO (ALIGNDONE, 0x1, 0x1, 0, false, 0, complain_overflow_dont, 0, "donealign16", false, 0, 0, false),
+ HOWTO (ALIGNDONE, 0x3, 0x3, 0, false, 0, complain_overflow_dont, 0, "donealign32", false, 0, 0, false),
+ HOWTO (ALIGNDONE, 0x7, 0x7, 0, false, 0, complain_overflow_dont, 0, "donealign64", false, 0, 0, false),
+ HOWTO (ALIGNDONE, 0xf, 0xf, 0, false, 0, complain_overflow_dont, 0, "donealign128", false, 0, 0, false),
+};
+
+static reloc_howto_type *
+b_out_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ default:
+ return 0;
+ case BFD_RELOC_I960_CALLJ:
+ return &howto_reloc_callj;
+ case BFD_RELOC_32:
+ case BFD_RELOC_CTOR:
+ return &howto_reloc_abs32;
+ case BFD_RELOC_24_PCREL:
+ return &howto_reloc_pcrel24;
+ }
+}
+
+/* Allocate enough room for all the reloc entries, plus pointers to them all */
+
+static boolean
+b_out_slurp_reloc_table (abfd, asect, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ asymbol **symbols;
+{
+ register struct relocation_info *rptr;
+ unsigned int counter ;
+ arelent *cache_ptr ;
+ int extern_mask, pcrel_mask, callj_mask, length_shift;
+ int incode_mask;
+ int size_mask;
+ bfd_vma prev_addr = 0;
+ unsigned int count;
+ size_t reloc_size;
+ struct relocation_info *relocs;
+ arelent *reloc_cache;
+
+ if (asect->relocation)
+ return true;
+ if (!aout_32_slurp_symbol_table (abfd))
+ return false;
+
+ if (asect == obj_datasec (abfd)) {
+ reloc_size = exec_hdr(abfd)->a_drsize;
+ goto doit;
+ }
+
+ if (asect == obj_textsec (abfd)) {
+ reloc_size = exec_hdr(abfd)->a_trsize;
+ goto doit;
+ }
+
+ if (asect == obj_bsssec (abfd)) {
+ reloc_size = 0;
+ goto doit;
+ }
+
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+
+ doit:
+ if (bfd_seek (abfd, (file_ptr)(asect->rel_filepos), SEEK_SET) != 0)
+ return false;
+ count = reloc_size / sizeof (struct relocation_info);
+
+ relocs = (struct relocation_info *) bfd_malloc (reloc_size);
+ if (!relocs && reloc_size != 0)
+ return false;
+ reloc_cache = (arelent *) bfd_malloc ((count+1) * sizeof (arelent));
+ if (!reloc_cache) {
+ if (relocs != NULL)
+ free ((char*)relocs);
+ return false;
+ }
+
+ if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size) {
+ free (reloc_cache);
+ if (relocs != NULL)
+ free (relocs);
+ return false;
+ }
+
+
+
+ if (bfd_header_big_endian (abfd)) {
+ /* big-endian bit field allocation order */
+ pcrel_mask = 0x80;
+ extern_mask = 0x10;
+ incode_mask = 0x08;
+ callj_mask = 0x02;
+ size_mask = 0x20;
+ length_shift = 5;
+ } else {
+ /* little-endian bit field allocation order */
+ pcrel_mask = 0x01;
+ extern_mask = 0x08;
+ incode_mask = 0x10;
+ callj_mask = 0x40;
+ size_mask = 0x02;
+ length_shift = 1;
+ }
+
+ for (rptr = relocs, cache_ptr = reloc_cache, counter = 0;
+ counter < count;
+ counter++, rptr++, cache_ptr++)
+ {
+ unsigned char *raw = (unsigned char *)rptr;
+ unsigned int symnum;
+ cache_ptr->address = bfd_h_get_32 (abfd, raw + 0);
+ cache_ptr->howto = 0;
+ if (bfd_header_big_endian (abfd))
+ {
+ symnum = (raw[4] << 16) | (raw[5] << 8) | raw[6];
+ }
+ else
+ {
+ symnum = (raw[6] << 16) | (raw[5] << 8) | raw[4];
+ }
+
+ if (raw[7] & extern_mask)
+ {
+ /* if this is set then the r_index is a index into the symbol table;
+ * if the bit is not set then r_index contains a section map.
+ * we either fill in the sym entry with a pointer to the symbol,
+ * or point to the correct section
+ */
+ cache_ptr->sym_ptr_ptr = symbols + symnum;
+ cache_ptr->addend = 0;
+ } else
+ {
+ /* in a.out symbols are relative to the beginning of the
+ * file rather than sections ?
+ * (look in translate_from_native_sym_flags)
+ * the reloc entry addend has added to it the offset into the
+ * file of the data, so subtract the base to make the reloc
+ * section relative */
+ int s;
+ {
+ /* sign-extend symnum from 24 bits to whatever host uses */
+ s = symnum;
+ if (s & (1 << 23))
+ s |= (~0) << 24;
+ }
+ cache_ptr->sym_ptr_ptr = (asymbol **)NULL;
+ switch (s)
+ {
+ case N_TEXT:
+ case N_TEXT | N_EXT:
+ cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr;
+ cache_ptr->addend = - obj_textsec(abfd)->vma;
+ break;
+ case N_DATA:
+ case N_DATA | N_EXT:
+ cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr;
+ cache_ptr->addend = - obj_datasec(abfd)->vma;
+ break;
+ case N_BSS:
+ case N_BSS | N_EXT:
+ cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr;
+ cache_ptr->addend = - obj_bsssec(abfd)->vma;
+ break;
+ case N_ABS:
+ case N_ABS | N_EXT:
+ cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr;
+ cache_ptr->addend = 0;
+ break;
+ case -2: /* .align */
+ if (raw[7] & pcrel_mask)
+ {
+ cache_ptr->howto = &howto_align_table[(raw[7] >> length_shift) & 3];
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+ else
+ {
+ /* .org? */
+ abort ();
+ }
+ cache_ptr->addend = 0;
+ break;
+ default:
+ BFD_ASSERT(0);
+ break;
+ }
+
+ }
+
+ /* the i960 only has a few relocation types:
+ abs 32-bit and pcrel 24bit. except for callj's! */
+ if (cache_ptr->howto != 0)
+ ;
+ else if (raw[7] & callj_mask)
+ {
+ cache_ptr->howto = &howto_reloc_callj;
+ }
+ else if ( raw[7] & pcrel_mask)
+ {
+ if (raw[7] & size_mask)
+ cache_ptr->howto = &howto_reloc_pcrel13;
+ else
+ cache_ptr->howto = &howto_reloc_pcrel24;
+ }
+ else
+ {
+ if (raw[7] & incode_mask)
+ {
+ cache_ptr->howto = &howto_reloc_abs32code;
+ }
+ else
+ {
+ cache_ptr->howto = &howto_reloc_abs32;
+ }
+ }
+ if (cache_ptr->address < prev_addr)
+ {
+ /* Ouch! this reloc is out of order, insert into the right place
+ */
+ arelent tmp;
+ arelent *cursor = cache_ptr-1;
+ bfd_vma stop = cache_ptr->address;
+ tmp = *cache_ptr;
+ while (cursor->address > stop && cursor >= reloc_cache)
+ {
+ cursor[1] = cursor[0];
+ cursor--;
+ }
+ cursor[1] = tmp;
+ }
+ else
+ {
+ prev_addr = cache_ptr->address;
+ }
+ }
+
+
+ if (relocs != NULL)
+ free (relocs);
+ asect->relocation = reloc_cache;
+ asect->reloc_count = count;
+
+
+ return true;
+}
+
+
+static boolean
+b_out_squirt_out_relocs (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ arelent **generic;
+ int r_extern = 0;
+ int r_idx;
+ int incode_mask;
+ int len_1;
+ unsigned int count = section->reloc_count;
+ struct relocation_info *native, *natptr;
+ size_t natsize = count * sizeof (struct relocation_info);
+ int extern_mask, pcrel_mask, len_2, callj_mask;
+ if (count == 0) return true;
+ generic = section->orelocation;
+ native = ((struct relocation_info *) bfd_malloc (natsize));
+ if (!native && natsize != 0)
+ return false;
+
+ if (bfd_header_big_endian (abfd))
+ {
+ /* Big-endian bit field allocation order */
+ pcrel_mask = 0x80;
+ extern_mask = 0x10;
+ len_2 = 0x40;
+ len_1 = 0x20;
+ callj_mask = 0x02;
+ incode_mask = 0x08;
+ }
+ else
+ {
+ /* Little-endian bit field allocation order */
+ pcrel_mask = 0x01;
+ extern_mask = 0x08;
+ len_2 = 0x04;
+ len_1 = 0x02;
+ callj_mask = 0x40;
+ incode_mask = 0x10;
+ }
+
+ for (natptr = native; count > 0; --count, ++natptr, ++generic)
+ {
+ arelent *g = *generic;
+ unsigned char *raw = (unsigned char *)natptr;
+ asymbol *sym = *(g->sym_ptr_ptr);
+
+ asection *output_section = sym->section->output_section;
+
+ bfd_h_put_32(abfd, g->address, raw);
+ /* Find a type in the output format which matches the input howto -
+ * at the moment we assume input format == output format FIXME!!
+ */
+ r_idx = 0;
+ /* FIXME: Need callj stuff here, and to check the howto entries to
+ be sure they are real for this architecture. */
+ if (g->howto== &howto_reloc_callj)
+ {
+ raw[7] = callj_mask + pcrel_mask + len_2;
+ }
+ else if (g->howto == &howto_reloc_pcrel24)
+ {
+ raw[7] = pcrel_mask + len_2;
+ }
+ else if (g->howto == &howto_reloc_pcrel13)
+ {
+ raw[7] = pcrel_mask + len_1;
+ }
+ else if (g->howto == &howto_reloc_abs32code)
+ {
+ raw[7] = len_2 + incode_mask;
+ }
+ else if (g->howto >= howto_align_table
+ && g->howto <= (howto_align_table
+ + sizeof (howto_align_table) / sizeof (howto_align_table[0])
+ - 1))
+ {
+ /* symnum == -2; extern_mask not set, pcrel_mask set */
+ r_idx = -2;
+ r_extern = 0;
+ raw[7] = (pcrel_mask
+ | ((g->howto - howto_align_table) << 1));
+ }
+ else {
+ raw[7] = len_2;
+ }
+
+ if (r_idx != 0)
+ /* already mucked with r_extern, r_idx */;
+ else if (bfd_is_com_section (output_section)
+ || bfd_is_abs_section (output_section)
+ || bfd_is_und_section (output_section))
+ {
+
+ if (bfd_abs_section_ptr->symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_idx = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+
+ r_extern = 1;
+ r_idx = (*g->sym_ptr_ptr)->udata.i;
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_idx = output_section->target_index;
+ }
+
+ if (bfd_header_big_endian (abfd)) {
+ raw[4] = (unsigned char) (r_idx >> 16);
+ raw[5] = (unsigned char) (r_idx >> 8);
+ raw[6] = (unsigned char) (r_idx );
+ } else {
+ raw[6] = (unsigned char) (r_idx >> 16);
+ raw[5] = (unsigned char) (r_idx>> 8);
+ raw[4] = (unsigned char) (r_idx );
+ }
+ if (r_extern)
+ raw[7] |= extern_mask;
+ }
+
+ if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
+ free((PTR)native);
+ return false;
+ }
+ free ((PTR)native);
+
+ return true;
+}
+
+/* This is stupid. This function should be a boolean predicate */
+static long
+b_out_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr;
+ unsigned int count;
+
+ if ((section->flags & SEC_CONSTRUCTOR) != 0)
+ {
+ arelent_chain *chain = section->constructor_chain;
+ for (count = 0; count < section->reloc_count; count++)
+ {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+ }
+ else
+ {
+ if (section->relocation == NULL
+ && ! b_out_slurp_reloc_table (abfd, section, symbols))
+ return -1;
+
+ tblptr = section->relocation;
+ for (count = 0; count++ < section->reloc_count;)
+ *relptr++ = tblptr++;
+ }
+
+ *relptr = NULL;
+
+ return section->reloc_count;
+}
+
+static long
+b_out_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ if (bfd_get_format (abfd) != bfd_object) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ if (asect->flags & SEC_CONSTRUCTOR)
+ return sizeof (arelent *) * (asect->reloc_count + 1);
+
+ if (asect == obj_datasec (abfd))
+ return (sizeof (arelent *) *
+ ((exec_hdr(abfd)->a_drsize / sizeof (struct relocation_info))
+ +1));
+
+ if (asect == obj_textsec (abfd))
+ return (sizeof (arelent *) *
+ ((exec_hdr(abfd)->a_trsize / sizeof (struct relocation_info))
+ +1));
+
+ if (asect == obj_bsssec (abfd))
+ return 0;
+
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+}
+
+static boolean
+b_out_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+
+ if (abfd->output_has_begun == false) { /* set by bfd.c handler */
+ if (! aout_32_make_sections (abfd))
+ return false;
+
+ obj_textsec (abfd)->filepos = sizeof(struct internal_exec);
+ obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
+ + obj_textsec (abfd)->_raw_size;
+
+ }
+ /* regardless, once we know what we're doing, we might as well get going */
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
+ return false;
+
+ if (count != 0) {
+ return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
+ }
+ return true;
+}
+
+static boolean
+b_out_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ bfd_default_set_arch_mach(abfd, arch, machine);
+
+ if (arch == bfd_arch_unknown) /* Unknown machine arch is OK */
+ return true;
+ if (arch == bfd_arch_i960) /* i960 default is OK */
+ switch (machine) {
+ case bfd_mach_i960_core:
+ case bfd_mach_i960_kb_sb:
+ case bfd_mach_i960_mc:
+ case bfd_mach_i960_xa:
+ case bfd_mach_i960_ca:
+ case bfd_mach_i960_ka_sa:
+ case bfd_mach_i960_jx:
+ case bfd_mach_i960_hx:
+ case 0:
+ return true;
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+static int
+b_out_sizeof_headers (ignore_abfd, ignore)
+ bfd *ignore_abfd;
+ boolean ignore;
+{
+ return sizeof(struct internal_exec);
+}
+
+
+
+/************************************************************************/
+static bfd_vma
+get_value (reloc, link_info, input_section)
+ arelent *reloc;
+ struct bfd_link_info *link_info;
+ asection *input_section;
+{
+ bfd_vma value;
+ asymbol *symbol = *(reloc->sym_ptr_ptr);
+
+ /* A symbol holds a pointer to a section, and an offset from the
+ base of the section. To relocate, we find where the section will
+ live in the output and add that in */
+
+ if (bfd_is_und_section (symbol->section))
+ {
+ struct bfd_link_hash_entry *h;
+
+ /* The symbol is undefined in this BFD. Look it up in the
+ global linker hash table. FIXME: This should be changed when
+ we convert b.out to use a specific final_link function and
+ change the interface to bfd_relax_section to not require the
+ generic symbols. */
+ h = bfd_wrapped_link_hash_lookup (input_section->owner, link_info,
+ bfd_asymbol_name (symbol),
+ false, false, true);
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak))
+ value = h->u.def.value + output_addr (h->u.def.section);
+ else if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_common)
+ value = h->u.c.size;
+ else
+ {
+ if (! ((*link_info->callbacks->undefined_symbol)
+ (link_info, bfd_asymbol_name (symbol),
+ input_section->owner, input_section, reloc->address)))
+ abort ();
+ value = 0;
+ }
+ }
+ else
+ {
+ value = symbol->value + output_addr (symbol->section);
+ }
+
+ /* Add the value contained in the relocation */
+ value += reloc->addend;
+
+ return value;
+}
+
+static void
+perform_slip (abfd, slip, input_section, value)
+ bfd *abfd;
+ unsigned int slip;
+ asection *input_section;
+ bfd_vma value;
+{
+ asymbol **s;
+
+ s = _bfd_generic_link_get_symbols (abfd);
+ BFD_ASSERT (s != (asymbol **) NULL);
+
+ /* Find all symbols past this point, and make them know
+ what's happened */
+ while (*s)
+ {
+ asymbol *p = *s;
+ if (p->section == input_section)
+ {
+ /* This was pointing into this section, so mangle it */
+ if (p->value > value)
+ {
+ p->value -=slip;
+ if (p->udata.p != NULL)
+ {
+ struct generic_link_hash_entry *h;
+
+ h = (struct generic_link_hash_entry *) p->udata.p;
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined);
+ h->root.u.def.value -= slip;
+ BFD_ASSERT (h->root.u.def.value == p->value);
+ }
+ }
+ }
+ s++;
+
+ }
+}
+
+/* This routine works out if the thing we want to get to can be
+ reached with a 24bit offset instead of a 32 bit one.
+ If it can, then it changes the amode */
+
+static int
+abs32code (abfd, input_section, r, shrink, link_info)
+ bfd *abfd;
+ asection *input_section;
+ arelent *r;
+ unsigned int shrink;
+ struct bfd_link_info *link_info;
+{
+ bfd_vma value = get_value (r, link_info, input_section);
+ bfd_vma dot = output_addr (input_section) + r->address;
+ bfd_vma gap;
+
+ /* See if the address we're looking at within 2^23 bytes of where
+ we are, if so then we can use a small branch rather than the
+ jump we were going to */
+
+ gap = value - (dot - shrink);
+
+
+ if (-1<<23 < (long)gap && (long)gap < 1<<23 )
+ {
+ /* Change the reloc type from 32bitcode possible 24, to 24bit
+ possible 32 */
+
+ r->howto = &howto_reloc_abs32codeshrunk;
+ /* The place to relc moves back by four bytes */
+ r->address -=4;
+
+ /* This will be four bytes smaller in the long run */
+ shrink += 4 ;
+ perform_slip (abfd, 4, input_section, r->address-shrink + 4);
+ }
+ return shrink;
+}
+
+static int
+aligncode (abfd, input_section, r, shrink)
+ bfd *abfd;
+ asection *input_section;
+ arelent *r;
+ unsigned int shrink;
+{
+ bfd_vma dot = output_addr (input_section) + r->address;
+ bfd_vma gap;
+ bfd_vma old_end;
+ bfd_vma new_end;
+ int shrink_delta;
+ int size = r->howto->size;
+
+ /* Reduce the size of the alignment so that it's still aligned but
+ smaller - the current size is already the same size as or bigger
+ than the alignment required. */
+
+ /* calculate the first byte following the padding before we optimize */
+ old_end = ((dot + size ) & ~size) + size+1;
+ /* work out where the new end will be - remember that we're smaller
+ than we used to be */
+ new_end = ((dot - shrink + size) & ~size);
+
+ /* This is the new end */
+ gap = old_end - ((dot + size) & ~size);
+
+ shrink_delta = (old_end - new_end) - shrink;
+
+ if (shrink_delta)
+ {
+ /* Change the reloc so that it knows how far to align to */
+ r->howto = howto_done_align_table + (r->howto - howto_align_table);
+
+ /* Encode the stuff into the addend - for future use we need to
+ know how big the reloc used to be */
+ r->addend = old_end - dot + r->address;
+
+ /* This will be N bytes smaller in the long run, adjust all the symbols */
+ perform_slip (abfd, shrink_delta, input_section, r->address - shrink);
+ shrink += shrink_delta;
+ }
+ return shrink;
+}
+
+static boolean
+b_out_bfd_relax_section (abfd, i, link_info, again)
+ bfd *abfd;
+ asection *i;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ /* Get enough memory to hold the stuff */
+ bfd *input_bfd = i->owner;
+ asection *input_section = i;
+ int shrink = 0 ;
+ arelent **reloc_vector = NULL;
+ long reloc_size = bfd_get_reloc_upper_bound(input_bfd,
+ input_section);
+
+ if (reloc_size < 0)
+ return false;
+
+ /* We only run this relaxation once. It might work to run it
+ multiple times, but it hasn't been tested. */
+ *again = false;
+
+ if (reloc_size)
+ {
+ long reloc_count;
+
+ reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ if (reloc_vector == NULL && reloc_size != 0)
+ goto error_return;
+
+ /* Get the relocs and think about them */
+ reloc_count =
+ bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector,
+ _bfd_generic_link_get_symbols (input_bfd));
+ if (reloc_count < 0)
+ goto error_return;
+ if (reloc_count > 0)
+ {
+ arelent **parent;
+ for (parent = reloc_vector; *parent; parent++)
+ {
+ arelent *r = *parent;
+ switch (r->howto->type)
+ {
+ case ALIGNER:
+ /* An alignment reloc */
+ shrink = aligncode (abfd, input_section, r, shrink);
+ break;
+ case ABS32CODE:
+ /* A 32bit reloc in an addressing mode */
+ shrink = abs32code (input_bfd, input_section, r, shrink,
+ link_info);
+ break;
+ case ABS32CODE_SHRUNK:
+ shrink+=4;
+ break;
+ }
+ }
+ }
+ }
+ input_section->_cooked_size = input_section->_raw_size - shrink;
+
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return true;
+ error_return:
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return false;
+}
+
+static bfd_byte *
+b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ /* Get enough memory to hold the stuff */
+ bfd *input_bfd = link_order->u.indirect.section->owner;
+ asection *input_section = link_order->u.indirect.section;
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
+ input_section);
+ arelent **reloc_vector = NULL;
+ long reloc_count;
+
+ if (reloc_size < 0)
+ goto error_return;
+
+ /* If producing relocateable output, don't bother to relax. */
+ if (relocateable)
+ return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
+ link_order,
+ data, relocateable,
+ symbols);
+
+ reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ if (reloc_vector == NULL && reloc_size != 0)
+ goto error_return;
+
+ input_section->reloc_done = 1;
+
+ /* read in the section */
+ BFD_ASSERT (true == bfd_get_section_contents (input_bfd,
+ input_section,
+ data,
+ 0,
+ input_section->_raw_size));
+
+ reloc_count = bfd_canonicalize_reloc (input_bfd,
+ input_section,
+ reloc_vector,
+ symbols);
+ if (reloc_count < 0)
+ goto error_return;
+ if (reloc_count > 0)
+ {
+ arelent **parent = reloc_vector;
+ arelent *reloc ;
+
+ unsigned int dst_address = 0;
+ unsigned int src_address = 0;
+ unsigned int run;
+ unsigned int idx;
+
+ /* Find how long a run we can do */
+ while (dst_address < link_order->size)
+ {
+ reloc = *parent;
+ if (reloc)
+ {
+ /* Note that the relaxing didn't tie up the addresses in the
+ relocation, so we use the original address to work out the
+ run of non-relocated data */
+ BFD_ASSERT (reloc->address >= src_address);
+ run = reloc->address - src_address;
+ parent++;
+ }
+ else
+ {
+ run = link_order->size - dst_address;
+ }
+ /* Copy the bytes */
+ for (idx = 0; idx < run; idx++)
+ {
+ data[dst_address++] = data[src_address++];
+ }
+
+ /* Now do the relocation */
+
+ if (reloc)
+ {
+ switch (reloc->howto->type)
+ {
+ case ABS32CODE:
+ calljx_callback (input_bfd, link_info, reloc,
+ src_address + data, dst_address + data,
+ input_section);
+ src_address+=4;
+ dst_address+=4;
+ break;
+ case ABS32:
+ bfd_put_32 (input_bfd,
+ (bfd_get_32 (input_bfd, data + src_address)
+ + get_value (reloc, link_info, input_section)),
+ data + dst_address);
+ src_address+=4;
+ dst_address+=4;
+ break;
+ case CALLJ:
+ callj_callback (input_bfd, link_info, reloc, data,
+ src_address, dst_address, input_section,
+ false);
+ src_address+=4;
+ dst_address+=4;
+ break;
+ case ALIGNDONE:
+ BFD_ASSERT (reloc->addend >= src_address);
+ BFD_ASSERT (reloc->addend <= input_section->_raw_size);
+ src_address = reloc->addend;
+ dst_address = ((dst_address + reloc->howto->size)
+ & ~reloc->howto->size);
+ break;
+ case ABS32CODE_SHRUNK:
+ /* This used to be a callx, but we've found out that a
+ callj will reach, so do the right thing. */
+ callj_callback (input_bfd, link_info, reloc, data,
+ src_address + 4, dst_address, input_section,
+ true);
+ dst_address+=4;
+ src_address+=8;
+ break;
+ case PCREL24:
+ {
+ long int word = bfd_get_32 (input_bfd,
+ data + src_address);
+ bfd_vma value;
+
+ value = get_value (reloc, link_info, input_section);
+ word = ((word & ~BAL_MASK)
+ | (((word & BAL_MASK)
+ + value
+ - output_addr (input_section)
+ + reloc->addend)
+ & BAL_MASK));
+
+ bfd_put_32 (input_bfd, word, data + dst_address);
+ dst_address+=4;
+ src_address+=4;
+
+ }
+ break;
+
+ case PCREL13:
+ {
+ long int word = bfd_get_32 (input_bfd,
+ data + src_address);
+ bfd_vma value;
+
+ value = get_value (reloc, link_info, input_section);
+ word = ((word & ~PCREL13_MASK)
+ | (((word & PCREL13_MASK)
+ + value
+ + reloc->addend
+ - output_addr (input_section))
+ & PCREL13_MASK));
+
+ bfd_put_32 (input_bfd, word, data + dst_address);
+ dst_address+=4;
+ src_address+=4;
+
+ }
+ break;
+
+ default:
+ abort();
+ }
+ }
+ }
+ }
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return data;
+ error_return:
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return NULL;
+}
+/***********************************************************************/
+
+/* Build the transfer vectors for Big and Little-Endian B.OUT files. */
+
+#define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
+
+#define b_out_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define b_out_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define b_out_bfd_final_link _bfd_generic_final_link
+#define b_out_bfd_link_split_section _bfd_generic_link_split_section
+#define b_out_bfd_gc_sections bfd_generic_gc_sections
+
+#define aout_32_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+const bfd_target b_out_vec_big_host =
+{
+ "b.out.big", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_BIG, /* hdr byte order is big */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ '_', /* symbol leading char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ {_bfd_dummy_target, b_out_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, b_out_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, b_out_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (aout_32),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
+ BFD_JUMP_TABLE_SYMBOLS (aout_32),
+ BFD_JUMP_TABLE_RELOCS (b_out),
+ BFD_JUMP_TABLE_WRITE (b_out),
+ BFD_JUMP_TABLE_LINK (b_out),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0,
+};
+
+
+const bfd_target b_out_vec_little_host =
+{
+ "b.out.little", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ '_', /* symbol leading char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, b_out_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, b_out_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, b_out_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (aout_32),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
+ BFD_JUMP_TABLE_SYMBOLS (aout_32),
+ BFD_JUMP_TABLE_RELOCS (b_out),
+ BFD_JUMP_TABLE_WRITE (b_out),
+ BFD_JUMP_TABLE_LINK (b_out),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/cache.c b/bfd/cache.c
new file mode 100644
index 00000000000..b28de4bc4b9
--- /dev/null
+++ b/bfd/cache.c
@@ -0,0 +1,350 @@
+/* BFD library -- caching of file descriptors.
+ Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ File caching
+
+ The file caching mechanism is embedded within BFD and allows
+ the application to open as many BFDs as it wants without
+ regard to the underlying operating system's file descriptor
+ limit (often as low as 20 open files). The module in
+ <<cache.c>> maintains a least recently used list of
+ <<BFD_CACHE_MAX_OPEN>> files, and exports the name
+ <<bfd_cache_lookup>>, which runs around and makes sure that
+ the required BFD is open. If not, then it chooses a file to
+ close, closes it and opens the one wanted, returning its file
+ handle.
+
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+static void insert PARAMS ((bfd *));
+static void snip PARAMS ((bfd *));
+static boolean close_one PARAMS ((void));
+static boolean bfd_cache_delete PARAMS ((bfd *));
+
+/*
+INTERNAL_FUNCTION
+ BFD_CACHE_MAX_OPEN macro
+
+DESCRIPTION
+ The maximum number of files which the cache will keep open at
+ one time.
+
+.#define BFD_CACHE_MAX_OPEN 10
+
+*/
+
+/* The number of BFD files we have open. */
+
+static int open_files;
+
+/*
+INTERNAL_FUNCTION
+ bfd_last_cache
+
+SYNOPSIS
+ extern bfd *bfd_last_cache;
+
+DESCRIPTION
+ Zero, or a pointer to the topmost BFD on the chain. This is
+ used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
+ determine when it can avoid a function call.
+*/
+
+bfd *bfd_last_cache;
+
+/*
+ INTERNAL_FUNCTION
+ bfd_cache_lookup
+
+ DESCRIPTION
+ Check to see if the required BFD is the same as the last one
+ looked up. If so, then it can use the stream in the BFD with
+ impunity, since it can't have changed since the last lookup;
+ otherwise, it has to perform the complicated lookup function.
+
+ .#define bfd_cache_lookup(x) \
+ . ((x)==bfd_last_cache? \
+ . (FILE*)(bfd_last_cache->iostream): \
+ . bfd_cache_lookup_worker(x))
+
+
+ */
+
+/* Insert a BFD into the cache. */
+
+static INLINE void
+insert (abfd)
+ bfd *abfd;
+{
+ if (bfd_last_cache == NULL)
+ {
+ abfd->lru_next = abfd;
+ abfd->lru_prev = abfd;
+ }
+ else
+ {
+ abfd->lru_next = bfd_last_cache;
+ abfd->lru_prev = bfd_last_cache->lru_prev;
+ abfd->lru_prev->lru_next = abfd;
+ abfd->lru_next->lru_prev = abfd;
+ }
+ bfd_last_cache = abfd;
+}
+
+/* Remove a BFD from the cache. */
+
+static INLINE void
+snip (abfd)
+ bfd *abfd;
+{
+ abfd->lru_prev->lru_next = abfd->lru_next;
+ abfd->lru_next->lru_prev = abfd->lru_prev;
+ if (abfd == bfd_last_cache)
+ {
+ bfd_last_cache = abfd->lru_next;
+ if (abfd == bfd_last_cache)
+ bfd_last_cache = NULL;
+ }
+}
+
+/* We need to open a new file, and the cache is full. Find the least
+ recently used cacheable BFD and close it. */
+
+static boolean
+close_one ()
+{
+ register bfd *kill;
+
+ if (bfd_last_cache == NULL)
+ kill = NULL;
+ else
+ {
+ for (kill = bfd_last_cache->lru_prev;
+ ! kill->cacheable;
+ kill = kill->lru_prev)
+ {
+ if (kill == bfd_last_cache)
+ {
+ kill = NULL;
+ break;
+ }
+ }
+ }
+
+ if (kill == NULL)
+ {
+ /* There are no open cacheable BFD's. */
+ return true;
+ }
+
+ kill->where = ftell ((FILE *) kill->iostream);
+
+ return bfd_cache_delete (kill);
+}
+
+/* Close a BFD and remove it from the cache. */
+
+static boolean
+bfd_cache_delete (abfd)
+ bfd *abfd;
+{
+ boolean ret;
+
+ if (fclose ((FILE *) abfd->iostream) == 0)
+ ret = true;
+ else
+ {
+ ret = false;
+ bfd_set_error (bfd_error_system_call);
+ }
+
+ snip (abfd);
+
+ abfd->iostream = NULL;
+ --open_files;
+
+ return ret;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_cache_init
+
+SYNOPSIS
+ boolean bfd_cache_init (bfd *abfd);
+
+DESCRIPTION
+ Add a newly opened BFD to the cache.
+*/
+
+boolean
+bfd_cache_init (abfd)
+ bfd *abfd;
+{
+ BFD_ASSERT (abfd->iostream != NULL);
+ if (open_files >= BFD_CACHE_MAX_OPEN)
+ {
+ if (! close_one ())
+ return false;
+ }
+ insert (abfd);
+ ++open_files;
+ return true;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_cache_close
+
+SYNOPSIS
+ boolean bfd_cache_close (bfd *abfd);
+
+DESCRIPTION
+ Remove the BFD @var{abfd} from the cache. If the attached file is open,
+ then close it too.
+
+RETURNS
+ <<false>> is returned if closing the file fails, <<true>> is
+ returned if all is well.
+*/
+
+boolean
+bfd_cache_close (abfd)
+ bfd *abfd;
+{
+ if (abfd->iostream == NULL
+ || (abfd->flags & BFD_IN_MEMORY) != 0)
+ return true;
+
+ return bfd_cache_delete (abfd);
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_open_file
+
+SYNOPSIS
+ FILE* bfd_open_file(bfd *abfd);
+
+DESCRIPTION
+ Call the OS to open a file for @var{abfd}. Return the <<FILE *>>
+ (possibly <<NULL>>) that results from this operation. Set up the
+ BFD so that future accesses know the file is open. If the <<FILE *>>
+ returned is <<NULL>>, then it won't have been put in the
+ cache, so it won't have to be removed from it.
+*/
+
+FILE *
+bfd_open_file (abfd)
+ bfd *abfd;
+{
+ abfd->cacheable = true; /* Allow it to be closed later. */
+
+ if (open_files >= BFD_CACHE_MAX_OPEN)
+ {
+ if (! close_one ())
+ return NULL;
+ }
+
+ switch (abfd->direction)
+ {
+ case read_direction:
+ case no_direction:
+ abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
+ break;
+ case both_direction:
+ case write_direction:
+ if (abfd->opened_once == true)
+ {
+ abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
+ if (abfd->iostream == NULL)
+ abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
+ }
+ else
+ {
+ /* Create the file. Unlink it first, for the convenience of
+ operating systems which worry about overwriting running
+ binaries. */
+ unlink (abfd->filename);
+ abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WB);
+ abfd->opened_once = true;
+ }
+ break;
+ }
+
+ if (abfd->iostream != NULL)
+ {
+ if (! bfd_cache_init (abfd))
+ return NULL;
+ }
+
+ return (FILE *) abfd->iostream;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_cache_lookup_worker
+
+SYNOPSIS
+ FILE *bfd_cache_lookup_worker(bfd *abfd);
+
+DESCRIPTION
+ Called when the macro <<bfd_cache_lookup>> fails to find a
+ quick answer. Find a file descriptor for @var{abfd}. If
+ necessary, it open it. If there are already more than
+ <<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
+ avoid running out of file descriptors.
+*/
+
+FILE *
+bfd_cache_lookup_worker (abfd)
+ bfd *abfd;
+{
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ abort ();
+
+ if (abfd->my_archive)
+ abfd = abfd->my_archive;
+
+ if (abfd->iostream != NULL)
+ {
+ /* Move the file to the start of the cache. */
+ if (abfd != bfd_last_cache)
+ {
+ snip (abfd);
+ insert (abfd);
+ }
+ }
+ else
+ {
+ if (bfd_open_file (abfd) == NULL)
+ return NULL;
+ if (fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
+ return NULL;
+ }
+
+ return (FILE *) abfd->iostream;
+}
diff --git a/bfd/cf-i386lynx.c b/bfd/cf-i386lynx.c
new file mode 100644
index 00000000000..2a14bde8f12
--- /dev/null
+++ b/bfd/cf-i386lynx.c
@@ -0,0 +1,31 @@
+/* BFD back-end for Intel 386 COFF LynxOS files.
+ Copyright 1993, 1994 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#define TARGET_SYM i386lynx_coff_vec
+#define TARGET_NAME "coff-i386-lynx"
+
+#define LYNXOS
+
+#define COFF_LONG_FILENAMES
+
+#include "coff-i386.c"
diff --git a/bfd/cf-m68klynx.c b/bfd/cf-m68klynx.c
new file mode 100644
index 00000000000..7674f1b248b
--- /dev/null
+++ b/bfd/cf-m68klynx.c
@@ -0,0 +1,28 @@
+/* BFD back-end for Motorola M68K COFF LynxOS files.
+ Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM m68klynx_coff_vec
+#define TARGET_NAME "coff-m68k-lynx"
+#define LYNXOS
+#define COFF_LONG_FILENAMES
+#define STATIC_RELOCS
+#define COFF_COMMON_ADDEND
+
+#include "coff-m68k.c"
diff --git a/bfd/cf-sparclynx.c b/bfd/cf-sparclynx.c
new file mode 100644
index 00000000000..774a099fefb
--- /dev/null
+++ b/bfd/cf-sparclynx.c
@@ -0,0 +1,28 @@
+/* BFD back-end for Sparc COFF LynxOS files.
+ Copyright 1993 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM sparclynx_coff_vec
+#define TARGET_NAME "coff-sparc-lynx"
+
+#define LYNXOS
+
+#define COFF_LONG_FILENAMES
+
+#include "coff-sparc.c"
diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c
new file mode 100644
index 00000000000..11c9bbd4945
--- /dev/null
+++ b/bfd/cisco-core.c
@@ -0,0 +1,327 @@
+/* BFD back-end for CISCO crash dumps.
+
+Copyright 1994 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+/* core_file_failing_signal returns a host signal (this probably should
+ be fixed). */
+#include <signal.h>
+
+/* for MSVC builds */
+#ifndef SIGTRAP
+# define SIGTRAP 5
+#endif
+#ifndef SIGEMT
+# define SIGEMT 6
+#endif
+#ifndef SIGBUS
+# define SIGBUS 10
+#endif
+
+#define CRASH_INFO (0xffc)
+#define CRASH_MAGIC 0xdead1234
+
+typedef enum {
+ CRASH_REASON_NOTCRASHED = 0,
+ CRASH_REASON_EXCEPTION = 1,
+ CRASH_REASON_CORRUPT = 2,
+ } crashreason;
+
+struct crashinfo_external
+{
+ char magic[4]; /* Magic number */
+ char version[4]; /* Version number */
+ char reason[4]; /* Crash reason */
+ char cpu_vector[4]; /* CPU vector for exceptions */
+ char registers[4]; /* Pointer to saved registers */
+ char rambase[4]; /* Base of RAM (not in V1 crash info) */
+};
+
+struct cisco_core_struct
+{
+ int sig;
+};
+
+static const bfd_target *
+cisco_core_file_p (abfd)
+ bfd *abfd;
+{
+ char buf[4];
+ unsigned int crashinfo_offset;
+ struct crashinfo_external crashinfo;
+ int nread;
+ unsigned int rambase;
+ sec_ptr asect;
+ struct stat statbuf;
+
+ if (bfd_seek (abfd, CRASH_INFO, SEEK_SET) != 0)
+ return NULL;
+
+ nread = bfd_read (buf, 1, 4, abfd);
+ if (nread != 4)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ crashinfo_offset = bfd_get_32 (abfd, buf);
+
+ if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
+ return NULL;
+
+ nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
+ if (nread != sizeof (crashinfo))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (bfd_stat (abfd, &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+
+ if (bfd_get_32 (abfd, crashinfo.magic) != CRASH_MAGIC)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ switch (bfd_get_32 (abfd, crashinfo.version))
+ {
+ case 0:
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ case 1:
+ rambase = 0;
+ break;
+ default:
+ case 2:
+ rambase = bfd_get_32 (abfd, crashinfo.rambase);
+ break;
+ }
+
+ /* OK, we believe you. You're a core file. */
+
+ abfd->tdata.cisco_core_data =
+ ((struct cisco_core_struct *)
+ bfd_zmalloc (sizeof (struct cisco_core_struct)));
+ if (abfd->tdata.cisco_core_data == NULL)
+ return NULL;
+
+ switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
+ {
+ case CRASH_REASON_NOTCRASHED:
+ /* Crash file probably came from write core. */
+ abfd->tdata.cisco_core_data->sig = 0;
+ break;
+ case CRASH_REASON_CORRUPT:
+ /* The crash context area was corrupt -- proceed with caution.
+ We have no way of passing this information back to the caller. */
+ abfd->tdata.cisco_core_data->sig = 0;
+ break;
+ case CRASH_REASON_EXCEPTION:
+ /* Crash occured due to CPU exception. */
+
+ /* This is 68k-specific; for MIPS we'll need to interpret
+ cpu_vector differently based on the target configuration
+ (since CISCO core files don't seem to have the processor
+ encoded in them). */
+
+ switch (bfd_get_32 (abfd, crashinfo.cpu_vector))
+ {
+ /* bus error */
+ case 2 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
+ /* address error */
+ case 3 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
+ /* illegal instruction */
+ case 4 : abfd->tdata.cisco_core_data->sig = SIGILL; break;
+ /* zero divide */
+ case 5 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* chk instruction */
+ case 6 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* trapv instruction */
+ case 7 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* privilege violation */
+ case 8 : abfd->tdata.cisco_core_data->sig = SIGSEGV; break;
+ /* trace trap */
+ case 9 : abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
+ /* line 1010 emulator */
+ case 10: abfd->tdata.cisco_core_data->sig = SIGILL; break;
+ /* line 1111 emulator */
+ case 11: abfd->tdata.cisco_core_data->sig = SIGILL; break;
+
+ /* Coprocessor protocol violation. Using a standard MMU or FPU
+ this cannot be triggered by software. Call it a SIGBUS. */
+ case 13: abfd->tdata.cisco_core_data->sig = SIGBUS; break;
+
+ /* interrupt */
+ case 31: abfd->tdata.cisco_core_data->sig = SIGINT; break;
+ /* breakpoint */
+ case 33: abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
+
+ /* floating point err */
+ case 48: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* floating point err */
+ case 49: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* zero divide */
+ case 50: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* underflow */
+ case 51: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* operand error */
+ case 52: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* overflow */
+ case 53: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ /* NAN */
+ case 54: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
+ default:
+#ifndef SIGEMT
+#define SIGEMT SIGTRAP
+#endif
+ /* "software generated"*/
+ abfd->tdata.cisco_core_data->sig = SIGEMT;
+ }
+ break;
+ default:
+ /* Unknown crash reason. */
+ abfd->tdata.cisco_core_data->sig = 0;
+ break;
+ }
+
+ abfd->sections = NULL;
+ abfd->section_count = 0;
+
+ asect = (asection *) bfd_zmalloc (sizeof (asection));
+ if (asect == NULL)
+ goto error_return;
+ asect->name = ".reg";
+ asect->flags = SEC_HAS_CONTENTS;
+ /* This can be bigger than the real size. Set it to the size of the whole
+ core file. */
+ asect->_raw_size = statbuf.st_size;
+ asect->vma = 0;
+ asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
+ asect->next = abfd->sections;
+ abfd->sections = asect;
+ ++abfd->section_count;
+
+ /* There is only one section containing data from the target system's RAM.
+ We call it .data. */
+ asect = (asection *) bfd_zmalloc (sizeof (asection));
+ if (asect == NULL)
+ goto error_return;
+ asect->name = ".data";
+ asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+ /* The size of memory is the size of the core file itself. */
+ asect->_raw_size = statbuf.st_size;
+ asect->vma = rambase;
+ asect->filepos = 0;
+ asect->next = abfd->sections;
+ abfd->sections = asect;
+ ++abfd->section_count;
+
+ return abfd->xvec;
+
+ error_return:
+ {
+ sec_ptr nextsect;
+ for (asect = abfd->sections; asect != NULL;)
+ {
+ nextsect = asect->next;
+ free (asect);
+ asect = nextsect;
+ }
+ free (abfd->tdata.cisco_core_data);
+ return NULL;
+ }
+}
+
+char *
+cisco_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return NULL;
+}
+
+int
+cisco_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return abfd->tdata.cisco_core_data->sig;
+}
+
+boolean
+cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd;
+ bfd *exec_bfd;
+{
+ return true;
+}
+
+const bfd_target cisco_core_vec =
+ {
+ "trad-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ cisco_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (cisco),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c
new file mode 100644
index 00000000000..bbf23eed981
--- /dev/null
+++ b/bfd/coff-a29k.c
@@ -0,0 +1,640 @@
+/* BFD back-end for AMD 29000 COFF binaries.
+ Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Contributed by David Wood at New York University 7/8/91.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define A29K 1
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/a29k.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+static long get_symbol_value PARAMS ((asymbol *));
+static bfd_reloc_status_type a29k_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean coff_a29k_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+static boolean coff_a29k_adjust_symndx
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
+ struct internal_reloc *, boolean *));
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
+
+#define INSERT_HWORD(WORD,HWORD) \
+ (((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff))
+#define EXTRACT_HWORD(WORD) \
+ ((((WORD) & 0x00ff0000) >> 8) | ((WORD)& 0xff))
+#define SIGN_EXTEND_HWORD(HWORD) \
+ ((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
+
+/* Provided the symbol, returns the value reffed */
+static long
+get_symbol_value (symbol)
+ asymbol *symbol;
+{
+ long relocation = 0;
+
+ if (bfd_is_com_section (symbol->section))
+ {
+ relocation = 0;
+ }
+ else
+ {
+ relocation = symbol->value +
+ symbol->section->output_section->vma +
+ symbol->section->output_offset;
+ }
+
+ return(relocation);
+}
+
+/* this function is in charge of performing all the 29k relocations */
+
+static bfd_reloc_status_type
+a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* the consth relocation comes in two parts, we have to remember
+ the state between calls, in these variables */
+ static boolean part1_consth_active = false;
+ static unsigned long part1_consth_value;
+
+ unsigned long insn;
+ unsigned long sym_value;
+ unsigned long unsigned_value;
+ unsigned short r_type;
+ long signed_value;
+
+ unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
+ bfd_byte *hit_data =addr + (bfd_byte *)(data);
+
+ r_type = reloc_entry->howto->type;
+
+ if (output_bfd) {
+ /* Partial linking - do nothing */
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+
+ }
+
+ if (symbol_in != NULL
+ && bfd_is_und_section (symbol_in->section))
+ {
+ /* Keep the state machine happy in case we're called again */
+ if (r_type == R_IHIHALF)
+ {
+ part1_consth_active = true;
+ part1_consth_value = 0;
+ }
+ return(bfd_reloc_undefined);
+ }
+
+ if ((part1_consth_active) && (r_type != R_IHCONST))
+ {
+ part1_consth_active = false;
+ *error_message = (char *) _("Missing IHCONST");
+ return(bfd_reloc_dangerous);
+ }
+
+
+ sym_value = get_symbol_value(symbol_in);
+
+ switch (r_type)
+ {
+ case R_IREL:
+ insn = bfd_get_32(abfd, hit_data);
+ /* Take the value in the field and sign extend it */
+ signed_value = EXTRACT_HWORD(insn);
+ signed_value = SIGN_EXTEND_HWORD(signed_value);
+ signed_value <<= 2;
+
+ /* See the note on the R_IREL reloc in coff_a29k_relocate_section. */
+ if (signed_value == - (long) reloc_entry->address)
+ signed_value = 0;
+
+ signed_value += sym_value + reloc_entry->addend;
+ if ((signed_value & ~0x3ffff) == 0)
+ { /* Absolute jmp/call */
+ insn |= (1<<24); /* Make it absolute */
+ /* FIXME: Should we change r_type to R_IABS */
+ }
+ else
+ {
+ /* Relative jmp/call, so subtract from the value the
+ address of the place we're coming from */
+ signed_value -= (reloc_entry->address
+ + input_section->output_section->vma
+ + input_section->output_offset);
+ if (signed_value>0x1ffff || signed_value<-0x20000)
+ return(bfd_reloc_overflow);
+ }
+ signed_value >>= 2;
+ insn = INSERT_HWORD(insn, signed_value);
+ bfd_put_32(abfd, insn ,hit_data);
+ break;
+ case R_ILOHALF:
+ insn = bfd_get_32(abfd, hit_data);
+ unsigned_value = EXTRACT_HWORD(insn);
+ unsigned_value += sym_value + reloc_entry->addend;
+ insn = INSERT_HWORD(insn, unsigned_value);
+ bfd_put_32(abfd, insn, hit_data);
+ break;
+ case R_IHIHALF:
+ insn = bfd_get_32(abfd, hit_data);
+ /* consth, part 1
+ Just get the symbol value that is referenced */
+ part1_consth_active = true;
+ part1_consth_value = sym_value + reloc_entry->addend;
+ /* Don't modify insn until R_IHCONST */
+ break;
+ case R_IHCONST:
+ insn = bfd_get_32(abfd, hit_data);
+ /* consth, part 2
+ Now relocate the reference */
+ if (part1_consth_active == false) {
+ *error_message = (char *) _("Missing IHIHALF");
+ return(bfd_reloc_dangerous);
+ }
+ /* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
+ unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
+ unsigned_value += reloc_entry->addend; /* r_symndx */
+ unsigned_value += part1_consth_value;
+ unsigned_value = unsigned_value >> 16;
+ insn = INSERT_HWORD(insn, unsigned_value);
+ part1_consth_active = false;
+ bfd_put_32(abfd, insn, hit_data);
+ break;
+ case R_BYTE:
+ insn = bfd_get_8(abfd, hit_data);
+ unsigned_value = insn + sym_value + reloc_entry->addend;
+ if (unsigned_value & 0xffffff00)
+ return(bfd_reloc_overflow);
+ bfd_put_8(abfd, unsigned_value, hit_data);
+ break;
+ case R_HWORD:
+ insn = bfd_get_16(abfd, hit_data);
+ unsigned_value = insn + sym_value + reloc_entry->addend;
+ if (unsigned_value & 0xffff0000)
+ return(bfd_reloc_overflow);
+ bfd_put_16(abfd, insn, hit_data);
+ break;
+ case R_WORD:
+ insn = bfd_get_32(abfd, hit_data);
+ insn += sym_value + reloc_entry->addend;
+ bfd_put_32(abfd, insn, hit_data);
+ break;
+ default:
+ *error_message = _("Unrecognized reloc");
+ return (bfd_reloc_dangerous);
+ }
+
+
+ return(bfd_reloc_ok);
+}
+
+/* type rightshift
+ size
+ bitsize
+ pc-relative
+ bitpos
+ absolute
+ complain_on_overflow
+ special_function
+ relocation name
+ partial_inplace
+ src_mask
+*/
+
+/*FIXME: I'm not real sure about this table */
+static reloc_howto_type howto_table[] =
+{
+ {R_ABS, 0, 3, 32, false, 0, complain_overflow_bitfield,a29k_reloc,"ABS", true, 0xffffffff,0xffffffff, false},
+ {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10},
+ {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20},
+ {21}, {22}, {23},
+ {R_IREL, 0, 3, 32, true, 0, complain_overflow_signed,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false},
+ {R_IABS, 0, 3, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false},
+ {R_ILOHALF, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false},
+ {R_IHIHALF, 0, 3, 16, true, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false},
+ {R_IHCONST, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false},
+ {R_BYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false},
+ {R_HWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false},
+ {R_WORD, 0, 2, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false},
+};
+
+#define BADMAG(x) A29KBADMAG(x)
+
+#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void
+reloc_processing (relent,reloc, symbols, abfd, section)
+ arelent *relent;
+ struct internal_reloc *reloc;
+ asymbol **symbols;
+ bfd *abfd;
+ asection *section;
+{
+ static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
+
+ relent->address = reloc->r_vaddr;
+ relent->howto = howto_table + reloc->r_type;
+ if (reloc->r_type == R_IHCONST)
+ {
+ /* The address of an R_IHCONST should always be the address of
+ the immediately preceding R_IHIHALF. relocs generated by gas
+ are correct, but relocs generated by High C are different (I
+ can't figure out what the address means for High C). We can
+ handle both gas and High C by ignoring the address here, and
+ simply reusing the address saved for R_IHIHALF. */
+ if (ihihalf_vaddr == (bfd_vma) -1)
+ abort ();
+ relent->address = ihihalf_vaddr;
+ ihihalf_vaddr = (bfd_vma) -1;
+ relent->addend = reloc->r_symndx;
+ relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+ else
+ {
+ asymbol *ptr;
+ relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx];
+
+ ptr = *(relent->sym_ptr_ptr);
+
+ if (ptr
+ && bfd_asymbol_bfd(ptr) == abfd
+
+ && ((ptr->flags & BSF_OLD_COMMON)== 0))
+ {
+ relent->addend = 0;
+ }
+ else
+ {
+ relent->addend = 0;
+ }
+ relent->address-= section->vma;
+ if (reloc->r_type == R_IHIHALF)
+ ihihalf_vaddr = relent->address;
+ else if (ihihalf_vaddr != (bfd_vma) -1)
+ abort ();
+ }
+}
+
+/* The reloc processing routine for the optimized COFF linker. */
+
+static boolean
+coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, syms, sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+ boolean hihalf;
+ bfd_vma hihalf_val;
+
+ /* If we are performing a relocateable link, we don't need to do a
+ thing. The caller will take care of adjusting the reloc
+ addresses and symbol indices. */
+ if (info->relocateable)
+ return true;
+
+ hihalf = false;
+ hihalf_val = 0;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ bfd_byte *loc;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ asection *sec;
+ bfd_vma val;
+ boolean overflow;
+ unsigned long insn;
+ long signed_value;
+ unsigned long unsigned_value;
+ bfd_reloc_status_type rstat;
+
+ symndx = rel->r_symndx;
+ loc = contents + rel->r_vaddr - input_section->vma;
+
+ if (symndx == -1 || rel->r_type == R_IHCONST)
+ h = NULL;
+ else
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+
+ sym = NULL;
+ sec = NULL;
+ val = 0;
+
+ /* An R_IHCONST reloc does not have a symbol. Instead, the
+ symbol index is an addend. R_IHCONST is always used in
+ conjunction with R_IHHALF. */
+ if (rel->r_type != R_IHCONST)
+ {
+ if (h == NULL)
+ {
+ if (symndx == -1)
+ sec = bfd_abs_section_ptr;
+ else
+ {
+ sym = syms + symndx;
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma);
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ if (hihalf)
+ {
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info, _("missing IHCONST reloc"), input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ hihalf = false;
+ }
+ }
+
+ overflow = false;
+
+ switch (rel->r_type)
+ {
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+
+ case R_IREL:
+ insn = bfd_get_32 (input_bfd, loc);
+
+ /* Extract the addend. */
+ signed_value = EXTRACT_HWORD (insn);
+ signed_value = SIGN_EXTEND_HWORD (signed_value);
+ signed_value <<= 2;
+
+ /* Unfortunately, there are two different versions of COFF
+ a29k. In the original AMD version, the value stored in
+ the field for the R_IREL reloc is a simple addend. In
+ the GNU version, the value is the negative of the address
+ of the reloc within section. We try to cope here by
+ assuming the AMD version, unless the addend is exactly
+ the negative of the address; in the latter case we assume
+ the GNU version. This means that something like
+ .text
+ nop
+ jmp i-4
+ will fail, because the addend of -4 will happen to equal
+ the negative of the address within the section. The
+ compiler will never generate code like this.
+
+ At some point in the future we may want to take out this
+ check. */
+
+ if (signed_value == - (long) (rel->r_vaddr - input_section->vma))
+ signed_value = 0;
+
+ /* Determine the destination of the jump. */
+ signed_value += val;
+
+ if ((signed_value & ~0x3ffff) == 0)
+ {
+ /* We can use an absolute jump. */
+ insn |= (1 << 24);
+ }
+ else
+ {
+ /* Make the destination PC relative. */
+ signed_value -= (input_section->output_section->vma
+ + input_section->output_offset
+ + (rel->r_vaddr - input_section->vma));
+ if (signed_value > 0x1ffff || signed_value < - 0x20000)
+ {
+ overflow = true;
+ signed_value = 0;
+ }
+ }
+
+ /* Put the adjusted value back into the instruction. */
+ signed_value >>= 2;
+ insn = INSERT_HWORD (insn, signed_value);
+
+ bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
+
+ break;
+
+ case R_ILOHALF:
+ insn = bfd_get_32 (input_bfd, loc);
+ unsigned_value = EXTRACT_HWORD (insn);
+ unsigned_value += val;
+ insn = INSERT_HWORD (insn, unsigned_value);
+ bfd_put_32 (input_bfd, insn, loc);
+ break;
+
+ case R_IHIHALF:
+ /* Save the value for the R_IHCONST reloc. */
+ hihalf = true;
+ hihalf_val = val;
+ break;
+
+ case R_IHCONST:
+ if (! hihalf)
+ {
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info, _("missing IHIHALF reloc"), input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ hihalf_val = 0;
+ }
+
+ insn = bfd_get_32 (input_bfd, loc);
+ unsigned_value = rel->r_symndx + hihalf_val;
+ unsigned_value >>= 16;
+ insn = INSERT_HWORD (insn, unsigned_value);
+ bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
+
+ hihalf = false;
+
+ break;
+
+ case R_BYTE:
+ case R_HWORD:
+ case R_WORD:
+ rstat = _bfd_relocate_contents (howto_table + rel->r_type,
+ input_bfd, val, loc);
+ if (rstat == bfd_reloc_overflow)
+ overflow = true;
+ else if (rstat != bfd_reloc_ok)
+ abort ();
+ break;
+ }
+
+ if (overflow)
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else if (sym == NULL)
+ name = "*unknown*";
+ else if (sym->_n._n_n._n_zeroes == 0
+ && sym->_n._n_n._n_offset != 0)
+ name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
+ else
+ {
+ strncpy (buf, sym->_n._n_name, SYMNMLEN);
+ buf[SYMNMLEN] = '\0';
+ name = buf;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
+ input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+#define coff_relocate_section coff_a29k_relocate_section
+
+/* We don't want to change the symndx of a R_IHCONST reloc, since it
+ is actually an addend, not a symbol index at all. */
+
+/*ARGSUSED*/
+static boolean
+coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
+ bfd *obfd;
+ struct bfd_link_info *info;
+ bfd *ibfd;
+ asection *sec;
+ struct internal_reloc *irel;
+ boolean *adjustedp;
+{
+ if (irel->r_type == R_IHCONST)
+ *adjustedp = true;
+ else
+ *adjustedp = false;
+ return true;
+}
+
+#define coff_adjust_symndx coff_a29k_adjust_symndx
+
+#include "coffcode.h"
+
+const bfd_target a29kcoff_big_vec =
+{
+ "coff-a29k-big", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */
+ | SEC_LOAD | SEC_RELOC
+ | SEC_READONLY ),
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16,
+ /* hdrs */
+ 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_dummy_target,
+ coff_object_p,
+ bfd_generic_archive_p,
+ _bfd_dummy_target
+ },
+ {
+ bfd_false,
+ coff_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+ {
+ bfd_false,
+ coff_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE
+ };
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
new file mode 100644
index 00000000000..d841663edd5
--- /dev/null
+++ b/bfd/coff-alpha.c
@@ -0,0 +1,2402 @@
+/* BFD back-end for ALPHA Extended-Coff files.
+ Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
+ Ian Lance Taylor <ian@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/ecoff.h"
+#include "coff/alpha.h"
+#include "aout/ar.h"
+#include "libcoff.h"
+#include "libecoff.h"
+
+/* Prototypes for static functions. */
+
+static const bfd_target *alpha_ecoff_object_p PARAMS ((bfd *));
+static boolean alpha_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
+static PTR alpha_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
+static void alpha_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
+ struct internal_reloc *));
+static void alpha_ecoff_swap_reloc_out PARAMS ((bfd *,
+ const struct internal_reloc *,
+ PTR));
+static void alpha_adjust_reloc_in PARAMS ((bfd *,
+ const struct internal_reloc *,
+ arelent *));
+static void alpha_adjust_reloc_out PARAMS ((bfd *, const arelent *,
+ struct internal_reloc *));
+static reloc_howto_type *alpha_bfd_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static bfd_byte *alpha_ecoff_get_relocated_section_contents
+ PARAMS ((bfd *abfd, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *data, boolean relocateable, asymbol **symbols));
+static bfd_vma alpha_convert_external_reloc
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, struct external_reloc *,
+ struct ecoff_link_hash_entry *));
+static boolean alpha_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
+ bfd *, asection *,
+ bfd_byte *, PTR));
+static boolean alpha_adjust_headers
+ PARAMS ((bfd *, struct internal_filehdr *, struct internal_aouthdr *));
+static PTR alpha_ecoff_read_ar_hdr PARAMS ((bfd *));
+static bfd *alpha_ecoff_get_elt_at_filepos PARAMS ((bfd *, file_ptr));
+static bfd *alpha_ecoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
+static bfd *alpha_ecoff_get_elt_at_index PARAMS ((bfd *, symindex));
+
+/* ECOFF has COFF sections, but the debugging information is stored in
+ a completely different format. ECOFF targets use some of the
+ swapping routines from coffswap.h, and some of the generic COFF
+ routines in coffgen.c, but, unlike the real COFF targets, do not
+ use coffcode.h itself.
+
+ Get the generic COFF swapping routines, except for the reloc,
+ symbol, and lineno ones. Give them ecoff names. Define some
+ accessor macros for the large sizes used for Alpha ECOFF. */
+
+#define GET_FILEHDR_SYMPTR bfd_h_get_64
+#define PUT_FILEHDR_SYMPTR bfd_h_put_64
+#define GET_AOUTHDR_TSIZE bfd_h_get_64
+#define PUT_AOUTHDR_TSIZE bfd_h_put_64
+#define GET_AOUTHDR_DSIZE bfd_h_get_64
+#define PUT_AOUTHDR_DSIZE bfd_h_put_64
+#define GET_AOUTHDR_BSIZE bfd_h_get_64
+#define PUT_AOUTHDR_BSIZE bfd_h_put_64
+#define GET_AOUTHDR_ENTRY bfd_h_get_64
+#define PUT_AOUTHDR_ENTRY bfd_h_put_64
+#define GET_AOUTHDR_TEXT_START bfd_h_get_64
+#define PUT_AOUTHDR_TEXT_START bfd_h_put_64
+#define GET_AOUTHDR_DATA_START bfd_h_get_64
+#define PUT_AOUTHDR_DATA_START bfd_h_put_64
+#define GET_SCNHDR_PADDR bfd_h_get_64
+#define PUT_SCNHDR_PADDR bfd_h_put_64
+#define GET_SCNHDR_VADDR bfd_h_get_64
+#define PUT_SCNHDR_VADDR bfd_h_put_64
+#define GET_SCNHDR_SIZE bfd_h_get_64
+#define PUT_SCNHDR_SIZE bfd_h_put_64
+#define GET_SCNHDR_SCNPTR bfd_h_get_64
+#define PUT_SCNHDR_SCNPTR bfd_h_put_64
+#define GET_SCNHDR_RELPTR bfd_h_get_64
+#define PUT_SCNHDR_RELPTR bfd_h_put_64
+#define GET_SCNHDR_LNNOPTR bfd_h_get_64
+#define PUT_SCNHDR_LNNOPTR bfd_h_put_64
+
+#define ALPHAECOFF
+
+#define NO_COFF_RELOCS
+#define NO_COFF_SYMBOLS
+#define NO_COFF_LINENOS
+#define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
+#define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
+#define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
+#define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
+#define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
+#define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
+#include "coffswap.h"
+
+/* Get the ECOFF swapping routines. */
+#define ECOFF_64
+#include "ecoffswap.h"
+
+/* How to process the various reloc types. */
+
+static bfd_reloc_status_type
+reloc_nil PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc;
+ asymbol *sym;
+ PTR data;
+ asection *sec;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return bfd_reloc_ok;
+}
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+static reloc_howto_type 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 */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ reloc_nil, /* special_function */
+ "IGNORE", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* 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, /* src_mask */
+ 0xffffffff, /* dst_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 */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_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, /* src_mask */
+ 0xffffffff, /* dst_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, /* src_mask */
+ 0xffff, /* dst_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 */
+ reloc_nil, /* special_function */
+ "LITUSE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_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 */
+ reloc_nil, /* special_function */
+ "GPDISP", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_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. */
+ 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 */
+ true, /* partial_inplace */
+ 0x1fffff, /* src_mask */
+ 0x1fffff, /* dst_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 */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ 0, /* special_function */
+ "HINT", /* name */
+ true, /* partial_inplace */
+ 0x3fff, /* src_mask */
+ 0x3fff, /* dst_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, /* src_mask */
+ 0xffff, /* dst_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, /* src_mask */
+ 0xffffffff, /* dst_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 */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ MINUS_ONE, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+/* Recognize an Alpha ECOFF file. */
+
+static const bfd_target *
+alpha_ecoff_object_p (abfd)
+ bfd *abfd;
+{
+ static const bfd_target *ret;
+
+ ret = coff_object_p (abfd);
+
+ if (ret != NULL)
+ {
+ asection *sec;
+
+ /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
+ .pdata section is the number of entries it contains. Each
+ entry takes up 8 bytes. The number of entries is required
+ since the section is aligned to a 16 byte boundary. When we
+ link .pdata sections together, we do not want to include the
+ alignment bytes. We handle this on input by faking the size
+ of the .pdata section to remove the unwanted alignment bytes.
+ On output we will set the lnnoptr field and force the
+ alignment. */
+ sec = bfd_get_section_by_name (abfd, _PDATA);
+ if (sec != (asection *) NULL)
+ {
+ bfd_size_type size;
+
+ size = sec->line_filepos * 8;
+ BFD_ASSERT (size == bfd_section_size (abfd, sec)
+ || size + 8 == bfd_section_size (abfd, sec));
+ if (! bfd_set_section_size (abfd, sec, size))
+ return NULL;
+ }
+ }
+
+ return ret;
+}
+
+/* See whether the magic number matches. */
+
+static boolean
+alpha_ecoff_bad_format_hook (abfd, filehdr)
+ bfd *abfd;
+ PTR filehdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+ if (ALPHA_ECOFF_BADMAG (*internal_f))
+ return false;
+
+ return true;
+}
+
+/* This is a hook called by coff_real_object_p to create any backend
+ specific information. */
+
+static PTR
+alpha_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
+ bfd *abfd;
+ PTR filehdr;
+ PTR aouthdr;
+{
+ PTR ecoff;
+
+ ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
+
+ if (ecoff != NULL)
+ {
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+ /* Set additional BFD flags according to the object type from the
+ machine specific file header flags. */
+ switch (internal_f->f_flags & F_ALPHA_OBJECT_TYPE_MASK)
+ {
+ case F_ALPHA_SHARABLE:
+ abfd->flags |= DYNAMIC;
+ break;
+ case F_ALPHA_CALL_SHARED:
+ /* Always executable if using shared libraries as the run time
+ loader might resolve undefined references. */
+ abfd->flags |= (DYNAMIC | EXEC_P);
+ break;
+ }
+ }
+ return ecoff;
+}
+
+/* Reloc handling. */
+
+/* Swap a reloc in. */
+
+static void
+alpha_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
+ bfd *abfd;
+ PTR ext_ptr;
+ struct internal_reloc *intern;
+{
+ const RELOC *ext = (RELOC *) ext_ptr;
+
+ intern->r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext->r_vaddr);
+ intern->r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_symndx);
+
+ BFD_ASSERT (bfd_header_little_endian (abfd));
+
+ intern->r_type = ((ext->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
+ >> RELOC_BITS0_TYPE_SH_LITTLE);
+ intern->r_extern = (ext->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
+ intern->r_offset = ((ext->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
+ >> RELOC_BITS1_OFFSET_SH_LITTLE);
+ /* Ignored the reserved bits. */
+ intern->r_size = ((ext->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
+ >> RELOC_BITS3_SIZE_SH_LITTLE);
+
+ if (intern->r_type == ALPHA_R_LITUSE
+ || intern->r_type == ALPHA_R_GPDISP)
+ {
+ /* Handle the LITUSE and GPDISP relocs specially. Its symndx
+ value is not actually a symbol index, but is instead a
+ special code. We put the code in the r_size field, and
+ clobber the symndx. */
+ if (intern->r_size != 0)
+ abort ();
+ intern->r_size = intern->r_symndx;
+ intern->r_symndx = RELOC_SECTION_NONE;
+ }
+ else if (intern->r_type == ALPHA_R_IGNORE)
+ {
+ /* The IGNORE reloc generally follows a GPDISP reloc, and is
+ against the .lita section. The section is irrelevant. */
+ if (! intern->r_extern &&
+ intern->r_symndx == RELOC_SECTION_ABS)
+ abort ();
+ if (! intern->r_extern && intern->r_symndx == RELOC_SECTION_LITA)
+ intern->r_symndx = RELOC_SECTION_ABS;
+ }
+}
+
+/* Swap a reloc out. */
+
+static void
+alpha_ecoff_swap_reloc_out (abfd, intern, dst)
+ bfd *abfd;
+ const struct internal_reloc *intern;
+ PTR dst;
+{
+ RELOC *ext = (RELOC *) dst;
+ long symndx;
+ unsigned char size;
+
+ /* Undo the hackery done in swap_reloc_in. */
+ if (intern->r_type == ALPHA_R_LITUSE
+ || intern->r_type == ALPHA_R_GPDISP)
+ {
+ symndx = intern->r_size;
+ size = 0;
+ }
+ else if (intern->r_type == ALPHA_R_IGNORE
+ && ! intern->r_extern
+ && intern->r_symndx == RELOC_SECTION_ABS)
+ {
+ symndx = RELOC_SECTION_LITA;
+ size = intern->r_size;
+ }
+ else
+ {
+ symndx = intern->r_symndx;
+ size = intern->r_size;
+ }
+
+ BFD_ASSERT (intern->r_extern
+ || (intern->r_symndx >= 0 && intern->r_symndx <= 14));
+
+ bfd_h_put_64 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
+ bfd_h_put_32 (abfd, symndx, (bfd_byte *) ext->r_symndx);
+
+ BFD_ASSERT (bfd_header_little_endian (abfd));
+
+ ext->r_bits[0] = ((intern->r_type << RELOC_BITS0_TYPE_SH_LITTLE)
+ & RELOC_BITS0_TYPE_LITTLE);
+ ext->r_bits[1] = ((intern->r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
+ | ((intern->r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
+ & RELOC_BITS1_OFFSET_LITTLE));
+ ext->r_bits[2] = 0;
+ ext->r_bits[3] = ((size << RELOC_BITS3_SIZE_SH_LITTLE)
+ & RELOC_BITS3_SIZE_LITTLE);
+}
+
+/* Finish canonicalizing a reloc. Part of this is generic to all
+ ECOFF targets, and that part is in ecoff.c. The rest is done in
+ this backend routine. It must fill in the howto field. */
+
+static void
+alpha_adjust_reloc_in (abfd, intern, rptr)
+ bfd *abfd;
+ const struct internal_reloc *intern;
+ arelent *rptr;
+{
+ if (intern->r_type > ALPHA_R_GPVALUE)
+ abort ();
+
+ switch (intern->r_type)
+ {
+ case ALPHA_R_BRADDR:
+ case ALPHA_R_SREL16:
+ case ALPHA_R_SREL32:
+ case ALPHA_R_SREL64:
+ /* This relocs appear to be fully resolved when they are against
+ internal symbols. Against external symbols, BRADDR at least
+ appears to be resolved against the next instruction. */
+ if (! intern->r_extern)
+ rptr->addend = 0;
+ else
+ rptr->addend = - (intern->r_vaddr + 4);
+ break;
+
+ case ALPHA_R_GPREL32:
+ case ALPHA_R_LITERAL:
+ /* Copy the gp value for this object file into the addend, to
+ ensure that we are not confused by the linker. */
+ if (! intern->r_extern)
+ rptr->addend += ecoff_data (abfd)->gp;
+ 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. */
+ rptr->addend = intern->r_size;
+ break;
+
+ case ALPHA_R_OP_STORE:
+ /* The STORE reloc needs the size and offset fields. We store
+ them in the addend. */
+ BFD_ASSERT (intern->r_offset <= 256 && intern->r_size <= 256);
+ rptr->addend = (intern->r_offset << 8) + intern->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. */
+ rptr->addend = intern->r_vaddr;
+ break;
+
+ case ALPHA_R_GPVALUE:
+ /* Set the addend field to the new GP value. */
+ rptr->addend = intern->r_symndx + ecoff_data (abfd)->gp;
+ 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. */
+ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ rptr->address = intern->r_vaddr;
+ rptr->addend = ecoff_data (abfd)->gp;
+ break;
+
+ default:
+ break;
+ }
+
+ rptr->howto = &alpha_howto_table[intern->r_type];
+}
+
+/* When writing out a reloc we need to pull some values back out of
+ the addend field into the reloc. This is roughly the reverse of
+ alpha_adjust_reloc_in, except that there are several changes we do
+ not need to undo. */
+
+static void
+alpha_adjust_reloc_out (abfd, rel, intern)
+ bfd *abfd;
+ const arelent *rel;
+ struct internal_reloc *intern;
+{
+ switch (intern->r_type)
+ {
+ case ALPHA_R_LITUSE:
+ case ALPHA_R_GPDISP:
+ intern->r_size = rel->addend;
+ break;
+
+ case ALPHA_R_OP_STORE:
+ intern->r_size = rel->addend & 0xff;
+ intern->r_offset = (rel->addend >> 8) & 0xff;
+ break;
+
+ case ALPHA_R_OP_PUSH:
+ case ALPHA_R_OP_PSUB:
+ case ALPHA_R_OP_PRSHIFT:
+ intern->r_vaddr = rel->addend;
+ break;
+
+ case ALPHA_R_IGNORE:
+ intern->r_vaddr = rel->address;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* The size of the stack for the relocation evaluator. */
+#define RELOC_STACKSIZE (10)
+
+/* Alpha ECOFF relocs have a built in expression evaluator as well as
+ other interdependencies. Rather than use a bunch of special
+ functions and global variables, we use a single routine to do all
+ the relocation for a section. I haven't yet worked out how the
+ assembler is going to handle this. */
+
+static bfd_byte *
+alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ bfd *input_bfd = link_order->u.indirect.section->owner;
+ asection *input_section = link_order->u.indirect.section;
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
+ arelent **reloc_vector = NULL;
+ long reloc_count;
+ bfd *output_bfd = relocateable ? abfd : (bfd *) NULL;
+ bfd_vma gp;
+ boolean gp_undefined;
+ bfd_vma stack[RELOC_STACKSIZE];
+ int tos = 0;
+
+ if (reloc_size < 0)
+ goto error_return;
+ reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ if (reloc_vector == NULL && reloc_size != 0)
+ goto error_return;
+
+ if (! bfd_get_section_contents (input_bfd, input_section, data,
+ (file_ptr) 0, input_section->_raw_size))
+ goto error_return;
+
+ /* The section size is not going to change. */
+ input_section->_cooked_size = input_section->_raw_size;
+ input_section->reloc_done = true;
+
+ reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
+ reloc_vector, symbols);
+ if (reloc_count < 0)
+ goto error_return;
+ if (reloc_count == 0)
+ goto successful_return;
+
+ /* Get the GP value for the output BFD. */
+ gp_undefined = false;
+ gp = _bfd_get_gp_value (abfd);
+ if (gp == 0)
+ {
+ if (relocateable != false)
+ {
+ asection *sec;
+ bfd_vma lo;
+
+ /* Make up a value. */
+ lo = (bfd_vma) -1;
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ {
+ if (sec->vma < lo
+ && (strcmp (sec->name, ".sbss") == 0
+ || strcmp (sec->name, ".sdata") == 0
+ || strcmp (sec->name, ".lit4") == 0
+ || strcmp (sec->name, ".lit8") == 0
+ || strcmp (sec->name, ".lita") == 0))
+ lo = sec->vma;
+ }
+ gp = lo + 0x8000;
+ _bfd_set_gp_value (abfd, gp);
+ }
+ else
+ {
+ struct bfd_link_hash_entry *h;
+
+ h = bfd_link_hash_lookup (link_info->hash, "_gp", false, false,
+ true);
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || h->type != bfd_link_hash_defined)
+ gp_undefined = true;
+ else
+ {
+ gp = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+ _bfd_set_gp_value (abfd, gp);
+ }
+ }
+ }
+
+ for (; *reloc_vector != (arelent *) NULL; reloc_vector++)
+ {
+ arelent *rel;
+ bfd_reloc_status_type r;
+ char *err;
+
+ rel = *reloc_vector;
+ r = bfd_reloc_ok;
+ switch (rel->howto->type)
+ {
+ case ALPHA_R_IGNORE:
+ rel->address += input_section->output_offset;
+ break;
+
+ case ALPHA_R_REFLONG:
+ case ALPHA_R_REFQUAD:
+ case ALPHA_R_BRADDR:
+ case ALPHA_R_HINT:
+ case ALPHA_R_SREL16:
+ case ALPHA_R_SREL32:
+ case ALPHA_R_SREL64:
+ if (relocateable
+ && ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0)
+ {
+ rel->address += input_section->output_offset;
+ break;
+ }
+ r = bfd_perform_relocation (input_bfd, rel, data, input_section,
+ output_bfd, &err);
+ break;
+
+ case ALPHA_R_GPREL32:
+ /* This relocation is used in a switch table. It is a 32
+ bit offset from the current GP value. We must adjust it
+ by the different between the original GP value and the
+ current GP value. The original GP value is stored in the
+ addend. We adjust the addend and let
+ bfd_perform_relocation finish the job. */
+ rel->addend -= gp;
+ r = bfd_perform_relocation (input_bfd, rel, data, input_section,
+ output_bfd, &err);
+ if (r == bfd_reloc_ok && gp_undefined)
+ {
+ r = bfd_reloc_dangerous;
+ err = (char *) _("GP relative relocation used when GP not defined");
+ }
+ break;
+
+ case ALPHA_R_LITERAL:
+ /* This is a reference to a literal value, generally
+ (always?) in the .lita section. This is a 16 bit GP
+ relative relocation. Sometimes the subsequent reloc is a
+ LITUSE reloc, which indicates how this reloc is used.
+ This sometimes permits rewriting the two instructions
+ referred to by the LITERAL and the LITUSE into different
+ instructions which do not refer to .lita. This can save
+ a memory reference, and permits removing a value from
+ .lita thus saving GP relative space.
+
+ We do not these optimizations. To do them we would need
+ to arrange to link the .lita section first, so that by
+ the time we got here we would know the final values to
+ use. This would not be particularly difficult, but it is
+ not currently implemented. */
+
+ {
+ unsigned long insn;
+
+ /* I believe that the LITERAL reloc will only apply to a
+ ldq or ldl instruction, so check my assumption. */
+ insn = bfd_get_32 (input_bfd, data + rel->address);
+ BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
+ || ((insn >> 26) & 0x3f) == 0x28);
+
+ rel->addend -= gp;
+ r = bfd_perform_relocation (input_bfd, rel, data, input_section,
+ output_bfd, &err);
+ if (r == bfd_reloc_ok && gp_undefined)
+ {
+ r = bfd_reloc_dangerous;
+ err =
+ (char *) _("GP relative relocation used when GP not defined");
+ }
+ }
+ break;
+
+ case ALPHA_R_LITUSE:
+ /* See ALPHA_R_LITERAL above for the uses of this reloc. It
+ does not cause anything to happen, itself. */
+ rel->address += input_section->output_offset;
+ break;
+
+ case ALPHA_R_GPDISP:
+ /* This marks the ldah of an ldah/lda pair which loads the
+ gp register with the difference of the gp value and the
+ current location. The second of the pair is r_size bytes
+ ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
+ but that no longer happens in OSF/1 3.2. */
+ {
+ unsigned long insn1, insn2;
+ bfd_vma addend;
+
+ /* Get the two instructions. */
+ insn1 = bfd_get_32 (input_bfd, data + rel->address);
+ insn2 = bfd_get_32 (input_bfd, data + rel->address + rel->addend);
+
+ BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
+ BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
+
+ /* Get the existing addend. We must account for the sign
+ extension done by lda and ldah. */
+ addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
+ if (insn1 & 0x8000)
+ {
+ addend -= 0x80000000;
+ addend -= 0x80000000;
+ }
+ if (insn2 & 0x8000)
+ addend -= 0x10000;
+
+ /* The existing addend includes the different between the
+ gp of the input BFD and the address in the input BFD.
+ Subtract this out. */
+ addend -= (ecoff_data (input_bfd)->gp
+ - (input_section->vma + rel->address));
+
+ /* Now add in the final gp value, and subtract out the
+ final address. */
+ addend += (gp
+ - (input_section->output_section->vma
+ + input_section->output_offset
+ + rel->address));
+
+ /* Change the instructions, accounting for the sign
+ extension, and write them out. */
+ if (addend & 0x8000)
+ addend += 0x10000;
+ insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
+ insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
+
+ bfd_put_32 (input_bfd, (bfd_vma) insn1, data + rel->address);
+ bfd_put_32 (input_bfd, (bfd_vma) insn2,
+ data + rel->address + rel->addend);
+
+ rel->address += input_section->output_offset;
+ }
+ break;
+
+ case ALPHA_R_OP_PUSH:
+ /* Push a value on the reloc evaluation stack. */
+ {
+ asymbol *symbol;
+ bfd_vma relocation;
+
+ if (relocateable)
+ {
+ rel->address += input_section->output_offset;
+ break;
+ }
+
+ /* Figure out the relocation of this symbol. */
+ symbol = *rel->sym_ptr_ptr;
+
+ if (bfd_is_und_section (symbol->section))
+ r = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += rel->addend;
+
+ if (tos >= RELOC_STACKSIZE)
+ abort ();
+
+ stack[tos++] = relocation;
+ }
+ break;
+
+ case ALPHA_R_OP_STORE:
+ /* Store a value from the reloc stack into a bitfield. */
+ {
+ bfd_vma val;
+ int offset, size;
+
+ if (relocateable)
+ {
+ rel->address += input_section->output_offset;
+ break;
+ }
+
+ if (tos == 0)
+ abort ();
+
+ /* The offset and size for this reloc are encoded into the
+ addend field by alpha_adjust_reloc_in. */
+ offset = (rel->addend >> 8) & 0xff;
+ size = rel->addend & 0xff;
+
+ val = bfd_get_64 (abfd, data + rel->address);
+ val &=~ (((1 << size) - 1) << offset);
+ val |= (stack[--tos] & ((1 << size) - 1)) << offset;
+ bfd_put_64 (abfd, val, data + rel->address);
+ }
+ break;
+
+ case ALPHA_R_OP_PSUB:
+ /* Subtract a value from the top of the stack. */
+ {
+ asymbol *symbol;
+ bfd_vma relocation;
+
+ if (relocateable)
+ {
+ rel->address += input_section->output_offset;
+ break;
+ }
+
+ /* Figure out the relocation of this symbol. */
+ symbol = *rel->sym_ptr_ptr;
+
+ if (bfd_is_und_section (symbol->section))
+ r = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += rel->addend;
+
+ if (tos == 0)
+ abort ();
+
+ stack[tos - 1] -= relocation;
+ }
+ break;
+
+ case ALPHA_R_OP_PRSHIFT:
+ /* Shift the value on the top of the stack. */
+ {
+ asymbol *symbol;
+ bfd_vma relocation;
+
+ if (relocateable)
+ {
+ rel->address += input_section->output_offset;
+ break;
+ }
+
+ /* Figure out the relocation of this symbol. */
+ symbol = *rel->sym_ptr_ptr;
+
+ if (bfd_is_und_section (symbol->section))
+ r = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += rel->addend;
+
+ if (tos == 0)
+ abort ();
+
+ stack[tos - 1] >>= relocation;
+ }
+ break;
+
+ case ALPHA_R_GPVALUE:
+ /* I really don't know if this does the right thing. */
+ gp = rel->addend;
+ gp_undefined = false;
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (relocateable)
+ {
+ asection *os = input_section->output_section;
+
+ /* A partial link, so keep the relocs. */
+ os->orelocation[os->reloc_count] = rel;
+ os->reloc_count++;
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ case bfd_reloc_undefined:
+ if (! ((*link_info->callbacks->undefined_symbol)
+ (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
+ input_bfd, input_section, rel->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_dangerous:
+ if (! ((*link_info->callbacks->reloc_dangerous)
+ (link_info, err, input_bfd, input_section,
+ rel->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_overflow:
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
+ rel->howto->name, rel->addend, input_bfd,
+ input_section, rel->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_outofrange:
+ default:
+ abort ();
+ break;
+ }
+ }
+ }
+
+ if (tos != 0)
+ abort ();
+
+ successful_return:
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return data;
+
+ error_return:
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return NULL;
+}
+
+/* Get the howto structure for a generic reloc type. */
+
+static reloc_howto_type *
+alpha_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ int alpha_type;
+
+ switch (code)
+ {
+ case BFD_RELOC_32:
+ alpha_type = ALPHA_R_REFLONG;
+ break;
+ case BFD_RELOC_64:
+ case BFD_RELOC_CTOR:
+ alpha_type = ALPHA_R_REFQUAD;
+ break;
+ case BFD_RELOC_GPREL32:
+ alpha_type = ALPHA_R_GPREL32;
+ break;
+ case BFD_RELOC_ALPHA_LITERAL:
+ alpha_type = ALPHA_R_LITERAL;
+ break;
+ case BFD_RELOC_ALPHA_LITUSE:
+ alpha_type = ALPHA_R_LITUSE;
+ break;
+ case BFD_RELOC_ALPHA_GPDISP_HI16:
+ alpha_type = ALPHA_R_GPDISP;
+ break;
+ case BFD_RELOC_ALPHA_GPDISP_LO16:
+ alpha_type = ALPHA_R_IGNORE;
+ break;
+ case BFD_RELOC_23_PCREL_S2:
+ alpha_type = ALPHA_R_BRADDR;
+ break;
+ case BFD_RELOC_ALPHA_HINT:
+ alpha_type = ALPHA_R_HINT;
+ break;
+ case BFD_RELOC_16_PCREL:
+ alpha_type = ALPHA_R_SREL16;
+ break;
+ case BFD_RELOC_32_PCREL:
+ alpha_type = ALPHA_R_SREL32;
+ break;
+ case BFD_RELOC_64_PCREL:
+ alpha_type = ALPHA_R_SREL64;
+ break;
+#if 0
+ case ???:
+ alpha_type = ALPHA_R_OP_PUSH;
+ break;
+ case ???:
+ alpha_type = ALPHA_R_OP_STORE;
+ break;
+ case ???:
+ alpha_type = ALPHA_R_OP_PSUB;
+ break;
+ case ???:
+ alpha_type = ALPHA_R_OP_PRSHIFT;
+ break;
+ case ???:
+ alpha_type = ALPHA_R_GPVALUE;
+ break;
+#endif
+ default:
+ return (reloc_howto_type *) NULL;
+ }
+
+ return &alpha_howto_table[alpha_type];
+}
+
+/* A helper routine for alpha_relocate_section which converts an
+ external reloc when generating relocateable output. Returns the
+ relocation amount. */
+
+static bfd_vma
+alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ struct external_reloc *ext_rel;
+ struct ecoff_link_hash_entry *h;
+{
+ unsigned long r_symndx;
+ bfd_vma relocation;
+
+ BFD_ASSERT (info->relocateable);
+
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *hsec;
+ const char *name;
+
+ /* This symbol is defined in the output. Convert the reloc from
+ being against the symbol to being against the section. */
+
+ /* Clear the r_extern bit. */
+ ext_rel->r_bits[1] &=~ RELOC_BITS1_EXTERN_LITTLE;
+
+ /* Compute a new r_symndx value. */
+ hsec = h->root.u.def.section;
+ name = bfd_get_section_name (output_bfd, hsec->output_section);
+
+ r_symndx = -1;
+ switch (name[1])
+ {
+ case 'A':
+ if (strcmp (name, "*ABS*") == 0)
+ r_symndx = RELOC_SECTION_ABS;
+ break;
+ case 'b':
+ if (strcmp (name, ".bss") == 0)
+ r_symndx = RELOC_SECTION_BSS;
+ break;
+ case 'd':
+ if (strcmp (name, ".data") == 0)
+ r_symndx = RELOC_SECTION_DATA;
+ break;
+ case 'f':
+ if (strcmp (name, ".fini") == 0)
+ r_symndx = RELOC_SECTION_FINI;
+ break;
+ case 'i':
+ if (strcmp (name, ".init") == 0)
+ r_symndx = RELOC_SECTION_INIT;
+ break;
+ case 'l':
+ if (strcmp (name, ".lita") == 0)
+ r_symndx = RELOC_SECTION_LITA;
+ else if (strcmp (name, ".lit8") == 0)
+ r_symndx = RELOC_SECTION_LIT8;
+ else if (strcmp (name, ".lit4") == 0)
+ r_symndx = RELOC_SECTION_LIT4;
+ break;
+ case 'p':
+ if (strcmp (name, ".pdata") == 0)
+ r_symndx = RELOC_SECTION_PDATA;
+ break;
+ case 'r':
+ if (strcmp (name, ".rdata") == 0)
+ r_symndx = RELOC_SECTION_RDATA;
+ else if (strcmp (name, ".rconst") == 0)
+ r_symndx = RELOC_SECTION_RCONST;
+ break;
+ case 's':
+ if (strcmp (name, ".sdata") == 0)
+ r_symndx = RELOC_SECTION_SDATA;
+ else if (strcmp (name, ".sbss") == 0)
+ r_symndx = RELOC_SECTION_SBSS;
+ break;
+ case 't':
+ if (strcmp (name, ".text") == 0)
+ r_symndx = RELOC_SECTION_TEXT;
+ break;
+ case 'x':
+ if (strcmp (name, ".xdata") == 0)
+ r_symndx = RELOC_SECTION_XDATA;
+ break;
+ }
+
+ if (r_symndx == -1)
+ abort ();
+
+ /* Add the section VMA and the symbol value. */
+ relocation = (h->root.u.def.value
+ + hsec->output_section->vma
+ + hsec->output_offset);
+ }
+ else
+ {
+ /* Change the symndx value to the right one for
+ the output BFD. */
+ r_symndx = h->indx;
+ if (r_symndx == -1)
+ {
+ /* Caller must give an error. */
+ r_symndx = 0;
+ }
+ relocation = 0;
+ }
+
+ /* Write out the new r_symndx value. */
+ bfd_h_put_32 (input_bfd, (bfd_vma) r_symndx,
+ (bfd_byte *) ext_rel->r_symndx);
+
+ return relocation;
+}
+
+/* Relocate a section while linking an Alpha ECOFF file. This is
+ quite similar to get_relocated_section_contents. Perhaps they
+ could be combined somehow. */
+
+static boolean
+alpha_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, external_relocs)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ PTR external_relocs;
+{
+ asection **symndx_to_section, *lita_sec;
+ struct ecoff_link_hash_entry **sym_hashes;
+ bfd_vma gp;
+ boolean gp_undefined;
+ bfd_vma stack[RELOC_STACKSIZE];
+ int tos = 0;
+ struct external_reloc *ext_rel;
+ struct external_reloc *ext_rel_end;
+
+ /* We keep a table mapping the symndx found in an internal reloc to
+ the appropriate section. This is faster than looking up the
+ section by name each time. */
+ symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
+ if (symndx_to_section == (asection **) NULL)
+ {
+ symndx_to_section = ((asection **)
+ bfd_alloc (input_bfd,
+ (NUM_RELOC_SECTIONS
+ * sizeof (asection *))));
+ if (!symndx_to_section)
+ return false;
+
+ symndx_to_section[RELOC_SECTION_NONE] = NULL;
+ symndx_to_section[RELOC_SECTION_TEXT] =
+ bfd_get_section_by_name (input_bfd, ".text");
+ symndx_to_section[RELOC_SECTION_RDATA] =
+ bfd_get_section_by_name (input_bfd, ".rdata");
+ symndx_to_section[RELOC_SECTION_DATA] =
+ bfd_get_section_by_name (input_bfd, ".data");
+ symndx_to_section[RELOC_SECTION_SDATA] =
+ bfd_get_section_by_name (input_bfd, ".sdata");
+ symndx_to_section[RELOC_SECTION_SBSS] =
+ bfd_get_section_by_name (input_bfd, ".sbss");
+ symndx_to_section[RELOC_SECTION_BSS] =
+ bfd_get_section_by_name (input_bfd, ".bss");
+ symndx_to_section[RELOC_SECTION_INIT] =
+ bfd_get_section_by_name (input_bfd, ".init");
+ symndx_to_section[RELOC_SECTION_LIT8] =
+ bfd_get_section_by_name (input_bfd, ".lit8");
+ symndx_to_section[RELOC_SECTION_LIT4] =
+ bfd_get_section_by_name (input_bfd, ".lit4");
+ symndx_to_section[RELOC_SECTION_XDATA] =
+ bfd_get_section_by_name (input_bfd, ".xdata");
+ symndx_to_section[RELOC_SECTION_PDATA] =
+ bfd_get_section_by_name (input_bfd, ".pdata");
+ symndx_to_section[RELOC_SECTION_FINI] =
+ bfd_get_section_by_name (input_bfd, ".fini");
+ symndx_to_section[RELOC_SECTION_LITA] =
+ bfd_get_section_by_name (input_bfd, ".lita");
+ symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr;
+ symndx_to_section[RELOC_SECTION_RCONST] =
+ bfd_get_section_by_name (input_bfd, ".rconst");
+
+ ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
+ }
+
+ sym_hashes = ecoff_data (input_bfd)->sym_hashes;
+
+ /* On the Alpha, the .lita section must be addressable by the global
+ pointer. To support large programs, we need to allow multiple
+ global pointers. This works as long as each input .lita section
+ is <64KB big. This implies that when producing relocatable
+ output, the .lita section is limited to 64KB. . */
+
+ lita_sec = symndx_to_section[RELOC_SECTION_LITA];
+ gp = _bfd_get_gp_value (output_bfd);
+ if (! info->relocateable && lita_sec != NULL)
+ {
+ struct ecoff_section_tdata *lita_sec_data;
+
+ /* Make sure we have a section data structure to which we can
+ hang on to the gp value we pick for the section. */
+ lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
+ if (lita_sec_data == NULL)
+ {
+ lita_sec_data = ((struct ecoff_section_tdata *)
+ bfd_zalloc (input_bfd,
+ sizeof (struct ecoff_section_tdata)));
+ ecoff_section_data (input_bfd, lita_sec) = lita_sec_data;
+ }
+
+ if (lita_sec_data->gp != 0)
+ {
+ /* If we already assigned a gp to this section, we better
+ stick with that value. */
+ gp = lita_sec_data->gp;
+ }
+ else
+ {
+ bfd_vma lita_vma;
+ bfd_size_type lita_size;
+
+ lita_vma = lita_sec->output_offset + lita_sec->output_section->vma;
+ lita_size = lita_sec->_cooked_size;
+ if (lita_size == 0)
+ lita_size = lita_sec->_raw_size;
+
+ if (gp == 0
+ || lita_vma < gp - 0x8000
+ || lita_vma + lita_size >= gp + 0x8000)
+ {
+ /* Either gp hasn't been set at all or the current gp
+ cannot address this .lita section. In both cases we
+ reset the gp to point into the "middle" of the
+ current input .lita section. */
+ if (gp && !ecoff_data (output_bfd)->issued_multiple_gp_warning)
+ {
+ (*info->callbacks->warning) (info,
+ _("using multiple gp values"),
+ (char *) NULL, output_bfd,
+ (asection *) NULL, (bfd_vma) 0);
+ ecoff_data (output_bfd)->issued_multiple_gp_warning = true;
+ }
+ if (lita_vma < gp - 0x8000)
+ gp = lita_vma + lita_size - 0x8000;
+ else
+ gp = lita_vma + 0x8000;
+
+ }
+
+ lita_sec_data->gp = gp;
+ }
+
+ _bfd_set_gp_value (output_bfd, gp);
+ }
+
+ gp_undefined = (gp == 0);
+
+ BFD_ASSERT (bfd_header_little_endian (output_bfd));
+ BFD_ASSERT (bfd_header_little_endian (input_bfd));
+
+ ext_rel = (struct external_reloc *) external_relocs;
+ ext_rel_end = ext_rel + input_section->reloc_count;
+ for (; ext_rel < ext_rel_end; ext_rel++)
+ {
+ bfd_vma r_vaddr;
+ unsigned long r_symndx;
+ int r_type;
+ int r_extern;
+ int r_offset;
+ int r_size;
+ boolean relocatep;
+ boolean adjust_addrp;
+ boolean gp_usedp;
+ bfd_vma addend;
+
+ r_vaddr = bfd_h_get_64 (input_bfd, (bfd_byte *) ext_rel->r_vaddr);
+ r_symndx = bfd_h_get_32 (input_bfd, (bfd_byte *) ext_rel->r_symndx);
+
+ r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
+ >> RELOC_BITS0_TYPE_SH_LITTLE);
+ r_extern = (ext_rel->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
+ r_offset = ((ext_rel->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
+ >> RELOC_BITS1_OFFSET_SH_LITTLE);
+ /* Ignored the reserved bits. */
+ r_size = ((ext_rel->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
+ >> RELOC_BITS3_SIZE_SH_LITTLE);
+
+ relocatep = false;
+ adjust_addrp = true;
+ gp_usedp = false;
+ addend = 0;
+
+ switch (r_type)
+ {
+ default:
+ abort ();
+
+ case ALPHA_R_IGNORE:
+ /* This reloc appears after a GPDISP reloc. On earlier
+ versions of OSF/1, It marked the position of the second
+ instruction to be altered by the GPDISP reloc, but it is
+ not otherwise used for anything. For some reason, the
+ address of the relocation does not appear to include the
+ section VMA, unlike the other relocation types. */
+ if (info->relocateable)
+ bfd_h_put_64 (input_bfd,
+ input_section->output_offset + r_vaddr,
+ (bfd_byte *) ext_rel->r_vaddr);
+ adjust_addrp = false;
+ break;
+
+ case ALPHA_R_REFLONG:
+ case ALPHA_R_REFQUAD:
+ case ALPHA_R_HINT:
+ relocatep = true;
+ break;
+
+ case ALPHA_R_BRADDR:
+ case ALPHA_R_SREL16:
+ case ALPHA_R_SREL32:
+ case ALPHA_R_SREL64:
+ if (r_extern)
+ addend += - (r_vaddr + 4);
+ relocatep = true;
+ break;
+
+ case ALPHA_R_GPREL32:
+ /* This relocation is used in a switch table. It is a 32
+ bit offset from the current GP value. We must adjust it
+ by the different between the original GP value and the
+ current GP value. */
+ relocatep = true;
+ addend = ecoff_data (input_bfd)->gp - gp;
+ gp_usedp = true;
+ break;
+
+ case ALPHA_R_LITERAL:
+ /* This is a reference to a literal value, generally
+ (always?) in the .lita section. This is a 16 bit GP
+ relative relocation. Sometimes the subsequent reloc is a
+ LITUSE reloc, which indicates how this reloc is used.
+ This sometimes permits rewriting the two instructions
+ referred to by the LITERAL and the LITUSE into different
+ instructions which do not refer to .lita. This can save
+ a memory reference, and permits removing a value from
+ .lita thus saving GP relative space.
+
+ We do not these optimizations. To do them we would need
+ to arrange to link the .lita section first, so that by
+ the time we got here we would know the final values to
+ use. This would not be particularly difficult, but it is
+ not currently implemented. */
+
+ /* I believe that the LITERAL reloc will only apply to a ldq
+ or ldl instruction, so check my assumption. */
+ {
+ unsigned long insn;
+
+ insn = bfd_get_32 (input_bfd,
+ contents + r_vaddr - input_section->vma);
+ BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
+ || ((insn >> 26) & 0x3f) == 0x28);
+ }
+
+ relocatep = true;
+ addend = ecoff_data (input_bfd)->gp - gp;
+ gp_usedp = true;
+ break;
+
+ case ALPHA_R_LITUSE:
+ /* See ALPHA_R_LITERAL above for the uses of this reloc. It
+ does not cause anything to happen, itself. */
+ break;
+
+ case ALPHA_R_GPDISP:
+ /* This marks the ldah of an ldah/lda pair which loads the
+ gp register with the difference of the gp value and the
+ current location. The second of the pair is r_symndx
+ bytes ahead. It used to be marked with an ALPHA_R_IGNORE
+ reloc, but OSF/1 3.2 no longer does that. */
+ {
+ unsigned long insn1, insn2;
+
+ /* Get the two instructions. */
+ insn1 = bfd_get_32 (input_bfd,
+ contents + r_vaddr - input_section->vma);
+ insn2 = bfd_get_32 (input_bfd,
+ (contents
+ + r_vaddr
+ - input_section->vma
+ + r_symndx));
+
+ BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
+ BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
+
+ /* Get the existing addend. We must account for the sign
+ extension done by lda and ldah. */
+ addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
+ if (insn1 & 0x8000)
+ {
+ /* This is addend -= 0x100000000 without causing an
+ integer overflow on a 32 bit host. */
+ addend -= 0x80000000;
+ addend -= 0x80000000;
+ }
+ if (insn2 & 0x8000)
+ addend -= 0x10000;
+
+ /* The existing addend includes the difference between the
+ gp of the input BFD and the address in the input BFD.
+ We want to change this to the difference between the
+ final GP and the final address. */
+ addend += (gp
+ - ecoff_data (input_bfd)->gp
+ + input_section->vma
+ - (input_section->output_section->vma
+ + input_section->output_offset));
+
+ /* Change the instructions, accounting for the sign
+ extension, and write them out. */
+ if (addend & 0x8000)
+ addend += 0x10000;
+ insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
+ insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
+
+ bfd_put_32 (input_bfd, (bfd_vma) insn1,
+ contents + r_vaddr - input_section->vma);
+ bfd_put_32 (input_bfd, (bfd_vma) insn2,
+ contents + r_vaddr - input_section->vma + r_symndx);
+
+ gp_usedp = true;
+ }
+ break;
+
+ case ALPHA_R_OP_PUSH:
+ case ALPHA_R_OP_PSUB:
+ case ALPHA_R_OP_PRSHIFT:
+ /* Manipulate values on the reloc evaluation stack. The
+ r_vaddr field is not an address in input_section, it is
+ the current value (including any addend) of the object
+ being used. */
+ if (! r_extern)
+ {
+ asection *s;
+
+ s = symndx_to_section[r_symndx];
+ if (s == (asection *) NULL)
+ abort ();
+ addend = s->output_section->vma + s->output_offset - s->vma;
+ }
+ else
+ {
+ struct ecoff_link_hash_entry *h;
+
+ h = sym_hashes[r_symndx];
+ if (h == (struct ecoff_link_hash_entry *) NULL)
+ abort ();
+
+ if (! info->relocateable)
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ addend = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ else
+ {
+ /* Note that we pass the address as 0, since we
+ do not have a meaningful number for the
+ location within the section that is being
+ relocated. */
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, (bfd_vma) 0)))
+ return false;
+ addend = 0;
+ }
+ }
+ else
+ {
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak
+ && h->indx == -1)
+ {
+ /* This symbol is not being written out. Pass
+ the address as 0, as with undefined_symbol,
+ above. */
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, h->root.root.string, input_bfd,
+ input_section, (bfd_vma) 0)))
+ return false;
+ }
+
+ addend = alpha_convert_external_reloc (output_bfd, info,
+ input_bfd,
+ ext_rel, h);
+ }
+ }
+
+ addend += r_vaddr;
+
+ if (info->relocateable)
+ {
+ /* Adjust r_vaddr by the addend. */
+ bfd_h_put_64 (input_bfd, addend,
+ (bfd_byte *) ext_rel->r_vaddr);
+ }
+ else
+ {
+ switch (r_type)
+ {
+ case ALPHA_R_OP_PUSH:
+ if (tos >= RELOC_STACKSIZE)
+ abort ();
+ stack[tos++] = addend;
+ break;
+
+ case ALPHA_R_OP_PSUB:
+ if (tos == 0)
+ abort ();
+ stack[tos - 1] -= addend;
+ break;
+
+ case ALPHA_R_OP_PRSHIFT:
+ if (tos == 0)
+ abort ();
+ stack[tos - 1] >>= addend;
+ break;
+ }
+ }
+
+ adjust_addrp = false;
+ break;
+
+ case ALPHA_R_OP_STORE:
+ /* Store a value from the reloc stack into a bitfield. If
+ we are generating relocateable output, all we do is
+ adjust the address of the reloc. */
+ if (! info->relocateable)
+ {
+ bfd_vma mask;
+ bfd_vma val;
+
+ if (tos == 0)
+ abort ();
+
+ /* Get the relocation mask. The separate steps and the
+ casts to bfd_vma are attempts to avoid a bug in the
+ Alpha OSF 1.3 C compiler. See reloc.c for more
+ details. */
+ mask = 1;
+ mask <<= (bfd_vma) r_size;
+ mask -= 1;
+
+ /* FIXME: I don't know what kind of overflow checking,
+ if any, should be done here. */
+ val = bfd_get_64 (input_bfd,
+ contents + r_vaddr - input_section->vma);
+ val &=~ mask << (bfd_vma) r_offset;
+ val |= (stack[--tos] & mask) << (bfd_vma) r_offset;
+ bfd_put_64 (input_bfd, val,
+ contents + r_vaddr - input_section->vma);
+ }
+ break;
+
+ case ALPHA_R_GPVALUE:
+ /* I really don't know if this does the right thing. */
+ gp = ecoff_data (input_bfd)->gp + r_symndx;
+ gp_undefined = false;
+ break;
+ }
+
+ if (relocatep)
+ {
+ reloc_howto_type *howto;
+ struct ecoff_link_hash_entry *h = NULL;
+ asection *s = NULL;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ /* Perform a relocation. */
+
+ howto = &alpha_howto_table[r_type];
+
+ if (r_extern)
+ {
+ h = sym_hashes[r_symndx];
+ /* If h is NULL, that means that there is a reloc
+ against an external symbol which we thought was just
+ a debugging symbol. This should not happen. */
+ if (h == (struct ecoff_link_hash_entry *) NULL)
+ abort ();
+ }
+ else
+ {
+ if (r_symndx >= NUM_RELOC_SECTIONS)
+ s = NULL;
+ else
+ s = symndx_to_section[r_symndx];
+
+ if (s == (asection *) NULL)
+ abort ();
+ }
+
+ if (info->relocateable)
+ {
+ /* We are generating relocateable output, and must
+ convert the existing reloc. */
+ if (r_extern)
+ {
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak
+ && h->indx == -1)
+ {
+ /* This symbol is not being written out. */
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, h->root.root.string, input_bfd,
+ input_section, r_vaddr - input_section->vma)))
+ return false;
+ }
+
+ relocation = alpha_convert_external_reloc (output_bfd,
+ info,
+ input_bfd,
+ ext_rel,
+ h);
+ }
+ else
+ {
+ /* This is a relocation against a section. Adjust
+ the value by the amount the section moved. */
+ relocation = (s->output_section->vma
+ + s->output_offset
+ - s->vma);
+ }
+
+ /* If this is PC relative, the existing object file
+ appears to already have the reloc worked out. We
+ must subtract out the old value and add in the new
+ one. */
+ if (howto->pc_relative)
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma);
+
+ /* Put in any addend. */
+ relocation += addend;
+
+ /* Adjust the contents. */
+ r = _bfd_relocate_contents (howto, input_bfd, relocation,
+ (contents
+ + r_vaddr
+ - input_section->vma));
+ }
+ else
+ {
+ /* We are producing a final executable. */
+ if (r_extern)
+ {
+ /* This is a reloc against a symbol. */
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *hsec;
+
+ hsec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + hsec->output_section->vma
+ + hsec->output_offset);
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section,
+ r_vaddr - input_section->vma)))
+ return false;
+ relocation = 0;
+ }
+ }
+ else
+ {
+ /* This is a reloc against a section. */
+ relocation = (s->output_section->vma
+ + s->output_offset
+ - s->vma);
+
+ /* Adjust a PC relative relocation by removing the
+ reference to the original source section. */
+ if (howto->pc_relative)
+ relocation += input_section->vma;
+ }
+
+ r = _bfd_final_link_relocate (howto,
+ input_bfd,
+ input_section,
+ contents,
+ r_vaddr - input_section->vma,
+ relocation,
+ addend);
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (r_extern)
+ name = sym_hashes[r_symndx]->root.root.string;
+ else
+ name = bfd_section_name (input_bfd,
+ symndx_to_section[r_symndx]);
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, alpha_howto_table[r_type].name,
+ (bfd_vma) 0, input_bfd, input_section,
+ r_vaddr - input_section->vma)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ if (info->relocateable && adjust_addrp)
+ {
+ /* Change the address of the relocation. */
+ bfd_h_put_64 (input_bfd,
+ (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma
+ + r_vaddr),
+ (bfd_byte *) ext_rel->r_vaddr);
+ }
+
+ if (gp_usedp && gp_undefined)
+ {
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info, _("GP relative relocation when GP not defined"),
+ input_bfd, input_section, r_vaddr - input_section->vma)))
+ return false;
+ /* Only give the error once per link. */
+ gp = 4;
+ _bfd_set_gp_value (output_bfd, gp);
+ gp_undefined = false;
+ }
+ }
+
+ if (tos != 0)
+ abort ();
+
+ return true;
+}
+
+/* Do final adjustments to the filehdr and the aouthdr. This routine
+ sets the dynamic bits in the file header. */
+
+/*ARGSUSED*/
+static boolean
+alpha_adjust_headers (abfd, fhdr, ahdr)
+ bfd *abfd;
+ struct internal_filehdr *fhdr;
+ struct internal_aouthdr *ahdr;
+{
+ if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P))
+ fhdr->f_flags |= F_ALPHA_CALL_SHARED;
+ else if ((abfd->flags & DYNAMIC) != 0)
+ fhdr->f_flags |= F_ALPHA_SHARABLE;
+ return true;
+}
+
+/* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
+ introduced archive packing, in which the elements in an archive are
+ optionally compressed using a simple dictionary scheme. We know
+ how to read such archives, but we don't write them. */
+
+#define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
+#define alpha_ecoff_slurp_extended_name_table \
+ _bfd_ecoff_slurp_extended_name_table
+#define alpha_ecoff_construct_extended_name_table \
+ _bfd_ecoff_construct_extended_name_table
+#define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
+#define alpha_ecoff_write_armap _bfd_ecoff_write_armap
+#define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
+#define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
+
+/* A compressed file uses this instead of ARFMAG. */
+
+#define ARFZMAG "Z\012"
+
+/* Read an archive header. This is like the standard routine, but it
+ also accepts ARFZMAG. */
+
+static PTR
+alpha_ecoff_read_ar_hdr (abfd)
+ bfd *abfd;
+{
+ struct areltdata *ret;
+ struct ar_hdr *h;
+
+ ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
+ if (ret == NULL)
+ return NULL;
+
+ h = (struct ar_hdr *) ret->arch_header;
+ if (strncmp (h->ar_fmag, ARFZMAG, 2) == 0)
+ {
+ bfd_byte ab[8];
+
+ /* This is a compressed file. We must set the size correctly.
+ The size is the eight bytes after the dummy file header. */
+ if (bfd_seek (abfd, FILHSZ, SEEK_CUR) != 0
+ || bfd_read (ab, 1, 8, abfd) != 8
+ || bfd_seek (abfd, - (FILHSZ + 8), SEEK_CUR) != 0)
+ return NULL;
+
+ ret->parsed_size = bfd_h_get_64 (abfd, ab);
+ }
+
+ return (PTR) ret;
+}
+
+/* Get an archive element at a specified file position. This is where
+ we uncompress the archive element if necessary. */
+
+static bfd *
+alpha_ecoff_get_elt_at_filepos (archive, filepos)
+ bfd *archive;
+ file_ptr filepos;
+{
+ bfd *nbfd = NULL;
+ struct areltdata *tdata;
+ struct ar_hdr *hdr;
+ bfd_byte ab[8];
+ bfd_size_type size;
+ bfd_byte *buf, *p;
+ struct bfd_in_memory *bim;
+
+ nbfd = _bfd_get_elt_at_filepos (archive, filepos);
+ if (nbfd == NULL)
+ goto error_return;
+
+ if ((nbfd->flags & BFD_IN_MEMORY) != 0)
+ {
+ /* We have already expanded this BFD. */
+ return nbfd;
+ }
+
+ tdata = (struct areltdata *) nbfd->arelt_data;
+ hdr = (struct ar_hdr *) tdata->arch_header;
+ if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0)
+ return nbfd;
+
+ /* We must uncompress this element. We do this by copying it into a
+ memory buffer, and making bfd_read and bfd_seek use that buffer.
+ This can use a lot of memory, but it's simpler than getting a
+ temporary file, making that work with the file descriptor caching
+ code, and making sure that it is deleted at all appropriate
+ times. It can be changed if it ever becomes important. */
+
+ /* The compressed file starts with a dummy ECOFF file header. */
+ if (bfd_seek (nbfd, FILHSZ, SEEK_SET) != 0)
+ goto error_return;
+
+ /* The next eight bytes are the real file size. */
+ if (bfd_read (ab, 1, 8, nbfd) != 8)
+ goto error_return;
+ size = bfd_h_get_64 (nbfd, ab);
+
+ if (size == 0)
+ buf = NULL;
+ else
+ {
+ bfd_size_type left;
+ bfd_byte dict[4096];
+ unsigned int h;
+ bfd_byte b;
+
+ buf = (bfd_byte *) bfd_alloc (nbfd, size);
+ if (buf == NULL)
+ goto error_return;
+ p = buf;
+
+ left = size;
+
+ /* I don't know what the next eight bytes are for. */
+ if (bfd_read (ab, 1, 8, nbfd) != 8)
+ goto error_return;
+
+ /* This is the uncompression algorithm. It's a simple
+ dictionary based scheme in which each character is predicted
+ by a hash of the previous three characters. A control byte
+ indicates whether the character is predicted or whether it
+ appears in the input stream; each control byte manages the
+ next eight bytes in the output stream. */
+ memset (dict, 0, sizeof dict);
+ h = 0;
+ while (bfd_read (&b, 1, 1, nbfd) == 1)
+ {
+ unsigned int i;
+
+ for (i = 0; i < 8; i++, b >>= 1)
+ {
+ bfd_byte n;
+
+ if ((b & 1) == 0)
+ n = dict[h];
+ else
+ {
+ if (! bfd_read (&n, 1, 1, nbfd))
+ goto error_return;
+ dict[h] = n;
+ }
+
+ *p++ = n;
+
+ --left;
+ if (left == 0)
+ break;
+
+ h <<= 4;
+ h ^= n;
+ h &= sizeof dict - 1;
+ }
+
+ if (left == 0)
+ break;
+ }
+ }
+
+ /* Now the uncompressed file contents are in buf. */
+ bim = ((struct bfd_in_memory *)
+ bfd_alloc (nbfd, sizeof (struct bfd_in_memory)));
+ if (bim == NULL)
+ goto error_return;
+ bim->size = size;
+ bim->buffer = buf;
+
+ nbfd->mtime_set = true;
+ nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
+
+ nbfd->flags |= BFD_IN_MEMORY;
+ nbfd->iostream = (PTR) bim;
+ BFD_ASSERT (! nbfd->cacheable);
+
+ return nbfd;
+
+ error_return:
+ if (nbfd != NULL)
+ bfd_close (nbfd);
+ return NULL;
+}
+
+/* Open the next archived file. */
+
+static bfd *
+alpha_ecoff_openr_next_archived_file (archive, last_file)
+ bfd *archive;
+ bfd *last_file;
+{
+ file_ptr filestart;
+
+ if (last_file == NULL)
+ filestart = bfd_ardata (archive)->first_file_filepos;
+ else
+ {
+ struct areltdata *t;
+ struct ar_hdr *h;
+ bfd_size_type size;
+
+ /* We can't use arelt_size here, because that uses parsed_size,
+ which is the uncompressed size. We need the compressed size. */
+ t = (struct areltdata *) last_file->arelt_data;
+ h = (struct ar_hdr *) t->arch_header;
+ size = strtol (h->ar_size, (char **) NULL, 10);
+
+ /* Pad to an even boundary...
+ Note that last_file->origin can be odd in the case of
+ BSD-4.4-style element with a long odd size. */
+ filestart = last_file->origin + size;
+ filestart += filestart % 2;
+ }
+
+ return alpha_ecoff_get_elt_at_filepos (archive, filestart);
+}
+
+/* Open the archive file given an index into the armap. */
+
+static bfd *
+alpha_ecoff_get_elt_at_index (abfd, index)
+ bfd *abfd;
+ symindex index;
+{
+ carsym *entry;
+
+ entry = bfd_ardata (abfd)->symdefs + index;
+ return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset);
+}
+
+/* This is the ECOFF backend structure. The backend field of the
+ target vector points to this. */
+
+static const struct ecoff_backend_data alpha_ecoff_backend_data =
+{
+ /* COFF backend structure. */
+ {
+ (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
+ (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
+ (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
+ (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
+ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
+ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
+ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
+ alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
+ alpha_ecoff_swap_scnhdr_out,
+ FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true, false, 4,
+ alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
+ alpha_ecoff_swap_scnhdr_in, NULL,
+ alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
+ alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
+ _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ },
+ /* Supported architecture. */
+ bfd_arch_alpha,
+ /* Initial portion of armap string. */
+ "________64",
+ /* The page boundary used to align sections in a demand-paged
+ executable file. E.g., 0x1000. */
+ 0x2000,
+ /* True if the .rdata section is part of the text segment, as on the
+ Alpha. False if .rdata is part of the data segment, as on the
+ MIPS. */
+ true,
+ /* Bitsize of constructor entries. */
+ 64,
+ /* Reloc to use for constructor entries. */
+ &alpha_howto_table[ALPHA_R_REFQUAD],
+ {
+ /* Symbol table magic number. */
+ magicSym2,
+ /* Alignment of debugging information. E.g., 4. */
+ 8,
+ /* Sizes of external symbolic information. */
+ sizeof (struct hdr_ext),
+ sizeof (struct dnr_ext),
+ sizeof (struct pdr_ext),
+ sizeof (struct sym_ext),
+ sizeof (struct opt_ext),
+ sizeof (struct fdr_ext),
+ sizeof (struct rfd_ext),
+ sizeof (struct ext_ext),
+ /* Functions to swap in external symbolic data. */
+ ecoff_swap_hdr_in,
+ ecoff_swap_dnr_in,
+ ecoff_swap_pdr_in,
+ ecoff_swap_sym_in,
+ ecoff_swap_opt_in,
+ ecoff_swap_fdr_in,
+ ecoff_swap_rfd_in,
+ ecoff_swap_ext_in,
+ _bfd_ecoff_swap_tir_in,
+ _bfd_ecoff_swap_rndx_in,
+ /* Functions to swap out external symbolic data. */
+ ecoff_swap_hdr_out,
+ ecoff_swap_dnr_out,
+ ecoff_swap_pdr_out,
+ ecoff_swap_sym_out,
+ ecoff_swap_opt_out,
+ ecoff_swap_fdr_out,
+ ecoff_swap_rfd_out,
+ ecoff_swap_ext_out,
+ _bfd_ecoff_swap_tir_out,
+ _bfd_ecoff_swap_rndx_out,
+ /* Function to read in symbolic data. */
+ _bfd_ecoff_slurp_symbolic_info
+ },
+ /* External reloc size. */
+ RELSZ,
+ /* Reloc swapping functions. */
+ alpha_ecoff_swap_reloc_in,
+ alpha_ecoff_swap_reloc_out,
+ /* Backend reloc tweaking. */
+ alpha_adjust_reloc_in,
+ alpha_adjust_reloc_out,
+ /* Relocate section contents while linking. */
+ alpha_relocate_section,
+ /* Do final adjustments to filehdr and aouthdr. */
+ alpha_adjust_headers,
+ /* Read an element from an archive at a given file position. */
+ alpha_ecoff_get_elt_at_filepos
+};
+
+/* Looking up a reloc type is Alpha specific. */
+#define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
+
+/* So is getting relocated section contents. */
+#define _bfd_ecoff_bfd_get_relocated_section_contents \
+ alpha_ecoff_get_relocated_section_contents
+
+/* Handling file windows is generic. */
+#define _bfd_ecoff_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+/* Relaxing sections is generic. */
+#define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
+#define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
+
+const bfd_target ecoffalpha_little_vec =
+{
+ "ecoff-littlealpha", /* name */
+ bfd_target_ecoff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, alpha_ecoff_object_p, /* bfd_check_format */
+ _bfd_ecoff_archive_p, _bfd_dummy_target},
+ {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+ BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+ BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+ BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+ BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) &alpha_ecoff_backend_data
+};
diff --git a/bfd/coff-apollo.c b/bfd/coff-apollo.c
new file mode 100644
index 00000000000..253ec8944b8
--- /dev/null
+++ b/bfd/coff-apollo.c
@@ -0,0 +1,161 @@
+/* BFD back-end for Apollo 68000 COFF binaries.
+ Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ By Troy Rollo (troy@cbme.unsw.edu.au)
+ Based on m68k standard COFF version Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/apollo.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+#ifdef ONLY_DECLARE_RELOCS
+extern reloc_howto_type apollocoff_howto_table[];
+#else
+reloc_howto_type apollocoff_howto_table[] =
+{
+ HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
+ HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
+ HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
+ HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
+ HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "-32", true, 0xffffffff,0xffffffff, false),
+};
+#endif /* not ONLY_DECLARE_RELOCS */
+
+#ifndef BADMAG
+#define BADMAG(x) M68KBADMAG(x)
+#endif
+#define APOLLO_M68 1 /* Customize coffcode.h */
+
+/* Turn a howto into a reloc number */
+
+#ifdef ONLY_DECLARE_RELOCS
+extern void apollo_rtype2howto PARAMS ((arelent *internal, int relocentry));
+extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
+#else
+void
+apollo_rtype2howto(internal, relocentry)
+ arelent *internal;
+ int relocentry;
+{
+ switch (relocentry)
+ {
+ case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
+ case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
+ case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
+ case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
+ case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
+ case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
+ case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
+ }
+}
+
+int
+apollo_howto2rtype (internal)
+ reloc_howto_type *internal;
+{
+ if (internal->pc_relative)
+ {
+ switch (internal->bitsize)
+ {
+ case 32: return R_PCRLONG;
+ case 16: return R_PCRWORD;
+ case 8: return R_PCRBYTE;
+ }
+ }
+ else
+ {
+ switch (internal->bitsize)
+ {
+ case 32: return R_RELLONG;
+ case 16: return R_RELWORD;
+ case 8: return R_RELBYTE;
+ }
+ }
+ return R_RELLONG;
+}
+#endif /* not ONLY_DECLARE_RELOCS */
+
+#define RTYPE2HOWTO(internal, relocentry) \
+ apollo_rtype2howto(internal, (relocentry)->r_type)
+
+#define SELECT_RELOC(external, internal) \
+ external.r_type = apollo_howto2rtype(internal);
+
+#include "coffcode.h"
+
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ apollocoff_vec =
+#endif
+{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
+ "apollo-m68k", /* name */
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+#ifdef NAMES_HAVE_UNDERSCORE
+ '_',
+#else
+ 0, /* leading underscore */
+#endif
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE
+ };
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
new file mode 100644
index 00000000000..d478ce5f98c
--- /dev/null
+++ b/bfd/coff-arm.c
@@ -0,0 +1,2557 @@
+/* BFD back-end for ARM COFF files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "coff/arm.h"
+
+#include "coff/internal.h"
+
+#ifdef COFF_WITH_PE
+#include "coff/pe.h"
+#endif
+
+#include "libcoff.h"
+
+/* Macros for manipulation the bits in the flags field of the coff data
+ structure. */
+#define APCS_26_FLAG( abfd ) (coff_data (abfd)->flags & F_APCS_26)
+#define APCS_FLOAT_FLAG( abfd ) (coff_data (abfd)->flags & F_APCS_FLOAT)
+#define PIC_FLAG( abfd ) (coff_data (abfd)->flags & F_PIC)
+#define APCS_SET( abfd ) (coff_data (abfd)->flags & F_APCS_SET)
+#define SET_APCS_FLAGS( abfd, flgs) (coff_data (abfd)->flags = \
+ (coff_data (abfd)->flags & ~ (F_APCS_26 | F_APCS_FLOAT | F_PIC)) \
+ | (flgs | F_APCS_SET))
+#define INTERWORK_FLAG( abfd ) (coff_data (abfd)->flags & F_INTERWORK)
+#define INTERWORK_SET( abfd ) (coff_data (abfd)->flags & F_INTERWORK_SET)
+#define SET_INTERWORK_FLAG( abfd, flg ) (coff_data (abfd)->flags = \
+ (coff_data (abfd)->flags & ~ F_INTERWORK) \
+ | (flg | F_INTERWORK_SET))
+
+typedef enum {bunknown, b9, b12, b23} thumb_pcrel_branchtype;
+/* some typedefs for holding instructions */
+typedef unsigned long int insn32;
+typedef unsigned short int insn16;
+
+
+ /* Forward declarations for stupid compilers. */
+static boolean coff_arm_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+static bfd_reloc_status_type aoutarm_fix_pcrel_26_done
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type aoutarm_fix_pcrel_26
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type coff_thumb_pcrel_23
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type coff_thumb_pcrel_12
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type coff_thumb_pcrel_9
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type coff_arm_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean coff_arm_adjust_symndx
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *,
+ asection *, struct internal_reloc *, boolean *));
+static reloc_howto_type * coff_arm_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
+static bfd_reloc_status_type coff_thumb_pcrel_common
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **,
+ thumb_pcrel_branchtype));
+static CONST struct reloc_howto_struct * coff_arm_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static struct bfd_link_hash_table * coff_arm_link_hash_table_create
+ PARAMS ((bfd *));
+static insn32 insert_thumb_branch
+ PARAMS ((insn32, int));
+static struct coff_link_hash_entry * find_thumb_glue
+ PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
+static struct coff_link_hash_entry * find_arm_glue
+ PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
+static void record_arm_to_thumb_glue
+ PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
+static void record_thumb_to_arm_glue
+ PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
+static boolean coff_arm_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean coff_arm_print_private_bfd_data
+ PARAMS ((bfd *, PTR));
+static boolean _bfd_coff_arm_set_private_flags
+ PARAMS ((bfd *, flagword));
+static boolean coff_arm_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean coff_arm_is_local_label_name
+ PARAMS ((bfd *, const char *));
+static boolean coff_arm_link_output_has_begun
+ PARAMS ((bfd *, struct coff_final_link_info *));
+static boolean coff_arm_final_link_postscript
+ PARAMS ((bfd *, struct coff_final_link_info *));
+
+/* The linker script knows the section names for placement.
+ The entry_names are used to do simple name mangling on the stubs.
+ Given a function name, and its type, the stub can be found. The
+ name can be changed. The only requirement is the %s be present.
+ */
+
+#define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t"
+#define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb"
+
+#define ARM2THUMB_GLUE_SECTION_NAME ".glue_7"
+#define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm"
+
+/* Used by the assembler. */
+static bfd_reloc_status_type
+coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ symvalue diff;
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ diff = reloc_entry->addend;
+
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
+
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, x, addr);
+ }
+ break;
+
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_32 (abfd, x, addr);
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ /* Now let bfd_perform_relocation finish everything up. */
+ return bfd_reloc_continue;
+}
+
+/* If USER_LABEL_PREFIX is defined as "_" (see coff_arm_is_local_label_name()
+ in this file), then TARGET_UNDERSCORE should be defined, otherwise it
+ should not. */
+#ifndef TARGET_UNDERSCORE
+#define TARGET_UNDERSCORE '_'
+#endif
+
+#ifndef PCRELOFFSET
+#define PCRELOFFSET true
+#endif
+
+/* These most certainly belong somewhere else. Just had to get rid of
+ the manifest constants in the code. */
+
+#define ARM_8 0
+#define ARM_16 1
+#define ARM_32 2
+#define ARM_26 3
+#define ARM_DISP8 4
+#define ARM_DISP16 5
+#define ARM_DISP32 6
+#define ARM_26D 7
+/* 8 is unused */
+#define ARM_NEG16 9
+#define ARM_NEG32 10
+#define ARM_RVA32 11
+#define ARM_THUMB9 12
+#define ARM_THUMB12 13
+#define ARM_THUMB23 14
+
+static reloc_howto_type aoutarm_std_reloc_howto[] =
+{
+ /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
+ HOWTO(ARM_8, /* type */
+ 0, /* rightshift */
+ 0, /* size */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_arm_reloc, /* special_function */
+ "ARM_8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ PCRELOFFSET /* pcrel_offset */),
+ HOWTO(ARM_16,
+ 0,
+ 1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ PCRELOFFSET),
+ HOWTO(ARM_32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
+ HOWTO(ARM_26,
+ 2,
+ 2,
+ 24,
+ true,
+ 0,
+ complain_overflow_signed,
+ aoutarm_fix_pcrel_26 ,
+ "ARM_26",
+ false,
+ 0x00ffffff,
+ 0x00ffffff,
+ PCRELOFFSET),
+ HOWTO(ARM_DISP8,
+ 0,
+ 0,
+ 8,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_arm_reloc,
+ "ARM_DISP8",
+ true,
+ 0x000000ff,
+ 0x000000ff,
+ true),
+ HOWTO( ARM_DISP16,
+ 0,
+ 1,
+ 16,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_arm_reloc,
+ "ARM_DISP16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ true),
+ HOWTO( ARM_DISP32,
+ 0,
+ 2,
+ 32,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_arm_reloc,
+ "ARM_DISP32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ true),
+ HOWTO( ARM_26D,
+ 2,
+ 2,
+ 24,
+ false,
+ 0,
+ complain_overflow_dont,
+ aoutarm_fix_pcrel_26_done,
+ "ARM_26D",
+ true,
+ 0x00ffffff,
+ 0x0,
+ false),
+ /* 8 is unused */
+ {-1},
+ HOWTO( ARM_NEG16,
+ 0,
+ -1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_NEG16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ false),
+ HOWTO( ARM_NEG32,
+ 0,
+ -2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_NEG32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ false),
+ HOWTO( ARM_RVA32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_RVA32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
+ HOWTO( ARM_THUMB9,
+ 1,
+ 1,
+ 8,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_9 ,
+ "ARM_THUMB9",
+ false,
+ 0x000000ff,
+ 0x000000ff,
+ PCRELOFFSET),
+ HOWTO( ARM_THUMB12,
+ 1,
+ 1,
+ 11,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_12 ,
+ "ARM_THUMB12",
+ false,
+ 0x000007ff,
+ 0x000007ff,
+ PCRELOFFSET),
+ HOWTO( ARM_THUMB23,
+ 1,
+ 2,
+ 22,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_23 ,
+ "ARM_THUMB23",
+ false,
+ 0x07ff07ff,
+ 0x07ff07ff,
+ PCRELOFFSET),
+};
+
+#ifdef COFF_WITH_PE
+/* Return true if this relocation should
+ appear in the output .reloc section. */
+
+static boolean
+in_reloc_p (abfd, howto)
+ bfd * abfd;
+ reloc_howto_type * howto;
+{
+ return !howto->pc_relative && howto->type != ARM_RVA32;
+}
+#endif
+
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ (cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
+
+#define coff_rtype_to_howto coff_arm_rtype_to_howto
+
+static reloc_howto_type *
+coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+ reloc_howto_type *howto;
+
+ howto = aoutarm_std_reloc_howto + rel->r_type;
+
+ if (rel->r_type == ARM_RVA32)
+ {
+ *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
+ }
+
+ return howto;
+
+}
+/* Used by the assembler. */
+
+static bfd_reloc_status_type
+aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* This is dead simple at present. */
+ return bfd_reloc_ok;
+}
+
+/* Used by the assembler. */
+
+static bfd_reloc_status_type
+aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_size_type addr = reloc_entry->address;
+ long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+
+ /* If this is an undefined symbol, return error */
+ if (symbol->section == &bfd_und_section
+ && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
+
+ /* If the sections are different, and we are doing a partial relocation,
+ just ignore it for now. */
+ if (symbol->section->name != input_section->name
+ && output_bfd != (bfd *)NULL)
+ return bfd_reloc_continue;
+
+ relocation = (target & 0x00ffffff) << 2;
+ relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
+ relocation += symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+ relocation -= input_section->output_section->vma;
+ relocation -= input_section->output_offset;
+ relocation -= addr;
+
+ if (relocation & 3)
+ return bfd_reloc_overflow;
+
+ /* Check for overflow */
+ if (relocation & 0x02000000)
+ {
+ if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
+ flag = bfd_reloc_overflow;
+ }
+ else if (relocation & ~0x03ffffff)
+ flag = bfd_reloc_overflow;
+
+ target &= ~0x00ffffff;
+ target |= (relocation >> 2) & 0x00ffffff;
+ bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+
+ /* Now the ARM magic... Change the reloc type so that it is marked as done.
+ Strictly this is only necessary if we are doing a partial relocation. */
+ reloc_entry->howto = &aoutarm_std_reloc_howto[ARM_26D];
+
+ return flag;
+}
+
+static bfd_reloc_status_type
+coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message, btype)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+ thumb_pcrel_branchtype btype;
+{
+ bfd_vma relocation = 0;
+ bfd_size_type addr = reloc_entry->address;
+ long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+ bfd_vma dstmsk;
+ bfd_vma offmsk;
+ bfd_vma signbit;
+
+ /* NOTE: This routine is currently used by GAS, but not by the link
+ phase. */
+
+ switch (btype)
+ {
+ case b9:
+ dstmsk = 0x000000ff;
+ offmsk = 0x000001fe;
+ signbit = 0x00000100;
+ break;
+
+ case b12:
+ dstmsk = 0x000007ff;
+ offmsk = 0x00000ffe;
+ signbit = 0x00000800;
+ break;
+
+ case b23:
+ dstmsk = 0x07ff07ff;
+ offmsk = 0x007fffff;
+ signbit = 0x00400000;
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* If this is an undefined symbol, return error */
+ if (symbol->section == &bfd_und_section
+ && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
+
+ /* If the sections are different, and we are doing a partial relocation,
+ just ignore it for now. */
+ if (symbol->section->name != input_section->name
+ && output_bfd != (bfd *)NULL)
+ return bfd_reloc_continue;
+
+ switch (btype)
+ {
+ case b9:
+ case b12:
+ relocation = ((target & dstmsk) << 1);
+ break;
+
+ case b23:
+ if (bfd_big_endian (abfd))
+ relocation = ((target & 0x7ff) << 1) | ((target & 0x07ff0000) >> 4);
+ else
+ relocation = ((target & 0x7ff) << 12) | ((target & 0x07ff0000) >> 15);
+ break;
+
+ default:
+ abort ();
+ }
+
+ relocation = (relocation ^ signbit) - signbit; /* Sign extend */
+ relocation += symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+ relocation -= input_section->output_section->vma;
+ relocation -= input_section->output_offset;
+ relocation -= addr;
+
+ if (relocation & 1)
+ return bfd_reloc_overflow;
+
+ /* Check for overflow */
+ if (relocation & signbit)
+ {
+ if ((relocation & ~offmsk) != ~offmsk)
+ flag = bfd_reloc_overflow;
+ }
+ else if (relocation & ~offmsk)
+ flag = bfd_reloc_overflow;
+
+ target &= ~dstmsk;
+ switch (btype)
+ {
+ case b9:
+ case b12:
+ target |= (relocation >> 1);
+ break;
+
+ case b23:
+ if (bfd_big_endian (abfd))
+ target |= ((relocation & 0xfff) >> 1) | ((relocation << 4) & 0x07ff0000);
+ else
+ target |= ((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff);
+ break;
+
+ default:
+ abort ();
+ }
+
+ bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+
+ /* Now the ARM magic... Change the reloc type so that it is marked as done.
+ Strictly this is only necessary if we are doing a partial relocation. */
+ reloc_entry->howto = & aoutarm_std_reloc_howto [ARM_26D];
+
+ /* TODO: We should possibly have DONE entries for the THUMB PCREL relocations */
+ return flag;
+}
+
+static bfd_reloc_status_type
+coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message, b23);
+}
+
+static bfd_reloc_status_type
+coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message, b12);
+}
+
+static bfd_reloc_status_type
+coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message, b9);
+}
+
+
+static CONST struct reloc_howto_struct *
+coff_arm_reloc_type_lookup (abfd, code)
+ bfd * abfd;
+ bfd_reloc_code_real_type code;
+{
+#define ASTD(i,j) case i: return &aoutarm_std_reloc_howto[j]
+ if (code == BFD_RELOC_CTOR)
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ default: return (CONST struct reloc_howto_struct *) 0;
+ }
+
+ switch (code)
+ {
+ ASTD (BFD_RELOC_8, ARM_8);
+ ASTD (BFD_RELOC_16, ARM_16);
+ ASTD (BFD_RELOC_32, ARM_32);
+ ASTD (BFD_RELOC_ARM_PCREL_BRANCH, ARM_26);
+ ASTD (BFD_RELOC_8_PCREL, ARM_DISP8);
+ ASTD (BFD_RELOC_16_PCREL, ARM_DISP16);
+ ASTD (BFD_RELOC_32_PCREL, ARM_DISP32);
+ ASTD (BFD_RELOC_RVA, ARM_RVA32);
+ ASTD (BFD_RELOC_THUMB_PCREL_BRANCH9, ARM_THUMB9);
+ ASTD (BFD_RELOC_THUMB_PCREL_BRANCH12, ARM_THUMB12);
+ ASTD (BFD_RELOC_THUMB_PCREL_BRANCH23, ARM_THUMB23);
+ default: return (CONST struct reloc_howto_struct *) 0;
+ }
+}
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
+#define COFF_PAGE_SIZE 0x1000
+/* Turn a howto into a reloc nunmber */
+
+#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
+#define BADMAG(x) ARMBADMAG(x)
+#define ARM 1 /* Customize coffcode.h */
+
+/* Extend the coff_link_hash_table structure with a few ARM specific fields.
+ This allows us to store global data here without actually creating any
+ global variables, which is a no-no in the BFD world. */
+struct coff_arm_link_hash_table
+{
+ /* The original coff_link_hash_table structure. MUST be first field. */
+ struct coff_link_hash_table root;
+
+ /* The size in bytes of the section containg the Thumb-to-ARM glue. */
+ long int thumb_glue_size;
+
+ /* The size in bytes of the section containg the ARM-to-Thumb glue. */
+ long int arm_glue_size;
+
+ /* An arbitary input BFD chosen to hold the glue sections. */
+ bfd * bfd_of_glue_owner;
+
+ /* Support interworking with old, non-interworking aware ARM code. */
+ int support_old_code;
+};
+
+/* Get the ARM coff linker hash table from a link_info structure. */
+#define coff_arm_hash_table(info) \
+ ((struct coff_arm_link_hash_table *) ((info)->hash))
+
+/* Create an ARM coff linker hash table. */
+
+static struct bfd_link_hash_table *
+coff_arm_link_hash_table_create (abfd)
+ bfd * abfd;
+{
+ struct coff_arm_link_hash_table * ret;
+
+ ret = ((struct coff_arm_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct coff_arm_link_hash_table)));
+ if (ret == (struct coff_arm_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_coff_link_hash_table_init
+ (& ret->root, abfd, _bfd_coff_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->thumb_glue_size = 0;
+ ret->arm_glue_size = 0;
+ ret->bfd_of_glue_owner = NULL;
+
+ return & ret->root.root;
+}
+
+static
+arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset)
+ struct bfd_link_info *info;
+ bfd *output_bfd;
+ asection *input_section;
+ bfd_vma reloc_offset;
+{
+ bfd_vma addr = reloc_offset
+ - input_section->vma
+ + input_section->output_offset
+ + input_section->output_section->vma;
+
+ if (coff_data(output_bfd)->pe)
+ addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
+ fwrite (&addr, 1, sizeof (addr), (FILE *) info->base_file);
+
+}
+
+/* The thumb form of a long branch is a bit finicky, because the offset
+ encoding is split over two fields, each in it's own instruction. They
+ can occur in any order. So given a thumb form of long branch, and an
+ offset, insert the offset into the thumb branch and return finished
+ instruction.
+
+ It takes two thumb instructions to encode the target address. Each has
+ 11 bits to invest. The upper 11 bits are stored in one (identifed by
+ H-0.. see below), the lower 11 bits are stored in the other (identified
+ by H-1).
+
+ Combine together and shifted left by 1 (it's a half word address) and
+ there you have it.
+
+ Op: 1111 = F,
+ H-0, upper address-0 = 000
+ Op: 1111 = F,
+ H-1, lower address-0 = 800
+
+ They can be ordered either way, but the arm tools I've seen always put
+ the lower one first. It probably doesn't matter. krk@cygnus.com
+
+ XXX: Actually the order does matter. The second instruction (H-1)
+ moves the computed address into the PC, so it must be the second one
+ in the sequence. The problem, however is that whilst little endian code
+ stores the instructions in HI then LOW order, big endian code does the
+ reverse. nickc@cygnus.com */
+
+#define LOW_HI_ORDER 0xF800F000
+#define HI_LOW_ORDER 0xF000F800
+
+static insn32
+insert_thumb_branch (br_insn, rel_off)
+ insn32 br_insn;
+ int rel_off;
+{
+ unsigned int low_bits;
+ unsigned int high_bits;
+
+
+ BFD_ASSERT((rel_off & 1) != 1);
+
+ rel_off >>= 1; /* half word aligned address */
+ low_bits = rel_off & 0x000007FF; /* the bottom 11 bits */
+ high_bits = (rel_off >> 11) & 0x000007FF; /* the top 11 bits */
+
+ if ((br_insn & LOW_HI_ORDER) == LOW_HI_ORDER)
+ br_insn = LOW_HI_ORDER | (low_bits << 16) | high_bits;
+ else if ((br_insn & HI_LOW_ORDER) == HI_LOW_ORDER)
+ br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits;
+ else
+ abort(); /* error - not a valid branch instruction form */
+
+ /* FIXME: abort is probably not the right call. krk@cygnus.com */
+
+ return br_insn;
+}
+
+
+static struct coff_link_hash_entry *
+find_thumb_glue (info, name, input_bfd)
+ struct bfd_link_info * info;
+ CONST char * name;
+ bfd * input_bfd;
+{
+ char * tmp_name;
+ struct coff_link_hash_entry * myh;
+
+ tmp_name = ((char *)
+ bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1));
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name);
+
+ myh = coff_link_hash_lookup
+ (coff_hash_table (info), tmp_name, false, false, true);
+
+ if (myh == NULL)
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%s: unable to find THUMB glue '%s' for `%s'"),
+ bfd_get_filename (input_bfd), tmp_name, name);
+
+ free (tmp_name);
+
+ return myh;
+}
+
+static struct coff_link_hash_entry *
+find_arm_glue (info, name, input_bfd)
+ struct bfd_link_info * info;
+ CONST char * name;
+ bfd * input_bfd;
+{
+ char * tmp_name;
+ struct coff_link_hash_entry * myh;
+
+ tmp_name = ((char *)
+ bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name);
+
+ myh = coff_link_hash_lookup
+ (coff_hash_table (info), tmp_name, false, false, true);
+
+ if (myh == NULL)
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%s: unable to find ARM glue '%s' for `%s'"),
+ bfd_get_filename (input_bfd), tmp_name, name);
+
+ free (tmp_name);
+
+ return myh;
+}
+
+/*
+ ARM->Thumb glue:
+
+ .arm
+ __func_from_arm:
+ ldr r12, __func_addr
+ bx r12
+ __func_addr:
+ .word func @ behave as if you saw a ARM_32 reloc
+*/
+
+#define ARM2THUMB_GLUE_SIZE 12
+static const insn32 a2t1_ldr_insn = 0xe59fc000;
+static const insn32 a2t2_bx_r12_insn = 0xe12fff1c;
+static const insn32 a2t3_func_addr_insn = 0x00000001;
+
+#define A2T3_OFFSET 8
+
+/*
+ Thumb->ARM: Thumb->(non-interworking aware) ARM
+
+ .thumb .thumb
+ .align 2 .align 2
+ __func_from_thumb: __func_from_thumb:
+ bx pc push {r6, lr}
+ nop ldr r6, __func_addr
+ .arm mov lr, pc
+ __func_change_to_arm: bx r6
+ b func .arm
+ __func_back_to_thumb:
+ ldmia r13! {r6, lr}
+ bx lr
+ __func_addr:
+ .word func
+*/
+
+#define THUMB2ARM_GLUE_SIZE (globals->support_old_code ? 20 : 8)
+static const insn16 t2a1_bx_pc_insn = 0x4778;
+static const insn16 t2a2_noop_insn = 0x46c0;
+static const insn32 t2a3_b_insn = 0xea000000;
+
+#define T2A3_OFFSET 8
+
+static const insn16 t2a1_push_insn = 0xb540;
+static const insn16 t2a2_ldr_insn = 0x4e03;
+static const insn16 t2a3_mov_insn = 0x46fe;
+static const insn16 t2a4_bx_insn = 0x4730;
+static const insn32 t2a5_pop_insn = 0xe8bd4040;
+static const insn32 t2a6_bx_insn = 0xe12fff1e;
+
+/* TODO:
+ We should really create new local (static) symbols in destination
+ object for each stub we create. We should also create local
+ (static) symbols within the stubs when switching between ARM and
+ Thumb code. This will ensure that the debugger and disassembler
+ can present a better view of stubs.
+
+ We can treat stubs like literal sections, and for the THUMB9 ones
+ (short addressing range) we should be able to insert the stubs
+ between sections. i.e. the simplest approach (since relocations
+ are done on a section basis) is to dump the stubs at the end of
+ processing a section. That way we can always try and minimise the
+ offset to and from a stub. However, this does not map well onto
+ the way that the linker/BFD does its work: mapping all input
+ sections to output sections via the linker script before doing
+ all the processing.
+
+ Unfortunately it may be easier to just to disallow short range
+ Thumb->ARM stubs (i.e. no conditional inter-working branches,
+ only branch-and-link (BL) calls. This will simplify the processing
+ since we can then put all of the stubs into their own section.
+
+ TODO:
+ On a different subject, rather than complaining when a
+ branch cannot fit in the number of bits available for the
+ instruction we should generate a trampoline stub (needed to
+ address the complete 32bit address space). */
+
+/* The standard COFF backend linker does not cope with the special
+ Thumb BRANCH23 relocation. The alternative would be to split the
+ BRANCH23 into seperate HI23 and LO23 relocations. However, it is a
+ bit simpler simply providing our own relocation driver. */
+
+/* The reloc processing routine for the ARM/Thumb COFF linker. NOTE:
+ This code is a very slightly modified copy of
+ _bfd_coff_generic_relocate_section. It would be a much more
+ maintainable solution to have a MACRO that could be expanded within
+ _bfd_coff_generic_relocate_section that would only be provided for
+ ARM/Thumb builds. It is only the code marked THUMBEXTENSION that
+ is different from the original. */
+
+static boolean
+coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, syms, sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc * rel;
+ struct internal_reloc * relend;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+
+ for (; rel < relend; rel++)
+ {
+ int done = 0;
+ long symndx;
+ struct coff_link_hash_entry * h;
+ struct internal_syment * sym;
+ bfd_vma addend;
+ bfd_vma val;
+ reloc_howto_type * howto;
+ bfd_reloc_status_type rstat;
+ bfd_vma h_val;
+
+ symndx = rel->r_symndx;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ }
+
+ /* COFF treats common symbols in one of two ways. Either the
+ size of the symbol is included in the section contents, or it
+ is not. We assume that the size is not included, and force
+ the rtype_to_howto function to adjust the addend as needed. */
+
+ if (sym != NULL && sym->n_scnum != 0)
+ addend = - sym->n_value;
+ else
+ addend = 0;
+
+
+ howto = coff_rtype_to_howto (input_bfd, input_section, rel, h,
+ sym, &addend);
+ if (howto == NULL)
+ return false;
+
+ /* The relocation_section function will skip pcrel_offset relocs
+ when doing a relocateable link. However, we want to convert
+ ARM26 to ARM26D relocs if possible. We return a fake howto in
+ this case without pcrel_offset set, and adjust the addend to
+ compensate. */
+ if (rel->r_type == ARM_26
+ && h != NULL
+ && info->relocateable
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->root.u.def.section->output_section == input_section->output_section)
+ {
+ static reloc_howto_type fake_arm26_reloc =
+ HOWTO (ARM_26,
+ 2,
+ 2,
+ 24,
+ true,
+ 0,
+ complain_overflow_signed,
+ aoutarm_fix_pcrel_26 ,
+ "ARM_26",
+ false,
+ 0x00ffffff,
+ 0x00ffffff,
+ false);
+
+ addend -= rel->r_vaddr - input_section->vma;
+ howto = &fake_arm26_reloc;
+ }
+
+ /* If we are doing a relocateable link, then we can just ignore
+ a PC relative reloc that is pcrel_offset. It will already
+ have the correct value. If this is not a relocateable link,
+ then we should ignore the symbol value. */
+ if (howto->pc_relative && howto->pcrel_offset)
+ {
+ if (info->relocateable)
+ continue;
+ if (sym != NULL && sym->n_scnum != 0)
+ addend += sym->n_value;
+ }
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ asection *sec;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
+ else
+ {
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma);
+ }
+ }
+ else
+ {
+#if 1 /* THUMBEXTENSION */
+ /* We don't output the stubs if we are generating a
+ relocatable output file, since we may as well leave the
+ stub generation to the final linker pass. If we fail to
+ verify that the name is defined, we'll try to build stubs
+ for an undefined name... */
+ if (! info->relocateable
+ && ( h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ asection * h_sec = h->root.u.def.section;
+ const char * name = h->root.root.string;
+
+ /* h locates the symbol referenced in the reloc. */
+ h_val = (h->root.u.def.value
+ + h_sec->output_section->vma
+ + h_sec->output_offset);
+
+ if (howto->type == ARM_26)
+ {
+ if ( h->class == C_THUMBSTATFUNC
+ || h->class == C_THUMBEXTFUNC)
+ {
+ /* Arm code calling a Thumb function */
+ unsigned long int tmp;
+ long int my_offset;
+ asection * s;
+ long int ret_offset;
+ struct coff_link_hash_entry * myh;
+ struct coff_arm_link_hash_table * globals;
+
+ myh = find_arm_glue (info, name, input_bfd);
+ if (myh == NULL)
+ return false;
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ my_offset = myh->root.u.def.value;
+
+ s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
+ ARM2THUMB_GLUE_SECTION_NAME);
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->contents != NULL);
+ BFD_ASSERT (s->output_section != NULL);
+
+ if ((my_offset & 0x01) == 0x01)
+ {
+ if (h_sec->owner != NULL
+ && INTERWORK_SET (h_sec->owner)
+ && ! INTERWORK_FLAG (h_sec->owner))
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%s(%s): warning: interworking not enabled."),
+ bfd_get_filename (h_sec->owner), name);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_(" first occurrence: %s: arm call to thumb"),
+ bfd_get_filename (input_bfd));
+ }
+
+ --my_offset;
+ myh->root.u.def.value = my_offset;
+
+ bfd_put_32 (output_bfd, a2t1_ldr_insn,
+ s->contents + my_offset);
+
+ bfd_put_32 (output_bfd, a2t2_bx_r12_insn,
+ s->contents + my_offset + 4);
+
+ /* It's a thumb address. Add the low order bit. */
+ bfd_put_32 (output_bfd, h_val | a2t3_func_addr_insn,
+ s->contents + my_offset + 8);
+
+ if (info->base_file)
+ arm_emit_base_file_entry (info, output_bfd, s, A2T3_OFFSET);
+
+ }
+
+ BFD_ASSERT (my_offset <= globals->arm_glue_size);
+
+ tmp = bfd_get_32 (input_bfd, contents + rel->r_vaddr
+ - input_section->vma);
+
+ tmp = tmp & 0xFF000000;
+
+ /* Somehow these are both 4 too far, so subtract 8. */
+ ret_offset =
+ s->output_offset
+ + my_offset
+ + s->output_section->vma
+ - (input_section->output_offset
+ + input_section->output_section->vma
+ + rel->r_vaddr)
+ - 8;
+
+ tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF);
+
+ bfd_put_32 (output_bfd, tmp, contents + rel->r_vaddr
+ - input_section->vma);
+
+ done = 1;
+ }
+ }
+
+ /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12 */
+ else if (howto->type == ARM_THUMB23)
+ {
+ if ( h->class == C_EXT
+ || h->class == C_STAT
+ || h->class == C_LABEL)
+ {
+ /* Thumb code calling an ARM function */
+ asection * s = 0;
+ long int my_offset;
+ unsigned long int tmp;
+ long int ret_offset;
+ struct coff_link_hash_entry * myh;
+ struct coff_arm_link_hash_table * globals;
+
+ myh = find_thumb_glue (info, name, input_bfd);
+ if (myh == NULL)
+ return false;
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ my_offset = myh->root.u.def.value;
+
+ s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
+ THUMB2ARM_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->contents != NULL);
+ BFD_ASSERT (s->output_section != NULL);
+
+ if ((my_offset & 0x01) == 0x01)
+ {
+ if (h_sec->owner != NULL
+ && INTERWORK_SET (h_sec->owner)
+ && ! INTERWORK_FLAG (h_sec->owner)
+ && ! globals->support_old_code)
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%s(%s): warning: interworking not enabled."),
+ bfd_get_filename (h_sec->owner), name);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_(" first occurrence: %s: thumb call to arm"),
+ bfd_get_filename (input_bfd));
+ _bfd_error_handler
+ (_(" consider relinking with --support-old-code enabled"));
+ }
+
+ -- my_offset;
+ myh->root.u.def.value = my_offset;
+
+ if (globals->support_old_code)
+ {
+ bfd_put_16 (output_bfd, t2a1_push_insn,
+ s->contents + my_offset);
+
+ bfd_put_16 (output_bfd, t2a2_ldr_insn,
+ s->contents + my_offset + 2);
+
+ bfd_put_16 (output_bfd, t2a3_mov_insn,
+ s->contents + my_offset + 4);
+
+ bfd_put_16 (output_bfd, t2a4_bx_insn,
+ s->contents + my_offset + 6);
+
+ bfd_put_32 (output_bfd, t2a5_pop_insn,
+ s->contents + my_offset + 8);
+
+ bfd_put_32 (output_bfd, t2a6_bx_insn,
+ s->contents + my_offset + 12);
+
+ /* Store the address of the function in the last word of the stub. */
+ bfd_put_32 (output_bfd, h_val,
+ s->contents + my_offset + 16);
+ }
+ else
+ {
+ bfd_put_16 (output_bfd, t2a1_bx_pc_insn,
+ s->contents + my_offset);
+
+ bfd_put_16 (output_bfd, t2a2_noop_insn,
+ s->contents + my_offset + 2);
+
+ ret_offset =
+ ((bfd_signed_vma) h_val) /* Address of destination of the stub */
+ - ((bfd_signed_vma)
+ (s->output_offset /* Offset from the start of the current section to the start of the stubs. */
+ + my_offset /* Offset of the start of this stub from the start of the stubs. */
+ + s->output_section->vma) /* Address of the start of the current section. */
+ + 4 /* The branch instruction is 4 bytes into the stub. */
+ + 8); /* ARM branches work from the pc of the instruction + 8. */
+
+ bfd_put_32 (output_bfd,
+ t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
+ s->contents + my_offset + 4);
+
+ if (info->base_file)
+ arm_emit_base_file_entry (info, output_bfd, s, T2A3_OFFSET);
+ }
+ }
+
+ BFD_ASSERT (my_offset <= globals->thumb_glue_size);
+
+ /* Now go back and fix up the original BL insn to point
+ to here. */
+ ret_offset =
+ s->output_offset
+ + my_offset
+ - (input_section->output_offset
+ + rel->r_vaddr)
+ -4;
+
+ tmp = bfd_get_32 (input_bfd, contents + rel->r_vaddr
+ - input_section->vma);
+
+ bfd_put_32 (output_bfd,
+ insert_thumb_branch (tmp, ret_offset),
+ contents + rel->r_vaddr
+ - input_section->vma);
+
+ if (info->base_file)
+ arm_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr);
+
+ done = 1;
+ }
+ }
+ }
+
+ /* If the relocation type and destination symbol does not
+ fall into one of the above categories, then we can just
+ perform a direct link. */
+
+ if (done)
+ rstat = bfd_reloc_ok;
+ else
+#endif /* THUMBEXTENSION */
+ if ( h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ if (info->base_file)
+ {
+ /* Emit a reloc if the backend thinks it needs it. */
+ if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
+ arm_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr);
+ }
+
+#if 1 /* THUMBEXTENSION */
+ if (done)
+ rstat = bfd_reloc_ok;
+ /* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */
+ else if (! info->relocateable
+ && howto->type == ARM_THUMB23)
+ {
+ /* This is pretty much a copy of what the default
+ _bfd_final_link_relocate and _bfd_relocate_contents
+ routines do to perform a relocation, with special
+ processing for the split addressing of the Thumb BL
+ instruction. Again, it would probably be simpler adding a
+ ThumbBRANCH23 specific macro expansion into the default
+ code. */
+
+ bfd_vma address = rel->r_vaddr - input_section->vma;
+
+ if (address > input_section->_raw_size)
+ rstat = bfd_reloc_outofrange;
+ else
+ {
+ bfd_vma relocation = val + addend;
+ int size = bfd_get_reloc_size (howto);
+ boolean overflow = false;
+ bfd_byte * location = contents + address;
+ bfd_vma x = bfd_get_32 (input_bfd, location);
+ bfd_vma src_mask = 0x007FFFFE;
+ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+ bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
+ bfd_vma check;
+ bfd_signed_vma signed_check;
+ bfd_vma add;
+ bfd_signed_vma signed_add;
+
+ BFD_ASSERT (size == 4);
+
+ /* howto->pc_relative should be TRUE for type 14 BRANCH23 */
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+
+ /* howto->pcrel_offset should be TRUE for type 14 BRANCH23 */
+ relocation -= address;
+
+ /* No need to negate the relocation with BRANCH23. */
+ /* howto->complain_on_overflow == complain_overflow_signed for BRANCH23. */
+ /* howto->rightshift == 1 */
+ /* Drop unwanted bits from the value we are relocating to. */
+
+ check = relocation >> howto->rightshift;
+
+ /* If this is a signed value, the rightshift just dropped
+ leading 1 bits (assuming twos complement). */
+ if ((bfd_signed_vma) relocation >= 0)
+ signed_check = check;
+ else
+ signed_check = (check
+ | ((bfd_vma) - 1
+ & ~((bfd_vma) - 1 >> howto->rightshift)));
+
+ /* Get the value from the object file. */
+ if (bfd_big_endian (input_bfd))
+ {
+ add = (((x) & 0x07ff0000) >> 4) | (((x) & 0x7ff) << 1);
+ }
+ else
+ {
+ add = ((((x) & 0x7ff) << 12) | (((x) & 0x07ff0000) >> 15));
+ }
+
+ /* Get the value from the object file with an appropriate sign.
+ The expression involving howto->src_mask isolates the upper
+ bit of src_mask. If that bit is set in the value we are
+ adding, it is negative, and we subtract out that number times
+ two. If src_mask includes the highest possible bit, then we
+ can not get the upper bit, but that does not matter since
+ signed_add needs no adjustment to become negative in that
+ case. */
+
+ signed_add = add;
+
+ if ((add & (((~ src_mask) >> 1) & src_mask)) != 0)
+ signed_add -= (((~ src_mask) >> 1) & src_mask) << 1;
+
+ /* Add the value from the object file, shifted so that it is a
+ straight number. */
+ /* howto->bitpos == 0 */
+
+ signed_check += signed_add;
+ relocation += signed_add;
+
+ BFD_ASSERT (howto->complain_on_overflow == complain_overflow_signed);
+
+ /* Assumes two's complement. */
+ if ( signed_check > reloc_signed_max
+ || signed_check < reloc_signed_min)
+ overflow = true;
+
+ /* Put RELOCATION into the correct bits: */
+
+ if (bfd_big_endian (input_bfd))
+ {
+ relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000));
+ }
+ else
+ {
+ relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff));
+ }
+
+ /* Add RELOCATION to the correct bits of X: */
+ x = ((x & ~howto->dst_mask) | relocation);
+
+ /* Put the relocated value back in the object file: */
+ bfd_put_32 (input_bfd, x, location);
+
+ rstat = overflow ? bfd_reloc_overflow : bfd_reloc_ok;
+ }
+ }
+ else
+#endif /* THUMBEXTENSION */
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents,
+ rel->r_vaddr - input_section->vma,
+ val, addend);
+#if 1 /* THUMBEXTENSION */
+ /* FIXME:
+ Is this the best way to fix up thumb addresses? krk@cygnus.com
+ Probably not, but it works, and if it works it don't need fixing! nickc@cygnus.com */
+ /* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */
+ if (! info->relocateable
+ && rel->r_type == ARM_32)
+ {
+ /* Determine if we need to set the bottom bit of a relocated address
+ because the address is the address of a Thumb code symbol. */
+
+ int patchit = false;
+
+ if (h != NULL
+ && ( h->class == C_THUMBSTATFUNC
+ || h->class == C_THUMBEXTFUNC))
+ {
+ patchit = true;
+ }
+ else if (sym != NULL
+ && sym->n_scnum > N_UNDEF)
+ {
+ /* No hash entry - use the symbol instead. */
+
+ if ( sym->n_sclass == C_THUMBSTATFUNC
+ || sym->n_sclass == C_THUMBEXTFUNC)
+ patchit = true;
+ }
+
+ if (patchit)
+ {
+ bfd_byte * location = contents + rel->r_vaddr - input_section->vma;
+ bfd_vma x = bfd_get_32 (input_bfd, location);
+
+ bfd_put_32 (input_bfd, x | 1, location);
+ }
+ }
+#endif /* THUMBEXTENSION */
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_outofrange:
+ (*_bfd_error_handler)
+ (_("%s: bad reloc address 0x%lx in section `%s'"),
+ bfd_get_filename (input_bfd),
+ (unsigned long) rel->r_vaddr,
+ bfd_get_section_name (input_bfd, input_section));
+ return false;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+ if (name == NULL)
+ return false;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+#ifndef COFF_WITH_PE
+boolean
+bfd_arm_allocate_interworking_sections (info)
+ struct bfd_link_info * info;
+{
+ asection * s;
+ bfd_byte * foo;
+ struct coff_arm_link_hash_table * globals;
+#if 0
+ static char test_char = '1';
+#endif
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+
+ if (globals->arm_glue_size != 0)
+ {
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ foo = (bfd_byte *) bfd_alloc
+ (globals->bfd_of_glue_owner, globals->arm_glue_size);
+#if 0
+ memset (foo, test_char, globals->arm_glue_size);
+#endif
+
+ s->_raw_size = s->_cooked_size = globals->arm_glue_size;
+ s->contents = foo;
+ }
+
+ if (globals->thumb_glue_size != 0)
+ {
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ foo = (bfd_byte *) bfd_alloc
+ (globals->bfd_of_glue_owner, globals->thumb_glue_size);
+#if 0
+ memset (foo, test_char, globals->thumb_glue_size);
+#endif
+
+ s->_raw_size = s->_cooked_size = globals->thumb_glue_size;
+ s->contents = foo;
+ }
+
+ return true;
+}
+
+static void
+record_arm_to_thumb_glue (info, h)
+ struct bfd_link_info * info;
+ struct coff_link_hash_entry * h;
+{
+ const char * name = h->root.root.string;
+ register asection * s;
+ char * tmp_name;
+ struct coff_link_hash_entry * myh;
+ struct coff_arm_link_hash_table * globals;
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ tmp_name = ((char *)
+ bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name);
+
+ myh = coff_link_hash_lookup
+ (coff_hash_table (info), tmp_name, false, false, true);
+
+ if (myh != NULL)
+ {
+ free (tmp_name);
+ return; /* we've already seen this guy */
+ }
+
+ /* The only trick here is using globals->arm_glue_size as the value. Even
+ though the section isn't allocated yet, this is where we will be putting
+ it. */
+
+ bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_GLOBAL,
+ s, globals->arm_glue_size + 1,
+ NULL, true, false,
+ (struct bfd_link_hash_entry **) & myh);
+
+ free (tmp_name);
+
+ globals->arm_glue_size += ARM2THUMB_GLUE_SIZE;
+
+ return;
+}
+
+static void
+record_thumb_to_arm_glue (info, h)
+ struct bfd_link_info * info;
+ struct coff_link_hash_entry * h;
+{
+ const char * name = h->root.root.string;
+ register asection * s;
+ char * tmp_name;
+ struct coff_link_hash_entry * myh;
+ struct coff_arm_link_hash_table * globals;
+
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ tmp_name = (char *) bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name);
+
+ myh = coff_link_hash_lookup
+ (coff_hash_table (info), tmp_name, false, false, true);
+
+ if (myh != NULL)
+ {
+ free (tmp_name);
+ return; /* we've already seen this guy */
+ }
+
+ bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_GLOBAL, s, globals->thumb_glue_size + 1,
+ NULL, true, false,
+ (struct bfd_link_hash_entry **) & myh);
+
+ /* If we mark it 'thumb', the disassembler will do a better job. */
+ myh->class = C_THUMBEXTFUNC;
+
+ free (tmp_name);
+
+ /* Allocate another symbol to mark where we switch to arm mode. */
+
+#define CHANGE_TO_ARM "__%s_change_to_arm"
+#define BACK_FROM_ARM "__%s_back_from_arm"
+
+ tmp_name = (char *) bfd_malloc (strlen (name) + strlen (CHANGE_TO_ARM) + 1);
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, globals->support_old_code ? BACK_FROM_ARM : CHANGE_TO_ARM, name);
+
+ myh = NULL;
+
+ bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_LOCAL, s, globals->thumb_glue_size
+ + (globals->support_old_code ? 8 : 4),
+ NULL, true, false,
+ (struct bfd_link_hash_entry **) & myh);
+
+ free (tmp_name);
+
+ globals->thumb_glue_size += THUMB2ARM_GLUE_SIZE;
+
+ return;
+}
+
+/* Select a BFD to be used to hold the sections used by the glue code.
+ This function is called from the linker scripts in ld/emultempl/
+ {armcoff/pe}.em */
+boolean
+bfd_arm_get_bfd_for_interworking (abfd, info)
+ bfd * abfd;
+ struct bfd_link_info * info;
+{
+ struct coff_arm_link_hash_table * globals;
+ flagword flags;
+ asection * sec;
+
+ /* If we are only performing a partial link do not bother
+ getting a bfd to hold the glue. */
+ if (info->relocateable)
+ return true;
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+
+ if (globals->bfd_of_glue_owner != NULL)
+ return true;
+
+ sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME);
+
+ if (sec == NULL)
+ {
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME);
+
+ if (sec == NULL
+ || ! bfd_set_section_flags (abfd, sec, flags)
+ || ! bfd_set_section_alignment (abfd, sec, 2))
+ return false;
+ }
+
+ sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME);
+
+ if (sec == NULL)
+ {
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME);
+
+ if (sec == NULL
+ || ! bfd_set_section_flags (abfd, sec, flags)
+ || ! bfd_set_section_alignment (abfd, sec, 2))
+ return false;
+ }
+
+ /* Save the bfd for later use. */
+ globals->bfd_of_glue_owner = abfd;
+
+ return true;
+}
+
+boolean
+bfd_arm_process_before_allocation (abfd, info, support_old_code)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ int support_old_code;
+{
+ asection * sec;
+ struct coff_arm_link_hash_table * globals;
+
+ /* If we are only performing a partial link do not bother
+ to construct any glue. */
+ if (info->relocateable)
+ return true;
+
+ /* Here we have a bfd that is to be included on the link. We have a hook
+ to do reloc rummaging, before section sizes are nailed down. */
+
+ _bfd_coff_get_external_symbols (abfd);
+
+ globals = coff_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ globals->support_old_code = support_old_code;
+
+ /* Rummage around all the relocs and map the glue vectors. */
+ sec = abfd->sections;
+
+ if (sec == NULL)
+ return true;
+
+ for (; sec != NULL; sec = sec->next)
+ {
+ struct internal_reloc * i;
+ struct internal_reloc * rel;
+
+ if (sec->reloc_count == 0)
+ continue;
+
+ /* Load the relocs. */
+ /* FIXME: there may be a storage leak here. */
+
+ i = _bfd_coff_read_internal_relocs (abfd, sec, 1, 0, 0, 0);
+
+ BFD_ASSERT (i != 0);
+
+ for (rel = i; rel < i + sec->reloc_count; ++rel)
+ {
+ unsigned short r_type = rel->r_type;
+ long symndx;
+ struct coff_link_hash_entry * h;
+
+ symndx = rel->r_symndx;
+
+ /* If the relocation is not against a symbol it cannot concern us. */
+ if (symndx == -1)
+ continue;
+
+ h = obj_coff_sym_hashes (abfd)[symndx];
+
+ /* If the relocation is against a static symbol it must be within
+ the current section and so cannot be a cross ARM/Thumb relocation. */
+ if (h == NULL)
+ continue;
+
+ switch (r_type)
+ {
+ case ARM_26:
+ /* This one is a call from arm code. We need to look up
+ the target of the call. If it is a thumb target, we
+ insert glue. */
+
+ if (h->class == C_THUMBEXTFUNC)
+ record_arm_to_thumb_glue (info, h);
+ break;
+
+ case ARM_THUMB23:
+ /* This one is a call from thumb code. We used to look
+ for ARM_THUMB9 and ARM_THUMB12 as well. We need to look
+ up the target of the call. If it is an arm target, we
+ insert glue. If the symbol does not exist it will be
+ given a class of C_EXT and so we will generate a stub
+ for it. This is not really a problem, since the link
+ is doomed anyway. */
+
+ switch (h->class)
+ {
+ case C_EXT:
+ case C_STAT:
+ case C_LABEL:
+ record_thumb_to_arm_glue (info, h);
+ break;
+ default:
+ ;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+#endif /* ! COFF_WITH_PE */
+
+#define coff_bfd_reloc_type_lookup coff_arm_reloc_type_lookup
+#define coff_relocate_section coff_arm_relocate_section
+#define coff_bfd_is_local_label_name coff_arm_is_local_label_name
+#define coff_adjust_symndx coff_arm_adjust_symndx
+#define coff_link_output_has_begun coff_arm_link_output_has_begun
+#define coff_final_link_postscript coff_arm_final_link_postscript
+#define coff_bfd_merge_private_bfd_data coff_arm_merge_private_bfd_data
+#define coff_bfd_print_private_bfd_data coff_arm_print_private_bfd_data
+#define coff_bfd_set_private_flags _bfd_coff_arm_set_private_flags
+#define coff_bfd_copy_private_bfd_data coff_arm_copy_private_bfd_data
+#define coff_bfd_link_hash_table_create coff_arm_link_hash_table_create
+
+
+/* When doing a relocateable link, we want to convert ARM26 relocs
+ into ARM26D relocs. */
+
+static boolean
+coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
+ bfd *obfd;
+ struct bfd_link_info *info;
+ bfd *ibfd;
+ asection *sec;
+ struct internal_reloc *irel;
+ boolean *adjustedp;
+{
+ if (irel->r_type == 3)
+ {
+ struct coff_link_hash_entry *h;
+
+ h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->root.u.def.section->output_section == sec->output_section)
+ irel->r_type = 7;
+ }
+ *adjustedp = false;
+ return true;
+}
+
+/* Called when merging the private data areas of two BFDs.
+ This is important as it allows us to detect if we are
+ attempting to merge binaries compiled for different ARM
+ targets, eg different CPUs or differents APCS's. */
+
+static boolean
+coff_arm_merge_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ BFD_ASSERT (ibfd != NULL && obfd != NULL);
+
+ if (ibfd == obfd)
+ return true;
+
+ /* If the two formats are different we cannot merge anything.
+ This is not an error, since it is permissable to change the
+ input and output formats. */
+ if ( ibfd->xvec->flavour != bfd_target_coff_flavour
+ || obfd->xvec->flavour != bfd_target_coff_flavour)
+ return true;
+
+ /* Verify that the APCS is the same for the two BFDs */
+ if (APCS_SET (ibfd))
+ {
+ if (APCS_SET (obfd))
+ {
+ /* If the src and dest have different APCS flag bits set, fail. */
+ if (APCS_26_FLAG (obfd) != APCS_26_FLAG (ibfd))
+ {
+ _bfd_error_handler
+ /* xgettext: c-format */
+ (_("%s: ERROR: compiled for APCS-%d whereas target %s uses APCS-%d"),
+ bfd_get_filename (ibfd), APCS_26_FLAG (ibfd) ? 26 : 32,
+ bfd_get_filename (obfd), APCS_26_FLAG (obfd) ? 26 : 32
+ );
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if (APCS_FLOAT_FLAG (obfd) != APCS_FLOAT_FLAG (ibfd))
+ {
+ const char *msg;
+
+ if (APCS_FLOAT_FLAG (ibfd))
+ /* xgettext: c-format */
+ msg = _("%s: ERROR: passes floats in float registers whereas target %s uses integer registers");
+ else
+ /* xgettext: c-format */
+ msg = _("%s: ERROR: passes floats in integer registers whereas target %s uses float registers");
+
+ _bfd_error_handler (msg, bfd_get_filename (ibfd),
+ bfd_get_filename (obfd));
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if (PIC_FLAG (obfd) != PIC_FLAG (ibfd))
+ {
+ const char * msg;
+
+ if (PIC_FLAG (ibfd))
+ /* xgettext: c-format */
+ msg = _("%s: ERROR: compiled as position independent code, whereas target %s is absolute position");
+ else
+ /* xgettext: c-format */
+ msg = _("%s: ERROR: compiled as absolute position code, whereas target %s is position independent");
+ _bfd_error_handler (msg, bfd_get_filename (ibfd),
+ bfd_get_filename (obfd));
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+ }
+ else
+ {
+ SET_APCS_FLAGS (obfd, APCS_26_FLAG (ibfd) | APCS_FLOAT_FLAG (ibfd) | PIC_FLAG (ibfd));
+
+ /* Set up the arch and fields as well as these are probably wrong. */
+ bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
+ }
+ }
+
+ /* Check the interworking support. */
+ if (INTERWORK_SET (ibfd))
+ {
+ if (INTERWORK_SET (obfd))
+ {
+ /* If the src and dest differ in their interworking issue a warning. */
+ if (INTERWORK_FLAG (obfd) != INTERWORK_FLAG (ibfd))
+ {
+ const char * msg;
+
+ if (INTERWORK_FLAG (ibfd))
+ /* xgettext: c-format */
+ msg = _("Warning: input file %s supports interworking, whereas %s does not.");
+ else
+ /* xgettext: c-format */
+ msg = _("Warning: input file %s does not support interworking, whereas %s does.");
+
+ _bfd_error_handler (msg, bfd_get_filename (ibfd),
+ bfd_get_filename (obfd));
+ }
+ }
+ else
+ {
+ SET_INTERWORK_FLAG (obfd, INTERWORK_FLAG (ibfd));
+ }
+ }
+
+ return true;
+}
+
+
+/* Display the flags field. */
+
+static boolean
+coff_arm_print_private_bfd_data (abfd, ptr)
+ bfd * abfd;
+ PTR ptr;
+{
+ FILE * file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+ /* xgettext:c-format */
+ fprintf (file, _("private flags = %x:"), coff_data (abfd)->flags);
+
+ if (APCS_SET (abfd))
+ {
+ /* xgettext: APCS is ARM Prodecure Call Standard, it should not be translated. */
+ fprintf (file, " [APCS-%d]", APCS_26_FLAG (abfd) ? 26 : 32);
+
+ if (APCS_FLOAT_FLAG (abfd))
+ fprintf (file, _(" [floats passed in float registers]"));
+ else
+ fprintf (file, _(" [floats passed in integer registers]"));
+
+ if (PIC_FLAG (abfd))
+ fprintf (file, _(" [position independent]"));
+ else
+ fprintf (file, _(" [absolute position]"));
+ }
+
+ if (! INTERWORK_SET (abfd))
+ fprintf (file, _(" [interworking flag not initialised]"));
+ else if (INTERWORK_FLAG (abfd))
+ fprintf (file, _(" [interworking supported]"));
+ else
+ fprintf (file, _(" [interworking not supported]"));
+
+ fputc ('\n', file);
+
+ return true;
+}
+
+
+/* Copies the given flags into the coff_tdata.flags field.
+ Typically these flags come from the f_flags[] field of
+ the COFF filehdr structure, which contains important,
+ target specific information.
+ Note: Although this function is static, it is explicitly
+ called from both coffcode.h and peicode.h. */
+
+static boolean
+_bfd_coff_arm_set_private_flags (abfd, flags)
+ bfd * abfd;
+ flagword flags;
+{
+ flagword flag;
+
+ BFD_ASSERT (abfd != NULL);
+
+ flag = (flags & F_APCS26) ? F_APCS_26 : 0;
+
+ /* Make sure that the APCS field has not been initialised to the opposite
+ value. */
+ if (APCS_SET (abfd)
+ && ( (APCS_26_FLAG (abfd) != flag)
+ || (APCS_FLOAT_FLAG (abfd) != (flags & F_APCS_FLOAT))
+ || (PIC_FLAG (abfd) != (flags & F_PIC_INT ? F_PIC : 0))
+ ))
+ return false;
+
+ flag |= (flags & (F_APCS_FLOAT | F_PIC));
+
+ SET_APCS_FLAGS (abfd, flag);
+
+ flag = (flags & F_INTERWORK);
+
+ /* If the BFD has already had its interworking flag set, but it
+ is different from the value that we have been asked to set,
+ then assume that that merged code will not support interworking
+ and set the flag accordingly. */
+ if (INTERWORK_SET (abfd) && (INTERWORK_FLAG (abfd) != flag))
+ {
+ if (flag)
+ /* xgettext: c-format */
+ _bfd_error_handler (_("Warning: Not setting interworking flag of %s, since it has already been specified as non-interworking"),
+ bfd_get_filename (abfd));
+ else
+ /* xgettext: c-format */
+ _bfd_error_handler (_("Warning: Clearing the interworking flag of %s due to outside request"),
+ bfd_get_filename (abfd));
+ flag = 0;
+ }
+
+ SET_INTERWORK_FLAG (abfd, flag);
+
+ return true;
+}
+
+
+/* Copy the important parts of the target specific data
+ from one instance of a BFD to another. */
+
+static boolean
+coff_arm_copy_private_bfd_data (src, dest)
+ bfd * src;
+ bfd * dest;
+{
+ BFD_ASSERT (src != NULL && dest != NULL);
+
+ if (src == dest)
+ return true;
+
+ /* If the destination is not in the same format as the source, do not do
+ the copy. */
+ if (src->xvec != dest->xvec)
+ return true;
+
+ /* copy the flags field */
+ if (APCS_SET (src))
+ {
+ if (APCS_SET (dest))
+ {
+ /* If the src and dest have different APCS flag bits set, fail. */
+ if (APCS_26_FLAG (dest) != APCS_26_FLAG (src))
+ return false;
+
+ if (APCS_FLOAT_FLAG (dest) != APCS_FLOAT_FLAG (src))
+ return false;
+
+ if (PIC_FLAG (dest) != PIC_FLAG (src))
+ return false;
+ }
+ else
+ SET_APCS_FLAGS (dest, APCS_26_FLAG (src) | APCS_FLOAT_FLAG (src)
+ | PIC_FLAG (src));
+ }
+
+ if (INTERWORK_SET (src))
+ {
+ if (INTERWORK_SET (dest))
+ {
+ /* If the src and dest have different interworking flags then turn
+ off the interworking bit. */
+ if (INTERWORK_FLAG (dest) != INTERWORK_FLAG (src))
+ {
+ if (INTERWORK_FLAG (dest))
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler (("Warning: Clearing the interworking bit of %s, because the non-interworking code in %s has been copied into it"),
+ bfd_get_filename (dest),
+ bfd_get_filename (src));
+ }
+
+ SET_INTERWORK_FLAG (dest, 0);
+ }
+ }
+ else
+ {
+ SET_INTERWORK_FLAG (dest, INTERWORK_FLAG (src));
+ }
+ }
+
+ return true;
+}
+
+/* Note: the definitions here of LOCAL_LABEL_PREFIX and USER_LABEL_PREIFX
+ *must* match the definitions in gcc/config/arm/coff.h and semi.h */
+#define LOCAL_LABEL_PREFIX "."
+#ifndef USER_LABEL_PREFIX
+#define USER_LABEL_PREFIX "_"
+#endif
+
+static boolean
+coff_arm_is_local_label_name (abfd, name)
+ bfd * abfd;
+ const char * name;
+{
+#ifdef LOCAL_LABEL_PREFIX
+ /* If there is a prefix for local labels then look for this.
+ If the prefix exists, but it is empty, then ignore the test. */
+
+ if (LOCAL_LABEL_PREFIX[0] != 0)
+ {
+ if (strncmp (name, LOCAL_LABEL_PREFIX, strlen (LOCAL_LABEL_PREFIX)) == 0)
+ return true;
+ }
+#endif
+#ifdef USER_LABEL_PREFIX
+ if (USER_LABEL_PREFIX[0] != 0)
+ {
+ if (strncmp (name, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)) == 0)
+ return false;
+ }
+#endif
+
+ /* devo/gcc/config/dbxcoff.h defines ASM_OUTPUT_SOURCE_LINE to generate
+ local line numbers as .LM<number>, so treat these as local. */
+
+ switch (name[0])
+ {
+ case 'L': return true;
+ case '.': return (name[1] == 'L' && name[2] == 'M') ? true : false;
+ default: return false; /* Cannot make our minds up - default to
+ false so that it will not be stripped
+ by accident. */
+ }
+}
+
+/* This piece of machinery exists only to guarantee that the bfd that holds
+ the glue section is written last.
+
+ This does depend on bfd_make_section attaching a new section to the
+ end of the section list for the bfd.
+
+ krk@cygnus.com */
+
+static boolean
+coff_arm_link_output_has_begun (sub, info)
+ bfd * sub;
+ struct coff_final_link_info * info;
+{
+ return (sub->output_has_begun
+ || sub == coff_arm_hash_table (info->info)->bfd_of_glue_owner);
+}
+
+static boolean
+coff_arm_final_link_postscript (abfd, pfinfo)
+ bfd * abfd;
+ struct coff_final_link_info * pfinfo;
+{
+ struct coff_arm_link_hash_table * globals;
+
+ globals = coff_arm_hash_table (pfinfo->info);
+
+ BFD_ASSERT (globals != NULL);
+
+ if (globals->bfd_of_glue_owner != NULL)
+ {
+ if (! _bfd_coff_link_input_bfd (pfinfo, globals->bfd_of_glue_owner))
+ return false;
+
+ globals->bfd_of_glue_owner->output_has_begun = true;
+ }
+
+ return true;
+}
+
+#if 0
+#define coff_SWAP_sym_in arm_bfd_coff_swap_sym_in
+
+static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
+
+/* Sepcial version of symbol swapper, used to grab a bfd
+ onto which the glue sections can be attached. */
+static void
+arm_bfd_coff_swap_sym_in (abfd, ext1, in1)
+ bfd * abfd;
+ PTR ext1;
+ PTR in1;
+{
+ flagword flags;
+ register asection * s;
+
+ /* Do the normal swap in. */
+ coff_swap_sym_in (abfd, ext1, in1);
+
+ if (bfd_of_glue_owner != NULL) /* we already have a toc, so go home */
+ return;
+
+ /* Save the bfd for later allocation. */
+ bfd_of_glue_owner = abfd;
+
+ s = bfd_get_section_by_name (bfd_of_glue_owner ,
+ ARM2THUMB_GLUE_SECTION_NAME);
+
+ if (s == NULL)
+ {
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ;
+
+ s = bfd_make_section (bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
+
+ if (s == NULL
+ || !bfd_set_section_flags (bfd_of_glue_owner, s, flags)
+ || !bfd_set_section_alignment (bfd_of_glue_owner, s, 2))
+ {
+ /* FIXME: set appropriate bfd error */
+ abort();
+ }
+ }
+
+ s = bfd_get_section_by_name (bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
+
+ if (s == NULL)
+ {
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ;
+
+ s = bfd_make_section (bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
+
+ if (s == NULL
+ || !bfd_set_section_flags (bfd_of_glue_owner, s, flags)
+ || !bfd_set_section_alignment (bfd_of_glue_owner, s, 2))
+ {
+ /* FIXME: set appropriate bfd error krk@cygnus.com */
+ abort();
+ }
+ }
+
+ return;
+}
+#endif
+
+#include "coffcode.h"
+
+const bfd_target
+#ifdef TARGET_LITTLE_SYM
+TARGET_LITTLE_SYM =
+#else
+armcoff_little_vec =
+#endif
+{
+#ifdef TARGET_LITTLE_NAME
+ TARGET_LITTLE_NAME,
+#else
+ "coff-arm-little",
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+#ifndef COFF_WITH_PE
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+#else
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+#endif
+
+#ifdef TARGET_UNDERSCORE
+ TARGET_UNDERSCORE, /* leading underscore */
+#else
+ 0, /* leading underscore */
+#endif
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, coff_object_p},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) & bfd_coff_std_swap_table,
+};
+
+const bfd_target
+#ifdef TARGET_BIG_SYM
+TARGET_BIG_SYM =
+#else
+armcoff_big_vec =
+#endif
+{
+#ifdef TARGET_BIG_NAME
+ TARGET_BIG_NAME,
+#else
+ "coff-arm-big",
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+#ifndef COFF_WITH_PE
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+#else
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+#endif
+
+#ifdef TARGET_UNDERSCORE
+ TARGET_UNDERSCORE, /* leading underscore */
+#else
+ 0, /* leading underscore */
+#endif
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, coff_object_p},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) & bfd_coff_std_swap_table,
+};
diff --git a/bfd/coff-aux.c b/bfd/coff-aux.c
new file mode 100644
index 00000000000..6966392a33b
--- /dev/null
+++ b/bfd/coff-aux.c
@@ -0,0 +1,135 @@
+/* BFD back-end for Apple M68K COFF A/UX 3.x files.
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+ Written by Richard Henderson <rth@tamu.edu>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM m68kaux_coff_vec
+#define TARGET_NAME "coff-m68k-aux"
+
+#ifndef TARG_AUX
+#define TARG_AUX
+#endif
+
+#define COFF_LONG_FILENAMES
+
+/* 4k pages */
+#define COFF_PAGE_SIZE 0x1000
+
+/* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
+#define BSS_NOLOAD_IS_SHARED_LIBRARY
+
+#define STATIC_RELOCS
+
+#define COFF_COMMON_ADDEND
+
+#include "bfd.h"
+#include "sysdep.h"
+
+static boolean coff_m68k_aux_link_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
+ asection *, bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
+
+#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
+
+#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
+#include "coff-m68k.c"
+
+/* We need non-absolute symbols to override absolute symbols. This
+ mirrors Apple's "solution" to let a static library symbol override
+ a shared library symbol. On the whole not a good thing, given how
+ shared libraries work here, but can work if you are careful with
+ what you include in the shared object. */
+
+static boolean
+coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
+ string, copy, collect, hashp)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ const char *string;
+ boolean copy;
+ boolean collect;
+ struct bfd_link_hash_entry **hashp;
+{
+ struct bfd_link_hash_entry *h;
+
+ if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
+ !bfd_is_und_section (section) &&
+ !bfd_is_com_section (section))
+ {
+ /* The new symbol is a definition or an indirect definition */
+
+ /* This bit copied from linker.c */
+ if (hashp != NULL && *hashp != NULL)
+ {
+ h = *hashp;
+ BFD_ASSERT (strcmp (h->root.string, name) == 0);
+ }
+ else
+ {
+ h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
+ if (h == NULL)
+ {
+ if (hashp != NULL)
+ *hashp = NULL;
+ return false;
+ }
+ }
+
+ if (info->notice_hash != (struct bfd_hash_table *) NULL
+ && (bfd_hash_lookup (info->notice_hash, name, false, false)
+ != (struct bfd_hash_entry *) NULL))
+ {
+ if (! (*info->callbacks->notice) (info, name, abfd, section, value))
+ return false;
+ }
+
+ if (hashp != (struct bfd_link_hash_entry **) NULL)
+ *hashp = h;
+ /* end duplication from linker.c */
+
+ if (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_indirect)
+ {
+ asection *msec;
+
+ if (h->type == bfd_link_hash_defined)
+ msec = h->u.def.section;
+ else
+ msec = bfd_ind_section_ptr;
+
+ if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
+ {
+ h->u.def.section = section;
+ h->u.def.value = value;
+ return true;
+ }
+ else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
+ return true;
+ }
+ }
+
+ /* If we didn't exit early, finish processing in the generic routine */
+ return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
+ value, string, copy, collect,
+ hashp);
+}
diff --git a/bfd/coff-go32.c b/bfd/coff-go32.c
new file mode 100644
index 00000000000..be4adb24f52
--- /dev/null
+++ b/bfd/coff-go32.c
@@ -0,0 +1,25 @@
+/* BFD back-end for Intel 386 COFF files (go32 variant).
+ Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Written by DJ Delorie.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM go32coff_vec
+#define TARGET_NAME "coff-go32"
+#define TARGET_UNDERSCORE '_'
+
+#include "coff-i386.c"
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c
new file mode 100644
index 00000000000..74a4ec3962a
--- /dev/null
+++ b/bfd/coff-h8300.c
@@ -0,0 +1,1388 @@
+/* BFD back-end for Hitachi H8/300 COFF binaries.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Steve Chamberlain, <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "genlink.h"
+#include "coff/h8300.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+
+/* We derive a hash table from the basic BFD hash table to
+ hold entries in the function vector. Aside from the
+ info stored by the basic hash table, we need the offset
+ of a particular entry within the hash table as well as
+ the offset where we'll add the next entry. */
+
+struct funcvec_hash_entry
+{
+ /* The basic hash table entry. */
+ struct bfd_hash_entry root;
+
+ /* The offset within the vectors section where
+ this entry lives. */
+ bfd_vma offset;
+};
+
+struct funcvec_hash_table
+{
+ /* The basic hash table. */
+ struct bfd_hash_table root;
+
+ bfd *abfd;
+
+ /* Offset at which we'll add the next entry. */
+ unsigned int offset;
+};
+
+static struct bfd_hash_entry *
+funcvec_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+static boolean
+funcvec_hash_table_init
+ PARAMS ((struct funcvec_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *))));
+
+/* To lookup a value in the function vector hash table. */
+#define funcvec_hash_lookup(table, string, create, copy) \
+ ((struct funcvec_hash_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+/* The derived h8300 COFF linker table. Note it's derived from
+ the generic linker hash table, not the COFF backend linker hash
+ table! We use this to attach additional data structures we
+ need while linking on the h8300. */
+struct h8300_coff_link_hash_table
+{
+ /* The main hash table. */
+ struct generic_link_hash_table root;
+
+ /* Section for the vectors table. This gets attached to a
+ random input bfd, we keep it here for easy access. */
+ asection *vectors_sec;
+
+ /* Hash table of the functions we need to enter into the function
+ vector. */
+ struct funcvec_hash_table *funcvec_hash_table;
+};
+
+static struct bfd_link_hash_table *h8300_coff_link_hash_table_create
+ PARAMS ((bfd *));
+
+/* Get the H8/300 COFF linker hash table from a link_info structure. */
+
+#define h8300_coff_hash_table(p) \
+ ((struct h8300_coff_link_hash_table *) ((coff_hash_table (p))))
+
+/* Initialize fields within a funcvec hash table entry. Called whenever
+ a new entry is added to the funcvec hash table. */
+
+static struct bfd_hash_entry *
+funcvec_hash_newfunc (entry, gen_table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *gen_table;
+ const char *string;
+{
+ struct funcvec_hash_entry *ret;
+ struct funcvec_hash_table *table;
+
+ ret = (struct funcvec_hash_entry *) entry;
+ table = (struct funcvec_hash_table *) gen_table;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == NULL)
+ ret = ((struct funcvec_hash_entry *)
+ bfd_hash_allocate (gen_table,
+ sizeof (struct funcvec_hash_entry)));
+ if (ret == NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct funcvec_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
+
+ if (ret == NULL)
+ return NULL;
+
+ /* Note where this entry will reside in the function vector table. */
+ ret->offset = table->offset;
+
+ /* Bump the offset at which we store entries in the function
+ vector. We'd like to bump up the size of the vectors section,
+ but it's not easily available here. */
+ if (bfd_get_mach (table->abfd) == bfd_mach_h8300)
+ table->offset += 2;
+ else if (bfd_get_mach (table->abfd) == bfd_mach_h8300h
+ || bfd_get_mach (table->abfd) == bfd_mach_h8300s)
+ table->offset += 4;
+ else
+ return NULL;
+
+ /* Everything went OK. */
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize the function vector hash table. */
+
+static boolean
+funcvec_hash_table_init (table, abfd, newfunc)
+ struct funcvec_hash_table *table;
+ bfd *abfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ /* Initialize our local fields, then call the generic initialization
+ routine. */
+ table->offset = 0;
+ table->abfd = abfd;
+ return (bfd_hash_table_init (&table->root, newfunc));
+}
+
+/* Create the derived linker hash table. We use a derived hash table
+ basically to hold "static" information during an h8/300 coff link
+ without using static variables. */
+
+static struct bfd_link_hash_table *
+h8300_coff_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct h8300_coff_link_hash_table *ret;
+ ret = ((struct h8300_coff_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct h8300_coff_link_hash_table)));
+ if (ret == NULL)
+ return NULL;
+ if (!_bfd_link_hash_table_init (&ret->root.root, abfd, _bfd_generic_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ /* Initialize our data. */
+ ret->vectors_sec = NULL;
+ ret->funcvec_hash_table = NULL;
+
+ /* OK. Everything's intialized, return the base pointer. */
+ return &ret->root.root;
+}
+
+/* special handling for H8/300 relocs.
+ We only come here for pcrel stuff and return normally if not an -r link.
+ When doing -r, we can't do any arithmetic for the pcrel stuff, because
+ the code in reloc.c assumes that we can manipulate the targets of
+ the pcrel branches. This isn't so, since the H8/300 can do relaxing,
+ which means that the gap after the instruction may not be enough to
+ contain the offset required for the branch, so we have to use the only
+ the addend until the final link */
+
+static bfd_reloc_status_type
+special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_ok;
+}
+
+static reloc_howto_type howto_table[] =
+{
+ HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
+ HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true),
+ HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true),
+ HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true),
+ HOWTO (R_MOV16B1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "relaxable mov.b:16", false, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_MOV16B2, 0, 1, 8, false, 0, complain_overflow_bitfield, special, "relaxed mov.b:16", false, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false),
+ HOWTO (R_JMPL2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_MOV24B1, 0, 1, 32, false, 0, complain_overflow_bitfield, special, "relaxable mov.b:24", false, 0xffffffff, 0xffffffff, false),
+ HOWTO (R_MOV24B2, 0, 1, 8, false, 0, complain_overflow_bitfield, special, "relaxed mov.b:24", false, 0x0000ffff, 0x0000ffff, false),
+
+ /* An indirect reference to a function. This causes the function's address
+ to be added to the function vector in lo-mem and puts the address of
+ the function vector's entry in the jsr instruction. */
+ HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),
+
+ /* Internal reloc for relaxing. This is created when a 16bit pc-relative
+ branch is turned into an 8bit pc-relative branch. */
+ HOWTO (R_PCRWORD_B, 0, 0, 8, true, 0, complain_overflow_bitfield, special, "relaxed bCC:16", false, 0x000000ff, 0x000000ff, false),
+
+ HOWTO (R_MOVL1, 0, 2, 32, false, 0, complain_overflow_bitfield,special, "32/24 relaxable move", false, 0xffffffff, 0xffffffff, false),
+
+ HOWTO (R_MOVL2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "32/24 relaxed move", false, 0x0000ffff, 0x0000ffff, false),
+
+ HOWTO (R_BCC_INV, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8 inverted", false, 0x000000ff, 0x000000ff, true),
+
+ HOWTO (R_JMP_DEL, 0, 0, 8, true, 0, complain_overflow_signed, special, "Deleted jump", false, 0x000000ff, 0x000000ff, true),
+};
+
+
+/* Turn a howto into a reloc number */
+
+#define SELECT_RELOC(x,howto) \
+ { x.r_type = select_reloc(howto); }
+
+#define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x))
+#define H8300 1 /* Customize coffcode.h */
+#define __A_MAGIC_SET__
+
+
+
+/* Code to swap in the reloc */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
+ dst->r_stuff[0] = 'S'; \
+ dst->r_stuff[1] = 'C';
+
+
+static int
+select_reloc (howto)
+ reloc_howto_type *howto;
+{
+ return howto->type;
+}
+
+/* Code to turn a r_type into a howto ptr, uses the above howto table
+ */
+
+static void
+rtype2howto (internal, dst)
+ arelent *internal;
+ struct internal_reloc *dst;
+{
+ switch (dst->r_type)
+ {
+ case R_RELBYTE:
+ internal->howto = howto_table + 0;
+ break;
+ case R_RELWORD:
+ internal->howto = howto_table + 1;
+ break;
+ case R_RELLONG:
+ internal->howto = howto_table + 2;
+ break;
+ case R_PCRBYTE:
+ internal->howto = howto_table + 3;
+ break;
+ case R_PCRWORD:
+ internal->howto = howto_table + 4;
+ break;
+ case R_PCRLONG:
+ internal->howto = howto_table + 5;
+ break;
+ case R_MOV16B1:
+ internal->howto = howto_table + 6;
+ break;
+ case R_MOV16B2:
+ internal->howto = howto_table + 7;
+ break;
+ case R_JMP1:
+ internal->howto = howto_table + 8;
+ break;
+ case R_JMP2:
+ internal->howto = howto_table + 9;
+ break;
+ case R_JMPL1:
+ internal->howto = howto_table + 10;
+ break;
+ case R_JMPL2:
+ internal->howto = howto_table + 11;
+ break;
+ case R_MOV24B1:
+ internal->howto = howto_table + 12;
+ break;
+ case R_MOV24B2:
+ internal->howto = howto_table + 13;
+ break;
+ case R_MEM_INDIRECT:
+ internal->howto = howto_table + 14;
+ break;
+ case R_PCRWORD_B:
+ internal->howto = howto_table + 15;
+ break;
+ case R_MOVL1:
+ internal->howto = howto_table + 16;
+ break;
+ case R_MOVL2:
+ internal->howto = howto_table + 17;
+ break;
+ case R_BCC_INV:
+ internal->howto = howto_table + 18;
+ break;
+ case R_JMP_DEL:
+ internal->howto = howto_table + 19;
+ break;
+ default:
+ abort ();
+ break;
+ }
+}
+
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+
+
+/* Perform any necessary magic to the addend in a reloc entry */
+
+
+#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
+ cache_ptr->addend = ext_reloc.r_offset;
+
+
+#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void
+reloc_processing (relent, reloc, symbols, abfd, section)
+ arelent * relent;
+ struct internal_reloc *reloc;
+ asymbol ** symbols;
+ bfd * abfd;
+ asection * section;
+{
+ relent->address = reloc->r_vaddr;
+ rtype2howto (relent, reloc);
+
+ if (((int) reloc->r_symndx) > 0)
+ {
+ relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
+ }
+ else
+ {
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+
+
+
+ relent->addend = reloc->r_offset;
+
+ relent->address -= section->vma;
+ /* relent->section = 0;*/
+}
+
+static boolean
+h8300_symbol_address_p (abfd, input_section, address)
+ bfd *abfd;
+ asection *input_section;
+ bfd_vma address;
+{
+ asymbol **s;
+
+ s = _bfd_generic_link_get_symbols (abfd);
+ BFD_ASSERT (s != (asymbol **) NULL);
+
+ /* Search all the symbols for one in INPUT_SECTION with
+ address ADDRESS. */
+ while (*s)
+ {
+ asymbol *p = *s;
+ if (p->section == input_section
+ && (input_section->output_section->vma
+ + input_section->output_offset
+ + p->value) == address)
+ return true;
+ s++;
+ }
+ return false;
+}
+
+
+/* If RELOC represents a relaxable instruction/reloc, change it into
+ the relaxed reloc, notify the linker that symbol addresses
+ have changed (bfd_perform_slip) and return how much the current
+ section has shrunk by.
+
+ FIXME: Much of this code has knowledge of the ordering of entries
+ in the howto table. This needs to be fixed. */
+
+static int
+h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
+ bfd *abfd;
+ asection *input_section;
+ arelent *reloc;
+ unsigned int shrink;
+ struct bfd_link_info *link_info;
+{
+ bfd_vma value;
+ bfd_vma dot;
+ bfd_vma gap;
+ static asection *last_input_section = NULL;
+ static arelent *last_reloc = NULL;
+
+ /* The address of the thing to be relocated will have moved back by
+ the size of the shrink - but we don't change reloc->address here,
+ since we need it to know where the relocation lives in the source
+ uncooked section. */
+ bfd_vma address = reloc->address - shrink;
+
+ if (input_section != last_input_section)
+ last_reloc = NULL;
+
+ /* Only examine the relocs which might be relaxable. */
+ switch (reloc->howto->type)
+ {
+
+ /* This is the 16/24 bit absolute branch which could become an 8 bit
+ pc-relative branch. */
+ case R_JMP1:
+ case R_JMPL1:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ /* Get the address of the next instruction (not the reloc). */
+ dot = (input_section->output_section->vma
+ + input_section->output_offset + address);
+
+ /* Adjust for R_JMP1 vs R_JMPL1. */
+ dot += (reloc->howto->type == R_JMP1 ? 1 : 2);
+
+ /* Compute the distance from this insn to the branch target. */
+ gap = value - dot;
+
+ /* If the distance is within -128..+128 inclusive, then we can relax
+ this jump. +128 is valid since the target will move two bytes
+ closer if we do relax this branch. */
+ if ((int)gap >= -128 && (int)gap <= 128 )
+ {
+
+ /* It's possible we may be able to eliminate this branch entirely;
+ if the previous instruction is a branch around this instruction,
+ and there's no label at this instruction, then we can reverse
+ the condition on the previous branch and eliminate this jump.
+
+ original: new:
+ bCC lab1 bCC' lab2
+ jmp lab2
+ lab1: lab1:
+
+ This saves 4 bytes instead of two, and should be relatively
+ common. */
+
+ if (gap <= 126
+ && last_reloc
+ && last_reloc->howto->type == R_PCRBYTE)
+ {
+ bfd_vma last_value;
+ last_value = bfd_coff_reloc16_get_value (last_reloc, link_info,
+ input_section) + 1;
+
+ if (last_value == dot + 2
+ && last_reloc->address + 1 == reloc->address
+ && ! h8300_symbol_address_p (abfd, input_section, dot - 2))
+ {
+ reloc->howto = howto_table + 19;
+ last_reloc->howto = howto_table + 18;
+ last_reloc->sym_ptr_ptr = reloc->sym_ptr_ptr;
+ last_reloc->addend = reloc->addend;
+ shrink += 4;
+ bfd_perform_slip (abfd, 4, input_section, address);
+ break;
+ }
+ }
+
+ /* Change the reloc type. */
+ reloc->howto = reloc->howto + 1;
+
+ /* This shrinks this section by two bytes. */
+ shrink += 2;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+ break;
+
+ /* This is the 16 bit pc-relative branch which could become an 8 bit
+ pc-relative branch. */
+ case R_PCRWORD:
+ /* Get the address of the target of this branch, add one to the value
+ because the addend field in PCrel jumps is off by -1. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section) + 1;
+
+ /* Get the address of the next instruction if we were to relax. */
+ dot = input_section->output_section->vma +
+ input_section->output_offset + address;
+
+ /* Compute the distance from this insn to the branch target. */
+ gap = value - dot;
+
+ /* If the distance is within -128..+128 inclusive, then we can relax
+ this jump. +128 is valid since the target will move two bytes
+ closer if we do relax this branch. */
+ if ((int)gap >= -128 && (int)gap <= 128 )
+ {
+ /* Change the reloc type. */
+ reloc->howto = howto_table + 15;
+
+ /* This shrinks this section by two bytes. */
+ shrink += 2;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+ break;
+
+ /* This is a 16 bit absolute address in a mov.b insn, which can
+ become an 8 bit absolute address if it's in the right range. */
+ case R_MOV16B1:
+ /* Get the address of the data referenced by this mov.b insn. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ /* The address is in 0xff00..0xffff inclusive on the h8300 or
+ 0xffff00..0xffffff inclusive on the h8300h, then we can
+ relax this mov.b */
+ if ((bfd_get_mach (abfd) == bfd_mach_h8300
+ && value >= 0xff00
+ && value <= 0xffff)
+ || ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ || bfd_get_mach (abfd) == bfd_mach_h8300s)
+ && value >= 0xffff00
+ && value <= 0xffffff))
+ {
+ /* Change the reloc type. */
+ reloc->howto = reloc->howto + 1;
+
+ /* This shrinks this section by two bytes. */
+ shrink += 2;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+ break;
+
+ /* Similarly for a 24 bit absolute address in a mov.b. Note that
+ if we can't relax this into an 8 bit absolute, we'll fall through
+ and try to relax it into a 16bit absolute. */
+ case R_MOV24B1:
+ /* Get the address of the data referenced by this mov.b insn. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ /* The address is in 0xffff00..0xffffff inclusive on the h8300h,
+ then we can relax this mov.b */
+ if ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ || bfd_get_mach (abfd) == bfd_mach_h8300s)
+ && value >= 0xffff00
+ && value <= 0xffffff)
+ {
+ /* Change the reloc type. */
+ reloc->howto = reloc->howto + 1;
+
+ /* This shrinks this section by four bytes. */
+ shrink += 4;
+ bfd_perform_slip(abfd, 4, input_section, address);
+
+ /* Done with this reloc. */
+ break;
+ }
+
+ /* FALLTHROUGH and try to turn the 32/24 bit reloc into a 16 bit
+ reloc. */
+
+ /* This is a 24/32 bit absolute address in a mov insn, which can
+ become an 16 bit absolute address if it's in the right range. */
+ case R_MOVL1:
+ /* Get the address of the data referenced by this mov insn. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ /* If this address is in 0x0000..0x7fff inclusive or
+ 0xff8000..0xffffff inclusive, then it can be relaxed. */
+ if (value <= 0x7fff || value >= 0xff8000)
+ {
+ /* Change the reloc type. */
+ reloc->howto = howto_table + 17;
+
+ /* This shrinks this section by two bytes. */
+ shrink += 2;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+ break;
+
+ /* No other reloc types represent relaxing opportunities. */
+ default:
+ break;
+ }
+
+ last_reloc = reloc;
+ last_input_section = input_section;
+ return shrink;
+}
+
+
+/* Handle relocations for the H8/300, including relocs for relaxed
+ instructions.
+
+ FIXME: Not all relocations check for overflow! */
+
+static void
+h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
+ dst_ptr)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ arelent *reloc;
+ bfd_byte *data;
+ unsigned int *src_ptr;
+ unsigned int *dst_ptr;
+{
+ unsigned int src_address = *src_ptr;
+ unsigned int dst_address = *dst_ptr;
+ asection *input_section = link_order->u.indirect.section;
+ bfd_vma value;
+ bfd_vma dot;
+ int gap,tmp;
+
+ switch (reloc->howto->type)
+ {
+
+ /* Generic 8bit pc-relative relocation. */
+ case R_PCRBYTE:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ dot = (link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma);
+
+ gap = value - dot;
+
+ /* Sanity check. */
+ if (gap < -128 || gap > 126)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+
+ /* Everything looks OK. Apply the relocation and update the
+ src/dst address appropriately. */
+
+ bfd_put_8 (abfd, gap, data + dst_address);
+ dst_address++;
+ src_address++;
+
+ /* All done. */
+ break;
+
+ /* Generic 16bit pc-relative relocation. */
+ case R_PCRWORD:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ /* Get the address of the instruction (not the reloc). */
+ dot = (link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma + 1);
+
+ gap = value - dot;
+
+ /* Sanity check. */
+ if (gap > 32766 || gap < -32768)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+
+ /* Everything looks OK. Apply the relocation and update the
+ src/dst address appropriately. */
+
+ bfd_put_16 (abfd, gap, data + dst_address);
+ dst_address += 2;
+ src_address += 2;
+
+ /* All done. */
+ break;
+
+ /* Generic 8bit absolute relocation. */
+ case R_RELBYTE:
+ /* Get the address of the object referenced by this insn. */
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Sanity check. */
+ if (value <= 0xff
+ || (value >= 0x0000ff00 && value <= 0x0000ffff)
+ || (value >= 0x00ffff00 && value <= 0x00ffffff)
+ || (value >= 0xffffff00 && value <= 0xffffffff))
+ {
+ /* Everything looks OK. Apply the relocation and update the
+ src/dst address appropriately. */
+
+ bfd_put_8 (abfd, value & 0xff, data + dst_address);
+ dst_address += 1;
+ src_address += 1;
+ }
+ else
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+
+ /* All done. */
+ break;
+
+ /* Various simple 16bit absolute relocations. */
+ case R_MOV16B1:
+ case R_JMP1:
+ case R_RELWORD:
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+ bfd_put_16 (abfd, value, data + dst_address);
+ dst_address += 2;
+ src_address += 2;
+ break;
+
+ /* Various simple 24/32bit absolute relocations. */
+ case R_MOV24B1:
+ case R_MOVL1:
+ case R_RELLONG:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ bfd_put_32 (abfd, value, data + dst_address);
+ dst_address += 4;
+ src_address += 4;
+ break;
+
+ /* Another 24/32bit absolute relocation. */
+ case R_JMPL1:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ value = ((value & 0x00ffffff)
+ | (bfd_get_32 (abfd, data + src_address) & 0xff000000));
+ bfd_put_32 (abfd, value, data + dst_address);
+ dst_address += 4;
+ src_address += 4;
+ break;
+
+ /* A 16bit abolute relocation that was formerlly a 24/32bit
+ absolute relocation. */
+ case R_MOVL2:
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Sanity check. */
+ if (value < 0x8000 || value > 0xff8000)
+ {
+ /* Insert the 16bit value into the proper location. */
+ bfd_put_16 (abfd, value, data + dst_address);
+
+ /* Fix the opcode. For all the move insns, we simply
+ need to turn off bit 0x20 in the previous byte. */
+ data[dst_address - 1] &= ~0x20;
+ dst_address += 2;
+ src_address += 4;
+ }
+ else
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+ break;
+
+ /* A 16bit absolute branch that is now an 8-bit pc-relative branch. */
+ case R_JMP2:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Get the address of the next instruction. */
+ dot = (link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma + 1);
+
+ gap = value - dot;
+
+ /* Sanity check. */
+ if (gap < -128 || gap > 126)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+
+ /* Now fix the instruction itself. */
+ switch (data[dst_address - 1])
+ {
+ case 0x5e:
+ /* jsr -> bsr */
+ bfd_put_8 (abfd, 0x55, data + dst_address - 1);
+ break;
+ case 0x5a:
+ /* jmp ->bra */
+ bfd_put_8 (abfd, 0x40, data + dst_address - 1);
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* Write out the 8bit value. */
+ bfd_put_8 (abfd, gap, data + dst_address);
+
+ dst_address += 1;
+ src_address += 3;
+
+ break;
+
+ /* A 16bit pc-relative branch that is now an 8-bit pc-relative branch. */
+ case R_PCRWORD_B:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Get the address of the instruction (not the reloc). */
+ dot = (link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma - 1);
+
+ gap = value - dot;
+
+ /* Sanity check. */
+ if (gap < -128 || gap > 126)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+
+ /* Now fix the instruction. */
+ switch (data[dst_address - 2])
+ {
+ case 0x58:
+ /* bCC:16 -> bCC:8 */
+ /* Get the condition code from the original insn. */
+ tmp = data[dst_address - 1];
+ tmp &= 0xf0;
+ tmp >>= 4;
+
+ /* Now or in the high nibble of the opcode. */
+ tmp |= 0x40;
+
+ /* Write it. */
+ bfd_put_8 (abfd, tmp, data + dst_address - 2);
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* Output the target. */
+ bfd_put_8 (abfd, gap, data + dst_address - 1);
+
+ /* We don't advance dst_address -- the 8bit reloc is applied at
+ dst_address - 1, so the next insn should begin at dst_address. */
+ src_address += 2;
+
+ break;
+
+ /* Similarly for a 24bit absolute that is now 8 bits. */
+ case R_JMPL2:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Get the address of the instruction (not the reloc). */
+ dot = (link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma + 2);
+
+ gap = value - dot;
+
+ /* Fix the instruction. */
+ switch (data[src_address])
+ {
+ case 0x5e:
+ /* jsr -> bsr */
+ bfd_put_8 (abfd, 0x55, data + dst_address);
+ break;
+ case 0x5a:
+ /* jmp ->bra */
+ bfd_put_8 (abfd, 0x40, data + dst_address);
+ break;
+ default:
+ abort ();
+ }
+
+ bfd_put_8 (abfd, gap, data + dst_address + 1);
+ dst_address += 2;
+ src_address += 4;
+
+ break;
+
+ /* A 16bit absolute mov.b that is now an 8bit absolute mov.b. */
+ case R_MOV16B2:
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Sanity check. */
+ if (data[dst_address - 2] != 0x6a)
+ abort ();
+
+ /* Fix up the opcode. */
+ switch (data[src_address-1] & 0xf0)
+ {
+ case 0x00:
+ data[dst_address - 2] = (data[src_address-1] & 0xf) | 0x20;
+ break;
+ case 0x80:
+ data[dst_address - 2] = (data[src_address-1] & 0xf) | 0x30;
+ break;
+ default:
+ abort ();
+ }
+
+ bfd_put_8 (abfd, value & 0xff, data + dst_address - 1);
+ src_address += 2;
+ break;
+
+ /* Similarly for a 24bit mov.b */
+ case R_MOV24B2:
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+
+ /* Sanity check. */
+ if (data[dst_address - 2] != 0x6a)
+ abort ();
+
+ /* Fix up the opcode. */
+ switch (data[src_address-1] & 0xf0)
+ {
+ case 0x20:
+ data[dst_address - 2] = (data[src_address-1] & 0xf) | 0x20;
+ break;
+ case 0xa0:
+ data[dst_address - 2] = (data[src_address-1] & 0xf) | 0x30;
+ break;
+ default:
+ abort ();
+ }
+
+ bfd_put_8 (abfd, value & 0xff, data + dst_address - 1);
+ src_address += 4;
+ break;
+
+ case R_BCC_INV:
+ /* Get the address of the target of this branch. */
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ dot = (link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma) + 1;
+
+ gap = value - dot;
+
+ /* Sanity check. */
+ if (gap < -128 || gap > 126)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+
+ /* Everything looks OK. Fix the condition in the instruction, apply
+ the relocation, and update the src/dst address appropriately. */
+
+ bfd_put_8 (abfd, bfd_get_8 (abfd, data + dst_address - 1) ^ 1,
+ data + dst_address - 1);
+ bfd_put_8 (abfd, gap, data + dst_address);
+ dst_address++;
+ src_address++;
+
+ /* All done. */
+ break;
+
+ case R_JMP_DEL:
+ src_address += 4;
+ break;
+
+ /* An 8bit memory indirect instruction (jmp/jsr).
+
+ There's several things that need to be done to handle
+ this relocation.
+
+ If this is a reloc against the absolute symbol, then
+ we should handle it just R_RELBYTE. Likewise if it's
+ for a symbol with a value ge 0 and le 0xff.
+
+ Otherwise it's a jump/call through the function vector,
+ and the linker is expected to set up the function vector
+ and put the right value into the jump/call instruction. */
+ case R_MEM_INDIRECT:
+ {
+ /* We need to find the symbol so we can determine it's
+ address in the function vector table. */
+ asymbol *symbol;
+ bfd_vma value;
+ const char *name;
+ struct funcvec_hash_entry *h;
+ asection *vectors_sec = h8300_coff_hash_table (link_info)->vectors_sec;
+
+ /* First see if this is a reloc against the absolute symbol
+ or against a symbol with a nonnegative value <= 0xff. */
+ symbol = *(reloc->sym_ptr_ptr);
+ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+ if (symbol == bfd_abs_section_ptr->symbol
+ || (value >= 0 && value <= 0xff))
+ {
+ /* This should be handled in a manner very similar to
+ R_RELBYTES. If the value is in range, then just slam
+ the value into the right location. Else trigger a
+ reloc overflow callback. */
+ if (value >= 0 && value <= 0xff)
+ {
+ bfd_put_8 (abfd, value, data + dst_address);
+ dst_address += 1;
+ src_address += 1;
+ }
+ else
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+ break;
+ }
+
+ /* This is a jump/call through a function vector, and we're
+ expected to create the function vector ourselves.
+
+ First look up this symbol in the linker hash table -- we need
+ the derived linker symbol which holds this symbol's index
+ in the function vector. */
+ name = symbol->name;
+ if (symbol->flags & BSF_LOCAL)
+ {
+ char *new_name = bfd_malloc (strlen (name) + 9);
+ if (new_name == NULL)
+ abort ();
+
+ strcpy (new_name, name);
+ sprintf (new_name + strlen (name), "_%08x",
+ (int)symbol->section);
+ name = new_name;
+ }
+
+ h = funcvec_hash_lookup (h8300_coff_hash_table (link_info)->funcvec_hash_table,
+ name, false, false);
+
+ /* This shouldn't ever happen. If it does that means we've got
+ data corruption of some kind. Aborting seems like a reasonable
+ think to do here. */
+ if (h == NULL || vectors_sec == NULL)
+ abort ();
+
+ /* Place the address of the function vector entry into the
+ reloc's address. */
+ bfd_put_8 (abfd,
+ vectors_sec->output_offset + h->offset,
+ data + dst_address);
+
+ dst_address++;
+ src_address++;
+
+ /* Now create an entry in the function vector itself. */
+ if (bfd_get_mach (input_section->owner) == bfd_mach_h8300)
+ bfd_put_16 (abfd,
+ bfd_coff_reloc16_get_value (reloc,
+ link_info,
+ input_section),
+ vectors_sec->contents + h->offset);
+ else if (bfd_get_mach (input_section->owner) == bfd_mach_h8300h
+ || bfd_get_mach (input_section->owner) == bfd_mach_h8300s)
+ bfd_put_32 (abfd,
+ bfd_coff_reloc16_get_value (reloc,
+ link_info,
+ input_section),
+ vectors_sec->contents + h->offset);
+ else
+ abort ();
+
+ /* Gross. We've already written the contents of the vector section
+ before we get here... So we write it again with the new data. */
+ bfd_set_section_contents (vectors_sec->output_section->owner,
+ vectors_sec->output_section,
+ vectors_sec->contents,
+ vectors_sec->output_offset,
+ vectors_sec->_raw_size);
+ break;
+ }
+
+ default:
+ abort ();
+ break;
+
+ }
+
+ *src_ptr = src_address;
+ *dst_ptr = dst_address;
+}
+
+
+/* Routine for the h8300 linker.
+
+ This routine is necessary to handle the special R_MEM_INDIRECT
+ relocs on the h8300. It's responsible for generating a vectors
+ section and attaching it to an input bfd as well as sizing
+ the vectors section. It also creates our vectors hash table.
+
+ It uses the generic linker routines to actually add the symbols.
+ from this BFD to the bfd linker hash table. It may add a few
+ selected static symbols to the bfd linker hash table. */
+
+static boolean
+h8300_bfd_link_add_symbols(abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection *sec;
+ struct funcvec_hash_table *funcvec_hash_table;
+
+ /* If we haven't created a vectors section, do so now. */
+ if (!h8300_coff_hash_table (info)->vectors_sec)
+ {
+ flagword flags;
+
+ /* Make sure the appropriate flags are set, including SEC_IN_MEMORY. */
+ flags = (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_READONLY);
+ h8300_coff_hash_table (info)->vectors_sec = bfd_make_section (abfd,
+ ".vectors");
+
+ /* If the section wasn't created, or we couldn't set the flags,
+ quit quickly now, rather than dieing a painful death later. */
+ if (! h8300_coff_hash_table (info)->vectors_sec
+ || ! bfd_set_section_flags (abfd,
+ h8300_coff_hash_table(info)->vectors_sec,
+ flags))
+ return false;
+
+ /* Also create the vector hash table. */
+ funcvec_hash_table = ((struct funcvec_hash_table *)
+ bfd_alloc (abfd, sizeof (struct funcvec_hash_table)));
+
+ if (!funcvec_hash_table)
+ return false;
+
+ /* And initialize the funcvec hash table. */
+ if (!funcvec_hash_table_init (funcvec_hash_table, abfd,
+ funcvec_hash_newfunc))
+ {
+ bfd_release (abfd, funcvec_hash_table);
+ return false;
+ }
+
+ /* Store away a pointer to the funcvec hash table. */
+ h8300_coff_hash_table (info)->funcvec_hash_table = funcvec_hash_table;
+ }
+
+ /* Load up the function vector hash table. */
+ funcvec_hash_table = h8300_coff_hash_table (info)->funcvec_hash_table;
+
+ /* Add the symbols using the generic code. */
+ _bfd_generic_link_add_symbols (abfd, info);
+
+ /* Now scan the relocs for all the sections in this bfd; create
+ additional space in the .vectors section as needed. */
+ for (sec = abfd->sections; sec; sec = sec->next)
+ {
+ long reloc_size, reloc_count, i;
+ asymbol **symbols;
+ arelent **relocs;
+
+ /* Suck in the relocs, symbols & canonicalize them. */
+ reloc_size = bfd_get_reloc_upper_bound (abfd, sec);
+ if (reloc_size <= 0)
+ continue;
+
+ relocs = (arelent **)bfd_malloc ((size_t)reloc_size);
+ if (!relocs)
+ return false;
+
+ /* The symbols should have been read in by _bfd_generic link_add_symbols
+ call abovec, so we can cheat and use the pointer to them that was
+ saved in the above call. */
+ symbols = _bfd_generic_link_get_symbols(abfd);
+ reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, symbols);
+ if (reloc_count <= 0)
+ {
+ free (relocs);
+ continue;
+ }
+
+ /* Now walk through all the relocations in this section. */
+ for (i = 0; i < reloc_count; i++)
+ {
+ arelent *reloc = relocs[i];
+ asymbol *symbol = *(reloc->sym_ptr_ptr);
+ const char *name;
+
+ /* We've got an indirect reloc. See if we need to add it
+ to the function vector table. At this point, we have
+ to add a new entry for each unique symbol referenced
+ by an R_MEM_INDIRECT relocation except for a reloc
+ against the absolute section symbol. */
+ if (reloc->howto->type == R_MEM_INDIRECT
+ && symbol != bfd_abs_section_ptr->symbol)
+
+ {
+ struct funcvec_hash_entry *h;
+
+ name = symbol->name;
+ if (symbol->flags & BSF_LOCAL)
+ {
+ char *new_name = bfd_malloc (strlen (name) + 9);
+
+ if (new_name == NULL)
+ abort ();
+
+ strcpy (new_name, name);
+ sprintf (new_name + strlen (name), "_%08x",
+ (int)symbol->section);
+ name = new_name;
+ }
+
+ /* Look this symbol up in the function vector hash table. */
+ h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,
+ name, false, false);
+
+
+ /* If this symbol isn't already in the hash table, add
+ it and bump up the size of the hash table. */
+ if (h == NULL)
+ {
+ h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,
+ name, true, true);
+ if (h == NULL)
+ {
+ free (relocs);
+ return false;
+ }
+
+ /* Bump the size of the vectors section. Each vector
+ takes 2 bytes on the h8300 and 4 bytes on the h8300h. */
+ if (bfd_get_mach (abfd) == bfd_mach_h8300)
+ h8300_coff_hash_table (info)->vectors_sec->_raw_size += 2;
+ else if (bfd_get_mach (abfd) == bfd_mach_h8300h
+ || bfd_get_mach (abfd) == bfd_mach_h8300s)
+ h8300_coff_hash_table (info)->vectors_sec->_raw_size += 4;
+ }
+ }
+ }
+
+ /* We're done with the relocations, release them. */
+ free (relocs);
+ }
+
+ /* Now actually allocate some space for the function vector. It's
+ wasteful to do this more than once, but this is easier. */
+ if (h8300_coff_hash_table (info)->vectors_sec->_raw_size != 0)
+ {
+ /* Free the old contents. */
+ if (h8300_coff_hash_table (info)->vectors_sec->contents)
+ free (h8300_coff_hash_table (info)->vectors_sec->contents);
+
+ /* Allocate new contents. */
+ h8300_coff_hash_table (info)->vectors_sec->contents
+ = bfd_malloc (h8300_coff_hash_table (info)->vectors_sec->_raw_size);
+ }
+
+ return true;
+}
+
+#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
+#define coff_reloc16_estimate h8300_reloc16_estimate
+#define coff_bfd_link_add_symbols h8300_bfd_link_add_symbols
+#define coff_bfd_link_hash_table_create h8300_coff_link_hash_table_create
+
+#define COFF_LONG_FILENAMES
+#include "coffcode.h"
+
+
+#undef coff_bfd_get_relocated_section_contents
+#undef coff_bfd_relax_section
+#define coff_bfd_get_relocated_section_contents \
+ bfd_coff_reloc16_get_relocated_section_contents
+#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
+
+
+
+const bfd_target h8300coff_vec =
+{
+ "coff-h8300", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading char */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-h8500.c b/bfd/coff-h8500.c
new file mode 100644
index 00000000000..91109eaa921
--- /dev/null
+++ b/bfd/coff-h8500.c
@@ -0,0 +1,354 @@
+/* BFD back-end for Hitachi H8/500 COFF binaries.
+ Copyright 1993, 94, 95, 1997 Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+ Written by Steve Chamberlain, <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "coff/h8500.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+
+static reloc_howto_type r_imm8 =
+HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
+ complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
+
+static reloc_howto_type r_imm16 =
+HOWTO (R_H8500_IMM16, 0, 1, 16, false, 0,
+ complain_overflow_bitfield, 0, "r_imm16", true, 0x0000ffff, 0x0000ffff, false);
+
+static reloc_howto_type r_imm24 =
+HOWTO (R_H8500_IMM24, 0, 1, 24, false, 0,
+ complain_overflow_bitfield, 0, "r_imm24", true, 0x00ffffff, 0x00ffffff, false);
+
+static reloc_howto_type r_imm32 =
+HOWTO (R_H8500_IMM32, 0, 1, 32, false, 0,
+ complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff, 0xffffffff, false);
+
+
+static reloc_howto_type r_high8 =
+HOWTO (R_H8500_HIGH8, 0, 1, 8, false, 0,
+ complain_overflow_dont, 0, "r_high8", true, 0x000000ff, 0x000000ff, false);
+
+static reloc_howto_type r_low16 =
+HOWTO (R_H8500_LOW16, 0, 1, 16, false, 0,
+ complain_overflow_dont, 0, "r_low16", true, 0x0000ffff, 0x0000ffff, false);
+
+static reloc_howto_type r_pcrel8 =
+HOWTO (R_H8500_PCREL8, 0, 1, 8, true, 0, complain_overflow_signed, 0, "r_pcrel8", true, 0, 0, true);
+
+
+static reloc_howto_type r_pcrel16 =
+HOWTO (R_H8500_PCREL16, 0, 1, 16, true, 0, complain_overflow_signed, 0, "r_pcrel16", true, 0, 0, true);
+
+static reloc_howto_type r_high16 =
+HOWTO (R_H8500_HIGH16, 0, 1, 8, false, 0,
+ complain_overflow_dont, 0, "r_high16", true, 0x000ffff, 0x0000ffff, false);
+
+
+/* Turn a howto into a reloc number */
+
+static int
+coff_h8500_select_reloc (howto)
+ reloc_howto_type *howto;
+{
+ return howto->type;
+}
+
+#define SELECT_RELOC(x,howto) x.r_type = coff_h8500_select_reloc(howto)
+
+
+#define BADMAG(x) H8500BADMAG(x)
+#define H8500 1 /* Customize coffcode.h */
+
+#define __A_MAGIC_SET__
+
+/* Code to swap in the reloc */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
+ dst->r_stuff[0] = 'S'; \
+ dst->r_stuff[1] = 'C';
+
+/* Code to turn a r_type into a howto ptr, uses the above howto table
+ */
+
+static void
+rtype2howto(internal, dst)
+ arelent * internal;
+ struct internal_reloc *dst;
+{
+ switch (dst->r_type)
+ {
+ default:
+ abort ();
+ break;
+ case R_H8500_IMM8:
+ internal->howto = &r_imm8;
+ break;
+ case R_H8500_IMM16:
+ internal->howto = &r_imm16;
+ break;
+ case R_H8500_IMM24:
+ internal->howto = &r_imm24;
+ break;
+ case R_H8500_IMM32:
+ internal->howto = &r_imm32;
+ break;
+ case R_H8500_PCREL8:
+ internal->howto = &r_pcrel8;
+ break;
+ case R_H8500_PCREL16:
+ internal->howto = &r_pcrel16;
+ break;
+ case R_H8500_HIGH8:
+ internal->howto = &r_high8;
+ break;
+ case R_H8500_HIGH16:
+ internal->howto = &r_high16;
+ break;
+ case R_H8500_LOW16:
+ internal->howto = &r_low16;
+ break;
+ }
+}
+
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+
+
+/* Perform any necessary magic to the addend in a reloc entry */
+
+
+#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
+ cache_ptr->addend = ext_reloc.r_offset;
+
+
+#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void reloc_processing (relent, reloc, symbols, abfd, section)
+ arelent * relent;
+ struct internal_reloc *reloc;
+ asymbol ** symbols;
+ bfd * abfd;
+ asection * section;
+{
+ relent->address = reloc->r_vaddr;
+ rtype2howto (relent, reloc);
+
+ if (reloc->r_symndx > 0)
+ {
+ relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
+ }
+ else
+ {
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+
+
+ relent->addend = reloc->r_offset;
+ relent->address -= section->vma;
+}
+
+static void
+extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
+ bfd *in_abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ arelent *reloc;
+ bfd_byte *data;
+ unsigned int *src_ptr;
+ unsigned int *dst_ptr;
+{
+ bfd_byte *d = data+*dst_ptr;
+ asection *input_section = link_order->u.indirect.section;
+ switch (reloc->howto->type)
+ {
+ case R_H8500_IMM8:
+ bfd_put_8 (in_abfd,
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ d);
+ (*dst_ptr) += 1;
+ (*src_ptr) += 1;
+ break;
+
+ case R_H8500_HIGH8:
+ bfd_put_8 (in_abfd,
+ (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
+ >> 16),
+ d );
+ (*dst_ptr) += 1;
+ (*src_ptr) += 1;
+ break;
+
+ case R_H8500_IMM16:
+ bfd_put_16 (in_abfd,
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ d );
+ (*dst_ptr) += 2;
+ (*src_ptr) += 2;
+ break;
+
+ case R_H8500_LOW16:
+ bfd_put_16 (in_abfd,
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ d);
+
+ (*dst_ptr) += 2;
+ (*src_ptr) += 2;
+ break;
+
+ case R_H8500_HIGH16:
+ bfd_put_16 (in_abfd,
+ (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
+ >>16),
+ d);
+
+ (*dst_ptr) += 2;
+ (*src_ptr) += 2;
+ break;
+
+ case R_H8500_IMM24:
+ {
+ int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+ int o = bfd_get_32(in_abfd, data+ *dst_ptr -1);
+ v = (v & 0x00ffffff) | (o & 0xff00000);
+ bfd_put_32 (in_abfd, v, data + *dst_ptr -1);
+ (*dst_ptr) +=3;
+ (*src_ptr)+=3;;
+ }
+ break;
+ case R_H8500_IMM32:
+ {
+ int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+ bfd_put_32 (in_abfd, v, data + *dst_ptr);
+ (*dst_ptr) +=4;
+ (*src_ptr)+=4;;
+ }
+ break;
+
+
+ case R_H8500_PCREL8:
+ {
+ bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_vma dot = link_order->offset
+ + *dst_ptr
+ + link_order->u.indirect.section->output_section->vma;
+ int gap = dst - dot - 1; /* -1 since were in the odd byte of the
+ word and the pc's been incremented */
+
+ if (gap > 128 || gap < -128)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+ bfd_put_8 (in_abfd, gap, data + *dst_ptr);
+ (*dst_ptr)++;
+ (*src_ptr)++;
+ break;
+ }
+ case R_H8500_PCREL16:
+ {
+ bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_vma dot = link_order->offset
+ + *dst_ptr
+ + link_order->u.indirect.section->output_section->vma;
+ int gap = dst - dot - 1; /* -1 since were in the odd byte of the
+ word and the pc's been incremented */
+
+ if (gap > 32767 || gap < -32768)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+ bfd_put_16 (in_abfd, gap, data + *dst_ptr);
+ (*dst_ptr)+=2;
+ (*src_ptr)+=2;
+ break;
+ }
+
+ default:
+ abort ();
+ }
+}
+
+#define coff_reloc16_extra_cases extra_case
+
+#include "coffcode.h"
+
+
+#undef coff_bfd_get_relocated_section_contents
+#undef coff_bfd_relax_section
+#define coff_bfd_get_relocated_section_contents \
+ bfd_coff_reloc16_get_relocated_section_contents
+#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
+
+const bfd_target h8500coff_vec =
+{
+ "coff-h8500", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c
new file mode 100644
index 00000000000..7898cc159ca
--- /dev/null
+++ b/bfd/coff-i386.c
@@ -0,0 +1,637 @@
+/* BFD back-end for Intel 386 COFF files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "coff/i386.h"
+
+#include "coff/internal.h"
+
+#ifdef COFF_WITH_PE
+#include "coff/pe.h"
+#endif
+
+#ifdef COFF_GO32_EXE
+#include "coff/go32exe.h"
+#endif
+
+#include "libcoff.h"
+
+static bfd_reloc_status_type coff_i386_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *coff_i386_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+
+ bfd_vma *));
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
+/* The page size is a guess based on ELF. */
+
+#define COFF_PAGE_SIZE 0x1000
+
+/* For some reason when using i386 COFF the value stored in the .text
+ section for a reference to a common symbol is the value itself plus
+ any desired offset. Ian Taylor, Cygnus Support. */
+
+/* If we are producing relocateable output, we need to do some
+ adjustments to the object file that are not done by the
+ bfd_perform_relocation function. This function is called by every
+ reloc type to make any required adjustments. */
+
+static bfd_reloc_status_type
+coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ symvalue diff;
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ if (bfd_is_com_section (symbol->section))
+ {
+#ifndef COFF_WITH_PE
+ /* We are relocating a common symbol. The current value in the
+ object file is ORIG + OFFSET, where ORIG is the value of the
+ common symbol as seen by the object file when it was compiled
+ (this may be zero if the symbol was undefined) and OFFSET is
+ the offset into the common symbol (normally zero, but may be
+ non-zero when referring to a field in a common structure).
+ ORIG is the negative of reloc_entry->addend, which is set by
+ the CALC_ADDEND macro below. We want to replace the value in
+ the object file with NEW + OFFSET, where NEW is the value of
+ the common symbol which we are going to put in the final
+ object file. NEW is symbol->value. */
+ diff = symbol->value + reloc_entry->addend;
+#else
+ /* In PE mode, we do not offset the common symbol. */
+ diff = reloc_entry->addend;
+#endif
+ }
+ else
+ {
+ /* For some reason bfd_perform_relocation always effectively
+ ignores the addend for a COFF target when producing
+ relocateable output. This seems to be always wrong for 386
+ COFF, so we handle the addend here instead. */
+ diff = reloc_entry->addend;
+ }
+
+#ifdef COFF_WITH_PE
+ /* FIXME: How should this case be handled? */
+ if (reloc_entry->howto->type == R_IMAGEBASE && diff != 0)
+ abort ();
+#endif
+
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
+
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, x, addr);
+ }
+ break;
+
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_32 (abfd, x, addr);
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ /* Now let bfd_perform_relocation finish everything up. */
+ return bfd_reloc_continue;
+}
+
+#ifdef COFF_WITH_PE
+/* Return true if this relocation should
+ appear in the output .reloc section. */
+
+static boolean in_reloc_p(abfd, howto)
+ bfd * abfd;
+ reloc_howto_type *howto;
+{
+ return ! howto->pc_relative && howto->type != R_IMAGEBASE;
+}
+#endif
+
+#ifndef PCRELOFFSET
+#define PCRELOFFSET false
+#endif
+
+static reloc_howto_type howto_table[] =
+{
+ {0},
+ {1},
+ {2},
+ {3},
+ {4},
+ {5},
+ HOWTO (R_DIR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "dir32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+ /* {7}, */
+ HOWTO (R_IMAGEBASE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "rva32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+ {010},
+ {011},
+ {012},
+ {013},
+ {014},
+ {015},
+ {016},
+ HOWTO (R_RELBYTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_RELWORD, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_RELLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_PCRBYTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "DISP8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_PCRWORD, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "DISP16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_PCRLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "DISP32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ PCRELOFFSET) /* pcrel_offset */
+};
+
+/* Turn a howto into a reloc nunmber */
+
+#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
+#define BADMAG(x) I386BADMAG(x)
+#define I386 1 /* Customize coffcode.h */
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ (cache_ptr)->howto = howto_table + (dst)->r_type;
+
+/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
+ library. On some other COFF targets STYP_BSS is normally
+ STYP_NOLOAD. */
+#define BSS_NOLOAD_IS_SHARED_LIBRARY
+
+/* Compute the addend of a reloc. If the reloc is to a common symbol,
+ the object file contains the value of the common symbol. By the
+ time this is called, the linker may be using a different symbol
+ from a different object file with a different value. Therefore, we
+ hack wildly to locate the original symbol from this file so that we
+ can make the correct adjustment. This macro sets coffsym to the
+ symbol from the original file, and uses it to set the addend value
+ correctly. If this is not a common symbol, the usual addend
+ calculation is done, except that an additional tweak is needed for
+ PC relative relocs.
+ FIXME: This macro refers to symbols and asect; these are from the
+ calling function, not the macro arguments. */
+
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = - coffsym->native->u.syment.n_value; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ if (ptr && howto_table[reloc.r_type].pc_relative) \
+ cache_ptr->addend += asect->vma; \
+ }
+
+/* We use the special COFF backend linker. For normal i386 COFF, we
+ can use the generic relocate_section routine. For PE, we need our
+ own routine. */
+
+#ifndef COFF_WITH_PE
+
+#define coff_relocate_section _bfd_coff_generic_relocate_section
+
+#else /* COFF_WITH_PE */
+
+/* The PE relocate section routine. The only difference between this
+ and the regular routine is that we don't want to do anything for a
+ relocateable link. */
+
+static boolean coff_pe_i386_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+static boolean
+coff_pe_i386_relocate_section (output_bfd, info, input_bfd,
+ input_section, contents, relocs, syms,
+ sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ if (info->relocateable)
+ return true;
+
+ return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
+ input_section, contents,
+ relocs, syms, sections);
+}
+
+#define coff_relocate_section coff_pe_i386_relocate_section
+
+#endif /* COFF_WITH_PE */
+
+/* Convert an rtype to howto for the COFF backend linker. */
+
+static reloc_howto_type *
+coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+
+ reloc_howto_type *howto;
+
+ howto = howto_table + rel->r_type;
+
+#ifdef COFF_WITH_PE
+ *addendp = 0;
+#endif
+
+ if (howto->pc_relative)
+ *addendp += sec->vma;
+
+ if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
+ {
+ /* This is a common symbol. The section contents include the
+ size (sym->n_value) as an addend. The relocate_section
+ function will be adding in the final value of the symbol. We
+ need to subtract out the current size in order to get the
+ correct result. */
+
+ BFD_ASSERT (h != NULL);
+
+#ifndef COFF_WITH_PE
+ /* I think we *do* want to bypass this. If we don't, I have
+ seen some data parameters get the wrong relocation address.
+ If I link two versions with and without this section bypassed
+ and then do a binary comparison, the addresses which are
+ different can be looked up in the map. The case in which
+ this section has been bypassed has addresses which correspond
+ to values I can find in the map. */
+ *addendp -= sym->n_value;
+#endif
+ }
+
+#ifndef COFF_WITH_PE
+ /* If the output symbol is common (in which case this must be a
+ relocateable link), we need to add in the final size of the
+ common symbol. */
+ if (h != NULL && h->root.type == bfd_link_hash_common)
+ *addendp += h->root.u.c.size;
+#endif
+
+#ifdef COFF_WITH_PE
+ if (howto->pc_relative)
+ {
+ *addendp -= 4;
+
+ /* If the symbol is defined, then the generic code is going to
+ add back the symbol value in order to cancel out an
+ adjustment it made to the addend. However, we set the addend
+ to 0 at the start of this function. We need to adjust here,
+ to avoid the adjustment the generic code will make. FIXME:
+ This is getting a bit hackish. */
+ if (sym != NULL && sym->n_scnum != 0)
+ *addendp -= sym->n_value;
+ }
+
+ if (rel->r_type == R_IMAGEBASE)
+ {
+ *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
+ }
+#endif
+
+ return howto;
+}
+
+
+#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
+
+
+static reloc_howto_type *
+coff_i386_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_RVA:
+ return howto_table +R_IMAGEBASE;
+ case BFD_RELOC_32:
+ return howto_table + R_DIR32;
+ case BFD_RELOC_32_PCREL:
+ return howto_table + R_PCRLONG;
+ default:
+ BFD_FAIL ();
+ return 0;
+ }
+}
+
+#define coff_rtype_to_howto coff_i386_rtype_to_howto
+
+#ifdef TARGET_UNDERSCORE
+
+/* If i386 gcc uses underscores for symbol names, then it does not use
+ a leading dot for local labels, so if TARGET_UNDERSCORE is defined
+ we treat all symbols starting with L as local. */
+
+static boolean coff_i386_is_local_label_name PARAMS ((bfd *, const char *));
+
+static boolean
+coff_i386_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (name[0] == 'L')
+ return true;
+
+ return _bfd_coff_is_local_label_name (abfd, name);
+}
+
+#define coff_bfd_is_local_label_name coff_i386_is_local_label_name
+
+#endif /* TARGET_UNDERSCORE */
+
+#include "coffcode.h"
+
+static const bfd_target *
+i3coff_object_p (abfd)
+ bfd *abfd;
+{
+#ifdef COFF_IMAGE_WITH_PE
+ /* We need to hack badly to handle a PE image correctly. In PE
+ images created by the GNU linker, the offset to the COFF header
+ is always the size. However, this is not the case in images
+ generated by other PE linkers. The PE format stores a four byte
+ offset to the PE signature just before the COFF header at
+ location 0x3c of the file. We pick up that offset, verify that
+ the PE signature is there, and then set ourselves up to read in
+ the COFF header. */
+ {
+ bfd_byte ext_offset[4];
+ file_ptr offset;
+ bfd_byte ext_signature[4];
+ unsigned long signature;
+
+ if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0
+ || bfd_read (ext_offset, 1, 4, abfd) != 4)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ offset = bfd_h_get_32 (abfd, ext_offset);
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0
+ || bfd_read (ext_signature, 1, 4, abfd) != 4)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ signature = bfd_h_get_32 (abfd, ext_signature);
+
+ if (signature != 0x4550)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Here is the hack. coff_object_p wants to read filhsz bytes to
+ pick up the COFF header. We adjust so that that will work. 20
+ is the size of the i386 COFF filehdr. */
+
+ if (bfd_seek (abfd,
+ (bfd_tell (abfd)
+ - bfd_coff_filhsz (abfd)
+ + 20),
+ SEEK_SET)
+ != 0)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ }
+#endif
+
+ return coff_object_p (abfd);
+}
+
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ i386coff_vec =
+#endif
+{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
+ "coff-i386", /* name */
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+#ifndef COFF_WITH_PE
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_CODE | SEC_DATA),
+#else
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_CODE | SEC_DATA
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+#endif
+
+#ifdef TARGET_UNDERSCORE
+ TARGET_UNDERSCORE, /* leading underscore */
+#else
+ 0, /* leading underscore */
+#endif
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, i3coff_object_p},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-i860.c b/bfd/coff-i860.c
new file mode 100644
index 00000000000..929fa428cdb
--- /dev/null
+++ b/bfd/coff-i860.c
@@ -0,0 +1,422 @@
+/* BFD back-end for Intel 860 COFF files.
+ Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Created mostly by substituting "860" for "386" in coff-i386.c
+ Harry Dolan <dolan@ssd.intel.com>, October 1995
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "coff/i860.h"
+
+#include "coff/internal.h"
+
+#include "libcoff.h"
+
+static bfd_reloc_status_type coff_i860_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *coff_i860_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
+/* The page size is a guess based on ELF. */
+
+#define COFF_PAGE_SIZE 0x1000
+
+/* For some reason when using i860 COFF the value stored in the .text
+ section for a reference to a common symbol is the value itself plus
+ any desired offset. Ian Taylor, Cygnus Support. */
+
+/* If we are producing relocateable output, we need to do some
+ adjustments to the object file that are not done by the
+ bfd_perform_relocation function. This function is called by every
+ reloc type to make any required adjustments. */
+
+static bfd_reloc_status_type
+coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ symvalue diff;
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+
+ if (bfd_is_com_section (symbol->section))
+ {
+ /* We are relocating a common symbol. The current value in the
+ object file is ORIG + OFFSET, where ORIG is the value of the
+ common symbol as seen by the object file when it was compiled
+ (this may be zero if the symbol was undefined) and OFFSET is
+ the offset into the common symbol (normally zero, but may be
+ non-zero when referring to a field in a common structure).
+ ORIG is the negative of reloc_entry->addend, which is set by
+ the CALC_ADDEND macro below. We want to replace the value in
+ the object file with NEW + OFFSET, where NEW is the value of
+ the common symbol which we are going to put in the final
+ object file. NEW is symbol->value. */
+ diff = symbol->value + reloc_entry->addend;
+ }
+ else
+ {
+ /* For some reason bfd_perform_relocation always effectively
+ ignores the addend for a COFF target when producing
+ relocateable output. This seems to be always wrong for 860
+ COFF, so we handle the addend here instead. */
+ diff = reloc_entry->addend;
+ }
+
+
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
+
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, x, addr);
+ }
+ break;
+
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_32 (abfd, x, addr);
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ /* Now let bfd_perform_relocation finish everything up. */
+ return bfd_reloc_continue;
+}
+
+#ifndef PCRELOFFSET
+#define PCRELOFFSET false
+#endif
+
+static reloc_howto_type howto_table[] =
+{
+ {0},
+ {1},
+ {2},
+ {3},
+ {4},
+ {5},
+ HOWTO (R_DIR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "dir32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+ /* {7}, */
+ HOWTO (R_IMAGEBASE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "rva32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+ {010},
+ {011},
+ {012},
+ {013},
+ {014},
+ {015},
+ {016},
+ HOWTO (R_RELBYTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_RELWORD, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_RELLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_PCRBYTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "DISP8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_PCRWORD, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "DISP16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ PCRELOFFSET), /* pcrel_offset */
+ HOWTO (R_PCRLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_i860_reloc, /* special_function */
+ "DISP32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ PCRELOFFSET) /* pcrel_offset */
+};
+
+/* Turn a howto into a reloc nunmber */
+
+#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
+#define BADMAG(x) I860BADMAG(x)
+#define I860 1 /* Customize coffcode.h */
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ (cache_ptr)->howto = howto_table + (dst)->r_type;
+
+/* For 860 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
+ library. On some other COFF targets STYP_BSS is normally
+ STYP_NOLOAD. */
+#define BSS_NOLOAD_IS_SHARED_LIBRARY
+
+/* Compute the addend of a reloc. If the reloc is to a common symbol,
+ the object file contains the value of the common symbol. By the
+ time this is called, the linker may be using a different symbol
+ from a different object file with a different value. Therefore, we
+ hack wildly to locate the original symbol from this file so that we
+ can make the correct adjustment. This macro sets coffsym to the
+ symbol from the original file, and uses it to set the addend value
+ correctly. If this is not a common symbol, the usual addend
+ calculation is done, except that an additional tweak is needed for
+ PC relative relocs.
+ FIXME: This macro refers to symbols and asect; these are from the
+ calling function, not the macro arguments. */
+
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = - coffsym->native->u.syment.n_value; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ if (ptr && howto_table[reloc.r_type].pc_relative) \
+ cache_ptr->addend += asect->vma; \
+ }
+
+/* We use the special COFF backend linker. */
+#define coff_relocate_section _bfd_coff_generic_relocate_section
+
+static reloc_howto_type *
+coff_i860_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+
+ reloc_howto_type *howto;
+
+ howto = howto_table + rel->r_type;
+
+ if (howto->pc_relative)
+ *addendp += sec->vma;
+
+ if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
+ {
+ /* This is a common symbol. The section contents include the
+ size (sym->n_value) as an addend. The relocate_section
+ function will be adding in the final value of the symbol. We
+ need to subtract out the current size in order to get the
+ correct result. */
+
+ BFD_ASSERT (h != NULL);
+
+
+ /* I think we *do* want to bypass this. If we don't, I have seen some data
+ parameters get the wrong relcation address. If I link two versions
+ with and without this section bypassed and then do a binary comparison,
+ the addresses which are different can be looked up in the map. The
+ case in which this section has been bypassed has addresses which correspond
+ to values I can find in the map */
+ *addendp -= sym->n_value;
+ }
+
+ /* If the output symbol is common (in which case this must be a
+ relocateable link), we need to add in the final size of the
+ common symbol. */
+ if (h != NULL && h->root.type == bfd_link_hash_common)
+ *addendp += h->root.u.c.size;
+
+ return howto;
+}
+
+#define coff_rtype_to_howto coff_i860_rtype_to_howto
+
+#include "coffcode.h"
+
+static const bfd_target *
+i3coff_object_p(a)
+ bfd *a;
+{
+ return coff_object_p(a);
+}
+
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ i860coff_vec =
+#endif
+{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
+ "coff-i860", /* name */
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, i3coff_object_p},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c
new file mode 100644
index 00000000000..25455d9ead8
--- /dev/null
+++ b/bfd/coff-i960.c
@@ -0,0 +1,703 @@
+/* BFD back-end for Intel 960 COFF files.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define I960 1
+#define BADMAG(x) I960BADMAG(x)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/i960.h"
+#include "coff/internal.h"
+#include "libcoff.h" /* to allow easier abstraction-breaking */
+
+static boolean coff_i960_is_local_label_name PARAMS ((bfd *, const char *));
+static bfd_reloc_status_type optcall_callback
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type coff_i960_relocate
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *coff_i960_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static boolean coff_i960_start_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean coff_i960_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+static boolean coff_i960_adjust_symndx
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
+ struct internal_reloc *, boolean *));
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+#define COFF_ALIGN_IN_SECTION_HEADER 1
+
+#define GET_SCNHDR_ALIGN bfd_h_get_32
+#define PUT_SCNHDR_ALIGN bfd_h_put_32
+
+/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
+ arbitrarily small. */
+#define COFF_PAGE_SIZE 1
+
+#define COFF_LONG_FILENAMES
+
+/* This set of local label names is taken from gas. */
+
+static boolean
+coff_i960_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return (name[0] == 'L'
+ || (name[0] == '.'
+ && (name[1] == 'C'
+ || name[1] == 'I'
+ || name[1] == '.')));
+}
+
+/* This is just like the usual CALC_ADDEND, but it includes the
+ section VMA for PC relative relocs. */
+#ifndef CALC_ADDEND
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = 0; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
+ cache_ptr->addend += asect->vma; \
+ }
+#endif
+
+#define CALLS 0x66003800 /* Template for 'calls' instruction */
+#define BAL 0x0b000000 /* Template for 'bal' instruction */
+#define BAL_MASK 0x00ffffff
+
+static bfd_reloc_status_type
+optcall_callback (abfd, reloc_entry, symbol_in, data,
+ input_section, ignore_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *ignore_bfd;
+ char **error_message;
+{
+ /* This item has already been relocated correctly, but we may be
+ * able to patch in yet better code - done by digging out the
+ * correct info on this symbol */
+ bfd_reloc_status_type result;
+ coff_symbol_type *cs = coffsymbol(symbol_in);
+
+ /* Don't do anything with symbols which aren't tied up yet,
+ except move the reloc. */
+ if (bfd_is_und_section (cs->symbol.section)) {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* So the target symbol has to be of coff type, and the symbol
+ has to have the correct native information within it */
+ if ((bfd_asymbol_flavour(&cs->symbol) != bfd_target_coff_flavour)
+ || (cs->native == (combined_entry_type *)NULL))
+ {
+ /* This is interesting, consider the case where we're outputting coff
+ from a mix n match input, linking from coff to a symbol defined in a
+ bout file will cause this match to be true. Should I complain? This
+ will only work if the bout symbol is non leaf. */
+ *error_message =
+ (char *) _("uncertain calling convention for non-COFF symbol");
+ result = bfd_reloc_dangerous;
+ }
+ else
+ {
+ switch (cs->native->u.syment.n_sclass)
+ {
+ case C_LEAFSTAT:
+ case C_LEAFEXT:
+ /* This is a call to a leaf procedure, replace instruction with a bal
+ to the correct location. */
+ {
+ union internal_auxent *aux = &((cs->native+2)->u.auxent);
+ int word = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
+ int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
+ BFD_ASSERT(cs->native->u.syment.n_numaux==2);
+
+ /* We replace the original call instruction with a bal to
+ the bal entry point - the offset of which is described in
+ the 2nd auxent of the original symbol. We keep the native
+ sym and auxents untouched, so the delta between the two
+ is the offset of the bal entry point. */
+ word = ((word + olf) & BAL_MASK) | BAL;
+ bfd_put_32(abfd, word, (bfd_byte *) data + reloc_entry->address);
+ }
+ result = bfd_reloc_ok;
+ break;
+ case C_SCALL:
+ /* This is a call to a system call, replace with a calls to # */
+ BFD_ASSERT(0);
+ result = bfd_reloc_ok;
+ break;
+ default:
+ result = bfd_reloc_ok;
+ break;
+ }
+ }
+ return result;
+}
+
+/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
+ appear to correctly handle a reloc against a symbol defined in the
+ same object file. It appears to simply discard such relocs, rather
+ than adding their values into the object file. We handle this here
+ by converting all relocs against defined symbols into relocs
+ against the section symbol, when generating a relocateable output
+ file.
+
+ Note that this function is only called if we are not using the COFF
+ specific backend linker. It only does something when doing a
+ relocateable link, which will almost certainly fail when not
+ generating COFF i960 output, so this function is actually no longer
+ useful. It was used before this target was converted to use the
+ COFF specific backend linker. */
+
+static bfd_reloc_status_type
+coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ asection *osec;
+
+ if (output_bfd == NULL)
+ {
+ /* Not generating relocateable output file. */
+ return bfd_reloc_continue;
+ }
+
+ if (bfd_is_und_section (bfd_get_section (symbol)))
+ {
+ /* Symbol is not defined, so no need to worry about it. */
+ return bfd_reloc_continue;
+ }
+
+ if (bfd_is_com_section (bfd_get_section (symbol)))
+ {
+ /* I don't really know what the right action is for a common
+ symbol. */
+ return bfd_reloc_continue;
+ }
+
+ /* Convert the reloc to use the section symbol. FIXME: This method
+ is ridiculous. */
+ osec = bfd_get_section (symbol)->output_section;
+ if (coff_section_data (output_bfd, osec) != NULL
+ && coff_section_data (output_bfd, osec)->tdata != NULL)
+ reloc_entry->sym_ptr_ptr =
+ (asymbol **) coff_section_data (output_bfd, osec)->tdata;
+ else
+ {
+ const char *sec_name;
+ asymbol **syms, **sym_end;
+
+ sec_name = bfd_get_section_name (output_bfd, osec);
+ syms = bfd_get_outsymbols (output_bfd);
+ sym_end = syms + bfd_get_symcount (output_bfd);
+ for (; syms < sym_end; syms++)
+ {
+ if (bfd_asymbol_name (*syms) != NULL
+ && (*syms)->value == 0
+ && strcmp ((*syms)->section->output_section->name,
+ sec_name) == 0)
+ break;
+ }
+
+ if (syms >= sym_end)
+ abort ();
+
+ reloc_entry->sym_ptr_ptr = syms;
+
+ if (coff_section_data (output_bfd, osec) == NULL)
+ {
+ osec->used_by_bfd =
+ ((PTR) bfd_zalloc (abfd,
+ sizeof (struct coff_section_tdata)));
+ if (osec->used_by_bfd == NULL)
+ return bfd_reloc_overflow;
+ }
+ coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
+ }
+
+ /* Let bfd_perform_relocation do its thing, which will include
+ stuffing the symbol addend into the object file. */
+ return bfd_reloc_continue;
+}
+
+static reloc_howto_type howto_rellong =
+ HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,false, 0,
+ complain_overflow_bitfield, coff_i960_relocate,"rellong", true,
+ 0xffffffff, 0xffffffff, 0);
+static reloc_howto_type howto_iprmed =
+ HOWTO (R_IPRMED, 0, 2, 24,true,0, complain_overflow_signed,
+ coff_i960_relocate, "iprmed ", true, 0x00ffffff, 0x00ffffff, 0);
+static reloc_howto_type howto_optcall =
+ HOWTO (R_OPTCALL, 0,2,24,true,0, complain_overflow_signed,
+ optcall_callback, "optcall", true, 0x00ffffff, 0x00ffffff, 0);
+
+static reloc_howto_type *
+coff_i960_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ default:
+ return 0;
+ case BFD_RELOC_I960_CALLJ:
+ return &howto_optcall;
+ case BFD_RELOC_32:
+ case BFD_RELOC_CTOR:
+ return &howto_rellong;
+ case BFD_RELOC_24_PCREL:
+ return &howto_iprmed;
+ }
+}
+
+/* The real code is in coffcode.h */
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+{ \
+ reloc_howto_type *howto_ptr; \
+ switch ((dst)->r_type) { \
+ case 17: howto_ptr = &howto_rellong; break; \
+ case 25: howto_ptr = &howto_iprmed; break; \
+ case 27: howto_ptr = &howto_optcall; break; \
+ default: howto_ptr = 0; break; \
+ } \
+ (cache_ptr)->howto = howto_ptr; \
+ }
+
+/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
+ appear to correctly handle a reloc against a symbol defined in the
+ same object file. It appears to simply discard such relocs, rather
+ than adding their values into the object file. We handle this by
+ converting all relocs against global symbols into relocs against
+ internal symbols at the start of the section. This routine is
+ called at the start of the linking process, and it creates the
+ necessary symbols. */
+
+static boolean
+coff_i960_start_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd_size_type symesz = bfd_coff_symesz (abfd);
+ asection *o;
+ bfd_byte *esym;
+
+ if (! info->relocateable)
+ return true;
+
+ esym = (bfd_byte *) bfd_malloc (symesz);
+ if (esym == NULL)
+ return false;
+
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
+ return false;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct internal_syment isym;
+
+ strncpy (isym._n._n_name, o->name, SYMNMLEN);
+ isym.n_value = 0;
+ isym.n_scnum = o->target_index;
+ isym.n_type = T_NULL;
+ isym.n_sclass = C_STAT;
+ isym.n_numaux = 0;
+
+ bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
+
+ if (bfd_write (esym, symesz, 1, abfd) != symesz)
+ {
+ free (esym);
+ return false;
+ }
+
+ obj_raw_syment_count (abfd) += 1;
+ }
+
+ free (esym);
+
+ return true;
+}
+
+/* The reloc processing routine for the optimized COFF linker. */
+
+static boolean
+coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, syms, sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma addend;
+ bfd_vma val;
+ reloc_howto_type *howto;
+ bfd_reloc_status_type rstat = bfd_reloc_ok;
+ boolean done;
+
+ symndx = rel->r_symndx;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ }
+
+ if (sym != NULL && sym->n_scnum != 0)
+ addend = - sym->n_value;
+ else
+ addend = 0;
+
+ switch (rel->r_type)
+ {
+ case 17: howto = &howto_rellong; break;
+ case 25: howto = &howto_iprmed; break;
+ case 27: howto = &howto_optcall; break;
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ asection *sec;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
+ else
+ {
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma);
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ done = false;
+
+ if (howto->type == R_OPTCALL && ! info->relocateable && symndx != -1)
+ {
+ int class;
+
+ if (h != NULL)
+ class = h->class;
+ else
+ class = sym->n_sclass;
+
+ switch (class)
+ {
+ case C_NULL:
+ /* This symbol is apparently not from a COFF input file.
+ We warn, and then assume that it is not a leaf
+ function. */
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info,
+ _("uncertain calling convention for non-COFF symbol"),
+ input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ break;
+ case C_LEAFSTAT:
+ case C_LEAFEXT:
+ /* This is a call to a leaf procedure; use the bal
+ instruction. */
+ {
+ long olf;
+ unsigned long word;
+
+ if (h != NULL)
+ {
+ BFD_ASSERT (h->numaux == 2);
+ olf = h->aux[1].x_bal.x_balntry;
+ }
+ else
+ {
+ bfd_byte *esyms;
+ union internal_auxent aux;
+
+ BFD_ASSERT (sym->n_numaux == 2);
+ esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
+ esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
+ bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
+ sym->n_sclass, 1, sym->n_numaux,
+ (PTR) &aux);
+ olf = aux.x_bal.x_balntry;
+ }
+
+ word = bfd_get_32 (input_bfd,
+ (contents
+ + (rel->r_vaddr - input_section->vma)));
+ word = ((word + olf - val) & BAL_MASK) | BAL;
+ bfd_put_32 (input_bfd,
+ word,
+ (contents
+ + (rel->r_vaddr - input_section->vma)));
+ done = true;
+ }
+ break;
+ case C_SCALL:
+ BFD_ASSERT (0);
+ break;
+ }
+ }
+
+ if (! done)
+ {
+ if (howto->pc_relative)
+ addend += input_section->vma;
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents,
+ rel->r_vaddr - input_section->vma,
+ val, addend);
+ }
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+ if (name == NULL)
+ return false;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Adjust the symbol index of any reloc against a global symbol to
+ instead be a reloc against the internal symbol we created specially
+ for the section. */
+
+/*ARGSUSED*/
+static boolean
+coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
+ bfd *obfd;
+ struct bfd_link_info *info;
+ bfd *ibfd;
+ asection *sec;
+ struct internal_reloc *irel;
+ boolean *adjustedp;
+{
+ struct coff_link_hash_entry *h;
+
+ *adjustedp = false;
+
+ h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
+ if (h == NULL
+ || (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak))
+ return true;
+
+ irel->r_symndx = h->root.u.def.section->output_section->target_index - 1;
+ *adjustedp = true;
+
+ return true;
+}
+
+#define coff_bfd_is_local_label_name coff_i960_is_local_label_name
+
+#define coff_start_final_link coff_i960_start_final_link
+
+#define coff_relocate_section coff_i960_relocate_section
+
+#define coff_adjust_symndx coff_i960_adjust_symndx
+
+#define coff_bfd_reloc_type_lookup coff_i960_reloc_type_lookup
+
+#include "coffcode.h"
+
+const bfd_target icoff_little_vec =
+{
+ "coff-Intel-little", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+
+
+const bfd_target icoff_big_vec =
+{
+ "coff-Intel-big", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-m68k.c b/bfd/coff-m68k.c
new file mode 100644
index 00000000000..5a06b17d50b
--- /dev/null
+++ b/bfd/coff-m68k.c
@@ -0,0 +1,480 @@
+/* BFD back-end for Motorola 68000 COFF binaries.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/m68k.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+/* This source file is compiled multiple times for various m68k COFF
+ variants. The following macros control its behaviour:
+
+ TARGET_SYM
+ The C name of the BFD target vector. The default is m68kcoff_vec.
+ TARGET_NAME
+ The user visible target name. The default is "coff-m68k".
+ NAMES_HAVE_UNDERSCORE
+ Whether symbol names have an underscore.
+ ONLY_DECLARE_RELOCS
+ Only declare the relocation howto array. Don't actually compile
+ it. The actual array will be picked up in another version of the
+ file.
+ STATIC_RELOCS
+ Make the relocation howto array, and associated functions, static.
+ COFF_COMMON_ADDEND
+ If this is defined, then, for a relocation against a common
+ symbol, the object file holds the value (the size) of the common
+ symbol. If this is not defined, then, for a relocation against a
+ common symbol, the object file holds zero. */
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
+
+#ifndef COFF_PAGE_SIZE
+/* The page size is a guess based on ELF. */
+#define COFF_PAGE_SIZE 0x2000
+#endif
+
+#ifndef COFF_COMMON_ADDEND
+#define RELOC_SPECIAL_FN 0
+#else
+static bfd_reloc_status_type m68kcoff_common_addend_special_fn
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *m68kcoff_common_addend_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
+#define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn
+#endif
+
+static boolean m68k_coff_is_local_label_name PARAMS ((bfd *, const char *));
+
+/* On the delta, a symbol starting with L% is local. We won't see
+ such a symbol on other platforms, so it should be safe to always
+ consider it local here. */
+
+static boolean
+m68k_coff_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (name[0] == 'L' && name[1] == '%')
+ return true;
+
+ return _bfd_coff_is_local_label_name (abfd, name);
+}
+
+#ifndef STATIC_RELOCS
+/* Clean up namespace. */
+#define m68kcoff_howto_table _bfd_m68kcoff_howto_table
+#define m68k_rtype2howto _bfd_m68kcoff_rtype2howto
+#define m68k_howto2rtype _bfd_m68kcoff_howto2rtype
+#define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
+#endif
+
+#ifdef ONLY_DECLARE_RELOCS
+extern reloc_howto_type m68kcoff_howto_table[];
+#else
+#ifdef STATIC_RELOCS
+static
+#endif
+reloc_howto_type m68kcoff_howto_table[] =
+{
+ HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false),
+ HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false),
+ HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false),
+ HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false),
+ HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false),
+};
+#endif /* not ONLY_DECLARE_RELOCS */
+
+#ifndef BADMAG
+#define BADMAG(x) M68KBADMAG(x)
+#endif
+#define M68 1 /* Customize coffcode.h */
+
+/* Turn a howto into a reloc number */
+
+#ifdef ONLY_DECLARE_RELOCS
+extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
+extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
+extern reloc_howto_type *m68k_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+#else
+#ifdef STATIC_RELOCS
+static
+#endif
+void
+m68k_rtype2howto(internal, relocentry)
+ arelent *internal;
+ int relocentry;
+{
+ switch (relocentry)
+ {
+ case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
+ case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
+ case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
+ case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
+ case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
+ case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
+ case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
+ }
+}
+
+#ifdef STATIC_RELOCS
+static
+#endif
+int
+m68k_howto2rtype (internal)
+ reloc_howto_type *internal;
+{
+ if (internal->pc_relative)
+ {
+ switch (internal->bitsize)
+ {
+ case 32: return R_PCRLONG;
+ case 16: return R_PCRWORD;
+ case 8: return R_PCRBYTE;
+ }
+ }
+ else
+ {
+ switch (internal->bitsize)
+ {
+ case 32: return R_RELLONG;
+ case 16: return R_RELWORD;
+ case 8: return R_RELBYTE;
+ }
+ }
+ return R_RELLONG;
+}
+
+#ifdef STATIC_RELOCS
+static
+#endif
+reloc_howto_type *
+m68k_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ default: return NULL;
+ case BFD_RELOC_8: return m68kcoff_howto_table + 0;
+ case BFD_RELOC_16: return m68kcoff_howto_table + 1;
+ case BFD_RELOC_CTOR:
+ case BFD_RELOC_32: return m68kcoff_howto_table + 2;
+ case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
+ case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4;
+ case BFD_RELOC_32_PCREL: return m68kcoff_howto_table + 5;
+ /* FIXME: There doesn't seem to be a code for R_RELLONG_NEG. */
+ }
+ /*NOTREACHED*/
+}
+
+#endif /* not ONLY_DECLARE_RELOCS */
+
+#define RTYPE2HOWTO(internal, relocentry) \
+ m68k_rtype2howto(internal, (relocentry)->r_type)
+
+#define SELECT_RELOC(external, internal) \
+ external.r_type = m68k_howto2rtype (internal)
+
+#define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
+
+#ifndef COFF_COMMON_ADDEND
+#ifndef coff_rtype_to_howto
+
+#define coff_rtype_to_howto m68kcoff_rtype_to_howto
+
+static reloc_howto_type *m68kcoff_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
+
+/*ARGSUSED*/
+static reloc_howto_type *
+m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+ arelent relent;
+ reloc_howto_type *howto;
+
+ RTYPE2HOWTO (&relent, rel);
+
+ howto = relent.howto;
+
+ if (howto->pc_relative)
+ *addendp += sec->vma;
+
+ return howto;
+}
+
+#endif /* ! defined (coff_rtype_to_howto) */
+#endif /* ! defined (COFF_COMMON_ADDEND) */
+
+#ifdef COFF_COMMON_ADDEND
+
+/* If COFF_COMMON_ADDEND is defined, then when using m68k COFF the
+ value stored in the .text section for a reference to a common
+ symbol is the value itself plus any desired offset. (taken from
+ work done by Ian Taylor, Cygnus Support, for I386 COFF). */
+
+/* If we are producing relocateable output, we need to do some
+ adjustments to the object file that are not done by the
+ bfd_perform_relocation function. This function is called by every
+ reloc type to make any required adjustments. */
+
+static bfd_reloc_status_type
+m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ symvalue diff;
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ if (bfd_is_com_section (symbol->section))
+ {
+ /* We are relocating a common symbol. The current value in the
+ object file is ORIG + OFFSET, where ORIG is the value of the
+ common symbol as seen by the object file when it was compiled
+ (this may be zero if the symbol was undefined) and OFFSET is
+ the offset into the common symbol (normally zero, but may be
+ non-zero when referring to a field in a common structure).
+ ORIG is the negative of reloc_entry->addend, which is set by
+ the CALC_ADDEND macro below. We want to replace the value in
+ the object file with NEW + OFFSET, where NEW is the value of
+ the common symbol which we are going to put in the final
+ object file. NEW is symbol->value. */
+ diff = symbol->value + reloc_entry->addend;
+ }
+ else
+ {
+ /* For some reason bfd_perform_relocation always effectively
+ ignores the addend for a COFF target when producing
+ relocateable output. This seems to be always wrong for 386
+ COFF, so we handle the addend here instead. */
+ diff = reloc_entry->addend;
+ }
+
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
+
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, x, addr);
+ }
+ break;
+
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_32 (abfd, x, addr);
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ /* Now let bfd_perform_relocation finish everything up. */
+ return bfd_reloc_continue;
+}
+
+/* Compute the addend of a reloc. If the reloc is to a common symbol,
+ the object file contains the value of the common symbol. By the
+ time this is called, the linker may be using a different symbol
+ from a different object file with a different value. Therefore, we
+ hack wildly to locate the original symbol from this file so that we
+ can make the correct adjustment. This macro sets coffsym to the
+ symbol from the original file, and uses it to set the addend value
+ correctly. If this is not a common symbol, the usual addend
+ calculation is done, except that an additional tweak is needed for
+ PC relative relocs.
+ FIXME: This macro refers to symbols and asect; these are from the
+ calling function, not the macro arguments. */
+
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = - coffsym->native->u.syment.n_value; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ if (ptr && (reloc.r_type == R_PCRBYTE \
+ || reloc.r_type == R_PCRWORD \
+ || reloc.r_type == R_PCRLONG)) \
+ cache_ptr->addend += asect->vma; \
+ }
+
+#ifndef coff_rtype_to_howto
+
+/* coff-m68k.c uses the special COFF backend linker. We need to
+ adjust common symbols. */
+
+/*ARGSUSED*/
+static reloc_howto_type *
+m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+ arelent relent;
+ reloc_howto_type *howto;
+
+ RTYPE2HOWTO (&relent, rel);
+
+ howto = relent.howto;
+
+ if (howto->pc_relative)
+ *addendp += sec->vma;
+
+ if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
+ {
+ /* This is a common symbol. The section contents include the
+ size (sym->n_value) as an addend. The relocate_section
+ function will be adding in the final value of the symbol. We
+ need to subtract out the current size in order to get the
+ correct result. */
+ BFD_ASSERT (h != NULL);
+ *addendp -= sym->n_value;
+ }
+
+ /* If the output symbol is common (in which case this must be a
+ relocateable link), we need to add in the final size of the
+ common symbol. */
+ if (h != NULL && h->root.type == bfd_link_hash_common)
+ *addendp += h->root.u.c.size;
+
+ return howto;
+}
+
+#define coff_rtype_to_howto m68kcoff_common_addend_rtype_to_howto
+
+#endif /* ! defined (coff_rtype_to_howto) */
+
+#endif /* COFF_COMMON_ADDEND */
+
+#define coff_bfd_is_local_label_name m68k_coff_is_local_label_name
+
+#define coff_relocate_section _bfd_coff_generic_relocate_section
+
+#include "coffcode.h"
+
+#ifndef TARGET_SYM
+#define TARGET_SYM m68kcoff_vec
+#endif
+
+#ifndef TARGET_NAME
+#define TARGET_NAME "coff-m68k"
+#endif
+
+const bfd_target TARGET_SYM =
+{
+ TARGET_NAME,
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+#ifdef NAMES_HAVE_UNDERSCORE
+ '_',
+#else
+ 0, /* leading underscore */
+#endif
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE
+};
diff --git a/bfd/coff-m88k.c b/bfd/coff-m88k.c
new file mode 100644
index 00000000000..8da0b052530
--- /dev/null
+++ b/bfd/coff-m88k.c
@@ -0,0 +1,330 @@
+/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
+ Copyright 1990, 91, 92, 93, 94, 95, 97, 1998 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define M88 1 /* Customize various include files */
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/m88k.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+static boolean m88k_is_local_label_name PARAMS ((bfd *, const char *));
+static bfd_reloc_status_type m88k_special_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
+static void reloc_processing
+ PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+#define GET_SCNHDR_NRELOC bfd_h_get_32
+#define GET_SCNHDR_NLNNO bfd_h_get_32
+
+/* On coff-m88k, local labels start with '@'. */
+
+#define coff_bfd_is_local_label_name m88k_is_local_label_name
+
+static boolean
+m88k_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return name[0] == '@';
+}
+
+static bfd_reloc_status_type
+m88k_special_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ reloc_howto_type *howto = reloc_entry->howto;
+
+ switch (howto->type)
+ {
+ case R_HVRT16:
+ case R_LVRT16:
+ if (output_bfd != (bfd *) NULL)
+ {
+ /* This is a partial relocation, and we want to apply the
+ relocation to the reloc entry rather than the raw data.
+ Modify the reloc inplace to reflect what we now know. */
+
+ reloc_entry->address += input_section->output_offset;
+ }
+ else
+ {
+ bfd_vma output_base = 0;
+ bfd_vma addr = reloc_entry->address;
+ bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
+ asection *reloc_target_output_section;
+ long relocation = 0;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ reloc_target_output_section = symbol->section->output_section;
+
+ /* Convert input-section-relative symbol value to absolute. */
+ if (output_bfd)
+ output_base = 0;
+ else
+ output_base = reloc_target_output_section->vma;
+
+ relocation += output_base + symbol->section->output_offset;
+
+ /* Add in supplied addend. */
+ relocation += ((reloc_entry->addend << howto->bitsize) + x);
+
+ reloc_entry->addend = 0;
+
+ relocation >>= (bfd_vma) howto->rightshift;
+
+ /* Shift everything up to where it's going to be used */
+
+ relocation <<= (bfd_vma) howto->bitpos;
+
+ if (relocation)
+ bfd_put_16 (abfd, relocation, (unsigned char *) data + addr);
+ }
+
+ /* If we are not producing relocateable output, return an error if
+ the symbol is not defined. */
+ if (bfd_is_und_section (symbol->section) && output_bfd == (bfd *) NULL)
+ return bfd_reloc_undefined;
+
+ return bfd_reloc_ok;
+
+ default:
+ if (output_bfd != (bfd *) NULL)
+ {
+ /* This is a partial relocation, and we want to apply the
+ relocation to the reloc entry rather than the raw data.
+ Modify the reloc inplace to reflect what we now know. */
+
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+ break;
+ }
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_ok;
+}
+
+static reloc_howto_type howto_table[] =
+{
+ HOWTO (R_PCR16L, /* type */
+ 02, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ m88k_special_reloc, /* special_function */
+ "PCR16L", /* name */
+ false, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_PCR26L, /* type */
+ 02, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ m88k_special_reloc, /* special_function */
+ "PCR26L", /* name */
+ false, /* partial_inplace */
+ 0x03ffffff, /* src_mask */
+ 0x03ffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_VRT16, /* type */
+ 00, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ m88k_special_reloc, /* special_function */
+ "VRT16", /* name */
+ false, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_HVRT16, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ m88k_special_reloc, /* special_function */
+ "HVRT16", /* name */
+ false, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_LVRT16, /* type */
+ 00, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ m88k_special_reloc, /* special_function */
+ "LVRT16", /* name */
+ false, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_VRT32, /* type */
+ 00, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ m88k_special_reloc, /* special_function */
+ "VRT32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+};
+
+/* Code to turn an external r_type into a pointer to an entry in the
+ above howto table. */
+static void
+rtype2howto (cache_ptr, dst)
+ arelent *cache_ptr;
+ struct internal_reloc *dst;
+{
+ if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
+ {
+ cache_ptr->howto = howto_table + dst->r_type - R_PCR16L;
+ }
+ else
+ {
+ BFD_ASSERT (0);
+ }
+}
+
+#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
+
+
+/* Code to swap in the reloc offset */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
+
+
+#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void
+reloc_processing (relent, reloc, symbols, abfd, section)
+ arelent *relent;
+ struct internal_reloc *reloc;
+ asymbol **symbols;
+ bfd *abfd;
+ asection *section;
+{
+ relent->address = reloc->r_vaddr;
+ rtype2howto (relent, reloc);
+
+ if (((int) reloc->r_symndx) > 0)
+ {
+ relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
+ }
+ else
+ {
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+
+ relent->addend = reloc->r_offset;
+ relent->address -= section->vma;
+}
+
+#define BADMAG(x) MC88BADMAG(x)
+#include "coffcode.h"
+
+#undef coff_write_armap
+
+const bfd_target m88kbcs_vec =
+{
+ "coff-m88kbcs", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
new file mode 100644
index 00000000000..d787096e379
--- /dev/null
+++ b/bfd/coff-mcore.c
@@ -0,0 +1,703 @@
+/* BFD back-end for Motorolla MCore COFF/PE
+ Copyright 1999
+ Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/mcore.h"
+#include "coff/internal.h"
+#include "coff/pe.h"
+#include "libcoff.h"
+
+#ifdef BADMAG
+#undef BADMAG
+#endif
+#define BADMAG(x) MCOREBADMAG(x)
+
+#ifndef NUM_ELEM
+#define NUM_ELEM(A) (sizeof (A) / sizeof (A)[0])
+#endif
+
+/* This file is compiled more than once, but we only compile the
+ final_link routine once. */
+extern boolean mcore_bfd_coff_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+static struct bfd_link_hash_table * coff_mcore_link_hash_table_create
+ PARAMS ((bfd *));
+static bfd_reloc_status_type mcore_coff_unsupported_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean in_reloc_p
+ PARAMS ((bfd *, reloc_howto_type *));
+static boolean coff_mcore_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+static reloc_howto_type * mcore_coff_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static reloc_howto_type * coff_mcore_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
+static const bfd_target * pe_object_p
+ PARAMS ((bfd *));
+
+
+
+/* The NT loader points the toc register to &toc + 32768, in order to
+ use the complete range of a 16-bit displacement. We have to adjust
+ for this when we fix up loads displaced off the toc reg. */
+#define TOC_LOAD_ADJUSTMENT (-32768)
+#define TOC_SECTION_NAME ".private.toc"
+
+/* The main body of code is in coffcode.h. */
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+
+static reloc_howto_type mcore_coff_howto_table[] =
+{
+ /* Unused: */
+ HOWTO (IMAGE_REL_MCORE_ABSOLUTE,/* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* dont complain_on_overflow */
+ 0, /* special_function */
+ "ABSOLUTE", /* name */
+ false, /* partial_inplace */
+ 0x00, /* src_mask */
+ 0x00, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (IMAGE_REL_MCORE_ADDR32,/* 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 */
+ "ADDR32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions.
+ Should not appear in object files. */
+ HOWTO (IMAGE_REL_MCORE_PCREL_IMM8BY4, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mcore_coff_unsupported_reloc, /* special_function */
+ "IMM8BY4", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* bsr/bt/bf/br instructions; 11 bits + 1 zero bit
+ Span 2k instructions == 4k bytes.
+ Only useful pieces at the relocated address are the opcode (5 bits) */
+ HOWTO (IMAGE_REL_MCORE_PCREL_IMM11BY2,/* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ NULL, /* special_function */
+ "IMM11BY2", /* name */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0x7ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */
+ HOWTO (IMAGE_REL_MCORE_PCREL_IMM4BY2, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 4, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mcore_coff_unsupported_reloc,/* special_function */
+ "IMM4BY2", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 32-bit pc-relative. Eventually this will help support PIC code. */
+ HOWTO (IMAGE_REL_MCORE_PCREL_32,/* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PCREL_32", /* name */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Like PCREL_IMM11BY2, this relocation indicates that there is a
+ 'jsri' at the specified address. There is a separate relocation
+ entry for the literal pool entry that it references, but we
+ might be able to change the jsri to a bsr if the target turns out
+ to be close enough [even though we won't reclaim the literal pool
+ entry, we'll get some runtime efficiency back]. Note that this
+ is a relocation that we are allowed to safely ignore. */
+ HOWTO (IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2,/* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ NULL, /* special_function */
+ "JSR_IMM11BY2", /* name */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0x7ff, /* dst_mask */
+ true) /* pcrel_offset */
+};
+
+/* Extend the coff_link_hash_table structure with a few M*Core specific fields.
+ This allows us to store global data here without actually creating any
+ global variables, which is a no-no in the BFD world. */
+typedef struct coff_mcore_link_hash_table
+{
+ /* The original coff_link_hash_table structure. MUST be first field. */
+ struct coff_link_hash_table root;
+
+ bfd * bfd_of_toc_owner;
+ long int global_toc_size;
+ long int import_table_size;
+ long int first_thunk_address;
+ long int thunk_size;
+}
+mcore_hash_table;
+
+/* Get the MCore coff linker hash table from a link_info structure. */
+#define coff_mcore_hash_table(info) \
+ ((mcore_hash_table *) ((info)->hash))
+
+/* Create an MCore coff linker hash table. */
+static struct bfd_link_hash_table *
+coff_mcore_link_hash_table_create (abfd)
+ bfd * abfd;
+{
+ mcore_hash_table * ret;
+
+ ret = ((mcore_hash_table *) bfd_alloc (abfd, sizeof (* ret)));
+ if (ret == (mcore_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_coff_link_hash_table_init
+ (& ret->root, abfd, _bfd_coff_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->bfd_of_toc_owner = NULL;
+ ret->global_toc_size = 0;
+ ret->import_table_size = 0;
+ ret->first_thunk_address = 0;
+ ret->thunk_size = 0;
+
+ return & ret->root.root;
+}
+
+/*ARGSUSED*/
+static bfd_reloc_status_type
+mcore_coff_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd * abfd;
+ arelent * reloc_entry;
+ asymbol * symbol;
+ PTR data;
+ asection * input_section;
+ bfd * output_bfd;
+ char ** error_message;
+{
+ BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
+
+ _bfd_error_handler (_("%s: Relocation %s (%d) is not currently supported.\n"),
+ bfd_get_filename (abfd),
+ reloc_entry->howto->name,
+ reloc_entry->howto->type);
+
+ return bfd_reloc_notsupported;
+}
+
+
+/* A cheesy little macro to make the code a little more readable. */
+#define HOW2MAP(bfd_rtype, mcore_rtype) \
+ case bfd_rtype: return & mcore_coff_howto_table [mcore_rtype]
+
+static reloc_howto_type *
+mcore_coff_reloc_type_lookup (abfd, code)
+ bfd * abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ HOW2MAP (BFD_RELOC_32, IMAGE_REL_MCORE_ADDR32);
+ HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM8BY4, IMAGE_REL_MCORE_PCREL_IMM8BY4);
+ HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM11BY2, IMAGE_REL_MCORE_PCREL_IMM11BY2);
+ HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM4BY2, IMAGE_REL_MCORE_PCREL_IMM4BY2);
+ HOW2MAP (BFD_RELOC_32_PCREL, IMAGE_REL_MCORE_PCREL_32);
+ HOW2MAP (BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2);
+ default:
+ return NULL;
+ }
+ /*NOTREACHED*/
+}
+
+#undef HOW2MAP
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ (cache_ptr)->howto = mcore_coff_howto_table + (dst)->r_type;
+
+static reloc_howto_type *
+coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd * abfd;
+ asection * sec;
+ struct internal_reloc * rel;
+ struct coff_link_hash_entry * h;
+ struct internal_syment * sym;
+ bfd_vma * addendp;
+{
+ reloc_howto_type * howto;
+
+
+ if (rel->r_type >= NUM_ELEM (mcore_coff_howto_table))
+ return NULL;
+
+ howto = mcore_coff_howto_table + rel->r_type;
+
+ if (howto->pc_relative)
+ {
+ * addendp = sec->vma - 2; /* XXX guess - is this right ? */
+
+ /* If the symbol is defined, then the generic code is going to
+ add back the symbol value in order to cancel out an
+ adjustment it made to the addend. However, we set the addend
+ to 0 at the start of this function. We need to adjust here,
+ to avoid the adjustment the generic code will make. FIXME:
+ This is getting a bit hackish. */
+ if (sym != NULL && sym->n_scnum != 0)
+ * addendp -= sym->n_value;
+ }
+ else
+ * addendp = 0;
+
+ return howto;
+}
+
+/* Return true if this relocation should
+ appear in the output .reloc section. */
+static boolean in_reloc_p (abfd, howto)
+ bfd * abfd;
+ reloc_howto_type * howto;
+{
+ return ! howto->pc_relative;
+}
+
+/* The reloc processing routine for the optimized COFF linker. */
+static boolean
+coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, syms, sections)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+ bfd * input_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ struct internal_reloc * relocs;
+ struct internal_syment * syms;
+ asection ** sections;
+{
+ struct internal_reloc * rel;
+ struct internal_reloc * relend;
+ boolean hihalf;
+ bfd_vma hihalf_val;
+
+ /* If we are performing a relocateable link, we don't need to do a
+ thing. The caller will take care of adjusting the reloc
+ addresses and symbol indices. */
+ if (info->relocateable)
+ return true;
+
+ BFD_ASSERT (input_bfd->xvec->byteorder
+ == output_bfd->xvec->byteorder);
+
+ hihalf = false;
+ hihalf_val = 0;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+
+ for (; rel < relend; rel++)
+ {
+ asection * toc_section = NULL;
+ bfd_vma relocation;
+ long symndx;
+ struct internal_syment * sym;
+ bfd_vma val;
+ bfd_vma addend;
+ bfd_reloc_status_type rstat;
+ bfd_byte * loc;
+ unsigned short r_type = rel->r_type;
+ reloc_howto_type * howto = NULL;
+ struct coff_link_hash_entry * h;
+ const char * my_name;
+
+ symndx = rel->r_symndx;
+ loc = contents + rel->r_vaddr - input_section->vma;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ }
+
+ /* Get the howto and initialise the addend. */
+ howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
+ sym, & addend);
+ if (howto == NULL)
+ return false;
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ if (symndx == -1)
+ my_name = "*ABS*";
+ else
+ {
+ asection * sec = sections[symndx];
+
+ val = (sym->n_value
+ + sec->output_section->vma
+ + sec->output_offset);
+
+ if (sym == NULL)
+ my_name = "*unknown*";
+ else if ( sym->_n._n_n._n_zeroes == 0
+ && sym->_n._n_n._n_offset != 0)
+ my_name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
+ else
+ {
+ static char buf [SYMNMLEN + 1];
+
+ strncpy (buf, sym->_n._n_name, SYMNMLEN);
+ buf[SYMNMLEN] = '\0';
+ my_name = buf;
+ }
+ }
+ }
+ else
+ {
+ if ( h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection * sec = h->root.u.def.section;
+
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+
+ my_name = h->root.root.string;
+ }
+
+ rstat = bfd_reloc_ok;
+
+ /* Each case must do its own relocation, setting rstat appropriately. */
+ switch (r_type)
+ {
+ default:
+ _bfd_error_handler (_("%s: unsupported relocation type 0x%02x"),
+ bfd_get_filename (input_bfd), r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+
+ case IMAGE_REL_MCORE_ABSOLUTE:
+ fprintf (stderr,
+ _("Warning: unsupported reloc %s <file %s, section %s>\n"),
+ howto->name,
+ bfd_get_filename (input_bfd),
+ input_section->name);
+
+ fprintf (stderr,"sym %ld (%s), r_vaddr %ld (%lx)\n",
+ rel->r_symndx, my_name, (long) rel->r_vaddr,
+ (unsigned long) rel->r_vaddr);
+ break;
+
+ case IMAGE_REL_MCORE_PCREL_IMM8BY4:
+ case IMAGE_REL_MCORE_PCREL_IMM11BY2:
+ case IMAGE_REL_MCORE_PCREL_IMM4BY2:
+ case IMAGE_REL_MCORE_PCREL_32:
+ case IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2:
+ case IMAGE_REL_MCORE_ADDR32:
+ rstat = _bfd_relocate_contents (howto, input_bfd, val, loc);
+ break;
+ }
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+
+ case bfd_reloc_ok:
+ break;
+
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, my_name, howto->name,
+ (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+/* Tailor coffcode.h -- macro heaven. */
+
+/* We use the special COFF backend linker, with our own special touch. */
+
+#define coff_bfd_reloc_type_lookup mcore_coff_reloc_type_lookup
+#define coff_relocate_section coff_mcore_relocate_section
+#define coff_rtype_to_howto coff_mcore_rtype_to_howto
+
+#define SELECT_RELOC(internal, howto) {internal.r_type = howto->type;}
+
+#define COFF_PAGE_SIZE 0x1000
+
+#include "coffcode.h"
+
+static const bfd_target *
+pe_object_p (abfd)
+ bfd * abfd;
+{
+#ifdef COFF_IMAGE_WITH_PE
+ /* We need to hack badly to handle a PE image correctly. In PE
+ images created by the GNU linker, the offset to the COFF header
+ is always the size. However, this is not the case in images
+ generated by other PE linkers. The PE format stores a four byte
+ offset to the PE signature just before the COFF header at
+ location 0x3c of the file. We pick up that offset, verify that
+ the PE signature is there, and then set ourselves up to read in
+ the COFF header. */
+ {
+ bfd_byte ext_offset[4];
+ file_ptr offset;
+ bfd_byte ext_signature[4];
+ unsigned long signature;
+
+ if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0
+ || bfd_read (ext_offset, 1, 4, abfd) != 4)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ offset = bfd_h_get_32 (abfd, ext_offset);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0
+ || bfd_read (ext_signature, 1, 4, abfd) != 4)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+
+ return NULL;
+ }
+
+ signature = bfd_h_get_32 (abfd, ext_signature);
+
+ if (signature != 0x4550)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Here is the hack. coff_object_p wants to read filhsz bytes to
+ pick up the COFF header. We adjust so that that will work. 20
+ is the size of the mips COFF filehdr. */
+ if (bfd_seek (abfd, (bfd_tell (abfd) - bfd_coff_filhsz (abfd) + 20),
+ SEEK_SET) != 0)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+
+ return NULL;
+ }
+ }
+#endif
+
+ return coff_object_p (abfd);
+}
+
+/* The transfer vectors that lead the outside world to all of the above. */
+
+const bfd_target
+TARGET_BIG_SYM =
+{
+ TARGET_BIG_NAME,
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+
+ 0, /* leading char */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ { _bfd_dummy_target,
+ pe_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, /* _bfd_dummy_target */
+ pe_object_p
+ },
+ { bfd_false,
+ coff_mkobject,
+ _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false
+ },
+ { bfd_false,
+ coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+
+const bfd_target
+TARGET_LITTLE_SYM =
+{
+ TARGET_LITTLE_NAME,
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+
+ 0, /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {
+ _bfd_dummy_target,
+ pe_object_p, /* bfd_check_format */
+ bfd_generic_archive_p,
+ pe_object_p
+ },
+ {
+ bfd_false,
+ coff_mkobject,
+ _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false
+ },
+ {
+ bfd_false,
+ coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
new file mode 100644
index 00000000000..051eb86b166
--- /dev/null
+++ b/bfd/coff-mips.c
@@ -0,0 +1,2726 @@
+/* BFD back-end for MIPS Extended-Coff files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Original version by Per Bothner.
+ Full support added by Ian Lance Taylor, ian@cygnus.com.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/ecoff.h"
+#include "coff/mips.h"
+#include "libcoff.h"
+#include "libecoff.h"
+
+/* Prototypes for static functions. */
+
+static boolean mips_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
+static void mips_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
+ struct internal_reloc *));
+static void mips_ecoff_swap_reloc_out PARAMS ((bfd *,
+ const struct internal_reloc *,
+ PTR));
+static void mips_adjust_reloc_in PARAMS ((bfd *,
+ const struct internal_reloc *,
+ arelent *));
+static void mips_adjust_reloc_out PARAMS ((bfd *, const arelent *,
+ struct internal_reloc *));
+static bfd_reloc_status_type mips_generic_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static bfd_reloc_status_type mips_refhi_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static bfd_reloc_status_type mips_reflo_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static bfd_reloc_status_type mips_gprel_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static bfd_reloc_status_type mips_relhi_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static bfd_reloc_status_type mips_rello_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static bfd_reloc_status_type mips_switch_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+static void mips_relocate_hi PARAMS ((struct internal_reloc *refhi,
+ struct internal_reloc *reflo,
+ bfd *input_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ size_t adjust,
+ bfd_vma relocation,
+ boolean pcrel));
+static boolean mips_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
+ bfd *, asection *,
+ bfd_byte *, PTR));
+static boolean mips_read_relocs PARAMS ((bfd *, asection *));
+static boolean mips_relax_section PARAMS ((bfd *, asection *,
+ struct bfd_link_info *,
+ boolean *));
+static boolean mips_relax_pcrel16 PARAMS ((struct bfd_link_info *, bfd *,
+ asection *,
+ struct ecoff_link_hash_entry *,
+ bfd_byte *, bfd_vma));
+static reloc_howto_type *mips_bfd_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+
+
+/* ECOFF has COFF sections, but the debugging information is stored in
+ a completely different format. ECOFF targets use some of the
+ swapping routines from coffswap.h, and some of the generic COFF
+ routines in coffgen.c, but, unlike the real COFF targets, do not
+ use coffcode.h itself.
+
+ Get the generic COFF swapping routines, except for the reloc,
+ symbol, and lineno ones. Give them ECOFF names. */
+#define MIPSECOFF
+#define NO_COFF_RELOCS
+#define NO_COFF_SYMBOLS
+#define NO_COFF_LINENOS
+#define coff_swap_filehdr_in mips_ecoff_swap_filehdr_in
+#define coff_swap_filehdr_out mips_ecoff_swap_filehdr_out
+#define coff_swap_aouthdr_in mips_ecoff_swap_aouthdr_in
+#define coff_swap_aouthdr_out mips_ecoff_swap_aouthdr_out
+#define coff_swap_scnhdr_in mips_ecoff_swap_scnhdr_in
+#define coff_swap_scnhdr_out mips_ecoff_swap_scnhdr_out
+#include "coffswap.h"
+
+/* Get the ECOFF swapping routines. */
+#define ECOFF_32
+#include "ecoffswap.h"
+
+/* How to process the various relocs types. */
+
+static reloc_howto_type mips_howto_table[] =
+{
+ /* Reloc type 0 is ignored. The reloc reading code ensures that
+ this is a reference to the .abs section, which will cause
+ bfd_perform_relocation to do nothing. */
+ HOWTO (MIPS_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, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 16 bit reference to a symbol, normally from a data section. */
+ HOWTO (MIPS_R_REFHALF, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mips_generic_reloc, /* special_function */
+ "REFHALF", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 32 bit reference to a symbol, normally from a data section. */
+ HOWTO (MIPS_R_REFWORD, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mips_generic_reloc, /* special_function */
+ "REFWORD", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 26 bit absolute jump address. */
+ HOWTO (MIPS_R_JMPADDR, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ /* This needs complex overflow
+ detection, because the upper four
+ bits must match the PC. */
+ mips_generic_reloc, /* special_function */
+ "JMPADDR", /* name */
+ true, /* partial_inplace */
+ 0x3ffffff, /* src_mask */
+ 0x3ffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high 16 bits of a symbol value. Handled by the function
+ mips_refhi_reloc. */
+ HOWTO (MIPS_R_REFHI, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mips_refhi_reloc, /* special_function */
+ "REFHI", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The low 16 bits of a symbol value. */
+ HOWTO (MIPS_R_REFLO, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ mips_reflo_reloc, /* special_function */
+ "REFLO", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A reference to an offset from the gp register. Handled by the
+ function mips_gprel_reloc. */
+ HOWTO (MIPS_R_GPREL, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ mips_gprel_reloc, /* special_function */
+ "GPREL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A reference to a literal using an offset from the gp register.
+ Handled by the function mips_gprel_reloc. */
+ HOWTO (MIPS_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 */
+ mips_gprel_reloc, /* special_function */
+ "LITERAL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ { 8 },
+ { 9 },
+ { 10 },
+ { 11 },
+
+ /* This reloc is a Cygnus extension used when generating position
+ independent code for embedded systems. It represents a 16 bit PC
+ relative reloc rightshifted twice as used in the MIPS branch
+ instructions. */
+ HOWTO (MIPS_R_PCREL16, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ mips_generic_reloc, /* special_function */
+ "PCREL16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* This reloc is a Cygnus extension used when generating position
+ independent code for embedded systems. It represents the high 16
+ bits of a PC relative reloc. The next reloc must be
+ MIPS_R_RELLO, and the addend is formed from the addends of the
+ two instructions, just as in MIPS_R_REFHI and MIPS_R_REFLO. The
+ final value is actually PC relative to the location of the
+ MIPS_R_RELLO reloc, not the MIPS_R_RELHI reloc. */
+ HOWTO (MIPS_R_RELHI, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mips_relhi_reloc, /* special_function */
+ "RELHI", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* This reloc is a Cygnus extension used when generating position
+ independent code for embedded systems. It represents the low 16
+ bits of a PC relative reloc. */
+ HOWTO (MIPS_R_RELLO, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ mips_rello_reloc, /* special_function */
+ "RELLO", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ { 15 },
+ { 16 },
+ { 17 },
+ { 18 },
+ { 19 },
+ { 20 },
+ { 21 },
+
+ /* This reloc is a Cygnus extension used when generating position
+ independent code for embedded systems. It represents an entry in
+ a switch table, which is the difference between two symbols in
+ the .text section. The symndx is actually the offset from the
+ reloc address to the subtrahend. See include/coff/mips.h for
+ more details. */
+ HOWTO (MIPS_R_SWITCH, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ mips_switch_reloc, /* special_function */
+ "SWITCH", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true) /* pcrel_offset */
+};
+
+#define MIPS_HOWTO_COUNT \
+ (sizeof mips_howto_table / sizeof mips_howto_table[0])
+
+/* When the linker is doing relaxing, it may change a external PCREL16
+ reloc. This typically represents an instruction like
+ bal foo
+ We change it to
+ .set noreorder
+ bal $L1
+ lui $at,%hi(foo - $L1)
+ $L1:
+ addiu $at,%lo(foo - $L1)
+ addu $at,$at,$31
+ jalr $at
+ PCREL16_EXPANSION_ADJUSTMENT is the number of bytes this changes the
+ instruction by. */
+
+#define PCREL16_EXPANSION_ADJUSTMENT (4 * 4)
+
+/* See whether the magic number matches. */
+
+static boolean
+mips_ecoff_bad_format_hook (abfd, filehdr)
+ bfd *abfd;
+ PTR filehdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+ switch (internal_f->f_magic)
+ {
+ case MIPS_MAGIC_1:
+ /* I don't know what endianness this implies. */
+ return true;
+
+ case MIPS_MAGIC_BIG:
+ case MIPS_MAGIC_BIG2:
+ case MIPS_MAGIC_BIG3:
+ return bfd_big_endian (abfd);
+
+ case MIPS_MAGIC_LITTLE:
+ case MIPS_MAGIC_LITTLE2:
+ case MIPS_MAGIC_LITTLE3:
+ return bfd_little_endian (abfd);
+
+ default:
+ return false;
+ }
+}
+
+/* Reloc handling. MIPS ECOFF relocs are packed into 8 bytes in
+ external form. They use a bit which indicates whether the symbol
+ is external. */
+
+/* Swap a reloc in. */
+
+static void
+mips_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
+ bfd *abfd;
+ PTR ext_ptr;
+ struct internal_reloc *intern;
+{
+ const RELOC *ext = (RELOC *) ext_ptr;
+
+ intern->r_vaddr = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_vaddr);
+ if (bfd_header_big_endian (abfd))
+ {
+ intern->r_symndx = (((int) ext->r_bits[0]
+ << RELOC_BITS0_SYMNDX_SH_LEFT_BIG)
+ | ((int) ext->r_bits[1]
+ << RELOC_BITS1_SYMNDX_SH_LEFT_BIG)
+ | ((int) ext->r_bits[2]
+ << RELOC_BITS2_SYMNDX_SH_LEFT_BIG));
+ intern->r_type = ((ext->r_bits[3] & RELOC_BITS3_TYPE_BIG)
+ >> RELOC_BITS3_TYPE_SH_BIG);
+ intern->r_extern = (ext->r_bits[3] & RELOC_BITS3_EXTERN_BIG) != 0;
+ }
+ else
+ {
+ intern->r_symndx = (((int) ext->r_bits[0]
+ << RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE)
+ | ((int) ext->r_bits[1]
+ << RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE)
+ | ((int) ext->r_bits[2]
+ << RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE));
+ intern->r_type = (((ext->r_bits[3] & RELOC_BITS3_TYPE_LITTLE)
+ >> RELOC_BITS3_TYPE_SH_LITTLE)
+ | ((ext->r_bits[3] & RELOC_BITS3_TYPEHI_LITTLE)
+ << RELOC_BITS3_TYPEHI_SH_LITTLE));
+ intern->r_extern = (ext->r_bits[3] & RELOC_BITS3_EXTERN_LITTLE) != 0;
+ }
+
+ /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
+ MIPS_R_RELLO reloc, r_symndx is actually the offset from the
+ reloc address to the base of the difference (see
+ include/coff/mips.h for more details). We copy symndx into the
+ r_offset field so as not to confuse ecoff_slurp_reloc_table in
+ ecoff.c. In adjust_reloc_in we then copy r_offset into the reloc
+ addend. */
+ if (intern->r_type == MIPS_R_SWITCH
+ || (! intern->r_extern
+ && (intern->r_type == MIPS_R_RELLO
+ || intern->r_type == MIPS_R_RELHI)))
+ {
+ BFD_ASSERT (! intern->r_extern);
+ intern->r_offset = intern->r_symndx;
+ if (intern->r_offset & 0x800000)
+ intern->r_offset -= 0x1000000;
+ intern->r_symndx = RELOC_SECTION_TEXT;
+ }
+}
+
+/* Swap a reloc out. */
+
+static void
+mips_ecoff_swap_reloc_out (abfd, intern, dst)
+ bfd *abfd;
+ const struct internal_reloc *intern;
+ PTR dst;
+{
+ RELOC *ext = (RELOC *) dst;
+ long r_symndx;
+
+ BFD_ASSERT (intern->r_extern
+ || (intern->r_symndx >= 0 && intern->r_symndx <= 12));
+
+ /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELLO or
+ MIPS_R_RELHI reloc, we actually want to write the contents of
+ r_offset out as the symbol index. This undoes the change made by
+ mips_ecoff_swap_reloc_in. */
+ if (intern->r_type != MIPS_R_SWITCH
+ && (intern->r_extern
+ || (intern->r_type != MIPS_R_RELHI
+ && intern->r_type != MIPS_R_RELLO)))
+ r_symndx = intern->r_symndx;
+ else
+ {
+ BFD_ASSERT (intern->r_symndx == RELOC_SECTION_TEXT);
+ r_symndx = intern->r_offset & 0xffffff;
+ }
+
+ bfd_h_put_32 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
+ if (bfd_header_big_endian (abfd))
+ {
+ ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_BIG;
+ ext->r_bits[1] = r_symndx >> RELOC_BITS1_SYMNDX_SH_LEFT_BIG;
+ ext->r_bits[2] = r_symndx >> RELOC_BITS2_SYMNDX_SH_LEFT_BIG;
+ ext->r_bits[3] = (((intern->r_type << RELOC_BITS3_TYPE_SH_BIG)
+ & RELOC_BITS3_TYPE_BIG)
+ | (intern->r_extern ? RELOC_BITS3_EXTERN_BIG : 0));
+ }
+ else
+ {
+ ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE;
+ ext->r_bits[1] = r_symndx >> RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE;
+ ext->r_bits[2] = r_symndx >> RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE;
+ ext->r_bits[3] = (((intern->r_type << RELOC_BITS3_TYPE_SH_LITTLE)
+ & RELOC_BITS3_TYPE_LITTLE)
+ | ((intern->r_type >> RELOC_BITS3_TYPEHI_SH_LITTLE
+ & RELOC_BITS3_TYPEHI_LITTLE))
+ | (intern->r_extern ? RELOC_BITS3_EXTERN_LITTLE : 0));
+ }
+}
+
+/* Finish canonicalizing a reloc. Part of this is generic to all
+ ECOFF targets, and that part is in ecoff.c. The rest is done in
+ this backend routine. It must fill in the howto field. */
+
+static void
+mips_adjust_reloc_in (abfd, intern, rptr)
+ bfd *abfd;
+ const struct internal_reloc *intern;
+ arelent *rptr;
+{
+ if (intern->r_type > MIPS_R_SWITCH)
+ abort ();
+
+ if (! intern->r_extern
+ && (intern->r_type == MIPS_R_GPREL
+ || intern->r_type == MIPS_R_LITERAL))
+ rptr->addend += ecoff_data (abfd)->gp;
+
+ /* If the type is MIPS_R_IGNORE, make sure this is a reference to
+ the absolute section so that the reloc is ignored. */
+ if (intern->r_type == MIPS_R_IGNORE)
+ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+
+ /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
+ MIPS_R_RELLO reloc, we want the addend field of the BFD relocto
+ hold the value which was originally in the symndx field of the
+ internal MIPS ECOFF reloc. This value was copied into
+ intern->r_offset by mips_swap_reloc_in, and here we copy it into
+ the addend field. */
+ if (intern->r_type == MIPS_R_SWITCH
+ || (! intern->r_extern
+ && (intern->r_type == MIPS_R_RELHI
+ || intern->r_type == MIPS_R_RELLO)))
+ rptr->addend = intern->r_offset;
+
+ rptr->howto = &mips_howto_table[intern->r_type];
+}
+
+/* Make any adjustments needed to a reloc before writing it out. None
+ are needed for MIPS. */
+
+static void
+mips_adjust_reloc_out (abfd, rel, intern)
+ bfd *abfd;
+ const arelent *rel;
+ struct internal_reloc *intern;
+{
+ /* For a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
+ MIPS_R_RELLO reloc, we must copy rel->addend into
+ intern->r_offset. This will then be written out as the symbol
+ index by mips_ecoff_swap_reloc_out. This operation parallels the
+ action of mips_adjust_reloc_in. */
+ if (intern->r_type == MIPS_R_SWITCH
+ || (! intern->r_extern
+ && (intern->r_type == MIPS_R_RELHI
+ || intern->r_type == MIPS_R_RELLO)))
+ intern->r_offset = rel->addend;
+}
+
+/* ECOFF relocs are either against external symbols, or against
+ sections. If we are producing relocateable output, and the reloc
+ is against an external symbol, and nothing has given us any
+ additional addend, the resulting reloc will also be against the
+ same symbol. In such a case, we don't want to change anything
+ about the way the reloc is handled, since it will all be done at
+ final link time. Rather than put special case code into
+ bfd_perform_relocation, all the reloc types use this howto
+ function. It just short circuits the reloc if producing
+ relocateable output against an external symbol. */
+
+static bfd_reloc_status_type
+mips_generic_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ return bfd_reloc_continue;
+}
+
+/* Do a REFHI relocation. This has to be done in combination with a
+ REFLO reloc, because there is a carry from the REFLO to the REFHI.
+ Here we just save the information we need; we do the actual
+ relocation when we see the REFLO. MIPS ECOFF requires that the
+ REFLO immediately follow the REFHI. As a GNU extension, we permit
+ an arbitrary number of HI relocs to be associated with a single LO
+ reloc. This extension permits gcc to output the HI and LO relocs
+ itself. */
+
+struct mips_hi
+{
+ struct mips_hi *next;
+ bfd_byte *addr;
+ bfd_vma addend;
+};
+
+/* FIXME: This should not be a static variable. */
+
+static struct mips_hi *mips_refhi_list;
+
+static bfd_reloc_status_type
+mips_refhi_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_reloc_status_type ret;
+ bfd_vma relocation;
+ struct mips_hi *n;
+
+ /* If we're relocating, and this an external symbol, we don't want
+ to change anything. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ ret = bfd_reloc_ok;
+ if (bfd_is_und_section (symbol->section)
+ && output_bfd == (bfd *) NULL)
+ ret = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Save the information, and let REFLO do the actual relocation. */
+ n = (struct mips_hi *) bfd_malloc (sizeof *n);
+ if (n == NULL)
+ return bfd_reloc_outofrange;
+ n->addr = (bfd_byte *) data + reloc_entry->address;
+ n->addend = relocation;
+ n->next = mips_refhi_list;
+ mips_refhi_list = n;
+
+ if (output_bfd != (bfd *) NULL)
+ reloc_entry->address += input_section->output_offset;
+
+ return ret;
+}
+
+/* Do a REFLO relocation. This is a straightforward 16 bit inplace
+ relocation; this function exists in order to do the REFHI
+ relocation described above. */
+
+static bfd_reloc_status_type
+mips_reflo_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (mips_refhi_list != NULL)
+ {
+ struct mips_hi *l;
+
+ l = mips_refhi_list;
+ while (l != NULL)
+ {
+ unsigned long insn;
+ unsigned long val;
+ unsigned long vallo;
+ struct mips_hi *next;
+
+ /* Do the REFHI relocation. Note that we actually don't
+ need to know anything about the REFLO itself, except
+ where to find the low 16 bits of the addend needed by the
+ REFHI. */
+ insn = bfd_get_32 (abfd, l->addr);
+ vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
+ & 0xffff);
+ val = ((insn & 0xffff) << 16) + vallo;
+ val += l->addend;
+
+ /* The low order 16 bits are always treated as a signed
+ value. Therefore, a negative value in the low order bits
+ requires an adjustment in the high order bits. We need
+ to make this adjustment in two ways: once for the bits we
+ took from the data, and once for the bits we are putting
+ back in to the data. */
+ if ((vallo & 0x8000) != 0)
+ val -= 0x10000;
+ if ((val & 0x8000) != 0)
+ val += 0x10000;
+
+ insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, insn, l->addr);
+
+ next = l->next;
+ free (l);
+ l = next;
+ }
+
+ mips_refhi_list = NULL;
+ }
+
+ /* Now do the REFLO reloc in the usual way. */
+ return mips_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+}
+
+/* Do a GPREL relocation. This is a 16 bit value which must become
+ the offset from the gp register. */
+
+static bfd_reloc_status_type
+mips_gprel_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ boolean relocateable;
+ bfd_vma gp;
+ bfd_vma relocation;
+ unsigned long val;
+ unsigned long insn;
+
+ /* If we're relocating, and this is an external symbol with no
+ addend, we don't want to change anything. We will only have an
+ addend if this is a newly created reloc, not read from an ECOFF
+ file. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ relocateable = true;
+ else
+ {
+ relocateable = false;
+ output_bfd = symbol->section->output_section->owner;
+ }
+
+ if (bfd_is_und_section (symbol->section)
+ && relocateable == false)
+ return bfd_reloc_undefined;
+
+ /* We have to figure out the gp value, so that we can adjust the
+ symbol value correctly. We look up the symbol _gp in the output
+ BFD. If we can't find it, we're stuck. We cache it in the ECOFF
+ target data. We don't need to adjust the symbol value for an
+ external symbol if we are producing relocateable output. */
+ gp = _bfd_get_gp_value (output_bfd);
+ if (gp == 0
+ && (relocateable == false
+ || (symbol->flags & BSF_SECTION_SYM) != 0))
+ {
+ if (relocateable != false)
+ {
+ /* Make up a value. */
+ gp = symbol->section->output_section->vma + 0x4000;
+ _bfd_set_gp_value (output_bfd, gp);
+ }
+ else
+ {
+ unsigned int count;
+ asymbol **sym;
+ unsigned int i;
+
+ count = bfd_get_symcount (output_bfd);
+ sym = bfd_get_outsymbols (output_bfd);
+
+ if (sym == (asymbol **) NULL)
+ i = count;
+ else
+ {
+ for (i = 0; i < count; i++, sym++)
+ {
+ register CONST char *name;
+
+ name = bfd_asymbol_name (*sym);
+ if (*name == '_' && strcmp (name, "_gp") == 0)
+ {
+ gp = bfd_asymbol_value (*sym);
+ _bfd_set_gp_value (output_bfd, gp);
+ break;
+ }
+ }
+ }
+
+ if (i >= count)
+ {
+ /* Only get the error once. */
+ gp = 4;
+ _bfd_set_gp_value (output_bfd, gp);
+ *error_message =
+ (char *) _("GP relative relocation when _gp not defined");
+ return bfd_reloc_dangerous;
+ }
+ }
+ }
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+
+ /* Set val to the offset into the section or symbol. */
+ val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
+ if (val & 0x8000)
+ val -= 0x10000;
+
+ /* Adjust val for the final section location and GP value. If we
+ are producing relocateable output, we don't want to do this for
+ an external symbol. */
+ if (relocateable == false
+ || (symbol->flags & BSF_SECTION_SYM) != 0)
+ val += relocation - gp;
+
+ insn = (insn &~ 0xffff) | (val & 0xffff);
+ bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+ if (relocateable != false)
+ reloc_entry->address += input_section->output_offset;
+
+ /* Make sure it fit in 16 bits. */
+ if (val >= 0x8000 && val < 0xffff8000)
+ return bfd_reloc_overflow;
+
+ return bfd_reloc_ok;
+}
+
+/* Do a RELHI relocation. We do this in conjunction with a RELLO
+ reloc, just as REFHI and REFLO are done together. RELHI and RELLO
+ are Cygnus extensions used when generating position independent
+ code for embedded systems. */
+
+/* FIXME: This should not be a static variable. */
+
+static struct mips_hi *mips_relhi_list;
+
+static bfd_reloc_status_type
+mips_relhi_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_reloc_status_type ret;
+ bfd_vma relocation;
+ struct mips_hi *n;
+
+ /* If this is a reloc against a section symbol, then it is correct
+ in the object file. The only time we want to change this case is
+ when we are relaxing, and that is handled entirely by
+ mips_relocate_section and never calls this function. */
+ if ((symbol->flags & BSF_SECTION_SYM) != 0)
+ {
+ if (output_bfd != (bfd *) NULL)
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* This is an external symbol. If we're relocating, we don't want
+ to change anything. */
+ if (output_bfd != (bfd *) NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ ret = bfd_reloc_ok;
+ if (bfd_is_und_section (symbol->section)
+ && output_bfd == (bfd *) NULL)
+ ret = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Save the information, and let RELLO do the actual relocation. */
+ n = (struct mips_hi *) bfd_malloc (sizeof *n);
+ if (n == NULL)
+ return bfd_reloc_outofrange;
+ n->addr = (bfd_byte *) data + reloc_entry->address;
+ n->addend = relocation;
+ n->next = mips_relhi_list;
+ mips_relhi_list = n;
+
+ if (output_bfd != (bfd *) NULL)
+ reloc_entry->address += input_section->output_offset;
+
+ return ret;
+}
+
+/* Do a RELLO relocation. This is a straightforward 16 bit PC
+ relative relocation; this function exists in order to do the RELHI
+ relocation described above. */
+
+static bfd_reloc_status_type
+mips_rello_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (mips_relhi_list != NULL)
+ {
+ struct mips_hi *l;
+
+ l = mips_relhi_list;
+ while (l != NULL)
+ {
+ unsigned long insn;
+ unsigned long val;
+ unsigned long vallo;
+ struct mips_hi *next;
+
+ /* Do the RELHI relocation. Note that we actually don't
+ need to know anything about the RELLO itself, except
+ where to find the low 16 bits of the addend needed by the
+ RELHI. */
+ insn = bfd_get_32 (abfd, l->addr);
+ vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
+ & 0xffff);
+ val = ((insn & 0xffff) << 16) + vallo;
+ val += l->addend;
+
+ /* If the symbol is defined, make val PC relative. If the
+ symbol is not defined we don't want to do this, because
+ we don't want the value in the object file to incorporate
+ the address of the reloc. */
+ if (! bfd_is_und_section (bfd_get_section (symbol))
+ && ! bfd_is_com_section (bfd_get_section (symbol)))
+ val -= (input_section->output_section->vma
+ + input_section->output_offset
+ + reloc_entry->address);
+
+ /* The low order 16 bits are always treated as a signed
+ value. Therefore, a negative value in the low order bits
+ requires an adjustment in the high order bits. We need
+ to make this adjustment in two ways: once for the bits we
+ took from the data, and once for the bits we are putting
+ back in to the data. */
+ if ((vallo & 0x8000) != 0)
+ val -= 0x10000;
+ if ((val & 0x8000) != 0)
+ val += 0x10000;
+
+ insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, insn, l->addr);
+
+ next = l->next;
+ free (l);
+ l = next;
+ }
+
+ mips_relhi_list = NULL;
+ }
+
+ /* If this is a reloc against a section symbol, then it is correct
+ in the object file. The only time we want to change this case is
+ when we are relaxing, and that is handled entirely by
+ mips_relocate_section and never calls this function. */
+ if ((symbol->flags & BSF_SECTION_SYM) != 0)
+ {
+ if (output_bfd != (bfd *) NULL)
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* bfd_perform_relocation does not handle pcrel_offset relocations
+ correctly when generating a relocateable file, so handle them
+ directly here. */
+ if (output_bfd != (bfd *) NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* Now do the RELLO reloc in the usual way. */
+ return mips_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+}
+
+/* This is the special function for the MIPS_R_SWITCH reloc. This
+ special reloc is normally correct in the object file, and only
+ requires special handling when relaxing. We don't want
+ bfd_perform_relocation to tamper with it at all. */
+
+/*ARGSUSED*/
+static bfd_reloc_status_type
+mips_switch_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return bfd_reloc_ok;
+}
+
+/* Get the howto structure for a generic reloc type. */
+
+static reloc_howto_type *
+mips_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ int mips_type;
+
+ switch (code)
+ {
+ case BFD_RELOC_16:
+ mips_type = MIPS_R_REFHALF;
+ break;
+ case BFD_RELOC_32:
+ case BFD_RELOC_CTOR:
+ mips_type = MIPS_R_REFWORD;
+ break;
+ case BFD_RELOC_MIPS_JMP:
+ mips_type = MIPS_R_JMPADDR;
+ break;
+ case BFD_RELOC_HI16_S:
+ mips_type = MIPS_R_REFHI;
+ break;
+ case BFD_RELOC_LO16:
+ mips_type = MIPS_R_REFLO;
+ break;
+ case BFD_RELOC_MIPS_GPREL:
+ mips_type = MIPS_R_GPREL;
+ break;
+ case BFD_RELOC_MIPS_LITERAL:
+ mips_type = MIPS_R_LITERAL;
+ break;
+ case BFD_RELOC_16_PCREL_S2:
+ mips_type = MIPS_R_PCREL16;
+ break;
+ case BFD_RELOC_PCREL_HI16_S:
+ mips_type = MIPS_R_RELHI;
+ break;
+ case BFD_RELOC_PCREL_LO16:
+ mips_type = MIPS_R_RELLO;
+ break;
+ case BFD_RELOC_GPREL32:
+ mips_type = MIPS_R_SWITCH;
+ break;
+ default:
+ return (reloc_howto_type *) NULL;
+ }
+
+ return &mips_howto_table[mips_type];
+}
+
+/* A helper routine for mips_relocate_section which handles the REFHI
+ and RELHI relocations. The REFHI relocation must be followed by a
+ REFLO relocation (and RELHI by a RELLO), and the addend used is
+ formed from the addends of both instructions. */
+
+static void
+mips_relocate_hi (refhi, reflo, input_bfd, input_section, contents, adjust,
+ relocation, pcrel)
+ struct internal_reloc *refhi;
+ struct internal_reloc *reflo;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ size_t adjust;
+ bfd_vma relocation;
+ boolean pcrel;
+{
+ unsigned long insn;
+ unsigned long val;
+ unsigned long vallo;
+
+ if (refhi == NULL)
+ return;
+
+ insn = bfd_get_32 (input_bfd,
+ contents + adjust + refhi->r_vaddr - input_section->vma);
+ if (reflo == NULL)
+ vallo = 0;
+ else
+ vallo = (bfd_get_32 (input_bfd,
+ contents + adjust + reflo->r_vaddr - input_section->vma)
+ & 0xffff);
+
+ val = ((insn & 0xffff) << 16) + vallo;
+ val += relocation;
+
+ /* The low order 16 bits are always treated as a signed value.
+ Therefore, a negative value in the low order bits requires an
+ adjustment in the high order bits. We need to make this
+ adjustment in two ways: once for the bits we took from the data,
+ and once for the bits we are putting back in to the data. */
+ if ((vallo & 0x8000) != 0)
+ val -= 0x10000;
+
+ if (pcrel)
+ val -= (input_section->output_section->vma
+ + input_section->output_offset
+ + (reflo->r_vaddr - input_section->vma + adjust));
+
+ if ((val & 0x8000) != 0)
+ val += 0x10000;
+
+ insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (input_bfd, (bfd_vma) insn,
+ contents + adjust + refhi->r_vaddr - input_section->vma);
+}
+
+/* Relocate a section while linking a MIPS ECOFF file. */
+
+static boolean
+mips_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, external_relocs)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ PTR external_relocs;
+{
+ asection **symndx_to_section;
+ struct ecoff_link_hash_entry **sym_hashes;
+ bfd_vma gp;
+ boolean gp_undefined;
+ size_t adjust;
+ long *offsets;
+ struct external_reloc *ext_rel;
+ struct external_reloc *ext_rel_end;
+ unsigned int i;
+ boolean got_lo;
+ struct internal_reloc lo_int_rel;
+
+ BFD_ASSERT (input_bfd->xvec->byteorder
+ == output_bfd->xvec->byteorder);
+
+ /* We keep a table mapping the symndx found in an internal reloc to
+ the appropriate section. This is faster than looking up the
+ section by name each time. */
+ symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
+ if (symndx_to_section == (asection **) NULL)
+ {
+ symndx_to_section = ((asection **)
+ bfd_alloc (input_bfd,
+ (NUM_RELOC_SECTIONS
+ * sizeof (asection *))));
+ if (!symndx_to_section)
+ return false;
+
+ symndx_to_section[RELOC_SECTION_NONE] = NULL;
+ symndx_to_section[RELOC_SECTION_TEXT] =
+ bfd_get_section_by_name (input_bfd, ".text");
+ symndx_to_section[RELOC_SECTION_RDATA] =
+ bfd_get_section_by_name (input_bfd, ".rdata");
+ symndx_to_section[RELOC_SECTION_DATA] =
+ bfd_get_section_by_name (input_bfd, ".data");
+ symndx_to_section[RELOC_SECTION_SDATA] =
+ bfd_get_section_by_name (input_bfd, ".sdata");
+ symndx_to_section[RELOC_SECTION_SBSS] =
+ bfd_get_section_by_name (input_bfd, ".sbss");
+ symndx_to_section[RELOC_SECTION_BSS] =
+ bfd_get_section_by_name (input_bfd, ".bss");
+ symndx_to_section[RELOC_SECTION_INIT] =
+ bfd_get_section_by_name (input_bfd, ".init");
+ symndx_to_section[RELOC_SECTION_LIT8] =
+ bfd_get_section_by_name (input_bfd, ".lit8");
+ symndx_to_section[RELOC_SECTION_LIT4] =
+ bfd_get_section_by_name (input_bfd, ".lit4");
+ symndx_to_section[RELOC_SECTION_XDATA] = NULL;
+ symndx_to_section[RELOC_SECTION_PDATA] = NULL;
+ symndx_to_section[RELOC_SECTION_FINI] =
+ bfd_get_section_by_name (input_bfd, ".fini");
+ symndx_to_section[RELOC_SECTION_LITA] = NULL;
+ symndx_to_section[RELOC_SECTION_ABS] = NULL;
+
+ ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
+ }
+
+ sym_hashes = ecoff_data (input_bfd)->sym_hashes;
+
+ gp = _bfd_get_gp_value (output_bfd);
+ if (gp == 0)
+ gp_undefined = true;
+ else
+ gp_undefined = false;
+
+ got_lo = false;
+
+ adjust = 0;
+
+ if (ecoff_section_data (input_bfd, input_section) == NULL)
+ offsets = NULL;
+ else
+ offsets = ecoff_section_data (input_bfd, input_section)->offsets;
+
+ ext_rel = (struct external_reloc *) external_relocs;
+ ext_rel_end = ext_rel + input_section->reloc_count;
+ for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++)
+ {
+ struct internal_reloc int_rel;
+ boolean use_lo = false;
+ bfd_vma addend;
+ reloc_howto_type *howto;
+ struct ecoff_link_hash_entry *h = NULL;
+ asection *s = NULL;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ if (! got_lo)
+ mips_ecoff_swap_reloc_in (input_bfd, (PTR) ext_rel, &int_rel);
+ else
+ {
+ int_rel = lo_int_rel;
+ got_lo = false;
+ }
+
+ BFD_ASSERT (int_rel.r_type
+ < sizeof mips_howto_table / sizeof mips_howto_table[0]);
+
+ /* The REFHI and RELHI relocs requires special handling. they
+ must be followed by a REFLO or RELLO reloc, respectively, and
+ the addend is formed from both relocs. */
+ if (int_rel.r_type == MIPS_R_REFHI
+ || int_rel.r_type == MIPS_R_RELHI)
+ {
+ struct external_reloc *lo_ext_rel;
+
+ /* As a GNU extension, permit an arbitrary number of REFHI
+ or RELHI relocs before the REFLO or RELLO reloc. This
+ permits gcc to emit the HI and LO relocs itself. */
+ for (lo_ext_rel = ext_rel + 1;
+ lo_ext_rel < ext_rel_end;
+ lo_ext_rel++)
+ {
+ mips_ecoff_swap_reloc_in (input_bfd, (PTR) lo_ext_rel,
+ &lo_int_rel);
+ if (lo_int_rel.r_type != int_rel.r_type)
+ break;
+ }
+
+ if (lo_ext_rel < ext_rel_end
+ && (lo_int_rel.r_type
+ == (int_rel.r_type == MIPS_R_REFHI
+ ? MIPS_R_REFLO
+ : MIPS_R_RELLO))
+ && int_rel.r_extern == lo_int_rel.r_extern
+ && int_rel.r_symndx == lo_int_rel.r_symndx)
+ {
+ use_lo = true;
+ if (lo_ext_rel == ext_rel + 1)
+ got_lo = true;
+ }
+ }
+
+ howto = &mips_howto_table[int_rel.r_type];
+
+ /* The SWITCH reloc must be handled specially. This reloc is
+ marks the location of a difference between two portions of an
+ object file. The symbol index does not reference a symbol,
+ but is actually the offset from the reloc to the subtrahend
+ of the difference. This reloc is correct in the object file,
+ and needs no further adjustment, unless we are relaxing. If
+ we are relaxing, we may have to add in an offset. Since no
+ symbols are involved in this reloc, we handle it completely
+ here. */
+ if (int_rel.r_type == MIPS_R_SWITCH)
+ {
+ if (offsets != NULL
+ && offsets[i] != 0)
+ {
+ r = _bfd_relocate_contents (howto, input_bfd,
+ (bfd_vma) offsets[i],
+ (contents
+ + adjust
+ + int_rel.r_vaddr
+ - input_section->vma));
+ BFD_ASSERT (r == bfd_reloc_ok);
+ }
+
+ continue;
+ }
+
+ if (int_rel.r_extern)
+ {
+ h = sym_hashes[int_rel.r_symndx];
+ /* If h is NULL, that means that there is a reloc against an
+ external symbol which we thought was just a debugging
+ symbol. This should not happen. */
+ if (h == (struct ecoff_link_hash_entry *) NULL)
+ abort ();
+ }
+ else
+ {
+ if (int_rel.r_symndx < 0 || int_rel.r_symndx >= NUM_RELOC_SECTIONS)
+ s = NULL;
+ else
+ s = symndx_to_section[int_rel.r_symndx];
+
+ if (s == (asection *) NULL)
+ abort ();
+ }
+
+ /* The GPREL reloc uses an addend: the difference in the GP
+ values. */
+ if (int_rel.r_type != MIPS_R_GPREL
+ && int_rel.r_type != MIPS_R_LITERAL)
+ addend = 0;
+ else
+ {
+ if (gp_undefined)
+ {
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info, _("GP relative relocation when GP not defined"),
+ input_bfd, input_section,
+ int_rel.r_vaddr - input_section->vma)))
+ return false;
+ /* Only give the error once per link. */
+ gp = 4;
+ _bfd_set_gp_value (output_bfd, gp);
+ gp_undefined = false;
+ }
+ if (! int_rel.r_extern)
+ {
+ /* This is a relocation against a section. The current
+ addend in the instruction is the difference between
+ INPUT_SECTION->vma and the GP value of INPUT_BFD. We
+ must change this to be the difference between the
+ final definition (which will end up in RELOCATION)
+ and the GP value of OUTPUT_BFD (which is in GP). */
+ addend = ecoff_data (input_bfd)->gp - gp;
+ }
+ else if (! info->relocateable
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ /* This is a relocation against a defined symbol. The
+ current addend in the instruction is simply the
+ desired offset into the symbol (normally zero). We
+ are going to change this into a relocation against a
+ defined symbol, so we want the instruction to hold
+ the difference between the final definition of the
+ symbol (which will end up in RELOCATION) and the GP
+ value of OUTPUT_BFD (which is in GP). */
+ addend = - gp;
+ }
+ else
+ {
+ /* This is a relocation against an undefined or common
+ symbol. The current addend in the instruction is
+ simply the desired offset into the symbol (normally
+ zero). We are generating relocateable output, and we
+ aren't going to define this symbol, so we just leave
+ the instruction alone. */
+ addend = 0;
+ }
+ }
+
+ /* If we are relaxing, mips_relax_section may have set
+ offsets[i] to some value. A value of 1 means we must expand
+ a PC relative branch into a multi-instruction of sequence,
+ and any other value is an addend. */
+ if (offsets != NULL
+ && offsets[i] != 0)
+ {
+ BFD_ASSERT (! info->relocateable);
+ BFD_ASSERT (int_rel.r_type == MIPS_R_PCREL16
+ || int_rel.r_type == MIPS_R_RELHI
+ || int_rel.r_type == MIPS_R_RELLO);
+ if (offsets[i] != 1)
+ addend += offsets[i];
+ else
+ {
+ bfd_byte *here;
+
+ BFD_ASSERT (int_rel.r_extern
+ && int_rel.r_type == MIPS_R_PCREL16);
+
+ /* Move the rest of the instructions up. */
+ here = (contents
+ + adjust
+ + int_rel.r_vaddr
+ - input_section->vma);
+ memmove (here + PCREL16_EXPANSION_ADJUSTMENT, here,
+ (size_t) (input_section->_raw_size
+ - (int_rel.r_vaddr - input_section->vma)));
+
+ /* Generate the new instructions. */
+ if (! mips_relax_pcrel16 (info, input_bfd, input_section,
+ h, here,
+ (input_section->output_section->vma
+ + input_section->output_offset
+ + (int_rel.r_vaddr
+ - input_section->vma)
+ + adjust)))
+ return false;
+
+ /* We must adjust everything else up a notch. */
+ adjust += PCREL16_EXPANSION_ADJUSTMENT;
+
+ /* mips_relax_pcrel16 handles all the details of this
+ relocation. */
+ continue;
+ }
+ }
+
+ /* If we are relaxing, and this is a reloc against the .text
+ segment, we may need to adjust it if some branches have been
+ expanded. The reloc types which are likely to occur in the
+ .text section are handled efficiently by mips_relax_section,
+ and thus do not need to be handled here. */
+ if (ecoff_data (input_bfd)->debug_info.adjust != NULL
+ && ! int_rel.r_extern
+ && int_rel.r_symndx == RELOC_SECTION_TEXT
+ && (strcmp (bfd_get_section_name (input_bfd, input_section),
+ ".text") != 0
+ || (int_rel.r_type != MIPS_R_PCREL16
+ && int_rel.r_type != MIPS_R_SWITCH
+ && int_rel.r_type != MIPS_R_RELHI
+ && int_rel.r_type != MIPS_R_RELLO)))
+ {
+ bfd_vma adr;
+ struct ecoff_value_adjust *a;
+
+ /* We need to get the addend so that we know whether we need
+ to adjust the address. */
+ BFD_ASSERT (int_rel.r_type == MIPS_R_REFWORD);
+
+ adr = bfd_get_32 (input_bfd,
+ (contents
+ + adjust
+ + int_rel.r_vaddr
+ - input_section->vma));
+
+ for (a = ecoff_data (input_bfd)->debug_info.adjust;
+ a != (struct ecoff_value_adjust *) NULL;
+ a = a->next)
+ {
+ if (adr >= a->start && adr < a->end)
+ addend += a->adjust;
+ }
+ }
+
+ if (info->relocateable)
+ {
+ /* We are generating relocateable output, and must convert
+ the existing reloc. */
+ if (int_rel.r_extern)
+ {
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && ! bfd_is_abs_section (h->root.u.def.section))
+ {
+ const char *name;
+
+ /* This symbol is defined in the output. Convert
+ the reloc from being against the symbol to being
+ against the section. */
+
+ /* Clear the r_extern bit. */
+ int_rel.r_extern = 0;
+
+ /* Compute a new r_symndx value. */
+ s = h->root.u.def.section;
+ name = bfd_get_section_name (output_bfd,
+ s->output_section);
+
+ int_rel.r_symndx = -1;
+ switch (name[1])
+ {
+ case 'b':
+ if (strcmp (name, ".bss") == 0)
+ int_rel.r_symndx = RELOC_SECTION_BSS;
+ break;
+ case 'd':
+ if (strcmp (name, ".data") == 0)
+ int_rel.r_symndx = RELOC_SECTION_DATA;
+ break;
+ case 'f':
+ if (strcmp (name, ".fini") == 0)
+ int_rel.r_symndx = RELOC_SECTION_FINI;
+ break;
+ case 'i':
+ if (strcmp (name, ".init") == 0)
+ int_rel.r_symndx = RELOC_SECTION_INIT;
+ break;
+ case 'l':
+ if (strcmp (name, ".lit8") == 0)
+ int_rel.r_symndx = RELOC_SECTION_LIT8;
+ else if (strcmp (name, ".lit4") == 0)
+ int_rel.r_symndx = RELOC_SECTION_LIT4;
+ break;
+ case 'r':
+ if (strcmp (name, ".rdata") == 0)
+ int_rel.r_symndx = RELOC_SECTION_RDATA;
+ break;
+ case 's':
+ if (strcmp (name, ".sdata") == 0)
+ int_rel.r_symndx = RELOC_SECTION_SDATA;
+ else if (strcmp (name, ".sbss") == 0)
+ int_rel.r_symndx = RELOC_SECTION_SBSS;
+ break;
+ case 't':
+ if (strcmp (name, ".text") == 0)
+ int_rel.r_symndx = RELOC_SECTION_TEXT;
+ break;
+ }
+
+ if (int_rel.r_symndx == -1)
+ abort ();
+
+ /* Add the section VMA and the symbol value. */
+ relocation = (h->root.u.def.value
+ + s->output_section->vma
+ + s->output_offset);
+
+ /* For a PC relative relocation, the object file
+ currently holds just the addend. We must adjust
+ by the address to get the right value. */
+ if (howto->pc_relative)
+ {
+ relocation -= int_rel.r_vaddr - input_section->vma;
+
+ /* If we are converting a RELHI or RELLO reloc
+ from being against an external symbol to
+ being against a section, we must put a
+ special value into the r_offset field. This
+ value is the old addend. The r_offset for
+ both the RELHI and RELLO relocs are the same,
+ and we set both when we see RELHI. */
+ if (int_rel.r_type == MIPS_R_RELHI)
+ {
+ long addhi, addlo;
+
+ addhi = bfd_get_32 (input_bfd,
+ (contents
+ + adjust
+ + int_rel.r_vaddr
+ - input_section->vma));
+ addhi &= 0xffff;
+ if (addhi & 0x8000)
+ addhi -= 0x10000;
+ addhi <<= 16;
+
+ if (! use_lo)
+ addlo = 0;
+ else
+ {
+ addlo = bfd_get_32 (input_bfd,
+ (contents
+ + adjust
+ + lo_int_rel.r_vaddr
+ - input_section->vma));
+ addlo &= 0xffff;
+ if (addlo & 0x8000)
+ addlo -= 0x10000;
+
+ lo_int_rel.r_offset = addhi + addlo;
+ }
+
+ int_rel.r_offset = addhi + addlo;
+ }
+ }
+
+ h = NULL;
+ }
+ else
+ {
+ /* Change the symndx value to the right one for the
+ output BFD. */
+ int_rel.r_symndx = h->indx;
+ if (int_rel.r_symndx == -1)
+ {
+ /* This symbol is not being written out. */
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, h->root.root.string, input_bfd,
+ input_section,
+ int_rel.r_vaddr - input_section->vma)))
+ return false;
+ int_rel.r_symndx = 0;
+ }
+ relocation = 0;
+ }
+ }
+ else
+ {
+ /* This is a relocation against a section. Adjust the
+ value by the amount the section moved. */
+ relocation = (s->output_section->vma
+ + s->output_offset
+ - s->vma);
+ }
+
+ relocation += addend;
+ addend = 0;
+
+ /* Adjust a PC relative relocation by removing the reference
+ to the original address in the section and including the
+ reference to the new address. However, external RELHI
+ and RELLO relocs are PC relative, but don't include any
+ reference to the address. The addend is merely an
+ addend. */
+ if (howto->pc_relative
+ && (! int_rel.r_extern
+ || (int_rel.r_type != MIPS_R_RELHI
+ && int_rel.r_type != MIPS_R_RELLO)))
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma);
+
+ /* Adjust the contents. */
+ if (relocation == 0)
+ r = bfd_reloc_ok;
+ else
+ {
+ if (int_rel.r_type != MIPS_R_REFHI
+ && int_rel.r_type != MIPS_R_RELHI)
+ r = _bfd_relocate_contents (howto, input_bfd, relocation,
+ (contents
+ + adjust
+ + int_rel.r_vaddr
+ - input_section->vma));
+ else
+ {
+ mips_relocate_hi (&int_rel,
+ use_lo ? &lo_int_rel : NULL,
+ input_bfd, input_section, contents,
+ adjust, relocation,
+ int_rel.r_type == MIPS_R_RELHI);
+ r = bfd_reloc_ok;
+ }
+ }
+
+ /* Adjust the reloc address. */
+ int_rel.r_vaddr += (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma);
+
+ /* Save the changed reloc information. */
+ mips_ecoff_swap_reloc_out (input_bfd, &int_rel, (PTR) ext_rel);
+ }
+ else
+ {
+ /* We are producing a final executable. */
+ if (int_rel.r_extern)
+ {
+ /* This is a reloc against a symbol. */
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *hsec;
+
+ hsec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + hsec->output_section->vma
+ + hsec->output_offset);
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section,
+ int_rel.r_vaddr - input_section->vma)))
+ return false;
+ relocation = 0;
+ }
+ }
+ else
+ {
+ /* This is a reloc against a section. */
+ relocation = (s->output_section->vma
+ + s->output_offset
+ - s->vma);
+
+ /* A PC relative reloc is already correct in the object
+ file. Make it look like a pcrel_offset relocation by
+ adding in the start address. */
+ if (howto->pc_relative)
+ {
+ if (int_rel.r_type != MIPS_R_RELHI || ! use_lo)
+ relocation += int_rel.r_vaddr + adjust;
+ else
+ relocation += lo_int_rel.r_vaddr + adjust;
+ }
+ }
+
+ if (int_rel.r_type != MIPS_R_REFHI
+ && int_rel.r_type != MIPS_R_RELHI)
+ r = _bfd_final_link_relocate (howto,
+ input_bfd,
+ input_section,
+ contents,
+ (int_rel.r_vaddr
+ - input_section->vma
+ + adjust),
+ relocation,
+ addend);
+ else
+ {
+ mips_relocate_hi (&int_rel,
+ use_lo ? &lo_int_rel : NULL,
+ input_bfd, input_section, contents, adjust,
+ relocation,
+ int_rel.r_type == MIPS_R_RELHI);
+ r = bfd_reloc_ok;
+ }
+ }
+
+ /* MIPS_R_JMPADDR requires peculiar overflow detection. The
+ instruction provides a 28 bit address (the two lower bits are
+ implicit zeroes) which is combined with the upper four bits
+ of the instruction address. */
+ if (r == bfd_reloc_ok
+ && int_rel.r_type == MIPS_R_JMPADDR
+ && (((relocation
+ + addend
+ + (int_rel.r_extern ? 0 : s->vma))
+ & 0xf0000000)
+ != ((input_section->output_section->vma
+ + input_section->output_offset
+ + (int_rel.r_vaddr - input_section->vma)
+ + adjust)
+ & 0xf0000000)))
+ r = bfd_reloc_overflow;
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (int_rel.r_extern)
+ name = h->root.root.string;
+ else
+ name = bfd_section_name (input_bfd, s);
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section,
+ int_rel.r_vaddr - input_section->vma)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Read in the relocs for a section. */
+
+static boolean
+mips_read_relocs (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ struct ecoff_section_tdata *section_tdata;
+
+ section_tdata = ecoff_section_data (abfd, sec);
+ if (section_tdata == (struct ecoff_section_tdata *) NULL)
+ {
+ sec->used_by_bfd =
+ (PTR) bfd_alloc (abfd, sizeof (struct ecoff_section_tdata));
+ if (sec->used_by_bfd == NULL)
+ return false;
+
+ section_tdata = ecoff_section_data (abfd, sec);
+ section_tdata->external_relocs = NULL;
+ section_tdata->contents = NULL;
+ section_tdata->offsets = NULL;
+ }
+
+ if (section_tdata->external_relocs == NULL)
+ {
+ bfd_size_type external_relocs_size;
+
+ external_relocs_size = (ecoff_backend (abfd)->external_reloc_size
+ * sec->reloc_count);
+
+ section_tdata->external_relocs =
+ (PTR) bfd_alloc (abfd, external_relocs_size);
+ if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
+ return false;
+
+ if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
+ || (bfd_read (section_tdata->external_relocs, 1,
+ external_relocs_size, abfd)
+ != external_relocs_size))
+ return false;
+ }
+
+ return true;
+}
+
+/* Relax a section when linking a MIPS ECOFF file. This is used for
+ embedded PIC code, which always uses PC relative branches which
+ only have an 18 bit range on MIPS. If a branch is not in range, we
+ generate a long instruction sequence to compensate. Each time we
+ find a branch to expand, we have to check all the others again to
+ make sure they are still in range. This is slow, but it only has
+ to be done when -relax is passed to the linker.
+
+ This routine figures out which branches need to expand; the actual
+ expansion is done in mips_relocate_section when the section
+ contents are relocated. The information is stored in the offsets
+ field of the ecoff_section_tdata structure. An offset of 1 means
+ that the branch must be expanded into a multi-instruction PC
+ relative branch (such an offset will only occur for a PC relative
+ branch to an external symbol). Any other offset must be a multiple
+ of four, and is the amount to change the branch by (such an offset
+ will only occur for a PC relative branch within the same section).
+
+ We do not modify the section relocs or contents themselves so that
+ if memory usage becomes an issue we can discard them and read them
+ again. The only information we must save in memory between this
+ routine and the mips_relocate_section routine is the table of
+ offsets. */
+
+static boolean
+mips_relax_section (abfd, sec, info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *info;
+ boolean *again;
+{
+ struct ecoff_section_tdata *section_tdata;
+ bfd_byte *contents = NULL;
+ long *offsets;
+ struct external_reloc *ext_rel;
+ struct external_reloc *ext_rel_end;
+ unsigned int i;
+
+ /* Assume we are not going to need another pass. */
+ *again = false;
+
+ /* If we are not generating an ECOFF file, this is much too
+ confusing to deal with. */
+ if (info->hash->creator->flavour != bfd_get_flavour (abfd))
+ return true;
+
+ /* If there are no relocs, there is nothing to do. */
+ if (sec->reloc_count == 0)
+ return true;
+
+ /* We are only interested in PC relative relocs, and why would there
+ ever be one from anything but the .text section? */
+ if (strcmp (bfd_get_section_name (abfd, sec), ".text") != 0)
+ return true;
+
+ /* Read in the relocs, if we haven't already got them. */
+ section_tdata = ecoff_section_data (abfd, sec);
+ if (section_tdata == (struct ecoff_section_tdata *) NULL
+ || section_tdata->external_relocs == NULL)
+ {
+ if (! mips_read_relocs (abfd, sec))
+ goto error_return;
+ section_tdata = ecoff_section_data (abfd, sec);
+ }
+
+ if (sec->_cooked_size == 0)
+ {
+ /* We must initialize _cooked_size only the first time we are
+ called. */
+ sec->_cooked_size = sec->_raw_size;
+ }
+
+ contents = section_tdata->contents;
+ offsets = section_tdata->offsets;
+
+ /* Look for any external PC relative relocs. Internal PC relative
+ relocs are already correct in the object file, so they certainly
+ can not overflow. */
+ ext_rel = (struct external_reloc *) section_tdata->external_relocs;
+ ext_rel_end = ext_rel + sec->reloc_count;
+ for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++)
+ {
+ struct internal_reloc int_rel;
+ struct ecoff_link_hash_entry *h;
+ asection *hsec;
+ bfd_signed_vma relocation;
+ struct external_reloc *adj_ext_rel;
+ unsigned int adj_i;
+ unsigned long ext_count;
+ struct ecoff_link_hash_entry **adj_h_ptr;
+ struct ecoff_link_hash_entry **adj_h_ptr_end;
+ struct ecoff_value_adjust *adjust;
+
+ /* If we have already expanded this reloc, we certainly don't
+ need to do it again. */
+ if (offsets != (long *) NULL && offsets[i] == 1)
+ continue;
+
+ /* Quickly check that this reloc is external PCREL16. */
+ if (bfd_header_big_endian (abfd))
+ {
+ if ((ext_rel->r_bits[3] & RELOC_BITS3_EXTERN_BIG) == 0
+ || (((ext_rel->r_bits[3] & RELOC_BITS3_TYPE_BIG)
+ >> RELOC_BITS3_TYPE_SH_BIG)
+ != MIPS_R_PCREL16))
+ continue;
+ }
+ else
+ {
+ if ((ext_rel->r_bits[3] & RELOC_BITS3_EXTERN_LITTLE) == 0
+ || (((ext_rel->r_bits[3] & RELOC_BITS3_TYPE_LITTLE)
+ >> RELOC_BITS3_TYPE_SH_LITTLE)
+ != MIPS_R_PCREL16))
+ continue;
+ }
+
+ mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
+
+ h = ecoff_data (abfd)->sym_hashes[int_rel.r_symndx];
+ if (h == (struct ecoff_link_hash_entry *) NULL)
+ abort ();
+
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ {
+ /* Just ignore undefined symbols. These will presumably
+ generate an error later in the link. */
+ continue;
+ }
+
+ /* Get the value of the symbol. */
+ hsec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + hsec->output_section->vma
+ + hsec->output_offset);
+
+ /* Subtract out the current address. */
+ relocation -= (sec->output_section->vma
+ + sec->output_offset
+ + (int_rel.r_vaddr - sec->vma));
+
+ /* The addend is stored in the object file. In the normal case
+ of ``bal symbol'', the addend will be -4. It will only be
+ different in the case of ``bal symbol+constant''. To avoid
+ always reading in the section contents, we don't check the
+ addend in the object file (we could easily check the contents
+ if we happen to have already read them in, but I fear that
+ this could be confusing). This means we will screw up if
+ there is a branch to a symbol that is in range, but added to
+ a constant which puts it out of range; in such a case the
+ link will fail with a reloc overflow error. Since the
+ compiler will never generate such code, it should be easy
+ enough to work around it by changing the assembly code in the
+ source file. */
+ relocation -= 4;
+
+ /* Now RELOCATION is the number we want to put in the object
+ file. See whether it fits. */
+ if (relocation >= -0x20000 && relocation < 0x20000)
+ continue;
+
+ /* Now that we know this reloc needs work, which will rarely
+ happen, go ahead and grab the section contents. */
+ if (contents == (bfd_byte *) NULL)
+ {
+ if (info->keep_memory)
+ contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
+ else
+ contents = (bfd_byte *) bfd_malloc ((size_t) sec->_raw_size);
+ if (contents == (bfd_byte *) NULL)
+ goto error_return;
+ if (! bfd_get_section_contents (abfd, sec, (PTR) contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ if (info->keep_memory)
+ section_tdata->contents = contents;
+ }
+
+ /* We only support changing the bal instruction. It would be
+ possible to handle other PC relative branches, but some of
+ them (the conditional branches) would require a different
+ length instruction sequence which would complicate both this
+ routine and mips_relax_pcrel16. It could be written if
+ somebody felt it were important. Ignoring this reloc will
+ presumably cause a reloc overflow error later on. */
+ if (bfd_get_32 (abfd, contents + int_rel.r_vaddr - sec->vma)
+ != 0x0411ffff) /* bgezal $0,. == bal . */
+ continue;
+
+ /* Bother. We need to expand this reloc, and we will need to
+ make another relaxation pass since this change may put other
+ relocs out of range. We need to examine the local branches
+ and we need to allocate memory to hold the offsets we must
+ add to them. We also need to adjust the values of all
+ symbols in the object file following this location. */
+
+ sec->_cooked_size += PCREL16_EXPANSION_ADJUSTMENT;
+ *again = true;
+
+ if (offsets == (long *) NULL)
+ {
+ size_t size;
+
+ size = sec->reloc_count * sizeof (long);
+ offsets = (long *) bfd_alloc (abfd, size);
+ if (offsets == (long *) NULL)
+ goto error_return;
+ memset (offsets, 0, size);
+ section_tdata->offsets = offsets;
+ }
+
+ offsets[i] = 1;
+
+ /* Now look for all PC relative references that cross this reloc
+ and adjust their offsets. */
+ adj_ext_rel = (struct external_reloc *) section_tdata->external_relocs;
+ for (adj_i = 0; adj_ext_rel < ext_rel_end; adj_ext_rel++, adj_i++)
+ {
+ struct internal_reloc adj_int_rel;
+ bfd_vma start, stop;
+ int change;
+
+ mips_ecoff_swap_reloc_in (abfd, (PTR) adj_ext_rel, &adj_int_rel);
+
+ if (adj_int_rel.r_type == MIPS_R_PCREL16)
+ {
+ unsigned long insn;
+
+ /* We only care about local references. External ones
+ will be relocated correctly anyhow. */
+ if (adj_int_rel.r_extern)
+ continue;
+
+ /* We are only interested in a PC relative reloc within
+ this section. FIXME: Cross section PC relative
+ relocs may not be handled correctly; does anybody
+ care? */
+ if (adj_int_rel.r_symndx != RELOC_SECTION_TEXT)
+ continue;
+
+ start = adj_int_rel.r_vaddr;
+
+ insn = bfd_get_32 (abfd,
+ contents + adj_int_rel.r_vaddr - sec->vma);
+
+ stop = (insn & 0xffff) << 2;
+ if ((stop & 0x20000) != 0)
+ stop -= 0x40000;
+ stop += adj_int_rel.r_vaddr + 4;
+ }
+ else if (adj_int_rel.r_type == MIPS_R_RELHI)
+ {
+ struct internal_reloc rello;
+ long addhi, addlo;
+
+ /* The next reloc must be MIPS_R_RELLO, and we handle
+ them together. */
+ BFD_ASSERT (adj_ext_rel + 1 < ext_rel_end);
+
+ mips_ecoff_swap_reloc_in (abfd, (PTR) (adj_ext_rel + 1), &rello);
+
+ BFD_ASSERT (rello.r_type == MIPS_R_RELLO);
+
+ addhi = bfd_get_32 (abfd,
+ contents + adj_int_rel.r_vaddr - sec->vma);
+ addhi &= 0xffff;
+ if (addhi & 0x8000)
+ addhi -= 0x10000;
+ addhi <<= 16;
+
+ addlo = bfd_get_32 (abfd, contents + rello.r_vaddr - sec->vma);
+ addlo &= 0xffff;
+ if (addlo & 0x8000)
+ addlo -= 0x10000;
+
+ if (adj_int_rel.r_extern)
+ {
+ /* The value we want here is
+ sym - RELLOaddr + addend
+ which we can express as
+ sym - (RELLOaddr - addend)
+ Therefore if we are expanding the area between
+ RELLOaddr and RELLOaddr - addend we must adjust
+ the addend. This is admittedly ambiguous, since
+ we might mean (sym + addend) - RELLOaddr, but in
+ practice we don't, and there is no way to handle
+ that case correctly since at this point we have
+ no idea whether any reloc is being expanded
+ between sym and sym + addend. */
+ start = rello.r_vaddr - (addhi + addlo);
+ stop = rello.r_vaddr;
+ }
+ else
+ {
+ /* An internal RELHI/RELLO pair represents the
+ difference between two addresses, $LC0 - foo.
+ The symndx value is actually the difference
+ between the reloc address and $LC0. This lets us
+ compute $LC0, and, by considering the addend,
+ foo. If the reloc we are expanding falls between
+ those two relocs, we must adjust the addend. At
+ this point, the symndx value is actually in the
+ r_offset field, where it was put by
+ mips_ecoff_swap_reloc_in. */
+ start = rello.r_vaddr - adj_int_rel.r_offset;
+ stop = start + addhi + addlo;
+ }
+ }
+ else if (adj_int_rel.r_type == MIPS_R_SWITCH)
+ {
+ /* A MIPS_R_SWITCH reloc represents a word of the form
+ .word $L3-$LS12
+ The value in the object file is correct, assuming the
+ original value of $L3. The symndx value is actually
+ the difference between the reloc address and $LS12.
+ This lets us compute the original value of $LS12 as
+ vaddr - symndx
+ and the original value of $L3 as
+ vaddr - symndx + addend
+ where addend is the value from the object file. At
+ this point, the symndx value is actually found in the
+ r_offset field, since it was moved by
+ mips_ecoff_swap_reloc_in. */
+ start = adj_int_rel.r_vaddr - adj_int_rel.r_offset;
+ stop = start + bfd_get_32 (abfd,
+ (contents
+ + adj_int_rel.r_vaddr
+ - sec->vma));
+ }
+ else
+ continue;
+
+ /* If the range expressed by this reloc, which is the
+ distance between START and STOP crosses the reloc we are
+ expanding, we must adjust the offset. The sign of the
+ adjustment depends upon the direction in which the range
+ crosses the reloc being expanded. */
+ if (start <= int_rel.r_vaddr && stop > int_rel.r_vaddr)
+ change = PCREL16_EXPANSION_ADJUSTMENT;
+ else if (start > int_rel.r_vaddr && stop <= int_rel.r_vaddr)
+ change = - PCREL16_EXPANSION_ADJUSTMENT;
+ else
+ change = 0;
+
+ offsets[adj_i] += change;
+
+ if (adj_int_rel.r_type == MIPS_R_RELHI)
+ {
+ adj_ext_rel++;
+ adj_i++;
+ offsets[adj_i] += change;
+ }
+ }
+
+ /* Find all symbols in this section defined by this object file
+ and adjust their values. Note that we decide whether to
+ adjust the value based on the value stored in the ECOFF EXTR
+ structure, because the value stored in the hash table may
+ have been changed by an earlier expanded reloc and thus may
+ no longer correctly indicate whether the symbol is before or
+ after the expanded reloc. */
+ ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
+ adj_h_ptr = ecoff_data (abfd)->sym_hashes;
+ adj_h_ptr_end = adj_h_ptr + ext_count;
+ for (; adj_h_ptr < adj_h_ptr_end; adj_h_ptr++)
+ {
+ struct ecoff_link_hash_entry *adj_h;
+
+ adj_h = *adj_h_ptr;
+ if (adj_h != (struct ecoff_link_hash_entry *) NULL
+ && (adj_h->root.type == bfd_link_hash_defined
+ || adj_h->root.type == bfd_link_hash_defweak)
+ && adj_h->root.u.def.section == sec
+ && adj_h->esym.asym.value > int_rel.r_vaddr)
+ adj_h->root.u.def.value += PCREL16_EXPANSION_ADJUSTMENT;
+ }
+
+ /* Add an entry to the symbol value adjust list. This is used
+ by bfd_ecoff_debug_accumulate to adjust the values of
+ internal symbols and FDR's. */
+ adjust = ((struct ecoff_value_adjust *)
+ bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));
+ if (adjust == (struct ecoff_value_adjust *) NULL)
+ goto error_return;
+
+ adjust->start = int_rel.r_vaddr;
+ adjust->end = sec->vma + sec->_raw_size;
+ adjust->adjust = PCREL16_EXPANSION_ADJUSTMENT;
+
+ adjust->next = ecoff_data (abfd)->debug_info.adjust;
+ ecoff_data (abfd)->debug_info.adjust = adjust;
+ }
+
+ if (contents != (bfd_byte *) NULL && ! info->keep_memory)
+ free (contents);
+
+ return true;
+
+ error_return:
+ if (contents != (bfd_byte *) NULL && ! info->keep_memory)
+ free (contents);
+ return false;
+}
+
+/* This routine is called from mips_relocate_section when a PC
+ relative reloc must be expanded into the five instruction sequence.
+ It handles all the details of the expansion, including resolving
+ the reloc. */
+
+static boolean
+mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address)
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ struct ecoff_link_hash_entry *h;
+ bfd_byte *location;
+ bfd_vma address;
+{
+ bfd_vma relocation;
+
+ /* 0x0411ffff is bgezal $0,. == bal . */
+ BFD_ASSERT (bfd_get_32 (input_bfd, location) == 0x0411ffff);
+
+ /* We need to compute the distance between the symbol and the
+ current address plus eight. */
+ relocation = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ relocation -= address + 8;
+
+ /* If the lower half is negative, increment the upper 16 half. */
+ if ((relocation & 0x8000) != 0)
+ relocation += 0x10000;
+
+ bfd_put_32 (input_bfd, 0x04110001, location); /* bal .+8 */
+ bfd_put_32 (input_bfd,
+ 0x3c010000 | ((relocation >> 16) & 0xffff), /* lui $at,XX */
+ location + 4);
+ bfd_put_32 (input_bfd,
+ 0x24210000 | (relocation & 0xffff), /* addiu $at,$at,XX */
+ location + 8);
+ bfd_put_32 (input_bfd, 0x003f0821, location + 12); /* addu $at,$at,$ra */
+ bfd_put_32 (input_bfd, 0x0020f809, location + 16); /* jalr $at */
+
+ return true;
+}
+
+/* Given a .sdata section and a .rel.sdata in-memory section, store
+ relocation information into the .rel.sdata section which can be
+ used at runtime to relocate the section. This is called by the
+ linker when the --embedded-relocs switch is used. This is called
+ after the add_symbols entry point has been called for all the
+ objects, and before the final_link entry point is called. This
+ function presumes that the object was compiled using
+ -membedded-pic. */
+
+boolean
+bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *datasec;
+ asection *relsec;
+ char **errmsg;
+{
+ struct ecoff_link_hash_entry **sym_hashes;
+ struct ecoff_section_tdata *section_tdata;
+ struct external_reloc *ext_rel;
+ struct external_reloc *ext_rel_end;
+ bfd_byte *p;
+
+ BFD_ASSERT (! info->relocateable);
+
+ *errmsg = NULL;
+
+ if (datasec->reloc_count == 0)
+ return true;
+
+ sym_hashes = ecoff_data (abfd)->sym_hashes;
+
+ if (! mips_read_relocs (abfd, datasec))
+ return false;
+
+ relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
+ if (relsec->contents == NULL)
+ return false;
+
+ p = relsec->contents;
+
+ section_tdata = ecoff_section_data (abfd, datasec);
+ ext_rel = (struct external_reloc *) section_tdata->external_relocs;
+ ext_rel_end = ext_rel + datasec->reloc_count;
+ for (; ext_rel < ext_rel_end; ext_rel++, p += 4)
+ {
+ struct internal_reloc int_rel;
+ boolean text_relative;
+
+ mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
+
+ /* We are going to write a four byte word into the runtime reloc
+ section. The word will be the address in the data section
+ which must be relocated. This must be on a word boundary,
+ which means the lower two bits must be zero. We use the
+ least significant bit to indicate how the value in the data
+ section must be relocated. A 0 means that the value is
+ relative to the text section, while a 1 indicates that the
+ value is relative to the data section. Given that we are
+ assuming the code was compiled using -membedded-pic, there
+ should not be any other possibilities. */
+
+ /* We can only relocate REFWORD relocs at run time. */
+ if (int_rel.r_type != MIPS_R_REFWORD)
+ {
+ *errmsg = _("unsupported reloc type");
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (int_rel.r_extern)
+ {
+ struct ecoff_link_hash_entry *h;
+
+ h = sym_hashes[int_rel.r_symndx];
+ /* If h is NULL, that means that there is a reloc against an
+ external symbol which we thought was just a debugging
+ symbol. This should not happen. */
+ if (h == (struct ecoff_link_hash_entry *) NULL)
+ abort ();
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->flags & SEC_CODE) != 0)
+ text_relative = true;
+ else
+ text_relative = false;
+ }
+ else
+ {
+ switch (int_rel.r_symndx)
+ {
+ case RELOC_SECTION_TEXT:
+ text_relative = true;
+ break;
+ case RELOC_SECTION_SDATA:
+ case RELOC_SECTION_SBSS:
+ case RELOC_SECTION_LIT8:
+ text_relative = false;
+ break;
+ default:
+ /* No other sections should appear in -membedded-pic
+ code. */
+ *errmsg = _("reloc against unsupported section");
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ if ((int_rel.r_offset & 3) != 0)
+ {
+ *errmsg = _("reloc not properly aligned");
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ bfd_put_32 (abfd,
+ (int_rel.r_vaddr - datasec->vma + datasec->output_offset
+ + (text_relative ? 0 : 1)),
+ p);
+ }
+
+ return true;
+}
+
+/* This is the ECOFF backend structure. The backend field of the
+ target vector points to this. */
+
+static const struct ecoff_backend_data mips_ecoff_backend_data =
+{
+ /* COFF backend structure. */
+ {
+ (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
+ (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
+ (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
+ (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
+ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
+ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
+ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
+ mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out,
+ mips_ecoff_swap_scnhdr_out,
+ FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true, false, 4,
+ mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in,
+ mips_ecoff_swap_scnhdr_in, NULL,
+ mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
+ _bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
+ _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ },
+ /* Supported architecture. */
+ bfd_arch_mips,
+ /* Initial portion of armap string. */
+ "__________",
+ /* The page boundary used to align sections in a demand-paged
+ executable file. E.g., 0x1000. */
+ 0x1000,
+ /* True if the .rdata section is part of the text segment, as on the
+ Alpha. False if .rdata is part of the data segment, as on the
+ MIPS. */
+ false,
+ /* Bitsize of constructor entries. */
+ 32,
+ /* Reloc to use for constructor entries. */
+ &mips_howto_table[MIPS_R_REFWORD],
+ {
+ /* Symbol table magic number. */
+ magicSym,
+ /* Alignment of debugging information. E.g., 4. */
+ 4,
+ /* Sizes of external symbolic information. */
+ sizeof (struct hdr_ext),
+ sizeof (struct dnr_ext),
+ sizeof (struct pdr_ext),
+ sizeof (struct sym_ext),
+ sizeof (struct opt_ext),
+ sizeof (struct fdr_ext),
+ sizeof (struct rfd_ext),
+ sizeof (struct ext_ext),
+ /* Functions to swap in external symbolic data. */
+ ecoff_swap_hdr_in,
+ ecoff_swap_dnr_in,
+ ecoff_swap_pdr_in,
+ ecoff_swap_sym_in,
+ ecoff_swap_opt_in,
+ ecoff_swap_fdr_in,
+ ecoff_swap_rfd_in,
+ ecoff_swap_ext_in,
+ _bfd_ecoff_swap_tir_in,
+ _bfd_ecoff_swap_rndx_in,
+ /* Functions to swap out external symbolic data. */
+ ecoff_swap_hdr_out,
+ ecoff_swap_dnr_out,
+ ecoff_swap_pdr_out,
+ ecoff_swap_sym_out,
+ ecoff_swap_opt_out,
+ ecoff_swap_fdr_out,
+ ecoff_swap_rfd_out,
+ ecoff_swap_ext_out,
+ _bfd_ecoff_swap_tir_out,
+ _bfd_ecoff_swap_rndx_out,
+ /* Function to read in symbolic data. */
+ _bfd_ecoff_slurp_symbolic_info
+ },
+ /* External reloc size. */
+ RELSZ,
+ /* Reloc swapping functions. */
+ mips_ecoff_swap_reloc_in,
+ mips_ecoff_swap_reloc_out,
+ /* Backend reloc tweaking. */
+ mips_adjust_reloc_in,
+ mips_adjust_reloc_out,
+ /* Relocate section contents while linking. */
+ mips_relocate_section,
+ /* Do final adjustments to filehdr and aouthdr. */
+ NULL,
+ /* Read an element from an archive at a given file position. */
+ _bfd_get_elt_at_filepos
+};
+
+/* Looking up a reloc type is MIPS specific. */
+#define _bfd_ecoff_bfd_reloc_type_lookup mips_bfd_reloc_type_lookup
+
+/* Getting relocated section contents is generic. */
+#define _bfd_ecoff_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+
+/* Handling file windows is generic. */
+#define _bfd_ecoff_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+/* Relaxing sections is MIPS specific. */
+#define _bfd_ecoff_bfd_relax_section mips_relax_section
+
+/* GC of sections is not done. */
+#define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
+
+const bfd_target ecoff_little_vec =
+{
+ "ecoff-littlemips", /* name */
+ bfd_target_ecoff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ _bfd_ecoff_archive_p, _bfd_dummy_target},
+ {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+ BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+ BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+ BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+ BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) &mips_ecoff_backend_data
+};
+
+const bfd_target ecoff_big_vec =
+{
+ "ecoff-bigmips", /* name */
+ bfd_target_ecoff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ 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_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16,
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ _bfd_ecoff_archive_p, _bfd_dummy_target},
+ {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+ BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+ BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+ BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+ BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) &mips_ecoff_backend_data
+};
+
+const bfd_target ecoff_biglittle_vec =
+{
+ "ecoff-biglittlemips", /* name */
+ bfd_target_ecoff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ _bfd_ecoff_archive_p, _bfd_dummy_target},
+ {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+ BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+ BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+ BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+ BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) &mips_ecoff_backend_data
+};
diff --git a/bfd/coff-pmac.c b/bfd/coff-pmac.c
new file mode 100644
index 00000000000..f3332d98959
--- /dev/null
+++ b/bfd/coff-pmac.c
@@ -0,0 +1,27 @@
+/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
+ Copyright 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM pmac_xcoff_vec
+#define TARGET_NAME "xcoff-powermac"
+
+/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
+
+#define POWERMAC
+
+#include "coff-rs6000.c"
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
new file mode 100644
index 00000000000..cf4504479b5
--- /dev/null
+++ b/bfd/coff-ppc.c
@@ -0,0 +1,2934 @@
+/* BFD back-end for PowerPC Microsoft Portable Executable files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+
+ Original version pieced together by Kim Knuttila (krk@cygnus.com)
+
+ There is nothing new under the sun. This file draws a lot on other
+ coff files, in particular, those for the rs/6000, alpha, mips, and
+ intel backends, and the PE work for the arm.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* Current State:
+ - objdump works
+ - relocs generated by gas
+ - ld will link files, but they do not run.
+ - dlltool will not produce correct output in some .reloc cases, and will
+ not produce the right glue code for dll function calls.
+*/
+
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#include "libbfd.h"
+
+#include "coff/powerpc.h"
+#include "coff/internal.h"
+
+#include "coff/pe.h"
+
+#ifdef BADMAG
+#undef BADMAG
+#endif
+
+#define BADMAG(x) PPCBADMAG(x)
+
+#include "libcoff.h"
+
+/* This file is compiled more than once, but we only compile the
+ final_link routine once. */
+extern boolean ppc_bfd_coff_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern void dump_toc PARAMS ((PTR));
+
+/* The toc is a set of bfd_vma fields. We use the fact that valid */
+/* addresses are even (i.e. the bit representing "1" is off) to allow */
+/* us to encode a little extra information in the field */
+/* - Unallocated addresses are intialized to 1. */
+/* - Allocated addresses are even numbers. */
+/* The first time we actually write a reference to the toc in the bfd, */
+/* we want to record that fact in a fixup file (if it is asked for), so */
+/* we keep track of whether or not an address has been written by marking */
+/* the low order bit with a "1" upon writing */
+
+#define SET_UNALLOCATED(x) ((x) = 1)
+#define IS_UNALLOCATED(x) ((x) == 1)
+
+#define IS_WRITTEN(x) ((x) & 1)
+#define MARK_AS_WRITTEN(x) ((x) |= 1)
+#define MAKE_ADDR_AGAIN(x) ((x) &= ~1)
+
+
+/* Turn on this check if you suspect something amiss in the hash tables */
+#ifdef DEBUG_HASH
+
+/* Need a 7 char string for an eye catcher */
+#define EYE "krkjunk"
+
+#define HASH_CHECK_DCL char eye_catcher[8];
+#define HASH_CHECK_INIT(ret) strcpy(ret->eye_catcher, EYE)
+#define HASH_CHECK(addr) \
+ if (strcmp(addr->eye_catcher, EYE) != 0) \
+ { \
+ fprintf(stderr,\
+ _("File %s, line %d, Hash check failure, bad eye %8s\n"), \
+ __FILE__, __LINE__, addr->eye_catcher); \
+ abort(); \
+ }
+
+
+#else
+
+#define HASH_CHECK_DCL
+#define HASH_CHECK_INIT(ret)
+#define HASH_CHECK(addr)
+
+#endif
+
+/* In order not to add an int to every hash table item for every coff
+ linker, we define our own hash table, derived from the coff one */
+
+/* PE linker hash table entries. */
+
+struct ppc_coff_link_hash_entry
+{
+ struct coff_link_hash_entry root; /* First entry, as required */
+
+ /* As we wonder around the relocs, we'll keep the assigned toc_offset
+ here */
+ bfd_vma toc_offset; /* Our addition, as required */
+ int symbol_is_glue;
+ unsigned long int glue_insn;
+
+ HASH_CHECK_DCL
+};
+
+
+/* PE linker hash table. */
+
+struct ppc_coff_link_hash_table
+{
+ struct coff_link_hash_table root; /* First entry, as required */
+};
+
+static struct bfd_hash_entry *ppc_coff_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
+ const char *));
+static boolean ppc_coff_link_hash_table_init
+ PARAMS ((struct ppc_coff_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+static struct bfd_link_hash_table *ppc_coff_link_hash_table_create
+ PARAMS ((bfd *));
+static boolean coff_ppc_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+static reloc_howto_type *coff_ppc_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
+
+/* Routine to create an entry in the link hash table. */
+
+static struct bfd_hash_entry *
+ppc_coff_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct ppc_coff_link_hash_entry *ret =
+ (struct ppc_coff_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct ppc_coff_link_hash_entry *) NULL)
+ ret = (struct ppc_coff_link_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct ppc_coff_link_hash_entry));
+
+ if (ret == (struct ppc_coff_link_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct ppc_coff_link_hash_entry *)
+ _bfd_coff_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ SET_UNALLOCATED(ret->toc_offset);
+ ret->symbol_is_glue = 0;
+ ret->glue_insn = 0;
+
+ HASH_CHECK_INIT(ret);
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize a PE linker hash table. */
+
+static boolean
+ppc_coff_link_hash_table_init (table, abfd, newfunc)
+ struct ppc_coff_link_hash_table *table;
+ bfd *abfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc);
+}
+
+/* Create a PE linker hash table. */
+
+static struct bfd_link_hash_table *
+ppc_coff_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct ppc_coff_link_hash_table *ret;
+
+ ret = ((struct ppc_coff_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
+ if (ret == NULL)
+ return NULL;
+ if (! ppc_coff_link_hash_table_init (ret, abfd,
+ ppc_coff_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+ return &ret->root.root;
+}
+
+/* Now, tailor coffcode.h to use our hash stuff */
+
+#define coff_bfd_link_hash_table_create ppc_coff_link_hash_table_create
+
+
+/* The nt loader points the toc register to &toc + 32768, in order to */
+/* use the complete range of a 16-bit displacement. We have to adjust */
+/* for this when we fix up loads displaced off the toc reg. */
+#define TOC_LOAD_ADJUSTMENT (-32768)
+#define TOC_SECTION_NAME ".private.toc"
+
+/* The main body of code is in coffcode.h. */
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+/* these should definitely go in a header file somewhere... */
+
+/* NOP */
+#define IMAGE_REL_PPC_ABSOLUTE 0x0000
+
+/* 64-bit address */
+#define IMAGE_REL_PPC_ADDR64 0x0001
+
+/* 32-bit address */
+#define IMAGE_REL_PPC_ADDR32 0x0002
+
+/* 26-bit address, shifted left 2 (branch absolute) */
+#define IMAGE_REL_PPC_ADDR24 0x0003
+
+/* 16-bit address */
+#define IMAGE_REL_PPC_ADDR16 0x0004
+
+/* 16-bit address, shifted left 2 (load doubleword) */
+#define IMAGE_REL_PPC_ADDR14 0x0005
+
+/* 26-bit PC-relative offset, shifted left 2 (branch relative) */
+#define IMAGE_REL_PPC_REL24 0x0006
+
+/* 16-bit PC-relative offset, shifted left 2 (br cond relative) */
+#define IMAGE_REL_PPC_REL14 0x0007
+
+/* 16-bit offset from TOC base */
+#define IMAGE_REL_PPC_TOCREL16 0x0008
+
+/* 16-bit offset from TOC base, shifted left 2 (load doubleword) */
+#define IMAGE_REL_PPC_TOCREL14 0x0009
+
+/* 32-bit addr w/o image base */
+#define IMAGE_REL_PPC_ADDR32NB 0x000A
+
+/* va of containing section (as in an image sectionhdr) */
+#define IMAGE_REL_PPC_SECREL 0x000B
+
+/* sectionheader number */
+#define IMAGE_REL_PPC_SECTION 0x000C
+
+/* substitute TOC restore instruction iff symbol is glue code */
+#define IMAGE_REL_PPC_IFGLUE 0x000D
+
+/* symbol is glue code; virtual address is TOC restore instruction */
+#define IMAGE_REL_PPC_IMGLUE 0x000E
+
+/* va of containing section (limited to 16 bits) */
+#define IMAGE_REL_PPC_SECREL16 0x000F
+
+/* stuff to handle immediate data when the number of bits in the */
+/* data is greater than the number of bits in the immediate field */
+/* We need to do (usually) 32 bit arithmetic on 16 bit chunks */
+#define IMAGE_REL_PPC_REFHI 0x0010
+#define IMAGE_REL_PPC_REFLO 0x0011
+#define IMAGE_REL_PPC_PAIR 0x0012
+
+/* This is essentially the same as tocrel16, with TOCDEFN assumed */
+#define IMAGE_REL_PPC_TOCREL16_DEFN 0x0013
+
+/* Flag bits in IMAGE_RELOCATION.TYPE */
+
+/* subtract reloc value rather than adding it */
+#define IMAGE_REL_PPC_NEG 0x0100
+
+/* fix branch prediction bit to predict branch taken */
+#define IMAGE_REL_PPC_BRTAKEN 0x0200
+
+/* fix branch prediction bit to predict branch not taken */
+#define IMAGE_REL_PPC_BRNTAKEN 0x0400
+
+/* toc slot defined in file (or, data in toc) */
+#define IMAGE_REL_PPC_TOCDEFN 0x0800
+
+/* masks to isolate above values in IMAGE_RELOCATION.Type */
+#define IMAGE_REL_PPC_TYPEMASK 0x00FF
+#define IMAGE_REL_PPC_FLAGMASK 0x0F00
+
+#define EXTRACT_TYPE(x) ((x) & IMAGE_REL_PPC_TYPEMASK)
+#define EXTRACT_FLAGS(x) ((x) & IMAGE_REL_PPC_FLAGMASK)
+#define EXTRACT_JUNK(x) \
+ ((x) & ~(IMAGE_REL_PPC_TYPEMASK | IMAGE_REL_PPC_FLAGMASK))
+
+
+/* static helper functions to make relocation work */
+/* (Work In Progress) */
+
+static bfd_reloc_status_type ppc_refhi_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+#if 0
+static bfd_reloc_status_type ppc_reflo_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+#endif
+static bfd_reloc_status_type ppc_pair_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+
+
+static bfd_reloc_status_type ppc_toc16_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+
+#if 0
+static bfd_reloc_status_type ppc_addr32nb_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+#endif
+static bfd_reloc_status_type ppc_section_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+
+static bfd_reloc_status_type ppc_secrel_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+
+static bfd_reloc_status_type ppc_imglue_reloc PARAMS ((bfd *abfd,
+ arelent *reloc,
+ asymbol *symbol,
+ PTR data,
+ asection *section,
+ bfd *output_bfd,
+ char **error));
+
+
+
+static boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
+
+
+/* FIXME: It'll take a while to get through all of these. I only need a few to
+ get us started, so those I'll make sure work. Those marked FIXME are either
+ completely unverified or have a specific unknown marked in the comment */
+
+/*---------------------------------------------------------------------------*/
+/* */
+/* Relocation entries for Windows/NT on PowerPC. */
+/* */
+/* From the document "" we find the following listed as used relocs: */
+/* */
+/* ABSOLUTE : The noop */
+/* ADDR[64|32|16] : fields that hold addresses in data fields or the */
+/* 16 bit displacement field on a load/store. */
+/* ADDR[24|14] : fields that hold addresses in branch and cond */
+/* branches. These represent [26|16] bit addresses. */
+/* The low order 2 bits are preserved. */
+/* REL[24|14] : branches relative to the Instruction Address */
+/* register. These represent [26|16] bit addresses, */
+/* as before. The instruction field will be zero, and */
+/* the address of the SYM will be inserted at link time. */
+/* TOCREL16 : 16 bit displacement field referring to a slot in */
+/* toc. */
+/* TOCREL14 : 16 bit displacement field, similar to REL14 or ADDR14. */
+/* ADDR32NB : 32 bit address relative to the virtual origin. */
+/* (On the alpha, this is always a linker generated thunk)*/
+/* (i.e. 32bit addr relative to the image base) */
+/* SECREL : The value is relative to the start of the section */
+/* containing the symbol. */
+/* SECTION : access to the header containing the item. Supports the */
+/* codeview debugger. */
+/* */
+/* In particular, note that the document does not indicate that the */
+/* relocations listed in the header file are used. */
+/* */
+/* */
+/* */
+/*---------------------------------------------------------------------------*/
+
+static reloc_howto_type ppc_coff_howto_table[] =
+{
+ /* IMAGE_REL_PPC_ABSOLUTE 0x0000 NOP */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_ABSOLUTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* dont complain_on_overflow */
+ 0, /* special_function */
+ "ABSOLUTE", /* name */
+ false, /* partial_inplace */
+ 0x00, /* src_mask */
+ 0x00, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_ADDR64 0x0001 64-bit address */
+ /* Unused: */
+ HOWTO(IMAGE_REL_PPC_ADDR64, /* type */
+ 0, /* rightshift */
+ 3, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ 0, /* special_function */
+ "ADDR64", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_ADDR32 0x0002 32-bit address */
+ /* Used: */
+ HOWTO (IMAGE_REL_PPC_ADDR32, /* 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 */
+ "ADDR32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_ADDR24 0x0003 26-bit address, shifted left 2 (branch absolute) */
+ /* the LI field is in bit 6 through bit 29 is 24 bits, + 2 for the shift */
+ /* Of course, That's the IBM approved bit numbering, which is not what */
+ /* anyone else uses.... The li field is in bit 2 thru 25 */
+ /* Used: */
+ HOWTO (IMAGE_REL_PPC_ADDR24, /* 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 */
+ "ADDR24", /* name */
+ true, /* partial_inplace */
+ 0x07fffffc, /* src_mask */
+ 0x07fffffc, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_ADDR16 0x0004 16-bit address */
+ /* Used: */
+ HOWTO (IMAGE_REL_PPC_ADDR16, /* 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 */
+ "ADDR16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_ADDR14 0x0005 */
+ /* 16-bit address, shifted left 2 (load doubleword) */
+ /* FIXME: the mask is likely wrong, and the bit position may be as well */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_ADDR14, /* type */
+ 1, /* 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 */
+ "ADDR16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_REL24 0x0006 */
+ /* 26-bit PC-relative offset, shifted left 2 (branch relative) */
+ /* Used: */
+ HOWTO (IMAGE_REL_PPC_REL24, /* 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 */
+ "REL24", /* name */
+ true, /* partial_inplace */
+ 0x3fffffc, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_REL14 0x0007 */
+ /* 16-bit PC-relative offset, shifted left 2 (br cond relative) */
+ /* FIXME: the mask is likely wrong, and the bit position may be as well */
+ /* FIXME: how does it know how far to shift? */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_ADDR14, /* type */
+ 1, /* 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 */
+ "ADDR16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_TOCREL16 0x0008 */
+ /* 16-bit offset from TOC base */
+ /* Used: */
+ HOWTO (IMAGE_REL_PPC_TOCREL16,/* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ ppc_toc16_reloc, /* special_function */
+ "TOCREL16", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_TOCREL14 0x0009 */
+ /* 16-bit offset from TOC base, shifted left 2 (load doubleword) */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_TOCREL14,/* type */
+ 1, /* 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 */
+ "TOCREL14", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_ADDR32NB 0x000A */
+ /* 32-bit addr w/ image base */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_ADDR32NB,/* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ 0, /* special_function */
+ "ADDR32NB", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_SECREL 0x000B */
+ /* va of containing section (as in an image sectionhdr) */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_SECREL,/* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ ppc_secrel_reloc, /* special_function */
+ "SECREL", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_SECTION 0x000C */
+ /* sectionheader number */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_SECTION,/* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ ppc_section_reloc, /* special_function */
+ "SECTION", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_IFGLUE 0x000D */
+ /* substitute TOC restore instruction iff symbol is glue code */
+ /* Used: */
+ HOWTO (IMAGE_REL_PPC_IFGLUE,/* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ 0, /* special_function */
+ "IFGLUE", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_IMGLUE 0x000E */
+ /* symbol is glue code; virtual address is TOC restore instruction */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_IMGLUE,/* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ ppc_imglue_reloc, /* special_function */
+ "IMGLUE", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_SECREL16 0x000F */
+ /* va of containing section (limited to 16 bits) */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_SECREL16,/* 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 */
+ "SECREL16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_REFHI 0x0010 */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_REFHI, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ ppc_refhi_reloc, /* special_function */
+ "REFHI", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_REFLO 0x0011 */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_REFLO, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ ppc_refhi_reloc, /* special_function */
+ "REFLO", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_PAIR 0x0012 */
+ /* Unused: */
+ HOWTO (IMAGE_REL_PPC_PAIR, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ ppc_pair_reloc, /* special_function */
+ "PAIR", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* IMAGE_REL_PPC_TOCREL16_DEFN 0x0013 */
+ /* 16-bit offset from TOC base, without causing a definition */
+ /* Used: */
+ HOWTO ( (IMAGE_REL_PPC_TOCREL16 | IMAGE_REL_PPC_TOCDEFN), /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ 0, /* special_function */
+ "TOCREL16, TOCDEFN", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+
+
+
+/* Some really cheezy macros that can be turned on to test stderr :-) */
+
+#ifdef DEBUG_RELOC
+#define UN_IMPL(x) \
+{ \
+ static int i; \
+ if (i == 0) \
+ { \
+ i = 1; \
+ fprintf(stderr,_("Unimplemented Relocation -- %s\n"),x); \
+ } \
+}
+
+#define DUMP_RELOC(n,r) \
+{ \
+ fprintf(stderr,"%s sym %d, addr %d, addend %d\n", \
+ n, (*(r->sym_ptr_ptr))->name, \
+ r->address, r->addend); \
+}
+
+/* Given a reloc name, n, and a pointer to an internal_reloc,
+ dump out interesting information on the contents
+
+#define n_name _n._n_name
+#define n_zeroes _n._n_n._n_zeroes
+#define n_offset _n._n_n._n_offset
+
+*/
+
+#define DUMP_RELOC2(n,r) \
+{ \
+ fprintf(stderr,"%s sym %d, r_vaddr %d %s\n", \
+ n, r->r_symndx, r->r_vaddr,\
+ (((r->r_type) & IMAGE_REL_PPC_TOCDEFN) == 0) \
+ ?" ":" TOCDEFN" ); \
+}
+
+#else
+#define UN_IMPL(x)
+#define DUMP_RELOC(n,r)
+#define DUMP_RELOC2(n,r)
+#endif
+
+
+
+/* toc construction and management routines */
+
+/* This file is compiled twice, and these variables are defined in one
+ of the compilations. FIXME: This is confusing and weird. Also,
+ BFD should not use global variables. */
+extern bfd* bfd_of_toc_owner;
+extern long int global_toc_size;
+
+extern long int import_table_size;
+extern long int first_thunk_address;
+extern long int thunk_size;
+
+enum toc_type
+{
+ default_toc,
+ toc_32,
+ toc_64
+};
+
+enum ref_category
+{
+ priv,
+ pub,
+ data
+};
+
+struct list_ele
+{
+ struct list_ele *next;
+ bfd_vma addr;
+ enum ref_category cat;
+ int offset;
+ const char *name;
+};
+
+extern struct list_ele *head;
+extern struct list_ele *tail;
+
+static void record_toc
+ PARAMS ((asection *, int, enum ref_category, const char *));
+
+static void
+record_toc (toc_section, our_toc_offset, cat, name)
+ asection *toc_section;
+ int our_toc_offset;
+ enum ref_category cat;
+ const char *name;
+{
+ /* add this entry to our toc addr-offset-name list */
+ struct list_ele *t;
+ t = (struct list_ele *) bfd_malloc (sizeof (struct list_ele));
+ if (t == NULL)
+ abort ();
+ t->next = 0;
+ t->offset = our_toc_offset;
+ t->name = name;
+ t->cat = cat;
+ t->addr = toc_section->output_offset + our_toc_offset;
+
+ if (head == 0)
+ {
+ head = t;
+ tail = t;
+ }
+ else
+ {
+ tail->next = t;
+ tail = t;
+ }
+}
+
+#ifdef COFF_IMAGE_WITH_PE
+
+static boolean ppc_record_toc_entry
+ PARAMS ((bfd *, struct bfd_link_info *, asection *, int, enum toc_type));
+static void ppc_mark_symbol_as_glue
+ PARAMS ((bfd *, int, struct internal_reloc *));
+
+/* record a toc offset against a symbol */
+static boolean
+ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ int sym;
+ enum toc_type toc_kind;
+{
+ struct ppc_coff_link_hash_entry *h;
+ const char *name;
+
+ int *local_syms;
+
+ h = 0;
+
+ h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]);
+ if (h != 0)
+ {
+ HASH_CHECK(h);
+ }
+
+ if (h == 0)
+ {
+ local_syms = obj_coff_local_toc_table(abfd);
+ if (local_syms == 0)
+ {
+ unsigned int i;
+ /* allocate a table */
+ local_syms =
+ (int *) bfd_zalloc (abfd,
+ obj_raw_syment_count(abfd) * sizeof(int));
+ if (local_syms == 0)
+ return false;
+ obj_coff_local_toc_table(abfd) = local_syms;
+ for (i = 0; i < obj_raw_syment_count(abfd); ++i)
+ {
+ SET_UNALLOCATED(local_syms[i]);
+ }
+ }
+
+ if (IS_UNALLOCATED(local_syms[sym]))
+ {
+ local_syms[sym] = global_toc_size;
+ global_toc_size += 4;
+
+ /* The size must fit in a 16bit displacment */
+ if (global_toc_size > 65535)
+ {
+ (*_bfd_error_handler) (_("TOC overflow"));
+ bfd_set_error (bfd_error_file_too_big);
+ return false;
+ }
+ }
+ }
+ else
+ {
+ name = h->root.root.root.string;
+
+ /* check to see if there's a toc slot allocated. If not, do it
+ here. It will be used in relocate_section */
+ if (IS_UNALLOCATED(h->toc_offset))
+ {
+ h->toc_offset = global_toc_size;
+ global_toc_size += 4;
+
+ /* The size must fit in a 16bit displacment */
+ if (global_toc_size >= 65535)
+ {
+ (*_bfd_error_handler) (_("TOC overflow"));
+ bfd_set_error (bfd_error_file_too_big);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* record a toc offset against a symbol */
+static void
+ppc_mark_symbol_as_glue(abfd, sym, rel)
+ bfd *abfd;
+ int sym;
+ struct internal_reloc *rel;
+{
+ struct ppc_coff_link_hash_entry *h;
+
+ h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]);
+
+ HASH_CHECK(h);
+
+ h->symbol_is_glue = 1;
+ h->glue_insn = bfd_get_32 (abfd, (bfd_byte *) &rel->r_vaddr);
+
+ return;
+}
+
+#endif /* COFF_IMAGE_WITH_PE */
+
+
+/* Return true if this relocation should
+ appear in the output .reloc section. */
+
+static boolean in_reloc_p(abfd, howto)
+ bfd * abfd;
+ reloc_howto_type *howto;
+{
+ return
+ (! howto->pc_relative)
+ && (howto->type != IMAGE_REL_PPC_ADDR32NB)
+ && (howto->type != IMAGE_REL_PPC_TOCREL16)
+ && (howto->type != IMAGE_REL_PPC_IMGLUE)
+ && (howto->type != IMAGE_REL_PPC_IFGLUE)
+ && (howto->type != IMAGE_REL_PPC_SECREL)
+ && (howto->type != IMAGE_REL_PPC_SECTION)
+ && (howto->type != IMAGE_REL_PPC_SECREL16)
+ && (howto->type != IMAGE_REL_PPC_REFHI)
+ && (howto->type != IMAGE_REL_PPC_REFLO)
+ && (howto->type != IMAGE_REL_PPC_PAIR)
+ && (howto->type != IMAGE_REL_PPC_TOCREL16_DEFN) ;
+}
+
+#if 0
+
+/* this function is in charge of performing all the ppc PE relocations */
+/* Don't yet know if we want to do this this particular way ... (krk) */
+/* FIXME: (it is not yet enabled) */
+
+static bfd_reloc_status_type
+pe_ppc_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* the consth relocation comes in two parts, we have to remember
+ the state between calls, in these variables */
+ static boolean part1_consth_active = false;
+ static unsigned long part1_consth_value;
+
+ unsigned long sym_value;
+ unsigned short r_type;
+ unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
+
+ r_type = reloc_entry->howto->type;
+
+ if (output_bfd)
+ {
+ /* Partial linking - do nothing */
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (symbol_in != NULL
+ && bfd_is_und_section (symbol_in->section))
+ {
+ /* Keep the state machine happy in case we're called again */
+ if (r_type == IMAGE_REL_PPC_REFHI)
+ {
+ part1_consth_active = true;
+ part1_consth_value = 0;
+ }
+ return(bfd_reloc_undefined);
+ }
+
+ if ((part1_consth_active) && (r_type != IMAGE_REL_PPC_PAIR))
+ {
+ part1_consth_active = false;
+ *error_message = (char *) _("Missing PAIR");
+ return(bfd_reloc_dangerous);
+ }
+
+
+ sym_value = get_symbol_value(symbol_in);
+
+ return(bfd_reloc_ok);
+}
+
+#endif /* 0 */
+
+/* The reloc processing routine for the optimized COFF linker. */
+
+static boolean
+coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, syms, sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+ boolean hihalf;
+ bfd_vma hihalf_val;
+ asection *toc_section = 0;
+ bfd_vma relocation;
+ reloc_howto_type *howto = 0;
+
+ /* If we are performing a relocateable link, we don't need to do a
+ thing. The caller will take care of adjusting the reloc
+ addresses and symbol indices. */
+ if (info->relocateable)
+ return true;
+
+ hihalf = false;
+ hihalf_val = 0;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ struct ppc_coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma val;
+
+ asection *sec;
+ bfd_reloc_status_type rstat;
+ bfd_byte *loc;
+
+ unsigned short r_type = EXTRACT_TYPE (rel->r_type);
+ unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
+
+ symndx = rel->r_symndx;
+ loc = contents + rel->r_vaddr - input_section->vma;
+
+ /* FIXME: check bounds on r_type */
+ howto = ppc_coff_howto_table + r_type;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ h = (struct ppc_coff_link_hash_entry *)
+ (obj_coff_sym_hashes (input_bfd)[symndx]);
+ if (h != 0)
+ {
+ HASH_CHECK(h);
+ }
+
+ sym = syms + symndx;
+ }
+
+ if (r_type == IMAGE_REL_PPC_IMGLUE && h == 0)
+ {
+ /* An IMGLUE reloc must have a name. Something is very wrong. */
+ abort();
+ }
+
+ sec = NULL;
+ val = 0;
+
+ /* FIXME: PAIR unsupported in the following code */
+ if (h == NULL)
+ {
+ if (symndx == -1)
+ sec = bfd_abs_section_ptr;
+ else
+ {
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value);
+ if (! obj_pe (output_bfd))
+ val -= sec->vma;
+ }
+ }
+ else
+ {
+ HASH_CHECK(h);
+
+ if (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.root.u.def.section;
+ val = (h->root.root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ rstat = bfd_reloc_ok;
+
+ /* Each case must do its own relocation, setting rstat appropriately */
+ switch (r_type)
+ {
+ default:
+ (*_bfd_error_handler)
+ (_("%s: unsupported relocation type 0x%02x"),
+ bfd_get_filename (input_bfd), r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ case IMAGE_REL_PPC_TOCREL16:
+ {
+ bfd_vma our_toc_offset;
+ int fixit;
+
+ DUMP_RELOC2(howto->name, rel);
+
+ if (toc_section == 0)
+ {
+ toc_section = bfd_get_section_by_name (bfd_of_toc_owner,
+ TOC_SECTION_NAME);
+
+ if ( toc_section == NULL )
+ {
+ /* There is no toc section. Something is very wrong. */
+ abort();
+ }
+ }
+
+ /*
+ * Amazing bit tricks present. As we may have seen earlier, we
+ * use the 1 bit to tell us whether or not a toc offset has been
+ * allocated. Now that they've all been allocated, we will use
+ * the 1 bit to tell us if we've written this particular toc
+ * entry out.
+ */
+ fixit = false;
+ if (h == 0)
+ { /* it is a file local symbol */
+ int *local_toc_table;
+ const char *name;
+
+ sym = syms + symndx;
+ name = sym->_n._n_name;
+
+ local_toc_table = obj_coff_local_toc_table(input_bfd);
+ our_toc_offset = local_toc_table[symndx];
+
+ if (IS_WRITTEN(our_toc_offset))
+ {
+ /* if it has been written out, it is marked with the
+ 1 bit. Fix up our offset, but do not write it out
+ again.
+ */
+ MAKE_ADDR_AGAIN(our_toc_offset);
+ }
+ else
+ {
+ /* write out the toc entry */
+ record_toc(toc_section,
+ our_toc_offset,
+ priv,
+ strdup(name));
+
+ bfd_put_32(output_bfd,
+ val,
+ toc_section->contents + our_toc_offset);
+
+ MARK_AS_WRITTEN(local_toc_table[symndx]);
+ fixit = true;
+ }
+ }
+ else
+ {
+ const char *name = h->root.root.root.string;
+ our_toc_offset = h->toc_offset;
+
+ if ((r_flags & IMAGE_REL_PPC_TOCDEFN)
+ == IMAGE_REL_PPC_TOCDEFN )
+ {
+ /* This is unbelievable cheese. Some knowledgable asm
+ hacker has decided to use r2 as a base for loading
+ a value. He/She does this by setting the tocdefn bit,
+ and not supplying a toc definition. The behaviour is
+ then to use the difference between the value of the
+ symbol and the actual location of the toc as the toc
+ index.
+
+ In fact, what is usually happening is, because the
+ Import Address Table is mapped immediately following
+ the toc, some trippy library code trying for speed on
+ dll linkage, takes advantage of that and considers
+ the IAT to be part of the toc, thus saving a load.
+ */
+
+ our_toc_offset = val -
+ (toc_section->output_section->vma +
+ toc_section->output_offset);
+
+ /* The size must still fit in a 16bit displacment */
+ if (our_toc_offset >= 65535)
+ {
+ (*_bfd_error_handler)
+ (_("%s: Relocation for %s of %x exceeds Toc size limit"),
+ bfd_get_filename (input_bfd), name, our_toc_offset);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ record_toc(toc_section, our_toc_offset, pub, strdup(name));
+ }
+ else if (IS_WRITTEN(our_toc_offset))
+ {
+ /* if it has been written out, it is marked with the
+ 1 bit. Fix up our offset, but do not write it out
+ again.
+ */
+ MAKE_ADDR_AGAIN(our_toc_offset);
+ }
+ else
+ {
+ record_toc(toc_section, our_toc_offset, pub, strdup(name));
+
+ /* write out the toc entry */
+ bfd_put_32(output_bfd,
+ val,
+ toc_section->contents + our_toc_offset);
+
+ MARK_AS_WRITTEN(h->toc_offset);
+ /* The tricky part is that this is the address that */
+ /* needs a .reloc entry for it */
+ fixit = true;
+ }
+ }
+
+ if (fixit && info->base_file)
+ {
+ /* So if this is non pcrelative, and is referenced
+ to a section or a common symbol, then it needs a reloc */
+
+ /* relocation to a symbol in a section which
+ isn't absolute - we output the address here
+ to a file */
+
+ bfd_vma addr = toc_section->output_section->vma
+ + toc_section->output_offset + our_toc_offset;
+
+ if (coff_data(output_bfd)->pe)
+ addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
+
+ fwrite (&addr, 1,4, (FILE *) info->base_file);
+ }
+
+
+ /* FIXME: this test is conservative */
+ if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN &&
+ our_toc_offset > toc_section->_raw_size)
+ {
+ (*_bfd_error_handler)
+ (_("%s: Relocation exceeds allocated TOC (%x)"),
+ bfd_get_filename (input_bfd),
+ toc_section->_raw_size);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Now we know the relocation for this toc reference */
+ relocation = our_toc_offset + TOC_LOAD_ADJUSTMENT;
+ rstat = _bfd_relocate_contents (howto,
+ input_bfd,
+ relocation,
+ loc);
+ }
+ break;
+ case IMAGE_REL_PPC_IFGLUE:
+ {
+ /* To solve this, we need to know whether or not the symbol */
+ /* appearing on the call instruction is a glue function or not. */
+ /* A glue function must announce itself via a IMGLUE reloc, and */
+ /* the reloc contains the required toc restore instruction */
+
+ bfd_vma x;
+ const char *my_name;
+ DUMP_RELOC2(howto->name, rel);
+
+ if (h != 0)
+ {
+ my_name = h->root.root.root.string;
+ if (h->symbol_is_glue == 1)
+ {
+ x = bfd_get_32(input_bfd, loc);
+ bfd_put_32(input_bfd, h->glue_insn, loc);
+ }
+ }
+ }
+ break;
+ case IMAGE_REL_PPC_SECREL:
+ /* Unimplemented: codeview debugging information */
+ /* For fast access to the header of the section
+ containing the item. */
+ break;
+ case IMAGE_REL_PPC_SECTION:
+ /* Unimplemented: codeview debugging information */
+ /* Is used to indicate that the value should be relative
+ to the beginning of the section that contains the
+ symbol */
+ break;
+ case IMAGE_REL_PPC_ABSOLUTE:
+ {
+ const char *my_name;
+ if (h == 0)
+ my_name = (syms+symndx)->_n._n_name;
+ else
+ {
+ my_name = h->root.root.root.string;
+ }
+
+ fprintf(stderr,
+ _("Warning: unsupported reloc %s <file %s, section %s>\n"),
+ howto->name,
+ bfd_get_filename(input_bfd),
+ input_section->name);
+
+ fprintf(stderr,"sym %ld (%s), r_vaddr %ld (%lx)\n",
+ rel->r_symndx, my_name, (long) rel->r_vaddr,
+ (unsigned long) rel->r_vaddr);
+ }
+ break;
+ case IMAGE_REL_PPC_IMGLUE:
+ {
+ /* There is nothing to do now. This reloc was noted in the first
+ pass over the relocs, and the glue instruction extracted */
+ const char *my_name;
+ if (h->symbol_is_glue == 1)
+ break;
+ my_name = h->root.root.root.string;
+
+ (*_bfd_error_handler)
+ (_("%s: Out of order IMGLUE reloc for %s"),
+ bfd_get_filename (input_bfd), my_name);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ case IMAGE_REL_PPC_ADDR32NB:
+ {
+ struct coff_link_hash_entry *myh = 0;
+ const char *name = 0;
+ DUMP_RELOC2(howto->name, rel);
+
+ if (strncmp(".idata$2",input_section->name,8) == 0 && first_thunk_address == 0)
+ {
+ /* set magic values */
+ int idata5offset;
+ struct coff_link_hash_entry *myh = 0;
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ "__idata5_magic__",
+ false, false, true);
+ first_thunk_address = myh->root.u.def.value +
+ sec->output_section->vma +
+ sec->output_offset -
+ pe_data(output_bfd)->pe_opthdr.ImageBase;
+
+ idata5offset = myh->root.u.def.value;
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ "__idata6_magic__",
+ false, false, true);
+
+ thunk_size = myh->root.u.def.value - idata5offset;
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ "__idata4_magic__",
+ false, false, true);
+ import_table_size = myh->root.u.def.value;
+ }
+
+ if (h == 0)
+ { /* it is a file local symbol */
+ sym = syms + symndx;
+ name = sym->_n._n_name;
+ }
+ else
+ {
+ char *target = 0;
+
+ name = h->root.root.root.string;
+ if (strcmp(".idata$2", name) == 0)
+ target = "__idata2_magic__";
+ else if (strcmp(".idata$4", name) == 0)
+ target = "__idata4_magic__";
+ else if (strcmp(".idata$5", name) == 0)
+ target = "__idata5_magic__";
+
+ if (target != 0)
+ {
+ myh = 0;
+
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ target,
+ false, false, true);
+ if (myh == 0)
+ {
+ /* Missing magic cookies. Something is very wrong. */
+ abort();
+ }
+
+ val = myh->root.u.def.value +
+ sec->output_section->vma + sec->output_offset;
+ if (first_thunk_address == 0)
+ {
+ int idata5offset;
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ "__idata5_magic__",
+ false, false, true);
+ first_thunk_address = myh->root.u.def.value +
+ sec->output_section->vma +
+ sec->output_offset -
+ pe_data(output_bfd)->pe_opthdr.ImageBase;
+
+ idata5offset = myh->root.u.def.value;
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ "__idata6_magic__",
+ false, false, true);
+
+ thunk_size = myh->root.u.def.value - idata5offset;
+ myh = coff_link_hash_lookup (coff_hash_table (info),
+ "__idata4_magic__",
+ false, false, true);
+ import_table_size = myh->root.u.def.value;
+ }
+ }
+ }
+
+ rstat = _bfd_relocate_contents (howto,
+ input_bfd,
+ val -
+ pe_data(output_bfd)->pe_opthdr.ImageBase,
+ loc);
+ }
+ break;
+
+ case IMAGE_REL_PPC_REL24:
+ DUMP_RELOC2(howto->name, rel);
+ val -= (input_section->output_section->vma
+ + input_section->output_offset);
+
+ rstat = _bfd_relocate_contents (howto,
+ input_bfd,
+ val,
+ loc);
+ break;
+ case IMAGE_REL_PPC_ADDR16:
+ case IMAGE_REL_PPC_ADDR24:
+ case IMAGE_REL_PPC_ADDR32:
+ DUMP_RELOC2(howto->name, rel);
+ rstat = _bfd_relocate_contents (howto,
+ input_bfd,
+ val,
+ loc);
+ break;
+ }
+
+ if ( info->base_file )
+ {
+ /* So if this is non pcrelative, and is referenced
+ to a section or a common symbol, then it needs a reloc */
+ if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
+ {
+ /* relocation to a symbol in a section which
+ isn't absolute - we output the address here
+ to a file */
+ bfd_vma addr = rel->r_vaddr
+ - input_section->vma
+ + input_section->output_offset
+ + input_section->output_section->vma;
+
+ if (coff_data(output_bfd)->pe)
+ {
+ addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
+ }
+ fwrite (&addr, 1,4, (FILE *) info->base_file);
+ }
+ }
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.root.string;
+ else if (sym == NULL)
+ name = "*unknown*";
+ else if (sym->_n._n_n._n_zeroes == 0
+ && sym->_n._n_n._n_offset != 0)
+ name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
+ else
+ {
+ strncpy (buf, sym->_n._n_name, SYMNMLEN);
+ buf[SYMNMLEN] = '\0';
+ name = buf;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name,
+ (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ {
+ return false;
+ }
+ }
+ }
+
+ }
+
+ return true;
+}
+
+#ifdef COFF_IMAGE_WITH_PE
+
+/* FIXME: BFD should not use global variables. This file is compiled
+ twice, and these variables are shared. This is confusing and
+ weird. */
+
+long int global_toc_size = 4;
+
+bfd* bfd_of_toc_owner = 0;
+
+long int import_table_size;
+long int first_thunk_address;
+long int thunk_size;
+
+struct list_ele *head;
+struct list_ele *tail;
+
+static char *
+h1 = N_("\n\t\t\tTOC MAPPING\n\n");
+static char *
+h2 = N_(" TOC disassembly Comments Name\n");
+static char *
+h3 = N_(" Offset spelling (if present)\n");
+
+void
+dump_toc (vfile)
+ PTR vfile;
+{
+ FILE *file = (FILE *) vfile;
+ struct list_ele *t;
+
+ fprintf(file, _(h1));
+ fprintf(file, _(h2));
+ fprintf(file, _(h3));
+
+ for(t = head; t != 0; t=t->next)
+ {
+ const char *cat = "";
+
+ if (t->cat == priv)
+ cat = _("private ");
+ else if (t->cat == pub)
+ cat = _("public ");
+ else if (t->cat == data)
+ cat = _("data-in-toc ");
+
+ if (t->offset > global_toc_size)
+ {
+ if (t->offset <= global_toc_size + thunk_size)
+ cat = _("IAT reference ");
+ else
+ {
+ fprintf(file,
+ _("**** global_toc_size %ld(%lx), thunk_size %ld(%lx)\n"),
+ global_toc_size, global_toc_size, thunk_size, thunk_size);
+ cat = _("Out of bounds!");
+ }
+ }
+
+ fprintf(file,
+ " %04lx (%d)", (unsigned long) t->offset, t->offset - 32768);
+ fprintf(file,
+ " %s %s\n",
+ cat, t->name);
+
+ }
+
+ fprintf(file, "\n");
+}
+
+boolean
+ppc_allocate_toc_section (info)
+ struct bfd_link_info *info;
+{
+ asection *s;
+ bfd_byte *foo;
+ static char test_char = '1';
+
+ if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */
+ return true;
+
+ if (bfd_of_toc_owner == 0)
+ {
+ /* No toc owner? Something is very wrong. */
+ abort();
+ }
+
+ s = bfd_get_section_by_name ( bfd_of_toc_owner , TOC_SECTION_NAME);
+ if (s == NULL)
+ {
+ /* No toc section? Something is very wrong. */
+ abort();
+ }
+
+ foo = (bfd_byte *) bfd_alloc(bfd_of_toc_owner, global_toc_size);
+ memset(foo, test_char, global_toc_size);
+
+ s->_raw_size = s->_cooked_size = global_toc_size;
+ s->contents = foo;
+
+ return true;
+}
+
+boolean
+ppc_process_before_allocation (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection *sec;
+ struct internal_reloc *i, *rel;
+
+ /* here we have a bfd that is to be included on the link. We have a hook
+ to do reloc rummaging, before section sizes are nailed down. */
+
+ _bfd_coff_get_external_symbols(abfd);
+
+ /* rummage around all the relocs and map the toc */
+ sec = abfd->sections;
+
+ if (sec == 0)
+ {
+ return true;
+ }
+
+ for (; sec != 0; sec = sec->next)
+ {
+ if (sec->reloc_count == 0)
+ continue;
+
+ /* load the relocs */
+ /* FIXME: there may be a storage leak here */
+ i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0);
+
+ if (i == 0)
+ abort();
+
+ for (rel=i;rel<i+sec->reloc_count;++rel)
+ {
+ unsigned short r_type = EXTRACT_TYPE (rel->r_type);
+ unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
+ boolean ok = true;
+
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
+
+ switch(r_type)
+ {
+ case IMAGE_REL_PPC_TOCREL16:
+ /* if TOCDEFN is on, ignore as someone else has allocated the
+ toc entry */
+ if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN )
+ ok = ppc_record_toc_entry(abfd, info, sec,
+ rel->r_symndx, default_toc);
+ if (!ok)
+ return false;
+ break;
+ case IMAGE_REL_PPC_IMGLUE:
+ ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+#endif
+
+
+static bfd_reloc_status_type
+ppc_refhi_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("REFHI");
+ DUMP_RELOC("REFHI",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_undefined;
+}
+
+#if 0
+
+static bfd_reloc_status_type
+ppc_reflo_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("REFLO");
+ DUMP_RELOC("REFLO",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_undefined;
+}
+
+#endif
+
+static bfd_reloc_status_type
+ppc_pair_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("PAIR");
+ DUMP_RELOC("PAIR",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_undefined;
+}
+
+
+static bfd_reloc_status_type
+ppc_toc16_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("TOCREL16");
+ DUMP_RELOC("TOCREL16",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ {
+ return bfd_reloc_continue;
+ }
+
+ return bfd_reloc_ok;
+}
+
+#if 0
+
+/* ADDR32NB : 32 bit address relative to the virtual origin. */
+/* (On the alpha, this is always a linker generated thunk)*/
+/* (i.e. 32bit addr relative to the image base) */
+/* */
+/* */
+
+static bfd_reloc_status_type
+ppc_addr32nb_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("ADDR32NB");
+ DUMP_RELOC("ADDR32NB",reloc_entry);
+
+ return bfd_reloc_ok;
+}
+
+#endif
+
+static bfd_reloc_status_type
+ppc_secrel_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("SECREL");
+ DUMP_RELOC("SECREL",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+ppc_section_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("SECTION");
+ DUMP_RELOC("SECTION",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+ppc_imglue_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ UN_IMPL("IMGLUE");
+ DUMP_RELOC("IMGLUE",reloc_entry);
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ return bfd_reloc_ok;
+}
+
+
+
+#define MAX_RELOC_INDEX \
+ (sizeof(ppc_coff_howto_table) / sizeof(ppc_coff_howto_table[0]) - 1)
+
+
+/* FIXME: There is a possiblity that when we read in a reloc from a file,
+ that there are some bits encoded in the upper portion of the
+ type field. Not yet implemented.
+*/
+static void ppc_coff_rtype2howto PARAMS ((arelent *relent,
+ struct internal_reloc *internal));
+
+static void
+ppc_coff_rtype2howto (relent, internal)
+ arelent *relent;
+ struct internal_reloc *internal;
+{
+
+ /* We can encode one of three things in the type field, aside from the
+ type:
+ 1. IMAGE_REL_PPC_NEG - indicates the value field is a subtraction
+ value, rather than an addition value
+ 2. IMAGE_REL_PPC_BRTAKEN, IMAGE_REL_PPC_BRNTAKEN - indicates that
+ the branch is expected to be taken or not.
+ 3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file
+ For now, we just strip this stuff to find the type, and ignore it other
+ than that.
+ */
+ reloc_howto_type *howto;
+ unsigned short r_type = EXTRACT_TYPE (internal->r_type);
+ unsigned short r_flags = EXTRACT_FLAGS(internal->r_type);
+ unsigned short junk = EXTRACT_JUNK (internal->r_type);
+
+ /* the masking process only slices off the bottom byte for r_type. */
+ if ( r_type > MAX_RELOC_INDEX )
+ abort();
+
+ /* check for absolute crap */
+ if ( junk != 0 )
+ abort();
+
+ switch(r_type)
+ {
+ case IMAGE_REL_PPC_ADDR16:
+ case IMAGE_REL_PPC_REL24:
+ case IMAGE_REL_PPC_ADDR24:
+ case IMAGE_REL_PPC_ADDR32:
+ case IMAGE_REL_PPC_IFGLUE:
+ case IMAGE_REL_PPC_ADDR32NB:
+ case IMAGE_REL_PPC_SECTION:
+ case IMAGE_REL_PPC_SECREL:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ case IMAGE_REL_PPC_IMGLUE:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ case IMAGE_REL_PPC_TOCREL16:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
+ if (r_flags & IMAGE_REL_PPC_TOCDEFN)
+ howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16_DEFN;
+ else
+ howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16;
+ break;
+ default:
+ fprintf(stderr,
+ _("Warning: Unsupported reloc %s [%d] used -- it may not work.\n"),
+ ppc_coff_howto_table[r_type].name,
+ r_type);
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ }
+
+ relent->howto = howto;
+
+}
+
+static reloc_howto_type *
+coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+ reloc_howto_type *howto;
+
+ /* We can encode one of three things in the type field, aside from the
+ type:
+ 1. IMAGE_REL_PPC_NEG - indicates the value field is a subtraction
+ value, rather than an addition value
+ 2. IMAGE_REL_PPC_BRTAKEN, IMAGE_REL_PPC_BRNTAKEN - indicates that
+ the branch is expected to be taken or not.
+ 3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file
+ For now, we just strip this stuff to find the type, and ignore it other
+ than that.
+ */
+
+ unsigned short r_type = EXTRACT_TYPE (rel->r_type);
+ unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
+ unsigned short junk = EXTRACT_JUNK (rel->r_type);
+
+ /* the masking process only slices off the bottom byte for r_type. */
+ if ( r_type > MAX_RELOC_INDEX )
+ abort();
+
+ /* check for absolute crap */
+ if ( junk != 0 )
+ abort();
+
+ switch(r_type)
+ {
+ case IMAGE_REL_PPC_ADDR32NB:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
+ *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ case IMAGE_REL_PPC_TOCREL16:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
+ if (r_flags & IMAGE_REL_PPC_TOCDEFN)
+ howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16_DEFN;
+ else
+ howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16;
+ break;
+ case IMAGE_REL_PPC_ADDR16:
+ case IMAGE_REL_PPC_REL24:
+ case IMAGE_REL_PPC_ADDR24:
+ case IMAGE_REL_PPC_ADDR32:
+ case IMAGE_REL_PPC_IFGLUE:
+ case IMAGE_REL_PPC_SECTION:
+ case IMAGE_REL_PPC_SECREL:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ case IMAGE_REL_PPC_IMGLUE:
+ DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ default:
+ fprintf(stderr,
+ _("Warning: Unsupported reloc %s [%d] used -- it may not work.\n"),
+ ppc_coff_howto_table[r_type].name,
+ r_type);
+ howto = ppc_coff_howto_table + r_type;
+ break;
+ }
+
+ return howto;
+}
+
+
+/* a cheesy little macro to make the code a little more readable */
+#define HOW2MAP(bfd_rtype,ppc_rtype) \
+ case bfd_rtype: return &ppc_coff_howto_table[ppc_rtype]
+
+static reloc_howto_type *ppc_coff_reloc_type_lookup
+PARAMS ((bfd *, bfd_reloc_code_real_type));
+
+static reloc_howto_type *
+ppc_coff_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ HOW2MAP(BFD_RELOC_32_GOTOFF, IMAGE_REL_PPC_IMGLUE);
+ HOW2MAP(BFD_RELOC_16_GOT_PCREL, IMAGE_REL_PPC_IFGLUE);
+ HOW2MAP(BFD_RELOC_16, IMAGE_REL_PPC_ADDR16);
+ HOW2MAP(BFD_RELOC_PPC_B26, IMAGE_REL_PPC_REL24);
+ HOW2MAP(BFD_RELOC_PPC_BA26, IMAGE_REL_PPC_ADDR24);
+ HOW2MAP(BFD_RELOC_PPC_TOC16, IMAGE_REL_PPC_TOCREL16);
+ HOW2MAP(BFD_RELOC_16_GOTOFF, IMAGE_REL_PPC_TOCREL16_DEFN);
+ HOW2MAP(BFD_RELOC_32, IMAGE_REL_PPC_ADDR32);
+ HOW2MAP(BFD_RELOC_RVA, IMAGE_REL_PPC_ADDR32NB);
+ default:
+ return NULL;
+ }
+ /*NOTREACHED*/
+}
+
+#undef HOW2MAP
+
+
+/* Tailor coffcode.h -- macro heaven. */
+
+#define RTYPE2HOWTO(cache_ptr, dst) ppc_coff_rtype2howto (cache_ptr, dst)
+
+#ifndef COFF_IMAGE_WITH_PE
+static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR));
+#endif
+
+/* We use the special COFF backend linker, with our own special touch. */
+
+#define coff_bfd_reloc_type_lookup ppc_coff_reloc_type_lookup
+#define coff_rtype_to_howto coff_ppc_rtype_to_howto
+#define coff_relocate_section coff_ppc_relocate_section
+#define coff_bfd_final_link ppc_bfd_coff_final_link
+
+#ifndef COFF_IMAGE_WITH_PE
+#define coff_swap_sym_in_hook ppc_coff_swap_sym_in_hook
+#endif
+
+#define SELECT_RELOC(internal, howto) {internal.r_type=howto->type;}
+
+#define COFF_PAGE_SIZE 0x1000
+
+#define POWERPC_LE_PE
+
+#include "coffcode.h"
+
+
+
+#ifndef COFF_IMAGE_WITH_PE
+/* FIXME:
+ What we're trying to do here is allocate a toc section (early), and attach
+ it to the last bfd to be processed. This avoids the problem of having a toc
+ written out before all files have been processed. This code allocates
+ a toc section for every file, and records the last one seen. There are
+ at least two problems with this approach:
+ 1. We allocate whole bunches of toc sections that are ignored, but at
+ at least we will not allocate a toc if no .toc is present.
+ 2. It's not clear to me that being the last bfd read necessarily means
+ that you are the last bfd closed.
+ 3. Doing it on a "swap in" hook depends on when the "swap in" is called,
+ and how often, etc. It's not clear to me that there isn't a hole here.
+*/
+
+static void
+ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
+ bfd *abfd;
+ PTR ext1;
+ PTR in1;
+{
+ struct internal_syment *in = (struct internal_syment *)in1;
+
+ if (bfd_of_toc_owner != 0) /* we already have a toc, so go home */
+ return;
+
+ if (strcmp(in->_n._n_name, ".toc") == 0)
+ {
+ flagword flags;
+ register asection *s;
+
+ s = bfd_get_section_by_name ( abfd , TOC_SECTION_NAME);
+ if (s != NULL)
+ {
+ return;
+ }
+
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ;
+
+ s = bfd_make_section (abfd, TOC_SECTION_NAME);
+
+ if (s == NULL
+ || !bfd_set_section_flags (abfd, s, flags)
+ || !bfd_set_section_alignment (abfd, s, 2))
+ {
+ /* FIXME: set appropriate bfd error */
+ abort();
+ }
+
+ /* save the bfd for later allocation */
+ bfd_of_toc_owner = abfd;
+ }
+
+ return;
+}
+#endif
+
+#ifndef COFF_IMAGE_WITH_PE
+
+static boolean ppc_do_last PARAMS ((bfd *));
+static bfd *ppc_get_last PARAMS ((void));
+
+static boolean
+ppc_do_last (abfd)
+ bfd *abfd;
+{
+ if (abfd == bfd_of_toc_owner)
+ return true;
+ else
+ return false;
+}
+
+static bfd *
+ppc_get_last()
+{
+ return bfd_of_toc_owner;
+}
+
+/* this piece of machinery exists only to guarantee that the bfd that holds
+ the toc section is written last.
+
+ This does depend on bfd_make_section attaching a new section to the
+ end of the section list for the bfd.
+
+ This is otherwise intended to be functionally the same as
+ cofflink.c:_bfd_coff_final_link(). It is specifically different only
+ where the POWERPC_LE_PE macro modifies the code. It is left in as a
+ precise form of comment. krk@cygnus.com
+*/
+#define POWERPC_LE_PE
+
+
+/* Do the final link step. */
+
+boolean
+ppc_bfd_coff_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd_size_type symesz;
+ struct coff_final_link_info finfo;
+ boolean debug_merge_allocated;
+ asection *o;
+ struct bfd_link_order *p;
+ size_t max_sym_count;
+ size_t max_lineno_count;
+ size_t max_reloc_count;
+ size_t max_output_reloc_count;
+ size_t max_contents_size;
+ file_ptr rel_filepos;
+ unsigned int relsz;
+ file_ptr line_filepos;
+ unsigned int linesz;
+ bfd *sub;
+ bfd_byte *external_relocs = NULL;
+ char strbuf[STRING_SIZE_SIZE];
+
+ symesz = bfd_coff_symesz (abfd);
+
+ finfo.info = info;
+ finfo.output_bfd = abfd;
+ finfo.strtab = NULL;
+ finfo.section_info = NULL;
+ finfo.last_file_index = -1;
+ finfo.last_bf_index = -1;
+ finfo.internal_syms = NULL;
+ finfo.sec_ptrs = NULL;
+ finfo.sym_indices = NULL;
+ finfo.outsyms = NULL;
+ finfo.linenos = NULL;
+ finfo.contents = NULL;
+ finfo.external_relocs = NULL;
+ finfo.internal_relocs = NULL;
+ debug_merge_allocated = false;
+
+ coff_data (abfd)->link_info = info;
+
+ finfo.strtab = _bfd_stringtab_init ();
+ if (finfo.strtab == NULL)
+ goto error_return;
+
+ if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
+ goto error_return;
+ debug_merge_allocated = true;
+
+ /* Compute the file positions for all the sections. */
+ if (! abfd->output_has_begun)
+ {
+ if (! bfd_coff_compute_section_file_positions (abfd))
+ return false;
+ }
+
+ /* Count the line numbers and relocation entries required for the
+ output file. Set the file positions for the relocs. */
+ rel_filepos = obj_relocbase (abfd);
+ relsz = bfd_coff_relsz (abfd);
+ max_contents_size = 0;
+ max_lineno_count = 0;
+ max_reloc_count = 0;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+
+ if (p->type == bfd_indirect_link_order)
+ {
+ asection *sec;
+
+ sec = p->u.indirect.section;
+
+ /* Mark all sections which are to be included in the
+ link. This will normally be every section. We need
+ to do this so that we can identify any sections which
+ the linker has decided to not include. */
+ sec->linker_mark = true;
+
+ if (info->strip == strip_none
+ || info->strip == strip_some)
+ o->lineno_count += sec->lineno_count;
+
+ if (info->relocateable)
+ o->reloc_count += sec->reloc_count;
+
+ if (sec->_raw_size > max_contents_size)
+ max_contents_size = sec->_raw_size;
+ if (sec->lineno_count > max_lineno_count)
+ max_lineno_count = sec->lineno_count;
+ if (sec->reloc_count > max_reloc_count)
+ max_reloc_count = sec->reloc_count;
+ }
+ else if (info->relocateable
+ && (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order))
+ ++o->reloc_count;
+ }
+ if (o->reloc_count == 0)
+ o->rel_filepos = 0;
+ else
+ {
+ o->flags |= SEC_RELOC;
+ o->rel_filepos = rel_filepos;
+ rel_filepos += o->reloc_count * relsz;
+ }
+ }
+
+ /* If doing a relocateable link, allocate space for the pointers we
+ need to keep. */
+ if (info->relocateable)
+ {
+ unsigned int i;
+
+ /* We use section_count + 1, rather than section_count, because
+ the target_index fields are 1 based. */
+ finfo.section_info =
+ ((struct coff_link_section_info *)
+ bfd_malloc ((abfd->section_count + 1)
+ * sizeof (struct coff_link_section_info)));
+ if (finfo.section_info == NULL)
+ goto error_return;
+ for (i = 0; i <= abfd->section_count; i++)
+ {
+ finfo.section_info[i].relocs = NULL;
+ finfo.section_info[i].rel_hashes = NULL;
+ }
+ }
+
+ /* We now know the size of the relocs, so we can determine the file
+ positions of the line numbers. */
+ line_filepos = rel_filepos;
+ linesz = bfd_coff_linesz (abfd);
+ max_output_reloc_count = 0;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if (o->lineno_count == 0)
+ o->line_filepos = 0;
+ else
+ {
+ o->line_filepos = line_filepos;
+ line_filepos += o->lineno_count * linesz;
+ }
+
+ if (o->reloc_count != 0)
+ {
+ /* We don't know the indices of global symbols until we have
+ written out all the local symbols. For each section in
+ the output file, we keep an array of pointers to hash
+ table entries. Each entry in the array corresponds to a
+ reloc. When we find a reloc against a global symbol, we
+ set the corresponding entry in this array so that we can
+ fix up the symbol index after we have written out all the
+ local symbols.
+
+ Because of this problem, we also keep the relocs in
+ memory until the end of the link. This wastes memory,
+ but only when doing a relocateable link, which is not the
+ common case. */
+ BFD_ASSERT (info->relocateable);
+ finfo.section_info[o->target_index].relocs =
+ ((struct internal_reloc *)
+ bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+ finfo.section_info[o->target_index].rel_hashes =
+ ((struct coff_link_hash_entry **)
+ bfd_malloc (o->reloc_count
+ * sizeof (struct coff_link_hash_entry *)));
+ if (finfo.section_info[o->target_index].relocs == NULL
+ || finfo.section_info[o->target_index].rel_hashes == NULL)
+ goto error_return;
+
+ if (o->reloc_count > max_output_reloc_count)
+ max_output_reloc_count = o->reloc_count;
+ }
+
+ /* Reset the reloc and lineno counts, so that we can use them to
+ count the number of entries we have output so far. */
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ }
+
+ obj_sym_filepos (abfd) = line_filepos;
+
+ /* Figure out the largest number of symbols in an input BFD. Take
+ the opportunity to clear the output_has_begun fields of all the
+ input BFD's. */
+ max_sym_count = 0;
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ size_t sz;
+
+ sub->output_has_begun = false;
+ sz = obj_raw_syment_count (sub);
+ if (sz > max_sym_count)
+ max_sym_count = sz;
+ }
+
+ /* Allocate some buffers used while linking. */
+ finfo.internal_syms = ((struct internal_syment *)
+ bfd_malloc (max_sym_count
+ * sizeof (struct internal_syment)));
+ finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
+ * sizeof (asection *));
+ finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
+ finfo.outsyms = ((bfd_byte *)
+ bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
+ finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
+ * bfd_coff_linesz (abfd));
+ finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+ finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
+ if (! info->relocateable)
+ finfo.internal_relocs = ((struct internal_reloc *)
+ bfd_malloc (max_reloc_count
+ * sizeof (struct internal_reloc)));
+ if ((finfo.internal_syms == NULL && max_sym_count > 0)
+ || (finfo.sec_ptrs == NULL && max_sym_count > 0)
+ || (finfo.sym_indices == NULL && max_sym_count > 0)
+ || finfo.outsyms == NULL
+ || (finfo.linenos == NULL && max_lineno_count > 0)
+ || (finfo.contents == NULL && max_contents_size > 0)
+ || (finfo.external_relocs == NULL && max_reloc_count > 0)
+ || (! info->relocateable
+ && finfo.internal_relocs == NULL
+ && max_reloc_count > 0))
+ goto error_return;
+
+ /* We now know the position of everything in the file, except that
+ we don't know the size of the symbol table and therefore we don't
+ know where the string table starts. We just build the string
+ table in memory as we go along. We process all the relocations
+ for a single input file at once. */
+ obj_raw_syment_count (abfd) = 0;
+
+ if (coff_backend_info (abfd)->_bfd_coff_start_final_link)
+ {
+ if (! bfd_coff_start_final_link (abfd, info))
+ goto error_return;
+ }
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order
+ && (bfd_get_flavour (p->u.indirect.section->owner)
+ == bfd_target_coff_flavour))
+ {
+ sub = p->u.indirect.section->owner;
+#ifdef POWERPC_LE_PE
+ if (! sub->output_has_begun && !ppc_do_last(sub))
+#else
+ if (! sub->output_has_begun)
+#endif
+ {
+ if (! _bfd_coff_link_input_bfd (&finfo, sub))
+ goto error_return;
+ sub->output_has_begun = true;
+ }
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ if (! _bfd_coff_reloc_link_order (abfd, &finfo, o, p))
+ goto error_return;
+ }
+ else
+ {
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ goto error_return;
+ }
+ }
+ }
+
+#ifdef POWERPC_LE_PE
+ {
+ bfd* last_one = ppc_get_last();
+ if (last_one)
+ {
+ if (! _bfd_coff_link_input_bfd (&finfo, last_one))
+ goto error_return;
+ }
+ last_one->output_has_begun = true;
+ }
+#endif
+
+ /* Free up the buffers used by _bfd_coff_link_input_bfd. */
+
+ coff_debug_merge_hash_table_free (&finfo.debug_merge);
+ debug_merge_allocated = false;
+
+ if (finfo.internal_syms != NULL)
+ {
+ free (finfo.internal_syms);
+ finfo.internal_syms = NULL;
+ }
+ if (finfo.sec_ptrs != NULL)
+ {
+ free (finfo.sec_ptrs);
+ finfo.sec_ptrs = NULL;
+ }
+ if (finfo.sym_indices != NULL)
+ {
+ free (finfo.sym_indices);
+ finfo.sym_indices = NULL;
+ }
+ if (finfo.linenos != NULL)
+ {
+ free (finfo.linenos);
+ finfo.linenos = NULL;
+ }
+ if (finfo.contents != NULL)
+ {
+ free (finfo.contents);
+ finfo.contents = NULL;
+ }
+ if (finfo.external_relocs != NULL)
+ {
+ free (finfo.external_relocs);
+ finfo.external_relocs = NULL;
+ }
+ if (finfo.internal_relocs != NULL)
+ {
+ free (finfo.internal_relocs);
+ finfo.internal_relocs = NULL;
+ }
+
+ /* The value of the last C_FILE symbol is supposed to be the symbol
+ index of the first external symbol. Write it out again if
+ necessary. */
+ if (finfo.last_file_index != -1
+ && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
+ {
+ finfo.last_file.n_value = obj_raw_syment_count (abfd);
+ bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
+ (PTR) finfo.outsyms);
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + finfo.last_file_index * symesz),
+ SEEK_SET) != 0
+ || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
+ return false;
+ }
+
+ /* Write out the global symbols. */
+ finfo.failed = false;
+ coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
+ (PTR) &finfo);
+ if (finfo.failed)
+ goto error_return;
+
+ /* The outsyms buffer is used by _bfd_coff_write_global_sym. */
+ if (finfo.outsyms != NULL)
+ {
+ free (finfo.outsyms);
+ finfo.outsyms = NULL;
+ }
+
+ if (info->relocateable)
+ {
+ /* Now that we have written out all the global symbols, we know
+ the symbol indices to use for relocs against them, and we can
+ finally write out the relocs. */
+ external_relocs = ((bfd_byte *)
+ bfd_malloc (max_output_reloc_count * relsz));
+ if (external_relocs == NULL)
+ goto error_return;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct internal_reloc *irel;
+ struct internal_reloc *irelend;
+ struct coff_link_hash_entry **rel_hash;
+ bfd_byte *erel;
+
+ if (o->reloc_count == 0)
+ continue;
+
+ irel = finfo.section_info[o->target_index].relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = finfo.section_info[o->target_index].rel_hashes;
+ erel = external_relocs;
+ for (; irel < irelend; irel++, rel_hash++, erel += relsz)
+ {
+ if (*rel_hash != NULL)
+ {
+ BFD_ASSERT ((*rel_hash)->indx >= 0);
+ irel->r_symndx = (*rel_hash)->indx;
+ }
+ bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
+ }
+
+ if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
+ || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
+ abfd) != relsz * o->reloc_count)
+ goto error_return;
+ }
+
+ free (external_relocs);
+ external_relocs = NULL;
+ }
+
+ /* Free up the section information. */
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ finfo.section_info = NULL;
+ }
+
+ /* If we have optimized stabs strings, output them. */
+ if (coff_hash_table (info)->stab_info != NULL)
+ {
+ if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
+ return false;
+ }
+
+ /* Write out the string table. */
+ if (obj_raw_syment_count (abfd) != 0)
+ {
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + obj_raw_syment_count (abfd) * symesz),
+ SEEK_SET) != 0)
+ return false;
+
+#if STRING_SIZE_SIZE == 4
+ bfd_h_put_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ (bfd_byte *) strbuf);
+#else
+ #error Change bfd_h_put_32
+#endif
+
+ if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ return false;
+
+ if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+ return false;
+ }
+
+ _bfd_stringtab_free (finfo.strtab);
+
+ /* Setting bfd_get_symcount to 0 will cause write_object_contents to
+ not try to write out the symbols. */
+ bfd_get_symcount (abfd) = 0;
+
+ return true;
+
+ error_return:
+ if (debug_merge_allocated)
+ coff_debug_merge_hash_table_free (&finfo.debug_merge);
+ if (finfo.strtab != NULL)
+ _bfd_stringtab_free (finfo.strtab);
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ }
+ if (finfo.internal_syms != NULL)
+ free (finfo.internal_syms);
+ if (finfo.sec_ptrs != NULL)
+ free (finfo.sec_ptrs);
+ if (finfo.sym_indices != NULL)
+ free (finfo.sym_indices);
+ if (finfo.outsyms != NULL)
+ free (finfo.outsyms);
+ if (finfo.linenos != NULL)
+ free (finfo.linenos);
+ if (finfo.contents != NULL)
+ free (finfo.contents);
+ if (finfo.external_relocs != NULL)
+ free (finfo.external_relocs);
+ if (finfo.internal_relocs != NULL)
+ free (finfo.internal_relocs);
+ if (external_relocs != NULL)
+ free (external_relocs);
+ return false;
+}
+#endif
+
+
+/* The transfer vectors that lead the outside world to all of the above. */
+
+#ifdef TARGET_LITTLE_SYM
+const bfd_target
+TARGET_LITTLE_SYM =
+{
+ TARGET_LITTLE_NAME, /* name or coff-arm-little */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* FIXME: object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+#ifndef COFF_WITH_PE
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+#else
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+#endif
+
+ 0, /* leading char */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen??? FIXMEmgo */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, /* _bfd_dummy_target */ coff_object_p },
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+#endif
+
+#ifdef TARGET_BIG_SYM
+const bfd_target
+TARGET_BIG_SYM =
+{
+ TARGET_BIG_NAME,
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* FIXME: object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+#ifndef COFF_WITH_PE
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+#else
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+#endif
+
+ 0, /* leading char */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen??? FIXMEmgo */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, /* _bfd_dummy_target */ coff_object_p },
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+
+#endif
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
new file mode 100644
index 00000000000..6b4cd4429c2
--- /dev/null
+++ b/bfd/coff-rs6000.c
@@ -0,0 +1,1418 @@
+/* BFD back-end for IBM RS/6000 "XCOFF" files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ FIXME: Can someone provide a transliteration of this name into ASCII?
+ Using the following chars caused a compiler warning on HIUX (so I replaced
+ them with octal escapes), and isn't useful without an understanding of what
+ character set it is.
+ Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
+ and John Gilmore.
+ Archive support from Damon A. Permezel.
+ Contributed by IBM Corporation and Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Internalcoff.h and coffcode.h modify themselves based on this flag. */
+#define RS6000COFF_C 1
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "coff/rs6000.h"
+#include "libcoff.h"
+
+/* The main body of code is in coffcode.h. */
+
+static boolean xcoff_mkobject PARAMS ((bfd *));
+static boolean xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+static boolean xcoff_is_local_label_name PARAMS ((bfd *, const char *));
+static void xcoff_rtype2howto
+ PARAMS ((arelent *, struct internal_reloc *));
+static reloc_howto_type *xcoff_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static boolean xcoff_slurp_armap PARAMS ((bfd *));
+static const bfd_target *xcoff_archive_p PARAMS ((bfd *));
+static PTR xcoff_read_ar_hdr PARAMS ((bfd *));
+static bfd *xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
+static int xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
+static const char *normalize_filename PARAMS ((bfd *));
+static boolean xcoff_write_armap
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
+static boolean xcoff_write_archive_contents PARAMS ((bfd *));
+static int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
+
+/* We use our own tdata type. Its first field is the COFF tdata type,
+ so the COFF routines are compatible. */
+
+static boolean
+xcoff_mkobject (abfd)
+ bfd *abfd;
+{
+ coff_data_type *coff;
+
+ abfd->tdata.xcoff_obj_data =
+ ((struct xcoff_tdata *)
+ bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
+ if (abfd->tdata.xcoff_obj_data == NULL)
+ return false;
+ coff = coff_data (abfd);
+ coff->symbols = (coff_symbol_type *) NULL;
+ coff->conversion_table = (unsigned int *) NULL;
+ coff->raw_syments = (struct coff_ptr_struct *) NULL;
+ coff->relocbase = 0;
+
+ xcoff_data (abfd)->modtype = ('1' << 8) | 'L';
+
+ /* We set cputype to -1 to indicate that it has not been
+ initialized. */
+ xcoff_data (abfd)->cputype = -1;
+
+ xcoff_data (abfd)->csects = NULL;
+ xcoff_data (abfd)->debug_indices = NULL;
+
+ return true;
+}
+
+/* Copy XCOFF data from one BFD to another. */
+
+static boolean
+xcoff_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ struct xcoff_tdata *ix, *ox;
+ asection *sec;
+
+ if (ibfd->xvec != obfd->xvec)
+ return true;
+ ix = xcoff_data (ibfd);
+ ox = xcoff_data (obfd);
+ ox->full_aouthdr = ix->full_aouthdr;
+ ox->toc = ix->toc;
+ if (ix->sntoc == 0)
+ ox->sntoc = 0;
+ else
+ {
+ sec = coff_section_from_bfd_index (ibfd, ix->sntoc);
+ if (sec == NULL)
+ ox->sntoc = 0;
+ else
+ ox->sntoc = sec->output_section->target_index;
+ }
+ if (ix->snentry == 0)
+ ox->snentry = 0;
+ else
+ {
+ sec = coff_section_from_bfd_index (ibfd, ix->snentry);
+ if (sec == NULL)
+ ox->snentry = 0;
+ else
+ ox->snentry = sec->output_section->target_index;
+ }
+ ox->text_align_power = ix->text_align_power;
+ ox->data_align_power = ix->data_align_power;
+ ox->modtype = ix->modtype;
+ ox->cputype = ix->cputype;
+ ox->maxdata = ix->maxdata;
+ ox->maxstack = ix->maxstack;
+ return true;
+}
+
+/* I don't think XCOFF really has a notion of local labels based on
+ name. This will mean that ld -X doesn't actually strip anything.
+ The AIX native linker does not have a -X option, and it ignores the
+ -x option. */
+
+static boolean
+xcoff_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return false;
+}
+
+/* The XCOFF reloc table. Actually, XCOFF relocations specify the
+ bitsize and whether they are signed or not, along with a
+ conventional type. This table is for the types, which are used for
+ different algorithms for putting in the reloc. Many of these
+ relocs need special_function entries, which I have not written. */
+
+static reloc_howto_type xcoff_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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_bitfield, /* complain_on_overflow */
+ 0, /* special_function */
+ "R_TOC", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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_CREL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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_RBR", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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_RBRC", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+static void
+xcoff_rtype2howto (relent, internal)
+ arelent *relent;
+ struct internal_reloc *internal;
+{
+ relent->howto = xcoff_howto_table + internal->r_type;
+
+ /* The r_size field of an XCOFF reloc encodes the bitsize of the
+ relocation, as well as indicating whether it is signed or not.
+ Doublecheck that the relocation information gathered from the
+ type matches this information. */
+ if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1)
+ abort ();
+#if 0
+ if ((internal->r_size & 0x80) != 0
+ ? (relent->howto->complain_on_overflow != complain_overflow_signed)
+ : (relent->howto->complain_on_overflow != complain_overflow_bitfield))
+ abort ();
+#endif
+}
+
+static reloc_howto_type *
+xcoff_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_PPC_B26:
+ return &xcoff_howto_table[0xa];
+ case BFD_RELOC_PPC_BA26:
+ return &xcoff_howto_table[8];
+ case BFD_RELOC_PPC_TOC16:
+ return &xcoff_howto_table[3];
+ case BFD_RELOC_32:
+ case BFD_RELOC_CTOR:
+ return &xcoff_howto_table[0];
+ default:
+ return NULL;
+ }
+}
+
+#define SELECT_RELOC(internal, howto) \
+ { \
+ internal.r_type = howto->type; \
+ internal.r_size = \
+ ((howto->complain_on_overflow == complain_overflow_signed \
+ ? 0x80 \
+ : 0) \
+ | (howto->bitsize - 1)); \
+ }
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+#define COFF_LONG_FILENAMES
+
+#define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst)
+
+#define coff_mkobject xcoff_mkobject
+#define coff_bfd_copy_private_bfd_data xcoff_copy_private_bfd_data
+#define coff_bfd_is_local_label_name xcoff_is_local_label_name
+#define coff_bfd_reloc_type_lookup xcoff_reloc_type_lookup
+#define coff_relocate_section _bfd_ppc_xcoff_relocate_section
+
+#include "coffcode.h"
+
+/* XCOFF archive support. The original version of this code was by
+ Damon A. Permezel. It was enhanced to permit cross support, and
+ writing archive files, by Ian Lance Taylor, Cygnus Support.
+
+ XCOFF uses its own archive format. Everything is hooked together
+ with file offset links, so it is possible to rapidly update an
+ archive in place. Of course, we don't do that. An XCOFF archive
+ has a real file header, not just an ARMAG string. The structure of
+ the file header and of each archive header appear below.
+
+ An XCOFF archive also has a member table, which is a list of
+ elements in the archive (you can get that by looking through the
+ linked list, but you have to read a lot more of the file). The
+ member table has a normal archive header with an empty name. It is
+ normally (and perhaps must be) the second to last entry in the
+ archive. The member table data is almost printable ASCII. It
+ starts with a 12 character decimal string which is the number of
+ entries in the table. For each entry it has a 12 character decimal
+ string which is the offset in the archive of that member. These
+ entries are followed by a series of null terminated strings which
+ are the member names for each entry.
+
+ Finally, an XCOFF archive has a global symbol table, which is what
+ we call the armap. The global symbol table has a normal archive
+ header with an empty name. It is normally (and perhaps must be)
+ the last entry in the archive. The contents start with a four byte
+ binary number which is the number of entries. This is followed by
+ a that many four byte binary numbers; each is the file offset of an
+ entry in the archive. These numbers are followed by a series of
+ null terminated strings, which are symbol names. */
+
+/* XCOFF archives use this as a magic string. */
+
+#define XCOFFARMAG "<aiaff>\012"
+#define SXCOFFARMAG 8
+
+/* This terminates an XCOFF archive member name. */
+
+#define XCOFFARFMAG "`\012"
+#define SXCOFFARFMAG 2
+
+/* XCOFF archives start with this (printable) structure. */
+
+struct xcoff_ar_file_hdr
+{
+ /* Magic string. */
+ char magic[SXCOFFARMAG];
+
+ /* Offset of the member table (decimal ASCII string). */
+ char memoff[12];
+
+ /* Offset of the global symbol table (decimal ASCII string). */
+ char symoff[12];
+
+ /* Offset of the first member in the archive (decimal ASCII string). */
+ char firstmemoff[12];
+
+ /* Offset of the last member in the archive (decimal ASCII string). */
+ char lastmemoff[12];
+
+ /* Offset of the first member on the free list (decimal ASCII
+ string). */
+ char freeoff[12];
+};
+
+#define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG)
+
+/* Each XCOFF archive member starts with this (printable) structure. */
+
+struct xcoff_ar_hdr
+{
+ /* File size not including the header (decimal ASCII string). */
+ char size[12];
+
+ /* File offset of next archive member (decimal ASCII string). */
+ char nextoff[12];
+
+ /* File offset of previous archive member (decimal ASCII string). */
+ char prevoff[12];
+
+ /* File mtime (decimal ASCII string). */
+ char date[12];
+
+ /* File UID (decimal ASCII string). */
+ char uid[12];
+
+ /* File GID (decimal ASCII string). */
+ char gid[12];
+
+ /* File mode (octal ASCII string). */
+ char mode[12];
+
+ /* Length of file name (decimal ASCII string). */
+ char namlen[4];
+
+ /* This structure is followed by the file name. The length of the
+ name is given in the namlen field. If the length of the name is
+ odd, the name is followed by a null byte. The name and optional
+ null byte are followed by XCOFFARFMAG, which is not included in
+ namlen. The contents of the archive member follow; the number of
+ bytes is given in the size field. */
+};
+
+#define SIZEOF_AR_HDR (7 * 12 + 4)
+
+/* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
+ artdata structure. */
+#define xcoff_ardata(abfd) \
+ ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
+
+/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
+ archive element. */
+#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
+#define arch_xhdr(bfd) \
+ ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
+
+/* XCOFF archives do not have anything which corresponds to an
+ extended name table. */
+
+#define xcoff_slurp_extended_name_table bfd_false
+#define xcoff_construct_extended_name_table \
+ ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
+ bfd_false)
+#define xcoff_truncate_arname bfd_dont_truncate_arname
+
+/* We can use the standard get_elt_at_index routine. */
+
+#define xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
+
+/* XCOFF archives do not have a timestamp. */
+
+#define xcoff_update_armap_timestamp bfd_true
+
+/* Read in the armap of an XCOFF archive. */
+
+static boolean
+xcoff_slurp_armap (abfd)
+ bfd *abfd;
+{
+ file_ptr off;
+ struct xcoff_ar_hdr hdr;
+ size_t namlen;
+ bfd_size_type sz;
+ bfd_byte *contents, *cend;
+ unsigned int c, i;
+ carsym *arsym;
+ bfd_byte *p;
+
+ if (xcoff_ardata (abfd) == NULL)
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
+
+ off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);
+ if (off == 0)
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
+
+ if (bfd_seek (abfd, off, SEEK_SET) != 0)
+ return false;
+
+ /* The symbol table starts with a normal archive header. */
+ if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
+ return false;
+
+ /* Skip the name (normally empty). */
+ namlen = strtol (hdr.namlen, (char **) NULL, 10);
+ if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
+ return false;
+
+ /* Read in the entire symbol table. */
+ sz = strtol (hdr.size, (char **) NULL, 10);
+ contents = (bfd_byte *) bfd_alloc (abfd, sz);
+ if (contents == NULL)
+ return false;
+ if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
+ return false;
+
+ /* The symbol table starts with a four byte count. */
+ c = bfd_h_get_32 (abfd, contents);
+
+ if (c * 4 >= sz)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ bfd_ardata (abfd)->symdefs = ((carsym *)
+ bfd_alloc (abfd, c * sizeof (carsym)));
+ if (bfd_ardata (abfd)->symdefs == NULL)
+ return false;
+
+ /* After the count comes a list of four byte file offsets. */
+ for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
+ i < c;
+ ++i, ++arsym, p += 4)
+ arsym->file_offset = bfd_h_get_32 (abfd, p);
+
+ /* After the file offsets come null terminated symbol names. */
+ cend = contents + sz;
+ for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
+ i < c;
+ ++i, ++arsym, p += strlen ((char *) p) + 1)
+ {
+ if (p >= cend)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ arsym->name = (char *) p;
+ }
+
+ bfd_ardata (abfd)->symdef_count = c;
+ bfd_has_map (abfd) = true;
+
+ return true;
+}
+
+/* See if this is an XCOFF archive. */
+
+static const bfd_target *
+xcoff_archive_p (abfd)
+ bfd *abfd;
+{
+ struct xcoff_ar_file_hdr hdr;
+
+ if (bfd_read ((PTR) &hdr, SIZEOF_AR_FILE_HDR, 1, abfd)
+ != SIZEOF_AR_FILE_HDR)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (strncmp (hdr.magic, XCOFFARMAG, SXCOFFARMAG) != 0)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
+ involves a cast, we can't do it as the left operand of
+ assignment. */
+ abfd->tdata.aout_ar_data =
+ (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
+
+ if (bfd_ardata (abfd) == (struct artdata *) NULL)
+ return NULL;
+
+ bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
+ (char **) NULL, 10);
+ bfd_ardata (abfd)->cache = NULL;
+ bfd_ardata (abfd)->archive_head = NULL;
+ bfd_ardata (abfd)->symdefs = NULL;
+ bfd_ardata (abfd)->extended_names = NULL;
+
+ bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
+ if (bfd_ardata (abfd)->tdata == NULL)
+ return NULL;
+
+ memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
+
+ if (! xcoff_slurp_armap (abfd))
+ {
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = (struct artdata *) NULL;
+ return NULL;
+ }
+
+ return abfd->xvec;
+}
+
+/* Read the archive header in an XCOFF archive. */
+
+static PTR
+xcoff_read_ar_hdr (abfd)
+ bfd *abfd;
+{
+ struct xcoff_ar_hdr hdr;
+ size_t namlen;
+ struct xcoff_ar_hdr *hdrp;
+ struct areltdata *ret;
+
+ if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
+ return NULL;
+
+ namlen = strtol (hdr.namlen, (char **) NULL, 10);
+ hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
+ if (hdrp == NULL)
+ return NULL;
+ memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
+ if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
+ return NULL;
+ ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
+
+ ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
+ if (ret == NULL)
+ return NULL;
+ ret->arch_header = (char *) hdrp;
+ ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
+ ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
+
+ /* Skip over the XCOFFARFMAG at the end of the file name. */
+ if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
+ return NULL;
+
+ return (PTR) ret;
+}
+
+/* Open the next element in an XCOFF archive. */
+
+static bfd *
+xcoff_openr_next_archived_file (archive, last_file)
+ bfd *archive;
+ bfd *last_file;
+{
+ file_ptr filestart;
+
+ if (xcoff_ardata (archive) == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+ }
+
+ if (last_file == NULL)
+ filestart = bfd_ardata (archive)->first_file_filepos;
+ else
+ filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL, 10);
+
+ if (filestart == 0
+ || filestart == strtol (xcoff_ardata (archive)->memoff,
+ (char **) NULL, 10)
+ || filestart == strtol (xcoff_ardata (archive)->symoff,
+ (char **) NULL, 10))
+ {
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return NULL;
+ }
+
+ return _bfd_get_elt_at_filepos (archive, filestart);
+}
+
+/* Stat an element in an XCOFF archive. */
+
+static int
+xcoff_generic_stat_arch_elt (abfd, s)
+ bfd *abfd;
+ struct stat *s;
+{
+ struct xcoff_ar_hdr *hdrp;
+
+ if (abfd->arelt_data == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ hdrp = arch_xhdr (abfd);
+
+ s->st_mtime = strtol (hdrp->date, (char **) NULL, 10);
+ s->st_uid = strtol (hdrp->uid, (char **) NULL, 10);
+ s->st_gid = strtol (hdrp->gid, (char **) NULL, 10);
+ s->st_mode = strtol (hdrp->mode, (char **) NULL, 8);
+ s->st_size = arch_eltdata (abfd)->parsed_size;
+
+ return 0;
+}
+
+/* Normalize a file name for inclusion in an archive. */
+
+static const char *
+normalize_filename (abfd)
+ bfd *abfd;
+{
+ const char *file;
+ const char *filename;
+
+ file = bfd_get_filename (abfd);
+ filename = strrchr (file, '/');
+ if (filename != NULL)
+ filename++;
+ else
+ filename = file;
+ return filename;
+}
+
+/* Write out an XCOFF armap. */
+
+/*ARGSUSED*/
+static boolean
+xcoff_write_armap (abfd, elength, map, orl_count, stridx)
+ bfd *abfd;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int orl_count;
+ int stridx;
+{
+ struct xcoff_ar_hdr hdr;
+ char *p;
+ unsigned char buf[4];
+ bfd *sub;
+ file_ptr fileoff;
+ unsigned int i;
+
+ memset (&hdr, 0, sizeof hdr);
+ sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
+ sprintf (hdr.nextoff, "%d", 0);
+ memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12);
+ sprintf (hdr.date, "%d", 0);
+ sprintf (hdr.uid, "%d", 0);
+ sprintf (hdr.gid, "%d", 0);
+ sprintf (hdr.mode, "%d", 0);
+ sprintf (hdr.namlen, "%d", 0);
+
+ /* We need spaces, not null bytes, in the header. */
+ for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++)
+ if (*p == '\0')
+ *p = ' ';
+
+ if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
+ || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
+ return false;
+
+ bfd_h_put_32 (abfd, orl_count, buf);
+ if (bfd_write (buf, 1, 4, abfd) != 4)
+ return false;
+
+ sub = abfd->archive_head;
+ fileoff = SIZEOF_AR_FILE_HDR;
+ i = 0;
+ while (sub != NULL && i < orl_count)
+ {
+ size_t namlen;
+
+ while (((bfd *) (map[i]).pos) == sub)
+ {
+ bfd_h_put_32 (abfd, fileoff, buf);
+ if (bfd_write (buf, 1, 4, abfd) != 4)
+ return false;
+ ++i;
+ }
+ namlen = strlen (normalize_filename (sub));
+ namlen = (namlen + 1) &~ 1;
+ fileoff += (SIZEOF_AR_HDR
+ + namlen
+ + SXCOFFARFMAG
+ + arelt_size (sub));
+ fileoff = (fileoff + 1) &~ 1;
+ sub = sub->next;
+ }
+
+ for (i = 0; i < orl_count; i++)
+ {
+ const char *name;
+ size_t namlen;
+
+ name = *map[i].name;
+ namlen = strlen (name);
+ if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
+ return false;
+ }
+
+ if ((stridx & 1) != 0)
+ {
+ char b;
+
+ b = '\0';
+ if (bfd_write (&b, 1, 1, abfd) != 1)
+ return false;
+ }
+
+ return true;
+}
+
+/* Write out an XCOFF archive. We always write an entire archive,
+ rather than fussing with the freelist and so forth. */
+
+static boolean
+xcoff_write_archive_contents (abfd)
+ bfd *abfd;
+{
+ struct xcoff_ar_file_hdr fhdr;
+ size_t count;
+ size_t total_namlen;
+ file_ptr *offsets;
+ boolean makemap;
+ boolean hasobjects;
+ file_ptr prevoff, nextoff;
+ bfd *sub;
+ unsigned int i;
+ struct xcoff_ar_hdr ahdr;
+ bfd_size_type size;
+ char *p;
+ char decbuf[13];
+
+ memset (&fhdr, 0, sizeof fhdr);
+ strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);
+ sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR);
+ sprintf (fhdr.freeoff, "%d", 0);
+
+ count = 0;
+ total_namlen = 0;
+ for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
+ {
+ ++count;
+ total_namlen += strlen (normalize_filename (sub)) + 1;
+ }
+ offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
+ if (offsets == NULL)
+ return false;
+
+ if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
+ return false;
+
+ makemap = bfd_has_map (abfd);
+ hasobjects = false;
+ prevoff = 0;
+ nextoff = SIZEOF_AR_FILE_HDR;
+ for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
+ {
+ const char *name;
+ size_t namlen;
+ struct xcoff_ar_hdr *ahdrp;
+ bfd_size_type remaining;
+
+ if (makemap && ! hasobjects)
+ {
+ if (bfd_check_format (sub, bfd_object))
+ hasobjects = true;
+ }
+
+ name = normalize_filename (sub);
+ namlen = strlen (name);
+
+ if (sub->arelt_data != NULL)
+ ahdrp = arch_xhdr (sub);
+ else
+ ahdrp = NULL;
+
+ if (ahdrp == NULL)
+ {
+ struct stat s;
+
+ memset (&ahdr, 0, sizeof ahdr);
+ ahdrp = &ahdr;
+ if (stat (bfd_get_filename (sub), &s) != 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return false;
+ }
+
+ sprintf (ahdrp->size, "%ld", (long) s.st_size);
+ sprintf (ahdrp->date, "%ld", (long) s.st_mtime);
+ sprintf (ahdrp->uid, "%ld", (long) s.st_uid);
+ sprintf (ahdrp->gid, "%ld", (long) s.st_gid);
+ sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode);
+
+ if (sub->arelt_data == NULL)
+ {
+ sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata));
+ if (sub->arelt_data == NULL)
+ return false;
+ }
+
+ arch_eltdata (sub)->parsed_size = s.st_size;
+ }
+
+ sprintf (ahdrp->prevoff, "%ld", (long) prevoff);
+ sprintf (ahdrp->namlen, "%ld", (long) namlen);
+
+ /* If the length of the name is odd, we write out the null byte
+ after the name as well. */
+ namlen = (namlen + 1) &~ 1;
+
+ remaining = arelt_size (sub);
+ size = (SIZEOF_AR_HDR
+ + namlen
+ + SXCOFFARFMAG
+ + remaining);
+
+ BFD_ASSERT (nextoff == bfd_tell (abfd));
+
+ offsets[i] = nextoff;
+
+ prevoff = nextoff;
+ nextoff += size + (size & 1);
+
+ sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
+
+ /* We need spaces, not null bytes, in the header. */
+ for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++)
+ if (*p == '\0')
+ *p = ' ';
+
+ if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
+ || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
+ || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
+ != SXCOFFARFMAG))
+ return false;
+
+ if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+ while (remaining != 0)
+ {
+ bfd_size_type amt;
+ bfd_byte buffer[DEFAULT_BUFFERSIZE];
+
+ amt = sizeof buffer;
+ if (amt > remaining)
+ amt = remaining;
+ if (bfd_read (buffer, 1, amt, sub) != amt
+ || bfd_write (buffer, 1, amt, abfd) != amt)
+ return false;
+ remaining -= amt;
+ }
+
+ if ((size & 1) != 0)
+ {
+ bfd_byte b;
+
+ b = '\0';
+ if (bfd_write (&b, 1, 1, abfd) != 1)
+ return false;
+ }
+ }
+
+ sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
+
+ /* Write out the member table. */
+
+ BFD_ASSERT (nextoff == bfd_tell (abfd));
+ sprintf (fhdr.memoff, "%ld", (long) nextoff);
+
+ memset (&ahdr, 0, sizeof ahdr);
+ sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen));
+ sprintf (ahdr.prevoff, "%ld", (long) prevoff);
+ sprintf (ahdr.date, "%d", 0);
+ sprintf (ahdr.uid, "%d", 0);
+ sprintf (ahdr.gid, "%d", 0);
+ sprintf (ahdr.mode, "%d", 0);
+ sprintf (ahdr.namlen, "%d", 0);
+
+ size = (SIZEOF_AR_HDR
+ + 12
+ + count * 12
+ + total_namlen
+ + SXCOFFARFMAG);
+
+ prevoff = nextoff;
+ nextoff += size + (size & 1);
+
+ if (makemap && hasobjects)
+ sprintf (ahdr.nextoff, "%ld", (long) nextoff);
+ else
+ sprintf (ahdr.nextoff, "%d", 0);
+
+ /* We need spaces, not null bytes, in the header. */
+ for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++)
+ if (*p == '\0')
+ *p = ' ';
+
+ if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
+ || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
+ != SXCOFFARFMAG))
+ return false;
+
+ sprintf (decbuf, "%-12ld", (long) count);
+ if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
+ return false;
+ for (i = 0; i < count; i++)
+ {
+ sprintf (decbuf, "%-12ld", (long) offsets[i]);
+ if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
+ return false;
+ }
+ for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
+ {
+ const char *name;
+ size_t namlen;
+
+ name = normalize_filename (sub);
+ namlen = strlen (name);
+ if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
+ return false;
+ }
+ if ((size & 1) != 0)
+ {
+ bfd_byte b;
+
+ b = '\0';
+ if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
+ return false;
+ }
+
+ /* Write out the armap, if appropriate. */
+
+ if (! makemap || ! hasobjects)
+ sprintf (fhdr.symoff, "%d", 0);
+ else
+ {
+ BFD_ASSERT (nextoff == bfd_tell (abfd));
+ sprintf (fhdr.symoff, "%ld", (long) nextoff);
+ bfd_ardata (abfd)->tdata = (PTR) &fhdr;
+ if (! _bfd_compute_and_write_armap (abfd, 0))
+ return false;
+ }
+
+ /* Write out the archive file header. */
+
+ /* We need spaces, not null bytes, in the header. */
+ for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++)
+ if (*p == '\0')
+ *p = ' ';
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
+ SIZEOF_AR_FILE_HDR))
+ return false;
+
+ return true;
+}
+
+/* We can't use the usual coff_sizeof_headers routine, because AIX
+ always uses an a.out header. */
+
+/*ARGSUSED*/
+static int
+_bfd_xcoff_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+ int size;
+
+ size = FILHSZ;
+ if (xcoff_data (abfd)->full_aouthdr)
+ size += AOUTSZ;
+ else
+ size += SMALL_AOUTSZ;
+ size += abfd->section_count * SCNHSZ;
+ return size;
+}
+
+#define CORE_FILE_P _bfd_dummy_target
+
+#define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
+#define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
+#define coff_core_file_matches_executable_p \
+ _bfd_nocore_core_file_matches_executable_p
+
+#ifdef AIX_CORE
+#undef CORE_FILE_P
+#define CORE_FILE_P rs6000coff_core_p
+extern const bfd_target * rs6000coff_core_p ();
+extern boolean rs6000coff_get_section_contents ();
+extern boolean rs6000coff_core_file_matches_executable_p ();
+
+#undef coff_core_file_matches_executable_p
+#define coff_core_file_matches_executable_p \
+ rs6000coff_core_file_matches_executable_p
+
+extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
+#undef coff_core_file_failing_command
+#define coff_core_file_failing_command rs6000coff_core_file_failing_command
+
+extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
+#undef coff_core_file_failing_signal
+#define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
+
+#undef coff_get_section_contents
+#define coff_get_section_contents rs6000coff_get_section_contents
+#endif /* AIX_CORE */
+
+#ifdef LYNX_CORE
+
+#undef CORE_FILE_P
+#define CORE_FILE_P lynx_core_file_p
+extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
+
+extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
+ bfd *exec_bfd));
+#undef coff_core_file_matches_executable_p
+#define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
+
+extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
+#undef coff_core_file_failing_command
+#define coff_core_file_failing_command lynx_core_file_failing_command
+
+extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
+#undef coff_core_file_failing_signal
+#define coff_core_file_failing_signal lynx_core_file_failing_signal
+
+#endif /* LYNX_CORE */
+
+#define _bfd_xcoff_bfd_get_relocated_section_contents \
+ coff_bfd_get_relocated_section_contents
+#define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
+#define _bfd_xcoff_bfd_gc_sections coff_bfd_gc_sections
+#define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
+
+/* The transfer vector that leads the outside world to all of the above. */
+
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ rs6000coff_vec =
+#endif
+{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
+ "aixcoff-rs6000", /* name */
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG | DYNAMIC |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading char */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen??? FIXMEmgo */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ xcoff_archive_p, CORE_FILE_P},
+ {bfd_false, coff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ xcoff_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (coff),
+ BFD_JUMP_TABLE_ARCHIVE (xcoff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (_bfd_xcoff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
new file mode 100644
index 00000000000..e3d6eec00d9
--- /dev/null
+++ b/bfd/coff-sh.c
@@ -0,0 +1,2959 @@
+/* BFD back-end for Hitachi Super-H COFF binaries.
+ Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+ Written by Steve Chamberlain, <sac@cygnus.com>.
+ Relaxing code written by Ian Lance Taylor, <ian@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "coff/sh.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+/* Internal functions. */
+static bfd_reloc_status_type sh_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static long get_symbol_value PARAMS ((asymbol *));
+static boolean sh_merge_private_data PARAMS ((bfd *, bfd *));
+static boolean sh_relax_section
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
+static boolean sh_relax_delete_bytes
+ PARAMS ((bfd *, asection *, bfd_vma, int));
+static const struct sh_opcode *sh_insn_info PARAMS ((unsigned int));
+static boolean sh_align_loads
+ PARAMS ((bfd *, asection *, struct internal_reloc *, bfd_byte *, boolean *));
+static boolean sh_swap_insns
+ PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma));
+static boolean sh_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+static bfd_byte *sh_coff_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean, asymbol **));
+
+/* Default section alignment to 2**4. */
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (4)
+
+/* Generate long file names. */
+#define COFF_LONG_FILENAMES
+
+/* The supported relocations. There are a lot of relocations defined
+ in coff/internal.h which we do not expect to ever see. */
+static reloc_howto_type sh_coff_howtos[] =
+{
+ { 0 },
+ { 1 },
+ { 2 },
+ { 3 }, /* R_SH_PCREL8 */
+ { 4 }, /* R_SH_PCREL16 */
+ { 5 }, /* R_SH_HIGH8 */
+ { 6 }, /* R_SH_IMM24 */
+ { 7 }, /* R_SH_LOW16 */
+ { 8 },
+ { 9 }, /* R_SH_PCDISP8BY4 */
+
+ HOWTO (R_SH_PCDISP8BY2, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_pcdisp8by2", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ { 11 }, /* R_SH_PCDISP8 */
+
+ HOWTO (R_SH_PCDISP, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_pcdisp12by2", /* name */
+ true, /* partial_inplace */
+ 0xfff, /* src_mask */
+ 0xfff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ { 13 },
+
+ HOWTO (R_SH_IMM32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_imm32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ { 15 },
+ { 16 }, /* R_SH_IMM8 */
+ { 17 }, /* R_SH_IMM8BY2 */
+ { 18 }, /* R_SH_IMM8BY4 */
+ { 19 }, /* R_SH_IMM4 */
+ { 20 }, /* R_SH_IMM4BY2 */
+ { 21 }, /* R_SH_IMM4BY4 */
+
+ HOWTO (R_SH_PCRELIMM8BY2, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_pcrelimm8by2", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_SH_PCRELIMM8BY4, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_pcrelimm8by4", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_SH_IMM16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_imm16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_SWITCH16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_switch16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_SWITCH32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_switch32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_USES, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_uses", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_COUNT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_count", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_ALIGN, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_align", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_CODE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_code", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_DATA, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_data", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_LABEL, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_label", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_SH_SWITCH8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_reloc, /* special_function */
+ "r_switch8", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+#define SH_COFF_HOWTO_COUNT (sizeof sh_coff_howtos / sizeof sh_coff_howtos[0])
+
+/* Check for a bad magic number. */
+#define BADMAG(x) SHBADMAG(x)
+
+/* Customize coffcode.h (this is not currently used). */
+#define SH 1
+
+/* FIXME: This should not be set here. */
+#define __A_MAGIC_SET__
+
+/* Swap the r_offset field in and out. */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+
+/* Swap out extra information in the reloc structure. */
+#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
+ do \
+ { \
+ dst->r_stuff[0] = 'S'; \
+ dst->r_stuff[1] = 'C'; \
+ } \
+ while (0)
+
+/* Get the value of a symbol, when performing a relocation. */
+
+static long
+get_symbol_value (symbol)
+ asymbol *symbol;
+{
+ bfd_vma relocation;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = (symbol->value +
+ symbol->section->output_section->vma +
+ symbol->section->output_offset);
+
+ return relocation;
+}
+
+/* This macro is used in coffcode.h to get the howto corresponding to
+ an internal reloc. */
+
+#define RTYPE2HOWTO(relent, internal) \
+ ((relent)->howto = \
+ ((internal)->r_type < SH_COFF_HOWTO_COUNT \
+ ? &sh_coff_howtos[(internal)->r_type] \
+ : (reloc_howto_type *) NULL))
+
+/* This is the same as the macro in coffcode.h, except that it copies
+ r_offset into reloc_entry->addend for some relocs. */
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = 0; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ if ((reloc).r_type == R_SH_SWITCH8 \
+ || (reloc).r_type == R_SH_SWITCH16 \
+ || (reloc).r_type == R_SH_SWITCH32 \
+ || (reloc).r_type == R_SH_USES \
+ || (reloc).r_type == R_SH_COUNT \
+ || (reloc).r_type == R_SH_ALIGN) \
+ cache_ptr->addend = (reloc).r_offset; \
+ }
+
+/* This is the howto function for the SH relocations. */
+
+static bfd_reloc_status_type
+sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ unsigned long insn;
+ bfd_vma sym_value;
+ unsigned short r_type;
+ bfd_vma addr = reloc_entry->address;
+ bfd_byte *hit_data = addr + (bfd_byte *) data;
+
+ r_type = reloc_entry->howto->type;
+
+ if (output_bfd != NULL)
+ {
+ /* Partial linking--do nothing. */
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* Almost all relocs have to do with relaxing. If any work must be
+ done for them, it has been done in sh_relax_section. */
+ if (r_type != R_SH_IMM32
+ && (r_type != R_SH_PCDISP
+ || (symbol_in->flags & BSF_LOCAL) != 0))
+ return bfd_reloc_ok;
+
+ if (symbol_in != NULL
+ && bfd_is_und_section (symbol_in->section))
+ return bfd_reloc_undefined;
+
+ sym_value = get_symbol_value (symbol_in);
+
+ switch (r_type)
+ {
+ case R_SH_IMM32:
+ insn = bfd_get_32 (abfd, hit_data);
+ insn += sym_value + reloc_entry->addend;
+ bfd_put_32 (abfd, insn, hit_data);
+ break;
+ case R_SH_PCDISP:
+ insn = bfd_get_16 (abfd, hit_data);
+ sym_value += reloc_entry->addend;
+ sym_value -= (input_section->output_section->vma
+ + input_section->output_offset
+ + addr
+ + 4);
+ sym_value += (insn & 0xfff) << 1;
+ if (insn & 0x800)
+ sym_value -= 0x1000;
+ insn = (insn & 0xf000) | (sym_value & 0xfff);
+ bfd_put_16 (abfd, insn, hit_data);
+ if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000)
+ return bfd_reloc_overflow;
+ break;
+ default:
+ abort ();
+ break;
+ }
+
+ return bfd_reloc_ok;
+}
+
+/* This routine checks for linking big and little endian objects
+ together. */
+
+static boolean
+sh_merge_private_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+ && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
+ {
+ (*_bfd_error_handler)
+ ("%s: compiled for a %s endian system and target is %s endian",
+ bfd_get_filename (ibfd),
+ bfd_big_endian (ibfd) ? "big" : "little",
+ bfd_big_endian (obfd) ? "big" : "little");
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ return true;
+}
+
+#define coff_bfd_merge_private_bfd_data sh_merge_private_data
+
+/* We can do relaxing. */
+#define coff_bfd_relax_section sh_relax_section
+
+/* We use the special COFF backend linker. */
+#define coff_relocate_section sh_relocate_section
+
+/* When relaxing, we need to use special code to get the relocated
+ section contents. */
+#define coff_bfd_get_relocated_section_contents \
+ sh_coff_get_relocated_section_contents
+
+#include "coffcode.h"
+
+/* This function handles relaxing on the SH.
+
+ Function calls on the SH look like this:
+
+ movl L1,r0
+ ...
+ jsr @r0
+ ...
+ L1:
+ .long function
+
+ The compiler and assembler will cooperate to create R_SH_USES
+ relocs on the jsr instructions. The r_offset field of the
+ R_SH_USES reloc is the PC relative offset to the instruction which
+ loads the register (the r_offset field is computed as though it
+ were a jump instruction, so the offset value is actually from four
+ bytes past the instruction). The linker can use this reloc to
+ determine just which function is being called, and thus decide
+ whether it is possible to replace the jsr with a bsr.
+
+ If multiple function calls are all based on a single register load
+ (i.e., the same function is called multiple times), the compiler
+ guarantees that each function call will have an R_SH_USES reloc.
+ Therefore, if the linker is able to convert each R_SH_USES reloc
+ which refers to that address, it can safely eliminate the register
+ load.
+
+ When the assembler creates an R_SH_USES reloc, it examines it to
+ determine which address is being loaded (L1 in the above example).
+ It then counts the number of references to that address, and
+ creates an R_SH_COUNT reloc at that address. The r_offset field of
+ the R_SH_COUNT reloc will be the number of references. If the
+ linker is able to eliminate a register load, it can use the
+ R_SH_COUNT reloc to see whether it can also eliminate the function
+ address.
+
+ SH relaxing also handles another, unrelated, matter. On the SH, if
+ a load or store instruction is not aligned on a four byte boundary,
+ the memory cycle interferes with the 32 bit instruction fetch,
+ causing a one cycle bubble in the pipeline. Therefore, we try to
+ align load and store instructions on four byte boundaries if we
+ can, by swapping them with one of the adjacent instructions. */
+
+static boolean
+sh_relax_section (abfd, sec, link_info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ struct internal_reloc *internal_relocs;
+ struct internal_reloc *free_relocs = NULL;
+ boolean have_code;
+ struct internal_reloc *irel, *irelend;
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+
+ *again = false;
+
+ if (link_info->relocateable
+ || (sec->flags & SEC_RELOC) == 0
+ || sec->reloc_count == 0)
+ return true;
+
+ /* If this is the first time we have been called for this section,
+ initialize the cooked size. */
+ if (sec->_cooked_size == 0)
+ sec->_cooked_size = sec->_raw_size;
+
+ internal_relocs = (_bfd_coff_read_internal_relocs
+ (abfd, sec, link_info->keep_memory,
+ (bfd_byte *) NULL, false,
+ (struct internal_reloc *) NULL));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ have_code = false;
+
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma laddr, paddr, symval;
+ unsigned short insn;
+ struct internal_reloc *irelfn, *irelscan, *irelcount;
+ struct internal_syment sym;
+ bfd_signed_vma foff;
+
+ if (irel->r_type == R_SH_CODE)
+ have_code = true;
+
+ if (irel->r_type != R_SH_USES)
+ continue;
+
+ /* Get the section contents. */
+ if (contents == NULL)
+ {
+ if (coff_section_data (abfd, sec) != NULL
+ && coff_section_data (abfd, sec)->contents != NULL)
+ contents = coff_section_data (abfd, sec)->contents;
+ else
+ {
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* The r_offset field of the R_SH_USES reloc will point us to
+ the register load. The 4 is because the r_offset field is
+ computed as though it were a jump offset, which are based
+ from 4 bytes after the jump instruction. */
+ laddr = irel->r_vaddr - sec->vma + 4;
+ /* Careful to sign extend the 32-bit offset. */
+ laddr += ((irel->r_offset & 0xffffffff) ^ 0x80000000) - 0x80000000;
+ if (laddr >= sec->_raw_size)
+ {
+ (*_bfd_error_handler) ("%s: 0x%lx: warning: bad R_SH_USES offset",
+ bfd_get_filename (abfd),
+ (unsigned long) irel->r_vaddr);
+ continue;
+ }
+ insn = bfd_get_16 (abfd, contents + laddr);
+
+ /* If the instruction is not mov.l NN,rN, we don't know what to do. */
+ if ((insn & 0xf000) != 0xd000)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x",
+ bfd_get_filename (abfd), (unsigned long) irel->r_vaddr, insn));
+ continue;
+ }
+
+ /* Get the address from which the register is being loaded. The
+ displacement in the mov.l instruction is quadrupled. It is a
+ displacement from four bytes after the movl instruction, but,
+ before adding in the PC address, two least significant bits
+ of the PC are cleared. We assume that the section is aligned
+ on a four byte boundary. */
+ paddr = insn & 0xff;
+ paddr *= 4;
+ paddr += (laddr + 4) &~ 3;
+ if (paddr >= sec->_raw_size)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: warning: bad R_SH_USES load offset",
+ bfd_get_filename (abfd), (unsigned long) irel->r_vaddr));
+ continue;
+ }
+
+ /* Get the reloc for the address from which the register is
+ being loaded. This reloc will tell us which function is
+ actually being called. */
+ paddr += sec->vma;
+ for (irelfn = internal_relocs; irelfn < irelend; irelfn++)
+ if (irelfn->r_vaddr == paddr
+ && irelfn->r_type == R_SH_IMM32)
+ break;
+ if (irelfn >= irelend)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: warning: could not find expected reloc",
+ bfd_get_filename (abfd), (unsigned long) paddr));
+ continue;
+ }
+
+ /* Get the value of the symbol referred to by the reloc. */
+ if (! _bfd_coff_get_external_symbols (abfd))
+ goto error_return;
+ bfd_coff_swap_sym_in (abfd,
+ ((bfd_byte *) obj_coff_external_syms (abfd)
+ + (irelfn->r_symndx
+ * bfd_coff_symesz (abfd))),
+ &sym);
+ if (sym.n_scnum != 0 && sym.n_scnum != sec->target_index)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: warning: symbol in unexpected section",
+ bfd_get_filename (abfd), (unsigned long) paddr));
+ continue;
+ }
+
+ if (sym.n_sclass != C_EXT)
+ {
+ symval = (sym.n_value
+ - sec->vma
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ struct coff_link_hash_entry *h;
+
+ h = obj_coff_sym_hashes (abfd)[irelfn->r_symndx];
+ BFD_ASSERT (h != NULL);
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ {
+ /* This appears to be a reference to an undefined
+ symbol. Just ignore it--it will be caught by the
+ regular reloc processing. */
+ continue;
+ }
+
+ symval = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+
+ symval += bfd_get_32 (abfd, contents + paddr - sec->vma);
+
+ /* See if this function call can be shortened. */
+ foff = (symval
+ - (irel->r_vaddr
+ - sec->vma
+ + sec->output_section->vma
+ + sec->output_offset
+ + 4));
+ if (foff < -0x1000 || foff >= 0x1000)
+ {
+ /* After all that work, we can't shorten this function call. */
+ continue;
+ }
+
+ /* Shorten the function call. */
+
+ /* For simplicity of coding, we are going to modify the section
+ contents, the section relocs, and the BFD symbol table. We
+ must tell the rest of the code not to free up this
+ information. It would be possible to instead create a table
+ of changes which have to be made, as is done in coff-mips.c;
+ that would be more work, but would require less memory when
+ the linker is run. */
+
+ if (coff_section_data (abfd, sec) == NULL)
+ {
+ sec->used_by_bfd =
+ ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
+ if (sec->used_by_bfd == NULL)
+ goto error_return;
+ }
+
+ coff_section_data (abfd, sec)->relocs = internal_relocs;
+ coff_section_data (abfd, sec)->keep_relocs = true;
+ free_relocs = NULL;
+
+ coff_section_data (abfd, sec)->contents = contents;
+ coff_section_data (abfd, sec)->keep_contents = true;
+ free_contents = NULL;
+
+ obj_coff_keep_syms (abfd) = true;
+
+ /* Replace the jsr with a bsr. */
+
+ /* Change the R_SH_USES reloc into an R_SH_PCDISP reloc, and
+ replace the jsr with a bsr. */
+ irel->r_type = R_SH_PCDISP;
+ irel->r_symndx = irelfn->r_symndx;
+ if (sym.n_sclass != C_EXT)
+ {
+ /* If this needs to be changed because of future relaxing,
+ it will be handled here like other internal PCDISP
+ relocs. */
+ bfd_put_16 (abfd,
+ 0xb000 | ((foff >> 1) & 0xfff),
+ contents + irel->r_vaddr - sec->vma);
+ }
+ else
+ {
+ /* We can't fully resolve this yet, because the external
+ symbol value may be changed by future relaxing. We let
+ the final link phase handle it. */
+ bfd_put_16 (abfd, 0xb000, contents + irel->r_vaddr - sec->vma);
+ }
+
+ /* See if there is another R_SH_USES reloc referring to the same
+ register load. */
+ for (irelscan = internal_relocs; irelscan < irelend; irelscan++)
+ if (irelscan->r_type == R_SH_USES
+ && laddr == irelscan->r_vaddr - sec->vma + 4 + irelscan->r_offset)
+ break;
+ if (irelscan < irelend)
+ {
+ /* Some other function call depends upon this register load,
+ and we have not yet converted that function call.
+ Indeed, we may never be able to convert it. There is
+ nothing else we can do at this point. */
+ continue;
+ }
+
+ /* Look for a R_SH_COUNT reloc on the location where the
+ function address is stored. Do this before deleting any
+ bytes, to avoid confusion about the address. */
+ for (irelcount = internal_relocs; irelcount < irelend; irelcount++)
+ if (irelcount->r_vaddr == paddr
+ && irelcount->r_type == R_SH_COUNT)
+ break;
+
+ /* Delete the register load. */
+ if (! sh_relax_delete_bytes (abfd, sec, laddr, 2))
+ goto error_return;
+
+ /* That will change things, so, just in case it permits some
+ other function call to come within range, we should relax
+ again. Note that this is not required, and it may be slow. */
+ *again = true;
+
+ /* Now check whether we got a COUNT reloc. */
+ if (irelcount >= irelend)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: warning: could not find expected COUNT reloc",
+ bfd_get_filename (abfd), (unsigned long) paddr));
+ continue;
+ }
+
+ /* The number of uses is stored in the r_offset field. We've
+ just deleted one. */
+ if (irelcount->r_offset == 0)
+ {
+ ((*_bfd_error_handler) ("%s: 0x%lx: warning: bad count",
+ bfd_get_filename (abfd),
+ (unsigned long) paddr));
+ continue;
+ }
+
+ --irelcount->r_offset;
+
+ /* If there are no more uses, we can delete the address. Reload
+ the address from irelfn, in case it was changed by the
+ previous call to sh_relax_delete_bytes. */
+ if (irelcount->r_offset == 0)
+ {
+ if (! sh_relax_delete_bytes (abfd, sec,
+ irelfn->r_vaddr - sec->vma, 4))
+ goto error_return;
+ }
+
+ /* We've done all we can with that function call. */
+ }
+
+ /* Look for load and store instructions that we can align on four
+ byte boundaries. */
+ if (have_code)
+ {
+ boolean swapped;
+
+ /* Get the section contents. */
+ if (contents == NULL)
+ {
+ if (coff_section_data (abfd, sec) != NULL
+ && coff_section_data (abfd, sec)->contents != NULL)
+ contents = coff_section_data (abfd, sec)->contents;
+ else
+ {
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ if (! sh_align_loads (abfd, sec, internal_relocs, contents, &swapped))
+ goto error_return;
+
+ if (swapped)
+ {
+ if (coff_section_data (abfd, sec) == NULL)
+ {
+ sec->used_by_bfd =
+ ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
+ if (sec->used_by_bfd == NULL)
+ goto error_return;
+ }
+
+ coff_section_data (abfd, sec)->relocs = internal_relocs;
+ coff_section_data (abfd, sec)->keep_relocs = true;
+ free_relocs = NULL;
+
+ coff_section_data (abfd, sec)->contents = contents;
+ coff_section_data (abfd, sec)->keep_contents = true;
+ free_contents = NULL;
+
+ obj_coff_keep_syms (abfd) = true;
+ }
+ }
+
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for coff_link_input_bfd. */
+ if (coff_section_data (abfd, sec) == NULL)
+ {
+ sec->used_by_bfd =
+ ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
+ if (sec->used_by_bfd == NULL)
+ goto error_return;
+ coff_section_data (abfd, sec)->relocs = NULL;
+ }
+ coff_section_data (abfd, sec)->contents = contents;
+ }
+ }
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ return false;
+}
+
+/* Delete some bytes from a section while relaxing. */
+
+static boolean
+sh_relax_delete_bytes (abfd, sec, addr, count)
+ bfd *abfd;
+ asection *sec;
+ bfd_vma addr;
+ int count;
+{
+ bfd_byte *contents;
+ struct internal_reloc *irel, *irelend;
+ struct internal_reloc *irelalign;
+ bfd_vma toaddr;
+ bfd_byte *esym, *esymend;
+ bfd_size_type symesz;
+ struct coff_link_hash_entry **sym_hash;
+ asection *o;
+
+ contents = coff_section_data (abfd, sec)->contents;
+
+ /* The deletion must stop at the next ALIGN reloc for an aligment
+ power larger than the number of bytes we are deleting. */
+
+ irelalign = NULL;
+ toaddr = sec->_cooked_size;
+
+ irel = coff_section_data (abfd, sec)->relocs;
+ irelend = irel + sec->reloc_count;
+ for (; irel < irelend; irel++)
+ {
+ if (irel->r_type == R_SH_ALIGN
+ && irel->r_vaddr - sec->vma > addr
+ && count < (1 << irel->r_offset))
+ {
+ irelalign = irel;
+ toaddr = irel->r_vaddr - sec->vma;
+ break;
+ }
+ }
+
+ /* Actually delete the bytes. */
+ memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ if (irelalign == NULL)
+ sec->_cooked_size -= count;
+ else
+ {
+ int i;
+
+#define NOP_OPCODE (0x0009)
+
+ BFD_ASSERT ((count & 1) == 0);
+ for (i = 0; i < count; i += 2)
+ bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i);
+ }
+
+ /* Adjust all the relocs. */
+ for (irel = coff_section_data (abfd, sec)->relocs; irel < irelend; irel++)
+ {
+ bfd_vma nraddr, stop;
+ bfd_vma start = 0;
+ int insn = 0;
+ struct internal_syment sym;
+ int off, adjust, oinsn;
+ bfd_signed_vma voff = 0;
+ boolean overflow;
+
+ /* Get the new reloc address. */
+ nraddr = irel->r_vaddr - sec->vma;
+ if ((irel->r_vaddr - sec->vma > addr
+ && irel->r_vaddr - sec->vma < toaddr)
+ || (irel->r_type == R_SH_ALIGN
+ && irel->r_vaddr - sec->vma == toaddr))
+ nraddr -= count;
+
+ /* See if this reloc was for the bytes we have deleted, in which
+ case we no longer care about it. Don't delete relocs which
+ represent addresses, though. */
+ if (irel->r_vaddr - sec->vma >= addr
+ && irel->r_vaddr - sec->vma < addr + count
+ && irel->r_type != R_SH_ALIGN
+ && irel->r_type != R_SH_CODE
+ && irel->r_type != R_SH_DATA
+ && irel->r_type != R_SH_LABEL)
+ irel->r_type = R_SH_UNUSED;
+
+ /* If this is a PC relative reloc, see if the range it covers
+ includes the bytes we have deleted. */
+ switch (irel->r_type)
+ {
+ default:
+ break;
+
+ case R_SH_PCDISP8BY2:
+ case R_SH_PCDISP:
+ case R_SH_PCRELIMM8BY2:
+ case R_SH_PCRELIMM8BY4:
+ start = irel->r_vaddr - sec->vma;
+ insn = bfd_get_16 (abfd, contents + nraddr);
+ break;
+ }
+
+ switch (irel->r_type)
+ {
+ default:
+ start = stop = addr;
+ break;
+
+ case R_SH_IMM32:
+ /* If this reloc is against a symbol defined in this
+ section, and the symbol will not be adjusted below, we
+ must check the addend to see it will put the value in
+ range to be adjusted, and hence must be changed. */
+ bfd_coff_swap_sym_in (abfd,
+ ((bfd_byte *) obj_coff_external_syms (abfd)
+ + (irel->r_symndx
+ * bfd_coff_symesz (abfd))),
+ &sym);
+ if (sym.n_sclass != C_EXT
+ && sym.n_scnum == sec->target_index
+ && ((bfd_vma) sym.n_value <= addr
+ || (bfd_vma) sym.n_value >= toaddr))
+ {
+ bfd_vma val;
+
+ val = bfd_get_32 (abfd, contents + nraddr);
+ val += sym.n_value;
+ if (val > addr && val < toaddr)
+ bfd_put_32 (abfd, val - count, contents + nraddr);
+ }
+ start = stop = addr;
+ break;
+
+ case R_SH_PCDISP8BY2:
+ off = insn & 0xff;
+ if (off & 0x80)
+ off -= 0x100;
+ stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
+ break;
+
+ case R_SH_PCDISP:
+ bfd_coff_swap_sym_in (abfd,
+ ((bfd_byte *) obj_coff_external_syms (abfd)
+ + (irel->r_symndx
+ * bfd_coff_symesz (abfd))),
+ &sym);
+ if (sym.n_sclass == C_EXT)
+ start = stop = addr;
+ else
+ {
+ off = insn & 0xfff;
+ if (off & 0x800)
+ off -= 0x1000;
+ stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
+ }
+ break;
+
+ case R_SH_PCRELIMM8BY2:
+ off = insn & 0xff;
+ stop = start + 4 + off * 2;
+ break;
+
+ case R_SH_PCRELIMM8BY4:
+ off = insn & 0xff;
+ stop = (start &~ (bfd_vma) 3) + 4 + off * 4;
+ break;
+
+ case R_SH_SWITCH8:
+ case R_SH_SWITCH16:
+ case R_SH_SWITCH32:
+ /* These relocs types represent
+ .word L2-L1
+ The r_offset field holds the difference between the reloc
+ address and L1. That is the start of the reloc, and
+ adding in the contents gives us the top. We must adjust
+ both the r_offset field and the section contents. */
+
+ start = irel->r_vaddr - sec->vma;
+ stop = (bfd_vma) ((bfd_signed_vma) start - (long) irel->r_offset);
+
+ if (start > addr
+ && start < toaddr
+ && (stop <= addr || stop >= toaddr))
+ irel->r_offset += count;
+ else if (stop > addr
+ && stop < toaddr
+ && (start <= addr || start >= toaddr))
+ irel->r_offset -= count;
+
+ start = stop;
+
+ if (irel->r_type == R_SH_SWITCH16)
+ voff = bfd_get_signed_16 (abfd, contents + nraddr);
+ else if (irel->r_type == R_SH_SWITCH8)
+ voff = bfd_get_8 (abfd, contents + nraddr);
+ else
+ voff = bfd_get_signed_32 (abfd, contents + nraddr);
+ stop = (bfd_vma) ((bfd_signed_vma) start + voff);
+
+ break;
+
+ case R_SH_USES:
+ start = irel->r_vaddr - sec->vma;
+ stop = (bfd_vma) ((bfd_signed_vma) start
+ + (long) irel->r_offset
+ + 4);
+ break;
+ }
+
+ if (start > addr
+ && start < toaddr
+ && (stop <= addr || stop >= toaddr))
+ adjust = count;
+ else if (stop > addr
+ && stop < toaddr
+ && (start <= addr || start >= toaddr))
+ adjust = - count;
+ else
+ adjust = 0;
+
+ if (adjust != 0)
+ {
+ oinsn = insn;
+ overflow = false;
+ switch (irel->r_type)
+ {
+ default:
+ abort ();
+ break;
+
+ case R_SH_PCDISP8BY2:
+ case R_SH_PCRELIMM8BY2:
+ insn += adjust / 2;
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, contents + nraddr);
+ break;
+
+ case R_SH_PCDISP:
+ insn += adjust / 2;
+ if ((oinsn & 0xf000) != (insn & 0xf000))
+ overflow = true;
+ bfd_put_16 (abfd, insn, contents + nraddr);
+ break;
+
+ case R_SH_PCRELIMM8BY4:
+ BFD_ASSERT (adjust == count || count >= 4);
+ if (count >= 4)
+ insn += adjust / 4;
+ else
+ {
+ if ((irel->r_vaddr & 3) == 0)
+ ++insn;
+ }
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, contents + nraddr);
+ break;
+
+ case R_SH_SWITCH8:
+ voff += adjust;
+ if (voff < 0 || voff >= 0xff)
+ overflow = true;
+ bfd_put_8 (abfd, voff, contents + nraddr);
+ break;
+
+ case R_SH_SWITCH16:
+ voff += adjust;
+ if (voff < - 0x8000 || voff >= 0x8000)
+ overflow = true;
+ bfd_put_signed_16 (abfd, voff, contents + nraddr);
+ break;
+
+ case R_SH_SWITCH32:
+ voff += adjust;
+ bfd_put_signed_32 (abfd, voff, contents + nraddr);
+ break;
+
+ case R_SH_USES:
+ irel->r_offset += adjust;
+ break;
+ }
+
+ if (overflow)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: fatal: reloc overflow while relaxing",
+ bfd_get_filename (abfd), (unsigned long) irel->r_vaddr));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ irel->r_vaddr = nraddr + sec->vma;
+ }
+
+ /* Look through all the other sections. If there contain any IMM32
+ relocs against internal symbols which we are not going to adjust
+ below, we may need to adjust the addends. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct internal_reloc *internal_relocs;
+ struct internal_reloc *irelscan, *irelscanend;
+ bfd_byte *ocontents;
+
+ if (o == sec
+ || (o->flags & SEC_RELOC) == 0
+ || o->reloc_count == 0)
+ continue;
+
+ /* We always cache the relocs. Perhaps, if info->keep_memory is
+ false, we should free them, if we are permitted to, when we
+ leave sh_coff_relax_section. */
+ internal_relocs = (_bfd_coff_read_internal_relocs
+ (abfd, o, true, (bfd_byte *) NULL, false,
+ (struct internal_reloc *) NULL));
+ if (internal_relocs == NULL)
+ return false;
+
+ ocontents = NULL;
+ irelscanend = internal_relocs + o->reloc_count;
+ for (irelscan = internal_relocs; irelscan < irelscanend; irelscan++)
+ {
+ struct internal_syment sym;
+
+ if (irelscan->r_type != R_SH_IMM32)
+ continue;
+
+ bfd_coff_swap_sym_in (abfd,
+ ((bfd_byte *) obj_coff_external_syms (abfd)
+ + (irelscan->r_symndx
+ * bfd_coff_symesz (abfd))),
+ &sym);
+ if (sym.n_sclass != C_EXT
+ && sym.n_scnum == sec->target_index
+ && ((bfd_vma) sym.n_value <= addr
+ || (bfd_vma) sym.n_value >= toaddr))
+ {
+ bfd_vma val;
+
+ if (ocontents == NULL)
+ {
+ if (coff_section_data (abfd, o)->contents != NULL)
+ ocontents = coff_section_data (abfd, o)->contents;
+ else
+ {
+ /* We always cache the section contents.
+ Perhaps, if info->keep_memory is false, we
+ should free them, if we are permitted to,
+ when we leave sh_coff_relax_section. */
+ ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
+ if (ocontents == NULL)
+ return false;
+ if (! bfd_get_section_contents (abfd, o, ocontents,
+ (file_ptr) 0,
+ o->_raw_size))
+ return false;
+ coff_section_data (abfd, o)->contents = ocontents;
+ }
+ }
+
+ val = bfd_get_32 (abfd, ocontents + irelscan->r_vaddr - o->vma);
+ val += sym.n_value;
+ if (val > addr && val < toaddr)
+ bfd_put_32 (abfd, val - count,
+ ocontents + irelscan->r_vaddr - o->vma);
+
+ coff_section_data (abfd, o)->keep_contents = true;
+ }
+ }
+ }
+
+ /* Adjusting the internal symbols will not work if something has
+ already retrieved the generic symbols. It would be possible to
+ make this work by adjusting the generic symbols at the same time.
+ However, this case should not arise in normal usage. */
+ if (obj_symbols (abfd) != NULL
+ || obj_raw_syments (abfd) != NULL)
+ {
+ ((*_bfd_error_handler)
+ ("%s: fatal: generic symbols retrieved before relaxing",
+ bfd_get_filename (abfd)));
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ /* Adjust all the symbols. */
+ sym_hash = obj_coff_sym_hashes (abfd);
+ symesz = bfd_coff_symesz (abfd);
+ esym = (bfd_byte *) obj_coff_external_syms (abfd);
+ esymend = esym + obj_raw_syment_count (abfd) * symesz;
+ while (esym < esymend)
+ {
+ struct internal_syment isym;
+
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym);
+
+ if (isym.n_scnum == sec->target_index
+ && (bfd_vma) isym.n_value > addr
+ && (bfd_vma) isym.n_value < toaddr)
+ {
+ isym.n_value -= count;
+
+ bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
+
+ if (*sym_hash != NULL)
+ {
+ BFD_ASSERT ((*sym_hash)->root.type == bfd_link_hash_defined
+ || (*sym_hash)->root.type == bfd_link_hash_defweak);
+ BFD_ASSERT ((*sym_hash)->root.u.def.value >= addr
+ && (*sym_hash)->root.u.def.value < toaddr);
+ (*sym_hash)->root.u.def.value -= count;
+ }
+ }
+
+ esym += (isym.n_numaux + 1) * symesz;
+ sym_hash += isym.n_numaux + 1;
+ }
+
+ /* See if we can move the ALIGN reloc forward. We have adjusted
+ r_vaddr for it already. */
+ if (irelalign != NULL)
+ {
+ bfd_vma alignto, alignaddr;
+
+ alignto = BFD_ALIGN (toaddr, 1 << irelalign->r_offset);
+ alignaddr = BFD_ALIGN (irelalign->r_vaddr - sec->vma,
+ 1 << irelalign->r_offset);
+ if (alignto != alignaddr)
+ {
+ /* Tail recursion. */
+ return sh_relax_delete_bytes (abfd, sec, alignaddr,
+ alignto - alignaddr);
+ }
+ }
+
+ return true;
+}
+
+/* This is yet another version of the SH opcode table, used to rapidly
+ get information about a particular instruction. */
+
+/* The opcode map is represented by an array of these structures. The
+ array is indexed by the high order four bits in the instruction. */
+
+struct sh_major_opcode
+{
+ /* A pointer to the instruction list. This is an array which
+ contains all the instructions with this major opcode. */
+ const struct sh_minor_opcode *minor_opcodes;
+ /* The number of elements in minor_opcodes. */
+ unsigned short count;
+};
+
+/* This structure holds information for a set of SH opcodes. The
+ instruction code is anded with the mask value, and the resulting
+ value is used to search the order opcode list. */
+
+struct sh_minor_opcode
+{
+ /* The sorted opcode list. */
+ const struct sh_opcode *opcodes;
+ /* The number of elements in opcodes. */
+ unsigned short count;
+ /* The mask value to use when searching the opcode list. */
+ unsigned short mask;
+};
+
+/* This structure holds information for an SH instruction. An array
+ of these structures is sorted in order by opcode. */
+
+struct sh_opcode
+{
+ /* The code for this instruction, after it has been anded with the
+ mask value in the sh_major_opcode structure. */
+ unsigned short opcode;
+ /* Flags for this instruction. */
+ unsigned short flags;
+};
+
+/* Flag which appear in the sh_opcode structure. */
+
+/* This instruction loads a value from memory. */
+#define LOAD (0x1)
+
+/* This instruction stores a value to memory. */
+#define STORE (0x2)
+
+/* This instruction is a branch. */
+#define BRANCH (0x4)
+
+/* This instruction has a delay slot. */
+#define DELAY (0x8)
+
+/* This instruction uses the value in the register in the field at
+ mask 0x0f00 of the instruction. */
+#define USES1 (0x10)
+
+/* This instruction uses the value in the register in the field at
+ mask 0x00f0 of the instruction. */
+#define USES2 (0x20)
+
+/* This instruction uses the value in register 0. */
+#define USESR0 (0x40)
+
+/* This instruction sets the value in the register in the field at
+ mask 0x0f00 of the instruction. */
+#define SETS1 (0x80)
+
+/* This instruction sets the value in the register in the field at
+ mask 0x00f0 of the instruction. */
+#define SETS2 (0x100)
+
+/* This instruction sets register 0. */
+#define SETSR0 (0x200)
+
+/* This instruction sets a special register. */
+#define SETSSP (0x400)
+
+/* This instruction uses a special register. */
+#define USESSP (0x800)
+
+/* This instruction uses the floating point register in the field at
+ mask 0x0f00 of the instruction. */
+#define USESF1 (0x1000)
+
+/* This instruction uses the floating point register in the field at
+ mask 0x00f0 of the instruction. */
+#define USESF2 (0x2000)
+
+/* This instruction uses floating point register 0. */
+#define USESF0 (0x4000)
+
+/* This instruction sets the floating point register in the field at
+ mask 0x0f00 of the instruction. */
+#define SETSF1 (0x8000)
+
+static boolean sh_insn_uses_reg
+ PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
+static boolean sh_insn_uses_freg
+ PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
+static boolean sh_insns_conflict
+ PARAMS ((unsigned int, const struct sh_opcode *, unsigned int,
+ const struct sh_opcode *));
+static boolean sh_load_use
+ PARAMS ((unsigned int, const struct sh_opcode *, unsigned int,
+ const struct sh_opcode *));
+
+/* The opcode maps. */
+
+#define MAP(a) a, sizeof a / sizeof a[0]
+
+static const struct sh_opcode sh_opcode00[] =
+{
+ { 0x0008, SETSSP }, /* clrt */
+ { 0x0009, 0 }, /* nop */
+ { 0x000b, BRANCH | DELAY | USESSP }, /* rts */
+ { 0x0018, SETSSP }, /* sett */
+ { 0x0019, SETSSP }, /* div0u */
+ { 0x001b, 0 }, /* sleep */
+ { 0x0028, SETSSP }, /* clrmac */
+ { 0x002b, BRANCH | DELAY | SETSSP }, /* rte */
+ { 0x0038, USESSP | SETSSP }, /* ldtlb */
+ { 0x0048, SETSSP }, /* clrs */
+ { 0x0058, SETSSP } /* sets */
+};
+
+static const struct sh_opcode sh_opcode01[] =
+{
+ { 0x0002, SETS1 | USESSP }, /* stc sr,rn */
+ { 0x0003, BRANCH | DELAY | USES1 | SETSSP }, /* bsrf rn */
+ { 0x000a, SETS1 | USESSP }, /* sts mach,rn */
+ { 0x0012, SETS1 | USESSP }, /* stc gbr,rn */
+ { 0x001a, SETS1 | USESSP }, /* sts macl,rn */
+ { 0x0022, SETS1 | USESSP }, /* stc vbr,rn */
+ { 0x0023, BRANCH | DELAY | USES1 }, /* braf rn */
+ { 0x0029, SETS1 | USESSP }, /* movt rn */
+ { 0x002a, SETS1 | USESSP }, /* sts pr,rn */
+ { 0x0032, SETS1 | USESSP }, /* stc ssr,rn */
+ { 0x0042, SETS1 | USESSP }, /* stc spc,rn */
+ { 0x005a, SETS1 | USESSP }, /* sts fpul,rn */
+ { 0x006a, SETS1 | USESSP }, /* sts fpscr,rn */
+ { 0x0082, SETS1 | USESSP }, /* stc r0_bank,rn */
+ { 0x0083, LOAD | USES1 }, /* pref @rn */
+ { 0x0092, SETS1 | USESSP }, /* stc r1_bank,rn */
+ { 0x00a2, SETS1 | USESSP }, /* stc r2_bank,rn */
+ { 0x00b2, SETS1 | USESSP }, /* stc r3_bank,rn */
+ { 0x00c2, SETS1 | USESSP }, /* stc r4_bank,rn */
+ { 0x00d2, SETS1 | USESSP }, /* stc r5_bank,rn */
+ { 0x00e2, SETS1 | USESSP }, /* stc r6_bank,rn */
+ { 0x00f2, SETS1 | USESSP } /* stc r7_bank,rn */
+};
+
+static const struct sh_opcode sh_opcode02[] =
+{
+ { 0x0004, STORE | USES1 | USES2 | USESR0 }, /* mov.b rm,@(r0,rn) */
+ { 0x0005, STORE | USES1 | USES2 | USESR0 }, /* mov.w rm,@(r0,rn) */
+ { 0x0006, STORE | USES1 | USES2 | USESR0 }, /* mov.l rm,@(r0,rn) */
+ { 0x0007, SETSSP | USES1 | USES2 }, /* mul.l rm,rn */
+ { 0x000c, LOAD | SETS1 | USES2 | USESR0 }, /* mov.b @(r0,rm),rn */
+ { 0x000d, LOAD | SETS1 | USES2 | USESR0 }, /* mov.w @(r0,rm),rn */
+ { 0x000e, LOAD | SETS1 | USES2 | USESR0 }, /* mov.l @(r0,rm),rn */
+ { 0x000f, LOAD|SETS1|SETS2|SETSSP|USES1|USES2|USESSP }, /* mac.l @rm+,@rn+ */
+};
+
+static const struct sh_minor_opcode sh_opcode0[] =
+{
+ { MAP (sh_opcode00), 0xffff },
+ { MAP (sh_opcode01), 0xf0ff },
+ { MAP (sh_opcode02), 0xf00f }
+};
+
+static const struct sh_opcode sh_opcode10[] =
+{
+ { 0x1000, STORE | USES1 | USES2 } /* mov.l rm,@(disp,rn) */
+};
+
+static const struct sh_minor_opcode sh_opcode1[] =
+{
+ { MAP (sh_opcode10), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcode20[] =
+{
+ { 0x2000, STORE | USES1 | USES2 }, /* mov.b rm,@rn */
+ { 0x2001, STORE | USES1 | USES2 }, /* mov.w rm,@rn */
+ { 0x2002, STORE | USES1 | USES2 }, /* mov.l rm,@rn */
+ { 0x2004, STORE | SETS1 | USES1 | USES2 }, /* mov.b rm,@-rn */
+ { 0x2005, STORE | SETS1 | USES1 | USES2 }, /* mov.w rm,@-rn */
+ { 0x2006, STORE | SETS1 | USES1 | USES2 }, /* mov.l rm,@-rn */
+ { 0x2007, SETSSP | USES1 | USES2 | USESSP }, /* div0s */
+ { 0x2008, SETSSP | USES1 | USES2 }, /* tst rm,rn */
+ { 0x2009, SETS1 | USES1 | USES2 }, /* and rm,rn */
+ { 0x200a, SETS1 | USES1 | USES2 }, /* xor rm,rn */
+ { 0x200b, SETS1 | USES1 | USES2 }, /* or rm,rn */
+ { 0x200c, SETSSP | USES1 | USES2 }, /* cmp/str rm,rn */
+ { 0x200d, SETS1 | USES1 | USES2 }, /* xtrct rm,rn */
+ { 0x200e, SETSSP | USES1 | USES2 }, /* mulu.w rm,rn */
+ { 0x200f, SETSSP | USES1 | USES2 } /* muls.w rm,rn */
+};
+
+static const struct sh_minor_opcode sh_opcode2[] =
+{
+ { MAP (sh_opcode20), 0xf00f }
+};
+
+static const struct sh_opcode sh_opcode30[] =
+{
+ { 0x3000, SETSSP | USES1 | USES2 }, /* cmp/eq rm,rn */
+ { 0x3002, SETSSP | USES1 | USES2 }, /* cmp/hs rm,rn */
+ { 0x3003, SETSSP | USES1 | USES2 }, /* cmp/ge rm,rn */
+ { 0x3004, SETSSP | USESSP | USES1 | USES2 }, /* div1 rm,rn */
+ { 0x3005, SETSSP | USES1 | USES2 }, /* dmulu.l rm,rn */
+ { 0x3006, SETSSP | USES1 | USES2 }, /* cmp/hi rm,rn */
+ { 0x3007, SETSSP | USES1 | USES2 }, /* cmp/gt rm,rn */
+ { 0x3008, SETS1 | USES1 | USES2 }, /* sub rm,rn */
+ { 0x300a, SETS1 | SETSSP | USES1 | USES2 | USESSP }, /* subc rm,rn */
+ { 0x300b, SETS1 | SETSSP | USES1 | USES2 }, /* subv rm,rn */
+ { 0x300c, SETS1 | USES1 | USES2 }, /* add rm,rn */
+ { 0x300d, SETSSP | USES1 | USES2 }, /* dmuls.l rm,rn */
+ { 0x300e, SETS1 | SETSSP | USES1 | USES2 | USESSP }, /* addc rm,rn */
+ { 0x300f, SETS1 | SETSSP | USES1 | USES2 } /* addv rm,rn */
+};
+
+static const struct sh_minor_opcode sh_opcode3[] =
+{
+ { MAP (sh_opcode30), 0xf00f }
+};
+
+static const struct sh_opcode sh_opcode40[] =
+{
+ { 0x4000, SETS1 | SETSSP | USES1 }, /* shll rn */
+ { 0x4001, SETS1 | SETSSP | USES1 }, /* shlr rn */
+ { 0x4002, STORE | SETS1 | USES1 | USESSP }, /* sts.l mach,@-rn */
+ { 0x4003, STORE | SETS1 | USES1 | USESSP }, /* stc.l sr,@-rn */
+ { 0x4004, SETS1 | SETSSP | USES1 }, /* rotl rn */
+ { 0x4005, SETS1 | SETSSP | USES1 }, /* rotr rn */
+ { 0x4006, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,mach */
+ { 0x4007, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,sr */
+ { 0x4008, SETS1 | USES1 }, /* shll2 rn */
+ { 0x4009, SETS1 | USES1 }, /* shlr2 rn */
+ { 0x400a, SETSSP | USES1 }, /* lds rm,mach */
+ { 0x400b, BRANCH | DELAY | USES1 }, /* jsr @rn */
+ { 0x400e, SETSSP | USES1 }, /* ldc rm,sr */
+ { 0x4010, SETS1 | SETSSP | USES1 }, /* dt rn */
+ { 0x4011, SETSSP | USES1 }, /* cmp/pz rn */
+ { 0x4012, STORE | SETS1 | USES1 | USESSP }, /* sts.l macl,@-rn */
+ { 0x4013, STORE | SETS1 | USES1 | USESSP }, /* stc.l gbr,@-rn */
+ { 0x4015, SETSSP | USES1 }, /* cmp/pl rn */
+ { 0x4016, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,macl */
+ { 0x4017, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,gbr */
+ { 0x4018, SETS1 | USES1 }, /* shll8 rn */
+ { 0x4019, SETS1 | USES1 }, /* shlr8 rn */
+ { 0x401a, SETSSP | USES1 }, /* lds rm,macl */
+ { 0x401b, LOAD | SETSSP | USES1 }, /* tas.b @rn */
+ { 0x401e, SETSSP | USES1 }, /* ldc rm,gbr */
+ { 0x4020, SETS1 | SETSSP | USES1 }, /* shal rn */
+ { 0x4021, SETS1 | SETSSP | USES1 }, /* shar rn */
+ { 0x4022, STORE | SETS1 | USES1 | USESSP }, /* sts.l pr,@-rn */
+ { 0x4023, STORE | SETS1 | USES1 | USESSP }, /* stc.l vbr,@-rn */
+ { 0x4024, SETS1 | SETSSP | USES1 | USESSP }, /* rotcl rn */
+ { 0x4025, SETS1 | SETSSP | USES1 | USESSP }, /* rotcr rn */
+ { 0x4026, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,pr */
+ { 0x4027, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,vbr */
+ { 0x4028, SETS1 | USES1 }, /* shll16 rn */
+ { 0x4029, SETS1 | USES1 }, /* shlr16 rn */
+ { 0x402a, SETSSP | USES1 }, /* lds rm,pr */
+ { 0x402b, BRANCH | DELAY | USES1 }, /* jmp @rn */
+ { 0x402e, SETSSP | USES1 }, /* ldc rm,vbr */
+ { 0x4033, STORE | SETS1 | USES1 | USESSP }, /* stc.l ssr,@-rn */
+ { 0x4037, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,ssr */
+ { 0x403e, SETSSP | USES1 }, /* ldc rm,ssr */
+ { 0x4043, STORE | SETS1 | USES1 | USESSP }, /* stc.l spc,@-rn */
+ { 0x4047, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,spc */
+ { 0x404e, SETSSP | USES1 }, /* ldc rm,spc */
+ { 0x4052, STORE | SETS1 | USES1 | USESSP }, /* sts.l fpul,@-rn */
+ { 0x4056, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,fpul */
+ { 0x405a, SETSSP | USES1 }, /* lds.l rm,fpul */
+ { 0x4062, STORE | SETS1 | USES1 | USESSP }, /* sts.l fpscr,@-rn */
+ { 0x4066, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,fpscr */
+ { 0x406a, SETSSP | USES1 } /* lds rm,fpscr */
+};
+
+static const struct sh_opcode sh_opcode41[] =
+{
+ { 0x4083, STORE | SETS1 | USES1 | USESSP }, /* stc.l rx_bank,@-rn */
+ { 0x4087, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,rx_bank */
+ { 0x408e, SETSSP | USES1 } /* ldc rm,rx_bank */
+};
+
+static const struct sh_opcode sh_opcode42[] =
+{
+ { 0x400c, SETS1 | USES1 | USES2 }, /* shad rm,rn */
+ { 0x400d, SETS1 | USES1 | USES2 }, /* shld rm,rn */
+ { 0x400f, LOAD|SETS1|SETS2|SETSSP|USES1|USES2|USESSP }, /* mac.w @rm+,@rn+ */
+};
+
+static const struct sh_minor_opcode sh_opcode4[] =
+{
+ { MAP (sh_opcode40), 0xf0ff },
+ { MAP (sh_opcode41), 0xf08f },
+ { MAP (sh_opcode42), 0xf00f }
+};
+
+static const struct sh_opcode sh_opcode50[] =
+{
+ { 0x5000, LOAD | SETS1 | USES2 } /* mov.l @(disp,rm),rn */
+};
+
+static const struct sh_minor_opcode sh_opcode5[] =
+{
+ { MAP (sh_opcode50), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcode60[] =
+{
+ { 0x6000, LOAD | SETS1 | USES2 }, /* mov.b @rm,rn */
+ { 0x6001, LOAD | SETS1 | USES2 }, /* mov.w @rm,rn */
+ { 0x6002, LOAD | SETS1 | USES2 }, /* mov.l @rm,rn */
+ { 0x6003, SETS1 | USES2 }, /* mov rm,rn */
+ { 0x6004, LOAD | SETS1 | SETS2 | USES2 }, /* mov.b @rm+,rn */
+ { 0x6005, LOAD | SETS1 | SETS2 | USES2 }, /* mov.w @rm+,rn */
+ { 0x6006, LOAD | SETS1 | SETS2 | USES2 }, /* mov.l @rm+,rn */
+ { 0x6007, SETS1 | USES2 }, /* not rm,rn */
+ { 0x6008, SETS1 | USES2 }, /* swap.b rm,rn */
+ { 0x6009, SETS1 | USES2 }, /* swap.w rm,rn */
+ { 0x600a, SETS1 | SETSSP | USES2 | USESSP }, /* negc rm,rn */
+ { 0x600b, SETS1 | USES2 }, /* neg rm,rn */
+ { 0x600c, SETS1 | USES2 }, /* extu.b rm,rn */
+ { 0x600d, SETS1 | USES2 }, /* extu.w rm,rn */
+ { 0x600e, SETS1 | USES2 }, /* exts.b rm,rn */
+ { 0x600f, SETS1 | USES2 } /* exts.w rm,rn */
+};
+
+static const struct sh_minor_opcode sh_opcode6[] =
+{
+ { MAP (sh_opcode60), 0xf00f }
+};
+
+static const struct sh_opcode sh_opcode70[] =
+{
+ { 0x7000, SETS1 | USES1 } /* add #imm,rn */
+};
+
+static const struct sh_minor_opcode sh_opcode7[] =
+{
+ { MAP (sh_opcode70), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcode80[] =
+{
+ { 0x8000, STORE | USES2 | USESR0 }, /* mov.b r0,@(disp,rn) */
+ { 0x8100, STORE | USES2 | USESR0 }, /* mov.w r0,@(disp,rn) */
+ { 0x8400, LOAD | SETSR0 | USES2 }, /* mov.b @(disp,rm),r0 */
+ { 0x8500, LOAD | SETSR0 | USES2 }, /* mov.w @(disp,rn),r0 */
+ { 0x8800, SETSSP | USESR0 }, /* cmp/eq #imm,r0 */
+ { 0x8900, BRANCH | USESSP }, /* bt label */
+ { 0x8b00, BRANCH | USESSP }, /* bf label */
+ { 0x8d00, BRANCH | DELAY | USESSP }, /* bt/s label */
+ { 0x8f00, BRANCH | DELAY | USESSP } /* bf/s label */
+};
+
+static const struct sh_minor_opcode sh_opcode8[] =
+{
+ { MAP (sh_opcode80), 0xff00 }
+};
+
+static const struct sh_opcode sh_opcode90[] =
+{
+ { 0x9000, LOAD | SETS1 } /* mov.w @(disp,pc),rn */
+};
+
+static const struct sh_minor_opcode sh_opcode9[] =
+{
+ { MAP (sh_opcode90), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcodea0[] =
+{
+ { 0xa000, BRANCH | DELAY } /* bra label */
+};
+
+static const struct sh_minor_opcode sh_opcodea[] =
+{
+ { MAP (sh_opcodea0), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcodeb0[] =
+{
+ { 0xb000, BRANCH | DELAY } /* bsr label */
+};
+
+static const struct sh_minor_opcode sh_opcodeb[] =
+{
+ { MAP (sh_opcodeb0), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcodec0[] =
+{
+ { 0xc000, STORE | USESR0 | USESSP }, /* mov.b r0,@(disp,gbr) */
+ { 0xc100, STORE | USESR0 | USESSP }, /* mov.w r0,@(disp,gbr) */
+ { 0xc200, STORE | USESR0 | USESSP }, /* mov.l r0,@(disp,gbr) */
+ { 0xc300, BRANCH | USESSP }, /* trapa #imm */
+ { 0xc400, LOAD | SETSR0 | USESSP }, /* mov.b @(disp,gbr),r0 */
+ { 0xc500, LOAD | SETSR0 | USESSP }, /* mov.w @(disp,gbr),r0 */
+ { 0xc600, LOAD | SETSR0 | USESSP }, /* mov.l @(disp,gbr),r0 */
+ { 0xc700, SETSR0 }, /* mova @(disp,pc),r0 */
+ { 0xc800, SETSSP | USESR0 }, /* tst #imm,r0 */
+ { 0xc900, SETSR0 | USESR0 }, /* and #imm,r0 */
+ { 0xca00, SETSR0 | USESR0 }, /* xor #imm,r0 */
+ { 0xcb00, SETSR0 | USESR0 }, /* or #imm,r0 */
+ { 0xcc00, LOAD | SETSSP | USESR0 | USESSP }, /* tst.b #imm,@(r0,gbr) */
+ { 0xcd00, LOAD | STORE | USESR0 | USESSP }, /* and.b #imm,@(r0,gbr) */
+ { 0xce00, LOAD | STORE | USESR0 | USESSP }, /* xor.b #imm,@(r0,gbr) */
+ { 0xcf00, LOAD | STORE | USESR0 | USESSP } /* or.b #imm,@(r0,gbr) */
+};
+
+static const struct sh_minor_opcode sh_opcodec[] =
+{
+ { MAP (sh_opcodec0), 0xff00 }
+};
+
+static const struct sh_opcode sh_opcoded0[] =
+{
+ { 0xd000, LOAD | SETS1 } /* mov.l @(disp,pc),rn */
+};
+
+static const struct sh_minor_opcode sh_opcoded[] =
+{
+ { MAP (sh_opcoded0), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcodee0[] =
+{
+ { 0xe000, SETS1 } /* mov #imm,rn */
+};
+
+static const struct sh_minor_opcode sh_opcodee[] =
+{
+ { MAP (sh_opcodee0), 0xf000 }
+};
+
+static const struct sh_opcode sh_opcodef0[] =
+{
+ { 0xf000, SETSF1 | USESF1 | USESF2 }, /* fadd fm,fn */
+ { 0xf001, SETSF1 | USESF1 | USESF2 }, /* fsub fm,fn */
+ { 0xf002, SETSF1 | USESF1 | USESF2 }, /* fmul fm,fn */
+ { 0xf003, SETSF1 | USESF1 | USESF2 }, /* fdiv fm,fn */
+ { 0xf004, SETSSP | USESF1 | USESF2 }, /* fcmp/eq fm,fn */
+ { 0xf005, SETSSP | USESF1 | USESF2 }, /* fcmp/gt fm,fn */
+ { 0xf006, LOAD | SETSF1 | USES2 | USESR0 }, /* fmov.s @(r0,rm),fn */
+ { 0xf007, STORE | USES1 | USESF2 | USESR0 }, /* fmov.s fm,@(r0,rn) */
+ { 0xf008, LOAD | SETSF1 | USES2 }, /* fmov.s @rm,fn */
+ { 0xf009, LOAD | SETS2 | SETSF1 | USES2 }, /* fmov.s @rm+,fn */
+ { 0xf00a, STORE | USES1 | USESF2 }, /* fmov.s fm,@rn */
+ { 0xf00b, STORE | SETS1 | USES1 | USESF2 }, /* fmov.s fm,@-rn */
+ { 0xf00c, SETSF1 | USESF2 }, /* fmov fm,fn */
+ { 0xf00e, SETSF1 | USESF1 | USESF2 | USESF0 } /* fmac f0,fm,fn */
+};
+
+static const struct sh_opcode sh_opcodef1[] =
+{
+ { 0xf00d, SETSF1 | USESSP }, /* fsts fpul,fn */
+ { 0xf01d, SETSSP | USESF1 }, /* flds fn,fpul */
+ { 0xf02d, SETSF1 | USESSP }, /* float fpul,fn */
+ { 0xf03d, SETSSP | USESF1 }, /* ftrc fn,fpul */
+ { 0xf04d, SETSF1 | USESF1 }, /* fneg fn */
+ { 0xf05d, SETSF1 | USESF1 }, /* fabs fn */
+ { 0xf06d, SETSF1 | USESF1 }, /* fsqrt fn */
+ { 0xf07d, SETSSP | USESF1 }, /* ftst/nan fn */
+ { 0xf08d, SETSF1 }, /* fldi0 fn */
+ { 0xf09d, SETSF1 } /* fldi1 fn */
+};
+
+static const struct sh_minor_opcode sh_opcodef[] =
+{
+ { MAP (sh_opcodef0), 0xf00f },
+ { MAP (sh_opcodef1), 0xf0ff }
+};
+
+static const struct sh_major_opcode sh_opcodes[] =
+{
+ { MAP (sh_opcode0) },
+ { MAP (sh_opcode1) },
+ { MAP (sh_opcode2) },
+ { MAP (sh_opcode3) },
+ { MAP (sh_opcode4) },
+ { MAP (sh_opcode5) },
+ { MAP (sh_opcode6) },
+ { MAP (sh_opcode7) },
+ { MAP (sh_opcode8) },
+ { MAP (sh_opcode9) },
+ { MAP (sh_opcodea) },
+ { MAP (sh_opcodeb) },
+ { MAP (sh_opcodec) },
+ { MAP (sh_opcoded) },
+ { MAP (sh_opcodee) },
+ { MAP (sh_opcodef) }
+};
+
+/* Given an instruction, return a pointer to the corresponding
+ sh_opcode structure. Return NULL if the instruction is not
+ recognized. */
+
+static const struct sh_opcode *
+sh_insn_info (insn)
+ unsigned int insn;
+{
+ const struct sh_major_opcode *maj;
+ const struct sh_minor_opcode *min, *minend;
+
+ maj = &sh_opcodes[(insn & 0xf000) >> 12];
+ min = maj->minor_opcodes;
+ minend = min + maj->count;
+ for (; min < minend; min++)
+ {
+ unsigned int l;
+ const struct sh_opcode *op, *opend;
+
+ l = insn & min->mask;
+ op = min->opcodes;
+ opend = op + min->count;
+
+ /* Since the opcodes tables are sorted, we could use a binary
+ search here if the count were above some cutoff value. */
+ for (; op < opend; op++)
+ if (op->opcode == l)
+ return op;
+ }
+
+ return NULL;
+}
+
+/* See whether an instruction uses a general purpose register. */
+
+static boolean
+sh_insn_uses_reg (insn, op, reg)
+ unsigned int insn;
+ const struct sh_opcode *op;
+ unsigned int reg;
+{
+ unsigned int f;
+
+ f = op->flags;
+
+ if ((f & USES1) != 0
+ && ((insn & 0x0f00) >> 8) == reg)
+ return true;
+ if ((f & USES2) != 0
+ && ((insn & 0x00f0) >> 4) == reg)
+ return true;
+ if ((f & USESR0) != 0
+ && reg == 0)
+ return true;
+
+ return false;
+}
+
+/* See whether an instruction uses a floating point register. */
+
+static boolean
+sh_insn_uses_freg (insn, op, freg)
+ unsigned int insn;
+ const struct sh_opcode *op;
+ unsigned int freg;
+{
+ unsigned int f;
+
+ f = op->flags;
+
+ /* We can't tell if this is a double-precision insn, so just play safe
+ and assume that it might be. So not only have we test FREG against
+ itself, but also even FREG against FREG+1 - if the using insn uses
+ just the low part of a double precision value - but also an odd
+ FREG against FREG-1 - if the setting insn sets just the low part
+ of a double precision value.
+ So what this all boils down to is that we have to ignore the lowest
+ bit of the register number. */
+
+ if ((f & USESF1) != 0
+ && ((insn & 0x0e00) >> 8) == (freg & 0xe))
+ return true;
+ if ((f & USESF2) != 0
+ && ((insn & 0x00e0) >> 4) == (freg & 0xe))
+ return true;
+ if ((f & USESF0) != 0
+ && freg == 0)
+ return true;
+
+ return false;
+}
+
+/* See whether instructions I1 and I2 conflict, assuming I1 comes
+ before I2. OP1 and OP2 are the corresponding sh_opcode structures.
+ This should return true if there is a conflict, or false if the
+ instructions can be swapped safely. */
+
+static boolean
+sh_insns_conflict (i1, op1, i2, op2)
+ unsigned int i1;
+ const struct sh_opcode *op1;
+ unsigned int i2;
+ const struct sh_opcode *op2;
+{
+ unsigned int f1, f2;
+
+ f1 = op1->flags;
+ f2 = op2->flags;
+
+ /* Load of fpscr conflicts with floating point operations.
+ FIXME: shouldn't test raw opcodes here. */
+ if (((i1 & 0xf0ff) == 0x4066 && (i2 & 0xf000) == 0xf000)
+ || ((i2 & 0xf0ff) == 0x4066 && (i1 & 0xf000) == 0xf000))
+ return true;
+
+ if ((f1 & (BRANCH | DELAY)) != 0
+ || (f2 & (BRANCH | DELAY)) != 0)
+ return true;
+
+ if ((f1 & SETSSP) != 0 && (f2 & USESSP) != 0)
+ return true;
+ if ((f2 & SETSSP) != 0 && (f1 & USESSP) != 0)
+ return true;
+
+ if ((f1 & SETS1) != 0
+ && sh_insn_uses_reg (i2, op2, (i1 & 0x0f00) >> 8))
+ return true;
+ if ((f1 & SETS2) != 0
+ && sh_insn_uses_reg (i2, op2, (i1 & 0x00f0) >> 4))
+ return true;
+ if ((f1 & SETSR0) != 0
+ && sh_insn_uses_reg (i2, op2, 0))
+ return true;
+ if ((f1 & SETSF1) != 0
+ && sh_insn_uses_freg (i2, op2, (i1 & 0x0f00) >> 8))
+ return true;
+
+ if ((f2 & SETS1) != 0
+ && sh_insn_uses_reg (i1, op1, (i2 & 0x0f00) >> 8))
+ return true;
+ if ((f2 & SETS2) != 0
+ && sh_insn_uses_reg (i1, op1, (i2 & 0x00f0) >> 4))
+ return true;
+ if ((f2 & SETSR0) != 0
+ && sh_insn_uses_reg (i1, op1, 0))
+ return true;
+ if ((f2 & SETSF1) != 0
+ && sh_insn_uses_freg (i1, op1, (i2 & 0x0f00) >> 8))
+ return true;
+
+ /* The instructions do not conflict. */
+ return false;
+}
+
+/* I1 is a load instruction, and I2 is some other instruction. Return
+ true if I1 loads a register which I2 uses. */
+
+static boolean
+sh_load_use (i1, op1, i2, op2)
+ unsigned int i1;
+ const struct sh_opcode *op1;
+ unsigned int i2;
+ const struct sh_opcode *op2;
+{
+ unsigned int f1;
+
+ f1 = op1->flags;
+
+ if ((f1 & LOAD) == 0)
+ return false;
+
+ /* If both SETS1 and SETSSP are set, that means a load to a special
+ register using postincrement addressing mode, which we don't care
+ about here. */
+ if ((f1 & SETS1) != 0
+ && (f1 & SETSSP) == 0
+ && sh_insn_uses_reg (i2, op2, (i1 & 0x0f00) >> 8))
+ return true;
+
+ if ((f1 & SETSR0) != 0
+ && sh_insn_uses_reg (i2, op2, 0))
+ return true;
+
+ if ((f1 & SETSF1) != 0
+ && sh_insn_uses_freg (i2, op2, (i1 & 0x0f00) >> 8))
+ return true;
+
+ return false;
+}
+
+/* Try to align loads and stores within a span of memory. This is
+ called by both the ELF and the COFF sh targets. ABFD and SEC are
+ the BFD and section we are examining. CONTENTS is the contents of
+ the section. SWAP is the routine to call to swap two instructions.
+ RELOCS is a pointer to the internal relocation information, to be
+ passed to SWAP. PLABEL is a pointer to the current label in a
+ sorted list of labels; LABEL_END is the end of the list. START and
+ STOP are the range of memory to examine. If a swap is made,
+ *PSWAPPED is set to true. */
+
+boolean
+_bfd_sh_align_load_span (abfd, sec, contents, swap, relocs,
+ plabel, label_end, start, stop, pswapped)
+ bfd *abfd;
+ asection *sec;
+ bfd_byte *contents;
+ boolean (*swap) PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma));
+ PTR relocs;
+ bfd_vma **plabel;
+ bfd_vma *label_end;
+ bfd_vma start;
+ bfd_vma stop;
+ boolean *pswapped;
+{
+ bfd_vma i;
+
+ /* Instructions should be aligned on 2 byte boundaries. */
+ if ((start & 1) == 1)
+ ++start;
+
+ /* Now look through the unaligned addresses. */
+ i = start;
+ if ((i & 2) == 0)
+ i += 2;
+ for (; i < stop; i += 4)
+ {
+ unsigned int insn;
+ const struct sh_opcode *op;
+ unsigned int prev_insn = 0;
+ const struct sh_opcode *prev_op = NULL;
+
+ insn = bfd_get_16 (abfd, contents + i);
+ op = sh_insn_info (insn);
+ if (op == NULL
+ || (op->flags & (LOAD | STORE)) == 0)
+ continue;
+
+ /* This is a load or store which is not on a four byte boundary. */
+
+ while (*plabel < label_end && **plabel < i)
+ ++*plabel;
+
+ if (i > start)
+ {
+ prev_insn = bfd_get_16 (abfd, contents + i - 2);
+ prev_op = sh_insn_info (prev_insn);
+
+ /* If the load/store instruction is in a delay slot, we
+ can't swap. */
+ if (prev_op == NULL
+ || (prev_op->flags & DELAY) != 0)
+ continue;
+ }
+ if (i > start
+ && (*plabel >= label_end || **plabel != i)
+ && prev_op != NULL
+ && (prev_op->flags & (LOAD | STORE)) == 0
+ && ! sh_insns_conflict (prev_insn, prev_op, insn, op))
+ {
+ boolean ok;
+
+ /* The load/store instruction does not have a label, and
+ there is a previous instruction; PREV_INSN is not
+ itself a load/store instruction, and PREV_INSN and
+ INSN do not conflict. */
+
+ ok = true;
+
+ if (i >= start + 4)
+ {
+ unsigned int prev2_insn;
+ const struct sh_opcode *prev2_op;
+
+ prev2_insn = bfd_get_16 (abfd, contents + i - 4);
+ prev2_op = sh_insn_info (prev2_insn);
+
+ /* If the instruction before PREV_INSN has a delay
+ slot--that is, PREV_INSN is in a delay slot--we
+ can not swap. */
+ if (prev2_op == NULL
+ || (prev2_op->flags & DELAY) != 0)
+ ok = false;
+
+ /* If the instruction before PREV_INSN is a load,
+ and it sets a register which INSN uses, then
+ putting INSN immediately after PREV_INSN will
+ cause a pipeline bubble, so there is no point to
+ making the swap. */
+ if (ok
+ && (prev2_op->flags & LOAD) != 0
+ && sh_load_use (prev2_insn, prev2_op, insn, op))
+ ok = false;
+ }
+
+ if (ok)
+ {
+ if (! (*swap) (abfd, sec, relocs, contents, i - 2))
+ return false;
+ *pswapped = true;
+ continue;
+ }
+ }
+
+ while (*plabel < label_end && **plabel < i + 2)
+ ++*plabel;
+
+ if (i + 2 < stop
+ && (*plabel >= label_end || **plabel != i + 2))
+ {
+ unsigned int next_insn;
+ const struct sh_opcode *next_op;
+
+ /* There is an instruction after the load/store
+ instruction, and it does not have a label. */
+ next_insn = bfd_get_16 (abfd, contents + i + 2);
+ next_op = sh_insn_info (next_insn);
+ if (next_op != NULL
+ && (next_op->flags & (LOAD | STORE)) == 0
+ && ! sh_insns_conflict (insn, op, next_insn, next_op))
+ {
+ boolean ok;
+
+ /* NEXT_INSN is not itself a load/store instruction,
+ and it does not conflict with INSN. */
+
+ ok = true;
+
+ /* If PREV_INSN is a load, and it sets a register
+ which NEXT_INSN uses, then putting NEXT_INSN
+ immediately after PREV_INSN will cause a pipeline
+ bubble, so there is no reason to make this swap. */
+ if (prev_op != NULL
+ && (prev_op->flags & LOAD) != 0
+ && sh_load_use (prev_insn, prev_op, next_insn, next_op))
+ ok = false;
+
+ /* If INSN is a load, and it sets a register which
+ the insn after NEXT_INSN uses, then doing the
+ swap will cause a pipeline bubble, so there is no
+ reason to make the swap. However, if the insn
+ after NEXT_INSN is itself a load or store
+ instruction, then it is misaligned, so
+ optimistically hope that it will be swapped
+ itself, and just live with the pipeline bubble if
+ it isn't. */
+ if (ok
+ && i + 4 < stop
+ && (op->flags & LOAD) != 0)
+ {
+ unsigned int next2_insn;
+ const struct sh_opcode *next2_op;
+
+ next2_insn = bfd_get_16 (abfd, contents + i + 4);
+ next2_op = sh_insn_info (next2_insn);
+ if ((next2_op->flags & (LOAD | STORE)) == 0
+ && sh_load_use (insn, op, next2_insn, next2_op))
+ ok = false;
+ }
+
+ if (ok)
+ {
+ if (! (*swap) (abfd, sec, relocs, contents, i))
+ return false;
+ *pswapped = true;
+ continue;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Look for loads and stores which we can align to four byte
+ boundaries. See the longer comment above sh_relax_section for why
+ this is desirable. This sets *PSWAPPED if some instruction was
+ swapped. */
+
+static boolean
+sh_align_loads (abfd, sec, internal_relocs, contents, pswapped)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *internal_relocs;
+ bfd_byte *contents;
+ boolean *pswapped;
+{
+ struct internal_reloc *irel, *irelend;
+ bfd_vma *labels = NULL;
+ bfd_vma *label, *label_end;
+
+ *pswapped = false;
+
+ irelend = internal_relocs + sec->reloc_count;
+
+ /* Get all the addresses with labels on them. */
+ labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma));
+ if (labels == NULL)
+ goto error_return;
+ label_end = labels;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ if (irel->r_type == R_SH_LABEL)
+ {
+ *label_end = irel->r_vaddr - sec->vma;
+ ++label_end;
+ }
+ }
+
+ /* Note that the assembler currently always outputs relocs in
+ address order. If that ever changes, this code will need to sort
+ the label values and the relocs. */
+
+ label = labels;
+
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma start, stop;
+
+ if (irel->r_type != R_SH_CODE)
+ continue;
+
+ start = irel->r_vaddr - sec->vma;
+
+ for (irel++; irel < irelend; irel++)
+ if (irel->r_type == R_SH_DATA)
+ break;
+ if (irel < irelend)
+ stop = irel->r_vaddr - sec->vma;
+ else
+ stop = sec->_cooked_size;
+
+ if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_swap_insns,
+ (PTR) internal_relocs, &label,
+ label_end, start, stop, pswapped))
+ goto error_return;
+ }
+
+ free (labels);
+
+ return true;
+
+ error_return:
+ if (labels != NULL)
+ free (labels);
+ return false;
+}
+
+/* Swap two SH instructions. */
+
+static boolean
+sh_swap_insns (abfd, sec, relocs, contents, addr)
+ bfd *abfd;
+ asection *sec;
+ PTR relocs;
+ bfd_byte *contents;
+ bfd_vma addr;
+{
+ struct internal_reloc *internal_relocs = (struct internal_reloc *) relocs;
+ unsigned short i1, i2;
+ struct internal_reloc *irel, *irelend;
+
+ /* Swap the instructions themselves. */
+ i1 = bfd_get_16 (abfd, contents + addr);
+ i2 = bfd_get_16 (abfd, contents + addr + 2);
+ bfd_put_16 (abfd, i2, contents + addr);
+ bfd_put_16 (abfd, i1, contents + addr + 2);
+
+ /* Adjust all reloc addresses. */
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ int type, add;
+
+ /* There are a few special types of relocs that we don't want to
+ adjust. These relocs do not apply to the instruction itself,
+ but are only associated with the address. */
+ type = irel->r_type;
+ if (type == R_SH_ALIGN
+ || type == R_SH_CODE
+ || type == R_SH_DATA
+ || type == R_SH_LABEL)
+ continue;
+
+ /* If an R_SH_USES reloc points to one of the addresses being
+ swapped, we must adjust it. It would be incorrect to do this
+ for a jump, though, since we want to execute both
+ instructions after the jump. (We have avoided swapping
+ around a label, so the jump will not wind up executing an
+ instruction it shouldn't). */
+ if (type == R_SH_USES)
+ {
+ bfd_vma off;
+
+ off = irel->r_vaddr - sec->vma + 4 + irel->r_offset;
+ if (off == addr)
+ irel->r_offset += 2;
+ else if (off == addr + 2)
+ irel->r_offset -= 2;
+ }
+
+ if (irel->r_vaddr - sec->vma == addr)
+ {
+ irel->r_vaddr += 2;
+ add = -2;
+ }
+ else if (irel->r_vaddr - sec->vma == addr + 2)
+ {
+ irel->r_vaddr -= 2;
+ add = 2;
+ }
+ else
+ add = 0;
+
+ if (add != 0)
+ {
+ bfd_byte *loc;
+ unsigned short insn, oinsn;
+ boolean overflow;
+
+ loc = contents + irel->r_vaddr - sec->vma;
+ overflow = false;
+ switch (type)
+ {
+ default:
+ break;
+
+ case R_SH_PCDISP8BY2:
+ case R_SH_PCRELIMM8BY2:
+ insn = bfd_get_16 (abfd, loc);
+ oinsn = insn;
+ insn += add / 2;
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, loc);
+ break;
+
+ case R_SH_PCDISP:
+ insn = bfd_get_16 (abfd, loc);
+ oinsn = insn;
+ insn += add / 2;
+ if ((oinsn & 0xf000) != (insn & 0xf000))
+ overflow = true;
+ bfd_put_16 (abfd, insn, loc);
+ break;
+
+ case R_SH_PCRELIMM8BY4:
+ /* This reloc ignores the least significant 3 bits of
+ the program counter before adding in the offset.
+ This means that if ADDR is at an even address, the
+ swap will not affect the offset. If ADDR is an at an
+ odd address, then the instruction will be crossing a
+ four byte boundary, and must be adjusted. */
+ if ((addr & 3) != 0)
+ {
+ insn = bfd_get_16 (abfd, loc);
+ oinsn = insn;
+ insn += add / 2;
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, loc);
+ }
+
+ break;
+ }
+
+ if (overflow)
+ {
+ ((*_bfd_error_handler)
+ ("%s: 0x%lx: fatal: reloc overflow while relaxing",
+ bfd_get_filename (abfd), (unsigned long) irel->r_vaddr));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* This is a modification of _bfd_coff_generic_relocate_section, which
+ will handle SH relaxing. */
+
+static boolean
+sh_relocate_section (output_bfd, info, input_bfd, input_section, contents,
+ relocs, syms, sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma addend;
+ bfd_vma val;
+ reloc_howto_type *howto;
+ bfd_reloc_status_type rstat;
+
+ /* Almost all relocs have to do with relaxing. If any work must
+ be done for them, it has been done in sh_relax_section. */
+ if (rel->r_type != R_SH_IMM32
+ && rel->r_type != R_SH_PCDISP)
+ continue;
+
+ symndx = rel->r_symndx;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ if (symndx < 0
+ || (unsigned long) symndx >= obj_raw_syment_count (input_bfd))
+ {
+ (*_bfd_error_handler)
+ ("%s: illegal symbol index %ld in relocs",
+ bfd_get_filename (input_bfd), symndx);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ }
+
+ if (sym != NULL && sym->n_scnum != 0)
+ addend = - sym->n_value;
+ else
+ addend = 0;
+
+ if (rel->r_type == R_SH_PCDISP)
+ addend -= 4;
+
+ if (rel->r_type >= SH_COFF_HOWTO_COUNT)
+ howto = NULL;
+ else
+ howto = &sh_coff_howtos[rel->r_type];
+
+ if (howto == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ asection *sec;
+
+ /* There is nothing to do for an internal PCDISP reloc. */
+ if (rel->r_type == R_SH_PCDISP)
+ continue;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
+ else
+ {
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma);
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents,
+ rel->r_vaddr - input_section->vma,
+ val, addend);
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else if (sym->_n._n_n._n_zeroes == 0
+ && sym->_n._n_n._n_offset != 0)
+ name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
+ else
+ {
+ strncpy (buf, sym->_n._n_name, SYMNMLEN);
+ buf[SYMNMLEN] = '\0';
+ name = buf;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* This is a version of bfd_generic_get_relocated_section_contents
+ which uses sh_relocate_section. */
+
+static bfd_byte *
+sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ asection *input_section = link_order->u.indirect.section;
+ bfd *input_bfd = input_section->owner;
+ asection **sections = NULL;
+ struct internal_reloc *internal_relocs = NULL;
+ struct internal_syment *internal_syms = NULL;
+
+ /* We only need to handle the case of relaxing, or of having a
+ particular set of section contents, specially. */
+ if (relocateable
+ || coff_section_data (input_bfd, input_section) == NULL
+ || coff_section_data (input_bfd, input_section)->contents == NULL)
+ return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
+ link_order, data,
+ relocateable,
+ symbols);
+
+ memcpy (data, coff_section_data (input_bfd, input_section)->contents,
+ input_section->_raw_size);
+
+ if ((input_section->flags & SEC_RELOC) != 0
+ && input_section->reloc_count > 0)
+ {
+ bfd_size_type symesz = bfd_coff_symesz (input_bfd);
+ bfd_byte *esym, *esymend;
+ struct internal_syment *isymp;
+ asection **secpp;
+
+ if (! _bfd_coff_get_external_symbols (input_bfd))
+ goto error_return;
+
+ internal_relocs = (_bfd_coff_read_internal_relocs
+ (input_bfd, input_section, false, (bfd_byte *) NULL,
+ false, (struct internal_reloc *) NULL));
+ if (internal_relocs == NULL)
+ goto error_return;
+
+ internal_syms = ((struct internal_syment *)
+ bfd_malloc (obj_raw_syment_count (input_bfd)
+ * sizeof (struct internal_syment)));
+ if (internal_syms == NULL)
+ goto error_return;
+
+ sections = (asection **) bfd_malloc (obj_raw_syment_count (input_bfd)
+ * sizeof (asection *));
+ if (sections == NULL)
+ goto error_return;
+
+ isymp = internal_syms;
+ secpp = sections;
+ esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
+ esymend = esym + obj_raw_syment_count (input_bfd) * symesz;
+ while (esym < esymend)
+ {
+ bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
+
+ if (isymp->n_scnum != 0)
+ *secpp = coff_section_from_bfd_index (input_bfd, isymp->n_scnum);
+ else
+ {
+ if (isymp->n_value == 0)
+ *secpp = bfd_und_section_ptr;
+ else
+ *secpp = bfd_com_section_ptr;
+ }
+
+ esym += (isymp->n_numaux + 1) * symesz;
+ secpp += isymp->n_numaux + 1;
+ isymp += isymp->n_numaux + 1;
+ }
+
+ if (! sh_relocate_section (output_bfd, link_info, input_bfd,
+ input_section, data, internal_relocs,
+ internal_syms, sections))
+ goto error_return;
+
+ free (sections);
+ sections = NULL;
+ free (internal_syms);
+ internal_syms = NULL;
+ free (internal_relocs);
+ internal_relocs = NULL;
+ }
+
+ return data;
+
+ error_return:
+ if (internal_relocs != NULL)
+ free (internal_relocs);
+ if (internal_syms != NULL)
+ free (internal_syms);
+ if (sections != NULL)
+ free (sections);
+ return NULL;
+}
+
+/* The target vectors. */
+
+const bfd_target shcoff_vec =
+{
+ "coff-sh", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+
+const bfd_target shlcoff_vec =
+{
+ "coff-shl", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little endian too*/
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
+
+/* Some people want versions of the SH COFF target which do not align
+ to 16 byte boundaries. We implement that by adding a couple of new
+ target vectors. These are just like the ones above, but they
+ change the default section alignment. To generate them in the
+ assembler, use -small. To use them in the linker, use -b
+ coff-sh{l}-small and -oformat coff-sh{l}-small.
+
+ Yes, this is a horrible hack. A general solution for setting
+ section alignment in COFF is rather complex. ELF handles this
+ correctly. */
+
+/* Only recognize the small versions if the target was not defaulted.
+ Otherwise we won't recognize the non default endianness. */
+
+static const bfd_target *
+coff_small_object_p (abfd)
+ bfd *abfd;
+{
+ if (abfd->target_defaulted)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ return coff_object_p (abfd);
+}
+
+/* Set the section alignment for the small versions. */
+
+static boolean
+coff_small_new_section_hook (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ if (! coff_new_section_hook (abfd, section))
+ return false;
+
+ /* We must align to at least a four byte boundary, because longword
+ accesses must be on a four byte boundary. */
+ if (section->alignment_power == COFF_DEFAULT_SECTION_ALIGNMENT_POWER)
+ section->alignment_power = 2;
+
+ return true;
+}
+
+/* This is copied from bfd_coff_std_swap_table so that we can change
+ the default section alignment power. */
+
+static const bfd_coff_backend_data bfd_coff_small_swap_table =
+{
+ coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in,
+ coff_swap_aux_out, coff_swap_sym_out,
+ coff_swap_lineno_out, coff_swap_reloc_out,
+ coff_swap_filehdr_out, coff_swap_aouthdr_out,
+ coff_swap_scnhdr_out,
+ FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ,
+#ifdef COFF_LONG_FILENAMES
+ true,
+#else
+ false,
+#endif
+#ifdef COFF_LONG_SECTION_NAMES
+ true,
+#else
+ false,
+#endif
+ 2,
+ coff_swap_filehdr_in, coff_swap_aouthdr_in, coff_swap_scnhdr_in,
+ coff_swap_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
+ coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
+ coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
+ coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
+ coff_sym_is_global, coff_compute_section_file_positions,
+ coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
+ coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_link_output_has_begun, coff_final_link_postscript
+};
+
+#define coff_small_close_and_cleanup \
+ coff_close_and_cleanup
+#define coff_small_bfd_free_cached_info \
+ coff_bfd_free_cached_info
+#define coff_small_get_section_contents \
+ coff_get_section_contents
+#define coff_small_get_section_contents_in_window \
+ coff_get_section_contents_in_window
+
+const bfd_target shcoff_small_vec =
+{
+ "coff-sh-small", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_small_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff_small),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) &bfd_coff_small_swap_table
+};
+
+const bfd_target shlcoff_small_vec =
+{
+ "coff-shl-small", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little endian too*/
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_small_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff_small),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) &bfd_coff_small_swap_table
+};
diff --git a/bfd/coff-sparc.c b/bfd/coff-sparc.c
new file mode 100644
index 00000000000..bc2cf153843
--- /dev/null
+++ b/bfd/coff-sparc.c
@@ -0,0 +1,256 @@
+/* BFD back-end for Sparc COFF files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/sparc.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
+
+/* The page size is a guess based on ELF. */
+#define COFF_PAGE_SIZE 0x10000
+
+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
+ };
+
+#if 0
+static CONST char *CONST reloc_type_names[] =
+{
+ "R_SPARC_NONE",
+ "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",
+};
+#endif
+
+/* This is stolen pretty directly from elf.c. */
+static bfd_reloc_status_type
+bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ return bfd_reloc_continue;
+}
+
+static reloc_howto_type coff_sparc_howto_table[] =
+{
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", false,0,0x000000ff,true),
+ HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,true),
+ HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", false,0,0xffffffff,true),
+ HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,true),
+ HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,true),
+ HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,true),
+ HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
+ HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,true),
+ HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,true),
+ HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
+ HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
+ HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,true),
+ HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,true),
+};
+
+struct coff_reloc_map {
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char coff_reloc_val;
+};
+
+static CONST struct coff_reloc_map sparc_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_SPARC_NONE, },
+ { BFD_RELOC_16, R_SPARC_16, },
+ { BFD_RELOC_8, R_SPARC_8 },
+ { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
+ { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
+ { BFD_RELOC_32, R_SPARC_32 },
+ { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
+ { BFD_RELOC_HI22, R_SPARC_HI22 },
+ { BFD_RELOC_LO10, R_SPARC_LO10, },
+ { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
+ { BFD_RELOC_SPARC22, R_SPARC_22 },
+ { BFD_RELOC_SPARC13, R_SPARC_13 },
+ { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
+ { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
+ { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
+ { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
+ { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
+ { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
+ { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
+ { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
+ { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
+ { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
+ { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
+ /* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
+};
+
+static reloc_howto_type *
+coff_sparc_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+ for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
+ {
+ if (sparc_reloc_map[i].bfd_reloc_val == code)
+ return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
+ }
+ return 0;
+}
+#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
+
+static void
+rtype2howto (cache_ptr, dst)
+ arelent *cache_ptr;
+ struct internal_reloc *dst;
+{
+ BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
+ cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
+}
+
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ cache_ptr->addend = reloc.r_offset;
+
+/* Clear the r_spare field in relocs. */
+#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
+ do { \
+ dst->r_spare[0] = 0; \
+ dst->r_spare[1] = 0; \
+ } while (0)
+
+#define __A_MAGIC_SET__
+
+/* Enable Sparc-specific hacks in coffcode.h. */
+
+#define COFF_SPARC
+
+#include "coffcode.h"
+
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ sparccoff_vec =
+#endif
+{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
+ "coff-sparc", /* name */
+#endif
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, coff_object_p},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
new file mode 100644
index 00000000000..21724fec0dc
--- /dev/null
+++ b/bfd/coff-stgo32.c
@@ -0,0 +1,464 @@
+/* BFD back-end for Intel 386 COFF files (go32 variant with a stub).
+ Copyright 1997, 1998 Free Software Foundation, Inc.
+ Written by Robert Hoehne.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file handles now also stubbed coff images. The stub is a small
+ DOS executable program before the coff image to load it in memory
+ and execute it. This is needed, because DOS cannot run coff files.
+
+ All the functions below are called by the corresponding functions
+ from coffswap.h.
+ The only thing what they do is to adjust the information stored in
+ the COFF file which are offset into the file.
+ This is needed, because DJGPP uses a very special way to load and run
+ the coff image. It loads the image in memory and assumes then, that the
+ image had no stub by using the filepointers as pointers in the coff
+ image and NOT in the file.
+
+ To be compatible with any existing executables I have fixed this
+ here and NOT in the DJGPP startup code.
+ */
+
+#define TARGET_SYM go32stubbedcoff_vec
+#define TARGET_NAME "coff-go32-exe"
+#define TARGET_UNDERSCORE '_'
+#define COFF_GO32_EXE
+
+#include "bfd.h"
+
+/* At first the prototypes */
+
+static void
+adjust_filehdr_in_post PARAMS ((bfd * abfd, PTR src, PTR dst));
+static void
+adjust_filehdr_out_pre PARAMS ((bfd * abfd, PTR in, PTR out));
+static void
+adjust_filehdr_out_post PARAMS ((bfd * abfd, PTR in, PTR out));
+
+static void
+adjust_scnhdr_in_post PARAMS ((bfd * abfd, PTR ext, PTR in));
+static void
+adjust_scnhdr_out_pre PARAMS ((bfd * abfd, PTR in, PTR out));
+static void
+adjust_scnhdr_out_post PARAMS ((bfd * abfd, PTR in, PTR out));
+
+static void
+adjust_aux_in_post PARAMS ((bfd * abfd, PTR ext1, int type, int class, int indx,
+ int numaux, PTR in1));
+static void
+adjust_aux_out_pre PARAMS ((bfd * abfd, PTR inp, int type, int class, int indx,
+ int numaux, PTR extp));
+static void
+adjust_aux_out_post PARAMS ((bfd * abfd, PTR inp, int type, int class, int indx,
+ int numaux, PTR extp));
+
+static void
+create_go32_stub PARAMS ((bfd * abfd));
+
+/*
+ All that ..._PRE and ...POST functions are called from the corresponding
+ coff_swap... functions. The ...PRE functions are called at the beginning
+ of the function and the ...POST functions at the end of the swap routines.
+ */
+
+#define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post
+#define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre
+#define COFF_ADJUST_FILEHDR_OUT_POST adjust_filehdr_out_post
+
+#define COFF_ADJUST_SCNHDR_IN_POST adjust_scnhdr_in_post
+#define COFF_ADJUST_SCNHDR_OUT_PRE adjust_scnhdr_out_pre
+#define COFF_ADJUST_SCNHDR_OUT_POST adjust_scnhdr_out_post
+
+#define COFF_ADJUST_AUX_IN_POST adjust_aux_in_post
+#define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre
+#define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post
+
+static boolean
+ go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd * ibfd, bfd * obfd));
+
+#define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
+
+#include "coff-i386.c"
+
+/* I hold in the usrdata the stub */
+#define bfd_coff_go32stub bfd_usrdata
+
+/* This macro is used, because I cannot assume the endianess of the
+ host system */
+#define _H(index) (bfd_h_get_16(abfd, (bfd_byte *)(header+index*2)))
+
+/* This function checks if the bfd is a stubbed coff image */
+static const bfd_target *
+go32_stubbed_coff_object_p (abfd)
+ bfd *abfd;
+{
+ unsigned char header[10];
+ char magic[8];
+ unsigned long coff_start, exe_start;
+
+ if (bfd_read (&header, 1, sizeof (header), abfd) != sizeof (header))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ if (_H (0) != 0x5a4d) /* it is not an exe file. maybe a coff-image */
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ coff_start = (long) _H (2) * 512L;
+ if (_H (1))
+ coff_start += (long) _H (1) - 512L;
+
+ /* We can handle only a stub with a length of STUBSIZE */
+ if (coff_start != STUBSIZE)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ exe_start = _H (4) * 16;
+ if (bfd_seek (abfd, exe_start, SEEK_SET) != 0)
+ return 0;
+ if (bfd_read (&magic, 1, 8, abfd) != 8)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ if (memcmp (magic, "go32stub", 8) != 0)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ return 0;
+
+ /* Call the normal COFF detection routine */
+ return coff_object_p (abfd);
+}
+
+/* These bytes are a 2048-byte DOS executable, which loads the COFF
+ image into memory and then runs it. It is called 'stub' */
+
+static unsigned char stub_bytes[STUBSIZE] =
+{
+#include "go32stub.h"
+};
+
+/*
+ I have not commented each swap function below, because the
+ technique is in any function the same. For the ...in function,
+ all the pointers are adjusted by adding STUBSIZE and for the
+ ...out function, it is subtracted first and after calling the
+ standard swap function it is reset to the old value */
+
+/* This macro is used for adjusting the filepointers, which
+ is done only, if the pointer is nonzero */
+
+#define ADJUST_VAL(val,diff) \
+ if (val != 0) val += diff
+
+static void
+adjust_filehdr_in_post (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ FILHDR *filehdr_src = (FILHDR *) src;
+ struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
+
+ ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
+
+ /* Save now the stub to be used later */
+ bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, STUBSIZE);
+
+ /* Since this function returns no status, I do not set here
+ any bfd_error_...
+ That means, before the use of bfd_coff_go32stub (), this value
+ should be checked if it is != NULL */
+ if (bfd_coff_go32stub (abfd) == NULL)
+ return;
+ memcpy (bfd_coff_go32stub (abfd), filehdr_src->stub, STUBSIZE);
+}
+
+static void
+adjust_filehdr_out_pre (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
+ FILHDR *filehdr_out = (FILHDR *) out;
+
+ /* Generate the stub */
+ create_go32_stub (abfd);
+
+ /* Copy the stub to the file header */
+ if (bfd_coff_go32stub (abfd) != NULL)
+ memcpy (filehdr_out->stub, bfd_coff_go32stub (abfd), STUBSIZE);
+ else
+ /* use the default */
+ memcpy (filehdr_out->stub, stub_bytes, STUBSIZE);
+
+ ADJUST_VAL (filehdr_in->f_symptr, -STUBSIZE);
+}
+
+static void
+adjust_filehdr_out_post (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
+ /* undo the above change */
+ ADJUST_VAL (filehdr_in->f_symptr, STUBSIZE);
+}
+
+static void
+adjust_scnhdr_in_post (abfd, ext, in)
+ bfd *abfd;
+ PTR ext;
+ PTR in;
+{
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
+
+ ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
+ ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
+ ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
+}
+
+static void
+adjust_scnhdr_out_pre (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
+
+ ADJUST_VAL (scnhdr_int->s_scnptr, -STUBSIZE);
+ ADJUST_VAL (scnhdr_int->s_relptr, -STUBSIZE);
+ ADJUST_VAL (scnhdr_int->s_lnnoptr, -STUBSIZE);
+}
+
+static void
+adjust_scnhdr_out_post (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
+
+ ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
+ ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
+ ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
+}
+
+static void
+adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1)
+ bfd *abfd;
+ PTR ext1;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR in1;
+{
+ union internal_auxent *in = (union internal_auxent *) in1;
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
+ }
+}
+
+static void
+adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp)
+ bfd *abfd;
+ PTR inp;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR extp;
+{
+ union internal_auxent *in = (union internal_auxent *) inp;
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -STUBSIZE);
+ }
+}
+
+static void
+adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
+ bfd *abfd;
+ PTR inp;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR extp;
+{
+ union internal_auxent *in = (union internal_auxent *) inp;
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
+ }
+}
+
+/*
+ That's the function, which creates the stub. There are
+ different cases from where the stub is taken.
+ At first the environment variable $(GO32STUB) is checked and then
+ $(STUB) if it was not set.
+ If it exists and points to a valid stub the stub is taken from
+ that file. This file can be also a whole executable file, because
+ the stub is computed from the exe information at the start of that
+ file.
+
+ If there was any error, the standard stub (compiled in this file)
+ is taken.
+ */
+
+static void
+create_go32_stub (abfd)
+ bfd *abfd;
+{
+ /* Do it only once */
+ if (bfd_coff_go32stub (abfd) == NULL)
+ {
+ char *stub;
+ struct stat st;
+ int f;
+ unsigned char header[10];
+ char magic[8];
+ unsigned long coff_start, exe_start;
+
+ /* Check at first the environment variable $(GO32STUB) */
+ stub = getenv ("GO32STUB");
+ /* Now check the environment variable $(STUB) */
+ if (stub == NULL)
+ stub = getenv ("STUB");
+ if (stub == NULL)
+ goto stub_end;
+ if (stat (stub, &st) != 0)
+ goto stub_end;
+#ifdef O_BINARY
+ f = open (stub, O_RDONLY | O_BINARY);
+#else
+ f = open (stub, O_RDONLY);
+#endif
+ if (f < 0)
+ goto stub_end;
+ if (read (f, &header, sizeof (header)) < 0)
+ {
+ close (f);
+ goto stub_end;
+ }
+ if (_H (0) != 0x5a4d) /* it is not an exe file */
+ {
+ close (f);
+ goto stub_end;
+ }
+ /* Compute the size of the stub (it is every thing up
+ to the beginning of the coff image) */
+ coff_start = (long) _H (2) * 512L;
+ if (_H (1))
+ coff_start += (long) _H (1) - 512L;
+
+ /* Currently there is only a fixed stub size of 2048 bytes
+ supported */
+ if (coff_start != 2048)
+ {
+ close (f);
+ goto stub_end;
+ }
+ exe_start = _H (4) * 16;
+ if ((unsigned long) lseek (f, exe_start, SEEK_SET) != exe_start)
+ {
+ close (f);
+ goto stub_end;
+ }
+ if (read (f, &magic, 8) != 8)
+ {
+ close (f);
+ goto stub_end;
+ }
+ if (memcmp (magic, "go32stub", 8) != 0)
+ {
+ close (f);
+ goto stub_end;
+ }
+ /* Now we found a correct stub (hopefully) */
+ bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, coff_start);
+ if (bfd_coff_go32stub (abfd) == NULL)
+ {
+ close (f);
+ return;
+ }
+ lseek (f, 0L, SEEK_SET);
+ if ((unsigned long) read (f, bfd_coff_go32stub (abfd), coff_start)
+ != coff_start)
+ {
+ bfd_release (abfd, bfd_coff_go32stub (abfd));
+ bfd_coff_go32stub (abfd) = NULL;
+ }
+ close (f);
+ }
+stub_end:
+ /* There was something wrong above, so use now the standard builtin
+ stub */
+ if (bfd_coff_go32stub (abfd) == NULL)
+ {
+ bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, STUBSIZE);
+ if (bfd_coff_go32stub (abfd) == NULL)
+ {
+ return;
+ }
+
+ memcpy (bfd_coff_go32stub (abfd), stub_bytes, STUBSIZE);
+ }
+}
+
+/* If ibfd was a stubbed coff image, copy the stub from that bfd
+ to the new obfd.
+ */
+
+static boolean
+go32_stubbed_coff_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ /* check if both are the same targets */
+ if (ibfd->xvec != obfd->xvec)
+ return true;
+
+ /* check if both have a valid stub */
+ if (bfd_coff_go32stub (ibfd) == NULL
+ || bfd_coff_go32stub (obfd) == NULL)
+ return true;
+
+ /* Now copy the stub */
+ memcpy (bfd_coff_go32stub (obfd), bfd_coff_go32stub (ibfd), STUBSIZE);
+
+ return true;
+}
diff --git a/bfd/coff-svm68k.c b/bfd/coff-svm68k.c
new file mode 100644
index 00000000000..3d2a5a7d565
--- /dev/null
+++ b/bfd/coff-svm68k.c
@@ -0,0 +1,26 @@
+/* BFD back-end for Motorola sysv68
+ Copyright 1997 Free Software Foundation, Inc.
+ Written by Philippe De Muyter <phdm@info.ucl.ac.be>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM m68ksysvcoff_vec
+#define TARGET_NAME "coff-m68k-sysv"
+#define STATIC_RELOCS
+#define COFF_COMMON_ADDEND
+
+#include "coff-m68k.c"
diff --git a/bfd/coff-tic30.c b/bfd/coff-tic30.c
new file mode 100644
index 00000000000..3ff8c594036
--- /dev/null
+++ b/bfd/coff-tic30.c
@@ -0,0 +1,206 @@
+/* BFD back-end for TMS320C30 coff binaries.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "coff/tic30.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+
+reloc_howto_type tic30_coff_howto_table[] =
+{
+ HOWTO (R_TIC30_ABS16, 2, 1, 16, false, 0, 0, NULL,
+ "16", false, 0x0000FFFF, 0x0000FFFF, false),
+ HOWTO (R_TIC30_ABS24, 2, 2, 24, false, 8, complain_overflow_bitfield, NULL,
+ "24", false, 0xFFFFFF00, 0xFFFFFF00, false),
+ HOWTO (R_TIC30_LDP, 18, 0, 24, false, 0, complain_overflow_bitfield, NULL,
+ "LDP", false, 0x00FF0000, 0x000000FF, false),
+ HOWTO (R_TIC30_ABS32, 2, 2, 32, false, 0, complain_overflow_bitfield, NULL,
+ "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false),
+ HOWTO (R_TIC30_PC16, 2, 1, 16, true, 0, complain_overflow_signed, NULL,
+ "PCREL", false, 0x0000FFFF, 0x0000FFFF, false),
+ {-1}
+};
+
+#ifndef coff_bfd_reloc_type_lookup
+#define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup
+
+/* For the case statement use the code values used in tc_gen_reloc to
+ map to the howto table entries that match those in both the aout
+ and coff implementations. */
+reloc_howto_type *
+tic30_coff_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_8:
+ case BFD_RELOC_TIC30_LDP:
+ return &tic30_coff_howto_table[2];
+ case BFD_RELOC_16:
+ return &tic30_coff_howto_table[0];
+ case BFD_RELOC_24:
+ return &tic30_coff_howto_table[1];
+ case BFD_RELOC_16_PCREL:
+ return &tic30_coff_howto_table[4];
+ case BFD_RELOC_32:
+ return &tic30_coff_howto_table[3];
+ default:
+ return (reloc_howto_type *) NULL;
+ }
+}
+
+#endif
+
+/* Turn a howto into a reloc number */
+
+static int
+coff_tic30_select_reloc (howto)
+ reloc_howto_type *howto;
+{
+ return howto->type;
+}
+
+#define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto)
+
+
+#define BADMAG(x) TIC30BADMAG(x)
+#define TIC30 1 /* Customize coffcode.h */
+#define __A_MAGIC_SET__
+
+/* Code to swap in the reloc */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \
+dst->r_stuff[1] = 'C';
+
+/* Code to turn a r_type into a howto ptr, uses the above howto table. */
+
+static void
+rtype2howto (internal, dst)
+ arelent *internal;
+ struct internal_reloc *dst;
+{
+ switch (dst->r_type)
+ {
+ case R_TIC30_ABS16:
+ internal->howto = &tic30_coff_howto_table[0];
+ break;
+ case R_TIC30_ABS24:
+ internal->howto = &tic30_coff_howto_table[1];
+ break;
+ case R_TIC30_ABS32:
+ internal->howto = &tic30_coff_howto_table[3];
+ break;
+ case R_TIC30_LDP:
+ internal->howto = &tic30_coff_howto_table[2];
+ break;
+ case R_TIC30_PC16:
+ internal->howto = &tic30_coff_howto_table[4];
+ break;
+ default:
+ abort ();
+ break;
+ }
+}
+
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+
+/* Perform any necessary magic to the addend in a reloc entry */
+
+#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
+ cache_ptr->addend = ext_reloc.r_offset;
+
+
+#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void
+reloc_processing (relent, reloc, symbols, abfd, section)
+ arelent *relent;
+ struct internal_reloc *reloc;
+ asymbol **symbols;
+ bfd *abfd;
+ asection *section;
+{
+ relent->address = reloc->r_vaddr;
+ rtype2howto (relent, reloc);
+
+ if (reloc->r_symndx > 0)
+ {
+ relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
+ }
+ else
+ {
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+ relent->addend = reloc->r_offset;
+ relent->address -= section->vma;
+}
+
+#include "coffcode.h"
+
+const bfd_target tic30_coff_vec =
+{
+ "coff-tic30", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE
+};
diff --git a/bfd/coff-tic80.c b/bfd/coff-tic80.c
new file mode 100644
index 00000000000..043c8a01835
--- /dev/null
+++ b/bfd/coff-tic80.c
@@ -0,0 +1,759 @@
+/* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP).
+ Copyright 1996, 1997, 1999 Free Software Foundation, Inc.
+
+ Written by Fred Fish (fnf@cygnus.com)
+
+ There is nothing new under the sun. This file draws a lot on other
+ coff files.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "bfdlink.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/tic80.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
+#define COFF_ALIGN_IN_SECTION_HEADER 1
+#define COFF_ALIGN_IN_SFLAGS 1
+
+#define GET_SCNHDR_FLAGS bfd_h_get_16
+#define PUT_SCNHDR_FLAGS bfd_h_put_16
+
+static void rtype2howto
+ PARAMS ((arelent *cache_ptr, struct internal_reloc *dst));
+static bfd_reloc_status_type ppbase_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type glob15_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type glob16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type local16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean coff_tic80_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+static reloc_howto_type tic80_howto_table[] =
+{
+
+ HOWTO (R_RELLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ NULL, /* special_function */
+ "RELLONG", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MPPCR, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ NULL, /* special_function */
+ "MPPCR", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_ABS, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ NULL, /* special_function */
+ "ABS", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPBASE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ ppbase_reloc, /* special_function */
+ "PPBASE", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPLBASE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ ppbase_reloc, /* special_function */
+ "PPLBASE", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PP15, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob15_reloc, /* special_function */
+ "PP15", /* name */
+ true, /* partial_inplace */
+ 0x1ffc0, /* src_mask */
+ 0x1ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PP15W, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob15_reloc, /* special_function */
+ "PP15W", /* name */
+ true, /* partial_inplace */
+ 0x1ffc0, /* src_mask */
+ 0x1ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PP15H, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob15_reloc, /* special_function */
+ "PP15H", /* name */
+ true, /* partial_inplace */
+ 0x1ffc0, /* src_mask */
+ 0x1ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PP16B, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob16_reloc, /* special_function */
+ "PP16B", /* name */
+ true, /* partial_inplace */
+ 0x3ffc0, /* src_mask */
+ 0x3ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPL15, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PPL15", /* name */
+ true, /* partial_inplace */
+ 0x7fff, /* src_mask */
+ 0x7fff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPL15W, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PPL15W", /* name */
+ true, /* partial_inplace */
+ 0x7fff, /* src_mask */
+ 0x7fff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPL15H, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PPL15H", /* name */
+ true, /* partial_inplace */
+ 0x7fff, /* src_mask */
+ 0x7fff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPL16B, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ local16_reloc, /* special_function */
+ "PPL16B", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPN15, /* type */
+ 0, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob15_reloc, /* special_function */
+ "PPN15", /* name */
+ true, /* partial_inplace */
+ 0x1ffc0, /* src_mask */
+ 0x1ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPN15W, /* type */
+ 2, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob15_reloc, /* special_function */
+ "PPN15W", /* name */
+ true, /* partial_inplace */
+ 0x1ffc0, /* src_mask */
+ 0x1ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPN15H, /* type */
+ 1, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob15_reloc, /* special_function */
+ "PPN15H", /* name */
+ true, /* partial_inplace */
+ 0x1ffc0, /* src_mask */
+ 0x1ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPN16B, /* type */
+ 0, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ glob16_reloc, /* special_function */
+ "PPN16B", /* name */
+ true, /* partial_inplace */
+ 0x3ffc0, /* src_mask */
+ 0x3ffc0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPLN15, /* type */
+ 0, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PPLN15", /* name */
+ true, /* partial_inplace */
+ 0x7fff, /* src_mask */
+ 0x7fff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPLN15W, /* type */
+ 2, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PPLN15W", /* name */
+ true, /* partial_inplace */
+ 0x7fff, /* src_mask */
+ 0x7fff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPLN15H, /* type */
+ 1, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "PPLN15H", /* name */
+ true, /* partial_inplace */
+ 0x7fff, /* src_mask */
+ 0x7fff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_PPLN16B, /* type */
+ 0, /* rightshift */
+ -2, /* size (0 = byte, 1 = short, 2 = long) */
+ 15, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ local16_reloc, /* special_function */
+ "PPLN16B", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+/* Special relocation functions, used when the output file is not
+ itself a COFF TIc80 file. */
+
+/* This special function is used for the base address type
+ relocations. */
+
+static bfd_reloc_status_type
+ppbase_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* FIXME. */
+ abort ();
+}
+
+/* This special function is used for the global 15 bit relocations. */
+
+static bfd_reloc_status_type
+glob15_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* FIXME. */
+ abort ();
+}
+
+/* This special function is used for the global 16 bit relocations. */
+
+static bfd_reloc_status_type
+glob16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* FIXME. */
+ abort ();
+}
+
+/* This special function is used for the local 16 bit relocations. */
+
+static bfd_reloc_status_type
+local16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* FIXME. */
+ abort ();
+}
+
+/* Code to turn an external r_type into a pointer to an entry in the howto_table.
+ If passed an r_type we don't recognize the abort rather than silently failing
+ to generate an output file. */
+
+static void
+rtype2howto (cache_ptr, dst)
+ arelent *cache_ptr;
+ struct internal_reloc *dst;
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof tic80_howto_table / sizeof tic80_howto_table[0]; i++)
+ {
+ if (tic80_howto_table[i].type == dst->r_type)
+ {
+ cache_ptr->howto = tic80_howto_table + i;
+ return;
+ }
+ }
+
+ (*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
+ (unsigned int) dst->r_type);
+ cache_ptr->howto = tic80_howto_table + 0;
+}
+
+#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
+#define coff_rtype_to_howto coff_tic80_rtype_to_howto
+
+static reloc_howto_type *
+coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+ arelent genrel;
+
+ if (rel -> r_symndx == -1 && addendp != NULL)
+ {
+ /* This is a TI "internal relocation", which means that the relocation
+ amount is the amount by which the current section is being relocated
+ in the output section. */
+ *addendp = (sec -> output_section -> vma + sec -> output_offset) - sec -> vma;
+ }
+ RTYPE2HOWTO (&genrel, rel);
+ return genrel.howto;
+}
+
+#ifndef BADMAG
+#define BADMAG(x) TIC80BADMAG(x)
+#endif
+
+#define coff_relocate_section coff_tic80_relocate_section
+
+/* We need a special relocation routine to handle the PP relocs. Most
+ of this is a copy of _bfd_coff_generic_relocate_section. */
+
+static boolean
+coff_tic80_relocate_section (output_bfd, info, input_bfd,
+ input_section, contents, relocs, syms,
+ sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma addend;
+ bfd_vma val;
+ reloc_howto_type *howto;
+ bfd_reloc_status_type rstat;
+ bfd_vma addr;
+
+ symndx = rel->r_symndx;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ }
+
+ /* COFF treats common symbols in one of two ways. Either the
+ size of the symbol is included in the section contents, or it
+ is not. We assume that the size is not included, and force
+ the rtype_to_howto function to adjust the addend as needed. */
+
+ if (sym != NULL && sym->n_scnum != 0)
+ addend = - sym->n_value;
+ else
+ addend = 0;
+
+ howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
+ sym, &addend);
+ if (howto == NULL)
+ return false;
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ asection *sec;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
+ else
+ {
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value);
+ if (! obj_pe (output_bfd))
+ val -= sec->vma;
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ addr = rel->r_vaddr - input_section->vma;
+
+ /* FIXME: This code assumes little endian, but the PP can
+ apparently be bi-endian. I don't know if the bi-endianness
+ applies to the instruction set or just to the data. */
+ switch (howto->type)
+ {
+ default:
+ case R_ABS:
+ case R_RELLONGX:
+ case R_PPL15:
+ case R_PPL15W:
+ case R_PPL15H:
+ case R_PPLN15:
+ case R_PPLN15W:
+ case R_PPLN15H:
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, addr, val, addend);
+ break;
+
+ case R_PP15:
+ case R_PP15W:
+ case R_PP15H:
+ case R_PPN15:
+ case R_PPN15W:
+ case R_PPN15H:
+ /* Offset the address so that we can use 4 byte relocations. */
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents + 2, addr, val, addend);
+ break;
+
+ case R_PP16B:
+ case R_PPN16B:
+ {
+ /* The most significant bit is stored in bit 6. */
+ bfd_byte hold;
+
+ hold = contents[addr + 4];
+ contents[addr + 4] &=~ 0x20;
+ contents[addr + 4] |= (contents[addr] >> 1) & 0x20;
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents + 2, addr,
+ val, addend);
+ contents[addr] &=~ 0x40;
+ contents[addr] |= (contents[addr + 4] << 1) & 0x40;
+ contents[addr + 4] &=~ 0x20;
+ contents[addr + 4] |= hold & 0x20;
+ break;
+ }
+
+ case R_PPL16B:
+ case R_PPLN16B:
+ {
+ /* The most significant bit is stored in bit 28. */
+ bfd_byte hold;
+
+ hold = contents[addr + 1];
+ contents[addr + 1] &=~ 0x80;
+ contents[addr + 1] |= (contents[addr + 3] << 3) & 0x80;
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, addr,
+ val, addend);
+ contents[addr + 3] &= ~0x10;
+ contents[addr + 3] |= (contents[addr + 1] >> 3) & 0x10;
+ contents[addr + 1] &=~ 0x80;
+ contents[addr + 1] |= hold & 0x80;
+ break;
+ }
+
+ case R_PPBASE:
+ /* Parameter RAM is from 0x1000000 to 0x1000800. */
+ contents[addr] &=~ 0x3;
+ if (val >= 0x1000000 && val < 0x1000800)
+ contents[addr] |= 0x3;
+ else
+ contents[addr] |= 0x2;
+ rstat = bfd_reloc_ok;
+ break;
+
+ case R_PPLBASE:
+ /* Parameter RAM is from 0x1000000 to 0x1000800. */
+ contents[addr + 2] &= ~0xc0;
+ if (val >= 0x1000000 && val < 0x1000800)
+ contents[addr + 2] |= 0xc0;
+ else
+ contents[addr + 2] |= 0x80;
+ rstat = bfd_reloc_ok;
+ break;
+ }
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_outofrange:
+ (*_bfd_error_handler)
+ (_("%s: bad reloc address 0x%lx in section `%s'"),
+ bfd_get_filename (input_bfd),
+ (unsigned long) rel->r_vaddr,
+ bfd_get_section_name (input_bfd, input_section));
+ return false;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+ if (name == NULL)
+ return false;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+#define TIC80COFF 1 /* Customize coffcode.h */
+#undef C_AUTOARG /* Clashes with TIc80's C_UEXT */
+#undef C_LASTENT /* Clashes with TIc80's C_STATLAB */
+#include "coffcode.h"
+
+const bfd_target
+ tic80coff_vec =
+{
+ "coff-tic80", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little (arch supports both) */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE
+ };
diff --git a/bfd/coff-u68k.c b/bfd/coff-u68k.c
new file mode 100644
index 00000000000..97ea73fa9c6
--- /dev/null
+++ b/bfd/coff-u68k.c
@@ -0,0 +1,35 @@
+/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_SYM m68kcoffun_vec
+#define TARGET_NAME "coff-m68k-un"
+
+#define NAMES_HAVE_UNDERSCORE
+
+/* define this to not have multiple copy of m68k_rtype2howto
+ in the executable file */
+#define ONLY_DECLARE_RELOCS
+
+/* This magic number indicates that the names have underscores.
+ Other 68k magic numbers indicate that the names do not have
+ underscores. */
+#define BADMAG(x) ((x).f_magic != MC68KBCSMAGIC)
+
+#include "coff-m68k.c"
diff --git a/bfd/coff-w65.c b/bfd/coff-w65.c
new file mode 100644
index 00000000000..28d68c37998
--- /dev/null
+++ b/bfd/coff-w65.c
@@ -0,0 +1,445 @@
+/* BFD back-end for WDC 65816 COFF binaries.
+ Copyright 1995, 96, 1997 Free Software Foundation, Inc.
+ Written by Steve Chamberlain, <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "coff/w65.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+static reloc_howto_type howto_table[] =
+{
+ HOWTO (R_W65_ABS8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "abs8", true, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_W65_ABS16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_W65_ABS24, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs24", true, 0x00ffffff, 0x00ffffff, false),
+ HOWTO (R_W65_ABS8S8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, ">abs8", true, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_W65_ABS8S16, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "^abs8", true, 0x000000ff, 0x000000ff, false),
+ HOWTO (R_W65_ABS16S8, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, ">abs16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_W65_ABS16S16,1, 0, 16, false, 0, complain_overflow_bitfield, 0, "^abs16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_W65_PCR8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pcrel8", true, 0x000000ff, 0x000000ff, true),
+ HOWTO (R_W65_PCR16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, true),
+ HOWTO (R_W65_DP, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "dp", true, 0x000000ff, 0x000000ff, false),
+
+};
+
+
+/* Turn a howto into a reloc number */
+
+#define SELECT_RELOC(x,howto) \
+ { x.r_type = select_reloc(howto); }
+
+#define BADMAG(x) (W65BADMAG(x))
+#define W65 1 /* Customize coffcode.h */
+#define __A_MAGIC_SET__
+
+
+/* Code to swap in the reloc */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
+ dst->r_stuff[0] = 'S'; \
+ dst->r_stuff[1] = 'C';
+
+
+static int
+select_reloc (howto)
+ reloc_howto_type *howto;
+{
+ return howto->type ;
+}
+
+/* Code to turn a r_type into a howto ptr, uses the above howto table
+ */
+
+static void
+rtype2howto (internal, dst)
+ arelent *internal;
+ struct internal_reloc *dst;
+{
+ internal->howto = howto_table + dst->r_type - 1;
+}
+
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+
+
+/* Perform any necessary magic to the addend in a reloc entry */
+
+
+#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
+ cache_ptr->addend = ext_reloc.r_offset;
+
+
+#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void
+reloc_processing (relent, reloc, symbols, abfd, section)
+ arelent * relent;
+ struct internal_reloc *reloc;
+ asymbol ** symbols;
+ bfd * abfd;
+ asection * section;
+{
+ relent->address = reloc->r_vaddr;
+ rtype2howto (relent, reloc);
+
+ if (((int) reloc->r_symndx) > 0)
+ {
+ relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
+ }
+ else
+ {
+ relent->sym_ptr_ptr = (asymbol **)&(bfd_abs_symbol);
+ }
+
+
+
+ relent->addend = reloc->r_offset;
+
+ relent->address -= section->vma;
+ /* relent->section = 0;*/
+}
+
+
+static int
+h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
+ bfd *abfd;
+ asection *input_section;
+ arelent *reloc;
+ unsigned int shrink;
+ struct bfd_link_info *link_info;
+{
+ bfd_vma value;
+ bfd_vma dot;
+ bfd_vma gap;
+
+ /* The address of the thing to be relocated will have moved back by
+ the size of the shrink - but we don't change reloc->address here,
+ since we need it to know where the relocation lives in the source
+ uncooked section */
+
+ /* reloc->address -= shrink; conceptual */
+
+ bfd_vma address = reloc->address - shrink;
+
+
+ switch (reloc->howto->type)
+ {
+ case R_MOV16B2:
+ case R_JMP2:
+ shrink+=2;
+ break;
+
+ /* Thing is a move one byte */
+ case R_MOV16B1:
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ if (value >= 0xff00)
+ {
+
+ /* Change the reloc type from 16bit, possible 8 to 8bit
+ possible 16 */
+ reloc->howto = reloc->howto + 1;
+ /* The place to relc moves back by one */
+ /* This will be two bytes smaller in the long run */
+ shrink +=2 ;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+
+ break;
+ /* This is the 24 bit branch which could become an 8 bitter,
+ the relocation points to the first byte of the insn, not the
+ actual data */
+
+ case R_JMPL1:
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ dot = input_section->output_section->vma +
+ input_section->output_offset + address;
+
+ /* See if the address we're looking at within 127 bytes of where
+ we are, if so then we can use a small branch rather than the
+ jump we were going to */
+
+ gap = value - dot ;
+
+ if (-120 < (long)gap && (long)gap < 120 )
+ {
+
+ /* Change the reloc type from 24bit, possible 8 to 8bit
+ possible 32 */
+ reloc->howto = reloc->howto + 1;
+ /* This will be two bytes smaller in the long run */
+ shrink +=2 ;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+ break;
+
+ case R_JMP1:
+
+ value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
+
+ dot = input_section->output_section->vma +
+ input_section->output_offset + address;
+
+ /* See if the address we're looking at within 127 bytes of where
+ we are, if so then we can use a small branch rather than the
+ jump we were going to */
+
+ gap = value - (dot - shrink);
+
+
+ if (-120 < (long)gap && (long)gap < 120 )
+ {
+
+ /* Change the reloc type from 16bit, possible 8 to 8bit
+ possible 16 */
+ reloc->howto = reloc->howto + 1;
+ /* The place to relc moves back by one */
+
+ /* This will be two bytes smaller in the long run */
+ shrink +=2 ;
+ bfd_perform_slip(abfd, 2, input_section, address);
+ }
+ break;
+ }
+
+
+ return shrink;
+}
+
+
+/* First phase of a relaxing link */
+
+/* Reloc types
+ large small
+ R_MOV16B1 R_MOV16B2 mov.b with 16bit or 8 bit address
+ R_JMP1 R_JMP2 jmp or pcrel branch
+ R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
+ R_MOV24B1 R_MOV24B2 24 or 8 bit reloc for mov.b
+
+*/
+
+static void
+h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
+ dst_ptr)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ arelent *reloc;
+ bfd_byte *data;
+ unsigned int *src_ptr;
+ unsigned int *dst_ptr;
+{
+ unsigned int src_address = *src_ptr;
+ unsigned int dst_address = *dst_ptr;
+ asection *input_section = link_order->u.indirect.section;
+
+ switch (reloc->howto->type)
+ {
+ case R_W65_ABS8:
+ case R_W65_DP:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_put_8 (abfd, gap, data + dst_address);
+ dst_address += 1;
+ src_address += 1;
+ }
+ break;
+
+ case R_W65_ABS8S8:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ gap >>= 8;
+ bfd_put_8 (abfd, gap, data + dst_address);
+ dst_address += 1;
+ src_address += 1;
+ }
+ break;
+
+ case R_W65_ABS8S16:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ gap >>=16;
+ bfd_put_8 (abfd, gap, data + dst_address);
+ dst_address += 1;
+ src_address += 1;
+ }
+ break;
+
+ case R_W65_ABS16:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+
+ bfd_put_16 (abfd, gap, data + dst_address);
+ dst_address += 2;
+ src_address += 2;
+ }
+ break;
+ case R_W65_ABS16S8:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ gap >>= 8;
+ bfd_put_16 (abfd, gap, data + dst_address);
+ dst_address += 2;
+ src_address += 2;
+ }
+ break;
+ case R_W65_ABS16S16:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ gap >>= 16;
+ bfd_put_16 (abfd, gap, data + dst_address);
+ dst_address += 2;
+ src_address += 2;
+ }
+ break;
+
+ case R_W65_ABS24:
+ {
+ unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_put_16 (abfd, gap, data + dst_address);
+ bfd_put_8 (abfd, gap>>16, data+dst_address+2);
+ dst_address += 3;
+ src_address += 3;
+ }
+ break;
+
+ case R_W65_PCR8:
+ {
+ int gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_vma dot = link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma;
+
+ gap -= dot + 1;
+ if (gap < -128 || gap > 127) {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort();
+ }
+ bfd_put_8 (abfd, gap, data + dst_address);
+ dst_address += 1;
+ src_address += 1;
+ }
+ break;
+
+ case R_W65_PCR16:
+ {
+ bfd_vma gap = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_vma dot = link_order->offset
+ + dst_address
+ + link_order->u.indirect.section->output_section->vma;
+
+
+ /* This wraps within the page, so ignore the relativeness, look at the
+ high part */
+ if ((gap & 0xf0000) != (dot & 0xf0000)) {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort();
+ }
+
+ gap -= dot + 2;
+ bfd_put_16 (abfd, gap, data + dst_address);
+ dst_address += 2;
+ src_address += 2;
+ }
+ break;
+ default:
+ printf(_("ignoring reloc %s\n"), reloc->howto->name);
+ break;
+
+ }
+ *src_ptr = src_address;
+ *dst_ptr = dst_address;
+
+}
+
+#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
+#define coff_reloc16_estimate h8300_reloc16_estimate
+
+#include "coffcode.h"
+
+
+#undef coff_bfd_get_relocated_section_contents
+#undef coff_bfd_relax_section
+#define coff_bfd_get_relocated_section_contents \
+ bfd_coff_reloc16_get_relocated_section_contents
+#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
+
+
+
+bfd_target w65_vec =
+{
+ "coff-w65", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading char */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-we32k.c b/bfd/coff-we32k.c
new file mode 100644
index 00000000000..826bbe330db
--- /dev/null
+++ b/bfd/coff-we32k.c
@@ -0,0 +1,109 @@
+/* BFD back-end for we32k COFF files.
+ Copyright (C) 1992, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cs.widener.edu).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/we32k.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+static reloc_howto_type howto_table[] =
+{
+ {0},
+ {1},
+ {2},
+ {3},
+ {4},
+ {5},
+ HOWTO(R_DIR32, 0, 2, 32, false, 0,complain_overflow_bitfield, 0, "dir32", true, 0xffffffff,0xffffffff, false),
+ {7},
+ {010},
+ {011},
+ {012},
+ {013},
+ {014},
+ {015},
+ {016},
+ HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
+ HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
+ HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
+ HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
+};
+
+/* Turn a howto into a reloc nunmber */
+
+#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
+#define BADMAG(x) WE32KBADMAG(x)
+#define WE32K 1
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ (cache_ptr)->howto = howto_table + (dst)->r_type;
+
+#include "coffcode.h"
+
+#define coff_write_armap bsd_write_armap
+
+const bfd_target we32kcoff_vec =
+{
+ "coff-we32k", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coff-z8k.c b/bfd/coff-z8k.c
new file mode 100644
index 00000000000..04049e89c28
--- /dev/null
+++ b/bfd/coff-z8k.c
@@ -0,0 +1,280 @@
+/* BFD back-end for Zilog Z800n COFF binaries.
+ Copyright 1992, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+ Written by Steve Chamberlain, <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "coff/z8k.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+
+static reloc_howto_type r_imm32 =
+HOWTO (R_IMM32, 0, 1, 32, false, 0,
+ complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
+ 0xffffffff, false);
+
+static reloc_howto_type r_imm4l =
+HOWTO (R_IMM4L, 0, 1, 4, false, 0,
+ complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);
+
+static reloc_howto_type r_da =
+HOWTO (R_IMM16, 0, 1, 16, false, 0,
+ complain_overflow_bitfield, 0, "r_da", true, 0x0000ffff, 0x0000ffff,
+ false);
+
+static reloc_howto_type r_imm8 =
+HOWTO (R_IMM8, 0, 1, 8, false, 0,
+ complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,
+ false);
+
+static reloc_howto_type r_jr =
+HOWTO (R_JR, 0, 1, 8, true, 0, complain_overflow_signed, 0,
+ "r_jr", true, 0, 0, true);
+
+/* Turn a howto into a reloc number */
+
+static int
+coff_z8k_select_reloc (howto)
+ reloc_howto_type *howto;
+{
+ return howto->type;
+}
+
+#define SELECT_RELOC(x,howto) x.r_type = coff_z8k_select_reloc(howto)
+
+
+#define BADMAG(x) Z8KBADMAG(x)
+#define Z8K 1 /* Customize coffcode.h */
+#define __A_MAGIC_SET__
+
+
+
+/* Code to swap in the reloc */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
+ dst->r_stuff[0] = 'S'; \
+ dst->r_stuff[1] = 'C';
+
+/* Code to turn a r_type into a howto ptr, uses the above howto table
+ */
+
+static void
+rtype2howto (internal, dst)
+ arelent * internal;
+ struct internal_reloc *dst;
+{
+ switch (dst->r_type)
+ {
+ default:
+ abort ();
+ break;
+ case R_IMM8:
+ internal->howto = &r_imm8;
+ break;
+ case R_IMM16:
+ internal->howto = &r_da;
+ break;
+ case R_JR:
+ internal->howto = &r_jr;
+ break;
+ case R_IMM32:
+ internal->howto = &r_imm32;
+ break;
+ case R_IMM4L:
+ internal->howto = &r_imm4l;
+ break;
+ }
+}
+
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+
+
+/* Perform any necessary magic to the addend in a reloc entry */
+
+
+#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
+ cache_ptr->addend = ext_reloc.r_offset;
+
+
+#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
+ reloc_processing(relent, reloc, symbols, abfd, section)
+
+static void
+reloc_processing (relent, reloc, symbols, abfd, section)
+ arelent * relent;
+ struct internal_reloc *reloc;
+ asymbol ** symbols;
+ bfd * abfd;
+ asection * section;
+{
+ relent->address = reloc->r_vaddr;
+ rtype2howto (relent, reloc);
+
+ if (reloc->r_symndx > 0)
+ {
+ relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
+ }
+ else
+ {
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+
+
+ relent->addend = reloc->r_offset;
+ relent->address -= section->vma;
+}
+
+static void
+extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
+ bfd *in_abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ arelent *reloc;
+ bfd_byte *data;
+ unsigned int *src_ptr;
+ unsigned int *dst_ptr;
+{
+ asection *input_section = link_order->u.indirect.section;
+
+ switch (reloc->howto->type)
+ {
+ case R_IMM8:
+ bfd_put_8 (in_abfd,
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ data + *dst_ptr);
+ (*dst_ptr) += 1;
+ (*src_ptr) += 1;
+ break;
+
+ case R_IMM32:
+ bfd_put_32 (in_abfd,
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ data + *dst_ptr);
+ (*dst_ptr) += 4;
+ (*src_ptr) += 4;
+ break;
+
+ case R_IMM4L:
+ bfd_put_8 (in_abfd,
+ ((bfd_get_8 (in_abfd, data + *dst_ptr) & 0xf0)
+ | (0x0f
+ & bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section))),
+ data + *dst_ptr);
+ (*dst_ptr) += 1;
+ (*src_ptr) += 1;
+ break;
+
+ case R_IMM16:
+ bfd_put_16 (in_abfd,
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+ data + *dst_ptr);
+ (*dst_ptr) += 2;
+ (*src_ptr) += 2;
+ break;
+
+ case R_JR:
+ {
+ bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
+ input_section);
+ bfd_vma dot = (link_order->offset
+ + *dst_ptr
+ + input_section->output_section->vma);
+ int gap = dst - dot - 1;/* -1 since were in the odd byte of the
+ word and the pc's been incremented */
+
+ if (gap & 1)
+ abort ();
+ gap /= 2;
+ if (gap > 128 || gap < -128)
+ {
+ if (! ((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
+ reloc->howto->name, reloc->addend, input_section->owner,
+ input_section, reloc->address)))
+ abort ();
+ }
+ bfd_put_8 (in_abfd, gap, data + *dst_ptr);
+ (*dst_ptr)++;
+ (*src_ptr)++;
+ break;
+ }
+ default:
+ abort ();
+ }
+}
+
+#define coff_reloc16_extra_cases extra_case
+
+#include "coffcode.h"
+
+
+#undef coff_bfd_get_relocated_section_contents
+#undef coff_bfd_relax_section
+#define coff_bfd_get_relocated_section_contents \
+ bfd_coff_reloc16_get_relocated_section_contents
+#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
+
+const bfd_target z8kcoff_vec =
+{
+ "coff-z8k", /* name */
+ bfd_target_coff_flavour,
+ BFD_ENDIAN_BIG, /* data byte order is big */
+ BFD_ENDIAN_BIG, /* header byte order is big */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading symbol underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
new file mode 100644
index 00000000000..383719c00c9
--- /dev/null
+++ b/bfd/coffcode.h
@@ -0,0 +1,4318 @@
+/* Support for the generic parts of most COFF variants, for BFD.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+Most of this hacked by Steve Chamberlain,
+ sac@cygnus.com
+*/
+/*
+
+SECTION
+ coff backends
+
+ BFD supports a number of different flavours of coff format.
+ The major differences between formats are the sizes and
+ alignments of fields in structures on disk, and the occasional
+ extra field.
+
+ Coff in all its varieties is implemented with a few common
+ files and a number of implementation specific files. For
+ example, The 88k bcs coff format is implemented in the file
+ @file{coff-m88k.c}. This file @code{#include}s
+ @file{coff/m88k.h} which defines the external structure of the
+ coff format for the 88k, and @file{coff/internal.h} which
+ defines the internal structure. @file{coff-m88k.c} also
+ defines the relocations used by the 88k format
+ @xref{Relocations}.
+
+ The Intel i960 processor version of coff is implemented in
+ @file{coff-i960.c}. This file has the same structure as
+ @file{coff-m88k.c}, except that it includes @file{coff/i960.h}
+ rather than @file{coff-m88k.h}.
+
+SUBSECTION
+ Porting to a new version of coff
+
+ The recommended method is to select from the existing
+ implementations the version of coff which is most like the one
+ you want to use. For example, we'll say that i386 coff is
+ the one you select, and that your coff flavour is called foo.
+ Copy @file{i386coff.c} to @file{foocoff.c}, copy
+ @file{../include/coff/i386.h} to @file{../include/coff/foo.h},
+ and add the lines to @file{targets.c} and @file{Makefile.in}
+ so that your new back end is used. Alter the shapes of the
+ structures in @file{../include/coff/foo.h} so that they match
+ what you need. You will probably also have to add
+ @code{#ifdef}s to the code in @file{coff/internal.h} and
+ @file{coffcode.h} if your version of coff is too wild.
+
+ You can verify that your new BFD backend works quite simply by
+ building @file{objdump} from the @file{binutils} directory,
+ and making sure that its version of what's going on and your
+ host system's idea (assuming it has the pretty standard coff
+ dump utility, usually called @code{att-dump} or just
+ @code{dump}) are the same. Then clean up your code, and send
+ what you've done to Cygnus. Then your stuff will be in the
+ next release, and you won't have to keep integrating it.
+
+SUBSECTION
+ How the coff backend works
+
+SUBSUBSECTION
+ File layout
+
+ The Coff backend is split into generic routines that are
+ applicable to any Coff target and routines that are specific
+ to a particular target. The target-specific routines are
+ further split into ones which are basically the same for all
+ Coff targets except that they use the external symbol format
+ or use different values for certain constants.
+
+ The generic routines are in @file{coffgen.c}. These routines
+ work for any Coff target. They use some hooks into the target
+ specific code; the hooks are in a @code{bfd_coff_backend_data}
+ structure, one of which exists for each target.
+
+ The essentially similar target-specific routines are in
+ @file{coffcode.h}. This header file includes executable C code.
+ The various Coff targets first include the appropriate Coff
+ header file, make any special defines that are needed, and
+ then include @file{coffcode.h}.
+
+ Some of the Coff targets then also have additional routines in
+ the target source file itself.
+
+ For example, @file{coff-i960.c} includes
+ @file{coff/internal.h} and @file{coff/i960.h}. It then
+ defines a few constants, such as @code{I960}, and includes
+ @file{coffcode.h}. Since the i960 has complex relocation
+ types, @file{coff-i960.c} also includes some code to
+ manipulate the i960 relocs. This code is not in
+ @file{coffcode.h} because it would not be used by any other
+ target.
+
+SUBSUBSECTION
+ Bit twiddling
+
+ Each flavour of coff supported in BFD has its own header file
+ describing the external layout of the structures. There is also
+ an internal description of the coff layout, in
+ @file{coff/internal.h}. A major function of the
+ coff backend is swapping the bytes and twiddling the bits to
+ translate the external form of the structures into the normal
+ internal form. This is all performed in the
+ @code{bfd_swap}_@i{thing}_@i{direction} routines. Some
+ elements are different sizes between different versions of
+ coff; it is the duty of the coff version specific include file
+ to override the definitions of various packing routines in
+ @file{coffcode.h}. E.g., the size of line number entry in coff is
+ sometimes 16 bits, and sometimes 32 bits. @code{#define}ing
+ @code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the
+ correct one. No doubt, some day someone will find a version of
+ coff which has a varying field size not catered to at the
+ moment. To port BFD, that person will have to add more @code{#defines}.
+ Three of the bit twiddling routines are exported to
+ @code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in}
+ and @code{coff_swap_linno_in}. @code{GDB} reads the symbol
+ table on its own, but uses BFD to fix things up. More of the
+ bit twiddlers are exported for @code{gas};
+ @code{coff_swap_aux_out}, @code{coff_swap_sym_out},
+ @code{coff_swap_lineno_out}, @code{coff_swap_reloc_out},
+ @code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out},
+ @code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track
+ of all the symbol table and reloc drudgery itself, thereby
+ saving the internal BFD overhead, but uses BFD to swap things
+ on the way out, making cross ports much safer. Doing so also
+ allows BFD (and thus the linker) to use the same header files
+ as @code{gas}, which makes one avenue to disaster disappear.
+
+SUBSUBSECTION
+ Symbol reading
+
+ The simple canonical form for symbols used by BFD is not rich
+ enough to keep all the information available in a coff symbol
+ table. The back end gets around this problem by keeping the original
+ symbol table around, "behind the scenes".
+
+ When a symbol table is requested (through a call to
+ @code{bfd_canonicalize_symtab}), a request gets through to
+ @code{coff_get_normalized_symtab}. This reads the symbol table from
+ the coff file and swaps all the structures inside into the
+ internal form. It also fixes up all the pointers in the table
+ (represented in the file by offsets from the first symbol in
+ the table) into physical pointers to elements in the new
+ internal table. This involves some work since the meanings of
+ fields change depending upon context: a field that is a
+ pointer to another structure in the symbol table at one moment
+ may be the size in bytes of a structure at the next. Another
+ pass is made over the table. All symbols which mark file names
+ (<<C_FILE>> symbols) are modified so that the internal
+ string points to the value in the auxent (the real filename)
+ rather than the normal text associated with the symbol
+ (@code{".file"}).
+
+ At this time the symbol names are moved around. Coff stores
+ all symbols less than nine characters long physically
+ within the symbol table; longer strings are kept at the end of
+ the file in the string table. This pass moves all strings
+ into memory and replaces them with pointers to the strings.
+
+
+ The symbol table is massaged once again, this time to create
+ the canonical table used by the BFD application. Each symbol
+ is inspected in turn, and a decision made (using the
+ @code{sclass} field) about the various flags to set in the
+ @code{asymbol}. @xref{Symbols}. The generated canonical table
+ shares strings with the hidden internal symbol table.
+
+ Any linenumbers are read from the coff file too, and attached
+ to the symbols which own the functions the linenumbers belong to.
+
+SUBSUBSECTION
+ Symbol writing
+
+ Writing a symbol to a coff file which didn't come from a coff
+ file will lose any debugging information. The @code{asymbol}
+ structure remembers the BFD from which the symbol was taken, and on
+ output the back end makes sure that the same destination target as
+ source target is present.
+
+ When the symbols have come from a coff file then all the
+ debugging information is preserved.
+
+ Symbol tables are provided for writing to the back end in a
+ vector of pointers to pointers. This allows applications like
+ the linker to accumulate and output large symbol tables
+ without having to do too much byte copying.
+
+ This function runs through the provided symbol table and
+ patches each symbol marked as a file place holder
+ (@code{C_FILE}) to point to the next file place holder in the
+ list. It also marks each @code{offset} field in the list with
+ the offset from the first symbol of the current symbol.
+
+ Another function of this procedure is to turn the canonical
+ value form of BFD into the form used by coff. Internally, BFD
+ expects symbol values to be offsets from a section base; so a
+ symbol physically at 0x120, but in a section starting at
+ 0x100, would have the value 0x20. Coff expects symbols to
+ contain their final value, so symbols have their values
+ changed at this point to reflect their sum with their owning
+ section. This transformation uses the
+ <<output_section>> field of the @code{asymbol}'s
+ @code{asection} @xref{Sections}.
+
+ o <<coff_mangle_symbols>>
+
+ This routine runs though the provided symbol table and uses
+ the offsets generated by the previous pass and the pointers
+ generated when the symbol table was read in to create the
+ structured hierachy required by coff. It changes each pointer
+ to a symbol into the index into the symbol table of the asymbol.
+
+ o <<coff_write_symbols>>
+
+ This routine runs through the symbol table and patches up the
+ symbols from their internal form into the coff way, calls the
+ bit twiddlers, and writes out the table to the file.
+
+*/
+
+/*
+INTERNAL_DEFINITION
+ coff_symbol_type
+
+DESCRIPTION
+ The hidden information for an <<asymbol>> is described in a
+ <<combined_entry_type>>:
+
+CODE_FRAGMENT
+.
+.typedef struct coff_ptr_struct
+.{
+.
+. {* Remembers the offset from the first symbol in the file for
+. this symbol. Generated by coff_renumber_symbols. *}
+.unsigned int offset;
+.
+. {* Should the value of this symbol be renumbered. Used for
+. XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. *}
+.unsigned int fix_value : 1;
+.
+. {* Should the tag field of this symbol be renumbered.
+. Created by coff_pointerize_aux. *}
+.unsigned int fix_tag : 1;
+.
+. {* Should the endidx field of this symbol be renumbered.
+. Created by coff_pointerize_aux. *}
+.unsigned int fix_end : 1;
+.
+. {* Should the x_csect.x_scnlen field be renumbered.
+. Created by coff_pointerize_aux. *}
+.unsigned int fix_scnlen : 1;
+.
+. {* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
+. index into the line number entries. Set by
+. coff_slurp_symbol_table. *}
+.unsigned int fix_line : 1;
+.
+. {* The container for the symbol structure as read and translated
+. from the file. *}
+.
+.union {
+. union internal_auxent auxent;
+. struct internal_syment syment;
+. } u;
+.} combined_entry_type;
+.
+.
+.{* Each canonical asymbol really looks like this: *}
+.
+.typedef struct coff_symbol_struct
+.{
+. {* The actual symbol which the rest of BFD works with *}
+.asymbol symbol;
+.
+. {* A pointer to the hidden information for this symbol *}
+.combined_entry_type *native;
+.
+. {* A pointer to the linenumber information for this symbol *}
+.struct lineno_cache_entry *lineno;
+.
+. {* Have the line numbers been relocated yet ? *}
+.boolean done_lineno;
+.} coff_symbol_type;
+
+
+*/
+
+#ifdef COFF_WITH_PE
+#include "peicode.h"
+#else
+#include "coffswap.h"
+#endif
+
+#define STRING_SIZE_SIZE (4)
+
+static long sec_to_styp_flags PARAMS ((const char *, flagword));
+static flagword styp_to_sec_flags PARAMS ((bfd *, PTR, const char *));
+static boolean coff_bad_format_hook PARAMS ((bfd *, PTR));
+static boolean coff_new_section_hook PARAMS ((bfd *, asection *));
+static boolean coff_set_arch_mach_hook PARAMS ((bfd *, PTR));
+static boolean coff_write_relocs PARAMS ((bfd *, int));
+static boolean coff_set_flags
+ PARAMS ((bfd *, unsigned int *, unsigned short *));
+static boolean coff_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+static boolean coff_compute_section_file_positions PARAMS ((bfd *));
+static boolean coff_write_object_contents PARAMS ((bfd *));
+static boolean coff_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static PTR buy_and_read PARAMS ((bfd *, file_ptr, int, size_t));
+static boolean coff_slurp_line_table PARAMS ((bfd *, asection *));
+static boolean coff_slurp_symbol_table PARAMS ((bfd *));
+static boolean coff_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **));
+static long coff_canonicalize_reloc
+ PARAMS ((bfd *, asection *, arelent **, asymbol **));
+#ifndef coff_mkobject_hook
+static PTR coff_mkobject_hook PARAMS ((bfd *, PTR, PTR));
+#endif
+
+/* void warning(); */
+
+/*
+ * Return a word with STYP_* (scnhdr.s_flags) flags set to represent the
+ * incoming SEC_* flags. The inverse of this function is styp_to_sec_flags().
+ * NOTE: If you add to/change this routine, you should mirror the changes
+ * in styp_to_sec_flags().
+ */
+static long
+sec_to_styp_flags (sec_name, sec_flags)
+ CONST char *sec_name;
+ flagword sec_flags;
+{
+ long styp_flags = 0;
+
+ if (!strcmp (sec_name, _TEXT))
+ {
+ styp_flags = STYP_TEXT;
+ }
+ else if (!strcmp (sec_name, _DATA))
+ {
+ styp_flags = STYP_DATA;
+ }
+ else if (!strcmp (sec_name, _BSS))
+ {
+ styp_flags = STYP_BSS;
+#ifdef _COMMENT
+ }
+ else if (!strcmp (sec_name, _COMMENT))
+ {
+ styp_flags = STYP_INFO;
+#endif /* _COMMENT */
+#ifdef _LIB
+ }
+ else if (!strcmp (sec_name, _LIB))
+ {
+ styp_flags = STYP_LIB;
+#endif /* _LIB */
+#ifdef _LIT
+ }
+ else if (!strcmp (sec_name, _LIT))
+ {
+ styp_flags = STYP_LIT;
+#endif /* _LIT */
+ }
+ else if (!strcmp (sec_name, ".debug"))
+ {
+#ifdef STYP_DEBUG
+ styp_flags = STYP_DEBUG;
+#else
+ styp_flags = STYP_INFO;
+#endif
+ }
+ else if (!strncmp (sec_name, ".stab", 5))
+ {
+ styp_flags = STYP_INFO;
+ }
+#ifdef COFF_WITH_PE
+ else if (!strcmp (sec_name, ".edata"))
+ {
+ styp_flags = STYP_DATA;
+ }
+#endif
+#ifdef RS6000COFF_C
+ else if (!strcmp (sec_name, _PAD))
+ {
+ styp_flags = STYP_PAD;
+ }
+ else if (!strcmp (sec_name, _LOADER))
+ {
+ styp_flags = STYP_LOADER;
+ }
+#endif
+ /* Try and figure out what it should be */
+ else if (sec_flags & SEC_CODE)
+ {
+ styp_flags = STYP_TEXT;
+ }
+ else if (sec_flags & SEC_DATA)
+ {
+ styp_flags = STYP_DATA;
+ }
+ else if (sec_flags & SEC_READONLY)
+ {
+#ifdef STYP_LIT /* 29k readonly text/data section */
+ styp_flags = STYP_LIT;
+#else
+ styp_flags = STYP_TEXT;
+#endif /* STYP_LIT */
+ }
+ else if (sec_flags & SEC_LOAD)
+ {
+ styp_flags = STYP_TEXT;
+ }
+ else if (sec_flags & SEC_ALLOC)
+ {
+ styp_flags = STYP_BSS;
+ }
+
+#ifdef STYP_NOLOAD
+ if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
+ styp_flags |= STYP_NOLOAD;
+#endif
+
+#ifdef COFF_WITH_PE
+ if (sec_flags & SEC_LINK_ONCE)
+ styp_flags |= IMAGE_SCN_LNK_COMDAT;
+#endif
+
+ return (styp_flags);
+}
+/*
+ * Return a word with SEC_* flags set to represent the incoming
+ * STYP_* flags (from scnhdr.s_flags). The inverse of this
+ * function is sec_to_styp_flags().
+ * NOTE: If you add to/change this routine, you should mirror the changes
+ * in sec_to_styp_flags().
+ */
+static flagword
+styp_to_sec_flags (abfd, hdr, name)
+ bfd *abfd;
+ PTR hdr;
+ const char *name;
+{
+ struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
+ long styp_flags = internal_s->s_flags;
+ flagword sec_flags = 0;
+
+#ifdef STYP_NOLOAD
+ if (styp_flags & STYP_NOLOAD)
+ {
+ sec_flags |= SEC_NEVER_LOAD;
+ }
+#endif /* STYP_NOLOAD */
+
+ /* For 386 COFF, at least, an unloadable text or data section is
+ actually a shared library section. */
+ if (styp_flags & STYP_TEXT)
+ {
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
+ else
+ sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
+ }
+ else if (styp_flags & STYP_DATA)
+ {
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
+ else
+ sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
+ }
+ else if (styp_flags & STYP_BSS)
+ {
+#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
+ else
+#endif
+ sec_flags |= SEC_ALLOC;
+ }
+ else if (styp_flags & STYP_INFO)
+ {
+ /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
+ defined. coff_compute_section_file_positions uses
+ COFF_PAGE_SIZE to ensure that the low order bits of the
+ section VMA and the file offset match. If we don't know
+ COFF_PAGE_SIZE, we can't ensure the correct correspondence,
+ and demand page loading of the file will fail. */
+#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
+ sec_flags |= SEC_DEBUGGING;
+#endif
+ }
+ else if (styp_flags & STYP_PAD)
+ {
+ sec_flags = 0;
+ }
+ else if (strcmp (name, _TEXT) == 0)
+ {
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
+ else
+ sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
+ }
+ else if (strcmp (name, _DATA) == 0)
+ {
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
+ else
+ sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
+ }
+ else if (strcmp (name, _BSS) == 0)
+ {
+#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
+ else
+#endif
+ sec_flags |= SEC_ALLOC;
+ }
+ else if (strcmp (name, ".debug") == 0
+#ifdef _COMMENT
+ || strcmp (name, _COMMENT) == 0
+#endif
+ || strncmp (name, ".stab", 5) == 0)
+ {
+#ifdef COFF_PAGE_SIZE
+ sec_flags |= SEC_DEBUGGING;
+#endif
+ }
+#ifdef _LIB
+ else if (strcmp (name, _LIB) == 0)
+ ;
+#endif
+#ifdef _LIT
+ else if (strcmp (name, _LIT) == 0)
+ {
+ sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
+ }
+#endif
+ else
+ {
+ sec_flags |= SEC_ALLOC | SEC_LOAD;
+ }
+
+#ifdef STYP_LIT /* A29k readonly text/data section type */
+ if ((styp_flags & STYP_LIT) == STYP_LIT)
+ {
+ sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
+ }
+#endif /* STYP_LIT */
+#ifdef STYP_OTHER_LOAD /* Other loaded sections */
+ if (styp_flags & STYP_OTHER_LOAD)
+ {
+ sec_flags = (SEC_LOAD | SEC_ALLOC);
+ }
+#endif /* STYP_SDATA */
+
+#ifdef COFF_WITH_PE
+ if (styp_flags & IMAGE_SCN_LNK_REMOVE)
+ sec_flags |= SEC_EXCLUDE;
+
+ if (styp_flags & IMAGE_SCN_LNK_COMDAT)
+ {
+ sec_flags |= SEC_LINK_ONCE;
+
+ /* Unfortunately, the PE format stores essential information in
+ the symbol table, of all places. We need to extract that
+ information now, so that objdump and the linker will know how
+ to handle the section without worrying about the symbols. We
+ can't call slurp_symtab, because the linker doesn't want the
+ swapped symbols. */
+
+ if (_bfd_coff_get_external_symbols (abfd))
+ {
+ bfd_byte *esym, *esymend;
+
+ esym = (bfd_byte *) obj_coff_external_syms (abfd);
+ esymend = esym + obj_raw_syment_count (abfd) * SYMESZ;
+
+ while (esym < esymend)
+ {
+ struct internal_syment isym;
+
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym);
+
+ if (sizeof (internal_s->s_name) > SYMNMLEN)
+ {
+ /* This case implies that the matching symbol name
+ will be in the string table. */
+ abort ();
+ }
+
+ if (isym.n_sclass == C_STAT
+ && isym.n_type == T_NULL
+ && isym.n_numaux == 1)
+ {
+ char buf[SYMNMLEN + 1];
+ const char *symname;
+
+ symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
+ if (symname == NULL)
+ abort ();
+
+ if (strcmp (name, symname) == 0)
+ {
+ union internal_auxent aux;
+
+ /* This is the section symbol. */
+
+ bfd_coff_swap_aux_in (abfd, (PTR) (esym + SYMESZ),
+ isym.n_type, isym.n_sclass,
+ 0, isym.n_numaux, (PTR) &aux);
+
+ switch (aux.x_scn.x_comdat)
+ {
+ case IMAGE_COMDAT_SELECT_NODUPLICATES:
+ sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
+ break;
+
+ default:
+ case IMAGE_COMDAT_SELECT_ANY:
+ sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
+ break;
+
+ case IMAGE_COMDAT_SELECT_SAME_SIZE:
+ sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
+ break;
+
+ case IMAGE_COMDAT_SELECT_EXACT_MATCH:
+ sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
+ break;
+
+ case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
+ /* FIXME: This is not currently implemented. */
+ sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
+ break;
+ }
+
+ break;
+ }
+ }
+
+ esym += (isym.n_numaux + 1) * SYMESZ;
+ }
+ }
+ }
+#endif
+
+ return (sec_flags);
+}
+
+#define get_index(symbol) ((symbol)->udata.i)
+
+/*
+INTERNAL_DEFINITION
+ bfd_coff_backend_data
+
+CODE_FRAGMENT
+
+Special entry points for gdb to swap in coff symbol table parts:
+.typedef struct
+.{
+. void (*_bfd_coff_swap_aux_in) PARAMS ((
+. bfd *abfd,
+. PTR ext,
+. int type,
+. int class,
+. int indaux,
+. int numaux,
+. PTR in));
+.
+. void (*_bfd_coff_swap_sym_in) PARAMS ((
+. bfd *abfd ,
+. PTR ext,
+. PTR in));
+.
+. void (*_bfd_coff_swap_lineno_in) PARAMS ((
+. bfd *abfd,
+. PTR ext,
+. PTR in));
+.
+
+Special entry points for gas to swap out coff parts:
+
+. unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
+. bfd *abfd,
+. PTR in,
+. int type,
+. int class,
+. int indaux,
+. int numaux,
+. PTR ext));
+.
+. unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
+. bfd *abfd,
+. PTR in,
+. PTR ext));
+.
+. unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
+. bfd *abfd,
+. PTR in,
+. PTR ext));
+.
+. unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
+. bfd *abfd,
+. PTR src,
+. PTR dst));
+.
+. unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
+. bfd *abfd,
+. PTR in,
+. PTR out));
+.
+. unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
+. bfd *abfd,
+. PTR in,
+. PTR out));
+.
+. unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
+. bfd *abfd,
+. PTR in,
+. PTR out));
+.
+
+Special entry points for generic COFF routines to call target
+dependent COFF routines:
+
+. unsigned int _bfd_filhsz;
+. unsigned int _bfd_aoutsz;
+. unsigned int _bfd_scnhsz;
+. unsigned int _bfd_symesz;
+. unsigned int _bfd_auxesz;
+. unsigned int _bfd_relsz;
+. unsigned int _bfd_linesz;
+. boolean _bfd_coff_long_filenames;
+. boolean _bfd_coff_long_section_names;
+. unsigned int _bfd_coff_default_section_alignment_power;
+. void (*_bfd_coff_swap_filehdr_in) PARAMS ((
+. bfd *abfd,
+. PTR ext,
+. PTR in));
+. void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
+. bfd *abfd,
+. PTR ext,
+. PTR in));
+. void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
+. bfd *abfd,
+. PTR ext,
+. PTR in));
+. void (*_bfd_coff_swap_reloc_in) PARAMS ((
+. bfd *abfd,
+. PTR ext,
+. PTR in));
+. boolean (*_bfd_coff_bad_format_hook) PARAMS ((
+. bfd *abfd,
+. PTR internal_filehdr));
+. boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
+. bfd *abfd,
+. PTR internal_filehdr));
+. PTR (*_bfd_coff_mkobject_hook) PARAMS ((
+. bfd *abfd,
+. PTR internal_filehdr,
+. PTR internal_aouthdr));
+. flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
+. bfd *abfd,
+. PTR internal_scnhdr,
+. const char *name));
+. void (*_bfd_set_alignment_hook) PARAMS ((
+. bfd *abfd,
+. asection *sec,
+. PTR internal_scnhdr));
+. boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
+. bfd *abfd));
+. boolean (*_bfd_coff_symname_in_debug) PARAMS ((
+. bfd *abfd,
+. struct internal_syment *sym));
+. boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
+. bfd *abfd,
+. combined_entry_type *table_base,
+. combined_entry_type *symbol,
+. unsigned int indaux,
+. combined_entry_type *aux));
+. boolean (*_bfd_coff_print_aux) PARAMS ((
+. bfd *abfd,
+. FILE *file,
+. combined_entry_type *table_base,
+. combined_entry_type *symbol,
+. combined_entry_type *aux,
+. unsigned int indaux));
+. void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
+. bfd *abfd,
+. struct bfd_link_info *link_info,
+. struct bfd_link_order *link_order,
+. arelent *reloc,
+. bfd_byte *data,
+. unsigned int *src_ptr,
+. unsigned int *dst_ptr));
+. int (*_bfd_coff_reloc16_estimate) PARAMS ((
+. bfd *abfd,
+. asection *input_section,
+. arelent *r,
+. unsigned int shrink,
+. struct bfd_link_info *link_info));
+. boolean (*_bfd_coff_sym_is_global) PARAMS ((
+. bfd *abfd,
+. struct internal_syment *));
+. boolean (*_bfd_coff_compute_section_file_positions) PARAMS ((
+. bfd *abfd));
+. boolean (*_bfd_coff_start_final_link) PARAMS ((
+. bfd *output_bfd,
+. struct bfd_link_info *info));
+. boolean (*_bfd_coff_relocate_section) PARAMS ((
+. bfd *output_bfd,
+. struct bfd_link_info *info,
+. bfd *input_bfd,
+. asection *input_section,
+. bfd_byte *contents,
+. struct internal_reloc *relocs,
+. struct internal_syment *syms,
+. asection **sections));
+. reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
+. bfd *abfd,
+. asection *sec,
+. struct internal_reloc *rel,
+. struct coff_link_hash_entry *h,
+. struct internal_syment *sym,
+. bfd_vma *addendp));
+. boolean (*_bfd_coff_adjust_symndx) PARAMS ((
+. bfd *obfd,
+. struct bfd_link_info *info,
+. bfd *ibfd,
+. asection *sec,
+. struct internal_reloc *reloc,
+. boolean *adjustedp));
+. boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
+. struct bfd_link_info *info,
+. bfd *abfd,
+. const char *name,
+. flagword flags,
+. asection *section,
+. bfd_vma value,
+. const char *string,
+. boolean copy,
+. boolean collect,
+. struct bfd_link_hash_entry **hashp));
+.
+. boolean (*_bfd_coff_link_output_has_begun) PARAMS ((
+. bfd * abfd,
+. struct coff_final_link_info * pfinfo));
+. boolean (*_bfd_coff_final_link_postscript) PARAMS ((
+. bfd * abfd,
+. struct coff_final_link_info * pfinfo));
+.
+.} bfd_coff_backend_data;
+.
+.#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
+.
+.#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
+. ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
+.
+.#define bfd_coff_swap_sym_in(a,e,i) \
+. ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
+.
+.#define bfd_coff_swap_lineno_in(a,e,i) \
+. ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
+.
+.#define bfd_coff_swap_reloc_out(abfd, i, o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
+.
+.#define bfd_coff_swap_lineno_out(abfd, i, o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
+.
+.#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
+. ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
+.
+.#define bfd_coff_swap_sym_out(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
+.
+.#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
+.
+.#define bfd_coff_swap_filehdr_out(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
+.
+.#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
+.
+.#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
+.#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
+.#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
+.#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
+.#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
+.#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
+.#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
+.#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
+.#define bfd_coff_long_section_names(abfd) \
+. (coff_backend_info (abfd)->_bfd_coff_long_section_names)
+.#define bfd_coff_default_section_alignment_power(abfd) \
+. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
+.#define bfd_coff_swap_filehdr_in(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
+.
+.#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
+.
+.#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
+.
+.#define bfd_coff_swap_reloc_in(abfd, i, o) \
+. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
+.
+.#define bfd_coff_bad_format_hook(abfd, filehdr) \
+. ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
+.
+.#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
+. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
+.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
+. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
+.
+.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
+. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
+.
+.#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
+. ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
+.
+.#define bfd_coff_slurp_symbol_table(abfd)\
+. ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
+.
+.#define bfd_coff_symname_in_debug(abfd, sym)\
+. ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
+.
+.#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
+. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
+. (abfd, file, base, symbol, aux, indaux))
+.
+.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
+. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
+. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
+.
+.#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
+. ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
+. (abfd, section, reloc, shrink, link_info))
+.
+.#define bfd_coff_sym_is_global(abfd, sym)\
+. ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
+. (abfd, sym))
+.
+.#define bfd_coff_compute_section_file_positions(abfd)\
+. ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
+. (abfd))
+.
+.#define bfd_coff_start_final_link(obfd, info)\
+. ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
+. (obfd, info))
+.#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
+. ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
+. (obfd, info, ibfd, o, con, rel, isyms, secs))
+.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
+. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
+. (abfd, sec, rel, h, sym, addendp))
+.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
+. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
+. (obfd, info, ibfd, sec, rel, adjustedp))
+.#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
+. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
+. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
+.
+.#define bfd_coff_link_output_has_begun(a,p) \
+. ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
+.#define bfd_coff_final_link_postscript(a,p) \
+. ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
+.
+*/
+
+/* See whether the magic number matches. */
+
+static boolean
+coff_bad_format_hook (abfd, filehdr)
+ bfd * abfd;
+ PTR filehdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+ if (BADMAG (*internal_f))
+ return false;
+
+ /* if the optional header is NULL or not the correct size then
+ quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
+ and Intel 960 readwrite headers (I960WRMAGIC) is that the
+ optional header is of a different size.
+
+ But the mips keeps extra stuff in it's opthdr, so dont check
+ when doing that
+ */
+
+#if defined(M88) || defined(I960)
+ if (internal_f->f_opthdr != 0 && AOUTSZ != internal_f->f_opthdr)
+ return false;
+#endif
+
+ return true;
+}
+
+/*
+ initialize a section structure with information peculiar to this
+ particular implementation of coff
+*/
+
+static boolean
+coff_new_section_hook (abfd, section)
+ bfd * abfd;
+ asection * section;
+{
+ combined_entry_type *native;
+
+ section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
+
+#ifdef RS6000COFF_C
+ if (xcoff_data (abfd)->text_align_power != 0
+ && strcmp (bfd_get_section_name (abfd, section), ".text") == 0)
+ section->alignment_power = xcoff_data (abfd)->text_align_power;
+ if (xcoff_data (abfd)->data_align_power != 0
+ && strcmp (bfd_get_section_name (abfd, section), ".data") == 0)
+ section->alignment_power = xcoff_data (abfd)->data_align_power;
+#endif
+
+ /* Allocate aux records for section symbols, to store size and
+ related info.
+
+ @@ The 10 is a guess at a plausible maximum number of aux entries
+ (but shouldn't be a constant). */
+ native = ((combined_entry_type *)
+ bfd_zalloc (abfd, sizeof (combined_entry_type) * 10));
+ if (native == NULL)
+ return false;
+
+ /* We don't need to set up n_name, n_value, or n_scnum in the native
+ symbol information, since they'll be overriden by the BFD symbol
+ anyhow. However, we do need to set the type and storage class,
+ in case this symbol winds up getting written out. The value 0
+ for n_numaux is already correct. */
+
+ native->u.syment.n_type = T_NULL;
+ native->u.syment.n_sclass = C_STAT;
+
+ coffsymbol (section->symbol)->native = native;
+
+ /* The .stab section must be aligned to 2**2 at most, because
+ otherwise there may be gaps in the section which gdb will not
+ know how to interpret. Examining the section name is a hack, but
+ that is also how gdb locates the section.
+ We need to handle the .ctors and .dtors sections similarly, to
+ avoid introducing null words in the tables. */
+ if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 2
+ && (strncmp (section->name, ".stab", 5) == 0
+ || strcmp (section->name, ".ctors") == 0
+ || strcmp (section->name, ".dtors") == 0))
+ section->alignment_power = 2;
+
+ /* Similarly, the .stabstr section must be aligned to 2**0 at most. */
+ if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 0
+ && strncmp (section->name, ".stabstr", 8) == 0)
+ section->alignment_power = 0;
+
+ return true;
+}
+
+#ifdef COFF_ALIGN_IN_SECTION_HEADER
+
+/* Set the alignment of a BFD section. */
+
+static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));
+
+static void
+coff_set_alignment_hook (abfd, section, scnhdr)
+ bfd * abfd;
+ asection * section;
+ PTR scnhdr;
+{
+ struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
+ unsigned int i;
+
+#ifdef I960
+ /* Extract ALIGN from 2**ALIGN stored in section header */
+ for (i = 0; i < 32; i++)
+ if ((1 << i) >= hdr->s_align)
+ break;
+#endif
+#ifdef TIC80COFF
+ /* TI tools hijack bits 8-11 for the alignment */
+ i = (hdr->s_flags >> 8) & 0xF ;
+#endif
+ section->alignment_power = i;
+}
+
+#else /* ! COFF_ALIGN_IN_SECTION_HEADER */
+#ifdef COFF_WITH_PE
+
+/* a couple of macros to help setting the alignment power field */
+#define ALIGN_SET(field,x,y) \
+ if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x )\
+ {\
+ section->alignment_power = y;\
+ }
+
+#define ELIFALIGN_SET(field,x,y) \
+ else if (( (field) & IMAGE_SCN_ALIGN_64BYTES) == x ) \
+ {\
+ section->alignment_power = y;\
+ }
+
+static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));
+
+static void
+coff_set_alignment_hook (abfd, section, scnhdr)
+ bfd * abfd;
+ asection * section;
+ PTR scnhdr;
+{
+ struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
+
+ ALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_64BYTES, 6)
+ ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_32BYTES, 5)
+ ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_16BYTES, 4)
+ ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_8BYTES, 3)
+ ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_4BYTES, 2)
+ ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_2BYTES, 1)
+ ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_1BYTES, 0)
+
+#ifdef POWERPC_LE_PE
+ if (strcmp (section->name, ".idata$2") == 0)
+ {
+ section->alignment_power = 0;
+ }
+ else if (strcmp (section->name, ".idata$3") == 0)
+ {
+ section->alignment_power = 0;
+ }
+ else if (strcmp (section->name, ".idata$4") == 0)
+ {
+ section->alignment_power = 2;
+ }
+ else if (strcmp (section->name, ".idata$5") == 0)
+ {
+ section->alignment_power = 2;
+ }
+ else if (strcmp (section->name, ".idata$6") == 0)
+ {
+ section->alignment_power = 1;
+ }
+ else if (strcmp (section->name, ".reloc") == 0)
+ {
+ section->alignment_power = 1;
+ }
+ else if (strncmp (section->name, ".stab", 5) == 0)
+ {
+ section->alignment_power = 2;
+ }
+#endif
+
+#ifdef COFF_IMAGE_WITH_PE
+ /* In a PE image file, the s_paddr field holds the virtual size of a
+ section, while the s_size field holds the raw size. */
+ if (hdr->s_paddr != 0)
+ {
+ if (coff_section_data (abfd, section) == NULL)
+ {
+ section->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (section->used_by_bfd == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, section) == NULL)
+ {
+ coff_section_data (abfd, section)->tdata =
+ (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (abfd, section)->tdata == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
+ }
+#endif
+
+}
+#undef ALIGN_SET
+#undef ELIFALIGN_SET
+
+#else /* ! COFF_WITH_PE */
+#ifdef RS6000COFF_C
+
+/* We grossly abuse this function to handle XCOFF overflow headers.
+ When we see one, we correct the reloc and line number counts in the
+ real header, and remove the section we just created. */
+
+static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));
+
+static void
+coff_set_alignment_hook (abfd, section, scnhdr)
+ bfd *abfd;
+ asection *section;
+ PTR scnhdr;
+{
+ struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
+ asection *real_sec;
+ asection **ps;
+
+ if ((hdr->s_flags & STYP_OVRFLO) == 0)
+ return;
+
+ real_sec = coff_section_from_bfd_index (abfd, hdr->s_nreloc);
+ if (real_sec == NULL)
+ return;
+
+ real_sec->reloc_count = hdr->s_paddr;
+ real_sec->lineno_count = hdr->s_vaddr;
+
+ for (ps = &abfd->sections; *ps != NULL; ps = &(*ps)->next)
+ {
+ if (*ps == section)
+ {
+ *ps = (*ps)->next;
+ --abfd->section_count;
+ break;
+ }
+ }
+}
+
+#else /* ! RS6000COFF_C */
+
+#define coff_set_alignment_hook \
+ ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
+
+#endif /* ! RS6000COFF_C */
+#endif /* ! COFF_WITH_PE */
+#endif /* ! COFF_ALIGN_IN_SECTION_HEADER */
+
+#ifndef coff_mkobject
+
+static boolean coff_mkobject PARAMS ((bfd *));
+
+static boolean
+coff_mkobject (abfd)
+ bfd * abfd;
+{
+ coff_data_type *coff;
+
+ abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
+ if (abfd->tdata.coff_obj_data == 0)
+ return false;
+ coff = coff_data (abfd);
+ coff->symbols = (coff_symbol_type *) NULL;
+ coff->conversion_table = (unsigned int *) NULL;
+ coff->raw_syments = (struct coff_ptr_struct *) NULL;
+ coff->relocbase = 0;
+ coff->local_toc_sym_map = 0;
+
+/* make_abs_section(abfd);*/
+
+ return true;
+}
+#endif
+
+/* Create the COFF backend specific information. */
+#ifndef coff_mkobject_hook
+static PTR
+coff_mkobject_hook (abfd, filehdr, aouthdr)
+ bfd * abfd;
+ PTR filehdr;
+ PTR aouthdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+ coff_data_type *coff;
+
+ if (coff_mkobject (abfd) == false)
+ return NULL;
+
+ coff = coff_data (abfd);
+
+ coff->sym_filepos = internal_f->f_symptr;
+
+ /* These members communicate important constants about the symbol
+ table to GDB's symbol-reading code. These `constants'
+ unfortunately vary among coff implementations... */
+ coff->local_n_btmask = N_BTMASK;
+ coff->local_n_btshft = N_BTSHFT;
+ coff->local_n_tmask = N_TMASK;
+ coff->local_n_tshift = N_TSHIFT;
+ coff->local_symesz = SYMESZ;
+ coff->local_auxesz = AUXESZ;
+ coff->local_linesz = LINESZ;
+
+ obj_raw_syment_count (abfd) =
+ obj_conv_table_size (abfd) =
+ internal_f->f_nsyms;
+
+#ifdef RS6000COFF_C
+ if ((internal_f->f_flags & F_SHROBJ) != 0)
+ abfd->flags |= DYNAMIC;
+ if (aouthdr != NULL && internal_f->f_opthdr >= AOUTSZ)
+ {
+ struct internal_aouthdr *internal_a =
+ (struct internal_aouthdr *) aouthdr;
+ struct xcoff_tdata *xcoff;
+
+ xcoff = xcoff_data (abfd);
+ xcoff->full_aouthdr = true;
+ xcoff->toc = internal_a->o_toc;
+ xcoff->sntoc = internal_a->o_sntoc;
+ xcoff->snentry = internal_a->o_snentry;
+ xcoff->text_align_power = internal_a->o_algntext;
+ xcoff->data_align_power = internal_a->o_algndata;
+ xcoff->modtype = internal_a->o_modtype;
+ xcoff->cputype = internal_a->o_cputype;
+ xcoff->maxdata = internal_a->o_maxdata;
+ xcoff->maxstack = internal_a->o_maxstack;
+ }
+#endif
+
+#ifdef ARM
+ /* Set the flags field from the COFF header read in */
+ if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
+ coff->flags = 0;
+#endif
+
+ return (PTR) coff;
+}
+#endif
+
+/* Determine the machine architecture and type. FIXME: This is target
+ dependent because the magic numbers are defined in the target
+ dependent header files. But there is no particular need for this.
+ If the magic numbers were moved to a separate file, this function
+ would be target independent and would also be much more successful
+ at linking together COFF files for different architectures. */
+
+static boolean
+coff_set_arch_mach_hook (abfd, filehdr)
+ bfd *abfd;
+ PTR filehdr;
+{
+ long machine;
+ enum bfd_architecture arch;
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+ machine = 0;
+ switch (internal_f->f_magic)
+ {
+#ifdef PPCMAGIC
+ case PPCMAGIC:
+ arch = bfd_arch_powerpc;
+ machine = 0; /* what does this mean? (krk) */
+ break;
+#endif
+#ifdef I386MAGIC
+ case I386MAGIC:
+ case I386PTXMAGIC:
+ case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler */
+ case LYNXCOFFMAGIC: /* shadows the m68k Lynx number below, sigh */
+ arch = bfd_arch_i386;
+ machine = 0;
+ break;
+#endif
+#ifdef A29K_MAGIC_BIG
+ case A29K_MAGIC_BIG:
+ case A29K_MAGIC_LITTLE:
+ arch = bfd_arch_a29k;
+ machine = 0;
+ break;
+#endif
+#ifdef ARMMAGIC
+ case ARMMAGIC:
+ arch = bfd_arch_arm;
+ switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
+ {
+ case F_ARM_2: machine = bfd_mach_arm_2; break;
+ case F_ARM_3: machine = bfd_mach_arm_3; break;
+ default:
+ case F_ARM_4: machine = bfd_mach_arm_4; break;
+ case F_ARM_4T: machine = bfd_mach_arm_4T; break;
+ }
+ break;
+#endif
+#ifdef MC68MAGIC
+ case MC68MAGIC:
+ case M68MAGIC:
+#ifdef MC68KBCSMAGIC
+ case MC68KBCSMAGIC:
+#endif
+#ifdef APOLLOM68KMAGIC
+ case APOLLOM68KMAGIC:
+#endif
+#ifdef LYNXCOFFMAGIC
+ case LYNXCOFFMAGIC:
+#endif
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68020;
+ break;
+#endif
+#ifdef MC88MAGIC
+ case MC88MAGIC:
+ case MC88DMAGIC:
+ case MC88OMAGIC:
+ arch = bfd_arch_m88k;
+ machine = 88100;
+ break;
+#endif
+#ifdef Z8KMAGIC
+ case Z8KMAGIC:
+ arch = bfd_arch_z8k;
+ switch (internal_f->f_flags & F_MACHMASK)
+ {
+ case F_Z8001:
+ machine = bfd_mach_z8001;
+ break;
+ case F_Z8002:
+ machine = bfd_mach_z8002;
+ break;
+ default:
+ return false;
+ }
+ break;
+#endif
+#ifdef I860
+ case I860MAGIC:
+ arch = bfd_arch_i860;
+ break;
+#endif
+#ifdef I960
+#ifdef I960ROMAGIC
+ case I960ROMAGIC:
+ case I960RWMAGIC:
+ arch = bfd_arch_i960;
+ switch (F_I960TYPE & internal_f->f_flags)
+ {
+ default:
+ case F_I960CORE:
+ machine = bfd_mach_i960_core;
+ break;
+ case F_I960KB:
+ machine = bfd_mach_i960_kb_sb;
+ break;
+ case F_I960MC:
+ machine = bfd_mach_i960_mc;
+ break;
+ case F_I960XA:
+ machine = bfd_mach_i960_xa;
+ break;
+ case F_I960CA:
+ machine = bfd_mach_i960_ca;
+ break;
+ case F_I960KA:
+ machine = bfd_mach_i960_ka_sa;
+ break;
+ case F_I960JX:
+ machine = bfd_mach_i960_jx;
+ break;
+ case F_I960HX:
+ machine = bfd_mach_i960_hx;
+ break;
+ }
+ break;
+#endif
+#endif
+
+#ifdef RS6000COFF_C
+ case U802ROMAGIC:
+ case U802WRMAGIC:
+ case U802TOCMAGIC:
+ {
+ int cputype;
+
+ if (xcoff_data (abfd)->cputype != -1)
+ cputype = xcoff_data (abfd)->cputype & 0xff;
+ else
+ {
+ /* We did not get a value from the a.out header. If the
+ file has not been stripped, we may be able to get the
+ architecture information from the first symbol, if it
+ is a .file symbol. */
+ if (obj_raw_syment_count (abfd) == 0)
+ cputype = 0;
+ else
+ {
+ bfd_byte buf[SYMESZ];
+ struct internal_syment sym;
+
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+ || bfd_read (buf, 1, SYMESZ, abfd) != SYMESZ)
+ return false;
+ coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym);
+ if (sym.n_sclass == C_FILE)
+ cputype = sym.n_type & 0xff;
+ else
+ cputype = 0;
+ }
+ }
+
+ /* FIXME: We don't handle all cases here. */
+ switch (cputype)
+ {
+ default:
+ case 0:
+#ifdef POWERMAC
+ /* PowerPC Macs use the same magic numbers as RS/6000
+ (because that's how they were bootstrapped originally),
+ but they are always PowerPC architecture. */
+ arch = bfd_arch_powerpc;
+ machine = 0;
+#else
+ arch = bfd_arch_rs6000;
+ machine = 6000;
+#endif /* POWERMAC */
+ break;
+
+ case 1:
+ arch = bfd_arch_powerpc;
+ machine = 601;
+ break;
+ case 2: /* 64 bit PowerPC */
+ arch = bfd_arch_powerpc;
+ machine = 620;
+ break;
+ case 3:
+ arch = bfd_arch_powerpc;
+ machine = 0;
+ break;
+ case 4:
+ arch = bfd_arch_rs6000;
+ machine = 6000;
+ break;
+ }
+ }
+ break;
+#endif
+
+#ifdef WE32KMAGIC
+ case WE32KMAGIC:
+ arch = bfd_arch_we32k;
+ machine = 0;
+ break;
+#endif
+
+#ifdef H8300MAGIC
+ case H8300MAGIC:
+ arch = bfd_arch_h8300;
+ machine = bfd_mach_h8300;
+ /* !! FIXME this probably isn't the right place for this */
+ abfd->flags |= BFD_IS_RELAXABLE;
+ break;
+#endif
+
+#ifdef H8300HMAGIC
+ case H8300HMAGIC:
+ arch = bfd_arch_h8300;
+ machine = bfd_mach_h8300h;
+ /* !! FIXME this probably isn't the right place for this */
+ abfd->flags |= BFD_IS_RELAXABLE;
+ break;
+#endif
+
+#ifdef H8300SMAGIC
+ case H8300SMAGIC:
+ arch = bfd_arch_h8300;
+ machine = bfd_mach_h8300s;
+ /* !! FIXME this probably isn't the right place for this */
+ abfd->flags |= BFD_IS_RELAXABLE;
+ break;
+#endif
+
+#ifdef SH_ARCH_MAGIC_BIG
+ case SH_ARCH_MAGIC_BIG:
+ case SH_ARCH_MAGIC_LITTLE:
+ arch = bfd_arch_sh;
+ machine = 0;
+ break;
+#endif
+
+#ifdef H8500MAGIC
+ case H8500MAGIC:
+ arch = bfd_arch_h8500;
+ machine = 0;
+ break;
+#endif
+
+#ifdef SPARCMAGIC
+ case SPARCMAGIC:
+#ifdef LYNXCOFFMAGIC
+ case LYNXCOFFMAGIC:
+#endif
+ arch = bfd_arch_sparc;
+ machine = 0;
+ break;
+#endif
+
+#ifdef TIC30MAGIC
+ case TIC30MAGIC:
+ arch = bfd_arch_tic30;
+ break;
+#endif
+
+#ifdef TIC80_ARCH_MAGIC
+ case TIC80_ARCH_MAGIC:
+ arch = bfd_arch_tic80;
+ break;
+#endif
+
+#ifdef MCOREMAGIC
+ case MCOREMAGIC:
+ arch = bfd_arch_mcore;
+ break;
+#endif
+ default: /* Unreadable input file type */
+ arch = bfd_arch_obscure;
+ break;
+ }
+
+ bfd_default_set_arch_mach (abfd, arch, machine);
+ return true;
+}
+
+#ifdef SYMNAME_IN_DEBUG
+
+static boolean symname_in_debug_hook
+ PARAMS ((bfd *, struct internal_syment *));
+
+static boolean
+symname_in_debug_hook (abfd, sym)
+ bfd * abfd;
+ struct internal_syment *sym;
+{
+ return SYMNAME_IN_DEBUG (sym) ? true : false;
+}
+
+#else
+
+#define symname_in_debug_hook \
+ (boolean (*) PARAMS ((bfd *, struct internal_syment *))) bfd_false
+
+#endif
+
+#ifdef RS6000COFF_C
+
+/* Handle the csect auxent of a C_EXT or C_HIDEXT symbol. */
+
+static boolean coff_pointerize_aux_hook
+ PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
+ unsigned int, combined_entry_type *));
+
+/*ARGSUSED*/
+static boolean
+coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
+ bfd *abfd;
+ combined_entry_type *table_base;
+ combined_entry_type *symbol;
+ unsigned int indaux;
+ combined_entry_type *aux;
+{
+ int class = symbol->u.syment.n_sclass;
+
+ if ((class == C_EXT || class == C_HIDEXT)
+ && indaux + 1 == symbol->u.syment.n_numaux)
+ {
+ if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD)
+ {
+ aux->u.auxent.x_csect.x_scnlen.p =
+ table_base + aux->u.auxent.x_csect.x_scnlen.l;
+ aux->fix_scnlen = 1;
+ }
+
+ /* Return true to indicate that the caller should not do any
+ further work on this auxent. */
+ return true;
+ }
+
+ /* Return false to indicate that this auxent should be handled by
+ the caller. */
+ return false;
+}
+
+#else
+#ifdef I960
+
+/* We don't want to pointerize bal entries. */
+
+static boolean coff_pointerize_aux_hook
+ PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
+ unsigned int, combined_entry_type *));
+
+/*ARGSUSED*/
+static boolean
+coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
+ bfd *abfd;
+ combined_entry_type *table_base;
+ combined_entry_type *symbol;
+ unsigned int indaux;
+ combined_entry_type *aux;
+{
+ /* Return true if we don't want to pointerize this aux entry, which
+ is the case for the lastfirst aux entry for a C_LEAFPROC symbol. */
+ return (indaux == 1
+ && (symbol->u.syment.n_sclass == C_LEAFPROC
+ || symbol->u.syment.n_sclass == C_LEAFSTAT
+ || symbol->u.syment.n_sclass == C_LEAFEXT));
+}
+
+#else /* ! I960 */
+
+#define coff_pointerize_aux_hook 0
+
+#endif /* ! I960 */
+#endif /* ! RS6000COFF_C */
+
+/* Print an aux entry. This returns true if it has printed it. */
+
+static boolean coff_print_aux
+ PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
+ combined_entry_type *, unsigned int));
+
+static boolean
+coff_print_aux (abfd, file, table_base, symbol, aux, indaux)
+ bfd *abfd;
+ FILE *file;
+ combined_entry_type *table_base;
+ combined_entry_type *symbol;
+ combined_entry_type *aux;
+ unsigned int indaux;
+{
+#ifdef RS6000COFF_C
+ if ((symbol->u.syment.n_sclass == C_EXT
+ || symbol->u.syment.n_sclass == C_HIDEXT)
+ && indaux + 1 == symbol->u.syment.n_numaux)
+ {
+ /* This is a csect entry. */
+ fprintf (file, "AUX ");
+ if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
+ {
+ BFD_ASSERT (! aux->fix_scnlen);
+ fprintf (file, "val %5ld", aux->u.auxent.x_csect.x_scnlen.l);
+ }
+ else
+ {
+ fprintf (file, "indx ");
+ if (! aux->fix_scnlen)
+ fprintf (file, "%4ld", aux->u.auxent.x_csect.x_scnlen.l);
+ else
+ fprintf (file, "%4ld",
+ (long) (aux->u.auxent.x_csect.x_scnlen.p - table_base));
+ }
+ fprintf (file,
+ " prmhsh %ld snhsh %u typ %d algn %d clss %u stb %ld snstb %u",
+ aux->u.auxent.x_csect.x_parmhash,
+ (unsigned int) aux->u.auxent.x_csect.x_snhash,
+ SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp),
+ SMTYP_ALIGN (aux->u.auxent.x_csect.x_smtyp),
+ (unsigned int) aux->u.auxent.x_csect.x_smclas,
+ aux->u.auxent.x_csect.x_stab,
+ (unsigned int) aux->u.auxent.x_csect.x_snstab);
+ return true;
+ }
+#endif
+
+ /* Return false to indicate that no special action was taken. */
+ return false;
+}
+
+/*
+SUBSUBSECTION
+ Writing relocations
+
+ To write relocations, the back end steps though the
+ canonical relocation table and create an
+ @code{internal_reloc}. The symbol index to use is removed from
+ the @code{offset} field in the symbol table supplied. The
+ address comes directly from the sum of the section base
+ address and the relocation offset; the type is dug directly
+ from the howto field. Then the @code{internal_reloc} is
+ swapped into the shape of an @code{external_reloc} and written
+ out to disk.
+
+*/
+
+#ifdef TARG_AUX
+
+static int compare_arelent_ptr PARAMS ((const PTR, const PTR));
+
+/* AUX's ld wants relocations to be sorted */
+static int
+compare_arelent_ptr (x, y)
+ const PTR x;
+ const PTR y;
+{
+ const arelent **a = (const arelent **) x;
+ const arelent **b = (const arelent **) y;
+ bfd_size_type aadr = (*a)->address;
+ bfd_size_type badr = (*b)->address;
+
+ return (aadr < badr ? -1 : badr < aadr ? 1 : 0);
+}
+
+#endif /* TARG_AUX */
+
+static boolean
+coff_write_relocs (abfd, first_undef)
+ bfd * abfd;
+ int first_undef;
+{
+ asection *s;
+
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ unsigned int i;
+ struct external_reloc dst;
+ arelent **p;
+
+#ifndef TARG_AUX
+ p = s->orelocation;
+#else
+ /* sort relocations before we write them out */
+ p = (arelent **) bfd_malloc (s->reloc_count * sizeof (arelent *));
+ if (p == NULL && s->reloc_count > 0)
+ return false;
+ memcpy (p, s->orelocation, s->reloc_count * sizeof (arelent *));
+ qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
+#endif
+
+ if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
+ return false;
+ for (i = 0; i < s->reloc_count; i++)
+ {
+ struct internal_reloc n;
+ arelent *q = p[i];
+ memset ((PTR) & n, 0, sizeof (n));
+
+ /* Now we've renumbered the symbols we know where the
+ undefined symbols live in the table. Check the reloc
+ entries for symbols who's output bfd isn't the right one.
+ This is because the symbol was undefined (which means
+ that all the pointers are never made to point to the same
+ place). This is a bad thing,'cause the symbols attached
+ to the output bfd are indexed, so that the relocation
+ entries know which symbol index they point to. So we
+ have to look up the output symbol here. */
+
+ if (q->sym_ptr_ptr[0]->the_bfd != abfd)
+ {
+ int i;
+ const char *sname = q->sym_ptr_ptr[0]->name;
+ asymbol **outsyms = abfd->outsymbols;
+ for (i = first_undef; outsyms[i]; i++)
+ {
+ const char *intable = outsyms[i]->name;
+ if (strcmp (intable, sname) == 0) {
+ /* got a hit, so repoint the reloc */
+ q->sym_ptr_ptr = outsyms + i;
+ break;
+ }
+ }
+ }
+
+ n.r_vaddr = q->address + s->vma;
+
+#ifdef R_IHCONST
+ /* The 29k const/consth reloc pair is a real kludge. The consth
+ part doesn't have a symbol; it has an offset. So rebuilt
+ that here. */
+ if (q->howto->type == R_IHCONST)
+ n.r_symndx = q->addend;
+ else
+#endif
+ if (q->sym_ptr_ptr)
+ {
+ if (q->sym_ptr_ptr == bfd_abs_section_ptr->symbol_ptr_ptr)
+ /* This is a relocation relative to the absolute symbol. */
+ n.r_symndx = -1;
+ else
+ {
+ n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
+ /* Take notice if the symbol reloc points to a symbol
+ we don't have in our symbol table. What should we
+ do for this?? */
+ if (n.r_symndx > obj_conv_table_size (abfd))
+ abort ();
+ }
+ }
+
+#ifdef SWAP_OUT_RELOC_OFFSET
+ n.r_offset = q->addend;
+#endif
+
+#ifdef SELECT_RELOC
+ /* Work out reloc type from what is required */
+ SELECT_RELOC (n, q->howto);
+#else
+ n.r_type = q->howto->type;
+#endif
+ coff_swap_reloc_out (abfd, &n, &dst);
+ if (bfd_write ((PTR) & dst, 1, RELSZ, abfd) != RELSZ)
+ return false;
+ }
+
+#ifdef TARG_AUX
+ if (p != NULL)
+ free (p);
+#endif
+ }
+
+ return true;
+}
+
+/* Set flags and magic number of a coff file from architecture and machine
+ type. Result is true if we can represent the arch&type, false if not. */
+
+static boolean
+coff_set_flags (abfd, magicp, flagsp)
+ bfd * abfd;
+ unsigned int *magicp;
+ unsigned short *flagsp;
+{
+ switch (bfd_get_arch (abfd))
+ {
+#ifdef Z8KMAGIC
+ case bfd_arch_z8k:
+ *magicp = Z8KMAGIC;
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_z8001:
+ *flagsp = F_Z8001;
+ break;
+ case bfd_mach_z8002:
+ *flagsp = F_Z8002;
+ break;
+ default:
+ return false;
+ }
+ return true;
+#endif
+#ifdef I960ROMAGIC
+
+ case bfd_arch_i960:
+
+ {
+ unsigned flags;
+ *magicp = I960ROMAGIC;
+ /*
+ ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC :
+ I960RWMAGIC); FIXME???
+ */
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_i960_core:
+ flags = F_I960CORE;
+ break;
+ case bfd_mach_i960_kb_sb:
+ flags = F_I960KB;
+ break;
+ case bfd_mach_i960_mc:
+ flags = F_I960MC;
+ break;
+ case bfd_mach_i960_xa:
+ flags = F_I960XA;
+ break;
+ case bfd_mach_i960_ca:
+ flags = F_I960CA;
+ break;
+ case bfd_mach_i960_ka_sa:
+ flags = F_I960KA;
+ break;
+ case bfd_mach_i960_jx:
+ flags = F_I960JX;
+ break;
+ case bfd_mach_i960_hx:
+ flags = F_I960HX;
+ break;
+ default:
+ return false;
+ }
+ *flagsp = flags;
+ return true;
+ }
+ break;
+#endif
+
+#ifdef TIC30MAGIC
+ case bfd_arch_tic30:
+ *magicp = TIC30MAGIC;
+ return true;
+#endif
+#ifdef TIC80_ARCH_MAGIC
+ case bfd_arch_tic80:
+ *magicp = TIC80_ARCH_MAGIC;
+ return true;
+#endif
+#ifdef ARMMAGIC
+ case bfd_arch_arm:
+ * magicp = ARMMAGIC;
+ * flagsp = 0;
+ if (APCS_SET (abfd))
+ {
+ if (APCS_26_FLAG (abfd))
+ * flagsp |= F_APCS26;
+
+ if (APCS_FLOAT_FLAG (abfd))
+ * flagsp |= F_APCS_FLOAT;
+
+ if (PIC_FLAG (abfd))
+ * flagsp |= F_PIC_INT;
+ }
+ if (INTERWORK_SET (abfd) && INTERWORK_FLAG (abfd))
+ * flagsp |= F_INTERWORK;
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_arm_2: * flagsp |= F_ARM_2; break;
+ case bfd_mach_arm_2a: * flagsp |= F_ARM_2a; break;
+ case bfd_mach_arm_3: * flagsp |= F_ARM_3; break;
+ case bfd_mach_arm_3M: * flagsp |= F_ARM_3M; break;
+ case bfd_mach_arm_4: * flagsp |= F_ARM_4; break;
+ case bfd_mach_arm_4T: * flagsp |= F_ARM_4T; break;
+ }
+ return true;
+#endif
+#ifdef PPCMAGIC
+ case bfd_arch_powerpc:
+ *magicp = PPCMAGIC;
+ return true;
+ break;
+#endif
+#ifdef I386MAGIC
+ case bfd_arch_i386:
+ *magicp = I386MAGIC;
+#ifdef LYNXOS
+ /* Just overwrite the usual value if we're doing Lynx. */
+ *magicp = LYNXCOFFMAGIC;
+#endif
+ return true;
+ break;
+#endif
+#ifdef I860MAGIC
+ case bfd_arch_i860:
+ *magicp = I860MAGIC;
+ return true;
+ break;
+#endif
+#ifdef MC68MAGIC
+ case bfd_arch_m68k:
+#ifdef APOLLOM68KMAGIC
+ *magicp = APOLLO_COFF_VERSION_NUMBER;
+#else
+ /* NAMES_HAVE_UNDERSCORE may be defined by coff-u68k.c. */
+#ifdef NAMES_HAVE_UNDERSCORE
+ *magicp = MC68KBCSMAGIC;
+#else
+ *magicp = MC68MAGIC;
+#endif
+#endif
+#ifdef LYNXOS
+ /* Just overwrite the usual value if we're doing Lynx. */
+ *magicp = LYNXCOFFMAGIC;
+#endif
+ return true;
+ break;
+#endif
+
+#ifdef MC88MAGIC
+ case bfd_arch_m88k:
+ *magicp = MC88OMAGIC;
+ return true;
+ break;
+#endif
+#ifdef H8300MAGIC
+ case bfd_arch_h8300:
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_h8300:
+ *magicp = H8300MAGIC;
+ return true;
+ case bfd_mach_h8300h:
+ *magicp = H8300HMAGIC;
+ return true;
+ case bfd_mach_h8300s:
+ *magicp = H8300SMAGIC;
+ return true;
+ }
+ break;
+#endif
+
+#ifdef SH_ARCH_MAGIC_BIG
+ case bfd_arch_sh:
+ if (bfd_big_endian (abfd))
+ *magicp = SH_ARCH_MAGIC_BIG;
+ else
+ *magicp = SH_ARCH_MAGIC_LITTLE;
+ return true;
+ break;
+#endif
+
+#ifdef SPARCMAGIC
+ case bfd_arch_sparc:
+ *magicp = SPARCMAGIC;
+#ifdef LYNXOS
+ /* Just overwrite the usual value if we're doing Lynx. */
+ *magicp = LYNXCOFFMAGIC;
+#endif
+ return true;
+ break;
+#endif
+
+#ifdef H8500MAGIC
+ case bfd_arch_h8500:
+ *magicp = H8500MAGIC;
+ return true;
+ break;
+#endif
+#ifdef A29K_MAGIC_BIG
+ case bfd_arch_a29k:
+ if (bfd_big_endian (abfd))
+ *magicp = A29K_MAGIC_BIG;
+ else
+ *magicp = A29K_MAGIC_LITTLE;
+ return true;
+ break;
+#endif
+
+#ifdef WE32KMAGIC
+ case bfd_arch_we32k:
+ *magicp = WE32KMAGIC;
+ return true;
+ break;
+#endif
+
+#ifdef U802TOCMAGIC
+ case bfd_arch_rs6000:
+#ifndef PPCMAGIC
+ case bfd_arch_powerpc:
+#endif
+ *magicp = U802TOCMAGIC;
+ return true;
+ break;
+#endif
+
+#ifdef MCOREMAGIC
+ case bfd_arch_mcore:
+ * magicp = MCOREMAGIC;
+ return true;
+#endif
+
+ default: /* Unknown architecture */
+ /* return false; -- fall through to "return false" below, to avoid
+ "statement never reached" errors on the one below. */
+ break;
+ }
+
+ return false;
+}
+
+
+static boolean
+coff_set_arch_mach (abfd, arch, machine)
+ bfd * abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ unsigned dummy1;
+ unsigned short dummy2;
+
+ if (! bfd_default_set_arch_mach (abfd, arch, machine))
+ return false;
+
+ if (arch != bfd_arch_unknown &&
+ coff_set_flags (abfd, &dummy1, &dummy2) != true)
+ return false; /* We can't represent this type */
+
+ return true; /* We're easy ... */
+}
+
+
+/* Calculate the file position for each section. */
+
+#ifndef I960
+#define ALIGN_SECTIONS_IN_FILE
+#endif
+#ifdef TIC80COFF
+#undef ALIGN_SECTIONS_IN_FILE
+#endif
+
+static boolean
+coff_compute_section_file_positions (abfd)
+ bfd * abfd;
+{
+ asection *current;
+ asection *previous = (asection *) NULL;
+ file_ptr sofar = FILHSZ;
+ boolean align_adjust;
+ unsigned int count;
+#ifdef ALIGN_SECTIONS_IN_FILE
+ file_ptr old_sofar;
+#endif
+
+#ifdef RS6000COFF_C
+ /* On XCOFF, if we have symbols, set up the .debug section. */
+ if (bfd_get_symcount (abfd) > 0)
+ {
+ bfd_size_type sz;
+ bfd_size_type i, symcount;
+ asymbol **symp;
+
+ sz = 0;
+ symcount = bfd_get_symcount (abfd);
+ for (symp = abfd->outsymbols, i = 0; i < symcount; symp++, i++)
+ {
+ coff_symbol_type *cf;
+
+ cf = coff_symbol_from (abfd, *symp);
+ if (cf != NULL
+ && cf->native != NULL
+ && SYMNAME_IN_DEBUG (&cf->native->u.syment))
+ {
+ size_t len;
+
+ len = strlen (bfd_asymbol_name (*symp));
+ if (len > SYMNMLEN)
+ sz += len + 3;
+ }
+ }
+ if (sz > 0)
+ {
+ asection *dsec;
+
+ dsec = bfd_make_section_old_way (abfd, ".debug");
+ if (dsec == NULL)
+ abort ();
+ dsec->_raw_size = sz;
+ dsec->flags |= SEC_HAS_CONTENTS;
+ }
+ }
+#endif
+
+#ifdef COFF_IMAGE_WITH_PE
+ int page_size;
+ if (coff_data (abfd)->link_info)
+ {
+ page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
+ }
+ else
+ page_size = PE_DEF_FILE_ALIGNMENT;
+#else
+#ifdef COFF_PAGE_SIZE
+ int page_size = COFF_PAGE_SIZE;
+#endif
+#endif
+
+ if (bfd_get_start_address (abfd))
+ {
+ /* A start address may have been added to the original file. In this
+ case it will need an optional header to record it. */
+ abfd->flags |= EXEC_P;
+ }
+
+ if (abfd->flags & EXEC_P)
+ sofar += AOUTSZ;
+#ifdef RS6000COFF_C
+ else if (xcoff_data (abfd)->full_aouthdr)
+ sofar += AOUTSZ;
+ else
+ sofar += SMALL_AOUTSZ;
+#endif
+
+ sofar += abfd->section_count * SCNHSZ;
+
+#ifdef RS6000COFF_C
+ /* XCOFF handles overflows in the reloc and line number count fields
+ by allocating a new section header to hold the correct counts. */
+ for (current = abfd->sections; current != NULL; current = current->next)
+ if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
+ sofar += SCNHSZ;
+#endif
+
+ align_adjust = false;
+ for (current = abfd->sections, count = 1;
+ current != (asection *) NULL;
+ current = current->next, ++count)
+ {
+#ifdef COFF_IMAGE_WITH_PE
+ /* The NT loader does not want empty section headers, so we omit
+ them. We don't actually remove the section from the BFD,
+ although we probably should. This matches code in
+ coff_write_object_contents. */
+ if (current->_raw_size == 0)
+ {
+ current->target_index = -1;
+ --count;
+ continue;
+ }
+#endif
+
+ current->target_index = count;
+
+ /* Only deal with sections which have contents */
+ if (!(current->flags & SEC_HAS_CONTENTS))
+ continue;
+
+ /* Align the sections in the file to the same boundary on
+ which they are aligned in virtual memory. I960 doesn't
+ do this (FIXME) so we can stay in sync with Intel. 960
+ doesn't yet page from files... */
+#ifdef ALIGN_SECTIONS_IN_FILE
+ if ((abfd->flags & EXEC_P) != 0)
+ {
+ /* make sure this section is aligned on the right boundary - by
+ padding the previous section up if necessary */
+
+ old_sofar = sofar;
+ sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
+ if (previous != (asection *) NULL)
+ {
+ previous->_raw_size += sofar - old_sofar;
+ }
+ }
+
+#endif
+
+ /* In demand paged files the low order bits of the file offset
+ must match the low order bits of the virtual address. */
+#ifdef COFF_PAGE_SIZE
+ if ((abfd->flags & D_PAGED) != 0
+ && (current->flags & SEC_ALLOC) != 0)
+ sofar += (current->vma - sofar) % page_size;
+#endif
+ current->filepos = sofar;
+
+#ifdef COFF_IMAGE_WITH_PE
+ /* With PE we have to pad each section to be a multiple of its
+ page size too, and remember both sizes. */
+
+ if (coff_section_data (abfd, current) == NULL)
+ {
+ current->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (current->used_by_bfd == NULL)
+ return false;
+ }
+ if (pei_section_data (abfd, current) == NULL)
+ {
+ coff_section_data (abfd, current)->tdata =
+ (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (abfd, current)->tdata == NULL)
+ return false;
+ }
+ if (pei_section_data (abfd, current)->virt_size == 0)
+ pei_section_data (abfd, current)->virt_size = current->_raw_size;
+
+ current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
+#endif
+
+ sofar += current->_raw_size;
+
+#ifdef ALIGN_SECTIONS_IN_FILE
+ /* make sure that this section is of the right size too */
+ if ((abfd->flags & EXEC_P) == 0)
+ {
+ bfd_size_type old_size;
+
+ old_size = current->_raw_size;
+ current->_raw_size = BFD_ALIGN (current->_raw_size,
+ 1 << current->alignment_power);
+ align_adjust = current->_raw_size != old_size;
+ sofar += current->_raw_size - old_size;
+ }
+ else
+ {
+ old_sofar = sofar;
+ sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
+ align_adjust = sofar != old_sofar;
+ current->_raw_size += sofar - old_sofar;
+ }
+#endif
+
+#ifdef COFF_IMAGE_WITH_PE
+ /* For PE we need to make sure we pad out to the aligned
+ _raw_size, in case the caller only writes out data to the
+ unaligned _raw_size. */
+ if (pei_section_data (abfd, current)->virt_size < current->_raw_size)
+ align_adjust = true;
+#endif
+
+#ifdef _LIB
+ /* Force .lib sections to start at zero. The vma is then
+ incremented in coff_set_section_contents. This is right for
+ SVR3.2. */
+ if (strcmp (current->name, _LIB) == 0)
+ bfd_set_section_vma (abfd, current, 0);
+#endif
+
+ previous = current;
+ }
+
+ /* It is now safe to write to the output file. If we needed an
+ alignment adjustment for the last section, then make sure that
+ there is a byte at offset sofar. If there are no symbols and no
+ relocs, then nothing follows the last section. If we don't force
+ the last byte out, then the file may appear to be truncated. */
+ if (align_adjust)
+ {
+ bfd_byte b;
+
+ b = 0;
+ if (bfd_seek (abfd, sofar - 1, SEEK_SET) != 0
+ || bfd_write (&b, 1, 1, abfd) != 1)
+ return false;
+ }
+
+ /* Make sure the relocations are aligned. We don't need to make
+ sure that this byte exists, because it will only matter if there
+ really are relocs. */
+ sofar = BFD_ALIGN (sofar, 1 << COFF_DEFAULT_SECTION_ALIGNMENT_POWER);
+
+ obj_relocbase (abfd) = sofar;
+ abfd->output_has_begun = true;
+
+ return true;
+}
+
+#if 0
+
+/* This can never work, because it is called too late--after the
+ section positions have been set. I can't figure out what it is
+ for, so I am going to disable it--Ian Taylor 20 March 1996. */
+
+/* If .file, .text, .data, .bss symbols are missing, add them. */
+/* @@ Should we only be adding missing symbols, or overriding the aux
+ values for existing section symbols? */
+static boolean
+coff_add_missing_symbols (abfd)
+ bfd *abfd;
+{
+ unsigned int nsyms = bfd_get_symcount (abfd);
+ asymbol **sympp = abfd->outsymbols;
+ asymbol **sympp2;
+ unsigned int i;
+ int need_text = 1, need_data = 1, need_bss = 1, need_file = 1;
+
+ for (i = 0; i < nsyms; i++)
+ {
+ coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
+ CONST char *name;
+ if (csym)
+ {
+ /* only do this if there is a coff representation of the input
+ symbol */
+ if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
+ {
+ need_file = 0;
+ continue;
+ }
+ name = csym->symbol.name;
+ if (!name)
+ continue;
+ if (!strcmp (name, _TEXT))
+ need_text = 0;
+#ifdef APOLLO_M68
+ else if (!strcmp (name, ".wtext"))
+ need_text = 0;
+#endif
+ else if (!strcmp (name, _DATA))
+ need_data = 0;
+ else if (!strcmp (name, _BSS))
+ need_bss = 0;
+ }
+ }
+ /* Now i == bfd_get_symcount (abfd). */
+ /* @@ For now, don't deal with .file symbol. */
+ need_file = 0;
+
+ if (!need_text && !need_data && !need_bss && !need_file)
+ return true;
+ nsyms += need_text + need_data + need_bss + need_file;
+ sympp2 = (asymbol **) bfd_alloc (abfd, nsyms * sizeof (asymbol *));
+ if (!sympp2)
+ return false;
+ memcpy (sympp2, sympp, i * sizeof (asymbol *));
+ if (need_file)
+ {
+ /* @@ Generate fake .file symbol, in sympp2[i], and increment i. */
+ abort ();
+ }
+ if (need_text)
+ sympp2[i++] = coff_section_symbol (abfd, _TEXT);
+ if (need_data)
+ sympp2[i++] = coff_section_symbol (abfd, _DATA);
+ if (need_bss)
+ sympp2[i++] = coff_section_symbol (abfd, _BSS);
+ BFD_ASSERT (i == nsyms);
+ bfd_set_symtab (abfd, sympp2, nsyms);
+ return true;
+}
+
+#endif /* 0 */
+
+/* SUPPRESS 558 */
+/* SUPPRESS 529 */
+static boolean
+coff_write_object_contents (abfd)
+ bfd * abfd;
+{
+ asection *current;
+ boolean hasrelocs = false;
+ boolean haslinno = false;
+ file_ptr scn_base;
+ file_ptr reloc_base;
+ file_ptr lineno_base;
+ file_ptr sym_base;
+ unsigned long reloc_size = 0;
+ unsigned long lnno_size = 0;
+ boolean long_section_names;
+ asection *text_sec = NULL;
+ asection *data_sec = NULL;
+ asection *bss_sec = NULL;
+ struct internal_filehdr internal_f;
+ struct internal_aouthdr internal_a;
+#ifdef COFF_LONG_SECTION_NAMES
+ size_t string_size = STRING_SIZE_SIZE;
+#endif
+
+ bfd_set_error (bfd_error_system_call);
+
+ /* Make a pass through the symbol table to count line number entries and
+ put them into the correct asections */
+
+ lnno_size = coff_count_linenumbers (abfd) * LINESZ;
+
+ if (abfd->output_has_begun == false)
+ {
+ if (! coff_compute_section_file_positions (abfd))
+ return false;
+ }
+
+ reloc_base = obj_relocbase (abfd);
+
+ /* Work out the size of the reloc and linno areas */
+
+ for (current = abfd->sections; current != NULL; current =
+ current->next)
+ reloc_size += current->reloc_count * RELSZ;
+
+ lineno_base = reloc_base + reloc_size;
+ sym_base = lineno_base + lnno_size;
+
+ /* Indicate in each section->line_filepos its actual file address */
+ for (current = abfd->sections; current != NULL; current =
+ current->next)
+ {
+ if (current->lineno_count)
+ {
+ current->line_filepos = lineno_base;
+ current->moving_line_filepos = lineno_base;
+ lineno_base += current->lineno_count * LINESZ;
+ }
+ else
+ {
+ current->line_filepos = 0;
+ }
+ if (current->reloc_count)
+ {
+ current->rel_filepos = reloc_base;
+ reloc_base += current->reloc_count * RELSZ;
+ }
+ else
+ {
+ current->rel_filepos = 0;
+ }
+ }
+
+ /* Write section headers to the file. */
+ internal_f.f_nscns = 0;
+
+ if ((abfd->flags & EXEC_P) != 0)
+ scn_base = FILHSZ + AOUTSZ;
+ else
+ {
+ scn_base = FILHSZ;
+#ifdef RS6000COFF_C
+ if (xcoff_data (abfd)->full_aouthdr)
+ scn_base += AOUTSZ;
+ else
+ scn_base += SMALL_AOUTSZ;
+#endif
+ }
+
+ if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
+ return false;
+
+ long_section_names = false;
+ for (current = abfd->sections;
+ current != NULL;
+ current = current->next)
+ {
+ struct internal_scnhdr section;
+
+#ifdef COFF_WITH_PE
+ /* If we've got a .reloc section, remember. */
+
+#ifdef COFF_IMAGE_WITH_PE
+ if (strcmp (current->name, ".reloc") == 0)
+ {
+ pe_data (abfd)->has_reloc_section = 1;
+ }
+#endif
+
+#endif
+ internal_f.f_nscns++;
+
+ strncpy (section.s_name, current->name, SCNNMLEN);
+
+#ifdef COFF_LONG_SECTION_NAMES
+ /* Handle long section names as in PE. This must be compatible
+ with the code in coff_write_symbols. */
+ {
+ size_t len;
+
+ len = strlen (current->name);
+ if (len > SCNNMLEN)
+ {
+ memset (section.s_name, 0, SCNNMLEN);
+ sprintf (section.s_name, "/%lu", (unsigned long) string_size);
+ string_size += len + 1;
+ long_section_names = true;
+ }
+ }
+#endif
+
+#ifdef _LIB
+ /* Always set s_vaddr of .lib to 0. This is right for SVR3.2
+ Ian Taylor <ian@cygnus.com>. */
+ if (strcmp (current->name, _LIB) == 0)
+ section.s_vaddr = 0;
+ else
+#endif
+ section.s_vaddr = current->vma;
+ section.s_paddr = current->lma;
+ section.s_size = current->_raw_size;
+
+#ifdef COFF_WITH_PE
+ section.s_paddr = 0;
+#endif
+#ifdef COFF_IMAGE_WITH_PE
+ /* Reminder: s_paddr holds the virtual size of the section. */
+ if (coff_section_data (abfd, current) != NULL
+ && pei_section_data (abfd, current) != NULL)
+ section.s_paddr = pei_section_data (abfd, current)->virt_size;
+ else
+ section.s_paddr = 0;
+#endif
+
+ /*
+ If this section has no size or is unloadable then the scnptr
+ will be 0 too
+ */
+ if (current->_raw_size == 0 ||
+ (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+ {
+ section.s_scnptr = 0;
+ }
+ else
+ {
+ section.s_scnptr = current->filepos;
+ }
+ section.s_relptr = current->rel_filepos;
+ section.s_lnnoptr = current->line_filepos;
+ section.s_nreloc = current->reloc_count;
+ section.s_nlnno = current->lineno_count;
+ if (current->reloc_count != 0)
+ hasrelocs = true;
+ if (current->lineno_count != 0)
+ haslinno = true;
+
+#ifdef RS6000COFF_C
+ /* Indicate the use of an XCOFF overflow section header. */
+ if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
+ {
+ section.s_nreloc = 0xffff;
+ section.s_nlnno = 0xffff;
+ }
+#endif
+
+ section.s_flags = sec_to_styp_flags (current->name, current->flags);
+
+ if (!strcmp (current->name, _TEXT))
+ {
+ text_sec = current;
+ }
+ else if (!strcmp (current->name, _DATA))
+ {
+ data_sec = current;
+ }
+ else if (!strcmp (current->name, _BSS))
+ {
+ bss_sec = current;
+ }
+
+#ifdef I960
+ section.s_align = (current->alignment_power
+ ? 1 << current->alignment_power
+ : 0);
+#else
+#ifdef TIC80COFF
+ section.s_flags |= (current->alignment_power & 0xF) << 8;
+#endif
+#endif
+
+#ifdef COFF_IMAGE_WITH_PE
+ /* suppress output of the sections if they are null. ld includes
+ the bss and data sections even if there is no size assigned
+ to them. NT loader doesn't like it if these section headers are
+ included if the sections themselves are not needed */
+ if (section.s_size == 0)
+ internal_f.f_nscns--;
+ else
+#endif
+ {
+ SCNHDR buff;
+ if (coff_swap_scnhdr_out (abfd, &section, &buff) == 0
+ || bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ)
+ return false;
+ }
+
+#ifdef COFF_WITH_PE
+ /* PE stores COMDAT section information in the symbol table. If
+ this section is supposed to have some COMDAT info, track down
+ the symbol in the symbol table and modify it. */
+ if ((current->flags & SEC_LINK_ONCE) != 0)
+ {
+ unsigned int i, count;
+ asymbol **psym;
+ coff_symbol_type *csym = NULL;
+ asymbol **psymsec;
+
+ psymsec = NULL;
+ count = bfd_get_symcount (abfd);
+ for (i = 0, psym = abfd->outsymbols; i < count; i++, psym++)
+ {
+ if ((*psym)->section != current)
+ continue;
+
+ /* Remember the location of the first symbol in this
+ section. */
+ if (psymsec == NULL)
+ psymsec = psym;
+
+ /* See if this is the section symbol. */
+ if (strcmp ((*psym)->name, current->name) == 0)
+ {
+ csym = coff_symbol_from (abfd, *psym);
+ if (csym == NULL
+ || csym->native == NULL
+ || csym->native->u.syment.n_numaux < 1
+ || csym->native->u.syment.n_sclass != C_STAT
+ || csym->native->u.syment.n_type != T_NULL)
+ continue;
+
+ /* Here *PSYM is the section symbol for CURRENT. */
+
+ break;
+ }
+ }
+
+ /* Did we find it?
+ Note that we might not if we're converting the file from
+ some other object file format. */
+ if (i < count)
+ {
+ combined_entry_type *aux;
+
+ /* We don't touch the x_checksum field. The
+ x_associated field is not currently supported. */
+
+ aux = csym->native + 1;
+ switch (current->flags & SEC_LINK_DUPLICATES)
+ {
+ case SEC_LINK_DUPLICATES_DISCARD:
+ aux->u.auxent.x_scn.x_comdat = IMAGE_COMDAT_SELECT_ANY;
+ break;
+
+ case SEC_LINK_DUPLICATES_ONE_ONLY:
+ aux->u.auxent.x_scn.x_comdat =
+ IMAGE_COMDAT_SELECT_NODUPLICATES;
+ break;
+
+ case SEC_LINK_DUPLICATES_SAME_SIZE:
+ aux->u.auxent.x_scn.x_comdat =
+ IMAGE_COMDAT_SELECT_SAME_SIZE;
+ break;
+
+ case SEC_LINK_DUPLICATES_SAME_CONTENTS:
+ aux->u.auxent.x_scn.x_comdat =
+ IMAGE_COMDAT_SELECT_EXACT_MATCH;
+ break;
+ }
+
+ /* The COMDAT symbol must be the first symbol from this
+ section in the symbol table. In order to make this
+ work, we move the COMDAT symbol before the first
+ symbol we found in the search above. It's OK to
+ rearrange the symbol table at this point, because
+ coff_renumber_symbols is going to rearrange it
+ further and fix up all the aux entries. */
+ if (psym != psymsec)
+ {
+ asymbol *hold;
+ asymbol **pcopy;
+
+ hold = *psym;
+ for (pcopy = psym; pcopy > psymsec; pcopy--)
+ pcopy[0] = pcopy[-1];
+ *psymsec = hold;
+ }
+ }
+ }
+#endif /* COFF_WITH_PE */
+ }
+
+#ifdef RS6000COFF_C
+ /* XCOFF handles overflows in the reloc and line number count fields
+ by creating a new section header to hold the correct values. */
+ for (current = abfd->sections; current != NULL; current = current->next)
+ {
+ if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
+ {
+ struct internal_scnhdr scnhdr;
+ SCNHDR buff;
+
+ internal_f.f_nscns++;
+ strncpy (&(scnhdr.s_name[0]), current->name, 8);
+ scnhdr.s_paddr = current->reloc_count;
+ scnhdr.s_vaddr = current->lineno_count;
+ scnhdr.s_size = 0;
+ scnhdr.s_scnptr = 0;
+ scnhdr.s_relptr = current->rel_filepos;
+ scnhdr.s_lnnoptr = current->line_filepos;
+ scnhdr.s_nreloc = current->target_index;
+ scnhdr.s_nlnno = current->target_index;
+ scnhdr.s_flags = STYP_OVRFLO;
+ if (coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0
+ || bfd_write ((PTR) &buff, 1, SCNHSZ, abfd) != SCNHSZ)
+ return false;
+ }
+ }
+#endif
+
+ /* OK, now set up the filehdr... */
+
+ /* Don't include the internal abs section in the section count */
+
+ /*
+ We will NOT put a fucking timestamp in the header here. Every time you
+ put it back, I will come in and take it out again. I'm sorry. This
+ field does not belong here. We fill it with a 0 so it compares the
+ same but is not a reasonable time. -- gnu@cygnus.com
+ */
+ internal_f.f_timdat = 0;
+
+ internal_f.f_flags = 0;
+
+ if (abfd->flags & EXEC_P)
+ internal_f.f_opthdr = AOUTSZ;
+ else
+ {
+ internal_f.f_opthdr = 0;
+#ifdef RS6000COFF_C
+ if (xcoff_data (abfd)->full_aouthdr)
+ internal_f.f_opthdr = AOUTSZ;
+ else
+ internal_f.f_opthdr = SMALL_AOUTSZ;
+#endif
+ }
+
+ if (!hasrelocs)
+ internal_f.f_flags |= F_RELFLG;
+ if (!haslinno)
+ internal_f.f_flags |= F_LNNO;
+ if (abfd->flags & EXEC_P)
+ internal_f.f_flags |= F_EXEC;
+
+ /* FIXME: this is wrong for PPC_PE! */
+ if (bfd_little_endian (abfd))
+ internal_f.f_flags |= F_AR32WR;
+ else
+ internal_f.f_flags |= F_AR32W;
+
+#ifdef TIC80_TARGET_ID
+ internal_f.f_target_id = TIC80_TARGET_ID;
+#endif
+
+ /*
+ FIXME, should do something about the other byte orders and
+ architectures.
+ */
+
+#ifdef RS6000COFF_C
+ if ((abfd->flags & DYNAMIC) != 0)
+ internal_f.f_flags |= F_SHROBJ;
+ if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
+ internal_f.f_flags |= F_DYNLOAD;
+#endif
+
+ memset (&internal_a, 0, sizeof internal_a);
+
+ /* Set up architecture-dependent stuff */
+
+ {
+ unsigned int magic = 0;
+ unsigned short flags = 0;
+ coff_set_flags (abfd, &magic, &flags);
+ internal_f.f_magic = magic;
+ internal_f.f_flags |= flags;
+ /* ...and the "opt"hdr... */
+
+#ifdef A29K
+#ifdef ULTRA3 /* NYU's machine */
+ /* FIXME: This is a bogus check. I really want to see if there
+ * is a .shbss or a .shdata section, if so then set the magic
+ * number to indicate a shared data executable.
+ */
+ if (internal_f.f_nscns >= 7)
+ internal_a.magic = SHMAGIC; /* Shared magic */
+ else
+#endif /* ULTRA3 */
+ internal_a.magic = NMAGIC; /* Assume separate i/d */
+#define __A_MAGIC_SET__
+#endif /* A29K */
+#ifdef TIC80COFF
+ internal_a.magic = TIC80_ARCH_MAGIC;
+#define __A_MAGIC_SET__
+#endif /* TIC80 */
+#ifdef I860
+ /* FIXME: What are the a.out magic numbers for the i860? */
+ internal_a.magic = 0;
+#define __A_MAGIC_SET__
+#endif /* I860 */
+#ifdef I960
+ internal_a.magic = (magic == I960ROMAGIC ? NMAGIC : OMAGIC);
+#define __A_MAGIC_SET__
+#endif /* I960 */
+#if M88
+#define __A_MAGIC_SET__
+ internal_a.magic = PAGEMAGICBCS;
+#endif /* M88 */
+
+#if APOLLO_M68
+#define __A_MAGIC_SET__
+ internal_a.magic = APOLLO_COFF_VERSION_NUMBER;
+#endif
+
+#if defined(M68) || defined(WE32K) || defined(M68K)
+#define __A_MAGIC_SET__
+#if defined(LYNXOS)
+ internal_a.magic = LYNXCOFFMAGIC;
+#else
+#if defined(TARG_AUX)
+ internal_a.magic = (abfd->flags & D_PAGED ? PAGEMAGICPEXECPAGED :
+ abfd->flags & WP_TEXT ? PAGEMAGICPEXECSWAPPED :
+ PAGEMAGICEXECSWAPPED);
+#else
+#if defined (PAGEMAGICPEXECPAGED)
+ internal_a.magic = PAGEMAGICPEXECPAGED;
+#endif
+#endif /* TARG_AUX */
+#endif /* LYNXOS */
+#endif /* M68 || WE32K || M68K */
+
+#if defined(ARM)
+#define __A_MAGIC_SET__
+ internal_a.magic = ZMAGIC;
+#endif
+
+#if defined(PPC_PE)
+#define __A_MAGIC_SET__
+ internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
+#endif
+
+#if defined MCORE_PE
+#define __A_MAGIC_SET__
+ internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
+#endif
+
+#if defined(I386)
+#define __A_MAGIC_SET__
+#if defined(LYNXOS)
+ internal_a.magic = LYNXCOFFMAGIC;
+#else /* LYNXOS */
+ internal_a.magic = ZMAGIC;
+#endif /* LYNXOS */
+#endif /* I386 */
+
+#if defined(SPARC)
+#define __A_MAGIC_SET__
+#if defined(LYNXOS)
+ internal_a.magic = LYNXCOFFMAGIC;
+#endif /* LYNXOS */
+#endif /* SPARC */
+
+#ifdef RS6000COFF_C
+#define __A_MAGIC_SET__
+ internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
+ (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
+ RS6K_AOUTHDR_OMAGIC;
+#endif
+
+#ifndef __A_MAGIC_SET__
+#include "Your aouthdr magic number is not being set!"
+#else
+#undef __A_MAGIC_SET__
+#endif
+ }
+
+ /* FIXME: Does anybody ever set this to another value? */
+ internal_a.vstamp = 0;
+
+ /* Now should write relocs, strings, syms */
+ obj_sym_filepos (abfd) = sym_base;
+
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ int firstundef;
+#if 0
+ if (!coff_add_missing_symbols (abfd))
+ return false;
+#endif
+ if (!coff_renumber_symbols (abfd, &firstundef))
+ return false;
+ coff_mangle_symbols (abfd);
+ if (! coff_write_symbols (abfd))
+ return false;
+ if (! coff_write_linenumbers (abfd))
+ return false;
+ if (! coff_write_relocs (abfd, firstundef))
+ return false;
+ }
+#ifdef COFF_LONG_SECTION_NAMES
+ else if (long_section_names)
+ {
+ /* If we have long section names we have to write out the string
+ table even if there are no symbols. */
+ if (! coff_write_symbols (abfd))
+ return false;
+ }
+#endif
+#ifdef COFF_IMAGE_WITH_PE
+#ifdef PPC_PE
+ else if ((abfd->flags & EXEC_P) != 0)
+ {
+ bfd_byte b;
+
+ /* PowerPC PE appears to require that all executable files be
+ rounded up to the page size. */
+ b = 0;
+ if (bfd_seek (abfd,
+ BFD_ALIGN (sym_base, COFF_PAGE_SIZE) - 1,
+ SEEK_SET) != 0
+ || bfd_write (&b, 1, 1, abfd) != 1)
+ return false;
+ }
+#endif
+#endif
+
+ /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
+ backend linker, and obj_raw_syment_count is not valid until after
+ coff_write_symbols is called. */
+ if (obj_raw_syment_count (abfd) != 0)
+ {
+ internal_f.f_symptr = sym_base;
+#ifdef RS6000COFF_C
+ /* AIX appears to require that F_RELFLG not be set if there are
+ local symbols but no relocations. */
+ internal_f.f_flags &=~ F_RELFLG;
+#endif
+ }
+ else
+ {
+ if (long_section_names)
+ internal_f.f_symptr = sym_base;
+ else
+ internal_f.f_symptr = 0;
+ internal_f.f_flags |= F_LSYMS;
+ }
+
+ if (text_sec)
+ {
+ internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
+ internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
+ }
+ if (data_sec)
+ {
+ internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
+ internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
+ }
+ if (bss_sec)
+ {
+ internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
+ if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
+ internal_a.data_start = bss_sec->vma;
+ }
+
+ internal_a.entry = bfd_get_start_address (abfd);
+ internal_f.f_nsyms = obj_raw_syment_count (abfd);
+
+#ifdef RS6000COFF_C
+ if (xcoff_data (abfd)->full_aouthdr)
+ {
+ bfd_vma toc;
+ asection *loader_sec;
+
+ internal_a.vstamp = 1;
+
+ internal_a.o_snentry = xcoff_data (abfd)->snentry;
+ if (internal_a.o_snentry == 0)
+ internal_a.entry = (bfd_vma) -1;
+
+ if (text_sec != NULL)
+ {
+ internal_a.o_sntext = text_sec->target_index;
+ internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
+ }
+ else
+ {
+ internal_a.o_sntext = 0;
+ internal_a.o_algntext = 0;
+ }
+ if (data_sec != NULL)
+ {
+ internal_a.o_sndata = data_sec->target_index;
+ internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
+ }
+ else
+ {
+ internal_a.o_sndata = 0;
+ internal_a.o_algndata = 0;
+ }
+ loader_sec = bfd_get_section_by_name (abfd, ".loader");
+ if (loader_sec != NULL)
+ internal_a.o_snloader = loader_sec->target_index;
+ else
+ internal_a.o_snloader = 0;
+ if (bss_sec != NULL)
+ internal_a.o_snbss = bss_sec->target_index;
+ else
+ internal_a.o_snbss = 0;
+
+ toc = xcoff_data (abfd)->toc;
+ internal_a.o_toc = toc;
+ internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
+
+ internal_a.o_modtype = xcoff_data (abfd)->modtype;
+ if (xcoff_data (abfd)->cputype != -1)
+ internal_a.o_cputype = xcoff_data (abfd)->cputype;
+ else
+ {
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_rs6000:
+ internal_a.o_cputype = 4;
+ break;
+ case bfd_arch_powerpc:
+ if (bfd_get_mach (abfd) == 0)
+ internal_a.o_cputype = 3;
+ else
+ internal_a.o_cputype = 1;
+ break;
+ default:
+ abort ();
+ }
+ }
+ internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
+ internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
+ }
+#endif
+
+ /* now write them */
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+ {
+ char buff[FILHSZ];
+ coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) buff);
+ if (bfd_write ((PTR) buff, 1, FILHSZ, abfd) != FILHSZ)
+ return false;
+ }
+ if (abfd->flags & EXEC_P)
+ {
+ /* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
+ include/coff/pe.h sets AOUTSZ == sizeof(PEAOUTHDR)) */
+ char buff[AOUTSZ];
+ coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff);
+ if (bfd_write ((PTR) buff, 1, AOUTSZ, abfd) != AOUTSZ)
+ return false;
+ }
+#ifdef RS6000COFF_C
+ else
+ {
+ AOUTHDR buff;
+ size_t size;
+
+ /* XCOFF seems to always write at least a small a.out header. */
+ coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) &buff);
+ if (xcoff_data (abfd)->full_aouthdr)
+ size = AOUTSZ;
+ else
+ size = SMALL_AOUTSZ;
+ if (bfd_write ((PTR) &buff, 1, size, abfd) != size)
+ return false;
+ }
+#endif
+
+ return true;
+}
+
+static boolean
+coff_set_section_contents (abfd, section, location, offset, count)
+ bfd * abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (abfd->output_has_begun == false) /* set by bfd.c handler */
+ {
+ if (! coff_compute_section_file_positions (abfd))
+ return false;
+ }
+
+#if defined(_LIB) && !defined(TARG_AUX)
+
+ /* The physical address field of a .lib section is used to hold the
+ number of shared libraries in the section. This code counts the
+ number of sections being written, and increments the lma field
+ with the number.
+
+ I have found no documentation on the contents of this section.
+ Experimentation indicates that the section contains zero or more
+ records, each of which has the following structure:
+
+ - a (four byte) word holding the length of this record, in words,
+ - a word that always seems to be set to "2",
+ - the path to a shared library, null-terminated and then padded
+ to a whole word boundary.
+
+ bfd_assert calls have been added to alert if an attempt is made
+ to write a section which doesn't follow these assumptions. The
+ code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
+ <robertl@arnet.com> (Thanks!).
+
+ Gvran Uddeborg <gvran@uddeborg.pp.se> */
+
+ if (strcmp (section->name, _LIB) == 0)
+ {
+ bfd_byte *rec, *recend;
+
+ rec = (bfd_byte *) location;
+ recend = rec + count;
+ while (rec < recend)
+ {
+ ++section->lma;
+ rec += bfd_get_32 (abfd, rec) * 4;
+ }
+
+ BFD_ASSERT (rec == recend);
+ }
+
+#endif
+
+ /* Don't write out bss sections - one way to do this is to
+ see if the filepos has not been set. */
+ if (section->filepos == 0)
+ return true;
+
+ if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0)
+ return false;
+
+ if (count != 0)
+ {
+ return (bfd_write (location, 1, count, abfd) == count) ? true : false;
+ }
+ return true;
+}
+#if 0
+static boolean
+coff_close_and_cleanup (abfd)
+ bfd *abfd;
+{
+ if (!bfd_read_p (abfd))
+ switch (abfd->format)
+ {
+ case bfd_archive:
+ if (!_bfd_write_archive_contents (abfd))
+ return false;
+ break;
+ case bfd_object:
+ if (!coff_write_object_contents (abfd))
+ return false;
+ break;
+ default:
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ /* We depend on bfd_close to free all the memory on the objalloc. */
+ return true;
+}
+
+#endif
+
+static PTR
+buy_and_read (abfd, where, seek_direction, size)
+ bfd *abfd;
+ file_ptr where;
+ int seek_direction;
+ size_t size;
+{
+ PTR area = (PTR) bfd_alloc (abfd, size);
+ if (!area)
+ return (NULL);
+ if (bfd_seek (abfd, where, seek_direction) != 0
+ || bfd_read (area, 1, size, abfd) != size)
+ return (NULL);
+ return (area);
+} /* buy_and_read() */
+
+/*
+SUBSUBSECTION
+ Reading linenumbers
+
+ Creating the linenumber table is done by reading in the entire
+ coff linenumber table, and creating another table for internal use.
+
+ A coff linenumber table is structured so that each function
+ is marked as having a line number of 0. Each line within the
+ function is an offset from the first line in the function. The
+ base of the line number information for the table is stored in
+ the symbol associated with the function.
+
+ The information is copied from the external to the internal
+ table, and each symbol which marks a function is marked by
+ pointing its...
+
+ How does this work ?
+
+*/
+
+static boolean
+coff_slurp_line_table (abfd, asect)
+ bfd *abfd;
+ asection *asect;
+{
+ LINENO *native_lineno;
+ alent *lineno_cache;
+
+ BFD_ASSERT (asect->lineno == (alent *) NULL);
+
+ native_lineno = (LINENO *) buy_and_read (abfd,
+ asect->line_filepos,
+ SEEK_SET,
+ (size_t) (LINESZ *
+ asect->lineno_count));
+ lineno_cache =
+ (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
+ if (lineno_cache == NULL)
+ return false;
+ else
+ {
+ unsigned int counter = 0;
+ alent *cache_ptr = lineno_cache;
+ LINENO *src = native_lineno;
+
+ while (counter < asect->lineno_count)
+ {
+ struct internal_lineno dst;
+ coff_swap_lineno_in (abfd, src, &dst);
+ cache_ptr->line_number = dst.l_lnno;
+
+ if (cache_ptr->line_number == 0)
+ {
+ boolean warned;
+ long symndx;
+ coff_symbol_type *sym;
+
+ warned = false;
+ symndx = dst.l_addr.l_symndx;
+ if (symndx < 0
+ || (unsigned long) symndx >= obj_raw_syment_count (abfd))
+ {
+ (*_bfd_error_handler)
+ (_("%s: warning: illegal symbol index %ld in line numbers"),
+ bfd_get_filename (abfd), dst.l_addr.l_symndx);
+ symndx = 0;
+ warned = true;
+ }
+ /* FIXME: We should not be casting between ints and
+ pointers like this. */
+ sym = ((coff_symbol_type *)
+ ((symndx + obj_raw_syments (abfd))
+ ->u.syment._n._n_n._n_zeroes));
+ cache_ptr->u.sym = (asymbol *) sym;
+ if (sym->lineno != NULL && ! warned)
+ {
+ (*_bfd_error_handler)
+ (_("%s: warning: duplicate line number information for `%s'"),
+ bfd_get_filename (abfd),
+ bfd_asymbol_name (&sym->symbol));
+ }
+ sym->lineno = cache_ptr;
+ }
+ else
+ {
+ cache_ptr->u.offset = dst.l_addr.l_paddr
+ - bfd_section_vma (abfd, asect);
+ } /* If no linenumber expect a symbol index */
+
+ cache_ptr++;
+ src++;
+ counter++;
+ }
+ cache_ptr->line_number = 0;
+
+ }
+ asect->lineno = lineno_cache;
+ /* FIXME, free native_lineno here, or use alloca or something. */
+ return true;
+}
+
+static boolean
+coff_slurp_symbol_table (abfd)
+ bfd * abfd;
+{
+ combined_entry_type *native_symbols;
+ coff_symbol_type *cached_area;
+ unsigned int *table_ptr;
+
+ unsigned int number_of_symbols = 0;
+
+ if (obj_symbols (abfd))
+ return true;
+
+ /* Read in the symbol table */
+ if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
+ {
+ return (false);
+ } /* on error */
+
+ /* Allocate enough room for all the symbols in cached form */
+ cached_area = ((coff_symbol_type *)
+ bfd_alloc (abfd,
+ (obj_raw_syment_count (abfd)
+ * sizeof (coff_symbol_type))));
+
+ if (cached_area == NULL)
+ return false;
+ table_ptr = ((unsigned int *)
+ bfd_alloc (abfd,
+ (obj_raw_syment_count (abfd)
+ * sizeof (unsigned int))));
+
+ if (table_ptr == NULL)
+ return false;
+ else
+ {
+ coff_symbol_type *dst = cached_area;
+ unsigned int last_native_index = obj_raw_syment_count (abfd);
+ unsigned int this_index = 0;
+ while (this_index < last_native_index)
+ {
+ combined_entry_type *src = native_symbols + this_index;
+ table_ptr[this_index] = number_of_symbols;
+ dst->symbol.the_bfd = abfd;
+
+ dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
+ /* We use the native name field to point to the cached field. */
+ src->u.syment._n._n_n._n_zeroes = (long) dst;
+ dst->symbol.section = coff_section_from_bfd_index (abfd,
+ src->u.syment.n_scnum);
+ dst->symbol.flags = 0;
+ dst->done_lineno = false;
+
+ switch (src->u.syment.n_sclass)
+ {
+#ifdef I960
+ case C_LEAFEXT:
+#if 0
+ dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma;
+ dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
+ dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
+#endif
+ /* Fall through to next case */
+
+#endif
+
+ case C_EXT:
+ case C_WEAKEXT:
+#if defined ARM
+ case C_THUMBEXT:
+ case C_THUMBEXTFUNC:
+#endif
+#ifdef RS6000COFF_C
+ case C_HIDEXT:
+#endif
+#ifdef C_SYSTEM
+ case C_SYSTEM: /* System Wide variable */
+#endif
+#ifdef COFF_WITH_PE
+ /* PE uses storage class 0x68 to denote a section symbol */
+ case C_SECTION:
+ /* PE uses storage class 0x69 for a weak external symbol. */
+ case C_NT_WEAK:
+#endif
+ if ((src->u.syment.n_scnum) == 0)
+ {
+ if ((src->u.syment.n_value) == 0)
+ {
+ dst->symbol.section = bfd_und_section_ptr;
+ dst->symbol.value = 0;
+ }
+ else
+ {
+ dst->symbol.section = bfd_com_section_ptr;
+ dst->symbol.value = (src->u.syment.n_value);
+ }
+ }
+ else
+ {
+ /* Base the value as an index from the base of the
+ section */
+
+ dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
+
+#if defined COFF_WITH_PE
+ /* PE sets the symbol to a value relative to the
+ start of the section. */
+ dst->symbol.value = src->u.syment.n_value;
+#else
+ dst->symbol.value = (src->u.syment.n_value
+ - dst->symbol.section->vma);
+#endif
+
+ if (ISFCN ((src->u.syment.n_type)))
+ {
+ /* A function ext does not go at the end of a
+ file. */
+ dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
+ }
+ }
+
+#ifdef RS6000COFF_C
+ /* A C_HIDEXT symbol is not global. */
+ if (src->u.syment.n_sclass == C_HIDEXT)
+ dst->symbol.flags = BSF_LOCAL;
+ /* A symbol with a csect entry should not go at the end. */
+ if (src->u.syment.n_numaux > 0)
+ dst->symbol.flags |= BSF_NOT_AT_END;
+#endif
+
+#ifdef COFF_WITH_PE
+ if (src->u.syment.n_sclass == C_NT_WEAK)
+ dst->symbol.flags = BSF_WEAK;
+#endif
+
+ if (src->u.syment.n_sclass == C_WEAKEXT)
+ dst->symbol.flags = BSF_WEAK;
+
+ break;
+
+ case C_STAT: /* static */
+#ifdef I960
+ case C_LEAFSTAT: /* static leaf procedure */
+#endif
+#if defined ARM
+ case C_THUMBSTAT: /* Thumb static */
+ case C_THUMBLABEL: /* Thumb label */
+ case C_THUMBSTATFUNC:/* Thumb static function */
+#endif
+ case C_LABEL: /* label */
+ if (src->u.syment.n_scnum == -2)
+ dst->symbol.flags = BSF_DEBUGGING;
+ else
+ dst->symbol.flags = BSF_LOCAL;
+
+ /* Base the value as an index from the base of the
+ section, if there is one. */
+ if (dst->symbol.section)
+ {
+#if defined COFF_WITH_PE
+ /* PE sets the symbol to a value relative to the
+ start of the section. */
+ dst->symbol.value = src->u.syment.n_value;
+#else
+ dst->symbol.value = (src->u.syment.n_value
+ - dst->symbol.section->vma);
+#endif
+ }
+ else
+ dst->symbol.value = src->u.syment.n_value;
+ break;
+
+ case C_MOS: /* member of structure */
+ case C_EOS: /* end of structure */
+#ifdef NOTDEF /* C_AUTOARG has the same value */
+#ifdef C_GLBLREG
+ case C_GLBLREG: /* A29k-specific storage class */
+#endif
+#endif
+ case C_REGPARM: /* register parameter */
+ case C_REG: /* register variable */
+#ifndef TIC80COFF
+#ifdef C_AUTOARG
+ case C_AUTOARG: /* 960-specific storage class */
+#endif
+#endif
+ case C_TPDEF: /* type definition */
+ case C_ARG:
+ case C_AUTO: /* automatic variable */
+ case C_FIELD: /* bit field */
+ case C_ENTAG: /* enumeration tag */
+ case C_MOE: /* member of enumeration */
+ case C_MOU: /* member of union */
+ case C_UNTAG: /* union tag */
+ dst->symbol.flags = BSF_DEBUGGING;
+ dst->symbol.value = (src->u.syment.n_value);
+ break;
+
+ case C_FILE: /* file name */
+ case C_STRTAG: /* structure tag */
+#ifdef RS6000COFF_C
+ case C_GSYM:
+ case C_LSYM:
+ case C_PSYM:
+ case C_RSYM:
+ case C_RPSYM:
+ case C_STSYM:
+ case C_BCOMM:
+ case C_ECOMM:
+ case C_DECL:
+ case C_ENTRY:
+ case C_FUN:
+ case C_ESTAT:
+#endif
+ dst->symbol.flags = BSF_DEBUGGING;
+ dst->symbol.value = (src->u.syment.n_value);
+ break;
+
+#ifdef RS6000COFF_C
+ case C_BINCL: /* beginning of include file */
+ case C_EINCL: /* ending of include file */
+ /* The value is actually a pointer into the line numbers
+ of the file. We locate the line number entry, and
+ set the section to the section which contains it, and
+ the value to the index in that section. */
+ {
+ asection *sec;
+
+ dst->symbol.flags = BSF_DEBUGGING;
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
+ && ((file_ptr) (sec->line_filepos
+ + sec->lineno_count * LINESZ)
+ > (file_ptr) src->u.syment.n_value))
+ break;
+ if (sec == NULL)
+ dst->symbol.value = 0;
+ else
+ {
+ dst->symbol.section = sec;
+ dst->symbol.value = ((src->u.syment.n_value
+ - sec->line_filepos)
+ / LINESZ);
+ src->fix_line = 1;
+ }
+ }
+ break;
+
+ case C_BSTAT:
+ dst->symbol.flags = BSF_DEBUGGING;
+
+ /* The value is actually a symbol index. Save a pointer
+ to the symbol instead of the index. FIXME: This
+ should use a union. */
+ src->u.syment.n_value =
+ (long) (native_symbols + src->u.syment.n_value);
+ dst->symbol.value = src->u.syment.n_value;
+ src->fix_value = 1;
+ break;
+#endif
+
+ case C_BLOCK: /* ".bb" or ".eb" */
+ case C_FCN: /* ".bf" or ".ef" */
+ case C_EFCN: /* physical end of function */
+ dst->symbol.flags = BSF_LOCAL;
+#if defined COFF_WITH_PE
+ /* PE sets the symbol to a value relative to the start
+ of the section. */
+ dst->symbol.value = src->u.syment.n_value;
+#else
+ /* Base the value as an index from the base of the
+ section. */
+ dst->symbol.value = (src->u.syment.n_value
+ - dst->symbol.section->vma);
+#endif
+ break;
+
+ case C_NULL:
+ case C_EXTDEF: /* external definition */
+ case C_ULABEL: /* undefined label */
+ case C_USTATIC: /* undefined static */
+#ifndef COFF_WITH_PE
+ /* C_LINE in regular coff is 0x68. NT has taken over this storage
+ class to represent a section symbol */
+ case C_LINE: /* line # reformatted as symbol table entry */
+ /* NT uses 0x67 for a weak symbol, not C_ALIAS. */
+ case C_ALIAS: /* duplicate tag */
+#endif
+ /* New storage classes for TIc80 */
+#ifdef TIC80COFF
+ case C_UEXT: /* Tentative external definition */
+#endif
+ case C_STATLAB: /* Static load time label */
+ case C_EXTLAB: /* External load time label */
+ case C_HIDDEN: /* ext symbol in dmert public lib */
+ default:
+ (*_bfd_error_handler)
+ (_("%s: Unrecognized storage class %d for %s symbol `%s'"),
+ bfd_get_filename (abfd), src->u.syment.n_sclass,
+ dst->symbol.section->name, dst->symbol.name);
+ dst->symbol.flags = BSF_DEBUGGING;
+ dst->symbol.value = (src->u.syment.n_value);
+ break;
+ }
+
+/* BFD_ASSERT(dst->symbol.flags != 0);*/
+
+ dst->native = src;
+
+ dst->symbol.udata.i = 0;
+ dst->lineno = (alent *) NULL;
+ this_index += (src->u.syment.n_numaux) + 1;
+ dst++;
+ number_of_symbols++;
+ } /* walk the native symtab */
+ } /* bfdize the native symtab */
+
+ obj_symbols (abfd) = cached_area;
+ obj_raw_syments (abfd) = native_symbols;
+
+ bfd_get_symcount (abfd) = number_of_symbols;
+ obj_convert (abfd) = table_ptr;
+ /* Slurp the line tables for each section too */
+ {
+ asection *p;
+ p = abfd->sections;
+ while (p)
+ {
+ coff_slurp_line_table (abfd, p);
+ p = p->next;
+ }
+ }
+ return true;
+} /* coff_slurp_symbol_table() */
+
+/* Check whether a symbol is globally visible. This is used by the
+ COFF backend linker code in cofflink.c, since a couple of targets
+ have globally visible symbols which are not class C_EXT. This
+ function need not handle the case of n_class == C_EXT. */
+
+#undef OTHER_GLOBAL_CLASS
+
+#ifdef I960
+#define OTHER_GLOBAL_CLASS C_LEAFEXT
+#endif
+
+#ifdef COFFARM
+#define OTHER_GLOBAL_CLASS C_THUMBEXT || syment->n_sclass == C_THUMBEXTFUNC
+#else
+#ifdef COFF_WITH_PE
+#define OTHER_GLOBAL_CLASS C_SECTION
+#endif
+#endif
+
+#ifdef OTHER_GLOBAL_CLASS
+
+static boolean coff_sym_is_global PARAMS ((bfd *, struct internal_syment *));
+
+static boolean
+coff_sym_is_global (abfd, syment)
+ bfd * abfd;
+ struct internal_syment * syment;
+{
+ return (syment->n_sclass == OTHER_GLOBAL_CLASS);
+}
+
+#undef OTHER_GLOBAL_CLASS
+
+#else /* ! defined (OTHER_GLOBAL_CLASS) */
+
+/* sym_is_global should not be defined if it has nothing to do. */
+
+#define coff_sym_is_global 0
+
+#endif /* ! defined (OTHER_GLOBAL_CLASS) */
+
+/*
+SUBSUBSECTION
+ Reading relocations
+
+ Coff relocations are easily transformed into the internal BFD form
+ (@code{arelent}).
+
+ Reading a coff relocation table is done in the following stages:
+
+ o Read the entire coff relocation table into memory.
+
+ o Process each relocation in turn; first swap it from the
+ external to the internal form.
+
+ o Turn the symbol referenced in the relocation's symbol index
+ into a pointer into the canonical symbol table.
+ This table is the same as the one returned by a call to
+ @code{bfd_canonicalize_symtab}. The back end will call that
+ routine and save the result if a canonicalization hasn't been done.
+
+ o The reloc index is turned into a pointer to a howto
+ structure, in a back end specific way. For instance, the 386
+ and 960 use the @code{r_type} to directly produce an index
+ into a howto table vector; the 88k subtracts a number from the
+ @code{r_type} field and creates an addend field.
+
+
+*/
+
+#ifndef CALC_ADDEND
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = 0; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ }
+#endif
+
+static boolean
+coff_slurp_reloc_table (abfd, asect, symbols)
+ bfd * abfd;
+ sec_ptr asect;
+ asymbol ** symbols;
+{
+ RELOC *native_relocs;
+ arelent *reloc_cache;
+ arelent *cache_ptr;
+
+ unsigned int idx;
+
+ if (asect->relocation)
+ return true;
+ if (asect->reloc_count == 0)
+ return true;
+ if (asect->flags & SEC_CONSTRUCTOR)
+ return true;
+ if (!coff_slurp_symbol_table (abfd))
+ return false;
+ native_relocs =
+ (RELOC *) buy_and_read (abfd,
+ asect->rel_filepos,
+ SEEK_SET,
+ (size_t) (RELSZ *
+ asect->reloc_count));
+ reloc_cache = (arelent *)
+ bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
+
+ if (reloc_cache == NULL)
+ return false;
+
+
+ for (idx = 0; idx < asect->reloc_count; idx++)
+ {
+ struct internal_reloc dst;
+ struct external_reloc *src;
+#ifndef RELOC_PROCESSING
+ asymbol *ptr;
+#endif
+
+ cache_ptr = reloc_cache + idx;
+ src = native_relocs + idx;
+
+ coff_swap_reloc_in (abfd, src, &dst);
+
+#ifdef RELOC_PROCESSING
+ RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
+#else
+ cache_ptr->address = dst.r_vaddr;
+
+ if (dst.r_symndx != -1)
+ {
+ if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
+ {
+ (*_bfd_error_handler)
+ (_("%s: warning: illegal symbol index %ld in relocs"),
+ bfd_get_filename (abfd), dst.r_symndx);
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ ptr = NULL;
+ }
+ else
+ {
+ cache_ptr->sym_ptr_ptr = (symbols
+ + obj_convert (abfd)[dst.r_symndx]);
+ ptr = *(cache_ptr->sym_ptr_ptr);
+ }
+ }
+ else
+ {
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ ptr = NULL;
+ }
+
+ /* The symbols definitions that we have read in have been
+ relocated as if their sections started at 0. But the offsets
+ refering to the symbols in the raw data have not been
+ modified, so we have to have a negative addend to compensate.
+
+ Note that symbols which used to be common must be left alone */
+
+ /* Calculate any reloc addend by looking at the symbol */
+ CALC_ADDEND (abfd, ptr, dst, cache_ptr);
+
+ cache_ptr->address -= asect->vma;
+/* !! cache_ptr->section = (asection *) NULL;*/
+
+ /* Fill in the cache_ptr->howto field from dst.r_type */
+ RTYPE2HOWTO (cache_ptr, &dst);
+#endif /* RELOC_PROCESSING */
+
+ if (cache_ptr->howto == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: illegal relocation type %d at address 0x%lx"),
+ bfd_get_filename (abfd), dst.r_type, (long) dst.r_vaddr);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ asect->relocation = reloc_cache;
+ return true;
+}
+
+#ifndef coff_rtype_to_howto
+#ifdef RTYPE2HOWTO
+
+/* Get the howto structure for a reloc. This is only used if the file
+ including this one defines coff_relocate_section to be
+ _bfd_coff_generic_relocate_section, so it is OK if it does not
+ always work. It is the responsibility of the including file to
+ make sure it is reasonable if it is needed. */
+
+static reloc_howto_type *coff_rtype_to_howto
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
+
+/*ARGSUSED*/
+static reloc_howto_type *
+coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+ bfd *abfd;
+ asection *sec;
+ struct internal_reloc *rel;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma *addendp;
+{
+ arelent genrel;
+
+ RTYPE2HOWTO (&genrel, rel);
+ return genrel.howto;
+}
+
+#else /* ! defined (RTYPE2HOWTO) */
+
+#define coff_rtype_to_howto NULL
+
+#endif /* ! defined (RTYPE2HOWTO) */
+#endif /* ! defined (coff_rtype_to_howto) */
+
+/* This is stupid. This function should be a boolean predicate. */
+static long
+coff_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd * abfd;
+ sec_ptr section;
+ arelent ** relptr;
+ asymbol ** symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count = 0;
+
+
+ if (section->flags & SEC_CONSTRUCTOR)
+ {
+ /* this section has relocs made up by us, they are not in the
+ file, so take them out of their chain and place them into
+ the data area provided */
+ arelent_chain *chain = section->constructor_chain;
+ for (count = 0; count < section->reloc_count; count++)
+ {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+
+ }
+ else
+ {
+ if (! coff_slurp_reloc_table (abfd, section, symbols))
+ return -1;
+
+ tblptr = section->relocation;
+
+ for (; count++ < section->reloc_count;)
+ *relptr++ = tblptr++;
+
+
+ }
+ *relptr = 0;
+ return section->reloc_count;
+}
+
+#ifdef GNU960
+file_ptr
+coff_sym_filepos (abfd)
+ bfd *abfd;
+{
+ return obj_sym_filepos (abfd);
+}
+#endif
+
+#ifndef coff_reloc16_estimate
+#define coff_reloc16_estimate dummy_reloc16_estimate
+
+static int dummy_reloc16_estimate
+ PARAMS ((bfd *, asection *, arelent *, unsigned int,
+ struct bfd_link_info *));
+
+static int
+dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
+ bfd *abfd;
+ asection *input_section;
+ arelent *reloc;
+ unsigned int shrink;
+ struct bfd_link_info *link_info;
+{
+ abort ();
+}
+
+#endif
+
+#ifndef coff_reloc16_extra_cases
+
+#define coff_reloc16_extra_cases dummy_reloc16_extra_cases
+
+/* This works even if abort is not declared in any header file. */
+
+static void dummy_reloc16_extra_cases
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
+ bfd_byte *, unsigned int *, unsigned int *));
+
+static void
+dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
+ dst_ptr)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ arelent *reloc;
+ bfd_byte *data;
+ unsigned int *src_ptr;
+ unsigned int *dst_ptr;
+{
+ abort ();
+}
+#endif
+
+/* If coff_relocate_section is defined, we can use the optimized COFF
+ backend linker. Otherwise we must continue to use the old linker. */
+#ifdef coff_relocate_section
+#ifndef coff_bfd_link_hash_table_create
+#define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create
+#endif
+#ifndef coff_bfd_link_add_symbols
+#define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols
+#endif
+#ifndef coff_bfd_final_link
+#define coff_bfd_final_link _bfd_coff_final_link
+#endif
+#else /* ! defined (coff_relocate_section) */
+#define coff_relocate_section NULL
+#ifndef coff_bfd_link_hash_table_create
+#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#endif
+#ifndef coff_bfd_link_add_symbols
+#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#endif
+#define coff_bfd_final_link _bfd_generic_final_link
+#endif /* ! defined (coff_relocate_section) */
+
+#define coff_bfd_link_split_section _bfd_generic_link_split_section
+
+#ifndef coff_start_final_link
+#define coff_start_final_link NULL
+#endif
+
+#ifndef coff_adjust_symndx
+#define coff_adjust_symndx NULL
+#endif
+
+#ifndef coff_link_add_one_symbol
+#define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol
+#endif
+
+#ifndef coff_link_output_has_begun
+
+static boolean coff_link_output_has_begun
+ PARAMS ((bfd *, struct coff_final_link_info *));
+
+static boolean
+coff_link_output_has_begun (abfd, info)
+ bfd * abfd;
+ struct coff_final_link_info * info;
+{
+ return abfd->output_has_begun;
+}
+#endif
+
+#ifndef coff_final_link_postscript
+
+static boolean coff_final_link_postscript
+ PARAMS ((bfd *, struct coff_final_link_info *));
+
+static boolean
+coff_final_link_postscript (abfd, pfinfo)
+ bfd * abfd;
+ struct coff_final_link_info * pfinfo;
+{
+ return true;
+}
+#endif
+
+#ifndef coff_SWAP_aux_in
+#define coff_SWAP_aux_in coff_swap_aux_in
+#endif
+#ifndef coff_SWAP_sym_in
+#define coff_SWAP_sym_in coff_swap_sym_in
+#endif
+#ifndef coff_SWAP_lineno_in
+#define coff_SWAP_lineno_in coff_swap_lineno_in
+#endif
+#ifndef coff_SWAP_aux_out
+#define coff_SWAP_aux_out coff_swap_aux_out
+#endif
+#ifndef coff_SWAP_sym_out
+#define coff_SWAP_sym_out coff_swap_sym_out
+#endif
+#ifndef coff_SWAP_lineno_out
+#define coff_SWAP_lineno_out coff_swap_lineno_out
+#endif
+#ifndef coff_SWAP_reloc_out
+#define coff_SWAP_reloc_out coff_swap_reloc_out
+#endif
+#ifndef coff_SWAP_filehdr_out
+#define coff_SWAP_filehdr_out coff_swap_filehdr_out
+#endif
+#ifndef coff_SWAP_aouthdr_out
+#define coff_SWAP_aouthdr_out coff_swap_aouthdr_out
+#endif
+#ifndef coff_SWAP_scnhdr_out
+#define coff_SWAP_scnhdr_out coff_swap_scnhdr_out
+#endif
+#ifndef coff_SWAP_reloc_in
+#define coff_SWAP_reloc_in coff_swap_reloc_in
+#endif
+#ifndef coff_SWAP_filehdr_in
+#define coff_SWAP_filehdr_in coff_swap_filehdr_in
+#endif
+#ifndef coff_SWAP_aouthdr_in
+#define coff_SWAP_aouthdr_in coff_swap_aouthdr_in
+#endif
+#ifndef coff_SWAP_scnhdr_in
+#define coff_SWAP_scnhdr_in coff_swap_scnhdr_in
+#endif
+
+
+
+static CONST bfd_coff_backend_data bfd_coff_std_swap_table =
+{
+ coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
+ coff_SWAP_aux_out, coff_SWAP_sym_out,
+ coff_SWAP_lineno_out, coff_SWAP_reloc_out,
+ coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
+ coff_SWAP_scnhdr_out,
+ FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ,
+#ifdef COFF_LONG_FILENAMES
+ true,
+#else
+ false,
+#endif
+#ifdef COFF_LONG_SECTION_NAMES
+ true,
+#else
+ false,
+#endif
+ COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
+ coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
+ coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
+ coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
+ coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
+ coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
+ coff_sym_is_global, coff_compute_section_file_positions,
+ coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
+ coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_link_output_has_begun, coff_final_link_postscript
+};
+
+#ifndef coff_close_and_cleanup
+#define coff_close_and_cleanup _bfd_generic_close_and_cleanup
+#endif
+
+#ifndef coff_bfd_free_cached_info
+#define coff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#endif
+
+#ifndef coff_get_section_contents
+#define coff_get_section_contents _bfd_generic_get_section_contents
+#endif
+
+#ifndef coff_bfd_copy_private_symbol_data
+#define coff_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#endif
+
+#ifndef coff_bfd_copy_private_section_data
+#define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
+#endif
+
+#ifndef coff_bfd_copy_private_bfd_data
+#define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
+#endif
+
+#ifndef coff_bfd_merge_private_bfd_data
+#define coff_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#endif
+
+#ifndef coff_bfd_set_private_flags
+#define coff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+#endif
+
+#ifndef coff_bfd_print_private_bfd_data
+#define coff_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
+#endif
+
+#ifndef coff_bfd_is_local_label_name
+#define coff_bfd_is_local_label_name _bfd_coff_is_local_label_name
+#endif
+
+#ifndef coff_read_minisymbols
+#define coff_read_minisymbols _bfd_generic_read_minisymbols
+#endif
+
+#ifndef coff_minisymbol_to_symbol
+#define coff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+#endif
+
+/* The reloc lookup routine must be supplied by each individual COFF
+ backend. */
+#ifndef coff_bfd_reloc_type_lookup
+#define coff_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+#endif
+
+#ifndef coff_bfd_get_relocated_section_contents
+#define coff_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#endif
+
+#ifndef coff_bfd_relax_section
+#define coff_bfd_relax_section bfd_generic_relax_section
+#endif
+
+#ifndef coff_bfd_gc_sections
+#define coff_bfd_gc_sections bfd_generic_gc_sections
+#endif
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
new file mode 100644
index 00000000000..df413833bd3
--- /dev/null
+++ b/bfd/coffgen.c
@@ -0,0 +1,2378 @@
+/* Support for the generic parts of COFF, for BFD.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Most of this hacked by Steve Chamberlain, sac@cygnus.com.
+ Split out of coffcode.h by Ian Taylor, ian@cygnus.com. */
+
+/* This file contains COFF code that is not dependent on any
+ particular COFF target. There is only one version of this file in
+ libbfd.a, so no target specific code may be put in here. Or, to
+ put it another way,
+
+ ********** DO NOT PUT TARGET SPECIFIC CODE IN THIS FILE **********
+
+ If you need to add some target specific behaviour, add a new hook
+ function to bfd_coff_backend_data.
+
+ Some of these functions are also called by the ECOFF routines.
+ Those functions may not use any COFF specific information, such as
+ coff_data (abfd). */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+static void coff_fix_symbol_name
+ PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_size_type *,
+ asection **, bfd_size_type *));
+static boolean coff_write_symbol
+ PARAMS ((bfd *, asymbol *, combined_entry_type *, unsigned int *,
+ bfd_size_type *, asection **, bfd_size_type *));
+static boolean coff_write_alien_symbol
+ PARAMS ((bfd *, asymbol *, unsigned int *, bfd_size_type *,
+ asection **, bfd_size_type *));
+static boolean coff_write_native_symbol
+ PARAMS ((bfd *, coff_symbol_type *, unsigned int *, bfd_size_type *,
+ asection **, bfd_size_type *));
+static void coff_pointerize_aux
+ PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
+ unsigned int, combined_entry_type *));
+static boolean make_a_section_from_file
+ PARAMS ((bfd *, struct internal_scnhdr *, unsigned int));
+static const bfd_target *coff_real_object_p
+ PARAMS ((bfd *, unsigned, struct internal_filehdr *,
+ struct internal_aouthdr *));
+static void fixup_symbol_value
+ PARAMS ((bfd *, coff_symbol_type *, struct internal_syment *));
+static char *build_debug_section
+ PARAMS ((bfd *));
+static char *copy_name
+ PARAMS ((bfd *, char *, int));
+
+#define STRING_SIZE_SIZE (4)
+
+/* Take a section header read from a coff file (in HOST byte order),
+ and make a BFD "section" out of it. This is used by ECOFF. */
+static boolean
+make_a_section_from_file (abfd, hdr, target_index)
+ bfd *abfd;
+ struct internal_scnhdr *hdr;
+ unsigned int target_index;
+{
+ asection *return_section;
+ char *name;
+
+ name = NULL;
+
+ /* Handle long section names as in PE. */
+ if (bfd_coff_long_section_names (abfd)
+ && hdr->s_name[0] == '/')
+ {
+ char buf[SCNNMLEN];
+ long strindex;
+ char *p;
+ const char *strings;
+
+ memcpy (buf, hdr->s_name + 1, SCNNMLEN - 1);
+ buf[SCNNMLEN - 1] = '\0';
+ strindex = strtol (buf, &p, 10);
+ if (*p == '\0' && strindex >= 0)
+ {
+ strings = _bfd_coff_read_string_table (abfd);
+ if (strings == NULL)
+ return false;
+ /* FIXME: For extra safety, we should make sure that
+ strindex does not run us past the end, but right now we
+ don't know the length of the string table. */
+ strings += strindex;
+ name = bfd_alloc (abfd, strlen (strings) + 1);
+ if (name == NULL)
+ return false;
+ strcpy (name, strings);
+ }
+ }
+
+ if (name == NULL)
+ {
+ /* Assorted wastage to null-terminate the name, thanks AT&T! */
+ name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
+ if (name == NULL)
+ return false;
+ strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
+ name[sizeof (hdr->s_name)] = 0;
+ }
+
+ return_section = bfd_make_section_anyway (abfd, name);
+ if (return_section == NULL)
+ return false;
+
+ return_section->vma = hdr->s_vaddr;
+ return_section->lma = hdr->s_paddr;
+ return_section->_raw_size = hdr->s_size;
+ return_section->filepos = hdr->s_scnptr;
+ return_section->rel_filepos = hdr->s_relptr;
+ return_section->reloc_count = hdr->s_nreloc;
+
+ bfd_coff_set_alignment_hook (abfd, return_section, hdr);
+
+ return_section->line_filepos = hdr->s_lnnoptr;
+
+ return_section->lineno_count = hdr->s_nlnno;
+ return_section->userdata = NULL;
+ return_section->next = (asection *) NULL;
+ return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name);
+
+ return_section->target_index = target_index;
+
+ /* At least on i386-coff, the line number count for a shared library
+ section must be ignored. */
+ if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
+ return_section->lineno_count = 0;
+
+ if (hdr->s_nreloc != 0)
+ return_section->flags |= SEC_RELOC;
+ /* FIXME: should this check 'hdr->s_size > 0' */
+ if (hdr->s_scnptr != 0)
+ return_section->flags |= SEC_HAS_CONTENTS;
+ return true;
+}
+
+/* Read in a COFF object and make it into a BFD. This is used by
+ ECOFF as well. */
+
+static const bfd_target *
+coff_real_object_p (abfd, nscns, internal_f, internal_a)
+ bfd *abfd;
+ unsigned nscns;
+ struct internal_filehdr *internal_f;
+ struct internal_aouthdr *internal_a;
+{
+ flagword oflags = abfd->flags;
+ bfd_vma ostart = bfd_get_start_address (abfd);
+ PTR tdata;
+ size_t readsize; /* length of file_info */
+ unsigned int scnhsz;
+ char *external_sections;
+
+ if (!(internal_f->f_flags & F_RELFLG))
+ abfd->flags |= HAS_RELOC;
+ if ((internal_f->f_flags & F_EXEC))
+ abfd->flags |= EXEC_P;
+ if (!(internal_f->f_flags & F_LNNO))
+ abfd->flags |= HAS_LINENO;
+ if (!(internal_f->f_flags & F_LSYMS))
+ abfd->flags |= HAS_LOCALS;
+
+ /* FIXME: How can we set D_PAGED correctly? */
+ if ((internal_f->f_flags & F_EXEC) != 0)
+ abfd->flags |= D_PAGED;
+
+ bfd_get_symcount (abfd) = internal_f->f_nsyms;
+ if (internal_f->f_nsyms)
+ abfd->flags |= HAS_SYMS;
+
+ if (internal_a != (struct internal_aouthdr *) NULL)
+ bfd_get_start_address (abfd) = internal_a->entry;
+ else
+ bfd_get_start_address (abfd) = 0;
+
+ /* Set up the tdata area. ECOFF uses its own routine, and overrides
+ abfd->flags. */
+ tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a);
+ if (tdata == NULL)
+ return 0;
+
+ scnhsz = bfd_coff_scnhsz (abfd);
+ readsize = nscns * scnhsz;
+ external_sections = (char *) bfd_alloc (abfd, readsize);
+ if (!external_sections)
+ goto fail;
+
+ if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
+ goto fail;
+
+ /* Now copy data as required; construct all asections etc */
+ if (nscns != 0)
+ {
+ unsigned int i;
+ for (i = 0; i < nscns; i++)
+ {
+ struct internal_scnhdr tmp;
+ bfd_coff_swap_scnhdr_in (abfd,
+ (PTR) (external_sections + i * scnhsz),
+ (PTR) & tmp);
+ if (! make_a_section_from_file (abfd, &tmp, i + 1))
+ goto fail;
+ }
+ }
+
+ /* make_abs_section (abfd); */
+
+ if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
+ goto fail;
+
+ return abfd->xvec;
+
+ fail:
+ bfd_release (abfd, tdata);
+ abfd->flags = oflags;
+ bfd_get_start_address (abfd) = ostart;
+ return (const bfd_target *) NULL;
+}
+
+/* Turn a COFF file into a BFD, but fail with bfd_error_wrong_format if it is
+ not a COFF file. This is also used by ECOFF. */
+
+const bfd_target *
+coff_object_p (abfd)
+ bfd *abfd;
+{
+ unsigned int filhsz;
+ unsigned int aoutsz;
+ int nscns;
+ PTR filehdr;
+ struct internal_filehdr internal_f;
+ struct internal_aouthdr internal_a;
+
+ /* figure out how much to read */
+ filhsz = bfd_coff_filhsz (abfd);
+ aoutsz = bfd_coff_aoutsz (abfd);
+
+ filehdr = bfd_alloc (abfd, filhsz);
+ if (filehdr == NULL)
+ return 0;
+ if (bfd_read (filehdr, 1, filhsz, abfd) != filhsz)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f);
+ bfd_release (abfd, filehdr);
+
+ if (bfd_coff_bad_format_hook (abfd, &internal_f) == false)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ nscns = internal_f.f_nscns;
+
+ if (internal_f.f_opthdr)
+ {
+ PTR opthdr;
+
+ opthdr = bfd_alloc (abfd, aoutsz);
+ if (opthdr == NULL)
+ return 0;;
+ if (bfd_read (opthdr, 1, internal_f.f_opthdr, abfd)
+ != internal_f.f_opthdr)
+ {
+ return 0;
+ }
+ bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) &internal_a);
+ }
+
+ return coff_real_object_p (abfd, nscns, &internal_f,
+ (internal_f.f_opthdr != 0
+ ? &internal_a
+ : (struct internal_aouthdr *) NULL));
+}
+
+/* Get the BFD section from a COFF symbol section number. */
+
+asection *
+coff_section_from_bfd_index (abfd, index)
+ bfd *abfd;
+ int index;
+{
+ struct sec *answer = abfd->sections;
+
+ if (index == N_ABS)
+ return bfd_abs_section_ptr;
+ if (index == N_UNDEF)
+ return bfd_und_section_ptr;
+ if (index == N_DEBUG)
+ return bfd_abs_section_ptr;
+
+ while (answer)
+ {
+ if (answer->target_index == index)
+ return answer;
+ answer = answer->next;
+ }
+
+ /* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
+ has a bad symbol table in biglitpow.o. */
+ return bfd_und_section_ptr;
+}
+
+/* Get the upper bound of a COFF symbol table. */
+
+long
+coff_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ if (!bfd_coff_slurp_symbol_table (abfd))
+ return -1;
+
+ return (bfd_get_symcount (abfd) + 1) * (sizeof (coff_symbol_type *));
+}
+
+
+/* Canonicalize a COFF symbol table. */
+
+long
+coff_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ unsigned int counter;
+ coff_symbol_type *symbase;
+ coff_symbol_type **location = (coff_symbol_type **) alocation;
+
+ if (!bfd_coff_slurp_symbol_table (abfd))
+ return -1;
+
+ symbase = obj_symbols (abfd);
+ counter = bfd_get_symcount (abfd);
+ while (counter-- > 0)
+ *location++ = symbase++;
+
+ *location = NULL;
+
+ return bfd_get_symcount (abfd);
+}
+
+/* Get the name of a symbol. The caller must pass in a buffer of size
+ >= SYMNMLEN + 1. */
+
+const char *
+_bfd_coff_internal_syment_name (abfd, sym, buf)
+ bfd *abfd;
+ const struct internal_syment *sym;
+ char *buf;
+{
+ /* FIXME: It's not clear this will work correctly if sizeof
+ (_n_zeroes) != 4. */
+ if (sym->_n._n_n._n_zeroes != 0
+ || sym->_n._n_n._n_offset == 0)
+ {
+ memcpy (buf, sym->_n._n_name, SYMNMLEN);
+ buf[SYMNMLEN] = '\0';
+ return buf;
+ }
+ else
+ {
+ const char *strings;
+
+ BFD_ASSERT (sym->_n._n_n._n_offset >= STRING_SIZE_SIZE);
+ strings = obj_coff_strings (abfd);
+ if (strings == NULL)
+ {
+ strings = _bfd_coff_read_string_table (abfd);
+ if (strings == NULL)
+ return NULL;
+ }
+ return strings + sym->_n._n_n._n_offset;
+ }
+}
+
+/* Read in and swap the relocs. This returns a buffer holding the
+ relocs for section SEC in file ABFD. If CACHE is true and
+ INTERNAL_RELOCS is NULL, the relocs read in will be saved in case
+ the function is called again. If EXTERNAL_RELOCS is not NULL, it
+ is a buffer large enough to hold the unswapped relocs. If
+ INTERNAL_RELOCS is not NULL, it is a buffer large enough to hold
+ the swapped relocs. If REQUIRE_INTERNAL is true, then the return
+ value must be INTERNAL_RELOCS. The function returns NULL on error. */
+
+struct internal_reloc *
+_bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
+ require_internal, internal_relocs)
+ bfd *abfd;
+ asection *sec;
+ boolean cache;
+ bfd_byte *external_relocs;
+ boolean require_internal;
+ struct internal_reloc *internal_relocs;
+{
+ bfd_size_type relsz;
+ bfd_byte *free_external = NULL;
+ struct internal_reloc *free_internal = NULL;
+ bfd_byte *erel;
+ bfd_byte *erel_end;
+ struct internal_reloc *irel;
+
+ if (coff_section_data (abfd, sec) != NULL
+ && coff_section_data (abfd, sec)->relocs != NULL)
+ {
+ if (! require_internal)
+ return coff_section_data (abfd, sec)->relocs;
+ memcpy (internal_relocs, coff_section_data (abfd, sec)->relocs,
+ sec->reloc_count * sizeof (struct internal_reloc));
+ return internal_relocs;
+ }
+
+ relsz = bfd_coff_relsz (abfd);
+
+ if (external_relocs == NULL)
+ {
+ free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
+ if (free_external == NULL && sec->reloc_count > 0)
+ goto error_return;
+ external_relocs = free_external;
+ }
+
+ if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
+ || (bfd_read (external_relocs, relsz, sec->reloc_count, abfd)
+ != relsz * sec->reloc_count))
+ goto error_return;
+
+ if (internal_relocs == NULL)
+ {
+ free_internal = ((struct internal_reloc *)
+ bfd_malloc (sec->reloc_count
+ * sizeof (struct internal_reloc)));
+ if (free_internal == NULL && sec->reloc_count > 0)
+ goto error_return;
+ internal_relocs = free_internal;
+ }
+
+ /* Swap in the relocs. */
+ erel = external_relocs;
+ erel_end = erel + relsz * sec->reloc_count;
+ irel = internal_relocs;
+ for (; erel < erel_end; erel += relsz, irel++)
+ bfd_coff_swap_reloc_in (abfd, (PTR) erel, (PTR) irel);
+
+ if (free_external != NULL)
+ {
+ free (free_external);
+ free_external = NULL;
+ }
+
+ if (cache && free_internal != NULL)
+ {
+ if (coff_section_data (abfd, sec) == NULL)
+ {
+ sec->used_by_bfd =
+ (PTR) bfd_zalloc (abfd,
+ sizeof (struct coff_section_tdata));
+ if (sec->used_by_bfd == NULL)
+ goto error_return;
+ coff_section_data (abfd, sec)->contents = NULL;
+ }
+ coff_section_data (abfd, sec)->relocs = free_internal;
+ }
+
+ return internal_relocs;
+
+ error_return:
+ if (free_external != NULL)
+ free (free_external);
+ if (free_internal != NULL)
+ free (free_internal);
+ return NULL;
+}
+
+/* Set lineno_count for the output sections of a COFF file. */
+
+int
+coff_count_linenumbers (abfd)
+ bfd *abfd;
+{
+ unsigned int limit = bfd_get_symcount (abfd);
+ unsigned int i;
+ int total = 0;
+ asymbol **p;
+ asection *s;
+
+ if (limit == 0)
+ {
+ /* This may be from the backend linker, in which case the
+ lineno_count in the sections is correct. */
+ for (s = abfd->sections; s != NULL; s = s->next)
+ total += s->lineno_count;
+ return total;
+ }
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ BFD_ASSERT (s->lineno_count == 0);
+
+ for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
+ {
+ asymbol *q_maybe = *p;
+
+ if (bfd_asymbol_flavour (q_maybe) == bfd_target_coff_flavour)
+ {
+ coff_symbol_type *q = coffsymbol (q_maybe);
+
+ /* The AIX 4.1 compiler can sometimes generate line numbers
+ attached to debugging symbols. We try to simply ignore
+ those here. */
+ if (q->lineno != NULL
+ && q->symbol.section->owner != NULL)
+ {
+ /* This symbol has line numbers. Increment the owning
+ section's linenumber count. */
+ alent *l = q->lineno;
+
+ ++q->symbol.section->output_section->lineno_count;
+ ++total;
+ ++l;
+ while (l->line_number != 0)
+ {
+ ++total;
+ ++q->symbol.section->output_section->lineno_count;
+ ++l;
+ }
+ }
+ }
+ }
+
+ return total;
+}
+
+/* Takes a bfd and a symbol, returns a pointer to the coff specific
+ area of the symbol if there is one. */
+
+/*ARGSUSED*/
+coff_symbol_type *
+coff_symbol_from (ignore_abfd, symbol)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+{
+ if (bfd_asymbol_flavour (symbol) != bfd_target_coff_flavour)
+ return (coff_symbol_type *) NULL;
+
+ if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL)
+ return (coff_symbol_type *) NULL;
+
+ return (coff_symbol_type *) symbol;
+}
+
+static void
+fixup_symbol_value (abfd, coff_symbol_ptr, syment)
+ bfd *abfd;
+ coff_symbol_type *coff_symbol_ptr;
+ struct internal_syment *syment;
+{
+
+ /* Normalize the symbol flags */
+ if (bfd_is_com_section (coff_symbol_ptr->symbol.section))
+ {
+ /* a common symbol is undefined with a value */
+ syment->n_scnum = N_UNDEF;
+ syment->n_value = coff_symbol_ptr->symbol.value;
+ }
+ else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING)
+ {
+ syment->n_value = coff_symbol_ptr->symbol.value;
+ }
+ else if (bfd_is_und_section (coff_symbol_ptr->symbol.section))
+ {
+ syment->n_scnum = N_UNDEF;
+ syment->n_value = 0;
+ }
+ else
+ {
+ if (coff_symbol_ptr->symbol.section)
+ {
+ syment->n_scnum =
+ coff_symbol_ptr->symbol.section->output_section->target_index;
+
+ syment->n_value = (coff_symbol_ptr->symbol.value
+ + coff_symbol_ptr->symbol.section->output_offset);
+ if (! obj_pe (abfd))
+ syment->n_value +=
+ coff_symbol_ptr->symbol.section->output_section->vma;
+ }
+ else
+ {
+ BFD_ASSERT (0);
+ /* This can happen, but I don't know why yet (steve@cygnus.com) */
+ syment->n_scnum = N_ABS;
+ syment->n_value = coff_symbol_ptr->symbol.value;
+ }
+ }
+}
+
+/* Run through all the symbols in the symbol table and work out what
+ their indexes into the symbol table will be when output.
+
+ Coff requires that each C_FILE symbol points to the next one in the
+ chain, and that the last one points to the first external symbol. We
+ do that here too. */
+
+boolean
+coff_renumber_symbols (bfd_ptr, first_undef)
+ bfd *bfd_ptr;
+ int *first_undef;
+{
+ unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
+ asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
+ unsigned int native_index = 0;
+ struct internal_syment *last_file = (struct internal_syment *) NULL;
+ unsigned int symbol_index;
+
+ /* COFF demands that undefined symbols come after all other symbols.
+ Since we don't need to impose this extra knowledge on all our
+ client programs, deal with that here. Sort the symbol table;
+ just move the undefined symbols to the end, leaving the rest
+ alone. The O'Reilly book says that defined global symbols come
+ at the end before the undefined symbols, so we do that here as
+ well. */
+ /* @@ Do we have some condition we could test for, so we don't always
+ have to do this? I don't think relocatability is quite right, but
+ I'm not certain. [raeburn:19920508.1711EST] */
+ {
+ asymbol **newsyms;
+ unsigned int i;
+
+ newsyms = (asymbol **) bfd_alloc (bfd_ptr,
+ sizeof (asymbol *) * (symbol_count + 1));
+ if (!newsyms)
+ return false;
+ bfd_ptr->outsymbols = newsyms;
+ for (i = 0; i < symbol_count; i++)
+ if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
+ || (!bfd_is_und_section (symbol_ptr_ptr[i]->section)
+ && !bfd_is_com_section (symbol_ptr_ptr[i]->section)
+ && ((symbol_ptr_ptr[i]->flags & BSF_FUNCTION) != 0
+ || ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL | BSF_WEAK))
+ == 0))))
+ *newsyms++ = symbol_ptr_ptr[i];
+
+ for (i = 0; i < symbol_count; i++)
+ if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) == 0
+ && !bfd_is_und_section (symbol_ptr_ptr[i]->section)
+ && (bfd_is_com_section (symbol_ptr_ptr[i]->section)
+ || ((symbol_ptr_ptr[i]->flags & BSF_FUNCTION) == 0
+ && ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL | BSF_WEAK))
+ != 0))))
+ *newsyms++ = symbol_ptr_ptr[i];
+
+ *first_undef = newsyms - bfd_ptr->outsymbols;
+
+ for (i = 0; i < symbol_count; i++)
+ if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) == 0
+ && bfd_is_und_section (symbol_ptr_ptr[i]->section))
+ *newsyms++ = symbol_ptr_ptr[i];
+ *newsyms = (asymbol *) NULL;
+ symbol_ptr_ptr = bfd_ptr->outsymbols;
+ }
+
+ for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
+ {
+ coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
+ symbol_ptr_ptr[symbol_index]->udata.i = symbol_index;
+ if (coff_symbol_ptr && coff_symbol_ptr->native)
+ {
+ combined_entry_type *s = coff_symbol_ptr->native;
+ int i;
+
+ if (s->u.syment.n_sclass == C_FILE)
+ {
+ if (last_file != (struct internal_syment *) NULL)
+ last_file->n_value = native_index;
+ last_file = &(s->u.syment);
+ }
+ else
+ {
+
+ /* Modify the symbol values according to their section and
+ type */
+
+ fixup_symbol_value (bfd_ptr, coff_symbol_ptr, &(s->u.syment));
+ }
+ for (i = 0; i < s->u.syment.n_numaux + 1; i++)
+ s[i].offset = native_index++;
+ }
+ else
+ {
+ native_index++;
+ }
+ }
+ obj_conv_table_size (bfd_ptr) = native_index;
+
+ return true;
+}
+
+/* Run thorough the symbol table again, and fix it so that all
+ pointers to entries are changed to the entries' index in the output
+ symbol table. */
+
+void
+coff_mangle_symbols (bfd_ptr)
+ bfd *bfd_ptr;
+{
+ unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
+ asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
+ unsigned int symbol_index;
+
+ for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
+ {
+ coff_symbol_type *coff_symbol_ptr =
+ coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
+
+ if (coff_symbol_ptr && coff_symbol_ptr->native)
+ {
+ int i;
+ combined_entry_type *s = coff_symbol_ptr->native;
+
+ if (s->fix_value)
+ {
+ /* FIXME: We should use a union here. */
+ s->u.syment.n_value =
+ ((combined_entry_type *) s->u.syment.n_value)->offset;
+ s->fix_value = 0;
+ }
+ if (s->fix_line)
+ {
+ /* The value is the offset into the line number entries
+ for the symbol's section. On output, the symbol's
+ section should be N_DEBUG. */
+ s->u.syment.n_value =
+ (coff_symbol_ptr->symbol.section->output_section->line_filepos
+ + s->u.syment.n_value * bfd_coff_linesz (bfd_ptr));
+ coff_symbol_ptr->symbol.section =
+ coff_section_from_bfd_index (bfd_ptr, N_DEBUG);
+ BFD_ASSERT (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING);
+ }
+ for (i = 0; i < s->u.syment.n_numaux; i++)
+ {
+ combined_entry_type *a = s + i + 1;
+ if (a->fix_tag)
+ {
+ a->u.auxent.x_sym.x_tagndx.l =
+ a->u.auxent.x_sym.x_tagndx.p->offset;
+ a->fix_tag = 0;
+ }
+ if (a->fix_end)
+ {
+ a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l =
+ a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset;
+ a->fix_end = 0;
+ }
+ if (a->fix_scnlen)
+ {
+ a->u.auxent.x_csect.x_scnlen.l =
+ a->u.auxent.x_csect.x_scnlen.p->offset;
+ a->fix_scnlen = 0;
+ }
+ }
+ }
+ }
+}
+
+static void
+coff_fix_symbol_name (abfd, symbol, native, string_size_p,
+ debug_string_section_p, debug_string_size_p)
+ bfd *abfd;
+ asymbol *symbol;
+ combined_entry_type *native;
+ bfd_size_type *string_size_p;
+ asection **debug_string_section_p;
+ bfd_size_type *debug_string_size_p;
+{
+ unsigned int name_length;
+ union internal_auxent *auxent;
+ char *name = (char *) (symbol->name);
+
+ if (name == (char *) NULL)
+ {
+ /* coff symbols always have names, so we'll make one up */
+ symbol->name = "strange";
+ name = (char *) symbol->name;
+ }
+ name_length = strlen (name);
+
+ if (native->u.syment.n_sclass == C_FILE
+ && native->u.syment.n_numaux > 0)
+ {
+ strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN);
+ auxent = &(native + 1)->u.auxent;
+
+ if (bfd_coff_long_filenames (abfd))
+ {
+ if (name_length <= FILNMLEN)
+ {
+ strncpy (auxent->x_file.x_fname, name, FILNMLEN);
+ }
+ else
+ {
+ auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
+ auxent->x_file.x_n.x_zeroes = 0;
+ *string_size_p += name_length + 1;
+ }
+ }
+ else
+ {
+ strncpy (auxent->x_file.x_fname, name, FILNMLEN);
+ if (name_length > FILNMLEN)
+ {
+ name[FILNMLEN] = '\0';
+ }
+ }
+ }
+ else
+ {
+ if (name_length <= SYMNMLEN)
+ {
+ /* This name will fit into the symbol neatly */
+ strncpy (native->u.syment._n._n_name, symbol->name, SYMNMLEN);
+ }
+ else if (!bfd_coff_symname_in_debug (abfd, &native->u.syment))
+ {
+ native->u.syment._n._n_n._n_offset = (*string_size_p
+ + STRING_SIZE_SIZE);
+ native->u.syment._n._n_n._n_zeroes = 0;
+ *string_size_p += name_length + 1;
+ }
+ else
+ {
+ long filepos;
+ bfd_byte buf[2];
+
+ /* This name should be written into the .debug section. For
+ some reason each name is preceded by a two byte length
+ and also followed by a null byte. FIXME: We assume that
+ the .debug section has already been created, and that it
+ is large enough. */
+ if (*debug_string_section_p == (asection *) NULL)
+ *debug_string_section_p = bfd_get_section_by_name (abfd, ".debug");
+ filepos = bfd_tell (abfd);
+ bfd_put_16 (abfd, name_length + 1, buf);
+ if (!bfd_set_section_contents (abfd,
+ *debug_string_section_p,
+ (PTR) buf,
+ (file_ptr) *debug_string_size_p,
+ (bfd_size_type) 2)
+ || !bfd_set_section_contents (abfd,
+ *debug_string_section_p,
+ (PTR) symbol->name,
+ ((file_ptr) *debug_string_size_p
+ + 2),
+ (bfd_size_type) name_length + 1))
+ abort ();
+ if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
+ abort ();
+ native->u.syment._n._n_n._n_offset = *debug_string_size_p + 2;
+ native->u.syment._n._n_n._n_zeroes = 0;
+ *debug_string_size_p += name_length + 3;
+ }
+ }
+}
+
+/* We need to keep track of the symbol index so that when we write out
+ the relocs we can get the index for a symbol. This method is a
+ hack. FIXME. */
+
+#define set_index(symbol, idx) ((symbol)->udata.i = (idx))
+
+/* Write a symbol out to a COFF file. */
+
+static boolean
+coff_write_symbol (abfd, symbol, native, written, string_size_p,
+ debug_string_section_p, debug_string_size_p)
+ bfd *abfd;
+ asymbol *symbol;
+ combined_entry_type *native;
+ unsigned int *written;
+ bfd_size_type *string_size_p;
+ asection **debug_string_section_p;
+ bfd_size_type *debug_string_size_p;
+{
+ unsigned int numaux = native->u.syment.n_numaux;
+ int type = native->u.syment.n_type;
+ int class = native->u.syment.n_sclass;
+ PTR buf;
+ bfd_size_type symesz;
+
+ if (native->u.syment.n_sclass == C_FILE)
+ symbol->flags |= BSF_DEBUGGING;
+
+ if (symbol->flags & BSF_DEBUGGING
+ && bfd_is_abs_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_DEBUG;
+ }
+ else if (bfd_is_abs_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_ABS;
+ }
+ else if (bfd_is_und_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_UNDEF;
+ }
+ else
+ {
+ native->u.syment.n_scnum =
+ symbol->section->output_section->target_index;
+ }
+
+ coff_fix_symbol_name (abfd, symbol, native, string_size_p,
+ debug_string_section_p, debug_string_size_p);
+
+ symesz = bfd_coff_symesz (abfd);
+ buf = bfd_alloc (abfd, symesz);
+ if (!buf)
+ return false;
+ bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
+ if (bfd_write (buf, 1, symesz, abfd) != symesz)
+ return false;
+ bfd_release (abfd, buf);
+
+ if (native->u.syment.n_numaux > 0)
+ {
+ bfd_size_type auxesz;
+ unsigned int j;
+
+ auxesz = bfd_coff_auxesz (abfd);
+ buf = bfd_alloc (abfd, auxesz);
+ if (!buf)
+ return false;
+ for (j = 0; j < native->u.syment.n_numaux; j++)
+ {
+ bfd_coff_swap_aux_out (abfd,
+ &((native + j + 1)->u.auxent),
+ type,
+ class,
+ j,
+ native->u.syment.n_numaux,
+ buf);
+ if (bfd_write (buf, 1, auxesz, abfd) != auxesz)
+ return false;
+ }
+ bfd_release (abfd, buf);
+ }
+
+ /* Store the index for use when we write out the relocs. */
+ set_index (symbol, *written);
+
+ *written += numaux + 1;
+ return true;
+}
+
+/* Write out a symbol to a COFF file that does not come from a COFF
+ file originally. This symbol may have been created by the linker,
+ or we may be linking a non COFF file to a COFF file. */
+
+static boolean
+coff_write_alien_symbol (abfd, symbol, written, string_size_p,
+ debug_string_section_p, debug_string_size_p)
+ bfd *abfd;
+ asymbol *symbol;
+ unsigned int *written;
+ bfd_size_type *string_size_p;
+ asection **debug_string_section_p;
+ bfd_size_type *debug_string_size_p;
+{
+ combined_entry_type *native;
+ combined_entry_type dummy;
+
+ native = &dummy;
+ native->u.syment.n_type = T_NULL;
+ native->u.syment.n_flags = 0;
+ if (bfd_is_und_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_UNDEF;
+ native->u.syment.n_value = symbol->value;
+ }
+ else if (bfd_is_com_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_UNDEF;
+ native->u.syment.n_value = symbol->value;
+ }
+ else if (symbol->flags & BSF_DEBUGGING)
+ {
+ /* There isn't much point to writing out a debugging symbol
+ unless we are prepared to convert it into COFF debugging
+ format. So, we just ignore them. We must clobber the symbol
+ name to keep it from being put in the string table. */
+ symbol->name = "";
+ return true;
+ }
+ else
+ {
+ native->u.syment.n_scnum =
+ symbol->section->output_section->target_index;
+ native->u.syment.n_value = (symbol->value
+ + symbol->section->output_offset);
+ if (! obj_pe (abfd))
+ native->u.syment.n_value += symbol->section->output_section->vma;
+
+ /* Copy the any flags from the the file header into the symbol.
+ FIXME: Why? */
+ {
+ coff_symbol_type *c = coff_symbol_from (abfd, symbol);
+ if (c != (coff_symbol_type *) NULL)
+ native->u.syment.n_flags = bfd_asymbol_bfd (&c->symbol)->flags;
+ }
+ }
+
+ native->u.syment.n_type = 0;
+ if (symbol->flags & BSF_LOCAL)
+ native->u.syment.n_sclass = C_STAT;
+ else if (symbol->flags & BSF_WEAK)
+ native->u.syment.n_sclass = obj_pe (abfd) ? C_NT_WEAK : C_WEAKEXT;
+ else
+ native->u.syment.n_sclass = C_EXT;
+ native->u.syment.n_numaux = 0;
+
+ return coff_write_symbol (abfd, symbol, native, written, string_size_p,
+ debug_string_section_p, debug_string_size_p);
+}
+
+/* Write a native symbol to a COFF file. */
+
+static boolean
+coff_write_native_symbol (abfd, symbol, written, string_size_p,
+ debug_string_section_p, debug_string_size_p)
+ bfd *abfd;
+ coff_symbol_type *symbol;
+ unsigned int *written;
+ bfd_size_type *string_size_p;
+ asection **debug_string_section_p;
+ bfd_size_type *debug_string_size_p;
+{
+ combined_entry_type *native = symbol->native;
+ alent *lineno = symbol->lineno;
+
+ /* If this symbol has an associated line number, we must store the
+ symbol index in the line number field. We also tag the auxent to
+ point to the right place in the lineno table. */
+ if (lineno && !symbol->done_lineno && symbol->symbol.section->owner != NULL)
+ {
+ unsigned int count = 0;
+ lineno[count].u.offset = *written;
+ if (native->u.syment.n_numaux)
+ {
+ union internal_auxent *a = &((native + 1)->u.auxent);
+
+ a->x_sym.x_fcnary.x_fcn.x_lnnoptr =
+ symbol->symbol.section->output_section->moving_line_filepos;
+ }
+
+ /* Count and relocate all other linenumbers. */
+ count++;
+ while (lineno[count].line_number != 0)
+ {
+#if 0
+ /* 13 april 92. sac
+ I've been told this, but still need proof:
+ > The second bug is also in `bfd/coffcode.h'. This bug
+ > causes the linker to screw up the pc-relocations for
+ > all the line numbers in COFF code. This bug isn't only
+ > specific to A29K implementations, but affects all
+ > systems using COFF format binaries. Note that in COFF
+ > object files, the line number core offsets output by
+ > the assembler are relative to the start of each
+ > procedure, not to the start of the .text section. This
+ > patch relocates the line numbers relative to the
+ > `native->u.syment.n_value' instead of the section
+ > virtual address.
+ > modular!olson@cs.arizona.edu (Jon Olson)
+ */
+ lineno[count].u.offset += native->u.syment.n_value;
+#else
+ lineno[count].u.offset +=
+ (symbol->symbol.section->output_section->vma
+ + symbol->symbol.section->output_offset);
+#endif
+ count++;
+ }
+ symbol->done_lineno = true;
+
+ symbol->symbol.section->output_section->moving_line_filepos +=
+ count * bfd_coff_linesz (abfd);
+ }
+
+ return coff_write_symbol (abfd, &(symbol->symbol), native, written,
+ string_size_p, debug_string_section_p,
+ debug_string_size_p);
+}
+
+/* Write out the COFF symbols. */
+
+boolean
+coff_write_symbols (abfd)
+ bfd *abfd;
+{
+ bfd_size_type string_size;
+ asection *debug_string_section;
+ bfd_size_type debug_string_size;
+ unsigned int i;
+ unsigned int limit = bfd_get_symcount (abfd);
+ unsigned int written = 0;
+ asymbol **p;
+
+ string_size = 0;
+ debug_string_section = NULL;
+ debug_string_size = 0;
+
+ /* If this target supports long section names, they must be put into
+ the string table. This is supported by PE. This code must
+ handle section names just as they are handled in
+ coff_write_object_contents. */
+ if (bfd_coff_long_section_names (abfd))
+ {
+ asection *o;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ size_t len;
+
+ len = strlen (o->name);
+ if (len > SCNNMLEN)
+ string_size += len + 1;
+ }
+ }
+
+ /* Seek to the right place */
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
+ return false;
+
+ /* Output all the symbols we have */
+
+ written = 0;
+ for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
+ {
+ asymbol *symbol = *p;
+ coff_symbol_type *c_symbol = coff_symbol_from (abfd, symbol);
+
+ if (c_symbol == (coff_symbol_type *) NULL
+ || c_symbol->native == (combined_entry_type *) NULL)
+ {
+ if (!coff_write_alien_symbol (abfd, symbol, &written, &string_size,
+ &debug_string_section,
+ &debug_string_size))
+ return false;
+ }
+ else
+ {
+ if (!coff_write_native_symbol (abfd, c_symbol, &written,
+ &string_size, &debug_string_section,
+ &debug_string_size))
+ return false;
+ }
+ }
+
+ obj_raw_syment_count (abfd) = written;
+
+ /* Now write out strings */
+
+ if (string_size != 0)
+ {
+ unsigned int size = string_size + STRING_SIZE_SIZE;
+ bfd_byte buffer[STRING_SIZE_SIZE];
+
+#if STRING_SIZE_SIZE == 4
+ bfd_h_put_32 (abfd, size, buffer);
+#else
+ #error Change bfd_h_put_32
+#endif
+ if (bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd) != sizeof (buffer))
+ return false;
+
+ /* Handle long section names. This code must handle section
+ names just as they are handled in coff_write_object_contents. */
+ if (bfd_coff_long_section_names (abfd))
+ {
+ asection *o;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ size_t len;
+
+ len = strlen (o->name);
+ if (len > SCNNMLEN)
+ {
+ if (bfd_write (o->name, 1, len + 1, abfd) != len + 1)
+ return false;
+ }
+ }
+ }
+
+ for (p = abfd->outsymbols, i = 0;
+ i < limit;
+ i++, p++)
+ {
+ asymbol *q = *p;
+ size_t name_length = strlen (q->name);
+ coff_symbol_type *c_symbol = coff_symbol_from (abfd, q);
+ size_t maxlen;
+
+ /* Figure out whether the symbol name should go in the string
+ table. Symbol names that are short enough are stored
+ directly in the syment structure. File names permit a
+ different, longer, length in the syment structure. On
+ XCOFF, some symbol names are stored in the .debug section
+ rather than in the string table. */
+
+ if (c_symbol == NULL
+ || c_symbol->native == NULL)
+ {
+ /* This is not a COFF symbol, so it certainly is not a
+ file name, nor does it go in the .debug section. */
+ maxlen = SYMNMLEN;
+ }
+ else if (bfd_coff_symname_in_debug (abfd,
+ &c_symbol->native->u.syment))
+ {
+ /* This symbol name is in the XCOFF .debug section.
+ Don't write it into the string table. */
+ maxlen = name_length;
+ }
+ else if (c_symbol->native->u.syment.n_sclass == C_FILE
+ && c_symbol->native->u.syment.n_numaux > 0)
+ maxlen = FILNMLEN;
+ else
+ maxlen = SYMNMLEN;
+
+ if (name_length > maxlen)
+ {
+ if (bfd_write ((PTR) (q->name), 1, name_length + 1, abfd)
+ != name_length + 1)
+ return false;
+ }
+ }
+ }
+ else
+ {
+ /* We would normally not write anything here, but we'll write
+ out 4 so that any stupid coff reader which tries to read the
+ string table even when there isn't one won't croak. */
+ unsigned int size = STRING_SIZE_SIZE;
+ bfd_byte buffer[STRING_SIZE_SIZE];
+
+#if STRING_SIZE_SIZE == 4
+ bfd_h_put_32 (abfd, size, buffer);
+#else
+ #error Change bfd_h_put_32
+#endif
+ if (bfd_write ((PTR) buffer, 1, STRING_SIZE_SIZE, abfd)
+ != STRING_SIZE_SIZE)
+ return false;
+ }
+
+ /* Make sure the .debug section was created to be the correct size.
+ We should create it ourselves on the fly, but we don't because
+ BFD won't let us write to any section until we know how large all
+ the sections are. We could still do it by making another pass
+ over the symbols. FIXME. */
+ BFD_ASSERT (debug_string_size == 0
+ || (debug_string_section != (asection *) NULL
+ && (BFD_ALIGN (debug_string_size,
+ 1 << debug_string_section->alignment_power)
+ == bfd_section_size (abfd, debug_string_section))));
+
+ return true;
+}
+
+boolean
+coff_write_linenumbers (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ bfd_size_type linesz;
+ PTR buff;
+
+ linesz = bfd_coff_linesz (abfd);
+ buff = bfd_alloc (abfd, linesz);
+ if (!buff)
+ return false;
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ if (s->lineno_count)
+ {
+ asymbol **q = abfd->outsymbols;
+ if (bfd_seek (abfd, s->line_filepos, SEEK_SET) != 0)
+ return false;
+ /* Find all the linenumbers in this section */
+ while (*q)
+ {
+ asymbol *p = *q;
+ if (p->section->output_section == s)
+ {
+ alent *l =
+ BFD_SEND (bfd_asymbol_bfd (p), _get_lineno,
+ (bfd_asymbol_bfd (p), p));
+ if (l)
+ {
+ /* Found a linenumber entry, output */
+ struct internal_lineno out;
+ memset ((PTR) & out, 0, sizeof (out));
+ out.l_lnno = 0;
+ out.l_addr.l_symndx = l->u.offset;
+ bfd_coff_swap_lineno_out (abfd, &out, buff);
+ if (bfd_write (buff, 1, linesz, abfd) != linesz)
+ return false;
+ l++;
+ while (l->line_number)
+ {
+ out.l_lnno = l->line_number;
+ out.l_addr.l_symndx = l->u.offset;
+ bfd_coff_swap_lineno_out (abfd, &out, buff);
+ if (bfd_write (buff, 1, linesz, abfd) != linesz)
+ return false;
+ l++;
+ }
+ }
+ }
+ q++;
+ }
+ }
+ }
+ bfd_release (abfd, buff);
+ return true;
+}
+
+/*ARGSUSED */
+alent *
+coff_get_lineno (ignore_abfd, symbol)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+{
+ return coffsymbol (symbol)->lineno;
+}
+
+#if 0
+
+/* This is only called from coff_add_missing_symbols, which has been
+ disabled. */
+
+asymbol *
+coff_section_symbol (abfd, name)
+ bfd *abfd;
+ char *name;
+{
+ asection *sec = bfd_make_section_old_way (abfd, name);
+ asymbol *sym;
+ combined_entry_type *csym;
+
+ sym = sec->symbol;
+ csym = coff_symbol_from (abfd, sym)->native;
+ /* Make sure back-end COFF stuff is there. */
+ if (csym == 0)
+ {
+ struct foo
+ {
+ coff_symbol_type sym;
+ /* @@FIXME This shouldn't use a fixed size!! */
+ combined_entry_type e[10];
+ };
+ struct foo *f;
+ f = (struct foo *) bfd_alloc (abfd, sizeof (*f));
+ if (!f)
+ {
+ bfd_set_error (bfd_error_no_error);
+ return NULL;
+ }
+ memset ((char *) f, 0, sizeof (*f));
+ coff_symbol_from (abfd, sym)->native = csym = f->e;
+ }
+ csym[0].u.syment.n_sclass = C_STAT;
+ csym[0].u.syment.n_numaux = 1;
+/* SF_SET_STATICS (sym); @@ ??? */
+ csym[1].u.auxent.x_scn.x_scnlen = sec->_raw_size;
+ csym[1].u.auxent.x_scn.x_nreloc = sec->reloc_count;
+ csym[1].u.auxent.x_scn.x_nlinno = sec->lineno_count;
+
+ if (sec->output_section == NULL)
+ {
+ sec->output_section = sec;
+ sec->output_offset = 0;
+ }
+
+ return sym;
+}
+
+#endif /* 0 */
+
+/* This function transforms the offsets into the symbol table into
+ pointers to syments. */
+
+static void
+coff_pointerize_aux (abfd, table_base, symbol, indaux, auxent)
+ bfd *abfd;
+ combined_entry_type *table_base;
+ combined_entry_type *symbol;
+ unsigned int indaux;
+ combined_entry_type *auxent;
+{
+ unsigned int type = symbol->u.syment.n_type;
+ unsigned int class = symbol->u.syment.n_sclass;
+
+ if (coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
+ {
+ if ((*coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
+ (abfd, table_base, symbol, indaux, auxent))
+ return;
+ }
+
+ /* Don't bother if this is a file or a section */
+ if (class == C_STAT && type == T_NULL)
+ return;
+ if (class == C_FILE)
+ return;
+
+ /* Otherwise patch up */
+#define N_TMASK coff_data (abfd)->local_n_tmask
+#define N_BTSHFT coff_data (abfd)->local_n_btshft
+ if ((ISFCN (type) || ISTAG (class) || class == C_BLOCK || class == C_FCN)
+ && auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0)
+ {
+ auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p =
+ table_base + auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
+ auxent->fix_end = 1;
+ }
+ /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can
+ generate one, so we must be careful to ignore it. */
+ if (auxent->u.auxent.x_sym.x_tagndx.l > 0)
+ {
+ auxent->u.auxent.x_sym.x_tagndx.p =
+ table_base + auxent->u.auxent.x_sym.x_tagndx.l;
+ auxent->fix_tag = 1;
+ }
+}
+
+/* Allocate space for the ".debug" section, and read it.
+ We did not read the debug section until now, because
+ we didn't want to go to the trouble until someone needed it. */
+
+static char *
+build_debug_section (abfd)
+ bfd *abfd;
+{
+ char *debug_section;
+ long position;
+
+ asection *sect = bfd_get_section_by_name (abfd, ".debug");
+
+ if (!sect)
+ {
+ bfd_set_error (bfd_error_no_debug_section);
+ return NULL;
+ }
+
+ debug_section = (PTR) bfd_alloc (abfd,
+ bfd_get_section_size_before_reloc (sect));
+ if (debug_section == NULL)
+ return NULL;
+
+ /* Seek to the beginning of the `.debug' section and read it.
+ Save the current position first; it is needed by our caller.
+ Then read debug section and reset the file pointer. */
+
+ position = bfd_tell (abfd);
+ if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 0
+ || (bfd_read (debug_section,
+ bfd_get_section_size_before_reloc (sect), 1, abfd)
+ != bfd_get_section_size_before_reloc (sect))
+ || bfd_seek (abfd, position, SEEK_SET) != 0)
+ return NULL;
+ return debug_section;
+}
+
+
+/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be
+ \0-terminated, but will not exceed 'maxlen' characters. The copy *will*
+ be \0-terminated. */
+static char *
+copy_name (abfd, name, maxlen)
+ bfd *abfd;
+ char *name;
+ int maxlen;
+{
+ int len;
+ char *newname;
+
+ for (len = 0; len < maxlen; ++len)
+ {
+ if (name[len] == '\0')
+ {
+ break;
+ }
+ }
+
+ if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
+ return (NULL);
+ strncpy (newname, name, len);
+ newname[len] = '\0';
+ return newname;
+}
+
+/* Read in the external symbols. */
+
+boolean
+_bfd_coff_get_external_symbols (abfd)
+ bfd *abfd;
+{
+ bfd_size_type symesz;
+ size_t size;
+ PTR syms;
+
+ if (obj_coff_external_syms (abfd) != NULL)
+ return true;
+
+ symesz = bfd_coff_symesz (abfd);
+
+ size = obj_raw_syment_count (abfd) * symesz;
+
+ syms = (PTR) bfd_malloc (size);
+ if (syms == NULL && size != 0)
+ return false;
+
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+ || bfd_read (syms, size, 1, abfd) != size)
+ {
+ if (syms != NULL)
+ free (syms);
+ return false;
+ }
+
+ obj_coff_external_syms (abfd) = syms;
+
+ return true;
+}
+
+/* Read in the external strings. The strings are not loaded until
+ they are needed. This is because we have no simple way of
+ detecting a missing string table in an archive. */
+
+const char *
+_bfd_coff_read_string_table (abfd)
+ bfd *abfd;
+{
+ char extstrsize[STRING_SIZE_SIZE];
+ size_t strsize;
+ char *strings;
+
+ if (obj_coff_strings (abfd) != NULL)
+ return obj_coff_strings (abfd);
+
+ if (obj_sym_filepos (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return NULL;
+ }
+
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd)),
+ SEEK_SET) != 0)
+ return NULL;
+
+ if (bfd_read (extstrsize, sizeof extstrsize, 1, abfd) != sizeof extstrsize)
+ {
+ if (bfd_get_error () != bfd_error_file_truncated)
+ return NULL;
+
+ /* There is no string table. */
+ strsize = STRING_SIZE_SIZE;
+ }
+ else
+ {
+#if STRING_SIZE_SIZE == 4
+ strsize = bfd_h_get_32 (abfd, (bfd_byte *) extstrsize);
+#else
+ #error Change bfd_h_get_32
+#endif
+ }
+
+ if (strsize < STRING_SIZE_SIZE)
+ {
+ (*_bfd_error_handler)
+ (_("%s: bad string table size %lu"), bfd_get_filename (abfd),
+ (unsigned long) strsize);
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+ }
+
+ strings = (char *) bfd_malloc (strsize);
+ if (strings == NULL)
+ return NULL;
+
+ if (bfd_read (strings + STRING_SIZE_SIZE,
+ strsize - STRING_SIZE_SIZE, 1, abfd)
+ != strsize - STRING_SIZE_SIZE)
+ {
+ free (strings);
+ return NULL;
+ }
+
+ obj_coff_strings (abfd) = strings;
+
+ return strings;
+}
+
+/* Free up the external symbols and strings read from a COFF file. */
+
+boolean
+_bfd_coff_free_symbols (abfd)
+ bfd *abfd;
+{
+ if (obj_coff_external_syms (abfd) != NULL
+ && ! obj_coff_keep_syms (abfd))
+ {
+ free (obj_coff_external_syms (abfd));
+ obj_coff_external_syms (abfd) = NULL;
+ }
+ if (obj_coff_strings (abfd) != NULL
+ && ! obj_coff_keep_strings (abfd))
+ {
+ free (obj_coff_strings (abfd));
+ obj_coff_strings (abfd) = NULL;
+ }
+ return true;
+}
+
+/* Read a symbol table into freshly bfd_allocated memory, swap it, and
+ knit the symbol names into a normalized form. By normalized here I
+ mean that all symbols have an n_offset pointer that points to a null-
+ terminated string. */
+
+combined_entry_type *
+coff_get_normalized_symtab (abfd)
+ bfd *abfd;
+{
+ combined_entry_type *internal;
+ combined_entry_type *internal_ptr;
+ combined_entry_type *symbol_ptr;
+ combined_entry_type *internal_end;
+ bfd_size_type symesz;
+ char *raw_src;
+ char *raw_end;
+ const char *string_table = NULL;
+ char *debug_section = NULL;
+ unsigned long size;
+
+ if (obj_raw_syments (abfd) != NULL)
+ return obj_raw_syments (abfd);
+
+ size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
+ internal = (combined_entry_type *) bfd_zalloc (abfd, size);
+ if (internal == NULL && size != 0)
+ return NULL;
+ internal_end = internal + obj_raw_syment_count (abfd);
+
+ if (! _bfd_coff_get_external_symbols (abfd))
+ return NULL;
+
+ raw_src = (char *) obj_coff_external_syms (abfd);
+
+ /* mark the end of the symbols */
+ symesz = bfd_coff_symesz (abfd);
+ raw_end = (char *) raw_src + obj_raw_syment_count (abfd) * symesz;
+
+ /* FIXME SOMEDAY. A string table size of zero is very weird, but
+ probably possible. If one shows up, it will probably kill us. */
+
+ /* Swap all the raw entries */
+ for (internal_ptr = internal;
+ raw_src < raw_end;
+ raw_src += symesz, internal_ptr++)
+ {
+
+ unsigned int i;
+ bfd_coff_swap_sym_in (abfd, (PTR) raw_src,
+ (PTR) & internal_ptr->u.syment);
+ symbol_ptr = internal_ptr;
+
+ for (i = 0;
+ i < symbol_ptr->u.syment.n_numaux;
+ i++)
+ {
+ internal_ptr++;
+ raw_src += symesz;
+ bfd_coff_swap_aux_in (abfd, (PTR) raw_src,
+ symbol_ptr->u.syment.n_type,
+ symbol_ptr->u.syment.n_sclass,
+ i, symbol_ptr->u.syment.n_numaux,
+ &(internal_ptr->u.auxent));
+ coff_pointerize_aux (abfd, internal, symbol_ptr, i,
+ internal_ptr);
+ }
+ }
+
+ /* Free the raw symbols, but not the strings (if we have them). */
+ obj_coff_keep_strings (abfd) = true;
+ if (! _bfd_coff_free_symbols (abfd))
+ return NULL;
+
+ for (internal_ptr = internal; internal_ptr < internal_end;
+ internal_ptr++)
+ {
+ if (internal_ptr->u.syment.n_sclass == C_FILE
+ && internal_ptr->u.syment.n_numaux > 0)
+ {
+ /* make a file symbol point to the name in the auxent, since
+ the text ".file" is redundant */
+ if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0)
+ {
+ /* the filename is a long one, point into the string table */
+ if (string_table == NULL)
+ {
+ string_table = _bfd_coff_read_string_table (abfd);
+ if (string_table == NULL)
+ return NULL;
+ }
+
+ internal_ptr->u.syment._n._n_n._n_offset =
+ ((long)
+ (string_table
+ + (internal_ptr + 1)->u.auxent.x_file.x_n.x_offset));
+ }
+ else
+ {
+ /* ordinary short filename, put into memory anyway */
+ internal_ptr->u.syment._n._n_n._n_offset = (long)
+ copy_name (abfd, (internal_ptr + 1)->u.auxent.x_file.x_fname,
+ FILNMLEN);
+ }
+ }
+ else
+ {
+ if (internal_ptr->u.syment._n._n_n._n_zeroes != 0)
+ {
+ /* This is a "short" name. Make it long. */
+ unsigned long i = 0;
+ char *newstring = NULL;
+
+ /* find the length of this string without walking into memory
+ that isn't ours. */
+ for (i = 0; i < 8; ++i)
+ {
+ if (internal_ptr->u.syment._n._n_name[i] == '\0')
+ {
+ break;
+ } /* if end of string */
+ } /* possible lengths of this string. */
+
+ if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
+ return (NULL);
+ memset (newstring, 0, i);
+ strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
+ internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
+ internal_ptr->u.syment._n._n_n._n_zeroes = 0;
+ }
+ else if (internal_ptr->u.syment._n._n_n._n_offset == 0)
+ internal_ptr->u.syment._n._n_n._n_offset = (long int) "";
+ else if (!bfd_coff_symname_in_debug (abfd, &internal_ptr->u.syment))
+ {
+ /* Long name already. Point symbol at the string in the
+ table. */
+ if (string_table == NULL)
+ {
+ string_table = _bfd_coff_read_string_table (abfd);
+ if (string_table == NULL)
+ return NULL;
+ }
+ internal_ptr->u.syment._n._n_n._n_offset =
+ ((long int)
+ (string_table
+ + internal_ptr->u.syment._n._n_n._n_offset));
+ }
+ else
+ {
+ /* Long name in debug section. Very similar. */
+ if (debug_section == NULL)
+ debug_section = build_debug_section (abfd);
+ internal_ptr->u.syment._n._n_n._n_offset = (long int)
+ (debug_section + internal_ptr->u.syment._n._n_n._n_offset);
+ }
+ }
+ internal_ptr += internal_ptr->u.syment.n_numaux;
+ }
+
+ obj_raw_syments (abfd) = internal;
+ BFD_ASSERT (obj_raw_syment_count (abfd)
+ == (unsigned int) (internal_ptr - internal));
+
+ return (internal);
+} /* coff_get_normalized_symtab() */
+
+long
+coff_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ if (bfd_get_format (abfd) != bfd_object)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+ return (asect->reloc_count + 1) * sizeof (arelent *);
+}
+
+asymbol *
+coff_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
+ if (new == NULL)
+ return (NULL);
+ memset (new, 0, sizeof *new);
+ new->symbol.section = 0;
+ new->native = 0;
+ new->lineno = (alent *) NULL;
+ new->done_lineno = false;
+ new->symbol.the_bfd = abfd;
+ return &new->symbol;
+}
+
+/* Make a debugging symbol. */
+
+asymbol *
+coff_bfd_make_debug_symbol (abfd, ptr, sz)
+ bfd *abfd;
+ PTR ptr;
+ unsigned long sz;
+{
+ coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
+ if (new == NULL)
+ return (NULL);
+ /* @@ The 10 is a guess at a plausible maximum number of aux entries
+ (but shouldn't be a constant). */
+ new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
+ if (!new->native)
+ return (NULL);
+ new->symbol.section = bfd_abs_section_ptr;
+ new->symbol.flags = BSF_DEBUGGING;
+ new->lineno = (alent *) NULL;
+ new->done_lineno = false;
+ new->symbol.the_bfd = abfd;
+ return &new->symbol;
+}
+
+/*ARGSUSED */
+void
+coff_get_symbol_info (abfd, symbol, ret)
+ bfd *abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+ if (coffsymbol (symbol)->native != NULL
+ && coffsymbol (symbol)->native->fix_value)
+ {
+ combined_entry_type *psym;
+
+ psym = ((combined_entry_type *)
+ coffsymbol (symbol)->native->u.syment.n_value);
+ ret->value = (bfd_vma) (psym - obj_raw_syments (abfd));
+ }
+}
+
+/* Return the COFF syment for a symbol. */
+
+boolean
+bfd_coff_get_syment (abfd, symbol, psyment)
+ bfd *abfd;
+ asymbol *symbol;
+ struct internal_syment *psyment;
+{
+ coff_symbol_type *csym;
+
+ csym = coff_symbol_from (abfd, symbol);
+ if (csym == NULL || csym->native == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ *psyment = csym->native->u.syment;
+
+ if (csym->native->fix_value)
+ psyment->n_value = ((combined_entry_type *) psyment->n_value
+ - obj_raw_syments (abfd));
+
+ /* FIXME: We should handle fix_line here. */
+
+ return true;
+}
+
+/* Return the COFF auxent for a symbol. */
+
+boolean
+bfd_coff_get_auxent (abfd, symbol, indx, pauxent)
+ bfd *abfd;
+ asymbol *symbol;
+ int indx;
+ union internal_auxent *pauxent;
+{
+ coff_symbol_type *csym;
+ combined_entry_type *ent;
+
+ csym = coff_symbol_from (abfd, symbol);
+
+ if (csym == NULL
+ || csym->native == NULL
+ || indx >= csym->native->u.syment.n_numaux)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ ent = csym->native + indx + 1;
+
+ *pauxent = ent->u.auxent;
+
+ if (ent->fix_tag)
+ pauxent->x_sym.x_tagndx.l =
+ ((combined_entry_type *) pauxent->x_sym.x_tagndx.p
+ - obj_raw_syments (abfd));
+
+ if (ent->fix_end)
+ pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l =
+ ((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p
+ - obj_raw_syments (abfd));
+
+ if (ent->fix_scnlen)
+ pauxent->x_csect.x_scnlen.l =
+ ((combined_entry_type *) pauxent->x_csect.x_scnlen.p
+ - obj_raw_syments (abfd));
+
+ return true;
+}
+
+/* Print out information about COFF symbol. */
+
+void
+coff_print_symbol (abfd, filep, symbol, how)
+ bfd *abfd;
+ PTR filep;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) filep;
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+
+ case bfd_print_symbol_more:
+ fprintf (file, "coff %s %s",
+ coffsymbol (symbol)->native ? "n" : "g",
+ coffsymbol (symbol)->lineno ? "l" : " ");
+ break;
+
+ case bfd_print_symbol_all:
+ if (coffsymbol (symbol)->native)
+ {
+ unsigned long val;
+ unsigned int aux;
+ combined_entry_type *combined = coffsymbol (symbol)->native;
+ combined_entry_type *root = obj_raw_syments (abfd);
+ struct lineno_cache_entry *l = coffsymbol (symbol)->lineno;
+
+ fprintf (file, "[%3ld]", (long) (combined - root));
+
+ if (! combined->fix_value)
+ val = (unsigned long) combined->u.syment.n_value;
+ else
+ val = ((unsigned long)
+ ((combined_entry_type *) combined->u.syment.n_value
+ - root));
+
+ fprintf (file,
+ "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%08lx %s",
+ combined->u.syment.n_scnum,
+ combined->u.syment.n_flags,
+ combined->u.syment.n_type,
+ combined->u.syment.n_sclass,
+ combined->u.syment.n_numaux,
+ val,
+ symbol->name);
+
+ for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
+ {
+ combined_entry_type *auxp = combined + aux + 1;
+ long tagndx;
+
+ if (auxp->fix_tag)
+ tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root;
+ else
+ tagndx = auxp->u.auxent.x_sym.x_tagndx.l;
+
+ fprintf (file, "\n");
+
+ if (bfd_coff_print_aux (abfd, file, root, combined, auxp, aux))
+ continue;
+
+ switch (combined->u.syment.n_sclass)
+ {
+ case C_FILE:
+ fprintf (file, "File ");
+ break;
+
+ case C_STAT:
+ if (combined->u.syment.n_type == T_NULL)
+ /* probably a section symbol? */
+ {
+ fprintf (file, "AUX scnlen 0x%lx nreloc %d nlnno %d",
+ (long) auxp->u.auxent.x_scn.x_scnlen,
+ auxp->u.auxent.x_scn.x_nreloc,
+ auxp->u.auxent.x_scn.x_nlinno);
+ if (auxp->u.auxent.x_scn.x_checksum != 0
+ || auxp->u.auxent.x_scn.x_associated != 0
+ || auxp->u.auxent.x_scn.x_comdat != 0)
+ fprintf (file, " checksum 0x%lx assoc %d comdat %d",
+ auxp->u.auxent.x_scn.x_checksum,
+ auxp->u.auxent.x_scn.x_associated,
+ auxp->u.auxent.x_scn.x_comdat);
+ break;
+ }
+ /* else fall through */
+
+ default:
+ fprintf (file, "AUX lnno %d size 0x%x tagndx %ld",
+ auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
+ auxp->u.auxent.x_sym.x_misc.x_lnsz.x_size,
+ tagndx);
+ if (auxp->fix_end)
+ fprintf (file, " endndx %ld",
+ ((long)
+ (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
+ - root)));
+ break;
+ }
+ }
+
+ if (l)
+ {
+ fprintf (file, "\n%s :", l->u.sym->name);
+ l++;
+ while (l->line_number)
+ {
+ fprintf (file, "\n%4d : 0x%lx",
+ l->line_number,
+ ((unsigned long)
+ (l->u.offset + symbol->section->vma)));
+ l++;
+ }
+ }
+ }
+ else
+ {
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+ fprintf (file, " %-5s %s %s %s",
+ symbol->section->name,
+ coffsymbol (symbol)->native ? "n" : "g",
+ coffsymbol (symbol)->lineno ? "l" : " ",
+ symbol->name);
+ }
+ }
+}
+
+/* Return whether a symbol name implies a local symbol. In COFF,
+ local symbols generally start with ``.L''. Most targets use this
+ function for the is_local_label_name entry point, but some may
+ override it. */
+
+boolean
+_bfd_coff_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return name[0] == '.' && name[1] == 'L';
+}
+
+/* Provided a BFD, a section and an offset into the section, calculate
+ and return the name of the source file and the line nearest to the
+ wanted location. */
+
+/*ARGSUSED*/
+boolean
+coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
+ functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ boolean found;
+ unsigned int i;
+ unsigned int line_base;
+ coff_data_type *cof = coff_data (abfd);
+ /* Run through the raw syments if available */
+ combined_entry_type *p;
+ combined_entry_type *pend;
+ alent *l;
+ struct coff_section_tdata *sec_data;
+
+ /* Before looking through the symbol table, try to use a .stab
+ section to find the information. */
+ if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+ &found, filename_ptr,
+ functionname_ptr, line_ptr,
+ &coff_data (abfd)->line_info))
+ return false;
+ if (found)
+ return true;
+
+ *filename_ptr = 0;
+ *functionname_ptr = 0;
+ *line_ptr = 0;
+
+ /* Don't try and find line numbers in a non coff file */
+ if (abfd->xvec->flavour != bfd_target_coff_flavour)
+ return false;
+
+ if (cof == NULL)
+ return false;
+
+ /* Find the first C_FILE symbol. */
+ p = cof->raw_syments;
+ if (!p)
+ return false;
+
+ pend = p + cof->raw_syment_count;
+ while (p < pend)
+ {
+ if (p->u.syment.n_sclass == C_FILE)
+ break;
+ p += 1 + p->u.syment.n_numaux;
+ }
+
+ if (p < pend)
+ {
+ bfd_vma sec_vma;
+ bfd_vma maxdiff;
+
+ /* Look through the C_FILE symbols to find the best one. */
+ sec_vma = bfd_get_section_vma (abfd, section);
+ *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
+ maxdiff = (bfd_vma) 0 - (bfd_vma) 1;
+ while (1)
+ {
+ combined_entry_type *p2;
+
+ for (p2 = p + 1 + p->u.syment.n_numaux;
+ p2 < pend;
+ p2 += 1 + p2->u.syment.n_numaux)
+ {
+ if (p2->u.syment.n_scnum > 0
+ && (section
+ == coff_section_from_bfd_index (abfd,
+ p2->u.syment.n_scnum)))
+ break;
+ if (p2->u.syment.n_sclass == C_FILE)
+ {
+ p2 = pend;
+ break;
+ }
+ }
+
+ if (p2 < pend
+ && offset + sec_vma >= (bfd_vma) p2->u.syment.n_value
+ && offset + sec_vma - (bfd_vma) p2->u.syment.n_value < maxdiff)
+ {
+ *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
+ maxdiff = offset + sec_vma - p2->u.syment.n_value;
+ }
+
+ /* Avoid endless loops on erroneous files by ensuring that
+ we always move forward in the file. */
+ if (p - cof->raw_syments >= p->u.syment.n_value)
+ break;
+
+ p = cof->raw_syments + p->u.syment.n_value;
+ if (p > pend || p->u.syment.n_sclass != C_FILE)
+ break;
+ }
+ }
+
+ /* Now wander though the raw linenumbers of the section */
+ /* If we have been called on this section before, and the offset we
+ want is further down then we can prime the lookup loop. */
+ sec_data = coff_section_data (abfd, section);
+ if (sec_data != NULL
+ && sec_data->i > 0
+ && offset >= sec_data->offset)
+ {
+ i = sec_data->i;
+ *functionname_ptr = sec_data->function;
+ line_base = sec_data->line_base;
+ }
+ else
+ {
+ i = 0;
+ line_base = 0;
+ }
+
+ if (section->lineno != NULL)
+ {
+ l = &section->lineno[i];
+
+ for (; i < section->lineno_count; i++)
+ {
+ if (l->line_number == 0)
+ {
+ /* Get the symbol this line number points at */
+ coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym);
+ if (coff->symbol.value > offset)
+ break;
+ *functionname_ptr = coff->symbol.name;
+ if (coff->native)
+ {
+ combined_entry_type *s = coff->native;
+ s = s + 1 + s->u.syment.n_numaux;
+
+ /* In XCOFF a debugging symbol can follow the
+ function symbol. */
+ if (s->u.syment.n_scnum == N_DEBUG)
+ s = s + 1 + s->u.syment.n_numaux;
+
+ /* S should now point to the .bf of the function. */
+ if (s->u.syment.n_numaux)
+ {
+ /* The linenumber is stored in the auxent. */
+ union internal_auxent *a = &((s + 1)->u.auxent);
+ line_base = a->x_sym.x_misc.x_lnsz.x_lnno;
+ *line_ptr = line_base;
+ }
+ }
+ }
+ else
+ {
+ if (l->u.offset > offset)
+ break;
+ *line_ptr = l->line_number + line_base - 1;
+ }
+ l++;
+ }
+ }
+
+ /* Cache the results for the next call. */
+ if (sec_data == NULL && section->owner == abfd)
+ {
+ section->used_by_bfd =
+ ((PTR) bfd_zalloc (abfd,
+ sizeof (struct coff_section_tdata)));
+ sec_data = (struct coff_section_tdata *) section->used_by_bfd;
+ }
+ if (sec_data != NULL)
+ {
+ sec_data->offset = offset;
+ sec_data->i = i;
+ sec_data->function = *functionname_ptr;
+ sec_data->line_base = line_base;
+ }
+
+ return true;
+}
+
+int
+coff_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+ size_t size;
+
+ if (reloc == false)
+ {
+ size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
+ }
+ else
+ {
+ size = bfd_coff_filhsz (abfd);
+ }
+
+ size += abfd->section_count * bfd_coff_scnhsz (abfd);
+ return size;
+}
+
+/* Change the class of a coff symbol held by BFD. */
+boolean
+bfd_coff_set_symbol_class (abfd, symbol, class)
+ bfd * abfd;
+ asymbol * symbol;
+ unsigned int class;
+{
+ coff_symbol_type * csym;
+
+ csym = coff_symbol_from (abfd, symbol);
+ if (csym == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+ else if (csym->native == NULL)
+ {
+ /* This is an alien symbol which no native coff backend data.
+ We cheat here by creating a fake native entry for it and
+ then filling in the class. This code is based on that in
+ coff_write_alien_symbol(). */
+
+ combined_entry_type * native;
+
+ native = (combined_entry_type *) bfd_alloc (abfd, sizeof (* native));
+ if (native == NULL)
+ return false;
+
+ memset (native, 0, sizeof (* native));
+
+ native->u.syment.n_type = T_NULL;
+ native->u.syment.n_sclass = class;
+
+ if (bfd_is_und_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_UNDEF;
+ native->u.syment.n_value = symbol->value;
+ }
+ else if (bfd_is_com_section (symbol->section))
+ {
+ native->u.syment.n_scnum = N_UNDEF;
+ native->u.syment.n_value = symbol->value;
+ }
+ else
+ {
+ native->u.syment.n_scnum =
+ symbol->section->output_section->target_index;
+ native->u.syment.n_value = (symbol->value
+ + symbol->section->output_offset);
+ if (! obj_pe (abfd))
+ native->u.syment.n_value += symbol->section->output_section->vma;
+
+ /* Copy the any flags from the the file header into the symbol.
+ FIXME: Why? */
+ native->u.syment.n_flags = bfd_asymbol_bfd (& csym->symbol)->flags;
+ }
+
+ csym->native = native;
+ }
+ else
+ {
+ csym->native->u.syment.n_sclass = class;
+ }
+
+ return true;
+}
+
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
new file mode 100644
index 00000000000..cf56869fe65
--- /dev/null
+++ b/bfd/cofflink.c
@@ -0,0 +1,2752 @@
+/* COFF specific linker code.
+ Copyright 1994, 1995, 1996, 1997, 1998 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file contains the COFF backend linker code. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+static boolean coff_link_add_object_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean coff_link_check_archive_element
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *));
+static boolean coff_link_check_ar_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *));
+static boolean coff_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *));
+static char *dores_com PARAMS ((char *, bfd *, int));
+static char *get_name PARAMS ((char *, char **));
+static int process_embedded_commands
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *));
+static void mark_relocs PARAMS ((struct coff_final_link_info *, bfd *));
+
+/* Create an entry in a COFF linker hash table. */
+
+struct bfd_hash_entry *
+_bfd_coff_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct coff_link_hash_entry *ret = (struct coff_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct coff_link_hash_entry *) NULL)
+ ret = ((struct coff_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct coff_link_hash_entry)));
+ if (ret == (struct coff_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct coff_link_hash_entry *)
+ _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct coff_link_hash_entry *) NULL)
+ {
+ /* Set local fields. */
+ ret->indx = -1;
+ ret->type = T_NULL;
+ ret->class = C_NULL;
+ ret->numaux = 0;
+ ret->auxbfd = NULL;
+ ret->aux = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize a COFF linker hash table. */
+
+boolean
+_bfd_coff_link_hash_table_init (table, abfd, newfunc)
+ struct coff_link_hash_table *table;
+ bfd *abfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ table->stab_info = NULL;
+ return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+}
+
+/* Create a COFF linker hash table. */
+
+struct bfd_link_hash_table *
+_bfd_coff_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct coff_link_hash_table *ret;
+
+ ret = ((struct coff_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct coff_link_hash_table)));
+ if (ret == NULL)
+ return NULL;
+ if (! _bfd_coff_link_hash_table_init (ret, abfd,
+ _bfd_coff_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+ return &ret->root;
+}
+
+/* Create an entry in a COFF debug merge hash table. */
+
+struct bfd_hash_entry *
+_bfd_coff_debug_merge_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct coff_debug_merge_hash_entry *ret =
+ (struct coff_debug_merge_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct coff_debug_merge_hash_entry *) NULL)
+ ret = ((struct coff_debug_merge_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct coff_debug_merge_hash_entry)));
+ if (ret == (struct coff_debug_merge_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct coff_debug_merge_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+ if (ret != (struct coff_debug_merge_hash_entry *) NULL)
+ {
+ /* Set local fields. */
+ ret->types = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Given a COFF BFD, add symbols to the global hash table as
+ appropriate. */
+
+boolean
+_bfd_coff_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_object:
+ return coff_link_add_object_symbols (abfd, info);
+ case bfd_archive:
+ return (_bfd_generic_link_add_archive_symbols
+ (abfd, info, coff_link_check_archive_element));
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+}
+
+/* Add symbols from a COFF object file. */
+
+static boolean
+coff_link_add_object_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (! _bfd_coff_get_external_symbols (abfd))
+ return false;
+ if (! coff_link_add_symbols (abfd, info))
+ return false;
+
+ if (! info->keep_memory)
+ {
+ if (! _bfd_coff_free_symbols (abfd))
+ return false;
+ }
+ return true;
+}
+
+/* Check a single archive element to see if we need to include it in
+ the link. *PNEEDED is set according to whether this element is
+ needed in the link or not. This is called via
+ _bfd_generic_link_add_archive_symbols. */
+
+static boolean
+coff_link_check_archive_element (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ if (! _bfd_coff_get_external_symbols (abfd))
+ return false;
+
+ if (! coff_link_check_ar_symbols (abfd, info, pneeded))
+ return false;
+
+ if (*pneeded)
+ {
+ if (! coff_link_add_symbols (abfd, info))
+ return false;
+ }
+
+ if (! info->keep_memory || ! *pneeded)
+ {
+ if (! _bfd_coff_free_symbols (abfd))
+ return false;
+ }
+
+ return true;
+}
+
+/* Look through the symbols to see if this object file should be
+ included in the link. */
+
+static boolean
+coff_link_check_ar_symbols (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *));
+ bfd_size_type symesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
+
+ *pneeded = false;
+
+ sym_is_global = coff_backend_info (abfd)->_bfd_coff_sym_is_global;
+
+ symesz = bfd_coff_symesz (abfd);
+ esym = (bfd_byte *) obj_coff_external_syms (abfd);
+ esym_end = esym + obj_raw_syment_count (abfd) * symesz;
+ while (esym < esym_end)
+ {
+ struct internal_syment sym;
+
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
+
+ if ((sym.n_sclass == C_EXT
+ || sym.n_sclass == C_WEAKEXT
+ || (obj_pe (abfd) && sym.n_sclass == C_NT_WEAK)
+#ifdef C_SYSTEM
+ || sym.n_sclass == C_SYSTEM
+#endif
+ || (sym_is_global && (*sym_is_global) (abfd, &sym)))
+ && (sym.n_scnum != 0 || sym.n_value != 0))
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ struct bfd_link_hash_entry *h;
+
+ /* This symbol is externally visible, and is defined by this
+ object file. */
+
+ name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
+ if (name == NULL)
+ return false;
+ h = bfd_link_hash_lookup (info->hash, name, false, false, true);
+
+ /* We are only interested in symbols that are currently
+ undefined. If a symbol is currently known to be common,
+ COFF linkers do not bring in an object file which defines
+ it. */
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_undefined)
+ {
+ if (! (*info->callbacks->add_archive_element) (info, abfd, name))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+ }
+
+ esym += (sym.n_numaux + 1) * symesz;
+ }
+
+ /* We do not need this object file. */
+ return true;
+}
+
+/* Add all the symbols from an object file to the hash table. */
+
+static boolean
+coff_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *));
+ boolean keep_syms;
+ boolean default_copy;
+ bfd_size_type symcount;
+ struct coff_link_hash_entry **sym_hash;
+ bfd_size_type symesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
+
+ /* Keep the symbols during this function, in case the linker needs
+ to read the generic symbols in order to report an error message. */
+ keep_syms = obj_coff_keep_syms (abfd);
+ obj_coff_keep_syms (abfd) = true;
+
+ sym_is_global = coff_backend_info (abfd)->_bfd_coff_sym_is_global;
+
+ if (info->keep_memory)
+ default_copy = false;
+ else
+ default_copy = true;
+
+ symcount = obj_raw_syment_count (abfd);
+
+ /* We keep a list of the linker hash table entries that correspond
+ to particular symbols. */
+ sym_hash = ((struct coff_link_hash_entry **)
+ bfd_alloc (abfd,
+ ((size_t) symcount
+ * sizeof (struct coff_link_hash_entry *))));
+ if (sym_hash == NULL && symcount != 0)
+ goto error_return;
+ obj_coff_sym_hashes (abfd) = sym_hash;
+ memset (sym_hash, 0,
+ (size_t) symcount * sizeof (struct coff_link_hash_entry *));
+
+ symesz = bfd_coff_symesz (abfd);
+ BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
+ esym = (bfd_byte *) obj_coff_external_syms (abfd);
+ esym_end = esym + symcount * symesz;
+ while (esym < esym_end)
+ {
+ struct internal_syment sym;
+ boolean copy;
+
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
+
+ if (sym.n_sclass == C_EXT
+ || sym.n_sclass == C_WEAKEXT
+ || (obj_pe (abfd) && sym.n_sclass == C_NT_WEAK)
+#ifdef C_SYSTEM
+ || sym.n_sclass == C_SYSTEM
+#endif
+ || (sym_is_global && (*sym_is_global) (abfd, &sym)))
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+
+ /* This symbol is externally visible. */
+
+ name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
+ if (name == NULL)
+ goto error_return;
+
+ /* We must copy the name into memory if we got it from the
+ syment itself, rather than the string table. */
+ copy = default_copy;
+ if (sym._n._n_n._n_zeroes != 0
+ || sym._n._n_n._n_offset == 0)
+ copy = true;
+
+ value = sym.n_value;
+
+ if (sym.n_scnum == 0)
+ {
+ if (value == 0)
+ {
+ flags = 0;
+ section = bfd_und_section_ptr;
+ }
+ else
+ {
+ flags = BSF_GLOBAL;
+ section = bfd_com_section_ptr;
+ }
+ }
+ else
+ {
+ flags = BSF_EXPORT | BSF_GLOBAL;
+ section = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ if (! obj_pe (abfd))
+ value -= section->vma;
+ }
+
+ if (sym.n_sclass == C_WEAKEXT
+ || (obj_pe (abfd) && sym.n_sclass == C_NT_WEAK))
+ flags = BSF_WEAK;
+
+ if (! (bfd_coff_link_add_one_symbol
+ (info, abfd, name, flags, section, value,
+ (const char *) NULL, copy, false,
+ (struct bfd_link_hash_entry **) sym_hash)))
+ goto error_return;
+
+ if (section == bfd_com_section_ptr
+ && (*sym_hash)->root.type == bfd_link_hash_common
+ && ((*sym_hash)->root.u.c.p->alignment_power
+ > bfd_coff_default_section_alignment_power (abfd)))
+ (*sym_hash)->root.u.c.p->alignment_power
+ = bfd_coff_default_section_alignment_power (abfd);
+
+ if (info->hash->creator->flavour == bfd_get_flavour (abfd))
+ {
+ if (((*sym_hash)->class == C_NULL
+ && (*sym_hash)->type == T_NULL)
+ || sym.n_scnum != 0
+ || (sym.n_value != 0
+ && (*sym_hash)->root.type != bfd_link_hash_defined
+ && (*sym_hash)->root.type != bfd_link_hash_defweak))
+ {
+ (*sym_hash)->class = sym.n_sclass;
+ if (sym.n_type != T_NULL)
+ {
+ if ((*sym_hash)->type != T_NULL
+ && (*sym_hash)->type != sym.n_type)
+ (*_bfd_error_handler)
+ (_("Warning: type of symbol `%s' changed from %d to %d in %s"),
+ name, (*sym_hash)->type, sym.n_type,
+ bfd_get_filename (abfd));
+ (*sym_hash)->type = sym.n_type;
+ }
+ (*sym_hash)->auxbfd = abfd;
+ if (sym.n_numaux != 0)
+ {
+ union internal_auxent *alloc;
+ unsigned int i;
+ bfd_byte *eaux;
+ union internal_auxent *iaux;
+
+ (*sym_hash)->numaux = sym.n_numaux;
+ alloc = ((union internal_auxent *)
+ bfd_hash_allocate (&info->hash->table,
+ (sym.n_numaux
+ * sizeof (*alloc))));
+ if (alloc == NULL)
+ goto error_return;
+ for (i = 0, eaux = esym + symesz, iaux = alloc;
+ i < sym.n_numaux;
+ i++, eaux += symesz, iaux++)
+ bfd_coff_swap_aux_in (abfd, (PTR) eaux, sym.n_type,
+ sym.n_sclass, i, sym.n_numaux,
+ (PTR) iaux);
+ (*sym_hash)->aux = alloc;
+ }
+ }
+ }
+ }
+
+ esym += (sym.n_numaux + 1) * symesz;
+ sym_hash += sym.n_numaux + 1;
+ }
+
+ /* If this is a non-traditional, non-relocateable link, try to
+ optimize the handling of any .stab/.stabstr sections. */
+ if (! info->relocateable
+ && ! info->traditional_format
+ && info->hash->creator->flavour == bfd_get_flavour (abfd)
+ && (info->strip != strip_all && info->strip != strip_debugger))
+ {
+ asection *stab, *stabstr;
+
+ stab = bfd_get_section_by_name (abfd, ".stab");
+ if (stab != NULL)
+ {
+ stabstr = bfd_get_section_by_name (abfd, ".stabstr");
+
+ if (stabstr != NULL)
+ {
+ struct coff_link_hash_table *table;
+ struct coff_section_tdata *secdata;
+
+ secdata = coff_section_data (abfd, stab);
+ if (secdata == NULL)
+ {
+ stab->used_by_bfd =
+ (PTR) bfd_zalloc (abfd,
+ sizeof (struct coff_section_tdata));
+ if (stab->used_by_bfd == NULL)
+ goto error_return;
+ secdata = coff_section_data (abfd, stab);
+ }
+
+ table = coff_hash_table (info);
+
+ if (! _bfd_link_section_stabs (abfd, &table->stab_info,
+ stab, stabstr,
+ &secdata->stab_info))
+ goto error_return;
+ }
+ }
+ }
+
+ obj_coff_keep_syms (abfd) = keep_syms;
+
+ return true;
+
+ error_return:
+ obj_coff_keep_syms (abfd) = keep_syms;
+ return false;
+}
+
+/* Do the final link step. */
+
+boolean
+_bfd_coff_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd_size_type symesz;
+ struct coff_final_link_info finfo;
+ boolean debug_merge_allocated;
+ boolean long_section_names;
+ asection *o;
+ struct bfd_link_order *p;
+ size_t max_sym_count;
+ size_t max_lineno_count;
+ size_t max_reloc_count;
+ size_t max_output_reloc_count;
+ size_t max_contents_size;
+ file_ptr rel_filepos;
+ unsigned int relsz;
+ file_ptr line_filepos;
+ unsigned int linesz;
+ bfd *sub;
+ bfd_byte *external_relocs = NULL;
+ char strbuf[STRING_SIZE_SIZE];
+
+ symesz = bfd_coff_symesz (abfd);
+
+ finfo.info = info;
+ finfo.output_bfd = abfd;
+ finfo.strtab = NULL;
+ finfo.section_info = NULL;
+ finfo.last_file_index = -1;
+ finfo.last_bf_index = -1;
+ finfo.internal_syms = NULL;
+ finfo.sec_ptrs = NULL;
+ finfo.sym_indices = NULL;
+ finfo.outsyms = NULL;
+ finfo.linenos = NULL;
+ finfo.contents = NULL;
+ finfo.external_relocs = NULL;
+ finfo.internal_relocs = NULL;
+ finfo.global_to_static = false;
+ debug_merge_allocated = false;
+
+ coff_data (abfd)->link_info = info;
+
+ finfo.strtab = _bfd_stringtab_init ();
+ if (finfo.strtab == NULL)
+ goto error_return;
+
+ if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
+ goto error_return;
+ debug_merge_allocated = true;
+
+ /* Compute the file positions for all the sections. */
+ if (! abfd->output_has_begun)
+ {
+ if (! bfd_coff_compute_section_file_positions (abfd))
+ goto error_return;
+ }
+
+ /* Count the line numbers and relocation entries required for the
+ output file. Set the file positions for the relocs. */
+ rel_filepos = obj_relocbase (abfd);
+ relsz = bfd_coff_relsz (abfd);
+ max_contents_size = 0;
+ max_lineno_count = 0;
+ max_reloc_count = 0;
+
+ long_section_names = false;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order)
+ {
+ asection *sec;
+
+ sec = p->u.indirect.section;
+
+ /* Mark all sections which are to be included in the
+ link. This will normally be every section. We need
+ to do this so that we can identify any sections which
+ the linker has decided to not include. */
+ sec->linker_mark = true;
+
+ if (info->strip == strip_none
+ || info->strip == strip_some)
+ o->lineno_count += sec->lineno_count;
+
+ if (info->relocateable)
+ o->reloc_count += sec->reloc_count;
+
+ if (sec->_raw_size > max_contents_size)
+ max_contents_size = sec->_raw_size;
+ if (sec->lineno_count > max_lineno_count)
+ max_lineno_count = sec->lineno_count;
+ if (sec->reloc_count > max_reloc_count)
+ max_reloc_count = sec->reloc_count;
+ }
+ else if (info->relocateable
+ && (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order))
+ ++o->reloc_count;
+ }
+ if (o->reloc_count == 0)
+ o->rel_filepos = 0;
+ else
+ {
+ o->flags |= SEC_RELOC;
+ o->rel_filepos = rel_filepos;
+ rel_filepos += o->reloc_count * relsz;
+ }
+
+ if (bfd_coff_long_section_names (abfd)
+ && strlen (o->name) > SCNNMLEN)
+ {
+ /* This section has a long name which must go in the string
+ table. This must correspond to the code in
+ coff_write_object_contents which puts the string index
+ into the s_name field of the section header. That is why
+ we pass hash as false. */
+ if (_bfd_stringtab_add (finfo.strtab, o->name, false, false)
+ == (bfd_size_type) -1)
+ goto error_return;
+ long_section_names = true;
+ }
+ }
+
+ /* If doing a relocateable link, allocate space for the pointers we
+ need to keep. */
+ if (info->relocateable)
+ {
+ unsigned int i;
+
+ /* We use section_count + 1, rather than section_count, because
+ the target_index fields are 1 based. */
+ finfo.section_info =
+ ((struct coff_link_section_info *)
+ bfd_malloc ((abfd->section_count + 1)
+ * sizeof (struct coff_link_section_info)));
+ if (finfo.section_info == NULL)
+ goto error_return;
+ for (i = 0; i <= abfd->section_count; i++)
+ {
+ finfo.section_info[i].relocs = NULL;
+ finfo.section_info[i].rel_hashes = NULL;
+ }
+ }
+
+ /* We now know the size of the relocs, so we can determine the file
+ positions of the line numbers. */
+ line_filepos = rel_filepos;
+ linesz = bfd_coff_linesz (abfd);
+ max_output_reloc_count = 0;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if (o->lineno_count == 0)
+ o->line_filepos = 0;
+ else
+ {
+ o->line_filepos = line_filepos;
+ line_filepos += o->lineno_count * linesz;
+ }
+
+ if (o->reloc_count != 0)
+ {
+ /* We don't know the indices of global symbols until we have
+ written out all the local symbols. For each section in
+ the output file, we keep an array of pointers to hash
+ table entries. Each entry in the array corresponds to a
+ reloc. When we find a reloc against a global symbol, we
+ set the corresponding entry in this array so that we can
+ fix up the symbol index after we have written out all the
+ local symbols.
+
+ Because of this problem, we also keep the relocs in
+ memory until the end of the link. This wastes memory,
+ but only when doing a relocateable link, which is not the
+ common case. */
+ BFD_ASSERT (info->relocateable);
+ finfo.section_info[o->target_index].relocs =
+ ((struct internal_reloc *)
+ bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+ finfo.section_info[o->target_index].rel_hashes =
+ ((struct coff_link_hash_entry **)
+ bfd_malloc (o->reloc_count
+ * sizeof (struct coff_link_hash_entry *)));
+ if (finfo.section_info[o->target_index].relocs == NULL
+ || finfo.section_info[o->target_index].rel_hashes == NULL)
+ goto error_return;
+
+ if (o->reloc_count > max_output_reloc_count)
+ max_output_reloc_count = o->reloc_count;
+ }
+
+ /* Reset the reloc and lineno counts, so that we can use them to
+ count the number of entries we have output so far. */
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ }
+
+ obj_sym_filepos (abfd) = line_filepos;
+
+ /* Figure out the largest number of symbols in an input BFD. Take
+ the opportunity to clear the output_has_begun fields of all the
+ input BFD's. */
+ max_sym_count = 0;
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ size_t sz;
+
+ sub->output_has_begun = false;
+ sz = obj_raw_syment_count (sub);
+ if (sz > max_sym_count)
+ max_sym_count = sz;
+ }
+
+ /* Allocate some buffers used while linking. */
+ finfo.internal_syms = ((struct internal_syment *)
+ bfd_malloc (max_sym_count
+ * sizeof (struct internal_syment)));
+ finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
+ * sizeof (asection *));
+ finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
+ finfo.outsyms = ((bfd_byte *)
+ bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
+ finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
+ * bfd_coff_linesz (abfd));
+ finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+ finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
+ if (! info->relocateable)
+ finfo.internal_relocs = ((struct internal_reloc *)
+ bfd_malloc (max_reloc_count
+ * sizeof (struct internal_reloc)));
+ if ((finfo.internal_syms == NULL && max_sym_count > 0)
+ || (finfo.sec_ptrs == NULL && max_sym_count > 0)
+ || (finfo.sym_indices == NULL && max_sym_count > 0)
+ || finfo.outsyms == NULL
+ || (finfo.linenos == NULL && max_lineno_count > 0)
+ || (finfo.contents == NULL && max_contents_size > 0)
+ || (finfo.external_relocs == NULL && max_reloc_count > 0)
+ || (! info->relocateable
+ && finfo.internal_relocs == NULL
+ && max_reloc_count > 0))
+ goto error_return;
+
+ /* We now know the position of everything in the file, except that
+ we don't know the size of the symbol table and therefore we don't
+ know where the string table starts. We just build the string
+ table in memory as we go along. We process all the relocations
+ for a single input file at once. */
+ obj_raw_syment_count (abfd) = 0;
+
+ if (coff_backend_info (abfd)->_bfd_coff_start_final_link)
+ {
+ if (! bfd_coff_start_final_link (abfd, info))
+ goto error_return;
+ }
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order
+ && (bfd_get_flavour (p->u.indirect.section->owner)
+ == bfd_target_coff_flavour))
+ {
+ sub = p->u.indirect.section->owner;
+ if (! bfd_coff_link_output_has_begun (sub, & finfo))
+ {
+ if (! _bfd_coff_link_input_bfd (&finfo, sub))
+ goto error_return;
+ sub->output_has_begun = true;
+ }
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ if (! _bfd_coff_reloc_link_order (abfd, &finfo, o, p))
+ goto error_return;
+ }
+ else
+ {
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ goto error_return;
+ }
+ }
+ }
+
+ if (! bfd_coff_final_link_postscript (abfd, & finfo))
+ goto error_return;
+
+ /* Free up the buffers used by _bfd_coff_link_input_bfd. */
+
+ coff_debug_merge_hash_table_free (&finfo.debug_merge);
+ debug_merge_allocated = false;
+
+ if (finfo.internal_syms != NULL)
+ {
+ free (finfo.internal_syms);
+ finfo.internal_syms = NULL;
+ }
+ if (finfo.sec_ptrs != NULL)
+ {
+ free (finfo.sec_ptrs);
+ finfo.sec_ptrs = NULL;
+ }
+ if (finfo.sym_indices != NULL)
+ {
+ free (finfo.sym_indices);
+ finfo.sym_indices = NULL;
+ }
+ if (finfo.linenos != NULL)
+ {
+ free (finfo.linenos);
+ finfo.linenos = NULL;
+ }
+ if (finfo.contents != NULL)
+ {
+ free (finfo.contents);
+ finfo.contents = NULL;
+ }
+ if (finfo.external_relocs != NULL)
+ {
+ free (finfo.external_relocs);
+ finfo.external_relocs = NULL;
+ }
+ if (finfo.internal_relocs != NULL)
+ {
+ free (finfo.internal_relocs);
+ finfo.internal_relocs = NULL;
+ }
+
+ /* The value of the last C_FILE symbol is supposed to be the symbol
+ index of the first external symbol. Write it out again if
+ necessary. */
+ if (finfo.last_file_index != -1
+ && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
+ {
+ finfo.last_file.n_value = obj_raw_syment_count (abfd);
+ bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
+ (PTR) finfo.outsyms);
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + finfo.last_file_index * symesz),
+ SEEK_SET) != 0
+ || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
+ return false;
+ }
+
+ /* If doing task linking (ld --task-link) then make a pass through the
+ global symbols, writing out any that are defined, and making them
+ static. */
+ if (info->task_link)
+ {
+ finfo.failed = false;
+ coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_task_globals,
+ (PTR) &finfo);
+ if (finfo.failed)
+ goto error_return;
+ }
+
+ /* Write out the global symbols. */
+ finfo.failed = false;
+ coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
+ (PTR) &finfo);
+ if (finfo.failed)
+ goto error_return;
+
+ /* The outsyms buffer is used by _bfd_coff_write_global_sym. */
+ if (finfo.outsyms != NULL)
+ {
+ free (finfo.outsyms);
+ finfo.outsyms = NULL;
+ }
+
+ if (info->relocateable && max_output_reloc_count > 0)
+ {
+ /* Now that we have written out all the global symbols, we know
+ the symbol indices to use for relocs against them, and we can
+ finally write out the relocs. */
+ external_relocs = ((bfd_byte *)
+ bfd_malloc (max_output_reloc_count * relsz));
+ if (external_relocs == NULL)
+ goto error_return;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct internal_reloc *irel;
+ struct internal_reloc *irelend;
+ struct coff_link_hash_entry **rel_hash;
+ bfd_byte *erel;
+
+ if (o->reloc_count == 0)
+ continue;
+
+ irel = finfo.section_info[o->target_index].relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = finfo.section_info[o->target_index].rel_hashes;
+ erel = external_relocs;
+ for (; irel < irelend; irel++, rel_hash++, erel += relsz)
+ {
+ if (*rel_hash != NULL)
+ {
+ BFD_ASSERT ((*rel_hash)->indx >= 0);
+ irel->r_symndx = (*rel_hash)->indx;
+ }
+ bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
+ }
+
+ if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
+ || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
+ abfd) != relsz * o->reloc_count)
+ goto error_return;
+ }
+
+ free (external_relocs);
+ external_relocs = NULL;
+ }
+
+ /* Free up the section information. */
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ finfo.section_info = NULL;
+ }
+
+ /* If we have optimized stabs strings, output them. */
+ if (coff_hash_table (info)->stab_info != NULL)
+ {
+ if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
+ return false;
+ }
+
+ /* Write out the string table. */
+ if (obj_raw_syment_count (abfd) != 0 || long_section_names)
+ {
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + obj_raw_syment_count (abfd) * symesz),
+ SEEK_SET) != 0)
+ return false;
+
+#if STRING_SIZE_SIZE == 4
+ bfd_h_put_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ (bfd_byte *) strbuf);
+#else
+ #error Change bfd_h_put_32
+#endif
+
+ if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ return false;
+
+ if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+ return false;
+ }
+
+ _bfd_stringtab_free (finfo.strtab);
+
+ /* Setting bfd_get_symcount to 0 will cause write_object_contents to
+ not try to write out the symbols. */
+ bfd_get_symcount (abfd) = 0;
+
+ return true;
+
+ error_return:
+ if (debug_merge_allocated)
+ coff_debug_merge_hash_table_free (&finfo.debug_merge);
+ if (finfo.strtab != NULL)
+ _bfd_stringtab_free (finfo.strtab);
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ }
+ if (finfo.internal_syms != NULL)
+ free (finfo.internal_syms);
+ if (finfo.sec_ptrs != NULL)
+ free (finfo.sec_ptrs);
+ if (finfo.sym_indices != NULL)
+ free (finfo.sym_indices);
+ if (finfo.outsyms != NULL)
+ free (finfo.outsyms);
+ if (finfo.linenos != NULL)
+ free (finfo.linenos);
+ if (finfo.contents != NULL)
+ free (finfo.contents);
+ if (finfo.external_relocs != NULL)
+ free (finfo.external_relocs);
+ if (finfo.internal_relocs != NULL)
+ free (finfo.internal_relocs);
+ if (external_relocs != NULL)
+ free (external_relocs);
+ return false;
+}
+
+/* parse out a -heap <reserved>,<commit> line */
+
+static char *
+dores_com (ptr, output_bfd, heap)
+ char *ptr;
+ bfd *output_bfd;
+ int heap;
+{
+ if (coff_data(output_bfd)->pe)
+ {
+ int val = strtoul (ptr, &ptr, 0);
+ if (heap)
+ pe_data(output_bfd)->pe_opthdr.SizeOfHeapReserve =val;
+ else
+ pe_data(output_bfd)->pe_opthdr.SizeOfStackReserve =val;
+
+ if (ptr[0] == ',')
+ {
+ int val = strtoul (ptr+1, &ptr, 0);
+ if (heap)
+ pe_data(output_bfd)->pe_opthdr.SizeOfHeapCommit =val;
+ else
+ pe_data(output_bfd)->pe_opthdr.SizeOfStackCommit =val;
+ }
+ }
+ return ptr;
+}
+
+static char *get_name(ptr, dst)
+char *ptr;
+char **dst;
+{
+ while (*ptr == ' ')
+ ptr++;
+ *dst = ptr;
+ while (*ptr && *ptr != ' ')
+ ptr++;
+ *ptr = 0;
+ return ptr+1;
+}
+
+/* Process any magic embedded commands in a section called .drectve */
+
+static int
+process_embedded_commands (output_bfd, info, abfd)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *abfd;
+{
+ asection *sec = bfd_get_section_by_name (abfd, ".drectve");
+ char *s;
+ char *e;
+ char *copy;
+ if (!sec)
+ return 1;
+
+ copy = bfd_malloc ((size_t) sec->_raw_size);
+ if (!copy)
+ return 0;
+ if (! bfd_get_section_contents(abfd, sec, copy, 0, sec->_raw_size))
+ {
+ free (copy);
+ return 0;
+ }
+ e = copy + sec->_raw_size;
+ for (s = copy; s < e ; )
+ {
+ if (s[0]!= '-') {
+ s++;
+ continue;
+ }
+ if (strncmp (s,"-attr", 5) == 0)
+ {
+ char *name;
+ char *attribs;
+ asection *asec;
+
+ int loop = 1;
+ int had_write = 0;
+ int had_read = 0;
+ int had_exec= 0;
+ int had_shared= 0;
+ s += 5;
+ s = get_name(s, &name);
+ s = get_name(s, &attribs);
+ while (loop) {
+ switch (*attribs++)
+ {
+ case 'W':
+ had_write = 1;
+ break;
+ case 'R':
+ had_read = 1;
+ break;
+ case 'S':
+ had_shared = 1;
+ break;
+ case 'X':
+ had_exec = 1;
+ break;
+ default:
+ loop = 0;
+ }
+ }
+ asec = bfd_get_section_by_name (abfd, name);
+ if (asec) {
+ if (had_exec)
+ asec->flags |= SEC_CODE;
+ if (!had_write)
+ asec->flags |= SEC_READONLY;
+ }
+ }
+ else if (strncmp (s,"-heap", 5) == 0)
+ {
+ s = dores_com (s+5, output_bfd, 1);
+ }
+ else if (strncmp (s,"-stack", 6) == 0)
+ {
+ s = dores_com (s+6, output_bfd, 0);
+ }
+ else
+ s++;
+ }
+ free (copy);
+ return 1;
+}
+
+/* Place a marker against all symbols which are used by relocations.
+ This marker can be picked up by the 'do we skip this symbol ?'
+ loop in _bfd_coff_link_input_bfd() and used to prevent skipping
+ that symbol.
+ */
+
+static void
+mark_relocs (finfo, input_bfd)
+ struct coff_final_link_info * finfo;
+ bfd * input_bfd;
+{
+ asection * a;
+
+ if ((bfd_get_file_flags (input_bfd) & HAS_SYMS) == 0)
+ return;
+
+ for (a = input_bfd->sections; a != (asection *) NULL; a = a->next)
+ {
+ struct internal_reloc * internal_relocs;
+ struct internal_reloc * irel;
+ struct internal_reloc * irelend;
+
+
+ if ((a->flags & SEC_RELOC) == 0 || a->reloc_count < 1)
+ continue;
+
+ /* Read in the relocs. */
+ internal_relocs = _bfd_coff_read_internal_relocs
+ (input_bfd, a, false,
+ finfo->external_relocs,
+ finfo->info->relocateable,
+ (finfo->info->relocateable
+ ? (finfo->section_info[ a->output_section->target_index ].relocs + a->output_section->reloc_count)
+ : finfo->internal_relocs)
+ );
+
+ if (internal_relocs == NULL)
+ continue;
+
+ irel = internal_relocs;
+ irelend = irel + a->reloc_count;
+
+ /* Place a mark in the sym_indices array (whose entries have
+ been initialised to 0) for all of the symbols that are used
+ in the relocation table. This will then be picked up in the
+ skip/don't pass */
+
+ for (; irel < irelend; irel++)
+ {
+ finfo->sym_indices[ irel->r_symndx ] = -1;
+ }
+ }
+}
+
+/* Link an input file into the linker output file. This function
+ handles all the sections and relocations of the input file at once. */
+
+boolean
+_bfd_coff_link_input_bfd (finfo, input_bfd)
+ struct coff_final_link_info *finfo;
+ bfd *input_bfd;
+{
+ boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *));
+ boolean (*adjust_symndx) PARAMS ((bfd *, struct bfd_link_info *, bfd *,
+ asection *, struct internal_reloc *,
+ boolean *));
+ bfd *output_bfd;
+ const char *strings;
+ bfd_size_type syment_base;
+ unsigned int n_tmask;
+ unsigned int n_btshft;
+ boolean copy, hash;
+ bfd_size_type isymesz;
+ bfd_size_type osymesz;
+ bfd_size_type linesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
+ struct internal_syment *isymp;
+ asection **secpp;
+ long *indexp;
+ unsigned long output_index;
+ bfd_byte *outsym;
+ struct coff_link_hash_entry **sym_hash;
+ asection *o;
+
+ /* Move all the symbols to the output file. */
+
+ output_bfd = finfo->output_bfd;
+ sym_is_global = coff_backend_info (input_bfd)->_bfd_coff_sym_is_global;
+ strings = NULL;
+ syment_base = obj_raw_syment_count (output_bfd);
+ isymesz = bfd_coff_symesz (input_bfd);
+ osymesz = bfd_coff_symesz (output_bfd);
+ linesz = bfd_coff_linesz (input_bfd);
+ BFD_ASSERT (linesz == bfd_coff_linesz (output_bfd));
+
+ n_tmask = coff_data (input_bfd)->local_n_tmask;
+ n_btshft = coff_data (input_bfd)->local_n_btshft;
+
+ /* Define macros so that ISFCN, et. al., macros work correctly. */
+#define N_TMASK n_tmask
+#define N_BTSHFT n_btshft
+
+ copy = false;
+ if (! finfo->info->keep_memory)
+ copy = true;
+ hash = true;
+ if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ hash = false;
+
+ if (! _bfd_coff_get_external_symbols (input_bfd))
+ return false;
+
+ esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
+ esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
+ isymp = finfo->internal_syms;
+ secpp = finfo->sec_ptrs;
+ indexp = finfo->sym_indices;
+ output_index = syment_base;
+ outsym = finfo->outsyms;
+
+ if (coff_data (output_bfd)->pe)
+ {
+ if (! process_embedded_commands (output_bfd, finfo->info, input_bfd))
+ return false;
+ }
+
+ /* If we are going to perform relocations and also strip/discard some symbols
+ then we must make sure that we do not strip/discard those symbols that are
+ going to be involved in the relocations */
+ if (( finfo->info->strip != strip_none
+ || finfo->info->discard != discard_none)
+ && finfo->info->relocateable)
+ {
+ /* mark the symbol array as 'not-used' */
+ memset (indexp, 0, obj_raw_syment_count (input_bfd) * sizeof * indexp);
+
+ mark_relocs (finfo, input_bfd);
+ }
+
+ while (esym < esym_end)
+ {
+ struct internal_syment isym;
+ boolean skip;
+ boolean global;
+ boolean dont_skip_symbol;
+ int add;
+
+ bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
+
+ /* Make a copy of *isymp so that the relocate_section function
+ always sees the original values. This is more reliable than
+ always recomputing the symbol value even if we are stripping
+ the symbol. */
+ isym = *isymp;
+
+ if (isym.n_scnum != 0)
+ *secpp = coff_section_from_bfd_index (input_bfd, isym.n_scnum);
+ else
+ {
+ if (isym.n_value == 0)
+ *secpp = bfd_und_section_ptr;
+ else
+ *secpp = bfd_com_section_ptr;
+ }
+
+ /* Extract the flag indicating if this symbol is used by a
+ relocation. */
+ if ((finfo->info->strip != strip_none
+ || finfo->info->discard != discard_none)
+ && finfo->info->relocateable)
+ dont_skip_symbol = *indexp;
+ else
+ dont_skip_symbol = false;
+
+ *indexp = -1;
+
+ skip = false;
+ global = false;
+ add = 1 + isym.n_numaux;
+
+ /* If we are stripping all symbols, we want to skip this one. */
+ if (finfo->info->strip == strip_all && ! dont_skip_symbol)
+ skip = true;
+
+ if (! skip)
+ {
+ if (isym.n_sclass == C_EXT
+ || isym.n_sclass == C_WEAKEXT
+ || (obj_pe (input_bfd) && isym.n_sclass == C_NT_WEAK)
+#ifdef C_SYSTEM
+ || isym.n_sclass == C_SYSTEM
+#endif
+ || (sym_is_global && (*sym_is_global) (input_bfd, &isym)))
+ {
+ /* This is a global symbol. Global symbols come at the
+ end of the symbol table, so skip them for now.
+ Locally defined function symbols, however, are an
+ exception, and are not moved to the end. */
+ global = true;
+ if (! ISFCN (isym.n_type) || isym.n_scnum == 0)
+ skip = true;
+ }
+ else
+ {
+ /* This is a local symbol. Skip it if we are discarding
+ local symbols. */
+ if (finfo->info->discard == discard_all && ! dont_skip_symbol)
+ skip = true;
+ }
+ }
+
+ /* If we stripping debugging symbols, and this is a debugging
+ symbol, then skip it. FIXME: gas sets the section to N_ABS
+ for some types of debugging symbols; I don't know if this is
+ a bug or not. In any case, we handle it here. */
+ if (! skip
+ && finfo->info->strip == strip_debugger
+ && ! dont_skip_symbol
+ && (isym.n_scnum == N_DEBUG
+ || (isym.n_scnum == N_ABS
+ && (isym.n_sclass == C_AUTO
+ || isym.n_sclass == C_REG
+ || isym.n_sclass == C_MOS
+ || isym.n_sclass == C_MOE
+ || isym.n_sclass == C_MOU
+ || isym.n_sclass == C_ARG
+ || isym.n_sclass == C_REGPARM
+ || isym.n_sclass == C_FIELD
+ || isym.n_sclass == C_EOS))))
+ skip = true;
+
+ /* If some symbols are stripped based on the name, work out the
+ name and decide whether to skip this symbol. */
+ if (! skip
+ && (finfo->info->strip == strip_some
+ || finfo->info->discard == discard_l))
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
+ if (name == NULL)
+ return false;
+
+ if (! dont_skip_symbol
+ && ((finfo->info->strip == strip_some
+ && (bfd_hash_lookup (finfo->info->keep_hash, name, false,
+ false) == NULL))
+ || (! global
+ && finfo->info->discard == discard_l
+ && bfd_is_local_label_name (input_bfd, name))))
+ skip = true;
+ }
+
+ /* If this is an enum, struct, or union tag, see if we have
+ already output an identical type. */
+ if (! skip
+ && (finfo->output_bfd->flags & BFD_TRADITIONAL_FORMAT) == 0
+ && (isym.n_sclass == C_ENTAG
+ || isym.n_sclass == C_STRTAG
+ || isym.n_sclass == C_UNTAG)
+ && isym.n_numaux == 1)
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ struct coff_debug_merge_hash_entry *mh;
+ struct coff_debug_merge_type *mt;
+ union internal_auxent aux;
+ struct coff_debug_merge_element **epp;
+ bfd_byte *esl, *eslend;
+ struct internal_syment *islp;
+
+ name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
+ if (name == NULL)
+ return false;
+
+ /* Ignore fake names invented by compiler; treat them all as
+ the same name. */
+ if (*name == '~' || *name == '.' || *name == '$'
+ || (*name == bfd_get_symbol_leading_char (input_bfd)
+ && (name[1] == '~' || name[1] == '.' || name[1] == '$')))
+ name = "";
+
+ mh = coff_debug_merge_hash_lookup (&finfo->debug_merge, name,
+ true, true);
+ if (mh == NULL)
+ return false;
+
+ /* Allocate memory to hold type information. If this turns
+ out to be a duplicate, we pass this address to
+ bfd_release. */
+ mt = ((struct coff_debug_merge_type *)
+ bfd_alloc (input_bfd,
+ sizeof (struct coff_debug_merge_type)));
+ if (mt == NULL)
+ return false;
+ mt->class = isym.n_sclass;
+
+ /* Pick up the aux entry, which points to the end of the tag
+ entries. */
+ bfd_coff_swap_aux_in (input_bfd, (PTR) (esym + isymesz),
+ isym.n_type, isym.n_sclass, 0, isym.n_numaux,
+ (PTR) &aux);
+
+ /* Gather the elements. */
+ epp = &mt->elements;
+ mt->elements = NULL;
+ islp = isymp + 2;
+ esl = esym + 2 * isymesz;
+ eslend = ((bfd_byte *) obj_coff_external_syms (input_bfd)
+ + aux.x_sym.x_fcnary.x_fcn.x_endndx.l * isymesz);
+ while (esl < eslend)
+ {
+ const char *elename;
+ char elebuf[SYMNMLEN + 1];
+ char *copy;
+
+ bfd_coff_swap_sym_in (input_bfd, (PTR) esl, (PTR) islp);
+
+ *epp = ((struct coff_debug_merge_element *)
+ bfd_alloc (input_bfd,
+ sizeof (struct coff_debug_merge_element)));
+ if (*epp == NULL)
+ return false;
+
+ elename = _bfd_coff_internal_syment_name (input_bfd, islp,
+ elebuf);
+ if (elename == NULL)
+ return false;
+
+ copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1);
+ if (copy == NULL)
+ return false;
+ strcpy (copy, elename);
+
+ (*epp)->name = copy;
+ (*epp)->type = islp->n_type;
+ (*epp)->tagndx = 0;
+ if (islp->n_numaux >= 1
+ && islp->n_type != T_NULL
+ && islp->n_sclass != C_EOS)
+ {
+ union internal_auxent eleaux;
+ long indx;
+
+ bfd_coff_swap_aux_in (input_bfd, (PTR) (esl + isymesz),
+ islp->n_type, islp->n_sclass, 0,
+ islp->n_numaux, (PTR) &eleaux);
+ indx = eleaux.x_sym.x_tagndx.l;
+
+ /* FIXME: If this tagndx entry refers to a symbol
+ defined later in this file, we just ignore it.
+ Handling this correctly would be tedious, and may
+ not be required. */
+
+ if (indx > 0
+ && (indx
+ < ((esym -
+ (bfd_byte *) obj_coff_external_syms (input_bfd))
+ / (long) isymesz)))
+ {
+ (*epp)->tagndx = finfo->sym_indices[indx];
+ if ((*epp)->tagndx < 0)
+ (*epp)->tagndx = 0;
+ }
+ }
+ epp = &(*epp)->next;
+ *epp = NULL;
+
+ esl += (islp->n_numaux + 1) * isymesz;
+ islp += islp->n_numaux + 1;
+ }
+
+ /* See if we already have a definition which matches this
+ type. We always output the type if it has no elements,
+ for simplicity. */
+ if (mt->elements == NULL)
+ bfd_release (input_bfd, (PTR) mt);
+ else
+ {
+ struct coff_debug_merge_type *mtl;
+
+ for (mtl = mh->types; mtl != NULL; mtl = mtl->next)
+ {
+ struct coff_debug_merge_element *me, *mel;
+
+ if (mtl->class != mt->class)
+ continue;
+
+ for (me = mt->elements, mel = mtl->elements;
+ me != NULL && mel != NULL;
+ me = me->next, mel = mel->next)
+ {
+ if (strcmp (me->name, mel->name) != 0
+ || me->type != mel->type
+ || me->tagndx != mel->tagndx)
+ break;
+ }
+
+ if (me == NULL && mel == NULL)
+ break;
+ }
+
+ if (mtl == NULL || (bfd_size_type) mtl->indx >= syment_base)
+ {
+ /* This is the first definition of this type. */
+ mt->indx = output_index;
+ mt->next = mh->types;
+ mh->types = mt;
+ }
+ else
+ {
+ /* This is a redefinition which can be merged. */
+ bfd_release (input_bfd, (PTR) mt);
+ *indexp = mtl->indx;
+ add = (eslend - esym) / isymesz;
+ skip = true;
+ }
+ }
+ }
+
+ /* We now know whether we are to skip this symbol or not. */
+ if (! skip)
+ {
+ /* Adjust the symbol in order to output it. */
+
+ if (isym._n._n_n._n_zeroes == 0
+ && isym._n._n_n._n_offset != 0)
+ {
+ const char *name;
+ bfd_size_type indx;
+
+ /* This symbol has a long name. Enter it in the string
+ table we are building. Note that we do not check
+ bfd_coff_symname_in_debug. That is only true for
+ XCOFF, and XCOFF requires different linking code
+ anyhow. */
+ name = _bfd_coff_internal_syment_name (input_bfd, &isym,
+ (char *) NULL);
+ if (name == NULL)
+ return false;
+ indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
+ }
+
+ if (isym.n_scnum > 0)
+ {
+ isym.n_scnum = (*secpp)->output_section->target_index;
+ isym.n_value += (*secpp)->output_offset;
+ if (! obj_pe (input_bfd))
+ isym.n_value -= (*secpp)->vma;
+ if (! obj_pe (finfo->output_bfd))
+ isym.n_value += (*secpp)->output_section->vma;
+ }
+
+ /* The value of a C_FILE symbol is the symbol index of the
+ next C_FILE symbol. The value of the last C_FILE symbol
+ is the symbol index to the first external symbol
+ (actually, coff_renumber_symbols does not get this
+ right--it just sets the value of the last C_FILE symbol
+ to zero--and nobody has ever complained about it). We
+ try to get this right, below, just before we write the
+ symbols out, but in the general case we may have to write
+ the symbol out twice. */
+ if (isym.n_sclass == C_FILE)
+ {
+ if (finfo->last_file_index != -1
+ && finfo->last_file.n_value != (long) output_index)
+ {
+ /* We must correct the value of the last C_FILE entry. */
+ finfo->last_file.n_value = output_index;
+ if ((bfd_size_type) finfo->last_file_index >= syment_base)
+ {
+ /* The last C_FILE symbol is in this input file. */
+ bfd_coff_swap_sym_out (output_bfd,
+ (PTR) &finfo->last_file,
+ (PTR) (finfo->outsyms
+ + ((finfo->last_file_index
+ - syment_base)
+ * osymesz)));
+ }
+ else
+ {
+ /* We have already written out the last C_FILE
+ symbol. We need to write it out again. We
+ borrow *outsym temporarily. */
+ bfd_coff_swap_sym_out (output_bfd,
+ (PTR) &finfo->last_file,
+ (PTR) outsym);
+ if (bfd_seek (output_bfd,
+ (obj_sym_filepos (output_bfd)
+ + finfo->last_file_index * osymesz),
+ SEEK_SET) != 0
+ || (bfd_write (outsym, osymesz, 1, output_bfd)
+ != osymesz))
+ return false;
+ }
+ }
+
+ finfo->last_file_index = output_index;
+ finfo->last_file = isym;
+ }
+
+ /* If doing task linking, convert normal global function symbols to
+ static functions. */
+
+ if (finfo->info->task_link
+ && (isym.n_sclass == C_EXT
+ || isym.n_sclass == C_WEAKEXT
+ || (obj_pe (input_bfd) && isym.n_sclass == C_NT_WEAK)))
+ isym.n_sclass = C_STAT;
+
+ /* Output the symbol. */
+
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
+
+ *indexp = output_index;
+
+ if (global)
+ {
+ long indx;
+ struct coff_link_hash_entry *h;
+
+ indx = ((esym - (bfd_byte *) obj_coff_external_syms (input_bfd))
+ / isymesz);
+ h = obj_coff_sym_hashes (input_bfd)[indx];
+ if (h == NULL)
+ {
+ /* This can happen if there were errors earlier in
+ the link. */
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ h->indx = output_index;
+ }
+
+ output_index += add;
+ outsym += add * osymesz;
+ }
+
+ esym += add * isymesz;
+ isymp += add;
+ ++secpp;
+ ++indexp;
+ for (--add; add > 0; --add)
+ {
+ *secpp++ = NULL;
+ *indexp++ = -1;
+ }
+ }
+
+ /* Fix up the aux entries. This must be done in a separate pass,
+ because we don't know the correct symbol indices until we have
+ already decided which symbols we are going to keep. */
+
+ esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
+ esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
+ isymp = finfo->internal_syms;
+ indexp = finfo->sym_indices;
+ sym_hash = obj_coff_sym_hashes (input_bfd);
+ outsym = finfo->outsyms;
+ while (esym < esym_end)
+ {
+ int add;
+
+ add = 1 + isymp->n_numaux;
+
+ if ((*indexp < 0
+ || (bfd_size_type) *indexp < syment_base)
+ && (*sym_hash == NULL
+ || (*sym_hash)->auxbfd != input_bfd))
+ esym += add * isymesz;
+ else
+ {
+ struct coff_link_hash_entry *h;
+ int i;
+
+ h = NULL;
+ if (*indexp < 0)
+ {
+ h = *sym_hash;
+
+ /* The m68k-motorola-sysv assembler will sometimes
+ generate two symbols with the same name, but only one
+ will have aux entries. */
+ BFD_ASSERT (isymp->n_numaux == 0
+ || h->numaux == isymp->n_numaux);
+ }
+
+ esym += isymesz;
+
+ if (h == NULL)
+ outsym += osymesz;
+
+ /* Handle the aux entries. This handling is based on
+ coff_pointerize_aux. I don't know if it always correct. */
+ for (i = 0; i < isymp->n_numaux && esym < esym_end; i++)
+ {
+ union internal_auxent aux;
+ union internal_auxent *auxp;
+
+ if (h != NULL)
+ auxp = h->aux + i;
+ else
+ {
+ bfd_coff_swap_aux_in (input_bfd, (PTR) esym, isymp->n_type,
+ isymp->n_sclass, i, isymp->n_numaux,
+ (PTR) &aux);
+ auxp = &aux;
+ }
+
+ if (isymp->n_sclass == C_FILE)
+ {
+ /* If this is a long filename, we must put it in the
+ string table. */
+ if (auxp->x_file.x_n.x_zeroes == 0
+ && auxp->x_file.x_n.x_offset != 0)
+ {
+ const char *filename;
+ bfd_size_type indx;
+
+ BFD_ASSERT (auxp->x_file.x_n.x_offset
+ >= STRING_SIZE_SIZE);
+ if (strings == NULL)
+ {
+ strings = _bfd_coff_read_string_table (input_bfd);
+ if (strings == NULL)
+ return false;
+ }
+ filename = strings + auxp->x_file.x_n.x_offset;
+ indx = _bfd_stringtab_add (finfo->strtab, filename,
+ hash, copy);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ auxp->x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+ }
+ }
+ else if (isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
+ {
+ unsigned long indx;
+
+ if (ISFCN (isymp->n_type)
+ || ISTAG (isymp->n_sclass)
+ || isymp->n_sclass == C_BLOCK
+ || isymp->n_sclass == C_FCN)
+ {
+ indx = auxp->x_sym.x_fcnary.x_fcn.x_endndx.l;
+ if (indx > 0
+ && indx < obj_raw_syment_count (input_bfd))
+ {
+ /* We look forward through the symbol for
+ the index of the next symbol we are going
+ to include. I don't know if this is
+ entirely right. */
+ while ((finfo->sym_indices[indx] < 0
+ || ((bfd_size_type) finfo->sym_indices[indx]
+ < syment_base))
+ && indx < obj_raw_syment_count (input_bfd))
+ ++indx;
+ if (indx >= obj_raw_syment_count (input_bfd))
+ indx = output_index;
+ else
+ indx = finfo->sym_indices[indx];
+ auxp->x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
+ }
+ }
+
+ indx = auxp->x_sym.x_tagndx.l;
+ if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
+ {
+ long symindx;
+
+ symindx = finfo->sym_indices[indx];
+ if (symindx < 0)
+ auxp->x_sym.x_tagndx.l = 0;
+ else
+ auxp->x_sym.x_tagndx.l = symindx;
+ }
+
+ /* The .bf symbols are supposed to be linked through
+ the endndx field. We need to carry this list
+ across object files. */
+ if (i == 0
+ && h == NULL
+ && isymp->n_sclass == C_FCN
+ && (isymp->_n._n_n._n_zeroes != 0
+ || isymp->_n._n_n._n_offset == 0)
+ && isymp->_n._n_name[0] == '.'
+ && isymp->_n._n_name[1] == 'b'
+ && isymp->_n._n_name[2] == 'f'
+ && isymp->_n._n_name[3] == '\0')
+ {
+ if (finfo->last_bf_index != -1)
+ {
+ finfo->last_bf.x_sym.x_fcnary.x_fcn.x_endndx.l =
+ *indexp;
+
+ if ((bfd_size_type) finfo->last_bf_index
+ >= syment_base)
+ {
+ PTR auxout;
+
+ /* The last .bf symbol is in this input
+ file. This will only happen if the
+ assembler did not set up the .bf
+ endndx symbols correctly. */
+ auxout = (PTR) (finfo->outsyms
+ + ((finfo->last_bf_index
+ - syment_base)
+ * osymesz));
+ bfd_coff_swap_aux_out (output_bfd,
+ (PTR) &finfo->last_bf,
+ isymp->n_type,
+ isymp->n_sclass,
+ 0, isymp->n_numaux,
+ auxout);
+ }
+ else
+ {
+ /* We have already written out the last
+ .bf aux entry. We need to write it
+ out again. We borrow *outsym
+ temporarily. FIXME: This case should
+ be made faster. */
+ bfd_coff_swap_aux_out (output_bfd,
+ (PTR) &finfo->last_bf,
+ isymp->n_type,
+ isymp->n_sclass,
+ 0, isymp->n_numaux,
+ (PTR) outsym);
+ if (bfd_seek (output_bfd,
+ (obj_sym_filepos (output_bfd)
+ + finfo->last_bf_index * osymesz),
+ SEEK_SET) != 0
+ || bfd_write (outsym, osymesz, 1,
+ output_bfd) != osymesz)
+ return false;
+ }
+ }
+
+ if (auxp->x_sym.x_fcnary.x_fcn.x_endndx.l != 0)
+ finfo->last_bf_index = -1;
+ else
+ {
+ /* The endndx field of this aux entry must
+ be updated with the symbol number of the
+ next .bf symbol. */
+ finfo->last_bf = *auxp;
+ finfo->last_bf_index = (((outsym - finfo->outsyms)
+ / osymesz)
+ + syment_base);
+ }
+ }
+ }
+
+ if (h == NULL)
+ {
+ bfd_coff_swap_aux_out (output_bfd, (PTR) auxp, isymp->n_type,
+ isymp->n_sclass, i, isymp->n_numaux,
+ (PTR) outsym);
+ outsym += osymesz;
+ }
+
+ esym += isymesz;
+ }
+ }
+
+ indexp += add;
+ isymp += add;
+ sym_hash += add;
+ }
+
+ /* Relocate the line numbers, unless we are stripping them. */
+ if (finfo->info->strip == strip_none
+ || finfo->info->strip == strip_some)
+ {
+ for (o = input_bfd->sections; o != NULL; o = o->next)
+ {
+ bfd_vma offset;
+ bfd_byte *eline;
+ bfd_byte *elineend;
+
+ /* FIXME: If SEC_HAS_CONTENTS is not for the section, then
+ build_link_order in ldwrite.c will not have created a
+ link order, which means that we will not have seen this
+ input section in _bfd_coff_final_link, which means that
+ we will not have allocated space for the line numbers of
+ this section. I don't think line numbers can be
+ meaningful for a section which does not have
+ SEC_HAS_CONTENTS set, but, if they do, this must be
+ changed. */
+ if (o->lineno_count == 0
+ || (o->output_section->flags & SEC_HAS_CONTENTS) == 0)
+ continue;
+
+ if (bfd_seek (input_bfd, o->line_filepos, SEEK_SET) != 0
+ || bfd_read (finfo->linenos, linesz, o->lineno_count,
+ input_bfd) != linesz * o->lineno_count)
+ return false;
+
+ offset = o->output_section->vma + o->output_offset - o->vma;
+ eline = finfo->linenos;
+ elineend = eline + linesz * o->lineno_count;
+ for (; eline < elineend; eline += linesz)
+ {
+ struct internal_lineno iline;
+
+ bfd_coff_swap_lineno_in (input_bfd, (PTR) eline, (PTR) &iline);
+
+ if (iline.l_lnno != 0)
+ iline.l_addr.l_paddr += offset;
+ else if (iline.l_addr.l_symndx >= 0
+ && ((unsigned long) iline.l_addr.l_symndx
+ < obj_raw_syment_count (input_bfd)))
+ {
+ long indx;
+
+ indx = finfo->sym_indices[iline.l_addr.l_symndx];
+
+ if (indx < 0)
+ {
+ /* These line numbers are attached to a symbol
+ which we are stripping. We should really
+ just discard the line numbers, but that would
+ be a pain because we have already counted
+ them. */
+ indx = 0;
+ }
+ else
+ {
+ struct internal_syment is;
+ union internal_auxent ia;
+
+ /* Fix up the lnnoptr field in the aux entry of
+ the symbol. It turns out that we can't do
+ this when we modify the symbol aux entries,
+ because gas sometimes screws up the lnnoptr
+ field and makes it an offset from the start
+ of the line numbers rather than an absolute
+ file index. */
+ bfd_coff_swap_sym_in (output_bfd,
+ (PTR) (finfo->outsyms
+ + ((indx - syment_base)
+ * osymesz)),
+ (PTR) &is);
+ if ((ISFCN (is.n_type)
+ || is.n_sclass == C_BLOCK)
+ && is.n_numaux >= 1)
+ {
+ PTR auxptr;
+
+ auxptr = (PTR) (finfo->outsyms
+ + ((indx - syment_base + 1)
+ * osymesz));
+ bfd_coff_swap_aux_in (output_bfd, auxptr,
+ is.n_type, is.n_sclass,
+ 0, is.n_numaux, (PTR) &ia);
+ ia.x_sym.x_fcnary.x_fcn.x_lnnoptr =
+ (o->output_section->line_filepos
+ + o->output_section->lineno_count * linesz
+ + eline - finfo->linenos);
+ bfd_coff_swap_aux_out (output_bfd, (PTR) &ia,
+ is.n_type, is.n_sclass, 0,
+ is.n_numaux, auxptr);
+ }
+ }
+
+ iline.l_addr.l_symndx = indx;
+ }
+
+ bfd_coff_swap_lineno_out (output_bfd, (PTR) &iline, (PTR) eline);
+ }
+
+ if (bfd_seek (output_bfd,
+ (o->output_section->line_filepos
+ + o->output_section->lineno_count * linesz),
+ SEEK_SET) != 0
+ || bfd_write (finfo->linenos, linesz, o->lineno_count,
+ output_bfd) != linesz * o->lineno_count)
+ return false;
+
+ o->output_section->lineno_count += o->lineno_count;
+ }
+ }
+
+ /* If we swapped out a C_FILE symbol, guess that the next C_FILE
+ symbol will be the first symbol in the next input file. In the
+ normal case, this will save us from writing out the C_FILE symbol
+ again. */
+ if (finfo->last_file_index != -1
+ && (bfd_size_type) finfo->last_file_index >= syment_base)
+ {
+ finfo->last_file.n_value = output_index;
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &finfo->last_file,
+ (PTR) (finfo->outsyms
+ + ((finfo->last_file_index - syment_base)
+ * osymesz)));
+ }
+
+ /* Write the modified symbols to the output file. */
+ if (outsym > finfo->outsyms)
+ {
+ if (bfd_seek (output_bfd,
+ obj_sym_filepos (output_bfd) + syment_base * osymesz,
+ SEEK_SET) != 0
+ || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
+ output_bfd)
+ != (bfd_size_type) (outsym - finfo->outsyms)))
+ return false;
+
+ BFD_ASSERT ((obj_raw_syment_count (output_bfd)
+ + (outsym - finfo->outsyms) / osymesz)
+ == output_index);
+
+ obj_raw_syment_count (output_bfd) = output_index;
+ }
+
+ /* Relocate the contents of each section. */
+ adjust_symndx = coff_backend_info (input_bfd)->_bfd_coff_adjust_symndx;
+ for (o = input_bfd->sections; o != NULL; o = o->next)
+ {
+ bfd_byte *contents;
+ struct coff_section_tdata *secdata;
+
+ if (! o->linker_mark)
+ {
+ /* This section was omitted from the link. */
+ continue;
+ }
+
+ if ((o->flags & SEC_HAS_CONTENTS) == 0
+ || (o->_raw_size == 0 && (o->flags & SEC_RELOC) == 0))
+ {
+ if ((o->flags & SEC_RELOC) != 0
+ && o->reloc_count != 0)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: relocs in section `%s', but it has no contents"),
+ bfd_get_filename (input_bfd),
+ bfd_get_section_name (input_bfd, o)));
+ bfd_set_error (bfd_error_no_contents);
+ return false;
+ }
+
+ continue;
+ }
+
+ secdata = coff_section_data (input_bfd, o);
+ if (secdata != NULL && secdata->contents != NULL)
+ contents = secdata->contents;
+ else
+ {
+ if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
+ (file_ptr) 0, o->_raw_size))
+ return false;
+ contents = finfo->contents;
+ }
+
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ int target_index;
+ struct internal_reloc *internal_relocs;
+ struct internal_reloc *irel;
+
+ /* Read in the relocs. */
+ target_index = o->output_section->target_index;
+ internal_relocs = (_bfd_coff_read_internal_relocs
+ (input_bfd, o, false, finfo->external_relocs,
+ finfo->info->relocateable,
+ (finfo->info->relocateable
+ ? (finfo->section_info[target_index].relocs
+ + o->output_section->reloc_count)
+ : finfo->internal_relocs)));
+ if (internal_relocs == NULL)
+ return false;
+
+ /* Call processor specific code to relocate the section
+ contents. */
+ if (! bfd_coff_relocate_section (output_bfd, finfo->info,
+ input_bfd, o,
+ contents,
+ internal_relocs,
+ finfo->internal_syms,
+ finfo->sec_ptrs))
+ return false;
+
+ if (finfo->info->relocateable)
+ {
+ bfd_vma offset;
+ struct internal_reloc *irelend;
+ struct coff_link_hash_entry **rel_hash;
+
+ offset = o->output_section->vma + o->output_offset - o->vma;
+ irel = internal_relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = (finfo->section_info[target_index].rel_hashes
+ + o->output_section->reloc_count);
+ for (; irel < irelend; irel++, rel_hash++)
+ {
+ struct coff_link_hash_entry *h;
+ boolean adjusted;
+
+ *rel_hash = NULL;
+
+ /* Adjust the reloc address and symbol index. */
+
+ irel->r_vaddr += offset;
+
+ if (irel->r_symndx == -1)
+ continue;
+
+ if (adjust_symndx)
+ {
+ if (! (*adjust_symndx) (output_bfd, finfo->info,
+ input_bfd, o, irel,
+ &adjusted))
+ return false;
+ if (adjusted)
+ continue;
+ }
+
+ h = obj_coff_sym_hashes (input_bfd)[irel->r_symndx];
+ if (h != NULL)
+ {
+ /* This is a global symbol. */
+ if (h->indx >= 0)
+ irel->r_symndx = h->indx;
+ else
+ {
+ /* This symbol is being written at the end
+ of the file, and we do not yet know the
+ symbol index. We save the pointer to the
+ hash table entry in the rel_hash list.
+ We set the indx field to -2 to indicate
+ that this symbol must not be stripped. */
+ *rel_hash = h;
+ h->indx = -2;
+ }
+ }
+ else
+ {
+ long indx;
+
+ indx = finfo->sym_indices[irel->r_symndx];
+ if (indx != -1)
+ irel->r_symndx = indx;
+ else
+ {
+ struct internal_syment *is;
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ /* This reloc is against a symbol we are
+ stripping. This should have been handled
+ by the 'dont_skip_symbol' code in the while
+ loop at the top of this function. */
+
+ is = finfo->internal_syms + irel->r_symndx;
+
+ name = (_bfd_coff_internal_syment_name
+ (input_bfd, is, buf));
+ if (name == NULL)
+ return false;
+
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, o,
+ irel->r_vaddr)))
+ return false;
+ }
+ }
+ }
+
+ o->output_section->reloc_count += o->reloc_count;
+ }
+ }
+
+ /* Write out the modified section contents. */
+ if (secdata == NULL || secdata->stab_info == NULL)
+ {
+ if (! bfd_set_section_contents (output_bfd, o->output_section,
+ contents, o->output_offset,
+ (o->_cooked_size != 0
+ ? o->_cooked_size
+ : o->_raw_size)))
+ return false;
+ }
+ else
+ {
+ if (! (_bfd_write_section_stabs
+ (output_bfd, &coff_hash_table (finfo->info)->stab_info,
+ o, &secdata->stab_info, contents)))
+ return false;
+ }
+ }
+
+ if (! finfo->info->keep_memory)
+ {
+ if (! _bfd_coff_free_symbols (input_bfd))
+ return false;
+ }
+
+ return true;
+}
+
+/* Write out a global symbol. Called via coff_link_hash_traverse. */
+
+boolean
+_bfd_coff_write_global_sym (h, data)
+ struct coff_link_hash_entry *h;
+ PTR data;
+{
+ struct coff_final_link_info *finfo = (struct coff_final_link_info *) data;
+ bfd *output_bfd;
+ struct internal_syment isym;
+ bfd_size_type symesz;
+ unsigned int i;
+
+ output_bfd = finfo->output_bfd;
+
+ if (h->indx >= 0)
+ return true;
+
+ if (h->indx != -2
+ && (finfo->info->strip == strip_all
+ || (finfo->info->strip == strip_some
+ && (bfd_hash_lookup (finfo->info->keep_hash,
+ h->root.root.string, false, false)
+ == NULL))))
+ return true;
+
+ switch (h->root.type)
+ {
+ default:
+ case bfd_link_hash_new:
+ abort ();
+ return false;
+
+ case bfd_link_hash_undefined:
+ case bfd_link_hash_undefweak:
+ isym.n_scnum = N_UNDEF;
+ isym.n_value = 0;
+ break;
+
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section->output_section;
+ if (bfd_is_abs_section (sec))
+ isym.n_scnum = N_ABS;
+ else
+ isym.n_scnum = sec->target_index;
+ isym.n_value = (h->root.u.def.value
+ + h->root.u.def.section->output_offset);
+ if (! obj_pe (finfo->output_bfd))
+ isym.n_value += sec->vma;
+ }
+ break;
+
+ case bfd_link_hash_common:
+ isym.n_scnum = N_UNDEF;
+ isym.n_value = h->root.u.c.size;
+ break;
+
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+ /* Just ignore these. They can't be handled anyhow. */
+ return true;
+ }
+
+ if (strlen (h->root.root.string) <= SYMNMLEN)
+ strncpy (isym._n._n_name, h->root.root.string, SYMNMLEN);
+ else
+ {
+ boolean hash;
+ bfd_size_type indx;
+
+ hash = true;
+ if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ hash = false;
+ indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, hash,
+ false);
+ if (indx == (bfd_size_type) -1)
+ {
+ finfo->failed = true;
+ return false;
+ }
+ isym._n._n_n._n_zeroes = 0;
+ isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
+ }
+
+ isym.n_sclass = h->class;
+ isym.n_type = h->type;
+
+ if (isym.n_sclass == C_NULL)
+ isym.n_sclass = C_EXT;
+
+ /* If doing task linking and this is the pass where we convert
+ defined globals to statics, then do that conversion now. If the
+ symbol is not being converted, just ignore it and it will be
+ output during a later pass. */
+ if (finfo->global_to_static)
+ {
+ if (isym.n_sclass != C_EXT
+ && isym.n_sclass != C_WEAKEXT
+ && (! obj_pe (output_bfd) || isym.n_sclass != C_NT_WEAK))
+ {
+ return true;
+ }
+ isym.n_sclass = C_STAT;
+ }
+
+ isym.n_numaux = h->numaux;
+
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) finfo->outsyms);
+
+ symesz = bfd_coff_symesz (output_bfd);
+
+ if (bfd_seek (output_bfd,
+ (obj_sym_filepos (output_bfd)
+ + obj_raw_syment_count (output_bfd) * symesz),
+ SEEK_SET) != 0
+ || bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz)
+ {
+ finfo->failed = true;
+ return false;
+ }
+
+ h->indx = obj_raw_syment_count (output_bfd);
+
+ ++obj_raw_syment_count (output_bfd);
+
+ /* Write out any associated aux entries. There normally will be
+ none. If there are any, I have no idea how to modify them. */
+ for (i = 0; i < isym.n_numaux; i++)
+ {
+ bfd_coff_swap_aux_out (output_bfd, (PTR) (h->aux + i), isym.n_type,
+ isym.n_sclass, i, isym.n_numaux,
+ (PTR) finfo->outsyms);
+ if (bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz)
+ {
+ finfo->failed = true;
+ return false;
+ }
+ ++obj_raw_syment_count (output_bfd);
+ }
+
+ return true;
+}
+
+/* Write out task global symbols, converting them to statics. Called
+ via coff_link_hash_traverse. Calls bfd_coff_write_global_sym to do
+ the dirty work, if the symbol we are processing needs conversion. */
+
+boolean
+_bfd_coff_write_task_globals (h, data)
+ struct coff_link_hash_entry *h;
+ PTR data;
+{
+ struct coff_final_link_info *finfo = (struct coff_final_link_info *) data;
+ boolean rtnval = true;
+ boolean save_global_to_static;
+
+ if (h->indx < 0)
+ {
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ save_global_to_static = finfo->global_to_static;
+ finfo->global_to_static = true;
+ rtnval = _bfd_coff_write_global_sym (h, data);
+ finfo->global_to_static = save_global_to_static;
+ break;
+ default:
+ break;
+ }
+ }
+ return (rtnval);
+}
+
+/* Handle a link order which is supposed to generate a reloc. */
+
+boolean
+_bfd_coff_reloc_link_order (output_bfd, finfo, output_section, link_order)
+ bfd *output_bfd;
+ struct coff_final_link_info *finfo;
+ asection *output_section;
+ struct bfd_link_order *link_order;
+{
+ reloc_howto_type *howto;
+ struct internal_reloc *irel;
+ struct coff_link_hash_entry **rel_hash_ptr;
+
+ howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
+ if (howto == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (link_order->u.reloc.p->addend != 0)
+ {
+ bfd_size_type size;
+ bfd_byte *buf;
+ bfd_reloc_status_type rstat;
+ boolean ok;
+
+ size = bfd_get_reloc_size (howto);
+ buf = (bfd_byte *) bfd_zmalloc (size);
+ if (buf == NULL)
+ return false;
+
+ rstat = _bfd_relocate_contents (howto, output_bfd,
+ link_order->u.reloc.p->addend, buf);
+ switch (rstat)
+ {
+ case bfd_reloc_ok:
+ break;
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ if (! ((*finfo->info->callbacks->reloc_overflow)
+ (finfo->info,
+ (link_order->type == bfd_section_reloc_link_order
+ ? bfd_section_name (output_bfd,
+ link_order->u.reloc.p->u.section)
+ : link_order->u.reloc.p->u.name),
+ howto->name, link_order->u.reloc.p->addend,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
+ {
+ free (buf);
+ return false;
+ }
+ break;
+ }
+ ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
+ (file_ptr) link_order->offset, size);
+ free (buf);
+ if (! ok)
+ return false;
+ }
+
+ /* Store the reloc information in the right place. It will get
+ swapped and written out at the end of the final_link routine. */
+
+ irel = (finfo->section_info[output_section->target_index].relocs
+ + output_section->reloc_count);
+ rel_hash_ptr = (finfo->section_info[output_section->target_index].rel_hashes
+ + output_section->reloc_count);
+
+ memset (irel, 0, sizeof (struct internal_reloc));
+ *rel_hash_ptr = NULL;
+
+ irel->r_vaddr = output_section->vma + link_order->offset;
+
+ if (link_order->type == bfd_section_reloc_link_order)
+ {
+ /* We need to somehow locate a symbol in the right section. The
+ symbol must either have a value of zero, or we must adjust
+ the addend by the value of the symbol. FIXME: Write this
+ when we need it. The old linker couldn't handle this anyhow. */
+ abort ();
+ *rel_hash_ptr = NULL;
+ irel->r_symndx = 0;
+ }
+ else
+ {
+ struct coff_link_hash_entry *h;
+
+ h = ((struct coff_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (output_bfd, finfo->info,
+ link_order->u.reloc.p->u.name,
+ false, false, true));
+ if (h != NULL)
+ {
+ if (h->indx >= 0)
+ irel->r_symndx = h->indx;
+ else
+ {
+ /* Set the index to -2 to force this symbol to get
+ written out. */
+ h->indx = -2;
+ *rel_hash_ptr = h;
+ irel->r_symndx = 0;
+ }
+ }
+ else
+ {
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ return false;
+ irel->r_symndx = 0;
+ }
+ }
+
+ /* FIXME: Is this always right? */
+ irel->r_type = howto->type;
+
+ /* r_size is only used on the RS/6000, which needs its own linker
+ routines anyhow. r_extern is only used for ECOFF. */
+
+ /* FIXME: What is the right value for r_offset? Is zero OK? */
+
+ ++output_section->reloc_count;
+
+ return true;
+}
+
+/* A basic reloc handling routine which may be used by processors with
+ simple relocs. */
+
+boolean
+_bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
+ input_section, contents, relocs, syms,
+ sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma addend;
+ bfd_vma val;
+ reloc_howto_type *howto;
+ bfd_reloc_status_type rstat;
+
+ symndx = rel->r_symndx;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ }
+ else
+ {
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ }
+
+ /* COFF treats common symbols in one of two ways. Either the
+ size of the symbol is included in the section contents, or it
+ is not. We assume that the size is not included, and force
+ the rtype_to_howto function to adjust the addend as needed. */
+
+ if (sym != NULL && sym->n_scnum != 0)
+ addend = - sym->n_value;
+ else
+ addend = 0;
+
+
+ howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
+ sym, &addend);
+ if (howto == NULL)
+ return false;
+
+ /* If we are doing a relocateable link, then we can just ignore
+ a PC relative reloc that is pcrel_offset. It will already
+ have the correct value. If this is not a relocateable link,
+ then we should ignore the symbol value. */
+ if (howto->pc_relative && howto->pcrel_offset)
+ {
+ if (info->relocateable)
+ continue;
+ if (sym != NULL && sym->n_scnum != 0)
+ addend += sym->n_value;
+ }
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ asection *sec;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
+ else
+ {
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value);
+ if (! obj_pe (input_bfd))
+ val -= sec->vma;
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ if (info->base_file)
+ {
+ /* Emit a reloc if the backend thinks it needs it. */
+ if (sym && pe_data (output_bfd)->in_reloc_p (output_bfd, howto))
+ {
+ /* Relocation to a symbol in a section which isn't
+ absolute. We output the address here to a file.
+ This file is then read by dlltool when generating the
+ reloc section. Note that the base file is not
+ portable between systems. We write out a long here,
+ and dlltool reads in a long. */
+ long addr = (rel->r_vaddr
+ - input_section->vma
+ + input_section->output_offset
+ + input_section->output_section->vma);
+ if (coff_data (output_bfd)->pe)
+ addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
+ if (fwrite (&addr, 1, sizeof (long), (FILE *) info->base_file)
+ != sizeof (long))
+ {
+ bfd_set_error (bfd_error_system_call);
+ return false;
+ }
+ }
+ }
+
+ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents,
+ rel->r_vaddr - input_section->vma,
+ val, addend);
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_outofrange:
+ (*_bfd_error_handler)
+ (_("%s: bad reloc address 0x%lx in section `%s'"),
+ bfd_get_filename (input_bfd),
+ (unsigned long) rel->r_vaddr,
+ bfd_get_section_name (input_bfd, input_section));
+ return false;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+ if (name == NULL)
+ return false;
+ }
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
diff --git a/bfd/coffswap.h b/bfd/coffswap.h
new file mode 100644
index 00000000000..ae30a5d966f
--- /dev/null
+++ b/bfd/coffswap.h
@@ -0,0 +1,908 @@
+/* Generic COFF swapping routines, for BFD.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file contains routines used to swap COFF data. It is a header
+ file because the details of swapping depend on the details of the
+ structures used by each COFF implementation. This is included by
+ coffcode.h, as well as by the ECOFF backend.
+
+ Any file which uses this must first include "coff/internal.h" and
+ "coff/CPU.h". The functions will then be correct for that CPU. */
+
+#ifndef IMAGE_BASE
+#define IMAGE_BASE 0
+#endif
+
+#define PUTWORD bfd_h_put_32
+#define PUTHALF bfd_h_put_16
+#define PUTBYTE bfd_h_put_8
+
+#ifndef GET_FCN_LNNOPTR
+#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#endif
+
+#ifndef GET_FCN_ENDNDX
+#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#endif
+
+#ifndef PUT_FCN_LNNOPTR
+#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#endif
+#ifndef PUT_FCN_ENDNDX
+#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#endif
+#ifndef GET_LNSZ_LNNO
+#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
+#endif
+#ifndef GET_LNSZ_SIZE
+#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
+#endif
+#ifndef PUT_LNSZ_LNNO
+#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
+#endif
+#ifndef PUT_LNSZ_SIZE
+#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
+#endif
+#ifndef GET_SCN_SCNLEN
+#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
+#endif
+#ifndef GET_SCN_NRELOC
+#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
+#endif
+#ifndef GET_SCN_NLINNO
+#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
+#endif
+#ifndef PUT_SCN_SCNLEN
+#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
+#endif
+#ifndef PUT_SCN_NRELOC
+#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
+#endif
+#ifndef PUT_SCN_NLINNO
+#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
+#endif
+#ifndef GET_LINENO_LNNO
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
+#endif
+#ifndef PUT_LINENO_LNNO
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
+#endif
+
+/* The f_symptr field in the filehdr is sometimes 64 bits. */
+#ifndef GET_FILEHDR_SYMPTR
+#define GET_FILEHDR_SYMPTR bfd_h_get_32
+#endif
+#ifndef PUT_FILEHDR_SYMPTR
+#define PUT_FILEHDR_SYMPTR bfd_h_put_32
+#endif
+
+/* Some fields in the aouthdr are sometimes 64 bits. */
+#ifndef GET_AOUTHDR_TSIZE
+#define GET_AOUTHDR_TSIZE bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_TSIZE
+#define PUT_AOUTHDR_TSIZE bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_DSIZE
+#define GET_AOUTHDR_DSIZE bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_DSIZE
+#define PUT_AOUTHDR_DSIZE bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_BSIZE
+#define GET_AOUTHDR_BSIZE bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_BSIZE
+#define PUT_AOUTHDR_BSIZE bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_ENTRY
+#define GET_AOUTHDR_ENTRY bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_ENTRY
+#define PUT_AOUTHDR_ENTRY bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_TEXT_START
+#define GET_AOUTHDR_TEXT_START bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_TEXT_START
+#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_DATA_START
+#define GET_AOUTHDR_DATA_START bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_DATA_START
+#define PUT_AOUTHDR_DATA_START bfd_h_put_32
+#endif
+
+/* Some fields in the scnhdr are sometimes 64 bits. */
+#ifndef GET_SCNHDR_PADDR
+#define GET_SCNHDR_PADDR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_PADDR
+#define PUT_SCNHDR_PADDR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_VADDR
+#define GET_SCNHDR_VADDR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_VADDR
+#define PUT_SCNHDR_VADDR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_SIZE
+#define GET_SCNHDR_SIZE bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_SIZE
+#define PUT_SCNHDR_SIZE bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_SCNPTR
+#define GET_SCNHDR_SCNPTR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_SCNPTR
+#define PUT_SCNHDR_SCNPTR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_RELPTR
+#define GET_SCNHDR_RELPTR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_RELPTR
+#define PUT_SCNHDR_RELPTR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_LNNOPTR
+#define GET_SCNHDR_LNNOPTR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_LNNOPTR
+#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_NRELOC
+#define GET_SCNHDR_NRELOC bfd_h_get_16
+#endif
+#ifndef PUT_SCNHDR_NRELOC
+#define PUT_SCNHDR_NRELOC bfd_h_put_16
+#endif
+#ifndef GET_SCNHDR_NLNNO
+#define GET_SCNHDR_NLNNO bfd_h_get_16
+#endif
+#ifndef PUT_SCNHDR_NLNNO
+#define PUT_SCNHDR_NLNNO bfd_h_put_16
+#endif
+#ifndef GET_SCNHDR_FLAGS
+#define GET_SCNHDR_FLAGS bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_FLAGS
+#define PUT_SCNHDR_FLAGS bfd_h_put_32
+#endif
+
+
+static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
+#ifndef NO_COFF_RELOCS
+static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
+#endif /* NO_COFF_RELOCS */
+#ifndef NO_COFF_SYMBOLS
+static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+#endif /* NO_COFF_SYMBOLS */
+#ifndef NO_COFF_LINENOS
+static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
+#endif /* NO_COFF_LINENOS */
+
+#ifndef NO_COFF_RELOCS
+
+static void
+coff_swap_reloc_in (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ RELOC *reloc_src = (RELOC *) src;
+ struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
+
+ reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
+ reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
+
+#ifdef RS6000COFF_C
+ reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
+ reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
+#else
+ reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
+#endif
+
+#ifdef SWAP_IN_RELOC_OFFSET
+ reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
+ (bfd_byte *) reloc_src->r_offset);
+#endif
+}
+
+static unsigned int
+coff_swap_reloc_out (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ struct internal_reloc *reloc_src = (struct internal_reloc *)src;
+ struct external_reloc *reloc_dst = (struct external_reloc *)dst;
+ bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
+ bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
+
+#ifdef RS6000COFF_C
+ bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
+ bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
+#else
+ bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
+ reloc_dst->r_type);
+#endif
+
+#ifdef SWAP_OUT_RELOC_OFFSET
+ SWAP_OUT_RELOC_OFFSET(abfd,
+ reloc_src->r_offset,
+ (bfd_byte *) reloc_dst->r_offset);
+#endif
+#ifdef SWAP_OUT_RELOC_EXTRA
+ SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
+#endif
+
+ return RELSZ;
+}
+
+#endif /* NO_COFF_RELOCS */
+
+static void
+coff_swap_filehdr_in (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ FILHDR *filehdr_src = (FILHDR *) src;
+ struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
+#ifdef COFF_ADJUST_FILEHDR_IN_PRE
+ COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst);
+#endif
+ filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
+ filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
+ filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
+ filehdr_dst->f_symptr =
+ GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
+ filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
+ filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
+ filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
+#ifdef TIC80_TARGET_ID
+ filehdr_dst->f_target_id = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_target_id);
+#endif
+
+#ifdef COFF_ADJUST_FILEHDR_IN_POST
+ COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst);
+#endif
+}
+
+static unsigned int
+coff_swap_filehdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
+ FILHDR *filehdr_out = (FILHDR *)out;
+
+#ifdef COFF_ADJUST_FILEHDR_OUT_PRE
+ COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out);
+#endif
+ bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
+ bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
+ bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
+ (bfd_byte *) filehdr_out->f_symptr);
+ bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
+ bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
+ bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
+#ifdef TIC80_TARGET_ID
+ bfd_h_put_16(abfd, filehdr_in->f_target_id, (bfd_byte *) filehdr_out->f_target_id);
+#endif
+
+#ifdef COFF_ADJUST_FILEHDR_OUT_POST
+ COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out);
+#endif
+ return FILHSZ;
+}
+
+
+#ifndef NO_COFF_SYMBOLS
+
+static void
+coff_swap_sym_in (abfd, ext1, in1)
+ bfd *abfd;
+ PTR ext1;
+ PTR in1;
+{
+ SYMENT *ext = (SYMENT *)ext1;
+ struct internal_syment *in = (struct internal_syment *)in1;
+
+ if( ext->e.e_name[0] == 0) {
+ in->_n._n_n._n_zeroes = 0;
+ in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
+ }
+ else {
+#if SYMNMLEN != E_SYMNMLEN
+ -> Error, we need to cope with truncating or extending SYMNMLEN!;
+#else
+ memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
+#endif
+ }
+ in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
+ in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
+ if (sizeof(ext->e_type) == 2){
+ in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
+ }
+ else {
+ in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
+ }
+ in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
+ in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
+}
+
+static unsigned int
+coff_swap_sym_out (abfd, inp, extp)
+ bfd *abfd;
+ PTR inp;
+ PTR extp;
+{
+ struct internal_syment *in = (struct internal_syment *)inp;
+ SYMENT *ext =(SYMENT *)extp;
+ if(in->_n._n_name[0] == 0) {
+ bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
+ bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
+ }
+ else {
+#if SYMNMLEN != E_SYMNMLEN
+ -> Error, we need to cope with truncating or extending SYMNMLEN!;
+#else
+ memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
+#endif
+ }
+ bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
+ bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
+ if (sizeof(ext->e_type) == 2)
+ {
+ bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
+ }
+ else
+ {
+ bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
+ }
+ bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
+ bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
+ return SYMESZ;
+}
+
+static void
+coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
+ bfd *abfd;
+ PTR ext1;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR in1;
+{
+ AUXENT *ext = (AUXENT *)ext1;
+ union internal_auxent *in = (union internal_auxent *)in1;
+
+#ifdef COFF_ADJUST_AUX_IN_PRE
+ COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
+#endif
+ switch (class) {
+ case C_FILE:
+ if (ext->x_file.x_fname[0] == 0) {
+ in->x_file.x_n.x_zeroes = 0;
+ in->x_file.x_n.x_offset =
+ bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
+ } else {
+#if FILNMLEN != E_FILNMLEN
+ -> Error, we need to cope with truncating or extending FILNMLEN!;
+#else
+ memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+#endif
+ }
+ goto end;
+
+ /* RS/6000 "csect" auxents */
+#ifdef RS6000COFF_C
+ case C_EXT:
+ case C_HIDEXT:
+ if (indx + 1 == numaux)
+ {
+ in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
+ in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
+ ext->x_csect.x_parmhash);
+ in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
+ /* We don't have to hack bitfields in x_smtyp because it's
+ defined by shifts-and-ands, which are equivalent on all
+ byte orders. */
+ in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
+ in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
+ in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
+ in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
+ goto end;
+ }
+ break;
+#endif
+
+ case C_STAT:
+#ifdef C_LEAFSTAT
+ case C_LEAFSTAT:
+#endif
+ case C_HIDDEN:
+ if (type == T_NULL) {
+ in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
+ in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
+ in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
+
+ /* PE defines some extra fields; we zero them out for
+ safety. */
+ in->x_scn.x_checksum = 0;
+ in->x_scn.x_associated = 0;
+ in->x_scn.x_comdat = 0;
+
+ goto end;
+ }
+ break;
+ }
+
+ in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
+#ifndef NO_TVNDX
+ in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
+#endif
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
+ in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
+ }
+ else
+ {
+#if DIMNUM != E_DIMNUM
+ #error we need to cope with truncating or extending DIMNUM
+#endif
+ in->x_sym.x_fcnary.x_ary.x_dimen[0] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ in->x_sym.x_fcnary.x_ary.x_dimen[1] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ in->x_sym.x_fcnary.x_ary.x_dimen[2] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ in->x_sym.x_fcnary.x_ary.x_dimen[3] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ }
+
+ if (ISFCN(type)) {
+ in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ }
+ else {
+ in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
+ in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
+ }
+
+end: ;
+ /* the semicolon is because MSVC doesn't like labels at
+ end of block. */
+
+#ifdef COFF_ADJUST_AUX_IN_POST
+ COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
+#endif
+}
+
+static unsigned int
+coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
+ bfd *abfd;
+ PTR inp;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR extp;
+{
+ union internal_auxent *in = (union internal_auxent *)inp;
+ AUXENT *ext = (AUXENT *)extp;
+
+#ifdef COFF_ADJUST_AUX_OUT_PRE
+ COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
+#endif
+ memset((PTR)ext, 0, AUXESZ);
+ switch (class) {
+ case C_FILE:
+ if (in->x_file.x_fname[0] == 0) {
+ PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
+ PUTWORD(abfd,
+ in->x_file.x_n.x_offset,
+ (bfd_byte *) ext->x_file.x_n.x_offset);
+ }
+ else {
+#if FILNMLEN != E_FILNMLEN
+ -> Error, we need to cope with truncating or extending FILNMLEN!;
+#else
+ memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
+#endif
+ }
+ goto end;
+
+#ifdef RS6000COFF_C
+ /* RS/6000 "csect" auxents */
+ case C_EXT:
+ case C_HIDEXT:
+ if (indx + 1 == numaux)
+ {
+ PUTWORD (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen);
+ PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
+ PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
+ /* We don't have to hack bitfields in x_smtyp because it's
+ defined by shifts-and-ands, which are equivalent on all
+ byte orders. */
+ PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
+ PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
+ PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
+ PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
+ goto end;
+ }
+ break;
+#endif
+
+ case C_STAT:
+#ifdef C_LEAFSTAT
+ case C_LEAFSTAT:
+#endif
+ case C_HIDDEN:
+ if (type == T_NULL) {
+ PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
+ PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
+ PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
+ goto end;
+ }
+ break;
+ }
+
+ PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
+#ifndef NO_TVNDX
+ bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
+#endif
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
+ PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
+ }
+ else
+ {
+#if DIMNUM != E_DIMNUM
+ #error we need to cope with truncating or extending DIMNUM
+#endif
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ }
+
+ if (ISFCN (type))
+ PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
+ (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ else
+ {
+ PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
+ PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
+ }
+
+end:
+#ifdef COFF_ADJUST_AUX_OUT_POST
+ COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
+#endif
+ return AUXESZ;
+}
+
+#endif /* NO_COFF_SYMBOLS */
+
+#ifndef NO_COFF_LINENOS
+
+static void
+coff_swap_lineno_in (abfd, ext1, in1)
+ bfd *abfd;
+ PTR ext1;
+ PTR in1;
+{
+ LINENO *ext = (LINENO *)ext1;
+ struct internal_lineno *in = (struct internal_lineno *)in1;
+
+ in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
+ in->l_lnno = GET_LINENO_LNNO(abfd, ext);
+}
+
+static unsigned int
+coff_swap_lineno_out (abfd, inp, outp)
+ bfd *abfd;
+ PTR inp;
+ PTR outp;
+{
+ struct internal_lineno *in = (struct internal_lineno *)inp;
+ struct external_lineno *ext = (struct external_lineno *)outp;
+ PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
+ ext->l_addr.l_symndx);
+
+ PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
+ return LINESZ;
+}
+
+#endif /* NO_COFF_LINENOS */
+
+static void
+coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
+ bfd *abfd;
+ PTR aouthdr_ext1;
+ PTR aouthdr_int1;
+{
+ AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
+ struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
+
+ aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
+ aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
+ aouthdr_int->tsize =
+ GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
+ aouthdr_int->dsize =
+ GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
+ aouthdr_int->bsize =
+ GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
+ aouthdr_int->entry =
+ GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
+ aouthdr_int->text_start =
+ GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
+ aouthdr_int->data_start =
+ GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
+
+#ifdef I960
+ aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
+#endif
+
+#ifdef APOLLO_M68
+ bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
+ bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
+ bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
+ bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
+#endif
+
+
+#ifdef RS6000COFF_C
+ aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
+ aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
+ aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
+ aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
+ aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
+ aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
+ aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
+ aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
+ aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
+ aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
+ aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype);
+ aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
+ aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata);
+#endif
+
+#ifdef MIPSECOFF
+ aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
+ aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
+ aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
+ aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
+ aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
+ aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
+ aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
+#endif
+
+#ifdef ALPHAECOFF
+ aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
+ aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
+ aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
+ aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
+#endif
+}
+
+static unsigned int
+coff_swap_aouthdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
+ AOUTHDR *aouthdr_out = (AOUTHDR *)out;
+
+ bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
+ bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
+ PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
+ PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
+ PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
+ PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
+ PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
+ (bfd_byte *) aouthdr_out->text_start);
+ PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
+ (bfd_byte *) aouthdr_out->data_start);
+
+#ifdef I960
+ bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
+#endif
+
+#ifdef RS6000COFF_C
+ bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
+ bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
+ bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
+ bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
+ bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
+ bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
+ bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
+ bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
+ bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
+ bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
+ bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
+ bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
+ bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
+ memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
+#endif
+
+#ifdef MIPSECOFF
+ bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
+ bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
+ bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
+ bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
+ bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
+ bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
+ bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
+#endif
+
+#ifdef ALPHAECOFF
+ /* FIXME: What does bldrev mean? */
+ bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
+ bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
+ bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
+ bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
+ bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
+ bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
+#endif
+
+ return AOUTSZ;
+}
+
+static void
+coff_swap_scnhdr_in (abfd, ext, in)
+ bfd *abfd;
+ PTR ext;
+ PTR in;
+{
+ SCNHDR *scnhdr_ext = (SCNHDR *) ext;
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
+
+#ifdef COFF_ADJUST_SCNHDR_IN_PRE
+ COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
+#endif
+ memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
+ scnhdr_int->s_vaddr =
+ GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
+ scnhdr_int->s_paddr =
+ GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
+ scnhdr_int->s_size =
+ GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
+
+ scnhdr_int->s_scnptr =
+ GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
+ scnhdr_int->s_relptr =
+ GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
+ scnhdr_int->s_lnnoptr =
+ GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
+ scnhdr_int->s_flags =
+ GET_SCNHDR_FLAGS (abfd, (bfd_byte *) scnhdr_ext->s_flags);
+ scnhdr_int->s_nreloc =
+ GET_SCNHDR_NRELOC (abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
+ scnhdr_int->s_nlnno =
+ GET_SCNHDR_NLNNO (abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
+#ifdef I960
+ scnhdr_int->s_align =
+ GET_SCNHDR_ALIGN (abfd, (bfd_byte *) scnhdr_ext->s_align);
+#endif
+#ifdef COFF_ADJUST_SCNHDR_IN_POST
+ COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
+#endif
+}
+
+static unsigned int
+coff_swap_scnhdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
+ SCNHDR *scnhdr_ext = (SCNHDR *)out;
+ unsigned int ret = SCNHSZ;
+
+#ifdef COFF_ADJUST_SCNHDR_OUT_PRE
+ COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
+#endif
+ memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
+
+ PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
+ (bfd_byte *) scnhdr_ext->s_vaddr);
+
+
+ PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
+ (bfd_byte *) scnhdr_ext->s_paddr);
+ PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
+ (bfd_byte *) scnhdr_ext->s_size);
+
+ PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
+ (bfd_byte *) scnhdr_ext->s_scnptr);
+ PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
+ (bfd_byte *) scnhdr_ext->s_relptr);
+ PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
+ (bfd_byte *) scnhdr_ext->s_lnnoptr);
+ PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags,
+ (bfd_byte *) scnhdr_ext->s_flags);
+#if defined(M88)
+ PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
+ PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
+#else
+ if (scnhdr_int->s_nlnno <= 0xffff)
+ PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
+ else
+ {
+ char buf[sizeof (scnhdr_int->s_name) + 1];
+
+ memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
+ buf[sizeof (scnhdr_int->s_name)] = '\0';
+ (*_bfd_error_handler)
+ (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
+ bfd_get_filename (abfd),
+ buf, scnhdr_int->s_nlnno);
+ PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
+ }
+ if (scnhdr_int->s_nreloc <= 0xffff)
+ PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
+ else
+ {
+ char buf[sizeof (scnhdr_int->s_name) + 1];
+
+ memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
+ buf[sizeof (scnhdr_int->s_name)] = '\0';
+ (*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
+ bfd_get_filename (abfd),
+ buf, scnhdr_int->s_nreloc);
+ bfd_set_error (bfd_error_file_truncated);
+ PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
+ ret = 0;
+ }
+#endif
+
+#ifdef I960
+ PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
+#endif
+#ifdef COFF_ADJUST_SCNHDR_OUT_POST
+ COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
+#endif
+ return ret;
+}
diff --git a/bfd/config.bfd b/bfd/config.bfd
new file mode 100644
index 00000000000..449ae915b1d
--- /dev/null
+++ b/bfd/config.bfd
@@ -0,0 +1,719 @@
+# config.bfd
+# Convert a canonical host type into a BFD host type.
+# Set shell variable targ to canonical target name, and run
+# using ``. config.bfd''.
+# Sets the following shell variables:
+# targ_defvec Default vector for this target
+# targ_selvecs Vectors to build for this target
+# targ_archs Architectures for this target
+# targ_cflags $(CFLAGS) for this target (FIXME: pretty bogus)
+# targ_underscore Whether underscores are used: yes or no
+
+# Part of this file is processed by targmatch.sed to generate the
+# targmatch.h file. The #ifdef and #endif lines that appear below are
+# copied directly into targmatch.h.
+
+# The binutils c++filt program wants to know whether underscores are
+# stripped or not. That is why we set targ_underscore. c++filt uses
+# this information to choose a default. This information is
+# duplicated in the symbol_leading_char field of the BFD target
+# vector, but c++filt does not deal with object files and is not
+# linked against libbfd.a. It is not terribly important that c++filt
+# get this right; it is just convenient.
+
+targ_defvec=
+targ_selvecs=
+targ_cflags=
+targ_underscore=no
+
+targ_cpu=`echo $targ | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+case "${targ_cpu}" in
+alpha*) targ_archs=bfd_alpha_arch ;;
+arm*) targ_archs=bfd_arm_arch ;;
+strongarm*) targ_archs=bfd_arm_arch ;;
+thumb*) targ_archs=bfd_arm_arch ;;
+c30*) targ_archs=bfd_tic30_arch ;;
+hppa*) targ_archs=bfd_hppa_arch ;;
+i[3456]86) targ_archs=bfd_i386_arch ;;
+m68*) targ_archs=bfd_m68k_arch ;;
+m88*) targ_archs=bfd_m88k_arch ;;
+mips*) targ_archs=bfd_mips_arch ;;
+powerpc*) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
+rs6000) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
+sparc*) targ_archs=bfd_sparc_arch ;;
+v850*) targ_archs=bfd_v850_arch ;;
+z8k*) targ_archs=bfd_z8k_arch ;;
+*) targ_archs=bfd_${targ_cpu}_arch ;;
+esac
+
+
+# WHEN ADDING ENTRIES TO THIS MATRIX:
+# Make sure that the left side always has two dashes. Otherwise you
+# can get spurious matches. Even for unambiguous cases, do this as a
+# convention, else the table becomes a real mess to understand and maintain.
+
+case "${targ}" in
+# START OF targmatch.h
+#ifdef BFD64
+ alpha*-*-netbsd*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+ alpha*-*-netware*)
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=nlm32_alpha_vec
+ ;;
+ alpha*-*-linuxecoff*)
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+ alpha*-*-linux-gnu* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+ alpha*-*-*vms*)
+ targ_defvec=vms_alpha_vec
+ ;;
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+#endif /* BFD64 */
+
+ arc-*-elf*)
+ targ_defvec=bfd_elf32_littlearc_vec
+ targ_selvecs=bfd_elf32_bigarc_vec
+ ;;
+
+ arm-*-riscix*)
+ targ_defvec=riscix_vec
+ ;;
+ arm-epoc-pe*)
+ targ_defvec=arm_epoc_pe_little_vec
+ targ_selvecs="arm_epoc_pe_little_vec arm_epoc_pe_big_vec arm_epoc_pei_little_vec arm_epoc_pei_big_vec"
+ targ_underscore=no
+ ;;
+ arm-*-pe*)
+ targ_defvec=armpe_little_vec
+ targ_selvecs="armpe_little_vec armpe_big_vec armpei_little_vec armpei_big_vec"
+ targ_underscore=yes
+ ;;
+ arm-*-aout | armel-*-aout)
+ targ_defvec=aout_arm_little_vec
+ targ_selvecs=aout_arm_big_vec
+ ;;
+ armeb-*-aout)
+ targ_defvec=aout_arm_big_vec
+ targ_selvecs=aout_arm_little_vec
+ ;;
+ arm-*-coff)
+ targ_defvec=armcoff_little_vec
+ targ_selvecs=armcoff_big_vec
+ targ_underscore=yes
+ ;;
+ arm-*-elf | arm*-*-linux-gnu)
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+ arm-*-oabi)
+ targ_defvec=bfd_elf32_littlearm_oabi_vec
+ targ_selvecs=bfd_elf32_bigarm_oabi_vec
+ ;;
+
+ thumb-*-coff)
+ targ_defvec=armcoff_little_vec
+ targ_selvecs=armcoff_big_vec
+ targ_underscore=yes
+ ;;
+ thumb-*-oabi)
+ targ_defvec=bfd_elf32_littlearm_oabi_vec
+ targ_selvecs=bfd_elf32_bigarm_oabi_vec
+ ;;
+ thumb-*-elf)
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+ thumb-epoc-pe*)
+ targ_defvec=arm_epoc_pe_little_vec
+ targ_selvecs="arm_epoc_pe_little_vec arm_epoc_pe_big_vec arm_epoc_pei_little_vec arm_epoc_pei_big_vec"
+ targ_underscore=no
+ ;;
+ thumb-*-pe*)
+ targ_defvec=armpe_little_vec
+ targ_selvecs="armpe_little_vec armpe_big_vec armpei_little_vec armpei_big_vec"
+ targ_underscore=yes
+ ;;
+ strongarm-*-elf)
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+ strongarm-*-coff)
+ targ_defvec=armcoff_little_vec
+ targ_selvecs=armcoff_big_vec
+ targ_underscore=yes
+ ;;
+
+ a29k-*-ebmon* | a29k-*-udi* | a29k-*-coff* | a29k-*-sym1* | \
+ a29k-*-vxworks* | a29k-*-sysv*)
+ targ_defvec=a29kcoff_big_vec
+ targ_selvecs=sunos_big_vec
+ targ_underscore=yes
+ ;;
+ a29k-*-aout* | a29k-*-bsd* | a29k-*-vsta*)
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+
+ c30-*-*aout* | tic30-*-*aout*)
+ targ_defvec=tic30_aout_vec
+ ;;
+ c30-*-*coff* | tic30-*-*coff*)
+ targ_defvec=tic30_coff_vec
+ ;;
+
+ d10v-*-*)
+ targ_defvec=bfd_elf32_d10v_vec
+ ;;
+
+ d30v-*-*)
+ targ_defvec=bfd_elf32_d30v_vec
+ ;;
+
+ fr30-*-elf)
+ targ_defvec=bfd_elf32_fr30_vec
+ ;;
+
+
+ h8300*-*-*)
+ targ_defvec=h8300coff_vec
+ targ_underscore=yes
+ ;;
+
+ h8500-*-*)
+ targ_defvec=h8500coff_vec
+ targ_underscore=yes
+ ;;
+
+ hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*)
+ targ_defvec=bfd_elf32_hppa_vec
+ ;;
+#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined (HOST_HPPAMPEIX)
+ hppa*-*-bsd*)
+ targ_defvec=som_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+ hppa*-*-hpux* | hppa*-*-hiux* | hppa*-*-mpeix*)
+ targ_defvec=som_vec
+ ;;
+ hppa*-*-osf*)
+ targ_defvec=som_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+#endif /* defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) */
+
+ i[3456]86-*-sco3.2v5*coff)
+ targ_defvec=i386coff_vec
+ targ_selvecs=bfd_elf32_i386_vec
+ ;;
+ i[3456]86-*-sysv4* | i[3456]86-*-unixware | i[3456]86-*-solaris2* | \
+ i[3456]86-*-elf | i[3456]86-*-sco3.2v5* | i[3456]86-*-freebsdelf* | \
+ i[3456]86-*-dgux* | i[3456]86-*-sysv5*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs=i386coff_vec
+ ;;
+ i[3456]86-*-msdosdjgpp* | i[3456]*-*-go32* | i[3456]86-go32-rtems* )
+ targ_defvec=go32coff_vec
+ targ_selvecs="go32stubbedcoff_vec i386aout_vec"
+ ;;
+ i[3456]86-*-sysv* | i[3456]86-*-isc* | i[3456]86-*-sco* | i[3456]86-*-coff | \
+ i[3456]86-*-aix* | i[3456]86*-*-rtems*)
+ targ_defvec=i386coff_vec
+ ;;
+ i[3456]86-sequent-bsd*)
+ targ_defvec=i386dynix_vec
+ targ_underscore=yes
+ ;;
+ i[3456]86-*-bsd*)
+ targ_defvec=i386bsd_vec
+ targ_underscore=yes
+ ;;
+ i[3456]86-*-freebsd*)
+ targ_defvec=i386freebsd_vec
+ targ_selvecs=i386bsd_vec
+ targ_underscore=yes
+ ;;
+ i[3456]86-*-netbsd* | i[3456]86-*-openbsd*)
+ targ_defvec=i386netbsd_vec
+ targ_selvecs=i386bsd_vec
+ targ_underscore=yes
+ ;;
+ i[3456]86-*-netware*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="nlm32_i386_vec i386coff_vec i386aout_vec"
+ ;;
+ i[3456]86-*-linux*aout*)
+ targ_defvec=i386linux_vec
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+ i[3456]86-*-linux-gnu*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs=i386linux_vec
+ ;;
+ i[3456]86-*-lynxos*)
+ targ_defvec=i386lynx_coff_vec
+ targ_selvecs=i386lynx_aout_vec
+ ;;
+ i[3456]86-*-gnu*)
+ targ_defvec=bfd_elf32_i386_vec
+ ;;
+ i[3456]86-*-mach* | i[3456]86-*-osf1mk*)
+ targ_defvec=i386mach3_vec
+ targ_cflags=-DSTAT_FOR_EXEC
+ targ_underscore=yes
+ ;;
+ i[3456]86-*-os9k)
+ targ_defvec=i386os9k_vec
+ ;;
+ i[3456]86-*-msdos*)
+ targ_defvec=i386aout_vec
+ targ_selvecs=i386msdos_vec
+ ;;
+ i[3456]86-*-moss*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386msdos_vec i386aout_vec"
+ ;;
+ i[3456]86-*-beospe*)
+ targ_defvec=i386pe_vec
+ targ_selvecs="i386pe_vec i386pei_vec"
+ ;;
+ i[3456]86-*-beoself* | i[3456]86-*-beos*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386pe_vec i386pei_vec"
+ ;;
+ i[3456]86-*-mingw32* | i[3456]86-*-cygwin* | i[3456]86-*-winnt | i[3456]86-*-pe)
+ targ_defvec=i386pe_vec
+ targ_selvecs="i386pe_vec i386pei_vec"
+ ;;
+ i[3456]86-none-*)
+ targ_defvec=i386coff_vec
+ ;;
+ i[3456]86-*-aout* | i[3456]86*-*-vsta*)
+ targ_defvec=i386aout_vec
+ ;;
+
+ i860-*-mach3* | i860-*-osf1* | i860-*-coff*)
+ targ_defvec=i860coff_vec
+ ;;
+ i860-*-sysv4* | i860-*-elf*)
+ targ_defvec=bfd_elf32_i860_vec
+ ;;
+
+ i960-*-vxworks4* | i960-*-vxworks5.0)
+ targ_defvec=b_out_vec_little_host
+ targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec ieee_vec"
+ targ_underscore=yes
+ ;;
+ i960-*-vxworks5.* | i960-*-coff* | i960-*-sysv* | i960-*-rtems*)
+ targ_defvec=icoff_little_vec
+ targ_selvecs="icoff_big_vec b_out_vec_little_host b_out_vec_big_host ieee_vec"
+ targ_underscore=yes
+ ;;
+ i960-*-vxworks* | i960-*-aout* | i960-*-bout* | i960-*-nindy*)
+ targ_defvec=b_out_vec_little_host
+ targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec ieee_vec"
+ targ_underscore=yes
+ ;;
+
+ m32r-*-*)
+ targ_defvec=bfd_elf32_m32r_vec
+ ;;
+
+ m68*-apollo-*)
+ targ_defvec=apollocoff_vec
+ ;;
+ m68*-bull-sysv*)
+ targ_defvec=m68kcoffun_vec
+ targ_underscore=yes
+ ;;
+ m68*-motorola-sysv*)
+ targ_defvec=m68ksysvcoff_vec
+ ;;
+ m68*-hp-bsd*)
+ targ_defvec=hp300bsd_vec
+ targ_underscore=yes
+ ;;
+ m68*-*-aout*)
+ targ_defvec=aout0_big_vec
+ # We include cisco_core_vec here, rather than making a separate cisco
+ # configuration, so that cisco-core.c gets routinely tested at
+ # least for compilation.
+ targ_selvecs="cisco_core_vec ieee_vec"
+ targ_underscore=yes
+ ;;
+ m68*-*-elf* | m68*-*-sysv4*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs="m68kcoff_vec ieee_vec"
+ ;;
+ m68*-*-coff* | m68*-*-sysv* | m68*-*-rtems*)
+ targ_defvec=m68kcoff_vec
+ targ_selvecs="m68kcoff_vec versados_vec ieee_vec"
+ ;;
+ m68*-*-hpux*)
+ targ_defvec=hp300hpux_vec
+ targ_underscore=yes
+ ;;
+ m68*-*-linux*aout*)
+ targ_defvec=m68klinux_vec
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+ ;;
+ m68*-*-linux-gnu*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=m68klinux_vec
+ ;;
+ m68*-*-gnu*)
+ targ_defvec=bfd_elf32_m68k_vec
+ # targ_selvecs=m68kmach3_vec
+ # targ_cflags=-DSTAT_FOR_EXEC
+ ;;
+ m68*-*-lynxos*)
+ targ_defvec=m68klynx_coff_vec
+ targ_selvecs=m68klynx_aout_vec
+ ;;
+ m68*-hp*-netbsd*)
+ targ_defvec=m68k4knetbsd_vec
+ targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+ m68*-*-netbsd* | m68*-*-openbsd*)
+ targ_defvec=m68knetbsd_vec
+ targ_selvecs="m68k4knetbsd_vec hp300bsd_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+ m68*-*-sunos* | m68*-*-os68k* | m68*-*-vxworks* | m68*-netx-* | \
+ m68*-*-bsd* | m68*-*-vsta*)
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+ m68*-ericsson-*)
+ targ_defvec=sunos_big_vec
+ targ_selvecs="m68kcoff_vec versados_vec tekhex_vec"
+ targ_underscore=yes
+ ;;
+ m68*-cbm-*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=m68kcoff_vec
+ ;;
+ m68*-apple-aux*)
+ targ_defvec=m68kaux_coff_vec
+ ;;
+ m68*-*-psos*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=ieee_vec
+ targ_underscore=yes
+ ;;
+
+ m88*-harris-cxux* | m88*-*-dgux* | m88*-*-sysv4*)
+ targ_defvec=bfd_elf32_m88k_vec
+ targ_selvecs=m88kbcs_vec
+ ;;
+ m88*-*-mach3*)
+ targ_defvec=m88kmach3_vec
+ targ_cflags=-DSTAT_FOR_EXEC
+ ;;
+ m88*-*-*)
+ targ_defvec=m88kbcs_vec
+ targ_underscore=yes
+ ;;
+
+ mcore-*-elf)
+ targ_defvec=bfd_elf32_mcore_big_vec
+ targ_selvecs="bfd_elf32_mcore_big_vec bfd_elf32_mcore_little_vec"
+ ;;
+ mcore-*-pe)
+ targ_defvec=mcore_pe_big_vec
+ targ_selvecs="mcore_pe_big_vec mcore_pe_little_vec mcore_pei_big_vec mcore_pei_little_vec"
+ ;;
+
+ mips*-big-*)
+ targ_defvec=ecoff_big_vec
+ targ_selvecs=ecoff_little_vec
+ ;;
+ mips-dec-netbsd* | mips*el*-*-netbsd*)
+ targ_defvec=bfd_elf32_littlemips_vec
+ targ_selvecs="bfd_elf32_bigmips_vec ecoff_little_vec ecoff_big_vec"
+ ;;
+ mips*-*-netbsd*)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ ;;
+ mips*-dec-bsd*)
+ targ_defvec=aout_mips_little_vec
+ targ_underscore=yes
+ ;;
+ mips*-dec-mach3*)
+ targ_defvec=aout_mips_little_vec
+ targ_cflags=-DSTAT_FOR_EXEC
+ ;;
+ mips*-dec-* | mips*el-*-ecoff*)
+ targ_defvec=ecoff_little_vec
+ targ_selvecs=ecoff_big_vec
+ ;;
+ mips*-*-ecoff*)
+ targ_defvec=ecoff_big_vec
+ targ_selvecs=ecoff_little_vec
+ ;;
+ mips*-*-irix6*)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
+ ;;
+ mips*-*-irix5*)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ ;;
+ mips*-sgi-* | mips*-*-bsd*)
+ targ_defvec=ecoff_big_vec
+ targ_selvecs=ecoff_little_vec
+ ;;
+ mips*-*-lnews*)
+ targ_defvec=ecoff_biglittle_vec
+ targ_selvecs="ecoff_little_vec ecoff_big_vec"
+ ;;
+ mips*-*-mach3*)
+ targ_defvec=aout_mips_little_vec
+ targ_cflags=-DSTAT_FOR_EXEC
+ ;;
+ mips*-*-sysv4*)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ ;;
+ mips*-*-sysv* | mips*-*-riscos*)
+ targ_defvec=ecoff_big_vec
+ targ_selvecs=ecoff_little_vec
+ ;;
+ mips*el-*-elf* | mips*el-*-vxworks*)
+ targ_defvec=bfd_elf32_littlemips_vec
+ targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
+ ;;
+ mips*-*-elf* | mips*-*-rtems* | mips*-*-vxworks*)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
+ ;;
+ mips*-*-none)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
+ ;;
+ mips*el*-*-linux-gnu* | mips*el*-*-openbsd*)
+ targ_defvec=bfd_elf32_littlemips_vec
+ targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_little_vec ecoff_big_vec"
+ ;;
+ mips*-*-linux-gnu* | mips*-*-openbsd*)
+ targ_defvec=bfd_elf32_bigmips_vec
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ ;;
+
+ mn10200-*-*)
+ targ_defvec=bfd_elf32_mn10200_vec
+ ;;
+
+ mn10300-*-*)
+ targ_defvec=bfd_elf32_mn10300_vec
+ ;;
+
+ ns32k-pc532-mach* | ns32k-pc532-ux*)
+ targ_defvec=pc532machaout_vec
+ targ_underscore=yes
+ ;;
+ ns32k-*-netbsd* | ns32k-*-lites* | ns32k-*-openbsd*)
+ targ_defvec=pc532netbsd_vec
+ targ_underscore=yes
+ ;;
+
+ powerpc-*-aix* | powerpc-*-beos*)
+ targ_defvec=rs6000coff_vec
+ ;;
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+ powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
+ powerpc-*-vxworks*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+ ;;
+ powerpc-*-macos* | powerpc-*-mpw*)
+ targ_defvec=pmac_xcoff_vec
+ ;;
+ powerpc-*-netware*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="nlm32_powerpc_vec rs6000coff_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+ powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+
+ powerpcle-*-pe | powerpcle-*-winnt* | powerpcle-*-cygwin*)
+ targ_defvec=bfd_powerpcle_pe_vec
+ targ_selvecs="bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
+ ;;
+
+ rs6000-*-*)
+ targ_defvec=rs6000coff_vec
+ ;;
+
+ sh-*-elf*)
+ targ_defvec=bfd_elf32_sh_vec
+ targ_selvecs="bfd_elf32_shl_vec shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec"
+ targ_underscore=yes
+ ;;
+ sh-*-* | sh-*-rtems*)
+ targ_defvec=shcoff_vec
+ targ_selvecs="shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec"
+ targ_underscore=yes
+ ;;
+
+ sparclet-*-aout*)
+ targ_defvec=sunos_big_vec
+ targ_selvecs=sparcle_aout_vec
+ targ_underscore=yes
+ ;;
+ sparc86x-*-aout*)
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+ sparclite-*-elf* | sparc86x-*-elf*)
+ targ_defvec=bfd_elf32_sparc_vec
+ ;;
+ sparc-*-linux*aout*)
+ targ_defvec=sparclinux_vec
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+ sparc-*-linux-gnu*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec sunos_big_vec"
+ ;;
+ sparc-*-lynxos*)
+ targ_defvec=sparclynx_coff_vec
+ targ_selvecs=sparclynx_aout_vec
+ ;;
+ sparc-*-netbsd* | sparc-*-openbsd*)
+ targ_defvec=sparcnetbsd_vec
+ targ_underscore=yes
+ ;;
+ sparc-*-elf* | sparc-*-solaris2*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs=sunos_big_vec
+ ;;
+ sparc-*-sysv4*)
+ targ_defvec=bfd_elf32_sparc_vec
+ ;;
+ sparc-*-netware*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="nlm32_sparc_vec sunos_big_vec"
+ ;;
+#ifdef BFD64
+ sparc64-*-aout*)
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+ sparc64-*-linux-gnu*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+ sparc64-*-elf*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs=bfd_elf32_sparc_vec
+ ;;
+#endif /* BFD64 */
+ sparc*-*-coff*)
+ targ_defvec=sparccoff_vec
+ ;;
+ sparc*-*-* | sparc*-*-rtems*)
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+
+#if HAVE_host_aout_vec
+ tahoe-*-*)
+ targ_defvec=host_aout_vec
+ targ_underscore=yes
+ ;;
+#endif
+
+ tic80*-*-*)
+ targ_defvec=tic80coff_vec
+ targ_underscore=yes
+ ;;
+
+
+ v850-*-*)
+ targ_defvec=bfd_elf32_v850_vec
+ ;;
+ v850e-*-*)
+ targ_defvec=bfd_elf32_v850_vec
+ ;;
+ v850ea-*-*)
+ targ_defvec=bfd_elf32_v850_vec
+ ;;
+#if HAVE_host_aout_vec
+ vax-*-bsd* | vax-*-ultrix*)
+ targ_defvec=host_aout_vec
+ targ_underscore=yes
+ ;;
+#endif
+
+ vax*-*-*vms*)
+ targ_defvec=vms_vax_vec
+ ;;
+
+ we32k-*-*)
+ targ_defvec=we32kcoff_vec
+ ;;
+
+ w65-*-*)
+ targ_defvec=w65_vec
+ ;;
+
+ z8k*-*-*)
+ targ_defvec=z8kcoff_vec
+ targ_underscore=yes
+ ;;
+
+ *-*-ieee*)
+ targ_defvec=ieee_vec
+ ;;
+
+ *-adobe-*)
+ targ_defvec=a_out_adobe_vec
+ targ_underscore=yes
+ ;;
+
+ *-sony-*)
+ targ_defvec=newsos3_vec
+ targ_underscore=yes
+ ;;
+
+ *-tandem-*)
+ targ_defvec=m68kcoff_vec
+ targ_selvecs=ieee_vec
+ ;;
+# END OF targmatch.h
+ *)
+ echo 1>&2 "*** BFD does not support target ${targ}."
+ echo 1>&2 "*** Look in bfd/config.bfd for supported targets."
+ exit 1
+ ;;
+esac
+
+# If we support any ELF target, then automatically add support for the
+# generic ELF targets. This permits an objdump with some ELF support
+# to be used on an arbitrary ELF file for anything other than
+# relocation information.
+case "${targ_defvec} ${targ_selvecs}" in
+ *bfd_elf64*)
+ targ_selvecs="${targ_selvecs} bfd_elf64_little_generic_vec bfd_elf64_big_generic_vec bfd_elf32_little_generic_vec bfd_elf32_big_generic_vec"
+ ;;
+ *bfd_elf32*)
+ targ_selvecs="${targ_selvecs} bfd_elf32_little_generic_vec bfd_elf32_big_generic_vec"
+ ;;
+esac
diff --git a/bfd/config.in b/bfd/config.in
new file mode 100644
index 00000000000..51fa45b6928
--- /dev/null
+++ b/bfd/config.in
@@ -0,0 +1,234 @@
+/* config.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if using alloca.c. */
+#undef C_ALLOCA
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+ This function is required for alloca.c support on those systems. */
+#undef CRAY_STACKSEG_END
+
+/* Define if you have alloca, as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+#undef HAVE_ALLOCA_H
+
+/* Define if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#undef off_t
+
+/* Define if you need to in order for stat and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#undef STACK_DIRECTION
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define if you have the __argz_count function. */
+#undef HAVE___ARGZ_COUNT
+
+/* Define if you have the __argz_next function. */
+#undef HAVE___ARGZ_NEXT
+
+/* Define if you have the __argz_stringify function. */
+#undef HAVE___ARGZ_STRINGIFY
+
+/* Define if you have the dcgettext function. */
+#undef HAVE_DCGETTEXT
+
+/* Define if you have the fcntl function. */
+#undef HAVE_FCNTL
+
+/* Define if you have the fdopen function. */
+#undef HAVE_FDOPEN
+
+/* Define if you have the getcwd function. */
+#undef HAVE_GETCWD
+
+/* Define if you have the getpagesize function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the madvise function. */
+#undef HAVE_MADVISE
+
+/* Define if you have the mprotect function. */
+#undef HAVE_MPROTECT
+
+/* Define if you have the munmap function. */
+#undef HAVE_MUNMAP
+
+/* Define if you have the putenv function. */
+#undef HAVE_PUTENV
+
+/* Define if you have the setenv function. */
+#undef HAVE_SETENV
+
+/* Define if you have the setitimer function. */
+#undef HAVE_SETITIMER
+
+/* Define if you have the setlocale function. */
+#undef HAVE_SETLOCALE
+
+/* Define if you have the stpcpy function. */
+#undef HAVE_STPCPY
+
+/* Define if you have the strcasecmp function. */
+#undef HAVE_STRCASECMP
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the sysconf function. */
+#undef HAVE_SYSCONF
+
+/* Define if you have the <argz.h> header file. */
+#undef HAVE_ARGZ_H
+
+/* Define if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
+/* Define if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define if you have the <ndir.h> header file. */
+#undef HAVE_NDIR_H
+
+/* Define if you have the <nl_types.h> header file. */
+#undef HAVE_NL_TYPES_H
+
+/* Define if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define if you have the <sys/dir.h> header file. */
+#undef HAVE_SYS_DIR_H
+
+/* Define if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define if you have the <sys/ndir.h> header file. */
+#undef HAVE_SYS_NDIR_H
+
+/* Define if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define if you have the <sys/procfs.h> header file. */
+#undef HAVE_SYS_PROCFS_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+
+/* Define if you have the stpcpy function */
+#undef HAVE_STPCPY
+
+/* Define if your locale.h file contains LC_MESSAGES. */
+#undef HAVE_LC_MESSAGES
+
+/* Define to 1 if NLS is requested */
+#undef ENABLE_NLS
+
+/* Define as 1 if you have gettext and don't want to use GNU gettext. */
+#undef HAVE_GETTEXT
+
+/* Use b modifier when opening binary files? */
+#undef USE_BINARY_FOPEN
+
+/* Define if strstr is not declared in system header files. */
+#undef NEED_DECLARATION_STRSTR
+
+/* Define if malloc is not declared in system header files. */
+#undef NEED_DECLARATION_MALLOC
+
+/* Define if realloc is not declared in system header files. */
+#undef NEED_DECLARATION_REALLOC
+
+/* Define if free is not declared in system header files. */
+#undef NEED_DECLARATION_FREE
+
+/* Define if getenv is not declared in system header files. */
+#undef NEED_DECLARATION_GETENV
+
+/* Define if <sys/procfs.h> has prstatus_t. */
+#undef HAVE_PRSTATUS_T
+
+/* Define if <sys/procfs.h> has prstatus_t.pr_who. */
+#undef HAVE_PRSTATUS_T_PR_WHO
+
+/* Define if <sys/procfs.h> has pstatus_t. */
+#undef HAVE_PSTATUS_T
+
+/* Define if <sys/procfs.h> has prpsinfo_t. */
+#undef HAVE_PRPSINFO_T
+
+/* Define if <sys/procfs.h> has psinfo_t. */
+#undef HAVE_PSINFO_T
+
+/* Define if <sys/procfs.h> has lwpstatus_t. */
+#undef HAVE_LWPSTATUS_T
+
+/* Define if <sys/procfs.h> has lwpstatus_t.pr_context. */
+#undef HAVE_LWPSTATUS_T_PR_CONTEXT
+
+/* Define if <sys/procfs.h> has lwpstatus_t.pr_reg. */
+#undef HAVE_LWPSTATUS_T_PR_REG
+
+/* Name of host specific header file to include in trad-core.c. */
+#undef TRAD_HEADER
+
+/* Use mmap if it's available? */
+#undef USE_MMAP
+
diff --git a/bfd/configure b/bfd/configure
new file mode 100755
index 00000000000..f6ca66fae69
--- /dev/null
+++ b/bfd/configure
@@ -0,0 +1,5987 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --enable-shared[=PKGS] build shared libraries [default=no]"
+ac_help="$ac_help
+ --enable-static[=PKGS] build static libraries [default=yes]"
+ac_help="$ac_help
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]"
+ac_help="$ac_help
+ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)"
+ac_help="$ac_help
+ --enable-targets alternative target configurations"
+ac_help="$ac_help
+ --enable-commonbfdlib build shared BFD/opcodes/libiberty library"
+ac_help="$ac_help
+ --with-mmap try using mmap for BFD input files if available"
+ac_help="$ac_help
+ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer"
+ac_help="$ac_help
+ --disable-nls do not use Native Language Support"
+ac_help="$ac_help
+ --with-included-gettext use the GNU gettext library included here"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=libbfd.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+# same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:594: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+echo "configure:615: checking target system type" >&5
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+ case $nonopt in
+ NONE) target_alias=$host_alias ;;
+ *) target_alias=$nonopt ;;
+ esac ;;
+esac
+
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:633: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:658: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:688: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:739: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:771: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 782 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:813: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:818: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:846: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:878: checking for POSIXized ISC" >&5
+if test -d /etc/conf/kconfig.d &&
+ grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+ echo "$ac_t""yes" 1>&6
+ ISC=yes # If later tests want to check for ISC.
+ cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+ if test "$GCC" = yes; then
+ CC="$CC -posix"
+ else
+ CC="$CC -Xp"
+ fi
+else
+ echo "$ac_t""no" 1>&6
+ ISC=
+fi
+
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:911: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
+echo "configure:964: checking whether build environment is sane" >&5
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "$*" != "X $srcdir/configure conftestfile" \
+ && test "$*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { echo "configure: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" 1>&2; exit 1; }
+ fi
+
+ test "$2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ { echo "configure: error: newly created file is older than distributed files!
+Check your system clock" 1>&2; exit 1; }
+fi
+rm -f conftest*
+echo "$ac_t""yes" 1>&6
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:1021: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+PACKAGE=bfd
+
+VERSION=2.9.4
+
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
+fi
+cat >> confdefs.h <<EOF
+#define PACKAGE "$PACKAGE"
+EOF
+
+cat >> confdefs.h <<EOF
+#define VERSION "$VERSION"
+EOF
+
+
+
+missing_dir=`cd $ac_aux_dir && pwd`
+echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
+echo "configure:1067: checking for working aclocal" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+ ACLOCAL=aclocal
+ echo "$ac_t""found" 1>&6
+else
+ ACLOCAL="$missing_dir/missing aclocal"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
+echo "configure:1080: checking for working autoconf" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoconf --version) < /dev/null > /dev/null 2>&1; then
+ AUTOCONF=autoconf
+ echo "$ac_t""found" 1>&6
+else
+ AUTOCONF="$missing_dir/missing autoconf"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working automake""... $ac_c" 1>&6
+echo "configure:1093: checking for working automake" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (automake --version) < /dev/null > /dev/null 2>&1; then
+ AUTOMAKE=automake
+ echo "$ac_t""found" 1>&6
+else
+ AUTOMAKE="$missing_dir/missing automake"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
+echo "configure:1106: checking for working autoheader" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoheader --version) < /dev/null > /dev/null 2>&1; then
+ AUTOHEADER=autoheader
+ echo "$ac_t""found" 1>&6
+else
+ AUTOHEADER="$missing_dir/missing autoheader"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
+echo "configure:1119: checking for working makeinfo" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
+ MAKEINFO=makeinfo
+ echo "$ac_t""found" 1>&6
+else
+ MAKEINFO="$missing_dir/missing makeinfo"
+ echo "$ac_t""missing" 1>&6
+fi
+
+
+
+if test $host != $build; then
+ ac_tool_prefix=${host_alias}-
+else
+ ac_tool_prefix=
+fi
+
+# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1142: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
+fi
+fi
+AR="$ac_cv_prog_AR"
+if test -n "$AR"; then
+ echo "$ac_t""$AR" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1174: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_RANLIB"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1206: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ RANLIB=":"
+fi
+fi
+
+
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+ enableval="$enable_shared"
+ p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac
+else
+ enable_shared=no
+fi
+
+
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+ enableval="$enable_static"
+ p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac
+else
+ enable_static=yes
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1289: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
+echo "configure:1329: checking for ld used by GCC" >&5
+ ac_prog=`($CC -print-prog-name=ld) 2>&5`
+ case "$ac_prog" in
+ # Accept absolute paths.
+ /* | [A-Za-z]:\\*)
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+echo "configure:1347: checking for GNU ld" >&5
+else
+ echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+echo "configure:1350: checking for non-GNU ld" >&5
+fi
+if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog"; then
+ ac_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+ test "$with_gnu_ld" != no && break
+ else
+ test "$with_gnu_ld" != yes && break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+ echo "$ac_t""$LD" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
+
+echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
+echo "configure:1386: checking if the linker ($LD) is GNU ld" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+ ac_cv_prog_gnu_ld=yes
+else
+ ac_cv_prog_gnu_ld=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
+
+
+echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+echo "configure:1402: checking for BSD-compatible nm" >&5
+if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$NM"; then
+ # Let the user override the test.
+ ac_cv_path_NM="$NM"
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/nm; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -B"
+ elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -p"
+ else
+ ac_cv_path_NM="$ac_dir/nm"
+ fi
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi
+fi
+
+NM="$ac_cv_path_NM"
+echo "$ac_t""$NM" 1>&6
+
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1437: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags=
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$silent" = yes && libtool_flags="$libtool_flags --silent"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$host" in
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '#line 1473 "configure"' > conftest.$ac_ext
+ if { (eval echo configure:1474: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ CFLAGS="$CFLAGS -belf"
+ ;;
+
+*-*-cygwin*)
+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1499: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+DLLTOOL="$ac_cv_prog_DLLTOOL"
+if test -n "$DLLTOOL"; then
+ echo "$ac_t""$DLLTOOL" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_DLLTOOL"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1531: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_DLLTOOL="dlltool"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_DLLTOOL" && ac_cv_prog_DLLTOOL="false"
+fi
+fi
+DLLTOOL="$ac_cv_prog_DLLTOOL"
+if test -n "$DLLTOOL"; then
+ echo "$ac_t""$DLLTOOL" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ DLLTOOL="false"
+fi
+fi
+
+# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1566: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AS"; then
+ ac_cv_prog_AS="$AS" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AS="${ac_tool_prefix}as"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+AS="$ac_cv_prog_AS"
+if test -n "$AS"; then
+ echo "$ac_t""$AS" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_AS"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "as", so it can be a program name with args.
+set dummy as; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1598: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AS"; then
+ ac_cv_prog_AS="$AS" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AS="as"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_AS" && ac_cv_prog_AS="false"
+fi
+fi
+AS="$ac_cv_prog_AS"
+if test -n "$AS"; then
+ echo "$ac_t""$AS" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ AS="false"
+fi
+fi
+
+
+ ;;
+
+esac
+
+# Actually configure libtool. ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
+DLLTOOL="$DLLTOOL" AS="$AS" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+
+
+# Check whether --enable-64-bit-bfd or --disable-64-bit-bfd was given.
+if test "${enable_64_bit_bfd+set}" = set; then
+ enableval="$enable_64_bit_bfd"
+ case "${enableval}" in
+ yes) want64=true ;;
+ no) want64=false ;;
+ *) { echo "configure: error: bad value ${enableval} for 64-bit-bfd option" 1>&2; exit 1; } ;;
+esac
+else
+ want64=false
+fi
+# Check whether --enable-targets or --disable-targets was given.
+if test "${enable_targets+set}" = set; then
+ enableval="$enable_targets"
+ case "${enableval}" in
+ yes | "") { echo "configure: error: enable-targets option must specify target names or 'all'" 1>&2; exit 1; }
+ ;;
+ no) enable_targets= ;;
+ *) enable_targets=$enableval ;;
+esac
+fi
+# Check whether --enable-commonbfdlib or --disable-commonbfdlib was given.
+if test "${enable_commonbfdlib+set}" = set; then
+ enableval="$enable_commonbfdlib"
+ case "${enableval}" in
+ yes) commonbfdlib=true ;;
+ no) commonbfdlib=false ;;
+ *) { echo "configure: error: bad value ${enableval} for BFD commonbfdlib option" 1>&2; exit 1; } ;;
+esac
+fi
+# Check whether --with-mmap or --without-mmap was given.
+if test "${with_mmap+set}" = set; then
+ withval="$with_mmap"
+ case "${withval}" in
+ yes) want_mmap=true ;;
+ no) want_mmap=false ;;
+ *) { echo "configure: error: bad value ${withval} for BFD with-mmap option" 1>&2; exit 1; } ;;
+esac
+else
+ want_mmap=false
+fi
+
+
+
+
+
+if test -z "$target" ; then
+ { echo "configure: error: Unrecognized target system type; please check config.sub." 1>&2; exit 1; }
+fi
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+
+echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
+echo "configure:1718: checking whether to enable maintainer-specific portions of Makefiles" >&5
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ USE_MAINTAINER_MODE=$enableval
+else
+ USE_MAINTAINER_MODE=no
+fi
+
+ echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6
+
+
+if test $USE_MAINTAINER_MODE = yes; then
+ MAINTAINER_MODE_TRUE=
+ MAINTAINER_MODE_FALSE='#'
+else
+ MAINTAINER_MODE_TRUE='#'
+ MAINTAINER_MODE_FALSE=
+fi
+ MAINT=$MAINTAINER_MODE_TRUE
+
+
+echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
+echo "configure:1741: checking for Cygwin environment" >&5
+if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1746 "configure"
+#include "confdefs.h"
+
+int main() {
+
+#ifndef __CYGWIN__
+#define __CYGWIN__ __CYGWIN32__
+#endif
+return __CYGWIN__;
+; return 0; }
+EOF
+if { (eval echo configure:1757: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_cygwin=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_cygwin=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_cygwin" 1>&6
+CYGWIN=
+test "$ac_cv_cygwin" = yes && CYGWIN=yes
+echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
+echo "configure:1774: checking for mingw32 environment" >&5
+if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1779 "configure"
+#include "confdefs.h"
+
+int main() {
+return __MINGW32__;
+; return 0; }
+EOF
+if { (eval echo configure:1786: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_mingw32=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_mingw32=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_mingw32" 1>&6
+MINGW32=
+test "$ac_cv_mingw32" = yes && MINGW32=yes
+
+
+echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
+echo "configure:1805: checking for executable suffix" >&5
+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
+ ac_cv_exeext=.exe
+else
+ rm -f conftest*
+ echo 'int main () { return 0; }' > conftest.$ac_ext
+ ac_cv_exeext=
+ if { (eval echo configure:1815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+ for file in conftest.*; do
+ case $file in
+ *.c | *.o | *.obj | *.ilk | *.pdb) ;;
+ *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+ esac
+ done
+ else
+ { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ rm -f conftest*
+ test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
+fi
+fi
+
+EXEEXT=""
+test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
+echo "$ac_t""${ac_cv_exeext}" 1>&6
+ac_exeext=$EXEEXT
+
+
+host64=false
+target64=false
+
+# host stuff:
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1844: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1874: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1925: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:1957: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 1968 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:1973: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:1999: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:2004: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2013: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:2032: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+
+ALL_LINGUAS=
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:2066: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 2081 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2087: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 2098 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2104: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 2115 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2121: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:2146: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2151 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2159: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 2176 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 2194 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2215 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:2226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:2250: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2255 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:2304: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:2325: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat > conftest.$ac_ext <<EOF
+#line 2332 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:2339: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+ inline | yes) ;;
+ no) cat >> confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+ *) cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+echo "configure:2365: checking for off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2370 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+echo "configure:2398: checking for size_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2403 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments. Useless!
+echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
+echo "configure:2433: checking for working alloca.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2438 "configure"
+#include "confdefs.h"
+#include <alloca.h>
+int main() {
+char *p = alloca(2 * sizeof(int));
+; return 0; }
+EOF
+if { (eval echo configure:2445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_header_alloca_h=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_alloca_h=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
+if test $ac_cv_header_alloca_h = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA_H 1
+EOF
+
+fi
+
+echo $ac_n "checking for alloca""... $ac_c" 1>&6
+echo "configure:2466: checking for alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2471 "configure"
+#include "confdefs.h"
+
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# else
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
+int main() {
+char *p = (char *) alloca(1);
+; return 0; }
+EOF
+if { (eval echo configure:2499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_func_alloca_works=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_func_alloca_works=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_func_alloca_works" 1>&6
+if test $ac_cv_func_alloca_works = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA 1
+EOF
+
+fi
+
+if test $ac_cv_func_alloca_works = no; then
+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+ # that cause trouble. Some versions do not even contain alloca or
+ # contain a buggy version. If you still want to use their alloca,
+ # use ar to extract alloca.o from them instead of compiling alloca.c.
+ ALLOCA=alloca.${ac_objext}
+ cat >> confdefs.h <<\EOF
+#define C_ALLOCA 1
+EOF
+
+
+echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+echo "configure:2531: checking whether alloca needs Cray hooks" >&5
+if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2536 "configure"
+#include "confdefs.h"
+#if defined(CRAY) && ! defined(CRAY2)
+webecray
+#else
+wenotbecray
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "webecray" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_os_cray=yes
+else
+ rm -rf conftest*
+ ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_os_cray" 1>&6
+if test $ac_cv_os_cray = yes; then
+for ac_func in _getb67 GETB67 getb67; do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2561: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2566 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<EOF
+#define CRAY_STACKSEG_END $ac_func
+EOF
+
+ break
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+done
+fi
+
+echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
+echo "configure:2616: checking stack direction for C alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_c_stack_direction=0
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2624 "configure"
+#include "confdefs.h"
+find_stack_direction ()
+{
+ static char *addr = 0;
+ auto char dummy;
+ if (addr == 0)
+ {
+ addr = &dummy;
+ return find_stack_direction ();
+ }
+ else
+ return (&dummy > addr) ? 1 : -1;
+}
+main ()
+{
+ exit (find_stack_direction() < 0);
+}
+EOF
+if { (eval echo configure:2643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_stack_direction=1
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_stack_direction=-1
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_c_stack_direction" 1>&6
+cat >> confdefs.h <<EOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+EOF
+
+fi
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2668: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2673 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2678: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_func in getpagesize
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2707: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2712 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for working mmap""... $ac_c" 1>&6
+echo "configure:2760: checking for working mmap" >&5
+if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2768 "configure"
+#include "confdefs.h"
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the filesystem buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propogated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+#ifdef __cplusplus
+extern "C" { void *malloc(unsigned); }
+#else
+char *malloc();
+#endif
+
+int
+main()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmap", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file at a fixed address which
+ * already has something else allocated at it. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmap", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ data2 = malloc(2 * pagesize);
+ if (!data2)
+ exit(1);
+ data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ /*
+ * Finally, make sure that changes to the mapped area
+ * do not percolate back to the file as seen by read().
+ * (This is a bug on some variants of i386 svr4.0.)
+ */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit(1);
+ close(fd);
+ unlink("conftestmmap");
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:2908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_MMAP 1
+EOF
+
+fi
+
+
+ for ac_hdr in argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h values.h sys/param.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2936: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2941 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2946: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in getcwd munmap putenv setenv setlocale strchr strcasecmp \
+__argz_count __argz_stringify __argz_next
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2976: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2981 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ for ac_func in stpcpy
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3033: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3038 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_STPCPY 1
+EOF
+
+ fi
+
+ if test $ac_cv_header_locale_h = yes; then
+ echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
+echo "configure:3095: checking for LC_MESSAGES" >&5
+if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3100 "configure"
+#include "confdefs.h"
+#include <locale.h>
+int main() {
+return LC_MESSAGES
+; return 0; }
+EOF
+if { (eval echo configure:3107: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ am_cv_val_LC_MESSAGES=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ am_cv_val_LC_MESSAGES=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$am_cv_val_LC_MESSAGES" 1>&6
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LC_MESSAGES 1
+EOF
+
+ fi
+ fi
+ echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6
+echo "configure:3128: checking whether NLS is requested" >&5
+ # Check whether --enable-nls or --disable-nls was given.
+if test "${enable_nls+set}" = set; then
+ enableval="$enable_nls"
+ USE_NLS=$enableval
+else
+ USE_NLS=yes
+fi
+
+ echo "$ac_t""$USE_NLS" 1>&6
+
+
+ USE_INCLUDED_LIBINTL=no
+
+ if test "$USE_NLS" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define ENABLE_NLS 1
+EOF
+
+ echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6
+echo "configure:3148: checking whether included gettext is requested" >&5
+ # Check whether --with-included-gettext or --without-included-gettext was given.
+if test "${with_included_gettext+set}" = set; then
+ withval="$with_included_gettext"
+ nls_cv_force_use_gnu_gettext=$withval
+else
+ nls_cv_force_use_gnu_gettext=no
+fi
+
+ echo "$ac_t""$nls_cv_force_use_gnu_gettext" 1>&6
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+ CATOBJEXT=NONE
+
+ ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for libintl.h""... $ac_c" 1>&6
+echo "configure:3167: checking for libintl.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3172 "configure"
+#include "confdefs.h"
+#include <libintl.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3177: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6
+echo "configure:3194: checking for gettext in libc" >&5
+if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3199 "configure"
+#include "confdefs.h"
+#include <libintl.h>
+int main() {
+return (int) gettext ("")
+; return 0; }
+EOF
+if { (eval echo configure:3206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ gt_cv_func_gettext_libc=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ gt_cv_func_gettext_libc=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6
+
+ if test "$gt_cv_func_gettext_libc" != "yes"; then
+ echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
+echo "configure:3222: checking for bindtextdomain in -lintl" >&5
+ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lintl $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3230 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char bindtextdomain();
+
+int main() {
+bindtextdomain()
+; return 0; }
+EOF
+if { (eval echo configure:3241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
+echo "configure:3257: checking for gettext in libintl" >&5
+if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3262 "configure"
+#include "confdefs.h"
+
+int main() {
+return (int) gettext ("")
+; return 0; }
+EOF
+if { (eval echo configure:3269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ gt_cv_func_gettext_libintl=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ gt_cv_func_gettext_libintl=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$gt_cv_func_gettext_libintl" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ fi
+
+ if test "$gt_cv_func_gettext_libc" = "yes" \
+ || test "$gt_cv_func_gettext_libintl" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_GETTEXT 1
+EOF
+
+ # Extract the first word of "msgfmt", so it can be a program name with args.
+set dummy msgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3297: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$MSGFMT" in
+ /*)
+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then
+ ac_cv_path_MSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="no"
+ ;;
+esac
+fi
+MSGFMT="$ac_cv_path_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ if test "$MSGFMT" != "no"; then
+ for ac_func in dcgettext
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3331: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3336 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ # Extract the first word of "gmsgfmt", so it can be a program name with args.
+set dummy gmsgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3386: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GMSGFMT" in
+ /*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GMSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"
+ ;;
+esac
+fi
+GMSGFMT="$ac_cv_path_GMSGFMT"
+if test -n "$GMSGFMT"; then
+ echo "$ac_t""$GMSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "xgettext", so it can be a program name with args.
+set dummy xgettext; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3422: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$XGETTEXT" in
+ /*)
+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then
+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"
+ ;;
+esac
+fi
+XGETTEXT="$ac_cv_path_XGETTEXT"
+if test -n "$XGETTEXT"; then
+ echo "$ac_t""$XGETTEXT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ cat > conftest.$ac_ext <<EOF
+#line 3454 "configure"
+#include "confdefs.h"
+
+int main() {
+extern int _nl_msg_cat_cntr;
+ return _nl_msg_cat_cntr
+; return 0; }
+EOF
+if { (eval echo configure:3462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ CATOBJEXT=.gmo
+ DATADIRNAME=share
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CATOBJEXT=.mo
+ DATADIRNAME=lib
+fi
+rm -f conftest*
+ INSTOBJEXT=.mo
+ fi
+ fi
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+ if test "$CATOBJEXT" = "NONE"; then
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ INTLOBJS="\$(GETTOBJS)"
+ # Extract the first word of "msgfmt", so it can be a program name with args.
+set dummy msgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3494: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$MSGFMT" in
+ /*)
+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then
+ ac_cv_path_MSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="msgfmt"
+ ;;
+esac
+fi
+MSGFMT="$ac_cv_path_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "gmsgfmt", so it can be a program name with args.
+set dummy gmsgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3528: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GMSGFMT" in
+ /*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GMSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"
+ ;;
+esac
+fi
+GMSGFMT="$ac_cv_path_GMSGFMT"
+if test -n "$GMSGFMT"; then
+ echo "$ac_t""$GMSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "xgettext", so it can be a program name with args.
+set dummy xgettext; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3564: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$XGETTEXT" in
+ /*)
+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then
+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"
+ ;;
+esac
+fi
+XGETTEXT="$ac_cv_path_XGETTEXT"
+if test -n "$XGETTEXT"; then
+ echo "$ac_t""$XGETTEXT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+ USE_INCLUDED_LIBINTL=yes
+ CATOBJEXT=.gmo
+ INSTOBJEXT=.mo
+ DATADIRNAME=share
+ INTLDEPS='$(top_builddir)/../intl/libintl.a'
+ INTLLIBS=$INTLDEPS
+ LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ if test "$XGETTEXT" != ":"; then
+ if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
+ : ;
+ else
+ echo "$ac_t""found xgettext programs is not GNU xgettext; ignore it" 1>&6
+ XGETTEXT=":"
+ fi
+ fi
+
+ # We need to process the po/ directory.
+ POSUB=po
+ else
+ DATADIRNAME=share
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ # If this is used in GNU gettext we have to set USE_NLS to `yes'
+ # because some of the sources are only built for this goal.
+ if test "$PACKAGE" = gettext; then
+ USE_NLS=yes
+ USE_INCLUDED_LIBINTL=yes
+ fi
+
+ for lang in $ALL_LINGUAS; do
+ GMOFILES="$GMOFILES $lang.gmo"
+ POFILES="$POFILES $lang.po"
+ done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
+echo "configure:3654: checking for catalogs to be installed" >&5
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ echo "$ac_t""$LINGUAS" 1>&6
+ fi
+
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+
+
+ if test -f $srcdir/po2tbl.sed.in; then
+ if test "$CATOBJEXT" = ".cat"; then
+ ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
+echo "configure:3682: checking for linux/version.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3687 "configure"
+#include "confdefs.h"
+#include <linux/version.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3692: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ msgformat=linux
+else
+ echo "$ac_t""no" 1>&6
+msgformat=xopen
+fi
+
+
+ sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
+ fi
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/po2tbl.sed.in > po2tbl.sed
+ fi
+
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+
+
+
+ MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
+
+
+ l=
+
+
+ if test -d $srcdir/po; then
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ fi
+
+
+# Permit host specific settings.
+. ${srcdir}/configure.host
+
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:3770: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+BFD_HOST_64BIT_LONG=0
+BFD_HOST_64_BIT_DEFINED=0
+BFD_HOST_64_BIT=
+BFD_HOST_U_64_BIT=
+if test "x${HOST_64BIT_TYPE}" = "xlong"; then
+ BFD_HOST_64BIT_LONG=1
+elif test "x${HOST_64BIT_TYPE}" != "x"; then
+ BFD_HOST_64_BIT_DEFINED=1
+ BFD_HOST_64_BIT=${HOST_64BIT_TYPE}
+ BFD_HOST_U_64_BIT=${HOST_U_64BIT_TYPE}
+fi
+
+
+
+
+
+# Put a plausible default for CC_FOR_BUILD in Makefile.
+if test -z "$CC_FOR_BUILD"; then
+ if test "x$cross_compiling" = "xno"; then
+ CC_FOR_BUILD='$(CC)'
+ else
+ CC_FOR_BUILD=gcc
+ fi
+fi
+
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+ EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+ echo $ac_n "checking for build system executable suffix""... $ac_c" 1>&6
+echo "configure:3853: checking for build system executable suffix" >&5
+if eval "test \"`echo '$''{'bfd_cv_build_exeext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > ac_c_test.c << 'EOF'
+int main() {
+/* Nothing needed here */
+}
+EOF
+ ${CC_FOR_BUILD} -o ac_c_test am_c_test.c 1>&5 2>&5
+ bfd_cv_build_exeext=`echo ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
+ rm -f ac_c_test*
+ test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no
+fi
+
+echo "$ac_t""$bfd_cv_build_exeext" 1>&6
+ EXEEXT_FOR_BUILD=""
+ test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
+fi
+
+
+for ac_hdr in stddef.h string.h strings.h stdlib.h time.h unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3878: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3883 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3888: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_hdr in fcntl.h sys/file.h sys/time.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3918: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3923 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+echo "configure:3955: checking whether time.h and sys/time.h may both be included" >&5
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3960 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:3969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_time=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+ cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
+echo "configure:3994: checking for $ac_hdr that defines DIR" >&5
+if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3999 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <$ac_hdr>
+int main() {
+DIR *dirp = 0;
+; return 0; }
+EOF
+if { (eval echo configure:4007: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ eval "ac_cv_header_dirent_$ac_safe=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_dirent_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+ ac_header_dirent=$ac_hdr; break
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
+echo "configure:4032: checking for opendir in -ldir" >&5
+ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ldir $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 4040 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char opendir();
+
+int main() {
+opendir()
+; return 0; }
+EOF
+if { (eval echo configure:4051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ LIBS="$LIBS -ldir"
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
+echo "configure:4073: checking for opendir in -lx" >&5
+ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lx $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 4081 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char opendir();
+
+int main() {
+opendir()
+; return 0; }
+EOF
+if { (eval echo configure:4092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ LIBS="$LIBS -lx"
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+for ac_func in fcntl getpagesize setitimer sysconf fdopen
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:4117: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4122 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:4145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+
+case "${host}" in
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows)
+ cat >> confdefs.h <<\EOF
+#define USE_BINARY_FOPEN 1
+EOF
+ ;;
+esac
+
+echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6
+echo "configure:4180: checking whether strstr must be declared" >&5
+if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4185 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+int main() {
+char *(*pfn) = (char *(*)) strstr
+; return 0; }
+EOF
+if { (eval echo configure:4206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_decl_needed_strstr=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_decl_needed_strstr=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bfd_cv_decl_needed_strstr" 1>&6
+if test $bfd_cv_decl_needed_strstr = yes; then
+ cat >> confdefs.h <<\EOF
+#define NEED_DECLARATION_STRSTR 1
+EOF
+
+fi
+
+echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6
+echo "configure:4227: checking whether malloc must be declared" >&5
+if eval "test \"`echo '$''{'bfd_cv_decl_needed_malloc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4232 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+int main() {
+char *(*pfn) = (char *(*)) malloc
+; return 0; }
+EOF
+if { (eval echo configure:4253: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_decl_needed_malloc=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_decl_needed_malloc=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bfd_cv_decl_needed_malloc" 1>&6
+if test $bfd_cv_decl_needed_malloc = yes; then
+ cat >> confdefs.h <<\EOF
+#define NEED_DECLARATION_MALLOC 1
+EOF
+
+fi
+
+echo $ac_n "checking whether realloc must be declared""... $ac_c" 1>&6
+echo "configure:4274: checking whether realloc must be declared" >&5
+if eval "test \"`echo '$''{'bfd_cv_decl_needed_realloc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4279 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+int main() {
+char *(*pfn) = (char *(*)) realloc
+; return 0; }
+EOF
+if { (eval echo configure:4300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_decl_needed_realloc=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_decl_needed_realloc=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bfd_cv_decl_needed_realloc" 1>&6
+if test $bfd_cv_decl_needed_realloc = yes; then
+ cat >> confdefs.h <<\EOF
+#define NEED_DECLARATION_REALLOC 1
+EOF
+
+fi
+
+echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6
+echo "configure:4321: checking whether free must be declared" >&5
+if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4326 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+int main() {
+char *(*pfn) = (char *(*)) free
+; return 0; }
+EOF
+if { (eval echo configure:4347: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_decl_needed_free=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_decl_needed_free=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bfd_cv_decl_needed_free" 1>&6
+if test $bfd_cv_decl_needed_free = yes; then
+ cat >> confdefs.h <<\EOF
+#define NEED_DECLARATION_FREE 1
+EOF
+
+fi
+
+echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6
+echo "configure:4368: checking whether getenv must be declared" >&5
+if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4373 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+int main() {
+char *(*pfn) = (char *(*)) getenv
+; return 0; }
+EOF
+if { (eval echo configure:4394: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_decl_needed_getenv=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_decl_needed_getenv=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bfd_cv_decl_needed_getenv" 1>&6
+if test $bfd_cv_decl_needed_getenv = yes; then
+ cat >> confdefs.h <<\EOF
+#define NEED_DECLARATION_GETENV 1
+EOF
+
+fi
+
+
+# If we are configured native, pick a core file support file.
+COREFILE=
+COREFLAG=
+TRAD_HEADER=
+if test "${target}" = "${host}"; then
+ case "${host}" in
+ alpha*-*-linux-gnu*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+ alpha*-*-netbsd*) COREFILE=netbsd-core.lo ;;
+ alpha*-*-*) COREFILE=osf-core.lo ;;
+ arm-*-riscix) COREFILE=trad-core.lo ;;
+ hppa*-*-hpux*) COREFILE=hpux-core.lo ;;
+ hppa*-*-hiux*) COREFILE=hpux-core.lo ;;
+ hppa*-*-mpeix*) COREFILE=hpux-core.lo ;;
+ hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo"
+ COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
+ i[3456]86-sequent-bsd*)
+ COREFILE=trad-core.lo;
+ TRAD_HEADER='"hosts/symmetry.h"'
+ ;;
+ i[3456]86-sequent-sysv4*) ;;
+ i[3456]86-sequent-sysv*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/symmetry.h"'
+ ;;
+ i[3456]86-*-bsd* | i[3456]86-*-freebsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386bsd.h"'
+ ;;
+ i[3456]86-*-netbsd* | i[3456]86-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ i[3456]86-esix-sysv3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/esix.h"'
+ ;;
+ i[3456]86-*-sco3.2v5*)
+ COREFILE=sco5-core.lo
+ ;;
+ i[3456]86-*-sco* | i[3456]86-*-isc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386sco.h"'
+ ;;
+ i[3456]86-*-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ i[3456]86-*-linux-gnu*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+ i[3456]86-*-isc*) COREFILE=trad-core.lo ;;
+ i[3456]86-*-aix*) COREFILE=aix386-core.lo ;;
+ i860-*-mach3* | i860-*-osf1*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i860mach3.h"'
+ ;;
+ mips-dec-bsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/mipsbsd.h"'
+ ;;
+ mips-dec-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/mipsmach3.h"'
+ ;;
+ mips-*-netbsd* | mips*-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ mips-dec-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/decstation.h"'
+ ;;
+ mips-sgi-irix4*) COREFILE=irix-core.lo ;;
+ mips-sgi-irix5*) COREFILE=irix-core.lo ;;
+ mips-sgi-irix6*) COREFILE=irix-core.lo ;;
+ mips-*-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/mipsmach3.h"'
+ ;;
+ mips-*-sysv4*) ;;
+ mips-*-sysv* | mips-*-riscos*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/riscos.h"'
+ ;;
+ mips-sony-bsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/news-mips.h"'
+ ;;
+ m68*-bull*-sysv*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/dpx2.h"'
+ ;;
+ m68*-hp-hpux*) COREFILE=hpux-core.lo ;;
+ m68*-hp-bsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+ m68*-*-linux-gnu*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+ m68*-motorola-sysv*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/delta68.h"'
+ ;;
+ m68*-sony-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/news.h"'
+ ;;
+ m68*-*-netbsd* | m68*-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ m68*-apple-aux*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68kaux.h"'
+ ;;
+ m88*-*-sysv4*) ;;
+ m88*-motorola-sysv*) COREFILE=ptrace-core.lo ;;
+ m88*-*-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m88kmach3.h"'
+ ;;
+ ns32k-pc532-mach)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/pc532mach.h"'
+ ;;
+ ns32k-*-netbsd* | ns32k-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ rs6000-*-lynx*) COREFILE=lynx-core.lo ;;
+ rs6000-*-aix4*) COREFILE=rs6000-core.lo ;;
+ rs6000-*-*) COREFILE=rs6000-core.lo ;;
+ powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;;
+ powerpc-*-aix4*) COREFILE=rs6000-core.lo ;;
+ powerpc-*-aix*) COREFILE=rs6000-core.lo ;;
+ powerpc-*-beos*) ;;
+ powerpc-*-netbsd*) COREFILE=netbsd-core.lo ;;
+ sparc-*-netbsd* | sparc-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ tahoe-*-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/tahoe.h"'
+ ;;
+ vax-*-ultrix2*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+ vax-*-ultrix*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+ vax-*-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxbsd.h"'
+ ;;
+ esac
+
+ case "$COREFILE" in
+ aix386-core.lo) COREFLAG=-DAIX386_CORE ;;
+ hppabsd-core.lo) COREFLAG=-DHPPABSD_CORE ;;
+ hpux-core.lo) COREFLAG=-DHPUX_CORE ;;
+ irix-core.lo) COREFLAG=-DIRIX_CORE ;;
+ lynx-core.lo) COREFLAG=-DLYNX_CORE ;;
+ netbsd-core.lo) COREFLAG=-DNETBSD_CORE ;;
+ osf-core.lo) COREFLAG=-DOSF_CORE ;;
+ ptrace-core.lo) COREFLAG=-DPTRACE_CORE ;;
+ rs6000-core.lo) COREFLAG="$COREFLAG -DAIX_CORE" ;;
+ sco5-core.lo) COREFLAG="$COREFLAG -DSCO5_CORE" ;;
+ trad-core.lo) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
+ esac
+
+ # ELF corefile support has several flavors, but all of
+ # them use something called <sys/procfs.h>
+ for ac_hdr in sys/procfs.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:4595: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4600 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:4605: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ if test "$ac_cv_header_sys_procfs_h" = yes; then
+ echo $ac_n "checking for prstatus_t in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4633: checking for prstatus_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prstatus_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4638 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+prstatus_t avar
+; return 0; }
+EOF
+if { (eval echo configure:4645: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_prstatus_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_prstatus_t=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_prstatus_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PRSTATUS_T 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_prstatus_t" 1>&6
+
+ echo $ac_n "checking for prstatus_t.pr_who in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4667: checking for prstatus_t.pr_who in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4672 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+prstatus_t avar; void* aref = (void*) &avar.pr_who
+; return 0; }
+EOF
+if { (eval echo configure:4679: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PRSTATUS_T_PR_WHO 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who" 1>&6
+
+ echo $ac_n "checking for pstatus_t in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4701: checking for pstatus_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pstatus_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4706 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+pstatus_t avar
+; return 0; }
+EOF
+if { (eval echo configure:4713: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_pstatus_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_pstatus_t=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_pstatus_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PSTATUS_T 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_pstatus_t" 1>&6
+
+ echo $ac_n "checking for prpsinfo_t in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4735: checking for prpsinfo_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prpsinfo_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4740 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+prpsinfo_t avar
+; return 0; }
+EOF
+if { (eval echo configure:4747: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_prpsinfo_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_prpsinfo_t=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_prpsinfo_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PRPSINFO_T 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_prpsinfo_t" 1>&6
+
+ echo $ac_n "checking for psinfo_t in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4769: checking for psinfo_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psinfo_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4774 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+psinfo_t avar
+; return 0; }
+EOF
+if { (eval echo configure:4781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_psinfo_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_psinfo_t=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_psinfo_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PSINFO_T 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_psinfo_t" 1>&6
+
+ echo $ac_n "checking for lwpstatus_t in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4803: checking for lwpstatus_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpstatus_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4808 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+lwpstatus_t avar
+; return 0; }
+EOF
+if { (eval echo configure:4815: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_lwpstatus_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_lwpstatus_t=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_lwpstatus_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LWPSTATUS_T 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpstatus_t" 1>&6
+
+ echo $ac_n "checking for lwpstatus_t.pr_context in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4837: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4842 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+lwpstatus_t avar; void* aref = (void*) &avar.pr_context
+; return 0; }
+EOF
+if { (eval echo configure:4849: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LWPSTATUS_T_PR_CONTEXT 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context" 1>&6
+
+ echo $ac_n "checking for lwpstatus_t.pr_reg in sys/procfs.h""... $ac_c" 1>&6
+echo "configure:4871: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4876 "configure"
+#include "confdefs.h"
+#include <sys/procfs.h>
+int main() {
+lwpstatus_t avar; void* aref = (void*) &avar.pr_reg
+; return 0; }
+EOF
+if { (eval echo configure:4883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg=no
+
+fi
+rm -f conftest*
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LWPSTATUS_T_PR_REG 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg" 1>&6
+
+ fi
+fi
+
+
+cat >> confdefs.h <<EOF
+#define TRAD_HEADER $TRAD_HEADER
+EOF
+
+
+# Horrible hacks to build DLLs on Windows.
+WIN32LDFLAGS=
+WIN32LIBADD=
+case "${host}" in
+*-*-cygwin*)
+ if test "$enable_shared" = "yes"; then
+ WIN32LDFLAGS="-no-undefined"
+ WIN32LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
+ fi
+ ;;
+esac
+
+
+
+# target stuff:
+
+# Canonicalize the secondary target names.
+if test -n "$enable_targets" ; then
+ for targ in `echo $enable_targets | sed 's/,/ /g'`
+ do
+ result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null`
+ if test -n "$result" ; then
+ canon_targets="$canon_targets $result"
+ else
+ # Allow targets that config.sub doesn't recognize, like "all".
+ canon_targets="$canon_targets $targ"
+ fi
+ done
+fi
+
+all_targets=false
+defvec=
+selvecs=
+selarchs=
+TDEFINES=
+for targ in $target $canon_targets
+do
+ if test "x$targ" = "xall"; then
+ all_targets=true
+ else
+ . $srcdir/config.bfd
+ if test "x$targ" = "x$target"; then
+ defvec=$targ_defvec
+ fi
+ selvecs="$selvecs $targ_defvec $targ_selvecs"
+ selarchs="$selarchs $targ_archs"
+ TDEFINES="$TDEFINES $targ_cflags"
+ fi
+done
+
+
+# This processing still needs to be done if we're to decide properly whether
+# 64-bit support needs to be compiled in. Currently, it will be included if
+# the default or any other explicitly requested target requires it; it
+# will not be included on a 32-bit host if no 64-bit target is requested, and
+# no "--with-64-bit-bfd" option is given, even if "--with-targets=all" is
+# used.
+
+# uniq the default and selected vectors in all the configured targets.
+f=""
+for i in $selvecs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+selvecs="$f"
+
+
+# uniq the architectures in all the configured targets.
+f=""
+for i in $selarchs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+selarchs="$f"
+
+# Target backend .o files.
+tb=
+
+elf="elf.lo elflink.lo dwarf2.lo dwarf1.lo"
+
+for vec in $selvecs
+do
+ case "$vec" in
+ # This list is alphabetized to make it easy to compare
+ # with the two vector lists in targets.c.
+ a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;;
+ a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;;
+ armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armpe_little_vec) tb="$tb pe-arm.lo coff-arm.lo cofflink.lo " ;;
+ armpe_big_vec) tb="$tb pe-arm.lo coff-arm.lo cofflink.lo " ;;
+ armpei_little_vec) tb="$tb pei-arm.lo cofflink.lo " ;;
+ armpei_big_vec) tb="$tb pei-arm.lo cofflink.lo " ;;
+ arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo cofflink.lo " ;;
+ arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo cofflink.lo " ;;
+ arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo cofflink.lo " ;;
+ arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo cofflink.lo " ;;
+ aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;;
+ aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;;
+ aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;;
+ aout_mips_big_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
+ aout_mips_little_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
+ apollocoff_vec) tb="$tb coff-apollo.lo" ;;
+ b_out_vec_big_host) tb="$tb bout.lo aout32.lo" ;;
+ b_out_vec_little_host) tb="$tb bout.lo aout32.lo" ;;
+ bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"
+ target64=true ;;
+ bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
+ target64=true ;;
+ bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
+ bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
+ bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
+ bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
+ bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
+ bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
+ target64=true ;;
+ bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
+ bfd_elf32_m68k_vec) tb="$tb elf32-m68k.lo elf32.lo $elf" ;;
+ bfd_elf32_m88k_vec) tb="$tb elf32-m88k.lo elf32.lo $elf" ;;
+ bfd_elf32_mcore_big_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
+ bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;;
+ bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
+ bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
+ bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
+ bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;;
+ bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
+ target64=true ;;
+ bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
+ target64=true ;;
+ bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"
+ target64=true ;;
+ cisco_core_vec) tb="$tb cisco-core.lo" ;;
+ demo_64_vec) tb="$tb demo64.lo aout64.lo"
+ target64=true ;;
+ ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoff_biglittle_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"
+ target64=true ;;
+ go32coff_vec) tb="$tb coff-go32.lo cofflink.lo" ;;
+ go32stubbedcoff_vec) tb="$tb coff-stgo32.lo cofflink.lo" ;;
+ h8300coff_vec) tb="$tb coff-h8300.lo reloc16.lo" ;;
+ h8500coff_vec) tb="$tb coff-h8500.lo reloc16.lo" ;;
+ host_aout_vec) tb="$tb host-aout.lo aout32.lo" ;;
+ hp300bsd_vec) tb="$tb hp300bsd.lo aout32.lo" ;;
+ hp300hpux_vec) tb="$tb hp300hpux.lo aout32.lo" ;;
+ i386aout_vec) tb="$tb i386aout.lo aout32.lo" ;;
+ i386bsd_vec) tb="$tb i386bsd.lo aout32.lo" ;;
+ i386coff_vec) tb="$tb coff-i386.lo cofflink.lo" ;;
+ i386dynix_vec) tb="$tb i386dynix.lo aout32.lo" ;;
+ i386freebsd_vec) tb="$tb i386freebsd.lo aout32.lo" ;;
+ i386msdos_vec) tb="$tb i386msdos.lo" ;;
+ i386pe_vec) tb="$tb pe-i386.lo cofflink.lo " ;;
+ i386pei_vec) tb="$tb pei-i386.lo cofflink.lo" ;;
+ i386linux_vec) tb="$tb i386linux.lo aout32.lo" ;;
+ i386lynx_aout_vec) tb="$tb i386lynx.lo lynx-core.lo aout32.lo" ;;
+ i386lynx_coff_vec) tb="$tb cf-i386lynx.lo cofflink.lo lynx-core.lo" ;;
+ i386mach3_vec) tb="$tb i386mach3.lo aout32.lo" ;;
+ i386netbsd_vec) tb="$tb i386netbsd.lo aout32.lo" ;;
+ i386os9k_vec) tb="$tb i386os9k.lo aout32.lo" ;;
+ i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;;
+ icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
+ icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
+ ieee_vec) tb="$tb ieee.lo" ;;
+ m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
+ m68kcoffun_vec) tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
+ m68klinux_vec) tb="$tb m68klinux.lo aout32.lo" ;;
+ m68klynx_aout_vec) tb="$tb m68klynx.lo lynx-core.lo aout32.lo" ;;
+ m68klynx_coff_vec) tb="$tb cf-m68klynx.lo coff-m68k.lo cofflink.lo lynx-core.lo" ;;
+ m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;;
+ m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
+ m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
+ m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;;
+ m88kbcs_vec) tb="$tb coff-m88k.lo" ;;
+ mcore_pe_big_vec) tb="$tb pe-mcore.lo cofflink.lo" ;;
+ mcore_pe_little_vec) tb="$tb pe-mcore.lo cofflink.lo" ;;
+ mcore_pei_big_vec) tb="$tb pei-mcore.lo cofflink.lo" ;;
+ mcore_pei_little_vec) tb="$tb pei-mcore.lo cofflink.lo" ;;
+ newsos3_vec) tb="$tb newsos3.lo aout32.lo" ;;
+ nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
+ nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
+ nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"
+ target64=true ;;
+ riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
+ nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
+ pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
+ pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;;
+ pmac_xcoff_vec) tb="$tb coff-pmac.lo xcofflink.lo" ;;
+ rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
+ bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo cofflink.lo" ;;
+ bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo cofflink.lo" ;;
+ bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo cofflink.lo" ;;
+ bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo cofflink.lo" ;;
+ ppcboot_vec) tb="$tb ppcboot.lo" ;;
+ shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shlcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ som_vec) tb="$tb som.lo" ;;
+ sparcle_aout_vec) tb="$tb aout-sparcle.lo aout32.lo" ;;
+ sparclinux_vec) tb="$tb sparclinux.lo aout32.lo" ;;
+ sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;;
+ sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;;
+ sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;;
+ sparccoff_vec) tb="$tb coff-sparc.lo" ;;
+ srec_vec) tb="$tb srec.lo" ;;
+ sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;;
+ symbolsrec_vec) tb="$tb srec.lo" ;;
+ tekhex_vec) tb="$tb tekhex.lo" ;;
+ tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
+ tic30_coff_vec) tb="$tb coff-tic30.lo" ;;
+ tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;;
+ versados_vec) tb="$tb versados.lo" ;;
+ vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"
+ target64=true ;;
+ vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
+ w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
+ we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
+ z8kcoff_vec) tb="$tb coff-z8k.lo reloc16.lo" ;;
+
+ "") ;;
+ *) { echo "configure: error: *** unknown target vector $vec" 1>&2; exit 1; } ;;
+ esac
+done
+
+# Target architecture .o files.
+# A couple of CPUs use shorter file names to avoid problems on DOS
+# filesystems.
+ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.lo/g -e s/mn10200/m10200/ -e s/mn10300/m10300/`
+
+# Weed out duplicate .o files.
+f=""
+for i in $tb ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+tb="$f"
+
+f=""
+for i in $ta ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+ta="$f"
+
+bfd_backends="$tb"
+bfd_machines="$ta"
+
+if test x${all_targets} = xtrue ; then
+ bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
+ bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
+ selvecs=
+ havevecs=
+ selarchs=
+else # all_targets is true
+ # Only set these if they will be nonempty, for the clever echo.
+ havevecs=
+ test -n "$selvecs" &&
+ havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
+ test -n "$selvecs" &&
+ selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+ test -n "$selarchs" &&
+ selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+fi # all_targets is true
+
+case ${host64}-${target64}-${want64} in
+ *true*)
+ wordsize=64
+ all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
+ if test -z "$GCC" && test "$BFD_HOST_64BIT_LONG" = "0" && test "$BFD_HOST_64_BIT_DEFINED" = "0"; then
+ echo "configure: warning: You have requested a 64 bit BFD configuration, but" 1>&2
+ echo "configure: warning: your compiler may not have a 64 bit integral type" 1>&2
+ fi
+ ;;
+ false-false-false)
+ wordsize=32
+ all_backends='$(BFD32_BACKENDS)'
+ ;;
+esac
+
+
+
+
+
+
+tdefaults=""
+test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
+test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
+test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
+test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
+
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:5239: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5244 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:5249: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_func in getpagesize
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:5278: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5283 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:5306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for working mmap""... $ac_c" 1>&6
+echo "configure:5331: checking for working mmap" >&5
+if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5339 "configure"
+#include "confdefs.h"
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the filesystem buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propogated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+#ifdef __cplusplus
+extern "C" { void *malloc(unsigned); }
+#else
+char *malloc();
+#endif
+
+int
+main()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmap", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file at a fixed address which
+ * already has something else allocated at it. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmap", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ data2 = malloc(2 * pagesize);
+ if (!data2)
+ exit(1);
+ data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ /*
+ * Finally, make sure that changes to the mapped area
+ * do not percolate back to the file as seen by read().
+ * (This is a bug on some variants of i386 svr4.0.)
+ */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit(1);
+ close(fd);
+ unlink("conftestmmap");
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:5479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_MMAP 1
+EOF
+
+fi
+
+for ac_func in madvise mprotect
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:5504: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5509 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:5532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in
+ true+yes ) cat >> confdefs.h <<\EOF
+#define USE_MMAP 1
+EOF
+ ;;
+esac
+
+rm -f doc/config.status
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile doc/Makefile bfd-in3.h:bfd-in2.h po/Makefile.in:po/Make-in config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@CC@%$CC%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@PACKAGE@%$PACKAGE%g
+s%@VERSION@%$VERSION%g
+s%@ACLOCAL@%$ACLOCAL%g
+s%@AUTOCONF@%$AUTOCONF%g
+s%@AUTOMAKE@%$AUTOMAKE%g
+s%@AUTOHEADER@%$AUTOHEADER%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@AR@%$AR%g
+s%@RANLIB@%$RANLIB%g
+s%@LD@%$LD%g
+s%@NM@%$NM%g
+s%@LN_S@%$LN_S%g
+s%@LIBTOOL@%$LIBTOOL%g
+s%@DLLTOOL@%$DLLTOOL%g
+s%@AS@%$AS%g
+s%@MAINTAINER_MODE_TRUE@%$MAINTAINER_MODE_TRUE%g
+s%@MAINTAINER_MODE_FALSE@%$MAINTAINER_MODE_FALSE%g
+s%@MAINT@%$MAINT%g
+s%@EXEEXT@%$EXEEXT%g
+s%@CPP@%$CPP%g
+s%@ALLOCA@%$ALLOCA%g
+s%@USE_NLS@%$USE_NLS%g
+s%@MSGFMT@%$MSGFMT%g
+s%@GMSGFMT@%$GMSGFMT%g
+s%@XGETTEXT@%$XGETTEXT%g
+s%@USE_INCLUDED_LIBINTL@%$USE_INCLUDED_LIBINTL%g
+s%@CATALOGS@%$CATALOGS%g
+s%@CATOBJEXT@%$CATOBJEXT%g
+s%@DATADIRNAME@%$DATADIRNAME%g
+s%@GMOFILES@%$GMOFILES%g
+s%@INSTOBJEXT@%$INSTOBJEXT%g
+s%@INTLDEPS@%$INTLDEPS%g
+s%@INTLLIBS@%$INTLLIBS%g
+s%@INTLOBJS@%$INTLOBJS%g
+s%@POFILES@%$POFILES%g
+s%@POSUB@%$POSUB%g
+s%@INCLUDE_LOCALE_H@%$INCLUDE_LOCALE_H%g
+s%@GT_NO@%$GT_NO%g
+s%@GT_YES@%$GT_YES%g
+s%@MKINSTALLDIRS@%$MKINSTALLDIRS%g
+s%@l@%$l%g
+s%@HDEFINES@%$HDEFINES%g
+s%@BFD_HOST_64BIT_LONG@%$BFD_HOST_64BIT_LONG%g
+s%@BFD_HOST_64_BIT_DEFINED@%$BFD_HOST_64_BIT_DEFINED%g
+s%@BFD_HOST_64_BIT@%$BFD_HOST_64_BIT%g
+s%@BFD_HOST_U_64_BIT@%$BFD_HOST_U_64_BIT%g
+s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g
+s%@EXEEXT_FOR_BUILD@%$EXEEXT_FOR_BUILD%g
+s%@COREFILE@%$COREFILE%g
+s%@COREFLAG@%$COREFLAG%g
+s%@WIN32LDFLAGS@%$WIN32LDFLAGS%g
+s%@WIN32LIBADD@%$WIN32LIBADD%g
+s%@TDEFINES@%$TDEFINES%g
+s%@wordsize@%$wordsize%g
+s%@all_backends@%$all_backends%g
+s%@bfd_backends@%$bfd_backends%g
+s%@bfd_machines@%$bfd_machines%g
+s%@tdefaults@%$tdefaults%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile doc/Makefile bfd-in3.h:bfd-in2.h po/Makefile.in:po/Make-in"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h:config.in"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+sed -e '/POTFILES =/r po/POTFILES' po/Makefile.in > po/Makefile
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/bfd/configure.bat b/bfd/configure.bat
new file mode 100644
index 00000000000..78fe79e9112
--- /dev/null
+++ b/bfd/configure.bat
@@ -0,0 +1,18 @@
+@echo off
+if "%1" == "h8/300" goto h8300
+
+echo Configuring bfd for go32
+update hosts\go32.h sysdep.h
+update Makefile.dos Makefile
+echo s/@WORDSIZE@/32/g>config.sed
+sed -e s/^/s\/@VERSION@\// -e s/$/\/g/g version >>config.sed
+sed -f config.sed < bfd-in2.h > bfd.h2
+update bfd.h2 bfd.h
+goto exit
+
+:h8300
+echo Configuring bfd for H8/300
+update hosts\h-go32.h sysdep.h
+update Makefile.dos Makefile
+
+:exit
diff --git a/bfd/configure.com b/bfd/configure.com
new file mode 100644
index 00000000000..929977ce8f1
--- /dev/null
+++ b/bfd/configure.com
@@ -0,0 +1,215 @@
+$!
+$! This file configures the bfd library for use with openVMS (Alpha and Vax)
+$!
+$! We do not use the configure script, since we do not have /bin/sh
+$! to execute it.
+$!
+$! Written by Klaus K"ampf (kkaempf@rmi.de)
+$!
+$arch_indx = 1 + ((f$getsyi("CPU").ge.128).and.1) ! vax==1, alpha==2
+$arch = f$element(arch_indx,"|","|VAX|Alpha|")
+$!
+$if arch .eqs. "Alpha"
+$then
+$ write sys$output "Configuring for Alpha target"
+$ target = "alpha"
+$!
+$! copy bfd-in2.h to bfd.h, replacing @ macros
+$!
+$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
+ []bfd-in2.h /output=[]bfd.h
+$DECK
+!
+! Copy file, changing lines with macros (@@)
+!
+!
+ vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
+ rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
+ match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ vers := CURRENT_LINE-")";
+ ELSE;
+ vers := "unknown";
+ ENDIF;
+
+ file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
+ rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
+
+ match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT(vers);
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('64');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('0');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('__DECC');
+ SPLIT_LINE;
+ COPY_TEXT('#include <ints.h>');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('int64');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('uint64');
+ ENDIF;
+ WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
+ QUIT
+$ EOD
+$
+$else
+$
+$ write sys$output "Configuring for Vax target"
+$ target = "vax"
+$!
+$! copy bfd-in2.h to bfd.h, replacing @ macros
+$!
+$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
+ []bfd-in2.h /output=[]bfd.h
+$DECK
+!
+! Copy file, changing lines with macros (@@)
+!
+!
+ vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
+ rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
+ match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ vers := CURRENT_LINE-")";
+ ELSE;
+ vers := "unknown";
+ ENDIF;
+
+ file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
+ rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
+
+ match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT(vers);
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('32');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('0');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('__DECC');
+ SPLIT_LINE;
+ COPY_TEXT('#include <ints.h>');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('int64');
+ ENDIF;
+ match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
+ IF match_pos <> 0 THEN;
+ POSITION(BEGINNING_OF(match_pos));
+ ERASE(match_pos);
+ COPY_TEXT('uint64');
+ ENDIF;
+ WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
+ QUIT
+$ EOD
+$endif
+$
+$ write sys$output "Generated `bfd.h' from `bfd-in2.h'."
+$!
+$!
+$! create targmatch.h
+$!
+$ open/write tfile []targmatch.h
+$ write tfile "{ """ + target + "-*-*vms*""" + ","
+$ write tfile "#if defined (SELECT_VECS)"
+$ write tfile "SELECT_VECS"
+$ write tfile "#else"
+$ write tfile "UNSUPPORTED_TARGET"
+$ write tfile "#endif"
+$ write tfile "},"
+$ close tfile
+$ write sys$output "Generated `targmatch.h'"
+$!
+$!
+$! create config.h
+$!
+$ create []config.h
+/* config.h-vms. Generated by hand by Klaus Kämpf, kkaempf@didymus.rmi.de. */
+/* config.in. Generated automatically from configure.in by autoheader. */
+/* Whether malloc must be declared even if <stdlib.h> is included. */
+/* #undef NEED_DECLARATION_MALLOC */
+/* Whether free must be declared even if <stdlib.h> is included. */
+/* #undef NEED_DECLARATION_FREE */
+/* Define if you have a working `mmap' system call. */
+/* #define HAVE_MMAP 1 */
+/* Do we need to use the b modifier when opening binary files? */
+/* #undef USE_BINARY_FOPEN */
+/* Name of host specific header file to include in trad-core.c. */
+/* #undef TRAD_HEADER */
+/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
+/* #undef HAVE_SYS_PROCFS_H */
+/* Do we really want to use mmap if it's available? */
+/* #undef USE_MMAP */
+/* Define if you have the fcntl function. */
+#define HAVE_FCNTL 1
+/* Define if you have the getpagesize function. */
+#define HAVE_GETPAGESIZE 1
+/* Define if you have the madvise function. */
+#define HAVE_MADVISE 1
+/* Define if you have the mprotect function. */
+#define HAVE_MPROTECT 1
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+/* Define if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+/* Define if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+/* Define if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+/* Define if you have the <sys/file.h> header file. */
+#define HAVE_SYS_FILE_H 1
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+$!
+$ write sys$output "Generated `config.h'"
+
diff --git a/bfd/configure.host b/bfd/configure.host
new file mode 100644
index 00000000000..ef7048be13c
--- /dev/null
+++ b/bfd/configure.host
@@ -0,0 +1,70 @@
+# This file is a shell script that overrides some of the tools and
+# flags used on a host specific basis.
+
+# Since the "bfd/hosts" directory is shared by the bfd, opcodes, and
+# binutils directories (at least), the index to it is also shared.
+# This is that index. Each configure.in file should source this file
+# in its per-host part.
+
+# This sets the following shell variables:
+# HDEFINES host specific compiler options
+# host64 set to true if 64 bit types are as fast as 32 bit
+# HOST_64BIT_TYPE host 64 bit type
+# HOST_U_64BIT_TYPE unsigned 64 bit type (not needed if 64BIT_TYPE is long)
+
+HDEFINES=
+host64=false
+HOST_64BIT_TYPE=
+HOST_U_64BIT_TYPE=
+
+case "${host}" in
+
+alpha*-*-*) host64=true; HOST_64BIT_TYPE=long ;;
+
+hppa*-*-hpux*) HDEFINES=-DHOST_HPPAHPUX ;;
+hppa*-*-hiux*) HDEFINES=-DHOST_HPPAHPUX ;;
+hppa*-*-mpeix*) HDEFINES=-DHOST_HPPAMPEIX ;;
+hppa*-*-bsd*) HDEFINES=-DHOST_HPPABSD ;;
+hppa*-*-osf*) HDEFINES=-DHOST_HPPAOSF ;;
+
+i[3456]86-sequent-bsd*) HDEFINES=-Dshared=genshared ;;
+i[3456]86-sequent-sysv4*) ;;
+i[3456]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;;
+
+mips*-dec-netbsd*) ;;
+mips*-*-openbsd*) ;;
+mips*-dec-*) HDEFINES="-G 4" ;;
+mips*-sgi-irix3*) HDEFINES="-G 4" ;;
+mips*-sgi-irix4*) HDEFINES="-G 4" ;;
+mips*-sgi-irix6*) host64=true
+ HOST_64BIT_TYPE="long long";
+ HOST_U_64BIT_TYPE="unsigned long long";
+ ;;
+mips*-*-sysv4*) ;;
+mips*-*-sysv*) HDEFINES="-G 4" ;;
+mips*-*-riscos*) HDEFINES="-G 4" ;;
+
+m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;;
+
+*-*-solaris*) HOST_64BIT_TYPE="long long"
+ HOST_U_64BIT_TYPE="unsigned long long"
+ ;;
+
+*-*-windows*)
+ HOST_64BIT_TYPE=__int64
+ HOST_U_64BIT_TYPE="unsigned __int64"
+# The following krock is necessary because we can't run the build compiler
+# (MSVC) on the configure host, so we have to explicitly set the values here.
+# Note that this file is never run through autoconf, so we can't use any
+# autoconf macros here. Because of this, we have to muck with autoconf
+# variables explicitly.
+ ac_cv_func_mmap_fixed_mapped=no
+ ac_cv_header_time=no
+ ac_cv_func_getpagesize=no
+ ac_cv_func_madvise=no
+ ac_cv_func_mprotect=no
+ ac_cv_header_sys_file_h=no
+ ac_cv_header_sys_time_h=no
+ ac_cv_header_unistd_h=no
+ ;;
+esac
diff --git a/bfd/configure.in b/bfd/configure.in
new file mode 100644
index 00000000000..3a3e36f1b66
--- /dev/null
+++ b/bfd/configure.in
@@ -0,0 +1,648 @@
+dnl Process this file with autoconf to produce a configure script.
+dnl
+
+AC_PREREQ(2.13)
+AC_INIT(libbfd.c)
+
+AC_CANONICAL_SYSTEM
+AC_ISC_POSIX
+
+AM_INIT_AUTOMAKE(bfd, 2.9.4)
+
+dnl These must be called before AM_PROG_LIBTOOL, because it may want
+dnl to call AC_CHECK_PROG.
+AC_CHECK_TOOL(AR, ar)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+
+dnl Default to a non shared library. This may be overridden by the
+dnl configure option --enable-shared.
+AM_DISABLE_SHARED
+
+AM_PROG_LIBTOOL
+
+AC_ARG_ENABLE(64-bit-bfd,
+[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
+[case "${enableval}" in
+ yes) want64=true ;;
+ no) want64=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
+esac],[want64=false])dnl
+AC_ARG_ENABLE(targets,
+[ --enable-targets alternative target configurations],
+[case "${enableval}" in
+ yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
+ ;;
+ no) enable_targets= ;;
+ *) enable_targets=$enableval ;;
+esac])dnl
+AC_ARG_ENABLE(commonbfdlib,
+[ --enable-commonbfdlib build shared BFD/opcodes/libiberty library],
+[case "${enableval}" in
+ yes) commonbfdlib=true ;;
+ no) commonbfdlib=false ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
+esac])dnl
+AC_ARG_WITH(mmap,
+[ --with-mmap try using mmap for BFD input files if available],
+[case "${withval}" in
+ yes) want_mmap=true ;;
+ no) want_mmap=false ;;
+ *) AC_MSG_ERROR(bad value ${withval} for BFD with-mmap option) ;;
+esac],[want_mmap=false])dnl
+
+AM_CONFIG_HEADER(config.h:config.in)
+
+if test -z "$target" ; then
+ AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
+fi
+AC_ARG_PROGRAM
+
+AM_MAINTAINER_MODE
+AC_EXEEXT
+
+host64=false
+target64=false
+
+# host stuff:
+
+AC_PROG_CC
+
+ALL_LINGUAS=
+CY_GNU_GETTEXT
+
+# Permit host specific settings.
+. ${srcdir}/configure.host
+
+AC_SUBST(HDEFINES)
+AC_PROG_INSTALL
+
+BFD_HOST_64BIT_LONG=0
+BFD_HOST_64_BIT_DEFINED=0
+BFD_HOST_64_BIT=
+BFD_HOST_U_64_BIT=
+if test "x${HOST_64BIT_TYPE}" = "xlong"; then
+ BFD_HOST_64BIT_LONG=1
+elif test "x${HOST_64BIT_TYPE}" != "x"; then
+ BFD_HOST_64_BIT_DEFINED=1
+ BFD_HOST_64_BIT=${HOST_64BIT_TYPE}
+ BFD_HOST_U_64_BIT=${HOST_U_64BIT_TYPE}
+fi
+AC_SUBST(BFD_HOST_64BIT_LONG)
+AC_SUBST(BFD_HOST_64_BIT_DEFINED)
+AC_SUBST(BFD_HOST_64_BIT)
+AC_SUBST(BFD_HOST_U_64_BIT)
+
+BFD_CC_FOR_BUILD
+
+AC_CHECK_HEADERS(stddef.h string.h strings.h stdlib.h time.h unistd.h)
+AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h)
+AC_HEADER_TIME
+AC_HEADER_DIRENT
+AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen)
+
+BFD_BINARY_FOPEN
+
+BFD_NEED_DECLARATION(strstr)
+BFD_NEED_DECLARATION(malloc)
+BFD_NEED_DECLARATION(realloc)
+BFD_NEED_DECLARATION(free)
+BFD_NEED_DECLARATION(getenv)
+
+# If we are configured native, pick a core file support file.
+COREFILE=
+COREFLAG=
+TRAD_HEADER=
+if test "${target}" = "${host}"; then
+ case "${host}" in
+ alpha*-*-linux-gnu*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+ alpha*-*-netbsd*) COREFILE=netbsd-core.lo ;;
+ alpha*-*-*) COREFILE=osf-core.lo ;;
+ arm-*-riscix) COREFILE=trad-core.lo ;;
+ hppa*-*-hpux*) COREFILE=hpux-core.lo ;;
+ hppa*-*-hiux*) COREFILE=hpux-core.lo ;;
+ hppa*-*-mpeix*) COREFILE=hpux-core.lo ;;
+ hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo"
+ COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
+changequote(,)dnl
+ i[3456]86-sequent-bsd*)
+changequote([,])dnl
+ COREFILE=trad-core.lo;
+ TRAD_HEADER='"hosts/symmetry.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-sequent-sysv4*) ;;
+ i[3456]86-sequent-sysv*)
+changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/symmetry.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-*-bsd* | i[3456]86-*-freebsd*)
+changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386bsd.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-*-netbsd* | i[3456]86-*-openbsd*)
+changequote([,])dnl
+ COREFILE=netbsd-core.lo
+ ;;
+changequote(,)dnl
+ i[3456]86-esix-sysv3*)
+changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/esix.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-*-sco3.2v5*)
+changequote([,])dnl
+ COREFILE=sco5-core.lo
+ ;;
+changequote(,)dnl
+ i[3456]86-*-sco* | i[3456]86-*-isc*)
+changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386sco.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-*-mach3*)
+changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-*-linux-gnu*)
+changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+changequote(,)dnl
+ i[3456]86-*-isc*) COREFILE=trad-core.lo ;;
+ i[3456]86-*-aix*) COREFILE=aix386-core.lo ;;
+changequote([,])dnl
+ i860-*-mach3* | i860-*-osf1*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i860mach3.h"'
+ ;;
+ mips-dec-bsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/mipsbsd.h"'
+ ;;
+ mips-dec-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/mipsmach3.h"'
+ ;;
+ mips-*-netbsd* | mips*-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ mips-dec-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/decstation.h"'
+ ;;
+ mips-sgi-irix4*) COREFILE=irix-core.lo ;;
+ mips-sgi-irix5*) COREFILE=irix-core.lo ;;
+ mips-sgi-irix6*) COREFILE=irix-core.lo ;;
+ mips-*-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/mipsmach3.h"'
+ ;;
+ mips-*-sysv4*) ;;
+ mips-*-sysv* | mips-*-riscos*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/riscos.h"'
+ ;;
+ mips-sony-bsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/news-mips.h"'
+ ;;
+ m68*-bull*-sysv*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/dpx2.h"'
+ ;;
+ m68*-hp-hpux*) COREFILE=hpux-core.lo ;;
+ m68*-hp-bsd*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+ m68*-*-linux-gnu*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+ m68*-motorola-sysv*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/delta68.h"'
+ ;;
+ m68*-sony-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/news.h"'
+ ;;
+ m68*-*-netbsd* | m68*-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ m68*-apple-aux*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68kaux.h"'
+ ;;
+ m88*-*-sysv4*) ;;
+ m88*-motorola-sysv*) COREFILE=ptrace-core.lo ;;
+ m88*-*-mach3*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m88kmach3.h"'
+ ;;
+ ns32k-pc532-mach)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/pc532mach.h"'
+ ;;
+ ns32k-*-netbsd* | ns32k-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ rs6000-*-lynx*) COREFILE=lynx-core.lo ;;
+ rs6000-*-aix4*) COREFILE=rs6000-core.lo ;;
+ rs6000-*-*) COREFILE=rs6000-core.lo ;;
+ powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;;
+ powerpc-*-aix4*) COREFILE=rs6000-core.lo ;;
+ powerpc-*-aix*) COREFILE=rs6000-core.lo ;;
+ powerpc-*-beos*) ;;
+ powerpc-*-netbsd*) COREFILE=netbsd-core.lo ;;
+ sparc-*-netbsd* | sparc-*-openbsd*)
+ COREFILE=netbsd-core.lo
+ ;;
+ tahoe-*-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/tahoe.h"'
+ ;;
+ vax-*-ultrix2*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+ vax-*-ultrix*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+ vax-*-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxbsd.h"'
+ ;;
+ esac
+
+ case "$COREFILE" in
+ aix386-core.lo) COREFLAG=-DAIX386_CORE ;;
+ hppabsd-core.lo) COREFLAG=-DHPPABSD_CORE ;;
+ hpux-core.lo) COREFLAG=-DHPUX_CORE ;;
+ irix-core.lo) COREFLAG=-DIRIX_CORE ;;
+ lynx-core.lo) COREFLAG=-DLYNX_CORE ;;
+ netbsd-core.lo) COREFLAG=-DNETBSD_CORE ;;
+ osf-core.lo) COREFLAG=-DOSF_CORE ;;
+ ptrace-core.lo) COREFLAG=-DPTRACE_CORE ;;
+ rs6000-core.lo) COREFLAG="$COREFLAG -DAIX_CORE" ;;
+ sco5-core.lo) COREFLAG="$COREFLAG -DSCO5_CORE" ;;
+ trad-core.lo) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
+ esac
+
+ # ELF corefile support has several flavors, but all of
+ # them use something called <sys/procfs.h>
+ AC_CHECK_HEADERS(sys/procfs.h)
+ if test "$ac_cv_header_sys_procfs_h" = yes; then
+ BFD_HAVE_SYS_PROCFS_TYPE(prstatus_t)
+ BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prstatus_t, pr_who)
+ BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(psinfo_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(lwpstatus_t)
+ BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_context)
+ BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_reg)
+ fi
+fi
+AC_SUBST(COREFILE)
+AC_SUBST(COREFLAG)
+AC_DEFINE_UNQUOTED(TRAD_HEADER, $TRAD_HEADER,
+ [Name of host specific header file to include in trad-core.c.])
+
+# Horrible hacks to build DLLs on Windows.
+WIN32LDFLAGS=
+WIN32LIBADD=
+case "${host}" in
+*-*-cygwin*)
+ if test "$enable_shared" = "yes"; then
+ WIN32LDFLAGS="-no-undefined"
+ WIN32LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
+ fi
+ ;;
+esac
+AC_SUBST(WIN32LDFLAGS)
+AC_SUBST(WIN32LIBADD)
+
+# target stuff:
+
+# Canonicalize the secondary target names.
+if test -n "$enable_targets" ; then
+ for targ in `echo $enable_targets | sed 's/,/ /g'`
+ do
+ result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null`
+ if test -n "$result" ; then
+ canon_targets="$canon_targets $result"
+ else
+ # Allow targets that config.sub doesn't recognize, like "all".
+ canon_targets="$canon_targets $targ"
+ fi
+ done
+fi
+
+all_targets=false
+defvec=
+selvecs=
+selarchs=
+TDEFINES=
+for targ in $target $canon_targets
+do
+ if test "x$targ" = "xall"; then
+ all_targets=true
+ else
+ . $srcdir/config.bfd
+ if test "x$targ" = "x$target"; then
+ defvec=$targ_defvec
+ fi
+ selvecs="$selvecs $targ_defvec $targ_selvecs"
+ selarchs="$selarchs $targ_archs"
+ TDEFINES="$TDEFINES $targ_cflags"
+ fi
+done
+AC_SUBST(TDEFINES)
+
+# This processing still needs to be done if we're to decide properly whether
+# 64-bit support needs to be compiled in. Currently, it will be included if
+# the default or any other explicitly requested target requires it; it
+# will not be included on a 32-bit host if no 64-bit target is requested, and
+# no "--with-64-bit-bfd" option is given, even if "--with-targets=all" is
+# used.
+
+# uniq the default and selected vectors in all the configured targets.
+f=""
+for i in $selvecs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+selvecs="$f"
+
+
+# uniq the architectures in all the configured targets.
+f=""
+for i in $selarchs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+selarchs="$f"
+
+# Target backend .o files.
+tb=
+
+elf="elf.lo elflink.lo dwarf2.lo dwarf1.lo"
+
+for vec in $selvecs
+do
+ case "$vec" in
+ # This list is alphabetized to make it easy to compare
+ # with the two vector lists in targets.c.
+ a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;;
+ a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;;
+ armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armpe_little_vec) tb="$tb pe-arm.lo coff-arm.lo cofflink.lo " ;;
+ armpe_big_vec) tb="$tb pe-arm.lo coff-arm.lo cofflink.lo " ;;
+ armpei_little_vec) tb="$tb pei-arm.lo cofflink.lo " ;;
+ armpei_big_vec) tb="$tb pei-arm.lo cofflink.lo " ;;
+ arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo cofflink.lo " ;;
+ arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo cofflink.lo " ;;
+ arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo cofflink.lo " ;;
+ arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo cofflink.lo " ;;
+ aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;;
+ aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;;
+ aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;;
+ aout_mips_big_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
+ aout_mips_little_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
+ apollocoff_vec) tb="$tb coff-apollo.lo" ;;
+ b_out_vec_big_host) tb="$tb bout.lo aout32.lo" ;;
+ b_out_vec_little_host) tb="$tb bout.lo aout32.lo" ;;
+ bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"
+ target64=true ;;
+ bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
+ target64=true ;;
+ bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
+ bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
+ bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
+ bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
+ bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
+ bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
+ target64=true ;;
+ bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
+ bfd_elf32_m68k_vec) tb="$tb elf32-m68k.lo elf32.lo $elf" ;;
+ bfd_elf32_m88k_vec) tb="$tb elf32-m88k.lo elf32.lo $elf" ;;
+ bfd_elf32_mcore_big_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
+ bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;;
+ bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
+ bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
+ bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
+ bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;;
+ bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
+ target64=true ;;
+ bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
+ target64=true ;;
+ bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"
+ target64=true ;;
+ cisco_core_vec) tb="$tb cisco-core.lo" ;;
+ demo_64_vec) tb="$tb demo64.lo aout64.lo"
+ target64=true ;;
+ ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoff_biglittle_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"
+ target64=true ;;
+ go32coff_vec) tb="$tb coff-go32.lo cofflink.lo" ;;
+ go32stubbedcoff_vec) tb="$tb coff-stgo32.lo cofflink.lo" ;;
+ h8300coff_vec) tb="$tb coff-h8300.lo reloc16.lo" ;;
+ h8500coff_vec) tb="$tb coff-h8500.lo reloc16.lo" ;;
+ host_aout_vec) tb="$tb host-aout.lo aout32.lo" ;;
+ hp300bsd_vec) tb="$tb hp300bsd.lo aout32.lo" ;;
+ hp300hpux_vec) tb="$tb hp300hpux.lo aout32.lo" ;;
+ i386aout_vec) tb="$tb i386aout.lo aout32.lo" ;;
+ i386bsd_vec) tb="$tb i386bsd.lo aout32.lo" ;;
+ i386coff_vec) tb="$tb coff-i386.lo cofflink.lo" ;;
+ i386dynix_vec) tb="$tb i386dynix.lo aout32.lo" ;;
+ i386freebsd_vec) tb="$tb i386freebsd.lo aout32.lo" ;;
+ i386msdos_vec) tb="$tb i386msdos.lo" ;;
+ i386pe_vec) tb="$tb pe-i386.lo cofflink.lo " ;;
+ i386pei_vec) tb="$tb pei-i386.lo cofflink.lo" ;;
+ i386linux_vec) tb="$tb i386linux.lo aout32.lo" ;;
+ i386lynx_aout_vec) tb="$tb i386lynx.lo lynx-core.lo aout32.lo" ;;
+ i386lynx_coff_vec) tb="$tb cf-i386lynx.lo cofflink.lo lynx-core.lo" ;;
+ i386mach3_vec) tb="$tb i386mach3.lo aout32.lo" ;;
+ i386netbsd_vec) tb="$tb i386netbsd.lo aout32.lo" ;;
+ i386os9k_vec) tb="$tb i386os9k.lo aout32.lo" ;;
+ i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;;
+ icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
+ icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
+ ieee_vec) tb="$tb ieee.lo" ;;
+ m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
+ m68kcoffun_vec) tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
+ m68klinux_vec) tb="$tb m68klinux.lo aout32.lo" ;;
+ m68klynx_aout_vec) tb="$tb m68klynx.lo lynx-core.lo aout32.lo" ;;
+ m68klynx_coff_vec) tb="$tb cf-m68klynx.lo coff-m68k.lo cofflink.lo lynx-core.lo" ;;
+ m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;;
+ m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
+ m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
+ m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;;
+ m88kbcs_vec) tb="$tb coff-m88k.lo" ;;
+ mcore_pe_big_vec) tb="$tb pe-mcore.lo cofflink.lo" ;;
+ mcore_pe_little_vec) tb="$tb pe-mcore.lo cofflink.lo" ;;
+ mcore_pei_big_vec) tb="$tb pei-mcore.lo cofflink.lo" ;;
+ mcore_pei_little_vec) tb="$tb pei-mcore.lo cofflink.lo" ;;
+ newsos3_vec) tb="$tb newsos3.lo aout32.lo" ;;
+ nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
+ nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
+ nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"
+ target64=true ;;
+ riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
+ nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
+ pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
+ pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;;
+ pmac_xcoff_vec) tb="$tb coff-pmac.lo xcofflink.lo" ;;
+ rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
+ bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo cofflink.lo" ;;
+ bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo cofflink.lo" ;;
+ bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo cofflink.lo" ;;
+ bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo cofflink.lo" ;;
+ ppcboot_vec) tb="$tb ppcboot.lo" ;;
+ shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shlcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ som_vec) tb="$tb som.lo" ;;
+ sparcle_aout_vec) tb="$tb aout-sparcle.lo aout32.lo" ;;
+ sparclinux_vec) tb="$tb sparclinux.lo aout32.lo" ;;
+ sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;;
+ sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;;
+ sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;;
+ sparccoff_vec) tb="$tb coff-sparc.lo" ;;
+ srec_vec) tb="$tb srec.lo" ;;
+ sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;;
+ symbolsrec_vec) tb="$tb srec.lo" ;;
+ tekhex_vec) tb="$tb tekhex.lo" ;;
+ tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
+ tic30_coff_vec) tb="$tb coff-tic30.lo" ;;
+ tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;;
+ versados_vec) tb="$tb versados.lo" ;;
+ vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"
+ target64=true ;;
+ vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
+ w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
+ we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
+ z8kcoff_vec) tb="$tb coff-z8k.lo reloc16.lo" ;;
+
+ "") ;;
+ *) AC_MSG_ERROR(*** unknown target vector $vec) ;;
+ esac
+done
+
+# Target architecture .o files.
+# A couple of CPUs use shorter file names to avoid problems on DOS
+# filesystems.
+ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.lo/g -e s/mn10200/m10200/ -e s/mn10300/m10300/`
+
+# Weed out duplicate .o files.
+f=""
+for i in $tb ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+tb="$f"
+
+f=""
+for i in $ta ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+ta="$f"
+
+bfd_backends="$tb"
+bfd_machines="$ta"
+
+if test x${all_targets} = xtrue ; then
+ bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
+ bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
+ selvecs=
+ havevecs=
+ selarchs=
+else # all_targets is true
+ # Only set these if they will be nonempty, for the clever echo.
+ havevecs=
+ test -n "$selvecs" &&
+ havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
+ test -n "$selvecs" &&
+ selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+ test -n "$selarchs" &&
+ selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+fi # all_targets is true
+
+case ${host64}-${target64}-${want64} in
+ *true*)
+ wordsize=64
+ all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
+ if test -z "$GCC" && test "$BFD_HOST_64BIT_LONG" = "0" && test "$BFD_HOST_64_BIT_DEFINED" = "0"; then
+ AC_MSG_WARN([You have requested a 64 bit BFD configuration, but])
+ AC_MSG_WARN([your compiler may not have a 64 bit integral type])
+ fi
+ ;;
+ false-false-false)
+ wordsize=32
+ all_backends='$(BFD32_BACKENDS)'
+ ;;
+esac
+
+AC_SUBST(wordsize)
+AC_SUBST(all_backends)
+AC_SUBST(bfd_backends)
+AC_SUBST(bfd_machines)
+
+tdefaults=""
+test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
+test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
+test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
+test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
+AC_SUBST(tdefaults)
+
+dnl AC_CHECK_HEADERS(sys/mman.h)
+AC_FUNC_MMAP
+AC_CHECK_FUNCS(madvise mprotect)
+case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in
+ true+yes ) AC_DEFINE(USE_MMAP, 1, [Use mmap if it's available?]) ;;
+esac
+
+rm -f doc/config.status
+AC_OUTPUT(Makefile doc/Makefile bfd-in3.h:bfd-in2.h po/Makefile.in:po/Make-in,
+[sed -e '/POTFILES =/r po/POTFILES' po/Makefile.in > po/Makefile])
diff --git a/bfd/corefile.c b/bfd/corefile.c
new file mode 100644
index 00000000000..212f519ce8a
--- /dev/null
+++ b/bfd/corefile.c
@@ -0,0 +1,106 @@
+/* Core file generic interface routines for BFD.
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ Core files
+
+DESCRIPTION
+ These are functions pertaining to core files.
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+
+/*
+FUNCTION
+ bfd_core_file_failing_command
+
+SYNOPSIS
+ CONST char *bfd_core_file_failing_command(bfd *abfd);
+
+DESCRIPTION
+ Return a read-only string explaining which program was running
+ when it failed and produced the core file @var{abfd}.
+
+*/
+
+CONST char *
+bfd_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ if (abfd->format != bfd_core) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+ }
+ return BFD_SEND (abfd, _core_file_failing_command, (abfd));
+}
+
+/*
+FUNCTION
+ bfd_core_file_failing_signal
+
+SYNOPSIS
+ int bfd_core_file_failing_signal(bfd *abfd);
+
+DESCRIPTION
+ Returns the signal number which caused the core dump which
+ generated the file the BFD @var{abfd} is attached to.
+*/
+
+int
+bfd_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ if (abfd->format != bfd_core) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return 0;
+ }
+ return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
+}
+
+
+/*
+FUNCTION
+ core_file_matches_executable_p
+
+SYNOPSIS
+ boolean core_file_matches_executable_p
+ (bfd *core_bfd, bfd *exec_bfd);
+
+DESCRIPTION
+ Return <<true>> if the core file attached to @var{core_bfd}
+ was generated by a run of the executable file attached to
+ @var{exec_bfd}, <<false>> otherwise.
+*/
+boolean
+core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) {
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ return BFD_SEND (core_bfd, _core_file_matches_executable_p,
+ (core_bfd, exec_bfd));
+}
diff --git a/bfd/cpu-a29k.c b/bfd/cpu-a29k.c
new file mode 100644
index 00000000000..5bd25a47720
--- /dev/null
+++ b/bfd/cpu-a29k.c
@@ -0,0 +1,39 @@
+/* BFD support for the AMD 29000 architecture.
+ Copyright 1992 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_a29k_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_a29k,
+ 0, /* only 1 machine */
+ "a29k",
+ "a29k",
+ 4,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+ };
diff --git a/bfd/cpu-alpha.c b/bfd/cpu-alpha.c
new file mode 100644
index 00000000000..b89900be3b7
--- /dev/null
+++ b/bfd/cpu-alpha.c
@@ -0,0 +1,51 @@
+/* BFD support for the Alpha architecture.
+ Copyright 1992 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
+ { \
+ BITS_WORD, /* bits in a word */ \
+ BITS_ADDR, /* bits in an address */ \
+ 8, /* 8 bits in a byte */ \
+ bfd_arch_alpha, \
+ NUMBER, \
+ "alpha", \
+ PRINT, \
+ 3, \
+ DEFAULT, \
+ bfd_default_compatible, \
+ bfd_default_scan, \
+ NEXT, \
+ }
+
+#define NN(index) (&arch_info_struct[index])
+
+/* These exist only so that we can resonably disassemble PALcode. */
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N (64, 64, bfd_mach_alpha_ev4, "alpha:ev4", false, NN(1)),
+ N (64, 64, bfd_mach_alpha_ev5, "alpha:ev5", false, NN(2)),
+ N (64, 64, bfd_mach_alpha_ev6, "alpha:ev6", false, 0),
+};
+
+const bfd_arch_info_type bfd_alpha_arch =
+ N (64, 64, 0, "alpha", true, NN(0));
diff --git a/bfd/cpu-arc.c b/bfd/cpu-arc.c
new file mode 100644
index 00000000000..bce59d4c99f
--- /dev/null
+++ b/bfd/cpu-arc.c
@@ -0,0 +1,70 @@
+/* BFD support for the ARC processor
+ Copyright 1994, 1995, 1997 Free Software Foundation, Inc.
+ Contributed by Doug Evans (dje@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define ARC(mach, print_name, default_p, next) \
+{ \
+ 32, /* 32 bits in a word */ \
+ 32, /* 32 bits in an address */ \
+ 8, /* 8 bits in a byte */ \
+ bfd_arch_arc, \
+ mach, \
+ "arc", \
+ print_name, \
+ 4, /* section alignment power */ \
+ default_p, \
+ bfd_default_compatible, \
+ bfd_default_scan, \
+ next, \
+ }
+
+#if 0 /* ??? Not currently needed, but keep in for future reference. */
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ ARC (bfd_mach_arc_foo, "arc-foo", false, &arch_info_struct[1]),
+ ARC (bfd_mach_arc_bar, "arc-bar", false, 0),
+};
+#endif
+
+const bfd_arch_info_type bfd_arc_arch =
+ ARC (bfd_mach_arc_base, "arc-base", true, 0 /*&arch_info_struct[0]*/);
+
+/* Utility routines. */
+
+/* Given cpu type NAME, return its bfd_mach_arc_xxx value.
+ Returns -1 if not found. */
+
+int
+arc_get_mach (name)
+ char *name;
+{
+ const bfd_arch_info_type *p;
+
+ for (p = &bfd_arc_arch; p != NULL; p = p->next)
+ {
+ /* +4: skip over "arc-" */
+ if (strcmp (name, p->printable_name + 4) == 0)
+ return p->mach;
+ }
+ return -1;
+}
diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c
new file mode 100644
index 00000000000..d999c0ff247
--- /dev/null
+++ b/bfd/cpu-arm.c
@@ -0,0 +1,134 @@
+/* BFD support for the ARM processor
+ Copyright 1994, 95, 1997 Free Software Foundation, Inc.
+ Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+static const bfd_arch_info_type *compatible
+ PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+static boolean scan PARAMS ((const struct bfd_arch_info *, const char *));
+
+/* This routine is provided two arch_infos and works out which ARM
+ machine which would be compatible with both and returns a pointer
+ to its info structure */
+
+static const bfd_arch_info_type *
+compatible (a,b)
+ const bfd_arch_info_type * a;
+ const bfd_arch_info_type * b;
+{
+ /* If a & b are for different architecture we can do nothing */
+ if (a->arch != b->arch)
+ return NULL;
+
+ /* If a & b are for the same machine then all is well */
+ if (a->mach == b->mach)
+ return a;
+
+ /* Otherwise if either a or b is the 'default' machine then
+ it can be polymorphed into the other */
+ if (a->the_default)
+ return b;
+
+ if (b->the_default)
+ return a;
+
+ /* So far all newer ARM architecture cores are supersets of previous cores */
+ if (a->mach < b->mach)
+ return b;
+ else if (a->mach > b->mach)
+ return a;
+
+ /* Never reached! */
+ return NULL;
+}
+
+static struct
+{
+ enum bfd_architecture arch;
+ char * name;
+}
+processors[] =
+{
+ { bfd_mach_arm_2, "arm2" },
+ { bfd_mach_arm_2a, "arm250" },
+ { bfd_mach_arm_2a, "arm3" },
+ { bfd_mach_arm_3, "arm6" },
+ { bfd_mach_arm_3, "arm60" },
+ { bfd_mach_arm_3, "arm600" },
+ { bfd_mach_arm_3, "arm610" },
+ { bfd_mach_arm_3, "arm7" },
+ { bfd_mach_arm_3, "arm710" },
+ { bfd_mach_arm_3, "arm7500" },
+ { bfd_mach_arm_3, "arm7d" },
+ { bfd_mach_arm_3, "arm7di" },
+ { bfd_mach_arm_3M, "arm7dm" },
+ { bfd_mach_arm_3M, "arm7dmi" },
+ { bfd_mach_arm_4, "arm8" },
+ { bfd_mach_arm_4, "arm810" },
+ { bfd_mach_arm_4, "sa1" },
+ { bfd_mach_arm_4T, "arm7tdmi" }
+};
+
+static boolean
+scan (info, string)
+ const struct bfd_arch_info * info;
+ const char * string;
+{
+ int i;
+
+ /* First test for an exact match */
+ if (strcasecmp (string, info->printable_name) == 0)
+ return true;
+
+ /* Next check for a processor name instead of an Architecture name */
+ for (i = sizeof (processors) / sizeof (processors[0]); i--;)
+ {
+ if (strcasecmp (string, processors[ i ].name) == 0)
+ break;
+ }
+
+ if (i != -1 && info->arch == processors[ i ].arch)
+ return true;
+
+ /* Finally check for the default architecture */
+ if (strcasecmp (string, "arm") == 0)
+ return info->the_default;
+
+ return false;
+}
+
+
+#define N(number, print, default, next) \
+{ 32, 32, 8, bfd_arch_arm, number, "arm", print, 4, default, compatible, scan, next }
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N( bfd_mach_arm_2, "armv2", false, & arch_info_struct[1] ),
+ N( bfd_mach_arm_2a, "armv2a", false, & arch_info_struct[2] ),
+ N( bfd_mach_arm_3, "armv3", false, & arch_info_struct[3] ),
+ N( bfd_mach_arm_3M, "armv3m", false, & arch_info_struct[4] ),
+ N( bfd_mach_arm_4, "armv4", false, & arch_info_struct[5] ),
+ N( bfd_mach_arm_4T, "armv4t", false, NULL )
+};
+
+const bfd_arch_info_type bfd_arm_arch =
+ N( 0, "arm", true, & arch_info_struct[0] );
diff --git a/bfd/cpu-d10v.c b/bfd/cpu-d10v.c
new file mode 100644
index 00000000000..a1ff088bdbc
--- /dev/null
+++ b/bfd/cpu-d10v.c
@@ -0,0 +1,40 @@
+/* BFD support for the D10V processor
+ Copyright 1996 Free Software Foundation, Inc.
+ Contributed by Martin Hunt (hunt@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_d10v_arch =
+{
+ 16, /* 16 bits in a word */
+ 16, /* 16 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_d10v,
+ 0,
+ "d10v",
+ "d10v",
+ 4, /* section alignment power */
+ true,
+ bfd_default_compatible,
+ bfd_default_scan,
+ 0,
+};
+
diff --git a/bfd/cpu-d30v.c b/bfd/cpu-d30v.c
new file mode 100644
index 00000000000..6eadfee271a
--- /dev/null
+++ b/bfd/cpu-d30v.c
@@ -0,0 +1,39 @@
+/* BFD support for the Mitsubishi D30V processor
+ Copyright 1997 Free Software Foundation, Inc.
+ Contributed by Martin Hunt (hunt@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_d30v_arch =
+{
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_d30v,
+ 0,
+ "d30v",
+ "d30v",
+ 4, /* section alignment power */
+ true,
+ bfd_default_compatible,
+ bfd_default_scan,
+ 0,
+};
diff --git a/bfd/cpu-fr30.c b/bfd/cpu-fr30.c
new file mode 100644
index 00000000000..33208f89bbb
--- /dev/null
+++ b/bfd/cpu-fr30.c
@@ -0,0 +1,38 @@
+/* BFD support for the FR30 processor.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_fr30_arch =
+{
+ 32, /* bits per word */
+ 32, /* bits per address */
+ 8, /* bits per byte */
+ bfd_arch_fr30, /* architecture */
+ bfd_mach_fr30, /* machine */
+ "fr30", /* architecture name */
+ "fr30", /* printable name */
+ 4, /* section align power */
+ true, /* the default ? */
+ bfd_default_compatible, /* architecture comparison fn */
+ bfd_default_scan, /* string to architecture convert fn */
+ NULL /* next in list */
+};
diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c
new file mode 100644
index 00000000000..567b7df9de2
--- /dev/null
+++ b/bfd/cpu-h8300.c
@@ -0,0 +1,134 @@
+/* BFD library support routines for the Hitachi H8/300 architecture.
+ Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+int bfd_default_scan_num_mach ();
+
+static boolean
+h8300_scan (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ if (*string != 'h' && *string != 'H')
+ return false;
+
+ string++;
+ if (*string != '8')
+ return false;
+
+ string++;
+ if (*string == '/')
+ string++;
+
+ if (*string != '3')
+ return false;
+ string++;
+ if (*string != '0')
+ return false;
+ string++;
+ if (*string != '0')
+ return false;
+ string++;
+ if (*string == '-')
+ string++;
+ if (*string == 'h' || *string == 'H')
+ {
+ return (info->mach == bfd_mach_h8300h);
+ }
+ else if (*string == 's' || *string == 'S')
+ {
+ return (info->mach == bfd_mach_h8300s);
+ }
+ else
+ {
+ return info->mach == bfd_mach_h8300;
+ }
+}
+
+
+/* This routine is provided two arch_infos and works out the
+ machine which would be compatible with both and returns a pointer
+ to its info structure */
+
+static const bfd_arch_info_type *
+compatible (in, out)
+ const bfd_arch_info_type * in;
+ const bfd_arch_info_type * out;
+{
+ /* It's really not a good idea to mix and match modes. */
+ if (in->mach != out->mach)
+ return 0;
+ else
+ return in;
+}
+
+static const bfd_arch_info_type h8300_info_struct =
+{
+ 16, /* 16 bits in a word */
+ 16, /* 16 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_h8300,
+ bfd_mach_h8300,
+ "h8300", /* arch_name */
+ "h8300", /* printable name */
+ 1,
+ true, /* the default machine */
+ compatible,
+ h8300_scan,
+/* local_bfd_reloc_type_lookup, */
+ 0,
+};
+
+static const bfd_arch_info_type h8300h_info_struct =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_h8300,
+ bfd_mach_h8300h,
+ "h8300h", /* arch_name */
+ "h8300h", /* printable name */
+ 1,
+ false, /* the default machine */
+ compatible,
+ h8300_scan,
+/* local_bfd_reloc_type_lookup, */
+ &h8300_info_struct,
+};
+
+const bfd_arch_info_type bfd_h8300_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_h8300,
+ bfd_mach_h8300s,
+ "h8300s", /* arch_name */
+ "h8300s", /* printable name */
+ 1,
+ false, /* the default machine */
+ compatible,
+ h8300_scan,
+/* local_bfd_reloc_type_lookup, */
+ &h8300h_info_struct,
+};
diff --git a/bfd/cpu-h8500.c b/bfd/cpu-h8500.c
new file mode 100644
index 00000000000..e4abfd17807
--- /dev/null
+++ b/bfd/cpu-h8500.c
@@ -0,0 +1,199 @@
+/* BFD library support routines for the H8/500 architecture.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#if 0
+
+/*
+Relocations for the Z8K
+
+*/
+static bfd_reloc_status_type
+howto16_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+ long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
+
+ HOWTO_PREPARE(relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_16(abfd, x, (bfd_byte *)data + addr);
+ return bfd_reloc_ok;
+}
+
+
+static bfd_reloc_status_type
+howto8_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+ long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
+
+ HOWTO_PREPARE(relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_8(abfd, x, (bfd_byte *)data + addr);
+ return bfd_reloc_ok;
+}
+
+
+static bfd_reloc_status_type
+howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+
+ long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
+ abort();
+ HOWTO_PREPARE(relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_8(abfd, x, (bfd_byte *)data + addr);
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+ long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
+ abort();
+ HOWTO_PREPARE(relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_8(abfd, x, (bfd_byte *)data + addr);
+ return bfd_reloc_ok;
+}
+
+
+
+static reloc_howto_type howto_16
+ = NEWHOWTO(howto16_callback,"abs16",1,false,false);
+static reloc_howto_type howto_8
+ = NEWHOWTO(howto8_callback,"abs8",0,false,false);
+
+static reloc_howto_type howto_8_FFnn
+ = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
+
+static reloc_howto_type howto_8_pcrel
+ = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
+
+
+static reloc_howto_type *
+local_bfd_reloc_type_lookup (arch, code)
+ const struct bfd_arch_info *arch;
+ bfd_reloc_code_real_type code;
+{
+ switch (code) {
+ case BFD_RELOC_16:
+ return &howto_16;
+ case BFD_RELOC_8_FFnn:
+ return &howto_8_FFnn;
+ case BFD_RELOC_8:
+ return &howto_8;
+ case BFD_RELOC_8_PCREL:
+ return &howto_8_pcrel;
+ }
+ return (reloc_howto_type *)NULL;
+}
+#endif
+
+int bfd_default_scan_num_mach();
+
+static boolean
+scan_mach (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ if (strcmp(string,"h8/500") == 0) return true;
+ if (strcmp(string,"H8/500") == 0) return true;
+ if (strcmp(string,"h8500") == 0) return true;
+ if (strcmp(string,"H8500") == 0) return true;
+ return false;
+}
+
+
+#if 0 /* not used currently */
+/* This routine is provided two arch_infos and returns whether
+ they'd be compatible */
+
+static const bfd_arch_info_type *
+compatible (a,b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ if (a->arch != b->arch || a->mach != b->mach)
+ return NULL;
+ return a;
+}
+#endif
+
+const bfd_arch_info_type bfd_h8500_arch =
+{
+ 16, /* 16 bits in a word */
+ 24, /* 24 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_h8500,
+ 0, /* only 1 machine */
+ "h8500", /* arch_name */
+ "h8500", /* printable name */
+ 1,
+ true, /* the default machine */
+ bfd_default_compatible,
+ scan_mach,
+ 0,
+};
diff --git a/bfd/cpu-hppa.c b/bfd/cpu-hppa.c
new file mode 100644
index 00000000000..5d26a92ad99
--- /dev/null
+++ b/bfd/cpu-hppa.c
@@ -0,0 +1,71 @@
+/* BFD support for the HP Precision Architecture architecture.
+ Copyright 1992 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+static const bfd_arch_info_type bfd_hppa10_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_hppa,
+ 10, /* By convention PA1.0 = 10 */
+ "hppa",
+ "hppa1.0",
+ 3,
+ true, /* Unless we use 1.1 specific features */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+};
+
+/* PA2.0 in narrow mode */
+static const bfd_arch_info_type bfd_hppa20_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_hppa,
+ 20, /* By convention PA1.0 = 10 */
+ "hppa",
+ "hppa2.0",
+ 3,
+ false, /* Unless we use 1.1 specific features */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ &bfd_hppa10_arch,
+};
+
+const bfd_arch_info_type bfd_hppa_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_hppa,
+ 11, /* By convention PA1.1 = 11 */
+ "hppa",
+ "hppa1.1",
+ 3,
+ false, /* 1.1 specific features used */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ &bfd_hppa20_arch,
+};
diff --git a/bfd/cpu-i386.c b/bfd/cpu-i386.c
new file mode 100644
index 00000000000..f5b9b181d18
--- /dev/null
+++ b/bfd/cpu-i386.c
@@ -0,0 +1,70 @@
+/* BFD support for the Intel 386 architecture.
+ Copyright 1992, 94, 95, 1996 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_i386_arch_intel_syntax =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_i386,
+ bfd_mach_i386_i386_intel_syntax,
+ "i386:intel",
+ "i386:intel",
+ 3,
+ true,
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+};
+static const bfd_arch_info_type i8086_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address (well, not really) */
+ 8, /* 8 bits in a byte */
+ bfd_arch_i386,
+ bfd_mach_i386_i8086,
+ "i8086",
+ "i8086",
+ 3,
+ false,
+ bfd_default_compatible,
+ bfd_default_scan ,
+ &bfd_i386_arch_intel_syntax,
+};
+
+const bfd_arch_info_type bfd_i386_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_i386,
+ bfd_mach_i386_i386,
+ "i386",
+ "i386",
+ 3,
+ true,
+ bfd_default_compatible,
+ bfd_default_scan ,
+ &i8086_arch,
+};
+
diff --git a/bfd/cpu-i860.c b/bfd/cpu-i860.c
new file mode 100644
index 00000000000..57c867cdb2c
--- /dev/null
+++ b/bfd/cpu-i860.c
@@ -0,0 +1,40 @@
+/* BFD support for the Intel 860 architecture.
+ Copyright 1992, 1995 Free Software Foundation, Inc.
+ Created mostly by substituting "860" for "386" in cpu-i386.c
+ Harry Dolan <dolan@ssd.intel.com>, October 1995
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_i860_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_i860,
+ 0, /* only 1 machine */
+ "i860",
+ "i860",
+ 3,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+ };
diff --git a/bfd/cpu-i960.c b/bfd/cpu-i960.c
new file mode 100644
index 00000000000..7fb2c7ebc5c
--- /dev/null
+++ b/bfd/cpu-i960.c
@@ -0,0 +1,166 @@
+/* BFD library support routines for the i960 architecture.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+
+/* This routine is provided a string, and tries to work out if it
+ could possibly refer to the i960 machine pointed at in the
+ info_struct pointer */
+
+static boolean
+scan_960_mach (ap, string)
+ const bfd_arch_info_type *ap;
+ const char *string;
+{
+ unsigned long machine;
+
+ /* Look for the string i960, or somesuch at the front of the string */
+
+ if (strncmp("i960",string,4) == 0) {
+ string+=4;
+ }
+ else {
+ /* no match, can be us */
+ return false;
+ }
+ if (string[0] == 0) {
+ /* i960 on it's own means core to us*/
+ if (ap->mach == bfd_mach_i960_core) return true;
+ return false;
+ }
+
+ if (string[0] != ':') {
+ return false;
+ }
+ string++;
+ if (string[0] == '\0')
+ return false;
+ if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
+ string[3] == 'e' && string[4] == '\0')
+ machine = bfd_mach_i960_core;
+ else if (strcmp (string, "ka_sa") == 0)
+ machine = bfd_mach_i960_ka_sa;
+ else if (strcmp (string, "kb_sb") == 0)
+ machine = bfd_mach_i960_kb_sb;
+ else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char */
+ return false;
+ else if (string[0] == 'k' && string[1] == 'b')
+ machine = bfd_mach_i960_kb_sb;
+ else if (string[0] == 's' && string[1] == 'b')
+ machine = bfd_mach_i960_kb_sb;
+ else if (string[0] == 'm' && string[1] == 'c')
+ machine = bfd_mach_i960_mc;
+ else if (string[0] == 'x' && string[1] == 'a')
+ machine = bfd_mach_i960_xa;
+ else if (string[0] == 'c' && string[1] == 'a')
+ machine = bfd_mach_i960_ca;
+ else if (string[0] == 'k' && string[1] == 'a')
+ machine = bfd_mach_i960_ka_sa;
+ else if (string[0] == 's' && string[1] == 'a')
+ machine = bfd_mach_i960_ka_sa;
+ else if (string[0] == 'j' && string[1] == 'x')
+ machine = bfd_mach_i960_jx;
+ else if (string[0] == 'h' && string[1] == 'x')
+ machine = bfd_mach_i960_hx;
+ else
+ return false;
+ if (machine == ap->mach) return true;
+ return false;
+}
+
+
+
+/* This routine is provided two arch_infos and works out the i960
+ machine which would be compatible with both and returns a pointer
+ to its info structure */
+
+static const bfd_arch_info_type *
+compatible (a,b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+
+ /* The i960 has distinct subspecies which may not interbreed:
+ CORE CA
+ CORE KA KB MC XA
+ CORE HX JX
+ Any architecture on the same line is compatible, the one on
+ the right is the least restrictive.
+
+ We represent this information in an array, each machine to a side */
+
+#define ERROR 0
+#define CORE bfd_mach_i960_core /*1*/
+#define KA bfd_mach_i960_ka_sa /*2*/
+#define KB bfd_mach_i960_kb_sb /*3*/
+#define MC bfd_mach_i960_mc /*4*/
+#define XA bfd_mach_i960_xa /*5*/
+#define CA bfd_mach_i960_ca /*6*/
+#define JX bfd_mach_i960_jx /*7*/
+#define HX bfd_mach_i960_hx /*8*/
+#define MAX_ARCH ((int)HX)
+
+ static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
+ {
+ { ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
+ { CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
+ { KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
+ { KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
+ { MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
+ { XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
+ { CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
+ { JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
+ { HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
+ };
+
+
+ if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
+ {
+ return NULL;
+ }
+ else
+ {
+ return (a->mach == matrix[a->mach][b->mach]) ? a : b;
+ }
+}
+
+
+
+int bfd_default_scan_num_mach();
+#define N(a,b,d,n) \
+{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N(bfd_mach_i960_ka_sa,"i960:ka_sa",false, &arch_info_struct[1]),
+ N(bfd_mach_i960_kb_sb,"i960:kb_sb",false, &arch_info_struct[2]),
+ N(bfd_mach_i960_mc, "i960:mc", false, &arch_info_struct[3]),
+ N(bfd_mach_i960_xa, "i960:xa", false, &arch_info_struct[4]),
+ N(bfd_mach_i960_ca, "i960:ca", false, &arch_info_struct[5]),
+ N(bfd_mach_i960_jx, "i960:jx", false, &arch_info_struct[6]),
+ N(bfd_mach_i960_hx, "i960:hx", false, 0),
+};
+
+const bfd_arch_info_type bfd_i960_arch =
+ N(bfd_mach_i960_core, "i960:core", true, &arch_info_struct[0]);
diff --git a/bfd/cpu-m10200.c b/bfd/cpu-m10200.c
new file mode 100644
index 00000000000..3f8a678beec
--- /dev/null
+++ b/bfd/cpu-m10200.c
@@ -0,0 +1,38 @@
+/* BFD support for the Matsushita 10200 processor
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_mn10200_arch =
+ {
+ 16, /* 16 bits in a word */
+ 24, /* 16 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_mn10200,
+ 200,
+ "mn10200",
+ "mn10200",
+ 2,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+ };
diff --git a/bfd/cpu-m10300.c b/bfd/cpu-m10300.c
new file mode 100644
index 00000000000..5aa0bfe9c88
--- /dev/null
+++ b/bfd/cpu-m10300.c
@@ -0,0 +1,41 @@
+/* BFD support for the Matsushita 10300 processor
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define NEXT NULL
+
+const bfd_arch_info_type bfd_mn10300_arch =
+ {
+ 32, /* 16 bits in a word */
+ 32, /* 16 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_mn10300,
+ 300,
+ "mn10300",
+ "mn10300",
+ 2,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ NEXT,
+ };
+
diff --git a/bfd/cpu-m32r.c b/bfd/cpu-m32r.c
new file mode 100644
index 00000000000..bd3cc31963d
--- /dev/null
+++ b/bfd/cpu-m32r.c
@@ -0,0 +1,32 @@
+/* BFD support for the M32R processor.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define N(number, print, default, next) \
+{ 32, 32, 8, bfd_arch_m32r, number, "m32r", print, 4, default, \
+ bfd_default_compatible, bfd_default_scan, next }
+
+#define NEXT NULL
+
+
+const bfd_arch_info_type bfd_m32r_arch =
+ N (bfd_mach_m32r, "m32r", true, NEXT);
diff --git a/bfd/cpu-m68k.c b/bfd/cpu-m68k.c
new file mode 100644
index 00000000000..184182d695e
--- /dev/null
+++ b/bfd/cpu-m68k.c
@@ -0,0 +1,42 @@
+/* BFD library support routines for architectures.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 97, 1998
+ Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define N(name, print,d,next) \
+{ 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_default_compatible,bfd_default_scan, next, }
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N(bfd_mach_m68000, "m68k:68000", false, &arch_info_struct[1]),
+ N(bfd_mach_m68008, "m68k:68008", false, &arch_info_struct[2]),
+ N(bfd_mach_m68010, "m68k:68010", false, &arch_info_struct[3]),
+ N(bfd_mach_m68020, "m68k:68020", false, &arch_info_struct[4]),
+ N(bfd_mach_m68030, "m68k:68030", false, &arch_info_struct[5]),
+ N(bfd_mach_m68040, "m68k:68040", false, &arch_info_struct[6]),
+ N(bfd_mach_cpu32, "m68k:cpu32", false, &arch_info_struct[7]),
+ N(bfd_mach_m68060, "m68k:68060", false, 0),
+};
+
+const bfd_arch_info_type bfd_m68k_arch =
+ N(0, "m68k", true, &arch_info_struct[0]);
diff --git a/bfd/cpu-m88k.c b/bfd/cpu-m88k.c
new file mode 100644
index 00000000000..c3716c5a394
--- /dev/null
+++ b/bfd/cpu-m88k.c
@@ -0,0 +1,42 @@
+/* bfd back-end for m88k support
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+
+
+
+const bfd_arch_info_type bfd_m88k_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_m88k,
+ 88100, /* only 1 machine */
+ "m88k",
+ "m88k:88100",
+ 3,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+ };
diff --git a/bfd/cpu-mcore.c b/bfd/cpu-mcore.c
new file mode 100644
index 00000000000..7dbfe1b5dac
--- /dev/null
+++ b/bfd/cpu-mcore.c
@@ -0,0 +1,38 @@
+/* BFD library support routines for Motorolla's MCore architecture
+ Copyright (C) 1993, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_mcore_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_mcore, /* Architecture */
+ 0, /* Machine number - 0 for now */
+ "MCore", /* Architecture name */
+ "MCore", /* Printable name */
+ 3, /* Section align power */
+ true, /* Is this the default architecture ? */
+ bfd_default_compatible, /* Architecture comparison function */
+ bfd_default_scan, /* String to architecture conversion */
+ NULL /* Next in list */
+};
diff --git a/bfd/cpu-mips.c b/bfd/cpu-mips.c
new file mode 100644
index 00000000000..a933b8cd10b
--- /dev/null
+++ b/bfd/cpu-mips.c
@@ -0,0 +1,88 @@
+/* bfd back-end for mips support
+ Copyright (C) 1990, 91-97, 1998 Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
+ { \
+ BITS_WORD, /* bits in a word */ \
+ BITS_ADDR, /* bits in an address */ \
+ 8, /* 8 bits in a byte */ \
+ bfd_arch_mips, \
+ NUMBER, \
+ "mips", \
+ PRINT, \
+ 3, \
+ DEFAULT, \
+ bfd_default_compatible, \
+ bfd_default_scan, \
+ NEXT, \
+ }
+
+enum {
+I_mips3000,
+I_mips3900,
+I_mips4000,
+I_mips4010,
+I_mips4100,
+I_mips4111,
+I_mips4300,
+I_mips4400,
+I_mips4600,
+I_mips4650,
+I_mips5000,
+I_mips6000,
+I_mips8000,
+I_mips10000,
+I_mips16
+};
+
+
+#define NN(index) (&arch_info_struct[(index)+1])
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N (32, 32, bfd_mach_mips3000, "mips:3000", false, NN(I_mips3000)),
+ N (32, 32, bfd_mach_mips3900, "mips:3900", false, NN(I_mips3900)),
+ N (64, 64, bfd_mach_mips4000, "mips:4000", false, NN(I_mips4000)),
+ N (64, 64, bfd_mach_mips4010, "mips:4010", false, NN(I_mips4010)),
+ N (64, 64, bfd_mach_mips4100, "mips:4100", false, NN(I_mips4100)),
+ N (64, 64, bfd_mach_mips4111, "mips:4111", false, NN(I_mips4111)),
+ N (64, 64, bfd_mach_mips4300, "mips:4300", false, NN(I_mips4300)),
+ N (64, 64, bfd_mach_mips4400, "mips:4400", false, NN(I_mips4400)),
+ N (64, 64, bfd_mach_mips4600, "mips:4600", false, NN(I_mips4600)),
+ N (64, 64, bfd_mach_mips4650, "mips:4650", false, NN(I_mips4650)),
+ N (64, 64, bfd_mach_mips5000, "mips:5000", false, NN(I_mips5000)),
+ N (32, 32, bfd_mach_mips6000, "mips:6000", false, NN(I_mips6000)),
+ N (64, 64, bfd_mach_mips8000, "mips:8000", false, NN(I_mips8000)),
+ N (64, 64, bfd_mach_mips10000, "mips:10000", false, NN(I_mips10000)),
+
+
+ N (64, 64, bfd_mach_mips16, "mips:16", false, 0),
+};
+
+/* The default architecture is mips:3000, but with a machine number of
+ zero. This lets the linker distinguish between a default setting
+ of mips, and an explicit setting of mips:3000. */
+
+const bfd_arch_info_type bfd_mips_arch =
+N (32, 32, 0, "mips", true, &arch_info_struct[0]);
diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c
new file mode 100644
index 00000000000..1b0a18d5c52
--- /dev/null
+++ b/bfd/cpu-ns32k.c
@@ -0,0 +1,846 @@
+/* BFD support for the ns32k architecture.
+ Copyright (C) 1990, 91, 94, 95, 96, 1998 Free Software Foundation, Inc.
+ Almost totally rewritten by Ian Dall from initial work
+ by Andrew Cagney.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "ns32k.h"
+
+#define N(machine, printable, d, next) \
+{ 32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d,bfd_default_compatible,bfd_default_scan, next, }
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N(32532,"ns32k:32532",true, 0), /* the word ns32k will match this too */
+};
+
+const bfd_arch_info_type bfd_ns32k_arch =
+ N(32032,"ns32k:32032",false, &arch_info_struct[0]);
+
+static long
+ns32k_sign_extend(value, bits)
+ int value;
+ int bits;
+{
+ value = value & ((1 << bits) - 1);
+ return (value & (1 << (bits-1))
+ ? value | (~((1 << bits) - 1))
+ : value);
+}
+
+long
+_bfd_ns32k_get_displacement(buffer, offset, size)
+ bfd_byte *buffer;
+ long offset;
+ long size;
+{
+ long value;
+ buffer += offset;
+ switch (size)
+ {
+ case 1:
+ value = ns32k_sign_extend (*buffer, 7);
+ break;
+ case 2:
+ value = ns32k_sign_extend(*buffer++, 6);
+ value = (value << 8) | (0xff & *buffer);
+ break;
+ case 4:
+ value = ns32k_sign_extend(*buffer++, 6);
+ value = (value << 8) | (0xff & *buffer++);
+ value = (value << 8) | (0xff & *buffer++);
+ value = (value << 8) | (0xff & *buffer);
+ break;
+ default:
+ abort ();
+ return 0;
+ }
+ return value;
+}
+
+int
+_bfd_ns32k_put_displacement(value, buffer, offset, size)
+ long value;
+ bfd_byte *buffer;
+ long offset;
+ long size;
+{
+ buffer += offset;
+ switch (size)
+ {
+ case 1:
+ if (value < -64 || value > 63)
+ return -1;
+ value&=0x7f;
+ *buffer++=value;
+ break;
+ case 2:
+ if (value < -8192 || value > 8191)
+ return -1;
+ value&=0x3fff;
+ value|=0x8000;
+ *buffer++=(value>>8);
+ *buffer++=value;
+ break;
+ case 4:
+ if (value < -0x1f000000 || value >= 0x20000000)
+ return -1;
+ value|=0xc0000000;
+ *buffer++=(value>>24);
+ *buffer++=(value>>16);
+ *buffer++=(value>>8);
+ *buffer++=value;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+long
+_bfd_ns32k_get_immediate (buffer, offset, size)
+ bfd_byte *buffer;
+ long offset;
+ long size;
+{
+ long value = 0;
+ buffer += offset;
+ switch (size)
+ {
+ case 4:
+ value = (value << 8) | (*buffer++ & 0xff);
+ case 3:
+ value = (value << 8) | (*buffer++ & 0xff);
+ case 2:
+ value = (value << 8) | (*buffer++ & 0xff);
+ case 1:
+ value = (value << 8) | (*buffer++ & 0xff);
+ }
+ return value;
+}
+
+int
+_bfd_ns32k_put_immediate (value, buffer, offset, size)
+ long value;
+ bfd_byte *buffer;
+ long offset;
+ long size;
+{
+ buffer += offset + size - 1;
+ switch (size)
+ {
+ case 4:
+ *buffer-- = (value & 0xff); value >>= 8;
+ case 3:
+ *buffer-- = (value & 0xff); value >>= 8;
+ case 2:
+ *buffer-- = (value & 0xff); value >>= 8;
+ case 1:
+ *buffer-- = (value & 0xff); value >>= 8;
+ }
+ return 0;
+}
+
+/* This is just like the standard perform_relocation except we
+ * use get_data and put_data which know about the ns32k
+ * storage methods.
+ * This is probably a lot more complicated than it needs to be!
+ */
+static bfd_reloc_status_type
+do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message, get_data, put_data)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+ long (*get_data)();
+ int (*put_data)();
+{
+ int overflow = 0;
+ bfd_vma relocation;
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+ bfd_size_type addr = reloc_entry->address;
+ bfd_vma output_base = 0;
+ reloc_howto_type *howto = reloc_entry->howto;
+ asection *reloc_target_output_section;
+
+ if ((symbol->section == &bfd_abs_section)
+ && output_bfd != (bfd *) NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* If we are not producing relocateable output, return an error if
+ the symbol is not defined. An undefined weak symbol is
+ considered to have a value of zero (SVR4 ABI, p. 4-27). */
+ if (symbol->section == &bfd_und_section
+ && (symbol->flags & BSF_WEAK) == 0
+ && output_bfd == (bfd *) NULL)
+ flag = bfd_reloc_undefined;
+
+
+ /* Is the address of the relocation really within the section? */
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+
+ reloc_target_output_section = symbol->section->output_section;
+
+ /* Convert input-section-relative symbol value to absolute. */
+ if (output_bfd && howto->partial_inplace == false)
+ output_base = 0;
+ else
+ output_base = reloc_target_output_section->vma;
+
+ relocation += output_base + symbol->section->output_offset;
+
+ /* Add in supplied addend. */
+ relocation += reloc_entry->addend;
+
+ /* Here the variable relocation holds the final address of the
+ symbol we are relocating against, plus any addend. */
+
+ if (howto->pc_relative == true)
+ {
+ /* This is a PC relative relocation. We want to set RELOCATION
+ to the distance between the address of the symbol and the
+ location. RELOCATION is already the address of the symbol.
+
+ We start by subtracting the address of the section containing
+ the location.
+
+ If pcrel_offset is set, we must further subtract the position
+ of the location within the section. Some targets arrange for
+ the addend to be the negative of the position of the location
+ within the section; for example, i386-aout does this. For
+ i386-aout, pcrel_offset is false. Some other targets do not
+ include the position of the location; for example, m88kbcs,
+ or ELF. For those targets, pcrel_offset is true.
+
+ If we are producing relocateable output, then we must ensure
+ that this reloc will be correctly computed when the final
+ relocation is done. If pcrel_offset is false we want to wind
+ up with the negative of the location within the section,
+ which means we must adjust the existing addend by the change
+ in the location within the section. If pcrel_offset is true
+ we do not want to adjust the existing addend at all.
+
+ FIXME: This seems logical to me, but for the case of
+ producing relocateable output it is not what the code
+ actually does. I don't want to change it, because it seems
+ far too likely that something will break. */
+
+ relocation -=
+ input_section->output_section->vma + input_section->output_offset;
+
+ if (howto->pcrel_offset == true)
+ relocation -= reloc_entry->address;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ {
+ if (howto->partial_inplace == false)
+ {
+ /* This is a partial relocation, and we want to apply the relocation
+ to the reloc entry rather than the raw data. Modify the reloc
+ inplace to reflect what we now know. */
+ reloc_entry->addend = relocation;
+ reloc_entry->address += input_section->output_offset;
+ return flag;
+ }
+ else
+ {
+ /* This is a partial relocation, but inplace, so modify the
+ reloc record a bit.
+
+ If we've relocated with a symbol with a section, change
+ into a ref to the section belonging to the symbol. */
+
+ reloc_entry->address += input_section->output_offset;
+
+ /* WTF?? */
+ if (abfd->xvec->flavour == bfd_target_coff_flavour
+ && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0)
+ {
+#if 1
+ /* For m68k-coff, the addend was being subtracted twice during
+ relocation with -r. Removing the line below this comment
+ fixes that problem; see PR 2953.
+
+However, Ian wrote the following, regarding removing the line below,
+which explains why it is still enabled: --djm
+
+If you put a patch like that into BFD you need to check all the COFF
+linkers. I am fairly certain that patch will break coff-i386 (e.g.,
+SCO); see coff_i386_reloc in coff-i386.c where I worked around the
+problem in a different way. There may very well be a reason that the
+code works as it does.
+
+Hmmm. The first obvious point is that bfd_perform_relocation should
+not have any tests that depend upon the flavour. It's seem like
+entirely the wrong place for such a thing. The second obvious point
+is that the current code ignores the reloc addend when producing
+relocateable output for COFF. That's peculiar. In fact, I really
+have no idea what the point of the line you want to remove is.
+
+A typical COFF reloc subtracts the old value of the symbol and adds in
+the new value to the location in the object file (if it's a pc
+relative reloc it adds the difference between the symbol value and the
+location). When relocating we need to preserve that property.
+
+BFD handles this by setting the addend to the negative of the old
+value of the symbol. Unfortunately it handles common symbols in a
+non-standard way (it doesn't subtract the old value) but that's a
+different story (we can't change it without losing backward
+compatibility with old object files) (coff-i386 does subtract the old
+value, to be compatible with existing coff-i386 targets, like SCO).
+
+So everything works fine when not producing relocateable output. When
+we are producing relocateable output, logically we should do exactly
+what we do when not producing relocateable output. Therefore, your
+patch is correct. In fact, it should probably always just set
+reloc_entry->addend to 0 for all cases, since it is, in fact, going to
+add the value into the object file. This won't hurt the COFF code,
+which doesn't use the addend; I'm not sure what it will do to other
+formats (the thing to check for would be whether any formats both use
+the addend and set partial_inplace).
+
+When I wanted to make coff-i386 produce relocateable output, I ran
+into the problem that you are running into: I wanted to remove that
+line. Rather than risk it, I made the coff-i386 relocs use a special
+function; it's coff_i386_reloc in coff-i386.c. The function
+specifically adds the addend field into the object file, knowing that
+bfd_perform_relocation is not going to. If you remove that line, then
+coff-i386.c will wind up adding the addend field in twice. It's
+trivial to fix; it just needs to be done.
+
+The problem with removing the line is just that it may break some
+working code. With BFD it's hard to be sure of anything. The right
+way to deal with this is simply to build and test at least all the
+supported COFF targets. It should be straightforward if time and disk
+space consuming. For each target:
+ 1) build the linker
+ 2) generate some executable, and link it using -r (I would
+ probably use paranoia.o and link against newlib/libc.a, which
+ for all the supported targets would be available in
+ /usr/cygnus/progressive/H-host/target/lib/libc.a).
+ 3) make the change to reloc.c
+ 4) rebuild the linker
+ 5) repeat step 2
+ 6) if the resulting object files are the same, you have at least
+ made it no worse
+ 7) if they are different you have to figure out which version is
+ right
+*/
+ relocation -= reloc_entry->addend;
+#endif
+ reloc_entry->addend = 0;
+ }
+ else
+ {
+ reloc_entry->addend = relocation;
+ }
+ }
+ }
+ else
+ {
+ reloc_entry->addend = 0;
+ }
+
+ /* FIXME: This overflow checking is incomplete, because the value
+ might have overflowed before we get here. For a correct check we
+ need to compute the value in a size larger than bitsize, but we
+ can't reasonably do that for a reloc the same size as a host
+ machine word.
+ FIXME: We should also do overflow checking on the result after
+ adding in the value contained in the object file. */
+ if (howto->complain_on_overflow != complain_overflow_dont)
+ {
+ bfd_vma check;
+
+ /* Get the value that will be used for the relocation, but
+ starting at bit position zero. */
+ if (howto->rightshift > howto->bitpos)
+ check = relocation >> (howto->rightshift - howto->bitpos);
+ else
+ check = relocation << (howto->bitpos - howto->rightshift);
+ switch (howto->complain_on_overflow)
+ {
+ case complain_overflow_signed:
+ {
+ /* Assumes two's complement. */
+ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+ bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
+
+ /* The above right shift is incorrect for a signed value.
+ Fix it up by forcing on the upper bits. */
+ if (howto->rightshift > howto->bitpos
+ && (bfd_signed_vma) relocation < 0)
+ check |= ((bfd_vma) - 1
+ & ~((bfd_vma) - 1
+ >> (howto->rightshift - howto->bitpos)));
+ if ((bfd_signed_vma) check > reloc_signed_max
+ || (bfd_signed_vma) check < reloc_signed_min)
+ flag = bfd_reloc_overflow;
+ }
+ break;
+ case complain_overflow_unsigned:
+ {
+ /* Assumes two's complement. This expression avoids
+ overflow if howto->bitsize is the number of bits in
+ bfd_vma. */
+ bfd_vma reloc_unsigned_max =
+ (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
+
+ if ((bfd_vma) check > reloc_unsigned_max)
+ flag = bfd_reloc_overflow;
+ }
+ break;
+ case complain_overflow_bitfield:
+ {
+ /* Assumes two's complement. This expression avoids
+ overflow if howto->bitsize is the number of bits in
+ bfd_vma. */
+ bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
+
+ if (((bfd_vma) check & ~reloc_bits) != 0
+ && ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
+ {
+ /* The above right shift is incorrect for a signed
+ value. See if turning on the upper bits fixes the
+ overflow. */
+ if (howto->rightshift > howto->bitpos
+ && (bfd_signed_vma) relocation < 0)
+ {
+ check |= ((bfd_vma) - 1
+ & ~((bfd_vma) - 1
+ >> (howto->rightshift - howto->bitpos)));
+ if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
+ flag = bfd_reloc_overflow;
+ }
+ else
+ flag = bfd_reloc_overflow;
+ }
+ }
+ break;
+ default:
+ abort ();
+ }
+ }
+
+ /*
+ Either we are relocating all the way, or we don't want to apply
+ the relocation to the reloc entry (probably because there isn't
+ any room in the output format to describe addends to relocs)
+ */
+
+ /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
+ (OSF version 1.3, compiler version 3.11). It miscompiles the
+ following program:
+
+ struct str
+ {
+ unsigned int i0;
+ } s = { 0 };
+
+ int
+ main ()
+ {
+ unsigned long x;
+
+ x = 0x100000000;
+ x <<= (unsigned long) s.i0;
+ if (x == 0)
+ printf ("failed\n");
+ else
+ printf ("succeeded (%lx)\n", x);
+ }
+ */
+
+ relocation >>= (bfd_vma) howto->rightshift;
+
+ /* Shift everything up to where it's going to be used */
+
+ relocation <<= (bfd_vma) howto->bitpos;
+
+ /* Wait for the day when all have the mask in them */
+
+ /* What we do:
+ i instruction to be left alone
+ o offset within instruction
+ r relocation offset to apply
+ S src mask
+ D dst mask
+ N ~dst mask
+ A part 1
+ B part 2
+ R result
+
+ Do this:
+ i i i i i o o o o o from bfd_get<size>
+ and S S S S S to get the size offset we want
+ + r r r r r r r r r r to get the final value to place
+ and D D D D D to chop to right size
+ -----------------------
+ A A A A A
+ And this:
+ ... i i i i i o o o o o from bfd_get<size>
+ and N N N N N get instruction
+ -----------------------
+ ... B B B B B
+
+ And then:
+ B B B B B
+ or A A A A A
+ -----------------------
+ R R R R R R R R R R put into bfd_put<size>
+ */
+
+#define DOIT(x) \
+ x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = get_data (data, addr, 1);
+ DOIT (x);
+ overflow = put_data(x, data, addr, 1);
+ }
+ break;
+
+ case 1:
+ if (relocation)
+ {
+ short x = get_data (data, addr, 2);
+ DOIT (x);
+ overflow = put_data(x, (unsigned char *) data, addr, 2);
+ }
+ break;
+ case 2:
+ if (relocation)
+ {
+ long x = get_data (data, addr, 4);
+ DOIT (x);
+ overflow = put_data(x, data, addr, 4);
+ }
+ break;
+ case -2:
+ {
+ long x = get_data(data, addr, 4);
+ relocation = -relocation;
+ DOIT(x);
+ overflow = put_data(x, data , addr, 4);
+ }
+ break;
+
+ case 3:
+ /* Do nothing */
+ break;
+
+ case 4:
+#ifdef BFD64
+ if (relocation)
+ {
+ bfd_vma x = get_data (data, addr, 8);
+ DOIT (x);
+ overflow = put_data(x, data, addr, 8);
+ }
+#else
+ abort ();
+#endif
+ break;
+ default:
+ return bfd_reloc_other;
+ }
+ if ((howto->complain_on_overflow != complain_overflow_dont) && overflow)
+ return bfd_reloc_overflow;
+
+ return flag;
+}
+
+/* Relocate a given location using a given value and howto. */
+
+bfd_reloc_status_type
+_bfd_do_ns32k_reloc_contents ( howto, input_bfd, relocation, location,
+ get_data, put_data)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd_vma relocation;
+ bfd_byte *location;
+ long (*get_data)();
+ int (*put_data)();
+{
+ int size;
+ bfd_vma x;
+ boolean overflow;
+
+ /* If the size is negative, negate RELOCATION. This isn't very
+ general. */
+ if (howto->size < 0)
+ relocation = -relocation;
+
+ /* Get the value we are going to relocate. */
+ size = bfd_get_reloc_size (howto);
+ switch (size)
+ {
+ default:
+ case 0:
+ abort ();
+ case 1:
+ case 2:
+ case 4:
+#ifdef BFD64
+ case 8:
+#endif
+ x = get_data (location, 0, size);
+ break;
+ }
+
+ /* Check for overflow. FIXME: We may drop bits during the addition
+ which we don't check for. We must either check at every single
+ operation, which would be tedious, or we must do the computations
+ in a type larger than bfd_vma, which would be inefficient. */
+ overflow = false;
+ if (howto->complain_on_overflow != complain_overflow_dont)
+ {
+ bfd_vma check;
+ bfd_signed_vma signed_check;
+ bfd_vma add;
+ bfd_signed_vma signed_add;
+
+ if (howto->rightshift == 0)
+ {
+ check = relocation;
+ signed_check = (bfd_signed_vma) relocation;
+ }
+ else
+ {
+ /* Drop unwanted bits from the value we are relocating to. */
+ check = relocation >> howto->rightshift;
+
+ /* If this is a signed value, the rightshift just dropped
+ leading 1 bits (assuming twos complement). */
+ if ((bfd_signed_vma) relocation >= 0)
+ signed_check = check;
+ else
+ signed_check = (check
+ | ((bfd_vma) - 1
+ & ~((bfd_vma) - 1 >> howto->rightshift)));
+ }
+
+ /* Get the value from the object file. */
+ add = x & howto->src_mask;
+
+ /* Get the value from the object file with an appropriate sign.
+ The expression involving howto->src_mask isolates the upper
+ bit of src_mask. If that bit is set in the value we are
+ adding, it is negative, and we subtract out that number times
+ two. If src_mask includes the highest possible bit, then we
+ can not get the upper bit, but that does not matter since
+ signed_add needs no adjustment to become negative in that
+ case. */
+ signed_add = add;
+ if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
+ signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
+
+ /* Add the value from the object file, shifted so that it is a
+ straight number. */
+ if (howto->bitpos == 0)
+ {
+ check += add;
+ signed_check += signed_add;
+ }
+ else
+ {
+ check += add >> howto->bitpos;
+
+ /* For the signed case we use ADD, rather than SIGNED_ADD,
+ to avoid warnings from SVR4 cc. This is OK since we
+ explictly handle the sign bits. */
+ if (signed_add >= 0)
+ signed_check += add >> howto->bitpos;
+ else
+ signed_check += ((add >> howto->bitpos)
+ | ((bfd_vma) - 1
+ & ~((bfd_vma) - 1 >> howto->bitpos)));
+ }
+
+ switch (howto->complain_on_overflow)
+ {
+ case complain_overflow_signed:
+ {
+ /* Assumes two's complement. */
+ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+ bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
+
+ if (signed_check > reloc_signed_max
+ || signed_check < reloc_signed_min)
+ overflow = true;
+ }
+ break;
+ case complain_overflow_unsigned:
+ {
+ /* Assumes two's complement. This expression avoids
+ overflow if howto->bitsize is the number of bits in
+ bfd_vma. */
+ bfd_vma reloc_unsigned_max =
+ (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
+
+ if (check > reloc_unsigned_max)
+ overflow = true;
+ }
+ break;
+ case complain_overflow_bitfield:
+ {
+ /* Assumes two's complement. This expression avoids
+ overflow if howto->bitsize is the number of bits in
+ bfd_vma. */
+ bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
+
+ if ((check & ~reloc_bits) != 0
+ && (((bfd_vma) signed_check & ~reloc_bits)
+ != (-1 & ~reloc_bits)))
+ overflow = true;
+ }
+ break;
+ default:
+ abort ();
+ }
+ }
+
+ /* Put RELOCATION in the right bits. */
+ relocation >>= (bfd_vma) howto->rightshift;
+ relocation <<= (bfd_vma) howto->bitpos;
+
+ /* Add RELOCATION to the right bits of X. */
+ x = ((x & ~howto->dst_mask)
+ | (((x & howto->src_mask) + relocation) & howto->dst_mask));
+
+ /* Put the relocated value back in the object file. */
+ switch (size)
+ {
+ default:
+ case 0:
+ abort ();
+ case 1:
+ case 2:
+ case 4:
+#ifdef BFD64
+ case 8:
+#endif
+ put_data(x, location, 0, size);
+ break;
+ }
+
+ return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
+}
+
+bfd_reloc_status_type
+_bfd_ns32k_reloc_disp (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message,
+ _bfd_ns32k_get_displacement,
+ _bfd_ns32k_put_displacement);
+}
+
+bfd_reloc_status_type
+_bfd_ns32k_reloc_imm (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message, _bfd_ns32k_get_immediate,
+ _bfd_ns32k_put_immediate);
+}
+
+bfd_reloc_status_type
+_bfd_ns32k_final_link_relocate (howto, input_bfd, input_section, contents,
+ address, value, addend)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ bfd_vma address;
+ bfd_vma value;
+ bfd_vma addend;
+{
+ bfd_vma relocation;
+
+ /* Sanity check the address. */
+ if (address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* This function assumes that we are dealing with a basic relocation
+ against a symbol. We want to compute the value of the symbol to
+ relocate to. This is just VALUE, the value of the symbol, plus
+ ADDEND, any addend associated with the reloc. */
+ relocation = value + addend;
+
+ /* If the relocation is PC relative, we want to set RELOCATION to
+ the distance between the symbol (currently in RELOCATION) and the
+ location we are relocating. Some targets (e.g., i386-aout)
+ arrange for the contents of the section to be the negative of the
+ offset of the location within the section; for such targets
+ pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
+ simply leave the contents of the section as zero; for such
+ targets pcrel_offset is true. If pcrel_offset is false we do not
+ need to subtract out the offset of the location within the
+ section (which is just ADDRESS). */
+ if (howto->pc_relative)
+ {
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ if (howto->pcrel_offset)
+ relocation -= address;
+ }
+
+ return _bfd_ns32k_relocate_contents (howto, input_bfd, relocation,
+ contents + address);
+}
diff --git a/bfd/cpu-powerpc.c b/bfd/cpu-powerpc.c
new file mode 100644
index 00000000000..11f0f80af5a
--- /dev/null
+++ b/bfd/cpu-powerpc.c
@@ -0,0 +1,124 @@
+/* BFD PowerPC CPU definition
+ Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+ Contributed 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/* The common PowerPC architecture is compatible with the RS/6000. */
+
+static const bfd_arch_info_type *powerpc_compatible
+ PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+
+static const bfd_arch_info_type *
+powerpc_compatible (a,b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ BFD_ASSERT (a->arch == bfd_arch_powerpc);
+ switch (b->arch)
+ {
+ default:
+ return NULL;
+ case bfd_arch_powerpc:
+ return bfd_default_compatible (a, b);
+ case bfd_arch_rs6000:
+ if (a->mach == 0)
+ return a;
+ return NULL;
+ }
+ /*NOTREACHED*/
+}
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_powerpc,
+ 603, /* for the mpc603 */
+ "powerpc",
+ "powerpc:603",
+ 3,
+ false, /* not the default */
+ powerpc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[1]
+ },
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_powerpc,
+ 604, /* for the mpc604 */
+ "powerpc",
+ "powerpc:604",
+ 3,
+ false, /* not the default */
+ powerpc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[2]
+ },
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_powerpc,
+ 403, /* for the 403 */
+ "powerpc",
+ "powerpc:403",
+ 3,
+ false, /* not the default */
+ powerpc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[3]
+ },
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_powerpc,
+ 601, /* for the mpc601 */
+ "powerpc",
+ "powerpc:601",
+ 3,
+ false, /* not the default */
+ powerpc_compatible,
+ bfd_default_scan,
+ 0
+ }
+};
+
+const bfd_arch_info_type bfd_powerpc_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_powerpc,
+ 0, /* for the POWER/PowerPC common architecture */
+ "powerpc",
+ "powerpc:common",
+ 3,
+ true, /* the default */
+ powerpc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[0]
+ };
diff --git a/bfd/cpu-rs6000.c b/bfd/cpu-rs6000.c
new file mode 100644
index 00000000000..9852ae9a053
--- /dev/null
+++ b/bfd/cpu-rs6000.c
@@ -0,0 +1,70 @@
+/* BFD back-end for rs6000 support
+ Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ FIXME: Can someone provide a transliteration of this name into ASCII?
+ Using the following chars caused a compiler warning on HIUX (so I replaced
+ them with octal escapes), and isn't useful without an understanding of what
+ character set it is.
+ Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM
+ and John Gilmore of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/* The RS/6000 architecture is compatible with the PowerPC common
+ architecture. */
+
+static const bfd_arch_info_type *rs6000_compatible
+ PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+
+static const bfd_arch_info_type *
+rs6000_compatible (a,b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ BFD_ASSERT (a->arch == bfd_arch_rs6000);
+ switch (b->arch)
+ {
+ default:
+ return NULL;
+ case bfd_arch_rs6000:
+ return bfd_default_compatible (a, b);
+ case bfd_arch_powerpc:
+ if (b->mach == 0)
+ return b;
+ return NULL;
+ }
+ /*NOTREACHED*/
+}
+
+const bfd_arch_info_type bfd_rs6000_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_rs6000,
+ 6000, /* only 1 machine */
+ "rs6000",
+ "rs6000:6000",
+ 3,
+ true, /* the one and only */
+ rs6000_compatible,
+ bfd_default_scan,
+ 0,
+ };
diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c
new file mode 100644
index 00000000000..44adf9217ff
--- /dev/null
+++ b/bfd/cpu-sh.c
@@ -0,0 +1,102 @@
+/* BFD library support routines for the Hitachi-SH architecture.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+
+static boolean
+scan_mach (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ if (strcasecmp (info->printable_name, string) == 0)
+ return true;
+ return false;
+}
+
+
+#if 0
+/* This routine is provided two arch_infos and returns whether
+ they'd be compatible */
+
+static const bfd_arch_info_type *
+compatible (a,b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ if (a->arch != b->arch || a->mach != b->mach)
+ return NULL;
+ return a;
+}
+#endif
+
+#define SH_NEXT &arch_info_struct[0]
+#define SH3_NEXT &arch_info_struct[1]
+#define SH3E_NEXT NULL
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_sh,
+ bfd_mach_sh3,
+ "sh", /* arch_name */
+ "sh3", /* printable name */
+ 1,
+ false, /* not the default */
+ bfd_default_compatible,
+ scan_mach,
+ SH3_NEXT
+ },
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_sh,
+ bfd_mach_sh3e,
+ "sh", /* arch_name */
+ "sh3e", /* printable name */
+ 1,
+ false, /* not the default */
+ bfd_default_compatible,
+ scan_mach,
+ SH3E_NEXT
+ },
+};
+
+const bfd_arch_info_type bfd_sh_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_sh,
+ bfd_mach_sh,
+ "sh", /* arch_name */
+ "sh", /* printable name */
+ 1,
+ true, /* the default machine */
+ bfd_default_compatible,
+ scan_mach,
+ SH_NEXT
+};
diff --git a/bfd/cpu-sparc.c b/bfd/cpu-sparc.c
new file mode 100644
index 00000000000..234bd92bd29
--- /dev/null
+++ b/bfd/cpu-sparc.c
@@ -0,0 +1,156 @@
+/* BFD support for the SPARC architecture.
+ Copyright (C) 1992, 94, 95, 96, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/* Don't mix 32 bit and 64 bit files. */
+
+static const bfd_arch_info_type *sparc_compatible
+ PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+
+static const bfd_arch_info_type *
+sparc_compatible (a, b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ if (a->bits_per_word != b->bits_per_word)
+ return NULL;
+
+ return bfd_default_compatible (a, b);
+}
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ {
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_sparclet,
+ "sparc",
+ "sparc:sparclet",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[1],
+ },
+ {
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_sparclite,
+ "sparc",
+ "sparc:sparclite",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[2],
+ },
+ {
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_v8plus,
+ "sparc",
+ "sparc:v8plus",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[3],
+ },
+ {
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_v8plusa,
+ "sparc",
+ "sparc:v8plusa",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[4],
+ },
+ {
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_sparclite_le,
+ "sparc",
+ "sparc:sparclite_le",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[5],
+ },
+ {
+ 64, /* bits in a word */
+ 64, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_v9,
+ "sparc",
+ "sparc:v9",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[6],
+ },
+ {
+ 64, /* bits in a word */
+ 64, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc_v9a,
+ "sparc",
+ "sparc:v9a",
+ 3,
+ false,
+ sparc_compatible,
+ bfd_default_scan,
+ 0,
+ }
+};
+
+const bfd_arch_info_type bfd_sparc_arch =
+ {
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_sparc,
+ bfd_mach_sparc,
+ "sparc",
+ "sparc",
+ 3,
+ true, /* the default */
+ sparc_compatible,
+ bfd_default_scan,
+ &arch_info_struct[0],
+ };
diff --git a/bfd/cpu-tic30.c b/bfd/cpu-tic30.c
new file mode 100644
index 00000000000..dd723f7b4a5
--- /dev/null
+++ b/bfd/cpu-tic30.c
@@ -0,0 +1,39 @@
+/* BFD support for the Texas Instruments TMS320C30 architecture.
+ Copyright 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_tic30_arch =
+{
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_tic30,
+ 0, /* only 1 machine */
+ "tic30",
+ "tms320c30",
+ 2,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan,
+ 0,
+};
diff --git a/bfd/cpu-tic80.c b/bfd/cpu-tic80.c
new file mode 100644
index 00000000000..302866ece9d
--- /dev/null
+++ b/bfd/cpu-tic80.c
@@ -0,0 +1,39 @@
+/* bfd back-end for TI TMS320C80 (MVP) support
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ Written by Fred Fish at Cygnus support (fnf@cygnus.com)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_tic80_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_tic80, /* bfd_architecture enum */
+ 0, /* only 1 machine */
+ "tic80", /* architecture name */
+ "tic80", /* printable name */
+ 2, /* section alignment power */
+ true, /* default machine for architecture */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ NULL, /* Pointer to next in chain */
+ };
diff --git a/bfd/cpu-v850.c b/bfd/cpu-v850.c
new file mode 100644
index 00000000000..539413de022
--- /dev/null
+++ b/bfd/cpu-v850.c
@@ -0,0 +1,103 @@
+/* BFD support for the NEC V850 processor
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include <ctype.h>
+
+static boolean
+scan (info, string)
+ const struct bfd_arch_info * info;
+ const char * string;
+{
+ const char *ptr_src;
+ const char *ptr_tst;
+ unsigned long number;
+ enum bfd_architecture arch;
+
+ /* First test for an exact match */
+ if (strcasecmp (string, info->printable_name) == 0)
+ return true;
+
+ /* See how much of the supplied string matches with the
+ architecture, eg the string m68k:68020 would match the m68k entry
+ up to the :, then we get left with the machine number */
+
+ for (ptr_src = string, ptr_tst = info->arch_name;
+ *ptr_src && *ptr_tst;
+ ptr_src++, ptr_tst++)
+ {
+ if (*ptr_src != *ptr_tst) break;
+ }
+
+ /* Chewed up as much of the architecture as will match, skip any
+ colons */
+ if (*ptr_src == ':')
+ ptr_src++;
+
+ if (*ptr_src == 0)
+ {
+ /* nothing more, then only keep this one if it is the default
+ machine for this architecture */
+ return info->the_default;
+ }
+
+ number = 0;
+ while (isdigit ((unsigned char) *ptr_src))
+ {
+ number = number * 10 + * ptr_src - '0';
+ ptr_src++;
+ }
+
+ switch (number)
+ {
+ case bfd_mach_v850e: arch = bfd_arch_v850; break;
+ case bfd_mach_v850ea: arch = bfd_arch_v850; break;
+ default:
+ return false;
+ }
+
+ if (arch != info->arch)
+ return false;
+
+ if (number != info->mach)
+ return false;
+
+ return true;
+}
+
+#define N(number, print, default, next) \
+{ 32, 32, 8, bfd_arch_v850, number, "v850", print, 2, default, \
+ bfd_default_compatible, scan, next }
+
+#define NEXT NULL
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N (bfd_mach_v850e, "v850e", false, &arch_info_struct[1]),
+ N (bfd_mach_v850ea, "v850ea", false, NULL)
+};
+
+#undef NEXT
+#define NEXT &arch_info_struct[0]
+
+const bfd_arch_info_type bfd_v850_arch =
+ N (bfd_mach_v850, "v850", true, NEXT);
diff --git a/bfd/cpu-vax.c b/bfd/cpu-vax.c
new file mode 100644
index 00000000000..bdc6d39e451
--- /dev/null
+++ b/bfd/cpu-vax.c
@@ -0,0 +1,39 @@
+/* bfd back-end for vax support
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_vax_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_vax,
+ 0, /* only 1 machine */
+ "vax",
+ "vax",
+ 3,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+ };
diff --git a/bfd/cpu-w65.c b/bfd/cpu-w65.c
new file mode 100644
index 00000000000..c0bbf045219
--- /dev/null
+++ b/bfd/cpu-w65.c
@@ -0,0 +1,54 @@
+/* BFD library support routines for the WDC 65816 architecture.
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of 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 publiw65ed by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You w65ould have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+
+int bfd_default_scan_num_mach();
+
+static boolean
+scan_mach (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ if (strcmp(string,"w65") == 0) return true;
+ if (strcmp(string,"w65816") == 0) return true;
+ return false;
+}
+
+
+
+const bfd_arch_info_type bfd_w65_arch =
+{
+ 16, /* 16 bits in a word */
+ 24, /* 24 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_w65,
+ 0, /* only 1 machine */
+ "w65", /* arch_name */
+ "w65", /* printable name */
+ 1,
+ true, /* the default machine */
+ bfd_default_compatible,
+ scan_mach,
+ 0,
+};
diff --git a/bfd/cpu-we32k.c b/bfd/cpu-we32k.c
new file mode 100644
index 00000000000..a38cbc1268b
--- /dev/null
+++ b/bfd/cpu-we32k.c
@@ -0,0 +1,39 @@
+/* bfd back-end for we32k support
+ Copyright (C) 1992 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cs.widener.edu).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_we32k_arch =
+ {
+ 32, /* 32 bits in a word */
+ 32, /* 32 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_we32k,
+ 32000, /* only 1 machine */
+ "we32k",
+ "we32k:32000",
+ 3,
+ true, /* the one and only */
+ bfd_default_compatible,
+ bfd_default_scan ,
+ 0,
+ };
diff --git a/bfd/cpu-z8k.c b/bfd/cpu-z8k.c
new file mode 100644
index 00000000000..5cce8eb0689
--- /dev/null
+++ b/bfd/cpu-z8k.c
@@ -0,0 +1,198 @@
+/* BFD library support routines for the Z800n architecture.
+ Copyright (C) 1992 Free Software Foundation, Inc.
+ Hacked by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+
+#if 0 /* not used currently */
+/*
+Relocations for the Z8K
+
+*/
+static bfd_reloc_status_type
+howto16_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+ long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
+
+ HOWTO_PREPARE (relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
+ return bfd_reloc_ok;
+}
+
+
+static bfd_reloc_status_type
+howto8_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+ long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
+
+ HOWTO_PREPARE (relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
+ return bfd_reloc_ok;
+}
+
+
+static bfd_reloc_status_type
+howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+
+ long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
+ abort ();
+ HOWTO_PREPARE (relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
+ ignore_input_section, ignore_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol_in;
+ PTR data;
+ asection *ignore_input_section;
+ bfd *ignore_bfd;
+{
+ long relocation = 0;
+ bfd_vma addr = reloc_entry->address;
+ long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
+ abort ();
+ HOWTO_PREPARE (relocation, symbol_in);
+
+ x = (x + relocation + reloc_entry->addend);
+
+ bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
+ return bfd_reloc_ok;
+}
+
+
+
+static reloc_howto_type howto_16
+= NEWHOWTO (howto16_callback, "abs16", 1, false, false);
+static reloc_howto_type howto_8
+= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
+
+static reloc_howto_type howto_8_FFnn
+= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
+
+static reloc_howto_type howto_8_pcrel
+= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
+
+
+static reloc_howto_type *
+local_bfd_reloc_type_lookup (arch, code)
+ const struct bfd_arch_info *arch;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_16:
+ return &howto_16;
+ case BFD_RELOC_8_FFnn:
+ return &howto_8_FFnn;
+ case BFD_RELOC_8:
+ return &howto_8;
+ case BFD_RELOC_8_PCREL:
+ return &howto_8_pcrel;
+ default:
+ return (reloc_howto_type *) NULL;
+ }
+}
+#endif
+
+int bfd_default_scan_num_mach ();
+
+static boolean
+scan_mach (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ if (strcmp (string, "z8001") == 0 || strcmp (string, "z8k") == 0)
+ {
+ return bfd_mach_z8001 == info->mach;
+ }
+ if (strcmp (string, "z8002") == 0)
+ {
+ return bfd_mach_z8002 == info->mach;
+ }
+ return false;
+}
+
+
+/* This routine is provided two arch_infos and returns whether
+ they'd be compatible */
+
+static const bfd_arch_info_type *
+compatible (a, b)
+ const bfd_arch_info_type *a;
+ const bfd_arch_info_type *b;
+{
+ if (a->arch != b->arch || a->mach != b->mach)
+ return NULL;
+ return a;
+}
+
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ {32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, false, compatible, scan_mach, 0,},
+};
+
+const bfd_arch_info_type bfd_z8k_arch =
+{
+ 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, true, compatible, scan_mach, &arch_info_struct[0],
+};
diff --git a/bfd/demo64.c b/bfd/demo64.c
new file mode 100644
index 00000000000..c91381d46e9
--- /dev/null
+++ b/bfd/demo64.c
@@ -0,0 +1,24 @@
+/* BFD backend for demonstration 64-bit a.out binaries.
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 64
+#define MY(OP) CAT(demo_64_,OP)
+#define TARGETNAME "demo64"
+#include "aoutf1.h"
diff --git a/bfd/dep-in.sed b/bfd/dep-in.sed
new file mode 100644
index 00000000000..444dde0c019
--- /dev/null
+++ b/bfd/dep-in.sed
@@ -0,0 +1,26 @@
+:loop
+/\\$/N
+s/\\\n */ /g
+t loop
+
+s!\.o:!.lo:!
+s! @BFD_H@!!g
+s!@INCDIR@!$(INCDIR)!g
+s!@SRCDIR@/!!g
+s!hosts/[^ ]*\.h ! !g
+s/ sysdep.h//g
+s! \.\./bfd/sysdep.h!!g
+s/ libbfd.h//g
+s/ config.h//g
+s! \$(INCDIR)/fopen-[^ ]*\.h!!g
+s! \$(INCDIR)/ansidecl\.h!!g
+
+s/\\\n */ /g
+
+s/ *$//
+s/ */ /g
+s/ *:/:/g
+/:$/d
+
+s/\(.\{50\}[^ ]*\) /\1 \\\
+ /g
diff --git a/bfd/doc/ChangeLog b/bfd/doc/ChangeLog
new file mode 100644
index 00000000000..9e8207ac570
--- /dev/null
+++ b/bfd/doc/ChangeLog
@@ -0,0 +1,390 @@
+Thu Feb 4 23:21:36 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Rebuild with current autoconf/automake.
+
+Thu Jul 23 09:36:44 1998 Nick Clifton <nickc@cygnus.com>
+
+ * bfdint.texi (BFD ELF processor required): Add paragraph
+ describing the necessity to create "include/elf/CPU.h".
+
+Thu May 7 14:45:43 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (chew.o): Add -I options for intl srcdir and
+ objdir.
+ * Makefile.in: Rebuild.
+
+Mon Apr 27 20:19:24 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdint.texi: New file.
+ * Makefile.am (noinst_TEXINFOS): New variable.
+ * Makefile.in: Rebuild.
+
+Mon Apr 13 16:48:56 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Rebuild.
+
+Mon Apr 6 14:06:55 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (STAGESTUFF): Remove variable.
+ (CLEANFILES): Don't remove $(STAGESTUFF).
+ (DISTCLEANFILES, MAINTAINERCLEANFILES): New variables.
+ * Makefile.in: Rebuild.
+
+Fri Mar 27 16:25:25 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * chew.c (skip_white_and_starts): Remove unused declaration.
+ (skip_white_and_stars): Add casts to avoid warnings.
+ (skip_trailing_newlines, paramstuff, courierize): Likewise.
+ (bulletize, do_fancy_stuff, iscommand): Likewise.
+ (kill_bogus_lines, nextword, main): Likewise.
+ (manglecomments): Comment out.
+ (outputdots, kill_bogus_lines): Remove unused local variables.
+ (perform, compile): Likewise.
+ (courierize): Fully parenthesize expression.
+ (copy_past_newline): Declare return value.
+ (print): Change printf format string.
+ (main): Call usage for an unrecognized option.
+
+Fri Feb 13 14:37:14 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (AUTOMAKE_OPTIONS): Define.
+ * Makefile.in: Rebuild.
+
+Mon Jan 26 15:38:36 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * doc.str (bodytext): Don't output @* at the end.
+ * chew.c (kill_bogus_lines): Make sure that a period at the
+ beginning is recognized.
+ (indent): Don't put indentation at the end.
+ (copy_past_newline): Expand tabs.
+ * Makefile.am (s-reloc, s-syms): Depend on doc.str.
+ * Makefile.in: Rebuild.
+
+Wed Oct 1 14:41:28 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (libbfd.h): Don't use cpu-h8300.c, cpu-i960.c, or
+ elfcode.h as input files; they don't contribute anything.
+ * Makefile.in: Rebuild.
+
+Fri Aug 15 04:55:15 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.am (libbfd.h, libcoff.h): Invoke $(MKDOC) as ./$(MKDOC).
+ * Makefile.in: Rebuild.
+
+Fri Aug 1 12:59:58 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (CC_FOR_BUILD): Don't set explicitly.
+ * Makefile.in: Rebuild.
+
+Thu Jul 31 20:00:12 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: New file, based on old Makefile.in.
+ * Makefile.in: Now built with automake.
+
+Tue Jul 22 14:44:00 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
+
+ * Makefile.in: Change stamp-* files to s-* files. Use bfdt.texi
+ rather than bfd.texi.
+ (DOCFILES): Change bfd.texi to bfdt.texi.
+ * bfd.texinfo: Include bfdt.texi, not bfd.texi.
+
+Mon Jun 16 15:33:15 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (CC, CFLAGS): Substitute from configure script.
+ From Jeff Makey <jeff@cts.com>.
+
+Tue Apr 15 12:37:41 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (install-info): Use mkinstalldirs to build
+ $(infodir).
+
+Tue Apr 8 12:49:46 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (install-info): Permit info files to be in srcdir.
+ (stamp-*): Add a stamp-X target for each X.texi target.
+ (*.texi): Just depend upon stamp-X.
+ (clean): Remove stamp-*.
+ (distclean): Depend upon mostlyclean. Remove stamp-*. Don't
+ remove $(DOCFILES).
+
+Mon Apr 7 15:23:26 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (distclean): Don't remove *.info files.
+
+Thu Feb 13 20:50:02 1997 Klaus Kaempf (kkaempf@progis.de)
+
+ * makefile.vms: New file.
+
+Tue Jun 18 18:32:28 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * chew.c (kill_bogus_lines): Reset sl when not at the start of a
+ line. From Uwe Ohse <uwe@tirka.gun.de>.
+
+Tue Jan 30 14:10:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ From Ronald F. Guilmette <rfg@monkeys.com>:
+ * Makefile.in (libbfd.h): Depend upon proto.str.
+ (libcoff.h, bfd.h): Likewise.
+
+Fri Nov 3 14:46:48 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (SRCDOC, SRCPROT, core.texi, bfd.h): Use corefile.c,
+ renamed from core.c.
+
+Wed Nov 1 14:28:23 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de>
+
+ * chew.c: Include <ctype.h>.
+
+Fri Oct 6 16:23:34 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makefile.in (Makefile): Only remake this Makefile.
+
+Wed Oct 4 15:51:05 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * chew.c: Include <stdio.h>.
+
+Tue Sep 12 18:14:50 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (maintainer-clean): New target.
+
+Thu Aug 31 12:18:43 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (bfd.h): Add additional #endif at end of bfd.h if
+ __cplusplus is defined.
+
+Tue Nov 29 16:13:34 1994 Doug Evans <dje@canuck.cygnus.com>
+
+ * chew.c (write_buffer): New argument `f', all callers changed.
+ (stdout, stderr, print, drop, idrop): New forth words.
+ * proto.str (COMMENT): New command.
+ * doc.str (COMMENT): Likewise.
+
+Mon Sep 12 11:44:17 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * Makefile.in (DOCFILES): Remove ctor.texi.
+ (IPROTOS): Remove ctor.ip.
+ (SRCIPROT): Remove $(srcdir)/../ctor.c.
+ (ctor.texi): Remove target.
+ (libbfd.h): Remove dependency on $(srcdir)/../ctor.c. Remove
+ $(MKDOC) run on $(srcdir)/../ctor.c.
+ * bfd.texinfo (Constructors): Remove section.
+
+Fri Sep 2 13:33:44 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * chew.c: Include assert.h. Added prototypes for most functions.
+ Changed most uses of int to long. Do bounds checking on the
+ stacks. Added comment at the beginning documenting most of the
+ intrinsics. Lots of whitespace changes. Re-ordered some
+ functions.
+ (die, check_range, icheck_range): New functions.
+ (strip_trailing_newlines, print_stack_level): New functions.
+ (translatecomments): Don't insert tab before "/*".
+ (iscommand): Minimum command length is now 4.
+ (nextword): Handle some \-sequences.
+ (push_addr): Deleted.
+ (main): Add new intrinsics strip_trailing_newlines and
+ print_stack_level. Complain at end if stack contains more than
+ one element, or less.
+ (remchar): Make sure the string is not empty before chopping off a
+ character.
+
+ * doc.str, proto.str: Handle new commands SENUM, ENUM, ENUMX,
+ ENUMEQ, ENUMEQX, ENUMDOC.
+
+Wed Jan 12 18:37:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.texinfo: Added Linker Functions node.
+ * doc/Makefile.in (DOCFILES): Added linker.texi.
+ (SRCDOC): Added linker.c.
+ (linker.texi): New target.
+
+Tue Jan 4 10:52:56 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * chew.c: Don't rely on a correct declaration of exit.
+ (chew_exit): New function which just calls exit.
+ (main): Use it.
+
+Mon Jan 3 11:40:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.texinfo: Added Hash Tables node.
+ * Makefile.in (DOCFILES): Added hash.texi.
+ (SRCDOC): Added hash.c.
+ (hash.texi): New target.
+
+Thu Dec 30 16:57:04 1993 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * Makefile.in: Delete all references to seclet.c, since it's just
+ been deleted. Don't mention hash.c, linker.c, or genlink.h yet,
+ since they don't contain documentation yet (hint, hint!).
+
+Fri Nov 5 10:58:53 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * bfd.texinfo: Small cleanups.
+
+Fri Nov 19 03:46:11 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (archures.texi): Depends on $(MKDOC).
+
+Tue Aug 10 14:22:39 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * bfd.texinfo (BFD back end): Don't include elfcode.texi, since
+ it's empty now and that triggers a makeinfo bug.
+
+Mon Aug 9 16:27:30 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * bfd.texinfo (BFD back end): New section on ELF, includes
+ elf.texi and elfcode.texi.
+ * Makefile.in (DOCFILES): Include elf.texi, elfcode.texi.
+ (SRCDOC): Include elfcode.h, elf.c.
+ (elf.texi, elfcode.texi): New intermediate targets.
+
+Thu Jun 24 13:48:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * Makefile.in (.c.o, chew.o): Put CFLAGS last.
+ * bfdsumm.texi: New file, broken out of bfd.texinfo, to share
+ with ld.texinfo.
+
+Mon Jun 14 12:07:07 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
+
+ * Makefile.in (install-info): remove parentdir cruft,
+
+Wed Jun 9 16:00:32 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * Makefile.in (mostlyclean): Remove chew.o.
+
+Tue May 25 14:46:58 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (libbfd.h): Use elfcode.h, not elf32.c.
+
+Mon May 24 15:50:07 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * chew.c (compile): Add a couple of missing casts.
+
+Wed May 12 14:45:14 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (CC_FOR_BUILD): New variable, define to be $(CC).
+ (chew.o, $(MKDOC)): Build using CC_FOR_BUILD rather than CC, since
+ it must run on the build machine.
+
+Tue Apr 6 22:38:10 1993 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (chew): Don't compile from .c to executable in a
+ single step; it puts a temporary .o filename into the executable,
+ which makes multi-stage comparisons fail. Compile chew.c to
+ chew.o, and link that, which makes identical executables every time.
+
+Wed Mar 24 17:26:29 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
+
+ * Makefile.in: fix typo (bfd.texinfo not bfd.texino)
+
+Fri Mar 19 01:13:00 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * bfd.texinfo: Since BFD version number has been bumped, do same
+ to "version number" on title page, and elsewhere. Should be
+ fixed to extract real version number.
+
+Tue Mar 16 12:15:13 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in: Add *clean rules.
+
+Mon Jan 11 18:43:56 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Makefile.in (libbfd.h): Removed duplicate init.c and libbfd.c.
+ Added seclet.c.
+ (bfd.h): Added dependency on bfd.c and seclet.c. Added seclet.c
+ to build.
+
+Thu Dec 17 19:35:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: added dvi target, define and use $(TEXI2DVI)
+
+Thu Dec 3 17:42:48 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (TEXIDIR): New variable.
+ (bfd.dvi): Look for bfd.texinfo in $(srcdir). Generate index.
+
+ * bfd.texinfo: Minor doc fixes.
+
+Thu Nov 5 03:13:55 1992 John Gilmore (gnu@cygnus.com)
+
+ Cleanup: Replace all uses of EXFUN in the BFD sources, with PARAMS.
+
+ * doc/chew.c (exfunstuff): Eliminate.
+ (paramstuff): Replace exfunstuff with function to generate PARAMS.
+ * doc/proto.str: Use paramstuff rather than exfunstuff.
+
+Mon Aug 17 12:40:32 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * chew.c: various patches provided by Howard Chu.
+
+Fri Jun 19 18:59:54 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in (libbfd.h): Add elf.c as a source of prototypes.
+
+Mon May 11 18:55:59 1992 John Gilmore (gnu at cygnus.com)
+
+ * chew.c: exit() should be declared by config files, not by
+ portable source code. Its type could be int or void function.
+
+Mon May 4 13:45:57 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: another CFLAGS correction.
+
+Tue Apr 28 10:21:32 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * Makefile.in: Do the CFLAGS thing.
+
+Fri Apr 10 22:34:52 1992 Fred Fish (fnf@cygnus.com)
+
+ * Makefile.in (MINUS_G): Add macro and default to -g.
+
+Fri Mar 6 18:53:18 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * chew.c: now has -w switch turn on warnings
+
+Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in, configure.in: removed traces of namesubdir,
+ -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
+ copyrights to '92, changed some from Cygnus to FSF.
+
+Tue Dec 10 22:11:05 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: build chew into the current directory. Complete
+ the MKDOC macro transition.
+
+Tue Dec 10 08:26:28 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * chew.c: don't core dump when can't open file
+ * Makefile.in: get proto.str from the right place when built in
+ odd directories
+
+Tue Dec 10 04:07:25 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: infodir belongs in datadir.
+
+Sat Dec 7 17:01:23 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * chew.c: Much modified
+ * proto.str, doc.str: New files for extracting to product
+ prototypes and documents respectively.
+
+
+Fri Dec 6 22:57:12 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: added standards.text support, host/site/target
+ inclusion hooks, install using INSTALL_DATA rather than cp,
+ don't echo on install.
+
+Thu Dec 5 22:46:17 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: idestdir and ddestdir go away. Added copyrights
+ and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
+ and mandir now keyed off datadir by default.
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/bfd/doc/Makefile.am b/bfd/doc/Makefile.am
new file mode 100644
index 00000000000..0d5268e9608
--- /dev/null
+++ b/bfd/doc/Makefile.am
@@ -0,0 +1,250 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+DOCFILES = aoutx.texi archive.texi archures.texi \
+ bfdt.texi cache.texi coffcode.texi \
+ core.texi elf.texi elfcode.texi format.texi libbfd.texi \
+ opncls.texi reloc.texi section.texi \
+ syms.texi targets.texi init.texi hash.texi linker.texi
+
+PROTOS = archive.p archures.p bfd.p \
+ core.p format.p \
+ libbfd.p opncls.p reloc.p \
+ section.p syms.p targets.p \
+ format.p core.p init.p
+
+IPROTOS = cache.ip libbfd.ip reloc.ip init.ip archures.ip coffcode.ip
+
+# SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction
+# between VPATH and suffix rules. If you use GNU Make, perhaps other Makes,
+# you don't need these three:
+SRCDOC = $(srcdir)/../aoutx.h $(srcdir)/../archive.c \
+ $(srcdir)/../archures.c $(srcdir)/../bfd.c \
+ $(srcdir)/../cache.c $(srcdir)/../coffcode.h \
+ $(srcdir)/../corefile.c $(srcdir)/../elf.c \
+ $(srcdir)/../elfcode.h $(srcdir)/../format.c \
+ $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \
+ $(srcdir)/../reloc.c $(srcdir)/../section.c \
+ $(srcdir)/../syms.c $(srcdir)/../targets.c \
+ $(srcdir)/../hash.c $(srcdir)/../linker.c
+
+SRCPROT = $(srcdir)/../archive.c $(srcdir)/../archures.c \
+ $(srcdir)/../bfd.c $(srcdir)/../coffcode.h $(srcdir)/../corefile.c \
+ $(srcdir)/../format.c $(srcdir)/../libbfd.c \
+ $(srcdir)/../opncls.c $(srcdir)/../reloc.c \
+ $(srcdir)/../section.c $(srcdir)/../syms.c \
+ $(srcdir)/../targets.c $(srcdir)/../init.c
+
+SRCIPROT = $(srcdir)/../cache.c $(srcdir)/../libbfd.c \
+ $(srcdir)/../reloc.c $(srcdir)/../cpu-h8300.c \
+ $(srcdir)/../cpu-i960.c $(srcdir)/../archures.c \
+ $(srcdir)/../init.c
+
+TEXIDIR = $(srcdir)/../../texinfo/fsf
+
+info_TEXINFOS = bfd.texinfo
+
+MKDOC = chew$(EXEEXT_FOR_BUILD)
+
+$(MKDOC): chew.o
+ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(LOADLIBES) $(LDFLAGS)
+
+chew.o: chew.c
+ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
+
+protos: libbfd.h libcoff.h bfd.h
+
+bfd.info bfd.dvi: $(DOCFILES) bfdsumm.texi bfd.texinfo
+
+# We can't replace these rules with an implicit rule, because
+# makes without VPATH support couldn't find the .h files in `..'.
+
+# We use s-XXX targets so that we can distribute the info files,
+# and permit people to rebuild them, without requiring the makeinfo
+# program. If somebody tries to rebuild info, but none of the .texi
+# files have changed, then this Makefile will build chew, and will
+# build all of the stamp files, but will not actually have to rebuild
+# bfd.info.
+
+s-aoutx: $(MKDOC) $(srcdir)/../aoutx.h $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../aoutx.h >aoutx.tmp
+ $(srcdir)/../../move-if-change aoutx.tmp aoutx.texi
+ touch s-aoutx
+aoutx.texi: s-aoutx
+
+s-archive: $(MKDOC) $(srcdir)/../archive.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../archive.c >archive.tmp
+ $(srcdir)/../../move-if-change archive.tmp archive.texi
+ touch s-archive
+archive.texi: s-archive
+
+s-archures: $(MKDOC) $(srcdir)/../archures.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../archures.c >archures.tmp
+ $(srcdir)/../../move-if-change archures.tmp archures.texi
+ touch s-archures
+archures.texi: s-archures
+
+# We use bfdt.texi, rather than bfd.texi, to avoid conflicting with
+# bfd.texinfo on an 8.3 filesystem.
+s-bfd: $(MKDOC) $(srcdir)/../bfd.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../bfd.c >bfd.tmp
+ $(srcdir)/../../move-if-change bfd.tmp bfdt.texi
+ touch s-bfd
+bfdt.texi: s-bfd
+
+s-cache: $(MKDOC) $(srcdir)/../cache.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../cache.c >cache.tmp
+ $(srcdir)/../../move-if-change cache.tmp cache.texi
+ touch s-cache
+cache.texi: s-cache
+
+s-coffcode: $(MKDOC) $(srcdir)/../coffcode.h $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../coffcode.h >coffcode.tmp
+ $(srcdir)/../../move-if-change coffcode.tmp coffcode.texi
+ touch s-coffcode
+coffcode.texi: s-coffcode
+
+s-core: $(MKDOC) $(srcdir)/../corefile.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../corefile.c >core.tmp
+ $(srcdir)/../../move-if-change core.tmp core.texi
+ touch s-core
+core.texi: s-core
+
+s-elf: $(MKDOC) $(srcdir)/../elf.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elf.c >elf.tmp
+ $(srcdir)/../../move-if-change elf.tmp elf.texi
+ touch s-elf
+elf.texi: s-elf
+
+s-elfcode: $(MKDOC) $(srcdir)/../elfcode.h $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elfcode.h >elfcode.tmp
+ $(srcdir)/../../move-if-change elfcode.tmp elfcode.texi
+ touch s-elfcode
+elfcode.texi: s-elfcode
+
+s-format: $(MKDOC) $(srcdir)/../format.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../format.c >format.tmp
+ $(srcdir)/../../move-if-change format.tmp format.texi
+ touch s-format
+format.texi: s-format
+
+s-libbfd: $(MKDOC) $(srcdir)/../libbfd.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../libbfd.c >libbfd.tmp
+ $(srcdir)/../../move-if-change libbfd.tmp libbfd.texi
+ touch s-libbfd
+libbfd.texi: s-libbfd
+
+s-opncls: $(MKDOC) $(srcdir)/../opncls.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../opncls.c >opncls.tmp
+ $(srcdir)/../../move-if-change opncls.tmp opncls.texi
+ touch s-opncls
+opncls.texi: s-opncls
+
+s-reloc: $(MKDOC) $(srcdir)/../reloc.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../reloc.c >reloc.tmp
+ $(srcdir)/../../move-if-change reloc.tmp reloc.texi
+ touch s-reloc
+reloc.texi: s-reloc
+
+s-section: $(MKDOC) $(srcdir)/../section.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../section.c >section.tmp
+ $(srcdir)/../../move-if-change section.tmp section.texi
+ touch s-section
+section.texi: s-section
+
+s-syms: $(MKDOC) $(srcdir)/../syms.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../syms.c >syms.tmp
+ $(srcdir)/../../move-if-change syms.tmp syms.texi
+ touch s-syms
+syms.texi: s-syms
+
+s-targets: $(MKDOC) $(srcdir)/../targets.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../targets.c >targets.tmp
+ $(srcdir)/../../move-if-change targets.tmp targets.texi
+ touch s-targets
+targets.texi: s-targets
+
+s-init: $(MKDOC) $(srcdir)/../init.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../init.c >init.tmp
+ $(srcdir)/../../move-if-change init.tmp init.texi
+ touch s-init
+init.texi: s-init
+
+s-hash: $(MKDOC) $(srcdir)/../hash.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../hash.c >hash.tmp
+ $(srcdir)/../../move-if-change hash.tmp hash.texi
+ touch s-hash
+hash.texi: s-hash
+
+s-linker: $(MKDOC) $(srcdir)/../linker.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../linker.c >linker.tmp
+ $(srcdir)/../../move-if-change linker.tmp linker.texi
+ touch s-linker
+linker.texi: s-linker
+
+libbfd.h: $(srcdir)/../libbfd-in.h \
+ $(srcdir)/../init.c \
+ $(srcdir)/../libbfd.c \
+ $(srcdir)/../cache.c \
+ $(srcdir)/../reloc.c \
+ $(srcdir)/../archures.c \
+ $(srcdir)/proto.str \
+ $(MKDOC)
+ cat $(srcdir)/../libbfd-in.h >libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../init.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../libbfd.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cache.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../reloc.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../archures.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../elf.c >>libbfd.h
+
+libcoff.h: $(srcdir)/../libcoff-in.h \
+ $(srcdir)/../coffcode.h \
+ $(srcdir)/proto.str \
+ $(MKDOC)
+ cat $(srcdir)/../libcoff-in.h >libcoff.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../coffcode.h >>libcoff.h
+
+bfd.h: $(srcdir)/../bfd-in.h \
+ $(srcdir)/../init.c \
+ $(srcdir)/../opncls.c \
+ $(srcdir)/../libbfd.c \
+ $(srcdir)/../section.c \
+ $(srcdir)/../archures.c \
+ $(srcdir)/../reloc.c \
+ $(srcdir)/../syms.c \
+ $(srcdir)/../bfd.c \
+ $(srcdir)/../archive.c \
+ $(srcdir)/../corefile.c \
+ $(srcdir)/../targets.c \
+ $(srcdir)/../format.c \
+ $(srcdir)/proto.str \
+ $(MKDOC)
+ cat $(srcdir)/../bfd-in.h >bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../init.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../opncls.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../libbfd.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../section.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archures.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../reloc.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../syms.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../bfd.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archive.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../corefile.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../targets.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../format.c >>bfd.h
+ echo "#ifdef __cplusplus" >>bfd.h
+ echo "}" >>bfd.h
+ echo "#endif" >>bfd.h
+ echo "#endif" >>bfd.h
+
+noinst_TEXINFOS = bfdint.texi
+
+MOSTLYCLEANFILES = $(MKDOC) *.o
+
+CLEANFILES = s-* *.p *.ip
+
+DISTCLEANFILES = bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log
+
+MAINTAINERCLEANFILES = $(DOCFILES)
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
new file mode 100644
index 00000000000..6295c1002ee
--- /dev/null
+++ b/bfd/doc/Makefile.in
@@ -0,0 +1,600 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+AR = @AR@
+AS = @AS@
+BFD_HOST_64BIT_LONG = @BFD_HOST_64BIT_LONG@
+BFD_HOST_64_BIT = @BFD_HOST_64_BIT@
+BFD_HOST_64_BIT_DEFINED = @BFD_HOST_64_BIT_DEFINED@
+BFD_HOST_U_64_BIT = @BFD_HOST_U_64_BIT@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+COREFILE = @COREFILE@
+COREFLAG = @COREFLAG@
+DATADIRNAME = @DATADIRNAME@
+DLLTOOL = @DLLTOOL@
+EXEEXT = @EXEEXT@
+EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GT_NO = @GT_NO@
+GT_YES = @GT_YES@
+HDEFINES = @HDEFINES@
+INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
+INSTOBJEXT = @INSTOBJEXT@
+INTLDEPS = @INTLDEPS@
+INTLLIBS = @INTLLIBS@
+INTLOBJS = @INTLOBJS@
+LD = @LD@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+NM = @NM@
+PACKAGE = @PACKAGE@
+POFILES = @POFILES@
+POSUB = @POSUB@
+RANLIB = @RANLIB@
+TDEFINES = @TDEFINES@
+USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
+USE_NLS = @USE_NLS@
+USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
+VERSION = @VERSION@
+WIN32LDFLAGS = @WIN32LDFLAGS@
+WIN32LIBADD = @WIN32LIBADD@
+all_backends = @all_backends@
+bfd_backends = @bfd_backends@
+bfd_machines = @bfd_machines@
+l = @l@
+tdefaults = @tdefaults@
+wordsize = @wordsize@
+
+AUTOMAKE_OPTIONS = cygnus
+
+DOCFILES = aoutx.texi archive.texi archures.texi \
+ bfdt.texi cache.texi coffcode.texi \
+ core.texi elf.texi elfcode.texi format.texi libbfd.texi \
+ opncls.texi reloc.texi section.texi \
+ syms.texi targets.texi init.texi hash.texi linker.texi
+
+
+PROTOS = archive.p archures.p bfd.p \
+ core.p format.p \
+ libbfd.p opncls.p reloc.p \
+ section.p syms.p targets.p \
+ format.p core.p init.p
+
+
+IPROTOS = cache.ip libbfd.ip reloc.ip init.ip archures.ip coffcode.ip
+
+# SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction
+# between VPATH and suffix rules. If you use GNU Make, perhaps other Makes,
+# you don't need these three:
+SRCDOC = $(srcdir)/../aoutx.h $(srcdir)/../archive.c \
+ $(srcdir)/../archures.c $(srcdir)/../bfd.c \
+ $(srcdir)/../cache.c $(srcdir)/../coffcode.h \
+ $(srcdir)/../corefile.c $(srcdir)/../elf.c \
+ $(srcdir)/../elfcode.h $(srcdir)/../format.c \
+ $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \
+ $(srcdir)/../reloc.c $(srcdir)/../section.c \
+ $(srcdir)/../syms.c $(srcdir)/../targets.c \
+ $(srcdir)/../hash.c $(srcdir)/../linker.c
+
+
+SRCPROT = $(srcdir)/../archive.c $(srcdir)/../archures.c \
+ $(srcdir)/../bfd.c $(srcdir)/../coffcode.h $(srcdir)/../corefile.c \
+ $(srcdir)/../format.c $(srcdir)/../libbfd.c \
+ $(srcdir)/../opncls.c $(srcdir)/../reloc.c \
+ $(srcdir)/../section.c $(srcdir)/../syms.c \
+ $(srcdir)/../targets.c $(srcdir)/../init.c
+
+
+SRCIPROT = $(srcdir)/../cache.c $(srcdir)/../libbfd.c \
+ $(srcdir)/../reloc.c $(srcdir)/../cpu-h8300.c \
+ $(srcdir)/../cpu-i960.c $(srcdir)/../archures.c \
+ $(srcdir)/../init.c
+
+
+TEXIDIR = $(srcdir)/../../texinfo/fsf
+
+info_TEXINFOS = bfd.texinfo
+
+MKDOC = chew$(EXEEXT_FOR_BUILD)
+
+noinst_TEXINFOS = bfdint.texi
+
+MOSTLYCLEANFILES = $(MKDOC) *.o
+
+CLEANFILES = s-* *.p *.ip
+
+DISTCLEANFILES = bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log
+
+MAINTAINERCLEANFILES = $(DOCFILES)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES =
+TEXI2DVI = `if test -f $(top_srcdir)/../texinfo/util/texi2dvi; then echo $(top_srcdir)/../texinfo/util/texi2dvi; else echo texi2dvi; fi`
+TEXINFO_TEX = $(top_srcdir)/../texinfo/texinfo.tex
+INFO_DEPS = bfd.info
+DVIS = bfd.dvi
+TEXINFOS = bfd.texinfo
+DIST_COMMON = ChangeLog Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .dvi .info .ps .texi .texinfo .txi
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --cygnus doc/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+bfd.info: bfd.texinfo
+bfd.dvi: bfd.texinfo
+
+
+DVIPS = dvips
+
+.texi.info:
+ @rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ $(MAKEINFO) -I $(srcdir) $<
+
+.texi.dvi:
+ TEXINPUTS=$(top_srcdir)/../texinfo/texinfo.tex:$$TEXINPUTS \
+ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+
+.texi:
+ @rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ $(MAKEINFO) -I $(srcdir) $<
+
+.texinfo.info:
+ @rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ $(MAKEINFO) -I $(srcdir) $<
+
+.texinfo:
+ @rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ $(MAKEINFO) -I $(srcdir) $<
+
+.texinfo.dvi:
+ TEXINPUTS=$(top_srcdir)/../texinfo/texinfo.tex:$$TEXINPUTS \
+ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+
+.txi.info:
+ @rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ $(MAKEINFO) -I $(srcdir) $<
+
+.txi.dvi:
+ TEXINPUTS=$(top_srcdir)/../texinfo/texinfo.tex:$$TEXINPUTS \
+ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+
+.txi:
+ @rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ $(MAKEINFO) -I $(srcdir) $<
+.dvi.ps:
+ $(DVIPS) $< -o $@
+
+install-info-am: $(INFO_DEPS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(infodir)
+ @list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
+ if test -f $$d/$$ifile; then \
+ echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
+ $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
+ else : ; fi; \
+ done; \
+ done
+ @$(POST_INSTALL)
+ @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
+ install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
+ done; \
+ else : ; fi
+
+uninstall-info:
+ $(PRE_UNINSTALL)
+ @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+ ii=yes; \
+ else ii=; fi; \
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ test -z "$ii" \
+ || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
+ done
+ @$(NORMAL_UNINSTALL)
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ (cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
+ done
+
+dist-info: $(INFO_DEPS)
+ list='$(INFO_DEPS)'; \
+ for base in $$list; do \
+ if test -f $$base; then d=.; else d=$(srcdir); fi; \
+ for file in `cd $$d && eval echo $$base*`; do \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file; \
+ done; \
+ done
+
+mostlyclean-aminfo:
+ -rm -f bfd.aux bfd.cp bfd.cps bfd.dvi bfd.fn bfd.fns bfd.ky bfd.kys \
+ bfd.ps bfd.log bfd.pg bfd.toc bfd.tp bfd.tps bfd.vr bfd.vrs \
+ bfd.op bfd.tr bfd.cv bfd.cn
+
+clean-aminfo:
+
+distclean-aminfo:
+
+maintainer-clean-aminfo:
+ for i in $(INFO_DEPS); do \
+ rm -f $$i; \
+ if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
+ rm -f $$i-[0-9]*; \
+ fi; \
+ done
+clean-info: mostlyclean-aminfo
+tags: TAGS
+TAGS:
+
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = doc
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ cp -pr $$/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+ $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
+info-am: $(INFO_DEPS)
+info: info-am
+dvi-am: $(DVIS)
+dvi: dvi-am
+check-am:
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-info-am:
+install-info: install-info-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
+mostlyclean-generic:
+ -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+mostlyclean-am: mostlyclean-aminfo mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-aminfo clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-aminfo distclean-generic clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-aminfo maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: install-info-am uninstall-info mostlyclean-aminfo \
+distclean-aminfo clean-aminfo maintainer-clean-aminfo tags distdir \
+info-am info dvi-am dvi check check-am installcheck-am installcheck \
+install-info-am install-info install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+$(MKDOC): chew.o
+ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(LOADLIBES) $(LDFLAGS)
+
+chew.o: chew.c
+ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
+
+protos: libbfd.h libcoff.h bfd.h
+
+bfd.info bfd.dvi: $(DOCFILES) bfdsumm.texi bfd.texinfo
+
+# We can't replace these rules with an implicit rule, because
+# makes without VPATH support couldn't find the .h files in `..'.
+
+# We use s-XXX targets so that we can distribute the info files,
+# and permit people to rebuild them, without requiring the makeinfo
+# program. If somebody tries to rebuild info, but none of the .texi
+# files have changed, then this Makefile will build chew, and will
+# build all of the stamp files, but will not actually have to rebuild
+# bfd.info.
+
+s-aoutx: $(MKDOC) $(srcdir)/../aoutx.h $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../aoutx.h >aoutx.tmp
+ $(srcdir)/../../move-if-change aoutx.tmp aoutx.texi
+ touch s-aoutx
+aoutx.texi: s-aoutx
+
+s-archive: $(MKDOC) $(srcdir)/../archive.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../archive.c >archive.tmp
+ $(srcdir)/../../move-if-change archive.tmp archive.texi
+ touch s-archive
+archive.texi: s-archive
+
+s-archures: $(MKDOC) $(srcdir)/../archures.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../archures.c >archures.tmp
+ $(srcdir)/../../move-if-change archures.tmp archures.texi
+ touch s-archures
+archures.texi: s-archures
+
+# We use bfdt.texi, rather than bfd.texi, to avoid conflicting with
+# bfd.texinfo on an 8.3 filesystem.
+s-bfd: $(MKDOC) $(srcdir)/../bfd.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../bfd.c >bfd.tmp
+ $(srcdir)/../../move-if-change bfd.tmp bfdt.texi
+ touch s-bfd
+bfdt.texi: s-bfd
+
+s-cache: $(MKDOC) $(srcdir)/../cache.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../cache.c >cache.tmp
+ $(srcdir)/../../move-if-change cache.tmp cache.texi
+ touch s-cache
+cache.texi: s-cache
+
+s-coffcode: $(MKDOC) $(srcdir)/../coffcode.h $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../coffcode.h >coffcode.tmp
+ $(srcdir)/../../move-if-change coffcode.tmp coffcode.texi
+ touch s-coffcode
+coffcode.texi: s-coffcode
+
+s-core: $(MKDOC) $(srcdir)/../corefile.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../corefile.c >core.tmp
+ $(srcdir)/../../move-if-change core.tmp core.texi
+ touch s-core
+core.texi: s-core
+
+s-elf: $(MKDOC) $(srcdir)/../elf.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elf.c >elf.tmp
+ $(srcdir)/../../move-if-change elf.tmp elf.texi
+ touch s-elf
+elf.texi: s-elf
+
+s-elfcode: $(MKDOC) $(srcdir)/../elfcode.h $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elfcode.h >elfcode.tmp
+ $(srcdir)/../../move-if-change elfcode.tmp elfcode.texi
+ touch s-elfcode
+elfcode.texi: s-elfcode
+
+s-format: $(MKDOC) $(srcdir)/../format.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../format.c >format.tmp
+ $(srcdir)/../../move-if-change format.tmp format.texi
+ touch s-format
+format.texi: s-format
+
+s-libbfd: $(MKDOC) $(srcdir)/../libbfd.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../libbfd.c >libbfd.tmp
+ $(srcdir)/../../move-if-change libbfd.tmp libbfd.texi
+ touch s-libbfd
+libbfd.texi: s-libbfd
+
+s-opncls: $(MKDOC) $(srcdir)/../opncls.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../opncls.c >opncls.tmp
+ $(srcdir)/../../move-if-change opncls.tmp opncls.texi
+ touch s-opncls
+opncls.texi: s-opncls
+
+s-reloc: $(MKDOC) $(srcdir)/../reloc.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../reloc.c >reloc.tmp
+ $(srcdir)/../../move-if-change reloc.tmp reloc.texi
+ touch s-reloc
+reloc.texi: s-reloc
+
+s-section: $(MKDOC) $(srcdir)/../section.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../section.c >section.tmp
+ $(srcdir)/../../move-if-change section.tmp section.texi
+ touch s-section
+section.texi: s-section
+
+s-syms: $(MKDOC) $(srcdir)/../syms.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../syms.c >syms.tmp
+ $(srcdir)/../../move-if-change syms.tmp syms.texi
+ touch s-syms
+syms.texi: s-syms
+
+s-targets: $(MKDOC) $(srcdir)/../targets.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../targets.c >targets.tmp
+ $(srcdir)/../../move-if-change targets.tmp targets.texi
+ touch s-targets
+targets.texi: s-targets
+
+s-init: $(MKDOC) $(srcdir)/../init.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../init.c >init.tmp
+ $(srcdir)/../../move-if-change init.tmp init.texi
+ touch s-init
+init.texi: s-init
+
+s-hash: $(MKDOC) $(srcdir)/../hash.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../hash.c >hash.tmp
+ $(srcdir)/../../move-if-change hash.tmp hash.texi
+ touch s-hash
+hash.texi: s-hash
+
+s-linker: $(MKDOC) $(srcdir)/../linker.c $(srcdir)/doc.str
+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../linker.c >linker.tmp
+ $(srcdir)/../../move-if-change linker.tmp linker.texi
+ touch s-linker
+linker.texi: s-linker
+
+libbfd.h: $(srcdir)/../libbfd-in.h \
+ $(srcdir)/../init.c \
+ $(srcdir)/../libbfd.c \
+ $(srcdir)/../cache.c \
+ $(srcdir)/../reloc.c \
+ $(srcdir)/../archures.c \
+ $(srcdir)/proto.str \
+ $(MKDOC)
+ cat $(srcdir)/../libbfd-in.h >libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../init.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../libbfd.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cache.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../reloc.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../archures.c >>libbfd.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../elf.c >>libbfd.h
+
+libcoff.h: $(srcdir)/../libcoff-in.h \
+ $(srcdir)/../coffcode.h \
+ $(srcdir)/proto.str \
+ $(MKDOC)
+ cat $(srcdir)/../libcoff-in.h >libcoff.h
+ ./$(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../coffcode.h >>libcoff.h
+
+bfd.h: $(srcdir)/../bfd-in.h \
+ $(srcdir)/../init.c \
+ $(srcdir)/../opncls.c \
+ $(srcdir)/../libbfd.c \
+ $(srcdir)/../section.c \
+ $(srcdir)/../archures.c \
+ $(srcdir)/../reloc.c \
+ $(srcdir)/../syms.c \
+ $(srcdir)/../bfd.c \
+ $(srcdir)/../archive.c \
+ $(srcdir)/../corefile.c \
+ $(srcdir)/../targets.c \
+ $(srcdir)/../format.c \
+ $(srcdir)/proto.str \
+ $(MKDOC)
+ cat $(srcdir)/../bfd-in.h >bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../init.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../opncls.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../libbfd.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../section.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archures.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../reloc.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../syms.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../bfd.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archive.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../corefile.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../targets.c >>bfd.h
+ ./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../format.c >>bfd.h
+ echo "#ifdef __cplusplus" >>bfd.h
+ echo "}" >>bfd.h
+ echo "#endif" >>bfd.h
+ echo "#endif" >>bfd.h
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/bfd/doc/bfd.texinfo b/bfd/doc/bfd.texinfo
new file mode 100644
index 00000000000..eadf87cc345
--- /dev/null
+++ b/bfd/doc/bfd.texinfo
@@ -0,0 +1,348 @@
+\input texinfo.tex
+@setfilename bfd.info
+@c $Id$
+@tex
+% NOTE LOCAL KLUGE TO AVOID TOO MUCH WHITESPACE
+\global\long\def\example{%
+\begingroup
+\let\aboveenvbreak=\par
+\let\afterenvbreak=\par
+\parskip=0pt
+\lisp}
+\global\long\def\Eexample{%
+\Elisp
+\endgroup
+\vskip -\parskip% to cancel out effect of following \par
+}
+@end tex
+@synindex fn cp
+
+@ifinfo
+@format
+START-INFO-DIR-ENTRY
+* Bfd: (bfd). The Binary File Descriptor library.
+END-INFO-DIR-ENTRY
+@end format
+@end ifinfo
+
+@ifinfo
+This file documents the BFD library.
+
+Copyright (C) 1991 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+@ignore
+Permission is granted to process this file through Tex and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+
+@end ignore
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, subject to the terms
+of the GNU General Public License, which includes the provision that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions.
+@end ifinfo
+@iftex
+@c@finalout
+@setchapternewpage on
+@c@setchapternewpage odd
+@settitle LIB BFD, the Binary File Descriptor Library
+@titlepage
+@title{libbfd}
+@subtitle{The Binary File Descriptor Library}
+@sp 1
+@subtitle First Edition---BFD version < 3.0
+@subtitle April 1991
+@author {Steve Chamberlain}
+@author {Cygnus Support}
+@page
+
+@tex
+\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
+\xdef\manvers{\$Revision$} % For use in headers, footers too
+{\parskip=0pt
+\hfill Cygnus Support\par
+\hfill sac\@cygnus.com\par
+\hfill {\it BFD}, \manvers\par
+\hfill \TeX{}info \texinfoversion\par
+}
+\global\parindent=0pt % Steve likes it this way
+@end tex
+
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1991 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, subject to the terms
+of the GNU General Public License, which includes the provision that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions.
+@end titlepage
+@end iftex
+
+@node Top, Overview, (dir), (dir)
+@ifinfo
+This file documents the binary file descriptor library libbfd.
+@end ifinfo
+
+@menu
+* Overview:: Overview of BFD
+* BFD front end:: BFD front end
+* BFD back ends:: BFD back ends
+* Index:: Index
+@end menu
+
+@node Overview, BFD front end, Top, Top
+@chapter Introduction
+@cindex BFD
+@cindex what is it?
+BFD is a package which allows applications to use the
+same routines to operate on object files whatever the object file
+format. A new object file format can be supported simply by
+creating a new BFD back end and adding it to the library.
+
+BFD is split into two parts: the front end, and the back ends (one for
+each object file format).
+@itemize @bullet
+@item The front end of BFD provides the interface to the user. It manages
+memory and various canonical data structures. The front end also
+decides which back end to use and when to call back end routines.
+@item The back ends provide BFD its view of the real world. Each back
+end provides a set of calls which the BFD front end can use to maintain
+its canonical form. The back ends also may keep around information for
+their own use, for greater efficiency.
+@end itemize
+@menu
+* History:: History
+* How It Works:: How It Works
+* What BFD Version 2 Can Do:: What BFD Version 2 Can Do
+@end menu
+
+@node History, How It Works, Overview, Overview
+@section History
+
+One spur behind BFD was the desire, on the part of the GNU 960 team at
+Intel Oregon, for interoperability of applications on their COFF and
+b.out file formats. Cygnus was providing GNU support for the team, and
+was contracted to provide the required functionality.
+
+The name came from a conversation David Wallace was having with Richard
+Stallman about the library: RMS said that it would be quite hard---David
+said ``BFD''. Stallman was right, but the name stuck.
+
+At the same time, Ready Systems wanted much the same thing, but for
+different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k
+coff.
+
+BFD was first implemented by members of Cygnus Support; Steve
+Chamberlain (@code{sac@@cygnus.com}), John Gilmore
+(@code{gnu@@cygnus.com}), K. Richard Pixley (@code{rich@@cygnus.com})
+and David Henkel-Wallace (@code{gumby@@cygnus.com}).
+
+
+
+@node How It Works, What BFD Version 2 Can Do, History, Overview
+@section How To Use BFD
+
+To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
+
+BFD provides a common interface to the parts of an object file
+for a calling application.
+
+When an application sucessfully opens a target file (object, archive, or
+whatever), a pointer to an internal structure is returned. This pointer
+points to a structure called @code{bfd}, described in
+@file{bfd.h}. Our convention is to call this pointer a BFD, and
+instances of it within code @code{abfd}. All operations on
+the target object file are applied as methods to the BFD. The mapping is
+defined within @code{bfd.h} in a set of macros, all beginning
+with @samp{bfd_} to reduce namespace pollution.
+
+For example, this sequence does what you would probably expect:
+return the number of sections in an object file attached to a BFD
+@code{abfd}.
+
+@lisp
+@c @cartouche
+#include "bfd.h"
+
+unsigned int number_of_sections(abfd)
+bfd *abfd;
+@{
+ return bfd_count_sections(abfd);
+@}
+@c @end cartouche
+@end lisp
+
+The abstraction used within BFD is that an object file has:
+
+@itemize @bullet
+@item
+a header,
+@item
+a number of sections containing raw data (@pxref{Sections}),
+@item
+a set of relocations (@pxref{Relocations}), and
+@item
+some symbol information (@pxref{Symbols}).
+@end itemize
+@noindent
+Also, BFDs opened for archives have the additional attribute of an index
+and contain subordinate BFDs. This approach is fine for a.out and coff,
+but loses efficiency when applied to formats such as S-records and
+IEEE-695.
+
+@node What BFD Version 2 Can Do, , How It Works, Overview
+@section What BFD Version 2 Can Do
+@include bfdsumm.texi
+
+@node BFD front end, BFD back ends, Overview, Top
+@chapter BFD front end
+@include bfdt.texi
+
+@menu
+* Memory Usage::
+* Initialization::
+* Sections::
+* Symbols::
+* Archives::
+* Formats::
+* Relocations::
+* Core Files::
+* Targets::
+* Architectures::
+* Opening and Closing::
+* Internal::
+* File Caching::
+* Linker Functions::
+* Hash Tables::
+@end menu
+
+@node Memory Usage, Initialization, BFD front end, BFD front end
+@section Memory usage
+BFD keeps all of its internal structures in obstacks. There is one obstack
+per open BFD file, into which the current state is stored. When a BFD is
+closed, the obstack is deleted, and so everything which has been
+allocated by BFD for the closing file is thrown away.
+
+BFD does not free anything created by an application, but pointers into
+@code{bfd} structures become invalid on a @code{bfd_close}; for example,
+after a @code{bfd_close} the vector passed to
+@code{bfd_canonicalize_symtab} is still around, since it has been
+allocated by the application, but the data that it pointed to are
+lost.
+
+The general rule is to not close a BFD until all operations dependent
+upon data from the BFD have been completed, or all the data from within
+the file has been copied. To help with the management of memory, there
+is a function (@code{bfd_alloc_size}) which returns the number of bytes
+in obstacks associated with the supplied BFD. This could be used to
+select the greediest open BFD, close it to reclaim the memory, perform
+some operation and reopen the BFD again, to get a fresh copy of the data
+structures.
+
+@node Initialization, Sections, Memory Usage, BFD front end
+@include init.texi
+
+@node Sections, Symbols, Initialization, BFD front end
+@include section.texi
+
+@node Symbols, Archives, Sections, BFD front end
+@include syms.texi
+
+@node Archives, Formats, Symbols, BFD front end
+@include archive.texi
+
+@node Formats, Relocations, Archives, BFD front end
+@include format.texi
+
+@node Relocations, Core Files, Formats, BFD front end
+@include reloc.texi
+
+@node Core Files, Targets, Relocations, BFD front end
+@include core.texi
+
+@node Targets, Architectures, Core Files, BFD front end
+@include targets.texi
+
+@node Architectures, Opening and Closing, Targets, BFD front end
+@include archures.texi
+
+@node Opening and Closing, Internal, Architectures, BFD front end
+@include opncls.texi
+
+@node Internal, File Caching, Opening and Closing, BFD front end
+@include libbfd.texi
+
+@node File Caching, Linker Functions, Internal, BFD front end
+@include cache.texi
+
+@node Linker Functions, Hash Tables, File Caching, BFD front end
+@include linker.texi
+
+@node Hash Tables, , Linker Functions, BFD front end
+@include hash.texi
+
+@node BFD back ends, Index, BFD front end, Top
+@chapter BFD back ends
+@menu
+* What to Put Where::
+* aout :: a.out backends
+* coff :: coff backends
+* elf :: elf backends
+@ignore
+* oasys :: oasys backends
+* ieee :: ieee backend
+* srecord :: s-record backend
+@end ignore
+@end menu
+@node What to Put Where, aout, BFD back ends, BFD back ends
+All of BFD lives in one directory.
+
+@node aout, coff, What to Put Where, BFD back ends
+@include aoutx.texi
+
+@node coff, elf, aout, BFD back ends
+@include coffcode.texi
+
+@node elf, , coff, BFD back ends
+@include elf.texi
+@c Leave this out until the file has some actual contents...
+@c @include elfcode.texi
+
+@node Index, , BFD back ends , Top
+@unnumbered Index
+@printindex cp
+
+@tex
+% I think something like @colophon should be in texinfo. In the
+% meantime:
+\long\def\colophon{\hbox to0pt{}\vfill
+\centerline{The body of this manual is set in}
+\centerline{\fontname\tenrm,}
+\centerline{with headings in {\bf\fontname\tenbf}}
+\centerline{and examples in {\tt\fontname\tentt}.}
+\centerline{{\it\fontname\tenit\/} and}
+\centerline{{\sl\fontname\tensl\/}}
+\centerline{are used for emphasis.}\vfill}
+\page\colophon
+% Blame: doc@cygnus.com, 28mar91.
+@end tex
+
+@contents
+@bye
diff --git a/bfd/doc/bfdint.texi b/bfd/doc/bfdint.texi
new file mode 100644
index 00000000000..eb09b34a9d2
--- /dev/null
+++ b/bfd/doc/bfdint.texi
@@ -0,0 +1,1885 @@
+\input texinfo
+@setfilename bfdint.info
+
+@settitle BFD Internals
+@iftex
+@titlepage
+@title{BFD Internals}
+@author{Ian Lance Taylor}
+@author{Cygnus Solutions}
+@page
+@end iftex
+
+@node Top
+@top BFD Internals
+@raisesections
+@cindex bfd internals
+
+This document describes some BFD internal information which may be
+helpful when working on BFD. It is very incomplete.
+
+This document is not updated regularly, and may be out of date. It was
+last modified on $Date$.
+
+The initial version of this document was written by Ian Lance Taylor
+@email{ian@@cygnus.com}.
+
+@menu
+* BFD overview:: BFD overview
+* BFD guidelines:: BFD programming guidelines
+* BFD target vector:: BFD target vector
+* BFD generated files:: BFD generated files
+* BFD multiple compilations:: Files compiled multiple times in BFD
+* BFD relocation handling:: BFD relocation handling
+* BFD ELF support:: BFD ELF support
+* BFD glossary:: Glossary
+* Index:: Index
+@end menu
+
+@node BFD overview
+@section BFD overview
+
+BFD is a library which provides a single interface to read and write
+object files, executables, archive files, and core files in any format.
+
+@menu
+* BFD library interfaces:: BFD library interfaces
+* BFD library users:: BFD library users
+* BFD view:: The BFD view of a file
+* BFD blindness:: BFD loses information
+@end menu
+
+@node BFD library interfaces
+@subsection BFD library interfaces
+
+One way to look at the BFD library is to divide it into four parts by
+type of interface.
+
+The first interface is the set of generic functions which programs using
+the BFD library will call. These generic function normally translate
+directly or indirectly into calls to routines which are specific to a
+particular object file format. Many of these generic functions are
+actually defined as macros in @file{bfd.h}. These functions comprise
+the official BFD interface.
+
+The second interface is the set of functions which appear in the target
+vectors. This is the bulk of the code in BFD. A target vector is a set
+of function pointers specific to a particular object file format. The
+target vector is used to implement the generic BFD functions. These
+functions are always called through the target vector, and are never
+called directly. The target vector is described in detail in @ref{BFD
+target vector}. The set of functions which appear in a particular
+target vector is often referred to as a BFD backend.
+
+The third interface is a set of oddball functions which are typically
+specific to a particular object file format, are not generic functions,
+and are called from outside of the BFD library. These are used as hooks
+by the linker and the assembler when a particular object file format
+requires some action which the BFD generic interface does not provide.
+These functions are typically declared in @file{bfd.h}, but in many
+cases they are only provided when BFD is configured with support for a
+particular object file format. These functions live in a grey area, and
+are not really part of the official BFD interface.
+
+The fourth interface is the set of BFD support functions which are
+called by the other BFD functions. These manage issues like memory
+allocation, error handling, file access, hash tables, swapping, and the
+like. These functions are never called from outside of the BFD library.
+
+@node BFD library users
+@subsection BFD library users
+
+Another way to look at the BFD library is to divide it into three parts
+by the manner in which it is used.
+
+The first use is to read an object file. The object file readers are
+programs like @samp{gdb}, @samp{nm}, @samp{objdump}, and @samp{objcopy}.
+These programs use BFD to view an object file in a generic form. The
+official BFD interface is normally fully adequate for these programs.
+
+The second use is to write an object file. The object file writers are
+programs like @samp{gas} and @samp{objcopy}. These programs use BFD to
+create an object file. The official BFD interface is normally adequate
+for these programs, but for some object file formats the assembler needs
+some additional hooks in order to set particular flags or other
+information. The official BFD interface includes functions to copy
+private information from one object file to another, and these functions
+are used by @samp{objcopy} to avoid information loss.
+
+The third use is to link object files. There is only one object file
+linker, @samp{ld}. Originally, @samp{ld} was an object file reader and
+an object file writer, and it did the link operation using the generic
+BFD structures. However, this turned out to be too slow and too memory
+intensive.
+
+The official BFD linker functions were written to permit specific BFD
+backends to perform the link without translating through the generic
+structures, in the normal case where all the input files and output file
+have the same object file format. Not all of the backends currently
+implement the new interface, and there are default linking functions
+within BFD which use the generic structures and which work with all
+backends.
+
+For several object file formats the linker needs additional hooks which
+are not provided by the official BFD interface, particularly for dynamic
+linking support. These functions are typically called from the linker
+emulation template.
+
+@node BFD view
+@subsection The BFD view of a file
+
+BFD uses generic structures to manage information. It translates data
+into the generic form when reading files, and out of the generic form
+when writing files.
+
+BFD describes a file as a pointer to the @samp{bfd} type. A @samp{bfd}
+is composed of the following elements. The BFD information can be
+displayed using the @samp{objdump} program with various options.
+
+@table @asis
+@item general information
+The object file format, a few general flags, the start address.
+@item architecture
+The architecture, including both a general processor type (m68k, MIPS
+etc.) and a specific machine number (m68000, R4000, etc.).
+@item sections
+A list of sections.
+@item symbols
+A symbol table.
+@end table
+
+BFD represents a section as a pointer to the @samp{asection} type. Each
+section has a name and a size. Most sections also have an associated
+block of data, known as the section contents. Sections also have
+associated flags, a virtual memory address, a load memory address, a
+required alignment, a list of relocations, and other miscellaneous
+information.
+
+BFD represents a relocation as a pointer to the @samp{arelent} type. A
+relocation describes an action which the linker must take to modify the
+section contents. Relocations have a symbol, an address, an addend, and
+a pointer to a howto structure which describes how to perform the
+relocation. For more information, see @ref{BFD relocation handling}.
+
+BFD represents a symbol as a pointer to the @samp{asymbol} type. A
+symbol has a name, a pointer to a section, an offset within that
+section, and some flags.
+
+Archive files do not have any sections or symbols. Instead, BFD
+represents an archive file as a file which contains a list of
+@samp{bfd}s. BFD also provides access to the archive symbol map, as a
+list of symbol names. BFD provides a function to return the @samp{bfd}
+within the archive which corresponds to a particular entry in the
+archive symbol map.
+
+@node BFD blindness
+@subsection BFD loses information
+
+Most object file formats have information which BFD can not represent in
+its generic form, at least as currently defined.
+
+There is often explicit information which BFD can not represent. For
+example, the COFF version stamp, or the ELF program segments. BFD
+provides special hooks to handle this information when copying,
+printing, or linking an object file. The BFD support for a particular
+object file format will normally store this information in private data
+and handle it using the special hooks.
+
+In some cases there is also implicit information which BFD can not
+represent. For example, the MIPS processor distinguishes small and
+large symbols, and requires that all small symbls be within 32K of the
+GP register. This means that the MIPS assembler must be able to mark
+variables as either small or large, and the MIPS linker must know to put
+small symbols within range of the GP register. Since BFD can not
+represent this information, this means that the assembler and linker
+must have information that is specific to a particular object file
+format which is outside of the BFD library.
+
+This loss of information indicates areas where the BFD paradigm breaks
+down. It is not actually possible to represent the myriad differences
+among object file formats using a single generic interface, at least not
+in the manner which BFD does it today.
+
+Nevertheless, the BFD library does greatly simplify the task of dealing
+with object files, and particular problems caused by information loss
+can normally be solved using some sort of relatively constrained hook
+into the library.
+
+
+
+@node BFD guidelines
+@section BFD programming guidelines
+@cindex bfd programming guidelines
+@cindex programming guidelines for bfd
+@cindex guidelines, bfd programming
+
+There is a lot of poorly written and confusing code in BFD. New BFD
+code should be written to a higher standard. Merely because some BFD
+code is written in a particular manner does not mean that you should
+emulate it.
+
+Here are some general BFD programming guidelines:
+
+@itemize @bullet
+@item
+Follow the GNU coding standards.
+
+@item
+Avoid global variables. We ideally want BFD to be fully reentrant, so
+that it can be used in multiple threads. All uses of global or static
+variables interfere with that. Initialized constant variables are OK,
+and they should be explicitly marked with const. Instead of global
+variables, use data attached to a BFD or to a linker hash table.
+
+@item
+All externally visible functions should have names which start with
+@samp{bfd_}. All such functions should be declared in some header file,
+typically @file{bfd.h}. See, for example, the various declarations near
+the end of @file{bfd-in.h}, which mostly declare functions required by
+specific linker emulations.
+
+@item
+All functions which need to be visible from one file to another within
+BFD, but should not be visible outside of BFD, should start with
+@samp{_bfd_}. Although external names beginning with @samp{_} are
+prohibited by the ANSI standard, in practice this usage will always
+work, and it is required by the GNU coding standards.
+
+@item
+Always remember that people can compile using @samp{--enable-targets} to
+build several, or all, targets at once. It must be possible to link
+together the files for all targets.
+
+@item
+BFD code should compile with few or no warnings using @samp{gcc -Wall}.
+Some warnings are OK, like the absence of certain function declarations
+which may or may not be declared in system header files. Warnings about
+ambiguous expressions and the like should always be fixed.
+@end itemize
+
+@node BFD target vector
+@section BFD target vector
+@cindex bfd target vector
+@cindex target vector in bfd
+
+BFD supports multiple object file formats by using the @dfn{target
+vector}. This is simply a set of function pointers which implement
+behaviour that is specific to a particular object file format.
+
+In this section I list all of the entries in the target vector and
+describe what they do.
+
+@menu
+* BFD target vector miscellaneous:: Miscellaneous constants
+* BFD target vector swap:: Swapping functions
+* BFD target vector format:: Format type dependent functions
+* BFD_JUMP_TABLE macros:: BFD_JUMP_TABLE macros
+* BFD target vector generic:: Generic functions
+* BFD target vector copy:: Copy functions
+* BFD target vector core:: Core file support functions
+* BFD target vector archive:: Archive functions
+* BFD target vector symbols:: Symbol table functions
+* BFD target vector relocs:: Relocation support
+* BFD target vector write:: Output functions
+* BFD target vector link:: Linker functions
+* BFD target vector dynamic:: Dynamic linking information functions
+@end menu
+
+@node BFD target vector miscellaneous
+@subsection Miscellaneous constants
+
+The target vector starts with a set of constants.
+
+@table @samp
+@item name
+The name of the target vector. This is an arbitrary string. This is
+how the target vector is named in command line options for tools which
+use BFD, such as the @samp{-oformat} linker option.
+
+@item flavour
+A general description of the type of target. The following flavours are
+currently defined:
+
+@table @samp
+@item bfd_target_unknown_flavour
+Undefined or unknown.
+@item bfd_target_aout_flavour
+a.out.
+@item bfd_target_coff_flavour
+COFF.
+@item bfd_target_ecoff_flavour
+ECOFF.
+@item bfd_target_elf_flavour
+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
+Tektronix hex format.
+@item bfd_target_srec_flavour
+Motorola S-record format.
+@item bfd_target_ihex_flavour
+Intel hex format.
+@item bfd_target_som_flavour
+SOM (used on HP/UX).
+@item bfd_target_os9k_flavour
+os9000.
+@item bfd_target_versados_flavour
+VERSAdos.
+@item bfd_target_msdos_flavour
+MS-DOS.
+@item bfd_target_evax_flavour
+openVMS.
+@end table
+
+@item byteorder
+The byte order of data in the object file. One of
+@samp{BFD_ENDIAN_BIG}, @samp{BFD_ENDIAN_LITTLE}, or
+@samp{BFD_ENDIAN_UNKNOWN}. The latter would be used for a format such
+as S-records which do not record the architecture of the data.
+
+@item header_byteorder
+The byte order of header information in the object file. Normally the
+same as the @samp{byteorder} field, but there are certain cases where it
+may be different.
+
+@item object_flags
+Flags which may appear in the @samp{flags} field of a BFD with this
+format.
+
+@item section_flags
+Flags which may appear in the @samp{flags} field of a section within a
+BFD with this format.
+
+@item symbol_leading_char
+A character which the C compiler normally puts before a symbol. For
+example, an a.out compiler will typically generate the symbol
+@samp{_foo} for a function named @samp{foo} in the C source, in which
+case this field would be @samp{_}. If there is no such character, this
+field will be @samp{0}.
+
+@item ar_pad_char
+The padding character to use at the end of an archive name. Normally
+@samp{/}.
+
+@item ar_max_namelen
+The maximum length of a short name in an archive. Normally @samp{14}.
+
+@item backend_data
+A pointer to constant backend data. This is used by backends to store
+whatever additional information they need to distinguish similar target
+vectors which use the same sets of functions.
+@end table
+
+@node BFD target vector swap
+@subsection Swapping functions
+
+Every target vector has fuction pointers used for swapping information
+in and out of the target representation. There are two sets of
+functions: one for data information, and one for header information.
+Each set has three sizes: 64-bit, 32-bit, and 16-bit. Each size has
+three actual functions: put, get unsigned, and get signed.
+
+These 18 functions are used to convert data between the host and target
+representations.
+
+@node BFD target vector format
+@subsection Format type dependent functions
+
+Every target vector has three arrays of function pointers which are
+indexed by the BFD format type. The BFD format types are as follows:
+
+@table @samp
+@item bfd_unknown
+Unknown format. Not used for anything useful.
+@item bfd_object
+Object file.
+@item bfd_archive
+Archive file.
+@item bfd_core
+Core file.
+@end table
+
+The three arrays of function pointers are as follows:
+
+@table @samp
+@item bfd_check_format
+Check whether the BFD is of a particular format (object file, archive
+file, or core file) corresponding to this target vector. This is called
+by the @samp{bfd_check_format} function when examining an existing BFD.
+If the BFD matches the desired format, this function will initialize any
+format specific information such as the @samp{tdata} field of the BFD.
+This function must be called before any other BFD target vector function
+on a file opened for reading.
+
+@item bfd_set_format
+Set the format of a BFD which was created for output. This is called by
+the @samp{bfd_set_format} function after creating the BFD with a
+function such as @samp{bfd_openw}. This function will initialize format
+specific information required to write out an object file or whatever of
+the given format. This function must be called before any other BFD
+target vector function on a file opened for writing.
+
+@item bfd_write_contents
+Write out the contents of the BFD in the given format. This is called
+by @samp{bfd_close} function for a BFD opened for writing. This really
+should not be an array selected by format type, as the
+@samp{bfd_set_format} function provides all the required information.
+In fact, BFD will fail if a different format is used when calling
+through the @samp{bfd_set_format} and the @samp{bfd_write_contents}
+arrays; fortunately, since @samp{bfd_close} gets it right, this is a
+difficult error to make.
+@end table
+
+@node BFD_JUMP_TABLE macros
+@subsection @samp{BFD_JUMP_TABLE} macros
+@cindex @samp{BFD_JUMP_TABLE}
+
+Most target vectors are defined using @samp{BFD_JUMP_TABLE} macros.
+These macros take a single argument, which is a prefix applied to a set
+of functions. The macros are then used to initialize the fields in the
+target vector.
+
+For example, the @samp{BFD_JUMP_TABLE_RELOCS} macro defines three
+functions: @samp{_get_reloc_upper_bound}, @samp{_canonicalize_reloc},
+and @samp{_bfd_reloc_type_lookup}. A reference like
+@samp{BFD_JUMP_TABLE_RELOCS (foo)} will expand into three functions
+prefixed with @samp{foo}: @samp{foo_get_reloc_upper_found}, etc. The
+@samp{BFD_JUMP_TABLE_RELOCS} macro will be placed such that those three
+functions initialize the appropriate fields in the BFD target vector.
+
+This is done because it turns out that many different target vectors can
+share certain classes of functions. For example, archives are similar
+on most platforms, so most target vectors can use the same archive
+functions. Those target vectors all use @samp{BFD_JUMP_TABLE_ARCHIVE}
+with the same argument, calling a set of functions which is defined in
+@file{archive.c}.
+
+Each of the @samp{BFD_JUMP_TABLE} macros is mentioned below along with
+the description of the function pointers which it defines. The function
+pointers will be described using the name without the prefix which the
+@samp{BFD_JUMP_TABLE} macro defines. This name is normally the same as
+the name of the field in the target vector structure. Any differences
+will be noted.
+
+@node BFD target vector generic
+@subsection Generic functions
+@cindex @samp{BFD_JUMP_TABLE_GENERIC}
+
+The @samp{BFD_JUMP_TABLE_GENERIC} macro is used for some catch all
+functions which don't easily fit into other categories.
+
+@table @samp
+@item _close_and_cleanup
+Free any target specific information associated with the BFD. This is
+called when any BFD is closed (the @samp{bfd_write_contents} function
+mentioned earlier is only called for a BFD opened for writing). Most
+targets use @samp{bfd_alloc} to allocate all target specific
+information, and therefore don't have to do anything in this function.
+This function pointer is typically set to
+@samp{_bfd_generic_close_and_cleanup}, which simply returns true.
+
+@item _bfd_free_cached_info
+Free any cached information associated with the BFD which can be
+recreated later if necessary. This is used to reduce the memory
+consumption required by programs using BFD. This is normally called via
+the @samp{bfd_free_cached_info} macro. It is used by the default
+archive routines when computing the archive map. Most targets do not
+do anything special for this entry point, and just set it to
+@samp{_bfd_generic_free_cached_info}, which simply returns true.
+
+@item _new_section_hook
+This is called from @samp{bfd_make_section_anyway} whenever a new
+section is created. Most targets use it to initialize section specific
+information. This function is called whether or not the section
+corresponds to an actual section in an actual BFD.
+
+@item _get_section_contents
+Get the contents of a section. This is called from
+@samp{bfd_get_section_contents}. Most targets set this to
+@samp{_bfd_generic_get_section_contents}, which does a @samp{bfd_seek}
+based on the section's @samp{filepos} field and a @samp{bfd_read}. The
+corresponding field in the target vector is named
+@samp{_bfd_get_section_contents}.
+
+@item _get_section_contents_in_window
+Set a @samp{bfd_window} to hold the contents of a section. This is
+called from @samp{bfd_get_section_contents_in_window}. The
+@samp{bfd_window} idea never really caught on, and I don't think this is
+ever called. Pretty much all targets implement this as
+@samp{bfd_generic_get_section_contents_in_window}, which uses
+@samp{bfd_get_section_contents} to do the right thing. The
+corresponding field in the target vector is named
+@samp{_bfd_get_section_contents_in_window}.
+@end table
+
+@node BFD target vector copy
+@subsection Copy functions
+@cindex @samp{BFD_JUMP_TABLE_COPY}
+
+The @samp{BFD_JUMP_TABLE_COPY} macro is used for functions which are
+called when copying BFDs, and for a couple of functions which deal with
+internal BFD information.
+
+@table @samp
+@item _bfd_copy_private_bfd_data
+This is called when copying a BFD, via @samp{bfd_copy_private_bfd_data}.
+If the input and output BFDs have the same format, this will copy any
+private information over. This is called after all the section contents
+have been written to the output file. Only a few targets do anything in
+this function.
+
+@item _bfd_merge_private_bfd_data
+This is called when linking, via @samp{bfd_merge_private_bfd_data}. It
+gives the backend linker code a chance to set any special flags in the
+output file based on the contents of the input file. Only a few targets
+do anything in this function.
+
+@item _bfd_copy_private_section_data
+This is similar to @samp{_bfd_copy_private_bfd_data}, but it is called
+for each section, via @samp{bfd_copy_private_section_data}. This
+function is called before any section contents have been written. Only
+a few targets do anything in this function.
+
+@item _bfd_copy_private_symbol_data
+This is called via @samp{bfd_copy_private_symbol_data}, but I don't
+think anything actually calls it. If it were defined, it could be used
+to copy private symbol data from one BFD to another. However, most BFDs
+store extra symbol information by allocating space which is larger than
+the @samp{asymbol} structure and storing private information in the
+extra space. Since @samp{objcopy} and other programs copy symbol
+information by copying pointers to @samp{asymbol} structures, the
+private symbol information is automatically copied as well. Most
+targets do not do anything in this function.
+
+@item _bfd_set_private_flags
+This is called via @samp{bfd_set_private_flags}. It is basically a hook
+for the assembler to set magic information. For example, the PowerPC
+ELF assembler uses it to set flags which appear in the e_flags field of
+the ELF header. Most targets do not do anything in this function.
+
+@item _bfd_print_private_bfd_data
+This is called by @samp{objdump} when the @samp{-p} option is used. It
+is called via @samp{bfd_print_private_data}. It prints any interesting
+information about the BFD which can not be otherwise represented by BFD
+and thus can not be printed by @samp{objdump}. Most targets do not do
+anything in this function.
+@end table
+
+@node BFD target vector core
+@subsection Core file support functions
+@cindex @samp{BFD_JUMP_TABLE_CORE}
+
+The @samp{BFD_JUMP_TABLE_CORE} macro is used for functions which deal
+with core files. Obviously, these functions only do something
+interesting for targets which have core file support.
+
+@table @samp
+@item _core_file_failing_command
+Given a core file, this returns the command which was run to produce the
+core file.
+
+@item _core_file_failing_signal
+Given a core file, this returns the signal number which produced the
+core file.
+
+@item _core_file_matches_executable_p
+Given a core file and a BFD for an executable, this returns whether the
+core file was generated by the executable.
+@end table
+
+@node BFD target vector archive
+@subsection Archive functions
+@cindex @samp{BFD_JUMP_TABLE_ARCHIVE}
+
+The @samp{BFD_JUMP_TABLE_ARCHIVE} macro is used for functions which deal
+with archive files. Most targets use COFF style archive files
+(including ELF targets), and these use @samp{_bfd_archive_coff} as the
+argument to @samp{BFD_JUMP_TABLE_ARCHIVE}. Some targets use BSD/a.out
+style archives, and these use @samp{_bfd_archive_bsd}. (The main
+difference between BSD and COFF archives is the format of the archive
+symbol table). Targets with no archive support use
+@samp{_bfd_noarchive}. Finally, a few targets have unusual archive
+handling.
+
+@table @samp
+@item _slurp_armap
+Read in the archive symbol table, storing it in private BFD data. This
+is normally called from the archive @samp{check_format} routine. The
+corresponding field in the target vector is named
+@samp{_bfd_slurp_armap}.
+
+@item _slurp_extended_name_table
+Read in the extended name table from the archive, if there is one,
+storing it in private BFD data. This is normally called from the
+archive @samp{check_format} routine. The corresponding field in the
+target vector is named @samp{_bfd_slurp_extended_name_table}.
+
+@item construct_extended_name_table
+Build and return an extended name table if one is needed to write out
+the archive. This also adjusts the archive headers to refer to the
+extended name table appropriately. This is normally called from the
+archive @samp{write_contents} routine. The corresponding field in the
+target vector is named @samp{_bfd_construct_extended_name_table}.
+
+@item _truncate_arname
+This copies a file name into an archive header, truncating it as
+required. It is normally called from the archive @samp{write_contents}
+routine. This function is more interesting in targets which do not
+support extended name tables, but I think the GNU @samp{ar} program
+always uses extended name tables anyhow. The corresponding field in the
+target vector is named @samp{_bfd_truncate_arname}.
+
+@item _write_armap
+Write out the archive symbol table using calls to @samp{bfd_write}.
+This is normally called from the archive @samp{write_contents} routine.
+The corresponding field in the target vector is named @samp{write_armap}
+(no leading underscore).
+
+@item _read_ar_hdr
+Read and parse an archive header. This handles expanding the archive
+header name into the real file name using the extended name table. This
+is called by routines which read the archive symbol table or the archive
+itself. The corresponding field in the target vector is named
+@samp{_bfd_read_ar_hdr_fn}.
+
+@item _openr_next_archived_file
+Given an archive and a BFD representing a file stored within the
+archive, return a BFD for the next file in the archive. This is called
+via @samp{bfd_openr_next_archived_file}. The corresponding field in the
+target vector is named @samp{openr_next_archived_file} (no leading
+underscore).
+
+@item _get_elt_at_index
+Given an archive and an index, return a BFD for the file in the archive
+corresponding to that entry in the archive symbol table. This is called
+via @samp{bfd_get_elt_at_index}. The corresponding field in the target
+vector is named @samp{_bfd_get_elt_at_index}.
+
+@item _generic_stat_arch_elt
+Do a stat on an element of an archive, returning information read from
+the archive header (modification time, uid, gid, file mode, size). This
+is called via @samp{bfd_stat_arch_elt}. The corresponding field in the
+target vector is named @samp{_bfd_stat_arch_elt}.
+
+@item _update_armap_timestamp
+After the entire contents of an archive have been written out, update
+the timestamp of the archive symbol table to be newer than that of the
+file. This is required for a.out style archives. This is normally
+called by the archive @samp{write_contents} routine. The corresponding
+field in the target vector is named @samp{_bfd_update_armap_timestamp}.
+@end table
+
+@node BFD target vector symbols
+@subsection Symbol table functions
+@cindex @samp{BFD_JUMP_TABLE_SYMBOLS}
+
+The @samp{BFD_JUMP_TABLE_SYMBOLS} macro is used for functions which deal
+with symbols.
+
+@table @samp
+@item _get_symtab_upper_bound
+Return a sensible upper bound on the amount of memory which will be
+required to read the symbol table. In practice most targets return the
+amount of memory required to hold @samp{asymbol} pointers for all the
+symbols plus a trailing @samp{NULL} entry, and store the actual symbol
+information in BFD private data. This is called via
+@samp{bfd_get_symtab_upper_bound}. The corresponding field in the
+target vector is named @samp{_bfd_get_symtab_upper_bound}.
+
+@item _get_symtab
+Read in the symbol table. This is called via
+@samp{bfd_canonicalize_symtab}. The corresponding field in the target
+vector is named @samp{_bfd_canonicalize_symtab}.
+
+@item _make_empty_symbol
+Create an empty symbol for the BFD. This is needed because most targets
+store extra information with each symbol by allocating a structure
+larger than an @samp{asymbol} and storing the extra information at the
+end. This function will allocate the right amount of memory, and return
+what looks like a pointer to an empty @samp{asymbol}. This is called
+via @samp{bfd_make_empty_symbol}. The corresponding field in the target
+vector is named @samp{_bfd_make_empty_symbol}.
+
+@item _print_symbol
+Print information about the symbol. This is called via
+@samp{bfd_print_symbol}. One of the arguments indicates what sort of
+information should be printed:
+
+@table @samp
+@item bfd_print_symbol_name
+Just print the symbol name.
+@item bfd_print_symbol_more
+Print the symbol name and some interesting flags. I don't think
+anything actually uses this.
+@item bfd_print_symbol_all
+Print all information about the symbol. This is used by @samp{objdump}
+when run with the @samp{-t} option.
+@end table
+The corresponding field in the target vector is named
+@samp{_bfd_print_symbol}.
+
+@item _get_symbol_info
+Return a standard set of information about the symbol. This is called
+via @samp{bfd_symbol_info}. The corresponding field in the target
+vector is named @samp{_bfd_get_symbol_info}.
+
+@item _bfd_is_local_label_name
+Return whether the given string would normally represent the name of a
+local label. This is called via @samp{bfd_is_local_label} and
+@samp{bfd_is_local_label_name}. Local labels are normally discarded by
+the assembler. In the linker, this defines the difference between the
+@samp{-x} and @samp{-X} options.
+
+@item _get_lineno
+Return line number information for a symbol. This is only meaningful
+for a COFF target. This is called when writing out COFF line numbers.
+
+@item _find_nearest_line
+Given an address within a section, use the debugging information to find
+the matching file name, function name, and line number, if any. This is
+called via @samp{bfd_find_nearest_line}. The corresponding field in the
+target vector is named @samp{_bfd_find_nearest_line}.
+
+@item _bfd_make_debug_symbol
+Make a debugging symbol. This is only meaningful for a COFF target,
+where it simply returns a symbol which will be placed in the
+@samp{N_DEBUG} section when it is written out. This is called via
+@samp{bfd_make_debug_symbol}.
+
+@item _read_minisymbols
+Minisymbols are used to reduce the memory requirements of programs like
+@samp{nm}. A minisymbol is a cookie pointing to internal symbol
+information which the caller can use to extract complete symbol
+information. This permits BFD to not convert all the symbols into
+generic form, but to instead convert them one at a time. This is called
+via @samp{bfd_read_minisymbols}. Most targets do not implement this,
+and just use generic support which is based on using standard
+@samp{asymbol} structures.
+
+@item _minisymbol_to_symbol
+Convert a minisymbol to a standard @samp{asymbol}. This is called via
+@samp{bfd_minisymbol_to_symbol}.
+@end table
+
+@node BFD target vector relocs
+@subsection Relocation support
+@cindex @samp{BFD_JUMP_TABLE_RELOCS}
+
+The @samp{BFD_JUMP_TABLE_RELOCS} macro is used for functions which deal
+with relocations.
+
+@table @samp
+@item _get_reloc_upper_bound
+Return a sensible upper bound on the amount of memory which will be
+required to read the relocations for a section. In practice most
+targets return the amount of memory required to hold @samp{arelent}
+pointers for all the relocations plus a trailing @samp{NULL} entry, and
+store the actual relocation information in BFD private data. This is
+called via @samp{bfd_get_reloc_upper_bound}.
+
+@item _canonicalize_reloc
+Return the relocation information for a section. This is called via
+@samp{bfd_canonicalize_reloc}. The corresponding field in the target
+vector is named @samp{_bfd_canonicalize_reloc}.
+
+@item _bfd_reloc_type_lookup
+Given a relocation code, return the corresponding howto structure
+(@pxref{BFD relocation codes}). This is called via
+@samp{bfd_reloc_type_lookup}. The corresponding field in the target
+vector is named @samp{reloc_type_lookup}.
+@end table
+
+@node BFD target vector write
+@subsection Output functions
+@cindex @samp{BFD_JUMP_TABLE_WRITE}
+
+The @samp{BFD_JUMP_TABLE_WRITE} macro is used for functions which deal
+with writing out a BFD.
+
+@table @samp
+@item _set_arch_mach
+Set the architecture and machine number for a BFD. This is called via
+@samp{bfd_set_arch_mach}. Most targets implement this by calling
+@samp{bfd_default_set_arch_mach}. The corresponding field in the target
+vector is named @samp{_bfd_set_arch_mach}.
+
+@item _set_section_contents
+Write out the contents of a section. This is called via
+@samp{bfd_set_section_contents}. The corresponding field in the target
+vector is named @samp{_bfd_set_section_contents}.
+@end table
+
+@node BFD target vector link
+@subsection Linker functions
+@cindex @samp{BFD_JUMP_TABLE_LINK}
+
+The @samp{BFD_JUMP_TABLE_LINK} macro is used for functions called by the
+linker.
+
+@table @samp
+@item _sizeof_headers
+Return the size of the header information required for a BFD. This is
+used to implement the @samp{SIZEOF_HEADERS} linker script function. It
+is normally used to align the first section at an efficient position on
+the page. This is called via @samp{bfd_sizeof_headers}. The
+corresponding field in the target vector is named
+@samp{_bfd_sizeof_headers}.
+
+@item _bfd_get_relocated_section_contents
+Read the contents of a section and apply the relocation information.
+This handles both a final link and a relocateable link; in the latter
+case, it adjust the relocation information as well. This is called via
+@samp{bfd_get_relocated_section_contents}. Most targets implement it by
+calling @samp{bfd_generic_get_relocated_section_contents}.
+
+@item _bfd_relax_section
+Try to use relaxation to shrink the size of a section. This is called
+by the linker when the @samp{-relax} option is used. This is called via
+@samp{bfd_relax_section}. Most targets do not support any sort of
+relaxation.
+
+@item _bfd_link_hash_table_create
+Create the symbol hash table to use for the linker. This linker hook
+permits the backend to control the size and information of the elements
+in the linker symbol hash table. This is called via
+@samp{bfd_link_hash_table_create}.
+
+@item _bfd_link_add_symbols
+Given an object file or an archive, add all symbols into the linker
+symbol hash table. Use callbacks to the linker to include archive
+elements in the link. This is called via @samp{bfd_link_add_symbols}.
+
+@item _bfd_final_link
+Finish the linking process. The linker calls this hook after all of the
+input files have been read, when it is ready to finish the link and
+generate the output file. This is called via @samp{bfd_final_link}.
+
+@item _bfd_link_split_section
+I don't know what this is for. Nothing seems to call it. The only
+non-trivial definition is in @file{som.c}.
+@end table
+
+@node BFD target vector dynamic
+@subsection Dynamic linking information functions
+@cindex @samp{BFD_JUMP_TABLE_DYNAMIC}
+
+The @samp{BFD_JUMP_TABLE_DYNAMIC} macro is used for functions which read
+dynamic linking information.
+
+@table @samp
+@item _get_dynamic_symtab_upper_bound
+Return a sensible upper bound on the amount of memory which will be
+required to read the dynamic symbol table. In practice most targets
+return the amount of memory required to hold @samp{asymbol} pointers for
+all the symbols plus a trailing @samp{NULL} entry, and store the actual
+symbol information in BFD private data. This is called via
+@samp{bfd_get_dynamic_symtab_upper_bound}. The corresponding field in
+the target vector is named @samp{_bfd_get_dynamic_symtab_upper_bound}.
+
+@item _canonicalize_dynamic_symtab
+Read the dynamic symbol table. This is called via
+@samp{bfd_canonicalize_dynamic_symtab}. The corresponding field in the
+target vector is named @samp{_bfd_canonicalize_dynamic_symtab}.
+
+@item _get_dynamic_reloc_upper_bound
+Return a sensible upper bound on the amount of memory which will be
+required to read the dynamic relocations. In practice most targets
+return the amount of memory required to hold @samp{arelent} pointers for
+all the relocations plus a trailing @samp{NULL} entry, and store the
+actual relocation information in BFD private data. This is called via
+@samp{bfd_get_dynamic_reloc_upper_bound}. The corresponding field in
+the target vector is named @samp{_bfd_get_dynamic_reloc_upper_bound}.
+
+@item _canonicalize_dynamic_reloc
+Read the dynamic relocations. This is called via
+@samp{bfd_canonicalize_dynamic_reloc}. The corresponding field in the
+target vector is named @samp{_bfd_canonicalize_dynamic_reloc}.
+@end table
+
+@node BFD generated files
+@section BFD generated files
+@cindex generated files in bfd
+@cindex bfd generated files
+
+BFD contains several automatically generated files. This section
+describes them. Some files are created at configure time, when you
+configure BFD. Some files are created at make time, when you build
+time. Some files are automatically rebuilt at make time, but only if
+you configure with the @samp{--enable-maintainer-mode} option. Some
+files live in the object directory---the directory from which you run
+configure---and some live in the source directory. All files that live
+in the source directory are checked into the CVS repository.
+
+@table @file
+@item bfd.h
+@cindex @file{bfd.h}
+@cindex @file{bfd-in3.h}
+Lives in the object directory. Created at make time from
+@file{bfd-in2.h} via @file{bfd-in3.h}. @file{bfd-in3.h} is created at
+configure time from @file{bfd-in2.h}. There are automatic dependencies
+to rebuild @file{bfd-in3.h} and hence @file{bfd.h} if @file{bfd-in2.h}
+changes, so you can normally ignore @file{bfd-in3.h}, and just think
+about @file{bfd-in2.h} and @file{bfd.h}.
+
+@file{bfd.h} is built by replacing a few strings in @file{bfd-in2.h}.
+To see them, search for @samp{@@} in @file{bfd-in2.h}. They mainly
+control whether BFD is built for a 32 bit target or a 64 bit target.
+
+@item bfd-in2.h
+@cindex @file{bfd-in2.h}
+Lives in the source directory. Created from @file{bfd-in.h} and several
+other BFD source files. If you configure with the
+@samp{--enable-maintainer-mode} option, @file{bfd-in2.h} is rebuilt
+automatically when a source file changes.
+
+@item elf32-target.h
+@itemx elf64-target.h
+@cindex @file{elf32-target.h}
+@cindex @file{elf64-target.h}
+Live in the object directory. Created from @file{elfxx-target.h}.
+These files are versions of @file{elfxx-target.h} customized for either
+a 32 bit ELF target or a 64 bit ELF target.
+
+@item libbfd.h
+@cindex @file{libbfd.h}
+Lives in the source directory. Created from @file{libbfd-in.h} and
+several other BFD source files. If you configure with the
+@samp{--enable-maintainer-mode} option, @file{libbfd.h} is rebuilt
+automatically when a source file changes.
+
+@item libcoff.h
+@cindex @file{libcoff.h}
+Lives in the source directory. Created from @file{libcoff-in.h} and
+@file{coffcode.h}. If you configure with the
+@samp{--enable-maintainer-mode} option, @file{libcoff.h} is rebuilt
+automatically when a source file changes.
+
+@item targmatch.h
+@cindex @file{targmatch.h}
+Lives in the object directory. Created at make time from
+@file{config.bfd}. This file is used to map configuration triplets into
+BFD target vector variable names at run time.
+@end table
+
+@node BFD multiple compilations
+@section Files compiled multiple times in BFD
+Several files in BFD are compiled multiple times. By this I mean that
+there are header files which contain function definitions. These header
+files are included by other files, and thus the functions are compiled
+once per file which includes them.
+
+Preprocessor macros are used to control the compilation, so that each
+time the files are compiled the resulting functions are slightly
+different. Naturally, if they weren't different, there would be no
+reason to compile them multiple times.
+
+This is a not a particularly good programming technique, and future BFD
+work should avoid it.
+
+@itemize @bullet
+@item
+Since this technique is rarely used, even experienced C programmers find
+it confusing.
+
+@item
+It is difficult to debug programs which use BFD, since there is no way
+to describe which version of a particular function you are looking at.
+
+@item
+Programs which use BFD wind up incorporating two or more slightly
+different versions of the same function, which wastes space in the
+executable.
+
+@item
+This technique is never required nor is it especially efficient. It is
+always possible to use statically initialized structures holding
+function pointers and magic constants instead.
+@end itemize
+
+The following is a list of the files which are compiled multiple times.
+
+@table @file
+@item aout-target.h
+@cindex @file{aout-target.h}
+Describes a few functions and the target vector for a.out targets. This
+is used by individual a.out targets with different definitions of
+@samp{N_TXTADDR} and similar a.out macros.
+
+@item aoutf1.h
+@cindex @file{aoutf1.h}
+Implements standard SunOS a.out files. In principle it supports 64 bit
+a.out targets based on the preprocessor macro @samp{ARCH_SIZE}, but
+since all known a.out targets are 32 bits, this code may or may not
+work. This file is only included by a few other files, and it is
+difficult to justify its existence.
+
+@item aoutx.h
+@cindex @file{aoutx.h}
+Implements basic a.out support routines. This file can be compiled for
+either 32 or 64 bit support. Since all known a.out targets are 32 bits,
+the 64 bit support may or may not work. I believe the original
+intention was that this file would only be included by @samp{aout32.c}
+and @samp{aout64.c}, and that other a.out targets would simply refer to
+the functions it defined. Unfortunately, some other a.out targets
+started including it directly, leading to a somewhat confused state of
+affairs.
+
+@item coffcode.h
+@cindex @file{coffcode.h}
+Implements basic COFF support routines. This file is included by every
+COFF target. It implements code which handles COFF magic numbers as
+well as various hook functions called by the generic COFF functions in
+@file{coffgen.c}. This file is controlled by a number of different
+macros, and more are added regularly.
+
+@item coffswap.h
+@cindex @file{coffswap.h}
+Implements COFF swapping routines. This file is included by
+@file{coffcode.h}, and thus by every COFF target. It implements the
+routines which swap COFF structures between internal and external
+format. The main control for this file is the external structure
+definitions in the files in the @file{include/coff} directory. A COFF
+target file will include one of those files before including
+@file{coffcode.h} and thus @file{coffswap.h}. There are a few other
+macros which affect @file{coffswap.h} as well, mostly describing whether
+certain fields are present in the external structures.
+
+@item ecoffswap.h
+@cindex @file{ecoffswap.h}
+Implements ECOFF swapping routines. This is like @file{coffswap.h}, but
+for ECOFF. It is included by the ECOFF target files (of which there are
+only two). The control is the preprocessor macro @samp{ECOFF_32} or
+@samp{ECOFF_64}.
+
+@item elfcode.h
+@cindex @file{elfcode.h}
+Implements ELF functions that use external structure definitions. This
+file is included by two other files: @file{elf32.c} and @file{elf64.c}.
+It is controlled by the @samp{ARCH_SIZE} macro which is defined to be
+@samp{32} or @samp{64} before including it. The @samp{NAME} macro is
+used internally to give the functions different names for the two target
+sizes.
+
+@item elfcore.h
+@cindex @file{elfcore.h}
+Like @file{elfcode.h}, but for functions that are specific to ELF core
+files. This is included only by @file{elfcode.h}.
+
+@item elflink.h
+@cindex @file{elflink.h}
+Like @file{elfcode.h}, but for functions used by the ELF linker. This
+is included only by @file{elfcode.h}.
+
+@item elfxx-target.h
+@cindex @file{elfxx-target.h}
+This file is the source for the generated files @file{elf32-target.h}
+and @file{elf64-target.h}, one of which is included by every ELF target.
+It defines the ELF target vector.
+
+@item freebsd.h
+@cindex @file{freebsd.h}
+Presumably intended to be included by all FreeBSD targets, but in fact
+there is only one such target, @samp{i386-freebsd}. This defines a
+function used to set the right magic number for FreeBSD, as well as
+various macros, and includes @file{aout-target.h}.
+
+@item netbsd.h
+@cindex @file{netbsd.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.
+@file{coffcode.h} will include this rather than @file{coffswap.h} for a
+PE target. This defines PE specific versions of the COFF swapping
+routines, and also defines some macros which control @file{coffcode.h}
+itself.
+@end table
+
+@node BFD relocation handling
+@section BFD relocation handling
+@cindex bfd relocation handling
+@cindex relocations in bfd
+
+The handling of relocations is one of the more confusing aspects of BFD.
+Relocation handling has been implemented in various different ways, all
+somewhat incompatible, none perfect.
+
+@menu
+* BFD relocation concepts:: BFD relocation concepts
+* BFD relocation functions:: BFD relocation functions
+* BFD relocation codes:: BFD relocation codes
+* BFD relocation future:: BFD relocation future
+@end menu
+
+@node BFD relocation concepts
+@subsection BFD relocation concepts
+
+A relocation is an action which the linker must take when linking. It
+describes a change to the contents of a section. The change is normally
+based on the final value of one or more symbols. Relocations are
+created by the assembler when it creates an object file.
+
+Most relocations are simple. A typical simple relocation is to set 32
+bits at a given offset in a section to the value of a symbol. This type
+of relocation would be generated for code like @code{int *p = &i;} where
+@samp{p} and @samp{i} are global variables. A relocation for the symbol
+@samp{i} would be generated such that the linker would initialize the
+area of memory which holds the value of @samp{p} to the value of the
+symbol @samp{i}.
+
+Slightly more complex relocations may include an addend, which is a
+constant to add to the symbol value before using it. In some cases a
+relocation will require adding the symbol value to the existing contents
+of the section in the object file. In others the relocation will simply
+replace the contents of the section with the symbol value. Some
+relocations are PC relative, so that the value to be stored in the
+section is the difference between the value of a symbol and the final
+address of the section contents.
+
+In general, relocations can be arbitrarily complex. For example,
+relocations used in dynamic linking systems often require the linker to
+allocate space in a different section and use the offset within that
+section as the value to store. In the IEEE object file format,
+relocations may involve arbitrary expressions.
+
+When doing a relocateable link, the linker may or may not have to do
+anything with a relocation, depending upon the definition of the
+relocation. Simple relocations generally do not require any special
+action.
+
+@node BFD relocation functions
+@subsection BFD relocation functions
+
+In BFD, each section has an array of @samp{arelent} structures. Each
+structure has a pointer to a symbol, an address within the section, an
+addend, and a pointer to a @samp{reloc_howto_struct} structure. The
+howto structure has a bunch of fields describing the reloc, including a
+type field. The type field is specific to the object file format
+backend; none of the generic code in BFD examines it.
+
+Originally, the function @samp{bfd_perform_relocation} was supposed to
+handle all relocations. In theory, many relocations would be simple
+enough to be described by the fields in the howto structure. For those
+that weren't, the howto structure included a @samp{special_function}
+field to use as an escape.
+
+While this seems plausible, a look at @samp{bfd_perform_relocation}
+shows that it failed. The function has odd special cases. Some of the
+fields in the howto structure, such as @samp{pcrel_offset}, were not
+adequately documented.
+
+The linker uses @samp{bfd_perform_relocation} to do all relocations when
+the input and output file have different formats (e.g., when generating
+S-records). The generic linker code, which is used by all targets which
+do not define their own special purpose linker, uses
+@samp{bfd_get_relocated_section_contents}, which for most targets turns
+into a call to @samp{bfd_generic_get_relocated_section_contents}, which
+calls @samp{bfd_perform_relocation}. So @samp{bfd_perform_relocation}
+is still widely used, which makes it difficult to change, since it is
+difficult to test all possible cases.
+
+The assembler used @samp{bfd_perform_relocation} for a while. This
+turned out to be the wrong thing to do, since
+@samp{bfd_perform_relocation} was written to handle relocations on an
+existing object file, while the assembler needed to create relocations
+in a new object file. The assembler was changed to use the new function
+@samp{bfd_install_relocation} instead, and @samp{bfd_install_relocation}
+was created as a copy of @samp{bfd_perform_relocation}.
+
+Unfortunately, the work did not progress any farther, so
+@samp{bfd_install_relocation} remains a simple copy of
+@samp{bfd_perform_relocation}, with all the odd special cases and
+confusing code. This again is difficult to change, because again any
+change can affect any assembler target, and so is difficult to test.
+
+The new linker, when using the same object file format for all input
+files and the output file, does not convert relocations into
+@samp{arelent} structures, so it can not use
+@samp{bfd_perform_relocation} at all. Instead, users of the new linker
+are expected to write a @samp{relocate_section} function which will
+handle relocations in a target specific fashion.
+
+There are two helper functions for target specific relocation:
+@samp{_bfd_final_link_relocate} and @samp{_bfd_relocate_contents}.
+These functions use a howto structure, but they @emph{do not} use the
+@samp{special_function} field. Since the functions are normally called
+from target specific code, the @samp{special_function} field adds
+little; any relocations which require special handling can be handled
+without calling those functions.
+
+So, if you want to add a new target, or add a new relocation to an
+existing target, you need to do the following:
+
+@itemize @bullet
+@item
+Make sure you clearly understand what the contents of the section should
+look like after assembly, after a relocateable link, and after a final
+link. Make sure you clearly understand the operations the linker must
+perform during a relocateable link and during a final link.
+
+@item
+Write a howto structure for the relocation. The howto structure is
+flexible enough to represent any relocation which should be handled by
+setting a contiguous bitfield in the destination to the value of a
+symbol, possibly with an addend, possibly adding the symbol value to the
+value already present in the destination.
+
+@item
+Change the assembler to generate your relocation. The assembler will
+call @samp{bfd_install_relocation}, so your howto structure has to be
+able to handle that. You may need to set the @samp{special_function}
+field to handle assembly correctly. Be careful to ensure that any code
+you write to handle the assembler will also work correctly when doing a
+relocateable link. For example, see @samp{bfd_elf_generic_reloc}.
+
+@item
+Test the assembler. Consider the cases of relocation against an
+undefined symbol, a common symbol, a symbol defined in the object file
+in the same section, and a symbol defined in the object file in a
+different section. These cases may not all be applicable for your
+reloc.
+
+@item
+If your target uses the new linker, which is recommended, add any
+required handling to the target specific relocation function. In simple
+cases this will just involve a call to @samp{_bfd_final_link_relocate}
+or @samp{_bfd_relocate_contents}, depending upon the definition of the
+relocation and whether the link is relocateable or not.
+
+@item
+Test the linker. Test the case of a final link. If the relocation can
+overflow, use a linker script to force an overflow and make sure the
+error is reported correctly. Test a relocateable link, whether the
+symbol is defined or undefined in the relocateable output. For both the
+final and relocateable link, test the case when the symbol is a common
+symbol, when the symbol looked like a common symbol but became a defined
+symbol, when the symbol is defined in a different object file, and when
+the symbol is defined in the same object file.
+
+@item
+In order for linking to another object file format, such as S-records,
+to work correctly, @samp{bfd_perform_relocation} has to do the right
+thing for the relocation. You may need to set the
+@samp{special_function} field to handle this correctly. Test this by
+doing a link in which the output object file format is S-records.
+
+@item
+Using the linker to generate relocateable output in a different object
+file format is impossible in the general case, so you generally don't
+have to worry about that. Linking input files of different object file
+formats together is quite unusual, but if you're really dedicated you
+may want to consider testing this case, both when the output object file
+format is the same as your format, and when it is different.
+@end itemize
+
+@node BFD relocation codes
+@subsection BFD relocation codes
+
+BFD has another way of describing relocations besides the howto
+structures described above: the enum @samp{bfd_reloc_code_real_type}.
+
+Every known relocation type can be described as a value in this
+enumeration. The enumeration contains many target specific relocations,
+but where two or more targets have the same relocation, a single code is
+used. For example, the single value @samp{BFD_RELOC_32} is used for all
+simple 32 bit relocation types.
+
+The main purpose of this relocation code is to give the assembler some
+mechanism to create @samp{arelent} structures. In order for the
+assembler to create an @samp{arelent} structure, it has to be able to
+obtain a howto structure. The function @samp{bfd_reloc_type_lookup},
+which simply calls the target vector entry point
+@samp{reloc_type_lookup}, takes a relocation code and returns a howto
+structure.
+
+The function @samp{bfd_get_reloc_code_name} returns the name of a
+relocation code. This is mainly used in error messages.
+
+Using both howto structures and relocation codes can be somewhat
+confusing. There are many processor specific relocation codes.
+However, the relocation is only fully defined by the howto structure.
+The same relocation code will map to different howto structures in
+different object file formats. For example, the addend handling may be
+different.
+
+Most of the relocation codes are not really general. The assembler can
+not use them without already understanding what sorts of relocations can
+be used for a particular target. It might be possible to replace the
+relocation codes with something simpler.
+
+@node BFD relocation future
+@subsection BFD relocation future
+
+Clearly the current BFD relocation support is in bad shape. A
+wholescale rewrite would be very difficult, because it would require
+thorough testing of every BFD target. So some sort of incremental
+change is required.
+
+My vague thoughts on this would involve defining a new, clearly defined,
+howto structure. Some mechanism would be used to determine which type
+of howto structure was being used by a particular format.
+
+The new howto structure would clearly define the relocation behaviour in
+the case of an assembly, a relocateable link, and a final link. At
+least one special function would be defined as an escape, and it might
+make sense to define more.
+
+One or more generic functions similar to @samp{bfd_perform_relocation}
+would be written to handle the new howto structure.
+
+This should make it possible to write a generic version of the relocate
+section functions used by the new linker. The target specific code
+would provide some mechanism (a function pointer or an initial
+conversion) to convert target specific relocations into howto
+structures.
+
+Ideally it would be possible to use this generic relocate section
+function for the generic linker as well. That is, it would replace the
+@samp{bfd_generic_get_relocated_section_contents} function which is
+currently normally used.
+
+For the special case of ELF dynamic linking, more consideration needs to
+be given to writing ELF specific but ELF target generic code to handle
+special relocation types such as GOT and PLT.
+
+@node BFD ELF support
+@section BFD ELF support
+@cindex elf support in bfd
+@cindex bfd elf support
+
+The ELF object file format is defined in two parts: a generic ABI and a
+processor specific supplement. The ELF support in BFD is split in a
+similar fashion. The processor specific support is largely kept within
+a single file. The generic support is provided by several other files.
+The processor specific support provides a set of function pointers and
+constants used by the generic support.
+
+@menu
+* BFD ELF sections and segments:: ELF sections and segments
+* BFD ELF generic support:: BFD ELF generic support
+* BFD ELF processor specific support:: BFD ELF processor specific support
+* BFD ELF core files:: BFD ELF core files
+* BFD ELF future:: BFD ELF future
+@end menu
+
+@node BFD ELF sections and segments
+@subsection ELF sections and segments
+
+The ELF ABI permits a file to have either sections or segments or both.
+Relocateable object files conventionally have only sections.
+Executables conventionally have both. Core files conventionally have
+only program segments.
+
+ELF sections are similar to sections in other object file formats: they
+have a name, a VMA, file contents, flags, and other miscellaneous
+information. ELF relocations are stored in sections of a particular
+type; BFD automatically converts these sections into internal relocation
+information.
+
+ELF program segments are intended for fast interpretation by a system
+loader. They have a type, a VMA, an LMA, file contents, and a couple of
+other fields. When an ELF executable is run on a Unix system, the
+system loader will examine the program segments to decide how to load
+it. The loader will ignore the section information. Loadable program
+segments (type @samp{PT_LOAD}) are directly loaded into memory. Other
+program segments are interpreted by the loader, and generally provide
+dynamic linking information.
+
+When an ELF file has both program segments and sections, an ELF program
+segment may encompass one or more ELF sections, in the sense that the
+portion of the file which corresponds to the program segment may include
+the portions of the file corresponding to one or more sections. When
+there is more than one section in a loadable program segment, the
+relative positions of the section contents in the file must correspond
+to the relative positions they should hold when the program segment is
+loaded. This requirement should be obvious if you consider that the
+system loader will load an entire program segment at a time.
+
+On a system which supports dynamic paging, such as any native Unix
+system, the contents of a loadable program segment must be at the same
+offset in the file as in memory, modulo the memory page size used on the
+system. This is because the system loader will map the file into memory
+starting at the start of a page. The system loader can easily remap
+entire pages to the correct load address. However, if the contents of
+the file were not correctly aligned within the page, the system loader
+would have to shift the contents around within the page, which is too
+expensive. For example, if the LMA of a loadable program segment is
+@samp{0x40080} and the page size is @samp{0x1000}, then the position of
+the segment contents within the file must equal @samp{0x80} modulo
+@samp{0x1000}.
+
+BFD has only a single set of sections. It does not provide any generic
+way to examine both sections and segments. When BFD is used to open an
+object file or executable, the BFD sections will represent ELF sections.
+When BFD is used to open a core file, the BFD sections will represent
+ELF program segments.
+
+When BFD is used to examine an object file or executable, any program
+segments will be read to set the LMA of the sections. This is because
+ELF sections only have a VMA, while ELF program segments have both a VMA
+and an LMA. Any program segments will be copied by the
+@samp{copy_private} entry points. They will be printed by the
+@samp{print_private} entry point. Otherwise, the program segments are
+ignored. In particular, programs which use BFD currently have no direct
+access to the program segments.
+
+When BFD is used to create an executable, the program segments will be
+created automatically based on the section information. This is done in
+the function @samp{assign_file_positions_for_segments} in @file{elf.c}.
+This function has been tweaked many times, and probably still has
+problems that arise in particular cases.
+
+There is a hook which may be used to explicitly define the program
+segments when creating an executable: the @samp{bfd_record_phdr}
+function in @file{bfd.c}. If this function is called, BFD will not
+create program segments itself, but will only create the program
+segments specified by the caller. The linker uses this function to
+implement the @samp{PHDRS} linker script command.
+
+@node BFD ELF generic support
+@subsection BFD ELF generic support
+
+In general, functions which do not read external data from the ELF file
+are found in @file{elf.c}. They operate on the internal forms of the
+ELF structures, which are defined in @file{include/elf/internal.h}. The
+internal structures are defined in terms of @samp{bfd_vma}, and so may
+be used for both 32 bit and 64 bit ELF targets.
+
+The file @file{elfcode.h} contains functions which operate on the
+external data. @file{elfcode.h} is compiled twice, once via
+@file{elf32.c} with @samp{ARCH_SIZE} defined as @samp{32}, and once via
+@file{elf64.c} with @samp{ARCH_SIZE} defined as @samp{64}.
+@file{elfcode.h} includes functions to swap the ELF structures in and
+out of external form, as well as a few more complex functions.
+
+Linker support is found in @file{elflink.c} and @file{elflink.h}. The
+latter file is compiled twice, for both 32 and 64 bit support. The
+linker support is only used if the processor specific file defines
+@samp{elf_backend_relocate_section}, which is required to relocate the
+section contents. If that macro is not defined, the generic linker code
+is used, and relocations are handled via @samp{bfd_perform_relocation}.
+
+The core file support is in @file{elfcore.h}, which is compiled twice,
+for both 32 and 64 bit support. The more interesting cases of core file
+support only work on a native system which has the @file{sys/procfs.h}
+header file. Without that file, the core file support does little more
+than read the ELF program segments as BFD sections.
+
+The BFD internal header file @file{elf-bfd.h} is used for communication
+among these files and the processor specific files.
+
+The default entries for the BFD ELF target vector are found mainly in
+@file{elf.c}. Some functions are found in @file{elfcode.h}.
+
+The processor specific files may override particular entries in the
+target vector, but most do not, with one exception: the
+@samp{bfd_reloc_type_lookup} entry point is always processor specific.
+
+@node BFD ELF processor specific support
+@subsection BFD ELF processor specific support
+
+By convention, the processor specific support for a particular processor
+will be found in @file{elf@var{nn}-@var{cpu}.c}, where @var{nn} is
+either 32 or 64, and @var{cpu} is the name of the processor.
+
+@menu
+* BFD ELF processor required:: Required processor specific support
+* BFD ELF processor linker:: Processor specific linker support
+* BFD ELF processor other:: Other processor specific support options
+@end menu
+
+@node BFD ELF processor required
+@subsubsection Required processor specific support
+
+When writing a @file{elf@var{nn}-@var{cpu}.c} file, you must do the
+following:
+
+@itemize @bullet
+@item
+Define either @samp{TARGET_BIG_SYM} or @samp{TARGET_LITTLE_SYM}, or
+both, to a unique C name to use for the target vector. This name should
+appear in the list of target vectors in @file{targets.c}, and will also
+have to appear in @file{config.bfd} and @file{configure.in}. Define
+@samp{TARGET_BIG_SYM} for a big-endian processor,
+@samp{TARGET_LITTLE_SYM} for a little-endian processor, and define both
+for a bi-endian processor.
+@item
+Define either @samp{TARGET_BIG_NAME} or @samp{TARGET_LITTLE_NAME}, or
+both, to a string used as the name of the target vector. This is the
+name which a user of the BFD tool would use to specify the object file
+format. It would normally appear in a linker emulation parameters
+file.
+@item
+Define @samp{ELF_ARCH} to the BFD architecture (an element of the
+@samp{bfd_architecture} enum, typically @samp{bfd_arch_@var{cpu}}).
+@item
+Define @samp{ELF_MACHINE_CODE} to the magic number which should appear
+in the @samp{e_machine} field of the ELF header. As of this writing,
+these magic numbers are assigned by SCO; if you want to get a magic
+number for a particular processor, try sending a note to
+@email{registry@@sco.com}. In the BFD sources, the magic numbers are
+found in @file{include/elf/common.h}; they have names beginning with
+@samp{EM_}.
+@item
+Define @samp{ELF_MAXPAGESIZE} to the maximum size of a virtual page in
+memory. This can normally be found at the start of chapter 5 in the
+processor specific supplement. For a processor which will only be used
+in an embedded system, or which has no memory management hardware, this
+can simply be @samp{1}.
+@item
+If the format should use @samp{Rel} rather than @samp{Rela} relocations,
+define @samp{USE_REL}. This is normally defined in chapter 4 of the
+processor specific supplement.
+
+In the absence of a supplement, it's easier to work with @samp{Rela}
+relocations. @samp{Rela} relocations will require more space in object
+files (but not in executables, except when using dynamic linking).
+However, this is outweighed by the simplicity of addend handling when
+using @samp{Rela} relocations. With @samp{Rel} relocations, the addend
+must be stored in the section contents, which makes relocateable links
+more complex.
+
+For example, consider C code like @code{i = a[1000];} where @samp{a} is
+a global array. The instructions which load the value of @samp{a[1000]}
+will most likely use a relocation which refers to the symbol
+representing @samp{a}, with an addend that gives the offset from the
+start of @samp{a} to element @samp{1000}. When using @samp{Rel}
+relocations, that addend must be stored in the instructions themselves.
+If you are adding support for a RISC chip which uses two or more
+instructions to load an address, then the addend may not fit in a single
+instruction, and will have to be somehow split among the instructions.
+This makes linking awkward, particularly when doing a relocateable link
+in which the addend may have to be updated. It can be done---the MIPS
+ELF support does it---but it should be avoided when possible.
+
+It is possible, though somewhat awkward, to support both @samp{Rel} and
+@samp{Rela} relocations for a single target; @file{elf64-mips.c} does it
+by overriding the relocation reading and writing routines.
+@item
+Define howto structures for all the relocation types.
+@item
+Define a @samp{bfd_reloc_type_lookup} routine. This must be named
+@samp{bfd_elf@var{nn}_bfd_reloc_type_lookup}, and may be either a
+function or a macro. It must translate a BFD relocation code into a
+howto structure. This is normally a table lookup or a simple switch.
+@item
+If using @samp{Rel} relocations, define @samp{elf_info_to_howto_rel}.
+If using @samp{Rela} relocations, define @samp{elf_info_to_howto}.
+Either way, this is a macro defined as the name of a function which
+takes an @samp{arelent} and a @samp{Rel} or @samp{Rela} structure, and
+sets the @samp{howto} field of the @samp{arelent} based on the
+@samp{Rel} or @samp{Rela} structure. This is normally uses
+@samp{ELF@var{nn}_R_TYPE} to get the ELF relocation type and uses it as
+an index into a table of howto structures.
+@end itemize
+
+You must also add the magic number for this processor to the
+@samp{prep_headers} function in @file{elf.c}.
+
+You must also create a header file in the @file{include/elf} directory
+called @file{@var{cpu}.h}. This file should define any target specific
+information which may be needed outside of the BFD code. In particular
+it should use the @samp{START_RELOC_NUMBERS}, @samp{RELOC_NUMBER},
+@samp{FAKE_RELOC}, @samp{EMPTY_RELOC} and @samp{END_RELOC_NUMBERS}
+macros to create a table mapping the number used to indentify a
+relocation to a name describing that relocation.
+
+@node BFD ELF processor linker
+@subsubsection Processor specific linker support
+
+The linker will be much more efficient if you define a relocate section
+function. This will permit BFD to use the ELF specific linker support.
+
+If you do not define a relocate section function, BFD must use the
+generic linker support, which requires converting all symbols and
+relocations into BFD @samp{asymbol} and @samp{arelent} structures. In
+this case, relocations will be handled by calling
+@samp{bfd_perform_relocation}, which will use the howto structures you
+have defined. @xref{BFD relocation handling}.
+
+In order to support linking into a different object file format, such as
+S-records, @samp{bfd_perform_relocation} must work correctly with your
+howto structures, so you can't skip that step. However, if you define
+the relocate section function, then in the normal case of linking into
+an ELF file the linker will not need to convert symbols and relocations,
+and will be much more efficient.
+
+To use a relocation section function, define the macro
+@samp{elf_backend_relocate_section} as the name of a function which will
+take the contents of a section, as well as relocation, symbol, and other
+information, and modify the section contents according to the relocation
+information. In simple cases, this is little more than a loop over the
+relocations which computes the value of each relocation and calls
+@samp{_bfd_final_link_relocate}. The function must check for a
+relocateable link, and in that case normally needs to do nothing other
+than adjust the addend for relocations against a section symbol.
+
+The complex cases generally have to do with dynamic linker support. GOT
+and PLT relocations must be handled specially, and the linker normally
+arranges to set up the GOT and PLT sections while handling relocations.
+When generating a shared library, random relocations must normally be
+copied into the shared library, or converted to RELATIVE relocations
+when possible.
+
+@node BFD ELF processor other
+@subsubsection Other processor specific support options
+
+There are many other macros which may be defined in
+@file{elf@var{nn}-@var{cpu}.c}. These macros may be found in
+@file{elfxx-target.h}.
+
+Macros may be used to override some of the generic ELF target vector
+functions.
+
+Several processor specific hook functions which may be defined as
+macros. These functions are found as function pointers in the
+@samp{elf_backend_data} structure defined in @file{elf-bfd.h}. In
+general, a hook function is set by defining a macro
+@samp{elf_backend_@var{name}}.
+
+There are a few processor specific constants which may also be defined.
+These are again found in the @samp{elf_backend_data} structure.
+
+I will not define the various functions and constants here; see the
+comments in @file{elf-bfd.h}.
+
+Normally any odd characteristic of a particular ELF processor is handled
+via a hook function. For example, the special @samp{SHN_MIPS_SCOMMON}
+section number found in MIPS ELF is handled via the hooks
+@samp{section_from_bfd_section}, @samp{symbol_processing},
+@samp{add_symbol_hook}, and @samp{output_symbol_hook}.
+
+Dynamic linking support, which involves processor specific relocations
+requiring special handling, is also implemented via hook functions.
+
+@node BFD ELF core files
+@subsection BFD ELF core files
+@cindex elf core files
+
+On native ELF Unix systems, core files are generated without any
+sections. Instead, they only have program segments.
+
+When BFD is used to read an ELF core file, the BFD sections will
+actually represent program segments. Since ELF program segments do not
+have names, BFD will invent names like @samp{segment@var{n}} where
+@var{n} is a number.
+
+A single ELF program segment may include both an initialized part and an
+uninitialized part. The size of the initialized part is given by the
+@samp{p_filesz} field. The total size of the segment is given by the
+@samp{p_memsz} field. If @samp{p_memsz} is larger than @samp{p_filesz},
+then the extra space is uninitialized, or, more precisely, initialized
+to zero.
+
+BFD will represent such a program segment as two different sections.
+The first, named @samp{segment@var{n}a}, will represent the initialized
+part of the program segment. The second, named @samp{segment@var{n}b},
+will represent the uninitialized part.
+
+ELF core files store special information such as register values in
+program segments with the type @samp{PT_NOTE}. BFD will attempt to
+interpret the information in these segments, and will create additional
+sections holding the information. Some of this interpretation requires
+information found in the host header file @file{sys/procfs.h}, and so
+will only work when BFD is built on a native system.
+
+BFD does not currently provide any way to create an ELF core file. In
+general, BFD does not provide a way to create core files. The way to
+implement this would be to write @samp{bfd_set_format} and
+@samp{bfd_write_contents} routines for the @samp{bfd_core} type; see
+@ref{BFD target vector format}.
+
+@node BFD ELF future
+@subsection BFD ELF future
+
+The current dynamic linking support has too much code duplication.
+While each processor has particular differences, much of the dynamic
+linking support is quite similar for each processor. The GOT and PLT
+are handled in fairly similar ways, the details of -Bsymbolic linking
+are generally similar, etc. This code should be reworked to use more
+generic functions, eliminating the duplication.
+
+Similarly, the relocation handling has too much duplication. Many of
+the @samp{reloc_type_lookup} and @samp{info_to_howto} functions are
+quite similar. The relocate section functions are also often quite
+similar, both in the standard linker handling and the dynamic linker
+handling. Many of the COFF processor specific backends share a single
+relocate section function (@samp{_bfd_coff_generic_relocate_section}),
+and it should be possible to do something like this for the ELF targets
+as well.
+
+The appearance of the processor specific magic number in
+@samp{prep_headers} in @file{elf.c} is somewhat bogus. It should be
+possible to add support for a new processor without changing the generic
+support.
+
+The processor function hooks and constants are ad hoc and need better
+documentation.
+
+When a linker script uses @samp{SIZEOF_HEADERS}, the ELF backend must
+guess at the number of program segments which will be required, in
+@samp{get_program_header_size}. This is because the linker calls
+@samp{bfd_sizeof_headers} before it knows all the section addresses and
+sizes. The ELF backend may later discover, when creating program
+segments, that more program segments are required. This is currently
+reported as an error in @samp{assign_file_positions_for_segments}.
+
+In practice this makes it difficult to use @samp{SIZEOF_HEADERS} except
+with a carefully defined linker script. Unfortunately,
+@samp{SIZEOF_HEADERS} is required for fast program loading on a native
+system, since it permits the initial code section to appear on the same
+page as the program segments, saving a page read when the program starts
+running. Fortunately, native systems permit careful definition of the
+linker script. Still, ideally it would be possible to use relaxation to
+compute the number of program segments.
+
+@node BFD glossary
+@section BFD glossary
+@cindex glossary for bfd
+@cindex bfd glossary
+
+This is a short glossary of some BFD terms.
+
+@table @asis
+@item a.out
+The a.out object file format. The original Unix object file format.
+Still used on SunOS, though not Solaris. Supports only three sections.
+
+@item archive
+A collection of object files produced and manipulated by the @samp{ar}
+program.
+
+@item backend
+The implementation within BFD of a particular object file format. The
+set of functions which appear in a particular target vector.
+
+@item BFD
+The BFD library itself. Also, each object file, archive, or exectable
+opened by the BFD library has the type @samp{bfd *}, and is sometimes
+referred to as a bfd.
+
+@item COFF
+The Common Object File Format. Used on Unix SVR3. Used by some
+embedded targets, although ELF is normally better.
+
+@item DLL
+A shared library on Windows.
+
+@item dynamic linker
+When a program linked against a shared library is run, the dynamic
+linker will locate the appropriate shared library and arrange to somehow
+include it in the running image.
+
+@item dynamic object
+Another name for an ELF shared library.
+
+@item ECOFF
+The Extended Common Object File Format. Used on Alpha Digital Unix
+(formerly OSF/1), as well as Ultrix and Irix 4. A variant of COFF.
+
+@item ELF
+The Executable and Linking Format. The object file format used on most
+modern Unix systems, including GNU/Linux, Solaris, Irix, and SVR4. Also
+used on many embedded systems.
+
+@item executable
+A program, with instructions and symbols, and perhaps dynamic linking
+information. Normally produced by a linker.
+
+@item LMA
+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.
+
+@item object file format
+The format of an object file. Typically object files and executables
+for a particular system are in the same format, although executables
+will not contain any relocation information.
+
+@item PE
+The Portable Executable format. This is the object file format used for
+Windows (specifically, Win32) object files. It is based closely on
+COFF, but has a few significant differences.
+
+@item PEI
+The Portable Executable Image format. This is the object file format
+used for Windows (specifically, Win32) executables. It is very similar
+to PE, but includes some additional header information.
+
+@item relocations
+Information used by the linker to adjust section contents. Also called
+relocs.
+
+@item section
+Object files and executable are composed of sections. Sections have
+optional data and optional relocation information.
+
+@item shared library
+A library of functions which may be used by many executables without
+actually being linked into each executable. There are several different
+implementations of shared libraries, each having slightly different
+features.
+
+@item symbol
+Each object file and executable may have a list of symbols, often
+referred to as the symbol table. A symbol is basically a name and an
+address. There may also be some additional information like the type of
+symbol, although the type of a symbol is normally something simple like
+function or object, and should be confused with the more complex C
+notion of type. Typically every global function and variable in a C
+program will have an associated symbol.
+
+@item target vector
+A set of functions which implement support for a particular object file
+format. The @samp{bfd_target} structure.
+
+@item Win32
+The current Windows API, implemented by Windows 95 and later and Windows
+NT 3.51 and later, but not by Windows 3.1.
+
+@item XCOFF
+The eXtended Common Object File Format. Used on AIX. A variant of
+COFF, with a completely different symbol table implementation.
+
+@item VMA
+Virtual Memory Address. This is the address a section will have when
+an executable is run. Compare with LMA, above.
+@end table
+
+@node Index
+@unnumberedsec Index
+@printindex cp
+
+@contents
+@bye
diff --git a/bfd/doc/bfdsumm.texi b/bfd/doc/bfdsumm.texi
new file mode 100644
index 00000000000..844531aff8c
--- /dev/null
+++ b/bfd/doc/bfdsumm.texi
@@ -0,0 +1,148 @@
+@c This summary of BFD is shared by the BFD and LD docs.
+When an object file is opened, BFD subroutines automatically determine
+the format of the input object file. They then build a descriptor in
+memory with pointers to routines that will be used to access elements of
+the object file's data structures.
+
+As different information from the the object files is required,
+BFD reads from different sections of the file and processes them.
+For example, a very common operation for the linker is processing symbol
+tables. Each BFD back end provides a routine for converting
+between the object file's representation of symbols and an internal
+canonical format. When the linker asks for the symbol table of an object
+file, it calls through a memory pointer to the routine from the
+relevant BFD back end which reads and converts the table into a canonical
+form. The linker then operates upon the canonical form. When the link is
+finished and the linker writes the output file's symbol table,
+another BFD back end routine is called to take the newly
+created symbol table and convert it into the chosen output format.
+
+@menu
+* BFD information loss:: Information Loss
+* Canonical format:: The BFD canonical object-file format
+@end menu
+
+@node BFD information loss
+@subsection Information Loss
+
+@emph{Information can be lost during output.} The output formats
+supported by BFD do not provide identical facilities, and
+information which can be described in one form has nowhere to go in
+another format. One example of this is alignment information in
+@code{b.out}. There is nowhere in an @code{a.out} format file to store
+alignment information on the contained data, so when a file is linked
+from @code{b.out} and an @code{a.out} image is produced, alignment
+information will not propagate to the output file. (The linker will
+still use the alignment information internally, so the link is performed
+correctly).
+
+Another example is COFF section names. COFF files may contain an
+unlimited number of sections, each one with a textual section name. If
+the target of the link is a format which does not have many sections (e.g.,
+@code{a.out}) or has sections without names (e.g., the Oasys format), the
+link cannot be done simply. You can circumvent this problem by
+describing the desired input-to-output section mapping with the linker command
+language.
+
+@emph{Information can be lost during canonicalization.} The BFD
+internal canonical form of the external formats is not exhaustive; there
+are structures in input formats for which there is no direct
+representation internally. This means that the BFD back ends
+cannot maintain all possible data richness through the transformation
+between external to internal and back to external formats.
+
+This limitation is only a problem when an application reads one
+format and writes another. Each BFD back end is responsible for
+maintaining as much data as possible, and the internal BFD
+canonical form has structures which are opaque to the BFD core,
+and exported only to the back ends. When a file is read in one format,
+the canonical form is generated for BFD and the application. At the
+same time, the back end saves away any information which may otherwise
+be lost. If the data is then written back in the same format, the back
+end routine will be able to use the canonical form provided by the
+BFD core as well as the information it prepared earlier. Since
+there is a great deal of commonality between back ends,
+there is no information lost when
+linking or copying big endian COFF to little endian COFF, or @code{a.out} to
+@code{b.out}. When a mixture of formats is linked, the information is
+only lost from the files whose format differs from the destination.
+
+@node Canonical format
+@subsection The BFD canonical object-file format
+
+The greatest potential for loss of information occurs when there is the least
+overlap between the information provided by the source format, that
+stored by the canonical format, and that needed by the
+destination format. A brief description of the canonical form may help
+you understand which kinds of data you can count on preserving across
+conversions.
+@cindex BFD canonical format
+@cindex internal object-file format
+
+@table @emph
+@item files
+Information stored on a per-file basis includes target machine
+architecture, particular implementation format type, a demand pageable
+bit, and a write protected bit. Information like Unix magic numbers is
+not stored here---only the magic numbers' meaning, so a @code{ZMAGIC}
+file would have both the demand pageable bit and the write protected
+text bit set. The byte order of the target is stored on a per-file
+basis, so that big- and little-endian object files may be used with one
+another.
+
+@item sections
+Each section in the input file contains the name of the section, the
+section's original address in the object file, size and alignment
+information, various flags, and pointers into other BFD data
+structures.
+
+@item symbols
+Each symbol contains a pointer to the information for the object file
+which originally defined it, its name, its value, and various flag
+bits. When a BFD back end reads in a symbol table, it relocates all
+symbols to make them relative to the base of the section where they were
+defined. Doing this ensures that each symbol points to its containing
+section. Each symbol also has a varying amount of hidden private data
+for the BFD back end. Since the symbol points to the original file, the
+private data format for that symbol is accessible. @code{ld} can
+operate on a collection of symbols of wildly different formats without
+problems.
+
+Normal global and simple local symbols are maintained on output, so an
+output file (no matter its format) will retain symbols pointing to
+functions and to global, static, and common variables. Some symbol
+information is not worth retaining; in @code{a.out}, type information is
+stored in the symbol table as long symbol names. This information would
+be useless to most COFF debuggers; the linker has command line switches
+to allow users to throw it away.
+
+There is one word of type information within the symbol, so if the
+format supports symbol type information within symbols (for example, COFF,
+IEEE, Oasys) and the type is simple enough to fit within one word
+(nearly everything but aggregates), the information will be preserved.
+
+@item relocation level
+Each canonical BFD relocation record contains a pointer to the symbol to
+relocate to, the offset of the data to relocate, the section the data
+is in, and a pointer to a relocation type descriptor. Relocation is
+performed by passing messages through the relocation type
+descriptor and the symbol pointer. Therefore, relocations can be performed
+on output data using a relocation method that is only available in one of the
+input formats. For instance, Oasys provides a byte relocation format.
+A relocation record requesting this relocation type would point
+indirectly to a routine to perform this, so the relocation may be
+performed on a byte being written to a 68k COFF file, even though 68k COFF
+has no such relocation type.
+
+@item line numbers
+Object formats can contain, for debugging purposes, some form of mapping
+between symbols, source line numbers, and addresses in the output file.
+These addresses have to be relocated along with the symbol information.
+Each symbol with an associated list of line number records points to the
+first record of the list. The head of a line number list consists of a
+pointer to the symbol, which allows finding out the address of the
+function whose line number is being described. The rest of the list is
+made up of pairs: offsets into the section and line numbers. Any format
+which can simply derive this information can pass it successfully
+between formats (COFF, IEEE and Oasys).
+@end table
diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
new file mode 100644
index 00000000000..eba69c2bb1d
--- /dev/null
+++ b/bfd/doc/chew.c
@@ -0,0 +1,1579 @@
+/* chew
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1998
+ Free Software Foundation, Inc.
+ Contributed by steve chamberlain @cygnus
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Yet another way of extracting documentation from source.
+ No, I haven't finished it yet, but I hope you people like it better
+ than the old way
+
+ sac
+
+ Basically, this is a sort of string forth, maybe we should call it
+ struth?
+
+ You define new words thus:
+ : <newword> <oldwords> ;
+
+*/
+
+/* Primitives provided by the program:
+
+ Two stacks are provided, a string stack and an integer stack.
+
+ Internal state variables:
+ internal_wanted - indicates whether `-i' was passed
+ internal_mode - user-settable
+
+ Commands:
+ push_text
+ ! - pop top of integer stack for address, pop next for value; store
+ @ - treat value on integer stack as the address of an integer; push
+ that integer on the integer stack after popping the "address"
+ hello - print "hello\n" to stdout
+ stdout - put stdout marker on TOS
+ stderr - put stderr marker on TOS
+ print - print TOS-1 on TOS (eg: "hello\n" stdout print)
+ skip_past_newline
+ catstr - fn icatstr
+ copy_past_newline - append input, up to and including newline into TOS
+ dup - fn other_dup
+ drop - discard TOS
+ idrop - ditto
+ remchar - delete last character from TOS
+ get_stuff_in_command
+ do_fancy_stuff - translate <<foo>> to @code{foo} in TOS
+ bulletize - if "o" lines found, prepend @itemize @bullet to TOS
+ and @item to each "o" line; append @end itemize
+ courierize - put @example around . and | lines, translate {* *} { }
+ exit - fn chew_exit
+ swap
+ outputdots - strip out lines without leading dots
+ paramstuff - convert full declaration into "PARAMS" form if not already
+ maybecatstr - do catstr if internal_mode == internal_wanted, discard
+ value in any case
+ translatecomments - turn {* and *} into comment delimiters
+ kill_bogus_lines - get rid of extra newlines
+ indent
+ internalmode - pop from integer stack, set `internalmode' to that value
+ print_stack_level - print current stack depth to stderr
+ strip_trailing_newlines - go ahead, guess...
+ [quoted string] - push string onto string stack
+ [word starting with digit] - push atol(str) onto integer stack
+
+ A command must be all upper-case, and alone on a line.
+
+ Foo. */
+
+
+#include <ansidecl.h>
+#include "sysdep.h"
+#include <assert.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#define DEF_SIZE 5000
+#define STACK 50
+
+int internal_wanted;
+int internal_mode;
+
+int warning;
+
+/* Here is a string type ... */
+
+typedef struct buffer
+{
+ char *ptr;
+ unsigned long write_idx;
+ unsigned long size;
+} string_type;
+
+
+#ifdef __STDC__
+static void init_string_with_size (string_type *, unsigned int);
+static void init_string (string_type *);
+static int find (string_type *, char *);
+static void write_buffer (string_type *, FILE *);
+static void delete_string (string_type *);
+static char *addr (string_type *, unsigned int);
+static char at (string_type *, unsigned int);
+static void catchar (string_type *, int);
+static void overwrite_string (string_type *, string_type *);
+static void catbuf (string_type *, char *, unsigned int);
+static void cattext (string_type *, char *);
+static void catstr (string_type *, string_type *);
+#endif
+
+
+static void DEFUN(init_string_with_size,(buffer, size),
+ string_type *buffer AND
+ unsigned int size )
+{
+ buffer->write_idx = 0;
+ buffer->size = size;
+ buffer->ptr = malloc(size);
+}
+
+static void DEFUN(init_string,(buffer),
+ string_type *buffer)
+{
+ init_string_with_size(buffer, DEF_SIZE);
+
+}
+
+static int DEFUN(find, (str, what),
+ string_type *str AND
+ char *what)
+{
+ unsigned int i;
+ char *p;
+ p = what;
+ for (i = 0; i < str->write_idx && *p; i++)
+ {
+ if (*p == str->ptr[i])
+ p++;
+ else
+ p = what;
+ }
+ return (*p == 0);
+
+}
+
+static void DEFUN(write_buffer,(buffer, f),
+ string_type *buffer AND
+ FILE *f)
+{
+ fwrite(buffer->ptr, buffer->write_idx, 1, f);
+}
+
+
+static void DEFUN(delete_string,(buffer),
+ string_type *buffer)
+{
+ free(buffer->ptr);
+}
+
+
+static char *DEFUN(addr, (buffer, idx),
+ string_type *buffer AND
+ unsigned int idx)
+{
+ return buffer->ptr + idx;
+}
+
+static char DEFUN(at,(buffer, pos),
+ string_type *buffer AND
+ unsigned int pos)
+{
+ if (pos >= buffer->write_idx)
+ return 0;
+ return buffer->ptr[pos];
+}
+
+static void DEFUN(catchar,(buffer, ch),
+ string_type *buffer AND
+ int ch)
+{
+ if (buffer->write_idx == buffer->size)
+ {
+ buffer->size *=2;
+ buffer->ptr = realloc(buffer->ptr, buffer->size);
+ }
+
+ buffer->ptr[buffer->write_idx ++ ] = ch;
+}
+
+
+static void DEFUN(overwrite_string,(dst, src),
+ string_type *dst AND
+ string_type *src)
+{
+ free(dst->ptr);
+ dst->size = src->size;
+ dst->write_idx = src->write_idx;
+ dst->ptr = src->ptr;
+}
+
+static void DEFUN(catbuf,(buffer, buf, len),
+ string_type *buffer AND
+ char *buf AND
+ unsigned int len)
+{
+ if (buffer->write_idx + len >= buffer->size)
+ {
+ while (buffer->write_idx + len >= buffer->size)
+ buffer->size *= 2;
+ buffer->ptr = realloc (buffer->ptr, buffer->size);
+ }
+ memcpy (buffer->ptr + buffer->write_idx, buf, len);
+ buffer->write_idx += len;
+}
+
+static void DEFUN(cattext,(buffer, string),
+ string_type *buffer AND
+ char *string)
+{
+ catbuf (buffer, string, (unsigned int) strlen (string));
+}
+
+static void DEFUN(catstr,(dst, src),
+ string_type *dst AND
+ string_type *src)
+{
+ catbuf (dst, src->ptr, src->write_idx);
+}
+
+
+static unsigned int
+DEFUN(skip_white_and_stars,(src, idx),
+ string_type *src AND
+ unsigned int idx)
+{
+ char c;
+ while ((c = at(src,idx)),
+ isspace ((unsigned char) c)
+ || (c == '*'
+ /* Don't skip past end-of-comment or star as first
+ character on its line. */
+ && at(src,idx +1) != '/'
+ && at(src,idx -1) != '\n'))
+ idx++;
+ return idx;
+}
+
+/***********************************************************************/
+
+
+string_type stack[STACK];
+string_type *tos;
+
+unsigned int idx = 0; /* Pos in input buffer */
+string_type *ptr; /* and the buffer */
+typedef void (*stinst_type)();
+stinst_type *pc;
+stinst_type sstack[STACK];
+stinst_type *ssp = &sstack[0];
+long istack[STACK];
+long *isp = &istack[0];
+
+typedef int *word_type;
+
+
+
+struct dict_struct
+{
+ char *word;
+ struct dict_struct *next;
+ stinst_type *code;
+ int code_length;
+ int code_end;
+ int var;
+
+};
+typedef struct dict_struct dict_type;
+#define WORD(x) static void x()
+
+static void
+die (msg)
+ char *msg;
+{
+ fprintf (stderr, "%s\n", msg);
+ exit (1);
+}
+
+static void
+check_range ()
+{
+ if (tos < stack)
+ die ("underflow in string stack");
+ if (tos >= stack + STACK)
+ die ("overflow in string stack");
+}
+
+static void
+icheck_range ()
+{
+ if (isp < istack)
+ die ("underflow in integer stack");
+ if (isp >= istack + STACK)
+ die ("overflow in integer stack");
+}
+
+#ifdef __STDC__
+static void exec (dict_type *);
+static void call (void);
+static void remchar (void), strip_trailing_newlines (void), push_number (void);
+static void push_text (void);
+static void remove_noncomments (string_type *, string_type *);
+static void print_stack_level (void);
+static void paramstuff (void), translatecomments (void);
+static void outputdots (void), courierize (void), bulletize (void);
+static void do_fancy_stuff (void);
+static int iscommand (string_type *, unsigned int);
+static int copy_past_newline (string_type *, unsigned int, string_type *);
+static void icopy_past_newline (void), kill_bogus_lines (void), indent (void);
+static void get_stuff_in_command (void), swap (void), other_dup (void);
+static void drop (void), idrop (void);
+static void icatstr (void), skip_past_newline (void), internalmode (void);
+static void maybecatstr (void);
+static char *nextword (char *, char **);
+dict_type *lookup_word (char *);
+static void perform (void);
+dict_type *newentry (char *);
+unsigned int add_to_definition (dict_type *, stinst_type);
+void add_intrinsic (char *, void (*)());
+void add_var (char *);
+void compile (char *);
+static void bang (void);
+static void atsign (void);
+static void hello (void);
+static void stdout_ (void);
+static void stderr_ (void);
+static void print (void);
+static void read_in (string_type *, FILE *);
+static void usage (void);
+static void chew_exit (void);
+#endif
+
+static void DEFUN(exec,(word),
+ dict_type *word)
+{
+ pc = word->code;
+ while (*pc)
+ (*pc)();
+}
+WORD(call)
+{
+ stinst_type *oldpc = pc;
+ dict_type *e;
+ e = (dict_type *)(pc [1]);
+ exec(e);
+ pc = oldpc + 2;
+
+}
+
+WORD(remchar)
+{
+ if (tos->write_idx)
+ tos->write_idx--;
+ pc++;
+}
+
+static void
+strip_trailing_newlines ()
+{
+ while ((isspace ((unsigned char) at (tos, tos->write_idx - 1))
+ || at (tos, tos->write_idx - 1) == '\n')
+ && tos->write_idx > 0)
+ tos->write_idx--;
+ pc++;
+}
+
+WORD(push_number)
+{
+ isp++;
+ icheck_range ();
+ pc++;
+ *isp = (long)(*pc);
+ pc++;
+}
+
+WORD(push_text)
+{
+ tos++;
+ check_range ();
+ init_string(tos);
+ pc++;
+ cattext(tos,*((char **)pc));
+ pc++;
+
+}
+
+
+/* This function removes everything not inside comments starting on
+ the first char of the line from the string, also when copying
+ comments, removes blank space and leading *'s.
+ Blank lines are turned into one blank line. */
+
+static void
+DEFUN(remove_noncomments,(src,dst),
+ string_type *src AND
+ string_type *dst)
+{
+ unsigned int idx = 0;
+
+ while (at(src,idx))
+ {
+ /* Now see if we have a comment at the start of the line */
+ if (at(src,idx) == '\n'
+ && at(src,idx+1) == '/'
+ && at(src,idx+2) == '*')
+ {
+ idx+=3;
+
+ idx = skip_white_and_stars(src,idx);
+
+ /* Remove leading dot */
+ if (at(src, idx) == '.')
+ idx++;
+
+ /* Copy to the end of the line, or till the end of the
+ comment */
+ while (at(src, idx))
+ {
+ if (at(src, idx) == '\n')
+ {
+ /* end of line, echo and scrape of leading blanks */
+ if (at(src,idx +1) == '\n')
+ catchar(dst,'\n');
+ catchar(dst,'\n');
+ idx++;
+ idx = skip_white_and_stars(src, idx);
+ }
+ else if (at(src, idx) == '*' && at(src,idx+1) == '/')
+ {
+ idx +=2 ;
+ cattext(dst,"\nENDDD\n");
+ break;
+ }
+ else
+ {
+ catchar(dst, at(src, idx));
+ idx++;
+ }
+ }
+ }
+ else idx++;
+ }
+}
+
+static void
+print_stack_level ()
+{
+ fprintf (stderr, "current string stack depth = %d, ", tos - stack);
+ fprintf (stderr, "current integer stack depth = %d\n", isp - istack);
+ pc++;
+}
+
+/* turn:
+ foobar name(stuff);
+ into:
+ foobar
+ name PARAMS ((stuff));
+ and a blank line.
+ */
+
+static void
+DEFUN_VOID(paramstuff)
+{
+ unsigned int openp;
+ unsigned int fname;
+ unsigned int idx;
+ string_type out;
+ init_string(&out);
+
+
+ /* make sure that it's not already param'd or proto'd */
+ if(find(tos,"PARAMS") || find(tos,"PROTO") || !find(tos,"(")) {
+ catstr(&out,tos);
+ }
+ else
+ {
+ /* Find the open paren */
+ for (openp = 0; at(tos, openp) != '(' && at(tos,openp); openp++)
+ ;
+
+ fname = openp;
+ /* Step back to the fname */
+ fname--;
+ while (fname && isspace((unsigned char) at(tos, fname)))
+ fname --;
+ while (fname
+ && !isspace((unsigned char) at(tos,fname))
+ && at(tos,fname) != '*')
+ fname--;
+
+ fname++;
+
+ for (idx = 0; idx < fname; idx++) /* Output type */
+ {
+ catchar(&out, at(tos,idx));
+ }
+
+ cattext(&out, "\n"); /* Insert a newline between type and fnname */
+
+ for (idx = fname; idx < openp; idx++) /* Output fnname */
+ {
+ catchar(&out, at(tos,idx));
+ }
+
+ cattext(&out," PARAMS (");
+
+ while (at(tos,idx) && at(tos,idx) !=';')
+ {
+ catchar(&out, at(tos, idx));
+ idx++;
+ }
+ cattext(&out,");\n\n");
+ }
+ overwrite_string(tos, &out);
+ pc++;
+
+}
+
+
+
+/* turn {*
+ and *} into comments */
+
+WORD(translatecomments)
+{
+ unsigned int idx = 0;
+ string_type out;
+ init_string(&out);
+
+ while (at(tos, idx))
+ {
+ if (at(tos,idx) == '{' && at(tos,idx+1) =='*')
+ {
+ cattext(&out,"/*");
+ idx+=2;
+ }
+ else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
+ {
+ cattext(&out,"*/");
+ idx+=2;
+ }
+ else
+ {
+ catchar(&out, at(tos, idx));
+ idx++;
+ }
+ }
+
+
+ overwrite_string(tos, &out);
+
+ pc++;
+
+}
+
+#if 0
+
+/* This is not currently used. */
+
+/* turn everything not starting with a . into a comment */
+
+WORD(manglecomments)
+{
+ unsigned int idx = 0;
+ string_type out;
+ init_string(&out);
+
+ while (at(tos, idx))
+ {
+ if (at(tos,idx) == '\n' && at(tos,idx+1) =='*')
+ {
+ cattext(&out," /*");
+ idx+=2;
+ }
+ else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
+ {
+ cattext(&out,"*/");
+ idx+=2;
+ }
+ else
+ {
+ catchar(&out, at(tos, idx));
+ idx++;
+ }
+ }
+
+
+ overwrite_string(tos, &out);
+
+ pc++;
+
+}
+
+#endif
+
+/* Mod tos so that only lines with leading dots remain */
+static void
+DEFUN_VOID(outputdots)
+{
+ unsigned int idx = 0;
+ string_type out;
+ init_string(&out);
+
+ while (at(tos, idx))
+ {
+ if (at(tos, idx) == '\n' && at(tos, idx+1) == '.')
+ {
+ char c;
+ idx += 2;
+
+ while ((c = at(tos, idx)) && c != '\n')
+ {
+ if (c == '{' && at(tos,idx+1) =='*')
+ {
+ cattext(&out," /*");
+ idx+=2;
+ }
+ else if (c == '*' && at(tos,idx+1) =='}')
+ {
+ cattext(&out,"*/");
+ idx+=2;
+ }
+ else
+ {
+ catchar(&out, c);
+ idx++;
+ }
+ }
+ catchar(&out,'\n');
+ }
+ else
+ {
+ idx++;
+ }
+ }
+
+ overwrite_string(tos, &out);
+ pc++;
+
+}
+
+/* Find lines starting with . and | and put example around them on tos */
+WORD(courierize)
+{
+ string_type out;
+ unsigned int idx = 0;
+ int command = 0;
+
+ init_string(&out);
+
+ while (at(tos, idx))
+ {
+ if (at(tos, idx) == '\n'
+ && (at(tos, idx +1 ) == '.'
+ || at(tos,idx+1) == '|'))
+ {
+ cattext(&out,"\n@example\n");
+ do
+ {
+ idx += 2;
+
+ while (at(tos, idx) && at(tos, idx)!='\n')
+ {
+ if (at(tos,idx)=='{' && at(tos,idx+1) =='*')
+ {
+ cattext(&out," /*");
+ idx+=2;
+ }
+ else if (at(tos,idx)=='*' && at(tos,idx+1) =='}')
+ {
+ cattext(&out,"*/");
+ idx+=2;
+ }
+ else if (at(tos,idx) == '{' && !command)
+ {
+ cattext(&out,"@{");
+ idx++;
+ }
+ else if (at(tos,idx) == '}' && !command)
+ {
+ cattext(&out,"@}");
+ idx++;
+ }
+ else
+ {
+ if (at(tos,idx) == '@')
+ command = 1;
+ else if (isspace((unsigned char) at(tos,idx))
+ || at(tos,idx) == '}')
+ command = 0;
+ catchar(&out, at(tos, idx));
+ idx++;
+ }
+
+ }
+ catchar(&out,'\n');
+ }
+ while (at(tos, idx) == '\n'
+ && ((at(tos, idx+1) == '.')
+ || (at(tos,idx+1) == '|')))
+ ;
+ cattext(&out,"@end example");
+ }
+ else
+ {
+ catchar(&out, at(tos, idx));
+ idx++;
+ }
+ }
+
+ overwrite_string(tos, &out);
+ pc++;
+
+
+}
+
+/* Finds any lines starting with "o ", if there are any, then turns
+ on @itemize @bullet, and @items each of them. Then ends with @end
+ itemize, inplace at TOS*/
+
+
+WORD(bulletize)
+{
+ unsigned int idx = 0;
+ int on = 0;
+ string_type out;
+ init_string(&out);
+
+ while (at(tos, idx)) {
+ if (at(tos, idx) == '@' &&
+ at(tos, idx+1) == '*')
+ {
+ cattext(&out,"*");
+ idx+=2;
+ }
+
+ else
+ if (at(tos, idx) == '\n' &&
+ at(tos, idx+1) == 'o' &&
+ isspace((unsigned char) at(tos, idx +2)))
+ {
+ if (!on)
+ {
+ cattext(&out,"\n@itemize @bullet\n");
+ on = 1;
+
+ }
+ cattext(&out,"\n@item\n");
+ idx+=3;
+ }
+ else
+ {
+ catchar(&out, at(tos, idx));
+ if (on && at(tos, idx) == '\n' &&
+ at(tos, idx+1) == '\n' &&
+ at(tos, idx+2) != 'o')
+ {
+ cattext(&out, "@end itemize");
+ on = 0;
+ }
+ idx++;
+
+ }
+ }
+ if (on)
+ {
+ cattext(&out,"@end itemize\n");
+ }
+
+ delete_string(tos);
+ *tos = out;
+ pc++;
+
+}
+
+/* Turn <<foo>> into @code{foo} in place at TOS*/
+
+
+WORD(do_fancy_stuff)
+{
+ unsigned int idx = 0;
+ string_type out;
+ init_string(&out);
+ while (at(tos, idx))
+ {
+ if (at(tos, idx) == '<'
+ && at(tos, idx+1) == '<'
+ && !isspace((unsigned char) at(tos,idx + 2)))
+ {
+ /* This qualifies as a << startup */
+ idx +=2;
+ cattext(&out,"@code{");
+ while(at(tos,idx) &&
+ at(tos,idx) != '>' )
+ {
+ catchar(&out, at(tos, idx));
+ idx++;
+
+ }
+ cattext(&out,"}");
+ idx+=2;
+ }
+ else
+ {
+ catchar(&out, at(tos, idx));
+ idx++;
+ }
+ }
+ delete_string(tos);
+ *tos = out;
+ pc++;
+
+}
+/* A command is all upper case,and alone on a line */
+static int
+DEFUN( iscommand,(ptr, idx),
+ string_type *ptr AND
+ unsigned int idx)
+{
+ unsigned int len = 0;
+ while (at(ptr,idx)) {
+ if (isupper((unsigned char) at(ptr,idx)) || at(ptr,idx) == ' ' ||
+ at(ptr,idx) == '_')
+ {
+ len++;
+ idx++;
+ }
+ else if(at(ptr,idx) == '\n')
+ {
+ if (len > 3) return 1;
+ return 0;
+ }
+ else return 0;
+ }
+ return 0;
+
+}
+
+
+static int
+DEFUN(copy_past_newline,(ptr, idx, dst),
+ string_type *ptr AND
+ unsigned int idx AND
+ string_type *dst)
+{
+ int column = 0;
+
+ while (at(ptr, idx) && at(ptr, idx) != '\n')
+ {
+ if (at (ptr, idx) == '\t')
+ {
+ /* Expand tabs. Neither makeinfo nor TeX can cope well with
+ them. */
+ do
+ catchar (dst, ' ');
+ while (++column & 7);
+ }
+ else
+ {
+ catchar(dst, at(ptr, idx));
+ column++;
+ }
+ idx++;
+
+ }
+ catchar(dst, at(ptr, idx));
+ idx++;
+ return idx;
+
+}
+
+WORD(icopy_past_newline)
+{
+ tos++;
+ check_range ();
+ init_string(tos);
+ idx = copy_past_newline(ptr, idx, tos);
+ pc++;
+}
+
+/* indent
+ Take the string at the top of the stack, do some prettying */
+
+
+WORD(kill_bogus_lines)
+{
+ int sl ;
+
+ int idx = 0;
+ int c;
+ int dot = 0 ;
+
+ string_type out;
+ init_string(&out);
+ /* Drop leading nl */
+ while (at(tos,idx) == '\n')
+ {
+ idx++;
+ }
+ c = idx;
+
+ /* If the first char is a '.' prepend a newline so that it is
+ recognized properly later. */
+ if (at (tos, idx) == '.')
+ catchar (&out, '\n');
+
+ /* Find the last char */
+ while (at(tos,idx))
+ {
+ idx++;
+ }
+
+ /* find the last non white before the nl */
+ idx--;
+
+ while (idx && isspace((unsigned char) at(tos,idx)))
+ idx--;
+ idx++;
+
+ /* Copy buffer upto last char, but blank lines before and after
+ dots don't count */
+ sl = 1;
+
+ while (c < idx)
+ {
+ if (at(tos,c) == '\n'
+ && at(tos,c+1) == '\n'
+ && at(tos,c+2) == '.')
+ {
+ /* Ignore two newlines before a dot*/
+ c++;
+ }
+ else if (at(tos,c) == '.' && sl)
+ {
+ /* remember that this line started with a dot */
+ dot=2;
+ }
+ else if (at(tos,c) == '\n'
+ && at(tos,c+1) == '\n'
+ && dot)
+ {
+ c++;
+ /* Ignore two newlines when last line was dot */
+ }
+
+ catchar(&out, at(tos,c));
+ if (at(tos,c) == '\n')
+ {
+ sl = 1;
+
+ if (dot == 2)dot=1;else dot = 0;
+ }
+ else
+ sl = 0;
+
+ c++;
+
+ }
+
+ /* Append nl*/
+ catchar(&out, '\n');
+ pc++;
+ delete_string(tos);
+ *tos = out;
+
+
+}
+
+WORD(indent)
+{
+ string_type out;
+ int tab = 0;
+ int idx = 0;
+ int ol =0;
+ init_string(&out);
+ while (at(tos,idx)) {
+ switch (at(tos,idx))
+ {
+ case '\n':
+ cattext(&out,"\n");
+ idx++;
+ if (tab && at(tos,idx))
+ {
+ cattext(&out," ");
+ }
+ ol = 0;
+ break;
+ case '(':
+ tab++;
+ if (ol == 0)
+ cattext(&out," ");
+ idx++;
+ cattext(&out,"(");
+ ol = 1;
+ break;
+ case ')':
+ tab--;
+ cattext(&out,")");
+ idx++;
+ ol=1;
+
+ break;
+ default:
+ catchar(&out,at(tos,idx));
+ ol=1;
+
+ idx++;
+ break;
+ }
+ }
+
+ pc++;
+ delete_string(tos);
+ *tos = out;
+
+}
+
+
+WORD(get_stuff_in_command)
+{
+ tos++;
+ check_range ();
+ init_string(tos);
+
+ while (at(ptr, idx)) {
+ if (iscommand(ptr, idx)) break;
+ idx = copy_past_newline(ptr, idx, tos);
+ }
+ pc++;
+}
+
+WORD(swap)
+{
+ string_type t;
+
+ t = tos[0];
+ tos[0] = tos[-1];
+ tos[-1] =t;
+ pc++;
+
+}
+
+WORD(other_dup)
+{
+ tos++;
+ check_range ();
+ init_string(tos);
+ catstr(tos, tos-1);
+ pc++;
+}
+
+WORD(drop)
+{
+ tos--;
+ check_range ();
+ pc++;
+}
+
+WORD(idrop)
+{
+ isp--;
+ icheck_range ();
+ pc++;
+}
+
+WORD(icatstr)
+{
+ tos--;
+ check_range ();
+ catstr(tos, tos+1);
+ delete_string(tos+1);
+ pc++;
+}
+
+WORD(skip_past_newline)
+{
+ while (at(ptr,idx)
+ && at(ptr,idx) != '\n')
+ idx++;
+ idx++;
+ pc++;
+}
+
+
+WORD(internalmode)
+{
+ internal_mode = *(isp);
+ isp--;
+ icheck_range ();
+ pc++;
+}
+
+WORD(maybecatstr)
+{
+ if (internal_wanted == internal_mode)
+ {
+ catstr(tos-1, tos);
+ }
+ delete_string(tos);
+ tos--;
+ check_range ();
+ pc++;
+}
+
+char *
+DEFUN(nextword,(string, word),
+ char *string AND
+ char **word)
+{
+ char *word_start;
+ int idx;
+ char *dst;
+ char *src;
+
+ int length = 0;
+
+ while (isspace((unsigned char) *string) || *string == '-') {
+ if (*string == '-')
+ {
+ while (*string && *string != '\n')
+ string++;
+
+ }
+ else {
+ string++;
+ }
+ }
+ if (!*string) return 0;
+
+ word_start = string;
+ if (*string == '"')
+ {
+ do
+ {
+ string++;
+ length++;
+ if (*string == '\\')
+ {
+ string += 2;
+ length += 2;
+ }
+ }
+ while (*string != '"');
+ }
+ else
+ {
+ while (!isspace((unsigned char) *string))
+ {
+ string++;
+ length++;
+
+ }
+ }
+
+ *word = malloc(length + 1);
+
+ dst = *word;
+ src = word_start;
+
+
+ for (idx= 0; idx < length; idx++)
+ {
+ if (src[idx] == '\\')
+ switch (src[idx+1])
+ {
+ case 'n':
+ *dst++ = '\n';
+ idx++;
+ break;
+ case '"':
+ case '\\':
+ *dst++ = src[idx+1];
+ idx++;
+ break;
+ default:
+ *dst++ = '\\';
+ break;
+ }
+ else
+ *dst++ = src[idx];
+ }
+ *dst++ = 0;
+
+
+
+
+
+ if(*string)
+ return string + 1;
+ else
+ return 0;
+
+}
+dict_type *root;
+dict_type *
+DEFUN(lookup_word,(word),
+ char *word)
+{
+ dict_type *ptr = root;
+ while (ptr) {
+ if (strcmp(ptr->word, word) == 0) return ptr;
+ ptr = ptr->next;
+
+ }
+ if (warning)
+ fprintf(stderr,"Can't find %s\n",word);
+ return 0;
+
+
+}
+
+static void DEFUN_VOID(perform)
+{
+ tos = stack;
+
+ while (at(ptr, idx)) {
+ /* It's worth looking through the command list */
+ if (iscommand(ptr, idx))
+ {
+ char *next;
+ dict_type *word ;
+
+ (void) nextword(addr(ptr, idx), &next);
+
+
+ word = lookup_word(next);
+
+
+
+
+ if (word)
+ {
+ exec(word);
+ }
+ else
+ {
+ if (warning)
+ fprintf(stderr,"warning, %s is not recognised\n", next);
+ skip_past_newline();
+ }
+
+ }
+ else skip_past_newline();
+
+ }
+}
+
+dict_type *
+DEFUN(newentry,(word),
+ char *word)
+{
+ dict_type *new = (dict_type *)malloc(sizeof(dict_type));
+ new->word = word;
+ new->next = root;
+ root = new;
+ new->code = (stinst_type *)malloc(sizeof(stinst_type ));
+ new->code_length = 1;
+ new->code_end = 0;
+ return new;
+
+}
+
+
+unsigned int
+DEFUN(add_to_definition,(entry, word),
+ dict_type *entry AND
+ stinst_type word)
+{
+ if (entry->code_end == entry->code_length)
+ {
+ entry->code_length += 2;
+ entry->code =
+ (stinst_type *) realloc((char *)(entry->code),
+ entry->code_length *sizeof(word_type));
+ }
+ entry->code[entry->code_end] = word;
+
+return entry->code_end++;
+}
+
+
+
+
+
+
+
+void
+DEFUN(add_intrinsic,(name, func),
+ char *name AND
+ void (*func)())
+{
+ dict_type *new = newentry(name);
+ add_to_definition(new, func);
+ add_to_definition(new, 0);
+}
+
+void
+DEFUN(add_var,(name),
+ char *name)
+{
+ dict_type *new = newentry(name);
+ add_to_definition(new, push_number);
+ add_to_definition(new, (stinst_type)(&(new->var)));
+ add_to_definition(new,0);
+}
+
+
+void
+DEFUN(compile, (string),
+ char *string)
+{
+ /* add words to the dictionary */
+ char *word;
+ string = nextword(string, &word);
+ while (string && *string && word[0])
+ {
+ if (strcmp(word,"var")==0)
+ {
+ string=nextword(string, &word);
+
+ add_var(word);
+ string=nextword(string, &word);
+ }
+else
+
+ if (word[0] == ':')
+ {
+ dict_type *ptr;
+ /* Compile a word and add to dictionary */
+ string = nextword(string, &word);
+
+ ptr = newentry(word);
+ string = nextword(string, &word);
+ while (word[0] != ';' )
+ {
+ switch (word[0])
+ {
+ case '"':
+ /* got a string, embed magic push string
+ function */
+ add_to_definition(ptr, push_text);
+ add_to_definition(ptr, (stinst_type)(word+1));
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ /* Got a number, embedd the magic push number
+ function */
+ add_to_definition(ptr, push_number);
+ add_to_definition(ptr, (stinst_type)atol(word));
+ break;
+ default:
+ add_to_definition(ptr, call);
+ add_to_definition(ptr, (stinst_type)lookup_word(word));
+ }
+
+ string = nextword(string, &word);
+ }
+ add_to_definition(ptr,0);
+ string = nextword(string, &word);
+ }
+ else
+ {
+ fprintf(stderr,"syntax error at %s\n",string-1);
+ }
+ }
+
+}
+
+
+static void DEFUN_VOID(bang)
+{
+ *(long *)((isp[0])) = isp[-1];
+ isp-=2;
+ icheck_range ();
+ pc++;
+}
+
+WORD(atsign)
+{
+ isp[0] = *(long *)(isp[0]);
+ pc++;
+}
+
+WORD(hello)
+{
+ printf("hello\n");
+ pc++;
+}
+
+WORD(stdout_)
+{
+ isp++;
+ icheck_range ();
+ *isp = 1;
+ pc++;
+}
+
+WORD(stderr_)
+{
+ isp++;
+ icheck_range ();
+ *isp = 2;
+ pc++;
+}
+
+WORD(print)
+{
+ if (*isp == 1)
+ write_buffer (tos, stdout);
+ else if (*isp == 2)
+ write_buffer (tos, stderr);
+ else
+ fprintf (stderr, "print: illegal print destination `%ld'\n", *isp);
+ isp--;
+ tos--;
+ icheck_range ();
+ check_range ();
+ pc++;
+}
+
+
+static void DEFUN(read_in, (str, file),
+ string_type *str AND
+ FILE *file)
+{
+ char buff[10000];
+ unsigned int r;
+ do
+ {
+ r = fread(buff, 1, sizeof(buff), file);
+ catbuf(str, buff, r);
+ }
+ while (r);
+ buff[0] = 0;
+
+ catbuf(str, buff,1);
+}
+
+
+static void DEFUN_VOID(usage)
+{
+ fprintf(stderr,"usage: -[d|i|g] <file >file\n");
+ exit(33);
+}
+
+/* There is no reliable way to declare exit. Sometimes it returns
+ int, and sometimes it returns void. Sometimes it changes between
+ OS releases. Trying to get it declared correctly in the hosts file
+ is a pointless waste of time. */
+
+static void
+chew_exit ()
+{
+ exit (0);
+}
+
+int DEFUN(main,(ac,av),
+int ac AND
+char *av[])
+{
+ unsigned int i;
+ string_type buffer;
+ string_type pptr;
+
+ init_string(&buffer);
+ init_string(&pptr);
+ init_string(stack+0);
+ tos=stack+1;
+ ptr = &pptr;
+
+ add_intrinsic("push_text", push_text);
+ add_intrinsic("!", bang);
+ add_intrinsic("@", atsign);
+ add_intrinsic("hello",hello);
+ add_intrinsic("stdout",stdout_);
+ add_intrinsic("stderr",stderr_);
+ add_intrinsic("print",print);
+ add_intrinsic("skip_past_newline", skip_past_newline );
+ add_intrinsic("catstr", icatstr );
+ add_intrinsic("copy_past_newline", icopy_past_newline );
+ add_intrinsic("dup", other_dup );
+ add_intrinsic("drop", drop);
+ add_intrinsic("idrop", idrop);
+ add_intrinsic("remchar", remchar );
+ add_intrinsic("get_stuff_in_command", get_stuff_in_command );
+ add_intrinsic("do_fancy_stuff", do_fancy_stuff );
+ add_intrinsic("bulletize", bulletize );
+ add_intrinsic("courierize", courierize );
+ /* If the following line gives an error, exit() is not declared in the
+ ../hosts/foo.h file for this host. Fix it there, not here! */
+ /* No, don't fix it anywhere; see comment on chew_exit--Ian Taylor. */
+ add_intrinsic("exit", chew_exit );
+ add_intrinsic("swap", swap );
+ add_intrinsic("outputdots", outputdots );
+ add_intrinsic("paramstuff", paramstuff );
+ add_intrinsic("maybecatstr", maybecatstr );
+ add_intrinsic("translatecomments", translatecomments );
+ add_intrinsic("kill_bogus_lines", kill_bogus_lines);
+ add_intrinsic("indent", indent);
+ add_intrinsic("internalmode", internalmode);
+ add_intrinsic("print_stack_level", print_stack_level);
+ add_intrinsic("strip_trailing_newlines", strip_trailing_newlines);
+
+ /* Put a nl at the start */
+ catchar(&buffer,'\n');
+
+ read_in(&buffer, stdin);
+ remove_noncomments(&buffer, ptr);
+ for (i= 1; i < (unsigned int) ac; i++)
+ {
+ if (av[i][0] == '-')
+ {
+ if (av[i][1] == 'f')
+ {
+ string_type b;
+ FILE *f;
+ init_string(&b);
+
+ f = fopen(av[i+1],"r");
+ if (!f)
+ {
+ fprintf(stderr,"Can't open the input file %s\n",av[i+1]);
+ return 33;
+ }
+
+ read_in(&b, f);
+ compile(b.ptr);
+ perform();
+ }
+ else if (av[i][1] == 'i')
+ {
+ internal_wanted = 1;
+ }
+ else if (av[i][1] == 'w')
+ {
+ warning = 1;
+ }
+ else
+ usage ();
+ }
+ }
+ write_buffer(stack+0, stdout);
+ if (tos != stack)
+ {
+ fprintf (stderr, "finishing with current stack level %d\n", tos - stack);
+ return 1;
+ }
+ return 0;
+}
diff --git a/bfd/doc/doc.str b/bfd/doc/doc.str
new file mode 100644
index 00000000000..7a276fe59e6
--- /dev/null
+++ b/bfd/doc/doc.str
@@ -0,0 +1,158 @@
+: DOCDD
+ skip_past_newline
+ get_stuff_in_command kill_bogus_lines catstr
+ ;
+
+: ENDDD
+ skip_past_newline
+ ;
+
+: EXAMPLE
+ skip_past_newline
+ get_stuff_in_command kill_bogus_lines do_fancy_stuff translatecomments
+ courierize catstr
+
+ ;
+
+: INODE
+ "@node " catstr skip_past_newline copy_past_newline catstr
+ ;
+
+: CODE_FRAGMENT
+ EXAMPLE
+ ;
+
+: COMMENT
+ skip_past_newline
+ get_stuff_in_command
+ drop
+ ;
+
+: SYNOPSIS
+ skip_past_newline
+ "@strong{Synopsis}\n" catstr
+ "@example\n" catstr
+ get_stuff_in_command
+ kill_bogus_lines
+ indent
+ catstr
+ "@end example\n" catstr
+
+ ;
+
+: func
+ "@findex " - a
+ skip_past_newline
+ copy_past_newline
+ dup - a x x
+ "@subsubsection @code{" - a x x b
+ swap
+ remchar
+ "}\n" - a x b x c
+ catstr catstr catstr catstr catstr
+ ;
+
+: FUNCTION
+ "@findex " - a
+ skip_past_newline
+ copy_past_newline
+ dup - a x x
+ "@subsubsection @code{" - a x x b
+ swap
+ remchar
+ "}\n" - a x b x c
+ catstr catstr catstr catstr catstr
+ ;
+
+: bodytext
+ get_stuff_in_command
+ bulletize
+ kill_bogus_lines
+ do_fancy_stuff
+ courierize
+ catstr
+ "\n" catstr
+ ;
+
+: asection
+ skip_past_newline
+ catstr
+ copy_past_newline
+ do_fancy_stuff catstr
+ bodytext
+ ;
+
+: SECTION
+ "@section " asection ;
+
+: SUBSECTION
+ "@subsection " asection ;
+
+: SUBSUBSECTION
+ "@subsubsection " asection ;
+
+: subhead
+ skip_past_newline
+ bodytext
+ ;
+
+
+
+
+: DESCRIPTION
+ "@strong{Description}@*\n" catstr subhead ;
+
+: RETURNS
+ "@strong{Returns}@*\n" catstr subhead ;
+
+: INTERNAL_FUNCTION
+ func ;
+
+
+: INTERNAL_DEFINITION
+ func ;
+
+
+: INTERNAL
+ func ;
+
+: TYPEDEF
+ FUNCTION ;
+
+: SENUM
+ skip_past_newline
+ "Here are the possible values for @code{enum "
+ copy_past_newline remchar catstr
+ "}:\n\n" catstr catstr
+ ;
+: ENUM
+ skip_past_newline
+ "@deffn {} "
+ copy_past_newline catstr catstr
+ ;
+: ENUMX
+ skip_past_newline
+ "@deffnx {} "
+ copy_past_newline catstr
+ catstr
+ ;
+: ENUMEQ
+ skip_past_newline
+ "@deffn {} "
+ copy_past_newline catstr catstr
+ skip_past_newline
+ ;
+: ENUMEQX
+ skip_past_newline
+ "@deffnx {} "
+ copy_past_newline catstr
+ catstr
+ skip_past_newline
+ ;
+: ENUMDOC
+ skip_past_newline
+ get_stuff_in_command
+ strip_trailing_newlines
+ catstr
+ "\n@end deffn\n" catstr
+ ;
diff --git a/bfd/doc/makefile.vms b/bfd/doc/makefile.vms
new file mode 100644
index 00000000000..a0857c0caaf
--- /dev/null
+++ b/bfd/doc/makefile.vms
@@ -0,0 +1,5 @@
+CFLAGS = /noopt/include=([],[-],[-.-.include])
+LDFLAGS = /nomap
+LDLIBS = ,sys$$library:vaxcrtl.olb/lib
+
+all: chew.exe
diff --git a/bfd/doc/proto.str b/bfd/doc/proto.str
new file mode 100644
index 00000000000..8431c16bd57
--- /dev/null
+++ b/bfd/doc/proto.str
@@ -0,0 +1,135 @@
+
+: SYNOPSIS
+ skip_past_newline
+ get_stuff_in_command
+ paramstuff
+ indent
+ maybecatstr
+;
+
+: ignore
+ skip_past_newline
+ get_stuff_in_command
+ outputdots
+ maybecatstr
+ ;
+
+: CODE_FRAGMENT
+ ignore ;
+
+: external
+ 0 internalmode ignore ;
+
+: internal
+ 1 internalmode ignore ;
+
+- input stack { a b } output b if internal, a if external
+: ifinternal
+ "" swap 1 internalmode maybecatstr
+ swap
+ "" swap 0 internalmode maybecatstr
+ catstr
+ ;
+
+- Put note in output string, regardless of internal mode.
+: COMMENT
+ skip_past_newline
+ get_stuff_in_command
+ translatecomments
+ catstr
+ ;
+
+- SENUM enum-type-name
+- ENUM enum-name
+- ENUMX addl-enum-name
+- ENUMDOC doc for preceding enums
+- ENDSENUM max-enum-name
+
+: make_enum_header
+ dup
+ "enum " swap catstr
+ " {\n" catstr
+ swap " _dummy_first_" swap catstr catstr
+ ",\n" catstr
+ ;
+: make_string_table_header
+ dup
+ "#ifdef _BFD_MAKE_TABLE_" swap catstr swap
+ "\n\nstatic const char *const " swap catstr catstr
+ "_names[] = { \"@@uninitialized@@\",\n" catstr
+ ;
+: SENUM
+ skip_past_newline
+ copy_past_newline
+ remchar
+ dup
+ make_enum_header
+ swap
+ make_string_table_header
+ ifinternal
+ catstr
+ get_stuff_in_command catstr
+ translatecomments ;
+: ENDSENUM
+ skip_past_newline
+ copy_past_newline strip_trailing_newlines
+ dup
+ " " swap catstr " };\n" catstr swap
+ " \"@@overflow: " swap catstr "@@\",\n};\n#endif\n\n" catstr
+ ifinternal
+ catstr
+ ;
+: make_enumerator
+ " " swap catstr
+ ",\n" catstr
+ ;
+: make_enumerator_string
+ " \"" swap catstr
+ "\",\n" catstr
+ ;
+: ENUM
+ skip_past_newline
+ copy_past_newline
+ remchar
+ dup
+ make_enumerator
+ swap
+ make_enumerator_string
+ ifinternal
+ ;
+: ENUMX ENUM catstr ;
+: ENUMEQ
+ skip_past_newline
+ "#define "
+ copy_past_newline remchar
+ catstr
+ " "
+ catstr
+ copy_past_newline
+ catstr
+ "" swap 0 internalmode maybecatstr
+ ;
+: ENUMEQX ENUMEQ catstr ;
+: ENUMDOC
+ skip_past_newline
+ get_stuff_in_command
+ strip_trailing_newlines
+ "\n{* " swap catstr " *}\n" catstr
+ translatecomments
+ - discard it if we're doing internal mode
+ "" swap 0 internalmode maybecatstr
+ swap
+ catstr catstr
+ ;
+: ENDDD external ;
+: SECTION ignore ;
+: SUBSECTION ignore ;
+: SUBSUBSECTION ignore ;
+: INTERNAL_DEFINITION internal ;
+: DESCRIPTION ignore ;
+: FUNCTION external ;
+: RETURNS ignore ;
+: TYPEDEF external ;
+: INTERNAL_FUNCTION internal ;
+: INTERNAL internal ;
+: INODE ignore ;
diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c
new file mode 100644
index 00000000000..cbcc26b0035
--- /dev/null
+++ b/bfd/dwarf1.c
@@ -0,0 +1,576 @@
+/* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line).
+ Copyright 1998 Free Software Foundation, Inc.
+
+Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com).
+
+This file is part of BFD.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libiberty.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/dwarf.h"
+
+/* dwarf1_debug is the starting point for all dwarf1 info. */
+
+struct dwarf1_debug {
+
+ /* The bfd we are working with. */
+ bfd* abfd;
+
+ /* List of already parsed compilation units. */
+ struct dwarf1_unit* lastUnit;
+
+ /* The buffer for the .debug section.
+ Zero indicates that the .debug section failed to load. */
+ char* debug_section;
+
+ /* Pointer to the end of the .debug_info section memory buffer. */
+ char* debug_section_end;
+
+ /* The buffer for the .line section. */
+ char* line_section;
+
+ /* End of that buffer. */
+ char* line_section_end;
+
+ /* The current or next unread die within the .debug section. */
+ char* currentDie;
+};
+
+/* One dwarf1_unit for each parsed compilation unit die. */
+
+struct dwarf1_unit {
+ /* Linked starting from stash->lastUnit. */
+ struct dwarf1_unit* prev;
+
+ /* Name of the compilation unit. */
+ char* name;
+
+ /* The highest and lowest address used in the compilation unit. */
+ unsigned long low_pc;
+ unsigned long high_pc;
+
+ /* Does this unit have a statement list? */
+ int has_stmt_list;
+
+ /* If any, the offset of the line number table in the .line section. */
+ unsigned long stmt_list_offset;
+
+ /* If non-zero, a pointer to the first child of this unit. */
+ char* first_child;
+
+ /* How many line entries? */
+ unsigned long line_count;
+
+ /* The decoded line number table (line_count entries). */
+ struct linenumber* linenumber_table;
+
+ /* The list of functions in this unit. */
+ struct dwarf1_func* func_list;
+};
+
+
+
+/* One dwarf1_func for each parsed function die. */
+
+struct dwarf1_func {
+ /* Linked starting from aUnit->func_list. */
+ struct dwarf1_func* prev;
+
+ /* Name of function. */
+ char* name;
+
+ /* The highest and lowest address used in the compilation unit. */
+ unsigned long low_pc;
+ unsigned long high_pc;
+};
+
+
+/* Used to return info about a parsed die. */
+struct die_info {
+ unsigned long length;
+ unsigned long sibling;
+ unsigned long low_pc;
+ unsigned long high_pc;
+ unsigned long stmt_list_offset;
+
+ char* name;
+
+ int has_stmt_list;
+
+ unsigned short tag;
+};
+
+
+/* Parsed line number information. */
+struct linenumber {
+ /* First address in the line. */
+ unsigned long addr;
+
+ /* The line number. */
+ unsigned long linenumber;
+};
+
+
+/* Find the form of an attr, from the attr field. */
+#define FORM_FROM_ATTR(attr) ((attr) & 0xF) /* Implicitly specified */
+
+
+/* Return a newly allocated dwarf1_unit. It should be cleared and
+ then attached into the 'stash' at 'stash->lastUnit'. */
+
+static struct dwarf1_unit*
+alloc_dwarf1_unit (stash)
+ struct dwarf1_debug* stash;
+{
+ struct dwarf1_unit* x =
+ (struct dwarf1_unit*) bfd_alloc (stash->abfd,
+ sizeof (struct dwarf1_unit));
+ x->prev = stash->lastUnit;
+ stash->lastUnit = x;
+
+ return x;
+}
+
+/* Return a newly allocated dwarf1_func. It must be cleared and
+ attached into 'aUnit' at 'aUnit->func_list'. */
+
+static struct dwarf1_func*
+alloc_dwarf1_func (stash, aUnit)
+ struct dwarf1_debug* stash;
+ struct dwarf1_unit* aUnit;
+{
+ struct dwarf1_func* x =
+ (struct dwarf1_func*) bfd_alloc (stash->abfd,
+ sizeof (struct dwarf1_func));
+ x->prev = aUnit->func_list;
+ aUnit->func_list = x;
+
+ return x;
+}
+
+/* parse_die - parse a Dwarf1 die.
+ Parse the die starting at 'aDiePtr' into 'aDieInfo'.
+ 'abfd' must be the bfd from which the section that 'aDiePtr'
+ points to was pulled from.
+
+ Return false if the die is invalidly formatted; true otherwise. */
+
+static boolean
+parse_die (abfd, aDieInfo, aDiePtr)
+ bfd* abfd;
+ struct die_info* aDieInfo;
+ char* aDiePtr;
+{
+ char* this_die = aDiePtr;
+ char* xptr = this_die;
+
+ memset (aDieInfo,0,sizeof(*aDieInfo));
+
+ /* First comes the length. */
+ aDieInfo->length = bfd_get_32 (abfd, xptr);
+ xptr += 4;
+ if (aDieInfo->length < 6)
+ {
+ /* Just padding bytes. */
+ aDieInfo->tag = TAG_padding;
+ return true;
+ }
+
+ /* Then the tag. */
+ aDieInfo->tag = bfd_get_16 (abfd, xptr);
+ xptr += 2;
+
+ /* Then the attributes. */
+ while (xptr < (this_die + aDieInfo->length))
+ {
+ unsigned short attr;
+
+ /* Parse the attribute based on its form. This section
+ must handle all dwarf1 forms, but need only handle the
+ actual attributes that we care about. */
+
+ attr = bfd_get_16 (abfd, xptr);
+ xptr += 2;
+
+ switch (FORM_FROM_ATTR (attr))
+ {
+ case FORM_DATA2:
+ xptr += 2;
+ break;
+ case FORM_DATA4:
+ case FORM_REF:
+ if (attr == AT_sibling)
+ aDieInfo->sibling = bfd_get_32 (abfd, xptr);
+ else if (attr == AT_stmt_list)
+ {
+ aDieInfo->stmt_list_offset = bfd_get_32 (abfd, xptr);
+ aDieInfo->has_stmt_list = 1;
+ }
+ xptr += 4;
+ break;
+ case FORM_DATA8:
+ xptr += 8;
+ break;
+ case FORM_ADDR:
+ if (attr == AT_low_pc)
+ aDieInfo->low_pc = bfd_get_32 (abfd, xptr);
+ else if (attr == AT_high_pc)
+ aDieInfo->high_pc = bfd_get_32 (abfd, xptr);
+ xptr += 4;
+ break;
+ case FORM_BLOCK2:
+ xptr += 2 + bfd_get_16 (abfd, xptr);
+ break;
+ case FORM_BLOCK4:
+ xptr += 4 + bfd_get_32 (abfd, xptr);
+ break;
+ case FORM_STRING:
+ if (attr == AT_name)
+ aDieInfo->name = xptr;
+ xptr += strlen (xptr) + 1;
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Parse a dwarf1 line number table for 'aUnit->stmt_list_offset'
+ into 'aUnit->linenumber_table'. Return false if an error
+ occurs; true otherwise. */
+
+static boolean
+parse_line_table (stash, aUnit)
+ struct dwarf1_debug* stash;
+ struct dwarf1_unit* aUnit;
+{
+ char* xptr;
+
+ /* Load the ".line" section from the bfd if we haven't already. */
+ if (stash->line_section == 0)
+ {
+ asection *msec;
+ unsigned long size;
+
+ msec = bfd_get_section_by_name (stash->abfd, ".line");
+ if (! msec)
+ return false;
+
+ size = bfd_get_section_size_before_reloc (msec);
+ stash->line_section = (unsigned char*) bfd_alloc (stash->abfd, size);
+
+ if (! stash->line_section)
+ return false;
+
+ if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section, 0, size))
+ {
+ stash->line_section = 0;
+ return false;
+ }
+
+ stash->line_section_end = stash->line_section + size;
+ }
+
+ xptr = stash->line_section + aUnit->stmt_list_offset;
+ if (xptr < stash->line_section_end)
+ {
+ int eachLine;
+
+ char* tblend;
+ unsigned long base;
+
+ /* First comes the length. */
+ tblend = bfd_get_32 (stash->abfd, xptr) + xptr;
+ xptr += 4;
+
+ /* Then the base address for each address in the table. */
+ base = bfd_get_32 (stash->abfd, xptr);
+ xptr += 4;
+
+ /* How many line entrys?
+ 10 = 4 (line number) + 2 (pos in line) + 4 (address in line) */
+ aUnit->line_count = (tblend - xptr) / 10;
+
+ /* Allocate an array for the entries. */
+ aUnit->linenumber_table = (struct linenumber*)
+ bfd_alloc (stash->abfd,
+ sizeof (struct linenumber) * aUnit->line_count);
+
+ for (eachLine = 0; eachLine < aUnit->line_count; eachLine++)
+ {
+ /* A line number. */
+ aUnit->linenumber_table[eachLine].linenumber
+ = bfd_get_32 (stash->abfd, xptr);
+ xptr += 4;
+
+ /* Skip the position within the line. */
+ xptr += 2;
+
+ /* And finally the address. */
+ aUnit->linenumber_table[eachLine].addr
+ = base + bfd_get_32 (stash->abfd, xptr);
+ xptr += 4;
+ }
+ }
+
+ return true;
+}
+
+/* Parse each function die in a compilation unit 'aUnit'.
+ The first child die of 'aUnit' should be in 'aUnit->first_child',
+ the result is placed in 'aUnit->func_list'.
+ Return false if error; true otherwise. */
+
+static boolean
+parse_functions_in_unit (stash, aUnit)
+ struct dwarf1_debug* stash;
+ struct dwarf1_unit* aUnit;
+{
+ char* eachDie;
+
+ if (aUnit->first_child)
+ for (eachDie = aUnit->first_child;
+ eachDie < stash->debug_section_end;
+ )
+ {
+ struct die_info eachDieInfo;
+
+ if (! parse_die (stash->abfd, &eachDieInfo, eachDie))
+ return false;
+
+ if (eachDieInfo.tag == TAG_global_subroutine
+ || eachDieInfo.tag == TAG_subroutine
+ || eachDieInfo.tag == TAG_inlined_subroutine
+ || eachDieInfo.tag == TAG_entry_point)
+ {
+ struct dwarf1_func* aFunc = alloc_dwarf1_func (stash,aUnit);
+
+ aFunc->name = eachDieInfo.name;
+ aFunc->low_pc = eachDieInfo.low_pc;
+ aFunc->high_pc = eachDieInfo.high_pc;
+ }
+
+ /* Move to next sibling, if none, end loop */
+ if (eachDieInfo.sibling)
+ eachDie = stash->debug_section + eachDieInfo.sibling;
+ else
+ break;
+ }
+
+ return true;
+}
+
+/* Find the nearest line to 'addr' in 'aUnit'.
+ Return whether we found the line (or a function) without error. */
+
+static boolean
+dwarf1_unit_find_nearest_line (stash, aUnit, addr,
+ filename_ptr, functionname_ptr,
+ linenumber_ptr)
+ struct dwarf1_debug* stash;
+ struct dwarf1_unit* aUnit;
+ unsigned long addr;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *linenumber_ptr;
+{
+ int line_p = false;
+ int func_p = false;
+
+ if (aUnit->low_pc <= addr && addr < aUnit->high_pc)
+ {
+ if (aUnit->has_stmt_list)
+ {
+ int i;
+ struct dwarf1_func* eachFunc;
+
+ if (! aUnit->linenumber_table)
+ {
+ if (! parse_line_table (stash, aUnit))
+ return false;
+ }
+
+ if (! aUnit->func_list)
+ {
+ if (! parse_functions_in_unit (stash, aUnit))
+ return false;
+ }
+
+ for (i = 0; i < aUnit->line_count; i++)
+ {
+ if (aUnit->linenumber_table[i].addr <= addr
+ && addr < aUnit->linenumber_table[i+1].addr)
+ {
+ *filename_ptr = aUnit->name;
+ *linenumber_ptr = aUnit->linenumber_table[i].linenumber;
+ line_p = true;
+ break;
+ }
+ }
+
+ for (eachFunc = aUnit->func_list;
+ eachFunc;
+ eachFunc = eachFunc->prev)
+ {
+ if (eachFunc->low_pc <= addr
+ && addr < eachFunc->high_pc)
+ {
+ *functionname_ptr = eachFunc->name;
+ func_p = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return line_p || func_p;
+}
+
+
+
+
+/* The DWARF 1 version of find_nearest line.
+ Return true if the line is found without error. */
+
+boolean
+_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr, linenumber_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *linenumber_ptr;
+{
+ struct dwarf1_debug *stash = elf_tdata (abfd)->dwarf1_find_line_info;
+
+ struct dwarf1_unit* eachUnit;
+
+ /* What address are we looking for? */
+ bfd_vma addr = offset + section->vma;
+
+ *filename_ptr = NULL;
+ *functionname_ptr = NULL;
+ *linenumber_ptr = 0;
+
+
+ if (! stash)
+ {
+ asection *msec;
+ unsigned long size;
+
+ stash = elf_tdata (abfd)->dwarf1_find_line_info =
+ (struct dwarf1_debug*) bfd_zalloc (abfd, sizeof (struct dwarf1_debug));
+
+ if (! stash)
+ return false;
+
+ msec = bfd_get_section_by_name (abfd, ".debug");
+ if (! msec)
+ {
+ /* No dwarf1 info. Note that at this point the stash
+ has been allocated, but contains zeros, this lets
+ future calls to this function fail quicker. */
+ return false;
+ }
+
+ size = bfd_get_section_size_before_reloc (msec);
+ stash->debug_section = (unsigned char*) bfd_alloc (abfd, size);
+
+ if (! stash->debug_section)
+ return false;
+
+ if (! bfd_get_section_contents (abfd, msec, stash->debug_section, 0, size))
+ {
+ stash->debug_section = 0;
+ return false;
+ }
+
+ stash->debug_section_end = stash->debug_section + size;
+ stash->currentDie = stash->debug_section;
+ stash->abfd = abfd;
+ }
+
+ /* A null debug_section indicates that there was no dwarf1 info
+ or that an error occured while setting up the stash. */
+
+ if (! stash->debug_section)
+ return false;
+
+
+ /* Look at the previously parsed units to see if any contain
+ the addr. */
+ for (eachUnit = stash->lastUnit; eachUnit; eachUnit = eachUnit->prev)
+ {
+ if (eachUnit->low_pc <= addr && addr < eachUnit->high_pc)
+ return dwarf1_unit_find_nearest_line (stash, eachUnit, addr,
+ filename_ptr,
+ functionname_ptr,
+ linenumber_ptr);
+ }
+
+ while (stash->currentDie < stash->debug_section_end)
+ {
+ struct die_info aDieInfo;
+
+ if (! parse_die (stash->abfd, &aDieInfo, stash->currentDie))
+ return false;
+
+ if (aDieInfo.tag == TAG_compile_unit)
+ {
+ struct dwarf1_unit* aUnit
+ = alloc_dwarf1_unit (stash);
+
+ aUnit->name = aDieInfo.name;
+ aUnit->low_pc = aDieInfo.low_pc;
+ aUnit->high_pc = aDieInfo.high_pc;
+ aUnit->has_stmt_list = aDieInfo.has_stmt_list;
+ aUnit->stmt_list_offset = aDieInfo.stmt_list_offset;
+
+ /* A die has a child if it's followed by a die that is
+ not it's sibling. */
+ if (aDieInfo.sibling
+ && stash->currentDie + aDieInfo.length
+ < stash->debug_section_end
+ && stash->currentDie + aDieInfo.length
+ != stash->debug_section + aDieInfo.sibling)
+ aUnit->first_child = stash->currentDie + aDieInfo.length;
+ else
+ aUnit->first_child = 0;
+
+ if (aUnit->low_pc <= addr && addr < aUnit->high_pc)
+ return dwarf1_unit_find_nearest_line (stash, aUnit, addr,
+ filename_ptr,
+ functionname_ptr,
+ linenumber_ptr);
+ }
+
+ if (aDieInfo.sibling != 0)
+ stash->currentDie = stash->debug_section + aDieInfo.sibling;
+ else
+ stash->currentDie += aDieInfo.length;
+ }
+
+ return false;
+}
+
+
+/* EOF */
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
new file mode 100644
index 00000000000..385bf821b6e
--- /dev/null
+++ b/bfd/dwarf2.c
@@ -0,0 +1,1466 @@
+/* DWARF 2 support.
+ Copyright 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
+ (gavin@cygnus.com).
+
+ From the dwarf2read.c header:
+ Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
+ Inc. with support from Florida State University (under contract
+ with the Ada Joint Program Office), and Silicon Graphics, Inc.
+ Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
+ based on Fred Fish's (Cygnus Support) implementation of DWARF 1
+ support in dwarfread.c
+
+This file is part of BFD.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libiberty.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/dwarf2.h"
+
+/* The data in the .debug_line statement prologue looks like this. */
+struct line_head
+ {
+ unsigned int total_length;
+ unsigned short version;
+ unsigned int prologue_length;
+ unsigned char minimum_instruction_length;
+ unsigned char default_is_stmt;
+ int line_base;
+ unsigned char line_range;
+ unsigned char opcode_base;
+ unsigned char *standard_opcode_lengths;
+ };
+
+/* Attributes have a name and a value */
+struct attribute
+ {
+ enum dwarf_attribute name;
+ enum dwarf_form form;
+ union
+ {
+ char *str;
+ struct dwarf_block *blk;
+ unsigned int unsnd;
+ int snd;
+ bfd_vma addr;
+ }
+ u;
+ };
+
+/* Get at parts of an attribute structure */
+
+#define DW_STRING(attr) ((attr)->u.str)
+#define DW_UNSND(attr) ((attr)->u.unsnd)
+#define DW_BLOCK(attr) ((attr)->u.blk)
+#define DW_SND(attr) ((attr)->u.snd)
+#define DW_ADDR(attr) ((attr)->u.addr)
+
+/* Blocks are a bunch of untyped bytes. */
+struct dwarf_block
+ {
+ unsigned int size;
+ char *data;
+ };
+
+
+struct dwarf2_debug {
+
+ /* A list of all previously read comp_units. */
+ struct comp_unit* all_comp_units;
+
+ /* The next unread compilation unit within the .debug_info section.
+ Zero indicates that the .debug_info section has not been loaded
+ into a buffer yet.*/
+ char* info_ptr;
+
+ /* Pointer to the end of the .debug_info section memory buffer. */
+ char* info_ptr_end;
+
+ /* Pointer to the .debug_abbrev section loaded into memory. */
+ char* dwarf_abbrev_buffer;
+
+ /* Length of the loaded .debug_abbrev section. */
+ unsigned long dwarf_abbrev_size;
+};
+
+
+
+/* A minimal decoding of DWARF2 compilation units. We only decode
+ what's needed to get to the line number information. */
+
+struct comp_unit {
+
+ /* Chain the previously read compilation units. */
+ struct comp_unit* next_unit;
+
+ /* Keep the bdf convenient (for memory allocation). */
+ bfd* abfd;
+
+ /* The lowest and higest addresses contained in this compilation
+ unit as specified in the compilation unit header. */
+ bfd_vma low;
+ bfd_vma high;
+
+ /* The DW_AT_name attribute (for error messages). */
+ char* name;
+
+ /* The abbrev hash table. */
+ struct abbrev_info** abbrevs;
+
+ /* Note that an error was found by comp_unit_find_nearest_line. */
+ int error;
+
+ /* The DW_AT_comp_dir attribute */
+ char* comp_dir;
+
+ /* True if there is a line number table associated with this comp. unit. */
+ int stmtlist;
+
+ /* The offset into .debug_line of the line number table. */
+ unsigned long line_offset;
+
+ /* Pointer to the first child die for the comp unit. */
+ char *first_child_die_ptr;
+
+ /* The end of the comp unit. */
+ char *end_ptr;
+
+ /* The decoded line number, NULL if not yet decoded. */
+ struct line_info_table* line_table;
+
+ /* A list of the functions found in this comp. unit. */
+ struct funcinfo* function_table;
+
+ /* Address size for this unit - from unit header */
+ unsigned char addr_size;
+};
+
+
+
+/* VERBATIM
+ The following function up to the END VERBATIM mark are
+ copied directly from dwarf2read.c. */
+
+/* read dwarf information from a buffer */
+
+static unsigned int
+read_1_byte (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_8 (abfd, (bfd_byte *) buf);
+}
+
+static int
+read_1_signed_byte (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_signed_8 (abfd, (bfd_byte *) buf);
+}
+
+static unsigned int
+read_2_bytes (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_16 (abfd, (bfd_byte *) buf);
+}
+
+#if 0
+
+/* This is not used. */
+
+static int
+read_2_signed_bytes (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_signed_16 (abfd, (bfd_byte *) buf);
+}
+
+#endif
+
+static unsigned int
+read_4_bytes (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_32 (abfd, (bfd_byte *) buf);
+}
+
+#if 0
+
+/* This is not used. */
+
+static int
+read_4_signed_bytes (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_signed_32 (abfd, (bfd_byte *) buf);
+}
+
+#endif
+
+static unsigned int
+read_8_bytes (abfd, buf)
+ bfd *abfd;
+ char *buf;
+{
+ return bfd_get_64 (abfd, (bfd_byte *) buf);
+}
+
+static char *
+read_n_bytes (abfd, buf, size)
+ bfd * abfd;
+ char *buf;
+ unsigned int size;
+{
+ /* If the size of a host char is 8 bits, we can return a pointer
+ to the buffer, otherwise we have to copy the data to a buffer
+ allocated on the temporary obstack. */
+ return buf;
+}
+
+static char *
+read_string (abfd, buf, bytes_read_ptr)
+ bfd *abfd;
+ char *buf;
+ unsigned int *bytes_read_ptr;
+{
+ /* If the size of a host char is 8 bits, we can return a pointer
+ to the string, otherwise we have to copy the string to a buffer
+ allocated on the temporary obstack. */
+ if (*buf == '\0')
+ {
+ *bytes_read_ptr = 1;
+ return NULL;
+ }
+ *bytes_read_ptr = strlen (buf) + 1;
+ return buf;
+}
+
+static unsigned int
+read_unsigned_leb128 (abfd, buf, bytes_read_ptr)
+ bfd *abfd;
+ char *buf;
+ unsigned int *bytes_read_ptr;
+{
+ unsigned int result;
+ unsigned int num_read;
+ int shift;
+ unsigned char byte;
+
+ result = 0;
+ shift = 0;
+ num_read = 0;
+
+ do
+ {
+ byte = bfd_get_8 (abfd, (bfd_byte *) buf);
+ buf ++;
+ num_read ++;
+ result |= ((byte & 0x7f) << shift);
+ shift += 7;
+ }
+ while (byte & 0x80);
+
+ * bytes_read_ptr = num_read;
+
+ return result;
+}
+
+static int
+read_signed_leb128 (abfd, buf, bytes_read_ptr)
+ bfd * abfd;
+ char * buf;
+ unsigned int * bytes_read_ptr;
+{
+ int result;
+ int shift;
+ int num_read;
+ unsigned char byte;
+
+ result = 0;
+ shift = 0;
+ num_read = 0;
+
+ do
+ {
+ byte = bfd_get_8 (abfd, (bfd_byte *) buf);
+ buf ++;
+ num_read ++;
+ result |= ((byte & 0x7f) << shift);
+ shift += 7;
+ }
+ while (byte & 0x80);
+
+ if ((shift < 32) && (byte & 0x40))
+ result |= -(1 << shift);
+
+ * bytes_read_ptr = num_read;
+
+ return result;
+}
+
+/* END VERBATIM */
+
+static bfd_vma
+read_address (unit, buf)
+ struct comp_unit* unit;
+ char *buf;
+{
+ bfd_vma retval = 0;
+
+ if (unit->addr_size == 4)
+ {
+ retval = bfd_get_32 (unit->abfd, (bfd_byte *) buf);
+ } else {
+ retval = bfd_get_64 (unit->abfd, (bfd_byte *) buf);
+ }
+ return retval;
+}
+
+
+
+
+
+/* This data structure holds the information of an abbrev. */
+struct abbrev_info
+ {
+ unsigned int number; /* number identifying abbrev */
+ enum dwarf_tag tag; /* dwarf tag */
+ int has_children; /* boolean */
+ unsigned int num_attrs; /* number of attributes */
+ struct attr_abbrev *attrs; /* an array of attribute descriptions */
+ struct abbrev_info *next; /* next in chain */
+ };
+
+struct attr_abbrev
+ {
+ enum dwarf_attribute name;
+ enum dwarf_form form;
+ };
+
+#ifndef ABBREV_HASH_SIZE
+#define ABBREV_HASH_SIZE 121
+#endif
+#ifndef ATTR_ALLOC_CHUNK
+#define ATTR_ALLOC_CHUNK 4
+#endif
+
+/* Lookup an abbrev_info structure in the abbrev hash table. */
+
+static struct abbrev_info *
+lookup_abbrev (number,abbrevs)
+ unsigned int number;
+ struct abbrev_info **abbrevs;
+{
+ unsigned int hash_number;
+ struct abbrev_info *abbrev;
+
+ hash_number = number % ABBREV_HASH_SIZE;
+ abbrev = abbrevs[hash_number];
+
+ while (abbrev)
+ {
+ if (abbrev->number == number)
+ return abbrev;
+ else
+ abbrev = abbrev->next;
+ }
+ return NULL;
+}
+
+/* In DWARF version 2, the description of the debugging information is
+ stored in a separate .debug_abbrev section. Before we read any
+ dies from a section we read in all abbreviations and install them
+ in a hash table. */
+
+static struct abbrev_info**
+read_abbrevs (abfd, offset)
+ bfd * abfd;
+ unsigned int offset;
+{
+ struct abbrev_info **abbrevs;
+ char *abbrev_ptr;
+ struct abbrev_info *cur_abbrev;
+ unsigned int abbrev_number, bytes_read, abbrev_name;
+ unsigned int abbrev_form, hash_number;
+ struct dwarf2_debug *stash;
+
+ stash = elf_tdata(abfd)->dwarf2_find_line_info;
+
+ if (! stash->dwarf_abbrev_buffer)
+ {
+ asection *msec;
+
+ msec = bfd_get_section_by_name (abfd, ".debug_abbrev");
+ if (! msec)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: Can't find .debug_abbrev section."));
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ stash->dwarf_abbrev_size = bfd_get_section_size_before_reloc (msec);
+ stash->dwarf_abbrev_buffer = (unsigned char*) bfd_alloc (abfd, stash->dwarf_abbrev_size);
+ if (! stash->dwarf_abbrev_buffer)
+ return 0;
+
+ if (! bfd_get_section_contents (abfd, msec,
+ stash->dwarf_abbrev_buffer, 0,
+ stash->dwarf_abbrev_size))
+ return 0;
+ }
+
+ if (offset > stash->dwarf_abbrev_size)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%u) bigger than abbrev size (%u)."),
+ offset, stash->dwarf_abbrev_size );
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ abbrevs = (struct abbrev_info**) bfd_zalloc (abfd, sizeof(struct abbrev_info*) * ABBREV_HASH_SIZE);
+
+ abbrev_ptr = stash->dwarf_abbrev_buffer + offset;
+ abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+
+ /* loop until we reach an abbrev number of 0 */
+ while (abbrev_number)
+ {
+ cur_abbrev = (struct abbrev_info*)bfd_zalloc (abfd, sizeof (struct abbrev_info));
+
+ /* read in abbrev header */
+ cur_abbrev->number = abbrev_number;
+ cur_abbrev->tag = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+ cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr);
+ abbrev_ptr += 1;
+
+ /* now read in declarations */
+ abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+ abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+ while (abbrev_name)
+ {
+ if ((cur_abbrev->num_attrs % ATTR_ALLOC_CHUNK) == 0)
+ {
+ cur_abbrev->attrs = (struct attr_abbrev *)
+ bfd_realloc (cur_abbrev->attrs,
+ (cur_abbrev->num_attrs + ATTR_ALLOC_CHUNK)
+ * sizeof (struct attr_abbrev));
+ if (! cur_abbrev->attrs)
+ return 0;
+ }
+ cur_abbrev->attrs[cur_abbrev->num_attrs].name = abbrev_name;
+ cur_abbrev->attrs[cur_abbrev->num_attrs++].form = abbrev_form;
+ abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+ abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+ }
+
+ hash_number = abbrev_number % ABBREV_HASH_SIZE;
+ cur_abbrev->next = abbrevs[hash_number];
+ abbrevs[hash_number] = cur_abbrev;
+
+ /* Get next abbreviation.
+ Under Irix6 the abbreviations for a compilation unit are not
+ always properly terminated with an abbrev number of 0.
+ Exit loop if we encounter an abbreviation which we have
+ already read (which means we are about to read the abbreviations
+ for the next compile unit) or if the end of the abbreviation
+ table is reached. */
+ if ((unsigned int) (abbrev_ptr - stash->dwarf_abbrev_buffer)
+ >= stash->dwarf_abbrev_size)
+ break;
+ abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ abbrev_ptr += bytes_read;
+ if (lookup_abbrev (abbrev_number,abbrevs) != NULL)
+ break;
+ }
+
+ return abbrevs;
+}
+
+/* Read an attribute described by an abbreviated attribute. */
+
+static char *
+read_attribute (attr, abbrev, unit, info_ptr)
+ struct attribute *attr;
+ struct attr_abbrev *abbrev;
+ struct comp_unit *unit;
+ char *info_ptr;
+{
+ bfd *abfd = unit->abfd;
+ unsigned int bytes_read;
+ struct dwarf_block *blk;
+
+ attr->name = abbrev->name;
+ attr->form = abbrev->form;
+ switch (abbrev->form)
+ {
+ case DW_FORM_addr:
+ case DW_FORM_ref_addr:
+ DW_ADDR (attr) = read_address (unit, info_ptr);
+ info_ptr += unit->addr_size;
+ break;
+ case DW_FORM_block2:
+ blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ blk->size = read_2_bytes (abfd, info_ptr);
+ info_ptr += 2;
+ blk->data = read_n_bytes (abfd, info_ptr, blk->size);
+ info_ptr += blk->size;
+ DW_BLOCK (attr) = blk;
+ break;
+ case DW_FORM_block4:
+ blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ blk->size = read_4_bytes (abfd, info_ptr);
+ info_ptr += 4;
+ blk->data = read_n_bytes (abfd, info_ptr, blk->size);
+ info_ptr += blk->size;
+ DW_BLOCK (attr) = blk;
+ break;
+ case DW_FORM_data2:
+ DW_UNSND (attr) = read_2_bytes (abfd, info_ptr);
+ info_ptr += 2;
+ break;
+ case DW_FORM_data4:
+ DW_UNSND (attr) = read_4_bytes (abfd, info_ptr);
+ info_ptr += 4;
+ break;
+ case DW_FORM_data8:
+ DW_UNSND (attr) = read_8_bytes (abfd, info_ptr);
+ info_ptr += 8;
+ break;
+ case DW_FORM_string:
+ DW_STRING (attr) = read_string (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+ break;
+ case DW_FORM_block:
+ blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+ blk->data = read_n_bytes (abfd, info_ptr, blk->size);
+ info_ptr += blk->size;
+ DW_BLOCK (attr) = blk;
+ break;
+ case DW_FORM_block1:
+ blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ blk->size = read_1_byte (abfd, info_ptr);
+ info_ptr += 1;
+ blk->data = read_n_bytes (abfd, info_ptr, blk->size);
+ info_ptr += blk->size;
+ DW_BLOCK (attr) = blk;
+ break;
+ case DW_FORM_data1:
+ DW_UNSND (attr) = read_1_byte (abfd, info_ptr);
+ info_ptr += 1;
+ break;
+ case DW_FORM_flag:
+ DW_UNSND (attr) = read_1_byte (abfd, info_ptr);
+ info_ptr += 1;
+ break;
+ case DW_FORM_sdata:
+ DW_SND (attr) = read_signed_leb128 (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+ break;
+ case DW_FORM_udata:
+ DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+ break;
+ case DW_FORM_ref1:
+ DW_UNSND (attr) = read_1_byte (abfd, info_ptr);
+ info_ptr += 1;
+ break;
+ case DW_FORM_ref2:
+ DW_UNSND (attr) = read_2_bytes (abfd, info_ptr);
+ info_ptr += 2;
+ break;
+ case DW_FORM_ref4:
+ DW_UNSND (attr) = read_4_bytes (abfd, info_ptr);
+ info_ptr += 4;
+ break;
+ case DW_FORM_ref_udata:
+ DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+ break;
+ case DW_FORM_strp:
+ case DW_FORM_indirect:
+ default:
+ (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %d."),
+ abbrev->form);
+ bfd_set_error (bfd_error_bad_value);
+ }
+ return info_ptr;
+}
+
+
+/* Source line information table routines. */
+
+#define FILE_ALLOC_CHUNK 5
+#define DIR_ALLOC_CHUNK 5
+
+struct line_info {
+ struct line_info* prev_line;
+
+ bfd_vma address;
+ char* filename;
+ unsigned int line;
+ unsigned int column;
+};
+
+struct fileinfo {
+ char *name;
+ unsigned int dir;
+ unsigned int time;
+ unsigned int size;
+};
+
+struct line_info_table {
+ bfd* abfd;
+
+ unsigned int num_files;
+ unsigned int num_dirs;
+
+ char* comp_dir;
+ char** dirs;
+ struct fileinfo* files;
+ struct line_info* last_line;
+};
+
+static void
+add_line_info (table, address, filename, line, column)
+ struct line_info_table* table;
+ bfd_vma address;
+ char* filename;
+ unsigned int line;
+ unsigned int column;
+{
+ struct line_info* info = (struct line_info*)
+ bfd_alloc (table->abfd, sizeof (struct line_info));
+
+ info->prev_line = table->last_line;
+ table->last_line = info;
+
+ info->address = address;
+ info->filename = filename;
+ info->line = line;
+ info->column = column;
+}
+
+static char*
+concat_filename (table, file)
+ struct line_info_table* table;
+ unsigned int file;
+{
+ char* filename = table->files[file - 1].name;
+ if (*filename == '/')
+ return filename;
+
+ else
+ {
+ char* dirname = (table->files[file - 1].dir
+ ? table->dirs[table->files[file - 1].dir - 1]
+ : table->comp_dir);
+ return (char*) concat (dirname, "/", filename, NULL);
+ }
+}
+
+/* Decode the line number information for UNIT. */
+
+static struct line_info_table*
+decode_line_info (unit)
+ struct comp_unit *unit;
+{
+ bfd *abfd = unit->abfd;
+
+ static char* dwarf_line_buffer = 0;
+
+ struct line_info_table* table;
+
+ char *line_ptr;
+ char *line_end;
+ struct line_head lh;
+ unsigned int i, bytes_read;
+ char *cur_file, *cur_dir;
+ unsigned char op_code, extended_op, adj_opcode;
+
+ if (! dwarf_line_buffer)
+ {
+ asection *msec;
+ unsigned long size;
+
+ msec = bfd_get_section_by_name (abfd, ".debug_line");
+ if (! msec)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: Can't find .debug_line section."));
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ size = bfd_get_section_size_before_reloc (msec);
+ dwarf_line_buffer = (unsigned char*) bfd_alloc (abfd, size);
+ if (! dwarf_line_buffer)
+ return 0;
+
+ if (! bfd_get_section_contents (abfd, msec,
+ dwarf_line_buffer, 0,
+ size))
+ return 0;
+
+ /* FIXME: We ought to apply the relocs against this section before
+ we process it.... */
+ }
+
+ table = (struct line_info_table*) bfd_alloc (abfd,
+ sizeof (struct line_info_table));
+ table->abfd = abfd;
+ table->comp_dir = unit->comp_dir;
+
+ table->num_files = 0;
+ table->files = NULL;
+
+ table->num_dirs = 0;
+ table->dirs = NULL;
+
+ line_ptr = dwarf_line_buffer + unit->line_offset;
+
+ /* read in the prologue */
+ lh.total_length = read_4_bytes (abfd, line_ptr);
+ line_ptr += 4;
+ line_end = line_ptr + lh.total_length;
+ lh.version = read_2_bytes (abfd, line_ptr);
+ line_ptr += 2;
+ lh.prologue_length = read_4_bytes (abfd, line_ptr);
+ line_ptr += 4;
+ lh.minimum_instruction_length = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ lh.default_is_stmt = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ lh.line_base = read_1_signed_byte (abfd, line_ptr);
+ line_ptr += 1;
+ lh.line_range = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ lh.opcode_base = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ lh.standard_opcode_lengths = (unsigned char *)
+ bfd_alloc (abfd, lh.opcode_base * sizeof (unsigned char));
+
+ lh.standard_opcode_lengths[0] = 1;
+ for (i = 1; i < lh.opcode_base; ++i)
+ {
+ lh.standard_opcode_lengths[i] = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ }
+
+ /* Read directory table */
+ while ((cur_dir = read_string (abfd, line_ptr, &bytes_read)) != NULL)
+ {
+ line_ptr += bytes_read;
+ if ((table->num_dirs % DIR_ALLOC_CHUNK) == 0)
+ {
+ table->dirs = (char **)
+ bfd_realloc (table->dirs,
+ (table->num_dirs + DIR_ALLOC_CHUNK) * sizeof (char *));
+ if (! table->dirs)
+ return 0;
+ }
+ table->dirs[table->num_dirs++] = cur_dir;
+ }
+ line_ptr += bytes_read;
+
+ /* Read file name table */
+ while ((cur_file = read_string (abfd, line_ptr, &bytes_read)) != NULL)
+ {
+ line_ptr += bytes_read;
+ if ((table->num_files % FILE_ALLOC_CHUNK) == 0)
+ {
+ table->files = (struct fileinfo *)
+ bfd_realloc (table->files,
+ (table->num_files + FILE_ALLOC_CHUNK)
+ * sizeof (struct fileinfo));
+ if (! table->files)
+ return 0;
+ }
+ table->files[table->num_files].name = cur_file;
+ table->files[table->num_files].dir =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ table->files[table->num_files].time =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ table->files[table->num_files].size =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ table->num_files++;
+ }
+ line_ptr += bytes_read;
+
+ /* Read the statement sequences until there's nothing left. */
+ while (line_ptr < line_end)
+ {
+ /* state machine registers */
+ bfd_vma address = 0;
+ char* filename = concat_filename (table, 1);
+ unsigned int line = 1;
+ unsigned int column = 0;
+ int is_stmt = lh.default_is_stmt;
+ int basic_block = 0;
+ int end_sequence = 0;
+
+ /* Decode the table. */
+ while (! end_sequence)
+ {
+ op_code = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ switch (op_code)
+ {
+ case DW_LNS_extended_op:
+ line_ptr += 1; /* ignore length */
+ extended_op = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ switch (extended_op)
+ {
+ case DW_LNE_end_sequence:
+ end_sequence = 1;
+ add_line_info (table, address, filename, line, column);
+ break;
+ case DW_LNE_set_address:
+ address = read_address (unit, line_ptr);
+ line_ptr += unit->addr_size;
+ break;
+ case DW_LNE_define_file:
+ cur_file = read_string (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ if ((table->num_files % FILE_ALLOC_CHUNK) == 0)
+ {
+ table->files = (struct fileinfo *)
+ bfd_realloc (table->files,
+ (table->num_files + FILE_ALLOC_CHUNK)
+ * sizeof (struct fileinfo));
+ if (! table->files)
+ return 0;
+ }
+ table->files[table->num_files].name = cur_file;
+ table->files[table->num_files].dir =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ table->files[table->num_files].time =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ table->files[table->num_files].size =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ table->num_files++;
+ break;
+ default:
+ (*_bfd_error_handler) (_("Dwarf Error: mangled line number section."));
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+ break;
+ case DW_LNS_copy:
+ add_line_info (table, address, filename, line, column);
+ basic_block = 0;
+ break;
+ case DW_LNS_advance_pc:
+ address += lh.minimum_instruction_length
+ * read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ break;
+ case DW_LNS_advance_line:
+ line += read_signed_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ break;
+ case DW_LNS_set_file:
+ {
+ unsigned int file;
+
+ /* The file and directory tables are 0 based, the references
+ are 1 based. */
+ file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ filename = concat_filename (table, file);
+ break;
+ }
+ case DW_LNS_set_column:
+ column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ break;
+ case DW_LNS_negate_stmt:
+ is_stmt = (!is_stmt);
+ break;
+ case DW_LNS_set_basic_block:
+ basic_block = 1;
+ break;
+ case DW_LNS_const_add_pc:
+ address += (255 - lh.opcode_base) / lh.line_range;
+ break;
+ case DW_LNS_fixed_advance_pc:
+ address += read_2_bytes (abfd, line_ptr);
+ line_ptr += 2;
+ break;
+ default: /* special operand */
+ adj_opcode = op_code - lh.opcode_base;
+ address += (adj_opcode / lh.line_range)
+ * lh.minimum_instruction_length;
+ line += lh.line_base + (adj_opcode % lh.line_range);
+ /* append row to matrix using current values */
+ add_line_info (table, address, filename, line, column);
+ basic_block = 1;
+ }
+ }
+ }
+
+ return table;
+}
+
+
+/* If ADDR is within TABLE set the output parameters and return true,
+ otherwise return false. The output parameters, FILENAME_PTR and
+ LINENUMBER_PTR, are pointers to the objects to be filled in. */
+
+static boolean
+lookup_address_in_line_info_table (table,
+ addr,
+ filename_ptr,
+ linenumber_ptr)
+ struct line_info_table* table;
+ bfd_vma addr;
+ const char **filename_ptr;
+ unsigned int *linenumber_ptr;
+{
+ struct line_info* each_line;
+ struct line_info* next_line;
+
+ for (next_line = 0, each_line = table->last_line;
+ each_line;
+ next_line = each_line, each_line = each_line->prev_line)
+ {
+ if (addr >= each_line->address
+ && (next_line == 0
+ || addr < next_line->address))
+ {
+ *filename_ptr = each_line->filename;
+ *linenumber_ptr = each_line->line;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+
+/* Function table functions. */
+
+struct funcinfo {
+ struct funcinfo *prev_func;
+
+ char* name;
+ bfd_vma low;
+ bfd_vma high;
+};
+
+
+/* If ADDR is within TABLE, set FUNCTIONNAME_PTR, and return true. */
+
+static boolean
+lookup_address_in_function_table (table,
+ addr,
+ functionname_ptr)
+ struct funcinfo* table;
+ bfd_vma addr;
+ const char **functionname_ptr;
+{
+ struct funcinfo* each_func;
+
+ for (each_func = table;
+ each_func;
+ each_func = each_func->prev_func)
+ {
+ if (addr >= each_func->low && addr < each_func->high)
+ {
+ *functionname_ptr = each_func->name;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+
+/* DWARF2 Compilation unit functions. */
+
+
+/* Scan over each die in a comp. unit looking for functions to add
+ to the function table. */
+
+static boolean
+scan_unit_for_functions (unit)
+ struct comp_unit *unit;
+{
+ bfd *abfd = unit->abfd;
+ char *info_ptr = unit->first_child_die_ptr;
+ int nesting_level = 1;
+
+ while (nesting_level)
+ {
+ unsigned int abbrev_number, bytes_read, i;
+ struct abbrev_info *abbrev;
+ struct attribute attr;
+ struct funcinfo *func;
+ char* name = 0;
+
+ abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+
+ if (! abbrev_number)
+ {
+ nesting_level--;
+ continue;
+ }
+
+ abbrev = lookup_abbrev (abbrev_number,unit->abbrevs);
+ if (! abbrev)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."),
+ abbrev_number);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (abbrev->tag == DW_TAG_subprogram)
+ {
+ func = (struct funcinfo*) bfd_zalloc (abfd, sizeof (struct funcinfo));
+ func->prev_func = unit->function_table;
+ unit->function_table = func;
+ }
+ else
+ func = NULL;
+
+ for (i = 0; i < abbrev->num_attrs; ++i)
+ {
+ info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr);
+
+ if (func)
+ {
+ switch (attr.name)
+ {
+ case DW_AT_name:
+
+ name = DW_STRING (&attr);
+
+ /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
+ if (func->name == NULL)
+ func->name = DW_STRING (&attr);
+ break;
+
+ case DW_AT_MIPS_linkage_name:
+ func->name = DW_STRING (&attr);
+ break;
+
+ case DW_AT_low_pc:
+ func->low = DW_ADDR (&attr);
+ break;
+
+ case DW_AT_high_pc:
+ func->high = DW_ADDR (&attr);
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (attr.name)
+ {
+ case DW_AT_name:
+ name = DW_STRING (&attr);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ if (abbrev->has_children)
+ nesting_level++;
+ }
+
+ return true;
+}
+
+
+
+
+
+
+/* Parse a DWARF2 compilation unit starting at INFO_PTR. This includes
+ the compilation unit header that proceeds the DIE's, but does not
+ include the length field that preceeds each compilation unit header.
+ END_PTR points one past the end of this comp unit.
+
+ This routine does not read the whole compilation unit; only enough
+ to get to the line number information for the compilation unit. */
+
+static struct comp_unit *
+parse_comp_unit (abfd, info_ptr, end_ptr)
+ bfd* abfd;
+ char* info_ptr;
+ char* end_ptr;
+{
+ struct comp_unit* unit;
+
+ unsigned short version;
+ unsigned int abbrev_offset;
+ unsigned char addr_size;
+ struct abbrev_info** abbrevs;
+
+ unsigned int abbrev_number, bytes_read, i;
+ struct abbrev_info *abbrev;
+ struct attribute attr;
+
+ version = read_2_bytes (abfd, info_ptr);
+ info_ptr += 2;
+ abbrev_offset = read_4_bytes (abfd, info_ptr);
+ info_ptr += 4;
+ addr_size = read_1_byte (abfd, info_ptr);
+ info_ptr += 1;
+
+ if (version != 2)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%hu', this reader only handles version 2 information."), version );
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ if (addr_size > sizeof (bfd_vma))
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."),
+ addr_size,
+ sizeof (bfd_vma));
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ if (addr_size != 4 && addr_size != 8)
+ {
+ (*_bfd_error_handler) ("Dwarf Error: found address size '%u', this reader can only handle address sizes '4' and '8'.", addr_size );
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ /* Read the abbrevs for this compilation unit into a table */
+ abbrevs = read_abbrevs (abfd, abbrev_offset);
+ if (! abbrevs)
+ return 0;
+
+ abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+ info_ptr += bytes_read;
+ if (! abbrev_number)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %d."),
+ abbrev_number);
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ abbrev = lookup_abbrev (abbrev_number, abbrevs);
+ if (! abbrev)
+ {
+ (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."),
+ abbrev_number);
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ unit = (struct comp_unit*) bfd_zalloc (abfd, sizeof (struct comp_unit));
+ unit->abfd = abfd;
+ unit->addr_size = addr_size;
+ unit->abbrevs = abbrevs;
+ unit->end_ptr = end_ptr;
+
+ for (i = 0; i < abbrev->num_attrs; ++i)
+ {
+ info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr);
+
+ /* Store the data if it is of an attribute we want to keep in a
+ partial symbol table. */
+ switch (attr.name)
+ {
+ case DW_AT_stmt_list:
+ unit->stmtlist = 1;
+ unit->line_offset = DW_UNSND (&attr);
+ break;
+
+ case DW_AT_name:
+ unit->name = DW_STRING (&attr);
+ break;
+
+ case DW_AT_low_pc:
+ unit->low = DW_ADDR (&attr);
+ break;
+
+ case DW_AT_high_pc:
+ unit->high = DW_ADDR (&attr);
+ break;
+
+ case DW_AT_comp_dir:
+ {
+ char* comp_dir = DW_STRING (&attr);
+ if (comp_dir)
+ {
+ /* Irix 6.2 native cc prepends <machine>.: to the compilation
+ directory, get rid of it. */
+ char *cp = (char*) strchr (comp_dir, ':');
+
+ if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/')
+ comp_dir = cp + 1;
+ }
+ unit->comp_dir = comp_dir;
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ unit->first_child_die_ptr = info_ptr;
+ return unit;
+}
+
+
+
+
+
+/* Return true if UNIT contains the address given by ADDR. */
+
+static boolean
+comp_unit_contains_address (unit, addr)
+ struct comp_unit* unit;
+ bfd_vma addr;
+{
+ return ! unit->error
+ && (addr >= unit->low && addr <= unit->high);
+}
+
+
+/* If UNIT contains ADDR, set the output parameters to the values for
+ the line containing ADDR. The output parameters, FILENAME_PTR,
+ FUNCTIONNAME_PTR, and LINENUMBER_PTR, are pointers to the objects
+ to be filled in.
+
+ Return true of UNIT contains ADDR, and no errors were encountered;
+ false otherwise. */
+
+static boolean
+comp_unit_find_nearest_line (unit, addr,
+ filename_ptr, functionname_ptr, linenumber_ptr)
+ struct comp_unit* unit;
+ bfd_vma addr;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *linenumber_ptr;
+{
+ boolean line_p;
+ boolean func_p;
+
+ if (unit->error)
+ return false;
+
+ if (! unit->line_table)
+ {
+ if (! unit->stmtlist)
+ {
+ unit->error = 1;
+ return false;
+ }
+
+ unit->line_table = decode_line_info (unit);
+
+ if (! unit->line_table)
+ {
+ unit->error = 1;
+ return false;
+ }
+
+ if (! scan_unit_for_functions (unit))
+ {
+ unit->error = 1;
+ return false;
+ }
+ }
+
+ line_p = lookup_address_in_line_info_table (unit->line_table,
+ addr,
+ filename_ptr,
+ linenumber_ptr);
+ func_p = lookup_address_in_function_table (unit->function_table,
+ addr,
+ functionname_ptr);
+ return line_p || func_p;
+}
+
+/* The DWARF2 version of find_nearest line.
+ Return true if the line is found without error. */
+
+boolean
+_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr, linenumber_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *linenumber_ptr;
+{
+ /* Read each compilation unit from the section .debug_info, and check
+ to see if it contains the address we are searching for. If yes,
+ lookup the address, and return the line number info. If no, go
+ on to the next compilation unit.
+
+ We keep a list of all the previously read compilation units, and
+ a pointer to the next un-read compilation unit. Check the
+ previously read units before reading more.
+ */
+
+ struct dwarf2_debug *stash = elf_tdata (abfd)->dwarf2_find_line_info;
+
+ /* What address are we looking for? */
+ bfd_vma addr = offset + section->vma;
+
+ struct comp_unit* each;
+
+ *filename_ptr = NULL;
+ *functionname_ptr = NULL;
+ *linenumber_ptr = 0;
+
+ if (! stash)
+ {
+ asection *msec;
+ unsigned long size;
+
+ stash = elf_tdata (abfd)->dwarf2_find_line_info =
+ (struct dwarf2_debug*) bfd_zalloc (abfd, sizeof (struct dwarf2_debug));
+
+ if (! stash)
+ return false;
+
+ msec = bfd_get_section_by_name (abfd, ".debug_info");
+ if (! msec)
+ {
+ /* No dwarf2 info. Note that at this point the stash
+ has been allocated, but contains zeros, this lets
+ future calls to this function fail quicker. */
+ return false;
+ }
+
+ size = bfd_get_section_size_before_reloc (msec);
+ if (size == 0)
+ return false;
+
+ stash->info_ptr = (char *) bfd_alloc (abfd, size);
+
+ if (! stash->info_ptr)
+ return false;
+
+ if (! bfd_get_section_contents (abfd, msec, stash->info_ptr, 0, size))
+ {
+ stash->info_ptr = 0;
+ return false;
+ }
+
+ stash->info_ptr_end = stash->info_ptr + size;
+
+ /* FIXME: There is a problem with the contents of the .debug_info section.
+ The 'low' and 'high' addresses of the comp_units are computed by relocs
+ against symbols in the .text segment. We need these addresses in
+ order to determine the nearest line number, and so we have to resolve
+ the relocs. There is a similar problem when the .debug_line section is
+ processed as well.
+
+ Unfortunately getting hold of the reloc information is hard... */
+ }
+
+ /* A null info_ptr indicates that there is no dwarf2 info
+ (or that an error occured while setting up the stash). */
+
+ if (! stash->info_ptr)
+ return false;
+
+ /* Check the previously read comp. units first. */
+
+ for (each = stash->all_comp_units; each; each = each->next_unit)
+ {
+ if (comp_unit_contains_address (each, addr))
+ return comp_unit_find_nearest_line (each, addr,
+ filename_ptr,
+ functionname_ptr,
+ linenumber_ptr);
+ }
+
+ /* Read each remaining comp. units checking each as they are read. */
+ while (stash->info_ptr < stash->info_ptr_end)
+ {
+ struct comp_unit* each;
+ unsigned int length;
+
+ length = read_4_bytes (abfd, stash->info_ptr);
+ stash->info_ptr += 4;
+
+ if (length > 0)
+ {
+ each = parse_comp_unit (abfd, stash->info_ptr,
+ stash->info_ptr + length);
+ stash->info_ptr += length;
+
+ if (each)
+ {
+ each->next_unit = stash->all_comp_units;
+ stash->all_comp_units = each;
+
+ if (comp_unit_contains_address (each, addr))
+ return comp_unit_find_nearest_line (each, addr,
+ filename_ptr,
+ functionname_ptr,
+ linenumber_ptr);
+ }
+ }
+ }
+
+ return false;
+}
+
+/* end of file */
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
new file mode 100644
index 00000000000..d5c6f85a717
--- /dev/null
+++ b/bfd/ecoff.c
@@ -0,0 +1,4825 @@
+/* Generic ECOFF (Extended-COFF) routines.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Original version by Per Bothner.
+ Full support added by Ian Lance Taylor, ian@cygnus.com.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "aout/ar.h"
+#include "aout/ranlib.h"
+#include "aout/stab_gnu.h"
+
+/* FIXME: We need the definitions of N_SET[ADTB], but aout64.h defines
+ some other stuff which we don't want and which conflicts with stuff
+ we do want. */
+#include "libaout.h"
+#include "aout/aout64.h"
+#undef N_ABS
+#undef exec_hdr
+#undef obj_sym_filepos
+
+#include "coff/internal.h"
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/ecoff.h"
+#include "libcoff.h"
+#include "libecoff.h"
+
+/* Prototypes for static functions. */
+
+static int ecoff_get_magic PARAMS ((bfd *abfd));
+static long ecoff_sec_to_styp_flags PARAMS ((const char *name,
+ flagword flags));
+static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *abfd));
+static boolean ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym,
+ asymbol *asym, int ext, int weak));
+static void ecoff_emit_aggregate PARAMS ((bfd *abfd, FDR *fdr,
+ char *string,
+ RNDXR *rndx, long isym,
+ const char *which));
+static char *ecoff_type_to_string PARAMS ((bfd *abfd, FDR *fdr,
+ unsigned int indx));
+static boolean ecoff_slurp_reloc_table PARAMS ((bfd *abfd, asection *section,
+ asymbol **symbols));
+static int ecoff_sort_hdrs PARAMS ((const PTR, const PTR));
+static boolean ecoff_compute_section_file_positions PARAMS ((bfd *abfd));
+static bfd_size_type ecoff_compute_reloc_file_positions PARAMS ((bfd *abfd));
+static boolean ecoff_get_extr PARAMS ((asymbol *, EXTR *));
+static void ecoff_set_index PARAMS ((asymbol *, bfd_size_type));
+static unsigned int ecoff_armap_hash PARAMS ((CONST char *s,
+ unsigned int *rehash,
+ unsigned int size,
+ unsigned int hlog));
+
+/* This stuff is somewhat copied from coffcode.h. */
+
+static asection bfd_debug_section = { "*DEBUG*" };
+
+/* Create an ECOFF object. */
+
+boolean
+_bfd_ecoff_mkobject (abfd)
+ bfd *abfd;
+{
+ abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
+ bfd_zalloc (abfd, sizeof (ecoff_data_type)));
+ if (abfd->tdata.ecoff_obj_data == NULL)
+ return false;
+
+ return true;
+}
+
+/* This is a hook called by coff_real_object_p to create any backend
+ specific information. */
+
+PTR
+_bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
+ bfd *abfd;
+ PTR filehdr;
+ PTR aouthdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+ struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr;
+ ecoff_data_type *ecoff;
+
+ if (_bfd_ecoff_mkobject (abfd) == false)
+ return NULL;
+
+ ecoff = ecoff_data (abfd);
+ ecoff->gp_size = 8;
+ ecoff->sym_filepos = internal_f->f_symptr;
+
+ if (internal_a != (struct internal_aouthdr *) NULL)
+ {
+ int i;
+
+ ecoff->text_start = internal_a->text_start;
+ ecoff->text_end = internal_a->text_start + internal_a->tsize;
+ ecoff->gp = internal_a->gp_value;
+ ecoff->gprmask = internal_a->gprmask;
+ for (i = 0; i < 4; i++)
+ ecoff->cprmask[i] = internal_a->cprmask[i];
+ ecoff->fprmask = internal_a->fprmask;
+ if (internal_a->magic == ECOFF_AOUT_ZMAGIC)
+ abfd->flags |= D_PAGED;
+ else
+ abfd->flags &=~ D_PAGED;
+ }
+
+ /* It turns out that no special action is required by the MIPS or
+ Alpha ECOFF backends. They have different information in the
+ a.out header, but we just copy it all (e.g., gprmask, cprmask and
+ fprmask) and let the swapping routines ensure that only relevant
+ information is written out. */
+
+ return (PTR) ecoff;
+}
+
+/* Initialize a new section. */
+
+boolean
+_bfd_ecoff_new_section_hook (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ section->alignment_power = 4;
+
+ if (strcmp (section->name, _TEXT) == 0
+ || strcmp (section->name, _INIT) == 0
+ || strcmp (section->name, _FINI) == 0)
+ section->flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
+ else if (strcmp (section->name, _DATA) == 0
+ || strcmp (section->name, _SDATA) == 0)
+ section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
+ else if (strcmp (section->name, _RDATA) == 0
+ || strcmp (section->name, _LIT8) == 0
+ || strcmp (section->name, _LIT4) == 0
+ || strcmp (section->name, _RCONST) == 0
+ || strcmp (section->name, _PDATA) == 0)
+ section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
+ else if (strcmp (section->name, _BSS) == 0
+ || strcmp (section->name, _SBSS) == 0)
+ section->flags |= SEC_ALLOC;
+ else if (strcmp (section->name, _LIB) == 0)
+ {
+ /* An Irix 4 shared libary. */
+ section->flags |= SEC_COFF_SHARED_LIBRARY;
+ }
+
+ /* Probably any other section name is SEC_NEVER_LOAD, but I'm
+ uncertain about .init on some systems and I don't know how shared
+ libraries work. */
+
+ return true;
+}
+
+/* Determine the machine architecture and type. This is called from
+ the generic COFF routines. It is the inverse of ecoff_get_magic,
+ below. This could be an ECOFF backend routine, with one version
+ for each target, but there aren't all that many ECOFF targets. */
+
+boolean
+_bfd_ecoff_set_arch_mach_hook (abfd, filehdr)
+ bfd *abfd;
+ PTR filehdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+ enum bfd_architecture arch;
+ unsigned long mach;
+
+ switch (internal_f->f_magic)
+ {
+ case MIPS_MAGIC_1:
+ case MIPS_MAGIC_LITTLE:
+ case MIPS_MAGIC_BIG:
+ arch = bfd_arch_mips;
+ mach = 3000;
+ break;
+
+ case MIPS_MAGIC_LITTLE2:
+ case MIPS_MAGIC_BIG2:
+ /* MIPS ISA level 2: the r6000 */
+ arch = bfd_arch_mips;
+ mach = 6000;
+ break;
+
+ case MIPS_MAGIC_LITTLE3:
+ case MIPS_MAGIC_BIG3:
+ /* MIPS ISA level 3: the r4000 */
+ arch = bfd_arch_mips;
+ mach = 4000;
+ break;
+
+ case ALPHA_MAGIC:
+ arch = bfd_arch_alpha;
+ mach = 0;
+ break;
+
+ default:
+ arch = bfd_arch_obscure;
+ mach = 0;
+ break;
+ }
+
+ return bfd_default_set_arch_mach (abfd, arch, mach);
+}
+
+/* Get the magic number to use based on the architecture and machine.
+ This is the inverse of _bfd_ecoff_set_arch_mach_hook, above. */
+
+static int
+ecoff_get_magic (abfd)
+ bfd *abfd;
+{
+ int big, little;
+
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_mips:
+ switch (bfd_get_mach (abfd))
+ {
+ default:
+ case 0:
+ case 3000:
+ big = MIPS_MAGIC_BIG;
+ little = MIPS_MAGIC_LITTLE;
+ break;
+
+ case 6000:
+ big = MIPS_MAGIC_BIG2;
+ little = MIPS_MAGIC_LITTLE2;
+ break;
+
+ case 4000:
+ big = MIPS_MAGIC_BIG3;
+ little = MIPS_MAGIC_LITTLE3;
+ break;
+ }
+
+ return bfd_big_endian (abfd) ? big : little;
+
+ case bfd_arch_alpha:
+ return ALPHA_MAGIC;
+
+ default:
+ abort ();
+ return 0;
+ }
+}
+
+/* Get the section s_flags to use for a section. */
+
+static long
+ecoff_sec_to_styp_flags (name, flags)
+ const char *name;
+ flagword flags;
+{
+ long styp;
+
+ styp = 0;
+
+ if (strcmp (name, _TEXT) == 0)
+ styp = STYP_TEXT;
+ else if (strcmp (name, _DATA) == 0)
+ styp = STYP_DATA;
+ else if (strcmp (name, _SDATA) == 0)
+ styp = STYP_SDATA;
+ else if (strcmp (name, _RDATA) == 0)
+ styp = STYP_RDATA;
+ else if (strcmp (name, _LITA) == 0)
+ styp = STYP_LITA;
+ else if (strcmp (name, _LIT8) == 0)
+ styp = STYP_LIT8;
+ else if (strcmp (name, _LIT4) == 0)
+ styp = STYP_LIT4;
+ else if (strcmp (name, _BSS) == 0)
+ styp = STYP_BSS;
+ else if (strcmp (name, _SBSS) == 0)
+ styp = STYP_SBSS;
+ else if (strcmp (name, _INIT) == 0)
+ styp = STYP_ECOFF_INIT;
+ else if (strcmp (name, _FINI) == 0)
+ styp = STYP_ECOFF_FINI;
+ else if (strcmp (name, _PDATA) == 0)
+ styp = STYP_PDATA;
+ else if (strcmp (name, _XDATA) == 0)
+ styp = STYP_XDATA;
+ else if (strcmp (name, _LIB) == 0)
+ styp = STYP_ECOFF_LIB;
+ else if (strcmp (name, _GOT) == 0)
+ styp = STYP_GOT;
+ else if (strcmp (name, _HASH) == 0)
+ styp = STYP_HASH;
+ else if (strcmp (name, _DYNAMIC) == 0)
+ styp = STYP_DYNAMIC;
+ else if (strcmp (name, _LIBLIST) == 0)
+ styp = STYP_LIBLIST;
+ else if (strcmp (name, _RELDYN) == 0)
+ styp = STYP_RELDYN;
+ else if (strcmp (name, _CONFLIC) == 0)
+ styp = STYP_CONFLIC;
+ else if (strcmp (name, _DYNSTR) == 0)
+ styp = STYP_DYNSTR;
+ else if (strcmp (name, _DYNSYM) == 0)
+ styp = STYP_DYNSYM;
+ else if (strcmp (name, _COMMENT) == 0)
+ {
+ styp = STYP_COMMENT;
+ flags &=~ SEC_NEVER_LOAD;
+ }
+ else if (strcmp (name, _RCONST) == 0)
+ styp = STYP_RCONST;
+ else if (flags & SEC_CODE)
+ styp = STYP_TEXT;
+ else if (flags & SEC_DATA)
+ styp = STYP_DATA;
+ else if (flags & SEC_READONLY)
+ styp = STYP_RDATA;
+ else if (flags & SEC_LOAD)
+ styp = STYP_REG;
+ else
+ styp = STYP_BSS;
+
+ if (flags & SEC_NEVER_LOAD)
+ styp |= STYP_NOLOAD;
+
+ return styp;
+}
+
+/* Get the BFD flags to use for a section. */
+
+/*ARGSUSED*/
+flagword
+_bfd_ecoff_styp_to_sec_flags (abfd, hdr, name)
+ bfd *abfd;
+ PTR hdr;
+ const char *name;
+{
+ struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
+ long styp_flags = internal_s->s_flags;
+ flagword sec_flags=0;
+
+ if (styp_flags & STYP_NOLOAD)
+ sec_flags |= SEC_NEVER_LOAD;
+
+ /* For 386 COFF, at least, an unloadable text or data section is
+ actually a shared library section. */
+ if ((styp_flags & STYP_TEXT)
+ || (styp_flags & STYP_ECOFF_INIT)
+ || (styp_flags & STYP_ECOFF_FINI)
+ || (styp_flags & STYP_DYNAMIC)
+ || (styp_flags & STYP_LIBLIST)
+ || (styp_flags & STYP_RELDYN)
+ || styp_flags == STYP_CONFLIC
+ || (styp_flags & STYP_DYNSTR)
+ || (styp_flags & STYP_DYNSYM)
+ || (styp_flags & STYP_HASH))
+ {
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
+ else
+ sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
+ }
+ else if ((styp_flags & STYP_DATA)
+ || (styp_flags & STYP_RDATA)
+ || (styp_flags & STYP_SDATA)
+ || styp_flags == STYP_PDATA
+ || styp_flags == STYP_XDATA
+ || (styp_flags & STYP_GOT)
+ || styp_flags == STYP_RCONST)
+ {
+ if (sec_flags & SEC_NEVER_LOAD)
+ sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
+ else
+ sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
+ if ((styp_flags & STYP_RDATA)
+ || styp_flags == STYP_PDATA
+ || styp_flags == STYP_RCONST)
+ sec_flags |= SEC_READONLY;
+ }
+ else if ((styp_flags & STYP_BSS)
+ || (styp_flags & STYP_SBSS))
+ {
+ sec_flags |= SEC_ALLOC;
+ }
+ else if ((styp_flags & STYP_INFO) || styp_flags == STYP_COMMENT)
+ {
+ sec_flags |= SEC_NEVER_LOAD;
+ }
+ else if ((styp_flags & STYP_LITA)
+ || (styp_flags & STYP_LIT8)
+ || (styp_flags & STYP_LIT4))
+ {
+ sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
+ }
+ else if (styp_flags & STYP_ECOFF_LIB)
+ {
+ sec_flags |= SEC_COFF_SHARED_LIBRARY;
+ }
+ else
+ {
+ sec_flags |= SEC_ALLOC | SEC_LOAD;
+ }
+
+ return sec_flags;
+}
+
+/* Read in the symbolic header for an ECOFF object file. */
+
+static boolean
+ecoff_slurp_symbolic_header (abfd)
+ bfd *abfd;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ bfd_size_type external_hdr_size;
+ PTR raw = NULL;
+ HDRR *internal_symhdr;
+
+ /* See if we've already read it in. */
+ if (ecoff_data (abfd)->debug_info.symbolic_header.magic ==
+ backend->debug_swap.sym_magic)
+ return true;
+
+ /* See whether there is a symbolic header. */
+ if (ecoff_data (abfd)->sym_filepos == 0)
+ {
+ bfd_get_symcount (abfd) = 0;
+ return true;
+ }
+
+ /* At this point bfd_get_symcount (abfd) holds the number of symbols
+ as read from the file header, but on ECOFF this is always the
+ size of the symbolic information header. It would be cleaner to
+ handle this when we first read the file in coffgen.c. */
+ external_hdr_size = backend->debug_swap.external_hdr_size;
+ if (bfd_get_symcount (abfd) != external_hdr_size)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Read the symbolic information header. */
+ raw = (PTR) bfd_malloc ((size_t) external_hdr_size);
+ if (raw == NULL)
+ goto error_return;
+
+ if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
+ || (bfd_read (raw, external_hdr_size, 1, abfd)
+ != external_hdr_size))
+ goto error_return;
+ internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
+ (*backend->debug_swap.swap_hdr_in) (abfd, raw, internal_symhdr);
+
+ if (internal_symhdr->magic != backend->debug_swap.sym_magic)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ /* Now we can get the correct number of symbols. */
+ bfd_get_symcount (abfd) = (internal_symhdr->isymMax
+ + internal_symhdr->iextMax);
+
+ if (raw != NULL)
+ free (raw);
+ return true;
+ error_return:
+ if (raw != NULL)
+ free (raw);
+ return false;
+}
+
+/* Read in and swap the important symbolic information for an ECOFF
+ object file. This is called by gdb via the read_debug_info entry
+ point in the backend structure. */
+
+/*ARGSUSED*/
+boolean
+_bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug)
+ bfd *abfd;
+ asection *ignore;
+ struct ecoff_debug_info *debug;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ HDRR *internal_symhdr;
+ bfd_size_type raw_base;
+ bfd_size_type raw_size;
+ PTR raw;
+ bfd_size_type external_fdr_size;
+ char *fraw_src;
+ char *fraw_end;
+ struct fdr *fdr_ptr;
+ bfd_size_type raw_end;
+ bfd_size_type cb_end;
+
+ BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info);
+
+ /* Check whether we've already gotten it, and whether there's any to
+ get. */
+ if (ecoff_data (abfd)->raw_syments != (PTR) NULL)
+ return true;
+ if (ecoff_data (abfd)->sym_filepos == 0)
+ {
+ bfd_get_symcount (abfd) = 0;
+ return true;
+ }
+
+ if (! ecoff_slurp_symbolic_header (abfd))
+ return false;
+
+ internal_symhdr = &debug->symbolic_header;
+
+ /* Read all the symbolic information at once. */
+ raw_base = (ecoff_data (abfd)->sym_filepos
+ + backend->debug_swap.external_hdr_size);
+
+ /* Alpha ecoff makes the determination of raw_size difficult. It has
+ an undocumented debug data section between the symhdr and the first
+ documented section. And the ordering of the sections varies between
+ statically and dynamically linked executables.
+ If bfd supports SEEK_END someday, this code could be simplified. */
+
+ raw_end = 0;
+
+#define UPDATE_RAW_END(start, count, size) \
+ cb_end = internal_symhdr->start + internal_symhdr->count * (size); \
+ if (cb_end > raw_end) \
+ raw_end = cb_end
+
+ UPDATE_RAW_END (cbLineOffset, cbLine, sizeof (unsigned char));
+ UPDATE_RAW_END (cbDnOffset, idnMax, backend->debug_swap.external_dnr_size);
+ UPDATE_RAW_END (cbPdOffset, ipdMax, backend->debug_swap.external_pdr_size);
+ UPDATE_RAW_END (cbSymOffset, isymMax, backend->debug_swap.external_sym_size);
+ UPDATE_RAW_END (cbOptOffset, ioptMax, backend->debug_swap.external_opt_size);
+ UPDATE_RAW_END (cbAuxOffset, iauxMax, sizeof (union aux_ext));
+ UPDATE_RAW_END (cbSsOffset, issMax, sizeof (char));
+ UPDATE_RAW_END (cbSsExtOffset, issExtMax, sizeof (char));
+ UPDATE_RAW_END (cbFdOffset, ifdMax, backend->debug_swap.external_fdr_size);
+ UPDATE_RAW_END (cbRfdOffset, crfd, backend->debug_swap.external_rfd_size);
+ UPDATE_RAW_END (cbExtOffset, iextMax, backend->debug_swap.external_ext_size);
+
+#undef UPDATE_RAW_END
+
+ raw_size = raw_end - raw_base;
+ if (raw_size == 0)
+ {
+ ecoff_data (abfd)->sym_filepos = 0;
+ return true;
+ }
+ raw = (PTR) bfd_alloc (abfd, raw_size);
+ if (raw == NULL)
+ return false;
+ if (bfd_seek (abfd,
+ (ecoff_data (abfd)->sym_filepos
+ + backend->debug_swap.external_hdr_size),
+ SEEK_SET) != 0
+ || bfd_read (raw, raw_size, 1, abfd) != raw_size)
+ {
+ bfd_release (abfd, raw);
+ return false;
+ }
+
+ ecoff_data (abfd)->raw_syments = raw;
+
+ /* Get pointers for the numeric offsets in the HDRR structure. */
+#define FIX(off1, off2, type) \
+ if (internal_symhdr->off1 == 0) \
+ debug->off2 = (type) NULL; \
+ else \
+ debug->off2 = (type) ((char *) raw \
+ + (internal_symhdr->off1 \
+ - raw_base))
+ FIX (cbLineOffset, line, unsigned char *);
+ FIX (cbDnOffset, external_dnr, PTR);
+ FIX (cbPdOffset, external_pdr, PTR);
+ FIX (cbSymOffset, external_sym, PTR);
+ FIX (cbOptOffset, external_opt, PTR);
+ FIX (cbAuxOffset, external_aux, union aux_ext *);
+ FIX (cbSsOffset, ss, char *);
+ FIX (cbSsExtOffset, ssext, char *);
+ FIX (cbFdOffset, external_fdr, PTR);
+ FIX (cbRfdOffset, external_rfd, PTR);
+ FIX (cbExtOffset, external_ext, PTR);
+#undef FIX
+
+ /* I don't want to always swap all the data, because it will just
+ waste time and most programs will never look at it. The only
+ time the linker needs most of the debugging information swapped
+ is when linking big-endian and little-endian MIPS object files
+ together, which is not a common occurrence.
+
+ We need to look at the fdr to deal with a lot of information in
+ the symbols, so we swap them here. */
+ debug->fdr = (struct fdr *) bfd_alloc (abfd,
+ (internal_symhdr->ifdMax *
+ sizeof (struct fdr)));
+ if (debug->fdr == NULL)
+ return false;
+ external_fdr_size = backend->debug_swap.external_fdr_size;
+ fdr_ptr = debug->fdr;
+ fraw_src = (char *) debug->external_fdr;
+ fraw_end = fraw_src + internal_symhdr->ifdMax * external_fdr_size;
+ for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
+ (*backend->debug_swap.swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
+
+ return true;
+}
+
+/* ECOFF symbol table routines. The ECOFF symbol table is described
+ in gcc/mips-tfile.c. */
+
+/* ECOFF uses two common sections. One is the usual one, and the
+ other is for small objects. All the small objects are kept
+ together, and then referenced via the gp pointer, which yields
+ faster assembler code. This is what we use for the small common
+ section. */
+static asection ecoff_scom_section;
+static asymbol ecoff_scom_symbol;
+static asymbol *ecoff_scom_symbol_ptr;
+
+/* Create an empty symbol. */
+
+asymbol *
+_bfd_ecoff_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ ecoff_symbol_type *new;
+
+ new = (ecoff_symbol_type *) bfd_alloc (abfd, sizeof (ecoff_symbol_type));
+ if (new == (ecoff_symbol_type *) NULL)
+ return (asymbol *) NULL;
+ memset ((PTR) new, 0, sizeof *new);
+ new->symbol.section = (asection *) NULL;
+ new->fdr = (FDR *) NULL;
+ new->local = false;
+ new->native = NULL;
+ new->symbol.the_bfd = abfd;
+ return &new->symbol;
+}
+
+/* Set the BFD flags and section for an ECOFF symbol. */
+
+static boolean
+ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak)
+ bfd *abfd;
+ SYMR *ecoff_sym;
+ asymbol *asym;
+ int ext;
+ int weak;
+{
+ asym->the_bfd = abfd;
+ asym->value = ecoff_sym->value;
+ asym->section = &bfd_debug_section;
+ asym->udata.i = 0;
+
+ /* Most symbol types are just for debugging. */
+ switch (ecoff_sym->st)
+ {
+ case stGlobal:
+ case stStatic:
+ case stLabel:
+ case stProc:
+ case stStaticProc:
+ break;
+ case stNil:
+ if (ECOFF_IS_STAB (ecoff_sym))
+ {
+ asym->flags = BSF_DEBUGGING;
+ return true;
+ }
+ break;
+ default:
+ asym->flags = BSF_DEBUGGING;
+ return true;
+ }
+
+ if (weak)
+ asym->flags = BSF_EXPORT | BSF_WEAK;
+ else if (ext)
+ asym->flags = BSF_EXPORT | BSF_GLOBAL;
+ else
+ {
+ asym->flags = BSF_LOCAL;
+ /* Normally, a local stProc symbol will have a corresponding
+ external symbol. We mark the local symbol as a debugging
+ symbol, in order to prevent nm from printing both out.
+ Similarly, we mark stLabel and stabs symbols as debugging
+ symbols. In both cases, we do want to set the value
+ correctly based on the symbol class. */
+ if (ecoff_sym->st == stProc
+ || ecoff_sym->st == stLabel
+ || ECOFF_IS_STAB (ecoff_sym))
+ asym->flags |= BSF_DEBUGGING;
+ }
+ switch (ecoff_sym->sc)
+ {
+ case scNil:
+ /* Used for compiler generated labels. Leave them in the
+ debugging section, and mark them as local. If BSF_DEBUGGING
+ is set, then nm does not display them for some reason. If no
+ flags are set then the linker whines about them. */
+ asym->flags = BSF_LOCAL;
+ break;
+ case scText:
+ asym->section = bfd_make_section_old_way (abfd, ".text");
+ asym->value -= asym->section->vma;
+ break;
+ case scData:
+ asym->section = bfd_make_section_old_way (abfd, ".data");
+ asym->value -= asym->section->vma;
+ break;
+ case scBss:
+ asym->section = bfd_make_section_old_way (abfd, ".bss");
+ asym->value -= asym->section->vma;
+ break;
+ case scRegister:
+ asym->flags = BSF_DEBUGGING;
+ break;
+ case scAbs:
+ asym->section = bfd_abs_section_ptr;
+ break;
+ case scUndefined:
+ asym->section = bfd_und_section_ptr;
+ asym->flags = 0;
+ asym->value = 0;
+ break;
+ case scCdbLocal:
+ case scBits:
+ case scCdbSystem:
+ case scRegImage:
+ case scInfo:
+ case scUserStruct:
+ asym->flags = BSF_DEBUGGING;
+ break;
+ case scSData:
+ asym->section = bfd_make_section_old_way (abfd, ".sdata");
+ asym->value -= asym->section->vma;
+ break;
+ case scSBss:
+ asym->section = bfd_make_section_old_way (abfd, ".sbss");
+ asym->value -= asym->section->vma;
+ break;
+ case scRData:
+ asym->section = bfd_make_section_old_way (abfd, ".rdata");
+ asym->value -= asym->section->vma;
+ break;
+ case scVar:
+ asym->flags = BSF_DEBUGGING;
+ break;
+ case scCommon:
+ if (asym->value > ecoff_data (abfd)->gp_size)
+ {
+ asym->section = bfd_com_section_ptr;
+ asym->flags = 0;
+ break;
+ }
+ /* Fall through. */
+ case scSCommon:
+ if (ecoff_scom_section.name == NULL)
+ {
+ /* Initialize the small common section. */
+ ecoff_scom_section.name = SCOMMON;
+ ecoff_scom_section.flags = SEC_IS_COMMON;
+ ecoff_scom_section.output_section = &ecoff_scom_section;
+ ecoff_scom_section.symbol = &ecoff_scom_symbol;
+ ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
+ ecoff_scom_symbol.name = SCOMMON;
+ ecoff_scom_symbol.flags = BSF_SECTION_SYM;
+ ecoff_scom_symbol.section = &ecoff_scom_section;
+ ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
+ }
+ asym->section = &ecoff_scom_section;
+ asym->flags = 0;
+ break;
+ case scVarRegister:
+ case scVariant:
+ asym->flags = BSF_DEBUGGING;
+ break;
+ case scSUndefined:
+ asym->section = bfd_und_section_ptr;
+ asym->flags = 0;
+ asym->value = 0;
+ break;
+ case scInit:
+ asym->section = bfd_make_section_old_way (abfd, ".init");
+ asym->value -= asym->section->vma;
+ break;
+ case scBasedVar:
+ case scXData:
+ case scPData:
+ asym->flags = BSF_DEBUGGING;
+ break;
+ case scFini:
+ asym->section = bfd_make_section_old_way (abfd, ".fini");
+ asym->value -= asym->section->vma;
+ break;
+ case scRConst:
+ asym->section = bfd_make_section_old_way (abfd, ".rconst");
+ asym->value -= asym->section->vma;
+ break;
+ default:
+ break;
+ }
+
+ /* Look for special constructors symbols and make relocation entries
+ in a special construction section. These are produced by the
+ -fgnu-linker argument to g++. */
+ if (ECOFF_IS_STAB (ecoff_sym))
+ {
+ switch (ECOFF_UNMARK_STAB (ecoff_sym->index))
+ {
+ default:
+ break;
+
+ case N_SETA:
+ case N_SETT:
+ case N_SETD:
+ case N_SETB:
+ {
+ /* This code is no longer needed. It used to be used to
+ make the linker handle set symbols, but they are now
+ handled in the add_symbols routine instead. */
+#if 0
+ const char *name;
+ asection *section;
+ arelent_chain *reloc_chain;
+ unsigned int bitsize;
+
+ /* Get a section with the same name as the symbol (usually
+ __CTOR_LIST__ or __DTOR_LIST__). FIXME: gcc uses the
+ name ___CTOR_LIST (three underscores). We need
+ __CTOR_LIST (two underscores), since ECOFF doesn't use
+ a leading underscore. This should be handled by gcc,
+ but instead we do it here. Actually, this should all
+ be done differently anyhow. */
+ name = bfd_asymbol_name (asym);
+ if (name[0] == '_' && name[1] == '_' && name[2] == '_')
+ {
+ ++name;
+ asym->name = name;
+ }
+ section = bfd_get_section_by_name (abfd, name);
+ if (section == (asection *) NULL)
+ {
+ char *copy;
+
+ copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
+ if (!copy)
+ return false;
+ strcpy (copy, name);
+ section = bfd_make_section (abfd, copy);
+ }
+
+ /* Build a reloc pointing to this constructor. */
+ reloc_chain =
+ (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
+ if (!reloc_chain)
+ return false;
+ reloc_chain->relent.sym_ptr_ptr =
+ bfd_get_section (asym)->symbol_ptr_ptr;
+ reloc_chain->relent.address = section->_raw_size;
+ reloc_chain->relent.addend = asym->value;
+ reloc_chain->relent.howto =
+ ecoff_backend (abfd)->constructor_reloc;
+
+ /* Set up the constructor section to hold the reloc. */
+ section->flags = SEC_CONSTRUCTOR;
+ ++section->reloc_count;
+
+ /* Constructor sections must be rounded to a boundary
+ based on the bitsize. These are not real sections--
+ they are handled specially by the linker--so the ECOFF
+ 16 byte alignment restriction does not apply. */
+ bitsize = ecoff_backend (abfd)->constructor_bitsize;
+ section->alignment_power = 1;
+ while ((1 << section->alignment_power) < bitsize / 8)
+ ++section->alignment_power;
+
+ reloc_chain->next = section->constructor_chain;
+ section->constructor_chain = reloc_chain;
+ section->_raw_size += bitsize / 8;
+
+#endif /* 0 */
+
+ /* Mark the symbol as a constructor. */
+ asym->flags |= BSF_CONSTRUCTOR;
+ }
+ break;
+ }
+ }
+ return true;
+}
+
+/* Read an ECOFF symbol table. */
+
+boolean
+_bfd_ecoff_slurp_symbol_table (abfd)
+ bfd *abfd;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ const bfd_size_type external_ext_size
+ = backend->debug_swap.external_ext_size;
+ const bfd_size_type external_sym_size
+ = backend->debug_swap.external_sym_size;
+ void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
+ = backend->debug_swap.swap_ext_in;
+ void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
+ = backend->debug_swap.swap_sym_in;
+ bfd_size_type internal_size;
+ ecoff_symbol_type *internal;
+ ecoff_symbol_type *internal_ptr;
+ char *eraw_src;
+ char *eraw_end;
+ FDR *fdr_ptr;
+ FDR *fdr_end;
+
+ /* If we've already read in the symbol table, do nothing. */
+ if (ecoff_data (abfd)->canonical_symbols != NULL)
+ return true;
+
+ /* Get the symbolic information. */
+ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
+ &ecoff_data (abfd)->debug_info))
+ return false;
+ if (bfd_get_symcount (abfd) == 0)
+ return true;
+
+ internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type);
+ internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
+ if (internal == NULL)
+ return false;
+
+ internal_ptr = internal;
+ eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext;
+ eraw_end = (eraw_src
+ + (ecoff_data (abfd)->debug_info.symbolic_header.iextMax
+ * external_ext_size));
+ for (; eraw_src < eraw_end; eraw_src += external_ext_size, internal_ptr++)
+ {
+ EXTR internal_esym;
+
+ (*swap_ext_in) (abfd, (PTR) eraw_src, &internal_esym);
+ internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext
+ + internal_esym.asym.iss);
+ if (!ecoff_set_symbol_info (abfd, &internal_esym.asym,
+ &internal_ptr->symbol, 1,
+ internal_esym.weakext))
+ return false;
+ /* The alpha uses a negative ifd field for section symbols. */
+ if (internal_esym.ifd >= 0)
+ internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
+ + internal_esym.ifd);
+ else
+ internal_ptr->fdr = NULL;
+ internal_ptr->local = false;
+ internal_ptr->native = (PTR) eraw_src;
+ }
+
+ /* The local symbols must be accessed via the fdr's, because the
+ string and aux indices are relative to the fdr information. */
+ fdr_ptr = ecoff_data (abfd)->debug_info.fdr;
+ fdr_end = fdr_ptr + ecoff_data (abfd)->debug_info.symbolic_header.ifdMax;
+ for (; fdr_ptr < fdr_end; fdr_ptr++)
+ {
+ char *lraw_src;
+ char *lraw_end;
+
+ lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
+ + fdr_ptr->isymBase * external_sym_size);
+ lraw_end = lraw_src + fdr_ptr->csym * external_sym_size;
+ for (;
+ lraw_src < lraw_end;
+ lraw_src += external_sym_size, internal_ptr++)
+ {
+ SYMR internal_sym;
+
+ (*swap_sym_in) (abfd, (PTR) lraw_src, &internal_sym);
+ internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ss
+ + fdr_ptr->issBase
+ + internal_sym.iss);
+ if (!ecoff_set_symbol_info (abfd, &internal_sym,
+ &internal_ptr->symbol, 0, 0))
+ return false;
+ internal_ptr->fdr = fdr_ptr;
+ internal_ptr->local = true;
+ internal_ptr->native = (PTR) lraw_src;
+ }
+ }
+
+ ecoff_data (abfd)->canonical_symbols = internal;
+
+ return true;
+}
+
+/* Return the amount of space needed for the canonical symbols. */
+
+long
+_bfd_ecoff_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
+ &ecoff_data (abfd)->debug_info))
+ return -1;
+
+ if (bfd_get_symcount (abfd) == 0)
+ return 0;
+
+ return (bfd_get_symcount (abfd) + 1) * (sizeof (ecoff_symbol_type *));
+}
+
+/* Get the canonical symbols. */
+
+long
+_bfd_ecoff_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ unsigned int counter = 0;
+ ecoff_symbol_type *symbase;
+ ecoff_symbol_type **location = (ecoff_symbol_type **) alocation;
+
+ if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
+ return -1;
+ if (bfd_get_symcount (abfd) == 0)
+ return 0;
+
+ symbase = ecoff_data (abfd)->canonical_symbols;
+ while (counter < bfd_get_symcount (abfd))
+ {
+ *(location++) = symbase++;
+ counter++;
+ }
+ *location++ = (ecoff_symbol_type *) NULL;
+ return bfd_get_symcount (abfd);
+}
+
+/* Turn ECOFF type information into a printable string.
+ ecoff_emit_aggregate and ecoff_type_to_string are from
+ gcc/mips-tdump.c, with swapping added and used_ptr removed. */
+
+/* Write aggregate information to a string. */
+
+static void
+ecoff_emit_aggregate (abfd, fdr, string, rndx, isym, which)
+ bfd *abfd;
+ FDR *fdr;
+ char *string;
+ RNDXR *rndx;
+ long isym;
+ const char *which;
+{
+ const struct ecoff_debug_swap * const debug_swap =
+ &ecoff_backend (abfd)->debug_swap;
+ struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
+ unsigned int ifd = rndx->rfd;
+ unsigned int indx = rndx->index;
+ const char *name;
+
+ if (ifd == 0xfff)
+ ifd = isym;
+
+ /* An ifd of -1 is an opaque type. An escaped index of 0 is a
+ struct return type of a procedure compiled without -g. */
+ if (ifd == 0xffffffff
+ || (rndx->rfd == 0xfff && indx == 0))
+ name = "<undefined>";
+ else if (indx == indexNil)
+ name = "<no name>";
+ else
+ {
+ SYMR sym;
+
+ if (debug_info->external_rfd == NULL)
+ fdr = debug_info->fdr + ifd;
+ else
+ {
+ RFDT rfd;
+
+ (*debug_swap->swap_rfd_in) (abfd,
+ ((char *) debug_info->external_rfd
+ + ((fdr->rfdBase + ifd)
+ * debug_swap->external_rfd_size)),
+ &rfd);
+ fdr = debug_info->fdr + rfd;
+ }
+
+ indx += fdr->isymBase;
+
+ (*debug_swap->swap_sym_in) (abfd,
+ ((char *) debug_info->external_sym
+ + indx * debug_swap->external_sym_size),
+ &sym);
+
+ name = debug_info->ss + fdr->issBase + sym.iss;
+ }
+
+ sprintf (string,
+ "%s %s { ifd = %u, index = %lu }",
+ which, name, ifd,
+ ((long) indx
+ + debug_info->symbolic_header.iextMax));
+}
+
+/* Convert the type information to string format. */
+
+static char *
+ecoff_type_to_string (abfd, fdr, indx)
+ bfd *abfd;
+ FDR *fdr;
+ unsigned int indx;
+{
+ union aux_ext *aux_ptr;
+ int bigendian;
+ AUXU u;
+ struct qual {
+ unsigned int type;
+ int low_bound;
+ int high_bound;
+ int stride;
+ } qualifiers[7];
+ unsigned int basic_type;
+ int i;
+ char buffer1[1024];
+ static char buffer2[1024];
+ char *p1 = buffer1;
+ char *p2 = buffer2;
+ RNDXR rndx;
+
+ aux_ptr = ecoff_data (abfd)->debug_info.external_aux + fdr->iauxBase;
+ bigendian = fdr->fBigendian;
+
+ for (i = 0; i < 7; i++)
+ {
+ qualifiers[i].low_bound = 0;
+ qualifiers[i].high_bound = 0;
+ qualifiers[i].stride = 0;
+ }
+
+ if (AUX_GET_ISYM (bigendian, &aux_ptr[indx]) == (bfd_vma) -1)
+ return "-1 (no type)";
+ _bfd_ecoff_swap_tir_in (bigendian, &aux_ptr[indx++].a_ti, &u.ti);
+
+ basic_type = u.ti.bt;
+ qualifiers[0].type = u.ti.tq0;
+ qualifiers[1].type = u.ti.tq1;
+ qualifiers[2].type = u.ti.tq2;
+ qualifiers[3].type = u.ti.tq3;
+ qualifiers[4].type = u.ti.tq4;
+ qualifiers[5].type = u.ti.tq5;
+ qualifiers[6].type = tqNil;
+
+ /*
+ * Go get the basic type.
+ */
+ switch (basic_type)
+ {
+ case btNil: /* undefined */
+ strcpy (p1, "nil");
+ break;
+
+ case btAdr: /* address - integer same size as pointer */
+ strcpy (p1, "address");
+ break;
+
+ case btChar: /* character */
+ strcpy (p1, "char");
+ break;
+
+ case btUChar: /* unsigned character */
+ strcpy (p1, "unsigned char");
+ break;
+
+ case btShort: /* short */
+ strcpy (p1, "short");
+ break;
+
+ case btUShort: /* unsigned short */
+ strcpy (p1, "unsigned short");
+ break;
+
+ case btInt: /* int */
+ strcpy (p1, "int");
+ break;
+
+ case btUInt: /* unsigned int */
+ strcpy (p1, "unsigned int");
+ break;
+
+ case btLong: /* long */
+ strcpy (p1, "long");
+ break;
+
+ case btULong: /* unsigned long */
+ strcpy (p1, "unsigned long");
+ break;
+
+ case btFloat: /* float (real) */
+ strcpy (p1, "float");
+ break;
+
+ case btDouble: /* Double (real) */
+ strcpy (p1, "double");
+ break;
+
+ /* Structures add 1-2 aux words:
+ 1st word is [ST_RFDESCAPE, offset] pointer to struct def;
+ 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
+
+ case btStruct: /* Structure (Record) */
+ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
+ ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
+ (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
+ "struct");
+ indx++; /* skip aux words */
+ break;
+
+ /* Unions add 1-2 aux words:
+ 1st word is [ST_RFDESCAPE, offset] pointer to union def;
+ 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
+
+ case btUnion: /* Union */
+ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
+ ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
+ (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
+ "union");
+ indx++; /* skip aux words */
+ break;
+
+ /* Enumerations add 1-2 aux words:
+ 1st word is [ST_RFDESCAPE, offset] pointer to enum def;
+ 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
+
+ case btEnum: /* Enumeration */
+ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
+ ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
+ (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
+ "enum");
+ indx++; /* skip aux words */
+ break;
+
+ case btTypedef: /* defined via a typedef, isymRef points */
+ strcpy (p1, "typedef");
+ break;
+
+ case btRange: /* subrange of int */
+ strcpy (p1, "subrange");
+ break;
+
+ case btSet: /* pascal sets */
+ strcpy (p1, "set");
+ break;
+
+ case btComplex: /* fortran complex */
+ strcpy (p1, "complex");
+ break;
+
+ case btDComplex: /* fortran double complex */
+ strcpy (p1, "double complex");
+ break;
+
+ case btIndirect: /* forward or unnamed typedef */
+ strcpy (p1, "forward/unamed typedef");
+ break;
+
+ case btFixedDec: /* Fixed Decimal */
+ strcpy (p1, "fixed decimal");
+ break;
+
+ case btFloatDec: /* Float Decimal */
+ strcpy (p1, "float decimal");
+ break;
+
+ case btString: /* Varying Length Character String */
+ strcpy (p1, "string");
+ break;
+
+ case btBit: /* Aligned Bit String */
+ strcpy (p1, "bit");
+ break;
+
+ case btPicture: /* Picture */
+ strcpy (p1, "picture");
+ break;
+
+ case btVoid: /* Void */
+ strcpy (p1, "void");
+ break;
+
+ default:
+ sprintf (p1, _("Unknown basic type %d"), (int) basic_type);
+ break;
+ }
+
+ p1 += strlen (buffer1);
+
+ /*
+ * If this is a bitfield, get the bitsize.
+ */
+ if (u.ti.fBitfield)
+ {
+ int bitsize;
+
+ bitsize = AUX_GET_WIDTH (bigendian, &aux_ptr[indx++]);
+ sprintf (p1, " : %d", bitsize);
+ p1 += strlen (buffer1);
+ }
+
+
+ /*
+ * Deal with any qualifiers.
+ */
+ if (qualifiers[0].type != tqNil)
+ {
+ /*
+ * Snarf up any array bounds in the correct order. Arrays
+ * store 5 successive words in the aux. table:
+ * word 0 RNDXR to type of the bounds (ie, int)
+ * word 1 Current file descriptor index
+ * word 2 low bound
+ * word 3 high bound (or -1 if [])
+ * word 4 stride size in bits
+ */
+ for (i = 0; i < 7; i++)
+ {
+ if (qualifiers[i].type == tqArray)
+ {
+ qualifiers[i].low_bound =
+ AUX_GET_DNLOW (bigendian, &aux_ptr[indx+2]);
+ qualifiers[i].high_bound =
+ AUX_GET_DNHIGH (bigendian, &aux_ptr[indx+3]);
+ qualifiers[i].stride =
+ AUX_GET_WIDTH (bigendian, &aux_ptr[indx+4]);
+ indx += 5;
+ }
+ }
+
+ /*
+ * Now print out the qualifiers.
+ */
+ for (i = 0; i < 6; i++)
+ {
+ switch (qualifiers[i].type)
+ {
+ case tqNil:
+ case tqMax:
+ break;
+
+ case tqPtr:
+ strcpy (p2, "ptr to ");
+ p2 += sizeof ("ptr to ")-1;
+ break;
+
+ case tqVol:
+ strcpy (p2, "volatile ");
+ p2 += sizeof ("volatile ")-1;
+ break;
+
+ case tqFar:
+ strcpy (p2, "far ");
+ p2 += sizeof ("far ")-1;
+ break;
+
+ case tqProc:
+ strcpy (p2, "func. ret. ");
+ p2 += sizeof ("func. ret. ");
+ break;
+
+ case tqArray:
+ {
+ int first_array = i;
+ int j;
+
+ /* Print array bounds reversed (ie, in the order the C
+ programmer writes them). C is such a fun language.... */
+
+ while (i < 5 && qualifiers[i+1].type == tqArray)
+ i++;
+
+ for (j = i; j >= first_array; j--)
+ {
+ strcpy (p2, "array [");
+ p2 += sizeof ("array [")-1;
+ if (qualifiers[j].low_bound != 0)
+ sprintf (p2,
+ "%ld:%ld {%ld bits}",
+ (long) qualifiers[j].low_bound,
+ (long) qualifiers[j].high_bound,
+ (long) qualifiers[j].stride);
+
+ else if (qualifiers[j].high_bound != -1)
+ sprintf (p2,
+ "%ld {%ld bits}",
+ (long) (qualifiers[j].high_bound + 1),
+ (long) (qualifiers[j].stride));
+
+ else
+ sprintf (p2, " {%ld bits}", (long) (qualifiers[j].stride));
+
+ p2 += strlen (p2);
+ strcpy (p2, "] of ");
+ p2 += sizeof ("] of ")-1;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ strcpy (p2, buffer1);
+ return buffer2;
+}
+
+/* Return information about ECOFF symbol SYMBOL in RET. */
+
+/*ARGSUSED*/
+void
+_bfd_ecoff_get_symbol_info (abfd, symbol, ret)
+ bfd *abfd; /* Ignored. */
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+/* Return whether this is a local label. */
+
+/*ARGSUSED*/
+boolean
+_bfd_ecoff_bfd_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return name[0] == '$';
+}
+
+/* Print information about an ECOFF symbol. */
+
+void
+_bfd_ecoff_print_symbol (abfd, filep, symbol, how)
+ bfd *abfd;
+ PTR filep;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ const struct ecoff_debug_swap * const debug_swap
+ = &ecoff_backend (abfd)->debug_swap;
+ FILE *file = (FILE *)filep;
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+ if (ecoffsymbol (symbol)->local)
+ {
+ SYMR ecoff_sym;
+
+ (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
+ &ecoff_sym);
+ fprintf (file, "ecoff local ");
+ fprintf_vma (file, (bfd_vma) ecoff_sym.value);
+ fprintf (file, " %x %x", (unsigned) ecoff_sym.st,
+ (unsigned) ecoff_sym.sc);
+ }
+ else
+ {
+ EXTR ecoff_ext;
+
+ (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
+ &ecoff_ext);
+ fprintf (file, "ecoff extern ");
+ fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
+ fprintf (file, " %x %x", (unsigned) ecoff_ext.asym.st,
+ (unsigned) ecoff_ext.asym.sc);
+ }
+ break;
+ case bfd_print_symbol_all:
+ /* Print out the symbols in a reasonable way */
+ {
+ char type;
+ int pos;
+ EXTR ecoff_ext;
+ char jmptbl;
+ char cobol_main;
+ char weakext;
+
+ if (ecoffsymbol (symbol)->local)
+ {
+ (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
+ &ecoff_ext.asym);
+ type = 'l';
+ pos = ((((char *) ecoffsymbol (symbol)->native
+ - (char *) ecoff_data (abfd)->debug_info.external_sym)
+ / debug_swap->external_sym_size)
+ + ecoff_data (abfd)->debug_info.symbolic_header.iextMax);
+ jmptbl = ' ';
+ cobol_main = ' ';
+ weakext = ' ';
+ }
+ else
+ {
+ (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
+ &ecoff_ext);
+ type = 'e';
+ pos = (((char *) ecoffsymbol (symbol)->native
+ - (char *) ecoff_data (abfd)->debug_info.external_ext)
+ / debug_swap->external_ext_size);
+ jmptbl = ecoff_ext.jmptbl ? 'j' : ' ';
+ cobol_main = ecoff_ext.cobol_main ? 'c' : ' ';
+ weakext = ecoff_ext.weakext ? 'w' : ' ';
+ }
+
+ fprintf (file, "[%3d] %c ",
+ pos, type);
+ fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
+ fprintf (file, " st %x sc %x indx %x %c%c%c %s",
+ (unsigned) ecoff_ext.asym.st,
+ (unsigned) ecoff_ext.asym.sc,
+ (unsigned) ecoff_ext.asym.index,
+ jmptbl, cobol_main, weakext,
+ symbol->name);
+
+ if (ecoffsymbol (symbol)->fdr != NULL
+ && ecoff_ext.asym.index != indexNil)
+ {
+ FDR *fdr;
+ unsigned int indx;
+ int bigendian;
+ bfd_size_type sym_base;
+ union aux_ext *aux_base;
+
+ fdr = ecoffsymbol (symbol)->fdr;
+ indx = ecoff_ext.asym.index;
+
+ /* sym_base is used to map the fdr relative indices which
+ appear in the file to the position number which we are
+ using. */
+ sym_base = fdr->isymBase;
+ if (ecoffsymbol (symbol)->local)
+ sym_base +=
+ ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
+
+ /* aux_base is the start of the aux entries for this file;
+ asym.index is an offset from this. */
+ aux_base = (ecoff_data (abfd)->debug_info.external_aux
+ + fdr->iauxBase);
+
+ /* The aux entries are stored in host byte order; the
+ order is indicated by a bit in the fdr. */
+ bigendian = fdr->fBigendian;
+
+ /* This switch is basically from gcc/mips-tdump.c */
+ switch (ecoff_ext.asym.st)
+ {
+ case stNil:
+ case stLabel:
+ break;
+
+ case stFile:
+ case stBlock:
+ fprintf (file, _("\n End+1 symbol: %ld"),
+ (long) (indx + sym_base));
+ break;
+
+ case stEnd:
+ if (ecoff_ext.asym.sc == scText
+ || ecoff_ext.asym.sc == scInfo)
+ fprintf (file, _("\n First symbol: %ld"),
+ (long) (indx + sym_base));
+ else
+ fprintf (file, _("\n First symbol: %ld"),
+ ((long)
+ (AUX_GET_ISYM (bigendian,
+ &aux_base[ecoff_ext.asym.index])
+ + sym_base)));
+ break;
+
+ case stProc:
+ case stStaticProc:
+ if (ECOFF_IS_STAB (&ecoff_ext.asym))
+ ;
+ else if (ecoffsymbol (symbol)->local)
+ fprintf (file, _("\n End+1 symbol: %-7ld Type: %s"),
+ ((long)
+ (AUX_GET_ISYM (bigendian,
+ &aux_base[ecoff_ext.asym.index])
+ + sym_base)),
+ ecoff_type_to_string (abfd, fdr, indx + 1));
+ else
+ fprintf (file, _("\n Local symbol: %ld"),
+ ((long) indx
+ + (long) sym_base
+ + (ecoff_data (abfd)
+ ->debug_info.symbolic_header.iextMax)));
+ break;
+
+ case stStruct:
+ fprintf (file, _("\n struct; End+1 symbol: %ld"),
+ (long) (indx + sym_base));
+ break;
+
+ case stUnion:
+ fprintf (file, _("\n union; End+1 symbol: %ld"),
+ (long) (indx + sym_base));
+ break;
+
+ case stEnum:
+ fprintf (file, _("\n enum; End+1 symbol: %ld"),
+ (long) (indx + sym_base));
+ break;
+
+ default:
+ if (! ECOFF_IS_STAB (&ecoff_ext.asym))
+ fprintf (file, _("\n Type: %s"),
+ ecoff_type_to_string (abfd, fdr, indx));
+ break;
+ }
+ }
+ }
+ break;
+ }
+}
+
+/* Read in the relocs for a section. */
+
+static boolean
+ecoff_slurp_reloc_table (abfd, section, symbols)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ arelent *internal_relocs;
+ bfd_size_type external_reloc_size;
+ bfd_size_type external_relocs_size;
+ char *external_relocs;
+ arelent *rptr;
+ unsigned int i;
+
+ if (section->relocation != (arelent *) NULL
+ || section->reloc_count == 0
+ || (section->flags & SEC_CONSTRUCTOR) != 0)
+ return true;
+
+ if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
+ return false;
+
+ internal_relocs = (arelent *) bfd_alloc (abfd,
+ (sizeof (arelent)
+ * section->reloc_count));
+ external_reloc_size = backend->external_reloc_size;
+ external_relocs_size = external_reloc_size * section->reloc_count;
+ external_relocs = (char *) bfd_alloc (abfd, external_relocs_size);
+ if (internal_relocs == (arelent *) NULL
+ || external_relocs == (char *) NULL)
+ return false;
+ if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
+ return false;
+ if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
+ != external_relocs_size)
+ return false;
+
+ for (i = 0, rptr = internal_relocs; i < section->reloc_count; i++, rptr++)
+ {
+ struct internal_reloc intern;
+
+ (*backend->swap_reloc_in) (abfd,
+ external_relocs + i * external_reloc_size,
+ &intern);
+
+ if (intern.r_extern)
+ {
+ /* r_symndx is an index into the external symbols. */
+ BFD_ASSERT (intern.r_symndx >= 0
+ && (intern.r_symndx
+ < (ecoff_data (abfd)
+ ->debug_info.symbolic_header.iextMax)));
+ rptr->sym_ptr_ptr = symbols + intern.r_symndx;
+ rptr->addend = 0;
+ }
+ else if (intern.r_symndx == RELOC_SECTION_NONE
+ || intern.r_symndx == RELOC_SECTION_ABS)
+ {
+ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ rptr->addend = 0;
+ }
+ else
+ {
+ CONST char *sec_name;
+ asection *sec;
+
+ /* r_symndx is a section key. */
+ switch (intern.r_symndx)
+ {
+ case RELOC_SECTION_TEXT: sec_name = ".text"; break;
+ case RELOC_SECTION_RDATA: sec_name = ".rdata"; break;
+ case RELOC_SECTION_DATA: sec_name = ".data"; break;
+ case RELOC_SECTION_SDATA: sec_name = ".sdata"; break;
+ case RELOC_SECTION_SBSS: sec_name = ".sbss"; break;
+ case RELOC_SECTION_BSS: sec_name = ".bss"; break;
+ case RELOC_SECTION_INIT: sec_name = ".init"; break;
+ case RELOC_SECTION_LIT8: sec_name = ".lit8"; break;
+ case RELOC_SECTION_LIT4: sec_name = ".lit4"; break;
+ case RELOC_SECTION_XDATA: sec_name = ".xdata"; break;
+ case RELOC_SECTION_PDATA: sec_name = ".pdata"; break;
+ case RELOC_SECTION_FINI: sec_name = ".fini"; break;
+ case RELOC_SECTION_LITA: sec_name = ".lita"; break;
+ case RELOC_SECTION_RCONST: sec_name = ".rconst"; break;
+ default: abort ();
+ }
+
+ sec = bfd_get_section_by_name (abfd, sec_name);
+ if (sec == (asection *) NULL)
+ abort ();
+ rptr->sym_ptr_ptr = sec->symbol_ptr_ptr;
+
+ rptr->addend = - bfd_get_section_vma (abfd, sec);
+ }
+
+ rptr->address = intern.r_vaddr - bfd_get_section_vma (abfd, section);
+
+ /* Let the backend select the howto field and do any other
+ required processing. */
+ (*backend->adjust_reloc_in) (abfd, &intern, rptr);
+ }
+
+ bfd_release (abfd, external_relocs);
+
+ section->relocation = internal_relocs;
+
+ return true;
+}
+
+/* Get a canonical list of relocs. */
+
+long
+_bfd_ecoff_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd *abfd;
+ asection *section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ unsigned int count;
+
+ if (section->flags & SEC_CONSTRUCTOR)
+ {
+ arelent_chain *chain;
+
+ /* This section has relocs made up by us, not the file, so take
+ them out of their chain and place them into the data area
+ provided. */
+ for (count = 0, chain = section->constructor_chain;
+ count < section->reloc_count;
+ count++, chain = chain->next)
+ *relptr++ = &chain->relent;
+ }
+ else
+ {
+ arelent *tblptr;
+
+ if (ecoff_slurp_reloc_table (abfd, section, symbols) == false)
+ return -1;
+
+ tblptr = section->relocation;
+
+ for (count = 0; count < section->reloc_count; count++)
+ *relptr++ = tblptr++;
+ }
+
+ *relptr = (arelent *) NULL;
+
+ return section->reloc_count;
+}
+
+/* Provided a BFD, a section and an offset into the section, calculate
+ and return the name of the source file and the line nearest to the
+ wanted location. */
+
+/*ARGSUSED*/
+boolean
+_bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset,
+ filename_ptr, functionname_ptr, retline_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **ignore_symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *retline_ptr;
+{
+ const struct ecoff_debug_swap * const debug_swap
+ = &ecoff_backend (abfd)->debug_swap;
+ struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
+ struct ecoff_find_line *line_info;
+
+ /* Make sure we have the FDR's. */
+ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL, debug_info)
+ || bfd_get_symcount (abfd) == 0)
+ return false;
+
+ if (ecoff_data (abfd)->find_line_info == NULL)
+ {
+ ecoff_data (abfd)->find_line_info =
+ ((struct ecoff_find_line *)
+ bfd_zalloc (abfd, sizeof (struct ecoff_find_line)));
+ if (ecoff_data (abfd)->find_line_info == NULL)
+ return false;
+ }
+ line_info = ecoff_data (abfd)->find_line_info;
+
+ return _bfd_ecoff_locate_line (abfd, section, offset, debug_info,
+ debug_swap, line_info, filename_ptr,
+ functionname_ptr, retline_ptr);
+}
+
+/* Copy private BFD data. This is called by objcopy and strip. We
+ use it to copy the ECOFF debugging information from one BFD to the
+ other. It would be theoretically possible to represent the ECOFF
+ debugging information in the symbol table. However, it would be a
+ lot of work, and there would be little gain (gas, gdb, and ld
+ already access the ECOFF debugging information via the
+ ecoff_debug_info structure, and that structure would have to be
+ retained in order to support ECOFF debugging in MIPS ELF).
+
+ The debugging information for the ECOFF external symbols comes from
+ the symbol table, so this function only handles the other debugging
+ information. */
+
+boolean
+_bfd_ecoff_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ struct ecoff_debug_info *iinfo = &ecoff_data (ibfd)->debug_info;
+ struct ecoff_debug_info *oinfo = &ecoff_data (obfd)->debug_info;
+ register int i;
+ asymbol **sym_ptr_ptr;
+ size_t c;
+ boolean local;
+
+ /* We only want to copy information over if both BFD's use ECOFF
+ format. */
+ if (bfd_get_flavour (ibfd) != bfd_target_ecoff_flavour
+ || bfd_get_flavour (obfd) != bfd_target_ecoff_flavour)
+ return true;
+
+ /* Copy the GP value and the register masks. */
+ ecoff_data (obfd)->gp = ecoff_data (ibfd)->gp;
+ ecoff_data (obfd)->gprmask = ecoff_data (ibfd)->gprmask;
+ ecoff_data (obfd)->fprmask = ecoff_data (ibfd)->fprmask;
+ for (i = 0; i < 3; i++)
+ ecoff_data (obfd)->cprmask[i] = ecoff_data (ibfd)->cprmask[i];
+
+ /* Copy the version stamp. */
+ oinfo->symbolic_header.vstamp = iinfo->symbolic_header.vstamp;
+
+ /* If there are no symbols, don't copy any debugging information. */
+ c = bfd_get_symcount (obfd);
+ sym_ptr_ptr = bfd_get_outsymbols (obfd);
+ if (c == 0 || sym_ptr_ptr == (asymbol **) NULL)
+ return true;
+
+ /* See if there are any local symbols. */
+ local = false;
+ for (; c > 0; c--, sym_ptr_ptr++)
+ {
+ if (ecoffsymbol (*sym_ptr_ptr)->local)
+ {
+ local = true;
+ break;
+ }
+ }
+
+ if (local)
+ {
+ /* There are some local symbols. We just bring over all the
+ debugging information. FIXME: This is not quite the right
+ thing to do. If the user has asked us to discard all
+ debugging information, then we are probably going to wind up
+ keeping it because there will probably be some local symbol
+ which objcopy did not discard. We should actually break
+ apart the debugging information and only keep that which
+ applies to the symbols we want to keep. */
+ oinfo->symbolic_header.ilineMax = iinfo->symbolic_header.ilineMax;
+ oinfo->symbolic_header.cbLine = iinfo->symbolic_header.cbLine;
+ oinfo->line = iinfo->line;
+
+ oinfo->symbolic_header.idnMax = iinfo->symbolic_header.idnMax;
+ oinfo->external_dnr = iinfo->external_dnr;
+
+ oinfo->symbolic_header.ipdMax = iinfo->symbolic_header.ipdMax;
+ oinfo->external_pdr = iinfo->external_pdr;
+
+ oinfo->symbolic_header.isymMax = iinfo->symbolic_header.isymMax;
+ oinfo->external_sym = iinfo->external_sym;
+
+ oinfo->symbolic_header.ioptMax = iinfo->symbolic_header.ioptMax;
+ oinfo->external_opt = iinfo->external_opt;
+
+ oinfo->symbolic_header.iauxMax = iinfo->symbolic_header.iauxMax;
+ oinfo->external_aux = iinfo->external_aux;
+
+ oinfo->symbolic_header.issMax = iinfo->symbolic_header.issMax;
+ oinfo->ss = iinfo->ss;
+
+ oinfo->symbolic_header.ifdMax = iinfo->symbolic_header.ifdMax;
+ oinfo->external_fdr = iinfo->external_fdr;
+
+ oinfo->symbolic_header.crfd = iinfo->symbolic_header.crfd;
+ oinfo->external_rfd = iinfo->external_rfd;
+ }
+ else
+ {
+ /* We are discarding all the local symbol information. Look
+ through the external symbols and remove all references to FDR
+ or aux information. */
+ c = bfd_get_symcount (obfd);
+ sym_ptr_ptr = bfd_get_outsymbols (obfd);
+ for (; c > 0; c--, sym_ptr_ptr++)
+ {
+ EXTR esym;
+
+ (*(ecoff_backend (obfd)->debug_swap.swap_ext_in))
+ (obfd, ecoffsymbol (*sym_ptr_ptr)->native, &esym);
+ esym.ifd = ifdNil;
+ esym.asym.index = indexNil;
+ (*(ecoff_backend (obfd)->debug_swap.swap_ext_out))
+ (obfd, &esym, ecoffsymbol (*sym_ptr_ptr)->native);
+ }
+ }
+
+ return true;
+}
+
+/* Set the architecture. The supported architecture is stored in the
+ backend pointer. We always set the architecture anyhow, since many
+ callers ignore the return value. */
+
+boolean
+_bfd_ecoff_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ bfd_default_set_arch_mach (abfd, arch, machine);
+ return arch == ecoff_backend (abfd)->arch;
+}
+
+/* Get the size of the section headers. */
+
+/*ARGSUSED*/
+int
+_bfd_ecoff_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+ asection *current;
+ int c;
+ int ret;
+
+ c = 0;
+ for (current = abfd->sections;
+ current != (asection *)NULL;
+ current = current->next)
+ ++c;
+
+ ret = (bfd_coff_filhsz (abfd)
+ + bfd_coff_aoutsz (abfd)
+ + c * bfd_coff_scnhsz (abfd));
+ return BFD_ALIGN (ret, 16);
+}
+
+/* Get the contents of a section. */
+
+boolean
+_bfd_ecoff_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ return _bfd_generic_get_section_contents (abfd, section, location,
+ offset, count);
+}
+
+/* Sort sections by VMA, but put SEC_ALLOC sections first. This is
+ called via qsort. */
+
+static int
+ecoff_sort_hdrs (arg1, arg2)
+ const PTR arg1;
+ const PTR arg2;
+{
+ const asection *hdr1 = *(const asection **) arg1;
+ const asection *hdr2 = *(const asection **) arg2;
+
+ if ((hdr1->flags & SEC_ALLOC) != 0)
+ {
+ if ((hdr2->flags & SEC_ALLOC) == 0)
+ return -1;
+ }
+ else
+ {
+ if ((hdr2->flags & SEC_ALLOC) != 0)
+ return 1;
+ }
+ if (hdr1->vma < hdr2->vma)
+ return -1;
+ else if (hdr1->vma > hdr2->vma)
+ return 1;
+ else
+ return 0;
+}
+
+/* Calculate the file position for each section, and set
+ reloc_filepos. */
+
+static boolean
+ecoff_compute_section_file_positions (abfd)
+ bfd *abfd;
+{
+ file_ptr sofar, file_sofar;
+ asection **sorted_hdrs;
+ asection *current;
+ unsigned int i;
+ file_ptr old_sofar;
+ boolean rdata_in_text;
+ boolean first_data, first_nonalloc;
+ const bfd_vma round = ecoff_backend (abfd)->round;
+
+ sofar = _bfd_ecoff_sizeof_headers (abfd, false);
+ file_sofar = sofar;
+
+ /* Sort the sections by VMA. */
+ sorted_hdrs = (asection **) bfd_malloc (abfd->section_count
+ * sizeof (asection *));
+ if (sorted_hdrs == NULL)
+ return false;
+ for (current = abfd->sections, i = 0;
+ current != NULL;
+ current = current->next, i++)
+ sorted_hdrs[i] = current;
+ BFD_ASSERT (i == abfd->section_count);
+
+ qsort (sorted_hdrs, abfd->section_count, sizeof (asection *),
+ ecoff_sort_hdrs);
+
+ /* Some versions of the OSF linker put the .rdata section in the
+ text segment, and some do not. */
+ rdata_in_text = ecoff_backend (abfd)->rdata_in_text;
+ if (rdata_in_text)
+ {
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ current = sorted_hdrs[i];
+ if (strcmp (current->name, _RDATA) == 0)
+ break;
+ if ((current->flags & SEC_CODE) == 0
+ && strcmp (current->name, _PDATA) != 0
+ && strcmp (current->name, _RCONST) != 0)
+ {
+ rdata_in_text = false;
+ break;
+ }
+ }
+ }
+ ecoff_data (abfd)->rdata_in_text = rdata_in_text;
+
+ first_data = true;
+ first_nonalloc = true;
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ unsigned int alignment_power;
+
+ current = sorted_hdrs[i];
+
+ /* For the Alpha ECOFF .pdata section the lnnoptr field is
+ supposed to indicate the number of .pdata entries that are
+ really in the section. Each entry is 8 bytes. We store this
+ away in line_filepos before increasing the section size. */
+ if (strcmp (current->name, _PDATA) == 0)
+ current->line_filepos = current->_raw_size / 8;
+
+ alignment_power = current->alignment_power;
+
+ /* On Ultrix, the data sections in an executable file must be
+ aligned to a page boundary within the file. This does not
+ affect the section size, though. FIXME: Does this work for
+ other platforms? It requires some modification for the
+ Alpha, because .rdata on the Alpha goes with the text, not
+ the data. */
+ if ((abfd->flags & EXEC_P) != 0
+ && (abfd->flags & D_PAGED) != 0
+ && ! first_data
+ && (current->flags & SEC_CODE) == 0
+ && (! rdata_in_text
+ || strcmp (current->name, _RDATA) != 0)
+ && strcmp (current->name, _PDATA) != 0
+ && strcmp (current->name, _RCONST) != 0)
+ {
+ sofar = (sofar + round - 1) &~ (round - 1);
+ file_sofar = (file_sofar + round - 1) &~ (round - 1);
+ first_data = false;
+ }
+ else if (strcmp (current->name, _LIB) == 0)
+ {
+ /* On Irix 4, the location of contents of the .lib section
+ from a shared library section is also rounded up to a
+ page boundary. */
+
+ sofar = (sofar + round - 1) &~ (round - 1);
+ file_sofar = (file_sofar + round - 1) &~ (round - 1);
+ }
+ else if (first_nonalloc
+ && (current->flags & SEC_ALLOC) == 0
+ && (abfd->flags & D_PAGED) != 0)
+ {
+ /* Skip up to the next page for an unallocated section, such
+ as the .comment section on the Alpha. This leaves room
+ for the .bss section. */
+ first_nonalloc = false;
+ sofar = (sofar + round - 1) &~ (round - 1);
+ file_sofar = (file_sofar + round - 1) &~ (round - 1);
+ }
+
+ /* Align the sections in the file to the same boundary on
+ which they are aligned in virtual memory. */
+ sofar = BFD_ALIGN (sofar, 1 << alignment_power);
+ if ((current->flags & SEC_HAS_CONTENTS) != 0)
+ file_sofar = BFD_ALIGN (file_sofar, 1 << alignment_power);
+
+ if ((abfd->flags & D_PAGED) != 0
+ && (current->flags & SEC_ALLOC) != 0)
+ {
+ sofar += (current->vma - sofar) % round;
+ if ((current->flags & SEC_HAS_CONTENTS) != 0)
+ file_sofar += (current->vma - file_sofar) % round;
+ }
+
+ if ((current->flags & (SEC_HAS_CONTENTS | SEC_LOAD)) != 0)
+ current->filepos = file_sofar;
+
+ sofar += current->_raw_size;
+ if ((current->flags & SEC_HAS_CONTENTS) != 0)
+ file_sofar += current->_raw_size;
+
+ /* make sure that this section is of the right size too */
+ old_sofar = sofar;
+ sofar = BFD_ALIGN (sofar, 1 << alignment_power);
+ if ((current->flags & SEC_HAS_CONTENTS) != 0)
+ file_sofar = BFD_ALIGN (file_sofar, 1 << alignment_power);
+ current->_raw_size += sofar - old_sofar;
+ }
+
+ free (sorted_hdrs);
+ sorted_hdrs = NULL;
+
+ ecoff_data (abfd)->reloc_filepos = file_sofar;
+
+ return true;
+}
+
+/* Determine the location of the relocs for all the sections in the
+ output file, as well as the location of the symbolic debugging
+ information. */
+
+static bfd_size_type
+ecoff_compute_reloc_file_positions (abfd)
+ bfd *abfd;
+{
+ const bfd_size_type external_reloc_size =
+ ecoff_backend (abfd)->external_reloc_size;
+ file_ptr reloc_base;
+ bfd_size_type reloc_size;
+ asection *current;
+ file_ptr sym_base;
+
+ if (! abfd->output_has_begun)
+ {
+ if (! ecoff_compute_section_file_positions (abfd))
+ abort ();
+ abfd->output_has_begun = true;
+ }
+
+ reloc_base = ecoff_data (abfd)->reloc_filepos;
+
+ reloc_size = 0;
+ for (current = abfd->sections;
+ current != (asection *)NULL;
+ current = current->next)
+ {
+ if (current->reloc_count == 0)
+ current->rel_filepos = 0;
+ else
+ {
+ bfd_size_type relsize;
+
+ current->rel_filepos = reloc_base;
+ relsize = current->reloc_count * external_reloc_size;
+ reloc_size += relsize;
+ reloc_base += relsize;
+ }
+ }
+
+ sym_base = ecoff_data (abfd)->reloc_filepos + reloc_size;
+
+ /* At least on Ultrix, the symbol table of an executable file must
+ be aligned to a page boundary. FIXME: Is this true on other
+ platforms? */
+ if ((abfd->flags & EXEC_P) != 0
+ && (abfd->flags & D_PAGED) != 0)
+ sym_base = ((sym_base + ecoff_backend (abfd)->round - 1)
+ &~ (ecoff_backend (abfd)->round - 1));
+
+ ecoff_data (abfd)->sym_filepos = sym_base;
+
+ return reloc_size;
+}
+
+/* Set the contents of a section. */
+
+boolean
+_bfd_ecoff_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ /* This must be done first, because bfd_set_section_contents is
+ going to set output_has_begun to true. */
+ if (abfd->output_has_begun == false)
+ {
+ if (! ecoff_compute_section_file_positions (abfd))
+ return false;
+ }
+
+ /* Handle the .lib section specially so that Irix 4 shared libraries
+ work out. See coff_set_section_contents in coffcode.h. */
+ if (strcmp (section->name, _LIB) == 0)
+ {
+ bfd_byte *rec, *recend;
+
+ rec = (bfd_byte *) location;
+ recend = rec + count;
+ while (rec < recend)
+ {
+ ++section->lma;
+ rec += bfd_get_32 (abfd, rec) * 4;
+ }
+
+ BFD_ASSERT (rec == recend);
+ }
+
+ if (count == 0)
+ return true;
+
+ if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
+ || bfd_write (location, 1, count, abfd) != count)
+ return false;
+
+ return true;
+}
+
+/* Get the GP value for an ECOFF file. This is a hook used by
+ nlmconv. */
+
+bfd_vma
+bfd_ecoff_get_gp_value (abfd)
+ 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. */
+
+boolean
+bfd_ecoff_set_gp_value (abfd, gp_value)
+ bfd *abfd;
+ bfd_vma gp_value;
+{
+ if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
+ || bfd_get_format (abfd) != bfd_object)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ ecoff_data (abfd)->gp = gp_value;
+
+ return true;
+}
+
+/* Set the register masks for an ECOFF file. This is a hook used by
+ the assembler. */
+
+boolean
+bfd_ecoff_set_regmasks (abfd, gprmask, fprmask, cprmask)
+ bfd *abfd;
+ unsigned long gprmask;
+ unsigned long fprmask;
+ unsigned long *cprmask;
+{
+ ecoff_data_type *tdata;
+
+ if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
+ || bfd_get_format (abfd) != bfd_object)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ tdata = ecoff_data (abfd);
+ tdata->gprmask = gprmask;
+ tdata->fprmask = fprmask;
+ if (cprmask != (unsigned long *) NULL)
+ {
+ register int i;
+
+ for (i = 0; i < 3; i++)
+ tdata->cprmask[i] = cprmask[i];
+ }
+
+ return true;
+}
+
+/* Get ECOFF EXTR information for an external symbol. This function
+ is passed to bfd_ecoff_debug_externals. */
+
+static boolean
+ecoff_get_extr (sym, esym)
+ asymbol *sym;
+ EXTR *esym;
+{
+ ecoff_symbol_type *ecoff_sym_ptr;
+ bfd *input_bfd;
+
+ if (bfd_asymbol_flavour (sym) != bfd_target_ecoff_flavour
+ || ecoffsymbol (sym)->native == NULL)
+ {
+ /* Don't include debugging, local, or section symbols. */
+ if ((sym->flags & BSF_DEBUGGING) != 0
+ || (sym->flags & BSF_LOCAL) != 0
+ || (sym->flags & BSF_SECTION_SYM) != 0)
+ return false;
+
+ esym->jmptbl = 0;
+ esym->cobol_main = 0;
+ esym->weakext = (sym->flags & BSF_WEAK) != 0;
+ esym->reserved = 0;
+ esym->ifd = ifdNil;
+ /* FIXME: we can do better than this for st and sc. */
+ esym->asym.st = stGlobal;
+ esym->asym.sc = scAbs;
+ esym->asym.reserved = 0;
+ esym->asym.index = indexNil;
+ return true;
+ }
+
+ ecoff_sym_ptr = ecoffsymbol (sym);
+
+ if (ecoff_sym_ptr->local)
+ return false;
+
+ input_bfd = bfd_asymbol_bfd (sym);
+ (*(ecoff_backend (input_bfd)->debug_swap.swap_ext_in))
+ (input_bfd, ecoff_sym_ptr->native, esym);
+
+ /* If the symbol was defined by the linker, then esym will be
+ undefined but sym will not be. Get a better class for such a
+ symbol. */
+ if ((esym->asym.sc == scUndefined
+ || esym->asym.sc == scSUndefined)
+ && ! bfd_is_und_section (bfd_get_section (sym)))
+ esym->asym.sc = scAbs;
+
+ /* Adjust the FDR index for the symbol by that used for the input
+ BFD. */
+ if (esym->ifd != -1)
+ {
+ struct ecoff_debug_info *input_debug;
+
+ input_debug = &ecoff_data (input_bfd)->debug_info;
+ BFD_ASSERT (esym->ifd < input_debug->symbolic_header.ifdMax);
+ if (input_debug->ifdmap != (RFDT *) NULL)
+ esym->ifd = input_debug->ifdmap[esym->ifd];
+ }
+
+ return true;
+}
+
+/* Set the external symbol index. This routine is passed to
+ bfd_ecoff_debug_externals. */
+
+static void
+ecoff_set_index (sym, indx)
+ asymbol *sym;
+ bfd_size_type indx;
+{
+ ecoff_set_sym_index (sym, indx);
+}
+
+/* Write out an ECOFF file. */
+
+boolean
+_bfd_ecoff_write_object_contents (abfd)
+ bfd *abfd;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ const bfd_vma round = backend->round;
+ const bfd_size_type filhsz = bfd_coff_filhsz (abfd);
+ const bfd_size_type aoutsz = bfd_coff_aoutsz (abfd);
+ const bfd_size_type scnhsz = bfd_coff_scnhsz (abfd);
+ const bfd_size_type external_hdr_size
+ = backend->debug_swap.external_hdr_size;
+ const bfd_size_type external_reloc_size = backend->external_reloc_size;
+ void (* const adjust_reloc_out) PARAMS ((bfd *,
+ const arelent *,
+ struct internal_reloc *))
+ = backend->adjust_reloc_out;
+ void (* const swap_reloc_out) PARAMS ((bfd *,
+ const struct internal_reloc *,
+ PTR))
+ = backend->swap_reloc_out;
+ struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
+ HDRR * const symhdr = &debug->symbolic_header;
+ asection *current;
+ unsigned int count;
+ bfd_size_type reloc_size;
+ bfd_size_type text_size;
+ bfd_vma text_start;
+ boolean set_text_start;
+ bfd_size_type data_size;
+ bfd_vma data_start;
+ boolean set_data_start;
+ bfd_size_type bss_size;
+ PTR buff = NULL;
+ PTR reloc_buff = NULL;
+ struct internal_filehdr internal_f;
+ struct internal_aouthdr internal_a;
+ int i;
+
+ /* Determine where the sections and relocs will go in the output
+ file. */
+ reloc_size = ecoff_compute_reloc_file_positions (abfd);
+
+ count = 1;
+ for (current = abfd->sections;
+ current != (asection *)NULL;
+ current = current->next)
+ {
+ current->target_index = count;
+ ++count;
+ }
+
+ if ((abfd->flags & D_PAGED) != 0)
+ text_size = _bfd_ecoff_sizeof_headers (abfd, false);
+ else
+ text_size = 0;
+ text_start = 0;
+ set_text_start = false;
+ data_size = 0;
+ data_start = 0;
+ set_data_start = false;
+ bss_size = 0;
+
+ /* Write section headers to the file. */
+
+ /* Allocate buff big enough to hold a section header,
+ file header, or a.out header. */
+ {
+ bfd_size_type siz;
+ siz = scnhsz;
+ if (siz < filhsz)
+ siz = filhsz;
+ if (siz < aoutsz)
+ siz = aoutsz;
+ buff = (PTR) bfd_malloc ((size_t) siz);
+ if (buff == NULL)
+ goto error_return;
+ }
+
+ internal_f.f_nscns = 0;
+ if (bfd_seek (abfd, (file_ptr) (filhsz + aoutsz), SEEK_SET) != 0)
+ goto error_return;
+ for (current = abfd->sections;
+ current != (asection *) NULL;
+ current = current->next)
+ {
+ struct internal_scnhdr section;
+ bfd_vma vma;
+
+ ++internal_f.f_nscns;
+
+ strncpy (section.s_name, current->name, sizeof section.s_name);
+
+ /* This seems to be correct for Irix 4 shared libraries. */
+ vma = bfd_get_section_vma (abfd, current);
+ if (strcmp (current->name, _LIB) == 0)
+ section.s_vaddr = 0;
+ else
+ section.s_vaddr = vma;
+
+ section.s_paddr = current->lma;
+ section.s_size = bfd_get_section_size_before_reloc (current);
+
+ /* If this section is unloadable then the scnptr will be 0. */
+ if ((current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+ section.s_scnptr = 0;
+ else
+ section.s_scnptr = current->filepos;
+ section.s_relptr = current->rel_filepos;
+
+ /* FIXME: the lnnoptr of the .sbss or .sdata section of an
+ object file produced by the assembler is supposed to point to
+ information about how much room is required by objects of
+ various different sizes. I think this only matters if we
+ want the linker to compute the best size to use, or
+ something. I don't know what happens if the information is
+ not present. */
+ if (strcmp (current->name, _PDATA) != 0)
+ section.s_lnnoptr = 0;
+ else
+ {
+ /* The Alpha ECOFF .pdata section uses the lnnoptr field to
+ hold the number of entries in the section (each entry is
+ 8 bytes). We stored this in the line_filepos field in
+ ecoff_compute_section_file_positions. */
+ section.s_lnnoptr = current->line_filepos;
+ }
+
+ section.s_nreloc = current->reloc_count;
+ section.s_nlnno = 0;
+ section.s_flags = ecoff_sec_to_styp_flags (current->name,
+ current->flags);
+
+ if (bfd_coff_swap_scnhdr_out (abfd, (PTR) &section, buff) == 0
+ || bfd_write (buff, 1, scnhsz, abfd) != scnhsz)
+ goto error_return;
+
+ if ((section.s_flags & STYP_TEXT) != 0
+ || ((section.s_flags & STYP_RDATA) != 0
+ && ecoff_data (abfd)->rdata_in_text)
+ || section.s_flags == STYP_PDATA
+ || (section.s_flags & STYP_DYNAMIC) != 0
+ || (section.s_flags & STYP_LIBLIST) != 0
+ || (section.s_flags & STYP_RELDYN) != 0
+ || section.s_flags == STYP_CONFLIC
+ || (section.s_flags & STYP_DYNSTR) != 0
+ || (section.s_flags & STYP_DYNSYM) != 0
+ || (section.s_flags & STYP_HASH) != 0
+ || (section.s_flags & STYP_ECOFF_INIT) != 0
+ || (section.s_flags & STYP_ECOFF_FINI) != 0
+ || section.s_flags == STYP_RCONST)
+ {
+ text_size += bfd_get_section_size_before_reloc (current);
+ if (! set_text_start || text_start > vma)
+ {
+ text_start = vma;
+ set_text_start = true;
+ }
+ }
+ else if ((section.s_flags & STYP_RDATA) != 0
+ || (section.s_flags & STYP_DATA) != 0
+ || (section.s_flags & STYP_LITA) != 0
+ || (section.s_flags & STYP_LIT8) != 0
+ || (section.s_flags & STYP_LIT4) != 0
+ || (section.s_flags & STYP_SDATA) != 0
+ || section.s_flags == STYP_XDATA
+ || (section.s_flags & STYP_GOT) != 0)
+ {
+ data_size += bfd_get_section_size_before_reloc (current);
+ if (! set_data_start || data_start > vma)
+ {
+ data_start = vma;
+ set_data_start = true;
+ }
+ }
+ else if ((section.s_flags & STYP_BSS) != 0
+ || (section.s_flags & STYP_SBSS) != 0)
+ bss_size += bfd_get_section_size_before_reloc (current);
+ else if (section.s_flags == 0
+ || (section.s_flags & STYP_ECOFF_LIB) != 0
+ || section.s_flags == STYP_COMMENT)
+ /* Do nothing */ ;
+ else
+ abort ();
+ }
+
+ /* Set up the file header. */
+
+ internal_f.f_magic = ecoff_get_magic (abfd);
+
+ /* We will NOT put a fucking timestamp in the header here. Every
+ time you put it back, I will come in and take it out again. I'm
+ sorry. This field does not belong here. We fill it with a 0 so
+ it compares the same but is not a reasonable time. --
+ gnu@cygnus.com. */
+ internal_f.f_timdat = 0;
+
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ /* The ECOFF f_nsyms field is not actually the number of
+ symbols, it's the size of symbolic information header. */
+ internal_f.f_nsyms = external_hdr_size;
+ internal_f.f_symptr = ecoff_data (abfd)->sym_filepos;
+ }
+ else
+ {
+ internal_f.f_nsyms = 0;
+ internal_f.f_symptr = 0;
+ }
+
+ internal_f.f_opthdr = aoutsz;
+
+ internal_f.f_flags = F_LNNO;
+ if (reloc_size == 0)
+ internal_f.f_flags |= F_RELFLG;
+ if (bfd_get_symcount (abfd) == 0)
+ internal_f.f_flags |= F_LSYMS;
+ if (abfd->flags & EXEC_P)
+ internal_f.f_flags |= F_EXEC;
+
+ if (bfd_little_endian (abfd))
+ internal_f.f_flags |= F_AR32WR;
+ else
+ internal_f.f_flags |= F_AR32W;
+
+ /* Set up the ``optional'' header. */
+ if ((abfd->flags & D_PAGED) != 0)
+ internal_a.magic = ECOFF_AOUT_ZMAGIC;
+ else
+ internal_a.magic = ECOFF_AOUT_OMAGIC;
+
+ /* FIXME: Is this really correct? */
+ internal_a.vstamp = symhdr->vstamp;
+
+ /* At least on Ultrix, these have to be rounded to page boundaries.
+ FIXME: Is this true on other platforms? */
+ if ((abfd->flags & D_PAGED) != 0)
+ {
+ internal_a.tsize = (text_size + round - 1) &~ (round - 1);
+ internal_a.text_start = text_start &~ (round - 1);
+ internal_a.dsize = (data_size + round - 1) &~ (round - 1);
+ internal_a.data_start = data_start &~ (round - 1);
+ }
+ else
+ {
+ internal_a.tsize = text_size;
+ internal_a.text_start = text_start;
+ internal_a.dsize = data_size;
+ internal_a.data_start = data_start;
+ }
+
+ /* On Ultrix, the initial portions of the .sbss and .bss segments
+ are at the end of the data section. The bsize field in the
+ optional header records how many bss bytes are required beyond
+ those in the data section. The value is not rounded to a page
+ boundary. */
+ if (bss_size < internal_a.dsize - data_size)
+ bss_size = 0;
+ else
+ bss_size -= internal_a.dsize - data_size;
+ internal_a.bsize = bss_size;
+ internal_a.bss_start = internal_a.data_start + internal_a.dsize;
+
+ internal_a.entry = bfd_get_start_address (abfd);
+
+ internal_a.gp_value = ecoff_data (abfd)->gp;
+
+ internal_a.gprmask = ecoff_data (abfd)->gprmask;
+ internal_a.fprmask = ecoff_data (abfd)->fprmask;
+ for (i = 0; i < 4; i++)
+ internal_a.cprmask[i] = ecoff_data (abfd)->cprmask[i];
+
+ /* Let the backend adjust the headers if necessary. */
+ if (backend->adjust_headers)
+ {
+ if (! (*backend->adjust_headers) (abfd, &internal_f, &internal_a))
+ goto error_return;
+ }
+
+ /* Write out the file header and the optional header. */
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto error_return;
+
+ bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, buff);
+ if (bfd_write (buff, 1, filhsz, abfd) != filhsz)
+ goto error_return;
+
+ bfd_coff_swap_aouthdr_out (abfd, (PTR) &internal_a, buff);
+ if (bfd_write (buff, 1, aoutsz, abfd) != aoutsz)
+ goto error_return;
+
+ /* Build the external symbol information. This must be done before
+ writing out the relocs so that we know the symbol indices. We
+ don't do this if this BFD was created by the backend linker,
+ since it will have already handled the symbols and relocs. */
+ if (! ecoff_data (abfd)->linker)
+ {
+ symhdr->iextMax = 0;
+ symhdr->issExtMax = 0;
+ debug->external_ext = debug->external_ext_end = NULL;
+ debug->ssext = debug->ssext_end = NULL;
+ if (bfd_ecoff_debug_externals (abfd, debug, &backend->debug_swap,
+ (((abfd->flags & EXEC_P) == 0)
+ ? true : false),
+ ecoff_get_extr, ecoff_set_index)
+ == false)
+ goto error_return;
+
+ /* Write out the relocs. */
+ for (current = abfd->sections;
+ current != (asection *) NULL;
+ current = current->next)
+ {
+ arelent **reloc_ptr_ptr;
+ arelent **reloc_end;
+ char *out_ptr;
+
+ if (current->reloc_count == 0)
+ continue;
+
+ reloc_buff =
+ bfd_alloc (abfd, current->reloc_count * external_reloc_size);
+ if (reloc_buff == NULL)
+ goto error_return;
+
+ reloc_ptr_ptr = current->orelocation;
+ reloc_end = reloc_ptr_ptr + current->reloc_count;
+ out_ptr = (char *) reloc_buff;
+ for (;
+ reloc_ptr_ptr < reloc_end;
+ reloc_ptr_ptr++, out_ptr += external_reloc_size)
+ {
+ arelent *reloc;
+ asymbol *sym;
+ struct internal_reloc in;
+
+ memset ((PTR) &in, 0, sizeof in);
+
+ reloc = *reloc_ptr_ptr;
+ sym = *reloc->sym_ptr_ptr;
+
+ in.r_vaddr = (reloc->address
+ + bfd_get_section_vma (abfd, current));
+ in.r_type = reloc->howto->type;
+
+ if ((sym->flags & BSF_SECTION_SYM) == 0)
+ {
+ in.r_symndx = ecoff_get_sym_index (*reloc->sym_ptr_ptr);
+ in.r_extern = 1;
+ }
+ else
+ {
+ CONST char *name;
+
+ name = bfd_get_section_name (abfd, bfd_get_section (sym));
+ if (strcmp (name, ".text") == 0)
+ in.r_symndx = RELOC_SECTION_TEXT;
+ else if (strcmp (name, ".rdata") == 0)
+ in.r_symndx = RELOC_SECTION_RDATA;
+ else if (strcmp (name, ".data") == 0)
+ in.r_symndx = RELOC_SECTION_DATA;
+ else if (strcmp (name, ".sdata") == 0)
+ in.r_symndx = RELOC_SECTION_SDATA;
+ else if (strcmp (name, ".sbss") == 0)
+ in.r_symndx = RELOC_SECTION_SBSS;
+ else if (strcmp (name, ".bss") == 0)
+ in.r_symndx = RELOC_SECTION_BSS;
+ else if (strcmp (name, ".init") == 0)
+ in.r_symndx = RELOC_SECTION_INIT;
+ else if (strcmp (name, ".lit8") == 0)
+ in.r_symndx = RELOC_SECTION_LIT8;
+ else if (strcmp (name, ".lit4") == 0)
+ in.r_symndx = RELOC_SECTION_LIT4;
+ else if (strcmp (name, ".xdata") == 0)
+ in.r_symndx = RELOC_SECTION_XDATA;
+ else if (strcmp (name, ".pdata") == 0)
+ in.r_symndx = RELOC_SECTION_PDATA;
+ else if (strcmp (name, ".fini") == 0)
+ in.r_symndx = RELOC_SECTION_FINI;
+ else if (strcmp (name, ".lita") == 0)
+ in.r_symndx = RELOC_SECTION_LITA;
+ else if (strcmp (name, "*ABS*") == 0)
+ in.r_symndx = RELOC_SECTION_ABS;
+ else if (strcmp (name, ".rconst") == 0)
+ in.r_symndx = RELOC_SECTION_RCONST;
+ else
+ abort ();
+ in.r_extern = 0;
+ }
+
+ (*adjust_reloc_out) (abfd, reloc, &in);
+
+ (*swap_reloc_out) (abfd, &in, (PTR) out_ptr);
+ }
+
+ if (bfd_seek (abfd, current->rel_filepos, SEEK_SET) != 0)
+ goto error_return;
+ if (bfd_write (reloc_buff,
+ external_reloc_size, current->reloc_count, abfd)
+ != external_reloc_size * current->reloc_count)
+ goto error_return;
+ bfd_release (abfd, reloc_buff);
+ reloc_buff = NULL;
+ }
+
+ /* Write out the symbolic debugging information. */
+ if (bfd_get_symcount (abfd) > 0)
+ {
+ /* Write out the debugging information. */
+ if (bfd_ecoff_write_debug (abfd, debug, &backend->debug_swap,
+ ecoff_data (abfd)->sym_filepos)
+ == false)
+ goto error_return;
+ }
+ }
+
+ /* The .bss section of a demand paged executable must receive an
+ entire page. If there are symbols, the symbols will start on the
+ next page. If there are no symbols, we must fill out the page by
+ hand. */
+ if (bfd_get_symcount (abfd) == 0
+ && (abfd->flags & EXEC_P) != 0
+ && (abfd->flags & D_PAGED) != 0)
+ {
+ char c;
+
+ if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
+ SEEK_SET) != 0)
+ goto error_return;
+ if (bfd_read (&c, 1, 1, abfd) == 0)
+ c = 0;
+ if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
+ SEEK_SET) != 0)
+ goto error_return;
+ if (bfd_write (&c, 1, 1, abfd) != 1)
+ goto error_return;
+ }
+
+ if (reloc_buff != NULL)
+ bfd_release (abfd, reloc_buff);
+ if (buff != NULL)
+ free (buff);
+ return true;
+ error_return:
+ if (reloc_buff != NULL)
+ bfd_release (abfd, reloc_buff);
+ if (buff != NULL)
+ free (buff);
+ return false;
+}
+
+/* Archive handling. ECOFF uses what appears to be a unique type of
+ archive header (armap). The byte ordering of the armap and the
+ contents are encoded in the name of the armap itself. At least for
+ now, we only support archives with the same byte ordering in the
+ armap and the contents.
+
+ The first four bytes in the armap are the number of symbol
+ definitions. This is always a power of two.
+
+ This is followed by the symbol definitions. Each symbol definition
+ occupies 8 bytes. The first four bytes are the offset from the
+ start of the armap strings to the null-terminated string naming
+ this symbol. The second four bytes are the file offset to the
+ archive member which defines this symbol. If the second four bytes
+ are 0, then this is not actually a symbol definition, and it should
+ be ignored.
+
+ The symbols are hashed into the armap with a closed hashing scheme.
+ See the functions below for the details of the algorithm.
+
+ After the symbol definitions comes four bytes holding the size of
+ the string table, followed by the string table itself. */
+
+/* The name of an archive headers looks like this:
+ __________E[BL]E[BL]_ (with a trailing space).
+ The trailing space is changed to an X if the archive is changed to
+ indicate that the armap is out of date.
+
+ The Alpha seems to use ________64E[BL]E[BL]_. */
+
+#define ARMAP_BIG_ENDIAN 'B'
+#define ARMAP_LITTLE_ENDIAN 'L'
+#define ARMAP_MARKER 'E'
+#define ARMAP_START_LENGTH 10
+#define ARMAP_HEADER_MARKER_INDEX 10
+#define ARMAP_HEADER_ENDIAN_INDEX 11
+#define ARMAP_OBJECT_MARKER_INDEX 12
+#define ARMAP_OBJECT_ENDIAN_INDEX 13
+#define ARMAP_END_INDEX 14
+#define ARMAP_END "_ "
+
+/* This is a magic number used in the hashing algorithm. */
+#define ARMAP_HASH_MAGIC 0x9dd68ab5
+
+/* This returns the hash value to use for a string. It also sets
+ *REHASH to the rehash adjustment if the first slot is taken. SIZE
+ is the number of entries in the hash table, and HLOG is the log
+ base 2 of SIZE. */
+
+static unsigned int
+ecoff_armap_hash (s, rehash, size, hlog)
+ CONST char *s;
+ unsigned int *rehash;
+ unsigned int size;
+ unsigned int hlog;
+{
+ unsigned int hash;
+
+ if (hlog == 0)
+ return 0;
+ hash = *s++;
+ while (*s != '\0')
+ hash = ((hash >> 27) | (hash << 5)) + *s++;
+ hash *= ARMAP_HASH_MAGIC;
+ *rehash = (hash & (size - 1)) | 1;
+ return hash >> (32 - hlog);
+}
+
+/* Read in the armap. */
+
+boolean
+_bfd_ecoff_slurp_armap (abfd)
+ bfd *abfd;
+{
+ char nextname[17];
+ unsigned int i;
+ struct areltdata *mapdata;
+ bfd_size_type parsed_size;
+ char *raw_armap;
+ struct artdata *ardata;
+ unsigned int count;
+ char *raw_ptr;
+ struct symdef *symdef_ptr;
+ char *stringbase;
+
+ /* Get the name of the first element. */
+ i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ if (i == 0)
+ return true;
+ if (i != 16)
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
+ return false;
+
+ /* Irix 4.0.5F apparently can use either an ECOFF armap or a
+ standard COFF armap. We could move the ECOFF armap stuff into
+ bfd_slurp_armap, but that seems inappropriate since no other
+ target uses this format. Instead, we check directly for a COFF
+ armap. */
+ if (strncmp (nextname, "/ ", 16) == 0)
+ return bfd_slurp_armap (abfd);
+
+ /* See if the first element is an armap. */
+ if (strncmp (nextname, ecoff_backend (abfd)->armap_start,
+ ARMAP_START_LENGTH) != 0
+ || nextname[ARMAP_HEADER_MARKER_INDEX] != ARMAP_MARKER
+ || (nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
+ && nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
+ || nextname[ARMAP_OBJECT_MARKER_INDEX] != ARMAP_MARKER
+ || (nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
+ && nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
+ || strncmp (nextname + ARMAP_END_INDEX,
+ ARMAP_END, sizeof ARMAP_END - 1) != 0)
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
+
+ /* Make sure we have the right byte ordering. */
+ if (((nextname[ARMAP_HEADER_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
+ ^ (bfd_header_big_endian (abfd)))
+ || ((nextname[ARMAP_OBJECT_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
+ ^ (bfd_big_endian (abfd))))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ /* Read in the armap. */
+ ardata = bfd_ardata (abfd);
+ mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (mapdata == (struct areltdata *) NULL)
+ return false;
+ parsed_size = mapdata->parsed_size;
+ bfd_release (abfd, (PTR) mapdata);
+
+ raw_armap = (char *) bfd_alloc (abfd, parsed_size);
+ if (raw_armap == (char *) NULL)
+ return false;
+
+ if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ bfd_release (abfd, (PTR) raw_armap);
+ return false;
+ }
+
+ ardata->tdata = (PTR) raw_armap;
+
+ count = bfd_h_get_32 (abfd, (PTR) raw_armap);
+
+ ardata->symdef_count = 0;
+ ardata->cache = (struct ar_cache *) NULL;
+
+ /* This code used to overlay the symdefs over the raw archive data,
+ but that doesn't work on a 64 bit host. */
+
+ stringbase = raw_armap + count * 8 + 8;
+
+#ifdef CHECK_ARMAP_HASH
+ {
+ unsigned int hlog;
+
+ /* Double check that I have the hashing algorithm right by making
+ sure that every symbol can be looked up successfully. */
+ hlog = 0;
+ for (i = 1; i < count; i <<= 1)
+ hlog++;
+ BFD_ASSERT (i == count);
+
+ raw_ptr = raw_armap + 4;
+ for (i = 0; i < count; i++, raw_ptr += 8)
+ {
+ unsigned int name_offset, file_offset;
+ unsigned int hash, rehash, srch;
+
+ name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
+ file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
+ if (file_offset == 0)
+ continue;
+ hash = ecoff_armap_hash (stringbase + name_offset, &rehash, count,
+ hlog);
+ if (hash == i)
+ continue;
+
+ /* See if we can rehash to this location. */
+ for (srch = (hash + rehash) & (count - 1);
+ srch != hash && srch != i;
+ srch = (srch + rehash) & (count - 1))
+ BFD_ASSERT (bfd_h_get_32 (abfd, (PTR) (raw_armap + 8 + srch * 8))
+ != 0);
+ BFD_ASSERT (srch == i);
+ }
+ }
+
+#endif /* CHECK_ARMAP_HASH */
+
+ raw_ptr = raw_armap + 4;
+ for (i = 0; i < count; i++, raw_ptr += 8)
+ if (bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4)) != 0)
+ ++ardata->symdef_count;
+
+ symdef_ptr = ((struct symdef *)
+ bfd_alloc (abfd,
+ ardata->symdef_count * sizeof (struct symdef)));
+ if (!symdef_ptr)
+ return false;
+
+ ardata->symdefs = (carsym *) symdef_ptr;
+
+ raw_ptr = raw_armap + 4;
+ for (i = 0; i < count; i++, raw_ptr += 8)
+ {
+ unsigned int name_offset, file_offset;
+
+ file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
+ if (file_offset == 0)
+ continue;
+ name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
+ symdef_ptr->s.name = stringbase + name_offset;
+ symdef_ptr->file_offset = file_offset;
+ ++symdef_ptr;
+ }
+
+ ardata->first_file_filepos = bfd_tell (abfd);
+ /* Pad to an even boundary. */
+ ardata->first_file_filepos += ardata->first_file_filepos % 2;
+
+ bfd_has_map (abfd) = true;
+
+ return true;
+}
+
+/* Write out an armap. */
+
+boolean
+_bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx)
+ bfd *abfd;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int orl_count;
+ int stridx;
+{
+ unsigned int hashsize, hashlog;
+ unsigned int symdefsize;
+ int padit;
+ unsigned int stringsize;
+ unsigned int mapsize;
+ file_ptr firstreal;
+ struct ar_hdr hdr;
+ struct stat statbuf;
+ unsigned int i;
+ bfd_byte temp[4];
+ bfd_byte *hashtable;
+ bfd *current;
+ bfd *last_elt;
+
+ /* Ultrix appears to use as a hash table size the least power of two
+ greater than twice the number of entries. */
+ for (hashlog = 0; ((unsigned int) 1 << hashlog) <= 2 * orl_count; hashlog++)
+ ;
+ hashsize = 1 << hashlog;
+
+ symdefsize = hashsize * 8;
+ padit = stridx % 2;
+ stringsize = stridx + padit;
+
+ /* Include 8 bytes to store symdefsize and stringsize in output. */
+ mapsize = symdefsize + stringsize + 8;
+
+ firstreal = SARMAG + sizeof (struct ar_hdr) + mapsize + elength;
+
+ memset ((PTR) &hdr, 0, sizeof hdr);
+
+ /* Work out the ECOFF armap name. */
+ strcpy (hdr.ar_name, ecoff_backend (abfd)->armap_start);
+ hdr.ar_name[ARMAP_HEADER_MARKER_INDEX] = ARMAP_MARKER;
+ hdr.ar_name[ARMAP_HEADER_ENDIAN_INDEX] =
+ (bfd_header_big_endian (abfd)
+ ? ARMAP_BIG_ENDIAN
+ : ARMAP_LITTLE_ENDIAN);
+ hdr.ar_name[ARMAP_OBJECT_MARKER_INDEX] = ARMAP_MARKER;
+ hdr.ar_name[ARMAP_OBJECT_ENDIAN_INDEX] =
+ bfd_big_endian (abfd) ? ARMAP_BIG_ENDIAN : ARMAP_LITTLE_ENDIAN;
+ memcpy (hdr.ar_name + ARMAP_END_INDEX, ARMAP_END, sizeof ARMAP_END - 1);
+
+ /* Write the timestamp of the archive header to be just a little bit
+ later than the timestamp of the file, otherwise the linker will
+ complain that the index is out of date. Actually, the Ultrix
+ linker just checks the archive name; the GNU linker may check the
+ date. */
+ stat (abfd->filename, &statbuf);
+ sprintf (hdr.ar_date, "%ld", (long) (statbuf.st_mtime + 60));
+
+ /* The DECstation uses zeroes for the uid, gid and mode of the
+ armap. */
+ hdr.ar_uid[0] = '0';
+ hdr.ar_gid[0] = '0';
+ hdr.ar_mode[0] = '0';
+
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+
+ hdr.ar_fmag[0] = '`';
+ hdr.ar_fmag[1] = '\012';
+
+ /* Turn all null bytes in the header into spaces. */
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+ if (((char *)(&hdr))[i] == '\0')
+ (((char *)(&hdr))[i]) = ' ';
+
+ if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
+ != sizeof (struct ar_hdr))
+ return false;
+
+ bfd_h_put_32 (abfd, (bfd_vma) hashsize, temp);
+ if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
+ return false;
+
+ hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
+ if (!hashtable)
+ return false;
+
+ current = abfd->archive_head;
+ last_elt = current;
+ for (i = 0; i < orl_count; i++)
+ {
+ unsigned int hash, rehash;
+
+ /* Advance firstreal to the file position of this archive
+ element. */
+ if (((bfd *) map[i].pos) != last_elt)
+ {
+ do
+ {
+ firstreal += arelt_size (current) + sizeof (struct ar_hdr);
+ firstreal += firstreal % 2;
+ current = current->next;
+ }
+ while (current != (bfd *) map[i].pos);
+ }
+
+ last_elt = current;
+
+ hash = ecoff_armap_hash (*map[i].name, &rehash, hashsize, hashlog);
+ if (bfd_h_get_32 (abfd, (PTR) (hashtable + (hash * 8) + 4)) != 0)
+ {
+ unsigned int srch;
+
+ /* The desired slot is already taken. */
+ for (srch = (hash + rehash) & (hashsize - 1);
+ srch != hash;
+ srch = (srch + rehash) & (hashsize - 1))
+ if (bfd_h_get_32 (abfd, (PTR) (hashtable + (srch * 8) + 4)) == 0)
+ break;
+
+ BFD_ASSERT (srch != hash);
+
+ hash = srch;
+ }
+
+ bfd_h_put_32 (abfd, (bfd_vma) map[i].namidx,
+ (PTR) (hashtable + hash * 8));
+ bfd_h_put_32 (abfd, (bfd_vma) firstreal,
+ (PTR) (hashtable + hash * 8 + 4));
+ }
+
+ if (bfd_write ((PTR) hashtable, 1, symdefsize, abfd) != symdefsize)
+ return false;
+
+ bfd_release (abfd, hashtable);
+
+ /* Now write the strings. */
+ bfd_h_put_32 (abfd, (bfd_vma) stringsize, temp);
+ if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
+ return false;
+ for (i = 0; i < orl_count; i++)
+ {
+ bfd_size_type len;
+
+ len = strlen (*map[i].name) + 1;
+ if (bfd_write ((PTR) (*map[i].name), 1, len, abfd) != len)
+ return false;
+ }
+
+ /* The spec sez this should be a newline. But in order to be
+ bug-compatible for DECstation ar we use a null. */
+ if (padit)
+ {
+ if (bfd_write ("", 1, 1, abfd) != 1)
+ return false;
+ }
+
+ return true;
+}
+
+/* See whether this BFD is an archive. If it is, read in the armap
+ and the extended name table. */
+
+const bfd_target *
+_bfd_ecoff_archive_p (abfd)
+ bfd *abfd;
+{
+ struct artdata *tdata_hold;
+ char armag[SARMAG + 1];
+
+ tdata_hold = abfd->tdata.aout_ar_data;
+
+ if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return (const bfd_target *) NULL;
+ }
+
+ if (strncmp (armag, ARMAG, SARMAG) != 0)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
+ involves a cast, we can't do it as the left operand of
+ assignment. */
+ abfd->tdata.aout_ar_data =
+ (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
+
+ if (bfd_ardata (abfd) == (struct artdata *) NULL)
+ {
+ abfd->tdata.aout_ar_data = tdata_hold;
+ return (const bfd_target *) NULL;
+ }
+
+ bfd_ardata (abfd)->first_file_filepos = SARMAG;
+ bfd_ardata (abfd)->cache = NULL;
+ bfd_ardata (abfd)->archive_head = NULL;
+ bfd_ardata (abfd)->symdefs = NULL;
+ bfd_ardata (abfd)->extended_names = NULL;
+ bfd_ardata (abfd)->tdata = NULL;
+
+ if (_bfd_ecoff_slurp_armap (abfd) == false
+ || _bfd_ecoff_slurp_extended_name_table (abfd) == false)
+ {
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = tdata_hold;
+ return (const bfd_target *) NULL;
+ }
+
+ if (bfd_has_map (abfd))
+ {
+ bfd *first;
+
+ /* This archive has a map, so we may presume that the contents
+ are object files. Make sure that if the first file in the
+ archive can be recognized as an object file, it is for this
+ target. If not, assume that this is the wrong format. If
+ the first file is not an object file, somebody is doing
+ something weird, and we permit it so that ar -t will work. */
+
+ first = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
+ if (first != NULL)
+ {
+ boolean fail;
+
+ first->target_defaulted = false;
+ fail = false;
+ if (bfd_check_format (first, bfd_object)
+ && first->xvec != abfd->xvec)
+ {
+ (void) bfd_close (first);
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = tdata_hold;
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* We ought to close first here, but we can't, because we
+ have no way to remove it from the archive cache. FIXME. */
+ }
+ }
+
+ return abfd->xvec;
+}
+
+/* ECOFF linker code. */
+
+static struct bfd_hash_entry *ecoff_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string));
+static boolean ecoff_link_add_archive_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean ecoff_link_check_archive_element
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
+static boolean ecoff_link_add_object_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean ecoff_link_add_externals
+ PARAMS ((bfd *, struct bfd_link_info *, PTR, char *));
+
+/* Routine to create an entry in an ECOFF link hash table. */
+
+static struct bfd_hash_entry *
+ecoff_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct ecoff_link_hash_entry *ret = (struct ecoff_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct ecoff_link_hash_entry *) NULL)
+ ret = ((struct ecoff_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct ecoff_link_hash_entry)));
+ if (ret == (struct ecoff_link_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct ecoff_link_hash_entry *)
+ _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+
+ if (ret)
+ {
+ /* Set local fields. */
+ ret->indx = -1;
+ ret->abfd = NULL;
+ ret->written = 0;
+ ret->small = 0;
+ }
+ memset ((PTR) &ret->esym, 0, sizeof ret->esym);
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create an ECOFF link hash table. */
+
+struct bfd_link_hash_table *
+_bfd_ecoff_bfd_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct ecoff_link_hash_table *ret;
+
+ ret = ((struct ecoff_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct ecoff_link_hash_table)));
+ if (ret == NULL)
+ return NULL;
+ if (! _bfd_link_hash_table_init (&ret->root, abfd,
+ ecoff_link_hash_newfunc))
+ {
+ free (ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+ return &ret->root;
+}
+
+/* Look up an entry in an ECOFF link hash table. */
+
+#define ecoff_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct ecoff_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
+
+/* Traverse an ECOFF link hash table. */
+
+#define ecoff_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the ECOFF link hash table from the info structure. This is
+ just a cast. */
+
+#define ecoff_hash_table(p) ((struct ecoff_link_hash_table *) ((p)->hash))
+
+/* Given an ECOFF BFD, add symbols to the global hash table as
+ appropriate. */
+
+boolean
+_bfd_ecoff_bfd_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_object:
+ return ecoff_link_add_object_symbols (abfd, info);
+ case bfd_archive:
+ return ecoff_link_add_archive_symbols (abfd, info);
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+}
+
+/* Add the symbols from an archive file to the global hash table.
+ This looks through the undefined symbols, looks each one up in the
+ archive hash table, and adds any associated object file. We do not
+ use _bfd_generic_link_add_archive_symbols because ECOFF archives
+ already have a hash table, so there is no reason to construct
+ another one. */
+
+static boolean
+ecoff_link_add_archive_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ const bfd_byte *raw_armap;
+ struct bfd_link_hash_entry **pundef;
+ unsigned int armap_count;
+ unsigned int armap_log;
+ unsigned int i;
+ const bfd_byte *hashtable;
+ const char *stringbase;
+
+ if (! bfd_has_map (abfd))
+ {
+ /* An empty archive is a special case. */
+ if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
+ return true;
+ bfd_set_error (bfd_error_no_armap);
+ return false;
+ }
+
+ /* If we don't have any raw data for this archive, as can happen on
+ Irix 4.0.5F, we call the generic routine.
+ FIXME: We should be more clever about this, since someday tdata
+ may get to something for a generic archive. */
+ raw_armap = (const bfd_byte *) bfd_ardata (abfd)->tdata;
+ if (raw_armap == (bfd_byte *) NULL)
+ return (_bfd_generic_link_add_archive_symbols
+ (abfd, info, ecoff_link_check_archive_element));
+
+ armap_count = bfd_h_get_32 (abfd, raw_armap);
+
+ armap_log = 0;
+ for (i = 1; i < armap_count; i <<= 1)
+ armap_log++;
+ BFD_ASSERT (i == armap_count);
+
+ hashtable = raw_armap + 4;
+ stringbase = (const char *) raw_armap + armap_count * 8 + 8;
+
+ /* Look through the list of undefined symbols. */
+ pundef = &info->hash->undefs;
+ while (*pundef != (struct bfd_link_hash_entry *) NULL)
+ {
+ struct bfd_link_hash_entry *h;
+ unsigned int hash, rehash;
+ unsigned int file_offset;
+ const char *name;
+ bfd *element;
+
+ h = *pundef;
+
+ /* When a symbol is defined, it is not necessarily removed from
+ the list. */
+ if (h->type != bfd_link_hash_undefined
+ && h->type != bfd_link_hash_common)
+ {
+ /* Remove this entry from the list, for general cleanliness
+ and because we are going to look through the list again
+ if we search any more libraries. We can't remove the
+ entry if it is the tail, because that would lose any
+ entries we add to the list later on. */
+ if (*pundef != info->hash->undefs_tail)
+ *pundef = (*pundef)->next;
+ else
+ pundef = &(*pundef)->next;
+ continue;
+ }
+
+ /* Native ECOFF linkers do not pull in archive elements merely
+ to satisfy common definitions, so neither do we. We leave
+ them on the list, though, in case we are linking against some
+ other object format. */
+ if (h->type != bfd_link_hash_undefined)
+ {
+ pundef = &(*pundef)->next;
+ continue;
+ }
+
+ /* Look for this symbol in the archive hash table. */
+ hash = ecoff_armap_hash (h->root.string, &rehash, armap_count,
+ armap_log);
+
+ file_offset = bfd_h_get_32 (abfd, hashtable + (hash * 8) + 4);
+ if (file_offset == 0)
+ {
+ /* Nothing in this slot. */
+ pundef = &(*pundef)->next;
+ continue;
+ }
+
+ name = stringbase + bfd_h_get_32 (abfd, hashtable + (hash * 8));
+ if (name[0] != h->root.string[0]
+ || strcmp (name, h->root.string) != 0)
+ {
+ unsigned int srch;
+ boolean found;
+
+ /* That was the wrong symbol. Try rehashing. */
+ found = false;
+ for (srch = (hash + rehash) & (armap_count - 1);
+ srch != hash;
+ srch = (srch + rehash) & (armap_count - 1))
+ {
+ file_offset = bfd_h_get_32 (abfd, hashtable + (srch * 8) + 4);
+ if (file_offset == 0)
+ break;
+ name = stringbase + bfd_h_get_32 (abfd, hashtable + (srch * 8));
+ if (name[0] == h->root.string[0]
+ && strcmp (name, h->root.string) == 0)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (! found)
+ {
+ pundef = &(*pundef)->next;
+ continue;
+ }
+
+ hash = srch;
+ }
+
+ element = (*backend->get_elt_at_filepos) (abfd, file_offset);
+ if (element == (bfd *) NULL)
+ return false;
+
+ if (! bfd_check_format (element, bfd_object))
+ return false;
+
+ /* Unlike the generic linker, we know that this element provides
+ a definition for an undefined symbol and we know that we want
+ to include it. We don't need to check anything. */
+ if (! (*info->callbacks->add_archive_element) (info, element, name))
+ return false;
+ if (! ecoff_link_add_object_symbols (element, info))
+ return false;
+
+ pundef = &(*pundef)->next;
+ }
+
+ return true;
+}
+
+/* This is called if we used _bfd_generic_link_add_archive_symbols
+ because we were not dealing with an ECOFF archive. */
+
+static boolean
+ecoff_link_check_archive_element (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
+ = backend->debug_swap.swap_ext_in;
+ HDRR *symhdr;
+ bfd_size_type external_ext_size;
+ PTR external_ext = NULL;
+ size_t esize;
+ char *ssext = NULL;
+ char *ext_ptr;
+ char *ext_end;
+
+ *pneeded = false;
+
+ if (! ecoff_slurp_symbolic_header (abfd))
+ goto error_return;
+
+ /* If there are no symbols, we don't want it. */
+ if (bfd_get_symcount (abfd) == 0)
+ goto successful_return;
+
+ symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
+
+ /* Read in the external symbols and external strings. */
+ external_ext_size = backend->debug_swap.external_ext_size;
+ esize = symhdr->iextMax * external_ext_size;
+ external_ext = (PTR) bfd_malloc (esize);
+ if (external_ext == NULL && esize != 0)
+ goto error_return;
+
+ if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
+ || bfd_read (external_ext, 1, esize, abfd) != esize)
+ goto error_return;
+
+ ssext = (char *) bfd_malloc (symhdr->issExtMax);
+ if (ssext == NULL && symhdr->issExtMax != 0)
+ goto error_return;
+
+ if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
+ || (bfd_read (ssext, 1, symhdr->issExtMax, abfd) !=
+ (bfd_size_type) symhdr->issExtMax))
+ goto error_return;
+
+ /* Look through the external symbols to see if they define some
+ symbol that is currently undefined. */
+ ext_ptr = (char *) external_ext;
+ ext_end = ext_ptr + esize;
+ for (; ext_ptr < ext_end; ext_ptr += external_ext_size)
+ {
+ EXTR esym;
+ boolean def;
+ const char *name;
+ struct bfd_link_hash_entry *h;
+
+ (*swap_ext_in) (abfd, (PTR) ext_ptr, &esym);
+
+ /* See if this symbol defines something. */
+ if (esym.asym.st != stGlobal
+ && esym.asym.st != stLabel
+ && esym.asym.st != stProc)
+ continue;
+
+ switch (esym.asym.sc)
+ {
+ case scText:
+ case scData:
+ case scBss:
+ case scAbs:
+ case scSData:
+ case scSBss:
+ case scRData:
+ case scCommon:
+ case scSCommon:
+ case scInit:
+ case scFini:
+ case scRConst:
+ def = true;
+ break;
+ default:
+ def = false;
+ break;
+ }
+
+ if (! def)
+ continue;
+
+ name = ssext + esym.asym.iss;
+ h = bfd_link_hash_lookup (info->hash, name, false, false, true);
+
+ /* Unlike the generic linker, we do not pull in elements because
+ of common symbols. */
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || h->type != bfd_link_hash_undefined)
+ continue;
+
+ /* Include this element. */
+ if (! (*info->callbacks->add_archive_element) (info, abfd, name))
+ goto error_return;
+ if (! ecoff_link_add_externals (abfd, info, external_ext, ssext))
+ goto error_return;
+
+ *pneeded = true;
+ goto successful_return;
+ }
+
+ successful_return:
+ if (external_ext != NULL)
+ free (external_ext);
+ if (ssext != NULL)
+ free (ssext);
+ return true;
+ error_return:
+ if (external_ext != NULL)
+ free (external_ext);
+ if (ssext != NULL)
+ free (ssext);
+ return false;
+}
+
+/* Add symbols from an ECOFF object file to the global linker hash
+ table. */
+
+static boolean
+ecoff_link_add_object_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ HDRR *symhdr;
+ bfd_size_type external_ext_size;
+ PTR external_ext = NULL;
+ size_t esize;
+ char *ssext = NULL;
+ boolean result;
+
+ if (! ecoff_slurp_symbolic_header (abfd))
+ return false;
+
+ /* If there are no symbols, we don't want it. */
+ if (bfd_get_symcount (abfd) == 0)
+ return true;
+
+ symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
+
+ /* Read in the external symbols and external strings. */
+ external_ext_size = ecoff_backend (abfd)->debug_swap.external_ext_size;
+ esize = symhdr->iextMax * external_ext_size;
+ external_ext = (PTR) bfd_malloc (esize);
+ if (external_ext == NULL && esize != 0)
+ goto error_return;
+
+ if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
+ || bfd_read (external_ext, 1, esize, abfd) != esize)
+ goto error_return;
+
+ ssext = (char *) bfd_malloc (symhdr->issExtMax);
+ if (ssext == NULL && symhdr->issExtMax != 0)
+ goto error_return;
+
+ if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
+ || (bfd_read (ssext, 1, symhdr->issExtMax, abfd)
+ != (bfd_size_type) symhdr->issExtMax))
+ goto error_return;
+
+ result = ecoff_link_add_externals (abfd, info, external_ext, ssext);
+
+ if (ssext != NULL)
+ free (ssext);
+ if (external_ext != NULL)
+ free (external_ext);
+ return result;
+
+ error_return:
+ if (ssext != NULL)
+ free (ssext);
+ if (external_ext != NULL)
+ free (external_ext);
+ return false;
+}
+
+/* Add the external symbols of an object file to the global linker
+ hash table. The external symbols and strings we are passed are
+ just allocated on the stack, and will be discarded. We must
+ explicitly save any information we may need later on in the link.
+ We do not want to read the external symbol information again. */
+
+static boolean
+ecoff_link_add_externals (abfd, info, external_ext, ssext)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ PTR external_ext;
+ char *ssext;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
+ = backend->debug_swap.swap_ext_in;
+ bfd_size_type external_ext_size = backend->debug_swap.external_ext_size;
+ unsigned long ext_count;
+ struct ecoff_link_hash_entry **sym_hash;
+ char *ext_ptr;
+ char *ext_end;
+
+ ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
+
+ sym_hash = ((struct ecoff_link_hash_entry **)
+ bfd_alloc (abfd,
+ ext_count * sizeof (struct bfd_link_hash_entry *)));
+ if (!sym_hash)
+ return false;
+ ecoff_data (abfd)->sym_hashes = sym_hash;
+
+ ext_ptr = (char *) external_ext;
+ ext_end = ext_ptr + ext_count * external_ext_size;
+ for (; ext_ptr < ext_end; ext_ptr += external_ext_size, sym_hash++)
+ {
+ EXTR esym;
+ boolean skip;
+ bfd_vma value;
+ asection *section;
+ const char *name;
+ struct ecoff_link_hash_entry *h;
+
+ *sym_hash = NULL;
+
+ (*swap_ext_in) (abfd, (PTR) ext_ptr, &esym);
+
+ /* Skip debugging symbols. */
+ skip = false;
+ switch (esym.asym.st)
+ {
+ case stGlobal:
+ case stStatic:
+ case stLabel:
+ case stProc:
+ case stStaticProc:
+ break;
+ default:
+ skip = true;
+ break;
+ }
+
+ if (skip)
+ continue;
+
+ /* Get the information for this symbol. */
+ value = esym.asym.value;
+ switch (esym.asym.sc)
+ {
+ default:
+ case scNil:
+ case scRegister:
+ case scCdbLocal:
+ case scBits:
+ case scCdbSystem:
+ case scRegImage:
+ case scInfo:
+ case scUserStruct:
+ case scVar:
+ case scVarRegister:
+ case scVariant:
+ case scBasedVar:
+ case scXData:
+ case scPData:
+ section = NULL;
+ break;
+ case scText:
+ section = bfd_make_section_old_way (abfd, ".text");
+ value -= section->vma;
+ break;
+ case scData:
+ section = bfd_make_section_old_way (abfd, ".data");
+ value -= section->vma;
+ break;
+ case scBss:
+ section = bfd_make_section_old_way (abfd, ".bss");
+ value -= section->vma;
+ break;
+ case scAbs:
+ section = bfd_abs_section_ptr;
+ break;
+ case scUndefined:
+ section = bfd_und_section_ptr;
+ break;
+ case scSData:
+ section = bfd_make_section_old_way (abfd, ".sdata");
+ value -= section->vma;
+ break;
+ case scSBss:
+ section = bfd_make_section_old_way (abfd, ".sbss");
+ value -= section->vma;
+ break;
+ case scRData:
+ section = bfd_make_section_old_way (abfd, ".rdata");
+ value -= section->vma;
+ break;
+ case scCommon:
+ if (value > ecoff_data (abfd)->gp_size)
+ {
+ section = bfd_com_section_ptr;
+ break;
+ }
+ /* Fall through. */
+ case scSCommon:
+ if (ecoff_scom_section.name == NULL)
+ {
+ /* Initialize the small common section. */
+ ecoff_scom_section.name = SCOMMON;
+ ecoff_scom_section.flags = SEC_IS_COMMON;
+ ecoff_scom_section.output_section = &ecoff_scom_section;
+ ecoff_scom_section.symbol = &ecoff_scom_symbol;
+ ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
+ ecoff_scom_symbol.name = SCOMMON;
+ ecoff_scom_symbol.flags = BSF_SECTION_SYM;
+ ecoff_scom_symbol.section = &ecoff_scom_section;
+ ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
+ }
+ section = &ecoff_scom_section;
+ break;
+ case scSUndefined:
+ section = bfd_und_section_ptr;
+ break;
+ case scInit:
+ section = bfd_make_section_old_way (abfd, ".init");
+ value -= section->vma;
+ break;
+ case scFini:
+ section = bfd_make_section_old_way (abfd, ".fini");
+ value -= section->vma;
+ break;
+ case scRConst:
+ section = bfd_make_section_old_way (abfd, ".rconst");
+ value -= section->vma;
+ break;
+ }
+
+ if (section == (asection *) NULL)
+ continue;
+
+ name = ssext + esym.asym.iss;
+
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, name,
+ esym.weakext ? BSF_WEAK : BSF_GLOBAL,
+ section, value, (const char *) NULL, true, true,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+
+ *sym_hash = h;
+
+ /* If we are building an ECOFF hash table, save the external
+ symbol information. */
+ if (info->hash->creator->flavour == bfd_get_flavour (abfd))
+ {
+ if (h->abfd == (bfd *) NULL
+ || (! bfd_is_und_section (section)
+ && (! bfd_is_com_section (section)
+ || (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak))))
+ {
+ h->abfd = abfd;
+ h->esym = esym;
+ }
+
+ /* Remember whether this symbol was small undefined. */
+ if (esym.asym.sc == scSUndefined)
+ h->small = 1;
+
+ /* If this symbol was ever small undefined, it needs to wind
+ up in a GP relative section. We can't control the
+ section of a defined symbol, but we can control the
+ section of a common symbol. This case is actually needed
+ on Ultrix 4.2 to handle the symbol cred in -lckrb. */
+ if (h->small
+ && h->root.type == bfd_link_hash_common
+ && strcmp (h->root.u.c.p->section->name, SCOMMON) != 0)
+ {
+ h->root.u.c.p->section = bfd_make_section_old_way (abfd,
+ SCOMMON);
+ h->root.u.c.p->section->flags = SEC_ALLOC;
+ if (h->esym.asym.sc == scCommon)
+ h->esym.asym.sc = scSCommon;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* ECOFF final link routines. */
+
+static boolean ecoff_final_link_debug_accumulate
+ PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
+ PTR handle));
+static boolean ecoff_link_write_external
+ PARAMS ((struct ecoff_link_hash_entry *, PTR));
+static boolean ecoff_indirect_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+static boolean ecoff_reloc_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* Structure used to pass information to ecoff_link_write_external. */
+
+struct extsym_info
+{
+ bfd *abfd;
+ struct bfd_link_info *info;
+};
+
+/* ECOFF final link routine. This looks through all the input BFDs
+ and gathers together all the debugging information, and then
+ processes all the link order information. This may cause it to
+ close and reopen some input BFDs; I'll see how bad this is. */
+
+boolean
+_bfd_ecoff_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
+ struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
+ HDRR *symhdr;
+ PTR handle;
+ register bfd *input_bfd;
+ asection *o;
+ struct bfd_link_order *p;
+ struct extsym_info einfo;
+
+ /* We accumulate the debugging information counts in the symbolic
+ header. */
+ symhdr = &debug->symbolic_header;
+ symhdr->vstamp = 0;
+ symhdr->ilineMax = 0;
+ symhdr->cbLine = 0;
+ symhdr->idnMax = 0;
+ symhdr->ipdMax = 0;
+ symhdr->isymMax = 0;
+ symhdr->ioptMax = 0;
+ symhdr->iauxMax = 0;
+ symhdr->issMax = 0;
+ symhdr->issExtMax = 0;
+ symhdr->ifdMax = 0;
+ symhdr->crfd = 0;
+ symhdr->iextMax = 0;
+
+ /* We accumulate the debugging information itself in the debug_info
+ structure. */
+ debug->line = NULL;
+ debug->external_dnr = NULL;
+ debug->external_pdr = NULL;
+ debug->external_sym = NULL;
+ debug->external_opt = NULL;
+ debug->external_aux = NULL;
+ debug->ss = NULL;
+ debug->ssext = debug->ssext_end = NULL;
+ debug->external_fdr = NULL;
+ debug->external_rfd = NULL;
+ debug->external_ext = debug->external_ext_end = NULL;
+
+ handle = bfd_ecoff_debug_init (abfd, debug, &backend->debug_swap, info);
+ if (handle == (PTR) NULL)
+ return false;
+
+ /* Accumulate the debugging symbols from each input BFD. */
+ for (input_bfd = info->input_bfds;
+ input_bfd != (bfd *) NULL;
+ input_bfd = input_bfd->link_next)
+ {
+ boolean ret;
+
+ if (bfd_get_flavour (input_bfd) == bfd_target_ecoff_flavour)
+ {
+ /* Abitrarily set the symbolic header vstamp to the vstamp
+ of the first object file in the link. */
+ if (symhdr->vstamp == 0)
+ symhdr->vstamp
+ = ecoff_data (input_bfd)->debug_info.symbolic_header.vstamp;
+ ret = ecoff_final_link_debug_accumulate (abfd, input_bfd, info,
+ handle);
+ }
+ else
+ ret = bfd_ecoff_debug_accumulate_other (handle, abfd,
+ debug, &backend->debug_swap,
+ input_bfd, info);
+ if (! ret)
+ return false;
+
+ /* Combine the register masks. */
+ ecoff_data (abfd)->gprmask |= ecoff_data (input_bfd)->gprmask;
+ ecoff_data (abfd)->fprmask |= ecoff_data (input_bfd)->fprmask;
+ ecoff_data (abfd)->cprmask[0] |= ecoff_data (input_bfd)->cprmask[0];
+ ecoff_data (abfd)->cprmask[1] |= ecoff_data (input_bfd)->cprmask[1];
+ ecoff_data (abfd)->cprmask[2] |= ecoff_data (input_bfd)->cprmask[2];
+ ecoff_data (abfd)->cprmask[3] |= ecoff_data (input_bfd)->cprmask[3];
+ }
+
+ /* Write out the external symbols. */
+ einfo.abfd = abfd;
+ einfo.info = info;
+ ecoff_link_hash_traverse (ecoff_hash_table (info),
+ ecoff_link_write_external,
+ (PTR) &einfo);
+
+ if (info->relocateable)
+ {
+ /* We need to make a pass over the link_orders to count up the
+ number of relocations we will need to output, so that we know
+ how much space they will take up. */
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ o->reloc_count = 0;
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ if (p->type == bfd_indirect_link_order)
+ o->reloc_count += p->u.indirect.section->reloc_count;
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ ++o->reloc_count;
+ }
+ }
+
+ /* Compute the reloc and symbol file positions. */
+ ecoff_compute_reloc_file_positions (abfd);
+
+ /* Write out the debugging information. */
+ if (! bfd_ecoff_write_accumulated_debug (handle, abfd, debug,
+ &backend->debug_swap, info,
+ ecoff_data (abfd)->sym_filepos))
+ return false;
+
+ bfd_ecoff_debug_free (handle, abfd, debug, &backend->debug_swap, info);
+
+ if (info->relocateable)
+ {
+ /* Now reset the reloc_count field of the sections in the output
+ BFD to 0, so that we can use them to keep track of how many
+ relocs we have output thus far. */
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ o->reloc_count = 0;
+ }
+
+ /* Get a value for the GP register. */
+ if (ecoff_data (abfd)->gp == 0)
+ {
+ struct bfd_link_hash_entry *h;
+
+ h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_defined)
+ ecoff_data (abfd)->gp = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+ else if (info->relocateable)
+ {
+ bfd_vma lo;
+
+ /* Make up a value. */
+ lo = (bfd_vma) -1;
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ if (o->vma < lo
+ && (strcmp (o->name, _SBSS) == 0
+ || strcmp (o->name, _SDATA) == 0
+ || strcmp (o->name, _LIT4) == 0
+ || strcmp (o->name, _LIT8) == 0
+ || strcmp (o->name, _LITA) == 0))
+ lo = o->vma;
+ }
+ ecoff_data (abfd)->gp = lo + 0x8000;
+ }
+ else
+ {
+ /* If the relocate_section function needs to do a reloc
+ involving the GP value, it should make a reloc_dangerous
+ callback to warn that GP is not defined. */
+ }
+ }
+
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order
+ && (bfd_get_flavour (p->u.indirect.section->owner)
+ == bfd_target_ecoff_flavour))
+ {
+ if (! ecoff_indirect_link_order (abfd, info, o, p))
+ return false;
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ if (! ecoff_reloc_link_order (abfd, info, o, p))
+ return false;
+ }
+ else
+ {
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ return false;
+ }
+ }
+ }
+
+ bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax;
+
+ ecoff_data (abfd)->linker = true;
+
+ return true;
+}
+
+/* Accumulate the debugging information for an input BFD into the
+ output BFD. This must read in the symbolic information of the
+ input BFD. */
+
+static boolean
+ecoff_final_link_debug_accumulate (output_bfd, input_bfd, info, handle)
+ bfd *output_bfd;
+ bfd *input_bfd;
+ struct bfd_link_info *info;
+ PTR handle;
+{
+ struct ecoff_debug_info * const debug = &ecoff_data (input_bfd)->debug_info;
+ const struct ecoff_debug_swap * const swap =
+ &ecoff_backend (input_bfd)->debug_swap;
+ HDRR *symhdr = &debug->symbolic_header;
+ boolean ret;
+
+#define READ(ptr, offset, count, size, type) \
+ if (symhdr->count == 0) \
+ debug->ptr = NULL; \
+ else \
+ { \
+ debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
+ if (debug->ptr == NULL) \
+ { \
+ ret = false; \
+ goto return_something; \
+ } \
+ if ((bfd_seek (input_bfd, (file_ptr) symhdr->offset, SEEK_SET) \
+ != 0) \
+ || (bfd_read (debug->ptr, size, symhdr->count, \
+ input_bfd) != size * symhdr->count)) \
+ { \
+ ret = false; \
+ goto return_something; \
+ } \
+ }
+
+ /* If raw_syments is not NULL, then the data was already by read by
+ _bfd_ecoff_slurp_symbolic_info. */
+ if (ecoff_data (input_bfd)->raw_syments == NULL)
+ {
+ READ (line, cbLineOffset, cbLine, sizeof (unsigned char),
+ unsigned char *);
+ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
+ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
+ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
+ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
+ READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
+ union aux_ext *);
+ READ (ss, cbSsOffset, issMax, sizeof (char), char *);
+ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
+ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
+ }
+#undef READ
+
+ /* We do not read the external strings or the external symbols. */
+
+ ret = (bfd_ecoff_debug_accumulate
+ (handle, output_bfd, &ecoff_data (output_bfd)->debug_info,
+ &ecoff_backend (output_bfd)->debug_swap,
+ input_bfd, debug, swap, info));
+
+ return_something:
+ if (ecoff_data (input_bfd)->raw_syments == NULL)
+ {
+ if (debug->line != NULL)
+ free (debug->line);
+ if (debug->external_dnr != NULL)
+ free (debug->external_dnr);
+ if (debug->external_pdr != NULL)
+ free (debug->external_pdr);
+ if (debug->external_sym != NULL)
+ free (debug->external_sym);
+ if (debug->external_opt != NULL)
+ free (debug->external_opt);
+ if (debug->external_aux != NULL)
+ free (debug->external_aux);
+ if (debug->ss != NULL)
+ free (debug->ss);
+ if (debug->external_fdr != NULL)
+ free (debug->external_fdr);
+ if (debug->external_rfd != NULL)
+ free (debug->external_rfd);
+
+ /* Make sure we don't accidentally follow one of these pointers
+ into freed memory. */
+ debug->line = NULL;
+ debug->external_dnr = NULL;
+ debug->external_pdr = NULL;
+ debug->external_sym = NULL;
+ debug->external_opt = NULL;
+ debug->external_aux = NULL;
+ debug->ss = NULL;
+ debug->external_fdr = NULL;
+ debug->external_rfd = NULL;
+ }
+
+ return ret;
+}
+
+/* Put out information for an external symbol. These come only from
+ the hash table. */
+
+static boolean
+ecoff_link_write_external (h, data)
+ struct ecoff_link_hash_entry *h;
+ PTR data;
+{
+ struct extsym_info *einfo = (struct extsym_info *) data;
+ bfd *output_bfd = einfo->abfd;
+ boolean strip;
+
+ /* We need to check if this symbol is being stripped. */
+ if (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ strip = false;
+ else if (einfo->info->strip == strip_all
+ || (einfo->info->strip == strip_some
+ && bfd_hash_lookup (einfo->info->keep_hash,
+ h->root.root.string,
+ false, false) == NULL))
+ strip = true;
+ else
+ strip = false;
+
+ if (strip || h->written)
+ return true;
+
+ if (h->abfd == (bfd *) NULL)
+ {
+ h->esym.jmptbl = 0;
+ h->esym.cobol_main = 0;
+ h->esym.weakext = 0;
+ h->esym.reserved = 0;
+ h->esym.ifd = ifdNil;
+ h->esym.asym.value = 0;
+ h->esym.asym.st = stGlobal;
+
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ h->esym.asym.sc = scAbs;
+ else
+ {
+ asection *output_section;
+ const char *name;
+
+ output_section = h->root.u.def.section->output_section;
+ name = bfd_section_name (output_section->owner, output_section);
+
+ if (strcmp (name, _TEXT) == 0)
+ h->esym.asym.sc = scText;
+ else if (strcmp (name, _DATA) == 0)
+ h->esym.asym.sc = scData;
+ else if (strcmp (name, _SDATA) == 0)
+ h->esym.asym.sc = scSData;
+ else if (strcmp (name, _RDATA) == 0)
+ h->esym.asym.sc = scRData;
+ else if (strcmp (name, _BSS) == 0)
+ h->esym.asym.sc = scBss;
+ else if (strcmp (name, _SBSS) == 0)
+ h->esym.asym.sc = scSBss;
+ else if (strcmp (name, _INIT) == 0)
+ h->esym.asym.sc = scInit;
+ else if (strcmp (name, _FINI) == 0)
+ h->esym.asym.sc = scFini;
+ else if (strcmp (name, _PDATA) == 0)
+ h->esym.asym.sc = scPData;
+ else if (strcmp (name, _XDATA) == 0)
+ h->esym.asym.sc = scXData;
+ else if (strcmp (name, _RCONST) == 0)
+ h->esym.asym.sc = scRConst;
+ else
+ h->esym.asym.sc = scAbs;
+ }
+
+ h->esym.asym.reserved = 0;
+ h->esym.asym.index = indexNil;
+ }
+ else if (h->esym.ifd != -1)
+ {
+ struct ecoff_debug_info *debug;
+
+ /* Adjust the FDR index for the symbol by that used for the
+ input BFD. */
+ debug = &ecoff_data (h->abfd)->debug_info;
+ BFD_ASSERT (h->esym.ifd >= 0
+ && h->esym.ifd < debug->symbolic_header.ifdMax);
+ h->esym.ifd = debug->ifdmap[h->esym.ifd];
+ }
+
+ switch (h->root.type)
+ {
+ default:
+ case bfd_link_hash_new:
+ abort ();
+ case bfd_link_hash_undefined:
+ case bfd_link_hash_undefweak:
+ if (h->esym.asym.sc != scUndefined
+ && h->esym.asym.sc != scSUndefined)
+ h->esym.asym.sc = scUndefined;
+ break;
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ if (h->esym.asym.sc == scUndefined
+ || h->esym.asym.sc == scSUndefined)
+ h->esym.asym.sc = scAbs;
+ else if (h->esym.asym.sc == scCommon)
+ h->esym.asym.sc = scBss;
+ else if (h->esym.asym.sc == scSCommon)
+ h->esym.asym.sc = scSBss;
+ h->esym.asym.value = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ break;
+ case bfd_link_hash_common:
+ if (h->esym.asym.sc != scCommon
+ && h->esym.asym.sc != scSCommon)
+ h->esym.asym.sc = scCommon;
+ h->esym.asym.value = h->root.u.c.size;
+ break;
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+ /* FIXME: Ignore these for now. The circumstances under which
+ they should be written out are not clear to me. */
+ return true;
+ }
+
+ /* bfd_ecoff_debug_one_external uses iextMax to keep track of the
+ symbol number. */
+ h->indx = ecoff_data (output_bfd)->debug_info.symbolic_header.iextMax;
+ h->written = 1;
+
+ return (bfd_ecoff_debug_one_external
+ (output_bfd, &ecoff_data (output_bfd)->debug_info,
+ &ecoff_backend (output_bfd)->debug_swap, h->root.root.string,
+ &h->esym));
+}
+
+/* Relocate and write an ECOFF section into an ECOFF output file. */
+
+static boolean
+ecoff_indirect_link_order (output_bfd, info, output_section, link_order)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ asection *output_section;
+ struct bfd_link_order *link_order;
+{
+ asection *input_section;
+ bfd *input_bfd;
+ struct ecoff_section_tdata *section_tdata;
+ bfd_size_type raw_size;
+ bfd_size_type cooked_size;
+ bfd_byte *contents = NULL;
+ bfd_size_type external_reloc_size;
+ bfd_size_type external_relocs_size;
+ PTR external_relocs = NULL;
+
+ BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
+
+ if (link_order->size == 0)
+ return true;
+
+ input_section = link_order->u.indirect.section;
+ input_bfd = input_section->owner;
+ section_tdata = ecoff_section_data (input_bfd, input_section);
+
+ raw_size = input_section->_raw_size;
+ cooked_size = input_section->_cooked_size;
+ if (cooked_size == 0)
+ cooked_size = raw_size;
+
+ BFD_ASSERT (input_section->output_section == output_section);
+ BFD_ASSERT (input_section->output_offset == link_order->offset);
+ BFD_ASSERT (cooked_size == link_order->size);
+
+ /* Get the section contents. We allocate memory for the larger of
+ the size before relocating and the size after relocating. */
+ contents = (bfd_byte *) bfd_malloc (raw_size >= cooked_size
+ ? (size_t) raw_size
+ : (size_t) cooked_size);
+ if (contents == NULL && raw_size != 0)
+ goto error_return;
+
+ /* If we are relaxing, the contents may have already been read into
+ memory, in which case we copy them into our new buffer. We don't
+ simply reuse the old buffer in case cooked_size > raw_size. */
+ if (section_tdata != (struct ecoff_section_tdata *) NULL
+ && section_tdata->contents != (bfd_byte *) NULL)
+ memcpy (contents, section_tdata->contents, (size_t) raw_size);
+ else
+ {
+ if (! bfd_get_section_contents (input_bfd, input_section,
+ (PTR) contents,
+ (file_ptr) 0, raw_size))
+ goto error_return;
+ }
+
+ /* Get the relocs. If we are relaxing MIPS code, they will already
+ have been read in. Otherwise, we read them in now. */
+ external_reloc_size = ecoff_backend (input_bfd)->external_reloc_size;
+ external_relocs_size = external_reloc_size * input_section->reloc_count;
+
+ if (section_tdata != (struct ecoff_section_tdata *) NULL
+ && section_tdata->external_relocs != NULL)
+ external_relocs = section_tdata->external_relocs;
+ else
+ {
+ external_relocs = (PTR) bfd_malloc ((size_t) external_relocs_size);
+ if (external_relocs == NULL && external_relocs_size != 0)
+ goto error_return;
+
+ if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
+ || (bfd_read (external_relocs, 1, external_relocs_size, input_bfd)
+ != external_relocs_size))
+ goto error_return;
+ }
+
+ /* Relocate the section contents. */
+ if (! ((*ecoff_backend (input_bfd)->relocate_section)
+ (output_bfd, info, input_bfd, input_section, contents,
+ external_relocs)))
+ goto error_return;
+
+ /* Write out the relocated section. */
+ if (! bfd_set_section_contents (output_bfd,
+ output_section,
+ (PTR) contents,
+ input_section->output_offset,
+ cooked_size))
+ goto error_return;
+
+ /* If we are producing relocateable output, the relocs were
+ modified, and we write them out now. We use the reloc_count
+ field of output_section to keep track of the number of relocs we
+ have output so far. */
+ if (info->relocateable)
+ {
+ if (bfd_seek (output_bfd,
+ (output_section->rel_filepos +
+ output_section->reloc_count * external_reloc_size),
+ SEEK_SET) != 0
+ || (bfd_write (external_relocs, 1, external_relocs_size, output_bfd)
+ != external_relocs_size))
+ goto error_return;
+ output_section->reloc_count += input_section->reloc_count;
+ }
+
+ if (contents != NULL)
+ free (contents);
+ if (external_relocs != NULL && section_tdata == NULL)
+ free (external_relocs);
+ return true;
+
+ error_return:
+ if (contents != NULL)
+ free (contents);
+ if (external_relocs != NULL && section_tdata == NULL)
+ free (external_relocs);
+ return false;
+}
+
+/* Generate a reloc when linking an ECOFF file. This is a reloc
+ requested by the linker, and does come from any input file. This
+ is used to build constructor and destructor tables when linking
+ with -Ur. */
+
+static boolean
+ecoff_reloc_link_order (output_bfd, info, output_section, link_order)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ asection *output_section;
+ struct bfd_link_order *link_order;
+{
+ enum bfd_link_order_type type;
+ asection *section;
+ bfd_vma addend;
+ arelent rel;
+ struct internal_reloc in;
+ bfd_size_type external_reloc_size;
+ bfd_byte *rbuf;
+ boolean ok;
+
+ type = link_order->type;
+ section = NULL;
+ addend = link_order->u.reloc.p->addend;
+
+ /* We set up an arelent to pass to the backend adjust_reloc_out
+ routine. */
+ rel.address = link_order->offset;
+
+ rel.howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
+ if (rel.howto == 0)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (type == bfd_section_reloc_link_order)
+ {
+ section = link_order->u.reloc.p->u.section;
+ rel.sym_ptr_ptr = section->symbol_ptr_ptr;
+ }
+ else
+ {
+ struct bfd_link_hash_entry *h;
+
+ /* Treat a reloc against a defined symbol as though it were
+ actually against the section. */
+ h = bfd_wrapped_link_hash_lookup (output_bfd, info,
+ link_order->u.reloc.p->u.name,
+ false, false, false);
+ if (h != NULL
+ && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak))
+ {
+ type = bfd_section_reloc_link_order;
+ section = h->u.def.section->output_section;
+ /* It seems that we ought to add the symbol value to the
+ addend here, but in practice it has already been added
+ because it was passed to constructor_callback. */
+ addend += section->vma + h->u.def.section->output_offset;
+ }
+ else
+ {
+ /* We can't set up a reloc against a symbol correctly,
+ because we have no asymbol structure. Currently no
+ adjust_reloc_out routine cares. */
+ rel.sym_ptr_ptr = (asymbol **) NULL;
+ }
+ }
+
+ /* All ECOFF relocs are in-place. Put the addend into the object
+ file. */
+
+ BFD_ASSERT (rel.howto->partial_inplace);
+ if (addend != 0)
+ {
+ bfd_size_type size;
+ bfd_reloc_status_type rstat;
+ bfd_byte *buf;
+ boolean ok;
+
+ size = bfd_get_reloc_size (rel.howto);
+ buf = (bfd_byte *) bfd_zmalloc (size);
+ if (buf == (bfd_byte *) NULL)
+ return false;
+ rstat = _bfd_relocate_contents (rel.howto, output_bfd, addend, buf);
+ switch (rstat)
+ {
+ case bfd_reloc_ok:
+ break;
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info,
+ (link_order->type == bfd_section_reloc_link_order
+ ? bfd_section_name (output_bfd, section)
+ : link_order->u.reloc.p->u.name),
+ rel.howto->name, addend, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ {
+ free (buf);
+ return false;
+ }
+ break;
+ }
+ ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
+ (file_ptr) link_order->offset, size);
+ free (buf);
+ if (! ok)
+ return false;
+ }
+
+ rel.addend = 0;
+
+ /* Move the information into a internal_reloc structure. */
+ in.r_vaddr = (rel.address
+ + bfd_get_section_vma (output_bfd, output_section));
+ in.r_type = rel.howto->type;
+
+ if (type == bfd_symbol_reloc_link_order)
+ {
+ struct ecoff_link_hash_entry *h;
+
+ h = ((struct ecoff_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (output_bfd, info,
+ link_order->u.reloc.p->u.name,
+ false, false, true));
+ if (h != (struct ecoff_link_hash_entry *) NULL
+ && h->indx != -1)
+ in.r_symndx = h->indx;
+ else
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, link_order->u.reloc.p->u.name, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ return false;
+ in.r_symndx = 0;
+ }
+ in.r_extern = 1;
+ }
+ else
+ {
+ CONST char *name;
+
+ name = bfd_get_section_name (output_bfd, section);
+ if (strcmp (name, ".text") == 0)
+ in.r_symndx = RELOC_SECTION_TEXT;
+ else if (strcmp (name, ".rdata") == 0)
+ in.r_symndx = RELOC_SECTION_RDATA;
+ else if (strcmp (name, ".data") == 0)
+ in.r_symndx = RELOC_SECTION_DATA;
+ else if (strcmp (name, ".sdata") == 0)
+ in.r_symndx = RELOC_SECTION_SDATA;
+ else if (strcmp (name, ".sbss") == 0)
+ in.r_symndx = RELOC_SECTION_SBSS;
+ else if (strcmp (name, ".bss") == 0)
+ in.r_symndx = RELOC_SECTION_BSS;
+ else if (strcmp (name, ".init") == 0)
+ in.r_symndx = RELOC_SECTION_INIT;
+ else if (strcmp (name, ".lit8") == 0)
+ in.r_symndx = RELOC_SECTION_LIT8;
+ else if (strcmp (name, ".lit4") == 0)
+ in.r_symndx = RELOC_SECTION_LIT4;
+ else if (strcmp (name, ".xdata") == 0)
+ in.r_symndx = RELOC_SECTION_XDATA;
+ else if (strcmp (name, ".pdata") == 0)
+ in.r_symndx = RELOC_SECTION_PDATA;
+ else if (strcmp (name, ".fini") == 0)
+ in.r_symndx = RELOC_SECTION_FINI;
+ else if (strcmp (name, ".lita") == 0)
+ in.r_symndx = RELOC_SECTION_LITA;
+ else if (strcmp (name, "*ABS*") == 0)
+ in.r_symndx = RELOC_SECTION_ABS;
+ else if (strcmp (name, ".rconst") == 0)
+ in.r_symndx = RELOC_SECTION_RCONST;
+ else
+ abort ();
+ in.r_extern = 0;
+ }
+
+ /* Let the BFD backend adjust the reloc. */
+ (*ecoff_backend (output_bfd)->adjust_reloc_out) (output_bfd, &rel, &in);
+
+ /* Get some memory and swap out the reloc. */
+ external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size;
+ rbuf = (bfd_byte *) bfd_malloc ((size_t) external_reloc_size);
+ if (rbuf == (bfd_byte *) NULL)
+ return false;
+
+ (*ecoff_backend (output_bfd)->swap_reloc_out) (output_bfd, &in, (PTR) rbuf);
+
+ ok = (bfd_seek (output_bfd,
+ (output_section->rel_filepos +
+ output_section->reloc_count * external_reloc_size),
+ SEEK_SET) == 0
+ && (bfd_write ((PTR) rbuf, 1, external_reloc_size, output_bfd)
+ == external_reloc_size));
+
+ if (ok)
+ ++output_section->reloc_count;
+
+ free (rbuf);
+
+ return ok;
+}
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
new file mode 100644
index 00000000000..a120a2be7c5
--- /dev/null
+++ b/bfd/ecofflink.c
@@ -0,0 +1,2499 @@
+/* Routines to link ECOFF debugging information.
+ Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "objalloc.h"
+#include "aout/stab_gnu.h"
+#include "coff/internal.h"
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/ecoff.h"
+#include "libcoff.h"
+#include "libecoff.h"
+
+static boolean ecoff_add_bytes PARAMS ((char **buf, char **bufend,
+ size_t need));
+static struct bfd_hash_entry *string_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
+ const char *));
+static void ecoff_align_debug PARAMS ((bfd *abfd,
+ struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap));
+static boolean ecoff_write_symhdr PARAMS ((bfd *, struct ecoff_debug_info *,
+ const struct ecoff_debug_swap *,
+ file_ptr where));
+static int cmp_fdrtab_entry PARAMS ((const PTR, const PTR));
+static boolean mk_fdrtab PARAMS ((bfd *,
+ struct ecoff_debug_info * const,
+ const struct ecoff_debug_swap * const,
+ struct ecoff_find_line *));
+static long fdrtab_lookup PARAMS ((struct ecoff_find_line *, bfd_vma));
+static boolean lookup_line
+ PARAMS ((bfd *, struct ecoff_debug_info * const,
+ const struct ecoff_debug_swap * const, struct ecoff_find_line *));
+
+/* Routines to swap auxiliary information in and out. I am assuming
+ that the auxiliary information format is always going to be target
+ independent. */
+
+/* Swap in a type information record.
+ BIGEND says whether AUX symbols are big-endian or little-endian; this
+ info comes from the file header record (fh-fBigendian). */
+
+void
+_bfd_ecoff_swap_tir_in (bigend, ext_copy, intern)
+ int bigend;
+ const struct tir_ext *ext_copy;
+ TIR *intern;
+{
+ struct tir_ext ext[1];
+
+ *ext = *ext_copy; /* Make it reasonable to do in-place. */
+
+ /* now the fun stuff... */
+ if (bigend) {
+ intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
+ intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
+ intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
+ >> TIR_BITS1_BT_SH_BIG;
+ intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
+ >> TIR_BITS_TQ4_SH_BIG;
+ intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
+ >> TIR_BITS_TQ5_SH_BIG;
+ intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
+ >> TIR_BITS_TQ0_SH_BIG;
+ intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
+ >> TIR_BITS_TQ1_SH_BIG;
+ intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
+ >> TIR_BITS_TQ2_SH_BIG;
+ intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
+ >> TIR_BITS_TQ3_SH_BIG;
+ } else {
+ intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
+ intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
+ intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
+ >> TIR_BITS1_BT_SH_LITTLE;
+ intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
+ >> TIR_BITS_TQ4_SH_LITTLE;
+ intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
+ >> TIR_BITS_TQ5_SH_LITTLE;
+ intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
+ >> TIR_BITS_TQ0_SH_LITTLE;
+ intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
+ >> TIR_BITS_TQ1_SH_LITTLE;
+ intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
+ >> TIR_BITS_TQ2_SH_LITTLE;
+ intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
+ >> TIR_BITS_TQ3_SH_LITTLE;
+ }
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out a type information record.
+ BIGEND says whether AUX symbols are big-endian or little-endian; this
+ info comes from the file header record (fh-fBigendian). */
+
+void
+_bfd_ecoff_swap_tir_out (bigend, intern_copy, ext)
+ int bigend;
+ const TIR *intern_copy;
+ struct tir_ext *ext;
+{
+ TIR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ /* now the fun stuff... */
+ if (bigend) {
+ ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
+ | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
+ | ((intern->bt << TIR_BITS1_BT_SH_BIG)
+ & TIR_BITS1_BT_BIG));
+ ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
+ & TIR_BITS_TQ4_BIG)
+ | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
+ & TIR_BITS_TQ5_BIG));
+ ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
+ & TIR_BITS_TQ0_BIG)
+ | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
+ & TIR_BITS_TQ1_BIG));
+ ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
+ & TIR_BITS_TQ2_BIG)
+ | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
+ & TIR_BITS_TQ3_BIG));
+ } else {
+ ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
+ | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
+ | ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
+ & TIR_BITS1_BT_LITTLE));
+ ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
+ & TIR_BITS_TQ4_LITTLE)
+ | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
+ & TIR_BITS_TQ5_LITTLE));
+ ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
+ & TIR_BITS_TQ0_LITTLE)
+ | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
+ & TIR_BITS_TQ1_LITTLE));
+ ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
+ & TIR_BITS_TQ2_LITTLE)
+ | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
+ & TIR_BITS_TQ3_LITTLE));
+ }
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap in a relative symbol record. BIGEND says whether it is in
+ big-endian or little-endian format.*/
+
+void
+_bfd_ecoff_swap_rndx_in (bigend, ext_copy, intern)
+ int bigend;
+ const struct rndx_ext *ext_copy;
+ RNDXR *intern;
+{
+ struct rndx_ext ext[1];
+
+ *ext = *ext_copy; /* Make it reasonable to do in-place. */
+
+ /* now the fun stuff... */
+ if (bigend) {
+ intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
+ | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
+ >> RNDX_BITS1_RFD_SH_BIG);
+ intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
+ << RNDX_BITS1_INDEX_SH_LEFT_BIG)
+ | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
+ | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
+ } else {
+ intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
+ | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
+ << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
+ intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
+ >> RNDX_BITS1_INDEX_SH_LITTLE)
+ | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
+ | ((unsigned int) ext->r_bits[3]
+ << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
+ }
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out a relative symbol record. BIGEND says whether it is in
+ big-endian or little-endian format.*/
+
+void
+_bfd_ecoff_swap_rndx_out (bigend, intern_copy, ext)
+ int bigend;
+ const RNDXR *intern_copy;
+ struct rndx_ext *ext;
+{
+ RNDXR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ /* now the fun stuff... */
+ if (bigend) {
+ ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
+ ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
+ & RNDX_BITS1_RFD_BIG)
+ | ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
+ & RNDX_BITS1_INDEX_BIG));
+ ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
+ ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
+ } else {
+ ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
+ ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
+ & RNDX_BITS1_RFD_LITTLE)
+ | ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
+ & RNDX_BITS1_INDEX_LITTLE));
+ ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
+ ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
+ }
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* The minimum amount of data to allocate. */
+#define ALLOC_SIZE (4064)
+
+/* Add bytes to a buffer. Return success. */
+
+static boolean
+ecoff_add_bytes (buf, bufend, need)
+ char **buf;
+ char **bufend;
+ size_t need;
+{
+ size_t have;
+ size_t want;
+ char *newbuf;
+
+ have = *bufend - *buf;
+ if (have > need)
+ want = ALLOC_SIZE;
+ else
+ {
+ want = need - have;
+ if (want < ALLOC_SIZE)
+ want = ALLOC_SIZE;
+ }
+ newbuf = (char *) bfd_realloc (*buf, have + want);
+ if (newbuf == NULL)
+ return false;
+ *buf = newbuf;
+ *bufend = *buf + have + want;
+ return true;
+}
+
+/* We keep a hash table which maps strings to numbers. We use it to
+ map FDR names to indices in the output file, and to map local
+ strings when combining stabs debugging information. */
+
+struct string_hash_entry
+{
+ struct bfd_hash_entry root;
+ /* FDR index or string table offset. */
+ long val;
+ /* Next entry in string table. */
+ struct string_hash_entry *next;
+};
+
+struct string_hash_table
+{
+ struct bfd_hash_table table;
+};
+
+/* Routine to create an entry in a string hash table. */
+
+static struct bfd_hash_entry *
+string_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct string_hash_entry *ret = (struct string_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct string_hash_entry *) NULL)
+ ret = ((struct string_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct string_hash_entry)));
+ if (ret == (struct string_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct string_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ ret->val = -1;
+ ret->next = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Look up an entry in an string hash table. */
+
+#define string_hash_lookup(t, string, create, copy) \
+ ((struct string_hash_entry *) \
+ bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
+
+/* We can't afford to read in all the debugging information when we do
+ a link. Instead, we build a list of these structures to show how
+ different parts of the input file map to the output file. */
+
+struct shuffle
+{
+ /* The next entry in this linked list. */
+ struct shuffle *next;
+ /* The length of the information. */
+ unsigned long size;
+ /* Whether this information comes from a file or not. */
+ boolean filep;
+ union
+ {
+ struct
+ {
+ /* The BFD the data comes from. */
+ bfd *input_bfd;
+ /* The offset within input_bfd. */
+ file_ptr offset;
+ } file;
+ /* The data to be written out. */
+ PTR memory;
+ } u;
+};
+
+/* This structure holds information across calls to
+ bfd_ecoff_debug_accumulate. */
+
+struct accumulate
+{
+ /* The FDR hash table. */
+ struct string_hash_table fdr_hash;
+ /* The strings hash table. */
+ struct string_hash_table str_hash;
+ /* Linked lists describing how to shuffle the input debug
+ information into the output file. We keep a pointer to both the
+ head and the tail. */
+ struct shuffle *line;
+ struct shuffle *line_end;
+ struct shuffle *pdr;
+ struct shuffle *pdr_end;
+ struct shuffle *sym;
+ struct shuffle *sym_end;
+ struct shuffle *opt;
+ struct shuffle *opt_end;
+ struct shuffle *aux;
+ struct shuffle *aux_end;
+ struct shuffle *ss;
+ struct shuffle *ss_end;
+ struct string_hash_entry *ss_hash;
+ struct string_hash_entry *ss_hash_end;
+ struct shuffle *fdr;
+ struct shuffle *fdr_end;
+ struct shuffle *rfd;
+ struct shuffle *rfd_end;
+ /* The size of the largest file shuffle. */
+ unsigned long largest_file_shuffle;
+ /* An objalloc for debugging information. */
+ struct objalloc *memory;
+};
+
+/* Add a file entry to a shuffle list. */
+
+static boolean add_file_shuffle PARAMS ((struct accumulate *,
+ struct shuffle **,
+ struct shuffle **, bfd *, file_ptr,
+ unsigned long));
+
+static boolean
+add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
+ struct accumulate *ainfo;
+ struct shuffle **head;
+ struct shuffle **tail;
+ bfd *input_bfd;
+ file_ptr offset;
+ unsigned long size;
+{
+ struct shuffle *n;
+
+ if (*tail != (struct shuffle *) NULL
+ && (*tail)->filep
+ && (*tail)->u.file.input_bfd == input_bfd
+ && (*tail)->u.file.offset + (*tail)->size == (unsigned long) offset)
+ {
+ /* Just merge this entry onto the existing one. */
+ (*tail)->size += size;
+ if ((*tail)->size > ainfo->largest_file_shuffle)
+ ainfo->largest_file_shuffle = (*tail)->size;
+ return true;
+ }
+
+ n = (struct shuffle *) objalloc_alloc (ainfo->memory,
+ sizeof (struct shuffle));
+ if (!n)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ n->next = NULL;
+ n->size = size;
+ n->filep = true;
+ n->u.file.input_bfd = input_bfd;
+ n->u.file.offset = offset;
+ if (*head == (struct shuffle *) NULL)
+ *head = n;
+ if (*tail != (struct shuffle *) NULL)
+ (*tail)->next = n;
+ *tail = n;
+ if (size > ainfo->largest_file_shuffle)
+ ainfo->largest_file_shuffle = size;
+ return true;
+}
+
+/* Add a memory entry to a shuffle list. */
+
+static boolean add_memory_shuffle PARAMS ((struct accumulate *,
+ struct shuffle **head,
+ struct shuffle **tail,
+ bfd_byte *data, unsigned long size));
+
+static boolean
+add_memory_shuffle (ainfo, head, tail, data, size)
+ struct accumulate *ainfo;
+ struct shuffle **head;
+ struct shuffle **tail;
+ bfd_byte *data;
+ unsigned long size;
+{
+ struct shuffle *n;
+
+ n = (struct shuffle *) objalloc_alloc (ainfo->memory,
+ sizeof (struct shuffle));
+ if (!n)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ n->next = NULL;
+ n->size = size;
+ n->filep = false;
+ n->u.memory = (PTR) data;
+ if (*head == (struct shuffle *) NULL)
+ *head = n;
+ if (*tail != (struct shuffle *) NULL)
+ (*tail)->next = n;
+ *tail = n;
+ return true;
+}
+
+/* Initialize the FDR hash table. This returns a handle which is then
+ passed in to bfd_ecoff_debug_accumulate, et. al. */
+
+/*ARGSUSED*/
+PTR
+bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
+ bfd *output_bfd;
+ struct ecoff_debug_info *output_debug;
+ const struct ecoff_debug_swap *output_swap;
+ struct bfd_link_info *info;
+{
+ struct accumulate *ainfo;
+
+ ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate));
+ if (!ainfo)
+ return NULL;
+ if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
+ 1021))
+ return NULL;
+
+ ainfo->line = NULL;
+ ainfo->line_end = NULL;
+ ainfo->pdr = NULL;
+ ainfo->pdr_end = NULL;
+ ainfo->sym = NULL;
+ ainfo->sym_end = NULL;
+ ainfo->opt = NULL;
+ ainfo->opt_end = NULL;
+ ainfo->aux = NULL;
+ ainfo->aux_end = NULL;
+ ainfo->ss = NULL;
+ ainfo->ss_end = NULL;
+ ainfo->ss_hash = NULL;
+ ainfo->ss_hash_end = NULL;
+ ainfo->fdr = NULL;
+ ainfo->fdr_end = NULL;
+ ainfo->rfd = NULL;
+ ainfo->rfd_end = NULL;
+
+ ainfo->largest_file_shuffle = 0;
+
+ if (! info->relocateable)
+ {
+ if (! bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc))
+ return NULL;
+
+ /* The first entry in the string table is the empty string. */
+ output_debug->symbolic_header.issMax = 1;
+ }
+
+ ainfo->memory = objalloc_create ();
+ if (ainfo->memory == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
+ return (PTR) ainfo;
+}
+
+/* Free the accumulated debugging information. */
+
+/*ARGSUSED*/
+void
+bfd_ecoff_debug_free (handle, output_bfd, output_debug, output_swap, info)
+ PTR handle;
+ bfd *output_bfd;
+ struct ecoff_debug_info *output_debug;
+ const struct ecoff_debug_swap *output_swap;
+ struct bfd_link_info *info;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+
+ bfd_hash_table_free (&ainfo->fdr_hash.table);
+
+ if (! info->relocateable)
+ bfd_hash_table_free (&ainfo->str_hash.table);
+
+ objalloc_free (ainfo->memory);
+
+ free (ainfo);
+}
+
+/* Accumulate the debugging information from INPUT_BFD into
+ OUTPUT_BFD. The INPUT_DEBUG argument points to some ECOFF
+ debugging information which we want to link into the information
+ pointed to by the OUTPUT_DEBUG argument. OUTPUT_SWAP and
+ INPUT_SWAP point to the swapping information needed. INFO is the
+ linker information structure. HANDLE is returned by
+ bfd_ecoff_debug_init. */
+
+/*ARGSUSED*/
+boolean
+bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
+ input_bfd, input_debug, input_swap,
+ info)
+ PTR handle;
+ bfd *output_bfd;
+ struct ecoff_debug_info *output_debug;
+ const struct ecoff_debug_swap *output_swap;
+ bfd *input_bfd;
+ struct ecoff_debug_info *input_debug;
+ const struct ecoff_debug_swap *input_swap;
+ struct bfd_link_info *info;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+ void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
+ = input_swap->swap_sym_in;
+ void (* const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *))
+ = input_swap->swap_rfd_in;
+ void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
+ = output_swap->swap_sym_out;
+ void (* const swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR))
+ = output_swap->swap_fdr_out;
+ void (* const swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR))
+ = output_swap->swap_rfd_out;
+ bfd_size_type external_pdr_size = output_swap->external_pdr_size;
+ bfd_size_type external_sym_size = output_swap->external_sym_size;
+ bfd_size_type external_opt_size = output_swap->external_opt_size;
+ bfd_size_type external_fdr_size = output_swap->external_fdr_size;
+ bfd_size_type external_rfd_size = output_swap->external_rfd_size;
+ HDRR * const output_symhdr = &output_debug->symbolic_header;
+ HDRR * const input_symhdr = &input_debug->symbolic_header;
+ bfd_vma section_adjust[scMax];
+ asection *sec;
+ bfd_byte *fdr_start;
+ bfd_byte *fdr_ptr;
+ bfd_byte *fdr_end;
+ bfd_size_type fdr_add;
+ unsigned int copied;
+ RFDT i;
+ unsigned long sz;
+ bfd_byte *rfd_out;
+ bfd_byte *rfd_in;
+ bfd_byte *rfd_end;
+ long newrfdbase = 0;
+ long oldrfdbase = 0;
+ bfd_byte *fdr_out;
+
+ /* Use section_adjust to hold the value to add to a symbol in a
+ particular section. */
+ memset ((PTR) section_adjust, 0, sizeof section_adjust);
+
+#define SET(name, indx) \
+ sec = bfd_get_section_by_name (input_bfd, name); \
+ if (sec != NULL) \
+ section_adjust[indx] = (sec->output_section->vma \
+ + sec->output_offset \
+ - sec->vma);
+
+ SET (".text", scText);
+ SET (".data", scData);
+ SET (".bss", scBss);
+ SET (".sdata", scSData);
+ SET (".sbss", scSBss);
+ /* scRdata section may be either .rdata or .rodata. */
+ SET (".rdata", scRData);
+ SET (".rodata", scRData);
+ SET (".init", scInit);
+ SET (".fini", scFini);
+ SET (".rconst", scRConst);
+
+#undef SET
+
+ /* Find all the debugging information based on the FDR's. We need
+ to handle them whether they are swapped or not. */
+ if (input_debug->fdr != (FDR *) NULL)
+ {
+ fdr_start = (bfd_byte *) input_debug->fdr;
+ fdr_add = sizeof (FDR);
+ }
+ else
+ {
+ fdr_start = (bfd_byte *) input_debug->external_fdr;
+ fdr_add = input_swap->external_fdr_size;
+ }
+ fdr_end = fdr_start + input_symhdr->ifdMax * fdr_add;
+
+ input_debug->ifdmap = (RFDT *) bfd_alloc (input_bfd,
+ (input_symhdr->ifdMax
+ * sizeof (RFDT)));
+
+ sz = (input_symhdr->crfd + input_symhdr->ifdMax) * external_rfd_size;
+ rfd_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz);
+ if (!input_debug->ifdmap || !rfd_out)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ if (!add_memory_shuffle (ainfo, &ainfo->rfd, &ainfo->rfd_end, rfd_out, sz))
+ return false;
+
+ copied = 0;
+
+ /* Look through the FDR's to see which ones we are going to include
+ in the final output. We do not want duplicate FDR information
+ for header files, because ECOFF debugging is often very large.
+ When we find an FDR with no line information which can be merged,
+ we look it up in a hash table to ensure that we only include it
+ once. We keep a table mapping FDR numbers to the final number
+ they get with the BFD, so that we can refer to it when we write
+ out the external symbols. */
+ for (fdr_ptr = fdr_start, i = 0;
+ fdr_ptr < fdr_end;
+ fdr_ptr += fdr_add, i++, rfd_out += external_rfd_size)
+ {
+ FDR fdr;
+
+ if (input_debug->fdr != (FDR *) NULL)
+ fdr = *(FDR *) fdr_ptr;
+ else
+ (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
+
+ /* See if this FDR can be merged with an existing one. */
+ if (fdr.cbLine == 0 && fdr.rss != -1 && fdr.fMerge)
+ {
+ const char *name;
+ char *lookup;
+ struct string_hash_entry *fh;
+
+ /* We look up a string formed from the file name and the
+ number of symbols and aux entries. Sometimes an include
+ file will conditionally define a typedef or something
+ based on the order of include files. Using the number of
+ symbols and aux entries as a hash reduces the chance that
+ we will merge symbol information that should not be
+ merged. */
+ name = input_debug->ss + fdr.issBase + fdr.rss;
+
+ lookup = (char *) bfd_malloc (strlen (name) + 20);
+ if (lookup == NULL)
+ return false;
+ sprintf (lookup, "%s %lx %lx", name, fdr.csym, fdr.caux);
+
+ fh = string_hash_lookup (&ainfo->fdr_hash, lookup, true, true);
+ free (lookup);
+ if (fh == (struct string_hash_entry *) NULL)
+ return false;
+
+ if (fh->val != -1)
+ {
+ input_debug->ifdmap[i] = fh->val;
+ (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i,
+ (PTR) rfd_out);
+
+ /* Don't copy this FDR. */
+ continue;
+ }
+
+ fh->val = output_symhdr->ifdMax + copied;
+ }
+
+ input_debug->ifdmap[i] = output_symhdr->ifdMax + copied;
+ (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i, (PTR) rfd_out);
+ ++copied;
+ }
+
+ newrfdbase = output_symhdr->crfd;
+ output_symhdr->crfd += input_symhdr->ifdMax;
+
+ /* Copy over any existing RFD's. RFD's are only created by the
+ linker, so this will only happen for input files which are the
+ result of a partial link. */
+ rfd_in = (bfd_byte *) input_debug->external_rfd;
+ rfd_end = rfd_in + input_symhdr->crfd * input_swap->external_rfd_size;
+ for (;
+ rfd_in < rfd_end;
+ rfd_in += input_swap->external_rfd_size)
+ {
+ RFDT rfd;
+
+ (*swap_rfd_in) (input_bfd, (PTR) rfd_in, &rfd);
+ BFD_ASSERT (rfd >= 0 && rfd < input_symhdr->ifdMax);
+ rfd = input_debug->ifdmap[rfd];
+ (*swap_rfd_out) (output_bfd, &rfd, (PTR) rfd_out);
+ rfd_out += external_rfd_size;
+ }
+
+ oldrfdbase = output_symhdr->crfd;
+ output_symhdr->crfd += input_symhdr->crfd;
+
+ /* Look through the FDR's and copy over all associated debugging
+ information. */
+ sz = copied * external_fdr_size;
+ fdr_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz);
+ if (!fdr_out)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ if (!add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end, fdr_out, sz))
+ return false;
+ for (fdr_ptr = fdr_start, i = 0;
+ fdr_ptr < fdr_end;
+ fdr_ptr += fdr_add, i++)
+ {
+ FDR fdr;
+ bfd_vma fdr_adr;
+ bfd_byte *sym_out;
+ bfd_byte *lraw_src;
+ bfd_byte *lraw_end;
+ boolean fgotfilename;
+
+ if (input_debug->ifdmap[i] < output_symhdr->ifdMax)
+ {
+ /* We are not copying this FDR. */
+ continue;
+ }
+
+ if (input_debug->fdr != (FDR *) NULL)
+ fdr = *(FDR *) fdr_ptr;
+ else
+ (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
+
+ fdr_adr = fdr.adr;
+
+ /* Adjust the FDR address for any changes that may have been
+ made by relaxing. */
+ if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
+ {
+ struct ecoff_value_adjust *adjust;
+
+ for (adjust = input_debug->adjust;
+ adjust != (struct ecoff_value_adjust *) NULL;
+ adjust = adjust->next)
+ if (fdr_adr >= adjust->start
+ && fdr_adr < adjust->end)
+ fdr.adr += adjust->adjust;
+ }
+
+ /* FIXME: It is conceivable that this FDR points to the .init or
+ .fini section, in which case this will not do the right
+ thing. */
+ fdr.adr += section_adjust[scText];
+
+ /* Swap in the local symbols, adjust their values, and swap them
+ out again. */
+ fgotfilename = false;
+ sz = fdr.csym * external_sym_size;
+ sym_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz);
+ if (!sym_out)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ if (!add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end, sym_out,
+ sz))
+ return false;
+ lraw_src = ((bfd_byte *) input_debug->external_sym
+ + fdr.isymBase * input_swap->external_sym_size);
+ lraw_end = lraw_src + fdr.csym * input_swap->external_sym_size;
+ for (; lraw_src < lraw_end; lraw_src += input_swap->external_sym_size)
+ {
+ SYMR internal_sym;
+
+ (*swap_sym_in) (input_bfd, (PTR) lraw_src, &internal_sym);
+
+ BFD_ASSERT (internal_sym.sc != scCommon
+ && internal_sym.sc != scSCommon);
+
+ /* Adjust the symbol value if appropriate. */
+ switch (internal_sym.st)
+ {
+ case stNil:
+ if (ECOFF_IS_STAB (&internal_sym))
+ break;
+ /* Fall through. */
+ case stGlobal:
+ case stStatic:
+ case stLabel:
+ case stProc:
+ case stStaticProc:
+ if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
+ {
+ bfd_vma value;
+ struct ecoff_value_adjust *adjust;
+
+ value = internal_sym.value;
+ for (adjust = input_debug->adjust;
+ adjust != (struct ecoff_value_adjust *) NULL;
+ adjust = adjust->next)
+ if (value >= adjust->start
+ && value < adjust->end)
+ internal_sym.value += adjust->adjust;
+ }
+ internal_sym.value += section_adjust[internal_sym.sc];
+ break;
+
+ default:
+ break;
+ }
+
+ /* If we are doing a final link, we hash all the strings in
+ the local symbol table together. This reduces the amount
+ of space required by debugging information. We don't do
+ this when performing a relocateable link because it would
+ prevent us from easily merging different FDR's. */
+ if (! info->relocateable)
+ {
+ boolean ffilename;
+ const char *name;
+
+ if (! fgotfilename && internal_sym.iss == fdr.rss)
+ ffilename = true;
+ else
+ ffilename = false;
+
+ /* Hash the name into the string table. */
+ name = input_debug->ss + fdr.issBase + internal_sym.iss;
+ if (*name == '\0')
+ internal_sym.iss = 0;
+ else
+ {
+ struct string_hash_entry *sh;
+
+ sh = string_hash_lookup (&ainfo->str_hash, name, true, true);
+ if (sh == (struct string_hash_entry *) NULL)
+ return false;
+ if (sh->val == -1)
+ {
+ sh->val = output_symhdr->issMax;
+ output_symhdr->issMax += strlen (name) + 1;
+ if (ainfo->ss_hash == (struct string_hash_entry *) NULL)
+ ainfo->ss_hash = sh;
+ if (ainfo->ss_hash_end
+ != (struct string_hash_entry *) NULL)
+ ainfo->ss_hash_end->next = sh;
+ ainfo->ss_hash_end = sh;
+ }
+ internal_sym.iss = sh->val;
+ }
+
+ if (ffilename)
+ {
+ fdr.rss = internal_sym.iss;
+ fgotfilename = true;
+ }
+ }
+
+ (*swap_sym_out) (output_bfd, &internal_sym, sym_out);
+ sym_out += external_sym_size;
+ }
+
+ fdr.isymBase = output_symhdr->isymMax;
+ output_symhdr->isymMax += fdr.csym;
+
+ /* Copy the information that does not need swapping. */
+
+ /* FIXME: If we are relaxing, we need to adjust the line
+ numbers. Frankly, forget it. Anybody using stabs debugging
+ information will not use this line number information, and
+ stabs are adjusted correctly. */
+ if (fdr.cbLine > 0)
+ {
+ if (!add_file_shuffle (ainfo, &ainfo->line, &ainfo->line_end,
+ input_bfd,
+ input_symhdr->cbLineOffset + fdr.cbLineOffset,
+ fdr.cbLine))
+ return false;
+ fdr.ilineBase = output_symhdr->ilineMax;
+ fdr.cbLineOffset = output_symhdr->cbLine;
+ output_symhdr->ilineMax += fdr.cline;
+ output_symhdr->cbLine += fdr.cbLine;
+ }
+ if (fdr.caux > 0)
+ {
+ if (!add_file_shuffle (ainfo, &ainfo->aux, &ainfo->aux_end,
+ input_bfd,
+ (input_symhdr->cbAuxOffset
+ + fdr.iauxBase * sizeof (union aux_ext)),
+ fdr.caux * sizeof (union aux_ext)))
+ return false;
+ fdr.iauxBase = output_symhdr->iauxMax;
+ output_symhdr->iauxMax += fdr.caux;
+ }
+ if (! info->relocateable)
+ {
+
+ /* When are are hashing strings, we lie about the number of
+ strings attached to each FDR. We need to set cbSs
+ because some versions of dbx apparently use it to decide
+ how much of the string table to read in. */
+ fdr.issBase = 0;
+ fdr.cbSs = output_symhdr->issMax;
+ }
+ else if (fdr.cbSs > 0)
+ {
+ if (!add_file_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end,
+ input_bfd,
+ input_symhdr->cbSsOffset + fdr.issBase,
+ fdr.cbSs))
+ return false;
+ fdr.issBase = output_symhdr->issMax;
+ output_symhdr->issMax += fdr.cbSs;
+ }
+
+ if ((output_bfd->xvec->header_byteorder
+ == input_bfd->xvec->header_byteorder)
+ && input_debug->adjust == (struct ecoff_value_adjust *) NULL)
+ {
+ /* The two BFD's have the same endianness, and we don't have
+ to adjust the PDR addresses, so simply copying the
+ information will suffice. */
+ BFD_ASSERT (external_pdr_size == input_swap->external_pdr_size);
+ if (fdr.cpd > 0)
+ {
+ if (!add_file_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end,
+ input_bfd,
+ (input_symhdr->cbPdOffset
+ + fdr.ipdFirst * external_pdr_size),
+ fdr.cpd * external_pdr_size))
+ return false;
+ }
+ BFD_ASSERT (external_opt_size == input_swap->external_opt_size);
+ if (fdr.copt > 0)
+ {
+ if (!add_file_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end,
+ input_bfd,
+ (input_symhdr->cbOptOffset
+ + fdr.ioptBase * external_opt_size),
+ fdr.copt * external_opt_size))
+ return false;
+ }
+ }
+ else
+ {
+ bfd_size_type outsz, insz;
+ bfd_byte *in;
+ bfd_byte *end;
+ bfd_byte *out;
+
+ /* The two BFD's have different endianness, so we must swap
+ everything in and out. This code would always work, but
+ it would be unnecessarily slow in the normal case. */
+ outsz = external_pdr_size;
+ insz = input_swap->external_pdr_size;
+ in = ((bfd_byte *) input_debug->external_pdr
+ + fdr.ipdFirst * insz);
+ end = in + fdr.cpd * insz;
+ sz = fdr.cpd * outsz;
+ out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz);
+ if (!out)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ if (!add_memory_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end, out,
+ sz))
+ return false;
+ for (; in < end; in += insz, out += outsz)
+ {
+ PDR pdr;
+
+ (*input_swap->swap_pdr_in) (input_bfd, (PTR) in, &pdr);
+
+ /* If we have been relaxing, we may have to adjust the
+ address. */
+ if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
+ {
+ bfd_vma adr;
+ struct ecoff_value_adjust *adjust;
+
+ adr = fdr_adr + pdr.adr;
+ for (adjust = input_debug->adjust;
+ adjust != (struct ecoff_value_adjust *) NULL;
+ adjust = adjust->next)
+ if (adr >= adjust->start
+ && adr < adjust->end)
+ pdr.adr += adjust->adjust;
+ }
+
+ (*output_swap->swap_pdr_out) (output_bfd, &pdr, (PTR) out);
+ }
+
+ /* Swap over the optimization information. */
+ outsz = external_opt_size;
+ insz = input_swap->external_opt_size;
+ in = ((bfd_byte *) input_debug->external_opt
+ + fdr.ioptBase * insz);
+ end = in + fdr.copt * insz;
+ sz = fdr.copt * outsz;
+ out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz);
+ if (!out)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ if (!add_memory_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end, out,
+ sz))
+ return false;
+ for (; in < end; in += insz, out += outsz)
+ {
+ OPTR opt;
+
+ (*input_swap->swap_opt_in) (input_bfd, (PTR) in, &opt);
+ (*output_swap->swap_opt_out) (output_bfd, &opt, (PTR) out);
+ }
+ }
+
+ fdr.ipdFirst = output_symhdr->ipdMax;
+ output_symhdr->ipdMax += fdr.cpd;
+ fdr.ioptBase = output_symhdr->ioptMax;
+ output_symhdr->ioptMax += fdr.copt;
+
+ if (fdr.crfd <= 0)
+ {
+ /* Point this FDR at the table of RFD's we created. */
+ fdr.rfdBase = newrfdbase;
+ fdr.crfd = input_symhdr->ifdMax;
+ }
+ else
+ {
+ /* Point this FDR at the remapped RFD's. */
+ fdr.rfdBase += oldrfdbase;
+ }
+
+ (*swap_fdr_out) (output_bfd, &fdr, fdr_out);
+ fdr_out += external_fdr_size;
+ ++output_symhdr->ifdMax;
+ }
+
+ return true;
+}
+
+/* Add a string to the debugging information we are accumulating.
+ Return the offset from the fdr string base. */
+
+static long ecoff_add_string PARAMS ((struct accumulate *,
+ struct bfd_link_info *,
+ struct ecoff_debug_info *,
+ FDR *fdr, const char *string));
+
+static long
+ecoff_add_string (ainfo, info, debug, fdr, string)
+ struct accumulate *ainfo;
+ struct bfd_link_info *info;
+ struct ecoff_debug_info *debug;
+ FDR *fdr;
+ const char *string;
+{
+ HDRR *symhdr;
+ size_t len;
+ bfd_size_type ret;
+
+ symhdr = &debug->symbolic_header;
+ len = strlen (string);
+ if (info->relocateable)
+ {
+ if (!add_memory_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end, (PTR) string,
+ len + 1))
+ return -1;
+ ret = symhdr->issMax;
+ symhdr->issMax += len + 1;
+ fdr->cbSs += len + 1;
+ }
+ else
+ {
+ struct string_hash_entry *sh;
+
+ sh = string_hash_lookup (&ainfo->str_hash, string, true, true);
+ if (sh == (struct string_hash_entry *) NULL)
+ return -1;
+ if (sh->val == -1)
+ {
+ sh->val = symhdr->issMax;
+ symhdr->issMax += len + 1;
+ if (ainfo->ss_hash == (struct string_hash_entry *) NULL)
+ ainfo->ss_hash = sh;
+ if (ainfo->ss_hash_end
+ != (struct string_hash_entry *) NULL)
+ ainfo->ss_hash_end->next = sh;
+ ainfo->ss_hash_end = sh;
+ }
+ ret = sh->val;
+ }
+
+ return ret;
+}
+
+/* Add debugging information from a non-ECOFF file. */
+
+boolean
+bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
+ output_swap, input_bfd, info)
+ PTR handle;
+ bfd *output_bfd;
+ struct ecoff_debug_info *output_debug;
+ const struct ecoff_debug_swap *output_swap;
+ bfd *input_bfd;
+ struct bfd_link_info *info;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+ void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
+ = output_swap->swap_sym_out;
+ HDRR *output_symhdr = &output_debug->symbolic_header;
+ FDR fdr;
+ asection *sec;
+ asymbol **symbols;
+ asymbol **sym_ptr;
+ asymbol **sym_end;
+ long symsize;
+ long symcount;
+ PTR external_fdr;
+
+ memset ((PTR) &fdr, 0, sizeof fdr);
+
+ sec = bfd_get_section_by_name (input_bfd, ".text");
+ if (sec != NULL)
+ fdr.adr = sec->output_section->vma + sec->output_offset;
+ else
+ {
+ /* FIXME: What about .init or .fini? */
+ fdr.adr = 0;
+ }
+
+ fdr.issBase = output_symhdr->issMax;
+ fdr.cbSs = 0;
+ fdr.rss = ecoff_add_string (ainfo, info, output_debug, &fdr,
+ bfd_get_filename (input_bfd));
+ if (fdr.rss == -1)
+ return false;
+ fdr.isymBase = output_symhdr->isymMax;
+
+ /* Get the local symbols from the input BFD. */
+ symsize = bfd_get_symtab_upper_bound (input_bfd);
+ if (symsize < 0)
+ return false;
+ symbols = (asymbol **) bfd_alloc (output_bfd, symsize);
+ if (symbols == (asymbol **) NULL)
+ return false;
+ symcount = bfd_canonicalize_symtab (input_bfd, symbols);
+ if (symcount < 0)
+ return false;
+ sym_end = symbols + symcount;
+
+ /* Handle the local symbols. Any external symbols are handled
+ separately. */
+ fdr.csym = 0;
+ for (sym_ptr = symbols; sym_ptr != sym_end; sym_ptr++)
+ {
+ SYMR internal_sym;
+ PTR external_sym;
+
+ if (((*sym_ptr)->flags & BSF_EXPORT) != 0)
+ continue;
+ memset ((PTR) &internal_sym, 0, sizeof internal_sym);
+ internal_sym.iss = ecoff_add_string (ainfo, info, output_debug, &fdr,
+ (*sym_ptr)->name);
+
+ if (internal_sym.iss == -1)
+ return false;
+ if (bfd_is_com_section ((*sym_ptr)->section)
+ || bfd_is_und_section ((*sym_ptr)->section))
+ internal_sym.value = (*sym_ptr)->value;
+ else
+ internal_sym.value = ((*sym_ptr)->value
+ + (*sym_ptr)->section->output_offset
+ + (*sym_ptr)->section->output_section->vma);
+ internal_sym.st = stNil;
+ internal_sym.sc = scUndefined;
+ internal_sym.index = indexNil;
+
+ external_sym = (PTR) objalloc_alloc (ainfo->memory,
+ output_swap->external_sym_size);
+ if (!external_sym)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ (*swap_sym_out) (output_bfd, &internal_sym, external_sym);
+ add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end,
+ external_sym, output_swap->external_sym_size);
+ ++fdr.csym;
+ ++output_symhdr->isymMax;
+ }
+
+ bfd_release (output_bfd, (PTR) symbols);
+
+ /* Leave everything else in the FDR zeroed out. This will cause
+ the lang field to be langC. The fBigendian field will
+ indicate little endian format, but it doesn't matter because
+ it only applies to aux fields and there are none. */
+ external_fdr = (PTR) objalloc_alloc (ainfo->memory,
+ output_swap->external_fdr_size);
+ if (!external_fdr)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ (*output_swap->swap_fdr_out) (output_bfd, &fdr, external_fdr);
+ add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end,
+ external_fdr, output_swap->external_fdr_size);
+
+ ++output_symhdr->ifdMax;
+
+ return true;
+}
+
+/* Set up ECOFF debugging information for the external symbols.
+ FIXME: This is done using a memory buffer, but it should be
+ probably be changed to use a shuffle structure. The assembler uses
+ this interface, so that must be changed to do something else. */
+
+boolean
+bfd_ecoff_debug_externals (abfd, debug, swap, relocateable, get_extr,
+ set_index)
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ boolean relocateable;
+ boolean (*get_extr) PARAMS ((asymbol *, EXTR *));
+ void (*set_index) PARAMS ((asymbol *, bfd_size_type));
+{
+ HDRR * const symhdr = &debug->symbolic_header;
+ asymbol **sym_ptr_ptr;
+ size_t c;
+
+ sym_ptr_ptr = bfd_get_outsymbols (abfd);
+ if (sym_ptr_ptr == NULL)
+ return true;
+
+ for (c = bfd_get_symcount (abfd); c > 0; c--, sym_ptr_ptr++)
+ {
+ asymbol *sym_ptr;
+ EXTR esym;
+
+ sym_ptr = *sym_ptr_ptr;
+
+ /* Get the external symbol information. */
+ if ((*get_extr) (sym_ptr, &esym) == false)
+ continue;
+
+ /* If we're producing an executable, move common symbols into
+ bss. */
+ if (relocateable == false)
+ {
+ if (esym.asym.sc == scCommon)
+ esym.asym.sc = scBss;
+ else if (esym.asym.sc == scSCommon)
+ esym.asym.sc = scSBss;
+ }
+
+ if (bfd_is_com_section (sym_ptr->section)
+ || bfd_is_und_section (sym_ptr->section)
+ || sym_ptr->section->output_section == (asection *) NULL)
+ {
+ /* FIXME: gas does not keep the value of a small undefined
+ symbol in the symbol itself, because of relocation
+ problems. */
+ if (esym.asym.sc != scSUndefined
+ || esym.asym.value == 0
+ || sym_ptr->value != 0)
+ esym.asym.value = sym_ptr->value;
+ }
+ else
+ esym.asym.value = (sym_ptr->value
+ + sym_ptr->section->output_offset
+ + sym_ptr->section->output_section->vma);
+
+ if (set_index)
+ (*set_index) (sym_ptr, (bfd_size_type) symhdr->iextMax);
+
+ if (! bfd_ecoff_debug_one_external (abfd, debug, swap,
+ sym_ptr->name, &esym))
+ return false;
+ }
+
+ return true;
+}
+
+/* Add a single external symbol to the debugging information. */
+
+boolean
+bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym)
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ const char *name;
+ EXTR *esym;
+{
+ const bfd_size_type external_ext_size = swap->external_ext_size;
+ void (* const swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR))
+ = swap->swap_ext_out;
+ HDRR * const symhdr = &debug->symbolic_header;
+ size_t namelen;
+
+ namelen = strlen (name);
+
+ if ((size_t) (debug->ssext_end - debug->ssext)
+ < symhdr->issExtMax + namelen + 1)
+ {
+ if (ecoff_add_bytes ((char **) &debug->ssext,
+ (char **) &debug->ssext_end,
+ symhdr->issExtMax + namelen + 1)
+ == false)
+ return false;
+ }
+ if ((size_t) ((char *) debug->external_ext_end
+ - (char *) debug->external_ext)
+ < (symhdr->iextMax + 1) * external_ext_size)
+ {
+ if (ecoff_add_bytes ((char **) &debug->external_ext,
+ (char **) &debug->external_ext_end,
+ (symhdr->iextMax + 1) * external_ext_size)
+ == false)
+ return false;
+ }
+
+ esym->asym.iss = symhdr->issExtMax;
+
+ (*swap_ext_out) (abfd, esym,
+ ((char *) debug->external_ext
+ + symhdr->iextMax * swap->external_ext_size));
+
+ ++symhdr->iextMax;
+
+ strcpy (debug->ssext + symhdr->issExtMax, name);
+ symhdr->issExtMax += namelen + 1;
+
+ return true;
+}
+
+/* Align the ECOFF debugging information. */
+
+/*ARGSUSED*/
+static void
+ecoff_align_debug (abfd, debug, swap)
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+{
+ HDRR * const symhdr = &debug->symbolic_header;
+ bfd_size_type debug_align, aux_align, rfd_align;
+ size_t add;
+
+ /* Adjust the counts so that structures are aligned. */
+ debug_align = swap->debug_align;
+ aux_align = debug_align / sizeof (union aux_ext);
+ rfd_align = debug_align / swap->external_rfd_size;
+
+ add = debug_align - (symhdr->cbLine & (debug_align - 1));
+ if (add != debug_align)
+ {
+ if (debug->line != (unsigned char *) NULL)
+ memset ((PTR) (debug->line + symhdr->cbLine), 0, add);
+ symhdr->cbLine += add;
+ }
+
+ add = debug_align - (symhdr->issMax & (debug_align - 1));
+ if (add != debug_align)
+ {
+ if (debug->ss != (char *) NULL)
+ memset ((PTR) (debug->ss + symhdr->issMax), 0, add);
+ symhdr->issMax += add;
+ }
+
+ add = debug_align - (symhdr->issExtMax & (debug_align - 1));
+ if (add != debug_align)
+ {
+ if (debug->ssext != (char *) NULL)
+ memset ((PTR) (debug->ssext + symhdr->issExtMax), 0, add);
+ symhdr->issExtMax += add;
+ }
+
+ add = aux_align - (symhdr->iauxMax & (aux_align - 1));
+ if (add != aux_align)
+ {
+ if (debug->external_aux != (union aux_ext *) NULL)
+ memset ((PTR) (debug->external_aux + symhdr->iauxMax), 0,
+ add * sizeof (union aux_ext));
+ symhdr->iauxMax += add;
+ }
+
+ add = rfd_align - (symhdr->crfd & (rfd_align - 1));
+ if (add != rfd_align)
+ {
+ if (debug->external_rfd != (PTR) NULL)
+ memset ((PTR) ((char *) debug->external_rfd
+ + symhdr->crfd * swap->external_rfd_size),
+ 0, (size_t) (add * swap->external_rfd_size));
+ symhdr->crfd += add;
+ }
+}
+
+/* Return the size required by the ECOFF debugging information. */
+
+bfd_size_type
+bfd_ecoff_debug_size (abfd, debug, swap)
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+{
+ bfd_size_type tot;
+
+ ecoff_align_debug (abfd, debug, swap);
+ tot = swap->external_hdr_size;
+
+#define ADD(count, size) \
+ tot += debug->symbolic_header.count * size
+
+ ADD (cbLine, sizeof (unsigned char));
+ ADD (idnMax, swap->external_dnr_size);
+ ADD (ipdMax, swap->external_pdr_size);
+ ADD (isymMax, swap->external_sym_size);
+ ADD (ioptMax, swap->external_opt_size);
+ ADD (iauxMax, sizeof (union aux_ext));
+ ADD (issMax, sizeof (char));
+ ADD (issExtMax, sizeof (char));
+ ADD (ifdMax, swap->external_fdr_size);
+ ADD (crfd, swap->external_rfd_size);
+ ADD (iextMax, swap->external_ext_size);
+
+#undef ADD
+
+ return tot;
+}
+
+/* Write out the ECOFF symbolic header, given the file position it is
+ going to be placed at. This assumes that the counts are set
+ correctly. */
+
+static boolean
+ecoff_write_symhdr (abfd, debug, swap, where)
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ file_ptr where;
+{
+ HDRR * const symhdr = &debug->symbolic_header;
+ char *buff = NULL;
+
+ ecoff_align_debug (abfd, debug, swap);
+
+ /* Go to the right location in the file. */
+ if (bfd_seek (abfd, where, SEEK_SET) != 0)
+ return false;
+
+ where += swap->external_hdr_size;
+
+ symhdr->magic = swap->sym_magic;
+
+ /* Fill in the file offsets. */
+#define SET(offset, count, size) \
+ if (symhdr->count == 0) \
+ symhdr->offset = 0; \
+ else \
+ { \
+ symhdr->offset = where; \
+ where += symhdr->count * size; \
+ }
+
+ SET (cbLineOffset, cbLine, sizeof (unsigned char));
+ SET (cbDnOffset, idnMax, swap->external_dnr_size);
+ SET (cbPdOffset, ipdMax, swap->external_pdr_size);
+ SET (cbSymOffset, isymMax, swap->external_sym_size);
+ SET (cbOptOffset, ioptMax, swap->external_opt_size);
+ SET (cbAuxOffset, iauxMax, sizeof (union aux_ext));
+ SET (cbSsOffset, issMax, sizeof (char));
+ SET (cbSsExtOffset, issExtMax, sizeof (char));
+ SET (cbFdOffset, ifdMax, swap->external_fdr_size);
+ SET (cbRfdOffset, crfd, swap->external_rfd_size);
+ SET (cbExtOffset, iextMax, swap->external_ext_size);
+#undef SET
+
+ buff = (PTR) bfd_malloc ((size_t) swap->external_hdr_size);
+ if (buff == NULL && swap->external_hdr_size != 0)
+ goto error_return;
+
+ (*swap->swap_hdr_out) (abfd, symhdr, buff);
+ if (bfd_write (buff, 1, swap->external_hdr_size, abfd)
+ != swap->external_hdr_size)
+ goto error_return;
+
+ if (buff != NULL)
+ free (buff);
+ return true;
+ error_return:
+ if (buff != NULL)
+ free (buff);
+ return false;
+}
+
+/* Write out the ECOFF debugging information. This function assumes
+ that the information (the pointers and counts) in *DEBUG have been
+ set correctly. WHERE is the position in the file to write the
+ information to. This function fills in the file offsets in the
+ symbolic header. */
+
+boolean
+bfd_ecoff_write_debug (abfd, debug, swap, where)
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ file_ptr where;
+{
+ HDRR * const symhdr = &debug->symbolic_header;
+
+ if (! ecoff_write_symhdr (abfd, debug, swap, where))
+ return false;
+
+#define WRITE(ptr, count, size, offset) \
+ BFD_ASSERT (symhdr->offset == 0 \
+ || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
+ if (bfd_write ((PTR) debug->ptr, size, symhdr->count, abfd) \
+ != size * symhdr->count) \
+ return false;
+
+ WRITE (line, cbLine, sizeof (unsigned char), cbLineOffset);
+ WRITE (external_dnr, idnMax, swap->external_dnr_size, cbDnOffset);
+ WRITE (external_pdr, ipdMax, swap->external_pdr_size, cbPdOffset);
+ WRITE (external_sym, isymMax, swap->external_sym_size, cbSymOffset);
+ WRITE (external_opt, ioptMax, swap->external_opt_size, cbOptOffset);
+ WRITE (external_aux, iauxMax, sizeof (union aux_ext), cbAuxOffset);
+ WRITE (ss, issMax, sizeof (char), cbSsOffset);
+ WRITE (ssext, issExtMax, sizeof (char), cbSsExtOffset);
+ WRITE (external_fdr, ifdMax, swap->external_fdr_size, cbFdOffset);
+ WRITE (external_rfd, crfd, swap->external_rfd_size, cbRfdOffset);
+ WRITE (external_ext, iextMax, swap->external_ext_size, cbExtOffset);
+#undef WRITE
+
+ return true;
+}
+
+/* Write out a shuffle list. */
+
+static boolean ecoff_write_shuffle PARAMS ((bfd *,
+ const struct ecoff_debug_swap *,
+ struct shuffle *, PTR space));
+
+static boolean
+ecoff_write_shuffle (abfd, swap, shuffle, space)
+ bfd *abfd;
+ const struct ecoff_debug_swap *swap;
+ struct shuffle *shuffle;
+ PTR space;
+{
+ register struct shuffle *l;
+ unsigned long total;
+
+ total = 0;
+ for (l = shuffle; l != (struct shuffle *) NULL; l = l->next)
+ {
+ if (! l->filep)
+ {
+ if (bfd_write (l->u.memory, 1, l->size, abfd) != l->size)
+ return false;
+ }
+ else
+ {
+ if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
+ || bfd_read (space, 1, l->size, l->u.file.input_bfd) != l->size
+ || bfd_write (space, 1, l->size, abfd) != l->size)
+ return false;
+ }
+ total += l->size;
+ }
+
+ if ((total & (swap->debug_align - 1)) != 0)
+ {
+ unsigned int i;
+ bfd_byte *s;
+
+ i = swap->debug_align - (total & (swap->debug_align - 1));
+ s = (bfd_byte *) bfd_malloc (i);
+ if (s == NULL && i != 0)
+ return false;
+
+ memset ((PTR) s, 0, i);
+ if (bfd_write ((PTR) s, 1, i, abfd) != i)
+ {
+ free (s);
+ return false;
+ }
+ free (s);
+ }
+
+ return true;
+}
+
+/* Write out debugging information using accumulated linker
+ information. */
+
+boolean
+bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
+ PTR handle;
+ bfd *abfd;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ struct bfd_link_info *info;
+ file_ptr where;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+ PTR space = NULL;
+
+ if (! ecoff_write_symhdr (abfd, debug, swap, where))
+ goto error_return;
+
+ space = (PTR) bfd_malloc (ainfo->largest_file_shuffle);
+ if (space == NULL && ainfo->largest_file_shuffle != 0)
+ goto error_return;
+
+ if (! ecoff_write_shuffle (abfd, swap, ainfo->line, space)
+ || ! ecoff_write_shuffle (abfd, swap, ainfo->pdr, space)
+ || ! ecoff_write_shuffle (abfd, swap, ainfo->sym, space)
+ || ! ecoff_write_shuffle (abfd, swap, ainfo->opt, space)
+ || ! ecoff_write_shuffle (abfd, swap, ainfo->aux, space))
+ goto error_return;
+
+ /* The string table is written out from the hash table if this is a
+ final link. */
+ if (info->relocateable)
+ {
+ BFD_ASSERT (ainfo->ss_hash == (struct string_hash_entry *) NULL);
+ if (! ecoff_write_shuffle (abfd, swap, ainfo->ss, space))
+ goto error_return;
+ }
+ else
+ {
+ unsigned long total;
+ bfd_byte null;
+ struct string_hash_entry *sh;
+
+ BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
+ null = 0;
+ if (bfd_write ((PTR) &null, 1, 1, abfd) != 1)
+ goto error_return;
+ total = 1;
+ BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
+ for (sh = ainfo->ss_hash;
+ sh != (struct string_hash_entry *) NULL;
+ sh = sh->next)
+ {
+ size_t len;
+
+ len = strlen (sh->root.string);
+ if (bfd_write ((PTR) sh->root.string, 1, len + 1, abfd) != len + 1)
+ goto error_return;
+ total += len + 1;
+ }
+
+ if ((total & (swap->debug_align - 1)) != 0)
+ {
+ unsigned int i;
+ bfd_byte *s;
+
+ i = swap->debug_align - (total & (swap->debug_align - 1));
+ s = (bfd_byte *) bfd_malloc (i);
+ if (s == NULL && i != 0)
+ goto error_return;
+ memset ((PTR) s, 0, i);
+ if (bfd_write ((PTR) s, 1, i, abfd) != i)
+ {
+ free (s);
+ goto error_return;
+ }
+ free (s);
+ }
+ }
+
+ /* The external strings and symbol are not converted over to using
+ shuffles. FIXME: They probably should be. */
+ if (bfd_write (debug->ssext, 1, debug->symbolic_header.issExtMax, abfd)
+ != (bfd_size_type) debug->symbolic_header.issExtMax)
+ goto error_return;
+ if ((debug->symbolic_header.issExtMax & (swap->debug_align - 1)) != 0)
+ {
+ unsigned int i;
+ bfd_byte *s;
+
+ i = (swap->debug_align
+ - (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
+ s = (bfd_byte *) bfd_malloc (i);
+ if (s == NULL && i != 0)
+ goto error_return;
+ memset ((PTR) s, 0, i);
+ if (bfd_write ((PTR) s, 1, i, abfd) != i)
+ {
+ free (s);
+ goto error_return;
+ }
+ free (s);
+ }
+
+ if (! ecoff_write_shuffle (abfd, swap, ainfo->fdr, space)
+ || ! ecoff_write_shuffle (abfd, swap, ainfo->rfd, space))
+ goto error_return;
+
+ BFD_ASSERT (debug->symbolic_header.cbExtOffset == 0
+ || (debug->symbolic_header.cbExtOffset
+ == (bfd_vma) bfd_tell (abfd)));
+
+ if (bfd_write (debug->external_ext, swap->external_ext_size,
+ debug->symbolic_header.iextMax, abfd)
+ != debug->symbolic_header.iextMax * swap->external_ext_size)
+ goto error_return;
+
+ if (space != NULL)
+ free (space);
+ return true;
+
+ error_return:
+ if (space != NULL)
+ free (space);
+ return false;
+}
+
+/* Handle the find_nearest_line function for both ECOFF and MIPS ELF
+ files. */
+
+/* Compare FDR entries. This is called via qsort. */
+
+static int
+cmp_fdrtab_entry (leftp, rightp)
+ const PTR leftp;
+ const PTR rightp;
+{
+ const struct ecoff_fdrtab_entry *lp =
+ (const struct ecoff_fdrtab_entry *) leftp;
+ const struct ecoff_fdrtab_entry *rp =
+ (const struct ecoff_fdrtab_entry *) rightp;
+
+ if (lp->base_addr < rp->base_addr)
+ return -1;
+ if (lp->base_addr > rp->base_addr)
+ return 1;
+ return 0;
+}
+
+/* Each file descriptor (FDR) has a memory address, to simplify
+ looking up an FDR by address, we build a table covering all FDRs
+ that have a least one procedure descriptor in them. The final
+ table will be sorted by address so we can look it up via binary
+ search. */
+
+static boolean
+mk_fdrtab (abfd, debug_info, debug_swap, line_info)
+ bfd *abfd;
+ struct ecoff_debug_info * const debug_info;
+ const struct ecoff_debug_swap * const debug_swap;
+ struct ecoff_find_line *line_info;
+{
+ struct ecoff_fdrtab_entry *tab;
+ FDR *fdr_ptr;
+ FDR *fdr_start;
+ FDR *fdr_end;
+ boolean stabs;
+ long len;
+
+ fdr_start = debug_info->fdr;
+ fdr_end = fdr_start + debug_info->symbolic_header.ifdMax;
+
+ /* First, let's see how long the table needs to be: */
+ for (len = 0, fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
+ {
+ if (fdr_ptr->cpd == 0) /* skip FDRs that have no PDRs */
+ continue;
+ ++len;
+ }
+
+ /* Now, create and fill in the table: */
+
+ line_info->fdrtab = ((struct ecoff_fdrtab_entry*)
+ bfd_zalloc (abfd,
+ len * sizeof (struct ecoff_fdrtab_entry)));
+ if (line_info->fdrtab == NULL)
+ return false;
+ line_info->fdrtab_len = len;
+
+ tab = line_info->fdrtab;
+ for (fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
+ {
+ if (fdr_ptr->cpd == 0)
+ continue;
+
+ /* Check whether this file has stabs debugging information. In
+ a file with stabs debugging information, the second local
+ symbol is named @stabs. */
+ stabs = false;
+ if (fdr_ptr->csym >= 2)
+ {
+ char *sym_ptr;
+ SYMR sym;
+
+ sym_ptr = ((char *) debug_info->external_sym
+ + (fdr_ptr->isymBase + 1)*debug_swap->external_sym_size);
+ (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
+ if (strcmp (debug_info->ss + fdr_ptr->issBase + sym.iss,
+ STABS_SYMBOL) == 0)
+ stabs = true;
+ }
+
+ if (!stabs)
+ {
+ bfd_size_type external_pdr_size;
+ char *pdr_ptr;
+ PDR pdr;
+
+ external_pdr_size = debug_swap->external_pdr_size;
+
+ pdr_ptr = ((char *) debug_info->external_pdr
+ + fdr_ptr->ipdFirst * external_pdr_size);
+ (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
+ /* The address of the first PDR is the offset of that
+ procedure relative to the beginning of file FDR. */
+ tab->base_addr = fdr_ptr->adr - pdr.adr;
+ }
+ else
+ {
+ /* XXX I don't know about stabs, so this is a guess
+ (davidm@cs.arizona.edu): */
+ tab->base_addr = fdr_ptr->adr;
+ }
+ tab->fdr = fdr_ptr;
+ ++tab;
+ }
+
+ /* Finally, the table is sorted in increasing memory-address order.
+ The table is mostly sorted already, but there are cases (e.g.,
+ static functions in include files), where this does not hold.
+ Use "odump -PFv" to verify... */
+ qsort ((PTR) line_info->fdrtab, len,
+ sizeof (struct ecoff_fdrtab_entry), cmp_fdrtab_entry);
+
+ return true;
+}
+
+/* Return index of first FDR that covers to OFFSET. */
+
+static long
+fdrtab_lookup (line_info, offset)
+ struct ecoff_find_line *line_info;
+ bfd_vma offset;
+{
+ long low, high, len;
+ long mid = -1;
+ struct ecoff_fdrtab_entry *tab;
+
+ len = line_info->fdrtab_len;
+ if (len == 0)
+ return -1;
+
+ tab = line_info->fdrtab;
+ for (low = 0, high = len - 1 ; low != high ;)
+ {
+ mid = (high + low) / 2;
+ if (offset >= tab[mid].base_addr && offset < tab[mid + 1].base_addr)
+ goto find_min;
+
+ if (tab[mid].base_addr > offset)
+ high = mid;
+ else
+ low = mid + 1;
+ }
+ ++mid;
+
+ /* last entry is catch-all for all higher addresses: */
+ if (offset < tab[mid].base_addr)
+ return -1;
+
+ find_min:
+
+ while (mid > 0 && tab[mid - 1].base_addr == tab[mid].base_addr)
+ --mid;
+
+ return mid;
+}
+
+/* Look up a line given an address, storing the information in
+ LINE_INFO->cache. */
+
+static boolean
+lookup_line (abfd, debug_info, debug_swap, line_info)
+ bfd *abfd;
+ struct ecoff_debug_info * const debug_info;
+ const struct ecoff_debug_swap * const debug_swap;
+ struct ecoff_find_line *line_info;
+{
+ struct ecoff_fdrtab_entry *tab;
+ bfd_vma offset;
+ boolean stabs;
+ FDR *fdr_ptr;
+ int i;
+
+ offset = line_info->cache.start;
+
+ /* Build FDR table (sorted by object file's base-address) if we
+ don't have it already. */
+ if (line_info->fdrtab == NULL
+ && !mk_fdrtab (abfd, debug_info, debug_swap, line_info))
+ return false;
+
+ tab = line_info->fdrtab;
+
+ /* find first FDR for address OFFSET */
+ i = fdrtab_lookup (line_info, offset);
+ if (i < 0)
+ return false; /* no FDR, no fun... */
+ fdr_ptr = tab[i].fdr;
+
+ /* Check whether this file has stabs debugging information. In a
+ file with stabs debugging information, the second local symbol is
+ named @stabs. */
+ stabs = false;
+ if (fdr_ptr->csym >= 2)
+ {
+ char *sym_ptr;
+ SYMR sym;
+
+ sym_ptr = ((char *) debug_info->external_sym
+ + (fdr_ptr->isymBase + 1) * debug_swap->external_sym_size);
+ (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
+ if (strcmp (debug_info->ss + fdr_ptr->issBase + sym.iss,
+ STABS_SYMBOL) == 0)
+ stabs = true;
+ }
+
+ if (!stabs)
+ {
+ bfd_size_type external_pdr_size;
+ char *pdr_ptr;
+ char *best_pdr = NULL;
+ FDR *best_fdr;
+ bfd_vma best_dist = ~0;
+ PDR pdr;
+ unsigned char *line_ptr;
+ unsigned char *line_end;
+ int lineno;
+ /* This file uses ECOFF debugging information. Each FDR has a
+ list of procedure descriptors (PDR). The address in the FDR
+ is the absolute address of the first procedure. The address
+ in the first PDR gives the offset of that procedure relative
+ to the object file's base-address. The addresses in
+ subsequent PDRs specify each procedure's address relative to
+ the object file's base-address. To make things more juicy,
+ whenever the PROF bit in the PDR is set, the real entry point
+ of the procedure may be 16 bytes below what would normally be
+ the procedure's entry point. Instead, DEC came up with a
+ wicked scheme to create profiled libraries "on the fly":
+ instead of shipping a regular and a profiled version of each
+ library, they insert 16 bytes of unused space in front of
+ each procedure and set the "prof" bit in the PDR to indicate
+ that there is a gap there (this is done automagically by "as"
+ when option "-pg" is specified). Thus, normally, you link
+ against such a library and, except for lots of 16 byte gaps
+ between functions, things will behave as usual. However,
+ when invoking "ld" with option "-pg", it will fill those gaps
+ with code that calls mcount(). It then moves the function's
+ entry point down by 16 bytes, and out pops a binary that has
+ all functions profiled.
+
+ NOTE: Neither FDRs nor PDRs are strictly sorted in memory
+ order. For example, when including header-files that
+ define functions, the FDRs follow behind the including
+ file, even though their code may have been generated at
+ a lower address. File coff-alpha.c from libbfd
+ illustrates this (use "odump -PFv" to look at a file's
+ FDR/PDR). Similarly, PDRs are sometimes out of order
+ as well. An example of this is OSF/1 v3.0 libc's
+ malloc.c. I'm not sure why this happens, but it could
+ be due to optimizations that reorder a function's
+ position within an object-file.
+
+ Strategy:
+
+ On the first call to this function, we build a table of FDRs
+ that is sorted by the base-address of the object-file the FDR
+ is referring to. Notice that each object-file may contain
+ code from multiple source files (e.g., due to code defined in
+ include files). Thus, for any given base-address, there may
+ be multiple FDRs (but this case is, fortunately, uncommon).
+ lookup(addr) guarantees to return the first FDR that applies
+ to address ADDR. Thus, after invoking lookup(), we have a
+ list of FDRs that may contain the PDR for ADDR. Next, we
+ walk through the PDRs of these FDRs and locate the one that
+ is closest to ADDR (i.e., for which the difference between
+ ADDR and the PDR's entry point is positive and minimal).
+ Once, the right FDR and PDR are located, we simply walk
+ through the line-number table to lookup the line-number that
+ best matches ADDR. Obviously, things could be sped up by
+ keeping a sorted list of PDRs instead of a sorted list of
+ FDRs. However, this would increase space requirements
+ considerably, which is undesirable. */
+ external_pdr_size = debug_swap->external_pdr_size;
+
+ /* Make offset relative to object file's start-address: */
+ offset -= tab[i].base_addr;
+ /* Search FDR list starting at tab[i] for the PDR that best matches
+ OFFSET. Normally, the FDR list is only one entry long. */
+ best_fdr = NULL;
+ do
+ {
+ bfd_vma dist, min_dist = 0;
+ char *pdr_hold;
+ char *pdr_end;
+
+ fdr_ptr = tab[i].fdr;
+
+ pdr_ptr = ((char *) debug_info->external_pdr
+ + fdr_ptr->ipdFirst * external_pdr_size);
+ pdr_end = pdr_ptr + fdr_ptr->cpd * external_pdr_size;
+ (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
+ /* Find PDR that is closest to OFFSET. If pdr.prof is set,
+ the procedure entry-point *may* be 0x10 below pdr.adr. We
+ simply pretend that pdr.prof *implies* a lower entry-point.
+ This is safe because it just means that may identify 4 NOPs
+ in front of the function as belonging to the function. */
+ for (pdr_hold = NULL;
+ pdr_ptr < pdr_end;
+ (pdr_ptr += external_pdr_size,
+ (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr)))
+ {
+ if (offset >= (pdr.adr - 0x10 * pdr.prof))
+ {
+ dist = offset - (pdr.adr - 0x10 * pdr.prof);
+ if (!pdr_hold || dist < min_dist)
+ {
+ min_dist = dist;
+ pdr_hold = pdr_ptr;
+ }
+ }
+ }
+
+ if (!best_pdr || min_dist < best_dist)
+ {
+ best_dist = min_dist;
+ best_fdr = fdr_ptr;
+ best_pdr = pdr_hold;
+ }
+ /* continue looping until base_addr of next entry is different: */
+ }
+ while (++i < line_info->fdrtab_len
+ && tab[i].base_addr == tab[i - 1].base_addr);
+
+ if (!best_fdr || !best_pdr)
+ return false; /* shouldn't happen... */
+
+ /* phew, finally we got something that we can hold onto: */
+ fdr_ptr = best_fdr;
+ pdr_ptr = best_pdr;
+ (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
+ /* Now we can look for the actual line number. The line numbers
+ are stored in a very funky format, which I won't try to
+ describe. The search is bounded by the end of the FDRs line
+ number entries. */
+ line_end = debug_info->line + fdr_ptr->cbLineOffset + fdr_ptr->cbLine;
+
+ /* Make offset relative to procedure entry: */
+ offset -= pdr.adr - 0x10 * pdr.prof;
+ lineno = pdr.lnLow;
+ line_ptr = debug_info->line + fdr_ptr->cbLineOffset + pdr.cbLineOffset;
+ while (line_ptr < line_end)
+ {
+ int delta;
+ unsigned int count;
+
+ delta = *line_ptr >> 4;
+ if (delta >= 0x8)
+ delta -= 0x10;
+ count = (*line_ptr & 0xf) + 1;
+ ++line_ptr;
+ if (delta == -8)
+ {
+ delta = (((line_ptr[0]) & 0xff) << 8) + ((line_ptr[1]) & 0xff);
+ if (delta >= 0x8000)
+ delta -= 0x10000;
+ line_ptr += 2;
+ }
+ lineno += delta;
+ if (offset < count * 4)
+ {
+ line_info->cache.stop += count * 4 - offset;
+ break;
+ }
+ offset -= count * 4;
+ }
+
+ /* If fdr_ptr->rss is -1, then this file does not have full
+ symbols, at least according to gdb/mipsread.c. */
+ if (fdr_ptr->rss == -1)
+ {
+ line_info->cache.filename = NULL;
+ if (pdr.isym == -1)
+ line_info->cache.functionname = NULL;
+ else
+ {
+ EXTR proc_ext;
+
+ (*debug_swap->swap_ext_in)
+ (abfd,
+ ((char *) debug_info->external_ext
+ + pdr.isym * debug_swap->external_ext_size),
+ &proc_ext);
+ line_info->cache.functionname = (debug_info->ssext
+ + proc_ext.asym.iss);
+ }
+ }
+ else
+ {
+ SYMR proc_sym;
+
+ line_info->cache.filename = (debug_info->ss
+ + fdr_ptr->issBase
+ + fdr_ptr->rss);
+ (*debug_swap->swap_sym_in)
+ (abfd,
+ ((char *) debug_info->external_sym
+ + ((fdr_ptr->isymBase + pdr.isym)
+ * debug_swap->external_sym_size)),
+ &proc_sym);
+ line_info->cache.functionname = (debug_info->ss
+ + fdr_ptr->issBase
+ + proc_sym.iss);
+ }
+ if (lineno == ilineNil)
+ lineno = 0;
+ line_info->cache.line_num = lineno;
+ }
+ else
+ {
+ bfd_size_type external_sym_size;
+ const char *directory_name;
+ const char *main_file_name;
+ const char *current_file_name;
+ const char *function_name;
+ const char *line_file_name;
+ bfd_vma low_func_vma;
+ bfd_vma low_line_vma;
+ boolean past_line;
+ boolean past_fn;
+ char *sym_ptr, *sym_ptr_end;
+ size_t len, funclen;
+ char *buffer = NULL;
+
+ /* This file uses stabs debugging information. When gcc is not
+ optimizing, it will put the line number information before
+ the function name stabs entry. When gcc is optimizing, it
+ will put the stabs entry for all the function first, followed
+ by the line number information. (This appears to happen
+ because of the two output files used by the -mgpopt switch,
+ which is implied by -O). This means that we must keep
+ looking through the symbols until we find both a line number
+ and a function name which are beyond the address we want. */
+
+ line_info->cache.filename = NULL;
+ line_info->cache.functionname = NULL;
+ line_info->cache.line_num = 0;
+
+ directory_name = NULL;
+ main_file_name = NULL;
+ current_file_name = NULL;
+ function_name = NULL;
+ line_file_name = NULL;
+ low_func_vma = 0;
+ low_line_vma = 0;
+ past_line = false;
+ past_fn = false;
+
+ external_sym_size = debug_swap->external_sym_size;
+
+ sym_ptr = ((char *) debug_info->external_sym
+ + (fdr_ptr->isymBase + 2) * external_sym_size);
+ sym_ptr_end = sym_ptr + (fdr_ptr->csym - 2) * external_sym_size;
+ for (;
+ sym_ptr < sym_ptr_end && (! past_line || ! past_fn);
+ sym_ptr += external_sym_size)
+ {
+ SYMR sym;
+
+ (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
+
+ if (ECOFF_IS_STAB (&sym))
+ {
+ switch (ECOFF_UNMARK_STAB (sym.index))
+ {
+ case N_SO:
+ main_file_name = current_file_name =
+ debug_info->ss + fdr_ptr->issBase + sym.iss;
+
+ /* Check the next symbol to see if it is also an
+ N_SO symbol. */
+ if (sym_ptr + external_sym_size < sym_ptr_end)
+ {
+ SYMR nextsym;
+
+ (*debug_swap->swap_sym_in) (abfd,
+ sym_ptr + external_sym_size,
+ &nextsym);
+ if (ECOFF_IS_STAB (&nextsym)
+ && ECOFF_UNMARK_STAB (nextsym.index) == N_SO)
+ {
+ directory_name = current_file_name;
+ main_file_name = current_file_name =
+ debug_info->ss + fdr_ptr->issBase + nextsym.iss;
+ sym_ptr += external_sym_size;
+ }
+ }
+ break;
+
+ case N_SOL:
+ current_file_name =
+ debug_info->ss + fdr_ptr->issBase + sym.iss;
+ break;
+
+ case N_FUN:
+ if (sym.value > offset)
+ past_fn = true;
+ else if (sym.value >= low_func_vma)
+ {
+ low_func_vma = sym.value;
+ function_name =
+ debug_info->ss + fdr_ptr->issBase + sym.iss;
+ }
+ break;
+ }
+ }
+ else if (sym.st == stLabel && sym.index != indexNil)
+ {
+ if (sym.value > offset)
+ past_line = true;
+ else if (sym.value >= low_line_vma)
+ {
+ low_line_vma = sym.value;
+ line_file_name = current_file_name;
+ line_info->cache.line_num = sym.index;
+ }
+ }
+ }
+
+ if (line_info->cache.line_num != 0)
+ main_file_name = line_file_name;
+
+ /* We need to remove the stuff after the colon in the function
+ name. We also need to put the directory name and the file
+ name together. */
+ if (function_name == NULL)
+ len = funclen = 0;
+ else
+ len = funclen = strlen (function_name) + 1;
+
+ if (main_file_name != NULL
+ && directory_name != NULL
+ && main_file_name[0] != '/')
+ len += strlen (directory_name) + strlen (main_file_name) + 1;
+
+ if (len != 0)
+ {
+ if (line_info->find_buffer != NULL)
+ free (line_info->find_buffer);
+ buffer = (char *) bfd_malloc (len);
+ if (buffer == NULL)
+ return false;
+ line_info->find_buffer = buffer;
+ }
+
+ if (function_name != NULL)
+ {
+ char *colon;
+
+ strcpy (buffer, function_name);
+ colon = strchr (buffer, ':');
+ if (colon != NULL)
+ *colon = '\0';
+ line_info->cache.functionname = buffer;
+ }
+
+ if (main_file_name != NULL)
+ {
+ if (directory_name == NULL || main_file_name[0] == '/')
+ line_info->cache.filename = main_file_name;
+ else
+ {
+ sprintf (buffer + funclen, "%s%s", directory_name,
+ main_file_name);
+ line_info->cache.filename = buffer + funclen;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Do the work of find_nearest_line. */
+
+boolean
+_bfd_ecoff_locate_line (abfd, section, offset, debug_info, debug_swap,
+ line_info, filename_ptr, functionname_ptr, retline_ptr)
+ bfd *abfd;
+ asection *section;
+ bfd_vma offset;
+ struct ecoff_debug_info * const debug_info;
+ const struct ecoff_debug_swap * const debug_swap;
+ struct ecoff_find_line *line_info;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *retline_ptr;
+{
+ offset += section->vma;
+
+ if (line_info->cache.sect == NULL
+ || line_info->cache.sect != section
+ || offset < line_info->cache.start
+ || offset >= line_info->cache.stop)
+ {
+ line_info->cache.sect = section;
+ line_info->cache.start = offset;
+ line_info->cache.stop = offset;
+ if (! lookup_line (abfd, debug_info, debug_swap, line_info))
+ {
+ line_info->cache.sect = NULL;
+ return false;
+ }
+ }
+
+ *filename_ptr = line_info->cache.filename;
+ *functionname_ptr = line_info->cache.functionname;
+ *retline_ptr = line_info->cache.line_num;
+
+ return true;
+}
+
+/* These routines copy symbolic information into a memory buffer.
+
+ FIXME: The whole point of the shuffle code is to avoid storing
+ everything in memory, since the linker is such a memory hog. This
+ code makes that effort useless. It is only called by the MIPS ELF
+ code when generating a shared library, so it is not that big a
+ deal, but it should be fixed eventually. */
+
+/* Collect a shuffle into a memory buffer. */
+
+static boolean ecoff_collect_shuffle PARAMS ((struct shuffle *, bfd_byte *));
+
+static boolean
+ecoff_collect_shuffle (l, buff)
+ struct shuffle *l;
+ bfd_byte *buff;
+{
+ unsigned long total;
+
+ total = 0;
+ for (; l != (struct shuffle *) NULL; l = l->next)
+ {
+ if (! l->filep)
+ memcpy (buff, l->u.memory, l->size);
+ else
+ {
+ if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
+ || bfd_read (buff, 1, l->size, l->u.file.input_bfd) != l->size)
+ return false;
+ }
+ total += l->size;
+ buff += l->size;
+ }
+
+ return true;
+}
+
+/* Copy PDR information into a memory buffer. */
+
+boolean
+_bfd_ecoff_get_accumulated_pdr (handle, buff)
+ PTR handle;
+ bfd_byte *buff;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+
+ return ecoff_collect_shuffle (ainfo->pdr, buff);
+}
+
+/* Copy symbol information into a memory buffer. */
+
+boolean
+_bfd_ecoff_get_accumulated_sym (handle, buff)
+ PTR handle;
+ bfd_byte *buff;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+
+ return ecoff_collect_shuffle (ainfo->sym, buff);
+}
+
+/* Copy the string table into a memory buffer. */
+
+boolean
+_bfd_ecoff_get_accumulated_ss (handle, buff)
+ PTR handle;
+ bfd_byte *buff;
+{
+ struct accumulate *ainfo = (struct accumulate *) handle;
+ struct string_hash_entry *sh;
+ unsigned long total;
+
+ /* The string table is written out from the hash table if this is a
+ final link. */
+ BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
+ *buff++ = '\0';
+ total = 1;
+ BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
+ for (sh = ainfo->ss_hash;
+ sh != (struct string_hash_entry *) NULL;
+ sh = sh->next)
+ {
+ size_t len;
+
+ len = strlen (sh->root.string);
+ memcpy (buff, (PTR) sh->root.string, len + 1);
+ total += len + 1;
+ buff += len + 1;
+ }
+
+ return true;
+}
diff --git a/bfd/ecoffswap.h b/bfd/ecoffswap.h
new file mode 100644
index 00000000000..0d28d16883e
--- /dev/null
+++ b/bfd/ecoffswap.h
@@ -0,0 +1,853 @@
+/* Generic ECOFF swapping routines, for BFD.
+ Copyright 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* NOTE: This is a header file, but it contains executable routines.
+ This is done this way because these routines are substantially
+ similar, but are not identical, for all ECOFF targets.
+
+ These are routines to swap the ECOFF symbolic information in and
+ out. The routines are defined statically. You can set breakpoints
+ on them in gdb by naming the including source file; e.g.,
+ 'coff-mips.c':ecoff_swap_hdr_in.
+
+ Before including this header file, one of ECOFF_32 or ECOFF_64 must
+ be defined. These are checked when swapping information that
+ depends upon the target size. This code works for 32 bit and 64
+ bit ECOFF, but may need to be generalized in the future.
+
+ Some header file which defines the external forms of these
+ structures must also be included before including this header file.
+ Currently this is either coff/mips.h or coff/alpha.h.
+
+ If the symbol TEST is defined when this file is compiled, a
+ comparison is made to ensure that, in fact, the output is
+ bit-for-bit the same as the input. Of course, this symbol should
+ only be defined when deliberately testing the code on a machine
+ with the proper byte sex and such. */
+
+#ifdef ECOFF_32
+#define ecoff_get_off bfd_h_get_32
+#define ecoff_put_off bfd_h_put_32
+#endif
+#ifdef ECOFF_64
+#define ecoff_get_off bfd_h_get_64
+#define ecoff_put_off bfd_h_put_64
+#endif
+
+/* ECOFF auxiliary information swapping routines. These are the same
+ for all ECOFF targets, so they are defined in ecofflink.c. */
+
+extern void _bfd_ecoff_swap_tir_in
+ PARAMS ((int, const struct tir_ext *, TIR *));
+extern void _bfd_ecoff_swap_tir_out
+ PARAMS ((int, const TIR *, struct tir_ext *));
+extern void _bfd_ecoff_swap_rndx_in
+ PARAMS ((int, const struct rndx_ext *, RNDXR *));
+extern void _bfd_ecoff_swap_rndx_out
+ PARAMS ((int, const RNDXR *, struct rndx_ext *));
+
+/* Prototypes for functions defined in this file. */
+
+static void ecoff_swap_hdr_in PARAMS ((bfd *, PTR, HDRR *));
+static void ecoff_swap_hdr_out PARAMS ((bfd *, const HDRR *, PTR));
+static void ecoff_swap_fdr_in PARAMS ((bfd *, PTR, FDR *));
+static void ecoff_swap_fdr_out PARAMS ((bfd *, const FDR *, PTR));
+static void ecoff_swap_pdr_in PARAMS ((bfd *, PTR, PDR *));
+static void ecoff_swap_pdr_out PARAMS ((bfd *, const PDR *, PTR));
+static void ecoff_swap_sym_in PARAMS ((bfd *, PTR, SYMR *));
+static void ecoff_swap_sym_out PARAMS ((bfd *, const SYMR *, PTR));
+static void ecoff_swap_ext_in PARAMS ((bfd *, PTR, EXTR *));
+static void ecoff_swap_ext_out PARAMS ((bfd *, const EXTR *, PTR));
+static void ecoff_swap_rfd_in PARAMS ((bfd *, PTR, RFDT *));
+static void ecoff_swap_rfd_out PARAMS ((bfd *, const RFDT *, PTR));
+static void ecoff_swap_opt_in PARAMS ((bfd *, PTR, OPTR *));
+static void ecoff_swap_opt_out PARAMS ((bfd *, const OPTR *, PTR));
+static void ecoff_swap_dnr_in PARAMS ((bfd *, PTR, DNR *));
+static void ecoff_swap_dnr_out PARAMS ((bfd *, const DNR *, PTR));
+
+/* Swap in the symbolic header. */
+
+static void
+ecoff_swap_hdr_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ HDRR *intern;
+{
+ struct hdr_ext ext[1];
+
+ *ext = *(struct hdr_ext *) ext_copy;
+
+ intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
+ intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
+ intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
+ intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
+ intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
+ intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
+ intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
+ intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
+ intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
+ intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
+ intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
+ intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
+ intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
+ intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
+ intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
+ intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
+ intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
+ intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
+ intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
+ intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
+ intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
+ intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
+ intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
+ intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
+ intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out the symbolic header. */
+
+static void
+ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const HDRR *intern_copy;
+ PTR ext_ptr;
+{
+ struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
+ HDRR intern[1];
+
+ *intern = *intern_copy;
+
+ bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
+ bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
+ bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
+ ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
+ ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
+ bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
+ ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
+ bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
+ ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
+ bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
+ ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
+ bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
+ ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
+ bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
+ ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
+ bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
+ ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
+ bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
+ ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
+ bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
+ ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
+ bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
+ ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
+ bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
+ ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap in the file descriptor record. */
+
+static void
+ecoff_swap_fdr_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ FDR *intern;
+{
+ struct fdr_ext ext[1];
+
+ *ext = *(struct fdr_ext *) ext_copy;
+
+ intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
+ intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
+#ifdef ECOFF_64
+ if (intern->rss == 0xffffffff)
+ intern->rss = -1;
+#endif
+ intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
+ intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
+ intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
+ intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
+ intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
+ intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
+ intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
+ intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
+#ifdef ECOFF_32
+ intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
+ intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
+#endif
+#ifdef ECOFF_64
+ intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
+ intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
+#endif
+ intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
+ intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
+ intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
+ intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
+
+ /* now the fun stuff... */
+ if (bfd_header_big_endian (abfd)) {
+ intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
+ >> FDR_BITS1_LANG_SH_BIG;
+ intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
+ intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
+ intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
+ intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
+ >> FDR_BITS2_GLEVEL_SH_BIG;
+ } else {
+ intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
+ >> FDR_BITS1_LANG_SH_LITTLE;
+ intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
+ intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
+ intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
+ intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
+ >> FDR_BITS2_GLEVEL_SH_LITTLE;
+ }
+ intern->reserved = 0;
+
+ intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
+ intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out the file descriptor record. */
+
+static void
+ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const FDR *intern_copy;
+ PTR ext_ptr;
+{
+ struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
+ FDR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
+ bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
+ bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
+ ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
+ bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
+ bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
+ bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
+ bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
+ bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
+ bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
+#ifdef ECOFF_32
+ bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
+ bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
+#endif
+#ifdef ECOFF_64
+ bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
+ bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
+#endif
+ bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
+ bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
+ bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
+ bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
+
+ /* now the fun stuff... */
+ if (bfd_header_big_endian (abfd)) {
+ ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
+ & FDR_BITS1_LANG_BIG)
+ | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
+ | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
+ | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
+ ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
+ & FDR_BITS2_GLEVEL_BIG);
+ ext->f_bits2[1] = 0;
+ ext->f_bits2[2] = 0;
+ } else {
+ ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
+ & FDR_BITS1_LANG_LITTLE)
+ | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
+ | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
+ | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
+ ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
+ & FDR_BITS2_GLEVEL_LITTLE);
+ ext->f_bits2[1] = 0;
+ ext->f_bits2[2] = 0;
+ }
+
+ ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
+ ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+#ifndef MPW_C
+
+/* Swap in the procedure descriptor record. */
+
+static void
+ecoff_swap_pdr_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ PDR *intern;
+{
+ struct pdr_ext ext[1];
+
+ *ext = *(struct pdr_ext *) ext_copy;
+
+ memset ((PTR) intern, 0, sizeof (*intern));
+
+ intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
+ intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
+ intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
+ intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
+ intern->regoffset = bfd_h_get_signed_32 (abfd,
+ (bfd_byte *)ext->p_regoffset);
+ intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
+ intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
+ intern->fregoffset = bfd_h_get_signed_32 (abfd,
+ (bfd_byte *)ext->p_fregoffset);
+ intern->frameoffset = bfd_h_get_signed_32 (abfd,
+ (bfd_byte *)ext->p_frameoffset);
+ intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
+ intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
+ intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
+ intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
+ intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
+
+#ifdef ECOFF_64
+ intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
+ if (bfd_header_big_endian (abfd))
+ {
+ intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
+ intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
+ intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG);
+ intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
+ << PDR_BITS1_RESERVED_SH_LEFT_BIG)
+ | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
+ >> PDR_BITS2_RESERVED_SH_BIG));
+ }
+ else
+ {
+ intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
+ intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
+ intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE);
+ intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
+ >> PDR_BITS1_RESERVED_SH_LITTLE)
+ | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
+ << PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
+ }
+ intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
+#endif
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out the procedure descriptor record. */
+
+static void
+ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const PDR *intern_copy;
+ PTR ext_ptr;
+{
+ struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
+ PDR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
+ bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
+ bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
+ bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
+ bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
+ bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
+ bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
+ bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
+ bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
+ bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
+ bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
+ bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
+ bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
+ ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
+
+#ifdef ECOFF_64
+ bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
+ if (bfd_header_big_endian (abfd))
+ {
+ ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
+ | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
+ | (intern->prof ? PDR_BITS1_PROF_BIG : 0)
+ | ((intern->reserved
+ >> PDR_BITS1_RESERVED_SH_LEFT_BIG)
+ & PDR_BITS1_RESERVED_BIG));
+ ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
+ & PDR_BITS2_RESERVED_BIG);
+ }
+ else
+ {
+ ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
+ | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
+ | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0)
+ | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
+ & PDR_BITS1_RESERVED_LITTLE));
+ ext->p_bits2[0] = ((intern->reserved >>
+ PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
+ & PDR_BITS2_RESERVED_LITTLE);
+ }
+ bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
+#endif
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+#else /* MPW_C */
+/* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
+ corrupt itself and then freak out. */
+/* Swap in the procedure descriptor record. */
+
+static void
+ecoff_swap_pdr_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ PDR *intern;
+{
+ struct pdr_ext ext[1];
+
+ *ext = *(struct pdr_ext *) ext_copy;
+
+ intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
+ intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
+ intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
+ intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
+ intern->regoffset = bfd_h_get_signed_32 (abfd,
+ (bfd_byte *)ext->p_regoffset);
+ intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
+ intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
+ intern->fregoffset = bfd_h_get_signed_32 (abfd,
+ (bfd_byte *)ext->p_fregoffset);
+ intern->frameoffset = bfd_h_get_signed_32 (abfd,
+ (bfd_byte *)ext->p_frameoffset);
+ intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
+ intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
+ intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
+ intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
+ intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out the procedure descriptor record. */
+
+static void
+ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const PDR *intern_copy;
+ PTR ext_ptr;
+{
+ struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
+ PDR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
+ bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
+ bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
+ bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
+ bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
+ bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
+ bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
+ bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
+ bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
+ bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
+ bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
+ bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
+ bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
+ ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+#endif /* MPW_C */
+
+/* Swap in a symbol record. */
+
+static void
+ecoff_swap_sym_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ SYMR *intern;
+{
+ struct sym_ext ext[1];
+
+ *ext = *(struct sym_ext *) ext_copy;
+
+ intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
+ intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
+
+ /* now the fun stuff... */
+ if (bfd_header_big_endian (abfd)) {
+ intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
+ >> SYM_BITS1_ST_SH_BIG;
+ intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
+ << SYM_BITS1_SC_SH_LEFT_BIG)
+ | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
+ >> SYM_BITS2_SC_SH_BIG);
+ intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
+ intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
+ << SYM_BITS2_INDEX_SH_LEFT_BIG)
+ | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
+ | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
+ } else {
+ intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
+ >> SYM_BITS1_ST_SH_LITTLE;
+ intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
+ >> SYM_BITS1_SC_SH_LITTLE)
+ | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
+ << SYM_BITS2_SC_SH_LEFT_LITTLE);
+ intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
+ intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
+ >> SYM_BITS2_INDEX_SH_LITTLE)
+ | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
+ | ((unsigned int) ext->s_bits4[0]
+ << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
+ }
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out a symbol record. */
+
+static void
+ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const SYMR *intern_copy;
+ PTR ext_ptr;
+{
+ struct sym_ext *ext = (struct sym_ext *) ext_ptr;
+ SYMR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
+ ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
+
+ /* now the fun stuff... */
+ if (bfd_header_big_endian (abfd)) {
+ ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
+ & SYM_BITS1_ST_BIG)
+ | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
+ & SYM_BITS1_SC_BIG));
+ ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
+ & SYM_BITS2_SC_BIG)
+ | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
+ | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
+ & SYM_BITS2_INDEX_BIG));
+ ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
+ ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
+ } else {
+ ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
+ & SYM_BITS1_ST_LITTLE)
+ | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
+ & SYM_BITS1_SC_LITTLE));
+ ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
+ & SYM_BITS2_SC_LITTLE)
+ | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
+ | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
+ & SYM_BITS2_INDEX_LITTLE));
+ ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
+ ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
+ }
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap in an external symbol record. */
+
+static void
+ecoff_swap_ext_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ EXTR *intern;
+{
+ struct ext_ext ext[1];
+
+ *ext = *(struct ext_ext *) ext_copy;
+
+ /* now the fun stuff... */
+ if (bfd_header_big_endian (abfd)) {
+ intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
+ intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
+ intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
+ } else {
+ intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
+ intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
+ intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
+ }
+ intern->reserved = 0;
+
+#ifdef ECOFF_32
+ intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
+#endif
+#ifdef ECOFF_64
+ intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
+#endif
+
+ ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out an external symbol record. */
+
+static void
+ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const EXTR *intern_copy;
+ PTR ext_ptr;
+{
+ struct ext_ext *ext = (struct ext_ext *) ext_ptr;
+ EXTR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ /* now the fun stuff... */
+ if (bfd_header_big_endian (abfd)) {
+ ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
+ | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
+ | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
+ ext->es_bits2[0] = 0;
+#ifdef ECOFF_64
+ ext->es_bits2[1] = 0;
+ ext->es_bits2[2] = 0;
+#endif
+ } else {
+ ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
+ | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
+ | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
+ ext->es_bits2[0] = 0;
+#ifdef ECOFF_64
+ ext->es_bits2[1] = 0;
+ ext->es_bits2[2] = 0;
+#endif
+ }
+
+#ifdef ECOFF_32
+ bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
+#endif
+#ifdef ECOFF_64
+ bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
+#endif
+
+ ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap in a relative file descriptor. */
+
+static void
+ecoff_swap_rfd_in (abfd, ext_ptr, intern)
+ bfd *abfd;
+ PTR ext_ptr;
+ RFDT *intern;
+{
+ struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
+
+ *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out a relative file descriptor. */
+
+static void
+ecoff_swap_rfd_out (abfd, intern, ext_ptr)
+ bfd *abfd;
+ const RFDT *intern;
+ PTR ext_ptr;
+{
+ struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
+
+ bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap in an optimization symbol. */
+
+static void
+ecoff_swap_opt_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ OPTR *intern;
+{
+ struct opt_ext ext[1];
+
+ *ext = *(struct opt_ext *) ext_copy;
+
+ if (bfd_header_big_endian (abfd))
+ {
+ intern->ot = ext->o_bits1[0];
+ intern->value = (((unsigned int) ext->o_bits2[0]
+ << OPT_BITS2_VALUE_SH_LEFT_BIG)
+ | ((unsigned int) ext->o_bits3[0]
+ << OPT_BITS2_VALUE_SH_LEFT_BIG)
+ | ((unsigned int) ext->o_bits4[0]
+ << OPT_BITS2_VALUE_SH_LEFT_BIG));
+ }
+ else
+ {
+ intern->ot = ext->o_bits1[0];
+ intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
+ | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
+ | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
+ }
+
+ _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd),
+ &ext->o_rndx, &intern->rndx);
+
+ intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out an optimization symbol. */
+
+static void
+ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const OPTR *intern_copy;
+ PTR ext_ptr;
+{
+ struct opt_ext *ext = (struct opt_ext *) ext_ptr;
+ OPTR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ if (bfd_header_big_endian (abfd))
+ {
+ ext->o_bits1[0] = intern->ot;
+ ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
+ ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
+ ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
+ }
+ else
+ {
+ ext->o_bits1[0] = intern->ot;
+ ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
+ ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
+ ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
+ }
+
+ _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd),
+ &intern->rndx, &ext->o_rndx);
+
+ bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap in a dense number. */
+
+static void
+ecoff_swap_dnr_in (abfd, ext_copy, intern)
+ bfd *abfd;
+ PTR ext_copy;
+ DNR *intern;
+{
+ struct dnr_ext ext[1];
+
+ *ext = *(struct dnr_ext *) ext_copy;
+
+ intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
+ intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
+
+/* Swap out a dense number. */
+
+static void
+ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
+ bfd *abfd;
+ const DNR *intern_copy;
+ PTR ext_ptr;
+{
+ struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
+ DNR intern[1];
+
+ *intern = *intern_copy; /* Make it reasonable to do in-place. */
+
+ bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
+ bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
+
+#ifdef TEST
+ if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ abort();
+#endif
+}
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
new file mode 100644
index 00000000000..82ffe2add97
--- /dev/null
+++ b/bfd/elf-bfd.h
@@ -0,0 +1,1114 @@
+/* BFD back-end data structures for ELF files.
+ Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _LIBELF_H_
+#define _LIBELF_H_ 1
+
+#include "elf/common.h"
+#include "elf/internal.h"
+#include "elf/external.h"
+#include "bfdlink.h"
+
+/* If size isn't specified as 64 or 32, NAME macro should fail. */
+#ifndef NAME
+#if ARCH_SIZE==64
+#define NAME(x,y) CAT4(x,64,_,y)
+#endif
+#if ARCH_SIZE==32
+#define NAME(x,y) CAT4(x,32,_,y)
+#endif
+#endif
+
+#ifndef NAME
+#define NAME(x,y) CAT4(x,NOSIZE,_,y)
+#endif
+
+#define ElfNAME(X) NAME(Elf,X)
+#define elfNAME(X) NAME(elf,X)
+
+/* Information held for an ELF symbol. The first field is the
+ corresponding asymbol. Every symbol is an ELF file is actually a
+ pointer to this structure, although it is often handled as a
+ pointer to an asymbol. */
+
+typedef struct
+{
+ /* The BFD symbol. */
+ asymbol symbol;
+ /* ELF symbol information. */
+ Elf_Internal_Sym internal_elf_sym;
+ /* Backend specific information. */
+ union
+ {
+ unsigned int hppa_arg_reloc;
+ PTR mips_extr;
+ PTR any;
+ }
+ tc_data;
+
+ /* Version information. This is from an Elf_Internal_Versym
+ structure in a SHT_GNU_versym section. It is zero if there is no
+ version information. */
+ unsigned short version;
+
+} elf_symbol_type;
+
+/* ELF linker hash table entries. */
+
+struct elf_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+
+ /* Symbol index in output file. This is initialized to -1. It is
+ set to -2 if the symbol is used by a reloc. */
+ long indx;
+
+ /* Symbol size. */
+ bfd_size_type size;
+
+ /* Symbol index as a dynamic symbol. Initialized to -1, and remains
+ -1 if this is not a dynamic symbol. */
+ long dynindx;
+
+ /* String table index in .dynstr if this is a dynamic symbol. */
+ unsigned long dynstr_index;
+
+ /* If this is a weak defined symbol from a dynamic object, this
+ field points to a defined symbol with the same value, if there is
+ one. Otherwise it is NULL. */
+ struct elf_link_hash_entry *weakdef;
+
+ /* If this symbol requires an entry in the global offset table, the
+ processor specific backend uses this field to track usage and
+ final offset. We use a union and two names primarily to document
+ the intent of any particular piece of code. The field should be
+ used as a count until size_dynamic_sections, at which point the
+ contents of the .got is fixed. Afterward, if this field is -1,
+ then the symbol does not require a global offset table entry. */
+ union
+ {
+ bfd_signed_vma refcount;
+ bfd_vma offset;
+ } got;
+
+ /* Same, but tracks a procedure linkage table entry. */
+ union
+ {
+ bfd_signed_vma refcount;
+ bfd_vma offset;
+ } plt;
+
+ /* If this symbol is used in the linker created sections, the processor
+ specific backend uses this field to map the field into the offset
+ from the beginning of the section. */
+ struct elf_linker_section_pointers *linker_section_pointer;
+
+ /* Version information. */
+ union
+ {
+ /* This field is used for a symbol which is not defined in a
+ regular object. It points to the version information read in
+ from the dynamic object. */
+ Elf_Internal_Verdef *verdef;
+ /* This field is used for a symbol which is defined in a regular
+ object. It is set up in size_dynamic_sections. It points to
+ the version information we should write out for this symbol. */
+ struct bfd_elf_version_tree *vertree;
+ } verinfo;
+
+ /* Virtual table entry use information. This array is nominally of size
+ size/sizeof(target_void_pointer), though we have to be able to assume
+ and track a size while the symbol is still undefined. It is indexed
+ via offset/sizeof(target_void_pointer). */
+ size_t vtable_entries_size;
+ boolean *vtable_entries_used;
+
+ /* Virtual table derivation info. */
+ struct elf_link_hash_entry *vtable_parent;
+
+ /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
+ char type;
+
+ /* Symbol st_other value. */
+ unsigned char other;
+
+ /* Hash value of the name computed using the ELF hash function. */
+ unsigned long elf_hash_value;
+
+ /* Some flags; legal values follow. */
+ unsigned short elf_link_hash_flags;
+ /* Symbol is referenced by a non-shared object. */
+#define ELF_LINK_HASH_REF_REGULAR 01
+ /* Symbol is defined by a non-shared object. */
+#define ELF_LINK_HASH_DEF_REGULAR 02
+ /* Symbol is referenced by a shared object. */
+#define ELF_LINK_HASH_REF_DYNAMIC 04
+ /* Symbol is defined by a shared object. */
+#define ELF_LINK_HASH_DEF_DYNAMIC 010
+ /* Symbol has a non-weak reference from a non-shared object. */
+#define ELF_LINK_HASH_REF_REGULAR_NONWEAK 020
+ /* Dynamic symbol has been adjustd. */
+#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 040
+ /* Symbol needs a copy reloc. */
+#define ELF_LINK_HASH_NEEDS_COPY 0100
+ /* Symbol needs a procedure linkage table entry. */
+#define ELF_LINK_HASH_NEEDS_PLT 0200
+ /* Symbol appears in a non-ELF input file. */
+#define ELF_LINK_NON_ELF 0400
+ /* Symbol should be marked as hidden in the version information. */
+#define ELF_LINK_HIDDEN 01000
+ /* Symbol was forced to local scope due to a version script file. */
+#define ELF_LINK_FORCED_LOCAL 02000
+ /* Symbol was marked during garbage collection. */
+#define ELF_LINK_HASH_MARK 04000
+};
+
+/* ELF linker hash table. */
+
+struct elf_link_hash_table
+{
+ struct bfd_link_hash_table root;
+ /* Whether we have created the special dynamic sections required
+ when linking against or generating a shared object. */
+ boolean dynamic_sections_created;
+ /* The BFD used to hold special sections created by the linker.
+ This will be the first BFD found which requires these sections to
+ be created. */
+ bfd *dynobj;
+ /* The number of symbols found in the link which must be put into
+ the .dynsym section. */
+ bfd_size_type dynsymcount;
+ /* The string table of dynamic symbols, which becomes the .dynstr
+ section. */
+ struct bfd_strtab_hash *dynstr;
+ /* The number of buckets in the hash table in the .hash section.
+ This is based on the number of dynamic symbols. */
+ bfd_size_type bucketcount;
+ /* A linked list of DT_NEEDED names found in dynamic objects
+ included in the link. */
+ struct bfd_link_needed_list *needed;
+ /* The _GLOBAL_OFFSET_TABLE_ symbol. */
+ struct elf_link_hash_entry *hgot;
+ /* A pointer to information used to link stabs in sections. */
+ PTR stab_info;
+};
+
+/* Look up an entry in an ELF linker hash table. */
+
+#define elf_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct elf_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+/* Traverse an ELF linker hash table. */
+
+#define elf_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the ELF linker hash table from a link_info structure. */
+
+#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
+
+/* Constant information held for an ELF backend. */
+
+struct elf_size_info {
+ unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
+ unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
+
+ unsigned char arch_size, file_align;
+ unsigned char elfclass, ev_current;
+ int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
+ boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
+ void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
+ void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
+ boolean (*slurp_reloc_table)
+ PARAMS ((bfd *, asection *, asymbol **, boolean));
+ long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
+ void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
+};
+
+#define elf_symbol_from(ABFD,S) \
+ (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
+ && (S)->the_bfd->tdata.elf_obj_data != 0) \
+ ? (elf_symbol_type *) (S) \
+ : 0)
+
+struct elf_backend_data
+{
+ /* Whether the backend uses REL or RELA relocations. FIXME: some
+ ELF backends use both. When we need to support one, this whole
+ approach will need to be changed. */
+ int use_rela_p;
+
+ /* The architecture for this backend. */
+ enum bfd_architecture arch;
+
+ /* The ELF machine code (EM_xxxx) for this backend. */
+ int elf_machine_code;
+
+ /* The maximum page size for this backend. */
+ bfd_vma maxpagesize;
+
+ /* This is true if the linker should act like collect and gather
+ global constructors and destructors by name. This is true for
+ MIPS ELF because the Irix 5 tools can not handle the .init
+ section. */
+ boolean collect;
+
+ /* This is true if the linker should ignore changes to the type of a
+ symbol. This is true for MIPS ELF because some Irix 5 objects
+ record undefined functions as STT_OBJECT although the definitions
+ are STT_FUNC. */
+ boolean type_change_ok;
+
+ /* A function to translate an ELF RELA relocation to a BFD arelent
+ structure. */
+ void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
+ Elf_Internal_Rela *));
+
+ /* A function to translate an ELF REL relocation to a BFD arelent
+ structure. */
+ void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
+ Elf_Internal_Rel *));
+
+ /* A function to determine whether a symbol is global when
+ partitioning the symbol table into local and global symbols.
+ This should be NULL for most targets, in which case the correct
+ thing will be done. MIPS ELF, at least on the Irix 5, has
+ special requirements. */
+ boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
+
+ /* The remaining functions are hooks which are called only if they
+ are not NULL. */
+
+ /* A function to permit a backend specific check on whether a
+ particular BFD format is relevant for an object file, and to
+ permit the backend to set any global information it wishes. When
+ this is called elf_elfheader is set, but anything else should be
+ used with caution. If this returns false, the check_format
+ routine will return a bfd_error_wrong_format error. */
+ boolean (*elf_backend_object_p) PARAMS ((bfd *));
+
+ /* A function to do additional symbol processing when reading the
+ ELF symbol table. This is where any processor-specific special
+ section indices are handled. */
+ void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
+
+ /* A function to do additional symbol processing after reading the
+ entire ELF symbol table. */
+ boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
+ elf_symbol_type *,
+ unsigned int));
+
+ /* A function to set the type of the info field. Processor-specific
+ types should be handled here. */
+ int (*elf_backend_get_symbol_type) PARAMS (( Elf_Internal_Sym *, int));
+
+ /* A function to do additional processing on the ELF section header
+ just before writing it out. This is used to set the flags and
+ type fields for some sections, or to actually write out data for
+ unusual sections. */
+ boolean (*elf_backend_section_processing) PARAMS ((bfd *,
+ Elf32_Internal_Shdr *));
+
+ /* A function to handle unusual section types when creating BFD
+ sections from ELF sections. */
+ boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
+ Elf32_Internal_Shdr *,
+ char *));
+
+ /* A function to set up the ELF section header for a BFD section in
+ preparation for writing it out. This is where the flags and type
+ fields are set for unusual sections. */
+ boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
+ asection *));
+
+ /* A function to get the ELF section index for a BFD section. If
+ this returns true, the section was found. If it is a normal ELF
+ section, *RETVAL should be left unchanged. If it is not a normal
+ ELF section *RETVAL should be set to the SHN_xxxx index. */
+ boolean (*elf_backend_section_from_bfd_section)
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
+
+ /* If this field is not NULL, it is called by the add_symbols phase
+ of a link just before adding a symbol to the global linker hash
+ table. It may modify any of the fields as it wishes. If *NAME
+ is set to NULL, the symbol will be skipped rather than being
+ added to the hash table. This function is responsible for
+ handling all processor dependent symbol bindings and section
+ indices, and must set at least *FLAGS and *SEC for each processor
+ dependent case; failure to do so will cause a link error. */
+ boolean (*elf_add_symbol_hook)
+ PARAMS ((bfd *abfd, struct bfd_link_info *info,
+ const Elf_Internal_Sym *, const char **name,
+ flagword *flags, asection **sec, bfd_vma *value));
+
+ /* If this field is not NULL, it is called by the elf_link_output_sym
+ phase of a link for each symbol which will appear in the object file. */
+ boolean (*elf_backend_link_output_symbol_hook)
+ PARAMS ((bfd *, struct bfd_link_info *info, const char *,
+ Elf_Internal_Sym *, asection *));
+
+ /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
+ linker the first time it encounters a dynamic object in the link.
+ This function must create any sections required for dynamic
+ linking. The ABFD argument is a dynamic object. The .interp,
+ .dynamic, .dynsym, .dynstr, and .hash functions have already been
+ created, and this function may modify the section flags if
+ desired. This function will normally create the .got and .plt
+ sections, but different backends have different requirements. */
+ boolean (*elf_backend_create_dynamic_sections)
+ PARAMS ((bfd *abfd, struct bfd_link_info *info));
+
+ /* The CHECK_RELOCS function is called by the add_symbols phase of
+ the ELF backend linker. It is called once for each section with
+ relocs of an object file, just after the symbols for the object
+ file have been added to the global linker hash table. The
+ function must look through the relocs and do any special handling
+ required. This generally means allocating space in the global
+ offset table, and perhaps allocating space for a reloc. The
+ relocs are always passed as Rela structures; if the section
+ actually uses Rel structures, the r_addend field will always be
+ zero. */
+ boolean (*check_relocs)
+ PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
+ const Elf_Internal_Rela *relocs));
+
+ /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
+ linker for every symbol which is defined by a dynamic object and
+ referenced by a regular object. This is called after all the
+ input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
+ function has been called. The hash table entry should be
+ bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
+ defined in a section from a dynamic object. Dynamic object
+ sections are not included in the final link, and this function is
+ responsible for changing the value to something which the rest of
+ the link can deal with. This will normally involve adding an
+ entry to the .plt or .got or some such section, and setting the
+ symbol to point to that. */
+ boolean (*elf_backend_adjust_dynamic_symbol)
+ PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
+
+ /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
+ after all the linker input files have been seen but before the
+ section sizes have been set. This is called after
+ ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
+ boolean (*elf_backend_always_size_sections)
+ PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
+
+ /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
+ linker after all the linker input files have been seen but before
+ the sections sizes have been set. This is called after
+ ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
+ It is only called when linking against a dynamic object. It must
+ set the sizes of the dynamic sections, and may fill in their
+ contents as well. The generic ELF linker can handle the .dynsym,
+ .dynstr and .hash sections. This function must handle the
+ .interp section and any sections created by the
+ CREATE_DYNAMIC_SECTIONS entry point. */
+ boolean (*elf_backend_size_dynamic_sections)
+ PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
+
+ /* The RELOCATE_SECTION function is called by the ELF backend linker
+ to handle the relocations for a section.
+
+ The relocs are always passed as Rela structures; if the section
+ actually uses Rel structures, the r_addend field will always be
+ zero.
+
+ This function is responsible for adjust the section contents as
+ necessary, and (if using Rela relocs and generating a
+ relocateable output file) adjusting the reloc addend as
+ necessary.
+
+ This function does not have to worry about setting the reloc
+ address or the reloc symbol index.
+
+ LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+ LOCAL_SECTIONS is an array giving the section in the input file
+ corresponding to the st_shndx field of each local symbol.
+
+ The global hash table entry for the global symbols can be found
+ via elf_sym_hashes (input_bfd).
+
+ When generating relocateable output, this function must handle
+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
+ going to be the section symbol corresponding to the output
+ section, which means that the addend must be adjusted
+ accordingly. */
+ boolean (*elf_backend_relocate_section)
+ PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
+ bfd *input_bfd, asection *input_section, bfd_byte *contents,
+ Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
+ asection **local_sections));
+
+ /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
+ linker just before it writes a symbol out to the .dynsym section.
+ The processor backend may make any required adjustment to the
+ symbol. It may also take the opportunity to set contents of the
+ dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
+ all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
+ on those symbols which are defined by a dynamic object. */
+ boolean (*elf_backend_finish_dynamic_symbol)
+ PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
+ struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
+
+ /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
+ linker just before it writes all the dynamic sections out to the
+ output file. The FINISH_DYNAMIC_SYMBOL will have been called on
+ all dynamic symbols. */
+ boolean (*elf_backend_finish_dynamic_sections)
+ PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
+
+ /* A function to do any beginning processing needed for the ELF file
+ before building the ELF headers and computing file positions. */
+ void (*elf_backend_begin_write_processing)
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+ /* A function to do any final processing needed for the ELF file
+ before writing it out. The LINKER argument is true if this BFD
+ was created by the ELF backend linker. */
+ void (*elf_backend_final_write_processing)
+ PARAMS ((bfd *, boolean linker));
+
+ /* This function is called by get_program_header_size. It should
+ return the number of additional program segments which this BFD
+ will need. It should return -1 on error. */
+ int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
+
+ /* This function is called to modify an existing segment map in a
+ backend specific fashion. */
+ boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
+
+ /* This function is called during section gc to discover the section a
+ particular relocation refers to. It need not be defined for hosts
+ that have no queer relocation types. */
+ asection * (*gc_mark_hook)
+ PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *h, Elf_Internal_Sym *));
+
+ /* This function, if defined, is called during the sweep phase of gc
+ in order that a backend might update any data structures it might
+ be maintaining. */
+ boolean (*gc_sweep_hook)
+ PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
+ const Elf_Internal_Rela *relocs));
+
+ /* The swapping table to use when dealing with ECOFF information.
+ Used for the MIPS ELF .mdebug section. */
+ const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
+
+ /* Alternate EM_xxxx machine codes for this backend. */
+ int elf_machine_alt1;
+ int elf_machine_alt2;
+
+ const struct elf_size_info *s;
+
+ /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
+ .got section */
+ bfd_vma got_symbol_offset;
+
+ /* The size in bytes of the headers for the GOT and PLT. This includes
+ the so-called reserved entries on some systems. */
+ bfd_vma got_header_size;
+ bfd_vma plt_header_size;
+
+ unsigned want_got_plt : 1;
+ unsigned plt_readonly : 1;
+ unsigned want_plt_sym : 1;
+ unsigned plt_not_loaded : 1;
+ unsigned plt_alignment : 4;
+ unsigned can_gc_sections : 1;
+};
+
+/* Information stored for each BFD section in an ELF file. This
+ structure is allocated by elf_new_section_hook. */
+
+struct bfd_elf_section_data
+{
+ /* The ELF header for this section. */
+ Elf_Internal_Shdr this_hdr;
+ /* The ELF header for the reloc section associated with this
+ section, if any. */
+ Elf_Internal_Shdr rel_hdr;
+ /* If there is a second reloc section associated with this section,
+ as can happen on Irix 6, this field points to the header. */
+ Elf_Internal_Shdr *rel_hdr2;
+ /* The ELF section number of this section. Only used for an output
+ file. */
+ int this_idx;
+ /* The ELF section number of the reloc section associated with this
+ section, if any. Only used for an output file. */
+ int rel_idx;
+ /* Used by the backend linker to store the symbol hash table entries
+ associated with relocs against global symbols. */
+ struct elf_link_hash_entry **rel_hashes;
+ /* A pointer to the swapped relocs. If the section uses REL relocs,
+ rather than RELA, all the r_addend fields will be zero. This
+ pointer may be NULL. It is used by the backend linker. */
+ Elf_Internal_Rela *relocs;
+ /* Used by the backend linker when generating a shared library to
+ record the dynamic symbol index for a section symbol
+ corresponding to this section. */
+ long dynindx;
+ /* A pointer used for .stab linking optimizations. */
+ PTR stab_info;
+ /* A pointer available for the processor specific ELF backend. */
+ PTR tdata;
+};
+
+#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
+
+#define get_elf_backend_data(abfd) \
+ ((struct elf_backend_data *) (abfd)->xvec->backend_data)
+
+/* Enumeration to specify the special section. */
+typedef enum elf_linker_section_enum
+{
+ LINKER_SECTION_UNKNOWN, /* not used */
+ LINKER_SECTION_GOT, /* .got section for global offset pointers */
+ LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
+ LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
+ LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
+ LINKER_SECTION_MAX /* # of linker sections */
+} elf_linker_section_enum_t;
+
+/* Sections created by the linker. */
+
+typedef struct elf_linker_section
+{
+ char *name; /* name of the section */
+ char *rel_name; /* name of the associated .rel{,a}. section */
+ char *bss_name; /* name of a related .bss section */
+ char *sym_name; /* name of symbol to reference this section */
+ asection *section; /* pointer to the section */
+ asection *bss_section; /* pointer to the bss section associated with this */
+ asection *rel_section; /* pointer to the relocations needed for this section */
+ struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
+ bfd_vma initial_size; /* initial size before any linker generated allocations */
+ bfd_vma sym_offset; /* offset of symbol from beginning of section */
+ bfd_vma hole_size; /* size of reserved address hole in allocation */
+ bfd_vma hole_offset; /* current offset for the hole */
+ bfd_vma max_hole_offset; /* maximum offset for the hole */
+ elf_linker_section_enum_t which; /* which section this is */
+ boolean hole_written_p; /* whether the hole has been initialized */
+ unsigned int alignment; /* alignment for the section */
+ flagword flags; /* flags to use to create the section */
+} elf_linker_section_t;
+
+/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
+ provides allows us to return different pointers, based on different addend's. */
+
+typedef struct elf_linker_section_pointers
+{
+ struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
+ bfd_vma offset; /* offset of pointer from beginning of section */
+ bfd_signed_vma addend; /* addend used */
+ elf_linker_section_enum_t which; /* which linker section this is */
+ boolean written_address_p; /* whether address was written yet */
+} elf_linker_section_pointers_t;
+
+/* Some private data is stashed away for future use using the tdata pointer
+ in the bfd structure. */
+
+struct elf_obj_tdata
+{
+ Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
+ Elf_Internal_Shdr **elf_sect_ptr;
+ Elf_Internal_Phdr *phdr;
+ struct elf_segment_map *segment_map;
+ struct bfd_strtab_hash *strtab_ptr;
+ int num_locals;
+ int num_globals;
+ asymbol **section_syms; /* STT_SECTION symbols for each section */
+ Elf_Internal_Shdr symtab_hdr;
+ Elf_Internal_Shdr shstrtab_hdr;
+ Elf_Internal_Shdr strtab_hdr;
+ Elf_Internal_Shdr dynsymtab_hdr;
+ Elf_Internal_Shdr dynstrtab_hdr;
+ Elf_Internal_Shdr dynversym_hdr;
+ Elf_Internal_Shdr dynverref_hdr;
+ Elf_Internal_Shdr dynverdef_hdr;
+ unsigned int symtab_section, shstrtab_section;
+ unsigned int strtab_section, dynsymtab_section;
+ unsigned int dynversym_section, dynverdef_section, dynverref_section;
+ file_ptr next_file_pos;
+#if 0
+ /* we don't need these inside bfd anymore, and I think
+ these weren't used outside bfd. */
+ void *prstatus; /* The raw /proc prstatus structure */
+ void *prpsinfo; /* The raw /proc prpsinfo structure */
+#endif
+ bfd_vma gp; /* The gp value (MIPS only, for now) */
+ unsigned int gp_size; /* The gp size (MIPS only, for now) */
+
+ /* Information grabbed from an elf core file. */
+ int core_signal;
+ int core_pid;
+ int core_lwpid;
+ char* core_program;
+ char* core_command;
+
+ /* This is set to true if the object was created by the backend
+ linker. */
+ boolean linker;
+
+ /* A mapping from external symbols to entries in the linker hash
+ table, used when linking. This is indexed by the symbol index
+ minus the sh_info field of the symbol table header. */
+ struct elf_link_hash_entry **sym_hashes;
+
+ /* A mapping from local symbols to offsets into the global offset
+ table, used when linking. This is indexed by the symbol index.
+ Like for the globals, we use a union and two names primarily to
+ document the intent of any particular piece of code. The field
+ should be used as a count until size_dynamic_sections, at which
+ point the contents of the .got is fixed. Afterward, if an entry
+ is -1, then the symbol does not require a global offset table entry. */
+ union
+ {
+ bfd_signed_vma *refcounts;
+ bfd_vma *offsets;
+ } local_got;
+
+ /* A mapping from local symbols to offsets into the various linker
+ sections added. This is index by the symbol index. */
+ elf_linker_section_pointers_t **linker_section_pointers;
+
+ /* The linker ELF emulation code needs to let the backend ELF linker
+ know what filename should be used for a dynamic object if the
+ dynamic object is found using a search. The emulation code then
+ sometimes needs to know what name was actually used. Until the
+ file has been added to the linker symbol table, this field holds
+ the name the linker wants. After it has been added, it holds the
+ name actually used, which will be the DT_SONAME entry if there is
+ one. */
+ const char *dt_name;
+
+ /* Irix 5 often screws up the symbol table, sorting local symbols
+ after global symbols. This flag is set if the symbol table in
+ this BFD appears to be screwed up. If it is, we ignore the
+ sh_info field in the symbol table header, and always read all the
+ symbols. */
+ boolean bad_symtab;
+
+ /* Records the result of `get_program_header_size'. */
+ bfd_size_type program_header_size;
+
+ /* Used by find_nearest_line entry point. */
+ PTR line_info;
+
+ /* Used by MIPS ELF find_nearest_line entry point. The structure
+ could be included directly in this one, but there's no point to
+ wasting the memory just for the infrequently called
+ find_nearest_line. */
+ struct mips_elf_find_line *find_line_info;
+
+ /* A place to stash dwarf1 info for this bfd. */
+ struct dwarf1_debug *dwarf1_find_line_info;
+
+ /* A place to stash dwarf2 info for this bfd. */
+ struct dwarf2_debug *dwarf2_find_line_info;
+
+ /* An array of stub sections indexed by symbol number, used by the
+ MIPS ELF linker. FIXME: We should figure out some way to only
+ include this field for a MIPS ELF target. */
+ asection **local_stubs;
+
+ /* Used to determine if the e_flags field has been initialized */
+ boolean flags_init;
+
+ /* Number of symbol version definitions we are about to emit. */
+ unsigned int cverdefs;
+
+ /* Number of symbol version references we are about to emit. */
+ unsigned int cverrefs;
+
+ /* Symbol version definitions in external objects. */
+ Elf_Internal_Verdef *verdef;
+
+ /* Symbol version references to external objects. */
+ Elf_Internal_Verneed *verref;
+
+ /* Linker sections that we are interested in. */
+ struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
+};
+
+#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
+#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
+#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
+#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
+#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
+#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
+#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
+#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
+#define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
+#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
+#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
+#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
+#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
+#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
+#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
+#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
+#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
+#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
+#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
+#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
+#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
+#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
+#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
+#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
+
+extern void _bfd_elf_swap_verdef_in
+ PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
+extern void _bfd_elf_swap_verdef_out
+ PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
+extern void _bfd_elf_swap_verdaux_in
+ PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
+extern void _bfd_elf_swap_verdaux_out
+ PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
+extern void _bfd_elf_swap_verneed_in
+ PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
+extern void _bfd_elf_swap_verneed_out
+ PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
+extern void _bfd_elf_swap_vernaux_in
+ PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
+extern void _bfd_elf_swap_vernaux_out
+ PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
+extern void _bfd_elf_swap_versym_in
+ PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
+extern void _bfd_elf_swap_versym_out
+ PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
+
+extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
+extern char *bfd_elf_string_from_elf_section
+ PARAMS ((bfd *, unsigned, unsigned));
+extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
+
+extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
+extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
+ bfd_print_symbol_type));
+#define elf_string_from_elf_strtab(abfd,strindex) \
+ bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
+
+#define bfd_elf32_print_symbol bfd_elf_print_symbol
+#define bfd_elf64_print_symbol bfd_elf_print_symbol
+
+extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *));
+
+extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
+ arelent *,
+ asymbol *,
+ PTR,
+ asection *,
+ bfd *,
+ char **));
+extern boolean bfd_elf_mkobject PARAMS ((bfd *));
+extern boolean bfd_elf_mkcorefile PARAMS ((bfd *));
+extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
+extern boolean _bfd_elf_make_section_from_shdr
+ PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
+extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
+ PARAMS ((bfd *));
+extern boolean _bfd_elf_link_hash_table_init
+ PARAMS ((struct elf_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));
+
+extern boolean _bfd_elf_copy_private_symbol_data
+ PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
+extern boolean _bfd_elf_copy_private_section_data
+ PARAMS ((bfd *, asection *, bfd *, asection *));
+extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
+extern boolean _bfd_elf_write_corefile_contents PARAMS ((bfd *));
+extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr,
+ bfd_size_type));
+extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
+extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
+extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
+extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
+extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
+extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
+ arelent **, asymbol **));
+extern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
+extern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **,
+ asymbol **));
+extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
+extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
+ symbol_info *));
+extern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *));
+extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
+extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
+ unsigned long));
+extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
+ asymbol **,
+ bfd_vma, CONST char **,
+ CONST char **,
+ unsigned int *));
+#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
+#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
+extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
+
+/* If the target doesn't have reloc handling written yet: */
+extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
+ Elf_Internal_Rela *));
+
+extern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
+extern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int));
+
+extern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
+
+asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
+boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
+ struct bfd_link_info *));
+struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
+boolean
+_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
+ struct elf_link_hash_entry *));
+boolean
+_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
+ struct bfd_link_info *));
+void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
+file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
+ file_ptr,
+ boolean));
+
+extern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
+
+boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
+ struct bfd_link_info *));
+boolean _bfd_elf_create_got_section PARAMS ((bfd *,
+ struct bfd_link_info *));
+
+elf_linker_section_t *_bfd_elf_create_linker_section
+ PARAMS ((bfd *abfd,
+ struct bfd_link_info *info,
+ enum elf_linker_section_enum,
+ elf_linker_section_t *defaults));
+
+elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
+ PARAMS ((elf_linker_section_pointers_t *linker_pointers,
+ bfd_signed_vma addend,
+ elf_linker_section_enum_t which));
+
+boolean bfd_elf32_create_pointer_linker_section
+ PARAMS ((bfd *abfd,
+ struct bfd_link_info *info,
+ elf_linker_section_t *lsect,
+ struct elf_link_hash_entry *h,
+ const Elf32_Internal_Rela *rel));
+
+bfd_vma bfd_elf32_finish_pointer_linker_section
+ PARAMS ((bfd *output_abfd,
+ bfd *input_bfd,
+ struct bfd_link_info *info,
+ elf_linker_section_t *lsect,
+ struct elf_link_hash_entry *h,
+ bfd_vma relocation,
+ const Elf32_Internal_Rela *rel,
+ int relative_reloc));
+
+boolean bfd_elf64_create_pointer_linker_section
+ PARAMS ((bfd *abfd,
+ struct bfd_link_info *info,
+ elf_linker_section_t *lsect,
+ struct elf_link_hash_entry *h,
+ const Elf64_Internal_Rela *rel));
+
+bfd_vma bfd_elf64_finish_pointer_linker_section
+ PARAMS ((bfd *output_abfd,
+ bfd *input_bfd,
+ struct bfd_link_info *info,
+ elf_linker_section_t *lsect,
+ struct elf_link_hash_entry *h,
+ bfd_vma relocation,
+ const Elf64_Internal_Rela *rel,
+ int relative_reloc));
+
+boolean _bfd_elf_make_linker_section_rela
+ PARAMS ((bfd *dynobj,
+ elf_linker_section_t *lsect,
+ int alignment));
+
+boolean _bfd_elfcore_section_from_phdr
+ PARAMS ((bfd *, Elf_Internal_Phdr *, int));
+
+extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
+extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
+extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
+extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
+extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
+ bfd *));
+
+extern boolean bfd_elf32_bfd_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_elf32_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+extern void bfd_elf32_swap_symbol_in
+ PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
+extern void bfd_elf32_swap_symbol_out
+ PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
+extern void bfd_elf32_swap_reloc_in
+ PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
+extern void bfd_elf32_swap_reloc_out
+ PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
+extern void bfd_elf32_swap_reloca_in
+ PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
+extern void bfd_elf32_swap_reloca_out
+ PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
+extern void bfd_elf32_swap_phdr_in
+ PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
+extern void bfd_elf32_swap_phdr_out
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
+extern void bfd_elf32_swap_dyn_in
+ PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
+extern void bfd_elf32_swap_dyn_out
+ PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf32_External_Dyn *));
+extern long bfd_elf32_slurp_symbol_table
+ PARAMS ((bfd *, asymbol **, boolean));
+extern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
+extern int bfd_elf32_write_out_phdrs
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
+extern boolean bfd_elf32_add_dynamic_entry
+ PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
+extern boolean bfd_elf32_link_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
+ PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
+
+extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
+extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
+extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
+extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
+extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
+ bfd *));
+extern boolean bfd_elf64_bfd_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_elf64_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+extern void bfd_elf64_swap_symbol_in
+ PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
+extern void bfd_elf64_swap_symbol_out
+ PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
+extern void bfd_elf64_swap_reloc_in
+ PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
+extern void bfd_elf64_swap_reloc_out
+ PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
+extern void bfd_elf64_swap_reloca_in
+ PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
+extern void bfd_elf64_swap_reloca_out
+ PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
+extern void bfd_elf64_swap_phdr_in
+ PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
+extern void bfd_elf64_swap_phdr_out
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
+extern void bfd_elf64_swap_dyn_in
+ PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
+extern void bfd_elf64_swap_dyn_out
+ PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf64_External_Dyn *));
+extern long bfd_elf64_slurp_symbol_table
+ PARAMS ((bfd *, asymbol **, boolean));
+extern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
+extern int bfd_elf64_write_out_phdrs
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
+extern boolean bfd_elf64_add_dynamic_entry
+ PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
+extern boolean bfd_elf64_link_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs
+ PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
+
+#define bfd_elf32_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
+#define bfd_elf64_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
+
+extern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *));
+extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
+ PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
+ asection *, bfd *, char **));
+
+boolean _bfd_elf32_gc_sections
+ PARAMS ((bfd *abfd, struct bfd_link_info *info));
+boolean _bfd_elf32_gc_common_finalize_got_offsets
+ PARAMS ((bfd *abfd, struct bfd_link_info *info));
+boolean _bfd_elf32_gc_common_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+boolean _bfd_elf32_gc_record_vtinherit
+ PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
+boolean _bfd_elf32_gc_record_vtentry
+ PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
+
+boolean _bfd_elf64_gc_sections
+ PARAMS ((bfd *abfd, struct bfd_link_info *info));
+boolean _bfd_elf64_gc_common_finalize_got_offsets
+ PARAMS ((bfd *abfd, struct bfd_link_info *info));
+boolean _bfd_elf64_gc_common_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+boolean _bfd_elf64_gc_record_vtinherit
+ PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
+boolean _bfd_elf64_gc_record_vtentry
+ PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
+
+/* MIPS ELF specific routines. */
+
+extern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
+extern boolean _bfd_mips_elf_section_from_shdr
+ PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
+extern boolean _bfd_mips_elf_fake_sections
+ PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
+extern boolean _bfd_mips_elf_section_from_bfd_section
+ PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
+extern boolean _bfd_mips_elf_section_processing
+ PARAMS ((bfd *, Elf_Internal_Shdr *));
+extern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
+extern boolean _bfd_mips_elf_read_ecoff_info
+ PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
+extern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
+extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern boolean _bfd_mips_elf_set_private_flags PARAMS ((bfd *, flagword));
+extern boolean _bfd_mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+extern boolean _bfd_mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
+extern boolean _bfd_mips_elf_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+extern boolean _bfd_mips_elf_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+
+#endif /* _LIBELF_H_ */
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
new file mode 100644
index 00000000000..53d193d8704
--- /dev/null
+++ b/bfd/elf-m10200.c
@@ -0,0 +1,1525 @@
+/* Matsushita 10200 specific support for 32-bit ELF
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void mn10200_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static boolean mn10200_elf_relax_delete_bytes
+ PARAMS ((bfd *, asection *, bfd_vma, int));
+static boolean mn10200_elf_symbol_address_p
+ PARAMS ((bfd *, asection *, Elf32_External_Sym *, bfd_vma));
+
+/* We have to use RELA instructions since md_apply_fix3 in the assembler
+ does absolutely nothing. */
+#define USE_RELA
+
+enum reloc_type
+{
+ R_MN10200_NONE = 0,
+ R_MN10200_32,
+ R_MN10200_16,
+ R_MN10200_8,
+ R_MN10200_24,
+ R_MN10200_PCREL8,
+ R_MN10200_PCREL16,
+ R_MN10200_PCREL24,
+ R_MN10200_MAX
+};
+
+static reloc_howto_type elf_mn10200_howto_table[] =
+{
+ /* Dummy relocation. Does nothing. */
+ HOWTO (R_MN10200_NONE,
+ 0,
+ 2,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_NONE",
+ false,
+ 0,
+ 0,
+ false),
+ /* Standard 32 bit reloc. */
+ HOWTO (R_MN10200_32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_32",
+ false,
+ 0xffffffff,
+ 0xffffffff,
+ false),
+ /* Standard 16 bit reloc. */
+ HOWTO (R_MN10200_16,
+ 0,
+ 1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_16",
+ false,
+ 0xffff,
+ 0xffff,
+ false),
+ /* Standard 8 bit reloc. */
+ HOWTO (R_MN10200_8,
+ 0,
+ 0,
+ 8,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_8",
+ false,
+ 0xff,
+ 0xff,
+ false),
+ /* Standard 24 bit reloc. */
+ HOWTO (R_MN10200_24,
+ 0,
+ 2,
+ 24,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_24",
+ false,
+ 0xffffff,
+ 0xffffff,
+ false),
+ /* Simple 8 pc-relative reloc. */
+ HOWTO (R_MN10200_PCREL8,
+ 0,
+ 0,
+ 8,
+ true,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_PCREL8",
+ false,
+ 0xff,
+ 0xff,
+ true),
+ /* Simple 16 pc-relative reloc. */
+ HOWTO (R_MN10200_PCREL16,
+ 0,
+ 1,
+ 16,
+ true,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_PCREL16",
+ false,
+ 0xffff,
+ 0xffff,
+ true),
+ /* Simple 32bit pc-relative reloc with a 1 byte adjustment
+ to get the pc-relative offset correct. */
+ HOWTO (R_MN10200_PCREL24,
+ 0,
+ 2,
+ 24,
+ true,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10200_PCREL24",
+ false,
+ 0xffffff,
+ 0xffffff,
+ true),
+};
+
+struct mn10200_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static const struct mn10200_reloc_map mn10200_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_MN10200_NONE, },
+ { BFD_RELOC_32, R_MN10200_32, },
+ { BFD_RELOC_16, R_MN10200_16, },
+ { BFD_RELOC_8, R_MN10200_8, },
+ { BFD_RELOC_24, R_MN10200_24, },
+ { BFD_RELOC_8_PCREL, R_MN10200_PCREL8, },
+ { BFD_RELOC_16_PCREL, R_MN10200_PCREL16, },
+ { BFD_RELOC_24_PCREL, R_MN10200_PCREL24, },
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (mn10200_reloc_map) / sizeof (struct mn10200_reloc_map);
+ i++)
+ {
+ if (mn10200_reloc_map[i].bfd_reloc_val == code)
+ return &elf_mn10200_howto_table[mn10200_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Set the howto pointer for an MN10200 ELF reloc. */
+
+static void
+mn10200_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_MN10200_MAX);
+ cache_ptr->howto = &elf_mn10200_howto_table[r_type];
+}
+
+/* Perform a relocation as part of a final link. */
+static bfd_reloc_status_type
+mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, offset, value,
+ addend, info, sym_sec, is_local)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd *output_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ bfd_vma offset;
+ bfd_vma value;
+ bfd_vma addend;
+ struct bfd_link_info *info;
+ asection *sym_sec;
+ int is_local;
+{
+ unsigned long r_type = howto->type;
+ bfd_byte *hit_data = contents + offset;
+
+ switch (r_type)
+ {
+
+ case R_MN10200_NONE:
+ return bfd_reloc_ok;
+
+ case R_MN10200_32:
+ value += addend;
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10200_16:
+ value += addend;
+
+ if ((long)value > 0x7fff || (long)value < -0x8000)
+ return bfd_reloc_overflow;
+
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10200_8:
+ value += addend;
+
+ if ((long)value > 0x7f || (long)value < -0x80)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10200_24:
+ value += addend;
+
+ if ((long)value > 0x7fffff || (long)value < -0x800000)
+ return bfd_reloc_overflow;
+
+ value &= 0xffffff;
+ value |= (bfd_get_32 (input_bfd, hit_data) & 0xff000000);
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10200_PCREL8:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= (offset + 1);
+ value += addend;
+
+ if ((long)value > 0xff || (long)value < -0x100)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10200_PCREL16:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= (offset + 2);
+ value += addend;
+
+ if ((long)value > 0xffff || (long)value < -0x10000)
+ return bfd_reloc_overflow;
+
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10200_PCREL24:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= (offset + 3);
+ value += addend;
+
+ if ((long)value > 0xffffff || (long)value < -0x1000000)
+ return bfd_reloc_overflow;
+
+ value &= 0xffffff;
+ value |= (bfd_get_32 (input_bfd, hit_data) & 0xff000000);
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ default:
+ return bfd_reloc_notsupported;
+ }
+}
+
+
+/* Relocate an MN10200 ELF section. */
+static boolean
+mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ Elf_Internal_Rela *rel, *relend;
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ struct elf_link_hash_entry *h;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+ howto = elf_mn10200_howto_table + r_type;
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ r = mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend,
+ info, sec, h == NULL);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char *name;
+ const char *msg = (const char *)0;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL || *name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_undefined:
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ msg = _("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ msg = _("internal error: dangerous error");
+ goto common_error;
+
+ default:
+ msg = _("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, msg, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* This function handles relaxing for the mn10200.
+
+ There's quite a few relaxing opportunites available on the mn10200:
+
+ * jsr:24 -> jsr:16 2 bytes
+
+ * jmp:24 -> jmp:16 2 bytes
+ * jmp:16 -> bra:8 1 byte
+
+ * If the previous instruction is a conditional branch
+ around the jump/bra, we may be able to reverse its condition
+ and change its target to the jump's target. The jump/bra
+ can then be deleted. 2 bytes
+
+ * mov abs24 -> mov abs16 2 byte savings
+
+ * Most instructions which accept imm24 can relax to imm16 2 bytes
+ - Most instructions which accept imm16 can relax to imm8 1 byte
+
+ * Most instructions which accept d24 can relax to d16 2 bytes
+ - Most instructions which accept d16 can relax to d8 1 byte
+
+ abs24, imm24, d24 all look the same at the reloc level. It
+ might make the code simpler if we had different relocs for
+ the various relaxable operand types.
+
+ We don't handle imm16->imm8 or d16->d8 as they're very rare
+ and somewhat more difficult to support. */
+
+static boolean
+mn10200_elf_relax_section (abfd, sec, link_info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *internal_relocs;
+ Elf_Internal_Rela *free_relocs = NULL;
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+ Elf32_External_Sym *extsyms = NULL;
+ Elf32_External_Sym *free_extsyms = NULL;
+
+ /* Assume nothing changes. */
+ *again = false;
+
+ /* We don't have to do anything for a relocateable link, if
+ this section does not have relocs, or if this is not a
+ code section. */
+ if (link_info->relocateable
+ || (sec->flags & SEC_RELOC) == 0
+ || sec->reloc_count == 0
+ || (sec->flags & SEC_CODE) == 0)
+ return true;
+
+ /* If this is the first time we have been called for this section,
+ initialize the cooked size. */
+ if (sec->_cooked_size == 0)
+ sec->_cooked_size = sec->_raw_size;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+ /* Get a copy of the native relocations. */
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ /* Walk through them looking for relaxing opportunities. */
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma symval;
+
+ /* If this isn't something that can be relaxed, then ignore
+ this reloc. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_NONE
+ || ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_8
+ || ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_MAX)
+ continue;
+
+ /* Get the section contents if we haven't done so already. */
+ if (contents == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* Read this BFD's symbols if we haven't done so already. */
+ if (extsyms == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ /* Go get them off disk. */
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ /* Get the value of the symbol referred to by the reloc. */
+ if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+ {
+ Elf_Internal_Sym isym;
+ asection *sym_sec;
+
+ /* A local symbol. */
+ bfd_elf32_swap_symbol_in (abfd,
+ extsyms + ELF32_R_SYM (irel->r_info),
+ &isym);
+
+ sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
+ symval = (isym.st_value
+ + sym_sec->output_section->vma
+ + sym_sec->output_offset);
+ }
+ else
+ {
+ unsigned long indx;
+ struct elf_link_hash_entry *h;
+
+ /* An external symbol. */
+ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+ h = elf_sym_hashes (abfd)[indx];
+ BFD_ASSERT (h != NULL);
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ {
+ /* This appears to be a reference to an undefined
+ symbol. Just ignore it--it will be caught by the
+ regular reloc processing. */
+ continue;
+ }
+
+ symval = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+
+ /* For simplicity of coding, we are going to modify the section
+ contents, the section relocs, and the BFD symbol table. We
+ must tell the rest of the code not to free up this
+ information. It would be possible to instead create a table
+ of changes which have to be made, as is done in coff-mips.c;
+ that would be more work, but would require less memory when
+ the linker is run. */
+
+
+ /* Try to turn a 24bit pc-relative branch/call into a 16bit pc-relative
+ branch/call. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_PCREL24)
+ {
+ bfd_vma value = symval;
+
+ /* Deal with pc-relative gunk. */
+ value -= (sec->output_section->vma + sec->output_offset);
+ value -= (irel->r_offset + 3);
+ value += irel->r_addend;
+
+ /* See if the value will fit in 16 bits, note the high value is
+ 0x7fff + 2 as the target will be two bytes closer if we are
+ able to relax. */
+ if ((long)value < 0x8001 && (long)value > -0x8000)
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ if (code != 0xe0 && code != 0xe1)
+ continue;
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ if (code == 0xe0)
+ bfd_put_8 (abfd, 0xfc, contents + irel->r_offset - 2);
+ else if (code == 0xe1)
+ bfd_put_8 (abfd, 0xfd, contents + irel->r_offset - 2);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10200_PCREL16);
+
+ /* The opcode got shorter too, so we have to fix the offset. */
+ irel->r_offset -= 1;
+
+ /* Delete two bytes of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+ }
+
+ /* Try to turn a 16bit pc-relative branch into a 8bit pc-relative
+ branch. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_PCREL16)
+ {
+ bfd_vma value = symval;
+
+ /* Deal with pc-relative gunk. */
+ value -= (sec->output_section->vma + sec->output_offset);
+ value -= (irel->r_offset + 2);
+ value += irel->r_addend;
+
+ /* See if the value will fit in 8 bits, note the high value is
+ 0x7f + 1 as the target will be one bytes closer if we are
+ able to relax. */
+ if ((long)value < 0x80 && (long)value > -0x80)
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ if (code != 0xfc)
+ continue;
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xea, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10200_PCREL8);
+
+ /* Delete one byte of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 1))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+ }
+
+ /* Try to eliminate an unconditional 8 bit pc-relative branch
+ which immediately follows a conditional 8 bit pc-relative
+ branch around the unconditional branch.
+
+ original: new:
+ bCC lab1 bCC' lab2
+ bra lab2
+ lab1: lab1:
+
+
+ This happens when the bCC can't reach lab2 at assembly time,
+ but due to other relaxations it can reach at link time. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_PCREL8)
+ {
+ Elf_Internal_Rela *nrel;
+ bfd_vma value = symval;
+ unsigned char code;
+
+ /* Deal with pc-relative gunk. */
+ value -= (sec->output_section->vma + sec->output_offset);
+ value -= (irel->r_offset + 1);
+ value += irel->r_addend;
+
+ /* Do nothing if this reloc is the last byte in the section. */
+ if (irel->r_offset == sec->_cooked_size)
+ continue;
+
+ /* See if the next instruction is an unconditional pc-relative
+ branch, more often than not this test will fail, so we
+ test it first to speed things up. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset + 1);
+ if (code != 0xea)
+ continue;
+
+ /* Also make sure the next relocation applies to the next
+ instruction and that it's a pc-relative 8 bit branch. */
+ nrel = irel + 1;
+ if (nrel == irelend
+ || irel->r_offset + 2 != nrel->r_offset
+ || ELF32_R_TYPE (nrel->r_info) != (int) R_MN10200_PCREL8)
+ continue;
+
+ /* Make sure our destination immediately follows the
+ unconditional branch. */
+ if (symval != (sec->output_section->vma + sec->output_offset
+ + irel->r_offset + 3))
+ continue;
+
+ /* Now make sure we are a conditional branch. This may not
+ be necessary, but why take the chance.
+
+ Note these checks assume that R_MN10200_PCREL8 relocs
+ only occur on bCC and bCCx insns. If they occured
+ elsewhere, we'd need to know the start of this insn
+ for this check to be accurate. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ if (code != 0xe0 && code != 0xe1 && code != 0xe2
+ && code != 0xe3 && code != 0xe4 && code != 0xe5
+ && code != 0xe6 && code != 0xe7 && code != 0xe8
+ && code != 0xe9 && code != 0xec && code != 0xed
+ && code != 0xee && code != 0xef && code != 0xfc
+ && code != 0xfd && code != 0xfe && code != 0xff)
+ continue;
+
+ /* We also have to be sure there is no symbol/label
+ at the unconditional branch. */
+ if (mn10200_elf_symbol_address_p (abfd, sec, extsyms,
+ irel->r_offset + 1))
+ continue;
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Reverse the condition of the first branch. */
+ switch (code)
+ {
+ case 0xfc:
+ code = 0xfd;
+ break;
+ case 0xfd:
+ code = 0xfc;
+ break;
+ case 0xfe:
+ code = 0xff;
+ break;
+ case 0xff:
+ code = 0xfe;
+ break;
+ case 0xe8:
+ code = 0xe9;
+ break;
+ case 0xe9:
+ code = 0xe8;
+ break;
+ case 0xe0:
+ code = 0xe2;
+ break;
+ case 0xe2:
+ code = 0xe0;
+ break;
+ case 0xe3:
+ code = 0xe1;
+ break;
+ case 0xe1:
+ code = 0xe3;
+ break;
+ case 0xe4:
+ code = 0xe6;
+ break;
+ case 0xe6:
+ code = 0xe4;
+ break;
+ case 0xe7:
+ code = 0xe5;
+ break;
+ case 0xe5:
+ code = 0xe7;
+ break;
+ case 0xec:
+ code = 0xed;
+ break;
+ case 0xed:
+ code = 0xec;
+ break;
+ case 0xee:
+ code = 0xef;
+ break;
+ case 0xef:
+ code = 0xee;
+ break;
+ }
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+
+ /* Set the reloc type and symbol for the first branch
+ from the second branch. */
+ irel->r_info = nrel->r_info;
+
+ /* Make the reloc for the second branch a null reloc. */
+ nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
+ R_MN10200_NONE);
+
+ /* Delete two bytes of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+
+ /* Try to turn a 24bit immediate, displacement or absolute address
+ into a 16bit immediate, displacement or absolute address. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_24)
+ {
+ bfd_vma value = symval;
+
+ /* See if the value will fit in 16 bits.
+ We allow any 16bit match here. We prune those we can't
+ handle below. */
+ if ((long)value < 0x7fff && (long)value > -0x8000)
+ {
+ unsigned char code;
+
+ /* All insns which have 24bit operands are 5 bytes long,
+ the first byte will always be 0xf4, but we double check
+ it just in case. */
+
+ /* Get the first opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+
+ if (code != 0xf4)
+ continue;
+
+ /* Get the second opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ switch (code & 0xfc)
+ {
+ /* mov imm24,dn -> mov imm16,dn */
+ case 0x70:
+ /* Not safe if the high bit is on as relaxing may
+ move the value out of high mem and thus not fit
+ in a signed 16bit value. */
+ if (value & 0x8000)
+ continue;
+
+ /* Note that we've changed the reldection contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xf8 + (code & 0x03),
+ contents + irel->r_offset - 2);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10200_16);
+
+ /* The opcode got shorter too, so we have to fix the
+ offset. */
+ irel->r_offset -= 1;
+
+ /* Delete two bytes of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+
+ /* mov imm24,an -> mov imm16,an
+ cmp imm24,an -> cmp imm16,an
+ mov (abs24),dn -> mov (abs16),dn
+ mov dn,(abs24) -> mov dn,(abs16)
+ movb dn,(abs24) -> movb dn,(abs16)
+ movbu (abs24),dn -> movbu (abs16),dn */
+ case 0x74:
+ case 0x7c:
+ case 0xc0:
+ case 0x40:
+ case 0x44:
+ case 0xc8:
+ /* Note that we've changed the reldection contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ if ((code & 0xfc) == 0x74)
+ code = 0xdc + (code & 0x03);
+ else if ((code & 0xfc) == 0x7c)
+ code = 0xec + (code & 0x03);
+ else if ((code & 0xfc) == 0xc0)
+ code = 0xc8 + (code & 0x03);
+ else if ((code & 0xfc) == 0x40)
+ code = 0xc0 + (code & 0x03);
+ else if ((code & 0xfc) == 0x44)
+ code = 0xc4 + (code & 0x03);
+ else if ((code & 0xfc) == 0xc8)
+ code = 0xcc + (code & 0x03);
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10200_16);
+
+ /* The opcode got shorter too, so we have to fix the
+ offset. */
+ irel->r_offset -= 1;
+
+ /* Delete two bytes of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+
+ /* cmp imm24,dn -> cmp imm16,dn
+ mov (abs24),an -> mov (abs16),an
+ mov an,(abs24) -> mov an,(abs16)
+ add imm24,dn -> add imm16,dn
+ add imm24,an -> add imm16,an
+ sub imm24,dn -> sub imm16,dn
+ sub imm24,an -> sub imm16,an
+ And all d24->d16 in memory ops. */
+ case 0x78:
+ case 0xd0:
+ case 0x50:
+ case 0x60:
+ case 0x64:
+ case 0x68:
+ case 0x6c:
+ case 0x80:
+ case 0xf0:
+ case 0x00:
+ case 0x10:
+ case 0xb0:
+ case 0x30:
+ case 0xa0:
+ case 0x20:
+ case 0x90:
+ /* Not safe if the high bit is on as relaxing may
+ move the value out of high mem and thus not fit
+ in a signed 16bit value. */
+ if (((code & 0xfc) == 0x78
+ || (code & 0xfc) == 0x60
+ || (code & 0xfc) == 0x64
+ || (code & 0xfc) == 0x68
+ || (code & 0xfc) == 0x6c
+ || (code & 0xfc) == 0x80
+ || (code & 0xfc) == 0xf0
+ || (code & 0xfc) == 0x00
+ || (code & 0xfc) == 0x10
+ || (code & 0xfc) == 0xb0
+ || (code & 0xfc) == 0x30
+ || (code & 0xfc) == 0xa0
+ || (code & 0xfc) == 0x20
+ || (code & 0xfc) == 0x90)
+ && (value & 0x8000) != 0)
+ continue;
+
+ /* Note that we've changed the reldection contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xf7, contents + irel->r_offset - 2);
+
+ if ((code & 0xfc) == 0x78)
+ code = 0x48 + (code & 0x03);
+ else if ((code & 0xfc) == 0xd0)
+ code = 0x30 + (code & 0x03);
+ else if ((code & 0xfc) == 0x50)
+ code = 0x20 + (code & 0x03);
+ else if ((code & 0xfc) == 0x60)
+ code = 0x18 + (code & 0x03);
+ else if ((code & 0xfc) == 0x64)
+ code = 0x08 + (code & 0x03);
+ else if ((code & 0xfc) == 0x68)
+ code = 0x1c + (code & 0x03);
+ else if ((code & 0xfc) == 0x6c)
+ code = 0x0c + (code & 0x03);
+ else if ((code & 0xfc) == 0x80)
+ code = 0xc0 + (code & 0x07);
+ else if ((code & 0xfc) == 0xf0)
+ code = 0xb0 + (code & 0x07);
+ else if ((code & 0xfc) == 0x00)
+ code = 0x80 + (code & 0x07);
+ else if ((code & 0xfc) == 0x10)
+ code = 0xa0 + (code & 0x07);
+ else if ((code & 0xfc) == 0xb0)
+ code = 0x70 + (code & 0x07);
+ else if ((code & 0xfc) == 0x30)
+ code = 0x60 + (code & 0x07);
+ else if ((code & 0xfc) == 0xa0)
+ code = 0xd0 + (code & 0x07);
+ else if ((code & 0xfc) == 0x20)
+ code = 0x90 + (code & 0x07);
+ else if ((code & 0xfc) == 0x90)
+ code = 0x50 + (code & 0x07);
+
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10200_16);
+
+ /* Delete one bytes of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 1))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+
+ /* movb (abs24),dn ->movbu (abs16),dn extxb bn */
+ case 0xc4:
+ /* Note that we've changed the reldection contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ bfd_put_8 (abfd, 0xcc + (code & 0x03),
+ contents + irel->r_offset - 2);
+
+ bfd_put_8 (abfd, 0xb8 + (code & 0x03),
+ contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10200_16);
+
+ /* The reloc will be applied one byte in front of its
+ current location. */
+ irel->r_offset -= 1;
+
+ /* Delete one bytes of data. */
+ if (!mn10200_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 1))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (sec)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ free_extsyms = NULL;
+ }
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ if (free_extsyms != NULL)
+ free (free_extsyms);
+ return false;
+}
+
+/* Delete some bytes from a section while relaxing. */
+
+static boolean
+mn10200_elf_relax_delete_bytes (abfd, sec, addr, count)
+ bfd *abfd;
+ asection *sec;
+ bfd_vma addr;
+ int count;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf32_External_Sym *extsyms;
+ int shndx, index;
+ bfd_byte *contents;
+ Elf_Internal_Rela *irel, *irelend;
+ Elf_Internal_Rela *irelalign;
+ bfd_vma toaddr;
+ Elf32_External_Sym *esym, *esymend;
+ struct elf_link_hash_entry *sym_hash;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ contents = elf_section_data (sec)->this_hdr.contents;
+
+ /* The deletion must stop at the next ALIGN reloc for an aligment
+ power larger than the number of bytes we are deleting. */
+
+ irelalign = NULL;
+ toaddr = sec->_cooked_size;
+
+ irel = elf_section_data (sec)->relocs;
+ irelend = irel + sec->reloc_count;
+
+ /* Actually delete the bytes. */
+ memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ sec->_cooked_size -= count;
+
+ /* Adjust all the relocs. */
+ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+ {
+ /* Get the new reloc address. */
+ if ((irel->r_offset > addr
+ && irel->r_offset < toaddr))
+ irel->r_offset -= count;
+ }
+
+ /* Adjust the local symbols defined in this section. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+
+ if (isym.st_shndx == shndx
+ && isym.st_value > addr
+ && isym.st_value < toaddr)
+ {
+ isym.st_value -= count;
+ bfd_elf32_swap_symbol_out (abfd, &isym, esym);
+ }
+ }
+
+ /* Now adjust the global symbols defined in this section. */
+ esym = extsyms + symtab_hdr->sh_info;
+ esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
+ for (index = 0; esym < esymend; esym++, index++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+ sym_hash = elf_sym_hashes (abfd)[index];
+ if (isym.st_shndx == shndx
+ && ((sym_hash)->root.type == bfd_link_hash_defined
+ || (sym_hash)->root.type == bfd_link_hash_defweak)
+ && (sym_hash)->root.u.def.section == sec
+ && (sym_hash)->root.u.def.value > addr
+ && (sym_hash)->root.u.def.value < toaddr)
+ {
+ (sym_hash)->root.u.def.value -= count;
+ }
+ }
+
+ return true;
+}
+
+/* Return true if a symbol exists at the given address, else return
+ false. */
+static boolean
+mn10200_elf_symbol_address_p (abfd, sec, extsyms, addr)
+ bfd *abfd;
+ asection *sec;
+ Elf32_External_Sym *extsyms;
+ bfd_vma addr;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ int shndx;
+ Elf32_External_Sym *esym, *esymend;
+ struct elf_link_hash_entry **sym_hash, **sym_hash_end;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ /* Examine all the symbols. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+
+ if (isym.st_shndx == shndx
+ && isym.st_value == addr)
+ return true;
+ }
+
+ sym_hash = elf_sym_hashes (abfd);
+ sym_hash_end = (sym_hash
+ + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
+ - symtab_hdr->sh_info));
+ for (; sym_hash < sym_hash_end; sym_hash++)
+ {
+ if (((*sym_hash)->root.type == bfd_link_hash_defined
+ || (*sym_hash)->root.type == bfd_link_hash_defweak)
+ && (*sym_hash)->root.u.def.section == sec
+ && (*sym_hash)->root.u.def.value == addr)
+ return true;
+ }
+ return false;
+}
+
+/* This is a version of bfd_generic_get_relocated_section_contents
+ which uses mn10200_elf_relocate_section. */
+
+static bfd_byte *
+mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *input_section = link_order->u.indirect.section;
+ bfd *input_bfd = input_section->owner;
+ asection **sections = NULL;
+ Elf_Internal_Rela *internal_relocs = NULL;
+ Elf32_External_Sym *external_syms = NULL;
+ Elf_Internal_Sym *internal_syms = NULL;
+
+ /* We only need to handle the case of relaxing, or of having a
+ particular set of section contents, specially. */
+ if (relocateable
+ || elf_section_data (input_section)->this_hdr.contents == NULL)
+ return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
+ link_order, data,
+ relocateable,
+ symbols);
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ memcpy (data, elf_section_data (input_section)->this_hdr.contents,
+ input_section->_raw_size);
+
+ if ((input_section->flags & SEC_RELOC) != 0
+ && input_section->reloc_count > 0)
+ {
+ Elf_Internal_Sym *isymp;
+ asection **secpp;
+ Elf32_External_Sym *esym, *esymend;
+
+ if (symtab_hdr->contents != NULL)
+ external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ external_syms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf32_External_Sym)));
+ if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
+ symtab_hdr->sh_info, input_bfd)
+ != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ goto error_return;
+ }
+
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (input_bfd, input_section, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL, false));
+ if (internal_relocs == NULL)
+ goto error_return;
+
+ internal_syms = ((Elf_Internal_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf_Internal_Sym)));
+ if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ sections = (asection **) bfd_malloc (symtab_hdr->sh_info
+ * sizeof (asection *));
+ if (sections == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ isymp = internal_syms;
+ secpp = sections;
+ esym = external_syms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; ++esym, ++isymp, ++secpp)
+ {
+ asection *isec;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, isymp);
+
+ if (isymp->st_shndx == SHN_UNDEF)
+ isec = bfd_und_section_ptr;
+ else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
+ isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
+ else if (isymp->st_shndx == SHN_ABS)
+ isec = bfd_abs_section_ptr;
+ else if (isymp->st_shndx == SHN_COMMON)
+ isec = bfd_com_section_ptr;
+ else
+ {
+ /* Who knows? */
+ isec = NULL;
+ }
+
+ *secpp = isec;
+ }
+
+ if (! mn10200_elf_relocate_section (output_bfd, link_info, input_bfd,
+ input_section, data, internal_relocs,
+ internal_syms, sections))
+ goto error_return;
+
+ if (sections != NULL)
+ free (sections);
+ sections = NULL;
+ if (internal_syms != NULL)
+ free (internal_syms);
+ internal_syms = NULL;
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ external_syms = NULL;
+ if (internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ internal_relocs = NULL;
+ }
+
+ return data;
+
+ error_return:
+ if (internal_relocs != NULL
+ && internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ if (internal_syms != NULL)
+ free (internal_syms);
+ if (sections != NULL)
+ free (sections);
+ return NULL;
+}
+
+
+#define TARGET_LITTLE_SYM bfd_elf32_mn10200_vec
+#define TARGET_LITTLE_NAME "elf32-mn10200"
+#define ELF_ARCH bfd_arch_mn10200
+#define ELF_MACHINE_CODE EM_CYGNUS_MN10200
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_info_to_howto mn10200_info_to_howto
+#define elf_info_to_howto_rel 0
+#define elf_backend_relocate_section mn10200_elf_relocate_section
+#define bfd_elf32_bfd_relax_section mn10200_elf_relax_section
+#define bfd_elf32_bfd_get_relocated_section_contents \
+ mn10200_elf_get_relocated_section_contents
+
+#define elf_symbol_leading_char '_'
+
+#include "elf32-target.h"
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
new file mode 100644
index 00000000000..9ba09a88d61
--- /dev/null
+++ b/bfd/elf-m10300.c
@@ -0,0 +1,2821 @@
+/* Matsushita 10300 specific support for 32-bit ELF
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/mn10300.h"
+
+struct elf32_mn10300_link_hash_entry
+{
+ /* The basic elf link hash table entry. */
+ struct elf_link_hash_entry root;
+
+ /* For function symbols, the number of times this function is
+ called directly (ie by name). */
+ unsigned int direct_calls;
+
+ /* For function symbols, the size of this function's stack
+ (if <= 255 bytes). We stuff this into "call" instructions
+ to this target when it's valid and profitable to do so.
+
+ This does not include stack allocated by movm! */
+ unsigned char stack_size;
+
+ /* For function symbols, arguments (if any) for movm instruction
+ in the prologue. We stuff this value into "call" instructions
+ to the target when it's valid and profitable to do so. */
+ unsigned char movm_args;
+
+ /* For funtion symbols, the amount of stack space that would be allocated
+ by the movm instruction. This is redundant with movm_args, but we
+ add it to the hash table to avoid computing it over and over. */
+ unsigned char movm_stack_size;
+
+/* When set, convert all "call" instructions to this target into "calls"
+ instructions. */
+#define MN10300_CONVERT_CALL_TO_CALLS 0x1
+
+/* Used to mark functions which have had redundant parts of their
+ prologue deleted. */
+#define MN10300_DELETED_PROLOGUE_BYTES 0x2
+ unsigned char flags;
+};
+
+/* We derive a hash table from the main elf linker hash table so
+ we can store state variables and a secondary hash table without
+ resorting to global variables. */
+struct elf32_mn10300_link_hash_table
+{
+ /* The main hash table. */
+ struct elf_link_hash_table root;
+
+ /* A hash table for static functions. We could derive a new hash table
+ instead of using the full elf32_mn10300_link_hash_table if we wanted
+ to save some memory. */
+ struct elf32_mn10300_link_hash_table *static_hash_table;
+
+ /* Random linker state flags. */
+#define MN10300_HASH_ENTRIES_INITIALIZED 0x1
+ char flags;
+};
+
+/* For MN10300 linker hash table. */
+
+/* Get the MN10300 ELF linker hash table from a link_info structure. */
+
+#define elf32_mn10300_hash_table(p) \
+ ((struct elf32_mn10300_link_hash_table *) ((p)->hash))
+
+#define elf32_mn10300_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+static struct bfd_hash_entry *elf32_mn10300_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *elf32_mn10300_link_hash_table_create
+ PARAMS ((bfd *));
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void mn10300_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static boolean mn10300_elf_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static asection *mn10300_elf_gc_mark_hook
+ PARAMS ((bfd *, struct bfd_link_info *info, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
+static boolean mn10300_elf_relax_delete_bytes
+ PARAMS ((bfd *, asection *, bfd_vma, int));
+static boolean mn10300_elf_symbol_address_p
+ PARAMS ((bfd *, asection *, Elf32_External_Sym *, bfd_vma));
+static boolean elf32_mn10300_finish_hash_table_entry
+ PARAMS ((struct bfd_hash_entry *, PTR));
+static void compute_function_info
+ PARAMS ((bfd *, struct elf32_mn10300_link_hash_entry *,
+ bfd_vma, unsigned char *));
+
+/* We have to use RELA instructions since md_apply_fix3 in the assembler
+ does absolutely nothing. */
+#define USE_RELA
+
+
+static reloc_howto_type elf_mn10300_howto_table[] =
+{
+ /* Dummy relocation. Does nothing. */
+ HOWTO (R_MN10300_NONE,
+ 0,
+ 2,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_NONE",
+ false,
+ 0,
+ 0,
+ false),
+ /* Standard 32 bit reloc. */
+ HOWTO (R_MN10300_32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_32",
+ false,
+ 0xffffffff,
+ 0xffffffff,
+ false),
+ /* Standard 16 bit reloc. */
+ HOWTO (R_MN10300_16,
+ 0,
+ 1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_16",
+ false,
+ 0xffff,
+ 0xffff,
+ false),
+ /* Standard 8 bit reloc. */
+ HOWTO (R_MN10300_8,
+ 0,
+ 0,
+ 8,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_8",
+ false,
+ 0xff,
+ 0xff,
+ false),
+ /* Standard 32bit pc-relative reloc. */
+ HOWTO (R_MN10300_PCREL32,
+ 0,
+ 2,
+ 32,
+ true,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_PCREL32",
+ false,
+ 0xffffffff,
+ 0xffffffff,
+ true),
+ /* Standard 16bit pc-relative reloc. */
+ HOWTO (R_MN10300_PCREL16,
+ 0,
+ 1,
+ 16,
+ true,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_PCREL16",
+ false,
+ 0xffff,
+ 0xffff,
+ true),
+ /* Standard 8 pc-relative reloc. */
+ HOWTO (R_MN10300_PCREL8,
+ 0,
+ 0,
+ 8,
+ true,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_PCREL8",
+ false,
+ 0xff,
+ 0xff,
+ true),
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_MN10300_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_MN10300_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_MN10300_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_MN10300_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Standard 24 bit reloc. */
+ HOWTO (R_MN10300_24,
+ 0,
+ 2,
+ 24,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_MN10300_24",
+ false,
+ 0xffffff,
+ 0xffffff,
+ false),
+
+};
+
+struct mn10300_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static const struct mn10300_reloc_map mn10300_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_MN10300_NONE, },
+ { BFD_RELOC_32, R_MN10300_32, },
+ { BFD_RELOC_16, R_MN10300_16, },
+ { BFD_RELOC_8, R_MN10300_8, },
+ { BFD_RELOC_32_PCREL, R_MN10300_PCREL32, },
+ { BFD_RELOC_16_PCREL, R_MN10300_PCREL16, },
+ { BFD_RELOC_8_PCREL, R_MN10300_PCREL8, },
+ { BFD_RELOC_24, R_MN10300_24, },
+ { BFD_RELOC_VTABLE_INHERIT, R_MN10300_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_MN10300_GNU_VTENTRY },
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (mn10300_reloc_map) / sizeof (struct mn10300_reloc_map);
+ i++)
+ {
+ if (mn10300_reloc_map[i].bfd_reloc_val == code)
+ return &elf_mn10300_howto_table[mn10300_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Set the howto pointer for an MN10300 ELF reloc. */
+
+static void
+mn10300_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_MN10300_MAX);
+ cache_ptr->howto = &elf_mn10300_howto_table[r_type];
+}
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+mn10300_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+
+ if (info->relocateable)
+ return true;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry *h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_MN10300_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_MN10300_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+mn10300_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_MN10300_GNU_VTINHERIT:
+ case R_MN10300_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Perform a relocation as part of a final link. */
+static bfd_reloc_status_type
+mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, offset, value,
+ addend, info, sym_sec, is_local)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd *output_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ bfd_vma offset;
+ bfd_vma value;
+ bfd_vma addend;
+ struct bfd_link_info *info;
+ asection *sym_sec;
+ int is_local;
+{
+ unsigned long r_type = howto->type;
+ bfd_byte *hit_data = contents + offset;
+
+ switch (r_type)
+ {
+ case R_MN10300_NONE:
+ return bfd_reloc_ok;
+
+ case R_MN10300_32:
+ value += addend;
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10300_24:
+ value += addend;
+
+ if ((long)value > 0x7fffff || (long)value < -0x800000)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, value & 0xff, hit_data);
+ bfd_put_8 (input_bfd, (value >> 8) & 0xff, hit_data + 1);
+ bfd_put_8 (input_bfd, (value >> 16) & 0xff, hit_data + 2);
+ return bfd_reloc_ok;
+
+ case R_MN10300_16:
+ value += addend;
+
+ if ((long)value > 0x7fff || (long)value < -0x8000)
+ return bfd_reloc_overflow;
+
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10300_8:
+ value += addend;
+
+ if ((long)value > 0x7f || (long)value < -0x80)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10300_PCREL8:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= offset;
+ value += addend;
+
+ if ((long)value > 0xff || (long)value < -0x100)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10300_PCREL16:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= offset;
+ value += addend;
+
+ if ((long)value > 0xffff || (long)value < -0x10000)
+ return bfd_reloc_overflow;
+
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10300_PCREL32:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= offset;
+ value += addend;
+
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_MN10300_GNU_VTINHERIT:
+ case R_MN10300_GNU_VTENTRY:
+ return bfd_reloc_ok;
+
+ default:
+ return bfd_reloc_notsupported;
+ }
+}
+
+
+/* Relocate an MN10300 ELF section. */
+static boolean
+mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf32_mn10300_link_hash_entry **sym_hashes;
+ Elf_Internal_Rela *rel, *relend;
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = (struct elf32_mn10300_link_hash_entry **)
+ (elf_sym_hashes (input_bfd));
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ struct elf32_mn10300_link_hash_entry *h;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+ howto = elf_mn10300_howto_table + r_type;
+
+ /* Just skip the vtable gc relocs. */
+ if (r_type == R_MN10300_GNU_VTINHERIT
+ || r_type == R_MN10300_GNU_VTENTRY)
+ continue;
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf32_mn10300_link_hash_entry *) h->root.root.u.i.link;
+ if (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.root.u.def.section;
+ relocation = (h->root.root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ r = mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend,
+ info, sec, h == NULL);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char *name;
+ const char *msg = (const char *)0;
+
+ if (h != NULL)
+ name = h->root.root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL || *name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_undefined:
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ msg = _("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ msg = _("internal error: dangerous error");
+ goto common_error;
+
+ default:
+ msg = _("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, msg, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Finish initializing one hash table entry. */
+static boolean
+elf32_mn10300_finish_hash_table_entry (gen_entry, in_args)
+ struct bfd_hash_entry *gen_entry;
+ PTR in_args;
+{
+ struct elf32_mn10300_link_hash_entry *entry;
+ unsigned int byte_count = 0;
+
+ entry = (struct elf32_mn10300_link_hash_entry *)gen_entry;
+
+ /* If we already know we want to convert "call" to "calls" for calls
+ to this symbol, then return now. */
+ if (entry->flags == MN10300_CONVERT_CALL_TO_CALLS)
+ return true;
+
+ /* If there are no named calls to this symbol, or there's nothing we
+ can move from the function itself into the "call" instruction, then
+ note that all "call" instructions should be converted into "calls"
+ instructions and return. */
+ if (entry->direct_calls == 0
+ || (entry->stack_size == 0 && entry->movm_args == 0))
+ {
+ /* Make a note that we should convert "call" instructions to "calls"
+ instructions for calls to this symbol. */
+ entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
+ return true;
+ }
+
+ /* We may be able to move some instructions from the function itself into
+ the "call" instruction. Count how many bytes we might be able to
+ eliminate in the function itself. */
+
+ /* A movm instruction is two bytes. */
+ if (entry->movm_args)
+ byte_count += 2;
+
+ /* Count the insn to allocate stack space too. */
+ if (entry->stack_size > 0 && entry->stack_size <= 128)
+ byte_count += 3;
+ else if (entry->stack_size > 0 && entry->stack_size < 256)
+ byte_count += 4;
+
+ /* If using "call" will result in larger code, then turn all
+ the associated "call" instructions into "calls" instrutions. */
+ if (byte_count < entry->direct_calls)
+ entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
+
+ /* This routine never fails. */
+ return true;
+}
+
+/* This function handles relaxing for the mn10300.
+
+ There's quite a few relaxing opportunites available on the mn10300:
+
+ * calls:32 -> calls:16 2 bytes
+ * call:32 -> call:16 2 bytes
+
+ * call:32 -> calls:32 1 byte
+ * call:16 -> calls:16 1 byte
+ * These are done anytime using "calls" would result
+ in smaller code, or when necessary to preserve the
+ meaning of the program.
+
+ * call:32 varies
+ * call:16
+ * In some circumstances we can move instructions
+ from a function prologue into a "call" instruction.
+ This is only done if the resulting code is no larger
+ than the original code.
+
+
+ * jmp:32 -> jmp:16 2 bytes
+ * jmp:16 -> bra:8 1 byte
+
+ * If the previous instruction is a conditional branch
+ around the jump/bra, we may be able to reverse its condition
+ and change its target to the jump's target. The jump/bra
+ can then be deleted. 2 bytes
+
+ * mov abs32 -> mov abs16 1 or 2 bytes
+
+ * Most instructions which accept imm32 can relax to imm16 1 or 2 bytes
+ - Most instructions which accept imm16 can relax to imm8 1 or 2 bytes
+
+ * Most instructions which accept d32 can relax to d16 1 or 2 bytes
+ - Most instructions which accept d16 can relax to d8 1 or 2 bytes
+
+ We don't handle imm16->imm8 or d16->d8 as they're very rare
+ and somewhat more difficult to support. */
+
+static boolean
+mn10300_elf_relax_section (abfd, sec, link_info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *internal_relocs = NULL;
+ Elf_Internal_Rela *free_relocs = NULL;
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+ Elf32_External_Sym *extsyms = NULL;
+ Elf32_External_Sym *free_extsyms = NULL;
+ struct elf32_mn10300_link_hash_table *hash_table;
+
+ /* Assume nothing changes. */
+ *again = false;
+
+ /* We need a pointer to the mn10300 specific hash table. */
+ hash_table = elf32_mn10300_hash_table (link_info);
+
+ /* Initialize fields in each hash table entry the first time through. */
+ if ((hash_table->flags & MN10300_HASH_ENTRIES_INITIALIZED) == 0)
+ {
+ bfd *input_bfd;
+
+ /* Iterate over all the input bfds. */
+ for (input_bfd = link_info->input_bfds;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next)
+ {
+ asection *section;
+
+ /* We're going to need all the symbols for each bfd. */
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ /* Get cached copy if it exists. */
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ /* Go get them off disk. */
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+
+ /* Iterate over each section in this bfd. */
+ for (section = input_bfd->sections;
+ section != NULL;
+ section = section->next)
+ {
+ struct elf32_mn10300_link_hash_entry *hash;
+ Elf_Internal_Sym *sym;
+ asection *sym_sec;
+ const char *sym_name;
+ char *new_name;
+ Elf_Internal_Shdr *hdr;
+
+ /* Get cached copy of section contents if it exists. */
+ if (elf_section_data (section)->this_hdr.contents != NULL)
+ contents = elf_section_data (section)->this_hdr.contents;
+ else if (section->_raw_size != 0)
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *)bfd_malloc (section->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (!bfd_get_section_contents (input_bfd, section,
+ contents, (file_ptr) 0,
+ section->_raw_size))
+ goto error_return;
+ }
+ else
+ {
+ contents = NULL;
+ free_contents = NULL;
+ }
+
+ /* If there aren't any relocs, then there's nothing to do. */
+ if ((section->flags & SEC_RELOC) != 0
+ && section->reloc_count != 0)
+ {
+
+ /* Get a copy of the native relocations. */
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (input_bfd, section, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ /* Now examine each relocation. */
+ irel = internal_relocs;
+ irelend = irel + section->reloc_count;
+ for (; irel < irelend; irel++)
+ {
+ long r_type;
+ unsigned long r_index;
+ unsigned char code;
+
+ r_type = ELF32_R_TYPE (irel->r_info);
+ r_index = ELF32_R_SYM (irel->r_info);
+
+ if (r_type < 0 || r_type >= (int)R_MN10300_MAX)
+ goto error_return;
+
+ /* We need the name and hash table entry of the target
+ symbol! */
+ hash = NULL;
+ sym = NULL;
+ sym_sec = NULL;
+
+ if (r_index < symtab_hdr->sh_info)
+ {
+ /* A local symbol. */
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (input_bfd,
+ extsyms + r_index, &isym);
+
+ if (isym.st_shndx == SHN_UNDEF)
+ sym_sec = bfd_und_section_ptr;
+ else if (isym.st_shndx > 0
+ && isym.st_shndx < SHN_LORESERVE)
+ sym_sec
+ = bfd_section_from_elf_index (input_bfd,
+ isym.st_shndx);
+ else if (isym.st_shndx == SHN_ABS)
+ sym_sec = bfd_abs_section_ptr;
+ else if (isym.st_shndx == SHN_COMMON)
+ sym_sec = bfd_com_section_ptr;
+
+ sym_name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ isym.st_name);
+
+ /* If it isn't a function, then we don't care
+ about it. */
+ if (r_index < symtab_hdr->sh_info
+ && ELF_ST_TYPE (isym.st_info) != STT_FUNC)
+ continue;
+
+ /* Tack on an ID so we can uniquely identify this
+ local symbol in the global hash table. */
+ new_name = bfd_malloc (strlen (sym_name) + 10);
+ if (new_name == 0)
+ goto error_return;
+
+ sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
+ sym_name = new_name;
+
+ hash = (struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (&hash_table->static_hash_table->root,
+ sym_name, true,
+ true, false);
+ free (new_name);
+ }
+ else
+ {
+ r_index -= symtab_hdr->sh_info;
+ hash = (struct elf32_mn10300_link_hash_entry *)
+ elf_sym_hashes (input_bfd)[r_index];
+ }
+
+ /* If this is not a "call" instruction, then we
+ should convert "call" instructions to "calls"
+ instructions. */
+ code = bfd_get_8 (input_bfd,
+ contents + irel->r_offset - 1);
+ if (code != 0xdd && code != 0xcd)
+ hash->flags |= MN10300_CONVERT_CALL_TO_CALLS;
+
+ /* If this is a jump/call, then bump the direct_calls
+ counter. Else force "call" to "calls" conversions. */
+ if (r_type == R_MN10300_PCREL32
+ || r_type == R_MN10300_PCREL16)
+ hash->direct_calls++;
+ else
+ hash->flags |= MN10300_CONVERT_CALL_TO_CALLS;
+ }
+ }
+
+ /* Now look at the actual contents to get the stack size,
+ and a list of what registers were saved in the prologue
+ (ie movm_args). */
+ if ((section->flags & SEC_CODE) != 0)
+ {
+
+ Elf32_External_Sym *esym, *esymend;
+ int idx, shndx;
+
+ shndx = _bfd_elf_section_from_bfd_section (input_bfd,
+ section);
+
+
+ /* Look at each function defined in this section and
+ update info for that function. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
+ if (isym.st_shndx == shndx
+ && ELF_ST_TYPE (isym.st_info) == STT_FUNC)
+ {
+ if (isym.st_shndx == SHN_UNDEF)
+ sym_sec = bfd_und_section_ptr;
+ else if (isym.st_shndx > 0
+ && isym.st_shndx < SHN_LORESERVE)
+ sym_sec
+ = bfd_section_from_elf_index (input_bfd,
+ isym.st_shndx);
+ else if (isym.st_shndx == SHN_ABS)
+ sym_sec = bfd_abs_section_ptr;
+ else if (isym.st_shndx == SHN_COMMON)
+ sym_sec = bfd_com_section_ptr;
+
+ sym_name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ isym.st_name);
+
+ /* Tack on an ID so we can uniquely identify this
+ local symbol in the global hash table. */
+ new_name = bfd_malloc (strlen (sym_name) + 10);
+ if (new_name == 0)
+ goto error_return;
+
+ sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
+ sym_name = new_name;
+
+ hash = (struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (&hash_table->static_hash_table->root,
+ sym_name, true,
+ true, false);
+ free (new_name);
+ compute_function_info (input_bfd, hash,
+ isym.st_value, contents);
+ }
+ }
+
+ esym = extsyms + symtab_hdr->sh_info;
+ esymend = extsyms + (symtab_hdr->sh_size
+ / sizeof (Elf32_External_Sym));
+ for (idx = 0; esym < esymend; esym++, idx++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
+ hash = (struct elf32_mn10300_link_hash_entry *)
+ elf_sym_hashes (input_bfd)[idx];
+ if (isym.st_shndx == shndx
+ && ELF_ST_TYPE (isym.st_info) == STT_FUNC
+ && (hash)->root.root.u.def.section == section
+ && ((hash)->root.root.type == bfd_link_hash_defined
+ || (hash)->root.root.type == bfd_link_hash_defweak))
+ compute_function_info (input_bfd, hash,
+ (hash)->root.root.u.def.value,
+ contents);
+ }
+ }
+
+ /* Cache or free any memory we allocated for the relocs. */
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ /* Cache or free any memory we allocated for the contents. */
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (section)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+ }
+
+ /* Cache or free any memory we allocated for the symbols. */
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ free_extsyms = NULL;
+ }
+ }
+
+ /* Now iterate on each symbol in the hash table and perform
+ the final initialization steps on each. */
+ elf32_mn10300_link_hash_traverse (hash_table,
+ elf32_mn10300_finish_hash_table_entry,
+ NULL);
+ elf32_mn10300_link_hash_traverse (hash_table->static_hash_table,
+ elf32_mn10300_finish_hash_table_entry,
+ NULL);
+
+ /* All entries in the hash table are fully initialized. */
+ hash_table->flags |= MN10300_HASH_ENTRIES_INITIALIZED;
+
+ /* Now that everything has been initialized, go through each
+ code section and delete any prologue insns which will be
+ redundant because their operations will be performed by
+ a "call" instruction. */
+ for (input_bfd = link_info->input_bfds;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next)
+ {
+ asection *section;
+
+ /* We're going to need all the symbols for each bfd. */
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ /* Get cached copy if it exists. */
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ /* Go get them off disk. */
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+
+ /* Walk over each section in this bfd. */
+ for (section = input_bfd->sections;
+ section != NULL;
+ section = section->next)
+ {
+ int shndx;
+ Elf32_External_Sym *esym, *esymend;
+ int idx;
+
+ /* Skip non-code sections and empty sections. */
+ if ((section->flags & SEC_CODE) == 0 || section->_raw_size == 0)
+ continue;
+
+ if (section->reloc_count != 0)
+ {
+ /* Get a copy of the native relocations. */
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (input_bfd, section, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+ }
+
+ /* Get cached copy of section contents if it exists. */
+ if (elf_section_data (section)->this_hdr.contents != NULL)
+ contents = elf_section_data (section)->this_hdr.contents;
+ else
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *)bfd_malloc (section->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (!bfd_get_section_contents (input_bfd, section,
+ contents, (file_ptr) 0,
+ section->_raw_size))
+ goto error_return;
+ }
+
+
+ shndx = _bfd_elf_section_from_bfd_section (input_bfd, section);
+
+ /* Now look for any function in this section which needs
+ insns deleted from its prologue. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+ struct elf32_mn10300_link_hash_entry *sym_hash;
+ asection *sym_sec;
+ const char *sym_name;
+ Elf_Internal_Shdr *hdr;
+ char *new_name;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
+
+ if (isym.st_shndx != shndx)
+ continue;
+
+ if (isym.st_shndx == SHN_UNDEF)
+ sym_sec = bfd_und_section_ptr;
+ else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
+ sym_sec
+ = bfd_section_from_elf_index (input_bfd, isym.st_shndx);
+ else if (isym.st_shndx == SHN_ABS)
+ sym_sec = bfd_abs_section_ptr;
+ else if (isym.st_shndx == SHN_COMMON)
+ sym_sec = bfd_com_section_ptr;
+
+ sym_name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ isym.st_name);
+
+ /* Tack on an ID so we can uniquely identify this
+ local symbol in the global hash table. */
+ new_name = bfd_malloc (strlen (sym_name) + 10);
+ if (new_name == 0)
+ goto error_return;
+ sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
+ sym_name = new_name;
+
+ sym_hash = (struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (&hash_table->static_hash_table->root,
+ sym_name, false,
+ false, false);
+
+ free (new_name);
+ if (sym_hash == NULL)
+ continue;
+
+ if (! ((sym_hash)->flags & MN10300_CONVERT_CALL_TO_CALLS)
+ && ! ((sym_hash)->flags & MN10300_DELETED_PROLOGUE_BYTES))
+ {
+ int bytes = 0;
+
+ /* Note that we've changed things. */
+ elf_section_data (section)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (section)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *)extsyms;
+ free_extsyms = NULL;
+
+ /* Count how many bytes we're going to delete. */
+ if (sym_hash->movm_args)
+ bytes += 2;
+
+ if (sym_hash->stack_size && sym_hash->stack_size <= 128)
+ bytes += 3;
+ else if (sym_hash->stack_size
+ && sym_hash->stack_size < 256)
+ bytes += 4;
+
+ /* Note that we've deleted prologue bytes for this
+ function. */
+ sym_hash->flags |= MN10300_DELETED_PROLOGUE_BYTES;
+
+ /* Actually delete the bytes. */
+ if (!mn10300_elf_relax_delete_bytes (input_bfd,
+ section,
+ isym.st_value,
+ bytes))
+ goto error_return;
+
+ /* Something changed. Not strictly necessary, but
+ may lead to more relaxing opportunities. */
+ *again = true;
+ }
+ }
+
+ /* Look for any global functions in this section which
+ need insns deleted from their prologues. */
+ esym = extsyms + symtab_hdr->sh_info;
+ esymend = extsyms + (symtab_hdr->sh_size
+ / sizeof (Elf32_External_Sym));
+ for (idx = 0; esym < esymend; esym++, idx++)
+ {
+ Elf_Internal_Sym isym;
+ struct elf32_mn10300_link_hash_entry *sym_hash;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
+ sym_hash = (struct elf32_mn10300_link_hash_entry *)
+ (elf_sym_hashes (input_bfd)[idx]);
+ if (isym.st_shndx == shndx
+ && (sym_hash)->root.root.u.def.section == section
+ && ! ((sym_hash)->flags & MN10300_CONVERT_CALL_TO_CALLS)
+ && ! ((sym_hash)->flags & MN10300_DELETED_PROLOGUE_BYTES))
+ {
+ int bytes = 0;
+
+ /* Note that we've changed things. */
+ elf_section_data (section)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (section)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *)extsyms;
+ free_extsyms = NULL;
+
+ /* Count how many bytes we're going to delete. */
+ if (sym_hash->movm_args)
+ bytes += 2;
+
+ if (sym_hash->stack_size && sym_hash->stack_size <= 128)
+ bytes += 3;
+ else if (sym_hash->stack_size
+ && sym_hash->stack_size < 256)
+ bytes += 4;
+
+ /* Note that we've deleted prologue bytes for this
+ function. */
+ sym_hash->flags |= MN10300_DELETED_PROLOGUE_BYTES;
+
+ /* Actually delete the bytes. */
+ if (!mn10300_elf_relax_delete_bytes (input_bfd,
+ section,
+ (sym_hash)->root.root.u.def.value,
+ bytes))
+ goto error_return;
+
+ /* Something changed. Not strictly necessary, but
+ may lead to more relaxing opportunities. */
+ *again = true;
+ }
+ }
+
+ /* Cache or free any memory we allocated for the relocs. */
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ /* Cache or free any memory we allocated for the contents. */
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (section)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+ }
+
+ /* Cache or free any memory we allocated for the symbols. */
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ free_extsyms = NULL;
+ }
+ }
+ }
+
+
+ /* (Re)initialize for the basic instruction shortening/relaxing pass. */
+ contents = NULL;
+ extsyms = NULL;
+ internal_relocs = NULL;
+ free_relocs = NULL;
+ free_contents = NULL;
+ free_extsyms = NULL;
+
+ /* We don't have to do anything for a relocateable link, if
+ this section does not have relocs, or if this is not a
+ code section. */
+ if (link_info->relocateable
+ || (sec->flags & SEC_RELOC) == 0
+ || sec->reloc_count == 0
+ || (sec->flags & SEC_CODE) == 0)
+ return true;
+
+ /* If this is the first time we have been called for this section,
+ initialize the cooked size. */
+ if (sec->_cooked_size == 0)
+ sec->_cooked_size = sec->_raw_size;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+ /* Get a copy of the native relocations. */
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ /* Walk through them looking for relaxing opportunities. */
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma symval;
+ struct elf32_mn10300_link_hash_entry *h = NULL;
+
+ /* If this isn't something that can be relaxed, then ignore
+ this reloc. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_NONE
+ || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_8
+ || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_MAX)
+ continue;
+
+ /* Get the section contents if we haven't done so already. */
+ if (contents == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* Read this BFD's symbols if we haven't done so already. */
+ if (extsyms == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ /* Go get them off disk. */
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ /* Get the value of the symbol referred to by the reloc. */
+ if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+ {
+ Elf_Internal_Sym isym;
+ asection *sym_sec;
+ Elf_Internal_Shdr *hdr;
+ const char *sym_name;
+ char *new_name;
+
+ /* A local symbol. */
+ bfd_elf32_swap_symbol_in (abfd,
+ extsyms + ELF32_R_SYM (irel->r_info),
+ &isym);
+
+ if (isym.st_shndx == SHN_UNDEF)
+ sym_sec = bfd_und_section_ptr;
+ else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
+ sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
+ else if (isym.st_shndx == SHN_ABS)
+ sym_sec = bfd_abs_section_ptr;
+ else if (isym.st_shndx == SHN_COMMON)
+ sym_sec = bfd_com_section_ptr;
+
+ symval = (isym.st_value
+ + sym_sec->output_section->vma
+ + sym_sec->output_offset);
+ sym_name = bfd_elf_string_from_elf_section (abfd,
+ symtab_hdr->sh_link,
+ isym.st_name);
+
+ /* Tack on an ID so we can uniquely identify this
+ local symbol in the global hash table. */
+ new_name = bfd_malloc (strlen (sym_name) + 10);
+ if (new_name == 0)
+ goto error_return;
+ sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
+ sym_name = new_name;
+
+ h = (struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (&hash_table->static_hash_table->root,
+ sym_name, false, false, false);
+ free (new_name);
+ }
+ else
+ {
+ unsigned long indx;
+
+ /* An external symbol. */
+ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+ h = (struct elf32_mn10300_link_hash_entry *)
+ (elf_sym_hashes (abfd)[indx]);
+ BFD_ASSERT (h != NULL);
+ if (h->root.root.type != bfd_link_hash_defined
+ && h->root.root.type != bfd_link_hash_defweak)
+ {
+ /* This appears to be a reference to an undefined
+ symbol. Just ignore it--it will be caught by the
+ regular reloc processing. */
+ continue;
+ }
+
+ symval = (h->root.root.u.def.value
+ + h->root.root.u.def.section->output_section->vma
+ + h->root.root.u.def.section->output_offset);
+ }
+
+ /* For simplicity of coding, we are going to modify the section
+ contents, the section relocs, and the BFD symbol table. We
+ must tell the rest of the code not to free up this
+ information. It would be possible to instead create a table
+ of changes which have to be made, as is done in coff-mips.c;
+ that would be more work, but would require less memory when
+ the linker is run. */
+
+ /* Try to turn a 32bit pc-relative branch/call into a 16bit pc-relative
+ branch/call, also deal with "call" -> "calls" conversions and
+ insertion of prologue data into "call" instructions. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL32)
+ {
+ bfd_vma value = symval;
+
+ /* If we've got a "call" instruction that needs to be turned
+ into a "calls" instruction, do so now. It saves a byte. */
+ if (h && (h->flags & MN10300_CONVERT_CALL_TO_CALLS))
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ /* Make sure we're working with a "call" instruction! */
+ if (code == 0xdd)
+ {
+ /* Note that we've changed the relocs, section contents,
+ etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xfc, contents + irel->r_offset - 1);
+ bfd_put_8 (abfd, 0xff, contents + irel->r_offset);
+
+ /* Fix irel->r_offset and irel->r_addend. */
+ irel->r_offset += 1;
+ irel->r_addend += 1;
+
+ /* Delete one byte of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 3, 1))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+ }
+ else if (h)
+ {
+ /* We've got a "call" instruction which needs some data
+ from target function filled in. */
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ /* Insert data from the target function into the "call"
+ instruction if needed. */
+ if (code == 0xdd)
+ {
+ bfd_put_8 (abfd, h->movm_args, contents + irel->r_offset + 4);
+ bfd_put_8 (abfd, h->stack_size + h->movm_stack_size,
+ contents + irel->r_offset + 5);
+ }
+ }
+
+ /* Deal with pc-relative gunk. */
+ value -= (sec->output_section->vma + sec->output_offset);
+ value -= irel->r_offset;
+ value += irel->r_addend;
+
+ /* See if the value will fit in 16 bits, note the high value is
+ 0x7fff + 2 as the target will be two bytes closer if we are
+ able to relax. */
+ if ((long)value < 0x8001 && (long)value > -0x8000)
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ if (code != 0xdc && code != 0xdd && code != 0xff)
+ continue;
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ if (code == 0xdc)
+ bfd_put_8 (abfd, 0xcc, contents + irel->r_offset - 1);
+ else if (code == 0xdd)
+ bfd_put_8 (abfd, 0xcd, contents + irel->r_offset - 1);
+ else if (code == 0xff)
+ bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_PCREL16);
+
+ /* Delete two bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+ }
+
+ /* Try to turn a 16bit pc-relative branch into a 8bit pc-relative
+ branch. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL16)
+ {
+ bfd_vma value = symval;
+
+ /* If we've got a "call" instruction that needs to be turned
+ into a "calls" instruction, do so now. It saves a byte. */
+ if (h && (h->flags & MN10300_CONVERT_CALL_TO_CALLS))
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ /* Make sure we're working with a "call" instruction! */
+ if (code == 0xcd)
+ {
+ /* Note that we've changed the relocs, section contents,
+ etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 1);
+ bfd_put_8 (abfd, 0xff, contents + irel->r_offset);
+
+ /* Fix irel->r_offset and irel->r_addend. */
+ irel->r_offset += 1;
+ irel->r_addend += 1;
+
+ /* Delete one byte of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 1))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+ }
+ else if (h)
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ /* Insert data from the target function into the "call"
+ instruction if needed. */
+ if (code == 0xcd)
+ {
+ bfd_put_8 (abfd, h->movm_args, contents + irel->r_offset + 2);
+ bfd_put_8 (abfd, h->stack_size + h->movm_stack_size,
+ contents + irel->r_offset + 3);
+ }
+ }
+
+ /* Deal with pc-relative gunk. */
+ value -= (sec->output_section->vma + sec->output_offset);
+ value -= irel->r_offset;
+ value += irel->r_addend;
+
+ /* See if the value will fit in 8 bits, note the high value is
+ 0x7f + 1 as the target will be one bytes closer if we are
+ able to relax. */
+ if ((long)value < 0x80 && (long)value > -0x80)
+ {
+ unsigned char code;
+
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ if (code != 0xcc)
+ continue;
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xca, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_PCREL8);
+
+ /* Delete one byte of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 1))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+ }
+
+ /* Try to eliminate an unconditional 8 bit pc-relative branch
+ which immediately follows a conditional 8 bit pc-relative
+ branch around the unconditional branch.
+
+ original: new:
+ bCC lab1 bCC' lab2
+ bra lab2
+ lab1: lab1:
+
+
+ This happens when the bCC can't reach lab2 at assembly time,
+ but due to other relaxations it can reach at link time. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL8)
+ {
+ Elf_Internal_Rela *nrel;
+ bfd_vma value = symval;
+ unsigned char code;
+
+ /* Deal with pc-relative gunk. */
+ value -= (sec->output_section->vma + sec->output_offset);
+ value -= irel->r_offset;
+ value += irel->r_addend;
+
+ /* Do nothing if this reloc is the last byte in the section. */
+ if (irel->r_offset == sec->_cooked_size)
+ continue;
+
+ /* See if the next instruction is an unconditional pc-relative
+ branch, more often than not this test will fail, so we
+ test it first to speed things up. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset + 1);
+ if (code != 0xca)
+ continue;
+
+ /* Also make sure the next relocation applies to the next
+ instruction and that it's a pc-relative 8 bit branch. */
+ nrel = irel + 1;
+ if (nrel == irelend
+ || irel->r_offset + 2 != nrel->r_offset
+ || ELF32_R_TYPE (nrel->r_info) != (int) R_MN10300_PCREL8)
+ continue;
+
+ /* Make sure our destination immediately follows the
+ unconditional branch. */
+ if (symval != (sec->output_section->vma + sec->output_offset
+ + irel->r_offset + 3))
+ continue;
+
+ /* Now make sure we are a conditional branch. This may not
+ be necessary, but why take the chance.
+
+ Note these checks assume that R_MN10300_PCREL8 relocs
+ only occur on bCC and bCCx insns. If they occured
+ elsewhere, we'd need to know the start of this insn
+ for this check to be accurate. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ if (code != 0xc0 && code != 0xc1 && code != 0xc2
+ && code != 0xc3 && code != 0xc4 && code != 0xc5
+ && code != 0xc6 && code != 0xc7 && code != 0xc8
+ && code != 0xc9 && code != 0xe8 && code != 0xe9
+ && code != 0xea && code != 0xeb)
+ continue;
+
+ /* We also have to be sure there is no symbol/label
+ at the unconditional branch. */
+ if (mn10300_elf_symbol_address_p (abfd, sec, extsyms,
+ irel->r_offset + 1))
+ continue;
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Reverse the condition of the first branch. */
+ switch (code)
+ {
+ case 0xc8:
+ code = 0xc9;
+ break;
+ case 0xc9:
+ code = 0xc8;
+ break;
+ case 0xc0:
+ code = 0xc2;
+ break;
+ case 0xc2:
+ code = 0xc0;
+ break;
+ case 0xc3:
+ code = 0xc1;
+ break;
+ case 0xc1:
+ code = 0xc3;
+ break;
+ case 0xc4:
+ code = 0xc6;
+ break;
+ case 0xc6:
+ code = 0xc4;
+ break;
+ case 0xc7:
+ code = 0xc5;
+ break;
+ case 0xc5:
+ code = 0xc7;
+ break;
+ case 0xe8:
+ code = 0xe9;
+ break;
+ case 0x9d:
+ code = 0xe8;
+ break;
+ case 0xea:
+ code = 0xeb;
+ break;
+ case 0xeb:
+ code = 0xea;
+ break;
+ }
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+
+ /* Set the reloc type and symbol for the first branch
+ from the second branch. */
+ irel->r_info = nrel->r_info;
+
+ /* Make the reloc for the second branch a null reloc. */
+ nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
+ R_MN10300_NONE);
+
+ /* Delete two bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ }
+
+
+ /* Try to turn a 32bit immediate, displacement or absolute address
+ into a 16bit immediate, displacement or absolute address. */
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_32)
+ {
+ bfd_vma value = symval;
+ value += irel->r_addend;
+
+
+ /* See if the value will fit in 16 bits.
+ We allow any 16bit match here. We prune those we can't
+ handle below. */
+ if ((long)value < 0x7fff && (long)value > -0x8000)
+ {
+ unsigned char code;
+
+ /* Most insns which have 32bit operands are 6 bytes long;
+ exceptions are pcrel insns and bit insns.
+
+ We handle pcrel insns above. We don't bother trying
+ to handle the bit insns here.
+
+ The first byte of the remaining insns will be 0xfc. */
+
+ /* Get the first opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+
+ if (code != 0xfc)
+ continue;
+
+ /* Get the second opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+ if ((code & 0xf0) < 0x80)
+ switch (code & 0xf0)
+ {
+ /* mov (d32,am),dn -> mov (d32,am),dn
+ mov dm,(d32,am) -> mov dn,(d32,am)
+ mov (d32,am),an -> mov (d32,am),an
+ mov dm,(d32,am) -> mov dn,(d32,am)
+ movbu (d32,am),dn -> movbu (d32,am),dn
+ movbu dm,(d32,am) -> movbu dn,(d32,am)
+ movhu (d32,am),dn -> movhu (d32,am),dn
+ movhu dm,(d32,am) -> movhu dn,(d32,am) */
+ case 0x00:
+ case 0x10:
+ case 0x20:
+ case 0x30:
+ case 0x40:
+ case 0x50:
+ case 0x60:
+ case 0x70:
+ /* Not safe if the high bit is on as relaxing may
+ move the value out of high mem and thus not fit
+ in a signed 16bit value. */
+ if (code == 0xcc
+ && (value & 0x8000))
+ continue;
+
+ /* Note that we've changed the relocation contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_16);
+
+ /* Delete two bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+ }
+ else if ((code & 0xf0) == 0x80
+ || (code & 0xf0) == 0x90)
+ switch (code & 0xf3)
+ {
+ /* mov dn,(abs32) -> mov dn,(abs16)
+ movbu dn,(abs32) -> movbu dn,(abs16)
+ movhu dn,(abs32) -> movhu dn,(abs16) */
+ case 0x81:
+ case 0x82:
+ case 0x83:
+ /* Note that we've changed the relocation contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ if ((code & 0xf3) == 0x81)
+ code = 0x01 + (code & 0x0c);
+ else if ((code & 0xf3) == 0x82)
+ code = 0x02 + (code & 0x0c);
+ else if ((code & 0xf3) == 0x83)
+ code = 0x03 + (code & 0x0c);
+ else
+ abort ();
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_16);
+
+ /* The opcode got shorter too, so we have to fix the
+ addend and offset too! */
+ irel->r_offset -= 1;
+
+ /* Delete three bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 3))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+
+ /* mov am,(abs32) -> mov am,(abs16)
+ mov am,(d32,sp) -> mov am,(d16,sp)
+ mov dm,(d32,sp) -> mov dm,(d32,sp)
+ movbu dm,(d32,sp) -> movbu dm,(d32,sp)
+ movhu dm,(d32,sp) -> movhu dm,(d32,sp) */
+ case 0x80:
+ case 0x90:
+ case 0x91:
+ case 0x92:
+ case 0x93:
+ /* Note that we've changed the relocation contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_16);
+
+ /* Delete two bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+ }
+ else if ((code & 0xf0) < 0xf0)
+ switch (code & 0xfc)
+ {
+ /* mov imm32,dn -> mov imm16,dn
+ mov imm32,an -> mov imm16,an
+ mov (abs32),dn -> mov (abs16),dn
+ movbu (abs32),dn -> movbu (abs16),dn
+ movhu (abs32),dn -> movhu (abs16),dn */
+ case 0xcc:
+ case 0xdc:
+ case 0xa4:
+ case 0xa8:
+ case 0xac:
+ /* Not safe if the high bit is on as relaxing may
+ move the value out of high mem and thus not fit
+ in a signed 16bit value. */
+ if (code == 0xcc
+ && (value & 0x8000))
+ continue;
+
+ /* Note that we've changed the relocation contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ if ((code & 0xfc) == 0xcc)
+ code = 0x2c + (code & 0x03);
+ else if ((code & 0xfc) == 0xdc)
+ code = 0x24 + (code & 0x03);
+ else if ((code & 0xfc) == 0xa4)
+ code = 0x30 + (code & 0x03);
+ else if ((code & 0xfc) == 0xa8)
+ code = 0x34 + (code & 0x03);
+ else if ((code & 0xfc) == 0xac)
+ code = 0x38 + (code & 0x03);
+ else
+ abort ();
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_16);
+
+ /* The opcode got shorter too, so we have to fix the
+ addend and offset too! */
+ irel->r_offset -= 1;
+
+ /* Delete three bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 1, 3))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+
+ /* mov (abs32),an -> mov (abs16),an
+ mov (d32,sp),an -> mov (d32,sp),an
+ mov (d32,sp),dn -> mov (d32,sp),dn
+ movbu (d32,sp),dn -> movbu (d32,sp),dn
+ movhu (d32,sp),dn -> movhu (d32,sp),dn
+ add imm32,dn -> add imm16,dn
+ cmp imm32,dn -> cmp imm16,dn
+ add imm32,an -> add imm16,an
+ cmp imm32,an -> cmp imm16,an
+ and imm32,dn -> and imm32,dn
+ or imm32,dn -> or imm32,dn
+ xor imm32,dn -> xor imm32,dn
+ btst imm32,dn -> btst imm32,dn */
+
+ case 0xa0:
+ case 0xb0:
+ case 0xb1:
+ case 0xb2:
+ case 0xb3:
+ case 0xc0:
+ case 0xc8:
+
+ case 0xd0:
+ case 0xd8:
+ case 0xe0:
+ case 0xe1:
+ case 0xe2:
+ case 0xe3:
+ /* Note that we've changed the relocation contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_16);
+
+ /* Delete two bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+ }
+ else if (code == 0xfe)
+ {
+ /* add imm32,sp -> add imm16,sp */
+
+ /* Note that we've changed the relocation contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Fix the opcode. */
+ bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
+ bfd_put_8 (abfd, 0xfe, contents + irel->r_offset - 1);
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_MN10300_16);
+
+ /* Delete two bytes of data. */
+ if (!mn10300_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 2))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (sec)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ free_extsyms = NULL;
+ }
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ if (free_extsyms != NULL)
+ free (free_extsyms);
+ return false;
+}
+
+/* Compute the stack size and movm arguments for the function
+ referred to by HASH at address ADDR in section with
+ contents CONTENTS, store the information in the hash table. */
+static void
+compute_function_info (abfd, hash, addr, contents)
+ bfd *abfd;
+ struct elf32_mn10300_link_hash_entry *hash;
+ bfd_vma addr;
+ unsigned char *contents;
+{
+ unsigned char byte1, byte2;
+ /* We only care about a very small subset of the possible prologue
+ sequences here. Basically we look for:
+
+ movm [d2,d3,a2,a3],sp (optional)
+ add <size>,sp (optional, and only for sizes which fit in an unsigned
+ 8 bit number)
+
+ If we find anything else, we quit. */
+
+ /* Look for movm [regs],sp */
+ byte1 = bfd_get_8 (abfd, contents + addr);
+ byte2 = bfd_get_8 (abfd, contents + addr + 1);
+
+ if (byte1 == 0xcf)
+ {
+ hash->movm_args = byte2;
+ addr += 2;
+ byte1 = bfd_get_8 (abfd, contents + addr);
+ byte2 = bfd_get_8 (abfd, contents + addr + 1);
+ }
+
+ /* Now figure out how much stack space will be allocated by the movm
+ instruction. We need this kept separate from the funtion's normal
+ stack space. */
+ if (hash->movm_args)
+ {
+ /* Space for d2. */
+ if (hash->movm_args & 0x80)
+ hash->movm_stack_size += 4;
+
+ /* Space for d3. */
+ if (hash->movm_args & 0x40)
+ hash->movm_stack_size += 4;
+
+ /* Space for a2. */
+ if (hash->movm_args & 0x20)
+ hash->movm_stack_size += 4;
+
+ /* Space for a3. */
+ if (hash->movm_args & 0x10)
+ hash->movm_stack_size += 4;
+
+ /* "other" space. d0, d1, a0, a1, mdr, lir, lar, 4 byte pad. */
+ if (hash->movm_args & 0x08)
+ hash->movm_stack_size += 8 * 4;
+
+ }
+
+ /* Now look for the two stack adjustment variants. */
+ if (byte1 == 0xf8 && byte2 == 0xfe)
+ {
+ int temp = bfd_get_8 (abfd, contents + addr + 2);
+ temp = ((temp & 0xff) ^ (~0x7f)) + 0x80;
+
+ hash->stack_size = -temp;
+ }
+ else if (byte1 == 0xfa && byte2 == 0xfe)
+ {
+ int temp = bfd_get_16 (abfd, contents + addr + 2);
+ temp = ((temp & 0xffff) ^ (~0x7fff)) + 0x8000;
+ temp = -temp;
+
+ if (temp < 255)
+ hash->stack_size = temp;
+ }
+
+ /* If the total stack to be allocated by the call instruction is more
+ than 255 bytes, then we can't remove the stack adjustment by using
+ "call" (we might still be able to remove the "movm" instruction. */
+ if (hash->stack_size + hash->movm_stack_size > 255)
+ hash->stack_size = 0;
+
+ return;
+}
+
+/* Delete some bytes from a section while relaxing. */
+
+static boolean
+mn10300_elf_relax_delete_bytes (abfd, sec, addr, count)
+ bfd *abfd;
+ asection *sec;
+ bfd_vma addr;
+ int count;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf32_External_Sym *extsyms;
+ int shndx, index;
+ bfd_byte *contents;
+ Elf_Internal_Rela *irel, *irelend;
+ Elf_Internal_Rela *irelalign;
+ bfd_vma toaddr;
+ Elf32_External_Sym *esym, *esymend;
+ struct elf32_mn10300_link_hash_entry *sym_hash;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ contents = elf_section_data (sec)->this_hdr.contents;
+
+ /* The deletion must stop at the next ALIGN reloc for an aligment
+ power larger than the number of bytes we are deleting. */
+
+ irelalign = NULL;
+ toaddr = sec->_cooked_size;
+
+ irel = elf_section_data (sec)->relocs;
+ irelend = irel + sec->reloc_count;
+
+ /* Actually delete the bytes. */
+ memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ sec->_cooked_size -= count;
+
+ /* Adjust all the relocs. */
+ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+ {
+ /* Get the new reloc address. */
+ if ((irel->r_offset > addr
+ && irel->r_offset < toaddr))
+ irel->r_offset -= count;
+ }
+
+ /* Adjust the local symbols defined in this section. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+
+ if (isym.st_shndx == shndx
+ && isym.st_value > addr
+ && isym.st_value < toaddr)
+ {
+ isym.st_value -= count;
+ bfd_elf32_swap_symbol_out (abfd, &isym, esym);
+ }
+ }
+
+ /* Now adjust the global symbols defined in this section. */
+ esym = extsyms + symtab_hdr->sh_info;
+ esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
+ for (index = 0; esym < esymend; esym++, index++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+ sym_hash = (struct elf32_mn10300_link_hash_entry *)
+ (elf_sym_hashes (abfd)[index]);
+ if (isym.st_shndx == shndx
+ && ((sym_hash)->root.root.type == bfd_link_hash_defined
+ || (sym_hash)->root.root.type == bfd_link_hash_defweak)
+ && (sym_hash)->root.root.u.def.section == sec
+ && (sym_hash)->root.root.u.def.value > addr
+ && (sym_hash)->root.root.u.def.value < toaddr)
+ {
+ (sym_hash)->root.root.u.def.value -= count;
+ }
+ }
+
+ return true;
+}
+
+/* Return true if a symbol exists at the given address, else return
+ false. */
+static boolean
+mn10300_elf_symbol_address_p (abfd, sec, extsyms, addr)
+ bfd *abfd;
+ asection *sec;
+ Elf32_External_Sym *extsyms;
+ bfd_vma addr;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ int shndx;
+ Elf32_External_Sym *esym, *esymend;
+ struct elf32_mn10300_link_hash_entry **sym_hash, **sym_hash_end;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ /* Examine all the symbols. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+
+ if (isym.st_shndx == shndx
+ && isym.st_value == addr)
+ return true;
+ }
+
+ sym_hash = (struct elf32_mn10300_link_hash_entry **)(elf_sym_hashes (abfd));
+ sym_hash_end = (sym_hash
+ + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
+ - symtab_hdr->sh_info));
+ for (; sym_hash < sym_hash_end; sym_hash++)
+ {
+ if (((*sym_hash)->root.root.type == bfd_link_hash_defined
+ || (*sym_hash)->root.root.type == bfd_link_hash_defweak)
+ && (*sym_hash)->root.root.u.def.section == sec
+ && (*sym_hash)->root.root.u.def.value == addr)
+ return true;
+ }
+ return false;
+}
+
+/* This is a version of bfd_generic_get_relocated_section_contents
+ which uses mn10300_elf_relocate_section. */
+
+static bfd_byte *
+mn10300_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *input_section = link_order->u.indirect.section;
+ bfd *input_bfd = input_section->owner;
+ asection **sections = NULL;
+ Elf_Internal_Rela *internal_relocs = NULL;
+ Elf32_External_Sym *external_syms = NULL;
+ Elf_Internal_Sym *internal_syms = NULL;
+
+ /* We only need to handle the case of relaxing, or of having a
+ particular set of section contents, specially. */
+ if (relocateable
+ || elf_section_data (input_section)->this_hdr.contents == NULL)
+ return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
+ link_order, data,
+ relocateable,
+ symbols);
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ memcpy (data, elf_section_data (input_section)->this_hdr.contents,
+ input_section->_raw_size);
+
+ if ((input_section->flags & SEC_RELOC) != 0
+ && input_section->reloc_count > 0)
+ {
+ Elf_Internal_Sym *isymp;
+ asection **secpp;
+ Elf32_External_Sym *esym, *esymend;
+
+ if (symtab_hdr->contents != NULL)
+ external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ external_syms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf32_External_Sym)));
+ if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
+ symtab_hdr->sh_info, input_bfd)
+ != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ goto error_return;
+ }
+
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (input_bfd, input_section, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL, false));
+ if (internal_relocs == NULL)
+ goto error_return;
+
+ internal_syms = ((Elf_Internal_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf_Internal_Sym)));
+ if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ sections = (asection **) bfd_malloc (symtab_hdr->sh_info
+ * sizeof (asection *));
+ if (sections == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ isymp = internal_syms;
+ secpp = sections;
+ esym = external_syms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; ++esym, ++isymp, ++secpp)
+ {
+ asection *isec;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, isymp);
+
+ if (isymp->st_shndx == SHN_UNDEF)
+ isec = bfd_und_section_ptr;
+ else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
+ isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
+ else if (isymp->st_shndx == SHN_ABS)
+ isec = bfd_abs_section_ptr;
+ else if (isymp->st_shndx == SHN_COMMON)
+ isec = bfd_com_section_ptr;
+ else
+ {
+ /* Who knows? */
+ isec = NULL;
+ }
+
+ *secpp = isec;
+ }
+
+ if (! mn10300_elf_relocate_section (output_bfd, link_info, input_bfd,
+ input_section, data, internal_relocs,
+ internal_syms, sections))
+ goto error_return;
+
+ if (sections != NULL)
+ free (sections);
+ sections = NULL;
+ if (internal_syms != NULL)
+ free (internal_syms);
+ internal_syms = NULL;
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ external_syms = NULL;
+ if (internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ internal_relocs = NULL;
+ }
+
+ return data;
+
+ error_return:
+ if (internal_relocs != NULL
+ && internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ if (internal_syms != NULL)
+ free (internal_syms);
+ if (sections != NULL)
+ free (sections);
+ return NULL;
+}
+
+/* Assorted hash table functions. */
+
+/* Initialize an entry in the link hash table. */
+
+/* Create an entry in an MN10300 ELF linker hash table. */
+
+static struct bfd_hash_entry *
+elf32_mn10300_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct elf32_mn10300_link_hash_entry *ret =
+ (struct elf32_mn10300_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct elf32_mn10300_link_hash_entry *) NULL)
+ ret = ((struct elf32_mn10300_link_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct elf32_mn10300_link_hash_entry)));
+ if (ret == (struct elf32_mn10300_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct elf32_mn10300_link_hash_entry *)
+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct elf32_mn10300_link_hash_entry *) NULL)
+ {
+ ret->direct_calls = 0;
+ ret->stack_size = 0;
+ ret->movm_stack_size = 0;
+ ret->flags = 0;
+ ret->movm_args = 0;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create an mn10300 ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+elf32_mn10300_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf32_mn10300_link_hash_table *ret;
+
+ ret = ((struct elf32_mn10300_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf32_mn10300_link_hash_table)));
+ if (ret == (struct elf32_mn10300_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
+ elf32_mn10300_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ ret->flags = 0;
+ ret->static_hash_table
+ = ((struct elf32_mn10300_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
+ if (ret->static_hash_table == NULL)
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ if (! _bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd,
+ elf32_mn10300_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret->static_hash_table);
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+ return &ret->root.root;
+}
+
+static int
+elf_mn10300_mach (flags)
+ flagword flags;
+{
+ switch (flags & EF_MN10300_MACH)
+ {
+ case E_MN10300_MACH_MN10300:
+ default:
+ return bfd_mach_mn10300;
+
+ }
+}
+
+/* The final processing done just before writing out a MN10300 ELF object
+ file. This gets the MN10300 architecture right based on the machine
+ number. */
+
+/*ARGSUSED*/
+void
+_bfd_mn10300_elf_final_write_processing (abfd, linker)
+ bfd *abfd;
+ boolean linker;
+{
+ unsigned long val;
+ unsigned int i;
+ Elf_Internal_Shdr **hdrpp;
+ const char *name;
+ asection *sec;
+
+ switch (bfd_get_mach (abfd))
+ {
+ default:
+ case bfd_mach_mn10300:
+ val = E_MN10300_MACH_MN10300;
+ break;
+
+ }
+
+ elf_elfheader (abfd)->e_flags &= ~ (EF_MN10300_MACH);
+ elf_elfheader (abfd)->e_flags |= val;
+}
+
+boolean
+_bfd_mn10300_elf_object_p (abfd)
+ bfd *abfd;
+{
+ bfd_default_set_arch_mach (abfd, bfd_arch_mn10300,
+ elf_mn10300_mach (elf_elfheader (abfd)->e_flags));
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+
+boolean
+_bfd_mn10300_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+ && bfd_get_mach (obfd) < bfd_get_mach (ibfd))
+ {
+ if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
+ bfd_get_mach (ibfd)))
+ return false;
+ }
+
+ return true;
+}
+
+
+#define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec
+#define TARGET_LITTLE_NAME "elf32-mn10300"
+#define ELF_ARCH bfd_arch_mn10300
+#define ELF_MACHINE_CODE EM_CYGNUS_MN10300
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_info_to_howto mn10300_info_to_howto
+#define elf_info_to_howto_rel 0
+#define elf_backend_can_gc_sections 1
+#define elf_backend_check_relocs mn10300_elf_check_relocs
+#define elf_backend_gc_mark_hook mn10300_elf_gc_mark_hook
+#define elf_backend_relocate_section mn10300_elf_relocate_section
+#define bfd_elf32_bfd_relax_section mn10300_elf_relax_section
+#define bfd_elf32_bfd_get_relocated_section_contents \
+ mn10300_elf_get_relocated_section_contents
+#define bfd_elf32_bfd_link_hash_table_create \
+ elf32_mn10300_link_hash_table_create
+
+#define elf_symbol_leading_char '_'
+
+/* So we can set bits in e_flags. */
+#define elf_backend_final_write_processing \
+ _bfd_mn10300_elf_final_write_processing
+#define elf_backend_object_p _bfd_mn10300_elf_object_p
+
+#define bfd_elf32_bfd_merge_private_bfd_data \
+ _bfd_mn10300_elf_merge_private_bfd_data
+
+
+#include "elf32-target.h"
diff --git a/bfd/elf.c b/bfd/elf.c
new file mode 100644
index 00000000000..ab010d46f4b
--- /dev/null
+++ b/bfd/elf.c
@@ -0,0 +1,5250 @@
+/* ELF executable support for BFD.
+ Copyright 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+
+SECTION
+ ELF backends
+
+ BFD support for ELF formats is being worked on.
+ Currently, the best supported back ends are for sparc and i386
+ (running svr4 or Solaris 2).
+
+ Documentation of the internals of the support code still needs
+ to be written. The code is changing quickly enough that we
+ haven't bothered yet.
+ */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#define ARCH_SIZE 0
+#include "elf-bfd.h"
+
+static INLINE struct elf_segment_map *make_mapping
+ PARAMS ((bfd *, asection **, unsigned int, unsigned int, boolean));
+static boolean map_sections_to_segments PARAMS ((bfd *));
+static int elf_sort_sections PARAMS ((const PTR, const PTR));
+static boolean assign_file_positions_for_segments PARAMS ((bfd *));
+static boolean assign_file_positions_except_relocs PARAMS ((bfd *));
+static boolean prep_headers PARAMS ((bfd *));
+static boolean swap_out_syms PARAMS ((bfd *, struct bfd_strtab_hash **, int));
+static boolean copy_private_bfd_data PARAMS ((bfd *, bfd *));
+static char *elf_read PARAMS ((bfd *, long, unsigned int));
+static void elf_fake_sections PARAMS ((bfd *, asection *, PTR));
+static boolean assign_section_numbers PARAMS ((bfd *));
+static INLINE int sym_is_global PARAMS ((bfd *, asymbol *));
+static boolean elf_map_symbols PARAMS ((bfd *));
+static bfd_size_type get_program_header_size PARAMS ((bfd *));
+
+/* Swap version information in and out. The version information is
+ currently size independent. If that ever changes, this code will
+ need to move into elfcode.h. */
+
+/* Swap in a Verdef structure. */
+
+void
+_bfd_elf_swap_verdef_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Verdef *src;
+ Elf_Internal_Verdef *dst;
+{
+ dst->vd_version = bfd_h_get_16 (abfd, src->vd_version);
+ dst->vd_flags = bfd_h_get_16 (abfd, src->vd_flags);
+ dst->vd_ndx = bfd_h_get_16 (abfd, src->vd_ndx);
+ dst->vd_cnt = bfd_h_get_16 (abfd, src->vd_cnt);
+ dst->vd_hash = bfd_h_get_32 (abfd, src->vd_hash);
+ dst->vd_aux = bfd_h_get_32 (abfd, src->vd_aux);
+ dst->vd_next = bfd_h_get_32 (abfd, src->vd_next);
+}
+
+/* Swap out a Verdef structure. */
+
+void
+_bfd_elf_swap_verdef_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Verdef *src;
+ Elf_External_Verdef *dst;
+{
+ bfd_h_put_16 (abfd, src->vd_version, dst->vd_version);
+ bfd_h_put_16 (abfd, src->vd_flags, dst->vd_flags);
+ bfd_h_put_16 (abfd, src->vd_ndx, dst->vd_ndx);
+ bfd_h_put_16 (abfd, src->vd_cnt, dst->vd_cnt);
+ bfd_h_put_32 (abfd, src->vd_hash, dst->vd_hash);
+ bfd_h_put_32 (abfd, src->vd_aux, dst->vd_aux);
+ bfd_h_put_32 (abfd, src->vd_next, dst->vd_next);
+}
+
+/* Swap in a Verdaux structure. */
+
+void
+_bfd_elf_swap_verdaux_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Verdaux *src;
+ Elf_Internal_Verdaux *dst;
+{
+ dst->vda_name = bfd_h_get_32 (abfd, src->vda_name);
+ dst->vda_next = bfd_h_get_32 (abfd, src->vda_next);
+}
+
+/* Swap out a Verdaux structure. */
+
+void
+_bfd_elf_swap_verdaux_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Verdaux *src;
+ Elf_External_Verdaux *dst;
+{
+ bfd_h_put_32 (abfd, src->vda_name, dst->vda_name);
+ bfd_h_put_32 (abfd, src->vda_next, dst->vda_next);
+}
+
+/* Swap in a Verneed structure. */
+
+void
+_bfd_elf_swap_verneed_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Verneed *src;
+ Elf_Internal_Verneed *dst;
+{
+ dst->vn_version = bfd_h_get_16 (abfd, src->vn_version);
+ dst->vn_cnt = bfd_h_get_16 (abfd, src->vn_cnt);
+ dst->vn_file = bfd_h_get_32 (abfd, src->vn_file);
+ dst->vn_aux = bfd_h_get_32 (abfd, src->vn_aux);
+ dst->vn_next = bfd_h_get_32 (abfd, src->vn_next);
+}
+
+/* Swap out a Verneed structure. */
+
+void
+_bfd_elf_swap_verneed_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Verneed *src;
+ Elf_External_Verneed *dst;
+{
+ bfd_h_put_16 (abfd, src->vn_version, dst->vn_version);
+ bfd_h_put_16 (abfd, src->vn_cnt, dst->vn_cnt);
+ bfd_h_put_32 (abfd, src->vn_file, dst->vn_file);
+ bfd_h_put_32 (abfd, src->vn_aux, dst->vn_aux);
+ bfd_h_put_32 (abfd, src->vn_next, dst->vn_next);
+}
+
+/* Swap in a Vernaux structure. */
+
+void
+_bfd_elf_swap_vernaux_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Vernaux *src;
+ Elf_Internal_Vernaux *dst;
+{
+ dst->vna_hash = bfd_h_get_32 (abfd, src->vna_hash);
+ dst->vna_flags = bfd_h_get_16 (abfd, src->vna_flags);
+ dst->vna_other = bfd_h_get_16 (abfd, src->vna_other);
+ dst->vna_name = bfd_h_get_32 (abfd, src->vna_name);
+ dst->vna_next = bfd_h_get_32 (abfd, src->vna_next);
+}
+
+/* Swap out a Vernaux structure. */
+
+void
+_bfd_elf_swap_vernaux_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Vernaux *src;
+ Elf_External_Vernaux *dst;
+{
+ bfd_h_put_32 (abfd, src->vna_hash, dst->vna_hash);
+ bfd_h_put_16 (abfd, src->vna_flags, dst->vna_flags);
+ bfd_h_put_16 (abfd, src->vna_other, dst->vna_other);
+ bfd_h_put_32 (abfd, src->vna_name, dst->vna_name);
+ bfd_h_put_32 (abfd, src->vna_next, dst->vna_next);
+}
+
+/* Swap in a Versym structure. */
+
+void
+_bfd_elf_swap_versym_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Versym *src;
+ Elf_Internal_Versym *dst;
+{
+ dst->vs_vers = bfd_h_get_16 (abfd, src->vs_vers);
+}
+
+/* Swap out a Versym structure. */
+
+void
+_bfd_elf_swap_versym_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Versym *src;
+ Elf_External_Versym *dst;
+{
+ bfd_h_put_16 (abfd, src->vs_vers, dst->vs_vers);
+}
+
+/* Standard ELF hash function. Do not change this function; you will
+ cause invalid hash tables to be generated. */
+unsigned long
+bfd_elf_hash (name)
+ CONST unsigned char *name;
+{
+ unsigned long h = 0;
+ unsigned long g;
+ int ch;
+
+ while ((ch = *name++) != '\0')
+ {
+ h = (h << 4) + ch;
+ if ((g = (h & 0xf0000000)) != 0)
+ {
+ h ^= g >> 24;
+ /* The ELF ABI says `h &= ~g', but this is equivalent in
+ this case and on some machines one insn instead of two. */
+ h ^= g;
+ }
+ }
+ return h;
+}
+
+/* Read a specified number of bytes at a specified offset in an ELF
+ file, into a newly allocated buffer, and return a pointer to the
+ buffer. */
+
+static char *
+elf_read (abfd, offset, size)
+ bfd * abfd;
+ long offset;
+ unsigned int size;
+{
+ char *buf;
+
+ if ((buf = bfd_alloc (abfd, size)) == NULL)
+ return NULL;
+ if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ return NULL;
+ if (bfd_read ((PTR) buf, size, 1, abfd) != size)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_file_truncated);
+ return NULL;
+ }
+ return buf;
+}
+
+boolean
+bfd_elf_mkobject (abfd)
+ bfd * abfd;
+{
+ /* this just does initialization */
+ /* coff_mkobject zalloc's space for tdata.coff_obj_data ... */
+ elf_tdata (abfd) = (struct elf_obj_tdata *)
+ bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
+ if (elf_tdata (abfd) == 0)
+ return false;
+ /* since everything is done at close time, do we need any
+ initialization? */
+
+ return true;
+}
+
+boolean
+bfd_elf_mkcorefile (abfd)
+ bfd * abfd;
+{
+ /* I think this can be done just like an object file. */
+ return bfd_elf_mkobject (abfd);
+}
+
+char *
+bfd_elf_get_str_section (abfd, shindex)
+ bfd * abfd;
+ unsigned int shindex;
+{
+ Elf_Internal_Shdr **i_shdrp;
+ char *shstrtab = NULL;
+ unsigned int offset;
+ unsigned int shstrtabsize;
+
+ i_shdrp = elf_elfsections (abfd);
+ if (i_shdrp == 0 || i_shdrp[shindex] == 0)
+ return 0;
+
+ shstrtab = (char *) i_shdrp[shindex]->contents;
+ if (shstrtab == NULL)
+ {
+ /* No cached one, attempt to read, and cache what we read. */
+ offset = i_shdrp[shindex]->sh_offset;
+ shstrtabsize = i_shdrp[shindex]->sh_size;
+ shstrtab = elf_read (abfd, offset, shstrtabsize);
+ i_shdrp[shindex]->contents = (PTR) shstrtab;
+ }
+ return shstrtab;
+}
+
+char *
+bfd_elf_string_from_elf_section (abfd, shindex, strindex)
+ bfd * abfd;
+ unsigned int shindex;
+ unsigned int strindex;
+{
+ Elf_Internal_Shdr *hdr;
+
+ if (strindex == 0)
+ return "";
+
+ hdr = elf_elfsections (abfd)[shindex];
+
+ if (hdr->contents == NULL
+ && bfd_elf_get_str_section (abfd, shindex) == NULL)
+ return NULL;
+
+ if (strindex >= hdr->sh_size)
+ {
+ (*_bfd_error_handler)
+ (_("%s: invalid string offset %u >= %lu for section `%s'"),
+ bfd_get_filename (abfd), strindex, (unsigned long) hdr->sh_size,
+ ((shindex == elf_elfheader(abfd)->e_shstrndx
+ && strindex == hdr->sh_name)
+ ? ".shstrtab"
+ : elf_string_from_elf_strtab (abfd, hdr->sh_name)));
+ return "";
+ }
+
+ return ((char *) hdr->contents) + strindex;
+}
+
+/* Make a BFD section from an ELF section. We store a pointer to the
+ BFD section in the bfd_section field of the header. */
+
+boolean
+_bfd_elf_make_section_from_shdr (abfd, hdr, name)
+ bfd *abfd;
+ Elf_Internal_Shdr *hdr;
+ const char *name;
+{
+ asection *newsect;
+ flagword flags;
+
+ if (hdr->bfd_section != NULL)
+ {
+ BFD_ASSERT (strcmp (name,
+ bfd_get_section_name (abfd, hdr->bfd_section)) == 0);
+ return true;
+ }
+
+ newsect = bfd_make_section_anyway (abfd, name);
+ if (newsect == NULL)
+ return false;
+
+ newsect->filepos = hdr->sh_offset;
+
+ if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
+ || ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
+ || ! bfd_set_section_alignment (abfd, newsect,
+ bfd_log2 (hdr->sh_addralign)))
+ return false;
+
+ flags = SEC_NO_FLAGS;
+ if (hdr->sh_type != SHT_NOBITS)
+ flags |= SEC_HAS_CONTENTS;
+ if ((hdr->sh_flags & SHF_ALLOC) != 0)
+ {
+ flags |= SEC_ALLOC;
+ if (hdr->sh_type != SHT_NOBITS)
+ flags |= SEC_LOAD;
+ }
+ if ((hdr->sh_flags & SHF_WRITE) == 0)
+ flags |= SEC_READONLY;
+ if ((hdr->sh_flags & SHF_EXECINSTR) != 0)
+ flags |= SEC_CODE;
+ else if ((flags & SEC_LOAD) != 0)
+ flags |= SEC_DATA;
+
+ /* The debugging sections appear to be recognized only by name, not
+ any sort of flag. */
+ if (strncmp (name, ".debug", sizeof ".debug" - 1) == 0
+ || strncmp (name, ".line", sizeof ".line" - 1) == 0
+ || strncmp (name, ".stab", sizeof ".stab" - 1) == 0)
+ flags |= SEC_DEBUGGING;
+
+ /* As a GNU extension, if the name begins with .gnu.linkonce, we
+ only link a single copy of the section. This is used to support
+ g++. g++ will emit each template expansion in its own section.
+ The symbols will be defined as weak, so that multiple definitions
+ are permitted. The GNU linker extension is to actually discard
+ all but one of the sections. */
+ if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0)
+ flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
+
+ if (! bfd_set_section_flags (abfd, newsect, flags))
+ return false;
+
+ if ((flags & SEC_ALLOC) != 0)
+ {
+ Elf_Internal_Phdr *phdr;
+ unsigned int i;
+
+ /* Look through the phdrs to see if we need to adjust the lma.
+ If all the p_paddr fields are zero, we ignore them, since
+ some ELF linkers produce such output. */
+ phdr = elf_tdata (abfd)->phdr;
+ for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
+ {
+ if (phdr->p_paddr != 0)
+ break;
+ }
+ if (i < elf_elfheader (abfd)->e_phnum)
+ {
+ phdr = elf_tdata (abfd)->phdr;
+ for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
+ {
+ if (phdr->p_type == PT_LOAD
+ && phdr->p_vaddr != phdr->p_paddr
+ && phdr->p_vaddr <= hdr->sh_addr
+ && (phdr->p_vaddr + phdr->p_memsz
+ >= hdr->sh_addr + hdr->sh_size)
+ && ((flags & SEC_LOAD) == 0
+ || (phdr->p_offset <= (bfd_vma) hdr->sh_offset
+ && (phdr->p_offset + phdr->p_filesz
+ >= hdr->sh_offset + hdr->sh_size))))
+ {
+ newsect->lma += phdr->p_paddr - phdr->p_vaddr;
+ break;
+ }
+ }
+ }
+ }
+
+ hdr->bfd_section = newsect;
+ elf_section_data (newsect)->this_hdr = *hdr;
+
+ return true;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_elf_find_section
+
+SYNOPSIS
+ struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
+
+DESCRIPTION
+ Helper functions for GDB to locate the string tables.
+ Since BFD hides string tables from callers, GDB needs to use an
+ internal hook to find them. Sun's .stabstr, in particular,
+ isn't even pointed to by the .stab section, so ordinary
+ mechanisms wouldn't work to find it, even if we had some.
+*/
+
+struct elf_internal_shdr *
+bfd_elf_find_section (abfd, name)
+ bfd * abfd;
+ char *name;
+{
+ Elf_Internal_Shdr **i_shdrp;
+ char *shstrtab;
+ unsigned int max;
+ unsigned int i;
+
+ i_shdrp = elf_elfsections (abfd);
+ if (i_shdrp != NULL)
+ {
+ shstrtab = bfd_elf_get_str_section
+ (abfd, elf_elfheader (abfd)->e_shstrndx);
+ if (shstrtab != NULL)
+ {
+ max = elf_elfheader (abfd)->e_shnum;
+ for (i = 1; i < max; i++)
+ if (!strcmp (&shstrtab[i_shdrp[i]->sh_name], name))
+ return i_shdrp[i];
+ }
+ }
+ return 0;
+}
+
+const char *const bfd_elf_section_type_names[] = {
+ "SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
+ "SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
+ "SHT_NOBITS", "SHT_REL", "SHT_SHLIB", "SHT_DYNSYM",
+};
+
+/* ELF relocs are against symbols. If we are producing relocateable
+ output, and the reloc is against an external symbol, and nothing
+ has given us any additional addend, the resulting reloc will also
+ be against the same symbol. In such a case, we don't want to
+ change anything about the way the reloc is handled, since it will
+ all be done at final link time. Rather than put special case code
+ into bfd_perform_relocation, all the reloc types use this howto
+ function. It just short circuits the reloc if producing
+ relocateable output against an external symbol. */
+
+/*ARGSUSED*/
+bfd_reloc_status_type
+bfd_elf_generic_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc_entry->howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ return bfd_reloc_continue;
+}
+
+/* Print out the program headers. */
+
+boolean
+_bfd_elf_print_private_bfd_data (abfd, farg)
+ bfd *abfd;
+ PTR farg;
+{
+ FILE *f = (FILE *) farg;
+ Elf_Internal_Phdr *p;
+ asection *s;
+ bfd_byte *dynbuf = NULL;
+
+ p = elf_tdata (abfd)->phdr;
+ if (p != NULL)
+ {
+ unsigned int i, c;
+
+ fprintf (f, _("\nProgram Header:\n"));
+ c = elf_elfheader (abfd)->e_phnum;
+ for (i = 0; i < c; i++, p++)
+ {
+ const char *s;
+ char buf[20];
+
+ switch (p->p_type)
+ {
+ case PT_NULL: s = "NULL"; break;
+ case PT_LOAD: s = "LOAD"; break;
+ case PT_DYNAMIC: s = "DYNAMIC"; break;
+ case PT_INTERP: s = "INTERP"; break;
+ case PT_NOTE: s = "NOTE"; break;
+ case PT_SHLIB: s = "SHLIB"; break;
+ case PT_PHDR: s = "PHDR"; break;
+ default: sprintf (buf, "0x%lx", p->p_type); s = buf; break;
+ }
+ fprintf (f, "%8s off 0x", s);
+ fprintf_vma (f, p->p_offset);
+ fprintf (f, " vaddr 0x");
+ fprintf_vma (f, p->p_vaddr);
+ fprintf (f, " paddr 0x");
+ fprintf_vma (f, p->p_paddr);
+ fprintf (f, " align 2**%u\n", bfd_log2 (p->p_align));
+ fprintf (f, " filesz 0x");
+ fprintf_vma (f, p->p_filesz);
+ fprintf (f, " memsz 0x");
+ fprintf_vma (f, p->p_memsz);
+ fprintf (f, " flags %c%c%c",
+ (p->p_flags & PF_R) != 0 ? 'r' : '-',
+ (p->p_flags & PF_W) != 0 ? 'w' : '-',
+ (p->p_flags & PF_X) != 0 ? 'x' : '-');
+ if ((p->p_flags &~ (PF_R | PF_W | PF_X)) != 0)
+ fprintf (f, " %lx", p->p_flags &~ (PF_R | PF_W | PF_X));
+ fprintf (f, "\n");
+ }
+ }
+
+ s = bfd_get_section_by_name (abfd, ".dynamic");
+ if (s != NULL)
+ {
+ int elfsec;
+ unsigned long link;
+ bfd_byte *extdyn, *extdynend;
+ size_t extdynsize;
+ void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
+
+ fprintf (f, _("\nDynamic Section:\n"));
+
+ dynbuf = (bfd_byte *) bfd_malloc (s->_raw_size);
+ if (dynbuf == NULL)
+ goto error_return;
+ if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf, (file_ptr) 0,
+ s->_raw_size))
+ goto error_return;
+
+ elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
+ if (elfsec == -1)
+ goto error_return;
+ link = elf_elfsections (abfd)[elfsec]->sh_link;
+
+ extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
+ swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
+
+ extdyn = dynbuf;
+ extdynend = extdyn + s->_raw_size;
+ for (; extdyn < extdynend; extdyn += extdynsize)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ char ab[20];
+ boolean stringp;
+
+ (*swap_dyn_in) (abfd, (PTR) extdyn, &dyn);
+
+ if (dyn.d_tag == DT_NULL)
+ break;
+
+ stringp = false;
+ switch (dyn.d_tag)
+ {
+ default:
+ sprintf (ab, "0x%lx", (unsigned long) dyn.d_tag);
+ name = ab;
+ break;
+
+ case DT_NEEDED: name = "NEEDED"; stringp = true; break;
+ case DT_PLTRELSZ: name = "PLTRELSZ"; break;
+ case DT_PLTGOT: name = "PLTGOT"; break;
+ case DT_HASH: name = "HASH"; break;
+ case DT_STRTAB: name = "STRTAB"; break;
+ case DT_SYMTAB: name = "SYMTAB"; break;
+ case DT_RELA: name = "RELA"; break;
+ case DT_RELASZ: name = "RELASZ"; break;
+ case DT_RELAENT: name = "RELAENT"; break;
+ case DT_STRSZ: name = "STRSZ"; break;
+ case DT_SYMENT: name = "SYMENT"; break;
+ case DT_INIT: name = "INIT"; break;
+ case DT_FINI: name = "FINI"; break;
+ case DT_SONAME: name = "SONAME"; stringp = true; break;
+ case DT_RPATH: name = "RPATH"; stringp = true; break;
+ case DT_SYMBOLIC: name = "SYMBOLIC"; break;
+ case DT_REL: name = "REL"; break;
+ case DT_RELSZ: name = "RELSZ"; break;
+ case DT_RELENT: name = "RELENT"; break;
+ case DT_PLTREL: name = "PLTREL"; break;
+ case DT_DEBUG: name = "DEBUG"; break;
+ case DT_TEXTREL: name = "TEXTREL"; break;
+ case DT_JMPREL: name = "JMPREL"; break;
+ case DT_AUXILIARY: name = "AUXILIARY"; stringp = true; break;
+ case DT_FILTER: name = "FILTER"; stringp = true; break;
+ case DT_VERSYM: name = "VERSYM"; break;
+ case DT_VERDEF: name = "VERDEF"; break;
+ case DT_VERDEFNUM: name = "VERDEFNUM"; break;
+ case DT_VERNEED: name = "VERNEED"; break;
+ case DT_VERNEEDNUM: name = "VERNEEDNUM"; break;
+ }
+
+ fprintf (f, " %-11s ", name);
+ if (! stringp)
+ fprintf (f, "0x%lx", (unsigned long) dyn.d_un.d_val);
+ else
+ {
+ const char *string;
+
+ string = bfd_elf_string_from_elf_section (abfd, link,
+ dyn.d_un.d_val);
+ if (string == NULL)
+ goto error_return;
+ fprintf (f, "%s", string);
+ }
+ fprintf (f, "\n");
+ }
+
+ free (dynbuf);
+ dynbuf = NULL;
+ }
+
+ if ((elf_dynverdef (abfd) != 0 && elf_tdata (abfd)->verdef == NULL)
+ || (elf_dynverref (abfd) != 0 && elf_tdata (abfd)->verref == NULL))
+ {
+ if (! _bfd_elf_slurp_version_tables (abfd))
+ return false;
+ }
+
+ if (elf_dynverdef (abfd) != 0)
+ {
+ Elf_Internal_Verdef *t;
+
+ fprintf (f, _("\nVersion definitions:\n"));
+ for (t = elf_tdata (abfd)->verdef; t != NULL; t = t->vd_nextdef)
+ {
+ fprintf (f, "%d 0x%2.2x 0x%8.8lx %s\n", t->vd_ndx,
+ t->vd_flags, t->vd_hash, t->vd_nodename);
+ if (t->vd_auxptr->vda_nextptr != NULL)
+ {
+ Elf_Internal_Verdaux *a;
+
+ fprintf (f, "\t");
+ for (a = t->vd_auxptr->vda_nextptr;
+ a != NULL;
+ a = a->vda_nextptr)
+ fprintf (f, "%s ", a->vda_nodename);
+ fprintf (f, "\n");
+ }
+ }
+ }
+
+ if (elf_dynverref (abfd) != 0)
+ {
+ Elf_Internal_Verneed *t;
+
+ fprintf (f, _("\nVersion References:\n"));
+ for (t = elf_tdata (abfd)->verref; t != NULL; t = t->vn_nextref)
+ {
+ Elf_Internal_Vernaux *a;
+
+ fprintf (f, _(" required from %s:\n"), t->vn_filename);
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ fprintf (f, " 0x%8.8lx 0x%2.2x %2.2d %s\n", a->vna_hash,
+ a->vna_flags, a->vna_other, a->vna_nodename);
+ }
+ }
+
+ return true;
+
+ error_return:
+ if (dynbuf != NULL)
+ free (dynbuf);
+ return false;
+}
+
+/* Display ELF-specific fields of a symbol. */
+
+void
+bfd_elf_print_symbol (abfd, filep, symbol, how)
+ bfd *abfd;
+ PTR filep;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) filep;
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+ fprintf (file, "elf ");
+ fprintf_vma (file, symbol->value);
+ fprintf (file, " %lx", (long) symbol->flags);
+ break;
+ case bfd_print_symbol_all:
+ {
+ CONST char *section_name;
+ section_name = symbol->section ? symbol->section->name : "(*none*)";
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+ fprintf (file, " %s\t", section_name);
+ /* Print the "other" value for a symbol. For common symbols,
+ we've already printed the size; now print the alignment.
+ For other symbols, we have no specified alignment, and
+ we've printed the address; now print the size. */
+ fprintf_vma (file,
+ (bfd_is_com_section (symbol->section)
+ ? ((elf_symbol_type *) symbol)->internal_elf_sym.st_value
+ : ((elf_symbol_type *) symbol)->internal_elf_sym.st_size));
+
+ /* If we have version information, print it. */
+ if (elf_tdata (abfd)->dynversym_section != 0
+ && (elf_tdata (abfd)->dynverdef_section != 0
+ || elf_tdata (abfd)->dynverref_section != 0))
+ {
+ unsigned int vernum;
+ const char *version_string;
+
+ vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION;
+
+ if (vernum == 0)
+ version_string = "";
+ else if (vernum == 1)
+ version_string = "Base";
+ else if (vernum <= elf_tdata (abfd)->cverdefs)
+ version_string =
+ elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
+ else
+ {
+ Elf_Internal_Verneed *t;
+
+ version_string = "";
+ for (t = elf_tdata (abfd)->verref;
+ t != NULL;
+ t = t->vn_nextref)
+ {
+ Elf_Internal_Vernaux *a;
+
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ {
+ if (a->vna_other == vernum)
+ {
+ version_string = a->vna_nodename;
+ break;
+ }
+ }
+ }
+ }
+
+ if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0)
+ fprintf (file, " %-11s", version_string);
+ else
+ {
+ int i;
+
+ fprintf (file, " (%s)", version_string);
+ for (i = 10 - strlen (version_string); i > 0; --i)
+ putc (' ', file);
+ }
+ }
+
+ /* If the st_other field is not zero, print it. */
+ if (((elf_symbol_type *) symbol)->internal_elf_sym.st_other != 0)
+ fprintf (file, " 0x%02x",
+ ((unsigned int)
+ ((elf_symbol_type *) symbol)->internal_elf_sym.st_other));
+
+ fprintf (file, " %s", symbol->name);
+ }
+ break;
+ }
+}
+
+/* Create an entry in an ELF linker hash table. */
+
+struct bfd_hash_entry *
+_bfd_elf_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct elf_link_hash_entry *ret = (struct elf_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct elf_link_hash_entry *) NULL)
+ ret = ((struct elf_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct elf_link_hash_entry)));
+ if (ret == (struct elf_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct elf_link_hash_entry *)
+ _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct elf_link_hash_entry *) NULL)
+ {
+ /* Set local fields. */
+ ret->indx = -1;
+ ret->size = 0;
+ ret->dynindx = -1;
+ ret->dynstr_index = 0;
+ ret->weakdef = NULL;
+ ret->got.offset = (bfd_vma) -1;
+ ret->plt.offset = (bfd_vma) -1;
+ ret->linker_section_pointer = (elf_linker_section_pointers_t *)0;
+ ret->verinfo.verdef = NULL;
+ ret->vtable_entries_used = NULL;
+ ret->vtable_entries_size = 0;
+ ret->vtable_parent = NULL;
+ ret->type = STT_NOTYPE;
+ ret->other = 0;
+ /* Assume that we have been called by a non-ELF symbol reader.
+ This flag is then reset by the code which reads an ELF input
+ file. This ensures that a symbol created by a non-ELF symbol
+ reader will have the flag set correctly. */
+ ret->elf_link_hash_flags = ELF_LINK_NON_ELF;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize an ELF linker hash table. */
+
+boolean
+_bfd_elf_link_hash_table_init (table, abfd, newfunc)
+ struct elf_link_hash_table *table;
+ bfd *abfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ table->dynamic_sections_created = false;
+ table->dynobj = NULL;
+ /* The first dynamic symbol is a dummy. */
+ table->dynsymcount = 1;
+ table->dynstr = NULL;
+ table->bucketcount = 0;
+ table->needed = NULL;
+ table->hgot = NULL;
+ table->stab_info = NULL;
+ return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+}
+
+/* Create an ELF linker hash table. */
+
+struct bfd_link_hash_table *
+_bfd_elf_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf_link_hash_table *ret;
+
+ ret = ((struct elf_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
+ if (ret == (struct elf_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ return &ret->root;
+}
+
+/* This is a hook for the ELF emulation code in the generic linker to
+ tell the backend linker what file name to use for the DT_NEEDED
+ entry for a dynamic object. The generic linker passes name as an
+ empty string to indicate that no DT_NEEDED entry should be made. */
+
+void
+bfd_elf_set_dt_needed_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+ && bfd_get_format (abfd) == bfd_object)
+ elf_dt_name (abfd) = name;
+}
+
+/* Get the list of DT_NEEDED entries for a link. This is a hook for
+ the linker ELF emulation code. */
+
+struct bfd_link_needed_list *
+bfd_elf_get_needed_list (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (info->hash->creator->flavour != bfd_target_elf_flavour)
+ return NULL;
+ return elf_hash_table (info)->needed;
+}
+
+/* Get the name actually used for a dynamic object for a link. This
+ is the SONAME entry if there is one. Otherwise, it is the string
+ passed to bfd_elf_set_dt_needed_name, or it is the filename. */
+
+const char *
+bfd_elf_get_dt_soname (abfd)
+ bfd *abfd;
+{
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+ && bfd_get_format (abfd) == bfd_object)
+ return elf_dt_name (abfd);
+ return NULL;
+}
+
+/* Get the list of DT_NEEDED entries from a BFD. This is a hook for
+ the ELF linker emulation code. */
+
+boolean
+bfd_elf_get_bfd_needed_list (abfd, pneeded)
+ bfd *abfd;
+ struct bfd_link_needed_list **pneeded;
+{
+ asection *s;
+ bfd_byte *dynbuf = NULL;
+ int elfsec;
+ unsigned long link;
+ bfd_byte *extdyn, *extdynend;
+ size_t extdynsize;
+ void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
+
+ *pneeded = NULL;
+
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour
+ || bfd_get_format (abfd) != bfd_object)
+ return true;
+
+ s = bfd_get_section_by_name (abfd, ".dynamic");
+ if (s == NULL || s->_raw_size == 0)
+ return true;
+
+ dynbuf = (bfd_byte *) bfd_malloc (s->_raw_size);
+ if (dynbuf == NULL)
+ goto error_return;
+
+ if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf, (file_ptr) 0,
+ s->_raw_size))
+ goto error_return;
+
+ elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
+ if (elfsec == -1)
+ goto error_return;
+
+ link = elf_elfsections (abfd)[elfsec]->sh_link;
+
+ extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
+ swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
+
+ extdyn = dynbuf;
+ extdynend = extdyn + s->_raw_size;
+ for (; extdyn < extdynend; extdyn += extdynsize)
+ {
+ Elf_Internal_Dyn dyn;
+
+ (*swap_dyn_in) (abfd, (PTR) extdyn, &dyn);
+
+ if (dyn.d_tag == DT_NULL)
+ break;
+
+ if (dyn.d_tag == DT_NEEDED)
+ {
+ const char *string;
+ struct bfd_link_needed_list *l;
+
+ string = bfd_elf_string_from_elf_section (abfd, link,
+ dyn.d_un.d_val);
+ if (string == NULL)
+ goto error_return;
+
+ l = (struct bfd_link_needed_list *) bfd_alloc (abfd, sizeof *l);
+ if (l == NULL)
+ goto error_return;
+
+ l->by = abfd;
+ l->name = string;
+ l->next = *pneeded;
+ *pneeded = l;
+ }
+ }
+
+ free (dynbuf);
+
+ return true;
+
+ error_return:
+ if (dynbuf != NULL)
+ free (dynbuf);
+ return false;
+}
+
+/* Allocate an ELF string table--force the first byte to be zero. */
+
+struct bfd_strtab_hash *
+_bfd_elf_stringtab_init ()
+{
+ struct bfd_strtab_hash *ret;
+
+ ret = _bfd_stringtab_init ();
+ if (ret != NULL)
+ {
+ bfd_size_type loc;
+
+ loc = _bfd_stringtab_add (ret, "", true, false);
+ BFD_ASSERT (loc == 0 || loc == (bfd_size_type) -1);
+ if (loc == (bfd_size_type) -1)
+ {
+ _bfd_stringtab_free (ret);
+ ret = NULL;
+ }
+ }
+ return ret;
+}
+
+/* ELF .o/exec file reading */
+
+/* Create a new bfd section from an ELF section header. */
+
+boolean
+bfd_section_from_shdr (abfd, shindex)
+ bfd *abfd;
+ unsigned int shindex;
+{
+ Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[shindex];
+ Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ char *name;
+
+ name = elf_string_from_elf_strtab (abfd, hdr->sh_name);
+
+ switch (hdr->sh_type)
+ {
+ case SHT_NULL:
+ /* Inactive section. Throw it away. */
+ return true;
+
+ case SHT_PROGBITS: /* Normal section with contents. */
+ case SHT_DYNAMIC: /* Dynamic linking information. */
+ case SHT_NOBITS: /* .bss section. */
+ case SHT_HASH: /* .hash section. */
+ case SHT_NOTE: /* .note section. */
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+
+ case SHT_SYMTAB: /* A symbol table */
+ if (elf_onesymtab (abfd) == shindex)
+ return true;
+
+ BFD_ASSERT (hdr->sh_entsize == bed->s->sizeof_sym);
+ BFD_ASSERT (elf_onesymtab (abfd) == 0);
+ elf_onesymtab (abfd) = shindex;
+ elf_tdata (abfd)->symtab_hdr = *hdr;
+ elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->symtab_hdr;
+ abfd->flags |= HAS_SYMS;
+
+ /* Sometimes a shared object will map in the symbol table. If
+ SHF_ALLOC is set, and this is a shared object, then we also
+ treat this section as a BFD section. We can not base the
+ decision purely on SHF_ALLOC, because that flag is sometimes
+ set in a relocateable object file, which would confuse the
+ linker. */
+ if ((hdr->sh_flags & SHF_ALLOC) != 0
+ && (abfd->flags & DYNAMIC) != 0
+ && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+ return false;
+
+ return true;
+
+ case SHT_DYNSYM: /* A dynamic symbol table */
+ if (elf_dynsymtab (abfd) == shindex)
+ return true;
+
+ BFD_ASSERT (hdr->sh_entsize == bed->s->sizeof_sym);
+ BFD_ASSERT (elf_dynsymtab (abfd) == 0);
+ elf_dynsymtab (abfd) = shindex;
+ elf_tdata (abfd)->dynsymtab_hdr = *hdr;
+ elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->dynsymtab_hdr;
+ abfd->flags |= HAS_SYMS;
+
+ /* Besides being a symbol table, we also treat this as a regular
+ section, so that objcopy can handle it. */
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+
+ case SHT_STRTAB: /* A string table */
+ if (hdr->bfd_section != NULL)
+ return true;
+ if (ehdr->e_shstrndx == shindex)
+ {
+ elf_tdata (abfd)->shstrtab_hdr = *hdr;
+ elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
+ return true;
+ }
+ {
+ unsigned int i;
+
+ for (i = 1; i < ehdr->e_shnum; i++)
+ {
+ Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
+ if (hdr2->sh_link == shindex)
+ {
+ if (! bfd_section_from_shdr (abfd, i))
+ return false;
+ if (elf_onesymtab (abfd) == i)
+ {
+ elf_tdata (abfd)->strtab_hdr = *hdr;
+ elf_elfsections (abfd)[shindex] =
+ &elf_tdata (abfd)->strtab_hdr;
+ return true;
+ }
+ if (elf_dynsymtab (abfd) == i)
+ {
+ elf_tdata (abfd)->dynstrtab_hdr = *hdr;
+ elf_elfsections (abfd)[shindex] = hdr =
+ &elf_tdata (abfd)->dynstrtab_hdr;
+ /* We also treat this as a regular section, so
+ that objcopy can handle it. */
+ break;
+ }
+#if 0 /* Not handling other string tables specially right now. */
+ hdr2 = elf_elfsections (abfd)[i]; /* in case it moved */
+ /* We have a strtab for some random other section. */
+ newsect = (asection *) hdr2->bfd_section;
+ if (!newsect)
+ break;
+ hdr->bfd_section = newsect;
+ hdr2 = &elf_section_data (newsect)->str_hdr;
+ *hdr2 = *hdr;
+ elf_elfsections (abfd)[shindex] = hdr2;
+#endif
+ }
+ }
+ }
+
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+
+ case SHT_REL:
+ case SHT_RELA:
+ /* *These* do a lot of work -- but build no sections! */
+ {
+ asection *target_sect;
+ Elf_Internal_Shdr *hdr2;
+
+ /* For some incomprehensible reason Oracle distributes
+ libraries for Solaris in which some of the objects have
+ bogus sh_link fields. It would be nice if we could just
+ reject them, but, unfortunately, some people need to use
+ them. We scan through the section headers; if we find only
+ one suitable symbol table, we clobber the sh_link to point
+ to it. I hope this doesn't break anything. */
+ if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
+ && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
+ {
+ int scan;
+ int found;
+
+ found = 0;
+ for (scan = 1; scan < ehdr->e_shnum; scan++)
+ {
+ if (elf_elfsections (abfd)[scan]->sh_type == SHT_SYMTAB
+ || elf_elfsections (abfd)[scan]->sh_type == SHT_DYNSYM)
+ {
+ if (found != 0)
+ {
+ found = 0;
+ break;
+ }
+ found = scan;
+ }
+ }
+ if (found != 0)
+ hdr->sh_link = found;
+ }
+
+ /* Get the symbol table. */
+ if (elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
+ && ! bfd_section_from_shdr (abfd, hdr->sh_link))
+ return false;
+
+ /* If this reloc section does not use the main symbol table we
+ don't treat it as a reloc section. BFD can't adequately
+ represent such a section, so at least for now, we don't
+ try. We just present it as a normal section. */
+ if (hdr->sh_link != elf_onesymtab (abfd))
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+
+ if (! bfd_section_from_shdr (abfd, hdr->sh_info))
+ return false;
+ target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
+ if (target_sect == NULL)
+ return false;
+
+ if ((target_sect->flags & SEC_RELOC) == 0
+ || target_sect->reloc_count == 0)
+ hdr2 = &elf_section_data (target_sect)->rel_hdr;
+ else
+ {
+ BFD_ASSERT (elf_section_data (target_sect)->rel_hdr2 == NULL);
+ hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, sizeof (*hdr2));
+ elf_section_data (target_sect)->rel_hdr2 = hdr2;
+ }
+ *hdr2 = *hdr;
+ elf_elfsections (abfd)[shindex] = hdr2;
+ target_sect->reloc_count += hdr->sh_size / hdr->sh_entsize;
+ target_sect->flags |= SEC_RELOC;
+ target_sect->relocation = NULL;
+ target_sect->rel_filepos = hdr->sh_offset;
+ abfd->flags |= HAS_RELOC;
+ return true;
+ }
+ break;
+
+ case SHT_GNU_verdef:
+ elf_dynverdef (abfd) = shindex;
+ elf_tdata (abfd)->dynverdef_hdr = *hdr;
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+ break;
+
+ case SHT_GNU_versym:
+ elf_dynversym (abfd) = shindex;
+ elf_tdata (abfd)->dynversym_hdr = *hdr;
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+ break;
+
+ case SHT_GNU_verneed:
+ elf_dynverref (abfd) = shindex;
+ elf_tdata (abfd)->dynverref_hdr = *hdr;
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+ break;
+
+ case SHT_SHLIB:
+ return true;
+
+ default:
+ /* Check for any processor-specific section types. */
+ {
+ if (bed->elf_backend_section_from_shdr)
+ (*bed->elf_backend_section_from_shdr) (abfd, hdr, name);
+ }
+ break;
+ }
+
+ return true;
+}
+
+/* Given an ELF section number, retrieve the corresponding BFD
+ section. */
+
+asection *
+bfd_section_from_elf_index (abfd, index)
+ bfd *abfd;
+ unsigned int index;
+{
+ BFD_ASSERT (index > 0 && index < SHN_LORESERVE);
+ if (index >= elf_elfheader (abfd)->e_shnum)
+ return NULL;
+ return elf_elfsections (abfd)[index]->bfd_section;
+}
+
+boolean
+_bfd_elf_new_section_hook (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ struct bfd_elf_section_data *sdata;
+
+ sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
+ if (!sdata)
+ return false;
+ sec->used_by_bfd = (PTR) sdata;
+ memset (sdata, 0, sizeof (*sdata));
+ return true;
+}
+
+/* Create a new bfd section from an ELF program header.
+
+ Since program segments have no names, we generate a synthetic name
+ of the form segment<NUM>, where NUM is generally the index in the
+ program header table. For segments that are split (see below) we
+ generate the names segment<NUM>a and segment<NUM>b.
+
+ Note that some program segments may have a file size that is different than
+ (less than) the memory size. All this means is that at execution the
+ system must allocate the amount of memory specified by the memory size,
+ but only initialize it with the first "file size" bytes read from the
+ file. This would occur for example, with program segments consisting
+ of combined data+bss.
+
+ To handle the above situation, this routine generates TWO bfd sections
+ for the single program segment. The first has the length specified by
+ the file size of the segment, and the second has the length specified
+ by the difference between the two sizes. In effect, the segment is split
+ into it's initialized and uninitialized parts.
+
+ */
+
+boolean
+bfd_section_from_phdr (abfd, hdr, index)
+ bfd *abfd;
+ Elf_Internal_Phdr *hdr;
+ int index;
+{
+ asection *newsect;
+ char *name;
+ char namebuf[64];
+ int split;
+
+ split = ((hdr->p_memsz > 0)
+ && (hdr->p_filesz > 0)
+ && (hdr->p_memsz > hdr->p_filesz));
+ sprintf (namebuf, split ? "segment%da" : "segment%d", index);
+ name = bfd_alloc (abfd, strlen (namebuf) + 1);
+ if (!name)
+ return false;
+ strcpy (name, namebuf);
+ newsect = bfd_make_section (abfd, name);
+ if (newsect == NULL)
+ return false;
+ newsect->vma = hdr->p_vaddr;
+ newsect->lma = hdr->p_paddr;
+ newsect->_raw_size = hdr->p_filesz;
+ newsect->filepos = hdr->p_offset;
+ newsect->flags |= SEC_HAS_CONTENTS;
+ if (hdr->p_type == PT_LOAD)
+ {
+ newsect->flags |= SEC_ALLOC;
+ newsect->flags |= SEC_LOAD;
+ if (hdr->p_flags & PF_X)
+ {
+ /* FIXME: all we known is that it has execute PERMISSION,
+ may be data. */
+ newsect->flags |= SEC_CODE;
+ }
+ }
+ if (!(hdr->p_flags & PF_W))
+ {
+ newsect->flags |= SEC_READONLY;
+ }
+
+ if (split)
+ {
+ sprintf (namebuf, "segment%db", index);
+ name = bfd_alloc (abfd, strlen (namebuf) + 1);
+ if (!name)
+ return false;
+ strcpy (name, namebuf);
+ newsect = bfd_make_section (abfd, name);
+ if (newsect == NULL)
+ return false;
+ newsect->vma = hdr->p_vaddr + hdr->p_filesz;
+ newsect->lma = hdr->p_paddr + hdr->p_filesz;
+ newsect->_raw_size = hdr->p_memsz - hdr->p_filesz;
+ if (hdr->p_type == PT_LOAD)
+ {
+ newsect->flags |= SEC_ALLOC;
+ if (hdr->p_flags & PF_X)
+ newsect->flags |= SEC_CODE;
+ }
+ if (!(hdr->p_flags & PF_W))
+ newsect->flags |= SEC_READONLY;
+ }
+
+ return true;
+}
+
+/* Set up an ELF internal section header for a section. */
+
+/*ARGSUSED*/
+static void
+elf_fake_sections (abfd, asect, failedptrarg)
+ bfd *abfd;
+ asection *asect;
+ PTR failedptrarg;
+{
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ boolean *failedptr = (boolean *) failedptrarg;
+ Elf_Internal_Shdr *this_hdr;
+
+ if (*failedptr)
+ {
+ /* We already failed; just get out of the bfd_map_over_sections
+ loop. */
+ return;
+ }
+
+ this_hdr = &elf_section_data (asect)->this_hdr;
+
+ this_hdr->sh_name = (unsigned long) _bfd_stringtab_add (elf_shstrtab (abfd),
+ asect->name,
+ true, false);
+ if (this_hdr->sh_name == (unsigned long) -1)
+ {
+ *failedptr = true;
+ return;
+ }
+
+ this_hdr->sh_flags = 0;
+
+ if ((asect->flags & SEC_ALLOC) != 0
+ || asect->user_set_vma)
+ this_hdr->sh_addr = asect->vma;
+ else
+ this_hdr->sh_addr = 0;
+
+ this_hdr->sh_offset = 0;
+ this_hdr->sh_size = asect->_raw_size;
+ this_hdr->sh_link = 0;
+ this_hdr->sh_addralign = 1 << asect->alignment_power;
+ /* The sh_entsize and sh_info fields may have been set already by
+ copy_private_section_data. */
+
+ this_hdr->bfd_section = asect;
+ this_hdr->contents = NULL;
+
+ /* FIXME: This should not be based on section names. */
+ if (strcmp (asect->name, ".dynstr") == 0)
+ this_hdr->sh_type = SHT_STRTAB;
+ else if (strcmp (asect->name, ".hash") == 0)
+ {
+ this_hdr->sh_type = SHT_HASH;
+ this_hdr->sh_entsize = bed->s->arch_size / 8;
+ }
+ else if (strcmp (asect->name, ".dynsym") == 0)
+ {
+ this_hdr->sh_type = SHT_DYNSYM;
+ this_hdr->sh_entsize = bed->s->sizeof_sym;
+ }
+ else if (strcmp (asect->name, ".dynamic") == 0)
+ {
+ this_hdr->sh_type = SHT_DYNAMIC;
+ this_hdr->sh_entsize = bed->s->sizeof_dyn;
+ }
+ else if (strncmp (asect->name, ".rela", 5) == 0
+ && get_elf_backend_data (abfd)->use_rela_p)
+ {
+ this_hdr->sh_type = SHT_RELA;
+ this_hdr->sh_entsize = bed->s->sizeof_rela;
+ }
+ else if (strncmp (asect->name, ".rel", 4) == 0
+ && ! get_elf_backend_data (abfd)->use_rela_p)
+ {
+ this_hdr->sh_type = SHT_REL;
+ this_hdr->sh_entsize = bed->s->sizeof_rel;
+ }
+ else if (strncmp (asect->name, ".note", 5) == 0)
+ this_hdr->sh_type = SHT_NOTE;
+ else if (strncmp (asect->name, ".stab", 5) == 0
+ && strcmp (asect->name + strlen (asect->name) - 3, "str") == 0)
+ this_hdr->sh_type = SHT_STRTAB;
+ else if (strcmp (asect->name, ".gnu.version") == 0)
+ {
+ this_hdr->sh_type = SHT_GNU_versym;
+ this_hdr->sh_entsize = sizeof (Elf_External_Versym);
+ }
+ else if (strcmp (asect->name, ".gnu.version_d") == 0)
+ {
+ this_hdr->sh_type = SHT_GNU_verdef;
+ this_hdr->sh_entsize = 0;
+ /* objcopy or strip will copy over sh_info, but may not set
+ cverdefs. The linker will set cverdefs, but sh_info will be
+ zero. */
+ if (this_hdr->sh_info == 0)
+ this_hdr->sh_info = elf_tdata (abfd)->cverdefs;
+ else
+ BFD_ASSERT (elf_tdata (abfd)->cverdefs == 0
+ || this_hdr->sh_info == elf_tdata (abfd)->cverdefs);
+ }
+ else if (strcmp (asect->name, ".gnu.version_r") == 0)
+ {
+ this_hdr->sh_type = SHT_GNU_verneed;
+ this_hdr->sh_entsize = 0;
+ /* objcopy or strip will copy over sh_info, but may not set
+ cverrefs. The linker will set cverrefs, but sh_info will be
+ zero. */
+ if (this_hdr->sh_info == 0)
+ this_hdr->sh_info = elf_tdata (abfd)->cverrefs;
+ else
+ BFD_ASSERT (elf_tdata (abfd)->cverrefs == 0
+ || this_hdr->sh_info == elf_tdata (abfd)->cverrefs);
+ }
+ else if ((asect->flags & SEC_ALLOC) != 0
+ && (asect->flags & SEC_LOAD) != 0)
+ this_hdr->sh_type = SHT_PROGBITS;
+ else if ((asect->flags & SEC_ALLOC) != 0
+ && ((asect->flags & SEC_LOAD) == 0))
+ this_hdr->sh_type = SHT_NOBITS;
+ else
+ {
+ /* Who knows? */
+ this_hdr->sh_type = SHT_PROGBITS;
+ }
+
+ if ((asect->flags & SEC_ALLOC) != 0)
+ this_hdr->sh_flags |= SHF_ALLOC;
+ if ((asect->flags & SEC_READONLY) == 0)
+ this_hdr->sh_flags |= SHF_WRITE;
+ if ((asect->flags & SEC_CODE) != 0)
+ this_hdr->sh_flags |= SHF_EXECINSTR;
+
+ /* Check for processor-specific section types. */
+ {
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+ if (bed->elf_backend_fake_sections)
+ (*bed->elf_backend_fake_sections) (abfd, this_hdr, asect);
+ }
+
+ /* If the section has relocs, set up a section header for the
+ SHT_REL[A] section. */
+ if ((asect->flags & SEC_RELOC) != 0)
+ {
+ Elf_Internal_Shdr *rela_hdr;
+ int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
+ char *name;
+
+ rela_hdr = &elf_section_data (asect)->rel_hdr;
+ name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name));
+ if (name == NULL)
+ {
+ *failedptr = true;
+ return;
+ }
+ sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
+ rela_hdr->sh_name =
+ (unsigned int) _bfd_stringtab_add (elf_shstrtab (abfd), name,
+ true, false);
+ if (rela_hdr->sh_name == (unsigned int) -1)
+ {
+ *failedptr = true;
+ return;
+ }
+ rela_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
+ rela_hdr->sh_entsize = (use_rela_p
+ ? bed->s->sizeof_rela
+ : bed->s->sizeof_rel);
+ rela_hdr->sh_addralign = bed->s->file_align;
+ rela_hdr->sh_flags = 0;
+ rela_hdr->sh_addr = 0;
+ rela_hdr->sh_size = 0;
+ rela_hdr->sh_offset = 0;
+ }
+}
+
+/* Assign all ELF section numbers. The dummy first section is handled here
+ too. The link/info pointers for the standard section types are filled
+ in here too, while we're at it. */
+
+static boolean
+assign_section_numbers (abfd)
+ bfd *abfd;
+{
+ struct elf_obj_tdata *t = elf_tdata (abfd);
+ asection *sec;
+ unsigned int section_number;
+ Elf_Internal_Shdr **i_shdrp;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+ section_number = 1;
+
+ for (sec = abfd->sections; sec; sec = sec->next)
+ {
+ struct bfd_elf_section_data *d = elf_section_data (sec);
+
+ d->this_idx = section_number++;
+ if ((sec->flags & SEC_RELOC) == 0)
+ d->rel_idx = 0;
+ else
+ d->rel_idx = section_number++;
+ }
+
+ t->shstrtab_section = section_number++;
+ elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
+ t->shstrtab_hdr.sh_size = _bfd_stringtab_size (elf_shstrtab (abfd));
+
+ if (bfd_get_symcount (abfd) > 0)
+ {
+ t->symtab_section = section_number++;
+ t->strtab_section = section_number++;
+ }
+
+ elf_elfheader (abfd)->e_shnum = section_number;
+
+ /* Set up the list of section header pointers, in agreement with the
+ indices. */
+ i_shdrp = ((Elf_Internal_Shdr **)
+ bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *)));
+ if (i_shdrp == NULL)
+ return false;
+
+ i_shdrp[0] = ((Elf_Internal_Shdr *)
+ bfd_alloc (abfd, sizeof (Elf_Internal_Shdr)));
+ if (i_shdrp[0] == NULL)
+ {
+ bfd_release (abfd, i_shdrp);
+ return false;
+ }
+ memset (i_shdrp[0], 0, sizeof (Elf_Internal_Shdr));
+
+ elf_elfsections (abfd) = i_shdrp;
+
+ i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
+ if (bfd_get_symcount (abfd) > 0)
+ {
+ i_shdrp[t->symtab_section] = &t->symtab_hdr;
+ i_shdrp[t->strtab_section] = &t->strtab_hdr;
+ t->symtab_hdr.sh_link = t->strtab_section;
+ }
+ for (sec = abfd->sections; sec; sec = sec->next)
+ {
+ struct bfd_elf_section_data *d = elf_section_data (sec);
+ asection *s;
+ const char *name;
+
+ i_shdrp[d->this_idx] = &d->this_hdr;
+ if (d->rel_idx != 0)
+ i_shdrp[d->rel_idx] = &d->rel_hdr;
+
+ /* Fill in the sh_link and sh_info fields while we're at it. */
+
+ /* sh_link of a reloc section is the section index of the symbol
+ table. sh_info is the section index of the section to which
+ the relocation entries apply. */
+ if (d->rel_idx != 0)
+ {
+ d->rel_hdr.sh_link = t->symtab_section;
+ d->rel_hdr.sh_info = d->this_idx;
+ }
+
+ switch (d->this_hdr.sh_type)
+ {
+ case SHT_REL:
+ case SHT_RELA:
+ /* A reloc section which we are treating as a normal BFD
+ section. sh_link is the section index of the symbol
+ table. sh_info is the section index of the section to
+ which the relocation entries apply. We assume that an
+ allocated reloc section uses the dynamic symbol table.
+ FIXME: How can we be sure? */
+ s = bfd_get_section_by_name (abfd, ".dynsym");
+ if (s != NULL)
+ d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+
+ /* We look up the section the relocs apply to by name. */
+ name = sec->name;
+ if (d->this_hdr.sh_type == SHT_REL)
+ name += 4;
+ else
+ name += 5;
+ s = bfd_get_section_by_name (abfd, name);
+ if (s != NULL)
+ d->this_hdr.sh_info = elf_section_data (s)->this_idx;
+ break;
+
+ case SHT_STRTAB:
+ /* We assume that a section named .stab*str is a stabs
+ string section. We look for a section with the same name
+ but without the trailing ``str'', and set its sh_link
+ field to point to this section. */
+ if (strncmp (sec->name, ".stab", sizeof ".stab" - 1) == 0
+ && strcmp (sec->name + strlen (sec->name) - 3, "str") == 0)
+ {
+ size_t len;
+ char *alc;
+
+ len = strlen (sec->name);
+ alc = (char *) bfd_malloc (len - 2);
+ if (alc == NULL)
+ return false;
+ strncpy (alc, sec->name, len - 3);
+ alc[len - 3] = '\0';
+ s = bfd_get_section_by_name (abfd, alc);
+ free (alc);
+ if (s != NULL)
+ {
+ elf_section_data (s)->this_hdr.sh_link = d->this_idx;
+
+ /* This is a .stab section. */
+ elf_section_data (s)->this_hdr.sh_entsize =
+ 4 + 2 * (bed->s->arch_size / 8);
+ }
+ }
+ break;
+
+ case SHT_DYNAMIC:
+ case SHT_DYNSYM:
+ case SHT_GNU_verneed:
+ case SHT_GNU_verdef:
+ /* sh_link is the section header index of the string table
+ used for the dynamic entries, or the symbol table, or the
+ version strings. */
+ s = bfd_get_section_by_name (abfd, ".dynstr");
+ if (s != NULL)
+ d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+ break;
+
+ case SHT_HASH:
+ case SHT_GNU_versym:
+ /* sh_link is the section header index of the symbol table
+ this hash table or version table is for. */
+ s = bfd_get_section_by_name (abfd, ".dynsym");
+ if (s != NULL)
+ d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Map symbol from it's internal number to the external number, moving
+ all local symbols to be at the head of the list. */
+
+static INLINE int
+sym_is_global (abfd, sym)
+ bfd *abfd;
+ asymbol *sym;
+{
+ /* If the backend has a special mapping, use it. */
+ if (get_elf_backend_data (abfd)->elf_backend_sym_is_global)
+ return ((*get_elf_backend_data (abfd)->elf_backend_sym_is_global)
+ (abfd, sym));
+
+ return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
+ || bfd_is_und_section (bfd_get_section (sym))
+ || bfd_is_com_section (bfd_get_section (sym)));
+}
+
+static boolean
+elf_map_symbols (abfd)
+ bfd *abfd;
+{
+ int symcount = bfd_get_symcount (abfd);
+ asymbol **syms = bfd_get_outsymbols (abfd);
+ asymbol **sect_syms;
+ int num_locals = 0;
+ int num_globals = 0;
+ int num_locals2 = 0;
+ int num_globals2 = 0;
+ int max_index = 0;
+ int num_sections = 0;
+ int idx;
+ asection *asect;
+ asymbol **new_syms;
+ asymbol *sym;
+
+#ifdef DEBUG
+ fprintf (stderr, "elf_map_symbols\n");
+ fflush (stderr);
+#endif
+
+ /* Add a section symbol for each BFD section. FIXME: Is this really
+ necessary? */
+ for (asect = abfd->sections; asect; asect = asect->next)
+ {
+ if (max_index < asect->index)
+ max_index = asect->index;
+ }
+
+ max_index++;
+ sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
+ if (sect_syms == NULL)
+ return false;
+ elf_section_syms (abfd) = sect_syms;
+
+ for (idx = 0; idx < symcount; idx++)
+ {
+ sym = syms[idx];
+
+ if ((sym->flags & BSF_SECTION_SYM) != 0
+ && sym->value == 0)
+ {
+ asection *sec;
+
+ sec = sym->section;
+
+ if (sec->owner != NULL)
+ {
+ if (sec->owner != abfd)
+ {
+ if (sec->output_offset != 0)
+ continue;
+
+ sec = sec->output_section;
+
+ /* Empty sections in the input files may have had a section
+ symbol created for them. (See the comment near the end of
+ _bfd_generic_link_output_symbols in linker.c). If the linker
+ script discards such sections then we will reach this point.
+ Since we know that we cannot avoid this case, we detect it
+ and skip the abort and the assignment to the sect_syms array.
+ To reproduce this particular case try running the linker
+ testsuite test ld-scripts/weak.exp for an ELF port that uses
+ the generic linker. */
+ if (sec->owner == NULL)
+ continue;
+
+ BFD_ASSERT (sec->owner == abfd);
+ }
+ sect_syms[sec->index] = syms[idx];
+ }
+ }
+ }
+
+ for (asect = abfd->sections; asect; asect = asect->next)
+ {
+ if (sect_syms[asect->index] != NULL)
+ continue;
+
+ sym = bfd_make_empty_symbol (abfd);
+ if (sym == NULL)
+ return false;
+ sym->the_bfd = abfd;
+ sym->name = asect->name;
+ sym->value = 0;
+ /* Set the flags to 0 to indicate that this one was newly added. */
+ sym->flags = 0;
+ sym->section = asect;
+ sect_syms[asect->index] = sym;
+ num_sections++;
+#ifdef DEBUG
+ fprintf (stderr,
+ _("creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = 0x%.8lx\n"),
+ asect->name, (long) asect->vma, asect->index, (long) asect);
+#endif
+ }
+
+ /* Classify all of the symbols. */
+ for (idx = 0; idx < symcount; idx++)
+ {
+ if (!sym_is_global (abfd, syms[idx]))
+ num_locals++;
+ else
+ num_globals++;
+ }
+ for (asect = abfd->sections; asect; asect = asect->next)
+ {
+ if (sect_syms[asect->index] != NULL
+ && sect_syms[asect->index]->flags == 0)
+ {
+ sect_syms[asect->index]->flags = BSF_SECTION_SYM;
+ if (!sym_is_global (abfd, sect_syms[asect->index]))
+ num_locals++;
+ else
+ num_globals++;
+ sect_syms[asect->index]->flags = 0;
+ }
+ }
+
+ /* Now sort the symbols so the local symbols are first. */
+ new_syms = ((asymbol **)
+ bfd_alloc (abfd,
+ (num_locals + num_globals) * sizeof (asymbol *)));
+ if (new_syms == NULL)
+ return false;
+
+ for (idx = 0; idx < symcount; idx++)
+ {
+ asymbol *sym = syms[idx];
+ int i;
+
+ if (!sym_is_global (abfd, sym))
+ i = num_locals2++;
+ else
+ i = num_locals + num_globals2++;
+ new_syms[i] = sym;
+ sym->udata.i = i + 1;
+ }
+ for (asect = abfd->sections; asect; asect = asect->next)
+ {
+ if (sect_syms[asect->index] != NULL
+ && sect_syms[asect->index]->flags == 0)
+ {
+ asymbol *sym = sect_syms[asect->index];
+ int i;
+
+ sym->flags = BSF_SECTION_SYM;
+ if (!sym_is_global (abfd, sym))
+ i = num_locals2++;
+ else
+ i = num_locals + num_globals2++;
+ new_syms[i] = sym;
+ sym->udata.i = i + 1;
+ }
+ }
+
+ bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
+
+ elf_num_locals (abfd) = num_locals;
+ elf_num_globals (abfd) = num_globals;
+ return true;
+}
+
+/* Align to the maximum file alignment that could be required for any
+ ELF data structure. */
+
+static INLINE file_ptr align_file_position PARAMS ((file_ptr, int));
+static INLINE file_ptr
+align_file_position (off, align)
+ file_ptr off;
+ int align;
+{
+ return (off + align - 1) & ~(align - 1);
+}
+
+/* Assign a file position to a section, optionally aligning to the
+ required section alignment. */
+
+INLINE file_ptr
+_bfd_elf_assign_file_position_for_section (i_shdrp, offset, align)
+ Elf_Internal_Shdr *i_shdrp;
+ file_ptr offset;
+ boolean align;
+{
+ if (align)
+ {
+ unsigned int al;
+
+ al = i_shdrp->sh_addralign;
+ if (al > 1)
+ offset = BFD_ALIGN (offset, al);
+ }
+ i_shdrp->sh_offset = offset;
+ if (i_shdrp->bfd_section != NULL)
+ i_shdrp->bfd_section->filepos = offset;
+ if (i_shdrp->sh_type != SHT_NOBITS)
+ offset += i_shdrp->sh_size;
+ return offset;
+}
+
+/* Compute the file positions we are going to put the sections at, and
+ otherwise prepare to begin writing out the ELF file. If LINK_INFO
+ is not NULL, this is being called by the ELF backend linker. */
+
+boolean
+_bfd_elf_compute_section_file_positions (abfd, link_info)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+{
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ boolean failed;
+ struct bfd_strtab_hash *strtab;
+ Elf_Internal_Shdr *shstrtab_hdr;
+
+ if (abfd->output_has_begun)
+ return true;
+
+ /* Do any elf backend specific processing first. */
+ if (bed->elf_backend_begin_write_processing)
+ (*bed->elf_backend_begin_write_processing) (abfd, link_info);
+
+ if (! prep_headers (abfd))
+ return false;
+
+ failed = false;
+ bfd_map_over_sections (abfd, elf_fake_sections, &failed);
+ if (failed)
+ return false;
+
+ if (!assign_section_numbers (abfd))
+ return false;
+
+ /* The backend linker builds symbol table information itself. */
+ if (link_info == NULL && bfd_get_symcount (abfd) > 0)
+ {
+ /* Non-zero if doing a relocatable link. */
+ int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));
+
+ if (! swap_out_syms (abfd, &strtab, relocatable_p))
+ return false;
+ }
+
+ shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
+ /* sh_name was set in prep_headers. */
+ shstrtab_hdr->sh_type = SHT_STRTAB;
+ shstrtab_hdr->sh_flags = 0;
+ shstrtab_hdr->sh_addr = 0;
+ shstrtab_hdr->sh_size = _bfd_stringtab_size (elf_shstrtab (abfd));
+ shstrtab_hdr->sh_entsize = 0;
+ shstrtab_hdr->sh_link = 0;
+ shstrtab_hdr->sh_info = 0;
+ /* sh_offset is set in assign_file_positions_except_relocs. */
+ shstrtab_hdr->sh_addralign = 1;
+
+ if (!assign_file_positions_except_relocs (abfd))
+ return false;
+
+ if (link_info == NULL && bfd_get_symcount (abfd) > 0)
+ {
+ file_ptr off;
+ Elf_Internal_Shdr *hdr;
+
+ off = elf_tdata (abfd)->next_file_pos;
+
+ hdr = &elf_tdata (abfd)->symtab_hdr;
+ off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
+
+ hdr = &elf_tdata (abfd)->strtab_hdr;
+ off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
+
+ elf_tdata (abfd)->next_file_pos = off;
+
+ /* Now that we know where the .strtab section goes, write it
+ out. */
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
+ || ! _bfd_stringtab_emit (abfd, strtab))
+ return false;
+ _bfd_stringtab_free (strtab);
+ }
+
+ abfd->output_has_begun = true;
+
+ return true;
+}
+
+/* Create a mapping from a set of sections to a program segment. */
+
+static INLINE struct elf_segment_map *
+make_mapping (abfd, sections, from, to, phdr)
+ bfd *abfd;
+ asection **sections;
+ unsigned int from;
+ unsigned int to;
+ boolean phdr;
+{
+ struct elf_segment_map *m;
+ unsigned int i;
+ asection **hdrpp;
+
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd,
+ (sizeof (struct elf_segment_map)
+ + (to - from - 1) * sizeof (asection *))));
+ if (m == NULL)
+ return NULL;
+ m->next = NULL;
+ m->p_type = PT_LOAD;
+ for (i = from, hdrpp = sections + from; i < to; i++, hdrpp++)
+ m->sections[i - from] = *hdrpp;
+ m->count = to - from;
+
+ if (from == 0 && phdr)
+ {
+ /* Include the headers in the first PT_LOAD segment. */
+ m->includes_filehdr = 1;
+ m->includes_phdrs = 1;
+ }
+
+ return m;
+}
+
+/* Set up a mapping from BFD sections to program segments. */
+
+static boolean
+map_sections_to_segments (abfd)
+ bfd *abfd;
+{
+ asection **sections = NULL;
+ asection *s;
+ unsigned int i;
+ unsigned int count;
+ struct elf_segment_map *mfirst;
+ struct elf_segment_map **pm;
+ struct elf_segment_map *m;
+ asection *last_hdr;
+ unsigned int phdr_index;
+ bfd_vma maxpagesize;
+ asection **hdrpp;
+ boolean phdr_in_segment = true;
+ boolean writable;
+ asection *dynsec;
+
+ if (elf_tdata (abfd)->segment_map != NULL)
+ return true;
+
+ if (bfd_count_sections (abfd) == 0)
+ return true;
+
+ /* Select the allocated sections, and sort them. */
+
+ sections = (asection **) bfd_malloc (bfd_count_sections (abfd)
+ * sizeof (asection *));
+ if (sections == NULL)
+ goto error_return;
+
+ i = 0;
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_ALLOC) != 0)
+ {
+ sections[i] = s;
+ ++i;
+ }
+ }
+ BFD_ASSERT (i <= bfd_count_sections (abfd));
+ count = i;
+
+ qsort (sections, (size_t) count, sizeof (asection *), elf_sort_sections);
+
+ /* Build the mapping. */
+
+ mfirst = NULL;
+ pm = &mfirst;
+
+ /* If we have a .interp section, then create a PT_PHDR segment for
+ the program headers and a PT_INTERP segment for the .interp
+ section. */
+ s = bfd_get_section_by_name (abfd, ".interp");
+ if (s != NULL && (s->flags & SEC_LOAD) != 0)
+ {
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ if (m == NULL)
+ goto error_return;
+ m->next = NULL;
+ m->p_type = PT_PHDR;
+ /* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
+ m->p_flags = PF_R | PF_X;
+ m->p_flags_valid = 1;
+ m->includes_phdrs = 1;
+
+ *pm = m;
+ pm = &m->next;
+
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ if (m == NULL)
+ goto error_return;
+ m->next = NULL;
+ m->p_type = PT_INTERP;
+ m->count = 1;
+ m->sections[0] = s;
+
+ *pm = m;
+ pm = &m->next;
+ }
+
+ /* Look through the sections. We put sections in the same program
+ segment when the start of the second section can be placed within
+ a few bytes of the end of the first section. */
+ last_hdr = NULL;
+ phdr_index = 0;
+ maxpagesize = get_elf_backend_data (abfd)->maxpagesize;
+ writable = false;
+ dynsec = bfd_get_section_by_name (abfd, ".dynamic");
+ if (dynsec != NULL
+ && (dynsec->flags & SEC_LOAD) == 0)
+ dynsec = NULL;
+
+ /* Deal with -Ttext or something similar such that the first section
+ is not adjacent to the program headers. This is an
+ approximation, since at this point we don't know exactly how many
+ program headers we will need. */
+ if (count > 0)
+ {
+ bfd_size_type phdr_size;
+
+ phdr_size = elf_tdata (abfd)->program_header_size;
+ if (phdr_size == 0)
+ phdr_size = get_elf_backend_data (abfd)->s->sizeof_phdr;
+ if ((abfd->flags & D_PAGED) == 0
+ || sections[0]->lma < phdr_size
+ || sections[0]->lma % maxpagesize < phdr_size % maxpagesize)
+ phdr_in_segment = false;
+ }
+
+ for (i = 0, hdrpp = sections; i < count; i++, hdrpp++)
+ {
+ asection *hdr;
+ boolean new_segment;
+
+ hdr = *hdrpp;
+
+ /* See if this section and the last one will fit in the same
+ segment. */
+
+ if (last_hdr == NULL)
+ {
+ /* If we don't have a segment yet, then we don't need a new
+ one (we build the last one after this loop). */
+ new_segment = false;
+ }
+ else if (last_hdr->lma - last_hdr->vma != hdr->lma - hdr->vma)
+ {
+ /* If this section has a different relation between the
+ virtual address and the load address, then we need a new
+ segment. */
+ new_segment = true;
+ }
+ else if (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize)
+ < BFD_ALIGN (hdr->lma, maxpagesize))
+ {
+ /* If putting this section in this segment would force us to
+ skip a page in the segment, then we need a new segment. */
+ new_segment = true;
+ }
+ else if ((last_hdr->flags & SEC_LOAD) == 0
+ && (hdr->flags & SEC_LOAD) != 0)
+ {
+ /* We don't want to put a loadable section after a
+ nonloadable section in the same segment. */
+ new_segment = true;
+ }
+ else if ((abfd->flags & D_PAGED) == 0)
+ {
+ /* If the file is not demand paged, which means that we
+ don't require the sections to be correctly aligned in the
+ file, then there is no other reason for a new segment. */
+ new_segment = false;
+ }
+ else if (! writable
+ && (hdr->flags & SEC_READONLY) == 0
+ && (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize)
+ == hdr->lma))
+ {
+ /* We don't want to put a writable section in a read only
+ segment, unless they are on the same page in memory
+ anyhow. We already know that the last section does not
+ bring us past the current section on the page, so the
+ only case in which the new section is not on the same
+ page as the previous section is when the previous section
+ ends precisely on a page boundary. */
+ new_segment = true;
+ }
+ else
+ {
+ /* Otherwise, we can use the same segment. */
+ new_segment = false;
+ }
+
+ if (! new_segment)
+ {
+ if ((hdr->flags & SEC_READONLY) == 0)
+ writable = true;
+ last_hdr = hdr;
+ continue;
+ }
+
+ /* We need a new program segment. We must create a new program
+ header holding all the sections from phdr_index until hdr. */
+
+ m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
+ if (m == NULL)
+ goto error_return;
+
+ *pm = m;
+ pm = &m->next;
+
+ if ((hdr->flags & SEC_READONLY) == 0)
+ writable = true;
+ else
+ writable = false;
+
+ last_hdr = hdr;
+ phdr_index = i;
+ phdr_in_segment = false;
+ }
+
+ /* Create a final PT_LOAD program segment. */
+ if (last_hdr != NULL)
+ {
+ m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
+ if (m == NULL)
+ goto error_return;
+
+ *pm = m;
+ pm = &m->next;
+ }
+
+ /* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
+ if (dynsec != NULL)
+ {
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ if (m == NULL)
+ goto error_return;
+ m->next = NULL;
+ m->p_type = PT_DYNAMIC;
+ m->count = 1;
+ m->sections[0] = dynsec;
+
+ *pm = m;
+ pm = &m->next;
+ }
+
+ /* For each loadable .note section, add a PT_NOTE segment. We don't
+ use bfd_get_section_by_name, because if we link together
+ nonloadable .note sections and loadable .note sections, we will
+ generate two .note sections in the output file. FIXME: Using
+ names for section types is bogus anyhow. */
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LOAD) != 0
+ && strncmp (s->name, ".note", 5) == 0)
+ {
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ if (m == NULL)
+ goto error_return;
+ m->next = NULL;
+ m->p_type = PT_NOTE;
+ m->count = 1;
+ m->sections[0] = s;
+
+ *pm = m;
+ pm = &m->next;
+ }
+ }
+
+ free (sections);
+ sections = NULL;
+
+ elf_tdata (abfd)->segment_map = mfirst;
+ return true;
+
+ error_return:
+ if (sections != NULL)
+ free (sections);
+ return false;
+}
+
+/* Sort sections by address. */
+
+static int
+elf_sort_sections (arg1, arg2)
+ const PTR arg1;
+ const PTR arg2;
+{
+ const asection *sec1 = *(const asection **) arg1;
+ const asection *sec2 = *(const asection **) arg2;
+
+ /* Sort by LMA first, since this is the address used to
+ place the section into a segment. */
+ if (sec1->lma < sec2->lma)
+ return -1;
+ else if (sec1->lma > sec2->lma)
+ return 1;
+
+ /* Then sort by VMA. Normally the LMA and the VMA will be
+ the same, and this will do nothing. */
+ if (sec1->vma < sec2->vma)
+ return -1;
+ else if (sec1->vma > sec2->vma)
+ return 1;
+
+ /* Put !SEC_LOAD sections after SEC_LOAD ones. */
+
+#define TOEND(x) (((x)->flags & SEC_LOAD) == 0)
+
+ if (TOEND (sec1))
+ {
+ if (TOEND (sec2))
+ return sec1->target_index - sec2->target_index;
+ else
+ return 1;
+ }
+
+ if (TOEND (sec2))
+ return -1;
+
+#undef TOEND
+
+ /* Sort by size, to put zero sized sections before others at the
+ same address. */
+
+ if (sec1->_raw_size < sec2->_raw_size)
+ return -1;
+ if (sec1->_raw_size > sec2->_raw_size)
+ return 1;
+
+ return sec1->target_index - sec2->target_index;
+}
+
+/* Assign file positions to the sections based on the mapping from
+ sections to segments. This function also sets up some fields in
+ the file header, and writes out the program headers. */
+
+static boolean
+assign_file_positions_for_segments (abfd)
+ bfd *abfd;
+{
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ unsigned int count;
+ struct elf_segment_map *m;
+ unsigned int alloc;
+ Elf_Internal_Phdr *phdrs;
+ file_ptr off, voff;
+ bfd_vma filehdr_vaddr, filehdr_paddr;
+ bfd_vma phdrs_vaddr, phdrs_paddr;
+ Elf_Internal_Phdr *p;
+
+ if (elf_tdata (abfd)->segment_map == NULL)
+ {
+ if (! map_sections_to_segments (abfd))
+ return false;
+ }
+
+ if (bed->elf_backend_modify_segment_map)
+ {
+ if (! (*bed->elf_backend_modify_segment_map) (abfd))
+ return false;
+ }
+
+ count = 0;
+ for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ ++count;
+
+ elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
+ elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
+ elf_elfheader (abfd)->e_phnum = count;
+
+ if (count == 0)
+ return true;
+
+ /* If we already counted the number of program segments, make sure
+ that we allocated enough space. This happens when SIZEOF_HEADERS
+ is used in a linker script. */
+ alloc = elf_tdata (abfd)->program_header_size / bed->s->sizeof_phdr;
+ if (alloc != 0 && count > alloc)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: Not enough room for program headers (allocated %u, need %u)"),
+ bfd_get_filename (abfd), alloc, count));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (alloc == 0)
+ alloc = count;
+
+ phdrs = ((Elf_Internal_Phdr *)
+ bfd_alloc (abfd, alloc * sizeof (Elf_Internal_Phdr)));
+ if (phdrs == NULL)
+ return false;
+
+ off = bed->s->sizeof_ehdr;
+ off += alloc * bed->s->sizeof_phdr;
+
+ filehdr_vaddr = 0;
+ filehdr_paddr = 0;
+ phdrs_vaddr = 0;
+ phdrs_paddr = 0;
+
+ for (m = elf_tdata (abfd)->segment_map, p = phdrs;
+ m != NULL;
+ m = m->next, p++)
+ {
+ unsigned int i;
+ asection **secpp;
+
+ /* If elf_segment_map is not from map_sections_to_segments, the
+ sections may not be correctly ordered. */
+ if (m->count > 0)
+ qsort (m->sections, (size_t) m->count, sizeof (asection *),
+ elf_sort_sections);
+
+ p->p_type = m->p_type;
+
+ if (m->p_flags_valid)
+ p->p_flags = m->p_flags;
+ else
+ p->p_flags = 0;
+
+ if (p->p_type == PT_LOAD
+ && m->count > 0
+ && (m->sections[0]->flags & SEC_ALLOC) != 0)
+ {
+ if ((abfd->flags & D_PAGED) != 0)
+ off += (m->sections[0]->vma - off) % bed->maxpagesize;
+ else
+ {
+ bfd_size_type align;
+
+ align = 0;
+ for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
+ {
+ bfd_size_type secalign;
+
+ secalign = bfd_get_section_alignment (abfd, *secpp);
+ if (secalign > align)
+ align = secalign;
+ }
+
+ off += (m->sections[0]->vma - off) % (1 << align);
+ }
+ }
+
+ if (m->count == 0)
+ p->p_vaddr = 0;
+ else
+ p->p_vaddr = m->sections[0]->vma;
+
+ if (m->p_paddr_valid)
+ p->p_paddr = m->p_paddr;
+ else if (m->count == 0)
+ p->p_paddr = 0;
+ else
+ p->p_paddr = m->sections[0]->lma;
+
+ if (p->p_type == PT_LOAD
+ && (abfd->flags & D_PAGED) != 0)
+ p->p_align = bed->maxpagesize;
+ else if (m->count == 0)
+ p->p_align = bed->s->file_align;
+ else
+ p->p_align = 0;
+
+ p->p_offset = 0;
+ p->p_filesz = 0;
+ p->p_memsz = 0;
+
+ if (m->includes_filehdr)
+ {
+ if (! m->p_flags_valid)
+ p->p_flags |= PF_R;
+ p->p_offset = 0;
+ p->p_filesz = bed->s->sizeof_ehdr;
+ p->p_memsz = bed->s->sizeof_ehdr;
+ if (m->count > 0)
+ {
+ BFD_ASSERT (p->p_type == PT_LOAD);
+
+ if (p->p_vaddr < (bfd_vma) off)
+ {
+ _bfd_error_handler (_("%s: Not enough room for program headers, try linking with -N"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ p->p_vaddr -= off;
+ if (! m->p_paddr_valid)
+ p->p_paddr -= off;
+ }
+ if (p->p_type == PT_LOAD)
+ {
+ filehdr_vaddr = p->p_vaddr;
+ filehdr_paddr = p->p_paddr;
+ }
+ }
+
+ if (m->includes_phdrs)
+ {
+ if (! m->p_flags_valid)
+ p->p_flags |= PF_R;
+
+ if (m->includes_filehdr)
+ {
+ if (p->p_type == PT_LOAD)
+ {
+ phdrs_vaddr = p->p_vaddr + bed->s->sizeof_ehdr;
+ phdrs_paddr = p->p_paddr + bed->s->sizeof_ehdr;
+ }
+ }
+ else
+ {
+ p->p_offset = bed->s->sizeof_ehdr;
+
+ if (m->count > 0)
+ {
+ BFD_ASSERT (p->p_type == PT_LOAD);
+ p->p_vaddr -= off - p->p_offset;
+ if (! m->p_paddr_valid)
+ p->p_paddr -= off - p->p_offset;
+ }
+
+ if (p->p_type == PT_LOAD)
+ {
+ phdrs_vaddr = p->p_vaddr;
+ phdrs_paddr = p->p_paddr;
+ }
+ else
+ phdrs_vaddr = bed->maxpagesize + bed->s->sizeof_ehdr;
+ }
+
+ p->p_filesz += alloc * bed->s->sizeof_phdr;
+ p->p_memsz += alloc * bed->s->sizeof_phdr;
+ }
+
+ if (p->p_type == PT_LOAD
+ || (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core))
+ {
+ if (! m->includes_filehdr && ! m->includes_phdrs)
+ p->p_offset = off;
+ else
+ {
+ file_ptr adjust;
+
+ adjust = off - (p->p_offset + p->p_filesz);
+ p->p_filesz += adjust;
+ p->p_memsz += adjust;
+ }
+ }
+
+ voff = off;
+
+ for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
+ {
+ asection *sec;
+ flagword flags;
+ bfd_size_type align;
+
+ sec = *secpp;
+ flags = sec->flags;
+ align = 1 << bfd_get_section_alignment (abfd, sec);
+
+ /* The section may have artificial alignment forced by a
+ link script. Notice this case by the gap between the
+ cumulative phdr vma and the section's vma. */
+ if (p->p_vaddr + p->p_memsz < sec->vma)
+ {
+ bfd_vma adjust = sec->vma - (p->p_vaddr + p->p_memsz);
+
+ p->p_memsz += adjust;
+ off += adjust;
+ voff += adjust;
+ if ((flags & SEC_LOAD) != 0)
+ p->p_filesz += adjust;
+ }
+
+ if (p->p_type == PT_LOAD)
+ {
+ bfd_signed_vma adjust;
+
+ if ((flags & SEC_LOAD) != 0)
+ {
+ adjust = sec->lma - (p->p_paddr + p->p_memsz);
+ if (adjust < 0)
+ adjust = 0;
+ }
+ else if ((flags & SEC_ALLOC) != 0)
+ {
+ /* The section VMA must equal the file position
+ modulo the page size. FIXME: I'm not sure if
+ this adjustment is really necessary. We used to
+ not have the SEC_LOAD case just above, and then
+ this was necessary, but now I'm not sure. */
+ if ((abfd->flags & D_PAGED) != 0)
+ adjust = (sec->vma - voff) % bed->maxpagesize;
+ else
+ adjust = (sec->vma - voff) % align;
+ }
+ else
+ adjust = 0;
+
+ if (adjust != 0)
+ {
+ if (i == 0)
+ {
+ (* _bfd_error_handler)
+ (_("Error: First section in segment (%s) starts at 0x%x"),
+ bfd_section_name (abfd, sec), sec->lma);
+ (* _bfd_error_handler)
+ (_(" whereas segment starts at 0x%x"),
+ p->p_paddr);
+
+ return false;
+ }
+ p->p_memsz += adjust;
+ off += adjust;
+ voff += adjust;
+ if ((flags & SEC_LOAD) != 0)
+ p->p_filesz += adjust;
+ }
+
+ sec->filepos = off;
+
+ /* We check SEC_HAS_CONTENTS here because if NOLOAD is
+ used in a linker script we may have a section with
+ SEC_LOAD clear but which is supposed to have
+ contents. */
+ if ((flags & SEC_LOAD) != 0
+ || (flags & SEC_HAS_CONTENTS) != 0)
+ off += sec->_raw_size;
+
+ if ((flags & SEC_ALLOC) != 0)
+ voff += sec->_raw_size;
+ }
+
+ if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core)
+ {
+ if (i == 0) /* the actual "note" segment */
+ { /* this one actually contains everything. */
+ sec->filepos = off;
+ p->p_filesz = sec->_raw_size;
+ off += sec->_raw_size;
+ voff = off;
+ }
+ else /* fake sections -- don't need to be written */
+ {
+ sec->filepos = 0;
+ sec->_raw_size = 0;
+ flags = sec->flags = 0; /* no contents */
+ }
+ p->p_memsz = 0;
+ p->p_align = 1;
+ }
+ else
+ {
+ p->p_memsz += sec->_raw_size;
+
+ if ((flags & SEC_LOAD) != 0)
+ p->p_filesz += sec->_raw_size;
+
+ if (align > p->p_align
+ && (p->p_type != PT_LOAD || (abfd->flags & D_PAGED) == 0))
+ p->p_align = align;
+ }
+
+ if (! m->p_flags_valid)
+ {
+ p->p_flags |= PF_R;
+ if ((flags & SEC_CODE) != 0)
+ p->p_flags |= PF_X;
+ if ((flags & SEC_READONLY) == 0)
+ p->p_flags |= PF_W;
+ }
+ }
+ }
+
+ /* Now that we have set the section file positions, we can set up
+ the file positions for the non PT_LOAD segments. */
+ for (m = elf_tdata (abfd)->segment_map, p = phdrs;
+ m != NULL;
+ m = m->next, p++)
+ {
+ if (p->p_type != PT_LOAD && m->count > 0)
+ {
+ BFD_ASSERT (! m->includes_filehdr && ! m->includes_phdrs);
+ p->p_offset = m->sections[0]->filepos;
+ }
+ if (m->count == 0)
+ {
+ if (m->includes_filehdr)
+ {
+ p->p_vaddr = filehdr_vaddr;
+ if (! m->p_paddr_valid)
+ p->p_paddr = filehdr_paddr;
+ }
+ else if (m->includes_phdrs)
+ {
+ p->p_vaddr = phdrs_vaddr;
+ if (! m->p_paddr_valid)
+ p->p_paddr = phdrs_paddr;
+ }
+ }
+ }
+
+ /* Clear out any program headers we allocated but did not use. */
+ for (; count < alloc; count++, p++)
+ {
+ memset (p, 0, sizeof *p);
+ p->p_type = PT_NULL;
+ }
+
+ elf_tdata (abfd)->phdr = phdrs;
+
+ elf_tdata (abfd)->next_file_pos = off;
+
+ /* Write out the program headers. */
+ if (bfd_seek (abfd, bed->s->sizeof_ehdr, SEEK_SET) != 0
+ || bed->s->write_out_phdrs (abfd, phdrs, alloc) != 0)
+ return false;
+
+ return true;
+}
+
+/* Get the size of the program header.
+
+ If this is called by the linker before any of the section VMA's are set, it
+ can't calculate the correct value for a strange memory layout. This only
+ happens when SIZEOF_HEADERS is used in a linker script. In this case,
+ SORTED_HDRS is NULL and we assume the normal scenario of one text and one
+ data segment (exclusive of .interp and .dynamic).
+
+ ??? User written scripts must either not use SIZEOF_HEADERS, or assume there
+ will be two segments. */
+
+static bfd_size_type
+get_program_header_size (abfd)
+ bfd *abfd;
+{
+ size_t segs;
+ asection *s;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+ /* We can't return a different result each time we're called. */
+ if (elf_tdata (abfd)->program_header_size != 0)
+ return elf_tdata (abfd)->program_header_size;
+
+ if (elf_tdata (abfd)->segment_map != NULL)
+ {
+ struct elf_segment_map *m;
+
+ segs = 0;
+ for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ ++segs;
+ elf_tdata (abfd)->program_header_size = segs * bed->s->sizeof_phdr;
+ return elf_tdata (abfd)->program_header_size;
+ }
+
+ /* Assume we will need exactly two PT_LOAD segments: one for text
+ and one for data. */
+ segs = 2;
+
+ s = bfd_get_section_by_name (abfd, ".interp");
+ if (s != NULL && (s->flags & SEC_LOAD) != 0)
+ {
+ /* If we have a loadable interpreter section, we need a
+ PT_INTERP segment. In this case, assume we also need a
+ PT_PHDR segment, although that may not be true for all
+ targets. */
+ segs += 2;
+ }
+
+ if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
+ {
+ /* We need a PT_DYNAMIC segment. */
+ ++segs;
+ }
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LOAD) != 0
+ && strncmp (s->name, ".note", 5) == 0)
+ {
+ /* We need a PT_NOTE segment. */
+ ++segs;
+ }
+ }
+
+ /* Let the backend count up any program headers it might need. */
+ if (bed->elf_backend_additional_program_headers)
+ {
+ int a;
+
+ a = (*bed->elf_backend_additional_program_headers) (abfd);
+ if (a == -1)
+ abort ();
+ segs += a;
+ }
+
+ elf_tdata (abfd)->program_header_size = segs * bed->s->sizeof_phdr;
+ return elf_tdata (abfd)->program_header_size;
+}
+
+/* Work out the file positions of all the sections. This is called by
+ _bfd_elf_compute_section_file_positions. All the section sizes and
+ VMAs must be known before this is called.
+
+ We do not consider reloc sections at this point, unless they form
+ part of the loadable image. Reloc sections are assigned file
+ positions in assign_file_positions_for_relocs, which is called by
+ write_object_contents and final_link.
+
+ We also don't set the positions of the .symtab and .strtab here. */
+
+static boolean
+assign_file_positions_except_relocs (abfd)
+ bfd *abfd;
+{
+ struct elf_obj_tdata * const tdata = elf_tdata (abfd);
+ Elf_Internal_Ehdr * const i_ehdrp = elf_elfheader (abfd);
+ Elf_Internal_Shdr ** const i_shdrpp = elf_elfsections (abfd);
+ file_ptr off;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
+ && bfd_get_format (abfd) != bfd_core)
+ {
+ Elf_Internal_Shdr **hdrpp;
+ unsigned int i;
+
+ /* Start after the ELF header. */
+ off = i_ehdrp->e_ehsize;
+
+ /* We are not creating an executable, which means that we are
+ not creating a program header, and that the actual order of
+ the sections in the file is unimportant. */
+ for (i = 1, hdrpp = i_shdrpp + 1; i < i_ehdrp->e_shnum; i++, hdrpp++)
+ {
+ Elf_Internal_Shdr *hdr;
+
+ hdr = *hdrpp;
+ if (hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
+ {
+ hdr->sh_offset = -1;
+ continue;
+ }
+ if (i == tdata->symtab_section
+ || i == tdata->strtab_section)
+ {
+ hdr->sh_offset = -1;
+ continue;
+ }
+
+ off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
+ }
+ }
+ else
+ {
+ unsigned int i;
+ Elf_Internal_Shdr **hdrpp;
+
+ /* Assign file positions for the loaded sections based on the
+ assignment of sections to segments. */
+ if (! assign_file_positions_for_segments (abfd))
+ return false;
+
+ /* Assign file positions for the other sections. */
+
+ off = elf_tdata (abfd)->next_file_pos;
+ for (i = 1, hdrpp = i_shdrpp + 1; i < i_ehdrp->e_shnum; i++, hdrpp++)
+ {
+ Elf_Internal_Shdr *hdr;
+
+ hdr = *hdrpp;
+ if (hdr->bfd_section != NULL
+ && hdr->bfd_section->filepos != 0)
+ hdr->sh_offset = hdr->bfd_section->filepos;
+ else if ((hdr->sh_flags & SHF_ALLOC) != 0)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: warning: allocated section `%s' not in segment"),
+ bfd_get_filename (abfd),
+ (hdr->bfd_section == NULL
+ ? "*unknown*"
+ : hdr->bfd_section->name)));
+ if ((abfd->flags & D_PAGED) != 0)
+ off += (hdr->sh_addr - off) % bed->maxpagesize;
+ else
+ off += (hdr->sh_addr - off) % hdr->sh_addralign;
+ off = _bfd_elf_assign_file_position_for_section (hdr, off,
+ false);
+ }
+ else if (hdr->sh_type == SHT_REL
+ || hdr->sh_type == SHT_RELA
+ || hdr == i_shdrpp[tdata->symtab_section]
+ || hdr == i_shdrpp[tdata->strtab_section])
+ hdr->sh_offset = -1;
+ else
+ off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
+ }
+ }
+
+ /* Place the section headers. */
+ off = align_file_position (off, bed->s->file_align);
+ i_ehdrp->e_shoff = off;
+ off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
+
+ elf_tdata (abfd)->next_file_pos = off;
+
+ return true;
+}
+
+static boolean
+prep_headers (abfd)
+ bfd *abfd;
+{
+ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
+ Elf_Internal_Phdr *i_phdrp = 0; /* Program header table, internal form */
+ Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
+ int count;
+ struct bfd_strtab_hash *shstrtab;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+ i_ehdrp = elf_elfheader (abfd);
+ i_shdrp = elf_elfsections (abfd);
+
+ shstrtab = _bfd_elf_stringtab_init ();
+ if (shstrtab == NULL)
+ return false;
+
+ elf_shstrtab (abfd) = shstrtab;
+
+ i_ehdrp->e_ident[EI_MAG0] = ELFMAG0;
+ i_ehdrp->e_ident[EI_MAG1] = ELFMAG1;
+ i_ehdrp->e_ident[EI_MAG2] = ELFMAG2;
+ i_ehdrp->e_ident[EI_MAG3] = ELFMAG3;
+
+ i_ehdrp->e_ident[EI_CLASS] = bed->s->elfclass;
+ i_ehdrp->e_ident[EI_DATA] =
+ bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
+ i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
+
+ for (count = EI_PAD; count < EI_NIDENT; count++)
+ i_ehdrp->e_ident[count] = 0;
+
+ if ((abfd->flags & DYNAMIC) != 0)
+ i_ehdrp->e_type = ET_DYN;
+ else if ((abfd->flags & EXEC_P) != 0)
+ i_ehdrp->e_type = ET_EXEC;
+ else if (bfd_get_format (abfd) == bfd_core)
+ i_ehdrp->e_type = ET_CORE;
+ else
+ i_ehdrp->e_type = ET_REL;
+
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_unknown:
+ i_ehdrp->e_machine = EM_NONE;
+ break;
+ case bfd_arch_sparc:
+ if (bed->s->arch_size == 64)
+ i_ehdrp->e_machine = EM_SPARCV9;
+ else
+ i_ehdrp->e_machine = EM_SPARC;
+ break;
+ case bfd_arch_i386:
+ i_ehdrp->e_machine = EM_386;
+ break;
+ case bfd_arch_m68k:
+ i_ehdrp->e_machine = EM_68K;
+ break;
+ case bfd_arch_m88k:
+ i_ehdrp->e_machine = EM_88K;
+ break;
+ case bfd_arch_i860:
+ i_ehdrp->e_machine = EM_860;
+ break;
+ case bfd_arch_mips: /* MIPS Rxxxx */
+ i_ehdrp->e_machine = EM_MIPS; /* only MIPS R3000 */
+ break;
+ case bfd_arch_hppa:
+ i_ehdrp->e_machine = EM_PARISC;
+ break;
+ case bfd_arch_powerpc:
+ i_ehdrp->e_machine = EM_PPC;
+ break;
+ case bfd_arch_alpha:
+ i_ehdrp->e_machine = EM_ALPHA;
+ break;
+ case bfd_arch_sh:
+ i_ehdrp->e_machine = EM_SH;
+ break;
+ case bfd_arch_d10v:
+ i_ehdrp->e_machine = EM_CYGNUS_D10V;
+ break;
+ case bfd_arch_d30v:
+ i_ehdrp->e_machine = EM_CYGNUS_D30V;
+ break;
+ case bfd_arch_fr30:
+ i_ehdrp->e_machine = EM_CYGNUS_FR30;
+ break;
+ case bfd_arch_mcore:
+ i_ehdrp->e_machine = EM_MCORE;
+ break;
+ case bfd_arch_v850:
+ switch (bfd_get_mach (abfd))
+ {
+ default:
+ case 0: i_ehdrp->e_machine = EM_CYGNUS_V850; break;
+ }
+ break;
+ case bfd_arch_arc:
+ i_ehdrp->e_machine = EM_CYGNUS_ARC;
+ break;
+ case bfd_arch_arm:
+ i_ehdrp->e_machine = EM_ARM;
+ break;
+ case bfd_arch_m32r:
+ i_ehdrp->e_machine = EM_CYGNUS_M32R;
+ break;
+ case bfd_arch_mn10200:
+ i_ehdrp->e_machine = EM_CYGNUS_MN10200;
+ break;
+ case bfd_arch_mn10300:
+ i_ehdrp->e_machine = EM_CYGNUS_MN10300;
+ break;
+ /* also note that EM_M32, AT&T WE32100 is unknown to bfd */
+ default:
+ i_ehdrp->e_machine = EM_NONE;
+ }
+ i_ehdrp->e_version = bed->s->ev_current;
+ i_ehdrp->e_ehsize = bed->s->sizeof_ehdr;
+
+ /* no program header, for now. */
+ i_ehdrp->e_phoff = 0;
+ i_ehdrp->e_phentsize = 0;
+ i_ehdrp->e_phnum = 0;
+
+ /* each bfd section is section header entry */
+ i_ehdrp->e_entry = bfd_get_start_address (abfd);
+ i_ehdrp->e_shentsize = bed->s->sizeof_shdr;
+
+ /* if we're building an executable, we'll need a program header table */
+ if (abfd->flags & EXEC_P)
+ {
+ /* it all happens later */
+#if 0
+ i_ehdrp->e_phentsize = sizeof (Elf_External_Phdr);
+
+ /* elf_build_phdrs() returns a (NULL-terminated) array of
+ Elf_Internal_Phdrs */
+ i_phdrp = elf_build_phdrs (abfd, i_ehdrp, i_shdrp, &i_ehdrp->e_phnum);
+ i_ehdrp->e_phoff = outbase;
+ outbase += i_ehdrp->e_phentsize * i_ehdrp->e_phnum;
+#endif
+ }
+ else
+ {
+ i_ehdrp->e_phentsize = 0;
+ i_phdrp = 0;
+ i_ehdrp->e_phoff = 0;
+ }
+
+ elf_tdata (abfd)->symtab_hdr.sh_name =
+ (unsigned int) _bfd_stringtab_add (shstrtab, ".symtab", true, false);
+ elf_tdata (abfd)->strtab_hdr.sh_name =
+ (unsigned int) _bfd_stringtab_add (shstrtab, ".strtab", true, false);
+ elf_tdata (abfd)->shstrtab_hdr.sh_name =
+ (unsigned int) _bfd_stringtab_add (shstrtab, ".shstrtab", true, false);
+ if (elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
+ || elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
+ || elf_tdata (abfd)->shstrtab_hdr.sh_name == (unsigned int) -1)
+ return false;
+
+ return true;
+}
+
+/* Assign file positions for all the reloc sections which are not part
+ of the loadable file image. */
+
+void
+_bfd_elf_assign_file_positions_for_relocs (abfd)
+ bfd *abfd;
+{
+ file_ptr off;
+ unsigned int i;
+ Elf_Internal_Shdr **shdrpp;
+
+ off = elf_tdata (abfd)->next_file_pos;
+
+ for (i = 1, shdrpp = elf_elfsections (abfd) + 1;
+ i < elf_elfheader (abfd)->e_shnum;
+ i++, shdrpp++)
+ {
+ Elf_Internal_Shdr *shdrp;
+
+ shdrp = *shdrpp;
+ if ((shdrp->sh_type == SHT_REL || shdrp->sh_type == SHT_RELA)
+ && shdrp->sh_offset == -1)
+ off = _bfd_elf_assign_file_position_for_section (shdrp, off, true);
+ }
+
+ elf_tdata (abfd)->next_file_pos = off;
+}
+
+boolean
+_bfd_elf_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ Elf_Internal_Ehdr *i_ehdrp;
+ Elf_Internal_Shdr **i_shdrp;
+ boolean failed;
+ unsigned int count;
+
+ if (! abfd->output_has_begun
+ && ! _bfd_elf_compute_section_file_positions
+ (abfd, (struct bfd_link_info *) NULL))
+ return false;
+
+ i_shdrp = elf_elfsections (abfd);
+ i_ehdrp = elf_elfheader (abfd);
+
+ failed = false;
+ bfd_map_over_sections (abfd, bed->s->write_relocs, &failed);
+ if (failed)
+ return false;
+
+ _bfd_elf_assign_file_positions_for_relocs (abfd);
+
+ /* After writing the headers, we need to write the sections too... */
+ for (count = 1; count < i_ehdrp->e_shnum; count++)
+ {
+ if (bed->elf_backend_section_processing)
+ (*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
+ if (i_shdrp[count]->contents)
+ {
+ if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
+ || (bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size,
+ 1, abfd)
+ != i_shdrp[count]->sh_size))
+ return false;
+ }
+ }
+
+ /* Write out the section header names. */
+ if (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
+ || ! _bfd_stringtab_emit (abfd, elf_shstrtab (abfd)))
+ return false;
+
+ if (bed->elf_backend_final_write_processing)
+ (*bed->elf_backend_final_write_processing) (abfd,
+ elf_tdata (abfd)->linker);
+
+ return bed->s->write_shdrs_and_ehdr (abfd);
+}
+
+boolean
+_bfd_elf_write_corefile_contents (abfd)
+ bfd *abfd;
+{
+ /* Hopefully this can be done just like an object file. */
+ return _bfd_elf_write_object_contents (abfd);
+}
+/* given a section, search the header to find them... */
+int
+_bfd_elf_section_from_bfd_section (abfd, asect)
+ bfd *abfd;
+ struct sec *asect;
+{
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
+ int index;
+ Elf_Internal_Shdr *hdr;
+ int maxindex = elf_elfheader (abfd)->e_shnum;
+
+ for (index = 0; index < maxindex; index++)
+ {
+ hdr = i_shdrp[index];
+ if (hdr->bfd_section == asect)
+ return index;
+ }
+
+ if (bed->elf_backend_section_from_bfd_section)
+ {
+ for (index = 0; index < maxindex; index++)
+ {
+ int retval;
+
+ hdr = i_shdrp[index];
+ retval = index;
+ if ((*bed->elf_backend_section_from_bfd_section)
+ (abfd, hdr, asect, &retval))
+ return retval;
+ }
+ }
+
+ if (bfd_is_abs_section (asect))
+ return SHN_ABS;
+ if (bfd_is_com_section (asect))
+ return SHN_COMMON;
+ if (bfd_is_und_section (asect))
+ return SHN_UNDEF;
+
+ bfd_set_error (bfd_error_nonrepresentable_section);
+
+ return -1;
+}
+
+/* Given a BFD symbol, return the index in the ELF symbol table, or -1
+ on error. */
+
+int
+_bfd_elf_symbol_from_bfd_symbol (abfd, asym_ptr_ptr)
+ bfd *abfd;
+ asymbol **asym_ptr_ptr;
+{
+ asymbol *asym_ptr = *asym_ptr_ptr;
+ int idx;
+ flagword flags = asym_ptr->flags;
+
+ /* When gas creates relocations against local labels, it creates its
+ own symbol for the section, but does put the symbol into the
+ symbol chain, so udata is 0. When the linker is generating
+ relocatable output, this section symbol may be for one of the
+ input sections rather than the output section. */
+ if (asym_ptr->udata.i == 0
+ && (flags & BSF_SECTION_SYM)
+ && asym_ptr->section)
+ {
+ int indx;
+
+ if (asym_ptr->section->output_section != NULL)
+ indx = asym_ptr->section->output_section->index;
+ else
+ indx = asym_ptr->section->index;
+ if (elf_section_syms (abfd)[indx])
+ asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
+ }
+
+ idx = asym_ptr->udata.i;
+
+ if (idx == 0)
+ {
+ /* This case can occur when using --strip-symbol on a symbol
+ which is used in a relocation entry. */
+ (*_bfd_error_handler)
+ (_("%s: symbol `%s' required but not present"),
+ bfd_get_filename (abfd), bfd_asymbol_name (asym_ptr));
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+#if DEBUG & 4
+ {
+ fprintf (stderr,
+ _("elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x%.8lx%s\n"),
+ (long) asym_ptr, asym_ptr->name, idx, flags,
+ elf_symbol_flags (flags));
+ fflush (stderr);
+ }
+#endif
+
+ return idx;
+}
+
+/* Copy private BFD data. This copies any program header information. */
+
+static boolean
+copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ Elf_Internal_Ehdr *iehdr;
+ struct elf_segment_map *mfirst;
+ struct elf_segment_map **pm;
+ struct elf_segment_map *m;
+ Elf_Internal_Phdr *p;
+ unsigned int i;
+ unsigned int num_segments;
+ boolean phdr_included = false;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ if (elf_tdata (ibfd)->phdr == NULL)
+ return true;
+
+ iehdr = elf_elfheader (ibfd);
+
+ mfirst = NULL;
+ pm = &mfirst;
+
+ num_segments = elf_elfheader (ibfd)->e_phnum;
+
+#define IS_CONTAINED_BY(addr, len, bottom, phdr) \
+ ((addr) >= (bottom) \
+ && ( ((addr) + (len)) <= ((bottom) + (phdr)->p_memsz) \
+ || ((addr) + (len)) <= ((bottom) + (phdr)->p_filesz)))
+
+ /* Special case: corefile "NOTE" section containing regs, prpsinfo etc. */
+
+#define IS_COREFILE_NOTE(p, s) \
+ (p->p_type == PT_NOTE \
+ && bfd_get_format (ibfd) == bfd_core \
+ && s->vma == 0 && s->lma == 0 \
+ && (bfd_vma) s->filepos >= p->p_offset \
+ && (bfd_vma) s->filepos + s->_raw_size \
+ <= p->p_offset + p->p_filesz)
+
+ /* The complicated case when p_vaddr is 0 is to handle the Solaris
+ linker, which generates a PT_INTERP section with p_vaddr and
+ p_memsz set to 0. */
+
+#define IS_SOLARIS_PT_INTERP(p, s) \
+ (p->p_vaddr == 0 \
+ && p->p_filesz > 0 \
+ && (s->flags & SEC_HAS_CONTENTS) != 0 \
+ && s->_raw_size > 0 \
+ && (bfd_vma) s->filepos >= p->p_offset \
+ && ((bfd_vma) s->filepos + s->_raw_size \
+ <= p->p_offset + p->p_filesz))
+
+ /* Scan through the segments specified in the program header
+ of the input BFD. */
+ for (i = 0, p = elf_tdata (ibfd)->phdr; i < num_segments; i++, p++)
+ {
+ unsigned int csecs;
+ asection *s;
+ asection **sections;
+ asection *os;
+ unsigned int isec;
+ bfd_vma matching_lma;
+ bfd_vma suggested_lma;
+ unsigned int j;
+
+ /* For each section in the input BFD, decide if it should be
+ included in the current segment. A section will be included
+ if it is within the address space of the segment, and it is
+ an allocated segment, and there is an output section
+ associated with it. */
+ csecs = 0;
+ for (s = ibfd->sections; s != NULL; s = s->next)
+ if (s->output_section != NULL)
+ {
+ if ((IS_CONTAINED_BY (s->vma, s->_raw_size, p->p_vaddr, p)
+ || IS_SOLARIS_PT_INTERP (p, s))
+ && (s->flags & SEC_ALLOC) != 0)
+ ++csecs;
+ else if (IS_COREFILE_NOTE (p, s))
+ ++csecs;
+ }
+
+ /* Allocate a segment map big enough to contain all of the
+ sections we have selected. */
+ m = ((struct elf_segment_map *)
+ bfd_alloc (obfd,
+ (sizeof (struct elf_segment_map)
+ + ((size_t) csecs - 1) * sizeof (asection *))));
+ if (m == NULL)
+ return false;
+
+ /* Initialise the fields of the segment map. Default to
+ using the physical address of the segment in the input BFD. */
+ m->next = NULL;
+ m->p_type = p->p_type;
+ m->p_flags = p->p_flags;
+ m->p_flags_valid = 1;
+ m->p_paddr = p->p_paddr;
+ m->p_paddr_valid = 1;
+
+ /* Determine if this segment contains the ELF file header
+ and if it contains the program headers themselves. */
+ m->includes_filehdr = (p->p_offset == 0
+ && p->p_filesz >= iehdr->e_ehsize);
+
+ m->includes_phdrs = 0;
+
+ if (! phdr_included || p->p_type != PT_LOAD)
+ {
+ m->includes_phdrs =
+ (p->p_offset <= (bfd_vma) iehdr->e_phoff
+ && (p->p_offset + p->p_filesz
+ >= ((bfd_vma) iehdr->e_phoff
+ + iehdr->e_phnum * iehdr->e_phentsize)));
+ if (p->p_type == PT_LOAD && m->includes_phdrs)
+ phdr_included = true;
+ }
+
+ if (csecs == 0)
+ {
+ /* Special segments, such as the PT_PHDR segment, may contain
+ no sections, but ordinary, loadable segments should contain
+ something. */
+
+ if (p->p_type == PT_LOAD)
+ _bfd_error_handler
+ (_("%s: warning: Empty loadable segment detected\n"),
+ bfd_get_filename (ibfd));
+
+ m->count = 0;
+ *pm = m;
+ pm = &m->next;
+
+ continue;
+ }
+
+ /* Now scan the sections in the input BFD again and attempt
+ to add their corresponding output sections to the segment map.
+ The problem here is how to handle an output section which has
+ been moved (ie had its LMA changed). There are four possibilities:
+
+ 1. None of the sections have been moved.
+ In this case we can continue to use the segment LMA from the
+ input BFD.
+
+ 2. All of the sections have been moved by the same amount.
+ In this case we can change the segment's LMA to match the LMA
+ of the first section.
+
+ 3. Some of the sections have been moved, others have not.
+ In this case those sections which have not been moved can be
+ placed in the current segment which will have to have its size,
+ and possibly its LMA changed, and a new segment or segments will
+ have to be created to contain the other sections.
+
+ 4. The sections have been moved, but not be the same amount.
+ In this case we can change the segment's LMA to match the LMA
+ of the first section and we will have to create a new segment
+ or segments to contain the other sections.
+
+ In order to save time, we allocate an array to hold the section
+ pointers that we are interested in. As these sections get assigned
+ to a segment, they are removed from this array. */
+
+ sections = (asection **) bfd_malloc (sizeof (asection *) * csecs);
+ if (sections == NULL)
+ return false;
+
+ /* Step One: Scan for segment vs section LMA conflicts.
+ Also add the sections to the section array allocated above.
+ Also add the sections to the current segment. In the common
+ case, where the sections have not been moved, this means that
+ we have completely filled the segment, and there is nothing
+ more to do. */
+
+ isec = 0;
+ matching_lma = false;
+ suggested_lma = 0;
+
+ for (j = 0, s = ibfd->sections; s != NULL; s = s->next)
+ {
+ os = s->output_section;
+
+ if ((((IS_CONTAINED_BY (s->vma, s->_raw_size, p->p_vaddr, p)
+ || IS_SOLARIS_PT_INTERP (p, s))
+ && (s->flags & SEC_ALLOC) != 0)
+ || IS_COREFILE_NOTE (p, s))
+ && os != NULL)
+ {
+ sections[j++] = s;
+
+ /* The Solaris native linker always sets p_paddr to 0.
+ We try to catch that case here, and set it to the
+ correct value. */
+ if (p->p_paddr == 0
+ && p->p_vaddr != 0
+ && isec == 0
+ && os->lma != 0
+ && (os->vma == (p->p_vaddr
+ + (m->includes_filehdr
+ ? iehdr->e_ehsize
+ : 0)
+ + (m->includes_phdrs
+ ? iehdr->e_phnum * iehdr->e_phentsize
+ : 0))))
+ m->p_paddr = p->p_vaddr;
+
+ /* Match up the physical address of the segment with the
+ LMA address of the output section. */
+ if (IS_CONTAINED_BY (os->lma, os->_raw_size, m->p_paddr, p)
+ || IS_COREFILE_NOTE (p, s))
+ {
+ if (matching_lma == 0)
+ matching_lma = os->lma;
+
+ /* We assume that if the section fits within the segment
+ that it does not overlap any other section within that
+ segment. */
+ m->sections[isec++] = os;
+ }
+ else if (suggested_lma == 0)
+ suggested_lma = os->lma;
+ }
+ }
+
+ BFD_ASSERT (j == csecs);
+
+ /* Step Two: Adjust the physical address of the current segment,
+ if necessary. */
+ if (isec == csecs)
+ {
+ /* All of the sections fitted within the segment as currently
+ specified. This is the default case. Add the segment to
+ the list of built segments and carry on to process the next
+ program header in the input BFD. */
+ m->count = csecs;
+ *pm = m;
+ pm = &m->next;
+
+ free (sections);
+ continue;
+ }
+ else if (matching_lma != 0)
+ {
+ /* At least one section fits inside the current segment.
+ Keep it, but modify its physical address to match the
+ LMA of the first section that fitted. */
+
+ m->p_paddr = matching_lma;
+ }
+ else
+ {
+ /* None of the sections fitted inside the current segment.
+ Change the current segment's physical address to match
+ the LMA of the first section. */
+
+ m->p_paddr = suggested_lma;
+ }
+
+ /* Step Three: Loop over the sections again, this time assigning
+ those that fit to the current segment and remvoing them from the
+ sections array; but making sure not to leave large gaps. Once all
+ possible sections have been assigned to the current segment it is
+ added to the list of built segments and if sections still remain
+ to be assigned, a new segment is constructed before repeating
+ the loop. */
+ isec = 0;
+ do
+ {
+ m->count = 0;
+ suggested_lma = 0;
+
+ /* Fill the current segment with sections that fit. */
+ for (j = 0; j < csecs; j++)
+ {
+ s = sections[j];
+
+ if (s == NULL)
+ continue;
+
+ os = s->output_section;
+
+ if (IS_CONTAINED_BY (os->lma, os->_raw_size, m->p_paddr, p)
+ || IS_COREFILE_NOTE (p, s))
+ {
+ if (m->count == 0)
+ {
+ /* If the first section in a segment does not start at
+ the beginning of the segment, then something is wrong. */
+ if (os->lma != m->p_paddr)
+ abort ();
+ }
+ else
+ {
+ asection * prev_sec;
+ bfd_vma maxpagesize;
+
+ prev_sec = m->sections[m->count - 1];
+ maxpagesize = get_elf_backend_data (obfd)->maxpagesize;
+
+ /* If the gap between the end of the previous section
+ and the start of this section is more than maxpagesize
+ then we need to start a new segment. */
+ if (BFD_ALIGN (prev_sec->lma + prev_sec->_raw_size, maxpagesize)
+ < BFD_ALIGN (os->lma, maxpagesize))
+ {
+ if (suggested_lma == 0)
+ suggested_lma = os->lma;
+
+ continue;
+ }
+ }
+
+ m->sections[m->count++] = os;
+ ++isec;
+ sections[j] = NULL;
+ }
+ else if (suggested_lma == 0)
+ suggested_lma = os->lma;
+ }
+
+ BFD_ASSERT (m->count > 0);
+
+ /* Add the current segment to the list of built segments. */
+ *pm = m;
+ pm = &m->next;
+
+ if (isec < csecs)
+ {
+ /* We still have not allocated all of the sections to
+ segments. Create a new segment here, initialise it
+ and carry on looping. */
+
+ m = ((struct elf_segment_map *)
+ bfd_alloc (obfd,
+ (sizeof (struct elf_segment_map)
+ + ((size_t) csecs - 1) * sizeof (asection *))));
+ if (m == NULL)
+ return false;
+
+ /* Initialise the fields of the segment map. Set the physical
+ physical address to the LMA of the first section that has
+ not yet been assigned. */
+
+ m->next = NULL;
+ m->p_type = p->p_type;
+ m->p_flags = p->p_flags;
+ m->p_flags_valid = 1;
+ m->p_paddr = suggested_lma;
+ m->p_paddr_valid = 1;
+ m->includes_filehdr = 0;
+ m->includes_phdrs = 0;
+ }
+ }
+ while (isec < csecs);
+
+ free (sections);
+ }
+
+ /* The Solaris linker creates program headers in which all the
+ p_paddr fields are zero. When we try to objcopy or strip such a
+ file, we get confused. Check for this case, and if we find it
+ reset the p_paddr_valid fields. */
+ for (m = mfirst; m != NULL; m = m->next)
+ if (m->p_paddr != 0)
+ break;
+ if (m == NULL)
+ {
+ for (m = mfirst; m != NULL; m = m->next)
+ m->p_paddr_valid = 0;
+ }
+
+ elf_tdata (obfd)->segment_map = mfirst;
+
+#if 0
+ /* Final Step: Sort the segments into ascending order of physical address. */
+ if (mfirst != NULL)
+ {
+ struct elf_segment_map* prev;
+
+ prev = mfirst;
+ for (m = mfirst->next; m != NULL; prev = m, m = m->next)
+ {
+ /* Yes I know - its a bubble sort....*/
+ if (m->next != NULL && (m->next->p_paddr < m->p_paddr))
+ {
+ /* swap m and m->next */
+ prev->next = m->next;
+ m->next = m->next->next;
+ prev->next->next = m;
+
+ /* restart loop. */
+ m = mfirst;
+ }
+ }
+ }
+#endif
+
+#undef IS_CONTAINED_BY
+#undef IS_SOLARIS_PT_INTERP
+#undef IS_COREFILE_NOTE
+ return true;
+}
+
+/* Copy private section information. This copies over the entsize
+ field, and sometimes the info field. */
+
+boolean
+_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)
+ bfd *ibfd;
+ asection *isec;
+ bfd *obfd;
+ asection *osec;
+{
+ Elf_Internal_Shdr *ihdr, *ohdr;
+
+ if (ibfd->xvec->flavour != bfd_target_elf_flavour
+ || obfd->xvec->flavour != bfd_target_elf_flavour)
+ return true;
+
+ /* Copy over private BFD data if it has not already been copied.
+ This must be done here, rather than in the copy_private_bfd_data
+ entry point, because the latter is called after the section
+ contents have been set, which means that the program headers have
+ already been worked out. */
+ if (elf_tdata (obfd)->segment_map == NULL
+ && elf_tdata (ibfd)->phdr != NULL)
+ {
+ asection *s;
+
+ /* Only set up the segments if there are no more SEC_ALLOC
+ sections. FIXME: This won't do the right thing if objcopy is
+ used to remove the last SEC_ALLOC section, since objcopy
+ won't call this routine in that case. */
+ for (s = isec->next; s != NULL; s = s->next)
+ if ((s->flags & SEC_ALLOC) != 0)
+ break;
+ if (s == NULL)
+ {
+ if (! copy_private_bfd_data (ibfd, obfd))
+ return false;
+ }
+ }
+
+ ihdr = &elf_section_data (isec)->this_hdr;
+ ohdr = &elf_section_data (osec)->this_hdr;
+
+ ohdr->sh_entsize = ihdr->sh_entsize;
+
+ if (ihdr->sh_type == SHT_SYMTAB
+ || ihdr->sh_type == SHT_DYNSYM
+ || ihdr->sh_type == SHT_GNU_verneed
+ || ihdr->sh_type == SHT_GNU_verdef)
+ ohdr->sh_info = ihdr->sh_info;
+
+ return true;
+}
+
+/* Copy private symbol information. If this symbol is in a section
+ which we did not map into a BFD section, try to map the section
+ index correctly. We use special macro definitions for the mapped
+ section indices; these definitions are interpreted by the
+ swap_out_syms function. */
+
+#define MAP_ONESYMTAB (SHN_LORESERVE - 1)
+#define MAP_DYNSYMTAB (SHN_LORESERVE - 2)
+#define MAP_STRTAB (SHN_LORESERVE - 3)
+#define MAP_SHSTRTAB (SHN_LORESERVE - 4)
+
+boolean
+_bfd_elf_copy_private_symbol_data (ibfd, isymarg, obfd, osymarg)
+ bfd *ibfd;
+ asymbol *isymarg;
+ bfd *obfd;
+ asymbol *osymarg;
+{
+ elf_symbol_type *isym, *osym;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ isym = elf_symbol_from (ibfd, isymarg);
+ osym = elf_symbol_from (obfd, osymarg);
+
+ if (isym != NULL
+ && osym != NULL
+ && bfd_is_abs_section (isym->symbol.section))
+ {
+ unsigned int shndx;
+
+ shndx = isym->internal_elf_sym.st_shndx;
+ if (shndx == elf_onesymtab (ibfd))
+ shndx = MAP_ONESYMTAB;
+ else if (shndx == elf_dynsymtab (ibfd))
+ shndx = MAP_DYNSYMTAB;
+ else if (shndx == elf_tdata (ibfd)->strtab_section)
+ shndx = MAP_STRTAB;
+ else if (shndx == elf_tdata (ibfd)->shstrtab_section)
+ shndx = MAP_SHSTRTAB;
+ osym->internal_elf_sym.st_shndx = shndx;
+ }
+
+ return true;
+}
+
+/* Swap out the symbols. */
+
+static boolean
+swap_out_syms (abfd, sttp, relocatable_p)
+ bfd *abfd;
+ struct bfd_strtab_hash **sttp;
+ int relocatable_p;
+{
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+ if (!elf_map_symbols (abfd))
+ return false;
+
+ /* Dump out the symtabs. */
+ {
+ int symcount = bfd_get_symcount (abfd);
+ asymbol **syms = bfd_get_outsymbols (abfd);
+ struct bfd_strtab_hash *stt;
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Shdr *symstrtab_hdr;
+ char *outbound_syms;
+ int idx;
+
+ stt = _bfd_elf_stringtab_init ();
+ if (stt == NULL)
+ return false;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr->sh_type = SHT_SYMTAB;
+ symtab_hdr->sh_entsize = bed->s->sizeof_sym;
+ symtab_hdr->sh_size = symtab_hdr->sh_entsize * (symcount + 1);
+ symtab_hdr->sh_info = elf_num_locals (abfd) + 1;
+ symtab_hdr->sh_addralign = bed->s->file_align;
+
+ symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
+ symstrtab_hdr->sh_type = SHT_STRTAB;
+
+ outbound_syms = bfd_alloc (abfd,
+ (1 + symcount) * bed->s->sizeof_sym);
+ if (outbound_syms == NULL)
+ return false;
+ symtab_hdr->contents = (PTR) outbound_syms;
+
+ /* now generate the data (for "contents") */
+ {
+ /* Fill in zeroth symbol and swap it out. */
+ Elf_Internal_Sym sym;
+ sym.st_name = 0;
+ sym.st_value = 0;
+ sym.st_size = 0;
+ sym.st_info = 0;
+ sym.st_other = 0;
+ sym.st_shndx = SHN_UNDEF;
+ bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
+ outbound_syms += bed->s->sizeof_sym;
+ }
+ for (idx = 0; idx < symcount; idx++)
+ {
+ Elf_Internal_Sym sym;
+ bfd_vma value = syms[idx]->value;
+ elf_symbol_type *type_ptr;
+ flagword flags = syms[idx]->flags;
+ int type;
+
+ if (flags & BSF_SECTION_SYM)
+ /* Section symbols have no names. */
+ sym.st_name = 0;
+ else
+ {
+ sym.st_name = (unsigned long) _bfd_stringtab_add (stt,
+ syms[idx]->name,
+ true, false);
+ if (sym.st_name == (unsigned long) -1)
+ return false;
+ }
+
+ type_ptr = elf_symbol_from (abfd, syms[idx]);
+
+ if ((flags & BSF_SECTION_SYM) == 0
+ && bfd_is_com_section (syms[idx]->section))
+ {
+ /* ELF common symbols put the alignment into the `value' field,
+ and the size into the `size' field. This is backwards from
+ how BFD handles it, so reverse it here. */
+ sym.st_size = value;
+ if (type_ptr == NULL
+ || type_ptr->internal_elf_sym.st_value == 0)
+ sym.st_value = value >= 16 ? 16 : (1 << bfd_log2 (value));
+ else
+ sym.st_value = type_ptr->internal_elf_sym.st_value;
+ sym.st_shndx = _bfd_elf_section_from_bfd_section
+ (abfd, syms[idx]->section);
+ }
+ else
+ {
+ asection *sec = syms[idx]->section;
+ int shndx;
+
+ if (sec->output_section)
+ {
+ value += sec->output_offset;
+ sec = sec->output_section;
+ }
+ /* Don't add in the section vma for relocatable output. */
+ if (! relocatable_p)
+ value += sec->vma;
+ sym.st_value = value;
+ sym.st_size = type_ptr ? type_ptr->internal_elf_sym.st_size : 0;
+
+ if (bfd_is_abs_section (sec)
+ && type_ptr != NULL
+ && type_ptr->internal_elf_sym.st_shndx != 0)
+ {
+ /* This symbol is in a real ELF section which we did
+ not create as a BFD section. Undo the mapping done
+ by copy_private_symbol_data. */
+ shndx = type_ptr->internal_elf_sym.st_shndx;
+ switch (shndx)
+ {
+ case MAP_ONESYMTAB:
+ shndx = elf_onesymtab (abfd);
+ break;
+ case MAP_DYNSYMTAB:
+ shndx = elf_dynsymtab (abfd);
+ break;
+ case MAP_STRTAB:
+ shndx = elf_tdata (abfd)->strtab_section;
+ break;
+ case MAP_SHSTRTAB:
+ shndx = elf_tdata (abfd)->shstrtab_section;
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ if (shndx == -1)
+ {
+ asection *sec2;
+
+ /* Writing this would be a hell of a lot easier if
+ we had some decent documentation on bfd, and
+ knew what to expect of the library, and what to
+ demand of applications. For example, it
+ appears that `objcopy' might not set the
+ section of a symbol to be a section that is
+ actually in the output file. */
+ sec2 = bfd_get_section_by_name (abfd, sec->name);
+ BFD_ASSERT (sec2 != 0);
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec2);
+ BFD_ASSERT (shndx != -1);
+ }
+ }
+
+ sym.st_shndx = shndx;
+ }
+
+ if ((flags & BSF_FUNCTION) != 0)
+ type = STT_FUNC;
+ else if ((flags & BSF_OBJECT) != 0)
+ type = STT_OBJECT;
+ else
+ type = STT_NOTYPE;
+
+ /* Processor-specific types */
+ if (bed->elf_backend_get_symbol_type)
+ type = (*bed->elf_backend_get_symbol_type) (&type_ptr->internal_elf_sym, type);
+
+ if (flags & BSF_SECTION_SYM)
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ else if (bfd_is_com_section (syms[idx]->section))
+ sym.st_info = ELF_ST_INFO (STB_GLOBAL, type);
+ else if (bfd_is_und_section (syms[idx]->section))
+ sym.st_info = ELF_ST_INFO (((flags & BSF_WEAK)
+ ? STB_WEAK
+ : STB_GLOBAL),
+ type);
+ else if (flags & BSF_FILE)
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
+ else
+ {
+ int bind = STB_LOCAL;
+
+ if (flags & BSF_LOCAL)
+ bind = STB_LOCAL;
+ else if (flags & BSF_WEAK)
+ bind = STB_WEAK;
+ else if (flags & BSF_GLOBAL)
+ bind = STB_GLOBAL;
+
+ sym.st_info = ELF_ST_INFO (bind, type);
+ }
+
+ if (type_ptr != NULL)
+ sym.st_other = type_ptr->internal_elf_sym.st_other;
+ else
+ sym.st_other = 0;
+
+ bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
+ outbound_syms += bed->s->sizeof_sym;
+ }
+
+ *sttp = stt;
+ symstrtab_hdr->sh_size = _bfd_stringtab_size (stt);
+ symstrtab_hdr->sh_type = SHT_STRTAB;
+
+ symstrtab_hdr->sh_flags = 0;
+ symstrtab_hdr->sh_addr = 0;
+ symstrtab_hdr->sh_entsize = 0;
+ symstrtab_hdr->sh_link = 0;
+ symstrtab_hdr->sh_info = 0;
+ symstrtab_hdr->sh_addralign = 1;
+ }
+
+ return true;
+}
+
+/* Return the number of bytes required to hold the symtab vector.
+
+ Note that we base it on the count plus 1, since we will null terminate
+ the vector allocated based on this size. However, the ELF symbol table
+ always has a dummy entry as symbol #0, so it ends up even. */
+
+long
+_bfd_elf_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ long symcount;
+ long symtab_size;
+ Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;
+
+ symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
+ symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
+
+ return symtab_size;
+}
+
+long
+_bfd_elf_get_dynamic_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ long symcount;
+ long symtab_size;
+ Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;
+
+ if (elf_dynsymtab (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
+ symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
+
+ return symtab_size;
+}
+
+long
+_bfd_elf_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ return (asect->reloc_count + 1) * sizeof (arelent *);
+}
+
+/* Canonicalize the relocs. */
+
+long
+_bfd_elf_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr;
+ unsigned int i;
+
+ if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd,
+ section,
+ symbols,
+ false))
+ return -1;
+
+ tblptr = section->relocation;
+ for (i = 0; i < section->reloc_count; i++)
+ *relptr++ = tblptr++;
+
+ *relptr = NULL;
+
+ return section->reloc_count;
+}
+
+long
+_bfd_elf_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ long symcount = get_elf_backend_data (abfd)->s->slurp_symbol_table
+ (abfd, alocation, false);
+
+ if (symcount >= 0)
+ bfd_get_symcount (abfd) = symcount;
+ return symcount;
+}
+
+long
+_bfd_elf_canonicalize_dynamic_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ return get_elf_backend_data (abfd)->s->slurp_symbol_table
+ (abfd, alocation, true);
+}
+
+/* Return the size required for the dynamic reloc entries. Any
+ section that was actually installed in the BFD, and has type
+ SHT_REL or SHT_RELA, and uses the dynamic symbol table, is
+ considered to be a dynamic reloc section. */
+
+long
+_bfd_elf_get_dynamic_reloc_upper_bound (abfd)
+ bfd *abfd;
+{
+ long ret;
+ asection *s;
+
+ if (elf_dynsymtab (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ ret = sizeof (arelent *);
+ for (s = abfd->sections; s != NULL; s = s->next)
+ if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
+ && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
+ || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
+ ret += ((s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize)
+ * sizeof (arelent *));
+
+ return ret;
+}
+
+/* Canonicalize the dynamic relocation entries. Note that we return
+ the dynamic relocations as a single block, although they are
+ actually associated with particular sections; the interface, which
+ was designed for SunOS style shared libraries, expects that there
+ is only one set of dynamic relocs. Any section that was actually
+ installed in the BFD, and has type SHT_REL or SHT_RELA, and uses
+ the dynamic symbol table, is considered to be a dynamic reloc
+ section. */
+
+long
+_bfd_elf_canonicalize_dynamic_reloc (abfd, storage, syms)
+ bfd *abfd;
+ arelent **storage;
+ asymbol **syms;
+{
+ boolean (*slurp_relocs) PARAMS ((bfd *, asection *, asymbol **, boolean));
+ asection *s;
+ long ret;
+
+ if (elf_dynsymtab (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
+ ret = 0;
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
+ && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
+ || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
+ {
+ arelent *p;
+ long count, i;
+
+ if (! (*slurp_relocs) (abfd, s, syms, true))
+ return -1;
+ count = s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize;
+ p = s->relocation;
+ for (i = 0; i < count; i++)
+ *storage++ = p++;
+ ret += count;
+ }
+ }
+
+ *storage = NULL;
+
+ return ret;
+}
+
+/* Read in the version information. */
+
+boolean
+_bfd_elf_slurp_version_tables (abfd)
+ bfd *abfd;
+{
+ bfd_byte *contents = NULL;
+
+ if (elf_dynverdef (abfd) != 0)
+ {
+ Elf_Internal_Shdr *hdr;
+ Elf_External_Verdef *everdef;
+ Elf_Internal_Verdef *iverdef;
+ unsigned int i;
+
+ hdr = &elf_tdata (abfd)->dynverdef_hdr;
+
+ elf_tdata (abfd)->verdef =
+ ((Elf_Internal_Verdef *)
+ bfd_zalloc (abfd, hdr->sh_info * sizeof (Elf_Internal_Verdef)));
+ if (elf_tdata (abfd)->verdef == NULL)
+ goto error_return;
+
+ elf_tdata (abfd)->cverdefs = hdr->sh_info;
+
+ contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
+ if (contents == NULL)
+ goto error_return;
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
+ || bfd_read ((PTR) contents, 1, hdr->sh_size, abfd) != hdr->sh_size)
+ goto error_return;
+
+ everdef = (Elf_External_Verdef *) contents;
+ iverdef = elf_tdata (abfd)->verdef;
+ for (i = 0; i < hdr->sh_info; i++, iverdef++)
+ {
+ Elf_External_Verdaux *everdaux;
+ Elf_Internal_Verdaux *iverdaux;
+ unsigned int j;
+
+ _bfd_elf_swap_verdef_in (abfd, everdef, iverdef);
+
+ iverdef->vd_bfd = abfd;
+
+ iverdef->vd_auxptr = ((Elf_Internal_Verdaux *)
+ bfd_alloc (abfd,
+ (iverdef->vd_cnt
+ * sizeof (Elf_Internal_Verdaux))));
+ if (iverdef->vd_auxptr == NULL)
+ goto error_return;
+
+ everdaux = ((Elf_External_Verdaux *)
+ ((bfd_byte *) everdef + iverdef->vd_aux));
+ iverdaux = iverdef->vd_auxptr;
+ for (j = 0; j < iverdef->vd_cnt; j++, iverdaux++)
+ {
+ _bfd_elf_swap_verdaux_in (abfd, everdaux, iverdaux);
+
+ iverdaux->vda_nodename =
+ bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
+ iverdaux->vda_name);
+ if (iverdaux->vda_nodename == NULL)
+ goto error_return;
+
+ if (j + 1 < iverdef->vd_cnt)
+ iverdaux->vda_nextptr = iverdaux + 1;
+ else
+ iverdaux->vda_nextptr = NULL;
+
+ everdaux = ((Elf_External_Verdaux *)
+ ((bfd_byte *) everdaux + iverdaux->vda_next));
+ }
+
+ iverdef->vd_nodename = iverdef->vd_auxptr->vda_nodename;
+
+ if (i + 1 < hdr->sh_info)
+ iverdef->vd_nextdef = iverdef + 1;
+ else
+ iverdef->vd_nextdef = NULL;
+
+ everdef = ((Elf_External_Verdef *)
+ ((bfd_byte *) everdef + iverdef->vd_next));
+ }
+
+ free (contents);
+ contents = NULL;
+ }
+
+ if (elf_dynverref (abfd) != 0)
+ {
+ Elf_Internal_Shdr *hdr;
+ Elf_External_Verneed *everneed;
+ Elf_Internal_Verneed *iverneed;
+ unsigned int i;
+
+ hdr = &elf_tdata (abfd)->dynverref_hdr;
+
+ elf_tdata (abfd)->verref =
+ ((Elf_Internal_Verneed *)
+ bfd_zalloc (abfd, hdr->sh_info * sizeof (Elf_Internal_Verneed)));
+ if (elf_tdata (abfd)->verref == NULL)
+ goto error_return;
+
+ elf_tdata (abfd)->cverrefs = hdr->sh_info;
+
+ contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
+ if (contents == NULL)
+ goto error_return;
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
+ || bfd_read ((PTR) contents, 1, hdr->sh_size, abfd) != hdr->sh_size)
+ goto error_return;
+
+ everneed = (Elf_External_Verneed *) contents;
+ iverneed = elf_tdata (abfd)->verref;
+ for (i = 0; i < hdr->sh_info; i++, iverneed++)
+ {
+ Elf_External_Vernaux *evernaux;
+ Elf_Internal_Vernaux *ivernaux;
+ unsigned int j;
+
+ _bfd_elf_swap_verneed_in (abfd, everneed, iverneed);
+
+ iverneed->vn_bfd = abfd;
+
+ iverneed->vn_filename =
+ bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
+ iverneed->vn_file);
+ if (iverneed->vn_filename == NULL)
+ goto error_return;
+
+ iverneed->vn_auxptr =
+ ((Elf_Internal_Vernaux *)
+ bfd_alloc (abfd,
+ iverneed->vn_cnt * sizeof (Elf_Internal_Vernaux)));
+
+ evernaux = ((Elf_External_Vernaux *)
+ ((bfd_byte *) everneed + iverneed->vn_aux));
+ ivernaux = iverneed->vn_auxptr;
+ for (j = 0; j < iverneed->vn_cnt; j++, ivernaux++)
+ {
+ _bfd_elf_swap_vernaux_in (abfd, evernaux, ivernaux);
+
+ ivernaux->vna_nodename =
+ bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
+ ivernaux->vna_name);
+ if (ivernaux->vna_nodename == NULL)
+ goto error_return;
+
+ if (j + 1 < iverneed->vn_cnt)
+ ivernaux->vna_nextptr = ivernaux + 1;
+ else
+ ivernaux->vna_nextptr = NULL;
+
+ evernaux = ((Elf_External_Vernaux *)
+ ((bfd_byte *) evernaux + ivernaux->vna_next));
+ }
+
+ if (i + 1 < hdr->sh_info)
+ iverneed->vn_nextref = iverneed + 1;
+ else
+ iverneed->vn_nextref = NULL;
+
+ everneed = ((Elf_External_Verneed *)
+ ((bfd_byte *) everneed + iverneed->vn_next));
+ }
+
+ free (contents);
+ contents = NULL;
+ }
+
+ return true;
+
+ error_return:
+ if (contents == NULL)
+ free (contents);
+ return false;
+}
+
+asymbol *
+_bfd_elf_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ elf_symbol_type *newsym;
+
+ newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
+ if (!newsym)
+ return NULL;
+ else
+ {
+ newsym->symbol.the_bfd = abfd;
+ return &newsym->symbol;
+ }
+}
+
+void
+_bfd_elf_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+/* Return whether a symbol name implies a local symbol. Most targets
+ use this function for the is_local_label_name entry point, but some
+ override it. */
+
+boolean
+_bfd_elf_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ /* Normal local symbols start with ``.L''. */
+ if (name[0] == '.' && name[1] == 'L')
+ return true;
+
+ /* At least some SVR4 compilers (e.g., UnixWare 2.1 cc) generate
+ DWARF debugging symbols starting with ``..''. */
+ if (name[0] == '.' && name[1] == '.')
+ return true;
+
+ /* gcc will sometimes generate symbols beginning with ``_.L_'' when
+ emitting DWARF debugging output. I suspect this is actually a
+ small bug in gcc (it calls ASM_OUTPUT_LABEL when it should call
+ ASM_GENERATE_INTERNAL_LABEL, and this causes the leading
+ underscore to be emitted on some ELF targets). For ease of use,
+ we treat such symbols as local. */
+ if (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_')
+ return true;
+
+ return false;
+}
+
+alent *
+_bfd_elf_get_lineno (ignore_abfd, symbol)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+{
+ abort ();
+ return NULL;
+}
+
+boolean
+_bfd_elf_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ /* If this isn't the right architecture for this backend, and this
+ isn't the generic backend, fail. */
+ if (arch != get_elf_backend_data (abfd)->arch
+ && arch != bfd_arch_unknown
+ && get_elf_backend_data (abfd)->arch != bfd_arch_unknown)
+ return false;
+
+ return bfd_default_set_arch_mach (abfd, arch, machine);
+}
+
+/* Find the nearest line to a particular section and offset, for error
+ reporting. */
+
+boolean
+_bfd_elf_find_nearest_line (abfd,
+ section,
+ symbols,
+ offset,
+ filename_ptr,
+ functionname_ptr,
+ line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ boolean found;
+ const char *filename;
+ asymbol *func;
+ bfd_vma low_func;
+ asymbol **p;
+
+ if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ return true;
+
+ if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ return true;
+
+ if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+ &found, filename_ptr,
+ functionname_ptr, line_ptr,
+ &elf_tdata (abfd)->line_info))
+ return false;
+ if (found)
+ return true;
+
+ if (symbols == NULL)
+ return false;
+
+ filename = NULL;
+ func = NULL;
+ low_func = 0;
+
+ for (p = symbols; *p != NULL; p++)
+ {
+ elf_symbol_type *q;
+
+ q = (elf_symbol_type *) *p;
+
+ if (bfd_get_section (&q->symbol) != section)
+ continue;
+
+ switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
+ {
+ default:
+ break;
+ case STT_FILE:
+ filename = bfd_asymbol_name (&q->symbol);
+ break;
+ case STT_NOTYPE:
+ case STT_FUNC:
+ if (q->symbol.section == section
+ && q->symbol.value >= low_func
+ && q->symbol.value <= offset)
+ {
+ func = (asymbol *) q;
+ low_func = q->symbol.value;
+ }
+ break;
+ }
+ }
+
+ if (func == NULL)
+ return false;
+
+ *filename_ptr = filename;
+ *functionname_ptr = bfd_asymbol_name (func);
+ *line_ptr = 0;
+ return true;
+}
+
+int
+_bfd_elf_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+ int ret;
+
+ ret = get_elf_backend_data (abfd)->s->sizeof_ehdr;
+ if (! reloc)
+ ret += get_program_header_size (abfd);
+ return ret;
+}
+
+boolean
+_bfd_elf_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ Elf_Internal_Shdr *hdr;
+
+ if (! abfd->output_has_begun
+ && ! _bfd_elf_compute_section_file_positions
+ (abfd, (struct bfd_link_info *) NULL))
+ return false;
+
+ hdr = &elf_section_data (section)->this_hdr;
+
+ if (bfd_seek (abfd, hdr->sh_offset + offset, SEEK_SET) == -1)
+ return false;
+ if (bfd_write (location, 1, count, abfd) != count)
+ return false;
+
+ return true;
+}
+
+void
+_bfd_elf_no_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf_Internal_Rela *dst;
+{
+ abort ();
+}
+
+#if 0
+void
+_bfd_elf_no_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf_Internal_Rel *dst;
+{
+ abort ();
+}
+#endif
+
+/* Try to convert a non-ELF reloc into an ELF one. */
+
+boolean
+_bfd_elf_validate_reloc (abfd, areloc)
+ bfd *abfd;
+ arelent *areloc;
+{
+ /* Check whether we really have an ELF howto. */
+
+ if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec)
+ {
+ bfd_reloc_code_real_type code;
+ reloc_howto_type *howto;
+
+ /* Alien reloc: Try to determine its type to replace it with an
+ equivalent ELF reloc. */
+
+ if (areloc->howto->pc_relative)
+ {
+ switch (areloc->howto->bitsize)
+ {
+ case 8:
+ code = BFD_RELOC_8_PCREL;
+ break;
+ case 12:
+ code = BFD_RELOC_12_PCREL;
+ break;
+ case 16:
+ code = BFD_RELOC_16_PCREL;
+ break;
+ case 24:
+ code = BFD_RELOC_24_PCREL;
+ break;
+ case 32:
+ code = BFD_RELOC_32_PCREL;
+ break;
+ case 64:
+ code = BFD_RELOC_64_PCREL;
+ break;
+ default:
+ goto fail;
+ }
+
+ howto = bfd_reloc_type_lookup (abfd, code);
+
+ if (areloc->howto->pcrel_offset != howto->pcrel_offset)
+ {
+ if (howto->pcrel_offset)
+ areloc->addend += areloc->address;
+ else
+ areloc->addend -= areloc->address; /* addend is unsigned!! */
+ }
+ }
+ else
+ {
+ switch (areloc->howto->bitsize)
+ {
+ case 8:
+ code = BFD_RELOC_8;
+ break;
+ case 14:
+ code = BFD_RELOC_14;
+ break;
+ case 16:
+ code = BFD_RELOC_16;
+ break;
+ case 26:
+ code = BFD_RELOC_26;
+ break;
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ case 64:
+ code = BFD_RELOC_64;
+ break;
+ default:
+ goto fail;
+ }
+
+ howto = bfd_reloc_type_lookup (abfd, code);
+ }
+
+ if (howto)
+ areloc->howto = howto;
+ else
+ goto fail;
+ }
+
+ return true;
+
+ fail:
+ (*_bfd_error_handler)
+ (_("%s: unsupported relocation type %s"),
+ bfd_get_filename (abfd), areloc->howto->name);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+}
+
+boolean
+_bfd_elf_close_and_cleanup (abfd)
+ bfd *abfd;
+{
+ if (bfd_get_format (abfd) == bfd_object)
+ {
+ if (elf_shstrtab (abfd) != NULL)
+ _bfd_stringtab_free (elf_shstrtab (abfd));
+ }
+
+ return _bfd_generic_close_and_cleanup (abfd);
+}
+
+/* For Rel targets, we encode meaningful data for BFD_RELOC_VTABLE_ENTRY
+ in the relocation's offset. Thus we cannot allow any sort of sanity
+ range-checking to interfere. There is nothing else to do in processing
+ this reloc. */
+
+bfd_reloc_status_type
+_bfd_elf_rel_vtable_reloc_fn (abfd, re, symbol, data, is, obfd, errmsg)
+ bfd *abfd;
+ arelent *re;
+ struct symbol_cache_entry *symbol;
+ PTR data;
+ asection *is;
+ bfd *obfd;
+ char **errmsg;
+{
+ return bfd_reloc_ok;
+}
+
+
+/* Elf core file support. Much of this only works on native
+ toolchains, since we rely on knowing the
+ machine-dependent procfs structure in order to pick
+ out details about the corefile. */
+
+#ifdef HAVE_SYS_PROCFS_H
+# include <sys/procfs.h>
+#endif
+
+
+/* Define offsetof for those systems which lack it. */
+
+#ifndef offsetof
+# define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
+#endif
+
+
+/* FIXME: this is kinda wrong, but it's what gdb wants. */
+
+static int
+elfcore_make_pid (abfd)
+ bfd* abfd;
+{
+ return ((elf_tdata (abfd)->core_lwpid << 16)
+ + (elf_tdata (abfd)->core_pid));
+}
+
+
+/* If there isn't a section called NAME, make one, using
+ data from SECT. Note, this function will generate a
+ reference to NAME, so you shouldn't deallocate or
+ overwrite it. */
+
+static boolean
+elfcore_maybe_make_sect (abfd, name, sect)
+ bfd* abfd;
+ char* name;
+ asection* sect;
+{
+ asection* sect2;
+
+ if (bfd_get_section_by_name (abfd, name) != NULL)
+ return true;
+
+ sect2 = bfd_make_section (abfd, name);
+ if (sect2 == NULL)
+ return false;
+
+ sect2->_raw_size = sect->_raw_size;
+ sect2->filepos = sect->filepos;
+ sect2->flags = sect->flags;
+ sect2->alignment_power = sect->alignment_power;
+ return true;
+}
+
+
+/* prstatus_t exists on:
+ solaris 2.[567]
+ linux 2.[01] + glibc
+ unixware 4.2
+*/
+
+#if defined (HAVE_PRSTATUS_T)
+static boolean
+elfcore_grok_prstatus (abfd, note)
+ bfd* abfd;
+ Elf_Internal_Note* note;
+{
+ prstatus_t prstat;
+ char buf[100];
+ char* name;
+ asection* sect;
+
+ if (note->descsz != sizeof (prstat))
+ return true;
+
+ memcpy (&prstat, note->descdata, sizeof (prstat));
+
+ elf_tdata (abfd)->core_signal = prstat.pr_cursig;
+ elf_tdata (abfd)->core_pid = prstat.pr_pid;
+
+ /* pr_who exists on:
+ solaris 2.[567]
+ unixware 4.2
+ pr_who doesn't exist on:
+ linux 2.[01]
+ */
+#if defined (HAVE_PRSTATUS_T_PR_WHO)
+ elf_tdata (abfd)->core_lwpid = prstat.pr_who;
+#endif
+
+ /* Make a ".reg/999" section. */
+
+ sprintf (buf, ".reg/%d", elfcore_make_pid (abfd));
+ name = bfd_alloc (abfd, strlen (buf) + 1);
+ if (name == NULL)
+ return false;
+ strcpy (name, buf);
+
+ sect = bfd_make_section (abfd, name);
+ if (sect == NULL)
+ return false;
+ sect->_raw_size = sizeof (prstat.pr_reg);
+ sect->filepos = note->descpos + offsetof (prstatus_t, pr_reg);
+ sect->flags = SEC_HAS_CONTENTS;
+ sect->alignment_power = 2;
+
+ if (! elfcore_maybe_make_sect (abfd, ".reg", sect))
+ return false;
+
+ return true;
+}
+#endif /* defined (HAVE_PRSTATUS_T) */
+
+
+/* There isn't a consistent prfpregset_t across platforms,
+ but it doesn't matter, because we don't have to pick this
+ data structure apart. */
+
+static boolean
+elfcore_grok_prfpreg (abfd, note)
+ bfd* abfd;
+ Elf_Internal_Note* note;
+{
+ char buf[100];
+ char* name;
+ asection* sect;
+
+ /* Make a ".reg2/999" section. */
+
+ sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd));
+ name = bfd_alloc (abfd, strlen (buf) + 1);
+ if (name == NULL)
+ return false;
+ strcpy (name, buf);
+
+ sect = bfd_make_section (abfd, name);
+ if (sect == NULL)
+ return false;
+ sect->_raw_size = note->descsz;
+ sect->filepos = note->descpos;
+ sect->flags = SEC_HAS_CONTENTS;
+ sect->alignment_power = 2;
+
+ if (! elfcore_maybe_make_sect (abfd, ".reg2", sect))
+ return false;
+
+ return true;
+}
+
+#if defined (HAVE_PRPSINFO_T)
+# define elfcore_psinfo_t prpsinfo_t
+#endif
+
+#if defined (HAVE_PSINFO_T)
+# define elfcore_psinfo_t psinfo_t
+#endif
+
+
+#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
+
+/* return a malloc'ed copy of a string at START which is at
+ most MAX bytes long, possibly without a terminating '\0'.
+ the copy will always have a terminating '\0'. */
+
+static char*
+elfcore_strndup (abfd, start, max)
+ bfd* abfd;
+ char* start;
+ int max;
+{
+ char* dup;
+ char* end = memchr (start, '\0', max);
+ int len;
+
+ if (end == NULL)
+ len = max;
+ else
+ len = end - start;
+
+ dup = bfd_alloc (abfd, len + 1);
+ if (dup == NULL)
+ return NULL;
+
+ memcpy (dup, start, len);
+ dup[len] = '\0';
+
+ return dup;
+}
+
+static boolean
+elfcore_grok_psinfo (abfd, note)
+ bfd* abfd;
+ Elf_Internal_Note* note;
+{
+ elfcore_psinfo_t psinfo;
+
+ if (note->descsz != sizeof (elfcore_psinfo_t))
+ return true;
+
+ memcpy (&psinfo, note->descdata, note->descsz);
+
+ elf_tdata (abfd)->core_program
+ = elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname));
+
+ elf_tdata (abfd)->core_command
+ = elfcore_strndup (abfd, psinfo.pr_psargs, sizeof (psinfo.pr_psargs));
+
+ /* Note that for some reason, a spurious space is tacked
+ onto the end of the args in some (at least one anyway)
+ implementations, so strip it off if it exists. */
+
+ {
+ char* command = elf_tdata (abfd)->core_command;
+ int n = strlen (command);
+
+ if (0 < n && command[n - 1] == ' ')
+ command[n - 1] = '\0';
+ }
+
+ return true;
+}
+#endif /* defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) */
+
+
+#if defined (HAVE_PSTATUS_T)
+static boolean
+elfcore_grok_pstatus (abfd, note)
+ bfd* abfd;
+ Elf_Internal_Note* note;
+{
+ pstatus_t pstat;
+
+ if (note->descsz != sizeof (pstat))
+ return true;
+
+ memcpy (&pstat, note->descdata, sizeof (pstat));
+
+ elf_tdata (abfd)->core_pid = pstat.pr_pid;
+
+ /* Could grab some more details from the "representative"
+ lwpstatus_t in pstat.pr_lwp, but we'll catch it all in an
+ NT_LWPSTATUS note, presumably. */
+
+ return true;
+}
+#endif /* defined (HAVE_PSTATUS_T) */
+
+
+#if defined (HAVE_LWPSTATUS_T)
+static boolean
+elfcore_grok_lwpstatus (abfd, note)
+ bfd* abfd;
+ Elf_Internal_Note* note;
+{
+ lwpstatus_t lwpstat;
+ char buf[100];
+ char* name;
+ asection* sect;
+
+ if (note->descsz != sizeof (lwpstat))
+ return true;
+
+ memcpy (&lwpstat, note->descdata, sizeof (lwpstat));
+
+ elf_tdata (abfd)->core_lwpid = lwpstat.pr_lwpid;
+ elf_tdata (abfd)->core_signal = lwpstat.pr_cursig;
+
+ /* Make a ".reg/999" section. */
+
+ sprintf (buf, ".reg/%d", elfcore_make_pid (abfd));
+ name = bfd_alloc (abfd, strlen (buf) + 1);
+ if (name == NULL)
+ return false;
+ strcpy (name, buf);
+
+ sect = bfd_make_section (abfd, name);
+ if (sect == NULL)
+ return false;
+
+#if defined (HAVE_LWPSTATUS_T_PR_CONTEXT)
+ sect->_raw_size = sizeof (lwpstat.pr_context.uc_mcontext.gregs);
+ sect->filepos = note->descpos
+ + offsetof (lwpstatus_t, pr_context.uc_mcontext.gregs);
+#endif
+
+#if defined (HAVE_LWPSTATUS_T_PR_REG)
+ sect->_raw_size = sizeof (lwpstat.pr_reg);
+ sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_reg);
+#endif
+
+ sect->flags = SEC_HAS_CONTENTS;
+ sect->alignment_power = 2;
+
+ if (!elfcore_maybe_make_sect (abfd, ".reg", sect))
+ return false;
+
+ /* Make a ".reg2/999" section */
+
+ sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd));
+ name = bfd_alloc (abfd, strlen (buf) + 1);
+ if (name == NULL)
+ return false;
+ strcpy (name, buf);
+
+ sect = bfd_make_section (abfd, name);
+ if (sect == NULL)
+ return false;
+
+#if defined (HAVE_LWPSTATUS_T_PR_CONTEXT)
+ sect->_raw_size = sizeof (lwpstat.pr_context.uc_mcontext.fpregs);
+ sect->filepos = note->descpos
+ + offsetof (lwpstatus_t, pr_context.uc_mcontext.fpregs);
+#endif
+
+#if defined (HAVE_LWPSTATUS_T_PR_FPREG)
+ sect->_raw_size = sizeof (lwpstat.pr_fpreg);
+ sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_fpreg);
+#endif
+
+ sect->flags = SEC_HAS_CONTENTS;
+ sect->alignment_power = 2;
+
+ if (!elfcore_maybe_make_sect (abfd, ".reg2", sect))
+ return false;
+
+ return true;
+}
+#endif /* defined (HAVE_LWPSTATUS_T) */
+
+
+
+static boolean
+elfcore_grok_note (abfd, note)
+ bfd* abfd;
+ Elf_Internal_Note* note;
+{
+ switch (note->type)
+ {
+ default:
+ return true;
+
+#if defined (HAVE_PRSTATUS_T)
+ case NT_PRSTATUS:
+ return elfcore_grok_prstatus (abfd, note);
+#endif
+
+#if defined (HAVE_PSTATUS_T)
+ case NT_PSTATUS:
+ return elfcore_grok_pstatus (abfd, note);
+#endif
+
+#if defined (HAVE_LWPSTATUS_T)
+ case NT_LWPSTATUS:
+ return elfcore_grok_lwpstatus (abfd, note);
+#endif
+
+ case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG */
+ return elfcore_grok_prfpreg (abfd, note);
+
+#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
+ case NT_PRPSINFO:
+ case NT_PSINFO:
+ return elfcore_grok_psinfo (abfd, note);
+#endif
+ }
+}
+
+
+static boolean
+elfcore_read_notes (abfd, offset, size)
+ bfd* abfd;
+ bfd_vma offset;
+ bfd_vma size;
+{
+ char* buf;
+ char* p;
+
+ if (size <= 0)
+ return true;
+
+ if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ return false;
+
+ buf = bfd_malloc ((size_t) size);
+ if (buf == NULL)
+ return false;
+
+ if (bfd_read (buf, size, 1, abfd) != size)
+ {
+ error:
+ free (buf);
+ return false;
+ }
+
+ p = buf;
+ while (p < buf + size)
+ {
+ /* FIXME: bad alignment assumption. */
+ Elf_External_Note* xnp = (Elf_External_Note*) p;
+ Elf_Internal_Note in;
+
+ in.type = bfd_h_get_32 (abfd, (bfd_byte *) xnp->type);
+
+ in.namesz = bfd_h_get_32 (abfd, (bfd_byte *) xnp->namesz);
+ in.namedata = xnp->name;
+
+ in.descsz = bfd_h_get_32 (abfd, (bfd_byte *) xnp->descsz);
+ in.descdata = in.namedata + BFD_ALIGN (in.namesz, 4);
+ in.descpos = offset + (in.descdata - buf);
+
+ if (! elfcore_grok_note (abfd, &in))
+ goto error;
+
+ p = in.descdata + BFD_ALIGN (in.descsz, 4);
+ }
+
+ free (buf);
+ return true;
+}
+
+
+
+boolean
+_bfd_elfcore_section_from_phdr (abfd, phdr, sec_num)
+ bfd* abfd;
+ Elf_Internal_Phdr* phdr;
+ int sec_num;
+{
+ if (! bfd_section_from_phdr (abfd, phdr, sec_num))
+ return false;
+
+ if (phdr->p_type == PT_NOTE
+ && ! elfcore_read_notes (abfd, phdr->p_offset, phdr->p_filesz))
+ return false;
+
+ return true;
+}
+
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
new file mode 100644
index 00000000000..a490a246b07
--- /dev/null
+++ b/bfd/elf32-arc.c
@@ -0,0 +1,213 @@
+/* ARC-specific support for 32-bit ELF
+ Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ Contributed by Doug Evans (dje@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/arc.h"
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void arc_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+static boolean arc_elf_object_p PARAMS ((bfd *));
+static void arc_elf_final_write_processing PARAMS ((bfd *, boolean));
+
+/* Try to minimize the amount of space occupied by relocation tables
+ on the ROM (not that the ROM won't be swamped by other ELF overhead). */
+#define USE_REL
+
+static reloc_howto_type elf_arc_howto_table[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_ARC_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARC_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A standard 32 bit relocation. */
+ HOWTO (R_ARC_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARC_32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 26 bit absolute branch, right shifted by 2. */
+ HOWTO (R_ARC_B26, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARC_B26", /* name */
+ false, /* partial_inplace */
+ 0x00ffffff, /* src_mask */
+ 0x00ffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 22 bit branch; bits 21-2 are stored in bits 26-7. */
+ HOWTO (R_ARC_B22_PCREL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 22, /* bitsize */
+ true, /* pc_relative */
+ 7, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARC_B22_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x07ffff80, /* src_mask */
+ 0x07ffff80, /* dst_mask */
+ true), /* pcrel_offset */
+
+};
+
+/* Map BFD reloc types to ARC ELF reloc types. */
+
+struct arc_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static const struct arc_reloc_map arc_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_ARC_NONE, },
+ { BFD_RELOC_32, R_ARC_32 },
+ { BFD_RELOC_CTOR, R_ARC_32 },
+ { BFD_RELOC_ARC_B26, R_ARC_B26 },
+ { BFD_RELOC_ARC_B22_PCREL, R_ARC_B22_PCREL },
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (arc_reloc_map) / sizeof (struct arc_reloc_map);
+ i++)
+ {
+ if (arc_reloc_map[i].bfd_reloc_val == code)
+ return &elf_arc_howto_table[arc_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Set the howto pointer for an ARC ELF reloc. */
+
+static void
+arc_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rel *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_ARC_max);
+ cache_ptr->howto = &elf_arc_howto_table[r_type];
+}
+
+/* Set the right machine number for an ARC ELF file. */
+
+static boolean
+arc_elf_object_p (abfd)
+ bfd *abfd;
+{
+ int mach;
+ unsigned long arch = elf_elfheader (abfd)->e_flags & EF_ARC_MACH;
+
+ switch (arch)
+ {
+ case E_ARC_MACH_BASE:
+ mach = bfd_mach_arc_base;
+ break;
+ default:
+ /* Unknown cpu type. ??? What to do? */
+ return false;
+ }
+
+ (void) bfd_default_set_arch_mach (abfd, bfd_arch_arc, mach);
+ return true;
+}
+
+/* The final processing done just before writing out an ARC ELF object file.
+ This gets the ARC architecture right based on the machine number. */
+
+static void
+arc_elf_final_write_processing (abfd, linker)
+ bfd *abfd;
+ boolean linker;
+{
+ int mach;
+ unsigned long val;
+
+ switch (mach = bfd_get_mach (abfd))
+ {
+ case bfd_mach_arc_base:
+ val = E_ARC_MACH_BASE;
+ break;
+ default:
+ return;
+ }
+
+ elf_elfheader (abfd)->e_flags &=~ EF_ARC_MACH;
+ elf_elfheader (abfd)->e_flags |= val;
+}
+
+#define TARGET_LITTLE_SYM bfd_elf32_littlearc_vec
+#define TARGET_LITTLE_NAME "elf32-littlearc"
+#define TARGET_BIG_SYM bfd_elf32_bigarc_vec
+#define TARGET_BIG_NAME "elf32-bigarc"
+#define ELF_ARCH bfd_arch_arc
+#define ELF_MACHINE_CODE EM_CYGNUS_ARC
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_info_to_howto 0
+#define elf_info_to_howto_rel arc_info_to_howto_rel
+#define elf_backend_object_p arc_elf_object_p
+#define elf_backend_final_write_processing \
+ arc_elf_final_write_processing
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
new file mode 100644
index 00000000000..d4e97d6b9bf
--- /dev/null
+++ b/bfd/elf32-arm.h
@@ -0,0 +1,3010 @@
+/* 32-bit ELF support for ARM
+ Copyright 1998, 1999 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+typedef unsigned long int insn32;
+typedef unsigned short int insn16;
+
+static boolean elf32_arm_set_private_flags
+ PARAMS ((bfd *, flagword));
+static boolean elf32_arm_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean elf32_arm_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean elf32_arm_print_private_bfd_data
+ PARAMS ((bfd *, PTR));
+static int elf32_arm_get_symbol_type
+ PARAMS (( Elf_Internal_Sym *, int));
+static struct bfd_link_hash_table *elf32_arm_link_hash_table_create
+ PARAMS ((bfd *));
+static bfd_reloc_status_type elf32_arm_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma, struct bfd_link_info *, asection *, const char *, unsigned char));
+
+static insn32 insert_thumb_branch
+ PARAMS ((insn32, int));
+static struct elf_link_hash_entry *find_thumb_glue
+ PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
+static struct elf_link_hash_entry *find_arm_glue
+ PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
+static void record_arm_to_thumb_glue
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static void record_thumb_to_arm_glue
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+
+/* The linker script knows the section names for placement.
+ The entry_names are used to do simple name mangling on the stubs.
+ Given a function name, and its type, the stub can be found. The
+ name can be changed. The only requirement is the %s be present.
+ */
+
+#define INTERWORK_FLAG( abfd ) (elf_elfheader (abfd)->e_flags & EF_INTERWORK)
+
+#define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t"
+#define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb"
+
+#define ARM2THUMB_GLUE_SECTION_NAME ".glue_7"
+#define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm"
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+
+/* The size in bytes of an entry in the procedure linkage table. */
+
+#define PLT_ENTRY_SIZE 16
+
+/* The first entry in a procedure linkage table looks like
+ this. It is set up so that any shared library function that is
+ called before the relocation has been set up calles the dynamic
+ linker first */
+
+static const bfd_byte elf32_arm_plt0_entry [PLT_ENTRY_SIZE] =
+{
+ 0x04, 0xe0, 0x2d, 0xe5, /* str lr, [sp, #-4]! */
+ 0x10, 0xe0, 0x9f, 0xe5, /* ldr lr, [pc, #16] */
+ 0x0e, 0xe0, 0x8f, 0xe0, /* adr lr, pc, lr */
+ 0x08, 0xf0, 0xbe, 0xe5 /* ldr pc, [lr, #-4] */
+};
+
+/* Subsequent entries in a procedure linkage table look like
+ this. */
+
+static const bfd_byte elf32_arm_plt_entry [PLT_ENTRY_SIZE] =
+{
+ 0x04, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc, #4] */
+ 0x0c, 0xc0, 0x8f, 0xe0, /* add ip, pc, ip */
+ 0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */
+ 0x00, 0x00, 0x00, 0x00 /* offset to symbol in got */
+};
+
+
+/* The ARM linker needs to keep track of the number of relocs that it
+ decides to copy in check_relocs for each symbol. This is so that
+ it can discard PC relative relocs if it doesn't need them when
+ linking with -Bsymbolic. We store the information in a field
+ extending the regular ELF linker hash table. */
+
+/* This structure keeps track of the number of PC relative relocs we
+ have copied for a given symbol. */
+
+struct elf32_arm_pcrel_relocs_copied
+{
+ /* Next section. */
+ struct elf32_arm_pcrel_relocs_copied * next;
+ /* A section in dynobj. */
+ asection * section;
+ /* Number of relocs copied in this section. */
+ bfd_size_type count;
+};
+
+/* arm ELF linker hash entry. */
+
+struct elf32_arm_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* Number of PC relative relocs copied for this symbol. */
+ struct elf32_arm_pcrel_relocs_copied * pcrel_relocs_copied;
+};
+
+/* Declare this now that the above structures are defined. */
+
+static boolean elf32_arm_discard_copies
+ PARAMS ((struct elf32_arm_link_hash_entry *, PTR));
+
+/* Traverse an arm ELF linker hash table. */
+
+#define elf32_arm_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the ARM elf linker hash table from a link_info structure. */
+#define elf32_arm_hash_table(info) \
+ ((struct elf32_arm_link_hash_table *) ((info)->hash))
+
+/* ARM ELF linker hash table */
+struct elf32_arm_link_hash_table
+ {
+ /* The main hash table. */
+ struct elf_link_hash_table root;
+
+ /* The size in bytes of the section containg the Thumb-to-ARM glue. */
+ long int thumb_glue_size;
+
+ /* The size in bytes of the section containg the ARM-to-Thumb glue. */
+ long int arm_glue_size;
+
+ /* An arbitary input BFD chosen to hold the glue sections. */
+ bfd * bfd_of_glue_owner;
+ };
+
+
+/* Create an ARM elf linker hash table */
+
+static struct bfd_link_hash_table *
+elf32_arm_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf32_arm_link_hash_table *ret;
+
+ ret = ((struct elf32_arm_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf32_arm_link_hash_table)));
+ if (ret == (struct elf32_arm_link_hash_table *) NULL)
+ return NULL;
+
+ if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+ _bfd_elf_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ ret->thumb_glue_size = 0;
+ ret->arm_glue_size = 0;
+ ret->bfd_of_glue_owner = NULL;
+
+ return &ret->root.root;
+}
+
+static struct elf_link_hash_entry *
+find_thumb_glue (link_info, name, input_bfd)
+ struct bfd_link_info *link_info;
+ CONST char *name;
+ bfd *input_bfd;
+{
+ char *tmp_name;
+ struct elf_link_hash_entry *hash;
+ struct elf32_arm_link_hash_table *hash_table;
+
+ /* We need a pointer to the armelf specific hash table. */
+ hash_table = elf32_arm_hash_table (link_info);
+
+
+ tmp_name = ((char *)
+ bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1));
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name);
+
+ hash = elf_link_hash_lookup
+ (&(hash_table)->root, tmp_name, false, false, true);
+
+ if (hash == NULL)
+ /* xgettext:c-format */
+ _bfd_error_handler (_ ("%s: unable to find THUMB glue '%s' for `%s'"),
+ bfd_get_filename (input_bfd), tmp_name, name);
+
+ free (tmp_name);
+
+ return hash;
+}
+
+static struct elf_link_hash_entry *
+find_arm_glue (link_info, name, input_bfd)
+ struct bfd_link_info *link_info;
+ CONST char *name;
+ bfd *input_bfd;
+{
+ char *tmp_name;
+ struct elf_link_hash_entry *myh;
+ struct elf32_arm_link_hash_table *hash_table;
+
+ /* We need a pointer to the elfarm specific hash table. */
+ hash_table = elf32_arm_hash_table (link_info);
+
+ tmp_name = ((char *)
+ bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name);
+
+ myh = elf_link_hash_lookup
+ (&(hash_table)->root, tmp_name, false, false, true);
+
+ if (myh == NULL)
+ /* xgettext:c-format */
+ _bfd_error_handler (_ ("%s: unable to find ARM glue '%s' for `%s'"),
+ bfd_get_filename (input_bfd), tmp_name, name);
+
+ free (tmp_name);
+
+ return myh;
+}
+
+/*
+ ARM->Thumb glue:
+
+ .arm
+ __func_from_arm:
+ ldr r12, __func_addr
+ bx r12
+ __func_addr:
+ .word func @ behave as if you saw a ARM_32 reloc
+ */
+
+#define ARM2THUMB_GLUE_SIZE 12
+static const insn32 a2t1_ldr_insn = 0xe59fc000;
+static const insn32 a2t2_bx_r12_insn = 0xe12fff1c;
+static const insn32 a2t3_func_addr_insn = 0x00000001;
+
+/*
+ Thumb->ARM: Thumb->(non-interworking aware) ARM
+
+ .thumb .thumb
+ .align 2 .align 2
+ __func_from_thumb: __func_from_thumb:
+ bx pc push {r6, lr}
+ nop ldr r6, __func_addr
+ .arm mov lr, pc
+ __func_change_to_arm: bx r6
+ b func .arm
+ __func_back_to_thumb:
+ ldmia r13! {r6, lr}
+ bx lr
+ __func_addr:
+ .word func
+ */
+
+#define THUMB2ARM_GLUE_SIZE 8
+static const insn16 t2a1_bx_pc_insn = 0x4778;
+static const insn16 t2a2_noop_insn = 0x46c0;
+static const insn32 t2a3_b_insn = 0xea000000;
+
+static const insn16 t2a1_push_insn = 0xb540;
+static const insn16 t2a2_ldr_insn = 0x4e03;
+static const insn16 t2a3_mov_insn = 0x46fe;
+static const insn16 t2a4_bx_insn = 0x4730;
+static const insn32 t2a5_pop_insn = 0xe8bd4040;
+static const insn32 t2a6_bx_insn = 0xe12fff1e;
+
+boolean
+bfd_elf32_arm_allocate_interworking_sections (info)
+ struct bfd_link_info * info;
+{
+ asection * s;
+ bfd_byte * foo;
+ struct elf32_arm_link_hash_table * globals;
+
+ globals = elf32_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+
+ if (globals->arm_glue_size != 0)
+ {
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ foo = (bfd_byte *) bfd_alloc
+ (globals->bfd_of_glue_owner, globals->arm_glue_size);
+
+ s->_raw_size = s->_cooked_size = globals->arm_glue_size;
+ s->contents = foo;
+ }
+
+ if (globals->thumb_glue_size != 0)
+ {
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ foo = (bfd_byte *) bfd_alloc
+ (globals->bfd_of_glue_owner, globals->thumb_glue_size);
+
+ s->_raw_size = s->_cooked_size = globals->thumb_glue_size;
+ s->contents = foo;
+ }
+
+ return true;
+}
+
+static void
+record_arm_to_thumb_glue (link_info, h)
+ struct bfd_link_info * link_info;
+ struct elf_link_hash_entry * h;
+{
+ const char * name = h->root.root.string;
+ register asection * s;
+ char * tmp_name;
+ struct elf_link_hash_entry * myh;
+ struct elf32_arm_link_hash_table * globals;
+
+ globals = elf32_arm_hash_table (link_info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
+
+
+ BFD_ASSERT (s != NULL);
+
+ tmp_name = ((char *)
+ bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name);
+
+ myh = elf_link_hash_lookup
+ (&(globals)->root, tmp_name, false, false, true);
+
+ if (myh != NULL)
+ {
+ free (tmp_name);
+ return; /* we've already seen this guy */
+ }
+
+ /* The only trick here is using hash_table->arm_glue_size as the value. Even
+ though the section isn't allocated yet, this is where we will be putting
+ it. */
+
+ _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_GLOBAL,
+ s, globals->arm_glue_size + 1,
+ NULL, true, false,
+ (struct bfd_link_hash_entry **) &myh);
+
+ free (tmp_name);
+
+ globals->arm_glue_size += ARM2THUMB_GLUE_SIZE;
+
+ return;
+}
+
+static void
+record_thumb_to_arm_glue (link_info, h)
+ struct bfd_link_info *link_info;
+ struct elf_link_hash_entry *h;
+{
+ const char *name = h->root.root.string;
+ register asection *s;
+ char *tmp_name;
+ struct elf_link_hash_entry *myh;
+ struct elf32_arm_link_hash_table *hash_table;
+ char bind;
+
+ hash_table = elf32_arm_hash_table (link_info);
+
+ BFD_ASSERT (hash_table != NULL);
+ BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL);
+
+ s = bfd_get_section_by_name
+ (hash_table->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+
+ tmp_name = (char *) bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name);
+
+ myh = elf_link_hash_lookup
+ (&(hash_table)->root, tmp_name, false, false, true);
+
+ if (myh != NULL)
+ {
+ free (tmp_name);
+ return; /* we've already seen this guy */
+ }
+
+ _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, tmp_name,
+ BSF_GLOBAL, s, hash_table->thumb_glue_size + 1,
+ NULL, true, false,
+ (struct bfd_link_hash_entry **) &myh);
+
+ /* If we mark it 'thumb', the disassembler will do a better job. */
+ bind = ELF_ST_BIND (myh->type);
+ myh->type = ELF_ST_INFO (bind, STT_ARM_TFUNC);
+
+ free (tmp_name);
+
+ /* Allocate another symbol to mark where we switch to arm mode. */
+
+#define CHANGE_TO_ARM "__%s_change_to_arm"
+#define BACK_FROM_ARM "__%s_back_from_arm"
+
+ tmp_name = (char *) bfd_malloc (strlen (name) + strlen (CHANGE_TO_ARM) + 1);
+
+ BFD_ASSERT (tmp_name);
+
+ sprintf (tmp_name, CHANGE_TO_ARM, name);
+
+ myh = NULL;
+
+ _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, tmp_name,
+ BSF_LOCAL, s, hash_table->thumb_glue_size + 4,
+ NULL, true, false,
+ (struct bfd_link_hash_entry **) &myh);
+
+ free (tmp_name);
+
+ hash_table->thumb_glue_size += THUMB2ARM_GLUE_SIZE;
+
+ return;
+}
+
+/* Select a BFD to be used to hold the sections used by the glue code.
+ This function is called from the linker scripts in ld/emultempl/
+ {armelf/pe}.em */
+boolean
+bfd_elf32_arm_get_bfd_for_interworking (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ struct elf32_arm_link_hash_table *globals;
+ flagword flags;
+ asection *sec;
+
+ /* If we are only performing a partial link do not bother
+ getting a bfd to hold the glue. */
+ if (info->relocateable)
+ return true;
+
+ globals = elf32_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+
+ if (globals->bfd_of_glue_owner != NULL)
+ return true;
+
+ sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME);
+
+ if (sec == NULL)
+ {
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME);
+
+ if (sec == NULL
+ || !bfd_set_section_flags (abfd, sec, flags)
+ || !bfd_set_section_alignment (abfd, sec, 2))
+ return false;
+ }
+
+ sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME);
+
+ if (sec == NULL)
+ {
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME);
+
+ if (sec == NULL
+ || !bfd_set_section_flags (abfd, sec, flags)
+ || !bfd_set_section_alignment (abfd, sec, 2))
+ return false;
+ }
+
+ /* Save the bfd for later use. */
+ globals->bfd_of_glue_owner = abfd;
+
+ return true;
+}
+
+boolean
+bfd_elf32_arm_process_before_allocation (abfd, link_info)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *free_relocs = NULL;
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+ Elf32_External_Sym *extsyms = NULL;
+ Elf32_External_Sym *free_extsyms = NULL;
+
+ asection *sec;
+ struct elf32_arm_link_hash_table *globals;
+
+ /* If we are only performing a partial link do not bother
+ to construct any glue. */
+ if (link_info->relocateable)
+ return true;
+
+ /* Here we have a bfd that is to be included on the link. We have a hook
+ to do reloc rummaging, before section sizes are nailed down. */
+
+ globals = elf32_arm_hash_table (link_info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ /* Rummage around all the relocs and map the glue vectors. */
+ sec = abfd->sections;
+
+ if (sec == NULL)
+ return true;
+
+ for (; sec != NULL; sec = sec->next)
+ {
+ if (sec->reloc_count == 0)
+ continue;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ /* Load the relocs. */
+
+ irel = (_bfd_elf32_link_read_relocs (abfd, sec, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL, false));
+
+ BFD_ASSERT (irel != 0);
+
+ irelend = irel + sec->reloc_count;
+ for (; irel < irelend; irel++)
+ {
+ long r_type;
+ unsigned long r_index;
+ unsigned char code;
+
+ struct elf_link_hash_entry *h;
+
+ r_type = ELF32_R_TYPE (irel->r_info);
+ r_index = ELF32_R_SYM (irel->r_info);
+
+ /* These are the only relocation types we care about */
+ if (r_type != R_ARM_PC24
+ && r_type != R_ARM_THM_PC22)
+ continue;
+
+ /* Get the section contents if we haven't done so already. */
+ if (contents == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (!bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* Read this BFD's symbols if we haven't done so already. */
+ if (extsyms == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ /* Go get them off disk. */
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ /* If the relocation is not against a symbol it cannot concern us. */
+
+ h = NULL;
+
+ /* We don't care about local symbols */
+ if (r_index < symtab_hdr->sh_info)
+ continue;
+
+ /* This is an external symbol */
+ r_index -= symtab_hdr->sh_info;
+ h = (struct elf_link_hash_entry *)
+ elf_sym_hashes (abfd)[r_index];
+
+ /* If the relocation is against a static symbol it must be within
+ the current section and so cannot be a cross ARM/Thumb relocation. */
+ if (h == NULL)
+ continue;
+
+ switch (r_type)
+ {
+ case R_ARM_PC24:
+ /* This one is a call from arm code. We need to look up
+ the target of the call. If it is a thumb target, we
+ insert glue. */
+
+ if (ELF_ST_TYPE(h->type) == STT_ARM_TFUNC)
+ record_arm_to_thumb_glue (link_info, h);
+ break;
+
+ case R_ARM_THM_PC22:
+ /* This one is a call from thumb code. We look
+ up the target of the call. If it is not a thumb
+ target, we insert glue. */
+
+ if (ELF_ST_TYPE (h->type) != STT_ARM_TFUNC)
+ record_thumb_to_arm_glue (link_info, h);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ return true;
+error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ if (free_extsyms != NULL)
+ free (free_extsyms);
+ return false;
+
+}
+
+/* The thumb form of a long branch is a bit finicky, because the offset
+ encoding is split over two fields, each in it's own instruction. They
+ can occur in any order. So given a thumb form of long branch, and an
+ offset, insert the offset into the thumb branch and return finished
+ instruction.
+
+ It takes two thumb instructions to encode the target address. Each has
+ 11 bits to invest. The upper 11 bits are stored in one (identifed by
+ H-0.. see below), the lower 11 bits are stored in the other (identified
+ by H-1).
+
+ Combine together and shifted left by 1 (it's a half word address) and
+ there you have it.
+
+ Op: 1111 = F,
+ H-0, upper address-0 = 000
+ Op: 1111 = F,
+ H-1, lower address-0 = 800
+
+ They can be ordered either way, but the arm tools I've seen always put
+ the lower one first. It probably doesn't matter. krk@cygnus.com
+
+ XXX: Actually the order does matter. The second instruction (H-1)
+ moves the computed address into the PC, so it must be the second one
+ in the sequence. The problem, however is that whilst little endian code
+ stores the instructions in HI then LOW order, big endian code does the
+ reverse. nickc@cygnus.com */
+
+#define LOW_HI_ORDER 0xF800F000
+#define HI_LOW_ORDER 0xF000F800
+
+static insn32
+insert_thumb_branch (br_insn, rel_off)
+ insn32 br_insn;
+ int rel_off;
+{
+ unsigned int low_bits;
+ unsigned int high_bits;
+
+
+ BFD_ASSERT ((rel_off & 1) != 1);
+
+ rel_off >>= 1; /* half word aligned address */
+ low_bits = rel_off & 0x000007FF; /* the bottom 11 bits */
+ high_bits = (rel_off >> 11) & 0x000007FF; /* the top 11 bits */
+
+ if ((br_insn & LOW_HI_ORDER) == LOW_HI_ORDER)
+ br_insn = LOW_HI_ORDER | (low_bits << 16) | high_bits;
+ else if ((br_insn & HI_LOW_ORDER) == HI_LOW_ORDER)
+ br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits;
+ else
+ abort (); /* error - not a valid branch instruction form */
+
+ /* FIXME: abort is probably not the right call. krk@cygnus.com */
+
+ return br_insn;
+}
+
+/* Thumb code calling an ARM function */
+static int
+elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section,
+ hit_data, sym_sec, offset, addend, val)
+ struct bfd_link_info *info;
+ char *name;
+ bfd *input_bfd;
+ bfd *output_bfd;
+ asection *input_section;
+ bfd_byte *hit_data;
+ asection *sym_sec;
+ int offset;
+ int addend;
+ bfd_vma val;
+{
+ asection *s = 0;
+ long int my_offset;
+ unsigned long int tmp;
+ long int ret_offset;
+ struct elf_link_hash_entry *myh;
+ struct elf32_arm_link_hash_table *globals;
+
+ myh = find_thumb_glue (info, name, input_bfd);
+ if (myh == NULL)
+ return false;
+
+ globals = elf32_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ my_offset = myh->root.u.def.value;
+
+ s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
+ THUMB2ARM_GLUE_SECTION_NAME);
+
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->contents != NULL);
+ BFD_ASSERT (s->output_section != NULL);
+
+ if ((my_offset & 0x01) == 0x01)
+ {
+ if (sym_sec != NULL
+ && sym_sec->owner != NULL
+ && !INTERWORK_FLAG (sym_sec->owner))
+ {
+ _bfd_error_handler
+ (_ ("%s(%s): warning: interworking not enabled."),
+ bfd_get_filename (sym_sec->owner), name);
+ _bfd_error_handler
+ (_ (" first occurrence: %s: thumb call to arm"),
+ bfd_get_filename (input_bfd));
+
+ return false;
+ }
+
+ --my_offset;
+ myh->root.u.def.value = my_offset;
+
+ bfd_put_16 (output_bfd, t2a1_bx_pc_insn,
+ s->contents + my_offset);
+
+ bfd_put_16 (output_bfd, t2a2_noop_insn,
+ s->contents + my_offset + 2);
+
+ ret_offset =
+ ((bfd_signed_vma) val) /* Address of destination of the stub */
+ - ((bfd_signed_vma)
+ (s->output_offset /* Offset from the start of the current section to the start of the stubs. */
+ + my_offset /* Offset of the start of this stub from the start of the stubs. */
+ + s->output_section->vma) /* Address of the start of the current section. */
+ + 4 /* The branch instruction is 4 bytes into the stub. */
+ + 8); /* ARM branches work from the pc of the instruction + 8. */
+
+ bfd_put_32 (output_bfd,
+ t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
+ s->contents + my_offset + 4);
+ }
+
+ BFD_ASSERT (my_offset <= globals->thumb_glue_size);
+
+ /* Now go back and fix up the original BL insn to point
+ to here. */
+ ret_offset =
+ s->output_offset
+ + my_offset
+ - (input_section->output_offset
+ + offset + addend)
+ - 4;
+
+ tmp = bfd_get_32 (input_bfd, hit_data
+ - input_section->vma);
+
+ bfd_put_32 (output_bfd,
+ insert_thumb_branch (tmp, ret_offset),
+ hit_data - input_section->vma);
+
+ return true;
+}
+
+/* Arm code calling a Thumb function */
+static int
+elf32_arm_to_thumb_stub (info, name, input_bfd, output_bfd, input_section,
+ hit_data, sym_sec, offset, addend, val)
+
+ struct bfd_link_info *info;
+ char *name;
+ bfd *input_bfd;
+ bfd *output_bfd;
+ asection *input_section;
+ bfd_byte *hit_data;
+ asection *sym_sec;
+ int offset;
+ int addend;
+ bfd_vma val;
+{
+ unsigned long int tmp;
+ long int my_offset;
+ asection *s;
+ long int ret_offset;
+ struct elf_link_hash_entry *myh;
+ struct elf32_arm_link_hash_table *globals;
+
+ myh = find_arm_glue (info, name, input_bfd);
+ if (myh == NULL)
+ return false;
+
+ globals = elf32_arm_hash_table (info);
+
+ BFD_ASSERT (globals != NULL);
+ BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
+
+ my_offset = myh->root.u.def.value;
+ s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
+ ARM2THUMB_GLUE_SECTION_NAME);
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->contents != NULL);
+ BFD_ASSERT (s->output_section != NULL);
+
+ if ((my_offset & 0x01) == 0x01)
+ {
+ if (sym_sec != NULL
+ && sym_sec->owner != NULL
+ && !INTERWORK_FLAG (sym_sec->owner))
+ {
+ _bfd_error_handler
+ (_ ("%s(%s): warning: interworking not enabled."),
+ bfd_get_filename (sym_sec->owner), name);
+ _bfd_error_handler
+ (_ (" first occurrence: %s: arm call to thumb"),
+ bfd_get_filename (input_bfd));
+ }
+ --my_offset;
+ myh->root.u.def.value = my_offset;
+
+ bfd_put_32 (output_bfd, a2t1_ldr_insn,
+ s->contents + my_offset);
+
+ bfd_put_32 (output_bfd, a2t2_bx_r12_insn,
+ s->contents + my_offset + 4);
+
+ /* It's a thumb address. Add the low order bit. */
+ bfd_put_32 (output_bfd, val | a2t3_func_addr_insn,
+ s->contents + my_offset + 8);
+ }
+
+ BFD_ASSERT (my_offset <= globals->arm_glue_size);
+
+ tmp = bfd_get_32 (input_bfd, hit_data);
+ tmp = tmp & 0xFF000000;
+
+ /* Somehow these are both 4 too far, so subtract 8. */
+ ret_offset = s->output_offset
+ + my_offset
+ + s->output_section->vma
+ - (input_section->output_offset
+ + input_section->output_section->vma
+ + offset + addend)
+ - 8;
+
+ tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF);
+
+ bfd_put_32 (output_bfd, tmp, hit_data
+ - input_section->vma);
+
+
+ return true;
+}
+
+/* Perform a relocation as part of a final link. */
+static bfd_reloc_status_type
+elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, rel, value,
+ info, sym_sec, sym_name, sym_flags)
+ reloc_howto_type * howto;
+ bfd * input_bfd;
+ bfd * output_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ Elf_Internal_Rela * rel;
+ bfd_vma value;
+ struct bfd_link_info * info;
+ asection * sym_sec;
+ const char * sym_name;
+ unsigned char sym_flags;
+{
+ unsigned long r_type = howto->type;
+ unsigned long r_symndx;
+ bfd_byte * hit_data = contents + rel->r_offset;
+ bfd * dynobj = NULL;
+ Elf_Internal_Shdr * symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes;
+ bfd_vma * local_got_offsets;
+ asection * sgot = NULL;
+ asection * splt = NULL;
+ asection * sreloc = NULL;
+ struct elf_link_hash_entry * h = NULL;
+ bfd_vma addend;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ if (dynobj)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ }
+ symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+#ifdef USE_REL
+ addend = (bfd_get_32 (input_bfd, hit_data) & howto->src_mask);
+#else
+ addend = rel->r_addend;
+#endif
+
+ switch (r_type)
+ {
+ case R_ARM_NONE:
+ return bfd_reloc_ok;
+
+ case R_ARM_PC24:
+ case R_ARM_ABS32:
+ case R_ARM_REL32:
+ /* When generating a shared object, these relocations are copied
+ into the output file to be resolved at run time. */
+
+ if (info->shared
+ && (r_type != R_ARM_PC24
+ || (h != NULL
+ && h->dynindx != -1
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ {
+ Elf_Internal_Rel outrel;
+ boolean skip, relocate;
+
+ if (sreloc == NULL)
+ {
+ const char * name;
+
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd,
+ elf_elfheader (input_bfd)->e_shstrndx,
+ elf_section_data (input_section)->rel_hdr.sh_name));
+ if (name == NULL)
+ return bfd_reloc_notsupported;
+
+ BFD_ASSERT (strncmp (name, ".rel", 4) == 0
+ && strcmp (bfd_get_section_name (input_bfd,
+ input_section),
+ name + 4) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ & elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ {
+ memset (&outrel, 0, sizeof outrel);
+ relocate = false;
+ }
+ else if (r_type == R_ARM_PC24)
+ {
+ BFD_ASSERT (h != NULL && h->dynindx != -1);
+ if ((input_section->flags & SEC_ALLOC) != 0)
+ relocate = false;
+ else
+ relocate = true;
+ outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_PC24);
+ }
+ else
+ {
+ if (h == NULL
+ || ((info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) != 0))
+ {
+ relocate = true;
+ outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
+ }
+ else
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ if ((input_section->flags & SEC_ALLOC) != 0)
+ relocate = false;
+ else
+ relocate = true;
+ outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_ABS32);
+ }
+ }
+
+ bfd_elf32_swap_reloc_out (output_bfd, &outrel,
+ (((Elf32_External_Rel *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ /* If this reloc is against an external symbol, we do not want to
+ fiddle with the addend. Otherwise, we need to include the symbol
+ value so that it becomes an addend for the dynamic reloc. */
+ if (! relocate)
+ return bfd_reloc_ok;
+
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+ }
+ else switch (r_type)
+ {
+ case R_ARM_PC24:
+ /* Arm B/BL instruction */
+
+ /* Check for arm calling thumb function. */
+ if (sym_flags == STT_ARM_TFUNC)
+ {
+ elf32_arm_to_thumb_stub (info, sym_name, input_bfd, output_bfd,
+ input_section, hit_data, sym_sec, rel->r_offset, addend, value);
+ return bfd_reloc_ok;
+ }
+
+ value = value + addend;
+ value -= (input_section->output_section->vma
+ + input_section->output_offset + 8);
+ value -= rel->r_offset;
+ value = value >> howto->rightshift;
+
+ value &= 0xffffff;
+ value |= (bfd_get_32 (input_bfd, hit_data) & 0xff000000);
+ break;
+
+ case R_ARM_ABS32:
+ value += addend;
+ if (sym_flags == STT_ARM_TFUNC)
+ value |= 1;
+ break;
+
+ case R_ARM_REL32:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value += addend;
+ break;
+ }
+
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_ARM_ABS8:
+ value += addend;
+ if ((long) value > 0x7f || (long) value < -0x80)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_ARM_ABS16:
+ value += addend;
+
+ if ((long) value > 0x7fff || (long) value < -0x8000)
+ return bfd_reloc_overflow;
+
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_ARM_ABS12:
+ /* Support ldr and str instruction for the arm */
+ /* Also thumb b (unconditional branch). ??? Really? */
+ value += addend;
+
+ if ((long) value > 0x7ff || (long) value < -0x800)
+ return bfd_reloc_overflow;
+
+ value |= (bfd_get_32 (input_bfd, hit_data) & 0xfffff000);
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_ARM_THM_ABS5:
+ /* Support ldr and str instructions for the thumb. */
+#ifdef USE_REL
+ /* Need to refetch addend. */
+ addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask;
+ /* ??? Need to determine shift amount from operand size. */
+ addend >>= howto->rightshift;
+#endif
+ value += addend;
+
+ /* ??? Isn't value unsigned? */
+ if ((long) value > 0x1f || (long) value < -0x10)
+ return bfd_reloc_overflow;
+
+ /* ??? Value needs to be properly shifted into place first. */
+ value |= bfd_get_16 (input_bfd, hit_data) & 0xf83f;
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_ARM_THM_PC22:
+ /* Thumb BL (branch long instruction). */
+ {
+ bfd_vma relocation;
+ boolean overflow = false;
+ bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data);
+ bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
+ bfd_vma src_mask = 0x007FFFFE;
+ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+ bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
+ bfd_vma check;
+ bfd_signed_vma signed_check;
+ bfd_vma add;
+ bfd_signed_vma signed_add;
+
+#ifdef USE_REL
+ /* Need to refetch the addend and squish the two 11 bit pieces
+ together. */
+ {
+ bfd_vma upper = bfd_get_16 (input_bfd, hit_data) & 0x7ff;
+ bfd_vma lower = bfd_get_16 (input_bfd, hit_data + 2) & 0x7ff;
+ upper = (upper ^ 0x400) - 0x400; /* sign extend */
+ addend = (upper << 12) | (lower << 1);
+ }
+#endif
+
+ /* If it's not a call to thumb, assume call to arm */
+ if (sym_flags != STT_ARM_TFUNC)
+ {
+ if (elf32_thumb_to_arm_stub
+ (info, sym_name, input_bfd, output_bfd, input_section,
+ hit_data, sym_sec, rel->r_offset, addend, value))
+ return bfd_reloc_ok;
+ else
+ return bfd_reloc_dangerous;
+ }
+
+ /* +4: pc is offset by 4 */
+ relocation = value + addend + 4;
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ relocation -= rel->r_offset;
+
+ check = relocation >> howto->rightshift;
+
+ /* If this is a signed value, the rightshift just dropped
+ leading 1 bits (assuming twos complement). */
+ if ((bfd_signed_vma) relocation >= 0)
+ signed_check = check;
+ else
+ signed_check = check | ~((bfd_vma) -1 >> howto->rightshift);
+
+ add = ((upper_insn & 0x7ff) << 12) | ((lower_insn & 0x7ff) << 1);
+ /* sign extend */
+ signed_add = (add ^ 0x400000) - 0x400000;
+
+ /* Add the value from the object file. */
+ signed_check += signed_add;
+ relocation += signed_add;
+
+ /* Assumes two's complement. */
+ if (signed_check > reloc_signed_max
+ || signed_check < reloc_signed_min)
+ overflow = true;
+
+ /* Put RELOCATION back into the insn. */
+ upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 12) & 0x7ff);
+ lower_insn = (lower_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 1) & 0x7ff);
+
+ /* Put the relocated value back in the object file: */
+ bfd_put_16 (input_bfd, upper_insn, hit_data);
+ bfd_put_16 (input_bfd, lower_insn, hit_data + 2);
+
+ return (overflow ? bfd_reloc_overflow : bfd_reloc_ok);
+ }
+ break;
+
+ case R_ARM_GNU_VTINHERIT:
+ case R_ARM_GNU_VTENTRY:
+ return bfd_reloc_ok;
+
+ case R_ARM_COPY:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_GLOB_DAT:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_JUMP_SLOT:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_RELATIVE:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_GOTOFF:
+ /* Relocation is relative to the start of the
+ global offset table. */
+
+ BFD_ASSERT (sgot != NULL);
+ if (sgot == NULL)
+ return bfd_reloc_notsupported;
+
+ /* Note that sgot->output_offset is not involved in this
+ calculation. We always want the start of .got. If we
+ define _GLOBAL_OFFSET_TABLE in a different way, as is
+ permitted by the ABI, we might have to change this
+ calculation. */
+
+ value -= sgot->output_section->vma;
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+
+ case R_ARM_GOTPC:
+ /* Use global offset table as symbol value. */
+
+ BFD_ASSERT (sgot != NULL);
+
+ if (sgot == NULL)
+ return bfd_reloc_notsupported;
+
+ value = sgot->output_section->vma;
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+
+ case R_ARM_GOT32:
+ /* Relocation is to the entry for this symbol in the
+ global offset table. */
+ if (sgot == NULL)
+ return bfd_reloc_notsupported;
+
+ if (h != NULL)
+ {
+ bfd_vma off;
+
+ off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ if (!elf_hash_table (info)->dynamic_sections_created ||
+ (info->shared && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a -Bsymbolic link
+ and the symbol is defined locally. We must initialize this
+ entry in the global offset table. Since the offset must
+ always be a multiple of 4, we use the least significant bit
+ to record whether we have initialized it already.
+
+ When doing a dynamic link, we create a .rel.got relocation
+ entry to initialize the value. This is done in the
+ finish_dynamic_symbol routine. */
+
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, value, sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+
+ value = sgot->output_offset + off;
+ }
+ else
+ {
+ bfd_vma off;
+
+ BFD_ASSERT (local_got_offsets != NULL &&
+ local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use the
+ least significant bit to record whether we have already
+ generated the necessary reloc. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, value, sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection * srelgot;
+ Elf_Internal_Rel outrel;
+
+ srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
+ bfd_elf32_swap_reloc_out (output_bfd, &outrel,
+ (((Elf32_External_Rel *)
+ srelgot->contents)
+ + srelgot->reloc_count));
+ ++srelgot->reloc_count;
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+
+ value = sgot->output_offset + off;
+ }
+
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+
+ case R_ARM_PLT32:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+
+ /* Resolve a PLT32 reloc against a local symbol directly,
+ without using the procedure linkage table. */
+ if (h == NULL)
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+
+ if (h->plt.offset == (bfd_vma) -1)
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+
+ BFD_ASSERT(splt != NULL);
+ if (splt == NULL)
+ return bfd_reloc_notsupported;
+
+ value = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+ return _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, value,
+ (bfd_vma) 0);
+
+ case R_ARM_SBREL32:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_AMP_VCALL9:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_RSBREL32:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_THM_RPC22:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_RREL32:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_RABS32:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_RPC24:
+ return bfd_reloc_notsupported;
+
+ case R_ARM_RBASE:
+ return bfd_reloc_notsupported;
+
+ default:
+ return bfd_reloc_notsupported;
+ }
+}
+
+
+/* Relocate an ARM ELF section. */
+static boolean
+elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+ bfd * input_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ Elf_Internal_Rela * relocs;
+ Elf_Internal_Sym * local_syms;
+ asection ** local_sections;
+{
+ Elf_Internal_Shdr * symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes;
+ Elf_Internal_Rela * rel;
+ Elf_Internal_Rela * relend;
+ const char * name;
+
+ symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type * howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym * sym;
+ asection * sec;
+ struct elf_link_hash_entry * h;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ if (r_type == R_ARM_GNU_VTENTRY
+ || r_type == R_ARM_GNU_VTINHERIT )
+ continue;
+
+ /* ScottB: range check r_type here. */
+
+ howto = elf32_arm_howto_table + r_type;
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+#ifdef USE_REL
+ {
+ bfd_vma val;
+ val = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ val += (sec->output_offset + sym->st_value) >> howto->rightshift;
+ bfd_put_32 (input_bfd, val, contents + rel->r_offset);
+ }
+#else
+ rel->r_addend += (sec->output_offset + sym->st_value)
+ >> howto->rightshift;
+#endif
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+
+ /* In these cases, we don't need the relocation value.
+ We check specially because in some obscure cases
+ sec->output_section will be NULL. */
+ switch (r_type)
+ {
+ case R_ARM_PC24:
+ case R_ARM_ABS32:
+ if (info->shared
+ && (
+ (!info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR == 0)
+ )
+ && ((input_section->flags & SEC_ALLOC) != 0)
+ )
+ relocation = 0;
+ break;
+
+ case R_ARM_GOTPC:
+ relocation = 0;
+ break;
+
+ case R_ARM_GOT32:
+ if (elf_hash_table(info)->dynamic_sections_created
+ && (!info->shared
+ || (!info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ )
+ )
+ relocation = 0;
+ break;
+
+ case R_ARM_PLT32:
+ if (h->plt.offset != (bfd_vma)-1)
+ relocation = 0;
+ break;
+
+ default:
+ if (sec->output_section == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
+ bfd_get_filename (input_bfd), h->root.root.string,
+ bfd_get_section_name (input_bfd, input_section));
+ relocation = 0;
+ }
+ }
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (!((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL || *name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, rel,
+ relocation, info, sec, name,
+ (h ? ELF_ST_TYPE (h->type) :
+ ELF_ST_TYPE (sym->st_info)));
+
+ if (r != bfd_reloc_ok)
+ {
+ const char * msg = (const char *) 0;
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ if (!((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_undefined:
+ if (!((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _ ("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ msg = _ ("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ msg = _ ("internal error: dangerous error");
+ goto common_error;
+
+ default:
+ msg = _ ("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, msg, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Function to keep ARM specific flags in the ELF header. */
+static boolean
+elf32_arm_set_private_flags (abfd, flags)
+ bfd *abfd;
+ flagword flags;
+{
+ if (elf_flags_init (abfd)
+ && elf_elfheader (abfd)->e_flags != flags)
+ {
+ if (flags & EF_INTERWORK)
+ _bfd_error_handler (_ ("\
+Warning: Not setting interwork flag of %s since it has already been specified as non-interworking"),
+ bfd_get_filename (abfd));
+ else
+ _bfd_error_handler (_ ("\
+Warning: Clearing the interwork flag of %s due to outside request"),
+ bfd_get_filename (abfd));
+ }
+ else
+ {
+ elf_elfheader (abfd)->e_flags = flags;
+ elf_flags_init (abfd) = true;
+ }
+
+ return true;
+}
+
+/* Copy backend specific data from one object module to another */
+static boolean
+elf32_arm_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ flagword in_flags;
+ flagword out_flags;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ in_flags = elf_elfheader (ibfd)->e_flags;
+ out_flags = elf_elfheader (obfd)->e_flags;
+
+ if (elf_flags_init (obfd) && in_flags != out_flags)
+ {
+ /* Cannot mix PIC and non-PIC code. */
+ if ((in_flags & EF_PIC) != (out_flags & EF_PIC))
+ return false;
+
+ /* Cannot mix APCS26 and APCS32 code. */
+ if ((in_flags & EF_APCS_26) != (out_flags & EF_APCS_26))
+ return false;
+
+ /* Cannot mix float APCS and non-float APCS code. */
+ if ((in_flags & EF_APCS_FLOAT) != (out_flags & EF_APCS_FLOAT))
+ return false;
+
+ /* If the src and dest have different interworking flags
+ then turn off the interworking bit. */
+ if ((in_flags & EF_INTERWORK) != (out_flags & EF_INTERWORK))
+ {
+ if (out_flags & EF_INTERWORK)
+ _bfd_error_handler (_ ("\
+Warning: Clearing the interwork flag in %s because non-interworking code in %s has been linked with it"),
+ bfd_get_filename (obfd), bfd_get_filename (ibfd));
+
+ in_flags &= ~EF_INTERWORK;
+ }
+ }
+
+ elf_elfheader (obfd)->e_flags = in_flags;
+ elf_flags_init (obfd) = true;
+
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+static boolean
+elf32_arm_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ flagword out_flags;
+ flagword in_flags;
+
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ /* Check if we have the same endianess */
+ if ( ibfd->xvec->byteorder != obfd->xvec->byteorder
+ && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
+ && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
+ {
+ (*_bfd_error_handler)
+ (_("%s: compiled for a %s endian system and target is %s endian"),
+ bfd_get_filename (ibfd),
+ bfd_big_endian (ibfd) ? "big" : "little",
+ bfd_big_endian (obfd) ? "big" : "little");
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ /* The input BFD must have had its flags initialised. */
+ /* The following seems bogus to me -- The flags are initialized in
+ the assembler but I don't think an elf_flags_init field is
+ written into the object */
+ /* BFD_ASSERT (elf_flags_init (ibfd)); */
+
+ in_flags = elf_elfheader (ibfd)->e_flags;
+ out_flags = elf_elfheader (obfd)->e_flags;
+
+ if (!elf_flags_init (obfd))
+ {
+ /* If the input is the default architecture then do not
+ bother setting the flags for the output architecture,
+ instead allow future merges to do this. If no future
+ merges ever set these flags then they will retain their
+ unitialised values, which surprise surprise, correspond
+ to the default values. */
+ if (bfd_get_arch_info (ibfd)->the_default)
+ return true;
+
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = in_flags;
+
+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+ && bfd_get_arch_info (obfd)->the_default)
+ return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
+
+ return true;
+ }
+
+ /* Check flag compatibility. */
+ if (in_flags == out_flags)
+ return true;
+
+ /* Complain about various flag mismatches. */
+
+ if ((in_flags & EF_APCS_26) != (out_flags & EF_APCS_26))
+ _bfd_error_handler (_ ("\
+Error: %s compiled for APCS-%d, whereas %s is compiled for APCS-%d"),
+ bfd_get_filename (ibfd),
+ in_flags & EF_APCS_26 ? 26 : 32,
+ bfd_get_filename (obfd),
+ out_flags & EF_APCS_26 ? 26 : 32);
+
+ if ((in_flags & EF_APCS_FLOAT) != (out_flags & EF_APCS_FLOAT))
+ _bfd_error_handler (_ ("\
+Error: %s passes floats in %s registers, whereas %s passes them in %s registers"),
+ bfd_get_filename (ibfd),
+ in_flags & EF_APCS_FLOAT ? _ ("float") : _ ("integer"),
+ bfd_get_filename (obfd),
+ out_flags & EF_APCS_26 ? _ ("float") : _ ("integer"));
+
+ if ((in_flags & EF_PIC) != (out_flags & EF_PIC))
+ _bfd_error_handler (_ ("\
+Error: %s is compiled as position %s code, whereas %s is not"),
+ bfd_get_filename (ibfd),
+ in_flags & EF_PIC ? _ ("independent") : _ ("dependent"),
+ bfd_get_filename (obfd));
+
+ /* Interworking mismatch is only a warning. */
+ if ((in_flags & EF_INTERWORK) != (out_flags & EF_INTERWORK))
+ {
+ _bfd_error_handler (_ ("\
+Warning: %s %s interworking, whereas %s %s"),
+ bfd_get_filename (ibfd),
+ in_flags & EF_INTERWORK ? _ ("supports") : _ ("does not support"),
+ bfd_get_filename (obfd),
+ out_flags & EF_INTERWORK ? _ ("does not") : _ ("does"));
+ return true;
+ }
+
+ return false;
+}
+
+/* Display the flags field */
+static boolean
+elf32_arm_print_private_bfd_data (abfd, ptr)
+ bfd *abfd;
+ PTR ptr;
+{
+ FILE *file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+ /* Print normal ELF private data. */
+ _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+ /* Ignore init flag - it may not be set, despite the flags field containing valid data. */
+
+ /* xgettext:c-format */
+ fprintf (file, _ ("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+
+ if (elf_elfheader (abfd)->e_flags & EF_INTERWORK)
+ fprintf (file, _ (" [interworking enabled]"));
+ else
+ fprintf (file, _ (" [interworking not enabled]"));
+
+ if (elf_elfheader (abfd)->e_flags & EF_APCS_26)
+ fprintf (file, _ (" [APCS-26]"));
+ else
+ fprintf (file, _ (" [APCS-32]"));
+
+ if (elf_elfheader (abfd)->e_flags & EF_APCS_FLOAT)
+ fprintf (file, _ (" [floats passed in float registers]"));
+ else
+ fprintf (file, _ (" [floats passed in integer registers]"));
+
+ if (elf_elfheader (abfd)->e_flags & EF_PIC)
+ fprintf (file, _ (" [position independent]"));
+ else
+ fprintf (file, _ (" [absolute position]"));
+
+ fputc ('\n', file);
+
+ return true;
+}
+
+static int
+elf32_arm_get_symbol_type (elf_sym, type)
+ Elf_Internal_Sym * elf_sym;
+ int type;
+{
+ if (ELF_ST_TYPE (elf_sym->st_info) == STT_ARM_TFUNC)
+ return ELF_ST_TYPE (elf_sym->st_info);
+ else
+ return type;
+}
+
+static asection *
+elf32_arm_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_ARM_GNU_VTINHERIT:
+ case R_ARM_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+ return NULL;
+}
+
+static boolean
+elf32_arm_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ /* we don't use got and plt entries for armelf */
+ return true;
+}
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+elf32_arm_check_relocs (abfd, info, sec, relocs)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ asection * sec;
+ const Elf_Internal_Rela * relocs;
+{
+ Elf_Internal_Shdr * symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes;
+ struct elf_link_hash_entry ** sym_hashes_end;
+ const Elf_Internal_Rela * rel;
+ const Elf_Internal_Rela * rel_end;
+ bfd * dynobj;
+ asection * sgot, *srelgot, *sreloc;
+ bfd_vma * local_got_offsets;
+
+ if (info->relocateable)
+ return true;
+
+ sgot = srelgot = sreloc = NULL;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ local_got_offsets = elf_local_got_offsets (abfd);
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry *h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ /* Some relocs require a global offset table. */
+ if (dynobj == NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_ARM_GOT32:
+ case R_ARM_GOTOFF:
+ case R_ARM_GOTPC:
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_ARM_GOT32:
+ /* This symbol requires a global offset table entry. */
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ /* Get the got relocation section if necessary. */
+ if (srelgot == NULL
+ && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
+
+ /* If no got relocation section, make one and initialize. */
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rel.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (h != NULL)
+ {
+ if (h->got.offset != (bfd_vma) -1)
+ /* We have already allocated space in the .got. */
+ break;
+
+ h->got.offset = sgot->_raw_size;
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+
+ srelgot->_raw_size += sizeof (Elf32_External_Rel);
+ }
+ else
+ {
+ /* This is a global offset table entry for a local
+ symbol. */
+ if (local_got_offsets == NULL)
+ {
+ size_t size;
+ register unsigned int i;
+
+ size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
+ if (local_got_offsets == NULL)
+ return false;
+ elf_local_got_offsets (abfd) = local_got_offsets;
+ for (i = 0; i < symtab_hdr->sh_info; i++)
+ local_got_offsets[i] = (bfd_vma) -1;
+ }
+
+ if (local_got_offsets[r_symndx] != (bfd_vma) -1)
+ /* We have already allocated space in the .got. */
+ break;
+
+ local_got_offsets[r_symndx] = sgot->_raw_size;
+
+ if (info->shared)
+ /* If we are generating a shared object, we need to
+ output a R_ARM_RELATIVE reloc so that the dynamic
+ linker can adjust this GOT entry. */
+ srelgot->_raw_size += sizeof (Elf32_External_Rel);
+ }
+
+ sgot->_raw_size += 4;
+ break;
+
+ case R_ARM_PLT32:
+ /* This symbol requires a procedure linkage table entry. We
+ actually build the entry in adjust_dynamic_symbol,
+ because this might be a case of linking PIC code which is
+ never referenced by a dynamic object, in which case we
+ don't need to generate a procedure linkage table entry
+ after all. */
+
+ /* If this is a local symbol, we resolve it directly without
+ creating a procedure linkage table entry. */
+ if (h == NULL)
+ continue;
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ break;
+
+ case R_ARM_ABS32:
+ case R_ARM_REL32:
+ case R_ARM_PC24:
+ /* If we are creating a shared library, and this is a reloc
+ against a global symbol, or a non PC relative reloc
+ against a local symbol, then we need to copy the reloc
+ into the shared library. However, if we are linking with
+ -Bsymbolic, we do not need to copy a reloc against a
+ global symbol which is defined in an object we are
+ including in the link (i.e., DEF_REGULAR is set). At
+ this point we have not seen all the input files, so it is
+ possible that DEF_REGULAR is not set now but will be set
+ later (it is never cleared). We account for that
+ possibility below by storing information in the
+ pcrel_relocs_copied field of the hash table entry. */
+ if (info->shared
+ && (ELF32_R_TYPE (rel->r_info) != R_ARM_PC24
+ || (h != NULL
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ {
+ /* When creating a shared object, we must copy these
+ reloc types into the output file. We create a reloc
+ section in dynobj and make room for this reloc. */
+ if (sreloc == NULL)
+ {
+ const char * name;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rel", 4) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ name + 4) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ }
+
+ sreloc->_raw_size += sizeof (Elf32_External_Rel);
+ /* If we are linking with -Bsymbolic, and this is a
+ global symbol, we count the number of PC relative
+ relocations we have entered for this symbol, so that
+ we can discard them again if the symbol is later
+ defined by a regular object. Note that this function
+ is only called if we are using an elf_i386 linker
+ hash table, which means that h is really a pointer to
+ an elf_i386_link_hash_entry. */
+ if (h != NULL && info->symbolic
+ && ELF32_R_TYPE (rel->r_info) == R_ARM_PC24)
+ {
+ struct elf32_arm_link_hash_entry * eh;
+ struct elf32_arm_pcrel_relocs_copied * p;
+
+ eh = (struct elf32_arm_link_hash_entry *) h;
+
+ for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
+ if (p->section == sreloc)
+ break;
+
+ if (p == NULL)
+ {
+ p = ((struct elf32_arm_pcrel_relocs_copied *)
+ bfd_alloc (dynobj, sizeof * p));
+
+ if (p == NULL)
+ return false;
+ p->next = eh->pcrel_relocs_copied;
+ eh->pcrel_relocs_copied = p;
+ p->section = sreloc;
+ p->count = 0;
+ }
+
+ ++p->count;
+ }
+ }
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_ARM_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_ARM_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+
+/* Find the nearest line to a particular section and offset, for error
+ reporting. This code is a duplicate of the code in elf.c, except
+ that it also accepts STT_ARM_TFUNC as a symbol that names a function. */
+
+static boolean
+elf32_arm_find_nearest_line
+ (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
+ bfd * abfd;
+ asection * section;
+ asymbol ** symbols;
+ bfd_vma offset;
+ CONST char ** filename_ptr;
+ CONST char ** functionname_ptr;
+ unsigned int * line_ptr;
+{
+ boolean found;
+ const char * filename;
+ asymbol * func;
+ bfd_vma low_func;
+ asymbol ** p;
+
+ if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ return true;
+
+ if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+ &found, filename_ptr,
+ functionname_ptr, line_ptr,
+ &elf_tdata (abfd)->line_info))
+ return false;
+
+ if (found)
+ return true;
+
+ if (symbols == NULL)
+ return false;
+
+ filename = NULL;
+ func = NULL;
+ low_func = 0;
+
+ for (p = symbols; *p != NULL; p++)
+ {
+ elf_symbol_type *q;
+
+ q = (elf_symbol_type *) *p;
+
+ if (bfd_get_section (&q->symbol) != section)
+ continue;
+
+ switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
+ {
+ default:
+ break;
+ case STT_FILE:
+ filename = bfd_asymbol_name (&q->symbol);
+ break;
+ case STT_NOTYPE:
+ case STT_FUNC:
+ case STT_ARM_TFUNC:
+ if (q->symbol.section == section
+ && q->symbol.value >= low_func
+ && q->symbol.value <= offset)
+ {
+ func = (asymbol *) q;
+ low_func = q->symbol.value;
+ }
+ break;
+ }
+ }
+
+ if (func == NULL)
+ return false;
+
+ *filename_ptr = filename;
+ *functionname_ptr = bfd_asymbol_name (func);
+ *line_ptr = 0;
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf32_arm_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info * info;
+ struct elf_link_hash_entry * h;
+{
+ bfd * dynobj;
+ asection * s;
+ unsigned int power_of_two;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+ /* If this is a function, put it in the procedure linkage table. We
+ will fill in the contents of the procedure linkage table later,
+ when we know the address of the .got section. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)
+ {
+ /* This case can occur if we saw a PLT32 reloc in an input
+ file, but the symbol was never referred to by a dynamic
+ object. In such a case, we don't actually need to build
+ a procedure linkage table, and we can just do a PC32
+ reloc instead. */
+ BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
+ return true;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+ }
+
+ h->plt.offset = s->_raw_size;
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+
+ s = bfd_get_section_by_name (dynobj, ".got.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += 4;
+
+ /* We also need to make an entry in the .rel.plt section. */
+
+ s = bfd_get_section_by_name (dynobj, ".rel.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += sizeof (Elf32_External_Rel);
+
+ return true;
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ BFD_ASSERT (s != NULL);
+
+ /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
+ copy the initial value out of the dynamic object and into the
+ runtime process image. We need to remember the offset into the
+ .rel.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ asection *srel;
+
+ srel = bfd_get_section_by_name (dynobj, ".rel.bss");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf32_External_Rel);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 3)
+ power_of_two = 3;
+
+ /* Apply the required alignment. */
+ s->_raw_size = BFD_ALIGN (s->_raw_size,
+ (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ {
+ if (! bfd_set_section_alignment (dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf32_arm_size_dynamic_sections (output_bfd, info)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+{
+ bfd * dynobj;
+ asection * s;
+ boolean plt;
+ boolean relocs;
+ boolean reltext;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+ else
+ {
+ /* We may have created entries in the .rel.got section.
+ However, if we are not creating the dynamic sections, we will
+ not actually use these entries. Reset the size of .rel.got,
+ which will cause it to get stripped from the output file
+ below. */
+ s = bfd_get_section_by_name (dynobj, ".rel.got");
+ if (s != NULL)
+ s->_raw_size = 0;
+ }
+
+ /* If this is a -Bsymbolic shared link, then we need to discard all
+ PC relative relocs against symbols defined in a regular object.
+ We allocated space for them in the check_relocs routine, but we
+ will not fill them in in the relocate_section routine. */
+ if (info->shared && info->symbolic)
+ elf32_arm_link_hash_traverse (elf32_arm_hash_table (info),
+ elf32_arm_discard_copies,
+ (PTR) NULL);
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ plt = false;
+ relocs = false;
+ reltext = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char * name;
+ boolean strip;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ strip = false;
+
+ if (strcmp (name, ".plt") == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
+ strip = true;
+ }
+ else
+ {
+ /* Remember whether there is a PLT. */
+ plt = true;
+ }
+ }
+ else if (strncmp (name, ".rel", 4) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is mostly to handle .rel.bss and
+ .rel.plt. We must create both sections in
+ create_dynamic_sections, because they must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ strip = true;
+ }
+ else
+ {
+ asection * target;
+
+ /* Remember whether there are any reloc sections other
+ than .rel.plt. */
+ if (strcmp (name, ".rel.plt") != 0)
+ {
+ const char *outname;
+
+ relocs = true;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL
+ entry. The entries in the .rel.plt section
+ really apply to the .got section, which we
+ created ourselves and so know is not readonly. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 4);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ reltext = true;
+ }
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strncmp (name, ".got", 4) != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ asection ** spp;
+
+ for (spp = &s->output_section->owner->sections;
+ *spp != s->output_section;
+ spp = &(*spp)->next)
+ ;
+ *spp = s->output_section->next;
+ --s->output_section->owner->section_count;
+
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf32_arm_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (! info->shared)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (plt)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
+ sizeof (Elf32_External_Rel)))
+ return false;
+ }
+
+ if (reltext)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* This function is called via elf32_arm_link_hash_traverse if we are
+ creating a shared object with -Bsymbolic. It discards the space
+ allocated to copy PC relative relocs against symbols which are
+ defined in regular objects. We allocated space for them in the
+ check_relocs routine, but we won't fill them in in the
+ relocate_section routine. */
+
+static boolean
+elf32_arm_discard_copies (h, ignore)
+ struct elf32_arm_link_hash_entry * h;
+ PTR ignore;
+{
+ struct elf32_arm_pcrel_relocs_copied * s;
+
+ /* We only discard relocs for symbols defined in a regular object. */
+ if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ return true;
+
+ for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
+ s->section->_raw_size -= s->count * sizeof (Elf32_External_Rel);
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf32_arm_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+ struct elf_link_hash_entry * h;
+ Elf_Internal_Sym * sym;
+{
+ bfd * dynobj;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection * splt;
+ asection * sgot;
+ asection * srel;
+ bfd_vma plt_index;
+ bfd_vma got_offset;
+ Elf_Internal_Rel rel;
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+ srel = bfd_get_section_by_name (dynobj, ".rel.plt");
+ BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
+
+ /* Get the index in the procedure linkage table which
+ corresponds to this symbol. This is the index of this symbol
+ in all the symbols for which we are making plt entries. The
+ first entry in the procedure linkage table is reserved. */
+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+
+ /* Get the offset into the .got table of the entry that
+ corresponds to this function. Each .got entry is 4 bytes.
+ The first three are reserved. */
+ got_offset = (plt_index + 3) * 4;
+
+ /* Fill in the entry in the procedure linkage table. */
+ memcpy (splt->contents + h->plt.offset,
+ elf32_arm_plt_entry,
+ PLT_ENTRY_SIZE);
+ bfd_put_32 (output_bfd,
+ (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset
+ - splt->output_section->vma
+ - splt->output_offset
+ - h->plt.offset - 12),
+ splt->contents + h->plt.offset + 12);
+
+ /* Fill in the entry in the global offset table. */
+ bfd_put_32 (output_bfd,
+ (splt->output_section->vma
+ + splt->output_offset),
+ sgot->contents + got_offset);
+
+ /* Fill in the entry in the .rel.plt section. */
+ rel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset);
+ rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_JUMP_SLOT);
+ bfd_elf32_swap_reloc_out (output_bfd, &rel,
+ ((Elf32_External_Rel *) srel->contents
+ + plt_index));
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ the .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ asection * sgot;
+ asection * srel;
+ Elf_Internal_Rel rel;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srel = bfd_get_section_by_name (dynobj, ".rel.got");
+ BFD_ASSERT (sgot != NULL && srel != NULL);
+
+ rel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + (h->got.offset &~ 1));
+
+ /* If this is a -Bsymbolic link, and the symbol is defined
+ locally, we just want to emit a RELATIVE reloc. The entry in
+ the global offset table will already have been initialized in
+ the relocate_section function. */
+ if (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ rel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
+ else
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+ rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT);
+ }
+
+ bfd_elf32_swap_reloc_out (output_bfd, &rel,
+ ((Elf32_External_Rel *) srel->contents
+ + srel->reloc_count));
+ ++srel->reloc_count;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ asection * s;
+ Elf_Internal_Rel rel;
+
+ /* This symbol needs a copy reloc. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak));
+
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rel.bss");
+ BFD_ASSERT (s != NULL);
+
+ rel.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY);
+ bfd_elf32_swap_reloc_out (output_bfd, &rel,
+ ((Elf32_External_Rel *) s->contents
+ + s->reloc_count));
+ ++s->reloc_count;
+ }
+
+ /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf32_arm_finish_dynamic_sections (output_bfd, info)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+{
+ bfd * dynobj;
+ asection * sgot;
+ asection * sdyn;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+ BFD_ASSERT (sgot != NULL);
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char * name;
+ asection * s;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ break;
+
+ case DT_PLTGOT:
+ name = ".got";
+ goto get_vma;
+ case DT_JMPREL:
+ name = ".rel.plt";
+ get_vma:
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_PLTRELSZ:
+ s = bfd_get_section_by_name (output_bfd, ".rel.plt");
+ BFD_ASSERT (s != NULL);
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_RELSZ:
+ /* My reading of the SVR4 ABI indicates that the
+ procedure linkage table relocs (DT_JMPREL) should be
+ included in the overall relocs (DT_REL). This is
+ what Solaris does. However, UnixWare can not handle
+ that case. Therefore, we override the DT_RELSZ entry
+ here to make it not include the JMPREL relocs. Since
+ the linker script arranges for .rel.plt to follow all
+ other relocation sections, we don't have to worry
+ about changing the DT_REL entry. */
+ s = bfd_get_section_by_name (output_bfd, ".rel.plt");
+ if (s != NULL)
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val -= s->_cooked_size;
+ else
+ dyn.d_un.d_val -= s->_raw_size;
+ }
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+ }
+ }
+
+ /* Fill in the first entry in the procedure linkage table. */
+ if (splt->_raw_size > 0)
+ memcpy (splt->contents, elf32_arm_plt0_entry, PLT_ENTRY_SIZE);
+
+ /* UnixWare sets the entsize of .plt to 4, although that doesn't
+ really seem like the right value. */
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ }
+
+ /* Fill in the first three entries in the global offset table. */
+ if (sgot->_raw_size > 0)
+ {
+ if (sdyn == NULL)
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
+ else
+ bfd_put_32 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ sgot->contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
+ }
+
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+
+ return true;
+}
+
+#define ELF_ARCH bfd_arch_arm
+#define ELF_MACHINE_CODE EM_ARM
+#define ELF_MAXPAGE_SIZE 0x8000
+
+
+#define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data
+#define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags
+#define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data
+#define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create
+#define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
+#define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line
+
+#define elf_backend_get_symbol_type elf32_arm_get_symbol_type
+#define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook
+#define elf_backend_check_relocs elf32_arm_check_relocs
+#define elf_backend_relocate_section elf32_arm_relocate_section
+#define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol
+#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
+#define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
+#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
+
+#define elf_backend_can_gc_sections 1
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_got_plt 1
+#define elf_backend_want_plt_sym 0
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c
new file mode 100644
index 00000000000..be80bae2e9b
--- /dev/null
+++ b/bfd/elf32-d10v.c
@@ -0,0 +1,534 @@
+/* D10V-specific support for 32-bit ELF
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by Martin Hunt (hunt@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+/* #include "elf/d10v.h" */
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void d10v_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+
+
+/* Use REL instead of RELA to save space */
+#define USE_REL
+
+enum reloc_type
+{
+ R_D10V_NONE = 0,
+ R_D10V_10_PCREL_R,
+ R_D10V_10_PCREL_L,
+ R_D10V_16,
+ R_D10V_18,
+ R_D10V_18_PCREL,
+ R_D10V_32,
+ R_D10V_GNU_VTINHERIT,
+ R_D10V_GNU_VTENTRY,
+ R_D10V_max
+};
+
+static reloc_howto_type elf_d10v_howto_table[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_D10V_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An PC Relative 10-bit relocation, shifted by 2 */
+ /* right container */
+ HOWTO (R_D10V_10_PCREL_R, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 10, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_10_PCREL_R", /* name */
+ false, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* An PC Relative 10-bit relocation, shifted by 2 */
+ /* left container */
+ HOWTO (R_D10V_10_PCREL_L, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 10, /* bitsize */
+ true, /* pc_relative */
+ 15, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_10_PCREL_L", /* name */
+ false, /* partial_inplace */
+ 0x07f8000, /* src_mask */
+ 0x07f8000, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A 16 bit absolute relocation */
+ HOWTO (R_D10V_16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_16", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An 18 bit absolute relocation, right shifted 2 */
+ HOWTO (R_D10V_18, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 18, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_18", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 18 bit relocation, right shifted by 2 */
+ HOWTO (R_D10V_18_PCREL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 18, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_18_PCREL", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A 32 bit absolute relocation */
+ HOWTO (R_D10V_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D10V_32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_D10V_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_D10V_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_D10V_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_D10V_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+/* Map BFD reloc types to D10V ELF reloc types. */
+
+struct d10v_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+ static const struct d10v_reloc_map d10v_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_D10V_NONE, },
+ { BFD_RELOC_D10V_10_PCREL_R, R_D10V_10_PCREL_R },
+ { BFD_RELOC_D10V_10_PCREL_L, R_D10V_10_PCREL_L },
+ { BFD_RELOC_16, R_D10V_16 },
+ { BFD_RELOC_D10V_18, R_D10V_18 },
+ { BFD_RELOC_D10V_18_PCREL, R_D10V_18_PCREL },
+ { BFD_RELOC_32, R_D10V_32 },
+ { BFD_RELOC_VTABLE_INHERIT, R_D10V_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_D10V_GNU_VTENTRY },
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (d10v_reloc_map) / sizeof (struct d10v_reloc_map);
+ i++)
+ {
+ if (d10v_reloc_map[i].bfd_reloc_val == code)
+ return &elf_d10v_howto_table[d10v_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Set the howto pointer for an D10V ELF reloc. */
+
+static void
+d10v_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rel *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_D10V_max);
+ cache_ptr->howto = &elf_d10v_howto_table[r_type];
+}
+
+static asection *
+elf32_d10v_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_D10V_GNU_VTINHERIT:
+ case R_D10V_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+ return NULL;
+}
+
+static boolean
+elf32_d10v_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ /* we don't use got and plt entries for d10v */
+ return true;
+}
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+elf32_d10v_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+
+ if (info->relocateable)
+ return true;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry *h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_D10V_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_D10V_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Relocate a D10V ELF section. */
+static boolean
+elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ Elf_Internal_Rela *rel, *relend;
+ const char *name;
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ struct elf_link_hash_entry *h;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ if (r_type == R_D10V_GNU_VTENTRY
+ || r_type == R_D10V_GNU_VTINHERIT )
+ continue;
+
+ howto = elf_d10v_howto_table + r_type;
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (!((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL || *name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char * msg = (const char *) 0;
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ if (!((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_undefined:
+ if (!((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _ ("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ msg = _ ("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ msg = _ ("internal error: dangerous error");
+ goto common_error;
+
+ default:
+ msg = _ ("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, msg, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+#define ELF_ARCH bfd_arch_d10v
+#define ELF_MACHINE_CODE EM_CYGNUS_D10V
+#define ELF_MAXPAGESIZE 0x1000
+
+#define TARGET_BIG_SYM bfd_elf32_d10v_vec
+#define TARGET_BIG_NAME "elf32-d10v"
+
+#define elf_info_to_howto 0
+#define elf_info_to_howto_rel d10v_info_to_howto_rel
+#define elf_backend_object_p 0
+#define elf_backend_final_write_processing 0
+#define elf_backend_gc_mark_hook elf32_d10v_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf32_d10v_gc_sweep_hook
+#define elf_backend_check_relocs elf32_d10v_check_relocs
+#define elf_backend_relocate_section elf32_d10v_relocate_section
+#define elf_backend_can_gc_sections 1
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c
new file mode 100644
index 00000000000..0b0e9e9e6cd
--- /dev/null
+++ b/bfd/elf32-d30v.c
@@ -0,0 +1,601 @@
+/* D30V-specific support for 32-bit ELF
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Contributed by Martin Hunt (hunt@cygnus.com).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void d30v_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+static void d30v_info_to_howto_rela
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static bfd_reloc_status_type bfd_elf_d30v_reloc PARAMS ((
+ bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol,
+ PTR data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message));
+static bfd_reloc_status_type bfd_elf_d30v_reloc_21 PARAMS ((
+ bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol,
+ PTR data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message));
+
+enum reloc_type
+{
+ R_D30V_NONE = 0,
+ R_D30V_6,
+ R_D30V_9_PCREL,
+ R_D30V_9_PCREL_R,
+ R_D30V_15,
+ R_D30V_15_PCREL,
+ R_D30V_15_PCREL_R,
+ R_D30V_21,
+ R_D30V_21_PCREL,
+ R_D30V_21_PCREL_R,
+ R_D30V_32,
+ R_D30V_32_PCREL,
+ R_D30V_32_NORMAL,
+ R_D30V_max
+};
+
+static reloc_howto_type elf_d30v_howto_table[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_D30V_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D30V_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 6 bit absolute relocation */
+ HOWTO (R_D30V_6, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D30V_6", /* name */
+ false, /* partial_inplace */
+ 0x3f, /* src_mask */
+ 0x3f, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 9 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_9_PCREL, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc_21, /* special_function */
+ "R_D30V_9_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x3f, /* src_mask */
+ 0x3f, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 9 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_9_PCREL_R, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc_21, /* special_function */
+ "R_D30V_9_PCREL_R", /* name */
+ false, /* partial_inplace */
+ 0x3f, /* src_mask */
+ 0x3f, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* An absolute 15 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_15, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D30V_15", /* name */
+ false, /* partial_inplace */
+ 0xfff, /* src_mask */
+ 0xfff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 15 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_15_PCREL, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc_21, /* special_function */
+ "R_D30V_15_PCREL", /* name */
+ false, /* partial_inplace */
+ 0xfff, /* src_mask */
+ 0xfff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 15 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_15_PCREL_R, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc_21, /* special_function */
+ "R_D30V_15_PCREL_R", /* name */
+ false, /* partial_inplace */
+ 0xfff, /* src_mask */
+ 0xfff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* An absolute 21 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_21, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 18, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D30V_21", /* name */
+ false, /* partial_inplace */
+ 0x3ffff, /* src_mask */
+ 0x3ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 21 bit relocation, right shifted by 3 */
+ HOWTO (R_D30V_21_PCREL, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 18, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc_21, /* special_function */
+ "R_D30V_21_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x3ffff, /* src_mask */
+ 0x3ffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 21 bit relocation, right shifted by 3, in the Right container */
+ HOWTO (R_D30V_21_PCREL_R, /* type */
+ 3, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 18, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc_21, /* special_function */
+ "R_D30V_21_PCREL_R", /* name */
+ false, /* partial_inplace */
+ 0x3ffff, /* src_mask */
+ 0x3ffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A D30V 32 bit absolute relocation */
+ HOWTO (R_D30V_32, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_d30v_reloc, /* special_function */
+ "R_D30V_32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 32 bit relocation */
+ HOWTO (R_D30V_32_PCREL, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_d30v_reloc, /* special_function */
+ "R_D30V_32_PCREL", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A regular 32 bit absolute relocation */
+ HOWTO (R_D30V_32_NORMAL, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_D30V_32_NORMAL", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+#define MIN32 (long long)0xffffffff80000000LL
+#define MAX32 0x7fffffffLL
+
+static bfd_reloc_status_type
+bfd_elf_d30v_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ long long relocation;
+ bfd_vma in1, in2, num;
+ bfd_vma tmp_addr = 0;
+ bfd_reloc_status_type r;
+ asection *reloc_target_output_section;
+ bfd_size_type addr = reloc_entry->address;
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+ bfd_vma output_base = 0;
+ reloc_howto_type *howto = reloc_entry->howto;
+ int make_absolute = 0;
+
+ r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+ if (r != bfd_reloc_continue)
+ return r;
+
+ /* a hacked-up version of bfd_perform_reloc() follows */
+ if (bfd_is_und_section (symbol->section)
+ && (symbol->flags & BSF_WEAK) == 0
+ && output_bfd == (bfd *) NULL)
+ flag = bfd_reloc_undefined;
+
+ /* Is the address of the relocation really within the section? */
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ reloc_target_output_section = symbol->section->output_section;
+
+ /* Convert input-section-relative symbol value to absolute. */
+ if (output_bfd)
+ output_base = 0;
+ else
+ output_base = reloc_target_output_section->vma;
+
+ relocation += output_base + symbol->section->output_offset;
+
+ /* Add in supplied addend. */
+ relocation += reloc_entry->addend;
+
+ /* Here the variable relocation holds the final address of the
+ symbol we are relocating against, plus any addend. */
+
+ if (howto->pc_relative == true)
+ {
+ tmp_addr = input_section->output_section->vma + input_section->output_offset
+ + reloc_entry->address;
+ relocation -= tmp_addr;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ {
+ /* This is a partial relocation, and we want to apply the relocation
+ to the reloc entry rather than the raw data. Modify the reloc
+ inplace to reflect what we now know. */
+ reloc_entry->addend = relocation;
+ reloc_entry->address += input_section->output_offset;
+ return flag;
+ }
+ else
+ reloc_entry->addend = 0;
+
+ in1 = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ in2 = bfd_get_32 (abfd, (bfd_byte *) data + addr + 4);
+
+ /* extract the addend */
+ num = ((in2 & 0x3FFFF)
+ | ((in2 & 0xFF00000) >> 2)
+ | ((in1 & 0x3F) << 26));
+ in1 &= 0xFFFFFFC0;
+ in2 = 0x80000000;
+
+ relocation += num;
+
+ if (howto->pc_relative == true && howto->bitsize == 32)
+ {
+ /* the D30V has a PC that doesn't wrap and PC-relative jumps */
+ /* are signed, so a PC-relative jump can'tbe more than +/- 2^31 byrtes */
+ /* if one exceeds this, change it to an absolute jump */
+ if (relocation > MAX32)
+ {
+ relocation = (relocation + tmp_addr) & 0xffffffff;
+ make_absolute = 1;
+ }
+ else if (relocation < MIN32)
+ {
+ relocation = (relocation + tmp_addr) & 0xffffffff;
+ make_absolute = 1;
+ }
+ }
+
+ in1 |= (relocation >> 26) & 0x3F; /* top 6 bits */
+ in2 |= ((relocation & 0x03FC0000) << 2); /* next 8 bits */
+ in2 |= relocation & 0x0003FFFF; /* bottom 18 bits */
+
+ /* change a PC-relative instruction to its absolute equivalent */
+ /* with this simple hack */
+ if (make_absolute)
+ in1 |= 0x00100000;
+
+ bfd_put_32 (abfd, in1, (bfd_byte *) data + addr);
+ bfd_put_32 (abfd, in2, (bfd_byte *) data + addr + 4);
+
+ return flag;
+}
+
+
+static bfd_reloc_status_type
+bfd_elf_d30v_reloc_21 (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_vma in1, num;
+ bfd_reloc_status_type r;
+ asection *reloc_target_output_section;
+ bfd_size_type addr = reloc_entry->address;
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+ bfd_vma output_base = 0;
+ reloc_howto_type *howto = reloc_entry->howto;
+ int mask, max;
+
+ r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+ if (r != bfd_reloc_continue)
+ return r;
+
+ /* a hacked-up version of bfd_perform_reloc() follows */
+ if (bfd_is_und_section (symbol->section)
+ && (symbol->flags & BSF_WEAK) == 0
+ && output_bfd == (bfd *) NULL)
+ flag = bfd_reloc_undefined;
+
+ /* Is the address of the relocation really within the section? */
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ reloc_target_output_section = symbol->section->output_section;
+
+ /* Convert input-section-relative symbol value to absolute. */
+ if (output_bfd)
+ output_base = 0;
+ else
+ output_base = reloc_target_output_section->vma;
+
+ relocation += output_base + symbol->section->output_offset;
+
+ /* Add in supplied addend. */
+ relocation += reloc_entry->addend;
+
+ /* Here the variable relocation holds the final address of the
+ symbol we are relocating against, plus any addend. */
+
+ if (howto->pc_relative == true)
+ {
+ relocation -= input_section->output_section->vma + input_section->output_offset;
+ if (howto->pcrel_offset == true)
+ relocation -= reloc_entry->address;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ {
+ /* This is a partial relocation, and we want to apply the relocation
+ to the reloc entry rather than the raw data. Modify the reloc
+ inplace to reflect what we now know. */
+ reloc_entry->addend = relocation;
+ reloc_entry->address += input_section->output_offset;
+ return flag;
+ }
+ else
+ reloc_entry->addend = 0;
+
+ in1 = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+
+ mask = (1 << howto->bitsize) - 1;
+ if (howto->bitsize == 6)
+ mask <<= 12;
+ max = (1 << (howto->bitsize + 2)) - 1;
+
+ /* extract the addend */
+ num = in1 & mask; /* 18 bits */
+ if (howto->bitsize == 6)
+ num >>= 12;
+ num <<= 3; /* shift left 3 */
+ in1 &= ~mask; /* mask out addend */
+
+ relocation += num;
+ if (howto->type == R_D30V_21_PCREL_R || howto->type == R_D30V_15_PCREL_R ||
+ howto->type == R_D30V_9_PCREL_R )
+ {
+ relocation += 4;
+ }
+
+ if ((int)relocation < 0 )
+ {
+ if (~(int)relocation > max)
+ flag = bfd_reloc_overflow;
+ }
+ else
+ {
+ if ((int)relocation > max)
+ flag = bfd_reloc_overflow;
+ }
+ relocation >>= 3;
+ if (howto->bitsize == 6)
+ in1 |= ((relocation & (mask >> 12)) << 12);
+ else
+ in1 |= relocation & mask;
+
+ bfd_put_32 (abfd, in1, (bfd_byte *) data + addr);
+
+ return flag;
+}
+
+/* Map BFD reloc types to D30V ELF reloc types. */
+
+struct d30v_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+
+static const struct d30v_reloc_map d30v_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_D30V_NONE, },
+ { BFD_RELOC_D30V_6, R_D30V_6 },
+ { BFD_RELOC_D30V_9_PCREL, R_D30V_9_PCREL },
+ { BFD_RELOC_D30V_9_PCREL_R, R_D30V_9_PCREL_R },
+ { BFD_RELOC_D30V_15, R_D30V_15 },
+ { BFD_RELOC_D30V_15_PCREL, R_D30V_15_PCREL },
+ { BFD_RELOC_D30V_15_PCREL_R, R_D30V_15_PCREL_R },
+ { BFD_RELOC_D30V_21, R_D30V_21 },
+ { BFD_RELOC_D30V_21_PCREL, R_D30V_21_PCREL },
+ { BFD_RELOC_D30V_21_PCREL_R, R_D30V_21_PCREL_R },
+ { BFD_RELOC_D30V_32, R_D30V_32 },
+ { BFD_RELOC_D30V_32_PCREL, R_D30V_32_PCREL },
+ { BFD_RELOC_32, R_D30V_32_NORMAL },
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (d30v_reloc_map) / sizeof (struct d30v_reloc_map);
+ i++)
+ {
+ if (d30v_reloc_map[i].bfd_reloc_val == code)
+ return &elf_d30v_howto_table[d30v_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Set the howto pointer for an D30V ELF reloc (type REL). */
+
+static void
+d30v_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rel *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_D30V_max);
+ cache_ptr->howto = &elf_d30v_howto_table[r_type];
+}
+
+/* Set the howto pointer for an D30V ELF reloc (type RELA). */
+
+static void
+d30v_info_to_howto_rela (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_D30V_max);
+ cache_ptr->howto = &elf_d30v_howto_table[r_type];
+}
+
+#define ELF_ARCH bfd_arch_d30v
+#define ELF_MACHINE_CODE EM_CYGNUS_D30V
+#define ELF_MAXPAGESIZE 0x1000
+
+#define TARGET_BIG_SYM bfd_elf32_d30v_vec
+#define TARGET_BIG_NAME "elf32-d30v"
+
+#define elf_info_to_howto d30v_info_to_howto_rela
+#define elf_info_to_howto_rel d30v_info_to_howto_rel
+#define elf_backend_object_p 0
+#define elf_backend_final_write_processing 0
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c
new file mode 100644
index 00000000000..7c8725f5562
--- /dev/null
+++ b/bfd/elf32-fr30.c
@@ -0,0 +1,811 @@
+/* FR30-specific support for 32-bit ELF.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/fr30.h"
+
+/* Forward declarations. */
+static bfd_reloc_status_type fr30_elf_i20_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type fr30_elf_i32_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type * fr30_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void fr30_info_to_howto_rela
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static boolean fr30_elf_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static bfd_reloc_status_type fr30_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma));
+static boolean fr30_elf_gc_sweep_hook
+ PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
+static asection * fr30_elf_gc_mark_hook
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *));
+
+static reloc_howto_type fr30_elf_howto_table [] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_FR30_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_FR30_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An 8 bit absolute relocation. */
+ HOWTO (R_FR30_8, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 4, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_FR30_8", /* name */
+ true, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x0ff0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 20 bit absolute relocation. */
+ HOWTO (R_FR30_20, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 20, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ fr30_elf_i20_reloc, /* special_function */
+ "R_FR30_20", /* name */
+ true, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0x00f0ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 32 bit absolute relocation. */
+ HOWTO (R_FR30_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_FR30_32", /* name */
+ true, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 32 bit into 48 bits absolute relocation. */
+ HOWTO (R_FR30_48, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ fr30_elf_i32_reloc, /* special_function */
+ "R_FR30_48", /* name */
+ true, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 6 bit absolute relocation. */
+ HOWTO (R_FR30_6_IN_4, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ false, /* pc_relative */
+ 4, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_FR30_6_IN_4", /* name */
+ true, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x00f0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An 8 bit absolute relocation. */
+ HOWTO (R_FR30_8_IN_8, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 4, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc,/* special_function */
+ "R_FR30_8_IN_8", /* name */
+ true, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x0ff0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 9 bit absolute relocation. */
+ HOWTO (R_FR30_9_IN_8, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 9, /* bitsize */
+ false, /* pc_relative */
+ 4, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc,/* special_function */
+ "R_FR30_9_IN_8", /* name */
+ true, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x0ff0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 10 bit absolute relocation. */
+ HOWTO (R_FR30_10_IN_8, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 10, /* bitsize */
+ false, /* pc_relative */
+ 4, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc,/* special_function */
+ "R_FR30_10_IN_8", /* name */
+ true, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x0ff0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A PC relative 9 bit relocation, right shifted by 1. */
+ HOWTO (R_FR30_9_PCREL, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 9, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_FR30_9_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x00ff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A PC relative 12 bit relocation, right shifted by 1. */
+ HOWTO (R_FR30_12_PCREL, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_FR30_12_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x0000, /* src_mask */
+ 0x07ff, /* dst_mask */
+ false), /* pcrel_offset */
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_FR30_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_FR30_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_FR30_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_FR30_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+/* Utility to actually perform an R_FR30_20 reloc. */
+
+static bfd_reloc_status_type
+fr30_elf_i20_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd * abfd;
+ arelent * reloc_entry;
+ asymbol * symbol;
+ PTR data;
+ asection * input_section;
+ bfd * output_bfd;
+ char ** error_message;
+{
+ bfd_vma relocation;
+ unsigned long x;
+
+ /* This part is from bfd_elf_generic_reloc. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc_entry->howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != NULL)
+ /* FIXME: See bfd_perform_relocation. Is this right? */
+ return bfd_reloc_ok;
+
+ relocation =
+ symbol->value
+ + symbol->section->output_section->vma
+ + symbol->section->output_offset
+ + reloc_entry->addend;
+
+ if (relocation > ((1U << 20) - 1))
+ return bfd_reloc_overflow;
+
+ x = bfd_get_32 (abfd, data + reloc_entry->address);
+ x = (x & 0xff0f0000) | (relocation & 0x0000ffff) | ((relocation & 0x000f0000) << 4);
+ bfd_put_32 (abfd, x, data + reloc_entry->address);
+
+ return bfd_reloc_ok;
+}
+
+
+/* Utility to actually perform a R_FR30_48 reloc. */
+
+static bfd_reloc_status_type
+fr30_elf_i32_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd * abfd;
+ arelent * reloc_entry;
+ asymbol * symbol;
+ PTR data;
+ asection * input_section;
+ bfd * output_bfd;
+ char ** error_message;
+{
+ bfd_vma relocation;
+
+ /* This part is from bfd_elf_generic_reloc. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc_entry->howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != NULL)
+ /* FIXME: See bfd_perform_relocation. Is this right? */
+ return bfd_reloc_ok;
+
+ relocation =
+ symbol->value
+ + symbol->section->output_section->vma
+ + symbol->section->output_offset
+ + reloc_entry->addend;
+
+ bfd_put_32 (abfd, relocation, data + reloc_entry->address + 2);
+
+ return bfd_reloc_ok;
+}
+
+/* Map BFD reloc types to FR30 ELF reloc types. */
+
+struct fr30_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned int fr30_reloc_val;
+};
+
+static const struct fr30_reloc_map fr30_reloc_map [] =
+{
+ { BFD_RELOC_NONE, R_FR30_NONE },
+ { BFD_RELOC_8, R_FR30_8 },
+ { BFD_RELOC_FR30_20, R_FR30_20 },
+ { BFD_RELOC_32, R_FR30_32 },
+ { BFD_RELOC_FR30_48, R_FR30_48 },
+ { BFD_RELOC_FR30_6_IN_4, R_FR30_6_IN_4 },
+ { BFD_RELOC_FR30_8_IN_8, R_FR30_8_IN_8 },
+ { BFD_RELOC_FR30_9_IN_8, R_FR30_9_IN_8 },
+ { BFD_RELOC_FR30_10_IN_8, R_FR30_10_IN_8 },
+ { BFD_RELOC_FR30_9_PCREL, R_FR30_9_PCREL },
+ { BFD_RELOC_FR30_12_PCREL, R_FR30_12_PCREL },
+ { BFD_RELOC_VTABLE_INHERIT, R_FR30_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_FR30_GNU_VTENTRY },
+};
+
+static reloc_howto_type *
+fr30_reloc_type_lookup (abfd, code)
+ bfd * abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = sizeof (fr30_reloc_map) / sizeof (fr30_reloc_map[0]);
+ --i;)
+ if (fr30_reloc_map [i].bfd_reloc_val == code)
+ return & fr30_elf_howto_table [fr30_reloc_map[i].fr30_reloc_val];
+
+ return NULL;
+}
+
+/* Set the howto pointer for an FR30 ELF reloc. */
+
+static void
+fr30_info_to_howto_rela (abfd, cache_ptr, dst)
+ bfd * abfd;
+ arelent * cache_ptr;
+ Elf32_Internal_Rela * dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_FR30_max);
+ cache_ptr->howto = & fr30_elf_howto_table [r_type];
+}
+
+/* Perform a single relocation. By default we use the standard BFD
+ routines, but a few relocs, we have to do them ourselves. */
+
+static bfd_reloc_status_type
+fr30_final_link_relocate (howto, input_bfd, input_section, contents, rel, relocation)
+ reloc_howto_type * howto;
+ bfd * input_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ Elf_Internal_Rela * rel;
+ bfd_vma relocation;
+{
+ bfd_reloc_status_type r = bfd_reloc_ok;
+ bfd_vma x;
+ bfd_signed_vma srel;
+
+ switch (howto->type)
+ {
+ case R_FR30_20:
+ contents += rel->r_offset;
+ relocation += rel->r_addend;
+
+ if (relocation > ((1 << 20) - 1))
+ return bfd_reloc_overflow;
+
+ x = bfd_get_32 (input_bfd, contents);
+ x = (x & 0xff0f0000) | (relocation & 0x0000ffff) | ((relocation & 0x000f0000) << 4);
+ bfd_put_32 (input_bfd, x, contents);
+ break;
+
+ case R_FR30_48:
+ contents += rel->r_offset + 2;
+ relocation += rel->r_addend;
+ bfd_put_32 (input_bfd, relocation, contents);
+ break;
+
+ case R_FR30_9_PCREL:
+ contents += rel->r_offset + 1;
+ srel = (bfd_signed_vma) relocation;
+ srel += rel->r_addend;
+ srel -= rel->r_offset;
+ srel -= 2; /* Branch instructions add 2 to the PC... */
+ srel -= (input_section->output_section->vma +
+ input_section->output_offset);
+
+ if (srel & 1)
+ return bfd_reloc_outofrange;
+ if (srel > ((1 << 8) - 1) || (srel < - (1 << 8)))
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (input_bfd, srel >> 1, contents);
+ break;
+
+ case R_FR30_12_PCREL:
+ contents += rel->r_offset;
+ srel = (bfd_signed_vma) relocation;
+ srel += rel->r_addend;
+ srel -= rel->r_offset;
+ srel -= 2; /* Branch instructions add 2 to the PC... */
+ srel -= (input_section->output_section->vma +
+ input_section->output_offset);
+
+ if (srel & 1)
+ return bfd_reloc_outofrange;
+ if (srel > ((1 << 11) - 1) || (srel < - (1 << 11)))
+ return bfd_reloc_overflow;
+
+ x = bfd_get_16 (input_bfd, contents);
+ x = (x & 0xf800) | ((srel >> 1) & 0x7ff);
+ bfd_put_16 (input_bfd, x, contents);
+ break;
+
+ default:
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+ }
+
+ return r;
+}
+
+
+/* Relocate an FR30 ELF section.
+ There is some attempt to make this function usable for many architectures,
+ both USE_REL and USE_RELA ['twould be nice if such a critter existed],
+ if only to serve as a learning tool.
+
+ The RELOCATE_SECTION function is called by the new ELF backend linker
+ to handle the relocations for a section.
+
+ The relocs are always passed as Rela structures; if the section
+ actually uses Rel structures, the r_addend field will always be
+ zero.
+
+ This function is responsible for adjusting the section contents as
+ necessary, and (if using Rela relocs and generating a relocateable
+ output file) adjusting the reloc addend as necessary.
+
+ This function does not have to worry about setting the reloc
+ address or the reloc symbol index.
+
+ LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+ LOCAL_SECTIONS is an array giving the section in the input file
+ corresponding to the st_shndx field of each local symbol.
+
+ The global hash table entry for the global symbols can be found
+ via elf_sym_hashes (input_bfd).
+
+ When generating relocateable output, this function must handle
+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
+ going to be the section symbol corresponding to the output
+ section, which means that the addend must be adjusted
+ accordingly. */
+
+static boolean
+fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+ bfd * input_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ Elf_Internal_Rela * relocs;
+ Elf_Internal_Sym * local_syms;
+ asection ** local_sections;
+{
+ Elf_Internal_Shdr * symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes;
+ Elf_Internal_Rela * rel;
+ Elf_Internal_Rela * relend;
+
+ symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ relend = relocs + input_section->reloc_count;
+
+ for (rel = relocs; rel < relend; rel ++)
+ {
+ reloc_howto_type * howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym * sym;
+ asection * sec;
+ struct elf_link_hash_entry * h;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+ const char * name = NULL;
+ int r_type;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ if ( r_type == R_FR30_GNU_VTINHERIT
+ || r_type == R_FR30_GNU_VTENTRY)
+ continue;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections [r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ howto = fr30_elf_howto_table + ELF32_R_TYPE (rel->r_info);
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections [r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+
+ name = bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name);
+ name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+#if 0
+ fprintf (stderr, "local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
+ sec->name, name, sym->st_name,
+ sec->output_section->vma, sec->output_offset,
+ sym->st_value, rel->r_addend);
+#endif
+ }
+ else
+ {
+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ name = h->root.root.string;
+
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+#if 0
+ fprintf (stderr,
+ "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
+ sec->name, name, h->root.u.def.value,
+ sec->output_section->vma, sec->output_offset, relocation);
+#endif
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ {
+#if 0
+ fprintf (stderr, "undefined: sec: %s, name: %s\n",
+ sec->name, name);
+#endif
+ relocation = 0;
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+#if 0
+ fprintf (stderr, "unknown: name: %s\n", name);
+#endif
+ relocation = 0;
+ }
+ }
+
+ r = fr30_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel, relocation);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char * msg = (const char *) NULL;
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ r = info->callbacks->reloc_overflow
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset);
+ break;
+
+ case bfd_reloc_undefined:
+ r = info->callbacks->undefined_symbol
+ (info, name, input_bfd, input_section, rel->r_offset);
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _("internal error: out of range error");
+ break;
+
+ case bfd_reloc_notsupported:
+ msg = _("internal error: unsupported relocation error");
+ break;
+
+ case bfd_reloc_dangerous:
+ msg = _("internal error: dangerous relocation");
+ break;
+
+ default:
+ msg = _("internal error: unknown error");
+ break;
+ }
+
+ if (msg)
+ r = info->callbacks->warning
+ (info, msg, name, input_bfd, input_section, rel->r_offset);
+
+ if (! r)
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+fr30_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ Elf_Internal_Rela * rel;
+ struct elf_link_hash_entry * h;
+ Elf_Internal_Sym * sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_FR30_GNU_VTINHERIT:
+ case R_FR30_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+fr30_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ asection * sec;
+ const Elf_Internal_Rela * relocs;
+{
+ return true;
+}
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+fr30_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+
+ if (info->relocateable)
+ return true;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry *h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_FR30_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_FR30_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+#define ELF_ARCH bfd_arch_fr30
+#define ELF_MACHINE_CODE EM_CYGNUS_FR30
+#define ELF_MAXPAGESIZE 0x1000
+
+#define TARGET_BIG_SYM bfd_elf32_fr30_vec
+#define TARGET_BIG_NAME "elf32-fr30"
+
+#define elf_info_to_howto_rel NULL
+#define elf_info_to_howto fr30_info_to_howto_rela
+#define elf_backend_relocate_section fr30_elf_relocate_section
+#define elf_backend_gc_mark_hook fr30_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook fr30_elf_gc_sweep_hook
+#define elf_backend_check_relocs fr30_elf_check_relocs
+
+#define elf_backend_can_gc_sections 1
+
+#define bfd_elf32_bfd_reloc_type_lookup fr30_reloc_type_lookup
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c
new file mode 100644
index 00000000000..a4d3cac0850
--- /dev/null
+++ b/bfd/elf32-gen.c
@@ -0,0 +1,71 @@
+/* Generic support for 32-bit ELF
+ Copyright 1993, 1995, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* This does not include any relocation information, but should be
+ good enough for GDB or objdump to read the file. */
+
+static reloc_howto_type dummy =
+ HOWTO (0, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "UNKNOWN", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false); /* pcrel_offset */
+
+static void
+elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc)
+ bfd *abfd;
+ arelent *bfd_reloc;
+ Elf32_Internal_Rela *elf_reloc;
+{
+ bfd_reloc->howto = &dummy;
+}
+
+static void
+elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
+ bfd *abfd;
+ arelent *bfd_reloc;
+ Elf32_Internal_Rel *elf_reloc;
+{
+ bfd_reloc->howto = &dummy;
+}
+
+#define TARGET_LITTLE_SYM bfd_elf32_little_generic_vec
+#define TARGET_LITTLE_NAME "elf32-little"
+#define TARGET_BIG_SYM bfd_elf32_big_generic_vec
+#define TARGET_BIG_NAME "elf32-big"
+#define ELF_ARCH bfd_arch_unknown
+#define ELF_MACHINE_CODE EM_NONE
+#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+#define elf_info_to_howto elf_generic_info_to_howto
+#define elf_info_to_howto_rel elf_generic_info_to_howto_rel
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
new file mode 100644
index 00000000000..6bd7f67a0ab
--- /dev/null
+++ b/bfd/elf32-hppa.c
@@ -0,0 +1,2988 @@
+/* BFD back-end for HP PA-RISC ELF files.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997
+ Free Software Foundation, Inc.
+
+ Written by
+
+ Center for Software Science
+ Department of Computer Science
+ University of Utah
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* The internal type of a symbol table extension entry. */
+typedef unsigned long symext_entryS;
+
+/* The external type of a symbol table extension entry. */
+#define ELF32_PARISC_SX_SIZE (4)
+#define ELF32_PARISC_SX_GET(bfd, addr) bfd_h_get_32 ((bfd), (addr))
+#define ELF32_PARISC_SX_PUT(bfd, val, addr) \
+ bfd_h_put_32 ((bfd), (val), (addr))
+
+/* HPPA symbol table extension entry types */
+enum elf32_hppa_symextn_types
+{
+ PARISC_SXT_NULL,
+ PARISC_SXT_SYMNDX,
+ PARISC_SXT_ARG_RELOC,
+};
+
+/* These macros compose and decompose the value of a symextn entry:
+
+ entry_type = ELF32_PARISC_SX_TYPE(word);
+ entry_value = ELF32_PARISC_SX_VAL(word);
+ word = ELF32_PARISC_SX_WORD(type,val); */
+
+#define ELF32_PARISC_SX_TYPE(p) ((p) >> 24)
+#define ELF32_PARISC_SX_VAL(p) ((p) & 0xFFFFFF)
+#define ELF32_PARISC_SX_WORD(type,val) (((type) << 24) + (val & 0xFFFFFF))
+
+/* The following was added facilitate implementation of the .hppa_symextn
+ section. This section is built after the symbol table is built in the
+ elf_write_object_contents routine (called from bfd_close). It is built
+ so late because it requires information that is not known until
+ the symbol and string table sections have been allocated, and
+ the symbol table has been built. */
+
+#define SYMEXTN_SECTION_NAME ".PARISC.symext"
+
+struct symext_chain
+ {
+ symext_entryS entry;
+ struct symext_chain *next;
+ };
+
+typedef struct symext_chain symext_chainS;
+
+/* We use three different hash tables to hold information for
+ linking PA ELF objects.
+
+ The first is the elf32_hppa_link_hash_table which is derived
+ from the standard ELF linker hash table. We use this as a place to
+ attach other hash tables and static information.
+
+ The second is the stub hash table which is derived from the
+ base BFD hash table. The stub hash table holds the information
+ necessary to build the linker stubs during a link.
+
+ The last hash table keeps track of argument location information needed
+ to build hash tables. Each function with nonzero argument location
+ bits will have an entry in this table. */
+
+/* Hash table for linker stubs. */
+
+struct elf32_hppa_stub_hash_entry
+{
+ /* Base hash table entry structure, we can get the name of the stub
+ (and thus know exactly what actions it performs) from the base
+ hash table entry. */
+ struct bfd_hash_entry root;
+
+ /* Offset of the beginning of this stub. */
+ bfd_vma offset;
+
+ /* Given the symbol's value and its section we can determine its final
+ value when building the stubs (so the stub knows where to jump. */
+ symvalue target_value;
+ asection *target_section;
+};
+
+struct elf32_hppa_stub_hash_table
+{
+ /* The hash table itself. */
+ struct bfd_hash_table root;
+
+ /* The stub BFD. */
+ bfd *stub_bfd;
+
+ /* Where to place the next stub. */
+ bfd_byte *location;
+
+ /* Current offset in the stub section. */
+ unsigned int offset;
+
+};
+
+/* Hash table for argument location information. */
+
+struct elf32_hppa_args_hash_entry
+{
+ /* Base hash table entry structure. */
+ struct bfd_hash_entry root;
+
+ /* The argument location bits for this entry. */
+ int arg_bits;
+};
+
+struct elf32_hppa_args_hash_table
+{
+ /* The hash table itself. */
+ struct bfd_hash_table root;
+};
+
+struct elf32_hppa_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+};
+
+struct elf32_hppa_link_hash_table
+{
+ /* The main hash table. */
+ struct elf_link_hash_table root;
+
+ /* The stub hash table. */
+ struct elf32_hppa_stub_hash_table *stub_hash_table;
+
+ /* The argument relocation bits hash table. */
+ struct elf32_hppa_args_hash_table *args_hash_table;
+
+ /* A count of the number of output symbols. */
+ unsigned int output_symbol_count;
+
+ /* Stuff so we can handle DP relative relocations. */
+ long global_value;
+ int global_sym_defined;
+};
+
+/* FIXME. */
+#define ARGUMENTS 0
+#define RETURN_VALUE 1
+
+/* The various argument relocations that may be performed. */
+typedef enum
+{
+ /* No relocation. */
+ NO,
+ /* Relocate 32 bits from GR to FP register. */
+ GF,
+ /* Relocate 64 bits from a GR pair to FP pair. */
+ GD,
+ /* Relocate 32 bits from FP to GR. */
+ FG,
+ /* Relocate 64 bits from FP pair to GR pair. */
+ DG,
+} arg_reloc_type;
+
+/* What is being relocated (eg which argument or the return value). */
+typedef enum
+{
+ ARG0, ARG1, ARG2, ARG3, RET,
+} arg_reloc_location;
+
+
+/* ELF32/HPPA relocation support
+
+ This file contains ELF32/HPPA relocation support as specified
+ in the Stratus FTX/Golf Object File Format (SED-1762) dated
+ February 1994. */
+
+#include "elf32-hppa.h"
+#include "hppa_stubs.h"
+
+static bfd_reloc_status_type hppa_elf_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+
+static unsigned long hppa_elf_relocate_insn
+ PARAMS ((bfd *, asection *, unsigned long, unsigned long, long,
+ long, unsigned long, unsigned long, unsigned long));
+
+static bfd_reloc_status_type hppa_elf_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd*, char **));
+
+static reloc_howto_type * elf_hppa_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+
+static boolean elf32_hppa_set_section_contents
+ PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
+
+static void elf32_hppa_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+
+static boolean elf32_hppa_backend_symbol_table_processing
+ PARAMS ((bfd *, elf_symbol_type *, unsigned int));
+
+static void elf32_hppa_backend_begin_write_processing
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+static void elf32_hppa_backend_final_write_processing
+ PARAMS ((bfd *, boolean));
+
+static void add_entry_to_symext_chain
+ PARAMS ((bfd *, unsigned int, unsigned int, symext_chainS **,
+ symext_chainS **));
+
+static void
+elf_hppa_tc_make_sections PARAMS ((bfd *, symext_chainS *));
+
+static boolean hppa_elf_is_local_label_name PARAMS ((bfd *, const char *));
+
+static boolean elf32_hppa_add_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+ const char **, flagword *, asection **, bfd_vma *));
+
+static bfd_reloc_status_type elf32_hppa_bfd_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *,
+ bfd_byte *, bfd_vma, bfd_vma, bfd_vma, struct bfd_link_info *,
+ asection *, const char *, int));
+
+static struct bfd_link_hash_table *elf32_hppa_link_hash_table_create
+ PARAMS ((bfd *));
+
+static struct bfd_hash_entry *
+elf32_hppa_stub_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+static struct bfd_hash_entry *
+elf32_hppa_args_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+static boolean
+elf32_hppa_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
+ bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+
+static boolean
+elf32_hppa_stub_hash_table_init
+ PARAMS ((struct elf32_hppa_stub_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *))));
+
+static boolean
+elf32_hppa_build_one_stub PARAMS ((struct bfd_hash_entry *, PTR));
+
+static boolean
+elf32_hppa_read_symext_info
+ PARAMS ((bfd *, Elf_Internal_Shdr *, struct elf32_hppa_args_hash_table *,
+ Elf_Internal_Sym *));
+
+static unsigned int elf32_hppa_size_of_stub
+ PARAMS ((unsigned int, unsigned int, bfd_vma, bfd_vma, const char *));
+
+static boolean elf32_hppa_arg_reloc_needed
+ PARAMS ((unsigned int, unsigned int, arg_reloc_type []));
+
+static void elf32_hppa_name_of_stub
+ PARAMS ((unsigned int, unsigned int, bfd_vma, bfd_vma, char *));
+
+static boolean elf32_hppa_size_symext PARAMS ((struct bfd_hash_entry *, PTR));
+
+static boolean elf32_hppa_link_output_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const char *,
+ Elf_Internal_Sym *, asection *));
+
+/* ELF/PA relocation howto entries. */
+
+static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
+{
+ {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_NONE"},
+ /* The values in DIR32 are to placate the check in
+ _bfd_stab_section_find_nearest_line. */
+ {R_PARISC_DIR32, 0, 2, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false},
+ {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR21L"},
+ {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17R"},
+ {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17F"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR14R"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL21L"},
+ {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17R"},
+ {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17F"},
+ {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17C"},
+ {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL14R"},
+ {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL14F"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL21L"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL14R"},
+ {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL14F"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL21L"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL14R"},
+ {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL14F"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND21L"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND14R"},
+ {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND14F"},
+
+ {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_SETBASE"},
+ {R_PARISC_BASEREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL32"},
+ {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL21L"},
+ {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL17R"},
+ {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL17F"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL14R"},
+ {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL14F"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_TEXTREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_TEXTREL32"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_DATAREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL32"},
+ {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL21L"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL14R"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_PLTIND21L, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND21L"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
+ {R_PARISC_PLTIND14R, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND14R"},
+ {R_PARISC_PLTIND14F, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND14F"},
+
+
+ {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_COPY"},
+ {R_PARISC_GLOB_DAT, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_GLOB_DAT"},
+ {R_PARISC_JMP_SLOT, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_JMP_SLOT"},
+ {R_PARISC_RELATIVE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_RELATIVE"},
+
+ {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
+};
+
+/* Where (what register type) is an argument comming from? */
+typedef enum
+{
+ AR_NO,
+ AR_GR,
+ AR_FR,
+ AR_FU,
+ AR_FPDBL1,
+ AR_FPDBL2,
+} arg_location;
+
+/* Horizontal represents the callee's argument location information,
+ vertical represents caller's argument location information. Value at a
+ particular X,Y location represents what (if any) argument relocation
+ needs to be performed to make caller and callee agree. */
+
+static CONST arg_reloc_type arg_mismatches[6][6] =
+{
+ {NO, NO, NO, NO, NO, NO},
+ {NO, NO, GF, NO, GD, NO},
+ {NO, FG, NO, NO, NO, NO},
+ {NO, NO, NO, NO, NO, NO},
+ {NO, DG, NO, NO, NO, NO},
+ {NO, DG, NO, NO, NO, NO},
+};
+
+/* Likewise, but reversed for the return value. */
+static CONST arg_reloc_type ret_mismatches[6][6] =
+{
+ {NO, NO, NO, NO, NO, NO},
+ {NO, NO, FG, NO, DG, NO},
+ {NO, GF, NO, NO, NO, NO},
+ {NO, NO, NO, NO, NO, NO},
+ {NO, GD, NO, NO, NO, NO},
+ {NO, GD, NO, NO, NO, NO},
+};
+
+/* Misc static crud for symbol extension records. */
+static symext_chainS *symext_rootP;
+static symext_chainS *symext_lastP;
+static bfd_size_type symext_chain_size;
+
+/* FIXME: We should be able to try this static variable! */
+static bfd_byte *symextn_contents;
+
+
+/* For linker stub hash tables. */
+#define elf32_hppa_stub_hash_lookup(table, string, create, copy) \
+ ((struct elf32_hppa_stub_hash_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+#define elf32_hppa_stub_hash_traverse(table, func, info) \
+ (bfd_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* For linker args hash tables. */
+#define elf32_hppa_args_hash_lookup(table, string, create, copy) \
+ ((struct elf32_hppa_args_hash_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+#define elf32_hppa_args_hash_traverse(table, func, info) \
+ (bfd_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \
+ (info)))
+
+#define elf32_hppa_args_hash_table_init(table, newfunc) \
+ (bfd_hash_table_init \
+ (&(table)->root, \
+ (struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *, \
+ struct bfd_hash_table *, \
+ const char *))) (newfunc)))
+
+/* For HPPA linker hash table. */
+
+#define elf32_hppa_link_hash_lookup(table, string, create, copy, follow)\
+ ((struct elf32_hppa_link_hash_entry *) \
+ elf_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+#define elf32_hppa_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the PA ELF linker hash table from a link_info structure. */
+
+#define elf32_hppa_hash_table(p) \
+ ((struct elf32_hppa_link_hash_table *) ((p)->hash))
+
+
+/* Extract specific argument location bits for WHICH from
+ the full argument location in AR. */
+#define EXTRACT_ARBITS(ar, which) ((ar) >> (8 - ((which) * 2))) & 3
+
+/* Assorted hash table functions. */
+
+/* Initialize an entry in the stub hash table. */
+
+static struct bfd_hash_entry *
+elf32_hppa_stub_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct elf32_hppa_stub_hash_entry *ret;
+
+ ret = (struct elf32_hppa_stub_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == NULL)
+ ret = ((struct elf32_hppa_stub_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct elf32_hppa_stub_hash_entry)));
+ if (ret == NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct elf32_hppa_stub_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ ret->offset = 0;
+ ret->target_value = 0;
+ ret->target_section = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize a stub hash table. */
+
+static boolean
+elf32_hppa_stub_hash_table_init (table, stub_bfd, newfunc)
+ struct elf32_hppa_stub_hash_table *table;
+ bfd *stub_bfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ table->offset = 0;
+ table->location = 0;
+ table->stub_bfd = stub_bfd;
+ return (bfd_hash_table_init (&table->root, newfunc));
+}
+
+/* Initialize an entry in the argument location hash table. */
+
+static struct bfd_hash_entry *
+elf32_hppa_args_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct elf32_hppa_args_hash_entry *ret;
+
+ ret = (struct elf32_hppa_args_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == NULL)
+ ret = ((struct elf32_hppa_args_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct elf32_hppa_args_hash_entry)));
+ if (ret == NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct elf32_hppa_args_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ /* Initialize the local fields. */
+ if (ret)
+ ret->arg_bits = 0;
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create the derived linker hash table. The PA ELF port uses the derived
+ hash table to keep information specific to the PA ELF linker (without
+ using static variables). */
+
+static struct bfd_link_hash_table *
+elf32_hppa_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf32_hppa_link_hash_table *ret;
+
+ ret = ((struct elf32_hppa_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf32_hppa_link_hash_table)));
+ if (ret == NULL)
+ return NULL;
+ if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+ _bfd_elf_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+ ret->stub_hash_table = NULL;
+ ret->args_hash_table = NULL;
+ ret->output_symbol_count = 0;
+ ret->global_value = 0;
+ ret->global_sym_defined = 0;
+
+ return &ret->root.root;
+}
+
+/* Relocate the given INSN given the various input parameters.
+
+ FIXME: endianness and sizeof (long) issues abound here. */
+
+static unsigned long
+hppa_elf_relocate_insn (abfd, input_sect, insn, address, sym_value,
+ r_addend, r_format, r_field, pcrel)
+ bfd *abfd;
+ asection *input_sect;
+ unsigned long insn;
+ unsigned long address;
+ long sym_value;
+ long r_addend;
+ unsigned long r_format;
+ unsigned long r_field;
+ unsigned long pcrel;
+{
+ unsigned char opcode = get_opcode (insn);
+ long constant_value;
+
+ switch (opcode)
+ {
+ case LDO:
+ case LDB:
+ case LDH:
+ case LDW:
+ case LDWM:
+ case STB:
+ case STH:
+ case STW:
+ case STWM:
+ case COMICLR:
+ case SUBI:
+ case ADDIT:
+ case ADDI:
+ case LDIL:
+ case ADDIL:
+ constant_value = HPPA_R_CONSTANT (r_addend);
+
+ if (pcrel)
+ sym_value -= address;
+
+ sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
+ return hppa_rebuild_insn (abfd, insn, sym_value, r_format);
+
+ case BL:
+ case BE:
+ case BLE:
+ /* XXX computing constant_value is not needed??? */
+ constant_value = assemble_17 ((insn & 0x001f0000) >> 16,
+ (insn & 0x00001ffc) >> 2,
+ insn & 1);
+
+ constant_value = (constant_value << 15) >> 15;
+ if (pcrel)
+ {
+ sym_value -=
+ address + input_sect->output_offset
+ + input_sect->output_section->vma;
+ sym_value = hppa_field_adjust (sym_value, -8, r_field);
+ }
+ else
+ sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
+
+ return hppa_rebuild_insn (abfd, insn, sym_value >> 2, r_format);
+
+ default:
+ if (opcode == 0)
+ {
+ constant_value = HPPA_R_CONSTANT (r_addend);
+
+ if (pcrel)
+ sym_value -= address;
+
+ return hppa_field_adjust (sym_value, constant_value, r_field);
+ }
+ else
+ abort ();
+ }
+}
+
+/* Relocate an HPPA ELF section. */
+
+static boolean
+elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sym_sec;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+ const char *sym_name;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+ if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ howto = elf_hppa_howto_table + r_type;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sym_sec = local_sections[r_symndx];
+ rel->r_addend += sym_sec->output_offset;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sym_sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sym_sec = local_sections[r_symndx];
+ relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
+ ? 0 : sym->st_value)
+ + sym_sec->output_offset
+ + sym_sec->output_section->vma);
+ }
+ else
+ {
+ long indx;
+
+ indx = r_symndx - symtab_hdr->sh_info;
+ h = elf_sym_hashes (input_bfd)[indx];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sym_sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sym_sec->output_offset
+ + sym_sec->output_section->vma);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (!((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ break;
+ }
+ }
+
+ if (h != NULL)
+ sym_name = h->root.root.string;
+ else
+ {
+ sym_name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (sym_name == NULL)
+ return false;
+ if (*sym_name == '\0')
+ sym_name = bfd_section_name (input_bfd, sym_sec);
+ }
+
+ /* If args_hash_table is NULL, then we have encountered some
+ kind of link error (ex. undefined symbols). Do not try to
+ apply any relocations, continue the loop so we can notify
+ the user of several errors in a single attempted link. */
+ if (elf32_hppa_hash_table (info)->args_hash_table == NULL)
+ continue;
+
+ r = elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents,
+ rel->r_offset, relocation,
+ rel->r_addend, info, sym_sec,
+ sym_name, h == NULL);
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ /* This can happen for DP relative relocs if $global$ is
+ undefined. This is a panic situation so we don't try
+ to continue. */
+ case bfd_reloc_undefined:
+ case bfd_reloc_notsupported:
+ if (!((*info->callbacks->undefined_symbol)
+ (info, "$global$", input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ return false;
+ case bfd_reloc_dangerous:
+ {
+ /* We use this return value to indicate that we performed
+ a "dangerous" relocation. This doesn't mean we did
+ the wrong thing, it just means there may be some cleanup
+ that needs to be done here.
+
+ In particular we had to swap the last call insn and its
+ delay slot. If the delay slot insn needed a relocation,
+ then we'll need to adjust the next relocation entry's
+ offset to account for the fact that the insn moved.
+
+ This hair wouldn't be necessary if we inserted stubs
+ between procedures and used a "bl" to get to the stub. */
+ if (rel != relend)
+ {
+ Elf_Internal_Rela *next_rel = rel + 1;
+
+ if (rel->r_offset + 4 == next_rel->r_offset)
+ next_rel->r_offset -= 4;
+ }
+ break;
+ }
+ default:
+ case bfd_reloc_outofrange:
+ case bfd_reloc_overflow:
+ {
+ if (!((*info->callbacks->reloc_overflow)
+ (info, sym_name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Return one (or more) BFD relocations which implement the base
+ relocation with modifications based on format and field. */
+
+elf32_hppa_reloc_type **
+hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
+ bfd *abfd;
+ elf32_hppa_reloc_type base_type;
+ int format;
+ int field;
+ int ignore;
+ asymbol *sym;
+{
+ elf32_hppa_reloc_type *finaltype;
+ elf32_hppa_reloc_type **final_types;
+
+ /* Allocate slots for the BFD relocation. */
+ final_types = ((elf32_hppa_reloc_type **)
+ bfd_alloc (abfd, sizeof (elf32_hppa_reloc_type *) * 2));
+ if (final_types == NULL)
+ return NULL;
+
+ /* Allocate space for the relocation itself. */
+ finaltype = ((elf32_hppa_reloc_type *)
+ bfd_alloc (abfd, sizeof (elf32_hppa_reloc_type)));
+ if (finaltype == NULL)
+ return NULL;
+
+ /* Some reasonable defaults. */
+ final_types[0] = finaltype;
+ final_types[1] = NULL;
+
+#define final_type finaltype[0]
+
+ final_type = base_type;
+
+ /* Just a tangle of nested switch statements to deal with the braindamage
+ that a different field selector means a completely different relocation
+ for PA ELF. */
+ switch (base_type)
+ {
+ case R_HPPA:
+ case R_HPPA_ABS_CALL:
+ switch (format)
+ {
+ case 14:
+ switch (field)
+ {
+ case e_rsel:
+ case e_rrsel:
+ final_type = R_PARISC_DIR14R;
+ break;
+ case e_rtsel:
+ final_type = R_PARISC_DLTREL14R;
+ break;
+ case e_tsel:
+ final_type = R_PARISC_DLTREL14F;
+ break;
+ case e_rpsel:
+ final_type = R_PARISC_PLABEL14R;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ case 17:
+ switch (field)
+ {
+ case e_fsel:
+ final_type = R_PARISC_DIR17F;
+ break;
+ case e_rsel:
+ case e_rrsel:
+ final_type = R_PARISC_DIR17R;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ case 21:
+ switch (field)
+ {
+ case e_lsel:
+ case e_lrsel:
+ final_type = R_PARISC_DIR21L;
+ break;
+ case e_ltsel:
+ final_type = R_PARISC_DLTREL21L;
+ break;
+ case e_lpsel:
+ final_type = R_PARISC_PLABEL21L;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ case 32:
+ switch (field)
+ {
+ case e_fsel:
+ final_type = R_PARISC_DIR32;
+ break;
+ case e_psel:
+ final_type = R_PARISC_PLABEL32;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ default:
+ return NULL;
+ }
+ break;
+
+
+ case R_HPPA_GOTOFF:
+ switch (format)
+ {
+ case 14:
+ switch (field)
+ {
+ case e_rsel:
+ case e_rrsel:
+ final_type = R_PARISC_DPREL14R;
+ break;
+ case e_fsel:
+ final_type = R_PARISC_DPREL14F;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ case 21:
+ switch (field)
+ {
+ case e_lrsel:
+ case e_lsel:
+ final_type = R_PARISC_DPREL21L;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ default:
+ return NULL;
+ }
+ break;
+
+
+ case R_HPPA_PCREL_CALL:
+ switch (format)
+ {
+ case 14:
+ switch (field)
+ {
+ case e_rsel:
+ case e_rrsel:
+ final_type = R_PARISC_PCREL14R;
+ break;
+ case e_fsel:
+ final_type = R_PARISC_PCREL14F;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ case 17:
+ switch (field)
+ {
+ case e_rsel:
+ case e_rrsel:
+ final_type = R_PARISC_PCREL17R;
+ break;
+ case e_fsel:
+ final_type = R_PARISC_PCREL17F;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ case 21:
+ switch (field)
+ {
+ case e_lsel:
+ case e_lrsel:
+ final_type = R_PARISC_PCREL21L;
+ break;
+ default:
+ return NULL;
+ }
+ break;
+
+ default:
+ return NULL;
+ }
+ break;
+
+ default:
+ return NULL;
+ }
+
+ return final_types;
+}
+
+#undef final_type
+
+/* Set the contents of a particular section at a particular location. */
+
+static boolean
+elf32_hppa_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ /* Ignore write requests for the symbol extension section until we've
+ had the chance to rebuild it ourselves. */
+ if (!strcmp (section->name, ".PARISC.symextn") && !symext_chain_size)
+ return true;
+ else
+ return _bfd_elf_set_section_contents (abfd, section, location,
+ offset, count);
+}
+
+/* Translate from an elf into field into a howto relocation pointer. */
+
+static void
+elf32_hppa_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_PARISC_UNIMPLEMENTED);
+ cache_ptr->howto = &elf_hppa_howto_table[ELF32_R_TYPE (dst->r_info)];
+}
+
+
+/* Actually perform a relocation. NOTE this is (mostly) superceeded
+ by elf32_hppa_bfd_final_link_relocate which is called by the new
+ fast linker. */
+
+static bfd_reloc_status_type
+hppa_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* It is no longer valid to call hppa_elf_reloc when creating
+ a final executable. */
+ if (output_bfd)
+ {
+ reloc_entry->address += input_section->output_offset;
+
+ /* Work around lossage in generic elf code to write relocations.
+ (maps different section symbols into the same symbol index). */
+ if ((symbol_in->flags & BSF_SECTION_SYM)
+ && symbol_in->section)
+ reloc_entry->addend += symbol_in->section->output_offset;
+ return bfd_reloc_ok;
+ }
+ else
+ {
+ *error_message = (char *) _("Unsupported call to hppa_elf_reloc");
+ return bfd_reloc_notsupported;
+ }
+}
+
+/* Actually perform a relocation as part of a final link. This can get
+ rather hairy when linker stubs are needed. */
+
+static bfd_reloc_status_type
+elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, offset, value,
+ addend, info, sym_sec, sym_name, is_local)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd *output_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ bfd_vma offset;
+ bfd_vma value;
+ bfd_vma addend;
+ struct bfd_link_info *info;
+ asection *sym_sec;
+ const char *sym_name;
+ int is_local;
+{
+ unsigned long insn;
+ unsigned long r_type = howto->type;
+ unsigned long r_format = howto->bitsize;
+ unsigned long r_field = e_fsel;
+ bfd_byte *hit_data = contents + offset;
+ boolean r_pcrel = howto->pc_relative;
+
+ insn = bfd_get_32 (input_bfd, hit_data);
+
+ /* Make sure we have a value for $global$. FIXME isn't this effectively
+ just like the gp pointer on MIPS? Can we use those routines for this
+ purpose? */
+ if (!elf32_hppa_hash_table (info)->global_sym_defined)
+ {
+ struct elf_link_hash_entry *h;
+ asection *sec;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), "$global$", false,
+ false, false);
+
+ /* If there isn't a $global$, then we're in deep trouble. */
+ if (h == NULL)
+ return bfd_reloc_notsupported;
+
+ /* If $global$ isn't a defined symbol, then we're still in deep
+ trouble. */
+ if (h->root.type != bfd_link_hash_defined)
+ return bfd_reloc_undefined;
+
+ sec = h->root.u.def.section;
+ elf32_hppa_hash_table (info)->global_value = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ elf32_hppa_hash_table (info)->global_sym_defined = 1;
+ }
+
+ switch (r_type)
+ {
+ case R_PARISC_NONE:
+ break;
+
+ case R_PARISC_DIR32:
+ case R_PARISC_DIR17F:
+ case R_PARISC_PCREL17C:
+ r_field = e_fsel;
+ goto do_basic_type_1;
+ case R_PARISC_DIR21L:
+ case R_PARISC_PCREL21L:
+ r_field = e_lrsel;
+ goto do_basic_type_1;
+ case R_PARISC_DIR17R:
+ case R_PARISC_PCREL17R:
+ case R_PARISC_DIR14R:
+ case R_PARISC_PCREL14R:
+ r_field = e_rrsel;
+ goto do_basic_type_1;
+
+ /* For all the DP relative relocations, we need to examine the symbol's
+ section. If it's a code section, then "data pointer relative" makes
+ no sense. In that case we don't adjust the "value", and for 21 bit
+ addil instructions, we change the source addend register from %dp to
+ %r0. */
+ case R_PARISC_DPREL21L:
+ r_field = e_lrsel;
+ if (sym_sec->flags & SEC_CODE)
+ {
+ if ((insn & 0xfc000000) >> 26 == 0xa
+ && (insn & 0x03e00000) >> 21 == 0x1b)
+ insn &= ~0x03e00000;
+ }
+ else
+ value -= elf32_hppa_hash_table (info)->global_value;
+ goto do_basic_type_1;
+ case R_PARISC_DPREL14R:
+ r_field = e_rrsel;
+ if ((sym_sec->flags & SEC_CODE) == 0)
+ value -= elf32_hppa_hash_table (info)->global_value;
+ goto do_basic_type_1;
+ case R_PARISC_DPREL14F:
+ r_field = e_fsel;
+ if ((sym_sec->flags & SEC_CODE) == 0)
+ value -= elf32_hppa_hash_table (info)->global_value;
+ goto do_basic_type_1;
+
+ /* These cases are separate as they may involve a lot more work
+ to deal with linker stubs. */
+ case R_PARISC_PLABEL32:
+ case R_PARISC_PLABEL21L:
+ case R_PARISC_PLABEL14R:
+ case R_PARISC_PCREL17F:
+ {
+ bfd_vma location;
+ unsigned int len, caller_args, callee_args;
+ arg_reloc_type arg_reloc_types[5];
+ struct elf32_hppa_args_hash_table *args_hash_table;
+ struct elf32_hppa_args_hash_entry *args_hash;
+ char *new_name, *stub_name;
+
+ /* Get the field selector right. We'll need it in a minute. */
+ if (r_type == R_PARISC_PCREL17F
+ || r_type == R_PARISC_PLABEL32)
+ r_field = e_fsel;
+ else if (r_type == R_PARISC_PLABEL21L)
+ r_field = e_lrsel;
+ else if (r_type == R_PARISC_PLABEL14R)
+ r_field = e_rrsel;
+
+ /* Find out where we are and where we're going. */
+ location = (offset +
+ input_section->output_offset +
+ input_section->output_section->vma);
+
+ /* Now look for the argument relocation bits associated with the
+ target. */
+ len = strlen (sym_name) + 1;
+ if (is_local)
+ len += 9;
+ new_name = bfd_malloc (len);
+ if (!new_name)
+ return bfd_reloc_notsupported;
+ strcpy (new_name, sym_name);
+
+ /* Local symbols have unique IDs. */
+ if (is_local)
+ sprintf (new_name + len - 10, "_%08x", (int)sym_sec);
+
+ args_hash_table = elf32_hppa_hash_table (info)->args_hash_table;
+
+ args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
+ new_name, false, false);
+ if (args_hash == NULL)
+ callee_args = 0;
+ else
+ callee_args = args_hash->arg_bits;
+
+ /* If this is a CALL relocation, then get the caller's bits
+ from the addend. Else use the magic 0x155 value for PLABELS.
+
+ Also we don't care about the destination (value) for PLABELS. */
+ if (r_type == R_PARISC_PCREL17F)
+ caller_args = HPPA_R_ARG_RELOC (addend);
+ else
+ {
+ caller_args = 0x155;
+ location = value;
+ }
+
+ /* Any kind of linker stub needed? */
+ if (((int)(value - location) > 0x3ffff)
+ || ((int)(value - location) < (int)0xfffc0000)
+ || elf32_hppa_arg_reloc_needed (caller_args, callee_args,
+ arg_reloc_types))
+ {
+ struct elf32_hppa_stub_hash_table *stub_hash_table;
+ struct elf32_hppa_stub_hash_entry *stub_hash;
+ asection *stub_section;
+
+ /* Build a name for the stub. */
+
+ len = strlen (new_name);
+ len += 23;
+ stub_name = bfd_malloc (len);
+ if (!stub_name)
+ return bfd_reloc_notsupported;
+ elf32_hppa_name_of_stub (caller_args, callee_args,
+ location, value, stub_name);
+ strcat (stub_name, new_name);
+ free (new_name);
+
+ stub_hash_table = elf32_hppa_hash_table (info)->stub_hash_table;
+
+ stub_hash
+ = elf32_hppa_stub_hash_lookup (stub_hash_table, stub_name,
+ false, false);
+
+ /* We're done with that name. */
+ free (stub_name);
+
+ /* The stub BFD only has one section. */
+ stub_section = stub_hash_table->stub_bfd->sections;
+
+ if (stub_hash != NULL)
+ {
+
+ if (r_type == R_PARISC_PCREL17F)
+ {
+ unsigned long delay_insn;
+ unsigned int opcode, rtn_reg, ldo_target_reg, ldo_src_reg;
+
+ /* We'll need to peek at the next insn. */
+ delay_insn = bfd_get_32 (input_bfd, hit_data + 4);
+ opcode = get_opcode (delay_insn);
+
+ /* We also need to know the return register for this
+ call. */
+ rtn_reg = (insn & 0x03e00000) >> 21;
+
+ ldo_src_reg = (delay_insn & 0x03e00000) >> 21;
+ ldo_target_reg = (delay_insn & 0x001f0000) >> 16;
+
+ /* Munge up the value and other parameters for
+ hppa_elf_relocate_insn. */
+
+ value = (stub_hash->offset
+ + stub_section->output_offset
+ + stub_section->output_section->vma);
+
+ r_format = 17;
+ r_field = e_fsel;
+ r_pcrel = 0;
+ addend = 0;
+
+ /* We need to peek at the delay insn and determine if
+ we'll need to swap the branch and its delay insn. */
+ if ((insn & 2)
+ || (opcode == LDO
+ && ldo_target_reg == rtn_reg)
+ || (delay_insn == 0x08000240))
+ {
+ /* No need to swap the branch and its delay slot, but
+ we do need to make sure to jump past the return
+ pointer update in the stub. */
+ value += 4;
+
+ /* If the delay insn does a return pointer adjustment,
+ then we have to make sure it stays valid. */
+ if (opcode == LDO
+ && ldo_target_reg == rtn_reg)
+ {
+ delay_insn &= 0xfc00ffff;
+ delay_insn |= ((31 << 21) | (31 << 16));
+ bfd_put_32 (input_bfd, delay_insn, hit_data + 4);
+ }
+ /* Use a BLE to reach the stub. */
+ insn = BLE_SR4_R0;
+ }
+ else
+ {
+ /* Wonderful, we have to swap the call insn and its
+ delay slot. */
+ bfd_put_32 (input_bfd, delay_insn, hit_data);
+ /* Use a BLE,n to reach the stub. */
+ insn = (BLE_SR4_R0 | 0x2);
+ bfd_put_32 (input_bfd, insn, hit_data + 4);
+ insn = hppa_elf_relocate_insn (input_bfd,
+ input_section,
+ insn, offset + 4,
+ value, addend,
+ r_format, r_field,
+ r_pcrel);
+ /* Update the instruction word. */
+ bfd_put_32 (input_bfd, insn, hit_data + 4);
+ return bfd_reloc_dangerous;
+ }
+ }
+ else
+ {
+ /* PLABEL stuff is easy. */
+
+ value = (stub_hash->offset
+ + stub_section->output_offset
+ + stub_section->output_section->vma);
+ /* We don't need the RP adjustment for PLABELs. */
+ value += 4;
+ if (r_type == R_PARISC_PLABEL32)
+ r_format = 32;
+ else if (r_type == R_PARISC_PLABEL21L)
+ r_format = 21;
+ else if (r_type == R_PARISC_PLABEL14R)
+ r_format = 14;
+
+ r_pcrel = 0;
+ addend = 0;
+ }
+ }
+ else
+ return bfd_reloc_notsupported;
+ }
+ goto do_basic_type_1;
+ }
+
+do_basic_type_1:
+ insn = hppa_elf_relocate_insn (input_bfd, input_section, insn,
+ offset, value, addend, r_format,
+ r_field, r_pcrel);
+ break;
+
+ /* Something we don't know how to handle. */
+ default:
+ return bfd_reloc_notsupported;
+ }
+
+ /* Update the instruction word. */
+ bfd_put_32 (input_bfd, insn, hit_data);
+ return (bfd_reloc_ok);
+}
+
+/* Return the address of the howto table entry to perform the CODE
+ relocation for an ARCH machine. */
+
+static reloc_howto_type *
+elf_hppa_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
+ {
+ BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
+ return &elf_hppa_howto_table[(int) code];
+ }
+ return NULL;
+}
+
+/* Return true if SYM represents a local label symbol. */
+
+static boolean
+hppa_elf_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return (name[0] == 'L' && name[1] == '$');
+}
+
+/* Do any backend specific processing when beginning to write an object
+ file. For PA ELF we need to determine the size of the symbol extension
+ section *before* any other output processing happens. */
+
+static void
+elf32_hppa_backend_begin_write_processing (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ unsigned int i;
+ asection *symextn_sec;
+
+ /* Size up the symbol extension section. */
+ if ((abfd->outsymbols == NULL
+ && info == NULL)
+ || symext_chain_size != 0)
+ return;
+
+ if (info == NULL)
+ {
+ /* We were not called from the BFD ELF linker code, so we need
+ to examine the output BFD's outsymbols.
+
+ Note we can not build the symbol extensions now as the symbol
+ map hasn't been set up. */
+ for (i = 0; i < abfd->symcount; i++)
+ {
+ elf_symbol_type *symbol = (elf_symbol_type *)abfd->outsymbols[i];
+
+ /* Only functions ever need an entry in the symbol extension
+ section. */
+ if (!(symbol->symbol.flags & BSF_FUNCTION))
+ continue;
+
+ /* And only if they specify the locations of their arguments. */
+ if (symbol->tc_data.hppa_arg_reloc == 0)
+ continue;
+
+ /* Yup. This function symbol needs an entry. */
+ symext_chain_size += 2 * ELF32_PARISC_SX_SIZE;
+ }
+ }
+ else if (info->relocateable == true)
+ {
+ struct elf32_hppa_args_hash_table *table;
+ table = elf32_hppa_hash_table (info)->args_hash_table;
+
+ /* Determine the size of the symbol extension section. */
+ elf32_hppa_args_hash_traverse (table,
+ elf32_hppa_size_symext,
+ &symext_chain_size);
+ }
+
+ /* Now create the section and set its size. We'll fill in the
+ contents later. */
+ symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
+ if (symextn_sec == NULL)
+ symextn_sec = bfd_make_section (abfd, SYMEXTN_SECTION_NAME);
+
+ bfd_set_section_flags (abfd, symextn_sec,
+ SEC_LOAD | SEC_HAS_CONTENTS | SEC_DATA);
+ symextn_sec->output_section = symextn_sec;
+ symextn_sec->output_offset = 0;
+ bfd_set_section_alignment (abfd, symextn_sec, 2);
+ bfd_set_section_size (abfd, symextn_sec, symext_chain_size);
+}
+
+/* Called for each entry in the args location hash table. For each
+ entry we bump the size pointer by 2 records (16 bytes). */
+
+static boolean
+elf32_hppa_size_symext (gen_entry, in_args)
+ struct bfd_hash_entry *gen_entry;
+ PTR in_args;
+{
+ bfd_size_type *sizep = (bfd_size_type *)in_args;
+
+ *sizep += 2 * ELF32_PARISC_SX_SIZE;
+ return true;
+}
+
+/* Backend routine called by the linker for each output symbol.
+
+ For PA ELF we use this opportunity to add an appropriate entry
+ to the symbol extension chain for function symbols. */
+
+static boolean
+elf32_hppa_link_output_symbol_hook (abfd, info, name, sym, section)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const char *name;
+ Elf_Internal_Sym *sym;
+ asection *section;
+{
+ char *new_name;
+ unsigned int len, index;
+ struct elf32_hppa_args_hash_table *args_hash_table;
+ struct elf32_hppa_args_hash_entry *args_hash;
+
+ /* If the args hash table is NULL, then we've encountered an error
+ of some sorts (for example, an undefined symbol). In that case
+ we've got nothing else to do.
+
+ NOTE: elf_link_output_symbol will abort if we return false here! */
+ if (elf32_hppa_hash_table (info)->args_hash_table == NULL)
+ return true;
+
+ index = elf32_hppa_hash_table (info)->output_symbol_count++;
+
+ /* We need to look up this symbol in the args hash table to see if
+ it has argument relocation bits. */
+ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+ return true;
+
+ /* We know it's a function symbol of some kind. */
+ len = strlen (name) + 1;
+ if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
+ len += 9;
+
+ new_name = bfd_malloc (len);
+ if (new_name == NULL)
+ return false;
+
+ strcpy (new_name, name);
+ if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
+ sprintf (new_name + len - 10, "_%08x", (int)section);
+
+ /* Now that we have the unique name, we can look it up in the
+ args hash table. */
+ args_hash_table = elf32_hppa_hash_table (info)->args_hash_table;
+ args_hash = elf32_hppa_args_hash_lookup (args_hash_table, new_name,
+ false, false);
+ free (new_name);
+ if (args_hash == NULL)
+ return true;
+
+ /* We know this symbol has arg reloc bits. */
+ add_entry_to_symext_chain (abfd, args_hash->arg_bits,
+ index, &symext_rootP, &symext_lastP);
+ return true;
+}
+
+/* Perform any processing needed late in the object file writing process.
+ For PA ELF we build and set the contents of the symbol extension
+ section. */
+
+static void
+elf32_hppa_backend_final_write_processing (abfd, linker)
+ bfd *abfd;
+ boolean linker;
+{
+ asection *symextn_sec;
+ unsigned int i;
+
+ /* Now build the symbol extension section. */
+ if (symext_chain_size == 0)
+ return;
+
+ if (! linker)
+ {
+ /* We were not called from the backend linker, so we still need
+ to build the symbol extension chain.
+
+ Look at each symbol, adding the appropriate information to the
+ symbol extension section list as necessary. */
+ for (i = 0; i < abfd->symcount; i++)
+ {
+ elf_symbol_type *symbol = (elf_symbol_type *) abfd->outsymbols[i];
+
+ /* Only functions ever need an entry in the symbol extension
+ section. */
+ if (!(symbol->symbol.flags & BSF_FUNCTION))
+ continue;
+
+ /* And only if they specify the locations of their arguments. */
+ if (symbol->tc_data.hppa_arg_reloc == 0)
+ continue;
+
+ /* Add this symbol's information to the chain. */
+ add_entry_to_symext_chain (abfd, symbol->tc_data.hppa_arg_reloc,
+ symbol->symbol.udata.i, &symext_rootP,
+ &symext_lastP);
+ }
+ }
+
+ /* Now fill in the contents of the symbol extension section. */
+ elf_hppa_tc_make_sections (abfd, symext_rootP);
+
+ /* And attach that as the section's contents. */
+ symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
+ if (symextn_sec == (asection *) 0)
+ abort();
+
+ symextn_sec->contents = (void *)symextn_contents;
+
+ bfd_set_section_contents (abfd, symextn_sec, symextn_sec->contents,
+ symextn_sec->output_offset, symextn_sec->_raw_size);
+}
+
+/* Update the symbol extention chain to include the symbol pointed to
+ by SYMBOLP if SYMBOLP is a function symbol. Used internally and by GAS. */
+
+static void
+add_entry_to_symext_chain (abfd, arg_reloc, sym_idx, symext_root, symext_last)
+ bfd *abfd;
+ unsigned int arg_reloc;
+ unsigned int sym_idx;
+ symext_chainS **symext_root;
+ symext_chainS **symext_last;
+{
+ symext_chainS *symextP;
+
+ /* Allocate memory and initialize this entry. */
+ symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
+ if (!symextP)
+ abort(); /* FIXME */
+
+ symextP[0].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_SYMNDX, sym_idx);
+ symextP[0].next = &symextP[1];
+
+ symextP[1].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_ARG_RELOC, arg_reloc);
+ symextP[1].next = NULL;
+
+ /* Now update the chain itself so it can be walked later to build
+ the symbol extension section. */
+ if (*symext_root == NULL)
+ {
+ *symext_root = &symextP[0];
+ *symext_last = &symextP[1];
+ }
+ else
+ {
+ (*symext_last)->next = &symextP[0];
+ *symext_last = &symextP[1];
+ }
+}
+
+/* Build the symbol extension section. */
+
+static void
+elf_hppa_tc_make_sections (abfd, symext_root)
+ bfd *abfd;
+ symext_chainS *symext_root;
+{
+ symext_chainS *symextP;
+ unsigned int i;
+ asection *symextn_sec;
+
+ symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
+
+ /* Grab some memory for the contents of the symbol extension section
+ itself. */
+ symextn_contents = (bfd_byte *) bfd_zalloc (abfd,
+ symextn_sec->_raw_size);
+ if (!symextn_contents)
+ abort(); /* FIXME */
+
+ /* Fill in the contents of the symbol extension chain. */
+ for (i = 0, symextP = symext_root; symextP; symextP = symextP->next, ++i)
+ ELF32_PARISC_SX_PUT (abfd, (bfd_vma) symextP->entry,
+ symextn_contents + i * ELF32_PARISC_SX_SIZE);
+
+ return;
+}
+
+/* Do some PA ELF specific work after reading in the symbol table.
+ In particular attach the argument relocation from the
+ symbol extension section to the appropriate symbols. */
+
+static boolean
+elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
+ bfd *abfd;
+ elf_symbol_type *esyms;
+ unsigned int symcnt;
+{
+ Elf32_Internal_Shdr *symextn_hdr =
+ bfd_elf_find_section (abfd, SYMEXTN_SECTION_NAME);
+ unsigned int i, current_sym_idx = 0;
+
+ /* If no symbol extension existed, then all symbol extension information
+ is assumed to be zero. */
+ if (symextn_hdr == NULL)
+ {
+ for (i = 0; i < symcnt; i++)
+ esyms[i].tc_data.hppa_arg_reloc = 0;
+ return (true);
+ }
+
+ /* FIXME: Why not use bfd_get_section_contents here? Also should give
+ memory back when we're done. */
+ /* Allocate a buffer of the appropriate size for the symextn section. */
+ symextn_hdr->contents = bfd_zalloc(abfd,symextn_hdr->sh_size);
+ if (!symextn_hdr->contents)
+ return false;
+
+ /* Read in the symextn section. */
+ if (bfd_seek (abfd, symextn_hdr->sh_offset, SEEK_SET) == -1)
+ return false;
+ if (bfd_read ((PTR) symextn_hdr->contents, 1, symextn_hdr->sh_size, abfd)
+ != symextn_hdr->sh_size)
+ return false;
+
+ /* Parse entries in the symbol extension section, updating the symtab
+ entries as we go */
+ for (i = 0; i < symextn_hdr->sh_size / ELF32_PARISC_SX_SIZE; i++)
+ {
+ symext_entryS se =
+ ELF32_PARISC_SX_GET (abfd,
+ ((unsigned char *)symextn_hdr->contents
+ + i * ELF32_PARISC_SX_SIZE));
+ unsigned int se_value = ELF32_PARISC_SX_VAL (se);
+ unsigned int se_type = ELF32_PARISC_SX_TYPE (se);
+
+ switch (se_type)
+ {
+ case PARISC_SXT_NULL:
+ break;
+
+ case PARISC_SXT_SYMNDX:
+ if (se_value >= symcnt)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return (false);
+ }
+ current_sym_idx = se_value - 1;
+ break;
+
+ case PARISC_SXT_ARG_RELOC:
+ esyms[current_sym_idx].tc_data.hppa_arg_reloc = se_value;
+ break;
+
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return (false);
+ }
+ }
+ return (true);
+}
+
+/* Read and attach the symbol extension information for the symbols
+ in INPUT_BFD to the argument location hash table. Handle locals
+ if DO_LOCALS is true; likewise for globals when DO_GLOBALS is true. */
+
+static boolean
+elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms)
+ bfd *input_bfd;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf32_hppa_args_hash_table *args_hash_table;
+ Elf_Internal_Sym *local_syms;
+{
+ asection *symextn_sec;
+ bfd_byte *contents;
+ unsigned int i, n_entries, current_index = 0;
+
+ /* Get the symbol extension section for this BFD. If no section exists
+ then there's nothing to do. Likewise if the section exists, but
+ has no contents. */
+ symextn_sec = bfd_get_section_by_name (input_bfd, SYMEXTN_SECTION_NAME);
+ if (symextn_sec == NULL)
+ return true;
+
+ /* Done separately so we can turn off SEC_HAS_CONTENTS (see below). */
+ if (symextn_sec->_raw_size == 0)
+ {
+ symextn_sec->flags &= ~SEC_HAS_CONTENTS;
+ return true;
+ }
+
+ contents = (bfd_byte *) bfd_malloc ((size_t) symextn_sec->_raw_size);
+ if (contents == NULL)
+ return false;
+
+ /* How gross. We turn off SEC_HAS_CONTENTS for the input symbol extension
+ sections to keep the generic ELF/BFD code from trying to do anything
+ with them. We have to undo that hack temporarily so that we can read
+ in the contents with the generic code. */
+ symextn_sec->flags |= SEC_HAS_CONTENTS;
+ if (bfd_get_section_contents (input_bfd, symextn_sec, contents,
+ 0, symextn_sec->_raw_size) == false)
+ {
+ symextn_sec->flags &= ~SEC_HAS_CONTENTS;
+ free (contents);
+ return false;
+ }
+
+ /* Gross. Turn off SEC_HAS_CONTENTS for the input symbol extension
+ sections (see above). */
+ symextn_sec->flags &= ~SEC_HAS_CONTENTS;
+
+ n_entries = symextn_sec->_raw_size / ELF32_PARISC_SX_SIZE;
+ for (i = 0; i < n_entries; i++)
+ {
+ symext_entryS entry =
+ ELF32_PARISC_SX_GET (input_bfd, contents + i * ELF32_PARISC_SX_SIZE);
+ unsigned int value = ELF32_PARISC_SX_VAL (entry);
+ unsigned int type = ELF32_PARISC_SX_TYPE (entry);
+ struct elf32_hppa_args_hash_entry *args_hash;
+
+ switch (type)
+ {
+ case PARISC_SXT_NULL:
+ break;
+
+ case PARISC_SXT_SYMNDX:
+ if (value >= symtab_hdr->sh_size / sizeof (Elf32_External_Sym))
+ {
+ bfd_set_error (bfd_error_bad_value);
+ free (contents);
+ return false;
+ }
+ current_index = value;
+ break;
+
+ case PARISC_SXT_ARG_RELOC:
+ if (current_index < symtab_hdr->sh_info)
+ {
+ Elf_Internal_Shdr *hdr;
+ char *new_name;
+ const char *sym_name;
+ asection *sym_sec;
+ unsigned int len;
+
+ hdr = elf_elfsections (input_bfd)[local_syms[current_index].st_shndx];
+ sym_sec = hdr->bfd_section;
+ sym_name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ local_syms[current_index].st_name);
+ len = strlen (sym_name) + 10;
+ new_name = bfd_malloc (len);
+ if (new_name == NULL)
+ {
+ free (contents);
+ return false;
+ }
+ strcpy (new_name, sym_name);
+ sprintf (new_name + len - 10, "_%08x", (int)sym_sec);
+
+ /* This is a global symbol with argument location info.
+ We need to enter it into the hash table. */
+ args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
+ new_name, true,
+ true);
+ free (new_name);
+ if (args_hash == NULL)
+ {
+ free (contents);
+ return false;
+ }
+ args_hash->arg_bits = value;
+ break;
+ }
+ else if (current_index >= symtab_hdr->sh_info)
+ {
+ struct elf_link_hash_entry *h;
+
+ current_index -= symtab_hdr->sh_info;
+ h = elf_sym_hashes(input_bfd)[current_index];
+ /* This is a global symbol with argument location
+ information. We need to enter it into the hash table. */
+ args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
+ h->root.root.string,
+ true, true);
+ if (args_hash == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ free (contents);
+ return false;
+ }
+ args_hash->arg_bits = value;
+ break;
+ }
+ else
+ break;
+
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ free (contents);
+ return false;
+ }
+ }
+ free (contents);
+ return true;
+}
+
+/* Undo the generic ELF code's subtraction of section->vma from the
+ value of each external symbol. */
+
+static boolean
+elf32_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const Elf_Internal_Sym *sym;
+ const char **namep;
+ flagword *flagsp;
+ asection **secp;
+ bfd_vma *valp;
+{
+ *valp += (*secp)->vma;
+ return true;
+}
+
+/* Determine the name of the stub needed to perform a call assuming the
+ argument relocation bits for caller and callee are in CALLER and CALLEE
+ for a call from LOCATION to DESTINATION. Copy the name into STUB_NAME. */
+
+static void
+elf32_hppa_name_of_stub (caller, callee, location, destination, stub_name)
+ unsigned int caller, callee;
+ bfd_vma location, destination;
+ char *stub_name;
+{
+ arg_reloc_type arg_reloc_types[5];
+
+ if (elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types))
+ {
+ arg_reloc_location i;
+ /* Fill in the basic template. */
+ strcpy (stub_name, "__XX_XX_XX_XX_XX_stub_");
+
+ /* Now fix the specifics. */
+ for (i = ARG0; i <= RET; i++)
+ switch (arg_reloc_types[i])
+ {
+ case NO:
+ stub_name[3 * i + 2] = 'N';
+ stub_name[3 * i + 3] = 'O';
+ break;
+ case GF:
+ stub_name[3 * i + 2] = 'G';
+ stub_name[3 * i + 3] = 'F';
+ break;
+ case FG:
+ stub_name[3 * i + 2] = 'F';
+ stub_name[3 * i + 3] = 'G';
+ break;
+ case GD:
+ stub_name[3 * i + 2] = 'G';
+ stub_name[3 * i + 3] = 'D';
+ break;
+ case DG:
+ stub_name[3 * i + 2] = 'D';
+ stub_name[3 * i + 3] = 'G';
+ break;
+ }
+ }
+ else
+ strcpy (stub_name, "_____long_branch_stub_");
+}
+
+/* Determine if an argument relocation stub is needed to perform a
+ call assuming the argument relocation bits for caller and callee
+ are in CALLER and CALLEE. Place the type of relocations (if any)
+ into stub_types_p. */
+
+static boolean
+elf32_hppa_arg_reloc_needed (caller, callee, stub_types)
+ unsigned int caller, callee;
+ arg_reloc_type stub_types[5];
+{
+ /* Special case for no relocations. */
+ if (caller == 0 || callee == 0)
+ return 0;
+ else
+ {
+ arg_location caller_loc[5];
+ arg_location callee_loc[5];
+
+ /* Extract the location information for the argument and return
+ value on both the caller and callee sides. */
+ caller_loc[ARG0] = EXTRACT_ARBITS (caller, ARG0);
+ callee_loc[ARG0] = EXTRACT_ARBITS (callee, ARG0);
+ caller_loc[ARG1] = EXTRACT_ARBITS (caller, ARG1);
+ callee_loc[ARG1] = EXTRACT_ARBITS (callee, ARG1);
+ caller_loc[ARG2] = EXTRACT_ARBITS (caller, ARG2);
+ callee_loc[ARG2] = EXTRACT_ARBITS (callee, ARG2);
+ caller_loc[ARG3] = EXTRACT_ARBITS (caller, ARG3);
+ callee_loc[ARG3] = EXTRACT_ARBITS (callee, ARG3);
+ caller_loc[RET] = EXTRACT_ARBITS (caller, RET);
+ callee_loc[RET] = EXTRACT_ARBITS (callee, RET);
+
+ /* Check some special combinations. This is necessary to
+ deal with double precision FP arguments. */
+ if (caller_loc[ARG0] == AR_FU || caller_loc[ARG1] == AR_FU)
+ {
+ caller_loc[ARG0] = AR_FPDBL1;
+ caller_loc[ARG1] = AR_NO;
+ }
+ if (caller_loc[ARG2] == AR_FU || caller_loc[ARG3] == AR_FU)
+ {
+ caller_loc[ARG2] = AR_FPDBL2;
+ caller_loc[ARG3] = AR_NO;
+ }
+ if (callee_loc[ARG0] == AR_FU || callee_loc[ARG1] == AR_FU)
+ {
+ callee_loc[ARG0] = AR_FPDBL1;
+ callee_loc[ARG1] = AR_NO;
+ }
+ if (callee_loc[ARG2] == AR_FU || callee_loc[ARG3] == AR_FU)
+ {
+ callee_loc[ARG2] = AR_FPDBL2;
+ callee_loc[ARG3] = AR_NO;
+ }
+
+ /* Now look up any relocation needed for each argument and the
+ return value. */
+ stub_types[ARG0] = arg_mismatches[caller_loc[ARG0]][callee_loc[ARG0]];
+ stub_types[ARG1] = arg_mismatches[caller_loc[ARG1]][callee_loc[ARG1]];
+ stub_types[ARG2] = arg_mismatches[caller_loc[ARG2]][callee_loc[ARG2]];
+ stub_types[ARG3] = arg_mismatches[caller_loc[ARG3]][callee_loc[ARG3]];
+ stub_types[RET] = ret_mismatches[caller_loc[RET]][callee_loc[RET]];
+
+ return (stub_types[ARG0] != NO
+ || stub_types[ARG1] != NO
+ || stub_types[ARG2] != NO
+ || stub_types[ARG3] != NO
+ || stub_types[RET] != NO);
+ }
+}
+
+/* Compute the size of the stub needed to call from LOCATION to DESTINATION
+ (a function named SYM_NAME), with argument relocation bits CALLER and
+ CALLEE. Return zero if no stub is needed to perform such a call. */
+
+static unsigned int
+elf32_hppa_size_of_stub (callee, caller, location, destination, sym_name)
+ unsigned int callee, caller;
+ bfd_vma location, destination;
+ const char *sym_name;
+{
+ arg_reloc_type arg_reloc_types[5];
+
+ /* Determine if a long branch or argument relocation stub is needed.
+ If an argument relocation stub is needed, the relocation will be
+ stored into arg_reloc_types. */
+ if (!(((int)(location - destination) > 0x3ffff)
+ || ((int)(location - destination) < (int)0xfffc0000)
+ || elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types)))
+ return 0;
+
+ /* Some kind of stub is needed. Determine how big it needs to be.
+ First check for argument relocation stubs as they also handle
+ long calls. Then check for long calls to millicode and finally
+ the normal long calls. */
+ if (arg_reloc_types[ARG0] != NO
+ || arg_reloc_types[ARG1] != NO
+ || arg_reloc_types[ARG2] != NO
+ || arg_reloc_types[ARG3] != NO
+ || arg_reloc_types[RET] != NO)
+ {
+ /* Some kind of argument relocation stub is needed. */
+ unsigned int len = 16;
+ arg_reloc_location i;
+
+ /* Each GR or FG relocation takes 2 insns, each GD or DG
+ relocation takes 3 insns. Plus 4 more insns for the
+ RP adjustment, ldil & (be | ble) and copy. */
+ for (i = ARG0; i <= RET; i++)
+ switch (arg_reloc_types[i])
+ {
+ case GF:
+ case FG:
+ len += 8;
+ break;
+
+ case GD:
+ case DG:
+ len += 12;
+ break;
+
+ default:
+ break;
+ }
+
+ /* Extra instructions are needed if we're relocating a return value. */
+ if (arg_reloc_types[RET] != NO)
+ len += 12;
+
+ return len;
+ }
+ else if (!strncmp ("$$", sym_name, 2)
+ && strcmp ("$$dyncall", sym_name))
+ return 12;
+ else
+ return 16;
+}
+
+/* Build one linker stub as defined by the stub hash table entry GEN_ENTRY.
+ IN_ARGS contains the stub BFD and link info pointers. */
+
+static boolean
+elf32_hppa_build_one_stub (gen_entry, in_args)
+ struct bfd_hash_entry *gen_entry;
+ PTR in_args;
+{
+ void **args = (void **)in_args;
+ bfd *stub_bfd = (bfd *)args[0];
+ struct bfd_link_info *info = (struct bfd_link_info *)args[1];
+ struct elf32_hppa_stub_hash_entry *entry;
+ struct elf32_hppa_stub_hash_table *stub_hash_table;
+ bfd_byte *loc;
+ symvalue sym_value;
+ const char *sym_name;
+
+ /* Initialize pointers to the stub hash table, the particular entry we
+ are building a stub for, and where (in memory) we should place the stub
+ instructions. */
+ entry = (struct elf32_hppa_stub_hash_entry *)gen_entry;
+ stub_hash_table = elf32_hppa_hash_table(info)->stub_hash_table;
+ loc = stub_hash_table->location;
+
+ /* Make a note of the offset within the stubs for this entry. */
+ entry->offset = stub_hash_table->offset;
+
+ /* The symbol's name starts at offset 22. */
+ sym_name = entry->root.string + 22;
+
+ sym_value = (entry->target_value
+ + entry->target_section->output_offset
+ + entry->target_section->output_section->vma);
+
+ if (strncmp ("_____long_branch_stub_", entry->root.string, 22))
+ {
+ /* This must be an argument or return value relocation stub. */
+ unsigned long insn;
+ arg_reloc_location i;
+ bfd_byte *begin_loc = loc;
+
+ /* First the return pointer adjustment. Depending on exact calling
+ sequence this instruction may be skipped. */
+ bfd_put_32 (stub_bfd, LDO_M4_R31_R31, loc);
+ loc += 4;
+
+ /* If we are relocating a return value, then we're going to have
+ to return into the stub. So we have to save off the user's
+ return pointer into the stack at RP'. */
+ if (strncmp (entry->root.string + 14, "NO", 2))
+ {
+ bfd_put_32 (stub_bfd, STW_R31_M8R30, loc);
+ loc += 4;
+ }
+
+ /* Iterate over the argument relocations, emitting instructions
+ to move them around as necessary. */
+ for (i = ARG0; i <= ARG3; i++)
+ {
+ if (!strncmp (entry->root.string + 3 * i + 2, "GF", 2))
+ {
+ bfd_put_32 (stub_bfd, STW_ARG_M16R30 | ((26 - i) << 16), loc);
+ bfd_put_32 (stub_bfd, FLDW_M16R30_FARG | (4 + i), loc + 4);
+ loc += 8;
+ }
+ else if (!strncmp (entry->root.string + 3 * i + 2, "FG", 2))
+ {
+ bfd_put_32 (stub_bfd, FSTW_FARG_M16R30 | (4 + i), loc);
+ bfd_put_32 (stub_bfd, LDW_M16R30_ARG | ((26 - i) << 16), loc + 4);
+ loc += 8;
+ }
+ else if (!strncmp (entry->root.string + 3 * i + 2, "GD", 2))
+ {
+ bfd_put_32 (stub_bfd, STW_ARG_M12R30 | ((26 - i) << 16), loc);
+ bfd_put_32 (stub_bfd, STW_ARG_M16R30 | ((25 - i) << 16), loc + 4);
+ bfd_put_32 (stub_bfd, FLDD_M16R30_FARG | (5 + i), loc + 8);
+ loc += 12;
+ }
+ else if (!strncmp (entry->root.string + 3 * i + 2, "DG", 2))
+ {
+ bfd_put_32 (stub_bfd, FSTD_FARG_M16R30 | (5 + i), loc);
+ bfd_put_32 (stub_bfd, LDW_M12R30_ARG | ((26 - i) << 16), loc + 4);
+ bfd_put_32 (stub_bfd, LDW_M16R30_ARG | ((25 - i) << 16), loc + 8);
+ loc += 12;
+ }
+ }
+
+ /* Load the high bits of the target address into %r1. */
+ insn = hppa_rebuild_insn (stub_bfd, LDIL_R1,
+ hppa_field_adjust (sym_value, 0, e_lrsel), 21);
+ bfd_put_32 (stub_bfd, insn, loc);
+ loc += 4;
+
+ /* If we are relocating a return value, then we're going to have
+ to return into the stub, then perform the return value relocation. */
+ if (strncmp (entry->root.string + 14, "NO", 2))
+ {
+ /* To return to the stub we "ble" to the target and copy the return
+ pointer from %r31 into %r2. */
+ insn = hppa_rebuild_insn (stub_bfd,
+ BLE_SR4_R1,
+ hppa_field_adjust (sym_value, 0,
+ e_rrsel) >> 2,
+ 17);
+ bfd_put_32 (stub_bfd, insn, loc);
+ bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 4);
+
+ /* Reload the return pointer for our caller from the stack. */
+ bfd_put_32 (stub_bfd, LDW_M8R30_R31, loc + 8);
+ loc += 12;
+
+ /* Perform the return value relocation. */
+ if (!strncmp (entry->root.string + 14, "GF", 2))
+ {
+ bfd_put_32 (stub_bfd, STW_ARG_M16R30 | (28 << 16), loc);
+ bfd_put_32 (stub_bfd, FLDW_M16R30_FARG | 4, loc + 4);
+ loc += 8;
+ }
+ else if (!strncmp (entry->root.string + 14, "FG", 2))
+ {
+ bfd_put_32 (stub_bfd, FSTW_FARG_M16R30 | 4, loc);
+ bfd_put_32 (stub_bfd, LDW_M16R30_ARG | (28 << 16), loc + 4);
+ loc += 8;
+ }
+ else if (!strncmp (entry->root.string + 2, "GD", 2))
+ {
+ bfd_put_32 (stub_bfd, STW_ARG_M12R30 | (28 << 16), loc);
+ bfd_put_32 (stub_bfd, STW_ARG_M16R30 | (29 << 16), loc + 4);
+ bfd_put_32 (stub_bfd, FLDD_M16R30_FARG | 4, loc + 8);
+ loc += 12;
+ }
+ else if (!strncmp (entry->root.string + 2, "DG", 2))
+ {
+ bfd_put_32 (stub_bfd, FSTD_FARG_M16R30 | 4, loc);
+ bfd_put_32 (stub_bfd, LDW_M12R30_ARG | (28 << 16), loc + 4);
+ bfd_put_32 (stub_bfd, LDW_M16R30_ARG | (29 << 16), loc + 8);
+ loc += 12;
+ }
+ /* Branch back to the user's code now. */
+ bfd_put_32 (stub_bfd, BV_N_0_R31, loc);
+ loc += 4;
+ }
+ else
+ {
+ /* No return value relocation, so we can simply "be" to the
+ target and copy out return pointer into %r2. */
+ insn = hppa_rebuild_insn (stub_bfd, BE_SR4_R1,
+ hppa_field_adjust (sym_value, 0,
+ e_rrsel) >> 2, 17);
+ bfd_put_32 (stub_bfd, insn, loc);
+ bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 4);
+ loc += 8;
+ }
+
+ /* Update the location and offsets. */
+ stub_hash_table->location += (loc - begin_loc);
+ stub_hash_table->offset += (loc - begin_loc);
+ }
+ else
+ {
+ /* Create one of two variant long branch stubs. One for $$dyncall and
+ normal calls, the other for calls to millicode. */
+ unsigned long insn;
+ int millicode_call = 0;
+
+ if (!strncmp ("$$", sym_name, 2) && strcmp ("$$dyncall", sym_name))
+ millicode_call = 1;
+
+ /* First the return pointer adjustment. Depending on exact calling
+ sequence this instruction may be skipped. */
+ bfd_put_32 (stub_bfd, LDO_M4_R31_R31, loc);
+
+ /* The next two instructions are the long branch itself. A long branch
+ is formed with "ldil" loading the upper bits of the target address
+ into a register, then branching with "be" which adds in the lower bits.
+ Long branches to millicode nullify the delay slot of the "be". */
+ insn = hppa_rebuild_insn (stub_bfd, LDIL_R1,
+ hppa_field_adjust (sym_value, 0, e_lrsel), 21);
+ bfd_put_32 (stub_bfd, insn, loc + 4);
+ insn = hppa_rebuild_insn (stub_bfd, BE_SR4_R1 | (millicode_call ? 2 : 0),
+ hppa_field_adjust (sym_value, 0, e_rrsel) >> 2,
+ 17);
+ bfd_put_32 (stub_bfd, insn, loc + 8);
+
+ if (!millicode_call)
+ {
+ /* The sequence to call this stub places the return pointer into %r31,
+ the final target expects the return pointer in %r2, so copy the
+ return pointer into the proper register. */
+ bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 12);
+
+ /* Update the location and offsets. */
+ stub_hash_table->location += 16;
+ stub_hash_table->offset += 16;
+ }
+ else
+ {
+ /* Update the location and offsets. */
+ stub_hash_table->location += 12;
+ stub_hash_table->offset += 12;
+ }
+
+ }
+ return true;
+}
+
+/* External entry points for sizing and building linker stubs. */
+
+/* Build all the stubs associated with the current output file. The
+ stubs are kept in a hash table attached to the main linker hash
+ table. This is called via hppaelf_finish in the linker. */
+
+boolean
+elf32_hppa_build_stubs (stub_bfd, info)
+ bfd *stub_bfd;
+ struct bfd_link_info *info;
+{
+ /* The stub BFD only has one section. */
+ asection *stub_sec = stub_bfd->sections;
+ struct elf32_hppa_stub_hash_table *table;
+ unsigned int size;
+ void *args[2];
+
+ /* So we can pass both the BFD for the stubs and the link info
+ structure to the routine which actually builds stubs. */
+ args[0] = stub_bfd;
+ args[1] = info;
+
+ /* Allocate memory to hold the linker stubs. */
+ size = bfd_section_size (stub_bfd, stub_sec);
+ stub_sec->contents = (unsigned char *) bfd_zalloc (stub_bfd, size);
+ if (stub_sec->contents == NULL)
+ return false;
+ table = elf32_hppa_hash_table(info)->stub_hash_table;
+ table->location = stub_sec->contents;
+
+ /* Build the stubs as directed by the stub hash table. */
+ elf32_hppa_stub_hash_traverse (table, elf32_hppa_build_one_stub, args);
+
+ return true;
+}
+
+/* Determine and set the size of the stub section for a final link.
+
+ The basic idea here is to examine all the relocations looking for
+ PC-relative calls to a target that is unreachable with a "bl"
+ instruction or calls where the caller and callee disagree on the
+ location of their arguments or return value. */
+
+boolean
+elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info)
+ bfd *stub_bfd;
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+{
+ bfd *input_bfd;
+ asection *section, *stub_sec = 0;
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Sym *local_syms, *isym, **all_local_syms;
+ Elf32_External_Sym *ext_syms, *esym;
+ unsigned int i, index, bfd_count = 0;
+ struct elf32_hppa_stub_hash_table *stub_hash_table = 0;
+ struct elf32_hppa_args_hash_table *args_hash_table = 0;
+
+ /* Create and initialize the stub hash table. */
+ stub_hash_table = ((struct elf32_hppa_stub_hash_table *)
+ bfd_malloc (sizeof (struct elf32_hppa_stub_hash_table)));
+ if (!stub_hash_table)
+ goto error_return;
+
+ if (!elf32_hppa_stub_hash_table_init (stub_hash_table, stub_bfd,
+ elf32_hppa_stub_hash_newfunc))
+ goto error_return;
+
+ /* Likewise for the argument location hash table. */
+ args_hash_table = ((struct elf32_hppa_args_hash_table *)
+ bfd_malloc (sizeof (struct elf32_hppa_args_hash_table)));
+ if (!args_hash_table)
+ goto error_return;
+
+ if (!elf32_hppa_args_hash_table_init (args_hash_table,
+ elf32_hppa_args_hash_newfunc))
+ goto error_return;
+
+ /* Attach the hash tables to the main hash table. */
+ elf32_hppa_hash_table(link_info)->stub_hash_table = stub_hash_table;
+ elf32_hppa_hash_table(link_info)->args_hash_table = args_hash_table;
+
+ /* Count the number of input BFDs. */
+ for (input_bfd = link_info->input_bfds;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next)
+ bfd_count++;
+
+ /* We want to read in symbol extension records only once. To do this
+ we need to read in the local symbols in parallel and save them for
+ later use; so hold pointers to the local symbols in an array. */
+ all_local_syms
+ = (Elf_Internal_Sym **) bfd_malloc (sizeof (Elf_Internal_Sym *)
+ * bfd_count);
+ if (all_local_syms == NULL)
+ goto error_return;
+ memset (all_local_syms, 0, sizeof (Elf_Internal_Sym *) * bfd_count);
+
+ /* Walk over all the input BFDs adding entries to the args hash table
+ for all the external functions. */
+ for (input_bfd = link_info->input_bfds, index = 0;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next, index++)
+ {
+ /* We'll need the symbol table in a second. */
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ if (symtab_hdr->sh_info == 0)
+ continue;
+
+ /* We need an array of the local symbols attached to the input bfd.
+ Unfortunately, we're going to have to read & swap them in. */
+ local_syms
+ = (Elf_Internal_Sym *) bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf_Internal_Sym));
+ if (local_syms == NULL)
+ {
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+ all_local_syms[index] = local_syms;
+
+ ext_syms
+ = (Elf32_External_Sym *) bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf32_External_Sym));
+ if (ext_syms == NULL)
+ {
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || bfd_read (ext_syms, 1,
+ (symtab_hdr->sh_info
+ * sizeof (Elf32_External_Sym)), input_bfd)
+ != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))
+ {
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ free (ext_syms);
+ goto error_return;
+ }
+
+ /* Swap the local symbols in. */
+ isym = local_syms;
+ esym = ext_syms;
+ for (i = 0; i < symtab_hdr->sh_info; i++, esym++, isym++)
+ bfd_elf32_swap_symbol_in (input_bfd, esym, isym);
+
+ /* Now we can free the external symbols. */
+ free (ext_syms);
+
+ if (elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table,
+ local_syms) == false)
+ {
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+ }
+
+ /* Magic as we know the stub bfd only has one section. */
+ stub_sec = stub_bfd->sections;
+
+ /* If generating a relocateable output file, then we don't
+ have to examine the relocs. */
+ if (link_info->relocateable)
+ {
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ return true;
+ }
+
+ /* Now that we have argument location information for all the global
+ functions we can start looking for stubs. */
+ for (input_bfd = link_info->input_bfds, index = 0;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next, index++)
+ {
+ /* We'll need the symbol table in a second. */
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ if (symtab_hdr->sh_info == 0)
+ continue;
+
+ local_syms = all_local_syms[index];
+
+ /* Walk over each section attached to the input bfd. */
+ for (section = input_bfd->sections;
+ section != NULL;
+ section = section->next)
+ {
+ Elf_Internal_Shdr *input_rel_hdr;
+ Elf32_External_Rela *external_relocs, *erelaend, *erela;
+ Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
+
+ /* If there aren't any relocs, then there's nothing to do. */
+ if ((section->flags & SEC_RELOC) == 0
+ || section->reloc_count == 0)
+ continue;
+
+ /* Allocate space for the external relocations. */
+ external_relocs
+ = ((Elf32_External_Rela *)
+ bfd_malloc (section->reloc_count
+ * sizeof (Elf32_External_Rela)));
+ if (external_relocs == NULL)
+ {
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+
+ /* Likewise for the internal relocations. */
+ internal_relocs
+ = ((Elf_Internal_Rela *)
+ bfd_malloc (section->reloc_count * sizeof (Elf_Internal_Rela)));
+ if (internal_relocs == NULL)
+ {
+ free (external_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+
+ /* Read in the external relocs. */
+ input_rel_hdr = &elf_section_data (section)->rel_hdr;
+ if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0
+ || bfd_read (external_relocs, 1, input_rel_hdr->sh_size,
+ input_bfd) != input_rel_hdr->sh_size)
+ {
+ free (external_relocs);
+ free (internal_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+
+ /* Swap in the relocs. */
+ erela = external_relocs;
+ erelaend = erela + section->reloc_count;
+ irela = internal_relocs;
+ for (; erela < erelaend; erela++, irela++)
+ bfd_elf32_swap_reloca_in (input_bfd, erela, irela);
+
+ /* We're done with the external relocs, free them. */
+ free (external_relocs);
+
+ /* Now examine each relocation. */
+ irela = internal_relocs;
+ irelaend = irela + section->reloc_count;
+ for (; irela < irelaend; irela++)
+ {
+ long r_type, callee_args, caller_args, size_of_stub;
+ unsigned long r_index;
+ struct elf_link_hash_entry *hash;
+ struct elf32_hppa_stub_hash_entry *stub_hash;
+ struct elf32_hppa_args_hash_entry *args_hash;
+ Elf_Internal_Sym *sym;
+ asection *sym_sec;
+ const char *sym_name;
+ symvalue sym_value;
+ bfd_vma location, destination;
+ char *new_name = NULL;
+
+ r_type = ELF32_R_TYPE (irela->r_info);
+ r_index = ELF32_R_SYM (irela->r_info);
+
+ if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ free (internal_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+
+ /* Only look for stubs on call instructions or plabel
+ references. */
+ if (r_type != R_PARISC_PCREL17F
+ && r_type != R_PARISC_PLABEL32
+ && r_type != R_PARISC_PLABEL21L
+ && r_type != R_PARISC_PLABEL14R)
+ continue;
+
+ /* Now determine the call target, its name, value, section
+ and argument relocation bits. */
+ hash = NULL;
+ sym = NULL;
+ sym_sec = NULL;
+ if (r_index < symtab_hdr->sh_info)
+ {
+ /* It's a local symbol. */
+ Elf_Internal_Shdr *hdr;
+
+ sym = local_syms + r_index;
+ hdr = elf_elfsections (input_bfd)[sym->st_shndx];
+ sym_sec = hdr->bfd_section;
+ sym_name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ sym_value = (ELF_ST_TYPE (sym->st_info) == STT_SECTION
+ ? 0 : sym->st_value);
+ destination = (sym_value
+ + sym_sec->output_offset
+ + sym_sec->output_section->vma);
+
+ /* Tack on an ID so we can uniquely identify this local
+ symbol in the stub or arg info hash tables. */
+ new_name = bfd_malloc (strlen (sym_name) + 10);
+ if (new_name == 0)
+ {
+ free (internal_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+ sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
+ sym_name = new_name;
+ }
+ else
+ {
+ /* It's an external symbol. */
+ long index;
+
+ index = r_index - symtab_hdr->sh_info;
+ hash = elf_sym_hashes (input_bfd)[index];
+ if (hash->root.type == bfd_link_hash_defined
+ || hash->root.type == bfd_link_hash_defweak)
+ {
+ sym_sec = hash->root.u.def.section;
+ sym_name = hash->root.root.string;
+ sym_value = hash->root.u.def.value;
+ destination = (sym_value
+ + sym_sec->output_offset
+ + sym_sec->output_section->vma);
+ }
+ else
+ {
+ bfd_set_error (bfd_error_bad_value);
+ free (internal_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+ }
+
+ args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
+ sym_name, false, false);
+
+ /* Get both caller and callee argument information. */
+ if (args_hash == NULL)
+ callee_args = 0;
+ else
+ callee_args = args_hash->arg_bits;
+
+ /* For calls get the caller's bits from the addend of
+ the call relocation. For PLABELS the caller's bits
+ are assumed to have all args & return values in general
+ registers (0x155). */
+ if (r_type == R_PARISC_PCREL17F)
+ caller_args = HPPA_R_ARG_RELOC (irela->r_addend);
+ else
+ caller_args = 0x155;
+
+ /* Now determine where the call point is. */
+ location = (section->output_offset
+ + section->output_section->vma
+ + irela->r_offset);
+
+ /* We only care about the destination for PCREL function
+ calls (eg. we don't care for PLABELS). */
+ if (r_type != R_PARISC_PCREL17F)
+ location = destination;
+
+ /* Determine what (if any) linker stub is needed and its
+ size (in bytes). */
+ size_of_stub = elf32_hppa_size_of_stub (callee_args,
+ caller_args,
+ location,
+ destination,
+ sym_name);
+ if (size_of_stub != 0)
+ {
+ char *stub_name;
+ unsigned int len;
+
+ /* Get the name of this stub. */
+ len = strlen (sym_name);
+ len += 23;
+
+ stub_name = bfd_malloc (len);
+ if (!stub_name)
+ {
+ /* Because sym_name was mallocd above for local
+ symbols. */
+ if (r_index < symtab_hdr->sh_info)
+ free (new_name);
+
+ free (internal_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+ elf32_hppa_name_of_stub (caller_args, callee_args,
+ location, destination, stub_name);
+ strcat (stub_name + 22, sym_name);
+
+ /* Because sym_name was malloced above for local symbols. */
+ if (r_index < symtab_hdr->sh_info)
+ free (new_name);
+
+ stub_hash
+ = elf32_hppa_stub_hash_lookup (stub_hash_table, stub_name,
+ false, false);
+ if (stub_hash != NULL)
+ {
+ /* The proper stub has already been created, nothing
+ else to do. */
+ free (stub_name);
+ }
+ else
+ {
+ bfd_set_section_size (stub_bfd, stub_sec,
+ (bfd_section_size (stub_bfd,
+ stub_sec)
+ + size_of_stub));
+
+ /* Enter this entry into the linker stub hash table. */
+ stub_hash
+ = elf32_hppa_stub_hash_lookup (stub_hash_table,
+ stub_name, true, true);
+ if (stub_hash == NULL)
+ {
+ free (stub_name);
+ free (internal_relocs);
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ goto error_return;
+ }
+
+ /* We'll need these to determine the address that the
+ stub will branch to. */
+ stub_hash->target_value = sym_value;
+ stub_hash->target_section = sym_sec;
+ }
+ free (stub_name);
+ }
+ }
+ /* We're done with the internal relocs, free them. */
+ free (internal_relocs);
+ }
+ }
+ /* We're done with the local symbols, free them. */
+ for (i = 0; i < bfd_count; i++)
+ if (all_local_syms[i])
+ free (all_local_syms[i]);
+ free (all_local_syms);
+ return true;
+
+error_return:
+ /* Return gracefully, avoiding dangling references to the hash tables. */
+ if (stub_hash_table)
+ {
+ elf32_hppa_hash_table(link_info)->stub_hash_table = NULL;
+ free (stub_hash_table);
+ }
+ if (args_hash_table)
+ {
+ elf32_hppa_hash_table(link_info)->args_hash_table = NULL;
+ free (args_hash_table);
+ }
+ /* Set the size of the stub section to zero since we're never going
+ to create them. Avoids losing when we try to get its contents
+ too. */
+ bfd_set_section_size (stub_bfd, stub_sec, 0);
+ return false;
+}
+
+/* Misc BFD support code. */
+#define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
+#define bfd_elf32_bfd_is_local_label_name hppa_elf_is_local_label_name
+
+/* Symbol extension stuff. */
+#define bfd_elf32_set_section_contents elf32_hppa_set_section_contents
+#define elf_info_to_howto elf32_hppa_info_to_howto
+#define elf_backend_symbol_table_processing \
+ elf32_hppa_backend_symbol_table_processing
+#define elf_backend_begin_write_processing \
+ elf32_hppa_backend_begin_write_processing
+#define elf_backend_final_write_processing \
+ elf32_hppa_backend_final_write_processing
+
+/* Stuff for the BFD linker. */
+#define elf_backend_relocate_section elf32_hppa_relocate_section
+#define elf_backend_add_symbol_hook elf32_hppa_add_symbol_hook
+#define elf_backend_link_output_symbol_hook \
+ elf32_hppa_link_output_symbol_hook
+#define bfd_elf32_bfd_link_hash_table_create \
+ elf32_hppa_link_hash_table_create
+
+#define TARGET_BIG_SYM bfd_elf32_hppa_vec
+#define TARGET_BIG_NAME "elf32-hppa"
+#define ELF_ARCH bfd_arch_hppa
+#define ELF_MACHINE_CODE EM_PARISC
+#define ELF_MAXPAGESIZE 0x1000
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-hppa.h b/bfd/elf32-hppa.h
new file mode 100644
index 00000000000..b2339204592
--- /dev/null
+++ b/bfd/elf32-hppa.h
@@ -0,0 +1,66 @@
+/* ELF32/HPPA support
+
+ This file contains ELF32/HPPA relocation support as specified
+ in the Stratus FTX/Golf Object File Format (SED-1762) dated
+ February 1994.
+
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+ Written by:
+
+ Center for Software Science
+ Department of Computer Science
+ University of Utah
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF32_HPPA_H
+#define _ELF32_HPPA_H
+
+#include "elf-bfd.h"
+#include "libhppa.h"
+#include "elf/hppa.h"
+
+#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
+#define N_PARISC_RELOCS R_PARISC_UNIMPLEMENTED + 1
+
+/* Define groups of basic relocations. FIXME: These should
+ be the only basic relocations created by GAS. The rest
+ should be internal to the BFD backend.
+
+ The idea is both SOM and ELF define these basic relocation
+ types so they map into a SOM or ELF specific relocation
+ as appropriate. This allows GAS to share much more code
+ between the two target object formats. */
+
+#define R_HPPA_NONE R_PARISC_NONE
+#define R_HPPA R_PARISC_DIR32
+#define R_HPPA_GOTOFF R_PARISC_DPREL21L
+#define R_HPPA_PCREL_CALL R_PARISC_PCREL21L
+#define R_HPPA_ABS_CALL R_PARISC_DIR17F
+#define R_HPPA_COMPLEX R_PARISC_UNIMPLEMENTED
+
+elf32_hppa_reloc_type ** hppa_elf_gen_reloc_type
+ PARAMS ((bfd *, elf32_hppa_reloc_type, int, int, int, asymbol *));
+
+boolean elf32_hppa_size_stubs
+ PARAMS ((bfd *, bfd *, struct bfd_link_info *));
+
+boolean elf32_hppa_build_stubs
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+#endif /* _ELF32_HPPA_H */
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
new file mode 100644
index 00000000000..830c680e885
--- /dev/null
+++ b/bfd/elf32-i386.c
@@ -0,0 +1,1943 @@
+/* Intel 80386/80486-specific support for 32-bit ELF
+ Copyright 1993-1998, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+static reloc_howto_type *elf_i386_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void elf_i386_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static void elf_i386_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+static boolean elf_i386_is_local_label_name PARAMS ((bfd *, const char *));
+static struct bfd_hash_entry *elf_i386_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *elf_i386_link_hash_table_create
+ PARAMS ((bfd *));
+static boolean elf_i386_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static boolean elf_i386_adjust_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean elf_i386_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_i386_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean elf_i386_finish_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static boolean elf_i386_finish_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+#define USE_REL 1 /* 386 uses REL relocations instead of RELA */
+
+#include "elf/i386.h"
+
+static reloc_howto_type elf_howto_table[]=
+{
+ HOWTO(R_386_NONE, 0,0, 0,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_NONE", true,0x00000000,0x00000000,false),
+ HOWTO(R_386_32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_32", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_PC32, 0,2,32,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC32", true,0xffffffff,0xffffffff,true),
+ HOWTO(R_386_GOT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOT32", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_PLT32, 0,2,32,true,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PLT32", true,0xffffffff,0xffffffff,true),
+ HOWTO(R_386_COPY, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_COPY", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_GLOB_DAT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GLOB_DAT", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_JUMP_SLOT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_JUMP_SLOT",true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_RELATIVE, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_GOTOFF, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_GOTPC, 0,2,32,true,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTPC", true,0xffffffff,0xffffffff,true),
+ { 11 },
+ { 12 },
+ { 13 },
+ { 14 },
+ { 15 },
+ { 16 },
+ { 17 },
+ { 18 },
+ { 19 },
+ /* The remaining relocs are a GNU extension. */
+ HOWTO(R_386_16, 0,1,16,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_16", true,0xffff,0xffff,false),
+ HOWTO(R_386_PC16, 0,1,16,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC16", true,0xffff,0xffff,true),
+ HOWTO(R_386_8, 0,0,8,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_8", true,0xff,0xff,false),
+ HOWTO(R_386_PC8, 0,0,8,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC8", true,0xff,0xff,true),
+};
+
+/* GNU extension to record C++ vtable hierarchy. */
+static reloc_howto_type elf32_i386_vtinherit_howto =
+ HOWTO (R_386_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_386_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false);
+
+/* GNU extension to record C++ vtable member usage. */
+static reloc_howto_type elf32_i386_vtentry_howto =
+ HOWTO (R_386_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_386_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false);
+
+#ifdef DEBUG_GEN_RELOC
+#define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
+#else
+#define TRACE(str)
+#endif
+
+static reloc_howto_type *
+elf_i386_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_NONE:
+ TRACE ("BFD_RELOC_NONE");
+ return &elf_howto_table[ (int)R_386_NONE ];
+
+ case BFD_RELOC_32:
+ TRACE ("BFD_RELOC_32");
+ return &elf_howto_table[ (int)R_386_32 ];
+
+ case BFD_RELOC_CTOR:
+ TRACE ("BFD_RELOC_CTOR");
+ return &elf_howto_table[ (int)R_386_32 ];
+
+ case BFD_RELOC_32_PCREL:
+ TRACE ("BFD_RELOC_PC32");
+ return &elf_howto_table[ (int)R_386_PC32 ];
+
+ case BFD_RELOC_386_GOT32:
+ TRACE ("BFD_RELOC_386_GOT32");
+ return &elf_howto_table[ (int)R_386_GOT32 ];
+
+ case BFD_RELOC_386_PLT32:
+ TRACE ("BFD_RELOC_386_PLT32");
+ return &elf_howto_table[ (int)R_386_PLT32 ];
+
+ case BFD_RELOC_386_COPY:
+ TRACE ("BFD_RELOC_386_COPY");
+ return &elf_howto_table[ (int)R_386_COPY ];
+
+ case BFD_RELOC_386_GLOB_DAT:
+ TRACE ("BFD_RELOC_386_GLOB_DAT");
+ return &elf_howto_table[ (int)R_386_GLOB_DAT ];
+
+ case BFD_RELOC_386_JUMP_SLOT:
+ TRACE ("BFD_RELOC_386_JUMP_SLOT");
+ return &elf_howto_table[ (int)R_386_JUMP_SLOT ];
+
+ case BFD_RELOC_386_RELATIVE:
+ TRACE ("BFD_RELOC_386_RELATIVE");
+ return &elf_howto_table[ (int)R_386_RELATIVE ];
+
+ case BFD_RELOC_386_GOTOFF:
+ TRACE ("BFD_RELOC_386_GOTOFF");
+ return &elf_howto_table[ (int)R_386_GOTOFF ];
+
+ case BFD_RELOC_386_GOTPC:
+ TRACE ("BFD_RELOC_386_GOTPC");
+ return &elf_howto_table[ (int)R_386_GOTPC ];
+
+ /* The remaining relocs are a GNU extension. */
+ case BFD_RELOC_16:
+ TRACE ("BFD_RELOC_16");
+ return &elf_howto_table[(int) R_386_16];
+
+ case BFD_RELOC_16_PCREL:
+ TRACE ("BFD_RELOC_16_PCREL");
+ return &elf_howto_table[(int) R_386_PC16];
+
+ case BFD_RELOC_8:
+ TRACE ("BFD_RELOC_8");
+ return &elf_howto_table[(int) R_386_8];
+
+ case BFD_RELOC_8_PCREL:
+ TRACE ("BFD_RELOC_8_PCREL");
+ return &elf_howto_table[(int) R_386_PC8];
+
+ case BFD_RELOC_VTABLE_INHERIT:
+ TRACE ("BFD_RELOC_VTABLE_INHERIT");
+ return &elf32_i386_vtinherit_howto;
+
+ case BFD_RELOC_VTABLE_ENTRY:
+ TRACE ("BFD_RELOC_VTABLE_ENTRY");
+ return &elf32_i386_vtentry_howto;
+
+ default:
+ break;
+ }
+
+ TRACE ("Unknown");
+ return 0;
+}
+
+static void
+elf_i386_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ abort ();
+}
+
+static void
+elf_i386_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rel *dst;
+{
+ enum elf_i386_reloc_type type;
+
+ type = (enum elf_i386_reloc_type) ELF32_R_TYPE (dst->r_info);
+ if (type == R_386_GNU_VTINHERIT)
+ cache_ptr->howto = &elf32_i386_vtinherit_howto;
+ else if (type == R_386_GNU_VTENTRY)
+ cache_ptr->howto = &elf32_i386_vtentry_howto;
+ else
+ {
+ BFD_ASSERT (type < R_386_max);
+ BFD_ASSERT (type < FIRST_INVALID_RELOC || type > LAST_INVALID_RELOC);
+ cache_ptr->howto = &elf_howto_table[(int) type];
+ }
+}
+
+/* Return whether a symbol name implies a local label. The UnixWare
+ 2.1 cc generates temporary symbols that start with .X, so we
+ recognize them here. FIXME: do other SVR4 compilers also use .X?.
+ If so, we should move the .X recognition into
+ _bfd_elf_is_local_label_name. */
+
+static boolean
+elf_i386_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (name[0] == '.' && name[1] == 'X')
+ return true;
+
+ return _bfd_elf_is_local_label_name (abfd, name);
+}
+
+/* Functions for the i386 ELF linker. */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
+
+/* The size in bytes of an entry in the procedure linkage table. */
+
+#define PLT_ENTRY_SIZE 16
+
+/* The first entry in an absolute procedure linkage table looks like
+ this. See the SVR4 ABI i386 supplement to see how this works. */
+
+static const bfd_byte elf_i386_plt0_entry[PLT_ENTRY_SIZE] =
+{
+ 0xff, 0x35, /* pushl contents of address */
+ 0, 0, 0, 0, /* replaced with address of .got + 4. */
+ 0xff, 0x25, /* jmp indirect */
+ 0, 0, 0, 0, /* replaced with address of .got + 8. */
+ 0, 0, 0, 0 /* pad out to 16 bytes. */
+};
+
+/* Subsequent entries in an absolute procedure linkage table look like
+ this. */
+
+static const bfd_byte elf_i386_plt_entry[PLT_ENTRY_SIZE] =
+{
+ 0xff, 0x25, /* jmp indirect */
+ 0, 0, 0, 0, /* replaced with address of this symbol in .got. */
+ 0x68, /* pushl immediate */
+ 0, 0, 0, 0, /* replaced with offset into relocation table. */
+ 0xe9, /* jmp relative */
+ 0, 0, 0, 0 /* replaced with offset to start of .plt. */
+};
+
+/* The first entry in a PIC procedure linkage table look like this. */
+
+static const bfd_byte elf_i386_pic_plt0_entry[PLT_ENTRY_SIZE] =
+{
+ 0xff, 0xb3, 4, 0, 0, 0, /* pushl 4(%ebx) */
+ 0xff, 0xa3, 8, 0, 0, 0, /* jmp *8(%ebx) */
+ 0, 0, 0, 0 /* pad out to 16 bytes. */
+};
+
+/* Subsequent entries in a PIC procedure linkage table look like this. */
+
+static const bfd_byte elf_i386_pic_plt_entry[PLT_ENTRY_SIZE] =
+{
+ 0xff, 0xa3, /* jmp *offset(%ebx) */
+ 0, 0, 0, 0, /* replaced with offset of this symbol in .got. */
+ 0x68, /* pushl immediate */
+ 0, 0, 0, 0, /* replaced with offset into relocation table. */
+ 0xe9, /* jmp relative */
+ 0, 0, 0, 0 /* replaced with offset to start of .plt. */
+};
+
+/* The i386 linker needs to keep track of the number of relocs that it
+ decides to copy in check_relocs for each symbol. This is so that
+ it can discard PC relative relocs if it doesn't need them when
+ linking with -Bsymbolic. We store the information in a field
+ extending the regular ELF linker hash table. */
+
+/* This structure keeps track of the number of PC relative relocs we
+ have copied for a given symbol. */
+
+struct elf_i386_pcrel_relocs_copied
+{
+ /* Next section. */
+ struct elf_i386_pcrel_relocs_copied *next;
+ /* A section in dynobj. */
+ asection *section;
+ /* Number of relocs copied in this section. */
+ bfd_size_type count;
+};
+
+/* i386 ELF linker hash entry. */
+
+struct elf_i386_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* Number of PC relative relocs copied for this symbol. */
+ struct elf_i386_pcrel_relocs_copied *pcrel_relocs_copied;
+};
+
+/* i386 ELF linker hash table. */
+
+struct elf_i386_link_hash_table
+{
+ struct elf_link_hash_table root;
+};
+
+/* Declare this now that the above structures are defined. */
+
+static boolean elf_i386_discard_copies
+ PARAMS ((struct elf_i386_link_hash_entry *, PTR));
+
+/* Traverse an i386 ELF linker hash table. */
+
+#define elf_i386_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the i386 ELF linker hash table from a link_info structure. */
+
+#define elf_i386_hash_table(p) \
+ ((struct elf_i386_link_hash_table *) ((p)->hash))
+
+/* Create an entry in an i386 ELF linker hash table. */
+
+static struct bfd_hash_entry *
+elf_i386_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct elf_i386_link_hash_entry *ret =
+ (struct elf_i386_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct elf_i386_link_hash_entry *) NULL)
+ ret = ((struct elf_i386_link_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct elf_i386_link_hash_entry)));
+ if (ret == (struct elf_i386_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct elf_i386_link_hash_entry *)
+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct elf_i386_link_hash_entry *) NULL)
+ {
+ ret->pcrel_relocs_copied = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create an i386 ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+elf_i386_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf_i386_link_hash_table *ret;
+
+ ret = ((struct elf_i386_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf_i386_link_hash_table)));
+ if (ret == (struct elf_i386_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
+ elf_i386_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ return &ret->root.root;
+}
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+elf_i386_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sgot;
+ asection *srelgot;
+ asection *sreloc;
+
+ if (info->relocateable)
+ return true;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_offsets = elf_local_got_offsets (abfd);
+
+ sgot = NULL;
+ srelgot = NULL;
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ /* Some relocs require a global offset table. */
+ if (dynobj == NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_386_GOT32:
+ case R_386_GOTOFF:
+ case R_386_GOTPC:
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_386_GOT32:
+ /* This symbol requires a global offset table entry. */
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (srelgot == NULL
+ && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rel.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (h != NULL)
+ {
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ h->got.offset = sgot->_raw_size;
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ srelgot->_raw_size += sizeof (Elf32_External_Rel);
+ }
+ else
+ {
+ /* This is a global offset table entry for a local
+ symbol. */
+ if (local_got_offsets == NULL)
+ {
+ size_t size;
+ register unsigned int i;
+
+ size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
+ if (local_got_offsets == NULL)
+ return false;
+ elf_local_got_offsets (abfd) = local_got_offsets;
+ for (i = 0; i < symtab_hdr->sh_info; i++)
+ local_got_offsets[i] = (bfd_vma) -1;
+ }
+ if (local_got_offsets[r_symndx] != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ local_got_offsets[r_symndx] = sgot->_raw_size;
+
+ if (info->shared)
+ {
+ /* If we are generating a shared object, we need to
+ output a R_386_RELATIVE reloc so that the dynamic
+ linker can adjust this GOT entry. */
+ srelgot->_raw_size += sizeof (Elf32_External_Rel);
+ }
+ }
+
+ sgot->_raw_size += 4;
+
+ break;
+
+ case R_386_PLT32:
+ /* This symbol requires a procedure linkage table entry. We
+ actually build the entry in adjust_dynamic_symbol,
+ because this might be a case of linking PIC code which is
+ never referenced by a dynamic object, in which case we
+ don't need to generate a procedure linkage table entry
+ after all. */
+
+ /* If this is a local symbol, we resolve it directly without
+ creating a procedure linkage table entry. */
+ if (h == NULL)
+ continue;
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+
+ break;
+
+ case R_386_32:
+ case R_386_PC32:
+ /* If we are creating a shared library, and this is a reloc
+ against a global symbol, or a non PC relative reloc
+ against a local symbol, then we need to copy the reloc
+ into the shared library. However, if we are linking with
+ -Bsymbolic, we do not need to copy a reloc against a
+ global symbol which is defined in an object we are
+ including in the link (i.e., DEF_REGULAR is set). At
+ this point we have not seen all the input files, so it is
+ possible that DEF_REGULAR is not set now but will be set
+ later (it is never cleared). We account for that
+ possibility below by storing information in the
+ pcrel_relocs_copied field of the hash table entry. */
+ if (info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && (ELF32_R_TYPE (rel->r_info) != R_386_PC32
+ || (h != NULL
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ {
+ /* When creating a shared object, we must copy these
+ reloc types into the output file. We create a reloc
+ section in dynobj and make room for this reloc. */
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rel", 4) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ name + 4) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ }
+
+ sreloc->_raw_size += sizeof (Elf32_External_Rel);
+
+ /* If we are linking with -Bsymbolic, and this is a
+ global symbol, we count the number of PC relative
+ relocations we have entered for this symbol, so that
+ we can discard them again if the symbol is later
+ defined by a regular object. Note that this function
+ is only called if we are using an elf_i386 linker
+ hash table, which means that h is really a pointer to
+ an elf_i386_link_hash_entry. */
+ if (h != NULL && info->symbolic
+ && ELF32_R_TYPE (rel->r_info) == R_386_PC32)
+ {
+ struct elf_i386_link_hash_entry *eh;
+ struct elf_i386_pcrel_relocs_copied *p;
+
+ eh = (struct elf_i386_link_hash_entry *) h;
+
+ for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
+ if (p->section == sreloc)
+ break;
+
+ if (p == NULL)
+ {
+ p = ((struct elf_i386_pcrel_relocs_copied *)
+ bfd_alloc (dynobj, sizeof *p));
+ if (p == NULL)
+ return false;
+ p->next = eh->pcrel_relocs_copied;
+ eh->pcrel_relocs_copied = p;
+ p->section = sreloc;
+ p->count = 0;
+ }
+
+ ++p->count;
+ }
+ }
+
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_386_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_386_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+elf_i386_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_386_GNU_VTINHERIT:
+ case R_386_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+elf_i386_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ /* ??? It would seem that the existing i386 code does no sort
+ of reference counting or whatnot on its GOT and PLT entries,
+ so it is not possible to garbage collect them at this time. */
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf_i386_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj;
+ asection *s;
+ unsigned int power_of_two;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+ /* If this is a function, put it in the procedure linkage table. We
+ will fill in the contents of the procedure linkage table later,
+ when we know the address of the .got section. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)
+ {
+ /* This case can occur if we saw a PLT32 reloc in an input
+ file, but the symbol was never referred to by a dynamic
+ object. In such a case, we don't actually need to build
+ a procedure linkage table, and we can just do a PC32
+ reloc instead. */
+ BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
+ return true;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+ }
+
+ h->plt.offset = s->_raw_size;
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+
+ s = bfd_get_section_by_name (dynobj, ".got.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += 4;
+
+ /* We also need to make an entry in the .rel.plt section. */
+
+ s = bfd_get_section_by_name (dynobj, ".rel.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += sizeof (Elf32_External_Rel);
+
+ return true;
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ BFD_ASSERT (s != NULL);
+
+ /* We must generate a R_386_COPY reloc to tell the dynamic linker to
+ copy the initial value out of the dynamic object and into the
+ runtime process image. We need to remember the offset into the
+ .rel.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ asection *srel;
+
+ srel = bfd_get_section_by_name (dynobj, ".rel.bss");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf32_External_Rel);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 3)
+ power_of_two = 3;
+
+ /* Apply the required alignment. */
+ s->_raw_size = BFD_ALIGN (s->_raw_size,
+ (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ {
+ if (! bfd_set_section_alignment (dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf_i386_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean plt;
+ boolean relocs;
+ boolean reltext;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+ else
+ {
+ /* We may have created entries in the .rel.got section.
+ However, if we are not creating the dynamic sections, we will
+ not actually use these entries. Reset the size of .rel.got,
+ which will cause it to get stripped from the output file
+ below. */
+ s = bfd_get_section_by_name (dynobj, ".rel.got");
+ if (s != NULL)
+ s->_raw_size = 0;
+ }
+
+ /* If this is a -Bsymbolic shared link, then we need to discard all
+ PC relative relocs against symbols defined in a regular object.
+ We allocated space for them in the check_relocs routine, but we
+ will not fill them in in the relocate_section routine. */
+ if (info->shared && info->symbolic)
+ elf_i386_link_hash_traverse (elf_i386_hash_table (info),
+ elf_i386_discard_copies,
+ (PTR) NULL);
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ plt = false;
+ relocs = false;
+ reltext = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ strip = false;
+
+ if (strcmp (name, ".plt") == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
+ strip = true;
+ }
+ else
+ {
+ /* Remember whether there is a PLT. */
+ plt = true;
+ }
+ }
+ else if (strncmp (name, ".rel", 4) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is mostly to handle .rel.bss and
+ .rel.plt. We must create both sections in
+ create_dynamic_sections, because they must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ strip = true;
+ }
+ else
+ {
+ asection *target;
+
+ /* Remember whether there are any reloc sections other
+ than .rel.plt. */
+ if (strcmp (name, ".rel.plt") != 0)
+ {
+ const char *outname;
+
+ relocs = true;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL
+ entry. The entries in the .rel.plt section
+ really apply to the .got section, which we
+ created ourselves and so know is not readonly. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 4);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ reltext = true;
+ }
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strncmp (name, ".got", 4) != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ _bfd_strip_section_from_output (s);
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf_i386_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (! info->shared)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (plt)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
+ sizeof (Elf32_External_Rel)))
+ return false;
+ }
+
+ if (reltext)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* This function is called via elf_i386_link_hash_traverse if we are
+ creating a shared object with -Bsymbolic. It discards the space
+ allocated to copy PC relative relocs against symbols which are
+ defined in regular objects. We allocated space for them in the
+ check_relocs routine, but we won't fill them in in the
+ relocate_section routine. */
+
+/*ARGSUSED*/
+static boolean
+elf_i386_discard_copies (h, ignore)
+ struct elf_i386_link_hash_entry *h;
+ PTR ignore;
+{
+ struct elf_i386_pcrel_relocs_copied *s;
+
+ /* We only discard relocs for symbols defined in a regular object. */
+ if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ return true;
+
+ for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
+ s->section->_raw_size -= s->count * sizeof (Elf32_External_Rel);
+
+ return true;
+}
+
+/* Relocate an i386 ELF section. */
+
+static boolean
+elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ asection *sgot;
+ asection *splt;
+ asection *sreloc;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ sgot = NULL;
+ splt = NULL;
+ sreloc = NULL;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+ if (r_type == R_386_GNU_VTINHERIT
+ || r_type == R_386_GNU_VTENTRY)
+ continue;
+ if (r_type < 0
+ || r_type >= (int) R_386_max
+ || (r_type >= (int) FIRST_INVALID_RELOC
+ && r_type <= (int) LAST_INVALID_RELOC))
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ howto = elf_howto_table + r_type;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ bfd_vma val;
+
+ sec = local_sections[r_symndx];
+ val = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ val += sec->output_offset + sym->st_value;
+ bfd_put_32 (input_bfd, val, contents + rel->r_offset);
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ if (r_type == R_386_GOTPC
+ || (r_type == R_386_PLT32
+ && h->plt.offset != (bfd_vma) -1)
+ || (r_type == R_386_GOT32
+ && elf_hash_table (info)->dynamic_sections_created
+ && (! info->shared
+ || (! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ || (info->shared
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ && (r_type == R_386_32
+ || r_type == R_386_PC32)
+ && ((input_section->flags & SEC_ALLOC) != 0
+ /* DWARF will emit R_386_32 relocations in its
+ sections against symbols defined externally
+ in shared libraries. We can't do anything
+ with them here. */
+ || (input_section->flags & SEC_DEBUGGING) != 0)))
+ {
+ /* In these cases, we don't need the relocation
+ value. We check specially because in some
+ obscure cases sec->output_section will be NULL. */
+ relocation = 0;
+ }
+ else if (sec->output_section == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
+ bfd_get_filename (input_bfd), h->root.root.string,
+ bfd_get_section_name (input_bfd, input_section));
+ relocation = 0;
+ }
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ switch (r_type)
+ {
+ case R_386_GOT32:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (h != NULL)
+ {
+ bfd_vma off;
+
+ off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 4, we use the
+ least significant bit to record whether we have
+ initialized it already.
+
+ When doing a dynamic link, we create a .rel.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation,
+ sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+
+ relocation = sgot->output_offset + off;
+ }
+ else
+ {
+ bfd_vma off;
+
+ BFD_ASSERT (local_got_offsets != NULL
+ && local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use
+ the least significant bit to record whether we have
+ already generated the necessary reloc. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation, sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rel outrel;
+
+ srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
+ bfd_elf32_swap_reloc_out (output_bfd, &outrel,
+ (((Elf32_External_Rel *)
+ srelgot->contents)
+ + srelgot->reloc_count));
+ ++srelgot->reloc_count;
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+
+ relocation = sgot->output_offset + off;
+ }
+
+ break;
+
+ case R_386_GOTOFF:
+ /* Relocation is relative to the start of the global offset
+ table. */
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ /* Note that sgot->output_offset is not involved in this
+ calculation. We always want the start of .got. If we
+ defined _GLOBAL_OFFSET_TABLE in a different way, as is
+ permitted by the ABI, we might have to change this
+ calculation. */
+ relocation -= sgot->output_section->vma;
+
+ break;
+
+ case R_386_GOTPC:
+ /* Use global offset table as symbol value. */
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ relocation = sgot->output_section->vma;
+
+ break;
+
+ case R_386_PLT32:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+
+ /* Resolve a PLT32 reloc again a local symbol directly,
+ without using the procedure linkage table. */
+ if (h == NULL)
+ break;
+
+ if (h->plt.offset == (bfd_vma) -1)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ break;
+ }
+
+ if (splt == NULL)
+ {
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL);
+ }
+
+ relocation = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+
+ break;
+
+ case R_386_32:
+ case R_386_PC32:
+ if (info->shared
+ && (input_section->flags & SEC_ALLOC) != 0
+ && (r_type != R_386_PC32
+ || (h != NULL
+ && h->dynindx != -1
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ {
+ Elf_Internal_Rel outrel;
+ boolean skip, relocate;
+
+ /* When generating a shared object, these relocations
+ are copied into the output file to be resolved at run
+ time. */
+
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd,
+ elf_elfheader (input_bfd)->e_shstrndx,
+ elf_section_data (input_section)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rel", 4) == 0
+ && strcmp (bfd_get_section_name (input_bfd,
+ input_section),
+ name + 4) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ {
+ memset (&outrel, 0, sizeof outrel);
+ relocate = false;
+ }
+ else if (r_type == R_386_PC32)
+ {
+ BFD_ASSERT (h != NULL && h->dynindx != -1);
+ relocate = false;
+ outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_PC32);
+ }
+ else
+ {
+ /* h->dynindx may be -1 if this symbol was marked to
+ become local. */
+ if (h == NULL
+ || ((info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) != 0))
+ {
+ relocate = true;
+ outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
+ }
+ else
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ relocate = false;
+ outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_32);
+ }
+ }
+
+ bfd_elf32_swap_reloc_out (output_bfd, &outrel,
+ (((Elf32_External_Rel *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ /* If this reloc is against an external symbol, we do
+ not want to fiddle with the addend. Otherwise, we
+ need to include the symbol value so that it becomes
+ an addend for the dynamic reloc. */
+ if (! relocate)
+ continue;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, (bfd_vma) 0);
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection *splt;
+ asection *sgot;
+ asection *srel;
+ bfd_vma plt_index;
+ bfd_vma got_offset;
+ Elf_Internal_Rel rel;
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+ srel = bfd_get_section_by_name (dynobj, ".rel.plt");
+ BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
+
+ /* Get the index in the procedure linkage table which
+ corresponds to this symbol. This is the index of this symbol
+ in all the symbols for which we are making plt entries. The
+ first entry in the procedure linkage table is reserved. */
+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+
+ /* Get the offset into the .got table of the entry that
+ corresponds to this function. Each .got entry is 4 bytes.
+ The first three are reserved. */
+ got_offset = (plt_index + 3) * 4;
+
+ /* Fill in the entry in the procedure linkage table. */
+ if (! info->shared)
+ {
+ memcpy (splt->contents + h->plt.offset, elf_i386_plt_entry,
+ PLT_ENTRY_SIZE);
+ bfd_put_32 (output_bfd,
+ (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset),
+ splt->contents + h->plt.offset + 2);
+ }
+ else
+ {
+ memcpy (splt->contents + h->plt.offset, elf_i386_pic_plt_entry,
+ PLT_ENTRY_SIZE);
+ bfd_put_32 (output_bfd, got_offset,
+ splt->contents + h->plt.offset + 2);
+ }
+
+ bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel),
+ splt->contents + h->plt.offset + 7);
+ bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE),
+ splt->contents + h->plt.offset + 12);
+
+ /* Fill in the entry in the global offset table. */
+ bfd_put_32 (output_bfd,
+ (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset
+ + 6),
+ sgot->contents + got_offset);
+
+ /* Fill in the entry in the .rel.plt section. */
+ rel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset);
+ rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT);
+ bfd_elf32_swap_reloc_out (output_bfd, &rel,
+ ((Elf32_External_Rel *) srel->contents
+ + plt_index));
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ the .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ asection *sgot;
+ asection *srel;
+ Elf_Internal_Rel rel;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srel = bfd_get_section_by_name (dynobj, ".rel.got");
+ BFD_ASSERT (sgot != NULL && srel != NULL);
+
+ rel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + (h->got.offset &~ 1));
+
+ /* If this is a -Bsymbolic link, and the symbol is defined
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
+ if (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ rel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
+ else
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+ rel.r_info = ELF32_R_INFO (h->dynindx, R_386_GLOB_DAT);
+ }
+
+ bfd_elf32_swap_reloc_out (output_bfd, &rel,
+ ((Elf32_External_Rel *) srel->contents
+ + srel->reloc_count));
+ ++srel->reloc_count;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ asection *s;
+ Elf_Internal_Rel rel;
+
+ /* This symbol needs a copy reloc. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak));
+
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rel.bss");
+ BFD_ASSERT (s != NULL);
+
+ rel.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
+ bfd_elf32_swap_reloc_out (output_bfd, &rel,
+ ((Elf32_External_Rel *) s->contents
+ + s->reloc_count));
+ ++s->reloc_count;
+ }
+
+ /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf_i386_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *sgot;
+ asection *sdyn;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+ BFD_ASSERT (sgot != NULL);
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ BFD_ASSERT (sdyn != NULL);
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ asection *s;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ break;
+
+ case DT_PLTGOT:
+ name = ".got";
+ goto get_vma;
+ case DT_JMPREL:
+ name = ".rel.plt";
+ get_vma:
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_PLTRELSZ:
+ s = bfd_get_section_by_name (output_bfd, ".rel.plt");
+ BFD_ASSERT (s != NULL);
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_RELSZ:
+ /* My reading of the SVR4 ABI indicates that the
+ procedure linkage table relocs (DT_JMPREL) should be
+ included in the overall relocs (DT_REL). This is
+ what Solaris does. However, UnixWare can not handle
+ that case. Therefore, we override the DT_RELSZ entry
+ here to make it not include the JMPREL relocs. Since
+ the linker script arranges for .rel.plt to follow all
+ other relocation sections, we don't have to worry
+ about changing the DT_REL entry. */
+ s = bfd_get_section_by_name (output_bfd, ".rel.plt");
+ if (s != NULL)
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val -= s->_cooked_size;
+ else
+ dyn.d_un.d_val -= s->_raw_size;
+ }
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+ }
+ }
+
+ /* Fill in the first entry in the procedure linkage table. */
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ if (splt && splt->_raw_size > 0)
+ {
+ if (info->shared)
+ memcpy (splt->contents, elf_i386_pic_plt0_entry, PLT_ENTRY_SIZE);
+ else
+ {
+ memcpy (splt->contents, elf_i386_plt0_entry, PLT_ENTRY_SIZE);
+ bfd_put_32 (output_bfd,
+ sgot->output_section->vma + sgot->output_offset + 4,
+ splt->contents + 2);
+ bfd_put_32 (output_bfd,
+ sgot->output_section->vma + sgot->output_offset + 8,
+ splt->contents + 8);
+ }
+
+ /* UnixWare sets the entsize of .plt to 4, although that doesn't
+ really seem like the right value. */
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ }
+ }
+
+ /* Fill in the first three entries in the global offset table. */
+ if (sgot->_raw_size > 0)
+ {
+ if (sdyn == NULL)
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
+ else
+ bfd_put_32 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ sgot->contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
+ }
+
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+
+ return true;
+}
+
+#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
+#define TARGET_LITTLE_NAME "elf32-i386"
+#define ELF_ARCH bfd_arch_i386
+#define ELF_MACHINE_CODE EM_386
+#define ELF_MAXPAGESIZE 0x1000
+#define elf_info_to_howto elf_i386_info_to_howto
+#define elf_info_to_howto_rel elf_i386_info_to_howto_rel
+#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
+#define bfd_elf32_bfd_is_local_label_name \
+ elf_i386_is_local_label_name
+#define elf_backend_create_dynamic_sections \
+ _bfd_elf_create_dynamic_sections
+#define bfd_elf32_bfd_link_hash_table_create \
+ elf_i386_link_hash_table_create
+#define elf_backend_check_relocs elf_i386_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+ elf_i386_adjust_dynamic_symbol
+#define elf_backend_size_dynamic_sections \
+ elf_i386_size_dynamic_sections
+#define elf_backend_relocate_section elf_i386_relocate_section
+#define elf_backend_finish_dynamic_symbol \
+ elf_i386_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ elf_i386_finish_dynamic_sections
+#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook
+
+#define elf_backend_can_gc_sections 1
+#define elf_backend_want_got_plt 1
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_plt_sym 0
+#define elf_backend_got_header_size 12
+#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c
new file mode 100644
index 00000000000..a8537a75508
--- /dev/null
+++ b/bfd/elf32-i860.c
@@ -0,0 +1,33 @@
+/* Intel 860 specific support for 32-bit ELF
+ Copyright 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+#define elf_info_to_howto _bfd_elf_no_info_to_howto
+
+#define TARGET_BIG_SYM bfd_elf32_i860_vec
+#define TARGET_BIG_NAME "elf32-i860"
+#define ELF_ARCH bfd_arch_i860
+#define ELF_MACHINE_CODE EM_860
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
new file mode 100644
index 00000000000..b2f852370e9
--- /dev/null
+++ b/bfd/elf32-m32r.c
@@ -0,0 +1,2082 @@
+/* M32R-specific support for 32-bit ELF.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/m32r.h"
+
+static bfd_reloc_status_type m32r_elf_10_pcrel_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type m32r_elf_do_10_pcrel_reloc
+ PARAMS ((bfd *, reloc_howto_type *, asection *,
+ bfd_byte *, bfd_vma, asection *, bfd_vma, bfd_vma));
+static bfd_reloc_status_type m32r_elf_hi16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static void m32r_elf_relocate_hi16
+ PARAMS ((bfd *, int, Elf_Internal_Rela *, Elf_Internal_Rela *,
+ bfd_byte *, bfd_vma));
+bfd_reloc_status_type m32r_elf_lo16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type m32r_elf_sda16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void m32r_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+boolean _bfd_m32r_elf_section_from_bfd_section
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
+void _bfd_m32r_elf_symbol_processing
+ PARAMS ((bfd *, asymbol *));
+static boolean m32r_elf_add_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+ const char **, flagword *, asection **, bfd_vma *));
+static boolean m32r_elf_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+#if 0 /* not yet */
+static boolean m32r_elf_relax_delete_bytes
+ PARAMS ((bfd *, asection *, bfd_vma, int));
+#endif
+
+static bfd_reloc_status_type m32r_elf_final_sda_base
+ PARAMS ((bfd *, struct bfd_link_info *, const char **, bfd_vma *));
+static boolean m32r_elf_object_p
+ PARAMS ((bfd *));
+static void m32r_elf_final_write_processing
+ PARAMS ((bfd *, boolean));
+static boolean m32r_elf_set_private_flags
+ PARAMS ((bfd *, flagword));
+static boolean m32r_elf_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean m32r_elf_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean m32r_elf_print_private_bfd_data
+ PARAMS ((bfd *, PTR));
+
+#define NOP_INSN 0x7000
+#define MAKE_PARALLEL(insn) ((insn) | 0x8000)
+
+/* Use REL instead of RELA to save space.
+ This only saves space in libraries and object files, but perhaps
+ relocs will be put in ROM? All in all though, REL relocs are a pain
+ to work with. */
+#define USE_REL
+
+static reloc_howto_type m32r_elf_howto_table[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_M32R_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_M32R_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 16 bit absolute relocation. */
+ HOWTO (R_M32R_16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_M32R_16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 32 bit absolute relocation. */
+ HOWTO (R_M32R_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_M32R_32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 24 bit address. */
+ HOWTO (R_M32R_24, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 24, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_M32R_24", /* name */
+ true, /* partial_inplace */
+ 0xffffff, /* src_mask */
+ 0xffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An PC Relative 10-bit relocation, shifted by 2.
+ This reloc is complicated because relocations are relative to pc & -4.
+ i.e. branches in the right insn slot use the address of the left insn
+ slot for pc. */
+ /* ??? It's not clear whether this should have partial_inplace set or not.
+ Branch relaxing in the assembler can store the addend in the insn,
+ and if bfd_install_relocation gets called the addend may get added
+ again. */
+ HOWTO (R_M32R_10_PCREL, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 10, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ m32r_elf_10_pcrel_reloc, /* special_function */
+ "R_M32R_10_PCREL", /* name */
+ false, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 18 bit relocation, right shifted by 2. */
+ HOWTO (R_M32R_18_PCREL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_M32R_18_PCREL", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 26 bit relocation, right shifted by 2. */
+ /* ??? It's not clear whether this should have partial_inplace set or not.
+ Branch relaxing in the assembler can store the addend in the insn,
+ and if bfd_install_relocation gets called the addend may get added
+ again. */
+ HOWTO (R_M32R_26_PCREL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_M32R_26_PCREL", /* name */
+ false, /* partial_inplace */
+ 0xffffff, /* src_mask */
+ 0xffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* High 16 bits of address when lower 16 is or'd in. */
+ HOWTO (R_M32R_HI16_ULO, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ m32r_elf_hi16_reloc, /* special_function */
+ "R_M32R_HI16_ULO", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of address when lower 16 is added in. */
+ HOWTO (R_M32R_HI16_SLO, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ m32r_elf_hi16_reloc, /* special_function */
+ "R_M32R_HI16_SLO", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Lower 16 bits of address. */
+ HOWTO (R_M32R_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ m32r_elf_lo16_reloc, /* special_function */
+ "R_M32R_LO16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Small data area 16 bits offset. */
+ HOWTO (R_M32R_SDA16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ m32r_elf_sda16_reloc, /* special_function */
+ "R_M32R_SDA16", /* name */
+ true, /* partial_inplace */ /* FIXME: correct? */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_M32R_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_M32R_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_M32R_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_M32R_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+/* Handle the R_M32R_10_PCREL reloc. */
+
+static bfd_reloc_status_type
+m32r_elf_10_pcrel_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd * abfd;
+ arelent * reloc_entry;
+ asymbol * symbol;
+ PTR data;
+ asection * input_section;
+ bfd * output_bfd;
+ char ** error_message;
+{
+ /* This part is from bfd_elf_generic_reloc. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc_entry->howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != NULL)
+ {
+ /* FIXME: See bfd_perform_relocation. Is this right? */
+ return bfd_reloc_continue;
+ }
+
+ return m32r_elf_do_10_pcrel_reloc (abfd, reloc_entry->howto,
+ input_section,
+ data, reloc_entry->address,
+ symbol->section,
+ (symbol->value
+ + symbol->section->output_section->vma
+ + symbol->section->output_offset),
+ reloc_entry->addend);
+}
+
+/* Utility to actually perform an R_M32R_10_PCREL reloc. */
+
+static bfd_reloc_status_type
+m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset,
+ symbol_section, symbol_value, addend)
+ bfd *abfd;
+ reloc_howto_type *howto;
+ asection *input_section;
+ bfd_byte *data;
+ bfd_vma offset;
+ asection *symbol_section;
+ bfd_vma symbol_value;
+ bfd_vma addend;
+{
+ bfd_signed_vma relocation;
+ unsigned long x;
+ bfd_reloc_status_type status;
+
+ /* Sanity check the address (offset in section). */
+ if (offset > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ relocation = symbol_value + addend;
+ /* Make it pc relative. */
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ /* These jumps mask off the lower two bits of the current address
+ before doing pcrel calculations. */
+ relocation -= (offset & -4L);
+
+ if (relocation < -0x200 || relocation > 0x1ff)
+ status = bfd_reloc_overflow;
+ else
+ status = bfd_reloc_ok;
+
+ x = bfd_get_16 (abfd, data + offset);
+ relocation >>= howto->rightshift;
+ relocation <<= howto->bitpos;
+ x = (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask);
+ bfd_put_16 (abfd, x, data + offset);
+
+ return status;
+}
+
+/* Handle the R_M32R_HI16_[SU]LO relocs.
+ HI16_SLO is for the add3 and load/store with displacement instructions.
+ HI16_ULO is for the or3 instruction.
+ For R_M32R_HI16_SLO, the lower 16 bits are sign extended when added to
+ the high 16 bytes so if the lower 16 bits are negative (bit 15 == 1) then
+ we must add one to the high 16 bytes (which will get subtracted off when
+ the low 16 bits are added).
+ These relocs have to be done in combination with an R_M32R_LO16 reloc
+ because there is a carry from the LO16 to the HI16. Here we just save
+ the information we need; we do the actual relocation when we see the LO16.
+ This code is copied from the elf32-mips.c. We also support an arbitrary
+ number of HI16 relocs to be associated with a single LO16 reloc. The
+ assembler sorts the relocs to ensure each HI16 immediately precedes its
+ LO16. However if there are multiple copies, the assembler may not find
+ the real LO16 so it picks the first one it finds. */
+
+struct m32r_hi16
+{
+ struct m32r_hi16 *next;
+ bfd_byte *addr;
+ bfd_vma addend;
+};
+
+/* FIXME: This should not be a static variable. */
+
+static struct m32r_hi16 *m32r_hi16_list;
+
+static bfd_reloc_status_type
+m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_reloc_status_type ret;
+ bfd_vma relocation;
+ struct m32r_hi16 *n;
+
+ /* This part is from bfd_elf_generic_reloc.
+ If we're relocating, and this an external symbol, we don't want
+ to change anything. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* Sanity check the address (offset in section). */
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ ret = bfd_reloc_ok;
+ if (bfd_is_und_section (symbol->section)
+ && output_bfd == (bfd *) NULL)
+ ret = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ /* Save the information, and let LO16 do the actual relocation. */
+ n = (struct m32r_hi16 *) bfd_malloc (sizeof *n);
+ if (n == NULL)
+ return bfd_reloc_outofrange;
+ n->addr = (bfd_byte *) data + reloc_entry->address;
+ n->addend = relocation;
+ n->next = m32r_hi16_list;
+ m32r_hi16_list = n;
+
+ if (output_bfd != (bfd *) NULL)
+ reloc_entry->address += input_section->output_offset;
+
+ return ret;
+}
+
+/* Handle an M32R ELF HI16 reloc. */
+
+static void
+m32r_elf_relocate_hi16 (input_bfd, type, relhi, rello, contents, addend)
+ bfd *input_bfd;
+ int type;
+ Elf_Internal_Rela *relhi;
+ Elf_Internal_Rela *rello;
+ bfd_byte *contents;
+ bfd_vma addend;
+{
+ unsigned long insn;
+ bfd_vma addlo;
+
+ insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
+
+ addlo = bfd_get_32 (input_bfd, contents + rello->r_offset);
+ if (type == R_M32R_HI16_SLO)
+ addlo = ((addlo & 0xffff) ^ 0x8000) - 0x8000;
+ else
+ addlo &= 0xffff;
+
+ addend += ((insn & 0xffff) << 16) + addlo;
+
+ /* Reaccount for sign extension of low part. */
+ if (type == R_M32R_HI16_SLO
+ && (addend & 0x8000) != 0)
+ addend += 0x10000;
+
+ bfd_put_32 (input_bfd,
+ (insn & 0xffff0000) | ((addend >> 16) & 0xffff),
+ contents + relhi->r_offset);
+}
+
+/* Do an R_M32R_LO16 relocation. This is a straightforward 16 bit
+ inplace relocation; this function exists in order to do the
+ R_M32R_HI16_[SU]LO relocation described above. */
+
+bfd_reloc_status_type
+m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (m32r_hi16_list != NULL)
+ {
+ struct m32r_hi16 *l;
+
+ l = m32r_hi16_list;
+ while (l != NULL)
+ {
+ unsigned long insn;
+ unsigned long val;
+ unsigned long vallo;
+ struct m32r_hi16 *next;
+
+ /* Do the HI16 relocation. Note that we actually don't need
+ to know anything about the LO16 itself, except where to
+ find the low 16 bits of the addend needed by the LO16. */
+ insn = bfd_get_32 (abfd, l->addr);
+ vallo = ((bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
+ & 0xffff) ^ 0x8000) - 0x8000;
+ val = ((insn & 0xffff) << 16) + vallo;
+ val += l->addend;
+
+ /* Reaccount for sign extension of low part. */
+ if ((val & 0x8000) != 0)
+ val += 0x10000;
+
+ insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, insn, l->addr);
+
+ next = l->next;
+ free (l);
+ l = next;
+ }
+
+ m32r_hi16_list = NULL;
+ }
+
+ /* Now do the LO16 reloc in the usual way. */
+ return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+}
+
+/* Handle the R_M32R_SDA16 reloc.
+ This reloc is used to compute the address of objects in the small data area
+ and to perform loads and stores from that area.
+ The lower 16 bits are sign extended and added to the register specified
+ in the instruction, which is assumed to point to _SDA_BASE_. */
+
+static bfd_reloc_status_type
+m32r_elf_sda16_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* This part is from bfd_elf_generic_reloc. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc_entry->howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != NULL)
+ {
+ /* FIXME: See bfd_perform_relocation. Is this right? */
+ return bfd_reloc_continue;
+ }
+
+ /* FIXME: not sure what to do here yet. But then again, the linker
+ may never call us. */
+ abort ();
+}
+
+/* Map BFD reloc types to M32R ELF reloc types. */
+
+struct m32r_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static const struct m32r_reloc_map m32r_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_M32R_NONE },
+ { BFD_RELOC_16, R_M32R_16 },
+ { BFD_RELOC_32, R_M32R_32 },
+ { BFD_RELOC_M32R_24, R_M32R_24 },
+ { BFD_RELOC_M32R_10_PCREL, R_M32R_10_PCREL },
+ { BFD_RELOC_M32R_18_PCREL, R_M32R_18_PCREL },
+ { BFD_RELOC_M32R_26_PCREL, R_M32R_26_PCREL },
+ { BFD_RELOC_M32R_HI16_ULO, R_M32R_HI16_ULO },
+ { BFD_RELOC_M32R_HI16_SLO, R_M32R_HI16_SLO },
+ { BFD_RELOC_M32R_LO16, R_M32R_LO16 },
+ { BFD_RELOC_M32R_SDA16, R_M32R_SDA16 },
+ { BFD_RELOC_VTABLE_INHERIT, R_M32R_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_M32R_GNU_VTENTRY },
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (m32r_reloc_map) / sizeof (struct m32r_reloc_map);
+ i++)
+ {
+ if (m32r_reloc_map[i].bfd_reloc_val == code)
+ return &m32r_elf_howto_table[m32r_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Set the howto pointer for an M32R ELF reloc. */
+
+static void
+m32r_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rel *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_M32R_max);
+ cache_ptr->howto = &m32r_elf_howto_table[r_type];
+}
+
+/* Given a BFD section, try to locate the corresponding ELF section
+ index. */
+
+boolean
+_bfd_m32r_elf_section_from_bfd_section (abfd, hdr, sec, retval)
+ bfd *abfd;
+ Elf32_Internal_Shdr *hdr;
+ asection *sec;
+ int *retval;
+{
+ if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+ {
+ *retval = SHN_M32R_SCOMMON;
+ return true;
+ }
+ return false;
+}
+
+/* M32R ELF uses two common sections. One is the usual one, and the other
+ is for small objects. All the small objects are kept together, and then
+ referenced via one register, which yields faster assembler code. It is
+ up to the compiler to emit an instruction to load the register with
+ _SDA_BASE. This is what we use for the small common section. This
+ approach is copied from elf32-mips.c. */
+static asection m32r_elf_scom_section;
+static asymbol m32r_elf_scom_symbol;
+static asymbol *m32r_elf_scom_symbol_ptr;
+
+/* Handle the special M32R section numbers that a symbol may use. */
+
+void
+_bfd_m32r_elf_symbol_processing (abfd, asym)
+ bfd *abfd;
+ asymbol *asym;
+{
+ elf_symbol_type *elfsym;
+
+ elfsym = (elf_symbol_type *) asym;
+
+ switch (elfsym->internal_elf_sym.st_shndx)
+ {
+ case SHN_M32R_SCOMMON:
+ if (m32r_elf_scom_section.name == NULL)
+ {
+ /* Initialize the small common section. */
+ m32r_elf_scom_section.name = ".scommon";
+ m32r_elf_scom_section.flags = SEC_IS_COMMON;
+ m32r_elf_scom_section.output_section = &m32r_elf_scom_section;
+ m32r_elf_scom_section.symbol = &m32r_elf_scom_symbol;
+ m32r_elf_scom_section.symbol_ptr_ptr = &m32r_elf_scom_symbol_ptr;
+ m32r_elf_scom_symbol.name = ".scommon";
+ m32r_elf_scom_symbol.flags = BSF_SECTION_SYM;
+ m32r_elf_scom_symbol.section = &m32r_elf_scom_section;
+ m32r_elf_scom_symbol_ptr = &m32r_elf_scom_symbol;
+ }
+ asym->section = &m32r_elf_scom_section;
+ asym->value = elfsym->internal_elf_sym.st_size;
+ break;
+ }
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+ file. We must handle the special M32R section numbers here.
+ We also keep watching for whether we need to create the sdata special
+ linker sections. */
+
+static boolean
+m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const Elf_Internal_Sym *sym;
+ const char **namep;
+ flagword *flagsp;
+ asection **secp;
+ bfd_vma *valp;
+{
+ if (! info->relocateable
+ && (*namep)[0] == '_' && (*namep)[1] == 'S'
+ && strcmp (*namep, "_SDA_BASE_") == 0)
+ {
+ /* This is simpler than using _bfd_elf_create_linker_section
+ (our needs are simpler than ppc's needs). Also
+ _bfd_elf_create_linker_section currently has a bug where if a .sdata
+ section already exists a new one is created that follows it which
+ screws of _SDA_BASE_ address calcs because output_offset != 0. */
+ struct elf_link_hash_entry *h;
+ asection *s = bfd_get_section_by_name (abfd, ".sdata");
+
+ /* The following code was cobbled from elf32-ppc.c and elflink.c. */
+
+ if (s == NULL)
+ {
+ int flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+
+ s = bfd_make_section_anyway (abfd, ".sdata");
+ if (s == NULL)
+ return false;
+ bfd_set_section_flags (abfd, s, flags);
+ bfd_set_section_alignment (abfd, s, 2);
+ }
+
+ h = (struct elf_link_hash_entry *)
+ bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, false);
+
+ if ((h == NULL || h->root.type == bfd_link_hash_undefined)
+ && !(_bfd_generic_link_add_one_symbol (info,
+ abfd,
+ "_SDA_BASE_",
+ BSF_GLOBAL,
+ s,
+ 32768,
+ (const char *) NULL,
+ false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->type = STT_OBJECT;
+ }
+
+ switch (sym->st_shndx)
+ {
+ case SHN_M32R_SCOMMON:
+ *secp = bfd_make_section_old_way (abfd, ".scommon");
+ (*secp)->flags |= SEC_IS_COMMON;
+ *valp = sym->st_size;
+ break;
+ }
+
+ return true;
+}
+
+/* We have to figure out the SDA_BASE value, so that we can adjust the
+ symbol value correctly. We look up the symbol _SDA_BASE_ in the output
+ BFD. If we can't find it, we're stuck. We cache it in the ELF
+ target data. We don't need to adjust the symbol value for an
+ external symbol if we are producing relocateable output. */
+
+static bfd_reloc_status_type
+m32r_elf_final_sda_base (output_bfd, info, error_message, psb)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ const char **error_message;
+ bfd_vma *psb;
+{
+ if (elf_gp (output_bfd) == 0)
+ {
+ struct bfd_link_hash_entry *h;
+
+ h = bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, true);
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_defined)
+ elf_gp (output_bfd) = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+ else
+ {
+ /* Only get the error once. */
+ *psb = elf_gp (output_bfd) = 4;
+ *error_message =
+ (const char *) _("SDA relocation when _SDA_BASE_ not defined");
+ return bfd_reloc_dangerous;
+ }
+ }
+ *psb = elf_gp (output_bfd);
+ return bfd_reloc_ok;
+}
+
+/* Relocate an M32R/D ELF section.
+ There is some attempt to make this function usable for many architectures,
+ both USE_REL and USE_RELA ['twould be nice if such a critter existed],
+ if only to serve as a learning tool.
+
+ The RELOCATE_SECTION function is called by the new ELF backend linker
+ to handle the relocations for a section.
+
+ The relocs are always passed as Rela structures; if the section
+ actually uses Rel structures, the r_addend field will always be
+ zero.
+
+ This function is responsible for adjust the section contents as
+ necessary, and (if using Rela relocs and generating a
+ relocateable output file) adjusting the reloc addend as
+ necessary.
+
+ This function does not have to worry about setting the reloc
+ address or the reloc symbol index.
+
+ LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+ LOCAL_SECTIONS is an array giving the section in the input file
+ corresponding to the st_shndx field of each local symbol.
+
+ The global hash table entry for the global symbols can be found
+ via elf_sym_hashes (input_bfd).
+
+ When generating relocateable output, this function must handle
+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
+ going to be the section symbol corresponding to the output
+ section, which means that the addend must be adjusted
+ accordingly. */
+
+static boolean
+m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
+ Elf_Internal_Rela *rel, *relend;
+ /* Assume success. */
+ boolean ret = true;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ /* We can't modify r_addend here as elf_link_input_bfd has an assert to
+ ensure it's zero (we use REL relocs, not RELA). Therefore this
+ should be assigning zero to `addend', but for clarity we use
+ `r_addend'. */
+ bfd_vma addend = rel->r_addend;
+ bfd_vma offset = rel->r_offset;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ const char *sym_name;
+ bfd_reloc_status_type r;
+ const char *errmsg = NULL;
+
+ h = NULL;
+ r_type = ELF32_R_TYPE (rel->r_info);
+ if (r_type < 0 || r_type >= (int) R_M32R_max)
+ {
+ (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
+ bfd_get_filename (input_bfd),
+ (int) r_type);
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+ }
+
+ if (r_type == R_M32R_GNU_VTENTRY
+ || r_type == R_M32R_GNU_VTINHERIT)
+ continue;
+
+ howto = m32r_elf_howto_table + r_type;
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ sec = NULL;
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ /* External symbol. */
+ continue;
+ }
+
+ /* Local symbol. */
+ sym = local_syms + r_symndx;
+ sym_name = "<local symbol>";
+ /* STT_SECTION: symbol is associated with a section. */
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+ {
+ /* Symbol isn't associated with a section. Nothing to do. */
+ continue;
+ }
+
+ sec = local_sections[r_symndx];
+ addend += sec->output_offset + sym->st_value;
+#ifndef USE_REL
+ /* This can't be done for USE_REL because it doesn't mean anything
+ and elf_link_input_bfd asserts this stays zero. */
+ rel->r_addend = addend;
+#endif
+
+#ifndef USE_REL
+ /* Addends are stored with relocs. We're done. */
+ continue;
+#else /* USE_REL */
+ /* If partial_inplace, we need to store any additional addend
+ back in the section. */
+ if (! howto->partial_inplace)
+ continue;
+ /* ??? Here is a nice place to call a special_function
+ like handler. */
+ if (r_type != R_M32R_HI16_SLO && r_type != R_M32R_HI16_ULO)
+ r = _bfd_relocate_contents (howto, input_bfd,
+ addend, contents + offset);
+ else
+ {
+ Elf_Internal_Rela *lorel;
+
+ /* We allow an arbitrary number of HI16 relocs before the
+ LO16 reloc. This permits gcc to emit the HI and LO relocs
+ itself. */
+ for (lorel = rel + 1;
+ (lorel < relend
+ && (ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_SLO
+ || ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_ULO));
+ lorel++)
+ continue;
+ if (lorel < relend
+ && ELF32_R_TYPE (lorel->r_info) == R_M32R_LO16)
+ {
+ m32r_elf_relocate_hi16 (input_bfd, r_type, rel, lorel,
+ contents, addend);
+ r = bfd_reloc_ok;
+ }
+ else
+ r = _bfd_relocate_contents (howto, input_bfd,
+ addend, contents + offset);
+ }
+#endif /* USE_REL */
+ }
+ else
+ {
+ bfd_vma relocation;
+
+ /* This is a final link. */
+ sym = NULL;
+ sec = NULL;
+
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ /* Local symbol. */
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ sym_name = "<local symbol>";
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ /* External symbol. */
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ sym_name = h->root.root.string;
+
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ if (sec->output_section == NULL)
+ relocation = 0;
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ /* Sanity check the address. */
+ if (offset > input_section->_raw_size)
+ {
+ r = bfd_reloc_outofrange;
+ goto check_reloc;
+ }
+
+ switch ((int) r_type)
+ {
+ case (int) R_M32R_10_PCREL :
+ r = m32r_elf_do_10_pcrel_reloc (input_bfd, howto, input_section,
+ contents, offset,
+ sec, relocation, addend);
+ break;
+
+ case (int) R_M32R_HI16_SLO :
+ case (int) R_M32R_HI16_ULO :
+ {
+ Elf_Internal_Rela *lorel;
+
+ /* We allow an arbitrary number of HI16 relocs before the
+ LO16 reloc. This permits gcc to emit the HI and LO relocs
+ itself. */
+ for (lorel = rel + 1;
+ (lorel < relend
+ && (ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_SLO
+ || ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_ULO));
+ lorel++)
+ continue;
+ if (lorel < relend
+ && ELF32_R_TYPE (lorel->r_info) == R_M32R_LO16)
+ {
+ m32r_elf_relocate_hi16 (input_bfd, r_type, rel, lorel,
+ contents, relocation + addend);
+ r = bfd_reloc_ok;
+ }
+ else
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, offset,
+ relocation, addend);
+ }
+ break;
+
+ case (int) R_M32R_SDA16 :
+ {
+ const char *name;
+
+ BFD_ASSERT (sec != NULL);
+ name = bfd_get_section_name (abfd, sec);
+
+ if (strcmp (name, ".sdata") == 0
+ || strcmp (name, ".sbss") == 0
+ || strcmp (name, ".scommon") == 0)
+ {
+ bfd_vma sda_base;
+ bfd *out_bfd = sec->output_section->owner;
+
+ r = m32r_elf_final_sda_base (out_bfd, info,
+ &errmsg,
+ &sda_base);
+ if (r != bfd_reloc_ok)
+ {
+ ret = false;
+ goto check_reloc;
+ }
+
+ /* At this point `relocation' contains the object's
+ address. */
+ relocation -= sda_base;
+ /* Now it contains the offset from _SDA_BASE_. */
+ }
+ else
+ {
+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
+ bfd_get_filename (input_bfd),
+ sym_name,
+ m32r_elf_howto_table[(int) r_type].name,
+ bfd_get_section_name (abfd, sec));
+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
+ ret = false;
+ continue;
+ }
+ }
+ /* fall through */
+
+ default :
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, offset,
+ relocation, addend);
+ break;
+ }
+ }
+
+ check_reloc:
+
+ if (r != bfd_reloc_ok)
+ {
+ /* FIXME: This should be generic enough to go in a utility. */
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL || *name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ if (errmsg != NULL)
+ goto common_error;
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, offset)))
+ return false;
+ break;
+
+ case bfd_reloc_undefined:
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section,
+ offset)))
+ return false;
+ break;
+
+ case bfd_reloc_outofrange:
+ errmsg = _("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ errmsg = _("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ errmsg = _("internal error: dangerous error");
+ goto common_error;
+
+ default:
+ errmsg = _("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, errmsg, name, input_bfd, input_section,
+ offset)))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
+#if 0 /* relaxing not supported yet */
+
+/* This function handles relaxing for the m32r.
+ Relaxing on the m32r is tricky because of instruction alignment
+ requirements (4 byte instructions must be aligned on 4 byte boundaries).
+
+ The following relaxing opportunities are handled:
+
+ seth/add3/jl -> bl24 or bl8
+ seth/add3 -> ld24
+
+ It would be nice to handle bl24 -> bl8 but given:
+
+ - 4 byte insns must be on 4 byte boundaries
+ - branch instructions only branch to insns on 4 byte boundaries
+
+ this isn't much of a win because the insn in the 2 "deleted" bytes
+ must become a nop. With some complexity some real relaxation could be
+ done but the frequency just wouldn't make it worth it; it's better to
+ try to do all the code compaction one can elsewhere.
+ When the chip supports parallel 16 bit insns, things may change.
+*/
+
+static boolean
+m32r_elf_relax_section (abfd, sec, link_info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ /* The Rela structures are used here because that's what
+ _bfd_elf32_link_read_relocs uses [for convenience - it sets the addend
+ field to 0]. */
+ Elf_Internal_Rela *internal_relocs;
+ Elf_Internal_Rela *free_relocs = NULL;
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+ Elf32_External_Sym *extsyms = NULL;
+ Elf32_External_Sym *free_extsyms = NULL;
+
+ /* Assume nothing changes. */
+ *again = false;
+
+ /* We don't have to do anything for a relocateable link, if
+ this section does not have relocs, or if this is not a
+ code section. */
+ if (link_info->relocateable
+ || (sec->flags & SEC_RELOC) == 0
+ || sec->reloc_count == 0
+ || (sec->flags & SEC_CODE) == 0
+ || 0 /* FIXME: check SHF_M32R_CAN_RELAX */)
+ return true;
+
+ /* If this is the first time we have been called for this section,
+ initialize the cooked size. */
+ if (sec->_cooked_size == 0)
+ sec->_cooked_size = sec->_raw_size;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+ /* Get a copy of the native relocations. */
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ /* Walk through them looking for relaxing opportunities. */
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma symval;
+
+ /* If this isn't something that can be relaxed, then ignore
+ this reloc. */
+ if (ELF32_R_TYPE (irel->r_info) != (int) R_M32R_HI16_SLO)
+ continue;
+
+ /* Get the section contents if we haven't done so already. */
+ if (contents == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* Read this BFD's symbols if we haven't done so already. */
+ if (extsyms == NULL)
+ {
+ /* Get cached copy if it exists. */
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ /* Go get them off disk. */
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ /* Get the value of the symbol referred to by the reloc. */
+ if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+ {
+ Elf_Internal_Sym isym;
+ asection *sym_sec;
+
+ /* A local symbol. */
+ bfd_elf32_swap_symbol_in (abfd,
+ extsyms + ELF32_R_SYM (irel->r_info),
+ &isym);
+
+ sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
+ symval = (isym.st_value
+ + sym_sec->output_section->vma
+ + sym_sec->output_offset);
+ }
+ else
+ {
+ unsigned long indx;
+ struct elf_link_hash_entry *h;
+
+ /* An external symbol. */
+ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+ h = elf_sym_hashes (abfd)[indx];
+ BFD_ASSERT (h != NULL);
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ {
+ /* This appears to be a reference to an undefined
+ symbol. Just ignore it--it will be caught by the
+ regular reloc processing. */
+ continue;
+ }
+
+ symval = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+
+ /* For simplicity of coding, we are going to modify the section
+ contents, the section relocs, and the BFD symbol table. We
+ must tell the rest of the code not to free up this
+ information. It would be possible to instead create a table
+ of changes which have to be made, as is done in coff-mips.c;
+ that would be more work, but would require less memory when
+ the linker is run. */
+
+ /* Try to change a seth/add3/jl subroutine call to bl24 or bl8.
+ This sequence is generated by the compiler when compiling in
+ 32 bit mode. Also look for seth/add3 -> ld24. */
+
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_M32R_HI16_SLO)
+ {
+ Elf_Internal_Rela *nrel;
+ bfd_vma pc = (sec->output_section->vma + sec->output_offset
+ + irel->r_offset);
+ bfd_signed_vma pcrel_value = symval - pc;
+ unsigned int code,reg;
+ int addend,nop_p,bl8_p,to_delete;
+
+ /* The tests are ordered so that we get out as quickly as possible
+ if this isn't something we can relax, taking into account that
+ we are looking for two separate possibilities (jl/ld24). */
+
+ /* Do nothing if no room in the section for this to be what we're
+ looking for. */
+ if (irel->r_offset > sec->_cooked_size - 8)
+ continue;
+
+ /* Make sure the next relocation applies to the next
+ instruction and that it's the add3's reloc. */
+ nrel = irel + 1;
+ if (nrel == irelend
+ || irel->r_offset + 4 != nrel->r_offset
+ || ELF32_R_TYPE (nrel->r_info) != (int) R_M32R_LO16)
+ continue;
+
+ /* See if the instructions are seth/add3. */
+ /* FIXME: This is where macros from cgen can come in. */
+ code = bfd_get_16 (abfd, contents + irel->r_offset + 0);
+ if ((code & 0xf0ff) != 0xd0c0)
+ continue; /* not seth rN,foo */
+ reg = (code & 0x0f00) >> 8;
+ code = bfd_get_16 (abfd, contents + irel->r_offset + 4);
+ if (code != (0x80a0 | reg | (reg << 8)))
+ continue; /* not add3 rN,rN,foo */
+
+ /* At this point we've confirmed we have seth/add3. Now check
+ whether the next insn is a jl, in which case try to change this
+ to bl24 or bl8. */
+
+ /* Ensure the branch target is in range.
+ The bl24 instruction has a 24 bit operand which is the target
+ address right shifted by 2, giving a signed range of 26 bits.
+ Note that 4 bytes are added to the high value because the target
+ will be at least 4 bytes closer if we can relax. It'll actually
+ be 4 or 8 bytes closer, but we don't know which just yet and
+ the difference isn't significant enough to worry about. */
+#ifndef USE_REL /* put in for learning purposes */
+ pcrel_value += irel->r_addend;
+#else
+ addend = bfd_get_signed_16 (abfd, contents + irel->r_offset + 2);
+ pcrel_value += addend;
+#endif
+
+ if (pcrel_value >= -(1 << 25) && pcrel_value < (1 << 25) + 4
+ /* Do nothing if no room in the section for this to be what we're
+ looking for. */
+ && (irel->r_offset <= sec->_cooked_size - 12)
+ /* Ensure the next insn is "jl rN". */
+ && ((code = bfd_get_16 (abfd, contents + irel->r_offset + 8)),
+ code != (0x1ec0 | reg)))
+ {
+ /* We can relax to bl24/bl8. */
+
+ /* See if there's a nop following the jl.
+ Also see if we can use a bl8 insn. */
+ code = bfd_get_16 (abfd, contents + irel->r_offset + 10);
+ nop_p = (code & 0x7fff) == NOP_INSN;
+ bl8_p = pcrel_value >= -0x200 && pcrel_value < 0x200;
+
+ if (bl8_p)
+ {
+ /* Change "seth rN,foo" to "bl8 foo || nop".
+ We OR in CODE just in case it's not a nop (technically,
+ CODE currently must be a nop, but for cleanness we
+ allow it to be anything). */
+#ifndef USE_REL /* put in for learning purposes */
+ code = 0x7e000000 | MAKE_PARALLEL (code);
+#else
+ code = (0x7e000000 + (((addend >> 2) & 0xff) << 16)) | MAKE_PARALLEL (code);
+#endif
+ to_delete = 8;
+ }
+ else
+ {
+ /* Change the seth rN,foo to a bl24 foo. */
+#ifndef USE_REL /* put in for learning purposes */
+ code = 0xfe000000;
+#else
+ code = 0xfe000000 + ((addend >> 2) & 0xffffff);
+#endif
+ to_delete = nop_p ? 8 : 4;
+ }
+
+ bfd_put_32 (abfd, code, contents + irel->r_offset);
+
+ /* Set the new reloc type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
+ bl8_p ? R_M32R_10_PCREL : R_M32R_26_PCREL);
+
+ /* Delete the add3 reloc by making it a null reloc. */
+ nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
+ R_M32R_NONE);
+ }
+ else if (addend >= 0
+ && symval + addend <= 0xffffff)
+ {
+ /* We can relax to ld24. */
+
+ code = 0xe0000000 | (reg << 24) | (addend & 0xffffff);
+ bfd_put_32 (abfd, code, contents + irel->r_offset);
+ to_delete = 4;
+ /* Tell the following code a nop filler isn't needed. */
+ nop_p = 1;
+ }
+ else
+ {
+ /* Can't do anything here. */
+ continue;
+ }
+
+ /* Note that we've changed the relocs, section contents, etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Delete TO_DELETE bytes of data. */
+ if (!m32r_elf_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 4, to_delete))
+ goto error_return;
+
+ /* Now that the following bytes have been moved into place, see if
+ we need to replace the jl with a nop. This happens when we had
+ to use a bl24 insn and the insn following the jl isn't a nop.
+ Technically, this situation can't happen (since the insn can
+ never be executed) but to be clean we do this. When the chip
+ supports parallel 16 bit insns things may change.
+ We don't need to do this in the case of relaxing to ld24,
+ and the above code sets nop_p so this isn't done. */
+ if (! nop_p && to_delete == 4)
+ bfd_put_16 (abfd, NOP_INSN, contents + irel->r_offset + 4);
+
+ /* That will change things, so we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = true;
+
+ continue;
+ }
+
+ /* loop to try the next reloc */
+ }
+
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (sec)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ free_extsyms = NULL;
+ }
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ if (free_extsyms != NULL)
+ free (free_extsyms);
+ return false;
+}
+
+/* Delete some bytes from a section while relaxing. */
+
+static boolean
+m32r_elf_relax_delete_bytes (abfd, sec, addr, count)
+ bfd *abfd;
+ asection *sec;
+ bfd_vma addr;
+ int count;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf32_External_Sym *extsyms;
+ int shndx, index;
+ bfd_byte *contents;
+ Elf_Internal_Rela *irel, *irelend;
+ Elf_Internal_Rela *irelalign;
+ bfd_vma toaddr;
+ Elf32_External_Sym *esym, *esymend;
+ struct elf_link_hash_entry *sym_hash;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ contents = elf_section_data (sec)->this_hdr.contents;
+
+ /* The deletion must stop at the next ALIGN reloc for an aligment
+ power larger than the number of bytes we are deleting. */
+
+ irelalign = NULL;
+ toaddr = sec->_cooked_size;
+
+ irel = elf_section_data (sec)->relocs;
+ irelend = irel + sec->reloc_count;
+
+ /* Actually delete the bytes. */
+ memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ sec->_cooked_size -= count;
+
+ /* Adjust all the relocs. */
+ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+ {
+ /* Get the new reloc address. */
+ if ((irel->r_offset > addr
+ && irel->r_offset < toaddr))
+ irel->r_offset -= count;
+ }
+
+ /* Adjust the local symbols defined in this section. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+
+ if (isym.st_shndx == shndx
+ && isym.st_value > addr
+ && isym.st_value < toaddr)
+ {
+ isym.st_value -= count;
+ bfd_elf32_swap_symbol_out (abfd, &isym, esym);
+ }
+ }
+
+ /* Now adjust the global symbols defined in this section. */
+ esym = extsyms + symtab_hdr->sh_info;
+ esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
+ for (index = 0; esym < esymend; esym++, index++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+ sym_hash = elf_sym_hashes (abfd)[index];
+ if (isym.st_shndx == shndx
+ && ((sym_hash)->root.type == bfd_link_hash_defined
+ || (sym_hash)->root.type == bfd_link_hash_defweak)
+ && (sym_hash)->root.u.def.section == sec
+ && (sym_hash)->root.u.def.value > addr
+ && (sym_hash)->root.u.def.value < toaddr)
+ {
+ (sym_hash)->root.u.def.value -= count;
+ }
+ }
+
+ return true;
+}
+
+/* This is a version of bfd_generic_get_relocated_section_contents
+ which uses m32r_elf_relocate_section. */
+
+static bfd_byte *
+m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *input_section = link_order->u.indirect.section;
+ bfd *input_bfd = input_section->owner;
+ asection **sections = NULL;
+ Elf_Internal_Rela *internal_relocs = NULL;
+ Elf32_External_Sym *external_syms = NULL;
+ Elf_Internal_Sym *internal_syms = NULL;
+
+ /* We only need to handle the case of relaxing, or of having a
+ particular set of section contents, specially. */
+ if (relocateable
+ || elf_section_data (input_section)->this_hdr.contents == NULL)
+ return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
+ link_order, data,
+ relocateable,
+ symbols);
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ memcpy (data, elf_section_data (input_section)->this_hdr.contents,
+ input_section->_raw_size);
+
+ if ((input_section->flags & SEC_RELOC) != 0
+ && input_section->reloc_count > 0)
+ {
+ Elf_Internal_Sym *isymp;
+ asection **secpp;
+ Elf32_External_Sym *esym, *esymend;
+
+ if (symtab_hdr->contents != NULL)
+ external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ external_syms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf32_External_Sym)));
+ if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
+ symtab_hdr->sh_info, input_bfd)
+ != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ goto error_return;
+ }
+
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (input_bfd, input_section, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL, false));
+ if (internal_relocs == NULL)
+ goto error_return;
+
+ internal_syms = ((Elf_Internal_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf_Internal_Sym)));
+ if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ sections = (asection **) bfd_malloc (symtab_hdr->sh_info
+ * sizeof (asection *));
+ if (sections == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ isymp = internal_syms;
+ secpp = sections;
+ esym = external_syms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; ++esym, ++isymp, ++secpp)
+ {
+ asection *isec;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, isymp);
+
+ if (isymp->st_shndx == SHN_UNDEF)
+ isec = bfd_und_section_ptr;
+ else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
+ isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
+ else if (isymp->st_shndx == SHN_ABS)
+ isec = bfd_abs_section_ptr;
+ else if (isymp->st_shndx == SHN_COMMON)
+ isec = bfd_com_section_ptr;
+ else if (isymp->st_shndx == SHN_M32R_SCOMMON)
+ isec = &m32r_elf_scom_section;
+ else
+ {
+ /* Who knows? */
+ isec = NULL;
+ }
+
+ *secpp = isec;
+ }
+
+ if (! m32r_elf_relocate_section (output_bfd, link_info, input_bfd,
+ input_section, data, internal_relocs,
+ internal_syms, sections))
+ goto error_return;
+
+ if (sections != NULL)
+ free (sections);
+ sections = NULL;
+ if (internal_syms != NULL)
+ free (internal_syms);
+ internal_syms = NULL;
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ external_syms = NULL;
+ if (internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ internal_relocs = NULL;
+ }
+
+ return data;
+
+ error_return:
+ if (internal_relocs != NULL
+ && internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ if (internal_syms != NULL)
+ free (internal_syms);
+ if (sections != NULL)
+ free (sections);
+ return NULL;
+}
+
+#endif /* #if 0 */
+
+/* Set the right machine number. */
+static boolean
+m32r_elf_object_p (abfd)
+ bfd *abfd;
+{
+ switch (elf_elfheader (abfd)->e_flags & EF_M32R_ARCH)
+ {
+ default:
+ case E_M32R_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_m32r, bfd_mach_m32r); break;
+ }
+ return true;
+}
+
+/* Store the machine number in the flags field. */
+static void
+m32r_elf_final_write_processing (abfd, linker)
+ bfd * abfd;
+ boolean linker;
+{
+ unsigned long val;
+
+ switch (bfd_get_mach (abfd))
+ {
+ default:
+ case bfd_mach_m32r: val = E_M32R_ARCH; break;
+ }
+
+ elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH;
+ elf_elfheader (abfd)->e_flags |= val;
+}
+
+/* Function to keep M32R specific file flags. */
+static boolean
+m32r_elf_set_private_flags (abfd, flags)
+ bfd * abfd;
+ flagword flags;
+{
+ BFD_ASSERT (!elf_flags_init (abfd)
+ || elf_elfheader (abfd)->e_flags == flags);
+
+ elf_elfheader (abfd)->e_flags = flags;
+ elf_flags_init (abfd) = true;
+ return true;
+}
+
+/* Copy backend specific data from one object module to another */
+static boolean
+m32r_elf_copy_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ BFD_ASSERT (!elf_flags_init (obfd)
+ || (elf_elfheader (obfd)->e_flags
+ == elf_elfheader (ibfd)->e_flags));
+
+ elf_gp (obfd) = elf_gp (ibfd);
+ elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+ elf_flags_init (obfd) = true;
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+static boolean
+m32r_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ flagword out_flags;
+ flagword in_flags;
+
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ in_flags = elf_elfheader (ibfd)->e_flags;
+ out_flags = elf_elfheader (obfd)->e_flags;
+
+ if (! elf_flags_init (obfd))
+ {
+ /* If the input is the default architecture then do not
+ bother setting the flags for the output architecture,
+ instead allow future merges to do this. If no future
+ merges ever set these flags then they will retain their
+ unitialised values, which surprise surprise, correspond
+ to the default values. */
+ if (bfd_get_arch_info (ibfd)->the_default)
+ return true;
+
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = in_flags;
+
+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+ && bfd_get_arch_info (obfd)->the_default)
+ {
+ return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
+ }
+
+ return true;
+ }
+
+ /* Check flag compatibility. */
+ if (in_flags == out_flags)
+ return true;
+
+ if ((in_flags & EF_M32R_ARCH) != (out_flags & EF_M32R_ARCH))
+ {
+ if ((in_flags & EF_M32R_ARCH) != E_M32R_ARCH)
+ {
+ _bfd_error_handler (_("%s: Instruction set mismatch with previous modules"),
+ bfd_get_filename (ibfd));
+
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Display the flags field */
+static boolean
+m32r_elf_print_private_bfd_data (abfd, ptr)
+ bfd * abfd;
+ PTR ptr;
+{
+ FILE * file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL)
+
+ _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+ fprintf (file, _("private flags = %lx"), elf_elfheader (abfd)->e_flags);
+
+ switch (elf_elfheader (abfd)->e_flags & EF_M32R_ARCH)
+ {
+ default:
+ case E_M32R_ARCH: fprintf (file, _(": m32r instructions")); break;
+ }
+
+ fputc ('\n', file);
+
+ return true;
+}
+
+asection *
+m32r_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_M32R_GNU_VTINHERIT:
+ case R_M32R_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+ return NULL;
+}
+
+static boolean
+m32r_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ /* we don't use got and plt entries for m32r */
+ return true;
+}
+
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+m32r_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+
+ if (info->relocateable)
+ return true;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry *h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_M32R_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_M32R_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+
+
+
+#define ELF_ARCH bfd_arch_m32r
+#define ELF_MACHINE_CODE EM_CYGNUS_M32R
+#define ELF_MAXPAGESIZE 0x1000
+
+#define TARGET_BIG_SYM bfd_elf32_m32r_vec
+#define TARGET_BIG_NAME "elf32-m32r"
+
+#define elf_info_to_howto 0
+#define elf_info_to_howto_rel m32r_info_to_howto_rel
+#define elf_backend_section_from_bfd_section _bfd_m32r_elf_section_from_bfd_section
+#define elf_backend_symbol_processing _bfd_m32r_elf_symbol_processing
+#define elf_backend_add_symbol_hook m32r_elf_add_symbol_hook
+#define elf_backend_relocate_section m32r_elf_relocate_section
+#define elf_backend_gc_mark_hook m32r_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook m32r_elf_gc_sweep_hook
+#define elf_backend_check_relocs m32r_elf_check_relocs
+
+#define elf_backend_can_gc_sections 1
+#if 0 /* not yet */
+/* relax support */
+#define bfd_elf32_bfd_relax_section m32r_elf_relax_section
+#define bfd_elf32_bfd_get_relocated_section_contents \
+ m32r_elf_get_relocated_section_contents
+#endif
+
+#define elf_backend_object_p m32r_elf_object_p
+#define elf_backend_final_write_processing m32r_elf_final_write_processing
+#define bfd_elf32_bfd_copy_private_bfd_data m32r_elf_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data m32r_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_set_private_flags m32r_elf_set_private_flags
+#define bfd_elf32_bfd_print_private_bfd_data m32r_elf_print_private_bfd_data
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
new file mode 100644
index 00000000000..2d0aba210fb
--- /dev/null
+++ b/bfd/elf32-m68k.c
@@ -0,0 +1,2128 @@
+/* Motorola 68k series support for 32-bit ELF
+ Copyright 1993, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/m68k.h"
+
+static reloc_howto_type *reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void rtype_to_howto
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static struct bfd_hash_entry *elf_m68k_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *elf_m68k_link_hash_table_create
+ PARAMS ((bfd *));
+static boolean elf_m68k_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static asection *elf_m68k_gc_mark_hook
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
+static boolean elf_m68k_gc_sweep_hook
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static boolean elf_m68k_adjust_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean elf_m68k_adjust_dynindx
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_m68k_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_m68k_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean elf_m68k_finish_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static boolean elf_m68k_finish_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+static reloc_howto_type howto_table[] = {
+ HOWTO(R_68K_NONE, 0, 0, 0, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_NONE", false, 0, 0x00000000,false),
+ HOWTO(R_68K_32, 0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32", false, 0, 0xffffffff,false),
+ HOWTO(R_68K_16, 0, 1,16, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16", false, 0, 0x0000ffff,false),
+ HOWTO(R_68K_8, 0, 0, 8, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_8", false, 0, 0x000000ff,false),
+ HOWTO(R_68K_PC32, 0, 2,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PC32", false, 0, 0xffffffff,true),
+ HOWTO(R_68K_PC16, 0, 1,16, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PC16", false, 0, 0x0000ffff,true),
+ HOWTO(R_68K_PC8, 0, 0, 8, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PC8", false, 0, 0x000000ff,true),
+ HOWTO(R_68K_GOT32, 0, 2,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32", false, 0, 0xffffffff,true),
+ HOWTO(R_68K_GOT16, 0, 1,16, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT16", false, 0, 0x0000ffff,true),
+ HOWTO(R_68K_GOT8, 0, 0, 8, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT8", false, 0, 0x000000ff,true),
+ HOWTO(R_68K_GOT32O, 0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32O", false, 0, 0xffffffff,false),
+ HOWTO(R_68K_GOT16O, 0, 1,16, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT16O", false, 0, 0x0000ffff,false),
+ HOWTO(R_68K_GOT8O, 0, 0, 8, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT8O", false, 0, 0x000000ff,false),
+ HOWTO(R_68K_PLT32, 0, 2,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32", false, 0, 0xffffffff,true),
+ HOWTO(R_68K_PLT16, 0, 1,16, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT16", false, 0, 0x0000ffff,true),
+ HOWTO(R_68K_PLT8, 0, 0, 8, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT8", false, 0, 0x000000ff,true),
+ HOWTO(R_68K_PLT32O, 0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32O", false, 0, 0xffffffff,false),
+ HOWTO(R_68K_PLT16O, 0, 1,16, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT16O", false, 0, 0x0000ffff,false),
+ HOWTO(R_68K_PLT8O, 0, 0, 8, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT8O", false, 0, 0x000000ff,false),
+ HOWTO(R_68K_COPY, 0, 0, 0, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_COPY", false, 0, 0xffffffff,false),
+ HOWTO(R_68K_GLOB_DAT, 0, 2,32, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_GLOB_DAT", false, 0, 0xffffffff,false),
+ HOWTO(R_68K_JMP_SLOT, 0, 2,32, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_JMP_SLOT", false, 0, 0xffffffff,false),
+ HOWTO(R_68K_RELATIVE, 0, 2,32, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_RELATIVE", false, 0, 0xffffffff,false),
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_68K_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_68K_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false),
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_68K_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_68K_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false),
+};
+
+static void
+rtype_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf_Internal_Rela *dst;
+{
+ BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_68K_max);
+ cache_ptr->howto = &howto_table[ELF32_R_TYPE(dst->r_info)];
+}
+
+#define elf_info_to_howto rtype_to_howto
+
+static const struct
+{
+ bfd_reloc_code_real_type bfd_val;
+ int elf_val;
+} reloc_map[] = {
+ { BFD_RELOC_NONE, R_68K_NONE },
+ { BFD_RELOC_32, R_68K_32 },
+ { BFD_RELOC_16, R_68K_16 },
+ { BFD_RELOC_8, R_68K_8 },
+ { BFD_RELOC_32_PCREL, R_68K_PC32 },
+ { BFD_RELOC_16_PCREL, R_68K_PC16 },
+ { BFD_RELOC_8_PCREL, R_68K_PC8 },
+ { BFD_RELOC_32_GOT_PCREL, R_68K_GOT32 },
+ { BFD_RELOC_16_GOT_PCREL, R_68K_GOT16 },
+ { BFD_RELOC_8_GOT_PCREL, R_68K_GOT8 },
+ { BFD_RELOC_32_GOTOFF, R_68K_GOT32O },
+ { BFD_RELOC_16_GOTOFF, R_68K_GOT16O },
+ { BFD_RELOC_8_GOTOFF, R_68K_GOT8O },
+ { BFD_RELOC_32_PLT_PCREL, R_68K_PLT32 },
+ { BFD_RELOC_16_PLT_PCREL, R_68K_PLT16 },
+ { BFD_RELOC_8_PLT_PCREL, R_68K_PLT8 },
+ { BFD_RELOC_32_PLTOFF, R_68K_PLT32O },
+ { BFD_RELOC_16_PLTOFF, R_68K_PLT16O },
+ { BFD_RELOC_8_PLTOFF, R_68K_PLT8O },
+ { BFD_RELOC_NONE, R_68K_COPY },
+ { BFD_RELOC_68K_GLOB_DAT, R_68K_GLOB_DAT },
+ { BFD_RELOC_68K_JMP_SLOT, R_68K_JMP_SLOT },
+ { BFD_RELOC_68K_RELATIVE, R_68K_RELATIVE },
+ { BFD_RELOC_CTOR, R_68K_32 },
+ { BFD_RELOC_VTABLE_INHERIT, R_68K_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_68K_GNU_VTENTRY },
+};
+
+static reloc_howto_type *
+reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+ for (i = 0; i < sizeof (reloc_map) / sizeof (reloc_map[0]); i++)
+ {
+ if (reloc_map[i].bfd_val == code)
+ return &howto_table[reloc_map[i].elf_val];
+ }
+ return 0;
+}
+
+#define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup
+#define ELF_ARCH bfd_arch_m68k
+/* end code generated by elf.el */
+
+#define USE_RELA
+
+
+/* Functions for the m68k ELF linker. */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
+
+/* The size in bytes of an entry in the procedure linkage table. */
+
+#define PLT_ENTRY_SIZE 20
+
+/* The first entry in a procedure linkage table looks like this. See
+ the SVR4 ABI m68k supplement to see how this works. */
+
+static const bfd_byte elf_m68k_plt0_entry[PLT_ENTRY_SIZE] =
+{
+ 0x2f, 0x3b, 0x01, 0x70, /* move.l (%pc,addr),-(%sp) */
+ 0, 0, 0, 0, /* replaced with offset to .got + 4. */
+ 0x4e, 0xfb, 0x01, 0x71, /* jmp ([%pc,addr]) */
+ 0, 0, 0, 0, /* replaced with offset to .got + 8. */
+ 0, 0, 0, 0 /* pad out to 20 bytes. */
+};
+
+/* Subsequent entries in a procedure linkage table look like this. */
+
+static const bfd_byte elf_m68k_plt_entry[PLT_ENTRY_SIZE] =
+{
+ 0x4e, 0xfb, 0x01, 0x71, /* jmp ([%pc,symbol@GOTPC]) */
+ 0, 0, 0, 0, /* replaced with offset to symbol's .got entry. */
+ 0x2f, 0x3c, /* move.l #offset,-(%sp) */
+ 0, 0, 0, 0, /* replaced with offset into relocation table. */
+ 0x60, 0xff, /* bra.l .plt */
+ 0, 0, 0, 0 /* replaced with offset to start of .plt. */
+};
+
+/* The m68k linker needs to keep track of the number of relocs that it
+ decides to copy in check_relocs for each symbol. This is so that it
+ can discard PC relative relocs if it doesn't need them when linking
+ with -Bsymbolic. We store the information in a field extending the
+ regular ELF linker hash table. */
+
+/* This structure keeps track of the number of PC relative relocs we have
+ copied for a given symbol. */
+
+struct elf_m68k_pcrel_relocs_copied
+{
+ /* Next section. */
+ struct elf_m68k_pcrel_relocs_copied *next;
+ /* A section in dynobj. */
+ asection *section;
+ /* Number of relocs copied in this section. */
+ bfd_size_type count;
+};
+
+/* m68k ELF linker hash entry. */
+
+struct elf_m68k_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* Number of PC relative relocs copied for this symbol. */
+ struct elf_m68k_pcrel_relocs_copied *pcrel_relocs_copied;
+};
+
+/* m68k ELF linker hash table. */
+
+struct elf_m68k_link_hash_table
+{
+ struct elf_link_hash_table root;
+};
+
+/* Declare this now that the above structures are defined. */
+
+static boolean elf_m68k_discard_copies
+ PARAMS ((struct elf_m68k_link_hash_entry *, PTR));
+
+/* Traverse an m68k ELF linker hash table. */
+
+#define elf_m68k_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the m68k ELF linker hash table from a link_info structure. */
+
+#define elf_m68k_hash_table(p) \
+ ((struct elf_m68k_link_hash_table *) (p)->hash)
+
+/* Create an entry in an m68k ELF linker hash table. */
+
+static struct bfd_hash_entry *
+elf_m68k_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct elf_m68k_link_hash_entry *ret =
+ (struct elf_m68k_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct elf_m68k_link_hash_entry *) NULL)
+ ret = ((struct elf_m68k_link_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct elf_m68k_link_hash_entry)));
+ if (ret == (struct elf_m68k_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct elf_m68k_link_hash_entry *)
+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct elf_m68k_link_hash_entry *) NULL)
+ {
+ ret->pcrel_relocs_copied = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create an m68k ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+elf_m68k_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf_m68k_link_hash_table *ret;
+
+ ret = ((struct elf_m68k_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct elf_m68k_link_hash_table)));
+ if (ret == (struct elf_m68k_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
+ elf_m68k_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ return &ret->root.root;
+}
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+elf_m68k_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sgot;
+ asection *srelgot;
+ asection *sreloc;
+
+ if (info->relocateable)
+ return true;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ sgot = NULL;
+ srelgot = NULL;
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_68K_GOT8:
+ case R_68K_GOT16:
+ case R_68K_GOT32:
+ if (h != NULL
+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* Fall through. */
+ case R_68K_GOT8O:
+ case R_68K_GOT16O:
+ case R_68K_GOT32O:
+ /* This symbol requires a global offset table entry. */
+
+ if (dynobj == NULL)
+ {
+ /* Create the .got section. */
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (!_bfd_elf_create_got_section (dynobj, info))
+ return false;
+ }
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (srelgot == NULL
+ && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (srelgot == NULL
+ || !bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || !bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (h != NULL)
+ {
+ if (h->got.refcount == -1)
+ {
+ h->got.refcount = 1;
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (!bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ /* Allocate space in the .got section. */
+ sgot->_raw_size += 4;
+ /* Allocate relocation space. */
+ srelgot->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ else
+ h->got.refcount++;
+ }
+ else
+ {
+ /* This is a global offset table entry for a local symbol. */
+ if (local_got_refcounts == NULL)
+ {
+ size_t size;
+
+ size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
+ local_got_refcounts = ((bfd_signed_vma *)
+ bfd_alloc (abfd, size));
+ if (local_got_refcounts == NULL)
+ return false;
+ elf_local_got_refcounts (abfd) = local_got_refcounts;
+ memset (local_got_refcounts, -1, size);
+ }
+ if (local_got_refcounts[r_symndx] == -1)
+ {
+ local_got_refcounts[r_symndx] = 1;
+
+ sgot->_raw_size += 4;
+ if (info->shared)
+ {
+ /* If we are generating a shared object, we need to
+ output a R_68K_RELATIVE reloc so that the dynamic
+ linker can adjust this GOT entry. */
+ srelgot->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ }
+ else
+ local_got_refcounts[r_symndx]++;
+ }
+ break;
+
+ case R_68K_PLT8:
+ case R_68K_PLT16:
+ case R_68K_PLT32:
+ /* This symbol requires a procedure linkage table entry. We
+ actually build the entry in adjust_dynamic_symbol,
+ because this might be a case of linking PIC code which is
+ never referenced by a dynamic object, in which case we
+ don't need to generate a procedure linkage table entry
+ after all. */
+
+ /* If this is a local symbol, we resolve it directly without
+ creating a procedure linkage table entry. */
+ if (h == NULL)
+ continue;
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ if (h->plt.refcount == -1)
+ h->plt.refcount = 1;
+ else
+ h->plt.refcount++;
+ break;
+
+ case R_68K_PLT8O:
+ case R_68K_PLT16O:
+ case R_68K_PLT32O:
+ /* This symbol requires a procedure linkage table entry. */
+
+ if (h == NULL)
+ {
+ /* It does not make sense to have this relocation for a
+ local symbol. FIXME: does it? How to handle it if
+ it does make sense? */
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (!bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ if (h->plt.refcount == -1)
+ h->plt.refcount = 1;
+ else
+ h->plt.refcount++;
+ break;
+
+ case R_68K_PC8:
+ case R_68K_PC16:
+ case R_68K_PC32:
+ /* If we are creating a shared library and this is not a local
+ symbol, we need to copy the reloc into the shared library.
+ However when linking with -Bsymbolic and this is a global
+ symbol which is defined in an object we are including in the
+ link (i.e., DEF_REGULAR is set), then we can resolve the
+ reloc directly. At this point we have not seen all the input
+ files, so it is possible that DEF_REGULAR is not set now but
+ will be set later (it is never cleared). We account for that
+ possibility below by storing information in the
+ pcrel_relocs_copied field of the hash table entry. */
+ if (!(info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && h != NULL
+ && (!info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+ {
+ if (h != NULL)
+ {
+ /* Make sure a plt entry is created for this symbol if
+ it turns out to be a function defined by a dynamic
+ object. */
+ if (h->plt.refcount == -1)
+ h->plt.refcount = 1;
+ else
+ h->plt.refcount++;
+ }
+ break;
+ }
+ /* Fall through. */
+ case R_68K_8:
+ case R_68K_16:
+ case R_68K_32:
+ if (h != NULL)
+ {
+ /* Make sure a plt entry is created for this symbol if it
+ turns out to be a function defined by a dynamic object. */
+ if (h->plt.refcount == -1)
+ h->plt.refcount = 1;
+ else
+ h->plt.refcount++;
+ }
+
+ /* If we are creating a shared library, we need to copy the
+ reloc into the shared library. */
+ if (info->shared
+ && (sec->flags & SEC_ALLOC) != 0)
+ {
+ /* When creating a shared object, we must copy these
+ reloc types into the output file. We create a reloc
+ section in dynobj and make room for this reloc. */
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ sreloc = bfd_make_section (dynobj, name);
+ if (sreloc == NULL
+ || !bfd_set_section_flags (dynobj, sreloc,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || !bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ }
+
+ sreloc->_raw_size += sizeof (Elf32_External_Rela);
+
+ /* If we are linking with -Bsymbolic, we count the number of
+ PC relative relocations we have entered for this symbol,
+ so that we can discard them again if the symbol is later
+ defined by a regular object. Note that this function is
+ only called if we are using an m68kelf linker hash table,
+ which means that h is really a pointer to an
+ elf_m68k_link_hash_entry. */
+ if ((ELF32_R_TYPE (rel->r_info) == R_68K_PC8
+ || ELF32_R_TYPE (rel->r_info) == R_68K_PC16
+ || ELF32_R_TYPE (rel->r_info) == R_68K_PC32)
+ && info->symbolic)
+ {
+ struct elf_m68k_link_hash_entry *eh;
+ struct elf_m68k_pcrel_relocs_copied *p;
+
+ eh = (struct elf_m68k_link_hash_entry *) h;
+
+ for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
+ if (p->section == sreloc)
+ break;
+
+ if (p == NULL)
+ {
+ p = ((struct elf_m68k_pcrel_relocs_copied *)
+ bfd_alloc (dynobj, sizeof *p));
+ if (p == NULL)
+ return false;
+ p->next = eh->pcrel_relocs_copied;
+ eh->pcrel_relocs_copied = p;
+ p->section = sreloc;
+ p->count = 0;
+ }
+
+ ++p->count;
+ }
+ }
+
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_68K_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_68K_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+elf_m68k_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_68K_GNU_VTINHERIT:
+ case R_68K_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ default:
+ break;
+
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+elf_m68k_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel, *relend;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ bfd *dynobj;
+ asection *sgot;
+ asection *srelgot;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ dynobj = elf_hash_table (info)->dynobj;
+ if (dynobj)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ }
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; rel++)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_68K_GOT8:
+ case R_68K_GOT16:
+ case R_68K_GOT32:
+ case R_68K_GOT8O:
+ case R_68K_GOT16O:
+ case R_68K_GOT32O:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->got.refcount > 0)
+ {
+ --h->got.refcount;
+ if (h->got.refcount == 0)
+ {
+ /* We don't need the .got entry any more. */
+ sgot->_raw_size -= 4;
+ srelgot->_raw_size -= sizeof (Elf32_External_Rela);
+ }
+ }
+ }
+ else
+ {
+ if (local_got_refcounts[r_symndx] > 0)
+ {
+ --local_got_refcounts[r_symndx];
+ if (local_got_refcounts[r_symndx] == 0)
+ {
+ /* We don't need the .got entry any more. */
+ sgot->_raw_size -= 4;
+ if (info->shared)
+ srelgot->_raw_size -= sizeof (Elf32_External_Rela);
+ }
+ }
+ }
+ break;
+
+ case R_68K_PLT8:
+ case R_68K_PLT16:
+ case R_68K_PLT32:
+ case R_68K_PLT8O:
+ case R_68K_PLT16O:
+ case R_68K_PLT32O:
+ case R_68K_PC8:
+ case R_68K_PC16:
+ case R_68K_PC32:
+ case R_68K_8:
+ case R_68K_16:
+ case R_68K_32:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->plt.refcount > 0)
+ --h->plt.refcount;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf_m68k_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj;
+ asection *s;
+ unsigned int power_of_two;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+ /* If this is a function, put it in the procedure linkage table. We
+ will fill in the contents of the procedure linkage table later,
+ when we know the address of the .got section. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
+ /* We must always create the plt entry if it was referenced
+ by a PLTxxO relocation. In this case we already recorded
+ it as a dynamic symbol. */
+ && h->dynindx == -1)
+ {
+ /* This case can occur if we saw a PLTxx reloc in an input
+ file, but the symbol was never referred to by a dynamic
+ object. In such a case, we don't actually need to build
+ a procedure linkage table, and we can just do a PCxx
+ reloc instead. */
+ BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
+ h->plt.offset = (bfd_vma) -1;
+ return true;
+ }
+
+ /* GC may have rendered this entry unused. */
+ if (h->plt.refcount <= 0)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ h->plt.offset = (bfd_vma) -1;
+ return true;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (!info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+ }
+
+ h->plt.offset = s->_raw_size;
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+
+ s = bfd_get_section_by_name (dynobj, ".got.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += 4;
+
+ /* We also need to make an entry in the .rela.plt section. */
+
+ s = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += sizeof (Elf32_External_Rela);
+
+ return true;
+ }
+
+ /* Reinitialize the plt offset now that it is not used as a reference
+ count any more. */
+ h->plt.offset = (bfd_vma) -1;
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ BFD_ASSERT (s != NULL);
+
+ /* We must generate a R_68K_COPY reloc to tell the dynamic linker to
+ copy the initial value out of the dynamic object and into the
+ runtime process image. We need to remember the offset into the
+ .rela.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ asection *srel;
+
+ srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf32_External_Rela);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 3)
+ power_of_two = 3;
+
+ /* Apply the required alignment. */
+ s->_raw_size = BFD_ALIGN (s->_raw_size,
+ (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ {
+ if (!bfd_set_section_alignment (dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf_m68k_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean plt;
+ boolean relocs;
+ boolean reltext;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (!info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+ else
+ {
+ /* We may have created entries in the .rela.got section.
+ However, if we are not creating the dynamic sections, we will
+ not actually use these entries. Reset the size of .rela.got,
+ which will cause it to get stripped from the output file
+ below. */
+ s = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (s != NULL)
+ s->_raw_size = 0;
+ }
+
+ /* If this is a -Bsymbolic shared link, then we need to discard all PC
+ relative relocs against symbols defined in a regular object. We
+ allocated space for them in the check_relocs routine, but we will not
+ fill them in in the relocate_section routine. */
+ if (info->shared && info->symbolic)
+ elf_m68k_link_hash_traverse (elf_m68k_hash_table (info),
+ elf_m68k_discard_copies,
+ (PTR) NULL);
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ plt = false;
+ relocs = false;
+ reltext = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ strip = false;
+
+ if (strcmp (name, ".plt") == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
+ strip = true;
+ }
+ else
+ {
+ /* Remember whether there is a PLT. */
+ plt = true;
+ }
+ }
+ else if (strncmp (name, ".rela", 5) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is mostly to handle .rela.bss and
+ .rela.plt. We must create both sections in
+ create_dynamic_sections, because they must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ strip = true;
+ }
+ else
+ {
+ asection *target;
+
+ /* Remember whether there are any reloc sections other
+ than .rela.plt. */
+ if (strcmp (name, ".rela.plt") != 0)
+ {
+ const char *outname;
+
+ relocs = true;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL
+ entry. .rela.plt is actually associated with
+ .got.plt, which is never readonly. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 5);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ reltext = true;
+ }
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strncmp (name, ".got", 4) != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ _bfd_strip_section_from_output (s);
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf_m68k_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (!info->shared)
+ {
+ if (!bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (plt)
+ {
+ if (!bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
+ || !bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || !bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
+ || !bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (!bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
+ || !bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
+ || !bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
+ sizeof (Elf32_External_Rela)))
+ return false;
+ }
+
+ if (reltext)
+ {
+ if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ /* If we are generating a shared library, we generate a section
+ symbol for each output section for which we might need to copy
+ relocs. These are local symbols, which means that they must come
+ first in the dynamic symbol table. That means we must increment
+ the dynamic symbol index of every other dynamic symbol. */
+ if (info->shared)
+ {
+ int c;
+
+ c = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) != 0
+ || (s->flags & SEC_ALLOC) == 0)
+ continue;
+
+ elf_section_data (s)->dynindx = c + 1;
+
+ /* These symbols will have no names, so we don't need to
+ fiddle with dynstr_index. */
+
+ ++c;
+ }
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_m68k_adjust_dynindx,
+ (PTR) &c);
+ elf_hash_table (info)->dynsymcount += c;
+ }
+
+ return true;
+}
+
+/* Increment the index of a dynamic symbol by a given amount. Called
+ via elf_link_hash_traverse. */
+
+static boolean
+elf_m68k_adjust_dynindx (h, cparg)
+ struct elf_link_hash_entry *h;
+ PTR cparg;
+{
+ int *cp = (int *) cparg;
+
+ if (h->dynindx != -1)
+ h->dynindx += *cp;
+ return true;
+}
+
+/* This function is called via elf_m68k_link_hash_traverse if we are
+ creating a shared object with -Bsymbolic. It discards the space
+ allocated to copy PC relative relocs against symbols which are defined
+ in regular objects. We allocated space for them in the check_relocs
+ routine, but we won't fill them in in the relocate_section routine. */
+
+/*ARGSUSED*/
+static boolean
+elf_m68k_discard_copies (h, ignore)
+ struct elf_m68k_link_hash_entry *h;
+ PTR ignore;
+{
+ struct elf_m68k_pcrel_relocs_copied *s;
+
+ /* We only discard relocs for symbols defined in a regular object. */
+ if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ return true;
+
+ for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
+ s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela);
+
+ return true;
+}
+
+/* Relocate an M68K ELF section. */
+
+static boolean
+elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ asection *sgot;
+ asection *splt;
+ asection *sreloc;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ sgot = NULL;
+ splt = NULL;
+ sreloc = NULL;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+ if (r_type < 0 || r_type >= (int) R_68K_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ howto = howto_table + r_type;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ if (((r_type == R_68K_PLT8
+ || r_type == R_68K_PLT16
+ || r_type == R_68K_PLT32
+ || r_type == R_68K_PLT8O
+ || r_type == R_68K_PLT16O
+ || r_type == R_68K_PLT32O)
+ && h->plt.offset != (bfd_vma) -1
+ && elf_hash_table (info)->dynamic_sections_created)
+ || ((r_type == R_68K_GOT8O
+ || r_type == R_68K_GOT16O
+ || r_type == R_68K_GOT32O
+ || ((r_type == R_68K_GOT8
+ || r_type == R_68K_GOT16
+ || r_type == R_68K_GOT32)
+ && strcmp (h->root.root.string,
+ "_GLOBAL_OFFSET_TABLE_") != 0))
+ && elf_hash_table (info)->dynamic_sections_created
+ && (! info->shared
+ || (! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ || (info->shared
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ && (input_section->flags & SEC_ALLOC) != 0
+ && (r_type == R_68K_8
+ || r_type == R_68K_16
+ || r_type == R_68K_32
+ || r_type == R_68K_PC8
+ || r_type == R_68K_PC16
+ || r_type == R_68K_PC32)))
+ {
+ /* In these cases, we don't need the relocation
+ value. We check specially because in some
+ obscure cases sec->output_section will be NULL. */
+ relocation = 0;
+ }
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else
+ {
+ if (!(info->callbacks->undefined_symbol
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ switch (r_type)
+ {
+ case R_68K_GOT8:
+ case R_68K_GOT16:
+ case R_68K_GOT32:
+ /* Relocation is to the address of the entry for this symbol
+ in the global offset table. */
+ if (h != NULL
+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* Fall through. */
+ case R_68K_GOT8O:
+ case R_68K_GOT16O:
+ case R_68K_GOT32O:
+ /* Relocation is the offset of the entry for this symbol in
+ the global offset table. */
+
+ {
+ bfd_vma off;
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (h != NULL)
+ {
+ off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ if (!elf_hash_table (info)->dynamic_sections_created
+ || (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally, or the symbol was forced to be local
+ because of a version file.. We must initialize
+ this entry in the global offset table. Since
+ the offset must always be a multiple of 4, we
+ use the least significant bit to record whether
+ we have initialized it already.
+
+ When doing a dynamic link, we create a .rela.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation,
+ sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+ }
+ else
+ {
+ BFD_ASSERT (local_got_offsets != NULL
+ && local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use
+ the least significant bit to record whether we have
+ already generated the necessary reloc. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation, sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
+ outrel.r_addend = relocation;
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+ (((Elf32_External_Rela *)
+ srelgot->contents)
+ + srelgot->reloc_count));
+ ++srelgot->reloc_count;
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+ }
+
+ relocation = sgot->output_offset + off;
+ if (r_type == R_68K_GOT8O
+ || r_type == R_68K_GOT16O
+ || r_type == R_68K_GOT32O)
+ {
+ /* This relocation does not use the addend. */
+ rel->r_addend = 0;
+ }
+ else
+ relocation += sgot->output_section->vma;
+ }
+ break;
+
+ case R_68K_PLT8:
+ case R_68K_PLT16:
+ case R_68K_PLT32:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+
+ /* Resolve a PLTxx reloc against a local symbol directly,
+ without using the procedure linkage table. */
+ if (h == NULL)
+ break;
+
+ if (h->plt.offset == (bfd_vma) -1
+ || !elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ break;
+ }
+
+ if (splt == NULL)
+ {
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL);
+ }
+
+ relocation = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+ break;
+
+ case R_68K_PLT8O:
+ case R_68K_PLT16O:
+ case R_68K_PLT32O:
+ /* Relocation is the offset of the entry for this symbol in
+ the procedure linkage table. */
+ BFD_ASSERT (h != NULL && h->plt.offset != (bfd_vma) -1);
+
+ if (splt == NULL)
+ {
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL);
+ }
+
+ relocation = h->plt.offset;
+
+ /* This relocation does not use the addend. */
+ rel->r_addend = 0;
+
+ break;
+
+ case R_68K_PC8:
+ case R_68K_PC16:
+ case R_68K_PC32:
+ if (h == NULL)
+ break;
+ /* Fall through. */
+ case R_68K_8:
+ case R_68K_16:
+ case R_68K_32:
+ if (info->shared
+ && (input_section->flags & SEC_ALLOC) != 0
+ && ((r_type != R_68K_PC8
+ && r_type != R_68K_PC16
+ && r_type != R_68K_PC32)
+ || (!info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip, relocate;
+
+ /* When generating a shared object, these relocations
+ are copied into the output file to be resolved at run
+ time. */
+
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd,
+ elf_elfheader (input_bfd)->e_shstrndx,
+ elf_section_data (input_section)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (input_bfd,
+ input_section),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ {
+ memset (&outrel, 0, sizeof outrel);
+ relocate = false;
+ }
+ /* h->dynindx may be -1 if the symbol was marked to
+ become local. */
+ else if (h != NULL
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ relocate = false;
+ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ else
+ {
+ if (r_type == R_68K_32)
+ {
+ relocate = true;
+ outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ else
+ {
+ long indx;
+
+ if (h == NULL)
+ sec = local_sections[r_symndx];
+ else
+ {
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || (h->root.type
+ == bfd_link_hash_defweak));
+ sec = h->root.u.def.section;
+ }
+ if (sec != NULL && bfd_is_abs_section (sec))
+ indx = 0;
+ else if (sec == NULL || sec->owner == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else
+ {
+ asection *osec;
+
+ osec = sec->output_section;
+ indx = elf_section_data (osec)->dynindx;
+ BFD_ASSERT (indx > 0);
+ }
+
+ relocate = false;
+ outrel.r_info = ELF32_R_INFO (indx, r_type);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ }
+
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+ (((Elf32_External_Rela *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ /* This reloc will be computed at runtime, so there's no
+ need to do anything now, except for R_68K_32
+ relocations that have been turned into
+ R_68K_RELATIVE. */
+ if (!relocate)
+ continue;
+ }
+
+ break;
+
+ case R_68K_GNU_VTINHERIT:
+ case R_68K_GNU_VTENTRY:
+ /* These are no-ops in the end. */
+ continue;
+
+ default:
+ break;
+ }
+
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (!(info->callbacks->reloc_overflow
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection *splt;
+ asection *sgot;
+ asection *srela;
+ bfd_vma plt_index;
+ bfd_vma got_offset;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+ srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
+
+ /* Get the index in the procedure linkage table which
+ corresponds to this symbol. This is the index of this symbol
+ in all the symbols for which we are making plt entries. The
+ first entry in the procedure linkage table is reserved. */
+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+
+ /* Get the offset into the .got table of the entry that
+ corresponds to this function. Each .got entry is 4 bytes.
+ The first three are reserved. */
+ got_offset = (plt_index + 3) * 4;
+
+ /* Fill in the entry in the procedure linkage table. */
+ memcpy (splt->contents + h->plt.offset, elf_m68k_plt_entry,
+ PLT_ENTRY_SIZE);
+ /* The offset is relative to the first extension word. */
+ bfd_put_32 (output_bfd,
+ (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset
+ - (splt->output_section->vma
+ + h->plt.offset + 2)),
+ splt->contents + h->plt.offset + 4);
+
+ bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
+ splt->contents + h->plt.offset + 10);
+ bfd_put_32 (output_bfd, - (h->plt.offset + 16),
+ splt->contents + h->plt.offset + 16);
+
+ /* Fill in the entry in the global offset table. */
+ bfd_put_32 (output_bfd,
+ (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset
+ + 8),
+ sgot->contents + got_offset);
+
+ /* Fill in the entry in the .rela.plt section. */
+ rela.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_JMP_SLOT);
+ rela.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) srela->contents
+ + plt_index));
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ the .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ asection *sgot;
+ asection *srela;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srela = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (sgot != NULL && srela != NULL);
+
+ rela.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + (h->got.offset &~ 1));
+
+ /* If this is a -Bsymbolic link, and the symbol is defined
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
+ if (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ {
+ rela.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
+ rela.r_addend = bfd_get_signed_32 (output_bfd,
+ (sgot->contents
+ + (h->got.offset & ~1)));
+ }
+ else
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) 0,
+ sgot->contents + (h->got.offset & ~1));
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_GLOB_DAT);
+ rela.r_addend = 0;
+ }
+
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) srela->contents
+ + srela->reloc_count));
+ ++srela->reloc_count;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ asection *s;
+ Elf_Internal_Rela rela;
+
+ /* This symbol needs a copy reloc. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak));
+
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rela.bss");
+ BFD_ASSERT (s != NULL);
+
+ rela.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_COPY);
+ rela.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) s->contents
+ + s->reloc_count));
+ ++s->reloc_count;
+ }
+
+ /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf_m68k_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *sgot;
+ asection *sdyn;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+ BFD_ASSERT (sgot != NULL);
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ asection *s;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ break;
+
+ case DT_PLTGOT:
+ name = ".got";
+ goto get_vma;
+ case DT_JMPREL:
+ name = ".rela.plt";
+ get_vma:
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_PLTRELSZ:
+ s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ BFD_ASSERT (s != NULL);
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_RELASZ:
+ /* The procedure linkage table relocs (DT_JMPREL) should
+ not be included in the overall relocs (DT_RELA).
+ Therefore, we override the DT_RELASZ entry here to
+ make it not include the JMPREL relocs. Since the
+ linker script arranges for .rela.plt to follow all
+ other relocation sections, we don't have to worry
+ about changing the DT_RELA entry. */
+ s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ if (s != NULL)
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val -= s->_cooked_size;
+ else
+ dyn.d_un.d_val -= s->_raw_size;
+ }
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+ }
+ }
+
+ /* Fill in the first entry in the procedure linkage table. */
+ if (splt->_raw_size > 0)
+ {
+ memcpy (splt->contents, elf_m68k_plt0_entry, PLT_ENTRY_SIZE);
+ bfd_put_32 (output_bfd,
+ (sgot->output_section->vma
+ + sgot->output_offset + 4
+ - (splt->output_section->vma + 2)),
+ splt->contents + 4);
+ bfd_put_32 (output_bfd,
+ (sgot->output_section->vma
+ + sgot->output_offset + 8
+ - (splt->output_section->vma + 10)),
+ splt->contents + 12);
+ }
+
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize
+ = PLT_ENTRY_SIZE;
+ }
+
+ /* Fill in the first three entries in the global offset table. */
+ if (sgot->_raw_size > 0)
+ {
+ if (sdyn == NULL)
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
+ else
+ bfd_put_32 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ sgot->contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
+ }
+
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+
+ if (info->shared)
+ {
+ asection *sdynsym;
+ asection *s;
+ Elf_Internal_Sym sym;
+ int c;
+
+ /* Set up the section symbols for the output sections. */
+
+ sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (sdynsym != NULL);
+
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_other = 0;
+
+ c = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ int indx;
+
+ if (elf_section_data (s)->dynindx == 0)
+ continue;
+
+ sym.st_value = s->vma;
+
+ indx = elf_section_data (s)->this_idx;
+ BFD_ASSERT (indx > 0);
+ sym.st_shndx = indx;
+
+ bfd_elf32_swap_symbol_out (output_bfd, &sym,
+ (PTR) (((Elf32_External_Sym *)
+ sdynsym->contents)
+ + elf_section_data (s)->dynindx));
+
+ ++c;
+ }
+
+ /* Set the sh_info field of the output .dynsym section to the
+ index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info = c + 1;
+ }
+
+ return true;
+}
+
+#define TARGET_BIG_SYM bfd_elf32_m68k_vec
+#define TARGET_BIG_NAME "elf32-m68k"
+#define ELF_MACHINE_CODE EM_68K
+#define ELF_MAXPAGESIZE 0x2000
+#define elf_backend_create_dynamic_sections \
+ _bfd_elf_create_dynamic_sections
+#define bfd_elf32_bfd_link_hash_table_create \
+ elf_m68k_link_hash_table_create
+#define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link
+
+#define elf_backend_check_relocs elf_m68k_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+ elf_m68k_adjust_dynamic_symbol
+#define elf_backend_size_dynamic_sections \
+ elf_m68k_size_dynamic_sections
+#define elf_backend_relocate_section elf_m68k_relocate_section
+#define elf_backend_finish_dynamic_symbol \
+ elf_m68k_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ elf_m68k_finish_dynamic_sections
+#define elf_backend_gc_mark_hook elf_m68k_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf_m68k_gc_sweep_hook
+#define elf_backend_can_gc_sections 1
+#define elf_backend_want_got_plt 1
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_plt_sym 0
+#define elf_backend_got_header_size 12
+#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-m88k.c b/bfd/elf32-m88k.c
new file mode 100644
index 00000000000..f3c535e0776
--- /dev/null
+++ b/bfd/elf32-m88k.c
@@ -0,0 +1,35 @@
+/* Motorola 88k-specific support for 32-bit ELF
+ Copyright 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* This does not include any relocations, but should be good enough
+ for GDB. */
+
+#define TARGET_BIG_SYM bfd_elf32_m88k_vec
+#define TARGET_BIG_NAME "elf32-m88k"
+#define ELF_ARCH bfd_arch_m88k
+#define ELF_MACHINE_CODE EM_88K
+#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+#define elf_info_to_howto _bfd_elf_no_info_to_howto
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c
new file mode 100644
index 00000000000..ef3a39f1957
--- /dev/null
+++ b/bfd/elf32-mcore.c
@@ -0,0 +1,747 @@
+/* Motorolla MCore specific support for 32-bit ELF
+ Copyright 1994, 1995, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file is based on a preliminary RCE ELF ABI. The
+ information may not match the final RCE ELF ABI. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/mcore.h"
+#include <assert.h>
+
+#define USE_RELA /* Only USE_REL is actually significant, but this is
+ here are a reminder... */
+
+static void mcore_elf_howto_init
+ PARAMS ((void));
+static reloc_howto_type * mcore_elf_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void mcore_elf_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static boolean mcore_elf_set_private_flags
+ PARAMS ((bfd *, flagword));
+static boolean mcore_elf_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean mcore_elf_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static bfd_reloc_status_type mcore_elf_unsupported_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean mcore_elf_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+
+static reloc_howto_type * mcore_elf_howto_table [(int) R_MCORE_max];
+
+static reloc_howto_type mcore_elf_howto_raw[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_MCORE_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 1, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mcore_elf_unsupported_reloc, /* special_function */
+ "R_MCORE_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A standard 32 bit relocation. */
+ HOWTO (R_MCORE_ADDR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "ADDR32", /* name *//* For compatability with coff/pe port. */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions.
+ Should not appear in object files. */
+ HOWTO (R_MCORE_PCRELIMM8BY4, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mcore_elf_unsupported_reloc, /* special_function */
+ "R_MCORE_PCRELIMM8BY4",/* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* bsr/bt/bf/br instructions; 11 bits + 1 zero bit
+ Span 2k instructions == 4k bytes.
+ Only useful pieces at the relocated address are the opcode (5 bits) */
+ HOWTO (R_MCORE_PCRELIMM11BY2,/* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MCORE_PCRELIMM11BY2",/* name */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0x7ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */
+ HOWTO (R_MCORE_PCRELIMM4BY2, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 4, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mcore_elf_unsupported_reloc,/* special_function */
+ "R_MCORE_PCRELIMM4BY2",/* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 32-bit pc-relative. Eventually this will help support PIC code. */
+ HOWTO (R_MCORE_PCREL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MCORE_PCREL32", /* name */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Like PCRELIMM11BY2, this relocation indicates that there is a
+ 'jsri' at the specified address. There is a separate relocation
+ entry for the literal pool entry that it references, but we
+ might be able to change the jsri to a bsr if the target turns out
+ to be close enough [even though we won't reclaim the literal pool
+ entry, we'll get some runtime efficiency back]. Note that this
+ is a relocation that we are allowed to safely ignore. */
+ HOWTO (R_MCORE_PCRELJSR_IMM11BY2,/* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MCORE_PCRELJSR_IMM11BY2", /* name */
+ false, /* partial_inplace */
+ 0x0, /* src_mask */
+ 0x7ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_MCORE_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_MCORE_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_MCORE_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_MCORE_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+};
+
+#ifndef NUM_ELEM
+#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
+#endif
+
+/* Initialize the mcore_elf_howto_table, so that linear accesses can be done. */
+static void
+mcore_elf_howto_init ()
+{
+ unsigned int i;
+
+ for (i = NUM_ELEM (mcore_elf_howto_raw); i--;)
+ {
+ unsigned int type;
+
+ type = mcore_elf_howto_raw[i].type;
+
+ BFD_ASSERT (type < NUM_ELEM (mcore_elf_howto_table));
+
+ mcore_elf_howto_table [type] = & mcore_elf_howto_raw [i];
+ }
+}
+
+
+static reloc_howto_type *
+mcore_elf_reloc_type_lookup (abfd, code)
+ bfd * abfd;
+ bfd_reloc_code_real_type code;
+{
+ enum elf_mcore_reloc_type mcore_reloc = R_MCORE_NONE;
+
+ switch (code)
+ {
+ case BFD_RELOC_NONE: mcore_reloc = R_MCORE_NONE; break;
+ case BFD_RELOC_32: mcore_reloc = R_MCORE_ADDR32; break;
+ case BFD_RELOC_MCORE_PCREL_IMM8BY4: mcore_reloc = R_MCORE_PCRELIMM8BY4; break;
+ case BFD_RELOC_MCORE_PCREL_IMM11BY2: mcore_reloc = R_MCORE_PCRELIMM11BY2; break;
+ case BFD_RELOC_MCORE_PCREL_IMM4BY2: mcore_reloc = R_MCORE_PCRELIMM4BY2; break;
+ case BFD_RELOC_32_PCREL: mcore_reloc = R_MCORE_PCREL32; break;
+ case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2: mcore_reloc = R_MCORE_PCRELJSR_IMM11BY2; break;
+ case BFD_RELOC_VTABLE_INHERIT: mcore_reloc = R_MCORE_GNU_VTINHERIT; break;
+ case BFD_RELOC_VTABLE_ENTRY: mcore_reloc = R_MCORE_GNU_VTENTRY; break;
+ default:
+ return (reloc_howto_type *)NULL;
+ }
+
+ if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */
+ mcore_elf_howto_init ();
+
+ return mcore_elf_howto_table [(int) mcore_reloc];
+};
+
+/* Set the howto pointer for a RCE ELF reloc. */
+static void
+mcore_elf_info_to_howto (abfd, cache_ptr, dst)
+ bfd * abfd;
+ arelent * cache_ptr;
+ Elf32_Internal_Rela * dst;
+{
+ if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */
+ mcore_elf_howto_init ();
+
+ BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_MCORE_max);
+
+ cache_ptr->howto = mcore_elf_howto_table [ELF32_R_TYPE (dst->r_info)];
+}
+
+/* Function to set whether a module needs the -mrelocatable bit set. */
+static boolean
+mcore_elf_set_private_flags (abfd, flags)
+ bfd * abfd;
+ flagword flags;
+{
+ BFD_ASSERT (! elf_flags_init (abfd)
+ || elf_elfheader (abfd)->e_flags == flags);
+
+ elf_elfheader (abfd)->e_flags = flags;
+ elf_flags_init (abfd) = true;
+ return true;
+}
+
+/* Copy backend specific data from one object module to another. */
+static boolean
+mcore_elf_copy_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ BFD_ASSERT (! elf_flags_init (obfd)
+ || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
+
+ elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+ elf_flags_init (obfd) = true;
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+static boolean
+mcore_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ flagword old_flags;
+ flagword new_flags;
+ boolean error;
+
+ /* Check if we have the same endianess */
+ if ( ibfd->xvec->byteorder != obfd->xvec->byteorder
+ && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
+ {
+ (*_bfd_error_handler)
+ (_("%s: compiled for a %s endian system and target is %s endian.\n"),
+ bfd_get_filename (ibfd),
+ bfd_big_endian (ibfd) ? "big" : "little",
+ bfd_big_endian (obfd) ? "big" : "little");
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ new_flags = elf_elfheader (ibfd)->e_flags;
+ old_flags = elf_elfheader (obfd)->e_flags;
+
+ if (! elf_flags_init (obfd)) /* First call, no flags set */
+ {
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = new_flags;
+ }
+ else if (new_flags == old_flags) /* Compatible flags are ok */
+ ;
+
+ return true;
+}
+
+
+/* Don't pretend we can deal with unsupported relocs. */
+
+/*ARGSUSED*/
+static bfd_reloc_status_type
+mcore_elf_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd * abfd;
+ arelent * reloc_entry;
+ asymbol * symbol;
+ PTR data;
+ asection * input_section;
+ bfd * output_bfd;
+ char ** error_message;
+{
+ BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
+
+ _bfd_error_handler (_("%s: Relocation %s (%d) is not currently supported.\n"),
+ bfd_get_filename (abfd),
+ reloc_entry->howto->name,
+ reloc_entry->howto->type);
+
+ return bfd_reloc_notsupported;
+}
+
+
+/* The RELOCATE_SECTION function is called by the ELF backend linker
+ to handle the relocations for a section.
+
+ The relocs are always passed as Rela structures; if the section
+ actually uses Rel structures, the r_addend field will always be
+ zero.
+
+ This function is responsible for adjust the section contents as
+ necessary, and (if using Rela relocs and generating a
+ relocateable output file) adjusting the reloc addend as
+ necessary.
+
+ This function does not have to worry about setting the reloc
+ address or the reloc symbol index.
+
+ LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+ LOCAL_SECTIONS is an array giving the section in the input file
+ corresponding to the st_shndx field of each local symbol.
+
+ The global hash table entry for the global symbols can be found
+ via elf_sym_hashes (input_bfd).
+
+ When generating relocateable output, this function must handle
+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
+ going to be the section symbol corresponding to the output
+ section, which means that the addend must be adjusted
+ accordingly. */
+
+static boolean
+mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+ bfd * input_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ Elf_Internal_Rela * relocs;
+ Elf_Internal_Sym * local_syms;
+ asection ** local_sections;
+{
+ Elf_Internal_Shdr * symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes = elf_sym_hashes (input_bfd);
+ Elf_Internal_Rela * rel = relocs;
+ Elf_Internal_Rela * relend = relocs + input_section->reloc_count;
+ boolean ret = true;
+ long insn;
+
+#ifdef DEBUG
+ fprintf (stderr,
+ "mcore_elf_relocate_section called for %s section %s, %ld relocations%s\n",
+ bfd_get_filename (input_bfd),
+ bfd_section_name(input_bfd, input_section),
+ (long) input_section->reloc_count,
+ (info->relocateable) ? " (relocatable)" : "");
+#endif
+
+ if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */
+ mcore_elf_howto_init ();
+
+ for (; rel < relend; rel++)
+ {
+ enum elf_mcore_reloc_type r_type = (enum elf_mcore_reloc_type) ELF32_R_TYPE (rel->r_info);
+ bfd_vma offset = rel->r_offset;
+ bfd_vma addend = rel->r_addend;
+ bfd_reloc_status_type r = bfd_reloc_other;
+ asection * sec = (asection *) 0;
+ reloc_howto_type * howto;
+ bfd_vma relocation;
+ Elf_Internal_Sym * sym = (Elf_Internal_Sym *) 0;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry * h = (struct elf_link_hash_entry *) 0;
+ unsigned short oldinst;
+
+ /* Unknown relocation handling */
+ if ((unsigned) r_type >= (unsigned) R_MCORE_max
+ || ! mcore_elf_howto_table [(int)r_type])
+ {
+ _bfd_error_handler (_("%s: Unknown relocation type %d\n"),
+ bfd_get_filename (input_bfd),
+ (int) r_type);
+
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+ }
+
+ howto = mcore_elf_howto_table [(int) r_type];
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+
+ if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ addend = rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
+ howto->name, (int) r_type, r_symndx, (long) offset, (long) addend);
+#endif
+ continue;
+ }
+
+ /* This is a final link. */
+
+ /* Complain about known relocation that are not yet supported */
+ if (howto->special_function == mcore_elf_unsupported_reloc)
+ {
+ _bfd_error_handler (_("%s: Relocation %s (%d) is not currently supported.\n"),
+ bfd_get_filename (input_bfd),
+ howto->name,
+ (int)r_type);
+
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+ }
+
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections [r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+ if ( h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+
+ ret = false;
+ continue;
+ }
+ }
+
+ switch (r_type)
+ {
+ default:
+ case R_MCORE_PCRELIMM8BY4:
+ case R_MCORE_PCRELIMM11BY2:
+ case R_MCORE_PCRELIMM4BY2:
+ break;
+
+ case R_MCORE_PCRELJSR_IMM11BY2:
+ oldinst = bfd_get_16 (input_bfd, contents + offset);
+#define MCORE_INST_BSR 0xF800
+ bfd_put_16 (input_bfd, MCORE_INST_BSR, contents + offset);
+ break;
+ }
+
+
+#ifdef DEBUG
+ fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
+ howto->name, r_type, r_symndx, (long) offset, (long) addend);
+#endif
+
+ r = _bfd_final_link_relocate
+ (howto, input_bfd, input_section, contents, offset, relocation, addend);
+
+ if (r != bfd_reloc_ok && r_type == R_MCORE_PCRELJSR_IMM11BY2)
+ {
+ /* Wasn't ok, back it out and give up. */
+ bfd_put_16 (input_bfd, oldinst, contents + offset);
+ r = bfd_reloc_ok;
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ ret = false;
+
+ switch (r)
+ {
+ default:
+ break;
+
+ case bfd_reloc_overflow:
+ {
+ const char * name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name);
+
+ if (name == NULL)
+ break;
+
+ if (* name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ (*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0, input_bfd, input_section,
+ offset);
+ }
+ break;
+ }
+ }
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "\n");
+#endif
+
+ return ret;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+mcore_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ Elf_Internal_Rela * rel;
+ struct elf_link_hash_entry * h;
+ Elf_Internal_Sym * sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_MCORE_GNU_VTINHERIT:
+ case R_MCORE_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+mcore_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ asection * sec;
+ const Elf_Internal_Rela * relocs;
+{
+ return true;
+}
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+mcore_elf_check_relocs (abfd, info, sec, relocs)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ asection * sec;
+ const Elf_Internal_Rela * relocs;
+{
+ Elf_Internal_Shdr * symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes;
+ struct elf_link_hash_entry ** sym_hashes_end;
+ const Elf_Internal_Rela * rel;
+ const Elf_Internal_Rela * rel_end;
+
+ if (info->relocateable)
+ return true;
+
+ symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry * h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_MCORE_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_MCORE_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+#define TARGET_BIG_SYM bfd_elf32_mcore_big_vec
+#define TARGET_BIG_NAME "elf32-mcore-big"
+#define TARGET_LITTLE_SYM bfd_elf32_mcore_little_vec
+#define TARGET_LITTLE_NAME "elf32-mcore-little"
+
+#define ELF_ARCH bfd_arch_mcore
+#define ELF_MACHINE_CODE EM_MCORE
+#define ELF_MAXPAGESIZE 0x1000 /* 4k, if we ever have 'em */
+#define elf_info_to_howto mcore_elf_info_to_howto
+#define elf_info_to_howto_rel NULL
+
+
+#define bfd_elf32_bfd_copy_private_bfd_data mcore_elf_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data mcore_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_set_private_flags mcore_elf_set_private_flags
+#define bfd_elf32_bfd_reloc_type_lookup mcore_elf_reloc_type_lookup
+#define elf_backend_relocate_section mcore_elf_relocate_section
+#define elf_backend_gc_mark_hook mcore_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook mcore_elf_gc_sweep_hook
+#define elf_backend_check_relocs mcore_elf_check_relocs
+
+#define elf_backend_can_gc_sections 1
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
new file mode 100644
index 00000000000..9f03262eb38
--- /dev/null
+++ b/bfd/elf32-mips.c
@@ -0,0 +1,7800 @@
+/* MIPS-specific support for 32-bit ELF
+ Copyright 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+
+ Most of the information added by Ian Lance Taylor, Cygnus Support,
+ <ian@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
+ different MIPS ELF from other targets. This matters when linking.
+ This file supports both, switching at runtime. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "genlink.h"
+#include "elf-bfd.h"
+#include "elf/mips.h"
+
+/* Get the ECOFF swapping routines. */
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/internal.h"
+#include "coff/ecoff.h"
+#include "coff/mips.h"
+#define ECOFF_32
+#include "ecoffswap.h"
+
+static bfd_reloc_status_type mips32_64bit_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void mips_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+static void bfd_mips_elf32_swap_gptab_in
+ PARAMS ((bfd *, const Elf32_External_gptab *, Elf32_gptab *));
+static void bfd_mips_elf32_swap_gptab_out
+ PARAMS ((bfd *, const Elf32_gptab *, Elf32_External_gptab *));
+static boolean mips_elf_sym_is_global PARAMS ((bfd *, asymbol *));
+static boolean mips_elf32_object_p PARAMS ((bfd *));
+static boolean mips_elf_create_procedure_table
+ PARAMS ((PTR, bfd *, struct bfd_link_info *, asection *,
+ struct ecoff_debug_info *));
+static int mips_elf_additional_program_headers PARAMS ((bfd *));
+static boolean mips_elf_modify_segment_map PARAMS ((bfd *));
+static INLINE int elf_mips_isa PARAMS ((flagword));
+static INLINE int elf_mips_mach PARAMS ((flagword));
+static INLINE char* elf_mips_abi_name PARAMS ((flagword));
+static boolean mips_elf32_section_from_shdr
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, char *));
+static boolean mips_elf32_section_processing
+ PARAMS ((bfd *, Elf32_Internal_Shdr *));
+static boolean mips_elf_is_local_label_name
+ PARAMS ((bfd *, const char *));
+static struct bfd_hash_entry *mips_elf_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *mips_elf_link_hash_table_create
+ PARAMS ((bfd *));
+static int gptab_compare PARAMS ((const void *, const void *));
+static boolean mips_elf_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+static void mips_elf_relocate_hi16
+ PARAMS ((bfd *, Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_byte *,
+ bfd_vma));
+static boolean mips_elf_relocate_got_local
+ PARAMS ((bfd *, bfd *, asection *, Elf_Internal_Rela *,
+ Elf_Internal_Rela *, bfd_byte *, bfd_vma));
+static void mips_elf_relocate_global_got
+ PARAMS ((bfd *, Elf_Internal_Rela *, bfd_byte *, bfd_vma));
+static bfd_reloc_status_type mips16_jump_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type mips16_gprel_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean mips_elf_adjust_dynindx
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean mips_elf_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean mips_elf_link_output_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
+ asection *));
+static boolean mips_elf_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_create_compact_rel_section
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_create_got_section
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static boolean mips_elf_adjust_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean mips_elf_always_size_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_finish_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static boolean mips_elf_finish_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_add_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+ const char **, flagword *, asection **, bfd_vma *));
+static bfd_reloc_status_type mips_elf_final_gp
+ PARAMS ((bfd *, asymbol *, boolean, char **, bfd_vma *));
+static bfd_byte *elf32_mips_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean, asymbol **));
+
+/* This is true for Irix 5 executables, false for normal MIPS ELF ABI
+ executables. FIXME: At the moment, we default to always generating
+ Irix 5 executables. */
+
+#define SGI_COMPAT(abfd) (1)
+
+/* This structure is used to hold .got information when linking. It
+ is stored in the tdata field of the bfd_elf_section_data structure. */
+
+struct mips_got_info
+{
+ /* The symbol index of the first global .got symbol. */
+ unsigned long global_gotsym;
+ /* The number of local .got entries. */
+ unsigned int local_gotno;
+ /* The number of local .got entries we have used. */
+ unsigned int assigned_gotno;
+};
+
+/* The number of local .got entries we reserve. */
+#define MIPS_RESERVED_GOTNO (2)
+
+/* Instructions which appear in a stub. For some reason the stub is
+ slightly different on an SGI system. */
+#define ELF_MIPS_GP_OFFSET(abfd) (SGI_COMPAT (abfd) ? 0x7ff0 : 0x8000)
+#define STUB_LW(abfd) \
+ (SGI_COMPAT (abfd) \
+ ? 0x8f998010 /* lw t9,0x8010(gp) */ \
+ : 0x8f998000) /* lw t9,0x8000(gp) */
+#define STUB_MOVE 0x03e07825 /* move t7,ra */
+#define STUB_JALR 0x0320f809 /* jal t9 */
+#define STUB_LI16 0x34180000 /* ori t8,zero,0 */
+#define MIPS_FUNCTION_STUB_SIZE (16)
+
+#if 0
+/* We no longer try to identify particular sections for the .dynsym
+ section. When we do, we wind up crashing if there are other random
+ sections with relocations. */
+
+/* Names of sections which appear in the .dynsym section in an Irix 5
+ executable. */
+
+static const char * const mips_elf_dynsym_sec_names[] =
+{
+ ".text",
+ ".init",
+ ".fini",
+ ".data",
+ ".rodata",
+ ".sdata",
+ ".sbss",
+ ".bss",
+ NULL
+};
+
+#define SIZEOF_MIPS_DYNSYM_SECNAMES \
+ (sizeof mips_elf_dynsym_sec_names / sizeof mips_elf_dynsym_sec_names[0])
+
+/* The number of entries in mips_elf_dynsym_sec_names which go in the
+ text segment. */
+
+#define MIPS_TEXT_DYNSYM_SECNO (3)
+
+#endif /* 0 */
+
+/* The names of the runtime procedure table symbols used on Irix 5. */
+
+static const char * const mips_elf_dynsym_rtproc_names[] =
+{
+ "_procedure_table",
+ "_procedure_string_table",
+ "_procedure_table_size",
+ NULL
+};
+
+/* These structures are used to generate the .compact_rel section on
+ Irix 5. */
+
+typedef struct
+{
+ unsigned long id1; /* Always one? */
+ unsigned long num; /* Number of compact relocation entries. */
+ unsigned long id2; /* Always two? */
+ unsigned long offset; /* The file offset of the first relocation. */
+ unsigned long reserved0; /* Zero? */
+ unsigned long reserved1; /* Zero? */
+} Elf32_compact_rel;
+
+typedef struct
+{
+ bfd_byte id1[4];
+ bfd_byte num[4];
+ bfd_byte id2[4];
+ bfd_byte offset[4];
+ bfd_byte reserved0[4];
+ bfd_byte reserved1[4];
+} Elf32_External_compact_rel;
+
+typedef struct
+{
+ unsigned int ctype : 1; /* 1: long 0: short format. See below. */
+ unsigned int rtype : 4; /* Relocation types. See below. */
+ unsigned int dist2to : 8;
+ unsigned int relvaddr : 19; /* (VADDR - vaddr of the previous entry)/ 4 */
+ unsigned long konst; /* KONST field. See below. */
+ unsigned long vaddr; /* VADDR to be relocated. */
+} Elf32_crinfo;
+
+typedef struct
+{
+ unsigned int ctype : 1; /* 1: long 0: short format. See below. */
+ unsigned int rtype : 4; /* Relocation types. See below. */
+ unsigned int dist2to : 8;
+ unsigned int relvaddr : 19; /* (VADDR - vaddr of the previous entry)/ 4 */
+ unsigned long konst; /* KONST field. See below. */
+} Elf32_crinfo2;
+
+typedef struct
+{
+ bfd_byte info[4];
+ bfd_byte konst[4];
+ bfd_byte vaddr[4];
+} Elf32_External_crinfo;
+
+typedef struct
+{
+ bfd_byte info[4];
+ bfd_byte konst[4];
+} Elf32_External_crinfo2;
+
+/* These are the constants used to swap the bitfields in a crinfo. */
+
+#define CRINFO_CTYPE (0x1)
+#define CRINFO_CTYPE_SH (31)
+#define CRINFO_RTYPE (0xf)
+#define CRINFO_RTYPE_SH (27)
+#define CRINFO_DIST2TO (0xff)
+#define CRINFO_DIST2TO_SH (19)
+#define CRINFO_RELVADDR (0x7ffff)
+#define CRINFO_RELVADDR_SH (0)
+
+/* A compact relocation info has long (3 words) or short (2 words)
+ formats. A short format doesn't have VADDR field and relvaddr
+ fields contains ((VADDR - vaddr of the previous entry) >> 2). */
+#define CRF_MIPS_LONG 1
+#define CRF_MIPS_SHORT 0
+
+/* There are 4 types of compact relocation at least. The value KONST
+ has different meaning for each type:
+
+ (type) (konst)
+ CT_MIPS_REL32 Address in data
+ CT_MIPS_WORD Address in word (XXX)
+ CT_MIPS_GPHI_LO GP - vaddr
+ CT_MIPS_JMPAD Address to jump
+ */
+
+#define CRT_MIPS_REL32 0xa
+#define CRT_MIPS_WORD 0xb
+#define CRT_MIPS_GPHI_LO 0xc
+#define CRT_MIPS_JMPAD 0xd
+
+#define mips_elf_set_cr_format(x,format) ((x).ctype = (format))
+#define mips_elf_set_cr_type(x,type) ((x).rtype = (type))
+#define mips_elf_set_cr_dist2to(x,v) ((x).dist2to = (v))
+#define mips_elf_set_cr_relvaddr(x,d) ((x).relvaddr = (d)<<2)
+
+static void bfd_elf32_swap_compact_rel_out
+ PARAMS ((bfd *, const Elf32_compact_rel *, Elf32_External_compact_rel *));
+static void bfd_elf32_swap_crinfo_out
+ PARAMS ((bfd *, const Elf32_crinfo *, Elf32_External_crinfo *));
+
+#define USE_REL 1 /* MIPS uses REL relocations instead of RELA */
+
+static reloc_howto_type elf_mips_howto_table[] =
+{
+ /* No relocation. */
+ HOWTO (R_MIPS_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit relocation. */
+ HOWTO (R_MIPS_16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit relocation. */
+ HOWTO (R_MIPS_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit symbol relative relocation. */
+ HOWTO (R_MIPS_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_REL32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 26 bit branch address. */
+ HOWTO (R_MIPS_26, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ /* This needs complex overflow
+ detection, because the upper four
+ bits must match the PC. */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_26", /* name */
+ true, /* partial_inplace */
+ 0x3ffffff, /* src_mask */
+ 0x3ffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of symbol value. */
+ HOWTO (R_MIPS_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_mips_elf_hi16_reloc, /* special_function */
+ "R_MIPS_HI16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of symbol value. */
+ HOWTO (R_MIPS_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_mips_elf_lo16_reloc, /* special_function */
+ "R_MIPS_LO16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GP relative reference. */
+ HOWTO (R_MIPS_GPREL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ _bfd_mips_elf_gprel16_reloc, /* special_function */
+ "R_MIPS_GPREL16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Reference to literal section. */
+ HOWTO (R_MIPS_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 */
+ _bfd_mips_elf_gprel16_reloc, /* special_function */
+ "R_MIPS_LITERAL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Reference to global offset table. */
+ HOWTO (R_MIPS_GOT16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ _bfd_mips_elf_got16_reloc, /* special_function */
+ "R_MIPS_GOT16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit PC relative reference. */
+ HOWTO (R_MIPS_PC16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_PC16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit call through global offset table. */
+ /* FIXME: This is not handled correctly. */
+ HOWTO (R_MIPS_CALL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit GP relative reference. */
+ HOWTO (R_MIPS_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 */
+ _bfd_mips_elf_gprel32_reloc, /* special_function */
+ "R_MIPS_GPREL32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The remaining relocs are defined on Irix 5, although they are
+ not defined by the ABI. */
+ { 13 },
+ { 14 },
+ { 15 },
+
+ /* A 5 bit shift field. */
+ HOWTO (R_MIPS_SHIFT5, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 5, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SHIFT5", /* name */
+ true, /* partial_inplace */
+ 0x000007c0, /* src_mask */
+ 0x000007c0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 6 bit shift field. */
+ /* FIXME: This is not handled correctly; a special function is
+ needed to put the most significant bit in the right place. */
+ HOWTO (R_MIPS_SHIFT6, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SHIFT6", /* name */
+ true, /* partial_inplace */
+ 0x000007c4, /* src_mask */
+ 0x000007c4, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 64 bit relocation. This is used in 32 bit ELF when addresses
+ are 64 bits long; the upper 32 bits are simply a sign extension.
+ The fields of the howto should be the same as for R_MIPS_32,
+ other than the type, name, and special_function. */
+ HOWTO (R_MIPS_64, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ mips32_64bit_reloc, /* special_function */
+ "R_MIPS_64", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Displacement in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_DISP, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_DISP", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Displacement to page pointer in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_PAGE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_PAGE", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Offset from page pointer in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_OFST, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_OFST", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_HI16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_LO16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 64 bit subtraction. Presumably not used in 32 bit ELF. */
+ { R_MIPS_SUB },
+
+ /* Used to cause the linker to insert and delete instructions? */
+ { R_MIPS_INSERT_A },
+ { R_MIPS_INSERT_B },
+ { R_MIPS_DELETE },
+
+ /* Get the higher values of a 64 bit addend. Presumably not used in
+ 32 bit ELF. */
+ { R_MIPS_HIGHER },
+ { R_MIPS_HIGHEST },
+
+ /* High 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_CALL_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL_HI16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_CALL_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL_LO16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ { R_MIPS_SCN_DISP },
+ { R_MIPS_REL16 },
+ { R_MIPS_ADD_IMMEDIATE },
+ { R_MIPS_PJUMP },
+ { R_MIPS_RELGOT }
+};
+
+/* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This
+ is a hack to make the linker think that we need 64 bit values. */
+static reloc_howto_type elf_mips_ctor64_howto =
+ HOWTO (R_MIPS_64, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ mips32_64bit_reloc, /* special_function */
+ "R_MIPS_64", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false); /* pcrel_offset */
+
+/* The reloc used for the mips16 jump instruction. */
+static reloc_howto_type elf_mips16_jump_howto =
+ HOWTO (R_MIPS16_26, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ /* This needs complex overflow
+ detection, because the upper four
+ bits must match the PC. */
+ mips16_jump_reloc, /* special_function */
+ "R_MIPS16_26", /* name */
+ true, /* partial_inplace */
+ 0x3ffffff, /* src_mask */
+ 0x3ffffff, /* dst_mask */
+ false); /* pcrel_offset */
+
+/* The reloc used for the mips16 gprel instruction. The src_mask and
+ dsk_mask for this howto do not reflect the actual instruction, in
+ which the value is not contiguous; the masks are for the
+ convenience of the relocate_section routine. */
+static reloc_howto_type elf_mips16_gprel_howto =
+ HOWTO (R_MIPS16_GPREL, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ mips16_gprel_reloc, /* special_function */
+ "R_MIPS16_GPREL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false); /* pcrel_offset */
+
+
+/* GNU extension to record C++ vtable hierarchy */
+static reloc_howto_type elf_mips_gnu_vtinherit_howto =
+ HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_MIPS_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false); /* pcrel_offset */
+
+/* GNU extension to record C++ vtable member usage */
+static reloc_howto_type elf_mips_gnu_vtentry_howto =
+ HOWTO (R_MIPS_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_MIPS_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false); /* pcrel_offset */
+
+/* Do a R_MIPS_HI16 relocation. This has to be done in combination
+ with a R_MIPS_LO16 reloc, because there is a carry from the LO16 to
+ the HI16. Here we just save the information we need; we do the
+ actual relocation when we see the LO16. MIPS ELF requires that the
+ LO16 immediately follow the HI16. As a GNU extension, we permit an
+ arbitrary number of HI16 relocs to be associated with a single LO16
+ reloc. This extension permits gcc to output the HI and LO relocs
+ itself. */
+
+struct mips_hi16
+{
+ struct mips_hi16 *next;
+ bfd_byte *addr;
+ bfd_vma addend;
+};
+
+/* FIXME: This should not be a static variable. */
+
+static struct mips_hi16 *mips_hi16_list;
+
+bfd_reloc_status_type
+_bfd_mips_elf_hi16_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_reloc_status_type ret;
+ bfd_vma relocation;
+ struct mips_hi16 *n;
+
+ /* If we're relocating, and this an external symbol, we don't want
+ to change anything. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ ret = bfd_reloc_ok;
+
+ if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
+ {
+ boolean relocateable;
+ bfd_vma gp;
+
+ if (ret == bfd_reloc_undefined)
+ abort ();
+
+ if (output_bfd != NULL)
+ relocateable = true;
+ else
+ {
+ relocateable = false;
+ output_bfd = symbol->section->output_section->owner;
+ }
+
+ ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
+ error_message, &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+
+ relocation = gp - reloc_entry->address;
+ }
+ else
+ {
+ if (bfd_is_und_section (symbol->section)
+ && output_bfd == (bfd *) NULL)
+ ret = bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+ }
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Save the information, and let LO16 do the actual relocation. */
+ n = (struct mips_hi16 *) bfd_malloc (sizeof *n);
+ if (n == NULL)
+ return bfd_reloc_outofrange;
+ n->addr = (bfd_byte *) data + reloc_entry->address;
+ n->addend = relocation;
+ n->next = mips_hi16_list;
+ mips_hi16_list = n;
+
+ if (output_bfd != (bfd *) NULL)
+ reloc_entry->address += input_section->output_offset;
+
+ return ret;
+}
+
+/* Do a R_MIPS_LO16 relocation. This is a straightforward 16 bit
+ inplace relocation; this function exists in order to do the
+ R_MIPS_HI16 relocation described above. */
+
+bfd_reloc_status_type
+_bfd_mips_elf_lo16_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ arelent gp_disp_relent;
+
+ if (mips_hi16_list != NULL)
+ {
+ struct mips_hi16 *l;
+
+ l = mips_hi16_list;
+ while (l != NULL)
+ {
+ unsigned long insn;
+ unsigned long val;
+ unsigned long vallo;
+ struct mips_hi16 *next;
+
+ /* Do the HI16 relocation. Note that we actually don't need
+ to know anything about the LO16 itself, except where to
+ find the low 16 bits of the addend needed by the LO16. */
+ insn = bfd_get_32 (abfd, l->addr);
+ vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
+ & 0xffff);
+ val = ((insn & 0xffff) << 16) + vallo;
+ val += l->addend;
+
+ /* The low order 16 bits are always treated as a signed
+ value. Therefore, a negative value in the low order bits
+ requires an adjustment in the high order bits. We need
+ to make this adjustment in two ways: once for the bits we
+ took from the data, and once for the bits we are putting
+ back in to the data. */
+ if ((vallo & 0x8000) != 0)
+ val -= 0x10000;
+ if ((val & 0x8000) != 0)
+ val += 0x10000;
+
+ insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, insn, l->addr);
+
+ if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
+ {
+ gp_disp_relent = *reloc_entry;
+ reloc_entry = &gp_disp_relent;
+ reloc_entry->addend = l->addend;
+ }
+
+ next = l->next;
+ free (l);
+ l = next;
+ }
+
+ mips_hi16_list = NULL;
+ }
+ else if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
+ {
+ bfd_reloc_status_type ret;
+ bfd_vma gp, relocation;
+
+ /* FIXME: Does this case ever occur? */
+
+ ret = mips_elf_final_gp (output_bfd, symbol, true, error_message, &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+
+ relocation = gp - reloc_entry->address;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ gp_disp_relent = *reloc_entry;
+ reloc_entry = &gp_disp_relent;
+ reloc_entry->addend = relocation - 4;
+ }
+
+ /* Now do the LO16 reloc in the usual way. */
+ return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+}
+
+/* Do a R_MIPS_GOT16 reloc. This is a reloc against the global offset
+ table used for PIC code. If the symbol is an external symbol, the
+ instruction is modified to contain the offset of the appropriate
+ entry in the global offset table. If the symbol is a section
+ symbol, the next reloc is a R_MIPS_LO16 reloc. The two 16 bit
+ addends are combined to form the real addend against the section
+ symbol; the GOT16 is modified to contain the offset of an entry in
+ the global offset table, and the LO16 is modified to offset it
+ appropriately. Thus an offset larger than 16 bits requires a
+ modified value in the global offset table.
+
+ This implementation suffices for the assembler, but the linker does
+ not yet know how to create global offset tables. */
+
+bfd_reloc_status_type
+_bfd_mips_elf_got16_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* If we're relocating, and this an external symbol, we don't want
+ to change anything. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* If we're relocating, and this is a local symbol, we can handle it
+ just like HI16. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) != 0)
+ return _bfd_mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+
+ abort ();
+}
+
+/* We have to figure out the gp value, so that we can adjust the
+ symbol value correctly. We look up the symbol _gp in the output
+ BFD. If we can't find it, we're stuck. We cache it in the ELF
+ target data. We don't need to adjust the symbol value for an
+ external symbol if we are producing relocateable output. */
+
+static bfd_reloc_status_type
+mips_elf_final_gp (output_bfd, symbol, relocateable, error_message, pgp)
+ bfd *output_bfd;
+ asymbol *symbol;
+ boolean relocateable;
+ char **error_message;
+ bfd_vma *pgp;
+{
+ if (bfd_is_und_section (symbol->section)
+ && ! relocateable)
+ {
+ *pgp = 0;
+ return bfd_reloc_undefined;
+ }
+
+ *pgp = _bfd_get_gp_value (output_bfd);
+ if (*pgp == 0
+ && (! relocateable
+ || (symbol->flags & BSF_SECTION_SYM) != 0))
+ {
+ if (relocateable)
+ {
+ /* Make up a value. */
+ *pgp = symbol->section->output_section->vma + 0x4000;
+ _bfd_set_gp_value (output_bfd, *pgp);
+ }
+ else
+ {
+ unsigned int count;
+ asymbol **sym;
+ unsigned int i;
+
+ count = bfd_get_symcount (output_bfd);
+ sym = bfd_get_outsymbols (output_bfd);
+
+ if (sym == (asymbol **) NULL)
+ i = count;
+ else
+ {
+ for (i = 0; i < count; i++, sym++)
+ {
+ register CONST char *name;
+
+ name = bfd_asymbol_name (*sym);
+ if (*name == '_' && strcmp (name, "_gp") == 0)
+ {
+ *pgp = bfd_asymbol_value (*sym);
+ _bfd_set_gp_value (output_bfd, *pgp);
+ break;
+ }
+ }
+ }
+
+ if (i >= count)
+ {
+ /* Only get the error once. */
+ *pgp = 4;
+ _bfd_set_gp_value (output_bfd, *pgp);
+ *error_message =
+ (char *) _("GP relative relocation when _gp not defined");
+ return bfd_reloc_dangerous;
+ }
+ }
+ }
+
+ return bfd_reloc_ok;
+}
+
+/* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
+ become the offset from the gp register. This function also handles
+ R_MIPS_LITERAL relocations, although those can be handled more
+ cleverly because the entries in the .lit8 and .lit4 sections can be
+ merged. */
+
+static bfd_reloc_status_type gprel16_with_gp PARAMS ((bfd *, asymbol *,
+ arelent *, asection *,
+ boolean, PTR, bfd_vma));
+
+bfd_reloc_status_type
+_bfd_mips_elf_gprel16_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ boolean relocateable;
+ bfd_reloc_status_type ret;
+ bfd_vma gp;
+
+ /* If we're relocating, and this is an external symbol with no
+ addend, we don't want to change anything. We will only have an
+ addend if this is a newly created reloc, not read from an ELF
+ file. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ relocateable = true;
+ else
+ {
+ relocateable = false;
+ output_bfd = symbol->section->output_section->owner;
+ }
+
+ ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
+ &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+
+ return gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
+ relocateable, data, gp);
+}
+
+static bfd_reloc_status_type
+gprel16_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
+ gp)
+ bfd *abfd;
+ asymbol *symbol;
+ arelent *reloc_entry;
+ asection *input_section;
+ boolean relocateable;
+ PTR data;
+ bfd_vma gp;
+{
+ bfd_vma relocation;
+ unsigned long insn;
+ unsigned long val;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+
+ /* Set val to the offset into the section or symbol. */
+ if (reloc_entry->howto->src_mask == 0)
+ {
+ /* This case occurs with the 64-bit MIPS ELF ABI. */
+ val = reloc_entry->addend;
+ }
+ else
+ {
+ val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
+ if (val & 0x8000)
+ val -= 0x10000;
+ }
+
+ /* Adjust val for the final section location and GP value. If we
+ are producing relocateable output, we don't want to do this for
+ an external symbol. */
+ if (! relocateable
+ || (symbol->flags & BSF_SECTION_SYM) != 0)
+ val += relocation - gp;
+
+ insn = (insn &~ 0xffff) | (val & 0xffff);
+ bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+ if (relocateable)
+ reloc_entry->address += input_section->output_offset;
+
+ /* Make sure it fit in 16 bits. */
+ if (val >= 0x8000 && val < 0xffff8000)
+ return bfd_reloc_overflow;
+
+ return bfd_reloc_ok;
+}
+
+/* Do a R_MIPS_GPREL32 relocation. Is this 32 bit value the offset
+ from the gp register? XXX */
+
+static bfd_reloc_status_type gprel32_with_gp PARAMS ((bfd *, asymbol *,
+ arelent *, asection *,
+ boolean, PTR, bfd_vma));
+
+bfd_reloc_status_type
+_bfd_mips_elf_gprel32_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ boolean relocateable;
+ bfd_reloc_status_type ret;
+ bfd_vma gp;
+
+ /* If we're relocating, and this is an external symbol with no
+ addend, we don't want to change anything. We will only have an
+ addend if this is a newly created reloc, not read from an ELF
+ file. */
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ *error_message = (char *)
+ _("32bits gp relative relocation occurs for an external symbol");
+ return bfd_reloc_outofrange;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ {
+ relocateable = true;
+ gp = _bfd_get_gp_value (output_bfd);
+ }
+ else
+ {
+ relocateable = false;
+ output_bfd = symbol->section->output_section->owner;
+
+ ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
+ error_message, &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+ }
+
+ return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
+ relocateable, data, gp);
+}
+
+static bfd_reloc_status_type
+gprel32_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
+ gp)
+ bfd *abfd;
+ asymbol *symbol;
+ arelent *reloc_entry;
+ asection *input_section;
+ boolean relocateable;
+ PTR data;
+ bfd_vma gp;
+{
+ bfd_vma relocation;
+ unsigned long val;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ if (reloc_entry->howto->src_mask == 0)
+ {
+ /* This case arises with the 64-bit MIPS ELF ABI. */
+ val = 0;
+ }
+ else
+ val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+
+ /* Set val to the offset into the section or symbol. */
+ val += reloc_entry->addend;
+
+ /* Adjust val for the final section location and GP value. If we
+ are producing relocateable output, we don't want to do this for
+ an external symbol. */
+ if (! relocateable
+ || (symbol->flags & BSF_SECTION_SYM) != 0)
+ val += relocation - gp;
+
+ bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
+
+ if (relocateable)
+ reloc_entry->address += input_section->output_offset;
+
+ return bfd_reloc_ok;
+}
+
+/* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
+ generated when addreses are 64 bits. The upper 32 bits are a simle
+ sign extension. */
+
+static bfd_reloc_status_type
+mips32_64bit_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_reloc_status_type r;
+ arelent reloc32;
+ unsigned long val;
+ bfd_size_type addr;
+
+ r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+ if (r != bfd_reloc_continue)
+ return r;
+
+ /* Do a normal 32 bit relocation on the lower 32 bits. */
+ reloc32 = *reloc_entry;
+ if (bfd_big_endian (abfd))
+ reloc32.address += 4;
+ reloc32.howto = &elf_mips_howto_table[R_MIPS_32];
+ r = bfd_perform_relocation (abfd, &reloc32, data, input_section,
+ output_bfd, error_message);
+
+ /* Sign extend into the upper 32 bits. */
+ val = bfd_get_32 (abfd, (bfd_byte *) data + reloc32.address);
+ if ((val & 0x80000000) != 0)
+ val = 0xffffffff;
+ else
+ val = 0;
+ addr = reloc_entry->address;
+ if (bfd_little_endian (abfd))
+ addr += 4;
+ bfd_put_32 (abfd, val, (bfd_byte *) data + addr);
+
+ return r;
+}
+
+/* Handle a mips16 jump. */
+
+static bfd_reloc_status_type
+mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* FIXME. */
+ {
+ static boolean warned;
+
+ if (! warned)
+ (*_bfd_error_handler)
+ (_("Linking mips16 objects into %s format is not supported"),
+ bfd_get_target (input_section->output_section->owner));
+ warned = true;
+ }
+
+ return bfd_reloc_undefined;
+}
+
+/* Handle a mips16 GP relative reloc. */
+
+static bfd_reloc_status_type
+mips16_gprel_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ boolean relocateable;
+ bfd_reloc_status_type ret;
+ bfd_vma gp;
+ unsigned short extend, insn;
+ unsigned long final;
+
+ /* If we're relocating, and this is an external symbol with no
+ addend, we don't want to change anything. We will only have an
+ addend if this is a newly created reloc, not read from an ELF
+ file. */
+ if (output_bfd != NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != NULL)
+ relocateable = true;
+ else
+ {
+ relocateable = false;
+ output_bfd = symbol->section->output_section->owner;
+ }
+
+ ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
+ &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Pick up the mips16 extend instruction and the real instruction. */
+ extend = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
+ insn = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address + 2);
+
+ /* Stuff the current addend back as a 32 bit value, do the usual
+ relocation, and then clean up. */
+ bfd_put_32 (abfd,
+ (((extend & 0x1f) << 11)
+ | (extend & 0x7e0)
+ | (insn & 0x1f)),
+ (bfd_byte *) data + reloc_entry->address);
+
+ ret = gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
+ relocateable, data, gp);
+
+ final = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ bfd_put_16 (abfd,
+ ((extend & 0xf800)
+ | ((final >> 11) & 0x1f)
+ | (final & 0x7e0)),
+ (bfd_byte *) data + reloc_entry->address);
+ bfd_put_16 (abfd,
+ ((insn & 0xffe0)
+ | (final & 0x1f)),
+ (bfd_byte *) data + reloc_entry->address + 2);
+
+ return ret;
+}
+
+/* Return the ISA for a MIPS e_flags value. */
+
+static INLINE int
+elf_mips_isa (flags)
+ flagword flags;
+{
+ switch (flags & EF_MIPS_ARCH)
+ {
+ case E_MIPS_ARCH_1:
+ return 1;
+ case E_MIPS_ARCH_2:
+ return 2;
+ case E_MIPS_ARCH_3:
+ return 3;
+ case E_MIPS_ARCH_4:
+ return 4;
+ }
+ return 4;
+}
+
+/* Return the MACH for a MIPS e_flags value. */
+
+static INLINE int
+elf_mips_mach (flags)
+ flagword flags;
+{
+ switch (flags & EF_MIPS_MACH)
+ {
+ case E_MIPS_MACH_3900:
+ return bfd_mach_mips3900;
+
+ case E_MIPS_MACH_4010:
+ return bfd_mach_mips4010;
+
+ case E_MIPS_MACH_4100:
+ return bfd_mach_mips4100;
+
+ case E_MIPS_MACH_4111:
+ return bfd_mach_mips4111;
+
+ case E_MIPS_MACH_4650:
+ return bfd_mach_mips4650;
+
+ default:
+ switch (flags & EF_MIPS_ARCH)
+ {
+ default:
+ case E_MIPS_ARCH_1:
+ return bfd_mach_mips3000;
+ break;
+
+ case E_MIPS_ARCH_2:
+ return bfd_mach_mips6000;
+ break;
+
+ case E_MIPS_ARCH_3:
+ return bfd_mach_mips4000;
+ break;
+
+ case E_MIPS_ARCH_4:
+ return bfd_mach_mips8000;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/* Return printable name for ABI from flagword. */
+
+static INLINE char*
+elf_mips_abi_name (flags)
+ flagword flags;
+{
+ switch (flags & EF_MIPS_ABI)
+ {
+ case 0:
+ return "none";
+ case E_MIPS_ABI_O32:
+ return "O32";
+ case E_MIPS_ABI_O64:
+ return "O64";
+ case E_MIPS_ABI_EABI32:
+ return "EABI32";
+ case E_MIPS_ABI_EABI64:
+ return "EABI64";
+ default:
+ return "unknown abi";
+ }
+}
+
+/* A mapping from BFD reloc types to MIPS ELF reloc types. */
+
+struct elf_reloc_map {
+ bfd_reloc_code_real_type bfd_reloc_val;
+ enum elf_mips_reloc_type elf_reloc_val;
+};
+
+static CONST struct elf_reloc_map mips_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_MIPS_NONE, },
+ { BFD_RELOC_16, R_MIPS_16 },
+ { BFD_RELOC_32, R_MIPS_32 },
+ { BFD_RELOC_64, R_MIPS_64 },
+ { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
+ { BFD_RELOC_HI16_S, R_MIPS_HI16 },
+ { BFD_RELOC_LO16, R_MIPS_LO16 },
+ { BFD_RELOC_MIPS_GPREL, R_MIPS_GPREL16 },
+ { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
+ { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
+ { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
+ { BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 },
+ { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
+ { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
+ { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
+ { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 }
+};
+
+/* Given a BFD reloc type, return a howto structure. */
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map); i++)
+ {
+ if (mips_reloc_map[i].bfd_reloc_val == code)
+ return &elf_mips_howto_table[(int) mips_reloc_map[i].elf_reloc_val];
+ }
+
+ switch (code)
+ {
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+
+ case BFD_RELOC_CTOR:
+ /* We need to handle BFD_RELOC_CTOR specially.
+ Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
+ size of addresses on this architecture. */
+ if (bfd_arch_bits_per_address (abfd) == 32)
+ return &elf_mips_howto_table[(int) R_MIPS_32];
+ else
+ return &elf_mips_ctor64_howto;
+
+ case BFD_RELOC_MIPS16_JMP:
+ return &elf_mips16_jump_howto;
+ case BFD_RELOC_MIPS16_GPREL:
+ return &elf_mips16_gprel_howto;
+ case BFD_RELOC_VTABLE_INHERIT:
+ return &elf_mips_gnu_vtinherit_howto;
+ case BFD_RELOC_VTABLE_ENTRY:
+ return &elf_mips_gnu_vtentry_howto;
+ }
+}
+
+/* Given a MIPS reloc type, fill in an arelent structure. */
+
+static void
+mips_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rel *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ switch (r_type)
+ {
+ case R_MIPS16_26:
+ cache_ptr->howto = &elf_mips16_jump_howto;
+ break;
+ case R_MIPS16_GPREL:
+ cache_ptr->howto = &elf_mips16_gprel_howto;
+ break;
+ case R_MIPS_GNU_VTINHERIT:
+ cache_ptr->howto = &elf_mips_gnu_vtinherit_howto;
+ break;
+ case R_MIPS_GNU_VTENTRY:
+ cache_ptr->howto = &elf_mips_gnu_vtentry_howto;
+ break;
+
+ default:
+ BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
+ cache_ptr->howto = &elf_mips_howto_table[r_type];
+ break;
+ }
+
+ /* The addend for a GPREL16 or LITERAL relocation comes from the GP
+ value for the object file. We get the addend now, rather than
+ when we do the relocation, because the symbol manipulations done
+ by the linker may cause us to lose track of the input BFD. */
+ if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
+ && (r_type == (unsigned int) R_MIPS_GPREL16
+ || r_type == (unsigned int) R_MIPS_LITERAL))
+ cache_ptr->addend = elf_gp (abfd);
+}
+
+/* A .reginfo section holds a single Elf32_RegInfo structure. These
+ routines swap this structure in and out. They are used outside of
+ BFD, so they are globally visible. */
+
+void
+bfd_mips_elf32_swap_reginfo_in (abfd, ex, in)
+ bfd *abfd;
+ const Elf32_External_RegInfo *ex;
+ Elf32_RegInfo *in;
+{
+ in->ri_gprmask = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gprmask);
+ in->ri_cprmask[0] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[0]);
+ in->ri_cprmask[1] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[1]);
+ in->ri_cprmask[2] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[2]);
+ in->ri_cprmask[3] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[3]);
+ in->ri_gp_value = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gp_value);
+}
+
+void
+bfd_mips_elf32_swap_reginfo_out (abfd, in, ex)
+ bfd *abfd;
+ const Elf32_RegInfo *in;
+ Elf32_External_RegInfo *ex;
+{
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_gprmask,
+ (bfd_byte *) ex->ri_gprmask);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[0],
+ (bfd_byte *) ex->ri_cprmask[0]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[1],
+ (bfd_byte *) ex->ri_cprmask[1]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[2],
+ (bfd_byte *) ex->ri_cprmask[2]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[3],
+ (bfd_byte *) ex->ri_cprmask[3]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_gp_value,
+ (bfd_byte *) ex->ri_gp_value);
+}
+
+/* In the 64 bit ABI, the .MIPS.options section holds register
+ information in an Elf64_Reginfo structure. These routines swap
+ them in and out. They are globally visible because they are used
+ outside of BFD. These routines are here so that gas can call them
+ without worrying about whether the 64 bit ABI has been included. */
+
+void
+bfd_mips_elf64_swap_reginfo_in (abfd, ex, in)
+ bfd *abfd;
+ const Elf64_External_RegInfo *ex;
+ Elf64_Internal_RegInfo *in;
+{
+ in->ri_gprmask = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gprmask);
+ in->ri_pad = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_pad);
+ in->ri_cprmask[0] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[0]);
+ in->ri_cprmask[1] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[1]);
+ in->ri_cprmask[2] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[2]);
+ in->ri_cprmask[3] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[3]);
+ in->ri_gp_value = bfd_h_get_64 (abfd, (bfd_byte *) ex->ri_gp_value);
+}
+
+void
+bfd_mips_elf64_swap_reginfo_out (abfd, in, ex)
+ bfd *abfd;
+ const Elf64_Internal_RegInfo *in;
+ Elf64_External_RegInfo *ex;
+{
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_gprmask,
+ (bfd_byte *) ex->ri_gprmask);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_pad,
+ (bfd_byte *) ex->ri_pad);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[0],
+ (bfd_byte *) ex->ri_cprmask[0]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[1],
+ (bfd_byte *) ex->ri_cprmask[1]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[2],
+ (bfd_byte *) ex->ri_cprmask[2]);
+ bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[3],
+ (bfd_byte *) ex->ri_cprmask[3]);
+ bfd_h_put_64 (abfd, (bfd_vma) in->ri_gp_value,
+ (bfd_byte *) ex->ri_gp_value);
+}
+
+/* Swap an entry in a .gptab section. Note that these routines rely
+ on the equivalence of the two elements of the union. */
+
+static void
+bfd_mips_elf32_swap_gptab_in (abfd, ex, in)
+ bfd *abfd;
+ const Elf32_External_gptab *ex;
+ Elf32_gptab *in;
+{
+ in->gt_entry.gt_g_value = bfd_h_get_32 (abfd, ex->gt_entry.gt_g_value);
+ in->gt_entry.gt_bytes = bfd_h_get_32 (abfd, ex->gt_entry.gt_bytes);
+}
+
+static void
+bfd_mips_elf32_swap_gptab_out (abfd, in, ex)
+ bfd *abfd;
+ const Elf32_gptab *in;
+ Elf32_External_gptab *ex;
+{
+ bfd_h_put_32 (abfd, (bfd_vma) in->gt_entry.gt_g_value,
+ ex->gt_entry.gt_g_value);
+ bfd_h_put_32 (abfd, (bfd_vma) in->gt_entry.gt_bytes,
+ ex->gt_entry.gt_bytes);
+}
+
+static void
+bfd_elf32_swap_compact_rel_out (abfd, in, ex)
+ bfd *abfd;
+ const Elf32_compact_rel *in;
+ Elf32_External_compact_rel *ex;
+{
+ bfd_h_put_32 (abfd, (bfd_vma) in->id1, ex->id1);
+ bfd_h_put_32 (abfd, (bfd_vma) in->num, ex->num);
+ bfd_h_put_32 (abfd, (bfd_vma) in->id2, ex->id2);
+ bfd_h_put_32 (abfd, (bfd_vma) in->offset, ex->offset);
+ bfd_h_put_32 (abfd, (bfd_vma) in->reserved0, ex->reserved0);
+ bfd_h_put_32 (abfd, (bfd_vma) in->reserved1, ex->reserved1);
+}
+
+static void
+bfd_elf32_swap_crinfo_out (abfd, in, ex)
+ bfd *abfd;
+ const Elf32_crinfo *in;
+ Elf32_External_crinfo *ex;
+{
+ unsigned long l;
+
+ l = (((in->ctype & CRINFO_CTYPE) << CRINFO_CTYPE_SH)
+ | ((in->rtype & CRINFO_RTYPE) << CRINFO_RTYPE_SH)
+ | ((in->dist2to & CRINFO_DIST2TO) << CRINFO_DIST2TO_SH)
+ | ((in->relvaddr & CRINFO_RELVADDR) << CRINFO_RELVADDR_SH));
+ bfd_h_put_32 (abfd, (bfd_vma) l, ex->info);
+ bfd_h_put_32 (abfd, (bfd_vma) in->konst, ex->konst);
+ bfd_h_put_32 (abfd, (bfd_vma) in->vaddr, ex->vaddr);
+}
+
+/* Swap in an options header. */
+
+void
+bfd_mips_elf_swap_options_in (abfd, ex, in)
+ bfd *abfd;
+ const Elf_External_Options *ex;
+ Elf_Internal_Options *in;
+{
+ in->kind = bfd_h_get_8 (abfd, ex->kind);
+ in->size = bfd_h_get_8 (abfd, ex->size);
+ in->section = bfd_h_get_16 (abfd, ex->section);
+ in->info = bfd_h_get_32 (abfd, ex->info);
+}
+
+/* Swap out an options header. */
+
+void
+bfd_mips_elf_swap_options_out (abfd, in, ex)
+ bfd *abfd;
+ const Elf_Internal_Options *in;
+ Elf_External_Options *ex;
+{
+ bfd_h_put_8 (abfd, in->kind, ex->kind);
+ bfd_h_put_8 (abfd, in->size, ex->size);
+ bfd_h_put_16 (abfd, in->section, ex->section);
+ bfd_h_put_32 (abfd, in->info, ex->info);
+}
+
+/* Determine whether a symbol is global for the purposes of splitting
+ the symbol table into global symbols and local symbols. At least
+ on Irix 5, this split must be between section symbols and all other
+ symbols. On most ELF targets the split is between static symbols
+ and externally visible symbols. */
+
+/*ARGSUSED*/
+static boolean
+mips_elf_sym_is_global (abfd, sym)
+ bfd *abfd;
+ asymbol *sym;
+{
+ return (sym->flags & BSF_SECTION_SYM) == 0 ? true : false;
+}
+
+/* Set the right machine number for a MIPS ELF file. This is used for
+ both the 32-bit and the 64-bit ABI. */
+
+boolean
+_bfd_mips_elf_object_p (abfd)
+ bfd *abfd;
+{
+ bfd_default_set_arch_mach (abfd, bfd_arch_mips,
+ elf_mips_mach (elf_elfheader (abfd)->e_flags));
+ return true;
+}
+
+/* Set the right machine number for a 32-bit MIPS ELF file. */
+
+static boolean
+mips_elf32_object_p (abfd)
+ bfd *abfd;
+{
+ /* Irix 5 is broken. Object file symbol tables are not always
+ sorted correctly such that local symbols precede global symbols,
+ and the sh_info field in the symbol table is not always right. */
+ elf_bad_symtab (abfd) = true;
+
+ return _bfd_mips_elf_object_p (abfd);
+}
+
+/* The final processing done just before writing out a MIPS ELF object
+ file. This gets the MIPS architecture right based on the machine
+ number. This is used by both the 32-bit and the 64-bit ABI. */
+
+/*ARGSUSED*/
+void
+_bfd_mips_elf_final_write_processing (abfd, linker)
+ bfd *abfd;
+ boolean linker;
+{
+ unsigned long val;
+ unsigned int i;
+ Elf_Internal_Shdr **hdrpp;
+ const char *name;
+ asection *sec;
+
+ switch (bfd_get_mach (abfd))
+ {
+ default:
+ case bfd_mach_mips3000:
+ val = E_MIPS_ARCH_1;
+ break;
+
+ case bfd_mach_mips3900:
+ val = E_MIPS_ARCH_1 | E_MIPS_MACH_3900;
+ break;
+
+ case bfd_mach_mips6000:
+ val = E_MIPS_ARCH_2;
+ break;
+
+ case bfd_mach_mips4000:
+ case bfd_mach_mips4300:
+ val = E_MIPS_ARCH_3;
+ break;
+
+ case bfd_mach_mips4010:
+ val = E_MIPS_ARCH_3 | E_MIPS_MACH_4010;
+ break;
+
+ case bfd_mach_mips4100:
+ val = E_MIPS_ARCH_3 | E_MIPS_MACH_4100;
+ break;
+
+ case bfd_mach_mips4111:
+ val = E_MIPS_ARCH_3 | E_MIPS_MACH_4111;
+ break;
+
+ case bfd_mach_mips4650:
+ val = E_MIPS_ARCH_3 | E_MIPS_MACH_4650;
+ break;
+
+ case bfd_mach_mips8000:
+ val = E_MIPS_ARCH_4;
+ break;
+ }
+
+ elf_elfheader (abfd)->e_flags &= ~ (EF_MIPS_ARCH | EF_MIPS_MACH);
+ elf_elfheader (abfd)->e_flags |= val;
+
+ /* Set the sh_info field for .gptab sections and other appropriate
+ info for each special section. */
+ for (i = 1, hdrpp = elf_elfsections (abfd) + 1;
+ i < elf_elfheader (abfd)->e_shnum;
+ i++, hdrpp++)
+ {
+ switch ((*hdrpp)->sh_type)
+ {
+ case SHT_MIPS_LIBLIST:
+ sec = bfd_get_section_by_name (abfd, ".dynstr");
+ if (sec != NULL)
+ (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+ break;
+
+ case SHT_MIPS_GPTAB:
+ BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
+ name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
+ BFD_ASSERT (name != NULL
+ && strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0);
+ sec = bfd_get_section_by_name (abfd, name + sizeof ".gptab" - 1);
+ BFD_ASSERT (sec != NULL);
+ (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
+ break;
+
+ case SHT_MIPS_CONTENT:
+ BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
+ name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
+ BFD_ASSERT (name != NULL
+ && strncmp (name, ".MIPS.content",
+ sizeof ".MIPS.content" - 1) == 0);
+ sec = bfd_get_section_by_name (abfd,
+ name + sizeof ".MIPS.content" - 1);
+ BFD_ASSERT (sec != NULL);
+ (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
+ break;
+
+ case SHT_MIPS_SYMBOL_LIB:
+ sec = bfd_get_section_by_name (abfd, ".dynsym");
+ if (sec != NULL)
+ (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+ sec = bfd_get_section_by_name (abfd, ".liblist");
+ if (sec != NULL)
+ (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
+ break;
+
+ case SHT_MIPS_EVENTS:
+ BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
+ name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
+ BFD_ASSERT (name != NULL);
+ if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0)
+ sec = bfd_get_section_by_name (abfd,
+ name + sizeof ".MIPS.events" - 1);
+ else
+ {
+ BFD_ASSERT (strncmp (name, ".MIPS.post_rel",
+ sizeof ".MIPS.post_rel" - 1) == 0);
+ sec = bfd_get_section_by_name (abfd,
+ (name
+ + sizeof ".MIPS.post_rel" - 1));
+ }
+ BFD_ASSERT (sec != NULL);
+ (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+ break;
+
+ }
+ }
+}
+
+/* Function to keep MIPS specific file flags like as EF_MIPS_PIC. */
+
+boolean
+_bfd_mips_elf_set_private_flags (abfd, flags)
+ bfd *abfd;
+ flagword flags;
+{
+ BFD_ASSERT (!elf_flags_init (abfd)
+ || elf_elfheader (abfd)->e_flags == flags);
+
+ elf_elfheader (abfd)->e_flags = flags;
+ elf_flags_init (abfd) = true;
+ return true;
+}
+
+/* Copy backend specific data from one object module to another */
+
+boolean
+_bfd_mips_elf_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ BFD_ASSERT (!elf_flags_init (obfd)
+ || (elf_elfheader (obfd)->e_flags
+ == elf_elfheader (ibfd)->e_flags));
+
+ elf_gp (obfd) = elf_gp (ibfd);
+ elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+ elf_flags_init (obfd) = true;
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+
+boolean
+_bfd_mips_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ flagword old_flags;
+ flagword new_flags;
+ boolean ok;
+
+ /* Check if we have the same endianess */
+ if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+ && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
+ {
+ const char *msg;
+
+ if (bfd_big_endian (ibfd))
+ msg = _("%s: compiled for a big endian system and target is little endian");
+ else
+ msg = _("%s: compiled for a little endian system and target is big endian");
+
+ (*_bfd_error_handler) (msg, bfd_get_filename (ibfd));
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ new_flags = elf_elfheader (ibfd)->e_flags;
+ elf_elfheader (obfd)->e_flags |= new_flags & EF_MIPS_NOREORDER;
+ old_flags = elf_elfheader (obfd)->e_flags;
+
+ if (! elf_flags_init (obfd))
+ {
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = new_flags;
+
+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+ && bfd_get_arch_info (obfd)->the_default)
+ {
+ if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
+ bfd_get_mach (ibfd)))
+ return false;
+ }
+
+ return true;
+ }
+
+ /* Check flag compatibility. */
+
+ new_flags &= ~EF_MIPS_NOREORDER;
+ old_flags &= ~EF_MIPS_NOREORDER;
+
+ if (new_flags == old_flags)
+ return true;
+
+ ok = true;
+
+ if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC))
+ {
+ new_flags &= ~EF_MIPS_PIC;
+ old_flags &= ~EF_MIPS_PIC;
+ (*_bfd_error_handler)
+ (_("%s: linking PIC files with non-PIC files"),
+ bfd_get_filename (ibfd));
+ ok = false;
+ }
+
+ if ((new_flags & EF_MIPS_CPIC) != (old_flags & EF_MIPS_CPIC))
+ {
+ new_flags &= ~EF_MIPS_CPIC;
+ old_flags &= ~EF_MIPS_CPIC;
+ (*_bfd_error_handler)
+ (_("%s: linking abicalls files with non-abicalls files"),
+ bfd_get_filename (ibfd));
+ ok = false;
+ }
+
+ /* Compare the ISA's. */
+ if ((new_flags & (EF_MIPS_ARCH | EF_MIPS_MACH))
+ != (old_flags & (EF_MIPS_ARCH | EF_MIPS_MACH)))
+ {
+ int new_mach = new_flags & EF_MIPS_MACH;
+ int old_mach = old_flags & EF_MIPS_MACH;
+ int new_isa = elf_mips_isa (new_flags);
+ int old_isa = elf_mips_isa (old_flags);
+
+ /* If either has no machine specified, just compare the general isa's.
+ Some combinations of machines are ok, if the isa's match. */
+ if (! new_mach
+ || ! old_mach
+ || new_mach == old_mach
+ )
+ {
+ /* Don't warn about mixing -mips1 and -mips2 code, or mixing -mips3
+ and -mips4 code. They will normally use the same data sizes and
+ calling conventions. */
+
+ if ((new_isa == 1 || new_isa == 2)
+ ? (old_isa != 1 && old_isa != 2)
+ : (old_isa == 1 || old_isa == 2))
+ {
+ (*_bfd_error_handler)
+ (_("%s: ISA mismatch (-mips%d) with previous modules (-mips%d)"),
+ bfd_get_filename (ibfd), new_isa, old_isa);
+ ok = false;
+ }
+ }
+
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: ISA mismatch (%d) with previous modules (%d)"),
+ bfd_get_filename (ibfd),
+ elf_mips_mach (new_flags),
+ elf_mips_mach (old_flags));
+ ok = false;
+ }
+
+ new_flags &= ~ (EF_MIPS_ARCH | EF_MIPS_MACH);
+ old_flags &= ~ (EF_MIPS_ARCH | EF_MIPS_MACH);
+ }
+
+ /* Compare ABI's */
+ if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI))
+ {
+ /* Only error if both are set (to different values). */
+ if ((new_flags & EF_MIPS_ABI)
+ && (old_flags & EF_MIPS_ABI))
+ {
+ (*_bfd_error_handler)
+ (_("%s: ABI mismatch: linking %s module with previous %s modules"),
+ bfd_get_filename (ibfd),
+ elf_mips_abi_name (new_flags),
+ elf_mips_abi_name (old_flags));
+ ok = false;
+ }
+ new_flags &= ~EF_MIPS_ABI;
+ old_flags &= ~EF_MIPS_ABI;
+ }
+
+ /* Warn about any other mismatches */
+ if (new_flags != old_flags)
+ {
+ (*_bfd_error_handler)
+ (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
+ bfd_get_filename (ibfd), (unsigned long) new_flags,
+ (unsigned long) old_flags);
+ ok = false;
+ }
+
+ if (! ok)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ return true;
+}
+
+static boolean
+_bfd_mips_elf_print_private_bfd_data (abfd, ptr)
+ bfd *abfd;
+ PTR ptr;
+{
+ FILE *file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+ /* Print normal ELF private data. */
+ _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+ /* xgettext:c-format */
+ fprintf (file, _ ("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+
+ if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_O32)
+ fprintf (file, _ (" [abi=O32]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_O64)
+ fprintf (file, _ (" [abi=O64]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI32)
+ fprintf (file, _ (" [abi=EABI32]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI64)
+ fprintf (file, _ (" [abi=EABI64]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI))
+ fprintf (file, _ (" [abi unknown]"));
+ else
+ fprintf (file, _ (" [no abi set]"));
+
+ if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_1)
+ fprintf (file, _ (" [mips1]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_2)
+ fprintf (file, _ (" [mips2]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_3)
+ fprintf (file, _ (" [mips3]"));
+ else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_4)
+ fprintf (file, _ (" [mips4]"));
+ else
+ fprintf (file, _ (" [unknown ISA]"));
+
+ if (elf_elfheader (abfd)->e_flags & EF_MIPS_32BITMODE)
+ fprintf (file, _ (" [32bitmode]"));
+ else
+ fprintf (file, _ (" [not 32bitmode]"));
+
+ fputc ('\n', file);
+
+ return true;
+}
+
+/* Handle a MIPS specific section when reading an object file. This
+ is called when elfcode.h finds a section with an unknown type.
+ This routine supports both the 32-bit and 64-bit ELF ABI.
+
+ FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure
+ how to. */
+
+boolean
+_bfd_mips_elf_section_from_shdr (abfd, hdr, name)
+ bfd *abfd;
+ Elf_Internal_Shdr *hdr;
+ const char *name;
+{
+ flagword flags = 0;
+
+ /* There ought to be a place to keep ELF backend specific flags, but
+ at the moment there isn't one. We just keep track of the
+ sections by their name, instead. Fortunately, the ABI gives
+ suggested names for all the MIPS specific sections, so we will
+ probably get away with this. */
+ switch (hdr->sh_type)
+ {
+ case SHT_MIPS_LIBLIST:
+ if (strcmp (name, ".liblist") != 0)
+ return false;
+ break;
+ case SHT_MIPS_MSYM:
+ if (strcmp (name, ".msym") != 0)
+ return false;
+ break;
+ case SHT_MIPS_CONFLICT:
+ if (strcmp (name, ".conflict") != 0)
+ return false;
+ break;
+ case SHT_MIPS_GPTAB:
+ if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) != 0)
+ return false;
+ break;
+ case SHT_MIPS_UCODE:
+ if (strcmp (name, ".ucode") != 0)
+ return false;
+ break;
+ case SHT_MIPS_DEBUG:
+ if (strcmp (name, ".mdebug") != 0)
+ return false;
+ flags = SEC_DEBUGGING;
+ break;
+ case SHT_MIPS_REGINFO:
+ if (strcmp (name, ".reginfo") != 0
+ || hdr->sh_size != sizeof (Elf32_External_RegInfo))
+ return false;
+ flags = (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_SAME_SIZE);
+ break;
+ case SHT_MIPS_IFACE:
+ if (strcmp (name, ".MIPS.interfaces") != 0)
+ return false;
+ break;
+ case SHT_MIPS_CONTENT:
+ if (strncmp (name, ".MIPS.content", sizeof ".MIPS.content" - 1) != 0)
+ return false;
+ break;
+ case SHT_MIPS_OPTIONS:
+ if (strcmp (name, ".options") != 0
+ && strcmp (name, ".MIPS.options") != 0)
+ return false;
+ break;
+ case SHT_MIPS_DWARF:
+ if (strncmp (name, ".debug_", sizeof ".debug_" - 1) != 0)
+ return false;
+ break;
+ case SHT_MIPS_SYMBOL_LIB:
+ if (strcmp (name, ".MIPS.symlib") != 0)
+ return false;
+ break;
+ case SHT_MIPS_EVENTS:
+ if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) != 0
+ && strncmp (name, ".MIPS.post_rel",
+ sizeof ".MIPS.post_rel" - 1) != 0)
+ return false;
+ break;
+ default:
+ return false;
+ }
+
+ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+ return false;
+
+ if (flags)
+ {
+ if (! bfd_set_section_flags (abfd, hdr->bfd_section,
+ (bfd_get_section_flags (abfd,
+ hdr->bfd_section)
+ | flags)))
+ return false;
+ }
+
+ return true;
+}
+
+/* Handle a 32-bit MIPS ELF specific section. */
+
+static boolean
+mips_elf32_section_from_shdr (abfd, hdr, name)
+ bfd *abfd;
+ Elf_Internal_Shdr *hdr;
+ char *name;
+{
+ if (! _bfd_mips_elf_section_from_shdr (abfd, hdr, name))
+ return false;
+
+ /* FIXME: We should record sh_info for a .gptab section. */
+
+ /* For a .reginfo section, set the gp value in the tdata information
+ from the contents of this section. We need the gp value while
+ processing relocs, so we just get it now. The .reginfo section
+ is not used in the 64-bit MIPS ELF ABI. */
+ if (hdr->sh_type == SHT_MIPS_REGINFO)
+ {
+ Elf32_External_RegInfo ext;
+ Elf32_RegInfo s;
+
+ if (! bfd_get_section_contents (abfd, hdr->bfd_section, (PTR) &ext,
+ (file_ptr) 0, sizeof ext))
+ return false;
+ bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s);
+ elf_gp (abfd) = s.ri_gp_value;
+ }
+
+ /* For a SHT_MIPS_OPTIONS section, look for a ODK_REGINFO entry, and
+ set the gp value based on what we find. We may see both
+ SHT_MIPS_REGINFO and SHT_MIPS_OPTIONS/ODK_REGINFO; in that case,
+ they should agree. */
+ if (hdr->sh_type == SHT_MIPS_OPTIONS)
+ {
+ bfd_byte *contents, *l, *lend;
+
+ contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
+ if (contents == NULL)
+ return false;
+ if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents,
+ (file_ptr) 0, hdr->sh_size))
+ {
+ free (contents);
+ return false;
+ }
+ l = contents;
+ lend = contents + hdr->sh_size;
+ while (l + sizeof (Elf_External_Options) <= lend)
+ {
+ Elf_Internal_Options intopt;
+
+ bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
+ &intopt);
+ if (intopt.kind == ODK_REGINFO)
+ {
+ Elf32_RegInfo intreg;
+
+ bfd_mips_elf32_swap_reginfo_in
+ (abfd,
+ ((Elf32_External_RegInfo *)
+ (l + sizeof (Elf_External_Options))),
+ &intreg);
+ elf_gp (abfd) = intreg.ri_gp_value;
+ }
+ l += intopt.size;
+ }
+ free (contents);
+ }
+
+ return true;
+}
+
+/* Set the correct type for a MIPS ELF section. We do this by the
+ section name, which is a hack, but ought to work. This routine is
+ used by both the 32-bit and the 64-bit ABI. */
+
+boolean
+_bfd_mips_elf_fake_sections (abfd, hdr, sec)
+ bfd *abfd;
+ Elf32_Internal_Shdr *hdr;
+ asection *sec;
+{
+ register const char *name;
+
+ name = bfd_get_section_name (abfd, sec);
+
+ if (strcmp (name, ".liblist") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_LIBLIST;
+ hdr->sh_info = sec->_raw_size / sizeof (Elf32_Lib);
+ /* The sh_link field is set in final_write_processing. */
+ }
+ else if (strcmp (name, ".msym") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_MSYM;
+ hdr->sh_entsize = 8;
+ /* FIXME: Set the sh_info field. */
+ }
+ else if (strcmp (name, ".conflict") == 0)
+ hdr->sh_type = SHT_MIPS_CONFLICT;
+ else if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0)
+ {
+ hdr->sh_type = SHT_MIPS_GPTAB;
+ hdr->sh_entsize = sizeof (Elf32_External_gptab);
+ /* The sh_info field is set in final_write_processing. */
+ }
+ else if (strcmp (name, ".ucode") == 0)
+ hdr->sh_type = SHT_MIPS_UCODE;
+ else if (strcmp (name, ".mdebug") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_DEBUG;
+ /* In a shared object on Irix 5.3, the .mdebug section has an
+ entsize of 0. FIXME: Does this matter? */
+ if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
+ hdr->sh_entsize = 0;
+ else
+ hdr->sh_entsize = 1;
+ }
+ else if (strcmp (name, ".reginfo") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_REGINFO;
+ /* In a shared object on Irix 5.3, the .reginfo section has an
+ entsize of 0x18. FIXME: Does this matter? */
+ if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
+ hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
+ else
+ hdr->sh_entsize = 1;
+ }
+ else if (SGI_COMPAT (abfd)
+ && (strcmp (name, ".hash") == 0
+ || strcmp (name, ".dynamic") == 0
+ || strcmp (name, ".dynstr") == 0))
+ {
+ hdr->sh_entsize = 0;
+#if 0
+ /* This isn't how the Irix 6 linker behaves. */
+ hdr->sh_info = SIZEOF_MIPS_DYNSYM_SECNAMES;
+#endif
+ }
+ else if (strcmp (name, ".got") == 0
+ || strcmp (name, ".sdata") == 0
+ || strcmp (name, ".sbss") == 0
+ || strcmp (name, ".lit4") == 0
+ || strcmp (name, ".lit8") == 0)
+ hdr->sh_flags |= SHF_MIPS_GPREL;
+ else if (strcmp (name, ".MIPS.interfaces") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_IFACE;
+ hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+ }
+ else if (strcmp (name, ".MIPS.content") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_CONTENT;
+ /* The sh_info field is set in final_write_processing. */
+ }
+ else if (strcmp (name, ".options") == 0
+ || strcmp (name, ".MIPS.options") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_OPTIONS;
+ hdr->sh_entsize = 1;
+ hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+ }
+ else if (strncmp (name, ".debug_", sizeof ".debug_" - 1) == 0)
+ hdr->sh_type = SHT_MIPS_DWARF;
+ else if (strcmp (name, ".MIPS.symlib") == 0)
+ {
+ hdr->sh_type = SHT_MIPS_SYMBOL_LIB;
+ /* The sh_link and sh_info fields are set in
+ final_write_processing. */
+ }
+ else if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0
+ || strncmp (name, ".MIPS.post_rel",
+ sizeof ".MIPS.post_rel" - 1) == 0)
+ {
+ hdr->sh_type = SHT_MIPS_EVENTS;
+ hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+ /* The sh_link field is set in final_write_processing. */
+ }
+
+ return true;
+}
+
+/* Given a BFD section, try to locate the corresponding ELF section
+ index. This is used by both the 32-bit and the 64-bit ABI.
+ Actually, it's not clear to me that the 64-bit ABI supports these,
+ but for non-PIC objects we will certainly want support for at least
+ the .scommon section. */
+
+boolean
+_bfd_mips_elf_section_from_bfd_section (abfd, hdr, sec, retval)
+ bfd *abfd;
+ Elf32_Internal_Shdr *hdr;
+ asection *sec;
+ int *retval;
+{
+ if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+ {
+ *retval = SHN_MIPS_SCOMMON;
+ return true;
+ }
+ if (strcmp (bfd_get_section_name (abfd, sec), ".acommon") == 0)
+ {
+ *retval = SHN_MIPS_ACOMMON;
+ return true;
+ }
+ return false;
+}
+
+/* When are writing out the .options or .MIPS.options section,
+ remember the bytes we are writing out, so that we can install the
+ GP value in the section_processing routine. */
+
+boolean
+_bfd_mips_elf_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (strcmp (section->name, ".options") == 0
+ || strcmp (section->name, ".MIPS.options") == 0)
+ {
+ bfd_byte *c;
+
+ if (elf_section_data (section) == NULL)
+ {
+ section->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct bfd_elf_section_data));
+ if (elf_section_data (section) == NULL)
+ return false;
+ }
+ c = (bfd_byte *) elf_section_data (section)->tdata;
+ if (c == NULL)
+ {
+ bfd_size_type size;
+
+ if (section->_cooked_size != 0)
+ size = section->_cooked_size;
+ else
+ size = section->_raw_size;
+ c = (bfd_byte *) bfd_zalloc (abfd, size);
+ if (c == NULL)
+ return false;
+ elf_section_data (section)->tdata = (PTR) c;
+ }
+
+ memcpy (c + offset, location, count);
+ }
+
+ return _bfd_elf_set_section_contents (abfd, section, location, offset,
+ count);
+}
+
+/* Work over a section just before writing it out. This routine is
+ used by both the 32-bit and the 64-bit ABI. FIXME: We recognize
+ sections that need the SHF_MIPS_GPREL flag by name; there has to be
+ a better way. */
+
+boolean
+_bfd_mips_elf_section_processing (abfd, hdr)
+ bfd *abfd;
+ Elf_Internal_Shdr *hdr;
+{
+ if (hdr->bfd_section != NULL)
+ {
+ const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+
+ if (strcmp (name, ".sdata") == 0)
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+ hdr->sh_type = SHT_PROGBITS;
+ }
+ else if (strcmp (name, ".sbss") == 0)
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+ hdr->sh_type = SHT_NOBITS;
+ }
+ else if (strcmp (name, ".lit8") == 0
+ || strcmp (name, ".lit4") == 0)
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+ hdr->sh_type = SHT_PROGBITS;
+ }
+ else if (strcmp (name, ".compact_rel") == 0)
+ {
+ hdr->sh_flags = 0;
+ hdr->sh_type = SHT_PROGBITS;
+ }
+ else if (strcmp (name, ".rtproc") == 0)
+ {
+ if (hdr->sh_addralign != 0 && hdr->sh_entsize == 0)
+ {
+ unsigned int adjust;
+
+ adjust = hdr->sh_size % hdr->sh_addralign;
+ if (adjust != 0)
+ hdr->sh_size += hdr->sh_addralign - adjust;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Work over a section just before writing it out. We update the GP
+ value in the SHT_MIPS_REGINFO and SHT_MIPS_OPTIONS sections based
+ on the value we are using. */
+
+static boolean
+mips_elf32_section_processing (abfd, hdr)
+ bfd *abfd;
+ Elf32_Internal_Shdr *hdr;
+{
+ if (hdr->sh_type == SHT_MIPS_REGINFO)
+ {
+ bfd_byte buf[4];
+
+ BFD_ASSERT (hdr->sh_size == sizeof (Elf32_External_RegInfo));
+ BFD_ASSERT (hdr->contents == NULL);
+
+ if (bfd_seek (abfd,
+ hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
+ SEEK_SET) == -1)
+ return false;
+ bfd_h_put_32 (abfd, (bfd_vma) elf_gp (abfd), buf);
+ if (bfd_write (buf, (bfd_size_type) 1, (bfd_size_type) 4, abfd) != 4)
+ return false;
+ }
+
+ if (hdr->sh_type == SHT_MIPS_OPTIONS
+ && hdr->bfd_section != NULL
+ && elf_section_data (hdr->bfd_section) != NULL
+ && elf_section_data (hdr->bfd_section)->tdata != NULL)
+ {
+ bfd_byte *contents, *l, *lend;
+
+ /* We stored the section contents in the elf_section_data tdata
+ field in the set_section_contents routine. We save the
+ section contents so that we don't have to read them again.
+ At this point we know that elf_gp is set, so we can look
+ through the section contents to see if there is an
+ ODK_REGINFO structure. */
+
+ contents = (bfd_byte *) elf_section_data (hdr->bfd_section)->tdata;
+ l = contents;
+ lend = contents + hdr->sh_size;
+ while (l + sizeof (Elf_External_Options) <= lend)
+ {
+ Elf_Internal_Options intopt;
+
+ bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
+ &intopt);
+ if (intopt.kind == ODK_REGINFO)
+ {
+ bfd_byte buf[4];
+
+ if (bfd_seek (abfd,
+ (hdr->sh_offset
+ + (l - contents)
+ + sizeof (Elf_External_Options)
+ + (sizeof (Elf32_External_RegInfo) - 4)),
+ SEEK_SET) == -1)
+ return false;
+ bfd_h_put_32 (abfd, elf_gp (abfd), buf);
+ if (bfd_write (buf, 1, 4, abfd) != 4)
+ return false;
+ }
+ l += intopt.size;
+ }
+ }
+
+ return _bfd_mips_elf_section_processing (abfd, hdr);
+}
+
+/* MIPS ELF uses two common sections. One is the usual one, and the
+ other is for small objects. All the small objects are kept
+ together, and then referenced via the gp pointer, which yields
+ faster assembler code. This is what we use for the small common
+ section. This approach is copied from ecoff.c. */
+static asection mips_elf_scom_section;
+static asymbol mips_elf_scom_symbol;
+static asymbol *mips_elf_scom_symbol_ptr;
+
+/* MIPS ELF also uses an acommon section, which represents an
+ allocated common symbol which may be overridden by a
+ definition in a shared library. */
+static asection mips_elf_acom_section;
+static asymbol mips_elf_acom_symbol;
+static asymbol *mips_elf_acom_symbol_ptr;
+
+/* The Irix 5 support uses two virtual sections, which represent
+ text/data symbols defined in dynamic objects. */
+static asection mips_elf_text_section;
+static asection *mips_elf_text_section_ptr;
+static asymbol mips_elf_text_symbol;
+static asymbol *mips_elf_text_symbol_ptr;
+
+static asection mips_elf_data_section;
+static asection *mips_elf_data_section_ptr;
+static asymbol mips_elf_data_symbol;
+static asymbol *mips_elf_data_symbol_ptr;
+
+/* Handle the special MIPS section numbers that a symbol may use.
+ This is used for both the 32-bit and the 64-bit ABI. */
+
+void
+_bfd_mips_elf_symbol_processing (abfd, asym)
+ bfd *abfd;
+ asymbol *asym;
+{
+ elf_symbol_type *elfsym;
+
+ elfsym = (elf_symbol_type *) asym;
+ switch (elfsym->internal_elf_sym.st_shndx)
+ {
+ case SHN_MIPS_ACOMMON:
+ /* This section is used in a dynamically linked executable file.
+ It is an allocated common section. The dynamic linker can
+ either resolve these symbols to something in a shared
+ library, or it can just leave them here. For our purposes,
+ we can consider these symbols to be in a new section. */
+ if (mips_elf_acom_section.name == NULL)
+ {
+ /* Initialize the acommon section. */
+ mips_elf_acom_section.name = ".acommon";
+ mips_elf_acom_section.flags = SEC_ALLOC;
+ mips_elf_acom_section.output_section = &mips_elf_acom_section;
+ mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
+ mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
+ mips_elf_acom_symbol.name = ".acommon";
+ mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
+ mips_elf_acom_symbol.section = &mips_elf_acom_section;
+ mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
+ }
+ asym->section = &mips_elf_acom_section;
+ break;
+
+ case SHN_COMMON:
+ /* Common symbols less than the GP size are automatically
+ treated as SHN_MIPS_SCOMMON symbols. */
+ if (asym->value > elf_gp_size (abfd))
+ break;
+ /* Fall through. */
+ case SHN_MIPS_SCOMMON:
+ if (mips_elf_scom_section.name == NULL)
+ {
+ /* Initialize the small common section. */
+ mips_elf_scom_section.name = ".scommon";
+ mips_elf_scom_section.flags = SEC_IS_COMMON;
+ mips_elf_scom_section.output_section = &mips_elf_scom_section;
+ mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
+ mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
+ mips_elf_scom_symbol.name = ".scommon";
+ mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
+ mips_elf_scom_symbol.section = &mips_elf_scom_section;
+ mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
+ }
+ asym->section = &mips_elf_scom_section;
+ asym->value = elfsym->internal_elf_sym.st_size;
+ break;
+
+ case SHN_MIPS_SUNDEFINED:
+ asym->section = bfd_und_section_ptr;
+ break;
+
+#if 0 /* for SGI_COMPAT */
+ case SHN_MIPS_TEXT:
+ asym->section = mips_elf_text_section_ptr;
+ break;
+
+ case SHN_MIPS_DATA:
+ asym->section = mips_elf_data_section_ptr;
+ break;
+#endif
+ }
+}
+
+/* When creating an Irix 5 executable, we need REGINFO and RTPROC
+ segments. */
+
+static int
+mips_elf_additional_program_headers (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ int ret;
+
+ ret = 0;
+
+ if (! SGI_COMPAT (abfd))
+ return ret;
+
+ s = bfd_get_section_by_name (abfd, ".reginfo");
+ if (s != NULL && (s->flags & SEC_LOAD) != 0)
+ {
+ /* We need a PT_MIPS_REGINFO segment. */
+ ++ret;
+ }
+
+ if (bfd_get_section_by_name (abfd, ".dynamic") != NULL
+ && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
+ {
+ /* We need a PT_MIPS_RTPROC segment. */
+ ++ret;
+ }
+
+ return ret;
+}
+
+/* Modify the segment map for an Irix 5 executable. */
+
+static boolean
+mips_elf_modify_segment_map (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ struct elf_segment_map *m, **pm;
+
+ if (! SGI_COMPAT (abfd))
+ return true;
+
+ /* If there is a .reginfo section, we need a PT_MIPS_REGINFO
+ segment. */
+ s = bfd_get_section_by_name (abfd, ".reginfo");
+ if (s != NULL && (s->flags & SEC_LOAD) != 0)
+ {
+ for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ if (m->p_type == PT_MIPS_REGINFO)
+ break;
+ if (m == NULL)
+ {
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ if (m == NULL)
+ return false;
+
+ m->p_type = PT_MIPS_REGINFO;
+ m->count = 1;
+ m->sections[0] = s;
+
+ /* We want to put it after the PHDR and INTERP segments. */
+ pm = &elf_tdata (abfd)->segment_map;
+ while (*pm != NULL
+ && ((*pm)->p_type == PT_PHDR
+ || (*pm)->p_type == PT_INTERP))
+ pm = &(*pm)->next;
+
+ m->next = *pm;
+ *pm = m;
+ }
+ }
+
+ /* If there are .dynamic and .mdebug sections, we make a room for
+ the RTPROC header. FIXME: Rewrite without section names. */
+ if (bfd_get_section_by_name (abfd, ".interp") == NULL
+ && bfd_get_section_by_name (abfd, ".dynamic") != NULL
+ && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
+ {
+ for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ if (m->p_type == PT_MIPS_RTPROC)
+ break;
+ if (m == NULL)
+ {
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ if (m == NULL)
+ return false;
+
+ m->p_type = PT_MIPS_RTPROC;
+
+ s = bfd_get_section_by_name (abfd, ".rtproc");
+ if (s == NULL)
+ {
+ m->count = 0;
+ m->p_flags = 0;
+ m->p_flags_valid = 1;
+ }
+ else
+ {
+ m->count = 1;
+ m->sections[0] = s;
+ }
+
+ /* We want to put it after the DYNAMIC segment. */
+ pm = &elf_tdata (abfd)->segment_map;
+ while (*pm != NULL && (*pm)->p_type != PT_DYNAMIC)
+ pm = &(*pm)->next;
+ if (*pm != NULL)
+ pm = &(*pm)->next;
+
+ m->next = *pm;
+ *pm = m;
+ }
+ }
+
+ /* On Irix 5, the PT_DYNAMIC segment includes the .dynamic, .dynstr,
+ .dynsym, and .hash sections, and everything in between. */
+ for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
+ if ((*pm)->p_type == PT_DYNAMIC)
+ break;
+ m = *pm;
+ if (m != NULL
+ && m->count == 1
+ && strcmp (m->sections[0]->name, ".dynamic") == 0)
+ {
+ static const char *sec_names[] =
+ { ".dynamic", ".dynstr", ".dynsym", ".hash" };
+ bfd_vma low, high;
+ unsigned int i, c;
+ struct elf_segment_map *n;
+
+ low = 0xffffffff;
+ high = 0;
+ for (i = 0; i < sizeof sec_names / sizeof sec_names[0]; i++)
+ {
+ s = bfd_get_section_by_name (abfd, sec_names[i]);
+ if (s != NULL && (s->flags & SEC_LOAD) != 0)
+ {
+ bfd_size_type sz;
+
+ if (low > s->vma)
+ low = s->vma;
+ sz = s->_cooked_size;
+ if (sz == 0)
+ sz = s->_raw_size;
+ if (high < s->vma + sz)
+ high = s->vma + sz;
+ }
+ }
+
+ c = 0;
+ for (s = abfd->sections; s != NULL; s = s->next)
+ if ((s->flags & SEC_LOAD) != 0
+ && s->vma >= low
+ && ((s->vma
+ + (s->_cooked_size != 0 ? s->_cooked_size : s->_raw_size))
+ <= high))
+ ++c;
+
+ n = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, sizeof *n + (c - 1) * sizeof (asection *)));
+ if (n == NULL)
+ return false;
+ *n = *m;
+ n->count = c;
+
+ i = 0;
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LOAD) != 0
+ && s->vma >= low
+ && ((s->vma
+ + (s->_cooked_size != 0 ? s->_cooked_size : s->_raw_size))
+ <= high))
+ {
+ n->sections[i] = s;
+ ++i;
+ }
+ }
+
+ *pm = n;
+ }
+
+ return true;
+}
+
+/* The structure of the runtime procedure descriptor created by the
+ loader for use by the static exception system. */
+
+typedef struct runtime_pdr {
+ bfd_vma adr; /* memory address of start of procedure */
+ long regmask; /* save register mask */
+ long regoffset; /* save register offset */
+ long fregmask; /* save floating point register mask */
+ long fregoffset; /* save floating point register offset */
+ long frameoffset; /* frame size */
+ short framereg; /* frame pointer register */
+ short pcreg; /* offset or reg of return pc */
+ long irpss; /* index into the runtime string table */
+ long reserved;
+ struct exception_info *exception_info;/* pointer to exception array */
+} RPDR, *pRPDR;
+#define cbRPDR sizeof(RPDR)
+#define rpdNil ((pRPDR) 0)
+
+/* Swap RPDR (runtime procedure table entry) for output. */
+
+static void ecoff_swap_rpdr_out
+ PARAMS ((bfd *, const RPDR *, struct rpdr_ext *));
+
+static void
+ecoff_swap_rpdr_out (abfd, in, ex)
+ bfd *abfd;
+ const RPDR *in;
+ struct rpdr_ext *ex;
+{
+ /* ecoff_put_off was defined in ecoffswap.h. */
+ ecoff_put_off (abfd, in->adr, (bfd_byte *) ex->p_adr);
+ bfd_h_put_32 (abfd, in->regmask, (bfd_byte *) ex->p_regmask);
+ bfd_h_put_32 (abfd, in->regoffset, (bfd_byte *) ex->p_regoffset);
+ bfd_h_put_32 (abfd, in->fregmask, (bfd_byte *) ex->p_fregmask);
+ bfd_h_put_32 (abfd, in->fregoffset, (bfd_byte *) ex->p_fregoffset);
+ bfd_h_put_32 (abfd, in->frameoffset, (bfd_byte *) ex->p_frameoffset);
+
+ bfd_h_put_16 (abfd, in->framereg, (bfd_byte *) ex->p_framereg);
+ bfd_h_put_16 (abfd, in->pcreg, (bfd_byte *) ex->p_pcreg);
+
+ bfd_h_put_32 (abfd, in->irpss, (bfd_byte *) ex->p_irpss);
+#if 0 /* FIXME */
+ ecoff_put_off (abfd, in->exception_info, (bfd_byte *) ex->p_exception_info);
+#endif
+}
+
+/* Read ECOFF debugging information from a .mdebug section into a
+ ecoff_debug_info structure. */
+
+boolean
+_bfd_mips_elf_read_ecoff_info (abfd, section, debug)
+ bfd *abfd;
+ asection *section;
+ struct ecoff_debug_info *debug;
+{
+ HDRR *symhdr;
+ const struct ecoff_debug_swap *swap;
+ char *ext_hdr = NULL;
+
+ swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+ memset (debug, 0, sizeof(*debug));
+
+ ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
+ if (ext_hdr == NULL && swap->external_hdr_size != 0)
+ goto error_return;
+
+ if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
+ swap->external_hdr_size)
+ == false)
+ goto error_return;
+
+ symhdr = &debug->symbolic_header;
+ (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr);
+
+ /* The symbolic header contains absolute file offsets and sizes to
+ read. */
+#define READ(ptr, offset, count, size, type) \
+ if (symhdr->count == 0) \
+ debug->ptr = NULL; \
+ else \
+ { \
+ debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
+ if (debug->ptr == NULL) \
+ goto error_return; \
+ if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
+ || (bfd_read (debug->ptr, size, symhdr->count, \
+ abfd) != size * symhdr->count)) \
+ goto error_return; \
+ }
+
+ READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
+ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
+ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
+ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
+ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
+ READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
+ union aux_ext *);
+ READ (ss, cbSsOffset, issMax, sizeof (char), char *);
+ READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
+ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
+ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
+ READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
+#undef READ
+
+ debug->fdr = NULL;
+ debug->adjust = NULL;
+
+ return true;
+
+ error_return:
+ if (ext_hdr != NULL)
+ free (ext_hdr);
+ if (debug->line != NULL)
+ free (debug->line);
+ if (debug->external_dnr != NULL)
+ free (debug->external_dnr);
+ if (debug->external_pdr != NULL)
+ free (debug->external_pdr);
+ if (debug->external_sym != NULL)
+ free (debug->external_sym);
+ if (debug->external_opt != NULL)
+ free (debug->external_opt);
+ if (debug->external_aux != NULL)
+ free (debug->external_aux);
+ if (debug->ss != NULL)
+ free (debug->ss);
+ if (debug->ssext != NULL)
+ free (debug->ssext);
+ if (debug->external_fdr != NULL)
+ free (debug->external_fdr);
+ if (debug->external_rfd != NULL)
+ free (debug->external_rfd);
+ if (debug->external_ext != NULL)
+ free (debug->external_ext);
+ return false;
+}
+
+/* MIPS ELF local labels start with '$', not 'L'. */
+
+/*ARGSUSED*/
+static boolean
+mips_elf_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (name[0] == '$')
+ return true;
+
+ /* On Irix 6, the labels go back to starting with '.', so we accept
+ the generic ELF local label syntax as well. */
+ return _bfd_elf_is_local_label_name (abfd, name);
+}
+
+/* MIPS ELF uses a special find_nearest_line routine in order the
+ handle the ECOFF debugging information. */
+
+struct mips_elf_find_line
+{
+ struct ecoff_debug_info d;
+ struct ecoff_find_line i;
+};
+
+boolean
+_bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
+ functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ asection *msec;
+
+ if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ return true;
+
+ if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ return true;
+
+ msec = bfd_get_section_by_name (abfd, ".mdebug");
+ if (msec != NULL)
+ {
+ flagword origflags;
+ struct mips_elf_find_line *fi;
+ const struct ecoff_debug_swap * const swap =
+ get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+
+ /* If we are called during a link, mips_elf_final_link may have
+ cleared the SEC_HAS_CONTENTS field. We force it back on here
+ if appropriate (which it normally will be). */
+ origflags = msec->flags;
+ if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
+ msec->flags |= SEC_HAS_CONTENTS;
+
+ fi = elf_tdata (abfd)->find_line_info;
+ if (fi == NULL)
+ {
+ bfd_size_type external_fdr_size;
+ char *fraw_src;
+ char *fraw_end;
+ struct fdr *fdr_ptr;
+
+ fi = ((struct mips_elf_find_line *)
+ bfd_zalloc (abfd, sizeof (struct mips_elf_find_line)));
+ if (fi == NULL)
+ {
+ msec->flags = origflags;
+ return false;
+ }
+
+ if (! _bfd_mips_elf_read_ecoff_info (abfd, msec, &fi->d))
+ {
+ msec->flags = origflags;
+ return false;
+ }
+
+ /* Swap in the FDR information. */
+ fi->d.fdr = ((struct fdr *)
+ bfd_alloc (abfd,
+ (fi->d.symbolic_header.ifdMax *
+ sizeof (struct fdr))));
+ if (fi->d.fdr == NULL)
+ {
+ msec->flags = origflags;
+ return false;
+ }
+ external_fdr_size = swap->external_fdr_size;
+ fdr_ptr = fi->d.fdr;
+ fraw_src = (char *) fi->d.external_fdr;
+ fraw_end = (fraw_src
+ + fi->d.symbolic_header.ifdMax * external_fdr_size);
+ for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
+ (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
+
+ elf_tdata (abfd)->find_line_info = fi;
+
+ /* Note that we don't bother to ever free this information.
+ find_nearest_line is either called all the time, as in
+ objdump -l, so the information should be saved, or it is
+ rarely called, as in ld error messages, so the memory
+ wasted is unimportant. Still, it would probably be a
+ good idea for free_cached_info to throw it away. */
+ }
+
+ if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap,
+ &fi->i, filename_ptr, functionname_ptr,
+ line_ptr))
+ {
+ msec->flags = origflags;
+ return true;
+ }
+
+ msec->flags = origflags;
+ }
+
+ /* Fall back on the generic ELF find_nearest_line routine. */
+
+ return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr);
+}
+
+ /* The mips16 compiler uses a couple of special sections to handle
+ floating point arguments.
+
+ Section names that look like .mips16.fn.FNNAME contain stubs that
+ copy floating point arguments from the fp regs to the gp regs and
+ then jump to FNNAME. If any 32 bit function calls FNNAME, the
+ call should be redirected to the stub instead. If no 32 bit
+ function calls FNNAME, the stub should be discarded. We need to
+ consider any reference to the function, not just a call, because
+ if the address of the function is taken we will need the stub,
+ since the address might be passed to a 32 bit function.
+
+ Section names that look like .mips16.call.FNNAME contain stubs
+ that copy floating point arguments from the gp regs to the fp
+ regs and then jump to FNNAME. If FNNAME is a 32 bit function,
+ then any 16 bit function that calls FNNAME should be redirected
+ to the stub instead. If FNNAME is not a 32 bit function, the
+ stub should be discarded.
+
+ .mips16.call.fp.FNNAME sections are similar, but contain stubs
+ which call FNNAME and then copy the return value from the fp regs
+ to the gp regs. These stubs store the return value in $18 while
+ calling FNNAME; any function which might call one of these stubs
+ must arrange to save $18 around the call. (This case is not
+ needed for 32 bit functions that call 16 bit functions, because
+ 16 bit functions always return floating point values in both
+ $f0/$f1 and $2/$3.)
+
+ Note that in all cases FNNAME might be defined statically.
+ Therefore, FNNAME is not used literally. Instead, the relocation
+ information will indicate which symbol the section is for.
+
+ We record any stubs that we find in the symbol table. */
+
+#define FN_STUB ".mips16.fn."
+#define CALL_STUB ".mips16.call."
+#define CALL_FP_STUB ".mips16.call.fp."
+
+/* The MIPS ELF linker needs additional information for each symbol in
+ the global hash table. */
+
+struct mips_elf_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* External symbol information. */
+ EXTR esym;
+
+ /* Number of MIPS_32 or MIPS_REL32 relocs against this symbol. */
+ unsigned int mips_32_relocs;
+
+ /* If there is a stub that 32 bit functions should use to call this
+ 16 bit function, this points to the section containing the stub. */
+ asection *fn_stub;
+
+ /* Whether we need the fn_stub; this is set if this symbol appears
+ in any relocs other than a 16 bit call. */
+ boolean need_fn_stub;
+
+ /* If there is a stub that 16 bit functions should use to call this
+ 32 bit function, this points to the section containing the stub. */
+ asection *call_stub;
+
+ /* This is like the call_stub field, but it is used if the function
+ being called returns a floating point value. */
+ asection *call_fp_stub;
+};
+
+/* MIPS ELF linker hash table. */
+
+struct mips_elf_link_hash_table
+{
+ struct elf_link_hash_table root;
+#if 0
+ /* We no longer use this. */
+ /* String section indices for the dynamic section symbols. */
+ bfd_size_type dynsym_sec_strindex[SIZEOF_MIPS_DYNSYM_SECNAMES];
+#endif
+ /* The number of .rtproc entries. */
+ bfd_size_type procedure_count;
+ /* The size of the .compact_rel section (if SGI_COMPAT). */
+ bfd_size_type compact_rel_size;
+ /* This flag indicates that the value of DT_MIPS_RLD_MAP dynamic
+ entry is set to the address of __rld_obj_head as in Irix 5. */
+ boolean use_rld_obj_head;
+ /* This is the value of the __rld_map or __rld_obj_head symbol. */
+ bfd_vma rld_value;
+ /* This is set if we see any mips16 stub sections. */
+ boolean mips16_stubs_seen;
+};
+
+/* Look up an entry in a MIPS ELF linker hash table. */
+
+#define mips_elf_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct mips_elf_link_hash_entry *) \
+ elf_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+/* Traverse a MIPS ELF linker hash table. */
+
+#define mips_elf_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the MIPS ELF linker hash table from a link_info structure. */
+
+#define mips_elf_hash_table(p) \
+ ((struct mips_elf_link_hash_table *) ((p)->hash))
+
+static boolean mips_elf_output_extsym
+ PARAMS ((struct mips_elf_link_hash_entry *, PTR));
+
+/* Create an entry in a MIPS ELF linker hash table. */
+
+static struct bfd_hash_entry *
+mips_elf_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct mips_elf_link_hash_entry *ret =
+ (struct mips_elf_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct mips_elf_link_hash_entry *) NULL)
+ ret = ((struct mips_elf_link_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct mips_elf_link_hash_entry)));
+ if (ret == (struct mips_elf_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct mips_elf_link_hash_entry *)
+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct mips_elf_link_hash_entry *) NULL)
+ {
+ /* Set local fields. */
+ memset (&ret->esym, 0, sizeof (EXTR));
+ /* We use -2 as a marker to indicate that the information has
+ not been set. -1 means there is no associated ifd. */
+ ret->esym.ifd = -2;
+ ret->mips_32_relocs = 0;
+ ret->fn_stub = NULL;
+ ret->need_fn_stub = false;
+ ret->call_stub = NULL;
+ ret->call_fp_stub = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a MIPS ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+mips_elf_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct mips_elf_link_hash_table *ret;
+
+ ret = ((struct mips_elf_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct mips_elf_link_hash_table)));
+ if (ret == (struct mips_elf_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
+ mips_elf_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+#if 0
+ /* We no longer use this. */
+ for (i = 0; i < SIZEOF_MIPS_DYNSYM_SECNAMES; i++)
+ ret->dynsym_sec_strindex[i] = (bfd_size_type) -1;
+#endif
+ ret->procedure_count = 0;
+ ret->compact_rel_size = 0;
+ ret->use_rld_obj_head = false;
+ ret->rld_value = 0;
+ ret->mips16_stubs_seen = false;
+
+ return &ret->root.root;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+ file. We must handle the special MIPS section numbers here. */
+
+/*ARGSUSED*/
+static boolean
+mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const Elf_Internal_Sym *sym;
+ const char **namep;
+ flagword *flagsp;
+ asection **secp;
+ bfd_vma *valp;
+{
+ if (SGI_COMPAT (abfd)
+ && (abfd->flags & DYNAMIC) != 0
+ && strcmp (*namep, "_rld_new_interface") == 0)
+ {
+ /* Skip Irix 5 rld entry name. */
+ *namep = NULL;
+ return true;
+ }
+
+ switch (sym->st_shndx)
+ {
+ case SHN_COMMON:
+ /* Common symbols less than the GP size are automatically
+ treated as SHN_MIPS_SCOMMON symbols. */
+ if (sym->st_size > elf_gp_size (abfd))
+ break;
+ /* Fall through. */
+ case SHN_MIPS_SCOMMON:
+ *secp = bfd_make_section_old_way (abfd, ".scommon");
+ (*secp)->flags |= SEC_IS_COMMON;
+ *valp = sym->st_size;
+ break;
+
+ case SHN_MIPS_TEXT:
+ /* This section is used in a shared object. */
+ if (mips_elf_text_section_ptr == NULL)
+ {
+ /* Initialize the section. */
+ mips_elf_text_section.name = ".text";
+ mips_elf_text_section.flags = SEC_NO_FLAGS;
+ mips_elf_text_section.output_section = NULL;
+ mips_elf_text_section.symbol = &mips_elf_text_symbol;
+ mips_elf_text_section.symbol_ptr_ptr = &mips_elf_text_symbol_ptr;
+ mips_elf_text_symbol.name = ".text";
+ mips_elf_text_symbol.flags = BSF_SECTION_SYM;
+ mips_elf_text_symbol.section = &mips_elf_text_section;
+ mips_elf_text_symbol_ptr = &mips_elf_text_symbol;
+ mips_elf_text_section_ptr = &mips_elf_text_section;
+ }
+ /* This code used to do *secp = bfd_und_section_ptr if
+ info->shared. I don't know why, and that doesn't make sense,
+ so I took it out. */
+ *secp = mips_elf_text_section_ptr;
+ break;
+
+ case SHN_MIPS_ACOMMON:
+ /* Fall through. XXX Can we treat this as allocated data? */
+ case SHN_MIPS_DATA:
+ /* This section is used in a shared object. */
+ if (mips_elf_data_section_ptr == NULL)
+ {
+ /* Initialize the section. */
+ mips_elf_data_section.name = ".data";
+ mips_elf_data_section.flags = SEC_NO_FLAGS;
+ mips_elf_data_section.output_section = NULL;
+ mips_elf_data_section.symbol = &mips_elf_data_symbol;
+ mips_elf_data_section.symbol_ptr_ptr = &mips_elf_data_symbol_ptr;
+ mips_elf_data_symbol.name = ".data";
+ mips_elf_data_symbol.flags = BSF_SECTION_SYM;
+ mips_elf_data_symbol.section = &mips_elf_data_section;
+ mips_elf_data_symbol_ptr = &mips_elf_data_symbol;
+ mips_elf_data_section_ptr = &mips_elf_data_section;
+ }
+ /* This code used to do *secp = bfd_und_section_ptr if
+ info->shared. I don't know why, and that doesn't make sense,
+ so I took it out. */
+ *secp = mips_elf_data_section_ptr;
+ break;
+
+ case SHN_MIPS_SUNDEFINED:
+ *secp = bfd_und_section_ptr;
+ break;
+ }
+
+ if (SGI_COMPAT (abfd)
+ && ! info->shared
+ && info->hash->creator == abfd->xvec
+ && strcmp (*namep, "__rld_obj_head") == 0)
+ {
+ struct elf_link_hash_entry *h;
+
+ /* Mark __rld_obj_head as dynamic. */
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, *namep, BSF_GLOBAL, *secp,
+ (bfd_vma) *valp, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+
+ mips_elf_hash_table (info)->use_rld_obj_head = true;
+ }
+
+ /* If this is a mips16 text symbol, add 1 to the value to make it
+ odd. This will cause something like .word SYM to come up with
+ the right value when it is loaded into the PC. */
+ if (sym->st_other == STO_MIPS16)
+ ++*valp;
+
+ return true;
+}
+
+/* Structure used to pass information to mips_elf_output_extsym. */
+
+struct extsym_info
+{
+ bfd *abfd;
+ struct bfd_link_info *info;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ boolean failed;
+};
+
+/* This routine is used to write out ECOFF debugging external symbol
+ information. It is called via mips_elf_link_hash_traverse. The
+ ECOFF external symbol information must match the ELF external
+ symbol information. Unfortunately, at this point we don't know
+ whether a symbol is required by reloc information, so the two
+ tables may wind up being different. We must sort out the external
+ symbol information before we can set the final size of the .mdebug
+ section, and we must set the size of the .mdebug section before we
+ can relocate any sections, and we can't know which symbols are
+ required by relocation until we relocate the sections.
+ Fortunately, it is relatively unlikely that any symbol will be
+ stripped but required by a reloc. In particular, it can not happen
+ when generating a final executable. */
+
+static boolean
+mips_elf_output_extsym (h, data)
+ struct mips_elf_link_hash_entry *h;
+ PTR data;
+{
+ struct extsym_info *einfo = (struct extsym_info *) data;
+ boolean strip;
+ asection *sec, *output_section;
+
+ if (h->root.indx == -2)
+ strip = false;
+ else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
+ && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
+ strip = true;
+ else if (einfo->info->strip == strip_all
+ || (einfo->info->strip == strip_some
+ && bfd_hash_lookup (einfo->info->keep_hash,
+ h->root.root.root.string,
+ false, false) == NULL))
+ strip = true;
+ else
+ strip = false;
+
+ if (strip)
+ return true;
+
+ if (h->esym.ifd == -2)
+ {
+ h->esym.jmptbl = 0;
+ h->esym.cobol_main = 0;
+ h->esym.weakext = 0;
+ h->esym.reserved = 0;
+ h->esym.ifd = ifdNil;
+ h->esym.asym.value = 0;
+ h->esym.asym.st = stGlobal;
+
+ if (SGI_COMPAT (einfo->abfd)
+ && (h->root.root.type == bfd_link_hash_undefined
+ || h->root.root.type == bfd_link_hash_undefweak))
+ {
+ const char *name;
+
+ /* Use undefined class. Also, set class and type for some
+ special symbols. */
+ name = h->root.root.root.string;
+ if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
+ || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
+ {
+ h->esym.asym.sc = scData;
+ h->esym.asym.st = stLabel;
+ h->esym.asym.value = 0;
+ }
+ else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
+ {
+ h->esym.asym.sc = scAbs;
+ h->esym.asym.st = stLabel;
+ h->esym.asym.value =
+ mips_elf_hash_table (einfo->info)->procedure_count;
+ }
+ else if (strcmp (name, "_gp_disp") == 0)
+ {
+ h->esym.asym.sc = scAbs;
+ h->esym.asym.st = stLabel;
+ h->esym.asym.value = elf_gp (einfo->abfd);
+ }
+ else
+ h->esym.asym.sc = scUndefined;
+ }
+ else if (h->root.root.type != bfd_link_hash_defined
+ && h->root.root.type != bfd_link_hash_defweak)
+ h->esym.asym.sc = scAbs;
+ else
+ {
+ const char *name;
+
+ sec = h->root.root.u.def.section;
+ output_section = sec->output_section;
+
+ /* When making a shared library and symbol h is the one from
+ the another shared library, OUTPUT_SECTION may be null. */
+ if (output_section == NULL)
+ h->esym.asym.sc = scUndefined;
+ else
+ {
+ name = bfd_section_name (output_section->owner, output_section);
+
+ if (strcmp (name, ".text") == 0)
+ h->esym.asym.sc = scText;
+ else if (strcmp (name, ".data") == 0)
+ h->esym.asym.sc = scData;
+ else if (strcmp (name, ".sdata") == 0)
+ h->esym.asym.sc = scSData;
+ else if (strcmp (name, ".rodata") == 0
+ || strcmp (name, ".rdata") == 0)
+ h->esym.asym.sc = scRData;
+ else if (strcmp (name, ".bss") == 0)
+ h->esym.asym.sc = scBss;
+ else if (strcmp (name, ".sbss") == 0)
+ h->esym.asym.sc = scSBss;
+ else if (strcmp (name, ".init") == 0)
+ h->esym.asym.sc = scInit;
+ else if (strcmp (name, ".fini") == 0)
+ h->esym.asym.sc = scFini;
+ else
+ h->esym.asym.sc = scAbs;
+ }
+ }
+
+ h->esym.asym.reserved = 0;
+ h->esym.asym.index = indexNil;
+ }
+
+ if (h->root.root.type == bfd_link_hash_common)
+ h->esym.asym.value = h->root.root.u.c.size;
+ else if (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ {
+ if (h->esym.asym.sc == scCommon)
+ h->esym.asym.sc = scBss;
+ else if (h->esym.asym.sc == scSCommon)
+ h->esym.asym.sc = scSBss;
+
+ sec = h->root.root.u.def.section;
+ output_section = sec->output_section;
+ if (output_section != NULL)
+ h->esym.asym.value = (h->root.root.u.def.value
+ + sec->output_offset
+ + output_section->vma);
+ else
+ h->esym.asym.value = 0;
+ }
+ else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ /* Set type and value for a symbol with a function stub. */
+ h->esym.asym.st = stProc;
+ sec = h->root.root.u.def.section;
+ if (sec == NULL)
+ h->esym.asym.value = 0;
+ else
+ {
+ output_section = sec->output_section;
+ if (output_section != NULL)
+ h->esym.asym.value = (h->root.plt.offset
+ + sec->output_offset
+ + output_section->vma);
+ else
+ h->esym.asym.value = 0;
+ }
+#if 0 /* FIXME? */
+ h->esym.ifd = 0;
+#endif
+ }
+
+ if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
+ h->root.root.root.string,
+ &h->esym))
+ {
+ einfo->failed = true;
+ return false;
+ }
+
+ return true;
+}
+
+/* Create a runtime procedure table from the .mdebug section. */
+
+static boolean
+mips_elf_create_procedure_table (handle, abfd, info, s, debug)
+ PTR handle;
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *s;
+ struct ecoff_debug_info *debug;
+{
+ const struct ecoff_debug_swap *swap;
+ HDRR *hdr = &debug->symbolic_header;
+ RPDR *rpdr, *rp;
+ struct rpdr_ext *erp;
+ PTR rtproc;
+ struct pdr_ext *epdr;
+ struct sym_ext *esym;
+ char *ss, **sv;
+ char *str;
+ unsigned long size, count;
+ unsigned long sindex;
+ unsigned long i;
+ PDR pdr;
+ SYMR sym;
+ const char *no_name_func = _("static procedure (no name)");
+
+ epdr = NULL;
+ rpdr = NULL;
+ esym = NULL;
+ ss = NULL;
+ sv = NULL;
+
+ swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+
+ sindex = strlen (no_name_func) + 1;
+ count = hdr->ipdMax;
+ if (count > 0)
+ {
+ size = swap->external_pdr_size;
+
+ epdr = (struct pdr_ext *) bfd_malloc (size * count);
+ if (epdr == NULL)
+ goto error_return;
+
+ if (! _bfd_ecoff_get_accumulated_pdr (handle, (PTR) epdr))
+ goto error_return;
+
+ size = sizeof (RPDR);
+ rp = rpdr = (RPDR *) bfd_malloc (size * count);
+ if (rpdr == NULL)
+ goto error_return;
+
+ sv = (char **) bfd_malloc (sizeof (char *) * count);
+ if (sv == NULL)
+ goto error_return;
+
+ count = hdr->isymMax;
+ size = swap->external_sym_size;
+ esym = (struct sym_ext *) bfd_malloc (size * count);
+ if (esym == NULL)
+ goto error_return;
+
+ if (! _bfd_ecoff_get_accumulated_sym (handle, (PTR) esym))
+ goto error_return;
+
+ count = hdr->issMax;
+ ss = (char *) bfd_malloc (count);
+ if (ss == NULL)
+ goto error_return;
+ if (! _bfd_ecoff_get_accumulated_ss (handle, (PTR) ss))
+ goto error_return;
+
+ count = hdr->ipdMax;
+ for (i = 0; i < count; i++, rp++)
+ {
+ (*swap->swap_pdr_in) (abfd, (PTR) (epdr + i), &pdr);
+ (*swap->swap_sym_in) (abfd, (PTR) &esym[pdr.isym], &sym);
+ rp->adr = sym.value;
+ rp->regmask = pdr.regmask;
+ rp->regoffset = pdr.regoffset;
+ rp->fregmask = pdr.fregmask;
+ rp->fregoffset = pdr.fregoffset;
+ rp->frameoffset = pdr.frameoffset;
+ rp->framereg = pdr.framereg;
+ rp->pcreg = pdr.pcreg;
+ rp->irpss = sindex;
+ sv[i] = ss + sym.iss;
+ sindex += strlen (sv[i]) + 1;
+ }
+ }
+
+ size = sizeof (struct rpdr_ext) * (count + 2) + sindex;
+ size = BFD_ALIGN (size, 16);
+ rtproc = (PTR) bfd_alloc (abfd, size);
+ if (rtproc == NULL)
+ {
+ mips_elf_hash_table (info)->procedure_count = 0;
+ goto error_return;
+ }
+
+ mips_elf_hash_table (info)->procedure_count = count + 2;
+
+ erp = (struct rpdr_ext *) rtproc;
+ memset (erp, 0, sizeof (struct rpdr_ext));
+ erp++;
+ str = (char *) rtproc + sizeof (struct rpdr_ext) * (count + 2);
+ strcpy (str, no_name_func);
+ str += strlen (no_name_func) + 1;
+ for (i = 0; i < count; i++)
+ {
+ ecoff_swap_rpdr_out (abfd, rpdr + i, erp + i);
+ strcpy (str, sv[i]);
+ str += strlen (sv[i]) + 1;
+ }
+ ecoff_put_off (abfd, (bfd_vma) -1, (bfd_byte *) (erp + count)->p_adr);
+
+ /* Set the size and contents of .rtproc section. */
+ s->_raw_size = size;
+ s->contents = (bfd_byte *) rtproc;
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ s->link_order_head = (struct bfd_link_order *) NULL;
+
+ if (epdr != NULL)
+ free (epdr);
+ if (rpdr != NULL)
+ free (rpdr);
+ if (esym != NULL)
+ free (esym);
+ if (ss != NULL)
+ free (ss);
+ if (sv != NULL)
+ free (sv);
+
+ return true;
+
+ error_return:
+ if (epdr != NULL)
+ free (epdr);
+ if (rpdr != NULL)
+ free (rpdr);
+ if (esym != NULL)
+ free (esym);
+ if (ss != NULL)
+ free (ss);
+ if (sv != NULL)
+ free (sv);
+ return false;
+}
+
+/* A comparison routine used to sort .gptab entries. */
+
+static int
+gptab_compare (p1, p2)
+ const PTR p1;
+ const PTR p2;
+{
+ const Elf32_gptab *a1 = (const Elf32_gptab *) p1;
+ const Elf32_gptab *a2 = (const Elf32_gptab *) p2;
+
+ return a1->gt_entry.gt_g_value - a2->gt_entry.gt_g_value;
+}
+
+/* We need to use a special link routine to handle the .reginfo and
+ the .mdebug sections. We need to merge all instances of these
+ sections together, not write them all out sequentially. */
+
+static boolean
+mips_elf_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection **secpp;
+ asection *o;
+ struct bfd_link_order *p;
+ asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
+ asection *rtproc_sec;
+ Elf32_RegInfo reginfo;
+ struct ecoff_debug_info debug;
+ const struct ecoff_debug_swap *swap
+ = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+ HDRR *symhdr = &debug.symbolic_header;
+ PTR mdebug_handle = NULL;
+
+ /* Drop the .options section, since it has special semantics which I
+ haven't bothered to figure out. */
+ for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
+ {
+ if (strcmp ((*secpp)->name, ".options") == 0)
+ {
+ for (p = (*secpp)->link_order_head; p != NULL; p = p->next)
+ if (p->type == bfd_indirect_link_order)
+ p->u.indirect.section->flags &=~ SEC_HAS_CONTENTS;
+ (*secpp)->link_order_head = NULL;
+ *secpp = (*secpp)->next;
+ --abfd->section_count;
+ break;
+ }
+ }
+
+ /* Get a value for the GP register. */
+ if (elf_gp (abfd) == 0)
+ {
+ struct bfd_link_hash_entry *h;
+
+ h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_defined)
+ elf_gp (abfd) = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+ else if (info->relocateable)
+ {
+ bfd_vma lo;
+
+ /* Make up a value. */
+ lo = (bfd_vma) -1;
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ if (o->vma < lo
+ && (strcmp (o->name, ".sbss") == 0
+ || strcmp (o->name, ".sdata") == 0
+ || strcmp (o->name, ".lit4") == 0
+ || strcmp (o->name, ".lit8") == 0))
+ lo = o->vma;
+ }
+ elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (abfd);
+ }
+ else
+ {
+ /* If the relocate_section function needs to do a reloc
+ involving the GP value, it should make a reloc_dangerous
+ callback to warn that GP is not defined. */
+ }
+ }
+
+ /* Go through the sections and collect the .reginfo and .mdebug
+ information. */
+ reginfo_sec = NULL;
+ mdebug_sec = NULL;
+ gptab_data_sec = NULL;
+ gptab_bss_sec = NULL;
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ if (strcmp (o->name, ".reginfo") == 0)
+ {
+ memset (&reginfo, 0, sizeof reginfo);
+
+ /* We have found the .reginfo section in the output file.
+ Look through all the link_orders comprising it and merge
+ the information together. */
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ Elf32_External_RegInfo ext;
+ Elf32_RegInfo sub;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ /* The linker emulation code has probably clobbered the
+ size to be zero bytes. */
+ if (input_section->_raw_size == 0)
+ input_section->_raw_size = sizeof (Elf32_External_RegInfo);
+
+ if (! bfd_get_section_contents (input_bfd, input_section,
+ (PTR) &ext,
+ (file_ptr) 0,
+ sizeof ext))
+ return false;
+
+ bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);
+
+ reginfo.ri_gprmask |= sub.ri_gprmask;
+ reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
+ reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
+ reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
+ reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
+
+ /* ri_gp_value is set by the function
+ mips_elf32_section_processing when the section is
+ finally written out. */
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ /* Size has been set in mips_elf_always_size_sections */
+ BFD_ASSERT(o->_raw_size == sizeof (Elf32_External_RegInfo));
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+
+ reginfo_sec = o;
+ }
+
+ if (strcmp (o->name, ".mdebug") == 0)
+ {
+ struct extsym_info einfo;
+
+ /* We have found the .mdebug section in the output file.
+ Look through all the link_orders comprising it and merge
+ the information together. */
+ symhdr->magic = swap->sym_magic;
+ /* FIXME: What should the version stamp be? */
+ symhdr->vstamp = 0;
+ symhdr->ilineMax = 0;
+ symhdr->cbLine = 0;
+ symhdr->idnMax = 0;
+ symhdr->ipdMax = 0;
+ symhdr->isymMax = 0;
+ symhdr->ioptMax = 0;
+ symhdr->iauxMax = 0;
+ symhdr->issMax = 0;
+ symhdr->issExtMax = 0;
+ symhdr->ifdMax = 0;
+ symhdr->crfd = 0;
+ symhdr->iextMax = 0;
+
+ /* We accumulate the debugging information itself in the
+ debug_info structure. */
+ debug.line = NULL;
+ debug.external_dnr = NULL;
+ debug.external_pdr = NULL;
+ debug.external_sym = NULL;
+ debug.external_opt = NULL;
+ debug.external_aux = NULL;
+ debug.ss = NULL;
+ debug.ssext = debug.ssext_end = NULL;
+ debug.external_fdr = NULL;
+ debug.external_rfd = NULL;
+ debug.external_ext = debug.external_ext_end = NULL;
+
+ mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
+ if (mdebug_handle == (PTR) NULL)
+ return false;
+
+ if (SGI_COMPAT (abfd))
+ {
+ asection *s;
+ EXTR esym;
+ bfd_vma last;
+ unsigned int i;
+ static const char * const name[] =
+ { ".text", ".init", ".fini", ".data",
+ ".rodata", ".sdata", ".sbss", ".bss" };
+ static const int sc[] = { scText, scInit, scFini, scData,
+ scRData, scSData, scSBss, scBss };
+
+ esym.jmptbl = 0;
+ esym.cobol_main = 0;
+ esym.weakext = 0;
+ esym.reserved = 0;
+ esym.ifd = ifdNil;
+ esym.asym.iss = issNil;
+ esym.asym.st = stLocal;
+ esym.asym.reserved = 0;
+ esym.asym.index = indexNil;
+ last = 0;
+ for (i = 0; i < 8; i++)
+ {
+ esym.asym.sc = sc[i];
+ s = bfd_get_section_by_name (abfd, name[i]);
+ if (s != NULL)
+ {
+ esym.asym.value = s->vma;
+ last = s->vma + s->_raw_size;
+ }
+ else
+ esym.asym.value = last;
+
+ if (! bfd_ecoff_debug_one_external (abfd, &debug, swap,
+ name[i], &esym))
+ return false;
+ }
+ }
+
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ const struct ecoff_debug_swap *input_swap;
+ struct ecoff_debug_info input_debug;
+ char *eraw_src;
+ char *eraw_end;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
+ || (get_elf_backend_data (input_bfd)
+ ->elf_backend_ecoff_debug_swap) == NULL)
+ {
+ /* I don't know what a non MIPS ELF bfd would be
+ doing with a .mdebug section, but I don't really
+ want to deal with it. */
+ continue;
+ }
+
+ input_swap = (get_elf_backend_data (input_bfd)
+ ->elf_backend_ecoff_debug_swap);
+
+ BFD_ASSERT (p->size == input_section->_raw_size);
+
+ /* The ECOFF linking code expects that we have already
+ read in the debugging information and set up an
+ ecoff_debug_info structure, so we do that now. */
+ if (! _bfd_mips_elf_read_ecoff_info (input_bfd, input_section,
+ &input_debug))
+ return false;
+
+ if (! (bfd_ecoff_debug_accumulate
+ (mdebug_handle, abfd, &debug, swap, input_bfd,
+ &input_debug, input_swap, info)))
+ return false;
+
+ /* Loop through the external symbols. For each one with
+ interesting information, try to find the symbol in
+ the linker global hash table and save the information
+ for the output external symbols. */
+ eraw_src = input_debug.external_ext;
+ eraw_end = (eraw_src
+ + (input_debug.symbolic_header.iextMax
+ * input_swap->external_ext_size));
+ for (;
+ eraw_src < eraw_end;
+ eraw_src += input_swap->external_ext_size)
+ {
+ EXTR ext;
+ const char *name;
+ struct mips_elf_link_hash_entry *h;
+
+ (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
+ if (ext.asym.sc == scNil
+ || ext.asym.sc == scUndefined
+ || ext.asym.sc == scSUndefined)
+ continue;
+
+ name = input_debug.ssext + ext.asym.iss;
+ h = mips_elf_link_hash_lookup (mips_elf_hash_table (info),
+ name, false, false, true);
+ if (h == NULL || h->esym.ifd != -2)
+ continue;
+
+ if (ext.ifd != -1)
+ {
+ BFD_ASSERT (ext.ifd
+ < input_debug.symbolic_header.ifdMax);
+ ext.ifd = input_debug.ifdmap[ext.ifd];
+ }
+
+ h->esym = ext;
+ }
+
+ /* Free up the information we just read. */
+ free (input_debug.line);
+ free (input_debug.external_dnr);
+ free (input_debug.external_pdr);
+ free (input_debug.external_sym);
+ free (input_debug.external_opt);
+ free (input_debug.external_aux);
+ free (input_debug.ss);
+ free (input_debug.ssext);
+ free (input_debug.external_fdr);
+ free (input_debug.external_rfd);
+ free (input_debug.external_ext);
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ if (SGI_COMPAT (abfd) && info->shared)
+ {
+ /* Create .rtproc section. */
+ rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
+ if (rtproc_sec == NULL)
+ {
+ flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED | SEC_READONLY);
+
+ rtproc_sec = bfd_make_section (abfd, ".rtproc");
+ if (rtproc_sec == NULL
+ || ! bfd_set_section_flags (abfd, rtproc_sec, flags)
+ || ! bfd_set_section_alignment (abfd, rtproc_sec, 4))
+ return false;
+ }
+
+ if (! mips_elf_create_procedure_table (mdebug_handle, abfd,
+ info, rtproc_sec, &debug))
+ return false;
+ }
+
+ /* Build the external symbol information. */
+ einfo.abfd = abfd;
+ einfo.info = info;
+ einfo.debug = &debug;
+ einfo.swap = swap;
+ einfo.failed = false;
+ mips_elf_link_hash_traverse (mips_elf_hash_table (info),
+ mips_elf_output_extsym,
+ (PTR) &einfo);
+ if (einfo.failed)
+ return false;
+
+ /* Set the size of the .mdebug section. */
+ o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+
+ mdebug_sec = o;
+ }
+
+ if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
+ {
+ const char *subname;
+ unsigned int c;
+ Elf32_gptab *tab;
+ Elf32_External_gptab *ext_tab;
+ unsigned int i;
+
+ /* The .gptab.sdata and .gptab.sbss sections hold
+ information describing how the small data area would
+ change depending upon the -G switch. These sections
+ not used in executables files. */
+ if (! info->relocateable)
+ {
+ asection **secpp;
+
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ /* Skip this section later on (I don't think this
+ currently matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+
+ /* Really remove the section. */
+ for (secpp = &abfd->sections;
+ *secpp != o;
+ secpp = &(*secpp)->next)
+ ;
+ *secpp = (*secpp)->next;
+ --abfd->section_count;
+
+ continue;
+ }
+
+ /* There is one gptab for initialized data, and one for
+ uninitialized data. */
+ if (strcmp (o->name, ".gptab.sdata") == 0)
+ gptab_data_sec = o;
+ else if (strcmp (o->name, ".gptab.sbss") == 0)
+ gptab_bss_sec = o;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: illegal section name `%s'"),
+ bfd_get_filename (abfd), o->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+
+ /* The linker script always combines .gptab.data and
+ .gptab.sdata into .gptab.sdata, and likewise for
+ .gptab.bss and .gptab.sbss. It is possible that there is
+ no .sdata or .sbss section in the output file, in which
+ case we must change the name of the output section. */
+ subname = o->name + sizeof ".gptab" - 1;
+ if (bfd_get_section_by_name (abfd, subname) == NULL)
+ {
+ if (o == gptab_data_sec)
+ o->name = ".gptab.data";
+ else
+ o->name = ".gptab.bss";
+ subname = o->name + sizeof ".gptab" - 1;
+ BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
+ }
+
+ /* Set up the first entry. */
+ c = 1;
+ tab = (Elf32_gptab *) bfd_malloc (c * sizeof (Elf32_gptab));
+ if (tab == NULL)
+ return false;
+ tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
+ tab[0].gt_header.gt_unused = 0;
+
+ /* Combine the input sections. */
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ bfd_size_type size;
+ unsigned long last;
+ bfd_size_type gpentry;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ /* Combine the gptab entries for this input section one
+ by one. We know that the input gptab entries are
+ sorted by ascending -G value. */
+ size = bfd_section_size (input_bfd, input_section);
+ last = 0;
+ for (gpentry = sizeof (Elf32_External_gptab);
+ gpentry < size;
+ gpentry += sizeof (Elf32_External_gptab))
+ {
+ Elf32_External_gptab ext_gptab;
+ Elf32_gptab int_gptab;
+ unsigned long val;
+ unsigned long add;
+ boolean exact;
+ unsigned int look;
+
+ if (! (bfd_get_section_contents
+ (input_bfd, input_section, (PTR) &ext_gptab,
+ gpentry, sizeof (Elf32_External_gptab))))
+ {
+ free (tab);
+ return false;
+ }
+
+ bfd_mips_elf32_swap_gptab_in (input_bfd, &ext_gptab,
+ &int_gptab);
+ val = int_gptab.gt_entry.gt_g_value;
+ add = int_gptab.gt_entry.gt_bytes - last;
+
+ exact = false;
+ for (look = 1; look < c; look++)
+ {
+ if (tab[look].gt_entry.gt_g_value >= val)
+ tab[look].gt_entry.gt_bytes += add;
+
+ if (tab[look].gt_entry.gt_g_value == val)
+ exact = true;
+ }
+
+ if (! exact)
+ {
+ Elf32_gptab *new_tab;
+ unsigned int max;
+
+ /* We need a new table entry. */
+ new_tab = ((Elf32_gptab *)
+ bfd_realloc ((PTR) tab,
+ (c + 1) * sizeof (Elf32_gptab)));
+ if (new_tab == NULL)
+ {
+ free (tab);
+ return false;
+ }
+ tab = new_tab;
+ tab[c].gt_entry.gt_g_value = val;
+ tab[c].gt_entry.gt_bytes = add;
+
+ /* Merge in the size for the next smallest -G
+ value, since that will be implied by this new
+ value. */
+ max = 0;
+ for (look = 1; look < c; look++)
+ {
+ if (tab[look].gt_entry.gt_g_value < val
+ && (max == 0
+ || (tab[look].gt_entry.gt_g_value
+ > tab[max].gt_entry.gt_g_value)))
+ max = look;
+ }
+ if (max != 0)
+ tab[c].gt_entry.gt_bytes +=
+ tab[max].gt_entry.gt_bytes;
+
+ ++c;
+ }
+
+ last = int_gptab.gt_entry.gt_bytes;
+ }
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ /* The table must be sorted by -G value. */
+ if (c > 2)
+ qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
+
+ /* Swap out the table. */
+ ext_tab = ((Elf32_External_gptab *)
+ bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
+ if (ext_tab == NULL)
+ {
+ free (tab);
+ return false;
+ }
+
+ for (i = 0; i < c; i++)
+ bfd_mips_elf32_swap_gptab_out (abfd, tab + i, ext_tab + i);
+ free (tab);
+
+ o->_raw_size = c * sizeof (Elf32_External_gptab);
+ o->contents = (bfd_byte *) ext_tab;
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+ }
+ }
+
+ /* Invoke the regular ELF backend linker to do all the work. */
+ if (! bfd_elf32_bfd_final_link (abfd, info))
+ return false;
+
+ /* Now write out the computed sections. */
+
+ if (reginfo_sec != (asection *) NULL)
+ {
+ Elf32_External_RegInfo ext;
+
+ bfd_mips_elf32_swap_reginfo_out (abfd, &reginfo, &ext);
+ if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
+ (file_ptr) 0, sizeof ext))
+ return false;
+ }
+
+ if (mdebug_sec != (asection *) NULL)
+ {
+ BFD_ASSERT (abfd->output_has_begun);
+ if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
+ swap, info,
+ mdebug_sec->filepos))
+ return false;
+
+ bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
+ }
+
+ if (gptab_data_sec != (asection *) NULL)
+ {
+ if (! bfd_set_section_contents (abfd, gptab_data_sec,
+ gptab_data_sec->contents,
+ (file_ptr) 0,
+ gptab_data_sec->_raw_size))
+ return false;
+ }
+
+ if (gptab_bss_sec != (asection *) NULL)
+ {
+ if (! bfd_set_section_contents (abfd, gptab_bss_sec,
+ gptab_bss_sec->contents,
+ (file_ptr) 0,
+ gptab_bss_sec->_raw_size))
+ return false;
+ }
+
+ if (SGI_COMPAT (abfd))
+ {
+ rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
+ if (rtproc_sec != NULL)
+ {
+ if (! bfd_set_section_contents (abfd, rtproc_sec,
+ rtproc_sec->contents,
+ (file_ptr) 0,
+ rtproc_sec->_raw_size))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Handle a MIPS ELF HI16 reloc. */
+
+static void
+mips_elf_relocate_hi16 (input_bfd, relhi, rello, contents, addend)
+ bfd *input_bfd;
+ Elf_Internal_Rela *relhi;
+ Elf_Internal_Rela *rello;
+ bfd_byte *contents;
+ bfd_vma addend;
+{
+ bfd_vma insn;
+ bfd_vma addlo;
+
+ insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
+
+ addlo = bfd_get_32 (input_bfd, contents + rello->r_offset);
+ addlo &= 0xffff;
+
+ addend += ((insn & 0xffff) << 16) + addlo;
+
+ if ((addlo & 0x8000) != 0)
+ addend -= 0x10000;
+ if ((addend & 0x8000) != 0)
+ addend += 0x10000;
+
+ bfd_put_32 (input_bfd,
+ (insn & 0xffff0000) | ((addend >> 16) & 0xffff),
+ contents + relhi->r_offset);
+}
+
+/* Handle a MIPS ELF local GOT16 reloc. */
+
+static boolean
+mips_elf_relocate_got_local (output_bfd, input_bfd, sgot, relhi, rello,
+ contents, addend)
+ bfd *output_bfd;
+ bfd *input_bfd;
+ asection *sgot;
+ Elf_Internal_Rela *relhi;
+ Elf_Internal_Rela *rello;
+ bfd_byte *contents;
+ bfd_vma addend;
+{
+ unsigned int assigned_gotno;
+ unsigned int i;
+ bfd_vma insn;
+ bfd_vma addlo;
+ bfd_vma address;
+ bfd_vma hipage;
+ bfd_byte *got_contents;
+ struct mips_got_info *g;
+
+ insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
+
+ addlo = bfd_get_32 (input_bfd, contents + rello->r_offset);
+ addlo &= 0xffff;
+
+ addend += ((insn & 0xffff) << 16) + addlo;
+
+ if ((addlo & 0x8000) != 0)
+ addend -= 0x10000;
+ if ((addend & 0x8000) != 0)
+ addend += 0x10000;
+
+ /* Get a got entry representing requested hipage. */
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+
+ assigned_gotno = g->assigned_gotno;
+ got_contents = sgot->contents;
+ hipage = addend & 0xffff0000;
+
+ for (i = MIPS_RESERVED_GOTNO; i < assigned_gotno; i++)
+ {
+ address = bfd_get_32 (input_bfd, got_contents + i * 4);
+ if (hipage == (address & 0xffff0000))
+ break;
+ }
+
+ if (i == assigned_gotno)
+ {
+ if (assigned_gotno >= g->local_gotno)
+ {
+ (*_bfd_error_handler)
+ (_("more got entries are needed for hipage relocations"));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ bfd_put_32 (input_bfd, hipage, got_contents + assigned_gotno * 4);
+ ++g->assigned_gotno;
+ }
+
+ i = - ELF_MIPS_GP_OFFSET (output_bfd) + i * 4;
+ bfd_put_32 (input_bfd, (insn & 0xffff0000) | (i & 0xffff),
+ contents + relhi->r_offset);
+
+ return true;
+}
+
+/* Handle MIPS ELF CALL16 reloc and global GOT16 reloc. */
+
+static void
+mips_elf_relocate_global_got (input_bfd, rel, contents, offset)
+ bfd *input_bfd;
+ Elf_Internal_Rela *rel;
+ bfd_byte *contents;
+ bfd_vma offset;
+{
+ bfd_vma insn;
+
+ insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ bfd_put_32 (input_bfd,
+ (insn & 0xffff0000) | (offset & 0xffff),
+ contents + rel->r_offset);
+}
+
+/* Relocate a MIPS ELF section. */
+
+static boolean
+mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ size_t locsymcount;
+ size_t extsymoff;
+ asection *sgot, *sreloc, *scpt;
+ bfd *dynobj;
+ bfd_vma gp;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+ struct mips_got_info *g;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ sgot = NULL;
+ sreloc = NULL;
+ if (dynobj == NULL || ! SGI_COMPAT (output_bfd))
+ scpt = NULL;
+ else
+ scpt = bfd_get_section_by_name (dynobj, ".compact_rel");
+ g = NULL;
+
+ if (elf_bad_symtab (input_bfd))
+ {
+ locsymcount = symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
+ extsymoff = 0;
+ }
+ else
+ {
+ locsymcount = symtab_hdr->sh_info;
+ extsymoff = symtab_hdr->sh_info;
+ }
+
+ gp = _bfd_get_gp_value (output_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ bfd_vma addend;
+ struct elf_link_hash_entry *h;
+ asection *sec;
+ Elf_Internal_Sym *sym;
+ struct mips_elf_link_hash_entry *mh;
+ int other;
+ bfd_reloc_status_type r;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+ if (r_type == R_MIPS_GNU_VTINHERIT
+ || r_type == R_MIPS_GNU_VTENTRY)
+ continue;
+ if ((r_type < 0 || r_type >= (int) R_MIPS_max)
+ && r_type != R_MIPS16_26
+ && r_type != R_MIPS16_GPREL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ if (r_type == R_MIPS16_26)
+ howto = &elf_mips16_jump_howto;
+ else if (r_type == R_MIPS16_GPREL)
+ howto = &elf_mips16_gprel_howto;
+ else
+ howto = elf_mips_howto_table + r_type;
+
+ if (dynobj != NULL
+ && (r_type == R_MIPS_CALL16
+ || r_type == R_MIPS_GOT16
+ || r_type == R_MIPS_CALL_HI16
+ || r_type == R_MIPS_CALL_LO16
+ || r_type == R_MIPS_GOT_HI16
+ || r_type == R_MIPS_GOT_LO16))
+ {
+ /* We need the .got section. */
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+ }
+ }
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ /* Mix in the change in GP address for a GP relative reloc. */
+ if (r_type != R_MIPS_GPREL16
+ && r_type != R_MIPS_LITERAL
+ && r_type != R_MIPS_GPREL32
+ && r_type != R_MIPS16_GPREL)
+ addend = 0;
+ else
+ {
+ if (gp == 0)
+ {
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info,
+ _("GP relative relocation when GP not defined"),
+ input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ /* Only give the error once per link. */
+ gp = 4;
+ _bfd_set_gp_value (output_bfd, gp);
+ }
+
+ if (r_symndx < extsymoff
+ || (elf_bad_symtab (input_bfd)
+ && local_sections[r_symndx] != NULL))
+ {
+ /* This is a relocation against a section. The current
+ addend in the instruction is the difference between
+ INPUT_SECTION->vma and the GP value of INPUT_BFD. We
+ must change this to be the difference between the
+ final definition (which will end up in RELOCATION)
+ and the GP value of OUTPUT_BFD (which is in GP). */
+ addend = elf_gp (input_bfd) - gp;
+ }
+ else if (! info->relocateable)
+ {
+ /* We are doing a final link. The current addend in the
+ instruction is simply the desired offset into the
+ symbol (normally zero). We want the instruction to
+ hold the difference between the final definition of
+ the symbol (which will end up in RELOCATION) and the
+ GP value of OUTPUT_BFD (which is in GP). */
+ addend = - gp;
+ }
+ else
+ {
+ /* We are generating relocateable output, and we aren't
+ going to define this symbol, so we just leave the
+ instruction alone. */
+ addend = 0;
+ }
+ }
+
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx >= locsymcount
+ || (elf_bad_symtab (input_bfd)
+ && local_sections[r_symndx] == NULL))
+ r = bfd_reloc_ok;
+ else
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+ r = bfd_reloc_ok;
+ else
+ {
+ sec = local_sections[r_symndx];
+
+ /* It would be logical to add sym->st_value here,
+ but Irix 5 sometimes generates a garbage symbol
+ value. */
+ addend += sec->output_offset;
+
+ /* If this is HI16 or GOT16 with an associated LO16,
+ adjust the addend accordingly. Otherwise, just
+ relocate. */
+ if (r_type == R_MIPS_64 && bfd_big_endian (input_bfd))
+ r = _bfd_relocate_contents (howto, input_bfd,
+ addend,
+ contents + rel->r_offset + 4);
+ else if (r_type != R_MIPS_HI16 && r_type != R_MIPS_GOT16)
+ r = _bfd_relocate_contents (howto, input_bfd,
+ addend,
+ contents + rel->r_offset);
+ else
+ {
+ Elf_Internal_Rela *lorel;
+
+ /* As a GNU extension, permit an arbitrary
+ number of R_MIPS_HI16 relocs before the
+ R_MIPS_LO16 reloc. This permits gcc to emit
+ the HI and LO relocs itself. */
+ if (r_type == R_MIPS_GOT16)
+ lorel = rel + 1;
+ else
+ {
+ for (lorel = rel + 1;
+ (lorel < relend
+ && (ELF32_R_TYPE (lorel->r_info)
+ == R_MIPS_HI16));
+ lorel++)
+ ;
+ }
+ if (lorel < relend
+ && ELF32_R_TYPE (lorel->r_info) == R_MIPS_LO16)
+ {
+ mips_elf_relocate_hi16 (input_bfd, rel, lorel,
+ contents, addend);
+ r = bfd_reloc_ok;
+ }
+ else
+ r = _bfd_relocate_contents (howto, input_bfd,
+ addend,
+ contents + rel->r_offset);
+ }
+ }
+ }
+ }
+ else
+ {
+ bfd_vma relocation;
+ boolean local;
+ boolean undefined_error;
+
+ /* This is a final link. */
+ undefined_error = false;
+ sym = NULL;
+ if (r_symndx < extsymoff
+ || (elf_bad_symtab (input_bfd)
+ && local_sections[r_symndx] != NULL))
+ {
+ local = true;
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset);
+
+ /* It would be logical to always add sym->st_value here,
+ but Irix 5 sometimes generates a garbage symbol
+ value. */
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+ relocation += sym->st_value;
+
+ /* mips16 text labels should be treated as odd. */
+ if (sym->st_other == STO_MIPS16)
+ ++relocation;
+ }
+ else
+ {
+ long indx;
+
+ local = false;
+ indx = r_symndx - extsymoff;
+ h = elf_sym_hashes (input_bfd)[indx];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (strcmp (h->root.root.string, "_gp_disp") == 0)
+ {
+ if (gp == 0)
+ {
+ if (! ((*info->callbacks->reloc_dangerous)
+ (info,
+ _("_gp_disp used when GP not defined"),
+ input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ /* Only give the error once per link. */
+ gp = 4;
+ _bfd_set_gp_value (output_bfd, gp);
+ relocation = 0;
+ }
+ else
+ {
+ sec = input_section;
+ if (sec->output_section != NULL)
+ relocation = (gp
+ - (rel->r_offset
+ + sec->output_section->vma
+ + sec->output_offset));
+ else
+ relocation = gp - rel->r_offset;
+ if (r_type == R_MIPS_LO16)
+ relocation += 4;
+ }
+ }
+ else if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ if (sec->output_section == NULL)
+ relocation = 0;
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else if (strcmp (h->root.root.string, "_DYNAMIC_LINK") == 0)
+ {
+ /* If this is a dynamic link, we should have created
+ a _DYNAMIC_LINK symbol in
+ mips_elf_create_dynamic_sections. Otherwise, we
+ should define the symbol with a value of 0.
+ FIXME: It should probably get into the symbol
+ table somehow as well. */
+ BFD_ASSERT (! info->shared);
+ BFD_ASSERT (bfd_get_section_by_name (output_bfd,
+ ".dynamic") == NULL);
+ relocation = 0;
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ undefined_error = true;
+ relocation = 0;
+ }
+ }
+
+ mh = (struct mips_elf_link_hash_entry *) h;
+ if (h != NULL)
+ other = h->other;
+ else if (sym != NULL)
+ other = sym->st_other;
+ else
+ other = 0;
+
+ /* If this function has an fn_stub, then it is a mips16
+ function which needs a stub if it is called by a 32 bit
+ function. If this reloc is anything other than a 16 bit
+ call, redirect the reloc to the stub. We don't redirect
+ relocs from other stub functions. */
+ if (r_type != R_MIPS16_26
+ && ((mh != NULL
+ && mh->fn_stub != NULL)
+ || (mh == NULL
+ && elf_tdata (input_bfd)->local_stubs != NULL
+ && elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL))
+ && strncmp (bfd_get_section_name (input_bfd, input_section),
+ FN_STUB, sizeof FN_STUB - 1) != 0
+ && strncmp (bfd_get_section_name (input_bfd, input_section),
+ CALL_STUB, sizeof CALL_STUB - 1) != 0
+ && strncmp (bfd_get_section_name (input_bfd, input_section),
+ CALL_FP_STUB, sizeof CALL_FP_STUB - 1) != 0)
+ {
+ if (mh != NULL)
+ {
+ BFD_ASSERT (mh->need_fn_stub);
+ relocation = (mh->fn_stub->output_section->vma
+ + mh->fn_stub->output_offset);
+ }
+ else
+ {
+ asection *fn_stub;
+
+ fn_stub = elf_tdata (input_bfd)->local_stubs[r_symndx];
+ relocation = (fn_stub->output_section->vma
+ + fn_stub->output_offset);
+ }
+
+ /* RELOCATION now points to 32 bit code. */
+ other = 0;
+ }
+
+ /* If this function has a call_stub, then it is called by a
+ mips16 function; the call needs to go through a stub if
+ this function is a 32 bit function. If this reloc is a
+ 16 bit call, and the symbol is not a 16 bit function,
+ then redirect the reloc to the stub. Note that we don't
+ need to worry about calling the function through a
+ function pointer; such calls are handled by routing
+ through a special mips16 routine. We don't have to check
+ whether this call is from a stub; it can't be, because a
+ stub contains 32 bit code, and hence can not have a 16
+ bit reloc. */
+ if (r_type == R_MIPS16_26
+ && mh != NULL
+ && (mh->call_stub != NULL || mh->call_fp_stub != NULL)
+ && other != STO_MIPS16)
+ {
+ asection *stub;
+
+ /* If both call_stub and call_fp_stub are defined, we
+ can figure out which one to use by seeing which one
+ appears in the input file. */
+ if (mh->call_stub != NULL && mh->call_fp_stub != NULL)
+ {
+ asection *o;
+
+ stub = NULL;
+ for (o = input_bfd->sections; o != NULL; o = o->next)
+ {
+ if (strncmp (bfd_get_section_name (input_bfd, o),
+ CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
+ {
+ stub = mh->call_fp_stub;
+ break;
+ }
+ }
+ if (stub == NULL)
+ stub = mh->call_stub;
+ }
+ else if (mh->call_stub != NULL)
+ stub = mh->call_stub;
+ else
+ stub = mh->call_fp_stub;
+
+ BFD_ASSERT (stub->_raw_size > 0);
+ relocation = stub->output_section->vma + stub->output_offset;
+ }
+
+ if (r_type == R_MIPS_HI16)
+ {
+ Elf_Internal_Rela *lorel;
+
+ /* As a GNU extension, permit an arbitrary number of
+ R_MIPS_HI16 relocs before the R_MIPS_LO16 reloc.
+ This permits gcc to emit the HI and LO relocs itself. */
+ for (lorel = rel + 1;
+ (lorel < relend
+ && ELF32_R_TYPE (lorel->r_info) == R_MIPS_HI16);
+ lorel++)
+ ;
+ if (lorel < relend
+ && ELF32_R_TYPE (lorel->r_info) == R_MIPS_LO16)
+ {
+ mips_elf_relocate_hi16 (input_bfd, rel, lorel,
+ contents, relocation + addend);
+ r = bfd_reloc_ok;
+ }
+ else
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, addend);
+ }
+ else if (r_type == R_MIPS_GOT16 && local)
+ {
+ /* GOT16 must also have an associated LO16 in the local
+ case. In this case, the addend is extracted and the
+ section in which the referenced object is determined.
+ Then the final address of the object is computed and
+ the GOT entry for the hipage (an aligned 64kb chunk)
+ is added to .got section if needed. The offset field
+ of the GOT16-relocated instruction is replaced by the
+ index of this GOT entry for the hipage. */
+ if ((rel + 1) < relend
+ && ELF32_R_TYPE ((rel + 1)->r_info) == R_MIPS_LO16)
+ {
+ if (! mips_elf_relocate_got_local (output_bfd, input_bfd,
+ sgot, rel, rel + 1,
+ contents,
+ relocation + addend))
+ return false;
+ r = bfd_reloc_ok;
+ }
+ else
+ r = bfd_reloc_outofrange;
+ }
+ else if (r_type == R_MIPS_CALL16
+ || r_type == R_MIPS_GOT16
+ || r_type == R_MIPS_CALL_LO16
+ || r_type == R_MIPS_GOT_LO16)
+ {
+ bfd_vma offset;
+
+ /* This symbol must be registered as a global symbol
+ having the corresponding got entry. */
+ BFD_ASSERT (h->got.offset != (bfd_vma) -1);
+
+ offset = (h->dynindx - g->global_gotsym + g->local_gotno) * 4;
+ BFD_ASSERT (g->local_gotno <= offset
+ && offset < sgot->_raw_size);
+ bfd_put_32 (output_bfd, relocation + addend,
+ sgot->contents + offset);
+ offset = (sgot->output_section->vma + sgot->output_offset
+ + offset - gp);
+ mips_elf_relocate_global_got (input_bfd, rel, contents,
+ offset);
+ r = bfd_reloc_ok;
+ }
+ else if (r_type == R_MIPS_CALL_HI16
+ || r_type == R_MIPS_GOT_HI16)
+ {
+ bfd_vma offset;
+
+ /* This must be a global symbol with a got entry. The
+ next reloc must be the corresponding LO16 reloc. */
+ BFD_ASSERT (h != NULL && h->got.offset != (bfd_vma) -1);
+ BFD_ASSERT ((rel + 1) < relend);
+ BFD_ASSERT ((int) ELF32_R_TYPE ((rel + 1)->r_info)
+ == (r_type == R_MIPS_CALL_HI16
+ ? (int) R_MIPS_CALL_LO16
+ : (int) R_MIPS_GOT_LO16));
+
+ offset = (h->dynindx - g->global_gotsym + g->local_gotno) * 4;
+ BFD_ASSERT (g->local_gotno <= offset
+ && offset < sgot->_raw_size);
+ bfd_put_32 (output_bfd, relocation + addend,
+ sgot->contents + offset);
+ offset = (sgot->output_section->vma + sgot->output_offset
+ + offset - gp);
+ mips_elf_relocate_hi16 (input_bfd, rel, rel + 1, contents,
+ offset);
+ r = bfd_reloc_ok;
+ }
+ else if (r_type == R_MIPS_REL32
+ || r_type == R_MIPS_32)
+ {
+ Elf_Internal_Rel outrel;
+ Elf32_crinfo cptrel;
+ bfd_byte *cr;
+
+ if ((info->shared
+ || (elf_hash_table (info)->dynamic_sections_created
+ && h != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
+ == 0)))
+ && (input_section->flags & SEC_ALLOC) != 0)
+ {
+ boolean skip;
+
+ /* When generating a shared object, these
+ relocations are copied into the output file to be
+ resolved at run time. */
+ if (sreloc == NULL)
+ {
+ sreloc = bfd_get_section_by_name (dynobj, ".rel.dyn");
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
+
+ if (skip)
+ memset (&outrel, 0, sizeof outrel);
+ else if (h != NULL
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ outrel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_REL32);
+ sec = input_section;
+ }
+ else
+ {
+ long indx;
+
+ if (h == NULL)
+ sec = local_sections[r_symndx];
+ else
+ {
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || (h->root.type
+ == bfd_link_hash_defweak));
+ sec = h->root.u.def.section;
+ }
+ if (sec != NULL && bfd_is_abs_section (sec))
+ indx = 0;
+ else if (sec == NULL || sec->owner == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else
+ {
+ asection *osec;
+
+ osec = sec->output_section;
+ indx = elf_section_data (osec)->dynindx;
+ if (indx == 0)
+ abort ();
+ }
+
+ outrel.r_info = ELF32_R_INFO (indx, R_MIPS_REL32);
+ addend += relocation;
+ }
+
+ if (! skip)
+ bfd_put_32 (output_bfd, addend, contents + rel->r_offset);
+
+ bfd_elf32_swap_reloc_out (output_bfd, &outrel,
+ (((Elf32_External_Rel *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ if (! skip && SGI_COMPAT (output_bfd))
+ {
+ if (scpt == NULL)
+ continue;
+
+ /* Make an entry of compact relocation info. */
+ mips_elf_set_cr_format (cptrel, CRF_MIPS_LONG);
+ cptrel.vaddr = (rel->r_offset
+ + input_section->output_section->vma
+ + input_section->output_offset);
+ if (r_type == R_MIPS_REL32)
+ mips_elf_set_cr_type (cptrel, CRT_MIPS_REL32);
+ else
+ mips_elf_set_cr_type (cptrel, CRT_MIPS_WORD);
+ mips_elf_set_cr_dist2to (cptrel, 0);
+ cptrel.konst = addend;
+
+ cr = (scpt->contents
+ + sizeof (Elf32_External_compact_rel));
+ bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
+ ((Elf32_External_crinfo *) cr
+ + scpt->reloc_count));
+ ++scpt->reloc_count;
+ }
+
+ /* This reloc will be computed at runtime, so
+ there's no need to do anything now. */
+ continue;
+ }
+ else
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, addend);
+ }
+ else if (r_type == R_MIPS_64)
+ {
+ bfd_size_type addr;
+ unsigned long val;
+
+ /* Do a 32 bit relocation, and sign extend to 64 bits. */
+ addr = rel->r_offset;
+ if (bfd_big_endian (input_bfd))
+ addr += 4;
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, addr, relocation,
+ addend);
+ val = bfd_get_32 (input_bfd, contents + addr);
+ if ((val & 0x80000000) != 0)
+ val = 0xffffffff;
+ else
+ val = 0;
+ addr = rel->r_offset;
+ if (bfd_little_endian (input_bfd))
+ addr += 4;
+ bfd_put_32 (input_bfd, val, contents + addr);
+ }
+ else if (r_type == R_MIPS_26 && other == STO_MIPS16)
+ {
+ unsigned long insn;
+
+ /* This is a jump to a mips16 routine from a mips32
+ routine. We need to change jal into jalx. */
+ insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ if (((insn >> 26) & 0x3f) != 0x3
+ && ((insn >> 26) & 0x3f) != 0x1d)
+ {
+ (*_bfd_error_handler)
+ (_("%s: %s+0x%lx: jump to mips16 routine which is not jal"),
+ bfd_get_filename (input_bfd),
+ input_section->name,
+ (unsigned long) rel->r_offset);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ insn = (insn & 0x3ffffff) | (0x1d << 26);
+ bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, addend);
+ }
+ else if (r_type == R_MIPS16_26)
+ {
+ /* It's easiest to do the normal relocation, and then
+ dig out the instruction and swap the first word the
+ way the mips16 expects it. If this is little endian,
+ though, we need to swap the two words first, and then
+ swap them back again later, so that the address looks
+ right. */
+
+ if (bfd_little_endian (input_bfd))
+ {
+ unsigned long insn;
+
+ insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ insn = ((insn >> 16) & 0xffff) | ((insn & 0xffff) << 16);
+ bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
+ }
+
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, addend);
+ if (r == bfd_reloc_ok)
+ {
+ unsigned long insn;
+
+ if (bfd_little_endian (input_bfd))
+ {
+ insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ insn = ((insn >> 16) & 0xffff) | ((insn & 0xffff) << 16);
+ bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
+ }
+
+ insn = bfd_get_16 (input_bfd, contents + rel->r_offset);
+ insn = ((insn & 0xfc00)
+ | ((insn & 0x1f) << 5)
+ | ((insn & 0x3e0) >> 5));
+ /* If this is a jump to a 32 bit routine, then make
+ it jalx. */
+ if (other != STO_MIPS16)
+ insn |= 0x400;
+ bfd_put_16 (input_bfd, insn, contents + rel->r_offset);
+ }
+ }
+ else if (r_type == R_MIPS16_GPREL)
+ {
+ unsigned short extend, insn;
+ bfd_byte buf[4];
+ unsigned long final;
+
+ /* Extract the addend into buf, run the regular reloc,
+ and stuff the resulting value back into the
+ instructions. */
+ if (rel->r_offset > input_section->_raw_size)
+ r = bfd_reloc_outofrange;
+ else
+ {
+ extend = bfd_get_16 (input_bfd, contents + rel->r_offset);
+ insn = bfd_get_16 (input_bfd, contents + rel->r_offset + 2);
+ bfd_put_32 (input_bfd,
+ (((extend & 0x1f) << 11)
+ | (extend & 0x7e0)
+ | (insn & 0x1f)),
+ buf);
+ r = _bfd_final_link_relocate (howto, input_bfd,
+ input_section, buf,
+ (bfd_vma) 0, relocation,
+ addend);
+ final = bfd_get_32 (input_bfd, buf);
+ bfd_put_16 (input_bfd,
+ ((extend & 0xf800)
+ | ((final >> 11) & 0x1f)
+ | (final & 0x7e0)),
+ contents + rel->r_offset);
+ bfd_put_16 (input_bfd,
+ ((insn & 0xffe0)
+ | (final & 0x1f)),
+ contents + rel->r_offset + 2);
+ }
+ }
+ else
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, addend);
+
+ /* The jal instruction can only jump to an address which is
+ divisible by 4, and it can only jump to an address with
+ the same upper 4 bits as the PC. */
+ if (r == bfd_reloc_ok
+ && (r_type == R_MIPS16_26 || r_type == R_MIPS_26))
+ {
+ bfd_vma addr;
+ bfd_vma pc;
+ bfd_vma target;
+
+ pc = ((input_section->output_section->vma
+ + input_section->output_offset
+ + rel->r_offset)
+ & 0xf0000000);
+ target = bfd_get_32 (input_bfd, contents + rel->r_offset)
+ & (howto->dst_mask);
+ addr = (target << 2) + pc;
+ if (other == STO_MIPS16)
+ addr &= ~ (bfd_vma) 1;
+ if ((addr & 3) != 0
+ || ((addr & 0xf0000000)
+ != pc))
+ r = bfd_reloc_overflow;
+ }
+
+ /* Don't bother to report a relocation overflow for a call
+ to a weak undefined symbol with a value of zero. This
+ permits us to use
+ if (!f) f();
+ even if we aren't in range to call address zero. */
+ if (r == bfd_reloc_overflow
+ && (r_type == R_MIPS16_26 || r_type == R_MIPS_26)
+ && relocation + addend == 0
+ && h != NULL
+ && h->root.type == bfd_link_hash_undefweak)
+ r = bfd_reloc_ok;
+
+ /* If we've already issued an error for an undefined symbol,
+ don't issue another useless error. */
+ if (undefined_error
+ && (r == bfd_reloc_undefined || r == bfd_reloc_overflow))
+ r = bfd_reloc_ok;
+
+ if (SGI_COMPAT (abfd)
+ && scpt != NULL
+ && (input_section->flags & SEC_ALLOC) != 0)
+ {
+ Elf32_crinfo cptrel;
+ bfd_byte *cr;
+
+ /* Make an entry of compact relocation info. */
+ mips_elf_set_cr_format (cptrel, CRF_MIPS_LONG);
+ cptrel.vaddr = (rel->r_offset
+ + input_section->output_section->vma
+ + input_section->output_offset);
+
+ switch (r_type)
+ {
+ case R_MIPS_26:
+ mips_elf_set_cr_type (cptrel, CRT_MIPS_JMPAD);
+ /* XXX How should we set dist2to in this case. */
+ mips_elf_set_cr_dist2to (cptrel, 8);
+ cptrel.konst = addend + relocation;
+ cr = scpt->contents + sizeof (Elf32_External_compact_rel);
+ bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
+ ((Elf32_External_crinfo *) cr
+ + scpt->reloc_count));
+ ++scpt->reloc_count;
+ break;
+
+ case R_MIPS_GPREL16:
+ case R_MIPS_LITERAL:
+ case R_MIPS_GPREL32:
+ mips_elf_set_cr_type (cptrel, CRT_MIPS_GPHI_LO);
+ cptrel.konst = gp - cptrel.vaddr;
+ mips_elf_set_cr_dist2to (cptrel, 4);
+ cr = scpt->contents + sizeof (Elf32_External_compact_rel);
+ bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
+ ((Elf32_External_crinfo *) cr
+ + scpt->reloc_count));
+ ++scpt->reloc_count;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* This hook function is called before the linker writes out a global
+ symbol. We mark symbols as small common if appropriate. This is
+ also where we undo the increment of the value for a mips16 symbol. */
+
+/*ARGSIGNORED*/
+static boolean
+mips_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const char *name;
+ Elf_Internal_Sym *sym;
+ asection *input_sec;
+{
+ /* If we see a common symbol, which implies a relocatable link, then
+ if a symbol was small common in an input file, mark it as small
+ common in the output file. */
+ if (sym->st_shndx == SHN_COMMON
+ && strcmp (input_sec->name, ".scommon") == 0)
+ sym->st_shndx = SHN_MIPS_SCOMMON;
+
+ if (sym->st_other == STO_MIPS16
+ && (sym->st_value & 1) != 0)
+ --sym->st_value;
+
+ return true;
+}
+
+/* Functions for the dynamic linker. */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
+
+/* Create dynamic sections when linking against a dynamic object. */
+
+static boolean
+mips_elf_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ struct elf_link_hash_entry *h;
+ flagword flags;
+ register asection *s;
+ const char * const *namep;
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED | SEC_READONLY);
+
+ /* Mips ABI requests the .dynamic section to be read only. */
+ s = bfd_get_section_by_name (abfd, ".dynamic");
+ if (s != NULL)
+ {
+ if (! bfd_set_section_flags (abfd, s, flags))
+ return false;
+ }
+
+ /* We need to create .got section. */
+ if (! mips_elf_create_got_section (abfd, info))
+ return false;
+
+ /* Create .stub section. */
+ if (bfd_get_section_by_name (abfd, ".stub") == NULL)
+ {
+ s = bfd_make_section (abfd, ".stub");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+ }
+
+ if (SGI_COMPAT (abfd)
+ && !info->shared
+ && bfd_get_section_by_name (abfd, ".rld_map") == NULL)
+ {
+ s = bfd_make_section (abfd, ".rld_map");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags & ~SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+ }
+
+ if (SGI_COMPAT (abfd))
+ {
+ for (namep = mips_elf_dynsym_rtproc_names; *namep != NULL; namep++)
+ {
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, *namep, BSF_GLOBAL, bfd_und_section_ptr,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_SECTION;
+
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ /* We need to create a .compact_rel section. */
+ if (! mips_elf_create_compact_rel_section (abfd, info))
+ return false;
+
+ /* Change aligments of some sections. */
+ s = bfd_get_section_by_name (abfd, ".hash");
+ if (s != NULL)
+ bfd_set_section_alignment (abfd, s, 4);
+ s = bfd_get_section_by_name (abfd, ".dynsym");
+ if (s != NULL)
+ bfd_set_section_alignment (abfd, s, 4);
+ s = bfd_get_section_by_name (abfd, ".dynstr");
+ if (s != NULL)
+ bfd_set_section_alignment (abfd, s, 4);
+ s = bfd_get_section_by_name (abfd, ".reginfo");
+ if (s != NULL)
+ bfd_set_section_alignment (abfd, s, 4);
+ s = bfd_get_section_by_name (abfd, ".dynamic");
+ if (s != NULL)
+ bfd_set_section_alignment (abfd, s, 4);
+ }
+
+ if (!info->shared)
+ {
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "_DYNAMIC_LINK", BSF_GLOBAL, bfd_abs_section_ptr,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_SECTION;
+
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+
+ if (! mips_elf_hash_table (info)->use_rld_obj_head)
+ {
+ /* __rld_map is a four byte word located in the .data section
+ and is filled in by the rtld to contain a pointer to
+ the _r_debug structure. Its symbol value will be set in
+ mips_elf_finish_dynamic_symbol. */
+ s = bfd_get_section_by_name (abfd, ".rld_map");
+ BFD_ASSERT (s != NULL);
+
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "__rld_map", BSF_GLOBAL, s,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Create the .compact_rel section. */
+
+static boolean
+mips_elf_create_compact_rel_section (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+
+ if (bfd_get_section_by_name (abfd, ".compact_rel") == NULL)
+ {
+ flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_READONLY);
+
+ s = bfd_make_section (abfd, ".compact_rel");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ s->_raw_size = sizeof (Elf32_External_compact_rel);
+ }
+
+ return true;
+}
+
+/* Create the .got section to hold the global offset table. */
+
+static boolean
+mips_elf_create_got_section (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+ struct elf_link_hash_entry *h;
+ struct mips_got_info *g;
+
+ /* This function may be called more than once. */
+ if (bfd_get_section_by_name (abfd, ".got") != NULL)
+ return true;
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+
+ s = bfd_make_section (abfd, ".got");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 4))
+ return false;
+
+ /* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the
+ linker script because we don't want to define the symbol if we
+ are not creating a global offset table. */
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (info->shared
+ && ! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+
+ /* The first several global offset table entries are reserved. */
+ s->_raw_size = MIPS_RESERVED_GOTNO * 4;
+
+ g = (struct mips_got_info *) bfd_alloc (abfd,
+ sizeof (struct mips_got_info));
+ if (g == NULL)
+ return false;
+ g->global_gotsym = 0;
+ g->local_gotno = MIPS_RESERVED_GOTNO;
+ g->assigned_gotno = MIPS_RESERVED_GOTNO;
+ if (elf_section_data (s) == NULL)
+ {
+ s->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct bfd_elf_section_data));
+ if (elf_section_data (s) == NULL)
+ return false;
+ }
+ elf_section_data (s)->tdata = (PTR) g;
+
+ return true;
+}
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table. */
+
+static boolean
+mips_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ const char *name;
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ struct mips_got_info *g;
+ size_t extsymoff;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sgot;
+ asection *sreloc;
+
+ if (info->relocateable)
+ return true;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
+
+ /* Check for the mips16 stub sections. */
+
+ name = bfd_get_section_name (abfd, sec);
+ if (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0)
+ {
+ unsigned long r_symndx;
+
+ /* Look at the relocation information to figure out which symbol
+ this is for. */
+
+ r_symndx = ELF32_R_SYM (relocs->r_info);
+
+ if (r_symndx < extsymoff
+ || sym_hashes[r_symndx - extsymoff] == NULL)
+ {
+ asection *o;
+
+ /* This stub is for a local symbol. This stub will only be
+ needed if there is some relocation in this BFD, other
+ than a 16 bit function call, which refers to this symbol. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ Elf_Internal_Rela *sec_relocs;
+ const Elf_Internal_Rela *r, *rend;
+
+ /* We can ignore stub sections when looking for relocs. */
+ if ((o->flags & SEC_RELOC) == 0
+ || o->reloc_count == 0
+ || strncmp (bfd_get_section_name (abfd, o), FN_STUB,
+ sizeof FN_STUB - 1) == 0
+ || strncmp (bfd_get_section_name (abfd, o), CALL_STUB,
+ sizeof CALL_STUB - 1) == 0
+ || strncmp (bfd_get_section_name (abfd, o), CALL_FP_STUB,
+ sizeof CALL_FP_STUB - 1) == 0)
+ continue;
+
+ sec_relocs = (_bfd_elf32_link_read_relocs
+ (abfd, o, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL,
+ info->keep_memory));
+ if (sec_relocs == NULL)
+ return false;
+
+ rend = sec_relocs + o->reloc_count;
+ for (r = sec_relocs; r < rend; r++)
+ if (ELF32_R_SYM (r->r_info) == r_symndx
+ && ELF32_R_TYPE (r->r_info) != R_MIPS16_26)
+ break;
+
+ if (! info->keep_memory)
+ free (sec_relocs);
+
+ if (r < rend)
+ break;
+ }
+
+ if (o == NULL)
+ {
+ /* There is no non-call reloc for this stub, so we do
+ not need it. Since this function is called before
+ the linker maps input sections to output sections, we
+ can easily discard it by setting the SEC_EXCLUDE
+ flag. */
+ sec->flags |= SEC_EXCLUDE;
+ return true;
+ }
+
+ /* Record this stub in an array of local symbol stubs for
+ this BFD. */
+ if (elf_tdata (abfd)->local_stubs == NULL)
+ {
+ unsigned long symcount;
+ asection **n;
+
+ if (elf_bad_symtab (abfd))
+ symcount = symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
+ else
+ symcount = symtab_hdr->sh_info;
+ n = (asection **) bfd_zalloc (abfd,
+ symcount * sizeof (asection *));
+ if (n == NULL)
+ return false;
+ elf_tdata (abfd)->local_stubs = n;
+ }
+
+ elf_tdata (abfd)->local_stubs[r_symndx] = sec;
+
+ /* We don't need to set mips16_stubs_seen in this case.
+ That flag is used to see whether we need to look through
+ the global symbol table for stubs. We don't need to set
+ it here, because we just have a local stub. */
+ }
+ else
+ {
+ struct mips_elf_link_hash_entry *h;
+
+ h = ((struct mips_elf_link_hash_entry *)
+ sym_hashes[r_symndx - extsymoff]);
+
+ /* H is the symbol this stub is for. */
+
+ h->fn_stub = sec;
+ mips_elf_hash_table (info)->mips16_stubs_seen = true;
+ }
+ }
+ else if (strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
+ || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
+ {
+ unsigned long r_symndx;
+ struct mips_elf_link_hash_entry *h;
+ asection **loc;
+
+ /* Look at the relocation information to figure out which symbol
+ this is for. */
+
+ r_symndx = ELF32_R_SYM (relocs->r_info);
+
+ if (r_symndx < extsymoff
+ || sym_hashes[r_symndx - extsymoff] == NULL)
+ {
+ /* This stub was actually built for a static symbol defined
+ in the same file. We assume that all static symbols in
+ mips16 code are themselves mips16, so we can simply
+ discard this stub. Since this function is called before
+ the linker maps input sections to output sections, we can
+ easily discard it by setting the SEC_EXCLUDE flag. */
+ sec->flags |= SEC_EXCLUDE;
+ return true;
+ }
+
+ h = ((struct mips_elf_link_hash_entry *)
+ sym_hashes[r_symndx - extsymoff]);
+
+ /* H is the symbol this stub is for. */
+
+ if (strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
+ loc = &h->call_fp_stub;
+ else
+ loc = &h->call_stub;
+
+ /* If we already have an appropriate stub for this function, we
+ don't need another one, so we can discard this one. Since
+ this function is called before the linker maps input sections
+ to output sections, we can easily discard it by setting the
+ SEC_EXCLUDE flag. We can also discard this section if we
+ happen to already know that this is a mips16 function; it is
+ not necessary to check this here, as it is checked later, but
+ it is slightly faster to check now. */
+ if (*loc != NULL || h->root.other == STO_MIPS16)
+ {
+ sec->flags |= SEC_EXCLUDE;
+ return true;
+ }
+
+ *loc = sec;
+ mips_elf_hash_table (info)->mips16_stubs_seen = true;
+ }
+
+ if (dynobj == NULL)
+ {
+ sgot = NULL;
+ g = NULL;
+ }
+ else
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ if (sgot == NULL)
+ g = NULL;
+ else
+ {
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+ }
+ }
+
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (r_symndx < extsymoff)
+ h = NULL;
+ else
+ {
+ h = sym_hashes[r_symndx - extsymoff];
+
+ /* This may be an indirect symbol created because of a version. */
+ if (h != NULL)
+ {
+ while (h->root.type == bfd_link_hash_indirect)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ }
+ }
+
+ /* Some relocs require a global offset table. */
+ if (dynobj == NULL || sgot == NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_MIPS_GOT16:
+ case R_MIPS_CALL16:
+ case R_MIPS_CALL_HI16:
+ case R_MIPS_CALL_LO16:
+ case R_MIPS_GOT_HI16:
+ case R_MIPS_GOT_LO16:
+ if (dynobj == NULL)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! mips_elf_create_got_section (dynobj, info))
+ return false;
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+ break;
+
+ case R_MIPS_32:
+ case R_MIPS_REL32:
+ if (dynobj == NULL
+ && (info->shared || h != NULL)
+ && (sec->flags & SEC_ALLOC) != 0)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_MIPS_CALL16:
+ case R_MIPS_CALL_HI16:
+ case R_MIPS_CALL_LO16:
+ /* This symbol requires a global offset table entry. */
+
+ if (h == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: CALL16 reloc at 0x%lx not against global symbol"),
+ bfd_get_filename (abfd), (unsigned long) rel->r_offset);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+
+ /* Note the index of the first global got symbol in .dynsym. */
+ if (g->global_gotsym == 0
+ || g->global_gotsym > (unsigned long) h->dynindx)
+ g->global_gotsym = h->dynindx;
+
+ /* Make this symbol to have the corresponding got entry. */
+ h->got.offset = 0;
+
+ /* We need a stub, not a plt entry for the undefined
+ function. But we record it as if it needs plt. See
+ elf_adjust_dynamic_symbol in elflink.h. */
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ h->type = STT_FUNC;
+
+ break;
+
+ case R_MIPS_GOT16:
+ case R_MIPS_GOT_HI16:
+ case R_MIPS_GOT_LO16:
+ /* This symbol requires a global offset table entry. */
+
+ if (h != NULL)
+ {
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ /* Note the index of the first global got symbol in
+ .dynsym. */
+ if (g->global_gotsym == 0
+ || g->global_gotsym > (unsigned long) h->dynindx)
+ g->global_gotsym = h->dynindx;
+
+ /* Make this symbol to be the global got symbol. */
+ h->got.offset = 0;
+ }
+
+ break;
+
+ case R_MIPS_32:
+ case R_MIPS_REL32:
+ if ((info->shared || h != NULL)
+ && (sec->flags & SEC_ALLOC) != 0)
+ {
+ if (sreloc == NULL)
+ {
+ const char *name = ".rel.dyn";
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ sreloc = bfd_make_section (dynobj, name);
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, sreloc,
+ 4))
+ return false;
+ }
+ }
+ if (info->shared)
+ {
+ /* When creating a shared object, we must copy these
+ reloc types into the output file as R_MIPS_REL32
+ relocs. We make room for this reloc in the
+ .rel.dyn reloc section */
+ if (sreloc->_raw_size == 0)
+ {
+ /* Add a null element. */
+ sreloc->_raw_size += sizeof (Elf32_External_Rel);
+ ++sreloc->reloc_count;
+ }
+ sreloc->_raw_size += sizeof (Elf32_External_Rel);
+ }
+ else
+ {
+ struct mips_elf_link_hash_entry *hmips;
+
+ /* We only need to copy this reloc if the symbol is
+ defined in a dynamic object. */
+ hmips = (struct mips_elf_link_hash_entry *) h;
+ ++hmips->mips_32_relocs;
+ }
+ }
+
+ if (SGI_COMPAT (abfd))
+ mips_elf_hash_table (info)->compact_rel_size +=
+ sizeof (Elf32_External_crinfo);
+
+ break;
+
+ case R_MIPS_26:
+ case R_MIPS_GPREL16:
+ case R_MIPS_LITERAL:
+ case R_MIPS_GPREL32:
+ if (SGI_COMPAT (abfd))
+ mips_elf_hash_table (info)->compact_rel_size +=
+ sizeof (Elf32_External_crinfo);
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_MIPS_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_MIPS_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+
+ /* If this reloc is not a 16 bit call, and it has a global
+ symbol, then we will need the fn_stub if there is one.
+ References from a stub section do not count. */
+ if (h != NULL
+ && ELF32_R_TYPE (rel->r_info) != R_MIPS16_26
+ && strncmp (bfd_get_section_name (abfd, sec), FN_STUB,
+ sizeof FN_STUB - 1) != 0
+ && strncmp (bfd_get_section_name (abfd, sec), CALL_STUB,
+ sizeof CALL_STUB - 1) != 0
+ && strncmp (bfd_get_section_name (abfd, sec), CALL_FP_STUB,
+ sizeof CALL_FP_STUB - 1) != 0)
+ {
+ struct mips_elf_link_hash_entry *mh;
+
+ mh = (struct mips_elf_link_hash_entry *) h;
+ mh->need_fn_stub = true;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+mips_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ /* ??? Do mips16 stub sections need to be handled special? */
+
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_MIPS_GNU_VTINHERIT:
+ case R_MIPS_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+mips_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+#if 0
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel, *relend;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; rel++)
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_MIPS_GOT16:
+ case R_MIPS_CALL16:
+ case R_MIPS_CALL_HI16:
+ case R_MIPS_CALL_LO16:
+ case R_MIPS_GOT_HI16:
+ case R_MIPS_GOT_LO16:
+ /* ??? It would seem that the existing MIPS code does no sort
+ of reference counting or whatnot on its GOT and PLT entries,
+ so it is not possible to garbage collect them at this time. */
+ break;
+
+ default:
+ break;
+ }
+#endif
+
+ return true;
+}
+
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+mips_elf_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj;
+ struct mips_elf_link_hash_entry *hmips;
+ asection *s;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+ /* If this symbol is defined in a dynamic object, we need to copy
+ any R_MIPS_32 or R_MIPS_REL32 relocs against it into the output
+ file. */
+ hmips = (struct mips_elf_link_hash_entry *) h;
+ if (! info->relocateable
+ && hmips->mips_32_relocs != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ s = bfd_get_section_by_name (dynobj, ".rel.dyn");
+ BFD_ASSERT (s != NULL);
+
+ if (s->_raw_size == 0)
+ {
+ /* Make room for a null element. */
+ s->_raw_size += sizeof (Elf32_External_Rel);
+ ++s->reloc_count;
+ }
+ s->_raw_size += hmips->mips_32_relocs * sizeof (Elf32_External_Rel);
+ }
+
+ /* For a function, create a stub, if needed. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (! elf_hash_table (info)->dynamic_sections_created)
+ return true;
+
+ /* If this symbol is not defined in a regular file, then set
+ the symbol to the stub location. This is required to make
+ function pointers compare as equal between the normal
+ executable and the shared library. */
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* We need .stub section. */
+ s = bfd_get_section_by_name (dynobj, ".stub");
+ BFD_ASSERT (s != NULL);
+
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* XXX Write this stub address somewhere. */
+ h->plt.offset = s->_raw_size;
+
+ /* Make room for this stub code. */
+ s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
+
+ /* The last half word of the stub will be filled with the index
+ of this symbol in .dynsym section. */
+ return true;
+ }
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ return true;
+}
+
+/* This function is called after all the input files have been read,
+ and the input sections have been assigned to output sections. We
+ check for any mips16 stub sections that we can discard. */
+
+static boolean mips_elf_check_mips16_stubs
+ PARAMS ((struct mips_elf_link_hash_entry *, PTR));
+
+static boolean
+mips_elf_always_size_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ asection *ri;
+
+ /* The .reginfo section has a fixed size. */
+ ri = bfd_get_section_by_name (output_bfd, ".reginfo");
+ if (ri != NULL)
+ bfd_set_section_size (output_bfd, ri, sizeof (Elf32_External_RegInfo));
+
+ if (info->relocateable
+ || ! mips_elf_hash_table (info)->mips16_stubs_seen)
+ return true;
+
+ mips_elf_link_hash_traverse (mips_elf_hash_table (info),
+ mips_elf_check_mips16_stubs,
+ (PTR) NULL);
+
+ return true;
+}
+
+/* Check the mips16 stubs for a particular symbol, and see if we can
+ discard them. */
+
+/*ARGSUSED*/
+static boolean
+mips_elf_check_mips16_stubs (h, data)
+ struct mips_elf_link_hash_entry *h;
+ PTR data;
+{
+ if (h->fn_stub != NULL
+ && ! h->need_fn_stub)
+ {
+ /* We don't need the fn_stub; the only references to this symbol
+ are 16 bit calls. Clobber the size to 0 to prevent it from
+ being included in the link. */
+ h->fn_stub->_raw_size = 0;
+ h->fn_stub->_cooked_size = 0;
+ h->fn_stub->flags &= ~ SEC_RELOC;
+ h->fn_stub->reloc_count = 0;
+ h->fn_stub->flags |= SEC_EXCLUDE;
+ }
+
+ if (h->call_stub != NULL
+ && h->root.other == STO_MIPS16)
+ {
+ /* We don't need the call_stub; this is a 16 bit function, so
+ calls from other 16 bit functions are OK. Clobber the size
+ to 0 to prevent it from being included in the link. */
+ h->call_stub->_raw_size = 0;
+ h->call_stub->_cooked_size = 0;
+ h->call_stub->flags &= ~ SEC_RELOC;
+ h->call_stub->reloc_count = 0;
+ h->call_stub->flags |= SEC_EXCLUDE;
+ }
+
+ if (h->call_fp_stub != NULL
+ && h->root.other == STO_MIPS16)
+ {
+ /* We don't need the call_stub; this is a 16 bit function, so
+ calls from other 16 bit functions are OK. Clobber the size
+ to 0 to prevent it from being included in the link. */
+ h->call_fp_stub->_raw_size = 0;
+ h->call_fp_stub->_cooked_size = 0;
+ h->call_fp_stub->flags &= ~ SEC_RELOC;
+ h->call_fp_stub->reloc_count = 0;
+ h->call_fp_stub->flags |= SEC_EXCLUDE;
+ }
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+mips_elf_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean reltext;
+ asection *sgot;
+ struct mips_got_info *g;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+
+ /* Recompute the size of .got for local entires (reserved and
+ hipages) if needed. To estimate it, get the upper bound of total
+ size of loadable sections. */
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+
+ if (sgot != NULL)
+ {
+ bfd_size_type loadable_size = 0;
+ bfd_size_type local_gotno;
+ struct _bfd *sub;
+
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+
+ for (sub = info->input_bfds; sub; sub = sub->link_next)
+ for (s = sub->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_ALLOC) == 0)
+ continue;
+ loadable_size += (s->_raw_size + 0xf) & ~0xf;
+ }
+
+ loadable_size += MIPS_FUNCTION_STUB_SIZE;
+
+ /* Assume there are two loadable segments consisting of
+ contiguous sections. Is 5 enough? */
+ local_gotno = (loadable_size >> 16) + 5 + MIPS_RESERVED_GOTNO;
+ g->local_gotno = local_gotno;
+ sgot->_raw_size += local_gotno * 4;
+ }
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ reltext = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ strip = false;
+
+ if (strncmp (name, ".rel", 4) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* We only strip the section if the output section name
+ has the same name. Otherwise, there might be several
+ input sections for this output section. FIXME: This
+ code is probably not needed these days anyhow, since
+ the linker now does not create empty output sections. */
+ if (s->output_section != NULL
+ && strcmp (name,
+ bfd_get_section_name (s->output_section->owner,
+ s->output_section)) == 0)
+ strip = true;
+ }
+ else
+ {
+ const char *outname;
+ asection *target;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL entry.
+ If the relocation section is .rel.dyn, we always
+ assert a DT_TEXTREL entry rather than testing whether
+ there exists a relocation to a read only section or
+ not. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 4);
+ if ((target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ || strcmp (outname, ".rel.dyn") == 0)
+ reltext = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ if (strcmp (name, ".rel.dyn") != 0)
+ s->reloc_count = 0;
+ }
+ }
+ else if (strncmp (name, ".got", 4) == 0)
+ {
+ int i;
+
+ BFD_ASSERT (elf_section_data (s) != NULL);
+ g = (struct mips_got_info *) elf_section_data (s)->tdata;
+ BFD_ASSERT (g != NULL);
+
+ /* Fix the size of .got section for the correspondence of
+ global symbols and got entries. This adds some useless
+ got entries. Is this required by ABI really? */
+ i = elf_hash_table (info)->dynsymcount - g->global_gotsym;
+ s->_raw_size += i * 4;
+ }
+ else if (strncmp (name, ".stub", 5) == 0)
+ {
+ /* Irix rld assumes that the function stub isn't at the end
+ of .text section. So put a dummy. XXX */
+ s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
+ }
+ else if (! info->shared
+ && ! mips_elf_hash_table (info)->use_rld_obj_head
+ && strncmp (name, ".rld_map", 8) == 0)
+ {
+ /* We add a room for __rld_map. It will be filled in by the
+ rtld to contain a pointer to the _r_debug structure. */
+ s->_raw_size += 4;
+ }
+ else if (SGI_COMPAT (output_bfd)
+ && strncmp (name, ".compact_rel", 12) == 0)
+ s->_raw_size += mips_elf_hash_table (info)->compact_rel_size;
+ else if (strncmp (name, ".init", 5) != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ _bfd_strip_section_from_output (s);
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ memset (s->contents, 0, s->_raw_size);
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf_mips_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (! info->shared)
+ {
+ if (SGI_COMPAT (output_bfd))
+ {
+ /* SGI object has the equivalence of DT_DEBUG in the
+ DT_MIPS_RLD_MAP entry. */
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_RLD_MAP, 0))
+ return false;
+ }
+ else
+ if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (reltext)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
+ return false;
+
+ if (bfd_get_section_by_name (dynobj, ".rel.dyn"))
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_RELENT, 0))
+ return false;
+ }
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_CONFLICTNO, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LIBLISTNO, 0))
+ return false;
+
+ if (bfd_get_section_by_name (dynobj, ".conflict") != NULL)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_CONFLICT, 0))
+ return false;
+
+ s = bfd_get_section_by_name (dynobj, ".liblist");
+ BFD_ASSERT (s != NULL);
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LIBLIST, 0))
+ return false;
+ }
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_RLD_VERSION, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_FLAGS, 0))
+ return false;
+
+#if 0
+ /* Time stamps in executable files are a bad idea. */
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_TIME_STAMP, 0))
+ return false;
+#endif
+
+#if 0 /* FIXME */
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_ICHECKSUM, 0))
+ return false;
+#endif
+
+#if 0 /* FIXME */
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_IVERSION, 0))
+ return false;
+#endif
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_BASE_ADDRESS, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LOCAL_GOTNO, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_SYMTABNO, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_UNREFEXTNO, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_GOTSYM, 0))
+ return false;
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_HIPAGENO, 0))
+ return false;
+
+#if 0 /* (SGI_COMPAT) */
+ if (! bfd_get_section_by_name (dynobj, ".init"))
+ if (! bfd_elf32_add_dynamic_entry (info, DT_INIT, 0))
+ return false;
+
+ if (! bfd_get_section_by_name (dynobj, ".fini"))
+ if (! bfd_elf32_add_dynamic_entry (info, DT_FINI, 0))
+ return false;
+#endif
+ }
+
+ /* If we use dynamic linking, we generate a section symbol for each
+ output section. These are local symbols, which means that they
+ must come first in the dynamic symbol table.
+ That means we must increment the dynamic symbol index of every
+ other dynamic symbol. */
+ {
+ unsigned int c, i;
+ struct mips_got_info *g;
+
+ c = 0;
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+#if 0
+ /* We no longer try to restrict the set of sections which get
+ dynamic symbol table entries, since it fails if we have
+ other random sections which need dynamic relocations. */
+ const char * const *namep;
+ bfd_size_type strindex;
+ struct bfd_strtab_hash *dynstr;
+
+ if (SGI_COMPAT (output_bfd))
+ {
+ c = SIZEOF_MIPS_DYNSYM_SECNAMES - 1;
+ elf_link_hash_traverse (elf_hash_table (info),
+ mips_elf_adjust_dynindx,
+ (PTR) &c);
+ elf_hash_table (info)->dynsymcount += c;
+
+ dynstr = elf_hash_table (info)->dynstr;
+ BFD_ASSERT (dynstr != NULL);
+
+ for (i = 1, namep = mips_elf_dynsym_sec_names;
+ *namep != NULL;
+ i++, namep++)
+ {
+ s = bfd_get_section_by_name (output_bfd, *namep);
+ if (s != NULL)
+ elf_section_data (s)->dynindx = i;
+
+ strindex = _bfd_stringtab_add (dynstr, *namep, true, false);
+ if (strindex == (bfd_size_type) -1)
+ return false;
+
+ mips_elf_hash_table (info)->dynsym_sec_strindex[i] = strindex;
+ }
+ }
+ else
+#endif /* 0 */
+ {
+ c = bfd_count_sections (output_bfd);
+ elf_link_hash_traverse (elf_hash_table (info),
+ mips_elf_adjust_dynindx,
+ (PTR) &c);
+ elf_hash_table (info)->dynsymcount += c;
+
+ for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
+ {
+ elf_section_data (s)->dynindx = i;
+ /* These symbols will have no names, so we don't need to
+ fiddle with dynstr_index. */
+ }
+ }
+ }
+
+ if (sgot != NULL)
+ {
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+
+ /* If there are no global got symbols, fake the last symbol so
+ for safety. */
+ if (g->global_gotsym)
+ g->global_gotsym += c;
+ else
+ g->global_gotsym = elf_hash_table (info)->dynsymcount - 1;
+ }
+ }
+
+ return true;
+}
+
+/* Increment the index of a dynamic symbol by a given amount. Called
+ via elf_link_hash_traverse. */
+
+static boolean
+mips_elf_adjust_dynindx (h, cparg)
+ struct elf_link_hash_entry *h;
+ PTR cparg;
+{
+ unsigned int *cp = (unsigned int *) cparg;
+
+ if (h->dynindx != -1)
+ h->dynindx += *cp;
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj;
+ bfd_vma gval;
+ asection *sgot;
+ struct mips_got_info *g;
+ const char *name;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ gval = sym->st_value;
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection *s;
+ bfd_byte *p;
+ bfd_byte stub[MIPS_FUNCTION_STUB_SIZE];
+
+ /* This symbol has a stub. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ s = bfd_get_section_by_name (dynobj, ".stub");
+ BFD_ASSERT (s != NULL);
+
+ /* Fill the stub. */
+ p = stub;
+ bfd_put_32 (output_bfd, STUB_LW(output_bfd), p);
+ p += 4;
+ bfd_put_32 (output_bfd, STUB_MOVE, p);
+ p += 4;
+
+ /* FIXME: Can h->dynindex be more than 64K? */
+ if (h->dynindx & 0xffff0000)
+ return false;
+
+ bfd_put_32 (output_bfd, STUB_JALR, p);
+ p += 4;
+ bfd_put_32 (output_bfd, STUB_LI16 + h->dynindx, p);
+
+ BFD_ASSERT (h->plt.offset <= s->_raw_size);
+ memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
+
+ /* Mark the symbol as undefined. plt.offset != -1 occurs
+ only for the referenced symbol. */
+ sym->st_shndx = SHN_UNDEF;
+
+ /* The run-time linker uses the st_value field of the symbol
+ to reset the global offset table entry for this external
+ to its stub address when unlinking a shared object. */
+ gval = s->output_section->vma + s->output_offset + h->plt.offset;
+ sym->st_value = gval;
+ }
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+
+ if ((unsigned long) h->dynindx >= g->global_gotsym)
+ {
+ bfd_size_type offset;
+
+ /* This symbol has an entry in the global offset table. Set its
+ value to the corresponding got entry, if needed. */
+ if (h->got.offset == (bfd_vma) -1)
+ {
+ offset = (h->dynindx - g->global_gotsym + g->local_gotno) * 4;
+ BFD_ASSERT (g->local_gotno * 4 <= offset
+ && offset < sgot->_raw_size);
+ bfd_put_32 (output_bfd, gval, sgot->contents + offset);
+ }
+ }
+
+ /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
+ name = h->root.root.string;
+ if (strcmp (name, "_DYNAMIC") == 0
+ || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+ else if (strcmp (name, "_DYNAMIC_LINK") == 0)
+ {
+ sym->st_shndx = SHN_ABS;
+ sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+ sym->st_value = 1;
+ }
+ else if (SGI_COMPAT (output_bfd))
+ {
+ if (strcmp (name, "_gp_disp") == 0)
+ {
+ sym->st_shndx = SHN_ABS;
+ sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+ sym->st_value = elf_gp (output_bfd);
+ }
+ else if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
+ || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
+ {
+ sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+ sym->st_other = STO_PROTECTED;
+ sym->st_value = 0;
+ sym->st_shndx = SHN_MIPS_DATA;
+ }
+ else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
+ {
+ sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+ sym->st_other = STO_PROTECTED;
+ sym->st_value = mips_elf_hash_table (info)->procedure_count;
+ sym->st_shndx = SHN_ABS;
+ }
+ else if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS)
+ {
+ if (h->type == STT_FUNC)
+ sym->st_shndx = SHN_MIPS_TEXT;
+ else if (h->type == STT_OBJECT)
+ sym->st_shndx = SHN_MIPS_DATA;
+ }
+ }
+
+ if (SGI_COMPAT (output_bfd)
+ && ! info->shared)
+ {
+ if (! mips_elf_hash_table (info)->use_rld_obj_head
+ && strcmp (name, "__rld_map") == 0)
+ {
+ asection *s = bfd_get_section_by_name (dynobj, ".rld_map");
+ BFD_ASSERT (s != NULL);
+ sym->st_value = s->output_section->vma + s->output_offset;
+ bfd_put_32 (output_bfd, (bfd_vma) 0, s->contents);
+ if (mips_elf_hash_table (info)->rld_value == 0)
+ mips_elf_hash_table (info)->rld_value = sym->st_value;
+ }
+ else if (mips_elf_hash_table (info)->use_rld_obj_head
+ && strcmp (name, "__rld_obj_head") == 0)
+ {
+ asection *s = bfd_get_section_by_name (dynobj, ".rld_map");
+ BFD_ASSERT (s != NULL);
+ mips_elf_hash_table (info)->rld_value = sym->st_value;
+ }
+ }
+
+ /* If this is a mips16 symbol, force the value to be even. */
+ if (sym->st_other == STO_MIPS16
+ && (sym->st_value & 1) != 0)
+ --sym->st_value;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+mips_elf_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *sdyn;
+ asection *sgot;
+ struct mips_got_info *g;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ if (sgot == NULL)
+ g = NULL;
+ else
+ {
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+ BFD_ASSERT (g != NULL);
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ BFD_ASSERT (sdyn != NULL);
+ BFD_ASSERT (g != NULL);
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ size_t elemsize;
+ asection *s;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ break;
+
+ case DT_RELENT:
+ s = bfd_get_section_by_name (dynobj, ".rel.dyn");
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_val = sizeof (Elf32_External_Rel);
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_STRSZ:
+ /* Rewrite DT_STRSZ. */
+ dyn.d_un.d_val =
+ _bfd_stringtab_size (elf_hash_table (info)->dynstr);
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_PLTGOT:
+ name = ".got";
+ goto get_vma;
+ case DT_MIPS_CONFLICT:
+ name = ".conflict";
+ goto get_vma;
+ case DT_MIPS_LIBLIST:
+ name = ".liblist";
+ get_vma:
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_RLD_VERSION:
+ dyn.d_un.d_val = 1; /* XXX */
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_FLAGS:
+ dyn.d_un.d_val = RHF_NOTPOT; /* XXX */
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_CONFLICTNO:
+ name = ".conflict";
+ elemsize = sizeof (Elf32_Conflict);
+ goto set_elemno;
+
+ case DT_MIPS_LIBLISTNO:
+ name = ".liblist";
+ elemsize = sizeof (Elf32_Lib);
+ set_elemno:
+ s = bfd_get_section_by_name (output_bfd, name);
+ if (s != NULL)
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size / elemsize;
+ else
+ dyn.d_un.d_val = s->_raw_size / elemsize;
+ }
+ else
+ dyn.d_un.d_val = 0;
+
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_TIME_STAMP:
+ time ((time_t *) &dyn.d_un.d_val);
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_ICHECKSUM:
+ /* XXX FIXME: */
+ break;
+
+ case DT_MIPS_IVERSION:
+ /* XXX FIXME: */
+ break;
+
+ case DT_MIPS_BASE_ADDRESS:
+ s = output_bfd->sections;
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma & ~(0xffff);
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_LOCAL_GOTNO:
+ dyn.d_un.d_val = g->local_gotno;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_SYMTABNO:
+ name = ".dynsym";
+ elemsize = sizeof (Elf32_External_Sym);
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size / elemsize;
+ else
+ dyn.d_un.d_val = s->_raw_size / elemsize;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_UNREFEXTNO:
+#if 0
+ dyn.d_un.d_val = SIZEOF_MIPS_DYNSYM_SECNAMES;
+#else
+ dyn.d_un.d_val = bfd_count_sections (output_bfd);
+#endif
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_GOTSYM:
+ dyn.d_un.d_val = g->global_gotsym;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_HIPAGENO:
+ dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ case DT_MIPS_RLD_MAP:
+ dyn.d_un.d_ptr = mips_elf_hash_table (info)->rld_value;
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ break;
+
+ }
+ }
+ }
+
+ /* The first entry of the global offset table will be filled at
+ runtime. The second entry will be used by some runtime loaders.
+ This isn't the case of Irix rld. */
+ if (sgot != NULL && sgot->_raw_size > 0)
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x80000000, sgot->contents + 4);
+ }
+
+ if (sgot != NULL)
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+
+ {
+ asection *sdynsym;
+ asection *s;
+ Elf_Internal_Sym sym;
+ Elf32_compact_rel cpt;
+
+ /* Set up the section symbols for the output sections. SGI sets
+ the STT_NOTYPE attribute for these symbols. Should we do so? */
+
+ sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+ if (sdynsym != NULL)
+ {
+#if 0
+ const char *name;
+ const char * const * namep = mips_elf_dynsym_sec_names;
+ unsigned int i;
+ bfd_vma last;
+ long dindx;
+
+ /* We no longer try to restrict the set of sections which get
+ dynamic symbol table entries, since it fails if we have
+ other random sections which need dynamic relocations. */
+ if (SGI_COMPAT (output_bfd))
+ {
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
+ sym.st_other = 0;
+
+ i = 0;
+ last = 0;
+ dindx = 0;
+ while ((name = *namep++) != NULL)
+ {
+ s = bfd_get_section_by_name (output_bfd, name);
+ if (s != NULL)
+ {
+ sym.st_value = s->vma;
+ dindx = elf_section_data (s)->dynindx;
+ last = s->vma + s->_raw_size;
+ }
+ else
+ {
+ sym.st_value = last;
+ dindx++;
+ }
+
+ sym.st_shndx = (i < MIPS_TEXT_DYNSYM_SECNO
+ ? SHN_MIPS_TEXT
+ : SHN_MIPS_DATA);
+ ++i;
+ sym.st_name =
+ mips_elf_hash_table (info)->dynsym_sec_strindex[dindx];
+
+ bfd_elf32_swap_symbol_out (output_bfd, &sym,
+ (((Elf32_External_Sym *)
+ sdynsym->contents)
+ + dindx));
+ }
+
+ /* Set the sh_info field of the output .dynsym section to
+ the index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
+ SIZEOF_MIPS_DYNSYM_SECNAMES;
+ }
+ else
+#endif /* 0 */
+ {
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_other = 0;
+
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ int indx;
+
+ sym.st_value = s->vma;
+
+ indx = elf_section_data (s)->this_idx;
+ BFD_ASSERT (indx > 0);
+ sym.st_shndx = indx;
+
+ bfd_elf32_swap_symbol_out (output_bfd, &sym,
+ (((Elf32_External_Sym *)
+ sdynsym->contents)
+ + elf_section_data (s)->dynindx));
+ }
+
+ /* Set the sh_info field of the output .dynsym section to
+ the index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
+ bfd_count_sections (output_bfd) + 1;
+ }
+ }
+
+ if (SGI_COMPAT (output_bfd))
+ {
+ /* Write .compact_rel section out. */
+ s = bfd_get_section_by_name (dynobj, ".compact_rel");
+ if (s != NULL)
+ {
+ cpt.id1 = 1;
+ cpt.num = s->reloc_count;
+ cpt.id2 = 2;
+ cpt.offset = (s->output_section->filepos
+ + sizeof (Elf32_External_compact_rel));
+ cpt.reserved0 = 0;
+ cpt.reserved1 = 0;
+ bfd_elf32_swap_compact_rel_out (output_bfd, &cpt,
+ ((Elf32_External_compact_rel *)
+ s->contents));
+
+ /* Clean up a dummy stub function entry in .text. */
+ s = bfd_get_section_by_name (dynobj, ".stub");
+ if (s != NULL)
+ {
+ file_ptr dummy_offset;
+
+ BFD_ASSERT (s->_raw_size >= MIPS_FUNCTION_STUB_SIZE);
+ dummy_offset = s->_raw_size - MIPS_FUNCTION_STUB_SIZE;
+ memset (s->contents + dummy_offset, 0,
+ MIPS_FUNCTION_STUB_SIZE);
+ }
+ }
+ }
+
+ /* Clean up a first relocation in .rel.dyn. */
+ s = bfd_get_section_by_name (dynobj, ".rel.dyn");
+ if (s != NULL && s->_raw_size > 0)
+ memset (s->contents, 0, sizeof (Elf32_External_Rel));
+ }
+
+ return true;
+}
+
+/* This is almost identical to bfd_generic_get_... except that some
+ MIPS relocations need to be handled specially. Sigh. */
+
+static bfd_byte *
+elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data,
+ relocateable, symbols)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ /* Get enough memory to hold the stuff */
+ bfd *input_bfd = link_order->u.indirect.section->owner;
+ asection *input_section = link_order->u.indirect.section;
+
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
+ arelent **reloc_vector = NULL;
+ long reloc_count;
+
+ if (reloc_size < 0)
+ goto error_return;
+
+ reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ if (reloc_vector == NULL && reloc_size != 0)
+ goto error_return;
+
+ /* read in the section */
+ if (!bfd_get_section_contents (input_bfd,
+ input_section,
+ (PTR) data,
+ 0,
+ input_section->_raw_size))
+ goto error_return;
+
+ /* We're not relaxing the section, so just copy the size info */
+ input_section->_cooked_size = input_section->_raw_size;
+ input_section->reloc_done = true;
+
+ reloc_count = bfd_canonicalize_reloc (input_bfd,
+ input_section,
+ reloc_vector,
+ symbols);
+ if (reloc_count < 0)
+ goto error_return;
+
+ if (reloc_count > 0)
+ {
+ arelent **parent;
+ /* for mips */
+ int gp_found;
+ bfd_vma gp = 0x12345678; /* initialize just to shut gcc up */
+
+ {
+ struct bfd_hash_entry *h;
+ struct bfd_link_hash_entry *lh;
+ /* Skip all this stuff if we aren't mixing formats. */
+ if (abfd && input_bfd
+ && abfd->xvec == input_bfd->xvec)
+ lh = 0;
+ else
+ {
+ h = bfd_hash_lookup (&link_info->hash->table, "_gp", false, false);
+ lh = (struct bfd_link_hash_entry *) h;
+ }
+ lookup:
+ if (lh)
+ {
+ switch (lh->type)
+ {
+ case bfd_link_hash_undefined:
+ case bfd_link_hash_undefweak:
+ case bfd_link_hash_common:
+ gp_found = 0;
+ break;
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ gp_found = 1;
+ gp = lh->u.def.value;
+ break;
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+ lh = lh->u.i.link;
+ /* @@FIXME ignoring warning for now */
+ goto lookup;
+ case bfd_link_hash_new:
+ default:
+ abort ();
+ }
+ }
+ else
+ gp_found = 0;
+ }
+ /* end mips */
+ for (parent = reloc_vector; *parent != (arelent *) NULL;
+ parent++)
+ {
+ char *error_message = (char *) NULL;
+ bfd_reloc_status_type r;
+
+ /* Specific to MIPS: Deal with relocation types that require
+ knowing the gp of the output bfd. */
+ asymbol *sym = *(*parent)->sym_ptr_ptr;
+ if (bfd_is_abs_section (sym->section) && abfd)
+ {
+ /* The special_function wouldn't get called anyways. */
+ }
+ else if (!gp_found)
+ {
+ /* The gp isn't there; let the special function code
+ fall over on its own. */
+ }
+ else if ((*parent)->howto->special_function
+ == _bfd_mips_elf_gprel16_reloc)
+ {
+ /* bypass special_function call */
+ r = gprel16_with_gp (input_bfd, sym, *parent, input_section,
+ relocateable, (PTR) data, gp);
+ goto skip_bfd_perform_relocation;
+ }
+ /* end mips specific stuff */
+
+ r = bfd_perform_relocation (input_bfd,
+ *parent,
+ (PTR) data,
+ input_section,
+ relocateable ? abfd : (bfd *) NULL,
+ &error_message);
+ skip_bfd_perform_relocation:
+
+ if (relocateable)
+ {
+ asection *os = input_section->output_section;
+
+ /* A partial link, so keep the relocs */
+ os->orelocation[os->reloc_count] = *parent;
+ os->reloc_count++;
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ case bfd_reloc_undefined:
+ if (!((*link_info->callbacks->undefined_symbol)
+ (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
+ input_bfd, input_section, (*parent)->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_dangerous:
+ BFD_ASSERT (error_message != (char *) NULL);
+ if (!((*link_info->callbacks->reloc_dangerous)
+ (link_info, error_message, input_bfd, input_section,
+ (*parent)->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_overflow:
+ if (!((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
+ (*parent)->howto->name, (*parent)->addend,
+ input_bfd, input_section, (*parent)->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_outofrange:
+ default:
+ abort ();
+ break;
+ }
+
+ }
+ }
+ }
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return data;
+
+error_return:
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return NULL;
+}
+#define bfd_elf32_bfd_get_relocated_section_contents \
+ elf32_mips_get_relocated_section_contents
+
+/* ECOFF swapping routines. These are used when dealing with the
+ .mdebug section, which is in the ECOFF debugging format. */
+static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap =
+{
+ /* Symbol table magic number. */
+ magicSym,
+ /* Alignment of debugging information. E.g., 4. */
+ 4,
+ /* Sizes of external symbolic information. */
+ sizeof (struct hdr_ext),
+ sizeof (struct dnr_ext),
+ sizeof (struct pdr_ext),
+ sizeof (struct sym_ext),
+ sizeof (struct opt_ext),
+ sizeof (struct fdr_ext),
+ sizeof (struct rfd_ext),
+ sizeof (struct ext_ext),
+ /* Functions to swap in external symbolic data. */
+ ecoff_swap_hdr_in,
+ ecoff_swap_dnr_in,
+ ecoff_swap_pdr_in,
+ ecoff_swap_sym_in,
+ ecoff_swap_opt_in,
+ ecoff_swap_fdr_in,
+ ecoff_swap_rfd_in,
+ ecoff_swap_ext_in,
+ _bfd_ecoff_swap_tir_in,
+ _bfd_ecoff_swap_rndx_in,
+ /* Functions to swap out external symbolic data. */
+ ecoff_swap_hdr_out,
+ ecoff_swap_dnr_out,
+ ecoff_swap_pdr_out,
+ ecoff_swap_sym_out,
+ ecoff_swap_opt_out,
+ ecoff_swap_fdr_out,
+ ecoff_swap_rfd_out,
+ ecoff_swap_ext_out,
+ _bfd_ecoff_swap_tir_out,
+ _bfd_ecoff_swap_rndx_out,
+ /* Function to read in symbolic data. */
+ _bfd_mips_elf_read_ecoff_info
+};
+
+#define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec
+#define TARGET_LITTLE_NAME "elf32-littlemips"
+#define TARGET_BIG_SYM bfd_elf32_bigmips_vec
+#define TARGET_BIG_NAME "elf32-bigmips"
+#define ELF_ARCH bfd_arch_mips
+#define ELF_MACHINE_CODE EM_MIPS
+
+/* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
+ a value of 0x1000, and we are compatible. */
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_backend_collect true
+#define elf_backend_type_change_ok true
+#define elf_backend_can_gc_sections true
+#define elf_info_to_howto 0
+#define elf_info_to_howto_rel mips_info_to_howto_rel
+#define elf_backend_sym_is_global mips_elf_sym_is_global
+#define elf_backend_object_p mips_elf32_object_p
+#define elf_backend_section_from_shdr mips_elf32_section_from_shdr
+#define elf_backend_fake_sections _bfd_mips_elf_fake_sections
+#define elf_backend_section_from_bfd_section \
+ _bfd_mips_elf_section_from_bfd_section
+#define elf_backend_section_processing mips_elf32_section_processing
+#define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
+#define elf_backend_additional_program_headers \
+ mips_elf_additional_program_headers
+#define elf_backend_modify_segment_map mips_elf_modify_segment_map
+#define elf_backend_final_write_processing \
+ _bfd_mips_elf_final_write_processing
+#define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
+
+#define bfd_elf32_bfd_is_local_label_name \
+ mips_elf_is_local_label_name
+#define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
+#define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
+#define bfd_elf32_bfd_link_hash_table_create \
+ mips_elf_link_hash_table_create
+#define bfd_elf32_bfd_final_link mips_elf_final_link
+#define bfd_elf32_bfd_copy_private_bfd_data \
+ _bfd_mips_elf_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data \
+ _bfd_mips_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
+#define bfd_elf32_bfd_print_private_bfd_data \
+ _bfd_mips_elf_print_private_bfd_data
+#define elf_backend_add_symbol_hook mips_elf_add_symbol_hook
+#define elf_backend_create_dynamic_sections \
+ mips_elf_create_dynamic_sections
+#define elf_backend_check_relocs mips_elf_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+ mips_elf_adjust_dynamic_symbol
+#define elf_backend_always_size_sections \
+ mips_elf_always_size_sections
+#define elf_backend_size_dynamic_sections \
+ mips_elf_size_dynamic_sections
+#define elf_backend_relocate_section mips_elf_relocate_section
+#define elf_backend_link_output_symbol_hook \
+ mips_elf_link_output_symbol_hook
+#define elf_backend_finish_dynamic_symbol \
+ mips_elf_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ mips_elf_finish_dynamic_sections
+#define elf_backend_gc_mark_hook mips_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook mips_elf_gc_sweep_hook
+
+#define elf_backend_got_header_size (4*MIPS_RESERVED_GOTNO)
+#define elf_backend_plt_header_size 0
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
new file mode 100644
index 00000000000..25bb24ae4f9
--- /dev/null
+++ b/bfd/elf32-ppc.c
@@ -0,0 +1,3848 @@
+/* PowerPC-specific support for 32-bit ELF
+ Copyright 1994, 95, 96, 97, 98, 1999 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file is based on a preliminary PowerPC ELF ABI. The
+ information may not match the final PowerPC ELF ABI. It includes
+ suggestions from the in-progress Embedded PowerPC ABI, and that
+ information may also not match. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/ppc.h"
+
+#define USE_RELA /* we want RELA relocations, not REL */
+
+
+static reloc_howto_type *ppc_elf_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void ppc_elf_info_to_howto
+ PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst));
+static void ppc_elf_howto_init PARAMS ((void));
+static bfd_reloc_status_type ppc_elf_addr16_ha_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword));
+static boolean ppc_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
+
+static int ppc_elf_additional_program_headers PARAMS ((bfd *));
+static boolean ppc_elf_modify_segment_map PARAMS ((bfd *));
+
+static boolean ppc_elf_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+static boolean ppc_elf_section_from_shdr PARAMS ((bfd *,
+ Elf32_Internal_Shdr *,
+ char *));
+static boolean ppc_elf_fake_sections
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+
+static elf_linker_section_t *ppc_elf_create_linker_section
+ PARAMS ((bfd *abfd,
+ struct bfd_link_info *info,
+ enum elf_linker_section_enum));
+
+static boolean ppc_elf_check_relocs PARAMS ((bfd *,
+ struct bfd_link_info *,
+ asection *,
+ const Elf_Internal_Rela *));
+
+static asection * ppc_elf_gc_mark_hook PARAMS ((bfd *abfd,
+ struct bfd_link_info *info,
+ Elf_Internal_Rela *rel,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym));
+
+static boolean ppc_elf_gc_sweep_hook PARAMS ((bfd *abfd,
+ struct bfd_link_info *info,
+ asection *sec,
+ const Elf_Internal_Rela *relocs));
+
+static boolean ppc_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *,
+ struct elf_link_hash_entry *));
+
+static boolean ppc_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR));
+
+static boolean ppc_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
+
+static boolean ppc_elf_relocate_section PARAMS ((bfd *,
+ struct bfd_link_info *info,
+ bfd *,
+ asection *,
+ bfd_byte *,
+ Elf_Internal_Rela *relocs,
+ Elf_Internal_Sym *local_syms,
+ asection **));
+
+static boolean ppc_elf_add_symbol_hook PARAMS ((bfd *,
+ struct bfd_link_info *,
+ const Elf_Internal_Sym *,
+ const char **,
+ flagword *,
+ asection **,
+ bfd_vma *));
+
+static boolean ppc_elf_finish_dynamic_symbol PARAMS ((bfd *,
+ struct bfd_link_info *,
+ struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+
+static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
+
+#define BRANCH_PREDICT_BIT 0x200000 /* branch prediction bit for branch taken relocs */
+#define RA_REGISTER_MASK 0x001f0000 /* mask to set RA in memory instructions */
+#define RA_REGISTER_SHIFT 16 /* value to shift register by to insert RA */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+
+/* The size in bytes of an entry in the procedure linkage table. */
+#define PLT_ENTRY_SIZE 12
+/* The initial size of the plt reserved for the dynamic linker. */
+#define PLT_INITIAL_ENTRY_SIZE 72
+/* The size of the gap between entries in the PLT. */
+#define PLT_SLOT_SIZE 8
+/* The number of single-slot PLT entries (the rest use two slots). */
+#define PLT_NUM_SINGLE_ENTRIES 8192
+
+
+static reloc_howto_type *ppc_elf_howto_table[ (int)R_PPC_max ];
+
+static reloc_howto_type ppc_elf_howto_raw[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_PPC_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A standard 32 bit relocation. */
+ HOWTO (R_PPC_ADDR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An absolute 26 bit branch; the lower two bits must be zero.
+ FIXME: we don't check that, we just clear them. */
+ HOWTO (R_PPC_ADDR24, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR24", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A standard 16 bit relocation. */
+ HOWTO (R_PPC_ADDR16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 16 bit relocation without overflow. */
+ HOWTO (R_PPC_ADDR16_LO, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR16_LO", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high order 16 bits of an address. */
+ HOWTO (R_PPC_ADDR16_HI, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR16_HI", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high order 16 bits of an address, plus 1 if the contents of
+ the low 16 bits, treated as a signed number, is negative. */
+ HOWTO (R_PPC_ADDR16_HA, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ ppc_elf_addr16_ha_reloc, /* special_function */
+ "R_PPC_ADDR16_HA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An absolute 16 bit branch; the lower two bits must be zero.
+ FIXME: we don't check that, we just clear them. */
+ HOWTO (R_PPC_ADDR14, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR14", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xfffc, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An absolute 16 bit branch, for which bit 10 should be set to
+ indicate that the branch is expected to be taken. The lower two
+ bits must be zero. */
+ HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR14_BRTAKEN",/* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xfffc, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* An absolute 16 bit branch, for which bit 10 should be set to
+ indicate that the branch is not expected to be taken. The lower
+ two bits must be zero. */
+ HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_ADDR14_BRNTAKEN",/* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xfffc, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A relative 26 bit branch; the lower two bits must be zero. */
+ HOWTO (R_PPC_REL24, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_REL24", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 16 bit branch; the lower two bits must be zero. */
+ HOWTO (R_PPC_REL14, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_REL14", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xfffc, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 16 bit branch. Bit 10 should be set to indicate that
+ the branch is expected to be taken. The lower two bits must be
+ zero. */
+ HOWTO (R_PPC_REL14_BRTAKEN, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_REL14_BRTAKEN", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xfffc, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A relative 16 bit branch. Bit 10 should be set to indicate that
+ the branch is not expected to be taken. The lower two bits must
+ be zero. */
+ HOWTO (R_PPC_REL14_BRNTAKEN, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_REL14_BRNTAKEN",/* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xfffc, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16, but referring to the GOT table entry for the
+ symbol. */
+ HOWTO (R_PPC_GOT16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_GOT16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for
+ the symbol. */
+ HOWTO (R_PPC_GOT16_LO, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_GOT16_LO", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for
+ the symbol. */
+ HOWTO (R_PPC_GOT16_HI, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_GOT16_HI", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for
+ the symbol. */
+ HOWTO (R_PPC_GOT16_HA, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ ppc_elf_addr16_ha_reloc, /* special_function */
+ "R_PPC_GOT16_HA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_REL24, but referring to the procedure linkage table
+ entry for the symbol. */
+ HOWTO (R_PPC_PLTREL24, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_PLTREL24", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* This is used only by the dynamic linker. The symbol should exist
+ both in the object being run and in some shared library. The
+ dynamic linker copies the data addressed by the symbol from the
+ shared library into the object, because the object being
+ run has to have the data at some particular address. */
+ HOWTO (R_PPC_COPY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_COPY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR32, but used when setting global offset table
+ entries. */
+ HOWTO (R_PPC_GLOB_DAT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_GLOB_DAT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Marks a procedure linkage table entry for a symbol. */
+ HOWTO (R_PPC_JMP_SLOT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_JMP_SLOT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Used only by the dynamic linker. When the object is run, this
+ longword is set to the load address of the object, plus the
+ addend. */
+ HOWTO (R_PPC_RELATIVE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_RELATIVE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_REL24, but uses the value of the symbol within the
+ object rather than the final value. Normally used for
+ _GLOBAL_OFFSET_TABLE_. */
+ HOWTO (R_PPC_LOCAL24PC, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_LOCAL24PC", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR32, but may be unaligned. */
+ HOWTO (R_PPC_UADDR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_UADDR32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16, but may be unaligned. */
+ HOWTO (R_PPC_UADDR16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_UADDR16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32-bit PC relative */
+ HOWTO (R_PPC_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_REL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 32-bit relocation to the symbol's procedure linkage table.
+ FIXME: not supported. */
+ HOWTO (R_PPC_PLT32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_PLT32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32-bit PC relative relocation to the symbol's procedure linkage table.
+ FIXME: not supported. */
+ HOWTO (R_PPC_PLTREL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_PLTREL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for
+ the symbol. */
+ HOWTO (R_PPC_PLT16_LO, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_PLT16_LO", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for
+ the symbol. */
+ HOWTO (R_PPC_PLT16_HI, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_PLT16_HI", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for
+ the symbol. */
+ HOWTO (R_PPC_PLT16_HA, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ ppc_elf_addr16_ha_reloc, /* special_function */
+ "R_PPC_PLT16_HA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A sign-extended 16 bit value relative to _SDA_BASE_, for use with
+ small data items. */
+ HOWTO (R_PPC_SDAREL16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_SDAREL16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32-bit section relative relocation. */
+ HOWTO (R_PPC_SECTOFF, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_SECTOFF", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 16-bit lower half section relative relocation. */
+ HOWTO (R_PPC_SECTOFF_LO, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_SECTOFF_LO", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16-bit upper half section relative relocation. */
+ HOWTO (R_PPC_SECTOFF_HI, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_SECTOFF_HI", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16-bit upper half adjusted section relative relocation. */
+ HOWTO (R_PPC_SECTOFF_HA, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ ppc_elf_addr16_ha_reloc, /* special_function */
+ "R_PPC_SECTOFF_HA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The remaining relocs are from the Embedded ELF ABI, and are not
+ in the SVR4 ELF ABI. */
+
+ /* 32 bit value resulting from the addend minus the symbol */
+ HOWTO (R_PPC_EMB_NADDR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_NADDR32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit value resulting from the addend minus the symbol */
+ HOWTO (R_PPC_EMB_NADDR16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_NADDR16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit value resulting from the addend minus the symbol */
+ HOWTO (R_PPC_EMB_NADDR16_LO, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_ADDR16_LO", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high order 16 bits of the addend minus the symbol */
+ HOWTO (R_PPC_EMB_NADDR16_HI, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_NADDR16_HI", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high order 16 bits of the result of the addend minus the address,
+ plus 1 if the contents of the low 16 bits, treated as a signed number,
+ is negative. */
+ HOWTO (R_PPC_EMB_NADDR16_HA, /* type */
+ 16, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ ppc_elf_addr16_ha_reloc, /* special_function */
+ "R_PPC_EMB_NADDR16_HA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit value resulting from allocating a 4 byte word to hold an
+ address in the .sdata section, and returning the offset from
+ _SDA_BASE_ for that relocation */
+ HOWTO (R_PPC_EMB_SDAI16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_SDAI16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit value resulting from allocating a 4 byte word to hold an
+ address in the .sdata2 section, and returning the offset from
+ _SDA2_BASE_ for that relocation */
+ HOWTO (R_PPC_EMB_SDA2I16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_SDA2I16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with
+ small data items. */
+ HOWTO (R_PPC_EMB_SDA2REL, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_SDA2REL", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Relocate against either _SDA_BASE_ or _SDA2_BASE_, filling in the 16 bit
+ signed offset from the appropriate base, and filling in the register
+ field with the appropriate register (0, 2, or 13). */
+ HOWTO (R_PPC_EMB_SDA21, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_SDA21", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Relocation not handled: R_PPC_EMB_MRKREF */
+ /* Relocation not handled: R_PPC_EMB_RELSEC16 */
+ /* Relocation not handled: R_PPC_EMB_RELST_LO */
+ /* Relocation not handled: R_PPC_EMB_RELST_HI */
+ /* Relocation not handled: R_PPC_EMB_RELST_HA */
+ /* Relocation not handled: R_PPC_EMB_BIT_FLD */
+
+ /* PC relative relocation against either _SDA_BASE_ or _SDA2_BASE_, filling
+ in the 16 bit signed offset from the appropriate base, and filling in the
+ register field with the appropriate register (0, 2, or 13). */
+ HOWTO (R_PPC_EMB_RELSDA, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_EMB_RELSDA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_PPC_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_PPC_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_PPC_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_PPC_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Phony reloc to handle AIX style TOC entries */
+ HOWTO (R_PPC_TOC16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_PPC_TOC16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+};
+
+
+/* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */
+
+static void
+ppc_elf_howto_init ()
+{
+ unsigned int i, type;
+
+ for (i = 0; i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); i++)
+ {
+ type = ppc_elf_howto_raw[i].type;
+ BFD_ASSERT (type < sizeof(ppc_elf_howto_table) / sizeof(ppc_elf_howto_table[0]));
+ ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i];
+ }
+}
+
+
+/* This function handles relaxing for the PPC with option --mpc860c0[=<n>].
+
+ The MPC860, revision C0 or earlier contains a bug in the die.
+ If all of the following conditions are true, the next instruction
+ to be executed *may* be treated as a no-op.
+ 1/ A forward branch is executed.
+ 2/ The branch is predicted as not taken.
+ 3/ The branch is taken.
+ 4/ The branch is located in the last 5 words of a page.
+ (The EOP limit is 5 by default but may be specified as any value from 1-10.)
+
+ Our software solution is to detect these problematic branches in a
+ linker pass and modify them as follows:
+ 1/ Unconditional branches - Since these are always predicted taken,
+ there is no problem and no action is required.
+ 2/ Conditional backward branches - No problem, no action required.
+ 3/ Conditional forward branches - Ensure that the "inverse prediction
+ bit" is set (ensure it is predicted taken).
+ 4/ Conditional register branches - Ensure that the "y bit" is set
+ (ensure it is predicted taken).
+*/
+
+/* Sort sections by address. */
+
+static int
+ppc_elf_sort_rela (arg1, arg2)
+ const void *arg1;
+ const void *arg2;
+{
+ const Elf_Internal_Rela **rela1 = (const Elf_Internal_Rela**) arg1;
+ const Elf_Internal_Rela **rela2 = (const Elf_Internal_Rela**) arg2;
+
+ /* Sort by offset. */
+ return ((*rela1)->r_offset - (*rela2)->r_offset);
+}
+
+static boolean
+ppc_elf_relax_section (abfd, isec, link_info, again)
+ bfd *abfd;
+ asection *isec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+#define PAGESIZE 0x1000
+
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+ Elf_Internal_Rela *internal_relocs = NULL;
+ Elf_Internal_Rela *free_relocs = NULL;
+ Elf_Internal_Rela **rela_comb = NULL;
+ int comb_curr, comb_count;
+
+ /* We never have to do this more than once per input section. */
+ *again = false;
+
+ /* If needed, initialize this section's cooked size. */
+ if (isec->_cooked_size == 0)
+ isec->_cooked_size = isec->_raw_size;
+
+ /* We're only interested in text sections which overlap the
+ troublesome area at the end of a page. */
+ if (link_info->mpc860c0 && (isec->flags & SEC_CODE) && isec->_cooked_size)
+ {
+ bfd_vma dot, end_page, end_section;
+ boolean section_modified;
+
+ /* Get the section contents. */
+ /* Get cached copy if it exists. */
+ if (elf_section_data (isec)->this_hdr.contents != NULL)
+ contents = elf_section_data (isec)->this_hdr.contents;
+ else
+ {
+ /* Go get them off disk. */
+ contents = (bfd_byte *) bfd_malloc (isec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, isec, contents,
+ (file_ptr) 0, isec->_raw_size))
+ goto error_return;
+ }
+
+ comb_curr = 0;
+ comb_count = 0;
+ if (isec->reloc_count)
+ {
+ unsigned n;
+
+ /* Get a copy of the native relocations. */
+ internal_relocs = _bfd_elf32_link_read_relocs (
+ abfd, isec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory);
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ /* Setup a faster access method for the reloc info we need. */
+ rela_comb = (Elf_Internal_Rela**)
+ bfd_malloc (isec->reloc_count*sizeof(Elf_Internal_Rela*));
+ if (rela_comb == NULL)
+ goto error_return;
+ for (n=0; n<isec->reloc_count; ++n)
+ {
+ long r_type;
+
+ r_type = ELF32_R_TYPE (internal_relocs[n].r_info);
+ if (r_type < 0 || r_type >= (int)R_PPC_max)
+ goto error_return;
+
+ /* Prologue constants are sometimes present in the ".text"
+ sections and they can be identified by their associated relocation.
+ We don't want to process those words and some others which
+ can also be identified by their relocations. However, not all
+ conditional branches will have a relocation so we will
+ only ignore words that 1) have a reloc, and 2) the reloc
+ is not applicable to a conditional branch.
+ The array rela_comb is built here for use in the EOP scan loop. */
+ switch (r_type)
+ {
+ case R_PPC_ADDR14_BRNTAKEN: /* absolute, predicted not taken */
+ case R_PPC_REL14: /* relative cond. br. */
+ case R_PPC_REL14_BRNTAKEN: /* rel. cond. br., predicted not taken */
+ /* We should check the instruction. */
+ break;
+ default:
+ /* The word is not a conditional branch - ignore it. */
+ rela_comb[comb_count++] = &internal_relocs[n];
+ break;
+ }
+ }
+ if (comb_count > 1)
+ qsort (rela_comb, (size_t) comb_count, sizeof (int), ppc_elf_sort_rela);
+ }
+
+ /* Enumerate each EOP region that overlaps this section. */
+ end_section = isec->vma + isec->_cooked_size;
+ dot = end_page = (isec->vma | (PAGESIZE - 1)) + 1;
+ dot -= link_info->mpc860c0;
+ section_modified = false;
+ if (dot < isec->vma) /* Increment the start position if this section */
+ dot = isec->vma; /* begins in the middle of its first EOP region. */
+ for (;
+ dot < end_section;
+ dot += PAGESIZE, end_page += PAGESIZE)
+ {
+
+ /* Check each word in this EOP region. */
+ for (; dot < end_page; dot += 4)
+ {
+ bfd_vma isec_offset;
+ unsigned long insn;
+ boolean skip, modified;
+
+ /* Don't process this word if there is a relocation for it and
+ the relocation indicates the word is not a conditional branch. */
+ skip = false;
+ isec_offset = dot - isec->vma;
+ for (; comb_curr<comb_count; ++comb_curr)
+ {
+ bfd_vma r_offset;
+
+ r_offset = rela_comb[comb_curr]->r_offset;
+ if (r_offset >= isec_offset)
+ {
+ if (r_offset == isec_offset) skip = true;
+ break;
+ }
+ }
+ if (skip) continue;
+
+ /* Check the current word for a problematic conditional branch. */
+#define BO0(insn) ((insn) & 0x02000000)
+#define BO2(insn) ((insn) & 0x00800000)
+#define BO4(insn) ((insn) & 0x00200000)
+ insn = (unsigned long) bfd_get_32 (abfd, contents + isec_offset);
+ modified = false;
+ if ((insn & 0xFc000000) == 0x40000000)
+ {
+ /* Instruction is BCx */
+ if ((!BO0(insn) || !BO2(insn)) && !BO4(insn))
+ {
+ bfd_vma target;
+ /* This branch is predicted as "normal".
+ If this is a forward branch, it is problematic. */
+
+ target = insn & 0x0000Fffc; /*extract*/
+ target = (target ^ 0x8000) - 0x8000; /*sign extend*/
+ if ((insn & 0x00000002) == 0)
+ target += dot; /*convert to abs*/
+ if (target > dot)
+ {
+ insn |= 0x00200000; /* set the prediction bit */
+ modified = true;
+ }
+ }
+ }
+ else if ((insn & 0xFc00Fffe) == 0x4c000420)
+ {
+ /* Instruction is BCCTRx */
+ if ((!BO0(insn) || !BO2(insn)) && !BO4(insn))
+ {
+ /* This branch is predicted as not-taken.
+ If this is a forward branch, it is problematic.
+ Since we can't tell statically if it will branch forward,
+ always set the prediction bit. */
+ insn |= 0x00200000; /* set the prediction bit */
+ modified = true;
+ }
+ }
+ else if ((insn & 0xFc00Fffe) == 0x4c000020)
+ {
+ /* Instruction is BCLRx */
+ if ((!BO0(insn) || !BO2(insn)) && !BO4(insn))
+ {
+ /* This branch is predicted as not-taken.
+ If this is a forward branch, it is problematic.
+ Since we can't tell statically if it will branch forward,
+ always set the prediction bit. */
+ insn |= 0x00200000; /* set the prediction bit */
+ modified = true;
+ }
+ }
+#undef BO0
+#undef BO2
+#undef BO4
+ if (modified)
+ {
+ bfd_put_32 (abfd, insn, contents + isec_offset);
+ section_modified = true;
+ }
+ }
+ }
+ if (section_modified)
+ {
+ elf_section_data (isec)->this_hdr.contents = contents;
+ free_contents = NULL;
+ }
+ }
+
+ if (rela_comb != NULL)
+ {
+ free (rela_comb);
+ rela_comb = NULL;
+ }
+
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (isec)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+
+ return true;
+
+error_return:
+ if (rela_comb != NULL)
+ free (rela_comb);
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ return false;
+}
+
+
+static reloc_howto_type *
+ppc_elf_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE;
+
+ if (!ppc_elf_howto_table[R_PPC_ADDR32])
+ /* Initialize howto table if needed */
+ ppc_elf_howto_init ();
+
+ switch ((int)code)
+ {
+ default:
+ return (reloc_howto_type *)NULL;
+
+ case BFD_RELOC_NONE: ppc_reloc = R_PPC_NONE; break;
+ case BFD_RELOC_32: ppc_reloc = R_PPC_ADDR32; break;
+ case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC_ADDR24; break;
+ case BFD_RELOC_16: ppc_reloc = R_PPC_ADDR16; break;
+ case BFD_RELOC_LO16: ppc_reloc = R_PPC_ADDR16_LO; break;
+ case BFD_RELOC_HI16: ppc_reloc = R_PPC_ADDR16_HI; break;
+ case BFD_RELOC_HI16_S: ppc_reloc = R_PPC_ADDR16_HA; break;
+ case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC_ADDR14; break;
+ case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC_ADDR14_BRTAKEN; break;
+ case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC_ADDR14_BRNTAKEN; break;
+ case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC_REL24; break;
+ case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC_REL14; break;
+ case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC_REL14_BRTAKEN; break;
+ case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC_REL14_BRNTAKEN; break;
+ case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC_GOT16; break;
+ case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC_GOT16_LO; break;
+ case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC_GOT16_HI; break;
+ case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC_GOT16_HA; break;
+ case BFD_RELOC_24_PLT_PCREL: ppc_reloc = R_PPC_PLTREL24; break;
+ case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC_COPY; break;
+ case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC_GLOB_DAT; break;
+ case BFD_RELOC_PPC_LOCAL24PC: ppc_reloc = R_PPC_LOCAL24PC; break;
+ case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC_REL32; break;
+ case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC_PLT32; break;
+ case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC_PLTREL32; break;
+ case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC_PLT16_LO; break;
+ case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break;
+ case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break;
+ case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break;
+ case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
+ case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break;
+ case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break;
+ case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break;
+ case BFD_RELOC_CTOR: ppc_reloc = R_PPC_ADDR32; break;
+ case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC_TOC16; break;
+ case BFD_RELOC_PPC_EMB_NADDR32: ppc_reloc = R_PPC_EMB_NADDR32; break;
+ case BFD_RELOC_PPC_EMB_NADDR16: ppc_reloc = R_PPC_EMB_NADDR16; break;
+ case BFD_RELOC_PPC_EMB_NADDR16_LO: ppc_reloc = R_PPC_EMB_NADDR16_LO; break;
+ case BFD_RELOC_PPC_EMB_NADDR16_HI: ppc_reloc = R_PPC_EMB_NADDR16_HI; break;
+ case BFD_RELOC_PPC_EMB_NADDR16_HA: ppc_reloc = R_PPC_EMB_NADDR16_HA; break;
+ case BFD_RELOC_PPC_EMB_SDAI16: ppc_reloc = R_PPC_EMB_SDAI16; break;
+ case BFD_RELOC_PPC_EMB_SDA2I16: ppc_reloc = R_PPC_EMB_SDA2I16; break;
+ case BFD_RELOC_PPC_EMB_SDA2REL: ppc_reloc = R_PPC_EMB_SDA2REL; break;
+ case BFD_RELOC_PPC_EMB_SDA21: ppc_reloc = R_PPC_EMB_SDA21; break;
+ case BFD_RELOC_PPC_EMB_MRKREF: ppc_reloc = R_PPC_EMB_MRKREF; break;
+ case BFD_RELOC_PPC_EMB_RELSEC16: ppc_reloc = R_PPC_EMB_RELSEC16; break;
+ case BFD_RELOC_PPC_EMB_RELST_LO: ppc_reloc = R_PPC_EMB_RELST_LO; break;
+ case BFD_RELOC_PPC_EMB_RELST_HI: ppc_reloc = R_PPC_EMB_RELST_HI; break;
+ case BFD_RELOC_PPC_EMB_RELST_HA: ppc_reloc = R_PPC_EMB_RELST_HA; break;
+ case BFD_RELOC_PPC_EMB_BIT_FLD: ppc_reloc = R_PPC_EMB_BIT_FLD; break;
+ case BFD_RELOC_PPC_EMB_RELSDA: ppc_reloc = R_PPC_EMB_RELSDA; break;
+ case BFD_RELOC_VTABLE_INHERIT: ppc_reloc = R_PPC_GNU_VTINHERIT; break;
+ case BFD_RELOC_VTABLE_ENTRY: ppc_reloc = R_PPC_GNU_VTENTRY; break;
+ }
+
+ return ppc_elf_howto_table[ (int)ppc_reloc ];
+};
+
+/* Set the howto pointer for a PowerPC ELF reloc. */
+
+static void
+ppc_elf_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
+ ppc_elf_howto_init ();
+
+ BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
+ cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
+}
+
+/* Handle the R_PPC_ADDR16_HA reloc. */
+
+static bfd_reloc_status_type
+ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+
+ if (output_bfd != NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ reloc_entry->addend += (relocation & 0x8000) << 1;
+
+ return bfd_reloc_continue;
+}
+
+/* Function to set whether a module needs the -mrelocatable bit set. */
+
+static boolean
+ppc_elf_set_private_flags (abfd, flags)
+ bfd *abfd;
+ flagword flags;
+{
+ BFD_ASSERT (!elf_flags_init (abfd)
+ || elf_elfheader (abfd)->e_flags == flags);
+
+ elf_elfheader (abfd)->e_flags = flags;
+ elf_flags_init (abfd) = true;
+ return true;
+}
+
+/* Copy backend specific data from one object module to another */
+static boolean
+ppc_elf_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ BFD_ASSERT (!elf_flags_init (obfd)
+ || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
+
+ elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+ elf_flags_init (obfd) = true;
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking */
+static boolean
+ppc_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ flagword old_flags;
+ flagword new_flags;
+ boolean error;
+
+ /* Check if we have the same endianess */
+ if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+ && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
+ {
+ const char *msg;
+
+ if (bfd_big_endian (ibfd))
+ msg = _("%s: compiled for a big endian system and target is little endian");
+ else
+ msg = _("%s: compiled for a little endian system and target is big endian");
+
+ (*_bfd_error_handler) (msg, bfd_get_filename (ibfd));
+
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ new_flags = elf_elfheader (ibfd)->e_flags;
+ old_flags = elf_elfheader (obfd)->e_flags;
+ if (!elf_flags_init (obfd)) /* First call, no flags set */
+ {
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = new_flags;
+ }
+
+ else if (new_flags == old_flags) /* Compatible flags are ok */
+ ;
+
+ else /* Incompatible flags */
+ {
+ /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib to be linked
+ with either. */
+ error = false;
+ if ((new_flags & EF_PPC_RELOCATABLE) != 0
+ && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0)
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: compiled with -mrelocatable and linked with modules compiled normally"),
+ bfd_get_filename (ibfd));
+ }
+ else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0
+ && (old_flags & EF_PPC_RELOCATABLE) != 0)
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: compiled normally and linked with modules compiled with -mrelocatable"),
+ bfd_get_filename (ibfd));
+ }
+
+ /* The output is -mrelocatable-lib iff both the input files are. */
+ if (! (new_flags & EF_PPC_RELOCATABLE_LIB))
+ elf_elfheader (obfd)->e_flags &= ~EF_PPC_RELOCATABLE_LIB;
+
+ /* The output is -mrelocatable iff it can't be -mrelocatable-lib,
+ but each input file is either -mrelocatable or -mrelocatable-lib. */
+ if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB)
+ && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))
+ && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)))
+ elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE;
+
+ /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if any module uses it */
+ elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB);
+
+ new_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
+ old_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
+
+ /* Warn about any other mismatches */
+ if (new_flags != old_flags)
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
+ bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
+ }
+
+ if (error)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+/* Handle a PowerPC specific section when reading an object file. This
+ is called when elfcode.h finds a section with an unknown type. */
+
+static boolean
+ppc_elf_section_from_shdr (abfd, hdr, name)
+ bfd *abfd;
+ Elf32_Internal_Shdr *hdr;
+ char *name;
+{
+ asection *newsect;
+ flagword flags;
+
+ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+ return false;
+
+ newsect = hdr->bfd_section;
+ flags = bfd_get_section_flags (abfd, newsect);
+ if (hdr->sh_flags & SHF_EXCLUDE)
+ flags |= SEC_EXCLUDE;
+
+ if (hdr->sh_type == SHT_ORDERED)
+ flags |= SEC_SORT_ENTRIES;
+
+ bfd_set_section_flags (abfd, newsect, flags);
+ return true;
+}
+
+
+/* Set up any other section flags and such that may be necessary. */
+
+static boolean
+ppc_elf_fake_sections (abfd, shdr, asect)
+ bfd *abfd;
+ Elf32_Internal_Shdr *shdr;
+ asection *asect;
+{
+ if ((asect->flags & SEC_EXCLUDE) != 0)
+ shdr->sh_flags |= SHF_EXCLUDE;
+
+ if ((asect->flags & SEC_SORT_ENTRIES) != 0)
+ shdr->sh_type = SHT_ORDERED;
+
+ return true;
+}
+
+
+/* Create a special linker section */
+static elf_linker_section_t *
+ppc_elf_create_linker_section (abfd, info, which)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ enum elf_linker_section_enum which;
+{
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ elf_linker_section_t *lsect;
+
+ /* Record the first bfd section that needs the special section */
+ if (!dynobj)
+ dynobj = elf_hash_table (info)->dynobj = abfd;
+
+ /* If this is the first time, create the section */
+ lsect = elf_linker_section (dynobj, which);
+ if (!lsect)
+ {
+ elf_linker_section_t defaults;
+ static elf_linker_section_t zero_section;
+
+ defaults = zero_section;
+ defaults.which = which;
+ defaults.hole_written_p = false;
+ defaults.alignment = 2;
+
+ /* Both of these sections are (technically) created by the user
+ putting data in them, so they shouldn't be marked
+ SEC_LINKER_CREATED.
+
+ The linker creates them so it has somewhere to attach their
+ respective symbols. In fact, if they were empty it would
+ be OK to leave the symbol set to 0 (or any random number), because
+ the appropriate register should never be used. */
+ defaults.flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+
+ switch (which)
+ {
+ default:
+ (*_bfd_error_handler) (_("%s: Unknown special linker type %d"),
+ bfd_get_filename (abfd),
+ (int)which);
+
+ bfd_set_error (bfd_error_bad_value);
+ return (elf_linker_section_t *)0;
+
+ case LINKER_SECTION_SDATA: /* .sdata/.sbss section */
+ defaults.name = ".sdata";
+ defaults.rel_name = ".rela.sdata";
+ defaults.bss_name = ".sbss";
+ defaults.sym_name = "_SDA_BASE_";
+ defaults.sym_offset = 32768;
+ break;
+
+ case LINKER_SECTION_SDATA2: /* .sdata2/.sbss2 section */
+ defaults.name = ".sdata2";
+ defaults.rel_name = ".rela.sdata2";
+ defaults.bss_name = ".sbss2";
+ defaults.sym_name = "_SDA2_BASE_";
+ defaults.sym_offset = 32768;
+ defaults.flags |= SEC_READONLY;
+ break;
+ }
+
+ lsect = _bfd_elf_create_linker_section (abfd, info, which, &defaults);
+ }
+
+ return lsect;
+}
+
+
+/* If we have a non-zero sized .sbss2 or .PPC.EMB.sbss0 sections, we need to bump up
+ the number of section headers. */
+
+static int
+ppc_elf_additional_program_headers (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ int ret;
+
+ ret = 0;
+
+ s = bfd_get_section_by_name (abfd, ".interp");
+ if (s != NULL)
+ ++ret;
+
+ s = bfd_get_section_by_name (abfd, ".sbss2");
+ if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0)
+ ++ret;
+
+ s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0");
+ if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0)
+ ++ret;
+
+ return ret;
+}
+
+/* Modify the segment map if needed */
+
+static boolean
+ppc_elf_modify_segment_map (abfd)
+ bfd *abfd;
+{
+ return true;
+}
+
+/* We have to create .dynsbss and .rela.sbss here so that they get mapped
+ to output sections (just like _bfd_elf_create_dynamic_sections has
+ to create .dynbss and .rela.bss). */
+
+static boolean
+ppc_elf_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ register asection *s;
+ flagword flags;
+
+ if (!_bfd_elf_create_dynamic_sections(abfd, info))
+ return false;
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+
+ s = bfd_make_section (abfd, ".dynsbss");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
+ return false;
+
+ if (! info->shared)
+ {
+ s = bfd_make_section (abfd, ".rela.sbss");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+ }
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+ppc_elf_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ asection *s;
+ unsigned int power_of_two;
+ bfd_vma plt_offset;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called for %s\n", h->root.root.string);
+#endif
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+
+ /* If this is a function, put it in the procedure linkage table. We
+ will fill in the contents of the procedure linkage table later,
+ when we know the address of the .got section. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || ((!info->shared || info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) != 0)
+ || (info->shared && h->plt.refcount <= 0))
+ {
+ /* A PLT entry is not required/allowed when:
+
+ 1. We are not using ld.so; because then the PLT entry
+ can't be set up, so we can't use one.
+
+ 2. We know for certain that a symbol is defined in
+ this object, because this object is the application,
+ is linked with -Bsymbolic, or because the symbol is local.
+
+ 3. GC has rendered the entry unused.
+ Note, however, that in an executable all references to the
+ symbol go to the PLT, so we can't turn it off in that case.
+ ??? The correct thing to do here is to reference count
+ all uses of the symbol, not just those to the GOT or PLT. */
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ return true;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+ BFD_ASSERT (h->dynindx != -1);
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_INITIAL_ENTRY_SIZE;
+
+ /* The PowerPC PLT is actually composed of two parts, the first part
+ is 2 words (for a load and a jump), and then there is a remaining
+ word available at the end. */
+ plt_offset = (PLT_INITIAL_ENTRY_SIZE
+ + (PLT_SLOT_SIZE
+ * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE)
+ / PLT_ENTRY_SIZE)));
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = plt_offset;
+ }
+
+ h->plt.offset = plt_offset;
+
+ /* Make room for this entry. After the 8192nd entry, room
+ for two entries is allocated. */
+ if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE
+ >= PLT_NUM_SINGLE_ENTRIES)
+ s->_raw_size += 2 * PLT_ENTRY_SIZE;
+ else
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .rela.plt section. */
+ s = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += sizeof (Elf32_External_Rela);
+
+ return true;
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable.
+
+ Of course, if the symbol is sufficiently small, we must instead
+ allocate it in .sbss. FIXME: It would be better to do this if and
+ only if there were actually SDAREL relocs for that symbol. */
+
+ if (h->size <= elf_gp_size (dynobj))
+ s = bfd_get_section_by_name (dynobj, ".dynsbss");
+ else
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ BFD_ASSERT (s != NULL);
+
+ /* We must generate a R_PPC_COPY reloc to tell the dynamic linker to
+ copy the initial value out of the dynamic object and into the
+ runtime process image. We need to remember the offset into the
+ .rela.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ asection *srel;
+
+ if (h->size <= elf_gp_size (dynobj))
+ srel = bfd_get_section_by_name (dynobj, ".rela.sbss");
+ else
+ srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf32_External_Rela);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 4)
+ power_of_two = 4;
+
+ /* Apply the required alignment. */
+ s->_raw_size = BFD_ALIGN (s->_raw_size,
+ (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ {
+ if (! bfd_set_section_alignment (dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+
+/* Increment the index of a dynamic symbol by a given amount. Called
+ via elf_link_hash_traverse. */
+
+static boolean
+ppc_elf_adjust_dynindx (h, cparg)
+ struct elf_link_hash_entry *h;
+ PTR cparg;
+{
+ int *cp = (int *) cparg;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_adjust_dynindx called, h->dynindx = %d, *cp = %d\n", h->dynindx, *cp);
+#endif
+
+ if (h->dynindx != -1)
+ h->dynindx += *cp;
+
+ return true;
+}
+
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+ppc_elf_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean plt;
+ boolean relocs;
+ boolean reltext;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
+#endif
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+ else
+ {
+ /* We may have created entries in the .rela.got, .rela.sdata, and
+ .rela.sdata2 sections. However, if we are not creating the
+ dynamic sections, we will not actually use these entries. Reset
+ the size of .rela.got, et al, which will cause it to get
+ stripped from the output file below. */
+ static char *rela_sections[] = { ".rela.got", ".rela.sdata",
+ ".rela.sdata2", ".rela.sbss",
+ (char *)0 };
+ char **p;
+
+ for (p = rela_sections; *p != (char *)0; p++)
+ {
+ s = bfd_get_section_by_name (dynobj, *p);
+ if (s != NULL)
+ s->_raw_size = 0;
+ }
+ }
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ plt = false;
+ relocs = false;
+ reltext = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ strip = false;
+
+ if (strcmp (name, ".plt") == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
+ strip = true;
+ }
+ else
+ {
+ /* Remember whether there is a PLT. */
+ plt = true;
+ }
+ }
+ else if (strncmp (name, ".rela", 5) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is mostly to handle .rela.bss and
+ .rela.plt. We must create both sections in
+ create_dynamic_sections, because they must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ strip = true;
+ }
+ else
+ {
+ asection *target;
+ const char *outname;
+
+ /* Remember whether there are any relocation sections. */
+ relocs = true;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL entry. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 5);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ reltext = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strcmp (name, ".got") != 0
+ && strcmp (name, ".sdata") != 0
+ && strcmp (name, ".sdata2") != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ _bfd_strip_section_from_output (s);
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in ppc_elf_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (! info->shared)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (plt)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
+ sizeof (Elf32_External_Rela)))
+ return false;
+ }
+
+ if (reltext)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ /* If we are generating a shared library, we generate a section
+ symbol for each output section. These are local symbols, which
+ means that they must come first in the dynamic symbol table.
+ That means we must increment the dynamic symbol index of every
+ other dynamic symbol.
+
+ FIXME: We assume that there will never be relocations to
+ locations in linker-created sections that do not have
+ externally-visible names. Instead, we should work out precisely
+ which sections relocations are targetted at. */
+ if (info->shared)
+ {
+ int c;
+
+ for (c = 0, s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) != 0
+ || (s->flags & SEC_ALLOC) == 0)
+ {
+ elf_section_data (s)->dynindx = -1;
+ continue;
+ }
+
+ /* These symbols will have no names, so we don't need to
+ fiddle with dynstr_index. */
+
+ elf_section_data (s)->dynindx = c + 1;
+
+ c++;
+ }
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ ppc_elf_adjust_dynindx,
+ (PTR) &c);
+ elf_hash_table (info)->dynsymcount += c;
+ }
+
+ return true;
+}
+
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+ppc_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ bfd_signed_vma *local_got_refcounts;
+ elf_linker_section_t *sdata;
+ elf_linker_section_t *sdata2;
+ asection *sreloc;
+ asection *sgot = NULL;
+ asection *srelgot = NULL;
+
+ if (info->relocateable)
+ return true;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_check_relocs called for section %s in %s\n",
+ bfd_get_section_name (abfd, sec),
+ bfd_get_filename (abfd));
+#endif
+
+ /* Create the linker generated sections all the time so that the
+ special symbols are created. */
+
+ if ((sdata = elf_linker_section (abfd, LINKER_SECTION_SDATA)) == NULL)
+ {
+ sdata = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA);
+ if (!sdata)
+ return false;
+ }
+
+
+ if ((sdata2 = elf_linker_section (abfd, LINKER_SECTION_SDATA2)) == NULL)
+ {
+ sdata2 = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA2);
+ if (!sdata2)
+ return false;
+ }
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ /* If a relocation refers to _GLOBAL_OFFSET_TABLE_, create the .got.
+ This shows up in particular in an R_PPC_ADDR32 in the eabi
+ startup code. */
+ if (h && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ {
+ if (sgot == NULL)
+ {
+ if (dynobj == NULL)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+ }
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* GOT16 relocations */
+ case R_PPC_GOT16:
+ case R_PPC_GOT16_LO:
+ case R_PPC_GOT16_HI:
+ case R_PPC_GOT16_HA:
+ /* This symbol requires a global offset table entry. */
+
+ if (sgot == NULL)
+ {
+ if (dynobj == NULL)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (srelgot == NULL
+ && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (h != NULL)
+ {
+ if (h->got.refcount == -1)
+ {
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ if (!bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+
+ /* Allocate space in the .got. */
+ sgot->_raw_size += 4;
+ /* Allocate relocation space. */
+ srelgot->_raw_size += sizeof (Elf32_External_Rela);
+
+ h->got.refcount = 1;
+ }
+ else
+ h->got.refcount++;
+ }
+ else
+ {
+ /* This is a global offset table entry for a local symbol. */
+ if (local_got_refcounts == NULL)
+ {
+ size_t size;
+
+ size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
+ local_got_refcounts = (bfd_signed_vma *)
+ bfd_alloc (abfd, size);
+ if (local_got_refcounts == NULL)
+ return false;
+ elf_local_got_refcounts (abfd) = local_got_refcounts;
+ memset (local_got_refcounts, -1, size);
+ }
+ if (local_got_refcounts[r_symndx] == -1)
+ {
+ sgot->_raw_size += 4;
+
+ /* If we are generating a shared object, we need to
+ output a R_PPC_RELATIVE reloc so that the
+ dynamic linker can adjust this GOT entry. */
+ if (info->shared)
+ srelgot->_raw_size += sizeof (Elf32_External_Rela);
+
+ local_got_refcounts[r_symndx] = 1;
+ }
+ else
+ local_got_refcounts[r_symndx]++;
+ }
+ break;
+
+ /* Indirect .sdata relocation */
+ case R_PPC_EMB_SDAI16:
+ if (info->shared)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: relocation %s cannot be used when making a shared object"),
+ bfd_get_filename (abfd), "R_PPC_EMB_SDAI16"));
+ return false;
+ }
+
+ if (srelgot == NULL && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata, h, rel))
+ return false;
+
+ break;
+
+ /* Indirect .sdata2 relocation */
+ case R_PPC_EMB_SDA2I16:
+ if (info->shared)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: relocation %s cannot be used when making a shared object"),
+ bfd_get_filename (abfd), "R_PPC_EMB_SDA2I16"));
+ return false;
+ }
+
+ if (srelgot == NULL && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata2, h, rel))
+ return false;
+
+ break;
+
+ case R_PPC_SDAREL16:
+ case R_PPC_EMB_SDA2REL:
+ case R_PPC_EMB_SDA21:
+ if (info->shared)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: relocation %s cannot be used when making a shared object"),
+ bfd_get_filename (abfd),
+ ppc_elf_howto_table[(int)ELF32_R_TYPE (rel->r_info)]->name));
+ return false;
+ }
+ break;
+
+ case R_PPC_PLT32:
+ case R_PPC_PLTREL24:
+ case R_PPC_PLT16_LO:
+ case R_PPC_PLT16_HI:
+ case R_PPC_PLT16_HA:
+#ifdef DEBUG
+ fprintf (stderr, "Reloc requires a PLT entry\n");
+#endif
+ /* This symbol requires a procedure linkage table entry. We
+ actually build the entry in adjust_dynamic_symbol,
+ because this might be a case of linking PIC code without
+ linking in any dynamic objects, in which case we don't
+ need to generate a procedure linkage table after all. */
+
+ if (h == NULL)
+ {
+ /* It does not make sense to have a procedure linkage
+ table entry for a local symbol. */
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+ if (h->plt.refcount == -1)
+ {
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ h->plt.refcount = 1;
+ }
+ else
+ h->plt.refcount++;
+ break;
+
+ /* The following relocations don't need to propagate the
+ relocation if linking a shared object since they are
+ section relative. */
+ case R_PPC_SECTOFF:
+ case R_PPC_SECTOFF_LO:
+ case R_PPC_SECTOFF_HI:
+ case R_PPC_SECTOFF_HA:
+ break;
+
+ /* This refers only to functions defined in the shared library */
+ case R_PPC_LOCAL24PC:
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_PPC_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_PPC_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+
+ /* When creating a shared object, we must copy these
+ relocs into the output file. We create a reloc
+ section in dynobj and make room for the reloc. */
+ case R_PPC_REL24:
+ case R_PPC_REL14:
+ case R_PPC_REL14_BRTAKEN:
+ case R_PPC_REL14_BRNTAKEN:
+ case R_PPC_REL32:
+ if (h == NULL
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* fall through */
+
+ default:
+ if (info->shared)
+ {
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_check_relocs need to create relocation for %s\n",
+ (h && h->root.root.string) ? h->root.root.string : "<unknown>");
+#endif
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ }
+
+ sreloc->_raw_size += sizeof (Elf32_External_Rela);
+
+ /* FIXME: We should here do what the m68k and i386
+ backends do: if the reloc is pc-relative, record it
+ in case it turns out that the reloc is unnecessary
+ because the symbol is forced local by versioning or
+ we are linking with -Bdynamic. Fortunately this
+ case is not frequent. */
+ }
+
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+ppc_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_PPC_GNU_VTINHERIT:
+ case R_PPC_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+ppc_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel, *relend;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; rel++)
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_PPC_GOT16:
+ case R_PPC_GOT16_LO:
+ case R_PPC_GOT16_HI:
+ case R_PPC_GOT16_HA:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->got.refcount > 0)
+ h->got.refcount--;
+ }
+ else
+ {
+ if (local_got_refcounts[r_symndx] > 0)
+ local_got_refcounts[r_symndx]--;
+ }
+ break;
+
+ case R_PPC_PLT32:
+ case R_PPC_PLTREL24:
+ case R_PPC_PLT16_LO:
+ case R_PPC_PLT16_HI:
+ case R_PPC_PLT16_HA:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->plt.refcount > 0)
+ h->plt.refcount--;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+ file. We use it to put .comm items in .sbss, and not .bss. */
+
+/*ARGSUSED*/
+static boolean
+ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const Elf_Internal_Sym *sym;
+ const char **namep;
+ flagword *flagsp;
+ asection **secp;
+ bfd_vma *valp;
+{
+ if (sym->st_shndx == SHN_COMMON
+ && !info->relocateable
+ && sym->st_size <= (bfd_vma) bfd_get_gp_size (abfd))
+ {
+ /* Common symbols less than or equal to -G nn bytes are automatically
+ put into .sdata. */
+ elf_linker_section_t *sdata
+ = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA);
+
+ if (!sdata->bss_section)
+ {
+ /* We don't go through bfd_make_section, because we don't
+ want to attach this common section to DYNOBJ. The linker
+ will move the symbols to the appropriate output section
+ when it defines common symbols. */
+ sdata->bss_section = ((asection *)
+ bfd_zalloc (abfd, sizeof (asection)));
+ if (sdata->bss_section == NULL)
+ return false;
+ sdata->bss_section->name = sdata->bss_name;
+ sdata->bss_section->flags = SEC_IS_COMMON;
+ sdata->bss_section->output_section = sdata->bss_section;
+ sdata->bss_section->symbol =
+ (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ sdata->bss_section->symbol_ptr_ptr =
+ (asymbol **) bfd_zalloc (abfd, sizeof (asymbol *));
+ if (sdata->bss_section->symbol == NULL
+ || sdata->bss_section->symbol_ptr_ptr == NULL)
+ return false;
+ sdata->bss_section->symbol->name = sdata->bss_name;
+ sdata->bss_section->symbol->flags = BSF_SECTION_SYM;
+ sdata->bss_section->symbol->section = sdata->bss_section;
+ *sdata->bss_section->symbol_ptr_ptr = sdata->bss_section->symbol;
+ }
+
+ *secp = sdata->bss_section;
+ *valp = sym->st_size;
+ }
+
+ return true;
+}
+
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_finish_dynamic_symbol called for %s",
+ h->root.root.string);
+#endif
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection *splt;
+ asection *srela;
+ Elf_Internal_Rela rela;
+ bfd_vma reloc_index;
+
+#ifdef DEBUG
+ fprintf (stderr, ", plt_offset = %d", h->plt.offset);
+#endif
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (splt != NULL && srela != NULL);
+
+ /* We don't need to fill in the .plt. The ppc dynamic linker
+ will fill it in. */
+
+ /* Fill in the entry in the .rela.plt section. */
+ rela.r_offset = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_JMP_SLOT);
+ rela.r_addend = 0;
+
+ reloc_index = (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_SLOT_SIZE;
+ if (reloc_index > PLT_NUM_SINGLE_ENTRIES)
+ reloc_index -= (reloc_index - PLT_NUM_SINGLE_ENTRIES) / 2;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) srela->contents
+ + reloc_index));
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ the .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ asection *sgot;
+ asection *srela;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srela = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (sgot != NULL && srela != NULL);
+
+ rela.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + (h->got.offset &~ 1));
+
+ /* If this is a -Bsymbolic link, and the symbol is defined
+ locally, we just want to emit a RELATIVE reloc. The entry in
+ the global offset table will already have been initialized in
+ the relocate_section function. */
+ if (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ {
+ rela.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
+ rela.r_addend = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+ else
+ {
+ BFD_ASSERT((h->got.offset & 1) == 0);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT);
+ rela.r_addend = 0;
+ }
+
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) srela->contents
+ + srela->reloc_count));
+ ++srela->reloc_count;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ asection *s;
+ Elf_Internal_Rela rela;
+
+ /* This symbols needs a copy reloc. Set it up. */
+
+#ifdef DEBUG
+ fprintf (stderr, ", copy");
+#endif
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ if (h->size <= elf_gp_size (dynobj))
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rela.sbss");
+ else
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rela.bss");
+ BFD_ASSERT (s != NULL);
+
+ rela.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY);
+ rela.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) s->contents
+ + s->reloc_count));
+ ++s->reloc_count;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "\n");
+#endif
+
+ /* Mark some specially defined symbols as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
+ || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+
+/* Finish up the dynamic sections. */
+
+static boolean
+ppc_elf_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ asection *sdyn;
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ asection *sgot = bfd_get_section_by_name (dynobj, ".got");
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_finish_dynamic_sections called\n");
+#endif
+
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ boolean size;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ case DT_PLTGOT: name = ".plt"; size = false; break;
+ case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
+ case DT_JMPREL: name = ".rela.plt"; size = false; break;
+ default: name = NULL; size = false; break;
+ }
+
+ if (name != NULL)
+ {
+ asection *s;
+
+ s = bfd_get_section_by_name (output_bfd, name);
+ if (s == NULL)
+ dyn.d_un.d_val = 0;
+ else
+ {
+ if (! size)
+ dyn.d_un.d_ptr = s->vma;
+ else
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ }
+ }
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ }
+ }
+ }
+
+ /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can
+ easily find the address of the _GLOBAL_OFFSET_TABLE_. */
+ if (sgot)
+ {
+ unsigned char *contents = sgot->contents;
+ bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
+
+ if (sdyn == NULL)
+ bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
+ else
+ bfd_put_32 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ contents+4);
+
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ }
+
+ if (info->shared)
+ {
+ asection *sdynsym;
+ asection *s;
+ Elf_Internal_Sym sym;
+ int maxdindx = 0;
+
+ /* Set up the section symbols for the output sections. */
+
+ sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (sdynsym != NULL);
+
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_other = 0;
+
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ int indx, dindx;
+
+ sym.st_value = s->vma;
+
+ indx = elf_section_data (s)->this_idx;
+ dindx = elf_section_data (s)->dynindx;
+ if (dindx != -1)
+ {
+ BFD_ASSERT(indx > 0);
+ BFD_ASSERT(dindx > 0);
+
+ if (dindx > maxdindx)
+ maxdindx = dindx;
+
+ sym.st_shndx = indx;
+
+ bfd_elf32_swap_symbol_out (output_bfd, &sym,
+ (PTR) (((Elf32_External_Sym *)
+ sdynsym->contents)
+ + dindx));
+ }
+ }
+
+ /* Set the sh_info field of the output .dynsym section to the
+ index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
+ maxdindx + 1;
+ }
+
+ return true;
+}
+
+
+/* The RELOCATE_SECTION function is called by the ELF backend linker
+ to handle the relocations for a section.
+
+ The relocs are always passed as Rela structures; if the section
+ actually uses Rel structures, the r_addend field will always be
+ zero.
+
+ This function is responsible for adjust the section contents as
+ necessary, and (if using Rela relocs and generating a
+ relocateable output file) adjusting the reloc addend as
+ necessary.
+
+ This function does not have to worry about setting the reloc
+ address or the reloc symbol index.
+
+ LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+ LOCAL_SECTIONS is an array giving the section in the input file
+ corresponding to the st_shndx field of each local symbol.
+
+ The global hash table entry for the global symbols can be found
+ via elf_sym_hashes (input_bfd).
+
+ When generating relocateable output, this function must handle
+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
+ going to be the section symbol corresponding to the output
+ section, which means that the addend must be adjusted
+ accordingly. */
+
+static boolean
+ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ elf_linker_section_t *sdata = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA) : NULL;
+ elf_linker_section_t *sdata2 = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA2) : NULL;
+ Elf_Internal_Rela *rel = relocs;
+ Elf_Internal_Rela *relend = relocs + input_section->reloc_count;
+ asection *sreloc = NULL;
+ asection *splt;
+ asection *sgot;
+ bfd_vma *local_got_offsets;
+ boolean ret = true;
+ long insn;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n",
+ bfd_get_filename (input_bfd),
+ bfd_section_name(input_bfd, input_section),
+ (long)input_section->reloc_count,
+ (info->relocateable) ? " (relocatable)" : "");
+#endif
+
+ if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
+ ppc_elf_howto_init ();
+
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ splt = sgot = NULL;
+ if (dynobj != NULL)
+ {
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ }
+
+ for (; rel < relend; rel++)
+ {
+ enum elf_ppc_reloc_type r_type = (enum elf_ppc_reloc_type)ELF32_R_TYPE (rel->r_info);
+ bfd_vma offset = rel->r_offset;
+ bfd_vma addend = rel->r_addend;
+ bfd_reloc_status_type r = bfd_reloc_other;
+ Elf_Internal_Sym *sym = (Elf_Internal_Sym *)0;
+ asection *sec = (asection *)0;
+ struct elf_link_hash_entry *h = (struct elf_link_hash_entry *)0;
+ const char *sym_name = (const char *)0;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ bfd_vma relocation;
+
+ /* Unknown relocation handling */
+ if ((unsigned)r_type >= (unsigned)R_PPC_max || !ppc_elf_howto_table[(int)r_type])
+ {
+ (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
+ bfd_get_filename (input_bfd),
+ (int)r_type);
+
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+ }
+
+ howto = ppc_elf_howto_table[(int)r_type];
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ addend = rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
+ howto->name,
+ (int)r_type,
+ r_symndx,
+ (long)offset,
+ (long)addend);
+#endif
+ continue;
+ }
+
+ /* This is a final link. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ sym_name = "<local symbol>";
+
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ sym_name = h->root.root.string;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ if ((r_type == R_PPC_PLT32
+ && h->plt.offset != (bfd_vma) -1)
+ || (r_type == R_PPC_LOCAL24PC
+ && sec->output_section == NULL)
+ || ((r_type == R_PPC_GOT16
+ || r_type == R_PPC_GOT16_LO
+ || r_type == R_PPC_GOT16_HI
+ || r_type == R_PPC_GOT16_HA)
+ && elf_hash_table (info)->dynamic_sections_created
+ && (! info->shared
+ || (! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ || (info->shared
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ && (input_section->flags & SEC_ALLOC) != 0
+ && (r_type == R_PPC_ADDR32
+ || r_type == R_PPC_ADDR24
+ || r_type == R_PPC_ADDR16
+ || r_type == R_PPC_ADDR16_LO
+ || r_type == R_PPC_ADDR16_HI
+ || r_type == R_PPC_ADDR16_HA
+ || r_type == R_PPC_ADDR14
+ || r_type == R_PPC_ADDR14_BRTAKEN
+ || r_type == R_PPC_ADDR14_BRNTAKEN
+ || r_type == R_PPC_PLTREL24
+ || r_type == R_PPC_COPY
+ || r_type == R_PPC_GLOB_DAT
+ || r_type == R_PPC_JMP_SLOT
+ || r_type == R_PPC_UADDR32
+ || r_type == R_PPC_UADDR16
+ || r_type == R_PPC_SDAREL16
+ || r_type == R_PPC_EMB_NADDR32
+ || r_type == R_PPC_EMB_NADDR16
+ || r_type == R_PPC_EMB_NADDR16_LO
+ || r_type == R_PPC_EMB_NADDR16_HI
+ || r_type == R_PPC_EMB_NADDR16_HA
+ || r_type == R_PPC_EMB_SDAI16
+ || r_type == R_PPC_EMB_SDA2I16
+ || r_type == R_PPC_EMB_SDA2REL
+ || r_type == R_PPC_EMB_SDA21
+ || r_type == R_PPC_EMB_MRKREF
+ || r_type == R_PPC_EMB_BIT_FLD
+ || r_type == R_PPC_EMB_RELSDA
+ || ((r_type == R_PPC_REL24
+ || r_type == R_PPC_REL32
+ || r_type == R_PPC_REL14
+ || r_type == R_PPC_REL14_BRTAKEN
+ || r_type == R_PPC_REL14_BRNTAKEN
+ || r_type == R_PPC_RELATIVE)
+ && strcmp (h->root.root.string,
+ "_GLOBAL_OFFSET_TABLE_") != 0))))
+ {
+ /* In these cases, we don't need the relocation
+ value. We check specially because in some
+ obscure cases sec->output_section will be NULL. */
+ relocation = 0;
+ }
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else
+ {
+ (*info->callbacks->undefined_symbol)(info,
+ h->root.root.string,
+ input_bfd,
+ input_section,
+ rel->r_offset);
+ ret = false;
+ continue;
+ }
+ }
+
+ switch ((int)r_type)
+ {
+ default:
+ (*_bfd_error_handler) (_("%s: unknown relocation type %d for symbol %s"),
+ bfd_get_filename (input_bfd),
+ (int)r_type, sym_name);
+
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+
+ /* Relocations that need no special processing. */
+ case (int)R_PPC_LOCAL24PC:
+ /* It makes no sense to point a local relocation
+ at a symbol not in this object. */
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && sec->output_section == NULL)
+ {
+ (*info->callbacks->undefined_symbol) (info,
+ h->root.root.string,
+ input_bfd,
+ input_section,
+ rel->r_offset);
+ ret = false;
+ continue;
+ }
+ break;
+
+ /* Relocations that may need to be propagated if this is a shared
+ object. */
+ case (int)R_PPC_REL24:
+ case (int)R_PPC_REL32:
+ case (int)R_PPC_REL14:
+ /* If these relocations are not to a named symbol, they can be
+ handled right here, no need to bother the dynamic linker. */
+ if (h == NULL
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* fall through */
+
+ /* Relocations that always need to be propagated if this is a shared
+ object. */
+ case (int)R_PPC_NONE:
+ case (int)R_PPC_ADDR32:
+ case (int)R_PPC_ADDR24:
+ case (int)R_PPC_ADDR16:
+ case (int)R_PPC_ADDR16_LO:
+ case (int)R_PPC_ADDR16_HI:
+ case (int)R_PPC_ADDR16_HA:
+ case (int)R_PPC_ADDR14:
+ case (int)R_PPC_UADDR32:
+ case (int)R_PPC_UADDR16:
+ if (info->shared)
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip;
+
+#ifdef DEBUG
+ fprintf (stderr, "ppc_elf_relocate_section need to create relocation for %s\n",
+ (h && h->root.root.string) ? h->root.root.string : "<unknown>");
+#endif
+
+ /* When generating a shared object, these relocations
+ are copied into the output file to be resolved at run
+ time. */
+
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd,
+ elf_elfheader (input_bfd)->e_shstrndx,
+ elf_section_data (input_section)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (input_bfd,
+ input_section),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ memset (&outrel, 0, sizeof outrel);
+ /* h->dynindx may be -1 if this symbol was marked to
+ become local. */
+ else if (h != NULL
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
+ outrel.r_addend = rel->r_addend;
+ }
+ else
+ {
+ if (r_type == R_PPC_ADDR32)
+ {
+ outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ else
+ {
+ long indx;
+
+ if (h == NULL)
+ sec = local_sections[r_symndx];
+ else
+ {
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || (h->root.type
+ == bfd_link_hash_defweak));
+ sec = h->root.u.def.section;
+ }
+ if (sec != NULL && bfd_is_abs_section (sec))
+ indx = 0;
+ else if (sec == NULL || sec->owner == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else
+ {
+ asection *osec;
+
+ osec = sec->output_section;
+ indx = elf_section_data (osec)->dynindx;
+ BFD_ASSERT(indx > 0);
+#ifdef DEBUG
+ if (indx <= 0)
+ {
+ printf("indx=%d section=%s flags=%08x name=%s\n",
+ indx, osec->name, osec->flags,
+ h->root.root.string);
+ }
+#endif
+ }
+
+ outrel.r_info = ELF32_R_INFO (indx, r_type);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ }
+
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+ (((Elf32_External_Rela *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ /* This reloc will be computed at runtime, so there's no
+ need to do anything now, unless this is a RELATIVE
+ reloc in an unallocated section. */
+ if (skip
+ || (input_section->flags & SEC_ALLOC) != 0
+ || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)
+ continue;
+ }
+
+ /* Arithmetic adjust relocations that aren't going into a
+ shared object. */
+ if (r_type == R_PPC_ADDR16_HA
+ /* It's just possible that this symbol is a weak symbol
+ that's not actually defined anywhere. In that case,
+ 'sec' would be NULL, and we should leave the symbol
+ alone (it will be set to zero elsewhere in the link). */
+ && sec != NULL)
+ {
+ addend += ((relocation + addend) & 0x8000) << 1;
+ }
+ break;
+
+ /* branch taken prediction relocations */
+ case (int)R_PPC_ADDR14_BRTAKEN:
+ case (int)R_PPC_REL14_BRTAKEN:
+ insn = bfd_get_32 (output_bfd, contents + offset);
+ if ((relocation - offset) & 0x8000)
+ insn &= ~BRANCH_PREDICT_BIT;
+ else
+ insn |= BRANCH_PREDICT_BIT;
+ bfd_put_32 (output_bfd, insn, contents + offset);
+ break;
+
+ /* branch not taken predicition relocations */
+ case (int)R_PPC_ADDR14_BRNTAKEN:
+ case (int)R_PPC_REL14_BRNTAKEN:
+ insn = bfd_get_32 (output_bfd, contents + offset);
+ if ((relocation - offset) & 0x8000)
+ insn |= BRANCH_PREDICT_BIT;
+ else
+ insn &= ~BRANCH_PREDICT_BIT;
+ bfd_put_32 (output_bfd, insn, contents + offset);
+ break;
+
+ /* GOT16 relocations */
+ case (int)R_PPC_GOT16:
+ case (int)R_PPC_GOT16_LO:
+ case (int)R_PPC_GOT16_HI:
+ case (int)R_PPC_GOT16_HA:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ BFD_ASSERT (sgot != NULL);
+
+ if (h != NULL)
+ {
+ bfd_vma off;
+
+ off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally. We must initialize this entry in the
+ global offset table. Since the offset must
+ always be a multiple of 4, we use the least
+ significant bit to record whether we have
+ initialized it already.
+
+ When doing a dynamic link, we create a .rela.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation,
+ sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+
+ relocation = sgot->output_offset + off - 4;
+ }
+ else
+ {
+ bfd_vma off;
+
+ BFD_ASSERT (local_got_offsets != NULL
+ && local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use
+ the least significant bit to record whether we have
+ already processed this entry. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation, sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+
+ /* We need to generate a R_PPC_RELATIVE reloc
+ for the dynamic linker. */
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
+ outrel.r_addend = relocation;
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+ (((Elf32_External_Rela *)
+ srelgot->contents)
+ + srelgot->reloc_count));
+ ++srelgot->reloc_count;
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+
+ relocation = sgot->output_offset + off - 4;
+ }
+ break;
+
+ /* Indirect .sdata relocation */
+ case (int)R_PPC_EMB_SDAI16:
+ BFD_ASSERT (sdata != NULL);
+ relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info,
+ sdata, h, relocation, rel,
+ R_PPC_RELATIVE);
+ break;
+
+ /* Indirect .sdata2 relocation */
+ case (int)R_PPC_EMB_SDA2I16:
+ BFD_ASSERT (sdata2 != NULL);
+ relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info,
+ sdata2, h, relocation, rel,
+ R_PPC_RELATIVE);
+ break;
+
+ /* Handle the TOC16 reloc. We want to use the offset within the .got
+ section, not the actual VMA. This is appropriate when generating
+ an embedded ELF object, for which the .got section acts like the
+ AIX .toc section. */
+ case (int)R_PPC_TOC16: /* phony GOT16 relocations */
+ BFD_ASSERT (sec != (asection *)0);
+ BFD_ASSERT (bfd_is_und_section (sec)
+ || strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
+ || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0)
+
+ addend -= sec->output_section->vma + sec->output_offset + 0x8000;
+ break;
+
+ case (int)R_PPC_PLTREL24:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+ BFD_ASSERT (h != NULL);
+
+ if (h->plt.offset == (bfd_vma) -1
+ || splt == NULL)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ break;
+ }
+
+ relocation = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+ break;
+
+ /* relocate against _SDA_BASE_ */
+ case (int)R_PPC_SDAREL16:
+ {
+ const char *name;
+
+ BFD_ASSERT (sec != (asection *)0);
+ name = bfd_get_section_name (abfd, sec->output_section);
+ if (strcmp (name, ".sdata") != 0
+ && strcmp (name, ".sbss") != 0)
+ {
+ (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
+ bfd_get_filename (input_bfd),
+ sym_name,
+ ppc_elf_howto_table[ (int)r_type ]->name,
+ name);
+ }
+ addend -= (sdata->sym_hash->root.u.def.value
+ + sdata->sym_hash->root.u.def.section->output_section->vma
+ + sdata->sym_hash->root.u.def.section->output_offset);
+ }
+ break;
+
+
+ /* relocate against _SDA2_BASE_ */
+ case (int)R_PPC_EMB_SDA2REL:
+ {
+ const char *name;
+
+ BFD_ASSERT (sec != (asection *)0);
+ name = bfd_get_section_name (abfd, sec->output_section);
+ if (strcmp (name, ".sdata2") != 0 && strcmp (name, ".sbss2") != 0)
+ {
+ (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
+ bfd_get_filename (input_bfd),
+ sym_name,
+ ppc_elf_howto_table[ (int)r_type ]->name,
+ name);
+
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+ }
+ addend -= (sdata2->sym_hash->root.u.def.value
+ + sdata2->sym_hash->root.u.def.section->output_section->vma
+ + sdata2->sym_hash->root.u.def.section->output_offset);
+ }
+ break;
+
+
+ /* relocate against either _SDA_BASE_, _SDA2_BASE_, or 0 */
+ case (int)R_PPC_EMB_SDA21:
+ case (int)R_PPC_EMB_RELSDA:
+ {
+ const char *name;
+ int reg;
+
+ BFD_ASSERT (sec != (asection *)0);
+ name = bfd_get_section_name (abfd, sec->output_section);
+ if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0)
+ {
+ reg = 13;
+ addend -= (sdata->sym_hash->root.u.def.value
+ + sdata->sym_hash->root.u.def.section->output_section->vma
+ + sdata->sym_hash->root.u.def.section->output_offset);
+ }
+
+ else if (strcmp (name, ".sdata2") == 0 || strcmp (name, ".sbss2") == 0)
+ {
+ reg = 2;
+ addend -= (sdata2->sym_hash->root.u.def.value
+ + sdata2->sym_hash->root.u.def.section->output_section->vma
+ + sdata2->sym_hash->root.u.def.section->output_offset);
+ }
+
+ else if (strcmp (name, ".PPC.EMB.sdata0") == 0 || strcmp (name, ".PPC.EMB.sbss0") == 0)
+ {
+ reg = 0;
+ }
+
+ else
+ {
+ (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
+ bfd_get_filename (input_bfd),
+ sym_name,
+ ppc_elf_howto_table[ (int)r_type ]->name,
+ name);
+
+ bfd_set_error (bfd_error_bad_value);
+ ret = false;
+ continue;
+ }
+
+ if (r_type == R_PPC_EMB_SDA21)
+ { /* fill in register field */
+ insn = bfd_get_32 (output_bfd, contents + offset);
+ insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT);
+ bfd_put_32 (output_bfd, insn, contents + offset);
+ }
+ }
+ break;
+
+ /* Relocate against the beginning of the section */
+ case (int)R_PPC_SECTOFF:
+ case (int)R_PPC_SECTOFF_LO:
+ case (int)R_PPC_SECTOFF_HI:
+ BFD_ASSERT (sec != (asection *)0);
+ addend -= sec->output_section->vma;
+ break;
+
+ case (int)R_PPC_SECTOFF_HA:
+ BFD_ASSERT (sec != (asection *)0);
+ addend -= sec->output_section->vma;
+ addend += ((relocation + addend) & 0x8000) << 1;
+ break;
+
+ /* Negative relocations */
+ case (int)R_PPC_EMB_NADDR32:
+ case (int)R_PPC_EMB_NADDR16:
+ case (int)R_PPC_EMB_NADDR16_LO:
+ case (int)R_PPC_EMB_NADDR16_HI:
+ addend -= 2*relocation;
+ break;
+
+ case (int)R_PPC_EMB_NADDR16_HA:
+ addend -= 2*relocation;
+ addend += ((relocation + addend) & 0x8000) << 1;
+ break;
+
+ /* NOP relocation that prevents garbage collecting linkers from omitting a
+ reference. */
+ case (int)R_PPC_EMB_MRKREF:
+ continue;
+
+ case (int)R_PPC_COPY:
+ case (int)R_PPC_GLOB_DAT:
+ case (int)R_PPC_JMP_SLOT:
+ case (int)R_PPC_RELATIVE:
+ case (int)R_PPC_PLT32:
+ case (int)R_PPC_PLTREL32:
+ case (int)R_PPC_PLT16_LO:
+ case (int)R_PPC_PLT16_HI:
+ case (int)R_PPC_PLT16_HA:
+ case (int)R_PPC_EMB_RELSEC16:
+ case (int)R_PPC_EMB_RELST_LO:
+ case (int)R_PPC_EMB_RELST_HI:
+ case (int)R_PPC_EMB_RELST_HA:
+ case (int)R_PPC_EMB_BIT_FLD:
+ (*_bfd_error_handler) (_("%s: Relocation %s is not yet supported for symbol %s."),
+ bfd_get_filename (input_bfd),
+ ppc_elf_howto_table[ (int)r_type ]->name,
+ sym_name);
+
+ bfd_set_error (bfd_error_invalid_operation);
+ ret = false;
+ continue;
+
+ case (int)R_PPC_GNU_VTINHERIT:
+ case (int)R_PPC_GNU_VTENTRY:
+ /* These are no-ops in the end. */
+ continue;
+ }
+
+
+#ifdef DEBUG
+ fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n",
+ howto->name,
+ (int)r_type,
+ sym_name,
+ r_symndx,
+ (long)offset,
+ (long)addend);
+#endif
+
+ r = _bfd_final_link_relocate (howto,
+ input_bfd,
+ input_section,
+ contents,
+ offset,
+ relocation,
+ addend);
+
+ if (r != bfd_reloc_ok)
+ {
+ ret = false;
+ switch (r)
+ {
+ default:
+ break;
+
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ break;
+
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ (*info->callbacks->reloc_overflow)(info,
+ name,
+ howto->name,
+ (bfd_vma) 0,
+ input_bfd,
+ input_section,
+ offset);
+ }
+ break;
+
+ }
+ }
+ }
+
+
+#ifdef DEBUG
+ fprintf (stderr, "\n");
+#endif
+
+ return ret;
+}
+
+
+#define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
+#define TARGET_LITTLE_NAME "elf32-powerpcle"
+#define TARGET_BIG_SYM bfd_elf32_powerpc_vec
+#define TARGET_BIG_NAME "elf32-powerpc"
+#define ELF_ARCH bfd_arch_powerpc
+#define ELF_MACHINE_CODE EM_PPC
+#define ELF_MAXPAGESIZE 0x10000
+#define elf_info_to_howto ppc_elf_info_to_howto
+
+#ifdef EM_CYGNUS_POWERPC
+#define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC
+#endif
+
+#ifdef EM_PPC_OLD
+#define ELF_MACHINE_ALT2 EM_PPC_OLD
+#endif
+
+#define elf_backend_plt_not_loaded 1
+#define elf_backend_got_symbol_offset 4
+#define elf_backend_can_gc_sections 1
+#define elf_backend_got_header_size 12
+#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
+
+#define bfd_elf32_bfd_copy_private_bfd_data ppc_elf_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_relax_section ppc_elf_relax_section
+#define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup
+#define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags
+#define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link
+
+#define elf_backend_gc_mark_hook ppc_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook ppc_elf_gc_sweep_hook
+#define elf_backend_section_from_shdr ppc_elf_section_from_shdr
+#define elf_backend_relocate_section ppc_elf_relocate_section
+#define elf_backend_create_dynamic_sections ppc_elf_create_dynamic_sections
+#define elf_backend_check_relocs ppc_elf_check_relocs
+#define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol
+#define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook
+#define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections
+#define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections
+#define elf_backend_fake_sections ppc_elf_fake_sections
+#define elf_backend_additional_program_headers ppc_elf_additional_program_headers
+#define elf_backend_modify_segment_map ppc_elf_modify_segment_map
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
new file mode 100644
index 00000000000..ebbe352456e
--- /dev/null
+++ b/bfd/elf32-sh.c
@@ -0,0 +1,2059 @@
+/* Hitachi SH specific support for 32-bit ELF
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+ Contributed 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/sh.h"
+
+static bfd_reloc_status_type sh_elf_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type sh_elf_ignore_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *sh_elf_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void sh_elf_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+static boolean sh_elf_relax_section
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
+static boolean sh_elf_relax_delete_bytes
+ PARAMS ((bfd *, asection *, bfd_vma, int));
+static boolean sh_elf_align_loads
+ PARAMS ((bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, boolean *));
+static boolean sh_elf_swap_insns
+ PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma));
+static boolean sh_elf_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static bfd_byte *sh_elf_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean, asymbol **));
+
+static reloc_howto_type sh_elf_howto_table[] =
+{
+ /* No relocation. */
+ HOWTO (R_SH_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit absolute relocation. Setting partial_inplace to true and
+ src_mask to a non-zero value is similar to the COFF toolchain. */
+ HOWTO (R_SH_DIR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit PC relative relocation. */
+ HOWTO (R_SH_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_REL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit PC relative branch divided by 2. */
+ HOWTO (R_SH_DIR8WPN, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR8WPN", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 12 bit PC relative branch divided by 2. */
+ HOWTO (R_SH_IND12W, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_IND12W", /* name */
+ true, /* partial_inplace */
+ 0xfff, /* src_mask */
+ 0xfff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit unsigned PC relative divided by 4. */
+ HOWTO (R_SH_DIR8WPL, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR8WPL", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit unsigned PC relative divided by 2. */
+ HOWTO (R_SH_DIR8WPZ, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR8WPZ", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit GBR relative. FIXME: This only makes sense if we have some
+ special symbol for the GBR relative area, and that is not
+ implemented. */
+ HOWTO (R_SH_DIR8BP, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR8BP", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit GBR relative divided by 2. FIXME: This only makes sense if
+ we have some special symbol for the GBR relative area, and that
+ is not implemented. */
+ HOWTO (R_SH_DIR8W, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR8W", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit GBR relative divided by 4. FIXME: This only makes sense if
+ we have some special symbol for the GBR relative area, and that
+ is not implemented. */
+ HOWTO (R_SH_DIR8L, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_reloc, /* special_function */
+ "R_SH_DIR8L", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ { 10 },
+ { 11 },
+ { 12 },
+ { 13 },
+ { 14 },
+ { 15 },
+ { 16 },
+ { 17 },
+ { 18 },
+ { 19 },
+ { 20 },
+ { 21 },
+ { 22 },
+ { 23 },
+ { 24 },
+
+ /* The remaining relocs are a GNU extension used for relaxing. The
+ final pass of the linker never needs to do anything with any of
+ these relocs. Any required operations are handled by the
+ relaxation code. */
+
+ /* A 16 bit switch table entry. This is generated for an expression
+ such as ``.word L1 - L2''. The offset holds the difference
+ between the reloc address and L2. */
+ HOWTO (R_SH_SWITCH16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_SWITCH16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A 32 bit switch table entry. This is generated for an expression
+ such as ``.long L1 - L2''. The offset holds the difference
+ between the reloc address and L2. */
+ HOWTO (R_SH_SWITCH32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_SWITCH32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Indicates a .uses pseudo-op. The compiler will generate .uses
+ pseudo-ops when it finds a function call which can be relaxed.
+ The offset field holds the PC relative offset to the instruction
+ which loads the register used in the function call. */
+ HOWTO (R_SH_USES, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_USES", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* The assembler will generate this reloc for addresses referred to
+ by the register loads associated with USES relocs. The offset
+ field holds the number of times the address is referenced in the
+ object file. */
+ HOWTO (R_SH_COUNT, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_COUNT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* Indicates an alignment statement. The offset field is the power
+ of 2 to which subsequent portions of the object file must be
+ aligned. */
+ HOWTO (R_SH_ALIGN, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_ALIGN", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* The assembler will generate this reloc before a block of
+ instructions. A section should be processed as assumining it
+ contains data, unless this reloc is seen. */
+ HOWTO (R_SH_CODE, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_CODE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* The assembler will generate this reloc after a block of
+ instructions when it sees data that is not instructions. */
+ HOWTO (R_SH_DATA, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_DATA", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* The assembler generates this reloc for each label within a block
+ of instructions. This permits the linker to avoid swapping
+ instructions which are the targets of branches. */
+ HOWTO (R_SH_LABEL, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_LABEL", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* An 8 bit switch table entry. This is generated for an expression
+ such as ``.word L1 - L2''. The offset holds the difference
+ between the reloc address and L2. */
+ HOWTO (R_SH_SWITCH8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_unsigned, /* complain_on_overflow */
+ sh_elf_ignore_reloc, /* special_function */
+ "R_SH_SWITCH8", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_SH_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_SH_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_SH_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_SH_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+/* This function is used for normal relocs. This is like the COFF
+ function, and is almost certainly incorrect for other ELF targets. */
+
+static bfd_reloc_status_type
+sh_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ unsigned long insn;
+ bfd_vma sym_value;
+ enum elf_sh_reloc_type r_type;
+ bfd_vma addr = reloc_entry->address;
+ bfd_byte *hit_data = addr + (bfd_byte *) data;
+
+ r_type = (enum elf_sh_reloc_type) reloc_entry->howto->type;
+
+ if (output_bfd != NULL)
+ {
+ /* Partial linking--do nothing. */
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* Almost all relocs have to do with relaxing. If any work must be
+ done for them, it has been done in sh_relax_section. */
+ if (r_type != R_SH_DIR32
+ && (r_type != R_SH_IND12W
+ || (symbol_in->flags & BSF_LOCAL) != 0))
+ return bfd_reloc_ok;
+
+ if (symbol_in != NULL
+ && bfd_is_und_section (symbol_in->section))
+ return bfd_reloc_undefined;
+
+ if (bfd_is_com_section (symbol_in->section))
+ sym_value = 0;
+ else
+ sym_value = (symbol_in->value +
+ symbol_in->section->output_section->vma +
+ symbol_in->section->output_offset);
+
+ switch (r_type)
+ {
+ case R_SH_DIR32:
+ insn = bfd_get_32 (abfd, hit_data);
+ insn += sym_value + reloc_entry->addend;
+ bfd_put_32 (abfd, insn, hit_data);
+ break;
+ case R_SH_IND12W:
+ insn = bfd_get_16 (abfd, hit_data);
+ sym_value += reloc_entry->addend;
+ sym_value -= (input_section->output_section->vma
+ + input_section->output_offset
+ + addr
+ + 4);
+ sym_value += (insn & 0xfff) << 1;
+ if (insn & 0x800)
+ sym_value -= 0x1000;
+ insn = (insn & 0xf000) | (sym_value & 0xfff);
+ bfd_put_16 (abfd, insn, hit_data);
+ if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000)
+ return bfd_reloc_overflow;
+ break;
+ default:
+ abort ();
+ break;
+ }
+
+ return bfd_reloc_ok;
+}
+
+/* This function is used for relocs which are only used for relaxing,
+ which the linker should otherwise ignore. */
+
+static bfd_reloc_status_type
+sh_elf_ignore_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd != NULL)
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+}
+
+/* This structure is used to map BFD reloc codes to SH ELF relocs. */
+
+struct elf_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+/* An array mapping BFD reloc codes to SH ELF relocs. */
+
+static const struct elf_reloc_map sh_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_SH_NONE },
+ { BFD_RELOC_32, R_SH_DIR32 },
+ { BFD_RELOC_CTOR, R_SH_DIR32 },
+ { BFD_RELOC_32_PCREL, R_SH_REL32 },
+ { BFD_RELOC_SH_PCDISP8BY2, R_SH_DIR8WPN },
+ { BFD_RELOC_SH_PCDISP12BY2, R_SH_IND12W },
+ { BFD_RELOC_SH_PCRELIMM8BY2, R_SH_DIR8WPZ },
+ { BFD_RELOC_SH_PCRELIMM8BY4, R_SH_DIR8WPL },
+ { BFD_RELOC_8_PCREL, R_SH_SWITCH8 },
+ { BFD_RELOC_SH_SWITCH16, R_SH_SWITCH16 },
+ { BFD_RELOC_SH_SWITCH32, R_SH_SWITCH32 },
+ { BFD_RELOC_SH_USES, R_SH_USES },
+ { BFD_RELOC_SH_COUNT, R_SH_COUNT },
+ { BFD_RELOC_SH_ALIGN, R_SH_ALIGN },
+ { BFD_RELOC_SH_CODE, R_SH_CODE },
+ { BFD_RELOC_SH_DATA, R_SH_DATA },
+ { BFD_RELOC_SH_LABEL, R_SH_LABEL },
+ { BFD_RELOC_VTABLE_INHERIT, R_SH_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_SH_GNU_VTENTRY },
+};
+
+/* Given a BFD reloc code, return the howto structure for the
+ corresponding SH ELf reloc. */
+
+static reloc_howto_type *
+sh_elf_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof (sh_reloc_map) / sizeof (struct elf_reloc_map); i++)
+ {
+ if (sh_reloc_map[i].bfd_reloc_val == code)
+ return &sh_elf_howto_table[(int) sh_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+/* Given an ELF reloc, fill in the howto field of a relent. */
+
+static void
+sh_elf_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf_Internal_Rela *dst;
+{
+ unsigned int r;
+
+ r = ELF32_R_TYPE (dst->r_info);
+
+ BFD_ASSERT (r < (unsigned int) R_SH_max);
+ BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC || r > R_SH_LAST_INVALID_RELOC);
+
+ cache_ptr->howto = &sh_elf_howto_table[r];
+}
+
+/* This function handles relaxing for SH ELF. See the corresponding
+ function in coff-sh.c for a description of what this does. FIXME:
+ There is a lot of duplication here between this code and the COFF
+ specific code. The format of relocs and symbols is wound deeply
+ into this code, but it would still be better if the duplication
+ could be eliminated somehow. Note in particular that although both
+ functions use symbols like R_SH_CODE, those symbols have different
+ values; in coff-sh.c they come from include/coff/sh.h, whereas here
+ they come from enum elf_sh_reloc_type in include/elf/sh.h. */
+
+static boolean
+sh_elf_relax_section (abfd, sec, link_info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *internal_relocs;
+ Elf_Internal_Rela *free_relocs = NULL;
+ boolean have_code;
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_byte *contents = NULL;
+ bfd_byte *free_contents = NULL;
+ Elf32_External_Sym *extsyms = NULL;
+ Elf32_External_Sym *free_extsyms = NULL;
+
+ *again = false;
+
+ if (link_info->relocateable
+ || (sec->flags & SEC_RELOC) == 0
+ || sec->reloc_count == 0)
+ return true;
+
+ /* If this is the first time we have been called for this section,
+ initialize the cooked size. */
+ if (sec->_cooked_size == 0)
+ sec->_cooked_size = sec->_raw_size;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ have_code = false;
+
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma laddr, paddr, symval;
+ unsigned short insn;
+ Elf_Internal_Rela *irelfn, *irelscan, *irelcount;
+ bfd_signed_vma foff;
+
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_CODE)
+ have_code = true;
+
+ if (ELF32_R_TYPE (irel->r_info) != (int) R_SH_USES)
+ continue;
+
+ /* Get the section contents. */
+ if (contents == NULL)
+ {
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* The r_addend field of the R_SH_USES reloc will point us to
+ the register load. The 4 is because the r_addend field is
+ computed as though it were a jump offset, which are based
+ from 4 bytes after the jump instruction. */
+ laddr = irel->r_offset + 4 + irel->r_addend;
+ if (laddr >= sec->_raw_size)
+ {
+ (*_bfd_error_handler) (_("%s: 0x%lx: warning: bad R_SH_USES offset"),
+ bfd_get_filename (abfd),
+ (unsigned long) irel->r_offset);
+ continue;
+ }
+ insn = bfd_get_16 (abfd, contents + laddr);
+
+ /* If the instruction is not mov.l NN,rN, we don't know what to
+ do. */
+ if ((insn & 0xf000) != 0xd000)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
+ bfd_get_filename (abfd), (unsigned long) irel->r_offset, insn));
+ continue;
+ }
+
+ /* Get the address from which the register is being loaded. The
+ displacement in the mov.l instruction is quadrupled. It is a
+ displacement from four bytes after the movl instruction, but,
+ before adding in the PC address, two least significant bits
+ of the PC are cleared. We assume that the section is aligned
+ on a four byte boundary. */
+ paddr = insn & 0xff;
+ paddr *= 4;
+ paddr += (laddr + 4) &~ 3;
+ if (paddr >= sec->_raw_size)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: warning: bad R_SH_USES load offset"),
+ bfd_get_filename (abfd), (unsigned long) irel->r_offset));
+ continue;
+ }
+
+ /* Get the reloc for the address from which the register is
+ being loaded. This reloc will tell us which function is
+ actually being called. */
+ for (irelfn = internal_relocs; irelfn < irelend; irelfn++)
+ if (irelfn->r_offset == paddr
+ && ELF32_R_TYPE (irelfn->r_info) == (int) R_SH_DIR32)
+ break;
+ if (irelfn >= irelend)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: warning: could not find expected reloc"),
+ bfd_get_filename (abfd), (unsigned long) paddr));
+ continue;
+ }
+
+ /* Read this BFD's symbols if we haven't done so already. */
+ if (extsyms == NULL)
+ {
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ extsyms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ /* Get the value of the symbol referred to by the reloc. */
+ if (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info)
+ {
+ Elf_Internal_Sym isym;
+
+ /* A local symbol. */
+ bfd_elf32_swap_symbol_in (abfd,
+ extsyms + ELF32_R_SYM (irelfn->r_info),
+ &isym);
+
+ if (isym.st_shndx != _bfd_elf_section_from_bfd_section (abfd, sec))
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: warning: symbol in unexpected section"),
+ bfd_get_filename (abfd), (unsigned long) paddr));
+ continue;
+ }
+
+ symval = (isym.st_value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ unsigned long indx;
+ struct elf_link_hash_entry *h;
+
+ indx = ELF32_R_SYM (irelfn->r_info) - symtab_hdr->sh_info;
+ h = elf_sym_hashes (abfd)[indx];
+ BFD_ASSERT (h != NULL);
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ {
+ /* This appears to be a reference to an undefined
+ symbol. Just ignore it--it will be caught by the
+ regular reloc processing. */
+ continue;
+ }
+
+ symval = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+
+ symval += bfd_get_32 (abfd, contents + paddr);
+
+ /* See if this function call can be shortened. */
+ foff = (symval
+ - (irel->r_offset
+ + sec->output_section->vma
+ + sec->output_offset
+ + 4));
+ if (foff < -0x1000 || foff >= 0x1000)
+ {
+ /* After all that work, we can't shorten this function call. */
+ continue;
+ }
+
+ /* Shorten the function call. */
+
+ /* For simplicity of coding, we are going to modify the section
+ contents, the section relocs, and the BFD symbol table. We
+ must tell the rest of the code not to free up this
+ information. It would be possible to instead create a table
+ of changes which have to be made, as is done in coff-mips.c;
+ that would be more work, but would require less memory when
+ the linker is run. */
+
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+
+ /* Replace the jsr with a bsr. */
+
+ /* Change the R_SH_USES reloc into an R_SH_IND12W reloc, and
+ replace the jsr with a bsr. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irelfn->r_info), R_SH_IND12W);
+ if (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info)
+ {
+ /* If this needs to be changed because of future relaxing,
+ it will be handled here like other internal IND12W
+ relocs. */
+ bfd_put_16 (abfd,
+ 0xb000 | ((foff >> 1) & 0xfff),
+ contents + irel->r_offset);
+ }
+ else
+ {
+ /* We can't fully resolve this yet, because the external
+ symbol value may be changed by future relaxing. We let
+ the final link phase handle it. */
+ bfd_put_16 (abfd, 0xb000, contents + irel->r_offset);
+ }
+
+ /* See if there is another R_SH_USES reloc referring to the same
+ register load. */
+ for (irelscan = internal_relocs; irelscan < irelend; irelscan++)
+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_SH_USES
+ && laddr == irelscan->r_offset + 4 + irelscan->r_addend)
+ break;
+ if (irelscan < irelend)
+ {
+ /* Some other function call depends upon this register load,
+ and we have not yet converted that function call.
+ Indeed, we may never be able to convert it. There is
+ nothing else we can do at this point. */
+ continue;
+ }
+
+ /* Look for a R_SH_COUNT reloc on the location where the
+ function address is stored. Do this before deleting any
+ bytes, to avoid confusion about the address. */
+ for (irelcount = internal_relocs; irelcount < irelend; irelcount++)
+ if (irelcount->r_offset == paddr
+ && ELF32_R_TYPE (irelcount->r_info) == (int) R_SH_COUNT)
+ break;
+
+ /* Delete the register load. */
+ if (! sh_elf_relax_delete_bytes (abfd, sec, laddr, 2))
+ goto error_return;
+
+ /* That will change things, so, just in case it permits some
+ other function call to come within range, we should relax
+ again. Note that this is not required, and it may be slow. */
+ *again = true;
+
+ /* Now check whether we got a COUNT reloc. */
+ if (irelcount >= irelend)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: warning: could not find expected COUNT reloc"),
+ bfd_get_filename (abfd), (unsigned long) paddr));
+ continue;
+ }
+
+ /* The number of uses is stored in the r_addend field. We've
+ just deleted one. */
+ if (irelcount->r_addend == 0)
+ {
+ ((*_bfd_error_handler) (_("%s: 0x%lx: warning: bad count"),
+ bfd_get_filename (abfd),
+ (unsigned long) paddr));
+ continue;
+ }
+
+ --irelcount->r_addend;
+
+ /* If there are no more uses, we can delete the address. Reload
+ the address from irelfn, in case it was changed by the
+ previous call to sh_elf_relax_delete_bytes. */
+ if (irelcount->r_addend == 0)
+ {
+ if (! sh_elf_relax_delete_bytes (abfd, sec, irelfn->r_offset, 4))
+ goto error_return;
+ }
+
+ /* We've done all we can with that function call. */
+ }
+
+ /* Look for load and store instructions that we can align on four
+ byte boundaries. */
+ if (have_code)
+ {
+ boolean swapped;
+
+ /* Get the section contents. */
+ if (contents == NULL)
+ {
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (contents == NULL)
+ goto error_return;
+ free_contents = contents;
+
+ if (! bfd_get_section_contents (abfd, sec, contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ if (! sh_elf_align_loads (abfd, sec, internal_relocs, contents,
+ &swapped))
+ goto error_return;
+
+ if (swapped)
+ {
+ elf_section_data (sec)->relocs = internal_relocs;
+ free_relocs = NULL;
+
+ elf_section_data (sec)->this_hdr.contents = contents;
+ free_contents = NULL;
+
+ symtab_hdr->contents = (bfd_byte *) extsyms;
+ free_extsyms = NULL;
+ }
+ }
+
+ if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ free_relocs = NULL;
+ }
+
+ if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (sec)->this_hdr.contents = contents;
+ }
+ free_contents = NULL;
+ }
+
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ free_extsyms = NULL;
+ }
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ if (free_extsyms != NULL)
+ free (free_extsyms);
+ return false;
+}
+
+/* Delete some bytes from a section while relaxing. FIXME: There is a
+ lot of duplication between this function and sh_relax_delete_bytes
+ in coff-sh.c. */
+
+static boolean
+sh_elf_relax_delete_bytes (abfd, sec, addr, count)
+ bfd *abfd;
+ asection *sec;
+ bfd_vma addr;
+ int count;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf32_External_Sym *extsyms;
+ int shndx, index;
+ bfd_byte *contents;
+ Elf_Internal_Rela *irel, *irelend;
+ Elf_Internal_Rela *irelalign;
+ bfd_vma toaddr;
+ Elf32_External_Sym *esym, *esymend;
+ struct elf_link_hash_entry *sym_hash;
+ asection *o;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
+
+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+ contents = elf_section_data (sec)->this_hdr.contents;
+
+ /* The deletion must stop at the next ALIGN reloc for an aligment
+ power larger than the number of bytes we are deleting. */
+
+ irelalign = NULL;
+ toaddr = sec->_cooked_size;
+
+ irel = elf_section_data (sec)->relocs;
+ irelend = irel + sec->reloc_count;
+ for (; irel < irelend; irel++)
+ {
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_ALIGN
+ && irel->r_offset > addr
+ && count < (1 << irel->r_addend))
+ {
+ irelalign = irel;
+ toaddr = irel->r_offset;
+ break;
+ }
+ }
+
+ /* Actually delete the bytes. */
+ memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ if (irelalign == NULL)
+ sec->_cooked_size -= count;
+ else
+ {
+ int i;
+
+#define NOP_OPCODE (0x0009)
+
+ BFD_ASSERT ((count & 1) == 0);
+ for (i = 0; i < count; i += 2)
+ bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i);
+ }
+
+ /* Adjust all the relocs. */
+ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+ {
+ bfd_vma nraddr, stop;
+ bfd_vma start = 0;
+ int insn = 0;
+ Elf_Internal_Sym sym;
+ int off, adjust, oinsn;
+ bfd_signed_vma voff = 0;
+ boolean overflow;
+
+ /* Get the new reloc address. */
+ nraddr = irel->r_offset;
+ if ((irel->r_offset > addr
+ && irel->r_offset < toaddr)
+ || (ELF32_R_TYPE (irel->r_info) == (int) R_SH_ALIGN
+ && irel->r_offset == toaddr))
+ nraddr -= count;
+
+ /* See if this reloc was for the bytes we have deleted, in which
+ case we no longer care about it. Don't delete relocs which
+ represent addresses, though. */
+ if (irel->r_offset >= addr
+ && irel->r_offset < addr + count
+ && ELF32_R_TYPE (irel->r_info) != (int) R_SH_ALIGN
+ && ELF32_R_TYPE (irel->r_info) != (int) R_SH_CODE
+ && ELF32_R_TYPE (irel->r_info) != (int) R_SH_DATA
+ && ELF32_R_TYPE (irel->r_info) != (int) R_SH_LABEL)
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ (int) R_SH_NONE);
+
+ /* If this is a PC relative reloc, see if the range it covers
+ includes the bytes we have deleted. */
+ switch ((enum elf_sh_reloc_type) ELF32_R_TYPE (irel->r_info))
+ {
+ default:
+ break;
+
+ case R_SH_DIR8WPN:
+ case R_SH_IND12W:
+ case R_SH_DIR8WPZ:
+ case R_SH_DIR8WPL:
+ start = irel->r_offset;
+ insn = bfd_get_16 (abfd, contents + nraddr);
+ break;
+ }
+
+ switch ((enum elf_sh_reloc_type) ELF32_R_TYPE (irel->r_info))
+ {
+ default:
+ start = stop = addr;
+ break;
+
+ case R_SH_DIR32:
+ /* If this reloc is against a symbol defined in this
+ section, and the symbol will not be adjusted below, we
+ must check the addend to see it will put the value in
+ range to be adjusted, and hence must be changed. */
+ if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+ {
+ bfd_elf32_swap_symbol_in (abfd,
+ extsyms + ELF32_R_SYM (irel->r_info),
+ &sym);
+ if (sym.st_shndx == shndx
+ && (sym.st_value <= addr
+ || sym.st_value >= toaddr))
+ {
+ bfd_vma val;
+
+ val = bfd_get_32 (abfd, contents + nraddr);
+ val += sym.st_value;
+ if (val > addr && val < toaddr)
+ bfd_put_32 (abfd, val - count, contents + nraddr);
+ }
+ }
+ start = stop = addr;
+ break;
+
+ case R_SH_DIR8WPN:
+ off = insn & 0xff;
+ if (off & 0x80)
+ off -= 0x100;
+ stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
+ break;
+
+ case R_SH_IND12W:
+ if (ELF32_R_SYM (irel->r_info) >= symtab_hdr->sh_info)
+ start = stop = addr;
+ else
+ {
+ off = insn & 0xfff;
+ if (off & 0x800)
+ off -= 0x1000;
+ stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
+ }
+ break;
+
+ case R_SH_DIR8WPZ:
+ off = insn & 0xff;
+ stop = start + 4 + off * 2;
+ break;
+
+ case R_SH_DIR8WPL:
+ off = insn & 0xff;
+ stop = (start &~ (bfd_vma) 3) + 4 + off * 4;
+ break;
+
+ case R_SH_SWITCH8:
+ case R_SH_SWITCH16:
+ case R_SH_SWITCH32:
+ /* These relocs types represent
+ .word L2-L1
+ The r_offset field holds the difference between the reloc
+ address and L1. That is the start of the reloc, and
+ adding in the contents gives us the top. We must adjust
+ both the r_offset field and the section contents. */
+
+ start = irel->r_offset;
+ stop = (bfd_vma) ((bfd_signed_vma) start - (long) irel->r_addend);
+
+ if (start > addr
+ && start < toaddr
+ && (stop <= addr || stop >= toaddr))
+ irel->r_addend += count;
+ else if (stop > addr
+ && stop < toaddr
+ && (start <= addr || start >= toaddr))
+ irel->r_addend -= count;
+
+ start = stop;
+
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_SWITCH16)
+ voff = bfd_get_signed_16 (abfd, contents + nraddr);
+ else if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_SWITCH8)
+ voff = bfd_get_8 (abfd, contents + nraddr);
+ else
+ voff = bfd_get_signed_32 (abfd, contents + nraddr);
+ stop = (bfd_vma) ((bfd_signed_vma) start + voff);
+
+ break;
+
+ case R_SH_USES:
+ start = irel->r_offset;
+ stop = (bfd_vma) ((bfd_signed_vma) start
+ + (long) irel->r_addend
+ + 4);
+ break;
+ }
+
+ if (start > addr
+ && start < toaddr
+ && (stop <= addr || stop >= toaddr))
+ adjust = count;
+ else if (stop > addr
+ && stop < toaddr
+ && (start <= addr || start >= toaddr))
+ adjust = - count;
+ else
+ adjust = 0;
+
+ if (adjust != 0)
+ {
+ oinsn = insn;
+ overflow = false;
+ switch ((enum elf_sh_reloc_type) ELF32_R_TYPE (irel->r_info))
+ {
+ default:
+ abort ();
+ break;
+
+ case R_SH_DIR8WPN:
+ case R_SH_DIR8WPZ:
+ insn += adjust / 2;
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, contents + nraddr);
+ break;
+
+ case R_SH_IND12W:
+ insn += adjust / 2;
+ if ((oinsn & 0xf000) != (insn & 0xf000))
+ overflow = true;
+ bfd_put_16 (abfd, insn, contents + nraddr);
+ break;
+
+ case R_SH_DIR8WPL:
+ BFD_ASSERT (adjust == count || count >= 4);
+ if (count >= 4)
+ insn += adjust / 4;
+ else
+ {
+ if ((irel->r_offset & 3) == 0)
+ ++insn;
+ }
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, contents + nraddr);
+ break;
+
+ case R_SH_SWITCH16:
+ voff += adjust;
+ if (voff < - 0x8000 || voff >= 0x8000)
+ overflow = true;
+ bfd_put_signed_16 (abfd, voff, contents + nraddr);
+ break;
+
+ case R_SH_SWITCH32:
+ voff += adjust;
+ bfd_put_signed_32 (abfd, voff, contents + nraddr);
+ break;
+
+ case R_SH_USES:
+ irel->r_addend += adjust;
+ break;
+ }
+
+ if (overflow)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
+ bfd_get_filename (abfd), (unsigned long) irel->r_offset));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ irel->r_offset = nraddr;
+ }
+
+ /* Look through all the other sections. If there contain any IMM32
+ relocs against internal symbols which we are not going to adjust
+ below, we may need to adjust the addends. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ Elf_Internal_Rela *internal_relocs;
+ Elf_Internal_Rela *irelscan, *irelscanend;
+ bfd_byte *ocontents;
+
+ if (o == sec
+ || (o->flags & SEC_RELOC) == 0
+ || o->reloc_count == 0)
+ continue;
+
+ /* We always cache the relocs. Perhaps, if info->keep_memory is
+ false, we should free them, if we are permitted to, when we
+ leave sh_coff_relax_section. */
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (abfd, o, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ true));
+ if (internal_relocs == NULL)
+ return false;
+
+ ocontents = NULL;
+ irelscanend = internal_relocs + o->reloc_count;
+ for (irelscan = internal_relocs; irelscan < irelscanend; irelscan++)
+ {
+ Elf_Internal_Sym sym;
+
+ if (ELF32_R_TYPE (irelscan->r_info) != (int) R_SH_DIR32)
+ continue;
+
+ if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+ continue;
+
+ bfd_elf32_swap_symbol_in (abfd,
+ extsyms + ELF32_R_SYM (irelscan->r_info),
+ &sym);
+
+ if (sym.st_shndx == shndx
+ && (sym.st_value <= addr
+ || sym.st_value >= toaddr))
+ {
+ bfd_vma val;
+
+ if (ocontents == NULL)
+ {
+ if (elf_section_data (o)->this_hdr.contents != NULL)
+ ocontents = elf_section_data (o)->this_hdr.contents;
+ else
+ {
+ /* We always cache the section contents.
+ Perhaps, if info->keep_memory is false, we
+ should free them, if we are permitted to,
+ when we leave sh_coff_relax_section. */
+ ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
+ if (ocontents == NULL)
+ return false;
+ if (! bfd_get_section_contents (abfd, o, ocontents,
+ (file_ptr) 0,
+ o->_raw_size))
+ return false;
+ elf_section_data (o)->this_hdr.contents = ocontents;
+ }
+ }
+
+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
+ val += sym.st_value;
+ if (val > addr && val < toaddr)
+ bfd_put_32 (abfd, val - count,
+ ocontents + irelscan->r_offset);
+ }
+ }
+ }
+
+ /* Adjust the local symbols defined in this section. */
+ esym = extsyms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; esym++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+
+ if (isym.st_shndx == shndx
+ && isym.st_value > addr
+ && isym.st_value < toaddr)
+ {
+ isym.st_value -= count;
+ bfd_elf32_swap_symbol_out (abfd, &isym, esym);
+ }
+ }
+
+ /* Now adjust the global symbols defined in this section. */
+ esym = extsyms + symtab_hdr->sh_info;
+ esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
+ for (index = 0; esym < esymend; esym++, index++)
+ {
+ Elf_Internal_Sym isym;
+
+ bfd_elf32_swap_symbol_in (abfd, esym, &isym);
+ sym_hash = elf_sym_hashes (abfd)[index];
+ if (isym.st_shndx == shndx
+ && ((sym_hash)->root.type == bfd_link_hash_defined
+ || (sym_hash)->root.type == bfd_link_hash_defweak)
+ && (sym_hash)->root.u.def.section == sec
+ && (sym_hash)->root.u.def.value > addr
+ && (sym_hash)->root.u.def.value < toaddr)
+ {
+ (sym_hash)->root.u.def.value -= count;
+ }
+ }
+
+ /* See if we can move the ALIGN reloc forward. We have adjusted
+ r_offset for it already. */
+ if (irelalign != NULL)
+ {
+ bfd_vma alignto, alignaddr;
+
+ alignto = BFD_ALIGN (toaddr, 1 << irelalign->r_addend);
+ alignaddr = BFD_ALIGN (irelalign->r_offset,
+ 1 << irelalign->r_addend);
+ if (alignto != alignaddr)
+ {
+ /* Tail recursion. */
+ return sh_elf_relax_delete_bytes (abfd, sec, alignaddr,
+ alignto - alignaddr);
+ }
+ }
+
+ return true;
+}
+
+/* Look for loads and stores which we can align to four byte
+ boundaries. This is like sh_align_loads in coff-sh.c. */
+
+static boolean
+sh_elf_align_loads (abfd, sec, internal_relocs, contents, pswapped)
+ bfd *abfd;
+ asection *sec;
+ Elf_Internal_Rela *internal_relocs;
+ bfd_byte *contents;
+ boolean *pswapped;
+{
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_vma *labels = NULL;
+ bfd_vma *label, *label_end;
+
+ *pswapped = false;
+
+ irelend = internal_relocs + sec->reloc_count;
+
+ /* Get all the addresses with labels on them. */
+ labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma));
+ if (labels == NULL)
+ goto error_return;
+ label_end = labels;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_LABEL)
+ {
+ *label_end = irel->r_offset;
+ ++label_end;
+ }
+ }
+
+ /* Note that the assembler currently always outputs relocs in
+ address order. If that ever changes, this code will need to sort
+ the label values and the relocs. */
+
+ label = labels;
+
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma start, stop;
+
+ if (ELF32_R_TYPE (irel->r_info) != (int) R_SH_CODE)
+ continue;
+
+ start = irel->r_offset;
+
+ for (irel++; irel < irelend; irel++)
+ if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_DATA)
+ break;
+ if (irel < irelend)
+ stop = irel->r_offset;
+ else
+ stop = sec->_cooked_size;
+
+ if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_elf_swap_insns,
+ (PTR) internal_relocs, &label,
+ label_end, start, stop, pswapped))
+ goto error_return;
+ }
+
+ free (labels);
+
+ return true;
+
+ error_return:
+ if (labels != NULL)
+ free (labels);
+ return false;
+}
+
+/* Swap two SH instructions. This is like sh_swap_insns in coff-sh.c. */
+
+static boolean
+sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
+ bfd *abfd;
+ asection *sec;
+ PTR relocs;
+ bfd_byte *contents;
+ bfd_vma addr;
+{
+ Elf_Internal_Rela *internal_relocs = (Elf_Internal_Rela *) relocs;
+ unsigned short i1, i2;
+ Elf_Internal_Rela *irel, *irelend;
+
+ /* Swap the instructions themselves. */
+ i1 = bfd_get_16 (abfd, contents + addr);
+ i2 = bfd_get_16 (abfd, contents + addr + 2);
+ bfd_put_16 (abfd, i2, contents + addr);
+ bfd_put_16 (abfd, i1, contents + addr + 2);
+
+ /* Adjust all reloc addresses. */
+ irelend = internal_relocs + sec->reloc_count;
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ enum elf_sh_reloc_type type;
+ int add;
+
+ /* There are a few special types of relocs that we don't want to
+ adjust. These relocs do not apply to the instruction itself,
+ but are only associated with the address. */
+ type = (enum elf_sh_reloc_type) ELF32_R_TYPE (irel->r_info);
+ if (type == R_SH_ALIGN
+ || type == R_SH_CODE
+ || type == R_SH_DATA
+ || type == R_SH_LABEL)
+ continue;
+
+ /* If an R_SH_USES reloc points to one of the addresses being
+ swapped, we must adjust it. It would be incorrect to do this
+ for a jump, though, since we want to execute both
+ instructions after the jump. (We have avoided swapping
+ around a label, so the jump will not wind up executing an
+ instruction it shouldn't). */
+ if (type == R_SH_USES)
+ {
+ bfd_vma off;
+
+ off = irel->r_offset + 4 + irel->r_addend;
+ if (off == addr)
+ irel->r_offset += 2;
+ else if (off == addr + 2)
+ irel->r_offset -= 2;
+ }
+
+ if (irel->r_offset == addr)
+ {
+ irel->r_offset += 2;
+ add = -2;
+ }
+ else if (irel->r_offset == addr + 2)
+ {
+ irel->r_offset -= 2;
+ add = 2;
+ }
+ else
+ add = 0;
+
+ if (add != 0)
+ {
+ bfd_byte *loc;
+ unsigned short insn, oinsn;
+ boolean overflow;
+
+ loc = contents + irel->r_offset;
+ overflow = false;
+ switch (type)
+ {
+ default:
+ break;
+
+ case R_SH_DIR8WPN:
+ case R_SH_DIR8WPZ:
+ insn = bfd_get_16 (abfd, loc);
+ oinsn = insn;
+ insn += add / 2;
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, loc);
+ break;
+
+ case R_SH_IND12W:
+ insn = bfd_get_16 (abfd, loc);
+ oinsn = insn;
+ insn += add / 2;
+ if ((oinsn & 0xf000) != (insn & 0xf000))
+ overflow = true;
+ bfd_put_16 (abfd, insn, loc);
+ break;
+
+ case R_SH_DIR8WPL:
+ /* This reloc ignores the least significant 3 bits of
+ the program counter before adding in the offset.
+ This means that if ADDR is at an even address, the
+ swap will not affect the offset. If ADDR is an at an
+ odd address, then the instruction will be crossing a
+ four byte boundary, and must be adjusted. */
+ if ((addr & 3) != 0)
+ {
+ insn = bfd_get_16 (abfd, loc);
+ oinsn = insn;
+ insn += add / 2;
+ if ((oinsn & 0xff00) != (insn & 0xff00))
+ overflow = true;
+ bfd_put_16 (abfd, insn, loc);
+ }
+
+ break;
+ }
+
+ if (overflow)
+ {
+ ((*_bfd_error_handler)
+ (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
+ bfd_get_filename (abfd), (unsigned long) irel->r_offset));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Relocate an SH ELF section. */
+
+static boolean
+sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ Elf_Internal_Rela *rel, *relend;
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ struct elf_link_hash_entry *h;
+ bfd_vma relocation;
+ bfd_vma addend = (bfd_vma)0;
+ bfd_reloc_status_type r;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ /* Many of the relocs are only used for relaxing, and are
+ handled entirely by the relaxation code. */
+ if (r_type > (int) R_SH_LAST_INVALID_RELOC)
+ continue;
+
+ if (r_type < 0
+ || r_type >= (int) R_SH_FIRST_INVALID_RELOC)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* FIXME: This is certainly incorrect. However, it is how the
+ COFF linker works. */
+ if (r_type != (int) R_SH_DIR32
+ && r_type != (int) R_SH_IND12W)
+ continue;
+
+ howto = sh_elf_howto_table + r_type;
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ /* There is nothing to be done for an internal IND12W
+ relocation. FIXME: This is probably wrong, but it's how
+ the COFF relocations work. */
+ if (r_type == (int) R_SH_IND12W)
+ continue;
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ /* FIXME: This is how the COFF relocations work. */
+ if (r_type == (int) R_SH_IND12W)
+ relocation -= 4;
+
+ switch ((int)r_type)
+ {
+ case (int)R_SH_DIR32:
+ addend = rel->r_addend;
+ break;
+ }
+
+ /* COFF relocs don't use the addend. The addend is used for R_SH_DIR32
+ to be compatible with other compilers. */
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, addend);
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* This is a version of bfd_generic_get_relocated_section_contents
+ which uses sh_elf_relocate_section. */
+
+static bfd_byte *
+sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
+ data, relocateable, symbols)
+ bfd *output_bfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *input_section = link_order->u.indirect.section;
+ bfd *input_bfd = input_section->owner;
+ asection **sections = NULL;
+ Elf_Internal_Rela *internal_relocs = NULL;
+ Elf32_External_Sym *external_syms = NULL;
+ Elf_Internal_Sym *internal_syms = NULL;
+
+ /* We only need to handle the case of relaxing, or of having a
+ particular set of section contents, specially. */
+ if (relocateable
+ || elf_section_data (input_section)->this_hdr.contents == NULL)
+ return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
+ link_order, data,
+ relocateable,
+ symbols);
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+
+ memcpy (data, elf_section_data (input_section)->this_hdr.contents,
+ input_section->_raw_size);
+
+ if ((input_section->flags & SEC_RELOC) != 0
+ && input_section->reloc_count > 0)
+ {
+ Elf_Internal_Sym *isymp;
+ asection **secpp;
+ Elf32_External_Sym *esym, *esymend;
+
+ if (symtab_hdr->contents != NULL)
+ external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ external_syms = ((Elf32_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf32_External_Sym)));
+ if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
+ symtab_hdr->sh_info, input_bfd)
+ != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ goto error_return;
+ }
+
+ internal_relocs = (_bfd_elf32_link_read_relocs
+ (input_bfd, input_section, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL, false));
+ if (internal_relocs == NULL)
+ goto error_return;
+
+ internal_syms = ((Elf_Internal_Sym *)
+ bfd_malloc (symtab_hdr->sh_info
+ * sizeof (Elf_Internal_Sym)));
+ if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ sections = (asection **) bfd_malloc (symtab_hdr->sh_info
+ * sizeof (asection *));
+ if (sections == NULL && symtab_hdr->sh_info > 0)
+ goto error_return;
+
+ isymp = internal_syms;
+ secpp = sections;
+ esym = external_syms;
+ esymend = esym + symtab_hdr->sh_info;
+ for (; esym < esymend; ++esym, ++isymp, ++secpp)
+ {
+ asection *isec;
+
+ bfd_elf32_swap_symbol_in (input_bfd, esym, isymp);
+
+ if (isymp->st_shndx == SHN_UNDEF)
+ isec = bfd_und_section_ptr;
+ else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
+ isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
+ else if (isymp->st_shndx == SHN_ABS)
+ isec = bfd_abs_section_ptr;
+ else if (isymp->st_shndx == SHN_COMMON)
+ isec = bfd_com_section_ptr;
+ else
+ {
+ /* Who knows? */
+ isec = NULL;
+ }
+
+ *secpp = isec;
+ }
+
+ if (! sh_elf_relocate_section (output_bfd, link_info, input_bfd,
+ input_section, data, internal_relocs,
+ internal_syms, sections))
+ goto error_return;
+
+ if (sections != NULL)
+ free (sections);
+ sections = NULL;
+ if (internal_syms != NULL)
+ free (internal_syms);
+ internal_syms = NULL;
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ external_syms = NULL;
+ if (internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ internal_relocs = NULL;
+ }
+
+ return data;
+
+ error_return:
+ if (internal_relocs != NULL
+ && internal_relocs != elf_section_data (input_section)->relocs)
+ free (internal_relocs);
+ if (external_syms != NULL && symtab_hdr->contents == NULL)
+ free (external_syms);
+ if (internal_syms != NULL)
+ free (internal_syms);
+ if (sections != NULL)
+ free (sections);
+ return NULL;
+}
+static asection *
+sh_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_SH_GNU_VTINHERIT:
+ case R_SH_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+ return NULL;
+}
+
+static boolean
+sh_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ /* we don't use got and plt entries for sh. */
+ return true;
+}
+
+/* Look through the relocs for a section during the first phase.
+ Since we don't do .gots or .plts, we just need to consider the
+ virtual table relocs for gc. */
+
+static boolean
+sh_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+
+ if (info->relocateable)
+ return true;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ sym_hashes_end -= symtab_hdr->sh_info;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ struct elf_link_hash_entry *h;
+ unsigned long r_symndx;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_SH_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_SH_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+ }
+ }
+
+ return true;
+}
+
+#define TARGET_BIG_SYM bfd_elf32_sh_vec
+#define TARGET_BIG_NAME "elf32-sh"
+#define TARGET_LITTLE_SYM bfd_elf32_shl_vec
+#define TARGET_LITTLE_NAME "elf32-shl"
+#define ELF_ARCH bfd_arch_sh
+#define ELF_MACHINE_CODE EM_SH
+#define ELF_MAXPAGESIZE 0x1
+
+#define elf_symbol_leading_char '_'
+
+#define bfd_elf32_bfd_reloc_type_lookup sh_elf_reloc_type_lookup
+#define elf_info_to_howto sh_elf_info_to_howto
+#define bfd_elf32_bfd_relax_section sh_elf_relax_section
+#define elf_backend_relocate_section sh_elf_relocate_section
+#define bfd_elf32_bfd_get_relocated_section_contents \
+ sh_elf_get_relocated_section_contents
+
+#define elf_backend_gc_mark_hook sh_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook sh_elf_gc_sweep_hook
+#define elf_backend_check_relocs sh_elf_check_relocs
+
+#define elf_backend_can_gc_sections 1
+#include "elf32-target.h"
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
new file mode 100644
index 00000000000..ec57c8cb35f
--- /dev/null
+++ b/bfd/elf32-sparc.c
@@ -0,0 +1,2059 @@
+/* SPARC-specific support for 32-bit ELF
+ Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/sparc.h"
+
+static reloc_howto_type *elf32_sparc_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void elf32_sparc_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+static boolean elf32_sparc_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static boolean elf32_sparc_adjust_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean elf32_sparc_adjust_dynindx
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf32_sparc_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf32_sparc_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean elf32_sparc_finish_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static boolean elf32_sparc_finish_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf32_sparc_merge_private_bfd_data PARAMS ((bfd *, bfd *));
+static boolean elf32_sparc_object_p
+ PARAMS ((bfd *));
+static void elf32_sparc_final_write_processing
+ PARAMS ((bfd *, boolean));
+
+/* The relocation "howto" table. */
+
+static bfd_reloc_status_type sparc_elf_notsupported_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type sparc_elf_wdisp16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+
+reloc_howto_type _bfd_sparc_elf_howto_table[] =
+{
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true),
+ HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true),
+ HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true),
+ HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true),
+ HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true),
+ HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0x00ffffff,true),
+ HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
+ HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
+ HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true),
+ HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
+ HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
+ HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true),
+ HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PLT32", false,0,0x00000000,true),
+ HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true),
+ HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true),
+ /* These are for sparc64 in a 64 bit environment.
+ Values need to be here because the table is indexed by reloc number. */
+ HOWTO(R_SPARC_64, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_64", false,0,0x00000000,true),
+ HOWTO(R_SPARC_OLO10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_OLO10", false,0,0x00000000,true),
+ HOWTO(R_SPARC_HH22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HH22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_HM10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HM10", false,0,0x00000000,true),
+ HOWTO(R_SPARC_LM22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LM22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PC_HH22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HH22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PC_HM10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HM10", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PC_LM22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_LM22", false,0,0x00000000,true),
+ /* End sparc64 in 64 bit environment values.
+ The following are for sparc64 in a 32 bit environment. */
+ HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
+ HOWTO(R_SPARC_WDISP19, 2,2,19,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
+ HOWTO(R_SPARC_UNUSED_42, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UNUSED_42",false,0,0x00000000,true),
+ HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true),
+ HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true),
+ HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_REV32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_REV32", false,0,0xffffffff,true),
+};
+static reloc_howto_type elf32_sparc_vtinherit_howto =
+ HOWTO (R_SPARC_GNU_VTINHERIT, 0,2,0,false,0,complain_overflow_dont, NULL, "R_SPARC_GNU_VTINHERIT", false,0, 0, false);
+static reloc_howto_type elf32_sparc_vtentry_howto =
+ HOWTO (R_SPARC_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_SPARC_GNU_VTENTRY", false,0,0, false);
+
+
+struct elf_reloc_map {
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static CONST struct elf_reloc_map sparc_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_SPARC_NONE, },
+ { BFD_RELOC_16, R_SPARC_16, },
+ { BFD_RELOC_8, R_SPARC_8 },
+ { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
+ { BFD_RELOC_CTOR, R_SPARC_32 },
+ { BFD_RELOC_32, R_SPARC_32 },
+ { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
+ { BFD_RELOC_HI22, R_SPARC_HI22 },
+ { BFD_RELOC_LO10, R_SPARC_LO10, },
+ { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
+ { BFD_RELOC_SPARC22, R_SPARC_22 },
+ { BFD_RELOC_SPARC13, R_SPARC_13 },
+ { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
+ { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
+ { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
+ { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
+ { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
+ { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
+ { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
+ { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
+ { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
+ { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
+ { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
+ /* ??? Doesn't dwarf use this? */
+/*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
+ {BFD_RELOC_SPARC_10, R_SPARC_10},
+ {BFD_RELOC_SPARC_11, R_SPARC_11},
+ {BFD_RELOC_SPARC_64, R_SPARC_64},
+ {BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
+ {BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
+ {BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
+ {BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
+ {BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
+ {BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
+ {BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
+ {BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
+ {BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
+ {BFD_RELOC_SPARC_7, R_SPARC_7},
+ {BFD_RELOC_SPARC_5, R_SPARC_5},
+ {BFD_RELOC_SPARC_6, R_SPARC_6},
+ {BFD_RELOC_SPARC_REV32, R_SPARC_REV32 },
+ {BFD_RELOC_VTABLE_INHERIT, R_SPARC_GNU_VTINHERIT},
+ {BFD_RELOC_VTABLE_ENTRY, R_SPARC_GNU_VTENTRY},
+};
+
+static reloc_howto_type *
+elf32_sparc_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ switch (code)
+ {
+ case BFD_RELOC_VTABLE_INHERIT:
+ return &elf32_sparc_vtinherit_howto;
+
+ case BFD_RELOC_VTABLE_ENTRY:
+ return &elf32_sparc_vtentry_howto;
+
+ default:
+ for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
+ {
+ if (sparc_reloc_map[i].bfd_reloc_val == code)
+ return &_bfd_sparc_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
+ }
+ }
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+}
+
+/* We need to use ELF32_R_TYPE so we have our own copy of this function,
+ and elf64-sparc.c has its own copy. */
+
+static void
+elf32_sparc_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf_Internal_Rela *dst;
+{
+ BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max);
+ cache_ptr->howto = &_bfd_sparc_elf_howto_table[ELF32_R_TYPE(dst->r_info)];
+}
+
+/* For unsupported relocs. */
+
+static bfd_reloc_status_type
+sparc_elf_notsupported_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return bfd_reloc_notsupported;
+}
+
+/* Handle the WDISP16 reloc. */
+
+static bfd_reloc_status_type
+sparc_elf_wdisp16_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_vma x;
+
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc_entry->howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (output_bfd != NULL)
+ return bfd_reloc_continue;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ relocation = (symbol->value
+ + symbol->section->output_section->vma
+ + symbol->section->output_offset);
+ relocation += reloc_entry->addend;
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ relocation -= reloc_entry->address;
+
+ x = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ x |= ((((relocation >> 2) & 0xc000) << 6)
+ | ((relocation >> 2) & 0x3fff));
+ bfd_put_32 (abfd, x, (bfd_byte *) data + reloc_entry->address);
+
+ if ((bfd_signed_vma) relocation < - 0x40000
+ || (bfd_signed_vma) relocation > 0x3ffff)
+ return bfd_reloc_overflow;
+ else
+ return bfd_reloc_ok;
+}
+
+/* Functions for the SPARC ELF linker. */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+
+/* The nop opcode we use. */
+
+#define SPARC_NOP 0x01000000
+
+/* The size in bytes of an entry in the procedure linkage table. */
+
+#define PLT_ENTRY_SIZE 12
+
+/* The first four entries in a procedure linkage table are reserved,
+ and the initial contents are unimportant (we zero them out).
+ Subsequent entries look like this. See the SVR4 ABI SPARC
+ supplement to see how this works. */
+
+/* sethi %hi(.-.plt0),%g1. We fill in the address later. */
+#define PLT_ENTRY_WORD0 0x03000000
+/* b,a .plt0. We fill in the offset later. */
+#define PLT_ENTRY_WORD1 0x30800000
+/* nop. */
+#define PLT_ENTRY_WORD2 SPARC_NOP
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+elf32_sparc_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sgot;
+ asection *srelgot;
+ asection *sreloc;
+
+ if (info->relocateable)
+ return true;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_offsets = elf_local_got_offsets (abfd);
+
+ sgot = NULL;
+ srelgot = NULL;
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_SPARC_GOT10:
+ case R_SPARC_GOT13:
+ case R_SPARC_GOT22:
+ /* This symbol requires a global offset table entry. */
+
+ if (dynobj == NULL)
+ {
+ /* Create the .got section. */
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+ }
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (srelgot == NULL
+ && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 2))
+ return false;
+ }
+ }
+
+ if (h != NULL)
+ {
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ h->got.offset = sgot->_raw_size;
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ srelgot->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ else
+ {
+ /* This is a global offset table entry for a local
+ symbol. */
+ if (local_got_offsets == NULL)
+ {
+ size_t size;
+ register unsigned int i;
+
+ size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
+ if (local_got_offsets == NULL)
+ return false;
+ elf_local_got_offsets (abfd) = local_got_offsets;
+ for (i = 0; i < symtab_hdr->sh_info; i++)
+ local_got_offsets[i] = (bfd_vma) -1;
+ }
+ if (local_got_offsets[r_symndx] != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ local_got_offsets[r_symndx] = sgot->_raw_size;
+
+ if (info->shared)
+ {
+ /* If we are generating a shared object, we need to
+ output a R_SPARC_RELATIVE reloc so that the
+ dynamic linker can adjust this GOT entry. */
+ srelgot->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ }
+
+ sgot->_raw_size += 4;
+
+ /* If the .got section is more than 0x1000 bytes, we add
+ 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13
+ bit relocations have a greater chance of working. */
+ if (sgot->_raw_size >= 0x1000
+ && elf_hash_table (info)->hgot->root.u.def.value == 0)
+ elf_hash_table (info)->hgot->root.u.def.value = 0x1000;
+
+ break;
+
+ case R_SPARC_WPLT30:
+ /* This symbol requires a procedure linkage table entry. We
+ actually build the entry in adjust_dynamic_symbol,
+ because this might be a case of linking PIC code without
+ linking in any dynamic objects, in which case we don't
+ need to generate a procedure linkage table after all. */
+
+ if (h == NULL)
+ {
+ /* The Solaris native assembler will generate a WPLT30
+ reloc for a local symbol if you assemble a call from
+ one section to another when using -K pic. We treat
+ it as WDISP30. */
+ break;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+
+ break;
+
+ case R_SPARC_PC10:
+ case R_SPARC_PC22:
+ if (h != NULL
+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* Fall through. */
+ case R_SPARC_DISP8:
+ case R_SPARC_DISP16:
+ case R_SPARC_DISP32:
+ case R_SPARC_WDISP30:
+ case R_SPARC_WDISP22:
+ case R_SPARC_WDISP19:
+ case R_SPARC_WDISP16:
+ /* If we are linking with -Bsymbolic, we do not need to copy
+ a PC relative reloc against a global symbol which is
+ defined in an object we are including in the link (i.e.,
+ DEF_REGULAR is set). FIXME: At this point we have not
+ seen all the input files, so it is possible that
+ DEF_REGULAR is not set now but will be set later (it is
+ never cleared). This needs to be handled as in
+ elf32-i386.c. */
+ if (h == NULL
+ || (info->symbolic
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) != 0))
+ break;
+ /* Fall through. */
+ case R_SPARC_8:
+ case R_SPARC_16:
+ case R_SPARC_32:
+ case R_SPARC_HI22:
+ case R_SPARC_22:
+ case R_SPARC_13:
+ case R_SPARC_LO10:
+ case R_SPARC_UA32:
+ if (info->shared)
+ {
+ /* When creating a shared object, we must copy these
+ relocs into the output file. We create a reloc
+ section in dynobj and make room for the reloc. */
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ }
+
+ sreloc->_raw_size += sizeof (Elf32_External_Rela);
+ }
+
+ break;
+
+ case R_SPARC_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ case R_SPARC_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+static asection *
+elf32_sparc_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_SPARC_GNU_VTINHERIT:
+ case R_SPARC_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+static boolean
+elf32_sparc_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel, *relend;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; rel++)
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_SPARC_GOT10:
+ case R_SPARC_GOT13:
+ case R_SPARC_GOT22:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->got.refcount > 0)
+ h->got.refcount--;
+ }
+ else
+ {
+ if (local_got_refcounts[r_symndx] > 0)
+ local_got_refcounts[r_symndx]--;
+ }
+ break;
+
+ case R_SPARC_PLT32:
+ case R_SPARC_HIPLT22:
+ case R_SPARC_LOPLT10:
+ case R_SPARC_PCPLT32:
+ case R_SPARC_PCPLT10:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->plt.refcount > 0)
+ h->plt.refcount--;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf32_sparc_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj;
+ asection *s;
+ unsigned int power_of_two;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+ /* If this is a function, put it in the procedure linkage table. We
+ will fill in the contents of the procedure linkage table later
+ (although we could actually do it here). The STT_NOTYPE
+ condition is a hack specifically for the Oracle libraries
+ delivered for Solaris; for some inexplicable reason, they define
+ some of their functions as STT_NOTYPE when they really should be
+ STT_FUNC. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
+ || (h->type == STT_NOTYPE
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->flags & SEC_CODE) != 0))
+ {
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || ((!info->shared || info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) != 0))
+ {
+ /* This case can occur if we saw a WPLT30 reloc in an input
+ file, but none of the input files were dynamic objects.
+ Or, when linking the main application or a -Bsymbolic
+ shared library against PIC code. Or when a global symbol
+ has been made private, e.g. via versioning.
+
+ In these cases we know what value the symbol will resolve
+ to, so we don't actually need to build a procedure linkage
+ table, and we can just do a WDISP30 reloc instead. */
+
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ return true;
+ }
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+
+ /* The first four entries in .plt are reserved. */
+ if (s->_raw_size == 0)
+ s->_raw_size = 4 * PLT_ENTRY_SIZE;
+
+ /* The procedure linkage table has a maximum size. */
+ if (s->_raw_size >= 0x400000)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+ }
+
+ h->plt.offset = s->_raw_size;
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .rela.plt section. */
+
+ s = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += sizeof (Elf32_External_Rela);
+
+ return true;
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ BFD_ASSERT (s != NULL);
+
+ /* We must generate a R_SPARC_COPY reloc to tell the dynamic linker
+ to copy the initial value out of the dynamic object and into the
+ runtime process image. We need to remember the offset into the
+ .rel.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ asection *srel;
+
+ srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf32_External_Rela);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 3)
+ power_of_two = 3;
+
+ /* Apply the required alignment. */
+ s->_raw_size = BFD_ALIGN (s->_raw_size,
+ (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ {
+ if (! bfd_set_section_alignment (dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf32_sparc_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean reltext;
+ boolean relplt;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+
+ /* Make space for the trailing nop in .plt. */
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+ if (s->_raw_size > 0)
+ s->_raw_size += 4;
+ }
+ else
+ {
+ /* We may have created entries in the .rela.got section.
+ However, if we are not creating the dynamic sections, we will
+ not actually use these entries. Reset the size of .rela.got,
+ which will cause it to get stripped from the output file
+ below. */
+ s = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (s != NULL)
+ s->_raw_size = 0;
+ }
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ reltext = false;
+ relplt = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ strip = false;
+
+ if (strncmp (name, ".rela", 5) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is to handle .rela.bss and
+ .rel.plt. We must create it in
+ create_dynamic_sections, because it must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ strip = true;
+ }
+ else
+ {
+ const char *outname;
+ asection *target;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL entry. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 5);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ reltext = true;
+
+ if (strcmp (name, ".rela.plt") == 0)
+ relplt = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strcmp (name, ".plt") != 0
+ && strcmp (name, ".got") != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ _bfd_strip_section_from_output (s);
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf32_sparc_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (! info->shared)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (relplt)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
+ sizeof (Elf32_External_Rela)))
+ return false;
+
+ if (reltext)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ /* If we are generating a shared library, we generate a section
+ symbol for each output section for which we might need to copy
+ relocs. These are local symbols, which means that they must come
+ first in the dynamic symbol table. That means we must increment
+ the dynamic symbol index of every other dynamic symbol. */
+ if (info->shared)
+ {
+ int c;
+
+ c = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) != 0
+ || (s->flags & SEC_ALLOC) == 0)
+ continue;
+
+ elf_section_data (s)->dynindx = c + 1;
+
+ /* These symbols will have no names, so we don't need to
+ fiddle with dynstr_index. */
+
+ ++c;
+ }
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf32_sparc_adjust_dynindx,
+ (PTR) &c);
+ elf_hash_table (info)->dynsymcount += c;
+ }
+
+ return true;
+}
+
+/* Increment the index of a dynamic symbol by a given amount. Called
+ via elf_link_hash_traverse. */
+
+static boolean
+elf32_sparc_adjust_dynindx (h, cparg)
+ struct elf_link_hash_entry *h;
+ PTR cparg;
+{
+ int *cp = (int *) cparg;
+
+ if (h->dynindx != -1)
+ h->dynindx += *cp;
+ return true;
+}
+
+/* Relocate a SPARC ELF section. */
+
+static boolean
+elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ bfd_vma got_base;
+ asection *sgot;
+ asection *splt;
+ asection *sreloc;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ if (elf_hash_table (info)->hgot == NULL)
+ got_base = 0;
+ else
+ got_base = elf_hash_table (info)->hgot->root.u.def.value;
+
+ sgot = NULL;
+ splt = NULL;
+ sreloc = NULL;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ if (r_type == R_SPARC_GNU_VTINHERIT
+ || r_type == R_SPARC_GNU_VTENTRY)
+ continue;
+
+ if (r_type < 0 || r_type >= (int) R_SPARC_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ howto = _bfd_sparc_elf_howto_table + r_type;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ if ((r_type == R_SPARC_WPLT30
+ && h->plt.offset != (bfd_vma) -1)
+ || ((r_type == R_SPARC_GOT10
+ || r_type == R_SPARC_GOT13
+ || r_type == R_SPARC_GOT22)
+ && elf_hash_table (info)->dynamic_sections_created
+ && (! info->shared
+ || (! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ || (info->shared
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ && (r_type == R_SPARC_8
+ || r_type == R_SPARC_16
+ || r_type == R_SPARC_32
+ || r_type == R_SPARC_DISP8
+ || r_type == R_SPARC_DISP16
+ || r_type == R_SPARC_DISP32
+ || r_type == R_SPARC_WDISP30
+ || r_type == R_SPARC_WDISP22
+ || r_type == R_SPARC_WDISP19
+ || r_type == R_SPARC_WDISP16
+ || r_type == R_SPARC_HI22
+ || r_type == R_SPARC_22
+ || r_type == R_SPARC_13
+ || r_type == R_SPARC_LO10
+ || r_type == R_SPARC_UA32
+ || ((r_type == R_SPARC_PC10
+ || r_type == R_SPARC_PC22)
+ && strcmp (h->root.root.string,
+ "_GLOBAL_OFFSET_TABLE_") != 0))))
+ {
+ /* In these cases, we don't need the relocation
+ value. We check specially because in some
+ obscure cases sec->output_section will be NULL. */
+ relocation = 0;
+ }
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ switch (r_type)
+ {
+ case R_SPARC_GOT10:
+ case R_SPARC_GOT13:
+ case R_SPARC_GOT22:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (h != NULL)
+ {
+ bfd_vma off;
+
+ off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 4, we use the
+ least significant bit to record whether we have
+ initialized it already.
+
+ When doing a dynamic link, we create a .rela.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation,
+ sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+
+ relocation = sgot->output_offset + off - got_base;
+ }
+ else
+ {
+ bfd_vma off;
+
+ BFD_ASSERT (local_got_offsets != NULL
+ && local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use
+ the least significant bit to record whether we have
+ already processed this entry. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation, sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+
+ /* We need to generate a R_SPARC_RELATIVE reloc
+ for the dynamic linker. */
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
+ outrel.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+ (((Elf32_External_Rela *)
+ srelgot->contents)
+ + srelgot->reloc_count));
+ ++srelgot->reloc_count;
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+
+ relocation = sgot->output_offset + off - got_base;
+ }
+
+ break;
+
+ case R_SPARC_WPLT30:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+
+ /* The Solaris native assembler will generate a WPLT30 reloc
+ for a local symbol if you assemble a call from one
+ section to another when using -K pic. We treat it as
+ WDISP30. */
+ if (h == NULL)
+ break;
+
+ if (h->plt.offset == (bfd_vma) -1)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ break;
+ }
+
+ if (splt == NULL)
+ {
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL);
+ }
+
+ relocation = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+ break;
+
+ case R_SPARC_PC10:
+ case R_SPARC_PC22:
+ if (h != NULL
+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* Fall through. */
+ case R_SPARC_DISP8:
+ case R_SPARC_DISP16:
+ case R_SPARC_DISP32:
+ case R_SPARC_WDISP30:
+ case R_SPARC_WDISP22:
+ case R_SPARC_WDISP19:
+ case R_SPARC_WDISP16:
+ if (h == NULL
+ || (info->symbolic
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) != 0))
+ break;
+ /* Fall through. */
+ case R_SPARC_8:
+ case R_SPARC_16:
+ case R_SPARC_32:
+ case R_SPARC_HI22:
+ case R_SPARC_22:
+ case R_SPARC_13:
+ case R_SPARC_LO10:
+ case R_SPARC_UA32:
+ if (info->shared)
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip;
+
+ /* When generating a shared object, these relocations
+ are copied into the output file to be resolved at run
+ time. */
+
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd,
+ elf_elfheader (input_bfd)->e_shstrndx,
+ elf_section_data (input_section)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (input_bfd,
+ input_section),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ memset (&outrel, 0, sizeof outrel);
+ /* h->dynindx may be -1 if the symbol was marked to
+ become local. */
+ else if (h != NULL
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
+ outrel.r_addend = rel->r_addend;
+ }
+ else
+ {
+ if (r_type == R_SPARC_32)
+ {
+ outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ else
+ {
+ long indx;
+
+ if (h == NULL)
+ sec = local_sections[r_symndx];
+ else
+ {
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || (h->root.type
+ == bfd_link_hash_defweak));
+ sec = h->root.u.def.section;
+ }
+ if (sec != NULL && bfd_is_abs_section (sec))
+ indx = 0;
+ else if (sec == NULL || sec->owner == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else
+ {
+ asection *osec;
+
+ osec = sec->output_section;
+ indx = elf_section_data (osec)->dynindx;
+
+ /* FIXME: we really should be able to link non-pic
+ shared libraries. */
+ if (indx == 0)
+ {
+ BFD_FAIL ();
+ (*_bfd_error_handler)
+ (_("%s: probably compiled without -fPIC?"),
+ bfd_get_filename (input_bfd));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ outrel.r_info = ELF32_R_INFO (indx, r_type);
+
+ /* For non-RELATIVE dynamic relocations, we keep the
+ same symbol, and so generally the same addend. But
+ we do need to adjust those relocations referencing
+ sections. */
+ outrel.r_addend = rel->r_addend;
+ if (r_symndx < symtab_hdr->sh_info
+ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ outrel.r_addend += sec->output_offset+sym->st_value;
+ }
+ }
+
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+ (((Elf32_External_Rela *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ /* This reloc will be computed at runtime, so there's no
+ need to do anything now, unless this is a RELATIVE
+ reloc in an unallocated section. */
+ if (skip
+ || (input_section->flags & SEC_ALLOC) != 0
+ || ELF32_R_TYPE (outrel.r_info) != R_SPARC_RELATIVE)
+ continue;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (r_type == R_SPARC_WDISP16)
+ {
+ bfd_vma x;
+
+ relocation += rel->r_addend;
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ relocation -= rel->r_offset;
+
+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ x |= ((((relocation >> 2) & 0xc000) << 6)
+ | ((relocation >> 2) & 0x3fff));
+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
+
+ if ((bfd_signed_vma) relocation < - 0x40000
+ || (bfd_signed_vma) relocation > 0x3ffff)
+ r = bfd_reloc_overflow;
+ else
+ r = bfd_reloc_ok;
+ }
+ else if (r_type == R_SPARC_REV32)
+ {
+ bfd_vma x;
+
+ relocation = relocation + rel->r_addend;
+
+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ x = x + relocation;
+ bfd_putl32 (/*input_bfd,*/ x, contents + rel->r_offset);
+ r = bfd_reloc_ok;
+ }
+ else
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection *splt;
+ asection *srela;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (splt != NULL && srela != NULL);
+
+ /* Fill in the entry in the procedure linkage table. */
+ bfd_put_32 (output_bfd,
+ PLT_ENTRY_WORD0 + h->plt.offset,
+ splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd,
+ (PLT_ENTRY_WORD1
+ + (((- (h->plt.offset + 4)) >> 2) & 0x3fffff)),
+ splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
+ splt->contents + h->plt.offset + 8);
+
+ /* Fill in the entry in the .rela.plt section. */
+ rela.r_offset = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
+ rela.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) srela->contents
+ + h->plt.offset / PLT_ENTRY_SIZE - 4));
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ the .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ asection *sgot;
+ asection *srela;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srela = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (sgot != NULL && srela != NULL);
+
+ rela.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + (h->got.offset &~ 1));
+
+ /* If this is a -Bsymbolic link, and the symbol is defined
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
+ if (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ rela.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
+ else
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_GLOB_DAT);
+ }
+
+ rela.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) srela->contents
+ + srela->reloc_count));
+ ++srela->reloc_count;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ asection *s;
+ Elf_Internal_Rela rela;
+
+ /* This symbols needs a copy reloc. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rela.bss");
+ BFD_ASSERT (s != NULL);
+
+ rela.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_COPY);
+ rela.r_addend = 0;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela,
+ ((Elf32_External_Rela *) s->contents
+ + s->reloc_count));
+ ++s->reloc_count;
+ }
+
+ /* Mark some specially defined symbols as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
+ || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf32_sparc_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *sdyn;
+ asection *sgot;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ boolean size;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ case DT_PLTGOT: name = ".plt"; size = false; break;
+ case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
+ case DT_JMPREL: name = ".rela.plt"; size = false; break;
+ default: name = NULL; size = false; break;
+ }
+
+ if (name != NULL)
+ {
+ asection *s;
+
+ s = bfd_get_section_by_name (output_bfd, name);
+ if (s == NULL)
+ dyn.d_un.d_val = 0;
+ else
+ {
+ if (! size)
+ dyn.d_un.d_ptr = s->vma;
+ else
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ }
+ }
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ }
+ }
+
+ /* Clear the first four entries in the procedure linkage table,
+ and put a nop in the last four bytes. */
+ if (splt->_raw_size > 0)
+ {
+ memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
+ bfd_put_32 (output_bfd, SPARC_NOP,
+ splt->contents + splt->_raw_size - 4);
+ }
+
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize =
+ PLT_ENTRY_SIZE;
+ }
+
+ /* Set the first entry in the global offset table to the address of
+ the dynamic section. */
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ if (sgot->_raw_size > 0)
+ {
+ if (sdyn == NULL)
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
+ else
+ bfd_put_32 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ sgot->contents);
+ }
+
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+
+ if (info->shared)
+ {
+ asection *sdynsym;
+ asection *s;
+ Elf_Internal_Sym sym;
+ int c;
+
+ /* Set up the section symbols for the output sections. */
+
+ sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (sdynsym != NULL);
+
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_other = 0;
+
+ c = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ int indx;
+
+ if (elf_section_data (s)->dynindx == 0)
+ continue;
+
+ sym.st_value = s->vma;
+
+ indx = elf_section_data (s)->this_idx;
+ BFD_ASSERT (indx > 0);
+ sym.st_shndx = indx;
+
+ bfd_elf32_swap_symbol_out (output_bfd, &sym,
+ (PTR) (((Elf32_External_Sym *)
+ sdynsym->contents)
+ + elf_section_data (s)->dynindx));
+
+ ++c;
+ }
+
+ /* Set the sh_info field of the output .dynsym section to the
+ index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info = c + 1;
+ }
+
+ return true;
+}
+
+/* Functions for dealing with the e_flags field.
+
+ We don't define set_private_flags or copy_private_bfd_data because
+ the only currently defined values are based on the bfd mach number,
+ so we use the latter instead and defer setting e_flags until the
+ file is written out. */
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+
+static boolean
+elf32_sparc_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ boolean error;
+ static int previous_ibfd_e_flags = -1;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ error = false;
+
+#if 0
+ /* ??? The native linker doesn't do this so we can't (otherwise gcc would
+ have to know which linker is being used). Instead, the native linker
+ bumps up the architecture level when it has to. However, I still think
+ warnings like these are good, so it would be nice to have them turned on
+ by some option. */
+
+ /* If the output machine is normal sparc, we can't allow v9 input files. */
+ if (bfd_get_mach (obfd) == bfd_mach_sparc
+ && (bfd_get_mach (ibfd) == bfd_mach_sparc_v8plus
+ || bfd_get_mach (ibfd) == bfd_mach_sparc_v8plusa))
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: compiled for a v8plus system and target is v8"),
+ bfd_get_filename (ibfd));
+ }
+ /* If the output machine is v9, we can't allow v9+vis input files. */
+ if (bfd_get_mach (obfd) == bfd_mach_sparc_v8plus
+ && bfd_get_mach (ibfd) == bfd_mach_sparc_v8plusa)
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: compiled for a v8plusa system and target is v8plus"),
+ bfd_get_filename (ibfd));
+ }
+#else
+ if (bfd_get_mach (ibfd) >= bfd_mach_sparc_v9)
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: compiled for a 64 bit system and target is 32 bit"),
+ bfd_get_filename (ibfd));
+ }
+ else if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
+ bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
+#endif
+
+ if (((elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA)
+ != previous_ibfd_e_flags)
+ && previous_ibfd_e_flags >= 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: linking little endian files with big endian files"),
+ bfd_get_filename (ibfd));
+ error = true;
+ }
+ previous_ibfd_e_flags = elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA;
+
+ if (error)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ return true;
+}
+
+/* Set the right machine number. */
+
+static boolean
+elf32_sparc_object_p (abfd)
+ bfd *abfd;
+{
+ if (elf_elfheader (abfd)->e_machine == EM_SPARC32PLUS)
+ {
+ if (elf_elfheader (abfd)->e_flags & EF_SPARC_SUN_US1)
+ return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
+ bfd_mach_sparc_v8plusa);
+ else if (elf_elfheader (abfd)->e_flags & EF_SPARC_32PLUS)
+ return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
+ bfd_mach_sparc_v8plus);
+ else
+ return false;
+ }
+ else if (elf_elfheader (abfd)->e_flags & EF_SPARC_LEDATA)
+ return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
+ bfd_mach_sparc_sparclite_le);
+ else
+ return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc);
+}
+
+/* The final processing done just before writing out the object file.
+ We need to set the e_machine field appropriately. */
+
+static void
+elf32_sparc_final_write_processing (abfd, linker)
+ bfd *abfd;
+ boolean linker;
+{
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_sparc :
+ break; /* nothing to do */
+ case bfd_mach_sparc_v8plus :
+ elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
+ elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
+ elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS;
+ break;
+ case bfd_mach_sparc_v8plusa :
+ elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
+ elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
+ elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1;
+ break;
+ case bfd_mach_sparc_sparclite_le :
+ elf_elfheader (abfd)->e_machine = EM_SPARC;
+ elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
+ break;
+ default :
+ abort ();
+ break;
+ }
+}
+
+#define TARGET_BIG_SYM bfd_elf32_sparc_vec
+#define TARGET_BIG_NAME "elf32-sparc"
+#define ELF_ARCH bfd_arch_sparc
+#define ELF_MACHINE_CODE EM_SPARC
+#define ELF_MACHINE_ALT1 EM_SPARC32PLUS
+#define ELF_MAXPAGESIZE 0x10000
+
+#define bfd_elf32_bfd_reloc_type_lookup elf32_sparc_reloc_type_lookup
+#define elf_info_to_howto elf32_sparc_info_to_howto
+#define elf_backend_create_dynamic_sections \
+ _bfd_elf_create_dynamic_sections
+#define elf_backend_check_relocs elf32_sparc_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+ elf32_sparc_adjust_dynamic_symbol
+#define elf_backend_size_dynamic_sections \
+ elf32_sparc_size_dynamic_sections
+#define elf_backend_relocate_section elf32_sparc_relocate_section
+#define elf_backend_finish_dynamic_symbol \
+ elf32_sparc_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ elf32_sparc_finish_dynamic_sections
+#define bfd_elf32_bfd_merge_private_bfd_data \
+ elf32_sparc_merge_private_bfd_data
+#define elf_backend_object_p elf32_sparc_object_p
+#define elf_backend_final_write_processing \
+ elf32_sparc_final_write_processing
+#define elf_backend_gc_mark_hook elf32_sparc_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf32_sparc_gc_sweep_hook
+
+#define elf_backend_can_gc_sections 1
+#define elf_backend_want_got_plt 0
+#define elf_backend_plt_readonly 0
+#define elf_backend_want_plt_sym 1
+#define elf_backend_got_header_size 4
+#define elf_backend_plt_header_size (4*PLT_ENTRY_SIZE)
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
new file mode 100644
index 00000000000..e71353df55f
--- /dev/null
+++ b/bfd/elf32-v850.c
@@ -0,0 +1,2230 @@
+/* V850-specific support for 32-bit ELF
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+
+/* XXX FIXME: This code is littered with 32bit int, 16bit short, 8bit char
+ dependencies. As is the gas & simulator code or the v850. */
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/v850.h"
+
+/* sign-extend a 24-bit number */
+#define SEXT24(x) ((((x) & 0xffffff) ^ (~ 0x7fffff)) + 0x800000)
+
+static reloc_howto_type *v850_elf_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void v850_elf_info_to_howto_rel
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+static void v850_elf_info_to_howto_rela
+ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static bfd_reloc_status_type v850_elf_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static boolean v850_elf_is_local_label_name
+ PARAMS ((bfd *, const char *));
+static boolean v850_elf_relocate_section
+ PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static bfd_reloc_status_type v850_elf_perform_relocation
+ PARAMS ((bfd *, int, bfd_vma, bfd_byte *));
+static boolean v850_elf_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
+static void remember_hi16s_reloc
+ PARAMS ((bfd *, bfd_vma, bfd_byte *));
+static bfd_byte * find_remembered_hi16s_reloc
+ PARAMS ((bfd_vma, boolean *));
+static bfd_reloc_status_type v850_elf_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *, bfd_vma,
+ bfd_vma, bfd_vma, struct bfd_link_info *, asection *, int));
+static boolean v850_elf_object_p
+ PARAMS ((bfd *));
+static boolean v850_elf_fake_sections
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+static void v850_elf_final_write_processing
+ PARAMS ((bfd *, boolean));
+static boolean v850_elf_set_private_flags
+ PARAMS ((bfd *, flagword));
+static boolean v850_elf_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean v850_elf_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean v850_elf_print_private_bfd_data
+ PARAMS ((bfd *, PTR));
+static boolean v850_elf_section_from_bfd_section
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
+static void v850_elf_symbol_processing
+ PARAMS ((bfd *, asymbol *));
+static boolean v850_elf_add_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+ const char **, flagword *, asection **, bfd_vma *));
+static boolean v850_elf_link_output_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const char *,
+ Elf_Internal_Sym *, asection *));
+static boolean v850_elf_section_from_shdr
+ PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
+
+/* Note: It is REQUIRED that the 'type' value of each entry in this array
+ match the index of the entry in the array. */
+static reloc_howto_type v850_elf_howto_table[] =
+{
+ /* This reloc does nothing. */
+ HOWTO (R_V850_NONE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_V850_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A PC relative 9 bit branch. */
+ HOWTO (R_V850_9_PCREL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_9_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x00ffffff, /* src_mask */
+ 0x00ffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A PC relative 22 bit branch. */
+ HOWTO (R_V850_22_PCREL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 22, /* bitsize */
+ true, /* pc_relative */
+ 7, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_22_PCREL", /* name */
+ false, /* partial_inplace */
+ 0x07ffff80, /* src_mask */
+ 0x07ffff80, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* High 16 bits of symbol value. */
+ HOWTO (R_V850_HI16_S, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_HI16_S", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of symbol value. */
+ HOWTO (R_V850_HI16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_HI16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of symbol value. */
+ HOWTO (R_V850_LO16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_LO16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Simple 32bit reloc. */
+ HOWTO (R_V850_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Simple 16bit reloc. */
+ HOWTO (R_V850_16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_V850_16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Simple 8bit reloc. */
+ HOWTO (R_V850_8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_V850_8", /* name */
+ true, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit offset from the short data area pointer. */
+ HOWTO (R_V850_SDA_16_16_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_SDA_16_16_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 15 bit offset from the short data area pointer. */
+ HOWTO (R_V850_SDA_15_16_OFFSET, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_SDA_15_16_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0xfffe, /* src_mask */
+ 0xfffe, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit offset from the zero data area pointer. */
+ HOWTO (R_V850_ZDA_16_16_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_ZDA_16_16_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 15 bit offset from the zero data area pointer. */
+ HOWTO (R_V850_ZDA_15_16_OFFSET, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_ZDA_15_16_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0xfffe, /* src_mask */
+ 0xfffe, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 6 bit offset from the tiny data area pointer. */
+ HOWTO (R_V850_TDA_6_8_OFFSET, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_TDA_6_8_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0x7e, /* src_mask */
+ 0x7e, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 8 bit offset from the tiny data area pointer. */
+ HOWTO (R_V850_TDA_7_8_OFFSET, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_TDA_7_8_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0x7f, /* src_mask */
+ 0x7f, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 7 bit offset from the tiny data area pointer. */
+ HOWTO (R_V850_TDA_7_7_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 7, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_TDA_7_7_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0x7f, /* src_mask */
+ 0x7f, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit offset from the tiny data area pointer! */
+ HOWTO (R_V850_TDA_16_16_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_TDA_16_16_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xfff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 5 bit offset from the tiny data area pointer. */
+ HOWTO (R_V850_TDA_4_5_OFFSET, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 5, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_TDA_4_5_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0x0f, /* src_mask */
+ 0x0f, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 4 bit offset from the tiny data area pointer. */
+ HOWTO (R_V850_TDA_4_4_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 4, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_TDA_4_4_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0x0f, /* src_mask */
+ 0x0f, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit offset from the short data area pointer. */
+ HOWTO (R_V850_SDA_16_16_SPLIT_OFFSET, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_SDA_16_16_SPLIT_OFFSET",/* name */
+ false, /* partial_inplace */
+ 0xfffe0020, /* src_mask */
+ 0xfffe0020, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit offset from the zero data area pointer. */
+ HOWTO (R_V850_ZDA_16_16_SPLIT_OFFSET, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_ZDA_16_16_SPLIT_OFFSET",/* name */
+ false, /* partial_inplace */
+ 0xfffe0020, /* src_mask */
+ 0xfffe0020, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 6 bit offset from the call table base pointer. */
+ HOWTO (R_V850_CALLT_6_7_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 7, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_CALLT_6_7_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0x3f, /* src_mask */
+ 0x3f, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit offset from the call table base pointer. */
+ HOWTO (R_V850_CALLT_16_16_OFFSET, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ v850_elf_reloc, /* special_function */
+ "R_V850_CALLT_16_16_OFFSET", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_V850_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_V850_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_V850_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_V850_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+/* Map BFD reloc types to V850 ELF reloc types. */
+
+struct v850_elf_reloc_map
+{
+ /* BFD_RELOC_V850_CALLT_16_16_OFFSET is 258, which will not fix in an
+ unsigned char. */
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static const struct v850_elf_reloc_map v850_elf_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_V850_NONE },
+ { BFD_RELOC_V850_9_PCREL, R_V850_9_PCREL },
+ { BFD_RELOC_V850_22_PCREL, R_V850_22_PCREL },
+ { BFD_RELOC_HI16_S, R_V850_HI16_S },
+ { BFD_RELOC_HI16, R_V850_HI16 },
+ { BFD_RELOC_LO16, R_V850_LO16 },
+ { BFD_RELOC_32, R_V850_32 },
+ { BFD_RELOC_16, R_V850_16 },
+ { BFD_RELOC_8, R_V850_8 },
+ { BFD_RELOC_V850_SDA_16_16_OFFSET, R_V850_SDA_16_16_OFFSET },
+ { BFD_RELOC_V850_SDA_15_16_OFFSET, R_V850_SDA_15_16_OFFSET },
+ { BFD_RELOC_V850_ZDA_16_16_OFFSET, R_V850_ZDA_16_16_OFFSET },
+ { BFD_RELOC_V850_ZDA_15_16_OFFSET, R_V850_ZDA_15_16_OFFSET },
+ { BFD_RELOC_V850_TDA_6_8_OFFSET, R_V850_TDA_6_8_OFFSET },
+ { BFD_RELOC_V850_TDA_7_8_OFFSET, R_V850_TDA_7_8_OFFSET },
+ { BFD_RELOC_V850_TDA_7_7_OFFSET, R_V850_TDA_7_7_OFFSET },
+ { BFD_RELOC_V850_TDA_16_16_OFFSET, R_V850_TDA_16_16_OFFSET },
+ { BFD_RELOC_V850_TDA_4_5_OFFSET, R_V850_TDA_4_5_OFFSET },
+ { BFD_RELOC_V850_TDA_4_4_OFFSET, R_V850_TDA_4_4_OFFSET },
+ { BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET, R_V850_SDA_16_16_SPLIT_OFFSET },
+ { BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET, R_V850_ZDA_16_16_SPLIT_OFFSET },
+ { BFD_RELOC_V850_CALLT_6_7_OFFSET, R_V850_CALLT_6_7_OFFSET },
+ { BFD_RELOC_V850_CALLT_16_16_OFFSET, R_V850_CALLT_16_16_OFFSET },
+ { BFD_RELOC_VTABLE_INHERIT, R_V850_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_V850_GNU_VTENTRY },
+
+};
+
+
+/* Map a bfd relocation into the appropriate howto structure */
+static reloc_howto_type *
+v850_elf_reloc_type_lookup (abfd, code)
+ bfd * abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (v850_elf_reloc_map) / sizeof (struct v850_elf_reloc_map);
+ i++)
+ {
+ if (v850_elf_reloc_map[i].bfd_reloc_val == code)
+ {
+ BFD_ASSERT (v850_elf_howto_table[v850_elf_reloc_map[i].elf_reloc_val].type == v850_elf_reloc_map[i].elf_reloc_val);
+
+ return & v850_elf_howto_table[v850_elf_reloc_map[i].elf_reloc_val];
+ }
+ }
+
+ return NULL;
+}
+
+
+/* Set the howto pointer for an V850 ELF reloc. */
+static void
+v850_elf_info_to_howto_rel (abfd, cache_ptr, dst)
+ bfd * abfd;
+ arelent * cache_ptr;
+ Elf32_Internal_Rel * dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_V850_max);
+ cache_ptr->howto = &v850_elf_howto_table[r_type];
+}
+
+/* Set the howto pointer for a V850 ELF reloc (type RELA). */
+static void
+v850_elf_info_to_howto_rela (abfd, cache_ptr, dst)
+ bfd * abfd;
+ arelent * cache_ptr;
+ Elf32_Internal_Rela *dst;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_V850_max);
+ cache_ptr->howto = &v850_elf_howto_table[r_type];
+}
+
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+v850_elf_check_relocs (abfd, info, sec, relocs)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ asection * sec;
+ const Elf_Internal_Rela * relocs;
+{
+ boolean ret = true;
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sreloc;
+ enum v850_reloc_type r_type;
+ int other = 0;
+ const char *common = (const char *)0;
+
+ if (info->relocateable)
+ return true;
+
+#ifdef DEBUG
+ fprintf (stderr, "v850_elf_check_relocs called for section %s in %s\n",
+ bfd_get_section_name (abfd, sec),
+ bfd_get_filename (abfd));
+#endif
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ r_type = (enum v850_reloc_type) ELF32_R_TYPE (rel->r_info);
+ switch (r_type)
+ {
+ default:
+ case R_V850_NONE:
+ case R_V850_9_PCREL:
+ case R_V850_22_PCREL:
+ case R_V850_HI16_S:
+ case R_V850_HI16:
+ case R_V850_LO16:
+ case R_V850_32:
+ case R_V850_16:
+ case R_V850_8:
+ case R_V850_CALLT_6_7_OFFSET:
+ case R_V850_CALLT_16_16_OFFSET:
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_V850_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_V850_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+
+ case R_V850_SDA_16_16_SPLIT_OFFSET:
+ case R_V850_SDA_16_16_OFFSET:
+ case R_V850_SDA_15_16_OFFSET:
+ other = V850_OTHER_SDA;
+ common = ".scommon";
+ goto small_data_common;
+
+ case R_V850_ZDA_16_16_SPLIT_OFFSET:
+ case R_V850_ZDA_16_16_OFFSET:
+ case R_V850_ZDA_15_16_OFFSET:
+ other = V850_OTHER_ZDA;
+ common = ".zcommon";
+ goto small_data_common;
+
+ case R_V850_TDA_4_5_OFFSET:
+ case R_V850_TDA_4_4_OFFSET:
+ case R_V850_TDA_6_8_OFFSET:
+ case R_V850_TDA_7_8_OFFSET:
+ case R_V850_TDA_7_7_OFFSET:
+ case R_V850_TDA_16_16_OFFSET:
+ other = V850_OTHER_TDA;
+ common = ".tcommon";
+ /* fall through */
+
+#define V850_OTHER_MASK (V850_OTHER_TDA | V850_OTHER_SDA | V850_OTHER_ZDA)
+
+ small_data_common:
+ if (h)
+ {
+ h->other |= other; /* flag which type of relocation was used */
+ if ((h->other & V850_OTHER_MASK) != (other & V850_OTHER_MASK)
+ && (h->other & V850_OTHER_ERROR) == 0)
+ {
+ const char * msg;
+ static char buff[200]; /* XXX */
+
+ switch (h->other & V850_OTHER_MASK)
+ {
+ default:
+ msg = _("Variable `%s' cannot occupy in multiple small data regions");
+ break;
+ case V850_OTHER_SDA | V850_OTHER_ZDA | V850_OTHER_TDA:
+ msg = _("Variable `%s' can only be in one of the small, zero, and tiny data regions");
+ break;
+ case V850_OTHER_SDA | V850_OTHER_ZDA:
+ msg = _("Variable `%s' cannot be in both small and zero data regions simultaneously");
+ break;
+ case V850_OTHER_SDA | V850_OTHER_TDA:
+ msg = _("Variable `%s' cannot be in both small and tiny data regions simultaneously");
+ break;
+ case V850_OTHER_ZDA | V850_OTHER_TDA:
+ msg = _("Variable `%s' cannot be in both zero and tiny data regions simultaneously");
+ break;
+ }
+
+ sprintf (buff, msg, h->root.root.string);
+ info->callbacks->warning (info, buff, h->root.root.string,
+ abfd, h->root.u.def.section, 0);
+
+ bfd_set_error (bfd_error_bad_value);
+ h->other |= V850_OTHER_ERROR;
+ ret = false;
+ }
+ }
+
+ if (h && h->root.type == bfd_link_hash_common
+ && h->root.u.c.p
+ && !strcmp (bfd_get_section_name (abfd, h->root.u.c.p->section), "COMMON"))
+ {
+ asection *section = h->root.u.c.p->section = bfd_make_section_old_way (abfd, common);
+ section->flags |= SEC_IS_COMMON;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "v850_elf_check_relocs, found %s relocation for %s%s\n",
+ v850_elf_howto_table[ (int)r_type ].name,
+ (h && h->root.root.string) ? h->root.root.string : "<unknown>",
+ (h->root.type == bfd_link_hash_common) ? ", symbol is common" : "");
+#endif
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * In the old version, when an entry was checked out from the table,
+ * it was deleted. This produced an error if the entry was needed
+ * more than once, as the second attempted retry failed.
+ *
+ * In the current version, the entry is not deleted, instead we set
+ * the field 'found' to true. If a second lookup matches the same
+ * entry, then we know that the hi16s reloc has already been updated
+ * and does not need to be updated a second time.
+ *
+ * TODO - TOFIX: If it is possible that we need to restore 2 different
+ * addresses from the same table entry, where the first generates an
+ * overflow, whilst the second do not, then this code will fail.
+ */
+
+typedef struct hi16s_location
+{
+ bfd_vma addend;
+ bfd_byte * address;
+ unsigned long counter;
+ boolean found;
+ struct hi16s_location * next;
+}
+hi16s_location;
+
+static hi16s_location * previous_hi16s;
+static hi16s_location * free_hi16s;
+static unsigned long hi16s_counter;
+
+static void
+remember_hi16s_reloc (abfd, addend, address)
+ bfd * abfd;
+ bfd_vma addend;
+ bfd_byte * address;
+{
+ hi16s_location * entry = NULL;
+
+ /* Find a free structure. */
+ if (free_hi16s == NULL)
+ free_hi16s = (hi16s_location *) bfd_zalloc (abfd, sizeof (* free_hi16s));
+
+ entry = free_hi16s;
+ free_hi16s = free_hi16s->next;
+
+ entry->addend = addend;
+ entry->address = address;
+ entry->counter = hi16s_counter ++;
+ entry->found = false;
+ entry->next = previous_hi16s;
+ previous_hi16s = entry;
+
+ /* Cope with wrap around of our counter. */
+ if (hi16s_counter == 0)
+ {
+ /* XXX - Assume that all counter entries differ only in their low 16 bits. */
+ for (entry = previous_hi16s; entry != NULL; entry = entry->next)
+ entry->counter &= 0xffff;
+
+ hi16s_counter = 0x10000;
+ }
+
+ return;
+}
+
+static bfd_byte *
+find_remembered_hi16s_reloc (addend, already_found)
+ bfd_vma addend;
+ boolean * already_found;
+{
+ hi16s_location * match = NULL;
+ hi16s_location * entry;
+ hi16s_location * previous = NULL;
+ hi16s_location * prev;
+ int i;
+ bfd_byte * addr;
+
+ /* Search the table. Record the most recent entry that matches. */
+ for (entry = previous_hi16s; entry; entry = entry->next)
+ {
+ if (entry->addend == addend
+ && (match == NULL || match->counter < entry->counter))
+ {
+ previous = prev;
+ match = entry;
+ }
+
+ prev = entry;
+ }
+
+ if (match == NULL)
+ return NULL;
+
+ /* Extract the address. */
+ addr = match->address;
+
+ /* Remeber if this entry has already been used before. */
+ if (already_found)
+ * already_found = match->found;
+
+ /* Note that this entry has now been used. */
+ match->found = true;
+
+ return addr;
+}
+
+/* FIXME: The code here probably ought to be removed and the code in reloc.c
+ allowed to do its stuff instead. At least for most of the relocs, anwyay. */
+static bfd_reloc_status_type
+v850_elf_perform_relocation (abfd, r_type, addend, address)
+ bfd * abfd;
+ int r_type;
+ bfd_vma addend;
+ bfd_byte * address;
+{
+ unsigned long insn;
+ bfd_signed_vma saddend = (bfd_signed_vma) addend;
+
+ switch (r_type)
+ {
+ default:
+ /* fprintf (stderr, "reloc type %d not SUPPORTED\n", r_type ); */
+ return bfd_reloc_notsupported;
+
+ case R_V850_32:
+ bfd_put_32 (abfd, addend, address);
+ return bfd_reloc_ok;
+
+ case R_V850_22_PCREL:
+ if (saddend > 0x1fffff || saddend < -0x200000)
+ return bfd_reloc_overflow;
+
+ if ((addend % 2) != 0)
+ return bfd_reloc_dangerous;
+
+ insn = bfd_get_32 (abfd, address);
+ insn &= ~0xfffe003f;
+ insn |= (((addend & 0xfffe) << 16) | ((addend & 0x3f0000) >> 16));
+ bfd_put_32 (abfd, insn, address);
+ return bfd_reloc_ok;
+
+ case R_V850_9_PCREL:
+ if (saddend > 0xff || saddend < -0x100)
+ return bfd_reloc_overflow;
+
+ if ((addend % 2) != 0)
+ return bfd_reloc_dangerous;
+
+ insn = bfd_get_16 (abfd, address);
+ insn &= ~ 0xf870;
+ insn |= ((addend & 0x1f0) << 7) | ((addend & 0x0e) << 3);
+ break;
+
+ case R_V850_HI16:
+ addend += (bfd_get_16 (abfd, address) << 16);
+ addend = (addend >> 16);
+ insn = addend;
+ break;
+
+ case R_V850_HI16_S:
+ /* Remember where this relocation took place. */
+ remember_hi16s_reloc (abfd, addend, address);
+
+ addend += (bfd_get_16 (abfd, address) << 16);
+ addend = (addend >> 16) + ((addend & 0x8000) != 0);
+
+ /* This relocation cannot overflow. */
+ if (addend > 0x7fff)
+ addend = 0;
+
+ insn = addend;
+ break;
+
+ case R_V850_LO16:
+ /* Calculate the sum of the value stored in the instruction and the
+ addend and check for overflow from the low 16 bits into the high
+ 16 bits. The assembler has already done some of this: If the
+ value stored in the instruction has its 15th bit set, (counting
+ from zero) then the assembler will have added 1 to the value
+ stored in the associated HI16S reloc. So for example, these
+ relocations:
+
+ movhi hi( fred ), r0, r1
+ movea lo( fred ), r1, r1
+
+ will store 0 in the value fields for the MOVHI and MOVEA instructions
+ and addend will be the address of fred, but for these instructions:
+
+ movhi hi( fred + 0x123456), r0, r1
+ movea lo( fred + 0x123456), r1, r1
+
+ the value stored in the MOVHI instruction will be 0x12 and the value
+ stored in the MOVEA instruction will be 0x3456. If however the
+ instructions were:
+
+ movhi hi( fred + 0x10ffff), r0, r1
+ movea lo( fred + 0x10ffff), r1, r1
+
+ then the value stored in the MOVHI instruction would be 0x11 (not
+ 0x10) and the value stored in the MOVEA instruction would be 0xffff.
+ Thus (assuming for the moment that the addend is 0), at run time the
+ MOVHI instruction loads 0x110000 into r1, then the MOVEA instruction
+ adds 0xffffffff (sign extension!) producing 0x10ffff. Similarly if
+ the instructions were:
+
+ movhi hi( fred - 1), r0, r1
+ movea lo( fred - 1), r1, r1
+
+ then 0 is stored in the MOVHI instruction and -1 is stored in the
+ MOVEA instruction.
+
+ Overflow can occur if the addition of the value stored in the
+ instruction plus the addend sets the 15th bit when before it was clear.
+ This is because the 15th bit will be sign extended into the high part,
+ thus reducing its value by one, but since the 15th bit was originally
+ clear, the assembler will not have added 1 to the previous HI16S reloc
+ to compensate for this effect. For example:
+
+ movhi hi( fred + 0x123456), r0, r1
+ movea lo( fred + 0x123456), r1, r1
+
+ The value stored in HI16S reloc is 0x12, the value stored in the LO16
+ reloc is 0x3456. If we assume that the address of fred is 0x00007000
+ then the relocations become:
+
+ HI16S: 0x0012 + (0x00007000 >> 16) = 0x12
+ LO16: 0x3456 + (0x00007000 & 0xffff) = 0xa456
+
+ but when the instructions are executed, the MOVEA instruction's value
+ is signed extended, so the sum becomes:
+
+ 0x00120000
+ + 0xffffa456
+ ------------
+ 0x0011a456 but 'fred + 0x123456' = 0x0012a456
+
+ Note that if the 15th bit was set in the value stored in the LO16
+ reloc, then we do not have to do anything:
+
+ movhi hi( fred + 0x10ffff), r0, r1
+ movea lo( fred + 0x10ffff), r1, r1
+
+ HI16S: 0x0011 + (0x00007000 >> 16) = 0x11
+ LO16: 0xffff + (0x00007000 & 0xffff) = 0x6fff
+
+ 0x00110000
+ + 0x00006fff
+ ------------
+ 0x00116fff = fred + 0x10ffff = 0x7000 + 0x10ffff
+
+
+ Overflow can also occur if the computation carries into the 16th bit
+ and it also results in the 15th bit having the same value as the 15th
+ bit of the original value. What happens is that the HI16S reloc
+ will have already examined the 15th bit of the original value and
+ added 1 to the high part if the bit is set. This compensates for the
+ sign extension of 15th bit of the result of the computation. But now
+ there is a carry into the 16th bit, and this has not been allowed for.
+
+ So, for example if fred is at address 0xf000:
+
+ movhi hi( fred + 0xffff), r0, r1 [bit 15 of the offset is set]
+ movea lo( fred + 0xffff), r1, r1
+
+ HI16S: 0x0001 + (0x0000f000 >> 16) = 0x0001
+ LO16: 0xffff + (0x0000f000 & 0xffff) = 0xefff (carry into bit 16 is lost)
+
+ 0x00010000
+ + 0xffffefff
+ ------------
+ 0x0000efff but 'fred + 0xffff' = 0x0001efff
+
+ Similarly, if the 15th bit remains clear, but overflow occurs into
+ the 16th bit then (assuming the address of fred is 0xf000):
+
+ movhi hi( fred + 0x7000), r0, r1 [bit 15 of the offset is clear]
+ movea lo( fred + 0x7000), r1, r1
+
+ HI16S: 0x0000 + (0x0000f000 >> 16) = 0x0000
+ LO16: 0x7000 + (0x0000f000 & 0xffff) = 0x6fff (carry into bit 16 is lost)
+
+ 0x00000000
+ + 0x00006fff
+ ------------
+ 0x00006fff but 'fred + 0x7000' = 0x00016fff
+
+ Note - there is no need to change anything if a carry occurs, and the
+ 15th bit changes its value from being set to being clear, as the HI16S
+ reloc will have already added in 1 to the high part for us:
+
+ movhi hi( fred + 0xffff), r0, r1 [bit 15 of the offset is set]
+ movea lo( fred + 0xffff), r1, r1
+
+ HI16S: 0x0001 + (0x00007000 >> 16)
+ LO16: 0xffff + (0x00007000 & 0xffff) = 0x6fff (carry into bit 16 is lost)
+
+ 0x00010000
+ + 0x00006fff (bit 15 not set, so the top half is zero)
+ ------------
+ 0x00016fff which is right (assuming that fred is at 0x7000)
+
+ but if the 15th bit goes from being clear to being set, then we must
+ once again handle overflow:
+
+ movhi hi( fred + 0x7000), r0, r1 [bit 15 of the offset is clear]
+ movea lo( fred + 0x7000), r1, r1
+
+ HI16S: 0x0000 + (0x0000ffff >> 16)
+ LO16: 0x7000 + (0x0000ffff & 0xffff) = 0x6fff (carry into bit 16)
+
+ 0x00000000
+ + 0x00006fff (bit 15 not set, so the top half is zero)
+ ------------
+ 0x00006fff which is wrong (assuming that fred is at 0xffff)
+ */
+
+ {
+ long result;
+
+ insn = bfd_get_16 (abfd, address);
+ result = insn + addend;
+
+#define BIT15_SET(x) ((x) & 0x8000)
+#define OVERFLOWS(a,i) ((((a) & 0xffff) + (i)) > 0xffff)
+
+ if ((BIT15_SET (result) && ! BIT15_SET (addend))
+ || (OVERFLOWS (addend, insn)
+ && ((! BIT15_SET (insn)) || (BIT15_SET (addend)))))
+ {
+ boolean already_updated;
+ bfd_byte * hi16s_address = find_remembered_hi16s_reloc
+ (addend, & already_updated);
+
+ /* Amend the matching HI16_S relocation. */
+ if (hi16s_address != NULL)
+ {
+ if (! already_updated)
+ {
+ insn = bfd_get_16 (abfd, hi16s_address);
+ insn += 1;
+ bfd_put_16 (abfd, insn, hi16s_address);
+ }
+ }
+ else
+ {
+ fprintf (stderr, _("FAILED to find previous HI16 reloc\n"));
+ return bfd_reloc_overflow;
+ }
+ }
+
+ /* Do not complain if value has top bit set, as this has been anticipated. */
+ insn = result & 0xffff;
+ break;
+ }
+
+ case R_V850_8:
+ addend += (char) bfd_get_8 (abfd, address);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x7f || saddend < -0x80)
+ return bfd_reloc_overflow;
+
+ bfd_put_8 (abfd, addend, address);
+ return bfd_reloc_ok;
+
+ case R_V850_CALLT_16_16_OFFSET:
+ addend += bfd_get_16 (abfd, address);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0xffff || saddend < 0)
+ return bfd_reloc_overflow;
+
+ insn = addend;
+ break;
+
+ case R_V850_16:
+
+ /* drop through */
+ case R_V850_SDA_16_16_OFFSET:
+ case R_V850_ZDA_16_16_OFFSET:
+ case R_V850_TDA_16_16_OFFSET:
+ addend += bfd_get_16 (abfd, address);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x7fff || saddend < -0x8000)
+ return bfd_reloc_overflow;
+
+ insn = addend;
+ break;
+
+ case R_V850_SDA_15_16_OFFSET:
+ case R_V850_ZDA_15_16_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += (insn & 0xfffe);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x7ffe || saddend < -0x8000)
+ return bfd_reloc_overflow;
+
+ if (addend & 1)
+ return bfd_reloc_dangerous;
+
+ insn = (addend & ~1) | (insn & 1);
+ break;
+
+ case R_V850_TDA_6_8_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += ((insn & 0x7e) << 1);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0xfc || saddend < 0)
+ return bfd_reloc_overflow;
+
+ if (addend & 3)
+ return bfd_reloc_dangerous;
+
+ insn &= 0xff81;
+ insn |= (addend >> 1);
+ break;
+
+ case R_V850_TDA_7_8_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += ((insn & 0x7f) << 1);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0xfe || saddend < 0)
+ return bfd_reloc_overflow;
+
+ if (addend & 1)
+ return bfd_reloc_dangerous;
+
+ insn &= 0xff80;
+ insn |= (addend >> 1);
+ break;
+
+ case R_V850_TDA_7_7_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += insn & 0x7f;
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x7f || saddend < 0)
+ return bfd_reloc_overflow;
+
+ insn &= 0xff80;
+ insn |= addend;
+ break;
+
+ case R_V850_TDA_4_5_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += ((insn & 0xf) << 1);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x1e || saddend < 0)
+ return bfd_reloc_overflow;
+
+ if (addend & 1)
+ return bfd_reloc_dangerous;
+
+ insn &= 0xfff0;
+ insn |= (addend >> 1);
+ break;
+
+ case R_V850_TDA_4_4_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += insn & 0xf;
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0xf || saddend < 0)
+ return bfd_reloc_overflow;
+
+ insn &= 0xfff0;
+ insn |= addend;
+ break;
+
+ case R_V850_ZDA_16_16_SPLIT_OFFSET:
+ case R_V850_SDA_16_16_SPLIT_OFFSET:
+ insn = bfd_get_32 (abfd, address);
+ addend += ((insn & 0xfffe0000) >> 16) + ((insn & 0x20) >> 5);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x7fff || saddend < -0x8000)
+ return bfd_reloc_overflow;
+
+ insn &= 0x0001ffdf;
+ insn |= (addend & 1) << 5;
+ insn |= (addend & ~1) << 16;
+
+ bfd_put_32 (abfd, insn, address);
+ return bfd_reloc_ok;
+
+ case R_V850_CALLT_6_7_OFFSET:
+ insn = bfd_get_16 (abfd, address);
+ addend += ((insn & 0x3f) << 1);
+
+ saddend = (bfd_signed_vma) addend;
+
+ if (saddend > 0x7e || saddend < 0)
+ return bfd_reloc_overflow;
+
+ if (addend & 1)
+ return bfd_reloc_dangerous;
+
+ insn &= 0xff80;
+ insn |= (addend >> 1);
+ break;
+
+ case R_V850_GNU_VTINHERIT:
+ case R_V850_GNU_VTENTRY:
+ return bfd_reloc_ok;
+
+ }
+
+ bfd_put_16 (abfd, insn, address);
+ return bfd_reloc_ok;
+}
+
+
+/* Insert the addend into the instruction. */
+static bfd_reloc_status_type
+v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err)
+ bfd * abfd;
+ arelent * reloc;
+ asymbol * symbol;
+ PTR data;
+ asection * isection;
+ bfd * obfd;
+ char ** err;
+{
+ long relocation;
+
+ /* If there is an output BFD,
+ and the symbol is not a section name (which is only defined at final link time),
+ and either we are not putting the addend into the instruction
+ or the addend is zero, so there is nothing to add into the instruction
+ then just fixup the address and return. */
+ if (obfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! reloc->howto->partial_inplace
+ || reloc->addend == 0))
+ {
+ reloc->address += isection->output_offset;
+ return bfd_reloc_ok;
+ }
+#if 0
+ else if (obfd != NULL)
+ {
+ return bfd_reloc_continue;
+ }
+#endif
+
+ /* Catch relocs involving undefined symbols. */
+ if (bfd_is_und_section (symbol->section)
+ && (symbol->flags & BSF_WEAK) == 0
+ && obfd == NULL)
+ return bfd_reloc_undefined;
+
+ /* We handle final linking of some relocs ourselves. */
+
+ /* Is the address of the relocation really within the section? */
+ if (reloc->address > isection->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ /* Convert input-section-relative symbol value to absolute + addend. */
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc->addend;
+
+ if (reloc->howto->pc_relative == true)
+ {
+ /* Here the variable relocation holds the final address of the
+ symbol we are relocating against, plus any addend. */
+ relocation -= isection->output_section->vma + isection->output_offset;
+
+ /* Deal with pcrel_offset */
+ relocation -= reloc->address;
+ }
+
+ reloc->addend = relocation;
+ return bfd_reloc_ok;
+}
+
+
+/*ARGSUSED*/
+static boolean
+v850_elf_is_local_label_name (abfd, name)
+ bfd * abfd;
+ const char * name;
+{
+ return ( (name[0] == '.' && (name[1] == 'L' || name[1] == '.'))
+ || (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_'));
+}
+
+
+/* Perform a relocation as part of a final link. */
+static bfd_reloc_status_type
+v850_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, offset, value,
+ addend, info, sym_sec, is_local)
+ reloc_howto_type * howto;
+ bfd * input_bfd;
+ bfd * output_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ bfd_vma offset;
+ bfd_vma value;
+ bfd_vma addend;
+ struct bfd_link_info * info;
+ asection * sym_sec;
+ int is_local;
+{
+ unsigned long r_type = howto->type;
+ bfd_byte * hit_data = contents + offset;
+
+ /* Adjust the value according to the relocation. */
+ switch (r_type)
+ {
+ case R_V850_9_PCREL:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= offset;
+ break;
+
+ case R_V850_22_PCREL:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset
+ + offset);
+
+ value = SEXT24 (value); /* Only the bottom 24 bits of the PC are valid */
+ break;
+
+ case R_V850_HI16_S:
+ case R_V850_HI16:
+ case R_V850_LO16:
+ case R_V850_16:
+ case R_V850_32:
+ case R_V850_8:
+ break;
+
+ case R_V850_ZDA_15_16_OFFSET:
+ case R_V850_ZDA_16_16_OFFSET:
+ case R_V850_ZDA_16_16_SPLIT_OFFSET:
+ if (sym_sec == NULL)
+ return bfd_reloc_undefined;
+
+ value -= sym_sec->output_section->vma;
+ break;
+
+ case R_V850_SDA_15_16_OFFSET:
+ case R_V850_SDA_16_16_OFFSET:
+ case R_V850_SDA_16_16_SPLIT_OFFSET:
+ {
+ unsigned long gp;
+ struct bfd_link_hash_entry * h;
+
+ if (sym_sec == NULL)
+ return bfd_reloc_undefined;
+
+ /* Get the value of __gp. */
+ h = bfd_link_hash_lookup (info->hash, "__gp", false, false, true);
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || h->type != bfd_link_hash_defined)
+ return bfd_reloc_other;
+
+ gp = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+
+ value -= sym_sec->output_section->vma;
+ value -= (gp - sym_sec->output_section->vma);
+ }
+ break;
+
+ case R_V850_TDA_4_4_OFFSET:
+ case R_V850_TDA_4_5_OFFSET:
+ case R_V850_TDA_16_16_OFFSET:
+ case R_V850_TDA_7_7_OFFSET:
+ case R_V850_TDA_7_8_OFFSET:
+ case R_V850_TDA_6_8_OFFSET:
+ {
+ unsigned long ep;
+ struct bfd_link_hash_entry * h;
+
+ /* Get the value of __ep. */
+ h = bfd_link_hash_lookup (info->hash, "__ep", false, false, true);
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || h->type != bfd_link_hash_defined)
+ return bfd_reloc_continue; /* Actually this indicates that __ep could not be found. */
+
+ ep = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+
+ value -= ep;
+ }
+ break;
+
+ case R_V850_CALLT_6_7_OFFSET:
+ {
+ unsigned long ctbp;
+ struct bfd_link_hash_entry * h;
+
+ /* Get the value of __ctbp. */
+ h = bfd_link_hash_lookup (info->hash, "__ctbp", false, false, true);
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || h->type != bfd_link_hash_defined)
+ return (bfd_reloc_dangerous + 1); /* Actually this indicates that __ctbp could not be found. */
+
+ ctbp = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+ value -= ctbp;
+ }
+ break;
+
+ case R_V850_CALLT_16_16_OFFSET:
+ {
+ unsigned long ctbp;
+ struct bfd_link_hash_entry * h;
+
+ if (sym_sec == NULL)
+ return bfd_reloc_undefined;
+
+ /* Get the value of __ctbp. */
+ h = bfd_link_hash_lookup (info->hash, "__ctbp", false, false, true);
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || h->type != bfd_link_hash_defined)
+ return (bfd_reloc_dangerous + 1);
+
+ ctbp = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+
+ value -= sym_sec->output_section->vma;
+ value -= (ctbp - sym_sec->output_section->vma);
+ }
+ break;
+
+ case R_V850_NONE:
+ case R_V850_GNU_VTINHERIT:
+ case R_V850_GNU_VTENTRY:
+ return bfd_reloc_ok;
+
+ default:
+ return bfd_reloc_notsupported;
+ }
+
+ /* Perform the relocation. */
+ return v850_elf_perform_relocation (input_bfd, r_type, value + addend, hit_data);
+}
+
+
+/* Relocate an V850 ELF section. */
+static boolean
+v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd * output_bfd;
+ struct bfd_link_info * info;
+ bfd * input_bfd;
+ asection * input_section;
+ bfd_byte * contents;
+ Elf_Internal_Rela * relocs;
+ Elf_Internal_Sym * local_syms;
+ asection ** local_sections;
+{
+ Elf_Internal_Shdr * symtab_hdr;
+ struct elf_link_hash_entry ** sym_hashes;
+ Elf_Internal_Rela * rel;
+ Elf_Internal_Rela * relend;
+
+ symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+
+ if (sym_hashes == NULL)
+ {
+ info->callbacks->warning
+ (info, "no hash table available", NULL, input_bfd, input_section, 0);
+
+ return false;
+ }
+
+ /* Reset the list of remembered HI16S relocs to empty. */
+ free_hi16s = previous_hi16s;
+ previous_hi16s = NULL;
+ hi16s_counter = 0;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type * howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym * sym;
+ asection * sec;
+ struct elf_link_hash_entry * h;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ if (r_type == R_V850_GNU_VTENTRY
+ || r_type == R_V850_GNU_VTINHERIT)
+ continue;
+
+ howto = v850_elf_howto_table + r_type;
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+#if 0
+ {
+ char * name;
+ name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name);
+ name = (name == NULL) ? "<none>" : name;
+fprintf (stderr, "local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
+ sec->name, name, sym->st_name,
+ sec->output_section->vma, sec->output_offset, sym->st_value, rel->r_addend);
+ }
+#endif
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.u.def.section;
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+#if 0
+fprintf (stderr, "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
+ sec->name, h->root.root.string, h->root.u.def.value, sec->output_section->vma, sec->output_offset, relocation);
+#endif
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ {
+#if 0
+fprintf (stderr, "undefined: sec: %s, name: %s\n",
+ sec->name, h->root.root.string);
+#endif
+ relocation = 0;
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+#if 0
+fprintf (stderr, "unknown: name: %s\n", h->root.root.string);
+#endif
+ relocation = 0;
+ }
+ }
+
+ /* FIXME: We should use the addend, but the COFF relocations
+ don't. */
+ r = v850_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend,
+ info, sec, h == NULL);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char * name;
+ const char * msg = (const char *)0;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL || *name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_undefined:
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ msg = _("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ msg = _("internal error: dangerous relocation");
+ goto common_error;
+
+ case bfd_reloc_other:
+ msg = _("could not locate special linker symbol __gp");
+ goto common_error;
+
+ case bfd_reloc_continue:
+ msg = _("could not locate special linker symbol __ep");
+ goto common_error;
+
+ case (bfd_reloc_dangerous + 1):
+ msg = _("could not locate special linker symbol __ctbp");
+ goto common_error;
+
+ default:
+ msg = _("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, msg, name, input_bfd, input_section,
+ rel->r_offset)))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+static boolean
+v850_elf_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ /* No got and plt entries for v850-elf */
+ return true;
+}
+
+static asection *
+v850_elf_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ Elf_Internal_Rela *rel;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ if (h != NULL)
+ {
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_V850_GNU_VTINHERIT:
+ case R_V850_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+ }
+ }
+ }
+ else
+ {
+ if (!(elf_bad_symtab (abfd)
+ && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
+ && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
+ && sym->st_shndx != SHN_COMMON))
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+ }
+ return NULL;
+}
+/* Set the right machine number. */
+static boolean
+v850_elf_object_p (abfd)
+ bfd *abfd;
+{
+ switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
+ {
+ default:
+ case E_V850_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_v850, 0); break;
+ case E_V850E_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850e); break;
+ case E_V850EA_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850ea); break;
+ }
+ return true;
+}
+
+/* Store the machine number in the flags field. */
+static void
+v850_elf_final_write_processing (abfd, linker)
+ bfd * abfd;
+ boolean linker;
+{
+ unsigned long val;
+
+ switch (bfd_get_mach (abfd))
+ {
+ default:
+ case 0: val = E_V850_ARCH; break;
+ case bfd_mach_v850e: val = E_V850E_ARCH; break;
+ case bfd_mach_v850ea: val = E_V850EA_ARCH; break;
+ }
+
+ elf_elfheader (abfd)->e_flags &=~ EF_V850_ARCH;
+ elf_elfheader (abfd)->e_flags |= val;
+}
+
+/* Function to keep V850 specific file flags. */
+static boolean
+v850_elf_set_private_flags (abfd, flags)
+ bfd * abfd;
+ flagword flags;
+{
+ BFD_ASSERT (!elf_flags_init (abfd)
+ || elf_elfheader (abfd)->e_flags == flags);
+
+ elf_elfheader (abfd)->e_flags = flags;
+ elf_flags_init (abfd) = true;
+ return true;
+}
+
+/* Copy backend specific data from one object module to another */
+static boolean
+v850_elf_copy_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ BFD_ASSERT (!elf_flags_init (obfd)
+ || (elf_elfheader (obfd)->e_flags
+ == elf_elfheader (ibfd)->e_flags));
+
+ elf_gp (obfd) = elf_gp (ibfd);
+ elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+ elf_flags_init (obfd) = true;
+ return true;
+}
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+static boolean
+v850_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd * ibfd;
+ bfd * obfd;
+{
+ flagword out_flags;
+ flagword in_flags;
+
+ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ in_flags = elf_elfheader (ibfd)->e_flags;
+ out_flags = elf_elfheader (obfd)->e_flags;
+
+ if (! elf_flags_init (obfd))
+ {
+ /* If the input is the default architecture then do not
+ bother setting the flags for the output architecture,
+ instead allow future merges to do this. If no future
+ merges ever set these flags then they will retain their
+ unitialised values, which surprise surprise, correspond
+ to the default values. */
+ if (bfd_get_arch_info (ibfd)->the_default)
+ return true;
+
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = in_flags;
+
+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+ && bfd_get_arch_info (obfd)->the_default)
+ {
+ return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
+ }
+
+ return true;
+ }
+
+ /* Check flag compatibility. */
+ if (in_flags == out_flags)
+ return true;
+
+ if ((in_flags & EF_V850_ARCH) != (out_flags & EF_V850_ARCH)
+ && (in_flags & EF_V850_ARCH) != E_V850_ARCH)
+ _bfd_error_handler (_("%s: Architecture mismatch with previous modules"),
+ bfd_get_filename (ibfd));
+
+ return true;
+}
+/* Display the flags field */
+
+static boolean
+v850_elf_print_private_bfd_data (abfd, ptr)
+ bfd * abfd;
+ PTR ptr;
+{
+ FILE * file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+ _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+ /* xgettext:c-format */
+ fprintf (file, _("private flags = %lx: "), elf_elfheader (abfd)->e_flags);
+
+ switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
+ {
+ default:
+ case E_V850_ARCH: fprintf (file, _("v850 architecture")); break;
+ case E_V850E_ARCH: fprintf (file, _("v850e architecture")); break;
+ case E_V850EA_ARCH: fprintf (file, _("v850ea architecture")); break;
+ }
+
+ fputc ('\n', file);
+
+ return true;
+}
+
+/* V850 ELF uses four common sections. One is the usual one, and the
+ others are for (small) objects in one of the special data areas:
+ small, tiny and zero. All the objects are kept together, and then
+ referenced via the gp register, the ep register or the r0 register
+ respectively, which yields smaller, faster assembler code. This
+ approach is copied from elf32-mips.c. */
+
+static asection v850_elf_scom_section;
+static asymbol v850_elf_scom_symbol;
+static asymbol * v850_elf_scom_symbol_ptr;
+static asection v850_elf_tcom_section;
+static asymbol v850_elf_tcom_symbol;
+static asymbol * v850_elf_tcom_symbol_ptr;
+static asection v850_elf_zcom_section;
+static asymbol v850_elf_zcom_symbol;
+static asymbol * v850_elf_zcom_symbol_ptr;
+
+
+/* Given a BFD section, try to locate the corresponding ELF section
+ index. */
+
+static boolean
+v850_elf_section_from_bfd_section (abfd, hdr, sec, retval)
+ bfd * abfd;
+ Elf32_Internal_Shdr * hdr;
+ asection * sec;
+ int * retval;
+{
+ if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+ *retval = SHN_V850_SCOMMON;
+ else if (strcmp (bfd_get_section_name (abfd, sec), ".tcommon") == 0)
+ *retval = SHN_V850_TCOMMON;
+ else if (strcmp (bfd_get_section_name (abfd, sec), ".zcommon") == 0)
+ *retval = SHN_V850_ZCOMMON;
+ else
+ return false;
+
+ return true;
+}
+
+/* Handle the special V850 section numbers that a symbol may use. */
+
+static void
+v850_elf_symbol_processing (abfd, asym)
+ bfd * abfd;
+ asymbol * asym;
+{
+ elf_symbol_type * elfsym = (elf_symbol_type *) asym;
+ unsigned short index;
+
+ index = elfsym->internal_elf_sym.st_shndx;
+
+ /* If the section index is an "ordinary" index, then it may
+ refer to a v850 specific section created by the assembler.
+ Check the section's type and change the index it matches.
+
+ FIXME: Should we alter the st_shndx field as well ? */
+
+ if (index < elf_elfheader(abfd)[0].e_shnum)
+ switch (elf_elfsections(abfd)[index]->sh_type)
+ {
+ case SHT_V850_SCOMMON:
+ index = SHN_V850_SCOMMON;
+ break;
+
+ case SHT_V850_TCOMMON:
+ index = SHN_V850_TCOMMON;
+ break;
+
+ case SHT_V850_ZCOMMON:
+ index = SHN_V850_ZCOMMON;
+ break;
+
+ default:
+ break;
+ }
+
+ switch (index)
+ {
+ case SHN_V850_SCOMMON:
+ if (v850_elf_scom_section.name == NULL)
+ {
+ /* Initialize the small common section. */
+ v850_elf_scom_section.name = ".scommon";
+ v850_elf_scom_section.flags = SEC_IS_COMMON | SEC_ALLOC | SEC_DATA;
+ v850_elf_scom_section.output_section = & v850_elf_scom_section;
+ v850_elf_scom_section.symbol = & v850_elf_scom_symbol;
+ v850_elf_scom_section.symbol_ptr_ptr = & v850_elf_scom_symbol_ptr;
+ v850_elf_scom_symbol.name = ".scommon";
+ v850_elf_scom_symbol.flags = BSF_SECTION_SYM;
+ v850_elf_scom_symbol.section = & v850_elf_scom_section;
+ v850_elf_scom_symbol_ptr = & v850_elf_scom_symbol;
+ }
+ asym->section = & v850_elf_scom_section;
+ asym->value = elfsym->internal_elf_sym.st_size;
+ break;
+
+ case SHN_V850_TCOMMON:
+ if (v850_elf_tcom_section.name == NULL)
+ {
+ /* Initialize the tcommon section. */
+ v850_elf_tcom_section.name = ".tcommon";
+ v850_elf_tcom_section.flags = SEC_IS_COMMON;
+ v850_elf_tcom_section.output_section = & v850_elf_tcom_section;
+ v850_elf_tcom_section.symbol = & v850_elf_tcom_symbol;
+ v850_elf_tcom_section.symbol_ptr_ptr = & v850_elf_tcom_symbol_ptr;
+ v850_elf_tcom_symbol.name = ".tcommon";
+ v850_elf_tcom_symbol.flags = BSF_SECTION_SYM;
+ v850_elf_tcom_symbol.section = & v850_elf_tcom_section;
+ v850_elf_tcom_symbol_ptr = & v850_elf_tcom_symbol;
+ }
+ asym->section = & v850_elf_tcom_section;
+ asym->value = elfsym->internal_elf_sym.st_size;
+ break;
+
+ case SHN_V850_ZCOMMON:
+ if (v850_elf_zcom_section.name == NULL)
+ {
+ /* Initialize the zcommon section. */
+ v850_elf_zcom_section.name = ".zcommon";
+ v850_elf_zcom_section.flags = SEC_IS_COMMON;
+ v850_elf_zcom_section.output_section = & v850_elf_zcom_section;
+ v850_elf_zcom_section.symbol = & v850_elf_zcom_symbol;
+ v850_elf_zcom_section.symbol_ptr_ptr = & v850_elf_zcom_symbol_ptr;
+ v850_elf_zcom_symbol.name = ".zcommon";
+ v850_elf_zcom_symbol.flags = BSF_SECTION_SYM;
+ v850_elf_zcom_symbol.section = & v850_elf_zcom_section;
+ v850_elf_zcom_symbol_ptr = & v850_elf_zcom_symbol;
+ }
+ asym->section = & v850_elf_zcom_section;
+ asym->value = elfsym->internal_elf_sym.st_size;
+ break;
+ }
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+ file. We must handle the special v850 section numbers here. */
+
+/*ARGSUSED*/
+static boolean
+v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ const Elf_Internal_Sym * sym;
+ const char ** namep;
+ flagword * flagsp;
+ asection ** secp;
+ bfd_vma * valp;
+{
+ int index = sym->st_shndx;
+
+ /* If the section index is an "ordinary" index, then it may
+ refer to a v850 specific section created by the assembler.
+ Check the section's type and change the index it matches.
+
+ FIXME: Should we alter the st_shndx field as well ? */
+
+ if (index < elf_elfheader(abfd)[0].e_shnum)
+ switch (elf_elfsections(abfd)[index]->sh_type)
+ {
+ case SHT_V850_SCOMMON:
+ index = SHN_V850_SCOMMON;
+ break;
+
+ case SHT_V850_TCOMMON:
+ index = SHN_V850_TCOMMON;
+ break;
+
+ case SHT_V850_ZCOMMON:
+ index = SHN_V850_ZCOMMON;
+ break;
+
+ default:
+ break;
+ }
+
+ switch (index)
+ {
+ case SHN_V850_SCOMMON:
+ *secp = bfd_make_section_old_way (abfd, ".scommon");
+ (*secp)->flags |= SEC_IS_COMMON;
+ *valp = sym->st_size;
+ break;
+
+ case SHN_V850_TCOMMON:
+ *secp = bfd_make_section_old_way (abfd, ".tcommon");
+ (*secp)->flags |= SEC_IS_COMMON;
+ *valp = sym->st_size;
+ break;
+
+ case SHN_V850_ZCOMMON:
+ *secp = bfd_make_section_old_way (abfd, ".zcommon");
+ (*secp)->flags |= SEC_IS_COMMON;
+ *valp = sym->st_size;
+ break;
+ }
+
+ return true;
+}
+
+/*ARGSIGNORED*/
+static boolean
+v850_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec)
+ bfd * abfd;
+ struct bfd_link_info * info;
+ const char * name;
+ Elf_Internal_Sym * sym;
+ asection * input_sec;
+{
+ /* If we see a common symbol, which implies a relocatable link, then
+ if a symbol was in a special common section in an input file, mark
+ it as a special common in the output file. */
+
+ if (sym->st_shndx == SHN_COMMON)
+ {
+ if (strcmp (input_sec->name, ".scommon") == 0)
+ sym->st_shndx = SHN_V850_SCOMMON;
+ else if (strcmp (input_sec->name, ".tcommon") == 0)
+ sym->st_shndx = SHN_V850_TCOMMON;
+ else if (strcmp (input_sec->name, ".zcommon") == 0)
+ sym->st_shndx = SHN_V850_ZCOMMON;
+ }
+
+ return true;
+}
+
+static boolean
+v850_elf_section_from_shdr (abfd, hdr, name)
+ bfd * abfd;
+ Elf_Internal_Shdr * hdr;
+ char * name;
+{
+ /* There ought to be a place to keep ELF backend specific flags, but
+ at the moment there isn't one. We just keep track of the
+ sections by their name, instead. */
+
+ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+ return false;
+
+ switch (hdr->sh_type)
+ {
+ case SHT_V850_SCOMMON:
+ case SHT_V850_TCOMMON:
+ case SHT_V850_ZCOMMON:
+ if (! bfd_set_section_flags (abfd, hdr->bfd_section,
+ (bfd_get_section_flags (abfd,
+ hdr->bfd_section)
+ | SEC_IS_COMMON)))
+ return false;
+ }
+
+ return true;
+}
+
+/* Set the correct type for a V850 ELF section. We do this by the
+ section name, which is a hack, but ought to work. */
+static boolean
+v850_elf_fake_sections (abfd, hdr, sec)
+ bfd * abfd;
+ Elf32_Internal_Shdr * hdr;
+ asection * sec;
+{
+ register const char * name;
+
+ name = bfd_get_section_name (abfd, sec);
+
+ if (strcmp (name, ".scommon") == 0)
+ {
+ hdr->sh_type = SHT_V850_SCOMMON;
+ }
+ else if (strcmp (name, ".tcommon") == 0)
+ {
+ hdr->sh_type = SHT_V850_TCOMMON;
+ }
+ else if (strcmp (name, ".zcommon") == 0)
+ hdr->sh_type = SHT_V850_ZCOMMON;
+
+ return true;
+}
+
+
+
+#define TARGET_LITTLE_SYM bfd_elf32_v850_vec
+#define TARGET_LITTLE_NAME "elf32-v850"
+#define ELF_ARCH bfd_arch_v850
+#define ELF_MACHINE_CODE EM_CYGNUS_V850
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_info_to_howto v850_elf_info_to_howto_rela
+#define elf_info_to_howto_rel v850_elf_info_to_howto_rel
+
+#define elf_backend_check_relocs v850_elf_check_relocs
+#define elf_backend_relocate_section v850_elf_relocate_section
+#define elf_backend_object_p v850_elf_object_p
+#define elf_backend_final_write_processing v850_elf_final_write_processing
+#define elf_backend_section_from_bfd_section v850_elf_section_from_bfd_section
+#define elf_backend_symbol_processing v850_elf_symbol_processing
+#define elf_backend_add_symbol_hook v850_elf_add_symbol_hook
+#define elf_backend_link_output_symbol_hook v850_elf_link_output_symbol_hook
+#define elf_backend_section_from_shdr v850_elf_section_from_shdr
+#define elf_backend_fake_sections v850_elf_fake_sections
+#define elf_backend_gc_mark_hook v850_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook v850_elf_gc_sweep_hook
+
+#define elf_backend_can_gc_sections 1
+
+
+#define bfd_elf32_bfd_is_local_label_name v850_elf_is_local_label_name
+#define bfd_elf32_bfd_reloc_type_lookup v850_elf_reloc_type_lookup
+#define bfd_elf32_bfd_copy_private_bfd_data v850_elf_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data v850_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_set_private_flags v850_elf_set_private_flags
+#define bfd_elf32_bfd_print_private_bfd_data v850_elf_print_private_bfd_data
+
+#define elf_symbol_leading_char '_'
+
+#include "elf32-target.h"
diff --git a/bfd/elf32.c b/bfd/elf32.c
new file mode 100644
index 00000000000..f2229694406
--- /dev/null
+++ b/bfd/elf32.c
@@ -0,0 +1,23 @@
+/* ELF 32-bit executable support for BFD.
+ Copyright 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 32
+
+
+#include "elfcode.h"
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
new file mode 100644
index 00000000000..1964f86e859
--- /dev/null
+++ b/bfd/elf64-alpha.c
@@ -0,0 +1,4768 @@
+/* Alpha specific support for 64-bit ELF
+ Copyright 1996, 97, 98, 1999 Free Software Foundation, Inc.
+ Contributed by Richard Henderson <rth@tamu.edu>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* We need a published ABI spec for this. Until one comes out, don't
+ assume this'll remain unchanged forever. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+#include "elf/alpha.h"
+
+#define ALPHAECOFF
+
+#define NO_COFF_RELOCS
+#define NO_COFF_SYMBOLS
+#define NO_COFF_LINENOS
+
+/* Get the ECOFF swapping routines. Needed for the debug information. */
+#include "coff/internal.h"
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/ecoff.h"
+#include "coff/alpha.h"
+#include "aout/ar.h"
+#include "libcoff.h"
+#include "libecoff.h"
+#define ECOFF_64
+#include "ecoffswap.h"
+
+static boolean elf64_alpha_mkobject PARAMS ((bfd *));
+static struct bfd_hash_entry * elf64_alpha_link_hash_newfunc
+ PARAMS((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table * elf64_alpha_bfd_link_hash_table_create
+ PARAMS((bfd *));
+
+static bfd_reloc_status_type elf64_alpha_reloc_nil
+ PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type elf64_alpha_reloc_bad
+ PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type elf64_alpha_do_reloc_gpdisp
+ PARAMS((bfd *, bfd_vma, bfd_byte *, bfd_byte *));
+static bfd_reloc_status_type elf64_alpha_reloc_gpdisp
+ PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+
+static reloc_howto_type * elf64_alpha_bfd_reloc_type_lookup
+ PARAMS((bfd *, bfd_reloc_code_real_type));
+static void elf64_alpha_info_to_howto
+ PARAMS((bfd *, arelent *, Elf64_Internal_Rela *));
+
+static boolean elf64_alpha_object_p
+ PARAMS((bfd *));
+static boolean elf64_alpha_section_from_shdr
+ PARAMS((bfd *, Elf64_Internal_Shdr *, char *));
+static boolean elf64_alpha_fake_sections
+ PARAMS((bfd *, Elf64_Internal_Shdr *, asection *));
+static boolean elf64_alpha_create_got_section
+ PARAMS((bfd *, struct bfd_link_info *));
+static boolean elf64_alpha_create_dynamic_sections
+ PARAMS((bfd *, struct bfd_link_info *));
+
+static boolean elf64_alpha_read_ecoff_info
+ PARAMS((bfd *, asection *, struct ecoff_debug_info *));
+static boolean elf64_alpha_is_local_label_name
+ PARAMS((bfd *, const char *));
+static boolean elf64_alpha_find_nearest_line
+ PARAMS((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct alpha_elf_link_hash_entry;
+#endif
+
+static boolean elf64_alpha_output_extsym
+ PARAMS((struct alpha_elf_link_hash_entry *, PTR));
+
+static boolean elf64_alpha_can_merge_gots
+ PARAMS((bfd *, bfd *));
+static void elf64_alpha_merge_gots
+ PARAMS((bfd *, bfd *));
+static boolean elf64_alpha_calc_got_offsets_for_symbol
+ PARAMS ((struct alpha_elf_link_hash_entry *, PTR));
+static void elf64_alpha_calc_got_offsets PARAMS ((struct bfd_link_info *));
+static boolean elf64_alpha_size_got_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf64_alpha_always_size_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf64_alpha_calc_dynrel_sizes
+ PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *));
+static boolean elf64_alpha_add_symbol_hook
+ PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+ const char **, flagword *, asection **, bfd_vma *));
+static boolean elf64_alpha_check_relocs
+ PARAMS((bfd *, struct bfd_link_info *, asection *sec,
+ const Elf_Internal_Rela *));
+static boolean elf64_alpha_adjust_dynamic_symbol
+ PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean elf64_alpha_size_dynamic_sections
+ PARAMS((bfd *, struct bfd_link_info *));
+static boolean elf64_alpha_adjust_dynindx
+ PARAMS((struct elf_link_hash_entry *, PTR));
+static boolean elf64_alpha_relocate_section
+ PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean elf64_alpha_finish_dynamic_symbol
+ PARAMS((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static boolean elf64_alpha_finish_dynamic_sections
+ PARAMS((bfd *, struct bfd_link_info *));
+static boolean elf64_alpha_final_link
+ PARAMS((bfd *, struct bfd_link_info *));
+
+
+struct alpha_elf_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* External symbol information. */
+ EXTR esym;
+
+ /* Cumulative flags for all the .got entries. */
+ int flags;
+
+ /* Contexts (LITUSE) in which a literal was referenced. */
+#define ALPHA_ELF_LINK_HASH_LU_ADDR 0x01
+#define ALPHA_ELF_LINK_HASH_LU_MEM 0x02
+#define ALPHA_ELF_LINK_HASH_LU_BYTE 0x04
+#define ALPHA_ELF_LINK_HASH_LU_FUNC 0x08
+
+ /* Used to implement multiple .got subsections. */
+ struct alpha_elf_got_entry
+ {
+ struct alpha_elf_got_entry *next;
+
+ /* which .got subsection? */
+ bfd *gotobj;
+
+ /* the addend in effect for this entry. */
+ bfd_vma addend;
+
+ /* the .got offset for this entry. */
+ int got_offset;
+
+ int flags;
+
+ /* An additional flag. */
+#define ALPHA_ELF_GOT_ENTRY_RELOCS_DONE 0x10
+
+ int use_count;
+ } *got_entries;
+
+ /* used to count non-got, non-plt relocations for delayed sizing
+ of relocation sections. */
+ struct alpha_elf_reloc_entry
+ {
+ struct alpha_elf_reloc_entry *next;
+
+ /* which .reloc section? */
+ asection *srel;
+
+ /* what kind of relocation? */
+ unsigned long rtype;
+
+ /* how many did we find? */
+ unsigned long count;
+ } *reloc_entries;
+};
+
+/* Alpha ELF linker hash table. */
+
+struct alpha_elf_link_hash_table
+{
+ struct elf_link_hash_table root;
+
+ /* The head of a list of .got subsections linked through
+ alpha_elf_tdata(abfd)->got_link_next. */
+ bfd *got_list;
+};
+
+/* Look up an entry in a Alpha ELF linker hash table. */
+
+#define alpha_elf_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct alpha_elf_link_hash_entry *) \
+ elf_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+/* Traverse a Alpha ELF linker hash table. */
+
+#define alpha_elf_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the Alpha ELF linker hash table from a link_info structure. */
+
+#define alpha_elf_hash_table(p) \
+ ((struct alpha_elf_link_hash_table *) ((p)->hash))
+
+/* Get the object's symbols as our own entry type. */
+
+#define alpha_elf_sym_hashes(abfd) \
+ ((struct alpha_elf_link_hash_entry **)elf_sym_hashes(abfd))
+
+/* Should we do dynamic things to this symbol? */
+
+#define alpha_elf_dynamic_symbol_p(h, info) \
+ ((((info)->shared && !(info)->symbolic) \
+ || (((h)->elf_link_hash_flags \
+ & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) \
+ == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) \
+ || (h)->root.type == bfd_link_hash_undefweak \
+ || (h)->root.type == bfd_link_hash_defweak) \
+ && (h)->dynindx != -1)
+
+/* Create an entry in a Alpha ELF linker hash table. */
+
+static struct bfd_hash_entry *
+elf64_alpha_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct alpha_elf_link_hash_entry *ret =
+ (struct alpha_elf_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct alpha_elf_link_hash_entry *) NULL)
+ ret = ((struct alpha_elf_link_hash_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct alpha_elf_link_hash_entry)));
+ if (ret == (struct alpha_elf_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct alpha_elf_link_hash_entry *)
+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != (struct alpha_elf_link_hash_entry *) NULL)
+ {
+ /* Set local fields. */
+ memset (&ret->esym, 0, sizeof (EXTR));
+ /* We use -2 as a marker to indicate that the information has
+ not been set. -1 means there is no associated ifd. */
+ ret->esym.ifd = -2;
+ ret->flags = 0;
+ ret->got_entries = NULL;
+ ret->reloc_entries = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a Alpha ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+elf64_alpha_bfd_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct alpha_elf_link_hash_table *ret;
+
+ ret = ((struct alpha_elf_link_hash_table *)
+ bfd_zalloc (abfd, sizeof (struct alpha_elf_link_hash_table)));
+ if (ret == (struct alpha_elf_link_hash_table *) NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
+ elf64_alpha_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ return &ret->root.root;
+}
+
+/* We have some private fields hanging off of the elf_tdata structure. */
+
+struct alpha_elf_obj_tdata
+{
+ struct elf_obj_tdata root;
+
+ /* For every input file, these are the got entries for that object's
+ local symbols. */
+ struct alpha_elf_got_entry ** local_got_entries;
+
+ /* For every input file, this is the object that owns the got that
+ this input file uses. */
+ bfd *gotobj;
+
+ /* For every got, this is a linked list through the objects using this got */
+ bfd *in_got_link_next;
+
+ /* For every got, this is a link to the next got subsegment. */
+ bfd *got_link_next;
+
+ /* For every got, this is the section. */
+ asection *got;
+
+ /* For every got, this is it's total number of *entries*. */
+ int total_got_entries;
+
+ /* For every got, this is the sum of the number of *entries* required
+ to hold all of the member object's local got. */
+ int n_local_got_entries;
+};
+
+#define alpha_elf_tdata(abfd) \
+ ((struct alpha_elf_obj_tdata *) (abfd)->tdata.any)
+
+static boolean
+elf64_alpha_mkobject (abfd)
+ bfd *abfd;
+{
+ abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata));
+ if (abfd->tdata.any == NULL)
+ return false;
+ return true;
+}
+
+static boolean
+elf64_alpha_object_p (abfd)
+ bfd *abfd;
+{
+ /* Allocate our special target data. */
+ struct alpha_elf_obj_tdata *new_tdata;
+ new_tdata = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata));
+ if (new_tdata == NULL)
+ return false;
+ new_tdata->root = *abfd->tdata.elf_obj_data;
+ abfd->tdata.any = new_tdata;
+
+ /* Set the right machine number for an Alpha ELF file. */
+ return bfd_default_set_arch_mach (abfd, bfd_arch_alpha, 0);
+}
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+static reloc_howto_type elf64_alpha_howto_table[] =
+{
+ HOWTO (R_ALPHA_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_nil, /* special_function */
+ "NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A 32 bit reference to a symbol. */
+ HOWTO (R_ALPHA_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 */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 64 bit reference to a symbol. */
+ HOWTO (R_ALPHA_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 */
+ false, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_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 (R_ALPHA_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 */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Used for an instruction that refers to memory off the GP register. */
+ HOWTO (R_ALPHA_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 */
+ "ELF_LITERAL", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* This reloc only appears immediately following an ELF_LITERAL reloc.
+ It identifies a use of the literal. 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 (R_ALPHA_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 */
+ elf64_alpha_reloc_nil, /* special_function */
+ "LITUSE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_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 symbol
+ index of the GPDISP instruction is an offset in bytes to the lda
+ instruction that loads the lower 16 bits. 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.
+
+ NOTE: Unlike ECOFF, partial in-place relocation is not done. If
+ any offset is present in the instructions, it is an offset from
+ the register to the ldah instruction. This lets us avoid any
+ stupid hackery like inventing a gp value to do partial relocation
+ against. Also unlike ECOFF, we do the whole relocation off of
+ the GPDISP rather than a GPDISP_HI16/GPDISP_LO16 pair. An odd,
+ space consuming bit, that, since all the information was present
+ in the GPDISP_HI16 reloc. */
+ HOWTO (R_ALPHA_GPDISP, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_gpdisp, /* special_function */
+ "GPDISP", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A 21 bit branch. */
+ HOWTO (R_ALPHA_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 */
+ 0x1fffff, /* src_mask */
+ 0x1fffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* A hint for a jump to a register. */
+ HOWTO (R_ALPHA_HINT, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 14, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ 0, /* special_function */
+ "HINT", /* name */
+ false, /* partial_inplace */
+ 0x3fff, /* src_mask */
+ 0x3fff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 16 bit PC relative offset. */
+ HOWTO (R_ALPHA_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 */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit PC relative offset. */
+ HOWTO (R_ALPHA_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 */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 64 bit PC relative offset. */
+ HOWTO (R_ALPHA_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 */
+ false, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Push a value on the reloc evaluation stack. */
+ /* Not implemented -- it's dumb. */
+ HOWTO (R_ALPHA_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 */
+ elf64_alpha_reloc_bad, /* special_function */
+ "OP_PUSH", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_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. */
+ /* Not implemented -- it's dumb. */
+ HOWTO (R_ALPHA_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 */
+ elf64_alpha_reloc_bad, /* special_function */
+ "OP_STORE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Subtract the reloc address from the value on the top of the
+ relocation stack. */
+ /* Not implemented -- it's dumb. */
+ HOWTO (R_ALPHA_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 */
+ elf64_alpha_reloc_bad, /* special_function */
+ "OP_PSUB", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Shift the value on the top of the relocation stack right by the
+ given value. */
+ /* Not implemented -- it's dumb. */
+ HOWTO (R_ALPHA_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 */
+ elf64_alpha_reloc_bad, /* special_function */
+ "OP_PRSHIFT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Change the value of GP used by +r_addend until the next GPVALUE or the
+ end of the input bfd. */
+ /* Not implemented -- it's dumb. */
+ HOWTO (R_ALPHA_GPVALUE,
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "GPVALUE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high 16 bits of the displacement from GP to the target. */
+ HOWTO (R_ALPHA_GPRELHIGH,
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "GPRELHIGH", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The low 16 bits of the displacement from GP to the target. */
+ HOWTO (R_ALPHA_GPRELLOW,
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "GPRELLOW", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 16-bit displacement from the GP to the target. */
+ /* XXX: Not implemented. */
+ HOWTO (R_ALPHA_IMMED_GP_16,
+ 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 */
+ "IMMED_GP_16", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high bits of a 32-bit displacement from the GP to the target; the
+ low bits are supplied in the subsequent R_ALPHA_IMMED_LO32 relocs. */
+ /* XXX: Not implemented. */
+ HOWTO (R_ALPHA_IMMED_GP_HI32,
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "IMMED_GP_HI32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high bits of a 32-bit displacement to the starting address of the
+ current section (the relocation target is ignored); the low bits are
+ supplied in the subsequent R_ALPHA_IMMED_LO32 relocs. */
+ /* XXX: Not implemented. */
+ HOWTO (R_ALPHA_IMMED_SCN_HI32,
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "IMMED_SCN_HI32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The high bits of a 32-bit displacement from the previous br, bsr, jsr
+ or jmp insn (as tagged by a BRADDR or HINT reloc) to the target; the
+ low bits are supplied by subsequent R_ALPHA_IMMED_LO32 relocs. */
+ /* XXX: Not implemented. */
+ HOWTO (R_ALPHA_IMMED_BR_HI32,
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "IMMED_BR_HI32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* The low 16 bits of a displacement calculated in a previous HI32 reloc. */
+ /* XXX: Not implemented. */
+ HOWTO (R_ALPHA_IMMED_LO32,
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ elf64_alpha_reloc_bad, /* special_function */
+ "IMMED_LO32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Misc ELF relocations. */
+
+ /* A dynamic relocation to copy the target into our .dynbss section. */
+ /* Not generated, as all Alpha objects use PIC, so it is not needed. It
+ is present because every other ELF has one, but should not be used
+ because .dynbss is an ugly thing. */
+ HOWTO (R_ALPHA_COPY,
+ 0,
+ 0,
+ 0,
+ false,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "COPY",
+ false,
+ 0,
+ 0,
+ true),
+
+ /* A dynamic relocation for a .got entry. */
+ HOWTO (R_ALPHA_GLOB_DAT,
+ 0,
+ 0,
+ 0,
+ false,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "GLOB_DAT",
+ false,
+ 0,
+ 0,
+ true),
+
+ /* A dynamic relocation for a .plt entry. */
+ HOWTO (R_ALPHA_JMP_SLOT,
+ 0,
+ 0,
+ 0,
+ false,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "JMP_SLOT",
+ false,
+ 0,
+ 0,
+ true),
+
+ /* A dynamic relocation to add the base of the DSO to a 64-bit field. */
+ HOWTO (R_ALPHA_RELATIVE,
+ 0,
+ 0,
+ 0,
+ false,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "RELATIVE",
+ false,
+ 0,
+ 0,
+ true)
+};
+
+/* A relocation function which doesn't do anything. */
+
+static bfd_reloc_status_type
+elf64_alpha_reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc;
+ asymbol *sym;
+ PTR data;
+ asection *sec;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd)
+ reloc->address += sec->output_offset;
+ return bfd_reloc_ok;
+}
+
+/* A relocation function used for an unsupported reloc. */
+
+static bfd_reloc_status_type
+elf64_alpha_reloc_bad (abfd, reloc, sym, data, sec, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc;
+ asymbol *sym;
+ PTR data;
+ asection *sec;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd)
+ reloc->address += sec->output_offset;
+ return bfd_reloc_notsupported;
+}
+
+/* Do the work of the GPDISP relocation. */
+
+static bfd_reloc_status_type
+elf64_alpha_do_reloc_gpdisp (abfd, gpdisp, p_ldah, p_lda)
+ bfd *abfd;
+ bfd_vma gpdisp;
+ bfd_byte *p_ldah;
+ bfd_byte *p_lda;
+{
+ bfd_reloc_status_type ret = bfd_reloc_ok;
+ bfd_vma addend;
+ unsigned long i_ldah, i_lda;
+
+ i_ldah = bfd_get_32 (abfd, p_ldah);
+ i_lda = bfd_get_32 (abfd, p_lda);
+
+ /* Complain if the instructions are not correct. */
+ if (((i_ldah >> 26) & 0x3f) != 0x09
+ || ((i_lda >> 26) & 0x3f) != 0x08)
+ ret = bfd_reloc_dangerous;
+
+ /* Extract the user-supplied offset, mirroring the sign extensions
+ that the instructions perform. */
+ addend = ((i_ldah & 0xffff) << 16) | (i_lda & 0xffff);
+ addend = (addend ^ 0x80008000) - 0x80008000;
+
+ gpdisp += addend;
+
+ if ((bfd_signed_vma) gpdisp < -(bfd_signed_vma) 0x80000000
+ || (bfd_signed_vma) gpdisp >= (bfd_signed_vma) 0x7fff8000)
+ ret = bfd_reloc_overflow;
+
+ /* compensate for the sign extension again. */
+ i_ldah = ((i_ldah & 0xffff0000)
+ | (((gpdisp >> 16) + ((gpdisp >> 15) & 1)) & 0xffff));
+ i_lda = (i_lda & 0xffff0000) | (gpdisp & 0xffff);
+
+ bfd_put_32 (abfd, i_ldah, p_ldah);
+ bfd_put_32 (abfd, i_lda, p_lda);
+
+ return ret;
+}
+
+/* The special function for the GPDISP reloc. */
+
+static bfd_reloc_status_type
+elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section,
+ output_bfd, err_msg)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *sym;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **err_msg;
+{
+ bfd_reloc_status_type ret;
+ bfd_vma gp, relocation;
+ bfd_byte *p_ldah, *p_lda;
+
+ /* Don't do anything if we're not doing a final link. */
+ if (output_bfd)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (reloc_entry->address > input_section->_cooked_size ||
+ reloc_entry->address + reloc_entry->addend > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* The gp used in the portion of the output object to which this
+ input object belongs is cached on the input bfd. */
+ gp = _bfd_get_gp_value (abfd);
+
+ relocation = (input_section->output_section->vma
+ + input_section->output_offset
+ + reloc_entry->address);
+
+ p_ldah = (bfd_byte *) data + reloc_entry->address;
+ p_lda = p_ldah + reloc_entry->addend;
+
+ ret = elf64_alpha_do_reloc_gpdisp (abfd, gp - relocation, p_ldah, p_lda);
+
+ /* Complain if the instructions are not correct. */
+ if (ret == bfd_reloc_dangerous)
+ *err_msg = _("GPDISP relocation did not find ldah and lda instructions");
+
+ return ret;
+}
+
+/* A mapping from BFD reloc types to Alpha ELF reloc types. */
+
+struct elf_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ int elf_reloc_val;
+};
+
+static const struct elf_reloc_map elf64_alpha_reloc_map[] =
+{
+ {BFD_RELOC_NONE, R_ALPHA_NONE},
+ {BFD_RELOC_32, R_ALPHA_REFLONG},
+ {BFD_RELOC_64, R_ALPHA_REFQUAD},
+ {BFD_RELOC_CTOR, R_ALPHA_REFQUAD},
+ {BFD_RELOC_GPREL32, R_ALPHA_GPREL32},
+ {BFD_RELOC_ALPHA_ELF_LITERAL, R_ALPHA_LITERAL},
+ {BFD_RELOC_ALPHA_LITUSE, R_ALPHA_LITUSE},
+ {BFD_RELOC_ALPHA_GPDISP, R_ALPHA_GPDISP},
+ {BFD_RELOC_23_PCREL_S2, R_ALPHA_BRADDR},
+ {BFD_RELOC_ALPHA_HINT, R_ALPHA_HINT},
+ {BFD_RELOC_16_PCREL, R_ALPHA_SREL16},
+ {BFD_RELOC_32_PCREL, R_ALPHA_SREL32},
+ {BFD_RELOC_64_PCREL, R_ALPHA_SREL64},
+};
+
+/* Given a BFD reloc type, return a HOWTO structure. */
+
+static reloc_howto_type *
+elf64_alpha_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ const struct elf_reloc_map *i, *e;
+ i = e = elf64_alpha_reloc_map;
+ e += sizeof (elf64_alpha_reloc_map) / sizeof (struct elf_reloc_map);
+ for (; i != e; ++i)
+ {
+ if (i->bfd_reloc_val == code)
+ return &elf64_alpha_howto_table[i->elf_reloc_val];
+ }
+ return 0;
+}
+
+/* Given an Alpha ELF reloc type, fill in an arelent structure. */
+
+static void
+elf64_alpha_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf64_Internal_Rela *dst;
+{
+ unsigned r_type;
+
+ r_type = ELF64_R_TYPE(dst->r_info);
+ BFD_ASSERT (r_type < (unsigned int) R_ALPHA_max);
+ cache_ptr->howto = &elf64_alpha_howto_table[r_type];
+}
+
+/* These functions do relaxation for Alpha ELF.
+
+ Currently I'm only handling what I can do with existing compiler
+ and assembler support, which means no instructions are removed,
+ though some may be nopped. At this time GCC does not emit enough
+ information to do all of the relaxing that is possible. It will
+ take some not small amount of work for that to happen.
+
+ There are a couple of interesting papers that I once read on this
+ subject, that I cannot find references to at the moment, that
+ related to Alpha in particular. They are by David Wall, then of
+ DEC WRL. */
+
+#define OP_LDA 0x08
+#define OP_LDAH 0x09
+#define INSN_JSR 0x68004000
+#define INSN_JSR_MASK 0xfc00c000
+#define OP_LDQ 0x29
+#define OP_BR 0x30
+#define OP_BSR 0x34
+#define INSN_UNOP 0x2fe00000
+
+struct alpha_relax_info
+{
+ bfd *abfd;
+ asection *sec;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs, *relend;
+ struct bfd_link_info *link_info;
+ boolean changed_contents;
+ boolean changed_relocs;
+ bfd_vma gp;
+ bfd *gotobj;
+ asection *tsec;
+ struct alpha_elf_link_hash_entry *h;
+ struct alpha_elf_got_entry *gotent;
+ unsigned char other;
+};
+
+static Elf_Internal_Rela * elf64_alpha_relax_with_lituse
+ PARAMS((struct alpha_relax_info *info, bfd_vma symval,
+ Elf_Internal_Rela *irel, Elf_Internal_Rela *irelend));
+
+static boolean elf64_alpha_relax_without_lituse
+ PARAMS((struct alpha_relax_info *info, bfd_vma symval,
+ Elf_Internal_Rela *irel));
+
+static bfd_vma elf64_alpha_relax_opt_call
+ PARAMS((struct alpha_relax_info *info, bfd_vma symval));
+
+static boolean elf64_alpha_relax_section
+ PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
+ boolean *again));
+
+static Elf_Internal_Rela *
+elf64_alpha_find_reloc_at_ofs (rel, relend, offset, type)
+ Elf_Internal_Rela *rel, *relend;
+ bfd_vma offset;
+ int type;
+{
+ while (rel < relend)
+ {
+ if (rel->r_offset == offset && ELF64_R_TYPE (rel->r_info) == type)
+ return rel;
+ ++rel;
+ }
+ return NULL;
+}
+
+static Elf_Internal_Rela *
+elf64_alpha_relax_with_lituse (info, symval, irel, irelend)
+ struct alpha_relax_info *info;
+ bfd_vma symval;
+ Elf_Internal_Rela *irel, *irelend;
+{
+ Elf_Internal_Rela *urel;
+ int flags, count, i;
+ bfd_signed_vma disp;
+ boolean fits16;
+ boolean fits32;
+ boolean lit_reused = false;
+ boolean all_optimized = true;
+ unsigned int lit_insn;
+
+ lit_insn = bfd_get_32 (info->abfd, info->contents + irel->r_offset);
+ if (lit_insn >> 26 != OP_LDQ)
+ {
+ ((*_bfd_error_handler)
+ ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn",
+ bfd_get_filename (info->abfd), info->sec->name,
+ (unsigned long)irel->r_offset));
+ return irel;
+ }
+
+ /* Summarize how this particular LITERAL is used. */
+ for (urel = irel+1, flags = count = 0; urel < irelend; ++urel, ++count)
+ {
+ if (ELF64_R_TYPE (urel->r_info) != R_ALPHA_LITUSE)
+ break;
+ if (urel->r_addend >= 0 && urel->r_addend <= 3)
+ flags |= 1 << urel->r_addend;
+ }
+
+ /* A little preparation for the loop... */
+ disp = symval - info->gp;
+ fits16 = (disp >= -(bfd_signed_vma)0x8000 && disp < 0x8000);
+ fits32 = (disp >= -(bfd_signed_vma)0x80000000 && disp < 0x7fff8000);
+
+ for (urel = irel+1, i = 0; i < count; ++i, ++urel)
+ {
+ unsigned int insn;
+ insn = bfd_get_32 (info->abfd, info->contents + urel->r_offset);
+
+ switch (urel->r_addend)
+ {
+ default: /* 0 = ADDRESS FORMAT */
+ /* This type is really just a placeholder to note that all
+ uses cannot be optimized, but to still allow some. */
+ all_optimized = false;
+ break;
+
+ case 1: /* MEM FORMAT */
+ /* We can always optimize 16-bit displacements. */
+ if (fits16)
+ {
+ /* FIXME: sanity check the insn for mem format with
+ zero addend. */
+
+ /* Take the op code and dest from this insn, take the base
+ register from the literal insn. Leave the offset alone. */
+ insn = (insn & 0xffe00000) | (lit_insn & 0x001f0000);
+ urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+ R_ALPHA_GPRELLOW);
+ urel->r_addend = irel->r_addend;
+ info->changed_relocs = true;
+
+ bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
+ info->changed_contents = true;
+ }
+
+ /* If all mem+byte, we can optimize 32-bit mem displacements. */
+ else if (fits32 && !(flags & ~6))
+ {
+ /* FIXME: sanity check that lit insn Ra is mem insn Rb, and
+ that mem_insn disp is zero. */
+
+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+ R_ALPHA_GPRELHIGH);
+ lit_insn = (OP_LDAH << 26) | (lit_insn & 0x03ff0000);
+ bfd_put_32 (info->abfd, lit_insn,
+ info->contents + irel->r_offset);
+ lit_reused = true;
+ info->changed_contents = true;
+
+ urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+ R_ALPHA_GPRELLOW);
+ urel->r_addend = irel->r_addend;
+ info->changed_relocs = true;
+ }
+ else
+ all_optimized = false;
+ break;
+
+ case 2: /* BYTE OFFSET FORMAT */
+ /* We can always optimize byte instructions. */
+
+ /* FIXME: sanity check the insn for byte op. Check that the
+ literal dest reg is indeed Rb in the byte insn. */
+
+ insn = (insn & ~0x001ff000) | ((symval & 7) << 13) | 0x1000;
+
+ urel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
+ urel->r_addend = 0;
+ info->changed_relocs = true;
+
+ bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
+ info->changed_contents = true;
+ break;
+
+ case 3: /* CALL FORMAT */
+ {
+ /* If not zero, place to jump without needing pv. */
+ bfd_vma optdest = elf64_alpha_relax_opt_call (info, symval);
+ bfd_vma org = (info->sec->output_section->vma
+ + info->sec->output_offset
+ + urel->r_offset + 4);
+ bfd_signed_vma odisp;
+
+ odisp = (optdest ? optdest : symval) - org;
+ if (odisp >= -0x400000 && odisp < 0x400000)
+ {
+ Elf_Internal_Rela *xrel;
+
+ /* Preserve branch prediction call stack when possible. */
+ if ((insn & INSN_JSR_MASK) == INSN_JSR)
+ insn = (OP_BSR << 26) | (insn & 0x03e00000);
+ else
+ insn = (OP_BR << 26) | (insn & 0x03e00000);
+
+ urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+ R_ALPHA_BRADDR);
+ urel->r_addend = irel->r_addend;
+
+ if (optdest)
+ urel->r_addend += optdest - symval;
+ else
+ all_optimized = false;
+
+ bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
+
+ /* Kill any HINT reloc that might exist for this insn. */
+ xrel = (elf64_alpha_find_reloc_at_ofs
+ (info->relocs, info->relend, urel->r_offset,
+ R_ALPHA_HINT));
+ if (xrel)
+ xrel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
+
+ info->changed_contents = true;
+ info->changed_relocs = true;
+ }
+ else
+ all_optimized = false;
+
+ /* ??? If target gp == current gp we can eliminate the gp reload.
+ This does depend on every place a gp could be reloaded will
+ be, which currently happens for all code produced by gcc, but
+ not necessarily by hand-coded assembly, or if sibling calls
+ are enabled in gcc.
+
+ Perhaps conditionalize this on a flag being set in the target
+ object file's header, and have gcc set it? */
+ }
+ break;
+ }
+ }
+
+ /* If all cases were optimized, we can reduce the use count on this
+ got entry by one, possibly eliminating it. */
+ if (all_optimized)
+ {
+ info->gotent->use_count -= 1;
+ alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1;
+ if (!info->h)
+ alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1;
+
+ /* If the literal instruction is no longer needed (it may have been
+ reused. We can eliminate it.
+ ??? For now, I don't want to deal with compacting the section,
+ so just nop it out. */
+ if (!lit_reused)
+ {
+ irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
+ info->changed_relocs = true;
+
+ bfd_put_32 (info->abfd, INSN_UNOP, info->contents + irel->r_offset);
+ info->changed_contents = true;
+ }
+ }
+
+ return irel + count;
+}
+
+static bfd_vma
+elf64_alpha_relax_opt_call (info, symval)
+ struct alpha_relax_info *info;
+ bfd_vma symval;
+{
+ /* If the function has the same gp, and we can identify that the
+ function does not use its function pointer, we can eliminate the
+ address load. */
+
+ /* If the symbol is marked NOPV, we are being told the function never
+ needs its procedure value. */
+ if (info->other == STO_ALPHA_NOPV)
+ return symval;
+
+ /* If the symbol is marked STD_GP, we are being told the function does
+ a normal ldgp in the first two words. */
+ else if (info->other == STO_ALPHA_STD_GPLOAD)
+ ;
+
+ /* Otherwise, we may be able to identify a GP load in the first two
+ words, which we can then skip. */
+ else
+ {
+ Elf_Internal_Rela *tsec_relocs, *tsec_relend, *tsec_free, *gpdisp;
+ bfd_vma ofs;
+
+ /* Load the relocations from the section that the target symbol is in. */
+ if (info->sec == info->tsec)
+ {
+ tsec_relocs = info->relocs;
+ tsec_relend = info->relend;
+ tsec_free = NULL;
+ }
+ else
+ {
+ tsec_relocs = (_bfd_elf64_link_read_relocs
+ (info->abfd, info->tsec, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL,
+ info->link_info->keep_memory));
+ if (tsec_relocs == NULL)
+ return 0;
+ tsec_relend = tsec_relocs + info->tsec->reloc_count;
+ tsec_free = (info->link_info->keep_memory ? NULL : tsec_relocs);
+ }
+
+ /* Recover the symbol's offset within the section. */
+ ofs = (symval - info->tsec->output_section->vma
+ - info->tsec->output_offset);
+
+ /* Look for a GPDISP reloc. */
+ gpdisp = (elf64_alpha_find_reloc_at_ofs
+ (tsec_relocs, tsec_relend, ofs, R_ALPHA_GPDISP));
+
+ if (!gpdisp || gpdisp->r_addend != 4)
+ {
+ if (tsec_free)
+ free (tsec_free);
+ return 0;
+ }
+ if (tsec_free)
+ free (tsec_free);
+ }
+
+ /* We've now determined that we can skip an initial gp load. Verify
+ that the call and the target use the same gp. */
+ if (info->link_info->hash->creator != info->tsec->owner->xvec
+ || info->gotobj != alpha_elf_tdata (info->tsec->owner)->gotobj)
+ return 0;
+
+ return symval + 8;
+}
+
+static boolean
+elf64_alpha_relax_without_lituse (info, symval, irel)
+ struct alpha_relax_info *info;
+ bfd_vma symval;
+ Elf_Internal_Rela *irel;
+{
+ unsigned int insn;
+ bfd_signed_vma disp;
+
+ /* Get the instruction. */
+ insn = bfd_get_32 (info->abfd, info->contents + irel->r_offset);
+
+ if (insn >> 26 != OP_LDQ)
+ {
+ ((*_bfd_error_handler)
+ ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn",
+ bfd_get_filename (info->abfd), info->sec->name,
+ (unsigned long) irel->r_offset));
+ return true;
+ }
+
+ /* So we aren't told much. Do what we can with the address load and
+ fake the rest. All of the optimizations here require that the
+ offset from the GP fit in 16 bits. */
+
+ disp = symval - info->gp;
+ if (disp < -0x8000 || disp >= 0x8000)
+ return true;
+
+ /* On the LITERAL instruction itself, consider exchanging
+ `ldq R,X(gp)' for `lda R,Y(gp)'. */
+
+ insn = (OP_LDA << 26) | (insn & 0x03ff0000);
+ bfd_put_32 (info->abfd, insn, info->contents + irel->r_offset);
+ info->changed_contents = true;
+
+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), R_ALPHA_GPRELLOW);
+ info->changed_relocs = true;
+
+ /* Reduce the use count on this got entry by one, possibly
+ eliminating it. */
+ info->gotent->use_count -= 1;
+ alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1;
+ if (!info->h)
+ alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1;
+
+ /* ??? Search forward through this basic block looking for insns
+ that use the target register. Stop after an insn modifying the
+ register is seen, or after a branch or call.
+
+ Any such memory load insn may be substituted by a load directly
+ off the GP. This allows the memory load insn to be issued before
+ the calculated GP register would otherwise be ready.
+
+ Any such jsr insn can be replaced by a bsr if it is in range.
+
+ This would mean that we'd have to _add_ relocations, the pain of
+ which gives one pause. */
+
+ return true;
+}
+
+static boolean
+elf64_alpha_relax_section (abfd, sec, link_info, again)
+ bfd *abfd;
+ asection *sec;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *internal_relocs;
+ Elf_Internal_Rela *free_relocs = NULL;
+ Elf_Internal_Rela *irel, *irelend;
+ bfd_byte *free_contents = NULL;
+ Elf64_External_Sym *extsyms = NULL;
+ Elf64_External_Sym *free_extsyms = NULL;
+ struct alpha_elf_got_entry **local_got_entries;
+ struct alpha_relax_info info;
+
+ /* We are not currently changing any sizes, so only one pass. */
+ *again = false;
+
+ if (link_info->relocateable
+ || (sec->flags & SEC_RELOC) == 0
+ || sec->reloc_count == 0)
+ return true;
+
+ /* If this is the first time we have been called for this section,
+ initialize the cooked size. */
+ if (sec->_cooked_size == 0)
+ sec->_cooked_size = sec->_raw_size;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
+
+ /* Load the relocations for this section. */
+ internal_relocs = (_bfd_elf64_link_read_relocs
+ (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ link_info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+ if (! link_info->keep_memory)
+ free_relocs = internal_relocs;
+
+ memset(&info, 0, sizeof(info));
+ info.abfd = abfd;
+ info.sec = sec;
+ info.link_info = link_info;
+ info.relocs = internal_relocs;
+ info.relend = irelend = internal_relocs + sec->reloc_count;
+
+ /* Find the GP for this object. */
+ info.gotobj = alpha_elf_tdata (abfd)->gotobj;
+ if (info.gotobj)
+ {
+ asection *sgot = alpha_elf_tdata (info.gotobj)->got;
+ info.gp = _bfd_get_gp_value (info.gotobj);
+ if (info.gp == 0)
+ {
+ info.gp = (sgot->output_section->vma
+ + sgot->output_offset
+ + 0x8000);
+ _bfd_set_gp_value (info.gotobj, info.gp);
+ }
+ }
+
+ for (irel = internal_relocs; irel < irelend; irel++)
+ {
+ bfd_vma symval;
+ Elf_Internal_Sym isym;
+ struct alpha_elf_got_entry *gotent;
+
+ if (ELF64_R_TYPE (irel->r_info) != (int) R_ALPHA_LITERAL)
+ continue;
+
+ /* Get the section contents. */
+ if (info.contents == NULL)
+ {
+ if (elf_section_data (sec)->this_hdr.contents != NULL)
+ info.contents = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (info.contents == NULL)
+ goto error_return;
+ free_contents = info.contents;
+
+ if (! bfd_get_section_contents (abfd, sec, info.contents,
+ (file_ptr) 0, sec->_raw_size))
+ goto error_return;
+ }
+ }
+
+ /* Read this BFD's symbols if we haven't done so already. */
+ if (extsyms == NULL)
+ {
+ if (symtab_hdr->contents != NULL)
+ extsyms = (Elf64_External_Sym *) symtab_hdr->contents;
+ else
+ {
+ extsyms = ((Elf64_External_Sym *)
+ bfd_malloc (symtab_hdr->sh_size));
+ if (extsyms == NULL)
+ goto error_return;
+ free_extsyms = extsyms;
+ if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ != symtab_hdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ /* Get the value of the symbol referred to by the reloc. */
+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+ {
+ /* A local symbol. */
+ bfd_elf64_swap_symbol_in (abfd,
+ extsyms + ELF64_R_SYM (irel->r_info),
+ &isym);
+ if (isym.st_shndx == SHN_UNDEF)
+ info.tsec = bfd_und_section_ptr;
+ else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
+ info.tsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
+ else if (isym.st_shndx == SHN_ABS)
+ info.tsec = bfd_abs_section_ptr;
+ else if (isym.st_shndx == SHN_COMMON)
+ info.tsec = bfd_com_section_ptr;
+ else
+ continue; /* who knows. */
+
+ info.h = NULL;
+ info.other = isym.st_other;
+ gotent = local_got_entries[ELF64_R_SYM(irel->r_info)];
+ symval = isym.st_value;
+ }
+ else
+ {
+ unsigned long indx;
+ struct alpha_elf_link_hash_entry *h;
+
+ indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+ h = alpha_elf_sym_hashes (abfd)[indx];
+ BFD_ASSERT (h != NULL);
+
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+
+ /* We can't do anthing with undefined or dynamic symbols. */
+ if (h->root.root.type == bfd_link_hash_undefined
+ || h->root.root.type == bfd_link_hash_undefweak
+ || alpha_elf_dynamic_symbol_p (&h->root, link_info))
+ continue;
+
+ info.h = h;
+ info.gotent = gotent;
+ info.tsec = h->root.root.u.def.section;
+ info.other = h->root.other;
+ gotent = h->got_entries;
+ symval = h->root.root.u.def.value;
+ }
+
+ /* Search for the got entry to be used by this relocation. */
+ while (gotent->gotobj != info.gotobj || gotent->addend != irel->r_addend)
+ gotent = gotent->next;
+ info.gotent = gotent;
+
+ symval += info.tsec->output_section->vma + info.tsec->output_offset;
+ symval += irel->r_addend;
+
+ BFD_ASSERT(info.gotent != NULL);
+
+ /* If there exist LITUSE relocations immediately following, this
+ opens up all sorts of interesting optimizations, because we
+ now know every location that this address load is used. */
+
+ if (irel+1 < irelend && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE)
+ {
+ irel = elf64_alpha_relax_with_lituse (&info, symval, irel, irelend);
+ if (irel == NULL)
+ goto error_return;
+ }
+ else
+ {
+ if (!elf64_alpha_relax_without_lituse (&info, symval, irel))
+ goto error_return;
+ }
+ }
+
+ if (!elf64_alpha_size_got_sections (abfd, link_info))
+ return false;
+
+ if (info.changed_relocs)
+ {
+ elf_section_data (sec)->relocs = internal_relocs;
+ }
+ else if (free_relocs != NULL)
+ {
+ free (free_relocs);
+ }
+
+ if (info.changed_contents)
+ {
+ elf_section_data (sec)->this_hdr.contents = info.contents;
+ }
+ else if (free_contents != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_contents);
+ else
+ {
+ /* Cache the section contents for elf_link_input_bfd. */
+ elf_section_data (sec)->this_hdr.contents = info.contents;
+ }
+ }
+
+ if (free_extsyms != NULL)
+ {
+ if (! link_info->keep_memory)
+ free (free_extsyms);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = extsyms;
+ }
+ }
+
+ *again = info.changed_contents || info.changed_relocs;
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ if (free_contents != NULL)
+ free (free_contents);
+ if (free_extsyms != NULL)
+ free (free_extsyms);
+ return false;
+}
+
+/* PLT/GOT Stuff */
+#define PLT_HEADER_SIZE 32
+#define PLT_HEADER_WORD1 0xc3600000 /* br $27,.+4 */
+#define PLT_HEADER_WORD2 0xa77b000c /* ldq $27,12($27) */
+#define PLT_HEADER_WORD3 0x47ff041f /* nop */
+#define PLT_HEADER_WORD4 0x6b7b0000 /* jmp $27,($27) */
+
+#define PLT_ENTRY_SIZE 12
+#define PLT_ENTRY_WORD1 0xc3800000 /* br $28, plt0 */
+#define PLT_ENTRY_WORD2 0
+#define PLT_ENTRY_WORD3 0
+
+#define MAX_GOT_ENTRIES (64*1024 / 8)
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so"
+
+/* Handle an Alpha specific section when reading an object file. This
+ is called when elfcode.h finds a section with an unknown type.
+ FIXME: We need to handle the SHF_ALPHA_GPREL flag, but I'm not sure
+ how to. */
+
+static boolean
+elf64_alpha_section_from_shdr (abfd, hdr, name)
+ bfd *abfd;
+ Elf64_Internal_Shdr *hdr;
+ char *name;
+{
+ asection *newsect;
+
+ /* There ought to be a place to keep ELF backend specific flags, but
+ at the moment there isn't one. We just keep track of the
+ sections by their name, instead. Fortunately, the ABI gives
+ suggested names for all the MIPS specific sections, so we will
+ probably get away with this. */
+ switch (hdr->sh_type)
+ {
+ case SHT_ALPHA_DEBUG:
+ if (strcmp (name, ".mdebug") != 0)
+ return false;
+ break;
+#ifdef ERIC_neverdef
+ case SHT_ALPHA_REGINFO:
+ if (strcmp (name, ".reginfo") != 0
+ || hdr->sh_size != sizeof (Elf64_External_RegInfo))
+ return false;
+ break;
+#endif
+ default:
+ return false;
+ }
+
+ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+ return false;
+ newsect = hdr->bfd_section;
+
+ if (hdr->sh_type == SHT_ALPHA_DEBUG)
+ {
+ if (! bfd_set_section_flags (abfd, newsect,
+ (bfd_get_section_flags (abfd, newsect)
+ | SEC_DEBUGGING)))
+ return false;
+ }
+
+#ifdef ERIC_neverdef
+ /* For a .reginfo section, set the gp value in the tdata information
+ from the contents of this section. We need the gp value while
+ processing relocs, so we just get it now. */
+ if (hdr->sh_type == SHT_ALPHA_REGINFO)
+ {
+ Elf64_External_RegInfo ext;
+ Elf64_RegInfo s;
+
+ if (! bfd_get_section_contents (abfd, newsect, (PTR) &ext,
+ (file_ptr) 0, sizeof ext))
+ return false;
+ bfd_alpha_elf64_swap_reginfo_in (abfd, &ext, &s);
+ elf_gp (abfd) = s.ri_gp_value;
+ }
+#endif
+
+ return true;
+}
+
+/* Set the correct type for an Alpha ELF section. We do this by the
+ section name, which is a hack, but ought to work. */
+
+static boolean
+elf64_alpha_fake_sections (abfd, hdr, sec)
+ bfd *abfd;
+ Elf64_Internal_Shdr *hdr;
+ asection *sec;
+{
+ register const char *name;
+
+ name = bfd_get_section_name (abfd, sec);
+
+ if (strcmp (name, ".mdebug") == 0)
+ {
+ hdr->sh_type = SHT_ALPHA_DEBUG;
+ /* In a shared object on Irix 5.3, the .mdebug section has an
+ entsize of 0. FIXME: Does this matter? */
+ if ((abfd->flags & DYNAMIC) != 0 )
+ hdr->sh_entsize = 0;
+ else
+ hdr->sh_entsize = 1;
+ }
+#ifdef ERIC_neverdef
+ else if (strcmp (name, ".reginfo") == 0)
+ {
+ hdr->sh_type = SHT_ALPHA_REGINFO;
+ /* In a shared object on Irix 5.3, the .reginfo section has an
+ entsize of 0x18. FIXME: Does this matter? */
+ if ((abfd->flags & DYNAMIC) != 0)
+ hdr->sh_entsize = sizeof (Elf64_External_RegInfo);
+ else
+ hdr->sh_entsize = 1;
+
+ /* Force the section size to the correct value, even if the
+ linker thinks it is larger. The link routine below will only
+ write out this much data for .reginfo. */
+ hdr->sh_size = sec->_raw_size = sizeof (Elf64_External_RegInfo);
+ }
+ else if (strcmp (name, ".hash") == 0
+ || strcmp (name, ".dynamic") == 0
+ || strcmp (name, ".dynstr") == 0)
+ {
+ hdr->sh_entsize = 0;
+ hdr->sh_info = SIZEOF_ALPHA_DYNSYM_SECNAMES;
+ }
+#endif
+ else if (strcmp (name, ".sdata") == 0
+ || strcmp (name, ".sbss") == 0
+ || strcmp (name, ".lit4") == 0
+ || strcmp (name, ".lit8") == 0)
+ hdr->sh_flags |= SHF_ALPHA_GPREL;
+
+ return true;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+ file. We use it to put .comm items in .sbss, and not .bss. */
+
+static boolean
+elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const Elf_Internal_Sym *sym;
+ const char **namep;
+ flagword *flagsp;
+ asection **secp;
+ bfd_vma *valp;
+{
+ if (sym->st_shndx == SHN_COMMON
+ && !info->relocateable
+ && sym->st_size <= bfd_get_gp_size (abfd))
+ {
+ /* Common symbols less than or equal to -G nn bytes are
+ automatically put into .sbss. */
+
+ asection *scomm = bfd_get_section_by_name (abfd, ".scommon");
+
+ if (scomm == NULL)
+ {
+ scomm = bfd_make_section (abfd, ".scommon");
+ if (scomm == NULL
+ || !bfd_set_section_flags (abfd, scomm, (SEC_ALLOC
+ | SEC_IS_COMMON
+ | SEC_LINKER_CREATED)))
+ return false;
+ }
+
+ *secp = scomm;
+ *valp = sym->st_size;
+ }
+
+ return true;
+}
+
+/* Create the .got section. */
+
+static boolean
+elf64_alpha_create_got_section(abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection *s;
+
+ if (bfd_get_section_by_name (abfd, ".got"))
+ return true;
+
+ s = bfd_make_section (abfd, ".got");
+ if (s == NULL
+ || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED))
+ || !bfd_set_section_alignment (abfd, s, 3))
+ return false;
+
+ alpha_elf_tdata (abfd)->got = s;
+
+ return true;
+}
+
+/* Create all the dynamic sections. */
+
+static boolean
+elf64_alpha_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection *s;
+ struct elf_link_hash_entry *h;
+
+ /* We need to create .plt, .rela.plt, .got, and .rela.got sections. */
+
+ s = bfd_make_section (abfd, ".plt");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_CODE))
+ || ! bfd_set_section_alignment (abfd, s, 3))
+ return false;
+
+ /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
+ .plt section. */
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (info->shared
+ && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+
+ s = bfd_make_section (abfd, ".rela.plt");
+ if (s == NULL
+ || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (abfd, s, 3))
+ return false;
+
+ /* We may or may not have created a .got section for this object, but
+ we definitely havn't done the rest of the work. */
+
+ if (!elf64_alpha_create_got_section (abfd, info))
+ return false;
+
+ s = bfd_make_section(abfd, ".rela.got");
+ if (s == NULL
+ || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || !bfd_set_section_alignment (abfd, s, 3))
+ return false;
+
+ /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the
+ dynobj's .got section. We don't do this in the linker script
+ because we don't want to define the symbol if we are not creating
+ a global offset table. */
+ h = NULL;
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL,
+ alpha_elf_tdata(abfd)->got, (bfd_vma) 0, (const char *) NULL,
+ false, get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (info->shared
+ && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+
+ elf_hash_table (info)->hgot = h;
+
+ return true;
+}
+
+/* Read ECOFF debugging information from a .mdebug section into a
+ ecoff_debug_info structure. */
+
+static boolean
+elf64_alpha_read_ecoff_info (abfd, section, debug)
+ bfd *abfd;
+ asection *section;
+ struct ecoff_debug_info *debug;
+{
+ HDRR *symhdr;
+ const struct ecoff_debug_swap *swap;
+ char *ext_hdr = NULL;
+
+ swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+ memset (debug, 0, sizeof(*debug));
+
+ ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
+ if (ext_hdr == NULL && swap->external_hdr_size != 0)
+ goto error_return;
+
+ if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
+ swap->external_hdr_size)
+ == false)
+ goto error_return;
+
+ symhdr = &debug->symbolic_header;
+ (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr);
+
+ /* The symbolic header contains absolute file offsets and sizes to
+ read. */
+#define READ(ptr, offset, count, size, type) \
+ if (symhdr->count == 0) \
+ debug->ptr = NULL; \
+ else \
+ { \
+ debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
+ if (debug->ptr == NULL) \
+ goto error_return; \
+ if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
+ || (bfd_read (debug->ptr, size, symhdr->count, \
+ abfd) != size * symhdr->count)) \
+ goto error_return; \
+ }
+
+ READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
+ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
+ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
+ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
+ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
+ READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
+ union aux_ext *);
+ READ (ss, cbSsOffset, issMax, sizeof (char), char *);
+ READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
+ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
+ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
+ READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
+#undef READ
+
+ debug->fdr = NULL;
+ debug->adjust = NULL;
+
+ return true;
+
+ error_return:
+ if (ext_hdr != NULL)
+ free (ext_hdr);
+ if (debug->line != NULL)
+ free (debug->line);
+ if (debug->external_dnr != NULL)
+ free (debug->external_dnr);
+ if (debug->external_pdr != NULL)
+ free (debug->external_pdr);
+ if (debug->external_sym != NULL)
+ free (debug->external_sym);
+ if (debug->external_opt != NULL)
+ free (debug->external_opt);
+ if (debug->external_aux != NULL)
+ free (debug->external_aux);
+ if (debug->ss != NULL)
+ free (debug->ss);
+ if (debug->ssext != NULL)
+ free (debug->ssext);
+ if (debug->external_fdr != NULL)
+ free (debug->external_fdr);
+ if (debug->external_rfd != NULL)
+ free (debug->external_rfd);
+ if (debug->external_ext != NULL)
+ free (debug->external_ext);
+ return false;
+}
+
+/* Alpha ELF local labels start with '$'. */
+
+static boolean
+elf64_alpha_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return name[0] == '$';
+}
+
+/* Alpha ELF follows MIPS ELF in using a special find_nearest_line
+ routine in order to handle the ECOFF debugging information. We
+ still call this mips_elf_find_line because of the slot
+ find_line_info in elf_obj_tdata is declared that way. */
+
+struct mips_elf_find_line
+{
+ struct ecoff_debug_info d;
+ struct ecoff_find_line i;
+};
+
+static boolean
+elf64_alpha_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
+ functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ asection *msec;
+
+ msec = bfd_get_section_by_name (abfd, ".mdebug");
+ if (msec != NULL)
+ {
+ flagword origflags;
+ struct mips_elf_find_line *fi;
+ const struct ecoff_debug_swap * const swap =
+ get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+
+ /* If we are called during a link, alpha_elf_final_link may have
+ cleared the SEC_HAS_CONTENTS field. We force it back on here
+ if appropriate (which it normally will be). */
+ origflags = msec->flags;
+ if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
+ msec->flags |= SEC_HAS_CONTENTS;
+
+ fi = elf_tdata (abfd)->find_line_info;
+ if (fi == NULL)
+ {
+ bfd_size_type external_fdr_size;
+ char *fraw_src;
+ char *fraw_end;
+ struct fdr *fdr_ptr;
+
+ fi = ((struct mips_elf_find_line *)
+ bfd_zalloc (abfd, sizeof (struct mips_elf_find_line)));
+ if (fi == NULL)
+ {
+ msec->flags = origflags;
+ return false;
+ }
+
+ if (!elf64_alpha_read_ecoff_info (abfd, msec, &fi->d))
+ {
+ msec->flags = origflags;
+ return false;
+ }
+
+ /* Swap in the FDR information. */
+ fi->d.fdr = ((struct fdr *)
+ bfd_alloc (abfd,
+ (fi->d.symbolic_header.ifdMax *
+ sizeof (struct fdr))));
+ if (fi->d.fdr == NULL)
+ {
+ msec->flags = origflags;
+ return false;
+ }
+ external_fdr_size = swap->external_fdr_size;
+ fdr_ptr = fi->d.fdr;
+ fraw_src = (char *) fi->d.external_fdr;
+ fraw_end = (fraw_src
+ + fi->d.symbolic_header.ifdMax * external_fdr_size);
+ for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
+ (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
+
+ elf_tdata (abfd)->find_line_info = fi;
+
+ /* Note that we don't bother to ever free this information.
+ find_nearest_line is either called all the time, as in
+ objdump -l, so the information should be saved, or it is
+ rarely called, as in ld error messages, so the memory
+ wasted is unimportant. Still, it would probably be a
+ good idea for free_cached_info to throw it away. */
+ }
+
+ if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap,
+ &fi->i, filename_ptr, functionname_ptr,
+ line_ptr))
+ {
+ msec->flags = origflags;
+ return true;
+ }
+
+ msec->flags = origflags;
+ }
+
+ /* Fall back on the generic ELF find_nearest_line routine. */
+
+ return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr);
+}
+
+/* Structure used to pass information to alpha_elf_output_extsym. */
+
+struct extsym_info
+{
+ bfd *abfd;
+ struct bfd_link_info *info;
+ struct ecoff_debug_info *debug;
+ const struct ecoff_debug_swap *swap;
+ boolean failed;
+};
+
+static boolean
+elf64_alpha_output_extsym (h, data)
+ struct alpha_elf_link_hash_entry *h;
+ PTR data;
+{
+ struct extsym_info *einfo = (struct extsym_info *) data;
+ boolean strip;
+ asection *sec, *output_section;
+
+ if (h->root.indx == -2)
+ strip = false;
+ else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
+ && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
+ strip = true;
+ else if (einfo->info->strip == strip_all
+ || (einfo->info->strip == strip_some
+ && bfd_hash_lookup (einfo->info->keep_hash,
+ h->root.root.root.string,
+ false, false) == NULL))
+ strip = true;
+ else
+ strip = false;
+
+ if (strip)
+ return true;
+
+ if (h->esym.ifd == -2)
+ {
+ h->esym.jmptbl = 0;
+ h->esym.cobol_main = 0;
+ h->esym.weakext = 0;
+ h->esym.reserved = 0;
+ h->esym.ifd = ifdNil;
+ h->esym.asym.value = 0;
+ h->esym.asym.st = stGlobal;
+
+ if (h->root.root.type != bfd_link_hash_defined
+ && h->root.root.type != bfd_link_hash_defweak)
+ h->esym.asym.sc = scAbs;
+ else
+ {
+ const char *name;
+
+ sec = h->root.root.u.def.section;
+ output_section = sec->output_section;
+
+ /* When making a shared library and symbol h is the one from
+ the another shared library, OUTPUT_SECTION may be null. */
+ if (output_section == NULL)
+ h->esym.asym.sc = scUndefined;
+ else
+ {
+ name = bfd_section_name (output_section->owner, output_section);
+
+ if (strcmp (name, ".text") == 0)
+ h->esym.asym.sc = scText;
+ else if (strcmp (name, ".data") == 0)
+ h->esym.asym.sc = scData;
+ else if (strcmp (name, ".sdata") == 0)
+ h->esym.asym.sc = scSData;
+ else if (strcmp (name, ".rodata") == 0
+ || strcmp (name, ".rdata") == 0)
+ h->esym.asym.sc = scRData;
+ else if (strcmp (name, ".bss") == 0)
+ h->esym.asym.sc = scBss;
+ else if (strcmp (name, ".sbss") == 0)
+ h->esym.asym.sc = scSBss;
+ else if (strcmp (name, ".init") == 0)
+ h->esym.asym.sc = scInit;
+ else if (strcmp (name, ".fini") == 0)
+ h->esym.asym.sc = scFini;
+ else
+ h->esym.asym.sc = scAbs;
+ }
+ }
+
+ h->esym.asym.reserved = 0;
+ h->esym.asym.index = indexNil;
+ }
+
+ if (h->root.root.type == bfd_link_hash_common)
+ h->esym.asym.value = h->root.root.u.c.size;
+ else if (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ {
+ if (h->esym.asym.sc == scCommon)
+ h->esym.asym.sc = scBss;
+ else if (h->esym.asym.sc == scSCommon)
+ h->esym.asym.sc = scSBss;
+
+ sec = h->root.root.u.def.section;
+ output_section = sec->output_section;
+ if (output_section != NULL)
+ h->esym.asym.value = (h->root.root.u.def.value
+ + sec->output_offset
+ + output_section->vma);
+ else
+ h->esym.asym.value = 0;
+ }
+ else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ /* Set type and value for a symbol with a function stub. */
+ h->esym.asym.st = stProc;
+ sec = bfd_get_section_by_name (einfo->abfd, ".plt");
+ if (sec == NULL)
+ h->esym.asym.value = 0;
+ else
+ {
+ output_section = sec->output_section;
+ if (output_section != NULL)
+ h->esym.asym.value = (h->root.plt.offset
+ + sec->output_offset
+ + output_section->vma);
+ else
+ h->esym.asym.value = 0;
+ }
+#if 0 /* FIXME? */
+ h->esym.ifd = 0;
+#endif
+ }
+
+ if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
+ h->root.root.root.string,
+ &h->esym))
+ {
+ einfo->failed = true;
+ return false;
+ }
+
+ return true;
+}
+
+/* FIXME: Create a runtime procedure table from the .mdebug section.
+
+static boolean
+mips_elf_create_procedure_table (handle, abfd, info, s, debug)
+ PTR handle;
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *s;
+ struct ecoff_debug_info *debug;
+*/
+
+/* Handle dynamic relocations when doing an Alpha ELF link. */
+
+static boolean
+elf64_alpha_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ bfd *dynobj;
+ asection *sreloc;
+ const char *rel_sec_name;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct alpha_elf_link_hash_entry **sym_hashes;
+ struct alpha_elf_got_entry **local_got_entries;
+ const Elf_Internal_Rela *rel, *relend;
+ int got_created;
+
+ if (info->relocateable)
+ return true;
+
+ dynobj = elf_hash_table(info)->dynobj;
+ if (dynobj == NULL)
+ elf_hash_table(info)->dynobj = dynobj = abfd;
+
+ sreloc = NULL;
+ rel_sec_name = NULL;
+ symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
+ sym_hashes = alpha_elf_sym_hashes(abfd);
+ local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
+ got_created = 0;
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; ++rel)
+ {
+ unsigned long r_symndx, r_type;
+ struct alpha_elf_link_hash_entry *h;
+
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+
+ h->root.elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
+ }
+ r_type = ELF64_R_TYPE (rel->r_info);
+
+ switch (r_type)
+ {
+ case R_ALPHA_LITERAL:
+ {
+ struct alpha_elf_got_entry *gotent;
+ int flags = 0;
+
+ if (h)
+ {
+ /* Search for and possibly create a got entry. */
+ for (gotent = h->got_entries; gotent ; gotent = gotent->next)
+ if (gotent->gotobj == abfd &&
+ gotent->addend == rel->r_addend)
+ break;
+
+ if (!gotent)
+ {
+ gotent = ((struct alpha_elf_got_entry *)
+ bfd_alloc (abfd,
+ sizeof (struct alpha_elf_got_entry)));
+ if (!gotent)
+ return false;
+
+ gotent->gotobj = abfd;
+ gotent->addend = rel->r_addend;
+ gotent->got_offset = -1;
+ gotent->flags = 0;
+ gotent->use_count = 1;
+
+ gotent->next = h->got_entries;
+ h->got_entries = gotent;
+
+ alpha_elf_tdata (abfd)->total_got_entries++;
+ }
+ else
+ gotent->use_count += 1;
+ }
+ else
+ {
+ /* This is a local .got entry -- record for merge. */
+ if (!local_got_entries)
+ {
+ size_t size;
+ size = (symtab_hdr->sh_info
+ * sizeof (struct alpha_elf_got_entry *));
+
+ local_got_entries = ((struct alpha_elf_got_entry **)
+ bfd_alloc (abfd, size));
+ if (!local_got_entries)
+ return false;
+
+ memset (local_got_entries, 0, size);
+ alpha_elf_tdata (abfd)->local_got_entries =
+ local_got_entries;
+ }
+
+ for (gotent = local_got_entries[ELF64_R_SYM(rel->r_info)];
+ gotent != NULL && gotent->addend != rel->r_addend;
+ gotent = gotent->next)
+ continue;
+ if (!gotent)
+ {
+ gotent = ((struct alpha_elf_got_entry *)
+ bfd_alloc (abfd,
+ sizeof (struct alpha_elf_got_entry)));
+ if (!gotent)
+ return false;
+
+ gotent->gotobj = abfd;
+ gotent->addend = rel->r_addend;
+ gotent->got_offset = -1;
+ gotent->flags = 0;
+ gotent->use_count = 1;
+
+ gotent->next = local_got_entries[ELF64_R_SYM(rel->r_info)];
+ local_got_entries[ELF64_R_SYM(rel->r_info)] = gotent;
+
+ alpha_elf_tdata(abfd)->total_got_entries++;
+ alpha_elf_tdata(abfd)->n_local_got_entries++;
+ }
+ else
+ gotent->use_count += 1;
+ }
+
+ /* Remember how this literal is used from its LITUSEs.
+ This will be important when it comes to decide if we can
+ create a .plt entry for a function symbol. */
+ if (rel+1 < relend
+ && ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE)
+ {
+ do
+ {
+ ++rel;
+ if (rel->r_addend >= 1 && rel->r_addend <= 3)
+ flags |= 1 << rel->r_addend;
+ }
+ while (rel+1 < relend &&
+ ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE);
+ }
+ else
+ {
+ /* No LITUSEs -- presumably the address is not being
+ loaded for nothing. */
+ flags = ALPHA_ELF_LINK_HASH_LU_ADDR;
+ }
+
+ gotent->flags |= flags;
+ if (h)
+ {
+ /* Make a guess as to whether a .plt entry will be needed. */
+ if ((h->flags |= flags) == ALPHA_ELF_LINK_HASH_LU_FUNC)
+ h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ else
+ h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+ }
+ /* FALLTHRU */
+
+ case R_ALPHA_GPDISP:
+ case R_ALPHA_GPREL32:
+ case R_ALPHA_GPRELHIGH:
+ case R_ALPHA_GPRELLOW:
+ /* We don't actually use the .got here, but the sections must
+ be created before the linker maps input sections to output
+ sections. */
+ if (!got_created)
+ {
+ if (!elf64_alpha_create_got_section (abfd, info))
+ return false;
+
+ /* Make sure the object's gotobj is set to itself so
+ that we default to every object with its own .got.
+ We'll merge .gots later once we've collected each
+ object's info. */
+ alpha_elf_tdata(abfd)->gotobj = abfd;
+
+ got_created = 1;
+ }
+ break;
+
+ case R_ALPHA_SREL16:
+ case R_ALPHA_SREL32:
+ case R_ALPHA_SREL64:
+ if (h == NULL)
+ break;
+ /* FALLTHRU */
+
+ case R_ALPHA_REFLONG:
+ case R_ALPHA_REFQUAD:
+ if (rel_sec_name == NULL)
+ {
+ rel_sec_name = (bfd_elf_string_from_elf_section
+ (abfd, elf_elfheader(abfd)->e_shstrndx,
+ elf_section_data(sec)->rel_hdr.sh_name));
+ if (rel_sec_name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (rel_sec_name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ rel_sec_name+5) == 0);
+ }
+
+ /* We need to create the section here now whether we eventually
+ use it or not so that it gets mapped to an output section by
+ the linker. If not used, we'll kill it in
+ size_dynamic_sections. */
+ if (sreloc == NULL)
+ {
+ sreloc = bfd_get_section_by_name (dynobj, rel_sec_name);
+ if (sreloc == NULL)
+ {
+ sreloc = bfd_make_section (dynobj, rel_sec_name);
+ if (sreloc == NULL
+ || !bfd_set_section_flags (dynobj, sreloc,
+ (SEC_ALLOC|SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || !bfd_set_section_alignment (dynobj, sreloc, 3))
+ return false;
+ }
+ }
+
+ if (h)
+ {
+ /* Since we havn't seen all of the input symbols yet, we
+ don't know whether we'll actually need a dynamic relocation
+ entry for this reloc. So make a record of it. Once we
+ find out if this thing needs dynamic relocation we'll
+ expand the relocation sections by the appropriate amount. */
+
+ struct alpha_elf_reloc_entry *rent;
+
+ for (rent = h->reloc_entries; rent; rent = rent->next)
+ if (rent->rtype == r_type && rent->srel == sreloc)
+ break;
+
+ if (!rent)
+ {
+ rent = ((struct alpha_elf_reloc_entry *)
+ bfd_alloc (abfd,
+ sizeof (struct alpha_elf_reloc_entry)));
+ if (!rent)
+ return false;
+
+ rent->srel = sreloc;
+ rent->rtype = r_type;
+ rent->count = 1;
+
+ rent->next = h->reloc_entries;
+ h->reloc_entries = rent;
+ }
+ else
+ rent->count++;
+ }
+ else if (info->shared)
+ {
+ /* If this is a shared library, we need a RELATIVE reloc. */
+ sreloc->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf64_alpha_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj;
+ asection *s;
+ struct alpha_elf_link_hash_entry *ah;
+
+ dynobj = elf_hash_table(info)->dynobj;
+ ah = (struct alpha_elf_link_hash_entry *)h;
+
+ /* Now that we've seen all of the input symbols, finalize our decision
+ about whether this symbol should get a .plt entry. */
+
+ if (h->root.type != bfd_link_hash_undefweak
+ && alpha_elf_dynamic_symbol_p (h, info)
+ && ((h->type == STT_FUNC
+ && !(ah->flags & ALPHA_ELF_LINK_HASH_LU_ADDR))
+ || (h->type == STT_NOTYPE
+ && ah->flags == ALPHA_ELF_LINK_HASH_LU_FUNC))
+ /* Don't prevent otherwise valid programs from linking by attempting
+ to create a new .got entry somewhere. A Correct Solution would be
+ to add a new .got section to a new object file and let it be merged
+ somewhere later. But for now don't bother. */
+ && ah->got_entries)
+ {
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+
+ s = bfd_get_section_by_name(dynobj, ".plt");
+ if (!s && !elf64_alpha_create_dynamic_sections (dynobj, info))
+ return false;
+
+ /* The first bit of the .plt is reserved. */
+ if (s->_raw_size == 0)
+ s->_raw_size = PLT_HEADER_SIZE;
+
+ h->plt.offset = s->_raw_size;
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* If this symbol is not defined in a regular file, and we are not
+ generating a shared library, then set the symbol to the location
+ in the .plt. This is required to make function pointers compare
+ equal between the normal executable and the shared library. */
+ if (! info->shared
+ && h->root.type != bfd_link_hash_defweak)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = h->plt.offset;
+ }
+
+ /* We also need a JMP_SLOT entry in the .rela.plt section. */
+ s = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size += sizeof (Elf64_External_Rela);
+
+ return true;
+ }
+ else
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. The Alpha, since it uses .got entries for all
+ symbols even in regular objects, does not need the hackery of a
+ .dynbss section and COPY dynamic relocations. */
+
+ return true;
+}
+
+/* Symbol versioning can create new symbols, and make our old symbols
+ indirect to the new ones. Consolidate the got and reloc information
+ in these situations. */
+
+static boolean
+elf64_alpha_merge_ind_symbols (hi, dummy)
+ struct alpha_elf_link_hash_entry *hi;
+ PTR dummy;
+{
+ struct alpha_elf_link_hash_entry *hs;
+
+ if (hi->root.root.type != bfd_link_hash_indirect)
+ return true;
+ hs = hi;
+ do {
+ hs = (struct alpha_elf_link_hash_entry *)hs->root.root.u.i.link;
+ } while (hs->root.root.type == bfd_link_hash_indirect);
+
+ /* Merge the flags. Whee. */
+
+ hs->flags |= hi->flags;
+
+ /* Merge the .got entries. Cannibalize the old symbol's list in
+ doing so, since we don't need it anymore. */
+
+ if (hs->got_entries == NULL)
+ hs->got_entries = hi->got_entries;
+ else
+ {
+ struct alpha_elf_got_entry *gi, *gs, *gin, *gsh;
+
+ gsh = hs->got_entries;
+ for (gi = hi->got_entries; gi ; gi = gin)
+ {
+ gin = gi->next;
+ for (gs = gsh; gs ; gs = gs->next)
+ if (gi->gotobj == gs->gotobj && gi->addend == gs->addend)
+ goto got_found;
+ gi->next = hs->got_entries;
+ hs->got_entries = gi;
+ got_found:;
+ }
+ }
+ hi->got_entries = NULL;
+
+ /* And similar for the reloc entries. */
+
+ if (hs->reloc_entries == NULL)
+ hs->reloc_entries = hi->reloc_entries;
+ else
+ {
+ struct alpha_elf_reloc_entry *ri, *rs, *rin, *rsh;
+
+ rsh = hs->reloc_entries;
+ for (ri = hi->reloc_entries; ri ; ri = rin)
+ {
+ rin = ri->next;
+ for (rs = rsh; rs ; rs = rs->next)
+ if (ri->rtype == rs->rtype)
+ {
+ rs->count += ri->count;
+ goto found_reloc;
+ }
+ ri->next = hs->reloc_entries;
+ hs->reloc_entries = ri;
+ found_reloc:;
+ }
+ }
+ hi->reloc_entries = NULL;
+
+ return true;
+}
+
+/* Is it possible to merge two object file's .got tables? */
+
+static boolean
+elf64_alpha_can_merge_gots (a, b)
+ bfd *a, *b;
+{
+ int total = alpha_elf_tdata (a)->total_got_entries;
+ bfd *bsub;
+
+ /* Trivial quick fallout test. */
+ if (total + alpha_elf_tdata (b)->total_got_entries <= MAX_GOT_ENTRIES)
+ return true;
+
+ /* By their nature, local .got entries cannot be merged. */
+ if ((total += alpha_elf_tdata (b)->n_local_got_entries) > MAX_GOT_ENTRIES)
+ return false;
+
+ /* Failing the common trivial comparison, we must effectively
+ perform the merge. Not actually performing the merge means that
+ we don't have to store undo information in case we fail. */
+ for (bsub = b; bsub ; bsub = alpha_elf_tdata (bsub)->in_got_link_next)
+ {
+ struct alpha_elf_link_hash_entry **hashes = alpha_elf_sym_hashes (bsub);
+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (bsub)->symtab_hdr;
+ int i, n;
+
+ n = symtab_hdr->sh_size / symtab_hdr->sh_entsize - symtab_hdr->sh_info;
+ for (i = 0; i < n; ++i)
+ {
+ struct alpha_elf_got_entry *ae, *be;
+ struct alpha_elf_link_hash_entry *h;
+
+ h = hashes[i];
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+
+ for (be = h->got_entries; be ; be = be->next)
+ {
+ if (be->use_count == 0)
+ continue;
+ if (be->gotobj != b)
+ continue;
+
+ for (ae = h->got_entries; ae ; ae = ae->next)
+ if (ae->gotobj == a && ae->addend == be->addend)
+ goto global_found;
+
+ if (++total > MAX_GOT_ENTRIES)
+ return false;
+ global_found:;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Actually merge two .got tables. */
+
+static void
+elf64_alpha_merge_gots (a, b)
+ bfd *a, *b;
+{
+ int total = alpha_elf_tdata (a)->total_got_entries;
+ bfd *bsub;
+
+ /* Remember local expansion. */
+ {
+ int e = alpha_elf_tdata (b)->n_local_got_entries;
+ total += e;
+ alpha_elf_tdata (a)->n_local_got_entries += e;
+ }
+
+ for (bsub = b; bsub ; bsub = alpha_elf_tdata (bsub)->in_got_link_next)
+ {
+ struct alpha_elf_got_entry **local_got_entries;
+ struct alpha_elf_link_hash_entry **hashes;
+ Elf_Internal_Shdr *symtab_hdr;
+ int i, n;
+
+ /* Let the local .got entries know they are part of a new subsegment. */
+ local_got_entries = alpha_elf_tdata (bsub)->local_got_entries;
+ if (local_got_entries)
+ {
+ n = elf_tdata (bsub)->symtab_hdr.sh_info;
+ for (i = 0; i < n; ++i)
+ {
+ struct alpha_elf_got_entry *ent;
+ for (ent = local_got_entries[i]; ent; ent = ent->next)
+ ent->gotobj = a;
+ }
+ }
+
+ /* Merge the global .got entries. */
+ hashes = alpha_elf_sym_hashes (bsub);
+ symtab_hdr = &elf_tdata (bsub)->symtab_hdr;
+
+ n = symtab_hdr->sh_size / symtab_hdr->sh_entsize - symtab_hdr->sh_info;
+ for (i = 0; i < n; ++i)
+ {
+ struct alpha_elf_got_entry *ae, *be, **pbe, **start;
+ struct alpha_elf_link_hash_entry *h;
+
+ h = hashes[i];
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+
+ start = &h->got_entries;
+ for (pbe = start, be = *start; be ; pbe = &be->next, be = be->next)
+ {
+ if (be->use_count == 0)
+ {
+ *pbe = be->next;
+ continue;
+ }
+ if (be->gotobj != b)
+ continue;
+
+ for (ae = *start; ae ; ae = ae->next)
+ if (ae->gotobj == a && ae->addend == be->addend)
+ {
+ ae->flags |= be->flags;
+ ae->use_count += be->use_count;
+ *pbe = be->next;
+ goto global_found;
+ }
+ be->gotobj = a;
+ total += 1;
+
+ global_found:;
+ }
+ }
+
+ alpha_elf_tdata (bsub)->gotobj = a;
+ }
+ alpha_elf_tdata (a)->total_got_entries = total;
+
+ /* Merge the two in_got chains. */
+ {
+ bfd *next;
+
+ bsub = a;
+ while ((next = alpha_elf_tdata (bsub)->in_got_link_next) != NULL)
+ bsub = next;
+
+ alpha_elf_tdata (bsub)->in_got_link_next = b;
+ }
+}
+
+/* Calculate the offsets for the got entries. */
+
+static boolean
+elf64_alpha_calc_got_offsets_for_symbol (h, arg)
+ struct alpha_elf_link_hash_entry *h;
+ PTR arg;
+{
+ struct alpha_elf_got_entry *gotent;
+
+ for (gotent = h->got_entries; gotent; gotent = gotent->next)
+ if (gotent->use_count > 0)
+ {
+ bfd_size_type *plge
+ = &alpha_elf_tdata (gotent->gotobj)->got->_raw_size;
+
+ gotent->got_offset = *plge;
+ *plge += 8;
+ }
+
+ return true;
+}
+
+static void
+elf64_alpha_calc_got_offsets (info)
+ struct bfd_link_info *info;
+{
+ bfd *i, *got_list = alpha_elf_hash_table(info)->got_list;
+
+ /* First, zero out the .got sizes, as we may be recalculating the
+ .got after optimizing it. */
+ for (i = got_list; i ; i = alpha_elf_tdata(i)->got_link_next)
+ alpha_elf_tdata(i)->got->_raw_size = 0;
+
+ /* Next, fill in the offsets for all the global entries. */
+ alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
+ elf64_alpha_calc_got_offsets_for_symbol,
+ NULL);
+
+ /* Finally, fill in the offsets for the local entries. */
+ for (i = got_list; i ; i = alpha_elf_tdata(i)->got_link_next)
+ {
+ bfd_size_type got_offset = alpha_elf_tdata(i)->got->_raw_size;
+ bfd *j;
+
+ for (j = i; j ; j = alpha_elf_tdata(j)->in_got_link_next)
+ {
+ struct alpha_elf_got_entry **local_got_entries, *gotent;
+ int k, n;
+
+ local_got_entries = alpha_elf_tdata(j)->local_got_entries;
+ if (!local_got_entries)
+ continue;
+
+ for (k = 0, n = elf_tdata(j)->symtab_hdr.sh_info; k < n; ++k)
+ for (gotent = local_got_entries[k]; gotent; gotent = gotent->next)
+ if (gotent->use_count > 0)
+ {
+ gotent->got_offset = got_offset;
+ got_offset += 8;
+ }
+ }
+
+ alpha_elf_tdata(i)->got->_raw_size = got_offset;
+ alpha_elf_tdata(i)->got->_cooked_size = got_offset;
+ }
+}
+
+/* Constructs the gots. */
+
+static boolean
+elf64_alpha_size_got_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *i, *got_list, *cur_got_obj;
+ int something_changed = 0;
+
+ got_list = alpha_elf_hash_table (info)->got_list;
+
+ /* On the first time through, pretend we have an existing got list
+ consisting of all of the input files. */
+ if (got_list == NULL)
+ {
+ for (i = info->input_bfds; i ; i = i->link_next)
+ {
+ bfd *this_got = alpha_elf_tdata (i)->gotobj;
+ if (this_got == NULL)
+ continue;
+
+ /* We are assuming no merging has yet ocurred. */
+ BFD_ASSERT (this_got == i);
+
+ if (alpha_elf_tdata (this_got)->total_got_entries > MAX_GOT_ENTRIES)
+ {
+ /* Yikes! A single object file has too many entries. */
+ (*_bfd_error_handler)
+ (_("%s: .got subsegment exceeds 64K (size %d)"),
+ bfd_get_filename (i),
+ alpha_elf_tdata (this_got)->total_got_entries * 8);
+ return false;
+ }
+
+ if (got_list == NULL)
+ got_list = this_got;
+ else
+ alpha_elf_tdata(cur_got_obj)->got_link_next = this_got;
+ cur_got_obj = this_got;
+ }
+
+ /* Strange degenerate case of no got references. */
+ if (got_list == NULL)
+ return true;
+
+ alpha_elf_hash_table (info)->got_list = got_list;
+
+ /* Force got offsets to be recalculated. */
+ something_changed = 1;
+ }
+
+ cur_got_obj = got_list;
+ i = alpha_elf_tdata(cur_got_obj)->got_link_next;
+ while (i != NULL)
+ {
+ if (elf64_alpha_can_merge_gots (cur_got_obj, i))
+ {
+ elf64_alpha_merge_gots (cur_got_obj, i);
+ i = alpha_elf_tdata(i)->got_link_next;
+ alpha_elf_tdata(cur_got_obj)->got_link_next = i;
+ something_changed = 1;
+ }
+ else
+ {
+ cur_got_obj = i;
+ i = alpha_elf_tdata(i)->got_link_next;
+ }
+ }
+
+ /* Once the gots have been merged, fill in the got offsets for
+ everything therein. */
+ if (1 || something_changed)
+ elf64_alpha_calc_got_offsets (info);
+
+ return true;
+}
+
+static boolean
+elf64_alpha_always_size_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *i;
+
+ if (info->relocateable)
+ return true;
+
+ /* First, take care of the indirect symbols created by versioning. */
+ alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
+ elf64_alpha_merge_ind_symbols,
+ NULL);
+
+ if (!elf64_alpha_size_got_sections (output_bfd, info))
+ return false;
+
+ /* Allocate space for all of the .got subsections. */
+ i = alpha_elf_hash_table (info)->got_list;
+ for ( ; i ; i = alpha_elf_tdata(i)->got_link_next)
+ {
+ asection *s = alpha_elf_tdata(i)->got;
+ if (s->_raw_size > 0)
+ {
+ s->contents = (bfd_byte *) bfd_zalloc (i, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Work out the sizes of the dynamic relocation entries. */
+
+static boolean
+elf64_alpha_calc_dynrel_sizes (h, info)
+ struct alpha_elf_link_hash_entry *h;
+ struct bfd_link_info *info;
+{
+ /* If the symbol was defined as a common symbol in a regular object
+ file, and there was no definition in any dynamic object, then the
+ linker will have allocated space for the symbol in a common
+ section but the ELF_LINK_HASH_DEF_REGULAR flag will not have been
+ set. This is done for dynamic symbols in
+ elf_adjust_dynamic_symbol but this is not done for non-dynamic
+ symbols, somehow. */
+ if (((h->root.elf_link_hash_flags
+ & (ELF_LINK_HASH_DEF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_DEF_DYNAMIC))
+ == ELF_LINK_HASH_REF_REGULAR)
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ && !(h->root.root.u.def.section->owner->flags & DYNAMIC))
+ {
+ h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ }
+
+ /* If the symbol is dynamic, we'll need all the relocations in their
+ natural form. If this is a shared object, and it has been forced
+ local, we'll need the same number of RELATIVE relocations. */
+
+ if (alpha_elf_dynamic_symbol_p (&h->root, info) || info->shared)
+ {
+ struct alpha_elf_reloc_entry *relent;
+ bfd *dynobj;
+ struct alpha_elf_got_entry *gotent;
+ bfd_size_type count;
+ asection *srel;
+
+ for (relent = h->reloc_entries; relent; relent = relent->next)
+ if (relent->rtype == R_ALPHA_REFLONG
+ || relent->rtype == R_ALPHA_REFQUAD)
+ {
+ relent->srel->_raw_size +=
+ sizeof(Elf64_External_Rela) * relent->count;
+ }
+
+ dynobj = elf_hash_table(info)->dynobj;
+ count = 0;
+
+ for (gotent = h->got_entries; gotent ; gotent = gotent->next)
+ count++;
+
+ /* If we are using a .plt entry, subtract one, as the first
+ reference uses a .rela.plt entry instead. */
+ if (h->root.plt.offset != MINUS_ONE)
+ count--;
+
+ if (count > 0)
+ {
+ srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf64_External_Rela) * count;
+ }
+ }
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf64_alpha_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean reltext;
+ boolean relplt;
+
+ dynobj = elf_hash_table(info)->dynobj;
+ BFD_ASSERT(dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (!info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+
+ /* Now that we've seen all of the input files, we can decide which
+ symbols need dynamic relocation entries and which don't. We've
+ collected information in check_relocs that we can now apply to
+ size the dynamic relocation sections. */
+ alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
+ elf64_alpha_calc_dynrel_sizes,
+ info);
+
+ /* When building shared libraries, each local .got entry needs a
+ RELATIVE reloc. */
+ if (info->shared)
+ {
+ bfd *i;
+ asection *srel;
+ bfd_size_type count;
+
+ srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (srel != NULL);
+
+ for (i = alpha_elf_hash_table(info)->got_list, count = 0;
+ i != NULL;
+ i = alpha_elf_tdata(i)->got_link_next)
+ count += alpha_elf_tdata(i)->n_local_got_entries;
+
+ srel->_raw_size += count * sizeof(Elf64_External_Rela);
+ }
+ }
+ /* else we're not dynamic and by definition we don't need such things. */
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ reltext = false;
+ relplt = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ if (!(s->flags & SEC_LINKER_CREATED))
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ /* If we don't need this section, strip it from the output file.
+ This is to handle .rela.bss and .rela.plt. We must create it
+ in create_dynamic_sections, because it must be created before
+ the linker maps input sections to output sections. The
+ linker does that before adjust_dynamic_symbol is called, and
+ it is that function which decides whether anything needs to
+ go into these sections. */
+
+ strip = false;
+
+ if (strncmp (name, ".rela", 5) == 0)
+ {
+ strip = (s->_raw_size == 0);
+
+ if (!strip)
+ {
+ const char *outname;
+ asection *target;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL entry. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 5);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0)
+ reltext = true;
+
+ if (strcmp(name, ".rela.plt") == 0)
+ relplt = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strcmp (name, ".plt") != 0)
+ {
+ /* It's not one of our dynamic sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ _bfd_strip_section_from_output (s);
+ else
+ {
+ /* Allocate memory for the section contents. */
+ s->contents = (bfd_byte *) bfd_zalloc(dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+ }
+
+ /* If we are generating a shared library, we generate a section
+ symbol for each output section. These are local symbols, which
+ means that they must come first in the dynamic symbol table.
+ That means we must increment the dynamic symbol index of every
+ other dynamic symbol. */
+ if (info->shared)
+ {
+ long c[2], i;
+ asection *p;
+
+ c[0] = 0;
+ c[1] = bfd_count_sections (output_bfd);
+
+ elf_hash_table (info)->dynsymcount += c[1];
+ elf_link_hash_traverse (elf_hash_table(info),
+ elf64_alpha_adjust_dynindx,
+ (PTR) c);
+
+ for (i = 1, p = output_bfd->sections;
+ p != NULL;
+ p = p->next, i++)
+ {
+ elf_section_data (p)->dynindx = i;
+ /* These symbols will have no names, so we don't need to
+ fiddle with dynstr_index. */
+ }
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf64_alpha_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (!info->shared)
+ {
+ if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0))
+ return false;
+
+ if (relplt)
+ {
+ if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
+ sizeof(Elf64_External_Rela)))
+ return false;
+
+ if (reltext)
+ {
+ if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Increment the index of a dynamic symbol by a given amount. Called
+ via elf_link_hash_traverse. */
+
+static boolean
+elf64_alpha_adjust_dynindx (h, cparg)
+ struct elf_link_hash_entry *h;
+ PTR cparg;
+{
+ long *cp = (long *)cparg;
+
+ if (h->dynindx >= cp[0])
+ h->dynindx += cp[1];
+
+ return true;
+}
+
+/* Relocate an Alpha ELF section. */
+
+static boolean
+elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+ asection *sec, *sgot, *srel, *srelgot;
+ bfd *dynobj, *gotobj;
+ bfd_vma gp;
+
+ srelgot = srel = NULL;
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ dynobj = elf_hash_table (info)->dynobj;
+ if (dynobj)
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ }
+
+ /* Find the gp value for this input bfd. */
+ sgot = NULL;
+ gp = 0;
+ gotobj = alpha_elf_tdata (input_bfd)->gotobj;
+ if (gotobj)
+ {
+ sgot = alpha_elf_tdata (gotobj)->got;
+ gp = _bfd_get_gp_value (gotobj);
+ if (gp == 0)
+ {
+ gp = (sgot->output_section->vma
+ + sgot->output_offset
+ + 0x8000);
+ _bfd_set_gp_value (gotobj, gp);
+ }
+ }
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct alpha_elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ bfd_vma relocation;
+ bfd_vma addend;
+ bfd_reloc_status_type r;
+
+ r_type = ELF64_R_TYPE(rel->r_info);
+ if (r_type < 0 || r_type >= (int) R_ALPHA_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ howto = elf64_alpha_howto_table + r_type;
+
+ r_symndx = ELF64_R_SYM(rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = alpha_elf_sym_hashes (input_bfd)[r_symndx - symtab_hdr->sh_info];
+
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+
+ if (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ {
+ sec = h->root.root.u.def.section;
+
+#if rth_notdef
+ if ((r_type == R_ALPHA_LITERAL
+ && elf_hash_table(info)->dynamic_sections_created
+ && (!info->shared
+ || !info->symbolic
+ || !(h->root.elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR)))
+ || (info->shared
+ && (!info->symbolic
+ || !(h->root.elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR))
+ && (input_section->flags & SEC_ALLOC)
+ && (r_type == R_ALPHA_REFLONG
+ || r_type == R_ALPHA_REFQUAD
+ || r_type == R_ALPHA_LITERAL)))
+ {
+ /* In these cases, we don't need the relocation value.
+ We check specially because in some obscure cases
+ sec->output_section will be NULL. */
+ relocation = 0;
+ }
+#else
+ /* FIXME: Are not these obscure cases simply bugs? Let's
+ get something working and come back to this. */
+ if (sec->output_section == NULL)
+ relocation = 0;
+#endif /* rth_notdef */
+ else
+ {
+ relocation = (h->root.root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ }
+ else if (h->root.root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else
+ {
+ if (!((*info->callbacks->undefined_symbol)
+ (info, h->root.root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+ addend = rel->r_addend;
+
+ switch (r_type)
+ {
+ case R_ALPHA_GPDISP:
+ {
+ bfd_byte *p_ldah, *p_lda;
+
+ BFD_ASSERT(gp != 0);
+
+ relocation = (input_section->output_section->vma
+ + input_section->output_offset
+ + rel->r_offset);
+
+ p_ldah = contents + rel->r_offset - input_section->vma;
+ p_lda = p_ldah + rel->r_addend;
+
+ r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - relocation,
+ p_ldah, p_lda);
+ }
+ break;
+
+ case R_ALPHA_OP_PUSH:
+ case R_ALPHA_OP_STORE:
+ case R_ALPHA_OP_PSUB:
+ case R_ALPHA_OP_PRSHIFT:
+ /* We hate these silly beasts. */
+ abort();
+
+ case R_ALPHA_LITERAL:
+ {
+ struct alpha_elf_got_entry *gotent;
+ boolean dynamic_symbol;
+
+ BFD_ASSERT(sgot != NULL);
+ BFD_ASSERT(gp != 0);
+
+ if (h != NULL)
+ {
+ gotent = h->got_entries;
+ dynamic_symbol = alpha_elf_dynamic_symbol_p (&h->root, info);
+ }
+ else
+ {
+ gotent = (alpha_elf_tdata(input_bfd)->
+ local_got_entries[r_symndx]);
+ dynamic_symbol = false;
+ }
+
+ BFD_ASSERT(gotent != NULL);
+
+ while (gotent->gotobj != gotobj || gotent->addend != addend)
+ gotent = gotent->next;
+
+ BFD_ASSERT(gotent->use_count >= 1);
+
+ /* Initialize the .got entry's value. */
+ if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE))
+ {
+ bfd_put_64 (output_bfd, relocation+addend,
+ sgot->contents + gotent->got_offset);
+
+ /* If the symbol has been forced local, output a
+ RELATIVE reloc, otherwise it will be handled in
+ finish_dynamic_symbol. */
+ if (info->shared && !dynamic_symbol)
+ {
+ Elf_Internal_Rela outrel;
+
+ BFD_ASSERT(srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + gotent->got_offset);
+ outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
+ outrel.r_addend = 0;
+
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ ((Elf64_External_Rela *)
+ srelgot->contents)
+ + srelgot->reloc_count++);
+ BFD_ASSERT (sizeof(Elf64_External_Rela)
+ * srelgot->reloc_count
+ <= srelgot->_cooked_size);
+ }
+
+ gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE;
+ }
+
+ /* Figure the gprel relocation. */
+ addend = 0;
+ relocation = (sgot->output_section->vma
+ + sgot->output_offset
+ + gotent->got_offset);
+ relocation -= gp;
+ }
+ /* overflow handled by _bfd_final_link_relocate */
+ goto default_reloc;
+
+ case R_ALPHA_GPREL32:
+ case R_ALPHA_GPRELLOW:
+ BFD_ASSERT(gp != 0);
+ relocation -= gp;
+ goto default_reloc;
+
+ case R_ALPHA_GPRELHIGH:
+ BFD_ASSERT(gp != 0);
+ relocation -= gp;
+ relocation += addend;
+ addend = 0;
+ relocation = (((bfd_signed_vma) relocation >> 16)
+ + ((relocation >> 15) & 1));
+ goto default_reloc;
+
+ case R_ALPHA_BRADDR:
+ case R_ALPHA_HINT:
+ /* The regular PC-relative stuff measures from the start of
+ the instruction rather than the end. */
+ addend -= 4;
+ goto default_reloc;
+
+ case R_ALPHA_REFLONG:
+ case R_ALPHA_REFQUAD:
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip;
+
+ /* Careful here to remember RELATIVE relocations for global
+ variables for symbolic shared objects. */
+
+ if (h && alpha_elf_dynamic_symbol_p (&h->root, info))
+ {
+ BFD_ASSERT(h->root.dynindx != -1);
+ outrel.r_info = ELF64_R_INFO(h->root.dynindx, r_type);
+ outrel.r_addend = addend;
+ addend = 0, relocation = 0;
+ }
+ else if (info->shared)
+ {
+ outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
+ outrel.r_addend = 0;
+ }
+ else
+ goto default_reloc;
+
+ if (!srel)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, elf_elfheader(input_bfd)->e_shstrndx,
+ elf_section_data(input_section)->rel_hdr.sh_name));
+ BFD_ASSERT(name != NULL);
+
+ srel = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT(srel != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == (bfd_vma) -1)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ if (! skip)
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+ else
+ memset (&outrel, 0, sizeof outrel);
+
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ ((Elf64_External_Rela *)
+ srel->contents)
+ + srel->reloc_count++);
+ BFD_ASSERT (sizeof(Elf64_External_Rela) * srel->reloc_count
+ <= srel->_cooked_size);
+ }
+ goto default_reloc;
+
+ default:
+ default_reloc:
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset, relocation,
+ addend);
+ break;
+ }
+
+ switch (r)
+ {
+ case bfd_reloc_ok:
+ break;
+
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.root.string;
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj = elf_hash_table(info)->dynobj;
+
+ if (h->plt.offset != MINUS_ONE)
+ {
+ /* Fill in the .plt entry for this symbol. */
+ asection *splt, *sgot, *srel;
+ Elf_Internal_Rela outrel;
+ bfd_vma got_addr, plt_addr;
+ bfd_vma plt_index;
+ struct alpha_elf_got_entry *gotent;
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ /* The first .got entry will be updated by the .plt with the
+ address of the target function. */
+ gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries;
+ BFD_ASSERT (gotent && gotent->addend == 0);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL);
+ srel = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (srel != NULL);
+ sgot = alpha_elf_tdata (gotent->gotobj)->got;
+ BFD_ASSERT (sgot != NULL);
+
+ got_addr = (sgot->output_section->vma
+ + sgot->output_offset
+ + gotent->got_offset);
+ plt_addr = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt.offset);
+
+ plt_index = (h->plt.offset - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;
+
+ /* Fill in the entry in the procedure linkage table. */
+ {
+ unsigned insn1, insn2, insn3;
+
+ insn1 = PLT_ENTRY_WORD1 | ((-(h->plt.offset + 4) >> 2) & 0x1fffff);
+ insn2 = PLT_ENTRY_WORD2;
+ insn3 = PLT_ENTRY_WORD3;
+
+ bfd_put_32 (output_bfd, insn1, splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd, insn2, splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, insn3, splt->contents + h->plt.offset + 8);
+ }
+
+ /* Fill in the entry in the .rela.plt section. */
+ outrel.r_offset = got_addr;
+ outrel.r_info = ELF64_R_INFO(h->dynindx, R_ALPHA_JMP_SLOT);
+ outrel.r_addend = 0;
+
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ ((Elf64_External_Rela *)srel->contents
+ + plt_index));
+
+ if (!(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ {
+ /* Mark the symbol as undefined, rather than as defined in the
+ .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+
+ /* Fill in the entries in the .got. */
+ bfd_put_64 (output_bfd, plt_addr, sgot->contents + gotent->got_offset);
+
+ /* Subsequent .got entries will continue to bounce through the .plt. */
+ if (gotent->next)
+ {
+ srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (! info->shared || srel != NULL);
+
+ gotent = gotent->next;
+ do
+ {
+ sgot = alpha_elf_tdata(gotent->gotobj)->got;
+ BFD_ASSERT(sgot != NULL);
+ BFD_ASSERT(gotent->addend == 0);
+
+ bfd_put_64 (output_bfd, plt_addr,
+ sgot->contents + gotent->got_offset);
+
+ if (info->shared)
+ {
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + gotent->got_offset);
+ outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
+ outrel.r_addend = 0;
+
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ ((Elf64_External_Rela *)
+ srel->contents)
+ + srel->reloc_count++);
+ BFD_ASSERT (sizeof(Elf64_External_Rela) * srel->reloc_count
+ <= srel->_cooked_size);
+ }
+
+ gotent = gotent->next;
+ }
+ while (gotent != NULL);
+ }
+ }
+ else if (alpha_elf_dynamic_symbol_p (h, info))
+ {
+ /* Fill in the dynamic relocations for this symbol's .got entries. */
+ asection *srel;
+ Elf_Internal_Rela outrel;
+ struct alpha_elf_got_entry *gotent;
+
+ srel = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (srel != NULL);
+
+ outrel.r_info = ELF64_R_INFO (h->dynindx, R_ALPHA_GLOB_DAT);
+ for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries;
+ gotent != NULL;
+ gotent = gotent->next)
+ {
+ asection *sgot = alpha_elf_tdata (gotent->gotobj)->got;
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + gotent->got_offset);
+ outrel.r_addend = gotent->addend;
+
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ ((Elf64_External_Rela *)srel->contents
+ + srel->reloc_count++));
+ BFD_ASSERT (sizeof(Elf64_External_Rela) * srel->reloc_count
+ <= srel->_cooked_size);
+ }
+ }
+
+ /* Mark some specially defined symbols as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
+ || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf64_alpha_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *sdyn;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf64_External_Dyn *dyncon, *dynconend;
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ asection *s;
+
+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ case DT_PLTGOT:
+ name = ".plt";
+ goto get_vma;
+ case DT_PLTRELSZ:
+ name = ".rela.plt";
+ goto get_size;
+ case DT_JMPREL:
+ name = ".rela.plt";
+ goto get_vma;
+
+ case DT_RELASZ:
+ /* My interpretation of the TIS v1.1 ELF document indicates
+ that RELASZ should not include JMPREL. This is not what
+ the rest of the BFD does. It is, however, what the
+ glibc ld.so wants. Do this fixup here until we found
+ out who is right. */
+ s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ if (s)
+ {
+ dyn.d_un.d_val -=
+ (s->_cooked_size ? s->_cooked_size : s->_raw_size);
+ }
+ break;
+
+ get_vma:
+ s = bfd_get_section_by_name (output_bfd, name);
+ dyn.d_un.d_ptr = (s ? s->vma : 0);
+ break;
+
+ get_size:
+ s = bfd_get_section_by_name (output_bfd, name);
+ dyn.d_un.d_val =
+ (s->_cooked_size ? s->_cooked_size : s->_raw_size);
+ break;
+ }
+
+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
+ }
+
+ /* Initialize the PLT0 entry */
+ if (splt->_raw_size > 0)
+ {
+ bfd_put_32 (output_bfd, PLT_HEADER_WORD1, splt->contents);
+ bfd_put_32 (output_bfd, PLT_HEADER_WORD2, splt->contents + 4);
+ bfd_put_32 (output_bfd, PLT_HEADER_WORD3, splt->contents + 8);
+ bfd_put_32 (output_bfd, PLT_HEADER_WORD4, splt->contents + 12);
+
+ /* The next two words will be filled in by ld.so */
+ bfd_put_64 (output_bfd, 0, splt->contents + 16);
+ bfd_put_64 (output_bfd, 0, splt->contents + 24);
+
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize =
+ PLT_HEADER_SIZE;
+ }
+ }
+
+ if (info->shared)
+ {
+ asection *sdynsym;
+ asection *s;
+ Elf_Internal_Sym sym;
+
+ /* Set up the section symbols for the output sections. */
+
+ sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (sdynsym != NULL);
+
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_other = 0;
+
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ int indx;
+
+ sym.st_value = s->vma;
+
+ indx = elf_section_data (s)->this_idx;
+ BFD_ASSERT (indx > 0);
+ sym.st_shndx = indx;
+
+ bfd_elf64_swap_symbol_out (output_bfd, &sym,
+ (PTR) (((Elf64_External_Sym *)
+ sdynsym->contents)
+ + elf_section_data (s)->dynindx));
+ }
+
+ /* Set the sh_info field of the output .dynsym section to the
+ index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
+ bfd_count_sections (output_bfd) + 1;
+ }
+
+ return true;
+}
+
+/* We need to use a special link routine to handle the .reginfo and
+ the .mdebug sections. We need to merge all instances of these
+ sections together, not write them all out sequentially. */
+
+static boolean
+elf64_alpha_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection *o;
+ struct bfd_link_order *p;
+ asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
+ struct ecoff_debug_info debug;
+ const struct ecoff_debug_swap *swap
+ = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+ HDRR *symhdr = &debug.symbolic_header;
+ PTR mdebug_handle = NULL;
+
+#if 0
+ if (++ngots == 2)
+ {
+ (*info->callbacks->warning)
+ (info, _("using multiple gp values"), (char *) NULL,
+ output_bfd, (asection *) NULL, (bfd_vma) 0);
+ }
+#endif
+
+ /* Go through the sections and collect the .reginfo and .mdebug
+ information. */
+ reginfo_sec = NULL;
+ mdebug_sec = NULL;
+ gptab_data_sec = NULL;
+ gptab_bss_sec = NULL;
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+#ifdef ERIC_neverdef
+ if (strcmp (o->name, ".reginfo") == 0)
+ {
+ memset (&reginfo, 0, sizeof reginfo);
+
+ /* We have found the .reginfo section in the output file.
+ Look through all the link_orders comprising it and merge
+ the information together. */
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ Elf64_External_RegInfo ext;
+ Elf64_RegInfo sub;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ /* The linker emulation code has probably clobbered the
+ size to be zero bytes. */
+ if (input_section->_raw_size == 0)
+ input_section->_raw_size = sizeof (Elf64_External_RegInfo);
+
+ if (! bfd_get_section_contents (input_bfd, input_section,
+ (PTR) &ext,
+ (file_ptr) 0,
+ sizeof ext))
+ return false;
+
+ bfd_alpha_elf64_swap_reginfo_in (input_bfd, &ext, &sub);
+
+ reginfo.ri_gprmask |= sub.ri_gprmask;
+ reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
+ reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
+ reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
+ reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
+
+ /* ri_gp_value is set by the function
+ alpha_elf_section_processing when the section is
+ finally written out. */
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ /* Force the section size to the value we want. */
+ o->_raw_size = sizeof (Elf64_External_RegInfo);
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+
+ reginfo_sec = o;
+ }
+#endif
+
+ if (strcmp (o->name, ".mdebug") == 0)
+ {
+ struct extsym_info einfo;
+
+ /* We have found the .mdebug section in the output file.
+ Look through all the link_orders comprising it and merge
+ the information together. */
+ symhdr->magic = swap->sym_magic;
+ /* FIXME: What should the version stamp be? */
+ symhdr->vstamp = 0;
+ symhdr->ilineMax = 0;
+ symhdr->cbLine = 0;
+ symhdr->idnMax = 0;
+ symhdr->ipdMax = 0;
+ symhdr->isymMax = 0;
+ symhdr->ioptMax = 0;
+ symhdr->iauxMax = 0;
+ symhdr->issMax = 0;
+ symhdr->issExtMax = 0;
+ symhdr->ifdMax = 0;
+ symhdr->crfd = 0;
+ symhdr->iextMax = 0;
+
+ /* We accumulate the debugging information itself in the
+ debug_info structure. */
+ debug.line = NULL;
+ debug.external_dnr = NULL;
+ debug.external_pdr = NULL;
+ debug.external_sym = NULL;
+ debug.external_opt = NULL;
+ debug.external_aux = NULL;
+ debug.ss = NULL;
+ debug.ssext = debug.ssext_end = NULL;
+ debug.external_fdr = NULL;
+ debug.external_rfd = NULL;
+ debug.external_ext = debug.external_ext_end = NULL;
+
+ mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
+ if (mdebug_handle == (PTR) NULL)
+ return false;
+
+ if (1)
+ {
+ asection *s;
+ EXTR esym;
+ bfd_vma last;
+ unsigned int i;
+ static const char * const name[] =
+ {
+ ".text", ".init", ".fini", ".data",
+ ".rodata", ".sdata", ".sbss", ".bss"
+ };
+ static const int sc[] = { scText, scInit, scFini, scData,
+ scRData, scSData, scSBss, scBss };
+
+ esym.jmptbl = 0;
+ esym.cobol_main = 0;
+ esym.weakext = 0;
+ esym.reserved = 0;
+ esym.ifd = ifdNil;
+ esym.asym.iss = issNil;
+ esym.asym.st = stLocal;
+ esym.asym.reserved = 0;
+ esym.asym.index = indexNil;
+ for (i = 0; i < 8; i++)
+ {
+ esym.asym.sc = sc[i];
+ s = bfd_get_section_by_name (abfd, name[i]);
+ if (s != NULL)
+ {
+ esym.asym.value = s->vma;
+ last = s->vma + s->_raw_size;
+ }
+ else
+ esym.asym.value = last;
+
+ if (! bfd_ecoff_debug_one_external (abfd, &debug, swap,
+ name[i], &esym))
+ return false;
+ }
+ }
+
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ const struct ecoff_debug_swap *input_swap;
+ struct ecoff_debug_info input_debug;
+ char *eraw_src;
+ char *eraw_end;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
+ || (get_elf_backend_data (input_bfd)
+ ->elf_backend_ecoff_debug_swap) == NULL)
+ {
+ /* I don't know what a non ALPHA ELF bfd would be
+ doing with a .mdebug section, but I don't really
+ want to deal with it. */
+ continue;
+ }
+
+ input_swap = (get_elf_backend_data (input_bfd)
+ ->elf_backend_ecoff_debug_swap);
+
+ BFD_ASSERT (p->size == input_section->_raw_size);
+
+ /* The ECOFF linking code expects that we have already
+ read in the debugging information and set up an
+ ecoff_debug_info structure, so we do that now. */
+ if (!elf64_alpha_read_ecoff_info (input_bfd, input_section,
+ &input_debug))
+ return false;
+
+ if (! (bfd_ecoff_debug_accumulate
+ (mdebug_handle, abfd, &debug, swap, input_bfd,
+ &input_debug, input_swap, info)))
+ return false;
+
+ /* Loop through the external symbols. For each one with
+ interesting information, try to find the symbol in
+ the linker global hash table and save the information
+ for the output external symbols. */
+ eraw_src = input_debug.external_ext;
+ eraw_end = (eraw_src
+ + (input_debug.symbolic_header.iextMax
+ * input_swap->external_ext_size));
+ for (;
+ eraw_src < eraw_end;
+ eraw_src += input_swap->external_ext_size)
+ {
+ EXTR ext;
+ const char *name;
+ struct alpha_elf_link_hash_entry *h;
+
+ (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
+ if (ext.asym.sc == scNil
+ || ext.asym.sc == scUndefined
+ || ext.asym.sc == scSUndefined)
+ continue;
+
+ name = input_debug.ssext + ext.asym.iss;
+ h = alpha_elf_link_hash_lookup (alpha_elf_hash_table (info),
+ name, false, false, true);
+ if (h == NULL || h->esym.ifd != -2)
+ continue;
+
+ if (ext.ifd != -1)
+ {
+ BFD_ASSERT (ext.ifd
+ < input_debug.symbolic_header.ifdMax);
+ ext.ifd = input_debug.ifdmap[ext.ifd];
+ }
+
+ h->esym = ext;
+ }
+
+ /* Free up the information we just read. */
+ free (input_debug.line);
+ free (input_debug.external_dnr);
+ free (input_debug.external_pdr);
+ free (input_debug.external_sym);
+ free (input_debug.external_opt);
+ free (input_debug.external_aux);
+ free (input_debug.ss);
+ free (input_debug.ssext);
+ free (input_debug.external_fdr);
+ free (input_debug.external_rfd);
+ free (input_debug.external_ext);
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+#ifdef ERIC_neverdef
+ if (info->shared)
+ {
+ /* Create .rtproc section. */
+ rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
+ if (rtproc_sec == NULL)
+ {
+ flagword flags = (SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY);
+
+ rtproc_sec = bfd_make_section (abfd, ".rtproc");
+ if (rtproc_sec == NULL
+ || ! bfd_set_section_flags (abfd, rtproc_sec, flags)
+ || ! bfd_set_section_alignment (abfd, rtproc_sec, 12))
+ return false;
+ }
+
+ if (! alpha_elf_create_procedure_table (mdebug_handle, abfd,
+ info, rtproc_sec, &debug))
+ return false;
+ }
+#endif
+
+
+ /* Build the external symbol information. */
+ einfo.abfd = abfd;
+ einfo.info = info;
+ einfo.debug = &debug;
+ einfo.swap = swap;
+ einfo.failed = false;
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf64_alpha_output_extsym,
+ (PTR) &einfo);
+ if (einfo.failed)
+ return false;
+
+ /* Set the size of the .mdebug section. */
+ o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+
+ mdebug_sec = o;
+ }
+
+#ifdef ERIC_neverdef
+ if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
+ {
+ const char *subname;
+ unsigned int c;
+ Elf64_gptab *tab;
+ Elf64_External_gptab *ext_tab;
+ unsigned int i;
+
+ /* The .gptab.sdata and .gptab.sbss sections hold
+ information describing how the small data area would
+ change depending upon the -G switch. These sections
+ not used in executables files. */
+ if (! info->relocateable)
+ {
+ asection **secpp;
+
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ /* Skip this section later on (I don't think this
+ currently matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+
+ /* Really remove the section. */
+ for (secpp = &abfd->sections;
+ *secpp != o;
+ secpp = &(*secpp)->next)
+ ;
+ *secpp = (*secpp)->next;
+ --abfd->section_count;
+
+ continue;
+ }
+
+ /* There is one gptab for initialized data, and one for
+ uninitialized data. */
+ if (strcmp (o->name, ".gptab.sdata") == 0)
+ gptab_data_sec = o;
+ else if (strcmp (o->name, ".gptab.sbss") == 0)
+ gptab_bss_sec = o;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: illegal section name `%s'"),
+ bfd_get_filename (abfd), o->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+
+ /* The linker script always combines .gptab.data and
+ .gptab.sdata into .gptab.sdata, and likewise for
+ .gptab.bss and .gptab.sbss. It is possible that there is
+ no .sdata or .sbss section in the output file, in which
+ case we must change the name of the output section. */
+ subname = o->name + sizeof ".gptab" - 1;
+ if (bfd_get_section_by_name (abfd, subname) == NULL)
+ {
+ if (o == gptab_data_sec)
+ o->name = ".gptab.data";
+ else
+ o->name = ".gptab.bss";
+ subname = o->name + sizeof ".gptab" - 1;
+ BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
+ }
+
+ /* Set up the first entry. */
+ c = 1;
+ tab = (Elf64_gptab *) bfd_malloc (c * sizeof (Elf64_gptab));
+ if (tab == NULL)
+ return false;
+ tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
+ tab[0].gt_header.gt_unused = 0;
+
+ /* Combine the input sections. */
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ bfd_size_type size;
+ unsigned long last;
+ bfd_size_type gpentry;
+
+ if (p->type != bfd_indirect_link_order)
+ {
+ if (p->type == bfd_fill_link_order)
+ continue;
+ abort ();
+ }
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ /* Combine the gptab entries for this input section one
+ by one. We know that the input gptab entries are
+ sorted by ascending -G value. */
+ size = bfd_section_size (input_bfd, input_section);
+ last = 0;
+ for (gpentry = sizeof (Elf64_External_gptab);
+ gpentry < size;
+ gpentry += sizeof (Elf64_External_gptab))
+ {
+ Elf64_External_gptab ext_gptab;
+ Elf64_gptab int_gptab;
+ unsigned long val;
+ unsigned long add;
+ boolean exact;
+ unsigned int look;
+
+ if (! (bfd_get_section_contents
+ (input_bfd, input_section, (PTR) &ext_gptab,
+ gpentry, sizeof (Elf64_External_gptab))))
+ {
+ free (tab);
+ return false;
+ }
+
+ bfd_alpha_elf64_swap_gptab_in (input_bfd, &ext_gptab,
+ &int_gptab);
+ val = int_gptab.gt_entry.gt_g_value;
+ add = int_gptab.gt_entry.gt_bytes - last;
+
+ exact = false;
+ for (look = 1; look < c; look++)
+ {
+ if (tab[look].gt_entry.gt_g_value >= val)
+ tab[look].gt_entry.gt_bytes += add;
+
+ if (tab[look].gt_entry.gt_g_value == val)
+ exact = true;
+ }
+
+ if (! exact)
+ {
+ Elf64_gptab *new_tab;
+ unsigned int max;
+
+ /* We need a new table entry. */
+ new_tab = ((Elf64_gptab *)
+ bfd_realloc ((PTR) tab,
+ (c + 1) * sizeof (Elf64_gptab)));
+ if (new_tab == NULL)
+ {
+ free (tab);
+ return false;
+ }
+ tab = new_tab;
+ tab[c].gt_entry.gt_g_value = val;
+ tab[c].gt_entry.gt_bytes = add;
+
+ /* Merge in the size for the next smallest -G
+ value, since that will be implied by this new
+ value. */
+ max = 0;
+ for (look = 1; look < c; look++)
+ {
+ if (tab[look].gt_entry.gt_g_value < val
+ && (max == 0
+ || (tab[look].gt_entry.gt_g_value
+ > tab[max].gt_entry.gt_g_value)))
+ max = look;
+ }
+ if (max != 0)
+ tab[c].gt_entry.gt_bytes +=
+ tab[max].gt_entry.gt_bytes;
+
+ ++c;
+ }
+
+ last = int_gptab.gt_entry.gt_bytes;
+ }
+
+ /* Hack: reset the SEC_HAS_CONTENTS flag so that
+ elf_link_input_bfd ignores this section. */
+ input_section->flags &=~ SEC_HAS_CONTENTS;
+ }
+
+ /* The table must be sorted by -G value. */
+ if (c > 2)
+ qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
+
+ /* Swap out the table. */
+ ext_tab = ((Elf64_External_gptab *)
+ bfd_alloc (abfd, c * sizeof (Elf64_External_gptab)));
+ if (ext_tab == NULL)
+ {
+ free (tab);
+ return false;
+ }
+
+ for (i = 0; i < c; i++)
+ bfd_alpha_elf64_swap_gptab_out (abfd, tab + i, ext_tab + i);
+ free (tab);
+
+ o->_raw_size = c * sizeof (Elf64_External_gptab);
+ o->contents = (bfd_byte *) ext_tab;
+
+ /* Skip this section later on (I don't think this currently
+ matters, but someday it might). */
+ o->link_order_head = (struct bfd_link_order *) NULL;
+ }
+#endif
+
+ }
+
+ /* Invoke the regular ELF backend linker to do all the work. */
+ if (! bfd_elf64_bfd_final_link (abfd, info))
+ return false;
+
+ /* Now write out the computed sections. */
+
+ /* The .got subsections... */
+ {
+ bfd *i, *dynobj = elf_hash_table(info)->dynobj;
+ for (i = alpha_elf_hash_table(info)->got_list;
+ i != NULL;
+ i = alpha_elf_tdata(i)->got_link_next)
+ {
+ asection *sgot;
+
+ /* elf_bfd_final_link already did everything in dynobj. */
+ if (i == dynobj)
+ continue;
+
+ sgot = alpha_elf_tdata(i)->got;
+ if (! bfd_set_section_contents (abfd, sgot->output_section,
+ sgot->contents, sgot->output_offset,
+ sgot->_raw_size))
+ return false;
+ }
+ }
+
+#ifdef ERIC_neverdef
+ if (reginfo_sec != (asection *) NULL)
+ {
+ Elf64_External_RegInfo ext;
+
+ bfd_alpha_elf64_swap_reginfo_out (abfd, &reginfo, &ext);
+ if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
+ (file_ptr) 0, sizeof ext))
+ return false;
+ }
+#endif
+
+ if (mdebug_sec != (asection *) NULL)
+ {
+ BFD_ASSERT (abfd->output_has_begun);
+ if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
+ swap, info,
+ mdebug_sec->filepos))
+ return false;
+
+ bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
+ }
+
+ if (gptab_data_sec != (asection *) NULL)
+ {
+ if (! bfd_set_section_contents (abfd, gptab_data_sec,
+ gptab_data_sec->contents,
+ (file_ptr) 0,
+ gptab_data_sec->_raw_size))
+ return false;
+ }
+
+ if (gptab_bss_sec != (asection *) NULL)
+ {
+ if (! bfd_set_section_contents (abfd, gptab_bss_sec,
+ gptab_bss_sec->contents,
+ (file_ptr) 0,
+ gptab_bss_sec->_raw_size))
+ return false;
+ }
+
+ return true;
+}
+
+/* ECOFF swapping routines. These are used when dealing with the
+ .mdebug section, which is in the ECOFF debugging format. Copied
+ from elf32-mips.c. */
+static const struct ecoff_debug_swap
+elf64_alpha_ecoff_debug_swap =
+{
+ /* Symbol table magic number. */
+ magicSym2,
+ /* Alignment of debugging information. E.g., 4. */
+ 8,
+ /* Sizes of external symbolic information. */
+ sizeof (struct hdr_ext),
+ sizeof (struct dnr_ext),
+ sizeof (struct pdr_ext),
+ sizeof (struct sym_ext),
+ sizeof (struct opt_ext),
+ sizeof (struct fdr_ext),
+ sizeof (struct rfd_ext),
+ sizeof (struct ext_ext),
+ /* Functions to swap in external symbolic data. */
+ ecoff_swap_hdr_in,
+ ecoff_swap_dnr_in,
+ ecoff_swap_pdr_in,
+ ecoff_swap_sym_in,
+ ecoff_swap_opt_in,
+ ecoff_swap_fdr_in,
+ ecoff_swap_rfd_in,
+ ecoff_swap_ext_in,
+ _bfd_ecoff_swap_tir_in,
+ _bfd_ecoff_swap_rndx_in,
+ /* Functions to swap out external symbolic data. */
+ ecoff_swap_hdr_out,
+ ecoff_swap_dnr_out,
+ ecoff_swap_pdr_out,
+ ecoff_swap_sym_out,
+ ecoff_swap_opt_out,
+ ecoff_swap_fdr_out,
+ ecoff_swap_rfd_out,
+ ecoff_swap_ext_out,
+ _bfd_ecoff_swap_tir_out,
+ _bfd_ecoff_swap_rndx_out,
+ /* Function to read in symbolic data. */
+ elf64_alpha_read_ecoff_info
+};
+
+#define TARGET_LITTLE_SYM bfd_elf64_alpha_vec
+#define TARGET_LITTLE_NAME "elf64-alpha"
+#define ELF_ARCH bfd_arch_alpha
+#define ELF_MACHINE_CODE EM_ALPHA
+#define ELF_MAXPAGESIZE 0x10000
+
+#define bfd_elf64_bfd_link_hash_table_create \
+ elf64_alpha_bfd_link_hash_table_create
+
+#define bfd_elf64_bfd_reloc_type_lookup \
+ elf64_alpha_bfd_reloc_type_lookup
+#define elf_info_to_howto \
+ elf64_alpha_info_to_howto
+
+#define bfd_elf64_mkobject \
+ elf64_alpha_mkobject
+#define elf_backend_object_p \
+ elf64_alpha_object_p
+
+#define elf_backend_section_from_shdr \
+ elf64_alpha_section_from_shdr
+#define elf_backend_fake_sections \
+ elf64_alpha_fake_sections
+
+#define bfd_elf64_bfd_is_local_label_name \
+ elf64_alpha_is_local_label_name
+#define bfd_elf64_find_nearest_line \
+ elf64_alpha_find_nearest_line
+#define bfd_elf64_bfd_relax_section \
+ elf64_alpha_relax_section
+
+#define elf_backend_add_symbol_hook \
+ elf64_alpha_add_symbol_hook
+#define elf_backend_check_relocs \
+ elf64_alpha_check_relocs
+#define elf_backend_create_dynamic_sections \
+ elf64_alpha_create_dynamic_sections
+#define elf_backend_adjust_dynamic_symbol \
+ elf64_alpha_adjust_dynamic_symbol
+#define elf_backend_always_size_sections \
+ elf64_alpha_always_size_sections
+#define elf_backend_size_dynamic_sections \
+ elf64_alpha_size_dynamic_sections
+#define elf_backend_relocate_section \
+ elf64_alpha_relocate_section
+#define elf_backend_finish_dynamic_symbol \
+ elf64_alpha_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ elf64_alpha_finish_dynamic_sections
+#define bfd_elf64_bfd_final_link \
+ elf64_alpha_final_link
+
+#define elf_backend_ecoff_debug_swap \
+ &elf64_alpha_ecoff_debug_swap
+
+/*
+ * A few constants that determine how the .plt section is set up.
+ */
+#define elf_backend_want_got_plt 0
+#define elf_backend_plt_readonly 0
+#define elf_backend_want_plt_sym 1
+#define elf_backend_got_header_size 0
+#define elf_backend_plt_header_size PLT_HEADER_SIZE
+
+#include "elf64-target.h"
diff --git a/bfd/elf64-gen.c b/bfd/elf64-gen.c
new file mode 100644
index 00000000000..2f470ff057f
--- /dev/null
+++ b/bfd/elf64-gen.c
@@ -0,0 +1,71 @@
+/* Generic support for 64-bit ELF
+ Copyright 1993, 1995, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* This does not include any relocation information, but should be
+ good enough for GDB or objdump to read the file. */
+
+static reloc_howto_type dummy =
+ HOWTO (0, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "UNKNOWN", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false); /* pcrel_offset */
+
+static void
+elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc)
+ bfd *abfd;
+ arelent *bfd_reloc;
+ Elf64_Internal_Rela *elf_reloc;
+{
+ bfd_reloc->howto = &dummy;
+}
+
+static void
+elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
+ bfd *abfd;
+ arelent *bfd_reloc;
+ Elf64_Internal_Rel *elf_reloc;
+{
+ bfd_reloc->howto = &dummy;
+}
+
+#define TARGET_LITTLE_SYM bfd_elf64_little_generic_vec
+#define TARGET_LITTLE_NAME "elf64-little"
+#define TARGET_BIG_SYM bfd_elf64_big_generic_vec
+#define TARGET_BIG_NAME "elf64-big"
+#define ELF_ARCH bfd_arch_unknown
+#define ELF_MACHINE_CODE EM_NONE
+#define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+#define elf_info_to_howto elf_generic_info_to_howto
+#define elf_info_to_howto_rel elf_generic_info_to_howto_rel
+
+#include "elf64-target.h"
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
new file mode 100644
index 00000000000..9fb8bb9c85e
--- /dev/null
+++ b/bfd/elf64-mips.c
@@ -0,0 +1,2127 @@
+/* MIPS-specific support for 64-bit ELF
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+ 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file supports the 64-bit MIPS ELF ABI.
+
+ The MIPS 64-bit ELF ABI uses an unusual reloc format. This file
+ overrides the usual ELF reloc handling, and handles reading and
+ writing the relocations here.
+
+ The MIPS 64-bit ELF ABI also uses an unusual archive map format. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/ar.h"
+#include "bfdlink.h"
+#include "genlink.h"
+#include "elf-bfd.h"
+#include "elf/mips.h"
+
+/* Get the ECOFF swapping routines. The 64-bit ABI is not supposed to
+ use ECOFF. However, we support it anyhow for an easier changeover. */
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/internal.h"
+#include "coff/ecoff.h"
+/* The 64 bit versions of the mdebug data structures are in alpha.h. */
+#include "coff/alpha.h"
+#define ECOFF_64
+#include "ecoffswap.h"
+
+static void mips_elf64_swap_reloc_in
+ PARAMS ((bfd *, const Elf64_Mips_External_Rel *,
+ Elf64_Mips_Internal_Rel *));
+static void mips_elf64_swap_reloca_in
+ PARAMS ((bfd *, const Elf64_Mips_External_Rela *,
+ Elf64_Mips_Internal_Rela *));
+#if 0
+static void mips_elf64_swap_reloc_out
+ PARAMS ((bfd *, const Elf64_Mips_Internal_Rel *,
+ Elf64_Mips_External_Rel *));
+#endif
+static void mips_elf64_swap_reloca_out
+ PARAMS ((bfd *, const Elf64_Mips_Internal_Rela *,
+ Elf64_Mips_External_Rela *));
+static reloc_howto_type *mips_elf64_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static long mips_elf64_get_reloc_upper_bound PARAMS ((bfd *, asection *));
+static boolean mips_elf64_slurp_one_reloc_table
+ PARAMS ((bfd *, asection *, asymbol **, const Elf_Internal_Shdr *));
+static boolean mips_elf64_slurp_reloc_table
+ PARAMS ((bfd *, asection *, asymbol **, boolean));
+static void mips_elf64_write_relocs PARAMS ((bfd *, asection *, PTR));
+static boolean mips_elf64_section_from_shdr
+ PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
+static boolean mips_elf64_section_processing
+ PARAMS ((bfd *, Elf_Internal_Shdr *));
+static boolean mips_elf64_slurp_armap PARAMS ((bfd *));
+static boolean mips_elf64_write_armap
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+/* The relocation table used for SHT_REL sections. */
+
+static reloc_howto_type mips_elf64_howto_table_rel[] =
+{
+ /* No relocation. */
+ HOWTO (R_MIPS_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit relocation. */
+ HOWTO (R_MIPS_16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit relocation. */
+ HOWTO (R_MIPS_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit symbol relative relocation. */
+ HOWTO (R_MIPS_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_REL32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 26 bit branch address. */
+ HOWTO (R_MIPS_26, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ /* This needs complex overflow
+ detection, because the upper four
+ bits must match the PC. */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_26", /* name */
+ true, /* partial_inplace */
+ 0x3ffffff, /* src_mask */
+ 0x3ffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of symbol value. */
+ HOWTO (R_MIPS_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_mips_elf_hi16_reloc, /* special_function */
+ "R_MIPS_HI16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of symbol value. */
+ HOWTO (R_MIPS_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_mips_elf_lo16_reloc, /* special_function */
+ "R_MIPS_LO16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GP relative reference. */
+ HOWTO (R_MIPS_GPREL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ _bfd_mips_elf_gprel16_reloc, /* special_function */
+ "R_MIPS_GPREL16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Reference to literal section. */
+ HOWTO (R_MIPS_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 */
+ _bfd_mips_elf_gprel16_reloc, /* special_function */
+ "R_MIPS_LITERAL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Reference to global offset table. */
+ HOWTO (R_MIPS_GOT16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ _bfd_mips_elf_got16_reloc, /* special_function */
+ "R_MIPS_GOT16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit PC relative reference. */
+ HOWTO (R_MIPS_PC16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_PC16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit call through global offset table. */
+ /* FIXME: This is not handled correctly. */
+ HOWTO (R_MIPS_CALL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit GP relative reference. */
+ HOWTO (R_MIPS_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 */
+ _bfd_mips_elf_gprel32_reloc, /* special_function */
+ "R_MIPS_GPREL32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ { 13 },
+ { 14 },
+ { 15 },
+
+ /* A 5 bit shift field. */
+ HOWTO (R_MIPS_SHIFT5, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 5, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SHIFT5", /* name */
+ true, /* partial_inplace */
+ 0x000007c0, /* src_mask */
+ 0x000007c0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 6 bit shift field. */
+ /* FIXME: This is not handled correctly; a special function is
+ needed to put the most significant bit in the right place. */
+ HOWTO (R_MIPS_SHIFT6, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SHIFT6", /* name */
+ true, /* partial_inplace */
+ 0x000007c4, /* src_mask */
+ 0x000007c4, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 64 bit relocation. */
+ HOWTO (R_MIPS_64, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_64", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Displacement in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_DISP, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_DISP", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Displacement to page pointer in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_PAGE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_PAGE", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Offset from page pointer in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_OFST, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_OFST", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_HI16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_LO16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 64 bit substraction. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_SUB, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SUB", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Insert the addend as an instruction. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_INSERT_A, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_INSERT_A", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Insert the addend as an instruction, and change all relocations
+ to refer to the old instruction at the address. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_INSERT_B, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_INSERT_B", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Delete a 32 bit instruction. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_DELETE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_DELETE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Get the higher value of a 64 bit addend. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_HIGHER, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_HIGHER", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Get the highest value of a 64 bit addend. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_HIGHEST, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_HIGHEST", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_CALL_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL_HI16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_CALL_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL_LO16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* I'm not sure what the remaining relocs are, but they are defined
+ on Irix 6. */
+
+ HOWTO (R_MIPS_SCN_DISP, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SCN_DISP", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_REL16, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_REL16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_ADD_IMMEDIATE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_ADD_IMMEDIATE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_PJUMP, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_PJUMP", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_RELGOT, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_RELGOT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+/* The relocation table used for SHT_RELA sections. */
+
+static reloc_howto_type mips_elf64_howto_table_rela[] =
+{
+ /* No relocation. */
+ HOWTO (R_MIPS_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit relocation. */
+ HOWTO (R_MIPS_16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit relocation. */
+ HOWTO (R_MIPS_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_32", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit symbol relative relocation. */
+ HOWTO (R_MIPS_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_REL32", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 26 bit branch address. */
+ HOWTO (R_MIPS_26, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ /* This needs complex overflow
+ detection, because the upper four
+ bits must match the PC. */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_26", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x3ffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of symbol value. */
+ HOWTO (R_MIPS_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_HI16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of symbol value. */
+ HOWTO (R_MIPS_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_LO16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GP relative reference. */
+ HOWTO (R_MIPS_GPREL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ _bfd_mips_elf_gprel16_reloc, /* special_function */
+ "R_MIPS_GPREL16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Reference to literal section. */
+ HOWTO (R_MIPS_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 */
+ _bfd_mips_elf_gprel16_reloc, /* special_function */
+ "R_MIPS_LITERAL", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Reference to global offset table. */
+ /* FIXME: This is not handled correctly. */
+ HOWTO (R_MIPS_GOT16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit PC relative reference. */
+ HOWTO (R_MIPS_PC16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_PC16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit call through global offset table. */
+ /* FIXME: This is not handled correctly. */
+ HOWTO (R_MIPS_CALL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 32 bit GP relative reference. */
+ HOWTO (R_MIPS_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 */
+ _bfd_mips_elf_gprel32_reloc, /* special_function */
+ "R_MIPS_GPREL32", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ { 13 },
+ { 14 },
+ { 15 },
+
+ /* A 5 bit shift field. */
+ HOWTO (R_MIPS_SHIFT5, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 5, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SHIFT5", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x000007c0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 6 bit shift field. */
+ /* FIXME: This is not handled correctly; a special function is
+ needed to put the most significant bit in the right place. */
+ HOWTO (R_MIPS_SHIFT6, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 6, /* bitsize */
+ false, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SHIFT6", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x000007c4, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 64 bit relocation. */
+ HOWTO (R_MIPS_64, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_64", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Displacement in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_DISP, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_DISP", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Displacement to page pointer in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_PAGE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_PAGE", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Offset from page pointer in the global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_OFST, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_OFST", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_HI16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_GOT_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_GOT_LO16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 64 bit substraction. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_SUB, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SUB", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Insert the addend as an instruction. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_INSERT_A, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_INSERT_A", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Insert the addend as an instruction, and change all relocations
+ to refer to the old instruction at the address. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_INSERT_B, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_INSERT_B", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Delete a 32 bit instruction. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_DELETE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_DELETE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Get the higher value of a 64 bit addend. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_HIGHER, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_HIGHER", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Get the highest value of a 64 bit addend. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_HIGHEST, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_HIGHEST", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* High 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_CALL_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL_HI16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ /* FIXME: Not handled correctly. */
+ HOWTO (R_MIPS_CALL_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_CALL_LO16", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* I'm not sure what the remaining relocs are, but they are defined
+ on Irix 6. */
+
+ HOWTO (R_MIPS_SCN_DISP, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_SCN_DISP", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_REL16, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_REL16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_ADD_IMMEDIATE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_ADD_IMMEDIATE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_PJUMP, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_PJUMP", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_MIPS_RELGOT, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_MIPS_RELGOT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+/* Swap in a MIPS 64-bit Rel reloc. */
+
+static void
+mips_elf64_swap_reloc_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf64_Mips_External_Rel *src;
+ Elf64_Mips_Internal_Rel *dst;
+{
+ dst->r_offset = bfd_h_get_64 (abfd, (bfd_byte *) src->r_offset);
+ dst->r_sym = bfd_h_get_32 (abfd, (bfd_byte *) src->r_sym);
+ dst->r_ssym = bfd_h_get_8 (abfd, (bfd_byte *) src->r_ssym);
+ dst->r_type3 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type3);
+ dst->r_type2 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type2);
+ dst->r_type = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type);
+}
+
+/* Swap in a MIPS 64-bit Rela reloc. */
+
+static void
+mips_elf64_swap_reloca_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf64_Mips_External_Rela *src;
+ Elf64_Mips_Internal_Rela *dst;
+{
+ dst->r_offset = bfd_h_get_64 (abfd, (bfd_byte *) src->r_offset);
+ dst->r_sym = bfd_h_get_32 (abfd, (bfd_byte *) src->r_sym);
+ dst->r_ssym = bfd_h_get_8 (abfd, (bfd_byte *) src->r_ssym);
+ dst->r_type3 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type3);
+ dst->r_type2 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type2);
+ dst->r_type = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type);
+ dst->r_addend = bfd_h_get_signed_64 (abfd, (bfd_byte *) src->r_addend);
+}
+
+#if 0
+
+/* This is not currently used. */
+
+/* Swap out a MIPS 64-bit Rel reloc. */
+
+static void
+mips_elf64_swap_reloc_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf64_Mips_Internal_Rel *src;
+ Elf64_Mips_External_Rel *dst;
+{
+ bfd_h_put_64 (abfd, src->r_offset, (bfd_byte *) dst->r_offset);
+ bfd_h_put_32 (abfd, src->r_sym, (bfd_byte *) dst->r_sym);
+ bfd_h_put_8 (abfd, src->r_ssym, (bfd_byte *) dst->r_ssym);
+ bfd_h_put_8 (abfd, src->r_type3, (bfd_byte *) dst->r_type3);
+ bfd_h_put_8 (abfd, src->r_type2, (bfd_byte *) dst->r_type2);
+ bfd_h_put_8 (abfd, src->r_type, (bfd_byte *) dst->r_type);
+}
+
+#endif /* 0 */
+
+/* Swap out a MIPS 64-bit Rela reloc. */
+
+static void
+mips_elf64_swap_reloca_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf64_Mips_Internal_Rela *src;
+ Elf64_Mips_External_Rela *dst;
+{
+ bfd_h_put_64 (abfd, src->r_offset, (bfd_byte *) dst->r_offset);
+ bfd_h_put_32 (abfd, src->r_sym, (bfd_byte *) dst->r_sym);
+ bfd_h_put_8 (abfd, src->r_ssym, (bfd_byte *) dst->r_ssym);
+ bfd_h_put_8 (abfd, src->r_type3, (bfd_byte *) dst->r_type3);
+ bfd_h_put_8 (abfd, src->r_type2, (bfd_byte *) dst->r_type2);
+ bfd_h_put_8 (abfd, src->r_type, (bfd_byte *) dst->r_type);
+ bfd_h_put_64 (abfd, src->r_addend, (bfd_byte *) dst->r_addend);
+}
+
+/* A mapping from BFD reloc types to MIPS ELF reloc types. */
+
+struct elf_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ enum elf_mips_reloc_type elf_reloc_val;
+};
+
+static CONST struct elf_reloc_map mips_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_MIPS_NONE, },
+ { BFD_RELOC_16, R_MIPS_16 },
+ { BFD_RELOC_32, R_MIPS_32 },
+ { BFD_RELOC_64, R_MIPS_64 },
+ { BFD_RELOC_CTOR, R_MIPS_64 },
+ { BFD_RELOC_32_PCREL, R_MIPS_REL32 },
+ { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
+ { BFD_RELOC_HI16_S, R_MIPS_HI16 },
+ { BFD_RELOC_LO16, R_MIPS_LO16 },
+ { BFD_RELOC_MIPS_GPREL, R_MIPS_GPREL16 },
+ { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
+ { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
+ { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
+ { BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 },
+ { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
+ { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
+ { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
+ { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 }
+};
+
+/* Given a BFD reloc type, return a howto structure. */
+
+static reloc_howto_type *
+mips_elf64_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map); i++)
+ {
+ if (mips_reloc_map[i].bfd_reloc_val == code)
+ {
+ int v;
+
+ v = (int) mips_reloc_map[i].elf_reloc_val;
+ return &mips_elf64_howto_table_rel[v];
+ }
+ }
+
+ return NULL;
+}
+
+/* Since each entry in an SHT_REL or SHT_RELA section can represent up
+ to three relocs, we must tell the user to allocate more space. */
+
+static long
+mips_elf64_get_reloc_upper_bound (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ return (sec->reloc_count * 3 + 1) * sizeof (arelent *);
+}
+
+/* Read the relocations from one reloc section. */
+
+static boolean
+mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr)
+ bfd *abfd;
+ asection *asect;
+ asymbol **symbols;
+ const Elf_Internal_Shdr *rel_hdr;
+{
+ PTR allocated = NULL;
+ bfd_byte *native_relocs;
+ arelent *relents;
+ arelent *relent;
+ unsigned int count;
+ unsigned int i;
+ int entsize;
+ reloc_howto_type *howto_table;
+
+ allocated = (PTR) bfd_malloc (rel_hdr->sh_size);
+ if (allocated == NULL)
+ goto error_return;
+
+ if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (allocated, 1, rel_hdr->sh_size, abfd) != rel_hdr->sh_size))
+ goto error_return;
+
+ native_relocs = (bfd_byte *) allocated;
+
+ relents = asect->relocation + asect->reloc_count;
+
+ entsize = rel_hdr->sh_entsize;
+ BFD_ASSERT (entsize == sizeof (Elf64_Mips_External_Rel)
+ || entsize == sizeof (Elf64_Mips_External_Rela));
+
+ count = rel_hdr->sh_size / entsize;
+
+ if (entsize == sizeof (Elf64_Mips_External_Rel))
+ howto_table = mips_elf64_howto_table_rel;
+ else
+ howto_table = mips_elf64_howto_table_rela;
+
+ relent = relents;
+ for (i = 0; i < count; i++, native_relocs += entsize)
+ {
+ Elf64_Mips_Internal_Rela rela;
+ boolean used_sym, used_ssym;
+ int ir;
+
+ if (entsize == sizeof (Elf64_Mips_External_Rela))
+ mips_elf64_swap_reloca_in (abfd,
+ (Elf64_Mips_External_Rela *) native_relocs,
+ &rela);
+ else
+ {
+ Elf64_Mips_Internal_Rel rel;
+
+ mips_elf64_swap_reloc_in (abfd,
+ (Elf64_Mips_External_Rel *) native_relocs,
+ &rel);
+ rela.r_offset = rel.r_offset;
+ rela.r_sym = rel.r_sym;
+ rela.r_ssym = rel.r_ssym;
+ rela.r_type3 = rel.r_type3;
+ rela.r_type2 = rel.r_type2;
+ rela.r_type = rel.r_type;
+ rela.r_addend = 0;
+ }
+
+ /* Each entry represents up to three actual relocations. */
+
+ used_sym = false;
+ used_ssym = false;
+ for (ir = 0; ir < 3; ir++)
+ {
+ enum elf_mips_reloc_type type;
+
+ switch (ir)
+ {
+ default:
+ abort ();
+ case 0:
+ type = (enum elf_mips_reloc_type) rela.r_type;
+ break;
+ case 1:
+ type = (enum elf_mips_reloc_type) rela.r_type2;
+ break;
+ case 2:
+ type = (enum elf_mips_reloc_type) rela.r_type3;
+ break;
+ }
+
+ if (type == R_MIPS_NONE)
+ {
+ /* There are no more relocations in this entry. If this
+ is the first entry, we need to generate a dummy
+ relocation so that the generic linker knows that
+ there has been a break in the sequence of relocations
+ applying to a particular address. */
+ if (ir == 0)
+ {
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ relent->address = rela.r_offset;
+ else
+ relent->address = rela.r_offset - asect->vma;
+ relent->addend = 0;
+ relent->howto = &howto_table[(int) R_MIPS_NONE];
+ ++relent;
+ }
+ break;
+ }
+
+ /* Some types require symbols, whereas some do not. */
+ switch (type)
+ {
+ case R_MIPS_NONE:
+ case R_MIPS_LITERAL:
+ case R_MIPS_INSERT_A:
+ case R_MIPS_INSERT_B:
+ case R_MIPS_DELETE:
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ break;
+
+ default:
+ if (! used_sym)
+ {
+ if (rela.r_sym == 0)
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ else
+ {
+ asymbol **ps, *s;
+
+ ps = symbols + rela.r_sym - 1;
+ s = *ps;
+ if ((s->flags & BSF_SECTION_SYM) == 0)
+ relent->sym_ptr_ptr = ps;
+ else
+ relent->sym_ptr_ptr = s->section->symbol_ptr_ptr;
+ }
+
+ used_sym = true;
+ }
+ else if (! used_ssym)
+ {
+ switch (rela.r_ssym)
+ {
+ case RSS_UNDEF:
+ relent->sym_ptr_ptr =
+ bfd_abs_section_ptr->symbol_ptr_ptr;
+ break;
+
+ case RSS_GP:
+ case RSS_GP0:
+ case RSS_LOC:
+ /* FIXME: I think these need to be handled using
+ special howto structures. */
+ BFD_ASSERT (0);
+ break;
+
+ default:
+ BFD_ASSERT (0);
+ break;
+ }
+
+ used_ssym = true;
+ }
+ else
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+
+ break;
+ }
+
+ /* The address of an ELF reloc is section relative for an
+ object file, and absolute for an executable file or
+ shared library. The address of a BFD reloc is always
+ section relative. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ relent->address = rela.r_offset;
+ else
+ relent->address = rela.r_offset - asect->vma;
+
+ relent->addend = rela.r_addend;
+
+ relent->howto = &howto_table[(int) type];
+
+ ++relent;
+ }
+ }
+
+ asect->reloc_count += relent - relents;
+
+ if (allocated != NULL)
+ free (allocated);
+
+ return true;
+
+ error_return:
+ if (allocated != NULL)
+ free (allocated);
+ return false;
+}
+
+/* Read the relocations. On Irix 6, there can be two reloc sections
+ associated with a single data section. */
+
+static boolean
+mips_elf64_slurp_reloc_table (abfd, asect, symbols, dynamic)
+ bfd *abfd;
+ asection *asect;
+ asymbol **symbols;
+ boolean dynamic;
+{
+ struct bfd_elf_section_data * const d = elf_section_data (asect);
+
+ if (dynamic)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ if (asect->relocation != NULL
+ || (asect->flags & SEC_RELOC) == 0
+ || asect->reloc_count == 0)
+ return true;
+
+ /* Allocate space for 3 arelent structures for each Rel structure. */
+ asect->relocation = ((arelent *)
+ bfd_alloc (abfd,
+ asect->reloc_count * 3 * sizeof (arelent)));
+ if (asect->relocation == NULL)
+ return false;
+
+ /* The slurp_one_reloc_table routine increments reloc_count. */
+ asect->reloc_count = 0;
+
+ if (! mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, &d->rel_hdr))
+ return false;
+ if (d->rel_hdr2 != NULL)
+ {
+ if (! mips_elf64_slurp_one_reloc_table (abfd, asect, symbols,
+ d->rel_hdr2))
+ return false;
+ }
+
+ return true;
+}
+
+/* Write out the relocations. */
+
+static void
+mips_elf64_write_relocs (abfd, sec, data)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+{
+ boolean *failedp = (boolean *) data;
+ unsigned int count;
+ Elf_Internal_Shdr *rela_hdr;
+ Elf64_Mips_External_Rela *ext_rela;
+ unsigned int idx;
+ asymbol *last_sym = 0;
+ int last_sym_idx = 0;
+
+ /* If we have already failed, don't do anything. */
+ if (*failedp)
+ return;
+
+ if ((sec->flags & SEC_RELOC) == 0)
+ return;
+
+ /* The linker backend writes the relocs out itself, and sets the
+ reloc_count field to zero to inhibit writing them here. Also,
+ sometimes the SEC_RELOC flag gets set even when there aren't any
+ relocs. */
+ if (sec->reloc_count == 0)
+ return;
+
+ /* We can combine up to three relocs that refer to the same address
+ if the latter relocs have no associated symbol. */
+ count = 0;
+ for (idx = 0; idx < sec->reloc_count; idx++)
+ {
+ bfd_vma addr;
+ unsigned int i;
+
+ ++count;
+
+ addr = sec->orelocation[idx]->address;
+ for (i = 0; i < 2; i++)
+ {
+ arelent *r;
+
+ if (idx + 1 >= sec->reloc_count)
+ break;
+ r = sec->orelocation[idx + 1];
+ if (r->address != addr
+ || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
+ || (*r->sym_ptr_ptr)->value != 0)
+ break;
+
+ /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
+
+ ++idx;
+ }
+ }
+
+ rela_hdr = &elf_section_data (sec)->rel_hdr;
+
+ rela_hdr->sh_size = rela_hdr->sh_entsize * count;
+ rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
+ if (rela_hdr->contents == NULL)
+ {
+ *failedp = true;
+ return;
+ }
+
+ ext_rela = (Elf64_Mips_External_Rela *) rela_hdr->contents;
+ for (idx = 0; idx < sec->reloc_count; idx++, ext_rela++)
+ {
+ arelent *ptr;
+ Elf64_Mips_Internal_Rela int_rela;
+ asymbol *sym;
+ int n;
+ unsigned int i;
+
+ ptr = sec->orelocation[idx];
+
+ /* The address of an ELF reloc is section relative for an object
+ file, and absolute for an executable file or shared library.
+ The address of a BFD reloc is always section relative. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ int_rela.r_offset = ptr->address;
+ else
+ int_rela.r_offset = ptr->address + sec->vma;
+
+ sym = *ptr->sym_ptr_ptr;
+ if (sym == last_sym)
+ n = last_sym_idx;
+ else
+ {
+ last_sym = sym;
+ n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
+ if (n < 0)
+ {
+ *failedp = true;
+ return;
+ }
+ last_sym_idx = n;
+ }
+
+ int_rela.r_sym = n;
+
+ int_rela.r_addend = ptr->addend;
+
+ int_rela.r_ssym = RSS_UNDEF;
+
+ if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
+ && ! _bfd_elf_validate_reloc (abfd, ptr))
+ {
+ *failedp = true;
+ return;
+ }
+
+ int_rela.r_type = ptr->howto->type;
+ int_rela.r_type2 = (int) R_MIPS_NONE;
+ int_rela.r_type3 = (int) R_MIPS_NONE;
+
+ for (i = 0; i < 2; i++)
+ {
+ arelent *r;
+
+ if (idx + 1 >= sec->reloc_count)
+ break;
+ r = sec->orelocation[idx + 1];
+ if (r->address != ptr->address
+ || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
+ || (*r->sym_ptr_ptr)->value != 0)
+ break;
+
+ /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
+
+ if (i == 0)
+ int_rela.r_type2 = r->howto->type;
+ else
+ int_rela.r_type3 = r->howto->type;
+
+ ++idx;
+ }
+
+ mips_elf64_swap_reloca_out (abfd, &int_rela, ext_rela);
+ }
+
+ BFD_ASSERT (ext_rela - (Elf64_Mips_External_Rela *) rela_hdr->contents
+ == count);
+}
+
+/* Handle a 64-bit MIPS ELF specific section. */
+
+static boolean
+mips_elf64_section_from_shdr (abfd, hdr, name)
+ bfd *abfd;
+ Elf_Internal_Shdr *hdr;
+ char *name;
+{
+ if (! _bfd_mips_elf_section_from_shdr (abfd, hdr, name))
+ return false;
+
+ /* For a SHT_MIPS_OPTIONS section, look for a ODK_REGINFO entry, and
+ set the gp value based on what we find. We may see both
+ SHT_MIPS_REGINFO and SHT_MIPS_OPTIONS/ODK_REGINFO; in that case,
+ they should agree. */
+ if (hdr->sh_type == SHT_MIPS_OPTIONS)
+ {
+ bfd_byte *contents, *l, *lend;
+
+ contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
+ if (contents == NULL)
+ return false;
+ if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents,
+ (file_ptr) 0, hdr->sh_size))
+ {
+ free (contents);
+ return false;
+ }
+ l = contents;
+ lend = contents + hdr->sh_size;
+ while (l + sizeof (Elf_External_Options) <= lend)
+ {
+ Elf_Internal_Options intopt;
+
+ bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
+ &intopt);
+ if (intopt.kind == ODK_REGINFO)
+ {
+ Elf64_Internal_RegInfo intreg;
+
+ bfd_mips_elf64_swap_reginfo_in
+ (abfd,
+ ((Elf64_External_RegInfo *)
+ (l + sizeof (Elf_External_Options))),
+ &intreg);
+ elf_gp (abfd) = intreg.ri_gp_value;
+ }
+ l += intopt.size;
+ }
+ free (contents);
+ }
+
+ return true;
+}
+
+/* Work over a section just before writing it out. We update the GP
+ value in the SHT_MIPS_OPTIONS section based on the value we are
+ using. */
+
+static boolean
+mips_elf64_section_processing (abfd, hdr)
+ bfd *abfd;
+ Elf_Internal_Shdr *hdr;
+{
+ if (hdr->sh_type == SHT_MIPS_OPTIONS
+ && hdr->bfd_section != NULL
+ && elf_section_data (hdr->bfd_section) != NULL
+ && elf_section_data (hdr->bfd_section)->tdata != NULL)
+ {
+ bfd_byte *contents, *l, *lend;
+
+ /* We stored the section contents in the elf_section_data tdata
+ field in the set_section_contents routine. We save the
+ section contents so that we don't have to read them again.
+ At this point we know that elf_gp is set, so we can look
+ through the section contents to see if there is an
+ ODK_REGINFO structure. */
+
+ contents = (bfd_byte *) elf_section_data (hdr->bfd_section)->tdata;
+ l = contents;
+ lend = contents + hdr->sh_size;
+ while (l + sizeof (Elf_External_Options) <= lend)
+ {
+ Elf_Internal_Options intopt;
+
+ bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
+ &intopt);
+ if (intopt.kind == ODK_REGINFO)
+ {
+ bfd_byte buf[8];
+
+ if (bfd_seek (abfd,
+ (hdr->sh_offset
+ + (l - contents)
+ + sizeof (Elf_External_Options)
+ + (sizeof (Elf64_External_RegInfo) - 8)),
+ SEEK_SET) == -1)
+ return false;
+ bfd_h_put_64 (abfd, elf_gp (abfd), buf);
+ if (bfd_write (buf, 1, 8, abfd) != 8)
+ return false;
+ }
+ l += intopt.size;
+ }
+ }
+
+ return _bfd_mips_elf_section_processing (abfd, hdr);
+}
+
+/* Irix 6 defines a brand new archive map format, so that they can
+ have archives more than 4 GB in size. */
+
+/* Read an Irix 6 armap. */
+
+static boolean
+mips_elf64_slurp_armap (abfd)
+ bfd *abfd;
+{
+ struct artdata *ardata = bfd_ardata (abfd);
+ char nextname[17];
+ file_ptr arhdrpos;
+ bfd_size_type i, parsed_size, nsymz, stringsize, carsym_size, ptrsize;
+ struct areltdata *mapdata;
+ bfd_byte int_buf[8];
+ char *stringbase;
+ bfd_byte *raw_armap = NULL;
+ carsym *carsyms;
+
+ ardata->symdefs = NULL;
+
+ /* Get the name of the first element. */
+ arhdrpos = bfd_tell (abfd);
+ i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ if (i == 0)
+ return true;
+ if (i != 16)
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ return false;
+
+ /* Archives with traditional armaps are still permitted. */
+ if (strncmp (nextname, "/ ", 16) == 0)
+ return bfd_slurp_armap (abfd);
+
+ if (strncmp (nextname, "/SYM64/ ", 16) != 0)
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
+
+ mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
+ if (mapdata == NULL)
+ return false;
+ parsed_size = mapdata->parsed_size;
+ bfd_release (abfd, (PTR) mapdata);
+
+ if (bfd_read (int_buf, 1, 8, abfd) != 8)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ return false;
+ }
+
+ nsymz = bfd_getb64 (int_buf);
+ stringsize = parsed_size - 8 * nsymz - 8;
+
+ carsym_size = nsymz * sizeof (carsym);
+ ptrsize = 8 * nsymz;
+
+ ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
+ if (ardata->symdefs == NULL)
+ return false;
+ carsyms = ardata->symdefs;
+ stringbase = ((char *) ardata->symdefs) + carsym_size;
+
+ raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize);
+ if (raw_armap == NULL)
+ goto error_return;
+
+ if (bfd_read (raw_armap, 1, ptrsize, abfd) != ptrsize
+ || bfd_read (stringbase, 1, stringsize, abfd) != stringsize)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
+ goto error_return;
+ }
+
+ for (i = 0; i < nsymz; i++)
+ {
+ carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);
+ carsyms->name = stringbase;
+ stringbase += strlen (stringbase) + 1;
+ ++carsyms;
+ }
+ *stringbase = '\0';
+
+ ardata->symdef_count = nsymz;
+ ardata->first_file_filepos = arhdrpos + sizeof (struct ar_hdr) + parsed_size;
+
+ bfd_has_map (abfd) = true;
+ bfd_release (abfd, raw_armap);
+
+ return true;
+
+ error_return:
+ if (raw_armap != NULL)
+ bfd_release (abfd, raw_armap);
+ if (ardata->symdefs != NULL)
+ bfd_release (abfd, ardata->symdefs);
+ return false;
+}
+
+/* Write out an Irix 6 armap. The Irix 6 tools are supposed to be
+ able to handle ordinary ELF armaps, but at least on Irix 6.2 the
+ linker crashes. */
+
+static boolean
+mips_elf64_write_armap (arch, elength, map, symbol_count, stridx)
+ bfd *arch;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int symbol_count;
+ int stridx;
+{
+ unsigned int ranlibsize = (symbol_count * 8) + 8;
+ unsigned int stringsize = stridx;
+ unsigned int mapsize = stringsize + ranlibsize;
+ file_ptr archive_member_file_ptr;
+ bfd *current = arch->archive_head;
+ unsigned int count;
+ struct ar_hdr hdr;
+ unsigned int i;
+ int padding;
+ bfd_byte buf[8];
+
+ padding = BFD_ALIGN (mapsize, 8) - mapsize;
+ mapsize += padding;
+
+ /* work out where the first object file will go in the archive */
+ archive_member_file_ptr = (mapsize
+ + elength
+ + sizeof (struct ar_hdr)
+ + SARMAG);
+
+ memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
+ strcpy (hdr.ar_name, "/SYM64/");
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+ sprintf (hdr.ar_date, "%ld", (long) time (NULL));
+ /* This, at least, is what Intel coff sets the values to.: */
+ sprintf ((hdr.ar_uid), "%d", 0);
+ sprintf ((hdr.ar_gid), "%d", 0);
+ sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
+ strncpy (hdr.ar_fmag, ARFMAG, 2);
+
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+ if (((char *) (&hdr))[i] == '\0')
+ (((char *) (&hdr))[i]) = ' ';
+
+ /* Write the ar header for this item and the number of symbols */
+
+ if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ return false;
+
+ bfd_putb64 (symbol_count, buf);
+ if (bfd_write (buf, 1, 8, arch) != 8)
+ return false;
+
+ /* Two passes, first write the file offsets for each symbol -
+ remembering that each offset is on a two byte boundary. */
+
+ /* Write out the file offset for the file associated with each
+ symbol, and remember to keep the offsets padded out. */
+
+ current = arch->archive_head;
+ count = 0;
+ while (current != (bfd *) NULL && count < symbol_count)
+ {
+ /* For each symbol which is used defined in this object, write out
+ the object file's address in the archive */
+
+ while (((bfd *) (map[count]).pos) == current)
+ {
+ bfd_putb64 (archive_member_file_ptr, buf);
+ if (bfd_write (buf, 1, 8, arch) != 8)
+ return false;
+ count++;
+ }
+ /* Add size of this archive entry */
+ archive_member_file_ptr += (arelt_size (current)
+ + sizeof (struct ar_hdr));
+ /* remember about the even alignment */
+ archive_member_file_ptr += archive_member_file_ptr % 2;
+ current = current->next;
+ }
+
+ /* now write the strings themselves */
+ for (count = 0; count < symbol_count; count++)
+ {
+ size_t len = strlen (*map[count].name) + 1;
+
+ if (bfd_write (*map[count].name, 1, len, arch) != len)
+ return false;
+ }
+
+ /* The spec says that this should be padded to an 8 byte boundary.
+ However, the Irix 6.2 tools do not appear to do this. */
+ while (padding != 0)
+ {
+ if (bfd_write ("", 1, 1, arch) != 1)
+ return false;
+ --padding;
+ }
+
+ return true;
+}
+
+/* ECOFF swapping routines. These are used when dealing with the
+ .mdebug section, which is in the ECOFF debugging format. */
+static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap =
+{
+ /* Symbol table magic number. */
+ magicSym2,
+ /* Alignment of debugging information. E.g., 4. */
+ 8,
+ /* Sizes of external symbolic information. */
+ sizeof (struct hdr_ext),
+ sizeof (struct dnr_ext),
+ sizeof (struct pdr_ext),
+ sizeof (struct sym_ext),
+ sizeof (struct opt_ext),
+ sizeof (struct fdr_ext),
+ sizeof (struct rfd_ext),
+ sizeof (struct ext_ext),
+ /* Functions to swap in external symbolic data. */
+ ecoff_swap_hdr_in,
+ ecoff_swap_dnr_in,
+ ecoff_swap_pdr_in,
+ ecoff_swap_sym_in,
+ ecoff_swap_opt_in,
+ ecoff_swap_fdr_in,
+ ecoff_swap_rfd_in,
+ ecoff_swap_ext_in,
+ _bfd_ecoff_swap_tir_in,
+ _bfd_ecoff_swap_rndx_in,
+ /* Functions to swap out external symbolic data. */
+ ecoff_swap_hdr_out,
+ ecoff_swap_dnr_out,
+ ecoff_swap_pdr_out,
+ ecoff_swap_sym_out,
+ ecoff_swap_opt_out,
+ ecoff_swap_fdr_out,
+ ecoff_swap_rfd_out,
+ ecoff_swap_ext_out,
+ _bfd_ecoff_swap_tir_out,
+ _bfd_ecoff_swap_rndx_out,
+ /* Function to read in symbolic data. */
+ _bfd_mips_elf_read_ecoff_info
+};
+
+/* Relocations in the 64 bit MIPS ELF ABI are more complex than in
+ standard ELF. This structure is used to redirect the relocation
+ handling routines. */
+
+const struct elf_size_info mips_elf64_size_info =
+{
+ sizeof (Elf64_External_Ehdr),
+ sizeof (Elf64_External_Phdr),
+ sizeof (Elf64_External_Shdr),
+ sizeof (Elf64_Mips_External_Rel),
+ sizeof (Elf64_Mips_External_Rela),
+ sizeof (Elf64_External_Sym),
+ sizeof (Elf64_External_Dyn),
+ sizeof (Elf_External_Note),
+ 64, /* arch_size */
+ 8, /* file_align */
+ ELFCLASS64,
+ EV_CURRENT,
+ bfd_elf64_write_out_phdrs,
+ bfd_elf64_write_shdrs_and_ehdr,
+ mips_elf64_write_relocs,
+ bfd_elf64_swap_symbol_out,
+ mips_elf64_slurp_reloc_table,
+ bfd_elf64_slurp_symbol_table,
+ bfd_elf64_swap_dyn_in
+};
+
+#define TARGET_LITTLE_SYM bfd_elf64_littlemips_vec
+#define TARGET_LITTLE_NAME "elf64-littlemips"
+#define TARGET_BIG_SYM bfd_elf64_bigmips_vec
+#define TARGET_BIG_NAME "elf64-bigmips"
+#define ELF_ARCH bfd_arch_mips
+#define ELF_MACHINE_CODE EM_MIPS
+#define ELF_MAXPAGESIZE 0x1000
+#define elf_backend_size_info mips_elf64_size_info
+#define elf_backend_object_p _bfd_mips_elf_object_p
+#define elf_backend_section_from_shdr mips_elf64_section_from_shdr
+#define elf_backend_fake_sections _bfd_mips_elf_fake_sections
+#define elf_backend_section_from_bfd_section \
+ _bfd_mips_elf_section_from_bfd_section
+#define elf_backend_section_processing mips_elf64_section_processing
+#define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
+#define elf_backend_final_write_processing \
+ _bfd_mips_elf_final_write_processing
+#define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
+
+#define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line
+#define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
+#define bfd_elf64_bfd_reloc_type_lookup mips_elf64_reloc_type_lookup
+#define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
+#define bfd_elf64_bfd_copy_private_bfd_data \
+ _bfd_mips_elf_copy_private_bfd_data
+#define bfd_elf64_bfd_merge_private_bfd_data \
+ _bfd_mips_elf_merge_private_bfd_data
+#define bfd_elf64_bfd_set_private_flags _bfd_mips_elf_set_private_flags
+
+#define bfd_elf64_archive_functions
+#define bfd_elf64_archive_slurp_armap mips_elf64_slurp_armap
+#define bfd_elf64_archive_slurp_extended_name_table \
+ _bfd_archive_coff_slurp_extended_name_table
+#define bfd_elf64_archive_construct_extended_name_table \
+ _bfd_archive_coff_construct_extended_name_table
+#define bfd_elf64_archive_truncate_arname \
+ _bfd_archive_coff_truncate_arname
+#define bfd_elf64_archive_write_armap mips_elf64_write_armap
+#define bfd_elf64_archive_read_ar_hdr _bfd_archive_coff_read_ar_hdr
+#define bfd_elf64_archive_openr_next_archived_file \
+ _bfd_archive_coff_openr_next_archived_file
+#define bfd_elf64_archive_get_elt_at_index \
+ _bfd_archive_coff_get_elt_at_index
+#define bfd_elf64_archive_generic_stat_arch_elt \
+ _bfd_archive_coff_generic_stat_arch_elt
+#define bfd_elf64_archive_update_armap_timestamp \
+ _bfd_archive_coff_update_armap_timestamp
+
+#include "elf64-target.h"
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
new file mode 100644
index 00000000000..17fe98dafc2
--- /dev/null
+++ b/bfd/elf64-sparc.c
@@ -0,0 +1,2275 @@
+/* SPARC-specific support for 64-bit ELF
+ Copyright (C) 1993, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* This is defined if one wants to build upward compatible binaries
+ with the original sparc64-elf toolchain. The support is kept in for
+ now but is turned off by default. dje 970930 */
+/*#define SPARC64_OLD_RELOCS*/
+
+#include "elf/sparc.h"
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
+#define MINUS_ONE (~ (bfd_vma) 0)
+
+static reloc_howto_type *sparc64_elf_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void sparc64_elf_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+
+static void sparc64_elf_build_plt
+ PARAMS((bfd *, unsigned char *, int));
+static bfd_vma sparc64_elf_plt_entry_offset
+ PARAMS((int));
+static bfd_vma sparc64_elf_plt_ptr_offset
+ PARAMS((int, int));
+
+static boolean sparc64_elf_check_relocs
+ PARAMS((bfd *, struct bfd_link_info *, asection *sec,
+ const Elf_Internal_Rela *));
+static boolean sparc64_elf_adjust_dynamic_symbol
+ PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean sparc64_elf_size_dynamic_sections
+ PARAMS((bfd *, struct bfd_link_info *));
+static boolean sparc64_elf_adjust_dynindx
+ PARAMS((struct elf_link_hash_entry *, PTR));
+
+static boolean sparc64_elf_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+
+static boolean sparc64_elf_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean sparc64_elf_object_p PARAMS ((bfd *));
+
+/* The relocation "howto" table. */
+
+static bfd_reloc_status_type sparc_elf_notsup_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type sparc_elf_wdisp16_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type sparc_elf_hix22_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type sparc_elf_lox10_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+
+static reloc_howto_type sparc64_elf_howto_table[] =
+{
+ HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
+ HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true),
+ HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true),
+ HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true),
+ HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true),
+ HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true),
+ HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0x00ffffff,true),
+ HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
+ HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
+ HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true),
+ HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
+ HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
+ HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true),
+ HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0x00000000,true),
+#ifndef SPARC64_OLD_RELOCS
+ /* These aren't implemented yet. */
+ HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PLT32", false,0,0x00000000,true),
+ HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true),
+ HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true),
+#endif
+ HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true),
+ HOWTO(R_SPARC_64, 0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_64", false,0,MINUS_ONE, true),
+ HOWTO(R_SPARC_OLO10, 0,2,13,false,0,complain_overflow_signed, sparc_elf_notsup_reloc, "R_SPARC_OLO10", false,0,0x00001fff,true),
+ HOWTO(R_SPARC_HH22, 42,2,22,false,0,complain_overflow_unsigned,bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_HM10, 32,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_LM22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_PC_HH22, 42,2,22,true, 0,complain_overflow_unsigned,bfd_elf_generic_reloc, "R_SPARC_PC_HH22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_PC_HM10, 32,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC_HM10", false,0,0x000003ff,true),
+ HOWTO(R_SPARC_PC_LM22, 10,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC_LM22", false,0,0x003fffff,true),
+ HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
+ HOWTO(R_SPARC_WDISP19, 2,2,19,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
+ HOWTO(R_SPARC_UNUSED_42, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UNUSED_42",false,0,0x00000000,true),
+ HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true),
+ HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true),
+ HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true),
+ HOWTO(R_SPARC_DISP64, 0,4,64,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP64", false,0,MINUS_ONE, true),
+ HOWTO(R_SPARC_PLT64, 0,4,64,false,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_PLT64", false,0,MINUS_ONE, false),
+ HOWTO(R_SPARC_HIX22, 0,4, 0,false,0,complain_overflow_bitfield,sparc_elf_hix22_reloc, "R_SPARC_HIX22", false,0,MINUS_ONE, false),
+ HOWTO(R_SPARC_LOX10, 0,4, 0,false,0,complain_overflow_dont, sparc_elf_lox10_reloc, "R_SPARC_LOX10", false,0,MINUS_ONE, false),
+ HOWTO(R_SPARC_H44, 22,2,22,false,0,complain_overflow_unsigned,bfd_elf_generic_reloc, "R_SPARC_H44", false,0,0x003fffff,false),
+ HOWTO(R_SPARC_M44, 12,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_M44", false,0,0x000003ff,false),
+ HOWTO(R_SPARC_L44, 0,2,13,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_L44", false,0,0x00000fff,false),
+ HOWTO(R_SPARC_REGISTER, 0,4, 0,false,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_REGISTER",false,0,MINUS_ONE, false),
+ HOWTO(R_SPARC_UA64, 0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA64", false,0,MINUS_ONE, true),
+ HOWTO(R_SPARC_UA16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA16", false,0,0x0000ffff,true)
+};
+
+struct elf_reloc_map {
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static CONST struct elf_reloc_map sparc_reloc_map[] =
+{
+ { BFD_RELOC_NONE, R_SPARC_NONE, },
+ { BFD_RELOC_16, R_SPARC_16, },
+ { BFD_RELOC_8, R_SPARC_8 },
+ { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
+ { BFD_RELOC_CTOR, R_SPARC_64 },
+ { BFD_RELOC_32, R_SPARC_32 },
+ { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
+ { BFD_RELOC_HI22, R_SPARC_HI22 },
+ { BFD_RELOC_LO10, R_SPARC_LO10, },
+ { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
+ { BFD_RELOC_SPARC22, R_SPARC_22 },
+ { BFD_RELOC_SPARC13, R_SPARC_13 },
+ { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
+ { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
+ { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
+ { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
+ { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
+ { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
+ { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
+ { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
+ { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
+ { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
+ { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
+ /* ??? Doesn't dwarf use this? */
+/*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
+ {BFD_RELOC_SPARC_10, R_SPARC_10},
+ {BFD_RELOC_SPARC_11, R_SPARC_11},
+ {BFD_RELOC_SPARC_64, R_SPARC_64},
+ {BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
+ {BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
+ {BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
+ {BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
+ {BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
+ {BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
+ {BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
+ {BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
+ {BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
+ {BFD_RELOC_SPARC_7, R_SPARC_7},
+ {BFD_RELOC_SPARC_5, R_SPARC_5},
+ {BFD_RELOC_SPARC_6, R_SPARC_6},
+ {BFD_RELOC_SPARC_DISP64, R_SPARC_DISP64},
+ {BFD_RELOC_SPARC_PLT64, R_SPARC_PLT64},
+ {BFD_RELOC_SPARC_HIX22, R_SPARC_HIX22},
+ {BFD_RELOC_SPARC_LOX10, R_SPARC_LOX10},
+ {BFD_RELOC_SPARC_H44, R_SPARC_H44},
+ {BFD_RELOC_SPARC_M44, R_SPARC_M44},
+ {BFD_RELOC_SPARC_L44, R_SPARC_L44},
+ {BFD_RELOC_SPARC_REGISTER, R_SPARC_REGISTER}
+};
+
+static reloc_howto_type *
+sparc64_elf_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+ for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
+ {
+ if (sparc_reloc_map[i].bfd_reloc_val == code)
+ return &sparc64_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
+ }
+ return 0;
+}
+
+static void
+sparc64_elf_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd;
+ arelent *cache_ptr;
+ Elf64_Internal_Rela *dst;
+{
+ BFD_ASSERT (ELF64_R_TYPE (dst->r_info) < (unsigned int) R_SPARC_max);
+ cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE (dst->r_info)];
+}
+
+/* Utility for performing the standard initial work of an instruction
+ relocation.
+ *PRELOCATION will contain the relocated item.
+ *PINSN will contain the instruction from the input stream.
+ If the result is `bfd_reloc_other' the caller can continue with
+ performing the relocation. Otherwise it must stop and return the
+ value to its caller. */
+
+static bfd_reloc_status_type
+init_insn_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ prelocation,
+ pinsn)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ bfd_vma *prelocation;
+ bfd_vma *pinsn;
+{
+ bfd_vma relocation;
+ reloc_howto_type *howto = reloc_entry->howto;
+
+ if (output_bfd != (bfd *) NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (! howto->partial_inplace
+ || reloc_entry->addend == 0))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* This works because partial_inplace == false. */
+ if (output_bfd != NULL)
+ return bfd_reloc_continue;
+
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ relocation = (symbol->value
+ + symbol->section->output_section->vma
+ + symbol->section->output_offset);
+ relocation += reloc_entry->addend;
+ if (howto->pc_relative)
+ {
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ relocation -= reloc_entry->address;
+ }
+
+ *prelocation = relocation;
+ *pinsn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ return bfd_reloc_other;
+}
+
+/* For unsupported relocs. */
+
+static bfd_reloc_status_type
+sparc_elf_notsup_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ return bfd_reloc_notsupported;
+}
+
+/* Handle the WDISP16 reloc. */
+
+static bfd_reloc_status_type
+sparc_elf_wdisp16_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_vma insn;
+ bfd_reloc_status_type status;
+
+ status = init_insn_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, &relocation, &insn);
+ if (status != bfd_reloc_other)
+ return status;
+
+ insn = (insn & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
+ | ((relocation >> 2) & 0x3fff));
+ bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+ if ((bfd_signed_vma) relocation < - 0x40000
+ || (bfd_signed_vma) relocation > 0x3ffff)
+ return bfd_reloc_overflow;
+ else
+ return bfd_reloc_ok;
+}
+
+/* Handle the HIX22 reloc. */
+
+static bfd_reloc_status_type
+sparc_elf_hix22_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_vma insn;
+ bfd_reloc_status_type status;
+
+ status = init_insn_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, &relocation, &insn);
+ if (status != bfd_reloc_other)
+ return status;
+
+ relocation ^= MINUS_ONE;
+ insn = (insn & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
+ bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+ if ((relocation & ~ (bfd_vma) 0xffffffff) != 0)
+ return bfd_reloc_overflow;
+ else
+ return bfd_reloc_ok;
+}
+
+/* Handle the LOX10 reloc. */
+
+static bfd_reloc_status_type
+sparc_elf_lox10_reloc (abfd,
+ reloc_entry,
+ symbol,
+ data,
+ input_section,
+ output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_vma insn;
+ bfd_reloc_status_type status;
+
+ status = init_insn_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, &relocation, &insn);
+ if (status != bfd_reloc_other)
+ return status;
+
+ insn = (insn & ~0x1fff) | 0x1c00 | (relocation & 0x3ff);
+ bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+ return bfd_reloc_ok;
+}
+
+/* PLT/GOT stuff */
+
+/* Both the headers and the entries are icache aligned. */
+#define PLT_ENTRY_SIZE 32
+#define PLT_HEADER_SIZE (4 * PLT_ENTRY_SIZE)
+#define LARGE_PLT_THRESHOLD 32768
+#define GOT_RESERVED_ENTRIES 1
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/sparcv9/ld.so.1"
+
+
+/* Fill in the .plt section. */
+
+static void
+sparc64_elf_build_plt (output_bfd, contents, nentries)
+ bfd *output_bfd;
+ unsigned char *contents;
+ int nentries;
+{
+ const unsigned int nop = 0x01000000;
+ int i, j;
+
+ /* The first four entries are reserved, and are initially undefined.
+ We fill them with `illtrap 0' to force ld.so to do something. */
+
+ for (i = 0; i < PLT_HEADER_SIZE/4; ++i)
+ bfd_put_32 (output_bfd, 0, contents+i*4);
+
+ /* The first 32768 entries are close enough to plt1 to get there via
+ a straight branch. */
+
+ for (i = 4; i < LARGE_PLT_THRESHOLD && i < nentries; ++i)
+ {
+ unsigned char *entry = contents + i * PLT_ENTRY_SIZE;
+ unsigned int sethi, ba;
+
+ /* sethi (. - plt0), %g1 */
+ sethi = 0x03000000 | (i * PLT_ENTRY_SIZE);
+
+ /* ba,a,pt %icc, plt1 */
+ ba = 0x30480000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff);
+
+ bfd_put_32 (output_bfd, sethi, entry);
+ bfd_put_32 (output_bfd, ba, entry+4);
+ bfd_put_32 (output_bfd, nop, entry+8);
+ bfd_put_32 (output_bfd, nop, entry+12);
+ bfd_put_32 (output_bfd, nop, entry+16);
+ bfd_put_32 (output_bfd, nop, entry+20);
+ bfd_put_32 (output_bfd, nop, entry+24);
+ bfd_put_32 (output_bfd, nop, entry+28);
+ }
+
+ /* Now the tricky bit. Entries 32768 and higher are grouped in blocks of
+ 160: 160 entries and 160 pointers. This is to separate code from data,
+ which is much friendlier on the cache. */
+
+ for (; i < nentries; i += 160)
+ {
+ int block = (i + 160 <= nentries ? 160 : nentries - i);
+ for (j = 0; j < block; ++j)
+ {
+ unsigned char *entry, *ptr;
+ unsigned int ldx;
+
+ entry = contents + i*PLT_ENTRY_SIZE + j*4*6;
+ ptr = contents + i*PLT_ENTRY_SIZE + block*4*6 + j*8;
+
+ /* ldx [%o7 + ptr - entry+4], %g1 */
+ ldx = 0xc25be000 | ((ptr - entry+4) & 0x1fff);
+
+ bfd_put_32 (output_bfd, 0x8a10000f, entry); /* mov %o7,%g5 */
+ bfd_put_32 (output_bfd, 0x40000002, entry+4); /* call .+8 */
+ bfd_put_32 (output_bfd, nop, entry+8); /* nop */
+ bfd_put_32 (output_bfd, ldx, entry+12); /* ldx [%o7+P],%g1 */
+ bfd_put_32 (output_bfd, 0x83c3c001, entry+16); /* jmpl %o7+%g1,%g1 */
+ bfd_put_32 (output_bfd, 0x9e100005, entry+20); /* mov %g5,%o7 */
+
+ bfd_put_64 (output_bfd, contents - entry+4, ptr);
+ }
+ }
+}
+
+/* Return the offset of a particular plt entry within the .plt section. */
+
+static bfd_vma
+sparc64_elf_plt_entry_offset (index)
+ int index;
+{
+ int block, ofs;
+
+ if (index < LARGE_PLT_THRESHOLD)
+ return index * PLT_ENTRY_SIZE;
+
+ /* See above for details. */
+
+ block = (index - LARGE_PLT_THRESHOLD) / 160;
+ ofs = (index - LARGE_PLT_THRESHOLD) % 160;
+
+ return ((bfd_vma)(LARGE_PLT_THRESHOLD + block*160) * PLT_ENTRY_SIZE
+ + ofs * 6*4);
+}
+
+static bfd_vma
+sparc64_elf_plt_ptr_offset (index, max)
+ int index, max;
+{
+ int block, ofs, last;
+
+ BFD_ASSERT(index >= LARGE_PLT_THRESHOLD);
+
+ /* See above for details. */
+
+ block = (index - LARGE_PLT_THRESHOLD) / 160;
+ ofs = (index - LARGE_PLT_THRESHOLD) % 160;
+ last = (max - LARGE_PLT_THRESHOLD) % 160;
+
+ return ((LARGE_PLT_THRESHOLD + block*160) * PLT_ENTRY_SIZE
+ + last * 6*4
+ + ofs * 8);
+}
+
+
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+sparc64_elf_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sgot;
+ asection *srelgot;
+ asection *sreloc;
+
+ if (info->relocateable || !(sec->flags & SEC_ALLOC))
+ return true;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_offsets = elf_local_got_offsets (abfd);
+
+ sgot = NULL;
+ srelgot = NULL;
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF64_R_TYPE (rel->r_info))
+ {
+ case R_SPARC_GOT10:
+ case R_SPARC_GOT13:
+ case R_SPARC_GOT22:
+ /* This symbol requires a global offset table entry. */
+
+ if (dynobj == NULL)
+ {
+ /* Create the .got section. */
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+ }
+
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (srelgot == NULL && (h != NULL || info->shared))
+ {
+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (srelgot == NULL)
+ {
+ srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, srelgot,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, srelgot, 3))
+ return false;
+ }
+ }
+
+ if (h != NULL)
+ {
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ h->got.offset = sgot->_raw_size;
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ srelgot->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ else
+ {
+ /* This is a global offset table entry for a local
+ symbol. */
+ if (local_got_offsets == NULL)
+ {
+ size_t size;
+ register unsigned int i;
+
+ size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
+ if (local_got_offsets == NULL)
+ return false;
+ elf_local_got_offsets (abfd) = local_got_offsets;
+ for (i = 0; i < symtab_hdr->sh_info; i++)
+ local_got_offsets[i] = (bfd_vma) -1;
+ }
+ if (local_got_offsets[r_symndx] != (bfd_vma) -1)
+ {
+ /* We have already allocated space in the .got. */
+ break;
+ }
+ local_got_offsets[r_symndx] = sgot->_raw_size;
+
+ if (info->shared)
+ {
+ /* If we are generating a shared object, we need to
+ output a R_SPARC_RELATIVE reloc so that the
+ dynamic linker can adjust this GOT entry. */
+ srelgot->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ }
+
+ sgot->_raw_size += 8;
+
+#if 0
+ /* Doesn't work for 64-bit -fPIC, since sethi/or builds
+ unsigned numbers. If we permit ourselves to modify
+ code so we get sethi/xor, this could work.
+ Question: do we consider conditionally re-enabling
+ this for -fpic, once we know about object code models? */
+ /* If the .got section is more than 0x1000 bytes, we add
+ 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13
+ bit relocations have a greater chance of working. */
+ if (sgot->_raw_size >= 0x1000
+ && elf_hash_table (info)->hgot->root.u.def.value == 0)
+ elf_hash_table (info)->hgot->root.u.def.value = 0x1000;
+#endif
+
+ break;
+
+ case R_SPARC_WPLT30:
+ case R_SPARC_PLT32:
+ case R_SPARC_HIPLT22:
+ case R_SPARC_LOPLT10:
+ case R_SPARC_PCPLT32:
+ case R_SPARC_PCPLT22:
+ case R_SPARC_PCPLT10:
+ case R_SPARC_PLT64:
+ /* This symbol requires a procedure linkage table entry. We
+ actually build the entry in adjust_dynamic_symbol,
+ because this might be a case of linking PIC code without
+ linking in any dynamic objects, in which case we don't
+ need to generate a procedure linkage table after all. */
+
+ if (h == NULL)
+ {
+ /* It does not make sense to have a procedure linkage
+ table entry for a local symbol. */
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ break;
+
+ case R_SPARC_PC10:
+ case R_SPARC_PC22:
+ case R_SPARC_PC_HH22:
+ case R_SPARC_PC_HM10:
+ case R_SPARC_PC_LM22:
+ if (h != NULL
+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ break;
+ /* Fall through. */
+ case R_SPARC_DISP8:
+ case R_SPARC_DISP16:
+ case R_SPARC_DISP32:
+ case R_SPARC_DISP64:
+ case R_SPARC_WDISP30:
+ case R_SPARC_WDISP22:
+ case R_SPARC_WDISP19:
+ case R_SPARC_WDISP16:
+ if (h == NULL)
+ break;
+ /* Fall through. */
+ case R_SPARC_8:
+ case R_SPARC_16:
+ case R_SPARC_32:
+ case R_SPARC_HI22:
+ case R_SPARC_22:
+ case R_SPARC_13:
+ case R_SPARC_LO10:
+ case R_SPARC_UA32:
+ case R_SPARC_10:
+ case R_SPARC_11:
+ case R_SPARC_64:
+ case R_SPARC_OLO10:
+ case R_SPARC_HH22:
+ case R_SPARC_HM10:
+ case R_SPARC_LM22:
+ case R_SPARC_7:
+ case R_SPARC_5:
+ case R_SPARC_6:
+ case R_SPARC_HIX22:
+ case R_SPARC_LOX10:
+ case R_SPARC_H44:
+ case R_SPARC_M44:
+ case R_SPARC_L44:
+ case R_SPARC_UA64:
+ case R_SPARC_UA16:
+ /* When creating a shared object, we must copy these relocs
+ into the output file. We create a reloc section in
+ dynobj and make room for the reloc.
+
+ But don't do this for debugging sections -- this shows up
+ with DWARF2 -- first because they are not loaded, and
+ second because DWARF sez the debug info is not to be
+ biased by the load address. */
+ if (info->shared && (sec->flags & SEC_ALLOC))
+ {
+ if (sreloc == NULL)
+ {
+ const char *name;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 3))
+ return false;
+ }
+ }
+
+ sreloc->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ break;
+
+ case R_SPARC_REGISTER:
+ /* Nothing to do. */
+ break;
+
+ default:
+ (*_bfd_error_handler)(_("%s: check_relocs: unhandled reloc type %d"),
+ bfd_get_filename(abfd),
+ ELF64_R_TYPE (rel->r_info));
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+sparc64_elf_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ bfd *dynobj;
+ asection *s;
+ unsigned int power_of_two;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || h->weakdef != NULL
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+ /* If this is a function, put it in the procedure linkage table. We
+ will fill in the contents of the procedure linkage table later
+ (although we could actually do it here). The STT_NOTYPE
+ condition is a hack specifically for the Oracle libraries
+ delivered for Solaris; for some inexplicable reason, they define
+ some of their functions as STT_NOTYPE when they really should be
+ STT_FUNC. */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
+ || (h->type == STT_NOTYPE
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->flags & SEC_CODE) != 0))
+ {
+ if (! elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* This case can occur if we saw a WPLT30 reloc in an input
+ file, but none of the input files were dynamic objects.
+ In such a case, we don't actually need to build a
+ procedure linkage table, and we can just do a WDISP30
+ reloc instead. */
+ BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
+ return true;
+ }
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+
+ /* The first four bit in .plt is reserved. */
+ if (s->_raw_size == 0)
+ s->_raw_size = PLT_HEADER_SIZE;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+ }
+
+ /* To simplify matters later, just store the plt index here. */
+ h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE;
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .rela.plt section. */
+
+ s = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (s != NULL);
+
+ /* The first plt entries are reserved, and the relocations must
+ pair up exactly. */
+ if (s->_raw_size == 0)
+ s->_raw_size += (PLT_HEADER_SIZE/PLT_ENTRY_SIZE
+ * sizeof (Elf64_External_Rela));
+
+ s->_raw_size += sizeof (Elf64_External_Rela);
+
+ /* The procedure linkage table size is bounded by the magnitude
+ of the offset we can describe in the entry. */
+ if (s->_raw_size >= (bfd_vma)1 << 32)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ return true;
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ BFD_ASSERT (s != NULL);
+
+ /* We must generate a R_SPARC_COPY reloc to tell the dynamic linker
+ to copy the initial value out of the dynamic object and into the
+ runtime process image. We need to remember the offset into the
+ .rel.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ asection *srel;
+
+ srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+ BFD_ASSERT (srel != NULL);
+ srel->_raw_size += sizeof (Elf64_External_Rela);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. 16-bytes is the size
+ of the largest type that requires hard alignment -- long double. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 4)
+ power_of_two = 4;
+
+ /* Apply the required alignment. */
+ s->_raw_size = BFD_ALIGN (s->_raw_size,
+ (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ {
+ if (! bfd_set_section_alignment (dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+sparc64_elf_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *s;
+ boolean reltext;
+ boolean relplt;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+ else
+ {
+ /* We may have created entries in the .rela.got section.
+ However, if we are not creating the dynamic sections, we will
+ not actually use these entries. Reset the size of .rela.got,
+ which will cause it to get stripped from the output file
+ below. */
+ s = bfd_get_section_by_name (dynobj, ".rela.got");
+ if (s != NULL)
+ s->_raw_size = 0;
+ }
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ reltext = false;
+ relplt = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+ boolean strip;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ strip = false;
+
+ if (strncmp (name, ".rela", 5) == 0)
+ {
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is to handle .rela.bss and
+ .rel.plt. We must create it in
+ create_dynamic_sections, because it must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ strip = true;
+ }
+ else
+ {
+ const char *outname;
+ asection *target;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL entry. */
+ outname = bfd_get_section_name (output_bfd,
+ s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 5);
+ if (target != NULL
+ && (target->flags & SEC_READONLY) != 0)
+ reltext = true;
+
+ if (strcmp (name, ".rela.plt") == 0)
+ relplt = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ }
+ else if (strcmp (name, ".plt") != 0
+ && strncmp (name, ".got", 4) != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (strip)
+ {
+ _bfd_strip_section_from_output (s);
+ continue;
+ }
+
+ /* Allocate memory for the section contents. Zero the memory
+ for the benefit of .rela.plt, which has 4 unused entries
+ at the beginning, and we don't want garbage. */
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in sparc64_elf_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+ if (! info->shared)
+ {
+ if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ return false;
+ }
+
+ if (relplt)
+ {
+ if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_SPARC_PLTFMT,
+ (info->shared != 0) + 1))
+ return false;
+ }
+
+ if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
+ || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
+ sizeof (Elf64_External_Rela)))
+ return false;
+
+ if (reltext)
+ {
+ if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ return false;
+ }
+ }
+
+ /* If we are generating a shared library, we generate a section
+ symbol for each output section for which we might need to copy
+ relocs. These are local symbols, which means that they must come
+ first in the dynamic symbol table. That means we must increment
+ the dynamic symbol index of every other dynamic symbol. */
+ if (info->shared)
+ {
+ int c;
+
+ c = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) != 0
+ || (s->flags & SEC_ALLOC) == 0)
+ continue;
+
+ elf_section_data (s)->dynindx = c + 1;
+
+ /* These symbols will have no names, so we don't need to
+ fiddle with dynstr_index. */
+
+ ++c;
+ }
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ sparc64_elf_adjust_dynindx,
+ (PTR) &c);
+ elf_hash_table (info)->dynsymcount += c;
+ }
+
+ return true;
+}
+
+/* Increment the index of a dynamic symbol by a given amount. Called
+ via elf_link_hash_traverse. */
+
+static boolean
+sparc64_elf_adjust_dynindx (h, cparg)
+ struct elf_link_hash_entry *h;
+ PTR cparg;
+{
+ int *cp = (int *) cparg;
+
+ if (h->dynindx != -1)
+ h->dynindx += *cp;
+ return true;
+}
+
+
+/* Relocate a SPARC64 ELF section. */
+
+static boolean
+sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ bfd_vma got_base;
+ asection *sgot;
+ asection *splt;
+ asection *sreloc;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ if (elf_hash_table(info)->hgot == NULL)
+ got_base = 0;
+ else
+ got_base = elf_hash_table (info)->hgot->root.u.def.value;
+
+ sgot = splt = sreloc = NULL;
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ bfd_vma relocation;
+ bfd_reloc_status_type r;
+
+ r_type = ELF64_R_TYPE (rel->r_info);
+ if (r_type < 0 || r_type >= (int) R_SPARC_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ howto = sparc64_elf_howto_table + r_type;
+
+ r_symndx = ELF64_R_SYM (rel->r_info);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ rel->r_addend += sec->output_offset + sym->st_value;
+ }
+ }
+
+ continue;
+ }
+
+ /* This is a final link. */
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = (sec->output_section->vma
+ + sec->output_offset
+ + sym->st_value);
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ boolean skip_it = false;
+ sec = h->root.u.def.section;
+
+ switch (r_type)
+ {
+ case R_SPARC_WPLT30:
+ case R_SPARC_PLT32:
+ case R_SPARC_HIPLT22:
+ case R_SPARC_LOPLT10:
+ case R_SPARC_PCPLT32:
+ case R_SPARC_PCPLT22:
+ case R_SPARC_PCPLT10:
+ case R_SPARC_PLT64:
+ if (h->plt.offset != (bfd_vma) -1)
+ skip_it = true;
+ break;
+
+ case R_SPARC_GOT10:
+ case R_SPARC_GOT13:
+ case R_SPARC_GOT22:
+ if (elf_hash_table(info)->dynamic_sections_created
+ && (!info->shared
+ || (!info->symbolic && h->dynindx != -1)
+ || !(h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR)))
+ skip_it = true;
+ break;
+
+ case R_SPARC_PC10:
+ case R_SPARC_PC22:
+ case R_SPARC_PC_HH22:
+ case R_SPARC_PC_HM10:
+ case R_SPARC_PC_LM22:
+ if (!strcmp(h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
+ break;
+ /* FALLTHRU */
+
+ case R_SPARC_8:
+ case R_SPARC_16:
+ case R_SPARC_32:
+ case R_SPARC_DISP8:
+ case R_SPARC_DISP16:
+ case R_SPARC_DISP32:
+ case R_SPARC_WDISP30:
+ case R_SPARC_WDISP22:
+ case R_SPARC_HI22:
+ case R_SPARC_22:
+ case R_SPARC_13:
+ case R_SPARC_LO10:
+ case R_SPARC_UA32:
+ case R_SPARC_10:
+ case R_SPARC_11:
+ case R_SPARC_64:
+ case R_SPARC_OLO10:
+ case R_SPARC_HH22:
+ case R_SPARC_HM10:
+ case R_SPARC_LM22:
+ case R_SPARC_WDISP19:
+ case R_SPARC_WDISP16:
+ case R_SPARC_7:
+ case R_SPARC_5:
+ case R_SPARC_6:
+ case R_SPARC_DISP64:
+ case R_SPARC_HIX22:
+ case R_SPARC_LOX10:
+ case R_SPARC_H44:
+ case R_SPARC_M44:
+ case R_SPARC_L44:
+ case R_SPARC_UA64:
+ case R_SPARC_UA16:
+ if (info->shared
+ && ((!info->symbolic && h->dynindx != -1)
+ || !(h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR)))
+ skip_it = true;
+ break;
+ }
+
+ if (skip_it)
+ {
+ /* In these cases, we don't need the relocation
+ value. We check specially because in some
+ obscure cases sec->output_section will be NULL. */
+ relocation = 0;
+ }
+ else
+ {
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared && !info->symbolic && !info->no_undefined)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset)))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ /* When generating a shared object, these relocations are copied
+ into the output file to be resolved at run time. */
+ if (info->shared && (input_section->flags & SEC_ALLOC))
+ {
+ switch (r_type)
+ {
+ case R_SPARC_PC10:
+ case R_SPARC_PC22:
+ case R_SPARC_PC_HH22:
+ case R_SPARC_PC_HM10:
+ case R_SPARC_PC_LM22:
+ if (h != NULL
+ && !strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
+ break;
+ /* Fall through. */
+ case R_SPARC_DISP8:
+ case R_SPARC_DISP16:
+ case R_SPARC_DISP32:
+ case R_SPARC_WDISP30:
+ case R_SPARC_WDISP22:
+ case R_SPARC_WDISP19:
+ case R_SPARC_WDISP16:
+ case R_SPARC_DISP64:
+ if (h == NULL)
+ break;
+ /* Fall through. */
+ case R_SPARC_8:
+ case R_SPARC_16:
+ case R_SPARC_32:
+ case R_SPARC_HI22:
+ case R_SPARC_22:
+ case R_SPARC_13:
+ case R_SPARC_LO10:
+ case R_SPARC_UA32:
+ case R_SPARC_10:
+ case R_SPARC_11:
+ case R_SPARC_64:
+ case R_SPARC_OLO10:
+ case R_SPARC_HH22:
+ case R_SPARC_HM10:
+ case R_SPARC_LM22:
+ case R_SPARC_7:
+ case R_SPARC_5:
+ case R_SPARC_6:
+ case R_SPARC_HIX22:
+ case R_SPARC_LOX10:
+ case R_SPARC_H44:
+ case R_SPARC_M44:
+ case R_SPARC_L44:
+ case R_SPARC_UA64:
+ case R_SPARC_UA16:
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip;
+
+ if (sreloc == NULL)
+ {
+ const char *name =
+ (bfd_elf_string_from_elf_section
+ (input_bfd,
+ elf_elfheader (input_bfd)->e_shstrndx,
+ elf_section_data (input_section)->rel_hdr.sh_name));
+
+ if (name == NULL)
+ return false;
+
+ BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+ && strcmp (bfd_get_section_name(input_bfd,
+ input_section),
+ name + 5) == 0);
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ BFD_ASSERT (sreloc != NULL);
+ }
+
+ skip = false;
+
+ if (elf_section_data (input_section)->stab_info == NULL)
+ outrel.r_offset = rel->r_offset;
+ else
+ {
+ bfd_vma off;
+
+ off = (_bfd_stab_section_offset
+ (output_bfd, &elf_hash_table (info)->stab_info,
+ input_section,
+ &elf_section_data (input_section)->stab_info,
+ rel->r_offset));
+ if (off == MINUS_ONE)
+ skip = true;
+ outrel.r_offset = off;
+ }
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ /* Optimize unaligned reloc usage now that we know where
+ it finally resides. */
+ switch (r_type)
+ {
+ case R_SPARC_16:
+ if (outrel.r_offset & 1) r_type = R_SPARC_UA16;
+ break;
+ case R_SPARC_UA16:
+ if (!(outrel.r_offset & 1)) r_type = R_SPARC_16;
+ break;
+ case R_SPARC_32:
+ if (outrel.r_offset & 3) r_type = R_SPARC_UA32;
+ break;
+ case R_SPARC_UA32:
+ if (!(outrel.r_offset & 3)) r_type = R_SPARC_32;
+ break;
+ case R_SPARC_64:
+ if (outrel.r_offset & 7) r_type = R_SPARC_UA64;
+ break;
+ case R_SPARC_UA64:
+ if (!(outrel.r_offset & 7)) r_type = R_SPARC_64;
+ break;
+ }
+
+ if (skip)
+ memset (&outrel, 0, sizeof outrel);
+ /* h->dynindx may be -1 if the symbol was marked to
+ become local. */
+ else if (h != NULL
+ && ((! info->symbolic && h->dynindx != -1)
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ BFD_ASSERT (h->dynindx != -1);
+ outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
+ outrel.r_addend = rel->r_addend;
+ }
+ else
+ {
+ if (r_type == R_SPARC_64)
+ {
+ outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+ else
+ {
+ long indx;
+
+ if (h == NULL)
+ sec = local_sections[r_symndx];
+ else
+ {
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || (h->root.type
+ == bfd_link_hash_defweak));
+ sec = h->root.u.def.section;
+ }
+ if (sec != NULL && bfd_is_abs_section (sec))
+ indx = 0;
+ else if (sec == NULL || sec->owner == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else
+ {
+ asection *osec;
+
+ osec = sec->output_section;
+ indx = elf_section_data (osec)->dynindx;
+
+ /* FIXME: we really should be able to link non-pic
+ shared libraries. */
+ if (indx == 0)
+ {
+ BFD_FAIL ();
+ (*_bfd_error_handler)
+ (_("%s: probably compiled without -fPIC?"),
+ bfd_get_filename (input_bfd));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ outrel.r_info = ELF64_R_INFO (indx, r_type);
+
+ /* For non-RELATIVE dynamic relocations, we keep the
+ same symbol, and so generally the same addend. But
+ we do need to adjust those relocations referencing
+ sections. */
+ outrel.r_addend = rel->r_addend;
+ if (r_symndx < symtab_hdr->sh_info
+ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ outrel.r_addend += sec->output_offset+sym->st_value;
+ }
+ }
+
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ (((Elf64_External_Rela *)
+ sreloc->contents)
+ + sreloc->reloc_count));
+ ++sreloc->reloc_count;
+
+ /* This reloc will be computed at runtime, so there's no
+ need to do anything now, unless this is a RELATIVE
+ reloc in an unallocated section. */
+ if (skip
+ || (input_section->flags & SEC_ALLOC) != 0
+ || ELF64_R_TYPE (outrel.r_info) != R_SPARC_RELATIVE)
+ continue;
+ }
+ break;
+ }
+ }
+
+ switch (r_type)
+ {
+ case R_SPARC_GOT10:
+ case R_SPARC_GOT13:
+ case R_SPARC_GOT22:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ if (sgot == NULL)
+ {
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ }
+
+ if (h != NULL)
+ {
+ bfd_vma off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a -Bsymbolic
+ link and the symbol is defined locally, or the symbol
+ was forced to be local because of a version file. We
+ must initialize this entry in the global offset table.
+ Since the offset must always be a multiple of 8, we
+ use the least significant bit to record whether we
+ have initialized it already.
+
+ When doing a dynamic link, we create a .rela.got
+ relocation entry to initialize the value. This is
+ done in the finish_dynamic_symbol routine. */
+
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_64 (output_bfd, relocation,
+ sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+ relocation = sgot->output_offset + off - got_base;
+ }
+ else
+ {
+ bfd_vma off;
+
+ BFD_ASSERT (local_got_offsets != NULL);
+ off = local_got_offsets[r_symndx];
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ /* The offset must always be a multiple of 8. We use
+ the least significant bit to record whether we have
+ already processed this entry. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_64 (output_bfd, relocation, sgot->contents + off);
+ local_got_offsets[r_symndx] |= 1;
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+
+ /* We need to generate a R_SPARC_RELATIVE reloc
+ for the dynamic linker. */
+ srelgot = bfd_get_section_by_name(dynobj, ".rela.got");
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
+ outrel.r_addend = relocation;
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+ (((Elf64_External_Rela *)
+ srelgot->contents)
+ + srelgot->reloc_count));
+ ++srelgot->reloc_count;
+ }
+ }
+ relocation = sgot->output_offset + off - got_base;
+ }
+ goto do_default;
+
+ case R_SPARC_WPLT30:
+ case R_SPARC_PLT32:
+ case R_SPARC_HIPLT22:
+ case R_SPARC_LOPLT10:
+ case R_SPARC_PCPLT32:
+ case R_SPARC_PCPLT22:
+ case R_SPARC_PCPLT10:
+ case R_SPARC_PLT64:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+ BFD_ASSERT (h != NULL);
+
+ if (h->plt.offset == (bfd_vma) -1)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ goto do_default;
+ }
+
+ if (splt == NULL)
+ {
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL);
+ }
+
+ relocation = (splt->output_section->vma
+ + splt->output_offset
+ + sparc64_elf_plt_entry_offset (h->plt.offset));
+ goto do_default;
+
+ case R_SPARC_OLO10:
+ {
+ bfd_vma x;
+
+ relocation += rel->r_addend;
+ relocation = (relocation & 0x3ff) + ELF64_R_TYPE_DATA (rel->r_info);
+
+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ x = (x & ~0x1fff) | (relocation & 0x1fff);
+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
+
+ r = bfd_check_overflow (howto->complain_on_overflow,
+ howto->bitsize, howto->rightshift,
+ bfd_arch_bits_per_address (input_bfd),
+ relocation);
+ }
+ break;
+
+ case R_SPARC_WDISP16:
+ {
+ bfd_vma x;
+
+ relocation += rel->r_addend;
+ /* Adjust for pc-relative-ness. */
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ relocation -= rel->r_offset;
+
+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ x = (x & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
+ | ((relocation >> 2) & 0x3fff));
+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
+
+ r = bfd_check_overflow (howto->complain_on_overflow,
+ howto->bitsize, howto->rightshift,
+ bfd_arch_bits_per_address (input_bfd),
+ relocation);
+ }
+ break;
+
+ case R_SPARC_HIX22:
+ {
+ bfd_vma x;
+
+ relocation += rel->r_addend;
+ relocation = relocation ^ MINUS_ONE;
+
+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ x = (x & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
+
+ r = bfd_check_overflow (howto->complain_on_overflow,
+ howto->bitsize, howto->rightshift,
+ bfd_arch_bits_per_address (input_bfd),
+ relocation);
+ }
+ break;
+
+ case R_SPARC_LOX10:
+ {
+ bfd_vma x;
+
+ relocation += rel->r_addend;
+ relocation = (relocation & 0x3ff) | 0x1c00;
+
+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ x = (x & ~0x1fff) | relocation;
+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
+
+ r = bfd_reloc_ok;
+ }
+ break;
+
+ default:
+ do_default:
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+ break;
+ }
+
+ switch (r)
+ {
+ case bfd_reloc_ok:
+ break;
+
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+
+ if (h != NULL)
+ {
+ if (h->root.type == bfd_link_hash_undefweak
+ && howto->pc_relative)
+ {
+ /* Assume this is a call protected by other code that
+ detect the symbol is undefined. If this is the case,
+ we can safely ignore the overflow. If not, the
+ program is hosed anyway, and a little warning isn't
+ going to help. */
+ break;
+ }
+
+ name = h->root.root.string;
+ }
+ else
+ {
+ name = (bfd_elf_string_from_elf_section
+ (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name));
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset)))
+ return false;
+ }
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ bfd *dynobj;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ asection *splt;
+ asection *srela;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the PLT. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+ BFD_ASSERT (splt != NULL && srela != NULL);
+
+ /* Fill in the entry in the .rela.plt section. */
+
+ if (h->plt.offset < LARGE_PLT_THRESHOLD)
+ {
+ rela.r_offset = sparc64_elf_plt_entry_offset (h->plt.offset);
+ rela.r_addend = 0;
+ }
+ else
+ {
+ int max = splt->_raw_size / PLT_ENTRY_SIZE;
+ rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max);
+ rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4);
+ }
+ rela.r_offset += (splt->output_section->vma + splt->output_offset);
+ rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
+
+ bfd_elf64_swap_reloca_out (output_bfd, &rela,
+ ((Elf64_External_Rela *) srela->contents
+ + h->plt.offset));
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ the .plt section. Leave the value alone. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ asection *sgot;
+ asection *srela;
+ Elf_Internal_Rela rela;
+
+ /* This symbol has an entry in the GOT. Set it up. */
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srela = bfd_get_section_by_name (dynobj, ".rela.got");
+ BFD_ASSERT (sgot != NULL && srela != NULL);
+
+ rela.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + (h->got.offset &~ 1));
+
+ /* If this is a -Bsymbolic link, and the symbol is defined
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
+ if (info->shared
+ && (info->symbolic || h->dynindx == -1)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ {
+ asection *sec = h->root.u.def.section;
+ rela.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
+ rela.r_addend = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+ rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_GLOB_DAT);
+ rela.r_addend = 0;
+ }
+
+ bfd_elf64_swap_reloca_out (output_bfd, &rela,
+ ((Elf64_External_Rela *) srela->contents
+ + srela->reloc_count));
+ ++srela->reloc_count;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ asection *s;
+ Elf_Internal_Rela rela;
+
+ /* This symbols needs a copy reloc. Set it up. */
+
+ BFD_ASSERT (h->dynindx != -1);
+
+ s = bfd_get_section_by_name (h->root.u.def.section->owner,
+ ".rela.bss");
+ BFD_ASSERT (s != NULL);
+
+ rela.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_COPY);
+ rela.r_addend = 0;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela,
+ ((Elf64_External_Rela *) s->contents
+ + s->reloc_count));
+ ++s->reloc_count;
+ }
+
+ /* Mark some specially defined symbols as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
+ || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+sparc64_elf_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *sdyn;
+ asection *sgot;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ asection *splt;
+ Elf64_External_Dyn *dyncon, *dynconend;
+
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ boolean size;
+
+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ case DT_PLTGOT: name = ".plt"; size = false; break;
+ case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
+ case DT_JMPREL: name = ".rela.plt"; size = false; break;
+ default: name = NULL; size = false; break;
+ }
+
+ if (name != NULL)
+ {
+ asection *s;
+
+ s = bfd_get_section_by_name (output_bfd, name);
+ if (s == NULL)
+ dyn.d_un.d_val = 0;
+ else
+ {
+ if (! size)
+ dyn.d_un.d_ptr = s->vma;
+ else
+ {
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ }
+ }
+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
+ }
+ }
+
+ /* Initialize the contents of the .plt section. */
+ if (splt->_raw_size > 0)
+ {
+ sparc64_elf_build_plt(output_bfd, splt->contents,
+ splt->_raw_size / PLT_ENTRY_SIZE);
+ }
+
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize =
+ PLT_ENTRY_SIZE;
+ }
+
+ /* Set the first entry in the global offset table to the address of
+ the dynamic section. */
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ if (sgot->_raw_size > 0)
+ {
+ if (sdyn == NULL)
+ bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
+ else
+ bfd_put_64 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ sgot->contents);
+ }
+
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8;
+
+ if (info->shared)
+ {
+ asection *sdynsym;
+ asection *s;
+ Elf_Internal_Sym sym;
+ int c;
+
+ /* Set up the section symbols for the output sections. */
+
+ sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (sdynsym != NULL);
+
+ sym.st_size = 0;
+ sym.st_name = 0;
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ sym.st_other = 0;
+
+ c = 0;
+ for (s = output_bfd->sections; s != NULL; s = s->next)
+ {
+ int indx;
+
+ if (elf_section_data (s)->dynindx == 0)
+ continue;
+
+ sym.st_value = s->vma;
+
+ indx = elf_section_data (s)->this_idx;
+ BFD_ASSERT (indx > 0);
+ sym.st_shndx = indx;
+
+ bfd_elf64_swap_symbol_out (output_bfd, &sym,
+ (PTR) (((Elf64_External_Sym *)
+ sdynsym->contents)
+ + elf_section_data (s)->dynindx));
+
+ ++c;
+ }
+
+ /* Set the sh_info field of the output .dynsym section to the
+ index of the first global symbol. */
+ elf_section_data (sdynsym->output_section)->this_hdr.sh_info = c + 1;
+ }
+
+ return true;
+}
+
+/* Functions for dealing with the e_flags field. */
+
+/* Merge backend specific data from an object file to the output
+ object file when linking. */
+
+static boolean
+sparc64_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ boolean error;
+ flagword new_flags, old_flags;
+ int new_mm, old_mm;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ new_flags = elf_elfheader (ibfd)->e_flags;
+ old_flags = elf_elfheader (obfd)->e_flags;
+
+ if (!elf_flags_init (obfd)) /* First call, no flags set */
+ {
+ elf_flags_init (obfd) = true;
+ elf_elfheader (obfd)->e_flags = new_flags;
+ }
+
+ else if (new_flags == old_flags) /* Compatible flags are ok */
+ ;
+
+ else /* Incompatible flags */
+ {
+ error = false;
+
+ old_flags |= (new_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
+ new_flags |= (old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
+ if ((old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1)) ==
+ (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1))
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: linking UltraSPARC specific with HAL specific code"),
+ bfd_get_filename (ibfd));
+ }
+
+ /* Choose the most restrictive memory ordering */
+ old_mm = (old_flags & EF_SPARCV9_MM);
+ new_mm = (new_flags & EF_SPARCV9_MM);
+ old_flags &= ~EF_SPARCV9_MM;
+ new_flags &= ~EF_SPARCV9_MM;
+ if (new_mm < old_mm) old_mm = new_mm;
+ old_flags |= old_mm;
+ new_flags |= old_mm;
+
+ /* Warn about any other mismatches */
+ if (new_flags != old_flags)
+ {
+ error = true;
+ (*_bfd_error_handler)
+ (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
+ bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
+ }
+
+ elf_elfheader (obfd)->e_flags = old_flags;
+
+ if (error)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+ return true;
+}
+
+
+/* Set the right machine number for a SPARC64 ELF file. */
+
+static boolean
+sparc64_elf_object_p (abfd)
+ bfd *abfd;
+{
+ unsigned long mach = bfd_mach_sparc_v9;
+
+ if (elf_elfheader (abfd)->e_flags & EF_SPARC_SUN_US1)
+ mach = bfd_mach_sparc_v9a;
+ return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, mach);
+}
+
+#define TARGET_BIG_SYM bfd_elf64_sparc_vec
+#define TARGET_BIG_NAME "elf64-sparc"
+#define ELF_ARCH bfd_arch_sparc
+#define ELF_MAXPAGESIZE 0x100000
+
+/* This is the official ABI value. */
+#define ELF_MACHINE_CODE EM_SPARCV9
+
+/* This is the value that we used before the ABI was released. */
+#define ELF_MACHINE_ALT1 EM_OLD_SPARCV9
+
+#define elf_info_to_howto \
+ sparc64_elf_info_to_howto
+#define bfd_elf64_bfd_reloc_type_lookup \
+ sparc64_elf_reloc_type_lookup
+
+#define elf_backend_create_dynamic_sections \
+ _bfd_elf_create_dynamic_sections
+#define elf_backend_check_relocs \
+ sparc64_elf_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+ sparc64_elf_adjust_dynamic_symbol
+#define elf_backend_size_dynamic_sections \
+ sparc64_elf_size_dynamic_sections
+#define elf_backend_relocate_section \
+ sparc64_elf_relocate_section
+#define elf_backend_finish_dynamic_symbol \
+ sparc64_elf_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ sparc64_elf_finish_dynamic_sections
+
+#define bfd_elf64_bfd_merge_private_bfd_data \
+ sparc64_elf_merge_private_bfd_data
+
+#define elf_backend_object_p \
+ sparc64_elf_object_p
+
+#define elf_backend_want_got_plt 0
+#define elf_backend_plt_readonly 0
+#define elf_backend_want_plt_sym 1
+
+/* Section 5.2.4 of the ABI specifies a 256-byte boundary for the table. */
+#define elf_backend_plt_alignment 8
+
+#define elf_backend_got_header_size 8
+#define elf_backend_plt_header_size PLT_HEADER_SIZE
+
+#include "elf64-target.h"
diff --git a/bfd/elf64.c b/bfd/elf64.c
new file mode 100644
index 00000000000..69fb5b5e6e1
--- /dev/null
+++ b/bfd/elf64.c
@@ -0,0 +1,22 @@
+/* ELF 64-bit executable support for BFD.
+ Copyright 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 64
+
+#include "elfcode.h"
diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c
new file mode 100644
index 00000000000..5952e74e5ef
--- /dev/null
+++ b/bfd/elfarm-nabi.c
@@ -0,0 +1,670 @@
+/* 32-bit ELF support for ARM new abi option.
+ Copyright 1999 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "elf/arm.h"
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+#ifndef NUM_ELEM
+#define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0]))
+#endif
+
+#define USE_REL
+
+#define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec
+#define TARGET_LITTLE_NAME "elf32-littlearm"
+#define TARGET_BIG_SYM bfd_elf32_bigarm_vec
+#define TARGET_BIG_NAME "elf32-bigarm"
+
+#define elf_info_to_howto 0
+#define elf_info_to_howto_rel elf32_arm_info_to_howto_rel
+
+
+static reloc_howto_type * elf32_arm_reloc_type_lookup
+ PARAMS ((bfd * abfd, bfd_reloc_code_real_type code));
+
+static reloc_howto_type elf32_arm_howto_table[] =
+{
+ /* No relocation */
+ HOWTO (R_ARM_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_PC24, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 24, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_PC24", /* name */
+ false, /* partial_inplace */
+ 0x00ffffff, /* src_mask */
+ 0x00ffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 32 bit absolute */
+ HOWTO (R_ARM_ABS32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* standard 32bit pc-relative reloc */
+ HOWTO (R_ARM_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_REL32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit absolute */
+ HOWTO (R_ARM_PC13, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_PC13", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit absolute */
+ HOWTO (R_ARM_ABS16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 12 bit absolute */
+ HOWTO (R_ARM_ABS12, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS12", /* name */
+ false, /* partial_inplace */
+ 0x000008ff, /* src_mask */
+ 0x000008ff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_ABS5, /* type */
+ 6, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 5, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_ABS5", /* name */
+ false, /* partial_inplace */
+ 0x000007e0, /* src_mask */
+ 0x000007e0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 8 bit absolute */
+ HOWTO (R_ARM_ABS8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS8", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_SBREL32, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_SBREL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_PC22, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 23, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC22", /* name */
+ false, /* partial_inplace */
+ 0x07ff07ff, /* src_mask */
+ 0x07ff07ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_PC8, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC8", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_ARM_AMP_VCALL9, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_AMP_VCALL9", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_ARM_SWI24, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_SWI24", /* name */
+ false, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0x00000000, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_SWI8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_SWI8", /* name */
+ false, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0x00000000, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* These next two relocs are defined, but I do not know what they do. */
+
+ HOWTO (R_ARM_XPC25, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_XPC25", /* name */
+ false, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0x00000000, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_XPC22, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_XPC22", /* name */
+ false, /* partial_inplace */
+ 0x00000000, /* src_mask */
+ 0x00000000, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* These next three relocs are not defined, but we need to fill the space. */
+
+ HOWTO (R_ARM_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_unknown_17", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_unknown_18", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_unknown_19", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Relocs used in ARM Linux */
+
+ HOWTO (R_ARM_COPY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_COPY", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_GLOB_DAT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_GLOB_DAT", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_JUMP_SLOT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_JUMP_SLOT", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RELATIVE, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RELATIVE", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_GOTOFF, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_GOTOFF", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_GOTPC, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_GOTPC", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_ARM_GOT32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_GOT32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_PLT32, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_PLT32", /* name */
+ true, /* partial_inplace */
+ 0x00ffffff, /* src_mask */
+ 0x00ffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* End of relocs used in ARM Linux */
+
+ HOWTO (R_ARM_RREL32, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RREL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RABS32, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RABS32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RPC24, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RPC24", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RBASE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RBASE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+ /* GNU extension to record C++ vtable hierarchy */
+static reloc_howto_type elf32_arm_vtinherit_howto =
+ HOWTO (R_ARM_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_ARM_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false); /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+static reloc_howto_type elf32_arm_vtentry_howto =
+ HOWTO (R_ARM_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_ARM_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false); /* pcrel_offset */
+
+ /* 12 bit pc relative */
+static reloc_howto_type elf32_arm_thm_pc11_howto =
+ HOWTO (R_ARM_THM_PC11, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC11", /* name */
+ false, /* partial_inplace */
+ 0x000007ff, /* src_mask */
+ 0x000007ff, /* dst_mask */
+ true); /* pcrel_offset */
+
+ /* 12 bit pc relative */
+static reloc_howto_type elf32_arm_thm_pc9_howto =
+ HOWTO (R_ARM_THM_PC9, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC9", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ true); /* pcrel_offset */
+
+
+static void
+elf32_arm_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
+ bfd * abfd;
+ arelent * bfd_reloc;
+ Elf32_Internal_Rel * elf_reloc;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (elf_reloc->r_info);
+
+ switch (r_type)
+ {
+ case R_ARM_GNU_VTINHERIT:
+ bfd_reloc->howto = & elf32_arm_vtinherit_howto;
+ break;
+
+ case R_ARM_GNU_VTENTRY:
+ bfd_reloc->howto = & elf32_arm_vtentry_howto;
+ break;
+
+ case R_ARM_THM_PC11:
+ bfd_reloc->howto = & elf32_arm_thm_pc11_howto;
+ break;
+
+ case R_ARM_THM_PC9:
+ bfd_reloc->howto = & elf32_arm_thm_pc9_howto;
+ break;
+
+ default:
+ if (r_type >= NUM_ELEM (elf32_arm_howto_table))
+ bfd_reloc->howto = NULL;
+ else
+ bfd_reloc->howto = & elf32_arm_howto_table[r_type];
+ break;
+ }
+}
+
+struct elf32_arm_reloc_map
+ {
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+ };
+
+static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] =
+{
+ {BFD_RELOC_NONE, R_ARM_NONE},
+ {BFD_RELOC_ARM_PCREL_BRANCH, R_ARM_PC24},
+ {BFD_RELOC_32, R_ARM_ABS32},
+ {BFD_RELOC_32_PCREL, R_ARM_REL32},
+ {BFD_RELOC_8, R_ARM_ABS8},
+ {BFD_RELOC_16, R_ARM_ABS16},
+ {BFD_RELOC_ARM_OFFSET_IMM, R_ARM_ABS12},
+ {BFD_RELOC_ARM_THUMB_OFFSET, R_ARM_THM_ABS5},
+ {BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_PC22},
+ {BFD_RELOC_ARM_COPY, R_ARM_COPY},
+ {BFD_RELOC_ARM_GLOB_DAT, R_ARM_GLOB_DAT},
+ {BFD_RELOC_ARM_JUMP_SLOT, R_ARM_JUMP_SLOT},
+ {BFD_RELOC_ARM_RELATIVE, R_ARM_RELATIVE},
+ {BFD_RELOC_ARM_GOTOFF, R_ARM_GOTOFF},
+ {BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC},
+ {BFD_RELOC_ARM_GOT32, R_ARM_GOT32},
+ {BFD_RELOC_ARM_PLT32, R_ARM_PLT32}
+};
+
+static reloc_howto_type *
+elf32_arm_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ switch (code)
+ {
+ case BFD_RELOC_VTABLE_INHERIT:
+ return & elf32_arm_vtinherit_howto;
+
+ case BFD_RELOC_VTABLE_ENTRY:
+ return & elf32_arm_vtentry_howto;
+
+ case BFD_RELOC_THUMB_PCREL_BRANCH12:
+ return & elf32_arm_thm_pc11_howto;
+
+ case BFD_RELOC_THUMB_PCREL_BRANCH9:
+ return & elf32_arm_thm_pc9_howto;
+
+ default:
+ for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++)
+ if (elf32_arm_reloc_map[i].bfd_reloc_val == code)
+ return & elf32_arm_howto_table[elf32_arm_reloc_map[i].elf_reloc_val];
+
+ return NULL;
+ }
+}
+
+#include "elf32-arm.h"
diff --git a/bfd/elfarm-oabi.c b/bfd/elfarm-oabi.c
new file mode 100644
index 00000000000..f219b92ea7b
--- /dev/null
+++ b/bfd/elfarm-oabi.c
@@ -0,0 +1,381 @@
+/* 32-bit ELF support for ARM old abi option.
+ Copyright 1999 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "elf/arm-oabi.h"
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+#define USE_RELA
+
+#define TARGET_LITTLE_SYM bfd_elf32_littlearm_oabi_vec
+#define TARGET_LITTLE_NAME "elf32-littlearm-oabi"
+#define TARGET_BIG_SYM bfd_elf32_bigarm_oabi_vec
+#define TARGET_BIG_NAME "elf32-bigarm-oabi"
+
+#define elf_info_to_howto elf32_arm_info_to_howto
+#define elf_info_to_howto_rel 0
+
+static reloc_howto_type elf32_arm_howto_table[] =
+{
+ /* No relocation */
+ HOWTO (R_ARM_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_PC24, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 24, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_PC24", /* name */
+ false, /* partial_inplace */
+ 0x00ffffff, /* src_mask */
+ 0x00ffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 32 bit absolute */
+ HOWTO (R_ARM_ABS32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* standard 32bit pc-relative reloc */
+ HOWTO (R_ARM_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_REL32", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 8 bit absolute */
+ HOWTO (R_ARM_ABS8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS8", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 16 bit absolute */
+ HOWTO (R_ARM_ABS16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS16", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* 12 bit absolute */
+ HOWTO (R_ARM_ABS12, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 12, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_ABS12", /* name */
+ false, /* partial_inplace */
+ 0x000008ff, /* src_mask */
+ 0x000008ff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_ABS5, /* type */
+ 6, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 5, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_ABS5", /* name */
+ false, /* partial_inplace */
+ 0x000007e0, /* src_mask */
+ 0x000007e0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_THM_PC22, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 23, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC22", /* name */
+ false, /* partial_inplace */
+ 0x07ff07ff, /* src_mask */
+ 0x07ff07ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ HOWTO (R_ARM_SBREL32, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_SBREL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_AMP_VCALL9, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_AMP_VCALL9", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 12 bit pc relative */
+ HOWTO (R_ARM_THM_PC11, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC11", /* name */
+ false, /* partial_inplace */
+ 0x000007ff, /* src_mask */
+ 0x000007ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* 12 bit pc relative */
+ HOWTO (R_ARM_THM_PC9, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_THM_PC9", /* name */
+ false, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ true), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy */
+ HOWTO (R_ARM_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_ARM_GNU_VTINHERIT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_ARM_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_ARM_GNU_VTENTRY", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+
+ HOWTO (R_ARM_RREL32, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RREL32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RABS32, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RABS32", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RPC24, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RPC24", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (R_ARM_RBASE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_ARM_RBASE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+static void
+elf32_arm_info_to_howto (abfd, bfd_reloc, elf_reloc)
+ bfd *abfd;
+ arelent *bfd_reloc;
+ Elf32_Internal_Rela *elf_reloc;
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (elf_reloc->r_info);
+ /* fixme: need range test */
+ /* BFD_ASSERT (r_type < (unsigned int) R_ELF32_ARM_MAX); */
+ bfd_reloc->howto = &elf32_arm_howto_table[r_type];
+}
+
+struct elf32_arm_reloc_map
+ {
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+ };
+
+static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] =
+{
+ {BFD_RELOC_NONE, R_ARM_NONE,},
+ {BFD_RELOC_ARM_PCREL_BRANCH, R_ARM_PC24,},
+ {BFD_RELOC_32, R_ARM_ABS32,},
+ {BFD_RELOC_32_PCREL, R_ARM_REL32,},
+ {BFD_RELOC_8, R_ARM_ABS8,},
+ {BFD_RELOC_16, R_ARM_ABS16,},
+ {BFD_RELOC_ARM_OFFSET_IMM, R_ARM_ABS12,},
+ {BFD_RELOC_ARM_THUMB_OFFSET, R_ARM_THM_ABS5,},
+ {BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_PC22,},
+ {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT },
+ {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY },
+ {BFD_RELOC_NONE, R_ARM_SBREL32,},
+ {BFD_RELOC_NONE, R_ARM_AMP_VCALL9,},
+ {BFD_RELOC_THUMB_PCREL_BRANCH12, R_ARM_THM_PC11,},
+ {BFD_RELOC_THUMB_PCREL_BRANCH9, R_ARM_THM_PC9,}
+};
+
+static reloc_howto_type *
+elf32_arm_reloc_type_lookup (abfd, code)
+ bfd * abfd;
+ bfd_reloc_code_real_type code;
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (elf32_arm_reloc_map) / sizeof (struct elf32_arm_reloc_map);
+ i++)
+ {
+ if (elf32_arm_reloc_map[i].bfd_reloc_val == code)
+ return & elf32_arm_howto_table[elf32_arm_reloc_map[i].elf_reloc_val];
+ }
+
+ return NULL;
+}
+
+#define bfd_elf32_arm_allocate_interworking_sections \
+ bfd_elf32_arm_oabi_allocate_interworking_sections
+#define bfd_elf32_arm_get_bfd_for_interworking \
+ bfd_elf32_arm_oabi_get_bfd_for_interworking
+#define bfd_elf32_arm_process_before_allocation \
+ bfd_elf32_arm_oabi_process_before_allocation
+
+#include "elf32-arm.h"
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
new file mode 100644
index 00000000000..22f64886287
--- /dev/null
+++ b/bfd/elfcode.h
@@ -0,0 +1,1452 @@
+/* ELF executable support for BFD.
+ Copyright 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, from information published
+ in "UNIX System V Release 4, Programmers Guide: ANSI C and
+ Programming Support Tools". Sufficient support for gdb.
+
+ Rewritten by Mark Eichin @ Cygnus Support, from information
+ published in "System V Application Binary Interface", chapters 4
+ and 5, as well as the various "Processor Supplement" documents
+ derived from it. Added support for assembler and other object file
+ utilities. Further work done by Ken Raeburn (Cygnus Support), Michael
+ Meissner (Open Software Foundation), and Peter Hoogenboom (University
+ of Utah) to finish and extend this.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Problems and other issues to resolve.
+
+ (1) BFD expects there to be some fixed number of "sections" in
+ the object file. I.E. there is a "section_count" variable in the
+ bfd structure which contains the number of sections. However, ELF
+ supports multiple "views" of a file. In particular, with current
+ implementations, executable files typically have two tables, a
+ program header table and a section header table, both of which
+ partition the executable.
+
+ In ELF-speak, the "linking view" of the file uses the section header
+ table to access "sections" within the file, and the "execution view"
+ uses the program header table to access "segments" within the file.
+ "Segments" typically may contain all the data from one or more
+ "sections".
+
+ Note that the section header table is optional in ELF executables,
+ but it is this information that is most useful to gdb. If the
+ section header table is missing, then gdb should probably try
+ to make do with the program header table. (FIXME)
+
+ (2) The code in this file is compiled twice, once in 32-bit mode and
+ once in 64-bit mode. More of it should be made size-independent
+ and moved into elf.c.
+
+ (3) ELF section symbols are handled rather sloppily now. This should
+ be cleaned up, and ELF section symbols reconciled with BFD section
+ symbols.
+
+ (4) We need a published spec for 64-bit ELF. We've got some stuff here
+ that we're using for SPARC V9 64-bit chips, but don't assume that
+ it's cast in stone.
+ */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+/* Renaming structures, typedefs, macros and functions to be size-specific. */
+#define Elf_External_Ehdr NAME(Elf,External_Ehdr)
+#define Elf_External_Sym NAME(Elf,External_Sym)
+#define Elf_External_Shdr NAME(Elf,External_Shdr)
+#define Elf_External_Phdr NAME(Elf,External_Phdr)
+#define Elf_External_Rel NAME(Elf,External_Rel)
+#define Elf_External_Rela NAME(Elf,External_Rela)
+#define Elf_External_Dyn NAME(Elf,External_Dyn)
+
+#define elf_core_file_failing_command NAME(bfd_elf,core_file_failing_command)
+#define elf_core_file_failing_signal NAME(bfd_elf,core_file_failing_signal)
+#define elf_core_file_matches_executable_p \
+ NAME(bfd_elf,core_file_matches_executable_p)
+#define elf_object_p NAME(bfd_elf,object_p)
+#define elf_core_file_p NAME(bfd_elf,core_file_p)
+#define elf_get_symtab_upper_bound NAME(bfd_elf,get_symtab_upper_bound)
+#define elf_get_dynamic_symtab_upper_bound \
+ NAME(bfd_elf,get_dynamic_symtab_upper_bound)
+#define elf_swap_reloc_in NAME(bfd_elf,swap_reloc_in)
+#define elf_swap_reloca_in NAME(bfd_elf,swap_reloca_in)
+#define elf_swap_reloc_out NAME(bfd_elf,swap_reloc_out)
+#define elf_swap_reloca_out NAME(bfd_elf,swap_reloca_out)
+#define elf_swap_symbol_in NAME(bfd_elf,swap_symbol_in)
+#define elf_swap_symbol_out NAME(bfd_elf,swap_symbol_out)
+#define elf_swap_phdr_in NAME(bfd_elf,swap_phdr_in)
+#define elf_swap_phdr_out NAME(bfd_elf,swap_phdr_out)
+#define elf_swap_dyn_in NAME(bfd_elf,swap_dyn_in)
+#define elf_swap_dyn_out NAME(bfd_elf,swap_dyn_out)
+#define elf_get_reloc_upper_bound NAME(bfd_elf,get_reloc_upper_bound)
+#define elf_canonicalize_reloc NAME(bfd_elf,canonicalize_reloc)
+#define elf_slurp_symbol_table NAME(bfd_elf,slurp_symbol_table)
+#define elf_get_symtab NAME(bfd_elf,get_symtab)
+#define elf_canonicalize_dynamic_symtab \
+ NAME(bfd_elf,canonicalize_dynamic_symtab)
+#define elf_make_empty_symbol NAME(bfd_elf,make_empty_symbol)
+#define elf_get_symbol_info NAME(bfd_elf,get_symbol_info)
+#define elf_get_lineno NAME(bfd_elf,get_lineno)
+#define elf_set_arch_mach NAME(bfd_elf,set_arch_mach)
+#define elf_find_nearest_line NAME(bfd_elf,find_nearest_line)
+#define elf_sizeof_headers NAME(bfd_elf,sizeof_headers)
+#define elf_set_section_contents NAME(bfd_elf,set_section_contents)
+#define elf_no_info_to_howto NAME(bfd_elf,no_info_to_howto)
+#define elf_no_info_to_howto_rel NAME(bfd_elf,no_info_to_howto_rel)
+#define elf_find_section NAME(bfd_elf,find_section)
+#define elf_bfd_link_add_symbols NAME(bfd_elf,bfd_link_add_symbols)
+#define elf_add_dynamic_entry NAME(bfd_elf,add_dynamic_entry)
+#define elf_write_shdrs_and_ehdr NAME(bfd_elf,write_shdrs_and_ehdr)
+#define elf_write_out_phdrs NAME(bfd_elf,write_out_phdrs)
+#define elf_link_create_dynamic_sections \
+ NAME(bfd_elf,link_create_dynamic_sections)
+#define elf_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
+#define elf_bfd_final_link NAME(bfd_elf,bfd_final_link)
+#define elf_create_pointer_linker_section NAME(bfd_elf,create_pointer_linker_section)
+#define elf_finish_pointer_linker_section NAME(bfd_elf,finish_pointer_linker_section)
+#define elf_gc_sections NAME(_bfd_elf,gc_sections)
+#define elf_gc_common_finalize_got_offsets \
+ NAME(_bfd_elf,gc_common_finalize_got_offsets)
+#define elf_gc_common_final_link NAME(_bfd_elf,gc_common_final_link)
+#define elf_gc_record_vtinherit NAME(_bfd_elf,gc_record_vtinherit)
+#define elf_gc_record_vtentry NAME(_bfd_elf,gc_record_vtentry)
+
+#if ARCH_SIZE == 64
+#define ELF_R_INFO(X,Y) ELF64_R_INFO(X,Y)
+#define ELF_R_SYM(X) ELF64_R_SYM(X)
+#define ELF_R_TYPE(X) ELF64_R_TYPE(X)
+#define ELFCLASS ELFCLASS64
+#define FILE_ALIGN 8
+#define LOG_FILE_ALIGN 3
+#endif
+#if ARCH_SIZE == 32
+#define ELF_R_INFO(X,Y) ELF32_R_INFO(X,Y)
+#define ELF_R_SYM(X) ELF32_R_SYM(X)
+#define ELF_R_TYPE(X) ELF32_R_TYPE(X)
+#define ELFCLASS ELFCLASS32
+#define FILE_ALIGN 4
+#define LOG_FILE_ALIGN 2
+#endif
+
+/* Static functions */
+
+static void elf_swap_ehdr_in
+ PARAMS ((bfd *, const Elf_External_Ehdr *, Elf_Internal_Ehdr *));
+static void elf_swap_ehdr_out
+ PARAMS ((bfd *, const Elf_Internal_Ehdr *, Elf_External_Ehdr *));
+static void elf_swap_shdr_in
+ PARAMS ((bfd *, const Elf_External_Shdr *, Elf_Internal_Shdr *));
+static void elf_swap_shdr_out
+ PARAMS ((bfd *, const Elf_Internal_Shdr *, Elf_External_Shdr *));
+
+#define elf_stringtab_init _bfd_elf_stringtab_init
+
+#define section_from_elf_index bfd_section_from_elf_index
+
+static boolean elf_slurp_reloc_table
+ PARAMS ((bfd *, asection *, asymbol **, boolean));
+
+static void write_relocs PARAMS ((bfd *, asection *, PTR));
+
+static boolean elf_file_p PARAMS ((Elf_External_Ehdr *));
+
+#ifdef DEBUG
+static void elf_debug_section PARAMS ((int, Elf_Internal_Shdr *));
+static void elf_debug_file PARAMS ((Elf_Internal_Ehdr *));
+static char *elf_symbol_flags PARAMS ((flagword));
+#endif
+
+/* Structure swapping routines */
+
+/* Should perhaps use put_offset, put_word, etc. For now, the two versions
+ can be handled by explicitly specifying 32 bits or "the long type". */
+#if ARCH_SIZE == 64
+#define put_word bfd_h_put_64
+#define put_signed_word bfd_h_put_signed_64
+#define get_word bfd_h_get_64
+#define get_signed_word bfd_h_get_signed_64
+#endif
+#if ARCH_SIZE == 32
+#define put_word bfd_h_put_32
+#define put_signed_word bfd_h_put_signed_32
+#define get_word bfd_h_get_32
+#define get_signed_word bfd_h_get_signed_32
+#endif
+
+/* Translate an ELF symbol in external format into an ELF symbol in internal
+ format. */
+
+void
+elf_swap_symbol_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Sym *src;
+ Elf_Internal_Sym *dst;
+{
+ dst->st_name = bfd_h_get_32 (abfd, (bfd_byte *) src->st_name);
+ dst->st_value = get_word (abfd, (bfd_byte *) src->st_value);
+ dst->st_size = get_word (abfd, (bfd_byte *) src->st_size);
+ dst->st_info = bfd_h_get_8 (abfd, (bfd_byte *) src->st_info);
+ dst->st_other = bfd_h_get_8 (abfd, (bfd_byte *) src->st_other);
+ dst->st_shndx = bfd_h_get_16 (abfd, (bfd_byte *) src->st_shndx);
+}
+
+/* Translate an ELF symbol in internal format into an ELF symbol in external
+ format. */
+
+void
+elf_swap_symbol_out (abfd, src, cdst)
+ bfd *abfd;
+ const Elf_Internal_Sym *src;
+ PTR cdst;
+{
+ Elf_External_Sym *dst = (Elf_External_Sym *) cdst;
+ bfd_h_put_32 (abfd, src->st_name, dst->st_name);
+ put_word (abfd, src->st_value, dst->st_value);
+ put_word (abfd, src->st_size, dst->st_size);
+ bfd_h_put_8 (abfd, src->st_info, dst->st_info);
+ bfd_h_put_8 (abfd, src->st_other, dst->st_other);
+ bfd_h_put_16 (abfd, src->st_shndx, dst->st_shndx);
+}
+
+
+/* Translate an ELF file header in external format into an ELF file header in
+ internal format. */
+
+static void
+elf_swap_ehdr_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Ehdr *src;
+ Elf_Internal_Ehdr *dst;
+{
+ memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
+ dst->e_type = bfd_h_get_16 (abfd, (bfd_byte *) src->e_type);
+ dst->e_machine = bfd_h_get_16 (abfd, (bfd_byte *) src->e_machine);
+ dst->e_version = bfd_h_get_32 (abfd, (bfd_byte *) src->e_version);
+ dst->e_entry = get_word (abfd, (bfd_byte *) src->e_entry);
+ dst->e_phoff = get_word (abfd, (bfd_byte *) src->e_phoff);
+ dst->e_shoff = get_word (abfd, (bfd_byte *) src->e_shoff);
+ dst->e_flags = bfd_h_get_32 (abfd, (bfd_byte *) src->e_flags);
+ dst->e_ehsize = bfd_h_get_16 (abfd, (bfd_byte *) src->e_ehsize);
+ dst->e_phentsize = bfd_h_get_16 (abfd, (bfd_byte *) src->e_phentsize);
+ dst->e_phnum = bfd_h_get_16 (abfd, (bfd_byte *) src->e_phnum);
+ dst->e_shentsize = bfd_h_get_16 (abfd, (bfd_byte *) src->e_shentsize);
+ dst->e_shnum = bfd_h_get_16 (abfd, (bfd_byte *) src->e_shnum);
+ dst->e_shstrndx = bfd_h_get_16 (abfd, (bfd_byte *) src->e_shstrndx);
+}
+
+/* Translate an ELF file header in internal format into an ELF file header in
+ external format. */
+
+static void
+elf_swap_ehdr_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Ehdr *src;
+ Elf_External_Ehdr *dst;
+{
+ memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
+ /* note that all elements of dst are *arrays of unsigned char* already... */
+ bfd_h_put_16 (abfd, src->e_type, dst->e_type);
+ bfd_h_put_16 (abfd, src->e_machine, dst->e_machine);
+ bfd_h_put_32 (abfd, src->e_version, dst->e_version);
+ put_word (abfd, src->e_entry, dst->e_entry);
+ put_word (abfd, src->e_phoff, dst->e_phoff);
+ put_word (abfd, src->e_shoff, dst->e_shoff);
+ bfd_h_put_32 (abfd, src->e_flags, dst->e_flags);
+ bfd_h_put_16 (abfd, src->e_ehsize, dst->e_ehsize);
+ bfd_h_put_16 (abfd, src->e_phentsize, dst->e_phentsize);
+ bfd_h_put_16 (abfd, src->e_phnum, dst->e_phnum);
+ bfd_h_put_16 (abfd, src->e_shentsize, dst->e_shentsize);
+ bfd_h_put_16 (abfd, src->e_shnum, dst->e_shnum);
+ bfd_h_put_16 (abfd, src->e_shstrndx, dst->e_shstrndx);
+}
+
+
+/* Translate an ELF section header table entry in external format into an
+ ELF section header table entry in internal format. */
+
+static void
+elf_swap_shdr_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Shdr *src;
+ Elf_Internal_Shdr *dst;
+{
+ dst->sh_name = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_name);
+ dst->sh_type = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_type);
+ dst->sh_flags = get_word (abfd, (bfd_byte *) src->sh_flags);
+ dst->sh_addr = get_word (abfd, (bfd_byte *) src->sh_addr);
+ dst->sh_offset = get_word (abfd, (bfd_byte *) src->sh_offset);
+ dst->sh_size = get_word (abfd, (bfd_byte *) src->sh_size);
+ dst->sh_link = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_link);
+ dst->sh_info = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_info);
+ dst->sh_addralign = get_word (abfd, (bfd_byte *) src->sh_addralign);
+ dst->sh_entsize = get_word (abfd, (bfd_byte *) src->sh_entsize);
+ dst->bfd_section = NULL;
+ dst->contents = NULL;
+}
+
+/* Translate an ELF section header table entry in internal format into an
+ ELF section header table entry in external format. */
+
+static void
+elf_swap_shdr_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Shdr *src;
+ Elf_External_Shdr *dst;
+{
+ /* note that all elements of dst are *arrays of unsigned char* already... */
+ bfd_h_put_32 (abfd, src->sh_name, dst->sh_name);
+ bfd_h_put_32 (abfd, src->sh_type, dst->sh_type);
+ put_word (abfd, src->sh_flags, dst->sh_flags);
+ put_word (abfd, src->sh_addr, dst->sh_addr);
+ put_word (abfd, src->sh_offset, dst->sh_offset);
+ put_word (abfd, src->sh_size, dst->sh_size);
+ bfd_h_put_32 (abfd, src->sh_link, dst->sh_link);
+ bfd_h_put_32 (abfd, src->sh_info, dst->sh_info);
+ put_word (abfd, src->sh_addralign, dst->sh_addralign);
+ put_word (abfd, src->sh_entsize, dst->sh_entsize);
+}
+
+
+/* Translate an ELF program header table entry in external format into an
+ ELF program header table entry in internal format. */
+
+void
+elf_swap_phdr_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Phdr *src;
+ Elf_Internal_Phdr *dst;
+{
+ dst->p_type = bfd_h_get_32 (abfd, (bfd_byte *) src->p_type);
+ dst->p_flags = bfd_h_get_32 (abfd, (bfd_byte *) src->p_flags);
+ dst->p_offset = get_word (abfd, (bfd_byte *) src->p_offset);
+ dst->p_vaddr = get_word (abfd, (bfd_byte *) src->p_vaddr);
+ dst->p_paddr = get_word (abfd, (bfd_byte *) src->p_paddr);
+ dst->p_filesz = get_word (abfd, (bfd_byte *) src->p_filesz);
+ dst->p_memsz = get_word (abfd, (bfd_byte *) src->p_memsz);
+ dst->p_align = get_word (abfd, (bfd_byte *) src->p_align);
+}
+
+void
+elf_swap_phdr_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Phdr *src;
+ Elf_External_Phdr *dst;
+{
+ /* note that all elements of dst are *arrays of unsigned char* already... */
+ bfd_h_put_32 (abfd, src->p_type, dst->p_type);
+ put_word (abfd, src->p_offset, dst->p_offset);
+ put_word (abfd, src->p_vaddr, dst->p_vaddr);
+ put_word (abfd, src->p_paddr, dst->p_paddr);
+ put_word (abfd, src->p_filesz, dst->p_filesz);
+ put_word (abfd, src->p_memsz, dst->p_memsz);
+ bfd_h_put_32 (abfd, src->p_flags, dst->p_flags);
+ put_word (abfd, src->p_align, dst->p_align);
+}
+
+/* Translate an ELF reloc from external format to internal format. */
+INLINE void
+elf_swap_reloc_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Rel *src;
+ Elf_Internal_Rel *dst;
+{
+ dst->r_offset = get_word (abfd, (bfd_byte *) src->r_offset);
+ dst->r_info = get_word (abfd, (bfd_byte *) src->r_info);
+}
+
+INLINE void
+elf_swap_reloca_in (abfd, src, dst)
+ bfd *abfd;
+ const Elf_External_Rela *src;
+ Elf_Internal_Rela *dst;
+{
+ dst->r_offset = get_word (abfd, (bfd_byte *) src->r_offset);
+ dst->r_info = get_word (abfd, (bfd_byte *) src->r_info);
+ dst->r_addend = get_signed_word (abfd, (bfd_byte *) src->r_addend);
+}
+
+/* Translate an ELF reloc from internal format to external format. */
+INLINE void
+elf_swap_reloc_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Rel *src;
+ Elf_External_Rel *dst;
+{
+ put_word (abfd, src->r_offset, dst->r_offset);
+ put_word (abfd, src->r_info, dst->r_info);
+}
+
+INLINE void
+elf_swap_reloca_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Rela *src;
+ Elf_External_Rela *dst;
+{
+ put_word (abfd, src->r_offset, dst->r_offset);
+ put_word (abfd, src->r_info, dst->r_info);
+ put_signed_word (abfd, src->r_addend, dst->r_addend);
+}
+
+INLINE void
+elf_swap_dyn_in (abfd, p, dst)
+ bfd *abfd;
+ const PTR p;
+ Elf_Internal_Dyn *dst;
+{
+ const Elf_External_Dyn *src = (const Elf_External_Dyn *) p;
+
+ dst->d_tag = get_word (abfd, src->d_tag);
+ dst->d_un.d_val = get_word (abfd, src->d_un.d_val);
+}
+
+INLINE void
+elf_swap_dyn_out (abfd, src, dst)
+ bfd *abfd;
+ const Elf_Internal_Dyn *src;
+ Elf_External_Dyn *dst;
+{
+ put_word (abfd, src->d_tag, dst->d_tag);
+ put_word (abfd, src->d_un.d_val, dst->d_un.d_val);
+}
+
+/* ELF .o/exec file reading */
+
+
+/* Begin processing a given object.
+
+ First we validate the file by reading in the ELF header and checking
+ the magic number. */
+
+static INLINE boolean
+elf_file_p (x_ehdrp)
+ Elf_External_Ehdr *x_ehdrp;
+{
+ return ((x_ehdrp->e_ident[EI_MAG0] == ELFMAG0)
+ && (x_ehdrp->e_ident[EI_MAG1] == ELFMAG1)
+ && (x_ehdrp->e_ident[EI_MAG2] == ELFMAG2)
+ && (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
+}
+
+/* Check to see if the file associated with ABFD matches the target vector
+ that ABFD points to.
+
+ Note that we may be called several times with the same ABFD, but different
+ target vectors, most of which will not match. We have to avoid leaving
+ any side effects in ABFD, or any data it points to (like tdata), if the
+ file does not match the target vector. */
+
+const bfd_target *
+elf_object_p (abfd)
+ bfd *abfd;
+{
+ Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
+ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
+ Elf_External_Shdr x_shdr; /* Section header table entry, external form */
+ Elf_Internal_Shdr *i_shdrp = NULL; /* Section header table, internal form */
+ unsigned int shindex;
+ char *shstrtab; /* Internal copy of section header stringtab */
+ struct elf_backend_data *ebd;
+ struct elf_obj_tdata *preserved_tdata = elf_tdata (abfd);
+ struct elf_obj_tdata *new_tdata = NULL;
+ asection *s;
+
+ /* Read in the ELF header in external format. */
+
+ if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ goto got_wrong_format_error;
+ else
+ goto got_no_match;
+ }
+
+ /* Now check to see if we have a valid ELF file, and one that BFD can
+ make use of. The magic number must match, the address size ('class')
+ and byte-swapping must match our XVEC entry, and it must have a
+ section header table (FIXME: See comments re sections at top of this
+ file). */
+
+ if ((elf_file_p (&x_ehdr) == false) ||
+ (x_ehdr.e_ident[EI_VERSION] != EV_CURRENT) ||
+ (x_ehdr.e_ident[EI_CLASS] != ELFCLASS))
+ goto got_wrong_format_error;
+
+ /* Check that file's byte order matches xvec's */
+ switch (x_ehdr.e_ident[EI_DATA])
+ {
+ case ELFDATA2MSB: /* Big-endian */
+ if (! bfd_header_big_endian (abfd))
+ goto got_wrong_format_error;
+ break;
+ case ELFDATA2LSB: /* Little-endian */
+ if (! bfd_header_little_endian (abfd))
+ goto got_wrong_format_error;
+ break;
+ case ELFDATANONE: /* No data encoding specified */
+ default: /* Unknown data encoding specified */
+ goto got_wrong_format_error;
+ }
+
+ /* Allocate an instance of the elf_obj_tdata structure and hook it up to
+ the tdata pointer in the bfd. */
+
+ new_tdata = ((struct elf_obj_tdata *)
+ bfd_zalloc (abfd, sizeof (struct elf_obj_tdata)));
+ if (new_tdata == NULL)
+ goto got_no_match;
+ elf_tdata (abfd) = new_tdata;
+
+ /* Now that we know the byte order, swap in the rest of the header */
+ i_ehdrp = elf_elfheader (abfd);
+ elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
+#if DEBUG & 1
+ elf_debug_file (i_ehdrp);
+#endif
+
+ /* Reject ET_CORE (header indicates core file, not object file) */
+ if (i_ehdrp->e_type == ET_CORE)
+ goto got_wrong_format_error;
+
+ /* If there is no section header table, we're hosed. */
+ if (i_ehdrp->e_shoff == 0)
+ goto got_wrong_format_error;
+
+ /* As a simple sanity check, verify that the what BFD thinks is the
+ size of each section header table entry actually matches the size
+ recorded in the file. */
+ if (i_ehdrp->e_shentsize != sizeof (x_shdr))
+ goto got_wrong_format_error;
+
+ ebd = get_elf_backend_data (abfd);
+
+ /* Check that the ELF e_machine field matches what this particular
+ BFD format expects. */
+ if (ebd->elf_machine_code != i_ehdrp->e_machine
+ && (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
+ && (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
+ {
+ const bfd_target * const *target_ptr;
+
+ if (ebd->elf_machine_code != EM_NONE)
+ goto got_wrong_format_error;
+
+ /* This is the generic ELF target. Let it match any ELF target
+ for which we do not have a specific backend. */
+ for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
+ {
+ struct elf_backend_data *back;
+
+ if ((*target_ptr)->flavour != bfd_target_elf_flavour)
+ continue;
+ back = (struct elf_backend_data *) (*target_ptr)->backend_data;
+ if (back->elf_machine_code == i_ehdrp->e_machine
+ || (back->elf_machine_alt1 != 0
+ && back->elf_machine_alt1 == i_ehdrp->e_machine)
+ || (back->elf_machine_alt2 != 0
+ && back->elf_machine_alt2 == i_ehdrp->e_machine))
+ {
+ /* target_ptr is an ELF backend which matches this
+ object file, so reject the generic ELF target. */
+ goto got_wrong_format_error;
+ }
+ }
+ }
+
+ if (i_ehdrp->e_type == ET_EXEC)
+ abfd->flags |= EXEC_P;
+ else if (i_ehdrp->e_type == ET_DYN)
+ abfd->flags |= DYNAMIC;
+
+ if (i_ehdrp->e_phnum > 0)
+ abfd->flags |= D_PAGED;
+
+ if (! bfd_default_set_arch_mach (abfd, ebd->arch, 0))
+ {
+ /* It's OK if this fails for the generic target. */
+ if (ebd->elf_machine_code != EM_NONE)
+ goto got_no_match;
+ }
+
+ /* Remember the entry point specified in the ELF file header. */
+ bfd_get_start_address (abfd) = i_ehdrp->e_entry;
+
+ /* Allocate space for a copy of the section header table in
+ internal form, seek to the section header table in the file,
+ read it in, and convert it to internal form. */
+ i_shdrp = ((Elf_Internal_Shdr *)
+ bfd_alloc (abfd, sizeof (*i_shdrp) * i_ehdrp->e_shnum));
+ elf_elfsections (abfd) = ((Elf_Internal_Shdr **)
+ bfd_alloc (abfd,
+ sizeof (i_shdrp) * i_ehdrp->e_shnum));
+ if (!i_shdrp || !elf_elfsections (abfd))
+ goto got_no_match;
+ if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) != 0)
+ goto got_no_match;
+ for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
+ {
+ if (bfd_read ((PTR) & x_shdr, sizeof x_shdr, 1, abfd) != sizeof (x_shdr))
+ goto got_no_match;
+ elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
+ elf_elfsections (abfd)[shindex] = i_shdrp + shindex;
+
+ /* If the section is loaded, but not page aligned, clear
+ D_PAGED. */
+ if ((i_shdrp[shindex].sh_flags & SHF_ALLOC) != 0
+ && i_shdrp[shindex].sh_type != SHT_NOBITS
+ && (((i_shdrp[shindex].sh_addr - i_shdrp[shindex].sh_offset)
+ % ebd->maxpagesize)
+ != 0))
+ abfd->flags &= ~D_PAGED;
+ }
+ if (i_ehdrp->e_shstrndx)
+ {
+ if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
+ goto got_no_match;
+ }
+
+ /* Read in the program headers. */
+ if (i_ehdrp->e_phnum == 0)
+ elf_tdata (abfd)->phdr = NULL;
+ else
+ {
+ Elf_Internal_Phdr *i_phdr;
+ unsigned int i;
+
+ elf_tdata (abfd)->phdr = ((Elf_Internal_Phdr *)
+ bfd_alloc (abfd,
+ (i_ehdrp->e_phnum
+ * sizeof (Elf_Internal_Phdr))));
+ if (elf_tdata (abfd)->phdr == NULL)
+ goto got_no_match;
+ if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
+ goto got_no_match;
+ i_phdr = elf_tdata (abfd)->phdr;
+ for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
+ {
+ Elf_External_Phdr x_phdr;
+
+ if (bfd_read ((PTR) &x_phdr, sizeof x_phdr, 1, abfd)
+ != sizeof x_phdr)
+ goto got_no_match;
+ elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
+ }
+ }
+
+ /* Read in the string table containing the names of the sections. We
+ will need the base pointer to this table later. */
+ /* We read this inline now, so that we don't have to go through
+ bfd_section_from_shdr with it (since this particular strtab is
+ used to find all of the ELF section names.) */
+
+ shstrtab = bfd_elf_get_str_section (abfd, i_ehdrp->e_shstrndx);
+ if (!shstrtab)
+ goto got_no_match;
+
+ /* Once all of the section headers have been read and converted, we
+ can start processing them. Note that the first section header is
+ a dummy placeholder entry, so we ignore it. */
+
+ for (shindex = 1; shindex < i_ehdrp->e_shnum; shindex++)
+ {
+ if (! bfd_section_from_shdr (abfd, shindex))
+ goto got_no_match;
+ }
+
+ /* Let the backend double check the format and override global
+ information. */
+ if (ebd->elf_backend_object_p)
+ {
+ if ((*ebd->elf_backend_object_p) (abfd) == false)
+ goto got_wrong_format_error;
+ }
+
+ /* If we have created any reloc sections that are associated with
+ debugging sections, mark the reloc sections as debugging as well. */
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if ((elf_section_data (s)->this_hdr.sh_type == SHT_REL
+ || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)
+ && elf_section_data (s)->this_hdr.sh_info > 0)
+ {
+ unsigned long targ_index;
+ asection *targ_sec;
+
+ targ_index = elf_section_data (s)->this_hdr.sh_info;
+ targ_sec = bfd_section_from_elf_index (abfd, targ_index);
+ if (targ_sec != NULL
+ && (targ_sec->flags & SEC_DEBUGGING) != 0)
+ s->flags |= SEC_DEBUGGING;
+ }
+ }
+
+ return (abfd->xvec);
+
+ got_wrong_format_error:
+ bfd_set_error (bfd_error_wrong_format);
+ got_no_match:
+ if (new_tdata != NULL
+ && new_tdata->elf_sect_ptr != NULL)
+ bfd_release (abfd, new_tdata->elf_sect_ptr);
+ if (i_shdrp != NULL)
+ bfd_release (abfd, i_shdrp);
+ if (new_tdata != NULL)
+ bfd_release (abfd, new_tdata);
+ elf_tdata (abfd) = preserved_tdata;
+ return (NULL);
+}
+
+/* ELF .o/exec file writing */
+
+/* Write out the relocs. */
+
+static void
+write_relocs (abfd, sec, data)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+{
+ boolean *failedp = (boolean *) data;
+ Elf_Internal_Shdr *rela_hdr;
+ Elf_External_Rela *outbound_relocas;
+ Elf_External_Rel *outbound_relocs;
+ unsigned int idx;
+ int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
+ asymbol *last_sym = 0;
+ int last_sym_idx = 0;
+
+ /* If we have already failed, don't do anything. */
+ if (*failedp)
+ return;
+
+ if ((sec->flags & SEC_RELOC) == 0)
+ return;
+
+ /* The linker backend writes the relocs out itself, and sets the
+ reloc_count field to zero to inhibit writing them here. Also,
+ sometimes the SEC_RELOC flag gets set even when there aren't any
+ relocs. */
+ if (sec->reloc_count == 0)
+ return;
+
+ rela_hdr = &elf_section_data (sec)->rel_hdr;
+
+ rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count;
+ rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
+ if (rela_hdr->contents == NULL)
+ {
+ *failedp = true;
+ return;
+ }
+
+ /* orelocation has the data, reloc_count has the count... */
+ if (use_rela_p)
+ {
+ outbound_relocas = (Elf_External_Rela *) rela_hdr->contents;
+
+ for (idx = 0; idx < sec->reloc_count; idx++)
+ {
+ Elf_Internal_Rela dst_rela;
+ Elf_External_Rela *src_rela;
+ arelent *ptr;
+ asymbol *sym;
+ int n;
+
+ ptr = sec->orelocation[idx];
+ src_rela = outbound_relocas + idx;
+
+ /* The address of an ELF reloc is section relative for an object
+ file, and absolute for an executable file or shared library.
+ The address of a BFD reloc is always section relative. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ dst_rela.r_offset = ptr->address;
+ else
+ dst_rela.r_offset = ptr->address + sec->vma;
+
+ sym = *ptr->sym_ptr_ptr;
+ if (sym == last_sym)
+ n = last_sym_idx;
+ else if (bfd_is_abs_section (sym->section) && sym->value == 0)
+ n = STN_UNDEF;
+ else
+ {
+ last_sym = sym;
+ n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
+ if (n < 0)
+ {
+ *failedp = true;
+ return;
+ }
+ last_sym_idx = n;
+ }
+
+ if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
+ && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
+ && ! _bfd_elf_validate_reloc (abfd, ptr))
+ {
+ *failedp = true;
+ return;
+ }
+
+ dst_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
+
+ dst_rela.r_addend = ptr->addend;
+ elf_swap_reloca_out (abfd, &dst_rela, src_rela);
+ }
+ }
+ else
+ /* REL relocations */
+ {
+ outbound_relocs = (Elf_External_Rel *) rela_hdr->contents;
+
+ for (idx = 0; idx < sec->reloc_count; idx++)
+ {
+ Elf_Internal_Rel dst_rel;
+ Elf_External_Rel *src_rel;
+ arelent *ptr;
+ int n;
+ asymbol *sym;
+
+ ptr = sec->orelocation[idx];
+ sym = *ptr->sym_ptr_ptr;
+ src_rel = outbound_relocs + idx;
+
+ /* The address of an ELF reloc is section relative for an object
+ file, and absolute for an executable file or shared library.
+ The address of a BFD reloc is always section relative. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ dst_rel.r_offset = ptr->address;
+ else
+ dst_rel.r_offset = ptr->address + sec->vma;
+
+ if (sym == last_sym)
+ n = last_sym_idx;
+ else
+ {
+ last_sym = sym;
+ n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
+ if (n < 0)
+ {
+ *failedp = true;
+ return;
+ }
+ last_sym_idx = n;
+ }
+
+ if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
+ && ! _bfd_elf_validate_reloc (abfd, ptr))
+ {
+ *failedp = true;
+ return;
+ }
+
+ dst_rel.r_info = ELF_R_INFO (n, ptr->howto->type);
+
+ elf_swap_reloc_out (abfd, &dst_rel, src_rel);
+ }
+ }
+}
+
+/* Write out the program headers. */
+
+int
+elf_write_out_phdrs (abfd, phdr, count)
+ bfd *abfd;
+ const Elf_Internal_Phdr *phdr;
+ int count;
+{
+ while (count--)
+ {
+ Elf_External_Phdr extphdr;
+ elf_swap_phdr_out (abfd, phdr, &extphdr);
+ if (bfd_write (&extphdr, sizeof (Elf_External_Phdr), 1, abfd)
+ != sizeof (Elf_External_Phdr))
+ return -1;
+ phdr++;
+ }
+ return 0;
+}
+
+/* Write out the section headers and the ELF file header. */
+
+boolean
+elf_write_shdrs_and_ehdr (abfd)
+ bfd *abfd;
+{
+ Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
+ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
+ Elf_External_Shdr *x_shdrp; /* Section header table, external form */
+ Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
+ unsigned int count;
+
+ i_ehdrp = elf_elfheader (abfd);
+ i_shdrp = elf_elfsections (abfd);
+
+ /* swap the header before spitting it out... */
+
+#if DEBUG & 1
+ elf_debug_file (i_ehdrp);
+#endif
+ elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd)
+ != sizeof (x_ehdr)))
+ return false;
+
+ /* at this point we've concocted all the ELF sections... */
+ x_shdrp = (Elf_External_Shdr *)
+ bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
+ if (!x_shdrp)
+ return false;
+
+ for (count = 0; count < i_ehdrp->e_shnum; count++)
+ {
+#if DEBUG & 2
+ elf_debug_section (count, i_shdrp[count]);
+#endif
+ elf_swap_shdr_out (abfd, i_shdrp[count], x_shdrp + count);
+ }
+ if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0
+ || (bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd)
+ != sizeof (*x_shdrp) * i_ehdrp->e_shnum))
+ return false;
+
+ /* need to dump the string table too... */
+
+ return true;
+}
+
+long
+elf_slurp_symbol_table (abfd, symptrs, dynamic)
+ bfd *abfd;
+ asymbol **symptrs; /* Buffer for generated bfd symbols */
+ boolean dynamic;
+{
+ Elf_Internal_Shdr *hdr;
+ Elf_Internal_Shdr *verhdr;
+ unsigned long symcount; /* Number of external ELF symbols */
+ elf_symbol_type *sym; /* Pointer to current bfd symbol */
+ elf_symbol_type *symbase; /* Buffer for generated bfd symbols */
+ Elf_Internal_Sym i_sym;
+ Elf_External_Sym *x_symp = NULL;
+ Elf_External_Versym *x_versymp = NULL;
+
+ /* Read each raw ELF symbol, converting from external ELF form to
+ internal ELF form, and then 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 ELF symbols to canonical
+ symbols. We actually use all the ELF 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. */
+
+ if (! dynamic)
+ {
+ hdr = &elf_tdata (abfd)->symtab_hdr;
+ verhdr = NULL;
+ }
+ else
+ {
+ hdr = &elf_tdata (abfd)->dynsymtab_hdr;
+ if (elf_dynversym (abfd) == 0)
+ verhdr = NULL;
+ else
+ verhdr = &elf_tdata (abfd)->dynversym_hdr;
+ if ((elf_tdata (abfd)->dynverdef_section != 0
+ && elf_tdata (abfd)->verdef == NULL)
+ || (elf_tdata (abfd)->dynverref_section != 0
+ && elf_tdata (abfd)->verref == NULL))
+ {
+ if (! _bfd_elf_slurp_version_tables (abfd))
+ return -1;
+ }
+ }
+
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
+ return -1;
+
+ symcount = hdr->sh_size / sizeof (Elf_External_Sym);
+
+ if (symcount == 0)
+ sym = symbase = NULL;
+ else
+ {
+ unsigned long i;
+
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
+ return -1;
+
+ symbase = ((elf_symbol_type *)
+ bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
+ if (symbase == (elf_symbol_type *) NULL)
+ return -1;
+ sym = symbase;
+
+ /* Temporarily allocate room for the raw ELF symbols. */
+ x_symp = ((Elf_External_Sym *)
+ bfd_malloc (symcount * sizeof (Elf_External_Sym)));
+ if (x_symp == NULL && symcount != 0)
+ goto error_return;
+
+ if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
+ != symcount * sizeof (Elf_External_Sym))
+ goto error_return;
+
+ /* Read the raw ELF version symbol information. */
+
+ if (verhdr != NULL
+ && verhdr->sh_size / sizeof (Elf_External_Versym) != symcount)
+ {
+ (*_bfd_error_handler)
+ (_("%s: version count (%ld) does not match symbol count (%ld)"),
+ abfd->filename,
+ (long) (verhdr->sh_size / sizeof (Elf_External_Versym)),
+ symcount);
+
+ /* Slurp in the symbols without the version information,
+ since that is more helpful than just quitting. */
+ verhdr = NULL;
+ }
+
+ if (verhdr != NULL)
+ {
+ if (bfd_seek (abfd, verhdr->sh_offset, SEEK_SET) != 0)
+ goto error_return;
+
+ x_versymp = (Elf_External_Versym *) bfd_malloc (verhdr->sh_size);
+ if (x_versymp == NULL && verhdr->sh_size != 0)
+ goto error_return;
+
+ if (bfd_read ((PTR) x_versymp, 1, verhdr->sh_size, abfd)
+ != verhdr->sh_size)
+ goto error_return;
+ }
+
+ /* Skip first symbol, which is a null dummy. */
+ for (i = 1; i < symcount; i++)
+ {
+ elf_swap_symbol_in (abfd, x_symp + i, &i_sym);
+ memcpy (&sym->internal_elf_sym, &i_sym, sizeof (Elf_Internal_Sym));
+#ifdef ELF_KEEP_EXTSYM
+ memcpy (&sym->native_elf_sym, x_symp + i, sizeof (Elf_External_Sym));
+#endif
+ sym->symbol.the_bfd = abfd;
+
+ sym->symbol.name = bfd_elf_string_from_elf_section (abfd,
+ hdr->sh_link,
+ i_sym.st_name);
+
+ sym->symbol.value = i_sym.st_value;
+
+ if (i_sym.st_shndx > 0 && i_sym.st_shndx < SHN_LORESERVE)
+ {
+ sym->symbol.section = section_from_elf_index (abfd,
+ i_sym.st_shndx);
+ if (sym->symbol.section == NULL)
+ {
+ /* This symbol is in a section for which we did not
+ create a BFD section. Just use bfd_abs_section,
+ although it is wrong. FIXME. */
+ sym->symbol.section = bfd_abs_section_ptr;
+ }
+ }
+ else if (i_sym.st_shndx == SHN_ABS)
+ {
+ sym->symbol.section = bfd_abs_section_ptr;
+ }
+ else if (i_sym.st_shndx == SHN_COMMON)
+ {
+ sym->symbol.section = bfd_com_section_ptr;
+ /* Elf puts the alignment into the `value' field, and
+ the size into the `size' field. BFD wants to see the
+ size in the value field, and doesn't care (at the
+ moment) about the alignment. */
+ sym->symbol.value = i_sym.st_size;
+ }
+ else if (i_sym.st_shndx == SHN_UNDEF)
+ {
+ sym->symbol.section = bfd_und_section_ptr;
+ }
+ else
+ sym->symbol.section = bfd_abs_section_ptr;
+
+ /* If this is a relocateable file, then the symbol value is
+ already section relative. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
+ sym->symbol.value -= sym->symbol.section->vma;
+
+ switch (ELF_ST_BIND (i_sym.st_info))
+ {
+ case STB_LOCAL:
+ sym->symbol.flags |= BSF_LOCAL;
+ break;
+ case STB_GLOBAL:
+ if (i_sym.st_shndx != SHN_UNDEF
+ && i_sym.st_shndx != SHN_COMMON)
+ sym->symbol.flags |= BSF_GLOBAL;
+ break;
+ case STB_WEAK:
+ sym->symbol.flags |= BSF_WEAK;
+ break;
+ }
+
+ switch (ELF_ST_TYPE (i_sym.st_info))
+ {
+ case STT_SECTION:
+ sym->symbol.flags |= BSF_SECTION_SYM | BSF_DEBUGGING;
+ break;
+ case STT_FILE:
+ sym->symbol.flags |= BSF_FILE | BSF_DEBUGGING;
+ break;
+ case STT_FUNC:
+ sym->symbol.flags |= BSF_FUNCTION;
+ break;
+ case STT_OBJECT:
+ sym->symbol.flags |= BSF_OBJECT;
+ break;
+ }
+
+ if (dynamic)
+ sym->symbol.flags |= BSF_DYNAMIC;
+
+ if (x_versymp != NULL)
+ {
+ Elf_Internal_Versym iversym;
+
+ _bfd_elf_swap_versym_in (abfd, x_versymp + i, &iversym);
+ sym->version = iversym.vs_vers;
+ }
+
+ /* Do some backend-specific processing on this symbol. */
+ {
+ struct elf_backend_data *ebd = get_elf_backend_data (abfd);
+ if (ebd->elf_backend_symbol_processing)
+ (*ebd->elf_backend_symbol_processing) (abfd, &sym->symbol);
+ }
+
+ sym++;
+ }
+ }
+
+ /* Do some backend-specific processing on this symbol table. */
+ {
+ struct elf_backend_data *ebd = get_elf_backend_data (abfd);
+ if (ebd->elf_backend_symbol_table_processing)
+ (*ebd->elf_backend_symbol_table_processing) (abfd, symbase, symcount);
+ }
+
+ /* We rely on the zalloc to clear out the final symbol entry. */
+
+ symcount = sym - symbase;
+
+ /* Fill in the user's symbol pointer vector if needed. */
+ if (symptrs)
+ {
+ long l = symcount;
+
+ sym = symbase;
+ while (l-- > 0)
+ {
+ *symptrs++ = &sym->symbol;
+ sym++;
+ }
+ *symptrs = 0; /* Final null pointer */
+ }
+
+ if (x_versymp != NULL)
+ free (x_versymp);
+ if (x_symp != NULL)
+ free (x_symp);
+ return symcount;
+error_return:
+ if (x_versymp != NULL)
+ free (x_versymp);
+ if (x_symp != NULL)
+ free (x_symp);
+ return -1;
+}
+
+/* Read in and swap the external relocs. */
+
+static boolean
+elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
+ bfd *abfd;
+ asection *asect;
+ asymbol **symbols;
+ boolean dynamic;
+{
+ struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
+ struct bfd_elf_section_data * const d = elf_section_data (asect);
+ Elf_Internal_Shdr *rel_hdr;
+ bfd_size_type reloc_count;
+ PTR allocated = NULL;
+ bfd_byte *native_relocs;
+ arelent *relents;
+ arelent *relent;
+ unsigned int i;
+ int entsize;
+
+ if (asect->relocation != NULL)
+ return true;
+
+ if (! dynamic)
+ {
+ if ((asect->flags & SEC_RELOC) == 0
+ || asect->reloc_count == 0)
+ return true;
+
+ rel_hdr = &d->rel_hdr;
+ reloc_count = asect->reloc_count;
+
+ BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset
+ && reloc_count == rel_hdr->sh_size / rel_hdr->sh_entsize);
+ }
+ else
+ {
+ if (asect->_raw_size == 0)
+ return true;
+
+ rel_hdr = &d->this_hdr;
+ reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize;
+ }
+
+ allocated = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
+ if (allocated == NULL)
+ goto error_return;
+
+ if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (allocated, 1, rel_hdr->sh_size, abfd)
+ != rel_hdr->sh_size))
+ goto error_return;
+
+ native_relocs = (bfd_byte *) allocated;
+
+ relents = (arelent *) bfd_alloc (abfd, reloc_count * sizeof (arelent));
+ if (relents == NULL)
+ goto error_return;
+
+ entsize = rel_hdr->sh_entsize;
+ BFD_ASSERT (entsize == sizeof (Elf_External_Rel)
+ || entsize == sizeof (Elf_External_Rela));
+
+ for (i = 0, relent = relents;
+ i < reloc_count;
+ i++, relent++, native_relocs += entsize)
+ {
+ Elf_Internal_Rela rela;
+ Elf_Internal_Rel rel;
+
+ if (entsize == sizeof (Elf_External_Rela))
+ elf_swap_reloca_in (abfd, (Elf_External_Rela *) native_relocs, &rela);
+ else
+ {
+ elf_swap_reloc_in (abfd, (Elf_External_Rel *) native_relocs, &rel);
+ rela.r_offset = rel.r_offset;
+ rela.r_info = rel.r_info;
+ rela.r_addend = 0;
+ }
+
+ /* The address of an ELF reloc is section relative for an object
+ file, and absolute for an executable file or shared library.
+ The address of a normal BFD reloc is always section relative,
+ and the address of a dynamic reloc is absolute.. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 || dynamic)
+ relent->address = rela.r_offset;
+ else
+ relent->address = rela.r_offset - asect->vma;
+
+ if (ELF_R_SYM (rela.r_info) == 0)
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ else
+ {
+ asymbol **ps, *s;
+
+ ps = symbols + ELF_R_SYM (rela.r_info) - 1;
+ s = *ps;
+
+ /* Canonicalize ELF section symbols. FIXME: Why? */
+ if ((s->flags & BSF_SECTION_SYM) == 0)
+ relent->sym_ptr_ptr = ps;
+ else
+ relent->sym_ptr_ptr = s->section->symbol_ptr_ptr;
+ }
+
+ relent->addend = rela.r_addend;
+
+ if (entsize == sizeof (Elf_External_Rela))
+ (*ebd->elf_info_to_howto) (abfd, relent, &rela);
+ else
+ (*ebd->elf_info_to_howto_rel) (abfd, relent, &rel);
+ }
+
+ asect->relocation = relents;
+
+ if (allocated != NULL)
+ free (allocated);
+
+ return true;
+
+ error_return:
+ if (allocated != NULL)
+ free (allocated);
+ return false;
+}
+
+#ifdef DEBUG
+static void
+elf_debug_section (num, hdr)
+ int num;
+ Elf_Internal_Shdr *hdr;
+{
+ fprintf (stderr, "\nSection#%d '%s' 0x%.8lx\n", num,
+ hdr->bfd_section != NULL ? hdr->bfd_section->name : "",
+ (long) hdr);
+ fprintf (stderr,
+ "sh_name = %ld\tsh_type = %ld\tsh_flags = %ld\n",
+ (long) hdr->sh_name,
+ (long) hdr->sh_type,
+ (long) hdr->sh_flags);
+ fprintf (stderr,
+ "sh_addr = %ld\tsh_offset = %ld\tsh_size = %ld\n",
+ (long) hdr->sh_addr,
+ (long) hdr->sh_offset,
+ (long) hdr->sh_size);
+ fprintf (stderr,
+ "sh_link = %ld\tsh_info = %ld\tsh_addralign = %ld\n",
+ (long) hdr->sh_link,
+ (long) hdr->sh_info,
+ (long) hdr->sh_addralign);
+ fprintf (stderr, "sh_entsize = %ld\n",
+ (long) hdr->sh_entsize);
+ fflush (stderr);
+}
+
+static void
+elf_debug_file (ehdrp)
+ Elf_Internal_Ehdr *ehdrp;
+{
+ fprintf (stderr, "e_entry = 0x%.8lx\n", (long) ehdrp->e_entry);
+ fprintf (stderr, "e_phoff = %ld\n", (long) ehdrp->e_phoff);
+ fprintf (stderr, "e_phnum = %ld\n", (long) ehdrp->e_phnum);
+ fprintf (stderr, "e_phentsize = %ld\n", (long) ehdrp->e_phentsize);
+ fprintf (stderr, "e_shoff = %ld\n", (long) ehdrp->e_shoff);
+ fprintf (stderr, "e_shnum = %ld\n", (long) ehdrp->e_shnum);
+ fprintf (stderr, "e_shentsize = %ld\n", (long) ehdrp->e_shentsize);
+}
+
+static char *
+elf_symbol_flags (flags)
+ flagword flags;
+{
+ static char buffer[1024];
+
+ buffer[0] = '\0';
+ if (flags & BSF_LOCAL)
+ strcat (buffer, " local");
+
+ if (flags & BSF_GLOBAL)
+ strcat (buffer, " global");
+
+ if (flags & BSF_DEBUGGING)
+ strcat (buffer, " debug");
+
+ if (flags & BSF_FUNCTION)
+ strcat (buffer, " function");
+
+ if (flags & BSF_KEEP)
+ strcat (buffer, " keep");
+
+ if (flags & BSF_KEEP_G)
+ strcat (buffer, " keep_g");
+
+ if (flags & BSF_WEAK)
+ strcat (buffer, " weak");
+
+ if (flags & BSF_SECTION_SYM)
+ strcat (buffer, " section-sym");
+
+ if (flags & BSF_OLD_COMMON)
+ strcat (buffer, " old-common");
+
+ if (flags & BSF_NOT_AT_END)
+ strcat (buffer, " not-at-end");
+
+ if (flags & BSF_CONSTRUCTOR)
+ strcat (buffer, " constructor");
+
+ if (flags & BSF_WARNING)
+ strcat (buffer, " warning");
+
+ if (flags & BSF_INDIRECT)
+ strcat (buffer, " indirect");
+
+ if (flags & BSF_FILE)
+ strcat (buffer, " file");
+
+ if (flags & DYNAMIC)
+ strcat (buffer, " dynamic");
+
+ if (flags & ~(BSF_LOCAL
+ | BSF_GLOBAL
+ | BSF_DEBUGGING
+ | BSF_FUNCTION
+ | BSF_KEEP
+ | BSF_KEEP_G
+ | BSF_WEAK
+ | BSF_SECTION_SYM
+ | BSF_OLD_COMMON
+ | BSF_NOT_AT_END
+ | BSF_CONSTRUCTOR
+ | BSF_WARNING
+ | BSF_INDIRECT
+ | BSF_FILE
+ | BSF_DYNAMIC))
+ strcat (buffer, " unknown-bits");
+
+ return buffer;
+}
+#endif
+
+#include "elfcore.h"
+#include "elflink.h"
+
+/* Size-dependent data and functions. */
+const struct elf_size_info NAME(_bfd_elf,size_info) = {
+ sizeof (Elf_External_Ehdr),
+ sizeof (Elf_External_Phdr),
+ sizeof (Elf_External_Shdr),
+ sizeof (Elf_External_Rel),
+ sizeof (Elf_External_Rela),
+ sizeof (Elf_External_Sym),
+ sizeof (Elf_External_Dyn),
+ sizeof (Elf_External_Note),
+
+ ARCH_SIZE, FILE_ALIGN,
+ ELFCLASS, EV_CURRENT,
+ elf_write_out_phdrs,
+ elf_write_shdrs_and_ehdr,
+ write_relocs,
+ elf_swap_symbol_out,
+ elf_slurp_reloc_table,
+ elf_slurp_symbol_table,
+ elf_swap_dyn_in
+};
diff --git a/bfd/elfcore.h b/bfd/elfcore.h
new file mode 100644
index 00000000000..e4454aac9d0
--- /dev/null
+++ b/bfd/elfcore.h
@@ -0,0 +1,226 @@
+/* ELF core file support for BFD.
+ Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+char*
+elf_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return elf_tdata (abfd)->core_command;
+}
+
+int
+elf_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return elf_tdata (abfd)->core_signal;
+}
+
+
+boolean
+elf_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd;
+ bfd *exec_bfd;
+{
+ char* corename;
+
+ /* xvecs must match if both are ELF files for the same target. */
+
+ if (core_bfd->xvec != exec_bfd->xvec)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return false;
+ }
+
+ /* See if the name in the corefile matches the executable name. */
+
+ corename = elf_tdata (core_bfd)->core_program;
+ if (corename != NULL)
+ {
+ const char* execname = strrchr (exec_bfd->filename, '/');
+ execname = execname ? execname + 1 : exec_bfd->filename;
+
+ if (strcmp(execname, corename) != 0)
+ return false;
+ }
+
+ return true;
+}
+
+
+/* Core files are simply standard ELF formatted files that partition
+ the file using the execution view of the file (program header table)
+ rather than the linking view. In fact, there is no section header
+ table in a core file.
+
+ The process status information (including the contents of the general
+ register set) and the floating point register set are stored in a
+ segment of type PT_NOTE. We handcraft a couple of extra bfd sections
+ that allow standard bfd access to the general registers (.reg) and the
+ floating point registers (.reg2).
+
+ */
+
+const bfd_target *
+elf_core_file_p (abfd)
+ bfd *abfd;
+{
+ Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
+ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
+ Elf_Internal_Phdr *i_phdrp; /* Elf program header, internal form */
+ unsigned int phindex;
+ struct elf_backend_data *ebd;
+
+ /* Read in the ELF header in external format. */
+ if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Check the magic number. */
+ if (elf_file_p (&x_ehdr) == false)
+ {
+ wrong:
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* FIXME: Check EI_VERSION here ! */
+
+ /* Check the address size ("class"). */
+ if (x_ehdr.e_ident[EI_CLASS] != ELFCLASS)
+ goto wrong;
+
+ /* Check the byteorder. */
+ switch (x_ehdr.e_ident[EI_DATA])
+ {
+ case ELFDATA2MSB: /* Big-endian */
+ if (! bfd_big_endian (abfd))
+ goto wrong;
+ break;
+ case ELFDATA2LSB: /* Little-endian */
+ if (! bfd_little_endian (abfd))
+ goto wrong;
+ break;
+ default:
+ goto wrong;
+ }
+
+ /* Give abfd an elf_obj_tdata. */
+ elf_tdata (abfd) =
+ (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
+ if (elf_tdata (abfd) == NULL)
+ return NULL;
+
+ /* FIXME: from here on down, "goto wrong" will leak memory. */
+
+ /* Swap in the rest of the header, now that we have the byte order. */
+ i_ehdrp = elf_elfheader (abfd);
+ elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
+
+#if DEBUG & 1
+ elf_debug_file (i_ehdrp);
+#endif
+
+ ebd = get_elf_backend_data (abfd);
+
+ /* Check that the ELF e_machine field matches what this particular
+ BFD format expects. */
+
+ if (ebd->elf_machine_code != i_ehdrp->e_machine
+ && (ebd->elf_machine_alt1 == 0
+ || i_ehdrp->e_machine != ebd->elf_machine_alt1)
+ && (ebd->elf_machine_alt2 == 0
+ || i_ehdrp->e_machine != ebd->elf_machine_alt2))
+ {
+ const bfd_target * const *target_ptr;
+
+ if (ebd->elf_machine_code != EM_NONE)
+ goto wrong;
+
+ /* This is the generic ELF target. Let it match any ELF target
+ for which we do not have a specific backend. */
+
+ for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
+ {
+ struct elf_backend_data *back;
+
+ if ((*target_ptr)->flavour != bfd_target_elf_flavour)
+ continue;
+ back = (struct elf_backend_data *) (*target_ptr)->backend_data;
+ if (back->elf_machine_code == i_ehdrp->e_machine)
+ {
+ /* target_ptr is an ELF backend which matches this
+ object file, so reject the generic ELF target. */
+ goto wrong;
+ }
+ }
+ }
+
+ /* If there is no program header, or the type is not a core file, then
+ we are hosed. */
+ if (i_ehdrp->e_phoff == 0 || i_ehdrp->e_type != ET_CORE)
+ goto wrong;
+
+ /* Does BFD's idea of the phdr size match the size
+ recorded in the file? */
+ if (i_ehdrp->e_phentsize != sizeof (Elf_External_Phdr))
+ goto wrong;
+
+ /* Allocate space for the program headers. */
+ i_phdrp = (Elf_Internal_Phdr *)
+ bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
+ if (!i_phdrp)
+ return NULL;
+
+ elf_tdata (abfd)->phdr = i_phdrp;
+
+ /* Read and convert to internal form. */
+ for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
+ {
+ Elf_External_Phdr x_phdr;
+ if (bfd_read ((PTR) &x_phdr, sizeof (x_phdr), 1, abfd)
+ != sizeof (x_phdr))
+ return NULL;
+
+ elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);
+ }
+
+ /* Process each program header. */
+ for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
+ {
+ if (!_bfd_elfcore_section_from_phdr (abfd, i_phdrp + phindex, phindex))
+ return NULL;
+ }
+
+ /* Set the machine architecture. */
+ if (! bfd_default_set_arch_mach (abfd, ebd->arch, 0))
+ {
+ /* It's OK if this fails for the generic target. */
+ if (ebd->elf_machine_code != EM_NONE)
+ return NULL;
+ }
+
+ /* Save the entry point from the ELF header. */
+ bfd_get_start_address (abfd) = i_ehdrp->e_entry;
+
+ return abfd->xvec;
+}
diff --git a/bfd/elflink.c b/bfd/elflink.c
new file mode 100644
index 00000000000..dc0b0428c60
--- /dev/null
+++ b/bfd/elflink.c
@@ -0,0 +1,433 @@
+/* ELF linking support for BFD.
+ Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#define ARCH_SIZE 0
+#include "elf-bfd.h"
+
+boolean
+_bfd_elf_create_got_section (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+ struct elf_link_hash_entry *h;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ int ptralign;
+
+ /* This function may be called more than once. */
+ if (bfd_get_section_by_name (abfd, ".got") != NULL)
+ return true;
+
+ switch (bed->s->arch_size)
+ {
+ case 32: ptralign = 2; break;
+ case 64: ptralign = 3; break;
+ default: abort();
+ }
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+
+ s = bfd_make_section (abfd, ".got");
+ if (s == NULL
+ || !bfd_set_section_flags (abfd, s, flags)
+ || !bfd_set_section_alignment (abfd, s, ptralign))
+ return false;
+
+ if (bed->want_got_plt)
+ {
+ s = bfd_make_section (abfd, ".got.plt");
+ if (s == NULL
+ || !bfd_set_section_flags (abfd, s, flags)
+ || !bfd_set_section_alignment (abfd, s, ptralign))
+ return false;
+ }
+
+ /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
+ (or .got.plt) section. We don't do this in the linker script
+ because we don't want to define the symbol if we are not creating
+ a global offset table. */
+ h = NULL;
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
+ bed->got_symbol_offset, (const char *) NULL, false,
+ bed->collect, (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (info->shared
+ && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+
+ elf_hash_table (info)->hgot = h;
+
+ /* The first bit of the global offset table is the header. */
+ s->_raw_size += bed->got_header_size + bed->got_symbol_offset;
+
+ return true;
+}
+
+
+/* Create dynamic sections when linking against a dynamic object. */
+
+boolean
+_bfd_elf_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags, pltflags;
+ register asection *s;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ int ptralign;
+
+ switch (bed->s->arch_size)
+ {
+ case 32: ptralign = 2; break;
+ case 64: ptralign = 3; break;
+ default: abort();
+ }
+
+ /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
+ .rel[a].bss sections. */
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+
+ pltflags = flags;
+ pltflags |= SEC_CODE;
+ if (bed->plt_not_loaded)
+ pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS);
+ if (bed->plt_readonly)
+ pltflags |= SEC_READONLY;
+
+ s = bfd_make_section (abfd, ".plt");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, pltflags)
+ || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+ return false;
+
+ if (bed->want_plt_sym)
+ {
+ /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
+ .plt section. */
+ struct elf_link_hash_entry *h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (info->shared
+ && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.plt" : ".rel.plt");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, ptralign))
+ return false;
+
+ if (! _bfd_elf_create_got_section (abfd, info))
+ return false;
+
+ /* The .dynbss section is a place to put symbols which are defined
+ by dynamic objects, are referenced by regular objects, and are
+ not functions. We must allocate space for them in the process
+ image and use a R_*_COPY reloc to tell the dynamic linker to
+ initialize them at run time. The linker script puts the .dynbss
+ section into the .bss section of the final image. */
+ s = bfd_make_section (abfd, ".dynbss");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
+ return false;
+
+ /* The .rel[a].bss section holds copy relocs. This section is not
+ normally needed. We need to create it here, though, so that the
+ linker will map it to an output section. We can't just create it
+ only if we need it, because we will not know whether we need it
+ until we have seen all the input files, and the first time the
+ main linker code calls BFD after examining all the input files
+ (size_dynamic_sections) the input sections have already been
+ mapped to the output sections. If the section turns out not to
+ be needed, we can discard it later. We will never need this
+ section when generating a shared object, since they do not use
+ copy relocs. */
+ if (! info->shared)
+ {
+ s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.bss" : ".rel.bss");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, ptralign))
+ return false;
+ }
+
+ return true;
+}
+
+
+/* Record a new dynamic symbol. We record the dynamic symbols as we
+ read the input files, since we need to have a list of all of them
+ before we can determine the final sizes of the output sections.
+ Note that we may actually call this function even though we are not
+ going to output any dynamic symbols; in some cases we know that a
+ symbol should be in the dynamic symbol table, but only if there is
+ one. */
+
+boolean
+_bfd_elf_link_record_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ if (h->dynindx == -1)
+ {
+ struct bfd_strtab_hash *dynstr;
+ char *p, *alc;
+ const char *name;
+ boolean copy;
+ bfd_size_type indx;
+
+ h->dynindx = elf_hash_table (info)->dynsymcount;
+ ++elf_hash_table (info)->dynsymcount;
+
+ dynstr = elf_hash_table (info)->dynstr;
+ if (dynstr == NULL)
+ {
+ /* Create a strtab to hold the dynamic symbol names. */
+ elf_hash_table (info)->dynstr = dynstr = _bfd_elf_stringtab_init ();
+ if (dynstr == NULL)
+ return false;
+ }
+
+ /* We don't put any version information in the dynamic string
+ table. */
+ name = h->root.root.string;
+ p = strchr (name, ELF_VER_CHR);
+ if (p == NULL)
+ {
+ alc = NULL;
+ copy = false;
+ }
+ else
+ {
+ alc = bfd_malloc (p - name + 1);
+ if (alc == NULL)
+ return false;
+ strncpy (alc, name, p - name);
+ alc[p - name] = '\0';
+ name = alc;
+ copy = true;
+ }
+
+ indx = _bfd_stringtab_add (dynstr, name, true, copy);
+
+ if (alc != NULL)
+ free (alc);
+
+ if (indx == (bfd_size_type) -1)
+ return false;
+ h->dynstr_index = indx;
+ }
+
+ return true;
+}
+
+/* Create a special linker section, or return a pointer to a linker section already created */
+
+elf_linker_section_t *
+_bfd_elf_create_linker_section (abfd, info, which, defaults)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ enum elf_linker_section_enum which;
+ elf_linker_section_t *defaults;
+{
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ elf_linker_section_t *lsect;
+
+ /* Record the first bfd section that needs the special section */
+ if (!dynobj)
+ dynobj = elf_hash_table (info)->dynobj = abfd;
+
+ /* If this is the first time, create the section */
+ lsect = elf_linker_section (dynobj, which);
+ if (!lsect)
+ {
+ asection *s;
+
+ lsect = (elf_linker_section_t *)
+ bfd_alloc (dynobj, sizeof (elf_linker_section_t));
+
+ *lsect = *defaults;
+ elf_linker_section (dynobj, which) = lsect;
+ lsect->which = which;
+ lsect->hole_written_p = false;
+
+ /* See if the sections already exist */
+ lsect->section = s = bfd_get_section_by_name (dynobj, lsect->name);
+ if (!s || (s->flags & defaults->flags) != defaults->flags)
+ {
+ lsect->section = s = bfd_make_section_anyway (dynobj, lsect->name);
+
+ if (s == NULL)
+ return (elf_linker_section_t *)0;
+
+ bfd_set_section_flags (dynobj, s, defaults->flags);
+ bfd_set_section_alignment (dynobj, s, lsect->alignment);
+ }
+ else if (bfd_get_section_alignment (dynobj, s) < lsect->alignment)
+ bfd_set_section_alignment (dynobj, s, lsect->alignment);
+
+ s->_raw_size = align_power (s->_raw_size, lsect->alignment);
+
+ /* Is there a hole we have to provide? If so check whether the segment is
+ too big already */
+ if (lsect->hole_size)
+ {
+ lsect->hole_offset = s->_raw_size;
+ s->_raw_size += lsect->hole_size;
+ if (lsect->hole_offset > lsect->max_hole_offset)
+ {
+ (*_bfd_error_handler) (_("%s: Section %s is already to large to put hole of %ld bytes in"),
+ bfd_get_filename (abfd),
+ lsect->name,
+ (long)lsect->hole_size);
+
+ bfd_set_error (bfd_error_bad_value);
+ return (elf_linker_section_t *)0;
+ }
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "Creating section %s, current size = %ld\n",
+ lsect->name, (long)s->_raw_size);
+#endif
+
+ if (lsect->sym_name)
+ {
+ struct elf_link_hash_entry *h = NULL;
+#ifdef DEBUG
+ fprintf (stderr, "Adding %s to section %s\n",
+ lsect->sym_name,
+ lsect->name);
+#endif
+ h = (struct elf_link_hash_entry *)
+ bfd_link_hash_lookup (info->hash, lsect->sym_name, false, false, false);
+
+ if ((h == NULL || h->root.type == bfd_link_hash_undefined)
+ && !(_bfd_generic_link_add_one_symbol (info,
+ abfd,
+ lsect->sym_name,
+ BSF_GLOBAL,
+ s,
+ ((lsect->hole_size)
+ ? s->_raw_size - lsect->hole_size + lsect->sym_offset
+ : lsect->sym_offset),
+ (const char *) NULL,
+ false,
+ get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return (elf_linker_section_t *)0;
+
+ if ((defaults->which != LINKER_SECTION_SDATA)
+ && (defaults->which != LINKER_SECTION_SDATA2))
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_DYNAMIC;
+
+ h->type = STT_OBJECT;
+ lsect->sym_hash = h;
+
+ if (info->shared
+ && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return (elf_linker_section_t *)0;
+ }
+ }
+
+#if 0
+ /* This does not make sense. The sections which may exist in the
+ object file have nothing to do with the sections we want to
+ create. */
+
+ /* Find the related sections if they have been created */
+ if (lsect->bss_name && !lsect->bss_section)
+ lsect->bss_section = bfd_get_section_by_name (dynobj, lsect->bss_name);
+
+ if (lsect->rel_name && !lsect->rel_section)
+ lsect->rel_section = bfd_get_section_by_name (dynobj, lsect->rel_name);
+#endif
+
+ return lsect;
+}
+
+
+/* Find a linker generated pointer with a given addend and type. */
+
+elf_linker_section_pointers_t *
+_bfd_elf_find_pointer_linker_section (linker_pointers, addend, which)
+ elf_linker_section_pointers_t *linker_pointers;
+ bfd_signed_vma addend;
+ elf_linker_section_enum_t which;
+{
+ for ( ; linker_pointers != NULL; linker_pointers = linker_pointers->next)
+ {
+ if (which == linker_pointers->which && addend == linker_pointers->addend)
+ return linker_pointers;
+ }
+
+ return (elf_linker_section_pointers_t *)0;
+}
+
+
+/* Make the .rela section corresponding to the generated linker section. */
+
+boolean
+_bfd_elf_make_linker_section_rela (dynobj, lsect, alignment)
+ bfd *dynobj;
+ elf_linker_section_t *lsect;
+ int alignment;
+{
+ if (lsect->rel_section)
+ return true;
+
+ lsect->rel_section = bfd_get_section_by_name (dynobj, lsect->rel_name);
+ if (lsect->rel_section == NULL)
+ {
+ lsect->rel_section = bfd_make_section (dynobj, lsect->rel_name);
+ if (lsect->rel_section == NULL
+ || ! bfd_set_section_flags (dynobj,
+ lsect->rel_section,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, lsect->rel_section, alignment))
+ return false;
+ }
+
+ return true;
+}
diff --git a/bfd/elflink.h b/bfd/elflink.h
new file mode 100644
index 00000000000..32bfab0e802
--- /dev/null
+++ b/bfd/elflink.h
@@ -0,0 +1,6150 @@
+/* ELF linker support.
+ Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ELF linker code. */
+
+/* This struct is used to pass information to routines called via
+ elf_link_hash_traverse which must return failure. */
+
+struct elf_info_failed
+{
+ boolean failed;
+ struct bfd_link_info *info;
+};
+
+static boolean elf_link_add_object_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_link_add_archive_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_merge_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
+ asection **, bfd_vma *, struct elf_link_hash_entry **,
+ boolean *, boolean *, boolean *));
+static boolean elf_export_symbol
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_fix_symbol_flags
+ PARAMS ((struct elf_link_hash_entry *, struct elf_info_failed *));
+static boolean elf_adjust_dynamic_symbol
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_link_find_version_dependencies
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_link_find_version_dependencies
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_link_assign_sym_version
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_link_renumber_dynsyms
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_collect_hash_codes
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+
+/* Given an ELF BFD, add symbols to the global hash table as
+ appropriate. */
+
+boolean
+elf_bfd_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_object:
+ return elf_link_add_object_symbols (abfd, info);
+ case bfd_archive:
+ return elf_link_add_archive_symbols (abfd, info);
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+}
+
+
+/* Add symbols from an ELF archive file to the linker hash table. We
+ don't use _bfd_generic_link_add_archive_symbols because of a
+ problem which arises on UnixWare. The UnixWare libc.so is an
+ archive which includes an entry libc.so.1 which defines a bunch of
+ symbols. The libc.so archive also includes a number of other
+ object files, which also define symbols, some of which are the same
+ as those defined in libc.so.1. Correct linking requires that we
+ consider each object file in turn, and include it if it defines any
+ symbols we need. _bfd_generic_link_add_archive_symbols does not do
+ this; it looks through the list of undefined symbols, and includes
+ any object file which defines them. When this algorithm is used on
+ UnixWare, it winds up pulling in libc.so.1 early and defining a
+ bunch of symbols. This means that some of the other objects in the
+ archive are not included in the link, which is incorrect since they
+ precede libc.so.1 in the archive.
+
+ Fortunately, ELF archive handling is simpler than that done by
+ _bfd_generic_link_add_archive_symbols, which has to allow for a.out
+ oddities. In ELF, if we find a symbol in the archive map, and the
+ symbol is currently undefined, we know that we must pull in that
+ object file.
+
+ Unfortunately, we do have to make multiple passes over the symbol
+ table until nothing further is resolved. */
+
+static boolean
+elf_link_add_archive_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ symindex c;
+ boolean *defined = NULL;
+ boolean *included = NULL;
+ carsym *symdefs;
+ boolean loop;
+
+ if (! bfd_has_map (abfd))
+ {
+ /* An empty archive is a special case. */
+ if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
+ return true;
+ bfd_set_error (bfd_error_no_armap);
+ return false;
+ }
+
+ /* Keep track of all symbols we know to be already defined, and all
+ files we know to be already included. This is to speed up the
+ second and subsequent passes. */
+ c = bfd_ardata (abfd)->symdef_count;
+ if (c == 0)
+ return true;
+ defined = (boolean *) bfd_malloc (c * sizeof (boolean));
+ included = (boolean *) bfd_malloc (c * sizeof (boolean));
+ if (defined == (boolean *) NULL || included == (boolean *) NULL)
+ goto error_return;
+ memset (defined, 0, c * sizeof (boolean));
+ memset (included, 0, c * sizeof (boolean));
+
+ symdefs = bfd_ardata (abfd)->symdefs;
+
+ do
+ {
+ file_ptr last;
+ symindex i;
+ carsym *symdef;
+ carsym *symdefend;
+
+ loop = false;
+ last = -1;
+
+ symdef = symdefs;
+ symdefend = symdef + c;
+ for (i = 0; symdef < symdefend; symdef++, i++)
+ {
+ struct elf_link_hash_entry *h;
+ bfd *element;
+ struct bfd_link_hash_entry *undefs_tail;
+ symindex mark;
+
+ if (defined[i] || included[i])
+ continue;
+ if (symdef->file_offset == last)
+ {
+ included[i] = true;
+ continue;
+ }
+
+ h = elf_link_hash_lookup (elf_hash_table (info), symdef->name,
+ false, false, false);
+
+ if (h == NULL)
+ {
+ char *p, *copy;
+
+ /* If this is a default version (the name contains @@),
+ look up the symbol again without the version. The
+ effect is that references to the symbol without the
+ version will be matched by the default symbol in the
+ archive. */
+
+ p = strchr (symdef->name, ELF_VER_CHR);
+ if (p == NULL || p[1] != ELF_VER_CHR)
+ continue;
+
+ copy = bfd_alloc (abfd, p - symdef->name + 1);
+ if (copy == NULL)
+ goto error_return;
+ memcpy (copy, symdef->name, p - symdef->name);
+ copy[p - symdef->name] = '\0';
+
+ h = elf_link_hash_lookup (elf_hash_table (info), copy,
+ false, false, false);
+
+ bfd_release (abfd, copy);
+ }
+
+ if (h == NULL)
+ continue;
+
+ if (h->root.type != bfd_link_hash_undefined)
+ {
+ if (h->root.type != bfd_link_hash_undefweak)
+ defined[i] = true;
+ continue;
+ }
+
+ /* We need to include this archive member. */
+
+ element = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
+ if (element == (bfd *) NULL)
+ goto error_return;
+
+ if (! bfd_check_format (element, bfd_object))
+ goto error_return;
+
+ /* Doublecheck that we have not included this object
+ already--it should be impossible, but there may be
+ something wrong with the archive. */
+ if (element->archive_pass != 0)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ element->archive_pass = 1;
+
+ undefs_tail = info->hash->undefs_tail;
+
+ if (! (*info->callbacks->add_archive_element) (info, element,
+ symdef->name))
+ goto error_return;
+ if (! elf_link_add_object_symbols (element, info))
+ goto error_return;
+
+ /* If there are any new undefined symbols, we need to make
+ another pass through the archive in order to see whether
+ they can be defined. FIXME: This isn't perfect, because
+ common symbols wind up on undefs_tail and because an
+ undefined symbol which is defined later on in this pass
+ does not require another pass. This isn't a bug, but it
+ does make the code less efficient than it could be. */
+ if (undefs_tail != info->hash->undefs_tail)
+ loop = true;
+
+ /* Look backward to mark all symbols from this object file
+ which we have already seen in this pass. */
+ mark = i;
+ do
+ {
+ included[mark] = true;
+ if (mark == 0)
+ break;
+ --mark;
+ }
+ while (symdefs[mark].file_offset == symdef->file_offset);
+
+ /* We mark subsequent symbols from this object file as we go
+ on through the loop. */
+ last = symdef->file_offset;
+ }
+ }
+ while (loop);
+
+ free (defined);
+ free (included);
+
+ return true;
+
+ error_return:
+ if (defined != (boolean *) NULL)
+ free (defined);
+ if (included != (boolean *) NULL)
+ free (included);
+ return false;
+}
+
+/* This function is called when we want to define a new symbol. It
+ handles the various cases which arise when we find a definition in
+ a dynamic object, or when there is already a definition in a
+ dynamic object. The new symbol is described by NAME, SYM, PSEC,
+ and PVALUE. We set SYM_HASH to the hash table entry. We set
+ OVERRIDE if the old symbol is overriding a new definition. We set
+ TYPE_CHANGE_OK if it is OK for the type to change. We set
+ SIZE_CHANGE_OK if it is OK for the size to change. By OK to
+ change, we mean that we shouldn't warn if the type or size does
+ change. */
+
+static boolean
+elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash,
+ override, type_change_ok, size_change_ok)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const char *name;
+ Elf_Internal_Sym *sym;
+ asection **psec;
+ bfd_vma *pvalue;
+ struct elf_link_hash_entry **sym_hash;
+ boolean *override;
+ boolean *type_change_ok;
+ boolean *size_change_ok;
+{
+ asection *sec;
+ struct elf_link_hash_entry *h;
+ int bind;
+ bfd *oldbfd;
+ boolean newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
+
+ *override = false;
+
+ sec = *psec;
+ bind = ELF_ST_BIND (sym->st_info);
+
+ if (! bfd_is_und_section (sec))
+ h = elf_link_hash_lookup (elf_hash_table (info), name, true, false, false);
+ else
+ h = ((struct elf_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (abfd, info, name, true, false, false));
+ if (h == NULL)
+ return false;
+ *sym_hash = h;
+
+ /* This code is for coping with dynamic objects, and is only useful
+ if we are doing an ELF link. */
+ if (info->hash->creator != abfd->xvec)
+ return true;
+
+ /* For merging, we only care about real symbols. */
+
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ /* If we just created the symbol, mark it as being an ELF symbol.
+ Other than that, there is nothing to do--there is no merge issue
+ with a newly defined symbol--so we just return. */
+
+ if (h->root.type == bfd_link_hash_new)
+ {
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+ return true;
+ }
+
+ /* OLDBFD is a BFD associated with the existing symbol. */
+
+ switch (h->root.type)
+ {
+ default:
+ oldbfd = NULL;
+ break;
+
+ case bfd_link_hash_undefined:
+ case bfd_link_hash_undefweak:
+ oldbfd = h->root.u.undef.abfd;
+ break;
+
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ oldbfd = h->root.u.def.section->owner;
+ break;
+
+ case bfd_link_hash_common:
+ oldbfd = h->root.u.c.p->section->owner;
+ break;
+ }
+
+ /* NEWDYN and OLDDYN indicate whether the new or old symbol,
+ respectively, is from a dynamic object. */
+
+ if ((abfd->flags & DYNAMIC) != 0)
+ newdyn = true;
+ else
+ newdyn = false;
+
+ if (oldbfd == NULL || (oldbfd->flags & DYNAMIC) == 0)
+ olddyn = false;
+ else
+ olddyn = true;
+
+ /* NEWDEF and OLDDEF indicate whether the new or old symbol,
+ respectively, appear to be a definition rather than reference. */
+
+ if (bfd_is_und_section (sec) || bfd_is_com_section (sec))
+ newdef = false;
+ else
+ newdef = true;
+
+ if (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_common)
+ olddef = false;
+ else
+ olddef = true;
+
+ /* NEWDYNCOMMON and OLDDYNCOMMON indicate whether the new or old
+ symbol, respectively, appears to be a common symbol in a dynamic
+ object. If a symbol appears in an uninitialized section, and is
+ not weak, and is not a function, then it may be a common symbol
+ which was resolved when the dynamic object was created. We want
+ to treat such symbols specially, because they raise special
+ considerations when setting the symbol size: if the symbol
+ appears as a common symbol in a regular object, and the size in
+ the regular object is larger, we must make sure that we use the
+ larger size. This problematic case can always be avoided in C,
+ but it must be handled correctly when using Fortran shared
+ libraries.
+
+ Note that if NEWDYNCOMMON is set, NEWDEF will be set, and
+ likewise for OLDDYNCOMMON and OLDDEF.
+
+ Note that this test is just a heuristic, and that it is quite
+ possible to have an uninitialized symbol in a shared object which
+ is really a definition, rather than a common symbol. This could
+ lead to some minor confusion when the symbol really is a common
+ symbol in some regular object. However, I think it will be
+ harmless. */
+
+ if (newdyn
+ && newdef
+ && (sec->flags & SEC_ALLOC) != 0
+ && (sec->flags & SEC_LOAD) == 0
+ && sym->st_size > 0
+ && bind != STB_WEAK
+ && ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+ newdyncommon = true;
+ else
+ newdyncommon = false;
+
+ if (olddyn
+ && olddef
+ && h->root.type == bfd_link_hash_defined
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->root.u.def.section->flags & SEC_ALLOC) != 0
+ && (h->root.u.def.section->flags & SEC_LOAD) == 0
+ && h->size > 0
+ && h->type != STT_FUNC)
+ olddyncommon = true;
+ else
+ olddyncommon = false;
+
+ /* It's OK to change the type if either the existing symbol or the
+ new symbol is weak. */
+
+ if (h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_undefweak
+ || bind == STB_WEAK)
+ *type_change_ok = true;
+
+ /* It's OK to change the size if either the existing symbol or the
+ new symbol is weak, or if the old symbol is undefined. */
+
+ if (*type_change_ok
+ || h->root.type == bfd_link_hash_undefined)
+ *size_change_ok = true;
+
+ /* If both the old and the new symbols look like common symbols in a
+ dynamic object, set the size of the symbol to the larger of the
+ two. */
+
+ if (olddyncommon
+ && newdyncommon
+ && sym->st_size != h->size)
+ {
+ /* Since we think we have two common symbols, issue a multiple
+ common warning if desired. Note that we only warn if the
+ size is different. If the size is the same, we simply let
+ the old symbol override the new one as normally happens with
+ symbols defined in dynamic objects. */
+
+ if (! ((*info->callbacks->multiple_common)
+ (info, h->root.root.string, oldbfd, bfd_link_hash_common,
+ h->size, abfd, bfd_link_hash_common, sym->st_size)))
+ return false;
+
+ if (sym->st_size > h->size)
+ h->size = sym->st_size;
+
+ *size_change_ok = true;
+ }
+
+ /* If we are looking at a dynamic object, and we have found a
+ definition, we need to see if the symbol was already defined by
+ some other object. If so, we want to use the existing
+ definition, and we do not want to report a multiple symbol
+ definition error; we do this by clobbering *PSEC to be
+ bfd_und_section_ptr.
+
+ We treat a common symbol as a definition if the symbol in the
+ shared library is a function, since common symbols always
+ represent variables; this can cause confusion in principle, but
+ any such confusion would seem to indicate an erroneous program or
+ shared library. We also permit a common symbol in a regular
+ object to override a weak symbol in a shared object. */
+
+ if (newdyn
+ && newdef
+ && (olddef
+ || (h->root.type == bfd_link_hash_common
+ && (bind == STB_WEAK
+ || ELF_ST_TYPE (sym->st_info) == STT_FUNC))))
+ {
+ *override = true;
+ newdef = false;
+ newdyncommon = false;
+
+ *psec = sec = bfd_und_section_ptr;
+ *size_change_ok = true;
+
+ /* If we get here when the old symbol is a common symbol, then
+ we are explicitly letting it override a weak symbol or
+ function in a dynamic object, and we don't want to warn about
+ a type change. If the old symbol is a defined symbol, a type
+ change warning may still be appropriate. */
+
+ if (h->root.type == bfd_link_hash_common)
+ *type_change_ok = true;
+ }
+
+ /* Handle the special case of an old common symbol merging with a
+ new symbol which looks like a common symbol in a shared object.
+ We change *PSEC and *PVALUE to make the new symbol look like a
+ common symbol, and let _bfd_generic_link_add_one_symbol will do
+ the right thing. */
+
+ if (newdyncommon
+ && h->root.type == bfd_link_hash_common)
+ {
+ *override = true;
+ newdef = false;
+ newdyncommon = false;
+ *pvalue = sym->st_size;
+ *psec = sec = bfd_com_section_ptr;
+ *size_change_ok = true;
+ }
+
+ /* If the old symbol is from a dynamic object, and the new symbol is
+ a definition which is not from a dynamic object, then the new
+ symbol overrides the old symbol. Symbols from regular files
+ always take precedence over symbols from dynamic objects, even if
+ they are defined after the dynamic object in the link.
+
+ As above, we again permit a common symbol in a regular object to
+ override a definition in a shared object if the shared object
+ symbol is a function or is weak. */
+
+ if (! newdyn
+ && (newdef
+ || (bfd_is_com_section (sec)
+ && (h->root.type == bfd_link_hash_defweak
+ || h->type == STT_FUNC)))
+ && olddyn
+ && olddef
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)
+ {
+ /* Change the hash table entry to undefined, and let
+ _bfd_generic_link_add_one_symbol do the right thing with the
+ new definition. */
+
+ h->root.type = bfd_link_hash_undefined;
+ h->root.u.undef.abfd = h->root.u.def.section->owner;
+ *size_change_ok = true;
+
+ olddef = false;
+ olddyncommon = false;
+
+ /* We again permit a type change when a common symbol may be
+ overriding a function. */
+
+ if (bfd_is_com_section (sec))
+ *type_change_ok = true;
+
+ /* This union may have been set to be non-NULL when this symbol
+ was seen in a dynamic object. We must force the union to be
+ NULL, so that it is correct for a regular symbol. */
+
+ h->verinfo.vertree = NULL;
+
+ /* In this special case, if H is the target of an indirection,
+ we want the caller to frob with H rather than with the
+ indirect symbol. That will permit the caller to redefine the
+ target of the indirection, rather than the indirect symbol
+ itself. FIXME: This will break the -y option if we store a
+ symbol with a different name. */
+ *sym_hash = h;
+ }
+
+ /* Handle the special case of a new common symbol merging with an
+ old symbol that looks like it might be a common symbol defined in
+ a shared object. Note that we have already handled the case in
+ which a new common symbol should simply override the definition
+ in the shared library. */
+
+ if (! newdyn
+ && bfd_is_com_section (sec)
+ && olddyncommon)
+ {
+ /* It would be best if we could set the hash table entry to a
+ common symbol, but we don't know what to use for the section
+ or the alignment. */
+ if (! ((*info->callbacks->multiple_common)
+ (info, h->root.root.string, oldbfd, bfd_link_hash_common,
+ h->size, abfd, bfd_link_hash_common, sym->st_size)))
+ return false;
+
+ /* If the predumed common symbol in the dynamic object is
+ larger, pretend that the new symbol has its size. */
+
+ if (h->size > *pvalue)
+ *pvalue = h->size;
+
+ /* FIXME: We no longer know the alignment required by the symbol
+ in the dynamic object, so we just wind up using the one from
+ the regular object. */
+
+ olddef = false;
+ olddyncommon = false;
+
+ h->root.type = bfd_link_hash_undefined;
+ h->root.u.undef.abfd = h->root.u.def.section->owner;
+
+ *size_change_ok = true;
+ *type_change_ok = true;
+
+ h->verinfo.vertree = NULL;
+ }
+
+ return true;
+}
+
+/* Add symbols from an ELF object file to the linker hash table. */
+
+static boolean
+elf_link_add_object_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ boolean (*add_symbol_hook) PARAMS ((bfd *, struct bfd_link_info *,
+ const Elf_Internal_Sym *,
+ const char **, flagword *,
+ asection **, bfd_vma *));
+ boolean (*check_relocs) PARAMS ((bfd *, struct bfd_link_info *,
+ asection *, const Elf_Internal_Rela *));
+ boolean collect;
+ Elf_Internal_Shdr *hdr;
+ size_t symcount;
+ size_t extsymcount;
+ size_t extsymoff;
+ Elf_External_Sym *buf = NULL;
+ struct elf_link_hash_entry **sym_hash;
+ boolean dynamic;
+ bfd_byte *dynver = NULL;
+ Elf_External_Versym *extversym = NULL;
+ Elf_External_Versym *ever;
+ Elf_External_Dyn *dynbuf = NULL;
+ struct elf_link_hash_entry *weaks;
+ Elf_External_Sym *esym;
+ Elf_External_Sym *esymend;
+
+ add_symbol_hook = get_elf_backend_data (abfd)->elf_add_symbol_hook;
+ collect = get_elf_backend_data (abfd)->collect;
+
+ if ((abfd->flags & DYNAMIC) == 0)
+ dynamic = false;
+ else
+ {
+ dynamic = true;
+
+ /* You can't use -r against a dynamic object. Also, there's no
+ hope of using a dynamic object which does not exactly match
+ the format of the output file. */
+ if (info->relocateable || info->hash->creator != abfd->xvec)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ goto error_return;
+ }
+ }
+
+ /* As a GNU extension, any input sections which are named
+ .gnu.warning.SYMBOL are treated as warning symbols for the given
+ symbol. This differs from .gnu.warning sections, which generate
+ warnings when they are included in an output file. */
+ if (! info->shared)
+ {
+ asection *s;
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+
+ name = bfd_get_section_name (abfd, s);
+ if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0)
+ {
+ char *msg;
+ bfd_size_type sz;
+
+ name += sizeof ".gnu.warning." - 1;
+
+ /* If this is a shared object, then look up the symbol
+ in the hash table. If it is there, and it is already
+ been defined, then we will not be using the entry
+ from this shared object, so we don't need to warn.
+ FIXME: If we see the definition in a regular object
+ later on, we will warn, but we shouldn't. The only
+ fix is to keep track of what warnings we are supposed
+ to emit, and then handle them all at the end of the
+ link. */
+ if (dynamic && abfd->xvec == info->hash->creator)
+ {
+ struct elf_link_hash_entry *h;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), name,
+ false, false, true);
+
+ /* FIXME: What about bfd_link_hash_common? */
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ /* We don't want to issue this warning. Clobber
+ the section size so that the warning does not
+ get copied into the output file. */
+ s->_raw_size = 0;
+ continue;
+ }
+ }
+
+ sz = bfd_section_size (abfd, s);
+ msg = (char *) bfd_alloc (abfd, sz + 1);
+ if (msg == NULL)
+ goto error_return;
+
+ if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
+ goto error_return;
+
+ msg[sz] = '\0';
+
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_WARNING, s, (bfd_vma) 0, msg,
+ false, collect, (struct bfd_link_hash_entry **) NULL)))
+ goto error_return;
+
+ if (! info->relocateable)
+ {
+ /* Clobber the section size so that the warning does
+ not get copied into the output file. */
+ s->_raw_size = 0;
+ }
+ }
+ }
+ }
+
+ /* If this is a dynamic object, we always link against the .dynsym
+ symbol table, not the .symtab symbol table. The dynamic linker
+ will only see the .dynsym symbol table, so there is no reason to
+ look at .symtab for a dynamic object. */
+
+ if (! dynamic || elf_dynsymtab (abfd) == 0)
+ hdr = &elf_tdata (abfd)->symtab_hdr;
+ else
+ hdr = &elf_tdata (abfd)->dynsymtab_hdr;
+
+ if (dynamic)
+ {
+ /* Read in any version definitions. */
+
+ if (! _bfd_elf_slurp_version_tables (abfd))
+ goto error_return;
+
+ /* Read in the symbol versions, but don't bother to convert them
+ to internal format. */
+ if (elf_dynversym (abfd) != 0)
+ {
+ Elf_Internal_Shdr *versymhdr;
+
+ versymhdr = &elf_tdata (abfd)->dynversym_hdr;
+ extversym = (Elf_External_Versym *) bfd_malloc (hdr->sh_size);
+ if (extversym == NULL)
+ goto error_return;
+ if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read ((PTR) extversym, 1, versymhdr->sh_size, abfd)
+ != versymhdr->sh_size))
+ goto error_return;
+ }
+ }
+
+ symcount = hdr->sh_size / sizeof (Elf_External_Sym);
+
+ /* The sh_info field of the symtab header tells us where the
+ external symbols start. We don't care about the local symbols at
+ this point. */
+ if (elf_bad_symtab (abfd))
+ {
+ extsymcount = symcount;
+ extsymoff = 0;
+ }
+ else
+ {
+ extsymcount = symcount - hdr->sh_info;
+ extsymoff = hdr->sh_info;
+ }
+
+ buf = ((Elf_External_Sym *)
+ bfd_malloc (extsymcount * sizeof (Elf_External_Sym)));
+ if (buf == NULL && extsymcount != 0)
+ goto error_return;
+
+ /* We store a pointer to the hash table entry for each external
+ symbol. */
+ sym_hash = ((struct elf_link_hash_entry **)
+ bfd_alloc (abfd,
+ extsymcount * sizeof (struct elf_link_hash_entry *)));
+ if (sym_hash == NULL)
+ goto error_return;
+ elf_sym_hashes (abfd) = sym_hash;
+
+ if (! dynamic)
+ {
+ /* If we are creating a shared library, create all the dynamic
+ sections immediately. We need to attach them to something,
+ so we attach them to this BFD, provided it is the right
+ format. FIXME: If there are no input BFD's of the same
+ format as the output, we can't make a shared library. */
+ if (info->shared
+ && ! elf_hash_table (info)->dynamic_sections_created
+ && abfd->xvec == info->hash->creator)
+ {
+ if (! elf_link_create_dynamic_sections (abfd, info))
+ goto error_return;
+ }
+ }
+ else
+ {
+ asection *s;
+ boolean add_needed;
+ const char *name;
+ bfd_size_type oldsize;
+ bfd_size_type strindex;
+
+ /* Find the name to use in a DT_NEEDED entry that refers to this
+ object. If the object has a DT_SONAME entry, we use it.
+ Otherwise, if the generic linker stuck something in
+ elf_dt_name, we use that. Otherwise, we just use the file
+ name. If the generic linker put a null string into
+ elf_dt_name, we don't make a DT_NEEDED entry at all, even if
+ there is a DT_SONAME entry. */
+ add_needed = true;
+ name = bfd_get_filename (abfd);
+ if (elf_dt_name (abfd) != NULL)
+ {
+ name = elf_dt_name (abfd);
+ if (*name == '\0')
+ add_needed = false;
+ }
+ s = bfd_get_section_by_name (abfd, ".dynamic");
+ if (s != NULL)
+ {
+ Elf_External_Dyn *extdyn;
+ Elf_External_Dyn *extdynend;
+ int elfsec;
+ unsigned long link;
+
+ dynbuf = (Elf_External_Dyn *) bfd_malloc ((size_t) s->_raw_size);
+ if (dynbuf == NULL)
+ goto error_return;
+
+ if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf,
+ (file_ptr) 0, s->_raw_size))
+ goto error_return;
+
+ elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
+ if (elfsec == -1)
+ goto error_return;
+ link = elf_elfsections (abfd)[elfsec]->sh_link;
+
+ extdyn = dynbuf;
+ extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn);
+ for (; extdyn < extdynend; extdyn++)
+ {
+ Elf_Internal_Dyn dyn;
+
+ elf_swap_dyn_in (abfd, extdyn, &dyn);
+ if (dyn.d_tag == DT_SONAME)
+ {
+ name = bfd_elf_string_from_elf_section (abfd, link,
+ dyn.d_un.d_val);
+ if (name == NULL)
+ goto error_return;
+ }
+ if (dyn.d_tag == DT_NEEDED)
+ {
+ struct bfd_link_needed_list *n, **pn;
+ char *fnm, *anm;
+
+ n = ((struct bfd_link_needed_list *)
+ bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
+ fnm = bfd_elf_string_from_elf_section (abfd, link,
+ dyn.d_un.d_val);
+ if (n == NULL || fnm == NULL)
+ goto error_return;
+ anm = bfd_alloc (abfd, strlen (fnm) + 1);
+ if (anm == NULL)
+ goto error_return;
+ strcpy (anm, fnm);
+ n->name = anm;
+ n->by = abfd;
+ n->next = NULL;
+ for (pn = &elf_hash_table (info)->needed;
+ *pn != NULL;
+ pn = &(*pn)->next)
+ ;
+ *pn = n;
+ }
+ }
+
+ free (dynbuf);
+ dynbuf = NULL;
+ }
+
+ /* We do not want to include any of the sections in a dynamic
+ object in the output file. We hack by simply clobbering the
+ list of sections in the BFD. This could be handled more
+ cleanly by, say, a new section flag; the existing
+ SEC_NEVER_LOAD flag is not the one we want, because that one
+ still implies that the section takes up space in the output
+ file. */
+ abfd->sections = NULL;
+ abfd->section_count = 0;
+
+ /* If this is the first dynamic object found in the link, create
+ the special sections required for dynamic linking. */
+ if (! elf_hash_table (info)->dynamic_sections_created)
+ {
+ if (! elf_link_create_dynamic_sections (abfd, info))
+ goto error_return;
+ }
+
+ if (add_needed)
+ {
+ /* Add a DT_NEEDED entry for this dynamic object. */
+ oldsize = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
+ strindex = _bfd_stringtab_add (elf_hash_table (info)->dynstr, name,
+ true, false);
+ if (strindex == (bfd_size_type) -1)
+ goto error_return;
+
+ if (oldsize == _bfd_stringtab_size (elf_hash_table (info)->dynstr))
+ {
+ asection *sdyn;
+ Elf_External_Dyn *dyncon, *dynconend;
+
+ /* The hash table size did not change, which means that
+ the dynamic object name was already entered. If we
+ have already included this dynamic object in the
+ link, just ignore it. There is no reason to include
+ a particular dynamic object more than once. */
+ sdyn = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
+ ".dynamic");
+ BFD_ASSERT (sdyn != NULL);
+
+ dyncon = (Elf_External_Dyn *) sdyn->contents;
+ dynconend = (Elf_External_Dyn *) (sdyn->contents +
+ sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+
+ elf_swap_dyn_in (elf_hash_table (info)->dynobj, dyncon,
+ &dyn);
+ if (dyn.d_tag == DT_NEEDED
+ && dyn.d_un.d_val == strindex)
+ {
+ if (buf != NULL)
+ free (buf);
+ if (extversym != NULL)
+ free (extversym);
+ return true;
+ }
+ }
+ }
+
+ if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex))
+ goto error_return;
+ }
+
+ /* Save the SONAME, if there is one, because sometimes the
+ linker emulation code will need to know it. */
+ if (*name == '\0')
+ name = bfd_get_filename (abfd);
+ elf_dt_name (abfd) = name;
+ }
+
+ if (bfd_seek (abfd,
+ hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym),
+ SEEK_SET) != 0
+ || (bfd_read ((PTR) buf, sizeof (Elf_External_Sym), extsymcount, abfd)
+ != extsymcount * sizeof (Elf_External_Sym)))
+ goto error_return;
+
+ weaks = NULL;
+
+ ever = extversym != NULL ? extversym + extsymoff : NULL;
+ esymend = buf + extsymcount;
+ for (esym = buf;
+ esym < esymend;
+ esym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL))
+ {
+ Elf_Internal_Sym sym;
+ int bind;
+ bfd_vma value;
+ asection *sec;
+ flagword flags;
+ const char *name;
+ struct elf_link_hash_entry *h;
+ boolean definition;
+ boolean size_change_ok, type_change_ok;
+ boolean new_weakdef;
+ unsigned int old_alignment;
+
+ elf_swap_symbol_in (abfd, esym, &sym);
+
+ flags = BSF_NO_FLAGS;
+ sec = NULL;
+ value = sym.st_value;
+ *sym_hash = NULL;
+
+ bind = ELF_ST_BIND (sym.st_info);
+ if (bind == STB_LOCAL)
+ {
+ /* This should be impossible, since ELF requires that all
+ global symbols follow all local symbols, and that sh_info
+ point to the first global symbol. Unfortunatealy, Irix 5
+ screws this up. */
+ continue;
+ }
+ else if (bind == STB_GLOBAL)
+ {
+ if (sym.st_shndx != SHN_UNDEF
+ && sym.st_shndx != SHN_COMMON)
+ flags = BSF_GLOBAL;
+ else
+ flags = 0;
+ }
+ else if (bind == STB_WEAK)
+ flags = BSF_WEAK;
+ else
+ {
+ /* Leave it up to the processor backend. */
+ }
+
+ if (sym.st_shndx == SHN_UNDEF)
+ sec = bfd_und_section_ptr;
+ else if (sym.st_shndx > 0 && sym.st_shndx < SHN_LORESERVE)
+ {
+ sec = section_from_elf_index (abfd, sym.st_shndx);
+ if (sec == NULL)
+ sec = bfd_abs_section_ptr;
+ else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
+ value -= sec->vma;
+ }
+ else if (sym.st_shndx == SHN_ABS)
+ sec = bfd_abs_section_ptr;
+ else if (sym.st_shndx == SHN_COMMON)
+ {
+ sec = bfd_com_section_ptr;
+ /* What ELF calls the size we call the value. What ELF
+ calls the value we call the alignment. */
+ value = sym.st_size;
+ }
+ else
+ {
+ /* Leave it up to the processor backend. */
+ }
+
+ name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name);
+ if (name == (const char *) NULL)
+ goto error_return;
+
+ if (add_symbol_hook)
+ {
+ if (! (*add_symbol_hook) (abfd, info, &sym, &name, &flags, &sec,
+ &value))
+ goto error_return;
+
+ /* The hook function sets the name to NULL if this symbol
+ should be skipped for some reason. */
+ if (name == (const char *) NULL)
+ continue;
+ }
+
+ /* Sanity check that all possibilities were handled. */
+ if (sec == (asection *) NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ if (bfd_is_und_section (sec)
+ || bfd_is_com_section (sec))
+ definition = false;
+ else
+ definition = true;
+
+ size_change_ok = false;
+ type_change_ok = get_elf_backend_data (abfd)->type_change_ok;
+ old_alignment = 0;
+ if (info->hash->creator->flavour == bfd_target_elf_flavour)
+ {
+ Elf_Internal_Versym iver;
+ unsigned int vernum = 0;
+ boolean override;
+
+ if (ever != NULL)
+ {
+ _bfd_elf_swap_versym_in (abfd, ever, &iver);
+ vernum = iver.vs_vers & VERSYM_VERSION;
+
+ /* If this is a hidden symbol, or if it is not version
+ 1, we append the version name to the symbol name.
+ However, we do not modify a non-hidden absolute
+ symbol, because it might be the version symbol
+ itself. FIXME: What if it isn't? */
+ if ((iver.vs_vers & VERSYM_HIDDEN) != 0
+ || (vernum > 1 && ! bfd_is_abs_section (sec)))
+ {
+ const char *verstr;
+ int namelen, newlen;
+ char *newname, *p;
+
+ if (sym.st_shndx != SHN_UNDEF)
+ {
+ if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info)
+ {
+ (*_bfd_error_handler)
+ (_("%s: %s: invalid version %u (max %d)"),
+ bfd_get_filename (abfd), name, vernum,
+ elf_tdata (abfd)->dynverdef_hdr.sh_info);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ else if (vernum > 1)
+ verstr =
+ elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
+ else
+ verstr = "";
+ }
+ else
+ {
+ /* We cannot simply test for the number of
+ entries in the VERNEED section since the
+ numbers for the needed versions do not start
+ at 0. */
+ Elf_Internal_Verneed *t;
+
+ verstr = NULL;
+ for (t = elf_tdata (abfd)->verref;
+ t != NULL;
+ t = t->vn_nextref)
+ {
+ Elf_Internal_Vernaux *a;
+
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ {
+ if (a->vna_other == vernum)
+ {
+ verstr = a->vna_nodename;
+ break;
+ }
+ }
+ if (a != NULL)
+ break;
+ }
+ if (verstr == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: %s: invalid needed version %d"),
+ bfd_get_filename (abfd), name, vernum);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ }
+
+ namelen = strlen (name);
+ newlen = namelen + strlen (verstr) + 2;
+ if ((iver.vs_vers & VERSYM_HIDDEN) == 0)
+ ++newlen;
+
+ newname = (char *) bfd_alloc (abfd, newlen);
+ if (newname == NULL)
+ goto error_return;
+ strcpy (newname, name);
+ p = newname + namelen;
+ *p++ = ELF_VER_CHR;
+ if ((iver.vs_vers & VERSYM_HIDDEN) == 0)
+ *p++ = ELF_VER_CHR;
+ strcpy (p, verstr);
+
+ name = newname;
+ }
+ }
+
+ if (! elf_merge_symbol (abfd, info, name, &sym, &sec, &value,
+ sym_hash, &override, &type_change_ok,
+ &size_change_ok))
+ goto error_return;
+
+ if (override)
+ definition = false;
+
+ h = *sym_hash;
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ /* Remember the old alignment if this is a common symbol, so
+ that we don't reduce the alignment later on. We can't
+ check later, because _bfd_generic_link_add_one_symbol
+ will set a default for the alignment which we want to
+ override. */
+ if (h->root.type == bfd_link_hash_common)
+ old_alignment = h->root.u.c.p->alignment_power;
+
+ if (elf_tdata (abfd)->verdef != NULL
+ && ! override
+ && vernum > 1
+ && definition)
+ h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1];
+ }
+
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, name, flags, sec, value, (const char *) NULL,
+ false, collect, (struct bfd_link_hash_entry **) sym_hash)))
+ goto error_return;
+
+ h = *sym_hash;
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ *sym_hash = h;
+
+ new_weakdef = false;
+ if (dynamic
+ && definition
+ && (flags & BSF_WEAK) != 0
+ && ELF_ST_TYPE (sym.st_info) != STT_FUNC
+ && info->hash->creator->flavour == bfd_target_elf_flavour
+ && h->weakdef == NULL)
+ {
+ /* Keep a list of all weak defined non function symbols from
+ a dynamic object, using the weakdef field. Later in this
+ function we will set the weakdef field to the correct
+ value. We only put non-function symbols from dynamic
+ objects on this list, because that happens to be the only
+ time we need to know the normal symbol corresponding to a
+ weak symbol, and the information is time consuming to
+ figure out. If the weakdef field is not already NULL,
+ then this symbol was already defined by some previous
+ dynamic object, and we will be using that previous
+ definition anyhow. */
+
+ h->weakdef = weaks;
+ weaks = h;
+ new_weakdef = true;
+ }
+
+ /* Set the alignment of a common symbol. */
+ if (sym.st_shndx == SHN_COMMON
+ && h->root.type == bfd_link_hash_common)
+ {
+ unsigned int align;
+
+ align = bfd_log2 (sym.st_value);
+ if (align > old_alignment)
+ h->root.u.c.p->alignment_power = align;
+ }
+
+ if (info->hash->creator->flavour == bfd_target_elf_flavour)
+ {
+ int old_flags;
+ boolean dynsym;
+ int new_flag;
+
+ /* Remember the symbol size and type. */
+ if (sym.st_size != 0
+ && (definition || h->size == 0))
+ {
+ if (h->size != 0 && h->size != sym.st_size && ! size_change_ok)
+ (*_bfd_error_handler)
+ (_("Warning: size of symbol `%s' changed from %lu to %lu in %s"),
+ name, (unsigned long) h->size, (unsigned long) sym.st_size,
+ bfd_get_filename (abfd));
+
+ h->size = sym.st_size;
+ }
+
+ /* If this is a common symbol, then we always want H->SIZE
+ to be the size of the common symbol. The code just above
+ won't fix the size if a common symbol becomes larger. We
+ don't warn about a size change here, because that is
+ covered by --warn-common. */
+ if (h->root.type == bfd_link_hash_common)
+ h->size = h->root.u.c.size;
+
+ if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE
+ && (definition || h->type == STT_NOTYPE))
+ {
+ if (h->type != STT_NOTYPE
+ && h->type != ELF_ST_TYPE (sym.st_info)
+ && ! type_change_ok)
+ (*_bfd_error_handler)
+ (_("Warning: type of symbol `%s' changed from %d to %d in %s"),
+ name, h->type, ELF_ST_TYPE (sym.st_info),
+ bfd_get_filename (abfd));
+
+ h->type = ELF_ST_TYPE (sym.st_info);
+ }
+
+ if (sym.st_other != 0
+ && (definition || h->other == 0))
+ h->other = sym.st_other;
+
+ /* Set a flag in the hash table entry indicating the type of
+ reference or definition we just found. Keep a count of
+ the number of dynamic symbols we find. A dynamic symbol
+ is one which is referenced or defined by both a regular
+ object and a shared object. */
+ old_flags = h->elf_link_hash_flags;
+ dynsym = false;
+ if (! dynamic)
+ {
+ if (! definition)
+ {
+ new_flag = ELF_LINK_HASH_REF_REGULAR;
+ if (bind != STB_WEAK)
+ new_flag |= ELF_LINK_HASH_REF_REGULAR_NONWEAK;
+ }
+ else
+ new_flag = ELF_LINK_HASH_DEF_REGULAR;
+ if (info->shared
+ || (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC
+ | ELF_LINK_HASH_REF_DYNAMIC)) != 0)
+ dynsym = true;
+ }
+ else
+ {
+ if (! definition)
+ new_flag = ELF_LINK_HASH_REF_DYNAMIC;
+ else
+ new_flag = ELF_LINK_HASH_DEF_DYNAMIC;
+ if ((old_flags & (ELF_LINK_HASH_DEF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR)) != 0
+ || (h->weakdef != NULL
+ && ! new_weakdef
+ && h->weakdef->dynindx != -1))
+ dynsym = true;
+ }
+
+ h->elf_link_hash_flags |= new_flag;
+
+ /* If this symbol has a version, and it is the default
+ version, we create an indirect symbol from the default
+ name to the fully decorated name. This will cause
+ external references which do not specify a version to be
+ bound to this version of the symbol. */
+ if (definition)
+ {
+ char *p;
+
+ p = strchr (name, ELF_VER_CHR);
+ if (p != NULL && p[1] == ELF_VER_CHR)
+ {
+ char *shortname;
+ struct elf_link_hash_entry *hi;
+ boolean override;
+
+ shortname = bfd_hash_allocate (&info->hash->table,
+ p - name + 1);
+ if (shortname == NULL)
+ goto error_return;
+ strncpy (shortname, name, p - name);
+ shortname[p - name] = '\0';
+
+ /* We are going to create a new symbol. Merge it
+ with any existing symbol with this name. For the
+ purposes of the merge, act as though we were
+ defining the symbol we just defined, although we
+ actually going to define an indirect symbol. */
+ type_change_ok = false;
+ size_change_ok = false;
+ if (! elf_merge_symbol (abfd, info, shortname, &sym, &sec,
+ &value, &hi, &override,
+ &type_change_ok, &size_change_ok))
+ goto error_return;
+
+ if (! override)
+ {
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, shortname, BSF_INDIRECT,
+ bfd_ind_section_ptr, (bfd_vma) 0, name, false,
+ collect, (struct bfd_link_hash_entry **) &hi)))
+ goto error_return;
+ }
+ else
+ {
+ /* In this case the symbol named SHORTNAME is
+ overriding the indirect symbol we want to
+ add. We were planning on making SHORTNAME an
+ indirect symbol referring to NAME. SHORTNAME
+ is the name without a version. NAME is the
+ fully versioned name, and it is the default
+ version.
+
+ Overriding means that we already saw a
+ definition for the symbol SHORTNAME in a
+ regular object, and it is overriding the
+ symbol defined in the dynamic object.
+
+ When this happens, we actually want to change
+ NAME, the symbol we just added, to refer to
+ SHORTNAME. This will cause references to
+ NAME in the shared object to become
+ references to SHORTNAME in the regular
+ object. This is what we expect when we
+ override a function in a shared object: that
+ the references in the shared object will be
+ mapped to the definition in the regular
+ object. */
+
+ while (hi->root.type == bfd_link_hash_indirect
+ || hi->root.type == bfd_link_hash_warning)
+ hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
+
+ h->root.type = bfd_link_hash_indirect;
+ h->root.u.i.link = (struct bfd_link_hash_entry *) hi;
+ if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)
+ {
+ h->elf_link_hash_flags &=~ ELF_LINK_HASH_DEF_DYNAMIC;
+ hi->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
+ if (hi->elf_link_hash_flags
+ & (ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_DEF_REGULAR))
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info,
+ hi))
+ goto error_return;
+ }
+ }
+
+ /* Now set HI to H, so that the following code
+ will set the other fields correctly. */
+ hi = h;
+ }
+
+ /* If there is a duplicate definition somewhere,
+ then HI may not point to an indirect symbol. We
+ will have reported an error to the user in that
+ case. */
+
+ if (hi->root.type == bfd_link_hash_indirect)
+ {
+ struct elf_link_hash_entry *ht;
+
+ /* If the symbol became indirect, then we assume
+ that we have not seen a definition before. */
+ BFD_ASSERT ((hi->elf_link_hash_flags
+ & (ELF_LINK_HASH_DEF_DYNAMIC
+ | ELF_LINK_HASH_DEF_REGULAR))
+ == 0);
+
+ ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
+
+ /* Copy down any references that we may have
+ already seen to the symbol which just became
+ indirect. */
+ ht->elf_link_hash_flags |=
+ (hi->elf_link_hash_flags
+ & (ELF_LINK_HASH_REF_DYNAMIC
+ | ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
+
+ /* Copy over the global and procedure linkage table
+ offset entries. These may have been already set
+ up by a check_relocs routine. */
+ if (ht->got.offset == (bfd_vma) -1)
+ {
+ ht->got.offset = hi->got.offset;
+ hi->got.offset = (bfd_vma) -1;
+ }
+ BFD_ASSERT (hi->got.offset == (bfd_vma) -1);
+
+ if (ht->plt.offset == (bfd_vma) -1)
+ {
+ ht->plt.offset = hi->plt.offset;
+ hi->plt.offset = (bfd_vma) -1;
+ }
+ BFD_ASSERT (hi->plt.offset == (bfd_vma) -1);
+
+ if (ht->dynindx == -1)
+ {
+ ht->dynindx = hi->dynindx;
+ ht->dynstr_index = hi->dynstr_index;
+ hi->dynindx = -1;
+ hi->dynstr_index = 0;
+ }
+ BFD_ASSERT (hi->dynindx == -1);
+
+ /* FIXME: There may be other information to copy
+ over for particular targets. */
+
+ /* See if the new flags lead us to realize that
+ the symbol must be dynamic. */
+ if (! dynsym)
+ {
+ if (! dynamic)
+ {
+ if (info->shared
+ || ((hi->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_DYNAMIC)
+ != 0))
+ dynsym = true;
+ }
+ else
+ {
+ if ((hi->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0)
+ dynsym = true;
+ }
+ }
+ }
+
+ /* We also need to define an indirection from the
+ nondefault version of the symbol. */
+
+ shortname = bfd_hash_allocate (&info->hash->table,
+ strlen (name));
+ if (shortname == NULL)
+ goto error_return;
+ strncpy (shortname, name, p - name);
+ strcpy (shortname + (p - name), p + 1);
+
+ /* Once again, merge with any existing symbol. */
+ type_change_ok = false;
+ size_change_ok = false;
+ if (! elf_merge_symbol (abfd, info, shortname, &sym, &sec,
+ &value, &hi, &override,
+ &type_change_ok, &size_change_ok))
+ goto error_return;
+
+ if (override)
+ {
+ /* Here SHORTNAME is a versioned name, so we
+ don't expect to see the type of override we
+ do in the case above. */
+ (*_bfd_error_handler)
+ (_("%s: warning: unexpected redefinition of `%s'"),
+ bfd_get_filename (abfd), shortname);
+ }
+ else
+ {
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, shortname, BSF_INDIRECT,
+ bfd_ind_section_ptr, (bfd_vma) 0, name, false,
+ collect, (struct bfd_link_hash_entry **) &hi)))
+ goto error_return;
+
+ /* If there is a duplicate definition somewhere,
+ then HI may not point to an indirect symbol.
+ We will have reported an error to the user in
+ that case. */
+
+ if (hi->root.type == bfd_link_hash_indirect)
+ {
+ /* If the symbol became indirect, then we
+ assume that we have not seen a definition
+ before. */
+ BFD_ASSERT ((hi->elf_link_hash_flags
+ & (ELF_LINK_HASH_DEF_DYNAMIC
+ | ELF_LINK_HASH_DEF_REGULAR))
+ == 0);
+
+ /* Copy down any references that we may have
+ already seen to the symbol which just
+ became indirect. */
+ h->elf_link_hash_flags |=
+ (hi->elf_link_hash_flags
+ & (ELF_LINK_HASH_REF_DYNAMIC
+ | ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
+
+ /* Copy over the global and procedure linkage
+ table offset entries. These may have been
+ already set up by a check_relocs routine. */
+ if (h->got.offset == (bfd_vma) -1)
+ {
+ h->got.offset = hi->got.offset;
+ hi->got.offset = (bfd_vma) -1;
+ }
+ BFD_ASSERT (hi->got.offset == (bfd_vma) -1);
+
+ if (h->plt.offset == (bfd_vma) -1)
+ {
+ h->plt.offset = hi->plt.offset;
+ hi->plt.offset = (bfd_vma) -1;
+ }
+ BFD_ASSERT (hi->got.offset == (bfd_vma) -1);
+
+ if (h->dynindx == -1)
+ {
+ h->dynindx = hi->dynindx;
+ h->dynstr_index = hi->dynstr_index;
+ hi->dynindx = -1;
+ hi->dynstr_index = 0;
+ }
+ BFD_ASSERT (hi->dynindx == -1);
+
+ /* FIXME: There may be other information to
+ copy over for particular targets. */
+
+ /* See if the new flags lead us to realize
+ that the symbol must be dynamic. */
+ if (! dynsym)
+ {
+ if (! dynamic)
+ {
+ if (info->shared
+ || ((hi->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_DYNAMIC)
+ != 0))
+ dynsym = true;
+ }
+ else
+ {
+ if ((hi->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0)
+ dynsym = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (dynsym && h->dynindx == -1)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info, h))
+ goto error_return;
+ if (h->weakdef != NULL
+ && ! new_weakdef
+ && h->weakdef->dynindx == -1)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info,
+ h->weakdef))
+ goto error_return;
+ }
+ }
+ }
+ }
+
+ /* Now set the weakdefs field correctly for all the weak defined
+ symbols we found. The only way to do this is to search all the
+ symbols. Since we only need the information for non functions in
+ dynamic objects, that's the only time we actually put anything on
+ the list WEAKS. We need this information so that if a regular
+ object refers to a symbol defined weakly in a dynamic object, the
+ real symbol in the dynamic object is also put in the dynamic
+ symbols; we also must arrange for both symbols to point to the
+ same memory location. We could handle the general case of symbol
+ aliasing, but a general symbol alias can only be generated in
+ assembler code, handling it correctly would be very time
+ consuming, and other ELF linkers don't handle general aliasing
+ either. */
+ while (weaks != NULL)
+ {
+ struct elf_link_hash_entry *hlook;
+ asection *slook;
+ bfd_vma vlook;
+ struct elf_link_hash_entry **hpp;
+ struct elf_link_hash_entry **hppend;
+
+ hlook = weaks;
+ weaks = hlook->weakdef;
+ hlook->weakdef = NULL;
+
+ BFD_ASSERT (hlook->root.type == bfd_link_hash_defined
+ || hlook->root.type == bfd_link_hash_defweak
+ || hlook->root.type == bfd_link_hash_common
+ || hlook->root.type == bfd_link_hash_indirect);
+ slook = hlook->root.u.def.section;
+ vlook = hlook->root.u.def.value;
+
+ hpp = elf_sym_hashes (abfd);
+ hppend = hpp + extsymcount;
+ for (; hpp < hppend; hpp++)
+ {
+ struct elf_link_hash_entry *h;
+
+ h = *hpp;
+ if (h != NULL && h != hlook
+ && h->root.type == bfd_link_hash_defined
+ && h->root.u.def.section == slook
+ && h->root.u.def.value == vlook)
+ {
+ hlook->weakdef = h;
+
+ /* If the weak definition is in the list of dynamic
+ symbols, make sure the real definition is put there
+ as well. */
+ if (hlook->dynindx != -1
+ && h->dynindx == -1)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info, h))
+ goto error_return;
+ }
+
+ /* If the real definition is in the list of dynamic
+ symbols, make sure the weak definition is put there
+ as well. If we don't do this, then the dynamic
+ loader might not merge the entries for the real
+ definition and the weak definition. */
+ if (h->dynindx != -1
+ && hlook->dynindx == -1)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info, hlook))
+ goto error_return;
+ }
+
+ break;
+ }
+ }
+ }
+
+ if (buf != NULL)
+ {
+ free (buf);
+ buf = NULL;
+ }
+
+ if (extversym != NULL)
+ {
+ free (extversym);
+ extversym = NULL;
+ }
+
+ /* If this object is the same format as the output object, and it is
+ not a shared library, then let the backend look through the
+ relocs.
+
+ This is required to build global offset table entries and to
+ arrange for dynamic relocs. It is not required for the
+ particular common case of linking non PIC code, even when linking
+ against shared libraries, but unfortunately there is no way of
+ knowing whether an object file has been compiled PIC or not.
+ Looking through the relocs is not particularly time consuming.
+ The problem is that we must either (1) keep the relocs in memory,
+ which causes the linker to require additional runtime memory or
+ (2) read the relocs twice from the input file, which wastes time.
+ This would be a good case for using mmap.
+
+ I have no idea how to handle linking PIC code into a file of a
+ different format. It probably can't be done. */
+ check_relocs = get_elf_backend_data (abfd)->check_relocs;
+ if (! dynamic
+ && abfd->xvec == info->hash->creator
+ && check_relocs != NULL)
+ {
+ asection *o;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ Elf_Internal_Rela *internal_relocs;
+ boolean ok;
+
+ if ((o->flags & SEC_RELOC) == 0
+ || o->reloc_count == 0
+ || ((info->strip == strip_all || info->strip == strip_debugger)
+ && (o->flags & SEC_DEBUGGING) != 0)
+ || bfd_is_abs_section (o->output_section))
+ continue;
+
+ internal_relocs = (NAME(_bfd_elf,link_read_relocs)
+ (abfd, o, (PTR) NULL,
+ (Elf_Internal_Rela *) NULL,
+ info->keep_memory));
+ if (internal_relocs == NULL)
+ goto error_return;
+
+ ok = (*check_relocs) (abfd, info, o, internal_relocs);
+
+ if (! info->keep_memory)
+ free (internal_relocs);
+
+ if (! ok)
+ goto error_return;
+ }
+ }
+
+ /* If this is a non-traditional, non-relocateable link, try to
+ optimize the handling of the .stab/.stabstr sections. */
+ if (! dynamic
+ && ! info->relocateable
+ && ! info->traditional_format
+ && info->hash->creator->flavour == bfd_target_elf_flavour
+ && (info->strip != strip_all && info->strip != strip_debugger))
+ {
+ asection *stab, *stabstr;
+
+ stab = bfd_get_section_by_name (abfd, ".stab");
+ if (stab != NULL)
+ {
+ stabstr = bfd_get_section_by_name (abfd, ".stabstr");
+
+ if (stabstr != NULL)
+ {
+ struct bfd_elf_section_data *secdata;
+
+ secdata = elf_section_data (stab);
+ if (! _bfd_link_section_stabs (abfd,
+ &elf_hash_table (info)->stab_info,
+ stab, stabstr,
+ &secdata->stab_info))
+ goto error_return;
+ }
+ }
+ }
+
+ return true;
+
+ error_return:
+ if (buf != NULL)
+ free (buf);
+ if (dynbuf != NULL)
+ free (dynbuf);
+ if (dynver != NULL)
+ free (dynver);
+ if (extversym != NULL)
+ free (extversym);
+ return false;
+}
+
+/* Create some sections which will be filled in with dynamic linking
+ information. ABFD is an input file which requires dynamic sections
+ to be created. The dynamic sections take up virtual memory space
+ when the final executable is run, so we need to create them before
+ addresses are assigned to the output sections. We work out the
+ actual contents and size of these sections later. */
+
+boolean
+elf_link_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+ struct elf_link_hash_entry *h;
+ struct elf_backend_data *bed;
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ return true;
+
+ /* Make sure that all dynamic sections use the same input BFD. */
+ if (elf_hash_table (info)->dynobj == NULL)
+ elf_hash_table (info)->dynobj = abfd;
+ else
+ abfd = elf_hash_table (info)->dynobj;
+
+ /* Note that we set the SEC_IN_MEMORY flag for all of these
+ sections. */
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+
+ /* A dynamically linked executable has a .interp section, but a
+ shared library does not. */
+ if (! info->shared)
+ {
+ s = bfd_make_section (abfd, ".interp");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY))
+ return false;
+ }
+
+ /* Create sections to hold version informations. These are removed
+ if they are not needed. */
+ s = bfd_make_section (abfd, ".gnu.version_d");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
+ return false;
+
+ s = bfd_make_section (abfd, ".gnu.version");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 1))
+ return false;
+
+ s = bfd_make_section (abfd, ".gnu.version_r");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
+ return false;
+
+ s = bfd_make_section (abfd, ".dynsym");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
+ return false;
+
+ s = bfd_make_section (abfd, ".dynstr");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY))
+ return false;
+
+ /* Create a strtab to hold the dynamic symbol names. */
+ if (elf_hash_table (info)->dynstr == NULL)
+ {
+ elf_hash_table (info)->dynstr = elf_stringtab_init ();
+ if (elf_hash_table (info)->dynstr == NULL)
+ return false;
+ }
+
+ s = bfd_make_section (abfd, ".dynamic");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
+ return false;
+
+ /* The special symbol _DYNAMIC is always set to the start of the
+ .dynamic section. This call occurs before we have processed the
+ symbols for any dynamic object, so we don't have to worry about
+ overriding a dynamic definition. We could set _DYNAMIC in a
+ linker script, but we only want to define it if we are, in fact,
+ creating a .dynamic section. We don't want to define it if there
+ is no .dynamic section, since on some ELF platforms the start up
+ code examines it to decide how to initialize the process. */
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "_DYNAMIC", BSF_GLOBAL, s, (bfd_vma) 0,
+ (const char *) NULL, false, get_elf_backend_data (abfd)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (info->shared
+ && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+
+ s = bfd_make_section (abfd, ".hash");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
+ return false;
+
+ /* Let the backend create the rest of the sections. This lets the
+ backend set the right flags. The backend will normally create
+ the .got and .plt sections. */
+ bed = get_elf_backend_data (abfd);
+ if (! (*bed->elf_backend_create_dynamic_sections) (abfd, info))
+ return false;
+
+ elf_hash_table (info)->dynamic_sections_created = true;
+
+ return true;
+}
+
+/* Add an entry to the .dynamic table. */
+
+boolean
+elf_add_dynamic_entry (info, tag, val)
+ struct bfd_link_info *info;
+ bfd_vma tag;
+ bfd_vma val;
+{
+ Elf_Internal_Dyn dyn;
+ bfd *dynobj;
+ asection *s;
+ size_t newsize;
+ bfd_byte *newcontents;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ s = bfd_get_section_by_name (dynobj, ".dynamic");
+ BFD_ASSERT (s != NULL);
+
+ newsize = s->_raw_size + sizeof (Elf_External_Dyn);
+ newcontents = (bfd_byte *) bfd_realloc (s->contents, newsize);
+ if (newcontents == NULL)
+ return false;
+
+ dyn.d_tag = tag;
+ dyn.d_un.d_val = val;
+ elf_swap_dyn_out (dynobj, &dyn,
+ (Elf_External_Dyn *) (newcontents + s->_raw_size));
+
+ s->_raw_size = newsize;
+ s->contents = newcontents;
+
+ return true;
+}
+
+
+/* Read and swap the relocs for a section. They may have been cached.
+ If the EXTERNAL_RELOCS and INTERNAL_RELOCS arguments are not NULL,
+ they are used as buffers to read into. They are known to be large
+ enough. If the INTERNAL_RELOCS relocs argument is NULL, the return
+ value is allocated using either malloc or bfd_alloc, according to
+ the KEEP_MEMORY argument. */
+
+Elf_Internal_Rela *
+NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs,
+ keep_memory)
+ bfd *abfd;
+ asection *o;
+ PTR external_relocs;
+ Elf_Internal_Rela *internal_relocs;
+ boolean keep_memory;
+{
+ Elf_Internal_Shdr *rel_hdr;
+ PTR alloc1 = NULL;
+ Elf_Internal_Rela *alloc2 = NULL;
+
+ if (elf_section_data (o)->relocs != NULL)
+ return elf_section_data (o)->relocs;
+
+ if (o->reloc_count == 0)
+ return NULL;
+
+ rel_hdr = &elf_section_data (o)->rel_hdr;
+
+ if (internal_relocs == NULL)
+ {
+ size_t size;
+
+ size = o->reloc_count * sizeof (Elf_Internal_Rela);
+ if (keep_memory)
+ internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size);
+ else
+ internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_malloc (size);
+ if (internal_relocs == NULL)
+ goto error_return;
+ }
+
+ if (external_relocs == NULL)
+ {
+ alloc1 = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
+ if (alloc1 == NULL)
+ goto error_return;
+ external_relocs = alloc1;
+ }
+
+ if ((bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0)
+ || (bfd_read (external_relocs, 1, rel_hdr->sh_size, abfd)
+ != rel_hdr->sh_size))
+ goto error_return;
+
+ /* Swap in the relocs. For convenience, we always produce an
+ Elf_Internal_Rela array; if the relocs are Rel, we set the addend
+ to 0. */
+ if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
+ {
+ Elf_External_Rel *erel;
+ Elf_External_Rel *erelend;
+ Elf_Internal_Rela *irela;
+
+ erel = (Elf_External_Rel *) external_relocs;
+ erelend = erel + o->reloc_count;
+ irela = internal_relocs;
+ for (; erel < erelend; erel++, irela++)
+ {
+ Elf_Internal_Rel irel;
+
+ elf_swap_reloc_in (abfd, erel, &irel);
+ irela->r_offset = irel.r_offset;
+ irela->r_info = irel.r_info;
+ irela->r_addend = 0;
+ }
+ }
+ else
+ {
+ Elf_External_Rela *erela;
+ Elf_External_Rela *erelaend;
+ Elf_Internal_Rela *irela;
+
+ BFD_ASSERT (rel_hdr->sh_entsize == sizeof (Elf_External_Rela));
+
+ erela = (Elf_External_Rela *) external_relocs;
+ erelaend = erela + o->reloc_count;
+ irela = internal_relocs;
+ for (; erela < erelaend; erela++, irela++)
+ elf_swap_reloca_in (abfd, erela, irela);
+ }
+
+ /* Cache the results for next time, if we can. */
+ if (keep_memory)
+ elf_section_data (o)->relocs = internal_relocs;
+
+ if (alloc1 != NULL)
+ free (alloc1);
+
+ /* Don't free alloc2, since if it was allocated we are passing it
+ back (under the name of internal_relocs). */
+
+ return internal_relocs;
+
+ error_return:
+ if (alloc1 != NULL)
+ free (alloc1);
+ if (alloc2 != NULL)
+ free (alloc2);
+ return NULL;
+}
+
+
+/* Record an assignment to a symbol made by a linker script. We need
+ this in case some dynamic object refers to this symbol. */
+
+/*ARGSUSED*/
+boolean
+NAME(bfd_elf,record_link_assignment) (output_bfd, info, name, provide)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ const char *name;
+ boolean provide;
+{
+ struct elf_link_hash_entry *h;
+
+ if (info->hash->creator->flavour != bfd_target_elf_flavour)
+ return true;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), name, true, true, false);
+ if (h == NULL)
+ return false;
+
+ if (h->root.type == bfd_link_hash_new)
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
+
+ /* If this symbol is being provided by the linker script, and it is
+ currently defined by a dynamic object, but not by a regular
+ object, then mark it as undefined so that the generic linker will
+ force the correct value. */
+ if (provide
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ h->root.type = bfd_link_hash_undefined;
+
+ /* If this symbol is not being provided by the linker script, and it is
+ currently defined by a dynamic object, but not by a regular object,
+ then clear out any version information because the symbol will not be
+ associated with the dynamic object any more. */
+ if (!provide
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ h->verinfo.verdef = NULL;
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+
+ if (((h->elf_link_hash_flags & (ELF_LINK_HASH_DEF_DYNAMIC
+ | ELF_LINK_HASH_REF_DYNAMIC)) != 0
+ || info->shared)
+ && h->dynindx == -1)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+
+ /* If this is a weak defined symbol, and we know a corresponding
+ real symbol from the same dynamic object, make sure the real
+ symbol is also made into a dynamic symbol. */
+ if (h->weakdef != NULL
+ && h->weakdef->dynindx == -1)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* This structure is used to pass information to
+ elf_link_assign_sym_version. */
+
+struct elf_assign_sym_version_info
+{
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* Version tree. */
+ struct bfd_elf_version_tree *verdefs;
+ /* Whether we are exporting all dynamic symbols. */
+ boolean export_dynamic;
+ /* Whether we removed any symbols from the dynamic symbol table. */
+ boolean removed_dynamic;
+ /* Whether we had a failure. */
+ boolean failed;
+};
+
+/* This structure is used to pass information to
+ elf_link_find_version_dependencies. */
+
+struct elf_find_verdep_info
+{
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* The number of dependencies. */
+ unsigned int vers;
+ /* Whether we had a failure. */
+ boolean failed;
+};
+
+/* Array used to determine the number of hash table buckets to use
+ based on the number of symbols there are. If there are fewer than
+ 3 symbols we use 1 bucket, fewer than 17 symbols we use 3 buckets,
+ fewer than 37 we use 17 buckets, and so forth. We never use more
+ than 32771 buckets. */
+
+static const size_t elf_buckets[] =
+{
+ 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209,
+ 16411, 32771, 0
+};
+
+/* Compute bucket count for hashing table. We do not use a static set
+ of possible tables sizes anymore. Instead we determine for all
+ possible reasonable sizes of the table the outcome (i.e., the
+ number of collisions etc) and choose the best solution. The
+ weighting functions are not too simple to allow the table to grow
+ without bounds. Instead one of the weighting factors is the size.
+ Therefore the result is always a good payoff between few collisions
+ (= short chain lengths) and table size. */
+static size_t
+compute_bucket_count (info)
+ struct bfd_link_info *info;
+{
+ size_t dynsymcount = elf_hash_table (info)->dynsymcount;
+ size_t best_size;
+ unsigned long int *hashcodes;
+ unsigned long int *hashcodesp;
+ unsigned long int i;
+
+ /* Compute the hash values for all exported symbols. At the same
+ time store the values in an array so that we could use them for
+ optimizations. */
+ hashcodes = (unsigned long int *) bfd_malloc (dynsymcount
+ * sizeof (unsigned long int));
+ if (hashcodes == NULL)
+ return 0;
+ hashcodesp = hashcodes;
+
+ /* Put all hash values in HASHCODES. */
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_collect_hash_codes, &hashcodesp);
+
+/* We have a problem here. The following code to optimize the table
+ size requires an integer type with more the 32 bits. If
+ BFD_HOST_U_64_BIT is set we know about such a type. */
+#ifdef BFD_HOST_U_64_BIT
+ if (info->optimize == true)
+ {
+ unsigned long int nsyms = hashcodesp - hashcodes;
+ size_t minsize;
+ size_t maxsize;
+ BFD_HOST_U_64_BIT best_chlen = ~((BFD_HOST_U_64_BIT) 0);
+ unsigned long int *counts ;
+
+ /* Possible optimization parameters: if we have NSYMS symbols we say
+ that the hashing table must at least have NSYMS/4 and at most
+ 2*NSYMS buckets. */
+ minsize = nsyms / 4;
+ if (minsize == 0)
+ minsize = 1;
+ best_size = maxsize = nsyms * 2;
+
+ /* Create array where we count the collisions in. We must use bfd_malloc
+ since the size could be large. */
+ counts = (unsigned long int *) bfd_malloc (maxsize
+ * sizeof (unsigned long int));
+ if (counts == NULL)
+ {
+ free (hashcodes);
+ return 0;
+ }
+
+ /* Compute the "optimal" size for the hash table. The criteria is a
+ minimal chain length. The minor criteria is (of course) the size
+ of the table. */
+ for (i = minsize; i < maxsize; ++i)
+ {
+ /* Walk through the array of hashcodes and count the collisions. */
+ BFD_HOST_U_64_BIT max;
+ unsigned long int j;
+ unsigned long int fact;
+
+ memset (counts, '\0', i * sizeof (unsigned long int));
+
+ /* Determine how often each hash bucket is used. */
+ for (j = 0; j < nsyms; ++j)
+ ++counts[hashcodes[j] % i];
+
+ /* For the weight function we need some information about the
+ pagesize on the target. This is information need not be 100%
+ accurate. Since this information is not available (so far) we
+ define it here to a reasonable default value. If it is crucial
+ to have a better value some day simply define this value. */
+# ifndef BFD_TARGET_PAGESIZE
+# define BFD_TARGET_PAGESIZE (4096)
+# endif
+
+ /* We in any case need 2 + NSYMS entries for the size values and
+ the chains. */
+ max = (2 + nsyms) * (ARCH_SIZE / 8);
+
+# if 1
+ /* Variant 1: optimize for short chains. We add the squares
+ of all the chain lengths (which favous many small chain
+ over a few long chains). */
+ for (j = 0; j < i; ++j)
+ max += counts[j] * counts[j];
+
+ /* This adds penalties for the overall size of the table. */
+ fact = i / (BFD_TARGET_PAGESIZE / (ARCH_SIZE / 8)) + 1;
+ max *= fact * fact;
+# else
+ /* Variant 2: Optimize a lot more for small table. Here we
+ also add squares of the size but we also add penalties for
+ empty slots (the +1 term). */
+ for (j = 0; j < i; ++j)
+ max += (1 + counts[j]) * (1 + counts[j]);
+
+ /* The overall size of the table is considered, but not as
+ strong as in variant 1, where it is squared. */
+ fact = i / (BFD_TARGET_PAGESIZE / (ARCH_SIZE / 8)) + 1;
+ max *= fact;
+# endif
+
+ /* Compare with current best results. */
+ if (max < best_chlen)
+ {
+ best_chlen = max;
+ best_size = i;
+ }
+ }
+
+ free (counts);
+ }
+ else
+#endif /* defined (BFD_HOST_U_64_BIT) */
+ {
+ /* This is the fallback solution if no 64bit type is available or if we
+ are not supposed to spend much time on optimizations. We select the
+ bucket count using a fixed set of numbers. */
+ for (i = 0; elf_buckets[i] != 0; i++)
+ {
+ best_size = elf_buckets[i];
+ if (dynsymcount < elf_buckets[i + 1])
+ break;
+ }
+ }
+
+ /* Free the arrays we needed. */
+ free (hashcodes);
+
+ return best_size;
+}
+
+/* Set up the sizes and contents of the ELF dynamic sections. This is
+ called by the ELF linker emulation before_allocation routine. We
+ must set the sizes of the sections before the linker sets the
+ addresses of the various sections. */
+
+boolean
+NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
+ export_dynamic, filter_shlib,
+ auxiliary_filters, info, sinterpptr,
+ verdefs)
+ bfd *output_bfd;
+ const char *soname;
+ const char *rpath;
+ boolean export_dynamic;
+ const char *filter_shlib;
+ const char * const *auxiliary_filters;
+ struct bfd_link_info *info;
+ asection **sinterpptr;
+ struct bfd_elf_version_tree *verdefs;
+{
+ bfd_size_type soname_indx;
+ bfd *dynobj;
+ struct elf_backend_data *bed;
+ bfd_size_type old_dynsymcount;
+ struct elf_assign_sym_version_info asvinfo;
+
+ *sinterpptr = NULL;
+
+ soname_indx = (bfd_size_type) -1;
+
+ if (info->hash->creator->flavour != bfd_target_elf_flavour)
+ return true;
+
+ /* The backend may have to create some sections regardless of whether
+ we're dynamic or not. */
+ bed = get_elf_backend_data (output_bfd);
+ if (bed->elf_backend_always_size_sections
+ && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
+ return false;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* If there were no dynamic objects in the link, there is nothing to
+ do here. */
+ if (dynobj == NULL)
+ return true;
+
+ /* If we are supposed to export all symbols into the dynamic symbol
+ table (this is not the normal case), then do so. */
+ if (export_dynamic)
+ {
+ struct elf_info_failed eif;
+
+ eif.failed = false;
+ eif.info = info;
+ elf_link_hash_traverse (elf_hash_table (info), elf_export_symbol,
+ (PTR) &eif);
+ if (eif.failed)
+ return false;
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ struct elf_info_failed eif;
+ struct elf_link_hash_entry *h;
+ bfd_size_type strsize;
+
+ *sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (*sinterpptr != NULL || info->shared);
+
+ if (soname != NULL)
+ {
+ soname_indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ soname, true, true);
+ if (soname_indx == (bfd_size_type) -1
+ || ! elf_add_dynamic_entry (info, DT_SONAME, soname_indx))
+ return false;
+ }
+
+ if (info->symbolic)
+ {
+ if (! elf_add_dynamic_entry (info, DT_SYMBOLIC, 0))
+ return false;
+ }
+
+ if (rpath != NULL)
+ {
+ bfd_size_type indx;
+
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr, rpath,
+ true, true);
+ if (indx == (bfd_size_type) -1
+ || ! elf_add_dynamic_entry (info, DT_RPATH, indx))
+ return false;
+ }
+
+ if (filter_shlib != NULL)
+ {
+ bfd_size_type indx;
+
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ filter_shlib, true, true);
+ if (indx == (bfd_size_type) -1
+ || ! elf_add_dynamic_entry (info, DT_FILTER, indx))
+ return false;
+ }
+
+ if (auxiliary_filters != NULL)
+ {
+ const char * const *p;
+
+ for (p = auxiliary_filters; *p != NULL; p++)
+ {
+ bfd_size_type indx;
+
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ *p, true, true);
+ if (indx == (bfd_size_type) -1
+ || ! elf_add_dynamic_entry (info, DT_AUXILIARY, indx))
+ return false;
+ }
+ }
+
+ /* Attach all the symbols to their version information. */
+ asvinfo.output_bfd = output_bfd;
+ asvinfo.info = info;
+ asvinfo.verdefs = verdefs;
+ asvinfo.export_dynamic = export_dynamic;
+ asvinfo.removed_dynamic = false;
+ asvinfo.failed = false;
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_assign_sym_version,
+ (PTR) &asvinfo);
+ if (asvinfo.failed)
+ return false;
+
+ /* Find all symbols which were defined in a dynamic object and make
+ the backend pick a reasonable value for them. */
+ eif.failed = false;
+ eif.info = info;
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_adjust_dynamic_symbol,
+ (PTR) &eif);
+ if (eif.failed)
+ return false;
+
+ /* Add some entries to the .dynamic section. We fill in some of the
+ values later, in elf_bfd_final_link, but we must add the entries
+ now so that we know the final size of the .dynamic section. */
+ h = elf_link_hash_lookup (elf_hash_table (info), "_init", false,
+ false, false);
+ if (h != NULL
+ && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_DEF_REGULAR)) != 0)
+ {
+ if (! elf_add_dynamic_entry (info, DT_INIT, 0))
+ return false;
+ }
+ h = elf_link_hash_lookup (elf_hash_table (info), "_fini", false,
+ false, false);
+ if (h != NULL
+ && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_DEF_REGULAR)) != 0)
+ {
+ if (! elf_add_dynamic_entry (info, DT_FINI, 0))
+ return false;
+ }
+ strsize = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
+ if (! elf_add_dynamic_entry (info, DT_HASH, 0)
+ || ! elf_add_dynamic_entry (info, DT_STRTAB, 0)
+ || ! elf_add_dynamic_entry (info, DT_SYMTAB, 0)
+ || ! elf_add_dynamic_entry (info, DT_STRSZ, strsize)
+ || ! elf_add_dynamic_entry (info, DT_SYMENT,
+ sizeof (Elf_External_Sym)))
+ return false;
+ }
+
+ /* The backend must work out the sizes of all the other dynamic
+ sections. */
+ old_dynsymcount = elf_hash_table (info)->dynsymcount;
+ if (bed->elf_backend_size_dynamic_sections
+ && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
+ return false;
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ size_t dynsymcount;
+ asection *s;
+ size_t bucketcount = 0;
+ Elf_Internal_Sym isym;
+
+ /* Set up the version definition section. */
+ s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
+ BFD_ASSERT (s != NULL);
+
+ /* We may have created additional version definitions if we are
+ just linking a regular application. */
+ verdefs = asvinfo.verdefs;
+
+ if (verdefs == NULL)
+ {
+ asection **spp;
+
+ /* Don't include this section in the output file. */
+ for (spp = &output_bfd->sections;
+ *spp != s->output_section;
+ spp = &(*spp)->next)
+ ;
+ *spp = s->output_section->next;
+ --output_bfd->section_count;
+ }
+ else
+ {
+ unsigned int cdefs;
+ bfd_size_type size;
+ struct bfd_elf_version_tree *t;
+ bfd_byte *p;
+ Elf_Internal_Verdef def;
+ Elf_Internal_Verdaux defaux;
+
+ if (asvinfo.removed_dynamic)
+ {
+ /* Some dynamic symbols were changed to be local
+ symbols. In this case, we renumber all of the
+ dynamic symbols, so that we don't have a hole. If
+ the backend changed dynsymcount, then assume that the
+ new symbols are at the start. This is the case on
+ the MIPS. FIXME: The names of the removed symbols
+ will still be in the dynamic string table, wasting
+ space. */
+ elf_hash_table (info)->dynsymcount =
+ 1 + (elf_hash_table (info)->dynsymcount - old_dynsymcount);
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_renumber_dynsyms,
+ (PTR) info);
+ }
+
+ cdefs = 0;
+ size = 0;
+
+ /* Make space for the base version. */
+ size += sizeof (Elf_External_Verdef);
+ size += sizeof (Elf_External_Verdaux);
+ ++cdefs;
+
+ for (t = verdefs; t != NULL; t = t->next)
+ {
+ struct bfd_elf_version_deps *n;
+
+ size += sizeof (Elf_External_Verdef);
+ size += sizeof (Elf_External_Verdaux);
+ ++cdefs;
+
+ for (n = t->deps; n != NULL; n = n->next)
+ size += sizeof (Elf_External_Verdaux);
+ }
+
+ s->_raw_size = size;
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+
+ /* Fill in the version definition section. */
+
+ p = s->contents;
+
+ def.vd_version = VER_DEF_CURRENT;
+ def.vd_flags = VER_FLG_BASE;
+ def.vd_ndx = 1;
+ def.vd_cnt = 1;
+ def.vd_aux = sizeof (Elf_External_Verdef);
+ def.vd_next = (sizeof (Elf_External_Verdef)
+ + sizeof (Elf_External_Verdaux));
+
+ if (soname_indx != (bfd_size_type) -1)
+ {
+ def.vd_hash = bfd_elf_hash ((const unsigned char *) soname);
+ defaux.vda_name = soname_indx;
+ }
+ else
+ {
+ const char *name;
+ bfd_size_type indx;
+
+ name = output_bfd->filename;
+ def.vd_hash = bfd_elf_hash ((const unsigned char *) name);
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ name, true, false);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ defaux.vda_name = indx;
+ }
+ defaux.vda_next = 0;
+
+ _bfd_elf_swap_verdef_out (output_bfd, &def,
+ (Elf_External_Verdef *)p);
+ p += sizeof (Elf_External_Verdef);
+ _bfd_elf_swap_verdaux_out (output_bfd, &defaux,
+ (Elf_External_Verdaux *) p);
+ p += sizeof (Elf_External_Verdaux);
+
+ for (t = verdefs; t != NULL; t = t->next)
+ {
+ unsigned int cdeps;
+ struct bfd_elf_version_deps *n;
+ struct elf_link_hash_entry *h;
+
+ cdeps = 0;
+ for (n = t->deps; n != NULL; n = n->next)
+ ++cdeps;
+
+ /* Add a symbol representing this version. */
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, dynobj, t->name, BSF_GLOBAL, bfd_abs_section_ptr,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (dynobj)->collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+ h->elf_link_hash_flags &= ~ ELF_LINK_NON_ELF;
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->type = STT_OBJECT;
+ h->verinfo.vertree = t;
+
+ if (! _bfd_elf_link_record_dynamic_symbol (info, h))
+ return false;
+
+ def.vd_version = VER_DEF_CURRENT;
+ def.vd_flags = 0;
+ if (t->globals == NULL && t->locals == NULL && ! t->used)
+ def.vd_flags |= VER_FLG_WEAK;
+ def.vd_ndx = t->vernum + 1;
+ def.vd_cnt = cdeps + 1;
+ def.vd_hash = bfd_elf_hash ((const unsigned char *) t->name);
+ def.vd_aux = sizeof (Elf_External_Verdef);
+ if (t->next != NULL)
+ def.vd_next = (sizeof (Elf_External_Verdef)
+ + (cdeps + 1) * sizeof (Elf_External_Verdaux));
+ else
+ def.vd_next = 0;
+
+ _bfd_elf_swap_verdef_out (output_bfd, &def,
+ (Elf_External_Verdef *) p);
+ p += sizeof (Elf_External_Verdef);
+
+ defaux.vda_name = h->dynstr_index;
+ if (t->deps == NULL)
+ defaux.vda_next = 0;
+ else
+ defaux.vda_next = sizeof (Elf_External_Verdaux);
+ t->name_indx = defaux.vda_name;
+
+ _bfd_elf_swap_verdaux_out (output_bfd, &defaux,
+ (Elf_External_Verdaux *) p);
+ p += sizeof (Elf_External_Verdaux);
+
+ for (n = t->deps; n != NULL; n = n->next)
+ {
+ if (n->version_needed == NULL)
+ {
+ /* This can happen if there was an error in the
+ version script. */
+ defaux.vda_name = 0;
+ }
+ else
+ defaux.vda_name = n->version_needed->name_indx;
+ if (n->next == NULL)
+ defaux.vda_next = 0;
+ else
+ defaux.vda_next = sizeof (Elf_External_Verdaux);
+
+ _bfd_elf_swap_verdaux_out (output_bfd, &defaux,
+ (Elf_External_Verdaux *) p);
+ p += sizeof (Elf_External_Verdaux);
+ }
+ }
+
+ if (! elf_add_dynamic_entry (info, DT_VERDEF, 0)
+ || ! elf_add_dynamic_entry (info, DT_VERDEFNUM, cdefs))
+ return false;
+
+ elf_tdata (output_bfd)->cverdefs = cdefs;
+ }
+
+ /* Work out the size of the version reference section. */
+
+ s = bfd_get_section_by_name (dynobj, ".gnu.version_r");
+ BFD_ASSERT (s != NULL);
+ {
+ struct elf_find_verdep_info sinfo;
+
+ sinfo.output_bfd = output_bfd;
+ sinfo.info = info;
+ sinfo.vers = elf_tdata (output_bfd)->cverdefs;
+ if (sinfo.vers == 0)
+ sinfo.vers = 1;
+ sinfo.failed = false;
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_find_version_dependencies,
+ (PTR) &sinfo);
+
+ if (elf_tdata (output_bfd)->verref == NULL)
+ {
+ asection **spp;
+
+ /* We don't have any version definitions, so we can just
+ remove the section. */
+
+ for (spp = &output_bfd->sections;
+ *spp != s->output_section;
+ spp = &(*spp)->next)
+ ;
+ *spp = s->output_section->next;
+ --output_bfd->section_count;
+ }
+ else
+ {
+ Elf_Internal_Verneed *t;
+ unsigned int size;
+ unsigned int crefs;
+ bfd_byte *p;
+
+ /* Build the version definition section. */
+ size = 0;
+ crefs = 0;
+ for (t = elf_tdata (output_bfd)->verref;
+ t != NULL;
+ t = t->vn_nextref)
+ {
+ Elf_Internal_Vernaux *a;
+
+ size += sizeof (Elf_External_Verneed);
+ ++crefs;
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ size += sizeof (Elf_External_Vernaux);
+ }
+
+ s->_raw_size = size;
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, size);
+ if (s->contents == NULL)
+ return false;
+
+ p = s->contents;
+ for (t = elf_tdata (output_bfd)->verref;
+ t != NULL;
+ t = t->vn_nextref)
+ {
+ unsigned int caux;
+ Elf_Internal_Vernaux *a;
+ bfd_size_type indx;
+
+ caux = 0;
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ ++caux;
+
+ t->vn_version = VER_NEED_CURRENT;
+ t->vn_cnt = caux;
+ if (elf_dt_name (t->vn_bfd) != NULL)
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ elf_dt_name (t->vn_bfd),
+ true, false);
+ else
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ t->vn_bfd->filename, true, false);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ t->vn_file = indx;
+ t->vn_aux = sizeof (Elf_External_Verneed);
+ if (t->vn_nextref == NULL)
+ t->vn_next = 0;
+ else
+ t->vn_next = (sizeof (Elf_External_Verneed)
+ + caux * sizeof (Elf_External_Vernaux));
+
+ _bfd_elf_swap_verneed_out (output_bfd, t,
+ (Elf_External_Verneed *) p);
+ p += sizeof (Elf_External_Verneed);
+
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ {
+ a->vna_hash = bfd_elf_hash ((const unsigned char *)
+ a->vna_nodename);
+ indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
+ a->vna_nodename, true, false);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ a->vna_name = indx;
+ if (a->vna_nextptr == NULL)
+ a->vna_next = 0;
+ else
+ a->vna_next = sizeof (Elf_External_Vernaux);
+
+ _bfd_elf_swap_vernaux_out (output_bfd, a,
+ (Elf_External_Vernaux *) p);
+ p += sizeof (Elf_External_Vernaux);
+ }
+ }
+
+ if (! elf_add_dynamic_entry (info, DT_VERNEED, 0)
+ || ! elf_add_dynamic_entry (info, DT_VERNEEDNUM, crefs))
+ return false;
+
+ elf_tdata (output_bfd)->cverrefs = crefs;
+ }
+ }
+
+ dynsymcount = elf_hash_table (info)->dynsymcount;
+
+ /* Work out the size of the symbol version section. */
+ s = bfd_get_section_by_name (dynobj, ".gnu.version");
+ BFD_ASSERT (s != NULL);
+ if (dynsymcount == 0
+ || (verdefs == NULL && elf_tdata (output_bfd)->verref == NULL))
+ {
+ asection **spp;
+
+ /* We don't need any symbol versions; just discard the
+ section. */
+ for (spp = &output_bfd->sections;
+ *spp != s->output_section;
+ spp = &(*spp)->next)
+ ;
+ *spp = s->output_section->next;
+ --output_bfd->section_count;
+ }
+ else
+ {
+ s->_raw_size = dynsymcount * sizeof (Elf_External_Versym);
+ s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+
+ if (! elf_add_dynamic_entry (info, DT_VERSYM, 0))
+ return false;
+ }
+
+ /* Set the size of the .dynsym and .hash sections. We counted
+ the number of dynamic symbols in elf_link_add_object_symbols.
+ We will build the contents of .dynsym and .hash when we build
+ the final symbol table, because until then we do not know the
+ correct value to give the symbols. We built the .dynstr
+ section as we went along in elf_link_add_object_symbols. */
+ s = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = dynsymcount * sizeof (Elf_External_Sym);
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+
+ /* The first entry in .dynsym is a dummy symbol. */
+ isym.st_value = 0;
+ isym.st_size = 0;
+ isym.st_name = 0;
+ isym.st_info = 0;
+ isym.st_other = 0;
+ isym.st_shndx = 0;
+ elf_swap_symbol_out (output_bfd, &isym,
+ (PTR) (Elf_External_Sym *) s->contents);
+
+ /* Compute the size of the hashing table. As a side effect this
+ computes the hash values for all the names we export. */
+ bucketcount = compute_bucket_count (info);
+
+ s = bfd_get_section_by_name (dynobj, ".hash");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = (2 + bucketcount + dynsymcount) * (ARCH_SIZE / 8);
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ memset (s->contents, 0, (size_t) s->_raw_size);
+
+ put_word (output_bfd, bucketcount, s->contents);
+ put_word (output_bfd, dynsymcount, s->contents + (ARCH_SIZE / 8));
+
+ elf_hash_table (info)->bucketcount = bucketcount;
+
+ s = bfd_get_section_by_name (dynobj, ".dynstr");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
+
+ if (! elf_add_dynamic_entry (info, DT_NULL, 0))
+ return false;
+ }
+
+ return true;
+}
+
+/* Fix up the flags for a symbol. This handles various cases which
+ can only be fixed after all the input files are seen. This is
+ currently called by both adjust_dynamic_symbol and
+ assign_sym_version, which is unnecessary but perhaps more robust in
+ the face of future changes. */
+
+static boolean
+elf_fix_symbol_flags (h, eif)
+ struct elf_link_hash_entry *h;
+ struct elf_info_failed *eif;
+{
+ /* If this symbol was mentioned in a non-ELF file, try to set
+ DEF_REGULAR and REF_REGULAR correctly. This is the only way to
+ permit a non-ELF file to correctly refer to a symbol defined in
+ an ELF dynamic object. */
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_ELF) != 0)
+ {
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ h->elf_link_hash_flags |= (ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK);
+ else
+ {
+ if (h->root.u.def.section->owner != NULL
+ && (bfd_get_flavour (h->root.u.def.section->owner)
+ == bfd_target_elf_flavour))
+ h->elf_link_hash_flags |= (ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK);
+ else
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ }
+
+ if (h->dynindx == -1
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0))
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
+ {
+ eif->failed = true;
+ return false;
+ }
+ }
+ }
+ else
+ {
+ /* Unfortunately, ELF_LINK_NON_ELF is only correct if the symbol
+ was first seen in a non-ELF file. Fortunately, if the symbol
+ was first seen in an ELF file, we're probably OK unless the
+ symbol was defined in a non-ELF file. Catch that case here.
+ FIXME: We're still in trouble if the symbol was first seen in
+ a dynamic object, and then later in a non-ELF regular object. */
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ && (h->root.u.def.section->owner != NULL
+ ? (bfd_get_flavour (h->root.u.def.section->owner)
+ != bfd_target_elf_flavour)
+ : (bfd_is_abs_section (h->root.u.def.section)
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) == 0)))
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ }
+
+ /* If this is a final link, and the symbol was defined as a common
+ symbol in a regular object file, and there was no definition in
+ any dynamic object, then the linker will have allocated space for
+ the symbol in a common section but the ELF_LINK_HASH_DEF_REGULAR
+ flag will not have been set. */
+ if (h->root.type == bfd_link_hash_defined
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+ && (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+
+ /* If -Bsymbolic was used (which means to bind references to global
+ symbols to the definition within the shared object), and this
+ symbol was defined in a regular object, then it actually doesn't
+ need a PLT entry. */
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
+ && eif->info->shared
+ && eif->info->symbolic
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
+ {
+ h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT;
+ h->plt.offset = (bfd_vma) -1;
+ }
+
+ return true;
+}
+
+/* Make the backend pick a good value for a dynamic symbol. This is
+ called via elf_link_hash_traverse, and also calls itself
+ recursively. */
+
+static boolean
+elf_adjust_dynamic_symbol (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ struct elf_info_failed *eif = (struct elf_info_failed *) data;
+ bfd *dynobj;
+ struct elf_backend_data *bed;
+
+ /* Ignore indirect symbols. These are added by the versioning code. */
+ if (h->root.type == bfd_link_hash_indirect)
+ return true;
+
+ /* Fix the symbol flags. */
+ if (! elf_fix_symbol_flags (h, eif))
+ return false;
+
+ /* If this symbol does not require a PLT entry, and it is not
+ defined by a dynamic object, or is not referenced by a regular
+ object, ignore it. We do have to handle a weak defined symbol,
+ even if no regular object refers to it, if we decided to add it
+ to the dynamic symbol table. FIXME: Do we normally need to worry
+ about symbols which are defined by one dynamic object and
+ referenced by another one? */
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0
+ && ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+ || ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
+ && (h->weakdef == NULL || h->weakdef->dynindx == -1))))
+ {
+ h->plt.offset = (bfd_vma) -1;
+ return true;
+ }
+
+ /* If we've already adjusted this symbol, don't do it again. This
+ can happen via a recursive call. */
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
+ return true;
+
+ /* Don't look at this symbol again. Note that we must set this
+ after checking the above conditions, because we may look at a
+ symbol once, decide not to do anything, and then get called
+ recursively later after REF_REGULAR is set below. */
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DYNAMIC_ADJUSTED;
+
+ /* If this is a weak definition, and we know a real definition, and
+ the real symbol is not itself defined by a regular object file,
+ then get a good value for the real definition. We handle the
+ real symbol first, for the convenience of the backend routine.
+
+ Note that there is a confusing case here. If the real definition
+ is defined by a regular object file, we don't get the real symbol
+ from the dynamic object, but we do get the weak symbol. If the
+ processor backend uses a COPY reloc, then if some routine in the
+ dynamic object changes the real symbol, we will not see that
+ change in the corresponding weak symbol. This is the way other
+ ELF linkers work as well, and seems to be a result of the shared
+ library model.
+
+ I will clarify this issue. Most SVR4 shared libraries define the
+ variable _timezone and define timezone as a weak synonym. The
+ tzset call changes _timezone. If you write
+ extern int timezone;
+ int _timezone = 5;
+ int main () { tzset (); printf ("%d %d\n", timezone, _timezone); }
+ you might expect that, since timezone is a synonym for _timezone,
+ the same number will print both times. However, if the processor
+ backend uses a COPY reloc, then actually timezone will be copied
+ into your process image, and, since you define _timezone
+ yourself, _timezone will not. Thus timezone and _timezone will
+ wind up at different memory locations. The tzset call will set
+ _timezone, leaving timezone unchanged. */
+
+ if (h->weakdef != NULL)
+ {
+ struct elf_link_hash_entry *weakdef;
+
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak);
+ weakdef = h->weakdef;
+ BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
+ || weakdef->root.type == bfd_link_hash_defweak);
+ BFD_ASSERT (weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC);
+ if ((weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
+ {
+ /* This symbol is defined by a regular object file, so we
+ will not do anything special. Clear weakdef for the
+ convenience of the processor backend. */
+ h->weakdef = NULL;
+ }
+ else
+ {
+ /* There is an implicit reference by a regular object file
+ via the weak symbol. */
+ weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
+ if (h->weakdef->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
+ weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR_NONWEAK;
+ if (! elf_adjust_dynamic_symbol (weakdef, (PTR) eif))
+ return false;
+ }
+ }
+
+ /* If a symbol has no type and no size and does not require a PLT
+ entry, then we are probably about to do the wrong thing here: we
+ are probably going to create a COPY reloc for an empty object.
+ This case can arise when a shared object is built with assembly
+ code, and the assembly code fails to set the symbol type. */
+ if (h->size == 0
+ && h->type == STT_NOTYPE
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
+ (*_bfd_error_handler)
+ (_("warning: type and size of dynamic symbol `%s' are not defined"),
+ h->root.root.string);
+
+ dynobj = elf_hash_table (eif->info)->dynobj;
+ bed = get_elf_backend_data (dynobj);
+ if (! (*bed->elf_backend_adjust_dynamic_symbol) (eif->info, h))
+ {
+ eif->failed = true;
+ return false;
+ }
+
+ return true;
+}
+
+/* This routine is used to export all defined symbols into the dynamic
+ symbol table. It is called via elf_link_hash_traverse. */
+
+static boolean
+elf_export_symbol (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ struct elf_info_failed *eif = (struct elf_info_failed *) data;
+
+ /* Ignore indirect symbols. These are added by the versioning code. */
+ if (h->root.type == bfd_link_hash_indirect)
+ return true;
+
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags
+ & (ELF_LINK_HASH_DEF_REGULAR | ELF_LINK_HASH_REF_REGULAR)) != 0)
+ {
+ if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
+ {
+ eif->failed = true;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Look through the symbols which are defined in other shared
+ libraries and referenced here. Update the list of version
+ dependencies. This will be put into the .gnu.version_r section.
+ This function is called via elf_link_hash_traverse. */
+
+static boolean
+elf_link_find_version_dependencies (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ struct elf_find_verdep_info *rinfo = (struct elf_find_verdep_info *) data;
+ Elf_Internal_Verneed *t;
+ Elf_Internal_Vernaux *a;
+
+ /* We only care about symbols defined in shared objects with version
+ information. */
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+ || h->dynindx == -1
+ || h->verinfo.verdef == NULL)
+ return true;
+
+ /* See if we already know about this version. */
+ for (t = elf_tdata (rinfo->output_bfd)->verref; t != NULL; t = t->vn_nextref)
+ {
+ if (t->vn_bfd != h->verinfo.verdef->vd_bfd)
+ continue;
+
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ if (a->vna_nodename == h->verinfo.verdef->vd_nodename)
+ return true;
+
+ break;
+ }
+
+ /* This is a new version. Add it to tree we are building. */
+
+ if (t == NULL)
+ {
+ t = (Elf_Internal_Verneed *) bfd_zalloc (rinfo->output_bfd, sizeof *t);
+ if (t == NULL)
+ {
+ rinfo->failed = true;
+ return false;
+ }
+
+ t->vn_bfd = h->verinfo.verdef->vd_bfd;
+ t->vn_nextref = elf_tdata (rinfo->output_bfd)->verref;
+ elf_tdata (rinfo->output_bfd)->verref = t;
+ }
+
+ a = (Elf_Internal_Vernaux *) bfd_zalloc (rinfo->output_bfd, sizeof *a);
+
+ /* Note that we are copying a string pointer here, and testing it
+ above. If bfd_elf_string_from_elf_section is ever changed to
+ discard the string data when low in memory, this will have to be
+ fixed. */
+ a->vna_nodename = h->verinfo.verdef->vd_nodename;
+
+ a->vna_flags = h->verinfo.verdef->vd_flags;
+ a->vna_nextptr = t->vn_auxptr;
+
+ h->verinfo.verdef->vd_exp_refno = rinfo->vers;
+ ++rinfo->vers;
+
+ a->vna_other = h->verinfo.verdef->vd_exp_refno + 1;
+
+ t->vn_auxptr = a;
+
+ return true;
+}
+
+/* Figure out appropriate versions for all the symbols. We may not
+ have the version number script until we have read all of the input
+ files, so until that point we don't know which symbols should be
+ local. This function is called via elf_link_hash_traverse. */
+
+static boolean
+elf_link_assign_sym_version (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ struct elf_assign_sym_version_info *sinfo =
+ (struct elf_assign_sym_version_info *) data;
+ struct bfd_link_info *info = sinfo->info;
+ struct elf_info_failed eif;
+ char *p;
+
+ /* Fix the symbol flags. */
+ eif.failed = false;
+ eif.info = info;
+ if (! elf_fix_symbol_flags (h, &eif))
+ {
+ if (eif.failed)
+ sinfo->failed = true;
+ return false;
+ }
+
+ /* We only need version numbers for symbols defined in regular
+ objects. */
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ return true;
+
+ p = strchr (h->root.root.string, ELF_VER_CHR);
+ if (p != NULL && h->verinfo.vertree == NULL)
+ {
+ struct bfd_elf_version_tree *t;
+ boolean hidden;
+
+ hidden = true;
+
+ /* There are two consecutive ELF_VER_CHR characters if this is
+ not a hidden symbol. */
+ ++p;
+ if (*p == ELF_VER_CHR)
+ {
+ hidden = false;
+ ++p;
+ }
+
+ /* If there is no version string, we can just return out. */
+ if (*p == '\0')
+ {
+ if (hidden)
+ h->elf_link_hash_flags |= ELF_LINK_HIDDEN;
+ return true;
+ }
+
+ /* Look for the version. If we find it, it is no longer weak. */
+ for (t = sinfo->verdefs; t != NULL; t = t->next)
+ {
+ if (strcmp (t->name, p) == 0)
+ {
+ int len;
+ char *alc;
+ struct bfd_elf_version_expr *d;
+
+ len = p - h->root.root.string;
+ alc = bfd_alloc (sinfo->output_bfd, len);
+ if (alc == NULL)
+ return false;
+ strncpy (alc, h->root.root.string, len - 1);
+ alc[len - 1] = '\0';
+ if (alc[len - 2] == ELF_VER_CHR)
+ alc[len - 2] = '\0';
+
+ h->verinfo.vertree = t;
+ t->used = true;
+ d = NULL;
+
+ if (t->globals != NULL)
+ {
+ for (d = t->globals; d != NULL; d = d->next)
+ if ((*d->match) (d, alc))
+ break;
+ }
+
+ /* See if there is anything to force this symbol to
+ local scope. */
+ if (d == NULL && t->locals != NULL)
+ {
+ for (d = t->locals; d != NULL; d = d->next)
+ {
+ if ((*d->match) (d, alc))
+ {
+ if (h->dynindx != -1
+ && info->shared
+ && ! sinfo->export_dynamic)
+ {
+ sinfo->removed_dynamic = true;
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ h->elf_link_hash_flags &=~
+ ELF_LINK_HASH_NEEDS_PLT;
+ h->dynindx = -1;
+ h->plt.offset = (bfd_vma) -1;
+ /* FIXME: The name of the symbol has
+ already been recorded in the dynamic
+ string table section. */
+ }
+
+ break;
+ }
+ }
+ }
+
+ bfd_release (sinfo->output_bfd, alc);
+ break;
+ }
+ }
+
+ /* If we are building an application, we need to create a
+ version node for this version. */
+ if (t == NULL && ! info->shared)
+ {
+ struct bfd_elf_version_tree **pp;
+ int version_index;
+
+ /* If we aren't going to export this symbol, we don't need
+ to worry about it. */
+ if (h->dynindx == -1)
+ return true;
+
+ t = ((struct bfd_elf_version_tree *)
+ bfd_alloc (sinfo->output_bfd, sizeof *t));
+ if (t == NULL)
+ {
+ sinfo->failed = true;
+ return false;
+ }
+
+ t->next = NULL;
+ t->name = p;
+ t->globals = NULL;
+ t->locals = NULL;
+ t->deps = NULL;
+ t->name_indx = (unsigned int) -1;
+ t->used = true;
+
+ version_index = 1;
+ for (pp = &sinfo->verdefs; *pp != NULL; pp = &(*pp)->next)
+ ++version_index;
+ t->vernum = version_index;
+
+ *pp = t;
+
+ h->verinfo.vertree = t;
+ }
+ else if (t == NULL)
+ {
+ /* We could not find the version for a symbol when
+ generating a shared archive. Return an error. */
+ (*_bfd_error_handler)
+ (_("%s: undefined versioned symbol name %s"),
+ bfd_get_filename (sinfo->output_bfd), h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ sinfo->failed = true;
+ return false;
+ }
+
+ if (hidden)
+ h->elf_link_hash_flags |= ELF_LINK_HIDDEN;
+ }
+
+ /* If we don't have a version for this symbol, see if we can find
+ something. */
+ if (h->verinfo.vertree == NULL && sinfo->verdefs != NULL)
+ {
+ struct bfd_elf_version_tree *t;
+ struct bfd_elf_version_tree *deflt;
+ struct bfd_elf_version_expr *d;
+
+ /* See if can find what version this symbol is in. If the
+ symbol is supposed to be local, then don't actually register
+ it. */
+ deflt = NULL;
+ for (t = sinfo->verdefs; t != NULL; t = t->next)
+ {
+ if (t->globals != NULL)
+ {
+ for (d = t->globals; d != NULL; d = d->next)
+ {
+ if ((*d->match) (d, h->root.root.string))
+ {
+ h->verinfo.vertree = t;
+ break;
+ }
+ }
+
+ if (d != NULL)
+ break;
+ }
+
+ if (t->locals != NULL)
+ {
+ for (d = t->locals; d != NULL; d = d->next)
+ {
+ if (d->pattern[0] == '*' && d->pattern[1] == '\0')
+ deflt = t;
+ else if ((*d->match) (d, h->root.root.string))
+ {
+ h->verinfo.vertree = t;
+ if (h->dynindx != -1
+ && info->shared
+ && ! sinfo->export_dynamic)
+ {
+ sinfo->removed_dynamic = true;
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT;
+ h->dynindx = -1;
+ h->plt.offset = (bfd_vma) -1;
+ /* FIXME: The name of the symbol has already
+ been recorded in the dynamic string table
+ section. */
+ }
+ break;
+ }
+ }
+
+ if (d != NULL)
+ break;
+ }
+ }
+
+ if (deflt != NULL && h->verinfo.vertree == NULL)
+ {
+ h->verinfo.vertree = deflt;
+ if (h->dynindx != -1
+ && info->shared
+ && ! sinfo->export_dynamic)
+ {
+ sinfo->removed_dynamic = true;
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT;
+ h->dynindx = -1;
+ h->plt.offset = (bfd_vma) -1;
+ /* FIXME: The name of the symbol has already been
+ recorded in the dynamic string table section. */
+ }
+ }
+ }
+
+ return true;
+}
+
+/* This function is used to renumber the dynamic symbols, if some of
+ them are removed because they are marked as local. This is called
+ via elf_link_hash_traverse. */
+
+static boolean
+elf_link_renumber_dynsyms (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ struct bfd_link_info *info = (struct bfd_link_info *) data;
+
+ if (h->dynindx != -1)
+ {
+ h->dynindx = elf_hash_table (info)->dynsymcount;
+ ++elf_hash_table (info)->dynsymcount;
+ }
+
+ return true;
+}
+
+/* Final phase of ELF linker. */
+
+/* A structure we use to avoid passing large numbers of arguments. */
+
+struct elf_final_link_info
+{
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* Symbol string table. */
+ struct bfd_strtab_hash *symstrtab;
+ /* .dynsym section. */
+ asection *dynsym_sec;
+ /* .hash section. */
+ asection *hash_sec;
+ /* symbol version section (.gnu.version). */
+ asection *symver_sec;
+ /* Buffer large enough to hold contents of any section. */
+ bfd_byte *contents;
+ /* Buffer large enough to hold external relocs of any section. */
+ PTR external_relocs;
+ /* Buffer large enough to hold internal relocs of any section. */
+ Elf_Internal_Rela *internal_relocs;
+ /* Buffer large enough to hold external local symbols of any input
+ BFD. */
+ Elf_External_Sym *external_syms;
+ /* Buffer large enough to hold internal local symbols of any input
+ BFD. */
+ Elf_Internal_Sym *internal_syms;
+ /* Array large enough to hold a symbol index for each local symbol
+ of any input BFD. */
+ long *indices;
+ /* Array large enough to hold a section pointer for each local
+ symbol of any input BFD. */
+ asection **sections;
+ /* Buffer to hold swapped out symbols. */
+ Elf_External_Sym *symbuf;
+ /* Number of swapped out symbols in buffer. */
+ size_t symbuf_count;
+ /* Number of symbols which fit in symbuf. */
+ size_t symbuf_size;
+};
+
+static boolean elf_link_output_sym
+ PARAMS ((struct elf_final_link_info *, const char *,
+ Elf_Internal_Sym *, asection *));
+static boolean elf_link_flush_output_syms
+ PARAMS ((struct elf_final_link_info *));
+static boolean elf_link_output_extsym
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_link_input_bfd
+ PARAMS ((struct elf_final_link_info *, bfd *));
+static boolean elf_reloc_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* This struct is used to pass information to elf_link_output_extsym. */
+
+struct elf_outext_info
+{
+ boolean failed;
+ boolean localsyms;
+ struct elf_final_link_info *finfo;
+};
+
+/* Do the final step of an ELF link. */
+
+boolean
+elf_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ boolean dynamic;
+ bfd *dynobj;
+ struct elf_final_link_info finfo;
+ register asection *o;
+ register struct bfd_link_order *p;
+ register bfd *sub;
+ size_t max_contents_size;
+ size_t max_external_reloc_size;
+ size_t max_internal_reloc_count;
+ size_t max_sym_count;
+ file_ptr off;
+ Elf_Internal_Sym elfsym;
+ unsigned int i;
+ Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Shdr *symstrtab_hdr;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ struct elf_outext_info eoinfo;
+
+ if (info->shared)
+ abfd->flags |= DYNAMIC;
+
+ dynamic = elf_hash_table (info)->dynamic_sections_created;
+ dynobj = elf_hash_table (info)->dynobj;
+
+ finfo.info = info;
+ finfo.output_bfd = abfd;
+ finfo.symstrtab = elf_stringtab_init ();
+ if (finfo.symstrtab == NULL)
+ return false;
+
+ if (! dynamic)
+ {
+ finfo.dynsym_sec = NULL;
+ finfo.hash_sec = NULL;
+ finfo.symver_sec = NULL;
+ }
+ else
+ {
+ finfo.dynsym_sec = bfd_get_section_by_name (dynobj, ".dynsym");
+ finfo.hash_sec = bfd_get_section_by_name (dynobj, ".hash");
+ BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL);
+ finfo.symver_sec = bfd_get_section_by_name (dynobj, ".gnu.version");
+ /* Note that it is OK if symver_sec is NULL. */
+ }
+
+ finfo.contents = NULL;
+ finfo.external_relocs = NULL;
+ finfo.internal_relocs = NULL;
+ finfo.external_syms = NULL;
+ finfo.internal_syms = NULL;
+ finfo.indices = NULL;
+ finfo.sections = NULL;
+ finfo.symbuf = NULL;
+ finfo.symbuf_count = 0;
+
+ /* Count up the number of relocations we will output for each output
+ section, so that we know the sizes of the reloc sections. We
+ also figure out some maximum sizes. */
+ max_contents_size = 0;
+ max_external_reloc_size = 0;
+ max_internal_reloc_count = 0;
+ max_sym_count = 0;
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ o->reloc_count = 0;
+
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ ++o->reloc_count;
+ else if (p->type == bfd_indirect_link_order)
+ {
+ asection *sec;
+
+ sec = p->u.indirect.section;
+
+ /* Mark all sections which are to be included in the
+ link. This will normally be every section. We need
+ to do this so that we can identify any sections which
+ the linker has decided to not include. */
+ sec->linker_mark = true;
+
+ if (info->relocateable)
+ o->reloc_count += sec->reloc_count;
+
+ if (sec->_raw_size > max_contents_size)
+ max_contents_size = sec->_raw_size;
+ if (sec->_cooked_size > max_contents_size)
+ max_contents_size = sec->_cooked_size;
+
+ /* We are interested in just local symbols, not all
+ symbols. */
+ if (bfd_get_flavour (sec->owner) == bfd_target_elf_flavour
+ && (sec->owner->flags & DYNAMIC) == 0)
+ {
+ size_t sym_count;
+
+ if (elf_bad_symtab (sec->owner))
+ sym_count = (elf_tdata (sec->owner)->symtab_hdr.sh_size
+ / sizeof (Elf_External_Sym));
+ else
+ sym_count = elf_tdata (sec->owner)->symtab_hdr.sh_info;
+
+ if (sym_count > max_sym_count)
+ max_sym_count = sym_count;
+
+ if ((sec->flags & SEC_RELOC) != 0)
+ {
+ size_t ext_size;
+
+ ext_size = elf_section_data (sec)->rel_hdr.sh_size;
+ if (ext_size > max_external_reloc_size)
+ max_external_reloc_size = ext_size;
+ if (sec->reloc_count > max_internal_reloc_count)
+ max_internal_reloc_count = sec->reloc_count;
+ }
+ }
+ }
+ }
+
+ if (o->reloc_count > 0)
+ o->flags |= SEC_RELOC;
+ else
+ {
+ /* Explicitly clear the SEC_RELOC flag. The linker tends to
+ set it (this is probably a bug) and if it is set
+ assign_section_numbers will create a reloc section. */
+ o->flags &=~ SEC_RELOC;
+ }
+
+ /* If the SEC_ALLOC flag is not set, force the section VMA to
+ zero. This is done in elf_fake_sections as well, but forcing
+ the VMA to 0 here will ensure that relocs against these
+ sections are handled correctly. */
+ if ((o->flags & SEC_ALLOC) == 0
+ && ! o->user_set_vma)
+ o->vma = 0;
+ }
+
+ /* Figure out the file positions for everything but the symbol table
+ and the relocs. We set symcount to force assign_section_numbers
+ to create a symbol table. */
+ bfd_get_symcount (abfd) = info->strip == strip_all ? 0 : 1;
+ BFD_ASSERT (! abfd->output_has_begun);
+ if (! _bfd_elf_compute_section_file_positions (abfd, info))
+ goto error_return;
+
+ /* That created the reloc sections. Set their sizes, and assign
+ them file positions, and allocate some buffers. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ Elf_Internal_Shdr *rel_hdr;
+ register struct elf_link_hash_entry **p, **pend;
+
+ rel_hdr = &elf_section_data (o)->rel_hdr;
+
+ rel_hdr->sh_size = rel_hdr->sh_entsize * o->reloc_count;
+
+ /* The contents field must last into write_object_contents,
+ so we allocate it with bfd_alloc rather than malloc. */
+ rel_hdr->contents = (PTR) bfd_alloc (abfd, rel_hdr->sh_size);
+ if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
+ goto error_return;
+
+ p = ((struct elf_link_hash_entry **)
+ bfd_malloc (o->reloc_count
+ * sizeof (struct elf_link_hash_entry *)));
+ if (p == NULL && o->reloc_count != 0)
+ goto error_return;
+ elf_section_data (o)->rel_hashes = p;
+ pend = p + o->reloc_count;
+ for (; p < pend; p++)
+ *p = NULL;
+
+ /* Use the reloc_count field as an index when outputting the
+ relocs. */
+ o->reloc_count = 0;
+ }
+ }
+
+ _bfd_elf_assign_file_positions_for_relocs (abfd);
+
+ /* We have now assigned file positions for all the sections except
+ .symtab and .strtab. We start the .symtab section at the current
+ file position, and write directly to it. We build the .strtab
+ section in memory. */
+ bfd_get_symcount (abfd) = 0;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ /* sh_name is set in prep_headers. */
+ symtab_hdr->sh_type = SHT_SYMTAB;
+ symtab_hdr->sh_flags = 0;
+ symtab_hdr->sh_addr = 0;
+ symtab_hdr->sh_size = 0;
+ symtab_hdr->sh_entsize = sizeof (Elf_External_Sym);
+ /* sh_link is set in assign_section_numbers. */
+ /* sh_info is set below. */
+ /* sh_offset is set just below. */
+ symtab_hdr->sh_addralign = 4; /* FIXME: system dependent? */
+
+ off = elf_tdata (abfd)->next_file_pos;
+ off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, true);
+
+ /* Note that at this point elf_tdata (abfd)->next_file_pos is
+ incorrect. We do not yet know the size of the .symtab section.
+ We correct next_file_pos below, after we do know the size. */
+
+ /* Allocate a buffer to hold swapped out symbols. This is to avoid
+ continuously seeking to the right position in the file. */
+ if (! info->keep_memory || max_sym_count < 20)
+ finfo.symbuf_size = 20;
+ else
+ finfo.symbuf_size = max_sym_count;
+ finfo.symbuf = ((Elf_External_Sym *)
+ bfd_malloc (finfo.symbuf_size * sizeof (Elf_External_Sym)));
+ if (finfo.symbuf == NULL)
+ goto error_return;
+
+ /* Start writing out the symbol table. The first symbol is always a
+ dummy symbol. */
+ if (info->strip != strip_all || info->relocateable)
+ {
+ elfsym.st_value = 0;
+ elfsym.st_size = 0;
+ elfsym.st_info = 0;
+ elfsym.st_other = 0;
+ elfsym.st_shndx = SHN_UNDEF;
+ if (! elf_link_output_sym (&finfo, (const char *) NULL,
+ &elfsym, bfd_und_section_ptr))
+ goto error_return;
+ }
+
+#if 0
+ /* Some standard ELF linkers do this, but we don't because it causes
+ bootstrap comparison failures. */
+ /* Output a file symbol for the output file as the second symbol.
+ We output this even if we are discarding local symbols, although
+ I'm not sure if this is correct. */
+ elfsym.st_value = 0;
+ elfsym.st_size = 0;
+ elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
+ elfsym.st_other = 0;
+ elfsym.st_shndx = SHN_ABS;
+ if (! elf_link_output_sym (&finfo, bfd_get_filename (abfd),
+ &elfsym, bfd_abs_section_ptr))
+ goto error_return;
+#endif
+
+ /* Output a symbol for each section. We output these even if we are
+ discarding local symbols, since they are used for relocs. These
+ symbols have no names. We store the index of each one in the
+ index field of the section, so that we can find it again when
+ outputting relocs. */
+ if (info->strip != strip_all || info->relocateable)
+ {
+ elfsym.st_size = 0;
+ elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+ elfsym.st_other = 0;
+ for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
+ {
+ o = section_from_elf_index (abfd, i);
+ if (o != NULL)
+ o->target_index = bfd_get_symcount (abfd);
+ elfsym.st_shndx = i;
+ if (info->relocateable || o == NULL)
+ elfsym.st_value = 0;
+ else
+ elfsym.st_value = o->vma;
+ if (! elf_link_output_sym (&finfo, (const char *) NULL,
+ &elfsym, o))
+ goto error_return;
+ }
+ }
+
+ /* Allocate some memory to hold information read in from the input
+ files. */
+ finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+ finfo.external_relocs = (PTR) bfd_malloc (max_external_reloc_size);
+ finfo.internal_relocs = ((Elf_Internal_Rela *)
+ bfd_malloc (max_internal_reloc_count
+ * sizeof (Elf_Internal_Rela)));
+ finfo.external_syms = ((Elf_External_Sym *)
+ bfd_malloc (max_sym_count
+ * sizeof (Elf_External_Sym)));
+ finfo.internal_syms = ((Elf_Internal_Sym *)
+ bfd_malloc (max_sym_count
+ * sizeof (Elf_Internal_Sym)));
+ finfo.indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
+ finfo.sections = ((asection **)
+ bfd_malloc (max_sym_count * sizeof (asection *)));
+ if ((finfo.contents == NULL && max_contents_size != 0)
+ || (finfo.external_relocs == NULL && max_external_reloc_size != 0)
+ || (finfo.internal_relocs == NULL && max_internal_reloc_count != 0)
+ || (finfo.external_syms == NULL && max_sym_count != 0)
+ || (finfo.internal_syms == NULL && max_sym_count != 0)
+ || (finfo.indices == NULL && max_sym_count != 0)
+ || (finfo.sections == NULL && max_sym_count != 0))
+ goto error_return;
+
+ /* Since ELF permits relocations to be against local symbols, we
+ must have the local symbols available when we do the relocations.
+ Since we would rather only read the local symbols once, and we
+ would rather not keep them in memory, we handle all the
+ relocations for a single input file at the same time.
+
+ Unfortunately, there is no way to know the total number of local
+ symbols until we have seen all of them, and the local symbol
+ indices precede the global symbol indices. This means that when
+ we are generating relocateable output, and we see a reloc against
+ a global symbol, we can not know the symbol index until we have
+ finished examining all the local symbols to see which ones we are
+ going to output. To deal with this, we keep the relocations in
+ memory, and don't output them until the end of the link. This is
+ an unfortunate waste of memory, but I don't see a good way around
+ it. Fortunately, it only happens when performing a relocateable
+ link, which is not the common case. FIXME: If keep_memory is set
+ we could write the relocs out and then read them again; I don't
+ know how bad the memory loss will be. */
+
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ sub->output_has_begun = false;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order
+ && (bfd_get_flavour (p->u.indirect.section->owner)
+ == bfd_target_elf_flavour))
+ {
+ sub = p->u.indirect.section->owner;
+ if (! sub->output_has_begun)
+ {
+ if (! elf_link_input_bfd (&finfo, sub))
+ goto error_return;
+ sub->output_has_begun = true;
+ }
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ if (! elf_reloc_link_order (abfd, info, o, p))
+ goto error_return;
+ }
+ else
+ {
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ goto error_return;
+ }
+ }
+ }
+
+ /* That wrote out all the local symbols. Finish up the symbol table
+ with the global symbols. */
+
+ if (info->strip != strip_all && info->shared)
+ {
+ /* Output any global symbols that got converted to local in a
+ version script. We do this in a separate step since ELF
+ requires all local symbols to appear prior to any global
+ symbols. FIXME: We should only do this if some global
+ symbols were, in fact, converted to become local. FIXME:
+ Will this work correctly with the Irix 5 linker? */
+ eoinfo.failed = false;
+ eoinfo.finfo = &finfo;
+ eoinfo.localsyms = true;
+ elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
+ (PTR) &eoinfo);
+ if (eoinfo.failed)
+ return false;
+ }
+
+ /* The sh_info field records the index of the first non local
+ symbol. */
+ symtab_hdr->sh_info = bfd_get_symcount (abfd);
+ if (dynamic)
+ elf_section_data (finfo.dynsym_sec->output_section)->this_hdr.sh_info = 1;
+
+ /* We get the global symbols from the hash table. */
+ eoinfo.failed = false;
+ eoinfo.localsyms = false;
+ eoinfo.finfo = &finfo;
+ elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
+ (PTR) &eoinfo);
+ if (eoinfo.failed)
+ return false;
+
+ /* Flush all symbols to the file. */
+ if (! elf_link_flush_output_syms (&finfo))
+ return false;
+
+ /* Now we know the size of the symtab section. */
+ off += symtab_hdr->sh_size;
+
+ /* Finish up and write out the symbol string table (.strtab)
+ section. */
+ symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
+ /* sh_name was set in prep_headers. */
+ symstrtab_hdr->sh_type = SHT_STRTAB;
+ symstrtab_hdr->sh_flags = 0;
+ symstrtab_hdr->sh_addr = 0;
+ symstrtab_hdr->sh_size = _bfd_stringtab_size (finfo.symstrtab);
+ symstrtab_hdr->sh_entsize = 0;
+ symstrtab_hdr->sh_link = 0;
+ symstrtab_hdr->sh_info = 0;
+ /* sh_offset is set just below. */
+ symstrtab_hdr->sh_addralign = 1;
+
+ off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, true);
+ elf_tdata (abfd)->next_file_pos = off;
+
+ if (bfd_get_symcount (abfd) > 0)
+ {
+ if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0
+ || ! _bfd_stringtab_emit (abfd, finfo.symstrtab))
+ return false;
+ }
+
+ /* Adjust the relocs to have the correct symbol indices. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct elf_link_hash_entry **rel_hash;
+ Elf_Internal_Shdr *rel_hdr;
+
+ if ((o->flags & SEC_RELOC) == 0)
+ continue;
+
+ rel_hash = elf_section_data (o)->rel_hashes;
+ rel_hdr = &elf_section_data (o)->rel_hdr;
+ for (i = 0; i < o->reloc_count; i++, rel_hash++)
+ {
+ if (*rel_hash == NULL)
+ continue;
+
+ BFD_ASSERT ((*rel_hash)->indx >= 0);
+
+ if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
+ {
+ Elf_External_Rel *erel;
+ Elf_Internal_Rel irel;
+
+ erel = (Elf_External_Rel *) rel_hdr->contents + i;
+ elf_swap_reloc_in (abfd, erel, &irel);
+ irel.r_info = ELF_R_INFO ((*rel_hash)->indx,
+ ELF_R_TYPE (irel.r_info));
+ elf_swap_reloc_out (abfd, &irel, erel);
+ }
+ else
+ {
+ Elf_External_Rela *erela;
+ Elf_Internal_Rela irela;
+
+ BFD_ASSERT (rel_hdr->sh_entsize
+ == sizeof (Elf_External_Rela));
+
+ erela = (Elf_External_Rela *) rel_hdr->contents + i;
+ elf_swap_reloca_in (abfd, erela, &irela);
+ irela.r_info = ELF_R_INFO ((*rel_hash)->indx,
+ ELF_R_TYPE (irela.r_info));
+ elf_swap_reloca_out (abfd, &irela, erela);
+ }
+ }
+
+ /* Set the reloc_count field to 0 to prevent write_relocs from
+ trying to swap the relocs out itself. */
+ o->reloc_count = 0;
+ }
+
+ /* If we are linking against a dynamic object, or generating a
+ shared library, finish up the dynamic linking information. */
+ if (dynamic)
+ {
+ Elf_External_Dyn *dyncon, *dynconend;
+
+ /* Fix up .dynamic entries. */
+ o = bfd_get_section_by_name (dynobj, ".dynamic");
+ BFD_ASSERT (o != NULL);
+
+ dyncon = (Elf_External_Dyn *) o->contents;
+ dynconend = (Elf_External_Dyn *) (o->contents + o->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ unsigned int type;
+
+ elf_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ break;
+
+ /* SVR4 linkers seem to set DT_INIT and DT_FINI based on
+ magic _init and _fini symbols. This is pretty ugly,
+ but we are compatible. */
+ case DT_INIT:
+ name = "_init";
+ goto get_sym;
+ case DT_FINI:
+ name = "_fini";
+ get_sym:
+ {
+ struct elf_link_hash_entry *h;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), name,
+ false, false, true);
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ dyn.d_un.d_val = h->root.u.def.value;
+ o = h->root.u.def.section;
+ if (o->output_section != NULL)
+ dyn.d_un.d_val += (o->output_section->vma
+ + o->output_offset);
+ else
+ {
+ /* The symbol is imported from another shared
+ library and does not apply to this one. */
+ dyn.d_un.d_val = 0;
+ }
+
+ elf_swap_dyn_out (dynobj, &dyn, dyncon);
+ }
+ }
+ break;
+
+ case DT_HASH:
+ name = ".hash";
+ goto get_vma;
+ case DT_STRTAB:
+ name = ".dynstr";
+ goto get_vma;
+ case DT_SYMTAB:
+ name = ".dynsym";
+ goto get_vma;
+ case DT_VERDEF:
+ name = ".gnu.version_d";
+ goto get_vma;
+ case DT_VERNEED:
+ name = ".gnu.version_r";
+ goto get_vma;
+ case DT_VERSYM:
+ name = ".gnu.version";
+ get_vma:
+ o = bfd_get_section_by_name (abfd, name);
+ BFD_ASSERT (o != NULL);
+ dyn.d_un.d_ptr = o->vma;
+ elf_swap_dyn_out (dynobj, &dyn, dyncon);
+ break;
+
+ case DT_REL:
+ case DT_RELA:
+ case DT_RELSZ:
+ case DT_RELASZ:
+ if (dyn.d_tag == DT_REL || dyn.d_tag == DT_RELSZ)
+ type = SHT_REL;
+ else
+ type = SHT_RELA;
+ dyn.d_un.d_val = 0;
+ for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
+ {
+ Elf_Internal_Shdr *hdr;
+
+ hdr = elf_elfsections (abfd)[i];
+ if (hdr->sh_type == type
+ && (hdr->sh_flags & SHF_ALLOC) != 0)
+ {
+ if (dyn.d_tag == DT_RELSZ || dyn.d_tag == DT_RELASZ)
+ dyn.d_un.d_val += hdr->sh_size;
+ else
+ {
+ if (dyn.d_un.d_val == 0
+ || hdr->sh_addr < dyn.d_un.d_val)
+ dyn.d_un.d_val = hdr->sh_addr;
+ }
+ }
+ }
+ elf_swap_dyn_out (dynobj, &dyn, dyncon);
+ break;
+ }
+ }
+ }
+
+ /* If we have created any dynamic sections, then output them. */
+ if (dynobj != NULL)
+ {
+ if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
+ goto error_return;
+
+ for (o = dynobj->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_HAS_CONTENTS) == 0
+ || o->_raw_size == 0)
+ continue;
+ if ((o->flags & SEC_LINKER_CREATED) == 0)
+ {
+ /* At this point, we are only interested in sections
+ created by elf_link_create_dynamic_sections. */
+ continue;
+ }
+ if ((elf_section_data (o->output_section)->this_hdr.sh_type
+ != SHT_STRTAB)
+ || strcmp (bfd_get_section_name (abfd, o), ".dynstr") != 0)
+ {
+ if (! bfd_set_section_contents (abfd, o->output_section,
+ o->contents, o->output_offset,
+ o->_raw_size))
+ goto error_return;
+ }
+ else
+ {
+ file_ptr off;
+
+ /* The contents of the .dynstr section are actually in a
+ stringtab. */
+ off = elf_section_data (o->output_section)->this_hdr.sh_offset;
+ if (bfd_seek (abfd, off, SEEK_SET) != 0
+ || ! _bfd_stringtab_emit (abfd,
+ elf_hash_table (info)->dynstr))
+ goto error_return;
+ }
+ }
+ }
+
+ /* If we have optimized stabs strings, output them. */
+ if (elf_hash_table (info)->stab_info != NULL)
+ {
+ if (! _bfd_write_stab_strings (abfd, &elf_hash_table (info)->stab_info))
+ goto error_return;
+ }
+
+ if (finfo.symstrtab != NULL)
+ _bfd_stringtab_free (finfo.symstrtab);
+ if (finfo.contents != NULL)
+ free (finfo.contents);
+ if (finfo.external_relocs != NULL)
+ free (finfo.external_relocs);
+ if (finfo.internal_relocs != NULL)
+ free (finfo.internal_relocs);
+ if (finfo.external_syms != NULL)
+ free (finfo.external_syms);
+ if (finfo.internal_syms != NULL)
+ free (finfo.internal_syms);
+ if (finfo.indices != NULL)
+ free (finfo.indices);
+ if (finfo.sections != NULL)
+ free (finfo.sections);
+ if (finfo.symbuf != NULL)
+ free (finfo.symbuf);
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_RELOC) != 0
+ && elf_section_data (o)->rel_hashes != NULL)
+ free (elf_section_data (o)->rel_hashes);
+ }
+
+ elf_tdata (abfd)->linker = true;
+
+ return true;
+
+ error_return:
+ if (finfo.symstrtab != NULL)
+ _bfd_stringtab_free (finfo.symstrtab);
+ if (finfo.contents != NULL)
+ free (finfo.contents);
+ if (finfo.external_relocs != NULL)
+ free (finfo.external_relocs);
+ if (finfo.internal_relocs != NULL)
+ free (finfo.internal_relocs);
+ if (finfo.external_syms != NULL)
+ free (finfo.external_syms);
+ if (finfo.internal_syms != NULL)
+ free (finfo.internal_syms);
+ if (finfo.indices != NULL)
+ free (finfo.indices);
+ if (finfo.sections != NULL)
+ free (finfo.sections);
+ if (finfo.symbuf != NULL)
+ free (finfo.symbuf);
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_RELOC) != 0
+ && elf_section_data (o)->rel_hashes != NULL)
+ free (elf_section_data (o)->rel_hashes);
+ }
+
+ return false;
+}
+
+/* Add a symbol to the output symbol table. */
+
+static boolean
+elf_link_output_sym (finfo, name, elfsym, input_sec)
+ struct elf_final_link_info *finfo;
+ const char *name;
+ Elf_Internal_Sym *elfsym;
+ asection *input_sec;
+{
+ boolean (*output_symbol_hook) PARAMS ((bfd *,
+ struct bfd_link_info *info,
+ const char *,
+ Elf_Internal_Sym *,
+ asection *));
+
+ output_symbol_hook = get_elf_backend_data (finfo->output_bfd)->
+ elf_backend_link_output_symbol_hook;
+ if (output_symbol_hook != NULL)
+ {
+ if (! ((*output_symbol_hook)
+ (finfo->output_bfd, finfo->info, name, elfsym, input_sec)))
+ return false;
+ }
+
+ if (name == (const char *) NULL || *name == '\0')
+ elfsym->st_name = 0;
+ else if (input_sec->flags & SEC_EXCLUDE)
+ elfsym->st_name = 0;
+ else
+ {
+ elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab,
+ name, true,
+ false);
+ if (elfsym->st_name == (unsigned long) -1)
+ return false;
+ }
+
+ if (finfo->symbuf_count >= finfo->symbuf_size)
+ {
+ if (! elf_link_flush_output_syms (finfo))
+ return false;
+ }
+
+ elf_swap_symbol_out (finfo->output_bfd, elfsym,
+ (PTR) (finfo->symbuf + finfo->symbuf_count));
+ ++finfo->symbuf_count;
+
+ ++ bfd_get_symcount (finfo->output_bfd);
+
+ return true;
+}
+
+/* Flush the output symbols to the file. */
+
+static boolean
+elf_link_flush_output_syms (finfo)
+ struct elf_final_link_info *finfo;
+{
+ if (finfo->symbuf_count > 0)
+ {
+ Elf_Internal_Shdr *symtab;
+
+ symtab = &elf_tdata (finfo->output_bfd)->symtab_hdr;
+
+ if (bfd_seek (finfo->output_bfd, symtab->sh_offset + symtab->sh_size,
+ SEEK_SET) != 0
+ || (bfd_write ((PTR) finfo->symbuf, finfo->symbuf_count,
+ sizeof (Elf_External_Sym), finfo->output_bfd)
+ != finfo->symbuf_count * sizeof (Elf_External_Sym)))
+ return false;
+
+ symtab->sh_size += finfo->symbuf_count * sizeof (Elf_External_Sym);
+
+ finfo->symbuf_count = 0;
+ }
+
+ return true;
+}
+
+/* Add an external symbol to the symbol table. This is called from
+ the hash table traversal routine. When generating a shared object,
+ we go through the symbol table twice. The first time we output
+ anything that might have been forced to local scope in a version
+ script. The second time we output the symbols that are still
+ global symbols. */
+
+static boolean
+elf_link_output_extsym (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ struct elf_outext_info *eoinfo = (struct elf_outext_info *) data;
+ struct elf_final_link_info *finfo = eoinfo->finfo;
+ boolean strip;
+ Elf_Internal_Sym sym;
+ asection *input_sec;
+
+ /* Decide whether to output this symbol in this pass. */
+ if (eoinfo->localsyms)
+ {
+ if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ return true;
+ }
+ else
+ {
+ if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+ return true;
+ }
+
+ /* If we are not creating a shared library, and this symbol is
+ referenced by a shared library but is not defined anywhere, then
+ warn that it is undefined. If we do not do this, the runtime
+ linker will complain that the symbol is undefined when the
+ program is run. We don't have to worry about symbols that are
+ referenced by regular files, because we will already have issued
+ warnings for them. */
+ if (! finfo->info->relocateable
+ && ! (finfo->info->shared
+ && !finfo->info->symbolic
+ && !finfo->info->no_undefined)
+ && h->root.type == bfd_link_hash_undefined
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
+ {
+ if (! ((*finfo->info->callbacks->undefined_symbol)
+ (finfo->info, h->root.root.string, h->root.u.undef.abfd,
+ (asection *) NULL, 0)))
+ {
+ eoinfo->failed = true;
+ return false;
+ }
+ }
+
+ /* We don't want to output symbols that have never been mentioned by
+ a regular file, or that we have been told to strip. However, if
+ h->indx is set to -2, the symbol is used by a reloc and we must
+ output it. */
+ if (h->indx == -2)
+ strip = false;
+ else if (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
+ strip = true;
+ else if (finfo->info->strip == strip_all
+ || (finfo->info->strip == strip_some
+ && bfd_hash_lookup (finfo->info->keep_hash,
+ h->root.root.string,
+ false, false) == NULL))
+ strip = true;
+ else
+ strip = false;
+
+ /* If we're stripping it, and it's not a dynamic symbol, there's
+ nothing else to do. */
+ if (strip && h->dynindx == -1)
+ return true;
+
+ sym.st_value = 0;
+ sym.st_size = h->size;
+ sym.st_other = h->other;
+ if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+ sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type);
+ else if (h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_defweak)
+ sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
+ else
+ sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
+
+ switch (h->root.type)
+ {
+ default:
+ case bfd_link_hash_new:
+ abort ();
+ return false;
+
+ case bfd_link_hash_undefined:
+ input_sec = bfd_und_section_ptr;
+ sym.st_shndx = SHN_UNDEF;
+ break;
+
+ case bfd_link_hash_undefweak:
+ input_sec = bfd_und_section_ptr;
+ sym.st_shndx = SHN_UNDEF;
+ break;
+
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ {
+ input_sec = h->root.u.def.section;
+ if (input_sec->output_section != NULL)
+ {
+ sym.st_shndx =
+ _bfd_elf_section_from_bfd_section (finfo->output_bfd,
+ input_sec->output_section);
+ if (sym.st_shndx == (unsigned short) -1)
+ {
+ (*_bfd_error_handler)
+ (_("%s: could not find output section %s for input section %s"),
+ bfd_get_filename (finfo->output_bfd),
+ input_sec->output_section->name,
+ input_sec->name);
+ eoinfo->failed = true;
+ return false;
+ }
+
+ /* ELF symbols in relocateable files are section relative,
+ but in nonrelocateable files they are virtual
+ addresses. */
+ sym.st_value = h->root.u.def.value + input_sec->output_offset;
+ if (! finfo->info->relocateable)
+ sym.st_value += input_sec->output_section->vma;
+ }
+ else
+ {
+ BFD_ASSERT (input_sec->owner == NULL
+ || (input_sec->owner->flags & DYNAMIC) != 0);
+ sym.st_shndx = SHN_UNDEF;
+ input_sec = bfd_und_section_ptr;
+ }
+ }
+ break;
+
+ case bfd_link_hash_common:
+ input_sec = h->root.u.c.p->section;
+ sym.st_shndx = SHN_COMMON;
+ sym.st_value = 1 << h->root.u.c.p->alignment_power;
+ break;
+
+ case bfd_link_hash_indirect:
+ /* These symbols are created by symbol versioning. They point
+ to the decorated version of the name. For example, if the
+ symbol foo@@GNU_1.2 is the default, which should be used when
+ foo is used with no version, then we add an indirect symbol
+ foo which points to foo@@GNU_1.2. We ignore these symbols,
+ since the indirected symbol is already in the hash table. If
+ the indirect symbol is non-ELF, fall through and output it. */
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_ELF) == 0)
+ return true;
+
+ /* Fall through. */
+ case bfd_link_hash_warning:
+ /* We can't represent these symbols in ELF, although a warning
+ symbol may have come from a .gnu.warning.SYMBOL section. We
+ just put the target symbol in the hash table. If the target
+ symbol does not really exist, don't do anything. */
+ if (h->root.u.i.link->type == bfd_link_hash_new)
+ return true;
+ return (elf_link_output_extsym
+ ((struct elf_link_hash_entry *) h->root.u.i.link, data));
+ }
+
+ /* Give the processor backend a chance to tweak the symbol value,
+ and also to finish up anything that needs to be done for this
+ symbol. */
+ if ((h->dynindx != -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+ && elf_hash_table (finfo->info)->dynamic_sections_created)
+ {
+ struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (finfo->output_bfd);
+ if (! ((*bed->elf_backend_finish_dynamic_symbol)
+ (finfo->output_bfd, finfo->info, h, &sym)))
+ {
+ eoinfo->failed = true;
+ return false;
+ }
+ }
+
+ /* If we are marking the symbol as undefined, and there are no
+ non-weak references to this symbol from a regular object, then
+ mark the symbol as weak undefined. We can't do this earlier,
+ because it might not be marked as undefined until the
+ finish_dynamic_symbol routine gets through with it. */
+ if (sym.st_shndx == SHN_UNDEF
+ && sym.st_info == ELF_ST_INFO (STB_GLOBAL, h->type)
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK) == 0)
+ sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
+
+ /* If this symbol should be put in the .dynsym section, then put it
+ there now. We have already know the symbol index. We also fill
+ in the entry in the .hash section. */
+ if (h->dynindx != -1
+ && elf_hash_table (finfo->info)->dynamic_sections_created)
+ {
+ size_t bucketcount;
+ size_t bucket;
+ bfd_byte *bucketpos;
+ bfd_vma chain;
+
+ sym.st_name = h->dynstr_index;
+
+ elf_swap_symbol_out (finfo->output_bfd, &sym,
+ (PTR) (((Elf_External_Sym *)
+ finfo->dynsym_sec->contents)
+ + h->dynindx));
+
+ bucketcount = elf_hash_table (finfo->info)->bucketcount;
+ bucket = h->elf_hash_value % bucketcount;
+ bucketpos = ((bfd_byte *) finfo->hash_sec->contents
+ + (bucket + 2) * (ARCH_SIZE / 8));
+ chain = get_word (finfo->output_bfd, bucketpos);
+ put_word (finfo->output_bfd, h->dynindx, bucketpos);
+ put_word (finfo->output_bfd, chain,
+ ((bfd_byte *) finfo->hash_sec->contents
+ + (bucketcount + 2 + h->dynindx) * (ARCH_SIZE / 8)));
+
+ if (finfo->symver_sec != NULL && finfo->symver_sec->contents != NULL)
+ {
+ Elf_Internal_Versym iversym;
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ if (h->verinfo.verdef == NULL)
+ iversym.vs_vers = 0;
+ else
+ iversym.vs_vers = h->verinfo.verdef->vd_exp_refno + 1;
+ }
+ else
+ {
+ if (h->verinfo.vertree == NULL)
+ iversym.vs_vers = 1;
+ else
+ iversym.vs_vers = h->verinfo.vertree->vernum + 1;
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HIDDEN) != 0)
+ iversym.vs_vers |= VERSYM_HIDDEN;
+
+ _bfd_elf_swap_versym_out (finfo->output_bfd, &iversym,
+ (((Elf_External_Versym *)
+ finfo->symver_sec->contents)
+ + h->dynindx));
+ }
+ }
+
+ /* If we're stripping it, then it was just a dynamic symbol, and
+ there's nothing else to do. */
+ if (strip)
+ return true;
+
+ h->indx = bfd_get_symcount (finfo->output_bfd);
+
+ if (! elf_link_output_sym (finfo, h->root.root.string, &sym, input_sec))
+ {
+ eoinfo->failed = true;
+ return false;
+ }
+
+ return true;
+}
+
+/* Link an input file into the linker output file. This function
+ handles all the sections and relocations of the input file at once.
+ This is so that we only have to read the local symbols once, and
+ don't have to keep them in memory. */
+
+static boolean
+elf_link_input_bfd (finfo, input_bfd)
+ struct elf_final_link_info *finfo;
+ bfd *input_bfd;
+{
+ boolean (*relocate_section) PARAMS ((bfd *, struct bfd_link_info *,
+ bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *,
+ Elf_Internal_Sym *, asection **));
+ bfd *output_bfd;
+ Elf_Internal_Shdr *symtab_hdr;
+ size_t locsymcount;
+ size_t extsymoff;
+ Elf_External_Sym *external_syms;
+ Elf_External_Sym *esym;
+ Elf_External_Sym *esymend;
+ Elf_Internal_Sym *isym;
+ long *pindex;
+ asection **ppsection;
+ asection *o;
+
+ output_bfd = finfo->output_bfd;
+ relocate_section =
+ get_elf_backend_data (output_bfd)->elf_backend_relocate_section;
+
+ /* If this is a dynamic object, we don't want to do anything here:
+ we don't want the local symbols, and we don't want the section
+ contents. */
+ if ((input_bfd->flags & DYNAMIC) != 0)
+ return true;
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ if (elf_bad_symtab (input_bfd))
+ {
+ locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
+ extsymoff = 0;
+ }
+ else
+ {
+ locsymcount = symtab_hdr->sh_info;
+ extsymoff = symtab_hdr->sh_info;
+ }
+
+ /* Read the local symbols. */
+ if (symtab_hdr->contents != NULL)
+ external_syms = (Elf_External_Sym *) symtab_hdr->contents;
+ else if (locsymcount == 0)
+ external_syms = NULL;
+ else
+ {
+ external_syms = finfo->external_syms;
+ if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (external_syms, sizeof (Elf_External_Sym),
+ locsymcount, input_bfd)
+ != locsymcount * sizeof (Elf_External_Sym)))
+ return false;
+ }
+
+ /* Swap in the local symbols and write out the ones which we know
+ are going into the output file. */
+ esym = external_syms;
+ esymend = esym + locsymcount;
+ isym = finfo->internal_syms;
+ pindex = finfo->indices;
+ ppsection = finfo->sections;
+ for (; esym < esymend; esym++, isym++, pindex++, ppsection++)
+ {
+ asection *isec;
+ const char *name;
+ Elf_Internal_Sym osym;
+
+ elf_swap_symbol_in (input_bfd, esym, isym);
+ *pindex = -1;
+
+ if (elf_bad_symtab (input_bfd))
+ {
+ if (ELF_ST_BIND (isym->st_info) != STB_LOCAL)
+ {
+ *ppsection = NULL;
+ continue;
+ }
+ }
+
+ if (isym->st_shndx == SHN_UNDEF)
+ isec = bfd_und_section_ptr;
+ else if (isym->st_shndx > 0 && isym->st_shndx < SHN_LORESERVE)
+ isec = section_from_elf_index (input_bfd, isym->st_shndx);
+ else if (isym->st_shndx == SHN_ABS)
+ isec = bfd_abs_section_ptr;
+ else if (isym->st_shndx == SHN_COMMON)
+ isec = bfd_com_section_ptr;
+ else
+ {
+ /* Who knows? */
+ isec = NULL;
+ }
+
+ *ppsection = isec;
+
+ /* Don't output the first, undefined, symbol. */
+ if (esym == external_syms)
+ continue;
+
+ /* If we are stripping all symbols, we don't want to output this
+ one. */
+ if (finfo->info->strip == strip_all)
+ continue;
+
+ /* We never output section symbols. Instead, we use the section
+ symbol of the corresponding section in the output file. */
+ if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+ continue;
+
+ /* If we are discarding all local symbols, we don't want to
+ output this one. If we are generating a relocateable output
+ file, then some of the local symbols may be required by
+ relocs; we output them below as we discover that they are
+ needed. */
+ if (finfo->info->discard == discard_all)
+ continue;
+
+ /* If this symbol is defined in a section which we are
+ discarding, we don't need to keep it, but note that
+ linker_mark is only reliable for sections that have contents.
+ For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
+ as well as linker_mark. */
+ if (isym->st_shndx > 0
+ && isym->st_shndx < SHN_LORESERVE
+ && isec != NULL
+ && ((! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
+ || (! finfo->info->relocateable
+ && (isec->flags & SEC_EXCLUDE) != 0)))
+ continue;
+
+ /* Get the name of the symbol. */
+ name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link,
+ isym->st_name);
+ if (name == NULL)
+ return false;
+
+ /* See if we are discarding symbols with this name. */
+ if ((finfo->info->strip == strip_some
+ && (bfd_hash_lookup (finfo->info->keep_hash, name, false, false)
+ == NULL))
+ || (finfo->info->discard == discard_l
+ && bfd_is_local_label_name (input_bfd, name)))
+ continue;
+
+ /* If we get here, we are going to output this symbol. */
+
+ osym = *isym;
+
+ /* Adjust the section index for the output file. */
+ osym.st_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
+ isec->output_section);
+ if (osym.st_shndx == (unsigned short) -1)
+ return false;
+
+ *pindex = bfd_get_symcount (output_bfd);
+
+ /* ELF symbols in relocateable files are section relative, but
+ in executable files they are virtual addresses. Note that
+ this code assumes that all ELF sections have an associated
+ BFD section with a reasonable value for output_offset; below
+ we assume that they also have a reasonable value for
+ output_section. Any special sections must be set up to meet
+ these requirements. */
+ osym.st_value += isec->output_offset;
+ if (! finfo->info->relocateable)
+ osym.st_value += isec->output_section->vma;
+
+ if (! elf_link_output_sym (finfo, name, &osym, isec))
+ return false;
+ }
+
+ /* Relocate the contents of each section. */
+ for (o = input_bfd->sections; o != NULL; o = o->next)
+ {
+ bfd_byte *contents;
+
+ if (! o->linker_mark)
+ {
+ /* This section was omitted from the link. */
+ continue;
+ }
+
+ if ((o->flags & SEC_HAS_CONTENTS) == 0
+ || (o->_raw_size == 0 && (o->flags & SEC_RELOC) == 0))
+ continue;
+
+ if ((o->flags & SEC_LINKER_CREATED) != 0)
+ {
+ /* Section was created by elf_link_create_dynamic_sections
+ or somesuch. */
+ continue;
+ }
+
+ /* Get the contents of the section. They have been cached by a
+ relaxation routine. Note that o is a section in an input
+ file, so the contents field will not have been set by any of
+ the routines which work on output files. */
+ if (elf_section_data (o)->this_hdr.contents != NULL)
+ contents = elf_section_data (o)->this_hdr.contents;
+ else
+ {
+ contents = finfo->contents;
+ if (! bfd_get_section_contents (input_bfd, o, contents,
+ (file_ptr) 0, o->_raw_size))
+ return false;
+ }
+
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ Elf_Internal_Rela *internal_relocs;
+
+ /* Get the swapped relocs. */
+ internal_relocs = (NAME(_bfd_elf,link_read_relocs)
+ (input_bfd, o, finfo->external_relocs,
+ finfo->internal_relocs, false));
+ if (internal_relocs == NULL
+ && o->reloc_count > 0)
+ return false;
+
+ /* Relocate the section by invoking a back end routine.
+
+ The back end routine is responsible for adjusting the
+ section contents as necessary, and (if using Rela relocs
+ and generating a relocateable output file) adjusting the
+ reloc addend as necessary.
+
+ The back end routine does not have to worry about setting
+ the reloc address or the reloc symbol index.
+
+ The back end routine is given a pointer to the swapped in
+ internal symbols, and can access the hash table entries
+ for the external symbols via elf_sym_hashes (input_bfd).
+
+ When generating relocateable output, the back end routine
+ must handle STB_LOCAL/STT_SECTION symbols specially. The
+ output symbol is going to be a section symbol
+ corresponding to the output section, which will require
+ the addend to be adjusted. */
+
+ if (! (*relocate_section) (output_bfd, finfo->info,
+ input_bfd, o, contents,
+ internal_relocs,
+ finfo->internal_syms,
+ finfo->sections))
+ return false;
+
+ if (finfo->info->relocateable)
+ {
+ Elf_Internal_Rela *irela;
+ Elf_Internal_Rela *irelaend;
+ struct elf_link_hash_entry **rel_hash;
+ Elf_Internal_Shdr *input_rel_hdr;
+ Elf_Internal_Shdr *output_rel_hdr;
+
+ /* Adjust the reloc addresses and symbol indices. */
+
+ irela = internal_relocs;
+ irelaend = irela + o->reloc_count;
+ rel_hash = (elf_section_data (o->output_section)->rel_hashes
+ + o->output_section->reloc_count);
+ for (; irela < irelaend; irela++, rel_hash++)
+ {
+ unsigned long r_symndx;
+ Elf_Internal_Sym *isym;
+ asection *sec;
+
+ irela->r_offset += o->output_offset;
+
+ r_symndx = ELF_R_SYM (irela->r_info);
+
+ if (r_symndx == 0)
+ continue;
+
+ if (r_symndx >= locsymcount
+ || (elf_bad_symtab (input_bfd)
+ && finfo->sections[r_symndx] == NULL))
+ {
+ struct elf_link_hash_entry *rh;
+ long indx;
+
+ /* This is a reloc against a global symbol. We
+ have not yet output all the local symbols, so
+ we do not know the symbol index of any global
+ symbol. We set the rel_hash entry for this
+ reloc to point to the global hash table entry
+ for this symbol. The symbol index is then
+ set at the end of elf_bfd_final_link. */
+ indx = r_symndx - extsymoff;
+ rh = elf_sym_hashes (input_bfd)[indx];
+ while (rh->root.type == bfd_link_hash_indirect
+ || rh->root.type == bfd_link_hash_warning)
+ rh = (struct elf_link_hash_entry *) rh->root.u.i.link;
+
+ /* Setting the index to -2 tells
+ elf_link_output_extsym that this symbol is
+ used by a reloc. */
+ BFD_ASSERT (rh->indx < 0);
+ rh->indx = -2;
+
+ *rel_hash = rh;
+
+ continue;
+ }
+
+ /* This is a reloc against a local symbol. */
+
+ *rel_hash = NULL;
+ isym = finfo->internal_syms + r_symndx;
+ sec = finfo->sections[r_symndx];
+ if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+ {
+ /* I suppose the backend ought to fill in the
+ section of any STT_SECTION symbol against a
+ processor specific section. If we have
+ discarded a section, the output_section will
+ be the absolute section. */
+ if (sec != NULL
+ && (bfd_is_abs_section (sec)
+ || (sec->output_section != NULL
+ && bfd_is_abs_section (sec->output_section))))
+ r_symndx = 0;
+ else if (sec == NULL || sec->owner == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else
+ {
+ r_symndx = sec->output_section->target_index;
+ BFD_ASSERT (r_symndx != 0);
+ }
+ }
+ else
+ {
+ if (finfo->indices[r_symndx] == -1)
+ {
+ unsigned long link;
+ const char *name;
+ asection *osec;
+
+ if (finfo->info->strip == strip_all)
+ {
+ /* You can't do ld -r -s. */
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ /* This symbol was skipped earlier, but
+ since it is needed by a reloc, we
+ must output it now. */
+ link = symtab_hdr->sh_link;
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ link,
+ isym->st_name);
+ if (name == NULL)
+ return false;
+
+ osec = sec->output_section;
+ isym->st_shndx =
+ _bfd_elf_section_from_bfd_section (output_bfd,
+ osec);
+ if (isym->st_shndx == (unsigned short) -1)
+ return false;
+
+ isym->st_value += sec->output_offset;
+ if (! finfo->info->relocateable)
+ isym->st_value += osec->vma;
+
+ finfo->indices[r_symndx] = bfd_get_symcount (output_bfd);
+
+ if (! elf_link_output_sym (finfo, name, isym, sec))
+ return false;
+ }
+
+ r_symndx = finfo->indices[r_symndx];
+ }
+
+ irela->r_info = ELF_R_INFO (r_symndx,
+ ELF_R_TYPE (irela->r_info));
+ }
+
+ /* Swap out the relocs. */
+ input_rel_hdr = &elf_section_data (o)->rel_hdr;
+ output_rel_hdr = &elf_section_data (o->output_section)->rel_hdr;
+ BFD_ASSERT (output_rel_hdr->sh_entsize
+ == input_rel_hdr->sh_entsize);
+ irela = internal_relocs;
+ irelaend = irela + o->reloc_count;
+ if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
+ {
+ Elf_External_Rel *erel;
+
+ erel = ((Elf_External_Rel *) output_rel_hdr->contents
+ + o->output_section->reloc_count);
+ for (; irela < irelaend; irela++, erel++)
+ {
+ Elf_Internal_Rel irel;
+
+ irel.r_offset = irela->r_offset;
+ irel.r_info = irela->r_info;
+ BFD_ASSERT (irela->r_addend == 0);
+ elf_swap_reloc_out (output_bfd, &irel, erel);
+ }
+ }
+ else
+ {
+ Elf_External_Rela *erela;
+
+ BFD_ASSERT (input_rel_hdr->sh_entsize
+ == sizeof (Elf_External_Rela));
+ erela = ((Elf_External_Rela *) output_rel_hdr->contents
+ + o->output_section->reloc_count);
+ for (; irela < irelaend; irela++, erela++)
+ elf_swap_reloca_out (output_bfd, irela, erela);
+ }
+
+ o->output_section->reloc_count += o->reloc_count;
+ }
+ }
+
+ /* Write out the modified section contents. */
+ if (elf_section_data (o)->stab_info == NULL)
+ {
+ if (! (o->flags & SEC_EXCLUDE) &&
+ ! bfd_set_section_contents (output_bfd, o->output_section,
+ contents, o->output_offset,
+ (o->_cooked_size != 0
+ ? o->_cooked_size
+ : o->_raw_size)))
+ return false;
+ }
+ else
+ {
+ if (! (_bfd_write_section_stabs
+ (output_bfd, &elf_hash_table (finfo->info)->stab_info,
+ o, &elf_section_data (o)->stab_info, contents)))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Generate a reloc when linking an ELF file. This is a reloc
+ requested by the linker, and does come from any input file. This
+ is used to build constructor and destructor tables when linking
+ with -Ur. */
+
+static boolean
+elf_reloc_link_order (output_bfd, info, output_section, link_order)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ asection *output_section;
+ struct bfd_link_order *link_order;
+{
+ reloc_howto_type *howto;
+ long indx;
+ bfd_vma offset;
+ bfd_vma addend;
+ struct elf_link_hash_entry **rel_hash_ptr;
+ Elf_Internal_Shdr *rel_hdr;
+
+ howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
+ if (howto == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ addend = link_order->u.reloc.p->addend;
+
+ /* Figure out the symbol index. */
+ rel_hash_ptr = (elf_section_data (output_section)->rel_hashes
+ + output_section->reloc_count);
+ if (link_order->type == bfd_section_reloc_link_order)
+ {
+ indx = link_order->u.reloc.p->u.section->target_index;
+ BFD_ASSERT (indx != 0);
+ *rel_hash_ptr = NULL;
+ }
+ else
+ {
+ struct elf_link_hash_entry *h;
+
+ /* Treat a reloc against a defined symbol as though it were
+ actually against the section. */
+ h = ((struct elf_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (output_bfd, info,
+ link_order->u.reloc.p->u.name,
+ false, false, true));
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ asection *section;
+
+ section = h->root.u.def.section;
+ indx = section->output_section->target_index;
+ *rel_hash_ptr = NULL;
+ /* It seems that we ought to add the symbol value to the
+ addend here, but in practice it has already been added
+ because it was passed to constructor_callback. */
+ addend += section->output_section->vma + section->output_offset;
+ }
+ else if (h != NULL)
+ {
+ /* Setting the index to -2 tells elf_link_output_extsym that
+ this symbol is used by a reloc. */
+ h->indx = -2;
+ *rel_hash_ptr = h;
+ indx = 0;
+ }
+ else
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, link_order->u.reloc.p->u.name, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ return false;
+ indx = 0;
+ }
+ }
+
+ /* If this is an inplace reloc, we must write the addend into the
+ object file. */
+ if (howto->partial_inplace && addend != 0)
+ {
+ bfd_size_type size;
+ bfd_reloc_status_type rstat;
+ bfd_byte *buf;
+ boolean ok;
+
+ size = bfd_get_reloc_size (howto);
+ buf = (bfd_byte *) bfd_zmalloc (size);
+ if (buf == (bfd_byte *) NULL)
+ return false;
+ rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
+ switch (rstat)
+ {
+ case bfd_reloc_ok:
+ break;
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info,
+ (link_order->type == bfd_section_reloc_link_order
+ ? bfd_section_name (output_bfd,
+ link_order->u.reloc.p->u.section)
+ : link_order->u.reloc.p->u.name),
+ howto->name, addend, (bfd *) NULL, (asection *) NULL,
+ (bfd_vma) 0)))
+ {
+ free (buf);
+ return false;
+ }
+ break;
+ }
+ ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
+ (file_ptr) link_order->offset, size);
+ free (buf);
+ if (! ok)
+ return false;
+ }
+
+ /* The address of a reloc is relative to the section in a
+ relocateable file, and is a virtual address in an executable
+ file. */
+ offset = link_order->offset;
+ if (! info->relocateable)
+ offset += output_section->vma;
+
+ rel_hdr = &elf_section_data (output_section)->rel_hdr;
+
+ if (rel_hdr->sh_type == SHT_REL)
+ {
+ Elf_Internal_Rel irel;
+ Elf_External_Rel *erel;
+
+ irel.r_offset = offset;
+ irel.r_info = ELF_R_INFO (indx, howto->type);
+ erel = ((Elf_External_Rel *) rel_hdr->contents
+ + output_section->reloc_count);
+ elf_swap_reloc_out (output_bfd, &irel, erel);
+ }
+ else
+ {
+ Elf_Internal_Rela irela;
+ Elf_External_Rela *erela;
+
+ irela.r_offset = offset;
+ irela.r_info = ELF_R_INFO (indx, howto->type);
+ irela.r_addend = addend;
+ erela = ((Elf_External_Rela *) rel_hdr->contents
+ + output_section->reloc_count);
+ elf_swap_reloca_out (output_bfd, &irela, erela);
+ }
+
+ ++output_section->reloc_count;
+
+ return true;
+}
+
+
+/* Allocate a pointer to live in a linker created section. */
+
+boolean
+elf_create_pointer_linker_section (abfd, info, lsect, h, rel)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ elf_linker_section_t *lsect;
+ struct elf_link_hash_entry *h;
+ const Elf_Internal_Rela *rel;
+{
+ elf_linker_section_pointers_t **ptr_linker_section_ptr = NULL;
+ elf_linker_section_pointers_t *linker_section_ptr;
+ unsigned long r_symndx = ELF_R_SYM (rel->r_info);;
+
+ BFD_ASSERT (lsect != NULL);
+
+ /* Is this a global symbol? */
+ if (h != NULL)
+ {
+ /* Has this symbol already been allocated, if so, our work is done */
+ if (_bfd_elf_find_pointer_linker_section (h->linker_section_pointer,
+ rel->r_addend,
+ lsect->which))
+ return true;
+
+ ptr_linker_section_ptr = &h->linker_section_pointer;
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (h->dynindx == -1)
+ {
+ if (! elf_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (lsect->rel_section)
+ lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
+ }
+
+ else /* Allocation of a pointer to a local symbol */
+ {
+ elf_linker_section_pointers_t **ptr = elf_local_ptr_offsets (abfd);
+
+ /* Allocate a table to hold the local symbols if first time */
+ if (!ptr)
+ {
+ unsigned int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info;
+ register unsigned int i;
+
+ ptr = (elf_linker_section_pointers_t **)
+ bfd_alloc (abfd, num_symbols * sizeof (elf_linker_section_pointers_t *));
+
+ if (!ptr)
+ return false;
+
+ elf_local_ptr_offsets (abfd) = ptr;
+ for (i = 0; i < num_symbols; i++)
+ ptr[i] = (elf_linker_section_pointers_t *)0;
+ }
+
+ /* Has this symbol already been allocated, if so, our work is done */
+ if (_bfd_elf_find_pointer_linker_section (ptr[r_symndx],
+ rel->r_addend,
+ lsect->which))
+ return true;
+
+ ptr_linker_section_ptr = &ptr[r_symndx];
+
+ if (info->shared)
+ {
+ /* If we are generating a shared object, we need to
+ output a R_<xxx>_RELATIVE reloc so that the
+ dynamic linker can adjust this GOT entry. */
+ BFD_ASSERT (lsect->rel_section != NULL);
+ lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
+ }
+ }
+
+ /* Allocate space for a pointer in the linker section, and allocate a new pointer record
+ from internal memory. */
+ BFD_ASSERT (ptr_linker_section_ptr != NULL);
+ linker_section_ptr = (elf_linker_section_pointers_t *)
+ bfd_alloc (abfd, sizeof (elf_linker_section_pointers_t));
+
+ if (!linker_section_ptr)
+ return false;
+
+ linker_section_ptr->next = *ptr_linker_section_ptr;
+ linker_section_ptr->addend = rel->r_addend;
+ linker_section_ptr->which = lsect->which;
+ linker_section_ptr->written_address_p = false;
+ *ptr_linker_section_ptr = linker_section_ptr;
+
+#if 0
+ if (lsect->hole_size && lsect->hole_offset < lsect->max_hole_offset)
+ {
+ linker_section_ptr->offset = lsect->section->_raw_size - lsect->hole_size + (ARCH_SIZE / 8);
+ lsect->hole_offset += ARCH_SIZE / 8;
+ lsect->sym_offset += ARCH_SIZE / 8;
+ if (lsect->sym_hash) /* Bump up symbol value if needed */
+ {
+ lsect->sym_hash->root.u.def.value += ARCH_SIZE / 8;
+#ifdef DEBUG
+ fprintf (stderr, "Bump up %s by %ld, current value = %ld\n",
+ lsect->sym_hash->root.root.string,
+ (long)ARCH_SIZE / 8,
+ (long)lsect->sym_hash->root.u.def.value);
+#endif
+ }
+ }
+ else
+#endif
+ linker_section_ptr->offset = lsect->section->_raw_size;
+
+ lsect->section->_raw_size += ARCH_SIZE / 8;
+
+#ifdef DEBUG
+ fprintf (stderr, "Create pointer in linker section %s, offset = %ld, section size = %ld\n",
+ lsect->name, (long)linker_section_ptr->offset, (long)lsect->section->_raw_size);
+#endif
+
+ return true;
+}
+
+
+#if ARCH_SIZE==64
+#define bfd_put_ptr(BFD,VAL,ADDR) bfd_put_64 (BFD, VAL, ADDR)
+#endif
+#if ARCH_SIZE==32
+#define bfd_put_ptr(BFD,VAL,ADDR) bfd_put_32 (BFD, VAL, ADDR)
+#endif
+
+/* Fill in the address for a pointer generated in alinker section. */
+
+bfd_vma
+elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, relocation, rel, relative_reloc)
+ bfd *output_bfd;
+ bfd *input_bfd;
+ struct bfd_link_info *info;
+ elf_linker_section_t *lsect;
+ struct elf_link_hash_entry *h;
+ bfd_vma relocation;
+ const Elf_Internal_Rela *rel;
+ int relative_reloc;
+{
+ elf_linker_section_pointers_t *linker_section_ptr;
+
+ BFD_ASSERT (lsect != NULL);
+
+ if (h != NULL) /* global symbol */
+ {
+ linker_section_ptr = _bfd_elf_find_pointer_linker_section (h->linker_section_pointer,
+ rel->r_addend,
+ lsect->which);
+
+ BFD_ASSERT (linker_section_ptr != NULL);
+
+ if (! elf_hash_table (info)->dynamic_sections_created
+ || (info->shared
+ && info->symbolic
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally. We must initialize this entry in the
+ global section.
+
+ When doing a dynamic link, we create a .rela.<xxx>
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if (!linker_section_ptr->written_address_p)
+ {
+ linker_section_ptr->written_address_p = true;
+ bfd_put_ptr (output_bfd, relocation + linker_section_ptr->addend,
+ lsect->section->contents + linker_section_ptr->offset);
+ }
+ }
+ }
+ else /* local symbol */
+ {
+ unsigned long r_symndx = ELF_R_SYM (rel->r_info);
+ BFD_ASSERT (elf_local_ptr_offsets (input_bfd) != NULL);
+ BFD_ASSERT (elf_local_ptr_offsets (input_bfd)[r_symndx] != NULL);
+ linker_section_ptr = _bfd_elf_find_pointer_linker_section (elf_local_ptr_offsets (input_bfd)[r_symndx],
+ rel->r_addend,
+ lsect->which);
+
+ BFD_ASSERT (linker_section_ptr != NULL);
+
+ /* Write out pointer if it hasn't been rewritten out before */
+ if (!linker_section_ptr->written_address_p)
+ {
+ linker_section_ptr->written_address_p = true;
+ bfd_put_ptr (output_bfd, relocation + linker_section_ptr->addend,
+ lsect->section->contents + linker_section_ptr->offset);
+
+ if (info->shared)
+ {
+ asection *srel = lsect->rel_section;
+ Elf_Internal_Rela outrel;
+
+ /* We need to generate a relative reloc for the dynamic linker. */
+ if (!srel)
+ lsect->rel_section = srel = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
+ lsect->rel_name);
+
+ BFD_ASSERT (srel != NULL);
+
+ outrel.r_offset = (lsect->section->output_section->vma
+ + lsect->section->output_offset
+ + linker_section_ptr->offset);
+ outrel.r_info = ELF_R_INFO (0, relative_reloc);
+ outrel.r_addend = 0;
+ elf_swap_reloca_out (output_bfd, &outrel,
+ (((Elf_External_Rela *)
+ lsect->section->contents)
+ + lsect->section->reloc_count));
+ ++lsect->section->reloc_count;
+ }
+ }
+ }
+
+ relocation = (lsect->section->output_offset
+ + linker_section_ptr->offset
+ - lsect->hole_offset
+ - lsect->sym_offset);
+
+#ifdef DEBUG
+ fprintf (stderr, "Finish pointer in linker section %s, offset = %ld (0x%lx)\n",
+ lsect->name, (long)relocation, (long)relocation);
+#endif
+
+ /* Subtract out the addend, because it will get added back in by the normal
+ processing. */
+ return relocation - linker_section_ptr->addend;
+}
+
+/* Garbage collect unused sections. */
+
+static boolean elf_gc_mark
+ PARAMS ((struct bfd_link_info *info, asection *sec,
+ asection * (*gc_mark_hook)
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *))));
+
+static boolean elf_gc_sweep
+ PARAMS ((struct bfd_link_info *info,
+ boolean (*gc_sweep_hook)
+ PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
+ const Elf_Internal_Rela *relocs))));
+
+static boolean elf_gc_sweep_symbol
+ PARAMS ((struct elf_link_hash_entry *h, PTR idxptr));
+
+static boolean elf_gc_allocate_got_offsets
+ PARAMS ((struct elf_link_hash_entry *h, PTR offarg));
+
+static boolean elf_gc_propagate_vtable_entries_used
+ PARAMS ((struct elf_link_hash_entry *h, PTR dummy));
+
+static boolean elf_gc_smash_unused_vtentry_relocs
+ PARAMS ((struct elf_link_hash_entry *h, PTR dummy));
+
+/* The mark phase of garbage collection. For a given section, mark
+ it, and all the sections which define symbols to which it refers. */
+
+static boolean
+elf_gc_mark (info, sec, gc_mark_hook)
+ struct bfd_link_info *info;
+ asection *sec;
+ asection * (*gc_mark_hook)
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
+{
+ boolean ret = true;
+
+ sec->gc_mark = 1;
+
+ /* Look through the section relocs. */
+
+ if ((sec->flags & SEC_RELOC) != 0 && sec->reloc_count > 0)
+ {
+ Elf_Internal_Rela *relstart, *rel, *relend;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ size_t nlocsyms;
+ size_t extsymoff;
+ Elf_External_Sym *locsyms, *freesyms = NULL;
+ bfd *input_bfd = sec->owner;
+
+ /* GCFIXME: how to arrange so that relocs and symbols are not
+ reread continually? */
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+
+ /* Read the local symbols. */
+ if (elf_bad_symtab (input_bfd))
+ {
+ nlocsyms = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
+ extsymoff = 0;
+ }
+ else
+ extsymoff = nlocsyms = symtab_hdr->sh_info;
+ if (symtab_hdr->contents)
+ locsyms = (Elf_External_Sym *) symtab_hdr->contents;
+ else if (nlocsyms == 0)
+ locsyms = NULL;
+ else
+ {
+ locsyms = freesyms =
+ bfd_malloc (nlocsyms * sizeof (Elf_External_Sym));
+ if (freesyms == NULL
+ || bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_read (locsyms, sizeof (Elf_External_Sym),
+ nlocsyms, input_bfd)
+ != nlocsyms * sizeof (Elf_External_Sym)))
+ {
+ ret = false;
+ goto out1;
+ }
+ }
+
+ /* Read the relocations. */
+ relstart = (NAME(_bfd_elf,link_read_relocs)
+ (sec->owner, sec, NULL, (Elf_Internal_Rela *) NULL,
+ info->keep_memory));
+ if (relstart == NULL)
+ {
+ ret = false;
+ goto out1;
+ }
+ relend = relstart + sec->reloc_count;
+
+ for (rel = relstart; rel < relend; rel++)
+ {
+ unsigned long r_symndx;
+ asection *rsec;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym s;
+
+ r_symndx = ELF_R_SYM (rel->r_info);
+ if (r_symndx == 0)
+ continue;
+
+ if (elf_bad_symtab (sec->owner))
+ {
+ elf_swap_symbol_in (input_bfd, &locsyms[r_symndx], &s);
+ if (ELF_ST_BIND (s.st_info) == STB_LOCAL)
+ rsec = (*gc_mark_hook)(sec->owner, info, rel, NULL, &s);
+ else
+ {
+ h = sym_hashes[r_symndx - extsymoff];
+ rsec = (*gc_mark_hook)(sec->owner, info, rel, h, NULL);
+ }
+ }
+ else if (r_symndx >= nlocsyms)
+ {
+ h = sym_hashes[r_symndx - extsymoff];
+ rsec = (*gc_mark_hook)(sec->owner, info, rel, h, NULL);
+ }
+ else
+ {
+ elf_swap_symbol_in (input_bfd, &locsyms[r_symndx], &s);
+ rsec = (*gc_mark_hook)(sec->owner, info, rel, NULL, &s);
+ }
+
+ if (rsec && !rsec->gc_mark)
+ if (!elf_gc_mark (info, rsec, gc_mark_hook))
+ {
+ ret = false;
+ goto out2;
+ }
+ }
+
+ out2:
+ if (!info->keep_memory)
+ free (relstart);
+ out1:
+ if (freesyms)
+ free (freesyms);
+ }
+
+ return ret;
+}
+
+/* The sweep phase of garbage collection. Remove all garbage sections. */
+
+static boolean
+elf_gc_sweep (info, gc_sweep_hook)
+ struct bfd_link_info *info;
+ boolean (*gc_sweep_hook)
+ PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
+ const Elf_Internal_Rela *relocs));
+{
+ bfd *sub;
+
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *o;
+
+ for (o = sub->sections; o != NULL; o = o->next)
+ {
+ /* Keep special sections. Keep .debug sections. */
+ if ((o->flags & SEC_LINKER_CREATED)
+ || (o->flags & SEC_DEBUGGING))
+ o->gc_mark = 1;
+
+ if (o->gc_mark)
+ continue;
+
+ /* Skip sweeping sections already excluded. */
+ if (o->flags & SEC_EXCLUDE)
+ continue;
+
+ /* Since this is early in the link process, it is simple
+ to remove a section from the output. */
+ o->flags |= SEC_EXCLUDE;
+
+ /* But we also have to update some of the relocation
+ info we collected before. */
+ if (gc_sweep_hook
+ && (o->flags & SEC_RELOC) && o->reloc_count > 0)
+ {
+ Elf_Internal_Rela *internal_relocs;
+ boolean r;
+
+ internal_relocs = (NAME(_bfd_elf,link_read_relocs)
+ (o->owner, o, NULL, NULL, info->keep_memory));
+ if (internal_relocs == NULL)
+ return false;
+
+ r = (*gc_sweep_hook)(o->owner, info, o, internal_relocs);
+
+ if (!info->keep_memory)
+ free (internal_relocs);
+
+ if (!r)
+ return false;
+ }
+ }
+ }
+
+ /* Remove the symbols that were in the swept sections from the dynamic
+ symbol table. GCFIXME: Anyone know how to get them out of the
+ static symbol table as well? */
+ {
+ int i = 0;
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_gc_sweep_symbol,
+ (PTR) &i);
+
+ elf_hash_table (info)->dynsymcount = i;
+ }
+
+ return true;
+}
+
+/* Sweep symbols in swept sections. Called via elf_link_hash_traverse. */
+
+static boolean
+elf_gc_sweep_symbol (h, idxptr)
+ struct elf_link_hash_entry *h;
+ PTR idxptr;
+{
+ int *idx = (int *) idxptr;
+
+ if (h->dynindx != -1
+ && ((h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ || h->root.u.def.section->gc_mark))
+ h->dynindx = (*idx)++;
+
+ return true;
+}
+
+/* Propogate collected vtable information. This is called through
+ elf_link_hash_traverse. */
+
+static boolean
+elf_gc_propagate_vtable_entries_used (h, okp)
+ struct elf_link_hash_entry *h;
+ PTR okp;
+{
+ /* Those that are not vtables. */
+ if (h->vtable_parent == NULL)
+ return true;
+
+ /* Those vtables that do not have parents, we cannot merge. */
+ if (h->vtable_parent == (struct elf_link_hash_entry *) -1)
+ return true;
+
+ /* If we've already been done, exit. */
+ if (h->vtable_entries_used && h->vtable_entries_used[-1])
+ return true;
+
+ /* Make sure the parent's table is up to date. */
+ elf_gc_propagate_vtable_entries_used (h->vtable_parent, okp);
+
+ if (h->vtable_entries_used == NULL)
+ {
+ /* None of this table's entries were referenced. Re-use the
+ parent's table. */
+ h->vtable_entries_used = h->vtable_parent->vtable_entries_used;
+ h->vtable_entries_size = h->vtable_parent->vtable_entries_size;
+ }
+ else
+ {
+ size_t n;
+ boolean *cu, *pu;
+
+ /* Or the parent's entries into ours. */
+ cu = h->vtable_entries_used;
+ cu[-1] = true;
+ pu = h->vtable_parent->vtable_entries_used;
+ if (pu != NULL)
+ {
+ n = h->vtable_parent->vtable_entries_size / FILE_ALIGN;
+ while (--n != 0)
+ {
+ if (*pu) *cu = true;
+ pu++, cu++;
+ }
+ }
+ }
+
+ return true;
+}
+
+static boolean
+elf_gc_smash_unused_vtentry_relocs (h, okp)
+ struct elf_link_hash_entry *h;
+ PTR okp;
+{
+ asection *sec;
+ bfd_vma hstart, hend;
+ Elf_Internal_Rela *relstart, *relend, *rel;
+
+ /* Take care of both those symbols that do not describe vtables as
+ well as those that are not loaded. */
+ if (h->vtable_parent == NULL)
+ return true;
+
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak);
+
+ sec = h->root.u.def.section;
+ hstart = h->root.u.def.value;
+ hend = hstart + h->size;
+
+ relstart = (NAME(_bfd_elf,link_read_relocs)
+ (sec->owner, sec, NULL, (Elf_Internal_Rela *) NULL, true));
+ if (!relstart)
+ return *(boolean *)okp = false;
+ relend = relstart + sec->reloc_count;
+
+ for (rel = relstart; rel < relend; ++rel)
+ if (rel->r_offset >= hstart && rel->r_offset < hend)
+ {
+ /* If the entry is in use, do nothing. */
+ if (h->vtable_entries_used
+ && (rel->r_offset - hstart) < h->vtable_entries_size)
+ {
+ bfd_vma entry = (rel->r_offset - hstart) / FILE_ALIGN;
+ if (h->vtable_entries_used[entry])
+ continue;
+ }
+ /* Otherwise, kill it. */
+ rel->r_offset = rel->r_info = rel->r_addend = 0;
+ }
+
+ return true;
+}
+
+/* Do mark and sweep of unused sections. */
+
+boolean
+elf_gc_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ boolean ok = true;
+ bfd *sub;
+ asection * (*gc_mark_hook)
+ PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *h, Elf_Internal_Sym *));
+
+ if (!get_elf_backend_data (abfd)->can_gc_sections
+ || info->relocateable
+ || elf_hash_table (info)->dynamic_sections_created)
+ return true;
+
+ /* Apply transitive closure to the vtable entry usage info. */
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_gc_propagate_vtable_entries_used,
+ (PTR) &ok);
+ if (!ok)
+ return false;
+
+ /* Kill the vtable relocations that were not used. */
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_gc_smash_unused_vtentry_relocs,
+ (PTR) &ok);
+ if (!ok)
+ return false;
+
+ /* Grovel through relocs to find out who stays ... */
+
+ gc_mark_hook = get_elf_backend_data (abfd)->gc_mark_hook;
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *o;
+ for (o = sub->sections; o != NULL; o = o->next)
+ {
+ if (o->flags & SEC_KEEP)
+ if (!elf_gc_mark (info, o, gc_mark_hook))
+ return false;
+ }
+ }
+
+ /* ... and mark SEC_EXCLUDE for those that go. */
+ if (!elf_gc_sweep(info, get_elf_backend_data (abfd)->gc_sweep_hook))
+ return false;
+
+ return true;
+}
+
+/* Called from check_relocs to record the existance of a VTINHERIT reloc. */
+
+boolean
+elf_gc_record_vtinherit (abfd, sec, h, offset)
+ bfd *abfd;
+ asection *sec;
+ struct elf_link_hash_entry *h;
+ bfd_vma offset;
+{
+ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+ struct elf_link_hash_entry **search, *child;
+ bfd_size_type extsymcount;
+
+ /* The sh_info field of the symtab header tells us where the
+ external symbols start. We don't care about the local symbols at
+ this point. */
+ extsymcount = elf_tdata (abfd)->symtab_hdr.sh_size/sizeof (Elf_External_Sym);
+ if (!elf_bad_symtab (abfd))
+ extsymcount -= elf_tdata (abfd)->symtab_hdr.sh_info;
+
+ sym_hashes = elf_sym_hashes (abfd);
+ sym_hashes_end = sym_hashes + extsymcount;
+
+ /* Hunt down the child symbol, which is in this section at the same
+ offset as the relocation. */
+ for (search = sym_hashes; search != sym_hashes_end; ++search)
+ {
+ if ((child = *search) != NULL
+ && (child->root.type == bfd_link_hash_defined
+ || child->root.type == bfd_link_hash_defweak)
+ && child->root.u.def.section == sec
+ && child->root.u.def.value == offset)
+ goto win;
+ }
+
+ (*_bfd_error_handler) ("%s: %s+%lu: No symbol found for INHERIT",
+ bfd_get_filename (abfd), sec->name,
+ (unsigned long)offset);
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+
+win:
+ if (!h)
+ {
+ /* This *should* only be the absolute section. It could potentially
+ be that someone has defined a non-global vtable though, which
+ would be bad. It isn't worth paging in the local symbols to be
+ sure though; that case should simply be handled by the assembler. */
+
+ child->vtable_parent = (struct elf_link_hash_entry *) -1;
+ }
+ else
+ child->vtable_parent = h;
+
+ return true;
+}
+
+/* Called from check_relocs to record the existance of a VTENTRY reloc. */
+
+boolean
+elf_gc_record_vtentry (abfd, sec, h, addend)
+ bfd *abfd;
+ asection *sec;
+ struct elf_link_hash_entry *h;
+ bfd_vma addend;
+{
+ if (addend >= h->vtable_entries_size)
+ {
+ size_t size, bytes;
+ boolean *ptr = h->vtable_entries_used;
+
+ /* While the symbol is undefined, we have to be prepared to handle
+ a zero size. */
+ if (h->root.type == bfd_link_hash_undefined)
+ size = addend;
+ else
+ {
+ size = h->size;
+ if (size < addend)
+ {
+ /* Oops! We've got a reference past the defined end of
+ the table. This is probably a bug -- shall we warn? */
+ size = addend;
+ }
+ }
+
+ /* Allocate one extra entry for use as a "done" flag for the
+ consolidation pass. */
+ bytes = (size / FILE_ALIGN + 1) * sizeof(boolean);
+
+ if (ptr)
+ {
+ size_t oldbytes;
+
+ ptr = realloc (ptr-1, bytes);
+ if (ptr == NULL)
+ return false;
+
+ oldbytes = (h->vtable_entries_size/FILE_ALIGN + 1) * sizeof(boolean);
+ memset (ptr + oldbytes, 0, bytes - oldbytes);
+ }
+ else
+ {
+ ptr = calloc (1, bytes);
+ if (ptr == NULL)
+ return false;
+ }
+
+ /* And arrange for that done flag to be at index -1. */
+ h->vtable_entries_used = ptr+1;
+ h->vtable_entries_size = size;
+ }
+ h->vtable_entries_used[addend / FILE_ALIGN] = true;
+
+ return true;
+}
+
+/* And an accompanying bit to work out final got entry offsets once
+ we're done. Should be called from final_link. */
+
+boolean
+elf_gc_common_finalize_got_offsets (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd *i;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ bfd_vma gotoff;
+
+ /* The GOT offset is relative to the .got section, but the GOT header is
+ put into the .got.plt section, if the backend uses it. */
+ if (bed->want_got_plt)
+ gotoff = 0;
+ else
+ gotoff = bed->got_header_size;
+
+ /* Do the local .got entries first. */
+ for (i = info->input_bfds; i; i = i->link_next)
+ {
+ bfd_signed_vma *local_got = elf_local_got_refcounts (i);
+ bfd_size_type j, locsymcount;
+ Elf_Internal_Shdr *symtab_hdr;
+
+ if (!local_got)
+ continue;
+
+ symtab_hdr = &elf_tdata (i)->symtab_hdr;
+ if (elf_bad_symtab (i))
+ locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
+ else
+ locsymcount = symtab_hdr->sh_info;
+
+ for (j = 0; j < locsymcount; ++j)
+ {
+ if (local_got[j] > 0)
+ {
+ local_got[j] = gotoff;
+ gotoff += ARCH_SIZE / 8;
+ }
+ else
+ local_got[j] = (bfd_vma) -1;
+ }
+ }
+
+ /* Then the global .got and .plt entries. */
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_gc_allocate_got_offsets,
+ (PTR) &gotoff);
+ return true;
+}
+
+/* We need a special top-level link routine to convert got reference counts
+ to real got offsets. */
+
+static boolean
+elf_gc_allocate_got_offsets (h, offarg)
+ struct elf_link_hash_entry *h;
+ PTR offarg;
+{
+ bfd_vma *off = (bfd_vma *) offarg;
+
+ if (h->got.refcount > 0)
+ {
+ h->got.offset = off[0];
+ off[0] += ARCH_SIZE / 8;
+ }
+ else
+ h->got.offset = (bfd_vma) -1;
+
+ return true;
+}
+
+/* Many folk need no more in the way of final link than this, once
+ got entry reference counting is enabled. */
+
+boolean
+elf_gc_common_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (!elf_gc_common_finalize_got_offsets (abfd, info))
+ return false;
+
+ /* Invoke the regular ELF backend linker to do all the work. */
+ return elf_bfd_final_link (abfd, info);
+}
+
+/* This function will be called though elf_link_hash_traverse to store
+ all hash value of the exported symbols in an array. */
+
+static boolean
+elf_collect_hash_codes (h, data)
+ struct elf_link_hash_entry *h;
+ PTR data;
+{
+ unsigned long **valuep = (unsigned long **) data;
+ const char *name;
+ char *p;
+ unsigned long ha;
+ char *alc = NULL;
+
+ /* Ignore indirect symbols. These are added by the versioning code. */
+ if (h->dynindx == -1)
+ return true;
+
+ name = h->root.root.string;
+ p = strchr (name, ELF_VER_CHR);
+ if (p != NULL)
+ {
+ alc = bfd_malloc (p - name + 1);
+ memcpy (alc, name, p - name);
+ alc[p - name] = '\0';
+ name = alc;
+ }
+
+ /* Compute the hash value. */
+ ha = bfd_elf_hash (name);
+
+ /* Store the found hash value in the array given as the argument. */
+ *(*valuep)++ = ha;
+
+ /* And store it in the struct so that we can put it in the hash table
+ later. */
+ h->elf_hash_value = ha;
+
+ if (alc != NULL)
+ free (alc);
+
+ return true;
+}
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
new file mode 100644
index 00000000000..9acabd1e607
--- /dev/null
+++ b/bfd/elfxx-target.h
@@ -0,0 +1,536 @@
+/* Target definitions for NN-bit ELF
+ Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This structure contains everything that BFD knows about a target.
+ It includes things like its byte order, name, what routines to call
+ to do various operations, etc. Every BFD points to a target structure
+ with its "xvec" member.
+
+ There are two such structures here: one for big-endian machines and
+ one for little-endian machines. */
+
+#define bfd_elfNN_close_and_cleanup _bfd_elf_close_and_cleanup
+#define bfd_elfNN_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#ifndef bfd_elfNN_get_section_contents
+#define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
+#endif
+
+#define bfd_elfNN_canonicalize_dynamic_symtab _bfd_elf_canonicalize_dynamic_symtab
+#define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
+#ifndef bfd_elfNN_find_nearest_line
+#define bfd_elfNN_find_nearest_line _bfd_elf_find_nearest_line
+#endif
+#define bfd_elfNN_read_minisymbols _bfd_elf_read_minisymbols
+#define bfd_elfNN_minisymbol_to_symbol _bfd_elf_minisymbol_to_symbol
+#define bfd_elfNN_get_dynamic_symtab_upper_bound _bfd_elf_get_dynamic_symtab_upper_bound
+#define bfd_elfNN_get_lineno _bfd_elf_get_lineno
+#ifndef bfd_elfNN_get_reloc_upper_bound
+#define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
+#endif
+#define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
+#define bfd_elfNN_get_symtab _bfd_elf_get_symtab
+#define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
+#if 0 /* done in elf-bfd.h */
+#define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
+#endif
+#define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
+#define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
+#define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
+#ifndef bfd_elfNN_set_section_contents
+#define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
+#endif
+#define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
+#define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
+#define bfd_elfNN_write_corefile_contents _bfd_elf_write_corefile_contents
+
+#define bfd_elfNN_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#ifndef elf_backend_got_symbol_offset
+#define elf_backend_got_symbol_offset (bfd_vma) 0
+#endif
+#ifndef elf_backend_want_got_plt
+#define elf_backend_want_got_plt 0
+#endif
+#ifndef elf_backend_plt_readonly
+#define elf_backend_plt_readonly 0
+#endif
+#ifndef elf_backend_want_plt_sym
+#define elf_backend_want_plt_sym 0
+#endif
+#ifndef elf_backend_plt_not_loaded
+#define elf_backend_plt_not_loaded 0
+#endif
+#ifndef elf_backend_plt_alignment
+#define elf_backend_plt_alignment 2
+#endif
+
+#define bfd_elfNN_bfd_debug_info_start bfd_void
+#define bfd_elfNN_bfd_debug_info_end bfd_void
+#define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
+
+#ifndef bfd_elfNN_bfd_get_relocated_section_contents
+#define bfd_elfNN_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#endif
+
+#ifndef bfd_elfNN_bfd_relax_section
+#define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
+#endif
+
+#ifndef elf_backend_can_gc_sections
+#define elf_backend_can_gc_sections 0
+#endif
+#ifndef elf_backend_gc_mark_hook
+#define elf_backend_gc_mark_hook NULL
+#endif
+#ifndef elf_backend_gc_sweep_hook
+#define elf_backend_gc_sweep_hook NULL
+#endif
+#ifndef bfd_elfNN_bfd_gc_sections
+#define bfd_elfNN_bfd_gc_sections _bfd_elfNN_gc_sections
+#endif
+
+#define bfd_elfNN_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
+#ifndef bfd_elfNN_bfd_copy_private_symbol_data
+#define bfd_elfNN_bfd_copy_private_symbol_data \
+ _bfd_elf_copy_private_symbol_data
+#endif
+
+#ifndef bfd_elfNN_bfd_copy_private_section_data
+#define bfd_elfNN_bfd_copy_private_section_data \
+ _bfd_elf_copy_private_section_data
+#endif
+#ifndef bfd_elfNN_bfd_copy_private_bfd_data
+#define bfd_elfNN_bfd_copy_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+#endif
+#ifndef bfd_elfNN_bfd_print_private_bfd_data
+#define bfd_elfNN_bfd_print_private_bfd_data \
+ _bfd_elf_print_private_bfd_data
+#endif
+#ifndef bfd_elfNN_bfd_merge_private_bfd_data
+#define bfd_elfNN_bfd_merge_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+#endif
+#ifndef bfd_elfNN_bfd_set_private_flags
+#define bfd_elfNN_bfd_set_private_flags \
+ ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
+#endif
+#ifndef bfd_elfNN_bfd_is_local_label_name
+#define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
+#endif
+
+#ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
+#define bfd_elfNN_get_dynamic_reloc_upper_bound \
+ _bfd_elf_get_dynamic_reloc_upper_bound
+#endif
+#ifndef bfd_elfNN_canonicalize_dynamic_reloc
+#define bfd_elfNN_canonicalize_dynamic_reloc \
+ _bfd_elf_canonicalize_dynamic_reloc
+#endif
+
+#ifdef elf_backend_relocate_section
+#ifndef bfd_elfNN_bfd_link_hash_table_create
+#define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
+#endif
+#else /* ! defined (elf_backend_relocate_section) */
+/* If no backend relocate_section routine, use the generic linker. */
+#ifndef bfd_elfNN_bfd_link_hash_table_create
+#define bfd_elfNN_bfd_link_hash_table_create \
+ _bfd_generic_link_hash_table_create
+#endif
+#ifndef bfd_elfNN_bfd_link_add_symbols
+#define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#endif
+#ifndef bfd_elfNN_bfd_final_link
+#define bfd_elfNN_bfd_final_link _bfd_generic_final_link
+#endif
+#endif /* ! defined (elf_backend_relocate_section) */
+#ifndef bfd_elfNN_bfd_link_split_section
+#define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
+#endif
+
+#ifndef bfd_elfNN_archive_p
+#define bfd_elfNN_archive_p bfd_generic_archive_p
+#endif
+
+#ifndef bfd_elfNN_write_archive_contents
+#define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
+#endif
+
+#ifndef bfd_elfNN_mkobject
+#define bfd_elfNN_mkobject bfd_elf_mkobject
+#endif
+
+#ifndef bfd_elfNN_mkcorefile
+#define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
+#endif
+
+#ifndef bfd_elfNN_mkarchive
+#define bfd_elfNN_mkarchive _bfd_generic_mkarchive
+#endif
+
+#ifndef elf_symbol_leading_char
+#define elf_symbol_leading_char 0
+#endif
+
+#ifndef elf_info_to_howto
+#define elf_info_to_howto 0
+#endif
+
+#ifndef elf_info_to_howto_rel
+#define elf_info_to_howto_rel 0
+#endif
+
+#ifndef ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE 1
+#endif
+
+#ifndef elf_backend_collect
+#define elf_backend_collect false
+#endif
+#ifndef elf_backend_type_change_ok
+#define elf_backend_type_change_ok false
+#endif
+
+#ifndef elf_backend_sym_is_global
+#define elf_backend_sym_is_global 0
+#endif
+#ifndef elf_backend_object_p
+#define elf_backend_object_p 0
+#endif
+#ifndef elf_backend_symbol_processing
+#define elf_backend_symbol_processing 0
+#endif
+#ifndef elf_backend_symbol_table_processing
+#define elf_backend_symbol_table_processing 0
+#endif
+#ifndef elf_backend_get_symbol_type
+#define elf_backend_get_symbol_type 0
+#endif
+#ifndef elf_backend_section_processing
+#define elf_backend_section_processing 0
+#endif
+#ifndef elf_backend_section_from_shdr
+#define elf_backend_section_from_shdr 0
+#endif
+#ifndef elf_backend_fake_sections
+#define elf_backend_fake_sections 0
+#endif
+#ifndef elf_backend_section_from_bfd_section
+#define elf_backend_section_from_bfd_section 0
+#endif
+#ifndef elf_backend_add_symbol_hook
+#define elf_backend_add_symbol_hook 0
+#endif
+#ifndef elf_backend_link_output_symbol_hook
+#define elf_backend_link_output_symbol_hook 0
+#endif
+#ifndef elf_backend_create_dynamic_sections
+#define elf_backend_create_dynamic_sections 0
+#endif
+#ifndef elf_backend_check_relocs
+#define elf_backend_check_relocs 0
+#endif
+#ifndef elf_backend_adjust_dynamic_symbol
+#define elf_backend_adjust_dynamic_symbol 0
+#endif
+#ifndef elf_backend_always_size_sections
+#define elf_backend_always_size_sections 0
+#endif
+#ifndef elf_backend_size_dynamic_sections
+#define elf_backend_size_dynamic_sections 0
+#endif
+#ifndef elf_backend_relocate_section
+#define elf_backend_relocate_section 0
+#endif
+#ifndef elf_backend_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_symbol 0
+#endif
+#ifndef elf_backend_finish_dynamic_sections
+#define elf_backend_finish_dynamic_sections 0
+#endif
+#ifndef elf_backend_begin_write_processing
+#define elf_backend_begin_write_processing 0
+#endif
+#ifndef elf_backend_final_write_processing
+#define elf_backend_final_write_processing 0
+#endif
+#ifndef elf_backend_additional_program_headers
+#define elf_backend_additional_program_headers 0
+#endif
+#ifndef elf_backend_modify_segment_map
+#define elf_backend_modify_segment_map 0
+#endif
+#ifndef elf_backend_ecoff_debug_swap
+#define elf_backend_ecoff_debug_swap 0
+#endif
+#ifndef elf_backend_got_header_size
+#define elf_backend_got_header_size 0
+#endif
+#ifndef elf_backend_plt_header_size
+#define elf_backend_plt_header_size 0
+#endif
+
+#ifndef ELF_MACHINE_ALT1
+#define ELF_MACHINE_ALT1 0
+#endif
+
+#ifndef ELF_MACHINE_ALT2
+#define ELF_MACHINE_ALT2 0
+#endif
+
+#ifndef elf_backend_size_info
+#define elf_backend_size_info _bfd_elfNN_size_info
+#endif
+
+extern const struct elf_size_info _bfd_elfNN_size_info;
+
+static CONST struct elf_backend_data elfNN_bed =
+{
+#ifdef USE_REL
+ 0, /* use_rela_p */
+#else
+ 1, /* use_rela_p */
+#endif
+ ELF_ARCH, /* arch */
+ ELF_MACHINE_CODE, /* elf_machine_code */
+ ELF_MAXPAGESIZE, /* maxpagesize */
+ elf_backend_collect,
+ elf_backend_type_change_ok,
+ elf_info_to_howto,
+ elf_info_to_howto_rel,
+ elf_backend_sym_is_global,
+ elf_backend_object_p,
+ elf_backend_symbol_processing,
+ elf_backend_symbol_table_processing,
+ elf_backend_get_symbol_type,
+ elf_backend_section_processing,
+ elf_backend_section_from_shdr,
+ elf_backend_fake_sections,
+ elf_backend_section_from_bfd_section,
+ elf_backend_add_symbol_hook,
+ elf_backend_link_output_symbol_hook,
+ elf_backend_create_dynamic_sections,
+ elf_backend_check_relocs,
+ elf_backend_adjust_dynamic_symbol,
+ elf_backend_always_size_sections,
+ elf_backend_size_dynamic_sections,
+ elf_backend_relocate_section,
+ elf_backend_finish_dynamic_symbol,
+ elf_backend_finish_dynamic_sections,
+ elf_backend_begin_write_processing,
+ elf_backend_final_write_processing,
+ elf_backend_additional_program_headers,
+ elf_backend_modify_segment_map,
+ elf_backend_gc_mark_hook,
+ elf_backend_gc_sweep_hook,
+ elf_backend_ecoff_debug_swap,
+ ELF_MACHINE_ALT1,
+ ELF_MACHINE_ALT2,
+ &elf_backend_size_info,
+ elf_backend_got_symbol_offset,
+ elf_backend_got_header_size,
+ elf_backend_plt_header_size,
+ elf_backend_want_got_plt,
+ elf_backend_plt_readonly,
+ elf_backend_want_plt_sym,
+ elf_backend_plt_not_loaded,
+ elf_backend_plt_alignment,
+ elf_backend_can_gc_sections
+};
+
+#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_elf_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 |
+ DYNAMIC | WP_TEXT | D_PAGED),
+
+ /* section_flags: mask of all section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
+ SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
+
+ /* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ elf_symbol_leading_char,
+
+ /* ar_pad_char: pad character for filenames within an archive header
+ FIXME: this really has nothing to do with ELF, 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 ELF, this is a characteristic
+ of the archiver and should be independently tunable. This value is
+ a WAG (wild a** guess) */
+ 14,
+
+ /* 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 */
+ bfd_elfNN_object_p, /* assembler/linker output (object file) */
+ bfd_elfNN_archive_p, /* an archive */
+ bfd_elfNN_core_file_p /* a core file */
+ },
+
+ /* bfd_set_format: set the format of a file being written */
+ { bfd_false,
+ bfd_elfNN_mkobject,
+ bfd_elfNN_mkarchive,
+ bfd_elfNN_mkcorefile
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ bfd_elfNN_write_object_contents,
+ bfd_elfNN_write_archive_contents,
+ bfd_elfNN_write_corefile_contents,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
+ BFD_JUMP_TABLE_COPY (bfd_elfNN),
+ BFD_JUMP_TABLE_CORE (bfd_elfNN),
+#ifdef bfd_elfNN_archive_functions
+ BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
+#else
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+#endif
+ BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
+ BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
+ BFD_JUMP_TABLE_WRITE (bfd_elfNN),
+ BFD_JUMP_TABLE_LINK (bfd_elfNN),
+ BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
+
+ /* backend_data: */
+ (PTR) &elfNN_bed,
+};
+#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_elf_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 |
+ DYNAMIC | WP_TEXT | D_PAGED),
+
+ /* section_flags: mask of all section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
+ SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
+
+ /* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ elf_symbol_leading_char,
+
+ /* ar_pad_char: pad character for filenames within an archive header
+ FIXME: this really has nothing to do with ELF, 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 ELF, this is a characteristic
+ of the archiver and should be independently tunable. This value is
+ a WAG (wild a** guess) */
+ 14,
+
+ /* 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 */
+ bfd_elfNN_object_p, /* assembler/linker output (object file) */
+ bfd_elfNN_archive_p, /* an archive */
+ bfd_elfNN_core_file_p /* a core file */
+ },
+
+ /* bfd_set_format: set the format of a file being written */
+ { bfd_false,
+ bfd_elfNN_mkobject,
+ bfd_elfNN_mkarchive,
+ bfd_elfNN_mkcorefile
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ bfd_elfNN_write_object_contents,
+ bfd_elfNN_write_archive_contents,
+ bfd_elfNN_write_corefile_contents,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
+ BFD_JUMP_TABLE_COPY (bfd_elfNN),
+ BFD_JUMP_TABLE_CORE (bfd_elfNN),
+#ifdef bfd_elfNN_archive_functions
+ BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
+#else
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+#endif
+ BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
+ BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
+ BFD_JUMP_TABLE_WRITE (bfd_elfNN),
+ BFD_JUMP_TABLE_LINK (bfd_elfNN),
+ BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
+
+ /* backend_data: */
+ (PTR) &elfNN_bed,
+};
+#endif
diff --git a/bfd/epoc-pe-arm.c b/bfd/epoc-pe-arm.c
new file mode 100644
index 00000000000..ea89a0b1257
--- /dev/null
+++ b/bfd/epoc-pe-arm.c
@@ -0,0 +1,30 @@
+/* BFD back-end for ARM EPOC PE files.
+ Copyright 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_UNDERSCORE 0
+#define USER_LABEL_PREFIX ""
+
+#define TARGET_LITTLE_SYM arm_epoc_pe_little_vec
+#define TARGET_LITTLE_NAME "epoc-pe-arm-little"
+#define TARGET_BIG_SYM arm_epoc_pe_big_vec
+#define TARGET_BIG_NAME "epoc-pe-arm-big"
+
+
+#include "pe-arm.c"
+
diff --git a/bfd/epoc-pei-arm.c b/bfd/epoc-pei-arm.c
new file mode 100644
index 00000000000..0f2548d3809
--- /dev/null
+++ b/bfd/epoc-pei-arm.c
@@ -0,0 +1,29 @@
+/* BFD back-end for ARM EPOC PE IMAGE COFF files.
+ Copyright 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_UNDERSCORE 0
+#define USER_LABEL_PREFIX ""
+
+#define TARGET_LITTLE_SYM arm_epoc_pei_little_vec
+#define TARGET_LITTLE_NAME "epoc-pei-arm-little"
+#define TARGET_BIG_SYM arm_epoc_pei_big_vec
+#define TARGET_BIG_NAME "epoc-pei-arm-big"
+
+#include "pei-arm.c"
+
diff --git a/bfd/format.c b/bfd/format.c
new file mode 100644
index 00000000000..c9f1f9cd4be
--- /dev/null
+++ b/bfd/format.c
@@ -0,0 +1,342 @@
+/* Generic BFD support for file formats.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1999 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ File formats
+
+ A format is a BFD concept of high level file contents type. The
+ formats supported by BFD are:
+
+ o <<bfd_object>>
+
+ The BFD may contain data, symbols, relocations and debug info.
+
+ o <<bfd_archive>>
+
+ The BFD contains other BFDs and an optional index.
+
+ o <<bfd_core>>
+
+ The BFD contains the result of an executable core dump.
+
+
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/* IMPORT from targets.c. */
+extern const size_t _bfd_target_vector_entries;
+
+/*
+FUNCTION
+ bfd_check_format
+
+SYNOPSIS
+ boolean bfd_check_format(bfd *abfd, bfd_format format);
+
+DESCRIPTION
+ Verify if the file attached to the BFD @var{abfd} is compatible
+ with the format @var{format} (i.e., one of <<bfd_object>>,
+ <<bfd_archive>> or <<bfd_core>>).
+
+ If the BFD has been set to a specific target before the
+ call, only the named target and format combination is
+ checked. If the target has not been set, or has been set to
+ <<default>>, then all the known target backends is
+ interrogated to determine a match. If the default target
+ matches, it is used. If not, exactly one target must recognize
+ the file, or an error results.
+
+ The function returns <<true>> on success, otherwise <<false>>
+ with one of the following error codes:
+
+ o <<bfd_error_invalid_operation>> -
+ if <<format>> is not one of <<bfd_object>>, <<bfd_archive>> or
+ <<bfd_core>>.
+
+ o <<bfd_error_system_call>> -
+ if an error occured during a read - even some file mismatches
+ can cause bfd_error_system_calls.
+
+ o <<file_not_recognised>> -
+ none of the backends recognised the file format.
+
+ o <<bfd_error_file_ambiguously_recognized>> -
+ more than one backend recognised the file format.
+*/
+
+boolean
+bfd_check_format (abfd, format)
+ bfd *abfd;
+ bfd_format format;
+{
+ return bfd_check_format_matches (abfd, format, NULL);
+}
+
+/*
+FUNCTION
+ bfd_check_format_matches
+
+SYNOPSIS
+ boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching);
+
+DESCRIPTION
+ Like <<bfd_check_format>>, except when it returns false with
+ <<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>. In that
+ case, if @var{matching} is not NULL, it will be filled in with
+ a NULL-terminated list of the names of the formats that matched,
+ allocated with <<malloc>>.
+ Then the user may choose a format and try again.
+
+ When done with the list that @var{matching} points to, the caller
+ should free it.
+*/
+
+boolean
+bfd_check_format_matches (abfd, format, matching)
+ bfd *abfd;
+ bfd_format format;
+ char ***matching;
+{
+ extern const bfd_target binary_vec;
+ const bfd_target * const *target, *save_targ, *right_targ;
+ char **matching_vector = NULL;
+ int match_count;
+
+ if (!bfd_read_p (abfd) ||
+ ((int)(abfd->format) < (int)bfd_unknown) ||
+ ((int)(abfd->format) >= (int)bfd_type_end)) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ if (abfd->format != bfd_unknown)
+ return (abfd->format == format)? true: false;
+
+
+ /* Since the target type was defaulted, check them
+ all in the hope that one will be uniquely recognized. */
+
+ save_targ = abfd->xvec;
+ match_count = 0;
+ if (matching)
+ {
+ matching_vector =
+ (char **) bfd_malloc (sizeof (char *) *
+ (_bfd_target_vector_entries + 1));
+ if (!matching_vector)
+ return false;
+ matching_vector[0] = NULL;
+ *matching = matching_vector;
+ }
+ right_targ = 0;
+
+
+ /* presume the answer is yes */
+ abfd->format = format;
+
+ /* If the target type was explicitly specified, just check that target. */
+
+ if (!abfd->target_defaulted) {
+ if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0) /* rewind! */
+ return false;
+ right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
+ if (right_targ) {
+ abfd->xvec = right_targ; /* Set the target as returned */
+ if (matching)
+ free (matching_vector);
+ return true; /* File position has moved, BTW */
+ }
+
+ /* For a long time the code has dropped through to check all
+ targets if the specified target was wrong. I don't know why,
+ and I'm reluctant to change it. However, in the case of an
+ archive, it can cause problems. If the specified target does
+ not permit archives (e.g., the binary target), then we should
+ not allow some other target to recognize it as an archive, but
+ should instead allow the specified target to recognize it as an
+ object. When I first made this change, it broke the PE target,
+ because the specified pei-i386 target did not recognize the
+ actual pe-i386 archive. Since there may be other problems of
+ this sort, I changed this test to check only for the binary
+ target. */
+
+ if (format == bfd_archive && save_targ == &binary_vec)
+ {
+ abfd->xvec = save_targ;
+ abfd->format = bfd_unknown;
+ if (matching)
+ free (matching_vector);
+ bfd_set_error (bfd_error_file_not_recognized);
+ return false;
+ }
+ }
+
+ for (target = bfd_target_vector; *target != NULL; target++) {
+ const bfd_target *temp;
+
+ if (*target == &binary_vec)
+ continue;
+
+ abfd->xvec = *target; /* Change BFD's target temporarily */
+ if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0)
+ return false;
+ /* If _bfd_check_format neglects to set bfd_error, assume bfd_error_wrong_format.
+ We didn't used to even pay any attention to bfd_error, so I suspect
+ that some _bfd_check_format might have this problem. */
+ bfd_set_error (bfd_error_wrong_format);
+ temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
+ if (temp) { /* This format checks out as ok! */
+ right_targ = temp;
+ if (matching)
+ {
+ matching_vector[match_count] = temp->name;
+ matching_vector[match_count + 1] = NULL;
+ }
+ match_count++;
+ /* If this is the default target, accept it, even if other targets
+ might match. People who want those other targets have to set
+ the GNUTARGET variable. */
+ if (temp == bfd_default_vector[0])
+ {
+ if (matching)
+ {
+ matching_vector[0] = temp->name;
+ matching_vector[1] = NULL;
+ }
+ match_count = 1;
+ break;
+ }
+#ifdef GNU960
+ /* Big- and little-endian b.out archives look the same, but it doesn't
+ * matter: there is no difference in their headers, and member file byte
+ * orders will (I hope) be handled appropriately by bfd. Ditto for big
+ * and little coff archives. And the 4 coff/b.out object formats are
+ * unambiguous. So accept the first match we find.
+ */
+ break;
+#endif
+ } else if (bfd_get_error () != bfd_error_wrong_format) {
+ abfd->xvec = save_targ;
+ abfd->format = bfd_unknown;
+ if (matching && bfd_get_error () != bfd_error_file_ambiguously_recognized)
+ free (matching_vector);
+ return false;
+ }
+ }
+
+ if (match_count == 1) {
+ abfd->xvec = right_targ; /* Change BFD's target permanently */
+ if (matching)
+ free (matching_vector);
+ return true; /* File position has moved, BTW */
+ }
+
+ abfd->xvec = save_targ; /* Restore original target type */
+ abfd->format = bfd_unknown; /* Restore original format */
+ if (match_count == 0)
+ {
+ bfd_set_error (bfd_error_file_not_recognized);
+ if (matching)
+ free (matching_vector);
+ }
+ else
+ bfd_set_error (bfd_error_file_ambiguously_recognized);
+ return false;
+}
+
+/*
+FUNCTION
+ bfd_set_format
+
+SYNOPSIS
+ boolean bfd_set_format(bfd *abfd, bfd_format format);
+
+DESCRIPTION
+ This function sets the file format of the BFD @var{abfd} to the
+ format @var{format}. If the target set in the BFD does not
+ support the format requested, the format is invalid, or the BFD
+ is not open for writing, then an error occurs.
+
+*/
+
+boolean
+bfd_set_format (abfd, format)
+ bfd *abfd;
+ bfd_format format;
+{
+
+ if (bfd_read_p (abfd) ||
+ ((int)abfd->format < (int)bfd_unknown) ||
+ ((int)abfd->format >= (int)bfd_type_end)) {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ if (abfd->format != bfd_unknown)
+ return (abfd->format == format) ? true:false;
+
+ /* presume the answer is yes */
+ abfd->format = format;
+
+ if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd))) {
+ abfd->format = bfd_unknown;
+ return false;
+ }
+
+ return true;
+}
+
+
+/*
+FUNCTION
+ bfd_format_string
+
+SYNOPSIS
+ CONST char *bfd_format_string(bfd_format format);
+
+DESCRIPTION
+ Return a pointer to a const string
+ <<invalid>>, <<object>>, <<archive>>, <<core>>, or <<unknown>>,
+ depending upon the value of @var{format}.
+*/
+
+CONST char *
+bfd_format_string (format)
+ bfd_format format;
+{
+ if (((int)format <(int) bfd_unknown)
+ || ((int)format >=(int) bfd_type_end))
+ return "invalid";
+
+ switch (format) {
+ case bfd_object:
+ return "object"; /* linker/assember/compiler output */
+ case bfd_archive:
+ return "archive"; /* object archive file */
+ case bfd_core:
+ return "core"; /* core dump */
+ default:
+ return "unknown";
+ }
+}
diff --git a/bfd/freebsd.h b/bfd/freebsd.h
new file mode 100644
index 00000000000..8bb19acd7d3
--- /dev/null
+++ b/bfd/freebsd.h
@@ -0,0 +1,110 @@
+/* BFD back-end definitions used by all FreeBSD targets.
+ Copyright (C) 1990, 1991, 1992, 1996 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* FreeBSD ZMAGIC files never have the header in the text. */
+#define N_HEADER_IN_TEXT(x) 0
+
+/* ZMAGIC files start at offset 0. Does not apply to QMAGIC files. */
+#define TEXT_START_ADDR 0
+
+#define N_GETMAGIC_NET(exec) \
+ ((exec).a_info & 0xffff)
+#define N_GETMID_NET(exec) \
+ (((exec).a_info >> 16) & 0x3ff)
+#define N_GETFLAG_NET(ex) \
+ (((exec).a_info >> 26) & 0x3f)
+
+#define N_MACHTYPE(exec) \
+ ((enum machine_type) \
+ ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
+ ((exec).a_info >> 16) & 0x3ff))
+#define N_FLAGS(exec) \
+ ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (exec) : \
+ ((exec).a_info >> 26) & 0x3f)
+
+#define N_SET_INFO(exec, magic, type, flags) \
+ ((exec).a_info = ((magic) & 0xffff) \
+ | (((int)(type) & 0x3ff) << 16) \
+ | (((flags) & 0x3f) << 26))
+#define N_SET_MACHTYPE(exec, machtype) \
+ ((exec).a_info = \
+ ((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
+#define N_SET_FLAGS(exec, flags) \
+ ((exec).a_info = \
+ ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+/* On FreeBSD, the magic number is always in i386 (little-endian)
+ format. I think. */
+#define SWAP_MAGIC(ext) bfd_getl32 (ext)
+
+
+#define MY_write_object_contents MY(write_object_contents)
+static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
+
+#include "aout-target.h"
+
+/* Write an object file.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+static boolean
+MY(write_object_contents) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+#if CHOOSE_RELOC_SIZE
+ CHOOSE_RELOC_SIZE(abfd);
+#else
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+#endif
+
+ /* Magic number, maestro, please! */
+ switch (bfd_get_arch(abfd)) {
+ case bfd_arch_m68k:
+ if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
+ N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
+ else
+ N_SET_MACHTYPE(*execp, M_68K_NETBSD);
+ break;
+ case bfd_arch_sparc:
+ N_SET_MACHTYPE(*execp, M_SPARC_NETBSD);
+ break;
+ case bfd_arch_i386:
+ N_SET_MACHTYPE(*execp, M_386_NETBSD);
+ break;
+ case bfd_arch_ns32k:
+ N_SET_MACHTYPE(*execp, M_532_NETBSD);
+ break;
+ default:
+ N_SET_MACHTYPE(*execp, M_UNKNOWN);
+ break;
+ }
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
diff --git a/bfd/gen-aout.c b/bfd/gen-aout.c
new file mode 100644
index 00000000000..b5ed91a096b
--- /dev/null
+++ b/bfd/gen-aout.c
@@ -0,0 +1,101 @@
+/* Generate parameters for an a.out system.
+ Copyright (C) 1990, 91, 92, 93, 94, 98 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "/usr/include/a.out.h"
+#include <stdio.h>
+
+int
+main (argc, argv)
+ int argc; char** argv;
+{
+ struct exec my_exec;
+ int page_size;
+ char *target = "unknown", *arch = "unknown";
+ FILE *file = fopen("gen-aout", "r");
+
+ if (file == NULL) {
+ fprintf(stderr, "Cannot open gen-aout!\n");
+ return -1;
+ }
+ if (fread(&my_exec, sizeof(struct exec), 1, file) != 1) {
+ fprintf(stderr, "Cannot read gen-aout!\n");
+ return -1;
+ }
+
+ target = argv[1];
+ if (target == NULL) {
+ fprintf(stderr, "Usage: gen-aout target_name\n");
+ exit (1);
+ }
+
+#ifdef N_TXTOFF
+ page_size = N_TXTOFF(my_exec);
+ if (page_size == 0)
+ printf("#define N_HEADER_IN_TEXT(x) 1\n");
+ else
+ printf("#define N_HEADER_IN_TEXT(x) 0\n");
+#endif
+
+ printf("#define BYTES_IN_WORD %d\n", sizeof (int));
+ if (my_exec.a_entry == 0) {
+ printf("#define ENTRY_CAN_BE_ZERO\n");
+ printf("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n");
+ }
+ else {
+ printf("/*#define ENTRY_CAN_BE_ZERO*/\n");
+ printf("/*#define N_SHARED_LIB(x) 0*/\n");
+ }
+
+ printf("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
+
+#ifdef PAGSIZ
+ if (page_size == 0)
+ page_size = PAGSIZ;
+#endif
+ if (page_size != 0)
+ printf("#define TARGET_PAGE_SIZE %d\n", page_size);
+ else
+ printf("/* #define TARGET_PAGE_SIZE ??? */\n");
+ printf("#define SEGMENT_SIZE TARGET_PAGE_SIZE\n");
+
+#ifdef vax
+ arch = "vax";
+#endif
+#ifdef m68k
+ arch = "m68k";
+#endif
+ if (arch[0] == '1')
+ {
+ fprintf (stderr, _("warning: preprocessor substituted architecture name inside string;"));
+ fprintf (stderr, _(" fix DEFAULT_ARCH in the output file yourself\n"));
+ arch = "unknown";
+ }
+ printf("#define DEFAULT_ARCH bfd_arch_%s\n", arch);
+
+ printf("\n#define MY(OP) CAT(%s_,OP)\n", target);
+ printf("#define TARGETNAME \"a.out-%s\"\n\n", target);
+
+ printf("#include \"bfd.h\"\n");
+ printf("#include \"sysdep.h\"\n");
+ printf("#include \"libbfd.h\"\n");
+ printf("#include \"libaout.h\"\n");
+ printf("\n#include \"aout-target.h\"\n");
+
+ return 0;
+}
diff --git a/bfd/genlink.h b/bfd/genlink.h
new file mode 100644
index 00000000000..0e0a8de300e
--- /dev/null
+++ b/bfd/genlink.h
@@ -0,0 +1,111 @@
+/* genlink.h -- interface to the BFD generic linker
+ Copyright 1993, 1994 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef GENLINK_H
+#define GENLINK_H
+
+/* This header file is internal to BFD. It describes the internal
+ structures and functions used by the BFD generic linker, in case
+ any of the more specific linkers want to use or call them. Note
+ that some functions, such as _bfd_generic_link_hash_table_create,
+ are declared in libbfd.h, because they are expected to be widely
+ used. The functions and structures in this file will probably only
+ be used by a few files besides linker.c itself. In fact, this file
+ is not particularly complete; I have only put in the interfaces I
+ actually needed. */
+
+/* The generic linker uses a hash table which is a derived class of
+ the standard linker hash table, just as the other backend specific
+ linkers do. Do not confuse the generic linker hash table with the
+ standard BFD linker hash table it is built upon. */
+
+/* Generic linker hash table entries. */
+
+struct generic_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+ /* Whether this symbol has been written out. */
+ boolean written;
+ /* Symbol from input BFD. */
+ asymbol *sym;
+};
+
+/* Generic linker hash table. */
+
+struct generic_link_hash_table
+{
+ struct bfd_link_hash_table root;
+};
+
+/* Look up an entry in an generic link hash table. */
+
+#define _bfd_generic_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct generic_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
+
+/* Traverse an generic link hash table. */
+
+#define _bfd_generic_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the generic link hash table from the info structure. This is
+ just a cast. */
+
+#define _bfd_generic_hash_table(p) \
+ ((struct generic_link_hash_table *) ((p)->hash))
+
+/* The generic linker reads in the asymbol structures for an input BFD
+ and keeps them in the outsymbol and symcount fields. */
+
+#define _bfd_generic_link_get_symbols(abfd) ((abfd)->outsymbols)
+#define _bfd_generic_link_get_symcount(abfd) ((abfd)->symcount)
+
+/* Add the symbols of input_bfd to the symbols being built for
+ output_bfd. */
+extern boolean _bfd_generic_link_output_symbols
+ PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
+ size_t *psymalloc));
+
+/* This structure is used to pass information to
+ _bfd_generic_link_write_global_symbol, which may be called via
+ _bfd_generic_link_hash_traverse. */
+
+struct generic_write_global_symbol_info
+{
+ struct bfd_link_info *info;
+ bfd *output_bfd;
+ size_t *psymalloc;
+};
+
+/* Write out a single global symbol. This is expected to be called
+ via _bfd_generic_link_hash_traverse. The second argument must
+ actually be a struct generic_write_global_symbol_info *. */
+extern boolean _bfd_generic_link_write_global_symbol
+ PARAMS ((struct generic_link_hash_entry *, PTR));
+
+/* Generic link hash table entry creation routine. */
+struct bfd_hash_entry *_bfd_generic_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
+ const char *));
+
+#endif
diff --git a/bfd/go32stub.h b/bfd/go32stub.h
new file mode 100644
index 00000000000..3e4388c087b
--- /dev/null
+++ b/bfd/go32stub.h
@@ -0,0 +1,128 @@
+0x4d,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x27,0x00,0xff,0xff,0x00,0x00,
+0x60,0x07,0x00,0x00,0x54,0x00,0x00,0x00,0x0d,0x0a,0x73,0x74,0x75,0x62,0x2e,0x68,
+0x20,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x20,0x66,0x72,0x6f,0x6d,0x20,
+0x73,0x74,0x75,0x62,0x2e,0x61,0x73,0x6d,0x20,0x62,0x79,0x20,0x64,0x6a,0x61,0x73,
+0x6d,0x2c,0x20,0x6f,0x6e,0x20,0x57,0x65,0x64,0x20,0x4a,0x75,0x6e,0x20,0x31,0x31,
+0x20,0x31,0x36,0x3a,0x30,0x39,0x3a,0x31,0x35,0x20,0x31,0x39,0x39,0x37,0x0d,0x0a,
+0x54,0x68,0x65,0x20,0x53,0x54,0x55,0x42,0x2e,0x45,0x58,0x45,0x20,0x73,0x74,0x75,
+0x62,0x20,0x6c,0x6f,0x61,0x64,0x65,0x72,0x20,0x69,0x73,0x20,0x43,0x6f,0x70,0x79,
+0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x43,0x29,0x20,0x31,0x39,0x39,0x33,0x2d,0x31,
+0x39,0x39,0x35,0x20,0x44,0x4a,0x20,0x44,0x65,0x6c,0x6f,0x72,0x69,0x65,0x2e,0x20,
+0x0d,0x0a,0x50,0x65,0x72,0x6d,0x69,0x73,0x73,0x69,0x6f,0x6e,0x20,0x67,0x72,0x61,
+0x6e,0x74,0x65,0x64,0x20,0x74,0x6f,0x20,0x75,0x73,0x65,0x20,0x66,0x6f,0x72,0x20,
+0x61,0x6e,0x79,0x20,0x70,0x75,0x72,0x70,0x6f,0x73,0x65,0x20,0x70,0x72,0x6f,0x76,
+0x69,0x64,0x65,0x64,0x20,0x74,0x68,0x69,0x73,0x20,0x63,0x6f,0x70,0x79,0x72,0x69,
+0x67,0x68,0x74,0x20,0x0d,0x0a,0x72,0x65,0x6d,0x61,0x69,0x6e,0x73,0x20,0x70,0x72,
+0x65,0x73,0x65,0x6e,0x74,0x20,0x61,0x6e,0x64,0x20,0x75,0x6e,0x6d,0x6f,0x64,0x69,
+0x66,0x69,0x65,0x64,0x2e,0x20,0x0d,0x0a,0x54,0x68,0x69,0x73,0x20,0x6f,0x6e,0x6c,
+0x79,0x20,0x61,0x70,0x70,0x6c,0x69,0x65,0x73,0x20,0x74,0x6f,0x20,0x74,0x68,0x65,
+0x20,0x73,0x74,0x75,0x62,0x2c,0x20,0x61,0x6e,0x64,0x20,0x6e,0x6f,0x74,0x20,0x6e,
+0x65,0x63,0x63,0x65,0x73,0x73,0x61,0x72,0x69,0x6c,0x79,0x20,0x74,0x68,0x65,0x20,
+0x77,0x68,0x6f,0x6c,0x65,0x20,0x70,0x72,0x6f,0x67,0x72,0x61,0x6d,0x2e,0x0a,0x0d,
+0x0a,0x24,0x49,0x64,0x3a,0x20,0x73,0x74,0x75,0x62,0x2e,0x61,0x73,0x6d,0x20,0x62,
+0x75,0x69,0x6c,0x74,0x20,0x30,0x36,0x2f,0x31,0x31,0x2f,0x39,0x37,0x20,0x31,0x36,
+0x3a,0x30,0x39,0x3a,0x31,0x35,0x20,0x62,0x79,0x20,0x64,0x6a,0x61,0x73,0x6d,0x20,
+0x24,0x0a,0x0d,0x0a,0x40,0x28,0x23,0x29,0x20,0x73,0x74,0x75,0x62,0x2e,0x61,0x73,
+0x6d,0x20,0x62,0x75,0x69,0x6c,0x74,0x20,0x30,0x36,0x2f,0x31,0x31,0x2f,0x39,0x37,
+0x20,0x31,0x36,0x3a,0x30,0x39,0x3a,0x31,0x35,0x20,0x62,0x79,0x20,0x64,0x6a,0x61,
+0x73,0x6d,0x0a,0x0d,0x0a,0x1a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x67,0x6f,0x33,0x32,0x73,0x74,0x75,0x62,0x2c,0x20,0x76,0x20,0x32,0x2e,0x30,0x30,
+0x54,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x43,0x57,0x53,0x44,0x50,0x4d,0x49,0x2e,0x45,0x58,0x45,0x00,
+0x00,0x00,0x00,0x00,0x0e,0x1f,0x8c,0x1e,0x24,0x00,0x8c,0x06,0x60,0x07,0xfc,0xb4,
+0x30,0xcd,0x21,0x3c,0x03,0x73,0x06,0xba,0x86,0x05,0xe9,0xb2,0x03,0xa2,0x69,0x08,
+0xbb,0x70,0x08,0xa1,0x20,0x00,0x39,0xc3,0x73,0x02,0x89,0xc3,0x89,0x1e,0x20,0x00,
+0xfe,0xc7,0xb9,0x04,0xff,0xd3,0xeb,0xb4,0x4a,0xcd,0x21,0x73,0x0a,0xd3,0xe3,0xfe,
+0xcf,0x89,0x1e,0x20,0x00,0xeb,0xd9,0x26,0x8e,0x06,0x2c,0x00,0x31,0xff,0x30,0xc0,
+0xa9,0xf2,0xae,0x26,0x81,0x3d,0x50,0x41,0x75,0x15,0xaf,0x26,0x81,0x3d,0x54,0x48,
+0x75,0x0d,0xaf,0x26,0x80,0x3d,0x3d,0x75,0x06,0x47,0x89,0x3e,0x67,0x04,0x4f,0xae,
+0x75,0xdf,0xaf,0x06,0x57,0x31,0xc9,0x74,0x10,0xba,0x5d,0x05,0xe9,0x50,0x03,0x09,
+0xc9,0x75,0xf6,0x41,0xe8,0x92,0x03,0x72,0xf0,0xb8,0x87,0x16,0xcd,0x2f,0x09,0xc0,
+0x75,0xed,0x80,0xe3,0x01,0x74,0xe8,0x89,0x3e,0x00,0x06,0x8c,0x06,0x02,0x06,0x89,
+0x36,0x04,0x06,0x5f,0x07,0xe8,0xd5,0x02,0x89,0x3e,0x2a,0x00,0x89,0x36,0x62,0x07,
+0x80,0x3e,0x2c,0x00,0x00,0x74,0x24,0xb9,0x08,0x00,0xbf,0x2c,0x00,0x8a,0x05,0x47,
+0x08,0xc0,0x74,0x05,0x88,0x07,0x43,0xe2,0xf4,0x66,0xc7,0x07,0x2e,0x45,0x58,0x45,
+0x81,0xc3,0x04,0x00,0xc6,0x07,0x00,0x89,0x1e,0x62,0x07,0xb8,0x00,0x3d,0xba,0x64,
+0x07,0xcd,0x21,0x0f,0x82,0xb4,0x02,0xa3,0x06,0x06,0x89,0xc3,0xb9,0x06,0x00,0xba,
+0xb5,0x07,0xb4,0x3f,0xcd,0x21,0x31,0xd2,0x31,0xc9,0xa1,0xb5,0x07,0x3d,0x4c,0x01,
+0x74,0x1b,0x3d,0x4d,0x5a,0x0f,0x85,0x97,0x02,0x8b,0x16,0xb9,0x07,0xc1,0xe2,0x09,
+0x8b,0x1e,0xb7,0x07,0x09,0xdb,0x74,0x05,0x80,0xee,0x02,0x01,0xda,0x89,0x16,0xbb,
+0x07,0x89,0x0e,0xbd,0x07,0xb8,0x00,0x42,0x8b,0x1e,0x06,0x06,0xcd,0x21,0xb9,0xa8,
+0x00,0xba,0xbf,0x07,0xb4,0x3f,0xcd,0x21,0x3d,0xa8,0x00,0x75,0x06,0x81,0x3e,0xbf,
+0x07,0x4c,0x01,0x0f,0x85,0x5e,0x02,0x66,0xa1,0xe3,0x07,0x66,0xa3,0x10,0x06,0x66,
+0x8b,0x0e,0xbb,0x07,0x66,0xa1,0x03,0x08,0x66,0x01,0xc8,0x66,0xa3,0x08,0x06,0x66,
+0xa1,0x2b,0x08,0x66,0x01,0xc8,0x66,0xa3,0x0c,0x06,0x66,0x8b,0x1e,0x4b,0x08,0x66,
+0xa1,0x4f,0x08,0x66,0x01,0xc3,0x66,0xb8,0x01,0x00,0x01,0x00,0x66,0x39,0xc3,0x73,
+0x03,0x66,0x89,0xc3,0x66,0x81,0xc3,0xff,0xff,0x00,0x00,0x31,0xdb,0x66,0x89,0x1e,
+0x1c,0x00,0xe8,0xe8,0x02,0x8b,0x1e,0x04,0x06,0x09,0xdb,0x74,0x0a,0xb4,0x48,0xcd,
+0x21,0x0f,0x82,0x10,0x02,0x8e,0xc0,0xe8,0xfb,0x02,0xb8,0x01,0x00,0xff,0x1e,0x00,
+0x06,0x0f,0x82,0x08,0x02,0x8c,0x06,0x26,0x00,0x8c,0x0e,0x28,0x00,0x8c,0xd8,0xa3,
+0x22,0x00,0x8e,0xc0,0x31,0xc0,0xb9,0x01,0x00,0xcd,0x31,0x72,0x07,0xa3,0x14,0x06,
+0x31,0xc0,0xcd,0x31,0x0f,0x82,0xea,0x01,0xa3,0x16,0x06,0x66,0x8b,0x0e,0x1c,0x00,
+0xb8,0x01,0x05,0x8b,0x1e,0x1e,0x00,0xcd,0x31,0x0f,0x82,0xda,0x01,0x89,0x1e,0x1a,
+0x06,0x89,0x0e,0x18,0x06,0x89,0x36,0x1a,0x00,0x89,0x3e,0x18,0x00,0xb8,0x07,0x00,
+0x8b,0x1e,0x14,0x06,0x8b,0x0e,0x1a,0x06,0x8b,0x16,0x18,0x06,0xcd,0x31,0xb8,0x09,
+0x00,0x8c,0xc9,0x81,0xe1,0x03,0x00,0xc1,0xe1,0x05,0x51,0x81,0xc9,0x9b,0xc0,0xcd,
+0x31,0xb8,0x08,0x00,0x8b,0x0e,0x1e,0x00,0x49,0xba,0xff,0xff,0xcd,0x31,0xb8,0x07,
+0x00,0x8b,0x1e,0x16,0x06,0x8b,0x0e,0x1a,0x06,0x8b,0x16,0x18,0x06,0xcd,0x31,0xb8,
+0x09,0x00,0x59,0x81,0xc9,0x93,0xc0,0xcd,0x31,0xb8,0x08,0x00,0x8b,0x0e,0x1e,0x00,
+0x49,0xba,0xff,0xff,0xcd,0x31,0xb8,0x00,0x01,0xbb,0x00,0x0f,0xcd,0x31,0x73,0x10,
+0x3d,0x08,0x00,0x0f,0x85,0x65,0x01,0xb8,0x00,0x01,0xcd,0x31,0x0f,0x82,0x5c,0x01,
+0xa3,0x1c,0x06,0x89,0x16,0x1e,0x06,0xc1,0xe3,0x04,0x89,0x1e,0x20,0x06,0x66,0x8b,
+0x36,0x08,0x06,0x66,0x8b,0x3e,0xfb,0x07,0x66,0x8b,0x0e,0xff,0x07,0xe8,0x49,0x00,
+0x66,0x8b,0x36,0x0c,0x06,0x66,0x8b,0x3e,0x23,0x08,0x66,0x8b,0x0e,0x27,0x08,0xe8,
+0x37,0x00,0x8e,0x06,0x16,0x06,0x66,0x8b,0x3e,0x4b,0x08,0x66,0x8b,0x0e,0x4f,0x08,
+0x66,0x31,0xc0,0x66,0xc1,0xe9,0x02,0x67,0xf3,0x66,0xab,0xb4,0x3e,0x8b,0x1e,0x06,
+0x06,0xcd,0x21,0xb8,0x01,0x01,0x8b,0x16,0x1e,0x06,0xcd,0x31,0x1e,0x0f,0xa1,0x8e,
+0x1e,0x16,0x06,0x66,0x64,0xff,0x2e,0x10,0x06,0x66,0x89,0xf0,0x66,0x25,0xff,0x01,
+0x00,0x00,0x66,0x01,0xc1,0x29,0xc6,0x66,0x29,0xc7,0x66,0x89,0x0e,0x26,0x06,0x66,
+0x89,0x3e,0x22,0x06,0xe8,0xfe,0x00,0x89,0x36,0x3e,0x06,0x66,0xc1,0xee,0x10,0x89,
+0x36,0x42,0x06,0x8b,0x1e,0x06,0x06,0x89,0x1e,0x3a,0x06,0xc7,0x06,0x46,0x06,0x00,
+0x42,0xe8,0xf2,0x00,0xa1,0x1c,0x06,0xa3,0x4e,0x06,0xc7,0x06,0x3e,0x06,0x00,0x00,
+0xc6,0x06,0x47,0x06,0x3f,0xa1,0x28,0x06,0x09,0xc0,0x75,0x09,0xa1,0x26,0x06,0x3b,
+0x06,0x20,0x06,0x76,0x03,0xa1,0x20,0x06,0xa3,0x42,0x06,0xe8,0xc8,0x00,0x66,0x31,
+0xc9,0x8b,0x0e,0x46,0x06,0x66,0x8b,0x3e,0x22,0x06,0x66,0x01,0x0e,0x22,0x06,0x66,
+0x29,0x0e,0x26,0x06,0x66,0x31,0xf6,0xc1,0xe9,0x02,0x1e,0x06,0x8e,0x06,0x16,0x06,
+0x8e,0x1e,0x1e,0x06,0x67,0xf3,0x66,0xa5,0x07,0x1f,0x66,0x03,0x0e,0x26,0x06,0x75,
+0xaf,0xc3,0x3c,0x3a,0x74,0x06,0x3c,0x2f,0x74,0x02,0x3c,0x5c,0xc3,0xbe,0x64,0x07,
+0x89,0xf3,0x26,0x8a,0x05,0x47,0x88,0x04,0x38,0xe0,0x74,0x0e,0x08,0xc0,0x74,0x0a,
+0x46,0xe8,0xde,0xff,0x75,0xec,0x89,0xf3,0x74,0xe8,0xc3,0xba,0x26,0x05,0xeb,0x08,
+0xba,0x34,0x05,0xeb,0x03,0xba,0x3e,0x05,0x52,0x8b,0x1e,0x62,0x07,0xc6,0x07,0x24,
+0xbb,0x64,0x07,0xeb,0x1e,0xe8,0xed,0x00,0xba,0x78,0x05,0xeb,0x12,0xba,0x91,0x05,
+0xeb,0x0d,0xba,0xa3,0x05,0xeb,0x08,0xba,0xb5,0x05,0xeb,0x03,0xba,0x78,0x05,0x52,
+0xbb,0x19,0x05,0xe8,0x14,0x00,0x5b,0xe8,0x10,0x00,0xbb,0x42,0x04,0xe8,0x0a,0x00,
+0xb8,0xff,0x4c,0xcd,0x21,0x43,0xb4,0x02,0xcd,0x21,0x8a,0x17,0x80,0xfa,0x24,0x75,
+0xf4,0xc3,0x0d,0x0a,0x24,0x50,0x51,0x57,0x31,0xc0,0xbf,0x2a,0x06,0xb9,0x19,0x00,
+0xf3,0xab,0x5f,0x59,0x58,0xc3,0xb8,0x00,0x03,0xbb,0x21,0x00,0x31,0xc9,0x66,0xbf,
+0x2a,0x06,0x00,0x00,0xcd,0x31,0xc3,0x00,0x00,0x30,0xe4,0xe8,0x5f,0xff,0x89,0xde,
+0x8b,0x3e,0x67,0x04,0xeb,0x18,0xb4,0x3b,0xe8,0x52,0xff,0x81,0xfe,0x64,0x07,0x74,
+0x13,0x8a,0x84,0xff,0xff,0xe8,0x3a,0xff,0x74,0x04,0xc6,0x04,0x5c,0x46,0xe8,0x03,
+0x00,0x72,0xe3,0xc3,0xe8,0x36,0x00,0xbb,0x44,0x00,0x8a,0x07,0x88,0x04,0x43,0x46,
+0x08,0xc0,0x75,0xf6,0x06,0x57,0x1e,0x07,0xe8,0x9a,0xff,0xbb,0x2a,0x06,0x8c,0x9f,
+0x04,0x00,0x89,0x9f,0x02,0x00,0xba,0x64,0x07,0xb8,0x00,0x4b,0xcd,0x21,0x5f,0x07,
+0x72,0x09,0xb4,0x4d,0xcd,0x21,0x2d,0x00,0x03,0xf7,0xd8,0xeb,0x28,0x80,0x3e,0x69,
+0x08,0x05,0x72,0x20,0xb8,0x00,0x58,0xcd,0x21,0xa2,0x67,0x08,0xb8,0x02,0x58,0xcd,
+0x21,0xa2,0x68,0x08,0xb8,0x01,0x58,0xbb,0x80,0x00,0xcd,0x21,0xb8,0x03,0x58,0xbb,
+0x01,0x00,0xcd,0x21,0xc3,0x9c,0x80,0x3e,0x69,0x08,0x05,0x72,0x1a,0x50,0x53,0xb8,
+0x03,0x58,0x8a,0x1e,0x68,0x08,0x30,0xff,0xcd,0x21,0xb8,0x01,0x58,0x8a,0x1e,0x67,
+0x08,0x30,0xff,0xcd,0x21,0x5b,0x58,0x9d,0xc3,0x4c,0x6f,0x61,0x64,0x20,0x65,0x72,
+0x72,0x6f,0x72,0x3a,0x20,0x24,0x3a,0x20,0x63,0x61,0x6e,0x6e,0x6f,0x74,0x20,0x6f,
+0x70,0x65,0x6e,0x24,0x3a,0x20,0x6e,0x6f,0x74,0x20,0x45,0x58,0x45,0x24,0x3a,0x20,
+0x6e,0x6f,0x74,0x20,0x43,0x4f,0x46,0x46,0x20,0x28,0x43,0x68,0x65,0x63,0x6b,0x20,
+0x66,0x6f,0x72,0x20,0x76,0x69,0x72,0x75,0x73,0x65,0x73,0x29,0x24,0x6e,0x6f,0x20,
+0x44,0x50,0x4d,0x49,0x20,0x2d,0x20,0x47,0x65,0x74,0x20,0x63,0x73,0x64,0x70,0x6d,
+0x69,0x2a,0x62,0x2e,0x7a,0x69,0x70,0x24,0x6e,0x6f,0x20,0x44,0x4f,0x53,0x20,0x6d,
+0x65,0x6d,0x6f,0x72,0x79,0x24,0x6e,0x65,0x65,0x64,0x20,0x44,0x4f,0x53,0x20,0x33,
+0x24,0x63,0x61,0x6e,0x27,0x74,0x20,0x73,0x77,0x69,0x74,0x63,0x68,0x20,0x6d,0x6f,
+0x64,0x65,0x24,0x6e,0x6f,0x20,0x44,0x50,0x4d,0x49,0x20,0x73,0x65,0x6c,0x65,0x63,
+0x74,0x6f,0x72,0x73,0x24,0x6e,0x6f,0x20,0x44,0x50,0x4d,0x49,0x20,0x6d,0x65,0x6d,
+0x6f,0x72,0x79,0x24,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
diff --git a/bfd/hash.c b/bfd/hash.c
new file mode 100644
index 00000000000..4c6e9877ce4
--- /dev/null
+++ b/bfd/hash.c
@@ -0,0 +1,734 @@
+/* hash.c -- hash table routines for BFD
+ Copyright (C) 1993, 94, 95, 1997 Free Software Foundation, Inc.
+ Written by Steve Chamberlain <sac@cygnus.com>
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "objalloc.h"
+
+/*
+SECTION
+ Hash Tables
+
+@cindex Hash tables
+ BFD provides a simple set of hash table functions. Routines
+ are provided to initialize a hash table, to free a hash table,
+ to look up a string in a hash table and optionally create an
+ entry for it, and to traverse a hash table. There is
+ currently no routine to delete an string from a hash table.
+
+ The basic hash table does not permit any data to be stored
+ with a string. However, a hash table is designed to present a
+ base class from which other types of hash tables may be
+ derived. These derived types may store additional information
+ with the string. Hash tables were implemented in this way,
+ rather than simply providing a data pointer in a hash table
+ entry, because they were designed for use by the linker back
+ ends. The linker may create thousands of hash table entries,
+ and the overhead of allocating private data and storing and
+ following pointers becomes noticeable.
+
+ The basic hash table code is in <<hash.c>>.
+
+@menu
+@* Creating and Freeing a Hash Table::
+@* Looking Up or Entering a String::
+@* Traversing a Hash Table::
+@* Deriving a New Hash Table Type::
+@end menu
+
+INODE
+Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables
+SUBSECTION
+ Creating and freeing a hash table
+
+@findex bfd_hash_table_init
+@findex bfd_hash_table_init_n
+ To create a hash table, create an instance of a <<struct
+ bfd_hash_table>> (defined in <<bfd.h>>) and call
+ <<bfd_hash_table_init>> (if you know approximately how many
+ entries you will need, the function <<bfd_hash_table_init_n>>,
+ which takes a @var{size} argument, may be used).
+ <<bfd_hash_table_init>> returns <<false>> if some sort of
+ error occurs.
+
+@findex bfd_hash_newfunc
+ The function <<bfd_hash_table_init>> take as an argument a
+ function to use to create new entries. For a basic hash
+ table, use the function <<bfd_hash_newfunc>>. @xref{Deriving
+ a New Hash Table Type} for why you would want to use a
+ different value for this argument.
+
+@findex bfd_hash_allocate
+ <<bfd_hash_table_init>> will create an objalloc which will be
+ used to allocate new entries. You may allocate memory on this
+ objalloc using <<bfd_hash_allocate>>.
+
+@findex bfd_hash_table_free
+ Use <<bfd_hash_table_free>> to free up all the memory that has
+ been allocated for a hash table. This will not free up the
+ <<struct bfd_hash_table>> itself, which you must provide.
+
+INODE
+Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables
+SUBSECTION
+ Looking up or entering a string
+
+@findex bfd_hash_lookup
+ The function <<bfd_hash_lookup>> is used both to look up a
+ string in the hash table and to create a new entry.
+
+ If the @var{create} argument is <<false>>, <<bfd_hash_lookup>>
+ will look up a string. If the string is found, it will
+ returns a pointer to a <<struct bfd_hash_entry>>. If the
+ string is not found in the table <<bfd_hash_lookup>> will
+ return <<NULL>>. You should not modify any of the fields in
+ the returns <<struct bfd_hash_entry>>.
+
+ If the @var{create} argument is <<true>>, the string will be
+ entered into the hash table if it is not already there.
+ Either way a pointer to a <<struct bfd_hash_entry>> will be
+ returned, either to the existing structure or to a newly
+ created one. In this case, a <<NULL>> return means that an
+ error occurred.
+
+ If the @var{create} argument is <<true>>, and a new entry is
+ created, the @var{copy} argument is used to decide whether to
+ copy the string onto the hash table objalloc or not. If
+ @var{copy} is passed as <<false>>, you must be careful not to
+ deallocate or modify the string as long as the hash table
+ exists.
+
+INODE
+Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables
+SUBSECTION
+ Traversing a hash table
+
+@findex bfd_hash_traverse
+ The function <<bfd_hash_traverse>> may be used to traverse a
+ hash table, calling a function on each element. The traversal
+ is done in a random order.
+
+ <<bfd_hash_traverse>> takes as arguments a function and a
+ generic <<void *>> pointer. The function is called with a
+ hash table entry (a <<struct bfd_hash_entry *>>) and the
+ generic pointer passed to <<bfd_hash_traverse>>. The function
+ must return a <<boolean>> value, which indicates whether to
+ continue traversing the hash table. If the function returns
+ <<false>>, <<bfd_hash_traverse>> will stop the traversal and
+ return immediately.
+
+INODE
+Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables
+SUBSECTION
+ Deriving a new hash table type
+
+ Many uses of hash tables want to store additional information
+ which each entry in the hash table. Some also find it
+ convenient to store additional information with the hash table
+ itself. This may be done using a derived hash table.
+
+ Since C is not an object oriented language, creating a derived
+ hash table requires sticking together some boilerplate
+ routines with a few differences specific to the type of hash
+ table you want to create.
+
+ An example of a derived hash table is the linker hash table.
+ The structures for this are defined in <<bfdlink.h>>. The
+ functions are in <<linker.c>>.
+
+ You may also derive a hash table from an already derived hash
+ table. For example, the a.out linker backend code uses a hash
+ table derived from the linker hash table.
+
+@menu
+@* Define the Derived Structures::
+@* Write the Derived Creation Routine::
+@* Write Other Derived Routines::
+@end menu
+
+INODE
+Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type
+SUBSUBSECTION
+ Define the derived structures
+
+ You must define a structure for an entry in the hash table,
+ and a structure for the hash table itself.
+
+ The first field in the structure for an entry in the hash
+ table must be of the type used for an entry in the hash table
+ you are deriving from. If you are deriving from a basic hash
+ table this is <<struct bfd_hash_entry>>, which is defined in
+ <<bfd.h>>. The first field in the structure for the hash
+ table itself must be of the type of the hash table you are
+ deriving from itself. If you are deriving from a basic hash
+ table, this is <<struct bfd_hash_table>>.
+
+ For example, the linker hash table defines <<struct
+ bfd_link_hash_entry>> (in <<bfdlink.h>>). The first field,
+ <<root>>, is of type <<struct bfd_hash_entry>>. Similarly,
+ the first field in <<struct bfd_link_hash_table>>, <<table>>,
+ is of type <<struct bfd_hash_table>>.
+
+INODE
+Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type
+SUBSUBSECTION
+ Write the derived creation routine
+
+ You must write a routine which will create and initialize an
+ entry in the hash table. This routine is passed as the
+ function argument to <<bfd_hash_table_init>>.
+
+ In order to permit other hash tables to be derived from the
+ hash table you are creating, this routine must be written in a
+ standard way.
+
+ The first argument to the creation routine is a pointer to a
+ hash table entry. This may be <<NULL>>, in which case the
+ routine should allocate the right amount of space. Otherwise
+ the space has already been allocated by a hash table type
+ derived from this one.
+
+ After allocating space, the creation routine must call the
+ creation routine of the hash table type it is derived from,
+ passing in a pointer to the space it just allocated. This
+ will initialize any fields used by the base hash table.
+
+ Finally the creation routine must initialize any local fields
+ for the new hash table type.
+
+ Here is a boilerplate example of a creation routine.
+ @var{function_name} is the name of the routine.
+ @var{entry_type} is the type of an entry in the hash table you
+ are creating. @var{base_newfunc} is the name of the creation
+ routine of the hash table type your hash table is derived
+ from.
+
+EXAMPLE
+
+.struct bfd_hash_entry *
+.@var{function_name} (entry, table, string)
+. struct bfd_hash_entry *entry;
+. struct bfd_hash_table *table;
+. const char *string;
+.{
+. struct @var{entry_type} *ret = (@var{entry_type} *) entry;
+.
+. {* Allocate the structure if it has not already been allocated by a
+. derived class. *}
+. if (ret == (@var{entry_type} *) NULL)
+. {
+. ret = ((@var{entry_type} *)
+. bfd_hash_allocate (table, sizeof (@var{entry_type})));
+. if (ret == (@var{entry_type} *) NULL)
+. return NULL;
+. }
+.
+. {* Call the allocation method of the base class. *}
+. ret = ((@var{entry_type} *)
+. @var{base_newfunc} ((struct bfd_hash_entry *) ret, table, string));
+.
+. {* Initialize the local fields here. *}
+.
+. return (struct bfd_hash_entry *) ret;
+.}
+
+DESCRIPTION
+ The creation routine for the linker hash table, which is in
+ <<linker.c>>, looks just like this example.
+ @var{function_name} is <<_bfd_link_hash_newfunc>>.
+ @var{entry_type} is <<struct bfd_link_hash_entry>>.
+ @var{base_newfunc} is <<bfd_hash_newfunc>>, the creation
+ routine for a basic hash table.
+
+ <<_bfd_link_hash_newfunc>> also initializes the local fields
+ in a linker hash table entry: <<type>>, <<written>> and
+ <<next>>.
+
+INODE
+Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type
+SUBSUBSECTION
+ Write other derived routines
+
+ You will want to write other routines for your new hash table,
+ as well.
+
+ You will want an initialization routine which calls the
+ initialization routine of the hash table you are deriving from
+ and initializes any other local fields. For the linker hash
+ table, this is <<_bfd_link_hash_table_init>> in <<linker.c>>.
+
+ You will want a lookup routine which calls the lookup routine
+ of the hash table you are deriving from and casts the result.
+ The linker hash table uses <<bfd_link_hash_lookup>> in
+ <<linker.c>> (this actually takes an additional argument which
+ it uses to decide how to return the looked up value).
+
+ You may want a traversal routine. This should just call the
+ traversal routine of the hash table you are deriving from with
+ appropriate casts. The linker hash table uses
+ <<bfd_link_hash_traverse>> in <<linker.c>>.
+
+ These routines may simply be defined as macros. For example,
+ the a.out backend linker hash table, which is derived from the
+ linker hash table, uses macros for the lookup and traversal
+ routines. These are <<aout_link_hash_lookup>> and
+ <<aout_link_hash_traverse>> in aoutx.h.
+*/
+
+/* The default number of entries to use when creating a hash table. */
+#define DEFAULT_SIZE (4051)
+
+/* Create a new hash table, given a number of entries. */
+
+boolean
+bfd_hash_table_init_n (table, newfunc, size)
+ struct bfd_hash_table *table;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+ unsigned int size;
+{
+ unsigned int alloc;
+
+ alloc = size * sizeof (struct bfd_hash_entry *);
+
+ table->memory = (PTR) objalloc_create ();
+ if (table->memory == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ table->table = ((struct bfd_hash_entry **)
+ objalloc_alloc ((struct objalloc *) table->memory, alloc));
+ if (table->table == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ memset ((PTR) table->table, 0, alloc);
+ table->size = size;
+ table->newfunc = newfunc;
+ return true;
+}
+
+/* Create a new hash table with the default number of entries. */
+
+boolean
+bfd_hash_table_init (table, newfunc)
+ struct bfd_hash_table *table;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ return bfd_hash_table_init_n (table, newfunc, DEFAULT_SIZE);
+}
+
+/* Free a hash table. */
+
+void
+bfd_hash_table_free (table)
+ struct bfd_hash_table *table;
+{
+ objalloc_free ((struct objalloc *) table->memory);
+ table->memory = NULL;
+}
+
+/* Look up a string in a hash table. */
+
+struct bfd_hash_entry *
+bfd_hash_lookup (table, string, create, copy)
+ struct bfd_hash_table *table;
+ const char *string;
+ boolean create;
+ boolean copy;
+{
+ register const unsigned char *s;
+ register unsigned long hash;
+ register unsigned int c;
+ struct bfd_hash_entry *hashp;
+ unsigned int len;
+ unsigned int index;
+
+ hash = 0;
+ len = 0;
+ s = (const unsigned char *) string;
+ while ((c = *s++) != '\0')
+ {
+ hash += c + (c << 17);
+ hash ^= hash >> 2;
+ ++len;
+ }
+ hash += len + (len << 17);
+ hash ^= hash >> 2;
+
+ index = hash % table->size;
+ for (hashp = table->table[index];
+ hashp != (struct bfd_hash_entry *) NULL;
+ hashp = hashp->next)
+ {
+ if (hashp->hash == hash
+ && strcmp (hashp->string, string) == 0)
+ return hashp;
+ }
+
+ if (! create)
+ return (struct bfd_hash_entry *) NULL;
+
+ hashp = (*table->newfunc) ((struct bfd_hash_entry *) NULL, table, string);
+ if (hashp == (struct bfd_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) NULL;
+ if (copy)
+ {
+ char *new;
+
+ new = (char *) objalloc_alloc ((struct objalloc *) table->memory,
+ len + 1);
+ if (!new)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return (struct bfd_hash_entry *) NULL;
+ }
+ strcpy (new, string);
+ string = new;
+ }
+ hashp->string = string;
+ hashp->hash = hash;
+ hashp->next = table->table[index];
+ table->table[index] = hashp;
+
+ return hashp;
+}
+
+/* Replace an entry in a hash table. */
+
+void
+bfd_hash_replace (table, old, nw)
+ struct bfd_hash_table *table;
+ struct bfd_hash_entry *old;
+ struct bfd_hash_entry *nw;
+{
+ unsigned int index;
+ struct bfd_hash_entry **pph;
+
+ index = old->hash % table->size;
+ for (pph = &table->table[index];
+ (*pph) != (struct bfd_hash_entry *) NULL;
+ pph = &(*pph)->next)
+ {
+ if (*pph == old)
+ {
+ *pph = nw;
+ return;
+ }
+ }
+
+ abort ();
+}
+
+/* Base method for creating a new hash table entry. */
+
+/*ARGSUSED*/
+struct bfd_hash_entry *
+bfd_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ if (entry == (struct bfd_hash_entry *) NULL)
+ entry = ((struct bfd_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct bfd_hash_entry)));
+ return entry;
+}
+
+/* Allocate space in a hash table. */
+
+PTR
+bfd_hash_allocate (table, size)
+ struct bfd_hash_table *table;
+ unsigned int size;
+{
+ PTR ret;
+
+ ret = objalloc_alloc ((struct objalloc *) table->memory, size);
+ if (ret == NULL && size != 0)
+ bfd_set_error (bfd_error_no_memory);
+ return ret;
+}
+
+/* Traverse a hash table. */
+
+void
+bfd_hash_traverse (table, func, info)
+ struct bfd_hash_table *table;
+ boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
+ PTR info;
+{
+ unsigned int i;
+
+ for (i = 0; i < table->size; i++)
+ {
+ struct bfd_hash_entry *p;
+
+ for (p = table->table[i]; p != NULL; p = p->next)
+ {
+ if (! (*func) (p, info))
+ return;
+ }
+ }
+}
+
+/* A few different object file formats (a.out, COFF, ELF) use a string
+ table. These functions support adding strings to a string table,
+ returning the byte offset, and writing out the table.
+
+ Possible improvements:
+ + look for strings matching trailing substrings of other strings
+ + better data structures? balanced trees?
+ + look at reducing memory use elsewhere -- maybe if we didn't have
+ to construct the entire symbol table at once, we could get by
+ with smaller amounts of VM? (What effect does that have on the
+ string table reductions?) */
+
+/* An entry in the strtab hash table. */
+
+struct strtab_hash_entry
+{
+ struct bfd_hash_entry root;
+ /* Index in string table. */
+ bfd_size_type index;
+ /* Next string in strtab. */
+ struct strtab_hash_entry *next;
+};
+
+/* The strtab hash table. */
+
+struct bfd_strtab_hash
+{
+ struct bfd_hash_table table;
+ /* Size of strtab--also next available index. */
+ bfd_size_type size;
+ /* First string in strtab. */
+ struct strtab_hash_entry *first;
+ /* Last string in strtab. */
+ struct strtab_hash_entry *last;
+ /* Whether to precede strings with a two byte length, as in the
+ XCOFF .debug section. */
+ boolean xcoff;
+};
+
+static struct bfd_hash_entry *strtab_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+/* Routine to create an entry in a strtab. */
+
+static struct bfd_hash_entry *
+strtab_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct strtab_hash_entry *) NULL)
+ ret = ((struct strtab_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct strtab_hash_entry)));
+ if (ret == (struct strtab_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct strtab_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ ret->index = (bfd_size_type) -1;
+ ret->next = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Look up an entry in an strtab. */
+
+#define strtab_hash_lookup(t, string, create, copy) \
+ ((struct strtab_hash_entry *) \
+ bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
+
+/* Create a new strtab. */
+
+struct bfd_strtab_hash *
+_bfd_stringtab_init ()
+{
+ struct bfd_strtab_hash *table;
+
+ table = ((struct bfd_strtab_hash *)
+ bfd_malloc (sizeof (struct bfd_strtab_hash)));
+ if (table == NULL)
+ return NULL;
+
+ if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc))
+ {
+ free (table);
+ return NULL;
+ }
+
+ table->size = 0;
+ table->first = NULL;
+ table->last = NULL;
+ table->xcoff = false;
+
+ return table;
+}
+
+/* Create a new strtab in which the strings are output in the format
+ used in the XCOFF .debug section: a two byte length precedes each
+ string. */
+
+struct bfd_strtab_hash *
+_bfd_xcoff_stringtab_init ()
+{
+ struct bfd_strtab_hash *ret;
+
+ ret = _bfd_stringtab_init ();
+ if (ret != NULL)
+ ret->xcoff = true;
+ return ret;
+}
+
+/* Free a strtab. */
+
+void
+_bfd_stringtab_free (table)
+ struct bfd_strtab_hash *table;
+{
+ bfd_hash_table_free (&table->table);
+ free (table);
+}
+
+/* Get the index of a string in a strtab, adding it if it is not
+ already present. If HASH is false, we don't really use the hash
+ table, and we don't eliminate duplicate strings. */
+
+bfd_size_type
+_bfd_stringtab_add (tab, str, hash, copy)
+ struct bfd_strtab_hash *tab;
+ const char *str;
+ boolean hash;
+ boolean copy;
+{
+ register struct strtab_hash_entry *entry;
+
+ if (hash)
+ {
+ entry = strtab_hash_lookup (tab, str, true, copy);
+ if (entry == NULL)
+ return (bfd_size_type) -1;
+ }
+ else
+ {
+ entry = ((struct strtab_hash_entry *)
+ bfd_hash_allocate (&tab->table,
+ sizeof (struct strtab_hash_entry)));
+ if (entry == NULL)
+ return (bfd_size_type) -1;
+ if (! copy)
+ entry->root.string = str;
+ else
+ {
+ char *n;
+
+ n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
+ if (n == NULL)
+ return (bfd_size_type) -1;
+ entry->root.string = n;
+ }
+ entry->index = (bfd_size_type) -1;
+ entry->next = NULL;
+ }
+
+ if (entry->index == (bfd_size_type) -1)
+ {
+ entry->index = tab->size;
+ tab->size += strlen (str) + 1;
+ if (tab->xcoff)
+ {
+ entry->index += 2;
+ tab->size += 2;
+ }
+ if (tab->first == NULL)
+ tab->first = entry;
+ else
+ tab->last->next = entry;
+ tab->last = entry;
+ }
+
+ return entry->index;
+}
+
+/* Get the number of bytes in a strtab. */
+
+bfd_size_type
+_bfd_stringtab_size (tab)
+ struct bfd_strtab_hash *tab;
+{
+ return tab->size;
+}
+
+/* Write out a strtab. ABFD must already be at the right location in
+ the file. */
+
+boolean
+_bfd_stringtab_emit (abfd, tab)
+ register bfd *abfd;
+ struct bfd_strtab_hash *tab;
+{
+ register boolean xcoff;
+ register struct strtab_hash_entry *entry;
+
+ xcoff = tab->xcoff;
+
+ for (entry = tab->first; entry != NULL; entry = entry->next)
+ {
+ register const char *str;
+ register size_t len;
+
+ str = entry->root.string;
+ len = strlen (str) + 1;
+
+ if (xcoff)
+ {
+ bfd_byte buf[2];
+
+ /* The output length includes the null byte. */
+ bfd_put_16 (abfd, len, buf);
+ if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
+ return false;
+ }
+
+ if (bfd_write ((PTR) str, 1, len, abfd) != len)
+ return false;
+ }
+
+ return true;
+}
diff --git a/bfd/host-aout.c b/bfd/host-aout.c
new file mode 100644
index 00000000000..99643dcc24e
--- /dev/null
+++ b/bfd/host-aout.c
@@ -0,0 +1,83 @@
+/* BFD backend for local host's a.out binaries
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Written by Cygnus Support. Probably John Gilmore's fault.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define ARCH_SIZE 32
+
+/* When porting to a new system, you must supply:
+
+ HOST_PAGE_SIZE (optional)
+ HOST_SEGMENT_SIZE (optional -- defaults to page size)
+ HOST_MACHINE_ARCH (optional)
+ HOST_MACHINE_MACHINE (optional)
+ HOST_TEXT_START_ADDR (optional)
+ HOST_STACK_END_ADDR (not used, except by trad-core ???)
+ HOST_BIG_ENDIAN_P (required -- define if big-endian)
+
+ in the ./hosts/h-systemname.h file. */
+
+#ifdef TRAD_HEADER
+#include TRAD_HEADER
+#endif
+
+#ifdef HOST_PAGE_SIZE
+#define TARGET_PAGE_SIZE HOST_PAGE_SIZE
+#endif
+
+#ifdef HOST_SEGMENT_SIZE
+#define SEGMENT_SIZE HOST_SEGMENT_SIZE
+#else
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#endif
+
+#ifdef HOST_TEXT_START_ADDR
+#define TEXT_START_ADDR HOST_TEXT_START_ADDR
+#endif
+
+#ifdef HOST_STACK_END_ADDR
+#define STACK_END_ADDR HOST_STACK_END_ADDR
+#endif
+
+#ifdef HOST_BIG_ENDIAN_P
+#define TARGET_IS_BIG_ENDIAN_P
+#else
+#undef TARGET_IS_BIG_ENDIAN_P
+#endif
+
+#include "libaout.h" /* BFD a.out internal data structures */
+#include "aout/aout64.h"
+
+#ifdef HOST_MACHINE_ARCH
+#ifdef HOST_MACHINE_MACHINE
+#define SET_ARCH_MACH(abfd, execp) \
+ bfd_default_set_arch_mach(abfd, HOST_MACHINE_ARCH, HOST_MACHINE_MACHINE)
+#else
+#define SET_ARCH_MACH(abfd, execp) \
+ bfd_default_set_arch_mach(abfd, HOST_MACHINE_ARCH, 0)
+#endif
+#endif /* HOST_MACHINE_ARCH */
+
+#define MY(OP) CAT(host_aout_,OP)
+#define TARGETNAME "a.out"
+
+#include "aout-target.h"
diff --git a/bfd/hosts/alphalinux.h b/bfd/hosts/alphalinux.h
new file mode 100644
index 00000000000..d9ba1b7ec6b
--- /dev/null
+++ b/bfd/hosts/alphalinux.h
@@ -0,0 +1,6 @@
+/* Linux dumps "struct task_struct" at the end of the core-file. This
+ structure is currently 920 bytes long, but we allow up to 1024
+ bytes to allow for some future growth. */
+#define TRAD_CORE_EXTRA_SIZE_ALLOWED 1024
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
+ ((abfd)->tdata.trad_core_data->u.signal)
diff --git a/bfd/hosts/alphavms.h b/bfd/hosts/alphavms.h
new file mode 100644
index 00000000000..eee391a97fb
--- /dev/null
+++ b/bfd/hosts/alphavms.h
@@ -0,0 +1,69 @@
+/* alphavms.h -- BFD definitions for an openVMS host
+ Copyright 1996 Free Software Foundation, Inc.
+ Written by Klaus Kämpf (kkaempf@progis.de)
+ of proGIS Softwareentwicklung, Aachen, Germany
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stddef.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/file.h>
+#include <stdlib.h>
+#include <unixlib.h>
+#include <unixio.h>
+#include <time.h>
+
+#include "bfd.h"
+
+#ifndef BFD_HOST_64_BIT
+/* Make the basic types 64-bit quantities on the host.
+ Also provide the support macros BFD needs. */
+# ifdef __GNUC__
+# define BFD_HOST_64_BIT long long
+# else
+# define BFD_HOST_64_BIT long
+# endif
+typedef unsigned BFD_HOST_64_BIT uint64_type;
+typedef BFD_HOST_64_BIT int64_type;
+
+# define sprintf_vma(s,x) sprintf (s, "%016lx", x) /* BFD_HOST_64_BIT */
+# define fprintf_vma(f,x) fprintf (f, "%016lx", x) /* BFD_HOST_64_BIT */
+
+# define BYTES_IN_PRINTF_INT 4
+
+/* These must have type unsigned long because they are used as
+ arguments in printf functions. */
+# define uint64_typeLOW(x) ((unsigned long) (((x) & 0xffffffff))) /* BFD_HOST_64_BIT */
+# define uint64_typeHIGH(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) /* BFD_HOST_64_BIT */
+
+#endif /* BFD_HOST_64_BIT */
+
+#include "fopen-vms.h"
+
+#define NO_FCNTL 1
+
+#ifndef O_ACCMODE
+#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+#endif
+
+extern int getpagesize PARAMS ((void));
diff --git a/bfd/hosts/decstation.h b/bfd/hosts/decstation.h
new file mode 100644
index 00000000000..a80c143d525
--- /dev/null
+++ b/bfd/hosts/decstation.h
@@ -0,0 +1,17 @@
+/* Hopefully this should include either machine/param.h (Ultrix) or
+ machine/machparam.h (Mach), whichever is its name on this system. */
+#include <sys/param.h>
+
+#include <machine/vmparam.h>
+
+#define HOST_PAGE_SIZE NBPG
+/* #define HOST_SEGMENT_SIZE NBPG -- we use HOST_DATA_START_ADDR */
+#define HOST_MACHINE_ARCH bfd_arch_mips
+/* #define HOST_MACHINE_MACHINE */
+
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_DATA_START_ADDR USRDATA
+#define HOST_STACK_END_ADDR USRSTACK
+
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
+ ((core_bfd)->tdata.trad_core_data->u.u_arg[0])
diff --git a/bfd/hosts/delta68.h b/bfd/hosts/delta68.h
new file mode 100644
index 00000000000..1a6a6e6f197
--- /dev/null
+++ b/bfd/hosts/delta68.h
@@ -0,0 +1,18 @@
+/* Definitions for a Motorola Delta 3300 box running System V R3.0.
+ Contributed by manfred@lts.sel.alcatel.de. */
+
+#include <sys/param.h>
+
+/* Definitions used by trad-core.c. */
+#define NBPG NBPC
+#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
+#define HOST_TEXT_START_ADDR u.u_exdata.ux_txtorg
+#if 0
+#define HOST_STACK_END_ADDR 0x40000000
+#else
+/* User's stack, copied from sys/param.h */
+#define HOST_STACK_END_ADDR USRSTACK
+#endif
+#define UPAGES USIZE
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
+ abfd->tdata.trad_core_data->u.u_abort
diff --git a/bfd/hosts/dpx2.h b/bfd/hosts/dpx2.h
new file mode 100644
index 00000000000..ea6395f2e5d
--- /dev/null
+++ b/bfd/hosts/dpx2.h
@@ -0,0 +1,8 @@
+/* Definitions that are needed for core files. Core section sizes for
+ the DPX2 are in bytes. */
+
+#include <sys/param.h>
+#define NBPG 1
+#define UPAGES (USIZE * NBPP)
+#define HOST_DATA_START_ADDR (u.u_exdata.ux_datorg)
+#define HOST_STACK_END_ADDR (USERSTACK)
diff --git a/bfd/hosts/hp300bsd.h b/bfd/hosts/hp300bsd.h
new file mode 100644
index 00000000000..98287178207
--- /dev/null
+++ b/bfd/hosts/hp300bsd.h
@@ -0,0 +1,13 @@
+#include <sys/param.h>
+#ifdef BSD4_4
+#define NO_CORE_COMMAND
+#endif
+
+#define HOST_PAGE_SIZE NBPG
+#define HOST_SEGMENT_SIZE NBPG /* Data seg start addr rounds to NBPG */
+#define HOST_MACHINE_ARCH bfd_arch_m68k
+/* #define HOST_MACHINE_MACHINE */
+
+#define HOST_TEXT_START_ADDR 0
+#define HOST_STACK_END_ADDR 0xfff00000
+#define HOST_BIG_ENDIAN_P
diff --git a/bfd/hosts/i386bsd.h b/bfd/hosts/i386bsd.h
new file mode 100644
index 00000000000..8eee3d82fb7
--- /dev/null
+++ b/bfd/hosts/i386bsd.h
@@ -0,0 +1,32 @@
+/* Intel 386 running any BSD Unix */
+
+#include <machine/param.h>
+#include <machine/vmparam.h>
+
+/* Recent versions of FreeBSD don't define NBPG. */
+#ifndef NBPG
+#ifdef PAGE_SIZE
+#define NBPG PAGE_SIZE
+#endif
+#endif
+
+#define HOST_PAGE_SIZE NBPG
+#define HOST_MACHINE_ARCH bfd_arch_i386
+#define HOST_TEXT_START_ADDR USRTEXT
+
+/* Jolitz suggested defining HOST_STACK_END_ADDR to
+ (u.u_kproc.kp_eproc.e_vm.vm_maxsaddr + MAXSSIZ), which should work on
+ both BSDI and 386BSD, but that is believed not to work for BSD 4.4. */
+
+#ifdef __bsdi__
+/* This seems to be the right thing for BSDI. */
+#define HOST_STACK_END_ADDR USRSTACK
+#define HOST_DATA_START_ADDR ((bfd_vma)u.u_kproc.kp_eproc.e_vm.vm_daddr)
+#else
+/* This seems to be the right thing for 386BSD release 0.1. */
+#define HOST_STACK_END_ADDR (USRSTACK - MAXSSIZ)
+#endif
+
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
+ ((core_bfd)->tdata.trad_core_data->u.u_sig)
+#define u_comm u_kproc.kp_proc.p_comm
diff --git a/bfd/hosts/i386linux.h b/bfd/hosts/i386linux.h
new file mode 100644
index 00000000000..13a51f1bd14
--- /dev/null
+++ b/bfd/hosts/i386linux.h
@@ -0,0 +1,8 @@
+/* Linux writes the task structure at the end of the core file. Currently it
+ is 2912 bytes. It is possible that this should be a pickier check, but
+ we should probably not be too picky (the size of the task structure might
+ vary, and if it's not the length we expect it to be, it doesn't affect
+ our ability to process the core file). So allow 0-4096 extra bytes at
+ the end. */
+
+#define TRAD_CORE_EXTRA_SIZE_ALLOWED 4096
diff --git a/bfd/hosts/i386mach3.h b/bfd/hosts/i386mach3.h
new file mode 100644
index 00000000000..dcc61e3c8e8
--- /dev/null
+++ b/bfd/hosts/i386mach3.h
@@ -0,0 +1,25 @@
+#include <machine/vmparam.h>
+#include <sys/param.h>
+
+/* This is an ugly way to hack around the incorrect
+ * definition of UPAGES in i386/machparam.h.
+ *
+ * The definition should specify the size reserved
+ * for "struct user" in core files in PAGES,
+ * but instead it gives it in 512-byte core-clicks
+ * for i386 and i860. UPAGES is used only in trad-core.c.
+ */
+#if UPAGES == 16
+#undef UPAGES
+#define UPAGES 2
+#endif
+
+#if UPAGES != 2
+FIXME!! UPAGES is neither 2 nor 16
+#endif
+
+#define HOST_PAGE_SIZE 1
+#define HOST_SEGMENT_SIZE NBPG
+#define HOST_MACHINE_ARCH bfd_arch_i386
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
diff --git a/bfd/hosts/i386sco.h b/bfd/hosts/i386sco.h
new file mode 100644
index 00000000000..ec8608c61dd
--- /dev/null
+++ b/bfd/hosts/i386sco.h
@@ -0,0 +1,19 @@
+/* Core file stuff. At least some, perhaps all, of the following
+ defines work on many more systems than just SCO. */
+
+#define NBPG NBPC
+#define UPAGES USIZE
+#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
+#define HOST_STACK_START_ADDR u.u_sub
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
+ ((core_upage(abfd)->u_sysabort != 0) \
+ ? core_upage(abfd)->u_sysabort \
+ : -1)
+
+/* According to the manpage, a version 2 SCO corefile can contain
+ various additional sections (it is cleverly arranged so the u area,
+ data, and stack are first where we can find them). So without
+ writing lots of code to parse all their headers and stuff, we can't
+ know whether a corefile is bigger than it should be. */
+
+#define TRAD_CORE_ALLOW_ANY_EXTRA_SIZE 1
diff --git a/bfd/hosts/i860mach3.h b/bfd/hosts/i860mach3.h
new file mode 100644
index 00000000000..edd2aa10a7b
--- /dev/null
+++ b/bfd/hosts/i860mach3.h
@@ -0,0 +1,27 @@
+/* This file was hacked from i386mach3.h [dolan@ssd.intel.com] */
+
+#include <machine/vmparam.h>
+#include <sys/param.h>
+
+/* This is an ugly way to hack around the incorrect
+ * definition of UPAGES in i386/machparam.h.
+ *
+ * The definition should specify the size reserved
+ * for "struct user" in core files in PAGES,
+ * but instead it gives it in 512-byte core-clicks
+ * for i386 and i860. UPAGES is used only in trad-core.c.
+ */
+#if UPAGES == 16
+#undef UPAGES
+#define UPAGES 2
+#endif
+
+#if UPAGES != 2
+FIXME!! UPAGES is neither 2 nor 16
+#endif
+
+#define HOST_PAGE_SIZE 1
+#define HOST_SEGMENT_SIZE NBPG
+#define HOST_MACHINE_ARCH bfd_arch_i860
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
diff --git a/bfd/hosts/m68kaux.h b/bfd/hosts/m68kaux.h
new file mode 100644
index 00000000000..6237755dba5
--- /dev/null
+++ b/bfd/hosts/m68kaux.h
@@ -0,0 +1,16 @@
+/* Definitions for an Apple Macintosh running A/UX 3.x. */
+
+#include <sys/param.h>
+#include <sys/page.h>
+
+/* Definitions used by trad-core.c. */
+#define NBPG NBPP
+
+#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
+#define HOST_TEXT_START_ADDR u.u_exdata.ux_txtorg
+#define HOST_STACK_END_ADDR 0x100000000
+
+#define UPAGES USIZE
+
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
+ (abfd->tdata.trad_core_data->u.u_arg[0])
diff --git a/bfd/hosts/m68klinux.h b/bfd/hosts/m68klinux.h
new file mode 100644
index 00000000000..0067dfa6fda
--- /dev/null
+++ b/bfd/hosts/m68klinux.h
@@ -0,0 +1,6 @@
+/* Linux dumps "struct task_struct" at the end of the core-file. This
+ structure is currently 2512 bytes long, but we allow up to 4096
+ bytes to allow for some future growth. */
+#define TRAD_CORE_EXTRA_SIZE_ALLOWED 4096
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
+ ((abfd)->tdata.trad_core_data->u.signal)
diff --git a/bfd/hosts/m88kmach3.h b/bfd/hosts/m88kmach3.h
new file mode 100644
index 00000000000..421553893ec
--- /dev/null
+++ b/bfd/hosts/m88kmach3.h
@@ -0,0 +1,11 @@
+#include <machine/vmparam.h>
+#include <sys/param.h>
+
+#undef UPAGES
+#define UPAGES 3
+
+#define HOST_PAGE_SIZE NBPG
+#define HOST_SEGMENT_SIZE NBPG
+#define HOST_MACHINE_ARCH bfd_arch_m88k
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
diff --git a/bfd/hosts/mipsbsd.h b/bfd/hosts/mipsbsd.h
new file mode 100644
index 00000000000..a2fad21fcf7
--- /dev/null
+++ b/bfd/hosts/mipsbsd.h
@@ -0,0 +1,12 @@
+#include <machine/param.h>
+#include <machine/vmparam.h>
+#undef ALIGN
+
+#define HOST_PAGE_SIZE NBPG
+/* #define HOST_SEGMENT_SIZE NBPG -- we use HOST_DATA_START_ADDR */
+#define HOST_MACHINE_ARCH bfd_arch_mips
+/* #define HOST_MACHINE_MACHINE */
+
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
+#define NO_CORE_COMMAND
diff --git a/bfd/hosts/mipsmach3.h b/bfd/hosts/mipsmach3.h
new file mode 100644
index 00000000000..c5c468d3742
--- /dev/null
+++ b/bfd/hosts/mipsmach3.h
@@ -0,0 +1,10 @@
+#include <machine/vmparam.h>
+#include <machine/machparam.h>
+#include <sys/param.h>
+
+#define HOST_PAGE_SIZE NBPG
+/* #define HOST_SEGMENT_SIZE NBPG */
+#define HOST_MACHINE_ARCH bfd_arch_mips
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_DATA_START_ADDR USRDATA
+#define HOST_STACK_END_ADDR USRSTACK
diff --git a/bfd/hosts/news-mips.h b/bfd/hosts/news-mips.h
new file mode 100644
index 00000000000..9e799bed904
--- /dev/null
+++ b/bfd/hosts/news-mips.h
@@ -0,0 +1,12 @@
+/* Sony News running NewsOS 3.2. */
+
+#include <sys/param.h>
+#include <machine/vmparam.h>
+
+#define HOST_PAGE_SIZE NBPG
+
+#define HOST_MACHINE_ARCH bfd_arch_mips
+
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_DATA_START_ADDR USRDATA
+#define HOST_STACK_END_ADDR USRSTACK
diff --git a/bfd/hosts/news.h b/bfd/hosts/news.h
new file mode 100644
index 00000000000..bf7946cdb99
--- /dev/null
+++ b/bfd/hosts/news.h
@@ -0,0 +1,9 @@
+/* Sony News running NewsOS 3.2. */
+
+#include <machine/vmparam.h>
+
+#define HOST_PAGE_SIZE NBPG
+#define HOST_SEGMENT_SIZE NBPG
+#define HOST_MACHINE_ARCH bfd_arch_m68k
+#define HOST_TEXT_START_ADDR 0
+#define HOST_STACK_END_ADDR (KERNBASE - (UPAGES * NBPG))
diff --git a/bfd/hosts/pc532mach.h b/bfd/hosts/pc532mach.h
new file mode 100644
index 00000000000..ab96f597edd
--- /dev/null
+++ b/bfd/hosts/pc532mach.h
@@ -0,0 +1,24 @@
+#include <machine/vmparam.h>
+#include <sys/param.h>
+
+/* This is an ugly way to hack around the incorrect
+ * definition of UPAGES in ns532/machparam.h.
+ *
+ * The definition should specify the size reserved
+ * for "struct user" in core files in PAGES,
+ * but instead it gives it in 512-byte core-clicks
+ * for ns532, i386 and i860. UPAGES is used only in trad-core.c.
+ */
+#if UPAGES == 16
+#undef UPAGES
+#define UPAGES 2
+#endif
+
+#if UPAGES != 2
+#error UPAGES is neither 2 nor 16
+#endif
+
+#define HOST_PAGE_SIZE 1
+#define HOST_SEGMENT_SIZE NBPG
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
diff --git a/bfd/hosts/riscos.h b/bfd/hosts/riscos.h
new file mode 100644
index 00000000000..8ffa826bdcf
--- /dev/null
+++ b/bfd/hosts/riscos.h
@@ -0,0 +1,10 @@
+/* RISC/os 4.52C, and presumably other versions. */
+
+#include <bsd43/machine/machparam.h>
+#include <bsd43/machine/vmparam.h>
+
+#define NBPG BSD43_NBPG
+#define UPAGES BSD43_UPAGES
+#define HOST_TEXT_START_ADDR BSD43_USRTEXT
+#define HOST_DATA_START_ADDR BSD43_USRDATA
+#define HOST_STACK_END_ADDR BSD43_USRSTACK
diff --git a/bfd/hosts/symmetry.h b/bfd/hosts/symmetry.h
new file mode 100644
index 00000000000..75717b31eb2
--- /dev/null
+++ b/bfd/hosts/symmetry.h
@@ -0,0 +1,20 @@
+/* Symmetry running either dynix 3.1 (bsd) or ptx (sysv). */
+
+#define NBPG 4096
+#define UPAGES 1
+
+#ifdef _SEQUENT_
+/* ptx */
+#define HOST_TEXT_START_ADDR 0
+#define HOST_STACK_END_ADDR 0x3fffe000
+#define TRAD_CORE_USER_OFFSET ((UPAGES * NBPG) - sizeof (struct user))
+#else
+/* dynix */
+#define HOST_TEXT_START_ADDR 0x1000
+#define HOST_DATA_START_ADDR (NBPG * u.u_tsize)
+#define HOST_STACK_END_ADDR 0x3ffff000
+#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
+ ((core_bfd)->tdata.trad_core_data->u.u_arg[0])
+#endif
+
+#define TRAD_CORE_DSIZE_INCLUDES_TSIZE
diff --git a/bfd/hosts/tahoe.h b/bfd/hosts/tahoe.h
new file mode 100644
index 00000000000..716cee2a171
--- /dev/null
+++ b/bfd/hosts/tahoe.h
@@ -0,0 +1,12 @@
+#define NO_CORE_COMMAND
+
+#undef ALIGN /* They use it, we use it too */
+#include <machine/param.h>
+#undef ALIGN /* They use it, we use it too */
+
+#define HOST_PAGE_SIZE NBPG
+#define HOST_MACHINE_ARCH bfd_arch_tahoe
+
+#define HOST_TEXT_START_ADDR 0
+#define HOST_STACK_END_ADDR (KERNBASE - (UPAGES * NBPG))
+#define HOST_BIG_ENDIAN_P
diff --git a/bfd/hosts/vaxbsd.h b/bfd/hosts/vaxbsd.h
new file mode 100644
index 00000000000..ceb9ccedfaf
--- /dev/null
+++ b/bfd/hosts/vaxbsd.h
@@ -0,0 +1,19 @@
+#define NO_CORE_COMMAND /* No command name in core file */
+
+#if 0
+#undef ALIGN /* They use it, we use it too */
+/* Does not exist on BSD 4.3, it uses machine/machparam.h.
+ Whatever it is, it's included by <sys/param.h>, which trad-core.c,
+ the only place that uses this (I think), already includes. */
+#include <machine/param.h>
+#endif
+#undef ALIGN /* They use it, we use it too */
+
+/* Note that HOST_PAGE_SIZE -- the page size as far as executable files
+ are concerned -- is not the same as NBPG, because of page clustering. */
+#define HOST_PAGE_SIZE 1024
+#define HOST_MACHINE_ARCH bfd_arch_vax
+
+#define HOST_TEXT_START_ADDR 0
+#define HOST_STACK_END_ADDR (0x80000000 - (UPAGES * NBPG))
+#undef HOST_BIG_ENDIAN_P
diff --git a/bfd/hosts/vaxult.h b/bfd/hosts/vaxult.h
new file mode 100644
index 00000000000..13731b7479f
--- /dev/null
+++ b/bfd/hosts/vaxult.h
@@ -0,0 +1,8 @@
+#include <machine/param.h>
+#include <machine/vmparam.h>
+#define HOST_PAGE_SIZE (NBPG*CLSIZE)
+#define HOST_MACHINE_ARCH bfd_arch_vax
+
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
+#undef HOST_BIG_ENDIAN_P
diff --git a/bfd/hosts/vaxult2.h b/bfd/hosts/vaxult2.h
new file mode 100644
index 00000000000..13731b7479f
--- /dev/null
+++ b/bfd/hosts/vaxult2.h
@@ -0,0 +1,8 @@
+#include <machine/param.h>
+#include <machine/vmparam.h>
+#define HOST_PAGE_SIZE (NBPG*CLSIZE)
+#define HOST_MACHINE_ARCH bfd_arch_vax
+
+#define HOST_TEXT_START_ADDR USRTEXT
+#define HOST_STACK_END_ADDR USRSTACK
+#undef HOST_BIG_ENDIAN_P
diff --git a/bfd/hp300bsd.c b/bfd/hp300bsd.c
new file mode 100644
index 00000000000..5767b18c179
--- /dev/null
+++ b/bfd/hp300bsd.c
@@ -0,0 +1,38 @@
+/* BFD back-end for HP 9000/300 (68000-based) machines running BSD Unix.
+ Copyright 1992 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_IS_BIG_ENDIAN_P
+#define N_HEADER_IN_TEXT(x) 0
+#define BYTES_IN_WORD 4
+#define ENTRY_CAN_BE_ZERO
+#define N_SHARED_LIB(x) 0 /* Avoids warning */
+#define TEXT_START_ADDR 0
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_m68k
+
+#define MY(OP) CAT(hp300bsd_,OP)
+#define TARGETNAME "a.out-hp300bsd"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#include "aout-target.h"
diff --git a/bfd/hp300hpux.c b/bfd/hp300hpux.c
new file mode 100644
index 00000000000..9552318baa8
--- /dev/null
+++ b/bfd/hp300hpux.c
@@ -0,0 +1,870 @@
+/* BFD backend for hp-ux 9000/300
+ Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
+ Written by Glenn Engel.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+
+ hpux native ------------> | |
+ | hp300hpux bfd | ----------> hpux w/gnu ext
+ hpux w/gnu extension ----> | |
+
+
+ Support for the 9000/[34]00 has several limitations.
+ 1. Shared libraries are not supported.
+ 2. The output format from this bfd is not usable by native tools.
+
+ The primary motivation for writing this bfd was to allow use of
+ gdb and gcc for host based debugging and not to mimic the hp-ux tools
+ in every detail. This leads to a significant simplification of the
+ code and a leap in performance. The decision to not output hp native
+ compatible objects was further strengthened by the fact that the richness
+ of the gcc compiled objects could not be represented without loss of
+ information. For example, while the hp format supports the concept of
+ secondary symbols, it does not support indirect symbols. Another
+ reason is to maintain backwards compatibility with older implementations
+ of gcc on hpux which used 'hpxt' to translate .a and .o files into a
+ format which could be readily understood by the gnu linker and gdb.
+ This allows reading hp secondary symbols and converting them into
+ indirect symbols but the reverse it not always possible.
+
+ Another example of differences is that the hp format stores symbol offsets
+ in the object code while the gnu utilities use a field in the
+ relocation record for this. To support the hp native format, the object
+ code would need to be patched with the offsets when producing .o files.
+
+ The basic technique taken in this implementation is to #include the code
+ from aoutx.h and aout-target.h with appropriate #defines to override
+ code where a unique implementation is needed:
+
+ {
+ #define a bunch of stuff
+ #include <aoutx.h>
+
+ implement a bunch of functions
+
+ #include "aout-target.h"
+ }
+
+ The hp symbol table is a bit different than other a.out targets. Instead
+ of having an array of nlist items and an array of strings, hp's format
+ has them mixed together in one structure. In addition, the strings are
+ not null terminated. It looks something like this:
+
+ nlist element 1
+ string1
+ nlist element 2
+ string2
+ ...
+
+ The whole symbol table is read as one chunk and then we march thru it
+ and convert it to canonical form. As we march thru the table, we copy
+ the nlist data into the internal form and we compact the strings and null
+ terminate them, using storage from the already allocated symbol table:
+
+ string1
+ null
+ string2
+ null
+ */
+
+/* @@ Is this really so different from normal a.out that it needs to include
+ aoutx.h? We should go through this file sometime and see what can be made
+ more dependent on aout32.o and what might need to be broken off and accessed
+ through the backend_data field. Or, maybe we really do need such a
+ completely separate implementation. I don't have time to investigate this
+ much further right now. [raeburn:19930428.2124EST] */
+/* @@ Also, note that there wind up being two versions of some routines, with
+ different names, only one of which actually gets used. For example:
+ slurp_symbol_table
+ swap_std_reloc_in
+ slurp_reloc_table
+ get_symtab
+ get_symtab_upper_bound
+ canonicalize_reloc
+ mkobject
+ This should also be fixed. */
+
+#define TARGETNAME "a.out-hp300hpux"
+#define MY(OP) CAT(hp300hpux_,OP)
+
+#define external_exec hp300hpux_exec_bytes
+#define external_nlist hp300hpux_nlist_bytes
+
+#include "aout/hp300hpux.h"
+
+/* define these so we can compile unused routines in aoutx.h */
+#define e_strx e_shlib
+#define e_other e_length
+#define e_desc e_almod
+
+#define AR_PAD_CHAR '/'
+#define TARGET_IS_BIG_ENDIAN_P
+#define DEFAULT_ARCH bfd_arch_m68k
+
+#define MY_get_section_contents aout_32_get_section_contents
+#define MY_slurp_armap bfd_slurp_bsd_armap_f2
+
+/***********************************************/
+/* provide overrides for routines in this file */
+/***********************************************/
+/* these don't use MY because that causes problems within JUMP_TABLE
+ (CAT winds up being expanded recursively, which ANSI C compilers
+ will not do). */
+#define MY_get_symtab hp300hpux_get_symtab
+#define MY_get_symtab_upper_bound hp300hpux_get_symtab_upper_bound
+#define MY_canonicalize_reloc hp300hpux_canonicalize_reloc
+#define MY_write_object_contents hp300hpux_write_object_contents
+
+#define MY_read_minisymbols _bfd_generic_read_minisymbols
+#define MY_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define MY_final_link_callback unused
+#define MY_bfd_final_link _bfd_generic_final_link
+
+/* Until and unless we convert the slurp_reloc and slurp_symtab
+ routines in this file, we can not use the default aout
+ free_cached_info routine which assumes that the relocs and symtabs
+ were allocated using malloc. */
+#define MY_bfd_free_cached_info bfd_true
+
+#define hp300hpux_write_syms aout_32_write_syms
+
+#define MY_callback MY(callback)
+
+#define MY_exec_hdr_flags 0x2
+
+#define NAME_swap_exec_header_in NAME(hp300hpux_32_,swap_exec_header_in)
+
+#define HP_SYMTYPE_UNDEFINED 0x00
+#define HP_SYMTYPE_ABSOLUTE 0x01
+#define HP_SYMTYPE_TEXT 0x02
+#define HP_SYMTYPE_DATA 0x03
+#define HP_SYMTYPE_BSS 0x04
+#define HP_SYMTYPE_COMMON 0x05
+
+#define HP_SYMTYPE_TYPE 0x0F
+#define HP_SYMTYPE_FILENAME 0x1F
+
+#define HP_SYMTYPE_ALIGN 0x10
+#define HP_SYMTYPE_EXTERNAL 0x20
+#define HP_SECONDARY_SYMBOL 0x40
+
+/* RELOCATION DEFINITIONS */
+#define HP_RSEGMENT_TEXT 0x00
+#define HP_RSEGMENT_DATA 0x01
+#define HP_RSEGMENT_BSS 0x02
+#define HP_RSEGMENT_EXTERNAL 0x03
+#define HP_RSEGMENT_PCREL 0x04
+#define HP_RSEGMENT_RDLT 0x05
+#define HP_RSEGMENT_RPLT 0x06
+#define HP_RSEGMENT_NOOP 0x3F
+
+#define HP_RLENGTH_BYTE 0x00
+#define HP_RLENGTH_WORD 0x01
+#define HP_RLENGTH_LONG 0x02
+#define HP_RLENGTH_ALIGN 0x03
+
+#define NAME(x,y) CAT3(hp300hpux,_32_,y)
+#define ARCH_SIZE 32
+
+/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
+#define BMAGIC HPUX_DOT_O_MAGIC
+#define QMAGIC 0314
+
+#include "aoutx.h"
+
+/* Since the hpux symbol table has nlist elements interspersed with
+ strings and we need to insert som strings for secondary symbols, we
+ give ourselves a little extra padding up front to account for
+ this. Note that for each non-secondary symbol we process, we gain
+ 9 bytes of space for the discarded nlist element (one byte used for
+ null). SYM_EXTRA_BYTES is the extra space. */
+#define SYM_EXTRA_BYTES 1024
+
+/* Set parameters about this a.out file that are machine-dependent.
+ This routine is called from some_aout_object_p just before it returns. */
+static const bfd_target *
+MY (callback) (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ /* Calculate the file positions of the parts of a newly read aout header */
+ obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
+
+ /* The virtual memory addresses of the sections */
+ obj_textsec (abfd)->vma = N_TXTADDR (*execp);
+ obj_datasec (abfd)->vma = N_DATADDR (*execp);
+ obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
+
+ obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
+ obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
+ obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
+
+ /* The file offsets of the sections */
+ obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
+ obj_datasec (abfd)->filepos = N_DATOFF (*execp);
+
+ /* The file offsets of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
+ obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
+
+ /* The file offsets of the string table and symbol table. */
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+
+ /* Determine the architecture and machine type of the object file. */
+#ifdef SET_ARCH_MACH
+ SET_ARCH_MACH (abfd, *execp);
+#else
+ bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
+#endif
+
+
+ if (obj_aout_subformat (abfd) == gnu_encap_format)
+ {
+ /* The file offsets of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_GNU_TRELOFF (*execp);
+ obj_datasec (abfd)->rel_filepos = N_GNU_DRELOFF (*execp);
+
+ /* The file offsets of the string table and symbol table. */
+ obj_sym_filepos (abfd) = N_GNU_SYMOFF (*execp);
+ obj_str_filepos (abfd) = (obj_sym_filepos (abfd) + execp->a_syms);
+
+ abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+ bfd_get_symcount (abfd) = execp->a_syms / 12;
+ obj_symbol_entry_size (abfd) = 12;
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ }
+
+ return abfd->xvec;
+}
+
+extern boolean aout_32_write_syms PARAMS ((bfd * abfd));
+
+static boolean
+MY (write_object_contents) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+ bfd_size_type text_size; /* dummy vars */
+ file_ptr text_end;
+
+ memset (&exec_bytes, 0, sizeof (exec_bytes));
+#if CHOOSE_RELOC_SIZE
+ CHOOSE_RELOC_SIZE (abfd);
+#else
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+#endif
+
+ if (adata (abfd).magic == undecided_magic)
+ NAME (aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
+ execp->a_syms = 0;
+
+ execp->a_entry = bfd_get_start_address (abfd);
+
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
+ obj_reloc_entry_size (abfd));
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
+ obj_reloc_entry_size (abfd));
+
+ N_SET_MACHTYPE (*execp, 0xc);
+ N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
+
+ NAME (aout,swap_exec_header_out) (abfd, execp, &exec_bytes);
+
+ /* update fields not covered by default swap_exec_header_out */
+
+ /* this is really the sym table size but we store it in drelocs */
+ bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
+
+ if (bfd_seek (abfd, 0L, false) != 0
+ || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
+
+ /* Write out the symbols, and then the relocs. We must write out
+ the symbols first so that we know the symbol indices. */
+
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ /* Skip the relocs to where we want to put the symbols. */
+ if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
+ SEEK_SET) != 0)
+ return false;
+ }
+
+ if (!MY (write_syms) (abfd))
+ return false;
+
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
+ return false;
+ if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
+ return false;
+ if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
+ return false;
+ if (!NAME (aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))
+ return false;
+ }
+
+ return true;
+}
+
+/* convert the hp symbol type to be the same as aout64.h usage so we */
+/* can piggyback routines in aoutx.h. */
+
+static void
+convert_sym_type (sym_pointer, cache_ptr, abfd)
+ struct external_nlist *sym_pointer;
+ aout_symbol_type *cache_ptr;
+ bfd *abfd;
+{
+ int name_type;
+ int new_type;
+
+ name_type = (cache_ptr->type);
+ new_type = 0;
+
+ if ((name_type & HP_SYMTYPE_ALIGN) != 0)
+ {
+ /* iou_error ("aligned symbol encountered: %s", name);*/
+ name_type = 0;
+ }
+
+ if (name_type == HP_SYMTYPE_FILENAME)
+ new_type = N_FN;
+ else
+ {
+ switch (name_type & HP_SYMTYPE_TYPE)
+ {
+ case HP_SYMTYPE_UNDEFINED:
+ new_type = N_UNDF;
+ break;
+
+ case HP_SYMTYPE_ABSOLUTE:
+ new_type = N_ABS;
+ break;
+
+ case HP_SYMTYPE_TEXT:
+ new_type = N_TEXT;
+ break;
+
+ case HP_SYMTYPE_DATA:
+ new_type = N_DATA;
+ break;
+
+ case HP_SYMTYPE_BSS:
+ new_type = N_BSS;
+ break;
+
+ case HP_SYMTYPE_COMMON:
+ new_type = N_COMM;
+ break;
+
+ default:
+ abort ();
+ break;
+ }
+ if (name_type & HP_SYMTYPE_EXTERNAL)
+ new_type |= N_EXT;
+
+ if (name_type & HP_SECONDARY_SYMBOL)
+ {
+ switch (new_type)
+ {
+ default:
+ abort ();
+ case N_UNDF | N_EXT:
+ /* If the value is nonzero, then just treat this as a
+ common symbol. I don't know if this is correct in
+ all cases, but it is more correct than treating it as
+ a weak undefined symbol. */
+ if (cache_ptr->symbol.value == 0)
+ new_type = N_WEAKU;
+ break;
+ case N_ABS | N_EXT:
+ new_type = N_WEAKA;
+ break;
+ case N_TEXT | N_EXT:
+ new_type = N_WEAKT;
+ break;
+ case N_DATA | N_EXT:
+ new_type = N_WEAKD;
+ break;
+ case N_BSS | N_EXT:
+ new_type = N_WEAKB;
+ break;
+ }
+ }
+ }
+ cache_ptr->type = new_type;
+
+}
+
+
+/*
+DESCRIPTION
+ Swaps the information in an executable header taken from a raw
+ byte stream memory image, into the internal exec_header
+ structure.
+*/
+
+void
+NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
+{
+ struct external_exec *bytes = (struct external_exec *) raw_bytes;
+
+ /* The internal_exec structure has some fields that are unused in this
+ configuration (IE for i960), so ensure that all such uninitialized
+ fields are zero'd out. There are places where two of these structs
+ are memcmp'd, and thus the contents do matter. */
+ memset (execp, 0, sizeof (struct internal_exec));
+ /* Now fill in fields in the execp, from the bytes in the raw data. */
+ execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_text = GET_WORD (abfd, bytes->e_text);
+ execp->a_data = GET_WORD (abfd, bytes->e_data);
+ execp->a_bss = GET_WORD (abfd, bytes->e_bss);
+ execp->a_syms = GET_WORD (abfd, bytes->e_syms);
+ execp->a_entry = GET_WORD (abfd, bytes->e_entry);
+ execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
+ execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
+
+ /***************************************************************/
+ /* check the header to see if it was generated by a bfd output */
+ /* this is detected rather bizarely by requiring a bunch of */
+ /* header fields to be zero and an old unused field (now used) */
+ /* to be set. */
+ /***************************************************************/
+ do
+ {
+ long syms;
+ struct aout_data_struct *rawptr;
+ if (bfd_h_get_32 (abfd, bytes->e_passize) != 0)
+ break;
+ if (bfd_h_get_32 (abfd, bytes->e_syms) != 0)
+ break;
+ if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0)
+ break;
+
+ syms = bfd_h_get_32 (abfd, bytes->e_drelocs);
+ if (syms == 0)
+ break;
+
+ /* OK, we've passed the test as best as we can determine */
+ execp->a_syms = syms;
+
+ /* allocate storage for where we will store this result */
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr));
+
+ if (rawptr == NULL)
+ return;
+ abfd->tdata.aout_data = rawptr;
+ obj_aout_subformat (abfd) = gnu_encap_format;
+ }
+ while (0);
+}
+
+
+/* The hp symbol table is a bit different than other a.out targets. Instead
+ of having an array of nlist items and an array of strings, hp's format
+ has them mixed together in one structure. In addition, the strings are
+ not null terminated. It looks something like this:
+
+ nlist element 1
+ string1
+ nlist element 2
+ string2
+ ...
+
+ The whole symbol table is read as one chunk and then we march thru it
+ and convert it to canonical form. As we march thru the table, we copy
+ the nlist data into the internal form and we compact the strings and null
+ terminate them, using storage from the already allocated symbol table:
+
+ string1
+ null
+ string2
+ null
+ ...
+*/
+
+boolean
+MY (slurp_symbol_table) (abfd)
+ bfd *abfd;
+{
+ bfd_size_type symbol_bytes;
+ struct external_nlist *syms;
+ struct external_nlist *sym_pointer;
+ struct external_nlist *sym_end;
+ char *strings;
+ aout_symbol_type *cached;
+ unsigned num_syms = 0;
+
+ /* If there's no work to be done, don't do any */
+ if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
+ return true;
+ symbol_bytes = exec_hdr (abfd)->a_syms;
+
+ strings = (char *) bfd_alloc (abfd,
+ symbol_bytes + SYM_EXTRA_BYTES);
+ if (!strings)
+ return false;
+ syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+ || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
+ {
+ bfd_release (abfd, syms);
+ return false;
+ }
+
+
+ sym_end = (struct external_nlist *) (((char *) syms) + symbol_bytes);
+
+ /* first, march thru the table and figure out how many symbols there are */
+ for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++, num_syms++)
+ {
+ /* skip over the embedded symbol. */
+ sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
+ sym_pointer->e_length[0]);
+ }
+
+ /* now that we know the symbol count, update the bfd header */
+ bfd_get_symcount (abfd) = num_syms;
+
+ cached = ((aout_symbol_type *)
+ bfd_zalloc (abfd,
+ bfd_get_symcount (abfd) * sizeof (aout_symbol_type)));
+ if (cached == NULL && bfd_get_symcount (abfd) != 0)
+ return false;
+
+ /* as we march thru the hp symbol table, convert it into a list of
+ null terminated strings to hold the symbol names. Make sure any
+ assignment to the strings pointer is done after we're thru using
+ the nlist so we don't overwrite anything important. */
+
+ /* OK, now walk the new symtable, cacheing symbol properties */
+ {
+ aout_symbol_type *cache_ptr = cached;
+ aout_symbol_type cache_save;
+ /* Run through table and copy values */
+ for (sym_pointer = syms, cache_ptr = cached;
+ sym_pointer < sym_end; sym_pointer++, cache_ptr++)
+ {
+ unsigned int length;
+ cache_ptr->symbol.the_bfd = abfd;
+ cache_ptr->symbol.value = GET_SWORD (abfd, sym_pointer->e_value);
+ cache_ptr->desc = bfd_get_16 (abfd, sym_pointer->e_almod);
+ cache_ptr->type = bfd_get_8 (abfd, sym_pointer->e_type);
+ cache_ptr->symbol.udata.p = NULL;
+ length = bfd_get_8 (abfd, sym_pointer->e_length);
+ cache_ptr->other = length; /* other not used, save length here */
+
+ cache_save = *cache_ptr;
+ convert_sym_type (sym_pointer, cache_ptr, abfd);
+ if (!translate_from_native_sym_flags (abfd, cache_ptr))
+ return false;
+
+ /********************************************************/
+ /* for hpux, the 'lenght' value indicates the length of */
+ /* the symbol name which follows the nlist entry. */
+ /********************************************************/
+ if (length)
+ {
+ /**************************************************************/
+ /* the hp string is not null terminated so we create a new one*/
+ /* by copying the string to overlap the just vacated nlist */
+ /* structure before it in memory. */
+ /**************************************************************/
+ cache_ptr->symbol.name = strings;
+ memcpy (strings, sym_pointer + 1, length);
+ strings[length] = '\0';
+ strings += length + 1;
+ }
+ else
+ cache_ptr->symbol.name = (char *) NULL;
+
+ /* skip over the embedded symbol. */
+ sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
+ length);
+ }
+ }
+
+ obj_aout_symbols (abfd) = cached;
+
+ return true;
+}
+
+
+
+void
+MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct hp300hpux_reloc *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ int r_index;
+ int r_extern = 0;
+ unsigned int r_length;
+ int r_pcrel = 0;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+
+ cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+ r_index = bfd_h_get_16 (abfd, bytes->r_index);
+
+ switch (bytes->r_type[0])
+ {
+ case HP_RSEGMENT_TEXT:
+ r_index = N_TEXT;
+ break;
+ case HP_RSEGMENT_DATA:
+ r_index = N_DATA;
+ break;
+ case HP_RSEGMENT_BSS:
+ r_index = N_BSS;
+ break;
+ case HP_RSEGMENT_EXTERNAL:
+ r_extern = 1;
+ break;
+ case HP_RSEGMENT_PCREL:
+ r_extern = 1;
+ r_pcrel = 1;
+ break;
+ case HP_RSEGMENT_RDLT:
+ break;
+ case HP_RSEGMENT_RPLT:
+ break;
+ case HP_RSEGMENT_NOOP:
+ break;
+ default:
+ abort ();
+ break;
+ }
+
+ switch (bytes->r_length[0])
+ {
+ case HP_RLENGTH_BYTE:
+ r_length = 0;
+ break;
+ case HP_RLENGTH_WORD:
+ r_length = 1;
+ break;
+ case HP_RLENGTH_LONG:
+ r_length = 2;
+ break;
+ default:
+ abort ();
+ break;
+ }
+
+ cache_ptr->howto = howto_table_std + r_length + 4 * r_pcrel;
+ /* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */
+
+ /* This macro uses the r_index value computed above */
+ if (r_pcrel && r_extern)
+ {
+ /* The GNU linker assumes any offset from beginning of section */
+ /* is already incorporated into the image while the HP linker */
+ /* adds this in later. Add it in now... */
+ MOVE_ADDRESS (-cache_ptr->address);
+ }
+ else
+ {
+ MOVE_ADDRESS (0);
+ }
+}
+
+boolean
+MY (slurp_reloc_table) (abfd, asect, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ asymbol **symbols;
+{
+ unsigned int count;
+ bfd_size_type reloc_size;
+ PTR relocs;
+ arelent *reloc_cache;
+ size_t each_size;
+ struct hp300hpux_reloc *rptr;
+ unsigned int counter;
+ arelent *cache_ptr;
+
+ if (asect->relocation)
+ return true;
+
+ if (asect->flags & SEC_CONSTRUCTOR)
+ return true;
+
+ if (asect == obj_datasec (abfd))
+ {
+ reloc_size = exec_hdr (abfd)->a_drsize;
+ goto doit;
+ }
+
+ if (asect == obj_textsec (abfd))
+ {
+ reloc_size = exec_hdr (abfd)->a_trsize;
+ goto doit;
+ }
+
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+
+doit:
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+ return false;
+ each_size = obj_reloc_entry_size (abfd);
+
+ count = reloc_size / each_size;
+
+
+ reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
+ (arelent)));
+ if (!reloc_cache && count != 0)
+ return false;
+
+ relocs = (PTR) bfd_alloc (abfd, reloc_size);
+ if (!relocs && reloc_size != 0)
+ {
+ bfd_release (abfd, reloc_cache);
+ return false;
+ }
+
+ if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ {
+ bfd_release (abfd, relocs);
+ bfd_release (abfd, reloc_cache);
+ return false;
+ }
+
+ rptr = (struct hp300hpux_reloc *) relocs;
+ counter = 0;
+ cache_ptr = reloc_cache;
+
+ for (; counter < count; counter++, rptr++, cache_ptr++)
+ {
+ MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
+ }
+
+
+ bfd_release (abfd, relocs);
+ asect->relocation = reloc_cache;
+ asect->reloc_count = count;
+ return true;
+}
+
+
+/************************************************************************/
+/* The following functions are identical to functions in aoutx.h except */
+/* they refer to MY(func) rather than NAME(aout,func) and they also */
+/* call aout_32 versions if the input file was generated by gcc */
+/************************************************************************/
+
+long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
+long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
+
+long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
+ arelent ** relptr,
+ asymbol ** symbols));
+
+long
+MY (get_symtab) (abfd, location)
+ bfd *abfd;
+ asymbol **location;
+{
+ unsigned int counter = 0;
+ aout_symbol_type *symbase;
+
+ if (obj_aout_subformat (abfd) == gnu_encap_format)
+ return aout_32_get_symtab (abfd, location);
+
+ if (!MY (slurp_symbol_table) (abfd))
+ return -1;
+
+ for (symbase = obj_aout_symbols (abfd); counter++ < bfd_get_symcount (abfd);)
+ *(location++) = (asymbol *) (symbase++);
+ *location++ = 0;
+ return bfd_get_symcount (abfd);
+}
+
+long
+MY (get_symtab_upper_bound) (abfd)
+ bfd *abfd;
+{
+ if (obj_aout_subformat (abfd) == gnu_encap_format)
+ return aout_32_get_symtab_upper_bound (abfd);
+ if (!MY (slurp_symbol_table) (abfd))
+ return -1;
+
+ return (bfd_get_symcount (abfd) + 1) * (sizeof (aout_symbol_type *));
+}
+
+
+
+
+long
+MY (canonicalize_reloc) (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count;
+ if (obj_aout_subformat (abfd) == gnu_encap_format)
+ return aout_32_canonicalize_reloc (abfd, section, relptr, symbols);
+
+ if (!(tblptr || MY (slurp_reloc_table) (abfd, section, symbols)))
+ return -1;
+
+ if (section->flags & SEC_CONSTRUCTOR)
+ {
+ arelent_chain *chain = section->constructor_chain;
+ for (count = 0; count < section->reloc_count; count++)
+ {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+ }
+ else
+ {
+ tblptr = section->relocation;
+
+ for (count = 0; count++ < section->reloc_count;)
+ {
+ *relptr++ = tblptr++;
+ }
+ }
+ *relptr = 0;
+
+ return section->reloc_count;
+}
+
+
+#include "aout-target.h"
diff --git a/bfd/hppa_stubs.h b/bfd/hppa_stubs.h
new file mode 100644
index 00000000000..ee893e8a57b
--- /dev/null
+++ b/bfd/hppa_stubs.h
@@ -0,0 +1,23 @@
+/* HPPA linker stub instructions */
+
+/* These are the instructions which the linker may insert into the
+ code stream when building final executables to handle out-of-range
+ calls and argument relocations. */
+
+#define LDO_M4_R31_R31 0x37ff3ff9 /* ldo -4(%r31),%r31 */
+#define LDIL_R1 0x20200000 /* ldil XXX,%r1 */
+#define BE_SR4_R1 0xe0202000 /* be XXX(%sr4,%r1) */
+#define COPY_R31_R2 0x081f0242 /* copy %r31,%r2 */
+#define BLE_SR4_R0 0xe4002000 /* ble XXX(%sr4,%r0) */
+#define BLE_SR4_R1 0xe4202000 /* ble XXX(%sr4,%r1) */
+#define BV_N_0_R31 0xebe0c002 /* bv,n 0(%r31) */
+#define STW_R31_M8R30 0x6bdf3ff1 /* stw %r31,-8(%r30) */
+#define LDW_M8R30_R31 0x4bdf3ff1 /* ldw -8(%r30),%r31 */
+#define STW_ARG_M16R30 0x6bc03fe1 /* stw %argX,-16(%r30) */
+#define LDW_M16R30_ARG 0x4bc03fe1 /* ldw -12(%r30),%argX */
+#define STW_ARG_M12R30 0x6bc03fe9 /* stw %argX,-16(%r30) */
+#define LDW_M12R30_ARG 0x4bc03fe9 /* ldw -12(%r30),%argX */
+#define FSTW_FARG_M16R30 0x27c11200 /* fstws %fargX,-16(%r30) */
+#define FLDW_M16R30_FARG 0x27c11000 /* fldws -16(%r30),%fargX */
+#define FSTD_FARG_M16R30 0x2fc11200 /* fstds %fargX,-16(%r30) */
+#define FLDD_M16R30_FARG 0x2fc11000 /* fldds -16(%r30),%fargX */
diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c
new file mode 100644
index 00000000000..a7c22f519eb
--- /dev/null
+++ b/bfd/hppabsd-core.c
@@ -0,0 +1,303 @@
+/* BFD back-end for HPPA BSD core files.
+ Copyright 1993, 94, 95, 97, 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Written by the Center for Software Science at the University of Utah
+ and by Cygnus Support.
+
+ The core file structure for the Utah 4.3BSD and OSF1 ports on the
+ PA is a mix between traditional cores and hpux cores -- just
+ different enough that supporting this format would tend to add
+ gross hacks to trad-core.c or hpux-core.c. So instead we keep any
+ gross hacks isolated to this file. */
+
+
+/* This file can only be compiled on systems which use HPPA-BSD style
+ core files.
+
+ I would not expect this to be of use to any other host/target, but
+ you never know. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#if defined (HOST_HPPABSD)
+
+#include "machine/vmparam.h"
+
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <signal.h>
+#include <machine/reg.h>
+#include <sys/user.h> /* After a.out.h */
+#include <sys/file.h>
+
+static asection *make_bfd_asection PARAMS ((bfd *, CONST char *,
+ flagword, bfd_size_type,
+ file_ptr, unsigned int));
+static asymbol *hppabsd_core_make_empty_symbol PARAMS ((bfd *));
+static const bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
+static char *hppabsd_core_core_file_failing_command PARAMS ((bfd *));
+static int hppabsd_core_core_file_failing_signal PARAMS ((bfd *));
+static boolean hppabsd_core_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
+static void swap_abort PARAMS ((void));
+
+/* These are stored in the bfd's tdata. */
+
+struct hppabsd_core_struct
+ {
+ int sig;
+ char cmd[MAXCOMLEN + 1];
+ asection *data_section;
+ asection *stack_section;
+ asection *reg_section;
+ };
+
+#define core_hdr(bfd) ((bfd)->tdata.hppabsd_core_data)
+#define core_signal(bfd) (core_hdr(bfd)->sig)
+#define core_command(bfd) (core_hdr(bfd)->cmd)
+#define core_datasec(bfd) (core_hdr(bfd)->data_section)
+#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
+#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power)
+ bfd *abfd;
+ CONST char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ file_ptr offset;
+ unsigned int alignment_power;
+{
+ asection *asect;
+
+ asect = bfd_make_section (abfd, name);
+ if (!asect)
+ return NULL;
+
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->filepos = offset;
+ asect->alignment_power = alignment_power;
+
+ return asect;
+}
+
+static asymbol *
+hppabsd_core_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+static const bfd_target *
+hppabsd_core_core_file_p (abfd)
+ bfd *abfd;
+{
+ int val;
+ struct user u;
+ struct hppabsd_core_struct *coredata;
+ int clicksz;
+
+ /* Try to read in the u-area. We will need information from this
+ to know how to grok the rest of the core structures. */
+ val = bfd_read ((void *) &u, 1, sizeof u, abfd);
+ if (val != sizeof u)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Get the page size out of the u structure. This will be different
+ for PA 1.0 machines and PA 1.1 machines. Yuk! */
+ clicksz = u.u_pcb.pcb_pgsz;
+
+ /* clicksz must be a power of two >= 2k. */
+ if (clicksz < 0x800
+ || clicksz != (clicksz & -clicksz))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+
+ /* Sanity checks. Make sure the size of the core file matches the
+ the size computed from information within the core itself. */
+ {
+ FILE *stream = bfd_cache_lookup (abfd);
+ struct stat statbuf;
+ if (stream == NULL || fstat (fileno (stream), &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+ if (NBPG * (UPAGES + u.u_dsize + u.u_ssize) > statbuf.st_size)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return NULL;
+ }
+ if (clicksz * (UPAGES + u.u_dsize + u.u_ssize) < statbuf.st_size)
+ {
+ /* The file is too big. Maybe it's not a core file
+ or we otherwise have bad values for u_dsize and u_ssize). */
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ coredata = (struct hppabsd_core_struct *)
+ bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
+ if (!coredata)
+ return NULL;
+
+ /* Make the core data and available via the tdata part of the BFD. */
+ abfd->tdata.hppabsd_core_data = coredata;
+
+ /* Create the sections. */
+ core_stacksec (abfd) = make_bfd_asection (abfd, ".stack",
+ SEC_ALLOC + SEC_HAS_CONTENTS,
+ clicksz * u.u_ssize,
+ NBPG * (USIZE + KSTAKSIZE)
+ + clicksz * u.u_dsize, 2);
+ core_stacksec (abfd)->vma = USRSTACK;
+
+ core_datasec (abfd) = make_bfd_asection (abfd, ".data",
+ SEC_ALLOC + SEC_LOAD
+ + SEC_HAS_CONTENTS,
+ clicksz * u.u_dsize,
+ NBPG * (USIZE + KSTAKSIZE), 2);
+ core_datasec (abfd)->vma = UDATASEG;
+
+ core_regsec (abfd) = make_bfd_asection (abfd, ".reg",
+ SEC_HAS_CONTENTS,
+ KSTAKSIZE * NBPG,
+ NBPG * USIZE, 2);
+ core_regsec (abfd)->vma = 0;
+
+ strncpy (core_command (abfd), u.u_comm, MAXCOMLEN + 1);
+ core_signal (abfd) = u.u_code;
+ return abfd->xvec;
+}
+
+static char *
+hppabsd_core_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_command (abfd);
+}
+
+/* ARGSUSED */
+static int
+hppabsd_core_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_signal (abfd);
+}
+
+/* ARGSUSED */
+static boolean
+hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ /* There's no way to know this... */
+ return true;
+}
+
+
+#define hppabsd_core_get_symtab_upper_bound \
+ _bfd_nosymbols_get_symtab_upper_bound
+#define hppabsd_core_get_symtab _bfd_nosymbols_get_symtab
+#define hppabsd_core_print_symbol _bfd_nosymbols_print_symbol
+#define hppabsd_core_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define hppabsd_core_bfd_is_local_label_name \
+ _bfd_nosymbols_bfd_is_local_label_name
+#define hppabsd_core_get_lineno _bfd_nosymbols_get_lineno
+#define hppabsd_core_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define hppabsd_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define hppabsd_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define hppabsd_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort ()
+{
+ /* This way doesn't require any declaration for ANSI to fuck up. */
+ abort ();
+}
+
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target hppabsd_core_vec =
+ {
+ "hppabsd-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ hppabsd_core_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (hppabsd_core),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (hppabsd_core),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
+#endif
diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c
new file mode 100644
index 00000000000..6be709f4999
--- /dev/null
+++ b/bfd/hpux-core.c
@@ -0,0 +1,404 @@
+/* BFD back-end for HP/UX core files.
+ Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Written by Stu Grossman, Cygnus Support.
+ Converted to back-end form 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file can only be compiled on systems which use HP/UX style
+ core files. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#if defined (HOST_HPPAHPUX) || defined (HOST_HP300HPUX) || defined (HOST_HPPAMPEIX)
+
+/* FIXME: sys/core.h doesn't exist for HPUX version 7. HPUX version
+ 5, 6, and 7 core files seem to be standard trad-core.c type core
+ files; can we just use trad-core.c in addition to this file? */
+
+#include <sys/core.h>
+#include <sys/utsname.h>
+
+#endif /* HOST_HPPAHPUX */
+
+#ifdef HOST_HPPABSD
+
+/* Not a very swift place to put it, but that's where the BSD port
+ puts them. */
+#include "/hpux/usr/include/sys/core.h"
+
+#endif /* HOST_HPPABSD */
+
+#include <sys/param.h>
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+#else
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
+#include <signal.h>
+#include <machine/reg.h>
+#include <sys/user.h> /* After a.out.h */
+#include <sys/file.h>
+
+/* Kludge: There's no explicit mechanism provided by sys/core.h to
+ conditionally know whether a proc_info has thread id fields.
+ However, CORE_ANON_SHMEM shows up first at 10.30, which is
+ happily also when meaningful thread id's show up in proc_info. */
+#if defined(CORE_ANON_SHMEM)
+#define PROC_INFO_HAS_THREAD_ID (1)
+#endif
+
+/* This type appears at HP-UX 10.30. Defining it if not defined
+ by sys/core.h allows us to build for older HP-UX's, and (since
+ it won't be encountered in core-dumps from older HP-UX's) is
+ harmless. */
+#if !defined(CORE_ANON_SHMEM)
+#define CORE_ANON_SHMEM 0x00000200 /* anonymous shared memory */
+#endif
+
+/* These are stored in the bfd's tdata */
+
+/* .lwpid and .user_tid are only valid if PROC_INFO_HAS_THREAD_ID, else they
+ are set to 0. Also, until HP-UX implements MxN threads, .user_tid and
+ .lwpid are synonymous. */
+struct hpux_core_struct
+{
+ int sig;
+ int lwpid; /* Kernel thread ID. */
+ unsigned long user_tid; /* User thread ID. */
+ char cmd[MAXCOMLEN + 1];
+};
+
+#define core_hdr(bfd) ((bfd)->tdata.hpux_core_data)
+#define core_signal(bfd) (core_hdr(bfd)->sig)
+#define core_command(bfd) (core_hdr(bfd)->cmd)
+#define core_kernel_thread_id(bfd) (core_hdr(bfd)->lwpid)
+#define core_user_thread_id(bfd) (core_hdr(bfd)->user_tid)
+
+static void swap_abort PARAMS ((void));
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
+ bfd *abfd;
+ CONST char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ bfd_vma vma;
+ unsigned int alignment_power;
+{
+ asection *asect;
+ char *newname;
+
+ newname = bfd_alloc (abfd, strlen (name) + 1);
+ if (!newname)
+ return NULL;
+
+ strcpy (newname, name);
+
+ asect = bfd_make_section_anyway (abfd, newname);
+ if (!asect)
+ return NULL;
+
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->vma = vma;
+ asect->filepos = bfd_tell (abfd);
+ asect->alignment_power = alignment_power;
+
+ return asect;
+}
+
+static asymbol *
+hpux_core_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+
+/* this function builds a bfd target if the file is a corefile.
+ It returns null or 0 if it finds out thaat it is not a core file.
+ The way it checks this is by looking for allowed 'type' field values.
+ These are declared in sys/core.h
+ There are some values which are 'reserved for future use'. In particular
+ CORE_NONE is actually defined as 0. This may be a catch-all for cases
+ in which the core file is generated by some non-hpux application.
+ (I am just guessing here!)
+*/
+static const bfd_target *
+hpux_core_core_file_p (abfd)
+ bfd *abfd;
+{
+ int good_sections = 0;
+ int unknown_sections = 0;
+
+ core_hdr (abfd) = (struct hpux_core_struct *)
+ bfd_zalloc (abfd, sizeof (struct hpux_core_struct));
+ if (!core_hdr (abfd))
+ return NULL;
+
+ while (1)
+ {
+ int val;
+ struct corehead core_header;
+
+ val = bfd_read ((void *) &core_header, 1, sizeof core_header, abfd);
+ if (val <= 0)
+ break;
+ switch (core_header.type)
+ {
+ case CORE_KERNEL:
+ case CORE_FORMAT:
+ bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */
+ good_sections++;
+ break;
+ case CORE_EXEC:
+ {
+ struct proc_exec proc_exec;
+ if (bfd_read ((void *) &proc_exec, 1, core_header.len, abfd)
+ != core_header.len)
+ break;
+ strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
+ good_sections++;
+ }
+ break;
+ case CORE_PROC:
+ {
+ struct proc_info proc_info;
+ char secname[100]; /* Of arbitrary size, but plenty large. */
+
+ /* We need to read this section, 'cause we need to determine
+ whether the core-dumped app was threaded before we create
+ any .reg sections. */
+ if (bfd_read (&proc_info, 1, core_header.len, abfd)
+ != core_header.len)
+ break;
+
+ /* However, we also want to create those sections with the
+ file positioned at the start of the record, it seems. */
+ if (bfd_seek (abfd, -core_header.len, SEEK_CUR) != 0)
+ break;
+
+#if defined(PROC_INFO_HAS_THREAD_ID)
+ core_kernel_thread_id (abfd) = proc_info.lwpid;
+ core_user_thread_id (abfd) = proc_info.user_tid;
+#else
+ core_kernel_thread_id (abfd) = 0;
+ core_user_thread_id (abfd) = 0;
+#endif
+ /* If the program was unthreaded, then we'll just create a
+ .reg section.
+
+ If the program was threaded, then we'll create .reg/XXXXX
+ section for each thread, where XXXXX is a printable
+ representation of the kernel thread id. We'll also
+ create a .reg section for the thread that was running
+ and signalled at the time of the core-dump (i.e., this
+ is effectively an alias, needed to keep GDB happy.)
+
+ Note that we use `.reg/XXXXX' as opposed to '.regXXXXX'
+ because GDB expects that .reg2 will be the floating-
+ point registers. */
+ if (core_kernel_thread_id (abfd) == 0)
+ {
+ if (!make_bfd_asection (abfd, ".reg",
+ SEC_HAS_CONTENTS,
+ core_header.len,
+ (int) &proc_info - (int) & proc_info.hw_regs,
+ 2))
+ return NULL;
+ }
+ else
+ {
+ /* There are threads. Is this the one that caused the
+ core-dump? We'll claim it was the running thread. */
+ if (proc_info.sig != -1)
+ {
+ if (!make_bfd_asection (abfd, ".reg",
+ SEC_HAS_CONTENTS,
+ core_header.len,
+ (int) &proc_info - (int) & proc_info.hw_regs,
+ 2))
+ return NULL;
+ }
+ /* We always make one of these sections, for every thread. */
+ sprintf (secname, ".reg/%d", core_kernel_thread_id (abfd));
+ if (!make_bfd_asection (abfd, secname,
+ SEC_HAS_CONTENTS,
+ core_header.len,
+ (int) &proc_info - (int) & proc_info.hw_regs,
+ 2))
+ return NULL;
+ }
+ core_signal (abfd) = proc_info.sig;
+ if (bfd_seek (abfd, core_header.len, SEEK_CUR) != 0)
+ break;
+ good_sections++;
+ }
+ break;
+
+ case CORE_DATA:
+ case CORE_STACK:
+ case CORE_TEXT:
+ case CORE_MMF:
+ case CORE_SHM:
+ case CORE_ANON_SHMEM:
+ if (!make_bfd_asection (abfd, ".data",
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
+ core_header.len, core_header.addr, 2))
+ return NULL;
+
+ bfd_seek (abfd, core_header.len, SEEK_CUR);
+ good_sections++;
+ break;
+
+ case CORE_NONE:
+ /* Let's not punt if we encounter a section of unknown
+ type. Rather, let's make a note of it. If we later
+ see that there were also "good" sections, then we'll
+ declare that this a core file, but we'll also warn that
+ it may be incompatible with this gdb.
+ */
+ unknown_sections++;
+ break;
+
+ default: return 0; /*unrecognized core file type */
+ }
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ /* Were there sections of unknown type? If so, yet there were
+ at least some complete sections of known type, then, issue
+ a warning. Possibly the core file was generated on a version
+ of HP-UX that is incompatible with that for which this gdb was
+ built.
+ */
+ if ((unknown_sections > 0) && (good_sections > 0))
+ (*_bfd_error_handler)
+ ("%s appears to be a core file,\nbut contains unknown sections. It may have been created on an incompatible\nversion of HP-UX. As a result, some information may be unavailable.\n",
+ abfd->filename);
+
+ return abfd->xvec;
+}
+
+static char *
+hpux_core_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_command (abfd);
+}
+
+/* ARGSUSED */
+static int
+hpux_core_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_signal (abfd);
+}
+
+/* ARGSUSED */
+static boolean
+hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this point */
+}
+
+#define hpux_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define hpux_core_get_symtab _bfd_nosymbols_get_symtab
+#define hpux_core_print_symbol _bfd_nosymbols_print_symbol
+#define hpux_core_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define hpux_core_bfd_is_local_label_name \
+ _bfd_nosymbols_bfd_is_local_label_name
+#define hpux_core_get_lineno _bfd_nosymbols_get_lineno
+#define hpux_core_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define hpux_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define hpux_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define hpux_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target hpux_core_vec =
+ {
+ "hpux-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ hpux_core_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (hpux_core),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (hpux_core),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
diff --git a/bfd/i386aout.c b/bfd/i386aout.c
new file mode 100644
index 00000000000..d0b2cffef23
--- /dev/null
+++ b/bfd/i386aout.c
@@ -0,0 +1,91 @@
+/* BFD back-end for i386 a.out binaries.
+ Copyright 1990, 91, 92, 94, 95, 96, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* The only 386 aout system we have here is GO32 from DJ.
+ These numbers make BFD work with that. If your aout 386 system
+ doesn't work with these, we'll have to split them into different
+ files. Send me (sac@cygnus.com) the runes to make it work on your
+ system, and I'll stick it in for the next release. */
+
+#define N_HEADER_IN_TEXT(x) 0
+#define BYTES_IN_WORD 4
+
+#define N_TXTOFF(x) 0x20
+#define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
+
+#define N_TXTSIZE(x) ((x).a_text)
+#if 0
+#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
+#define NOSUBEXECB
+
+#endif
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE 0x400000
+#define DEFAULT_ARCH bfd_arch_i386
+
+#define MY(OP) CAT(i386aout_,OP)
+#define TARGETNAME "a.out-i386"
+#define NO_WRITE_HEADER_KLUDGE 1
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "libaout.h"
+
+/* Set the machine type correctly. */
+
+static boolean
+i386aout_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ N_SET_MACHTYPE (*execp, M_386);
+
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ WRITE_HEADERS (abfd, execp);
+
+ return true;
+}
+
+#define MY_write_object_contents i386aout_write_object_contents
+
+static boolean MY(set_sizes)();
+#define MY_backend_data &MY(backend_data)
+static CONST struct aout_backend_data MY(backend_data) = {
+ 0, /* zmagic contiguous */
+ 1, /* text incl header */
+ 0, /* entry is text address */
+ 0, /* exec_hdr_flags */
+ 0, /* text vma? */
+ MY(set_sizes),
+ 1, /* exec header not counted */
+ 0, /* add_dynamic_symbols */
+ 0, /* add_one_symbol */
+ 0, /* link_dynamic_object */
+ 0, /* write_dynamic_symbol */
+ 0, /* check_dynamic_reloc */
+ 0 /* finish_dynamic_link */
+};
+
+#include "aout-target.h"
diff --git a/bfd/i386bsd.c b/bfd/i386bsd.c
new file mode 100644
index 00000000000..2328fe3e9e8
--- /dev/null
+++ b/bfd/i386bsd.c
@@ -0,0 +1,46 @@
+/* BFD back-end for i386 a.out binaries under BSD.
+ Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This data should be correct for the format used under all the various
+ BSD ports for 386 machines. */
+
+#define BYTES_IN_WORD 4
+
+/* ZMAGIC files never have the header in the text. */
+#define N_HEADER_IN_TEXT(x) 0
+
+/* ZMAGIC files start at address 0. This does not apply to QMAGIC. */
+#define TEXT_START_ADDR 0
+#define N_SHARED_LIB(x) 0
+
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+#define DEFAULT_ARCH bfd_arch_i386
+#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
+
+#define MY(OP) CAT(i386bsd_,OP)
+#define TARGETNAME "a.out-i386-bsd"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#include "aout-target.h"
diff --git a/bfd/i386dynix.c b/bfd/i386dynix.c
new file mode 100644
index 00000000000..ff50a1450a1
--- /dev/null
+++ b/bfd/i386dynix.c
@@ -0,0 +1,80 @@
+/* BFD back-end for i386 a.out binaries under dynix.
+ Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This BFD is currently only tested with gdb, writing object files
+ may not work. */
+
+#define BYTES_IN_WORD 4
+
+#define TEXT_START_ADDR 4096
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+#include "aout/dynix3.h"
+
+#define DEFAULT_ARCH bfd_arch_i386
+#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
+
+#define MY(OP) CAT(i386dynix_,OP)
+#define TARGETNAME "a.out-i386-dynix"
+#define NAME(x,y) CAT3(i386dynix,_32_,y)
+#define ARCH_SIZE 32
+#define NAME_swap_exec_header_in NAME(i386dynix_32_,swap_exec_header_in)
+#define MY_get_section_contents aout_32_get_section_contents
+
+/* aoutx.h requires definitions for NMAGIC, BMAGIC and QMAGIC. */
+#define NMAGIC 0
+#define BMAGIC OMAGIC
+#define QMAGIC XMAGIC
+
+#include "aoutx.h"
+
+/* (Ab)use some fields in the internal exec header to be able to read
+ executables that contain shared data. */
+
+#define a_shdata a_tload
+#define a_shdrsize a_dload
+
+void
+i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
+{
+ struct external_exec *bytes = (struct external_exec *)raw_bytes;
+
+ /* The internal_exec structure has some fields that are unused in this
+ configuration (IE for i960), so ensure that all such uninitialized
+ fields are zero'd out. There are places where two of these structs
+ are memcmp'd, and thus the contents do matter. */
+ memset ((PTR) execp, 0, sizeof (struct internal_exec));
+ /* Now fill in fields in the execp, from the bytes in the raw data. */
+ execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_text = GET_WORD (abfd, bytes->e_text);
+ execp->a_data = GET_WORD (abfd, bytes->e_data);
+ execp->a_bss = GET_WORD (abfd, bytes->e_bss);
+ execp->a_syms = GET_WORD (abfd, bytes->e_syms);
+ execp->a_entry = GET_WORD (abfd, bytes->e_entry);
+ execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
+ execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
+ execp->a_shdata = GET_WORD (abfd, bytes->e_shdata);
+ execp->a_shdrsize = GET_WORD (abfd, bytes->e_shdrsize);
+}
+
+#include "aout-target.h"
diff --git a/bfd/i386freebsd.c b/bfd/i386freebsd.c
new file mode 100644
index 00000000000..7a6371b5df6
--- /dev/null
+++ b/bfd/i386freebsd.c
@@ -0,0 +1,33 @@
+/* BFD back-end for FreeBSD/386 a.out-ish binaries.
+ Copyright (C) 1990, 1991, 1992, 1996 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#undef TARGET_IS_BIG_ENDIAN_P
+
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+#define DEFAULT_ARCH bfd_arch_i386
+#define MACHTYPE_OK(mtype) ((mtype) == M_386_NETBSD || (mtype) == M_UNKNOWN)
+
+#define MY(OP) CAT(i386freebsd_,OP)
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-i386-freebsd"
+
+#include "freebsd.h"
diff --git a/bfd/i386linux.c b/bfd/i386linux.c
new file mode 100644
index 00000000000..804bdcd1c1a
--- /dev/null
+++ b/bfd/i386linux.c
@@ -0,0 +1,767 @@
+/* BFD back-end for linux flavored i386 a.out binaries.
+ Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_PAGE_SIZE 4096
+#define ZMAGIC_DISK_BLOCK_SIZE 1024
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define TEXT_START_ADDR 0x0
+#define N_SHARED_LIB(x) 0
+#define BYTES_IN_WORD 4
+
+#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#define DEFAULT_ARCH bfd_arch_i386
+#define MY(OP) CAT(i386linux_,OP)
+#define TARGETNAME "a.out-i386-linux"
+
+extern const bfd_target MY(vec);
+
+/* We always generate QMAGIC files in preference to ZMAGIC files. It
+ would be possible to make this a linker option, if that ever
+ becomes important. */
+
+static void MY_final_link_callback
+ PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+static boolean i386linux_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean i386linux_write_object_contents PARAMS ((bfd *));
+
+static boolean
+i386linux_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ obj_aout_subformat (abfd) = q_magic_format;
+ return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
+}
+
+#define MY_bfd_final_link i386linux_bfd_final_link
+
+/* Set the machine type correctly. */
+
+static boolean
+i386linux_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ N_SET_MACHTYPE (*execp, M_386);
+
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
+
+#define MY_write_object_contents i386linux_write_object_contents
+
+/* Code to link against Linux a.out shared libraries. */
+
+/* See if a symbol name is a reference to the global offset table. */
+
+#ifndef GOT_REF_PREFIX
+#define GOT_REF_PREFIX "__GOT_"
+#endif
+
+#define IS_GOT_SYM(name) \
+ (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
+
+/* See if a symbol name is a reference to the procedure linkage table. */
+
+#ifndef PLT_REF_PREFIX
+#define PLT_REF_PREFIX "__PLT_"
+#endif
+
+#define IS_PLT_SYM(name) \
+ (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
+
+/* This string is used to generate specialized error messages. */
+
+#ifndef NEEDS_SHRLIB
+#define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
+#endif
+
+/* This special symbol is a set vector that contains a list of
+ pointers to fixup tables. It will be present in any dynamicly
+ linked file. The linker generated fixup table should also be added
+ to the list, and it should always appear in the second slot (the
+ first one is a dummy with a magic number that is defined in
+ crt0.o). */
+
+#ifndef SHARABLE_CONFLICTS
+#define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
+#endif
+
+/* We keep a list of fixups. The terminology is a bit strange, but
+ each fixup contains two 32 bit numbers. A regular fixup contains
+ an address and a pointer, and at runtime we should store the
+ address at the location pointed to by the pointer. A builtin fixup
+ contains two pointers, and we should read the address using one
+ pointer and store it at the location pointed to by the other
+ pointer. Builtin fixups come into play when we have duplicate
+ __GOT__ symbols for the same variable. The builtin fixup will copy
+ the GOT pointer from one over into the other. */
+
+struct fixup
+{
+ struct fixup *next;
+ struct linux_link_hash_entry *h;
+ bfd_vma value;
+
+ /* Nonzero if this is a jump instruction that needs to be fixed,
+ zero if this is just a pointer */
+ char jump;
+
+ char builtin;
+};
+
+/* We don't need a special hash table entry structure, but we do need
+ to keep some information between linker passes, so we use a special
+ hash table. */
+
+struct linux_link_hash_entry
+{
+ struct aout_link_hash_entry root;
+};
+
+struct linux_link_hash_table
+{
+ struct aout_link_hash_table root;
+
+ /* First dynamic object found in link. */
+ bfd *dynobj;
+
+ /* Number of fixups. */
+ size_t fixup_count;
+
+ /* Number of builtin fixups. */
+ size_t local_builtins;
+
+ /* List of fixups. */
+ struct fixup *fixup_list;
+};
+
+static struct bfd_hash_entry *linux_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *linux_link_hash_table_create
+ PARAMS ((bfd *));
+static struct fixup *new_fixup
+ PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
+ bfd_vma, int));
+static boolean linux_link_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean linux_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
+ bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
+static boolean linux_tally_symbols
+ PARAMS ((struct linux_link_hash_entry *, PTR));
+static boolean linux_finish_dynamic_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Routine to create an entry in an Linux link hash table. */
+
+static struct bfd_hash_entry *
+linux_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct linux_link_hash_entry *) NULL)
+ ret = ((struct linux_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
+ if (ret == NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct linux_link_hash_entry *)
+ NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != NULL)
+ {
+ /* Set local fields; there aren't any. */
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a Linux link hash table. */
+
+static struct bfd_link_hash_table *
+linux_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct linux_link_hash_table *ret;
+
+ ret = ((struct linux_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
+ if (ret == (struct linux_link_hash_table *) NULL)
+ return (struct bfd_link_hash_table *) NULL;
+ if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
+ linux_link_hash_newfunc))
+ {
+ free (ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->dynobj = NULL;
+ ret->fixup_count = 0;
+ ret->local_builtins = 0;
+ ret->fixup_list = NULL;
+
+ return &ret->root.root;
+}
+
+/* Look up an entry in a Linux link hash table. */
+
+#define linux_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct linux_link_hash_entry *) \
+ aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
+ (follow)))
+
+/* Traverse a Linux link hash table. */
+
+#define linux_link_hash_traverse(table, func, info) \
+ (aout_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the Linux link hash table from the info structure. This is
+ just a cast. */
+
+#define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
+
+/* Store the information for a new fixup. */
+
+static struct fixup *
+new_fixup (info, h, value, builtin)
+ struct bfd_link_info *info;
+ struct linux_link_hash_entry *h;
+ bfd_vma value;
+ int builtin;
+{
+ struct fixup *f;
+
+ f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
+ sizeof (struct fixup));
+ if (f == NULL)
+ return f;
+ f->next = linux_hash_table (info)->fixup_list;
+ linux_hash_table (info)->fixup_list = f;
+ f->h = h;
+ f->value = value;
+ f->builtin = builtin;
+ f->jump = 0;
+ ++linux_hash_table (info)->fixup_count;
+ return f;
+}
+
+/* We come here once we realize that we are going to link to a shared
+ library. We need to create a special section that contains the
+ fixup table, and we ultimately need to add a pointer to this into
+ the set vector for SHARABLE_CONFLICTS. At this point we do not
+ know the size of the section, but that's OK - we just need to
+ create it for now. */
+
+static boolean
+linux_link_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+
+ /* Note that we set the SEC_IN_MEMORY flag. */
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ /* We choose to use the name ".linux-dynamic" for the fixup table.
+ Why not? */
+ s = bfd_make_section (abfd, ".linux-dynamic");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+ s->_raw_size = 0;
+ s->contents = 0;
+
+ return true;
+}
+
+/* Function to add a single symbol to the linker hash table. This is
+ a wrapper around _bfd_generic_link_add_one_symbol which handles the
+ tweaking needed for dynamic linking support. */
+
+static boolean
+linux_add_one_symbol (info, abfd, name, flags, section, value, string,
+ copy, collect, hashp)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ const char *string;
+ boolean copy;
+ boolean collect;
+ struct bfd_link_hash_entry **hashp;
+{
+ struct linux_link_hash_entry *h;
+ boolean insert;
+
+ /* Look up and see if we already have this symbol in the hash table.
+ If we do, and the defining entry is from a shared library, we
+ need to create the dynamic sections.
+
+ FIXME: What if abfd->xvec != info->hash->creator? We may want to
+ be able to link Linux a.out and ELF objects together, but serious
+ confusion is possible. */
+
+ insert = false;
+
+ if (! info->relocateable
+ && linux_hash_table (info)->dynobj == NULL
+ && strcmp (name, SHARABLE_CONFLICTS) == 0
+ && (flags & BSF_CONSTRUCTOR) != 0
+ && abfd->xvec == info->hash->creator)
+ {
+ if (! linux_link_create_dynamic_sections (abfd, info))
+ return false;
+ linux_hash_table (info)->dynobj = abfd;
+ insert = true;
+ }
+
+ if (bfd_is_abs_section (section)
+ && abfd->xvec == info->hash->creator)
+ {
+ h = linux_link_hash_lookup (linux_hash_table (info), name, false,
+ false, false);
+ if (h != NULL
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak))
+ {
+ struct fixup *f;
+
+ if (hashp != NULL)
+ *hashp = (struct bfd_link_hash_entry *) h;
+
+ f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
+ if (f == NULL)
+ return false;
+ f->jump = IS_PLT_SYM (name);
+
+ return true;
+ }
+ }
+
+ /* Do the usual procedure for adding a symbol. */
+ if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
+ value, string, copy, collect,
+ hashp))
+ return false;
+
+ /* Insert a pointer to our table in the set vector. The dynamic
+ linker requires this information */
+ if (insert)
+ {
+ asection *s;
+
+ /* Here we do our special thing to add the pointer to the
+ dynamic section in the SHARABLE_CONFLICTS set vector. */
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ BFD_ASSERT (s != NULL);
+
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
+ BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
+ return false;
+ }
+
+ return true;
+}
+
+/* We will crawl the hash table and come here for every global symbol.
+ We will examine each entry and see if there are indications that we
+ need to add a fixup. There are two possible cases - one is where
+ you have duplicate definitions of PLT or GOT symbols - these will
+ have already been caught and added as "builtin" fixups. If we find
+ that the corresponding non PLT/GOT symbol is also present, we
+ convert it to a regular fixup instead.
+
+ This function is called via linux_link_hash_traverse. */
+
+static boolean
+linux_tally_symbols (h, data)
+ struct linux_link_hash_entry *h;
+ PTR data;
+{
+ struct bfd_link_info *info = (struct bfd_link_info *) data;
+ struct fixup *f, *f1;
+ int is_plt;
+ struct linux_link_hash_entry *h1, *h2;
+ boolean exists;
+
+ if (h->root.root.type == bfd_link_hash_undefined
+ && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
+ sizeof NEEDS_SHRLIB - 1) == 0)
+ {
+ const char *name;
+ char *p;
+ char *alloc = NULL;
+
+ name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
+ p = strrchr (name, '_');
+ if (p != NULL)
+ alloc = (char *) bfd_malloc (strlen (name) + 1);
+
+ if (p == NULL || alloc == NULL)
+ (*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
+ name);
+ else
+ {
+ strcpy (alloc, name);
+ p = strrchr (alloc, '_');
+ *p++ = '\0';
+ (*_bfd_error_handler)
+ (_("Output file requires shared library `%s.so.%s'\n"),
+ alloc, p);
+ free (alloc);
+ }
+
+ abort ();
+ }
+
+ /* If this symbol is not a PLT/GOT, we do not even need to look at it */
+ is_plt = IS_PLT_SYM (h->root.root.root.string);
+
+ if (is_plt || IS_GOT_SYM (h->root.root.root.string))
+ {
+ /* Look up this symbol twice. Once just as a regular lookup,
+ and then again following all of the indirect links until we
+ reach a real symbol. */
+ h1 = linux_link_hash_lookup (linux_hash_table (info),
+ (h->root.root.root.string
+ + sizeof PLT_REF_PREFIX - 1),
+ false, false, true);
+ /* h2 does not follow indirect symbols. */
+ h2 = linux_link_hash_lookup (linux_hash_table (info),
+ (h->root.root.root.string
+ + sizeof PLT_REF_PREFIX - 1),
+ false, false, false);
+
+ /* The real symbol must exist but if it is also an ABS symbol,
+ there is no need to have a fixup. This is because they both
+ came from the same library. If on the other hand, we had to
+ use an indirect symbol to get to the real symbol, we add the
+ fixup anyway, since there are cases where these symbols come
+ from different shared libraries */
+ if (h1 != NULL
+ && (((h1->root.root.type == bfd_link_hash_defined
+ || h1->root.root.type == bfd_link_hash_defweak)
+ && ! bfd_is_abs_section (h1->root.root.u.def.section))
+ || h2->root.root.type == bfd_link_hash_indirect))
+ {
+ /* See if there is a "builtin" fixup already present
+ involving this symbol. If so, convert it to a regular
+ fixup. In the end, this relaxes some of the requirements
+ about the order of performing fixups. */
+ exists = false;
+ for (f1 = linux_hash_table (info)->fixup_list;
+ f1 != NULL;
+ f1 = f1->next)
+ {
+ if ((f1->h != h && f1->h != h1)
+ || (! f1->builtin && ! f1->jump))
+ continue;
+ if (f1->h == h1)
+ exists = true;
+ if (! exists
+ && bfd_is_abs_section (h->root.root.u.def.section))
+ {
+ f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
+ f->jump = is_plt;
+ }
+ f1->h = h1;
+ f1->jump = is_plt;
+ f1->builtin = 0;
+ exists = true;
+ }
+ if (! exists
+ && bfd_is_abs_section (h->root.root.u.def.section))
+ {
+ f = new_fixup (info, h1, h->root.root.u.def.value, 0);
+ if (f == NULL)
+ {
+ /* FIXME: No way to return error. */
+ abort ();
+ }
+ f->jump = is_plt;
+ }
+ }
+
+ /* Quick and dirty way of stripping these symbols from the
+ symtab. */
+ if (bfd_is_abs_section (h->root.root.u.def.section))
+ h->root.written = true;
+ }
+
+ return true;
+}
+
+/* This is called to set the size of the .linux-dynamic section is.
+ It is called by the Linux linker emulation before_allocation
+ routine. We have finished reading all of the input files, and now
+ we just scan the hash tables to find out how many additional fixups
+ are required. */
+
+boolean
+bfd_i386linux_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ struct fixup *f;
+ asection *s;
+
+ if (output_bfd->xvec != &MY(vec))
+ return true;
+
+ /* First find the fixups... */
+ linux_link_hash_traverse (linux_hash_table (info),
+ linux_tally_symbols,
+ (PTR) info);
+
+ /* If there are builtin fixups, leave room for a marker. This is
+ used by the dynamic linker so that it knows that all that follow
+ are builtin fixups instead of regular fixups. */
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (f->builtin)
+ {
+ ++linux_hash_table (info)->fixup_count;
+ ++linux_hash_table (info)->local_builtins;
+ break;
+ }
+ }
+
+ if (linux_hash_table (info)->dynobj == NULL)
+ {
+ if (linux_hash_table (info)->fixup_count > 0)
+ abort ();
+ return true;
+ }
+
+ /* Allocate memory for our fixup table. We will fill it in later. */
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ if (s != NULL)
+ {
+ s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ memset (s->contents, 0, (size_t) s->_raw_size);
+ }
+
+ return true;
+}
+
+/* We come here once we are ready to actually write the fixup table to
+ the output file. Scan the fixup tables and so forth and generate
+ the stuff we need. */
+
+static boolean
+linux_finish_dynamic_link (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ asection *s, *os, *is;
+ bfd_byte *fixup_table;
+ struct linux_link_hash_entry *h;
+ struct fixup *f;
+ unsigned int new_addr;
+ int section_offset;
+ unsigned int fixups_written;
+
+ if (linux_hash_table (info)->dynobj == NULL)
+ return true;
+
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ BFD_ASSERT (s != NULL);
+ os = s->output_section;
+ fixups_written = 0;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup table file offset: %x VMA: %x\n",
+ os->filepos + s->output_offset,
+ os->vma + s->output_offset);
+#endif
+
+ fixup_table = s->contents;
+ bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
+ fixup_table += 4;
+
+ /* Fill in fixup table. */
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (f->builtin)
+ continue;
+
+ if (f->h->root.root.type != bfd_link_hash_defined
+ && f->h->root.root.type != bfd_link_hash_defweak)
+ {
+ (*_bfd_error_handler)
+ (_("Symbol %s not defined for fixups\n"),
+ f->h->root.root.root.string);
+ continue;
+ }
+
+ is = f->h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = f->h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
+ new_addr, f->value);
+#endif
+
+ if (f->jump)
+ {
+ /* Relative address */
+ new_addr = new_addr - (f->value + 5);
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value + 1, fixup_table);
+ fixup_table += 4;
+ }
+ else
+ {
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value, fixup_table);
+ fixup_table += 4;
+ }
+ ++fixups_written;
+ }
+
+ if (linux_hash_table (info)->local_builtins != 0)
+ {
+ /* Special marker so we know to switch to the other type of fixup */
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (! f->builtin)
+ continue;
+
+ if (f->h->root.root.type != bfd_link_hash_defined
+ && f->h->root.root.type != bfd_link_hash_defweak)
+ {
+ (*_bfd_error_handler)
+ (_("Symbol %s not defined for fixups\n"),
+ f->h->root.root.root.string);
+ continue;
+ }
+
+ is = f->h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = f->h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
+ new_addr, f->value);
+#endif
+
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ }
+ }
+
+ if (linux_hash_table (info)->fixup_count != fixups_written)
+ {
+ (*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
+ while (linux_hash_table (info)->fixup_count > fixups_written)
+ {
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ }
+ }
+
+ h = linux_link_hash_lookup (linux_hash_table (info),
+ "__BUILTIN_FIXUPS__",
+ false, false, false);
+
+ if (h != NULL
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak))
+ {
+ is = h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Builtin fixup table at %x\n", new_addr);
+#endif
+
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ }
+ else
+ bfd_put_32 (output_bfd, 0, fixup_table);
+
+ if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
+ return false;
+
+ if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
+ != s->_raw_size)
+ return false;
+
+ return true;
+}
+
+#define MY_bfd_link_hash_table_create linux_link_hash_table_create
+#define MY_add_one_symbol linux_add_one_symbol
+#define MY_finish_dynamic_link linux_finish_dynamic_link
+
+#define MY_zmagic_contiguous 1
+
+#include "aout-target.h"
diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c
new file mode 100644
index 00000000000..1f0344ec000
--- /dev/null
+++ b/bfd/i386lynx.c
@@ -0,0 +1,562 @@
+/* BFD back-end for i386 a.out binaries under LynxOS.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#define N_SHARED_LIB(x) 0
+
+#define TEXT_START_ADDR 0
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_i386
+
+#define MY(OP) CAT(i386lynx_aout_,OP)
+#define TARGETNAME "a.out-i386-lynx"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#ifndef WRITE_HEADERS
+#define WRITE_HEADERS(abfd, execp) \
+ { \
+ bfd_size_type text_size; /* dummy vars */ \
+ file_ptr text_end; \
+ if (adata(abfd).magic == undecided_magic) \
+ NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
+ \
+ execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
+ execp->a_entry = bfd_get_start_address (abfd); \
+ \
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
+ \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
+ if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
+ != EXEC_BYTES_SIZE) \
+ return false; \
+ /* Now write out reloc info, followed by syms and strings */ \
+ \
+ if (bfd_get_symcount (abfd) != 0) \
+ { \
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
+ \
+ if (! NAME(aout,write_syms)(abfd)) return false; \
+ \
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
+ \
+ if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
+ return false; \
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return 0; \
+ \
+ if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ return false; \
+ } \
+ }
+#endif
+
+#include "libaout.h"
+#include "aout/aout64.h"
+
+#ifdef LYNX_CORE
+
+char *lynx_core_file_failing_command ();
+int lynx_core_file_failing_signal ();
+boolean lynx_core_file_matches_executable_p ();
+const bfd_target *lynx_core_file_p ();
+
+#define MY_core_file_failing_command lynx_core_file_failing_command
+#define MY_core_file_failing_signal lynx_core_file_failing_signal
+#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
+#define MY_core_file_p lynx_core_file_p
+
+#endif /* LYNX_CORE */
+
+
+#define KEEPIT udata.i
+
+extern reloc_howto_type aout_32_ext_howto_table[];
+extern reloc_howto_type aout_32_std_howto_table[];
+
+/* Standard reloc stuff */
+/* Output standard relocation information to a file in target byte order. */
+
+void
+NAME(lynx,swap_std_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
+{
+ int r_index;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ int r_extern;
+ unsigned int r_length;
+ int r_pcrel;
+ int r_baserel, r_jmptable, r_relative;
+ unsigned int r_addend;
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD (abfd, g->address, natptr->r_address);
+
+ r_length = g->howto->size; /* Size as a power of two */
+ r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
+ /* r_baserel, r_jmptable, r_relative??? FIXME-soon */
+ r_baserel = 0;
+ r_jmptable = 0;
+ r_relative = 0;
+
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+
+ /* name was clobbered by aout_write_syms to be symbol index */
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here
+ */
+
+
+ if (bfd_is_com_section (output_section)
+ || bfd_is_abs_section (output_section)
+ || bfd_is_und_section (output_section))
+ {
+ if (bfd_abs_section_ptr->symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+ r_extern = 1;
+ r_index = (*g->sym_ptr_ptr)->KEEPIT;
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd))
+ {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ (r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
+ | (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)
+ | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_BIG : 0)
+ | (r_relative ? RELOC_STD_BITS_RELATIVE_BIG : 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG);
+ }
+ else
+ {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
+ | (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
+ | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
+ | (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE);
+ }
+}
+
+
+/* Extended stuff */
+/* Output extended relocation information to a file in target byte order. */
+
+void
+NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ register struct reloc_ext_external *natptr;
+{
+ int r_index;
+ int r_extern;
+ unsigned int r_type;
+ unsigned int r_addend;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD (abfd, g->address, natptr->r_address);
+
+ r_type = (unsigned int) g->howto->type;
+
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here
+ */
+
+ if (bfd_is_com_section (output_section)
+ || bfd_is_abs_section (output_section)
+ || bfd_is_und_section (output_section))
+ {
+ if (bfd_abs_section_ptr->symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ r_extern = 1;
+ r_index = (*g->sym_ptr_ptr)->KEEPIT;
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd))
+ {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ (r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
+ | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG);
+ }
+ else
+ {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ (r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
+ | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
+ }
+
+ PUT_WORD (abfd, r_addend, natptr->r_addend);
+}
+
+/* BFD deals internally with all things based from the section they're
+ in. so, something in 10 bytes into a text section with a base of
+ 50 would have a symbol (.text+10) and know .text vma was 50.
+
+ Aout keeps all it's symbols based from zero, so the symbol would
+ contain 60. This macro subs the base of each section from the value
+ to give the true offset from the section */
+
+
+#define MOVE_ADDRESS(ad) \
+ if (r_extern) { \
+ /* undefined symbol */ \
+ cache_ptr->sym_ptr_ptr = symbols + r_index; \
+ cache_ptr->addend = ad; \
+ } else { \
+ /* defined, section relative. replace symbol with pointer to \
+ symbol which points to section */ \
+ switch (r_index) { \
+ case N_TEXT: \
+ case N_TEXT | N_EXT: \
+ cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr; \
+ cache_ptr->addend = ad - su->textsec->vma; \
+ break; \
+ case N_DATA: \
+ case N_DATA | N_EXT: \
+ cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr; \
+ cache_ptr->addend = ad - su->datasec->vma; \
+ break; \
+ case N_BSS: \
+ case N_BSS | N_EXT: \
+ cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr; \
+ cache_ptr->addend = ad - su->bsssec->vma; \
+ break; \
+ default: \
+ case N_ABS: \
+ case N_ABS | N_EXT: \
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; \
+ cache_ptr->addend = ad; \
+ break; \
+ } \
+ } \
+
+void
+NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct reloc_ext_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ int r_index;
+ int r_extern;
+ unsigned int r_type;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+
+ cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
+
+ r_index = bytes->r_index[1];
+ r_extern = (0 != (bytes->r_index[0] & RELOC_EXT_BITS_EXTERN_BIG));
+ r_type = (bytes->r_index[0] & RELOC_EXT_BITS_TYPE_BIG)
+ >> RELOC_EXT_BITS_TYPE_SH_BIG;
+
+ cache_ptr->howto = aout_32_ext_howto_table + r_type;
+ MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
+}
+
+void
+NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
+ bfd *abfd;
+ struct reloc_std_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
+ bfd_size_type symcount;
+{
+ int r_index;
+ int r_extern;
+ unsigned int r_length;
+ int r_pcrel;
+ int r_baserel, r_jmptable, r_relative;
+ struct aoutdata *su = &(abfd->tdata.aout_data->a);
+
+ cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+
+ r_index = bytes->r_index[1];
+ r_extern = (0 != (bytes->r_index[0] & RELOC_STD_BITS_EXTERN_BIG));
+ r_pcrel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_PCREL_BIG));
+ r_baserel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_BASEREL_BIG));
+ r_jmptable = (0 != (bytes->r_index[0] & RELOC_STD_BITS_JMPTABLE_BIG));
+ r_relative = (0 != (bytes->r_index[0] & RELOC_STD_BITS_RELATIVE_BIG));
+ r_length = (bytes->r_index[0] & RELOC_STD_BITS_LENGTH_BIG)
+ >> RELOC_STD_BITS_LENGTH_SH_BIG;
+
+ cache_ptr->howto = aout_32_std_howto_table + r_length + 4 * r_pcrel;
+ /* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */
+
+ MOVE_ADDRESS (0);
+}
+
+/* Reloc hackery */
+
+boolean
+NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ asymbol **symbols;
+{
+ unsigned int count;
+ bfd_size_type reloc_size;
+ PTR relocs;
+ arelent *reloc_cache;
+ size_t each_size;
+
+ if (asect->relocation)
+ return true;
+
+ if (asect->flags & SEC_CONSTRUCTOR)
+ return true;
+
+ if (asect == obj_datasec (abfd))
+ {
+ reloc_size = exec_hdr (abfd)->a_drsize;
+ goto doit;
+ }
+
+ if (asect == obj_textsec (abfd))
+ {
+ reloc_size = exec_hdr (abfd)->a_trsize;
+ goto doit;
+ }
+
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+
+doit:
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+ return false;
+ each_size = obj_reloc_entry_size (abfd);
+
+ count = reloc_size / each_size;
+
+
+ reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
+ if (!reloc_cache && count != 0)
+ return false;
+ memset (reloc_cache, 0, count * sizeof (arelent));
+
+ relocs = (PTR) bfd_alloc (abfd, reloc_size);
+ if (!relocs && reloc_size != 0)
+ {
+ free (reloc_cache);
+ return false;
+ }
+
+ if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ {
+ bfd_release (abfd, relocs);
+ free (reloc_cache);
+ return false;
+ }
+
+ if (each_size == RELOC_EXT_SIZE)
+ {
+ register struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
+ unsigned int counter = 0;
+ arelent *cache_ptr = reloc_cache;
+
+ for (; counter < count; counter++, rptr++, cache_ptr++)
+ {
+ NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
+ }
+ }
+ else
+ {
+ register struct reloc_std_external *rptr = (struct reloc_std_external *) relocs;
+ unsigned int counter = 0;
+ arelent *cache_ptr = reloc_cache;
+
+ for (; counter < count; counter++, rptr++, cache_ptr++)
+ {
+ NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
+ }
+
+ }
+
+ bfd_release (abfd, relocs);
+ asect->relocation = reloc_cache;
+ asect->reloc_count = count;
+ return true;
+}
+
+
+
+/* Write out a relocation section into an object file. */
+
+boolean
+NAME(lynx,squirt_out_relocs) (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ arelent **generic;
+ unsigned char *native, *natptr;
+ size_t each_size;
+
+ unsigned int count = section->reloc_count;
+ size_t natsize;
+
+ if (count == 0)
+ return true;
+
+ each_size = obj_reloc_entry_size (abfd);
+ natsize = each_size * count;
+ native = (unsigned char *) bfd_zalloc (abfd, natsize);
+ if (!native)
+ return false;
+
+ generic = section->orelocation;
+
+ if (each_size == RELOC_EXT_SIZE)
+ {
+ for (natptr = native;
+ count != 0;
+ --count, natptr += each_size, ++generic)
+ NAME(lynx,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *) natptr);
+ }
+ else
+ {
+ for (natptr = native;
+ count != 0;
+ --count, natptr += each_size, ++generic)
+ NAME(lynx,swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
+ }
+
+ if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ {
+ bfd_release (abfd, native);
+ return false;
+ }
+ bfd_release (abfd, native);
+
+ return true;
+}
+
+/* This is stupid. This function should be a boolean predicate */
+long
+NAME(lynx,canonicalize_reloc) (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count;
+
+ if (!(tblptr || NAME(lynx,slurp_reloc_table) (abfd, section, symbols)))
+ return -1;
+
+ if (section->flags & SEC_CONSTRUCTOR)
+ {
+ arelent_chain *chain = section->constructor_chain;
+ for (count = 0; count < section->reloc_count; count++)
+ {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+ }
+ else
+ {
+ tblptr = section->relocation;
+
+ for (count = 0; count++ < section->reloc_count;)
+ {
+ *relptr++ = tblptr++;
+ }
+ }
+ *relptr = 0;
+
+ return section->reloc_count;
+}
+
+#define MY_canonicalize_reloc NAME(lynx,canonicalize_reloc)
+
+#include "aout-target.h"
diff --git a/bfd/i386mach3.c b/bfd/i386mach3.c
new file mode 100644
index 00000000000..eff75824658
--- /dev/null
+++ b/bfd/i386mach3.c
@@ -0,0 +1,66 @@
+/* BFD back-end for i386 a.out binaries.
+ Copyright (C) 1990, 91, 93, 94, 95, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This is for Mach 3, which uses a.out, not Mach-O. */
+
+/* There is no magic number or anything which lets us distinguish this target
+ from i386aout or i386bsd. So this target is only useful if it is the
+ default target. */
+
+#define TARGET_PAGE_SIZE 1
+#define SEGMENT_SIZE 0x1000
+#define TEXT_START_ADDR 0x10000
+#define ARCH 32
+#define BYTES_IN_WORD 4
+/* This macro is only relevant when N_MAGIC(x) == ZMAGIC. */
+#define N_HEADER_IN_TEXT(x) 1
+
+#define N_TXTSIZE(x) ((x).a_text)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#define DEFAULT_ARCH bfd_arch_i386
+#define MY(OP) CAT(i386mach3_,OP)
+#define TARGETNAME "a.out-mach3"
+
+static boolean MY(set_sizes)();
+#define MY_backend_data &MY(backend_data)
+static CONST struct aout_backend_data MY(backend_data) = {
+ 0, /* zmagic contiguous */
+ 1, /* text incl header */
+ 0, /* entry is text address */
+ 0, /* exec_hdr_flags */
+ 0, /* text vma? */
+ MY(set_sizes),
+ 1, /* exec header not counted */
+ 0, /* add_dynamic_symbols */
+ 0, /* add_one_symbol */
+ 0, /* link_dynamic_object */
+ 0, /* write_dynamic_symbol */
+ 0, /* check_dynamic_reloc */
+ 0 /* finish_dynamic_link */
+};
+
+#include "aout-target.h"
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
new file mode 100644
index 00000000000..c6f24b2ac33
--- /dev/null
+++ b/bfd/i386msdos.c
@@ -0,0 +1,244 @@
+/* BFD back-end for MS-DOS executables.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Bryan Ford of the University of Utah.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#if 0
+struct exe_header
+{
+ unsigned short magic;
+ unsigned short bytes_in_last_page;
+ unsigned short npages; /* number of 512-byte "pages" including this header */
+ unsigned short nrelocs;
+ unsigned short header_paras; /* number of 16-byte paragraphs in header */
+ unsigned short reserved;
+ unsigned short load_switch;
+ unsigned short ss_ofs;
+ unsigned short sp;
+ unsigned short checksum;
+ unsigned short ip;
+ unsigned short cs_ofs;
+ unsigned short reloc_ofs;
+ unsigned short reserved2;
+ unsigned short something1;
+ unsigned short something2;
+ unsigned short something3;
+};
+#endif
+
+#define EXE_MAGIC 0x5a4d
+#define EXE_LOAD_HIGH 0x0000
+#define EXE_LOAD_LOW 0xffff
+#define EXE_PAGE_SIZE 512
+
+
+static int
+msdos_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+static boolean
+msdos_write_object_contents (abfd)
+ bfd *abfd;
+{
+ static char hdr[EXE_PAGE_SIZE];
+ file_ptr outfile_size = sizeof(hdr);
+ bfd_vma high_vma = 0;
+ asection *sec;
+
+ /* Find the total size of the program on disk and in memory. */
+ for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
+ {
+ if (bfd_get_section_size_before_reloc (sec) == 0)
+ continue;
+ if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+ {
+ bfd_vma sec_vma = bfd_get_section_vma (abfd, sec)
+ + bfd_get_section_size_before_reloc (sec);
+ if (sec_vma > high_vma)
+ high_vma = sec_vma;
+ }
+ if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
+ {
+ file_ptr sec_end = sizeof(hdr)
+ + bfd_get_section_vma (abfd, sec)
+ + bfd_get_section_size_before_reloc (sec);
+ if (sec_end > outfile_size)
+ outfile_size = sec_end;
+ }
+ }
+
+ /* Make sure the program isn't too big. */
+ if (high_vma > (bfd_vma)0xffff)
+ {
+ bfd_set_error(bfd_error_file_too_big);
+ return false;
+ }
+
+ /* constants */
+ bfd_h_put_16(abfd, EXE_MAGIC, &hdr[0]);
+ bfd_h_put_16(abfd, EXE_PAGE_SIZE / 16, &hdr[8]);
+ bfd_h_put_16(abfd, EXE_LOAD_LOW, &hdr[12]);
+ bfd_h_put_16(abfd, 0x3e, &hdr[24]);
+ bfd_h_put_16(abfd, 0x0001, &hdr[28]); /* XXX??? */
+ bfd_h_put_16(abfd, 0x30fb, &hdr[30]); /* XXX??? */
+ bfd_h_put_16(abfd, 0x726a, &hdr[32]); /* XXX??? */
+
+ /* bytes in last page (0 = full page) */
+ bfd_h_put_16(abfd, outfile_size & (EXE_PAGE_SIZE - 1), &hdr[2]);
+
+ /* number of pages */
+ bfd_h_put_16(abfd, (outfile_size + EXE_PAGE_SIZE - 1) / EXE_PAGE_SIZE,
+ &hdr[4]);
+
+ /* Set the initial stack pointer to the end of the bss.
+ The program's crt0 code must relocate it to a real stack. */
+ bfd_h_put_16(abfd, high_vma, &hdr[16]);
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_write (hdr, 1, sizeof(hdr), abfd) != sizeof(hdr))
+ return false;
+
+ return true;
+}
+
+static boolean
+msdos_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+
+ if (count == 0)
+ return true;
+
+ section->filepos = EXE_PAGE_SIZE + bfd_get_section_vma (abfd, section);
+
+ if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
+ {
+ if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
+ || bfd_write (location, 1, count, abfd) != count)
+ return false;
+ }
+
+ return true;
+}
+
+
+
+#define msdos_mkobject aout_32_mkobject
+#define msdos_make_empty_symbol aout_32_make_empty_symbol
+#define msdos_bfd_reloc_type_lookup aout_32_reloc_type_lookup
+
+#define msdos_close_and_cleanup _bfd_generic_close_and_cleanup
+#define msdos_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define msdos_new_section_hook _bfd_generic_new_section_hook
+#define msdos_get_section_contents _bfd_generic_get_section_contents
+#define msdos_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+#define msdos_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define msdos_bfd_relax_section bfd_generic_relax_section
+#define msdos_bfd_gc_sections bfd_generic_gc_sections
+#define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define msdos_bfd_final_link _bfd_generic_final_link
+#define msdos_bfd_link_split_section _bfd_generic_link_split_section
+#define msdos_set_arch_mach _bfd_generic_set_arch_mach
+
+#define msdos_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define msdos_get_symtab _bfd_nosymbols_get_symtab
+#define msdos_print_symbol _bfd_nosymbols_print_symbol
+#define msdos_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define msdos_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define msdos_get_lineno _bfd_nosymbols_get_lineno
+#define msdos_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define msdos_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define msdos_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define msdos_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+#define msdos_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
+#define msdos_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
+#define msdos_32_bfd_link_split_section _bfd_generic_link_split_section
+
+const bfd_target i386msdos_vec =
+{
+ "msdos", /* name */
+ bfd_target_msdos_flavour,
+ BFD_ENDIAN_LITTLE, /* target byte order */
+ BFD_ENDIAN_LITTLE, /* target headers byte order */
+ (EXEC_P), /* object flags */
+ (SEC_CODE | SEC_DATA | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ _bfd_dummy_target, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ msdos_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ msdos_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (msdos),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (msdos),
+ BFD_JUMP_TABLE_RELOCS (msdos),
+ BFD_JUMP_TABLE_WRITE (msdos),
+ BFD_JUMP_TABLE_LINK (msdos),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
+
+
diff --git a/bfd/i386netbsd.c b/bfd/i386netbsd.c
new file mode 100644
index 00000000000..327b6f94bbf
--- /dev/null
+++ b/bfd/i386netbsd.c
@@ -0,0 +1,33 @@
+/* BFD back-end for NetBSD/386 a.out-ish binaries.
+ Copyright (C) 1990, 91, 92, 94, 95, 96, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#undef TARGET_IS_BIG_ENDIAN_P
+
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+#define DEFAULT_ARCH bfd_arch_i386
+#define DEFAULT_MID M_386_NETBSD
+
+#define MY(OP) CAT(i386netbsd_,OP)
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-i386-netbsd"
+
+#include "netbsd.h"
diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c
new file mode 100644
index 00000000000..2a01f5b2f83
--- /dev/null
+++ b/bfd/i386os9k.c
@@ -0,0 +1,371 @@
+/* BFD back-end for os9000 i386 binaries.
+ Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+#include "os9k.h"
+
+static const bfd_target *os9k_callback PARAMS ((bfd *));
+
+/* Swaps the information in an executable header taken from a raw byte
+ stream memory image, into the internal exec_header structure. */
+boolean
+os9k_swap_exec_header_in (abfd, raw_bytes, execp)
+ bfd *abfd;
+ mh_com *raw_bytes;
+ struct internal_exec *execp;
+{
+ mh_com *bytes = (mh_com *) raw_bytes;
+ unsigned int dload, dmemsize, dmemstart;
+
+ /* Now fill in fields in the execp, from the bytes in the raw data. */
+ execp->a_info = bfd_h_get_16 (abfd, bytes->m_sync);
+ execp->a_syms = 0;
+ execp->a_entry = bfd_h_get_32 (abfd, bytes->m_exec);
+ execp->a_talign = 2;
+ execp->a_dalign = 2;
+ execp->a_balign = 2;
+
+ dload = bfd_h_get_32 (abfd, bytes->m_idata);
+ execp->a_data = dload + 8;
+
+ if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0
+ || (bfd_read (&dmemstart, sizeof (dmemstart), 1, abfd)
+ != sizeof (dmemstart))
+ || (bfd_read (&dmemsize, sizeof (dmemsize), 1, abfd)
+ != sizeof (dmemsize)))
+ return false;
+
+ execp->a_tload = 0;
+ execp->a_dload = bfd_h_get_32 (abfd, (unsigned char *) &dmemstart);
+ execp->a_text = dload - execp->a_tload;
+ execp->a_data = bfd_h_get_32 (abfd, (unsigned char *) &dmemsize);
+ execp->a_bss = bfd_h_get_32 (abfd, bytes->m_data) - execp->a_data;
+
+ execp->a_trsize = 0;
+ execp->a_drsize = 0;
+
+ return true;
+}
+
+#if 0
+/* Swaps the information in an internal exec header structure into the
+ supplied buffer ready for writing to disk. */
+
+PROTO (void, os9k_swap_exec_header_out,
+ (bfd * abfd,
+ struct internal_exec * execp,
+ struct mh_com * raw_bytes));
+void
+os9k_swap_exec_header_out (abfd, execp, raw_bytes)
+ bfd *abfd;
+ struct internal_exec *execp;
+ mh_com *raw_bytes;
+{
+ mh_com *bytes = (mh_com *) raw_bytes;
+
+ /* Now fill in fields in the raw data, from the fields in the exec struct. */
+ bfd_h_put_32 (abfd, execp->a_info, bytes->e_info);
+ bfd_h_put_32 (abfd, execp->a_text, bytes->e_text);
+ bfd_h_put_32 (abfd, execp->a_data, bytes->e_data);
+ bfd_h_put_32 (abfd, execp->a_bss, bytes->e_bss);
+ bfd_h_put_32 (abfd, execp->a_syms, bytes->e_syms);
+ bfd_h_put_32 (abfd, execp->a_entry, bytes->e_entry);
+ bfd_h_put_32 (abfd, execp->a_trsize, bytes->e_trsize);
+ bfd_h_put_32 (abfd, execp->a_drsize, bytes->e_drsize);
+ bfd_h_put_32 (abfd, execp->a_tload, bytes->e_tload);
+ bfd_h_put_32 (abfd, execp->a_dload, bytes->e_dload);
+ bytes->e_talign[0] = execp->a_talign;
+ bytes->e_dalign[0] = execp->a_dalign;
+ bytes->e_balign[0] = execp->a_balign;
+ bytes->e_relaxable[0] = execp->a_relaxable;
+}
+
+#endif /* 0 */
+
+static const bfd_target *
+os9k_object_p (abfd)
+ bfd *abfd;
+{
+ struct internal_exec anexec;
+ mh_com exec_bytes;
+
+ if (bfd_read ((PTR) & exec_bytes, MHCOM_BYTES_SIZE, 1, abfd)
+ != MHCOM_BYTES_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ anexec.a_info = bfd_h_get_16 (abfd, exec_bytes.m_sync);
+ if (N_BADMAG (anexec))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (! os9k_swap_exec_header_in (abfd, &exec_bytes, &anexec))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ return aout_32_some_aout_object_p (abfd, &anexec, os9k_callback);
+}
+
+
+/* Finish up the opening of a b.out file for reading. Fill in all the
+ fields that are not handled by common code. */
+
+static const bfd_target *
+os9k_callback (abfd)
+ bfd *abfd;
+{
+ struct internal_exec *execp = exec_hdr (abfd);
+ unsigned long bss_start;
+
+ /* Architecture and machine type */
+ bfd_set_arch_mach (abfd, bfd_arch_i386, 0);
+
+ /* The positions of the string table and symbol table. */
+ obj_str_filepos (abfd) = 0;
+ obj_sym_filepos (abfd) = 0;
+
+ /* The alignments of the sections */
+ obj_textsec (abfd)->alignment_power = execp->a_talign;
+ obj_datasec (abfd)->alignment_power = execp->a_dalign;
+ obj_bsssec (abfd)->alignment_power = execp->a_balign;
+
+ /* The starting addresses of the sections. */
+ obj_textsec (abfd)->vma = execp->a_tload;
+ obj_datasec (abfd)->vma = execp->a_dload;
+
+ /* And reload the sizes, since the aout module zaps them */
+ obj_textsec (abfd)->_raw_size = execp->a_text;
+
+ bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
+ obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
+
+ /* The file positions of the sections */
+ obj_textsec (abfd)->filepos = execp->a_entry;
+ obj_datasec (abfd)->filepos = execp->a_dload;
+
+ /* The file positions of the relocation info ***
+ obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
+ obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
+ */
+
+ adata (abfd).page_size = 1; /* Not applicable. */
+ adata (abfd).segment_size = 1;/* Not applicable. */
+ adata (abfd).exec_bytes_size = MHCOM_BYTES_SIZE;
+
+ return abfd->xvec;
+}
+
+#if 0
+struct bout_data_struct
+{
+ struct aoutdata a;
+ struct internal_exec e;
+};
+
+static boolean
+os9k_mkobject (abfd)
+ bfd *abfd;
+{
+ struct bout_data_struct *rawptr;
+
+ rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
+ if (rawptr == NULL)
+ return false;
+
+ abfd->tdata.bout_data = rawptr;
+ exec_hdr (abfd) = &rawptr->e;
+
+ obj_textsec (abfd) = (asection *) NULL;
+ obj_datasec (abfd) = (asection *) NULL;
+ obj_bsssec (abfd) = (asection *) NULL;
+
+ return true;
+}
+
+static boolean
+os9k_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec swapped_hdr;
+
+ if (! aout_32_make_sections (abfd))
+ return false;
+
+ exec_hdr (abfd)->a_info = BMAGIC;
+
+ exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
+ exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size;
+ exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_size;
+ exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
+ exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
+ exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
+ sizeof (struct relocation_info));
+ exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) *
+ sizeof (struct relocation_info));
+
+ exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
+ exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
+ exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power;
+
+ exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma;
+ exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma;
+
+ bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) & swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
+
+ /* Now write out reloc info, followed by syms and strings */
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ if (!aout_32_write_syms (abfd))
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr) (N_TROFF (*exec_hdr (abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd)))
+ return false;
+ if (bfd_seek (abfd, (file_ptr) (N_DROFF (*exec_hdr (abfd))), SEEK_SET)
+ != 0)
+ return false;
+
+ if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd)))
+ return false;
+ }
+ return true;
+}
+
+static boolean
+os9k_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ unsigned char *location;
+ file_ptr offset;
+ int count;
+{
+
+ if (abfd->output_has_begun == false)
+ { /* set by bfd.c handler */
+ if (! aout_32_make_sections (abfd))
+ return false;
+
+ obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
+ obj_datasec (abfd)->filepos = obj_textsec (abfd)->filepos
+ + obj_textsec (abfd)->_raw_size;
+
+ }
+ /* regardless, once we know what we're doing, we might as well get going */
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
+ return false;
+
+ if (count != 0)
+ {
+ return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false;
+ }
+ return true;
+}
+#endif /* 0 */
+
+static int
+os9k_sizeof_headers (ignore_abfd, ignore)
+ bfd *ignore_abfd;
+ boolean ignore;
+{
+ return sizeof (struct internal_exec);
+}
+
+
+/***********************************************************************/
+
+#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
+
+#define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+
+#define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define aout_32_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#define os9k_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define os9k_bfd_relax_section bfd_generic_relax_section
+#define os9k_bfd_gc_sections bfd_generic_gc_sections
+#define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define os9k_bfd_final_link _bfd_generic_final_link
+#define os9k_bfd_link_split_section _bfd_generic_link_split_section
+
+const bfd_target i386os9k_vec =
+{
+ "i386os9k", /* name */
+ bfd_target_os9k_flavour,
+ BFD_ENDIAN_LITTLE, /* data byte order is little */
+ BFD_ENDIAN_LITTLE, /* hdr byte order is little */
+ (HAS_RELOC | EXEC_P | WP_TEXT), /* object flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */
+ 0, /* symbol leading char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+ {_bfd_dummy_target, os9k_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, bfd_false, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, bfd_false, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (aout_32),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
+ BFD_JUMP_TABLE_SYMBOLS (aout_32),
+ BFD_JUMP_TABLE_RELOCS (aout_32),
+ BFD_JUMP_TABLE_WRITE (aout_32),
+ BFD_JUMP_TABLE_LINK (os9k),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0,
+};
diff --git a/bfd/ieee.c b/bfd/ieee.c
new file mode 100644
index 00000000000..126b136d337
--- /dev/null
+++ b/bfd/ieee.c
@@ -0,0 +1,3970 @@
+/* BFD back-end for ieee-695 objects.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+
+ Written by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define KEEPMINUSPCININST 0
+
+/* IEEE 695 format is a stream of records, which we parse using a simple one-
+ token (which is one byte in this lexicon) lookahead recursive decent
+ parser. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "ieee.h"
+#include "libieee.h"
+
+#include <ctype.h>
+
+static boolean ieee_write_byte PARAMS ((bfd *, int));
+static boolean ieee_write_2bytes PARAMS ((bfd *, int));
+static boolean ieee_write_int PARAMS ((bfd *, bfd_vma));
+static boolean ieee_write_id PARAMS ((bfd *, const char *));
+static boolean ieee_write_expression
+ PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int));
+static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma));
+static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma));
+static boolean ieee_write_section_part PARAMS ((bfd *));
+static boolean do_with_relocs PARAMS ((bfd *, asection *));
+static boolean do_as_repeat PARAMS ((bfd *, asection *));
+static boolean do_without_relocs PARAMS ((bfd *, asection *));
+static boolean ieee_write_external_part PARAMS ((bfd *));
+static boolean ieee_write_data_part PARAMS ((bfd *));
+static boolean ieee_write_debug_part PARAMS ((bfd *));
+static boolean ieee_write_me_part PARAMS ((bfd *));
+static boolean ieee_write_processor PARAMS ((bfd *));
+
+static boolean ieee_slurp_debug PARAMS ((bfd *));
+static boolean ieee_slurp_section_data PARAMS ((bfd *));
+
+/* Functions for writing to ieee files in the strange way that the
+ standard requires. */
+
+static boolean
+ieee_write_byte (abfd, barg)
+ bfd *abfd;
+ int barg;
+{
+ bfd_byte byte;
+
+ byte = barg;
+ if (bfd_write ((PTR) &byte, 1, 1, abfd) != 1)
+ return false;
+ return true;
+}
+
+static boolean
+ieee_write_2bytes (abfd, bytes)
+ bfd *abfd;
+ int bytes;
+{
+ bfd_byte buffer[2];
+
+ buffer[0] = bytes >> 8;
+ buffer[1] = bytes & 0xff;
+ if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
+ return false;
+ return true;
+}
+
+static boolean
+ieee_write_int (abfd, value)
+ bfd *abfd;
+ bfd_vma value;
+{
+ if (value <= 127)
+ {
+ if (! ieee_write_byte (abfd, (bfd_byte) value))
+ return false;
+ }
+ else
+ {
+ unsigned int length;
+
+ /* How many significant bytes ? */
+ /* FIXME FOR LONGER INTS */
+ if (value & 0xff000000)
+ length = 4;
+ else if (value & 0x00ff0000)
+ length = 3;
+ else if (value & 0x0000ff00)
+ length = 2;
+ else
+ length = 1;
+
+ if (! ieee_write_byte (abfd,
+ (bfd_byte) ((int) ieee_number_repeat_start_enum
+ + length)))
+ return false;
+ switch (length)
+ {
+ case 4:
+ if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24)))
+ return false;
+ /* Fall through. */
+ case 3:
+ if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16)))
+ return false;
+ /* Fall through. */
+ case 2:
+ if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8)))
+ return false;
+ /* Fall through. */
+ case 1:
+ if (! ieee_write_byte (abfd, (bfd_byte) (value)))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static boolean
+ieee_write_id (abfd, id)
+ bfd *abfd;
+ const char *id;
+{
+ size_t length = strlen (id);
+
+ if (length <= 127)
+ {
+ if (! ieee_write_byte (abfd, (bfd_byte) length))
+ return false;
+ }
+ else if (length < 255)
+ {
+ if (! ieee_write_byte (abfd, ieee_extension_length_1_enum)
+ || ! ieee_write_byte (abfd, (bfd_byte) length))
+ return false;
+ }
+ else if (length < 65535)
+ {
+ if (! ieee_write_byte (abfd, ieee_extension_length_2_enum)
+ || ! ieee_write_2bytes (abfd, (int) length))
+ return false;
+ }
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: string too long (%d chars, max 65535)"),
+ bfd_get_filename (abfd), length);
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ if (bfd_write ((PTR) id, 1, length, abfd) != length)
+ return false;
+ return true;
+}
+
+/***************************************************************************
+Functions for reading from ieee files in the strange way that the
+standard requires:
+*/
+
+#define this_byte(ieee) *((ieee)->input_p)
+#define next_byte(ieee) ((ieee)->input_p++)
+#define this_byte_and_next(ieee) (*((ieee)->input_p++))
+
+static unsigned short
+read_2bytes (ieee)
+ common_header_type *ieee;
+{
+ unsigned char c1 = this_byte_and_next (ieee);
+ unsigned char c2 = this_byte_and_next (ieee);
+ return (c1 << 8) | c2;
+}
+
+static void
+bfd_get_string (ieee, string, length)
+ common_header_type *ieee;
+ char *string;
+ size_t length;
+{
+ size_t i;
+ for (i = 0; i < length; i++)
+ {
+ string[i] = this_byte_and_next (ieee);
+ }
+}
+
+static char *
+read_id (ieee)
+ common_header_type *ieee;
+{
+ size_t length;
+ char *string;
+ length = this_byte_and_next (ieee);
+ if (length <= 0x7f)
+ {
+ /* Simple string of length 0 to 127 */
+ }
+ else if (length == 0xde)
+ {
+ /* Length is next byte, allowing 0..255 */
+ length = this_byte_and_next (ieee);
+ }
+ else if (length == 0xdf)
+ {
+ /* Length is next two bytes, allowing 0..65535 */
+ length = this_byte_and_next (ieee);
+ length = (length * 256) + this_byte_and_next (ieee);
+ }
+ /* Buy memory and read string */
+ string = bfd_alloc (ieee->abfd, length + 1);
+ if (!string)
+ return NULL;
+ bfd_get_string (ieee, string, length);
+ string[length] = 0;
+ return string;
+}
+
+static boolean
+ieee_write_expression (abfd, value, symbol, pcrel, index)
+ bfd *abfd;
+ bfd_vma value;
+ asymbol *symbol;
+ boolean pcrel;
+ unsigned int index;
+{
+ unsigned int term_count = 0;
+
+ if (value != 0)
+ {
+ if (! ieee_write_int (abfd, value))
+ return false;
+ term_count++;
+ }
+
+ if (bfd_is_com_section (symbol->section)
+ || bfd_is_und_section (symbol->section))
+ {
+ /* Def of a common symbol */
+ if (! ieee_write_byte (abfd, ieee_variable_X_enum)
+ || ! ieee_write_int (abfd, symbol->value))
+ return false;
+ term_count++;
+ }
+ else if (! bfd_is_abs_section (symbol->section))
+ {
+ /* Ref to defined symbol - */
+
+ if (symbol->flags & BSF_GLOBAL)
+ {
+ if (! ieee_write_byte (abfd, ieee_variable_I_enum)
+ || ! ieee_write_int (abfd, symbol->value))
+ return false;
+ term_count++;
+ }
+ else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
+ {
+ /* This is a reference to a defined local symbol. We can
+ easily do a local as a section+offset. */
+ if (! ieee_write_byte (abfd, ieee_variable_R_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (symbol->section->index
+ + IEEE_SECTION_NUMBER_BASE)))
+ return false;
+ term_count++;
+ if (symbol->value != 0)
+ {
+ if (! ieee_write_int (abfd, symbol->value))
+ return false;
+ term_count++;
+ }
+ }
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: unrecognized symbol `%s' flags 0x%x"),
+ bfd_get_filename (abfd), bfd_asymbol_name (symbol),
+ symbol->flags);
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+ }
+
+ if (pcrel)
+ {
+ /* subtract the pc from here by asking for PC of this section*/
+ if (! ieee_write_byte (abfd, ieee_variable_P_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE))
+ || ! ieee_write_byte (abfd, ieee_function_minus_enum))
+ return false;
+ }
+
+ /* Handle the degenerate case of a 0 address. */
+ if (term_count == 0)
+ {
+ if (! ieee_write_int (abfd, 0))
+ return false;
+ }
+
+ while (term_count > 1)
+ {
+ if (! ieee_write_byte (abfd, ieee_function_plus_enum))
+ return false;
+ term_count--;
+ }
+
+ return true;
+}
+
+/*****************************************************************************/
+
+/*
+writes any integer into the buffer supplied and always takes 5 bytes
+*/
+static void
+ieee_write_int5 (buffer, value)
+ bfd_byte *buffer;
+ bfd_vma value;
+{
+ buffer[0] = (bfd_byte) ieee_number_repeat_4_enum;
+ buffer[1] = (value >> 24) & 0xff;
+ buffer[2] = (value >> 16) & 0xff;
+ buffer[3] = (value >> 8) & 0xff;
+ buffer[4] = (value >> 0) & 0xff;
+}
+
+static boolean
+ieee_write_int5_out (abfd, value)
+ bfd *abfd;
+ bfd_vma value;
+{
+ bfd_byte b[5];
+
+ ieee_write_int5 (b, value);
+ if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
+ return false;
+ return true;
+}
+
+static boolean
+parse_int (ieee, value_ptr)
+ common_header_type *ieee;
+ bfd_vma *value_ptr;
+{
+ int value = this_byte (ieee);
+ int result;
+ if (value >= 0 && value <= 127)
+ {
+ *value_ptr = value;
+ next_byte (ieee);
+ return true;
+ }
+ else if (value >= 0x80 && value <= 0x88)
+ {
+ unsigned int count = value & 0xf;
+ result = 0;
+ next_byte (ieee);
+ while (count)
+ {
+ result = (result << 8) | this_byte_and_next (ieee);
+ count--;
+ }
+ *value_ptr = result;
+ return true;
+ }
+ return false;
+}
+
+static int
+parse_i (ieee, ok)
+ common_header_type *ieee;
+ boolean *ok;
+{
+ bfd_vma x;
+ *ok = parse_int (ieee, &x);
+ return x;
+}
+
+static bfd_vma
+must_parse_int (ieee)
+ common_header_type *ieee;
+{
+ bfd_vma result;
+ BFD_ASSERT (parse_int (ieee, &result) == true);
+ return result;
+}
+
+typedef struct
+{
+ bfd_vma value;
+ asection *section;
+ ieee_symbol_index_type symbol;
+} ieee_value_type;
+
+
+#if KEEPMINUSPCININST
+
+#define SRC_MASK(arg) arg
+#define PCREL_OFFSET false
+
+#else
+
+#define SRC_MASK(arg) 0
+#define PCREL_OFFSET true
+
+#endif
+
+static reloc_howto_type abs32_howto =
+ HOWTO (1,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ 0,
+ "abs32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ false);
+
+static reloc_howto_type abs16_howto =
+ HOWTO (1,
+ 0,
+ 1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ 0,
+ "abs16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ false);
+
+static reloc_howto_type abs8_howto =
+ HOWTO (1,
+ 0,
+ 0,
+ 8,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ 0,
+ "abs8",
+ true,
+ 0x000000ff,
+ 0x000000ff,
+ false);
+
+static reloc_howto_type rel32_howto =
+ HOWTO (1,
+ 0,
+ 2,
+ 32,
+ true,
+ 0,
+ complain_overflow_signed,
+ 0,
+ "rel32",
+ true,
+ SRC_MASK (0xffffffff),
+ 0xffffffff,
+ PCREL_OFFSET);
+
+static reloc_howto_type rel16_howto =
+ HOWTO (1,
+ 0,
+ 1,
+ 16,
+ true,
+ 0,
+ complain_overflow_signed,
+ 0,
+ "rel16",
+ true,
+ SRC_MASK (0x0000ffff),
+ 0x0000ffff,
+ PCREL_OFFSET);
+
+static reloc_howto_type rel8_howto =
+ HOWTO (1,
+ 0,
+ 0,
+ 8,
+ true,
+ 0,
+ complain_overflow_signed,
+ 0,
+ "rel8",
+ true,
+ SRC_MASK (0x000000ff),
+ 0x000000ff,
+ PCREL_OFFSET);
+
+static ieee_symbol_index_type NOSYMBOL = {0, 0};
+
+static void
+parse_expression (ieee, value, symbol, pcrel, extra, section)
+ ieee_data_type *ieee;
+ bfd_vma *value;
+ ieee_symbol_index_type *symbol;
+ boolean *pcrel;
+ unsigned int *extra;
+ asection **section;
+
+{
+#define POS sp[1]
+#define TOS sp[0]
+#define NOS sp[-1]
+#define INC sp++;
+#define DEC sp--;
+
+ boolean loop = true;
+ ieee_value_type stack[10];
+
+ /* The stack pointer always points to the next unused location */
+#define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
+#define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
+ ieee_value_type *sp = stack;
+
+ while (loop)
+ {
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_variable_P_enum:
+ /* P variable, current program counter for section n */
+ {
+ int section_n;
+ next_byte (&(ieee->h));
+ *pcrel = true;
+ section_n = must_parse_int (&(ieee->h));
+ PUSH (NOSYMBOL, bfd_abs_section_ptr, 0);
+ break;
+ }
+ case ieee_variable_L_enum:
+ /* L variable address of section N */
+ next_byte (&(ieee->h));
+ PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
+ break;
+ case ieee_variable_R_enum:
+ /* R variable, logical address of section module */
+ /* FIXME, this should be different to L */
+ next_byte (&(ieee->h));
+ PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
+ break;
+ case ieee_variable_S_enum:
+ /* S variable, size in MAUS of section module */
+ next_byte (&(ieee->h));
+ PUSH (NOSYMBOL,
+ 0,
+ ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size);
+ break;
+ case ieee_variable_I_enum:
+ /* Push the address of variable n */
+ {
+ ieee_symbol_index_type sy;
+ next_byte (&(ieee->h));
+ sy.index = (int) must_parse_int (&(ieee->h));
+ sy.letter = 'I';
+
+ PUSH (sy, bfd_abs_section_ptr, 0);
+ }
+ break;
+ case ieee_variable_X_enum:
+ /* Push the address of external variable n */
+ {
+ ieee_symbol_index_type sy;
+ next_byte (&(ieee->h));
+ sy.index = (int) (must_parse_int (&(ieee->h)));
+ sy.letter = 'X';
+
+ PUSH (sy, bfd_und_section_ptr, 0);
+ }
+ break;
+ case ieee_function_minus_enum:
+ {
+ bfd_vma value1, value2;
+ asection *section1, *section_dummy;
+ ieee_symbol_index_type sy;
+ next_byte (&(ieee->h));
+
+ POP (sy, section1, value1);
+ POP (sy, section_dummy, value2);
+ PUSH (sy, section1 ? section1 : section_dummy, value2 - value1);
+ }
+ break;
+ case ieee_function_plus_enum:
+ {
+ bfd_vma value1, value2;
+ asection *section1;
+ asection *section2;
+ ieee_symbol_index_type sy1;
+ ieee_symbol_index_type sy2;
+ next_byte (&(ieee->h));
+
+ POP (sy1, section1, value1);
+ POP (sy2, section2, value2);
+ PUSH (sy1.letter ? sy1 : sy2,
+ bfd_is_abs_section (section1) ? section2 : section1,
+ value1 + value2);
+ }
+ break;
+ default:
+ {
+ bfd_vma va;
+ BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum
+ || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum);
+ if (parse_int (&(ieee->h), &va))
+ {
+ PUSH (NOSYMBOL, bfd_abs_section_ptr, va);
+ }
+ else
+ {
+ /*
+ Thats all that we can understand. As far as I can see
+ there is a bug in the Microtec IEEE output which I'm
+ using to scan, whereby the comma operator is omitted
+ sometimes in an expression, giving expressions with too
+ many terms. We can tell if that's the case by ensuring
+ that sp == stack here. If not, then we've pushed
+ something too far, so we keep adding. */
+
+ while (sp != stack + 1)
+ {
+ asection *section1;
+ ieee_symbol_index_type sy1;
+ POP (sy1, section1, *extra);
+ }
+ {
+ asection *dummy;
+
+ POP (*symbol, dummy, *value);
+ if (section)
+ *section = dummy;
+ }
+
+ loop = false;
+ }
+ }
+ }
+ }
+}
+
+
+#define ieee_seek(abfd, offset) \
+ IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
+
+#define ieee_pos(abfd) \
+ (IEEE_DATA(abfd)->h.input_p - IEEE_DATA(abfd)->h.first_byte)
+
+static unsigned int last_index;
+static char last_type; /* is the index for an X or a D */
+
+static ieee_symbol_type *
+get_symbol (abfd,
+ ieee,
+ last_symbol,
+ symbol_count,
+ pptr,
+ max_index,
+ this_type
+)
+ bfd *abfd;
+ ieee_data_type *ieee;
+ ieee_symbol_type *last_symbol;
+ unsigned int *symbol_count;
+ ieee_symbol_type ***pptr;
+ unsigned int *max_index;
+ char this_type
+ ;
+{
+ /* Need a new symbol */
+ unsigned int new_index = must_parse_int (&(ieee->h));
+ if (new_index != last_index || this_type != last_type)
+ {
+ ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
+ sizeof (ieee_symbol_type));
+ if (!new_symbol)
+ return NULL;
+
+ new_symbol->index = new_index;
+ last_index = new_index;
+ (*symbol_count)++;
+ **pptr = new_symbol;
+ *pptr = &new_symbol->next;
+ if (new_index > *max_index)
+ {
+ *max_index = new_index;
+ }
+ last_type = this_type;
+ new_symbol->symbol.section = bfd_abs_section_ptr;
+ return new_symbol;
+ }
+ return last_symbol;
+}
+
+static boolean
+ieee_slurp_external_symbols (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ file_ptr offset = ieee->w.r.external_part;
+
+ ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols;
+ ieee_symbol_type **prev_reference_ptr = &ieee->external_reference;
+ ieee_symbol_type *symbol = (ieee_symbol_type *) NULL;
+ unsigned int symbol_count = 0;
+ boolean loop = true;
+ last_index = 0xffffff;
+ ieee->symbol_table_full = true;
+
+ ieee_seek (abfd, offset);
+
+ while (loop)
+ {
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_nn_record:
+ next_byte (&(ieee->h));
+
+ symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
+ &prev_symbols_ptr,
+ &ieee->external_symbol_max_index, 'I');
+ if (symbol == NULL)
+ return false;
+
+ symbol->symbol.the_bfd = abfd;
+ symbol->symbol.name = read_id (&(ieee->h));
+ symbol->symbol.udata.p = (PTR) NULL;
+ symbol->symbol.flags = BSF_NO_FLAGS;
+ break;
+ case ieee_external_symbol_enum:
+ next_byte (&(ieee->h));
+
+ symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
+ &prev_symbols_ptr,
+ &ieee->external_symbol_max_index, 'D');
+ if (symbol == NULL)
+ return false;
+
+ BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
+
+ symbol->symbol.the_bfd = abfd;
+ symbol->symbol.name = read_id (&(ieee->h));
+ symbol->symbol.udata.p = (PTR) NULL;
+ symbol->symbol.flags = BSF_NO_FLAGS;
+ break;
+ case ieee_attribute_record_enum >> 8:
+ {
+ unsigned int symbol_name_index;
+ unsigned int symbol_type_index;
+ unsigned int symbol_attribute_def;
+ bfd_vma value;
+ switch (read_2bytes (ieee))
+ {
+ case ieee_attribute_record_enum:
+ symbol_name_index = must_parse_int (&(ieee->h));
+ symbol_type_index = must_parse_int (&(ieee->h));
+ symbol_attribute_def = must_parse_int (&(ieee->h));
+ switch (symbol_attribute_def)
+ {
+ case 8:
+ case 19:
+ parse_int (&ieee->h, &value);
+ break;
+ default:
+ (*_bfd_error_handler)
+ (_("%s: unimplemented ATI record %u for symbol %u"),
+ bfd_get_filename (abfd), symbol_attribute_def,
+ symbol_name_index);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ break;
+ }
+ break;
+ case ieee_external_reference_info_record_enum:
+ /* Skip over ATX record. */
+ parse_int (&(ieee->h), &value);
+ parse_int (&(ieee->h), &value);
+ parse_int (&(ieee->h), &value);
+ parse_int (&(ieee->h), &value);
+ break;
+ case ieee_atn_record_enum:
+ /* We may get call optimization information here,
+ which we just ignore. The format is
+ {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs} */
+ parse_int (&ieee->h, &value);
+ parse_int (&ieee->h, &value);
+ parse_int (&ieee->h, &value);
+ if (value != 0x3f)
+ {
+ (*_bfd_error_handler)
+ (_("%s: unexpected ATN type %d in external part"),
+ bfd_get_filename (abfd), (int) value);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ parse_int (&ieee->h, &value);
+ parse_int (&ieee->h, &value);
+ while (value > 0)
+ {
+ bfd_vma val1;
+
+ --value;
+
+ switch (read_2bytes (ieee))
+ {
+ case ieee_asn_record_enum:
+ parse_int (&ieee->h, &val1);
+ parse_int (&ieee->h, &val1);
+ break;
+
+ default:
+ (*_bfd_error_handler)
+ (_("%s: unexpected type after ATN"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+ }
+ }
+ break;
+ case ieee_value_record_enum >> 8:
+ {
+ unsigned int symbol_name_index;
+ ieee_symbol_index_type symbol_ignore;
+ boolean pcrel_ignore;
+ unsigned int extra;
+ next_byte (&(ieee->h));
+ next_byte (&(ieee->h));
+
+ symbol_name_index = must_parse_int (&(ieee->h));
+ parse_expression (ieee,
+ &symbol->symbol.value,
+ &symbol_ignore,
+ &pcrel_ignore,
+ &extra,
+ &symbol->symbol.section);
+
+ /* Fully linked IEEE-695 files tend to give every symbol
+ an absolute value. Try to convert that back into a
+ section relative value. FIXME: This won't always to
+ the right thing. */
+ if (bfd_is_abs_section (symbol->symbol.section)
+ && (abfd->flags & HAS_RELOC) == 0)
+ {
+ bfd_vma val;
+ asection *s;
+
+ val = symbol->symbol.value;
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ if (val >= s->vma && val < s->vma + s->_raw_size)
+ {
+ symbol->symbol.section = s;
+ symbol->symbol.value -= s->vma;
+ break;
+ }
+ }
+ }
+
+ symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
+
+ }
+ break;
+ case ieee_weak_external_reference_enum:
+ {
+ bfd_vma size;
+ bfd_vma value;
+ next_byte (&(ieee->h));
+ /* Throw away the external reference index */
+ (void) must_parse_int (&(ieee->h));
+ /* Fetch the default size if not resolved */
+ size = must_parse_int (&(ieee->h));
+ /* Fetch the defautlt value if available */
+ if (parse_int (&(ieee->h), &value) == false)
+ {
+ value = 0;
+ }
+ /* This turns into a common */
+ symbol->symbol.section = bfd_com_section_ptr;
+ symbol->symbol.value = size;
+ }
+ break;
+
+ case ieee_external_reference_enum:
+ next_byte (&(ieee->h));
+
+ symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
+ &prev_reference_ptr,
+ &ieee->external_reference_max_index, 'X');
+ if (symbol == NULL)
+ return false;
+
+ symbol->symbol.the_bfd = abfd;
+ symbol->symbol.name = read_id (&(ieee->h));
+ symbol->symbol.udata.p = (PTR) NULL;
+ symbol->symbol.section = bfd_und_section_ptr;
+ symbol->symbol.value = (bfd_vma) 0;
+ symbol->symbol.flags = 0;
+
+ BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
+ break;
+
+ default:
+ loop = false;
+ }
+ }
+
+ if (ieee->external_symbol_max_index != 0)
+ {
+ ieee->external_symbol_count =
+ ieee->external_symbol_max_index -
+ ieee->external_symbol_min_index + 1;
+ }
+ else
+ {
+ ieee->external_symbol_count = 0;
+ }
+
+ if (ieee->external_reference_max_index != 0)
+ {
+ ieee->external_reference_count =
+ ieee->external_reference_max_index -
+ ieee->external_reference_min_index + 1;
+ }
+ else
+ {
+ ieee->external_reference_count = 0;
+ }
+
+ abfd->symcount =
+ ieee->external_reference_count + ieee->external_symbol_count;
+
+ if (symbol_count != abfd->symcount)
+ {
+ /* There are gaps in the table -- */
+ ieee->symbol_table_full = false;
+ }
+
+ *prev_symbols_ptr = (ieee_symbol_type *) NULL;
+ *prev_reference_ptr = (ieee_symbol_type *) NULL;
+
+ return true;
+}
+
+static boolean
+ieee_slurp_symbol_table (abfd)
+ bfd *abfd;
+{
+ if (IEEE_DATA (abfd)->read_symbols == false)
+ {
+ if (! ieee_slurp_external_symbols (abfd))
+ return false;
+ IEEE_DATA (abfd)->read_symbols = true;
+ }
+ return true;
+}
+
+long
+ieee_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ if (! ieee_slurp_symbol_table (abfd))
+ return -1;
+
+ return (abfd->symcount != 0) ?
+ (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;
+}
+
+/*
+Move from our internal lists to the canon table, and insert in
+symbol index order
+*/
+
+extern const bfd_target ieee_vec;
+
+long
+ieee_get_symtab (abfd, location)
+ bfd *abfd;
+ asymbol **location;
+{
+ ieee_symbol_type *symp;
+ static bfd dummy_bfd;
+ static asymbol empty_symbol =
+ /* the_bfd, name, value, attr, section */
+ {&dummy_bfd, " ieee empty", (symvalue) 0, BSF_DEBUGGING, bfd_abs_section_ptr};
+
+ if (abfd->symcount)
+ {
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ dummy_bfd.xvec = &ieee_vec;
+ if (! ieee_slurp_symbol_table (abfd))
+ return -1;
+
+ if (ieee->symbol_table_full == false)
+ {
+ /* Arrgh - there are gaps in the table, run through and fill them */
+ /* up with pointers to a null place */
+ unsigned int i;
+ for (i = 0; i < abfd->symcount; i++)
+ {
+ location[i] = &empty_symbol;
+ }
+ }
+
+ ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;
+ for (symp = IEEE_DATA (abfd)->external_symbols;
+ symp != (ieee_symbol_type *) NULL;
+ symp = symp->next)
+ {
+ /* Place into table at correct index locations */
+ location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
+ }
+
+ /* The external refs are indexed in a bit */
+ ieee->external_reference_base_offset =
+ -ieee->external_reference_min_index + ieee->external_symbol_count;
+
+ for (symp = IEEE_DATA (abfd)->external_reference;
+ symp != (ieee_symbol_type *) NULL;
+ symp = symp->next)
+ {
+ location[symp->index + ieee->external_reference_base_offset] =
+ &symp->symbol;
+
+ }
+ }
+ if (abfd->symcount)
+ {
+ location[abfd->symcount] = (asymbol *) NULL;
+ }
+ return abfd->symcount;
+}
+
+static asection *
+get_section_entry (abfd, ieee, index)
+ bfd *abfd;
+ ieee_data_type *ieee;
+ unsigned int index;
+{
+ if (index >= ieee->section_table_size)
+ {
+ unsigned int c, i;
+ asection **n;
+
+ c = ieee->section_table_size;
+ if (c == 0)
+ c = 20;
+ while (c <= index)
+ c *= 2;
+
+ n = ((asection **)
+ bfd_realloc (ieee->section_table, c * sizeof (asection *)));
+ if (n == NULL)
+ return NULL;
+
+ for (i = ieee->section_table_size; i < c; i++)
+ n[i] = NULL;
+
+ ieee->section_table = n;
+ ieee->section_table_size = c;
+ }
+
+ if (ieee->section_table[index] == (asection *) NULL)
+ {
+ char *tmp = bfd_alloc (abfd, 11);
+ asection *section;
+
+ if (!tmp)
+ return NULL;
+ sprintf (tmp, " fsec%4d", index);
+ section = bfd_make_section (abfd, tmp);
+ ieee->section_table[index] = section;
+ section->flags = SEC_NO_FLAGS;
+ section->target_index = index;
+ ieee->section_table[index] = section;
+ }
+ return ieee->section_table[index];
+}
+
+static void
+ieee_slurp_sections (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ file_ptr offset = ieee->w.r.section_part;
+ asection *section = (asection *) NULL;
+ char *name;
+
+ if (offset != 0)
+ {
+ bfd_byte section_type[3];
+ ieee_seek (abfd, offset);
+ while (true)
+ {
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_section_type_enum:
+ {
+ unsigned int section_index;
+ next_byte (&(ieee->h));
+ section_index = must_parse_int (&(ieee->h));
+
+ section = get_section_entry (abfd, ieee, section_index);
+
+ section_type[0] = this_byte_and_next (&(ieee->h));
+
+ /* Set minimal section attributes. Attributes are
+ extended later, based on section contents. */
+
+ switch (section_type[0])
+ {
+ case 0xC1:
+ /* Normal attributes for absolute sections */
+ section_type[1] = this_byte (&(ieee->h));
+ section->flags = SEC_ALLOC;
+ switch (section_type[1])
+ {
+ case 0xD3: /* AS Absolute section attributes */
+ next_byte (&(ieee->h));
+ section_type[2] = this_byte (&(ieee->h));
+ switch (section_type[2])
+ {
+ case 0xD0:
+ /* Normal code */
+ next_byte (&(ieee->h));
+ section->flags |= SEC_CODE;
+ break;
+ case 0xC4:
+ /* Normal data */
+ next_byte (&(ieee->h));
+ section->flags |= SEC_DATA;
+ break;
+ case 0xD2:
+ next_byte (&(ieee->h));
+ /* Normal rom data */
+ section->flags |= SEC_ROM | SEC_DATA;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case 0xC3: /* Named relocatable sections (type C) */
+ section_type[1] = this_byte (&(ieee->h));
+ section->flags = SEC_ALLOC;
+ switch (section_type[1])
+ {
+ case 0xD0: /* Normal code (CP) */
+ next_byte (&(ieee->h));
+ section->flags |= SEC_CODE;
+ break;
+ case 0xC4: /* Normal data (CD) */
+ next_byte (&(ieee->h));
+ section->flags |= SEC_DATA;
+ break;
+ case 0xD2: /* Normal rom data (CR) */
+ next_byte (&(ieee->h));
+ section->flags |= SEC_ROM | SEC_DATA;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Read section name, use it if non empty. */
+ name = read_id (&ieee->h);
+ if (name[0])
+ section->name = name;
+
+ /* Skip these fields, which we don't care about */
+ {
+ bfd_vma parent, brother, context;
+ parse_int (&(ieee->h), &parent);
+ parse_int (&(ieee->h), &brother);
+ parse_int (&(ieee->h), &context);
+ }
+ }
+ break;
+ case ieee_section_alignment_enum:
+ {
+ unsigned int section_index;
+ bfd_vma value;
+ asection *section;
+ next_byte (&(ieee->h));
+ section_index = must_parse_int (&ieee->h);
+ section = get_section_entry (abfd, ieee, section_index);
+ if (section_index > ieee->section_count)
+ {
+ ieee->section_count = section_index;
+ }
+ section->alignment_power =
+ bfd_log2 (must_parse_int (&ieee->h));
+ (void) parse_int (&(ieee->h), &value);
+ }
+ break;
+ case ieee_e2_first_byte_enum:
+ {
+ ieee_record_enum_type t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
+
+ switch (t)
+ {
+ case ieee_section_size_enum:
+ section = ieee->section_table[must_parse_int (&(ieee->h))];
+ section->_raw_size = must_parse_int (&(ieee->h));
+ break;
+ case ieee_physical_region_size_enum:
+ section = ieee->section_table[must_parse_int (&(ieee->h))];
+ section->_raw_size = must_parse_int (&(ieee->h));
+ break;
+ case ieee_region_base_address_enum:
+ section = ieee->section_table[must_parse_int (&(ieee->h))];
+ section->vma = must_parse_int (&(ieee->h));
+ section->lma = section->vma;
+ break;
+ case ieee_mau_size_enum:
+ must_parse_int (&(ieee->h));
+ must_parse_int (&(ieee->h));
+ break;
+ case ieee_m_value_enum:
+ must_parse_int (&(ieee->h));
+ must_parse_int (&(ieee->h));
+ break;
+ case ieee_section_base_address_enum:
+ section = ieee->section_table[must_parse_int (&(ieee->h))];
+ section->vma = must_parse_int (&(ieee->h));
+ section->lma = section->vma;
+ break;
+ case ieee_section_offset_enum:
+ (void) must_parse_int (&(ieee->h));
+ (void) must_parse_int (&(ieee->h));
+ break;
+ default:
+ return;
+ }
+ }
+ break;
+ default:
+ return;
+ }
+ }
+ }
+}
+
+/* Make a section for the debugging information, if any. We don't try
+ to interpret the debugging information; we just point the section
+ at the area in the file so that program which understand can dig it
+ out. */
+
+static boolean
+ieee_slurp_debug (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ asection *sec;
+
+ if (ieee->w.r.debug_information_part == 0)
+ return true;
+
+ sec = bfd_make_section (abfd, ".debug");
+ if (sec == NULL)
+ return false;
+ sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS;
+ sec->filepos = ieee->w.r.debug_information_part;
+ sec->_raw_size = ieee->w.r.data_part - ieee->w.r.debug_information_part;
+
+ return true;
+}
+
+/***********************************************************************
+* archive stuff
+*/
+
+const bfd_target *
+ieee_archive_p (abfd)
+ bfd *abfd;
+{
+ char *library;
+ unsigned int i;
+ unsigned char buffer[512];
+ file_ptr buffer_offset = 0;
+ ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
+ ieee_ar_data_type *ieee;
+ unsigned int alc_elts;
+ ieee_ar_obstack_type *elts = NULL;
+
+ abfd->tdata.ieee_ar_data =
+ (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
+ if (!abfd->tdata.ieee_ar_data)
+ goto error_return;
+ ieee = IEEE_AR_DATA (abfd);
+
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
+ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+
+ ieee->h.first_byte = buffer;
+ ieee->h.input_p = buffer;
+
+ ieee->h.abfd = abfd;
+
+ if (this_byte (&(ieee->h)) != Module_Beginning)
+ {
+ abfd->tdata.ieee_ar_data = save;
+ goto error_return;
+ }
+
+ next_byte (&(ieee->h));
+ library = read_id (&(ieee->h));
+ if (strcmp (library, "LIBRARY") != 0)
+ {
+ bfd_release (abfd, ieee);
+ abfd->tdata.ieee_ar_data = save;
+ goto error_return;
+ }
+ /* Throw away the filename */
+ read_id (&(ieee->h));
+
+ ieee->element_count = 0;
+ ieee->element_index = 0;
+
+ next_byte (&(ieee->h)); /* Drop the ad part */
+ must_parse_int (&(ieee->h)); /* And the two dummy numbers */
+ must_parse_int (&(ieee->h));
+
+ alc_elts = 10;
+ elts = (ieee_ar_obstack_type *) bfd_malloc (alc_elts * sizeof *elts);
+ if (elts == NULL)
+ goto error_return;
+
+ /* Read the index of the BB table */
+ while (1)
+ {
+ int rec;
+ ieee_ar_obstack_type *t;
+
+ rec = read_2bytes (&(ieee->h));
+ if (rec != (int) ieee_assign_value_to_variable_enum)
+ break;
+
+ if (ieee->element_count >= alc_elts)
+ {
+ ieee_ar_obstack_type *n;
+
+ alc_elts *= 2;
+ n = ((ieee_ar_obstack_type *)
+ bfd_realloc (elts, alc_elts * sizeof *elts));
+ if (n == NULL)
+ goto error_return;
+ elts = n;
+ }
+
+ t = &elts[ieee->element_count];
+ ieee->element_count++;
+
+ must_parse_int (&(ieee->h));
+ t->file_offset = must_parse_int (&(ieee->h));
+ t->abfd = (bfd *) NULL;
+
+ /* Make sure that we don't go over the end of the buffer */
+
+ if ((size_t) ieee_pos (abfd) > sizeof (buffer) / 2)
+ {
+ /* Past half way, reseek and reprime */
+ buffer_offset += ieee_pos (abfd);
+ if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
+ goto error_return;
+ /* FIXME: Check return value. I'm not sure whether it needs
+ to read the entire buffer or not. */
+ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+ ieee->h.first_byte = buffer;
+ ieee->h.input_p = buffer;
+ }
+ }
+
+ ieee->elements = ((ieee_ar_obstack_type *)
+ bfd_alloc (abfd,
+ ieee->element_count * sizeof *ieee->elements));
+ if (ieee->elements == NULL)
+ goto error_return;
+ memcpy (ieee->elements, elts,
+ ieee->element_count * sizeof *ieee->elements);
+ free (elts);
+ elts = NULL;
+
+ /* Now scan the area again, and replace BB offsets with file */
+ /* offsets */
+
+ for (i = 2; i < ieee->element_count; i++)
+ {
+ if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
+ goto error_return;
+ /* FIXME: Check return value. I'm not sure whether it needs to
+ read the entire buffer or not. */
+ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+ ieee->h.first_byte = buffer;
+ ieee->h.input_p = buffer;
+
+ next_byte (&(ieee->h)); /* Drop F8 */
+ next_byte (&(ieee->h)); /* Drop 14 */
+ must_parse_int (&(ieee->h)); /* Drop size of block */
+ if (must_parse_int (&(ieee->h)) != 0)
+ {
+ /* This object has been deleted */
+ ieee->elements[i].file_offset = 0;
+ }
+ else
+ {
+ ieee->elements[i].file_offset = must_parse_int (&(ieee->h));
+ }
+ }
+
+ /* abfd->has_armap = ;*/
+
+ return abfd->xvec;
+
+ error_return:
+ if (elts != NULL)
+ free (elts);
+ return NULL;
+}
+
+static boolean
+ieee_mkobject (abfd)
+ bfd *abfd;
+{
+ abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));
+ return abfd->tdata.ieee_data ? true : false;
+}
+
+const bfd_target *
+ieee_object_p (abfd)
+ bfd *abfd;
+{
+ char *processor;
+ unsigned int part;
+ ieee_data_type *ieee;
+ unsigned char buffer[300];
+ ieee_data_type *save = IEEE_DATA (abfd);
+
+ abfd->tdata.ieee_data = 0;
+ ieee_mkobject (abfd);
+
+ ieee = IEEE_DATA (abfd);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto fail;
+ /* Read the first few bytes in to see if it makes sense */
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
+ bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+
+ ieee->h.input_p = buffer;
+ if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
+ goto got_wrong_format;
+
+ ieee->read_symbols = false;
+ ieee->read_data = false;
+ ieee->section_count = 0;
+ ieee->external_symbol_max_index = 0;
+ ieee->external_symbol_min_index = IEEE_PUBLIC_BASE;
+ ieee->external_reference_min_index = IEEE_REFERENCE_BASE;
+ ieee->external_reference_max_index = 0;
+ ieee->h.abfd = abfd;
+ ieee->section_table = NULL;
+ ieee->section_table_size = 0;
+
+ processor = ieee->mb.processor = read_id (&(ieee->h));
+ if (strcmp (processor, "LIBRARY") == 0)
+ goto got_wrong_format;
+ ieee->mb.module_name = read_id (&(ieee->h));
+ if (abfd->filename == (CONST char *) NULL)
+ {
+ abfd->filename = ieee->mb.module_name;
+ }
+ /* Determine the architecture and machine type of the object file.
+ */
+ {
+ const bfd_arch_info_type *arch;
+ char family[10];
+
+ /* IEEE does not specify the format of the processor identificaton
+ string, so the compiler is free to put in it whatever it wants.
+ We try here to recognize different processors belonging to the
+ m68k family. Code for other processors can be added here. */
+ if ((processor[0] == '6') && (processor[1] == '8'))
+ {
+ if (processor[2] == '3') /* 683xx integrated processors */
+ {
+ switch (processor[3])
+ {
+ case '0': /* 68302, 68306, 68307 */
+ case '2': /* 68322, 68328 */
+ case '5': /* 68356 */
+ strcpy (family, "68000"); /* MC68000-based controllers */
+ break;
+
+ case '3': /* 68330, 68331, 68332, 68333,
+ 68334, 68335, 68336, 68338 */
+ case '6': /* 68360 */
+ case '7': /* 68376 */
+ strcpy (family, "68332"); /* CPU32 and CPU32+ */
+ break;
+
+ case '4':
+ if (processor[4] == '9') /* 68349 */
+ strcpy (family, "68030"); /* CPU030 */
+ else /* 68340, 68341 */
+ strcpy (family, "68332"); /* CPU32 and CPU32+ */
+ break;
+
+ default: /* Does not exist yet */
+ strcpy (family, "68332"); /* Guess it will be CPU32 */
+ }
+ }
+ else if (toupper (processor[3]) == 'F') /* 68F333 */
+ strcpy (family, "68332"); /* CPU32 */
+ else if ((toupper (processor[3]) == 'C') /* Embedded controllers */
+ && ((toupper (processor[2]) == 'E')
+ || (toupper (processor[2]) == 'H')
+ || (toupper (processor[2]) == 'L')))
+ {
+ strcpy (family, "68");
+ strncat (family, processor + 4, 7);
+ family[9] = '\0';
+ }
+ else /* "Regular" processors */
+ {
+ strncpy (family, processor, 9);
+ family[9] = '\0';
+ }
+ }
+ else if ((strncmp (processor, "cpu32", 5) == 0) /* CPU32 and CPU32+ */
+ || (strncmp (processor, "CPU32", 5) == 0))
+ strcpy (family, "68332");
+ else
+ {
+ strncpy (family, processor, 9);
+ family[9] = '\0';
+ }
+
+ arch = bfd_scan_arch (family);
+ if (arch == 0)
+ goto got_wrong_format;
+ abfd->arch_info = arch;
+ }
+
+ if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum)
+ {
+ goto fail;
+ }
+ next_byte (&(ieee->h));
+
+ if (parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau) == false)
+ {
+ goto fail;
+ }
+ if (parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address) == false)
+ {
+ goto fail;
+ }
+
+ /* If there is a byte order info, take it */
+ if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum ||
+ this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
+ next_byte (&(ieee->h));
+
+ for (part = 0; part < N_W_VARIABLES; part++)
+ {
+ boolean ok;
+ if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum)
+ {
+ goto fail;
+ }
+ if (this_byte_and_next (&(ieee->h)) != part)
+ {
+ goto fail;
+ }
+
+ ieee->w.offset[part] = parse_i (&(ieee->h), &ok);
+ if (ok == false)
+ {
+ goto fail;
+ }
+
+ }
+
+ if (ieee->w.r.external_part != 0)
+ abfd->flags = HAS_SYMS;
+
+ /* By now we know that this is a real IEEE file, we're going to read
+ the whole thing into memory so that we can run up and down it
+ quickly. We can work out how big the file is from the trailer
+ record */
+
+ IEEE_DATA (abfd)->h.first_byte =
+ (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1);
+ if (!IEEE_DATA (abfd)->h.first_byte)
+ goto fail;
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto fail;
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
+ bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1,
+ ieee->w.r.me_record + 1, abfd);
+
+ ieee_slurp_sections (abfd);
+
+ if (! ieee_slurp_debug (abfd))
+ goto fail;
+
+ /* Parse section data to activate file and section flags implied by
+ section contents. */
+
+ if (! ieee_slurp_section_data (abfd))
+ goto fail;
+
+ return abfd->xvec;
+got_wrong_format:
+ bfd_set_error (bfd_error_wrong_format);
+fail:
+ (void) bfd_release (abfd, ieee);
+ abfd->tdata.ieee_data = save;
+ return (const bfd_target *) NULL;
+}
+
+void
+ieee_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+ if (symbol->name[0] == ' ')
+ ret->name = "* empty table entry ";
+ if (!symbol->section)
+ ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
+}
+
+void
+ieee_print_symbol (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+#if 0
+ fprintf (file, "%4x %2x", aout_symbol (symbol)->desc & 0xffff,
+ aout_symbol (symbol)->other & 0xff);
+#endif
+ BFD_FAIL ();
+ break;
+ case bfd_print_symbol_all:
+ {
+ const char *section_name =
+ (symbol->section == (asection *) NULL
+ ? "*abs"
+ : symbol->section->name);
+ if (symbol->name[0] == ' ')
+ {
+ fprintf (file, "* empty table entry ");
+ }
+ else
+ {
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+
+ fprintf (file, " %-5s %04x %02x %s",
+ section_name,
+ (unsigned) ieee_symbol (symbol)->index,
+ (unsigned) 0,
+ symbol->name);
+ }
+ }
+ break;
+ }
+}
+
+static boolean
+do_one (ieee, current_map, location_ptr, s, iterations)
+ ieee_data_type *ieee;
+ ieee_per_section_type *current_map;
+ unsigned char *location_ptr;
+ asection *s;
+ int iterations;
+{
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_load_constant_bytes_enum:
+ {
+ unsigned int number_of_maus;
+ unsigned int i;
+ next_byte (&(ieee->h));
+ number_of_maus = must_parse_int (&(ieee->h));
+
+ for (i = 0; i < number_of_maus; i++)
+ {
+ location_ptr[current_map->pc++] = this_byte (&(ieee->h));
+ next_byte (&(ieee->h));
+ }
+ }
+ break;
+
+ case ieee_load_with_relocation_enum:
+ {
+ boolean loop = true;
+ next_byte (&(ieee->h));
+ while (loop)
+ {
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_variable_R_enum:
+
+ case ieee_function_signed_open_b_enum:
+ case ieee_function_unsigned_open_b_enum:
+ case ieee_function_either_open_b_enum:
+ {
+ unsigned int extra = 4;
+ boolean pcrel = false;
+ asection *section;
+ ieee_reloc_type *r =
+ (ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
+ sizeof (ieee_reloc_type));
+ if (!r)
+ return false;
+
+ *(current_map->reloc_tail_ptr) = r;
+ current_map->reloc_tail_ptr = &r->next;
+ r->next = (ieee_reloc_type *) NULL;
+ next_byte (&(ieee->h));
+/* abort();*/
+ r->relent.sym_ptr_ptr = 0;
+ parse_expression (ieee,
+ &r->relent.addend,
+ &r->symbol,
+ &pcrel, &extra, &section);
+ r->relent.address = current_map->pc;
+ s->flags |= SEC_RELOC;
+ s->owner->flags |= HAS_RELOC;
+ s->reloc_count++;
+ if (r->relent.sym_ptr_ptr == NULL && section != NULL)
+ r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
+
+ if (this_byte (&(ieee->h)) == (int) ieee_comma)
+ {
+ next_byte (&(ieee->h));
+ /* Fetch number of bytes to pad */
+ extra = must_parse_int (&(ieee->h));
+ };
+
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_function_signed_close_b_enum:
+ next_byte (&(ieee->h));
+ break;
+ case ieee_function_unsigned_close_b_enum:
+ next_byte (&(ieee->h));
+ break;
+ case ieee_function_either_close_b_enum:
+ next_byte (&(ieee->h));
+ break;
+ default:
+ break;
+ }
+ /* Build a relocation entry for this type */
+ /* If pc rel then stick -ve pc into instruction
+ and take out of reloc ..
+
+ I've changed this. It's all too complicated. I
+ keep 0 in the instruction now. */
+
+ switch (extra)
+ {
+ case 0:
+ case 4:
+
+ if (pcrel == true)
+ {
+#if KEEPMINUSPCININST
+ bfd_put_32 (ieee->h.abfd, -current_map->pc, location_ptr +
+ current_map->pc);
+ r->relent.howto = &rel32_howto;
+ r->relent.addend -=
+ current_map->pc;
+#else
+ bfd_put_32 (ieee->h.abfd, 0, location_ptr +
+ current_map->pc);
+ r->relent.howto = &rel32_howto;
+#endif
+ }
+ else
+ {
+ bfd_put_32 (ieee->h.abfd, 0, location_ptr +
+ current_map->pc);
+ r->relent.howto = &abs32_howto;
+ }
+ current_map->pc += 4;
+ break;
+ case 2:
+ if (pcrel == true)
+ {
+#if KEEPMINUSPCININST
+ bfd_put_16 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
+ r->relent.addend -= current_map->pc;
+ r->relent.howto = &rel16_howto;
+#else
+
+ bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
+ r->relent.howto = &rel16_howto;
+#endif
+ }
+
+ else
+ {
+ bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
+ r->relent.howto = &abs16_howto;
+ }
+ current_map->pc += 2;
+ break;
+ case 1:
+ if (pcrel == true)
+ {
+#if KEEPMINUSPCININST
+ bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
+ r->relent.addend -= current_map->pc;
+ r->relent.howto = &rel8_howto;
+#else
+ bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
+ r->relent.howto = &rel8_howto;
+#endif
+ }
+ else
+ {
+ bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
+ r->relent.howto = &abs8_howto;
+ }
+ current_map->pc += 1;
+ break;
+
+ default:
+ BFD_FAIL ();
+ return false;
+ }
+ }
+ break;
+ default:
+ {
+ bfd_vma this_size;
+ if (parse_int (&(ieee->h), &this_size) == true)
+ {
+ unsigned int i;
+ for (i = 0; i < this_size; i++)
+ {
+ location_ptr[current_map->pc++] = this_byte (&(ieee->h));
+ next_byte (&(ieee->h));
+ }
+ }
+ else
+ {
+ loop = false;
+ }
+ }
+ }
+
+ /* Prevent more than the first load-item of an LR record
+ from being repeated (MRI convention). */
+ if (iterations != 1)
+ loop = false;
+ }
+ }
+ }
+ return true;
+}
+
+/* Read in all the section data and relocation stuff too */
+static boolean
+ieee_slurp_section_data (abfd)
+ bfd *abfd;
+{
+ bfd_byte *location_ptr = (bfd_byte *) NULL;
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ unsigned int section_number;
+
+ ieee_per_section_type *current_map = (ieee_per_section_type *) NULL;
+ asection *s;
+ /* Seek to the start of the data area */
+ if (ieee->read_data == true)
+ return true;
+ ieee->read_data = true;
+ ieee_seek (abfd, ieee->w.r.data_part);
+
+ /* Allocate enough space for all the section contents */
+
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
+ if ((s->flags & SEC_DEBUGGING) != 0)
+ continue;
+ per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
+ if (!per->data)
+ return false;
+ /*SUPPRESS 68*/
+ per->reloc_tail_ptr =
+ (ieee_reloc_type **) & (s->relocation);
+ }
+
+ while (true)
+ {
+ switch (this_byte (&(ieee->h)))
+ {
+ /* IF we see anything strange then quit */
+ default:
+ return true;
+
+ case ieee_set_current_section_enum:
+ next_byte (&(ieee->h));
+ section_number = must_parse_int (&(ieee->h));
+ s = ieee->section_table[section_number];
+ s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
+ current_map = (ieee_per_section_type *) s->used_by_bfd;
+ location_ptr = current_map->data - s->vma;
+ /* The document I have says that Microtec's compilers reset */
+ /* this after a sec section, even though the standard says not */
+ /* to. SO .. */
+ current_map->pc = s->vma;
+ break;
+
+ case ieee_e2_first_byte_enum:
+ next_byte (&(ieee->h));
+ switch (this_byte (&(ieee->h)))
+ {
+ case ieee_set_current_pc_enum & 0xff:
+ {
+ bfd_vma value;
+ ieee_symbol_index_type symbol;
+ unsigned int extra;
+ boolean pcrel;
+ next_byte (&(ieee->h));
+ must_parse_int (&(ieee->h)); /* Thow away section #*/
+ parse_expression (ieee, &value,
+ &symbol,
+ &pcrel, &extra,
+ 0);
+ current_map->pc = value;
+ BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_size);
+ }
+ break;
+
+ case ieee_value_starting_address_enum & 0xff:
+ next_byte (&(ieee->h));
+ if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum)
+ next_byte (&(ieee->h));
+ abfd->start_address = must_parse_int (&(ieee->h));
+ /* We've got to the end of the data now - */
+ return true;
+ default:
+ BFD_FAIL ();
+ return false;
+ }
+ break;
+ case ieee_repeat_data_enum:
+ {
+ /* Repeat the following LD or LR n times - we do this by
+ remembering the stream pointer before running it and
+ resetting it and running it n times. We special case
+ the repetition of a repeat_data/load_constant
+ */
+
+ unsigned int iterations;
+ unsigned char *start;
+ next_byte (&(ieee->h));
+ iterations = must_parse_int (&(ieee->h));
+ start = ieee->h.input_p;
+ if (start[0] == (int) ieee_load_constant_bytes_enum &&
+ start[1] == 1)
+ {
+ while (iterations != 0)
+ {
+ location_ptr[current_map->pc++] = start[2];
+ iterations--;
+ }
+ next_byte (&(ieee->h));
+ next_byte (&(ieee->h));
+ next_byte (&(ieee->h));
+ }
+ else
+ {
+ while (iterations != 0)
+ {
+ ieee->h.input_p = start;
+ if (!do_one (ieee, current_map, location_ptr, s,
+ iterations))
+ return false;
+ iterations--;
+ }
+ }
+ }
+ break;
+ case ieee_load_constant_bytes_enum:
+ case ieee_load_with_relocation_enum:
+ {
+ if (!do_one (ieee, current_map, location_ptr, s, 1))
+ return false;
+ }
+ }
+ }
+}
+
+boolean
+ieee_new_section_hook (abfd, newsect)
+ bfd *abfd;
+ asection *newsect;
+{
+ newsect->used_by_bfd = (PTR)
+ bfd_alloc (abfd, sizeof (ieee_per_section_type));
+ if (!newsect->used_by_bfd)
+ return false;
+ ieee_per_section (newsect)->data = (bfd_byte *) NULL;
+ ieee_per_section (newsect)->section = newsect;
+ return true;
+}
+
+long
+ieee_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ if ((asect->flags & SEC_DEBUGGING) != 0)
+ return 0;
+ if (! ieee_slurp_section_data (abfd))
+ return -1;
+ return (asect->reloc_count + 1) * sizeof (arelent *);
+}
+
+static boolean
+ieee_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;
+ if ((section->flags & SEC_DEBUGGING) != 0)
+ return _bfd_generic_get_section_contents (abfd, section, location,
+ offset, count);
+ ieee_slurp_section_data (abfd);
+ (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count);
+ return true;
+}
+
+long
+ieee_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+/* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
+ ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation);
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+
+ if ((section->flags & SEC_DEBUGGING) != 0)
+ return 0;
+
+ while (src != (ieee_reloc_type *) NULL)
+ {
+ /* Work out which symbol to attach it this reloc to */
+ switch (src->symbol.letter)
+ {
+ case 'I':
+ src->relent.sym_ptr_ptr =
+ symbols + src->symbol.index + ieee->external_symbol_base_offset;
+ break;
+ case 'X':
+ src->relent.sym_ptr_ptr =
+ symbols + src->symbol.index + ieee->external_reference_base_offset;
+ break;
+ case 0:
+ if (src->relent.sym_ptr_ptr != NULL)
+ src->relent.sym_ptr_ptr =
+ src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
+ break;
+ default:
+
+ BFD_FAIL ();
+ }
+ *relptr++ = &src->relent;
+ src = src->next;
+ }
+ *relptr = (arelent *) NULL;
+ return section->reloc_count;
+}
+
+static int
+comp (ap, bp)
+ CONST PTR ap;
+ CONST PTR bp;
+{
+ arelent *a = *((arelent **) ap);
+ arelent *b = *((arelent **) bp);
+ return a->address - b->address;
+}
+
+/* Write the section headers. */
+
+static boolean
+ieee_write_section_part (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ asection *s;
+ ieee->w.r.section_part = bfd_tell (abfd);
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ if (! bfd_is_abs_section (s)
+ && (s->flags & SEC_DEBUGGING) == 0)
+ {
+ if (! ieee_write_byte (abfd, ieee_section_type_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index
+ + IEEE_SECTION_NUMBER_BASE)))
+ return false;
+
+ if (abfd->flags & EXEC_P)
+ {
+ /* This image is executable, so output absolute sections */
+ if (! ieee_write_byte (abfd, ieee_variable_A_enum)
+ || ! ieee_write_byte (abfd, ieee_variable_S_enum))
+ return false;
+ }
+ else
+ {
+ if (! ieee_write_byte (abfd, ieee_variable_C_enum))
+ return false;
+ }
+
+ switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM))
+ {
+ case SEC_CODE | SEC_LOAD:
+ case SEC_CODE:
+ if (! ieee_write_byte (abfd, ieee_variable_P_enum))
+ return false;
+ break;
+ case SEC_DATA:
+ default:
+ if (! ieee_write_byte (abfd, ieee_variable_D_enum))
+ return false;
+ break;
+ case SEC_ROM:
+ case SEC_ROM | SEC_DATA:
+ case SEC_ROM | SEC_LOAD:
+ case SEC_ROM | SEC_DATA | SEC_LOAD:
+ if (! ieee_write_byte (abfd, ieee_variable_R_enum))
+ return false;
+ }
+
+
+ if (! ieee_write_id (abfd, s->name))
+ return false;
+#if 0
+ ieee_write_int (abfd, 0); /* Parent */
+ ieee_write_int (abfd, 0); /* Brother */
+ ieee_write_int (abfd, 0); /* Context */
+#endif
+ /* Alignment */
+ if (! ieee_write_byte (abfd, ieee_section_alignment_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index
+ + IEEE_SECTION_NUMBER_BASE))
+ || ! ieee_write_int (abfd, 1 << s->alignment_power))
+ return false;
+
+ /* Size */
+ if (! ieee_write_2bytes (abfd, ieee_section_size_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index
+ + IEEE_SECTION_NUMBER_BASE))
+ || ! ieee_write_int (abfd, s->_raw_size))
+ return false;
+ if (abfd->flags & EXEC_P)
+ {
+ /* Relocateable sections don't have asl records */
+ /* Vma */
+ if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum)
+ || ! ieee_write_byte (abfd,
+ ((bfd_byte)
+ (s->index
+ + IEEE_SECTION_NUMBER_BASE)))
+ || ! ieee_write_int (abfd, s->lma))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+
+static boolean
+do_with_relocs (abfd, s)
+ bfd *abfd;
+ asection *s;
+{
+ unsigned int number_of_maus_in_address =
+ bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd);
+ unsigned int relocs_to_go = s->reloc_count;
+ bfd_byte *stream = ieee_per_section (s)->data;
+ arelent **p = s->orelocation;
+ bfd_size_type current_byte_index = 0;
+
+ qsort (s->orelocation,
+ relocs_to_go,
+ sizeof (arelent **),
+ comp);
+
+ /* Output the section preheader */
+ if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))
+ || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)))
+ return false;
+ if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0)
+ {
+ if (! ieee_write_int (abfd, s->lma))
+ return false;
+ }
+ else
+ {
+ if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))
+ return false;
+ }
+
+ if (relocs_to_go == 0)
+ {
+ /* If there aren't any relocations then output the load constant
+ byte opcode rather than the load with relocation opcode */
+
+ while (current_byte_index < s->_raw_size)
+ {
+ bfd_size_type run;
+ unsigned int MAXRUN = 127;
+ run = MAXRUN;
+ if (run > s->_raw_size - current_byte_index)
+ {
+ run = s->_raw_size - current_byte_index;
+ }
+
+ if (run != 0)
+ {
+ if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum))
+ return false;
+ /* Output a stream of bytes */
+ if (! ieee_write_int (abfd, run))
+ return false;
+ if (bfd_write ((PTR) (stream + current_byte_index),
+ 1,
+ run,
+ abfd)
+ != run)
+ return false;
+ current_byte_index += run;
+ }
+ }
+ }
+ else
+ {
+ if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum))
+ return false;
+
+ /* Output the data stream as the longest sequence of bytes
+ possible, allowing for the a reasonable packet size and
+ relocation stuffs. */
+
+ if ((PTR) stream == (PTR) NULL)
+ {
+ /* Outputting a section without data, fill it up */
+ stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
+ if (!stream)
+ return false;
+ memset ((PTR) stream, 0, (size_t) s->_raw_size);
+ }
+ while (current_byte_index < s->_raw_size)
+ {
+ bfd_size_type run;
+ unsigned int MAXRUN = 127;
+ if (relocs_to_go)
+ {
+ run = (*p)->address - current_byte_index;
+ if (run > MAXRUN)
+ run = MAXRUN;
+ }
+ else
+ {
+ run = MAXRUN;
+ }
+ if (run > s->_raw_size - current_byte_index)
+ {
+ run = s->_raw_size - current_byte_index;
+ }
+
+ if (run != 0)
+ {
+ /* Output a stream of bytes */
+ if (! ieee_write_int (abfd, run))
+ return false;
+ if (bfd_write ((PTR) (stream + current_byte_index),
+ 1,
+ run,
+ abfd)
+ != run)
+ return false;
+ current_byte_index += run;
+ }
+ /* Output any relocations here */
+ if (relocs_to_go && (*p) && (*p)->address == current_byte_index)
+ {
+ while (relocs_to_go
+ && (*p) && (*p)->address == current_byte_index)
+ {
+ arelent *r = *p;
+ bfd_signed_vma ov;
+
+#if 0
+ if (r->howto->pc_relative)
+ {
+ r->addend += current_byte_index;
+ }
+#endif
+
+ switch (r->howto->size)
+ {
+ case 2:
+
+ ov = bfd_get_signed_32 (abfd,
+ stream + current_byte_index);
+ current_byte_index += 4;
+ break;
+ case 1:
+ ov = bfd_get_signed_16 (abfd,
+ stream + current_byte_index);
+ current_byte_index += 2;
+ break;
+ case 0:
+ ov = bfd_get_signed_8 (abfd,
+ stream + current_byte_index);
+ current_byte_index++;
+ break;
+ default:
+ ov = 0;
+ BFD_FAIL ();
+ return false;
+ }
+
+ ov &= r->howto->src_mask;
+
+ if (r->howto->pc_relative
+ && ! r->howto->pcrel_offset)
+ ov += r->address;
+
+ if (! ieee_write_byte (abfd,
+ ieee_function_either_open_b_enum))
+ return false;
+
+/* abort();*/
+
+ if (r->sym_ptr_ptr != (asymbol **) NULL)
+ {
+ if (! ieee_write_expression (abfd, r->addend + ov,
+ *(r->sym_ptr_ptr),
+ r->howto->pc_relative,
+ s->index))
+ return false;
+ }
+ else
+ {
+ if (! ieee_write_expression (abfd, r->addend + ov,
+ (asymbol *) NULL,
+ r->howto->pc_relative,
+ s->index))
+ return false;
+ }
+
+ if (number_of_maus_in_address
+ != bfd_get_reloc_size (r->howto))
+ {
+ if (! ieee_write_int (abfd,
+ bfd_get_reloc_size (r->howto)))
+ return false;
+ }
+ if (! ieee_write_byte (abfd,
+ ieee_function_either_close_b_enum))
+ return false;
+
+ relocs_to_go--;
+ p++;
+ }
+
+ }
+ }
+ }
+
+ return true;
+}
+
+/* If there are no relocations in the output section then we can be
+ clever about how we write. We block items up into a max of 127
+ bytes. */
+
+static boolean
+do_as_repeat (abfd, s)
+ bfd *abfd;
+ asection *s;
+{
+ if (s->_raw_size)
+ {
+ if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index
+ + IEEE_SECTION_NUMBER_BASE))
+ || ! ieee_write_byte (abfd, ieee_set_current_pc_enum >> 8)
+ || ! ieee_write_byte (abfd, ieee_set_current_pc_enum & 0xff)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (s->index
+ + IEEE_SECTION_NUMBER_BASE))
+ || ! ieee_write_int (abfd, s->lma)
+ || ! ieee_write_byte (abfd, ieee_repeat_data_enum)
+ || ! ieee_write_int (abfd, s->_raw_size)
+ || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)
+ || ! ieee_write_byte (abfd, 1)
+ || ! ieee_write_byte (abfd, 0))
+ return false;
+ }
+
+ return true;
+}
+
+static boolean
+do_without_relocs (abfd, s)
+ bfd *abfd;
+ asection *s;
+{
+ bfd_byte *stream = ieee_per_section (s)->data;
+
+ if (stream == 0 || ((s->flags & SEC_LOAD) == 0))
+ {
+ if (! do_as_repeat (abfd, s))
+ return false;
+ }
+ else
+ {
+ unsigned int i;
+ for (i = 0; i < s->_raw_size; i++)
+ {
+ if (stream[i] != 0)
+ {
+ if (! do_with_relocs (abfd, s))
+ return false;
+ return true;
+ }
+ }
+ if (! do_as_repeat (abfd, s))
+ return false;
+ }
+
+ return true;
+}
+
+
+static unsigned char *output_ptr_start;
+static unsigned char *output_ptr;
+static unsigned char *output_ptr_end;
+static unsigned char *input_ptr_start;
+static unsigned char *input_ptr;
+static unsigned char *input_ptr_end;
+static bfd *input_bfd;
+static bfd *output_bfd;
+static int output_buffer;
+
+static void
+fill ()
+{
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
+ bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
+ input_ptr = input_ptr_start;
+}
+static void
+flush ()
+{
+ if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
+ output_bfd)
+ != (bfd_size_type) (output_ptr - output_ptr_start))
+ abort ();
+ output_ptr = output_ptr_start;
+ output_buffer++;
+}
+
+#define THIS() ( *input_ptr )
+#define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
+#define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); }
+
+static void
+write_int (value)
+ int value;
+{
+ if (value >= 0 && value <= 127)
+ {
+ OUT (value);
+ }
+ else
+ {
+ unsigned int length;
+ /* How many significant bytes ? */
+ /* FIXME FOR LONGER INTS */
+ if (value & 0xff000000)
+ {
+ length = 4;
+ }
+ else if (value & 0x00ff0000)
+ {
+ length = 3;
+ }
+ else if (value & 0x0000ff00)
+ {
+ length = 2;
+ }
+ else
+ length = 1;
+
+ OUT ((int) ieee_number_repeat_start_enum + length);
+ switch (length)
+ {
+ case 4:
+ OUT (value >> 24);
+ case 3:
+ OUT (value >> 16);
+ case 2:
+ OUT (value >> 8);
+ case 1:
+ OUT (value);
+ }
+
+ }
+}
+
+static void
+copy_id ()
+{
+ int length = THIS ();
+ char ch;
+ OUT (length);
+ NEXT ();
+ while (length--)
+ {
+ ch = THIS ();
+ OUT (ch);
+ NEXT ();
+ }
+}
+
+#define VAR(x) ((x | 0x80))
+static void
+copy_expression ()
+{
+ int stack[10];
+ int *tos = stack;
+ int value = 0;
+ while (1)
+ {
+ switch (THIS ())
+ {
+ case 0x84:
+ NEXT ();
+ value = THIS ();
+ NEXT ();
+ value = (value << 8) | THIS ();
+ NEXT ();
+ value = (value << 8) | THIS ();
+ NEXT ();
+ value = (value << 8) | THIS ();
+ NEXT ();
+ *tos++ = value;
+ break;
+ case 0x83:
+ NEXT ();
+ value = THIS ();
+ NEXT ();
+ value = (value << 8) | THIS ();
+ NEXT ();
+ value = (value << 8) | THIS ();
+ NEXT ();
+ *tos++ = value;
+ break;
+ case 0x82:
+ NEXT ();
+ value = THIS ();
+ NEXT ();
+ value = (value << 8) | THIS ();
+ NEXT ();
+ *tos++ = value;
+ break;
+ case 0x81:
+ NEXT ();
+ value = THIS ();
+ NEXT ();
+ *tos++ = value;
+ break;
+ case 0x80:
+ NEXT ();
+ *tos++ = 0;
+ break;
+ default:
+ if (THIS () > 0x84)
+ {
+ /* Not a number, just bug out with the answer */
+ write_int (*(--tos));
+ return;
+ }
+ *tos++ = THIS ();
+ NEXT ();
+ value = 0;
+ break;
+ case 0xa5:
+ /* PLUS anything */
+ {
+ int value = *(--tos);
+ value += *(--tos);
+ *tos++ = value;
+ NEXT ();
+ }
+ break;
+ case VAR ('R'):
+ {
+ int section_number;
+ ieee_data_type *ieee;
+ asection *s;
+ NEXT ();
+ section_number = THIS ();
+
+ NEXT ();
+ ieee = IEEE_DATA (input_bfd);
+ s = ieee->section_table[section_number];
+ if (s->output_section)
+ {
+ value = s->output_section->lma;
+ }
+ else
+ {
+ value = 0;
+ }
+ value += s->output_offset;
+ *tos++ = value;
+ value = 0;
+ }
+ break;
+ case 0x90:
+ {
+ NEXT ();
+ write_int (*(--tos));
+ OUT (0x90);
+ return;
+
+ }
+ }
+ }
+
+}
+
+/* Drop the int in the buffer, and copy a null into the gap, which we
+ will overwrite later */
+
+struct output_buffer_struct
+{
+ unsigned char *ptrp;
+ int buffer;
+};
+
+static void
+fill_int (buf)
+ struct output_buffer_struct *buf;
+{
+ if (buf->buffer == output_buffer)
+ {
+ /* Still a chance to output the size */
+ int value = output_ptr - buf->ptrp + 3;
+ buf->ptrp[0] = value >> 24;
+ buf->ptrp[1] = value >> 16;
+ buf->ptrp[2] = value >> 8;
+ buf->ptrp[3] = value >> 0;
+ }
+}
+
+static void
+drop_int (buf)
+ struct output_buffer_struct *buf;
+{
+ int type = THIS ();
+ int ch;
+ if (type <= 0x84)
+ {
+ NEXT ();
+ switch (type)
+ {
+ case 0x84:
+ ch = THIS ();
+ NEXT ();
+ case 0x83:
+ ch = THIS ();
+ NEXT ();
+ case 0x82:
+ ch = THIS ();
+ NEXT ();
+ case 0x81:
+ ch = THIS ();
+ NEXT ();
+ case 0x80:
+ break;
+ }
+ }
+ OUT (0x84);
+ buf->ptrp = output_ptr;
+ buf->buffer = output_buffer;
+ OUT (0);
+ OUT (0);
+ OUT (0);
+ OUT (0);
+}
+
+static void
+copy_int ()
+{
+ int type = THIS ();
+ int ch;
+ if (type <= 0x84)
+ {
+ OUT (type);
+ NEXT ();
+ switch (type)
+ {
+ case 0x84:
+ ch = THIS ();
+ NEXT ();
+ OUT (ch);
+ case 0x83:
+ ch = THIS ();
+ NEXT ();
+ OUT (ch);
+ case 0x82:
+ ch = THIS ();
+ NEXT ();
+ OUT (ch);
+ case 0x81:
+ ch = THIS ();
+ NEXT ();
+ OUT (ch);
+ case 0x80:
+ break;
+ }
+ }
+}
+
+#define ID copy_id()
+#define INT copy_int()
+#define EXP copy_expression()
+static void copy_till_end ();
+#define INTn(q) copy_int()
+#define EXPn(q) copy_expression()
+
+static void
+f1_record ()
+{
+ int ch;
+ /* ATN record */
+ NEXT ();
+ ch = THIS ();
+ switch (ch)
+ {
+ default:
+ OUT (0xf1);
+ OUT (ch);
+ break;
+ case 0xc9:
+ NEXT ();
+ OUT (0xf1);
+ OUT (0xc9);
+ INT;
+ INT;
+ ch = THIS ();
+ switch (ch)
+ {
+ case 0x16:
+ NEXT ();
+ break;
+ case 0x01:
+ NEXT ();
+ break;
+ case 0x00:
+ NEXT ();
+ INT;
+ break;
+ case 0x03:
+ NEXT ();
+ INT;
+ break;
+ case 0x13:
+ EXPn (instruction address);
+ break;
+ default:
+ break;
+ }
+ break;
+ case 0xd8:
+ /* EXternal ref */
+ NEXT ();
+ OUT (0xf1);
+ OUT (0xd8);
+ EXP;
+ EXP;
+ EXP;
+ EXP;
+ break;
+ case 0xce:
+ NEXT ();
+ OUT (0xf1);
+ OUT (0xce);
+ INT;
+ INT;
+ ch = THIS ();
+ INT;
+ switch (ch)
+ {
+ case 0x01:
+ INT;
+ INT;
+ break;
+ case 0x02:
+ INT;
+ break;
+ case 0x04:
+ EXPn (external function);
+ break;
+ case 0x05:
+ break;
+ case 0x07:
+ INTn (line number);
+ INT;
+ case 0x08:
+ break;
+ case 0x0a:
+ INTn (locked register);
+ INT;
+ break;
+ case 0x3f:
+ copy_till_end ();
+ break;
+ case 0x3e:
+ copy_till_end ();
+ break;
+ case 0x40:
+ copy_till_end ();
+ break;
+ case 0x41:
+ ID;
+ break;
+ }
+ }
+
+}
+
+static void
+f0_record ()
+{
+ /* Attribute record */
+ NEXT ();
+ OUT (0xf0);
+ INTn (Symbol name);
+ ID;
+}
+
+static void
+copy_till_end ()
+{
+ int ch = THIS ();
+ while (1)
+ {
+ while (ch <= 0x80)
+ {
+ OUT (ch);
+ NEXT ();
+ ch = THIS ();
+ }
+ switch (ch)
+ {
+ case 0x84:
+ OUT (THIS ());
+ NEXT ();
+ case 0x83:
+ OUT (THIS ());
+ NEXT ();
+ case 0x82:
+ OUT (THIS ());
+ NEXT ();
+ case 0x81:
+ OUT (THIS ());
+ NEXT ();
+ OUT (THIS ());
+ NEXT ();
+
+ ch = THIS ();
+ break;
+ default:
+ return;
+ }
+ }
+
+}
+
+static void
+f2_record ()
+{
+ NEXT ();
+ OUT (0xf2);
+ INT;
+ NEXT ();
+ OUT (0xce);
+ INT;
+ copy_till_end ();
+}
+
+
+static void block ();
+static void
+f8_record ()
+{
+ int ch;
+ NEXT ();
+ ch = THIS ();
+ switch (ch)
+ {
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ /* Unique typedefs for module */
+ /* GLobal typedefs */
+ /* High level module scope beginning */
+ {
+ struct output_buffer_struct ob;
+ NEXT ();
+ OUT (0xf8);
+ OUT (ch);
+ drop_int (&ob);
+ ID;
+
+ block ();
+
+ NEXT ();
+ fill_int (&ob);
+ OUT (0xf9);
+ }
+ break;
+ case 0x04:
+ /* Global function */
+ {
+ struct output_buffer_struct ob;
+ NEXT ();
+ OUT (0xf8);
+ OUT (0x04);
+ drop_int (&ob);
+ ID;
+ INTn (stack size);
+ INTn (ret val);
+ EXPn (offset);
+
+ block ();
+
+ NEXT ();
+ OUT (0xf9);
+ EXPn (size of block);
+ fill_int (&ob);
+ }
+ break;
+
+ case 0x05:
+ /* File name for source line numbers */
+ {
+ struct output_buffer_struct ob;
+ NEXT ();
+ OUT (0xf8);
+ OUT (0x05);
+ drop_int (&ob);
+ ID;
+ INTn (year);
+ INTn (month);
+ INTn (day);
+ INTn (hour);
+ INTn (monute);
+ INTn (second);
+ block ();
+ NEXT ();
+ OUT (0xf9);
+ fill_int (&ob);
+ }
+ break;
+
+ case 0x06:
+ /* Local function */
+ {
+ struct output_buffer_struct ob;
+ NEXT ();
+ OUT (0xf8);
+ OUT (0x06);
+ drop_int (&ob);
+ ID;
+ INTn (stack size);
+ INTn (type return);
+ EXPn (offset);
+ block ();
+ NEXT ();
+ OUT (0xf9);
+ EXPn (size);
+ fill_int (&ob);
+ }
+ break;
+
+ case 0x0a:
+ /* Assembler module scope beginning -*/
+ {
+ struct output_buffer_struct ob;
+
+ NEXT ();
+ OUT (0xf8);
+ OUT (0x0a);
+ drop_int (&ob);
+ ID;
+ ID;
+ INT;
+ ID;
+ INT;
+ INT;
+ INT;
+ INT;
+ INT;
+ INT;
+
+ block ();
+
+ NEXT ();
+ OUT (0xf9);
+ fill_int (&ob);
+ }
+ break;
+ case 0x0b:
+ {
+ struct output_buffer_struct ob;
+ NEXT ();
+ OUT (0xf8);
+ OUT (0x0b);
+ drop_int (&ob);
+ ID;
+ INT;
+ INTn (section index);
+ EXPn (offset);
+ INTn (stuff);
+
+ block ();
+
+ OUT (0xf9);
+ NEXT ();
+ EXPn (Size in Maus);
+ fill_int (&ob);
+ }
+ break;
+ }
+}
+
+static void
+e2_record ()
+{
+ OUT (0xe2);
+ NEXT ();
+ OUT (0xce);
+ NEXT ();
+ INT;
+ EXP;
+}
+
+static void
+block ()
+{
+ int ch;
+ while (1)
+ {
+ ch = THIS ();
+ switch (ch)
+ {
+ case 0xe1:
+ case 0xe5:
+ return;
+ case 0xf9:
+ return;
+ case 0xf0:
+ f0_record ();
+ break;
+ case 0xf1:
+ f1_record ();
+ break;
+ case 0xf2:
+ f2_record ();
+ break;
+ case 0xf8:
+ f8_record ();
+ break;
+ case 0xe2:
+ e2_record ();
+ break;
+
+ }
+ }
+}
+
+
+
+/* relocate_debug,
+ moves all the debug information from the source bfd to the output
+ bfd, and relocates any expressions it finds
+*/
+
+static void
+relocate_debug (output, input)
+ bfd *output;
+ bfd *input;
+{
+#define IBS 400
+#define OBS 400
+ unsigned char input_buffer[IBS];
+
+ input_ptr_start = input_ptr = input_buffer;
+ input_ptr_end = input_buffer + IBS;
+ input_bfd = input;
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
+ bfd_read ((PTR) input_ptr_start, 1, IBS, input);
+ block ();
+}
+
+/*
+ During linking, we we told about the bfds which made up our
+ contents, we have a list of them. They will still be open, so go to
+ the debug info in each, and copy it out, relocating it as we go.
+*/
+
+static boolean
+ieee_write_debug_part (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ bfd_chain_type *chain = ieee->chain_root;
+ unsigned char output_buffer[OBS];
+ boolean some_debug = false;
+ file_ptr here = bfd_tell (abfd);
+
+ output_ptr_start = output_ptr = output_buffer;
+ output_ptr_end = output_buffer + OBS;
+ output_ptr = output_buffer;
+ output_bfd = abfd;
+
+ if (chain == (bfd_chain_type *) NULL)
+ {
+ asection *s;
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ if ((s->flags & SEC_DEBUGGING) != 0)
+ break;
+ if (s == NULL)
+ {
+ ieee->w.r.debug_information_part = 0;
+ return true;
+ }
+
+ ieee->w.r.debug_information_part = here;
+ if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size)
+ return false;
+ }
+ else
+ {
+ while (chain != (bfd_chain_type *) NULL)
+ {
+ bfd *entry = chain->this;
+ ieee_data_type *entry_ieee = IEEE_DATA (entry);
+ if (entry_ieee->w.r.debug_information_part)
+ {
+ if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
+ SEEK_SET)
+ != 0)
+ return false;
+ relocate_debug (abfd, entry);
+ }
+
+ chain = chain->next;
+ }
+ if (some_debug)
+ {
+ ieee->w.r.debug_information_part = here;
+ }
+ else
+ {
+ ieee->w.r.debug_information_part = 0;
+ }
+
+ flush ();
+ }
+
+ return true;
+}
+
+/* Write the data in an ieee way. */
+
+static boolean
+ieee_write_data_part (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ ieee->w.r.data_part = bfd_tell (abfd);
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ /* Skip sections that have no loadable contents (.bss,
+ debugging, etc.) */
+ if ((s->flags & SEC_LOAD) == 0)
+ continue;
+
+ /* Sort the reloc records so we can insert them in the correct
+ places */
+ if (s->reloc_count != 0)
+ {
+ if (! do_with_relocs (abfd, s))
+ return false;
+ }
+ else
+ {
+ if (! do_without_relocs (abfd, s))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+static boolean
+init_for_output (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ if ((s->flags & SEC_DEBUGGING) != 0)
+ continue;
+ if (s->_raw_size != 0)
+ {
+ ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
+ if (!ieee_per_section (s)->data)
+ return false;
+ }
+ }
+ return true;
+}
+
+/** exec and core file sections */
+
+/* set section contents is complicated with IEEE since the format is
+* not a byte image, but a record stream.
+*/
+boolean
+ieee_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if ((section->flags & SEC_DEBUGGING) != 0)
+ {
+ if (section->contents == NULL)
+ {
+ section->contents = ((unsigned char *)
+ bfd_alloc (abfd, section->_raw_size));
+ if (section->contents == NULL)
+ return false;
+ }
+ /* bfd_set_section_contents has already checked that everything
+ is within range. */
+ memcpy (section->contents + offset, location, count);
+ return true;
+ }
+
+ if (ieee_per_section (section)->data == (bfd_byte *) NULL)
+ {
+ if (!init_for_output (abfd))
+ return false;
+ }
+ memcpy ((PTR) (ieee_per_section (section)->data + offset),
+ (PTR) location,
+ (unsigned int) count);
+ return true;
+}
+
+/* Write the external symbols of a file. IEEE considers two sorts of
+ external symbols, public, and referenced. It uses to internal
+ forms to index them as well. When we write them out we turn their
+ symbol values into indexes from the right base. */
+
+static boolean
+ieee_write_external_part (abfd)
+ bfd *abfd;
+{
+ asymbol **q;
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+
+ unsigned int reference_index = IEEE_REFERENCE_BASE;
+ unsigned int public_index = IEEE_PUBLIC_BASE + 2;
+ file_ptr here = bfd_tell (abfd);
+ boolean hadone = false;
+ if (abfd->outsymbols != (asymbol **) NULL)
+ {
+
+ for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++)
+ {
+ asymbol *p = *q;
+ if (bfd_is_und_section (p->section))
+ {
+ /* This must be a symbol reference .. */
+ if (! ieee_write_byte (abfd, ieee_external_reference_enum)
+ || ! ieee_write_int (abfd, reference_index)
+ || ! ieee_write_id (abfd, p->name))
+ return false;
+ p->value = reference_index;
+ reference_index++;
+ hadone = true;
+ }
+ else if (bfd_is_com_section (p->section))
+ {
+ /* This is a weak reference */
+ if (! ieee_write_byte (abfd, ieee_external_reference_enum)
+ || ! ieee_write_int (abfd, reference_index)
+ || ! ieee_write_id (abfd, p->name)
+ || ! ieee_write_byte (abfd,
+ ieee_weak_external_reference_enum)
+ || ! ieee_write_int (abfd, reference_index)
+ || ! ieee_write_int (abfd, p->value))
+ return false;
+ p->value = reference_index;
+ reference_index++;
+ hadone = true;
+ }
+ else if (p->flags & BSF_GLOBAL)
+ {
+ /* This must be a symbol definition */
+
+ if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
+ || ! ieee_write_int (abfd, public_index)
+ || ! ieee_write_id (abfd, p->name)
+ || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum)
+ || ! ieee_write_int (abfd, public_index)
+ || ! ieee_write_byte (abfd, 15) /* instruction address */
+ || ! ieee_write_byte (abfd, 19) /* static symbol */
+ || ! ieee_write_byte (abfd, 1)) /* one of them */
+ return false;
+
+ /* Write out the value */
+ if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
+ || ! ieee_write_int (abfd, public_index))
+ return false;
+ if (! bfd_is_abs_section (p->section))
+ {
+ if (abfd->flags & EXEC_P)
+ {
+ /* If fully linked, then output all symbols
+ relocated */
+ if (! (ieee_write_int
+ (abfd,
+ (p->value
+ + p->section->output_offset
+ + p->section->output_section->vma))))
+ return false;
+ }
+ else
+ {
+ if (! (ieee_write_expression
+ (abfd,
+ p->value + p->section->output_offset,
+ p->section->output_section->symbol,
+ false, 0)))
+ return false;
+ }
+ }
+ else
+ {
+ if (! ieee_write_expression (abfd,
+ p->value,
+ bfd_abs_section_ptr->symbol,
+ false, 0))
+ return false;
+ }
+ p->value = public_index;
+ public_index++;
+ hadone = true;
+ }
+ else
+ {
+ /* This can happen - when there are gaps in the symbols read */
+ /* from an input ieee file */
+ }
+ }
+ }
+ if (hadone)
+ ieee->w.r.external_part = here;
+
+ return true;
+}
+
+
+static CONST unsigned char exten[] =
+{
+ 0xf0, 0x20, 0x00,
+ 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
+ 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */
+ 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
+};
+
+static CONST unsigned char envi[] =
+{
+ 0xf0, 0x21, 0x00,
+
+/* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
+ 0x19, 0x2c,
+*/
+ 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */
+
+ 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */
+/* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
+};
+
+static boolean
+ieee_write_me_part (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ ieee->w.r.trailer_part = bfd_tell (abfd);
+ if (abfd->start_address)
+ {
+ if (! ieee_write_2bytes (abfd, ieee_value_starting_address_enum)
+ || ! ieee_write_byte (abfd, ieee_function_either_open_b_enum)
+ || ! ieee_write_int (abfd, abfd->start_address)
+ || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum))
+ return false;
+ }
+ ieee->w.r.me_record = bfd_tell (abfd);
+ if (! ieee_write_byte (abfd, ieee_module_end_enum))
+ return false;
+ return true;
+}
+
+/* Write out the IEEE processor ID. */
+
+static boolean
+ieee_write_processor (abfd)
+ bfd *abfd;
+{
+ const bfd_arch_info_type *arch;
+
+ arch = bfd_get_arch_info (abfd);
+ switch (arch->arch)
+ {
+ default:
+ if (! ieee_write_id (abfd, bfd_printable_name (abfd)))
+ return false;
+ break;
+
+ case bfd_arch_a29k:
+ if (! ieee_write_id (abfd, "29000"))
+ return false;
+ break;
+
+ case bfd_arch_h8300:
+ if (! ieee_write_id (abfd, "H8/300"))
+ return false;
+ break;
+
+ case bfd_arch_h8500:
+ if (! ieee_write_id (abfd, "H8/500"))
+ return false;
+ break;
+
+ case bfd_arch_i960:
+ switch (arch->mach)
+ {
+ default:
+ case bfd_mach_i960_core:
+ case bfd_mach_i960_ka_sa:
+ if (! ieee_write_id (abfd, "80960KA"))
+ return false;
+ break;
+
+ case bfd_mach_i960_kb_sb:
+ if (! ieee_write_id (abfd, "80960KB"))
+ return false;
+ break;
+
+ case bfd_mach_i960_ca:
+ if (! ieee_write_id (abfd, "80960CA"))
+ return false;
+ break;
+
+ case bfd_mach_i960_mc:
+ case bfd_mach_i960_xa:
+ if (! ieee_write_id (abfd, "80960MC"))
+ return false;
+ break;
+ }
+ break;
+
+ case bfd_arch_m68k:
+ {
+ const char *id;
+
+ switch (arch->mach)
+ {
+ default: id = "68020"; break;
+ case bfd_mach_m68000: id = "68000"; break;
+ case bfd_mach_m68008: id = "68008"; break;
+ case bfd_mach_m68010: id = "68010"; break;
+ case bfd_mach_m68020: id = "68020"; break;
+ case bfd_mach_m68030: id = "68030"; break;
+ case bfd_mach_m68040: id = "68040"; break;
+ case bfd_mach_m68060: id = "68060"; break;
+ case bfd_mach_cpu32: id = "cpu32"; break;
+ }
+
+ if (! ieee_write_id (abfd, id))
+ return false;
+ }
+ break;
+ }
+
+ return true;
+}
+
+boolean
+ieee_write_object_contents (abfd)
+ bfd *abfd;
+{
+ ieee_data_type *ieee = IEEE_DATA (abfd);
+ unsigned int i;
+ file_ptr old;
+
+ /* Fast forward over the header area */
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+
+ if (! ieee_write_byte (abfd, ieee_module_beginning_enum)
+ || ! ieee_write_processor (abfd)
+ || ! ieee_write_id (abfd, abfd->filename))
+ return false;
+
+ /* Fast forward over the variable bits */
+ if (! ieee_write_byte (abfd, ieee_address_descriptor_enum))
+ return false;
+
+ /* Bits per MAU */
+ if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd))))
+ return false;
+ /* MAU's per address */
+ if (! ieee_write_byte (abfd,
+ (bfd_byte) (bfd_arch_bits_per_address (abfd)
+ / bfd_arch_bits_per_byte (abfd))))
+ return false;
+
+ old = bfd_tell (abfd);
+ if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
+ return false;
+
+ ieee->w.r.extension_record = bfd_tell (abfd);
+ if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
+ return false;
+ if (abfd->flags & EXEC_P)
+ {
+ if (! ieee_write_byte (abfd, 0x1)) /* Absolute */
+ return false;
+ }
+ else
+ {
+ if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */
+ return false;
+ }
+
+ ieee->w.r.environmental_record = bfd_tell (abfd);
+ if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
+ return false;
+
+ /* The HP emulator database requires a timestamp in the file. */
+ {
+ time_t now;
+ const struct tm *t;
+
+ time (&now);
+ t = (struct tm *) localtime (&now);
+ if (! ieee_write_2bytes (abfd, (int) ieee_atn_record_enum)
+ || ! ieee_write_byte (abfd, 0x21)
+ || ! ieee_write_byte (abfd, 0)
+ || ! ieee_write_byte (abfd, 50)
+ || ! ieee_write_int (abfd, t->tm_year + 1900)
+ || ! ieee_write_int (abfd, t->tm_mon + 1)
+ || ! ieee_write_int (abfd, t->tm_mday)
+ || ! ieee_write_int (abfd, t->tm_hour)
+ || ! ieee_write_int (abfd, t->tm_min)
+ || ! ieee_write_int (abfd, t->tm_sec))
+ return false;
+ }
+
+ output_bfd = abfd;
+
+ flush ();
+
+ if (! ieee_write_section_part (abfd))
+ return false;
+ /* First write the symbols. This changes their values into table
+ indeces so we cant use it after this point. */
+ if (! ieee_write_external_part (abfd))
+ return false;
+
+ /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
+
+ /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
+
+
+ /* Write any debugs we have been told about. */
+ if (! ieee_write_debug_part (abfd))
+ return false;
+
+ /* Can only write the data once the symbols have been written, since
+ the data contains relocation information which points to the
+ symbols. */
+ if (! ieee_write_data_part (abfd))
+ return false;
+
+ /* At the end we put the end! */
+ if (! ieee_write_me_part (abfd))
+ return false;
+
+ /* Generate the header */
+ if (bfd_seek (abfd, old, SEEK_SET) != 0)
+ return false;
+
+ for (i = 0; i < N_W_VARIABLES; i++)
+ {
+ if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum)
+ || ! ieee_write_byte (abfd, (bfd_byte) i)
+ || ! ieee_write_int5_out (abfd, ieee->w.offset[i]))
+ return false;
+ }
+
+ return true;
+}
+
+/* Native-level interface to symbols. */
+
+/* We read the symbols into a buffer, which is discarded when this
+ function exits. We read the strings into a buffer large enough to
+ hold them all plus all the cached symbol entries. */
+
+asymbol *
+ieee_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ ieee_symbol_type *new =
+ (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type));
+ if (!new)
+ return NULL;
+ new->symbol.the_bfd = abfd;
+ return &new->symbol;
+}
+
+static bfd *
+ieee_openr_next_archived_file (arch, prev)
+ bfd *arch;
+ bfd *prev;
+{
+ ieee_ar_data_type *ar = IEEE_AR_DATA (arch);
+ /* take the next one from the arch state, or reset */
+ if (prev == (bfd *) NULL)
+ {
+ /* Reset the index - the first two entries are bogus*/
+ ar->element_index = 2;
+ }
+ while (true)
+ {
+ ieee_ar_obstack_type *p = ar->elements + ar->element_index;
+ ar->element_index++;
+ if (ar->element_index <= ar->element_count)
+ {
+ if (p->file_offset != (file_ptr) 0)
+ {
+ if (p->abfd == (bfd *) NULL)
+ {
+ p->abfd = _bfd_create_empty_archive_element_shell (arch);
+ p->abfd->origin = p->file_offset;
+ }
+ return p->abfd;
+ }
+ }
+ else
+ {
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return (bfd *) NULL;
+ }
+
+ }
+}
+
+static boolean
+ieee_find_nearest_line (abfd,
+ section,
+ symbols,
+ offset,
+ filename_ptr,
+ functionname_ptr,
+ line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ const char **filename_ptr;
+ const char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ return false;
+}
+
+static int
+ieee_generic_stat_arch_elt (abfd, buf)
+ bfd *abfd;
+ struct stat *buf;
+{
+ ieee_ar_data_type *ar = (ieee_ar_data_type *) NULL;
+ ieee_data_type *ieee;
+
+ if (abfd->my_archive != NULL)
+ ar = abfd->my_archive->tdata.ieee_ar_data;
+ if (ar == (ieee_ar_data_type *) NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ if (IEEE_DATA (abfd) == NULL)
+ {
+ if (ieee_object_p (abfd) == NULL)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return -1;
+ }
+ }
+
+ ieee = IEEE_DATA (abfd);
+
+ buf->st_size = ieee->w.r.me_record + 1;
+ buf->st_mode = 0644;
+ return 0;
+}
+
+static int
+ieee_sizeof_headers (abfd, x)
+ bfd *abfd;
+ boolean x;
+{
+ return 0;
+}
+
+
+/* The debug info routines are never used. */
+#if 0
+
+static void
+ieee_bfd_debug_info_start (abfd)
+ bfd *abfd;
+{
+
+}
+
+static void
+ieee_bfd_debug_info_end (abfd)
+ bfd *abfd;
+{
+
+}
+
+
+/* Add this section to the list of sections we have debug info for, to
+ be ready to output it at close time
+ */
+static void
+ieee_bfd_debug_info_accumulate (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ ieee_data_type *ieee = IEEE_DATA (section->owner);
+ ieee_data_type *output_ieee = IEEE_DATA (abfd);
+ /* can only accumulate data from other ieee bfds */
+ if (section->owner->xvec != abfd->xvec)
+ return;
+ /* Only bother once per bfd */
+ if (ieee->done_debug == true)
+ return;
+ ieee->done_debug = true;
+
+ /* Don't bother if there is no debug info */
+ if (ieee->w.r.debug_information_part == 0)
+ return;
+
+
+ /* Add to chain */
+ {
+ bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
+ if (!n)
+ abort (); /* FIXME */
+ n->this = section->owner;
+ n->next = (bfd_chain_type *) NULL;
+
+ if (output_ieee->chain_head)
+ {
+ output_ieee->chain_head->next = n;
+ }
+ else
+ {
+ output_ieee->chain_root = n;
+
+ }
+ output_ieee->chain_head = n;
+ }
+}
+
+#endif
+
+#define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
+#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+
+#define ieee_slurp_armap bfd_true
+#define ieee_slurp_extended_name_table bfd_true
+#define ieee_construct_extended_name_table \
+ ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
+ bfd_true)
+#define ieee_truncate_arname bfd_dont_truncate_arname
+#define ieee_write_armap \
+ ((boolean (*) \
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
+ bfd_true)
+#define ieee_read_ar_hdr bfd_nullvoidptr
+#define ieee_update_armap_timestamp bfd_true
+#define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
+
+#define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define ieee_get_lineno _bfd_nosymbols_get_lineno
+#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define ieee_read_minisymbols _bfd_generic_read_minisymbols
+#define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define ieee_set_arch_mach _bfd_generic_set_arch_mach
+
+#define ieee_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+#define ieee_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define ieee_bfd_relax_section bfd_generic_relax_section
+#define ieee_bfd_gc_sections bfd_generic_gc_sections
+#define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define ieee_bfd_final_link _bfd_generic_final_link
+#define ieee_bfd_link_split_section _bfd_generic_link_split_section
+
+/*SUPPRESS 460 */
+const bfd_target ieee_vec =
+{
+ "ieee", /* name */
+ bfd_target_ieee_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target,
+ ieee_object_p, /* bfd_check_format */
+ ieee_archive_p,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ ieee_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+ {
+ bfd_false,
+ ieee_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (ieee),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (ieee),
+ BFD_JUMP_TABLE_SYMBOLS (ieee),
+ BFD_JUMP_TABLE_RELOCS (ieee),
+ BFD_JUMP_TABLE_WRITE (ieee),
+ BFD_JUMP_TABLE_LINK (ieee),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/ihex.c b/bfd/ihex.c
new file mode 100644
index 00000000000..b9953d329f5
--- /dev/null
+++ b/bfd/ihex.c
@@ -0,0 +1,1041 @@
+/* BFD back-end for Intel Hex objects.
+ Copyright 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This is what Intel Hex files look like:
+
+1. INTEL FORMATS
+
+A. Intel 1
+
+ 16-bit address-field format, for files 64k bytes in length or less.
+
+ DATA RECORD
+ Byte 1 Header = colon(:)
+ 2..3 The number of data bytes in hex notation
+ 4..5 High byte of the record load address
+ 6..7 Low byte of the record load address
+ 8..9 Record type, must be "00"
+ 10..x Data bytes in hex notation:
+ x = (number of bytes - 1) * 2 + 11
+ x+1..x+2 Checksum in hex notation
+ x+3..x+4 Carriage return, line feed
+
+ END RECORD
+ Byte 1 Header = colon (:)
+ 2..3 The byte count, must be "00"
+ 4..7 Transfer-address (usually "0000")
+ the jump-to address, execution start address
+ 8..9 Record type, must be "01"
+ 10..11 Checksum, in hex notation
+ 12..13 Carriage return, line feed
+
+B. INTEL 2
+
+ MCS-86 format, using a 20-bit address for files larger than 64K bytes.
+
+ DATA RECORD
+ Byte 1 Header = colon (:)
+ 2..3 The byte count of this record, hex notation
+ 4..5 High byte of the record load address
+ 6..7 Low byte of the record load address
+ 8..9 Record type, must be "00"
+ 10..x The data bytes in hex notation:
+ x = (number of data bytes - 1) * 2 + 11
+ x+1..x+2 Checksum in hex notation
+ x+3..x+4 Carriage return, line feed
+
+ EXTENDED ADDRESS RECORD
+ Byte 1 Header = colon(:)
+ 2..3 The byte count, must be "02"
+ 4..7 Load address, must be "0000"
+ 8..9 Record type, must be "02"
+ 10..11 High byte of the offset address
+ 12..13 Low byte of the offset address
+ 14..15 Checksum in hex notation
+ 16..17 Carriage return, line feed
+
+ The checksums are the two's complement of the 8-bit sum
+ without carry of the byte count, offset address, and the
+ record type.
+
+ START ADDRESS RECORD
+ Byte 1 Header = colon (:)
+ 2..3 The byte count, must be "04"
+ 4..7 Load address, must be "0000"
+ 8..9 Record type, must be "03"
+ 10..13 8086 CS value
+ 14..17 8086 IP value
+ 18..19 Checksum in hex notation
+ 20..21 Carriage return, line feed
+
+Another document reports these additional types:
+
+ EXTENDED LINEAR ADDRESS RECORD
+ Byte 1 Header = colon (:)
+ 2..3 The byte count, must be "02"
+ 4..7 Load address, must be "0000"
+ 8..9 Record type, must be "04"
+ 10..13 Upper 16 bits of address of subsequent records
+ 14..15 Checksum in hex notation
+ 16..17 Carriage return, line feed
+
+ START LINEAR ADDRESS RECORD
+ Byte 1 Header = colon (:)
+ 2..3 The byte count, must be "02"
+ 4..7 Load address, must be "0000"
+ 8..9 Record type, must be "05"
+ 10..13 Upper 16 bits of start address
+ 14..15 Checksum in hex notation
+ 16..17 Carriage return, line feed
+
+The MRI compiler uses this, which is a repeat of type 5:
+
+ EXTENDED START RECORD
+ Byte 1 Header = colon (:)
+ 2..3 The byte count, must be "04"
+ 4..7 Load address, must be "0000"
+ 8..9 Record type, must be "05"
+ 10..13 Upper 16 bits of start address
+ 14..17 Lower 16 bits of start address
+ 18..19 Checksum in hex notation
+ 20..21 Carriage return, line feed
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libiberty.h"
+
+#include <ctype.h>
+
+static void ihex_init PARAMS ((void));
+static boolean ihex_mkobject PARAMS ((bfd *));
+static INLINE int ihex_get_byte PARAMS ((bfd *, boolean *));
+static void ihex_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
+static boolean ihex_scan PARAMS ((bfd *));
+static const bfd_target *ihex_object_p PARAMS ((bfd *));
+static boolean ihex_read_section PARAMS ((bfd *, asection *, bfd_byte *));
+static boolean ihex_get_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static boolean ihex_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static boolean ihex_write_record
+ PARAMS ((bfd *, bfd_size_type, bfd_vma, unsigned int, bfd_byte *));
+static boolean ihex_write_object_contents PARAMS ((bfd *));
+static asymbol *ihex_make_empty_symbol PARAMS ((bfd *));
+static boolean ihex_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+static int ihex_sizeof_headers PARAMS ((bfd *, boolean));
+
+/* The number of bytes we put on one line during output. */
+
+#define CHUNK (21)
+
+/* Macros for converting between hex and binary. */
+
+#define NIBBLE(x) (hex_value (x))
+#define HEX2(buffer) ((NIBBLE ((buffer)[0]) << 4) + NIBBLE ((buffer)[1]))
+#define HEX4(buffer) ((HEX2 (buffer) << 8) + HEX2 ((buffer) + 2))
+#define ISHEX(x) (hex_p (x))
+
+/* When we write out an ihex value, the values can not be output as
+ they are seen. Instead, we hold them in memory in this structure. */
+
+struct ihex_data_list
+{
+ struct ihex_data_list *next;
+ bfd_byte *data;
+ bfd_vma where;
+ bfd_size_type size;
+};
+
+/* The ihex tdata information. */
+
+struct ihex_data_struct
+{
+ struct ihex_data_list *head;
+ struct ihex_data_list *tail;
+};
+
+/* Initialize by filling in the hex conversion array. */
+
+static void
+ihex_init ()
+{
+ static boolean inited;
+
+ if (! inited)
+ {
+ inited = true;
+ hex_init ();
+ }
+}
+
+/* Create an ihex object. */
+
+static boolean
+ihex_mkobject (abfd)
+ bfd *abfd;
+{
+ if (abfd->tdata.ihex_data == NULL)
+ {
+ struct ihex_data_struct *tdata;
+
+ tdata = ((struct ihex_data_struct *)
+ bfd_alloc (abfd, sizeof (struct ihex_data_struct)));
+ if (tdata == NULL)
+ return false;
+ abfd->tdata.ihex_data = tdata;
+ tdata->head = NULL;
+ tdata->tail = NULL;
+ }
+
+ return true;
+}
+
+/* Read a byte from a BFD. Set *ERRORPTR if an error occurred.
+ Return EOF on error or end of file. */
+
+static INLINE int
+ihex_get_byte (abfd, errorptr)
+ bfd *abfd;
+ boolean *errorptr;
+{
+ bfd_byte c;
+
+ if (bfd_read (&c, 1, 1, abfd) != 1)
+ {
+ if (bfd_get_error () != bfd_error_file_truncated)
+ *errorptr = true;
+ return EOF;
+ }
+
+ return (int) (c & 0xff);
+}
+
+/* Report a problem in an Intel Hex file. */
+
+static void
+ihex_bad_byte (abfd, lineno, c, error)
+ bfd *abfd;
+ unsigned int lineno;
+ int c;
+ boolean error;
+{
+ if (c == EOF)
+ {
+ if (! error)
+ bfd_set_error (bfd_error_file_truncated);
+ }
+ else
+ {
+ char buf[10];
+
+ if (! isprint (c))
+ sprintf (buf, "\\%03o", (unsigned int) c);
+ else
+ {
+ buf[0] = c;
+ buf[1] = '\0';
+ }
+ (*_bfd_error_handler)
+ (_("%s:%d: unexpected character `%s' in Intel Hex file\n"),
+ bfd_get_filename (abfd), lineno, buf);
+ bfd_set_error (bfd_error_bad_value);
+ }
+}
+
+/* Read an Intel hex file and turn it into sections. We create a new
+ section for each contiguous set of bytes. */
+
+static boolean
+ihex_scan (abfd)
+ bfd *abfd;
+{
+ bfd_vma segbase;
+ bfd_vma extbase;
+ asection *sec;
+ int lineno;
+ boolean error;
+ bfd_byte *buf = NULL;
+ size_t bufsize;
+ int c;
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto error_return;
+
+ abfd->start_address = 0;
+
+ segbase = 0;
+ extbase = 0;
+ sec = NULL;
+ lineno = 1;
+ error = false;
+ bufsize = 0;
+ while ((c = ihex_get_byte (abfd, &error)) != EOF)
+ {
+ if (c == '\r')
+ continue;
+ else if (c == '\n')
+ {
+ ++lineno;
+ continue;
+ }
+ else if (c != ':')
+ {
+ ihex_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+ else
+ {
+ file_ptr pos;
+ char hdr[8];
+ unsigned int i;
+ unsigned int len;
+ bfd_vma addr;
+ unsigned int type;
+ unsigned int chars;
+ unsigned int chksum;
+
+ /* This is a data record. */
+
+ pos = bfd_tell (abfd) - 1;
+
+ /* Read the header bytes. */
+
+ if (bfd_read (hdr, 1, 8, abfd) != 8)
+ goto error_return;
+
+ for (i = 0; i < 8; i++)
+ {
+ if (! ISHEX (hdr[i]))
+ {
+ ihex_bad_byte (abfd, lineno, hdr[i], error);
+ goto error_return;
+ }
+ }
+
+ len = HEX2 (hdr);
+ addr = HEX4 (hdr + 2);
+ type = HEX2 (hdr + 6);
+
+ /* Read the data bytes. */
+
+ chars = len * 2 + 2;
+ if (chars >= bufsize)
+ {
+ buf = (bfd_byte *) bfd_realloc (buf, chars);
+ if (buf == NULL)
+ goto error_return;
+ bufsize = chars;
+ }
+
+ if (bfd_read (buf, 1, chars, abfd) != chars)
+ goto error_return;
+
+ for (i = 0; i < chars; i++)
+ {
+ if (! ISHEX (buf[i]))
+ {
+ ihex_bad_byte (abfd, lineno, hdr[i], error);
+ goto error_return;
+ }
+ }
+
+ /* Check the checksum. */
+ chksum = len + addr + (addr >> 8) + type;
+ for (i = 0; i < len; i++)
+ chksum += HEX2 (buf + 2 * i);
+ if (((- chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i))
+ {
+ (*_bfd_error_handler)
+ (_("%s:%d: bad checksum in Intel Hex file (expected %u, found %u)"),
+ bfd_get_filename (abfd), lineno,
+ (- chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i));
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ switch (type)
+ {
+ case 0:
+ /* This is a data record. */
+ if (sec != NULL
+ && sec->vma + sec->_raw_size == extbase + segbase + addr)
+ {
+ /* This data goes at the end of the section we are
+ currently building. */
+ sec->_raw_size += len;
+ }
+ else if (len > 0)
+ {
+ char secbuf[20];
+ char *secname;
+
+ sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
+ secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
+ if (secname == NULL)
+ goto error_return;
+ strcpy (secname, secbuf);
+ sec = bfd_make_section (abfd, secname);
+ if (sec == NULL)
+ goto error_return;
+ sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
+ sec->vma = extbase + segbase + addr;
+ sec->lma = extbase + segbase + addr;
+ sec->_raw_size = len;
+ sec->filepos = pos;
+ }
+ break;
+
+ case 1:
+ /* An end record. */
+ if (abfd->start_address == 0)
+ abfd->start_address = addr;
+ if (buf != NULL)
+ free (buf);
+ return true;
+
+ case 2:
+ /* An extended address record. */
+ if (len != 2)
+ {
+ (*_bfd_error_handler)
+ (_("%s:%d: bad extended address record length in Intel Hex file"),
+ bfd_get_filename (abfd), lineno);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ segbase = HEX4 (buf) << 4;
+
+ sec = NULL;
+
+ break;
+
+ case 3:
+ /* An extended start address record. */
+ if (len != 4)
+ {
+ (*_bfd_error_handler)
+ (_("%s:%d: bad extended start address length in Intel Hex file"),
+ bfd_get_filename (abfd), lineno);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ abfd->start_address += (HEX4 (buf) << 4) + HEX4 (buf + 4);
+
+ sec = NULL;
+
+ break;
+
+ case 4:
+ /* An extended linear address record. */
+ if (len != 2)
+ {
+ (*_bfd_error_handler)
+ (_("%s:%d: bad extended linear address record length in Intel Hex file"),
+ bfd_get_filename (abfd), lineno);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ extbase = HEX4 (buf) << 16;
+
+ sec = NULL;
+
+ break;
+
+ case 5:
+ /* An extended linear start address record. */
+ if (len != 2 && len != 4)
+ {
+ (*_bfd_error_handler)
+ (_("%s:%d: bad extended linear start address length in Intel Hex file"),
+ bfd_get_filename (abfd), lineno);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ if (len == 2)
+ abfd->start_address += HEX4 (buf) << 16;
+ else
+ abfd->start_address = (HEX4 (buf) << 16) + HEX4 (buf + 4);
+
+ sec = NULL;
+
+ break;
+
+ default:
+ (*_bfd_error_handler)
+ (_("%s:%d: unrecognized ihex type %u in Intel Hex file\n"),
+ bfd_get_filename (abfd), lineno, type);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ }
+ }
+
+ if (error)
+ goto error_return;
+
+ if (buf != NULL)
+ free (buf);
+
+ return true;
+
+ error_return:
+ if (buf != NULL)
+ free (buf);
+ return false;
+}
+
+/* Try to recognize an Intel Hex file. */
+
+static const bfd_target *
+ihex_object_p (abfd)
+ bfd *abfd;
+{
+ bfd_byte b[9];
+ unsigned int i;
+ unsigned int type;
+
+ ihex_init ();
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return NULL;
+ if (bfd_read (b, 1, 9, abfd) != 9)
+ {
+ if (bfd_get_error () == bfd_error_file_truncated)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (b[0] != ':')
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ for (i = 1; i < 9; i++)
+ {
+ if (! ISHEX (b[i]))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ }
+
+ type = HEX2 (b + 7);
+ if (type > 5)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* OK, it looks like it really is an Intel Hex file. */
+
+ if (! ihex_mkobject (abfd)
+ || ! ihex_scan (abfd))
+ return NULL;
+
+ return abfd->xvec;
+}
+
+/* Read the contents of a section in an Intel Hex file. */
+
+static boolean
+ihex_read_section (abfd, section, contents)
+ bfd *abfd;
+ asection *section;
+ bfd_byte *contents;
+{
+ int c;
+ bfd_byte *p;
+ bfd_byte *buf = NULL;
+ size_t bufsize;
+ boolean error;
+
+ if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
+ goto error_return;
+
+ p = contents;
+ bufsize = 0;
+ error = false;
+ while ((c = ihex_get_byte (abfd, &error)) != EOF)
+ {
+ char hdr[8];
+ unsigned int len;
+ bfd_vma addr;
+ unsigned int type;
+ unsigned int i;
+
+ if (c == '\r' || c == '\n')
+ continue;
+
+ /* This is called after ihex_scan has succeeded, so we ought to
+ know the exact format. */
+ BFD_ASSERT (c == ':');
+
+ if (bfd_read (hdr, 1, 8, abfd) != 8)
+ goto error_return;
+
+ len = HEX2 (hdr);
+ addr = HEX4 (hdr + 2);
+ type = HEX2 (hdr + 6);
+
+ /* We should only see type 0 records here. */
+ if (type != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: internal error in ihex_read_section"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ if (len * 2 > bufsize)
+ {
+ buf = (bfd_byte *) bfd_realloc (buf, len * 2);
+ if (buf == NULL)
+ goto error_return;
+ bufsize = len * 2;
+ }
+
+ if (bfd_read (buf, 1, len * 2, abfd) != len * 2)
+ goto error_return;
+
+ for (i = 0; i < len; i++)
+ *p++ = HEX2 (buf + 2 * i);
+ if ((bfd_size_type) (p - contents) >= section->_raw_size)
+ {
+ /* We've read everything in the section. */
+ if (buf != NULL)
+ free (buf);
+ return true;
+ }
+
+ /* Skip the checksum. */
+ if (bfd_read (buf, 1, 2, abfd) != 2)
+ goto error_return;
+ }
+
+ if ((bfd_size_type) (p - contents) < section->_raw_size)
+ {
+ (*_bfd_error_handler)
+ (_("%s: bad section length in ihex_read_section"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ if (buf != NULL)
+ free (buf);
+
+ return true;
+
+ error_return:
+ if (buf != NULL)
+ free (buf);
+ return false;
+}
+
+/* Get the contents of a section in an Intel Hex file. */
+
+static boolean
+ihex_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (section->used_by_bfd == NULL)
+ {
+ section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
+ if (section->used_by_bfd == NULL)
+ return false;
+ if (! ihex_read_section (abfd, section, section->used_by_bfd))
+ return false;
+ }
+
+ memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
+ (size_t) count);
+
+ return true;
+}
+
+/* Set the contents of a section in an Intel Hex file. */
+
+static boolean
+ihex_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ struct ihex_data_list *n;
+ bfd_byte *data;
+ struct ihex_data_struct *tdata;
+
+ if (count == 0
+ || (section->flags & SEC_ALLOC) == 0
+ || (section->flags & SEC_LOAD) == 0)
+ return true;
+
+ n = ((struct ihex_data_list *)
+ bfd_alloc (abfd, sizeof (struct ihex_data_list)));
+ if (n == NULL)
+ return false;
+
+ data = (bfd_byte *) bfd_alloc (abfd, count);
+ if (data == NULL)
+ return false;
+ memcpy (data, location, (size_t) count);
+
+ n->data = data;
+ n->where = section->lma + offset;
+ n->size = count;
+
+ /* Sort the records by address. Optimize for the common case of
+ adding a record to the end of the list. */
+ tdata = abfd->tdata.ihex_data;
+ if (tdata->tail != NULL
+ && n->where >= tdata->tail->where)
+ {
+ tdata->tail->next = n;
+ n->next = NULL;
+ tdata->tail = n;
+ }
+ else
+ {
+ register struct ihex_data_list **pp;
+
+ for (pp = &tdata->head;
+ *pp != NULL && (*pp)->where < n->where;
+ pp = &(*pp)->next)
+ ;
+ n->next = *pp;
+ *pp = n;
+ if (n->next == NULL)
+ tdata->tail = n;
+ }
+
+ return true;
+}
+
+/* Write a record out to an Intel Hex file. */
+
+static boolean
+ihex_write_record (abfd, count, addr, type, data)
+ bfd *abfd;
+ bfd_size_type count;
+ bfd_vma addr;
+ unsigned int type;
+ bfd_byte *data;
+{
+ static const char digs[] = "0123456789ABCDEF";
+ char buf[9 + CHUNK * 2 + 4];
+ char *p;
+ unsigned int chksum;
+ unsigned int i;
+
+#define TOHEX(buf, v) \
+ ((buf)[0] = digs[((v) >> 4) & 0xf], (buf)[1] = digs[(v) & 0xf])
+
+ buf[0] = ':';
+ TOHEX (buf + 1, count);
+ TOHEX (buf + 3, (addr >> 8) & 0xff);
+ TOHEX (buf + 5, addr & 0xff);
+ TOHEX (buf + 7, type);
+
+ chksum = count + addr + (addr >> 8) + type;
+
+ for (i = 0, p = buf + 9; i < count; i++, p += 2, data++)
+ {
+ TOHEX (p, *data);
+ chksum += *data;
+ }
+
+ TOHEX (p, (- chksum) & 0xff);
+ p[2] = '\r';
+ p[3] = '\n';
+
+ if (bfd_write (buf, 1, 9 + count * 2 + 4, abfd) != 9 + count * 2 + 4)
+ return false;
+
+ return true;
+}
+
+/* Write out an Intel Hex file. */
+
+static boolean
+ihex_write_object_contents (abfd)
+ bfd *abfd;
+{
+ bfd_vma segbase;
+ bfd_vma extbase;
+ struct ihex_data_list *l;
+
+ segbase = 0;
+ extbase = 0;
+ for (l = abfd->tdata.ihex_data->head; l != NULL; l = l->next)
+ {
+ bfd_vma where;
+ bfd_byte *p;
+ bfd_size_type count;
+
+ where = l->where;
+ p = l->data;
+ count = l->size;
+ while (count > 0)
+ {
+ bfd_size_type now;
+
+ now = count;
+ if (now > CHUNK)
+ now = CHUNK;
+
+ if (where > segbase + extbase + 0xffff)
+ {
+ bfd_byte addr[2];
+
+ /* We need a new base address. */
+ if (where <= 0xfffff)
+ {
+ /* The addresses should be sorted. */
+ BFD_ASSERT (extbase == 0);
+
+ segbase = where & 0xf0000;
+ addr[0] = (bfd_byte)(segbase >> 12) & 0xff;
+ addr[1] = (bfd_byte)(segbase >> 4) & 0xff;
+ if (! ihex_write_record (abfd, 2, 0, 2, addr))
+ return false;
+ }
+ else
+ {
+ /* The extended address record and the extended
+ linear address record are combined, at least by
+ some readers. We need an extended linear address
+ record here, so if we've already written out an
+ extended address record, zero it out to avoid
+ confusion. */
+ if (segbase != 0)
+ {
+ addr[0] = 0;
+ addr[1] = 0;
+ if (! ihex_write_record (abfd, 2, 0, 2, addr))
+ return false;
+ segbase = 0;
+ }
+
+ extbase = where & 0xffff0000;
+ if (where > extbase + 0xffff)
+ {
+ char buf[20];
+
+ sprintf_vma (buf, where);
+ (*_bfd_error_handler)
+ (_("%s: address 0x%s out of range for Intex Hex file"),
+ bfd_get_filename (abfd), buf);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ addr[0] = (bfd_byte)(extbase >> 24) & 0xff;
+ addr[1] = (bfd_byte)(extbase >> 16) & 0xff;
+ if (! ihex_write_record (abfd, 2, 0, 4, addr))
+ return false;
+ }
+ }
+
+ if (! ihex_write_record (abfd, now, where - (extbase + segbase),
+ 0, p))
+ return false;
+
+ where += now;
+ p += now;
+ count -= now;
+ }
+ }
+
+ if (abfd->start_address != 0)
+ {
+ bfd_vma start;
+ bfd_byte startbuf[4];
+
+ start = abfd->start_address;
+
+ if (start <= 0xfffff)
+ {
+ startbuf[0] = (bfd_byte)((start & 0xf0000) >> 12) & 0xff;
+ startbuf[1] = 0;
+ startbuf[2] = (bfd_byte)(start >> 8) & 0xff;
+ startbuf[3] = (bfd_byte)start & 0xff;
+ if (! ihex_write_record (abfd, 4, 0, 3, startbuf))
+ return false;
+ }
+ else
+ {
+ startbuf[0] = (bfd_byte)(start >> 24) & 0xff;
+ startbuf[1] = (bfd_byte)(start >> 16) & 0xff;
+ startbuf[2] = (bfd_byte)(start >> 8) & 0xff;
+ startbuf[3] = (bfd_byte)start & 0xff;
+ if (! ihex_write_record (abfd, 4, 0, 5, startbuf))
+ return false;
+ }
+ }
+
+ if (! ihex_write_record (abfd, 0, 0, 1, NULL))
+ return false;
+
+ return true;
+}
+
+/* Make an empty symbol. This is required only because
+ bfd_make_section_anyway wants to create a symbol for the section. */
+
+static asymbol *
+ihex_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new != NULL)
+ new->the_bfd = abfd;
+ return new;
+}
+
+/* Set the architecture for the output file. The architecture is
+ irrelevant, so we ignore errors about unknown architectures. */
+
+static boolean
+ihex_set_arch_mach (abfd, arch, mach)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long mach;
+{
+ if (! bfd_default_set_arch_mach (abfd, arch, mach))
+ {
+ if (arch != bfd_arch_unknown)
+ return false;
+ }
+ return true;
+}
+
+/* Get the size of the headers, for the linker. */
+
+/*ARGSUSED*/
+static int
+ihex_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+/* Some random definitions for the target vector. */
+
+#define ihex_close_and_cleanup _bfd_generic_close_and_cleanup
+#define ihex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define ihex_new_section_hook _bfd_generic_new_section_hook
+#define ihex_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#define ihex_get_symtab_upper_bound bfd_0l
+#define ihex_get_symtab \
+ ((long (*) PARAMS ((bfd *, asymbol **))) bfd_0l)
+#define ihex_print_symbol _bfd_nosymbols_print_symbol
+#define ihex_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define ihex_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define ihex_get_lineno _bfd_nosymbols_get_lineno
+#define ihex_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define ihex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define ihex_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define ihex_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+#define ihex_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
+#define ihex_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
+#define ihex_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define ihex_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define ihex_bfd_relax_section bfd_generic_relax_section
+#define ihex_bfd_gc_sections bfd_generic_gc_sections
+#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define ihex_bfd_final_link _bfd_generic_final_link
+#define ihex_bfd_link_split_section _bfd_generic_link_split_section
+
+/* The Intel Hex target vector. */
+
+const bfd_target ihex_vec =
+{
+ "ihex", /* name */
+ bfd_target_ihex_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ 0, /* object flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ ihex_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ ihex_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ ihex_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (ihex),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (ihex),
+ BFD_JUMP_TABLE_RELOCS (ihex),
+ BFD_JUMP_TABLE_WRITE (ihex),
+ BFD_JUMP_TABLE_LINK (ihex),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/init.c b/bfd/init.c
new file mode 100644
index 00000000000..1fa1d505bee
--- /dev/null
+++ b/bfd/init.c
@@ -0,0 +1,50 @@
+/* bfd initialization stuff
+ Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/*
+SECTION
+ Initialization
+
+ These are the functions that handle initializing a BFD.
+*/
+
+/*
+FUNCTION
+ bfd_init
+
+SYNOPSIS
+ void bfd_init(void);
+
+DESCRIPTION
+ This routine must be called before any other BFD function to
+ initialize magical internal data structures.
+*/
+
+/* Actually, there is currently nothing for this function to do.
+ However, someday it may be needed, so keep it around. */
+
+void
+bfd_init ()
+{
+}
diff --git a/bfd/irix-core.c b/bfd/irix-core.c
new file mode 100644
index 00000000000..964ca20eac5
--- /dev/null
+++ b/bfd/irix-core.c
@@ -0,0 +1,276 @@
+/* BFD back-end for Irix core files.
+ Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Stu Grossman, Cygnus Support.
+ Converted to back-end form 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file can only be compiled on systems which use Irix style core
+ files (namely, Irix 4 and Irix 5, so far). */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#ifdef IRIX_CORE
+
+#include <core.out.h>
+
+struct sgi_core_struct
+{
+ int sig;
+ char cmd[CORE_NAMESIZE];
+};
+
+#define core_hdr(bfd) ((bfd)->tdata.sgi_core_data)
+#define core_signal(bfd) (core_hdr(bfd)->sig)
+#define core_command(bfd) (core_hdr(bfd)->cmd)
+
+static asection *make_bfd_asection
+ PARAMS ((bfd *, CONST char *, flagword, bfd_size_type, bfd_vma, file_ptr));
+static const bfd_target *irix_core_core_file_p PARAMS ((bfd *));
+static char *irix_core_core_file_failing_command PARAMS ((bfd *));
+static int irix_core_core_file_failing_signal PARAMS ((bfd *));
+static boolean irix_core_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
+static asymbol *irix_core_make_empty_symbol PARAMS ((bfd *));
+static void swap_abort PARAMS ((void));
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
+ bfd *abfd;
+ CONST char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ bfd_vma vma;
+ file_ptr filepos;
+{
+ asection *asect;
+
+ asect = bfd_make_section_anyway (abfd, name);
+ if (!asect)
+ return NULL;
+
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->vma = vma;
+ asect->filepos = filepos;
+ asect->alignment_power = 4;
+
+ return asect;
+}
+
+static const bfd_target *
+irix_core_core_file_p (abfd)
+ bfd *abfd;
+{
+ int val;
+ int i;
+ char *secname;
+ struct coreout coreout;
+ struct idesc *idg, *idf, *ids;
+
+ val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd);
+ if (val != sizeof coreout)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+#ifndef CORE_MAGICN32
+#define CORE_MAGICN32 CORE_MAGIC
+#endif
+ if ((coreout.c_magic != CORE_MAGIC && coreout.c_magic != CORE_MAGICN32)
+ || coreout.c_version != CORE_VERSION1)
+ return 0;
+
+ core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, sizeof (struct sgi_core_struct));
+ if (!core_hdr (abfd))
+ return NULL;
+
+ strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE);
+ core_signal (abfd) = coreout.c_sigcause;
+
+ if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
+ return NULL;
+
+ for (i = 0; i < coreout.c_nvmap; i++)
+ {
+ struct vmap vmap;
+
+ val = bfd_read ((PTR)&vmap, 1, sizeof vmap, abfd);
+ if (val != sizeof vmap)
+ break;
+
+ switch (vmap.v_type)
+ {
+ case VDATA:
+ secname = ".data";
+ break;
+ case VSTACK:
+ secname = ".stack";
+ break;
+#ifdef VMAPFILE
+ case VMAPFILE:
+ secname = ".mapfile";
+ break;
+#endif
+ default:
+ continue;
+ }
+
+ /* A file offset of zero means that the section is not contained
+ in the corefile. */
+ if (vmap.v_offset == 0)
+ continue;
+
+ if (!make_bfd_asection (abfd, secname,
+ SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
+ vmap.v_len,
+ vmap.v_vaddr,
+ vmap.v_offset))
+ return NULL;
+ }
+
+ /* Make sure that the regs are contiguous within the core file. */
+
+ idg = &coreout.c_idesc[I_GPREGS];
+ idf = &coreout.c_idesc[I_FPREGS];
+ ids = &coreout.c_idesc[I_SPECREGS];
+
+ if (idg->i_offset + idg->i_len != idf->i_offset
+ || idf->i_offset + idf->i_len != ids->i_offset)
+ return 0; /* Can't deal with non-contig regs */
+
+ if (bfd_seek (abfd, idg->i_offset, SEEK_SET) != 0)
+ return NULL;
+
+ make_bfd_asection (abfd, ".reg",
+ SEC_HAS_CONTENTS,
+ idg->i_len + idf->i_len + ids->i_len,
+ 0,
+ idg->i_offset);
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ return abfd->xvec;
+}
+
+static char *
+irix_core_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_command (abfd);
+}
+
+static int
+irix_core_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_signal (abfd);
+}
+
+static boolean
+irix_core_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* XXX - FIXME */
+}
+
+static asymbol *
+irix_core_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+#define irix_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define irix_core_get_symtab _bfd_nosymbols_get_symtab
+#define irix_core_print_symbol _bfd_nosymbols_print_symbol
+#define irix_core_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define irix_core_bfd_is_local_label_name \
+ _bfd_nosymbols_bfd_is_local_label_name
+#define irix_core_get_lineno _bfd_nosymbols_get_lineno
+#define irix_core_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define irix_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define irix_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define irix_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target irix_core_vec =
+ {
+ "irix-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ irix_core_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (irix_core),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (irix_core),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
+
+#endif /* IRIX_CORE */
diff --git a/bfd/libaout.h b/bfd/libaout.h
new file mode 100644
index 00000000000..7001d3dc6d4
--- /dev/null
+++ b/bfd/libaout.h
@@ -0,0 +1,624 @@
+/* BFD back-end data structures for a.out (and similar) files.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef LIBAOUT_H
+#define LIBAOUT_H
+
+/* We try to encapsulate the differences in the various a.out file
+ variants in a few routines, and otherwise share large masses of code.
+ This means we only have to fix bugs in one place, most of the time. */
+
+#include "bfdlink.h"
+
+/* Parameterize the a.out code based on whether it is being built
+ for a 32-bit architecture or a 64-bit architecture. */
+#if ARCH_SIZE==64
+#define GET_WORD bfd_h_get_64
+#define GET_SWORD bfd_h_get_signed_64
+#define PUT_WORD bfd_h_put_64
+#ifndef NAME
+#define NAME(x,y) CAT3(x,_64_,y)
+#endif
+#define JNAME(x) CAT(x,_64)
+#define BYTES_IN_WORD 8
+#else /* ARCH_SIZE == 32 */
+#define GET_WORD bfd_h_get_32
+#define GET_SWORD bfd_h_get_signed_32
+#define PUT_WORD bfd_h_put_32
+#ifndef NAME
+#define NAME(x,y) CAT3(x,_32_,y)
+#endif
+#define JNAME(x) CAT(x,_32)
+#define BYTES_IN_WORD 4
+#endif /* ARCH_SIZE==32 */
+
+/* Declare at file level, since used in parameter lists, which have
+ weird scope. */
+struct external_exec;
+struct external_nlist;
+struct reloc_ext_external;
+struct reloc_std_external;
+
+/* a.out backend linker hash table entries. */
+
+struct aout_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+ /* Whether this symbol has been written out. */
+ boolean written;
+ /* Symbol index in output file. */
+ int indx;
+};
+
+/* a.out backend linker hash table. */
+
+struct aout_link_hash_table
+{
+ struct bfd_link_hash_table root;
+};
+
+/* Look up an entry in an a.out link hash table. */
+
+#define aout_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct aout_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
+
+/* Traverse an a.out link hash table. */
+
+#define aout_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the a.out link hash table from the info structure. This is
+ just a cast. */
+
+#define aout_hash_table(p) ((struct aout_link_hash_table *) ((p)->hash))
+
+/* Back-end information for various a.out targets. */
+struct aout_backend_data
+{
+ /* Are ZMAGIC files mapped contiguously? If so, the text section may
+ need more padding, if the segment size (granularity for memory access
+ control) is larger than the page size. */
+ unsigned char zmagic_mapped_contiguous;
+ /* If this flag is set, ZMAGIC/NMAGIC file headers get mapped in with the
+ text section, which starts immediately after the file header.
+ If not, the text section starts on the next page. */
+ unsigned char text_includes_header;
+
+ /* If this flag is set, then if the entry address is not in the
+ first SEGMENT_SIZE bytes of the text section, it is taken to be
+ the address of the start of the text section. This can be useful
+ for kernels. */
+ unsigned char entry_is_text_address;
+
+ /* The value to pass to N_SET_FLAGS. */
+ unsigned char exec_hdr_flags;
+
+ /* If the text section VMA isn't specified, and we need an absolute
+ address, use this as the default. If we're producing a relocatable
+ file, zero is always used. */
+ /* ?? Perhaps a callback would be a better choice? Will this do anything
+ reasonable for a format that handles multiple CPUs with different
+ load addresses for each? */
+ bfd_vma default_text_vma;
+
+ /* Callback for setting the page and segment sizes, if they can't be
+ trivially determined from the architecture. */
+ boolean (*set_sizes) PARAMS ((bfd *));
+
+ /* zmagic files only. For go32, the length of the exec header contributes
+ to the size of the text section in the file for alignment purposes but
+ does *not* get counted in the length of the text section. */
+ unsigned char exec_header_not_counted;
+
+ /* Callback from the add symbols phase of the linker code to handle
+ a dynamic object. */
+ boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *,
+ struct external_nlist **,
+ bfd_size_type *, char **));
+
+ /* Callback from the add symbols phase of the linker code to handle
+ adding a single symbol to the global linker hash table. */
+ boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
+ const char *, flagword, asection *,
+ bfd_vma, const char *, boolean,
+ boolean,
+ struct bfd_link_hash_entry **));
+
+ /* Called to handle linking a dynamic object. */
+ boolean (*link_dynamic_object) PARAMS ((struct bfd_link_info *, bfd *));
+
+ /* Called for each global symbol being written out by the linker.
+ This should write out the dynamic symbol information. */
+ boolean (*write_dynamic_symbol) PARAMS ((bfd *, struct bfd_link_info *,
+ struct aout_link_hash_entry *));
+
+ /* If this callback is not NULL, the linker calls it for each reloc.
+ RELOC is a pointer to the unswapped reloc. If *SKIP is set to
+ true, the reloc will be skipped. *RELOCATION may be changed to
+ change the effects of the relocation. */
+ boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *info,
+ bfd *input_bfd,
+ asection *input_section,
+ struct aout_link_hash_entry *h,
+ PTR reloc, bfd_byte *contents,
+ boolean *skip,
+ bfd_vma *relocation));
+
+ /* Called at the end of a link to finish up any dynamic linking
+ information. */
+ boolean (*finish_dynamic_link) PARAMS ((bfd *, struct bfd_link_info *));
+};
+#define aout_backend_info(abfd) \
+ ((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
+
+/* This is the layout in memory of a "struct exec" while we process it.
+ All 'lengths' are given as a number of bytes.
+ All 'alignments' are for relinkable files only; an alignment of
+ 'n' indicates the corresponding segment must begin at an
+ address that is a multiple of (2**n). */
+
+struct internal_exec
+{
+ long a_info; /* Magic number and flags, packed */
+ bfd_vma a_text; /* length of text, in bytes */
+ bfd_vma a_data; /* length of data, in bytes */
+ bfd_vma a_bss; /* length of uninitialized data area in mem */
+ bfd_vma a_syms; /* length of symbol table data in file */
+ bfd_vma a_entry; /* start address */
+ bfd_vma a_trsize; /* length of text's relocation info, in bytes */
+ bfd_vma a_drsize; /* length of data's relocation info, in bytes */
+ /* Added for i960 */
+ bfd_vma a_tload; /* Text runtime load address */
+ bfd_vma a_dload; /* Data runtime load address */
+ unsigned char a_talign; /* Alignment of text segment */
+ unsigned char a_dalign; /* Alignment of data segment */
+ unsigned char a_balign; /* Alignment of bss segment */
+ char a_relaxable; /* Enough info for linker relax */
+};
+
+/* Magic number is written
+< MSB >
+3130292827262524232221201918171615141312111009080706050403020100
+< FLAGS >< MACHINE TYPE >< MAGIC NUMBER >
+*/
+/* Magic number for NetBSD is
+<MSB >
+3130292827262524232221201918171615141312111009080706050403020100
+< FLAGS >< MACHINE TYPE >< MAGIC NUMBER >
+*/
+
+enum machine_type {
+ M_UNKNOWN = 0,
+ M_68010 = 1,
+ M_68020 = 2,
+ M_SPARC = 3,
+ /* skip a bunch so we don't run into any of suns numbers */
+ /* make these up for the ns32k*/
+ M_NS32032 = (64), /* ns32032 running ? */
+ M_NS32532 = (64 + 5), /* ns32532 running mach */
+
+ M_386 = 100,
+ M_29K = 101, /* AMD 29000 */
+ M_386_DYNIX = 102, /* Sequent running dynix */
+ M_ARM = 103, /* Advanced Risc Machines ARM */
+ M_SPARCLET = 131, /* SPARClet = M_SPARC + 128 */
+ M_386_NETBSD = 134, /* NetBSD/i386 binary */
+ M_68K_NETBSD = 135, /* NetBSD/m68k binary */
+ M_68K4K_NETBSD = 136, /* NetBSD/m68k4k binary */
+ M_532_NETBSD = 137, /* NetBSD/ns32k binary */
+ M_SPARC_NETBSD = 138, /* NetBSD/sparc binary */
+ M_PMAX_NETBSD = 139, /* NetBSD/pmax (MIPS little-endian) binary */
+ M_VAX_NETBSD = 140, /* NetBSD/vax binary */
+ M_ALPHA_NETBSD = 141, /* NetBSD/alpha binary */
+ M_ARM6_NETBSD = 143, /* NetBSD/arm32 binary */
+ M_SPARCLET_1 = 147, /* 0x93, reserved */
+ M_MIPS1 = 151, /* MIPS R2000/R3000 binary */
+ M_MIPS2 = 152, /* MIPS R4000/R6000 binary */
+ M_SPARCLET_2 = 163, /* 0xa3, reserved */
+ M_SPARCLET_3 = 179, /* 0xb3, reserved */
+ M_SPARCLET_4 = 195, /* 0xc3, reserved */
+ M_HP200 = 200, /* HP 200 (68010) BSD binary */
+ M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */
+ M_HPUX = (0x20c % 256), /* HP 200/300 HPUX binary */
+ M_SPARCLET_5 = 211, /* 0xd3, reserved */
+ M_SPARCLET_6 = 227, /* 0xe3, reserved */
+ /* M_SPARCLET_7 = 243 / * 0xf3, reserved */
+ M_SPARCLITE_LE = 243
+};
+
+#define N_DYNAMIC(exec) ((exec).a_info & 0x80000000)
+
+#ifndef N_MAGIC
+# define N_MAGIC(exec) ((exec).a_info & 0xffff)
+#endif
+
+#ifndef N_MACHTYPE
+# define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
+#endif
+
+#ifndef N_FLAGS
+# define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
+#endif
+
+#ifndef N_SET_INFO
+# define N_SET_INFO(exec, magic, type, flags) \
+((exec).a_info = ((magic) & 0xffff) \
+ | (((int)(type) & 0xff) << 16) \
+ | (((flags) & 0xff) << 24))
+#endif
+
+#ifndef N_SET_DYNAMIC
+# define N_SET_DYNAMIC(exec, dynamic) \
+((exec).a_info = (dynamic) ? ((exec).a_info | 0x80000000) : \
+((exec).a_info & 0x7fffffff))
+#endif
+
+#ifndef N_SET_MAGIC
+# define N_SET_MAGIC(exec, magic) \
+((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
+#endif
+
+#ifndef N_SET_MACHTYPE
+# define N_SET_MACHTYPE(exec, machtype) \
+((exec).a_info = \
+ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
+#endif
+
+#ifndef N_SET_FLAGS
+# define N_SET_FLAGS(exec, flags) \
+((exec).a_info = \
+ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
+#endif
+
+typedef struct aout_symbol {
+ asymbol symbol;
+ short desc;
+ char other;
+ unsigned char type;
+} aout_symbol_type;
+
+/* The `tdata' struct for all a.out-like object file formats.
+ Various things depend on this struct being around any time an a.out
+ file is being handled. An example is dbxread.c in GDB. */
+
+struct aoutdata {
+ struct internal_exec *hdr; /* exec file header */
+ aout_symbol_type *symbols; /* symtab for input bfd */
+
+ /* For ease, we do this */
+ asection *textsec;
+ asection *datasec;
+ asection *bsssec;
+
+ /* We remember these offsets so that after check_file_format, we have
+ no dependencies on the particular format of the exec_hdr. */
+ file_ptr sym_filepos;
+ file_ptr str_filepos;
+
+ /* Size of a relocation entry in external form */
+ unsigned reloc_entry_size;
+
+ /* Size of a symbol table entry in external form */
+ unsigned symbol_entry_size;
+
+ /* Page size - needed for alignment of demand paged files. */
+ unsigned long page_size;
+
+ /* Segment size - needed for alignment of demand paged files. */
+ unsigned long segment_size;
+
+ /* Zmagic disk block size - need to align the start of the text
+ section in ZMAGIC binaries. Normally the same as page_size. */
+ unsigned long zmagic_disk_block_size;
+
+ unsigned exec_bytes_size;
+ unsigned vma_adjusted : 1;
+
+ /* used when a bfd supports several highly similar formats */
+ enum
+ {
+ default_format = 0,
+ /* Used on HP 9000/300 running HP/UX. See hp300hpux.c. */
+ gnu_encap_format,
+ /* Used on Linux, 386BSD, etc. See include/aout/aout64.h. */
+ q_magic_format
+ } subformat;
+
+ enum
+ {
+ undecided_magic = 0,
+ z_magic,
+ o_magic,
+ n_magic
+ } magic;
+
+ /* A buffer for find_nearest_line. */
+ char *line_buf;
+
+ /* The external symbol information. */
+ struct external_nlist *external_syms;
+ bfd_size_type external_sym_count;
+ bfd_window sym_window;
+ char *external_strings;
+ bfd_size_type external_string_size;
+ bfd_window string_window;
+ struct aout_link_hash_entry **sym_hashes;
+
+ /* A pointer for shared library information. */
+ PTR dynamic_info;
+
+ /* A mapping from local symbols to offsets into the global offset
+ table, used when linking on SunOS. This is indexed by the symbol
+ index. */
+ bfd_vma *local_got_offsets;
+};
+
+struct aout_data_struct {
+ struct aoutdata a;
+ struct internal_exec e;
+};
+
+#define adata(bfd) ((bfd)->tdata.aout_data->a)
+#define exec_hdr(bfd) (adata(bfd).hdr)
+#define obj_aout_symbols(bfd) (adata(bfd).symbols)
+#define obj_textsec(bfd) (adata(bfd).textsec)
+#define obj_datasec(bfd) (adata(bfd).datasec)
+#define obj_bsssec(bfd) (adata(bfd).bsssec)
+#define obj_sym_filepos(bfd) (adata(bfd).sym_filepos)
+#define obj_str_filepos(bfd) (adata(bfd).str_filepos)
+#define obj_reloc_entry_size(bfd) (adata(bfd).reloc_entry_size)
+#define obj_symbol_entry_size(bfd) (adata(bfd).symbol_entry_size)
+#define obj_aout_subformat(bfd) (adata(bfd).subformat)
+#define obj_aout_external_syms(bfd) (adata(bfd).external_syms)
+#define obj_aout_external_sym_count(bfd) (adata(bfd).external_sym_count)
+#define obj_aout_sym_window(bfd) (adata(bfd).sym_window)
+#define obj_aout_external_strings(bfd) (adata(bfd).external_strings)
+#define obj_aout_external_string_size(bfd) (adata(bfd).external_string_size)
+#define obj_aout_string_window(bfd) (adata(bfd).string_window)
+#define obj_aout_sym_hashes(bfd) (adata(bfd).sym_hashes)
+#define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info)
+
+/* We take the address of the first element of an asymbol to ensure that the
+ macro is only ever applied to an asymbol */
+#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
+
+/* Information we keep for each a.out section. This is currently only
+ used by the a.out backend linker. */
+
+struct aout_section_data_struct
+{
+ /* The unswapped relocation entries for this section. */
+ PTR relocs;
+};
+
+#define aout_section_data(s) \
+ ((struct aout_section_data_struct *) (s)->used_by_bfd)
+
+#define set_aout_section_data(s,v) \
+ ((s)->used_by_bfd = (PTR)&(v)->relocs)
+
+/* Prototype declarations for functions defined in aoutx.h */
+
+boolean
+NAME(aout,squirt_out_relocs) PARAMS ((bfd *abfd, asection *section));
+
+boolean
+NAME(aout,make_sections) PARAMS ((bfd *));
+
+const bfd_target *
+NAME(aout,some_aout_object_p) PARAMS ((bfd *abfd,
+ struct internal_exec *execp,
+ const bfd_target *(*callback)(bfd *)));
+
+boolean
+NAME(aout,mkobject) PARAMS ((bfd *abfd));
+
+enum machine_type
+NAME(aout,machine_type) PARAMS ((enum bfd_architecture arch,
+ unsigned long machine,
+ boolean *unknown));
+
+boolean
+NAME(aout,set_arch_mach) PARAMS ((bfd *abfd, enum bfd_architecture arch,
+ unsigned long machine));
+
+boolean
+NAME(aout,new_section_hook) PARAMS ((bfd *abfd, asection *newsect));
+
+boolean
+NAME(aout,set_section_contents) PARAMS ((bfd *abfd, sec_ptr section,
+ PTR location, file_ptr offset, bfd_size_type count));
+
+asymbol *
+NAME(aout,make_empty_symbol) PARAMS ((bfd *abfd));
+
+boolean
+NAME(aout,translate_symbol_table) PARAMS ((bfd *, aout_symbol_type *,
+ struct external_nlist *,
+ bfd_size_type, char *,
+ bfd_size_type,
+ boolean dynamic));
+
+boolean
+NAME(aout,slurp_symbol_table) PARAMS ((bfd *abfd));
+
+boolean
+NAME(aout,write_syms) PARAMS ((bfd *abfd));
+
+void
+NAME(aout,reclaim_symbol_table) PARAMS ((bfd *abfd));
+
+long
+NAME(aout,get_symtab_upper_bound) PARAMS ((bfd *abfd));
+
+long
+NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location));
+
+void
+NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *,
+ arelent *, asymbol **, bfd_size_type));
+void
+NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
+ arelent *, asymbol **, bfd_size_type));
+
+reloc_howto_type *
+NAME(aout,reloc_type_lookup) PARAMS ((bfd *abfd,
+ bfd_reloc_code_real_type code));
+
+boolean
+NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect,
+ asymbol **symbols));
+
+long
+NAME(aout,canonicalize_reloc) PARAMS ((bfd *abfd, sec_ptr section,
+ arelent **relptr, asymbol **symbols));
+
+long
+NAME(aout,get_reloc_upper_bound) PARAMS ((bfd *abfd, sec_ptr asect));
+
+void
+NAME(aout,reclaim_reloc) PARAMS ((bfd *ignore_abfd, sec_ptr ignore));
+
+alent *
+NAME(aout,get_lineno) PARAMS ((bfd *ignore_abfd, asymbol *ignore_symbol));
+
+void
+NAME(aout,print_symbol) PARAMS ((bfd *ignore_abfd, PTR file,
+ asymbol *symbol, bfd_print_symbol_type how));
+
+void
+NAME(aout,get_symbol_info) PARAMS ((bfd *ignore_abfd,
+ asymbol *symbol, symbol_info *ret));
+
+boolean
+NAME(aout,find_nearest_line) PARAMS ((bfd *abfd, asection *section,
+ asymbol **symbols, bfd_vma offset, CONST char **filename_ptr,
+ CONST char **functionname_ptr, unsigned int *line_ptr));
+
+long
+NAME(aout,read_minisymbols) PARAMS ((bfd *, boolean, PTR *, unsigned int *));
+
+asymbol *
+NAME(aout,minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
+ asymbol *));
+
+int
+NAME(aout,sizeof_headers) PARAMS ((bfd *abfd, boolean exec));
+
+boolean
+NAME(aout,adjust_sizes_and_vmas) PARAMS ((bfd *abfd,
+ bfd_size_type *text_size, file_ptr *text_end));
+
+void
+NAME(aout,swap_exec_header_in) PARAMS ((bfd *abfd,
+ struct external_exec *raw_bytes, struct internal_exec *execp));
+
+void
+NAME(aout,swap_exec_header_out) PARAMS ((bfd *abfd,
+ struct internal_exec *execp, struct external_exec *raw_bytes));
+
+struct bfd_hash_entry *
+NAME(aout,link_hash_newfunc)
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+boolean
+NAME(aout,link_hash_table_init)
+ PARAMS ((struct aout_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+struct bfd_link_hash_table *
+NAME(aout,link_hash_table_create) PARAMS ((bfd *));
+
+boolean
+NAME(aout,link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+
+boolean
+NAME(aout,final_link) PARAMS ((bfd *, struct bfd_link_info *,
+ void (*) (bfd *, file_ptr *, file_ptr *,
+ file_ptr *)));
+
+boolean
+NAME(aout,bfd_free_cached_info) PARAMS ((bfd *));
+
+/* A.out uses the generic versions of these routines... */
+
+#define aout_32_get_section_contents _bfd_generic_get_section_contents
+
+#define aout_64_get_section_contents _bfd_generic_get_section_contents
+#ifndef NO_WRITE_HEADER_KLUDGE
+#define NO_WRITE_HEADER_KLUDGE 0
+#endif
+
+#ifndef aout_32_bfd_is_local_label_name
+#define aout_32_bfd_is_local_label_name bfd_generic_is_local_label_name
+#endif
+
+#ifndef WRITE_HEADERS
+#define WRITE_HEADERS(abfd, execp) \
+ { \
+ bfd_size_type text_size; /* dummy vars */ \
+ file_ptr text_end; \
+ if (adata(abfd).magic == undecided_magic) \
+ NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
+ \
+ execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
+ execp->a_entry = bfd_get_start_address (abfd); \
+ \
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
+ \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
+ if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
+ != EXEC_BYTES_SIZE) \
+ return false; \
+ /* Now write out reloc info, followed by syms and strings */ \
+ \
+ if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
+ && bfd_get_symcount (abfd) != 0) \
+ { \
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (! NAME(aout,write_syms)(abfd)) return false; \
+ } \
+ \
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
+ return false; \
+ \
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ return false; \
+ }
+#endif
+
+#endif /* ! defined (LIBAOUT_H) */
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
new file mode 100644
index 00000000000..cb4a4df1ac2
--- /dev/null
+++ b/bfd/libbfd-in.h
@@ -0,0 +1,538 @@
+/* libbfd.h -- Declarations used by bfd library *implementation*.
+ (This include file is not for users of the library.)
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+** NOTE: libbfd.h is a GENERATED file. Don't change it; instead,
+** change libbfd-in.h or the other BFD source files processed to
+** generate this file.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Align an address upward to a boundary, expressed as a number of bytes.
+ E.g. align to an 8-byte boundary with argument of 8. Take care never
+ to wrap around if the address is within boundary-1 of the end of the
+ address space. */
+#define BFD_ALIGN(this, boundary) \
+ ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
+ ? (((bfd_vma) (this) + ((boundary) - 1)) & (~((boundary)-1))) \
+ : ~ (bfd_vma) 0)
+
+/* If you want to read and write large blocks, you might want to do it
+ in quanta of this amount */
+#define DEFAULT_BUFFERSIZE 8192
+
+/* Set a tdata field. Can't use the other macros for this, since they
+ do casts, and casting to the left of assignment isn't portable. */
+#define set_tdata(bfd, v) ((bfd)->tdata.any = (PTR) (v))
+
+/* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
+ to an instance of this structure. */
+
+struct bfd_in_memory
+{
+ /* Size of buffer. */
+ bfd_size_type size;
+ /* Buffer holding contents of BFD. */
+ bfd_byte *buffer;
+};
+
+/* tdata for an archive. For an input archive, cache
+ needs to be free()'d. For an output archive, symdefs do. */
+
+struct artdata {
+ file_ptr first_file_filepos;
+ /* Speed up searching the armap */
+ struct ar_cache *cache;
+ bfd *archive_head; /* Only interesting in output routines */
+ carsym *symdefs; /* the symdef entries */
+ symindex symdef_count; /* how many there are */
+ char *extended_names; /* clever intel extension */
+ /* when more compilers are standard C, this can be a time_t */
+ long armap_timestamp; /* Timestamp value written into armap.
+ This is used for BSD archives to check
+ that the timestamp is recent enough
+ for the BSD linker to not complain,
+ just before we finish writing an
+ archive. */
+ file_ptr armap_datepos; /* Position within archive to seek to
+ rewrite the date field. */
+ PTR tdata; /* Backend specific information. */
+};
+
+#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
+
+/* Goes in bfd's arelt_data slot */
+struct areltdata {
+ char * arch_header; /* it's actually a string */
+ unsigned int parsed_size; /* octets of filesize not including ar_hdr */
+ char *filename; /* null-terminated */
+};
+
+#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
+
+extern PTR bfd_malloc PARAMS ((size_t));
+extern PTR bfd_realloc PARAMS ((PTR, size_t));
+extern PTR bfd_zmalloc PARAMS ((size_t));
+
+extern bfd_error_handler_type _bfd_error_handler;
+
+/* These routines allocate and free things on the BFD's objalloc. */
+
+extern PTR bfd_alloc PARAMS ((bfd *, size_t));
+extern PTR bfd_zalloc PARAMS ((bfd *, size_t));
+extern void bfd_release PARAMS ((bfd *, PTR));
+
+bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
+bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
+boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
+boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
+const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
+boolean bfd_slurp_armap PARAMS ((bfd *abfd));
+boolean bfd_slurp_bsd_armap_f2 PARAMS ((bfd *abfd));
+#define bfd_slurp_bsd_armap bfd_slurp_armap
+#define bfd_slurp_coff_armap bfd_slurp_armap
+boolean _bfd_slurp_extended_name_table PARAMS ((bfd *abfd));
+extern boolean _bfd_construct_extended_name_table
+ PARAMS ((bfd *, boolean, char **, bfd_size_type *));
+boolean _bfd_write_archive_contents PARAMS ((bfd *abfd));
+boolean _bfd_compute_and_write_armap PARAMS ((bfd *, unsigned int elength));
+bfd *_bfd_get_elt_at_filepos PARAMS ((bfd *archive, file_ptr filepos));
+extern bfd *_bfd_generic_get_elt_at_index PARAMS ((bfd *, symindex));
+bfd * _bfd_new_bfd PARAMS ((void));
+
+boolean bfd_false PARAMS ((bfd *ignore));
+boolean bfd_true PARAMS ((bfd *ignore));
+PTR bfd_nullvoidptr PARAMS ((bfd *ignore));
+int bfd_0 PARAMS ((bfd *ignore));
+unsigned int bfd_0u PARAMS ((bfd *ignore));
+long bfd_0l PARAMS ((bfd *ignore));
+long _bfd_n1 PARAMS ((bfd *ignore));
+void bfd_void PARAMS ((bfd *ignore));
+
+bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
+const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
+
+void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
+ char *hdr));
+void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
+ char *hdr));
+void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
+ char *hdr));
+
+boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,
+ struct orl *map, unsigned int orl_count, int stridx));
+
+boolean coff_write_armap PARAMS ((bfd *arch, unsigned int elength,
+ struct orl *map, unsigned int orl_count, int stridx));
+
+extern PTR _bfd_generic_read_ar_hdr PARAMS ((bfd *));
+
+extern PTR _bfd_generic_read_ar_hdr_mag PARAMS ((bfd *, const char *));
+
+bfd * bfd_generic_openr_next_archived_file PARAMS ((bfd *archive,
+ bfd *last_file));
+
+int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
+
+#define _bfd_read_ar_hdr(abfd) \
+ BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
+
+/* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
+
+#define _bfd_generic_close_and_cleanup bfd_true
+#define _bfd_generic_bfd_free_cached_info bfd_true
+#define _bfd_generic_new_section_hook \
+ ((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
+extern boolean _bfd_generic_get_section_contents
+ PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
+ bfd_size_type count));
+extern boolean _bfd_generic_get_section_contents_in_window
+ PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
+
+/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
+ BFD_JUMP_TABLE_COPY (_bfd_generic). */
+
+#define _bfd_generic_bfd_copy_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+#define _bfd_generic_bfd_merge_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+#define _bfd_generic_bfd_set_private_flags \
+ ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
+#define _bfd_generic_bfd_copy_private_section_data \
+ ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
+#define _bfd_generic_bfd_copy_private_symbol_data \
+ ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
+#define _bfd_generic_bfd_print_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, PTR))) bfd_true)
+
+/* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
+ support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
+
+extern char *_bfd_nocore_core_file_failing_command PARAMS ((bfd *));
+extern int _bfd_nocore_core_file_failing_signal PARAMS ((bfd *));
+extern boolean _bfd_nocore_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
+
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
+ file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
+
+#define _bfd_noarchive_slurp_armap bfd_false
+#define _bfd_noarchive_slurp_extended_name_table bfd_false
+#define _bfd_noarchive_construct_extended_name_table \
+ ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
+ bfd_false)
+#define _bfd_noarchive_truncate_arname \
+ ((void (*) PARAMS ((bfd *, const char *, char *))) bfd_void)
+#define _bfd_noarchive_write_armap \
+ ((boolean (*) \
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
+ bfd_false)
+#define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
+#define _bfd_noarchive_openr_next_archived_file \
+ ((bfd *(*) PARAMS ((bfd *, bfd *))) bfd_nullvoidptr)
+#define _bfd_noarchive_get_elt_at_index \
+ ((bfd *(*) PARAMS ((bfd *, symindex))) bfd_nullvoidptr)
+#define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define _bfd_noarchive_update_armap_timestamp bfd_false
+
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
+ archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
+
+#define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
+#define _bfd_archive_bsd_slurp_extended_name_table \
+ _bfd_slurp_extended_name_table
+extern boolean _bfd_archive_bsd_construct_extended_name_table
+ PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+#define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
+#define _bfd_archive_bsd_write_armap bsd_write_armap
+#define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_bsd_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_archive_bsd_generic_stat_arch_elt \
+ bfd_generic_stat_arch_elt
+extern boolean _bfd_archive_bsd_update_armap_timestamp PARAMS ((bfd *));
+
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
+ archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
+
+#define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
+#define _bfd_archive_coff_slurp_extended_name_table \
+ _bfd_slurp_extended_name_table
+extern boolean _bfd_archive_coff_construct_extended_name_table
+ PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+#define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
+#define _bfd_archive_coff_write_armap coff_write_armap
+#define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_coff_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_archive_coff_generic_stat_arch_elt \
+ bfd_generic_stat_arch_elt
+#define _bfd_archive_coff_update_armap_timestamp bfd_true
+
+/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
+ support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
+
+#define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
+#define _bfd_nosymbols_get_symtab \
+ ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
+#define _bfd_nosymbols_make_empty_symbol \
+ ((asymbol *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define _bfd_nosymbols_print_symbol \
+ ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_void)
+#define _bfd_nosymbols_get_symbol_info \
+ ((void (*) PARAMS ((bfd *, asymbol *, symbol_info *))) bfd_void)
+#define _bfd_nosymbols_bfd_is_local_label_name \
+ ((boolean (*) PARAMS ((bfd *, const char *))) bfd_false)
+#define _bfd_nosymbols_get_lineno \
+ ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
+#define _bfd_nosymbols_find_nearest_line \
+ ((boolean (*) \
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, \
+ const char **, unsigned int *))) \
+ bfd_false)
+#define _bfd_nosymbols_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, PTR, unsigned long))) bfd_nullvoidptr)
+#define _bfd_nosymbols_read_minisymbols \
+ ((long (*) PARAMS ((bfd *, boolean, PTR *, unsigned int *))) _bfd_n1)
+#define _bfd_nosymbols_minisymbol_to_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, boolean, const PTR, asymbol *))) \
+ bfd_nullvoidptr)
+
+/* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
+ support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
+
+#define _bfd_norelocs_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) _bfd_n1)
+#define _bfd_norelocs_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) _bfd_n1)
+#define _bfd_norelocs_bfd_reloc_type_lookup \
+ ((reloc_howto_type *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) \
+ bfd_nullvoidptr)
+
+/* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
+ be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
+
+#define _bfd_nowrite_set_arch_mach \
+ ((boolean (*) PARAMS ((bfd *, enum bfd_architecture, unsigned long))) \
+ bfd_false)
+#define _bfd_nowrite_set_section_contents \
+ ((boolean (*) PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type))) \
+ bfd_false)
+
+/* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
+ BFD_JUMP_TABLE_WRITE (_bfd_generic). */
+
+#define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
+extern boolean _bfd_generic_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+
+/* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
+ support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
+
+#define _bfd_nolink_sizeof_headers ((int (*) PARAMS ((bfd *, boolean))) bfd_0)
+#define _bfd_nolink_bfd_get_relocated_section_contents \
+ ((bfd_byte *(*) \
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, \
+ bfd_byte *, boolean, asymbol **))) \
+ bfd_nullvoidptr)
+#define _bfd_nolink_bfd_relax_section \
+ ((boolean (*) \
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *))) \
+ bfd_false)
+#define _bfd_nolink_bfd_gc_sections \
+ ((boolean (*) \
+ PARAMS ((bfd *, struct bfd_link_info *))) \
+ bfd_false)
+#define _bfd_nolink_bfd_link_hash_table_create \
+ ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define _bfd_nolink_bfd_link_add_symbols \
+ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
+#define _bfd_nolink_bfd_final_link \
+ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
+#define _bfd_nolink_bfd_link_split_section \
+ ((boolean (*) PARAMS ((bfd *, struct sec *))) bfd_false)
+
+/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
+ have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
+ (_bfd_nodynamic). */
+
+#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
+#define _bfd_nodynamic_canonicalize_dynamic_symtab \
+ ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
+#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
+#define _bfd_nodynamic_canonicalize_dynamic_reloc \
+ ((long (*) PARAMS ((bfd *, arelent **, asymbol **))) _bfd_n1)
+
+/* Generic routine to determine of the given symbol is a local
+ label. */
+extern boolean bfd_generic_is_local_label_name PARAMS ((bfd *, const char *));
+
+/* Generic minisymbol routines. */
+extern long _bfd_generic_read_minisymbols
+ PARAMS ((bfd *, boolean, PTR *, unsigned int *));
+extern asymbol *_bfd_generic_minisymbol_to_symbol
+ PARAMS ((bfd *, boolean, const PTR, asymbol *));
+
+/* Find the nearest line using .stab/.stabstr sections. */
+extern boolean _bfd_stab_section_find_nearest_line
+ PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
+ const char **, unsigned int *, PTR *));
+
+/* Find the neaderst line using DWARF 1 debugging information. */
+extern boolean _bfd_dwarf1_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+
+/* Find the nearest line using DWARF 2 debugging information. */
+extern boolean _bfd_dwarf2_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+
+/* A routine to create entries for a bfd_link_hash_table. */
+extern struct bfd_hash_entry *_bfd_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string));
+
+/* Initialize a bfd_link_hash_table. */
+extern boolean _bfd_link_hash_table_init
+ PARAMS ((struct bfd_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+/* Generic link hash table creation routine. */
+extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
+ PARAMS ((bfd *));
+
+/* Generic add symbol routine. */
+extern boolean _bfd_generic_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Generic add symbol routine. This version is used by targets for
+ which the linker must collect constructors and destructors by name,
+ as the collect2 program does. */
+extern boolean _bfd_generic_link_add_symbols_collect
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Generic archive add symbol routine. */
+extern boolean _bfd_generic_link_add_archive_symbols
+ PARAMS ((bfd *, struct bfd_link_info *,
+ boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *)));
+
+
+
+/* Forward declaration to avoid prototype errors. */
+typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
+
+/* Generic routine to add a single symbol. */
+extern boolean _bfd_generic_link_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *name, flagword,
+ asection *, bfd_vma, const char *, boolean copy,
+ boolean constructor, struct bfd_link_hash_entry **));
+
+/* Generic link routine. */
+extern boolean _bfd_generic_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+extern boolean _bfd_generic_link_split_section
+ PARAMS ((bfd *, struct sec *));
+
+/* Generic reloc_link_order processing routine. */
+extern boolean _bfd_generic_reloc_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* Default link order processing routine. */
+extern boolean _bfd_default_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* Count the number of reloc entries in a link order list. */
+extern unsigned int _bfd_count_link_order_relocs
+ PARAMS ((struct bfd_link_order *));
+
+/* Final link relocation routine. */
+extern bfd_reloc_status_type _bfd_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
+ bfd_vma address, bfd_vma value, bfd_vma addend));
+
+/* Relocate a particular location by a howto and a value. */
+extern bfd_reloc_status_type _bfd_relocate_contents
+ PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
+
+/* Link stabs in sections in the first pass. */
+
+extern boolean _bfd_link_section_stabs
+ PARAMS ((bfd *, PTR *, asection *, asection *, PTR *));
+
+/* Write out the .stab section when linking stabs in sections. */
+
+extern boolean _bfd_write_section_stabs
+ PARAMS ((bfd *, PTR *, asection *, PTR *, bfd_byte *));
+
+/* Write out the .stabstr string table when linking stabs in sections. */
+
+extern boolean _bfd_write_stab_strings PARAMS ((bfd *, PTR *));
+
+/* Find an offset within a .stab section when linking stabs in
+ sections. */
+
+extern bfd_vma _bfd_stab_section_offset
+ PARAMS ((bfd *, PTR *, asection *, PTR *, bfd_vma));
+
+/* Create a string table. */
+extern struct bfd_strtab_hash *_bfd_stringtab_init PARAMS ((void));
+
+/* Create an XCOFF .debug section style string table. */
+extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init PARAMS ((void));
+
+/* Free a string table. */
+extern void _bfd_stringtab_free PARAMS ((struct bfd_strtab_hash *));
+
+/* Get the size of a string table. */
+extern bfd_size_type _bfd_stringtab_size PARAMS ((struct bfd_strtab_hash *));
+
+/* Add a string to a string table. */
+extern bfd_size_type _bfd_stringtab_add
+ PARAMS ((struct bfd_strtab_hash *, const char *, boolean hash,
+ boolean copy));
+
+/* Write out a string table. */
+extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *));
+
+/* Macros to tell if bfds are read or write enabled.
+
+ Note that bfds open for read may be scribbled into if the fd passed
+ to bfd_fdopenr is actually open both for read and write
+ simultaneously. However an output bfd will never be open for
+ read. Therefore sometimes you want to check bfd_read_p or
+ !bfd_read_p, and only sometimes bfd_write_p.
+*/
+
+#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
+#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
+
+void bfd_assert PARAMS ((const char*,int));
+
+#define BFD_ASSERT(x) \
+{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
+
+#define BFD_FAIL() \
+{ bfd_assert(__FILE__,__LINE__); }
+
+FILE * bfd_cache_lookup_worker PARAMS ((bfd *));
+
+extern bfd *bfd_last_cache;
+
+/* List of supported target vectors, and the default vector (if
+ bfd_default_vector[0] is NULL, there is no default). */
+extern const bfd_target * const bfd_target_vector[];
+extern const bfd_target *bfd_default_vector[];
+
+/* Functions shared by the ECOFF and MIPS ELF backends, which have no
+ other common header files. */
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct ecoff_find_line;
+#endif
+
+extern boolean _bfd_ecoff_locate_line
+ PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
+ const struct ecoff_debug_swap * const, struct ecoff_find_line *,
+ const char **, const char **, unsigned int *));
+extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
+extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
+extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
+
+extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *));
+extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma));
+
+/* Function shared by the COFF and ELF SH backends, which have no
+ other common header files. */
+
+extern boolean _bfd_sh_align_load_span
+ PARAMS ((bfd *, asection *, bfd_byte *,
+ boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma),
+ PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, boolean *));
+
+/* And more follows */
+
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
new file mode 100644
index 00000000000..8abd1f58f1c
--- /dev/null
+++ b/bfd/libbfd.c
@@ -0,0 +1,1263 @@
+/* Assorted BFD support routines, only used internally.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#ifndef HAVE_GETPAGESIZE
+#define getpagesize() 2048
+#endif
+
+static int real_read PARAMS ((PTR, size_t, size_t, FILE *));
+
+/*
+SECTION
+ Internal functions
+
+DESCRIPTION
+ These routines are used within BFD.
+ They are not intended for export, but are documented here for
+ completeness.
+*/
+
+/* A routine which is used in target vectors for unsupported
+ operations. */
+
+/*ARGSUSED*/
+boolean
+bfd_false (ignore)
+ bfd *ignore;
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+}
+
+/* A routine which is used in target vectors for supported operations
+ which do not actually do anything. */
+
+/*ARGSUSED*/
+boolean
+bfd_true (ignore)
+ bfd *ignore;
+{
+ return true;
+}
+
+/* A routine which is used in target vectors for unsupported
+ operations which return a pointer value. */
+
+/*ARGSUSED*/
+PTR
+bfd_nullvoidptr (ignore)
+ bfd *ignore;
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+}
+
+/*ARGSUSED*/
+int
+bfd_0 (ignore)
+ bfd *ignore;
+{
+ return 0;
+}
+
+/*ARGSUSED*/
+unsigned int
+bfd_0u (ignore)
+ bfd *ignore;
+{
+ return 0;
+}
+
+/*ARGUSED*/
+long
+bfd_0l (ignore)
+ bfd *ignore;
+{
+ return 0;
+}
+
+/* A routine which is used in target vectors for unsupported
+ operations which return -1 on error. */
+
+/*ARGSUSED*/
+long
+_bfd_n1 (ignore_abfd)
+ bfd *ignore_abfd;
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+}
+
+/*ARGSUSED*/
+void
+bfd_void (ignore)
+ bfd *ignore;
+{
+}
+
+/*ARGSUSED*/
+boolean
+_bfd_nocore_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd)
+ bfd *ignore_core_bfd;
+ bfd *ignore_exec_bfd;
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+}
+
+/* Routine to handle core_file_failing_command entry point for targets
+ without core file support. */
+
+/*ARGSUSED*/
+char *
+_bfd_nocore_core_file_failing_command (ignore_abfd)
+ bfd *ignore_abfd;
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return (char *)NULL;
+}
+
+/* Routine to handle core_file_failing_signal entry point for targets
+ without core file support. */
+
+/*ARGSUSED*/
+int
+_bfd_nocore_core_file_failing_signal (ignore_abfd)
+ bfd *ignore_abfd;
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return 0;
+}
+
+/*ARGSUSED*/
+const bfd_target *
+_bfd_dummy_target (ignore_abfd)
+ bfd *ignore_abfd;
+{
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+}
+
+/* Allocate memory using malloc. */
+
+PTR
+bfd_malloc (size)
+ size_t size;
+{
+ PTR ptr;
+
+ ptr = (PTR) malloc (size);
+ if (ptr == NULL && size != 0)
+ bfd_set_error (bfd_error_no_memory);
+ return ptr;
+}
+
+/* Reallocate memory using realloc. */
+
+PTR
+bfd_realloc (ptr, size)
+ PTR ptr;
+ size_t size;
+{
+ PTR ret;
+
+ if (ptr == NULL)
+ ret = malloc (size);
+ else
+ ret = realloc (ptr, size);
+
+ if (ret == NULL)
+ bfd_set_error (bfd_error_no_memory);
+
+ return ret;
+}
+
+/* Allocate memory using malloc and clear it. */
+
+PTR
+bfd_zmalloc (size)
+ size_t size;
+{
+ PTR ptr;
+
+ ptr = (PTR) malloc (size);
+
+ if (size != 0)
+ {
+ if (ptr == NULL)
+ bfd_set_error (bfd_error_no_memory);
+ else
+ memset (ptr, 0, size);
+ }
+
+ return ptr;
+}
+
+/* Some IO code */
+
+
+/* Note that archive entries don't have streams; they share their parent's.
+ This allows someone to play with the iostream behind BFD's back.
+
+ Also, note that the origin pointer points to the beginning of a file's
+ contents (0 for non-archive elements). For archive entries this is the
+ first octet in the file, NOT the beginning of the archive header. */
+
+static int
+real_read (where, a,b, file)
+ PTR where;
+ size_t a;
+ size_t b;
+ FILE *file;
+{
+ /* FIXME - this looks like an optimization, but it's really to cover
+ up for a feature of some OSs (not solaris - sigh) that
+ ld/pe-dll.c takes advantage of (apparently) when it creates BFDs
+ internally and tries to link against them. BFD seems to be smart
+ enough to realize there are no symbol records in the "file" that
+ doesn't exist but attempts to read them anyway. On Solaris,
+ attempting to read zero bytes from a NULL file results in a core
+ dump, but on other platforms it just returns zero bytes read.
+ This makes it to something reasonable. - DJ */
+ if (a == 0 || b == 0)
+ return 0;
+
+#if defined (__VAX) && defined (VMS)
+ /* Apparently fread on Vax VMS does not keep the record length
+ information. */
+ return read (fileno (file), where, a * b);
+#else
+ return fread (where, a, b, file);
+#endif
+}
+
+/* Return value is amount read (FIXME: how are errors and end of file dealt
+ with? We never call bfd_set_error, which is probably a mistake). */
+
+bfd_size_type
+bfd_read (ptr, size, nitems, abfd)
+ PTR ptr;
+ bfd_size_type size;
+ bfd_size_type nitems;
+ bfd *abfd;
+{
+ int nread;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ {
+ struct bfd_in_memory *bim;
+ bfd_size_type get;
+
+ bim = (struct bfd_in_memory *) abfd->iostream;
+ get = size * nitems;
+ if (abfd->where + get > bim->size)
+ {
+ get = bim->size - abfd->where;
+ bfd_set_error (bfd_error_file_truncated);
+ }
+ memcpy (ptr, bim->buffer + abfd->where, get);
+ abfd->where += get;
+ return get;
+ }
+
+ nread = real_read (ptr, 1, (size_t)(size*nitems), bfd_cache_lookup(abfd));
+ if (nread > 0)
+ abfd->where += nread;
+
+ /* Set bfd_error if we did not read as much data as we expected.
+
+ If the read failed due to an error set the bfd_error_system_call,
+ else set bfd_error_file_truncated.
+
+ A BFD backend may wish to override bfd_error_file_truncated to
+ provide something more useful (eg. no_symbols or wrong_format). */
+ if (nread < (int)(size * nitems))
+ {
+ if (ferror (bfd_cache_lookup (abfd)))
+ bfd_set_error (bfd_error_system_call);
+ else
+ bfd_set_error (bfd_error_file_truncated);
+ }
+
+ return nread;
+}
+
+/* The window support stuff should probably be broken out into
+ another file.... */
+/* The idea behind the next and refcount fields is that one mapped
+ region can suffice for multiple read-only windows or multiple
+ non-overlapping read-write windows. It's not implemented yet
+ though. */
+struct _bfd_window_internal {
+ struct _bfd_window_internal *next;
+ PTR data;
+ bfd_size_type size;
+ int refcount : 31; /* should be enough... */
+ unsigned mapped : 1; /* 1 = mmap, 0 = malloc */
+};
+
+void
+bfd_init_window (windowp)
+ bfd_window *windowp;
+{
+ windowp->data = 0;
+ windowp->i = 0;
+ windowp->size = 0;
+}
+
+/* Currently, if USE_MMAP is undefined, none if the window stuff is
+ used. Okay, so it's mis-named. At least the command-line option
+ "--without-mmap" is more obvious than "--without-windows" or some
+ such. */
+#ifdef USE_MMAP
+
+#undef HAVE_MPROTECT /* code's not tested yet */
+
+#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
+#include <sys/mman.h>
+#endif
+
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+
+static int debug_windows;
+
+void
+bfd_free_window (windowp)
+ bfd_window *windowp;
+{
+ bfd_window_internal *i = windowp->i;
+ windowp->i = 0;
+ windowp->data = 0;
+ if (i == 0)
+ return;
+ i->refcount--;
+ if (debug_windows)
+ fprintf (stderr, "freeing window @%p<%p,%lx,%p>\n",
+ windowp, windowp->data, windowp->size, windowp->i);
+ if (i->refcount != 0)
+ return;
+
+ if (i->mapped)
+ {
+#ifdef HAVE_MMAP
+ munmap (i->data, i->size);
+ goto no_free;
+#else
+ abort ();
+#endif
+ }
+#ifdef HAVE_MPROTECT
+ mprotect (i->data, i->size, PROT_READ | PROT_WRITE);
+#endif
+ free (i->data);
+#ifdef HAVE_MMAP
+ no_free:
+#endif
+ i->data = 0;
+ /* There should be no more references to i at this point. */
+ free (i);
+}
+
+static int ok_to_map = 1;
+
+boolean
+bfd_get_file_window (abfd, offset, size, windowp, writable)
+ bfd *abfd;
+ file_ptr offset;
+ bfd_size_type size;
+ bfd_window *windowp;
+ boolean writable;
+{
+ static size_t pagesize;
+ bfd_window_internal *i = windowp->i;
+ size_t size_to_alloc = size;
+
+ if (debug_windows)
+ fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
+ abfd, (long) offset, (long) size,
+ windowp, windowp->data, (unsigned long) windowp->size,
+ windowp->i, writable);
+
+ /* Make sure we know the page size, so we can be friendly to mmap. */
+ if (pagesize == 0)
+ pagesize = getpagesize ();
+ if (pagesize == 0)
+ abort ();
+
+ if (i == 0)
+ {
+ windowp->i = i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
+ if (i == 0)
+ return false;
+ i->data = 0;
+ }
+#ifdef HAVE_MMAP
+ if (ok_to_map
+ && (i->data == 0 || i->mapped == 1)
+ && (abfd->flags & BFD_IN_MEMORY) == 0)
+ {
+ file_ptr file_offset, offset2;
+ size_t real_size;
+ int fd;
+ FILE *f;
+
+ /* Find the real file and the real offset into it. */
+ while (abfd->my_archive != NULL)
+ {
+ offset += abfd->origin;
+ abfd = abfd->my_archive;
+ }
+ f = bfd_cache_lookup (abfd);
+ fd = fileno (f);
+
+ /* Compute offsets and size for mmap and for the user's data. */
+ offset2 = offset % pagesize;
+ if (offset2 < 0)
+ abort ();
+ file_offset = offset - offset2;
+ real_size = offset + size - file_offset;
+ real_size = real_size + pagesize - 1;
+ real_size -= real_size % pagesize;
+
+ /* If we're re-using a memory region, make sure it's big enough. */
+ if (i->data && i->size < size)
+ {
+ munmap (i->data, i->size);
+ i->data = 0;
+ }
+ i->data = mmap (i->data, real_size,
+ writable ? PROT_WRITE | PROT_READ : PROT_READ,
+ (writable
+ ? MAP_FILE | MAP_PRIVATE
+ : MAP_FILE | MAP_SHARED),
+ fd, file_offset);
+ if (i->data == (PTR) -1)
+ {
+ /* An error happened. Report it, or try using malloc, or
+ something. */
+ bfd_set_error (bfd_error_system_call);
+ i->data = 0;
+ windowp->data = 0;
+ if (debug_windows)
+ fprintf (stderr, "\t\tmmap failed!\n");
+ return false;
+ }
+ if (debug_windows)
+ fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
+ (long) real_size, i->data, (long) offset2);
+ i->size = real_size;
+ windowp->data = (PTR) ((bfd_byte *) i->data + offset2);
+ windowp->size = size;
+ i->mapped = 1;
+ return true;
+ }
+ else if (debug_windows)
+ {
+ if (ok_to_map)
+ fprintf (stderr, _("not mapping: data=%lx mapped=%d\n"),
+ (unsigned long) i->data, (int) i->mapped);
+ else
+ fprintf (stderr, _("not mapping: env var not set\n"));
+ }
+#else
+ ok_to_map = 0;
+#endif
+
+#ifdef HAVE_MPROTECT
+ if (!writable)
+ {
+ size_to_alloc += pagesize - 1;
+ size_to_alloc -= size_to_alloc % pagesize;
+ }
+#endif
+ if (debug_windows)
+ fprintf (stderr, "\n\t%s(%6ld)",
+ i->data ? "realloc" : " malloc", (long) size_to_alloc);
+ i->data = (PTR) bfd_realloc (i->data, size_to_alloc);
+ if (debug_windows)
+ fprintf (stderr, "\t-> %p\n", i->data);
+ i->refcount = 1;
+ if (i->data == NULL)
+ {
+ if (size_to_alloc == 0)
+ return true;
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
+ return false;
+ i->size = bfd_read (i->data, size, 1, abfd);
+ if (i->size != size)
+ return false;
+ i->mapped = 0;
+#ifdef HAVE_MPROTECT
+ if (!writable)
+ {
+ if (debug_windows)
+ fprintf (stderr, "\tmprotect (%p, %ld, PROT_READ)\n", i->data,
+ (long) i->size);
+ mprotect (i->data, i->size, PROT_READ);
+ }
+#endif
+ windowp->data = i->data;
+ windowp->size = i->size;
+ return true;
+}
+
+#endif /* USE_MMAP */
+
+bfd_size_type
+bfd_write (ptr, size, nitems, abfd)
+ CONST PTR ptr;
+ bfd_size_type size;
+ bfd_size_type nitems;
+ bfd *abfd;
+{
+ long nwrote;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ {
+ struct bfd_in_memory *bim = (struct bfd_in_memory *) (abfd->iostream);
+ size *= nitems;
+ if (abfd->where + size > bim->size)
+ {
+ long newsize, oldsize = (bim->size + 127) & ~127;
+ bim->size = abfd->where + size;
+ /* Round up to cut down on memory fragmentation */
+ newsize = (bim->size + 127) & ~127;
+ if (newsize > oldsize)
+ {
+ bim->buffer = bfd_realloc (bim->buffer, newsize);
+ if (bim->buffer == 0)
+ {
+ bim->size = 0;
+ return 0;
+ }
+ }
+ }
+ memcpy (bim->buffer + abfd->where, ptr, size);
+ abfd->where += size;
+ return size;
+ }
+
+ nwrote = fwrite (ptr, 1, (size_t) (size * nitems),
+ bfd_cache_lookup (abfd));
+ if (nwrote > 0)
+ abfd->where += nwrote;
+ if ((bfd_size_type) nwrote != size * nitems)
+ {
+#ifdef ENOSPC
+ if (nwrote >= 0)
+ errno = ENOSPC;
+#endif
+ bfd_set_error (bfd_error_system_call);
+ }
+ return nwrote;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_write_bigendian_4byte_int
+
+SYNOPSIS
+ void bfd_write_bigendian_4byte_int(bfd *abfd, int i);
+
+DESCRIPTION
+ Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
+ endian order regardless of what else is going on. This is useful in
+ archives.
+
+*/
+void
+bfd_write_bigendian_4byte_int (abfd, i)
+ bfd *abfd;
+ int i;
+{
+ bfd_byte buffer[4];
+ bfd_putb32(i, buffer);
+ if (bfd_write((PTR)buffer, 4, 1, abfd) != 4)
+ abort ();
+}
+
+long
+bfd_tell (abfd)
+ bfd *abfd;
+{
+ file_ptr ptr;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ return abfd->where;
+
+ ptr = ftell (bfd_cache_lookup(abfd));
+
+ if (abfd->my_archive)
+ ptr -= abfd->origin;
+ abfd->where = ptr;
+ return ptr;
+}
+
+int
+bfd_flush (abfd)
+ bfd *abfd;
+{
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ return 0;
+ return fflush (bfd_cache_lookup(abfd));
+}
+
+/* Returns 0 for success, negative value for failure (in which case
+ bfd_get_error can retrieve the error code). */
+int
+bfd_stat (abfd, statbuf)
+ bfd *abfd;
+ struct stat *statbuf;
+{
+ FILE *f;
+ int result;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ abort ();
+
+ f = bfd_cache_lookup (abfd);
+ if (f == NULL)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return -1;
+ }
+ result = fstat (fileno (f), statbuf);
+ if (result < 0)
+ bfd_set_error (bfd_error_system_call);
+ return result;
+}
+
+/* Returns 0 for success, nonzero for failure (in which case bfd_get_error
+ can retrieve the error code). */
+
+int
+bfd_seek (abfd, position, direction)
+ bfd *abfd;
+ file_ptr position;
+ int direction;
+{
+ int result;
+ FILE *f;
+ file_ptr file_position;
+ /* For the time being, a BFD may not seek to it's end. The problem
+ is that we don't easily have a way to recognize the end of an
+ element in an archive. */
+
+ BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR);
+
+ if (direction == SEEK_CUR && position == 0)
+ return 0;
+
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ {
+ if (direction == SEEK_SET)
+ abfd->where = position;
+ else
+ abfd->where += position;
+ return 0;
+ }
+
+ if (abfd->format != bfd_archive && abfd->my_archive == 0)
+ {
+#if 0
+ /* Explanation for this code: I'm only about 95+% sure that the above
+ conditions are sufficient and that all i/o calls are properly
+ adjusting the `where' field. So this is sort of an `assert'
+ that the `where' field is correct. If we can go a while without
+ tripping the abort, we can probably safely disable this code,
+ so that the real optimizations happen. */
+ file_ptr where_am_i_now;
+ where_am_i_now = ftell (bfd_cache_lookup (abfd));
+ if (abfd->my_archive)
+ where_am_i_now -= abfd->origin;
+ if (where_am_i_now != abfd->where)
+ abort ();
+#endif
+ if (direction == SEEK_SET && position == abfd->where)
+ return 0;
+ }
+ else
+ {
+ /* We need something smarter to optimize access to archives.
+ Currently, anything inside an archive is read via the file
+ handle for the archive. Which means that a bfd_seek on one
+ component affects the `current position' in the archive, as
+ well as in any other component.
+
+ It might be sufficient to put a spike through the cache
+ abstraction, and look to the archive for the file position,
+ but I think we should try for something cleaner.
+
+ In the meantime, no optimization for archives. */
+ }
+
+ f = bfd_cache_lookup (abfd);
+ file_position = position;
+ if (direction == SEEK_SET && abfd->my_archive != NULL)
+ file_position += abfd->origin;
+
+ result = fseek (f, file_position, direction);
+
+ if (result != 0)
+ {
+ int hold_errno = errno;
+
+ /* Force redetermination of `where' field. */
+ bfd_tell (abfd);
+
+ /* An EINVAL error probably means that the file offset was
+ absurd. */
+ if (hold_errno == EINVAL)
+ bfd_set_error (bfd_error_file_truncated);
+ else
+ {
+ bfd_set_error (bfd_error_system_call);
+ errno = hold_errno;
+ }
+ }
+ else
+ {
+ /* Adjust `where' field. */
+ if (direction == SEEK_SET)
+ abfd->where = position;
+ else
+ abfd->where += position;
+ }
+ return result;
+}
+
+/** The do-it-yourself (byte) sex-change kit */
+
+/* The middle letter e.g. get<b>short indicates Big or Little endian
+ target machine. It doesn't matter what the byte order of the host
+ machine is; these routines work for either. */
+
+/* FIXME: Should these take a count argument?
+ Answer (gnu@cygnus.com): No, but perhaps they should be inline
+ functions in swap.h #ifdef __GNUC__.
+ Gprof them later and find out. */
+
+/*
+FUNCTION
+ bfd_put_size
+FUNCTION
+ bfd_get_size
+
+DESCRIPTION
+ These macros as used for reading and writing raw data in
+ sections; each access (except for bytes) is vectored through
+ the target format of the BFD and mangled accordingly. The
+ mangling performs any necessary endian translations and
+ removes alignment restrictions. Note that types accepted and
+ returned by these macros are identical so they can be swapped
+ around in macros---for example, @file{libaout.h} defines <<GET_WORD>>
+ to either <<bfd_get_32>> or <<bfd_get_64>>.
+
+ In the put routines, @var{val} must be a <<bfd_vma>>. If we are on a
+ system without prototypes, the caller is responsible for making
+ sure that is true, with a cast if necessary. We don't cast
+ them in the macro definitions because that would prevent <<lint>>
+ or <<gcc -Wall>> from detecting sins such as passing a pointer.
+ To detect calling these with less than a <<bfd_vma>>, use
+ <<gcc -Wconversion>> on a host with 64 bit <<bfd_vma>>'s.
+
+.
+.{* Byte swapping macros for user section data. *}
+.
+.#define bfd_put_8(abfd, val, ptr) \
+. (*((unsigned char *)(ptr)) = (unsigned char)(val))
+.#define bfd_put_signed_8 \
+. bfd_put_8
+.#define bfd_get_8(abfd, ptr) \
+. (*(unsigned char *)(ptr))
+.#define bfd_get_signed_8(abfd, ptr) \
+. ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
+.
+.#define bfd_put_16(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
+.#define bfd_put_signed_16 \
+. bfd_put_16
+.#define bfd_get_16(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx16, (ptr))
+.#define bfd_get_signed_16(abfd, ptr) \
+. BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
+.
+.#define bfd_put_32(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
+.#define bfd_put_signed_32 \
+. bfd_put_32
+.#define bfd_get_32(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx32, (ptr))
+.#define bfd_get_signed_32(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
+.
+.#define bfd_put_64(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
+.#define bfd_put_signed_64 \
+. bfd_put_64
+.#define bfd_get_64(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx64, (ptr))
+.#define bfd_get_signed_64(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
+.
+*/
+
+/*
+FUNCTION
+ bfd_h_put_size
+ bfd_h_get_size
+
+DESCRIPTION
+ These macros have the same function as their <<bfd_get_x>>
+ bretheren, except that they are used for removing information
+ for the header records of object files. Believe it or not,
+ some object files keep their header records in big endian
+ order and their data in little endian order.
+.
+.{* Byte swapping macros for file header data. *}
+.
+.#define bfd_h_put_8(abfd, val, ptr) \
+. bfd_put_8 (abfd, val, ptr)
+.#define bfd_h_put_signed_8(abfd, val, ptr) \
+. bfd_put_8 (abfd, val, ptr)
+.#define bfd_h_get_8(abfd, ptr) \
+. bfd_get_8 (abfd, ptr)
+.#define bfd_h_get_signed_8(abfd, ptr) \
+. bfd_get_signed_8 (abfd, ptr)
+.
+.#define bfd_h_put_16(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
+.#define bfd_h_put_signed_16 \
+. bfd_h_put_16
+.#define bfd_h_get_16(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx16,(ptr))
+.#define bfd_h_get_signed_16(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
+.
+.#define bfd_h_put_32(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
+.#define bfd_h_put_signed_32 \
+. bfd_h_put_32
+.#define bfd_h_get_32(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx32,(ptr))
+.#define bfd_h_get_signed_32(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
+.
+.#define bfd_h_put_64(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
+.#define bfd_h_put_signed_64 \
+. bfd_h_put_64
+.#define bfd_h_get_64(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx64,(ptr))
+.#define bfd_h_get_signed_64(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
+.
+*/
+
+/* Sign extension to bfd_signed_vma. */
+#define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000)
+#define COERCE32(x) \
+ ((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000))
+#define EIGHT_GAZILLION (((BFD_HOST_64_BIT)0x80000000) << 32)
+#define COERCE64(x) \
+ (((bfd_signed_vma) (x) ^ EIGHT_GAZILLION) - EIGHT_GAZILLION)
+
+bfd_vma
+bfd_getb16 (addr)
+ register const bfd_byte *addr;
+{
+ return (addr[0] << 8) | addr[1];
+}
+
+bfd_vma
+bfd_getl16 (addr)
+ register const bfd_byte *addr;
+{
+ return (addr[1] << 8) | addr[0];
+}
+
+bfd_signed_vma
+bfd_getb_signed_16 (addr)
+ register const bfd_byte *addr;
+{
+ return COERCE16((addr[0] << 8) | addr[1]);
+}
+
+bfd_signed_vma
+bfd_getl_signed_16 (addr)
+ register const bfd_byte *addr;
+{
+ return COERCE16((addr[1] << 8) | addr[0]);
+}
+
+void
+bfd_putb16 (data, addr)
+ bfd_vma data;
+ register bfd_byte *addr;
+{
+ addr[0] = (bfd_byte)(data >> 8);
+ addr[1] = (bfd_byte )data;
+}
+
+void
+bfd_putl16 (data, addr)
+ bfd_vma data;
+ register bfd_byte *addr;
+{
+ addr[0] = (bfd_byte )data;
+ addr[1] = (bfd_byte)(data >> 8);
+}
+
+bfd_vma
+bfd_getb32 (addr)
+ register const bfd_byte *addr;
+{
+ unsigned long v;
+
+ v = (unsigned long) addr[0] << 24;
+ v |= (unsigned long) addr[1] << 16;
+ v |= (unsigned long) addr[2] << 8;
+ v |= (unsigned long) addr[3];
+ return (bfd_vma) v;
+}
+
+bfd_vma
+bfd_getl32 (addr)
+ register const bfd_byte *addr;
+{
+ unsigned long v;
+
+ v = (unsigned long) addr[0];
+ v |= (unsigned long) addr[1] << 8;
+ v |= (unsigned long) addr[2] << 16;
+ v |= (unsigned long) addr[3] << 24;
+ return (bfd_vma) v;
+}
+
+bfd_signed_vma
+bfd_getb_signed_32 (addr)
+ register const bfd_byte *addr;
+{
+ unsigned long v;
+
+ v = (unsigned long) addr[0] << 24;
+ v |= (unsigned long) addr[1] << 16;
+ v |= (unsigned long) addr[2] << 8;
+ v |= (unsigned long) addr[3];
+ return COERCE32 (v);
+}
+
+bfd_signed_vma
+bfd_getl_signed_32 (addr)
+ register const bfd_byte *addr;
+{
+ unsigned long v;
+
+ v = (unsigned long) addr[0];
+ v |= (unsigned long) addr[1] << 8;
+ v |= (unsigned long) addr[2] << 16;
+ v |= (unsigned long) addr[3] << 24;
+ return COERCE32 (v);
+}
+
+bfd_vma
+bfd_getb64 (addr)
+ register const bfd_byte *addr;
+{
+#ifdef BFD64
+ bfd_vma low, high;
+
+ high= ((((((((addr[0]) << 8) |
+ addr[1]) << 8) |
+ addr[2]) << 8) |
+ addr[3]) );
+
+ low = (((((((((bfd_vma)addr[4]) << 8) |
+ addr[5]) << 8) |
+ addr[6]) << 8) |
+ addr[7]));
+
+ return high << 32 | low;
+#else
+ BFD_FAIL();
+ return 0;
+#endif
+}
+
+bfd_vma
+bfd_getl64 (addr)
+ register const bfd_byte *addr;
+{
+#ifdef BFD64
+ bfd_vma low, high;
+ high= (((((((addr[7] << 8) |
+ addr[6]) << 8) |
+ addr[5]) << 8) |
+ addr[4]));
+
+ low = ((((((((bfd_vma)addr[3] << 8) |
+ addr[2]) << 8) |
+ addr[1]) << 8) |
+ addr[0]) );
+
+ return high << 32 | low;
+#else
+ BFD_FAIL();
+ return 0;
+#endif
+
+}
+
+bfd_signed_vma
+bfd_getb_signed_64 (addr)
+ register const bfd_byte *addr;
+{
+#ifdef BFD64
+ bfd_vma low, high;
+
+ high= ((((((((addr[0]) << 8) |
+ addr[1]) << 8) |
+ addr[2]) << 8) |
+ addr[3]) );
+
+ low = (((((((((bfd_vma)addr[4]) << 8) |
+ addr[5]) << 8) |
+ addr[6]) << 8) |
+ addr[7]));
+
+ return COERCE64(high << 32 | low);
+#else
+ BFD_FAIL();
+ return 0;
+#endif
+}
+
+bfd_signed_vma
+bfd_getl_signed_64 (addr)
+ register const bfd_byte *addr;
+{
+#ifdef BFD64
+ bfd_vma low, high;
+ high= (((((((addr[7] << 8) |
+ addr[6]) << 8) |
+ addr[5]) << 8) |
+ addr[4]));
+
+ low = ((((((((bfd_vma)addr[3] << 8) |
+ addr[2]) << 8) |
+ addr[1]) << 8) |
+ addr[0]) );
+
+ return COERCE64(high << 32 | low);
+#else
+ BFD_FAIL();
+ return 0;
+#endif
+}
+
+void
+bfd_putb32 (data, addr)
+ bfd_vma data;
+ register bfd_byte *addr;
+{
+ addr[0] = (bfd_byte)(data >> 24);
+ addr[1] = (bfd_byte)(data >> 16);
+ addr[2] = (bfd_byte)(data >> 8);
+ addr[3] = (bfd_byte)data;
+}
+
+void
+bfd_putl32 (data, addr)
+ bfd_vma data;
+ register bfd_byte *addr;
+{
+ addr[0] = (bfd_byte)data;
+ addr[1] = (bfd_byte)(data >> 8);
+ addr[2] = (bfd_byte)(data >> 16);
+ addr[3] = (bfd_byte)(data >> 24);
+}
+
+void
+bfd_putb64 (data, addr)
+ bfd_vma data;
+ register bfd_byte *addr;
+{
+#ifdef BFD64
+ addr[0] = (bfd_byte)(data >> (7*8));
+ addr[1] = (bfd_byte)(data >> (6*8));
+ addr[2] = (bfd_byte)(data >> (5*8));
+ addr[3] = (bfd_byte)(data >> (4*8));
+ addr[4] = (bfd_byte)(data >> (3*8));
+ addr[5] = (bfd_byte)(data >> (2*8));
+ addr[6] = (bfd_byte)(data >> (1*8));
+ addr[7] = (bfd_byte)(data >> (0*8));
+#else
+ BFD_FAIL();
+#endif
+}
+
+void
+bfd_putl64 (data, addr)
+ bfd_vma data;
+ register bfd_byte *addr;
+{
+#ifdef BFD64
+ addr[7] = (bfd_byte)(data >> (7*8));
+ addr[6] = (bfd_byte)(data >> (6*8));
+ addr[5] = (bfd_byte)(data >> (5*8));
+ addr[4] = (bfd_byte)(data >> (4*8));
+ addr[3] = (bfd_byte)(data >> (3*8));
+ addr[2] = (bfd_byte)(data >> (2*8));
+ addr[1] = (bfd_byte)(data >> (1*8));
+ addr[0] = (bfd_byte)(data >> (0*8));
+#else
+ BFD_FAIL();
+#endif
+}
+
+/* Default implementation */
+
+boolean
+_bfd_generic_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (count == 0)
+ return true;
+ if ((bfd_size_type)(offset+count) > section->_raw_size
+ || bfd_seek(abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1
+ || bfd_read(location, (bfd_size_type)1, count, abfd) != count)
+ return (false); /* on error */
+ return (true);
+}
+
+boolean
+_bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ bfd_window *w;
+ file_ptr offset;
+ bfd_size_type count;
+{
+#ifdef USE_MMAP
+ if (count == 0)
+ return true;
+ if (abfd->xvec->_bfd_get_section_contents != _bfd_generic_get_section_contents)
+ {
+ /* We don't know what changes the bfd's get_section_contents
+ method may have to make. So punt trying to map the file
+ window, and let get_section_contents do its thing. */
+ /* @@ FIXME : If the internal window has a refcount of 1 and was
+ allocated with malloc instead of mmap, just reuse it. */
+ bfd_free_window (w);
+ w->i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
+ if (w->i == NULL)
+ return false;
+ w->i->data = (PTR) bfd_malloc ((size_t) count);
+ if (w->i->data == NULL)
+ {
+ free (w->i);
+ w->i = NULL;
+ return false;
+ }
+ w->i->mapped = 0;
+ w->i->refcount = 1;
+ w->size = w->i->size = count;
+ w->data = w->i->data;
+ return bfd_get_section_contents (abfd, section, w->data, offset, count);
+ }
+ if ((bfd_size_type) (offset+count) > section->_raw_size
+ || (bfd_get_file_window (abfd, section->filepos + offset, count, w, true)
+ == false))
+ return false;
+ return true;
+#else
+ abort ();
+#endif
+}
+
+/* This generic function can only be used in implementations where creating
+ NEW sections is disallowed. It is useful in patching existing sections
+ in read-write files, though. See other set_section_contents functions
+ to see why it doesn't work for new sections. */
+boolean
+_bfd_generic_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (count == 0)
+ return true;
+
+ if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) == -1
+ || bfd_write (location, (bfd_size_type) 1, count, abfd) != count)
+ return false;
+
+ return true;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_log2
+
+SYNOPSIS
+ unsigned int bfd_log2(bfd_vma x);
+
+DESCRIPTION
+ Return the log base 2 of the value supplied, rounded up. E.g., an
+ @var{x} of 1025 returns 11.
+*/
+
+unsigned int
+bfd_log2 (x)
+ bfd_vma x;
+{
+ unsigned int result = 0;
+
+ while ((((bfd_vma) 1) << result) < x)
+ ++result;
+ return result;
+}
+
+boolean
+bfd_generic_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ char locals_prefix = (bfd_get_symbol_leading_char (abfd) == '_') ? 'L' : '.';
+
+ return (name[0] == locals_prefix);
+}
+
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
new file mode 100644
index 00000000000..f804bde593c
--- /dev/null
+++ b/bfd/libbfd.h
@@ -0,0 +1,885 @@
+/* libbfd.h -- Declarations used by bfd library *implementation*.
+ (This include file is not for users of the library.)
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+** NOTE: libbfd.h is a GENERATED file. Don't change it; instead,
+** change libbfd-in.h or the other BFD source files processed to
+** generate this file.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Align an address upward to a boundary, expressed as a number of bytes.
+ E.g. align to an 8-byte boundary with argument of 8. Take care never
+ to wrap around if the address is within boundary-1 of the end of the
+ address space. */
+#define BFD_ALIGN(this, boundary) \
+ ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
+ ? (((bfd_vma) (this) + ((boundary) - 1)) & (~((boundary)-1))) \
+ : ~ (bfd_vma) 0)
+
+/* If you want to read and write large blocks, you might want to do it
+ in quanta of this amount */
+#define DEFAULT_BUFFERSIZE 8192
+
+/* Set a tdata field. Can't use the other macros for this, since they
+ do casts, and casting to the left of assignment isn't portable. */
+#define set_tdata(bfd, v) ((bfd)->tdata.any = (PTR) (v))
+
+/* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
+ to an instance of this structure. */
+
+struct bfd_in_memory
+{
+ /* Size of buffer. */
+ bfd_size_type size;
+ /* Buffer holding contents of BFD. */
+ bfd_byte *buffer;
+};
+
+/* tdata for an archive. For an input archive, cache
+ needs to be free()'d. For an output archive, symdefs do. */
+
+struct artdata {
+ file_ptr first_file_filepos;
+ /* Speed up searching the armap */
+ struct ar_cache *cache;
+ bfd *archive_head; /* Only interesting in output routines */
+ carsym *symdefs; /* the symdef entries */
+ symindex symdef_count; /* how many there are */
+ char *extended_names; /* clever intel extension */
+ /* when more compilers are standard C, this can be a time_t */
+ long armap_timestamp; /* Timestamp value written into armap.
+ This is used for BSD archives to check
+ that the timestamp is recent enough
+ for the BSD linker to not complain,
+ just before we finish writing an
+ archive. */
+ file_ptr armap_datepos; /* Position within archive to seek to
+ rewrite the date field. */
+ PTR tdata; /* Backend specific information. */
+};
+
+#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
+
+/* Goes in bfd's arelt_data slot */
+struct areltdata {
+ char * arch_header; /* it's actually a string */
+ unsigned int parsed_size; /* octets of filesize not including ar_hdr */
+ char *filename; /* null-terminated */
+};
+
+#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
+
+extern PTR bfd_malloc PARAMS ((size_t));
+extern PTR bfd_realloc PARAMS ((PTR, size_t));
+extern PTR bfd_zmalloc PARAMS ((size_t));
+
+extern bfd_error_handler_type _bfd_error_handler;
+
+/* These routines allocate and free things on the BFD's objalloc. */
+
+extern PTR bfd_alloc PARAMS ((bfd *, size_t));
+extern PTR bfd_zalloc PARAMS ((bfd *, size_t));
+extern void bfd_release PARAMS ((bfd *, PTR));
+
+bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
+bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
+boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
+boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
+const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
+boolean bfd_slurp_armap PARAMS ((bfd *abfd));
+boolean bfd_slurp_bsd_armap_f2 PARAMS ((bfd *abfd));
+#define bfd_slurp_bsd_armap bfd_slurp_armap
+#define bfd_slurp_coff_armap bfd_slurp_armap
+boolean _bfd_slurp_extended_name_table PARAMS ((bfd *abfd));
+extern boolean _bfd_construct_extended_name_table
+ PARAMS ((bfd *, boolean, char **, bfd_size_type *));
+boolean _bfd_write_archive_contents PARAMS ((bfd *abfd));
+boolean _bfd_compute_and_write_armap PARAMS ((bfd *, unsigned int elength));
+bfd *_bfd_get_elt_at_filepos PARAMS ((bfd *archive, file_ptr filepos));
+extern bfd *_bfd_generic_get_elt_at_index PARAMS ((bfd *, symindex));
+bfd * _bfd_new_bfd PARAMS ((void));
+
+boolean bfd_false PARAMS ((bfd *ignore));
+boolean bfd_true PARAMS ((bfd *ignore));
+PTR bfd_nullvoidptr PARAMS ((bfd *ignore));
+int bfd_0 PARAMS ((bfd *ignore));
+unsigned int bfd_0u PARAMS ((bfd *ignore));
+long bfd_0l PARAMS ((bfd *ignore));
+long _bfd_n1 PARAMS ((bfd *ignore));
+void bfd_void PARAMS ((bfd *ignore));
+
+bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
+const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
+
+void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
+ char *hdr));
+void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
+ char *hdr));
+void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
+ char *hdr));
+
+boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,
+ struct orl *map, unsigned int orl_count, int stridx));
+
+boolean coff_write_armap PARAMS ((bfd *arch, unsigned int elength,
+ struct orl *map, unsigned int orl_count, int stridx));
+
+extern PTR _bfd_generic_read_ar_hdr PARAMS ((bfd *));
+
+extern PTR _bfd_generic_read_ar_hdr_mag PARAMS ((bfd *, const char *));
+
+bfd * bfd_generic_openr_next_archived_file PARAMS ((bfd *archive,
+ bfd *last_file));
+
+int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
+
+#define _bfd_read_ar_hdr(abfd) \
+ BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
+
+/* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
+
+#define _bfd_generic_close_and_cleanup bfd_true
+#define _bfd_generic_bfd_free_cached_info bfd_true
+#define _bfd_generic_new_section_hook \
+ ((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
+extern boolean _bfd_generic_get_section_contents
+ PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
+ bfd_size_type count));
+extern boolean _bfd_generic_get_section_contents_in_window
+ PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
+
+/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
+ BFD_JUMP_TABLE_COPY (_bfd_generic). */
+
+#define _bfd_generic_bfd_copy_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+#define _bfd_generic_bfd_merge_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+#define _bfd_generic_bfd_set_private_flags \
+ ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
+#define _bfd_generic_bfd_copy_private_section_data \
+ ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
+#define _bfd_generic_bfd_copy_private_symbol_data \
+ ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
+#define _bfd_generic_bfd_print_private_bfd_data \
+ ((boolean (*) PARAMS ((bfd *, PTR))) bfd_true)
+
+/* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
+ support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
+
+extern char *_bfd_nocore_core_file_failing_command PARAMS ((bfd *));
+extern int _bfd_nocore_core_file_failing_signal PARAMS ((bfd *));
+extern boolean _bfd_nocore_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
+
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
+ file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
+
+#define _bfd_noarchive_slurp_armap bfd_false
+#define _bfd_noarchive_slurp_extended_name_table bfd_false
+#define _bfd_noarchive_construct_extended_name_table \
+ ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
+ bfd_false)
+#define _bfd_noarchive_truncate_arname \
+ ((void (*) PARAMS ((bfd *, const char *, char *))) bfd_void)
+#define _bfd_noarchive_write_armap \
+ ((boolean (*) \
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
+ bfd_false)
+#define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
+#define _bfd_noarchive_openr_next_archived_file \
+ ((bfd *(*) PARAMS ((bfd *, bfd *))) bfd_nullvoidptr)
+#define _bfd_noarchive_get_elt_at_index \
+ ((bfd *(*) PARAMS ((bfd *, symindex))) bfd_nullvoidptr)
+#define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define _bfd_noarchive_update_armap_timestamp bfd_false
+
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
+ archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
+
+#define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
+#define _bfd_archive_bsd_slurp_extended_name_table \
+ _bfd_slurp_extended_name_table
+extern boolean _bfd_archive_bsd_construct_extended_name_table
+ PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+#define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
+#define _bfd_archive_bsd_write_armap bsd_write_armap
+#define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_bsd_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_archive_bsd_generic_stat_arch_elt \
+ bfd_generic_stat_arch_elt
+extern boolean _bfd_archive_bsd_update_armap_timestamp PARAMS ((bfd *));
+
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
+ archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
+
+#define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
+#define _bfd_archive_coff_slurp_extended_name_table \
+ _bfd_slurp_extended_name_table
+extern boolean _bfd_archive_coff_construct_extended_name_table
+ PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+#define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
+#define _bfd_archive_coff_write_armap coff_write_armap
+#define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_coff_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_archive_coff_generic_stat_arch_elt \
+ bfd_generic_stat_arch_elt
+#define _bfd_archive_coff_update_armap_timestamp bfd_true
+
+/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
+ support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
+
+#define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
+#define _bfd_nosymbols_get_symtab \
+ ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
+#define _bfd_nosymbols_make_empty_symbol \
+ ((asymbol *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define _bfd_nosymbols_print_symbol \
+ ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_void)
+#define _bfd_nosymbols_get_symbol_info \
+ ((void (*) PARAMS ((bfd *, asymbol *, symbol_info *))) bfd_void)
+#define _bfd_nosymbols_bfd_is_local_label_name \
+ ((boolean (*) PARAMS ((bfd *, const char *))) bfd_false)
+#define _bfd_nosymbols_get_lineno \
+ ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
+#define _bfd_nosymbols_find_nearest_line \
+ ((boolean (*) \
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, \
+ const char **, unsigned int *))) \
+ bfd_false)
+#define _bfd_nosymbols_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, PTR, unsigned long))) bfd_nullvoidptr)
+#define _bfd_nosymbols_read_minisymbols \
+ ((long (*) PARAMS ((bfd *, boolean, PTR *, unsigned int *))) _bfd_n1)
+#define _bfd_nosymbols_minisymbol_to_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, boolean, const PTR, asymbol *))) \
+ bfd_nullvoidptr)
+
+/* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
+ support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
+
+#define _bfd_norelocs_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) _bfd_n1)
+#define _bfd_norelocs_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) _bfd_n1)
+#define _bfd_norelocs_bfd_reloc_type_lookup \
+ ((reloc_howto_type *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) \
+ bfd_nullvoidptr)
+
+/* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
+ be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
+
+#define _bfd_nowrite_set_arch_mach \
+ ((boolean (*) PARAMS ((bfd *, enum bfd_architecture, unsigned long))) \
+ bfd_false)
+#define _bfd_nowrite_set_section_contents \
+ ((boolean (*) PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type))) \
+ bfd_false)
+
+/* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
+ BFD_JUMP_TABLE_WRITE (_bfd_generic). */
+
+#define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
+extern boolean _bfd_generic_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+
+/* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
+ support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
+
+#define _bfd_nolink_sizeof_headers ((int (*) PARAMS ((bfd *, boolean))) bfd_0)
+#define _bfd_nolink_bfd_get_relocated_section_contents \
+ ((bfd_byte *(*) \
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, \
+ bfd_byte *, boolean, asymbol **))) \
+ bfd_nullvoidptr)
+#define _bfd_nolink_bfd_relax_section \
+ ((boolean (*) \
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *))) \
+ bfd_false)
+#define _bfd_nolink_bfd_gc_sections \
+ ((boolean (*) \
+ PARAMS ((bfd *, struct bfd_link_info *))) \
+ bfd_false)
+#define _bfd_nolink_bfd_link_hash_table_create \
+ ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define _bfd_nolink_bfd_link_add_symbols \
+ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
+#define _bfd_nolink_bfd_final_link \
+ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
+#define _bfd_nolink_bfd_link_split_section \
+ ((boolean (*) PARAMS ((bfd *, struct sec *))) bfd_false)
+
+/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
+ have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
+ (_bfd_nodynamic). */
+
+#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
+#define _bfd_nodynamic_canonicalize_dynamic_symtab \
+ ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
+#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
+#define _bfd_nodynamic_canonicalize_dynamic_reloc \
+ ((long (*) PARAMS ((bfd *, arelent **, asymbol **))) _bfd_n1)
+
+/* Generic routine to determine of the given symbol is a local
+ label. */
+extern boolean bfd_generic_is_local_label_name PARAMS ((bfd *, const char *));
+
+/* Generic minisymbol routines. */
+extern long _bfd_generic_read_minisymbols
+ PARAMS ((bfd *, boolean, PTR *, unsigned int *));
+extern asymbol *_bfd_generic_minisymbol_to_symbol
+ PARAMS ((bfd *, boolean, const PTR, asymbol *));
+
+/* Find the nearest line using .stab/.stabstr sections. */
+extern boolean _bfd_stab_section_find_nearest_line
+ PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
+ const char **, unsigned int *, PTR *));
+
+/* Find the neaderst line using DWARF 1 debugging information. */
+extern boolean _bfd_dwarf1_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+
+/* Find the nearest line using DWARF 2 debugging information. */
+extern boolean _bfd_dwarf2_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+
+/* A routine to create entries for a bfd_link_hash_table. */
+extern struct bfd_hash_entry *_bfd_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string));
+
+/* Initialize a bfd_link_hash_table. */
+extern boolean _bfd_link_hash_table_init
+ PARAMS ((struct bfd_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+/* Generic link hash table creation routine. */
+extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
+ PARAMS ((bfd *));
+
+/* Generic add symbol routine. */
+extern boolean _bfd_generic_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Generic add symbol routine. This version is used by targets for
+ which the linker must collect constructors and destructors by name,
+ as the collect2 program does. */
+extern boolean _bfd_generic_link_add_symbols_collect
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Generic archive add symbol routine. */
+extern boolean _bfd_generic_link_add_archive_symbols
+ PARAMS ((bfd *, struct bfd_link_info *,
+ boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *)));
+
+
+
+/* Forward declaration to avoid prototype errors. */
+typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
+
+/* Generic routine to add a single symbol. */
+extern boolean _bfd_generic_link_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *name, flagword,
+ asection *, bfd_vma, const char *, boolean copy,
+ boolean constructor, struct bfd_link_hash_entry **));
+
+/* Generic link routine. */
+extern boolean _bfd_generic_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+extern boolean _bfd_generic_link_split_section
+ PARAMS ((bfd *, struct sec *));
+
+/* Generic reloc_link_order processing routine. */
+extern boolean _bfd_generic_reloc_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* Default link order processing routine. */
+extern boolean _bfd_default_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+
+/* Count the number of reloc entries in a link order list. */
+extern unsigned int _bfd_count_link_order_relocs
+ PARAMS ((struct bfd_link_order *));
+
+/* Final link relocation routine. */
+extern bfd_reloc_status_type _bfd_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
+ bfd_vma address, bfd_vma value, bfd_vma addend));
+
+/* Relocate a particular location by a howto and a value. */
+extern bfd_reloc_status_type _bfd_relocate_contents
+ PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
+
+/* Link stabs in sections in the first pass. */
+
+extern boolean _bfd_link_section_stabs
+ PARAMS ((bfd *, PTR *, asection *, asection *, PTR *));
+
+/* Write out the .stab section when linking stabs in sections. */
+
+extern boolean _bfd_write_section_stabs
+ PARAMS ((bfd *, PTR *, asection *, PTR *, bfd_byte *));
+
+/* Write out the .stabstr string table when linking stabs in sections. */
+
+extern boolean _bfd_write_stab_strings PARAMS ((bfd *, PTR *));
+
+/* Find an offset within a .stab section when linking stabs in
+ sections. */
+
+extern bfd_vma _bfd_stab_section_offset
+ PARAMS ((bfd *, PTR *, asection *, PTR *, bfd_vma));
+
+/* Create a string table. */
+extern struct bfd_strtab_hash *_bfd_stringtab_init PARAMS ((void));
+
+/* Create an XCOFF .debug section style string table. */
+extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init PARAMS ((void));
+
+/* Free a string table. */
+extern void _bfd_stringtab_free PARAMS ((struct bfd_strtab_hash *));
+
+/* Get the size of a string table. */
+extern bfd_size_type _bfd_stringtab_size PARAMS ((struct bfd_strtab_hash *));
+
+/* Add a string to a string table. */
+extern bfd_size_type _bfd_stringtab_add
+ PARAMS ((struct bfd_strtab_hash *, const char *, boolean hash,
+ boolean copy));
+
+/* Write out a string table. */
+extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *));
+
+/* Macros to tell if bfds are read or write enabled.
+
+ Note that bfds open for read may be scribbled into if the fd passed
+ to bfd_fdopenr is actually open both for read and write
+ simultaneously. However an output bfd will never be open for
+ read. Therefore sometimes you want to check bfd_read_p or
+ !bfd_read_p, and only sometimes bfd_write_p.
+*/
+
+#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
+#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
+
+void bfd_assert PARAMS ((const char*,int));
+
+#define BFD_ASSERT(x) \
+{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
+
+#define BFD_FAIL() \
+{ bfd_assert(__FILE__,__LINE__); }
+
+FILE * bfd_cache_lookup_worker PARAMS ((bfd *));
+
+extern bfd *bfd_last_cache;
+
+/* List of supported target vectors, and the default vector (if
+ bfd_default_vector[0] is NULL, there is no default). */
+extern const bfd_target * const bfd_target_vector[];
+extern const bfd_target *bfd_default_vector[];
+
+/* Functions shared by the ECOFF and MIPS ELF backends, which have no
+ other common header files. */
+
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct ecoff_find_line;
+#endif
+
+extern boolean _bfd_ecoff_locate_line
+ PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
+ const struct ecoff_debug_swap * const, struct ecoff_find_line *,
+ const char **, const char **, unsigned int *));
+extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
+extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
+extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
+
+extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *));
+extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma));
+
+/* Function shared by the COFF and ELF SH backends, which have no
+ other common header files. */
+
+extern boolean _bfd_sh_align_load_span
+ PARAMS ((bfd *, asection *, bfd_byte *,
+ boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma),
+ PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, boolean *));
+
+/* And more follows */
+
+void
+bfd_write_bigendian_4byte_int PARAMS ((bfd *abfd, int i));
+
+unsigned int
+bfd_log2 PARAMS ((bfd_vma x));
+
+#define BFD_CACHE_MAX_OPEN 10
+extern bfd *bfd_last_cache;
+
+#define bfd_cache_lookup(x) \
+ ((x)==bfd_last_cache? \
+ (FILE*)(bfd_last_cache->iostream): \
+ bfd_cache_lookup_worker(x))
+boolean
+bfd_cache_init PARAMS ((bfd *abfd));
+
+boolean
+bfd_cache_close PARAMS ((bfd *abfd));
+
+FILE*
+bfd_open_file PARAMS ((bfd *abfd));
+
+FILE *
+bfd_cache_lookup_worker PARAMS ((bfd *abfd));
+
+#ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real
+
+static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
+
+ "BFD_RELOC_64",
+ "BFD_RELOC_32",
+ "BFD_RELOC_26",
+ "BFD_RELOC_24",
+ "BFD_RELOC_16",
+ "BFD_RELOC_14",
+ "BFD_RELOC_8",
+ "BFD_RELOC_64_PCREL",
+ "BFD_RELOC_32_PCREL",
+ "BFD_RELOC_24_PCREL",
+ "BFD_RELOC_16_PCREL",
+ "BFD_RELOC_12_PCREL",
+ "BFD_RELOC_8_PCREL",
+ "BFD_RELOC_32_GOT_PCREL",
+ "BFD_RELOC_16_GOT_PCREL",
+ "BFD_RELOC_8_GOT_PCREL",
+ "BFD_RELOC_32_GOTOFF",
+ "BFD_RELOC_16_GOTOFF",
+ "BFD_RELOC_LO16_GOTOFF",
+ "BFD_RELOC_HI16_GOTOFF",
+ "BFD_RELOC_HI16_S_GOTOFF",
+ "BFD_RELOC_8_GOTOFF",
+ "BFD_RELOC_32_PLT_PCREL",
+ "BFD_RELOC_24_PLT_PCREL",
+ "BFD_RELOC_16_PLT_PCREL",
+ "BFD_RELOC_8_PLT_PCREL",
+ "BFD_RELOC_32_PLTOFF",
+ "BFD_RELOC_16_PLTOFF",
+ "BFD_RELOC_LO16_PLTOFF",
+ "BFD_RELOC_HI16_PLTOFF",
+ "BFD_RELOC_HI16_S_PLTOFF",
+ "BFD_RELOC_8_PLTOFF",
+ "BFD_RELOC_68K_GLOB_DAT",
+ "BFD_RELOC_68K_JMP_SLOT",
+ "BFD_RELOC_68K_RELATIVE",
+ "BFD_RELOC_32_BASEREL",
+ "BFD_RELOC_16_BASEREL",
+ "BFD_RELOC_LO16_BASEREL",
+ "BFD_RELOC_HI16_BASEREL",
+ "BFD_RELOC_HI16_S_BASEREL",
+ "BFD_RELOC_8_BASEREL",
+ "BFD_RELOC_RVA",
+ "BFD_RELOC_8_FFnn",
+ "BFD_RELOC_32_PCREL_S2",
+ "BFD_RELOC_16_PCREL_S2",
+ "BFD_RELOC_23_PCREL_S2",
+ "BFD_RELOC_HI22",
+ "BFD_RELOC_LO10",
+ "BFD_RELOC_GPREL16",
+ "BFD_RELOC_GPREL32",
+ "BFD_RELOC_I960_CALLJ",
+ "BFD_RELOC_NONE",
+ "BFD_RELOC_SPARC_WDISP22",
+ "BFD_RELOC_SPARC22",
+ "BFD_RELOC_SPARC13",
+ "BFD_RELOC_SPARC_GOT10",
+ "BFD_RELOC_SPARC_GOT13",
+ "BFD_RELOC_SPARC_GOT22",
+ "BFD_RELOC_SPARC_PC10",
+ "BFD_RELOC_SPARC_PC22",
+ "BFD_RELOC_SPARC_WPLT30",
+ "BFD_RELOC_SPARC_COPY",
+ "BFD_RELOC_SPARC_GLOB_DAT",
+ "BFD_RELOC_SPARC_JMP_SLOT",
+ "BFD_RELOC_SPARC_RELATIVE",
+ "BFD_RELOC_SPARC_UA32",
+ "BFD_RELOC_SPARC_BASE13",
+ "BFD_RELOC_SPARC_BASE22",
+ "BFD_RELOC_SPARC_10",
+ "BFD_RELOC_SPARC_11",
+ "BFD_RELOC_SPARC_OLO10",
+ "BFD_RELOC_SPARC_HH22",
+ "BFD_RELOC_SPARC_HM10",
+ "BFD_RELOC_SPARC_LM22",
+ "BFD_RELOC_SPARC_PC_HH22",
+ "BFD_RELOC_SPARC_PC_HM10",
+ "BFD_RELOC_SPARC_PC_LM22",
+ "BFD_RELOC_SPARC_WDISP16",
+ "BFD_RELOC_SPARC_WDISP19",
+ "BFD_RELOC_SPARC_7",
+ "BFD_RELOC_SPARC_6",
+ "BFD_RELOC_SPARC_5",
+ "BFD_RELOC_SPARC_PLT64",
+ "BFD_RELOC_SPARC_HIX22",
+ "BFD_RELOC_SPARC_LOX10",
+ "BFD_RELOC_SPARC_H44",
+ "BFD_RELOC_SPARC_M44",
+ "BFD_RELOC_SPARC_L44",
+ "BFD_RELOC_SPARC_REGISTER",
+ "BFD_RELOC_SPARC_REV32",
+ "BFD_RELOC_ALPHA_GPDISP_HI16",
+ "BFD_RELOC_ALPHA_GPDISP_LO16",
+ "BFD_RELOC_ALPHA_GPDISP",
+ "BFD_RELOC_ALPHA_LITERAL",
+ "BFD_RELOC_ALPHA_ELF_LITERAL",
+ "BFD_RELOC_ALPHA_LITUSE",
+ "BFD_RELOC_ALPHA_HINT",
+ "BFD_RELOC_ALPHA_LINKAGE",
+ "BFD_RELOC_ALPHA_CODEADDR",
+ "BFD_RELOC_MIPS_JMP",
+ "BFD_RELOC_MIPS16_JMP",
+ "BFD_RELOC_MIPS16_GPREL",
+ "BFD_RELOC_HI16",
+ "BFD_RELOC_HI16_S",
+ "BFD_RELOC_LO16",
+ "BFD_RELOC_PCREL_HI16_S",
+ "BFD_RELOC_PCREL_LO16",
+ "BFD_RELOC_MIPS_LITERAL",
+ "BFD_RELOC_MIPS_GOT16",
+ "BFD_RELOC_MIPS_CALL16",
+ "BFD_RELOC_MIPS_GOT_HI16",
+ "BFD_RELOC_MIPS_GOT_LO16",
+ "BFD_RELOC_MIPS_CALL_HI16",
+ "BFD_RELOC_MIPS_CALL_LO16",
+
+ "BFD_RELOC_386_GOT32",
+ "BFD_RELOC_386_PLT32",
+ "BFD_RELOC_386_COPY",
+ "BFD_RELOC_386_GLOB_DAT",
+ "BFD_RELOC_386_JUMP_SLOT",
+ "BFD_RELOC_386_RELATIVE",
+ "BFD_RELOC_386_GOTOFF",
+ "BFD_RELOC_386_GOTPC",
+ "BFD_RELOC_NS32K_IMM_8",
+ "BFD_RELOC_NS32K_IMM_16",
+ "BFD_RELOC_NS32K_IMM_32",
+ "BFD_RELOC_NS32K_IMM_8_PCREL",
+ "BFD_RELOC_NS32K_IMM_16_PCREL",
+ "BFD_RELOC_NS32K_IMM_32_PCREL",
+ "BFD_RELOC_NS32K_DISP_8",
+ "BFD_RELOC_NS32K_DISP_16",
+ "BFD_RELOC_NS32K_DISP_32",
+ "BFD_RELOC_NS32K_DISP_8_PCREL",
+ "BFD_RELOC_NS32K_DISP_16_PCREL",
+ "BFD_RELOC_NS32K_DISP_32_PCREL",
+ "BFD_RELOC_PPC_B26",
+ "BFD_RELOC_PPC_BA26",
+ "BFD_RELOC_PPC_TOC16",
+ "BFD_RELOC_PPC_B16",
+ "BFD_RELOC_PPC_B16_BRTAKEN",
+ "BFD_RELOC_PPC_B16_BRNTAKEN",
+ "BFD_RELOC_PPC_BA16",
+ "BFD_RELOC_PPC_BA16_BRTAKEN",
+ "BFD_RELOC_PPC_BA16_BRNTAKEN",
+ "BFD_RELOC_PPC_COPY",
+ "BFD_RELOC_PPC_GLOB_DAT",
+ "BFD_RELOC_PPC_JMP_SLOT",
+ "BFD_RELOC_PPC_RELATIVE",
+ "BFD_RELOC_PPC_LOCAL24PC",
+ "BFD_RELOC_PPC_EMB_NADDR32",
+ "BFD_RELOC_PPC_EMB_NADDR16",
+ "BFD_RELOC_PPC_EMB_NADDR16_LO",
+ "BFD_RELOC_PPC_EMB_NADDR16_HI",
+ "BFD_RELOC_PPC_EMB_NADDR16_HA",
+ "BFD_RELOC_PPC_EMB_SDAI16",
+ "BFD_RELOC_PPC_EMB_SDA2I16",
+ "BFD_RELOC_PPC_EMB_SDA2REL",
+ "BFD_RELOC_PPC_EMB_SDA21",
+ "BFD_RELOC_PPC_EMB_MRKREF",
+ "BFD_RELOC_PPC_EMB_RELSEC16",
+ "BFD_RELOC_PPC_EMB_RELST_LO",
+ "BFD_RELOC_PPC_EMB_RELST_HI",
+ "BFD_RELOC_PPC_EMB_RELST_HA",
+ "BFD_RELOC_PPC_EMB_BIT_FLD",
+ "BFD_RELOC_PPC_EMB_RELSDA",
+ "BFD_RELOC_CTOR",
+ "BFD_RELOC_ARM_PCREL_BRANCH",
+ "BFD_RELOC_ARM_IMMEDIATE",
+ "BFD_RELOC_ARM_OFFSET_IMM",
+ "BFD_RELOC_ARM_SHIFT_IMM",
+ "BFD_RELOC_ARM_SWI",
+ "BFD_RELOC_ARM_MULTI",
+ "BFD_RELOC_ARM_CP_OFF_IMM",
+ "BFD_RELOC_ARM_ADR_IMM",
+ "BFD_RELOC_ARM_LDR_IMM",
+ "BFD_RELOC_ARM_LITERAL",
+ "BFD_RELOC_ARM_IN_POOL",
+ "BFD_RELOC_ARM_OFFSET_IMM8",
+ "BFD_RELOC_ARM_HWLITERAL",
+ "BFD_RELOC_ARM_THUMB_ADD",
+ "BFD_RELOC_ARM_THUMB_IMM",
+ "BFD_RELOC_ARM_THUMB_SHIFT",
+ "BFD_RELOC_ARM_THUMB_OFFSET",
+ "BFD_RELOC_ARM_GOT12",
+ "BFD_RELOC_ARM_GOT32",
+ "BFD_RELOC_ARM_JUMP_SLOT",
+ "BFD_RELOC_ARM_COPY",
+ "BFD_RELOC_ARM_GLOB_DAT",
+ "BFD_RELOC_ARM_PLT32",
+ "BFD_RELOC_ARM_RELATIVE",
+ "BFD_RELOC_ARM_GOTOFF",
+ "BFD_RELOC_ARM_GOTPC",
+ "BFD_RELOC_SH_PCDISP8BY2",
+ "BFD_RELOC_SH_PCDISP12BY2",
+ "BFD_RELOC_SH_IMM4",
+ "BFD_RELOC_SH_IMM4BY2",
+ "BFD_RELOC_SH_IMM4BY4",
+ "BFD_RELOC_SH_IMM8",
+ "BFD_RELOC_SH_IMM8BY2",
+ "BFD_RELOC_SH_IMM8BY4",
+ "BFD_RELOC_SH_PCRELIMM8BY2",
+ "BFD_RELOC_SH_PCRELIMM8BY4",
+ "BFD_RELOC_SH_SWITCH16",
+ "BFD_RELOC_SH_SWITCH32",
+ "BFD_RELOC_SH_USES",
+ "BFD_RELOC_SH_COUNT",
+ "BFD_RELOC_SH_ALIGN",
+ "BFD_RELOC_SH_CODE",
+ "BFD_RELOC_SH_DATA",
+ "BFD_RELOC_SH_LABEL",
+ "BFD_RELOC_THUMB_PCREL_BRANCH9",
+ "BFD_RELOC_THUMB_PCREL_BRANCH12",
+ "BFD_RELOC_THUMB_PCREL_BRANCH23",
+ "BFD_RELOC_ARC_B22_PCREL",
+ "BFD_RELOC_ARC_B26",
+ "BFD_RELOC_D10V_10_PCREL_R",
+ "BFD_RELOC_D10V_10_PCREL_L",
+ "BFD_RELOC_D10V_18",
+ "BFD_RELOC_D10V_18_PCREL",
+ "BFD_RELOC_D30V_6",
+ "BFD_RELOC_D30V_9_PCREL",
+ "BFD_RELOC_D30V_9_PCREL_R",
+ "BFD_RELOC_D30V_15",
+ "BFD_RELOC_D30V_15_PCREL",
+ "BFD_RELOC_D30V_15_PCREL_R",
+ "BFD_RELOC_D30V_21",
+ "BFD_RELOC_D30V_21_PCREL",
+ "BFD_RELOC_D30V_21_PCREL_R",
+ "BFD_RELOC_D30V_32",
+ "BFD_RELOC_D30V_32_PCREL",
+ "BFD_RELOC_M32R_24",
+ "BFD_RELOC_M32R_10_PCREL",
+ "BFD_RELOC_M32R_18_PCREL",
+ "BFD_RELOC_M32R_26_PCREL",
+ "BFD_RELOC_M32R_HI16_ULO",
+ "BFD_RELOC_M32R_HI16_SLO",
+ "BFD_RELOC_M32R_LO16",
+ "BFD_RELOC_M32R_SDA16",
+ "BFD_RELOC_V850_9_PCREL",
+ "BFD_RELOC_V850_22_PCREL",
+ "BFD_RELOC_V850_SDA_16_16_OFFSET",
+ "BFD_RELOC_V850_SDA_15_16_OFFSET",
+ "BFD_RELOC_V850_ZDA_16_16_OFFSET",
+ "BFD_RELOC_V850_ZDA_15_16_OFFSET",
+ "BFD_RELOC_V850_TDA_6_8_OFFSET",
+ "BFD_RELOC_V850_TDA_7_8_OFFSET",
+ "BFD_RELOC_V850_TDA_7_7_OFFSET",
+ "BFD_RELOC_V850_TDA_16_16_OFFSET",
+ "BFD_RELOC_V850_TDA_4_5_OFFSET",
+ "BFD_RELOC_V850_TDA_4_4_OFFSET",
+ "BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET",
+ "BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET",
+ "BFD_RELOC_V850_CALLT_6_7_OFFSET",
+ "BFD_RELOC_V850_CALLT_16_16_OFFSET",
+
+ "BFD_RELOC_MN10300_32_PCREL",
+ "BFD_RELOC_MN10300_16_PCREL",
+ "BFD_RELOC_TIC30_LDP",
+ "BFD_RELOC_FR30_48",
+ "BFD_RELOC_FR30_20",
+ "BFD_RELOC_FR30_6_IN_4",
+ "BFD_RELOC_FR30_8_IN_8",
+ "BFD_RELOC_FR30_9_IN_8",
+ "BFD_RELOC_FR30_10_IN_8",
+ "BFD_RELOC_FR30_9_PCREL",
+ "BFD_RELOC_FR30_12_PCREL",
+ "BFD_RELOC_MCORE_PCREL_IMM8BY4",
+ "BFD_RELOC_MCORE_PCREL_IMM11BY2",
+ "BFD_RELOC_MCORE_PCREL_IMM4BY2",
+ "BFD_RELOC_MCORE_PCREL_32",
+ "BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2",
+ "BFD_RELOC_VTABLE_INHERIT",
+ "BFD_RELOC_VTABLE_ENTRY",
+ "@@overflow: BFD_RELOC_UNUSED@@",
+};
+#endif
+
+reloc_howto_type *
+bfd_default_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+
+boolean
+bfd_generic_relax_section
+ PARAMS ((bfd *abfd,
+ asection *section,
+ struct bfd_link_info *,
+ boolean *));
+
+boolean
+bfd_generic_gc_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+bfd_byte *
+
+bfd_generic_get_relocated_section_contents PARAMS ((bfd *abfd,
+ struct bfd_link_info *link_info,
+ struct bfd_link_order *link_order,
+ bfd_byte *data,
+ boolean relocateable,
+ asymbol **symbols));
+
+extern const bfd_arch_info_type bfd_default_arch_struct;
+boolean
+bfd_default_set_arch_mach PARAMS ((bfd *abfd,
+ enum bfd_architecture arch,
+ unsigned long mach));
+
+const bfd_arch_info_type *
+bfd_default_compatible
+ PARAMS ((const bfd_arch_info_type *a,
+ const bfd_arch_info_type *b));
+
+boolean
+bfd_default_scan PARAMS ((const struct bfd_arch_info *info, const char *string));
+
+struct elf_internal_shdr *
+bfd_elf_find_section PARAMS ((bfd *abfd, char *name));
+
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
new file mode 100644
index 00000000000..0dc2121c981
--- /dev/null
+++ b/bfd/libcoff-in.h
@@ -0,0 +1,529 @@
+/* BFD COFF object file private structure.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+** NOTE: libcoff.h is a GENERATED file. Don't change it; instead,
+** change libcoff-in.h or coffcode.h.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfdlink.h"
+
+/* Object file tdata; access macros */
+
+#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
+#define exec_hdr(bfd) (coff_data(bfd)->hdr)
+#define obj_pe(bfd) (coff_data(bfd)->pe)
+#define obj_symbols(bfd) (coff_data(bfd)->symbols)
+#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
+
+#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
+#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
+#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
+#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
+#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
+
+#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
+#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
+#define obj_coff_strings(bfd) (coff_data (bfd)->strings)
+#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
+#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
+
+#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
+
+/* `Tdata' information kept for COFF files. */
+
+typedef struct coff_tdata
+{
+ struct coff_symbol_struct *symbols; /* symtab for input bfd */
+ unsigned int *conversion_table;
+ int conv_table_size;
+ file_ptr sym_filepos;
+
+ struct coff_ptr_struct *raw_syments;
+ unsigned int raw_syment_count;
+
+ /* These are only valid once writing has begun */
+ long int relocbase;
+
+ /* These members communicate important constants about the symbol table
+ to GDB's symbol-reading code. These `constants' unfortunately vary
+ from coff implementation to implementation... */
+ unsigned local_n_btmask;
+ unsigned local_n_btshft;
+ unsigned local_n_tmask;
+ unsigned local_n_tshift;
+ unsigned local_symesz;
+ unsigned local_auxesz;
+ unsigned local_linesz;
+
+ /* The unswapped external symbols. May be NULL. Read by
+ _bfd_coff_get_external_symbols. */
+ PTR external_syms;
+ /* If this is true, the external_syms may not be freed. */
+ boolean keep_syms;
+
+ /* The string table. May be NULL. Read by
+ _bfd_coff_read_string_table. */
+ char *strings;
+ /* If this is true, the strings may not be freed. */
+ boolean keep_strings;
+
+ /* is this a PE format coff file */
+ int pe;
+ /* Used by the COFF backend linker. */
+ struct coff_link_hash_entry **sym_hashes;
+
+ /* used by the pe linker for PowerPC */
+ int *local_toc_sym_map;
+
+ struct bfd_link_info *link_info;
+
+ /* Used by coff_find_nearest_line. */
+ PTR line_info;
+
+ /* Copy of some of the f_flags bits in the COFF filehdr structure,
+ used by ARM code. */
+ flagword flags;
+
+} coff_data_type;
+
+/* Tdata for pe image files. */
+typedef struct pe_tdata
+{
+ coff_data_type coff;
+ struct internal_extra_pe_aouthdr pe_opthdr;
+ int dll;
+ int has_reloc_section;
+ boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
+ flagword real_flags;
+} pe_data_type;
+
+#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
+
+/* Tdata for XCOFF files. */
+
+struct xcoff_tdata
+{
+ /* Basic COFF information. */
+ coff_data_type coff;
+
+ /* True if a large a.out header should be generated. */
+ boolean full_aouthdr;
+
+ /* TOC value. */
+ bfd_vma toc;
+
+ /* Index of section holding TOC. */
+ int sntoc;
+
+ /* Index of section holding entry point. */
+ int snentry;
+
+ /* .text alignment from optional header. */
+ int text_align_power;
+
+ /* .data alignment from optional header. */
+ int data_align_power;
+
+ /* modtype from optional header. */
+ short modtype;
+
+ /* cputype from optional header. */
+ short cputype;
+
+ /* maxdata from optional header. */
+ bfd_size_type maxdata;
+
+ /* maxstack from optional header. */
+ bfd_size_type maxstack;
+
+ /* Used by the XCOFF backend linker. */
+ asection **csects;
+ unsigned long *debug_indices;
+ unsigned int import_file_id;
+};
+
+#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
+
+/* We take the address of the first element of a asymbol to ensure that the
+ * macro is only ever applied to an asymbol. */
+#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
+
+/* The used_by_bfd field of a section may be set to a pointer to this
+ structure. */
+
+struct coff_section_tdata
+{
+ /* The relocs, swapped into COFF internal form. This may be NULL. */
+ struct internal_reloc *relocs;
+ /* If this is true, the relocs entry may not be freed. */
+ boolean keep_relocs;
+ /* The section contents. This may be NULL. */
+ bfd_byte *contents;
+ /* If this is true, the contents entry may not be freed. */
+ boolean keep_contents;
+ /* Information cached by coff_find_nearest_line. */
+ bfd_vma offset;
+ unsigned int i;
+ const char *function;
+ int line_base;
+ /* A pointer used for .stab linking optimizations. */
+ PTR stab_info;
+ /* Available for individual backends. */
+ PTR tdata;
+};
+
+/* An accessor macro for the coff_section_tdata structure. */
+#define coff_section_data(abfd, sec) \
+ ((struct coff_section_tdata *) (sec)->used_by_bfd)
+
+/* Tdata for sections in XCOFF files. This is used by the linker. */
+
+struct xcoff_section_tdata
+{
+ /* Used for XCOFF csects created by the linker; points to the real
+ XCOFF section which contains this csect. */
+ asection *enclosing;
+ /* The lineno_count field for the enclosing section, because we are
+ going to clobber it there. */
+ unsigned int lineno_count;
+ /* The first and one past the last symbol indices for symbols used
+ by this csect. */
+ unsigned long first_symndx;
+ unsigned long last_symndx;
+};
+
+/* An accessor macro the xcoff_section_tdata structure. */
+#define xcoff_section_data(abfd, sec) \
+ ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
+
+/* Tdata for sections in PEI image files. */
+
+struct pei_section_tdata
+{
+ /* The virtual size of the section. */
+ bfd_size_type virt_size;
+};
+
+/* An accessor macro for the pei_section_tdata structure. */
+#define pei_section_data(abfd, sec) \
+ ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
+
+/* COFF linker hash table entries. */
+
+struct coff_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+
+ /* Symbol index in output file. Set to -1 initially. Set to -2 if
+ there is a reloc against this symbol. */
+ long indx;
+
+ /* Symbol type. */
+ unsigned short type;
+
+ /* Symbol class. */
+ unsigned char class;
+
+ /* Number of auxiliary entries. */
+ char numaux;
+
+ /* BFD to take auxiliary entries from. */
+ bfd *auxbfd;
+
+ /* Pointer to array of auxiliary entries, if any. */
+ union internal_auxent *aux;
+};
+
+/* COFF linker hash table. */
+
+struct coff_link_hash_table
+{
+ struct bfd_link_hash_table root;
+ /* A pointer to information used to link stabs in sections. */
+ PTR stab_info;
+};
+
+/* Look up an entry in a COFF linker hash table. */
+
+#define coff_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct coff_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+/* Traverse a COFF linker hash table. */
+
+#define coff_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the COFF linker hash table from a link_info structure. */
+
+#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
+
+/* Functions in coffgen.c. */
+extern const bfd_target *coff_object_p PARAMS ((bfd *));
+extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
+extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
+extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
+extern int coff_count_linenumbers PARAMS ((bfd *));
+extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
+extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
+extern void coff_mangle_symbols PARAMS ((bfd *));
+extern boolean coff_write_symbols PARAMS ((bfd *));
+extern boolean coff_write_linenumbers PARAMS ((bfd *));
+extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
+extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
+extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
+extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
+extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
+extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
+extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
+extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
+extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
+ bfd_print_symbol_type how));
+extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
+ symbol_info *ret));
+extern boolean _bfd_coff_is_local_label_name PARAMS ((bfd *, const char *));
+extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
+ unsigned long));
+extern boolean coff_find_nearest_line PARAMS ((bfd *,
+ asection *,
+ asymbol **,
+ bfd_vma offset,
+ CONST char **filename_ptr,
+ CONST char **functionname_ptr,
+ unsigned int *line_ptr));
+extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
+extern boolean bfd_coff_reloc16_relax_section
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
+extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean relocateable, asymbol **));
+extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
+ struct bfd_link_info *,
+ asection *));
+extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
+ asection *input_section,
+ bfd_vma val));
+
+/* Functions and types in cofflink.c. */
+
+#define STRING_SIZE_SIZE (4)
+
+/* We use a hash table to merge identical enum, struct, and union
+ definitions in the linker. */
+
+/* Information we keep for a single element (an enum value, a
+ structure or union field) in the debug merge hash table. */
+
+struct coff_debug_merge_element
+{
+ /* Next element. */
+ struct coff_debug_merge_element *next;
+
+ /* Name. */
+ const char *name;
+
+ /* Type. */
+ unsigned int type;
+
+ /* Symbol index for complex type. */
+ long tagndx;
+};
+
+/* A linked list of debug merge entries for a given name. */
+
+struct coff_debug_merge_type
+{
+ /* Next type with the same name. */
+ struct coff_debug_merge_type *next;
+
+ /* Class of type. */
+ int class;
+
+ /* Symbol index where this type is defined. */
+ long indx;
+
+ /* List of elements. */
+ struct coff_debug_merge_element *elements;
+};
+
+/* Information we store in the debug merge hash table. */
+
+struct coff_debug_merge_hash_entry
+{
+ struct bfd_hash_entry root;
+
+ /* A list of types with this name. */
+ struct coff_debug_merge_type *types;
+};
+
+/* The debug merge hash table. */
+
+struct coff_debug_merge_hash_table
+{
+ struct bfd_hash_table root;
+};
+
+/* Initialize a COFF debug merge hash table. */
+
+#define coff_debug_merge_hash_table_init(table) \
+ (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
+
+/* Free a COFF debug merge hash table. */
+
+#define coff_debug_merge_hash_table_free(table) \
+ (bfd_hash_table_free (&(table)->root))
+
+/* Look up an entry in a COFF debug merge hash table. */
+
+#define coff_debug_merge_hash_lookup(table, string, create, copy) \
+ ((struct coff_debug_merge_hash_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+/* Information we keep for each section in the output file when doing
+ a relocateable link. */
+
+struct coff_link_section_info
+{
+ /* The relocs to be output. */
+ struct internal_reloc *relocs;
+ /* For each reloc against a global symbol whose index was not known
+ when the reloc was handled, the global hash table entry. */
+ struct coff_link_hash_entry **rel_hashes;
+};
+
+/* Information that we pass around while doing the final link step. */
+
+struct coff_final_link_info
+{
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* Used to indicate failure in traversal routine. */
+ boolean failed;
+ /* If doing "task linking" set only during the time when we want the
+ global symbol writer to convert the storage class of defined global
+ symbols from global to static. */
+ boolean global_to_static;
+ /* Hash table for long symbol names. */
+ struct bfd_strtab_hash *strtab;
+ /* When doing a relocateable link, an array of information kept for
+ each output section, indexed by the target_index field. */
+ struct coff_link_section_info *section_info;
+ /* Symbol index of last C_FILE symbol (-1 if none). */
+ long last_file_index;
+ /* Contents of last C_FILE symbol. */
+ struct internal_syment last_file;
+ /* Symbol index of first aux entry of last .bf symbol with an empty
+ endndx field (-1 if none). */
+ long last_bf_index;
+ /* Contents of last_bf_index aux entry. */
+ union internal_auxent last_bf;
+ /* Hash table used to merge debug information. */
+ struct coff_debug_merge_hash_table debug_merge;
+ /* Buffer large enough to hold swapped symbols of any input file. */
+ struct internal_syment *internal_syms;
+ /* Buffer large enough to hold sections of symbols of any input file. */
+ asection **sec_ptrs;
+ /* Buffer large enough to hold output indices of symbols of any
+ input file. */
+ long *sym_indices;
+ /* Buffer large enough to hold output symbols for any input file. */
+ bfd_byte *outsyms;
+ /* Buffer large enough to hold external line numbers for any input
+ section. */
+ bfd_byte *linenos;
+ /* Buffer large enough to hold any input section. */
+ bfd_byte *contents;
+ /* Buffer large enough to hold external relocs of any input section. */
+ bfd_byte *external_relocs;
+ /* Buffer large enough to hold swapped relocs of any input section. */
+ struct internal_reloc *internal_relocs;
+};
+
+extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+extern boolean _bfd_coff_link_hash_table_init
+ PARAMS ((struct coff_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
+ PARAMS ((bfd *));
+extern const char *_bfd_coff_internal_syment_name
+ PARAMS ((bfd *, const struct internal_syment *, char *));
+extern boolean _bfd_coff_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_coff_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern struct internal_reloc *_bfd_coff_read_internal_relocs
+ PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
+ struct internal_reloc *));
+extern boolean _bfd_coff_generic_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+extern boolean _bfd_coff_write_global_sym
+ PARAMS ((struct coff_link_hash_entry *, PTR));
+extern boolean _bfd_coff_write_task_globals
+ PARAMS ((struct coff_link_hash_entry *, PTR));
+extern boolean _bfd_coff_link_input_bfd
+ PARAMS ((struct coff_final_link_info *, bfd *));
+extern boolean _bfd_coff_reloc_link_order
+ PARAMS ((bfd *, struct coff_final_link_info *, asection *,
+ struct bfd_link_order *));
+
+
+#define coff_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+/* Functions in xcofflink.c. */
+
+extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_canonicalize_dynamic_symtab
+ PARAMS ((bfd *, asymbol **));
+extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_canonicalize_dynamic_reloc
+ PARAMS ((bfd *, arelent **, asymbol **));
+extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
+ PARAMS ((bfd *));
+extern boolean _bfd_xcoff_bfd_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_xcoff_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_ppc_xcoff_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the
+ linker, and so should start with bfd and be declared in bfd.h. */
+
+extern boolean ppc_allocate_toc_section PARAMS ((struct bfd_link_info *));
+extern boolean ppc_process_before_allocation
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* And more taken from the source .. */
+
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
new file mode 100644
index 00000000000..c418a4d4667
--- /dev/null
+++ b/bfd/libcoff.h
@@ -0,0 +1,888 @@
+/* BFD COFF object file private structure.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+** NOTE: libcoff.h is a GENERATED file. Don't change it; instead,
+** change libcoff-in.h or coffcode.h.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfdlink.h"
+
+/* Object file tdata; access macros */
+
+#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
+#define exec_hdr(bfd) (coff_data(bfd)->hdr)
+#define obj_pe(bfd) (coff_data(bfd)->pe)
+#define obj_symbols(bfd) (coff_data(bfd)->symbols)
+#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
+
+#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
+#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
+#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
+#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
+#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
+
+#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
+#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
+#define obj_coff_strings(bfd) (coff_data (bfd)->strings)
+#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
+#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
+
+#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
+
+/* `Tdata' information kept for COFF files. */
+
+typedef struct coff_tdata
+{
+ struct coff_symbol_struct *symbols; /* symtab for input bfd */
+ unsigned int *conversion_table;
+ int conv_table_size;
+ file_ptr sym_filepos;
+
+ struct coff_ptr_struct *raw_syments;
+ unsigned int raw_syment_count;
+
+ /* These are only valid once writing has begun */
+ long int relocbase;
+
+ /* These members communicate important constants about the symbol table
+ to GDB's symbol-reading code. These `constants' unfortunately vary
+ from coff implementation to implementation... */
+ unsigned local_n_btmask;
+ unsigned local_n_btshft;
+ unsigned local_n_tmask;
+ unsigned local_n_tshift;
+ unsigned local_symesz;
+ unsigned local_auxesz;
+ unsigned local_linesz;
+
+ /* The unswapped external symbols. May be NULL. Read by
+ _bfd_coff_get_external_symbols. */
+ PTR external_syms;
+ /* If this is true, the external_syms may not be freed. */
+ boolean keep_syms;
+
+ /* The string table. May be NULL. Read by
+ _bfd_coff_read_string_table. */
+ char *strings;
+ /* If this is true, the strings may not be freed. */
+ boolean keep_strings;
+
+ /* is this a PE format coff file */
+ int pe;
+ /* Used by the COFF backend linker. */
+ struct coff_link_hash_entry **sym_hashes;
+
+ /* used by the pe linker for PowerPC */
+ int *local_toc_sym_map;
+
+ struct bfd_link_info *link_info;
+
+ /* Used by coff_find_nearest_line. */
+ PTR line_info;
+
+ /* Copy of some of the f_flags bits in the COFF filehdr structure,
+ used by ARM code. */
+ flagword flags;
+
+} coff_data_type;
+
+/* Tdata for pe image files. */
+typedef struct pe_tdata
+{
+ coff_data_type coff;
+ struct internal_extra_pe_aouthdr pe_opthdr;
+ int dll;
+ int has_reloc_section;
+ boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
+ flagword real_flags;
+} pe_data_type;
+
+#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
+
+/* Tdata for XCOFF files. */
+
+struct xcoff_tdata
+{
+ /* Basic COFF information. */
+ coff_data_type coff;
+
+ /* True if a large a.out header should be generated. */
+ boolean full_aouthdr;
+
+ /* TOC value. */
+ bfd_vma toc;
+
+ /* Index of section holding TOC. */
+ int sntoc;
+
+ /* Index of section holding entry point. */
+ int snentry;
+
+ /* .text alignment from optional header. */
+ int text_align_power;
+
+ /* .data alignment from optional header. */
+ int data_align_power;
+
+ /* modtype from optional header. */
+ short modtype;
+
+ /* cputype from optional header. */
+ short cputype;
+
+ /* maxdata from optional header. */
+ bfd_size_type maxdata;
+
+ /* maxstack from optional header. */
+ bfd_size_type maxstack;
+
+ /* Used by the XCOFF backend linker. */
+ asection **csects;
+ unsigned long *debug_indices;
+ unsigned int import_file_id;
+};
+
+#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
+
+/* We take the address of the first element of a asymbol to ensure that the
+ * macro is only ever applied to an asymbol. */
+#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
+
+/* The used_by_bfd field of a section may be set to a pointer to this
+ structure. */
+
+struct coff_section_tdata
+{
+ /* The relocs, swapped into COFF internal form. This may be NULL. */
+ struct internal_reloc *relocs;
+ /* If this is true, the relocs entry may not be freed. */
+ boolean keep_relocs;
+ /* The section contents. This may be NULL. */
+ bfd_byte *contents;
+ /* If this is true, the contents entry may not be freed. */
+ boolean keep_contents;
+ /* Information cached by coff_find_nearest_line. */
+ bfd_vma offset;
+ unsigned int i;
+ const char *function;
+ int line_base;
+ /* A pointer used for .stab linking optimizations. */
+ PTR stab_info;
+ /* Available for individual backends. */
+ PTR tdata;
+};
+
+/* An accessor macro for the coff_section_tdata structure. */
+#define coff_section_data(abfd, sec) \
+ ((struct coff_section_tdata *) (sec)->used_by_bfd)
+
+/* Tdata for sections in XCOFF files. This is used by the linker. */
+
+struct xcoff_section_tdata
+{
+ /* Used for XCOFF csects created by the linker; points to the real
+ XCOFF section which contains this csect. */
+ asection *enclosing;
+ /* The lineno_count field for the enclosing section, because we are
+ going to clobber it there. */
+ unsigned int lineno_count;
+ /* The first and one past the last symbol indices for symbols used
+ by this csect. */
+ unsigned long first_symndx;
+ unsigned long last_symndx;
+};
+
+/* An accessor macro the xcoff_section_tdata structure. */
+#define xcoff_section_data(abfd, sec) \
+ ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
+
+/* Tdata for sections in PEI image files. */
+
+struct pei_section_tdata
+{
+ /* The virtual size of the section. */
+ bfd_size_type virt_size;
+};
+
+/* An accessor macro for the pei_section_tdata structure. */
+#define pei_section_data(abfd, sec) \
+ ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
+
+/* COFF linker hash table entries. */
+
+struct coff_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+
+ /* Symbol index in output file. Set to -1 initially. Set to -2 if
+ there is a reloc against this symbol. */
+ long indx;
+
+ /* Symbol type. */
+ unsigned short type;
+
+ /* Symbol class. */
+ unsigned char class;
+
+ /* Number of auxiliary entries. */
+ char numaux;
+
+ /* BFD to take auxiliary entries from. */
+ bfd *auxbfd;
+
+ /* Pointer to array of auxiliary entries, if any. */
+ union internal_auxent *aux;
+};
+
+/* COFF linker hash table. */
+
+struct coff_link_hash_table
+{
+ struct bfd_link_hash_table root;
+ /* A pointer to information used to link stabs in sections. */
+ PTR stab_info;
+};
+
+/* Look up an entry in a COFF linker hash table. */
+
+#define coff_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct coff_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+/* Traverse a COFF linker hash table. */
+
+#define coff_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the COFF linker hash table from a link_info structure. */
+
+#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
+
+/* Functions in coffgen.c. */
+extern const bfd_target *coff_object_p PARAMS ((bfd *));
+extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
+extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
+extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
+extern int coff_count_linenumbers PARAMS ((bfd *));
+extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
+extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
+extern void coff_mangle_symbols PARAMS ((bfd *));
+extern boolean coff_write_symbols PARAMS ((bfd *));
+extern boolean coff_write_linenumbers PARAMS ((bfd *));
+extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
+extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
+extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
+extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
+extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
+extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
+extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
+extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
+extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
+ bfd_print_symbol_type how));
+extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
+ symbol_info *ret));
+extern boolean _bfd_coff_is_local_label_name PARAMS ((bfd *, const char *));
+extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
+ unsigned long));
+extern boolean coff_find_nearest_line PARAMS ((bfd *,
+ asection *,
+ asymbol **,
+ bfd_vma offset,
+ CONST char **filename_ptr,
+ CONST char **functionname_ptr,
+ unsigned int *line_ptr));
+extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
+extern boolean bfd_coff_reloc16_relax_section
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
+extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean relocateable, asymbol **));
+extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
+ struct bfd_link_info *,
+ asection *));
+extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
+ asection *input_section,
+ bfd_vma val));
+
+/* Functions and types in cofflink.c. */
+
+#define STRING_SIZE_SIZE (4)
+
+/* We use a hash table to merge identical enum, struct, and union
+ definitions in the linker. */
+
+/* Information we keep for a single element (an enum value, a
+ structure or union field) in the debug merge hash table. */
+
+struct coff_debug_merge_element
+{
+ /* Next element. */
+ struct coff_debug_merge_element *next;
+
+ /* Name. */
+ const char *name;
+
+ /* Type. */
+ unsigned int type;
+
+ /* Symbol index for complex type. */
+ long tagndx;
+};
+
+/* A linked list of debug merge entries for a given name. */
+
+struct coff_debug_merge_type
+{
+ /* Next type with the same name. */
+ struct coff_debug_merge_type *next;
+
+ /* Class of type. */
+ int class;
+
+ /* Symbol index where this type is defined. */
+ long indx;
+
+ /* List of elements. */
+ struct coff_debug_merge_element *elements;
+};
+
+/* Information we store in the debug merge hash table. */
+
+struct coff_debug_merge_hash_entry
+{
+ struct bfd_hash_entry root;
+
+ /* A list of types with this name. */
+ struct coff_debug_merge_type *types;
+};
+
+/* The debug merge hash table. */
+
+struct coff_debug_merge_hash_table
+{
+ struct bfd_hash_table root;
+};
+
+/* Initialize a COFF debug merge hash table. */
+
+#define coff_debug_merge_hash_table_init(table) \
+ (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
+
+/* Free a COFF debug merge hash table. */
+
+#define coff_debug_merge_hash_table_free(table) \
+ (bfd_hash_table_free (&(table)->root))
+
+/* Look up an entry in a COFF debug merge hash table. */
+
+#define coff_debug_merge_hash_lookup(table, string, create, copy) \
+ ((struct coff_debug_merge_hash_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+/* Information we keep for each section in the output file when doing
+ a relocateable link. */
+
+struct coff_link_section_info
+{
+ /* The relocs to be output. */
+ struct internal_reloc *relocs;
+ /* For each reloc against a global symbol whose index was not known
+ when the reloc was handled, the global hash table entry. */
+ struct coff_link_hash_entry **rel_hashes;
+};
+
+/* Information that we pass around while doing the final link step. */
+
+struct coff_final_link_info
+{
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* Used to indicate failure in traversal routine. */
+ boolean failed;
+ /* If doing "task linking" set only during the time when we want the
+ global symbol writer to convert the storage class of defined global
+ symbols from global to static. */
+ boolean global_to_static;
+ /* Hash table for long symbol names. */
+ struct bfd_strtab_hash *strtab;
+ /* When doing a relocateable link, an array of information kept for
+ each output section, indexed by the target_index field. */
+ struct coff_link_section_info *section_info;
+ /* Symbol index of last C_FILE symbol (-1 if none). */
+ long last_file_index;
+ /* Contents of last C_FILE symbol. */
+ struct internal_syment last_file;
+ /* Symbol index of first aux entry of last .bf symbol with an empty
+ endndx field (-1 if none). */
+ long last_bf_index;
+ /* Contents of last_bf_index aux entry. */
+ union internal_auxent last_bf;
+ /* Hash table used to merge debug information. */
+ struct coff_debug_merge_hash_table debug_merge;
+ /* Buffer large enough to hold swapped symbols of any input file. */
+ struct internal_syment *internal_syms;
+ /* Buffer large enough to hold sections of symbols of any input file. */
+ asection **sec_ptrs;
+ /* Buffer large enough to hold output indices of symbols of any
+ input file. */
+ long *sym_indices;
+ /* Buffer large enough to hold output symbols for any input file. */
+ bfd_byte *outsyms;
+ /* Buffer large enough to hold external line numbers for any input
+ section. */
+ bfd_byte *linenos;
+ /* Buffer large enough to hold any input section. */
+ bfd_byte *contents;
+ /* Buffer large enough to hold external relocs of any input section. */
+ bfd_byte *external_relocs;
+ /* Buffer large enough to hold swapped relocs of any input section. */
+ struct internal_reloc *internal_relocs;
+};
+
+extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+extern boolean _bfd_coff_link_hash_table_init
+ PARAMS ((struct coff_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
+ PARAMS ((bfd *));
+extern const char *_bfd_coff_internal_syment_name
+ PARAMS ((bfd *, const struct internal_syment *, char *));
+extern boolean _bfd_coff_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_coff_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern struct internal_reloc *_bfd_coff_read_internal_relocs
+ PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
+ struct internal_reloc *));
+extern boolean _bfd_coff_generic_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+extern boolean _bfd_coff_write_global_sym
+ PARAMS ((struct coff_link_hash_entry *, PTR));
+extern boolean _bfd_coff_write_task_globals
+ PARAMS ((struct coff_link_hash_entry *, PTR));
+extern boolean _bfd_coff_link_input_bfd
+ PARAMS ((struct coff_final_link_info *, bfd *));
+extern boolean _bfd_coff_reloc_link_order
+ PARAMS ((bfd *, struct coff_final_link_info *, asection *,
+ struct bfd_link_order *));
+
+
+#define coff_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+/* Functions in xcofflink.c. */
+
+extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_canonicalize_dynamic_symtab
+ PARAMS ((bfd *, asymbol **));
+extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_canonicalize_dynamic_reloc
+ PARAMS ((bfd *, arelent **, asymbol **));
+extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
+ PARAMS ((bfd *));
+extern boolean _bfd_xcoff_bfd_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_xcoff_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_ppc_xcoff_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the
+ linker, and so should start with bfd and be declared in bfd.h. */
+
+extern boolean ppc_allocate_toc_section PARAMS ((struct bfd_link_info *));
+extern boolean ppc_process_before_allocation
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* And more taken from the source .. */
+
+typedef struct coff_ptr_struct
+{
+
+ /* Remembers the offset from the first symbol in the file for
+ this symbol. Generated by coff_renumber_symbols. */
+unsigned int offset;
+
+ /* Should the value of this symbol be renumbered. Used for
+ XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
+unsigned int fix_value : 1;
+
+ /* Should the tag field of this symbol be renumbered.
+ Created by coff_pointerize_aux. */
+unsigned int fix_tag : 1;
+
+ /* Should the endidx field of this symbol be renumbered.
+ Created by coff_pointerize_aux. */
+unsigned int fix_end : 1;
+
+ /* Should the x_csect.x_scnlen field be renumbered.
+ Created by coff_pointerize_aux. */
+unsigned int fix_scnlen : 1;
+
+ /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
+ index into the line number entries. Set by
+ coff_slurp_symbol_table. */
+unsigned int fix_line : 1;
+
+ /* The container for the symbol structure as read and translated
+ from the file. */
+
+union {
+ union internal_auxent auxent;
+ struct internal_syment syment;
+ } u;
+} combined_entry_type;
+
+
+ /* Each canonical asymbol really looks like this: */
+
+typedef struct coff_symbol_struct
+{
+ /* The actual symbol which the rest of BFD works with */
+asymbol symbol;
+
+ /* A pointer to the hidden information for this symbol */
+combined_entry_type *native;
+
+ /* A pointer to the linenumber information for this symbol */
+struct lineno_cache_entry *lineno;
+
+ /* Have the line numbers been relocated yet ? */
+boolean done_lineno;
+} coff_symbol_type;
+typedef struct
+{
+ void (*_bfd_coff_swap_aux_in) PARAMS ((
+ bfd *abfd,
+ PTR ext,
+ int type,
+ int class,
+ int indaux,
+ int numaux,
+ PTR in));
+
+ void (*_bfd_coff_swap_sym_in) PARAMS ((
+ bfd *abfd ,
+ PTR ext,
+ PTR in));
+
+ void (*_bfd_coff_swap_lineno_in) PARAMS ((
+ bfd *abfd,
+ PTR ext,
+ PTR in));
+
+ unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
+ bfd *abfd,
+ PTR in,
+ int type,
+ int class,
+ int indaux,
+ int numaux,
+ PTR ext));
+
+ unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
+ bfd *abfd,
+ PTR in,
+ PTR ext));
+
+ unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
+ bfd *abfd,
+ PTR in,
+ PTR ext));
+
+ unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
+ bfd *abfd,
+ PTR src,
+ PTR dst));
+
+ unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
+ bfd *abfd,
+ PTR in,
+ PTR out));
+
+ unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
+ bfd *abfd,
+ PTR in,
+ PTR out));
+
+ unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
+ bfd *abfd,
+ PTR in,
+ PTR out));
+
+ unsigned int _bfd_filhsz;
+ unsigned int _bfd_aoutsz;
+ unsigned int _bfd_scnhsz;
+ unsigned int _bfd_symesz;
+ unsigned int _bfd_auxesz;
+ unsigned int _bfd_relsz;
+ unsigned int _bfd_linesz;
+ boolean _bfd_coff_long_filenames;
+ boolean _bfd_coff_long_section_names;
+ unsigned int _bfd_coff_default_section_alignment_power;
+ void (*_bfd_coff_swap_filehdr_in) PARAMS ((
+ bfd *abfd,
+ PTR ext,
+ PTR in));
+ void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
+ bfd *abfd,
+ PTR ext,
+ PTR in));
+ void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
+ bfd *abfd,
+ PTR ext,
+ PTR in));
+ void (*_bfd_coff_swap_reloc_in) PARAMS ((
+ bfd *abfd,
+ PTR ext,
+ PTR in));
+ boolean (*_bfd_coff_bad_format_hook) PARAMS ((
+ bfd *abfd,
+ PTR internal_filehdr));
+ boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
+ bfd *abfd,
+ PTR internal_filehdr));
+ PTR (*_bfd_coff_mkobject_hook) PARAMS ((
+ bfd *abfd,
+ PTR internal_filehdr,
+ PTR internal_aouthdr));
+ flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
+ bfd *abfd,
+ PTR internal_scnhdr,
+ const char *name));
+ void (*_bfd_set_alignment_hook) PARAMS ((
+ bfd *abfd,
+ asection *sec,
+ PTR internal_scnhdr));
+ boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
+ bfd *abfd));
+ boolean (*_bfd_coff_symname_in_debug) PARAMS ((
+ bfd *abfd,
+ struct internal_syment *sym));
+ boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
+ bfd *abfd,
+ combined_entry_type *table_base,
+ combined_entry_type *symbol,
+ unsigned int indaux,
+ combined_entry_type *aux));
+ boolean (*_bfd_coff_print_aux) PARAMS ((
+ bfd *abfd,
+ FILE *file,
+ combined_entry_type *table_base,
+ combined_entry_type *symbol,
+ combined_entry_type *aux,
+ unsigned int indaux));
+ void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
+ bfd *abfd,
+ struct bfd_link_info *link_info,
+ struct bfd_link_order *link_order,
+ arelent *reloc,
+ bfd_byte *data,
+ unsigned int *src_ptr,
+ unsigned int *dst_ptr));
+ int (*_bfd_coff_reloc16_estimate) PARAMS ((
+ bfd *abfd,
+ asection *input_section,
+ arelent *r,
+ unsigned int shrink,
+ struct bfd_link_info *link_info));
+ boolean (*_bfd_coff_sym_is_global) PARAMS ((
+ bfd *abfd,
+ struct internal_syment *));
+ boolean (*_bfd_coff_compute_section_file_positions) PARAMS ((
+ bfd *abfd));
+ boolean (*_bfd_coff_start_final_link) PARAMS ((
+ bfd *output_bfd,
+ struct bfd_link_info *info));
+ boolean (*_bfd_coff_relocate_section) PARAMS ((
+ bfd *output_bfd,
+ struct bfd_link_info *info,
+ bfd *input_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ struct internal_reloc *relocs,
+ struct internal_syment *syms,
+ asection **sections));
+ reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
+ bfd *abfd,
+ asection *sec,
+ struct internal_reloc *rel,
+ struct coff_link_hash_entry *h,
+ struct internal_syment *sym,
+ bfd_vma *addendp));
+ boolean (*_bfd_coff_adjust_symndx) PARAMS ((
+ bfd *obfd,
+ struct bfd_link_info *info,
+ bfd *ibfd,
+ asection *sec,
+ struct internal_reloc *reloc,
+ boolean *adjustedp));
+ boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
+ struct bfd_link_info *info,
+ bfd *abfd,
+ const char *name,
+ flagword flags,
+ asection *section,
+ bfd_vma value,
+ const char *string,
+ boolean copy,
+ boolean collect,
+ struct bfd_link_hash_entry **hashp));
+
+ boolean (*_bfd_coff_link_output_has_begun) PARAMS ((
+ bfd * abfd,
+ struct coff_final_link_info * pfinfo));
+ boolean (*_bfd_coff_final_link_postscript) PARAMS ((
+ bfd * abfd,
+ struct coff_final_link_info * pfinfo));
+
+} bfd_coff_backend_data;
+
+#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
+
+#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
+ ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
+
+#define bfd_coff_swap_sym_in(a,e,i) \
+ ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
+
+#define bfd_coff_swap_lineno_in(a,e,i) \
+ ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
+
+#define bfd_coff_swap_reloc_out(abfd, i, o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
+
+#define bfd_coff_swap_lineno_out(abfd, i, o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
+
+#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
+ ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
+
+#define bfd_coff_swap_sym_out(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
+
+#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
+
+#define bfd_coff_swap_filehdr_out(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
+
+#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
+
+#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
+#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
+#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
+#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
+#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
+#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
+#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
+#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
+#define bfd_coff_long_section_names(abfd) \
+ (coff_backend_info (abfd)->_bfd_coff_long_section_names)
+#define bfd_coff_default_section_alignment_power(abfd) \
+ (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
+#define bfd_coff_swap_filehdr_in(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
+
+#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
+
+#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
+
+#define bfd_coff_swap_reloc_in(abfd, i, o) \
+ ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
+
+#define bfd_coff_bad_format_hook(abfd, filehdr) \
+ ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
+
+#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
+ ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
+#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
+ ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
+
+#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
+ ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
+
+#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
+ ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
+
+#define bfd_coff_slurp_symbol_table(abfd)\
+ ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
+
+#define bfd_coff_symname_in_debug(abfd, sym)\
+ ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
+
+#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
+ ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
+ (abfd, file, base, symbol, aux, indaux))
+
+#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
+ ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
+ (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
+
+#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
+ ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
+ (abfd, section, reloc, shrink, link_info))
+
+#define bfd_coff_sym_is_global(abfd, sym)\
+ ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
+ (abfd, sym))
+
+#define bfd_coff_compute_section_file_positions(abfd)\
+ ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
+ (abfd))
+
+#define bfd_coff_start_final_link(obfd, info)\
+ ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
+ (obfd, info))
+#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
+ ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
+ (obfd, info, ibfd, o, con, rel, isyms, secs))
+#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
+ ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
+ (abfd, sec, rel, h, sym, addendp))
+#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
+ ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
+ (obfd, info, ibfd, sec, rel, adjustedp))
+#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
+ ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
+ (info, abfd, name, flags, section, value, string, cp, coll, hashp))
+
+#define bfd_coff_link_output_has_begun(a,p) \
+ ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
+#define bfd_coff_final_link_postscript(a,p) \
+ ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
+
diff --git a/bfd/libecoff.h b/bfd/libecoff.h
new file mode 100644
index 00000000000..ad269a52f5d
--- /dev/null
+++ b/bfd/libecoff.h
@@ -0,0 +1,357 @@
+/* BFD ECOFF object file private structure.
+ Copyright (C) 1993, 94, 95, 96, 1997 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfdlink.h"
+
+#ifndef ECOFF_H
+#include "coff/ecoff.h"
+#endif
+
+/* This is the backend information kept for ECOFF files. This
+ structure is constant for a particular backend. The first element
+ is the COFF backend data structure, so that ECOFF targets can use
+ the generic COFF code. */
+
+#define ecoff_backend(abfd) \
+ ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
+
+struct ecoff_backend_data
+{
+ /* COFF backend information. This must be the first field. */
+ bfd_coff_backend_data coff;
+ /* Supported architecture. */
+ enum bfd_architecture arch;
+ /* Initial portion of armap string. */
+ const char *armap_start;
+ /* The page boundary used to align sections in a demand-paged
+ executable file. E.g., 0x1000. */
+ bfd_vma round;
+ /* True if the .rdata section is part of the text segment, as on the
+ Alpha. False if .rdata is part of the data segment, as on the
+ MIPS. */
+ boolean rdata_in_text;
+ /* Bitsize of constructor entries. */
+ unsigned int constructor_bitsize;
+ /* Reloc to use for constructor entries. */
+ reloc_howto_type *constructor_reloc;
+ /* How to swap debugging information. */
+ struct ecoff_debug_swap debug_swap;
+ /* External reloc size. */
+ bfd_size_type external_reloc_size;
+ /* Reloc swapping functions. */
+ void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
+ void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
+ /* Backend reloc tweaking. */
+ void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
+ arelent *));
+ void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
+ struct internal_reloc *));
+ /* Relocate section contents while linking. */
+ boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
+ bfd *input_bfd, asection *input_section,
+ bfd_byte *contents,
+ PTR external_relocs));
+ /* Do final adjustments to filehdr and aouthdr. */
+ boolean (*adjust_headers) PARAMS ((bfd *, struct internal_filehdr *,
+ struct internal_aouthdr *));
+ /* Read an element from an archive at a given file position. This
+ is needed because OSF/1 3.2 uses a weird archive format. */
+ bfd *(*get_elt_at_filepos) PARAMS ((bfd *, file_ptr));
+};
+
+/* This is the target specific information kept for ECOFF files. */
+
+#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
+
+typedef struct ecoff_tdata
+{
+ /* The reloc file position, set by
+ ecoff_compute_section_file_positions. */
+ file_ptr reloc_filepos;
+
+ /* The symbol table file position, set by _bfd_ecoff_mkobject_hook. */
+ file_ptr sym_filepos;
+
+ /* The start and end of the text segment. Only valid for an
+ existing file, not for one we are creating. */
+ unsigned long text_start;
+ unsigned long text_end;
+
+ /* The cached gp value. This is used when relocating. */
+ bfd_vma gp;
+
+ /* The maximum size of objects to optimize using gp. This is
+ typically set by the -G option to the compiler, assembler or
+ linker. */
+ unsigned int gp_size;
+
+ /* The register masks. When linking, all the masks found in the
+ input files are combined into the masks of the output file.
+ These are not all used for all targets, but that's OK, because
+ the relevant ones are the only ones swapped in and out. */
+ unsigned long gprmask;
+ unsigned long fprmask;
+ unsigned long cprmask[4];
+
+ /* The ECOFF symbolic debugging information. */
+ struct ecoff_debug_info debug_info;
+
+ /* The unswapped ECOFF symbolic information. */
+ PTR raw_syments;
+
+ /* The canonical BFD symbols. */
+ struct ecoff_symbol_struct *canonical_symbols;
+
+ /* A mapping from external symbol numbers to entries in the linker
+ hash table, used when linking. */
+ struct ecoff_link_hash_entry **sym_hashes;
+
+ /* A mapping from reloc symbol indices to sections, used when
+ linking. */
+ asection **symndx_to_section;
+
+ /* True if this BFD was written by the backend linker. */
+ boolean linker;
+
+ /* True if a warning that multiple global pointer values are
+ needed in the output binary was issued already. */
+ boolean issued_multiple_gp_warning;
+
+ /* Used by find_nearest_line entry point. The structure could be
+ included directly in this one, but there's no point to wasting
+ the memory just for the infrequently called find_nearest_line. */
+ struct ecoff_find_line *find_line_info;
+
+ /* Whether the .rdata section is in the text segment for this
+ particular ECOFF file. This is not valid until
+ ecoff_compute_section_file_positions is called. */
+ boolean rdata_in_text;
+
+} ecoff_data_type;
+
+/* Each canonical asymbol really looks like this. */
+
+typedef struct ecoff_symbol_struct
+{
+ /* The actual symbol which the rest of BFD works with */
+ asymbol symbol;
+
+ /* The fdr for this symbol. */
+ FDR *fdr;
+
+ /* true if this is a local symbol rather than an external one. */
+ boolean local;
+
+ /* A pointer to the unswapped hidden information for this symbol.
+ This is either a struct sym_ext or a struct ext_ext, depending on
+ the value of the local field above. */
+ PTR native;
+} ecoff_symbol_type;
+
+/* We take the address of the first element of a asymbol to ensure that the
+ macro is only ever applied to an asymbol. */
+#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
+
+/* We need to save the index of an external symbol when we write it
+ out so that can set the symbol index correctly when we write out
+ the relocs. */
+#define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
+#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
+
+/* When generating MIPS embedded PIC code, the linker relaxes the code
+ to turn PC relative branches into longer code sequences when the PC
+ relative branch is out of range. This involves reading the relocs
+ in bfd_relax_section as well as in bfd_final_link, and requires the
+ code to keep track of which relocs have been expanded. A pointer
+ to this structure is put in the used_by_bfd pointer of a section to
+ keep track of this information. The user_by_bfd pointer will be
+ NULL if the information was not needed. */
+
+struct ecoff_section_tdata
+{
+ /* The unswapped relocs for this section. These are stored in
+ memory so the input file does not have to be read twice. */
+ PTR external_relocs;
+
+ /* The contents of the section. These bytes may or may not be saved
+ in memory, but if it is this is a pointer to them. */
+ bfd_byte *contents;
+
+ /* Offset adjustments for PC relative branches. A number other than
+ 1 is an addend for a PC relative branch, or a switch table entry
+ which is the difference of two .text locations; this addend
+ arises because the branch or difference crosses one or more
+ branches which were expanded into a larger code sequence. A 1
+ means that this branch was itself expanded into a larger code
+ sequence. 1 is not a possible offset, since all offsets must be
+ multiples of the instruction size, which is 4; also, the only
+ relocs with non-zero offsets will be PC relative branches or
+ switch table entries within the same object file. If this field
+ is NULL, no branches were expanded and no offsets are required.
+ Otherwise there are as many entries as there are relocs in the
+ section, and the entry for any reloc that is not PC relative is
+ zero. */
+ long *offsets;
+
+ /* When producing an executable (i.e., final, non-relocatable link)
+ on the Alpha, we may need to use multiple global pointer values
+ to span the entire .lita section. In essence, we allow each
+ input .lita section to have its own gp value. To support this,
+ we need to keep track of the gp values that we picked for each
+ input .lita section . */
+ bfd_vma gp;
+};
+
+/* An accessor macro for the ecoff_section_tdata structure. */
+#define ecoff_section_data(abfd, sec) \
+ ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
+
+/* ECOFF linker hash table entries. */
+
+struct ecoff_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+ /* Symbol index in output file. */
+ long indx;
+ /* BFD that ext field value came from. */
+ bfd *abfd;
+ /* ECOFF external symbol information. */
+ EXTR esym;
+ /* Nonzero if this symbol has been written out. */
+ char written;
+ /* Nonzero if this symbol was referred to as small undefined. */
+ char small;
+};
+
+/* ECOFF linker hash table. */
+
+struct ecoff_link_hash_table
+{
+ struct bfd_link_hash_table root;
+};
+
+/* Make an ECOFF object. */
+extern boolean _bfd_ecoff_mkobject PARAMS ((bfd *));
+
+/* Read in the ECOFF symbolic debugging information. */
+extern boolean _bfd_ecoff_slurp_symbolic_info
+ PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
+
+/* Generic ECOFF BFD backend vectors. */
+
+extern boolean _bfd_ecoff_write_object_contents PARAMS ((bfd *abfd));
+extern const bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
+
+#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
+#define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+extern boolean _bfd_ecoff_new_section_hook
+ PARAMS ((bfd *, asection *));
+extern boolean _bfd_ecoff_get_section_contents
+ PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
+
+#define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
+
+extern boolean _bfd_ecoff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+#define _bfd_ecoff_bfd_copy_private_section_data \
+ _bfd_generic_bfd_copy_private_section_data
+
+#define _bfd_ecoff_bfd_copy_private_symbol_data \
+ _bfd_generic_bfd_copy_private_symbol_data
+
+#define _bfd_ecoff_bfd_print_private_bfd_data \
+ _bfd_generic_bfd_print_private_bfd_data
+
+#define _bfd_ecoff_bfd_merge_private_bfd_data \
+ _bfd_generic_bfd_merge_private_bfd_data
+
+#define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+extern boolean _bfd_ecoff_slurp_armap PARAMS ((bfd *abfd));
+#define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
+#define _bfd_ecoff_construct_extended_name_table \
+ _bfd_archive_bsd_construct_extended_name_table
+#define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
+extern boolean _bfd_ecoff_write_armap
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
+#define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_ecoff_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define _bfd_ecoff_update_armap_timestamp bfd_true
+
+extern long _bfd_ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
+extern long _bfd_ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation));
+extern asymbol *_bfd_ecoff_make_empty_symbol PARAMS ((bfd *abfd));
+extern void _bfd_ecoff_print_symbol
+ PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
+extern void _bfd_ecoff_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+extern boolean _bfd_ecoff_bfd_is_local_label_name
+ PARAMS ((bfd *, const char *));
+#define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
+extern boolean _bfd_ecoff_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma offset,
+ const char **filename_ptr, const char **fnname_ptr,
+ unsigned int *retline_ptr));
+#define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
+#define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
+extern long _bfd_ecoff_canonicalize_reloc
+ PARAMS ((bfd *, asection *, arelent **, asymbol **symbols));
+/* ecoff_bfd_reloc_type_lookup defined by backend. */
+
+extern boolean _bfd_ecoff_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long machine));
+extern boolean _bfd_ecoff_set_section_contents
+ PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
+
+extern int _bfd_ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
+/* ecoff_bfd_get_relocated_section_contents defined by backend. */
+/* ecoff_bfd_relax_section defined by backend. */
+extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
+ PARAMS ((bfd *));
+extern boolean _bfd_ecoff_bfd_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_ecoff_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Hook functions for the generic COFF section reading code. */
+
+extern PTR _bfd_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
+#define _bfd_ecoff_set_alignment_hook \
+ ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
+extern boolean _bfd_ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
+extern flagword _bfd_ecoff_styp_to_sec_flags
+ PARAMS ((bfd *abfd, PTR hdr, const char *name));
+extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
+
+/* ECOFF auxiliary information swapping routines. These are the same
+ for all ECOFF targets, so they are defined in ecofflink.c. */
+
+extern void _bfd_ecoff_swap_tir_in
+ PARAMS ((int, const struct tir_ext *, TIR *));
+extern void _bfd_ecoff_swap_tir_out
+ PARAMS ((int, const TIR *, struct tir_ext *));
+extern void _bfd_ecoff_swap_rndx_in
+ PARAMS ((int, const struct rndx_ext *, RNDXR *));
+extern void _bfd_ecoff_swap_rndx_out
+ PARAMS ((int, const RNDXR *, struct rndx_ext *));
diff --git a/bfd/libhppa.h b/bfd/libhppa.h
new file mode 100644
index 00000000000..35b40efe86e
--- /dev/null
+++ b/bfd/libhppa.h
@@ -0,0 +1,700 @@
+/* HP PA-RISC SOM object file format: definitions internal to BFD.
+ Copyright (C) 1990, 91, 92, 93, 94 , 95, 1996 Free Software Foundation, Inc.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _HPPA_H
+#define _HPPA_H
+
+#define BYTES_IN_WORD 4
+#define PA_PAGESIZE 0x1000
+
+#ifndef INLINE
+#ifdef __GNUC__
+#define INLINE inline
+#else
+#define INLINE
+#endif /* GNU C? */
+#endif /* INLINE */
+
+#if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
+/* Declare the functions with the unused attribute to avoid warnings. */
+static INLINE unsigned int assemble_3 (unsigned int)
+ __attribute__ ((__unused__));
+static INLINE void dis_assemble_3 (unsigned int, unsigned int *)
+ __attribute__ ((__unused__));
+static INLINE unsigned int assemble_12 (unsigned int, unsigned int)
+ __attribute__ ((__unused__));
+static INLINE void dis_assemble_12 (unsigned int, unsigned int *,
+ unsigned int *)
+ __attribute__ ((__unused__));
+static INLINE unsigned long assemble_17 (unsigned int, unsigned int,
+ unsigned int)
+ __attribute__ ((__unused__));
+static INLINE void dis_assemble_17 (unsigned int, unsigned int *,
+ unsigned int *, unsigned int *)
+ __attribute__ ((__unused__));
+static INLINE unsigned long assemble_21 (unsigned int)
+ __attribute ((__unused__));
+static INLINE void dis_assemble_21 (unsigned int, unsigned int *)
+ __attribute__ ((__unused__));
+static INLINE unsigned long sign_extend (unsigned int, unsigned int)
+ __attribute__ ((__unused__));
+static INLINE unsigned int ones (int) __attribute ((__unused__));
+static INLINE void sign_unext (unsigned int, unsigned int, unsigned int *)
+ __attribute__ ((__unused__));
+static INLINE unsigned long low_sign_extend (unsigned int, unsigned int)
+ __attribute__ ((__unused__));
+static INLINE void low_sign_unext (unsigned int, unsigned int, unsigned int *)
+ __attribute__ ((__unused__));
+static INLINE unsigned long hppa_field_adjust (unsigned long, unsigned long,
+ unsigned short)
+ __attribute__ ((__unused__));
+static INLINE char bfd_hppa_insn2fmt (unsigned long)
+ __attribute__ ((__unused__));
+static INLINE unsigned long hppa_rebuild_insn (bfd *, unsigned long,
+ unsigned long, unsigned long)
+ __attribute__ ((__unused__));
+#endif /* gcc 2.7 or higher */
+
+
+/* The PA instruction set variants. */
+enum pa_arch {pa10 = 10, pa11 = 11, pa20 = 20};
+
+/* HP PA-RISC relocation types */
+
+enum hppa_reloc_field_selector_type
+ {
+ R_HPPA_FSEL = 0x0,
+ R_HPPA_LSSEL = 0x1,
+ R_HPPA_RSSEL = 0x2,
+ R_HPPA_LSEL = 0x3,
+ R_HPPA_RSEL = 0x4,
+ R_HPPA_LDSEL = 0x5,
+ R_HPPA_RDSEL = 0x6,
+ R_HPPA_LRSEL = 0x7,
+ R_HPPA_RRSEL = 0x8,
+ R_HPPA_NSEL = 0x9,
+ R_HPPA_NLSEL = 0xa,
+ R_HPPA_NLRSEL = 0xb,
+ R_HPPA_PSEL = 0xc,
+ R_HPPA_LPSEL = 0xd,
+ R_HPPA_RPSEL = 0xe,
+ R_HPPA_TSEL = 0xf,
+ R_HPPA_LTSEL = 0x10,
+ R_HPPA_RTSEL = 0x11
+ };
+
+/* /usr/include/reloc.h defines these to constants. We want to use
+ them in enums, so #undef them before we start using them. We might
+ be able to fix this another way by simply managing not to include
+ /usr/include/reloc.h, but currently GDB picks up these defines
+ somewhere. */
+#undef e_fsel
+#undef e_lssel
+#undef e_rssel
+#undef e_lsel
+#undef e_rsel
+#undef e_ldsel
+#undef e_rdsel
+#undef e_lrsel
+#undef e_rrsel
+#undef e_nsel
+#undef e_nlsel
+#undef e_nlrsel
+#undef e_psel
+#undef e_lpsel
+#undef e_rpsel
+#undef e_tsel
+#undef e_ltsel
+#undef e_rtsel
+#undef e_one
+#undef e_two
+#undef e_pcrel
+#undef e_con
+#undef e_plabel
+#undef e_abs
+
+/* for compatibility */
+enum hppa_reloc_field_selector_type_alt
+ {
+ e_fsel = R_HPPA_FSEL,
+ e_lssel = R_HPPA_LSSEL,
+ e_rssel = R_HPPA_RSSEL,
+ e_lsel = R_HPPA_LSEL,
+ e_rsel = R_HPPA_RSEL,
+ e_ldsel = R_HPPA_LDSEL,
+ e_rdsel = R_HPPA_RDSEL,
+ e_lrsel = R_HPPA_LRSEL,
+ e_rrsel = R_HPPA_RRSEL,
+ e_nsel = R_HPPA_NSEL,
+ e_nlsel = R_HPPA_NLSEL,
+ e_nlrsel = R_HPPA_NLRSEL,
+ e_psel = R_HPPA_PSEL,
+ e_lpsel = R_HPPA_LPSEL,
+ e_rpsel = R_HPPA_RPSEL,
+ e_tsel = R_HPPA_TSEL,
+ e_ltsel = R_HPPA_LTSEL,
+ e_rtsel = R_HPPA_RTSEL
+ };
+
+enum hppa_reloc_expr_type
+ {
+ R_HPPA_E_ONE = 0,
+ R_HPPA_E_TWO = 1,
+ R_HPPA_E_PCREL = 2,
+ R_HPPA_E_CON = 3,
+ R_HPPA_E_PLABEL = 7,
+ R_HPPA_E_ABS = 18
+ };
+
+/* for compatibility */
+enum hppa_reloc_expr_type_alt
+ {
+ e_one = R_HPPA_E_ONE,
+ e_two = R_HPPA_E_TWO,
+ e_pcrel = R_HPPA_E_PCREL,
+ e_con = R_HPPA_E_CON,
+ e_plabel = R_HPPA_E_PLABEL,
+ e_abs = R_HPPA_E_ABS
+ };
+
+
+/* Relocations for function calls must be accompanied by parameter
+ relocation bits. These bits describe exactly where the caller has
+ placed the function's arguments and where it expects to find a return
+ value.
+
+ Both ELF and SOM encode this information within the addend field
+ of the call relocation. (Note this could break very badly if one
+ was to make a call like bl foo + 0x12345678).
+
+ The high order 10 bits contain parameter relocation information,
+ the low order 22 bits contain the constant offset. */
+
+#define HPPA_R_ARG_RELOC(a) (((a) >> 22) & 0x3FF)
+#define HPPA_R_CONSTANT(a) ((((int)(a)) << 10) >> 10)
+#define HPPA_R_ADDEND(r,c) (((r) << 22) + ((c) & 0x3FFFFF))
+#define HPPA_WIDE (0) /* PSW W-bit, need to check! FIXME */
+
+/* These macros get bit fields using HP's numbering (MSB = 0),
+ * but note that "MASK" assumes that the LSB bits are what's
+ * wanted.
+ */
+#ifndef GET_FIELD
+#define GET_FIELD(X, FROM, TO) \
+ ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
+#endif
+#define GET_BIT( X, WHICH ) \
+ GET_FIELD( X, WHICH, WHICH )
+
+#define MASK( SIZE ) \
+ (~((-1) << SIZE))
+
+#define CATENATE( X, XSIZE, Y, YSIZE ) \
+ (((X & MASK( XSIZE )) << YSIZE) | (Y & MASK( YSIZE )))
+
+#define ELEVEN( X ) \
+ CATENATE( GET_BIT( X, 10 ), 1, GET_FIELD( X, 0, 9 ), 10)
+
+/* Some functions to manipulate PA instructions. */
+
+/* NOTE: these use the HP convention that f{1} is the _left_ most
+ * bit (MSB) of f; they sometimes have to impose an assumption
+ * about the size of a field; and as far as I can tell, most
+ * aren't used.
+ */
+
+static INLINE unsigned long
+sign_extend (x, len)
+ unsigned int x, len;
+{
+ return (int)(x >> (len - 1) ? (-1 << len) | x : x);
+}
+
+static INLINE unsigned int
+assemble_3 (x)
+ unsigned int x;
+{
+ return (((x & 1) << 2) | ((x & 6) >> 1)) & 7;
+}
+
+static INLINE void
+dis_assemble_3 (x, r)
+ unsigned int x;
+ unsigned int *r;
+{
+ *r = (((x & 4) >> 2) | ((x & 3) << 1)) & 7;
+}
+
+static INLINE unsigned int /* PA 2.0 */
+assemble_6 (x, y)
+ unsigned int x, y;
+{
+ return (((x & 0x1) << 5) + (32 - (y & 0x1f)));
+}
+
+static INLINE unsigned int
+assemble_12 (x, y)
+ unsigned int x, y;
+{
+ return CATENATE( CATENATE( y, 1,
+ GET_BIT( x, 10 ), 1), 2,
+ GET_FIELD( x, 0, 9 ), 9);
+}
+
+static INLINE void
+dis_assemble_12 (as12, x, y)
+ unsigned int as12;
+ unsigned int *x, *y;
+{
+ *y = (as12 & 0x800) >> 11;
+ *x = ((as12 & 0x3ff) << 1) | ((as12 & 0x400) >> 10);
+}
+
+static INLINE unsigned long /* PA 2.0 */
+assemble_16 (x, y)
+ unsigned int x, y;
+{
+ /* Depends on PSW W-bit !*/
+ unsigned int temp;
+
+ if( HPPA_WIDE ) {
+ temp = CATENATE( CATENATE( GET_BIT( y, 13 ), 1,
+ (GET_BIT( y, 13 )^GET_BIT( x, 0)), 1 ), 2,
+ CATENATE( (GET_BIT( y, 13 )^GET_BIT( x, 1)), 1,
+ GET_FIELD( y, 0, 12 ), 13 ), 14 );
+ }
+ else {
+ temp = CATENATE( CATENATE( GET_BIT( y, 13 ), 1,
+ GET_BIT( y, 13 ), 1 ), 2,
+ CATENATE( GET_BIT( y, 13 ), 1,
+ GET_FIELD( y, 0, 12 ), 13 ), 14 );
+ }
+
+ return sign_extend( temp, 16 );
+}
+
+
+static INLINE unsigned long /* PA 2.0 */
+assemble_16a (x, y, z)
+ unsigned int x, y, z;
+{
+ /* Depends on PSW W-bit !*/
+ unsigned int temp;
+
+ if( HPPA_WIDE ) {
+ temp = CATENATE( CATENATE( z, 1,
+ (z^GET_BIT( x, 0 )), 1), 2,
+
+ CATENATE( (z^GET_BIT( x, 1 )), 1,
+ y, 11), 12);
+ }
+ else {
+ temp = CATENATE( CATENATE( z, 1,
+ z, 1), 2,
+ CATENATE( z, 1,
+ y, 11), 12);
+
+ }
+
+ return sign_extend( (temp << 2), 16 );
+}
+
+static INLINE unsigned long
+assemble_17 (x, y, z)
+ unsigned int x, y, z;
+{
+ unsigned long temp;
+ int q;
+
+ temp = CATENATE( CATENATE( z, q,
+ x, q), q,
+ CATENATE( GET_BIT( y, 1 ), 1,
+ GET_FIELD( y, 0, 9 ), 10), 11);
+
+ return temp;
+}
+
+static INLINE void
+dis_assemble_17 (as17, x, y, z)
+ unsigned int as17;
+ unsigned int *x, *y, *z;
+{
+
+ *z = (as17 & 0x10000) >> 16;
+ *x = (as17 & 0x0f800) >> 11;
+ *y = (((as17 & 0x00400) >> 10) | ((as17 & 0x3ff) << 1)) & 0x7ff;
+}
+
+static INLINE unsigned long
+assemble_21 (x)
+ unsigned int x;
+{
+ unsigned long temp;
+
+ temp = ((x & 1) << 20) |
+ ((x & 0xffe) << 8) |
+ ((x & 0xc000) >> 7) |
+ ((x & 0x1f0000) >> 14) |
+ ((x & 0x003000) >> 12);
+ return temp & 0x1fffff;
+}
+
+static INLINE unsigned long /* PA 2.0 */
+assemble_22 (a,b,c,d)
+ unsigned int a,b,c,d;
+{
+ unsigned long temp;
+
+ temp = CATENATE( CATENATE( d, 1,
+ a, 5 ), 6,
+ CATENATE( b, 5,
+ ELEVEN( c ), 11 ), 16 );
+
+ return sign_extend( temp, 22 );
+}
+
+static INLINE void
+dis_assemble_21 (as21, x)
+ unsigned int as21, *x;
+{
+ unsigned long temp;
+
+
+ temp = (as21 & 0x100000) >> 20;
+ temp |= (as21 & 0x0ffe00) >> 8;
+ temp |= (as21 & 0x000180) << 7;
+ temp |= (as21 & 0x00007c) << 14;
+ temp |= (as21 & 0x000003) << 12;
+ *x = temp;
+}
+
+static INLINE unsigned int
+ones (n)
+ int n;
+{
+ unsigned int len_ones;
+ int i;
+
+ i = 0;
+ len_ones = 0;
+ while (i < n)
+ {
+ len_ones = (len_ones << 1) | 1;
+ i++;
+ }
+
+ return len_ones;
+}
+
+static INLINE void
+sign_unext (x, len, result)
+ unsigned int x, len;
+ unsigned int *result;
+{
+ unsigned int len_ones;
+
+ len_ones = ones (len);
+
+ *result = x & len_ones;
+}
+
+static INLINE unsigned long
+low_sign_extend (x, len)
+ unsigned int x, len;
+{
+ return (int)((x & 0x1 ? (-1 << (len - 1)) : 0) | x >> 1);
+}
+
+static INLINE void
+low_sign_unext (x, len, result)
+ unsigned int x, len;
+ unsigned int *result;
+{
+ unsigned int temp;
+ unsigned int sign;
+ unsigned int rest;
+ unsigned int one_bit_at_len;
+ unsigned int len_ones;
+
+ len_ones = ones (len);
+ one_bit_at_len = 1 << (len - 1);
+
+ sign_unext (x, len, &temp);
+ sign = temp & one_bit_at_len;
+ sign >>= (len - 1);
+
+ rest = temp & (len_ones ^ one_bit_at_len);
+ rest <<= 1;
+
+ *result = rest | sign;
+}
+
+/* Handle field selectors for PA instructions. */
+
+static INLINE unsigned long
+hppa_field_adjust (value, constant_value, r_field)
+ unsigned long value;
+ unsigned long constant_value;
+ unsigned short r_field;
+{
+ switch (r_field)
+ {
+ case e_fsel: /* F : no change */
+ case e_nsel: /* N : no change */
+ value += constant_value;
+ break;
+
+ case e_lssel: /* LS : if (bit 21) then add 0x800
+ arithmetic shift right 11 bits */
+ value += constant_value;
+ if (value & 0x00000400)
+ value += 0x800;
+ value = (value & 0xfffff800) >> 11;
+ break;
+
+ case e_rssel: /* RS : Sign extend from bit 21 */
+ value += constant_value;
+ if (value & 0x00000400)
+ value |= 0xfffff800;
+ else
+ value &= 0x7ff;
+ break;
+
+ case e_lsel: /* L : Arithmetic shift right 11 bits */
+ case e_nlsel: /* NL : Arithmetic shift right 11 bits */
+ value += constant_value;
+ value = (value & 0xfffff800) >> 11;
+ break;
+
+ case e_rsel: /* R : Set bits 0-20 to zero */
+ value += constant_value;
+ value = value & 0x7ff;
+ break;
+
+ case e_ldsel: /* LD : Add 0x800, arithmetic shift
+ right 11 bits */
+ value += constant_value;
+ value += 0x800;
+ value = (value & 0xfffff800) >> 11;
+ break;
+
+ case e_rdsel: /* RD : Set bits 0-20 to one */
+ value += constant_value;
+ value |= 0xfffff800;
+ break;
+
+ case e_lrsel: /* LR : L with "rounded" constant */
+ case e_nlrsel: /* NLR : NL with "rounded" constant */
+ value = value + ((constant_value + 0x1000) & 0xffffe000);
+ value = (value & 0xfffff800) >> 11;
+ break;
+
+ case e_rrsel: /* RR : R with "rounded" constant */
+ value = value + ((constant_value + 0x1000) & 0xffffe000);
+ value = (value & 0x7ff) + constant_value - ((constant_value + 0x1000) & 0xffffe000);
+ break;
+
+ default:
+ abort ();
+ }
+ return value;
+
+}
+
+/* PA-RISC OPCODES */
+#define get_opcode(insn) ((insn) & 0xfc000000) >> 26
+
+/* FIXME: this list is incomplete. It should also be an enumerated
+ type rather than #defines. */
+
+#define LDO 0x0d
+#define LDB 0x10
+#define LDH 0x11
+#define LDW 0x12
+#define LDWM 0x13
+#define STB 0x18
+#define STH 0x19
+#define STW 0x1a
+#define STWM 0x1b
+#define COMICLR 0x24
+#define SUBI 0x25
+#define SUBIO 0x25
+#define ADDIT 0x2c
+#define ADDITO 0x2c
+#define ADDI 0x2d
+#define ADDIO 0x2d
+#define LDIL 0x08
+#define ADDIL 0x0a
+
+#define MOVB 0x32
+#define MOVIB 0x33
+#define COMBT 0x20
+#define COMBF 0x22
+#define COMIBT 0x21
+#define COMIBF 0x23
+#define ADDBT 0x28
+#define ADDBF 0x2a
+#define ADDIBT 0x29
+#define ADDIBF 0x2b
+#define BVB 0x30
+#define BB 0x31
+
+#define BL 0x3a
+#define BLE 0x39
+#define BE 0x38
+
+
+/* Given a machine instruction, return its format.
+
+ FIXME: opcodes which do not map to a known format
+ should return an error of some sort. */
+
+static INLINE char
+bfd_hppa_insn2fmt (insn)
+ unsigned long insn;
+{
+ char fmt = -1;
+ unsigned char op = get_opcode (insn);
+
+ switch (op)
+ {
+ case ADDI:
+ case ADDIT:
+ case SUBI:
+ fmt = 11;
+ break;
+ case MOVB:
+ case MOVIB:
+ case COMBT:
+ case COMBF:
+ case COMIBT:
+ case COMIBF:
+ case ADDBT:
+ case ADDBF:
+ case ADDIBT:
+ case ADDIBF:
+ case BVB:
+ case BB:
+ fmt = 12;
+ break;
+ case LDO:
+ case LDB:
+ case LDH:
+ case LDW:
+ case LDWM:
+ case STB:
+ case STH:
+ case STW:
+ case STWM:
+ fmt = 14;
+ break;
+ case BL:
+ case BE:
+ case BLE:
+ fmt = 17;
+ break;
+ case LDIL:
+ case ADDIL:
+ fmt = 21;
+ break;
+ default:
+ fmt = 32;
+ break;
+ }
+ return fmt;
+}
+
+
+/* Insert VALUE into INSN using R_FORMAT to determine exactly what
+ bits to change. */
+
+static INLINE unsigned long
+hppa_rebuild_insn (abfd, insn, value, r_format)
+ bfd *abfd;
+ unsigned long insn;
+ unsigned long value;
+ unsigned long r_format;
+{
+ unsigned long const_part;
+ unsigned long rebuilt_part;
+
+ switch (r_format)
+ {
+ case 11:
+ {
+ unsigned w1, w;
+
+ const_part = insn & 0xffffe002;
+ dis_assemble_12 (value, &w1, &w);
+ rebuilt_part = (w1 << 2) | w;
+ return const_part | rebuilt_part;
+ }
+
+ case 12:
+ {
+ unsigned w1, w;
+
+ const_part = insn & 0xffffe002;
+ dis_assemble_12 (value, &w1, &w);
+ rebuilt_part = (w1 << 2) | w;
+ return const_part | rebuilt_part;
+ }
+
+ case 14:
+ {
+ unsigned int ext;
+
+ const_part = insn & 0xffffc000;
+ low_sign_unext (value, 14, &ext);
+ return const_part | ext;
+ }
+
+ case 17:
+ {
+ unsigned w1, w2, w;
+
+ const_part = insn & 0xffe0e002;
+ dis_assemble_17 (value, &w1, &w2, &w);
+ rebuilt_part = (w2 << 2) | (w1 << 16) | w;
+ return const_part | rebuilt_part;
+ }
+
+ case 21:
+ {
+ unsigned int w;
+
+ const_part = insn & 0xffe00000;
+ dis_assemble_21 (value, &w);
+ return const_part | w;
+ }
+
+ case 32:
+ const_part = 0;
+ return value;
+
+ default:
+ abort ();
+ }
+ return insn;
+}
+
+#endif /* _HPPA_H */
diff --git a/bfd/libieee.h b/bfd/libieee.h
new file mode 100644
index 00000000000..30e806eaa70
--- /dev/null
+++ b/bfd/libieee.h
@@ -0,0 +1,133 @@
+/* IEEE-695 object file formats: definitions internal to BFD.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+ Written by Cygnus Support. Mostly Steve Chamberlain's fault.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+typedef struct {
+ unsigned int index:24;
+ char letter;
+} ieee_symbol_index_type;
+
+typedef struct ct {
+ bfd *this;
+ struct ct *next;
+} bfd_chain_type;
+
+typedef struct ieee_symbol
+{
+ asymbol symbol;
+ struct ieee_symbol *next;
+
+ unsigned int index;
+} ieee_symbol_type;
+
+
+typedef struct ieee_reloc {
+ arelent relent;
+ struct ieee_reloc *next;
+ ieee_symbol_index_type symbol;
+
+} ieee_reloc_type;
+
+#define ieee_symbol(x) ((ieee_symbol_type *)(x))
+
+typedef struct ieee_per_section
+{
+ asection *section;
+ bfd_byte *data;
+ bfd_vma offset;
+ bfd_vma pc;
+ /* For output */
+ file_ptr current_pos;
+ unsigned int current_byte;
+ boolean initialized;
+ ieee_reloc_type **reloc_tail_ptr;
+} ieee_per_section_type;
+
+#define ieee_per_section(x) ((ieee_per_section_type *)((x)->used_by_bfd))
+
+typedef struct {
+ unsigned char *input_p;
+ unsigned char *first_byte;
+ bfd *abfd;
+} common_header_type ;
+
+typedef struct ieee_data_struct
+{
+ common_header_type h;
+ boolean read_symbols;
+ boolean read_data;
+ file_ptr output_cursor;
+ /* Map of section indexes to section ptrs */
+ asection **section_table;
+ unsigned int section_table_size;
+ ieee_address_descriptor_type ad;
+ ieee_module_begin_type mb;
+ ieee_w_variable_type w;
+
+ unsigned int section_count;
+
+ unsigned int map_idx;
+ /* List of GLOBAL EXPORT symbols */
+ ieee_symbol_type *external_symbols;
+ /* List of UNDEFINED symbols */
+ ieee_symbol_type *external_reference;
+
+ /* When the symbols have been canonicalized, they are in a
+ * special order, we remember various bases here.. */
+ unsigned int external_symbol_max_index;
+ unsigned int external_symbol_min_index;
+ unsigned int external_symbol_count;
+ int external_symbol_base_offset;
+
+ unsigned int external_reference_max_index;
+ unsigned int external_reference_min_index;
+ unsigned int external_reference_count;
+ int external_reference_base_offset;
+
+
+ boolean symbol_table_full;
+
+
+boolean done_debug;
+
+
+bfd_chain_type *chain_head;
+bfd_chain_type *chain_root;
+
+} ieee_data_type;
+
+typedef struct {
+ file_ptr file_offset;
+ bfd *abfd;
+} ieee_ar_obstack_type;
+
+typedef struct ieee_ar_data_struct
+{
+ common_header_type h;
+ ieee_ar_obstack_type *elements;
+
+ unsigned int element_index ;
+ unsigned int element_count;
+
+} ieee_ar_data_type;
+
+#define IEEE_DATA(abfd) ((abfd)->tdata.ieee_data)
+#define IEEE_AR_DATA(abfd) ((abfd)->tdata.ieee_ar_data)
+
+#define ptr(abfd) (ieee_data(abfd)->input_p)
diff --git a/bfd/libnlm.h b/bfd/libnlm.h
new file mode 100644
index 00000000000..12d2e4e0cf8
--- /dev/null
+++ b/bfd/libnlm.h
@@ -0,0 +1,264 @@
+/* BFD back-end data structures for NLM (NetWare Loadable Modules) files.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 boolean nlm_mkobject PARAMS ((bfd *));
+extern boolean nlm_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
+ unsigned long));
+
+extern void nlmNAME(get_symbol_info)
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+extern long nlmNAME(get_symtab_upper_bound)
+ PARAMS ((bfd *));
+extern long nlmNAME(get_symtab)
+ PARAMS ((bfd *, asymbol **));
+extern asymbol *nlmNAME(make_empty_symbol)
+ PARAMS ((bfd *));
+extern void nlmNAME(print_symbol)
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+extern long nlmNAME(get_reloc_upper_bound)
+ PARAMS ((bfd *, asection *));
+extern long nlmNAME(canonicalize_reloc)
+ PARAMS ((bfd *, asection *, arelent **, asymbol **));
+extern const bfd_target *nlmNAME(object_p)
+ PARAMS ((bfd *));
+extern boolean nlmNAME(set_arch_mach)
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+extern boolean nlmNAME(set_section_contents)
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+extern boolean nlmNAME(write_object_contents)
+ PARAMS ((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. */
+ long mach;
+ /* Some NLM formats do not use the uninitialized data section, so
+ all uninitialized data must be put into the regular data section
+ instead. */
+ 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_read will pick up the fixed header. */
+ boolean (*nlm_backend_object_p) PARAMS ((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. */
+ boolean (*nlm_write_prefix) PARAMS ((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. */
+ boolean (*nlm_read_reloc) PARAMS ((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. */
+ boolean (*nlm_mangle_relocs) PARAMS ((bfd *, asection *, PTR data,
+ bfd_vma offset,
+ bfd_size_type count));
+ /* 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. */
+ boolean (*nlm_read_import) PARAMS ((bfd *, nlmNAME(symbol_type) *));
+ /* Write an import record to abfd. */
+ boolean (*nlm_write_import) PARAMS ((bfd *, asection *, arelent *));
+ /* Set the section for a public symbol. This may be NULL, in which
+ case a default method will be used. */
+ boolean (*nlm_set_public_section) PARAMS ((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) PARAMS ((bfd *, asymbol *));
+ /* Swap the fixed header in and out */
+ void (*nlm_swap_fhdr_in) PARAMS ((bfd *,
+ PTR,
+ Nlm_Internal_Fixed_Header *));
+ void (*nlm_swap_fhdr_out) PARAMS ((bfd *,
+ struct nlm_internal_fixed_header *,
+ PTR));
+ /* Write out an external reference. */
+ boolean (*nlm_write_external) PARAMS ((bfd *, bfd_size_type,
+ asymbol *,
+ struct reloc_and_sec *));
+ boolean (*nlm_write_export) PARAMS ((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/liboasys.h b/bfd/liboasys.h
new file mode 100644
index 00000000000..7f7ea59b5a7
--- /dev/null
+++ b/bfd/liboasys.h
@@ -0,0 +1,82 @@
+/* BFD internal declarations for Oasys file format handling.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Scrawled by Steve Chamberlain of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+typedef struct _oasys_symbol
+{
+ asymbol symbol;
+} oasys_symbol_type;
+
+typedef struct _oasys_reloc {
+ arelent relent;
+ struct _oasys_reloc *next;
+ unsigned int symbol;
+} oasys_reloc_type;
+
+
+#define oasys_symbol(x) ((oasys_symbol_type *)(x))
+#define oasys_per_section(x) ((oasys_per_section_type *)(x->used_by_bfd))
+
+typedef struct _oasys_per_section
+{
+ asection *section;
+ bfd_byte *data;
+ bfd_vma offset;
+ boolean had_vma;
+ oasys_reloc_type **reloc_tail_ptr;
+ bfd_vma pc;
+
+
+ file_ptr current_pos;
+ unsigned int current_byte;
+ boolean initialized;
+} oasys_per_section_type;
+
+#define NSECTIONS 10
+
+typedef struct _oasys_ar_obstack {
+ file_ptr file_offset;
+ bfd *abfd;
+} oasys_ar_obstack_type;
+
+
+typedef struct _oasys_module_info {
+ file_ptr pos;
+ unsigned int size;
+ bfd *abfd;
+ char *name;
+} oasys_module_info_type;
+
+typedef struct _oasys_ar_data {
+ oasys_module_info_type *module;
+ unsigned int module_count;
+ unsigned int module_index;
+} oasys_ar_data_type;
+
+typedef struct _oasys_data {
+ char *strings;
+ asymbol *symbols;
+ unsigned int symbol_string_length;
+ asection *sections[OASYS_MAX_SEC_COUNT];
+ file_ptr first_data_record;
+} oasys_data_type;
+
+#define OASYS_DATA(abfd) ((abfd)->tdata.oasys_obj_data)
+#define OASYS_AR_DATA(abfd) ((abfd)->tdata.oasys_ar_data)
+
diff --git a/bfd/linker.c b/bfd/linker.c
new file mode 100644
index 00000000000..947514c3fbd
--- /dev/null
+++ b/bfd/linker.c
@@ -0,0 +1,2804 @@
+/* linker.c -- BFD linker routines
+ Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Written by Steve Chamberlain and 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "genlink.h"
+
+/*
+SECTION
+ Linker Functions
+
+@cindex Linker
+ The linker uses three special entry points in the BFD target
+ vector. It is not necessary to write special routines for
+ these entry points when creating a new BFD back end, since
+ generic versions are provided. However, writing them can
+ speed up linking and make it use significantly less runtime
+ memory.
+
+ The first routine creates a hash table used by the other
+ routines. The second routine adds the symbols from an object
+ file to the hash table. The third routine takes all the
+ object files and links them together to create the output
+ file. These routines are designed so that the linker proper
+ does not need to know anything about the symbols in the object
+ files that it is linking. The linker merely arranges the
+ sections as directed by the linker script and lets BFD handle
+ the details of symbols and relocs.
+
+ The second routine and third routines are passed a pointer to
+ a <<struct bfd_link_info>> structure (defined in
+ <<bfdlink.h>>) which holds information relevant to the link,
+ including the linker hash table (which was created by the
+ first routine) and a set of callback functions to the linker
+ proper.
+
+ The generic linker routines are in <<linker.c>>, and use the
+ header file <<genlink.h>>. As of this writing, the only back
+ ends which have implemented versions of these routines are
+ a.out (in <<aoutx.h>>) and ECOFF (in <<ecoff.c>>). The a.out
+ routines are used as examples throughout this section.
+
+@menu
+@* Creating a Linker Hash Table::
+@* Adding Symbols to the Hash Table::
+@* Performing the Final Link::
+@end menu
+
+INODE
+Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions
+SUBSECTION
+ Creating a linker hash table
+
+@cindex _bfd_link_hash_table_create in target vector
+@cindex target vector (_bfd_link_hash_table_create)
+ The linker routines must create a hash table, which must be
+ derived from <<struct bfd_link_hash_table>> described in
+ <<bfdlink.c>>. @xref{Hash Tables} for information on how to
+ create a derived hash table. This entry point is called using
+ the target vector of the linker output file.
+
+ The <<_bfd_link_hash_table_create>> entry point must allocate
+ and initialize an instance of the desired hash table. If the
+ back end does not require any additional information to be
+ stored with the entries in the hash table, the entry point may
+ simply create a <<struct bfd_link_hash_table>>. Most likely,
+ however, some additional information will be needed.
+
+ For example, with each entry in the hash table the a.out
+ linker keeps the index the symbol has in the final output file
+ (this index number is used so that when doing a relocateable
+ link the symbol index used in the output file can be quickly
+ filled in when copying over a reloc). The a.out linker code
+ defines the required structures and functions for a hash table
+ derived from <<struct bfd_link_hash_table>>. The a.out linker
+ hash table is created by the function
+ <<NAME(aout,link_hash_table_create)>>; it simply allocates
+ space for the hash table, initializes it, and returns a
+ pointer to it.
+
+ When writing the linker routines for a new back end, you will
+ generally not know exactly which fields will be required until
+ you have finished. You should simply create a new hash table
+ which defines no additional fields, and then simply add fields
+ as they become necessary.
+
+INODE
+Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions
+SUBSECTION
+ Adding symbols to the hash table
+
+@cindex _bfd_link_add_symbols in target vector
+@cindex target vector (_bfd_link_add_symbols)
+ The linker proper will call the <<_bfd_link_add_symbols>>
+ entry point for each object file or archive which is to be
+ linked (typically these are the files named on the command
+ line, but some may also come from the linker script). The
+ entry point is responsible for examining the file. For an
+ object file, BFD must add any relevant symbol information to
+ the hash table. For an archive, BFD must determine which
+ elements of the archive should be used and adding them to the
+ link.
+
+ The a.out version of this entry point is
+ <<NAME(aout,link_add_symbols)>>.
+
+@menu
+@* Differing file formats::
+@* Adding symbols from an object file::
+@* Adding symbols from an archive::
+@end menu
+
+INODE
+Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table
+SUBSUBSECTION
+ Differing file formats
+
+ Normally all the files involved in a link will be of the same
+ format, but it is also possible to link together different
+ format object files, and the back end must support that. The
+ <<_bfd_link_add_symbols>> entry point is called via the target
+ vector of the file to be added. This has an important
+ consequence: the function may not assume that the hash table
+ is the type created by the corresponding
+ <<_bfd_link_hash_table_create>> vector. All the
+ <<_bfd_link_add_symbols>> function can assume about the hash
+ table is that it is derived from <<struct
+ bfd_link_hash_table>>.
+
+ Sometimes the <<_bfd_link_add_symbols>> function must store
+ some information in the hash table entry to be used by the
+ <<_bfd_final_link>> function. In such a case the <<creator>>
+ field of the hash table must be checked to make sure that the
+ hash table was created by an object file of the same format.
+
+ The <<_bfd_final_link>> routine must be prepared to handle a
+ hash entry without any extra information added by the
+ <<_bfd_link_add_symbols>> function. A hash entry without
+ extra information will also occur when the linker script
+ directs the linker to create a symbol. Note that, regardless
+ of how a hash table entry is added, all the fields will be
+ initialized to some sort of null value by the hash table entry
+ initialization function.
+
+ See <<ecoff_link_add_externals>> for an example of how to
+ check the <<creator>> field before saving information (in this
+ case, the ECOFF external symbol debugging information) in a
+ hash table entry.
+
+INODE
+Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table
+SUBSUBSECTION
+ Adding symbols from an object file
+
+ When the <<_bfd_link_add_symbols>> routine is passed an object
+ file, it must add all externally visible symbols in that
+ object file to the hash table. The actual work of adding the
+ symbol to the hash table is normally handled by the function
+ <<_bfd_generic_link_add_one_symbol>>. The
+ <<_bfd_link_add_symbols>> routine is responsible for reading
+ all the symbols from the object file and passing the correct
+ information to <<_bfd_generic_link_add_one_symbol>>.
+
+ The <<_bfd_link_add_symbols>> routine should not use
+ <<bfd_canonicalize_symtab>> to read the symbols. The point of
+ providing this routine is to avoid the overhead of converting
+ the symbols into generic <<asymbol>> structures.
+
+@findex _bfd_generic_link_add_one_symbol
+ <<_bfd_generic_link_add_one_symbol>> handles the details of
+ combining common symbols, warning about multiple definitions,
+ and so forth. It takes arguments which describe the symbol to
+ add, notably symbol flags, a section, and an offset. The
+ symbol flags include such things as <<BSF_WEAK>> or
+ <<BSF_INDIRECT>>. The section is a section in the object
+ file, or something like <<bfd_und_section_ptr>> for an undefined
+ symbol or <<bfd_com_section_ptr>> for a common symbol.
+
+ If the <<_bfd_final_link>> routine is also going to need to
+ read the symbol information, the <<_bfd_link_add_symbols>>
+ routine should save it somewhere attached to the object file
+ BFD. However, the information should only be saved if the
+ <<keep_memory>> field of the <<info>> argument is true, so
+ that the <<-no-keep-memory>> linker switch is effective.
+
+ The a.out function which adds symbols from an object file is
+ <<aout_link_add_object_symbols>>, and most of the interesting
+ work is in <<aout_link_add_symbols>>. The latter saves
+ pointers to the hash tables entries created by
+ <<_bfd_generic_link_add_one_symbol>> indexed by symbol number,
+ so that the <<_bfd_final_link>> routine does not have to call
+ the hash table lookup routine to locate the entry.
+
+INODE
+Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table
+SUBSUBSECTION
+ Adding symbols from an archive
+
+ When the <<_bfd_link_add_symbols>> routine is passed an
+ archive, it must look through the symbols defined by the
+ archive and decide which elements of the archive should be
+ included in the link. For each such element it must call the
+ <<add_archive_element>> linker callback, and it must add the
+ symbols from the object file to the linker hash table.
+
+@findex _bfd_generic_link_add_archive_symbols
+ In most cases the work of looking through the symbols in the
+ archive should be done by the
+ <<_bfd_generic_link_add_archive_symbols>> function. This
+ function builds a hash table from the archive symbol table and
+ looks through the list of undefined symbols to see which
+ elements should be included.
+ <<_bfd_generic_link_add_archive_symbols>> is passed a function
+ to call to make the final decision about adding an archive
+ element to the link and to do the actual work of adding the
+ symbols to the linker hash table.
+
+ The function passed to
+ <<_bfd_generic_link_add_archive_symbols>> must read the
+ symbols of the archive element and decide whether the archive
+ element should be included in the link. If the element is to
+ be included, the <<add_archive_element>> linker callback
+ routine must be called with the element as an argument, and
+ the elements symbols must be added to the linker hash table
+ just as though the element had itself been passed to the
+ <<_bfd_link_add_symbols>> function.
+
+ When the a.out <<_bfd_link_add_symbols>> function receives an
+ archive, it calls <<_bfd_generic_link_add_archive_symbols>>
+ passing <<aout_link_check_archive_element>> as the function
+ argument. <<aout_link_check_archive_element>> calls
+ <<aout_link_check_ar_symbols>>. If the latter decides to add
+ the element (an element is only added if it provides a real,
+ non-common, definition for a previously undefined or common
+ symbol) it calls the <<add_archive_element>> callback and then
+ <<aout_link_check_archive_element>> calls
+ <<aout_link_add_symbols>> to actually add the symbols to the
+ linker hash table.
+
+ The ECOFF back end is unusual in that it does not normally
+ call <<_bfd_generic_link_add_archive_symbols>>, because ECOFF
+ archives already contain a hash table of symbols. The ECOFF
+ back end searches the archive itself to avoid the overhead of
+ creating a new hash table.
+
+INODE
+Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions
+SUBSECTION
+ Performing the final link
+
+@cindex _bfd_link_final_link in target vector
+@cindex target vector (_bfd_final_link)
+ When all the input files have been processed, the linker calls
+ the <<_bfd_final_link>> entry point of the output BFD. This
+ routine is responsible for producing the final output file,
+ which has several aspects. It must relocate the contents of
+ the input sections and copy the data into the output sections.
+ It must build an output symbol table including any local
+ symbols from the input files and the global symbols from the
+ hash table. When producing relocateable output, it must
+ modify the input relocs and write them into the output file.
+ There may also be object format dependent work to be done.
+
+ The linker will also call the <<write_object_contents>> entry
+ point when the BFD is closed. The two entry points must work
+ together in order to produce the correct output file.
+
+ The details of how this works are inevitably dependent upon
+ the specific object file format. The a.out
+ <<_bfd_final_link>> routine is <<NAME(aout,final_link)>>.
+
+@menu
+@* Information provided by the linker::
+@* Relocating the section contents::
+@* Writing the symbol table::
+@end menu
+
+INODE
+Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link
+SUBSUBSECTION
+ Information provided by the linker
+
+ Before the linker calls the <<_bfd_final_link>> entry point,
+ it sets up some data structures for the function to use.
+
+ The <<input_bfds>> field of the <<bfd_link_info>> structure
+ will point to a list of all the input files included in the
+ link. These files are linked through the <<link_next>> field
+ of the <<bfd>> structure.
+
+ Each section in the output file will have a list of
+ <<link_order>> structures attached to the <<link_order_head>>
+ field (the <<link_order>> structure is defined in
+ <<bfdlink.h>>). These structures describe how to create the
+ contents of the output section in terms of the contents of
+ various input sections, fill constants, and, eventually, other
+ types of information. They also describe relocs that must be
+ created by the BFD backend, but do not correspond to any input
+ file; this is used to support -Ur, which builds constructors
+ while generating a relocateable object file.
+
+INODE
+Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link
+SUBSUBSECTION
+ Relocating the section contents
+
+ The <<_bfd_final_link>> function should look through the
+ <<link_order>> structures attached to each section of the
+ output file. Each <<link_order>> structure should either be
+ handled specially, or it should be passed to the function
+ <<_bfd_default_link_order>> which will do the right thing
+ (<<_bfd_default_link_order>> is defined in <<linker.c>>).
+
+ For efficiency, a <<link_order>> of type
+ <<bfd_indirect_link_order>> whose associated section belongs
+ to a BFD of the same format as the output BFD must be handled
+ specially. This type of <<link_order>> describes part of an
+ output section in terms of a section belonging to one of the
+ input files. The <<_bfd_final_link>> function should read the
+ contents of the section and any associated relocs, apply the
+ relocs to the section contents, and write out the modified
+ section contents. If performing a relocateable link, the
+ relocs themselves must also be modified and written out.
+
+@findex _bfd_relocate_contents
+@findex _bfd_final_link_relocate
+ The functions <<_bfd_relocate_contents>> and
+ <<_bfd_final_link_relocate>> provide some general support for
+ performing the actual relocations, notably overflow checking.
+ Their arguments include information about the symbol the
+ relocation is against and a <<reloc_howto_type>> argument
+ which describes the relocation to perform. These functions
+ are defined in <<reloc.c>>.
+
+ The a.out function which handles reading, relocating, and
+ writing section contents is <<aout_link_input_section>>. The
+ actual relocation is done in <<aout_link_input_section_std>>
+ and <<aout_link_input_section_ext>>.
+
+INODE
+Writing the symbol table, , Relocating the section contents, Performing the Final Link
+SUBSUBSECTION
+ Writing the symbol table
+
+ The <<_bfd_final_link>> function must gather all the symbols
+ in the input files and write them out. It must also write out
+ all the symbols in the global hash table. This must be
+ controlled by the <<strip>> and <<discard>> fields of the
+ <<bfd_link_info>> structure.
+
+ The local symbols of the input files will not have been
+ entered into the linker hash table. The <<_bfd_final_link>>
+ routine must consider each input file and include the symbols
+ in the output file. It may be convenient to do this when
+ looking through the <<link_order>> structures, or it may be
+ done by stepping through the <<input_bfds>> list.
+
+ The <<_bfd_final_link>> routine must also traverse the global
+ hash table to gather all the externally visible symbols. It
+ is possible that most of the externally visible symbols may be
+ written out when considering the symbols of each input file,
+ but it is still necessary to traverse the hash table since the
+ linker script may have defined some symbols that are not in
+ any of the input files.
+
+ The <<strip>> field of the <<bfd_link_info>> structure
+ controls which symbols are written out. The possible values
+ are listed in <<bfdlink.h>>. If the value is <<strip_some>>,
+ then the <<keep_hash>> field of the <<bfd_link_info>>
+ structure is a hash table of symbols to keep; each symbol
+ should be looked up in this hash table, and only symbols which
+ are present should be included in the output file.
+
+ If the <<strip>> field of the <<bfd_link_info>> structure
+ permits local symbols to be written out, the <<discard>> field
+ is used to further controls which local symbols are included
+ in the output file. If the value is <<discard_l>>, then all
+ local symbols which begin with a certain prefix are discarded;
+ this is controlled by the <<bfd_is_local_label_name>> entry point.
+
+ The a.out backend handles symbols by calling
+ <<aout_link_write_symbols>> on each input BFD and then
+ traversing the global hash table with the function
+ <<aout_link_write_other_symbol>>. It builds a string table
+ while writing out the symbols, which is written to the output
+ file at the end of <<NAME(aout,final_link)>>.
+*/
+
+static boolean generic_link_read_symbols
+ PARAMS ((bfd *));
+static boolean generic_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, boolean collect));
+static boolean generic_link_add_object_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, boolean collect));
+static boolean generic_link_check_archive_element_no_collect
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
+static boolean generic_link_check_archive_element_collect
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
+static boolean generic_link_check_archive_element
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded, boolean collect));
+static boolean generic_link_add_symbol_list
+ PARAMS ((bfd *, struct bfd_link_info *, bfd_size_type count, asymbol **,
+ boolean collect));
+static bfd *hash_entry_bfd PARAMS ((struct bfd_link_hash_entry *));
+static void set_symbol_from_hash
+ PARAMS ((asymbol *, struct bfd_link_hash_entry *));
+static boolean generic_add_output_symbol
+ PARAMS ((bfd *, size_t *psymalloc, asymbol *));
+static boolean default_fill_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *));
+static boolean default_indirect_link_order
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ struct bfd_link_order *, boolean));
+
+/* The link hash table structure is defined in bfdlink.h. It provides
+ a base hash table which the backend specific hash tables are built
+ upon. */
+
+/* Routine to create an entry in the link hash table. */
+
+struct bfd_hash_entry *
+_bfd_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct bfd_link_hash_entry *ret = (struct bfd_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct bfd_link_hash_entry *) NULL)
+ ret = ((struct bfd_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry)));
+ if (ret == (struct bfd_link_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct bfd_link_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ ret->type = bfd_link_hash_new;
+ ret->next = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize a link hash table. The BFD argument is the one
+ responsible for creating this table. */
+
+boolean
+_bfd_link_hash_table_init (table, abfd, newfunc)
+ struct bfd_link_hash_table *table;
+ bfd *abfd;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ table->creator = abfd->xvec;
+ table->undefs = NULL;
+ table->undefs_tail = NULL;
+ return bfd_hash_table_init (&table->table, newfunc);
+}
+
+/* Look up a symbol in a link hash table. If follow is true, we
+ follow bfd_link_hash_indirect and bfd_link_hash_warning links to
+ the real symbol. */
+
+struct bfd_link_hash_entry *
+bfd_link_hash_lookup (table, string, create, copy, follow)
+ struct bfd_link_hash_table *table;
+ const char *string;
+ boolean create;
+ boolean copy;
+ boolean follow;
+{
+ struct bfd_link_hash_entry *ret;
+
+ ret = ((struct bfd_link_hash_entry *)
+ bfd_hash_lookup (&table->table, string, create, copy));
+
+ if (follow && ret != (struct bfd_link_hash_entry *) NULL)
+ {
+ while (ret->type == bfd_link_hash_indirect
+ || ret->type == bfd_link_hash_warning)
+ ret = ret->u.i.link;
+ }
+
+ return ret;
+}
+
+/* Look up a symbol in the main linker hash table if the symbol might
+ be wrapped. This should only be used for references to an
+ undefined symbol, not for definitions of a symbol. */
+
+struct bfd_link_hash_entry *
+bfd_wrapped_link_hash_lookup (abfd, info, string, create, copy, follow)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ const char *string;
+ boolean create;
+ boolean copy;
+ boolean follow;
+{
+ if (info->wrap_hash != NULL)
+ {
+ const char *l;
+
+ l = string;
+ if (*l == bfd_get_symbol_leading_char (abfd))
+ ++l;
+
+#undef WRAP
+#define WRAP "__wrap_"
+
+ if (bfd_hash_lookup (info->wrap_hash, l, false, false) != NULL)
+ {
+ char *n;
+ struct bfd_link_hash_entry *h;
+
+ /* This symbol is being wrapped. We want to replace all
+ references to SYM with references to __wrap_SYM. */
+
+ n = (char *) bfd_malloc (strlen (l) + sizeof WRAP + 1);
+ if (n == NULL)
+ return NULL;
+
+ /* Note that symbol_leading_char may be '\0'. */
+ n[0] = bfd_get_symbol_leading_char (abfd);
+ n[1] = '\0';
+ strcat (n, WRAP);
+ strcat (n, l);
+ h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
+ free (n);
+ return h;
+ }
+
+#undef WRAP
+
+#undef REAL
+#define REAL "__real_"
+
+ if (*l == '_'
+ && strncmp (l, REAL, sizeof REAL - 1) == 0
+ && bfd_hash_lookup (info->wrap_hash, l + sizeof REAL - 1,
+ false, false) != NULL)
+ {
+ char *n;
+ struct bfd_link_hash_entry *h;
+
+ /* This is a reference to __real_SYM, where SYM is being
+ wrapped. We want to replace all references to __real_SYM
+ with references to SYM. */
+
+ n = (char *) bfd_malloc (strlen (l + sizeof REAL - 1) + 2);
+ if (n == NULL)
+ return NULL;
+
+ /* Note that symbol_leading_char may be '\0'. */
+ n[0] = bfd_get_symbol_leading_char (abfd);
+ n[1] = '\0';
+ strcat (n, l + sizeof REAL - 1);
+ h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
+ free (n);
+ return h;
+ }
+
+#undef REAL
+ }
+
+ return bfd_link_hash_lookup (info->hash, string, create, copy, follow);
+}
+
+/* Traverse a generic link hash table. The only reason this is not a
+ macro is to do better type checking. This code presumes that an
+ argument passed as a struct bfd_hash_entry * may be caught as a
+ struct bfd_link_hash_entry * with no explicit cast required on the
+ call. */
+
+void
+bfd_link_hash_traverse (table, func, info)
+ struct bfd_link_hash_table *table;
+ boolean (*func) PARAMS ((struct bfd_link_hash_entry *, PTR));
+ PTR info;
+{
+ bfd_hash_traverse (&table->table,
+ ((boolean (*) PARAMS ((struct bfd_hash_entry *, PTR)))
+ func),
+ info);
+}
+
+/* Add a symbol to the linker hash table undefs list. */
+
+INLINE void
+bfd_link_add_undef (table, h)
+ struct bfd_link_hash_table *table;
+ struct bfd_link_hash_entry *h;
+{
+ BFD_ASSERT (h->next == NULL);
+ if (table->undefs_tail != (struct bfd_link_hash_entry *) NULL)
+ table->undefs_tail->next = h;
+ if (table->undefs == (struct bfd_link_hash_entry *) NULL)
+ table->undefs = h;
+ table->undefs_tail = h;
+}
+
+/* Routine to create an entry in an generic link hash table. */
+
+struct bfd_hash_entry *
+_bfd_generic_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct generic_link_hash_entry *ret =
+ (struct generic_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct generic_link_hash_entry *) NULL)
+ ret = ((struct generic_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry)));
+ if (ret == (struct generic_link_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct generic_link_hash_entry *)
+ _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+
+ if (ret)
+ {
+ /* Set local fields. */
+ ret->written = false;
+ ret->sym = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create an generic link hash table. */
+
+struct bfd_link_hash_table *
+_bfd_generic_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct generic_link_hash_table *ret;
+
+ ret = ((struct generic_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));
+ if (ret == NULL)
+ return (struct bfd_link_hash_table *) NULL;
+ if (! _bfd_link_hash_table_init (&ret->root, abfd,
+ _bfd_generic_link_hash_newfunc))
+ {
+ free (ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+ return &ret->root;
+}
+
+/* Grab the symbols for an object file when doing a generic link. We
+ store the symbols in the outsymbols field. We need to keep them
+ around for the entire link to ensure that we only read them once.
+ If we read them multiple times, we might wind up with relocs and
+ the hash table pointing to different instances of the symbol
+ structure. */
+
+static boolean
+generic_link_read_symbols (abfd)
+ bfd *abfd;
+{
+ if (bfd_get_outsymbols (abfd) == (asymbol **) NULL)
+ {
+ long symsize;
+ long symcount;
+
+ symsize = bfd_get_symtab_upper_bound (abfd);
+ if (symsize < 0)
+ return false;
+ bfd_get_outsymbols (abfd) = (asymbol **) bfd_alloc (abfd, symsize);
+ if (bfd_get_outsymbols (abfd) == NULL && symsize != 0)
+ return false;
+ symcount = bfd_canonicalize_symtab (abfd, bfd_get_outsymbols (abfd));
+ if (symcount < 0)
+ return false;
+ bfd_get_symcount (abfd) = symcount;
+ }
+
+ return true;
+}
+
+/* Generic function to add symbols to from an object file to the
+ global hash table. This version does not automatically collect
+ constructors by name. */
+
+boolean
+_bfd_generic_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ return generic_link_add_symbols (abfd, info, false);
+}
+
+/* Generic function to add symbols from an object file to the global
+ hash table. This version automatically collects constructors by
+ name, as the collect2 program does. It should be used for any
+ target which does not provide some other mechanism for setting up
+ constructors and destructors; these are approximately those targets
+ for which gcc uses collect2 and do not support stabs. */
+
+boolean
+_bfd_generic_link_add_symbols_collect (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ return generic_link_add_symbols (abfd, info, true);
+}
+
+/* Add symbols from an object file to the global hash table. */
+
+static boolean
+generic_link_add_symbols (abfd, info, collect)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean collect;
+{
+ boolean ret;
+
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_object:
+ ret = generic_link_add_object_symbols (abfd, info, collect);
+ break;
+ case bfd_archive:
+ ret = (_bfd_generic_link_add_archive_symbols
+ (abfd, info,
+ (collect
+ ? generic_link_check_archive_element_collect
+ : generic_link_check_archive_element_no_collect)));
+ break;
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ ret = false;
+ }
+
+ return ret;
+}
+
+/* Add symbols from an object file to the global hash table. */
+
+static boolean
+generic_link_add_object_symbols (abfd, info, collect)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean collect;
+{
+ if (! generic_link_read_symbols (abfd))
+ return false;
+ return generic_link_add_symbol_list (abfd, info,
+ _bfd_generic_link_get_symcount (abfd),
+ _bfd_generic_link_get_symbols (abfd),
+ collect);
+}
+
+/* We build a hash table of all symbols defined in an archive. */
+
+/* An archive symbol may be defined by multiple archive elements.
+ This linked list is used to hold the elements. */
+
+struct archive_list
+{
+ struct archive_list *next;
+ int indx;
+};
+
+/* An entry in an archive hash table. */
+
+struct archive_hash_entry
+{
+ struct bfd_hash_entry root;
+ /* Where the symbol is defined. */
+ struct archive_list *defs;
+};
+
+/* An archive hash table itself. */
+
+struct archive_hash_table
+{
+ struct bfd_hash_table table;
+};
+
+static struct bfd_hash_entry *archive_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static boolean archive_hash_table_init
+ PARAMS ((struct archive_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+/* Create a new entry for an archive hash table. */
+
+static struct bfd_hash_entry *
+archive_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct archive_hash_entry *ret = (struct archive_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct archive_hash_entry *) NULL)
+ ret = ((struct archive_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct archive_hash_entry)));
+ if (ret == (struct archive_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct archive_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ ret->defs = (struct archive_list *) NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize an archive hash table. */
+
+static boolean
+archive_hash_table_init (table, newfunc)
+ struct archive_hash_table *table;
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+{
+ return bfd_hash_table_init (&table->table, newfunc);
+}
+
+/* Look up an entry in an archive hash table. */
+
+#define archive_hash_lookup(t, string, create, copy) \
+ ((struct archive_hash_entry *) \
+ bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
+
+/* Allocate space in an archive hash table. */
+
+#define archive_hash_allocate(t, size) bfd_hash_allocate (&(t)->table, (size))
+
+/* Free an archive hash table. */
+
+#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table)
+
+/* Generic function to add symbols from an archive file to the global
+ hash file. This function presumes that the archive symbol table
+ has already been read in (this is normally done by the
+ bfd_check_format entry point). It looks through the undefined and
+ common symbols and searches the archive symbol table for them. If
+ it finds an entry, it includes the associated object file in the
+ link.
+
+ The old linker looked through the archive symbol table for
+ undefined symbols. We do it the other way around, looking through
+ undefined symbols for symbols defined in the archive. The
+ advantage of the newer scheme is that we only have to look through
+ the list of undefined symbols once, whereas the old method had to
+ re-search the symbol table each time a new object file was added.
+
+ The CHECKFN argument is used to see if an object file should be
+ included. CHECKFN should set *PNEEDED to true if the object file
+ should be included, and must also call the bfd_link_info
+ add_archive_element callback function and handle adding the symbols
+ to the global hash table. CHECKFN should only return false if some
+ sort of error occurs.
+
+ For some formats, such as a.out, it is possible to look through an
+ object file but not actually include it in the link. The
+ archive_pass field in a BFD is used to avoid checking the symbols
+ of an object files too many times. When an object is included in
+ the link, archive_pass is set to -1. If an object is scanned but
+ not included, archive_pass is set to the pass number. The pass
+ number is incremented each time a new object file is included. The
+ pass number is used because when a new object file is included it
+ may create new undefined symbols which cause a previously examined
+ object file to be included. */
+
+boolean
+_bfd_generic_link_add_archive_symbols (abfd, info, checkfn)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean (*checkfn) PARAMS ((bfd *, struct bfd_link_info *,
+ boolean *pneeded));
+{
+ carsym *arsyms;
+ carsym *arsym_end;
+ register carsym *arsym;
+ int pass;
+ struct archive_hash_table arsym_hash;
+ int indx;
+ struct bfd_link_hash_entry **pundef;
+
+ if (! bfd_has_map (abfd))
+ {
+ /* An empty archive is a special case. */
+ if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
+ return true;
+ bfd_set_error (bfd_error_no_armap);
+ return false;
+ }
+
+ arsyms = bfd_ardata (abfd)->symdefs;
+ arsym_end = arsyms + bfd_ardata (abfd)->symdef_count;
+
+ /* In order to quickly determine whether an symbol is defined in
+ this archive, we build a hash table of the symbols. */
+ if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc))
+ return false;
+ for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++)
+ {
+ struct archive_hash_entry *arh;
+ struct archive_list *l, **pp;
+
+ arh = archive_hash_lookup (&arsym_hash, arsym->name, true, false);
+ if (arh == (struct archive_hash_entry *) NULL)
+ goto error_return;
+ l = ((struct archive_list *)
+ archive_hash_allocate (&arsym_hash, sizeof (struct archive_list)));
+ if (l == NULL)
+ goto error_return;
+ l->indx = indx;
+ for (pp = &arh->defs;
+ *pp != (struct archive_list *) NULL;
+ pp = &(*pp)->next)
+ ;
+ *pp = l;
+ l->next = NULL;
+ }
+
+ /* The archive_pass field in the archive itself is used to
+ initialize PASS, sine we may search the same archive multiple
+ times. */
+ pass = abfd->archive_pass + 1;
+
+ /* New undefined symbols are added to the end of the list, so we
+ only need to look through it once. */
+ pundef = &info->hash->undefs;
+ while (*pundef != (struct bfd_link_hash_entry *) NULL)
+ {
+ struct bfd_link_hash_entry *h;
+ struct archive_hash_entry *arh;
+ struct archive_list *l;
+
+ h = *pundef;
+
+ /* When a symbol is defined, it is not necessarily removed from
+ the list. */
+ if (h->type != bfd_link_hash_undefined
+ && h->type != bfd_link_hash_common)
+ {
+ /* Remove this entry from the list, for general cleanliness
+ and because we are going to look through the list again
+ if we search any more libraries. We can't remove the
+ entry if it is the tail, because that would lose any
+ entries we add to the list later on (it would also cause
+ us to lose track of whether the symbol has been
+ referenced). */
+ if (*pundef != info->hash->undefs_tail)
+ *pundef = (*pundef)->next;
+ else
+ pundef = &(*pundef)->next;
+ continue;
+ }
+
+ /* Look for this symbol in the archive symbol map. */
+ arh = archive_hash_lookup (&arsym_hash, h->root.string, false, false);
+ if (arh == (struct archive_hash_entry *) NULL)
+ {
+ pundef = &(*pundef)->next;
+ continue;
+ }
+
+ /* Look at all the objects which define this symbol. */
+ for (l = arh->defs; l != (struct archive_list *) NULL; l = l->next)
+ {
+ bfd *element;
+ boolean needed;
+
+ /* If the symbol has gotten defined along the way, quit. */
+ if (h->type != bfd_link_hash_undefined
+ && h->type != bfd_link_hash_common)
+ break;
+
+ element = bfd_get_elt_at_index (abfd, l->indx);
+ if (element == (bfd *) NULL)
+ goto error_return;
+
+ /* If we've already included this element, or if we've
+ already checked it on this pass, continue. */
+ if (element->archive_pass == -1
+ || element->archive_pass == pass)
+ continue;
+
+ /* If we can't figure this element out, just ignore it. */
+ if (! bfd_check_format (element, bfd_object))
+ {
+ element->archive_pass = -1;
+ continue;
+ }
+
+ /* CHECKFN will see if this element should be included, and
+ go ahead and include it if appropriate. */
+ if (! (*checkfn) (element, info, &needed))
+ goto error_return;
+
+ if (! needed)
+ element->archive_pass = pass;
+ else
+ {
+ element->archive_pass = -1;
+
+ /* Increment the pass count to show that we may need to
+ recheck object files which were already checked. */
+ ++pass;
+ }
+ }
+
+ pundef = &(*pundef)->next;
+ }
+
+ archive_hash_table_free (&arsym_hash);
+
+ /* Save PASS in case we are called again. */
+ abfd->archive_pass = pass;
+
+ return true;
+
+ error_return:
+ archive_hash_table_free (&arsym_hash);
+ return false;
+}
+
+/* See if we should include an archive element. This version is used
+ when we do not want to automatically collect constructors based on
+ the symbol name, presumably because we have some other mechanism
+ for finding them. */
+
+static boolean
+generic_link_check_archive_element_no_collect (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ return generic_link_check_archive_element (abfd, info, pneeded, false);
+}
+
+/* See if we should include an archive element. This version is used
+ when we want to automatically collect constructors based on the
+ symbol name, as collect2 does. */
+
+static boolean
+generic_link_check_archive_element_collect (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ return generic_link_check_archive_element (abfd, info, pneeded, true);
+}
+
+/* See if we should include an archive element. Optionally collect
+ constructors. */
+
+static boolean
+generic_link_check_archive_element (abfd, info, pneeded, collect)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+ boolean collect;
+{
+ asymbol **pp, **ppend;
+
+ *pneeded = false;
+
+ if (! generic_link_read_symbols (abfd))
+ return false;
+
+ pp = _bfd_generic_link_get_symbols (abfd);
+ ppend = pp + _bfd_generic_link_get_symcount (abfd);
+ for (; pp < ppend; pp++)
+ {
+ asymbol *p;
+ struct bfd_link_hash_entry *h;
+
+ p = *pp;
+
+ /* We are only interested in globally visible symbols. */
+ if (! bfd_is_com_section (p->section)
+ && (p->flags & (BSF_GLOBAL | BSF_INDIRECT | BSF_WEAK)) == 0)
+ continue;
+
+ /* We are only interested if we know something about this
+ symbol, and it is undefined or common. An undefined weak
+ symbol (type bfd_link_hash_undefweak) is not considered to be
+ a reference when pulling files out of an archive. See the
+ SVR4 ABI, p. 4-27. */
+ h = bfd_link_hash_lookup (info->hash, bfd_asymbol_name (p), false,
+ false, true);
+ if (h == (struct bfd_link_hash_entry *) NULL
+ || (h->type != bfd_link_hash_undefined
+ && h->type != bfd_link_hash_common))
+ continue;
+
+ /* P is a symbol we are looking for. */
+
+ if (! bfd_is_com_section (p->section))
+ {
+ bfd_size_type symcount;
+ asymbol **symbols;
+
+ /* This object file defines this symbol, so pull it in. */
+ if (! (*info->callbacks->add_archive_element) (info, abfd,
+ bfd_asymbol_name (p)))
+ return false;
+ symcount = _bfd_generic_link_get_symcount (abfd);
+ symbols = _bfd_generic_link_get_symbols (abfd);
+ if (! generic_link_add_symbol_list (abfd, info, symcount,
+ symbols, collect))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+
+ /* P is a common symbol. */
+
+ if (h->type == bfd_link_hash_undefined)
+ {
+ bfd *symbfd;
+ bfd_vma size;
+ unsigned int power;
+
+ symbfd = h->u.undef.abfd;
+ if (symbfd == (bfd *) NULL)
+ {
+ /* This symbol was created as undefined from outside
+ BFD. We assume that we should link in the object
+ file. This is for the -u option in the linker. */
+ if (! (*info->callbacks->add_archive_element)
+ (info, abfd, bfd_asymbol_name (p)))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+
+ /* Turn the symbol into a common symbol but do not link in
+ the object file. This is how a.out works. Object
+ formats that require different semantics must implement
+ this function differently. This symbol is already on the
+ undefs list. We add the section to a common section
+ attached to symbfd to ensure that it is in a BFD which
+ will be linked in. */
+ h->type = bfd_link_hash_common;
+ h->u.c.p =
+ ((struct bfd_link_hash_common_entry *)
+ bfd_hash_allocate (&info->hash->table,
+ sizeof (struct bfd_link_hash_common_entry)));
+ if (h->u.c.p == NULL)
+ return false;
+
+ size = bfd_asymbol_value (p);
+ h->u.c.size = size;
+
+ power = bfd_log2 (size);
+ if (power > 4)
+ power = 4;
+ h->u.c.p->alignment_power = power;
+
+ if (p->section == bfd_com_section_ptr)
+ h->u.c.p->section = bfd_make_section_old_way (symbfd, "COMMON");
+ else
+ h->u.c.p->section = bfd_make_section_old_way (symbfd,
+ p->section->name);
+ h->u.c.p->section->flags = SEC_ALLOC;
+ }
+ else
+ {
+ /* Adjust the size of the common symbol if necessary. This
+ is how a.out works. Object formats that require
+ different semantics must implement this function
+ differently. */
+ if (bfd_asymbol_value (p) > h->u.c.size)
+ h->u.c.size = bfd_asymbol_value (p);
+ }
+ }
+
+ /* This archive element is not needed. */
+ return true;
+}
+
+/* Add the symbols from an object file to the global hash table. ABFD
+ is the object file. INFO is the linker information. SYMBOL_COUNT
+ is the number of symbols. SYMBOLS is the list of symbols. COLLECT
+ is true if constructors should be automatically collected by name
+ as is done by collect2. */
+
+static boolean
+generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ bfd_size_type symbol_count;
+ asymbol **symbols;
+ boolean collect;
+{
+ asymbol **pp, **ppend;
+
+ pp = symbols;
+ ppend = symbols + symbol_count;
+ for (; pp < ppend; pp++)
+ {
+ asymbol *p;
+
+ p = *pp;
+
+ if ((p->flags & (BSF_INDIRECT
+ | BSF_WARNING
+ | BSF_GLOBAL
+ | BSF_CONSTRUCTOR
+ | BSF_WEAK)) != 0
+ || bfd_is_und_section (bfd_get_section (p))
+ || bfd_is_com_section (bfd_get_section (p))
+ || bfd_is_ind_section (bfd_get_section (p)))
+ {
+ const char *name;
+ const char *string;
+ struct generic_link_hash_entry *h;
+
+ name = bfd_asymbol_name (p);
+ if (((p->flags & BSF_INDIRECT) != 0
+ || bfd_is_ind_section (p->section))
+ && pp + 1 < ppend)
+ {
+ pp++;
+ string = bfd_asymbol_name (*pp);
+ }
+ else if ((p->flags & BSF_WARNING) != 0
+ && pp + 1 < ppend)
+ {
+ /* The name of P is actually the warning string, and the
+ next symbol is the one to warn about. */
+ string = name;
+ pp++;
+ name = bfd_asymbol_name (*pp);
+ }
+ else
+ string = NULL;
+
+ h = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, name, p->flags, bfd_get_section (p),
+ p->value, string, false, collect,
+ (struct bfd_link_hash_entry **) &h)))
+ return false;
+
+ /* If this is a constructor symbol, and the linker didn't do
+ anything with it, then we want to just pass the symbol
+ through to the output file. This will happen when
+ linking with -r. */
+ if ((p->flags & BSF_CONSTRUCTOR) != 0
+ && (h == NULL || h->root.type == bfd_link_hash_new))
+ {
+ p->udata.p = NULL;
+ continue;
+ }
+
+ /* Save the BFD symbol so that we don't lose any backend
+ specific information that may be attached to it. We only
+ want this one if it gives more information than the
+ existing one; we don't want to replace a defined symbol
+ with an undefined one. This routine may be called with a
+ hash table other than the generic hash table, so we only
+ do this if we are certain that the hash table is a
+ generic one. */
+ if (info->hash->creator == abfd->xvec)
+ {
+ if (h->sym == (asymbol *) NULL
+ || (! bfd_is_und_section (bfd_get_section (p))
+ && (! bfd_is_com_section (bfd_get_section (p))
+ || bfd_is_und_section (bfd_get_section (h->sym)))))
+ {
+ h->sym = p;
+ /* BSF_OLD_COMMON is a hack to support COFF reloc
+ reading, and it should go away when the COFF
+ linker is switched to the new version. */
+ if (bfd_is_com_section (bfd_get_section (p)))
+ p->flags |= BSF_OLD_COMMON;
+ }
+ }
+
+ /* Store a back pointer from the symbol to the hash
+ table entry for the benefit of relaxation code until
+ it gets rewritten to not use asymbol structures.
+ Setting this is also used to check whether these
+ symbols were set up by the generic linker. */
+ p->udata.p = (PTR) h;
+ }
+ }
+
+ return true;
+}
+
+/* We use a state table to deal with adding symbols from an object
+ file. The first index into the state table describes the symbol
+ from the object file. The second index into the state table is the
+ type of the symbol in the hash table. */
+
+/* The symbol from the object file is turned into one of these row
+ values. */
+
+enum link_row
+{
+ UNDEF_ROW, /* Undefined. */
+ UNDEFW_ROW, /* Weak undefined. */
+ DEF_ROW, /* Defined. */
+ DEFW_ROW, /* Weak defined. */
+ COMMON_ROW, /* Common. */
+ INDR_ROW, /* Indirect. */
+ WARN_ROW, /* Warning. */
+ SET_ROW /* Member of set. */
+};
+
+/* apparently needed for Hitachi 3050R(HI-UX/WE2)? */
+#undef FAIL
+
+/* The actions to take in the state table. */
+
+enum link_action
+{
+ FAIL, /* Abort. */
+ UND, /* Mark symbol undefined. */
+ WEAK, /* Mark symbol weak undefined. */
+ DEF, /* Mark symbol defined. */
+ DEFW, /* Mark symbol weak defined. */
+ COM, /* Mark symbol common. */
+ REF, /* Mark defined symbol referenced. */
+ CREF, /* Possibly warn about common reference to defined symbol. */
+ CDEF, /* Define existing common symbol. */
+ NOACT, /* No action. */
+ BIG, /* Mark symbol common using largest size. */
+ MDEF, /* Multiple definition error. */
+ MIND, /* Multiple indirect symbols. */
+ IND, /* Make indirect symbol. */
+ CIND, /* Make indirect symbol from existing common symbol. */
+ SET, /* Add value to set. */
+ MWARN, /* Make warning symbol. */
+ WARN, /* Issue warning. */
+ CWARN, /* Warn if referenced, else MWARN. */
+ CYCLE, /* Repeat with symbol pointed to. */
+ REFC, /* Mark indirect symbol referenced and then CYCLE. */
+ WARNC /* Issue warning and then CYCLE. */
+};
+
+/* The state table itself. The first index is a link_row and the
+ second index is a bfd_link_hash_type. */
+
+static const enum link_action link_action[8][8] =
+{
+ /* current\prev new undef undefw def defw com indr warn */
+ /* UNDEF_ROW */ {UND, NOACT, UND, REF, REF, NOACT, REFC, WARNC },
+ /* UNDEFW_ROW */ {WEAK, NOACT, NOACT, REF, REF, NOACT, REFC, WARNC },
+ /* DEF_ROW */ {DEF, DEF, DEF, MDEF, DEF, CDEF, MDEF, CYCLE },
+ /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE },
+ /* COMMON_ROW */ {COM, COM, COM, CREF, CREF, BIG, REFC, WARNC },
+ /* INDR_ROW */ {IND, IND, IND, MDEF, IND, CIND, MIND, CYCLE },
+ /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, MWARN },
+ /* SET_ROW */ {SET, SET, SET, SET, SET, SET, CYCLE, CYCLE }
+};
+
+/* Most of the entries in the LINK_ACTION table are straightforward,
+ but a few are somewhat subtle.
+
+ A reference to an indirect symbol (UNDEF_ROW/indr or
+ UNDEFW_ROW/indr) is counted as a reference both to the indirect
+ symbol and to the symbol the indirect symbol points to.
+
+ A reference to a warning symbol (UNDEF_ROW/warn or UNDEFW_ROW/warn)
+ causes the warning to be issued.
+
+ A common definition of an indirect symbol (COMMON_ROW/indr) is
+ treated as a multiple definition error. Likewise for an indirect
+ definition of a common symbol (INDR_ROW/com).
+
+ An indirect definition of a warning (INDR_ROW/warn) does not cause
+ the warning to be issued.
+
+ If a warning is created for an indirect symbol (WARN_ROW/indr) no
+ warning is created for the symbol the indirect symbol points to.
+
+ Adding an entry to a set does not count as a reference to a set,
+ and no warning is issued (SET_ROW/warn). */
+
+/* Return the BFD in which a hash entry has been defined, if known. */
+
+static bfd *
+hash_entry_bfd (h)
+ struct bfd_link_hash_entry *h;
+{
+ while (h->type == bfd_link_hash_warning)
+ h = h->u.i.link;
+ switch (h->type)
+ {
+ default:
+ return NULL;
+ case bfd_link_hash_undefined:
+ case bfd_link_hash_undefweak:
+ return h->u.undef.abfd;
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->u.def.section->owner;
+ case bfd_link_hash_common:
+ return h->u.c.p->section->owner;
+ }
+ /*NOTREACHED*/
+}
+
+/* Add a symbol to the global hash table.
+ ABFD is the BFD the symbol comes from.
+ NAME is the name of the symbol.
+ FLAGS is the BSF_* bits associated with the symbol.
+ SECTION is the section in which the symbol is defined; this may be
+ bfd_und_section_ptr or bfd_com_section_ptr.
+ VALUE is the value of the symbol, relative to the section.
+ STRING is used for either an indirect symbol, in which case it is
+ the name of the symbol to indirect to, or a warning symbol, in
+ which case it is the warning string.
+ COPY is true if NAME or STRING must be copied into locally
+ allocated memory if they need to be saved.
+ COLLECT is true if we should automatically collect gcc constructor
+ or destructor names as collect2 does.
+ HASHP, if not NULL, is a place to store the created hash table
+ entry; if *HASHP is not NULL, the caller has already looked up
+ the hash table entry, and stored it in *HASHP. */
+
+boolean
+_bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
+ string, copy, collect, hashp)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ const char *string;
+ boolean copy;
+ boolean collect;
+ struct bfd_link_hash_entry **hashp;
+{
+ enum link_row row;
+ struct bfd_link_hash_entry *h;
+ boolean cycle;
+
+ if (bfd_is_ind_section (section)
+ || (flags & BSF_INDIRECT) != 0)
+ row = INDR_ROW;
+ else if ((flags & BSF_WARNING) != 0)
+ row = WARN_ROW;
+ else if ((flags & BSF_CONSTRUCTOR) != 0)
+ row = SET_ROW;
+ else if (bfd_is_und_section (section))
+ {
+ if ((flags & BSF_WEAK) != 0)
+ row = UNDEFW_ROW;
+ else
+ row = UNDEF_ROW;
+ }
+ else if ((flags & BSF_WEAK) != 0)
+ row = DEFW_ROW;
+ else if (bfd_is_com_section (section))
+ row = COMMON_ROW;
+ else
+ row = DEF_ROW;
+
+ if (hashp != NULL && *hashp != NULL)
+ h = *hashp;
+ else
+ {
+ if (row == UNDEF_ROW || row == UNDEFW_ROW)
+ h = bfd_wrapped_link_hash_lookup (abfd, info, name, true, copy, false);
+ else
+ h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
+ if (h == NULL)
+ {
+ if (hashp != NULL)
+ *hashp = NULL;
+ return false;
+ }
+ }
+
+ if (info->notice_all
+ || (info->notice_hash != (struct bfd_hash_table *) NULL
+ && (bfd_hash_lookup (info->notice_hash, name, false, false)
+ != (struct bfd_hash_entry *) NULL)))
+ {
+ if (! (*info->callbacks->notice) (info, h->root.string, abfd, section,
+ value))
+ return false;
+ }
+
+ if (hashp != (struct bfd_link_hash_entry **) NULL)
+ *hashp = h;
+
+ do
+ {
+ enum link_action action;
+
+ cycle = false;
+ action = link_action[(int) row][(int) h->type];
+ switch (action)
+ {
+ case FAIL:
+ abort ();
+
+ case NOACT:
+ /* Do nothing. */
+ break;
+
+ case UND:
+ /* Make a new undefined symbol. */
+ h->type = bfd_link_hash_undefined;
+ h->u.undef.abfd = abfd;
+ bfd_link_add_undef (info->hash, h);
+ break;
+
+ case WEAK:
+ /* Make a new weak undefined symbol. */
+ h->type = bfd_link_hash_undefweak;
+ h->u.undef.abfd = abfd;
+ break;
+
+ case CDEF:
+ /* We have found a definition for a symbol which was
+ previously common. */
+ BFD_ASSERT (h->type == bfd_link_hash_common);
+ if (! ((*info->callbacks->multiple_common)
+ (info, h->root.string,
+ h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
+ abfd, bfd_link_hash_defined, (bfd_vma) 0)))
+ return false;
+ /* Fall through. */
+ case DEF:
+ case DEFW:
+ {
+ enum bfd_link_hash_type oldtype;
+
+ /* Define a symbol. */
+ oldtype = h->type;
+ if (action == DEFW)
+ h->type = bfd_link_hash_defweak;
+ else
+ h->type = bfd_link_hash_defined;
+ h->u.def.section = section;
+ h->u.def.value = value;
+
+ /* If we have been asked to, we act like collect2 and
+ identify all functions that might be global
+ constructors and destructors and pass them up in a
+ callback. We only do this for certain object file
+ types, since many object file types can handle this
+ automatically. */
+ if (collect && name[0] == '_')
+ {
+ const char *s;
+
+ /* A constructor or destructor name starts like this:
+ _+GLOBAL_[_.$][ID][_.$] where the first [_.$] and
+ the second are the same character (we accept any
+ character there, in case a new object file format
+ comes along with even worse naming restrictions). */
+
+#define CONS_PREFIX "GLOBAL_"
+#define CONS_PREFIX_LEN (sizeof CONS_PREFIX - 1)
+
+ s = name + 1;
+ while (*s == '_')
+ ++s;
+ if (s[0] == 'G'
+ && strncmp (s, CONS_PREFIX, CONS_PREFIX_LEN - 1) == 0)
+ {
+ char c;
+
+ c = s[CONS_PREFIX_LEN + 1];
+ if ((c == 'I' || c == 'D')
+ && s[CONS_PREFIX_LEN] == s[CONS_PREFIX_LEN + 2])
+ {
+ /* If this is a definition of a symbol which
+ was previously weakly defined, we are in
+ trouble. We have already added a
+ constructor entry for the weak defined
+ symbol, and now we are trying to add one
+ for the new symbol. Fortunately, this case
+ should never arise in practice. */
+ if (oldtype == bfd_link_hash_defweak)
+ abort ();
+
+ if (! ((*info->callbacks->constructor)
+ (info,
+ c == 'I' ? true : false,
+ h->root.string, abfd, section, value)))
+ return false;
+ }
+ }
+ }
+ }
+
+ break;
+
+ case COM:
+ /* We have found a common definition for a symbol. */
+ if (h->type == bfd_link_hash_new)
+ bfd_link_add_undef (info->hash, h);
+ h->type = bfd_link_hash_common;
+ h->u.c.p =
+ ((struct bfd_link_hash_common_entry *)
+ bfd_hash_allocate (&info->hash->table,
+ sizeof (struct bfd_link_hash_common_entry)));
+ if (h->u.c.p == NULL)
+ return false;
+
+ h->u.c.size = value;
+
+ /* Select a default alignment based on the size. This may
+ be overridden by the caller. */
+ {
+ unsigned int power;
+
+ power = bfd_log2 (value);
+ if (power > 4)
+ power = 4;
+ h->u.c.p->alignment_power = power;
+ }
+
+ /* The section of a common symbol is only used if the common
+ symbol is actually allocated. It basically provides a
+ hook for the linker script to decide which output section
+ the common symbols should be put in. In most cases, the
+ section of a common symbol will be bfd_com_section_ptr,
+ the code here will choose a common symbol section named
+ "COMMON", and the linker script will contain *(COMMON) in
+ the appropriate place. A few targets use separate common
+ sections for small symbols, and they require special
+ handling. */
+ if (section == bfd_com_section_ptr)
+ {
+ h->u.c.p->section = bfd_make_section_old_way (abfd, "COMMON");
+ h->u.c.p->section->flags = SEC_ALLOC;
+ }
+ else if (section->owner != abfd)
+ {
+ h->u.c.p->section = bfd_make_section_old_way (abfd,
+ section->name);
+ h->u.c.p->section->flags = SEC_ALLOC;
+ }
+ else
+ h->u.c.p->section = section;
+ break;
+
+ case REF:
+ /* A reference to a defined symbol. */
+ if (h->next == NULL && info->hash->undefs_tail != h)
+ h->next = h;
+ break;
+
+ case BIG:
+ /* We have found a common definition for a symbol which
+ already had a common definition. Use the maximum of the
+ two sizes. */
+ BFD_ASSERT (h->type == bfd_link_hash_common);
+ if (! ((*info->callbacks->multiple_common)
+ (info, h->root.string,
+ h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
+ abfd, bfd_link_hash_common, value)))
+ return false;
+ if (value > h->u.c.size)
+ {
+ unsigned int power;
+
+ h->u.c.size = value;
+
+ /* Select a default alignment based on the size. This may
+ be overridden by the caller. */
+ power = bfd_log2 (value);
+ if (power > 4)
+ power = 4;
+ h->u.c.p->alignment_power = power;
+ }
+ break;
+
+ case CREF:
+ {
+ bfd *obfd;
+
+ /* We have found a common definition for a symbol which
+ was already defined. FIXME: It would nice if we could
+ report the BFD which defined an indirect symbol, but we
+ don't have anywhere to store the information. */
+ if (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak)
+ obfd = h->u.def.section->owner;
+ else
+ obfd = NULL;
+ if (! ((*info->callbacks->multiple_common)
+ (info, h->root.string, obfd, h->type, (bfd_vma) 0,
+ abfd, bfd_link_hash_common, value)))
+ return false;
+ }
+ break;
+
+ case MIND:
+ /* Multiple indirect symbols. This is OK if they both point
+ to the same symbol. */
+ if (strcmp (h->u.i.link->root.string, string) == 0)
+ break;
+ /* Fall through. */
+ case MDEF:
+ /* Handle a multiple definition. */
+ {
+ asection *msec;
+ bfd_vma mval;
+
+ switch (h->type)
+ {
+ case bfd_link_hash_defined:
+ msec = h->u.def.section;
+ mval = h->u.def.value;
+ break;
+ case bfd_link_hash_indirect:
+ msec = bfd_ind_section_ptr;
+ mval = 0;
+ break;
+ default:
+ abort ();
+ }
+
+ /* Ignore a redefinition of an absolute symbol to the same
+ value; it's harmless. */
+ if (h->type == bfd_link_hash_defined
+ && bfd_is_abs_section (msec)
+ && bfd_is_abs_section (section)
+ && value == mval)
+ break;
+
+ if (! ((*info->callbacks->multiple_definition)
+ (info, h->root.string, msec->owner, msec, mval, abfd,
+ section, value)))
+ return false;
+ }
+ break;
+
+ case CIND:
+ /* Create an indirect symbol from an existing common symbol. */
+ BFD_ASSERT (h->type == bfd_link_hash_common);
+ if (! ((*info->callbacks->multiple_common)
+ (info, h->root.string,
+ h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
+ abfd, bfd_link_hash_indirect, (bfd_vma) 0)))
+ return false;
+ /* Fall through. */
+ case IND:
+ /* Create an indirect symbol. */
+ {
+ struct bfd_link_hash_entry *inh;
+
+ /* STRING is the name of the symbol we want to indirect
+ to. */
+ inh = bfd_wrapped_link_hash_lookup (abfd, info, string, true,
+ copy, false);
+ if (inh == (struct bfd_link_hash_entry *) NULL)
+ return false;
+ if (inh->type == bfd_link_hash_new)
+ {
+ inh->type = bfd_link_hash_undefined;
+ inh->u.undef.abfd = abfd;
+ bfd_link_add_undef (info->hash, inh);
+ }
+
+ /* If the indirect symbol has been referenced, we need to
+ push the reference down to the symbol we are
+ referencing. */
+ if (h->type != bfd_link_hash_new)
+ {
+ row = UNDEF_ROW;
+ cycle = true;
+ }
+
+ h->type = bfd_link_hash_indirect;
+ h->u.i.link = inh;
+ }
+ break;
+
+ case SET:
+ /* Add an entry to a set. */
+ if (! (*info->callbacks->add_to_set) (info, h, BFD_RELOC_CTOR,
+ abfd, section, value))
+ return false;
+ break;
+
+ case WARNC:
+ /* Issue a warning and cycle. */
+ if (h->u.i.warning != NULL)
+ {
+ if (! (*info->callbacks->warning) (info, h->u.i.warning,
+ h->root.string, abfd,
+ (asection *) NULL,
+ (bfd_vma) 0))
+ return false;
+ /* Only issue a warning once. */
+ h->u.i.warning = NULL;
+ }
+ /* Fall through. */
+ case CYCLE:
+ /* Try again with the referenced symbol. */
+ h = h->u.i.link;
+ cycle = true;
+ break;
+
+ case REFC:
+ /* A reference to an indirect symbol. */
+ if (h->next == NULL && info->hash->undefs_tail != h)
+ h->next = h;
+ h = h->u.i.link;
+ cycle = true;
+ break;
+
+ case WARN:
+ /* Issue a warning. */
+ if (! (*info->callbacks->warning) (info, string, h->root.string,
+ hash_entry_bfd (h),
+ (asection *) NULL, (bfd_vma) 0))
+ return false;
+ break;
+
+ case CWARN:
+ /* Warn if this symbol has been referenced already,
+ otherwise add a warning. A symbol has been referenced if
+ the next field is not NULL, or it is the tail of the
+ undefined symbol list. The REF case above helps to
+ ensure this. */
+ if (h->next != NULL || info->hash->undefs_tail == h)
+ {
+ if (! (*info->callbacks->warning) (info, string, h->root.string,
+ hash_entry_bfd (h),
+ (asection *) NULL,
+ (bfd_vma) 0))
+ return false;
+ break;
+ }
+ /* Fall through. */
+ case MWARN:
+ /* Make a warning symbol. */
+ {
+ struct bfd_link_hash_entry *sub;
+
+ /* STRING is the warning to give. */
+ sub = ((struct bfd_link_hash_entry *)
+ ((*info->hash->table.newfunc)
+ ((struct bfd_hash_entry *) NULL, &info->hash->table,
+ h->root.string)));
+ if (sub == NULL)
+ return false;
+ *sub = *h;
+ sub->type = bfd_link_hash_warning;
+ sub->u.i.link = h;
+ if (! copy)
+ sub->u.i.warning = string;
+ else
+ {
+ char *w;
+
+ w = bfd_hash_allocate (&info->hash->table,
+ strlen (string) + 1);
+ if (w == NULL)
+ return false;
+ strcpy (w, string);
+ sub->u.i.warning = w;
+ }
+
+ bfd_hash_replace (&info->hash->table,
+ (struct bfd_hash_entry *) h,
+ (struct bfd_hash_entry *) sub);
+ if (hashp != NULL)
+ *hashp = sub;
+ }
+ break;
+ }
+ }
+ while (cycle);
+
+ return true;
+}
+
+/* Generic final link routine. */
+
+boolean
+_bfd_generic_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd *sub;
+ asection *o;
+ struct bfd_link_order *p;
+ size_t outsymalloc;
+ struct generic_write_global_symbol_info wginfo;
+
+ bfd_get_outsymbols (abfd) = (asymbol **) NULL;
+ bfd_get_symcount (abfd) = 0;
+ outsymalloc = 0;
+
+ /* Mark all sections which will be included in the output file. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ if (p->type == bfd_indirect_link_order)
+ p->u.indirect.section->linker_mark = true;
+
+ /* Build the output symbol table. */
+ for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
+ if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc))
+ return false;
+
+ /* Accumulate the global symbols. */
+ wginfo.info = info;
+ wginfo.output_bfd = abfd;
+ wginfo.psymalloc = &outsymalloc;
+ _bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info),
+ _bfd_generic_link_write_global_symbol,
+ (PTR) &wginfo);
+
+ /* Make sure we have a trailing NULL pointer on OUTSYMBOLS. We
+ shouldn't really need one, since we have SYMCOUNT, but some old
+ code still expects one. */
+ if (! generic_add_output_symbol (abfd, &outsymalloc, NULL))
+ return false;
+
+ if (info->relocateable)
+ {
+ /* Allocate space for the output relocs for each section. */
+ for (o = abfd->sections;
+ o != (asection *) NULL;
+ o = o->next)
+ {
+ o->reloc_count = 0;
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ ++o->reloc_count;
+ else if (p->type == bfd_indirect_link_order)
+ {
+ asection *input_section;
+ bfd *input_bfd;
+ long relsize;
+ arelent **relocs;
+ asymbol **symbols;
+ long reloc_count;
+
+ input_section = p->u.indirect.section;
+ input_bfd = input_section->owner;
+ relsize = bfd_get_reloc_upper_bound (input_bfd,
+ input_section);
+ if (relsize < 0)
+ return false;
+ relocs = (arelent **) bfd_malloc ((size_t) relsize);
+ if (!relocs && relsize != 0)
+ return false;
+ symbols = _bfd_generic_link_get_symbols (input_bfd);
+ reloc_count = bfd_canonicalize_reloc (input_bfd,
+ input_section,
+ relocs,
+ symbols);
+ if (reloc_count < 0)
+ return false;
+ BFD_ASSERT ((unsigned long) reloc_count
+ == input_section->reloc_count);
+ o->reloc_count += reloc_count;
+ free (relocs);
+ }
+ }
+ if (o->reloc_count > 0)
+ {
+ o->orelocation = ((arelent **)
+ bfd_alloc (abfd,
+ (o->reloc_count
+ * sizeof (arelent *))));
+ if (!o->orelocation)
+ return false;
+ o->flags |= SEC_RELOC;
+ /* Reset the count so that it can be used as an index
+ when putting in the output relocs. */
+ o->reloc_count = 0;
+ }
+ }
+ }
+
+ /* Handle all the link order information for the sections. */
+ for (o = abfd->sections;
+ o != (asection *) NULL;
+ o = o->next)
+ {
+ for (p = o->link_order_head;
+ p != (struct bfd_link_order *) NULL;
+ p = p->next)
+ {
+ switch (p->type)
+ {
+ case bfd_section_reloc_link_order:
+ case bfd_symbol_reloc_link_order:
+ if (! _bfd_generic_reloc_link_order (abfd, info, o, p))
+ return false;
+ break;
+ case bfd_indirect_link_order:
+ if (! default_indirect_link_order (abfd, info, o, p, true))
+ return false;
+ break;
+ default:
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Add an output symbol to the output BFD. */
+
+static boolean
+generic_add_output_symbol (output_bfd, psymalloc, sym)
+ bfd *output_bfd;
+ size_t *psymalloc;
+ asymbol *sym;
+{
+ if (bfd_get_symcount (output_bfd) >= *psymalloc)
+ {
+ asymbol **newsyms;
+
+ if (*psymalloc == 0)
+ *psymalloc = 124;
+ else
+ *psymalloc *= 2;
+ newsyms = (asymbol **) bfd_realloc (bfd_get_outsymbols (output_bfd),
+ *psymalloc * sizeof (asymbol *));
+ if (newsyms == (asymbol **) NULL)
+ return false;
+ bfd_get_outsymbols (output_bfd) = newsyms;
+ }
+
+ bfd_get_outsymbols (output_bfd) [bfd_get_symcount (output_bfd)] = sym;
+ if (sym != NULL)
+ ++ bfd_get_symcount (output_bfd);
+
+ return true;
+}
+
+/* Handle the symbols for an input BFD. */
+
+boolean
+_bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
+ bfd *output_bfd;
+ bfd *input_bfd;
+ struct bfd_link_info *info;
+ size_t *psymalloc;
+{
+ asymbol **sym_ptr;
+ asymbol **sym_end;
+
+ if (! generic_link_read_symbols (input_bfd))
+ return false;
+
+ /* Create a filename symbol if we are supposed to. */
+ if (info->create_object_symbols_section != (asection *) NULL)
+ {
+ asection *sec;
+
+ for (sec = input_bfd->sections;
+ sec != (asection *) NULL;
+ sec = sec->next)
+ {
+ if (sec->output_section == info->create_object_symbols_section)
+ {
+ asymbol *newsym;
+
+ newsym = bfd_make_empty_symbol (input_bfd);
+ if (!newsym)
+ return false;
+ newsym->name = input_bfd->filename;
+ newsym->value = 0;
+ newsym->flags = BSF_LOCAL | BSF_FILE;
+ newsym->section = sec;
+
+ if (! generic_add_output_symbol (output_bfd, psymalloc,
+ newsym))
+ return false;
+
+ break;
+ }
+ }
+ }
+
+ /* Adjust the values of the globally visible symbols, and write out
+ local symbols. */
+ sym_ptr = _bfd_generic_link_get_symbols (input_bfd);
+ sym_end = sym_ptr + _bfd_generic_link_get_symcount (input_bfd);
+ for (; sym_ptr < sym_end; sym_ptr++)
+ {
+ asymbol *sym;
+ struct generic_link_hash_entry *h;
+ boolean output;
+
+ h = (struct generic_link_hash_entry *) NULL;
+ sym = *sym_ptr;
+ if ((sym->flags & (BSF_INDIRECT
+ | BSF_WARNING
+ | BSF_GLOBAL
+ | BSF_CONSTRUCTOR
+ | BSF_WEAK)) != 0
+ || bfd_is_und_section (bfd_get_section (sym))
+ || bfd_is_com_section (bfd_get_section (sym))
+ || bfd_is_ind_section (bfd_get_section (sym)))
+ {
+ if (sym->udata.p != NULL)
+ h = (struct generic_link_hash_entry *) sym->udata.p;
+ else if ((sym->flags & BSF_CONSTRUCTOR) != 0)
+ {
+ /* This case normally means that the main linker code
+ deliberately ignored this constructor symbol. We
+ should just pass it through. This will screw up if
+ the constructor symbol is from a different,
+ non-generic, object file format, but the case will
+ only arise when linking with -r, which will probably
+ fail anyhow, since there will be no way to represent
+ the relocs in the output format being used. */
+ h = NULL;
+ }
+ else if (bfd_is_und_section (bfd_get_section (sym)))
+ h = ((struct generic_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (output_bfd, info,
+ bfd_asymbol_name (sym),
+ false, false, true));
+ else
+ h = _bfd_generic_link_hash_lookup (_bfd_generic_hash_table (info),
+ bfd_asymbol_name (sym),
+ false, false, true);
+
+ if (h != (struct generic_link_hash_entry *) NULL)
+ {
+ /* Force all references to this symbol to point to
+ the same area in memory. It is possible that
+ this routine will be called with a hash table
+ other than a generic hash table, so we double
+ check that. */
+ if (info->hash->creator == input_bfd->xvec)
+ {
+ if (h->sym != (asymbol *) NULL)
+ *sym_ptr = sym = h->sym;
+ }
+
+ switch (h->root.type)
+ {
+ default:
+ case bfd_link_hash_new:
+ abort ();
+ case bfd_link_hash_undefined:
+ break;
+ case bfd_link_hash_undefweak:
+ sym->flags |= BSF_WEAK;
+ break;
+ case bfd_link_hash_indirect:
+ h = (struct generic_link_hash_entry *) h->root.u.i.link;
+ /* fall through */
+ case bfd_link_hash_defined:
+ sym->flags |= BSF_GLOBAL;
+ sym->flags &=~ BSF_CONSTRUCTOR;
+ sym->value = h->root.u.def.value;
+ sym->section = h->root.u.def.section;
+ break;
+ case bfd_link_hash_defweak:
+ sym->flags |= BSF_WEAK;
+ sym->flags &=~ BSF_CONSTRUCTOR;
+ sym->value = h->root.u.def.value;
+ sym->section = h->root.u.def.section;
+ break;
+ case bfd_link_hash_common:
+ sym->value = h->root.u.c.size;
+ sym->flags |= BSF_GLOBAL;
+ if (! bfd_is_com_section (sym->section))
+ {
+ BFD_ASSERT (bfd_is_und_section (sym->section));
+ sym->section = bfd_com_section_ptr;
+ }
+ /* We do not set the section of the symbol to
+ h->root.u.c.p->section. That value was saved so
+ that we would know where to allocate the symbol
+ if it was defined. In this case the type is
+ still bfd_link_hash_common, so we did not define
+ it, so we do not want to use that section. */
+ break;
+ }
+ }
+ }
+
+ /* This switch is straight from the old code in
+ write_file_locals in ldsym.c. */
+ if (info->strip == strip_all
+ || (info->strip == strip_some
+ && (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
+ false, false)
+ == (struct bfd_hash_entry *) NULL)))
+ output = false;
+ else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
+ {
+ /* If this symbol is marked as occurring now, rather
+ than at the end, output it now. This is used for
+ COFF C_EXT FCN symbols. FIXME: There must be a
+ better way. */
+ if (bfd_asymbol_bfd (sym) == input_bfd
+ && (sym->flags & BSF_NOT_AT_END) != 0)
+ output = true;
+ else
+ output = false;
+ }
+ else if (bfd_is_ind_section (sym->section))
+ output = false;
+ else if ((sym->flags & BSF_DEBUGGING) != 0)
+ {
+ if (info->strip == strip_none)
+ output = true;
+ else
+ output = false;
+ }
+ else if (bfd_is_und_section (sym->section)
+ || bfd_is_com_section (sym->section))
+ output = false;
+ else if ((sym->flags & BSF_LOCAL) != 0)
+ {
+ if ((sym->flags & BSF_WARNING) != 0)
+ output = false;
+ else
+ {
+ switch (info->discard)
+ {
+ default:
+ case discard_all:
+ output = false;
+ break;
+ case discard_l:
+ if (bfd_is_local_label (input_bfd, sym))
+ output = false;
+ else
+ output = true;
+ break;
+ case discard_none:
+ output = true;
+ break;
+ }
+ }
+ }
+ else if ((sym->flags & BSF_CONSTRUCTOR))
+ {
+ if (info->strip != strip_all)
+ output = true;
+ else
+ output = false;
+ }
+ else
+ abort ();
+
+ /* If this symbol is in a section which is not being included
+ in the output file, then we don't want to output the symbol.
+
+ Gross. .bss and similar sections won't have the linker_mark
+ field set. */
+ if ((sym->section->flags & SEC_HAS_CONTENTS) != 0
+ && sym->section->linker_mark == false)
+ output = false;
+
+ if (output)
+ {
+ if (! generic_add_output_symbol (output_bfd, psymalloc, sym))
+ return false;
+ if (h != (struct generic_link_hash_entry *) NULL)
+ h->written = true;
+ }
+ }
+
+ return true;
+}
+
+/* Set the section and value of a generic BFD symbol based on a linker
+ hash table entry. */
+
+static void
+set_symbol_from_hash (sym, h)
+ asymbol *sym;
+ struct bfd_link_hash_entry *h;
+{
+ switch (h->type)
+ {
+ default:
+ abort ();
+ break;
+ case bfd_link_hash_new:
+ /* This can happen when a constructor symbol is seen but we are
+ not building constructors. */
+ if (sym->section != NULL)
+ {
+ BFD_ASSERT ((sym->flags & BSF_CONSTRUCTOR) != 0);
+ }
+ else
+ {
+ sym->flags |= BSF_CONSTRUCTOR;
+ sym->section = bfd_abs_section_ptr;
+ sym->value = 0;
+ }
+ break;
+ case bfd_link_hash_undefined:
+ sym->section = bfd_und_section_ptr;
+ sym->value = 0;
+ break;
+ case bfd_link_hash_undefweak:
+ sym->section = bfd_und_section_ptr;
+ sym->value = 0;
+ sym->flags |= BSF_WEAK;
+ break;
+ case bfd_link_hash_defined:
+ sym->section = h->u.def.section;
+ sym->value = h->u.def.value;
+ break;
+ case bfd_link_hash_defweak:
+ sym->flags |= BSF_WEAK;
+ sym->section = h->u.def.section;
+ sym->value = h->u.def.value;
+ break;
+ case bfd_link_hash_common:
+ sym->value = h->u.c.size;
+ if (sym->section == NULL)
+ sym->section = bfd_com_section_ptr;
+ else if (! bfd_is_com_section (sym->section))
+ {
+ BFD_ASSERT (bfd_is_und_section (sym->section));
+ sym->section = bfd_com_section_ptr;
+ }
+ /* Do not set the section; see _bfd_generic_link_output_symbols. */
+ break;
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+ /* FIXME: What should we do here? */
+ break;
+ }
+}
+
+/* Write out a global symbol, if it hasn't already been written out.
+ This is called for each symbol in the hash table. */
+
+boolean
+_bfd_generic_link_write_global_symbol (h, data)
+ struct generic_link_hash_entry *h;
+ PTR data;
+{
+ struct generic_write_global_symbol_info *wginfo =
+ (struct generic_write_global_symbol_info *) data;
+ asymbol *sym;
+
+ if (h->written)
+ return true;
+
+ h->written = true;
+
+ if (wginfo->info->strip == strip_all
+ || (wginfo->info->strip == strip_some
+ && bfd_hash_lookup (wginfo->info->keep_hash, h->root.root.string,
+ false, false) == NULL))
+ return true;
+
+ if (h->sym != (asymbol *) NULL)
+ sym = h->sym;
+ else
+ {
+ sym = bfd_make_empty_symbol (wginfo->output_bfd);
+ if (!sym)
+ return false;
+ sym->name = h->root.root.string;
+ sym->flags = 0;
+ }
+
+ set_symbol_from_hash (sym, &h->root);
+
+ sym->flags |= BSF_GLOBAL;
+
+ if (! generic_add_output_symbol (wginfo->output_bfd, wginfo->psymalloc,
+ sym))
+ {
+ /* FIXME: No way to return failure. */
+ abort ();
+ }
+
+ return true;
+}
+
+/* Create a relocation. */
+
+boolean
+_bfd_generic_reloc_link_order (abfd, info, sec, link_order)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ struct bfd_link_order *link_order;
+{
+ arelent *r;
+
+ if (! info->relocateable)
+ abort ();
+ if (sec->orelocation == (arelent **) NULL)
+ abort ();
+
+ r = (arelent *) bfd_alloc (abfd, sizeof (arelent));
+ if (r == (arelent *) NULL)
+ return false;
+
+ r->address = link_order->offset;
+ r->howto = bfd_reloc_type_lookup (abfd, link_order->u.reloc.p->reloc);
+ if (r->howto == 0)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ /* Get the symbol to use for the relocation. */
+ if (link_order->type == bfd_section_reloc_link_order)
+ r->sym_ptr_ptr = link_order->u.reloc.p->u.section->symbol_ptr_ptr;
+ else
+ {
+ struct generic_link_hash_entry *h;
+
+ h = ((struct generic_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (abfd, info,
+ link_order->u.reloc.p->u.name,
+ false, false, true));
+ if (h == (struct generic_link_hash_entry *) NULL
+ || ! h->written)
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, link_order->u.reloc.p->u.name,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
+ return false;
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ r->sym_ptr_ptr = &h->sym;
+ }
+
+ /* If this is an inplace reloc, write the addend to the object file.
+ Otherwise, store it in the reloc addend. */
+ if (! r->howto->partial_inplace)
+ r->addend = link_order->u.reloc.p->addend;
+ else
+ {
+ bfd_size_type size;
+ bfd_reloc_status_type rstat;
+ bfd_byte *buf;
+ boolean ok;
+
+ size = bfd_get_reloc_size (r->howto);
+ buf = (bfd_byte *) bfd_zmalloc (size);
+ if (buf == (bfd_byte *) NULL)
+ return false;
+ rstat = _bfd_relocate_contents (r->howto, abfd,
+ link_order->u.reloc.p->addend, buf);
+ switch (rstat)
+ {
+ case bfd_reloc_ok:
+ break;
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ if (! ((*info->callbacks->reloc_overflow)
+ (info,
+ (link_order->type == bfd_section_reloc_link_order
+ ? bfd_section_name (abfd, link_order->u.reloc.p->u.section)
+ : link_order->u.reloc.p->u.name),
+ r->howto->name, link_order->u.reloc.p->addend,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
+ {
+ free (buf);
+ return false;
+ }
+ break;
+ }
+ ok = bfd_set_section_contents (abfd, sec, (PTR) buf,
+ (file_ptr) link_order->offset, size);
+ free (buf);
+ if (! ok)
+ return false;
+
+ r->addend = 0;
+ }
+
+ sec->orelocation[sec->reloc_count] = r;
+ ++sec->reloc_count;
+
+ return true;
+}
+
+/* Allocate a new link_order for a section. */
+
+struct bfd_link_order *
+bfd_new_link_order (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ struct bfd_link_order *new;
+
+ new = ((struct bfd_link_order *)
+ bfd_alloc (abfd, sizeof (struct bfd_link_order)));
+ if (!new)
+ return NULL;
+
+ new->type = bfd_undefined_link_order;
+ new->offset = 0;
+ new->size = 0;
+ new->next = (struct bfd_link_order *) NULL;
+
+ if (section->link_order_tail != (struct bfd_link_order *) NULL)
+ section->link_order_tail->next = new;
+ else
+ section->link_order_head = new;
+ section->link_order_tail = new;
+
+ return new;
+}
+
+/* Default link order processing routine. Note that we can not handle
+ the reloc_link_order types here, since they depend upon the details
+ of how the particular backends generates relocs. */
+
+boolean
+_bfd_default_link_order (abfd, info, sec, link_order)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ struct bfd_link_order *link_order;
+{
+ switch (link_order->type)
+ {
+ case bfd_undefined_link_order:
+ case bfd_section_reloc_link_order:
+ case bfd_symbol_reloc_link_order:
+ default:
+ abort ();
+ case bfd_indirect_link_order:
+ return default_indirect_link_order (abfd, info, sec, link_order,
+ false);
+ case bfd_fill_link_order:
+ return default_fill_link_order (abfd, info, sec, link_order);
+ case bfd_data_link_order:
+ return bfd_set_section_contents (abfd, sec,
+ (PTR) link_order->u.data.contents,
+ (file_ptr) link_order->offset,
+ link_order->size);
+ }
+}
+
+/* Default routine to handle a bfd_fill_link_order. */
+
+/*ARGSUSED*/
+static boolean
+default_fill_link_order (abfd, info, sec, link_order)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ struct bfd_link_order *link_order;
+{
+ size_t size;
+ char *space;
+ size_t i;
+ int fill;
+ boolean result;
+
+ BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
+
+ size = (size_t) link_order->size;
+ space = (char *) bfd_malloc (size);
+ if (space == NULL && size != 0)
+ return false;
+
+ fill = link_order->u.fill.value;
+ for (i = 0; i < size; i += 2)
+ space[i] = fill >> 8;
+ for (i = 1; i < size; i += 2)
+ space[i] = fill;
+ result = bfd_set_section_contents (abfd, sec, space,
+ (file_ptr) link_order->offset,
+ link_order->size);
+ free (space);
+ return result;
+}
+
+/* Default routine to handle a bfd_indirect_link_order. */
+
+static boolean
+default_indirect_link_order (output_bfd, info, output_section, link_order,
+ generic_linker)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ asection *output_section;
+ struct bfd_link_order *link_order;
+ boolean generic_linker;
+{
+ asection *input_section;
+ bfd *input_bfd;
+ bfd_byte *contents = NULL;
+ bfd_byte *new_contents;
+
+ BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
+
+ if (link_order->size == 0)
+ return true;
+
+ input_section = link_order->u.indirect.section;
+ input_bfd = input_section->owner;
+
+ BFD_ASSERT (input_section->output_section == output_section);
+ BFD_ASSERT (input_section->output_offset == link_order->offset);
+ BFD_ASSERT (input_section->_cooked_size == link_order->size);
+
+ if (info->relocateable
+ && input_section->reloc_count > 0
+ && output_section->orelocation == (arelent **) NULL)
+ {
+ /* Space has not been allocated for the output relocations.
+ This can happen when we are called by a specific backend
+ because somebody is attempting to link together different
+ types of object files. Handling this case correctly is
+ difficult, and sometimes impossible. */
+ (*_bfd_error_handler)
+ (_("Attempt to do relocateable link with %s input and %s output"),
+ bfd_get_target (input_bfd), bfd_get_target (output_bfd));
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ if (! generic_linker)
+ {
+ asymbol **sympp;
+ asymbol **symppend;
+
+ /* Get the canonical symbols. The generic linker will always
+ have retrieved them by this point, but we are being called by
+ a specific linker, presumably because we are linking
+ different types of object files together. */
+ if (! generic_link_read_symbols (input_bfd))
+ return false;
+
+ /* Since we have been called by a specific linker, rather than
+ the generic linker, the values of the symbols will not be
+ right. They will be the values as seen in the input file,
+ not the values of the final link. We need to fix them up
+ before we can relocate the section. */
+ sympp = _bfd_generic_link_get_symbols (input_bfd);
+ symppend = sympp + _bfd_generic_link_get_symcount (input_bfd);
+ for (; sympp < symppend; sympp++)
+ {
+ asymbol *sym;
+ struct bfd_link_hash_entry *h;
+
+ sym = *sympp;
+
+ if ((sym->flags & (BSF_INDIRECT
+ | BSF_WARNING
+ | BSF_GLOBAL
+ | BSF_CONSTRUCTOR
+ | BSF_WEAK)) != 0
+ || bfd_is_und_section (bfd_get_section (sym))
+ || bfd_is_com_section (bfd_get_section (sym))
+ || bfd_is_ind_section (bfd_get_section (sym)))
+ {
+ /* sym->udata may have been set by
+ generic_link_add_symbol_list. */
+ if (sym->udata.p != NULL)
+ h = (struct bfd_link_hash_entry *) sym->udata.p;
+ else if (bfd_is_und_section (bfd_get_section (sym)))
+ h = bfd_wrapped_link_hash_lookup (output_bfd, info,
+ bfd_asymbol_name (sym),
+ false, false, true);
+ else
+ h = bfd_link_hash_lookup (info->hash,
+ bfd_asymbol_name (sym),
+ false, false, true);
+ if (h != NULL)
+ set_symbol_from_hash (sym, h);
+ }
+ }
+ }
+
+ /* Get and relocate the section contents. */
+ contents = ((bfd_byte *)
+ bfd_malloc (bfd_section_size (input_bfd, input_section)));
+ if (contents == NULL && bfd_section_size (input_bfd, input_section) != 0)
+ goto error_return;
+ new_contents = (bfd_get_relocated_section_contents
+ (output_bfd, info, link_order, contents, info->relocateable,
+ _bfd_generic_link_get_symbols (input_bfd)));
+ if (!new_contents)
+ goto error_return;
+
+ /* Output the section contents. */
+ if (! bfd_set_section_contents (output_bfd, output_section,
+ (PTR) new_contents,
+ link_order->offset, link_order->size))
+ goto error_return;
+
+ if (contents != NULL)
+ free (contents);
+ return true;
+
+ error_return:
+ if (contents != NULL)
+ free (contents);
+ return false;
+}
+
+/* A little routine to count the number of relocs in a link_order
+ list. */
+
+unsigned int
+_bfd_count_link_order_relocs (link_order)
+ struct bfd_link_order *link_order;
+{
+ register unsigned int c;
+ register struct bfd_link_order *l;
+
+ c = 0;
+ for (l = link_order; l != (struct bfd_link_order *) NULL; l = l->next)
+ {
+ if (l->type == bfd_section_reloc_link_order
+ || l->type == bfd_symbol_reloc_link_order)
+ ++c;
+ }
+
+ return c;
+}
+
+/*
+FUNCTION
+ bfd_link_split_section
+
+SYNOPSIS
+ boolean bfd_link_split_section(bfd *abfd, asection *sec);
+
+DESCRIPTION
+ Return nonzero if @var{sec} should be split during a
+ reloceatable or final link.
+
+.#define bfd_link_split_section(abfd, sec) \
+. BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
+.
+
+*/
+
+
+
+boolean
+_bfd_generic_link_split_section (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ return false;
+}
diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c
new file mode 100644
index 00000000000..2358177dbc6
--- /dev/null
+++ b/bfd/lynx-core.c
@@ -0,0 +1,233 @@
+/* BFD back end for Lynx core files
+ Copyright 1993 Free Software Foundation, Inc.
+ Written by Stu Grossman of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#ifdef LYNX_CORE
+
+#include <sys/conf.h>
+#include <sys/kernel.h>
+/* sys/kernel.h should define this, but doesn't always, sigh. */
+#ifndef __LYNXOS
+#define __LYNXOS
+#endif
+#include <sys/mem.h>
+#include <sys/signal.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/itimer.h>
+#include <sys/file.h>
+#include <sys/proc.h>
+
+/* These are stored in the bfd's tdata */
+
+struct lynx_core_struct
+{
+ int sig;
+ char cmd[PNMLEN + 1];
+};
+
+#define core_hdr(bfd) ((bfd)->tdata.lynx_core_data)
+#define core_signal(bfd) (core_hdr(bfd)->sig)
+#define core_command(bfd) (core_hdr(bfd)->cmd)
+
+/* Handle Lynx core dump file. */
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
+ bfd *abfd;
+ CONST char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ bfd_vma vma;
+ file_ptr filepos;
+{
+ asection *asect;
+ char *newname;
+
+ newname = bfd_alloc (abfd, strlen (name) + 1);
+ if (!newname)
+ return NULL;
+
+ strcpy (newname, name);
+
+ asect = bfd_make_section (abfd, newname);
+ if (!asect)
+ return NULL;
+
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->vma = vma;
+ asect->filepos = filepos;
+ asect->alignment_power = 2;
+
+ return asect;
+}
+
+/* ARGSUSED */
+const bfd_target *
+lynx_core_file_p (abfd)
+ bfd *abfd;
+{
+ int val;
+ int secnum;
+ struct pssentry pss;
+ size_t tcontext_size;
+ core_st_t *threadp;
+ int pagesize;
+ asection *newsect;
+
+ pagesize = getpagesize (); /* Serious cross-target issue here... This
+ really needs to come from a system-specific
+ header file. */
+
+ /* Get the pss entry from the core file */
+
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ return NULL;
+
+ val = bfd_read ((void *)&pss, 1, sizeof pss, abfd);
+ if (val != sizeof pss)
+ {
+ /* Too small to be a core file */
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ core_hdr (abfd) = (struct lynx_core_struct *)
+ bfd_zalloc (abfd, sizeof (struct lynx_core_struct));
+
+ if (!core_hdr (abfd))
+ return NULL;
+
+ strncpy (core_command (abfd), pss.pname, PNMLEN + 1);
+
+ /* Compute the size of the thread contexts */
+
+ tcontext_size = pss.threadcnt * sizeof (core_st_t);
+
+ /* Allocate space for the thread contexts */
+
+ threadp = (core_st_t *)bfd_alloc (abfd, tcontext_size);
+ if (!threadp)
+ return NULL;
+
+ /* Save thread contexts */
+
+ if (bfd_seek (abfd, pagesize, SEEK_SET) != 0)
+ return NULL;
+
+ val = bfd_read ((void *)threadp, pss.threadcnt, sizeof (core_st_t), abfd);
+
+ if (val != tcontext_size)
+ {
+ /* Probably too small to be a core file */
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ core_signal (abfd) = threadp->currsig;
+
+ newsect = make_bfd_asection (abfd, ".stack",
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
+ pss.ssize,
+ pss.slimit,
+ pagesize + tcontext_size);
+ if (!newsect)
+ return NULL;
+
+ newsect = make_bfd_asection (abfd, ".data",
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
+ pss.data_len + pss.bss_len,
+ pss.data_start,
+ pagesize + tcontext_size + pss.ssize
+#if defined (SPARC) || defined (__SPARC__)
+ /* SPARC Lynx seems to start dumping
+ the .data section at a page
+ boundary. It's OK to check a
+ #define like SPARC here because this
+ file can only be compiled on a Lynx
+ host. */
+ + pss.data_start % pagesize
+#endif
+ );
+ if (!newsect)
+ return NULL;
+
+/* And, now for the .reg/XXX pseudo sections. Each thread has it's own
+ .reg/XXX section, where XXX is the thread id (without leading zeros). The
+ currently running thread (at the time of the core dump) also has an alias
+ called `.reg' (just to keep GDB happy). Note that we use `.reg/XXX' as
+ opposed to `.regXXX' because GDB expects that .reg2 will be the floating-
+ point registers. */
+
+ newsect = make_bfd_asection (abfd, ".reg",
+ SEC_HAS_CONTENTS,
+ sizeof (core_st_t),
+ 0,
+ pagesize);
+ if (!newsect)
+ return NULL;
+
+ for (secnum = 0; secnum < pss.threadcnt; secnum++)
+ {
+ char secname[100];
+
+ sprintf (secname, ".reg/%d", BUILDPID (0, threadp[secnum].tid));
+ newsect = make_bfd_asection (abfd, secname,
+ SEC_HAS_CONTENTS,
+ sizeof (core_st_t),
+ 0,
+ pagesize + secnum * sizeof (core_st_t));
+ if (!newsect)
+ return NULL;
+ }
+
+ return abfd->xvec;
+}
+
+char *
+lynx_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_command (abfd);
+}
+
+/* ARGSUSED */
+int
+lynx_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_signal (abfd);
+}
+
+/* ARGSUSED */
+boolean
+lynx_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this point */
+}
+
+#endif /* LYNX_CORE */
diff --git a/bfd/m68k4knetbsd.c b/bfd/m68k4knetbsd.c
new file mode 100644
index 00000000000..943438d2dda
--- /dev/null
+++ b/bfd/m68k4knetbsd.c
@@ -0,0 +1,32 @@
+/* BFD back-end for NetBSD/m68k a.out-ish binaries.
+ Copyright (C) 1990, 91, 92, 95, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#define TARGET_IS_BIG_ENDIAN_P
+
+#define TARGET_PAGE_SIZE 0x1000
+
+#define DEFAULT_ARCH bfd_arch_m68k
+#define DEFAULT_MID M_68K4K_NETBSD
+
+#define MY(OP) CAT(m68k4knetbsd_,OP)
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-m68k4k-netbsd"
+
+#include "netbsd.h"
diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c
new file mode 100644
index 00000000000..c8f47a89fb0
--- /dev/null
+++ b/bfd/m68klinux.c
@@ -0,0 +1,772 @@
+/* BFD back-end for linux flavored m68k a.out binaries.
+ Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_PAGE_SIZE 4096
+#define ZMAGIC_DISK_BLOCK_SIZE 1024
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define TEXT_START_ADDR 0x0
+#define N_SHARED_LIB(x) 0
+#define BYTES_IN_WORD 4
+
+#define MACHTYPE_OK(mtype) ((mtype) == M_68020 || (mtype) == M_UNKNOWN)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#define TARGET_IS_BIG_ENDIAN_P
+#define DEFAULT_ARCH bfd_arch_m68k
+#define MY(OP) CAT(m68klinux_,OP)
+#define TARGETNAME "a.out-m68k-linux"
+
+extern const bfd_target MY(vec);
+
+/* We always generate QMAGIC files in preference to ZMAGIC files. It
+ would be possible to make this a linker option, if that ever
+ becomes important. */
+
+static void MY_final_link_callback
+ PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+static boolean m68klinux_bfd_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean m68klinux_write_object_contents PARAMS ((bfd *));
+
+static boolean
+m68klinux_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ obj_aout_subformat (abfd) = q_magic_format;
+ return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
+}
+
+#define MY_bfd_final_link m68klinux_bfd_final_link
+
+/* Set the machine type correctly. */
+
+static boolean
+m68klinux_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ N_SET_MACHTYPE (*execp, M_68020);
+
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
+
+#define MY_write_object_contents m68klinux_write_object_contents
+
+/* Code to link against Linux a.out shared libraries. */
+
+/* See if a symbol name is a reference to the global offset table. */
+
+#ifndef GOT_REF_PREFIX
+#define GOT_REF_PREFIX "__GOT_"
+#endif
+
+#define IS_GOT_SYM(name) \
+ (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
+
+/* See if a symbol name is a reference to the procedure linkage table. */
+
+#ifndef PLT_REF_PREFIX
+#define PLT_REF_PREFIX "__PLT_"
+#endif
+
+#define IS_PLT_SYM(name) \
+ (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
+
+/* This string is used to generate specialized error messages. */
+
+#ifndef NEEDS_SHRLIB
+#define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
+#endif
+
+/* This special symbol is a set vector that contains a list of
+ pointers to fixup tables. It will be present in any dynamicly
+ linked file. The linker generated fixup table should also be added
+ to the list, and it should always appear in the second slot (the
+ first one is a dummy with a magic number that is defined in
+ crt0.o). */
+
+#ifndef SHARABLE_CONFLICTS
+#define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
+#endif
+
+/* We keep a list of fixups. The terminology is a bit strange, but
+ each fixup contains two 32 bit numbers. A regular fixup contains
+ an address and a pointer, and at runtime we should store the
+ address at the location pointed to by the pointer. A builtin fixup
+ contains two pointers, and we should read the address using one
+ pointer and store it at the location pointed to by the other
+ pointer. Builtin fixups come into play when we have duplicate
+ __GOT__ symbols for the same variable. The builtin fixup will copy
+ the GOT pointer from one over into the other. */
+
+struct fixup
+{
+ struct fixup *next;
+ struct linux_link_hash_entry *h;
+ bfd_vma value;
+
+ /* Nonzero if this is a jump instruction that needs to be fixed,
+ zero if this is just a pointer */
+ char jump;
+
+ char builtin;
+};
+
+/* We don't need a special hash table entry structure, but we do need
+ to keep some information between linker passes, so we use a special
+ hash table. */
+
+struct linux_link_hash_entry
+{
+ struct aout_link_hash_entry root;
+};
+
+struct linux_link_hash_table
+{
+ struct aout_link_hash_table root;
+
+ /* First dynamic object found in link. */
+ bfd *dynobj;
+
+ /* Number of fixups. */
+ size_t fixup_count;
+
+ /* Number of builtin fixups. */
+ size_t local_builtins;
+
+ /* List of fixups. */
+ struct fixup *fixup_list;
+};
+
+static struct bfd_hash_entry *linux_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *linux_link_hash_table_create
+ PARAMS ((bfd *));
+static struct fixup *new_fixup
+ PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
+ bfd_vma, int));
+static boolean linux_link_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean linux_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
+ bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
+static boolean linux_tally_symbols
+ PARAMS ((struct linux_link_hash_entry *, PTR));
+static boolean linux_finish_dynamic_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Routine to create an entry in an Linux link hash table. */
+
+static struct bfd_hash_entry *
+linux_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct linux_link_hash_entry *) NULL)
+ ret = ((struct linux_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
+ if (ret == NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct linux_link_hash_entry *)
+ NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != NULL)
+ {
+ /* Set local fields; there aren't any. */
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a Linux link hash table. */
+
+static struct bfd_link_hash_table *
+linux_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct linux_link_hash_table *ret;
+
+ ret = ((struct linux_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
+ if (ret == (struct linux_link_hash_table *) NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+ if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
+ linux_link_hash_newfunc))
+ {
+ free (ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->dynobj = NULL;
+ ret->fixup_count = 0;
+ ret->local_builtins = 0;
+ ret->fixup_list = NULL;
+
+ return &ret->root.root;
+}
+
+/* Look up an entry in a Linux link hash table. */
+
+#define linux_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct linux_link_hash_entry *) \
+ aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
+ (follow)))
+
+/* Traverse a Linux link hash table. */
+
+#define linux_link_hash_traverse(table, func, info) \
+ (aout_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the Linux link hash table from the info structure. This is
+ just a cast. */
+
+#define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
+
+/* Store the information for a new fixup. */
+
+static struct fixup *
+new_fixup (info, h, value, builtin)
+ struct bfd_link_info *info;
+ struct linux_link_hash_entry *h;
+ bfd_vma value;
+ int builtin;
+{
+ struct fixup *f;
+
+ f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
+ sizeof (struct fixup));
+ if (f == NULL)
+ return f;
+ f->next = linux_hash_table (info)->fixup_list;
+ linux_hash_table (info)->fixup_list = f;
+ f->h = h;
+ f->value = value;
+ f->builtin = builtin;
+ f->jump = 0;
+ ++linux_hash_table (info)->fixup_count;
+ return f;
+}
+
+/* We come here once we realize that we are going to link to a shared
+ library. We need to create a special section that contains the
+ fixup table, and we ultimately need to add a pointer to this into
+ the set vector for SHARABLE_CONFLICTS. At this point we do not
+ know the size of the section, but that's OK - we just need to
+ create it for now. */
+
+static boolean
+linux_link_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+
+ /* Note that we set the SEC_IN_MEMORY flag. */
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ /* We choose to use the name ".linux-dynamic" for the fixup table.
+ Why not? */
+ s = bfd_make_section (abfd, ".linux-dynamic");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+ s->_raw_size = 0;
+ s->contents = 0;
+
+ return true;
+}
+
+/* Function to add a single symbol to the linker hash table. This is
+ a wrapper around _bfd_generic_link_add_one_symbol which handles the
+ tweaking needed for dynamic linking support. */
+
+static boolean
+linux_add_one_symbol (info, abfd, name, flags, section, value, string,
+ copy, collect, hashp)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ const char *string;
+ boolean copy;
+ boolean collect;
+ struct bfd_link_hash_entry **hashp;
+{
+ struct linux_link_hash_entry *h;
+ boolean insert;
+
+ /* Look up and see if we already have this symbol in the hash table.
+ If we do, and the defining entry is from a shared library, we
+ need to create the dynamic sections.
+
+ FIXME: What if abfd->xvec != info->hash->creator? We may want to
+ be able to link Linux a.out and ELF objects together, but serious
+ confusion is possible. */
+
+ insert = false;
+
+ if (! info->relocateable
+ && linux_hash_table (info)->dynobj == NULL
+ && strcmp (name, SHARABLE_CONFLICTS) == 0
+ && (flags & BSF_CONSTRUCTOR) != 0
+ && abfd->xvec == info->hash->creator)
+ {
+ if (! linux_link_create_dynamic_sections (abfd, info))
+ return false;
+ linux_hash_table (info)->dynobj = abfd;
+ insert = true;
+ }
+
+ if (bfd_is_abs_section (section)
+ && abfd->xvec == info->hash->creator)
+ {
+ h = linux_link_hash_lookup (linux_hash_table (info), name, false,
+ false, false);
+ if (h != NULL
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak))
+ {
+ struct fixup *f;
+
+ if (hashp != NULL)
+ *hashp = (struct bfd_link_hash_entry *) h;
+
+ f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
+ if (f == NULL)
+ return false;
+ f->jump = IS_PLT_SYM (name);
+
+ return true;
+ }
+ }
+
+ /* Do the usual procedure for adding a symbol. */
+ if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
+ value, string, copy, collect,
+ hashp))
+ return false;
+
+ /* Insert a pointer to our table in the set vector. The dynamic
+ linker requires this information */
+ if (insert)
+ {
+ asection *s;
+
+ /* Here we do our special thing to add the pointer to the
+ dynamic section in the SHARABLE_CONFLICTS set vector. */
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ BFD_ASSERT (s != NULL);
+
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
+ BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
+ return false;
+ }
+
+ return true;
+}
+
+/* We will crawl the hash table and come here for every global symbol.
+ We will examine each entry and see if there are indications that we
+ need to add a fixup. There are two possible cases - one is where
+ you have duplicate definitions of PLT or GOT symbols - these will
+ have already been caught and added as "builtin" fixups. If we find
+ that the corresponding non PLT/GOT symbol is also present, we
+ convert it to a regular fixup instead.
+
+ This function is called via linux_link_hash_traverse. */
+
+static boolean
+linux_tally_symbols (h, data)
+ struct linux_link_hash_entry *h;
+ PTR data;
+{
+ struct bfd_link_info *info = (struct bfd_link_info *) data;
+ struct fixup *f, *f1;
+ int is_plt;
+ struct linux_link_hash_entry *h1, *h2;
+ boolean exists;
+
+ if (h->root.root.type == bfd_link_hash_undefined
+ && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
+ sizeof NEEDS_SHRLIB - 1) == 0)
+ {
+ const char *name;
+ char *p;
+ char *alloc = NULL;
+
+ name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
+ p = strrchr (name, '_');
+ if (p != NULL)
+ alloc = (char *) bfd_malloc (strlen (name) + 1);
+
+ if (p == NULL || alloc == NULL)
+ (*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
+ name);
+ else
+ {
+ strcpy (alloc, name);
+ p = strrchr (alloc, '_');
+ *p++ = '\0';
+ (*_bfd_error_handler)
+ (_("Output file requires shared library `%s.so.%s'\n"),
+ alloc, p);
+ free (alloc);
+ }
+
+ abort ();
+ }
+
+ /* If this symbol is not a PLT/GOT, we do not even need to look at it */
+ is_plt = IS_PLT_SYM (h->root.root.root.string);
+
+ if (is_plt || IS_GOT_SYM (h->root.root.root.string))
+ {
+ /* Look up this symbol twice. Once just as a regular lookup,
+ and then again following all of the indirect links until we
+ reach a real symbol. */
+ h1 = linux_link_hash_lookup (linux_hash_table (info),
+ (h->root.root.root.string
+ + sizeof PLT_REF_PREFIX - 1),
+ false, false, true);
+ /* h2 does not follow indirect symbols. */
+ h2 = linux_link_hash_lookup (linux_hash_table (info),
+ (h->root.root.root.string
+ + sizeof PLT_REF_PREFIX - 1),
+ false, false, false);
+
+ /* The real symbol must exist but if it is also an ABS symbol,
+ there is no need to have a fixup. This is because they both
+ came from the same library. If on the other hand, we had to
+ use an indirect symbol to get to the real symbol, we add the
+ fixup anyway, since there are cases where these symbols come
+ from different shared libraries */
+ if (h1 != NULL
+ && (((h1->root.root.type == bfd_link_hash_defined
+ || h1->root.root.type == bfd_link_hash_defweak)
+ && ! bfd_is_abs_section (h1->root.root.u.def.section))
+ || h2->root.root.type == bfd_link_hash_indirect))
+ {
+ /* See if there is a "builtin" fixup already present
+ involving this symbol. If so, convert it to a regular
+ fixup. In the end, this relaxes some of the requirements
+ about the order of performing fixups. */
+ exists = false;
+ for (f1 = linux_hash_table (info)->fixup_list;
+ f1 != NULL;
+ f1 = f1->next)
+ {
+ if ((f1->h != h && f1->h != h1)
+ || (! f1->builtin && ! f1->jump))
+ continue;
+ if (f1->h == h1)
+ exists = true;
+ if (! exists
+ && bfd_is_abs_section (h->root.root.u.def.section))
+ {
+ f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
+ f->jump = is_plt;
+ }
+ f1->h = h1;
+ f1->jump = is_plt;
+ f1->builtin = 0;
+ exists = true;
+ }
+ if (! exists
+ && bfd_is_abs_section (h->root.root.u.def.section))
+ {
+ f = new_fixup (info, h1, h->root.root.u.def.value, 0);
+ if (f == NULL)
+ {
+ /* FIXME: No way to return error. */
+ abort ();
+ }
+ f->jump = is_plt;
+ }
+ }
+
+ /* Quick and dirty way of stripping these symbols from the
+ symtab. */
+ if (bfd_is_abs_section (h->root.root.u.def.section))
+ h->root.written = true;
+ }
+
+ return true;
+}
+
+/* This is called to set the size of the .linux-dynamic section is.
+ It is called by the Linux linker emulation before_allocation
+ routine. We have finished reading all of the input files, and now
+ we just scan the hash tables to find out how many additional fixups
+ are required. */
+
+boolean
+bfd_m68klinux_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ struct fixup *f;
+ asection *s;
+
+ if (output_bfd->xvec != &MY(vec))
+ return true;
+
+ /* First find the fixups... */
+ linux_link_hash_traverse (linux_hash_table (info),
+ linux_tally_symbols,
+ (PTR) info);
+
+ /* If there are builtin fixups, leave room for a marker. This is
+ used by the dynamic linker so that it knows that all that follow
+ are builtin fixups instead of regular fixups. */
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (f->builtin)
+ {
+ ++linux_hash_table (info)->fixup_count;
+ ++linux_hash_table (info)->local_builtins;
+ break;
+ }
+ }
+
+ if (linux_hash_table (info)->dynobj == NULL)
+ {
+ if (linux_hash_table (info)->fixup_count > 0)
+ abort ();
+ return true;
+ }
+
+ /* Allocate memory for our fixup table. We will fill it in later. */
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ if (s != NULL)
+ {
+ s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ memset (s->contents, 0, (size_t) s->_raw_size);
+ }
+
+ return true;
+}
+
+/* We come here once we are ready to actually write the fixup table to
+ the output file. Scan the fixup tables and so forth and generate
+ the stuff we need. */
+
+static boolean
+linux_finish_dynamic_link (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ asection *s, *os, *is;
+ bfd_byte *fixup_table;
+ struct linux_link_hash_entry *h;
+ struct fixup *f;
+ unsigned int new_addr;
+ int section_offset;
+ unsigned int fixups_written;
+
+ if (linux_hash_table (info)->dynobj == NULL)
+ return true;
+
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ BFD_ASSERT (s != NULL);
+ os = s->output_section;
+ fixups_written = 0;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup table file offset: %x VMA: %x\n",
+ os->filepos + s->output_offset,
+ os->vma + s->output_offset);
+#endif
+
+ fixup_table = s->contents;
+ bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
+ fixup_table += 4;
+
+ /* Fill in fixup table. */
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (f->builtin)
+ continue;
+
+ if (f->h->root.root.type != bfd_link_hash_defined
+ && f->h->root.root.type != bfd_link_hash_defweak)
+ {
+ (*_bfd_error_handler)
+ (_("Symbol %s not defined for fixups\n"),
+ f->h->root.root.root.string);
+ continue;
+ }
+
+ is = f->h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = f->h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
+ new_addr, f->value);
+#endif
+
+ if (f->jump)
+ {
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value + 2, fixup_table);
+ fixup_table += 4;
+ }
+ else
+ {
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value, fixup_table);
+ fixup_table += 4;
+ }
+ ++fixups_written;
+ }
+
+ if (linux_hash_table (info)->local_builtins != 0)
+ {
+ /* Special marker so we know to switch to the other type of fixup */
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (! f->builtin)
+ continue;
+
+ if (f->h->root.root.type != bfd_link_hash_defined
+ && f->h->root.root.type != bfd_link_hash_defweak)
+ {
+ (*_bfd_error_handler)
+ (_("Symbol %s not defined for fixups\n"),
+ f->h->root.root.root.string);
+ continue;
+ }
+
+ is = f->h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = f->h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
+ new_addr, f->value);
+#endif
+
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ }
+ }
+
+ if (linux_hash_table (info)->fixup_count != fixups_written)
+ {
+ (*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
+ while (linux_hash_table (info)->fixup_count > fixups_written)
+ {
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ }
+ }
+
+ h = linux_link_hash_lookup (linux_hash_table (info),
+ "__BUILTIN_FIXUPS__",
+ false, false, false);
+
+ if (h != NULL
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak))
+ {
+ is = h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Builtin fixup table at %x\n", new_addr);
+#endif
+
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ }
+ else
+ bfd_put_32 (output_bfd, 0, fixup_table);
+
+ if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
+ return false;
+
+ if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
+ != s->_raw_size)
+ return false;
+
+ return true;
+}
+
+#define MY_bfd_link_hash_table_create linux_link_hash_table_create
+#define MY_add_one_symbol linux_add_one_symbol
+#define MY_finish_dynamic_link linux_finish_dynamic_link
+
+#define MY_zmagic_contiguous 1
+
+#include "aout-target.h"
diff --git a/bfd/m68klynx.c b/bfd/m68klynx.c
new file mode 100644
index 00000000000..7acdfbcad21
--- /dev/null
+++ b/bfd/m68klynx.c
@@ -0,0 +1,54 @@
+/* BFD back-end for m68k binaries under LynxOS.
+ Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#define N_SHARED_LIB(x) 0
+
+#define TEXT_START_ADDR 0
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_m68k
+
+#define MY(OP) CAT(m68klynx_aout_,OP)
+#define TARGETNAME "a.out-m68k-lynx"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "libaout.h"
+#include "aout/aout64.h"
+
+#define TARGET_IS_BIG_ENDIAN_P
+
+#ifdef LYNX_CORE
+
+char *lynx_core_file_failing_command();
+int lynx_core_file_failing_signal();
+boolean lynx_core_file_matches_executable_p();
+const bfd_target *lynx_core_file_p();
+
+#define MY_core_file_failing_command lynx_core_file_failing_command
+#define MY_core_file_failing_signal lynx_core_file_failing_signal
+#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
+#define MY_core_file_p lynx_core_file_p
+
+#endif /* LYNX_CORE */
+
+#include "aout-target.h"
diff --git a/bfd/m68knetbsd.c b/bfd/m68knetbsd.c
new file mode 100644
index 00000000000..24d16656539
--- /dev/null
+++ b/bfd/m68knetbsd.c
@@ -0,0 +1,34 @@
+/* BFD back-end for NetBSD/m68k a.out-ish binaries.
+ Copyright (C) 1990, 91, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#define TARGET_IS_BIG_ENDIAN_P
+
+/* Our m68k ports use either 4K or 8K pages, but object files always
+ assume 8K page alignment so they will work on all m68k machines. */
+#define TARGET_PAGE_SIZE 0x2000
+
+#define DEFAULT_ARCH bfd_arch_m68k
+#define DEFAULT_MID M_68K_NETBSD
+
+#define MY(OP) CAT(m68knetbsd_,OP)
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-m68k-netbsd"
+
+#include "netbsd.h"
diff --git a/bfd/m88kmach3.c b/bfd/m88kmach3.c
new file mode 100644
index 00000000000..7a564087300
--- /dev/null
+++ b/bfd/m88kmach3.c
@@ -0,0 +1,38 @@
+/* BFD back-end for Motorola m88k a.out (Mach 3) binaries.
+ Copyright (C) 1990, 1991, 1993, 1994 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_PAGE_SIZE (4096*2)
+#define SEGMENT_SIZE 0x20000
+#define TEXT_START_ADDR 0
+#define BYTES_IN_WORD 4
+#define N_HEADER_IN_TEXT(x) 1 /* (N_MAGIG(x) == ZMAGIC) */
+#define N_SHARED_LIB(x) 0
+
+#define N_TXTSIZE(x) ((x).a_text)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#define DEFAULT_ARCH bfd_arch_m88k
+#define MY(OP) CAT(m88kmach3_,OP)
+#define TARGETNAME "a.out-m88k-mach3"
+
+#include "aout-target.h"
diff --git a/bfd/makefile.dos b/bfd/makefile.dos
new file mode 100644
index 00000000000..8a22c6af201
--- /dev/null
+++ b/bfd/makefile.dos
@@ -0,0 +1,49 @@
+CFLAGS=-O2
+
+.c.o :
+ gcc $(CFLAGS) -I. -I../include -c $<
+
+all : libbfd.a
+
+targets.o : targets.c
+ gcc $(CFLAGS) -I. -I../include -DSELECT_VECS=&go32coff_vec,&i386aout_vec -DDEFAULT_VECTOR=go32coff_vec -c $*.c
+
+archures.o : archures.c
+ gcc $(CFLAGS) -I. -I../include -DSELECT_ARCHITECTURES=bfd_i386_arch -c $*.c
+
+OBJS = \
+ libbfd.o \
+ opncls.o \
+ bfd.o \
+ archive.o \
+ targets.o \
+ cache.o \
+ archures.o \
+ corefile.o \
+ section.o \
+ format.o \
+ syms.o \
+ reloc.o \
+ init.o \
+ coffgen.o \
+ srec.o \
+ hash.o \
+ linker.o \
+ ecoff.o \
+ ecofflink.o \
+ elf.o \
+ aout32.o \
+ stab-sym.o \
+ i386aout.o \
+ cpu-i386.o \
+ coff-go32.o \
+ cofflink.o \
+ elf32.o \
+ binary.o \
+ tekhex.o \
+ $E
+
+libbfd.a : $(OBJS)
+ -rm libbfd.a
+ ar rvs libbfd.a $(OBJS)
+ ranlib libbfd.a
diff --git a/bfd/makefile.vms b/bfd/makefile.vms
new file mode 100644
index 00000000000..ad6b1fff92a
--- /dev/null
+++ b/bfd/makefile.vms
@@ -0,0 +1,75 @@
+#
+# Makefile for bfd library under openVMS (Alpha and Vax)
+#
+# For use with gnu-make for vms
+#
+# Created by Klaus K"ampf, kkaempf@rmi.de
+#
+#
+
+CC=cc
+
+ifeq ($(ARCH),ALPHA)
+HOSTFILE=alphavms.h
+TARGETOBJS = cpu-alpha.obj
+else
+HOSTFILE=vaxvms.h
+TARGETOBJS = cpu-vax.obj
+endif
+
+
+OBJS=archive.obj,archures.obj,bfd.obj,cache.obj,coffgen.obj,corefile.obj,\
+ format.obj,init.obj,libbfd.obj,opncls.obj,reloc.obj,section.obj,syms.obj,\
+ targets.obj,hash.obj,linker.obj,elf.obj,srec.obj,binary.obj,tekhex.obj,\
+ ihex.obj,stab-syms.obj,vms.obj,vms-hdr.obj,vms-gsd.obj,vms-tir.obj,\
+ vms-misc.obj,$(TARGETOBJS)
+
+ifeq ($(CC),gcc)
+ifeq ($(ARCH),ALPHA)
+DEFS=/define=(SELECT_VECS="&vms_alpha_vec",SELECT_ARCHITECTURES="&bfd_alpha_arch",\
+"HAVE_vms_alpha_vec=1")
+else
+DEFS=/define=(SELECT_VECS="&vms_vax_vec",SELECT_ARCHITECTURES="&bfd_vax_arch",\
+"HAVE_vms_vax_vec=1","VMS_DEBUG")
+endif
+CFLAGS=/include=([],[-.include])$(DEFS)
+else
+ifeq ($(ARCH),ALPHA)
+DEFS=/define=(SELECT_VECS="&vms_alpha_vec",SELECT_ARCHITECTURES="&bfd_alpha_arch",\
+"HAVE_vms_alpha_vec=1","unlink=remove","const=","VMS_DEBUG",)
+else
+DEFS=/define=(SELECT_VECS="&vms_vax_vec",SELECT_ARCHITECTURES="&bfd_vax_arch",\
+"HAVE_vms_vax_vec=1","unlink=remove","const=","VMS_DEBUG")
+endif
+CFLAGS=/noopt/debug/include=([],[-.include])$(DEFS)/warnings=disable=(missingreturn,implicitfunc,longextern)
+endif
+
+
+libbfd.olb: sysdep.h bfd.h $(OBJS)
+ purge
+ lib/create libbfd $(OBJS)
+
+sysdep.h: [.hosts]$(HOSTFILE) config.h
+ $(CP) $< $@
+
+bfd.h: bfd-in2.h
+ $$ @configure
+
+targmatch.h: bfd.h
+config.h: bfd.h
+
+vms.c: vms.h
+vms-mhd.c: vms.h
+vms-gsd.c: vms.h
+vms-tir.c: vms.h
+vms-misc.c: vms.h
+targets.c: targmatch.h
+
+clean:
+ $$ purge
+ $(RM) libbfd.olb;
+ $(RM) sysdep.h;
+ $(RM) bfd.h;
+ $(RM) targmatch.h;
+ $(RM) config.h;
+ $(RM) *.obj;
diff --git a/bfd/mipsbsd.c b/bfd/mipsbsd.c
new file mode 100644
index 00000000000..e7ba68dde61
--- /dev/null
+++ b/bfd/mipsbsd.c
@@ -0,0 +1,468 @@
+/* BFD backend for MIPS BSD (a.out) binaries.
+ Copyright (C) 1993, 94, 95, 97, 1998 Free Software Foundation, Inc.
+ Written by Ralph Campbell.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+/* #define ENTRY_CAN_BE_ZERO */
+#define N_HEADER_IN_TEXT(x) 1
+#define N_SHARED_LIB(x) 0
+#define N_TXTADDR(x) \
+ (N_MAGIC(x) != ZMAGIC ? (x).a_entry : /* object file or NMAGIC */\
+ TEXT_START_ADDR + EXEC_BYTES_SIZE /* no padding */\
+ )
+#define N_DATADDR(x) (N_TXTADDR(x)+N_TXTSIZE(x))
+#define TEXT_START_ADDR 4096
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_mips
+#define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
+ || (mtype) == M_MIPS1 || (mtype) == M_MIPS2)
+#define MY_symbol_leading_char '\0'
+
+#define MY(OP) CAT(mipsbsd_,OP)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#define SET_ARCH_MACH(ABFD, EXEC) \
+ MY(set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
+ MY(choose_reloc_size)(ABFD);
+static void MY(set_arch_mach) PARAMS ((bfd *abfd, int machtype));
+static void MY(choose_reloc_size) PARAMS ((bfd *abfd));
+
+#define MY_write_object_contents MY(write_object_contents)
+static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
+
+/* We can't use MY(x) here because it leads to a recursive call to CAT
+ when expanded inside JUMP_TABLE. */
+#define MY_bfd_reloc_type_lookup mipsbsd_reloc_howto_type_lookup
+#define MY_canonicalize_reloc mipsbsd_canonicalize_reloc
+
+#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define MY_final_link_callback unused
+#define MY_bfd_final_link _bfd_generic_final_link
+
+#define MY_backend_data &MY(backend_data)
+#define MY_BFD_TARGET
+
+#include "aout-target.h"
+
+static void
+MY(set_arch_mach) (abfd, machtype)
+ bfd *abfd;
+ int machtype;
+{
+ enum bfd_architecture arch;
+ long machine;
+
+ /* Determine the architecture and machine type of the object file. */
+ switch (machtype) {
+
+ case M_MIPS1:
+ arch = bfd_arch_mips;
+ machine = 3000;
+ break;
+
+ case M_MIPS2:
+ arch = bfd_arch_mips;
+ machine = 4000;
+ break;
+
+ default:
+ arch = bfd_arch_obscure;
+ machine = 0;
+ break;
+ }
+ bfd_set_arch_mach(abfd, arch, machine);
+}
+
+/* Determine the size of a relocation entry, based on the architecture */
+static void
+MY(choose_reloc_size) (abfd)
+ bfd *abfd;
+{
+ switch (bfd_get_arch(abfd)) {
+ case bfd_arch_sparc:
+ case bfd_arch_a29k:
+ case bfd_arch_mips:
+ obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
+ break;
+ default:
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ break;
+ }
+}
+
+/* Write an object file in BSD a.out format.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+static boolean
+MY(write_object_contents) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ /* Magic number, maestro, please! */
+ switch (bfd_get_arch(abfd)) {
+ case bfd_arch_m68k:
+ switch (bfd_get_mach(abfd)) {
+ case bfd_mach_m68010:
+ N_SET_MACHTYPE(*execp, M_68010);
+ break;
+ default:
+ case bfd_mach_m68020:
+ N_SET_MACHTYPE(*execp, M_68020);
+ break;
+ }
+ break;
+ case bfd_arch_sparc:
+ N_SET_MACHTYPE(*execp, M_SPARC);
+ break;
+ case bfd_arch_i386:
+ N_SET_MACHTYPE(*execp, M_386);
+ break;
+ case bfd_arch_a29k:
+ N_SET_MACHTYPE(*execp, M_29K);
+ break;
+ case bfd_arch_mips:
+ switch (bfd_get_mach(abfd)) {
+ case 4000:
+ case 6000:
+ N_SET_MACHTYPE(*execp, M_MIPS2);
+ break;
+ default:
+ N_SET_MACHTYPE(*execp, M_MIPS1);
+ break;
+ }
+ break;
+ default:
+ N_SET_MACHTYPE(*execp, M_UNKNOWN);
+ }
+
+ MY(choose_reloc_size)(abfd);
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
+
+/*
+ * MIPS relocation types.
+ */
+#define MIPS_RELOC_32 0
+#define MIPS_RELOC_JMP 1
+#define MIPS_RELOC_WDISP16 2
+#define MIPS_RELOC_HI16 3
+#define MIPS_RELOC_HI16_S 4
+#define MIPS_RELOC_LO16 5
+
+/*
+ * This is only called when performing a BFD_RELOC_MIPS_JMP relocation.
+ * The jump destination address is formed from the upper 4 bits of the
+ * "current" program counter concatenated with the jump instruction's
+ * 26 bit field and two trailing zeros.
+ * If the destination address is not in the same segment as the "current"
+ * program counter, then we need to signal an error.
+ */
+static bfd_reloc_status_type
+mips_fix_jmp_addr (abfd,reloc_entry,symbol,data,input_section,output_bfd)
+ bfd *abfd;
+ arelent *reloc_entry;
+ struct symbol_cache_entry *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+{
+ bfd_vma relocation, pc;
+
+ /* If this is a partial relocation, just continue. */
+ if (output_bfd != (bfd *)NULL)
+ return bfd_reloc_continue;
+
+ /* If this is an undefined symbol, return error */
+ if (bfd_is_und_section (symbol->section)
+ && (symbol->flags & BSF_WEAK) == 0)
+ return bfd_reloc_undefined;
+
+ /*
+ * Work out which section the relocation is targetted at and the
+ * initial relocation command value.
+ */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ pc = input_section->output_section->vma + input_section->output_offset +
+ reloc_entry->address + 4;
+
+ if ((relocation & 0xF0000000) != (pc & 0xF0000000))
+ return bfd_reloc_overflow;
+
+ return bfd_reloc_continue;
+}
+
+/*
+ * This is only called when performing a BFD_RELOC_HI16_S relocation.
+ * We need to see if bit 15 is set in the result. If it is, we add
+ * 0x10000 and continue normally. This will compensate for the sign extension
+ * when the low bits are added at run time.
+ */
+static bfd_reloc_status_type
+mips_fix_hi16_s PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+mips_fix_hi16_s (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+
+ /* If this is a partial relocation, just continue. */
+ if (output_bfd != (bfd *)NULL)
+ return bfd_reloc_continue;
+
+ /* If this is an undefined symbol, return error */
+ if (bfd_is_und_section (symbol->section)
+ && (symbol->flags & BSF_WEAK) == 0)
+ return bfd_reloc_undefined;
+
+ /*
+ * Work out which section the relocation is targetted at and the
+ * initial relocation command value.
+ */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ if (relocation & 0x8000)
+ reloc_entry->addend += 0x10000;
+
+ return bfd_reloc_continue;
+}
+
+static reloc_howto_type mips_howto_table_ext[] = {
+ {MIPS_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield, 0,
+ "32", false, 0, 0xffffffff, false},
+ {MIPS_RELOC_JMP, 2, 2, 26, false, 0, complain_overflow_dont,
+ mips_fix_jmp_addr,
+ "MIPS_JMP", false, 0, 0x03ffffff, false},
+ {MIPS_RELOC_WDISP16, 2, 2, 16, true, 0, complain_overflow_signed, 0,
+ "WDISP16", false, 0, 0x0000ffff, false},
+ {MIPS_RELOC_HI16, 16, 2, 16, false, 0, complain_overflow_bitfield, 0,
+ "HI16", false, 0, 0x0000ffff, false},
+ {MIPS_RELOC_HI16_S, 16, 2, 16, false, 0, complain_overflow_bitfield,
+ mips_fix_hi16_s,
+ "HI16_S", false, 0, 0x0000ffff, false},
+ {MIPS_RELOC_LO16, 0, 2, 16, false, 0, complain_overflow_dont, 0,
+ "LO16", false, 0, 0x0000ffff, false},
+};
+
+static reloc_howto_type *
+MY(reloc_howto_type_lookup) (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+
+ if (bfd_get_arch (abfd) != bfd_arch_mips)
+ return 0;
+
+ switch (code)
+ {
+ case BFD_RELOC_CTOR:
+ case BFD_RELOC_32:
+ return (&mips_howto_table_ext[MIPS_RELOC_32]);
+ case BFD_RELOC_MIPS_JMP:
+ return (&mips_howto_table_ext[MIPS_RELOC_JMP]);
+ case BFD_RELOC_16_PCREL_S2:
+ return (&mips_howto_table_ext[MIPS_RELOC_WDISP16]);
+ case BFD_RELOC_HI16:
+ return (&mips_howto_table_ext[MIPS_RELOC_HI16]);
+ case BFD_RELOC_HI16_S:
+ return (&mips_howto_table_ext[MIPS_RELOC_HI16_S]);
+ case BFD_RELOC_LO16:
+ return (&mips_howto_table_ext[MIPS_RELOC_LO16]);
+ default:
+ return 0;
+ }
+}
+
+/*
+ * This is just like the standard aoutx.h version but we need to do our
+ * own mapping of external reloc type values to howto entries.
+ */
+long
+MY(canonicalize_reloc)(abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count, c;
+ extern reloc_howto_type NAME(aout,ext_howto_table)[];
+
+ /* If we have already read in the relocation table, return the values. */
+ if (section->flags & SEC_CONSTRUCTOR) {
+ arelent_chain *chain = section->constructor_chain;
+
+ for (count = 0; count < section->reloc_count; count++) {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+ }
+ if (tblptr && section->reloc_count) {
+ for (count = 0; count++ < section->reloc_count;)
+ *relptr++ = tblptr++;
+ *relptr = 0;
+ return section->reloc_count;
+ }
+
+ if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
+ return -1;
+ tblptr = section->relocation;
+
+ /* fix up howto entries */
+ for (count = 0; count++ < section->reloc_count;)
+ {
+ c = tblptr->howto - NAME(aout,ext_howto_table);
+ tblptr->howto = &mips_howto_table_ext[c];
+
+ *relptr++ = tblptr++;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+}
+
+static CONST struct aout_backend_data MY(backend_data) = {
+ 0, /* zmagic contiguous */
+ 1, /* text incl header */
+ 0, /* entry is text address */
+ 0, /* exec_hdr_flags */
+ TARGET_PAGE_SIZE, /* text vma */
+ MY_set_sizes,
+ 0, /* text size includes exec header */
+ 0, /* add_dynamic_symbols */
+ 0, /* add_one_symbol */
+ 0, /* link_dynamic_object */
+ 0, /* write_dynamic_symbol */
+ 0, /* check_dynamic_reloc */
+ 0 /* finish_dynamic_link */
+};
+
+const bfd_target aout_mips_little_vec =
+{
+ "a.out-mips-little", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_LITTLE, /* target byte order (little) */
+ BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ MY_symbol_leading_char,
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, MY_core_file_p},
+ {bfd_false, MY_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (MY),
+ BFD_JUMP_TABLE_COPY (MY),
+ BFD_JUMP_TABLE_CORE (MY),
+ BFD_JUMP_TABLE_ARCHIVE (MY),
+ BFD_JUMP_TABLE_SYMBOLS (MY),
+ BFD_JUMP_TABLE_RELOCS (MY),
+ BFD_JUMP_TABLE_WRITE (MY),
+ BFD_JUMP_TABLE_LINK (MY),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) MY_backend_data,
+};
+
+const bfd_target aout_mips_big_vec =
+{
+ "a.out-mips-big", /* name */
+ bfd_target_aout_flavour,
+ BFD_ENDIAN_BIG, /* target byte order (big) */
+ BFD_ENDIAN_BIG, /* target headers byte order (big) */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+ MY_symbol_leading_char,
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, MY_core_file_p},
+ {bfd_false, MY_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (MY),
+ BFD_JUMP_TABLE_COPY (MY),
+ BFD_JUMP_TABLE_CORE (MY),
+ BFD_JUMP_TABLE_ARCHIVE (MY),
+ BFD_JUMP_TABLE_SYMBOLS (MY),
+ BFD_JUMP_TABLE_RELOCS (MY),
+ BFD_JUMP_TABLE_WRITE (MY),
+ BFD_JUMP_TABLE_LINK (MY),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) MY_backend_data,
+};
diff --git a/bfd/mpw-config.in b/bfd/mpw-config.in
new file mode 100644
index 00000000000..31addeebdcf
--- /dev/null
+++ b/bfd/mpw-config.in
@@ -0,0 +1,86 @@
+# Configuration fragment for BFD.
+
+# This is almost always correct.
+
+Set selarchs "&bfd_{target_cpu}_arch"
+Set defvec ""
+Set selvecs ""
+Set havevecs ""
+
+If "{target_canonical}" =~ /m68k-apple-macos/
+ Set BFD_BACKENDS '"{o}"coff-m68k.c.o "{o}"cofflink.c.o'
+ Set defvec m68kcoff_vec
+ Set selvecs '&m68kcoff_vec'
+ Set havevecs '-d HAVE_m68kcoff_vec'
+
+Else If "{target_canonical}" =~ /powerpc-apple-macos/
+ Set BFD_BACKENDS '"{o}"coff-pmac.c.o "{o}"xcofflink.c.o'
+ Set defvec pmac_xcoff_vec
+ Set selvecs '&pmac_xcoff_vec'
+ Set havevecs '-d HAVE_pmac_xcoff_vec'
+ Set selarchs "&bfd_powerpc_arch"
+
+Else If "{target_canonical}" =~ /i386-\Option-x-go32/
+ Set BFD_BACKENDS '"{o}"coff-i386.c.o'
+ Set defvec i386coff_vec
+ Set selvecs '&i386coff_vec'
+ Set havevecs '-d HAVE_i386coff_vec'
+
+Else If "{target_canonical}" =~ /mips-\Option-x-\Option-x/
+ Set BFD_BACKENDS '"{o}"coff-mips.c.o "{o}"ecoff.c.o "{o}"ecofflink.c.o "{o}"elf32.c.o "{o}"elf32-mips.c.o "{o}"elflink.c.o'
+ Set defvec ecoff_big_vec
+ Set selvecs '&ecoff_big_vec,&ecoff_little_vec,&bfd_elf32_bigmips_vec'
+ Set havevecs '-d HAVE_ecoff_big_vec -d HAVE_ecoff_little_vec -d HAVE_bfd_elf32_bigmips_vec'
+
+Else If "{target_canonical}" =~ /sh-\Option-x-hms/
+ Set BFD_BACKENDS '"{o}"coff-sh.c.o "{o}"cofflink.c.o'
+ Set defvec shcoff_vec
+ Set selvecs '&shcoff_vec,&shlcoff_vec'
+ Set havevecs '-d HAVE_shcoff_vec -d HAVE_shlcoff_vec'
+End If
+
+Set ta `echo {selarchs} | sed -e 's/&bfd_/{o}cpu-/g' -e 's/_arch/.c.o/g'`
+
+Set tdefaults "-d DEFAULT_VECTOR={defvec} -d SELECT_VECS={selvecs} -d SELECT_ARCHITECTURES={selarchs} {havevecs}"
+
+Echo '# From mpw-config.in' > "{o}"mk.tmp
+Echo 'WORDSIZE = 32' >> "{o}"mk.tmp
+Echo 'BFD_MACHINES = ' {ta} >> "{o}"mk.tmp
+Echo 'BFD_BACKENDS = ' {BFD_BACKENDS} >> "{o}"mk.tmp
+Echo 'TDEFAULTS = ' {tdefaults} >> "{o}"mk.tmp
+Echo 'HDEPFILES = ' >> "{o}"mk.tmp
+Echo 'TDEPFILES = ' >> "{o}"mk.tmp
+Echo '# End from mpw-config.in' >> "{o}"mk.tmp
+
+Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
+Echo '#include "mpw.h"' >> "{o}"config.new
+
+MoveIfChange "{o}"config.new "{o}"config.h
+
+# We can only handle 32-bit targets right now.
+
+sed -e 's/@WORDSIZE@/32/' \Option-d
+ -e 's/@wordsize@/32/' \Option-d
+ -e "s/@VERSION@/`Catenate {srcdir}VERSION`/" \Option-d
+ -e 's/@BFD_HOST_64_BIT_DEFINED@/0/' \Option-d
+ -e 's/@BFD_HOST_64_BIT@//' \Option-d
+ -e 's/@BFD_HOST_U_64_BIT@//' \Option-d
+ -e 's/@BFD_HOST_64BIT_LONG@/0/' \Option-d
+ "{srcdir}"bfd-in2.h >"{o}"bfd.h-new
+
+MoveIfChange "{o}"bfd.h-new "{o}"bfd.h
+
+sed -e 's/NN/32/g' "{srcdir}"elfxx-target.h >"{o}"elf32-target.h-new
+MoveIfChange "{o}"elf32-target.h-new "{o}"elf32-target.h
+
+# Pre-expand some macros in coffswap.h, so MPW C doesn't choke.
+
+sed -e 's/^ PUT_AOUTHDR_TSIZE (/ bfd_h_put_32 (/' \Option-d
+ -e 's/^ PUT_AOUTHDR_DSIZE (/ bfd_h_put_32 (/' \Option-d
+ -e 's/^ PUT_AOUTHDR_BSIZE (/ bfd_h_put_32 (/' \Option-d
+ -e 's/^ PUT_AOUTHDR_ENTRY (/ bfd_h_put_32 (/' \Option-d
+ -e 's/^ PUT_AOUTHDR_TEXT_START (/ bfd_h_put_32 (/' \Option-d
+ -e 's/^ PUT_AOUTHDR_DATA_START (/ bfd_h_put_32 (/' \Option-d
+ "{srcdir}"coffswap.h >"{o}"coffswap.h-new
+
+MoveIfChange "{o}"coffswap.h-new "{o}"coffswap.h
diff --git a/bfd/mpw-make.sed b/bfd/mpw-make.sed
new file mode 100644
index 00000000000..b2463c72b7f
--- /dev/null
+++ b/bfd/mpw-make.sed
@@ -0,0 +1,81 @@
+# Sed commands to finish translating the Unix BFD Makefile into MPW syntax.
+
+# Whack out unused host and target define bits.
+/HDEFINES/s/@HDEFINES@//
+/TDEFINES/s/@TDEFINES@//
+
+# Fix pathnames to include directories.
+/^INCDIR = /s/^INCDIR = .*$/INCDIR = "{topsrcdir}"include/
+/^CSEARCH = /s/$/ -i "{INCDIR}":mpw: -i ::extra-include:/
+
+# Comment out setting of vars, configure script will add these itself.
+/^WORDSIZE =/s/^/#/
+# /^ALL_BACKENDS/s/^/#/
+/^BFD_BACKENDS/s/^/#/
+/^BFD_MACHINES/s/^/#/
+/^TDEFAULTS/s/^/#/
+
+# Remove extra, useless, "all".
+/^all \\Option-f _oldest/,/^$/d
+
+# Remove the Makefile rebuild rule.
+/^Makefile /,/--recheck/d
+
+# Don't do any recursive subdir stuff.
+/ subdir_do/s/{MAKE}/null-command/
+
+/BFD_H/s/^{BFD_H}/#{BFD_H}/
+
+# Add explicit srcdir paths to special files.
+/config.bfd/s/ config.bfd/ "{s}"config.bfd/g
+/targmatch.sed/s/ targmatch.sed/ "{s}"targmatch.sed/g
+
+# Point at include files that are always in the objdir.
+/bfd/s/"{s}"bfd\.h/"{o}"bfd.h/g
+/config/s/"{s}"config\.h/"{o}"config.h/g
+/targmatch/s/"{s}"targmatch\.h/"{o}"targmatch.h/g
+/targmatch/s/^targmatch\.h/"{o}"targmatch.h/
+/elf32-target/s/"{s}"elf32-target\.h/"{o}"elf32-target.h/g
+/elf32-target/s/^elf32-target\.h/"{o}"elf32-target.h/
+/elf64-target/s/"{s}"elf64-target\.h/"{o}"elf64-target.h/g
+/elf64-target/s/^elf64-target\.h/"{o}"elf64-target.h/
+
+/"{s}"{INCDIR}/s/"{s}"{INCDIR}/"{INCDIR}"/g
+
+/dep/s/\.dep/__dep/g
+
+# Removing duplicates is cool but presently unnecessary,
+# so whack this out.
+/^ofiles \\Option-f/,/^$/d
+/ofiles/s/{OFILES} ofiles/{OFILES}/
+/echo ofiles = /d
+/cat ofiles/s/`cat ofiles`/{OFILES}/
+
+# No corefile support.
+/COREFILE/s/@COREFILE@//
+/COREFLAG/s/@COREFLAG@//
+
+# No PIC foolery in this environment.
+/@ALLLIBS@/s/@ALLLIBS@/{TARGETLIB}/
+/@PICLIST@/s/@PICLIST@//
+/@PICFLAG@/s/@PICFLAG@//
+/^{OFILES} \\Option-f stamp-picdir/,/^$/d
+
+# Remove the pic trickery from the default build rule.
+/^\.c\.o \\Option-f /,/End If/c\
+.c.o \\Option-f .c
+
+# MPW Make doesn't know about $<.
+/"{o}"targets.c.o \\Option-f "{s}"targets.c Makefile/,/^$/c\
+"{o}"targets.c.o \\Option-f "{s}"targets.c Makefile\
+ {CC} @DASH_C_FLAG@ {ALL_CFLAGS} {TDEFAULTS} "{s}"targets.c -o "{o}"targets.c.o
+
+/"{o}"archures.c.o \\Option-f "{s}"archures.c Makefile/,/^$/c\
+"{o}"archures.c.o \\Option-f "{s}"archures.c Makefile\
+ {CC} @DASH_C_FLAG@ {ALL_CFLAGS} {TDEFAULTS} "{s}"archures.c -o "{o}"archures.c.o
+
+# Remove the .h rebuilding rules, we don't currently have a doc subdir,
+# or a way to build the prototype-hacking tool that's in it.
+/^"{srcdir}"bfd-in2.h \\Option-f /,/^$/d
+/^"{srcdir}"libbfd.h \\Option-f /,/^$/d
+/^"{srcdir}"libcoff.h \\Option-f /,/^$/d
diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c
new file mode 100644
index 00000000000..21b184dce3b
--- /dev/null
+++ b/bfd/netbsd-core.c
@@ -0,0 +1,251 @@
+/* BFD back end for NetBSD style core files
+ Copyright 1988, 89, 91, 92, 93, 96, 1998 Free Software Foundation, Inc.
+ Written by Paul Kranenburg, EUR
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <signal.h>
+#include <sys/core.h>
+
+/*
+ * FIXME: On NetBSD/sparc CORE_FPU_OFFSET should be (sizeof(struct trapframe))
+ */
+
+struct netbsd_core_struct {
+ struct core core;
+} *rawptr;
+
+/* forward declarations */
+
+static const bfd_target * netbsd_core_file_p PARAMS ((bfd *abfd));
+static char * netbsd_core_file_failing_command PARAMS ((bfd *abfd));
+static int netbsd_core_file_failing_signal PARAMS ((bfd *abfd));
+static boolean netbsd_core_file_matches_executable_p
+ PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+static void swap_abort PARAMS ((void));
+
+/* Handle NetBSD-style core dump file. */
+
+/* ARGSUSED */
+static const bfd_target *
+netbsd_core_file_p (abfd)
+ bfd *abfd;
+
+{
+ int i, val, offset;
+ asection *asect, *asect2;
+ struct core core;
+ struct coreseg coreseg;
+
+ val = bfd_read ((void *)&core, 1, sizeof core, abfd);
+ if (val != sizeof core) {
+ /* Too small to be a core file */
+ bfd_set_error(bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (CORE_GETMAGIC(core) != COREMAGIC) {
+ bfd_set_error(bfd_error_wrong_format);
+ return 0;
+ }
+
+ rawptr = (struct netbsd_core_struct *)
+ bfd_zalloc (abfd, sizeof (struct netbsd_core_struct));
+ if (rawptr == NULL) {
+ bfd_set_error(bfd_error_no_memory);
+ return 0;
+ }
+
+ rawptr->core = core;
+ abfd->tdata.netbsd_core_data = rawptr;
+
+ offset = core.c_hdrsize;
+ for (i = 0; i < core.c_nseg; i++) {
+
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
+ goto punt;
+
+ val = bfd_read ((void *)&coreseg, 1, sizeof coreseg, abfd);
+ if (val != sizeof coreseg) {
+ bfd_set_error(bfd_error_file_truncated);
+ goto punt;
+ }
+ if (CORE_GETMAGIC(coreseg) != CORESEGMAGIC) {
+ bfd_set_error(bfd_error_wrong_format);
+ goto punt;
+ }
+
+ offset += core.c_seghdrsize;
+
+ asect = (asection *) bfd_zalloc (abfd, sizeof(asection));
+ if (asect == NULL) {
+ bfd_set_error(bfd_error_no_memory);
+ goto punt;
+ }
+
+ asect->_raw_size = coreseg.c_size;
+ asect->vma = coreseg.c_addr;
+ asect->filepos = offset;
+ asect->alignment_power = 2;
+ asect->next = abfd->sections;
+ abfd->sections = asect;
+ abfd->section_count++;
+ offset += coreseg.c_size;
+
+ switch (CORE_GETFLAG(coreseg)) {
+ case CORE_CPU:
+ asect->name = ".reg";
+ asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+#ifdef CORE_FPU_OFFSET
+ /* Hackish... */
+ asect->_raw_size = CORE_FPU_OFFSET;
+ asect2 = (asection *)bfd_zalloc (abfd,
+ sizeof (asection));
+ if (asect2 == NULL) {
+ bfd_set_error(bfd_error_no_memory);
+ goto punt;
+ }
+ asect2->_raw_size = coreseg.c_size - CORE_FPU_OFFSET;
+ asect2->vma = 0;
+ asect2->filepos = asect->filepos + CORE_FPU_OFFSET;
+ asect2->alignment_power = 2;
+ asect2->next = abfd->sections;
+ asect2->name = ".reg2";
+ asect2->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+ abfd->sections = asect2;
+ abfd->section_count++;
+#endif
+
+ break;
+ case CORE_DATA:
+ asect->name = ".data";
+ asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
+ break;
+ case CORE_STACK:
+ asect->name = ".stack";
+ asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
+ break;
+ }
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+ return abfd->xvec;
+
+punt: {
+ asection *anext;
+ for (asect = abfd->sections; asect; asect = anext) {
+ anext = asect->next;
+ free((void *)asect);
+ }
+ }
+ free ((void *)rawptr);
+ abfd->tdata.netbsd_core_data = NULL;
+ abfd->sections = NULL;
+ abfd->section_count = 0;
+ return 0;
+}
+
+static char*
+netbsd_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ /*return core_command (abfd);*/
+ return abfd->tdata.netbsd_core_data->core.c_name;
+}
+
+/* ARGSUSED */
+static int
+netbsd_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ /*return core_signal (abfd);*/
+ return abfd->tdata.netbsd_core_data->core.c_signo;
+}
+
+/* ARGSUSED */
+static boolean
+netbsd_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this point */
+}
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target netbsd_core_vec =
+ {
+ "netbsd-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ netbsd_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (netbsd),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
diff --git a/bfd/netbsd.h b/bfd/netbsd.h
new file mode 100644
index 00000000000..a5482f04312
--- /dev/null
+++ b/bfd/netbsd.h
@@ -0,0 +1,122 @@
+/* BFD back-end definitions used by all NetBSD targets.
+ Copyright (C) 1990, 91, 92, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA. */
+
+/* Check for our machine type (part of magic number). */
+#ifndef MACHTYPE_OK
+#define MACHTYPE_OK(m) ((m) == DEFAULT_MID || (m) == M_UNKNOWN)
+#endif
+
+/* This is the normal load address for executables. */
+#define TEXT_START_ADDR TARGET_PAGE_SIZE
+
+/* NetBSD ZMAGIC has its header in the text segment. */
+#define N_HEADER_IN_TEXT(x) 1
+
+/* Determine if this is a shared library using the flags. */
+#define N_SHARED_LIB(x) (N_DYNAMIC(x))
+
+/* We have 6 bits of flags and 10 bits of machine ID. */
+#define N_MACHTYPE(exec) \
+ ((enum machine_type)(((exec).a_info >> 16) & 0x03ff))
+#define N_FLAGS(exec) \
+ (((exec).a_info >> 26) & 0x3f)
+
+#define N_SET_INFO(exec, magic, type, flags) \
+ ((exec).a_info = ((magic) & 0xffff) \
+ | (((int)(type) & 0x3ff) << 16) \
+ | (((flags) & 0x3f) << 24))
+#define N_SET_MACHTYPE(exec, machtype) \
+ ((exec).a_info = \
+ ((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
+#define N_SET_FLAGS(exec, flags) \
+ ((exec).a_info = \
+ ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+/* On NetBSD, the magic number is always in ntohl's "network" (big-endian)
+ format. */
+#define SWAP_MAGIC(ext) bfd_getb32 (ext)
+
+/* On NetBSD, the entry point may be taken to be the start of the text
+ section. */
+#define MY_entry_is_text_address 1
+
+#define MY_write_object_contents MY(write_object_contents)
+static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
+#define MY_text_includes_header 1
+
+#include "aout-target.h"
+
+/* Write an object file.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+static boolean
+MY(write_object_contents) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ /* We must make certain that the magic number has been set. This
+ will normally have been done by set_section_contents, but only if
+ there actually are some section contents. */
+ if (! abfd->output_has_begun)
+ {
+ bfd_size_type text_size;
+ file_ptr text_end;
+
+ NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
+ }
+
+#if CHOOSE_RELOC_SIZE
+ CHOOSE_RELOC_SIZE(abfd);
+#else
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+#endif
+
+ /* Magic number, maestro, please! */
+ switch (bfd_get_arch(abfd)) {
+ case DEFAULT_ARCH:
+ N_SET_MACHTYPE(*execp, DEFAULT_MID);
+ break;
+ default:
+ N_SET_MACHTYPE(*execp, M_UNKNOWN);
+ break;
+ }
+
+ /* The NetBSD magic number is always big-endian */
+#ifndef TARGET_IS_BIG_ENDIAN_P
+ /* XXX aren't there any macro to change byteorder of a word independent of
+ the host's or target's endianesses? */
+ execp->a_info
+ = (execp->a_info & 0xff) << 24 | (execp->a_info & 0xff00) << 8
+ | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
+#endif
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
diff --git a/bfd/newsos3.c b/bfd/newsos3.c
new file mode 100644
index 00000000000..7ec7a75a87c
--- /dev/null
+++ b/bfd/newsos3.c
@@ -0,0 +1,40 @@
+/* BFD back-end for NewsOS3 (Sony, 68k) binaries.
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define TEXT_START_ADDR 0
+#define BYTES_IN_WORD 4
+#define MY(OP) CAT(newsos3_,OP)
+#define TARGETNAME "a.out-newsos3"
+#define ENTRY_CAN_BE_ZERO
+#define N_SHARED_LIB(x) 0 /* Avoids warning when compiled with -Wall. */
+#define DEFAULT_ARCH bfd_arch_m68k
+#define TARGET_IS_BIG_ENDIAN_P
+#define N_HEADER_IN_TEXT(x) 0
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#include "aout-target.h"
diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h
new file mode 100644
index 00000000000..6f1d47d8c45
--- /dev/null
+++ b/bfd/nlm-target.h
@@ -0,0 +1,229 @@
+/* Target definitions for 32/64-bit NLM (NetWare Loadable Module)
+ Copyright (C) 1993, 94, 95, 1997 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define nlm_core_file_p _bfd_dummy_target
+
+#define nlm_get_symtab_upper_bound nlmNAME(get_symtab_upper_bound)
+#define nlm_get_symtab nlmNAME(get_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_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define nlm_get_lineno _bfd_nosymbols_get_lineno
+#define nlm_find_nearest_line _bfd_nosymbols_find_nearest_line
+#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_bfd_reloc_type_lookup bfd_default_reloc_type_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_link_hash_table_create _bfd_generic_link_hash_table_create
+#define nlm_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define nlm_bfd_final_link _bfd_generic_final_link
+#define nlm_bfd_link_split_section _bfd_generic_link_split_section
+
+/* 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. */
+
+
+#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,
+
+ /* 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_false,
+ nlm_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ nlmNAME(write_object_contents),
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ /* 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),
+
+ /* backend_data: */
+ (PTR) 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,
+
+ /* 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_false,
+ nlm_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ nlmNAME(write_object_contents),
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ /* 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),
+
+ /* backend_data: */
+ (PTR) TARGET_BACKEND_DATA
+};
+#endif
diff --git a/bfd/nlm.c b/bfd/nlm.c
new file mode 100644
index 00000000000..89c6baa64ef
--- /dev/null
+++ b/bfd/nlm.c
@@ -0,0 +1,55 @@
+/* NLM (NetWare Loadable Module) executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libnlm.h"
+
+/* Make an NLM object. We just need to allocate the backend
+ information. */
+
+boolean
+nlm_mkobject (abfd)
+ bfd * abfd;
+{
+ nlm_tdata (abfd) =
+ (struct nlm_obj_tdata *) bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata));
+ 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. */
+
+boolean
+nlm_set_arch_mach (abfd, arch, machine)
+ 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
new file mode 100644
index 00000000000..24c8e516762
--- /dev/null
+++ b/bfd/nlm32-alpha.c
@@ -0,0 +1,892 @@
+/* Support for 32-bit Alpha NLM (NetWare Loadable Module)
+ Copyright (C) 1993 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "bfd.h"
+#include "sysdep.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"
+
+static boolean nlm_alpha_backend_object_p
+ PARAMS ((bfd *));
+static boolean nlm_alpha_write_prefix
+ PARAMS ((bfd *));
+static boolean nlm_alpha_read_reloc
+ PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
+static boolean nlm_alpha_mangle_relocs
+ PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
+static boolean nlm_alpha_read_import
+ PARAMS ((bfd *, nlmNAME(symbol_type) *));
+static boolean nlm_alpha_write_import
+ PARAMS ((bfd *, asection *, arelent *));
+static boolean nlm_alpha_set_public_section
+ PARAMS ((bfd *, nlmNAME(symbol_type) *));
+static bfd_vma nlm_alpha_get_public_offset
+ PARAMS ((bfd *, asymbol *));
+static boolean nlm_alpha_write_external
+ PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
+
+/* 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 boolean
+nlm_alpha_backend_object_p (abfd)
+ bfd *abfd;
+{
+ struct nlm32_alpha_external_prefix_header s;
+ bfd_size_type size;
+
+ if (bfd_read ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ return false;
+
+ if (bfd_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 = bfd_h_get_32 (abfd, s.size);
+ if (bfd_seek (abfd, size, SEEK_SET) != 0)
+ return false;
+
+ return true;
+}
+
+/* Write out the prefix. */
+
+static boolean
+nlm_alpha_write_prefix (abfd)
+ bfd *abfd;
+{
+ struct nlm32_alpha_external_prefix_header s;
+
+ memset (&s, 0, sizeof s);
+ bfd_h_put_32 (abfd, (bfd_vma) NLM32_ALPHA_MAGIC, s.magic);
+ bfd_h_put_32 (abfd, (bfd_vma) 2, s.format);
+ bfd_h_put_32 (abfd, (bfd_vma) sizeof s, s.size);
+ if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ return false;
+ return true;
+}
+
+/* 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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0xffffffff, /* dst_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 */
+ 0xffffffffffffffff, /* src_mask */
+ 0xffffffffffffffff, /* dst_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, /* src_mask */
+ 0xffffffff, /* dst_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, /* src_mask */
+ 0xffff, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0xffff, /* dst_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, /* src_mask */
+ 0x1fffff, /* dst_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, /* src_mask */
+ 0x3fff, /* dst_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, /* src_mask */
+ 0xffff, /* dst_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, /* src_mask */
+ 0xffffffff, /* dst_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 */
+ 0xffffffffffffffff, /* src_mask */
+ 0xffffffffffffffff, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0xffffffffffffffff, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0, /* dst_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, /* src_mask */
+ 0, /* dst_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 boolean
+nlm_alpha_read_reloc (abfd, sym, secp, rel)
+ 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_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ return false;
+
+ /* Swap in the reloc information. */
+ r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext.r_vaddr);
+ r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) 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 < bfd_section_size (abfd, code_sec))
+ {
+ *secp = code_sec;
+ rel->address = r_vaddr;
+ }
+ else
+ {
+ *secp = data_sec;
+ rel->address = r_vaddr - bfd_section_size (abfd, code_sec);
+ }
+
+ /* 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 boolean
+nlm_alpha_mangle_relocs (abfd, sec, data, offset, count)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+ bfd_vma offset;
+ bfd_size_type count;
+{
+ return true;
+}
+
+/* Read an ALPHA NLM import record */
+
+static boolean
+nlm_alpha_read_import (abfd, sym)
+ 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_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength))
+ return false;
+ sym -> symbol.the_bfd = abfd;
+ name = bfd_alloc (abfd, symlength + 1);
+ if (name == NULL)
+ return false;
+ if (bfd_read (name, symlength, 1, 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_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return false;
+ rcount = bfd_h_get_32 (abfd, temp);
+ nlm_relocs = ((struct nlm_relent *)
+ 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_alpha_read_reloc (abfd, sym, &section,
+ &nlm_relocs -> reloc)
+ == false)
+ return false;
+ nlm_relocs -> section = section;
+ nlm_relocs++;
+ sym -> rcnt++;
+ }
+
+ return true;
+}
+
+/* Write an Alpha NLM reloc. */
+
+static boolean
+nlm_alpha_write_import (abfd, sec, rel)
+ 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_section_size (abfd,
+ bfd_get_section_by_name (abfd,
+ NLM_CODE_NAME));
+ 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. */
+ bfd_h_put_64 (abfd, r_vaddr, (bfd_byte *) ext.r_vaddr);
+ bfd_h_put_32 (abfd, r_symndx, (bfd_byte *) 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_write (&ext, sizeof ext, 1, 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 boolean
+nlm_alpha_set_public_section (abfd, sym)
+ 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 < bfd_section_size (abfd, code_sec))
+ {
+ sym->symbol.section = code_sec;
+ sym->symbol.flags |= BSF_FUNCTION;
+ }
+ else
+ {
+ sym->symbol.section = data_sec;
+ sym->symbol.value -= bfd_section_size (abfd, code_sec);
+ /* The data segment had better be aligned. */
+ BFD_ASSERT ((bfd_section_size (abfd, code_sec) & 0xf) == 0);
+ }
+ return true;
+}
+
+/* Get the offset to write out for a public symbol. */
+
+static bfd_vma
+nlm_alpha_get_public_offset (abfd, sym)
+ bfd *abfd;
+ asymbol *sym;
+{
+ return bfd_asymbol_value (sym);
+}
+
+/* Write an Alpha NLM external symbol. */
+
+static boolean
+nlm_alpha_write_external (abfd, count, sym, relocs)
+ bfd *abfd;
+ bfd_size_type count;
+ asymbol *sym;
+ struct reloc_and_sec *relocs;
+{
+ int i;
+ bfd_byte len;
+ unsigned char temp[NLM_TARGET_LONG_SIZE];
+ arelent r;
+
+ len = strlen (sym->name);
+ if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
+ || bfd_write (sym->name, len, 1, abfd) != len)
+ return false;
+
+ bfd_put_32 (abfd, count + 2, temp);
+ if (bfd_write (temp, sizeof (temp), 1, 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, (asection *) NULL, &r) == false)
+ return false;
+
+ r.address = nlm_alpha_backend_data (abfd)->gp;
+ r.addend = 0;
+ if (nlm_alpha_write_import (abfd, (asection *) NULL, &r) == false)
+ return false;
+
+ for (i = 0; i < count; i++)
+ {
+ if (nlm_alpha_write_import (abfd, relocs[i].sec,
+ relocs[i].rel) == false)
+ 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 nlmNAME(alpha_vec)
+#define TARGET_BACKEND_DATA &nlm32_alpha_backend
+
+#include "nlm-target.h"
diff --git a/bfd/nlm32-i386.c b/bfd/nlm32-i386.c
new file mode 100644
index 00000000000..f16c74d985e
--- /dev/null
+++ b/bfd/nlm32-i386.c
@@ -0,0 +1,451 @@
+/* Support for 32-bit i386 NLM (NetWare Loadable Module)
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.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"
+
+static boolean nlm_i386_read_reloc
+ PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
+static boolean nlm_i386_write_import
+ PARAMS ((bfd *, asection *, arelent *));
+static boolean nlm_i386_mangle_relocs
+ PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
+static boolean nlm_i386_read_import
+ PARAMS ((bfd *, nlmNAME(symbol_type) *));
+static boolean nlm_i386_write_external
+ PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
+
+/* 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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false); /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ true); /* pcrel_offset */
+
+/* Read a NetWare i386 reloc. */
+
+static boolean
+nlm_i386_read_reloc (abfd, sym, secp, rel)
+ bfd *abfd;
+ nlmNAME(symbol_type) *sym;
+ asection **secp;
+ arelent *rel;
+{
+ bfd_byte temp[4];
+ bfd_vma val;
+ const char *name;
+
+ if (bfd_read (temp, sizeof (temp), 1, 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 boolean
+nlm_i386_write_import (abfd, sec, rel)
+ 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_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return false;
+
+ return true;
+}
+
+/* I want to be able to use objcopy to turn a 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 boolean
+nlm_i386_mangle_relocs (abfd, sec, data, offset, count)
+ bfd *abfd;
+ asection *sec;
+ PTR 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 boolean
+nlm_i386_read_import (abfd, sym)
+ 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_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength))
+ return false;
+ sym -> symbol.the_bfd = abfd;
+ name = bfd_alloc (abfd, symlength + 1);
+ if (name == NULL)
+ return false;
+ if (bfd_read (name, symlength, 1, 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_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return false;
+ rcount = bfd_h_get_32 (abfd, temp);
+ nlm_relocs = ((struct nlm_relent *)
+ 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)
+ == false)
+ return false;
+ nlm_relocs -> section = section;
+ nlm_relocs++;
+ sym -> rcnt++;
+ }
+ return true;
+}
+
+/* Write out an external reference. */
+
+static boolean
+nlm_i386_write_external (abfd, count, sym, relocs)
+ 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_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
+ || bfd_write (sym->name, len, 1, abfd) != len)
+ return false;
+
+ bfd_put_32 (abfd, count, temp);
+ if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
+ return false;
+
+ for (i = 0; i < count; i++)
+ {
+ if (nlm_i386_write_import (abfd, relocs[i].sec,
+ relocs[i].rel) == false)
+ 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, /* get_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 nlmNAME(i386_vec)
+#define TARGET_BACKEND_DATA &nlm32_i386_backend
+
+#include "nlm-target.h"
diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c
new file mode 100644
index 00000000000..ecf2de8f10b
--- /dev/null
+++ b/bfd/nlm32-ppc.c
@@ -0,0 +1,1045 @@
+/* Support for 32-bit PowerPC NLM (NetWare Loadable Module)
+ Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.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
+static boolean nlm_powerpc_backend_object_p
+ PARAMS ((bfd *));
+static boolean nlm_powerpc_write_prefix
+ PARAMS ((bfd *));
+#endif
+
+static boolean nlm_powerpc_read_reloc
+ PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
+static boolean nlm_powerpc_mangle_relocs
+ PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
+static boolean nlm_powerpc_read_import
+ PARAMS ((bfd *, nlmNAME(symbol_type) *));
+
+#ifdef OLDFORMAT
+static boolean nlm_powerpc_write_reloc
+ PARAMS ((bfd *, asection *, arelent *, int));
+#endif
+
+static boolean nlm_powerpc_write_import
+ PARAMS ((bfd *, asection *, arelent *));
+static boolean nlm_powerpc_write_external
+ PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
+
+#ifndef OLDFORMAT
+static boolean nlm_powerpc_set_public_section
+ PARAMS ((bfd *, nlmNAME(symbol_type) *));
+static bfd_vma nlm_powerpc_get_public_offset
+ PARAMS ((bfd *, asymbol *));
+#endif
+
+#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 boolean
+nlm_powerpc_backend_object_p (abfd)
+ bfd *abfd;
+{
+ struct nlm32_powerpc_external_prefix_header s;
+
+ if (bfd_read ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ return false;
+
+ if (memcmp (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature) != 0
+ || bfd_h_get_32 (abfd, s.headerVersion) != NLM32_POWERPC_HEADER_VERSION)
+ return false;
+
+ return true;
+}
+
+/* Write out the prefix. */
+
+static boolean
+nlm_powerpc_write_prefix (abfd)
+ bfd *abfd;
+{
+ struct nlm32_powerpc_external_prefix_header s;
+
+ memset (&s, 0, sizeof s);
+ memcpy (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature);
+ bfd_h_put_32 (abfd, (bfd_vma) NLM32_POWERPC_HEADER_VERSION, s.headerVersion);
+ bfd_h_put_32 (abfd, (bfd_vma) 0, s.origins);
+
+ /* FIXME: What should we do about the date? */
+
+ if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ return false;
+
+ return true;
+}
+
+#endif /* OLDFORMAT */
+
+#ifndef 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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false); /* pcrel_offset */
+
+/* Read a PowerPC NLM reloc. */
+
+static boolean
+nlm_powerpc_read_reloc (abfd, sym, secp, rel)
+ bfd *abfd;
+ nlmNAME(symbol_type) *sym;
+ asection **secp;
+ arelent *rel;
+{
+ bfd_byte temp[4];
+ bfd_vma val;
+ const char *name;
+
+ if (bfd_read (temp, sizeof (temp), 1, 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;
+}
+
+#else /* OLDFORMAT */
+
+/* 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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_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, /* src_mask */
+ 0xffff, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+#define HOWTO_COUNT (sizeof nlm_powerpc_howto_table \
+ / sizeof nlm_powerpc_howto_table[0])
+
+/* Read a PowerPC NLM reloc. */
+
+static boolean
+nlm_powerpc_read_reloc (abfd, sym, secp, rel)
+ 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_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ return false;
+
+ /* Swap in the fields. */
+ l_vaddr = bfd_h_get_32 (abfd, ext.l_vaddr);
+ l_symndx = bfd_h_get_32 (abfd, ext.l_symndx);
+ l_rtype = bfd_h_get_16 (abfd, ext.l_rtype);
+ l_rsecnm = bfd_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 -= bfd_section_size (abfd, code_sec);
+ }
+ else
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ rel->address = l_vaddr;
+
+ return true;
+}
+
+#endif /* OLDFORMAT */
+
+/* Mangle PowerPC NLM relocs for output. */
+
+static boolean
+nlm_powerpc_mangle_relocs (abfd, sec, data, offset, count)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+ bfd_vma offset;
+ bfd_size_type count;
+{
+ return true;
+}
+
+/* Read a PowerPC NLM import record */
+
+static boolean
+nlm_powerpc_read_import (abfd, sym)
+ 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_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength))
+ return (false);
+ sym -> symbol.the_bfd = abfd;
+ name = bfd_alloc (abfd, symlength + 1);
+ if (name == NULL)
+ return false;
+ if (bfd_read (name, symlength, 1, 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_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return (false);
+ rcount = bfd_h_get_32 (abfd, temp);
+ nlm_relocs = ((struct nlm_relent *)
+ bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
+ if (nlm_relocs == (struct nlm_relent *) 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)
+ == false)
+ return false;
+ nlm_relocs -> section = section;
+ nlm_relocs++;
+ sym -> rcnt++;
+ }
+ return true;
+}
+
+#ifndef OLDFORMAT
+
+/* Write a PowerPC NLM reloc. */
+
+static boolean
+nlm_powerpc_write_import (abfd, sec, rel)
+ 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_write (temp, sizeof (temp), 1, 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 boolean
+nlm_powerpc_write_reloc (abfd, sec, rel, indx)
+ 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;
+ }
+ }
+
+ bfd_h_put_32 (abfd, (bfd_vma) 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;
+ bfd_h_put_16 (abfd, (bfd_vma) l_rtype, ext.l_rtype);
+
+ address = rel->address;
+
+ if (sec == code_sec)
+ l_rsecnm = 0;
+ else if (sec == data_sec)
+ {
+ l_rsecnm = 1;
+ address += bfd_section_size (abfd, code_sec);
+ }
+ else
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ bfd_h_put_16 (abfd, (bfd_vma) l_rsecnm, ext.l_rsecnm);
+ bfd_h_put_32 (abfd, (bfd_vma) address, ext.l_vaddr);
+
+ if (bfd_write (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ return false;
+
+ return true;
+}
+
+/* Write a PowerPC NLM import. */
+
+static boolean
+nlm_powerpc_write_import (abfd, sec, rel)
+ 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 boolean
+nlm_powerpc_write_external (abfd, count, sym, relocs)
+ 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_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
+ || bfd_write (sym->name, len, 1, abfd) != len)
+ return false;
+
+ bfd_put_32 (abfd, count, temp);
+ if (bfd_write (temp, sizeof(temp), 1, 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 boolean
+nlm_powerpc_set_public_section (abfd, sym)
+ 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 (abfd, sym)
+ 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 nlmNAME(powerpc_vec)
+#define TARGET_BACKEND_DATA &nlm32_powerpc_backend
+
+#include "nlm-target.h"
diff --git a/bfd/nlm32-sparc.c b/bfd/nlm32-sparc.c
new file mode 100644
index 00000000000..5963adbc70b
--- /dev/null
+++ b/bfd/nlm32-sparc.c
@@ -0,0 +1,440 @@
+/* Support for 32-bit SPARC NLM (NetWare Loadable Module)
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.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"
+
+static boolean nlm_sparc_read_reloc
+ PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
+static boolean nlm_sparc_write_reloc
+ PARAMS ((bfd *, asection *, arelent *));
+static boolean nlm_sparc_mangle_relocs
+ PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
+static boolean nlm_sparc_read_import
+ PARAMS ((bfd *, nlmNAME(symbol_type) *));
+static boolean nlm_sparc_write_import
+ PARAMS ((bfd *, asection *, arelent *));
+static boolean nlm_sparc_write_external
+ PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
+
+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
+ };
+
+#if 0
+static CONST char *CONST reloc_type_names[] =
+{
+ "R_SPARC_NONE",
+ "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",
+};
+#endif
+
+static reloc_howto_type nlm32_sparc_howto_table[] =
+{
+ HOWTO(R_SPARC_NONE, 0,0, 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 boolean
+nlm_sparc_read_reloc (abfd, sym, secp, rel)
+ bfd *abfd;
+ nlmNAME(symbol_type) *sym;
+ asection **secp;
+ arelent *rel;
+{
+ bfd_vma val, addend;
+ unsigned int index;
+ unsigned int type;
+ struct nlm32_sparc_reloc_ext tmp_reloc;
+ asection *code_sec, *data_sec;
+
+ if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12)
+ return false;
+
+ code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
+ data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_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 (index = 0;
+ index < sizeof(nlm32_sparc_howto_table) / sizeof(reloc_howto_type);
+ index++)
+ if (nlm32_sparc_howto_table[index].type == type) {
+ rel->howto = &nlm32_sparc_howto_table[index];
+ break;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "%s: address = %08lx, addend = %08lx, type = %d, howto = %08lx\n",
+ __FUNCTION__, rel->address, rel->addend, type, rel->howto);
+#endif
+ return true;
+
+}
+
+/* Write a NetWare sparc reloc. */
+
+static boolean
+nlm_sparc_write_reloc (abfd, sec, rel)
+ bfd *abfd;
+ asection *sec;
+ arelent *rel;
+{
+ bfd_vma val;
+ struct nlm32_sparc_reloc_ext tmp_reloc;
+ unsigned int index;
+ int type = -1;
+ reloc_howto_type *tmp;
+
+
+ for (index = 0;
+ index < sizeof (nlm32_sparc_howto_table) / sizeof(reloc_howto_type);
+ index++) {
+ tmp = &nlm32_sparc_howto_table[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. */
+#if 0
+ val = bfd_get_section_vma (abfd, (*rel->sym_ptr_ptr)->section) + rel->address;
+#else
+ val = bfd_get_section_vma (abfd, sec) + rel->address;
+#endif
+
+#ifdef DEBUG
+ fprintf (stderr, "%s: val = %08lx, addend = %08lx, type = %d\n",
+ __FUNCTION__, val, 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_write (&tmp_reloc, 12, 1, abfd) != 12)
+ return false;
+
+ return true;
+}
+
+/* Mangle relocs for SPARC NetWare. We can just use the standard
+ SPARC relocs. */
+
+static boolean
+nlm_sparc_mangle_relocs (abfd, sec, data, offset, count)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+ bfd_vma offset;
+ bfd_size_type count;
+{
+ return true;
+}
+
+/* Read a NetWare sparc import record */
+static boolean
+nlm_sparc_read_import (abfd, sym)
+ 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_read ((PTR) temp, 4, 1, abfd) != 4)
+ return false;
+
+ rcount = bfd_get_32 (abfd, temp);
+
+ /*
+ * Next, read in the length of the symbol
+ */
+
+ if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength))
+ return false;
+ sym -> symbol.the_bfd = abfd;
+ name = bfd_alloc (abfd, symlength + 1);
+ if (name == NULL)
+ return false;
+
+ /*
+ * Then read in the symbol
+ */
+
+ if (bfd_read (name, symlength, 1, 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 = ((struct nlm_relent *)
+ 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)
+ == false)
+ return false;
+ nlm_relocs -> section = section;
+ nlm_relocs++;
+ sym -> rcnt++;
+ }
+ return true;
+}
+
+static boolean
+nlm_sparc_write_import (abfd, sec, rel)
+ 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 = bfd_section_size (abfd, code);
+ } else if (symsec == bss) {
+ base = bfd_section_size (abfd, code) + bfd_section_size (abfd, data);
+ } else
+ base = 0;
+
+#ifdef DEBUG
+ fprintf (stderr, "%s: <%x, 1>\n\t",
+ __FUNCTION__, base + (*rel->sym_ptr_ptr)->value);
+#endif
+ bfd_put_32 (abfd, base + (*rel->sym_ptr_ptr)->value, temp);
+ if (bfd_write ((PTR)temp, 4, 1, abfd) != 4)
+ return false;
+ bfd_put_32 (abfd, 1, temp);
+ if (bfd_write ((PTR)temp, 4, 1, abfd) != 4)
+ return false;
+ if (nlm_sparc_write_reloc (abfd, sec, rel) == false)
+ return false;
+ return true;
+}
+
+/* Write out an external reference. */
+
+static boolean
+nlm_sparc_write_external (abfd, count, sym, relocs)
+ 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_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
+ return false;
+
+ len = strlen (sym->name);
+ if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
+ || bfd_write (sym->name, len, 1, abfd) != len)
+ return false;
+
+ for (i = 0; i < count; i++)
+ {
+ if (nlm_sparc_write_reloc (abfd, relocs[i].sec,
+ relocs[i].rel) == false)
+ return false;
+ }
+
+ return true;
+}
+
+static boolean
+nlm_sparc_write_export (abfd, sym, value)
+ bfd *abfd;
+ asymbol *sym;
+ bfd_vma value;
+{
+ bfd_byte len;
+ bfd_byte temp[4];
+
+#ifdef DEBUG
+ fprintf (stderr, "%s: <%x, %d, %s>\n",
+ __FUNCTION__, value, strlen (sym->name), sym->name);
+#endif
+ bfd_put_32 (abfd, value, temp);
+ len = strlen (sym->name);
+
+ if (bfd_write (temp, 4, 1, abfd) != 4
+ || bfd_write (&len, 1, 1, abfd) != 1
+ || bfd_write (sym->name, len, 1, 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 nlmNAME(sparc_vec)
+#define TARGET_BACKEND_DATA &nlm32_sparc_backend
+
+#include "nlm-target.h"
diff --git a/bfd/nlm32.c b/bfd/nlm32.c
new file mode 100644
index 00000000000..4730e4fd349
--- /dev/null
+++ b/bfd/nlm32.c
@@ -0,0 +1,21 @@
+/* NLM (NetWare Loadable Module) 32-bit executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 32
+#include "nlmcode.h"
diff --git a/bfd/nlm64.c b/bfd/nlm64.c
new file mode 100644
index 00000000000..5dcd96a2b3c
--- /dev/null
+++ b/bfd/nlm64.c
@@ -0,0 +1,21 @@
+/* NLM (NetWare Loadable Module) 64-bit executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define ARCH_SIZE 64
+#include "nlmcode.h"
diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h
new file mode 100644
index 00000000000..63ac0c300f7
--- /dev/null
+++ b/bfd/nlmcode.h
@@ -0,0 +1,2056 @@
+/* NLM (NetWare Loadable Module) executable support for BFD.
+ Copyright (C) 1993, 94, 95, 1998 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, using ELF support as the
+ template.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.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_get_symtab nlmNAME(get_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)
+
+/* Forward declarations of static functions */
+
+static boolean add_bfd_section
+ PARAMS ((bfd *, char *, file_ptr, bfd_size_type, flagword));
+static boolean nlm_swap_variable_header_in
+ PARAMS ((bfd *));
+static boolean nlm_swap_variable_header_out
+ PARAMS ((bfd *));
+static boolean find_nonzero
+ PARAMS ((PTR, size_t));
+static boolean nlm_swap_auxiliary_headers_in
+ PARAMS ((bfd *));
+static boolean nlm_swap_auxiliary_headers_out
+ PARAMS ((bfd *));
+static boolean nlm_slurp_symbol_table
+ PARAMS ((bfd *));
+static boolean nlm_slurp_reloc_fixups
+ PARAMS ((bfd *));
+static boolean nlm_compute_section_file_positions
+ PARAMS ((bfd *));
+static int nlm_external_reloc_compare
+ PARAMS ((const void *, const void *));
+
+/* Should perhaps use put_offset, put_word, etc. For now, the two versions
+ can be handled by explicitly specifying 32 bits or "the long type". */
+#if ARCH_SIZE == 64
+#define put_word bfd_h_put_64
+#define get_word bfd_h_get_64
+#endif
+#if ARCH_SIZE == 32
+#define put_word bfd_h_put_32
+#define get_word bfd_h_get_32
+#endif
+
+const bfd_target *
+nlm_object_p (abfd)
+ bfd *abfd;
+{
+ struct nlm_obj_tdata *preserved_tdata = nlm_tdata (abfd);
+ boolean (*backend_object_p) PARAMS ((bfd *));
+ PTR x_fxdhdr = NULL;
+ Nlm_Internal_Fixed_Header *i_fxdhdrp;
+ struct nlm_obj_tdata *new_tdata = NULL;
+ const char *signature;
+ enum bfd_architecture arch;
+
+ /* 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. */
+
+ x_fxdhdr = (PTR) bfd_malloc ((size_t) nlm_fixed_header_size (abfd));
+ if (x_fxdhdr == NULL)
+ goto got_no_match;
+
+ if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) !=
+ nlm_fixed_header_size (abfd))
+ {
+ 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. */
+
+ new_tdata = ((struct nlm_obj_tdata *)
+ bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata)));
+ 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 endianess 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);
+}
+
+/* Add a section to the bfd. */
+
+static boolean
+add_bfd_section (abfd, name, offset, size, flags)
+ bfd *abfd;
+ char *name;
+ file_ptr offset;
+ bfd_size_type size;
+ flagword flags;
+{
+ asection *newsect;
+
+ newsect = bfd_make_section (abfd, name);
+ if (newsect == NULL)
+ {
+ return (false);
+ }
+ newsect->vma = 0; /* NLM's are relocatable. */
+ newsect->_raw_size = size;
+ newsect->filepos = offset;
+ newsect->flags = flags;
+ newsect->alignment_power = bfd_log2 (0); /* FIXME */
+ return (true);
+}
+
+/* Read and swap in the variable length header. All the fields must
+ exist in the NLM, and must exist in the order they are read here. */
+
+static boolean
+nlm_swap_variable_header_in (abfd)
+ bfd *abfd;
+{
+ unsigned char temp[NLM_TARGET_LONG_SIZE];
+
+ /* Read the description length and text members. */
+
+ if (bfd_read ((PTR) & nlm_variable_header (abfd)->descriptionLength,
+ sizeof (nlm_variable_header (abfd)->descriptionLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->descriptionLength))
+ return (false);
+ if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
+ nlm_variable_header (abfd)->descriptionLength + 1,
+ 1, abfd) !=
+ (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
+ return (false);
+
+ /* Read and convert the stackSize field. */
+
+ if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return (false);
+ nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp);
+
+ /* Read and convert the reserved field. */
+
+ if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return (false);
+ nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp);
+
+ /* Read the oldThreadName field. This field is a fixed length string. */
+
+ if (bfd_read ((PTR) nlm_variable_header (abfd)->oldThreadName,
+ sizeof (nlm_variable_header (abfd)->oldThreadName),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->oldThreadName))
+ return (false);
+
+ /* Read the screen name length and text members. */
+
+ if (bfd_read ((PTR) & nlm_variable_header (abfd)->screenNameLength,
+ sizeof (nlm_variable_header (abfd)->screenNameLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->screenNameLength))
+ return (false);
+ if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
+ nlm_variable_header (abfd)->screenNameLength + 1,
+ 1, abfd) !=
+ (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
+ return (false);
+
+ /* Read the thread name length and text members. */
+
+ if (bfd_read ((PTR) & nlm_variable_header (abfd)->threadNameLength,
+ sizeof (nlm_variable_header (abfd)->threadNameLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->threadNameLength))
+ return (false);
+ if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
+ nlm_variable_header (abfd)->threadNameLength + 1,
+ 1, abfd) !=
+ (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
+ return (false);
+ return (true);
+}
+
+/* Swap and write out the variable length header. All the fields must
+ exist in the NLM, and must exist in this order. */
+
+static boolean
+nlm_swap_variable_header_out (abfd)
+ bfd *abfd;
+{
+ unsigned char temp[NLM_TARGET_LONG_SIZE];
+
+ /* Write the description length and text members. */
+
+ if (bfd_write ((PTR) & nlm_variable_header (abfd)->descriptionLength,
+ sizeof (nlm_variable_header (abfd)->descriptionLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->descriptionLength))
+ return (false);
+ if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
+ nlm_variable_header (abfd)->descriptionLength + 1,
+ 1, abfd) !=
+ (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
+ return (false);
+
+ /* Convert and write the stackSize field. */
+
+ put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize,
+ (bfd_byte *) temp);
+ if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return (false);
+
+ /* Convert and write the reserved field. */
+
+ put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved,
+ (bfd_byte *) temp);
+ if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ return (false);
+
+ /* Write the oldThreadName field. This field is a fixed length string. */
+
+ if (bfd_write ((PTR) nlm_variable_header (abfd)->oldThreadName,
+ sizeof (nlm_variable_header (abfd)->oldThreadName),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->oldThreadName))
+ return (false);
+
+ /* Write the screen name length and text members. */
+
+ if (bfd_write ((PTR) & nlm_variable_header (abfd)->screenNameLength,
+ sizeof (nlm_variable_header (abfd)->screenNameLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->screenNameLength))
+ return (false);
+ if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
+ nlm_variable_header (abfd)->screenNameLength + 1,
+ 1, abfd) !=
+ (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
+ return (false);
+
+ /* Write the thread name length and text members. */
+
+ if (bfd_write ((PTR) & nlm_variable_header (abfd)->threadNameLength,
+ sizeof (nlm_variable_header (abfd)->threadNameLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd)->threadNameLength))
+ return (false);
+ if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
+ nlm_variable_header (abfd)->threadNameLength + 1,
+ 1, abfd) !=
+ (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
+ return (false);
+ return (true);
+}
+
+/* Read and swap in the contents of all the auxiliary headers. Because of
+ the braindead design, we have to do strcmps on strings of indeterminate
+ length to figure out what each auxiliary header is. Even worse, we have
+ no way of knowing how many auxiliary headers there are or where the end
+ of the auxiliary headers are, except by finding something that doesn't
+ look like a known auxiliary header. This means that the first new type
+ of auxiliary header added will break all existing tools that don't
+ recognize it. */
+
+static boolean
+nlm_swap_auxiliary_headers_in (abfd)
+ bfd *abfd;
+{
+ char tempstr[16];
+ long position;
+
+ for (;;)
+ {
+ position = bfd_tell (abfd);
+ if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=
+ sizeof (tempstr))
+ return (false);
+ if (bfd_seek (abfd, position, SEEK_SET) == -1)
+ return (false);
+ if (strncmp (tempstr, "VeRsIoN#", 8) == 0)
+ {
+ Nlm_External_Version_Header thdr;
+ if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ return (false);
+ memcpy (nlm_version_header (abfd)->stamp, thdr.stamp,
+ sizeof (thdr.stamp));
+ nlm_version_header (abfd)->majorVersion =
+ get_word (abfd, (bfd_byte *) thdr.majorVersion);
+ nlm_version_header (abfd)->minorVersion =
+ get_word (abfd, (bfd_byte *) thdr.minorVersion);
+ nlm_version_header (abfd)->revision =
+ get_word (abfd, (bfd_byte *) thdr.revision);
+ nlm_version_header (abfd)->year =
+ get_word (abfd, (bfd_byte *) thdr.year);
+ nlm_version_header (abfd)->month =
+ get_word (abfd, (bfd_byte *) thdr.month);
+ nlm_version_header (abfd)->day =
+ get_word (abfd, (bfd_byte *) thdr.day);
+ }
+ else if (strncmp (tempstr, "MeSsAgEs", 8) == 0)
+ {
+ Nlm_External_Extended_Header thdr;
+ if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ 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 (strncmp (tempstr, "CoPyRiGhT=", 10) == 0)
+ {
+ if (bfd_read ((PTR) nlm_copyright_header (abfd)->stamp,
+ sizeof (nlm_copyright_header (abfd)->stamp),
+ 1, abfd)
+ != sizeof (nlm_copyright_header (abfd)->stamp))
+ return (false);
+ if (bfd_read ((PTR) & (nlm_copyright_header (abfd)
+ ->copyrightMessageLength),
+ 1, 1, abfd) != 1)
+ return (false);
+ /* The copyright message is a variable length string. */
+ if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
+ nlm_copyright_header (abfd)->copyrightMessageLength + 1,
+ 1, abfd) !=
+ ((bfd_size_type)
+ nlm_copyright_header (abfd)->copyrightMessageLength + 1))
+ return (false);
+ }
+ else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
+ {
+ Nlm_External_Custom_Header thdr;
+ bfd_size_type hdrLength;
+ file_ptr dataOffset;
+ bfd_size_type dataLength;
+ char dataStamp[8];
+ PTR hdr;
+
+ /* Read the stamp ("CuStHeAd"). */
+ if (bfd_read ((PTR) thdr.stamp, 1, sizeof (thdr.stamp), abfd)
+ != sizeof (thdr.stamp))
+ return false;
+ /* Read the length of this custom header. */
+ if (bfd_read ((PTR) thdr.length, 1, sizeof (thdr.length), abfd)
+ != sizeof (thdr.length))
+ 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
+ {
+ if (bfd_read ((PTR) thdr.dataOffset, 1,
+ sizeof (thdr.dataOffset), abfd)
+ != sizeof (thdr.dataOffset))
+ return false;
+ dataOffset = get_word (abfd, (bfd_byte *) thdr.dataOffset);
+ }
+ if (hdrLength < 2 * NLM_TARGET_LONG_SIZE)
+ dataLength = 0;
+ else
+ {
+ if (bfd_read ((PTR) thdr.dataLength, 1,
+ sizeof (thdr.dataLength), abfd)
+ != sizeof (thdr.dataLength))
+ return false;
+ dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength);
+ }
+ if (hdrLength < 2 * NLM_TARGET_LONG_SIZE + 8)
+ memset (dataStamp, 0, sizeof (dataStamp));
+ else
+ {
+ if (bfd_read ((PTR) dataStamp, 1, sizeof (dataStamp), abfd)
+ != sizeof (dataStamp))
+ 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_read (hdr, 1, 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 (strncmp (dataStamp, "CyGnUsEx", 8) == 0)
+ {
+ file_ptr pos;
+ bfd_byte *contents;
+ bfd_byte *p, *pend;
+
+ BFD_ASSERT (hdrLength == 0 && hdr == NULL);
+
+ pos = bfd_tell (abfd);
+ if (bfd_seek (abfd, dataOffset, SEEK_SET) != 0)
+ return false;
+ contents = (bfd_byte *) bfd_alloc (abfd, dataLength);
+ if (contents == NULL)
+ return false;
+ if (bfd_read (contents, 1, dataLength, abfd) != dataLength)
+ return false;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
+ return false;
+
+ memcpy (nlm_cygnus_ext_header (abfd), "CyGnUsEx", 8);
+ 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) &~ 3;
+ p += l;
+ filepos = bfd_h_get_32 (abfd, p);
+ p += 4;
+ size = bfd_h_get_32 (abfd, p);
+ p += 4;
+
+ newsec = bfd_make_section_anyway (abfd, name);
+ if (newsec == (asection *) NULL)
+ return false;
+ newsec->_raw_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);
+}
+
+/* Return whether there is a non-zero byte in a memory block. */
+
+static boolean
+find_nonzero (buf, size)
+ PTR 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 boolean
+nlm_swap_auxiliary_headers_out (abfd)
+ bfd *abfd;
+{
+ /* Write out the version header if there is one. */
+ if (find_nonzero ((PTR) nlm_version_header (abfd),
+ sizeof (Nlm_Internal_Version_Header)))
+ {
+ Nlm_External_Version_Header thdr;
+
+ memcpy (thdr.stamp, "VeRsIoN#", 8);
+ 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_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ return false;
+ }
+
+ /* Write out the extended header if there is one. */
+ if (find_nonzero ((PTR) nlm_extended_header (abfd),
+ sizeof (Nlm_Internal_Extended_Header)))
+ {
+ Nlm_External_Extended_Header thdr;
+
+ memcpy (thdr.stamp, "MeSsAgEs", 8);
+ 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_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ return false;
+ }
+
+
+ /* Write out the copyright header if there is one. */
+ if (find_nonzero ((PTR) nlm_copyright_header (abfd),
+ sizeof (Nlm_Internal_Copyright_Header)))
+ {
+ Nlm_External_Copyright_Header thdr;
+
+ memcpy (thdr.stamp, "CoPyRiGhT=", 10);
+ if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd)
+ != sizeof (thdr.stamp))
+ return false;
+ thdr.copyrightMessageLength[0] =
+ nlm_copyright_header (abfd)->copyrightMessageLength;
+ if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1)
+ return false;
+ /* The copyright message is a variable length string. */
+ if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
+ nlm_copyright_header (abfd)->copyrightMessageLength + 1,
+ 1, abfd) !=
+ ((bfd_size_type)
+ nlm_copyright_header (abfd)->copyrightMessageLength + 1))
+ return false;
+ }
+
+ /* Write out the custom header if there is one. */
+ if (find_nonzero ((PTR) nlm_custom_header (abfd),
+ sizeof (Nlm_Internal_Custom_Header)))
+ {
+ Nlm_External_Custom_Header thdr;
+ boolean ds;
+ bfd_size_type hdrLength;
+
+ ds = find_nonzero ((PTR) nlm_custom_header (abfd)->dataStamp,
+ sizeof (nlm_custom_header (abfd)->dataStamp));
+ memcpy (thdr.stamp, "CuStHeAd", 8);
+ 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);
+ if (bfd_write ((PTR) &thdr, 1,
+ sizeof (thdr) - sizeof (thdr.dataStamp), abfd)
+ != sizeof (thdr) - sizeof (thdr.dataStamp))
+ return false;
+ }
+ else
+ {
+ memcpy (thdr.dataStamp, nlm_custom_header (abfd)->dataStamp,
+ sizeof (thdr.dataStamp));
+ if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ return false;
+ if (bfd_write (nlm_custom_header (abfd)->hdr, 1,
+ nlm_custom_header (abfd)->hdrLength, abfd)
+ != nlm_custom_header (abfd)->hdrLength)
+ return false;
+ }
+ }
+
+ /* Write out the Cygnus debugging header if there is one. */
+ if (find_nonzero ((PTR) nlm_cygnus_ext_header (abfd),
+ sizeof (Nlm_Internal_Cygnus_Ext_Header)))
+ {
+ Nlm_External_Custom_Header thdr;
+
+ memcpy (thdr.stamp, "CuStHeAd", 8);
+ 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);
+ memcpy (thdr.dataStamp, "CyGnUsEx", 8);
+ if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ 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 (abfd)
+ 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);
+}
+
+/* Note that bfd_get_symcount is guaranteed to be zero if slurping the
+ symbol table fails. */
+
+long
+nlm_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ nlm_symbol_type *symbase;
+ bfd_size_type counter = 0;
+
+ if (nlm_slurp_symbol_table (abfd) == false)
+ return -1;
+ symbase = nlm_get_symbols (abfd);
+ while (counter < bfd_get_symcount (abfd))
+ {
+ *alocation++ = &symbase->symbol;
+ symbase++;
+ counter++;
+ }
+ *alocation = (asymbol *) NULL;
+ return bfd_get_symcount (abfd);
+}
+
+/* Make an NLM symbol. There is nothing special to do here. */
+
+asymbol *
+nlm_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ nlm_symbol_type *new;
+
+ new = (nlm_symbol_type *) bfd_zalloc (abfd, sizeof (nlm_symbol_type));
+ if (new)
+ new->symbol.the_bfd = abfd;
+ return &new->symbol;
+}
+
+/* Get symbol information. */
+
+void
+nlm_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+/* Print symbol information. */
+
+void
+nlm_print_symbol (abfd, afile, symbol, how)
+ bfd *abfd;
+ PTR 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 ((PTR) file, symbol);
+ fprintf (file, " %-5s", symbol->section->name);
+ if (symbol->name)
+ fprintf (file, " %s", symbol->name);
+ break;
+ }
+}
+
+/* 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 SYMPTRS.
+
+ When we return, the bfd symcount is either zero or contains the correct
+ number of symbols.
+*/
+
+static boolean
+nlm_slurp_symbol_table (abfd)
+ 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 */
+ boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *));
+ boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *));
+
+ 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) == -1)
+ return (false);
+
+ sym = ((nlm_symbol_type *)
+ bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
+ 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)
+ {
+ if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength))
+ return (false);
+ sym->symbol.the_bfd = abfd;
+ sym->symbol.name = bfd_alloc (abfd, symlength + 1);
+ if (!sym->symbol.name)
+ return false;
+ if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
+ != symlength)
+ return (false);
+ /* Cast away const. */
+ ((char *) (sym->symbol.name))[symlength] = '\0';
+ if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ 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) == false)
+ 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) == -1)
+ return (false);
+
+ symcount += i_fxdhdrp->numberOfDebugRecords;
+ while (abfd->symcount < symcount)
+ {
+ if ((bfd_read ((PTR) & symtype, sizeof (symtype), 1, abfd)
+ != sizeof (symtype))
+ || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)
+ || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength)))
+ return false;
+ sym->symbol.the_bfd = abfd;
+ sym->symbol.name = bfd_alloc (abfd, symlength + 1);
+ if (!sym->symbol.name)
+ return false;
+ if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
+ != symlength)
+ 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)
+ == -1)
+ return (false);
+
+ symcount += i_fxdhdrp->numberOfExternalReferences;
+ while (abfd->symcount < symcount)
+ {
+ if ((*read_import_func) (abfd, sym) == false)
+ return false;
+ sym++;
+ abfd->symcount++;
+ }
+ }
+
+ return (true);
+}
+
+/* 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 boolean
+nlm_slurp_reloc_fixups (abfd)
+ bfd *abfd;
+{
+ boolean (*read_func) PARAMS ((bfd *, nlm_symbol_type *, asection **,
+ arelent *));
+ bfd_size_type count;
+ 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;
+ rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
+ secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *));
+ 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, (nlm_symbol_type *) NULL, secs, rels) == false)
+ {
+ 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 (abfd, sec)
+ 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) == false)
+ 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 (abfd, sec, relptr, symbols)
+ bfd *abfd;
+ asection *sec;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *rels;
+ asection **secs;
+ bfd_size_type count, i;
+ unsigned int ret;
+
+ /* Get the relocation fixups. */
+ rels = nlm_relocation_fixups (abfd);
+ if (rels == NULL)
+ {
+ if (nlm_slurp_reloc_fixups (abfd) == false)
+ 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 boolean
+nlm_compute_section_file_positions (abfd)
+ 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 == true)
+ 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 ((PTR) nlm_version_header (abfd),
+ sizeof (Nlm_Internal_Version_Header)))
+ sofar += sizeof (Nlm_External_Version_Header);
+ if (find_nonzero ((PTR) nlm_extended_header (abfd),
+ sizeof (Nlm_Internal_Extended_Header)))
+ sofar += sizeof (Nlm_External_Extended_Header);
+ if (find_nonzero ((PTR) nlm_copyright_header (abfd),
+ sizeof (Nlm_Internal_Copyright_Header)))
+ sofar += (sizeof (Nlm_External_Copyright_Header)
+ + nlm_copyright_header (abfd)->copyrightMessageLength + 1);
+ if (find_nonzero ((PTR) nlm_custom_header (abfd),
+ sizeof (Nlm_Internal_Custom_Header)))
+ sofar += (sizeof (Nlm_External_Custom_Header)
+ + nlm_custom_header (abfd)->hdrLength);
+ if (find_nonzero ((PTR) 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 != (asection *) NULL; sec = sec->next)
+ {
+ flagword f;
+
+ sec->_raw_size = BFD_ALIGN (sec->_raw_size, 1 << sec->alignment_power);
+
+ f = bfd_get_section_flags (abfd, sec);
+ if (f & SEC_CODE)
+ {
+ text += sec->_raw_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->_raw_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->_raw_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 != (asection *) NULL; sec = sec->next)
+ {
+ flagword f;
+
+ f = bfd_get_section_flags (abfd, sec);
+
+ if (f & SEC_CODE)
+ {
+ sec->filepos = text_ptr;
+ text_ptr += sec->_raw_size;
+ }
+ else if (f & SEC_DATA)
+ {
+ sec->filepos = data_ptr;
+ data_ptr += sec->_raw_size;
+ }
+ else if (f & SEC_HAS_CONTENTS)
+ {
+ sec->filepos = other_ptr;
+ other_ptr += sec->_raw_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->_raw_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->_raw_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. */
+
+boolean
+nlm_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (abfd->output_has_begun == false
+ && nlm_compute_section_file_positions (abfd) == false)
+ 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)
+ {
+ boolean (*mangle_relocs_func) PARAMS ((bfd *, asection *, PTR,
+ 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, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
+ || bfd_write (location, 1, 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 (p1, p2)
+ 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. */
+
+boolean
+nlm_write_object_contents (abfd)
+ bfd *abfd;
+{
+ asection *sec;
+ boolean (*write_import_func) PARAMS ((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;
+ boolean (*write_prefix_func) PARAMS ((bfd *));
+ unsigned char *fixed_header = NULL;
+
+ fixed_header = ((unsigned char *)
+ bfd_malloc ((size_t) nlm_fixed_header_size (abfd)));
+ if (fixed_header == NULL)
+ goto error_return;
+
+ if (abfd->output_has_begun == false
+ && nlm_compute_section_file_positions (abfd) == false)
+ goto error_return;
+
+ /* Write out the variable length headers. */
+ if (bfd_seek (abfd,
+ nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd),
+ SEEK_SET) != 0)
+ goto error_return;
+ if (nlm_swap_variable_header_out (abfd) == false
+ || nlm_swap_auxiliary_headers_out (abfd) == false)
+ {
+ 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 != (asection *) 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) == false)
+ 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. */
+ external_relocs =
+ (struct reloc_and_sec *) bfd_alloc (abfd,
+ (external_reloc_count
+ * sizeof (struct reloc_and_sec)));
+ if (external_relocs == (struct reloc_and_sec *) NULL)
+ goto error_return;
+ i = 0;
+ for (sec = abfd->sections; sec != (asection *) 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 ((PTR) 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])
+ == false)
+ 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 != (asymbol **) NULL)
+ {
+ bfd_vma (*get_public_offset_func) PARAMS ((bfd *, asymbol *));
+ boolean (*write_export_func) PARAMS ((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) == false)
+ goto error_return;
+ }
+ else
+ {
+ len = strlen (sym->name);
+ if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
+ != sizeof (bfd_byte))
+ || bfd_write (sym->name, len, 1, abfd) != len)
+ goto error_return;
+
+ put_word (abfd, offset, temp);
+ if (bfd_write (temp, sizeof (temp), 1, 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_write (&type, sizeof (bfd_byte), 1, abfd)
+ != sizeof (bfd_byte))
+ goto error_return;
+
+ put_word (abfd, offset, temp);
+ if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ goto error_return;
+
+ len = strlen (sym->name);
+ if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
+ != sizeof (bfd_byte))
+ || bfd_write (sym->name, len, 1, 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, 0, SEEK_SET) != 0)
+ goto error_return;
+
+ write_prefix_func = nlm_write_prefix_func (abfd);
+ if (write_prefix_func)
+ {
+ if ((*write_prefix_func) (abfd) == false)
+ 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_write (fixed_header, nlm_fixed_header_size (abfd), 1, 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
new file mode 100644
index 00000000000..5a9ce7268d0
--- /dev/null
+++ b/bfd/nlmswap.h
@@ -0,0 +1,157 @@
+/* NLM (NetWare Loadable Module) swapping routines for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, using ELF support as the
+ template.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. */
+
+static void nlm_swap_fixed_header_in PARAMS ((bfd *, PTR,
+ Nlm_Internal_Fixed_Header *));
+static void nlm_swap_fixed_header_out PARAMS ((bfd *,
+ Nlm_Internal_Fixed_Header *,
+ PTR));
+
+/* 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 (abfd, realsrc, dst)
+ bfd *abfd;
+ PTR 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 =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->version);
+ dst->codeImageOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageOffset);
+ dst->codeImageSize =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageSize);
+ dst->dataImageOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageOffset);
+ dst->dataImageSize =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageSize);
+ dst->uninitializedDataSize =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->uninitializedDataSize);
+ dst->customDataOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->customDataOffset);
+ dst->customDataSize =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->customDataSize);
+ dst->moduleDependencyOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->moduleDependencyOffset);
+ dst->numberOfModuleDependencies =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfModuleDependencies);
+ dst->relocationFixupOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->relocationFixupOffset);
+ dst->numberOfRelocationFixups =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfRelocationFixups);
+ dst->externalReferencesOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->externalReferencesOffset);
+ dst->numberOfExternalReferences =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfExternalReferences);
+ dst->publicsOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->publicsOffset);
+ dst->numberOfPublics =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfPublics);
+ dst->debugInfoOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->debugInfoOffset);
+ dst->numberOfDebugRecords =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfDebugRecords);
+ dst->codeStartOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->codeStartOffset);
+ dst->exitProcedureOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->exitProcedureOffset);
+ dst->checkUnloadProcedureOffset =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->checkUnloadProcedureOffset);
+ dst->moduleType =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->moduleType);
+ dst->flags =
+ bfd_h_get_32 (abfd, (bfd_byte *) 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 (abfd, src, realdst)
+ bfd *abfd;
+ Nlm_Internal_Fixed_Header *src;
+ PTR 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);
+ bfd_h_put_32 (abfd, (bfd_vma) src->version,
+ (bfd_byte *) dst->version);
+ bfd_h_put_32 (abfd, (bfd_vma) src->codeImageOffset,
+ (bfd_byte *) dst->codeImageOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->codeImageSize,
+ (bfd_byte *) dst->codeImageSize);
+ bfd_h_put_32 (abfd, (bfd_vma) src->dataImageOffset,
+ (bfd_byte *) dst->dataImageOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->dataImageSize,
+ (bfd_byte *) dst->dataImageSize);
+ bfd_h_put_32 (abfd, (bfd_vma) src->uninitializedDataSize,
+ (bfd_byte *) dst->uninitializedDataSize);
+ bfd_h_put_32 (abfd, (bfd_vma) src->customDataOffset,
+ (bfd_byte *) dst->customDataOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->customDataSize,
+ (bfd_byte *) dst->customDataSize);
+ bfd_h_put_32 (abfd, (bfd_vma) src->moduleDependencyOffset,
+ (bfd_byte *) dst->moduleDependencyOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->numberOfModuleDependencies,
+ (bfd_byte *) dst->numberOfModuleDependencies);
+ bfd_h_put_32 (abfd, (bfd_vma) src->relocationFixupOffset,
+ (bfd_byte *) dst->relocationFixupOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->numberOfRelocationFixups,
+ (bfd_byte *) dst->numberOfRelocationFixups);
+ bfd_h_put_32 (abfd, (bfd_vma) src->externalReferencesOffset,
+ (bfd_byte *) dst->externalReferencesOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->numberOfExternalReferences,
+ (bfd_byte *) dst->numberOfExternalReferences);
+ bfd_h_put_32 (abfd, (bfd_vma) src->publicsOffset,
+ (bfd_byte *) dst->publicsOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->numberOfPublics,
+ (bfd_byte *) dst->numberOfPublics);
+ bfd_h_put_32 (abfd, (bfd_vma) src->debugInfoOffset,
+ (bfd_byte *) dst->debugInfoOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->numberOfDebugRecords,
+ (bfd_byte *) dst->numberOfDebugRecords);
+ bfd_h_put_32 (abfd, (bfd_vma) src->codeStartOffset,
+ (bfd_byte *) dst->codeStartOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->exitProcedureOffset,
+ (bfd_byte *) dst->exitProcedureOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->checkUnloadProcedureOffset,
+ (bfd_byte *) dst->checkUnloadProcedureOffset);
+ bfd_h_put_32 (abfd, (bfd_vma) src->moduleType,
+ (bfd_byte *) dst->moduleType);
+ bfd_h_put_32 (abfd, (bfd_vma) src->flags,
+ (bfd_byte *) dst->flags);
+}
diff --git a/bfd/ns32k.h b/bfd/ns32k.h
new file mode 100644
index 00000000000..d63ba096219
--- /dev/null
+++ b/bfd/ns32k.h
@@ -0,0 +1,41 @@
+/* Header file for ns32k routines.
+ Copyright 1996 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+extern bfd_reloc_status_type _bfd_ns32k_relocate_contents
+ PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
+
+extern bfd_reloc_status_type _bfd_do_ns32k_reloc_contents
+ PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *,
+ long (*) PARAMS ((bfd_byte *, long, long)),
+ int (*) PARAMS ((long, bfd_byte *, long, long))));
+
+extern bfd_reloc_status_type _bfd_ns32k_final_link_relocate
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma,
+ bfd_vma, bfd_vma));
+
+extern long _bfd_ns32k_get_displacement PARAMS ((bfd_byte *, long, long));
+extern long _bfd_ns32k_get_immediate PARAMS ((bfd_byte *, long, long));
+extern int _bfd_ns32k_put_displacement PARAMS ((long, bfd_byte *, long, long));
+extern int _bfd_ns32k_put_immediate PARAMS ((long, bfd_byte *, long, long));
+
+extern bfd_reloc_status_type _bfd_ns32k_reloc_disp
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern bfd_reloc_status_type _bfd_ns32k_reloc_imm
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
diff --git a/bfd/ns32knetbsd.c b/bfd/ns32knetbsd.c
new file mode 100644
index 00000000000..a22356df6e1
--- /dev/null
+++ b/bfd/ns32knetbsd.c
@@ -0,0 +1,53 @@
+/* BFD back-end for NetBSD/ns32k a.out-ish binaries.
+ Copyright (C) 1990, 91, 92, 94, 95, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#undef TARGET_IS_BIG_ENDIAN_P
+
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE 4096
+
+#define DEFAULT_ARCH bfd_arch_ns32k
+#define DEFAULT_MID M_532_NETBSD
+
+#define MY(OP) CAT(pc532netbsd_,OP)
+
+#define NAME(x,y) CAT3(ns32kaout,_32_,y)
+
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-ns32k-netbsd"
+
+#define ns32kaout_32_get_section_contents aout_32_get_section_contents
+
+#define MY_text_includes_header 1
+
+/* We can`t use the MYNS macro here for cpp reasons too subtle
+ * for me -- IWD
+ */
+#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
+
+#include "bfd.h" /* To ensure following declaration is OK */
+
+CONST struct reloc_howto_struct *
+MY_bfd_reloc_type_lookup
+ PARAMS((bfd *abfd AND
+ bfd_reloc_code_real_type code));
+
+
+#include "netbsd.h"
diff --git a/bfd/oasys.c b/bfd/oasys.c
new file mode 100644
index 00000000000..b51560e47fa
--- /dev/null
+++ b/bfd/oasys.c
@@ -0,0 +1,1535 @@
+/* BFD back-end for oasys objects.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define UNDERSCORE_HACK 1
+#include "bfd.h"
+#include "sysdep.h"
+#include <ctype.h>
+#include "libbfd.h"
+#include "oasys.h"
+#include "liboasys.h"
+
+/* XXX - FIXME. offsetof belongs in the system-specific files in
+ ../include/sys. */
+/* Define offsetof for those systems which lack it */
+
+#ifndef offsetof
+#define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier)
+#endif
+
+static boolean oasys_read_record PARAMS ((bfd *,
+ oasys_record_union_type *));
+static boolean oasys_write_sections PARAMS ((bfd *));
+static boolean oasys_write_record PARAMS ((bfd *,
+ oasys_record_enum_type,
+ oasys_record_union_type *,
+ size_t));
+static boolean oasys_write_syms PARAMS ((bfd *));
+static boolean oasys_write_header PARAMS ((bfd *));
+static boolean oasys_write_end PARAMS ((bfd *));
+static boolean oasys_write_data PARAMS ((bfd *));
+
+/* Read in all the section data and relocation stuff too */
+PROTO (static boolean, oasys_slurp_section_data, (bfd * CONST abfd));
+
+static boolean
+oasys_read_record (abfd, record)
+ bfd *abfd;
+ oasys_record_union_type *record;
+{
+ if (bfd_read ((PTR) record, 1, sizeof (record->header), abfd)
+ != sizeof (record->header))
+ return false;
+
+ if ((size_t) record->header.length <= (size_t) sizeof (record->header))
+ return true;
+ if (bfd_read ((PTR) (((char *) record) + sizeof (record->header)),
+ 1, record->header.length - sizeof (record->header),
+ abfd)
+ != record->header.length - sizeof (record->header))
+ return false;
+ return true;
+}
+static size_t
+oasys_string_length (record)
+ oasys_record_union_type *record;
+{
+ return record->header.length
+ - ((char *) record->symbol.name - (char *) record);
+}
+
+/*****************************************************************************/
+
+/*
+
+Slurp the symbol table by reading in all the records at the start file
+till we get to the first section record.
+
+We'll sort the symbolss into two lists, defined and undefined. The
+undefined symbols will be placed into the table according to their
+refno.
+
+We do this by placing all undefined symbols at the front of the table
+moving in, and the defined symbols at the end of the table moving back.
+
+*/
+
+static boolean
+oasys_slurp_symbol_table (abfd)
+ bfd *CONST abfd;
+{
+ oasys_record_union_type record;
+ oasys_data_type *data = OASYS_DATA (abfd);
+ boolean loop = true;
+ asymbol *dest_defined;
+ asymbol *dest;
+ char *string_ptr;
+
+
+ if (data->symbols != (asymbol *) NULL)
+ {
+ return true;
+ }
+ /* Buy enough memory for all the symbols and all the names */
+ data->symbols =
+ (asymbol *) bfd_alloc (abfd, sizeof (asymbol) * abfd->symcount);
+#ifdef UNDERSCORE_HACK
+ /* buy 1 more char for each symbol to keep the underscore in*/
+ data->strings = bfd_alloc (abfd, data->symbol_string_length +
+ abfd->symcount);
+#else
+ data->strings = bfd_alloc (abfd, data->symbol_string_length);
+#endif
+ if (!data->symbols || !data->strings)
+ return false;
+
+ dest_defined = data->symbols + abfd->symcount - 1;
+
+ string_ptr = data->strings;
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
+ while (loop)
+ {
+
+ if (! oasys_read_record (abfd, &record))
+ return false;
+ switch (record.header.type)
+ {
+ case oasys_record_is_header_enum:
+ break;
+ case oasys_record_is_local_enum:
+ case oasys_record_is_symbol_enum:
+ {
+ int flag = record.header.type == (int) oasys_record_is_local_enum ?
+ (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
+
+
+ size_t length = oasys_string_length (&record);
+ switch (record.symbol.relb & RELOCATION_TYPE_BITS)
+ {
+ case RELOCATION_TYPE_ABS:
+ dest = dest_defined--;
+ dest->section = bfd_abs_section_ptr;
+ dest->flags = 0;
+
+ break;
+ case RELOCATION_TYPE_REL:
+ dest = dest_defined--;
+ dest->section =
+ OASYS_DATA (abfd)->sections[record.symbol.relb &
+ RELOCATION_SECT_BITS];
+ if (record.header.type == (int) oasys_record_is_local_enum)
+ {
+ dest->flags = BSF_LOCAL;
+ if (dest->section == (asection *) (~0))
+ {
+ /* It seems that sometimes internal symbols are tied up, but
+ still get output, even though there is no
+ section */
+ dest->section = 0;
+ }
+ }
+ else
+ {
+
+ dest->flags = flag;
+ }
+ break;
+ case RELOCATION_TYPE_UND:
+ dest = data->symbols + bfd_h_get_16 (abfd, record.symbol.refno);
+ dest->section = bfd_und_section_ptr;
+ break;
+ case RELOCATION_TYPE_COM:
+ dest = dest_defined--;
+ dest->name = string_ptr;
+ dest->the_bfd = abfd;
+
+ dest->section = bfd_com_section_ptr;
+
+ break;
+ default:
+ dest = dest_defined--;
+ BFD_ASSERT (0);
+ break;
+ }
+ dest->name = string_ptr;
+ dest->the_bfd = abfd;
+ dest->udata.p = (PTR) NULL;
+ dest->value = bfd_h_get_32 (abfd, record.symbol.value);
+
+#ifdef UNDERSCORE_HACK
+ if (record.symbol.name[0] != '_')
+ {
+ string_ptr[0] = '_';
+ string_ptr++;
+ }
+#endif
+ memcpy (string_ptr, record.symbol.name, length);
+
+
+ string_ptr[length] = 0;
+ string_ptr += length + 1;
+ }
+ break;
+ default:
+ loop = false;
+ }
+ }
+ return true;
+}
+
+static long
+oasys_get_symtab_upper_bound (abfd)
+ bfd *CONST abfd;
+{
+ if (! oasys_slurp_symbol_table (abfd))
+ return -1;
+
+ return (abfd->symcount + 1) * (sizeof (oasys_symbol_type *));
+}
+
+/*
+*/
+
+extern const bfd_target oasys_vec;
+
+long
+oasys_get_symtab (abfd, location)
+ bfd *abfd;
+ asymbol **location;
+{
+ asymbol *symbase;
+ unsigned int counter;
+ if (oasys_slurp_symbol_table (abfd) == false)
+ {
+ return -1;
+ }
+ symbase = OASYS_DATA (abfd)->symbols;
+ for (counter = 0; counter < abfd->symcount; counter++)
+ {
+ *(location++) = symbase++;
+ }
+ *location = 0;
+ return abfd->symcount;
+}
+
+/***********************************************************************
+* archive stuff
+*/
+
+static const bfd_target *
+oasys_archive_p (abfd)
+ bfd *abfd;
+{
+ oasys_archive_header_type header;
+ oasys_extarchive_header_type header_ext;
+ unsigned int i;
+ file_ptr filepos;
+
+ if (bfd_seek (abfd, (file_ptr) 0, false) != 0
+ || (bfd_read ((PTR) & header_ext, 1, sizeof (header_ext), abfd)
+ != sizeof (header_ext)))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ header.version = bfd_h_get_32 (abfd, header_ext.version);
+ header.mod_count = bfd_h_get_32 (abfd, header_ext.mod_count);
+ header.mod_tbl_offset = bfd_h_get_32 (abfd, header_ext.mod_tbl_offset);
+ header.sym_tbl_size = bfd_h_get_32 (abfd, header_ext.sym_tbl_size);
+ header.sym_count = bfd_h_get_32 (abfd, header_ext.sym_count);
+ header.sym_tbl_offset = bfd_h_get_32 (abfd, header_ext.sym_tbl_offset);
+ header.xref_count = bfd_h_get_32 (abfd, header_ext.xref_count);
+ header.xref_lst_offset = bfd_h_get_32 (abfd, header_ext.xref_lst_offset);
+
+ /*
+ There isn't a magic number in an Oasys archive, so the best we
+ can do to verify reasnableness is to make sure that the values in
+ the header are too weird
+ */
+
+ if (header.version > 10000 ||
+ header.mod_count > 10000 ||
+ header.sym_count > 100000 ||
+ header.xref_count > 100000)
+ return (const bfd_target *) NULL;
+
+ /*
+ That all worked, let's buy the space for the header and read in
+ the headers.
+ */
+ {
+ oasys_ar_data_type *ar =
+ (oasys_ar_data_type *) bfd_alloc (abfd, sizeof (oasys_ar_data_type));
+
+ oasys_module_info_type *module =
+ (oasys_module_info_type *)
+ bfd_alloc (abfd, sizeof (oasys_module_info_type) * header.mod_count);
+ oasys_module_table_type record;
+
+ if (!ar || !module)
+ return NULL;
+
+ abfd->tdata.oasys_ar_data = ar;
+ ar->module = module;
+ ar->module_count = header.mod_count;
+
+ filepos = header.mod_tbl_offset;
+ for (i = 0; i < header.mod_count; i++)
+ {
+ if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
+ return NULL;
+
+ /* There are two ways of specifying the archive header */
+
+ if (0)
+ {
+ oasys_extmodule_table_type_a_type record_ext;
+ if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
+ != sizeof (record_ext))
+ return NULL;
+
+ record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
+ record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
+
+ record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
+ record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
+ record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
+
+ module[i].name = bfd_alloc (abfd, 33);
+ if (!module[i].name)
+ return NULL;
+
+ memcpy (module[i].name, record_ext.mod_name, 33);
+ filepos +=
+ sizeof (record_ext) +
+ record.dep_count * 4 +
+ record.depee_count * 4 +
+ record.sect_count * 8 + 187;
+ }
+ else
+ {
+ oasys_extmodule_table_type_b_type record_ext;
+ if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
+ != sizeof (record_ext))
+ return NULL;
+
+ record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
+ record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
+
+ record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
+ record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
+ record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
+ record.module_name_size = bfd_h_get_32 (abfd, record_ext.mod_name_length);
+
+ module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
+ if (!module[i].name)
+ return NULL;
+ if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
+ abfd)
+ != record.module_name_size)
+ return NULL;
+ module[i].name[record.module_name_size] = 0;
+ filepos +=
+ sizeof (record_ext) +
+ record.dep_count * 4 +
+ record.module_name_size + 1;
+
+ }
+
+
+ module[i].size = record.mod_size;
+ module[i].pos = record.file_offset;
+ module[i].abfd = 0;
+ }
+
+ }
+ return abfd->xvec;
+}
+
+static boolean
+oasys_mkobject (abfd)
+ bfd *abfd;
+{
+
+ abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, sizeof (oasys_data_type));
+ return abfd->tdata.oasys_obj_data ? true : false;
+}
+
+#define MAX_SECS 16
+static const bfd_target *
+oasys_object_p (abfd)
+ bfd *abfd;
+{
+ oasys_data_type *oasys;
+ oasys_data_type *save = OASYS_DATA (abfd);
+ boolean loop = true;
+ boolean had_usefull = false;
+
+ abfd->tdata.oasys_obj_data = 0;
+ oasys_mkobject (abfd);
+ oasys = OASYS_DATA (abfd);
+ memset ((PTR) oasys->sections, 0xff, sizeof (oasys->sections));
+
+ /* Point to the start of the file */
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto fail;
+ oasys->symbol_string_length = 0;
+ /* Inspect the records, but only keep the section info -
+ remember the size of the symbols
+ */
+ oasys->first_data_record = 0;
+ while (loop)
+ {
+ oasys_record_union_type record;
+ if (! oasys_read_record (abfd, &record))
+ goto fail;
+ if ((size_t) record.header.length < (size_t) sizeof (record.header))
+ goto fail;
+
+
+ switch ((oasys_record_enum_type) (record.header.type))
+ {
+ case oasys_record_is_header_enum:
+ had_usefull = true;
+ break;
+ case oasys_record_is_symbol_enum:
+ case oasys_record_is_local_enum:
+ /* Count symbols and remember their size for a future malloc */
+ abfd->symcount++;
+ oasys->symbol_string_length += 1 + oasys_string_length (&record);
+ had_usefull = true;
+ break;
+ case oasys_record_is_section_enum:
+ {
+ asection *s;
+ char *buffer;
+ unsigned int section_number;
+ if (record.section.header.length != sizeof (record.section))
+ {
+ goto fail;
+ }
+ buffer = bfd_alloc (abfd, 3);
+ if (!buffer)
+ goto fail;
+ section_number = record.section.relb & RELOCATION_SECT_BITS;
+ sprintf (buffer, "%u", section_number);
+ s = bfd_make_section (abfd, buffer);
+ oasys->sections[section_number] = s;
+ switch (record.section.relb & RELOCATION_TYPE_BITS)
+ {
+ case RELOCATION_TYPE_ABS:
+ case RELOCATION_TYPE_REL:
+ break;
+ case RELOCATION_TYPE_UND:
+ case RELOCATION_TYPE_COM:
+ BFD_FAIL ();
+ }
+
+ s->_raw_size = bfd_h_get_32 (abfd, record.section.value);
+ s->vma = bfd_h_get_32 (abfd, record.section.vma);
+ s->flags = 0;
+ had_usefull = true;
+ }
+ break;
+ case oasys_record_is_data_enum:
+ oasys->first_data_record = bfd_tell (abfd) - record.header.length;
+ case oasys_record_is_debug_enum:
+ case oasys_record_is_module_enum:
+ case oasys_record_is_named_section_enum:
+ case oasys_record_is_end_enum:
+ if (had_usefull == false)
+ goto fail;
+ loop = false;
+ break;
+ default:
+ goto fail;
+ }
+ }
+ oasys->symbols = (asymbol *) NULL;
+ /*
+ Oasys support several architectures, but I can't see a simple way
+ to discover which one is in a particular file - we'll guess
+ */
+ bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0);
+ if (abfd->symcount != 0)
+ {
+ abfd->flags |= HAS_SYMS;
+ }
+
+ /*
+ We don't know if a section has data until we've read it..
+ */
+
+ oasys_slurp_section_data (abfd);
+
+
+ return abfd->xvec;
+
+fail:
+ (void) bfd_release (abfd, oasys);
+ abfd->tdata.oasys_obj_data = save;
+ return (const bfd_target *) NULL;
+}
+
+
+static void
+oasys_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+ if (!symbol->section)
+ ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
+}
+
+static void
+oasys_print_symbol (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ case bfd_print_symbol_more:
+ fprintf (file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_all:
+ {
+ CONST char *section_name = symbol->section == (asection *) NULL ?
+ (CONST char *) "*abs" : symbol->section->name;
+
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+
+ fprintf (file, " %-5s %s",
+ section_name,
+ symbol->name);
+ }
+ break;
+ }
+}
+/*
+ The howto table is build using the top two bits of a reloc byte to
+ index into it. The bits are PCREL,WORD/LONG
+*/
+static reloc_howto_type howto_table[] =
+{
+
+ HOWTO (0, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (0, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs32", true, 0xffffffff, 0xffffffff, false),
+ HOWTO (0, 0, 1, 16, true, 0, complain_overflow_signed, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (0, 0, 2, 32, true, 0, complain_overflow_signed, 0, "pcrel32", true, 0xffffffff, 0xffffffff, false)
+};
+
+/* Read in all the section data and relocation stuff too */
+static boolean
+oasys_slurp_section_data (abfd)
+ bfd *CONST abfd;
+{
+ oasys_record_union_type record;
+ oasys_data_type *data = OASYS_DATA (abfd);
+ boolean loop = true;
+
+ oasys_per_section_type *per;
+
+ asection *s;
+
+ /* See if the data has been slurped already .. */
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ per = oasys_per_section (s);
+ if (per->initialized == true)
+ return true;
+ }
+
+ if (data->first_data_record == 0)
+ return true;
+
+ if (bfd_seek (abfd, data->first_data_record, SEEK_SET) != 0)
+ return false;
+ while (loop)
+ {
+ if (! oasys_read_record (abfd, &record))
+ return false;
+ switch (record.header.type)
+ {
+ case oasys_record_is_header_enum:
+ break;
+ case oasys_record_is_data_enum:
+ {
+
+ bfd_byte *src = record.data.data;
+ bfd_byte *end_src = ((bfd_byte *) & record) + record.header.length;
+ bfd_byte *dst_ptr;
+ bfd_byte *dst_base_ptr;
+ unsigned int relbit;
+ unsigned int count;
+ asection *section =
+ data->sections[record.data.relb & RELOCATION_SECT_BITS];
+ bfd_vma dst_offset;
+
+ per = oasys_per_section (section);
+
+ if (per->initialized == false)
+ {
+ per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size);
+ if (!per->data)
+ return false;
+ per->reloc_tail_ptr = (oasys_reloc_type **) & (section->relocation);
+ per->had_vma = false;
+ per->initialized = true;
+ section->reloc_count = 0;
+ section->flags = SEC_ALLOC;
+ }
+
+ dst_offset = bfd_h_get_32 (abfd, record.data.addr);
+ if (per->had_vma == false)
+ {
+ /* Take the first vma we see as the base */
+ section->vma = dst_offset;
+ per->had_vma = true;
+ }
+
+ dst_offset -= section->vma;
+
+ dst_base_ptr = oasys_per_section (section)->data;
+ dst_ptr = oasys_per_section (section)->data +
+ dst_offset;
+
+ if (src < end_src)
+ {
+ section->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
+ }
+ while (src < end_src)
+ {
+ unsigned char mod_byte = *src++;
+ size_t gap = end_src - src;
+
+ count = 8;
+ if (mod_byte == 0 && gap >= 8)
+ {
+ dst_ptr[0] = src[0];
+ dst_ptr[1] = src[1];
+ dst_ptr[2] = src[2];
+ dst_ptr[3] = src[3];
+ dst_ptr[4] = src[4];
+ dst_ptr[5] = src[5];
+ dst_ptr[6] = src[6];
+ dst_ptr[7] = src[7];
+ dst_ptr += 8;
+ src += 8;
+ }
+ else
+ {
+ for (relbit = 1; count-- != 0 && src < end_src; relbit <<= 1)
+ {
+ if (relbit & mod_byte)
+ {
+ unsigned char reloc = *src;
+ /* This item needs to be relocated */
+ switch (reloc & RELOCATION_TYPE_BITS)
+ {
+ case RELOCATION_TYPE_ABS:
+
+ break;
+
+ case RELOCATION_TYPE_REL:
+ {
+ /* Relocate the item relative to the section */
+ oasys_reloc_type *r =
+ (oasys_reloc_type *)
+ bfd_alloc (abfd,
+ sizeof (oasys_reloc_type));
+ if (!r)
+ return false;
+ *(per->reloc_tail_ptr) = r;
+ per->reloc_tail_ptr = &r->next;
+ r->next = (oasys_reloc_type *) NULL;
+ /* Reference to undefined symbol */
+ src++;
+ /* There is no symbol */
+ r->symbol = 0;
+ /* Work out the howto */
+ abort ();
+#if 0
+ r->relent.section =
+ data->sections[reloc &
+ RELOCATION_SECT_BITS];
+
+ r->relent.addend = -
+ r->relent.section->vma;
+#endif
+ r->relent.address = dst_ptr - dst_base_ptr;
+ r->relent.howto = &howto_table[reloc >> 6];
+ r->relent.sym_ptr_ptr = (asymbol **) NULL;
+ section->reloc_count++;
+
+ /* Fake up the data to look like it's got the -ve pc in it, this makes
+ it much easier to convert into other formats. This is done by
+ hitting the addend.
+ */
+ if (r->relent.howto->pc_relative == true)
+ {
+ r->relent.addend -= dst_ptr - dst_base_ptr;
+ }
+
+
+ }
+ break;
+
+
+ case RELOCATION_TYPE_UND:
+ {
+ oasys_reloc_type *r =
+ (oasys_reloc_type *)
+ bfd_alloc (abfd,
+ sizeof (oasys_reloc_type));
+ if (!r)
+ return false;
+ *(per->reloc_tail_ptr) = r;
+ per->reloc_tail_ptr = &r->next;
+ r->next = (oasys_reloc_type *) NULL;
+ /* Reference to undefined symbol */
+ src++;
+ /* Get symbol number */
+ r->symbol = (src[0] << 8) | src[1];
+ /* Work out the howto */
+ abort ();
+
+#if 0
+ r->relent.section = (asection
+ *) NULL;
+#endif
+ r->relent.addend = 0;
+ r->relent.address = dst_ptr - dst_base_ptr;
+ r->relent.howto = &howto_table[reloc >> 6];
+ r->relent.sym_ptr_ptr = (asymbol **) NULL;
+ section->reloc_count++;
+
+ src += 2;
+ /* Fake up the data to look like it's got the -ve pc in it, this makes
+ it much easier to convert into other formats. This is done by
+ hitting the addend.
+ */
+ if (r->relent.howto->pc_relative == true)
+ {
+ r->relent.addend -= dst_ptr - dst_base_ptr;
+ }
+
+
+
+ }
+ break;
+ case RELOCATION_TYPE_COM:
+ BFD_FAIL ();
+ }
+ }
+ *dst_ptr++ = *src++;
+ }
+ }
+ }
+ }
+ break;
+ case oasys_record_is_local_enum:
+ case oasys_record_is_symbol_enum:
+ case oasys_record_is_section_enum:
+ break;
+ default:
+ loop = false;
+ }
+ }
+
+ return true;
+
+}
+
+static boolean
+oasys_new_section_hook (abfd, newsect)
+ bfd *abfd;
+ asection *newsect;
+{
+ newsect->used_by_bfd = (PTR)
+ bfd_alloc (abfd, sizeof (oasys_per_section_type));
+ if (!newsect->used_by_bfd)
+ return false;
+ oasys_per_section (newsect)->data = (bfd_byte *) NULL;
+ oasys_per_section (newsect)->section = newsect;
+ oasys_per_section (newsect)->offset = 0;
+ oasys_per_section (newsect)->initialized = false;
+ newsect->alignment_power = 1;
+ /* Turn the section string into an index */
+
+ sscanf (newsect->name, "%u", &newsect->target_index);
+
+ return true;
+}
+
+
+static long
+oasys_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ if (! oasys_slurp_section_data (abfd))
+ return -1;
+ return (asect->reloc_count + 1) * sizeof (arelent *);
+}
+
+static boolean
+oasys_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
+ oasys_slurp_section_data (abfd);
+ if (p->initialized == false)
+ {
+ (void) memset (location, 0, (int) count);
+ }
+ else
+ {
+ (void) memcpy (location, (PTR) (p->data + offset), (int) count);
+ }
+ return true;
+}
+
+
+long
+oasys_canonicalize_reloc (ignore_abfd, section, relptr, symbols)
+ bfd *ignore_abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ unsigned int reloc_count = 0;
+ oasys_reloc_type *src = (oasys_reloc_type *) (section->relocation);
+ while (src != (oasys_reloc_type *) NULL)
+ {
+ abort ();
+
+#if 0
+ if (src->relent.section == (asection *) NULL)
+ {
+ src->relent.sym_ptr_ptr = symbols + src->symbol;
+ }
+#endif
+
+ *relptr++ = &src->relent;
+ src = src->next;
+ reloc_count++;
+ }
+ *relptr = (arelent *) NULL;
+ return section->reloc_count = reloc_count;
+}
+
+
+
+
+/* Writing */
+
+
+/* Calculate the checksum and write one record */
+static boolean
+oasys_write_record (abfd, type, record, size)
+ bfd *abfd;
+ oasys_record_enum_type type;
+ oasys_record_union_type *record;
+ size_t size;
+{
+ int checksum;
+ size_t i;
+ unsigned char *ptr;
+
+ record->header.length = size;
+ record->header.type = (int) type;
+ record->header.check_sum = 0;
+ record->header.fill = 0;
+ ptr = (unsigned char *) &record->pad[0];
+ checksum = 0;
+ for (i = 0; i < size; i++)
+ {
+ checksum += *ptr++;
+ }
+ record->header.check_sum = 0xff & (-checksum);
+ if (bfd_write ((PTR) record, 1, size, abfd) != size)
+ return false;
+ return true;
+}
+
+
+/* Write out all the symbols */
+static boolean
+oasys_write_syms (abfd)
+ bfd *abfd;
+{
+ unsigned int count;
+ asymbol **generic = bfd_get_outsymbols (abfd);
+ unsigned int index = 0;
+ for (count = 0; count < bfd_get_symcount (abfd); count++)
+ {
+
+ oasys_symbol_record_type symbol;
+ asymbol *CONST g = generic[count];
+
+ CONST char *src = g->name;
+ char *dst = symbol.name;
+ unsigned int l = 0;
+
+ if (bfd_is_com_section (g->section))
+ {
+ symbol.relb = RELOCATION_TYPE_COM;
+ bfd_h_put_16 (abfd, index, symbol.refno);
+ index++;
+ }
+ else if (bfd_is_abs_section (g->section))
+ {
+ symbol.relb = RELOCATION_TYPE_ABS;
+ bfd_h_put_16 (abfd, 0, symbol.refno);
+
+ }
+ else if (bfd_is_und_section (g->section))
+ {
+ symbol.relb = RELOCATION_TYPE_UND;
+ bfd_h_put_16 (abfd, index, symbol.refno);
+ /* Overload the value field with the output index number */
+ index++;
+ }
+ else if (g->flags & BSF_DEBUGGING)
+ {
+ /* throw it away */
+ continue;
+ }
+ else
+ {
+ if (g->section == (asection *) NULL)
+ {
+ /* Sometime, the oasys tools give out a symbol with illegal
+ bits in it, we'll output it in the same broken way */
+
+ symbol.relb = RELOCATION_TYPE_REL | 0;
+ }
+ else
+ {
+ symbol.relb = RELOCATION_TYPE_REL | g->section->output_section->target_index;
+ }
+ bfd_h_put_16 (abfd, 0, symbol.refno);
+ }
+#ifdef UNDERSCORE_HACK
+ if (src[l] == '_')
+ dst[l++] = '.';
+#endif
+ while (src[l])
+ {
+ dst[l] = src[l];
+ l++;
+ }
+
+ bfd_h_put_32 (abfd, g->value, symbol.value);
+
+
+ if (g->flags & BSF_LOCAL)
+ {
+ if (! oasys_write_record (abfd,
+ oasys_record_is_local_enum,
+ (oasys_record_union_type *) & symbol,
+ offsetof (oasys_symbol_record_type,
+ name[0]) + l))
+ return false;
+ }
+ else
+ {
+ if (! oasys_write_record (abfd,
+ oasys_record_is_symbol_enum,
+ (oasys_record_union_type *) & symbol,
+ offsetof (oasys_symbol_record_type,
+ name[0]) + l))
+ return false;
+ }
+ g->value = index - 1;
+ }
+
+ return true;
+}
+
+
+ /* Write a section header for each section */
+static boolean
+oasys_write_sections (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ static oasys_section_record_type out;
+
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ if (!isdigit ((unsigned char) s->name[0]))
+ {
+ (*_bfd_error_handler)
+ (_("%s: can not represent section `%s' in oasys"),
+ bfd_get_filename (abfd), s->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ out.relb = RELOCATION_TYPE_REL | s->target_index;
+ bfd_h_put_32 (abfd, s->_cooked_size, out.value);
+ bfd_h_put_32 (abfd, s->vma, out.vma);
+
+ if (! oasys_write_record (abfd,
+ oasys_record_is_section_enum,
+ (oasys_record_union_type *) & out,
+ sizeof (out)))
+ return false;
+ }
+ return true;
+}
+
+static boolean
+oasys_write_header (abfd)
+ bfd *abfd;
+{
+ /* Create and write the header */
+ oasys_header_record_type r;
+ size_t length = strlen (abfd->filename);
+ if (length > (size_t) sizeof (r.module_name))
+ {
+ length = sizeof (r.module_name);
+ }
+
+ (void) memcpy (r.module_name,
+ abfd->filename,
+ length);
+ (void) memset (r.module_name + length,
+ ' ',
+ sizeof (r.module_name) - length);
+
+ r.version_number = OASYS_VERSION_NUMBER;
+ r.rev_number = OASYS_REV_NUMBER;
+ if (! oasys_write_record (abfd,
+ oasys_record_is_header_enum,
+ (oasys_record_union_type *) & r,
+ offsetof (oasys_header_record_type,
+ description[0])))
+ return false;
+
+ return true;
+}
+
+static boolean
+oasys_write_end (abfd)
+ bfd *abfd;
+{
+ oasys_end_record_type end;
+ unsigned char null = 0;
+ end.relb = RELOCATION_TYPE_ABS;
+ bfd_h_put_32 (abfd, abfd->start_address, end.entry);
+ bfd_h_put_16 (abfd, 0, end.fill);
+ end.zero = 0;
+ if (! oasys_write_record (abfd,
+ oasys_record_is_end_enum,
+ (oasys_record_union_type *) & end,
+ sizeof (end)))
+ return false;
+ if (bfd_write ((PTR) & null, 1, 1, abfd) != 1)
+ return false;
+ return true;
+}
+
+static int
+comp (ap, bp)
+ CONST PTR ap;
+ CONST PTR bp;
+{
+ arelent *a = *((arelent **) ap);
+ arelent *b = *((arelent **) bp);
+ return a->address - b->address;
+}
+
+/*
+ Writing data..
+
+*/
+static boolean
+oasys_write_data (abfd)
+ bfd *abfd;
+{
+ asection *s;
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ if (s->flags & SEC_LOAD)
+ {
+ bfd_byte *raw_data = oasys_per_section (s)->data;
+ oasys_data_record_type processed_data;
+ bfd_size_type current_byte_index = 0;
+ unsigned int relocs_to_go = s->reloc_count;
+ arelent **p = s->orelocation;
+ if (s->reloc_count != 0)
+ {
+/* Sort the reloc records so it's easy to insert the relocs into the
+ data */
+
+ qsort (s->orelocation,
+ s->reloc_count,
+ sizeof (arelent **),
+ comp);
+ }
+ current_byte_index = 0;
+ processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
+
+ while (current_byte_index < s->_cooked_size)
+ {
+ /* Scan forwards by eight bytes or however much is left and see if
+ there are any relocations going on */
+ bfd_byte *mod = &processed_data.data[0];
+ bfd_byte *dst = &processed_data.data[1];
+
+ unsigned int i = 0;
+ *mod = 0;
+
+
+ bfd_h_put_32 (abfd, s->vma + current_byte_index,
+ processed_data.addr);
+
+ /* Don't start a relocation unless you're sure you can finish it
+ within the same data record. The worst case relocation is a
+ 4-byte relocatable value which is split across two modification
+ bytes (1 relocation byte + 2 symbol reference bytes + 2 data +
+ 1 modification byte + 2 data = 8 bytes total). That's where
+ the magic number 8 comes from.
+ */
+ while (current_byte_index < s->_raw_size && dst <=
+ &processed_data.data[sizeof (processed_data.data) - 8])
+ {
+
+
+ if (relocs_to_go != 0)
+ {
+ arelent *r = *p;
+ reloc_howto_type *const how = r->howto;
+ /* There is a relocation, is it for this byte ? */
+ if (r->address == current_byte_index)
+ {
+ unsigned char rel_byte;
+
+ p++;
+ relocs_to_go--;
+
+ *mod |= (1 << i);
+ if (how->pc_relative)
+ {
+ rel_byte = RELOCATION_PCREL_BIT;
+
+ /* Also patch the raw data so that it doesn't have
+ the -ve stuff any more */
+ if (how->size != 2)
+ {
+ bfd_put_16 (abfd,
+ bfd_get_16 (abfd, raw_data) +
+ current_byte_index, raw_data);
+ }
+
+ else
+ {
+ bfd_put_32 (abfd,
+ bfd_get_32 (abfd, raw_data) +
+ current_byte_index, raw_data);
+ }
+ }
+ else
+ {
+ rel_byte = 0;
+ }
+ if (how->size == 2)
+ {
+ rel_byte |= RELOCATION_32BIT_BIT;
+ }
+
+ /* Is this a section relative relocation, or a symbol
+ relative relocation ? */
+ abort ();
+
+#if 0
+ if (r->section != (asection *) NULL)
+ {
+ /* The relent has a section attached, so it must be section
+ relative */
+ rel_byte |= RELOCATION_TYPE_REL;
+ rel_byte |= r->section->output_section->target_index;
+ *dst++ = rel_byte;
+ }
+ else
+#endif
+ {
+ asymbol *p = *(r->sym_ptr_ptr);
+
+ /* If this symbol has a section attached, then it
+ has already been resolved. Change from a symbol
+ ref to a section ref */
+ if (p->section != (asection *) NULL)
+ {
+ rel_byte |= RELOCATION_TYPE_REL;
+ rel_byte |=
+ p->section->output_section->target_index;
+ *dst++ = rel_byte;
+ }
+ else
+ {
+ rel_byte |= RELOCATION_TYPE_UND;
+ *dst++ = rel_byte;
+ /* Next two bytes are a symbol index - we can get
+ this from the symbol value which has been zapped
+ into the symbol index in the table when the
+ symbol table was written
+ */
+ *dst++ = p->value >> 8;
+ *dst++ = p->value;
+ }
+ }
+#define ADVANCE { if (++i >= 8) { i = 0; mod = dst++; *mod = 0; } current_byte_index++; }
+ /* relocations never occur from an unloadable section,
+ so we can assume that raw_data is not NULL
+ */
+ *dst++ = *raw_data++;
+ ADVANCE
+ * dst++ = *raw_data++;
+ ADVANCE
+ if (how->size == 2)
+ {
+ *dst++ = *raw_data++;
+ ADVANCE
+ * dst++ = *raw_data++;
+ ADVANCE
+ }
+ continue;
+ }
+ }
+ /* If this is coming from an unloadable section then copy
+ zeros */
+ if (raw_data == NULL)
+ {
+ *dst++ = 0;
+ }
+ else
+ {
+ *dst++ = *raw_data++;
+ }
+ ADVANCE
+ }
+
+ /* Don't write a useless null modification byte */
+ if (dst == mod + 1)
+ {
+ --dst;
+ }
+
+ if (! oasys_write_record (abfd,
+ oasys_record_is_data_enum,
+ ((oasys_record_union_type *)
+ & processed_data),
+ dst - (bfd_byte *) & processed_data))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+static boolean
+oasys_write_object_contents (abfd)
+ bfd *abfd;
+{
+ if (! oasys_write_header (abfd))
+ return false;
+ if (! oasys_write_syms (abfd))
+ return false;
+ if (! oasys_write_sections (abfd))
+ return false;
+ if (! oasys_write_data (abfd))
+ return false;
+ if (! oasys_write_end (abfd))
+ return false;
+ return true;
+}
+
+
+
+
+/** exec and core file sections */
+
+/* set section contents is complicated with OASYS since the format is
+* not a byte image, but a record stream.
+*/
+static boolean
+oasys_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (count != 0)
+ {
+ if (oasys_per_section (section)->data == (bfd_byte *) NULL)
+ {
+ oasys_per_section (section)->data =
+ (bfd_byte *) (bfd_alloc (abfd, section->_cooked_size));
+ if (!oasys_per_section (section)->data)
+ return false;
+ }
+ (void) memcpy ((PTR) (oasys_per_section (section)->data + offset),
+ location,
+ (size_t) count);
+ }
+ return true;
+}
+
+
+
+/* Native-level interface to symbols. */
+
+/* We read the symbols into a buffer, which is discarded when this
+function exits. We read the strings into a buffer large enough to
+hold them all plus all the cached symbol entries. */
+
+static asymbol *
+oasys_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+
+ oasys_symbol_type *new =
+ (oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
+ if (!new)
+ return NULL;
+ new->symbol.the_bfd = abfd;
+ return &new->symbol;
+}
+
+
+
+
+/* User should have checked the file flags; perhaps we should return
+BFD_NO_MORE_SYMBOLS if there are none? */
+
+static bfd *
+oasys_openr_next_archived_file (arch, prev)
+ bfd *arch;
+ bfd *prev;
+{
+ oasys_ar_data_type *ar = OASYS_AR_DATA (arch);
+ oasys_module_info_type *p;
+ /* take the next one from the arch state, or reset */
+ if (prev == (bfd *) NULL)
+ {
+ /* Reset the index - the first two entries are bogus*/
+ ar->module_index = 0;
+ }
+
+ p = ar->module + ar->module_index;
+ ar->module_index++;
+
+ if (ar->module_index <= ar->module_count)
+ {
+ if (p->abfd == (bfd *) NULL)
+ {
+ p->abfd = _bfd_create_empty_archive_element_shell (arch);
+ p->abfd->origin = p->pos;
+ p->abfd->filename = p->name;
+
+ /* Fixup a pointer to this element for the member */
+ p->abfd->arelt_data = (PTR) p;
+ }
+ return p->abfd;
+ }
+ else
+ {
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return (bfd *) NULL;
+ }
+}
+
+static boolean
+oasys_find_nearest_line (abfd,
+ section,
+ symbols,
+ offset,
+ filename_ptr,
+ functionname_ptr,
+ line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ char **filename_ptr;
+ char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ return false;
+
+}
+
+static int
+oasys_generic_stat_arch_elt (abfd, buf)
+ bfd *abfd;
+ struct stat *buf;
+{
+ oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
+ if (mod == (oasys_module_info_type *) NULL)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+ else
+ {
+ buf->st_size = mod->size;
+ buf->st_mode = 0666;
+ return 0;
+ }
+}
+
+static int
+oasys_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+#define oasys_close_and_cleanup _bfd_generic_close_and_cleanup
+#define oasys_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+
+#define oasys_slurp_armap bfd_true
+#define oasys_slurp_extended_name_table bfd_true
+#define oasys_construct_extended_name_table \
+ ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
+ bfd_true)
+#define oasys_truncate_arname bfd_dont_truncate_arname
+#define oasys_write_armap \
+ ((boolean (*) \
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
+ bfd_true)
+#define oasys_read_ar_hdr bfd_nullvoidptr
+#define oasys_get_elt_at_index _bfd_generic_get_elt_at_index
+#define oasys_update_armap_timestamp bfd_true
+
+#define oasys_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define oasys_get_lineno _bfd_nosymbols_get_lineno
+#define oasys_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define oasys_read_minisymbols _bfd_generic_read_minisymbols
+#define oasys_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define oasys_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define oasys_set_arch_mach bfd_default_set_arch_mach
+
+#define oasys_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#define oasys_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define oasys_bfd_relax_section bfd_generic_relax_section
+#define oasys_bfd_gc_sections bfd_generic_gc_sections
+#define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define oasys_bfd_final_link _bfd_generic_final_link
+#define oasys_bfd_link_split_section _bfd_generic_link_split_section
+
+/*SUPPRESS 460 */
+const bfd_target oasys_vec =
+{
+ "oasys", /* name */
+ bfd_target_oasys_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {_bfd_dummy_target,
+ oasys_object_p, /* bfd_check_format */
+ oasys_archive_p,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ oasys_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ oasys_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (oasys),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (oasys),
+ BFD_JUMP_TABLE_SYMBOLS (oasys),
+ BFD_JUMP_TABLE_RELOCS (oasys),
+ BFD_JUMP_TABLE_WRITE (oasys),
+ BFD_JUMP_TABLE_LINK (oasys),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/opncls.c b/bfd/opncls.c
new file mode 100644
index 00000000000..8f10135d267
--- /dev/null
+++ b/bfd/opncls.c
@@ -0,0 +1,683 @@
+/* opncls.c -- open and close a BFD.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997
+ Free Software Foundation, Inc.
+
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "objalloc.h"
+#include "libbfd.h"
+
+#ifndef S_IXUSR
+#define S_IXUSR 0100 /* Execute by owner. */
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP 0010 /* Execute by group. */
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 0001 /* Execute by others. */
+#endif
+
+/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
+ if we do that we can't use fcntl. */
+
+/* FIXME: This is no longer used. */
+long _bfd_chunksize = -1;
+
+/* Return a new BFD. All BFD's are allocated through this routine. */
+
+bfd *
+_bfd_new_bfd ()
+{
+ bfd *nbfd;
+
+ nbfd = (bfd *) bfd_zmalloc (sizeof (bfd));
+ if (nbfd == NULL)
+ return NULL;
+
+ nbfd->memory = (PTR) objalloc_create ();
+ if (nbfd->memory == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
+ nbfd->arch_info = &bfd_default_arch_struct;
+
+ nbfd->direction = no_direction;
+ nbfd->iostream = NULL;
+ nbfd->where = 0;
+ nbfd->sections = (asection *) NULL;
+ nbfd->format = bfd_unknown;
+ nbfd->my_archive = (bfd *) NULL;
+ nbfd->origin = 0;
+ nbfd->opened_once = false;
+ nbfd->output_has_begun = false;
+ nbfd->section_count = 0;
+ nbfd->usrdata = (PTR) NULL;
+ nbfd->cacheable = false;
+ nbfd->flags = BFD_NO_FLAGS;
+ nbfd->mtime_set = false;
+
+ return nbfd;
+}
+
+/* Allocate a new BFD as a member of archive OBFD. */
+
+bfd *
+_bfd_new_bfd_contained_in (obfd)
+ bfd *obfd;
+{
+ bfd *nbfd;
+
+ nbfd = _bfd_new_bfd ();
+ nbfd->xvec = obfd->xvec;
+ nbfd->my_archive = obfd;
+ nbfd->direction = read_direction;
+ nbfd->target_defaulted = obfd->target_defaulted;
+ return nbfd;
+}
+
+/*
+SECTION
+ Opening and closing BFDs
+
+*/
+
+/*
+FUNCTION
+ bfd_openr
+
+SYNOPSIS
+ bfd *bfd_openr(CONST char *filename, CONST char *target);
+
+DESCRIPTION
+ Open the file @var{filename} (using <<fopen>>) with the target
+ @var{target}. Return a pointer to the created BFD.
+
+ Calls <<bfd_find_target>>, so @var{target} is interpreted as by
+ that function.
+
+ If <<NULL>> is returned then an error has occured. Possible errors
+ are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or <<system_call>> error.
+*/
+
+bfd *
+bfd_openr (filename, target)
+ CONST char *filename;
+ CONST char *target;
+{
+ bfd *nbfd;
+ const bfd_target *target_vec;
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+ return NULL;
+
+ target_vec = bfd_find_target (target, nbfd);
+ if (target_vec == NULL)
+ {
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ bfd_set_error (bfd_error_invalid_target);
+ return NULL;
+ }
+
+ nbfd->filename = filename;
+ nbfd->direction = read_direction;
+
+ if (bfd_open_file (nbfd) == NULL)
+ {
+ /* File didn't exist, or some such */
+ bfd_set_error (bfd_error_system_call);
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+ return nbfd;
+}
+
+/* Don't try to `optimize' this function:
+
+ o - We lock using stack space so that interrupting the locking
+ won't cause a storage leak.
+ o - We open the file stream last, since we don't want to have to
+ close it if anything goes wrong. Closing the stream means closing
+ the file descriptor too, even though we didn't open it.
+ */
+/*
+FUNCTION
+ bfd_fdopenr
+
+SYNOPSIS
+ bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
+
+DESCRIPTION
+ <<bfd_fdopenr>> is to <<bfd_fopenr>> much like <<fdopen>> is to <<fopen>>.
+ It opens a BFD on a file already described by the @var{fd}
+ supplied.
+
+ When the file is later <<bfd_close>>d, the file descriptor will be closed.
+
+ If the caller desires that this file descriptor be cached by BFD
+ (opened as needed, closed as needed to free descriptors for
+ other opens), with the supplied @var{fd} used as an initial
+ file descriptor (but subject to closure at any time), call
+ bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to
+ assume no cacheing; the file descriptor will remain open until
+ <<bfd_close>>, and will not be affected by BFD operations on other
+ files.
+
+ Possible errors are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
+*/
+
+bfd *
+bfd_fdopenr (filename, target, fd)
+ CONST char *filename;
+ CONST char *target;
+ int fd;
+{
+ bfd *nbfd;
+ const bfd_target *target_vec;
+ int fdflags;
+
+ bfd_set_error (bfd_error_system_call);
+#if ! defined(HAVE_FCNTL) || ! defined(F_GETFL)
+ fdflags = O_RDWR; /* Assume full access */
+#else
+ fdflags = fcntl (fd, F_GETFL, NULL);
+#endif
+ if (fdflags == -1) return NULL;
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+ return NULL;
+
+ target_vec = bfd_find_target (target, nbfd);
+ if (target_vec == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_target);
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+#ifndef HAVE_FDOPEN
+ nbfd->iostream = (PTR) fopen (filename, FOPEN_RB);
+#else
+ /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
+ switch (fdflags & (O_ACCMODE))
+ {
+ case O_RDONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RB); break;
+ case O_WRONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RUB); break;
+ case O_RDWR: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RUB); break;
+ default: abort ();
+ }
+#endif
+
+ if (nbfd->iostream == NULL)
+ {
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+ /* OK, put everything where it belongs */
+
+ nbfd->filename = filename;
+
+ /* As a special case we allow a FD open for read/write to
+ be written through, although doing so requires that we end
+ the previous clause with a preposition. */
+ /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
+ switch (fdflags & O_ACCMODE)
+ {
+ case O_RDONLY: nbfd->direction = read_direction; break;
+ case O_WRONLY: nbfd->direction = write_direction; break;
+ case O_RDWR: nbfd->direction = both_direction; break;
+ default: abort ();
+ }
+
+ if (! bfd_cache_init (nbfd))
+ {
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+ nbfd->opened_once = true;
+
+ return nbfd;
+}
+
+/*
+FUNCTION
+ bfd_openstreamr
+
+SYNOPSIS
+ bfd *bfd_openstreamr(const char *, const char *, PTR);
+
+DESCRIPTION
+
+ Open a BFD for read access on an existing stdio stream. When
+ the BFD is passed to <<bfd_close>>, the stream will be closed.
+*/
+
+bfd *
+bfd_openstreamr (filename, target, streamarg)
+ const char *filename;
+ const char *target;
+ PTR streamarg;
+{
+ FILE *stream = (FILE *) streamarg;
+ bfd *nbfd;
+ const bfd_target *target_vec;
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+ return NULL;
+
+ target_vec = bfd_find_target (target, nbfd);
+ if (target_vec == NULL)
+ {
+ bfd_set_error (bfd_error_invalid_target);
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+ nbfd->iostream = (PTR) stream;
+ nbfd->filename = filename;
+ nbfd->direction = read_direction;
+
+ if (! bfd_cache_init (nbfd))
+ {
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+ return nbfd;
+}
+
+/** bfd_openw -- open for writing.
+ Returns a pointer to a freshly-allocated BFD on success, or NULL.
+
+ See comment by bfd_fdopenr before you try to modify this function. */
+
+/*
+FUNCTION
+ bfd_openw
+
+SYNOPSIS
+ bfd *bfd_openw(CONST char *filename, CONST char *target);
+
+DESCRIPTION
+ Create a BFD, associated with file @var{filename}, using the
+ file format @var{target}, and return a pointer to it.
+
+ Possible errors are <<bfd_error_system_call>>, <<bfd_error_no_memory>>,
+ <<bfd_error_invalid_target>>.
+*/
+
+bfd *
+bfd_openw (filename, target)
+ CONST char *filename;
+ CONST char *target;
+{
+ bfd *nbfd;
+ const bfd_target *target_vec;
+
+ bfd_set_error (bfd_error_system_call);
+
+ /* nbfd has to point to head of malloc'ed block so that bfd_close may
+ reclaim it correctly. */
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+ return NULL;
+
+ target_vec = bfd_find_target (target, nbfd);
+ if (target_vec == NULL)
+ {
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+ nbfd->filename = filename;
+ nbfd->direction = write_direction;
+
+ if (bfd_open_file (nbfd) == NULL)
+ {
+ bfd_set_error (bfd_error_system_call); /* File not writeable, etc */
+ objalloc_free ((struct objalloc *) nbfd->memory);
+ free (nbfd);
+ return NULL;
+ }
+
+ return nbfd;
+}
+
+/*
+
+FUNCTION
+ bfd_close
+
+SYNOPSIS
+ boolean bfd_close(bfd *abfd);
+
+DESCRIPTION
+
+ Close a BFD. If the BFD was open for writing,
+ then pending operations are completed and the file written out
+ and closed. If the created file is executable, then
+ <<chmod>> is called to mark it as such.
+
+ All memory attached to the BFD is released.
+
+ The file descriptor associated with the BFD is closed (even
+ if it was passed in to BFD by <<bfd_fdopenr>>).
+
+RETURNS
+ <<true>> is returned if all is ok, otherwise <<false>>.
+*/
+
+
+boolean
+bfd_close (abfd)
+ bfd *abfd;
+{
+ boolean ret;
+
+ if (!bfd_read_p (abfd))
+ {
+ if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
+ return false;
+ }
+
+ if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
+ return false;
+
+ ret = bfd_cache_close (abfd);
+
+ /* If the file was open for writing and is now executable,
+ make it so */
+ if (ret
+ && abfd->direction == write_direction
+ && abfd->flags & EXEC_P)
+ {
+ struct stat buf;
+
+ if (stat (abfd->filename, &buf) == 0)
+ {
+ int mask = umask (0);
+ umask (mask);
+ chmod (abfd->filename,
+ (0777
+ & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
+ }
+ }
+
+ objalloc_free ((struct objalloc *) abfd->memory);
+ free (abfd);
+
+ return ret;
+}
+
+/*
+FUNCTION
+ bfd_close_all_done
+
+SYNOPSIS
+ boolean bfd_close_all_done(bfd *);
+
+DESCRIPTION
+ Close a BFD. Differs from <<bfd_close>>
+ since it does not complete any pending operations. This
+ routine would be used if the application had just used BFD for
+ swapping and didn't want to use any of the writing code.
+
+ If the created file is executable, then <<chmod>> is called
+ to mark it as such.
+
+ All memory attached to the BFD is released.
+
+RETURNS
+ <<true>> is returned if all is ok, otherwise <<false>>.
+
+*/
+
+boolean
+bfd_close_all_done (abfd)
+ bfd *abfd;
+{
+ boolean ret;
+
+ ret = bfd_cache_close (abfd);
+
+ /* If the file was open for writing and is now executable,
+ make it so */
+ if (ret
+ && abfd->direction == write_direction
+ && abfd->flags & EXEC_P)
+ {
+ struct stat buf;
+
+ if (stat (abfd->filename, &buf) == 0)
+ {
+ int mask = umask (0);
+ umask (mask);
+ chmod (abfd->filename,
+ (0x777
+ & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
+ }
+ }
+
+ objalloc_free ((struct objalloc *) abfd->memory);
+ free (abfd);
+
+ return ret;
+}
+
+/*
+FUNCTION
+ bfd_create
+
+SYNOPSIS
+ bfd *bfd_create(CONST char *filename, bfd *templ);
+
+DESCRIPTION
+ Create a new BFD in the manner of
+ <<bfd_openw>>, but without opening a file. The new BFD
+ takes the target from the target used by @var{template}. The
+ format is always set to <<bfd_object>>.
+
+*/
+
+bfd *
+bfd_create (filename, templ)
+ CONST char *filename;
+ bfd *templ;
+{
+ bfd *nbfd;
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+ return NULL;
+ nbfd->filename = filename;
+ if (templ)
+ nbfd->xvec = templ->xvec;
+ nbfd->direction = no_direction;
+ bfd_set_format (nbfd, bfd_object);
+ return nbfd;
+}
+
+/*
+FUNCTION
+ bfd_make_writable
+
+SYNOPSIS
+ boolean bfd_make_writable(bfd *abfd);
+
+DESCRIPTION
+ Takes a BFD as created by <<bfd_create>> and converts it
+ into one like as returned by <<bfd_openw>>. It does this
+ by converting the BFD to BFD_IN_MEMORY. It's assumed that
+ you will call <<bfd_make_readable>> on this bfd later.
+
+RETURNS
+ <<true>> is returned if all is ok, otherwise <<false>>.
+*/
+
+boolean
+bfd_make_writable(abfd)
+ bfd *abfd;
+{
+ struct bfd_in_memory *bim;
+
+ if (abfd->direction != no_direction)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ bim = (struct bfd_in_memory *) bfd_malloc (sizeof (struct bfd_in_memory));
+ abfd->iostream = (PTR) bim;
+ /* bfd_write will grow these as needed */
+ bim->size = 0;
+ bim->buffer = 0;
+
+ abfd->flags |= BFD_IN_MEMORY;
+ abfd->direction = write_direction;
+ abfd->where = 0;
+
+ return true;
+}
+
+/*
+FUNCTION
+ bfd_make_readable
+
+SYNOPSIS
+ boolean bfd_make_readable(bfd *abfd);
+
+DESCRIPTION
+ Takes a BFD as created by <<bfd_create>> and
+ <<bfd_make_writable>> and converts it into one like as
+ returned by <<bfd_openr>>. It does this by writing the
+ contents out to the memory buffer, then reversing the
+ direction.
+
+RETURNS
+ <<true>> is returned if all is ok, otherwise <<false>>. */
+
+boolean
+bfd_make_readable(abfd)
+ bfd *abfd;
+{
+ if (abfd->direction != write_direction || !(abfd->flags & BFD_IN_MEMORY))
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
+ return false;
+
+ if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
+ return false;
+
+
+ abfd->arch_info = &bfd_default_arch_struct;
+
+ abfd->where = 0;
+ abfd->sections = (asection *) NULL;
+ abfd->format = bfd_unknown;
+ abfd->my_archive = (bfd *) NULL;
+ abfd->origin = 0;
+ abfd->opened_once = false;
+ abfd->output_has_begun = false;
+ abfd->section_count = 0;
+ abfd->usrdata = (PTR) NULL;
+ abfd->cacheable = false;
+ abfd->flags = BFD_IN_MEMORY;
+ abfd->mtime_set = false;
+
+ abfd->target_defaulted = true;
+ abfd->direction = read_direction;
+ abfd->sections = 0;
+ abfd->symcount = 0;
+ abfd->outsymbols = 0;
+ abfd->tdata.any = 0;
+
+ bfd_check_format(abfd, bfd_object);
+
+ return true;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_alloc
+
+SYNOPSIS
+ PTR bfd_alloc (bfd *abfd, size_t wanted);
+
+DESCRIPTION
+ Allocate a block of @var{wanted} bytes of memory attached to
+ <<abfd>> and return a pointer to it.
+*/
+
+
+PTR
+bfd_alloc (abfd, size)
+ bfd *abfd;
+ size_t size;
+{
+ PTR ret;
+
+ ret = objalloc_alloc (abfd->memory, (unsigned long) size);
+ if (ret == NULL)
+ bfd_set_error (bfd_error_no_memory);
+ return ret;
+}
+
+PTR
+bfd_zalloc (abfd, size)
+ bfd *abfd;
+ size_t size;
+{
+ PTR res;
+
+ res = bfd_alloc (abfd, size);
+ if (res)
+ memset (res, 0, size);
+ return res;
+}
+
+/* Free a block allocated for a BFD. */
+
+void
+bfd_release (abfd, block)
+ bfd *abfd;
+ PTR block;
+{
+ objalloc_free_block ((struct objalloc *) abfd->memory, block);
+}
diff --git a/bfd/osf-core.c b/bfd/osf-core.c
new file mode 100644
index 00000000000..671f4af495c
--- /dev/null
+++ b/bfd/osf-core.c
@@ -0,0 +1,254 @@
+/* BFD back-end for OSF/1 core files.
+ Copyright 1993, 94, 95, 97, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file can only be compiled on systems which use OSF/1 style
+ core files. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include <sys/user.h>
+#include <sys/core.h>
+
+/* forward declarations */
+
+static asection *
+make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
+ bfd_vma, file_ptr));
+static asymbol *
+osf_core_make_empty_symbol PARAMS ((bfd *));
+static const bfd_target *
+osf_core_core_file_p PARAMS ((bfd *));
+static char *
+osf_core_core_file_failing_command PARAMS ((bfd *));
+static int
+osf_core_core_file_failing_signal PARAMS ((bfd *));
+static boolean
+osf_core_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
+static void
+swap_abort PARAMS ((void));
+
+/* These are stored in the bfd's tdata */
+
+struct osf_core_struct
+{
+ int sig;
+ char cmd[MAXCOMLEN + 1];
+};
+
+#define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
+#define core_signal(bfd) (core_hdr(bfd)->sig)
+#define core_command(bfd) (core_hdr(bfd)->cmd)
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
+ bfd *abfd;
+ CONST char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ bfd_vma vma;
+ file_ptr filepos;
+{
+ asection *asect;
+
+ asect = bfd_make_section_anyway (abfd, name);
+ if (!asect)
+ return NULL;
+
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->vma = vma;
+ asect->filepos = filepos;
+ asect->alignment_power = 8;
+
+ return asect;
+}
+
+static asymbol *
+osf_core_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+static const bfd_target *
+osf_core_core_file_p (abfd)
+ bfd *abfd;
+{
+ int val;
+ int i;
+ char *secname;
+ struct core_filehdr core_header;
+
+ val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
+ if (val != sizeof core_header)
+ return NULL;
+
+ if (strncmp (core_header.magic, "Core", 4) != 0)
+ return NULL;
+
+ core_hdr (abfd) = (struct osf_core_struct *)
+ bfd_zalloc (abfd, sizeof (struct osf_core_struct));
+ if (!core_hdr (abfd))
+ return NULL;
+
+ strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
+ core_signal (abfd) = core_header.signo;
+
+ for (i = 0; i < core_header.nscns; i++)
+ {
+ struct core_scnhdr core_scnhdr;
+ flagword flags;
+
+ val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
+ if (val != sizeof core_scnhdr)
+ break;
+
+ /* Skip empty sections. */
+ if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
+ continue;
+
+ switch (core_scnhdr.scntype)
+ {
+ case SCNRGN:
+ secname = ".data";
+ flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ break;
+ case SCNSTACK:
+ secname = ".stack";
+ flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ break;
+ case SCNREGS:
+ secname = ".reg";
+ flags = SEC_HAS_CONTENTS;
+ break;
+ default:
+ (*_bfd_error_handler) (_("Unhandled OSF/1 core file section type %d\n"),
+ core_scnhdr.scntype);
+ continue;
+ }
+
+ if (!make_bfd_asection (abfd, secname, flags,
+ (bfd_size_type) core_scnhdr.size,
+ (bfd_vma) core_scnhdr.vaddr,
+ (file_ptr) core_scnhdr.scnptr))
+ return NULL;
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ return abfd->xvec;
+}
+
+static char *
+osf_core_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ return core_command (abfd);
+}
+
+/* ARGSUSED */
+static int
+osf_core_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_signal (abfd);
+}
+
+/* ARGSUSED */
+static boolean
+osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this point */
+}
+
+#define osf_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define osf_core_get_symtab _bfd_nosymbols_get_symtab
+#define osf_core_print_symbol _bfd_nosymbols_print_symbol
+#define osf_core_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define osf_core_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define osf_core_get_lineno _bfd_nosymbols_get_lineno
+#define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target osf_core_vec =
+ {
+ "osf-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ osf_core_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (osf_core),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (osf_core),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
diff --git a/bfd/pc532-mach.c b/bfd/pc532-mach.c
new file mode 100644
index 00000000000..73f4ac49e82
--- /dev/null
+++ b/bfd/pc532-mach.c
@@ -0,0 +1,121 @@
+/* BFD back-end for Mach3/532 a.out-ish binaries.
+ Copyright (C) 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Written by Ian Dall
+ * 19-Apr-94
+ *
+ * Formerly part of aout-pc532-mach.c. Split out to allow more
+ * flexibility with multiple formats.
+ *
+ */
+/* This architecture has N_TXTOFF and N_TXTADDR defined as if
+ * N_HEADER_IN_TEXT, but the a_text entry (text size) does not include the
+ * space for the header. So we have N_HEADER_IN_TEXT defined to
+ * 1 and specially define our own N_TXTSIZE
+ */
+
+#define N_HEADER_IN_TEXT(x) 1
+#define N_TXTSIZE(x) ((x).a_text)
+
+
+#define TEXT_START_ADDR 0x10000 /* from old ld */
+#define TARGET_PAGE_SIZE 0x1000 /* from old ld, 032 & 532 are really 512/4k */
+
+/* Use a_entry of 0 to distinguish object files from OMAGIC executables */
+#define N_TXTADDR(x) \
+ (N_MAGIC(x) == OMAGIC ? \
+ ((x).a_entry < TEXT_START_ADDR? 0: TEXT_START_ADDR): \
+ (N_MAGIC(x) == NMAGIC? TEXT_START_ADDR: \
+ TEXT_START_ADDR + EXEC_BYTES_SIZE))
+
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+#define N_SHARED_LIB(x) 0
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_ns32k
+
+#define MY(OP) CAT(pc532machaout_,OP)
+
+/* Must be the same as aout-ns32k.c */
+#define NAME(x,y) CAT3(ns32kaout,_32_,y)
+
+#define TARGETNAME "a.out-pc532-mach"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libaout.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+
+/* We can`t use the MYNS macro here for cpp reasons too subtle for me -- IWD */
+
+#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
+
+/* libaout doesn't use NAME for these ... */
+
+#define MY_get_section_contents aout_32_get_section_contents
+
+#define MY_text_includes_header 1
+
+#define MY_exec_header_not_counted 1
+
+#define MYNSX(OP) CAT(ns32kaout_,OP)
+reloc_howto_type *
+MYNSX(bfd_reloc_type_lookup)
+ PARAMS((bfd *abfd AND
+ bfd_reloc_code_real_type code));
+
+boolean
+MYNSX(write_object_contents)
+ PARAMS((bfd *abfd));
+
+static boolean
+MY(write_object_contents) (abfd)
+bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+#if CHOOSE_RELOC_SIZE
+ CHOOSE_RELOC_SIZE(abfd);
+#else
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+#endif
+
+ BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_ns32k);
+ switch (bfd_get_mach (abfd))
+ {
+ case 32032:
+ N_SET_MACHTYPE (*execp, M_NS32032);
+ break;
+ case 32532:
+ default:
+ N_SET_MACHTYPE (*execp, M_NS32532);
+ break;
+ }
+ N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
+
+#define MY_write_object_contents MY(write_object_contents)
+
+#include "aout-target.h"
diff --git a/bfd/pe-arm.c b/bfd/pe-arm.c
new file mode 100644
index 00000000000..d315888f1da
--- /dev/null
+++ b/bfd/pe-arm.c
@@ -0,0 +1,34 @@
+/* BFD back-end for ARM PECOFF files.
+ Copyright 1995, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#ifndef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM armpe_little_vec
+#define TARGET_LITTLE_NAME "pe-arm-little"
+#define TARGET_BIG_SYM armpe_big_vec
+#define TARGET_BIG_NAME "pe-arm-big"
+#endif
+
+#define COFF_WITH_PE
+#define PCRELOFFSET true
+#define COFF_LONG_SECTION_NAMES
+
+#include "coff-arm.c"
diff --git a/bfd/pe-i386.c b/bfd/pe-i386.c
new file mode 100644
index 00000000000..bcdbe444994
--- /dev/null
+++ b/bfd/pe-i386.c
@@ -0,0 +1,31 @@
+/* BFD back-end for Intel 386 PECOFF files.
+ Copyright 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+
+#define TARGET_SYM i386pe_vec
+#define TARGET_NAME "pe-i386"
+#define COFF_WITH_PE
+#define PCRELOFFSET true
+#define TARGET_UNDERSCORE '_'
+#define COFF_LONG_SECTION_NAMES
+
+#include "coff-i386.c"
diff --git a/bfd/pe-mcore.c b/bfd/pe-mcore.c
new file mode 100644
index 00000000000..8119f815895
--- /dev/null
+++ b/bfd/pe-mcore.c
@@ -0,0 +1,36 @@
+/* BFD back-end for MCore PECOFF files.
+ Copyright 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#ifndef TARGET_BIG_SYM
+#define TARGET_BIG_SYM mcore_pe_big_vec
+#define TARGET_BIG_NAME "pe-mcore-big"
+#define TARGET_LITTLE_SYM mcore_pe_little_vec
+#define TARGET_LITTLE_NAME "pe-mcore-little"
+#endif
+
+#define COFF_WITH_PE
+#define PCRELOFFSET true
+#define COFF_LONG_SECTION_NAMES
+
+#define MCORE_PE
+
+#include "coff-mcore.c"
diff --git a/bfd/pe-ppc.c b/bfd/pe-ppc.c
new file mode 100644
index 00000000000..a2bac04ac6f
--- /dev/null
+++ b/bfd/pe-ppc.c
@@ -0,0 +1,41 @@
+/* BFD back-end for PowerPC PECOFF files.
+ Copyright 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+
+#define E_FILENMLEN 18
+
+#define PPC_PE
+
+#define TARGET_LITTLE_SYM bfd_powerpcle_pe_vec
+#define TARGET_LITTLE_NAME "pe-powerpcle"
+
+#define TARGET_BIG_SYM bfd_powerpc_pe_vec
+#define TARGET_BIG_NAME "pe-powerpc"
+
+#define COFF_WITH_PE
+
+#define COFF_LONG_SECTION_NAMES
+
+/* FIXME: verify PCRELOFFSET is always false */
+
+#include "coff-ppc.c"
diff --git a/bfd/pei-arm.c b/bfd/pei-arm.c
new file mode 100644
index 00000000000..4ba5b3a5cd0
--- /dev/null
+++ b/bfd/pei-arm.c
@@ -0,0 +1,36 @@
+/* BFD back-end for arm PE IMAGE COFF files.
+ Copyright 1995, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#ifndef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM armpei_little_vec
+#define TARGET_LITTLE_NAME "pei-arm-little"
+#define TARGET_BIG_SYM armpei_big_vec
+#define TARGET_BIG_NAME "pei-arm-big"
+#endif
+
+#define IMAGE_BASE NT_IMAGE_BASE
+#define COFF_IMAGE_WITH_PE
+#define COFF_WITH_PE
+#define PCRELOFFSET true
+#define COFF_LONG_SECTION_NAMES
+
+#include "coff-arm.c"
diff --git a/bfd/pei-i386.c b/bfd/pei-i386.c
new file mode 100644
index 00000000000..8b52968370e
--- /dev/null
+++ b/bfd/pei-i386.c
@@ -0,0 +1,35 @@
+/* BFD back-end for Intel 386 PE IMAGE COFF files.
+ Copyright 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#define TARGET_SYM i386pei_vec
+#define TARGET_NAME "pei-i386"
+#define IMAGE_BASE NT_IMAGE_BASE
+#define COFF_IMAGE_WITH_PE
+#define COFF_WITH_PE
+#define PCRELOFFSET true
+#define TARGET_UNDERSCORE '_'
+#define COFF_LONG_SECTION_NAMES
+
+#include "coff-i386.c"
+
+
+
diff --git a/bfd/pei-mcore.c b/bfd/pei-mcore.c
new file mode 100644
index 00000000000..d4a872cdfcb
--- /dev/null
+++ b/bfd/pei-mcore.c
@@ -0,0 +1,38 @@
+/* BFD back-end for MCore PECOFF files.
+ Copyright 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#ifndef TARGET_BIG_SYM
+#define TARGET_BIG_SYM mcore_pei_big_vec
+#define TARGET_BIG_NAME "pei-mcore-big"
+#define TARGET_LITTLE_SYM mcore_pei_little_vec
+#define TARGET_LITTLE_NAME "pei-mcore-little"
+#endif
+
+#define IMAGE_BASE NT_IMAGE_BASE
+#define COFF_IMAGE_WITH_PE
+#define COFF_WITH_PE
+#define PCRELOFFSET true
+#define COFF_LONG_SECTION_NAMES
+
+#define MCORE_PE
+
+#include "coff-mcore.c"
diff --git a/bfd/pei-ppc.c b/bfd/pei-ppc.c
new file mode 100644
index 00000000000..839bc0f64af
--- /dev/null
+++ b/bfd/pei-ppc.c
@@ -0,0 +1,47 @@
+/* BFD back-end for PowerPC PE IMAGE COFF files.
+ Copyright 1995 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+/* setting up for a PE environment stolen directly from the i386 structure */
+#define E_FILNMLEN 18 /* # characters in a file name */
+
+#define PPC_PE
+
+#define TARGET_LITTLE_SYM bfd_powerpcle_pei_vec
+#define TARGET_LITTLE_NAME "pei-powerpcle"
+
+#define TARGET_BIG_SYM bfd_powerpc_pei_vec
+#define TARGET_BIG_NAME "pei-powerpc"
+
+#define IMAGE_BASE NT_IMAGE_BASE
+
+#define COFF_IMAGE_WITH_PE
+#define COFF_WITH_PE
+
+#define COFF_LONG_SECTION_NAMES
+
+/* FIXME: Verify PCRELOFFSET is always false */
+
+#include "coff-ppc.c"
+
+
+
diff --git a/bfd/peicode.h b/bfd/peicode.h
new file mode 100644
index 00000000000..79d16e5abe9
--- /dev/null
+++ b/bfd/peicode.h
@@ -0,0 +1,2144 @@
+/* Support for the generic parts of most COFF variants, for BFD.
+ Copyright 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+Most of this hacked by Steve Chamberlain,
+ sac@cygnus.com
+*/
+
+/* Hey look, some documentation [and in a place you expect to find it]!
+
+ The main reference for the pei format is "Microsoft Portable Executable
+ and Common Object File Format Specification 4.1". Get it if you need to
+ do some serious hacking on this code.
+
+ Another reference:
+ "Peering Inside the PE: A Tour of the Win32 Portable Executable
+ File Format", MSJ 1994, Volume 9.
+
+ The *sole* difference between the pe format and the pei format is that the
+ latter has an MSDOS 2.0 .exe header on the front that prints the message
+ "This app must be run under Windows." (or some such).
+ (FIXME: Whether that statement is *really* true or not is unknown.
+ Are there more subtle differences between pe and pei formats?
+ For now assume there aren't. If you find one, then for God sakes
+ document it here!)
+
+ The Microsoft docs use the word "image" instead of "executable" because
+ the former can also refer to a DLL (shared library). Confusion can arise
+ because the `i' in `pei' also refers to "image". The `pe' format can
+ also create images (i.e. executables), it's just that to run on a win32
+ system you need to use the pei format.
+
+ FIXME: Please add more docs here so the next poor fool that has to hack
+ on this code has a chance of getting something accomplished without
+ wasting too much time.
+*/
+
+#ifdef coff_bfd_print_private_bfd_data
+static boolean (*pe_saved_coff_bfd_print_private_bfd_data)
+ PARAMS ((bfd *, PTR))
+ = coff_bfd_print_private_bfd_data;
+#undef coff_bfd_print_private_bfd_data
+#else
+static boolean (*pe_saved_coff_bfd_print_private_bfd_data)
+ PARAMS ((bfd *, PTR))
+ = NULL;
+#endif
+#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
+
+#define coff_mkobject pe_mkobject
+#define coff_mkobject_hook pe_mkobject_hook
+
+#ifndef GET_FCN_LNNOPTR
+#define GET_FCN_LNNOPTR(abfd, ext) \
+ bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#endif
+
+#ifndef GET_FCN_ENDNDX
+#define GET_FCN_ENDNDX(abfd, ext) \
+ bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#endif
+
+#ifndef PUT_FCN_LNNOPTR
+#define PUT_FCN_LNNOPTR(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#endif
+#ifndef PUT_FCN_ENDNDX
+#define PUT_FCN_ENDNDX(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#endif
+#ifndef GET_LNSZ_LNNO
+#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
+#endif
+#ifndef GET_LNSZ_SIZE
+#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
+#endif
+#ifndef PUT_LNSZ_LNNO
+#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
+#endif
+#ifndef PUT_LNSZ_SIZE
+#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
+#endif
+#ifndef GET_SCN_SCNLEN
+#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
+#endif
+#ifndef GET_SCN_NRELOC
+#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
+#endif
+#ifndef GET_SCN_NLINNO
+#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
+#endif
+#ifndef PUT_SCN_SCNLEN
+#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
+#endif
+#ifndef PUT_SCN_NRELOC
+#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
+#endif
+#ifndef PUT_SCN_NLINNO
+#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
+#endif
+#ifndef GET_LINENO_LNNO
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
+#endif
+#ifndef PUT_LINENO_LNNO
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
+#endif
+
+/* The f_symptr field in the filehdr is sometimes 64 bits. */
+#ifndef GET_FILEHDR_SYMPTR
+#define GET_FILEHDR_SYMPTR bfd_h_get_32
+#endif
+#ifndef PUT_FILEHDR_SYMPTR
+#define PUT_FILEHDR_SYMPTR bfd_h_put_32
+#endif
+
+/* Some fields in the aouthdr are sometimes 64 bits. */
+#ifndef GET_AOUTHDR_TSIZE
+#define GET_AOUTHDR_TSIZE bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_TSIZE
+#define PUT_AOUTHDR_TSIZE bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_DSIZE
+#define GET_AOUTHDR_DSIZE bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_DSIZE
+#define PUT_AOUTHDR_DSIZE bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_BSIZE
+#define GET_AOUTHDR_BSIZE bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_BSIZE
+#define PUT_AOUTHDR_BSIZE bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_ENTRY
+#define GET_AOUTHDR_ENTRY bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_ENTRY
+#define PUT_AOUTHDR_ENTRY bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_TEXT_START
+#define GET_AOUTHDR_TEXT_START bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_TEXT_START
+#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
+#endif
+#ifndef GET_AOUTHDR_DATA_START
+#define GET_AOUTHDR_DATA_START bfd_h_get_32
+#endif
+#ifndef PUT_AOUTHDR_DATA_START
+#define PUT_AOUTHDR_DATA_START bfd_h_put_32
+#endif
+
+/* Some fields in the scnhdr are sometimes 64 bits. */
+#ifndef GET_SCNHDR_PADDR
+#define GET_SCNHDR_PADDR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_PADDR
+#define PUT_SCNHDR_PADDR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_VADDR
+#define GET_SCNHDR_VADDR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_VADDR
+#define PUT_SCNHDR_VADDR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_SIZE
+#define GET_SCNHDR_SIZE bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_SIZE
+#define PUT_SCNHDR_SIZE bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_SCNPTR
+#define GET_SCNHDR_SCNPTR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_SCNPTR
+#define PUT_SCNHDR_SCNPTR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_RELPTR
+#define GET_SCNHDR_RELPTR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_RELPTR
+#define PUT_SCNHDR_RELPTR bfd_h_put_32
+#endif
+#ifndef GET_SCNHDR_LNNOPTR
+#define GET_SCNHDR_LNNOPTR bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_LNNOPTR
+#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
+#endif
+
+static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static unsigned int coff_swap_aux_out
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
+static void add_data_entry
+ PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
+static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
+static boolean pe_print_idata PARAMS ((bfd *, PTR));
+static boolean pe_print_edata PARAMS ((bfd *, PTR));
+static boolean pe_print_pdata PARAMS ((bfd *, PTR));
+static boolean pe_print_reloc PARAMS ((bfd *, PTR));
+static boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR));
+static boolean pe_mkobject PARAMS ((bfd *));
+static PTR pe_mkobject_hook PARAMS ((bfd *, PTR, PTR));
+static boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+
+/**********************************************************************/
+
+static void
+coff_swap_reloc_in (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ RELOC *reloc_src = (RELOC *) src;
+ struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
+
+ reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
+ reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
+
+ reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
+
+#ifdef SWAP_IN_RELOC_OFFSET
+ reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
+ (bfd_byte *) reloc_src->r_offset);
+#endif
+}
+
+
+static unsigned int
+coff_swap_reloc_out (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ struct internal_reloc *reloc_src = (struct internal_reloc *)src;
+ struct external_reloc *reloc_dst = (struct external_reloc *)dst;
+ bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
+ bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
+
+ bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
+ reloc_dst->r_type);
+
+#ifdef SWAP_OUT_RELOC_OFFSET
+ SWAP_OUT_RELOC_OFFSET(abfd,
+ reloc_src->r_offset,
+ (bfd_byte *) reloc_dst->r_offset);
+#endif
+#ifdef SWAP_OUT_RELOC_EXTRA
+ SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
+#endif
+ return RELSZ;
+}
+
+
+static void
+coff_swap_filehdr_in (abfd, src, dst)
+ bfd *abfd;
+ PTR src;
+ PTR dst;
+{
+ FILHDR *filehdr_src = (FILHDR *) src;
+ struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
+ filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
+ filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
+ filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
+
+ filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
+ filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
+ filehdr_dst->f_symptr = bfd_h_get_32 (abfd, (bfd_byte *) filehdr_src->f_symptr);
+
+ /* Other people's tools sometimes generate headers with an nsyms but
+ a zero symptr. */
+ if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0)
+ {
+ filehdr_dst->f_nsyms = 0;
+ filehdr_dst->f_flags |= F_LSYMS;
+ }
+
+ filehdr_dst->f_opthdr = bfd_h_get_16(abfd,
+ (bfd_byte *)filehdr_src-> f_opthdr);
+}
+
+#ifdef COFF_IMAGE_WITH_PE
+
+static unsigned int
+coff_swap_filehdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ int idx;
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
+ FILHDR *filehdr_out = (FILHDR *)out;
+
+ if (pe_data (abfd)->has_reloc_section)
+ filehdr_in->f_flags &= ~F_RELFLG;
+
+ if (pe_data (abfd)->dll)
+ filehdr_in->f_flags |= F_DLL;
+
+ filehdr_in->pe.e_magic = DOSMAGIC;
+ filehdr_in->pe.e_cblp = 0x90;
+ filehdr_in->pe.e_cp = 0x3;
+ filehdr_in->pe.e_crlc = 0x0;
+ filehdr_in->pe.e_cparhdr = 0x4;
+ filehdr_in->pe.e_minalloc = 0x0;
+ filehdr_in->pe.e_maxalloc = 0xffff;
+ filehdr_in->pe.e_ss = 0x0;
+ filehdr_in->pe.e_sp = 0xb8;
+ filehdr_in->pe.e_csum = 0x0;
+ filehdr_in->pe.e_ip = 0x0;
+ filehdr_in->pe.e_cs = 0x0;
+ filehdr_in->pe.e_lfarlc = 0x40;
+ filehdr_in->pe.e_ovno = 0x0;
+
+ for (idx=0; idx < 4; idx++)
+ filehdr_in->pe.e_res[idx] = 0x0;
+
+ filehdr_in->pe.e_oemid = 0x0;
+ filehdr_in->pe.e_oeminfo = 0x0;
+
+ for (idx=0; idx < 10; idx++)
+ filehdr_in->pe.e_res2[idx] = 0x0;
+
+ filehdr_in->pe.e_lfanew = 0x80;
+
+ /* this next collection of data are mostly just characters. It appears
+ to be constant within the headers put on NT exes */
+ filehdr_in->pe.dos_message[0] = 0x0eba1f0e;
+ filehdr_in->pe.dos_message[1] = 0xcd09b400;
+ filehdr_in->pe.dos_message[2] = 0x4c01b821;
+ filehdr_in->pe.dos_message[3] = 0x685421cd;
+ filehdr_in->pe.dos_message[4] = 0x70207369;
+ filehdr_in->pe.dos_message[5] = 0x72676f72;
+ filehdr_in->pe.dos_message[6] = 0x63206d61;
+ filehdr_in->pe.dos_message[7] = 0x6f6e6e61;
+ filehdr_in->pe.dos_message[8] = 0x65622074;
+ filehdr_in->pe.dos_message[9] = 0x6e757220;
+ filehdr_in->pe.dos_message[10] = 0x206e6920;
+ filehdr_in->pe.dos_message[11] = 0x20534f44;
+ filehdr_in->pe.dos_message[12] = 0x65646f6d;
+ filehdr_in->pe.dos_message[13] = 0x0a0d0d2e;
+ filehdr_in->pe.dos_message[14] = 0x24;
+ filehdr_in->pe.dos_message[15] = 0x0;
+ filehdr_in->pe.nt_signature = NT_SIGNATURE;
+
+
+
+ bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
+ bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
+
+ bfd_h_put_32(abfd, time (0), (bfd_byte *) filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
+ (bfd_byte *) filehdr_out->f_symptr);
+ bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
+ bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
+ bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
+
+ /* put in extra dos header stuff. This data remains essentially
+ constant, it just has to be tacked on to the beginning of all exes
+ for NT */
+ bfd_h_put_16(abfd, filehdr_in->pe.e_magic, (bfd_byte *) filehdr_out->e_magic);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_cblp, (bfd_byte *) filehdr_out->e_cblp);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_cp, (bfd_byte *) filehdr_out->e_cp);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_crlc, (bfd_byte *) filehdr_out->e_crlc);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_cparhdr,
+ (bfd_byte *) filehdr_out->e_cparhdr);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_minalloc,
+ (bfd_byte *) filehdr_out->e_minalloc);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_maxalloc,
+ (bfd_byte *) filehdr_out->e_maxalloc);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_ss, (bfd_byte *) filehdr_out->e_ss);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_sp, (bfd_byte *) filehdr_out->e_sp);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_csum, (bfd_byte *) filehdr_out->e_csum);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_ip, (bfd_byte *) filehdr_out->e_ip);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_cs, (bfd_byte *) filehdr_out->e_cs);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_lfarlc, (bfd_byte *) filehdr_out->e_lfarlc);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_ovno, (bfd_byte *) filehdr_out->e_ovno);
+ {
+ int idx;
+ for (idx=0; idx < 4; idx++)
+ bfd_h_put_16(abfd, filehdr_in->pe.e_res[idx],
+ (bfd_byte *) filehdr_out->e_res[idx]);
+ }
+ bfd_h_put_16(abfd, filehdr_in->pe.e_oemid, (bfd_byte *) filehdr_out->e_oemid);
+ bfd_h_put_16(abfd, filehdr_in->pe.e_oeminfo,
+ (bfd_byte *) filehdr_out->e_oeminfo);
+ {
+ int idx;
+ for (idx=0; idx < 10; idx++)
+ bfd_h_put_16(abfd, filehdr_in->pe.e_res2[idx],
+ (bfd_byte *) filehdr_out->e_res2[idx]);
+ }
+ bfd_h_put_32(abfd, filehdr_in->pe.e_lfanew, (bfd_byte *) filehdr_out->e_lfanew);
+
+ {
+ int idx;
+ for (idx=0; idx < 16; idx++)
+ bfd_h_put_32(abfd, filehdr_in->pe.dos_message[idx],
+ (bfd_byte *) filehdr_out->dos_message[idx]);
+ }
+
+ /* also put in the NT signature */
+ bfd_h_put_32(abfd, filehdr_in->pe.nt_signature,
+ (bfd_byte *) filehdr_out->nt_signature);
+
+
+
+
+ return FILHSZ;
+}
+#else
+
+static unsigned int
+coff_swap_filehdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
+ FILHDR *filehdr_out = (FILHDR *)out;
+
+ bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
+ bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
+ bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
+ (bfd_byte *) filehdr_out->f_symptr);
+ bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
+ bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
+ bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
+
+ return FILHSZ;
+}
+
+#endif
+
+
+static void
+coff_swap_sym_in (abfd, ext1, in1)
+ bfd *abfd;
+ PTR ext1;
+ PTR in1;
+{
+ SYMENT *ext = (SYMENT *)ext1;
+ struct internal_syment *in = (struct internal_syment *)in1;
+
+ if( ext->e.e_name[0] == 0) {
+ in->_n._n_n._n_zeroes = 0;
+ in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
+ }
+ else {
+#if SYMNMLEN != E_SYMNMLEN
+ -> Error, we need to cope with truncating or extending SYMNMLEN!;
+#else
+ memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
+#endif
+ }
+
+ in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
+ in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
+ if (sizeof(ext->e_type) == 2){
+ in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
+ }
+ else {
+ in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
+ }
+ in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
+ in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
+
+ /* The section symbols for the .idata$ sections have class 0x68
+ (C_SECTION), which MS documentation indicates is a section
+ symbol. Unfortunately, the value field in the symbol is simply a
+ copy of the .idata section's flags rather than something useful.
+ When these symbols are encountered, change the value to 0 so that
+ they will be handled somewhat correctly in the bfd code. */
+ if (in->n_sclass == C_SECTION)
+ {
+ in->n_value = 0x0;
+
+ /* FIXME: This is clearly wrong. The problem seems to be that
+ undefined C_SECTION symbols appear in the first object of a
+ MS generated .lib file, and the symbols are not defined
+ anywhere. */
+ in->n_scnum = 1;
+
+ /* I have tried setting the class to 3 and using the following
+ to set the section number. This will put the address of the
+ pointer to the string kernel32.dll at addresses 0 and 0x10
+ off start of idata section which is not correct */
+ /* if (strcmp (in->_n._n_name, ".idata$4") == 0) */
+ /* in->n_scnum = 3; */
+ /* else */
+ /* in->n_scnum = 2; */
+ }
+
+#ifdef coff_swap_sym_in_hook
+ coff_swap_sym_in_hook(abfd, ext1, in1);
+#endif
+}
+
+static unsigned int
+coff_swap_sym_out (abfd, inp, extp)
+ bfd *abfd;
+ PTR inp;
+ PTR extp;
+{
+ struct internal_syment *in = (struct internal_syment *)inp;
+ SYMENT *ext =(SYMENT *)extp;
+ if(in->_n._n_name[0] == 0) {
+ bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
+ bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
+ }
+ else {
+#if SYMNMLEN != E_SYMNMLEN
+ -> Error, we need to cope with truncating or extending SYMNMLEN!;
+#else
+ memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
+#endif
+ }
+
+ bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
+ bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
+ if (sizeof(ext->e_type) == 2)
+ {
+ bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
+ }
+ else
+ {
+ bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
+ }
+ bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
+ bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
+
+ return SYMESZ;
+}
+
+static void
+coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
+ bfd *abfd;
+ PTR ext1;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR in1;
+{
+ AUXENT *ext = (AUXENT *)ext1;
+ union internal_auxent *in = (union internal_auxent *)in1;
+
+ switch (class) {
+ case C_FILE:
+ if (ext->x_file.x_fname[0] == 0) {
+ in->x_file.x_n.x_zeroes = 0;
+ in->x_file.x_n.x_offset =
+ bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
+ } else {
+#if FILNMLEN != E_FILNMLEN
+ -> Error, we need to cope with truncating or extending FILNMLEN!;
+#else
+ memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+#endif
+ }
+ return;
+
+
+ case C_STAT:
+#ifdef C_LEAFSTAT
+ case C_LEAFSTAT:
+#endif
+ case C_HIDDEN:
+ if (type == T_NULL) {
+ in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
+ in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
+ in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
+ in->x_scn.x_checksum = bfd_h_get_32 (abfd,
+ (bfd_byte *) ext->x_scn.x_checksum);
+ in->x_scn.x_associated =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_scn.x_associated);
+ in->x_scn.x_comdat = bfd_h_get_8 (abfd,
+ (bfd_byte *) ext->x_scn.x_comdat);
+ return;
+ }
+ break;
+ }
+
+ in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
+#ifndef NO_TVNDX
+ in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
+#endif
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
+ in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
+ }
+ else
+ {
+#if DIMNUM != E_DIMNUM
+ #error we need to cope with truncating or extending DIMNUM
+#endif
+ in->x_sym.x_fcnary.x_ary.x_dimen[0] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ in->x_sym.x_fcnary.x_ary.x_dimen[1] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ in->x_sym.x_fcnary.x_ary.x_dimen[2] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ in->x_sym.x_fcnary.x_ary.x_dimen[3] =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ }
+
+ if (ISFCN(type)) {
+ in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ }
+ else {
+ in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
+ in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
+ }
+}
+
+static unsigned int
+coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
+ bfd *abfd;
+ PTR inp;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR extp;
+{
+ union internal_auxent *in = (union internal_auxent *)inp;
+ AUXENT *ext = (AUXENT *)extp;
+
+ memset((PTR)ext, 0, AUXESZ);
+ switch (class) {
+ case C_FILE:
+ if (in->x_file.x_fname[0] == 0) {
+ bfd_h_put_32(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
+ bfd_h_put_32(abfd,
+ in->x_file.x_n.x_offset,
+ (bfd_byte *) ext->x_file.x_n.x_offset);
+ }
+ else {
+#if FILNMLEN != E_FILNMLEN
+ -> Error, we need to cope with truncating or extending FILNMLEN!;
+#else
+ memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
+#endif
+ }
+ return AUXESZ;
+
+
+ case C_STAT:
+#ifdef C_LEAFSTAT
+ case C_LEAFSTAT:
+#endif
+ case C_HIDDEN:
+ if (type == T_NULL) {
+ PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
+ PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
+ PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
+ bfd_h_put_32 (abfd, in->x_scn.x_checksum,
+ (bfd_byte *) ext->x_scn.x_checksum);
+ bfd_h_put_16 (abfd, in->x_scn.x_associated,
+ (bfd_byte *) ext->x_scn.x_associated);
+ bfd_h_put_8 (abfd, in->x_scn.x_comdat,
+ (bfd_byte *) ext->x_scn.x_comdat);
+ return AUXESZ;
+ }
+ break;
+ }
+
+ bfd_h_put_32(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
+#ifndef NO_TVNDX
+ bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
+#endif
+
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
+ {
+ PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
+ PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
+ }
+ else
+ {
+#if DIMNUM != E_DIMNUM
+ #error we need to cope with truncating or extending DIMNUM
+#endif
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
+ (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ }
+
+ if (ISFCN (type))
+ bfd_h_put_32 (abfd, in->x_sym.x_misc.x_fsize,
+ (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ else
+ {
+ PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
+ PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
+ }
+
+ return AUXESZ;
+}
+
+
+static void
+coff_swap_lineno_in (abfd, ext1, in1)
+ bfd *abfd;
+ PTR ext1;
+ PTR in1;
+{
+ LINENO *ext = (LINENO *)ext1;
+ struct internal_lineno *in = (struct internal_lineno *)in1;
+
+ in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
+ in->l_lnno = GET_LINENO_LNNO(abfd, ext);
+}
+
+static unsigned int
+coff_swap_lineno_out (abfd, inp, outp)
+ bfd *abfd;
+ PTR inp;
+ PTR outp;
+{
+ struct internal_lineno *in = (struct internal_lineno *)inp;
+ struct external_lineno *ext = (struct external_lineno *)outp;
+ bfd_h_put_32(abfd, in->l_addr.l_symndx, (bfd_byte *)
+ ext->l_addr.l_symndx);
+
+ PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
+ return LINESZ;
+}
+
+
+
+static void
+coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
+ bfd *abfd;
+ PTR aouthdr_ext1;
+ PTR aouthdr_int1;
+{
+ struct internal_extra_pe_aouthdr *a;
+ PEAOUTHDR *src = (PEAOUTHDR *)(aouthdr_ext1);
+ AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
+ struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
+
+ aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
+ aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
+ aouthdr_int->tsize =
+ GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
+ aouthdr_int->dsize =
+ GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
+ aouthdr_int->bsize =
+ GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
+ aouthdr_int->entry =
+ GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
+ aouthdr_int->text_start =
+ GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
+ aouthdr_int->data_start =
+ GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
+
+ a = &aouthdr_int->pe;
+ a->ImageBase = bfd_h_get_32 (abfd, (bfd_byte *) src->ImageBase);
+ a->SectionAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->SectionAlignment);
+ a->FileAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->FileAlignment);
+ a->MajorOperatingSystemVersion =
+ bfd_h_get_16 (abfd, (bfd_byte *) src->MajorOperatingSystemVersion);
+ a->MinorOperatingSystemVersion =
+ bfd_h_get_16 (abfd, (bfd_byte *) src->MinorOperatingSystemVersion);
+ a->MajorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorImageVersion);
+ a->MinorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorImageVersion);
+ a->MajorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorSubsystemVersion);
+ a->MinorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorSubsystemVersion);
+ a->Reserved1 = bfd_h_get_32 (abfd, (bfd_byte *) src->Reserved1);
+ a->SizeOfImage = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfImage);
+ a->SizeOfHeaders = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfHeaders);
+ a->CheckSum = bfd_h_get_32 (abfd, (bfd_byte *) src->CheckSum);
+ a->Subsystem = bfd_h_get_16 (abfd, (bfd_byte *) src->Subsystem);
+ a->DllCharacteristics = bfd_h_get_16 (abfd, (bfd_byte *) src->DllCharacteristics);
+ a->SizeOfStackReserve = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfStackReserve);
+ a->SizeOfStackCommit = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfStackCommit);
+ a->SizeOfHeapReserve = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfHeapReserve);
+ a->SizeOfHeapCommit = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfHeapCommit);
+ a->LoaderFlags = bfd_h_get_32 (abfd, (bfd_byte *) src->LoaderFlags);
+ a->NumberOfRvaAndSizes = bfd_h_get_32 (abfd, (bfd_byte *) src->NumberOfRvaAndSizes);
+
+ {
+ int idx;
+ for (idx=0; idx < 16; idx++)
+ {
+ a->DataDirectory[idx].VirtualAddress =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][0]);
+ a->DataDirectory[idx].Size =
+ bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][1]);
+ }
+ }
+
+ if (aouthdr_int->entry)
+ {
+ aouthdr_int->entry += a->ImageBase;
+ aouthdr_int->entry &= 0xffffffff;
+ }
+ if (aouthdr_int->tsize)
+ {
+ aouthdr_int->text_start += a->ImageBase;
+ aouthdr_int->text_start &= 0xffffffff;
+ }
+ if (aouthdr_int->dsize)
+ {
+ aouthdr_int->data_start += a->ImageBase;
+ aouthdr_int->data_start &= 0xffffffff;
+ }
+
+#ifdef POWERPC_LE_PE
+ /* These three fields are normally set up by ppc_relocate_section.
+ In the case of reading a file in, we can pick them up from
+ the DataDirectory.
+ */
+ first_thunk_address = a->DataDirectory[12].VirtualAddress ;
+ thunk_size = a->DataDirectory[12].Size;
+ import_table_size = a->DataDirectory[1].Size;
+#endif
+}
+
+
+static void add_data_entry (abfd, aout, idx, name, base)
+ bfd *abfd;
+ struct internal_extra_pe_aouthdr *aout;
+ int idx;
+ char *name;
+ bfd_vma base;
+{
+ asection *sec = bfd_get_section_by_name (abfd, name);
+
+ /* add import directory information if it exists */
+ if ((sec != NULL)
+ && (coff_section_data (abfd, sec) != NULL)
+ && (pei_section_data (abfd, sec) != NULL))
+ {
+ aout->DataDirectory[idx].VirtualAddress = (sec->vma - base) & 0xffffffff;
+ aout->DataDirectory[idx].Size = pei_section_data (abfd, sec)->virt_size;
+ sec->flags |= SEC_DATA;
+ }
+}
+
+static unsigned int
+coff_swap_aouthdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
+ struct internal_extra_pe_aouthdr *extra = &pe_data (abfd)->pe_opthdr;
+ PEAOUTHDR *aouthdr_out = (PEAOUTHDR *)out;
+
+ bfd_vma sa = extra->SectionAlignment;
+ bfd_vma fa = extra->FileAlignment;
+ bfd_vma ib = extra->ImageBase ;
+
+ if (aouthdr_in->tsize)
+ {
+ aouthdr_in->text_start -= ib;
+ aouthdr_in->text_start &= 0xffffffff;
+ }
+ if (aouthdr_in->dsize)
+ {
+ aouthdr_in->data_start -= ib;
+ aouthdr_in->data_start &= 0xffffffff;
+ }
+ if (aouthdr_in->entry)
+ {
+ aouthdr_in->entry -= ib;
+ aouthdr_in->entry &= 0xffffffff;
+ }
+
+#define FA(x) (((x) + fa -1 ) & (- fa))
+#define SA(x) (((x) + sa -1 ) & (- sa))
+
+ /* We like to have the sizes aligned */
+
+ aouthdr_in->bsize = FA (aouthdr_in->bsize);
+
+
+ extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
+
+ /* first null out all data directory entries .. */
+ memset (extra->DataDirectory, sizeof (extra->DataDirectory), 0);
+
+ add_data_entry (abfd, extra, 0, ".edata", ib);
+ add_data_entry (abfd, extra, 1, ".idata", ib);
+ add_data_entry (abfd, extra, 2, ".rsrc" ,ib);
+
+#ifdef POWERPC_LE_PE
+ /* FIXME: do other PE platforms use this? */
+ add_data_entry (abfd, extra, 3, ".pdata" ,ib);
+#endif
+
+ add_data_entry (abfd, extra, 5, ".reloc", ib);
+
+#ifdef POWERPC_LE_PE
+ /* On the PPC NT system, this field is set up as follows. It is
+ not an "officially" reserved field, so it currently has no title.
+ first_thunk_address is idata$5, and the thunk_size is the size
+ of the idata$5 chunk of the idata section.
+ */
+ extra->DataDirectory[12].VirtualAddress = first_thunk_address;
+ extra->DataDirectory[12].Size = thunk_size;
+
+ /* On the PPC NT system, the size of the directory entry is not the
+ size of the entire section. It's actually offset to the end of
+ the idata$3 component of the idata section. This is the size of
+ the entire import table. (also known as the start of idata$4)
+ */
+ extra->DataDirectory[1].Size = import_table_size;
+#endif
+
+ {
+ asection *sec;
+ bfd_vma dsize= 0;
+ bfd_vma isize = SA(abfd->sections->filepos);
+ bfd_vma tsize= 0;
+
+ for (sec = abfd->sections; sec; sec = sec->next)
+ {
+ int rounded = FA(sec->_raw_size);
+
+ if (sec->flags & SEC_DATA)
+ dsize += rounded;
+ if (sec->flags & SEC_CODE)
+ tsize += rounded;
+ isize += SA(rounded);
+ }
+
+ aouthdr_in->dsize = dsize;
+ aouthdr_in->tsize = tsize;
+ extra->SizeOfImage = isize;
+ }
+
+ extra->SizeOfHeaders = abfd->sections->filepos;
+ bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->standard.magic);
+
+#ifdef POWERPC_LE_PE
+ /* this little piece of magic sets the "linker version" field to 2.60 */
+ bfd_h_put_16(abfd, 2 + 60 * 256, (bfd_byte *) aouthdr_out->standard.vstamp);
+#else
+ /* this little piece of magic sets the "linker version" field to 2.55 */
+ bfd_h_put_16(abfd, 2 + 55 * 256, (bfd_byte *) aouthdr_out->standard.vstamp);
+#endif
+
+ PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->standard.tsize);
+ PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->standard.dsize);
+ PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->standard.bsize);
+ PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->standard.entry);
+ PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
+ (bfd_byte *) aouthdr_out->standard.text_start);
+
+ PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
+ (bfd_byte *) aouthdr_out->standard.data_start);
+
+
+ bfd_h_put_32 (abfd, extra->ImageBase,
+ (bfd_byte *) aouthdr_out->ImageBase);
+ bfd_h_put_32 (abfd, extra->SectionAlignment,
+ (bfd_byte *) aouthdr_out->SectionAlignment);
+ bfd_h_put_32 (abfd, extra->FileAlignment,
+ (bfd_byte *) aouthdr_out->FileAlignment);
+ bfd_h_put_16 (abfd, extra->MajorOperatingSystemVersion,
+ (bfd_byte *) aouthdr_out->MajorOperatingSystemVersion);
+ bfd_h_put_16 (abfd, extra->MinorOperatingSystemVersion,
+ (bfd_byte *) aouthdr_out->MinorOperatingSystemVersion);
+ bfd_h_put_16 (abfd, extra->MajorImageVersion,
+ (bfd_byte *) aouthdr_out->MajorImageVersion);
+ bfd_h_put_16 (abfd, extra->MinorImageVersion,
+ (bfd_byte *) aouthdr_out->MinorImageVersion);
+ bfd_h_put_16 (abfd, extra->MajorSubsystemVersion,
+ (bfd_byte *) aouthdr_out->MajorSubsystemVersion);
+ bfd_h_put_16 (abfd, extra->MinorSubsystemVersion,
+ (bfd_byte *) aouthdr_out->MinorSubsystemVersion);
+ bfd_h_put_32 (abfd, extra->Reserved1,
+ (bfd_byte *) aouthdr_out->Reserved1);
+ bfd_h_put_32 (abfd, extra->SizeOfImage,
+ (bfd_byte *) aouthdr_out->SizeOfImage);
+ bfd_h_put_32 (abfd, extra->SizeOfHeaders,
+ (bfd_byte *) aouthdr_out->SizeOfHeaders);
+ bfd_h_put_32 (abfd, extra->CheckSum,
+ (bfd_byte *) aouthdr_out->CheckSum);
+ bfd_h_put_16 (abfd, extra->Subsystem,
+ (bfd_byte *) aouthdr_out->Subsystem);
+ bfd_h_put_16 (abfd, extra->DllCharacteristics,
+ (bfd_byte *) aouthdr_out->DllCharacteristics);
+ bfd_h_put_32 (abfd, extra->SizeOfStackReserve,
+ (bfd_byte *) aouthdr_out->SizeOfStackReserve);
+ bfd_h_put_32 (abfd, extra->SizeOfStackCommit,
+ (bfd_byte *) aouthdr_out->SizeOfStackCommit);
+ bfd_h_put_32 (abfd, extra->SizeOfHeapReserve,
+ (bfd_byte *) aouthdr_out->SizeOfHeapReserve);
+ bfd_h_put_32 (abfd, extra->SizeOfHeapCommit,
+ (bfd_byte *) aouthdr_out->SizeOfHeapCommit);
+ bfd_h_put_32 (abfd, extra->LoaderFlags,
+ (bfd_byte *) aouthdr_out->LoaderFlags);
+ bfd_h_put_32 (abfd, extra->NumberOfRvaAndSizes,
+ (bfd_byte *) aouthdr_out->NumberOfRvaAndSizes);
+ {
+ int idx;
+ for (idx=0; idx < 16; idx++)
+ {
+ bfd_h_put_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
+ (bfd_byte *) aouthdr_out->DataDirectory[idx][0]);
+ bfd_h_put_32 (abfd, extra->DataDirectory[idx].Size,
+ (bfd_byte *) aouthdr_out->DataDirectory[idx][1]);
+ }
+ }
+
+ return AOUTSZ;
+}
+
+static void
+ coff_swap_scnhdr_in (abfd, ext, in)
+ bfd *abfd;
+ PTR ext;
+ PTR in;
+{
+ SCNHDR *scnhdr_ext = (SCNHDR *) ext;
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
+
+ memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
+ scnhdr_int->s_vaddr =
+ GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
+ scnhdr_int->s_paddr =
+ GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
+ scnhdr_int->s_size =
+ GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
+ scnhdr_int->s_scnptr =
+ GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
+ scnhdr_int->s_relptr =
+ GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
+ scnhdr_int->s_lnnoptr =
+ GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
+ scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
+
+ scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
+ scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
+
+ if (scnhdr_int->s_vaddr != 0)
+ {
+ scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
+ scnhdr_int->s_vaddr &= 0xffffffff;
+ }
+ if (strcmp (scnhdr_int->s_name, _BSS) == 0)
+ {
+ scnhdr_int->s_size = scnhdr_int->s_paddr;
+ scnhdr_int->s_paddr = 0;
+ }
+}
+
+static unsigned int
+coff_swap_scnhdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
+ SCNHDR *scnhdr_ext = (SCNHDR *)out;
+ unsigned int ret = SCNHSZ;
+ bfd_vma ps;
+ bfd_vma ss;
+
+ memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
+
+ PUT_SCNHDR_VADDR (abfd,
+ ((scnhdr_int->s_vaddr
+ - pe_data(abfd)->pe_opthdr.ImageBase)
+ & 0xffffffff),
+ (bfd_byte *) scnhdr_ext->s_vaddr);
+
+ /* NT wants the size data to be rounded up to the next NT_FILE_ALIGNMENT
+ value except for the BSS section, its s_size should be 0 */
+
+
+ if (strcmp (scnhdr_int->s_name, _BSS) == 0)
+ {
+ ps = scnhdr_int->s_size;
+ ss = 0;
+ }
+ else
+ {
+ ps = scnhdr_int->s_paddr;
+ ss = scnhdr_int->s_size;
+ }
+
+ PUT_SCNHDR_SIZE (abfd, ss,
+ (bfd_byte *) scnhdr_ext->s_size);
+
+
+ PUT_SCNHDR_PADDR (abfd, ps, (bfd_byte *) scnhdr_ext->s_paddr);
+
+ PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
+ (bfd_byte *) scnhdr_ext->s_scnptr);
+ PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
+ (bfd_byte *) scnhdr_ext->s_relptr);
+ PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
+ (bfd_byte *) scnhdr_ext->s_lnnoptr);
+
+ /* Extra flags must be set when dealing with NT. All sections should also
+ have the IMAGE_SCN_MEM_READ (0x40000000) flag set. In addition, the
+ .text section must have IMAGE_SCN_MEM_EXECUTE (0x20000000) and the data
+ sections (.idata, .data, .bss, .CRT) must have IMAGE_SCN_MEM_WRITE set
+ (this is especially important when dealing with the .idata section since
+ the addresses for routines from .dlls must be overwritten). If .reloc
+ section data is ever generated, we must add IMAGE_SCN_MEM_DISCARDABLE
+ (0x02000000). Also, the resource data should also be read and
+ writable. */
+
+ /* FIXME: alignment is also encoded in this field, at least on ppc (krk) */
+ /* FIXME: even worse, I don't see how to get the original alignment field*/
+ /* back... */
+
+ /* FIXME: Basing this on section names is bogus. Also, this should
+ be in sec_to_styp_flags. */
+
+ {
+ int flags = scnhdr_int->s_flags;
+ if (strcmp (scnhdr_int->s_name, ".data") == 0 ||
+ strcmp (scnhdr_int->s_name, ".CRT") == 0 ||
+ strcmp (scnhdr_int->s_name, ".bss") == 0)
+ flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE;
+ else if (strcmp (scnhdr_int->s_name, ".text") == 0)
+ flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE;
+ else if (strcmp (scnhdr_int->s_name, ".reloc") == 0)
+ flags = (SEC_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE
+ | IMAGE_SCN_MEM_SHARED);
+ else if (strcmp (scnhdr_int->s_name, ".idata") == 0)
+ flags = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | SEC_DATA;
+ else if (strcmp (scnhdr_int->s_name, ".rdata") == 0
+ || strcmp (scnhdr_int->s_name, ".edata") == 0)
+ flags = IMAGE_SCN_MEM_READ | SEC_DATA;
+ else if (strcmp (scnhdr_int->s_name, ".pdata") == 0)
+ flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES |
+ IMAGE_SCN_MEM_READ ;
+ /* Remember this field is a max of 8 chars, so the null is _not_ there
+ for an 8 character name like ".reldata". (yep. Stupid bug) */
+ else if (strncmp (scnhdr_int->s_name, ".reldata", 8) == 0)
+ flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_8BYTES |
+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE ;
+ else if (strcmp (scnhdr_int->s_name, ".ydata") == 0)
+ flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_8BYTES |
+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE ;
+ else if (strncmp (scnhdr_int->s_name, ".drectve", 8) == 0)
+ flags = IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE ;
+ else if (strncmp (scnhdr_int->s_name, ".stab", 5) == 0)
+ flags |= (IMAGE_SCN_LNK_INFO | IMAGE_SCN_MEM_DISCARDABLE
+ | IMAGE_SCN_MEM_SHARED | IMAGE_SCN_MEM_READ);
+ else if (strcmp (scnhdr_int->s_name, ".rsrc") == 0)
+ flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_SHARED;
+ else
+ flags |= IMAGE_SCN_MEM_READ;
+
+ bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
+ }
+
+ if (scnhdr_int->s_nlnno <= 0xffff)
+ bfd_h_put_16(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
+ else
+ {
+ (*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
+ bfd_get_filename (abfd),
+ scnhdr_int->s_nlnno);
+ bfd_set_error (bfd_error_file_truncated);
+ bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
+ ret = 0;
+ }
+ if (scnhdr_int->s_nreloc <= 0xffff)
+ bfd_h_put_16(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
+ else
+ {
+ (*_bfd_error_handler) (_("%s: reloc overflow: 0x%lx > 0xffff"),
+ bfd_get_filename (abfd),
+ scnhdr_int->s_nreloc);
+ bfd_set_error (bfd_error_file_truncated);
+ bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
+ ret = 0;
+ }
+ return ret;
+}
+
+static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
+{
+ N_ ("Export Directory [.edata (or where ever we found it)]"),
+ N_ ("Import Directory [parts of .idata]"),
+ N_ ("Resource Directory [.rsrc]"),
+ N_ ("Exception Directory [.pdata]"),
+ N_ ("Security Directory"),
+ N_ ("Base Relocation Directory [.reloc]"),
+ N_ ("Debug Directory"),
+ N_ ("Description Directory"),
+ N_ ("Special Directory"),
+ N_ ("Thread Storage Directory [.tls]"),
+ N_ ("Load Configuration Directory"),
+ N_ ("Bound Import Directory"),
+ N_ ("Import Address Table Directory"),
+ N_ ("Reserved"),
+ N_ ("Reserved"),
+ N_ ("Reserved")
+};
+
+/**********************************************************************/
+static boolean
+pe_print_idata(abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
+{
+ FILE *file = (FILE *) vfile;
+ bfd_byte *data = 0;
+ asection *section = bfd_get_section_by_name (abfd, ".idata");
+ unsigned long adj;
+
+#ifdef POWERPC_LE_PE
+ asection *rel_section = bfd_get_section_by_name (abfd, ".reldata");
+#endif
+
+ bfd_size_type datasize;
+ bfd_size_type dataoff;
+ bfd_size_type secsize;
+ bfd_size_type i;
+ bfd_size_type start, stop;
+ int onaline = 20;
+
+ pe_data_type *pe = pe_data (abfd);
+ struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
+
+ if (section != NULL)
+ {
+ datasize = bfd_section_size (abfd, section);
+ dataoff = 0;
+
+ if (datasize == 0)
+ return true;
+ }
+ else
+ {
+ bfd_vma addr, size;
+
+ addr = extra->DataDirectory[1].VirtualAddress;
+ size = extra->DataDirectory[1].Size;
+
+ if (addr == 0 || size == 0)
+ return true;
+
+ for (section = abfd->sections; section != NULL; section = section->next)
+ {
+ if (section->vma - extra->ImageBase <= addr
+ && ((section->vma - extra->ImageBase
+ + bfd_section_size (abfd, section))
+ >= addr + size))
+ break;
+ }
+ if (section == NULL)
+ return true;
+
+ /* For some reason the import table size is not reliable. The
+ import data will extend past the indicated size, and before
+ the indicated address. */
+ dataoff = addr - (section->vma - extra->ImageBase);
+ datasize = size;
+ }
+
+#ifdef POWERPC_LE_PE
+ if (rel_section != 0 && bfd_section_size (abfd, rel_section) != 0)
+ {
+ /* The toc address can be found by taking the starting address,
+ which on the PPC locates a function descriptor. The descriptor
+ consists of the function code starting address followed by the
+ address of the toc. The starting address we get from the bfd,
+ and the descriptor is supposed to be in the .reldata section.
+ */
+
+ bfd_vma loadable_toc_address;
+ bfd_vma toc_address;
+ bfd_vma start_address;
+ bfd_byte *data = 0;
+ int offset;
+ data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
+ rel_section));
+ if (data == NULL && bfd_section_size (abfd, rel_section) != 0)
+ return false;
+
+ datasize = bfd_section_size (abfd, rel_section);
+
+ bfd_get_section_contents (abfd,
+ rel_section,
+ (PTR) data, 0,
+ bfd_section_size (abfd, rel_section));
+
+ offset = abfd->start_address - rel_section->vma;
+
+ start_address = bfd_get_32(abfd, data+offset);
+ loadable_toc_address = bfd_get_32(abfd, data+offset+4);
+ toc_address = loadable_toc_address - 32768;
+
+ fprintf(file,
+ _("\nFunction descriptor located at the start address: %04lx\n"),
+ (unsigned long int) (abfd->start_address));
+ fprintf (file,
+ _("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"),
+ start_address, loadable_toc_address, toc_address);
+ }
+ else
+ {
+ fprintf(file,
+ _("\nNo reldata section! Function descriptor not decoded.\n"));
+ }
+#endif
+
+ fprintf(file,
+ _("\nThe Import Tables (interpreted .idata section contents)\n"));
+ fprintf(file,
+ _(" vma: Hint Time Forward DLL First\n"));
+ fprintf(file,
+ _(" Table Stamp Chain Name Thunk\n"));
+
+ secsize = bfd_section_size (abfd, section);
+ data = (bfd_byte *) bfd_malloc (secsize);
+ if (data == NULL && secsize != 0)
+ return false;
+
+ if (! bfd_get_section_contents (abfd, section, (PTR) data, 0, secsize))
+ return false;
+
+ adj = (extra->ImageBase - section->vma) & 0xffffffff;
+
+ start = dataoff;
+ stop = dataoff + datasize;
+ for (i = start; i < stop; i += onaline)
+ {
+ bfd_vma hint_addr;
+ bfd_vma time_stamp;
+ bfd_vma forward_chain;
+ bfd_vma dll_name;
+ bfd_vma first_thunk;
+ int idx = 0;
+ bfd_size_type j;
+ char *dll;
+
+ fprintf (file,
+ " %08lx\t",
+ (unsigned long int) (i + section->vma + dataoff));
+
+ if (i+20 > stop)
+ {
+ /* check stuff */
+ ;
+ }
+
+ hint_addr = bfd_get_32(abfd, data+i);
+ time_stamp = bfd_get_32(abfd, data+i+4);
+ forward_chain = bfd_get_32(abfd, data+i+8);
+ dll_name = bfd_get_32(abfd, data+i+12);
+ first_thunk = bfd_get_32(abfd, data+i+16);
+
+ fprintf(file, "%08lx %08lx %08lx %08lx %08lx\n",
+ hint_addr,
+ time_stamp,
+ forward_chain,
+ dll_name,
+ first_thunk);
+
+ if (hint_addr == 0 && first_thunk == 0)
+ break;
+
+ /* the image base is present in the section->vma */
+ dll = (char *) data + dll_name + adj;
+ fprintf(file, _("\n\tDLL Name: %s\n"), dll);
+
+ if (hint_addr != 0)
+ {
+ fprintf (file, _("\tvma: Hint/Ord Member-Name\n"));
+
+ idx = hint_addr + adj;
+
+ for (j = 0; j < stop; j += 4)
+ {
+ unsigned long member = bfd_get_32 (abfd, data + idx + j);
+
+ if (member == 0)
+ break;
+ if (member & 0x80000000)
+ fprintf (file, "\t%04lx\t %4lu", member,
+ member & 0x7fffffff);
+ else
+ {
+ int ordinal;
+ char *member_name;
+
+ ordinal = bfd_get_16 (abfd, data + member + adj);
+ member_name = (char *) data + member + adj + 2;
+ fprintf (file, "\t%04lx\t %4d %s",
+ member, ordinal, member_name);
+ }
+
+ /* If the time stamp is not zero, the import address
+ table holds actual addresses. */
+ if (time_stamp != 0
+ && first_thunk != 0
+ && first_thunk != hint_addr)
+ fprintf (file, "\t%04lx",
+ bfd_get_32 (abfd, data + first_thunk + adj + j));
+
+ fprintf (file, "\n");
+ }
+ }
+
+ if (hint_addr != first_thunk && time_stamp == 0)
+ {
+ int differ = 0;
+ int idx2;
+
+ idx2 = first_thunk + adj;
+
+ for (j=0;j<stop;j+=4)
+ {
+ int ordinal;
+ char *member_name;
+ bfd_vma hint_member = 0;
+ bfd_vma iat_member;
+
+ if (hint_addr != 0)
+ hint_member = bfd_get_32 (abfd, data + idx + j);
+ iat_member = bfd_get_32 (abfd, data + idx2 + j);
+
+ if (hint_addr == 0 && iat_member == 0)
+ break;
+
+ if (hint_addr == 0 || hint_member != iat_member)
+ {
+ if (differ == 0)
+ {
+ fprintf (file,
+ _("\tThe Import Address Table (difference found)\n"));
+ fprintf(file, _("\tvma: Hint/Ord Member-Name\n"));
+ differ = 1;
+ }
+ if (iat_member == 0)
+ {
+ fprintf(file,
+ _("\t>>> Ran out of IAT members!\n"));
+ }
+ else
+ {
+ ordinal = bfd_get_16(abfd,
+ data + iat_member + adj);
+ member_name = (char *) data + iat_member + adj + 2;
+ fprintf(file, "\t%04lx\t %4d %s\n",
+ iat_member, ordinal, member_name);
+ }
+ }
+
+ if (hint_addr != 0 && hint_member == 0)
+ break;
+ }
+ if (differ == 0)
+ {
+ fprintf(file,
+ _("\tThe Import Address Table is identical\n"));
+ }
+ }
+
+ fprintf(file, "\n");
+
+ }
+
+ free (data);
+
+ return true;
+}
+
+static boolean
+pe_print_edata (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
+{
+ FILE *file = (FILE *) vfile;
+ bfd_byte *data = 0;
+ asection *section = bfd_get_section_by_name (abfd, ".edata");
+
+ bfd_size_type datasize;
+ bfd_size_type dataoff;
+ bfd_size_type i;
+
+ int adj;
+ struct EDT_type
+ {
+ long export_flags; /* reserved - should be zero */
+ long time_stamp;
+ short major_ver;
+ short minor_ver;
+ bfd_vma name; /* rva - relative to image base */
+ long base; /* ordinal base */
+ unsigned long num_functions; /* Number in the export address table */
+ unsigned long num_names; /* Number in the name pointer table */
+ bfd_vma eat_addr; /* rva to the export address table */
+ bfd_vma npt_addr; /* rva to the Export Name Pointer Table */
+ bfd_vma ot_addr; /* rva to the Ordinal Table */
+ } edt;
+
+ pe_data_type *pe = pe_data (abfd);
+ struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
+
+ if (section != NULL)
+ {
+ datasize = bfd_section_size (abfd, section);
+ dataoff = 0;
+ }
+ else
+ {
+ bfd_vma addr, size;
+
+ addr = extra->DataDirectory[0].VirtualAddress;
+ size = extra->DataDirectory[0].Size;
+
+ if (addr == 0 || size == 0)
+ return true;
+
+ for (section = abfd->sections; section != NULL; section = section->next)
+ {
+ if (section->vma - extra->ImageBase <= addr
+ && ((section->vma - extra->ImageBase
+ + bfd_section_size (abfd, section))
+ >= addr + size))
+ break;
+ }
+ if (section == NULL)
+ return true;
+
+ datasize = size;
+ dataoff = addr - (section->vma - extra->ImageBase);
+ }
+
+ data = (bfd_byte *) bfd_malloc (datasize);
+ if (data == NULL && datasize != 0)
+ return false;
+
+ if (! bfd_get_section_contents (abfd, section, (PTR) data, dataoff,
+ datasize))
+ return false;
+
+ /* Go get Export Directory Table */
+ edt.export_flags = bfd_get_32(abfd, data+0);
+ edt.time_stamp = bfd_get_32(abfd, data+4);
+ edt.major_ver = bfd_get_16(abfd, data+8);
+ edt.minor_ver = bfd_get_16(abfd, data+10);
+ edt.name = bfd_get_32(abfd, data+12);
+ edt.base = bfd_get_32(abfd, data+16);
+ edt.num_functions = bfd_get_32(abfd, data+20);
+ edt.num_names = bfd_get_32(abfd, data+24);
+ edt.eat_addr = bfd_get_32(abfd, data+28);
+ edt.npt_addr = bfd_get_32(abfd, data+32);
+ edt.ot_addr = bfd_get_32(abfd, data+36);
+
+ adj = (extra->ImageBase - (section->vma + dataoff)) & 0xffffffff;
+
+
+ /* Dump the EDT first first */
+ fprintf(file,
+ _("\nThe Export Tables (interpreted .edata section contents)\n\n"));
+
+ fprintf(file,
+ _("Export Flags \t\t\t%lx\n"), (unsigned long) edt.export_flags);
+
+ fprintf(file,
+ _("Time/Date stamp \t\t%lx\n"), (unsigned long) edt.time_stamp);
+
+ fprintf(file,
+ _("Major/Minor \t\t\t%d/%d\n"), edt.major_ver, edt.minor_ver);
+
+ fprintf (file,
+ _("Name \t\t\t\t"));
+ fprintf_vma (file, edt.name);
+ fprintf (file,
+ " %s\n", data + edt.name + adj);
+
+ fprintf(file,
+ _("Ordinal Base \t\t\t%ld\n"), edt.base);
+
+ fprintf(file,
+ _("Number in:\n"));
+
+ fprintf(file,
+ _("\tExport Address Table \t\t%lx\n"),
+ edt.num_functions);
+
+ fprintf(file,
+ _("\t[Name Pointer/Ordinal] Table\t%lu\n"), edt.num_names);
+
+ fprintf(file,
+ _("Table Addresses\n"));
+
+ fprintf (file,
+ _("\tExport Address Table \t\t"));
+ fprintf_vma (file, edt.eat_addr);
+ fprintf (file, "\n");
+
+ fprintf (file,
+ _("\tName Pointer Table \t\t"));
+ fprintf_vma (file, edt.npt_addr);
+ fprintf (file, "\n");
+
+ fprintf (file,
+ _("\tOrdinal Table \t\t\t"));
+ fprintf_vma (file, edt.ot_addr);
+ fprintf (file, "\n");
+
+
+ /* The next table to find si the Export Address Table. It's basically
+ a list of pointers that either locate a function in this dll, or
+ forward the call to another dll. Something like:
+ typedef union
+ {
+ long export_rva;
+ long forwarder_rva;
+ } export_address_table_entry;
+ */
+
+ fprintf(file,
+ _("\nExport Address Table -- Ordinal Base %ld\n"),
+ edt.base);
+
+ for (i = 0; i < edt.num_functions; ++i)
+ {
+ bfd_vma eat_member = bfd_get_32 (abfd,
+ data + edt.eat_addr + (i * 4) + adj);
+ bfd_vma eat_actual = (extra->ImageBase + eat_member) & 0xffffffff;
+ bfd_vma edata_start = bfd_get_section_vma (abfd,section) + dataoff;
+ bfd_vma edata_end = edata_start + datasize;
+
+ if (eat_member == 0)
+ continue;
+
+ if (edata_start < eat_actual && eat_actual < edata_end)
+ {
+ /* this rva is to a name (forwarding function) in our section */
+ /* Should locate a function descriptor */
+ fprintf(file,
+ "\t[%4ld] +base[%4ld] %04lx %s -- %s\n",
+ (long) i, (long) (i + edt.base), eat_member,
+ "Forwarder RVA", data + eat_member + adj);
+ }
+ else
+ {
+ /* Should locate a function descriptor in the reldata section */
+ fprintf(file,
+ "\t[%4ld] +base[%4ld] %04lx %s\n",
+ (long) i, (long) (i + edt.base), eat_member, "Export RVA");
+ }
+ }
+
+ /* The Export Name Pointer Table is paired with the Export Ordinal Table */
+ /* Dump them in parallel for clarity */
+ fprintf(file,
+ _("\n[Ordinal/Name Pointer] Table\n"));
+
+ for (i = 0; i < edt.num_names; ++i)
+ {
+ bfd_vma name_ptr = bfd_get_32(abfd,
+ data +
+ edt.npt_addr
+ + (i*4) + adj);
+
+ char *name = (char *) data + name_ptr + adj;
+
+ bfd_vma ord = bfd_get_16(abfd,
+ data +
+ edt.ot_addr
+ + (i*2) + adj);
+ fprintf(file,
+ "\t[%4ld] %s\n", (long) ord, name);
+
+ }
+
+ free (data);
+
+ return true;
+}
+
+static boolean
+pe_print_pdata (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
+{
+ FILE *file = (FILE *) vfile;
+ bfd_byte *data = 0;
+ asection *section = bfd_get_section_by_name (abfd, ".pdata");
+ bfd_size_type datasize = 0;
+ bfd_size_type i;
+ bfd_size_type start, stop;
+ int onaline = 20;
+
+ if (section == 0)
+ return true;
+
+ stop = bfd_section_size (abfd, section);
+ if ((stop % onaline) != 0)
+ fprintf (file, _("Warning, .pdata section size (%ld) is not a multiple of %d\n"),
+ (long)stop, onaline);
+
+ fprintf(file,
+ _("\nThe Function Table (interpreted .pdata section contents)\n"));
+ fprintf(file,
+ _(" vma:\t\tBegin End EH EH PrologEnd\n"));
+ fprintf(file,
+ _(" \t\tAddress Address Handler Data Address\n"));
+
+ if (bfd_section_size (abfd, section) == 0)
+ return true;
+
+ data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
+ datasize = bfd_section_size (abfd, section);
+ if (data == NULL && datasize != 0)
+ return false;
+
+ bfd_get_section_contents (abfd,
+ section,
+ (PTR) data, 0,
+ bfd_section_size (abfd, section));
+
+ start = 0;
+
+ for (i = start; i < stop; i += onaline)
+ {
+ bfd_vma begin_addr;
+ bfd_vma end_addr;
+ bfd_vma eh_handler;
+ bfd_vma eh_data;
+ bfd_vma prolog_end_addr;
+
+ if (i+20 > stop)
+ break;
+
+ begin_addr = bfd_get_32(abfd, data+i);
+ end_addr = bfd_get_32(abfd, data+i+4);
+ eh_handler = bfd_get_32(abfd, data+i+8);
+ eh_data = bfd_get_32(abfd, data+i+12);
+ prolog_end_addr = bfd_get_32(abfd, data+i+16);
+
+ if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
+ && eh_data == 0 && prolog_end_addr == 0)
+ {
+ /* We are probably into the padding of the
+ section now */
+ break;
+ }
+
+ fprintf (file,
+ " %08lx\t",
+ (unsigned long int) (i + section->vma));
+
+ fprintf(file, "%08lx %08lx %08lx %08lx %08lx",
+ begin_addr,
+ end_addr,
+ eh_handler,
+ eh_data,
+ prolog_end_addr);
+
+#ifdef POWERPC_LE_PE
+ if (eh_handler == 0 && eh_data != 0)
+ {
+ /* Special bits here, although the meaning may */
+ /* be a little mysterious. The only one I know */
+ /* for sure is 0x03. */
+ /* Code Significance */
+ /* 0x00 None */
+ /* 0x01 Register Save Millicode */
+ /* 0x02 Register Restore Millicode */
+ /* 0x03 Glue Code Sequence */
+ switch (eh_data)
+ {
+ case 0x01:
+ fprintf(file, _(" Register save millicode"));
+ break;
+ case 0x02:
+ fprintf(file, _(" Register restore millicode"));
+ break;
+ case 0x03:
+ fprintf(file, _(" Glue code sequence"));
+ break;
+ default:
+ break;
+ }
+ }
+#endif
+ fprintf(file, "\n");
+ }
+
+ free (data);
+
+ return true;
+}
+
+static const char *tbl[6] =
+{
+"ABSOLUTE",
+"HIGH",
+"LOW",
+"HIGHLOW",
+"HIGHADJ",
+"MIPS_JMPADDR"
+};
+
+static boolean
+pe_print_reloc (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
+{
+ FILE *file = (FILE *) vfile;
+ bfd_byte *data = 0;
+ asection *section = bfd_get_section_by_name (abfd, ".reloc");
+ bfd_size_type datasize = 0;
+ bfd_size_type i;
+ bfd_size_type start, stop;
+
+ if (section == 0)
+ return true;
+
+ if (bfd_section_size (abfd, section) == 0)
+ return true;
+
+ fprintf(file,
+ _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n"));
+
+ data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
+ datasize = bfd_section_size (abfd, section);
+ if (data == NULL && datasize != 0)
+ return false;
+
+ bfd_get_section_contents (abfd,
+ section,
+ (PTR) data, 0,
+ bfd_section_size (abfd, section));
+
+ start = 0;
+
+ stop = bfd_section_size (abfd, section);
+
+ for (i = start; i < stop;)
+ {
+ int j;
+ bfd_vma virtual_address;
+ long number, size;
+
+ /* The .reloc section is a sequence of blocks, with a header consisting
+ of two 32 bit quantities, followed by a number of 16 bit entries */
+
+ virtual_address = bfd_get_32(abfd, data+i);
+ size = bfd_get_32(abfd, data+i+4);
+ number = (size - 8) / 2;
+
+ if (size == 0)
+ {
+ break;
+ }
+
+ fprintf (file,
+ _("\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"),
+ virtual_address, size, size, number);
+
+ for (j = 0; j < number; ++j)
+ {
+ unsigned short e = bfd_get_16(abfd, data + i + 8 + j*2);
+ int t = (e & 0xF000) >> 12;
+ int off = e & 0x0FFF;
+
+ if (t > 5)
+ abort();
+
+ fprintf(file,
+ _("\treloc %4d offset %4x [%4lx] %s\n"),
+ j, off, (long) (off + virtual_address), tbl[t]);
+
+ }
+ i += size;
+ }
+
+ free (data);
+
+ return true;
+}
+
+static boolean
+pe_print_private_bfd_data (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
+{
+ FILE *file = (FILE *) vfile;
+ int j;
+ pe_data_type *pe = pe_data (abfd);
+ struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
+
+ /* The MS dumpbin program reportedly ands with 0xff0f before
+ printing the characteristics field. Not sure why. No reason to
+ emulate it here. */
+ fprintf (file, _("\nCharacteristics 0x%x\n"), pe->real_flags);
+#undef PF
+#define PF(x, y) if (pe->real_flags & x) { fprintf (file, "\t%s\n", y); }
+ PF (F_RELFLG, "relocations stripped");
+ PF (F_EXEC, "executable");
+ PF (F_LNNO, "line numbers stripped");
+ PF (F_LSYMS, "symbols stripped");
+ PF (0x80, "little endian");
+ PF (F_AR32WR, "32 bit words");
+ PF (0x200, "debugging information removed");
+ PF (0x1000, "system file");
+ PF (F_DLL, "DLL");
+ PF (0x8000, "big endian");
+#undef PF
+
+ fprintf (file,"\nImageBase\t\t");
+ fprintf_vma (file, i->ImageBase);
+ fprintf (file,"\nSectionAlignment\t");
+ fprintf_vma (file, i->SectionAlignment);
+ fprintf (file,"\nFileAlignment\t\t");
+ fprintf_vma (file, i->FileAlignment);
+ fprintf (file,"\nMajorOSystemVersion\t%d\n", i->MajorOperatingSystemVersion);
+ fprintf (file,"MinorOSystemVersion\t%d\n", i->MinorOperatingSystemVersion);
+ fprintf (file,"MajorImageVersion\t%d\n", i->MajorImageVersion);
+ fprintf (file,"MinorImageVersion\t%d\n", i->MinorImageVersion);
+ fprintf (file,"MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
+ fprintf (file,"MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
+ fprintf (file,"Reserved1\t\t%08lx\n", i->Reserved1);
+ fprintf (file,"SizeOfImage\t\t%08lx\n", i->SizeOfImage);
+ fprintf (file,"SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders);
+ fprintf (file,"CheckSum\t\t%08lx\n", i->CheckSum);
+ fprintf (file,"Subsystem\t\t%08x\n", i->Subsystem);
+ fprintf (file,"DllCharacteristics\t%08x\n", i->DllCharacteristics);
+ fprintf (file,"SizeOfStackReserve\t");
+ fprintf_vma (file, i->SizeOfStackReserve);
+ fprintf (file,"\nSizeOfStackCommit\t");
+ fprintf_vma (file, i->SizeOfStackCommit);
+ fprintf (file,"\nSizeOfHeapReserve\t");
+ fprintf_vma (file, i->SizeOfHeapReserve);
+ fprintf (file,"\nSizeOfHeapCommit\t");
+ fprintf_vma (file, i->SizeOfHeapCommit);
+ fprintf (file,"\nLoaderFlags\t\t%08lx\n", i->LoaderFlags);
+ fprintf (file,"NumberOfRvaAndSizes\t%08lx\n", i->NumberOfRvaAndSizes);
+
+ fprintf (file,"\nThe Data Directory\n");
+ for (j = 0; j < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; j++)
+ {
+ fprintf (file, "Entry %1x ", j);
+ fprintf_vma (file, i->DataDirectory[j].VirtualAddress);
+ fprintf (file, " %08lx ", i->DataDirectory[j].Size);
+ fprintf (file, "%s\n", dir_names[j]);
+ }
+
+ pe_print_idata (abfd, vfile);
+ pe_print_edata (abfd, vfile);
+ pe_print_pdata (abfd, vfile);
+ pe_print_reloc (abfd, vfile);
+
+ if (pe_saved_coff_bfd_print_private_bfd_data != NULL)
+ {
+ fputc ('\n', file);
+
+ return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile);
+ }
+
+ return true;
+}
+
+static boolean
+pe_mkobject (abfd)
+ bfd * abfd;
+{
+ pe_data_type *pe;
+ abfd->tdata.pe_obj_data =
+ (struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type));
+
+ if (abfd->tdata.pe_obj_data == 0)
+ return false;
+
+ pe = pe_data (abfd);
+
+ pe->coff.pe = 1;
+ pe->in_reloc_p = in_reloc_p;
+ return true;
+}
+
+/* Create the COFF backend specific information. */
+static PTR
+pe_mkobject_hook (abfd, filehdr, aouthdr)
+ bfd * abfd;
+ PTR filehdr;
+ PTR aouthdr;
+{
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+ pe_data_type *pe;
+
+ if (pe_mkobject (abfd) == false)
+ return NULL;
+
+ pe = pe_data (abfd);
+ pe->coff.sym_filepos = internal_f->f_symptr;
+ /* These members communicate important constants about the symbol
+ table to GDB's symbol-reading code. These `constants'
+ unfortunately vary among coff implementations... */
+ pe->coff.local_n_btmask = N_BTMASK;
+ pe->coff.local_n_btshft = N_BTSHFT;
+ pe->coff.local_n_tmask = N_TMASK;
+ pe->coff.local_n_tshift = N_TSHIFT;
+ pe->coff.local_symesz = SYMESZ;
+ pe->coff.local_auxesz = AUXESZ;
+ pe->coff.local_linesz = LINESZ;
+
+ obj_raw_syment_count (abfd) =
+ obj_conv_table_size (abfd) =
+ internal_f->f_nsyms;
+
+ pe->real_flags = internal_f->f_flags;
+
+ if ((internal_f->f_flags & F_DLL) != 0)
+ pe->dll = 1;
+
+#ifdef COFF_IMAGE_WITH_PE
+ if (aouthdr)
+ pe->pe_opthdr = ((struct internal_aouthdr *)aouthdr)->pe;
+#endif
+
+#ifdef ARM
+ if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
+ coff_data (abfd) ->flags = 0;
+#endif
+
+ return (PTR) pe;
+}
+
+
+
+/* Copy any private info we understand from the input bfd
+ to the output bfd. */
+
+#ifdef coff_bfd_copy_private_bfd_data
+static boolean (*pe_saved_coff_bfd_copy_private_bfd_data)
+ PARAMS ((bfd *, bfd *))
+ = coff_bfd_copy_private_bfd_data;
+#undef coff_bfd_copy_private_bfd_data
+#else
+static boolean (*pe_saved_coff_bfd_copy_private_bfd_data)
+ PARAMS ((bfd *, bfd *))
+ = NULL;
+#endif
+#define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data
+
+static boolean
+pe_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd, *obfd;
+{
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_coff_flavour
+ || obfd->xvec->flavour != bfd_target_coff_flavour)
+ return true;
+
+ pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
+ pe_data (obfd)->dll = pe_data (ibfd)->dll;
+
+ if (pe_saved_coff_bfd_copy_private_bfd_data)
+ return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd);
+
+ return true;
+}
+
+#ifdef COFF_IMAGE_WITH_PE
+
+/* Copy private section data. */
+
+#define coff_bfd_copy_private_section_data pe_bfd_copy_private_section_data
+
+static boolean pe_bfd_copy_private_section_data
+ PARAMS ((bfd *, asection *, bfd *, asection *));
+
+static boolean
+pe_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
+ bfd *ibfd;
+ asection *isec;
+ bfd *obfd;
+ asection *osec;
+{
+ if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
+ || bfd_get_flavour (obfd) != bfd_target_coff_flavour)
+ return true;
+
+ if (coff_section_data (ibfd, isec) != NULL
+ && pei_section_data (ibfd, isec) != NULL)
+ {
+ if (coff_section_data (obfd, osec) == NULL)
+ {
+ osec->used_by_bfd =
+ (PTR) bfd_zalloc (obfd, sizeof (struct coff_section_tdata));
+ if (osec->used_by_bfd == NULL)
+ return false;
+ }
+ if (pei_section_data (obfd, osec) == NULL)
+ {
+ coff_section_data (obfd, osec)->tdata =
+ (PTR) bfd_zalloc (obfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (obfd, osec)->tdata == NULL)
+ return false;
+ }
+ pei_section_data (obfd, osec)->virt_size =
+ pei_section_data (ibfd, isec)->virt_size;
+ }
+
+ return true;
+}
+
+#endif
diff --git a/bfd/po/Make-in b/bfd/po/Make-in
new file mode 100644
index 00000000000..0552db1feef
--- /dev/null
+++ b/bfd/po/Make-in
@@ -0,0 +1,251 @@
+# Makefile for program source directory in GNU NLS utilities package.
+# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SHELL = /bin/sh
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+datadir = $(prefix)/@DATADIRNAME@
+localedir = $(datadir)/locale
+gnulocaledir = $(prefix)/share/locale
+gettextsrcdir = $(prefix)/share/gettext/po
+subdir = po
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+
+CC = @CC@
+GENCAT = @GENCAT@
+GMSGFMT = PATH=../src:$$PATH @GMSGFMT@
+MSGFMT = @MSGFMT@
+XGETTEXT = PATH=../src:$$PATH @XGETTEXT@
+MSGMERGE = PATH=../src:$$PATH msgmerge
+
+DEFS = @DEFS@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+
+INCLUDES = -I.. -I$(top_srcdir)/intl
+
+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
+
+SOURCES = cat-id-tbl.c
+POFILES = @POFILES@
+GMOFILES = @GMOFILES@
+DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
+stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
+
+POTFILES = \
+
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+INSTOBJEXT = @INSTOBJEXT@
+
+.SUFFIXES:
+.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
+
+.c.o:
+ $(COMPILE) $<
+
+.po.pox:
+ $(MAKE) $(PACKAGE).pot
+ $(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
+
+.po.mo:
+ $(MSGFMT) -o $@ $<
+
+.po.gmo:
+ file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
+ && rm -f $$file && $(GMSGFMT) -o $$file $<
+
+.po.cat:
+ sed -f ../intl/po2msg.sed < $< > $*.msg \
+ && rm -f $@ && $(GENCAT) $@ $*.msg
+
+
+all: all-@USE_NLS@
+
+all-yes: $(CATALOGS) @MAINT@ $(PACKAGE).pot
+all-no:
+
+$(srcdir)/$(PACKAGE).pot: $(POTFILES)
+ $(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(top_srcdir) \
+ --add-comments --keyword=_ --keyword=N_ \
+ --files-from=$(srcdir)/POTFILES.in
+ rm -f $(srcdir)/$(PACKAGE).pot
+ mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot
+
+$(srcdir)/cat-id-tbl.c: stamp-cat-id; @:
+$(srcdir)/stamp-cat-id: $(PACKAGE).pot
+ rm -f cat-id-tbl.tmp
+ sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
+ | sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
+ if cmp -s cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; then \
+ rm cat-id-tbl.tmp; \
+ else \
+ echo cat-id-tbl.c changed; \
+ rm -f $(srcdir)/cat-id-tbl.c; \
+ mv cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; \
+ fi
+ cd $(srcdir) && rm -f stamp-cat-id && echo timestamp > stamp-cat-id
+
+
+install: install-exec install-data
+install-exec:
+install-info:
+install-data: install-data-@USE_NLS@
+install-data-no: all
+install-data-yes: all
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $(datadir); \
+ else \
+ $(top_srcdir)/mkinstalldirs $(datadir); \
+ fi
+ @catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ case "$$cat" in \
+ *.gmo) destdir=$(gnulocaledir);; \
+ *) destdir=$(localedir);; \
+ esac; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ dir=$$destdir/$$lang/LC_MESSAGES; \
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $$dir; \
+ else \
+ $(top_srcdir)/mkinstalldirs $$dir; \
+ fi; \
+ if test -r $$cat; then \
+ $(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
+ echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \
+ else \
+ $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
+ echo "installing $(srcdir)/$$cat as" \
+ "$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
+ fi; \
+ if test -r $$cat.m; then \
+ $(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
+ echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
+ else \
+ if test -r $(srcdir)/$$cat.m ; then \
+ $(INSTALL_DATA) $(srcdir)/$$cat.m \
+ $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
+ echo "installing $(srcdir)/$$cat as" \
+ "$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
+ else \
+ true; \
+ fi; \
+ fi; \
+ done
+ if test "$(PACKAGE)" = "gettext"; then \
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $(gettextsrcdir); \
+ else \
+ $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
+ fi; \
+ $(INSTALL_DATA) $(srcdir)/Makefile.in.in \
+ $(gettextsrcdir)/Makefile.in.in; \
+ else \
+ : ; \
+ fi
+
+# Define this as empty until I found a useful application.
+installcheck:
+
+uninstall:
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
+ rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
+ rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
+ rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
+ done
+ rm -f $(gettextsrcdir)/po-Makefile.in.in
+
+check: all
+
+cat-id-tbl.o: ../intl/libgettext.h
+
+dvi info tags TAGS ID:
+
+mostlyclean:
+ rm -f core core.* *.pox $(PACKAGE).po *.old.po cat-id-tbl.tmp
+ rm -fr *.o
+
+clean: mostlyclean
+
+distclean: clean
+ rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
+
+maintainer-clean: distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+ rm -f $(GMOFILES)
+
+distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
+dist distdir: update-po $(DISTFILES)
+ dists="$(DISTFILES)"; \
+ for file in $$dists; do \
+ ln $(srcdir)/$$file $(distdir) 2> /dev/null \
+ || cp -p $(srcdir)/$$file $(distdir); \
+ done
+
+update-po: Makefile
+ $(MAKE) $(PACKAGE).pot
+ PATH=`pwd`/../src:$$PATH; \
+ cd $(srcdir); \
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ mv $$lang.po $$lang.old.po; \
+ echo "$$lang:"; \
+ if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \
+ rm -f $$lang.old.po; \
+ else \
+ echo "msgmerge for $$cat failed!"; \
+ rm -f $$lang.po; \
+ mv $$lang.old.po $$lang.po; \
+ fi; \
+ done
+
+POTFILES: POTFILES.in
+ ( if test 'x$(srcdir)' != 'x.'; then \
+ posrcprefix='$(top_srcdir)/'; \
+ else \
+ posrcprefix="../"; \
+ fi; \
+ rm -f $@-t $@ \
+ && (sed -e '/^#/d' -e '/^[ ]*$$/d' \
+ -e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
+ | sed -e '$$s/\\$$//') > $@-t \
+ && chmod a-w $@-t \
+ && mv $@-t $@ )
+
+POTFILES.in: @MAINT@ ../Makefile
+ cd .. && $(MAKE) po/POTFILES.in
+
+Makefile: Make-in ../config.status POTFILES
+ cd .. \
+ && CONFIG_FILES=$(subdir)/Makefile.in:$(subdir)/Make-in \
+ CONFIG_HEADERS= $(SHELL) ./config.status
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/bfd/po/POTFILES.in b/bfd/po/POTFILES.in
new file mode 100644
index 00000000000..ae4996698e6
--- /dev/null
+++ b/bfd/po/POTFILES.in
@@ -0,0 +1,264 @@
+archures.c
+bfd-in2.h
+aix386-core.c
+aout-adobe.c
+aout-arm.c
+aout-encap.c
+aout-ns32k.c
+aout-sparcle.c
+aout-target.h
+aout-tic30.c
+aout0.c
+aout32.c
+aout64.c
+aoutf1.h
+aoutx.h
+archive.c
+bfd-in.h
+bfd.c
+binary.c
+bout.c
+cache.c
+cf-i386lynx.c
+cf-m68klynx.c
+cf-sparclynx.c
+cisco-core.c
+coff-a29k.c
+coff-alpha.c
+coff-apollo.c
+coff-arm.c
+coff-aux.c
+coff-go32.c
+coff-h8300.c
+coff-h8500.c
+coff-i386.c
+coff-i860.c
+coff-i960.c
+coff-m68k.c
+coff-m88k.c
+coff-mcore.c
+coff-mips.c
+coff-pmac.c
+coff-ppc.c
+coff-rs6000.c
+coff-sh.c
+coff-sparc.c
+coff-stgo32.c
+coff-svm68k.c
+coff-tic30.c
+coff-tic80.c
+coff-u68k.c
+coff-w65.c
+coff-we32k.c
+coff-z8k.c
+coffcode.h
+coffgen.c
+cofflink.c
+coffswap.h
+cpu-m10300.c
+cpu-m32r.c
+cpu-mips.c
+corefile.c
+cpu-a29k.c
+cpu-alpha.c
+cpu-arc.c
+cpu-arm.c
+cpu-d10v.c
+cpu-d30v.c
+cpu-fr30.c
+cpu-h8300.c
+cpu-h8500.c
+cpu-hppa.c
+cpu-i386.c
+cpu-i860.c
+cpu-i960.c
+cpu-m10200.c
+cpu-sh.c
+elf-m10300.c
+cpu-m68k.c
+cpu-m88k.c
+cpu-mcore.c
+elf32-m32r.c
+cpu-ns32k.c
+cpu-powerpc.c
+cpu-rs6000.c
+libbfd.h
+cpu-sparc.c
+cpu-tic30.c
+cpu-tic80.c
+cpu-v850.c
+cpu-vax.c
+elf32-mips.c
+cpu-w65.c
+cpu-we32k.c
+cpu-z8k.c
+demo64.c
+dwarf1.c
+dwarf2.c
+ecoff.c
+ecofflink.c
+ecoffswap.h
+elf-bfd.h
+elf-m10200.c
+libhppa.h
+elf.c
+elf32-arc.c
+elf32-arm.h
+elf32-d10v.c
+elf32-d30v.c
+elf32-fr30.c
+elf32-gen.c
+elf32-hppa.c
+elf32-hppa.h
+elf32-i386.c
+elf32-i860.c
+reloc.c
+elf32-m68k.c
+elf32-m88k.c
+elf32-mcore.c
+targets.c
+elf32-ppc.c
+elf32-sh.c
+elf32-sparc.c
+elf32-v850.c
+elf32.c
+elf64-alpha.c
+elf64-gen.c
+elf64-mips.c
+elf64-sparc.c
+elf64.c
+elfarm-nabi.c
+elfarm-oabi.c
+elfcode.h
+elfcore.h
+elflink.c
+elflink.h
+elfxx-target.h
+epoc-pe-arm.c
+epoc-pei-arm.c
+format.c
+freebsd.h
+gen-aout.c
+genlink.h
+go32stub.h
+hash.c
+host-aout.c
+hp300bsd.c
+hp300hpux.c
+hppa_stubs.h
+hppabsd-core.c
+hpux-core.c
+i386aout.c
+i386bsd.c
+i386dynix.c
+i386freebsd.c
+i386linux.c
+i386lynx.c
+i386mach3.c
+i386msdos.c
+i386netbsd.c
+i386os9k.c
+ieee.c
+ihex.c
+init.c
+irix-core.c
+libaout.h
+libbfd-in.h
+libbfd.c
+libcoff-in.h
+libcoff.h
+libecoff.h
+libieee.h
+libnlm.h
+liboasys.h
+linker.c
+lynx-core.c
+m68k4knetbsd.c
+m68klinux.c
+m68klynx.c
+m68knetbsd.c
+doc/chew.c
+m88kmach3.c
+mipsbsd.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
+opncls.c
+osf-core.c
+pc532-mach.c
+pe-arm.c
+pe-i386.c
+pe-mcore.c
+pe-ppc.c
+pei-arm.c
+pei-i386.c
+pei-mcore.c
+pei-ppc.c
+peicode.h
+ppcboot.c
+ptrace-core.c
+reloc16.c
+riscix.c
+rs6000-core.c
+sco5-core.c
+section.c
+som.c
+som.h
+sparclinux.c
+sparclynx.c
+sparcnetbsd.c
+srec.c
+stab-syms.c
+stabs.c
+sunos.c
+syms.c
+sysdep.h
+tekhex.c
+trad-core.c
+vaxnetbsd.c
+versados.c
+vms-gsd.c
+vms-hdr.c
+vms-misc.c
+vms-tir.c
+vms.c
+vms.h
+xcofflink.c
+hosts/alphalinux.h
+hosts/alphavms.h
+hosts/decstation.h
+hosts/delta68.h
+hosts/dpx2.h
+hosts/hp300bsd.h
+hosts/i386bsd.h
+hosts/i386linux.h
+hosts/i386mach3.h
+hosts/i386sco.h
+hosts/i860mach3.h
+hosts/m68kaux.h
+hosts/m68klinux.h
+hosts/m88kmach3.h
+hosts/mipsbsd.h
+hosts/mipsmach3.h
+hosts/news-mips.h
+hosts/news.h
+hosts/pc532mach.h
+hosts/riscos.h
+hosts/symmetry.h
+hosts/tahoe.h
+hosts/vaxbsd.h
+hosts/vaxult.h
+hosts/vaxult2.h
diff --git a/bfd/po/bfd.pot b/bfd/po/bfd.pot
new file mode 100644
index 00000000000..f7ffbb47b01
--- /dev/null
+++ b/bfd/po/bfd.pot
@@ -0,0 +1,632 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 1999-04-18 18:26-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: ENCODING\n"
+
+#: aout-adobe.c:182
+#, c-format
+msgid "%s: Unknown section type in a.out.adobe file: %x\n"
+msgstr ""
+
+#: aoutx.h:1237 aoutx.h:1651
+#, c-format
+msgid "%s: can not represent section `%s' in a.out object file format"
+msgstr ""
+
+#: aoutx.h:1621
+#, c-format
+msgid ""
+"%s: can not represent section for symbol `%s' in a.out object file format"
+msgstr ""
+
+#: aoutx.h:1623
+msgid "*unknown*"
+msgstr ""
+
+#: aoutx.h:3667
+#, c-format
+msgid "%s: relocateable link from %s to %s not supported"
+msgstr ""
+
+#: archive.c:1716
+msgid "Warning: writing archive was slow: rewriting timestamp\n"
+msgstr ""
+
+#: archive.c:1987
+msgid "Reading archive file mod timestamp"
+msgstr ""
+
+#. FIXME: bfd can't call perror.
+#: archive.c:2011
+msgid "Writing updated armap timestamp"
+msgstr ""
+
+#: bfd.c:274
+msgid "No error"
+msgstr ""
+
+#: bfd.c:275
+msgid "System call error"
+msgstr ""
+
+#: bfd.c:276
+msgid "Invalid bfd target"
+msgstr ""
+
+#: bfd.c:277
+msgid "File in wrong format"
+msgstr ""
+
+#: bfd.c:278
+msgid "Invalid operation"
+msgstr ""
+
+#: bfd.c:279
+msgid "Memory exhausted"
+msgstr ""
+
+#: bfd.c:280
+msgid "No symbols"
+msgstr ""
+
+#: bfd.c:281
+msgid "Archive has no index; run ranlib to add one"
+msgstr ""
+
+#: bfd.c:282
+msgid "No more archived files"
+msgstr ""
+
+#: bfd.c:283
+msgid "Malformed archive"
+msgstr ""
+
+#: bfd.c:284
+msgid "File format not recognized"
+msgstr ""
+
+#: bfd.c:285
+msgid "File format is ambiguous"
+msgstr ""
+
+#: bfd.c:286
+msgid "Section has no contents"
+msgstr ""
+
+#: bfd.c:287
+msgid "Nonrepresentable section on output"
+msgstr ""
+
+#: bfd.c:288
+msgid "Symbol needs debug section which does not exist"
+msgstr ""
+
+#: bfd.c:289
+msgid "Bad value"
+msgstr ""
+
+#: bfd.c:290
+msgid "File truncated"
+msgstr ""
+
+#: bfd.c:291
+msgid "File too big"
+msgstr ""
+
+#: bfd.c:292
+msgid "#<Invalid error code>"
+msgstr ""
+
+#: bfd.c:679
+#, c-format
+msgid "bfd assertion fail %s:%d"
+msgstr ""
+
+#: binary.c:298
+#, c-format
+msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."
+msgstr ""
+
+#: coff-a29k.c:121
+msgid "Missing IHCONST"
+msgstr ""
+
+#: coff-a29k.c:181
+msgid "Missing IHIHALF"
+msgstr ""
+
+#: coff-a29k.c:213
+msgid "Unrecognized reloc"
+msgstr ""
+
+#: coff-a29k.c:406
+msgid "missing IHCONST reloc"
+msgstr ""
+
+#: coff-a29k.c:497
+msgid "missing IHIHALF reloc"
+msgstr ""
+
+#: coff-alpha.c:880 coff-alpha.c:917
+msgid "GP relative relocation used when GP not defined"
+msgstr ""
+
+#: coff-alpha.c:1486 elf64-alpha.c:4051
+msgid "using multiple gp values"
+msgstr ""
+
+#: coff-alpha.c:1992 coff-mips.c:1435 elf32-mips.c:5175
+msgid "GP relative relocation when GP not defined"
+msgstr ""
+
+#: coff-arm.c:884
+#, c-format
+msgid "%s: unable to find THUMB glue '%s' for `%s'"
+msgstr ""
+
+#: coff-arm.c:913
+#, c-format
+msgid "%s: unable to find ARM glue '%s' for `%s'"
+msgstr ""
+
+#: coff-arm.c:1192 coff-arm.c:1286
+#, c-format
+msgid "%s(%s): warning: interworking not enabled."
+msgstr ""
+
+#: coff-arm.c:1196
+#, c-format
+msgid " first occurrence: %s: arm call to thumb"
+msgstr ""
+
+#: coff-arm.c:1290
+#, c-format
+msgid " first occurrence: %s: thumb call to arm"
+msgstr ""
+
+#: coff-arm.c:1293
+msgid " consider relinking with --support-old-code enabled"
+msgstr ""
+
+#: coff-arm.c:1581 coff-tic80.c:682 cofflink.c:2722
+#, c-format
+msgid "%s: bad reloc address 0x%lx in section `%s'"
+msgstr ""
+
+#: coff-arm.c:2036
+#, c-format
+msgid "%s: ERROR: compiled for APCS-%d whereas target %s uses APCS-%d"
+msgstr ""
+
+#: coff-arm.c:2051
+#, c-format
+msgid ""
+"%s: ERROR: passes floats in float registers whereas target %s uses integer "
+"registers"
+msgstr ""
+
+#: coff-arm.c:2054
+#, c-format
+msgid ""
+"%s: ERROR: passes floats in integer registers whereas target %s uses float "
+"registers"
+msgstr ""
+
+#: coff-arm.c:2069
+#, c-format
+msgid ""
+"%s: ERROR: compiled as position independent code, whereas target %s is "
+"absolute position"
+msgstr ""
+
+#: coff-arm.c:2072
+#, c-format
+msgid ""
+"%s: ERROR: compiled as absolute position code, whereas target %s is position "
+"independent"
+msgstr ""
+
+#: coff-arm.c:2101
+#, c-format
+msgid "Warning: input file %s supports interworking, whereas %s does not."
+msgstr ""
+
+#: coff-arm.c:2104
+#, c-format
+msgid "Warning: input file %s does not support interworking, whereas %s does."
+msgstr ""
+
+#: coff-arm.c:2132
+#, c-format
+msgid "private flags = %x:"
+msgstr ""
+
+#: coff-arm.c:2140
+msgid " [floats passed in float registers]"
+msgstr ""
+
+#: coff-arm.c:2142
+msgid " [floats passed in integer registers]"
+msgstr ""
+
+#: coff-arm.c:2145
+msgid " [position independent]"
+msgstr ""
+
+#: coff-arm.c:2147
+msgid " [absolute position]"
+msgstr ""
+
+#: coff-arm.c:2151
+msgid " [interworking flag not initialised]"
+msgstr ""
+
+#: coff-arm.c:2153
+msgid " [interworking supported]"
+msgstr ""
+
+#: coff-arm.c:2155
+msgid " [interworking not supported]"
+msgstr ""
+
+#: coff-arm.c:2204
+#, c-format
+msgid ""
+"Warning: Not setting interworking flag of %s, since it has already been "
+"specified as non-interworking"
+msgstr ""
+
+#: coff-arm.c:2208
+#, c-format
+msgid "Warning: Clearing the interworking flag of %s due to outside request"
+msgstr ""
+
+#: coff-i960.c:135 coff-i960.c:484
+msgid "uncertain calling convention for non-COFF symbol"
+msgstr ""
+
+#: coff-mips.c:875 elf32-mips.c:1183
+msgid "GP relative relocation when _gp not defined"
+msgstr ""
+
+#: coff-mips.c:2433
+msgid "unsupported reloc type"
+msgstr ""
+
+#. No other sections should appear in -membedded-pic
+#. code.
+#: coff-mips.c:2470
+msgid "reloc against unsupported section"
+msgstr ""
+
+#: coff-mips.c:2478
+msgid "reloc not properly aligned"
+msgstr ""
+
+#: coff-tic80.c:445
+#, c-format
+msgid "Unrecognized reloc type 0x%x"
+msgstr ""
+
+#: coff-w65.c:383
+#, c-format
+msgid "ignoring reloc %s\n"
+msgstr ""
+
+#: coffcode.h:3413
+#, c-format
+msgid "%s: warning: illegal symbol index %ld in line numbers"
+msgstr ""
+
+#: coffcode.h:3427
+#, c-format
+msgid "%s: warning: duplicate line number information for `%s'"
+msgstr ""
+
+#: coffcode.h:3748
+#, c-format
+msgid "%s: Unrecognized storage class %d for %s symbol `%s'"
+msgstr ""
+
+#: coffcode.h:3932
+#, c-format
+msgid "%s: warning: illegal symbol index %ld in relocs"
+msgstr ""
+
+#: coffcode.h:3970
+#, c-format
+msgid "%s: illegal relocation type %d at address 0x%lx"
+msgstr ""
+
+#: coffgen.c:1607
+#, c-format
+msgid "%s: bad string table size %lu"
+msgstr ""
+
+#: cofflink.c:423
+#, c-format
+msgid "Warning: type of symbol `%s' changed from %d to %d in %s"
+msgstr ""
+
+#: cofflink.c:2093
+#, c-format
+msgid "%s: relocs in section `%s', but it has no contents"
+msgstr ""
+
+#: coffswap.h:879
+#, c-format
+msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff"
+msgstr ""
+
+#: coffswap.h:892
+#, c-format
+msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
+msgstr ""
+
+#: dwarf2.c:420
+msgid "Dwarf Error: Can't find .debug_abbrev section."
+msgstr ""
+
+#: dwarf2.c:438
+#, c-format
+msgid "Dwarf Error: Abbrev offset (%u) bigger than abbrev size (%u)."
+msgstr ""
+
+#: dwarf2.c:614
+#, c-format
+msgid "Dwarf Error: Invalid or unhandled FORM value: %d."
+msgstr ""
+
+#: dwarf2.c:720
+msgid "Dwarf Error: Can't find .debug_line section."
+msgstr ""
+
+#: dwarf2.c:881
+msgid "Dwarf Error: mangled line number section."
+msgstr ""
+
+#: dwarf2.c:1054 dwarf2.c:1201
+#, c-format
+msgid "Dwarf Error: Could not find abbrev number %d."
+msgstr ""
+
+#: dwarf2.c:1162
+#, c-format
+msgid ""
+"Dwarf Error: found dwarf version '%hu', this reader only handles version 2 "
+"information."
+msgstr ""
+
+#: dwarf2.c:1169
+#, c-format
+msgid ""
+"Dwarf Error: found address size '%u', this reader can not handle sizes "
+"greater than '%u'."
+msgstr ""
+
+#: dwarf2.c:1192
+#, c-format
+msgid "Dwarf Error: Bad abbrev number: %d."
+msgstr ""
+
+#: ecoff.c:1308
+#, c-format
+msgid "Unknown basic type %d"
+msgstr ""
+
+#: ecoff.c:1580
+#, c-format
+msgid ""
+"\n"
+" End+1 symbol: %ld"
+msgstr ""
+
+#: ecoff.c:1587 ecoff.c:1590
+#, c-format
+msgid ""
+"\n"
+" First symbol: %ld"
+msgstr ""
+
+#: ecoff.c:1602
+#, c-format
+msgid ""
+"\n"
+" End+1 symbol: %-7ld Type: %s"
+msgstr ""
+
+#: ecoff.c:1609
+#, c-format
+msgid ""
+"\n"
+" Local symbol: %ld"
+msgstr ""
+
+#: ecoff.c:1617
+#, c-format
+msgid ""
+"\n"
+" struct; End+1 symbol: %ld"
+msgstr ""
+
+#: ecoff.c:1622
+#, c-format
+msgid ""
+"\n"
+" union; End+1 symbol: %ld"
+msgstr ""
+
+#: ecoff.c:1627
+#, c-format
+msgid ""
+"\n"
+" enum; End+1 symbol: %ld"
+msgstr ""
+
+#: ecoff.c:1633
+#, c-format
+msgid ""
+"\n"
+" Type: %s"
+msgstr ""
+
+#: elf-m10200.c:455 elf-m10300.c:667 elf32-d10v.c:490 elf32-fr30.c:650
+#: elf32-m32r.c:1157 elf32-v850.c:1674
+msgid "internal error: out of range error"
+msgstr ""
+
+#: elf-m10200.c:459 elf-m10300.c:671 elf32-d10v.c:494 elf32-fr30.c:654
+#: elf32-m32r.c:1161 elf32-v850.c:1678
+msgid "internal error: unsupported relocation error"
+msgstr ""
+
+#: elf-m10200.c:463 elf-m10300.c:675 elf32-d10v.c:498 elf32-m32r.c:1165
+msgid "internal error: dangerous error"
+msgstr ""
+
+#: elf-m10200.c:467 elf-m10300.c:679 elf32-d10v.c:502 elf32-fr30.c:662
+#: elf32-m32r.c:1169 elf32-v850.c:1698
+msgid "internal error: unknown error"
+msgstr ""
+
+#: elf.c:320
+#, c-format
+msgid "%s: invalid string offset %u >= %lu for section `%s'"
+msgstr ""
+
+#: elf.c:543
+msgid ""
+"\n"
+"Program Header:\n"
+msgstr ""
+
+#: elf.c:591
+msgid ""
+"\n"
+"Dynamic Section:\n"
+msgstr ""
+
+#: elf.c:693
+msgid ""
+"\n"
+"Version definitions:\n"
+msgstr ""
+
+#: elf.c:716
+msgid ""
+"\n"
+"Version References:\n"
+msgstr ""
+
+#: elf.c:721
+#, c-format
+msgid " required from %s:\n"
+msgstr ""
+
+#: elf.c:1882
+#, c-format
+msgid ""
+"creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = "
+"0x%.8lx\n"
+msgstr ""
+
+#: elf.c:2481
+#, c-format
+msgid "%s: Not enough room for program headers (allocated %u, need %u)"
+msgstr ""
+
+#: elf.c:2584
+#, c-format
+msgid "%s: Not enough room for program headers, try linking with -N"
+msgstr ""
+
+#: elf.c:2710
+#, c-format
+msgid "Error: First section in segment (%s) starts at 0x%x"
+msgstr ""
+
+#: elf.c:2713
+#, c-format
+msgid " whereas segment starts at 0x%x"
+msgstr ""
+
+#: elf.c:2983
+#, c-format
+msgid "%s: warning: allocated section `%s' not in segment"
+msgstr ""
+
+#: elf.c:3350
+#, c-format
+msgid "%s: symbol `%s' required but not present"
+msgstr ""
+
+#: elf.c:3359
+#, c-format
+msgid ""
+"elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = "
+"0x%.8lx%s\n"
+msgstr ""
+
+#: elf.c:3501
+#, c-format
+msgid "%s: warning: Empty loadable segment detected\n"
+msgstr ""
+
+#: elf.c:4774
+#, c-format
+msgid "%s: unsupported relocation type %s"
+msgstr ""
+
+#: elf32-fr30.c:658 elf32-v850.c:1682
+msgid "internal error: dangerous relocation"
+msgstr ""
+
+#: elf32-hppa.c:1215
+msgid "Unsupported call to hppa_elf_reloc"
+msgstr ""
+
+#: elf32-i386.c:1293
+#, c-format
+msgid ""
+"%s: warning: unresolvable relocation against symbol `%s' from %s section"
+msgstr ""
+
+#: elf32-m32r.c:808
+msgid "SDA relocation when _SDA_BASE_ not defined"
+msgstr ""
+
+#: elf32-m32r.c:892 elf32-ppc.c:3071
+#, c-format
+msgid "%s: unknown relocation type %d"
+msgstr ""
+
+#: elf32-m32r.c:1100
+#, c-format
+msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)"
+msgstr ""
+
+#: elf32-m32r.c:1906
+#, c-format
+msgid "%s: Instruction set mismatch with previous modules"
+msgstr ""
+
+#: elf32-m32r.c:1929
+#, c-format
+msgid "private flags = %lx"
+msgstr ""
+
+#: elf32-m32r.c:1934
+msgid ": m32r instructions"
+msgstr ""
+
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
new file mode 100644
index 00000000000..cbda407ea33
--- /dev/null
+++ b/bfd/ppcboot.c
@@ -0,0 +1,535 @@
+/* BFD back-end for PPCbug boot records.
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+ Written by Michael Meissner, Cygnus Support, <meissner@cygnus.com>
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This is a BFD backend which may be used to write PowerPCBug boot objects.
+ It may only be used for output, not input. The intention is that this may
+ be used as an output format for objcopy in order to generate raw binary
+ data.
+
+ This is very simple. The only complication is that the real data
+ will start at some address X, and in some cases we will not want to
+ include X zeroes just to get to that point. Since the start
+ address is not meaningful for this object file format, we use it
+ instead to indicate the number of zeroes to skip at the start of
+ the file. objcopy cooperates by specially setting the start
+ address to zero by default. */
+
+#include <ctype.h>
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+/* PPCbug location structure */
+typedef struct ppcboot_location {
+ bfd_byte ind;
+ bfd_byte head;
+ bfd_byte sector;
+ bfd_byte cylinder;
+} ppcboot_location_t;
+
+/* PPCbug partition table layout */
+typedef struct ppcboot_partition {
+ ppcboot_location_t partition_begin; /* partition begin */
+ ppcboot_location_t partition_end; /* partition end */
+ bfd_byte sector_begin[4]; /* 32-bit start RBA (zero-based), little endian */
+ bfd_byte sector_length[4]; /* 32-bit RBA count (one-based), little endian */
+} ppcboot_partition_t;
+
+/* PPCbug boot layout. */
+typedef struct ppcboot_hdr {
+ bfd_byte pc_compatibility[446]; /* x86 instruction field */
+ ppcboot_partition_t partition[4]; /* partition information */
+ bfd_byte signature[2]; /* 0x55 and 0xaa */
+ bfd_byte entry_offset[4]; /* entry point offset, little endian */
+ bfd_byte length[4]; /* load image length, little endian */
+ bfd_byte flags; /* flag field */
+ bfd_byte os_id; /* OS_ID */
+ char partition_name[32]; /* partition name */
+ bfd_byte reserved1[470]; /* reserved */
+} ppcboot_hdr_t;
+
+/* Signature bytes for last 2 bytes of the 512 byte record */
+#define SIGNATURE0 0x55
+#define SIGNATURE1 0xaa
+
+/* PowerPC boot type */
+#define PPC_IND 0x41
+
+/* Information needed for ppcboot header */
+typedef struct ppcboot_data {
+ ppcboot_hdr_t header; /* raw header */
+ asection *sec; /* single section */
+} ppcboot_data_t;
+
+/* Any bfd we create by reading a ppcboot file has three symbols:
+ a start symbol, an end symbol, and an absolute length symbol. */
+#define PPCBOOT_SYMS 3
+
+static boolean ppcboot_mkobject PARAMS ((bfd *));
+static const bfd_target *ppcboot_object_p PARAMS ((bfd *));
+static boolean ppcboot_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+static boolean ppcboot_get_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static long ppcboot_get_symtab_upper_bound PARAMS ((bfd *));
+static char *mangle_name PARAMS ((bfd *, char *));
+static long ppcboot_get_symtab PARAMS ((bfd *, asymbol **));
+static asymbol *ppcboot_make_empty_symbol PARAMS ((bfd *));
+static void ppcboot_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static boolean ppcboot_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static int ppcboot_sizeof_headers PARAMS ((bfd *, boolean));
+static boolean ppcboot_bfd_print_private_bfd_data PARAMS ((bfd *, PTR));
+
+#define ppcboot_set_tdata(abfd, ptr) ((abfd)->tdata.any = (PTR) (ptr))
+#define ppcboot_get_tdata(abfd) ((ppcboot_data_t *) ((abfd)->tdata.any))
+
+/* Create a ppcboot object. Invoked via bfd_set_format. */
+
+static boolean
+ppcboot_mkobject (abfd)
+ bfd *abfd;
+{
+ if (!ppcboot_get_tdata (abfd))
+ ppcboot_set_tdata (abfd, bfd_zalloc (abfd, sizeof (ppcboot_data_t)));
+
+ return true;
+}
+
+
+/* Set the architecture to PowerPC */
+static boolean
+ppcboot_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ if (arch == bfd_arch_unknown)
+ arch = bfd_arch_powerpc;
+
+ else if (arch != bfd_arch_powerpc)
+ return false;
+
+ return bfd_default_set_arch_mach (abfd, arch, machine);
+}
+
+
+/* Any file may be considered to be a ppcboot file, provided the target
+ was not defaulted. That is, it must be explicitly specified as
+ being ppcboot. */
+
+static const bfd_target *
+ppcboot_object_p (abfd)
+ bfd *abfd;
+{
+ struct stat statbuf;
+ asection *sec;
+ ppcboot_hdr_t hdr;
+ size_t i;
+ ppcboot_data_t *tdata;
+
+ BFD_ASSERT (sizeof (ppcboot_hdr_t) == 1024);
+
+ if (abfd->target_defaulted)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Find the file size. */
+ if (bfd_stat (abfd, &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+
+ if ((size_t) statbuf.st_size < sizeof (ppcboot_hdr_t))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (bfd_read ((PTR) &hdr, sizeof (hdr), 1, abfd) != sizeof (hdr))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+
+ return NULL;
+ }
+
+ /* Now do some basic checks. */
+ for (i = 0; i < sizeof (hdr.pc_compatibility); i++)
+ if (hdr.pc_compatibility[i])
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (hdr.signature[0] != SIGNATURE0 || hdr.signature[1] != SIGNATURE1)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (hdr.partition[0].partition_end.ind != PPC_IND)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ abfd->symcount = PPCBOOT_SYMS;
+
+ /* One data section. */
+ sec = bfd_make_section (abfd, ".data");
+ if (sec == NULL)
+ return NULL;
+ sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_CODE | SEC_HAS_CONTENTS;
+ sec->vma = 0;
+ sec->_raw_size = statbuf.st_size - sizeof (ppcboot_hdr_t);
+ sec->filepos = sizeof (ppcboot_hdr_t);
+
+ ppcboot_mkobject (abfd);
+ tdata = ppcboot_get_tdata (abfd);
+ tdata->sec = sec;
+ memcpy ((PTR) &tdata->header, (PTR) &hdr, sizeof (ppcboot_hdr_t));
+
+ ppcboot_set_arch_mach (abfd, bfd_arch_powerpc, 0);
+ return abfd->xvec;
+}
+
+#define ppcboot_close_and_cleanup _bfd_generic_close_and_cleanup
+#define ppcboot_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define ppcboot_new_section_hook _bfd_generic_new_section_hook
+
+
+/* Get contents of the only section. */
+
+static boolean
+ppcboot_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (bfd_seek (abfd, offset + sizeof(ppcboot_hdr_t), SEEK_SET) != 0
+ || bfd_read (location, 1, count, abfd) != count)
+ return false;
+ return true;
+}
+
+
+/* Return the amount of memory needed to read the symbol table. */
+
+static long
+ppcboot_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ return (PPCBOOT_SYMS + 1) * sizeof (asymbol *);
+}
+
+
+/* Create a symbol name based on the bfd's filename. */
+
+static char *
+mangle_name (abfd, suffix)
+ bfd *abfd;
+ char *suffix;
+{
+ int size;
+ char *buf;
+ char *p;
+
+ size = (strlen (bfd_get_filename (abfd))
+ + strlen (suffix)
+ + sizeof "_ppcboot__");
+
+ buf = (char *) bfd_alloc (abfd, size);
+ if (buf == NULL)
+ return "";
+
+ sprintf (buf, "_ppcboot_%s_%s", bfd_get_filename (abfd), suffix);
+
+ /* Change any non-alphanumeric characters to underscores. */
+ for (p = buf; *p; p++)
+ if (! isalnum ((unsigned char) *p))
+ *p = '_';
+
+ return buf;
+}
+
+
+/* Return the symbol table. */
+
+static long
+ppcboot_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ asection *sec = ppcboot_get_tdata (abfd)->sec;
+ asymbol *syms;
+ unsigned int i;
+
+ syms = (asymbol *) bfd_alloc (abfd, PPCBOOT_SYMS * sizeof (asymbol));
+ if (syms == NULL)
+ return false;
+
+ /* Start symbol. */
+ syms[0].the_bfd = abfd;
+ syms[0].name = mangle_name (abfd, "start");
+ syms[0].value = 0;
+ syms[0].flags = BSF_GLOBAL;
+ syms[0].section = sec;
+ syms[0].udata.p = NULL;
+
+ /* End symbol. */
+ syms[1].the_bfd = abfd;
+ syms[1].name = mangle_name (abfd, "end");
+ syms[1].value = sec->_raw_size;
+ syms[1].flags = BSF_GLOBAL;
+ syms[1].section = sec;
+ syms[1].udata.p = NULL;
+
+ /* Size symbol. */
+ syms[2].the_bfd = abfd;
+ syms[2].name = mangle_name (abfd, "size");
+ syms[2].value = sec->_raw_size;
+ syms[2].flags = BSF_GLOBAL;
+ syms[2].section = bfd_abs_section_ptr;
+ syms[2].udata.p = NULL;
+
+ for (i = 0; i < PPCBOOT_SYMS; i++)
+ *alocation++ = syms++;
+ *alocation = NULL;
+
+ return PPCBOOT_SYMS;
+}
+
+
+/* Make an empty symbol. */
+
+static asymbol *
+ppcboot_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+}
+
+
+#define ppcboot_print_symbol _bfd_nosymbols_print_symbol
+
+/* Get information about a symbol. */
+
+static void
+ppcboot_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+#define ppcboot_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define ppcboot_get_lineno _bfd_nosymbols_get_lineno
+#define ppcboot_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define ppcboot_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define ppcboot_read_minisymbols _bfd_generic_read_minisymbols
+#define ppcboot_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define ppcboot_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
+#define ppcboot_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
+#define ppcboot_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+/* Write section contents of a ppcboot file. */
+
+static boolean
+ppcboot_set_section_contents (abfd, sec, data, offset, size)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+ file_ptr offset;
+ bfd_size_type size;
+{
+ if (! abfd->output_has_begun)
+ {
+ bfd_vma low;
+ asection *s;
+
+ /* The lowest section VMA sets the virtual address of the start
+ of the file. We use the set the file position of all the
+ sections. */
+ low = abfd->sections->vma;
+ for (s = abfd->sections->next; s != NULL; s = s->next)
+ if (s->vma < low)
+ low = s->vma;
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ s->filepos = s->vma - low;
+
+ abfd->output_has_begun = true;
+ }
+
+ return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
+}
+
+
+static int
+ppcboot_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return sizeof (ppcboot_hdr_t);
+}
+
+
+/* Print out the program headers. */
+
+static boolean
+ppcboot_bfd_print_private_bfd_data (abfd, farg)
+ bfd *abfd;
+ PTR farg;
+{
+ FILE *f = (FILE *)farg;
+ ppcboot_data_t *tdata = ppcboot_get_tdata (abfd);
+ long entry_offset = bfd_getl_signed_32 ((PTR) tdata->header.entry_offset);
+ long length = bfd_getl_signed_32 ((PTR) tdata->header.length);
+ int i;
+
+ fprintf (f, _("\nppcboot header:\n"));
+ fprintf (f, _("Entry offset = 0x%.8lx (%ld)\n"), entry_offset, entry_offset);
+ fprintf (f, _("Length = 0x%.8lx (%ld)\n"), length, length);
+
+ if (tdata->header.flags)
+ fprintf (f, _("Flag field = 0x%.2x\n"), tdata->header.flags);
+
+ if (tdata->header.os_id)
+ fprintf (f, "OS_ID = 0x%.2x\n", tdata->header.os_id);
+
+ if (tdata->header.partition_name)
+ fprintf (f, _("Partition name = \"%s\"\n"), tdata->header.partition_name);
+
+ for (i = 0; i < 4; i++)
+ {
+ long sector_begin = bfd_getl_signed_32 ((PTR) tdata->header.partition[i].sector_begin);
+ long sector_length = bfd_getl_signed_32 ((PTR) tdata->header.partition[i].sector_length);
+
+ /* Skip all 0 entries */
+ if (!tdata->header.partition[i].partition_begin.ind
+ && !tdata->header.partition[i].partition_begin.head
+ && !tdata->header.partition[i].partition_begin.sector
+ && !tdata->header.partition[i].partition_begin.cylinder
+ && !tdata->header.partition[i].partition_end.ind
+ && !tdata->header.partition[i].partition_end.head
+ && !tdata->header.partition[i].partition_end.sector
+ && !tdata->header.partition[i].partition_end.cylinder
+ && !sector_begin && !sector_length)
+ continue;
+
+ fprintf (f, _("\nPartition[%d] start = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"), i,
+ tdata->header.partition[i].partition_begin.ind,
+ tdata->header.partition[i].partition_begin.head,
+ tdata->header.partition[i].partition_begin.sector,
+ tdata->header.partition[i].partition_begin.cylinder);
+
+ fprintf (f, _("Partition[%d] end = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"), i,
+ tdata->header.partition[i].partition_end.ind,
+ tdata->header.partition[i].partition_end.head,
+ tdata->header.partition[i].partition_end.sector,
+ tdata->header.partition[i].partition_end.cylinder);
+
+ fprintf (f, _("Partition[%d] sector = 0x%.8lx (%ld)\n"), i, sector_begin, sector_begin);
+ fprintf (f, _("Partition[%d] length = 0x%.8lx (%ld)\n"), i, sector_length, sector_length);
+ }
+
+ fprintf (f, "\n");
+ return true;
+}
+
+
+#define ppcboot_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define ppcboot_bfd_relax_section bfd_generic_relax_section
+#define ppcboot_bfd_gc_sections bfd_generic_gc_sections
+#define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define ppcboot_bfd_final_link _bfd_generic_final_link
+#define ppcboot_bfd_link_split_section _bfd_generic_link_split_section
+#define ppcboot_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#define ppcboot_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
+#define ppcboot_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#define ppcboot_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
+#define ppcboot_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#define ppcboot_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+#define ppcboot_bfd_print_private_bfd_dat ppcboot_bfd_print_private_bfd_data
+
+const bfd_target ppcboot_vec =
+{
+ "ppcboot", /* name */
+ bfd_target_unknown_flavour, /* flavour */
+ BFD_ENDIAN_BIG, /* byteorder is big endian for code */
+ BFD_ENDIAN_LITTLE, /* header_byteorder */
+ EXEC_P, /* object_flags */
+ (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+ { /* bfd_check_format */
+ _bfd_dummy_target,
+ ppcboot_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ ppcboot_mkobject,
+ bfd_false,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_true,
+ bfd_false,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (ppcboot),
+ BFD_JUMP_TABLE_COPY (ppcboot),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (ppcboot),
+ BFD_JUMP_TABLE_RELOCS (ppcboot),
+ BFD_JUMP_TABLE_WRITE (ppcboot),
+ BFD_JUMP_TABLE_LINK (ppcboot),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL
+};
diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c
new file mode 100644
index 00000000000..2b4fdbbd01f
--- /dev/null
+++ b/bfd/ptrace-core.c
@@ -0,0 +1,230 @@
+/* BFD backend for core files which use the ptrace_user structure
+ Copyright 1993, 94, 95, 96, 1998 Free Software Foundation, Inc.
+ The structure of this file is based on trad-core.c written by John Gilmore
+ of Cygnus Support.
+ Modified to work with the ptrace_user structure by Kevin A. Buettner.
+ (Longterm it may be better to merge this file with trad-core.c)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef PTRACE_CORE
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <signal.h>
+#include <sys/ptrace.h>
+
+
+struct trad_core_struct
+ {
+ asection *data_section;
+ asection *stack_section;
+ asection *reg_section;
+ struct ptrace_user u;
+ };
+
+#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
+#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
+#define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
+#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
+
+/* forward declarations */
+
+const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd));
+char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
+int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
+boolean ptrace_unix_core_file_matches_executable_p
+ PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+static void swap_abort PARAMS ((void));
+
+/* ARGSUSED */
+const bfd_target *
+ptrace_unix_core_file_p (abfd)
+ bfd *abfd;
+
+{
+ int val;
+ struct ptrace_user u;
+ struct trad_core_struct *rawptr;
+
+ val = bfd_read ((void *)&u, 1, sizeof u, abfd);
+ if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC
+ || u.pt_rev != _BCS_PTRACE_REV)
+ {
+ /* Too small to be a core file */
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ /* Allocate both the upage and the struct core_data at once, so
+ a single free() will free them both. */
+ rawptr = (struct trad_core_struct *)
+ bfd_zalloc (abfd, sizeof (struct trad_core_struct));
+
+ if (rawptr == NULL)
+ return 0;
+
+ abfd->tdata.trad_core_data = rawptr;
+
+ rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */
+
+ /* Create the sections. This is raunchy, but bfd_close wants to free
+ them separately. */
+
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_stacksec (abfd) == NULL)
+ return NULL;
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_datasec (abfd) == NULL)
+ return NULL;
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_regsec (abfd) == NULL)
+ return NULL;
+
+ core_stacksec (abfd)->name = ".stack";
+ core_datasec (abfd)->name = ".data";
+ core_regsec (abfd)->name = ".reg";
+
+ /* FIXME: Need to worry about shared memory, library data, and library
+ text. I don't think that any of these things are supported on the
+ system on which I am developing this for though. */
+
+
+ core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
+
+ core_datasec (abfd)->_raw_size = u.pt_dsize;
+ core_stacksec (abfd)->_raw_size = u.pt_ssize;
+ core_regsec (abfd)->_raw_size = sizeof(u);
+
+ core_datasec (abfd)->vma = u.pt_o_data_start;
+ core_stacksec (abfd)->vma = USRSTACK - u.pt_ssize;
+ core_regsec (abfd)->vma = 0 - sizeof(u); /* see trad-core.c */
+
+ core_datasec (abfd)->filepos = (int) u.pt_dataptr;
+ core_stacksec (abfd)->filepos = (int) (u.pt_dataptr + u.pt_dsize);
+ core_regsec (abfd)->filepos = 0; /* Register segment is ptrace_user */
+
+ /* Align to word at least */
+ core_stacksec (abfd)->alignment_power = 2;
+ core_datasec (abfd)->alignment_power = 2;
+ core_regsec (abfd)->alignment_power = 2;
+
+ abfd->sections = core_stacksec (abfd);
+ core_stacksec (abfd)->next = core_datasec (abfd);
+ core_datasec (abfd)->next = core_regsec (abfd);
+ abfd->section_count = 3;
+
+ return abfd->xvec;
+}
+
+char *
+ptrace_unix_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ char *com = abfd->tdata.trad_core_data->u.pt_comm;
+ if (*com)
+ return com;
+ else
+ return 0;
+}
+
+/* ARGSUSED */
+int
+ptrace_unix_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return abfd->tdata.trad_core_data->u.pt_sigframe.sig_num;
+}
+
+/* ARGSUSED */
+boolean
+ptrace_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ /* FIXME: Use pt_timdat field of the ptrace_user structure to match
+ the date of the executable */
+ return true;
+}
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target ptrace_core_vec =
+ {
+ "trad-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ ptrace_unix_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (ptrace_unix),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
+
+#endif /* PTRACE_CORE */
diff --git a/bfd/reloc.c b/bfd/reloc.c
new file mode 100644
index 00000000000..888581493b4
--- /dev/null
+++ b/bfd/reloc.c
@@ -0,0 +1,2842 @@
+/* BFD support for handling relocation entries.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ Relocations
+
+ BFD maintains relocations in much the same way it maintains
+ symbols: they are left alone until required, then read in
+ en-mass and translated into an internal form. A common
+ routine <<bfd_perform_relocation>> acts upon the
+ canonical form to do the fixup.
+
+ Relocations are maintained on a per section basis,
+ while symbols are maintained on a per BFD basis.
+
+ All that a back end has to do to fit the BFD interface is to create
+ a <<struct reloc_cache_entry>> for each relocation
+ in a particular section, and fill in the right bits of the structures.
+
+@menu
+@* typedef arelent::
+@* howto manager::
+@end menu
+
+*/
+
+/* DO compile in the reloc_code name table from libbfd.h. */
+#define _BFD_MAKE_TABLE_bfd_reloc_code_real
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+/*
+DOCDD
+INODE
+ typedef arelent, howto manager, Relocations, Relocations
+
+SUBSECTION
+ typedef arelent
+
+ This is the structure of a relocation entry:
+
+CODE_FRAGMENT
+.
+.typedef enum bfd_reloc_status
+.{
+. {* No errors detected *}
+. bfd_reloc_ok,
+.
+. {* The relocation was performed, but there was an overflow. *}
+. bfd_reloc_overflow,
+.
+. {* The address to relocate was not within the section supplied. *}
+. bfd_reloc_outofrange,
+.
+. {* Used by special functions *}
+. bfd_reloc_continue,
+.
+. {* Unsupported relocation size requested. *}
+. bfd_reloc_notsupported,
+.
+. {* Unused *}
+. bfd_reloc_other,
+.
+. {* The symbol to relocate against was undefined. *}
+. bfd_reloc_undefined,
+.
+. {* The relocation was performed, but may not be ok - presently
+. generated only when linking i960 coff files with i960 b.out
+. symbols. If this type is returned, the error_message argument
+. to bfd_perform_relocation will be set. *}
+. bfd_reloc_dangerous
+. }
+. bfd_reloc_status_type;
+.
+.
+.typedef struct reloc_cache_entry
+.{
+. {* A pointer into the canonical table of pointers *}
+. struct symbol_cache_entry **sym_ptr_ptr;
+.
+. {* offset in section *}
+. bfd_size_type address;
+.
+. {* addend for relocation value *}
+. bfd_vma addend;
+.
+. {* Pointer to how to perform the required relocation *}
+. reloc_howto_type *howto;
+.
+.} arelent;
+
+*/
+
+/*
+DESCRIPTION
+
+ Here is a description of each of the fields within an <<arelent>>:
+
+ o <<sym_ptr_ptr>>
+
+ The symbol table pointer points to a pointer to the symbol
+ associated with the relocation request. It is
+ the pointer into the table returned by the back end's
+ <<get_symtab>> action. @xref{Symbols}. The symbol is referenced
+ through a pointer to a pointer so that tools like the linker
+ can fix up all the symbols of the same name by modifying only
+ one pointer. The relocation routine looks in the symbol and
+ uses the base of the section the symbol is attached to and the
+ value of the symbol as the initial relocation offset. If the
+ symbol pointer is zero, then the section provided is looked up.
+
+ o <<address>>
+
+ The <<address>> field gives the offset in bytes from the base of
+ the section data which owns the relocation record to the first
+ byte of relocatable information. The actual data relocated
+ will be relative to this point; for example, a relocation
+ type which modifies the bottom two bytes of a four byte word
+ would not touch the first byte pointed to in a big endian
+ world.
+
+ o <<addend>>
+
+ The <<addend>> is a value provided by the back end to be added (!)
+ to the relocation offset. Its interpretation is dependent upon
+ the howto. For example, on the 68k the code:
+
+
+| char foo[];
+| main()
+| {
+| return foo[0x12345678];
+| }
+
+ Could be compiled into:
+
+| linkw fp,#-4
+| moveb @@#12345678,d0
+| extbl d0
+| unlk fp
+| rts
+
+
+ This could create a reloc pointing to <<foo>>, but leave the
+ offset in the data, something like:
+
+
+|RELOCATION RECORDS FOR [.text]:
+|offset type value
+|00000006 32 _foo
+|
+|00000000 4e56 fffc ; linkw fp,#-4
+|00000004 1039 1234 5678 ; moveb @@#12345678,d0
+|0000000a 49c0 ; extbl d0
+|0000000c 4e5e ; unlk fp
+|0000000e 4e75 ; rts
+
+
+ Using coff and an 88k, some instructions don't have enough
+ space in them to represent the full address range, and
+ pointers have to be loaded in two parts. So you'd get something like:
+
+
+| or.u r13,r0,hi16(_foo+0x12345678)
+| ld.b r2,r13,lo16(_foo+0x12345678)
+| jmp r1
+
+
+ This should create two relocs, both pointing to <<_foo>>, and with
+ 0x12340000 in their addend field. The data would consist of:
+
+
+|RELOCATION RECORDS FOR [.text]:
+|offset type value
+|00000002 HVRT16 _foo+0x12340000
+|00000006 LVRT16 _foo+0x12340000
+|
+|00000000 5da05678 ; or.u r13,r0,0x5678
+|00000004 1c4d5678 ; ld.b r2,r13,0x5678
+|00000008 f400c001 ; jmp r1
+
+
+ The relocation routine digs out the value from the data, adds
+ it to the addend to get the original offset, and then adds the
+ value of <<_foo>>. Note that all 32 bits have to be kept around
+ somewhere, to cope with carry from bit 15 to bit 16.
+
+ One further example is the sparc and the a.out format. The
+ sparc has a similar problem to the 88k, in that some
+ instructions don't have room for an entire offset, but on the
+ sparc the parts are created in odd sized lumps. The designers of
+ the a.out format chose to not use the data within the section
+ for storing part of the offset; all the offset is kept within
+ the reloc. Anything in the data should be ignored.
+
+| save %sp,-112,%sp
+| sethi %hi(_foo+0x12345678),%g2
+| ldsb [%g2+%lo(_foo+0x12345678)],%i0
+| ret
+| restore
+
+ Both relocs contain a pointer to <<foo>>, and the offsets
+ contain junk.
+
+
+|RELOCATION RECORDS FOR [.text]:
+|offset type value
+|00000004 HI22 _foo+0x12345678
+|00000008 LO10 _foo+0x12345678
+|
+|00000000 9de3bf90 ; save %sp,-112,%sp
+|00000004 05000000 ; sethi %hi(_foo+0),%g2
+|00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0
+|0000000c 81c7e008 ; ret
+|00000010 81e80000 ; restore
+
+
+ o <<howto>>
+
+ The <<howto>> field can be imagined as a
+ relocation instruction. It is a pointer to a structure which
+ contains information on what to do with all of the other
+ information in the reloc record and data section. A back end
+ would normally have a relocation instruction set and turn
+ relocations into pointers to the correct structure on input -
+ but it would be possible to create each howto field on demand.
+
+*/
+
+/*
+SUBSUBSECTION
+ <<enum complain_overflow>>
+
+ Indicates what sort of overflow checking should be done when
+ performing a relocation.
+
+CODE_FRAGMENT
+.
+.enum complain_overflow
+.{
+. {* Do not complain on overflow. *}
+. complain_overflow_dont,
+.
+. {* Complain if the bitfield overflows, whether it is considered
+. as signed or unsigned. *}
+. complain_overflow_bitfield,
+.
+. {* Complain if the value overflows when considered as signed
+. number. *}
+. complain_overflow_signed,
+.
+. {* Complain if the value overflows when considered as an
+. unsigned number. *}
+. complain_overflow_unsigned
+.};
+
+*/
+
+/*
+SUBSUBSECTION
+ <<reloc_howto_type>>
+
+ The <<reloc_howto_type>> is a structure which contains all the
+ information that libbfd needs to know to tie up a back end's data.
+
+CODE_FRAGMENT
+.struct symbol_cache_entry; {* Forward declaration *}
+.
+.struct reloc_howto_struct
+.{
+. {* The type field has mainly a documentary use - the back end can
+. do what it wants with it, though normally the back end's
+. external idea of what a reloc number is stored
+. in this field. For example, a PC relative word relocation
+. in a coff environment has the type 023 - because that's
+. what the outside world calls a R_PCRWORD reloc. *}
+. unsigned int type;
+.
+. {* The value the final relocation is shifted right by. This drops
+. unwanted data from the relocation. *}
+. unsigned int rightshift;
+.
+. {* The size of the item to be relocated. This is *not* a
+. power-of-two measure. To get the number of bytes operated
+. on by a type of relocation, use bfd_get_reloc_size. *}
+. int size;
+.
+. {* The number of bits in the item to be relocated. This is used
+. when doing overflow checking. *}
+. unsigned int bitsize;
+.
+. {* Notes that the relocation is relative to the location in the
+. data section of the addend. The relocation function will
+. subtract from the relocation value the address of the location
+. being relocated. *}
+. boolean pc_relative;
+.
+. {* The bit position of the reloc value in the destination.
+. The relocated value is left shifted by this amount. *}
+. unsigned int bitpos;
+.
+. {* What type of overflow error should be checked for when
+. relocating. *}
+. enum complain_overflow complain_on_overflow;
+.
+. {* If this field is non null, then the supplied function is
+. called rather than the normal function. This allows really
+. strange relocation methods to be accomodated (e.g., i960 callj
+. instructions). *}
+. bfd_reloc_status_type (*special_function)
+. PARAMS ((bfd *abfd,
+. arelent *reloc_entry,
+. struct symbol_cache_entry *symbol,
+. PTR data,
+. asection *input_section,
+. bfd *output_bfd,
+. char **error_message));
+.
+. {* The textual name of the relocation type. *}
+. char *name;
+.
+. {* When performing a partial link, some formats must modify the
+. relocations rather than the data - this flag signals this.*}
+. boolean partial_inplace;
+.
+. {* The src_mask selects which parts of the read in data
+. are to be used in the relocation sum. E.g., if this was an 8 bit
+. bit of data which we read and relocated, this would be
+. 0x000000ff. When we have relocs which have an addend, such as
+. sun4 extended relocs, the value in the offset part of a
+. relocating field is garbage so we never use it. In this case
+. the mask would be 0x00000000. *}
+. bfd_vma src_mask;
+.
+. {* The dst_mask selects which parts of the instruction are replaced
+. into the instruction. In most cases src_mask == dst_mask,
+. except in the above special case, where dst_mask would be
+. 0x000000ff, and src_mask would be 0x00000000. *}
+. bfd_vma dst_mask;
+.
+. {* When some formats create PC relative instructions, they leave
+. the value of the pc of the place being relocated in the offset
+. slot of the instruction, so that a PC relative relocation can
+. be made just by adding in an ordinary offset (e.g., sun3 a.out).
+. Some formats leave the displacement part of an instruction
+. empty (e.g., m88k bcs); this flag signals the fact.*}
+. boolean pcrel_offset;
+.
+.};
+
+*/
+
+/*
+FUNCTION
+ The HOWTO Macro
+
+DESCRIPTION
+ The HOWTO define is horrible and will go away.
+
+
+.#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
+. {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
+
+DESCRIPTION
+ And will be replaced with the totally magic way. But for the
+ moment, we are compatible, so do it this way.
+
+
+.#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
+.
+DESCRIPTION
+ Helper routine to turn a symbol into a relocation value.
+
+.#define HOWTO_PREPARE(relocation, symbol) \
+. { \
+. if (symbol != (asymbol *)NULL) { \
+. if (bfd_is_com_section (symbol->section)) { \
+. relocation = 0; \
+. } \
+. else { \
+. relocation = symbol->value; \
+. } \
+. } \
+.}
+
+*/
+
+/*
+FUNCTION
+ bfd_get_reloc_size
+
+SYNOPSIS
+ unsigned int bfd_get_reloc_size (reloc_howto_type *);
+
+DESCRIPTION
+ For a reloc_howto_type that operates on a fixed number of bytes,
+ this returns the number of bytes operated on.
+ */
+
+unsigned int
+bfd_get_reloc_size (howto)
+ reloc_howto_type *howto;
+{
+ switch (howto->size)
+ {
+ case 0: return 1;
+ case 1: return 2;
+ case 2: return 4;
+ case 3: return 0;
+ case 4: return 8;
+ case 8: return 16;
+ case -2: return 4;
+ default: abort ();
+ }
+}
+
+/*
+TYPEDEF
+ arelent_chain
+
+DESCRIPTION
+
+ How relocs are tied together in an <<asection>>:
+
+.typedef struct relent_chain {
+. arelent relent;
+. struct relent_chain *next;
+.} arelent_chain;
+
+*/
+
+/* N_ONES produces N one bits, without overflowing machine arithmetic. */
+#define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
+
+/*
+FUNCTION
+ bfd_check_overflow
+
+SYNOPSIS
+ bfd_reloc_status_type
+ bfd_check_overflow
+ (enum complain_overflow how,
+ unsigned int bitsize,
+ unsigned int rightshift,
+ unsigned int addrsize,
+ bfd_vma relocation);
+
+DESCRIPTION
+ Perform overflow checking on @var{relocation} which has
+ @var{bitsize} significant bits and will be shifted right by
+ @var{rightshift} bits, on a machine with addresses containing
+ @var{addrsize} significant bits. The result is either of
+ @code{bfd_reloc_ok} or @code{bfd_reloc_overflow}.
+
+*/
+
+bfd_reloc_status_type
+bfd_check_overflow (how, bitsize, rightshift, addrsize, relocation)
+ enum complain_overflow how;
+ unsigned int bitsize;
+ unsigned int rightshift;
+ unsigned int addrsize;
+ bfd_vma relocation;
+{
+ bfd_vma fieldmask, addrmask, signmask, ss, a;
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+
+ a = relocation;
+
+ /* Note: BITSIZE should always be <= ADDRSIZE, but in case it's not,
+ we'll be permissive: extra bits in the field mask will
+ automatically extend the address mask for purposes of the
+ overflow check. */
+ fieldmask = N_ONES (bitsize);
+ addrmask = N_ONES (addrsize) | fieldmask;
+
+ switch (how)
+ {
+ case complain_overflow_dont:
+ break;
+
+ case complain_overflow_signed:
+ /* If any sign bits are set, all sign bits must be set. That
+ is, A must be a valid negative address after shifting. */
+ a = (a & addrmask) >> rightshift;
+ signmask = ~ (fieldmask >> 1);
+ ss = a & signmask;
+ if (ss != 0 && ss != ((addrmask >> rightshift) & signmask))
+ flag = bfd_reloc_overflow;
+ break;
+
+ case complain_overflow_unsigned:
+ /* We have an overflow if the address does not fit in the field. */
+ a = (a & addrmask) >> rightshift;
+ if ((a & ~ fieldmask) != 0)
+ flag = bfd_reloc_overflow;
+ break;
+
+ case complain_overflow_bitfield:
+ /* Bitfields are sometimes signed, sometimes unsigned. We
+ overflow if the value has some, but not all, bits set outside
+ the field, or if it has any bits set outside the field but
+ the sign bit is not set. */
+ a >>= rightshift;
+ if ((a & ~ fieldmask) != 0)
+ {
+ signmask = (fieldmask >> 1) + 1;
+ ss = (signmask << rightshift) - 1;
+ if ((ss | relocation) != ~ (bfd_vma) 0)
+ flag = bfd_reloc_overflow;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ return flag;
+}
+
+/*
+FUNCTION
+ bfd_perform_relocation
+
+SYNOPSIS
+ bfd_reloc_status_type
+ bfd_perform_relocation
+ (bfd *abfd,
+ arelent *reloc_entry,
+ PTR data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message);
+
+DESCRIPTION
+ If @var{output_bfd} is supplied to this function, the
+ generated image will be relocatable; the relocations are
+ copied to the output file after they have been changed to
+ reflect the new state of the world. There are two ways of
+ reflecting the results of partial linkage in an output file:
+ by modifying the output data in place, and by modifying the
+ relocation record. Some native formats (e.g., basic a.out and
+ basic coff) have no way of specifying an addend in the
+ relocation type, so the addend has to go in the output data.
+ This is no big deal since in these formats the output data
+ slot will always be big enough for the addend. Complex reloc
+ types with addends were invented to solve just this problem.
+ The @var{error_message} argument is set to an error message if
+ this return @code{bfd_reloc_dangerous}.
+
+*/
+
+
+bfd_reloc_status_type
+bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+ bfd_size_type addr = reloc_entry->address;
+ bfd_vma output_base = 0;
+ reloc_howto_type *howto = reloc_entry->howto;
+ asection *reloc_target_output_section;
+ asymbol *symbol;
+
+ symbol = *(reloc_entry->sym_ptr_ptr);
+ if (bfd_is_abs_section (symbol->section)
+ && output_bfd != (bfd *) NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* If we are not producing relocateable output, return an error if
+ the symbol is not defined. An undefined weak symbol is
+ considered to have a value of zero (SVR4 ABI, p. 4-27). */
+ if (bfd_is_und_section (symbol->section)
+ && (symbol->flags & BSF_WEAK) == 0
+ && output_bfd == (bfd *) NULL)
+ flag = bfd_reloc_undefined;
+
+ /* If there is a function supplied to handle this relocation type,
+ call it. It'll return `bfd_reloc_continue' if further processing
+ can be done. */
+ if (howto->special_function)
+ {
+ bfd_reloc_status_type cont;
+ cont = howto->special_function (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd,
+ error_message);
+ if (cont != bfd_reloc_continue)
+ return cont;
+ }
+
+ /* Is the address of the relocation really within the section? */
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+
+ reloc_target_output_section = symbol->section->output_section;
+
+ /* Convert input-section-relative symbol value to absolute. */
+ if (output_bfd && howto->partial_inplace == false)
+ output_base = 0;
+ else
+ output_base = reloc_target_output_section->vma;
+
+ relocation += output_base + symbol->section->output_offset;
+
+ /* Add in supplied addend. */
+ relocation += reloc_entry->addend;
+
+ /* Here the variable relocation holds the final address of the
+ symbol we are relocating against, plus any addend. */
+
+ if (howto->pc_relative == true)
+ {
+ /* This is a PC relative relocation. We want to set RELOCATION
+ to the distance between the address of the symbol and the
+ location. RELOCATION is already the address of the symbol.
+
+ We start by subtracting the address of the section containing
+ the location.
+
+ If pcrel_offset is set, we must further subtract the position
+ of the location within the section. Some targets arrange for
+ the addend to be the negative of the position of the location
+ within the section; for example, i386-aout does this. For
+ i386-aout, pcrel_offset is false. Some other targets do not
+ include the position of the location; for example, m88kbcs,
+ or ELF. For those targets, pcrel_offset is true.
+
+ If we are producing relocateable output, then we must ensure
+ that this reloc will be correctly computed when the final
+ relocation is done. If pcrel_offset is false we want to wind
+ up with the negative of the location within the section,
+ which means we must adjust the existing addend by the change
+ in the location within the section. If pcrel_offset is true
+ we do not want to adjust the existing addend at all.
+
+ FIXME: This seems logical to me, but for the case of
+ producing relocateable output it is not what the code
+ actually does. I don't want to change it, because it seems
+ far too likely that something will break. */
+
+ relocation -=
+ input_section->output_section->vma + input_section->output_offset;
+
+ if (howto->pcrel_offset == true)
+ relocation -= reloc_entry->address;
+ }
+
+ if (output_bfd != (bfd *) NULL)
+ {
+ if (howto->partial_inplace == false)
+ {
+ /* This is a partial relocation, and we want to apply the relocation
+ to the reloc entry rather than the raw data. Modify the reloc
+ inplace to reflect what we now know. */
+ reloc_entry->addend = relocation;
+ reloc_entry->address += input_section->output_offset;
+ return flag;
+ }
+ else
+ {
+ /* This is a partial relocation, but inplace, so modify the
+ reloc record a bit.
+
+ If we've relocated with a symbol with a section, change
+ into a ref to the section belonging to the symbol. */
+
+ reloc_entry->address += input_section->output_offset;
+
+ /* WTF?? */
+ if (abfd->xvec->flavour == bfd_target_coff_flavour
+ && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0
+ && strcmp (abfd->xvec->name, "xcoff-powermac") != 0
+ && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
+ && strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
+ {
+#if 1
+ /* For m68k-coff, the addend was being subtracted twice during
+ relocation with -r. Removing the line below this comment
+ fixes that problem; see PR 2953.
+
+However, Ian wrote the following, regarding removing the line below,
+which explains why it is still enabled: --djm
+
+If you put a patch like that into BFD you need to check all the COFF
+linkers. I am fairly certain that patch will break coff-i386 (e.g.,
+SCO); see coff_i386_reloc in coff-i386.c where I worked around the
+problem in a different way. There may very well be a reason that the
+code works as it does.
+
+Hmmm. The first obvious point is that bfd_perform_relocation should
+not have any tests that depend upon the flavour. It's seem like
+entirely the wrong place for such a thing. The second obvious point
+is that the current code ignores the reloc addend when producing
+relocateable output for COFF. That's peculiar. In fact, I really
+have no idea what the point of the line you want to remove is.
+
+A typical COFF reloc subtracts the old value of the symbol and adds in
+the new value to the location in the object file (if it's a pc
+relative reloc it adds the difference between the symbol value and the
+location). When relocating we need to preserve that property.
+
+BFD handles this by setting the addend to the negative of the old
+value of the symbol. Unfortunately it handles common symbols in a
+non-standard way (it doesn't subtract the old value) but that's a
+different story (we can't change it without losing backward
+compatibility with old object files) (coff-i386 does subtract the old
+value, to be compatible with existing coff-i386 targets, like SCO).
+
+So everything works fine when not producing relocateable output. When
+we are producing relocateable output, logically we should do exactly
+what we do when not producing relocateable output. Therefore, your
+patch is correct. In fact, it should probably always just set
+reloc_entry->addend to 0 for all cases, since it is, in fact, going to
+add the value into the object file. This won't hurt the COFF code,
+which doesn't use the addend; I'm not sure what it will do to other
+formats (the thing to check for would be whether any formats both use
+the addend and set partial_inplace).
+
+When I wanted to make coff-i386 produce relocateable output, I ran
+into the problem that you are running into: I wanted to remove that
+line. Rather than risk it, I made the coff-i386 relocs use a special
+function; it's coff_i386_reloc in coff-i386.c. The function
+specifically adds the addend field into the object file, knowing that
+bfd_perform_relocation is not going to. If you remove that line, then
+coff-i386.c will wind up adding the addend field in twice. It's
+trivial to fix; it just needs to be done.
+
+The problem with removing the line is just that it may break some
+working code. With BFD it's hard to be sure of anything. The right
+way to deal with this is simply to build and test at least all the
+supported COFF targets. It should be straightforward if time and disk
+space consuming. For each target:
+ 1) build the linker
+ 2) generate some executable, and link it using -r (I would
+ probably use paranoia.o and link against newlib/libc.a, which
+ for all the supported targets would be available in
+ /usr/cygnus/progressive/H-host/target/lib/libc.a).
+ 3) make the change to reloc.c
+ 4) rebuild the linker
+ 5) repeat step 2
+ 6) if the resulting object files are the same, you have at least
+ made it no worse
+ 7) if they are different you have to figure out which version is
+ right
+*/
+ relocation -= reloc_entry->addend;
+#endif
+ reloc_entry->addend = 0;
+ }
+ else
+ {
+ reloc_entry->addend = relocation;
+ }
+ }
+ }
+ else
+ {
+ reloc_entry->addend = 0;
+ }
+
+ /* FIXME: This overflow checking is incomplete, because the value
+ might have overflowed before we get here. For a correct check we
+ need to compute the value in a size larger than bitsize, but we
+ can't reasonably do that for a reloc the same size as a host
+ machine word.
+ FIXME: We should also do overflow checking on the result after
+ adding in the value contained in the object file. */
+ if (howto->complain_on_overflow != complain_overflow_dont
+ && flag == bfd_reloc_ok)
+ flag = bfd_check_overflow (howto->complain_on_overflow,
+ howto->bitsize,
+ howto->rightshift,
+ bfd_arch_bits_per_address (abfd),
+ relocation);
+
+ /*
+ Either we are relocating all the way, or we don't want to apply
+ the relocation to the reloc entry (probably because there isn't
+ any room in the output format to describe addends to relocs)
+ */
+
+ /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
+ (OSF version 1.3, compiler version 3.11). It miscompiles the
+ following program:
+
+ struct str
+ {
+ unsigned int i0;
+ } s = { 0 };
+
+ int
+ main ()
+ {
+ unsigned long x;
+
+ x = 0x100000000;
+ x <<= (unsigned long) s.i0;
+ if (x == 0)
+ printf ("failed\n");
+ else
+ printf ("succeeded (%lx)\n", x);
+ }
+ */
+
+ relocation >>= (bfd_vma) howto->rightshift;
+
+ /* Shift everything up to where it's going to be used */
+
+ relocation <<= (bfd_vma) howto->bitpos;
+
+ /* Wait for the day when all have the mask in them */
+
+ /* What we do:
+ i instruction to be left alone
+ o offset within instruction
+ r relocation offset to apply
+ S src mask
+ D dst mask
+ N ~dst mask
+ A part 1
+ B part 2
+ R result
+
+ Do this:
+ i i i i i o o o o o from bfd_get<size>
+ and S S S S S to get the size offset we want
+ + r r r r r r r r r r to get the final value to place
+ and D D D D D to chop to right size
+ -----------------------
+ A A A A A
+ And this:
+ ... i i i i i o o o o o from bfd_get<size>
+ and N N N N N get instruction
+ -----------------------
+ ... B B B B B
+
+ And then:
+ B B B B B
+ or A A A A A
+ -----------------------
+ R R R R R R R R R R put into bfd_put<size>
+ */
+
+#define DOIT(x) \
+ x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, (char *) data + addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, (unsigned char *) data + addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
+ DOIT (x);
+ bfd_put_16 (abfd, x, (unsigned char *) data + addr);
+ }
+ break;
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ DOIT (x);
+ bfd_put_32 (abfd, x, (bfd_byte *) data + addr);
+ }
+ break;
+ case -2:
+ {
+ long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ relocation = -relocation;
+ DOIT (x);
+ bfd_put_32 (abfd, x, (bfd_byte *) data + addr);
+ }
+ break;
+
+ case -1:
+ {
+ long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
+ relocation = -relocation;
+ DOIT (x);
+ bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
+ }
+ break;
+
+ case 3:
+ /* Do nothing */
+ break;
+
+ case 4:
+#ifdef BFD64
+ {
+ bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr);
+ DOIT (x);
+ bfd_put_64 (abfd, x, (bfd_byte *) data + addr);
+ }
+#else
+ abort ();
+#endif
+ break;
+ default:
+ return bfd_reloc_other;
+ }
+
+ return flag;
+}
+
+/*
+FUNCTION
+ bfd_install_relocation
+
+SYNOPSIS
+ bfd_reloc_status_type
+ bfd_install_relocation
+ (bfd *abfd,
+ arelent *reloc_entry,
+ PTR data, bfd_vma data_start,
+ asection *input_section,
+ char **error_message);
+
+DESCRIPTION
+ This looks remarkably like <<bfd_perform_relocation>>, except it
+ does not expect that the section contents have been filled in.
+ I.e., it's suitable for use when creating, rather than applying
+ a relocation.
+
+ For now, this function should be considered reserved for the
+ assembler.
+
+*/
+
+
+bfd_reloc_status_type
+bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset,
+ input_section, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ PTR data_start;
+ bfd_vma data_start_offset;
+ asection *input_section;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+ bfd_size_type addr = reloc_entry->address;
+ bfd_vma output_base = 0;
+ reloc_howto_type *howto = reloc_entry->howto;
+ asection *reloc_target_output_section;
+ asymbol *symbol;
+ bfd_byte *data;
+
+ symbol = *(reloc_entry->sym_ptr_ptr);
+ if (bfd_is_abs_section (symbol->section))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* If there is a function supplied to handle this relocation type,
+ call it. It'll return `bfd_reloc_continue' if further processing
+ can be done. */
+ if (howto->special_function)
+ {
+ bfd_reloc_status_type cont;
+
+ /* XXX - The special_function calls haven't been fixed up to deal
+ with creating new relocations and section contents. */
+ cont = howto->special_function (abfd, reloc_entry, symbol,
+ /* XXX - Non-portable! */
+ ((bfd_byte *) data_start
+ - data_start_offset),
+ input_section, abfd, error_message);
+ if (cont != bfd_reloc_continue)
+ return cont;
+ }
+
+ /* Is the address of the relocation really within the section? */
+ if (reloc_entry->address > input_section->_cooked_size)
+ return bfd_reloc_outofrange;
+
+ /* Work out which section the relocation is targetted at and the
+ initial relocation command value. */
+
+ /* Get symbol value. (Common symbols are special.) */
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ reloc_target_output_section = symbol->section->output_section;
+
+ /* Convert input-section-relative symbol value to absolute. */
+ if (howto->partial_inplace == false)
+ output_base = 0;
+ else
+ output_base = reloc_target_output_section->vma;
+
+ relocation += output_base + symbol->section->output_offset;
+
+ /* Add in supplied addend. */
+ relocation += reloc_entry->addend;
+
+ /* Here the variable relocation holds the final address of the
+ symbol we are relocating against, plus any addend. */
+
+ if (howto->pc_relative == true)
+ {
+ /* This is a PC relative relocation. We want to set RELOCATION
+ to the distance between the address of the symbol and the
+ location. RELOCATION is already the address of the symbol.
+
+ We start by subtracting the address of the section containing
+ the location.
+
+ If pcrel_offset is set, we must further subtract the position
+ of the location within the section. Some targets arrange for
+ the addend to be the negative of the position of the location
+ within the section; for example, i386-aout does this. For
+ i386-aout, pcrel_offset is false. Some other targets do not
+ include the position of the location; for example, m88kbcs,
+ or ELF. For those targets, pcrel_offset is true.
+
+ If we are producing relocateable output, then we must ensure
+ that this reloc will be correctly computed when the final
+ relocation is done. If pcrel_offset is false we want to wind
+ up with the negative of the location within the section,
+ which means we must adjust the existing addend by the change
+ in the location within the section. If pcrel_offset is true
+ we do not want to adjust the existing addend at all.
+
+ FIXME: This seems logical to me, but for the case of
+ producing relocateable output it is not what the code
+ actually does. I don't want to change it, because it seems
+ far too likely that something will break. */
+
+ relocation -=
+ input_section->output_section->vma + input_section->output_offset;
+
+ if (howto->pcrel_offset == true && howto->partial_inplace == true)
+ relocation -= reloc_entry->address;
+ }
+
+ if (howto->partial_inplace == false)
+ {
+ /* This is a partial relocation, and we want to apply the relocation
+ to the reloc entry rather than the raw data. Modify the reloc
+ inplace to reflect what we now know. */
+ reloc_entry->addend = relocation;
+ reloc_entry->address += input_section->output_offset;
+ return flag;
+ }
+ else
+ {
+ /* This is a partial relocation, but inplace, so modify the
+ reloc record a bit.
+
+ If we've relocated with a symbol with a section, change
+ into a ref to the section belonging to the symbol. */
+
+ reloc_entry->address += input_section->output_offset;
+
+ /* WTF?? */
+ if (abfd->xvec->flavour == bfd_target_coff_flavour
+ && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0
+ && strcmp (abfd->xvec->name, "xcoff-powermac") != 0
+ && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
+ && strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
+ {
+#if 1
+/* For m68k-coff, the addend was being subtracted twice during
+ relocation with -r. Removing the line below this comment
+ fixes that problem; see PR 2953.
+
+However, Ian wrote the following, regarding removing the line below,
+which explains why it is still enabled: --djm
+
+If you put a patch like that into BFD you need to check all the COFF
+linkers. I am fairly certain that patch will break coff-i386 (e.g.,
+SCO); see coff_i386_reloc in coff-i386.c where I worked around the
+problem in a different way. There may very well be a reason that the
+code works as it does.
+
+Hmmm. The first obvious point is that bfd_install_relocation should
+not have any tests that depend upon the flavour. It's seem like
+entirely the wrong place for such a thing. The second obvious point
+is that the current code ignores the reloc addend when producing
+relocateable output for COFF. That's peculiar. In fact, I really
+have no idea what the point of the line you want to remove is.
+
+A typical COFF reloc subtracts the old value of the symbol and adds in
+the new value to the location in the object file (if it's a pc
+relative reloc it adds the difference between the symbol value and the
+location). When relocating we need to preserve that property.
+
+BFD handles this by setting the addend to the negative of the old
+value of the symbol. Unfortunately it handles common symbols in a
+non-standard way (it doesn't subtract the old value) but that's a
+different story (we can't change it without losing backward
+compatibility with old object files) (coff-i386 does subtract the old
+value, to be compatible with existing coff-i386 targets, like SCO).
+
+So everything works fine when not producing relocateable output. When
+we are producing relocateable output, logically we should do exactly
+what we do when not producing relocateable output. Therefore, your
+patch is correct. In fact, it should probably always just set
+reloc_entry->addend to 0 for all cases, since it is, in fact, going to
+add the value into the object file. This won't hurt the COFF code,
+which doesn't use the addend; I'm not sure what it will do to other
+formats (the thing to check for would be whether any formats both use
+the addend and set partial_inplace).
+
+When I wanted to make coff-i386 produce relocateable output, I ran
+into the problem that you are running into: I wanted to remove that
+line. Rather than risk it, I made the coff-i386 relocs use a special
+function; it's coff_i386_reloc in coff-i386.c. The function
+specifically adds the addend field into the object file, knowing that
+bfd_install_relocation is not going to. If you remove that line, then
+coff-i386.c will wind up adding the addend field in twice. It's
+trivial to fix; it just needs to be done.
+
+The problem with removing the line is just that it may break some
+working code. With BFD it's hard to be sure of anything. The right
+way to deal with this is simply to build and test at least all the
+supported COFF targets. It should be straightforward if time and disk
+space consuming. For each target:
+ 1) build the linker
+ 2) generate some executable, and link it using -r (I would
+ probably use paranoia.o and link against newlib/libc.a, which
+ for all the supported targets would be available in
+ /usr/cygnus/progressive/H-host/target/lib/libc.a).
+ 3) make the change to reloc.c
+ 4) rebuild the linker
+ 5) repeat step 2
+ 6) if the resulting object files are the same, you have at least
+ made it no worse
+ 7) if they are different you have to figure out which version is
+ right
+*/
+ relocation -= reloc_entry->addend;
+#endif
+ reloc_entry->addend = 0;
+ }
+ else
+ {
+ reloc_entry->addend = relocation;
+ }
+ }
+
+ /* FIXME: This overflow checking is incomplete, because the value
+ might have overflowed before we get here. For a correct check we
+ need to compute the value in a size larger than bitsize, but we
+ can't reasonably do that for a reloc the same size as a host
+ machine word.
+ FIXME: We should also do overflow checking on the result after
+ adding in the value contained in the object file. */
+ if (howto->complain_on_overflow != complain_overflow_dont)
+ flag = bfd_check_overflow (howto->complain_on_overflow,
+ howto->bitsize,
+ howto->rightshift,
+ bfd_arch_bits_per_address (abfd),
+ relocation);
+
+ /*
+ Either we are relocating all the way, or we don't want to apply
+ the relocation to the reloc entry (probably because there isn't
+ any room in the output format to describe addends to relocs)
+ */
+
+ /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
+ (OSF version 1.3, compiler version 3.11). It miscompiles the
+ following program:
+
+ struct str
+ {
+ unsigned int i0;
+ } s = { 0 };
+
+ int
+ main ()
+ {
+ unsigned long x;
+
+ x = 0x100000000;
+ x <<= (unsigned long) s.i0;
+ if (x == 0)
+ printf ("failed\n");
+ else
+ printf ("succeeded (%lx)\n", x);
+ }
+ */
+
+ relocation >>= (bfd_vma) howto->rightshift;
+
+ /* Shift everything up to where it's going to be used */
+
+ relocation <<= (bfd_vma) howto->bitpos;
+
+ /* Wait for the day when all have the mask in them */
+
+ /* What we do:
+ i instruction to be left alone
+ o offset within instruction
+ r relocation offset to apply
+ S src mask
+ D dst mask
+ N ~dst mask
+ A part 1
+ B part 2
+ R result
+
+ Do this:
+ i i i i i o o o o o from bfd_get<size>
+ and S S S S S to get the size offset we want
+ + r r r r r r r r r r to get the final value to place
+ and D D D D D to chop to right size
+ -----------------------
+ A A A A A
+ And this:
+ ... i i i i i o o o o o from bfd_get<size>
+ and N N N N N get instruction
+ -----------------------
+ ... B B B B B
+
+ And then:
+ B B B B B
+ or A A A A A
+ -----------------------
+ R R R R R R R R R R put into bfd_put<size>
+ */
+
+#define DOIT(x) \
+ x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
+
+ data = (bfd_byte *) data_start + (addr - data_start_offset);
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, (char *) data);
+ DOIT (x);
+ bfd_put_8 (abfd, x, (unsigned char *) data);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, (bfd_byte *) data);
+ DOIT (x);
+ bfd_put_16 (abfd, x, (unsigned char *) data);
+ }
+ break;
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, (bfd_byte *) data);
+ DOIT (x);
+ bfd_put_32 (abfd, x, (bfd_byte *) data);
+ }
+ break;
+ case -2:
+ {
+ long x = bfd_get_32 (abfd, (bfd_byte *) data);
+ relocation = -relocation;
+ DOIT (x);
+ bfd_put_32 (abfd, x, (bfd_byte *) data);
+ }
+ break;
+
+ case 3:
+ /* Do nothing */
+ break;
+
+ case 4:
+ {
+ bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data);
+ DOIT (x);
+ bfd_put_64 (abfd, x, (bfd_byte *) data);
+ }
+ break;
+ default:
+ return bfd_reloc_other;
+ }
+
+ return flag;
+}
+
+/* This relocation routine is used by some of the backend linkers.
+ They do not construct asymbol or arelent structures, so there is no
+ reason for them to use bfd_perform_relocation. Also,
+ bfd_perform_relocation is so hacked up it is easier to write a new
+ function than to try to deal with it.
+
+ This routine does a final relocation. Whether it is useful for a
+ relocateable link depends upon how the object format defines
+ relocations.
+
+ FIXME: This routine ignores any special_function in the HOWTO,
+ since the existing special_function values have been written for
+ bfd_perform_relocation.
+
+ HOWTO is the reloc howto information.
+ INPUT_BFD is the BFD which the reloc applies to.
+ INPUT_SECTION is the section which the reloc applies to.
+ CONTENTS is the contents of the section.
+ ADDRESS is the address of the reloc within INPUT_SECTION.
+ VALUE is the value of the symbol the reloc refers to.
+ ADDEND is the addend of the reloc. */
+
+bfd_reloc_status_type
+_bfd_final_link_relocate (howto, input_bfd, input_section, contents, address,
+ value, addend)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ bfd_vma address;
+ bfd_vma value;
+ bfd_vma addend;
+{
+ bfd_vma relocation;
+
+ /* Sanity check the address. */
+ if (address > input_section->_raw_size)
+ return bfd_reloc_outofrange;
+
+ /* This function assumes that we are dealing with a basic relocation
+ against a symbol. We want to compute the value of the symbol to
+ relocate to. This is just VALUE, the value of the symbol, plus
+ ADDEND, any addend associated with the reloc. */
+ relocation = value + addend;
+
+ /* If the relocation is PC relative, we want to set RELOCATION to
+ the distance between the symbol (currently in RELOCATION) and the
+ location we are relocating. Some targets (e.g., i386-aout)
+ arrange for the contents of the section to be the negative of the
+ offset of the location within the section; for such targets
+ pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
+ simply leave the contents of the section as zero; for such
+ targets pcrel_offset is true. If pcrel_offset is false we do not
+ need to subtract out the offset of the location within the
+ section (which is just ADDRESS). */
+ if (howto->pc_relative)
+ {
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset);
+ if (howto->pcrel_offset)
+ relocation -= address;
+ }
+
+ return _bfd_relocate_contents (howto, input_bfd, relocation,
+ contents + address);
+}
+
+/* Relocate a given location using a given value and howto. */
+
+bfd_reloc_status_type
+_bfd_relocate_contents (howto, input_bfd, relocation, location)
+ reloc_howto_type *howto;
+ bfd *input_bfd;
+ bfd_vma relocation;
+ bfd_byte *location;
+{
+ int size;
+ bfd_vma x;
+ boolean overflow;
+ unsigned int rightshift = howto->rightshift;
+ unsigned int bitpos = howto->bitpos;
+
+ /* If the size is negative, negate RELOCATION. This isn't very
+ general. */
+ if (howto->size < 0)
+ relocation = -relocation;
+
+ /* Get the value we are going to relocate. */
+ size = bfd_get_reloc_size (howto);
+ switch (size)
+ {
+ default:
+ case 0:
+ abort ();
+ case 1:
+ x = bfd_get_8 (input_bfd, location);
+ break;
+ case 2:
+ x = bfd_get_16 (input_bfd, location);
+ break;
+ case 4:
+ x = bfd_get_32 (input_bfd, location);
+ break;
+ case 8:
+#ifdef BFD64
+ x = bfd_get_64 (input_bfd, location);
+#else
+ abort ();
+#endif
+ break;
+ }
+
+ /* Check for overflow. FIXME: We may drop bits during the addition
+ which we don't check for. We must either check at every single
+ operation, which would be tedious, or we must do the computations
+ in a type larger than bfd_vma, which would be inefficient. */
+ overflow = false;
+ if (howto->complain_on_overflow != complain_overflow_dont)
+ {
+ bfd_vma addrmask, fieldmask, signmask, ss;
+ bfd_vma a, b, sum;
+
+ /* Get the values to be added together. For signed and unsigned
+ relocations, we assume that all values should be truncated to
+ the size of an address. For bitfields, all the bits matter.
+ See also bfd_check_overflow. */
+ fieldmask = N_ONES (howto->bitsize);
+ addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask;
+ a = relocation;
+ b = x & howto->src_mask;
+
+ switch (howto->complain_on_overflow)
+ {
+ case complain_overflow_signed:
+ a = (a & addrmask) >> rightshift;
+
+ /* If any sign bits are set, all sign bits must be set.
+ That is, A must be a valid negative address after
+ shifting. */
+ signmask = ~ (fieldmask >> 1);
+ ss = a & signmask;
+ if (ss != 0 && ss != ((addrmask >> rightshift) & signmask))
+ overflow = true;
+
+ /* We only need this next bit of code if the sign bit of B
+ is below the sign bit of A. This would only happen if
+ SRC_MASK had fewer bits than BITSIZE. Note that if
+ SRC_MASK has more bits than BITSIZE, we can get into
+ trouble; we would need to verify that B is in range, as
+ we do for A above. */
+ signmask = ((~ howto->src_mask) >> 1) & howto->src_mask;
+ if ((b & signmask) != 0)
+ {
+ /* Set all the bits above the sign bit. */
+ b -= signmask <<= 1;
+ }
+
+ b = (b & addrmask) >> bitpos;
+
+ /* Now we can do the addition. */
+ sum = a + b;
+
+ /* See if the result has the correct sign. Bits above the
+ sign bit are junk now; ignore them. If the sum is
+ positive, make sure we did not have all negative inputs;
+ if the sum is negative, make sure we did not have all
+ positive inputs. The test below looks only at the sign
+ bits, and it really just
+ SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM)
+ */
+ signmask = (fieldmask >> 1) + 1;
+ if (((~ (a ^ b)) & (a ^ sum)) & signmask)
+ overflow = true;
+
+ break;
+
+ case complain_overflow_unsigned:
+ /* Checking for an unsigned overflow is relatively easy:
+ trim the addresses and add, and trim the result as well.
+ Overflow is normally indicated when the result does not
+ fit in the field. However, we also need to consider the
+ case when, e.g., fieldmask is 0x7fffffff or smaller, an
+ input is 0x80000000, and bfd_vma is only 32 bits; then we
+ will get sum == 0, but there is an overflow, since the
+ inputs did not fit in the field. Instead of doing a
+ separate test, we can check for this by or-ing in the
+ operands when testing for the sum overflowing its final
+ field. */
+ a = (a & addrmask) >> rightshift;
+ b = (b & addrmask) >> bitpos;
+ sum = (a + b) & addrmask;
+ if ((a | b | sum) & ~ fieldmask)
+ overflow = true;
+
+ break;
+
+ case complain_overflow_bitfield:
+ /* Much like unsigned, except no trimming with addrmask. In
+ addition, the sum overflows if there is a carry out of
+ the bfd_vma, i.e., the sum is less than either input
+ operand. */
+ a >>= rightshift;
+ b >>= bitpos;
+
+ /* Bitfields are sometimes used for signed numbers; for
+ example, a 13-bit field sometimes represents values in
+ 0..8191 and sometimes represents values in -4096..4095.
+ If the field is signed and a is -4095 (0x1001) and b is
+ -1 (0x1fff), the sum is -4096 (0x1000), but (0x1001 +
+ 0x1fff is 0x3000). It's not clear how to handle this
+ everywhere, since there is not way to know how many bits
+ are significant in the relocation, but the original code
+ assumed that it was fully sign extended, and we will keep
+ that assumption. */
+ signmask = (fieldmask >> 1) + 1;
+
+ if ((a & ~ fieldmask) != 0)
+ {
+ /* Some bits out of the field are set. This might not
+ be a problem: if this is a signed bitfield, it is OK
+ iff all the high bits are set, including the sign
+ bit. We'll try setting all but the most significant
+ bit in the original relocation value: if this is all
+ ones, we are OK, assuming a signed bitfield. */
+ ss = (signmask << rightshift) - 1;
+ if ((ss | relocation) != ~ (bfd_vma) 0)
+ overflow = true;
+ a &= fieldmask;
+ }
+
+ /* We just assume (b & ~ fieldmask) == 0. */
+
+ sum = a + b;
+ if (sum < a || (sum & ~ fieldmask) != 0)
+ {
+ /* There was a carry out, or the field overflow. Test
+ for signed operands again. Here is the overflow test
+ is as for complain_overflow_signed. */
+ if (((~ (a ^ b)) & (a ^ sum)) & signmask)
+ overflow = true;
+ }
+
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ /* Put RELOCATION in the right bits. */
+ relocation >>= (bfd_vma) rightshift;
+ relocation <<= (bfd_vma) bitpos;
+
+ /* Add RELOCATION to the right bits of X. */
+ x = ((x & ~howto->dst_mask)
+ | (((x & howto->src_mask) + relocation) & howto->dst_mask));
+
+ /* Put the relocated value back in the object file. */
+ switch (size)
+ {
+ default:
+ case 0:
+ abort ();
+ case 1:
+ bfd_put_8 (input_bfd, x, location);
+ break;
+ case 2:
+ bfd_put_16 (input_bfd, x, location);
+ break;
+ case 4:
+ bfd_put_32 (input_bfd, x, location);
+ break;
+ case 8:
+#ifdef BFD64
+ bfd_put_64 (input_bfd, x, location);
+#else
+ abort ();
+#endif
+ break;
+ }
+
+ return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
+}
+
+/*
+DOCDD
+INODE
+ howto manager, , typedef arelent, Relocations
+
+SECTION
+ The howto manager
+
+ When an application wants to create a relocation, but doesn't
+ know what the target machine might call it, it can find out by
+ using this bit of code.
+
+*/
+
+/*
+TYPEDEF
+ bfd_reloc_code_type
+
+DESCRIPTION
+ The insides of a reloc code. The idea is that, eventually, there
+ will be one enumerator for every type of relocation we ever do.
+ Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll
+ return a howto pointer.
+
+ This does mean that the application must determine the correct
+ enumerator value; you can't get a howto pointer from a random set
+ of attributes.
+
+SENUM
+ bfd_reloc_code_real
+
+ENUM
+ BFD_RELOC_64
+ENUMX
+ BFD_RELOC_32
+ENUMX
+ BFD_RELOC_26
+ENUMX
+ BFD_RELOC_24
+ENUMX
+ BFD_RELOC_16
+ENUMX
+ BFD_RELOC_14
+ENUMX
+ BFD_RELOC_8
+ENUMDOC
+ Basic absolute relocations of N bits.
+
+ENUM
+ BFD_RELOC_64_PCREL
+ENUMX
+ BFD_RELOC_32_PCREL
+ENUMX
+ BFD_RELOC_24_PCREL
+ENUMX
+ BFD_RELOC_16_PCREL
+ENUMX
+ BFD_RELOC_12_PCREL
+ENUMX
+ BFD_RELOC_8_PCREL
+ENUMDOC
+ PC-relative relocations. Sometimes these are relative to the address
+of the relocation itself; sometimes they are relative to the start of
+the section containing the relocation. It depends on the specific target.
+
+The 24-bit relocation is used in some Intel 960 configurations.
+
+ENUM
+ BFD_RELOC_32_GOT_PCREL
+ENUMX
+ BFD_RELOC_16_GOT_PCREL
+ENUMX
+ BFD_RELOC_8_GOT_PCREL
+ENUMX
+ BFD_RELOC_32_GOTOFF
+ENUMX
+ BFD_RELOC_16_GOTOFF
+ENUMX
+ BFD_RELOC_LO16_GOTOFF
+ENUMX
+ BFD_RELOC_HI16_GOTOFF
+ENUMX
+ BFD_RELOC_HI16_S_GOTOFF
+ENUMX
+ BFD_RELOC_8_GOTOFF
+ENUMX
+ BFD_RELOC_32_PLT_PCREL
+ENUMX
+ BFD_RELOC_24_PLT_PCREL
+ENUMX
+ BFD_RELOC_16_PLT_PCREL
+ENUMX
+ BFD_RELOC_8_PLT_PCREL
+ENUMX
+ BFD_RELOC_32_PLTOFF
+ENUMX
+ BFD_RELOC_16_PLTOFF
+ENUMX
+ BFD_RELOC_LO16_PLTOFF
+ENUMX
+ BFD_RELOC_HI16_PLTOFF
+ENUMX
+ BFD_RELOC_HI16_S_PLTOFF
+ENUMX
+ BFD_RELOC_8_PLTOFF
+ENUMDOC
+ For ELF.
+
+ENUM
+ BFD_RELOC_68K_GLOB_DAT
+ENUMX
+ BFD_RELOC_68K_JMP_SLOT
+ENUMX
+ BFD_RELOC_68K_RELATIVE
+ENUMDOC
+ Relocations used by 68K ELF.
+
+ENUM
+ BFD_RELOC_32_BASEREL
+ENUMX
+ BFD_RELOC_16_BASEREL
+ENUMX
+ BFD_RELOC_LO16_BASEREL
+ENUMX
+ BFD_RELOC_HI16_BASEREL
+ENUMX
+ BFD_RELOC_HI16_S_BASEREL
+ENUMX
+ BFD_RELOC_8_BASEREL
+ENUMX
+ BFD_RELOC_RVA
+ENUMDOC
+ Linkage-table relative.
+
+ENUM
+ BFD_RELOC_8_FFnn
+ENUMDOC
+ Absolute 8-bit relocation, but used to form an address like 0xFFnn.
+
+ENUM
+ BFD_RELOC_32_PCREL_S2
+ENUMX
+ BFD_RELOC_16_PCREL_S2
+ENUMX
+ BFD_RELOC_23_PCREL_S2
+ENUMDOC
+ These PC-relative relocations are stored as word displacements --
+i.e., byte displacements shifted right two bits. The 30-bit word
+displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
+SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
+signed 16-bit displacement is used on the MIPS, and the 23-bit
+displacement is used on the Alpha.
+
+ENUM
+ BFD_RELOC_HI22
+ENUMX
+ BFD_RELOC_LO10
+ENUMDOC
+ High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
+the target word. These are used on the SPARC.
+
+ENUM
+ BFD_RELOC_GPREL16
+ENUMX
+ BFD_RELOC_GPREL32
+ENUMDOC
+ For systems that allocate a Global Pointer register, these are
+displacements off that register. These relocation types are
+handled specially, because the value the register will have is
+decided relatively late.
+
+
+ENUM
+ BFD_RELOC_I960_CALLJ
+ENUMDOC
+ Reloc types used for i960/b.out.
+
+ENUM
+ BFD_RELOC_NONE
+ENUMX
+ BFD_RELOC_SPARC_WDISP22
+ENUMX
+ BFD_RELOC_SPARC22
+ENUMX
+ BFD_RELOC_SPARC13
+ENUMX
+ BFD_RELOC_SPARC_GOT10
+ENUMX
+ BFD_RELOC_SPARC_GOT13
+ENUMX
+ BFD_RELOC_SPARC_GOT22
+ENUMX
+ BFD_RELOC_SPARC_PC10
+ENUMX
+ BFD_RELOC_SPARC_PC22
+ENUMX
+ BFD_RELOC_SPARC_WPLT30
+ENUMX
+ BFD_RELOC_SPARC_COPY
+ENUMX
+ BFD_RELOC_SPARC_GLOB_DAT
+ENUMX
+ BFD_RELOC_SPARC_JMP_SLOT
+ENUMX
+ BFD_RELOC_SPARC_RELATIVE
+ENUMX
+ BFD_RELOC_SPARC_UA32
+ENUMDOC
+ SPARC ELF relocations. There is probably some overlap with other
+ relocation types already defined.
+
+ENUM
+ BFD_RELOC_SPARC_BASE13
+ENUMX
+ BFD_RELOC_SPARC_BASE22
+ENUMDOC
+ I think these are specific to SPARC a.out (e.g., Sun 4).
+
+ENUMEQ
+ BFD_RELOC_SPARC_64
+ BFD_RELOC_64
+ENUMX
+ BFD_RELOC_SPARC_10
+ENUMX
+ BFD_RELOC_SPARC_11
+ENUMX
+ BFD_RELOC_SPARC_OLO10
+ENUMX
+ BFD_RELOC_SPARC_HH22
+ENUMX
+ BFD_RELOC_SPARC_HM10
+ENUMX
+ BFD_RELOC_SPARC_LM22
+ENUMX
+ BFD_RELOC_SPARC_PC_HH22
+ENUMX
+ BFD_RELOC_SPARC_PC_HM10
+ENUMX
+ BFD_RELOC_SPARC_PC_LM22
+ENUMX
+ BFD_RELOC_SPARC_WDISP16
+ENUMX
+ BFD_RELOC_SPARC_WDISP19
+ENUMX
+ BFD_RELOC_SPARC_7
+ENUMX
+ BFD_RELOC_SPARC_6
+ENUMX
+ BFD_RELOC_SPARC_5
+ENUMEQX
+ BFD_RELOC_SPARC_DISP64
+ BFD_RELOC_64_PCREL
+ENUMX
+ BFD_RELOC_SPARC_PLT64
+ENUMX
+ BFD_RELOC_SPARC_HIX22
+ENUMX
+ BFD_RELOC_SPARC_LOX10
+ENUMX
+ BFD_RELOC_SPARC_H44
+ENUMX
+ BFD_RELOC_SPARC_M44
+ENUMX
+ BFD_RELOC_SPARC_L44
+ENUMX
+ BFD_RELOC_SPARC_REGISTER
+ENUMDOC
+ SPARC64 relocations
+
+ENUM
+ BFD_RELOC_SPARC_REV32
+ENUMDOC
+ SPARC little endian relocation
+
+ENUM
+ BFD_RELOC_ALPHA_GPDISP_HI16
+ENUMDOC
+ Alpha ECOFF and ELF relocations. Some of these treat the symbol or
+ "addend" in some special way.
+ For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
+ writing; when reading, it will be the absolute section symbol. The
+ addend is the displacement in bytes of the "lda" instruction from
+ the "ldah" instruction (which is at the address of this reloc).
+ENUM
+ BFD_RELOC_ALPHA_GPDISP_LO16
+ENUMDOC
+ For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
+ with GPDISP_HI16 relocs. The addend is ignored when writing the
+ relocations out, and is filled in with the file's GP value on
+ reading, for convenience.
+
+ENUM
+ BFD_RELOC_ALPHA_GPDISP
+ENUMDOC
+ The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
+ relocation except that there is no accompanying GPDISP_LO16
+ relocation.
+
+ENUM
+ BFD_RELOC_ALPHA_LITERAL
+ENUMX
+ BFD_RELOC_ALPHA_ELF_LITERAL
+ENUMX
+ BFD_RELOC_ALPHA_LITUSE
+ENUMDOC
+ The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
+ the assembler turns it into a LDQ instruction to load the address of
+ the symbol, and then fills in a register in the real instruction.
+
+ The LITERAL reloc, at the LDQ instruction, refers to the .lita
+ section symbol. The addend is ignored when writing, but is filled
+ in with the file's GP value on reading, for convenience, as with the
+ GPDISP_LO16 reloc.
+
+ The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
+ It should refer to the symbol to be referenced, as with 16_GOTOFF,
+ but it generates output not based on the position within the .got
+ section, but relative to the GP value chosen for the file during the
+ final link stage.
+
+ The LITUSE reloc, on the instruction using the loaded address, gives
+ information to the linker that it might be able to use to optimize
+ away some literal section references. The symbol is ignored (read
+ as the absolute section symbol), and the "addend" indicates the type
+ of instruction using the register:
+ 1 - "memory" fmt insn
+ 2 - byte-manipulation (byte offset reg)
+ 3 - jsr (target of branch)
+
+ The GNU linker currently doesn't do any of this optimizing.
+
+ENUM
+ BFD_RELOC_ALPHA_HINT
+ENUMDOC
+ The HINT relocation indicates a value that should be filled into the
+ "hint" field of a jmp/jsr/ret instruction, for possible branch-
+ prediction logic which may be provided on some processors.
+
+ENUM
+ BFD_RELOC_ALPHA_LINKAGE
+ENUMDOC
+ The LINKAGE relocation outputs a linkage pair in the object file,
+ which is filled by the linker.
+
+ENUM
+ BFD_RELOC_ALPHA_CODEADDR
+ENUMDOC
+ The CODEADDR relocation outputs a STO_CA in the object file,
+ which is filled by the linker.
+
+ENUM
+ BFD_RELOC_MIPS_JMP
+ENUMDOC
+ Bits 27..2 of the relocation address shifted right 2 bits;
+ simple reloc otherwise.
+
+ENUM
+ BFD_RELOC_MIPS16_JMP
+ENUMDOC
+ The MIPS16 jump instruction.
+
+ENUM
+ BFD_RELOC_MIPS16_GPREL
+ENUMDOC
+ MIPS16 GP relative reloc.
+
+ENUM
+ BFD_RELOC_HI16
+ENUMDOC
+ High 16 bits of 32-bit value; simple reloc.
+ENUM
+ BFD_RELOC_HI16_S
+ENUMDOC
+ High 16 bits of 32-bit value but the low 16 bits will be sign
+ extended and added to form the final result. If the low 16
+ bits form a negative number, we need to add one to the high value
+ to compensate for the borrow when the low bits are added.
+ENUM
+ BFD_RELOC_LO16
+ENUMDOC
+ Low 16 bits.
+ENUM
+ BFD_RELOC_PCREL_HI16_S
+ENUMDOC
+ Like BFD_RELOC_HI16_S, but PC relative.
+ENUM
+ BFD_RELOC_PCREL_LO16
+ENUMDOC
+ Like BFD_RELOC_LO16, but PC relative.
+
+ENUMEQ
+ BFD_RELOC_MIPS_GPREL
+ BFD_RELOC_GPREL16
+ENUMDOC
+ Relocation relative to the global pointer.
+
+ENUM
+ BFD_RELOC_MIPS_LITERAL
+ENUMDOC
+ Relocation against a MIPS literal section.
+
+ENUM
+ BFD_RELOC_MIPS_GOT16
+ENUMX
+ BFD_RELOC_MIPS_CALL16
+ENUMEQX
+ BFD_RELOC_MIPS_GPREL32
+ BFD_RELOC_GPREL32
+ENUMX
+ BFD_RELOC_MIPS_GOT_HI16
+ENUMX
+ BFD_RELOC_MIPS_GOT_LO16
+ENUMX
+ BFD_RELOC_MIPS_CALL_HI16
+ENUMX
+ BFD_RELOC_MIPS_CALL_LO16
+COMMENT
+ENUMDOC
+ MIPS ELF relocations.
+
+COMMENT
+
+ENUM
+ BFD_RELOC_386_GOT32
+ENUMX
+ BFD_RELOC_386_PLT32
+ENUMX
+ BFD_RELOC_386_COPY
+ENUMX
+ BFD_RELOC_386_GLOB_DAT
+ENUMX
+ BFD_RELOC_386_JUMP_SLOT
+ENUMX
+ BFD_RELOC_386_RELATIVE
+ENUMX
+ BFD_RELOC_386_GOTOFF
+ENUMX
+ BFD_RELOC_386_GOTPC
+ENUMDOC
+ i386/elf relocations
+
+ENUM
+ BFD_RELOC_NS32K_IMM_8
+ENUMX
+ BFD_RELOC_NS32K_IMM_16
+ENUMX
+ BFD_RELOC_NS32K_IMM_32
+ENUMX
+ BFD_RELOC_NS32K_IMM_8_PCREL
+ENUMX
+ BFD_RELOC_NS32K_IMM_16_PCREL
+ENUMX
+ BFD_RELOC_NS32K_IMM_32_PCREL
+ENUMX
+ BFD_RELOC_NS32K_DISP_8
+ENUMX
+ BFD_RELOC_NS32K_DISP_16
+ENUMX
+ BFD_RELOC_NS32K_DISP_32
+ENUMX
+ BFD_RELOC_NS32K_DISP_8_PCREL
+ENUMX
+ BFD_RELOC_NS32K_DISP_16_PCREL
+ENUMX
+ BFD_RELOC_NS32K_DISP_32_PCREL
+ENUMDOC
+ ns32k relocations
+
+ENUM
+ BFD_RELOC_PPC_B26
+ENUMX
+ BFD_RELOC_PPC_BA26
+ENUMX
+ BFD_RELOC_PPC_TOC16
+ENUMX
+ BFD_RELOC_PPC_B16
+ENUMX
+ BFD_RELOC_PPC_B16_BRTAKEN
+ENUMX
+ BFD_RELOC_PPC_B16_BRNTAKEN
+ENUMX
+ BFD_RELOC_PPC_BA16
+ENUMX
+ BFD_RELOC_PPC_BA16_BRTAKEN
+ENUMX
+ BFD_RELOC_PPC_BA16_BRNTAKEN
+ENUMX
+ BFD_RELOC_PPC_COPY
+ENUMX
+ BFD_RELOC_PPC_GLOB_DAT
+ENUMX
+ BFD_RELOC_PPC_JMP_SLOT
+ENUMX
+ BFD_RELOC_PPC_RELATIVE
+ENUMX
+ BFD_RELOC_PPC_LOCAL24PC
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR32
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16_LO
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16_HI
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16_HA
+ENUMX
+ BFD_RELOC_PPC_EMB_SDAI16
+ENUMX
+ BFD_RELOC_PPC_EMB_SDA2I16
+ENUMX
+ BFD_RELOC_PPC_EMB_SDA2REL
+ENUMX
+ BFD_RELOC_PPC_EMB_SDA21
+ENUMX
+ BFD_RELOC_PPC_EMB_MRKREF
+ENUMX
+ BFD_RELOC_PPC_EMB_RELSEC16
+ENUMX
+ BFD_RELOC_PPC_EMB_RELST_LO
+ENUMX
+ BFD_RELOC_PPC_EMB_RELST_HI
+ENUMX
+ BFD_RELOC_PPC_EMB_RELST_HA
+ENUMX
+ BFD_RELOC_PPC_EMB_BIT_FLD
+ENUMX
+ BFD_RELOC_PPC_EMB_RELSDA
+ENUMDOC
+ Power(rs6000) and PowerPC relocations.
+
+ENUM
+ BFD_RELOC_CTOR
+ENUMDOC
+ The type of reloc used to build a contructor table - at the moment
+ probably a 32 bit wide absolute relocation, but the target can choose.
+ It generally does map to one of the other relocation types.
+
+ENUM
+ BFD_RELOC_ARM_PCREL_BRANCH
+ENUMDOC
+ ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
+ not stored in the instruction.
+ENUM
+ BFD_RELOC_ARM_IMMEDIATE
+ENUMX
+ BFD_RELOC_ARM_OFFSET_IMM
+ENUMX
+ BFD_RELOC_ARM_SHIFT_IMM
+ENUMX
+ BFD_RELOC_ARM_SWI
+ENUMX
+ BFD_RELOC_ARM_MULTI
+ENUMX
+ BFD_RELOC_ARM_CP_OFF_IMM
+ENUMX
+ BFD_RELOC_ARM_ADR_IMM
+ENUMX
+ BFD_RELOC_ARM_LDR_IMM
+ENUMX
+ BFD_RELOC_ARM_LITERAL
+ENUMX
+ BFD_RELOC_ARM_IN_POOL
+ENUMX
+ BFD_RELOC_ARM_OFFSET_IMM8
+ENUMX
+ BFD_RELOC_ARM_HWLITERAL
+ENUMX
+ BFD_RELOC_ARM_THUMB_ADD
+ENUMX
+ BFD_RELOC_ARM_THUMB_IMM
+ENUMX
+ BFD_RELOC_ARM_THUMB_SHIFT
+ENUMX
+ BFD_RELOC_ARM_THUMB_OFFSET
+ENUMX
+ BFD_RELOC_ARM_GOT12
+ENUMX
+ BFD_RELOC_ARM_GOT32
+ENUMX
+ BFD_RELOC_ARM_JUMP_SLOT
+ENUMX
+ BFD_RELOC_ARM_COPY
+ENUMX
+ BFD_RELOC_ARM_GLOB_DAT
+ENUMX
+ BFD_RELOC_ARM_PLT32
+ENUMX
+ BFD_RELOC_ARM_RELATIVE
+ENUMX
+ BFD_RELOC_ARM_GOTOFF
+ENUMX
+ BFD_RELOC_ARM_GOTPC
+ENUMDOC
+ These relocs are only used within the ARM assembler. They are not
+ (at present) written to any object files.
+
+ENUM
+ BFD_RELOC_SH_PCDISP8BY2
+ENUMX
+ BFD_RELOC_SH_PCDISP12BY2
+ENUMX
+ BFD_RELOC_SH_IMM4
+ENUMX
+ BFD_RELOC_SH_IMM4BY2
+ENUMX
+ BFD_RELOC_SH_IMM4BY4
+ENUMX
+ BFD_RELOC_SH_IMM8
+ENUMX
+ BFD_RELOC_SH_IMM8BY2
+ENUMX
+ BFD_RELOC_SH_IMM8BY4
+ENUMX
+ BFD_RELOC_SH_PCRELIMM8BY2
+ENUMX
+ BFD_RELOC_SH_PCRELIMM8BY4
+ENUMX
+ BFD_RELOC_SH_SWITCH16
+ENUMX
+ BFD_RELOC_SH_SWITCH32
+ENUMX
+ BFD_RELOC_SH_USES
+ENUMX
+ BFD_RELOC_SH_COUNT
+ENUMX
+ BFD_RELOC_SH_ALIGN
+ENUMX
+ BFD_RELOC_SH_CODE
+ENUMX
+ BFD_RELOC_SH_DATA
+ENUMX
+ BFD_RELOC_SH_LABEL
+ENUMDOC
+ Hitachi SH relocs. Not all of these appear in object files.
+
+ENUM
+ BFD_RELOC_THUMB_PCREL_BRANCH9
+ENUMX
+ BFD_RELOC_THUMB_PCREL_BRANCH12
+ENUMX
+ BFD_RELOC_THUMB_PCREL_BRANCH23
+ENUMDOC
+ Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must
+ be zero and is not stored in the instruction.
+
+ENUM
+ BFD_RELOC_ARC_B22_PCREL
+ENUMDOC
+ Argonaut RISC Core (ARC) relocs.
+ ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
+ not stored in the instruction. The high 20 bits are installed in bits 26
+ through 7 of the instruction.
+ENUM
+ BFD_RELOC_ARC_B26
+ENUMDOC
+ ARC 26 bit absolute branch. The lowest two bits must be zero and are not
+ stored in the instruction. The high 24 bits are installed in bits 23
+ through 0.
+
+ENUM
+ BFD_RELOC_D10V_10_PCREL_R
+ENUMDOC
+ Mitsubishi D10V relocs.
+ This is a 10-bit reloc with the right 2 bits
+ assumed to be 0.
+ENUM
+ BFD_RELOC_D10V_10_PCREL_L
+ENUMDOC
+ Mitsubishi D10V relocs.
+ This is a 10-bit reloc with the right 2 bits
+ assumed to be 0. This is the same as the previous reloc
+ except it is in the left container, i.e.,
+ shifted left 15 bits.
+ENUM
+ BFD_RELOC_D10V_18
+ENUMDOC
+ This is an 18-bit reloc with the right 2 bits
+ assumed to be 0.
+ENUM
+ BFD_RELOC_D10V_18_PCREL
+ENUMDOC
+ This is an 18-bit reloc with the right 2 bits
+ assumed to be 0.
+
+ENUM
+ BFD_RELOC_D30V_6
+ENUMDOC
+ Mitsubishi D30V relocs.
+ This is a 6-bit absolute reloc.
+ENUM
+ BFD_RELOC_D30V_9_PCREL
+ENUMDOC
+ This is a 6-bit pc-relative reloc with
+ the right 3 bits assumed to be 0.
+ENUM
+ BFD_RELOC_D30V_9_PCREL_R
+ENUMDOC
+ This is a 6-bit pc-relative reloc with
+ the right 3 bits assumed to be 0. Same
+ as the previous reloc but on the right side
+ of the container.
+ENUM
+ BFD_RELOC_D30V_15
+ENUMDOC
+ This is a 12-bit absolute reloc with the
+ right 3 bitsassumed to be 0.
+ENUM
+ BFD_RELOC_D30V_15_PCREL
+ENUMDOC
+ This is a 12-bit pc-relative reloc with
+ the right 3 bits assumed to be 0.
+ENUM
+ BFD_RELOC_D30V_15_PCREL_R
+ENUMDOC
+ This is a 12-bit pc-relative reloc with
+ the right 3 bits assumed to be 0. Same
+ as the previous reloc but on the right side
+ of the container.
+ENUM
+ BFD_RELOC_D30V_21
+ENUMDOC
+ This is an 18-bit absolute reloc with
+ the right 3 bits assumed to be 0.
+ENUM
+ BFD_RELOC_D30V_21_PCREL
+ENUMDOC
+ This is an 18-bit pc-relative reloc with
+ the right 3 bits assumed to be 0.
+ENUM
+ BFD_RELOC_D30V_21_PCREL_R
+ENUMDOC
+ This is an 18-bit pc-relative reloc with
+ the right 3 bits assumed to be 0. Same
+ as the previous reloc but on the right side
+ of the container.
+ENUM
+ BFD_RELOC_D30V_32
+ENUMDOC
+ This is a 32-bit absolute reloc.
+ENUM
+ BFD_RELOC_D30V_32_PCREL
+ENUMDOC
+ This is a 32-bit pc-relative reloc.
+
+ENUM
+ BFD_RELOC_M32R_24
+ENUMDOC
+ Mitsubishi M32R relocs.
+ This is a 24 bit absolute address.
+ENUM
+ BFD_RELOC_M32R_10_PCREL
+ENUMDOC
+ This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0.
+ENUM
+ BFD_RELOC_M32R_18_PCREL
+ENUMDOC
+ This is an 18-bit reloc with the right 2 bits assumed to be 0.
+ENUM
+ BFD_RELOC_M32R_26_PCREL
+ENUMDOC
+ This is a 26-bit reloc with the right 2 bits assumed to be 0.
+ENUM
+ BFD_RELOC_M32R_HI16_ULO
+ENUMDOC
+ This is a 16-bit reloc containing the high 16 bits of an address
+ used when the lower 16 bits are treated as unsigned.
+ENUM
+ BFD_RELOC_M32R_HI16_SLO
+ENUMDOC
+ This is a 16-bit reloc containing the high 16 bits of an address
+ used when the lower 16 bits are treated as signed.
+ENUM
+ BFD_RELOC_M32R_LO16
+ENUMDOC
+ This is a 16-bit reloc containing the lower 16 bits of an address.
+ENUM
+ BFD_RELOC_M32R_SDA16
+ENUMDOC
+ This is a 16-bit reloc containing the small data area offset for use in
+ add3, load, and store instructions.
+
+ENUM
+ BFD_RELOC_V850_9_PCREL
+ENUMDOC
+ This is a 9-bit reloc
+ENUM
+ BFD_RELOC_V850_22_PCREL
+ENUMDOC
+ This is a 22-bit reloc
+
+ENUM
+ BFD_RELOC_V850_SDA_16_16_OFFSET
+ENUMDOC
+ This is a 16 bit offset from the short data area pointer.
+ENUM
+ BFD_RELOC_V850_SDA_15_16_OFFSET
+ENUMDOC
+ This is a 16 bit offset (of which only 15 bits are used) from the
+ short data area pointer.
+ENUM
+ BFD_RELOC_V850_ZDA_16_16_OFFSET
+ENUMDOC
+ This is a 16 bit offset from the zero data area pointer.
+ENUM
+ BFD_RELOC_V850_ZDA_15_16_OFFSET
+ENUMDOC
+ This is a 16 bit offset (of which only 15 bits are used) from the
+ zero data area pointer.
+ENUM
+ BFD_RELOC_V850_TDA_6_8_OFFSET
+ENUMDOC
+ This is an 8 bit offset (of which only 6 bits are used) from the
+ tiny data area pointer.
+ENUM
+ BFD_RELOC_V850_TDA_7_8_OFFSET
+ENUMDOC
+ This is an 8bit offset (of which only 7 bits are used) from the tiny
+ data area pointer.
+ENUM
+ BFD_RELOC_V850_TDA_7_7_OFFSET
+ENUMDOC
+ This is a 7 bit offset from the tiny data area pointer.
+ENUM
+ BFD_RELOC_V850_TDA_16_16_OFFSET
+ENUMDOC
+ This is a 16 bit offset from the tiny data area pointer.
+COMMENT
+ENUM
+ BFD_RELOC_V850_TDA_4_5_OFFSET
+ENUMDOC
+ This is a 5 bit offset (of which only 4 bits are used) from the tiny
+ data area pointer.
+ENUM
+ BFD_RELOC_V850_TDA_4_4_OFFSET
+ENUMDOC
+ This is a 4 bit offset from the tiny data area pointer.
+ENUM
+ BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET
+ENUMDOC
+ This is a 16 bit offset from the short data area pointer, with the
+ bits placed non-contigously in the instruction.
+ENUM
+ BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET
+ENUMDOC
+ This is a 16 bit offset from the zero data area pointer, with the
+ bits placed non-contigously in the instruction.
+ENUM
+ BFD_RELOC_V850_CALLT_6_7_OFFSET
+ENUMDOC
+ This is a 6 bit offset from the call table base pointer.
+ENUM
+ BFD_RELOC_V850_CALLT_16_16_OFFSET
+ENUMDOC
+ This is a 16 bit offset from the call table base pointer.
+COMMENT
+
+ENUM
+ BFD_RELOC_MN10300_32_PCREL
+ENUMDOC
+ This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
+ instruction.
+ENUM
+ BFD_RELOC_MN10300_16_PCREL
+ENUMDOC
+ This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
+ instruction.
+
+ENUM
+ BFD_RELOC_TIC30_LDP
+ENUMDOC
+ This is a 8bit DP reloc for the tms320c30, where the most
+ significant 8 bits of a 24 bit word are placed into the least
+ significant 8 bits of the opcode.
+
+ENUM
+ BFD_RELOC_FR30_48
+ENUMDOC
+ This is a 48 bit reloc for the FR30 that stores 32 bits.
+ENUM
+ BFD_RELOC_FR30_20
+ENUMDOC
+ This is a 32 bit reloc for the FR30 that stores 20 bits split up into
+ two sections.
+ENUM
+ BFD_RELOC_FR30_6_IN_4
+ENUMDOC
+ This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
+ 4 bits.
+ENUM
+ BFD_RELOC_FR30_8_IN_8
+ENUMDOC
+ This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
+ into 8 bits.
+ENUM
+ BFD_RELOC_FR30_9_IN_8
+ENUMDOC
+ This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
+ into 8 bits.
+ENUM
+ BFD_RELOC_FR30_10_IN_8
+ENUMDOC
+ This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
+ into 8 bits.
+ENUM
+ BFD_RELOC_FR30_9_PCREL
+ENUMDOC
+ This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
+ short offset into 8 bits.
+ENUM
+ BFD_RELOC_FR30_12_PCREL
+ENUMDOC
+ This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
+ short offset into 11 bits.
+
+ENUM
+ BFD_RELOC_MCORE_PCREL_IMM8BY4
+ENUMX
+ BFD_RELOC_MCORE_PCREL_IMM11BY2
+ENUMX
+ BFD_RELOC_MCORE_PCREL_IMM4BY2
+ENUMX
+ BFD_RELOC_MCORE_PCREL_32
+ENUMX
+ BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2
+ENUMDOC
+ Motorola Mcore relocations.
+
+ENUM
+ BFD_RELOC_VTABLE_INHERIT
+ENUMX
+ BFD_RELOC_VTABLE_ENTRY
+ENUMDOC
+ These two relocations are used by the linker to determine which of
+ the entries in a C++ virtual function table are actually used. When
+ the --gc-sections option is given, the linker will zero out the entries
+ that are not used, so that the code for those functions need not be
+ included in the output.
+
+ VTABLE_INHERIT is a zero-space relocation used to describe to the
+ linker the inheritence tree of a C++ virtual function table. The
+ relocation's symbol should be the parent class' vtable, and the
+ relocation should be located at the child vtable.
+
+ VTABLE_ENTRY is a zero-space relocation that describes the use of a
+ virtual function table entry. The reloc's symbol should refer to the
+ table of the class mentioned in the code. Off of that base, an offset
+ describes the entry that is being used. For Rela hosts, this offset
+ is stored in the reloc's addend. For Rel hosts, we are forced to put
+ this offset in the reloc's section offset.
+
+ENDSENUM
+ BFD_RELOC_UNUSED
+CODE_FRAGMENT
+.
+.typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
+*/
+
+
+/*
+FUNCTION
+ bfd_reloc_type_lookup
+
+SYNOPSIS
+ reloc_howto_type *
+ bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
+
+DESCRIPTION
+ Return a pointer to a howto structure which, when
+ invoked, will perform the relocation @var{code} on data from the
+ architecture noted.
+
+*/
+
+
+reloc_howto_type *
+bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ return BFD_SEND (abfd, reloc_type_lookup, (abfd, code));
+}
+
+static reloc_howto_type bfd_howto_32 =
+HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield, 0, "VRT32", false, 0xffffffff, 0xffffffff, true);
+
+
+/*
+INTERNAL_FUNCTION
+ bfd_default_reloc_type_lookup
+
+SYNOPSIS
+ reloc_howto_type *bfd_default_reloc_type_lookup
+ (bfd *abfd, bfd_reloc_code_real_type code);
+
+DESCRIPTION
+ Provides a default relocation lookup routine for any architecture.
+
+
+*/
+
+reloc_howto_type *
+bfd_default_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_CTOR:
+ /* The type of reloc used in a ctor, which will be as wide as the
+ address - so either a 64, 32, or 16 bitter. */
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 64:
+ BFD_FAIL ();
+ case 32:
+ return &bfd_howto_32;
+ case 16:
+ BFD_FAIL ();
+ default:
+ BFD_FAIL ();
+ }
+ default:
+ BFD_FAIL ();
+ }
+ return (reloc_howto_type *) NULL;
+}
+
+/*
+FUNCTION
+ bfd_get_reloc_code_name
+
+SYNOPSIS
+ const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
+
+DESCRIPTION
+ Provides a printable name for the supplied relocation code.
+ Useful mainly for printing error messages.
+*/
+
+const char *
+bfd_get_reloc_code_name (code)
+ bfd_reloc_code_real_type code;
+{
+ if (code > BFD_RELOC_UNUSED)
+ return 0;
+ return bfd_reloc_code_real_names[(int)code];
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_generic_relax_section
+
+SYNOPSIS
+ boolean bfd_generic_relax_section
+ (bfd *abfd,
+ asection *section,
+ struct bfd_link_info *,
+ boolean *);
+
+DESCRIPTION
+ Provides default handling for relaxing for back ends which
+ don't do relaxing -- i.e., does nothing.
+*/
+
+/*ARGSUSED*/
+boolean
+bfd_generic_relax_section (abfd, section, link_info, again)
+ bfd *abfd;
+ asection *section;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ *again = false;
+ return true;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_generic_gc_sections
+
+SYNOPSIS
+ boolean bfd_generic_gc_sections
+ (bfd *, struct bfd_link_info *);
+
+DESCRIPTION
+ Provides default handling for relaxing for back ends which
+ don't do section gc -- i.e., does nothing.
+*/
+
+/*ARGSUSED*/
+boolean
+bfd_generic_gc_sections (abfd, link_info)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+{
+ return true;
+}
+
+/*
+INTERNAL_FUNCTION
+ bfd_generic_get_relocated_section_contents
+
+SYNOPSIS
+ bfd_byte *
+ bfd_generic_get_relocated_section_contents (bfd *abfd,
+ struct bfd_link_info *link_info,
+ struct bfd_link_order *link_order,
+ bfd_byte *data,
+ boolean relocateable,
+ asymbol **symbols);
+
+DESCRIPTION
+ Provides default handling of relocation effort for back ends
+ which can't be bothered to do it efficiently.
+
+*/
+
+bfd_byte *
+bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data,
+ relocateable, symbols)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ /* Get enough memory to hold the stuff */
+ bfd *input_bfd = link_order->u.indirect.section->owner;
+ asection *input_section = link_order->u.indirect.section;
+
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
+ arelent **reloc_vector = NULL;
+ long reloc_count;
+
+ if (reloc_size < 0)
+ goto error_return;
+
+ reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size);
+ if (reloc_vector == NULL && reloc_size != 0)
+ goto error_return;
+
+ /* read in the section */
+ if (!bfd_get_section_contents (input_bfd,
+ input_section,
+ (PTR) data,
+ 0,
+ input_section->_raw_size))
+ goto error_return;
+
+ /* We're not relaxing the section, so just copy the size info */
+ input_section->_cooked_size = input_section->_raw_size;
+ input_section->reloc_done = true;
+
+ reloc_count = bfd_canonicalize_reloc (input_bfd,
+ input_section,
+ reloc_vector,
+ symbols);
+ if (reloc_count < 0)
+ goto error_return;
+
+ if (reloc_count > 0)
+ {
+ arelent **parent;
+ for (parent = reloc_vector; *parent != (arelent *) NULL;
+ parent++)
+ {
+ char *error_message = (char *) NULL;
+ bfd_reloc_status_type r =
+ bfd_perform_relocation (input_bfd,
+ *parent,
+ (PTR) data,
+ input_section,
+ relocateable ? abfd : (bfd *) NULL,
+ &error_message);
+
+ if (relocateable)
+ {
+ asection *os = input_section->output_section;
+
+ /* A partial link, so keep the relocs */
+ os->orelocation[os->reloc_count] = *parent;
+ os->reloc_count++;
+ }
+
+ if (r != bfd_reloc_ok)
+ {
+ switch (r)
+ {
+ case bfd_reloc_undefined:
+ if (!((*link_info->callbacks->undefined_symbol)
+ (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
+ input_bfd, input_section, (*parent)->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_dangerous:
+ BFD_ASSERT (error_message != (char *) NULL);
+ if (!((*link_info->callbacks->reloc_dangerous)
+ (link_info, error_message, input_bfd, input_section,
+ (*parent)->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_overflow:
+ if (!((*link_info->callbacks->reloc_overflow)
+ (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
+ (*parent)->howto->name, (*parent)->addend,
+ input_bfd, input_section, (*parent)->address)))
+ goto error_return;
+ break;
+ case bfd_reloc_outofrange:
+ default:
+ abort ();
+ break;
+ }
+
+ }
+ }
+ }
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return data;
+
+error_return:
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return NULL;
+}
diff --git a/bfd/reloc16.c b/bfd/reloc16.c
new file mode 100644
index 00000000000..7e7952ed506
--- /dev/null
+++ b/bfd/reloc16.c
@@ -0,0 +1,334 @@
+/* 8 and 16 bit COFF relocation functions, for BFD.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+Most of this hacked by Steve Chamberlain,
+ sac@cygnus.com
+*/
+
+/* These routines are used by coff-h8300 and coff-z8k to do
+ relocation.
+
+ FIXME: This code should be rewritten to support the new COFF
+ linker. Basically, they need to deal with COFF relocs rather than
+ BFD generic relocs. They should store the relocs in some location
+ where coff_link_input_bfd can find them (and coff_link_input_bfd
+ should be changed to use this location rather than rereading the
+ file) (unless info->keep_memory is false, in which case they should
+ free up the relocs after dealing with them). */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "genlink.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+bfd_vma
+bfd_coff_reloc16_get_value (reloc, link_info, input_section)
+ arelent *reloc;
+ struct bfd_link_info *link_info;
+ asection *input_section;
+{
+ bfd_vma value;
+ asymbol *symbol = *(reloc->sym_ptr_ptr);
+ /* A symbol holds a pointer to a section, and an offset from the
+ base of the section. To relocate, we find where the section will
+ live in the output and add that in */
+
+ if (bfd_is_und_section (symbol->section)
+ || bfd_is_com_section (symbol->section))
+ {
+ struct bfd_link_hash_entry *h;
+
+ /* The symbol is undefined in this BFD. Look it up in the
+ global linker hash table. FIXME: This should be changed when
+ we convert this stuff to use a specific final_link function
+ and change the interface to bfd_relax_section to not require
+ the generic symbols. */
+ h = bfd_wrapped_link_hash_lookup (input_section->owner, link_info,
+ bfd_asymbol_name (symbol),
+ false, false, true);
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak))
+ value = (h->u.def.value
+ + h->u.def.section->output_section->vma
+ + h->u.def.section->output_offset);
+ else if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_common)
+ value = h->u.c.size;
+ else
+ {
+ if (! ((*link_info->callbacks->undefined_symbol)
+ (link_info, bfd_asymbol_name (symbol),
+ input_section->owner, input_section, reloc->address)))
+ abort ();
+ value = 0;
+ }
+ }
+ else
+ {
+ value = symbol->value +
+ symbol->section->output_offset +
+ symbol->section->output_section->vma;
+ }
+
+ /* Add the value contained in the relocation */
+ value += reloc->addend;
+
+ return value;
+}
+
+void
+bfd_perform_slip(abfd, slip, input_section, value)
+ bfd *abfd;
+ unsigned int slip;
+ asection *input_section;
+ bfd_vma value;
+{
+ asymbol **s;
+
+ s = _bfd_generic_link_get_symbols (abfd);
+ BFD_ASSERT (s != (asymbol **) NULL);
+
+ /* Find all symbols past this point, and make them know
+ what's happened */
+ while (*s)
+ {
+ asymbol *p = *s;
+ if (p->section == input_section)
+ {
+ /* This was pointing into this section, so mangle it */
+ if (p->value > value)
+ {
+ p->value -= slip;
+ if (p->udata.p != NULL)
+ {
+ struct generic_link_hash_entry *h;
+
+ h = (struct generic_link_hash_entry *) p->udata.p;
+ BFD_ASSERT (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak);
+ h->root.u.def.value -= slip;
+ BFD_ASSERT (h->root.u.def.value == p->value);
+ }
+ }
+ }
+ s++;
+ }
+}
+
+boolean
+bfd_coff_reloc16_relax_section (abfd, i, link_info, again)
+ bfd *abfd;
+ asection *i;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+ /* Get enough memory to hold the stuff */
+ bfd *input_bfd = i->owner;
+ asection *input_section = i;
+ int *shrinks;
+ int shrink = 0;
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
+ arelent **reloc_vector = NULL;
+ long reloc_count;
+
+ /* We only do global relaxation once. It is not safe to do it multiple
+ times (see discussion of the "shrinks" array below). */
+ *again = false;
+
+ if (reloc_size < 0)
+ return false;
+
+ reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ if (!reloc_vector && reloc_size > 0)
+ return false;
+
+ /* Get the relocs and think about them */
+ reloc_count =
+ bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector,
+ _bfd_generic_link_get_symbols (input_bfd));
+ if (reloc_count < 0)
+ {
+ free (reloc_vector);
+ return false;
+ }
+
+ /* The reloc16.c and related relaxing code is very simple, the price
+ for that simplicity is we can only call this function once for
+ each section.
+
+ So, to get the best results within that limitation, we do multiple
+ relaxing passes over each section here. That involves keeping track
+ of the "shrink" at each reloc in the section. This allows us to
+ accurately determine the relative location of two relocs within
+ this section.
+
+ In theory, if we kept the "shrinks" array for each section for the
+ entire link, we could use the generic relaxing code in the linker
+ and get better results, particularly for jsr->bsr and 24->16 bit
+ memory reference relaxations. */
+
+ if (reloc_count > 0)
+ {
+ int another_pass = 0;
+
+ /* Allocate and initialize the shrinks array for this section. */
+ shrinks = (int *) bfd_malloc (reloc_count * sizeof (int));
+ memset (shrinks, 0, reloc_count * sizeof (int));
+
+ /* Loop until nothing changes in this section. */
+ do {
+ arelent **parent;
+ unsigned int i;
+ long j;
+
+ another_pass = 0;
+
+ for (i = 0, parent = reloc_vector; *parent; parent++, i++)
+ {
+ /* Let the target/machine dependent code examine each reloc
+ in this section and attempt to shrink it. */
+ shrink = bfd_coff_reloc16_estimate (abfd, input_section, *parent,
+ shrinks[i], link_info);
+
+ /* If it shrunk, note it in the shrinks array and set up for
+ another pass. */
+ if (shrink != shrinks[i])
+ {
+ another_pass = 1;
+ for (j = i + 1; j < reloc_count; j++)
+ shrinks[j] += shrink - shrinks[i];
+ }
+ }
+
+ } while (another_pass);
+
+ free((char *)shrinks);
+ }
+
+ input_section->_cooked_size -= shrink;
+ free((char *)reloc_vector);
+ return true;
+}
+
+bfd_byte *
+bfd_coff_reloc16_get_relocated_section_contents(in_abfd,
+ link_info,
+ link_order,
+ data,
+ relocateable,
+ symbols)
+ bfd *in_abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+ /* Get enough memory to hold the stuff */
+ bfd *input_bfd = link_order->u.indirect.section->owner;
+ asection *input_section = link_order->u.indirect.section;
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
+ arelent **reloc_vector;
+ long reloc_count;
+
+ if (reloc_size < 0)
+ return NULL;
+
+ /* If producing relocateable output, don't bother to relax. */
+ if (relocateable)
+ return bfd_generic_get_relocated_section_contents (in_abfd, link_info,
+ link_order,
+ data, relocateable,
+ symbols);
+
+ /* read in the section */
+ if (! bfd_get_section_contents(input_bfd,
+ input_section,
+ data,
+ 0,
+ input_section->_raw_size))
+ return NULL;
+
+
+ reloc_vector = (arelent **) bfd_malloc((size_t) reloc_size);
+ if (!reloc_vector && reloc_size != 0)
+ return NULL;
+
+ reloc_count = bfd_canonicalize_reloc (input_bfd,
+ input_section,
+ reloc_vector,
+ symbols);
+ if (reloc_count < 0)
+ {
+ free (reloc_vector);
+ return NULL;
+ }
+
+ if (reloc_count > 0)
+ {
+ arelent **parent = reloc_vector;
+ arelent *reloc ;
+ unsigned int dst_address = 0;
+ unsigned int src_address = 0;
+ unsigned int run;
+ unsigned int idx;
+
+ /* Find how long a run we can do */
+ while (dst_address < link_order->size)
+ {
+ reloc = *parent;
+ if (reloc)
+ {
+ /* Note that the relaxing didn't tie up the addresses in the
+ relocation, so we use the original address to work out the
+ run of non-relocated data */
+ run = reloc->address - src_address;
+ parent++;
+ }
+ else
+ {
+ run = link_order->size - dst_address;
+ }
+ /* Copy the bytes */
+ for (idx = 0; idx < run; idx++)
+ {
+ data[dst_address++] = data[src_address++];
+ }
+
+ /* Now do the relocation */
+
+ if (reloc)
+ {
+ bfd_coff_reloc16_extra_cases (input_bfd, link_info, link_order,
+ reloc, data, &src_address,
+ &dst_address);
+ }
+ }
+ }
+ free((char *)reloc_vector);
+ return data;
+}
+
diff --git a/bfd/riscix.c b/bfd/riscix.c
new file mode 100644
index 00000000000..f5ab49a692c
--- /dev/null
+++ b/bfd/riscix.c
@@ -0,0 +1,644 @@
+/* BFD back-end for RISC iX (Acorn, arm) binaries.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* RISC iX overloads the MAGIC field to indicate more than just the usual
+ [ZNO]MAGIC values. Also included are squeezing information and
+ shared library usage. */
+
+/* The following come from the man page. */
+#define SHLIBLEN 60
+
+#define MF_IMPURE 00200
+#define MF_SQUEEZED 01000
+#define MF_USES_SL 02000
+#define MF_IS_SL 04000
+
+/* Common combinations. */
+#define IMAGIC (MF_IMPURE|ZMAGIC) /* Demand load (impure text) */
+#define SPOMAGIC (MF_USES_SL|OMAGIC) /* OMAGIC with large header */
+ /* -- may contain a ref to a */
+ /* shared lib required by the */
+ /* object. */
+#define SLOMAGIC (MF_IS_SL|OMAGIC) /* A reference to a shared library */
+ /* The text portion of the object */
+ /* contains "overflow text" from */
+ /* the shared library to be linked */
+ /* in with an object */
+#define QMAGIC (MF_SQUEEZED|ZMAGIC) /* Sqeezed demand paged. */
+ /* NOTE: This interpretation of */
+ /* QMAGIC seems to be at variance */
+ /* With that used on other */
+ /* architectures. */
+#define SPZMAGIC (MF_USES_SL|ZMAGIC) /* program which uses sl */
+#define SPQMAGIC (MF_USES_SL|QMAGIC) /* sqeezed ditto */
+#define SLZMAGIC (MF_IS_SL|ZMAGIC) /* shared lib part of prog */
+#define SLPZMAGIC (MF_USES_SL|SLZMAGIC) /* sl which uses another */
+
+#define N_SHARED_LIB(x) ((x).a_info & MF_USES_SL)
+
+/* Only a pure OMAGIC file has the minimal header */
+#define N_TXTOFF(x) \
+ ((x).a_info == OMAGIC ? 32 \
+ : (N_MAGIC(x) == ZMAGIC) ? TARGET_PAGE_SIZE \
+ : 999)
+
+#define N_TXTADDR(x) \
+ (N_MAGIC(x) != ZMAGIC ? 0 /* object file or NMAGIC */ \
+ /* Programs with shared libs are loaded at the first page after all the \
+ text segments of the shared library programs. Without looking this \
+ up we can't know exactly what the address will be. A reasonable guess \
+ is that a_entry will be in the first page of the executable. */ \
+ : N_SHARED_LIB(x) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) \
+ : TEXT_START_ADDR)
+
+#define N_SYMOFF(x) \
+ (N_TXTOFF (x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
+
+#define N_STROFF(x) (N_SYMOFF (x) + (x).a_syms)
+
+#define TEXT_START_ADDR 32768
+#define TARGET_PAGE_SIZE 32768
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_arm
+
+#define MY(OP) CAT(riscix_,OP)
+#define TARGETNAME "a.out-riscix"
+#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
+ (((x).a_info & ~006000) != OMAGIC) && \
+ ((x).a_info != NMAGIC))
+#define N_MAGIC(x) ((x).a_info & ~07200)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define WRITE_HEADERS(abfd, execp) \
+ { \
+ bfd_size_type text_size; /* dummy vars */ \
+ file_ptr text_end; \
+ if (adata(abfd).magic == undecided_magic) \
+ NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
+ \
+ execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
+ execp->a_entry = bfd_get_start_address (abfd); \
+ \
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
+ \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
+ if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
+ != EXEC_BYTES_SIZE) \
+ return false; \
+ /* Now write out reloc info, followed by syms and strings */ \
+ \
+ if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
+ && bfd_get_symcount (abfd) != 0) \
+ { \
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (! NAME(aout,write_syms)(abfd)) return false; \
+ \
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \
+ return false; \
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ return false; \
+ } \
+ }
+
+#include "libaout.h"
+#include "aout/aout64.h"
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static reloc_howto_type riscix_std_reloc_howto[] = {
+ /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
+ HOWTO( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),
+ HOWTO( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),
+ HOWTO( 3, 2, 3, 26, true, 0, complain_overflow_signed, riscix_fix_pcrel_26 , "ARM26", true, 0x00ffffff,0x00ffffff, false),
+ HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, true),
+ HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, true),
+ HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, true),
+ HOWTO( 7, 2, 3, 26, false, 0, complain_overflow_signed, riscix_fix_pcrel_26_done, "ARM26D",true,0x00ffffff,0x00ffffff, false),
+ {-1},
+ HOWTO( 9, 0, -1, 16, false, 0, complain_overflow_bitfield,0,"NEG16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO( 10, 0, -2, 32, false, 0, complain_overflow_bitfield,0,"NEG32", true, 0xffffffff,0xffffffff, false)
+};
+
+#define RISCIX_TABLE_SIZE \
+ (sizeof (riscix_std_reloc_howto) / sizeof (reloc_howto_type))
+
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* This is dead simple at present. */
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_size_type addr = reloc_entry->address;
+ long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+
+ /* If this is an undefined symbol, return error */
+ if (symbol->section == &bfd_und_section
+ && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
+
+ /* If the sections are different, and we are doing a partial relocation,
+ just ignore it for now. */
+ if (symbol->section->name != input_section->name
+ && output_bfd != (bfd *)NULL)
+ return bfd_reloc_continue;
+
+ relocation = (target & 0x00ffffff) << 2;
+ relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
+ relocation += symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+ relocation -= input_section->output_section->vma;
+ relocation -= input_section->output_offset;
+ relocation -= addr;
+ if (relocation & 3)
+ return bfd_reloc_overflow;
+
+ /* Check for overflow */
+ if (relocation & 0x02000000)
+ {
+ if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
+ flag = bfd_reloc_overflow;
+ }
+ else if (relocation & ~0x03ffffff)
+ flag = bfd_reloc_overflow;
+
+ target &= ~0x00ffffff;
+ target |= (relocation >> 2) & 0x00ffffff;
+ bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+
+ /* Now the ARM magic... Change the reloc type so that it is marked as done.
+ Strictly this is only necessary if we are doing a partial relocation. */
+ reloc_entry->howto = &riscix_std_reloc_howto[7];
+
+ return flag;
+}
+
+reloc_howto_type *
+DEFUN(riscix_reloc_type_lookup,(abfd,code),
+ bfd *abfd AND
+ bfd_reloc_code_real_type code)
+{
+#define ASTD(i,j) case i: return &riscix_std_reloc_howto[j]
+ if (code == BFD_RELOC_CTOR)
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ default: return (reloc_howto_type *) NULL;
+ }
+
+ switch (code)
+ {
+ ASTD (BFD_RELOC_16, 1);
+ ASTD (BFD_RELOC_32, 2);
+ ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
+ ASTD (BFD_RELOC_8_PCREL, 4);
+ ASTD (BFD_RELOC_16_PCREL, 5);
+ ASTD (BFD_RELOC_32_PCREL, 6);
+ default: return (reloc_howto_type *) NULL;
+ }
+}
+
+#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define MY_final_link_callback should_not_be_used
+#define MY_bfd_final_link _bfd_generic_final_link
+
+#define MY_bfd_reloc_type_lookup riscix_reloc_type_lookup
+#define MY_canonicalize_reloc riscix_canonicalize_reloc
+#define MY_object_p riscix_object_p
+
+static const bfd_target *riscix_callback PARAMS ((bfd *));
+
+void
+riscix_swap_std_reloc_out (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
+{
+ int r_index;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ int r_extern;
+ int r_length;
+ int r_pcrel;
+ int r_neg = 0; /* Negative relocs use the BASEREL bit. */
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD(abfd, g->address, natptr->r_address);
+
+ r_length = g->howto->size ; /* Size as a power of two */
+ if (r_length < 0)
+ {
+ r_length = -r_length;
+ r_neg = 1;
+ }
+
+ r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
+
+ /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
+ relocation has been done already (Only for the 26-bit one I think)???!!!
+ */
+
+ if (r_length == 3)
+ r_pcrel = r_pcrel ? 0 : 1;
+
+
+#if 0
+ /* For a standard reloc, the addend is in the object file. */
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+#endif
+
+ /* name was clobbered by aout_write_syms to be symbol index */
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here
+ */
+
+ if (bfd_is_com_section (output_section)
+ || output_section == &bfd_abs_section
+ || output_section == &bfd_und_section)
+ {
+ if (bfd_abs_section.symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+ r_extern = 1;
+ r_index = (*g->sym_ptr_ptr)->udata.i;
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ /* now the fun stuff */
+ if (bfd_header_big_endian (abfd))
+ {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ ( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
+ | (r_neg ? RELOC_STD_BITS_BASEREL_BIG: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
+ }
+ else
+ {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ ( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
+ | (r_neg ? RELOC_STD_BITS_BASEREL_LITTLE: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
+ }
+}
+
+boolean
+riscix_squirt_out_relocs (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ arelent **generic;
+ unsigned char *native, *natptr;
+ size_t each_size;
+
+ unsigned int count = section->reloc_count;
+ size_t natsize;
+
+ if (count == 0) return true;
+
+ each_size = obj_reloc_entry_size (abfd);
+ natsize = each_size * count;
+ native = (unsigned char *) bfd_zalloc (abfd, natsize);
+ if (!native)
+ return false;
+
+ generic = section->orelocation;
+
+ for (natptr = native;
+ count != 0;
+ --count, natptr += each_size, ++generic)
+ riscix_swap_std_reloc_out (abfd, *generic,
+ (struct reloc_std_external *) natptr);
+
+ if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ {
+ bfd_release(abfd, native);
+ return false;
+ }
+
+ bfd_release (abfd, native);
+ return true;
+}
+
+
+/*
+ * This is just like the standard aoutx.h version but we need to do our
+ * own mapping of external reloc type values to howto entries.
+ */
+long
+MY(canonicalize_reloc)(abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count, c;
+ extern reloc_howto_type NAME(aout,std_howto_table)[];
+
+ /* If we have already read in the relocation table, return the values. */
+ if (section->flags & SEC_CONSTRUCTOR) {
+ arelent_chain *chain = section->constructor_chain;
+
+ for (count = 0; count < section->reloc_count; count++) {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+ }
+ if (tblptr && section->reloc_count) {
+ for (count = 0; count++ < section->reloc_count;)
+ *relptr++ = tblptr++;
+ *relptr = 0;
+ return section->reloc_count;
+ }
+
+ if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
+ return -1;
+ tblptr = section->relocation;
+
+ /* fix up howto entries */
+ for (count = 0; count++ < section->reloc_count;)
+ {
+ c = tblptr->howto - NAME(aout,std_howto_table);
+ BFD_ASSERT (c < RISCIX_TABLE_SIZE);
+ tblptr->howto = &riscix_std_reloc_howto[c];
+
+ *relptr++ = tblptr++;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+}
+
+/* This is the same as NAME(aout,some_aout_object_p), but has different
+ expansions of the macro definitions. */
+
+const bfd_target *
+riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
+ bfd *abfd;
+ struct internal_exec *execp;
+ const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
+{
+ struct aout_data_struct *rawptr, *oldrawptr;
+ const bfd_target *result;
+
+ rawptr = ((struct aout_data_struct *)
+ bfd_zalloc (abfd, sizeof (struct aout_data_struct )));
+
+ if (rawptr == NULL)
+ return 0;
+
+ oldrawptr = abfd->tdata.aout_data;
+ abfd->tdata.aout_data = rawptr;
+
+ /* Copy the contents of the old tdata struct.
+ In particular, we want the subformat, since for hpux it was set in
+ hp300hpux.c:swap_exec_header_in and will be used in
+ hp300hpux.c:callback. */
+ if (oldrawptr != NULL)
+ *abfd->tdata.aout_data = *oldrawptr;
+
+ abfd->tdata.aout_data->a.hdr = &rawptr->e;
+ *(abfd->tdata.aout_data->a.hdr) = *execp; /* Copy in the internal_exec
+ struct */
+ execp = abfd->tdata.aout_data->a.hdr;
+
+ /* Set the file flags */
+ abfd->flags = BFD_NO_FLAGS;
+ if (execp->a_drsize || execp->a_trsize)
+ abfd->flags |= HAS_RELOC;
+ /* Setting of EXEC_P has been deferred to the bottom of this function */
+ if (execp->a_syms)
+ abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+ if (N_DYNAMIC(*execp))
+ abfd->flags |= DYNAMIC;
+
+
+ if ((execp->a_info & MF_SQUEEZED) != 0) /* Squeezed files aren't supported
+ (yet)! */
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ else if ((execp->a_info & MF_IS_SL) != 0) /* Nor are shared libraries */
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ else if (N_MAGIC (*execp) == ZMAGIC)
+ {
+ abfd->flags |= D_PAGED | WP_TEXT;
+ adata (abfd).magic = z_magic;
+ }
+ else if (N_MAGIC (*execp) == NMAGIC)
+ {
+ abfd->flags |= WP_TEXT;
+ adata (abfd).magic = n_magic;
+ }
+ else if (N_MAGIC (*execp) == OMAGIC)
+ adata (abfd).magic = o_magic;
+ else
+ {
+ /* Should have been checked with N_BADMAG before this routine
+ was called. */
+ abort ();
+ }
+
+ bfd_get_start_address (abfd) = execp->a_entry;
+
+ obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
+ bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
+
+ /* The default relocation entry size is that of traditional V7 Unix. */
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ /* The default symbol entry size is that of traditional Unix. */
+ obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
+
+ obj_aout_external_syms (abfd) = NULL;
+ obj_aout_external_strings (abfd) = NULL;
+ obj_aout_sym_hashes (abfd) = NULL;
+
+ if (! NAME(aout,make_sections) (abfd))
+ return NULL;
+
+ obj_datasec (abfd)->_raw_size = execp->a_data;
+ obj_bsssec (abfd)->_raw_size = execp->a_bss;
+
+ obj_textsec (abfd)->flags =
+ (execp->a_trsize != 0
+ ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)
+ : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));
+ obj_datasec (abfd)->flags =
+ (execp->a_drsize != 0
+ ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)
+ : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
+ obj_bsssec (abfd)->flags = SEC_ALLOC;
+
+ result = (*callback_to_real_object_p)(abfd);
+
+#if defined(MACH) || defined(STAT_FOR_EXEC)
+ /* The original heuristic doesn't work in some important cases. The
+ * a.out file has no information about the text start address. For
+ * files (like kernels) linked to non-standard addresses (ld -Ttext
+ * nnn) the entry point may not be between the default text start
+ * (obj_textsec(abfd)->vma) and (obj_textsec(abfd)->vma) + text size
+ * This is not just a mach issue. Many kernels are loaded at non
+ * standard addresses.
+ */
+ {
+ struct stat stat_buf;
+ if (abfd->iostream != NULL
+ && (abfd->flags & BFD_IN_MEMORY) == 0
+ && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)
+ && ((stat_buf.st_mode & 0111) != 0))
+ abfd->flags |= EXEC_P;
+ }
+#else /* ! MACH */
+ /* Now that the segment addresses have been worked out, take a better
+ guess at whether the file is executable. If the entry point
+ is within the text segment, assume it is. (This makes files
+ executable even if their entry point address is 0, as long as
+ their text starts at zero.)
+
+ At some point we should probably break down and stat the file and
+ declare it executable if (one of) its 'x' bits are on... */
+ if ((execp->a_entry >= obj_textsec(abfd)->vma) &&
+ (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
+ abfd->flags |= EXEC_P;
+#endif /* MACH */
+ if (result)
+ {
+ }
+ else
+ {
+ free (rawptr);
+ abfd->tdata.aout_data = oldrawptr;
+ }
+ return result;
+}
+
+
+static const bfd_target *
+MY(object_p) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes; /* Raw exec header from file */
+ struct internal_exec exec; /* Cleaned-up exec header */
+ const bfd_target *target;
+
+ if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+
+ if (N_BADMAG (exec)) return 0;
+#ifdef MACHTYPE_OK
+ if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
+#endif
+
+ NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+
+ target = riscix_some_aout_object_p (abfd, &exec, MY(callback));
+
+ return target;
+}
+
+
+#include "aout-target.h"
diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c
new file mode 100644
index 00000000000..b20555f5d38
--- /dev/null
+++ b/bfd/rs6000-core.c
@@ -0,0 +1,507 @@
+/* IBM RS/6000 "XCOFF" back-end for BFD.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ FIXME: Can someone provide a transliteration of this name into ASCII?
+ Using the following chars caused a compiler warning on HIUX (so I replaced
+ them with octal escapes), and isn't useful without an understanding of what
+ character set it is.
+ Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
+ and John Gilmore.
+ Archive support from Damon A. Permezel.
+ Contributed by IBM Corporation and Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This port currently only handles reading object files, except when
+ compiled on an RS/6000 host. -- no archive support, no core files.
+ In all cases, it does not support writing.
+
+ FIXMEmgo comments are left from Metin Ozisik's original port.
+
+ This is in a separate file from coff-rs6000.c, because it includes
+ system include files that conflict with coff/rs6000.h.
+ */
+
+/* Internalcoff.h and coffcode.h modify themselves based on this flag. */
+#define RS6000COFF_C 1
+
+/* The AIX 4.1 kernel is obviously compiled with -D_LONG_LONG, so
+ we have to define _LONG_LONG for older versions of gcc to get the
+ proper alignments in the user structure. */
+#if defined(_AIX41) && !defined(_LONG_LONG)
+#define _LONG_LONG
+#endif
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#ifdef AIX_CORE
+
+/* AOUTHDR is defined by the above. We need another defn of it, from the
+ system include files. Punt the old one and get us a new name for the
+ typedef in the system include files. */
+#ifdef AOUTHDR
+#undef AOUTHDR
+#endif
+#define AOUTHDR second_AOUTHDR
+
+#undef SCNHDR
+
+
+/* ------------------------------------------------------------------------ */
+/* Support for core file stuff.. */
+/* ------------------------------------------------------------------------ */
+
+#include <sys/user.h>
+#include <sys/ldr.h>
+#include <sys/core.h>
+
+
+/* Number of special purpose registers supported by gdb. This value
+ should match `tm.h' in gdb directory. Clean this mess up and use
+ the macros in sys/reg.h. FIXMEmgo. */
+
+#define NUM_OF_SPEC_REGS 7
+
+#define core_hdr(bfd) (((Rs6kCorData*)(bfd->tdata.any))->hdr)
+
+/* AIX 4.1 Changed the names and locations of a few items in the core file,
+ this seems to be the quickest easiet way to deal with it.
+
+ Note however that encoding magic addresses (STACK_END_ADDR) is going
+ to be _very_ fragile. But I don't see any easy way to get that info
+ right now. */
+#ifdef CORE_VERSION_1
+#define CORE_DATA_SIZE_FIELD c_u.U_dsize
+#define CORE_COMM_FIELD c_u.U_comm
+#define SAVE_FIELD c_mst
+#define STACK_END_ADDR 0x2ff23000
+#else
+#define CORE_DATA_SIZE_FIELD c_u.u_dsize
+#define CORE_COMM_FIELD c_u.u_comm
+#define SAVE_FIELD c_u.u_save
+#define STACK_END_ADDR 0x2ff80000
+#endif
+
+/* These are stored in the bfd's tdata */
+typedef struct {
+ struct core_dump hdr; /* core file header */
+} Rs6kCorData;
+
+static asection *make_bfd_asection PARAMS ((bfd *, CONST char *, flagword,
+ bfd_size_type, bfd_vma, file_ptr));
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
+ bfd *abfd;
+ CONST char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ bfd_vma vma;
+ file_ptr filepos;
+{
+ asection *asect;
+
+ asect = bfd_make_section_anyway (abfd, name);
+ if (!asect)
+ return NULL;
+
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->vma = vma;
+ asect->filepos = filepos;
+ asect->alignment_power = 8;
+
+ return asect;
+}
+
+/* Decide if a given bfd represents a `core' file or not. There really is no
+ magic number or anything like, in rs6000coff. */
+
+const bfd_target *
+rs6000coff_core_p (abfd)
+ bfd *abfd;
+{
+ struct core_dump coredata;
+ struct stat statbuf;
+ bfd_size_type nread;
+ char *tmpptr;
+
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ return NULL;
+
+ nread = bfd_read (&coredata, 1, sizeof (struct core_dump), abfd);
+ if (nread != sizeof (struct core_dump))
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (bfd_stat (abfd, &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+
+ /* If the core file ulimit is too small, the system will first
+ omit the data segment, then omit the stack, then decline to
+ dump core altogether (as far as I know UBLOCK_VALID and LE_VALID
+ are always set) (this is based on experimentation on AIX 3.2).
+ Now, the thing is that GDB users will be surprised
+ if segments just silently don't appear (well, maybe they would
+ think to check "info files", I don't know).
+
+ For the data segment, we have no choice but to keep going if it's
+ not there, since the default behavior is not to dump it (regardless
+ of the ulimit, it's based on SA_FULLDUMP). But for the stack segment,
+ if it's not there, we refuse to have anything to do with this core
+ file. The usefulness of a core dump without a stack segment is pretty
+ limited anyway. */
+
+ if (!(coredata.c_flag & UBLOCK_VALID)
+ || !(coredata.c_flag & LE_VALID))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (!(coredata.c_flag & USTACK_VALID))
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return NULL;
+ }
+
+ /* Don't check the core file size for a full core, AIX 4.1 includes
+ additional shared library sections in a full core. */
+ if (!(coredata.c_flag & (FULL_CORE | CORE_TRUNC))
+ && ((bfd_vma)coredata.c_stack + coredata.c_size) != statbuf.st_size)
+ {
+ /* If the size is wrong, it means we're misinterpreting something. */
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Sanity check on the c_tab field. */
+ if ((u_long) coredata.c_tab < sizeof coredata ||
+ (u_long) coredata.c_tab >= statbuf.st_size ||
+ (long) coredata.c_tab >= (long)coredata.c_stack)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Issue warning if the core file was truncated during writing. */
+ if (coredata.c_flag & CORE_TRUNC)
+ (*_bfd_error_handler) (_("%s: warning core file truncated"),
+ bfd_get_filename (abfd));
+
+ /* Allocate core file header. */
+ tmpptr = (char*) bfd_zalloc (abfd, sizeof (Rs6kCorData));
+ if (!tmpptr)
+ return NULL;
+
+ set_tdata (abfd, tmpptr);
+
+ /* Copy core file header. */
+ core_hdr (abfd) = coredata;
+
+ /* .stack section. */
+ if (!make_bfd_asection (abfd, ".stack",
+ SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
+ (bfd_size_type) coredata.c_size,
+ (bfd_vma) (STACK_END_ADDR - coredata.c_size),
+ (file_ptr) coredata.c_stack))
+ return NULL;
+
+ /* .reg section for GPRs and special registers. */
+ if (!make_bfd_asection (abfd, ".reg",
+ SEC_HAS_CONTENTS,
+ (bfd_size_type) ((32 + NUM_OF_SPEC_REGS) * 4),
+ (bfd_vma) 0,
+ (file_ptr) ((char *) &coredata.SAVE_FIELD
+ - (char *) &coredata)))
+ return NULL;
+
+ /* .reg2 section for FPRs (floating point registers). */
+ if (!make_bfd_asection (abfd, ".reg2",
+ SEC_HAS_CONTENTS,
+ (bfd_size_type) 8 * 32, /* 32 FPRs. */
+ (bfd_vma) 0,
+ (file_ptr) ((char *) &coredata.SAVE_FIELD.fpr[0]
+ - (char *) &coredata)))
+ return NULL;
+
+ /* .ldinfo section.
+ To actually find out how long this section is in this particular
+ core dump would require going down the whole list of struct ld_info's.
+ See if we can just fake it. */
+ if (!make_bfd_asection (abfd, ".ldinfo",
+ SEC_HAS_CONTENTS,
+ (bfd_size_type) 0x7fffffff,
+ (bfd_vma) 0,
+ (file_ptr) coredata.c_tab))
+ return NULL;
+
+#ifndef CORE_VERSION_1
+ /* .data section if present.
+ AIX 3 dumps the complete data section and sets FULL_CORE if the
+ ulimit is large enough, otherwise the data section is omitted.
+ AIX 4 sets FULL_CORE even if the core file is truncated, we have
+ to examine coredata.c_datasize below to find out the actual size of
+ the .data section. */
+ if (coredata.c_flag & FULL_CORE)
+ {
+ if (!make_bfd_asection (abfd, ".data",
+ SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
+ (bfd_size_type) coredata.CORE_DATA_SIZE_FIELD,
+ (bfd_vma)
+ CDATA_ADDR (coredata.CORE_DATA_SIZE_FIELD),
+ (file_ptr) coredata.c_stack + coredata.c_size))
+ return NULL;
+ }
+#endif
+
+#ifdef CORE_VERSION_1
+ /* AIX 4 adds data sections from loaded objects to the core file,
+ which can be found by examining ldinfo, and anonymously mmapped
+ regions. */
+ {
+ struct ld_info ldinfo;
+ bfd_size_type ldinfo_size;
+ file_ptr ldinfo_offset = (file_ptr) coredata.c_tab;
+
+ /* .data section from executable. */
+ if (coredata.c_datasize)
+ {
+ if (!make_bfd_asection (abfd, ".data",
+ SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
+ (bfd_size_type) coredata.c_datasize,
+ (bfd_vma)
+ CDATA_ADDR (coredata.CORE_DATA_SIZE_FIELD),
+ (file_ptr) coredata.c_data))
+ return NULL;
+ }
+
+ /* .data sections from loaded objects. */
+ ldinfo_size = (char *) &ldinfo.ldinfo_filename[0]
+ - (char *) &ldinfo.ldinfo_next;
+ while (1)
+ {
+ if (bfd_seek (abfd, ldinfo_offset, SEEK_SET) != 0)
+ return NULL;
+ if (bfd_read (&ldinfo, ldinfo_size, 1, abfd) != ldinfo_size)
+ return NULL;
+ if (ldinfo.ldinfo_core)
+ {
+ if (!make_bfd_asection (abfd, ".data",
+ SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
+ (bfd_size_type) ldinfo.ldinfo_datasize,
+ (bfd_vma) ldinfo.ldinfo_dataorg,
+ (file_ptr) ldinfo.ldinfo_core))
+ return NULL;
+ }
+ if (ldinfo.ldinfo_next == 0)
+ break;
+ ldinfo_offset += ldinfo.ldinfo_next;
+ }
+
+ /* .vmdata sections from anonymously mmapped regions. */
+ if (coredata.c_vmregions)
+ {
+ int i;
+
+ if (bfd_seek (abfd, (file_ptr) coredata.c_vmm, SEEK_SET) != 0)
+ return NULL;
+
+ for (i = 0; i < coredata.c_vmregions; i++)
+ {
+ struct vm_info vminfo;
+
+ if (bfd_read (&vminfo, sizeof (vminfo), 1, abfd) != sizeof (vminfo))
+ return NULL;
+ if (vminfo.vminfo_offset)
+ {
+ if (!make_bfd_asection (abfd, ".vmdata",
+ SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
+ (bfd_size_type) vminfo.vminfo_size,
+ (bfd_vma) vminfo.vminfo_addr,
+ (file_ptr) vminfo.vminfo_offset))
+ return NULL;
+ }
+ }
+ }
+ }
+#endif
+
+ return abfd->xvec; /* this is garbage for now. */
+}
+
+
+
+/* return `true' if given core is from the given executable.. */
+boolean
+rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd;
+ bfd *exec_bfd;
+{
+ struct core_dump coredata;
+ struct ld_info ldinfo;
+ bfd_size_type size;
+ char *path, *s;
+ size_t alloc;
+ const char *str1, *str2;
+ boolean ret;
+
+ if (bfd_seek (core_bfd, 0, SEEK_SET) != 0
+ || bfd_read (&coredata, sizeof coredata, 1, core_bfd) != sizeof coredata)
+ return false;
+
+ if (bfd_seek (core_bfd, (long) coredata.c_tab, SEEK_SET) != 0)
+ return false;
+
+ size = (char *) &ldinfo.ldinfo_filename[0] - (char *) &ldinfo.ldinfo_next;
+ if (bfd_read (&ldinfo, size, 1, core_bfd) != size)
+ return false;
+
+ alloc = 100;
+ path = bfd_malloc (alloc);
+ if (path == NULL)
+ return false;
+ s = path;
+
+ while (1)
+ {
+ if (bfd_read (s, 1, 1, core_bfd) != 1)
+ {
+ free (path);
+ return false;
+ }
+ if (*s == '\0')
+ break;
+ ++s;
+ if (s == path + alloc)
+ {
+ char *n;
+
+ alloc *= 2;
+ n = bfd_realloc (path, alloc);
+ if (n == NULL)
+ {
+ free (path);
+ return false;
+ }
+ s = n + (path - s);
+ path = n;
+ }
+ }
+
+ str1 = strrchr (path, '/');
+ str2 = strrchr (exec_bfd->filename, '/');
+
+ /* step over character '/' */
+ str1 = str1 != NULL ? str1 + 1 : path;
+ str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
+
+ if (strcmp (str1, str2) == 0)
+ ret = true;
+ else
+ ret = false;
+
+ free (path);
+
+ return ret;
+}
+
+char *
+rs6000coff_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ char *com = core_hdr (abfd).CORE_COMM_FIELD;
+ if (*com)
+ return com;
+ else
+ return 0;
+}
+
+int
+rs6000coff_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+ return core_hdr (abfd).c_signo;
+}
+
+
+boolean
+rs6000coff_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (count == 0)
+ return true;
+
+ /* Reading a core file's sections will be slightly different. For the
+ rest of them we can use bfd_generic_get_section_contents () I suppose. */
+ /* Make sure this routine works for any bfd and any section. FIXMEmgo. */
+
+ if (abfd->format == bfd_core && strcmp (section->name, ".reg") == 0) {
+
+ struct mstsave mstatus;
+ int regoffset = (char*)&mstatus.gpr[0] - (char*)&mstatus;
+
+ /* Assert that the only way this code will be executed is reading the
+ whole section. */
+ if (offset || count != (sizeof(mstatus.gpr) + (4 * NUM_OF_SPEC_REGS)))
+ (*_bfd_error_handler)
+ (_("ERROR! in rs6000coff_get_section_contents()\n"));
+
+ /* for `.reg' section, `filepos' is a pointer to the `mstsave' structure
+ in the core file. */
+
+ /* read GPR's into the location. */
+ if ( bfd_seek(abfd, section->filepos + regoffset, SEEK_SET) == -1
+ || bfd_read(location, sizeof (mstatus.gpr), 1, abfd) != sizeof (mstatus.gpr))
+ return (false); /* on error */
+
+ /* increment location to the beginning of special registers in the section,
+ reset register offset value to the beginning of first special register
+ in mstsave structure, and read special registers. */
+
+ location = (PTR) ((char*)location + sizeof (mstatus.gpr));
+ regoffset = (char*)&mstatus.iar - (char*)&mstatus;
+
+ if ( bfd_seek(abfd, section->filepos + regoffset, SEEK_SET) == -1
+ || bfd_read(location, 4 * NUM_OF_SPEC_REGS, 1, abfd) !=
+ 4 * NUM_OF_SPEC_REGS)
+ return (false); /* on error */
+
+ /* increment location address, and read the special registers.. */
+ /* FIXMEmgo */
+ return (true);
+ }
+
+ /* else, use default bfd section content transfer. */
+ else
+ return _bfd_generic_get_section_contents
+ (abfd, section, location, offset, count);
+}
+
+#endif /* AIX_CORE */
diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c
new file mode 100644
index 00000000000..f10c8f139f6
--- /dev/null
+++ b/bfd/sco5-core.c
@@ -0,0 +1,429 @@
+/* BFD back end for SCO5 core files (U-area and raw sections)
+ Copyright 1998 Free Software Foundation, Inc.
+ Written by Jouke Numan <jnuman@hiscom.nl>
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <signal.h>
+
+#include <sys/user.h> /* After a.out.h */
+#include <sys/paccess.h>
+#include <sys/region.h>
+
+struct sco5_core_struct
+{
+ struct user u;
+};
+
+/* forward declarations */
+
+static asection *
+make_bfd_asection PARAMS ((bfd *, const char *, flagword, bfd_size_type,
+ bfd_vma, file_ptr));
+static asymbol *sco5_core_make_empty_symbol PARAMS ((bfd *));
+static struct user *read_uarea PARAMS ((bfd *, int));
+const bfd_target *sco5_core_file_p PARAMS ((bfd *abfd));
+char *sco5_core_file_failing_command PARAMS ((bfd *abfd));
+int sco5_core_file_failing_signal PARAMS ((bfd *abfd));
+boolean sco5_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
+ bfd *exec_bfd));
+static void swap_abort PARAMS ((void));
+
+static asection *
+make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ bfd_size_type _raw_size;
+ bfd_vma vma;
+ file_ptr filepos;
+{
+ asection *asect;
+
+ asect = bfd_make_section_anyway (abfd, name);
+ if (!asect)
+ return NULL;
+ asect->flags = flags;
+ asect->_raw_size = _raw_size;
+ asect->vma = vma;
+ asect->filepos = filepos;
+ asect->alignment_power = 2;
+
+ return asect;
+}
+
+static asymbol *
+sco5_core_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+static struct user *
+read_uarea(abfd, filepos)
+ bfd *abfd;
+ int filepos;
+
+{
+ struct sco5_core_struct *rawptr;
+
+ rawptr = ((struct sco5_core_struct *)
+ bfd_zmalloc (sizeof (struct sco5_core_struct)));
+ if (rawptr == NULL)
+ return NULL;
+
+ abfd->tdata.sco5_core_data = rawptr;
+
+ if ((bfd_seek (abfd, filepos, SEEK_SET) != 0)
+ || (bfd_read ((void *)&rawptr->u, 1, sizeof rawptr->u, abfd)
+ != sizeof rawptr->u))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Sanity check perhaps??? */
+ if (rawptr->u.u_dsize > 0x1000000) /* Remember, it's in pages... */
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ if (rawptr->u.u_ssize > 0x1000000)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ return &rawptr->u;
+}
+
+/* ARGSUSED */
+const bfd_target *
+sco5_core_file_p (abfd)
+ bfd *abfd;
+{
+ int coffset_siz, val, nsecs, cheadoffs;
+ int coresize;
+ struct user *u;
+ struct coreoffsets coffsets;
+ struct coresecthead chead;
+ char *secname;
+ flagword flags;
+
+ /* Read coreoffsets region at end of core (see core(FP)) */
+
+ {
+ FILE *stream = bfd_cache_lookup (abfd);
+ struct stat statbuf;
+ if (stream == NULL)
+ return NULL;
+ if (fstat (fileno (stream), &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+ coresize = statbuf.st_size;
+ }
+ /* Last long in core is sizeof struct coreoffsets, read it */
+ if ((bfd_seek (abfd, coresize-sizeof coffset_siz, SEEK_SET) != 0)
+ || (bfd_read ((void *)&coffset_siz, 1, sizeof coffset_siz, abfd)
+ != sizeof coffset_siz) )
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* Use it to seek start of coreoffsets region, read it and determine
+ validity */
+ if ((bfd_seek (abfd, coresize-coffset_siz, SEEK_SET) != 0)
+ || (bfd_read ((void *)&coffsets, 1, sizeof coffsets, abfd)
+ != sizeof coffsets)
+ || ((coffsets.u_info != 1) && (coffsets.u_info != C_VERSION)))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+
+ if (coffsets.u_info == 1)
+ {
+ /* Old version, no section heads, read info from user struct */
+
+ u = read_uarea(abfd, coffsets.u_user);
+ if (! u)
+ return NULL;
+
+ if (!make_bfd_asection (abfd, ".reg", SEC_HAS_CONTENTS,
+ (bfd_size_type) coffsets.u_usize,
+ 0 - (bfd_vma) u->u_ar0,
+ (file_ptr) coffsets.u_user))
+ return NULL;
+
+ if (!make_bfd_asection (abfd, ".data",
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
+ ((bfd_size_type) u->u_exdata.ux_dsize
+ + u->u_exdata.ux_bsize),
+ (bfd_vma) u->u_exdata.ux_datorg,
+ (file_ptr) coffsets.u_data))
+ return NULL;
+
+ if (!make_bfd_asection (abfd, ".stack",
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
+ (bfd_size_type) u->u_ssize * NBPC,
+ (bfd_vma) u->u_sub,
+ (file_ptr) coffsets.u_stack))
+ return NULL;
+
+ return abfd->xvec; /* Done for version 1 */
+ }
+
+ /* Immediately before coreoffsets region is a long with offset in core
+ to first coresecthead (CORES_OFFSETS), the long before this is the
+ number of section heads in the list. Read both longs and read the
+ coresecthead and check its validity */
+
+ if ((bfd_seek (abfd,
+ coresize - coffset_siz - 2 * sizeof coffset_siz,
+ SEEK_SET) != 0)
+ || (bfd_read ((void *)&nsecs, 1, sizeof nsecs, abfd) != sizeof nsecs)
+ || (bfd_read ((void *)&cheadoffs, 1, sizeof cheadoffs, abfd)
+ != sizeof cheadoffs)
+ || (bfd_seek (abfd, cheadoffs, SEEK_SET) != 0)
+ || (bfd_read ((void *)&chead, 1, sizeof chead, abfd) != sizeof chead)
+ || (chead.cs_stype != CORES_OFFSETS)
+ || (chead.cs_x.csx_magic != COREMAGIC_NUMBER))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ /* Now loop over all regions and map them */
+ nsecs--; /* We've seen CORES_OFFSETS already */
+ for (; nsecs; nsecs--)
+ {
+ if ((bfd_seek (abfd, chead.cs_hseek, SEEK_SET) != 0)
+ || bfd_read ((void *)&chead, 1, sizeof chead, abfd) != sizeof chead)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ switch (chead.cs_stype)
+ {
+ case CORES_MAGIC: /* Core header, check magic */
+ if (chead.cs_x.csx_magic != COREMAGIC_NUMBER)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ secname = NULL;
+ nsecs++; /* MAGIC not in section cnt!*/
+ break;
+ case CORES_UAREA: /* U-area, read in tdata */
+ u = read_uarea(abfd, chead.cs_sseek);
+ if (! u)
+ return NULL;
+
+ /* This is tricky. As the "register section", we give them
+ the entire upage and stack. u.u_ar0 points to where
+ "register 0" is stored. There are two tricks with this,
+ though. One is that the rest of the registers might be
+ at positive or negative (or both) displacements from
+ *u_ar0. The other is that u_ar0 is sometimes an absolute
+ address in kernel memory, and on other systems it is an
+ offset from the beginning of the `struct user'.
+
+ As a practical matter, we don't know where the registers
+ actually are, so we have to pass the whole area to GDB.
+ We encode the value of u_ar0 by setting the .regs section
+ up so that its virtual memory address 0 is at the place
+ pointed to by u_ar0 (by setting the vma of the start of
+ the section to -u_ar0). GDB uses this info to locate the
+ regs, using minor trickery to get around the
+ offset-or-absolute-addr problem. */
+
+ chead.cs_vaddr = 0 - (bfd_vma) u->u_ar0;
+
+
+ secname = ".reg";
+ flags = SEC_HAS_CONTENTS;
+
+ break;
+ case CORES_PREGION: /* A program region, map it */
+ switch (chead.cs_x.csx_preg.csxp_rtyp)
+ {
+ case PT_DATA:
+ secname = ".data"; /* Data region. */
+ break;
+ case PT_STACK:
+ secname = ".stack"; /* Stack region. */
+ break;
+ case PT_SHMEM:
+ secname = ".shmem"; /* Shared memory */
+ break;
+ case PT_LIBDAT:
+ secname = ".libdat"; /* Shared library data */
+ break;
+ case PT_V86:
+ secname = ".virt86"; /* Virtual 8086 mode */
+ break;
+ case PT_SHFIL:
+ secname = ".mmfile"; /* Memory mapped file */
+ break;
+ case PT_XDATA0:
+ secname = ".Xdat0"; /* XENIX data region, virtual 0 */
+ break;
+ default:
+ secname = "";
+ }
+ flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ break;
+ case CORES_PROC: /* struct proc */
+ case CORES_ITIMER: /* interval timers */
+ case CORES_SCOUTSNAME: /* struct scoutsname */
+ secname = NULL; /* Ignore these */
+ break;
+ default:
+ (*_bfd_error_handler) ("Unhandled SCO core file section type %d\n",
+ chead.cs_stype);
+ continue;
+ }
+
+ if (secname
+ && !make_bfd_asection (abfd, secname, flags,
+ (bfd_size_type) chead.cs_vsize,
+ (bfd_vma) chead.cs_vaddr,
+ (file_ptr) chead.cs_sseek))
+ return NULL;
+
+ }
+
+ return abfd->xvec;
+
+}
+
+char *
+sco5_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ char *com = abfd->tdata.sco5_core_data->u.u_comm;
+ if (*com)
+ return com;
+ else
+ return NULL;
+}
+
+/* ARGSUSED */
+int
+sco5_core_file_failing_signal (ignore_abfd)
+ bfd *ignore_abfd;
+{
+ return ((ignore_abfd->tdata.sco5_core_data->u.u_sysabort != 0)
+ ? ignore_abfd->tdata.sco5_core_data->u.u_sysabort
+ : -1);
+}
+
+/* ARGSUSED */
+boolean
+sco5_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this point */
+}
+
+#define sco5_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define sco5_core_get_symtab _bfd_nosymbols_get_symtab
+#define sco5_core_print_symbol _bfd_nosymbols_print_symbol
+#define sco5_core_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define sco5_core_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define sco5_core_get_lineno _bfd_nosymbols_get_lineno
+#define sco5_core_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define sco5_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define sco5_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define sco5_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target sco5_core_vec =
+ {
+ "sco5-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_LITTLE, /* target byte order */
+ BFD_ENDIAN_LITTLE, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ sco5_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (sco5),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (sco5_core),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
diff --git a/bfd/section.c b/bfd/section.c
new file mode 100644
index 00000000000..18778b5362f
--- /dev/null
+++ b/bfd/section.c
@@ -0,0 +1,1075 @@
+/* Object file "section" support for the BFD library.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ Sections
+
+ The raw data contained within a BFD is maintained through the
+ section abstraction. A single BFD may have any number of
+ sections. It keeps hold of them by pointing to the first;
+ each one points to the next in the list.
+
+ Sections are supported in BFD in <<section.c>>.
+
+@menu
+@* Section Input::
+@* Section Output::
+@* typedef asection::
+@* section prototypes::
+@end menu
+
+INODE
+Section Input, Section Output, Sections, Sections
+SUBSECTION
+ Section input
+
+ When a BFD is opened for reading, the section structures are
+ created and attached to the BFD.
+
+ Each section has a name which describes the section in the
+ outside world---for example, <<a.out>> would contain at least
+ three sections, called <<.text>>, <<.data>> and <<.bss>>.
+
+ Names need not be unique; for example a COFF file may have several
+ sections named <<.data>>.
+
+ Sometimes a BFD will contain more than the ``natural'' number of
+ sections. A back end may attach other sections containing
+ constructor data, or an application may add a section (using
+ <<bfd_make_section>>) to the sections attached to an already open
+ BFD. For example, the linker creates an extra section
+ <<COMMON>> for each input file's BFD to hold information about
+ common storage.
+
+ The raw data is not necessarily read in when
+ the section descriptor is created. Some targets may leave the
+ data in place until a <<bfd_get_section_contents>> call is
+ made. Other back ends may read in all the data at once. For
+ example, an S-record file has to be read once to determine the
+ size of the data. An IEEE-695 file doesn't contain raw data in
+ sections, but data and relocation expressions intermixed, so
+ the data area has to be parsed to get out the data and
+ relocations.
+
+INODE
+Section Output, typedef asection, Section Input, Sections
+
+SUBSECTION
+ Section output
+
+ To write a new object style BFD, the various sections to be
+ written have to be created. They are attached to the BFD in
+ the same way as input sections; data is written to the
+ sections using <<bfd_set_section_contents>>.
+
+ Any program that creates or combines sections (e.g., the assembler
+ and linker) must use the <<asection>> fields <<output_section>> and
+ <<output_offset>> to indicate the file sections to which each
+ section must be written. (If the section is being created from
+ scratch, <<output_section>> should probably point to the section
+ itself and <<output_offset>> should probably be zero.)
+
+ The data to be written comes from input sections attached
+ (via <<output_section>> pointers) to
+ the output sections. The output section structure can be
+ considered a filter for the input section: the output section
+ determines the vma of the output data and the name, but the
+ input section determines the offset into the output section of
+ the data to be written.
+
+ E.g., to create a section "O", starting at 0x100, 0x123 long,
+ containing two subsections, "A" at offset 0x0 (i.e., at vma
+ 0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the <<asection>>
+ structures would look like:
+
+| section name "A"
+| output_offset 0x00
+| size 0x20
+| output_section -----------> section name "O"
+| | vma 0x100
+| section name "B" | size 0x123
+| output_offset 0x20 |
+| size 0x103 |
+| output_section --------|
+
+
+SUBSECTION
+ Link orders
+
+ The data within a section is stored in a @dfn{link_order}.
+ These are much like the fixups in <<gas>>. The link_order
+ abstraction allows a section to grow and shrink within itself.
+
+ A link_order knows how big it is, and which is the next
+ link_order and where the raw data for it is; it also points to
+ a list of relocations which apply to it.
+
+ The link_order is used by the linker to perform relaxing on
+ final code. The compiler creates code which is as big as
+ necessary to make it work without relaxing, and the user can
+ select whether to relax. Sometimes relaxing takes a lot of
+ time. The linker runs around the relocations to see if any
+ are attached to data which can be shrunk, if so it does it on
+ a link_order by link_order basis.
+
+*/
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+
+/*
+DOCDD
+INODE
+typedef asection, section prototypes, Section Output, Sections
+SUBSECTION
+ typedef asection
+
+ Here is the section structure:
+
+CODE_FRAGMENT
+.
+.typedef struct sec
+.{
+. {* The name of the section; the name isn't a copy, the pointer is
+. the same as that passed to bfd_make_section. *}
+.
+. CONST char *name;
+.
+. {* Which section is it; 0..nth. *}
+.
+. int index;
+.
+. {* The next section in the list belonging to the BFD, or NULL. *}
+.
+. struct sec *next;
+.
+. {* The field flags contains attributes of the section. Some
+. flags are read in from the object file, and some are
+. synthesized from other information. *}
+.
+. flagword flags;
+.
+.#define SEC_NO_FLAGS 0x000
+.
+. {* Tells the OS to allocate space for this section when loading.
+. This is clear for a section containing debug information
+. only. *}
+.#define SEC_ALLOC 0x001
+.
+. {* Tells the OS to load the section from the file when loading.
+. This is clear for a .bss section. *}
+.#define SEC_LOAD 0x002
+.
+. {* The section contains data still to be relocated, so there is
+. some relocation information too. *}
+.#define SEC_RELOC 0x004
+.
+.#if 0 {* Obsolete ? *}
+.#define SEC_BALIGN 0x008
+.#endif
+.
+. {* A signal to the OS that the section contains read only
+. data. *}
+.#define SEC_READONLY 0x010
+.
+. {* The section contains code only. *}
+.#define SEC_CODE 0x020
+.
+. {* The section contains data only. *}
+.#define SEC_DATA 0x040
+.
+. {* The section will reside in ROM. *}
+.#define SEC_ROM 0x080
+.
+. {* The section contains constructor information. This section
+. type is used by the linker to create lists of constructors and
+. destructors used by <<g++>>. When a back end sees a symbol
+. which should be used in a constructor list, it creates a new
+. section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
+. the symbol to it, and builds a relocation. To build the lists
+. of constructors, all the linker has to do is catenate all the
+. sections called <<__CTOR_LIST__>> and relocate the data
+. contained within - exactly the operations it would peform on
+. standard data. *}
+.#define SEC_CONSTRUCTOR 0x100
+.
+. {* The section is a constructor, and should be placed at the
+. end of the text, data, or bss section(?). *}
+.#define SEC_CONSTRUCTOR_TEXT 0x1100
+.#define SEC_CONSTRUCTOR_DATA 0x2100
+.#define SEC_CONSTRUCTOR_BSS 0x3100
+.
+. {* The section has contents - a data section could be
+. <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
+. <<SEC_HAS_CONTENTS>> *}
+.#define SEC_HAS_CONTENTS 0x200
+.
+. {* An instruction to the linker to not output the section
+. even if it has information which would normally be written. *}
+.#define SEC_NEVER_LOAD 0x400
+.
+. {* The section is a COFF shared library section. This flag is
+. only for the linker. If this type of section appears in
+. the input file, the linker must copy it to the output file
+. without changing the vma or size. FIXME: Although this
+. was originally intended to be general, it really is COFF
+. specific (and the flag was renamed to indicate this). It
+. might be cleaner to have some more general mechanism to
+. allow the back end to control what the linker does with
+. sections. *}
+.#define SEC_COFF_SHARED_LIBRARY 0x800
+.
+. {* The section contains common symbols (symbols may be defined
+. multiple times, the value of a symbol is the amount of
+. space it requires, and the largest symbol value is the one
+. used). Most targets have exactly one of these (which we
+. translate to bfd_com_section_ptr), but ECOFF has two. *}
+.#define SEC_IS_COMMON 0x8000
+.
+. {* The section contains only debugging information. For
+. example, this is set for ELF .debug and .stab sections.
+. strip tests this flag to see if a section can be
+. discarded. *}
+.#define SEC_DEBUGGING 0x10000
+.
+. {* The contents of this section are held in memory pointed to
+. by the contents field. This is checked by
+. bfd_get_section_contents, and the data is retrieved from
+. memory if appropriate. *}
+.#define SEC_IN_MEMORY 0x20000
+.
+. {* The contents of this section are to be excluded by the
+. linker for executable and shared objects unless those
+. objects are to be further relocated. *}
+.#define SEC_EXCLUDE 0x40000
+.
+. {* The contents of this section are to be sorted by the
+. based on the address specified in the associated symbol
+. table. *}
+.#define SEC_SORT_ENTRIES 0x80000
+.
+. {* When linking, duplicate sections of the same name should be
+. discarded, rather than being combined into a single section as
+. is usually done. This is similar to how common symbols are
+. handled. See SEC_LINK_DUPLICATES below. *}
+.#define SEC_LINK_ONCE 0x100000
+.
+. {* If SEC_LINK_ONCE is set, this bitfield describes how the linker
+. should handle duplicate sections. *}
+.#define SEC_LINK_DUPLICATES 0x600000
+.
+. {* This value for SEC_LINK_DUPLICATES means that duplicate
+. sections with the same name should simply be discarded. *}
+.#define SEC_LINK_DUPLICATES_DISCARD 0x0
+.
+. {* This value for SEC_LINK_DUPLICATES means that the linker
+. should warn if there are any duplicate sections, although
+. it should still only link one copy. *}
+.#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000
+.
+. {* This value for SEC_LINK_DUPLICATES means that the linker
+. should warn if any duplicate sections are a different size. *}
+.#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000
+.
+. {* This value for SEC_LINK_DUPLICATES means that the linker
+. should warn if any duplicate sections contain different
+. contents. *}
+.#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000
+.
+. {* This section was created by the linker as part of dynamic
+. relocation or other arcane processing. It is skipped when
+. going through the first-pass output, trusting that someone
+. else up the line will take care of it later. *}
+.#define SEC_LINKER_CREATED 0x800000
+.
+. {* This section should not be subject to garbage collection. *}
+.#define SEC_KEEP 0x1000000
+.
+. {* End of section flags. *}
+.
+. {* Some internal packed boolean fields. *}
+.
+. {* See the vma field. *}
+. unsigned int user_set_vma : 1;
+.
+. {* Whether relocations have been processed. *}
+. unsigned int reloc_done : 1;
+.
+. {* A mark flag used by some of the linker backends. *}
+. unsigned int linker_mark : 1;
+.
+. {* A mark flag used by some linker backends for garbage collection. *}
+. unsigned int gc_mark : 1;
+.
+. {* End of internal packed boolean fields. *}
+.
+. {* The virtual memory address of the section - where it will be
+. at run time. The symbols are relocated against this. The
+. user_set_vma flag is maintained by bfd; if it's not set, the
+. backend can assign addresses (for example, in <<a.out>>, where
+. the default address for <<.data>> is dependent on the specific
+. target and various flags). *}
+.
+. bfd_vma vma;
+.
+. {* The load address of the section - where it would be in a
+. rom image; really only used for writing section header
+. information. *}
+.
+. bfd_vma lma;
+.
+. {* The size of the section in bytes, as it will be output.
+. contains a value even if the section has no contents (e.g., the
+. size of <<.bss>>). This will be filled in after relocation *}
+.
+. bfd_size_type _cooked_size;
+.
+. {* The original size on disk of the section, in bytes. Normally this
+. value is the same as the size, but if some relaxing has
+. been done, then this value will be bigger. *}
+.
+. bfd_size_type _raw_size;
+.
+. {* If this section is going to be output, then this value is the
+. offset into the output section of the first byte in the input
+. section. E.g., if this was going to start at the 100th byte in
+. the output section, this value would be 100. *}
+.
+. bfd_vma output_offset;
+.
+. {* The output section through which to map on output. *}
+.
+. struct sec *output_section;
+.
+. {* The alignment requirement of the section, as an exponent of 2 -
+. e.g., 3 aligns to 2^3 (or 8). *}
+.
+. unsigned int alignment_power;
+.
+. {* If an input section, a pointer to a vector of relocation
+. records for the data in this section. *}
+.
+. struct reloc_cache_entry *relocation;
+.
+. {* If an output section, a pointer to a vector of pointers to
+. relocation records for the data in this section. *}
+.
+. struct reloc_cache_entry **orelocation;
+.
+. {* The number of relocation records in one of the above *}
+.
+. unsigned reloc_count;
+.
+. {* Information below is back end specific - and not always used
+. or updated. *}
+.
+. {* File position of section data *}
+.
+. file_ptr filepos;
+.
+. {* File position of relocation info *}
+.
+. file_ptr rel_filepos;
+.
+. {* File position of line data *}
+.
+. file_ptr line_filepos;
+.
+. {* Pointer to data for applications *}
+.
+. PTR userdata;
+.
+. {* If the SEC_IN_MEMORY flag is set, this points to the actual
+. contents. *}
+. unsigned char *contents;
+.
+. {* Attached line number information *}
+.
+. alent *lineno;
+.
+. {* Number of line number records *}
+.
+. unsigned int lineno_count;
+.
+. {* When a section is being output, this value changes as more
+. linenumbers are written out *}
+.
+. file_ptr moving_line_filepos;
+.
+. {* What the section number is in the target world *}
+.
+. int target_index;
+.
+. PTR used_by_bfd;
+.
+. {* If this is a constructor section then here is a list of the
+. relocations created to relocate items within it. *}
+.
+. struct relent_chain *constructor_chain;
+.
+. {* The BFD which owns the section. *}
+.
+. bfd *owner;
+.
+. {* A symbol which points at this section only *}
+. struct symbol_cache_entry *symbol;
+. struct symbol_cache_entry **symbol_ptr_ptr;
+.
+. struct bfd_link_order *link_order_head;
+. struct bfd_link_order *link_order_tail;
+.} asection ;
+.
+. {* These sections are global, and are managed by BFD. The application
+. and target back end are not permitted to change the values in
+. these sections. New code should use the section_ptr macros rather
+. than referring directly to the const sections. The const sections
+. may eventually vanish. *}
+.#define BFD_ABS_SECTION_NAME "*ABS*"
+.#define BFD_UND_SECTION_NAME "*UND*"
+.#define BFD_COM_SECTION_NAME "*COM*"
+.#define BFD_IND_SECTION_NAME "*IND*"
+.
+. {* the absolute section *}
+.extern const asection bfd_abs_section;
+.#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
+.#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
+. {* Pointer to the undefined section *}
+.extern const asection bfd_und_section;
+.#define bfd_und_section_ptr ((asection *) &bfd_und_section)
+.#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
+. {* Pointer to the common section *}
+.extern const asection bfd_com_section;
+.#define bfd_com_section_ptr ((asection *) &bfd_com_section)
+. {* Pointer to the indirect section *}
+.extern const asection bfd_ind_section;
+.#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
+.#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
+.
+.extern const struct symbol_cache_entry * const bfd_abs_symbol;
+.extern const struct symbol_cache_entry * const bfd_com_symbol;
+.extern const struct symbol_cache_entry * const bfd_und_symbol;
+.extern const struct symbol_cache_entry * const bfd_ind_symbol;
+.#define bfd_get_section_size_before_reloc(section) \
+. (section->reloc_done ? (abort(),1): (section)->_raw_size)
+.#define bfd_get_section_size_after_reloc(section) \
+. ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
+*/
+
+/* These symbols are global, not specific to any BFD. Therefore, anything
+ that tries to change them is broken, and should be repaired. */
+static const asymbol global_syms[] =
+{
+ /* the_bfd, name, value, attr, section [, udata] */
+ {0, BFD_COM_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_com_section},
+ {0, BFD_UND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_und_section},
+ {0, BFD_ABS_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_abs_section},
+ {0, BFD_IND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_ind_section},
+};
+
+#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \
+ const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
+ const asection SEC = \
+ { NAME, 0, 0, FLAGS, 0, 0, 0, 0, 0, 0, 0, 0, 0, (asection *) &SEC, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ (asymbol *) &global_syms[IDX], (asymbol **) &SYM, 0, 0 }
+
+STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
+ BFD_COM_SECTION_NAME, 0);
+STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1);
+STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);
+STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);
+#undef STD_SECTION
+
+/*
+DOCDD
+INODE
+section prototypes, , typedef asection, Sections
+SUBSECTION
+ Section prototypes
+
+These are the functions exported by the section handling part of BFD.
+*/
+
+/*
+FUNCTION
+ bfd_get_section_by_name
+
+SYNOPSIS
+ asection *bfd_get_section_by_name(bfd *abfd, CONST char *name);
+
+DESCRIPTION
+ Run through @var{abfd} and return the one of the
+ <<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
+ @xref{Sections}, for more information.
+
+ This should only be used in special cases; the normal way to process
+ all sections of a given name is to use <<bfd_map_over_sections>> and
+ <<strcmp>> on the name (or better yet, base it on the section flags
+ or something else) for each section.
+*/
+
+asection *
+bfd_get_section_by_name (abfd, name)
+ bfd *abfd;
+ CONST char *name;
+{
+ asection *sect;
+
+ for (sect = abfd->sections; sect != NULL; sect = sect->next)
+ if (!strcmp (sect->name, name))
+ return sect;
+ return NULL;
+}
+
+
+/*
+FUNCTION
+ bfd_make_section_old_way
+
+SYNOPSIS
+ asection *bfd_make_section_old_way(bfd *abfd, CONST char *name);
+
+DESCRIPTION
+ Create a new empty section called @var{name}
+ and attach it to the end of the chain of sections for the
+ BFD @var{abfd}. An attempt to create a section with a name which
+ is already in use returns its pointer without changing the
+ section chain.
+
+ It has the funny name since this is the way it used to be
+ before it was rewritten....
+
+ Possible errors are:
+ o <<bfd_error_invalid_operation>> -
+ If output has already started for this BFD.
+ o <<bfd_error_no_memory>> -
+ If memory allocation fails.
+
+*/
+
+
+asection *
+bfd_make_section_old_way (abfd, name)
+ bfd *abfd;
+ CONST char *name;
+{
+ asection *sec = bfd_get_section_by_name (abfd, name);
+ if (sec == (asection *) NULL)
+ {
+ sec = bfd_make_section (abfd, name);
+ }
+ return sec;
+}
+
+/*
+FUNCTION
+ bfd_make_section_anyway
+
+SYNOPSIS
+ asection *bfd_make_section_anyway(bfd *abfd, CONST char *name);
+
+DESCRIPTION
+ Create a new empty section called @var{name} and attach it to the end of
+ the chain of sections for @var{abfd}. Create a new section even if there
+ is already a section with that name.
+
+ Return <<NULL>> and set <<bfd_error>> on error; possible errors are:
+ o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}.
+ o <<bfd_error_no_memory>> - If memory allocation fails.
+*/
+
+sec_ptr
+bfd_make_section_anyway (abfd, name)
+ bfd *abfd;
+ CONST char *name;
+{
+ asection *newsect;
+ asection **prev = &abfd->sections;
+ asection *sect = abfd->sections;
+
+ if (abfd->output_has_begun)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+ }
+
+ while (sect)
+ {
+ prev = &sect->next;
+ sect = sect->next;
+ }
+
+ newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (newsect == NULL)
+ return NULL;
+
+ newsect->name = name;
+ newsect->index = abfd->section_count++;
+ newsect->flags = SEC_NO_FLAGS;
+
+ newsect->userdata = NULL;
+ newsect->contents = NULL;
+ newsect->next = (asection *) NULL;
+ newsect->relocation = (arelent *) NULL;
+ newsect->reloc_count = 0;
+ newsect->line_filepos = 0;
+ newsect->owner = abfd;
+
+ /* Create a symbol whos only job is to point to this section. This is
+ useful for things like relocs which are relative to the base of a
+ section. */
+ newsect->symbol = bfd_make_empty_symbol (abfd);
+ if (newsect->symbol == NULL)
+ return NULL;
+ newsect->symbol->name = name;
+ newsect->symbol->value = 0;
+ newsect->symbol->section = newsect;
+ newsect->symbol->flags = BSF_SECTION_SYM;
+
+ newsect->symbol_ptr_ptr = &newsect->symbol;
+
+ if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true)
+ {
+ free (newsect);
+ return NULL;
+ }
+
+ *prev = newsect;
+ return newsect;
+}
+
+/*
+FUNCTION
+ bfd_make_section
+
+SYNOPSIS
+ asection *bfd_make_section(bfd *, CONST char *name);
+
+DESCRIPTION
+ Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling
+ bfd_set_error ()) without changing the section chain if there is already a
+ section named @var{name}. If there is an error, return <<NULL>> and set
+ <<bfd_error>>.
+*/
+
+asection *
+bfd_make_section (abfd, name)
+ bfd *abfd;
+ CONST char *name;
+{
+ asection *sect = abfd->sections;
+
+ if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
+ {
+ return bfd_abs_section_ptr;
+ }
+ if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
+ {
+ return bfd_com_section_ptr;
+ }
+ if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
+ {
+ return bfd_und_section_ptr;
+ }
+
+ if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
+ {
+ return bfd_ind_section_ptr;
+ }
+
+ while (sect)
+ {
+ if (!strcmp (sect->name, name))
+ return NULL;
+ sect = sect->next;
+ }
+
+ /* The name is not already used; go ahead and make a new section. */
+ return bfd_make_section_anyway (abfd, name);
+}
+
+
+/*
+FUNCTION
+ bfd_set_section_flags
+
+SYNOPSIS
+ boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
+
+DESCRIPTION
+ Set the attributes of the section @var{sec} in the BFD
+ @var{abfd} to the value @var{flags}. Return <<true>> on success,
+ <<false>> on error. Possible error returns are:
+
+ o <<bfd_error_invalid_operation>> -
+ The section cannot have one or more of the attributes
+ requested. For example, a .bss section in <<a.out>> may not
+ have the <<SEC_HAS_CONTENTS>> field set.
+
+*/
+
+/*ARGSUSED*/
+boolean
+bfd_set_section_flags (abfd, section, flags)
+ bfd *abfd;
+ sec_ptr section;
+ flagword flags;
+{
+#if 0
+ /* If you try to copy a text section from an input file (where it
+ has the SEC_CODE flag set) to an output file, this loses big if
+ the bfd_applicable_section_flags (abfd) doesn't have the SEC_CODE
+ set - which it doesn't, at least not for a.out. FIXME */
+
+ if ((flags & bfd_applicable_section_flags (abfd)) != flags)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+#endif
+
+ section->flags = flags;
+ return true;
+}
+
+
+/*
+FUNCTION
+ bfd_map_over_sections
+
+SYNOPSIS
+ void bfd_map_over_sections(bfd *abfd,
+ void (*func)(bfd *abfd,
+ asection *sect,
+ PTR obj),
+ PTR obj);
+
+DESCRIPTION
+ Call the provided function @var{func} for each section
+ attached to the BFD @var{abfd}, passing @var{obj} as an
+ argument. The function will be called as if by
+
+| func(abfd, the_section, obj);
+
+ This is the prefered method for iterating over sections; an
+ alternative would be to use a loop:
+
+| section *p;
+| for (p = abfd->sections; p != NULL; p = p->next)
+| func(abfd, p, ...)
+
+
+*/
+
+/*VARARGS2*/
+void
+bfd_map_over_sections (abfd, operation, user_storage)
+ bfd *abfd;
+ void (*operation) PARAMS ((bfd * abfd, asection * sect, PTR obj));
+ PTR user_storage;
+{
+ asection *sect;
+ unsigned int i = 0;
+
+ for (sect = abfd->sections; sect != NULL; i++, sect = sect->next)
+ (*operation) (abfd, sect, user_storage);
+
+ if (i != abfd->section_count) /* Debugging */
+ abort ();
+}
+
+
+/*
+FUNCTION
+ bfd_set_section_size
+
+SYNOPSIS
+ boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
+
+DESCRIPTION
+ Set @var{sec} to the size @var{val}. If the operation is
+ ok, then <<true>> is returned, else <<false>>.
+
+ Possible error returns:
+ o <<bfd_error_invalid_operation>> -
+ Writing has started to the BFD, so setting the size is invalid.
+
+*/
+
+boolean
+bfd_set_section_size (abfd, ptr, val)
+ bfd *abfd;
+ sec_ptr ptr;
+ bfd_size_type val;
+{
+ /* Once you've started writing to any section you cannot create or change
+ the size of any others. */
+
+ if (abfd->output_has_begun)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ ptr->_cooked_size = val;
+ ptr->_raw_size = val;
+
+ return true;
+}
+
+/*
+FUNCTION
+ bfd_set_section_contents
+
+SYNOPSIS
+ boolean bfd_set_section_contents
+ (bfd *abfd,
+ asection *section,
+ PTR data,
+ file_ptr offset,
+ bfd_size_type count);
+
+
+DESCRIPTION
+ Sets the contents of the section @var{section} in BFD
+ @var{abfd} to the data starting in memory at @var{data}. The
+ data is written to the output section starting at offset
+ @var{offset} for @var{count} bytes.
+
+
+
+ Normally <<true>> is returned, else <<false>>. Possible error
+ returns are:
+ o <<bfd_error_no_contents>> -
+ The output section does not have the <<SEC_HAS_CONTENTS>>
+ attribute, so nothing can be written to it.
+ o and some more too
+
+ This routine is front end to the back end function
+ <<_bfd_set_section_contents>>.
+
+
+*/
+
+#define bfd_get_section_size_now(abfd,sec) \
+(sec->reloc_done \
+ ? bfd_get_section_size_after_reloc (sec) \
+ : bfd_get_section_size_before_reloc (sec))
+
+boolean
+bfd_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ bfd_size_type sz;
+
+ if (!(bfd_get_section_flags (abfd, section) & SEC_HAS_CONTENTS))
+ {
+ bfd_set_error (bfd_error_no_contents);
+ return (false);
+ }
+
+ if (offset < 0)
+ {
+ bad_val:
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ sz = bfd_get_section_size_now (abfd, section);
+ if ((bfd_size_type) offset > sz
+ || count > sz
+ || offset + count > sz)
+ goto bad_val;
+
+ switch (abfd->direction)
+ {
+ case read_direction:
+ case no_direction:
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+
+ case write_direction:
+ break;
+
+ case both_direction:
+ /* File is opened for update. `output_has_begun' some time ago when
+ the file was created. Do not recompute sections sizes or alignments
+ in _bfd_set_section_content. */
+ abfd->output_has_begun = true;
+ break;
+ }
+
+ if (BFD_SEND (abfd, _bfd_set_section_contents,
+ (abfd, section, location, offset, count)))
+ {
+ abfd->output_has_begun = true;
+ return true;
+ }
+
+ return false;
+}
+
+/*
+FUNCTION
+ bfd_get_section_contents
+
+SYNOPSIS
+ boolean bfd_get_section_contents
+ (bfd *abfd, asection *section, PTR location,
+ file_ptr offset, bfd_size_type count);
+
+DESCRIPTION
+ Read data from @var{section} in BFD @var{abfd}
+ into memory starting at @var{location}. The data is read at an
+ offset of @var{offset} from the start of the input section,
+ and is read for @var{count} bytes.
+
+ If the contents of a constructor with the <<SEC_CONSTRUCTOR>>
+ flag set are requested or if the section does not have the
+ <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled
+ with zeroes. If no errors occur, <<true>> is returned, else
+ <<false>>.
+
+
+
+*/
+boolean
+bfd_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ bfd_size_type sz;
+
+ if (section->flags & SEC_CONSTRUCTOR)
+ {
+ memset (location, 0, (unsigned) count);
+ return true;
+ }
+
+ if (offset < 0)
+ {
+ bad_val:
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ /* Even if reloc_done is true, this function reads unrelocated
+ contents, so we want the raw size. */
+ sz = section->_raw_size;
+ if ((bfd_size_type) offset > sz || count > sz || offset + count > sz)
+ goto bad_val;
+
+ if (count == 0)
+ /* Don't bother. */
+ return true;
+
+ if ((section->flags & SEC_HAS_CONTENTS) == 0)
+ {
+ memset (location, 0, (unsigned) count);
+ return true;
+ }
+
+ if ((section->flags & SEC_IN_MEMORY) != 0)
+ {
+ memcpy (location, section->contents + offset, (size_t) count);
+ return true;
+ }
+
+ return BFD_SEND (abfd, _bfd_get_section_contents,
+ (abfd, section, location, offset, count));
+}
+
+/*
+FUNCTION
+ bfd_copy_private_section_data
+
+SYNOPSIS
+ boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
+
+DESCRIPTION
+ Copy private section information from @var{isec} in the BFD
+ @var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
+ Return <<true>> on success, <<false>> on error. Possible error
+ returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{osec}.
+
+.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
+. BFD_SEND (obfd, _bfd_copy_private_section_data, \
+. (ibfd, isection, obfd, osection))
+*/
+
+/*
+FUNCTION
+ _bfd_strip_section_from_output
+
+SYNOPSIS
+ void _bfd_strip_section_from_output
+ (asection *section);
+
+DESCRIPTION
+ Remove @var{section} from the output. If the output section becomes
+ empty, remove it from the output bfd.
+*/
+void
+_bfd_strip_section_from_output (s)
+ asection *s;
+{
+ asection **spp, *os;
+ struct bfd_link_order *p, *pp;
+
+ os = s->output_section;
+ for (p = os->link_order_head, pp = NULL; p != NULL; pp = p, p = p->next)
+ if (p->type == bfd_indirect_link_order
+ && p->u.indirect.section == s)
+ {
+ /* Excise the input section. */
+ if (pp)
+ pp->next = p->next;
+ else
+ os->link_order_head = p->next;
+ if (!p->next)
+ os->link_order_tail = pp;
+
+ if (!os->link_order_head)
+ {
+ /* Excise the output section. */
+ for (spp = &os->owner->sections; *spp; spp = &(*spp)->next)
+ if (*spp == os)
+ {
+ *spp = os->next;
+ os->owner->section_count--;
+ break;
+ }
+ }
+ break;
+ }
+}
diff --git a/bfd/som.c b/bfd/som.c
new file mode 100644
index 00000000000..b5786b51ed7
--- /dev/null
+++ b/bfd/som.c
@@ -0,0 +1,6264 @@
+/* bfd back-end for HP PA-RISC SOM objects.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined(HOST_HPPAMPEIX)
+
+#include "libbfd.h"
+#include "som.h"
+
+#include <sys/param.h>
+#include <signal.h>
+#include <machine/reg.h>
+#include <sys/file.h>
+#include <ctype.h>
+
+/* Magic not defined in standard HP-UX header files until 8.0 */
+
+#ifndef CPU_PA_RISC1_0
+#define CPU_PA_RISC1_0 0x20B
+#endif /* CPU_PA_RISC1_0 */
+
+#ifndef CPU_PA_RISC1_1
+#define CPU_PA_RISC1_1 0x210
+#endif /* CPU_PA_RISC1_1 */
+
+#ifndef CPU_PA_RISC2_0
+#define CPU_PA_RISC2_0 0x214
+#endif /* CPU_PA_RISC2_0 */
+
+#ifndef _PA_RISC1_0_ID
+#define _PA_RISC1_0_ID CPU_PA_RISC1_0
+#endif /* _PA_RISC1_0_ID */
+
+#ifndef _PA_RISC1_1_ID
+#define _PA_RISC1_1_ID CPU_PA_RISC1_1
+#endif /* _PA_RISC1_1_ID */
+
+#ifndef _PA_RISC2_0_ID
+#define _PA_RISC2_0_ID CPU_PA_RISC2_0
+#endif /* _PA_RISC2_0_ID */
+
+#ifndef _PA_RISC_MAXID
+#define _PA_RISC_MAXID 0x2FF
+#endif /* _PA_RISC_MAXID */
+
+#ifndef _PA_RISC_ID
+#define _PA_RISC_ID(__m_num) \
+ (((__m_num) == _PA_RISC1_0_ID) || \
+ ((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
+#endif /* _PA_RISC_ID */
+
+
+/* HIUX in it's infinite stupidity changed the names for several "well
+ known" constants. Work around such braindamage. Try the HPUX version
+ first, then the HIUX version, and finally provide a default. */
+#ifdef HPUX_AUX_ID
+#define EXEC_AUX_ID HPUX_AUX_ID
+#endif
+
+#if !defined (EXEC_AUX_ID) && defined (HIUX_AUX_ID)
+#define EXEC_AUX_ID HIUX_AUX_ID
+#endif
+
+#ifndef EXEC_AUX_ID
+#define EXEC_AUX_ID 0
+#endif
+
+/* Size (in chars) of the temporary buffers used during fixup and string
+ table writes. */
+
+#define SOM_TMP_BUFSIZE 8192
+
+/* Size of the hash table in archives. */
+#define SOM_LST_HASH_SIZE 31
+
+/* Max number of SOMs to be found in an archive. */
+#define SOM_LST_MODULE_LIMIT 1024
+
+/* Generic alignment macro. */
+#define SOM_ALIGN(val, alignment) \
+ (((val) + (alignment) - 1) & ~((alignment) - 1))
+
+/* SOM allows any one of the four previous relocations to be reused
+ with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
+ relocations are always a single byte, using a R_PREV_FIXUP instead
+ of some multi-byte relocation makes object files smaller.
+
+ Note one side effect of using a R_PREV_FIXUP is the relocation that
+ is being repeated moves to the front of the queue. */
+struct reloc_queue
+ {
+ unsigned char *reloc;
+ unsigned int size;
+ } reloc_queue[4];
+
+/* This fully describes the symbol types which may be attached to
+ an EXPORT or IMPORT directive. Only SOM uses this formation
+ (ELF has no need for it). */
+typedef enum
+{
+ SYMBOL_TYPE_UNKNOWN,
+ SYMBOL_TYPE_ABSOLUTE,
+ SYMBOL_TYPE_CODE,
+ SYMBOL_TYPE_DATA,
+ SYMBOL_TYPE_ENTRY,
+ SYMBOL_TYPE_MILLICODE,
+ SYMBOL_TYPE_PLABEL,
+ SYMBOL_TYPE_PRI_PROG,
+ SYMBOL_TYPE_SEC_PROG,
+} pa_symbol_type;
+
+struct section_to_type
+{
+ char *section;
+ char type;
+};
+
+/* Assorted symbol information that needs to be derived from the BFD symbol
+ and/or the BFD backend private symbol data. */
+struct som_misc_symbol_info
+{
+ unsigned int symbol_type;
+ unsigned int symbol_scope;
+ unsigned int arg_reloc;
+ unsigned int symbol_info;
+ unsigned int symbol_value;
+ unsigned int priv_level;
+};
+
+/* Forward declarations */
+
+static boolean som_mkobject PARAMS ((bfd *));
+static const bfd_target * som_object_setup PARAMS ((bfd *,
+ struct header *,
+ struct som_exec_auxhdr *,
+ unsigned long));
+static boolean setup_sections PARAMS ((bfd *, struct header *, unsigned long));
+static const bfd_target * som_object_p PARAMS ((bfd *));
+static boolean som_write_object_contents PARAMS ((bfd *));
+static boolean som_slurp_string_table PARAMS ((bfd *));
+static unsigned int som_slurp_symbol_table PARAMS ((bfd *));
+static long som_get_symtab_upper_bound PARAMS ((bfd *));
+static long som_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
+ arelent **, asymbol **));
+static long som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
+static unsigned int som_set_reloc_info PARAMS ((unsigned char *, unsigned int,
+ arelent *, asection *,
+ asymbol **, boolean));
+static boolean som_slurp_reloc_table PARAMS ((bfd *, asection *,
+ asymbol **, boolean));
+static long som_get_symtab PARAMS ((bfd *, asymbol **));
+static asymbol * som_make_empty_symbol PARAMS ((bfd *));
+static void som_print_symbol PARAMS ((bfd *, PTR,
+ asymbol *, bfd_print_symbol_type));
+static boolean som_new_section_hook PARAMS ((bfd *, asection *));
+static boolean som_bfd_copy_private_symbol_data PARAMS ((bfd *, asymbol *,
+ bfd *, asymbol *));
+static boolean som_bfd_copy_private_section_data PARAMS ((bfd *, asection *,
+ bfd *, asection *));
+static boolean som_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+#define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+static boolean som_bfd_is_local_label_name PARAMS ((bfd *, const char *));
+static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr, bfd_size_type));
+static boolean som_get_section_contents PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr, bfd_size_type));
+static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
+ unsigned long));
+static boolean som_find_nearest_line PARAMS ((bfd *, asection *,
+ asymbol **, bfd_vma,
+ CONST char **,
+ CONST char **,
+ unsigned int *));
+static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static asection * bfd_section_from_som_symbol PARAMS ((bfd *,
+ struct symbol_dictionary_record *));
+static int log2 PARAMS ((unsigned int));
+static bfd_reloc_status_type hppa_som_reloc PARAMS ((bfd *, arelent *,
+ asymbol *, PTR,
+ asection *, bfd *,
+ char **));
+static void som_initialize_reloc_queue PARAMS ((struct reloc_queue *));
+static void som_reloc_queue_insert PARAMS ((unsigned char *, unsigned int,
+ struct reloc_queue *));
+static void som_reloc_queue_fix PARAMS ((struct reloc_queue *, unsigned int));
+static int som_reloc_queue_find PARAMS ((unsigned char *, unsigned int,
+ struct reloc_queue *));
+static unsigned char * try_prev_fixup PARAMS ((bfd *, int *, unsigned char *,
+ unsigned int,
+ struct reloc_queue *));
+
+static unsigned char * som_reloc_skip PARAMS ((bfd *, unsigned int,
+ unsigned char *, unsigned int *,
+ struct reloc_queue *));
+static unsigned char * som_reloc_addend PARAMS ((bfd *, int, unsigned char *,
+ unsigned int *,
+ struct reloc_queue *));
+static unsigned char * som_reloc_call PARAMS ((bfd *, unsigned char *,
+ unsigned int *,
+ arelent *, int,
+ struct reloc_queue *));
+static unsigned long som_count_spaces PARAMS ((bfd *));
+static unsigned long som_count_subspaces PARAMS ((bfd *));
+static int compare_syms PARAMS ((const void *, const void *));
+static int compare_subspaces PARAMS ((const void *, const void *));
+static unsigned long som_compute_checksum PARAMS ((bfd *));
+static boolean som_prep_headers PARAMS ((bfd *));
+static int som_sizeof_headers PARAMS ((bfd *, boolean));
+static boolean som_finish_writing PARAMS ((bfd *));
+static boolean som_build_and_write_symbol_table PARAMS ((bfd *));
+static void som_prep_for_fixups PARAMS ((bfd *, asymbol **, unsigned long));
+static boolean som_write_fixups PARAMS ((bfd *, unsigned long, unsigned int *));
+static boolean som_write_space_strings PARAMS ((bfd *, unsigned long,
+ unsigned int *));
+static boolean som_write_symbol_strings PARAMS ((bfd *, unsigned long,
+ asymbol **, unsigned int,
+ unsigned *,
+ COMPUNIT *));
+static boolean som_begin_writing PARAMS ((bfd *));
+static reloc_howto_type * som_bfd_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static char som_section_type PARAMS ((const char *));
+static int som_decode_symclass PARAMS ((asymbol *));
+static boolean som_bfd_count_ar_symbols PARAMS ((bfd *, struct lst_header *,
+ symindex *));
+
+static boolean som_bfd_fill_in_ar_symbols PARAMS ((bfd *, struct lst_header *,
+ carsym **syms));
+static boolean som_slurp_armap PARAMS ((bfd *));
+static boolean som_write_armap PARAMS ((bfd *, unsigned int, struct orl *,
+ unsigned int, int));
+static void som_bfd_derive_misc_symbol_info PARAMS ((bfd *, asymbol *,
+ struct som_misc_symbol_info *));
+static boolean som_bfd_prep_for_ar_write PARAMS ((bfd *, unsigned int *,
+ unsigned int *));
+static unsigned int som_bfd_ar_symbol_hash PARAMS ((asymbol *));
+static boolean som_bfd_ar_write_symbol_stuff PARAMS ((bfd *, unsigned int,
+ unsigned int,
+ struct lst_header,
+ unsigned int));
+static boolean som_is_space PARAMS ((asection *));
+static boolean som_is_subspace PARAMS ((asection *));
+static boolean som_is_container PARAMS ((asection *, asection *));
+static boolean som_bfd_free_cached_info PARAMS ((bfd *));
+static boolean som_bfd_link_split_section PARAMS ((bfd *, asection *));
+
+/* Map SOM section names to POSIX/BSD single-character symbol types.
+
+ This table includes all the standard subspaces as defined in the
+ current "PRO ABI for PA-RISC Systems", $UNWIND$ which for
+ some reason was left out, and sections specific to embedded stabs. */
+
+static const struct section_to_type stt[] = {
+ {"$TEXT$", 't'},
+ {"$SHLIB_INFO$", 't'},
+ {"$MILLICODE$", 't'},
+ {"$LIT$", 't'},
+ {"$CODE$", 't'},
+ {"$UNWIND_START$", 't'},
+ {"$UNWIND$", 't'},
+ {"$PRIVATE$", 'd'},
+ {"$PLT$", 'd'},
+ {"$SHLIB_DATA$", 'd'},
+ {"$DATA$", 'd'},
+ {"$SHORTDATA$", 'g'},
+ {"$DLT$", 'd'},
+ {"$GLOBAL$", 'g'},
+ {"$SHORTBSS$", 's'},
+ {"$BSS$", 'b'},
+ {"$GDB_STRINGS$", 'N'},
+ {"$GDB_SYMBOLS$", 'N'},
+ {0, 0}
+};
+
+/* About the relocation formatting table...
+
+ There are 256 entries in the table, one for each possible
+ relocation opcode available in SOM. We index the table by
+ the relocation opcode. The names and operations are those
+ defined by a.out_800 (4).
+
+ Right now this table is only used to count and perform minimal
+ processing on relocation streams so that they can be internalized
+ into BFD and symbolically printed by utilities. To make actual use
+ of them would be much more difficult, BFD's concept of relocations
+ is far too simple to handle SOM relocations. The basic assumption
+ that a relocation can be completely processed independent of other
+ relocations before an object file is written is invalid for SOM.
+
+ The SOM relocations are meant to be processed as a stream, they
+ specify copying of data from the input section to the output section
+ while possibly modifying the data in some manner. They also can
+ specify that a variable number of zeros or uninitialized data be
+ inserted on in the output segment at the current offset. Some
+ relocations specify that some previous relocation be re-applied at
+ the current location in the input/output sections. And finally a number
+ of relocations have effects on other sections (R_ENTRY, R_EXIT,
+ R_UNWIND_AUX and a variety of others). There isn't even enough room
+ in the BFD relocation data structure to store enough information to
+ perform all the relocations.
+
+ Each entry in the table has three fields.
+
+ The first entry is an index into this "class" of relocations. This
+ index can then be used as a variable within the relocation itself.
+
+ The second field is a format string which actually controls processing
+ of the relocation. It uses a simple postfix machine to do calculations
+ based on variables/constants found in the string and the relocation
+ stream.
+
+ The third field specifys whether or not this relocation may use
+ a constant (V) from the previous R_DATA_OVERRIDE rather than a constant
+ stored in the instruction.
+
+ Variables:
+
+ L = input space byte count
+ D = index into class of relocations
+ M = output space byte count
+ N = statement number (unused?)
+ O = stack operation
+ R = parameter relocation bits
+ S = symbol index
+ T = first 32 bits of stack unwind information
+ U = second 32 bits of stack unwind information
+ V = a literal constant (usually used in the next relocation)
+ P = a previous relocation
+
+ Lower case letters (starting with 'b') refer to following
+ bytes in the relocation stream. 'b' is the next 1 byte,
+ c is the next 2 bytes, d is the next 3 bytes, etc...
+ This is the variable part of the relocation entries that
+ makes our life a living hell.
+
+ numerical constants are also used in the format string. Note
+ the constants are represented in decimal.
+
+ '+', "*" and "=" represents the obvious postfix operators.
+ '<' represents a left shift.
+
+ Stack Operations:
+
+ Parameter Relocation Bits:
+
+ Unwind Entries:
+
+ Previous Relocations: The index field represents which in the queue
+ of 4 previous fixups should be re-applied.
+
+ Literal Constants: These are generally used to represent addend
+ parts of relocations when these constants are not stored in the
+ fields of the instructions themselves. For example the instruction
+ addil foo-$global$-0x1234 would use an override for "0x1234" rather
+ than storing it into the addil itself. */
+
+struct fixup_format
+{
+ int D;
+ char *format;
+};
+
+static const struct fixup_format som_fixup_formats[256] =
+{
+ /* R_NO_RELOCATION */
+ 0, "LD1+4*=", /* 0x00 */
+ 1, "LD1+4*=", /* 0x01 */
+ 2, "LD1+4*=", /* 0x02 */
+ 3, "LD1+4*=", /* 0x03 */
+ 4, "LD1+4*=", /* 0x04 */
+ 5, "LD1+4*=", /* 0x05 */
+ 6, "LD1+4*=", /* 0x06 */
+ 7, "LD1+4*=", /* 0x07 */
+ 8, "LD1+4*=", /* 0x08 */
+ 9, "LD1+4*=", /* 0x09 */
+ 10, "LD1+4*=", /* 0x0a */
+ 11, "LD1+4*=", /* 0x0b */
+ 12, "LD1+4*=", /* 0x0c */
+ 13, "LD1+4*=", /* 0x0d */
+ 14, "LD1+4*=", /* 0x0e */
+ 15, "LD1+4*=", /* 0x0f */
+ 16, "LD1+4*=", /* 0x10 */
+ 17, "LD1+4*=", /* 0x11 */
+ 18, "LD1+4*=", /* 0x12 */
+ 19, "LD1+4*=", /* 0x13 */
+ 20, "LD1+4*=", /* 0x14 */
+ 21, "LD1+4*=", /* 0x15 */
+ 22, "LD1+4*=", /* 0x16 */
+ 23, "LD1+4*=", /* 0x17 */
+ 0, "LD8<b+1+4*=", /* 0x18 */
+ 1, "LD8<b+1+4*=", /* 0x19 */
+ 2, "LD8<b+1+4*=", /* 0x1a */
+ 3, "LD8<b+1+4*=", /* 0x1b */
+ 0, "LD16<c+1+4*=", /* 0x1c */
+ 1, "LD16<c+1+4*=", /* 0x1d */
+ 2, "LD16<c+1+4*=", /* 0x1e */
+ 0, "Ld1+=", /* 0x1f */
+ /* R_ZEROES */
+ 0, "Lb1+4*=", /* 0x20 */
+ 1, "Ld1+=", /* 0x21 */
+ /* R_UNINIT */
+ 0, "Lb1+4*=", /* 0x22 */
+ 1, "Ld1+=", /* 0x23 */
+ /* R_RELOCATION */
+ 0, "L4=", /* 0x24 */
+ /* R_DATA_ONE_SYMBOL */
+ 0, "L4=Sb=", /* 0x25 */
+ 1, "L4=Sd=", /* 0x26 */
+ /* R_DATA_PLEBEL */
+ 0, "L4=Sb=", /* 0x27 */
+ 1, "L4=Sd=", /* 0x28 */
+ /* R_SPACE_REF */
+ 0, "L4=", /* 0x29 */
+ /* R_REPEATED_INIT */
+ 0, "L4=Mb1+4*=", /* 0x2a */
+ 1, "Lb4*=Mb1+L*=", /* 0x2b */
+ 2, "Lb4*=Md1+4*=", /* 0x2c */
+ 3, "Ld1+=Me1+=", /* 0x2d */
+ /* R_SHORT_PCREL_MODE */
+ 0, "", /* 0x2e */
+ /* R_LONG_PCREL_MODE */
+ 0, "", /* 0x2f */
+ /* R_PCREL_CALL */
+ 0, "L4=RD=Sb=", /* 0x30 */
+ 1, "L4=RD=Sb=", /* 0x31 */
+ 2, "L4=RD=Sb=", /* 0x32 */
+ 3, "L4=RD=Sb=", /* 0x33 */
+ 4, "L4=RD=Sb=", /* 0x34 */
+ 5, "L4=RD=Sb=", /* 0x35 */
+ 6, "L4=RD=Sb=", /* 0x36 */
+ 7, "L4=RD=Sb=", /* 0x37 */
+ 8, "L4=RD=Sb=", /* 0x38 */
+ 9, "L4=RD=Sb=", /* 0x39 */
+ 0, "L4=RD8<b+=Sb=",/* 0x3a */
+ 1, "L4=RD8<b+=Sb=",/* 0x3b */
+ 0, "L4=RD8<b+=Sd=",/* 0x3c */
+ 1, "L4=RD8<b+=Sd=",/* 0x3d */
+ /* R_RESERVED */
+ 0, "", /* 0x3e */
+ 0, "", /* 0x3f */
+ /* R_ABS_CALL */
+ 0, "L4=RD=Sb=", /* 0x40 */
+ 1, "L4=RD=Sb=", /* 0x41 */
+ 2, "L4=RD=Sb=", /* 0x42 */
+ 3, "L4=RD=Sb=", /* 0x43 */
+ 4, "L4=RD=Sb=", /* 0x44 */
+ 5, "L4=RD=Sb=", /* 0x45 */
+ 6, "L4=RD=Sb=", /* 0x46 */
+ 7, "L4=RD=Sb=", /* 0x47 */
+ 8, "L4=RD=Sb=", /* 0x48 */
+ 9, "L4=RD=Sb=", /* 0x49 */
+ 0, "L4=RD8<b+=Sb=",/* 0x4a */
+ 1, "L4=RD8<b+=Sb=",/* 0x4b */
+ 0, "L4=RD8<b+=Sd=",/* 0x4c */
+ 1, "L4=RD8<b+=Sd=",/* 0x4d */
+ /* R_RESERVED */
+ 0, "", /* 0x4e */
+ 0, "", /* 0x4f */
+ /* R_DP_RELATIVE */
+ 0, "L4=SD=", /* 0x50 */
+ 1, "L4=SD=", /* 0x51 */
+ 2, "L4=SD=", /* 0x52 */
+ 3, "L4=SD=", /* 0x53 */
+ 4, "L4=SD=", /* 0x54 */
+ 5, "L4=SD=", /* 0x55 */
+ 6, "L4=SD=", /* 0x56 */
+ 7, "L4=SD=", /* 0x57 */
+ 8, "L4=SD=", /* 0x58 */
+ 9, "L4=SD=", /* 0x59 */
+ 10, "L4=SD=", /* 0x5a */
+ 11, "L4=SD=", /* 0x5b */
+ 12, "L4=SD=", /* 0x5c */
+ 13, "L4=SD=", /* 0x5d */
+ 14, "L4=SD=", /* 0x5e */
+ 15, "L4=SD=", /* 0x5f */
+ 16, "L4=SD=", /* 0x60 */
+ 17, "L4=SD=", /* 0x61 */
+ 18, "L4=SD=", /* 0x62 */
+ 19, "L4=SD=", /* 0x63 */
+ 20, "L4=SD=", /* 0x64 */
+ 21, "L4=SD=", /* 0x65 */
+ 22, "L4=SD=", /* 0x66 */
+ 23, "L4=SD=", /* 0x67 */
+ 24, "L4=SD=", /* 0x68 */
+ 25, "L4=SD=", /* 0x69 */
+ 26, "L4=SD=", /* 0x6a */
+ 27, "L4=SD=", /* 0x6b */
+ 28, "L4=SD=", /* 0x6c */
+ 29, "L4=SD=", /* 0x6d */
+ 30, "L4=SD=", /* 0x6e */
+ 31, "L4=SD=", /* 0x6f */
+ 32, "L4=Sb=", /* 0x70 */
+ 33, "L4=Sd=", /* 0x71 */
+ /* R_RESERVED */
+ 0, "", /* 0x72 */
+ 0, "", /* 0x73 */
+ 0, "", /* 0x74 */
+ 0, "", /* 0x75 */
+ 0, "", /* 0x76 */
+ 0, "", /* 0x77 */
+ /* R_DLT_REL */
+ 0, "L4=Sb=", /* 0x78 */
+ 1, "L4=Sd=", /* 0x79 */
+ /* R_RESERVED */
+ 0, "", /* 0x7a */
+ 0, "", /* 0x7b */
+ 0, "", /* 0x7c */
+ 0, "", /* 0x7d */
+ 0, "", /* 0x7e */
+ 0, "", /* 0x7f */
+ /* R_CODE_ONE_SYMBOL */
+ 0, "L4=SD=", /* 0x80 */
+ 1, "L4=SD=", /* 0x81 */
+ 2, "L4=SD=", /* 0x82 */
+ 3, "L4=SD=", /* 0x83 */
+ 4, "L4=SD=", /* 0x84 */
+ 5, "L4=SD=", /* 0x85 */
+ 6, "L4=SD=", /* 0x86 */
+ 7, "L4=SD=", /* 0x87 */
+ 8, "L4=SD=", /* 0x88 */
+ 9, "L4=SD=", /* 0x89 */
+ 10, "L4=SD=", /* 0x8q */
+ 11, "L4=SD=", /* 0x8b */
+ 12, "L4=SD=", /* 0x8c */
+ 13, "L4=SD=", /* 0x8d */
+ 14, "L4=SD=", /* 0x8e */
+ 15, "L4=SD=", /* 0x8f */
+ 16, "L4=SD=", /* 0x90 */
+ 17, "L4=SD=", /* 0x91 */
+ 18, "L4=SD=", /* 0x92 */
+ 19, "L4=SD=", /* 0x93 */
+ 20, "L4=SD=", /* 0x94 */
+ 21, "L4=SD=", /* 0x95 */
+ 22, "L4=SD=", /* 0x96 */
+ 23, "L4=SD=", /* 0x97 */
+ 24, "L4=SD=", /* 0x98 */
+ 25, "L4=SD=", /* 0x99 */
+ 26, "L4=SD=", /* 0x9a */
+ 27, "L4=SD=", /* 0x9b */
+ 28, "L4=SD=", /* 0x9c */
+ 29, "L4=SD=", /* 0x9d */
+ 30, "L4=SD=", /* 0x9e */
+ 31, "L4=SD=", /* 0x9f */
+ 32, "L4=Sb=", /* 0xa0 */
+ 33, "L4=Sd=", /* 0xa1 */
+ /* R_RESERVED */
+ 0, "", /* 0xa2 */
+ 0, "", /* 0xa3 */
+ 0, "", /* 0xa4 */
+ 0, "", /* 0xa5 */
+ 0, "", /* 0xa6 */
+ 0, "", /* 0xa7 */
+ 0, "", /* 0xa8 */
+ 0, "", /* 0xa9 */
+ 0, "", /* 0xaa */
+ 0, "", /* 0xab */
+ 0, "", /* 0xac */
+ 0, "", /* 0xad */
+ /* R_MILLI_REL */
+ 0, "L4=Sb=", /* 0xae */
+ 1, "L4=Sd=", /* 0xaf */
+ /* R_CODE_PLABEL */
+ 0, "L4=Sb=", /* 0xb0 */
+ 1, "L4=Sd=", /* 0xb1 */
+ /* R_BREAKPOINT */
+ 0, "L4=", /* 0xb2 */
+ /* R_ENTRY */
+ 0, "Te=Ue=", /* 0xb3 */
+ 1, "Uf=", /* 0xb4 */
+ /* R_ALT_ENTRY */
+ 0, "", /* 0xb5 */
+ /* R_EXIT */
+ 0, "", /* 0xb6 */
+ /* R_BEGIN_TRY */
+ 0, "", /* 0xb7 */
+ /* R_END_TRY */
+ 0, "R0=", /* 0xb8 */
+ 1, "Rb4*=", /* 0xb9 */
+ 2, "Rd4*=", /* 0xba */
+ /* R_BEGIN_BRTAB */
+ 0, "", /* 0xbb */
+ /* R_END_BRTAB */
+ 0, "", /* 0xbc */
+ /* R_STATEMENT */
+ 0, "Nb=", /* 0xbd */
+ 1, "Nc=", /* 0xbe */
+ 2, "Nd=", /* 0xbf */
+ /* R_DATA_EXPR */
+ 0, "L4=", /* 0xc0 */
+ /* R_CODE_EXPR */
+ 0, "L4=", /* 0xc1 */
+ /* R_FSEL */
+ 0, "", /* 0xc2 */
+ /* R_LSEL */
+ 0, "", /* 0xc3 */
+ /* R_RSEL */
+ 0, "", /* 0xc4 */
+ /* R_N_MODE */
+ 0, "", /* 0xc5 */
+ /* R_S_MODE */
+ 0, "", /* 0xc6 */
+ /* R_D_MODE */
+ 0, "", /* 0xc7 */
+ /* R_R_MODE */
+ 0, "", /* 0xc8 */
+ /* R_DATA_OVERRIDE */
+ 0, "V0=", /* 0xc9 */
+ 1, "Vb=", /* 0xca */
+ 2, "Vc=", /* 0xcb */
+ 3, "Vd=", /* 0xcc */
+ 4, "Ve=", /* 0xcd */
+ /* R_TRANSLATED */
+ 0, "", /* 0xce */
+ /* R_RESERVED */
+ 0, "", /* 0xcf */
+ /* R_COMP1 */
+ 0, "Ob=", /* 0xd0 */
+ /* R_COMP2 */
+ 0, "Ob=Sd=", /* 0xd1 */
+ /* R_COMP3 */
+ 0, "Ob=Ve=", /* 0xd2 */
+ /* R_PREV_FIXUP */
+ 0, "P", /* 0xd3 */
+ 1, "P", /* 0xd4 */
+ 2, "P", /* 0xd5 */
+ 3, "P", /* 0xd6 */
+ /* R_SEC_STMT */
+ 0, "", /* 0xd7 */
+ /* R_N0SEL */
+ 0, "", /* 0xd8 */
+ /* R_N1SEL */
+ 0, "", /* 0xd9 */
+ /* R_LINETAB */
+ 0, "", /* 0xda */
+ /* R_LINETAB_ESC */
+ 0, "", /* 0xdb */
+ /* R_LTP_OVERRIDE */
+ 0, "", /* 0xdc */
+ /* R_COMMENT */
+ 0, "", /* 0xdd */
+ /* R_RESERVED */
+ 0, "", /* 0xde */
+ 0, "", /* 0xdf */
+ 0, "", /* 0xe0 */
+ 0, "", /* 0xe1 */
+ 0, "", /* 0xe2 */
+ 0, "", /* 0xe3 */
+ 0, "", /* 0xe4 */
+ 0, "", /* 0xe5 */
+ 0, "", /* 0xe6 */
+ 0, "", /* 0xe7 */
+ 0, "", /* 0xe8 */
+ 0, "", /* 0xe9 */
+ 0, "", /* 0xea */
+ 0, "", /* 0xeb */
+ 0, "", /* 0xec */
+ 0, "", /* 0xed */
+ 0, "", /* 0xee */
+ 0, "", /* 0xef */
+ 0, "", /* 0xf0 */
+ 0, "", /* 0xf1 */
+ 0, "", /* 0xf2 */
+ 0, "", /* 0xf3 */
+ 0, "", /* 0xf4 */
+ 0, "", /* 0xf5 */
+ 0, "", /* 0xf6 */
+ 0, "", /* 0xf7 */
+ 0, "", /* 0xf8 */
+ 0, "", /* 0xf9 */
+ 0, "", /* 0xfa */
+ 0, "", /* 0xfb */
+ 0, "", /* 0xfc */
+ 0, "", /* 0xfd */
+ 0, "", /* 0xfe */
+ 0, "", /* 0xff */
+};
+
+static const int comp1_opcodes[] =
+{
+ 0x00,
+ 0x40,
+ 0x41,
+ 0x42,
+ 0x43,
+ 0x44,
+ 0x45,
+ 0x46,
+ 0x47,
+ 0x48,
+ 0x49,
+ 0x4a,
+ 0x4b,
+ 0x60,
+ 0x80,
+ 0xa0,
+ 0xc0,
+ -1
+};
+
+static const int comp2_opcodes[] =
+{
+ 0x00,
+ 0x80,
+ 0x82,
+ 0xc0,
+ -1
+};
+
+static const int comp3_opcodes[] =
+{
+ 0x00,
+ 0x02,
+ -1
+};
+
+/* These apparently are not in older versions of hpux reloc.h (hpux7). */
+#ifndef R_DLT_REL
+#define R_DLT_REL 0x78
+#endif
+
+#ifndef R_AUX_UNWIND
+#define R_AUX_UNWIND 0xcf
+#endif
+
+#ifndef R_SEC_STMT
+#define R_SEC_STMT 0xd7
+#endif
+
+/* And these first appeared in hpux10. */
+#ifndef R_SHORT_PCREL_MODE
+#define R_SHORT_PCREL_MODE 0x3e
+#endif
+
+#ifndef R_LONG_PCREL_MODE
+#define R_LONG_PCREL_MODE 0x3f
+#endif
+
+#ifndef R_N0SEL
+#define R_N0SEL 0xd8
+#endif
+
+#ifndef R_N1SEL
+#define R_N1SEL 0xd9
+#endif
+
+#ifndef R_LINETAB
+#define R_LINETAB 0xda
+#endif
+
+#ifndef R_LINETAB_ESC
+#define R_LINETAB_ESC 0xdb
+#endif
+
+#ifndef R_LTP_OVERRIDE
+#define R_LTP_OVERRIDE 0xdc
+#endif
+
+#ifndef R_COMMENT
+#define R_COMMENT 0xdd
+#endif
+
+static reloc_howto_type som_hppa_howto_table[] =
+{
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
+ {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"},
+ {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"},
+ {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"},
+ {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"},
+ {R_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RELOCATION"},
+ {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"},
+ {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"},
+ {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"},
+ {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"},
+ {R_SPACE_REF, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SPACE_REF"},
+ {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
+ {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
+ {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
+ {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
+ {R_SHORT_PCREL_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SHORT_PCREL_MODE"},
+ {R_LONG_PCREL_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LONG_PCREL_MODE"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_DLT_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DLT_REL"},
+ {R_DLT_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DLT_REL"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"},
+ {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"},
+ {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"},
+ {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"},
+ {R_BREAKPOINT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BREAKPOINT"},
+ {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"},
+ {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"},
+ {R_ALT_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ALT_ENTRY"},
+ {R_EXIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_EXIT"},
+ {R_BEGIN_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_TRY"},
+ {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
+ {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
+ {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
+ {R_BEGIN_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_BRTAB"},
+ {R_END_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_BRTAB"},
+ {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
+ {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
+ {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
+ {R_DATA_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_EXPR"},
+ {R_CODE_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_EXPR"},
+ {R_FSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_FSEL"},
+ {R_LSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LSEL"},
+ {R_RSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RSEL"},
+ {R_N_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N_MODE"},
+ {R_S_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_S_MODE"},
+ {R_D_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_D_MODE"},
+ {R_R_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_R_MODE"},
+ {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
+ {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
+ {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
+ {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
+ {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
+ {R_TRANSLATED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_TRANSLATED"},
+ {R_AUX_UNWIND, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_AUX_UNWIND"},
+ {R_COMP1, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP1"},
+ {R_COMP2, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP2"},
+ {R_COMP3, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP3"},
+ {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
+ {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
+ {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
+ {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
+ {R_SEC_STMT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SEC_STMT"},
+ {R_N0SEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N0SEL"},
+ {R_N1SEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N1SEL"},
+ {R_LINETAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LINETAB"},
+ {R_LINETAB_ESC, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LINETAB_ESC"},
+ {R_LTP_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LTP_OVERRIDE"},
+ {R_COMMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMMENT"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
+ {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}};
+
+/* Initialize the SOM relocation queue. By definition the queue holds
+ the last four multibyte fixups. */
+
+static void
+som_initialize_reloc_queue (queue)
+ struct reloc_queue *queue;
+{
+ queue[0].reloc = NULL;
+ queue[0].size = 0;
+ queue[1].reloc = NULL;
+ queue[1].size = 0;
+ queue[2].reloc = NULL;
+ queue[2].size = 0;
+ queue[3].reloc = NULL;
+ queue[3].size = 0;
+}
+
+/* Insert a new relocation into the relocation queue. */
+
+static void
+som_reloc_queue_insert (p, size, queue)
+ unsigned char *p;
+ unsigned int size;
+ struct reloc_queue *queue;
+{
+ queue[3].reloc = queue[2].reloc;
+ queue[3].size = queue[2].size;
+ queue[2].reloc = queue[1].reloc;
+ queue[2].size = queue[1].size;
+ queue[1].reloc = queue[0].reloc;
+ queue[1].size = queue[0].size;
+ queue[0].reloc = p;
+ queue[0].size = size;
+}
+
+/* When an entry in the relocation queue is reused, the entry moves
+ to the front of the queue. */
+
+static void
+som_reloc_queue_fix (queue, index)
+ struct reloc_queue *queue;
+ unsigned int index;
+{
+ if (index == 0)
+ return;
+
+ if (index == 1)
+ {
+ unsigned char *tmp1 = queue[0].reloc;
+ unsigned int tmp2 = queue[0].size;
+ queue[0].reloc = queue[1].reloc;
+ queue[0].size = queue[1].size;
+ queue[1].reloc = tmp1;
+ queue[1].size = tmp2;
+ return;
+ }
+
+ if (index == 2)
+ {
+ unsigned char *tmp1 = queue[0].reloc;
+ unsigned int tmp2 = queue[0].size;
+ queue[0].reloc = queue[2].reloc;
+ queue[0].size = queue[2].size;
+ queue[2].reloc = queue[1].reloc;
+ queue[2].size = queue[1].size;
+ queue[1].reloc = tmp1;
+ queue[1].size = tmp2;
+ return;
+ }
+
+ if (index == 3)
+ {
+ unsigned char *tmp1 = queue[0].reloc;
+ unsigned int tmp2 = queue[0].size;
+ queue[0].reloc = queue[3].reloc;
+ queue[0].size = queue[3].size;
+ queue[3].reloc = queue[2].reloc;
+ queue[3].size = queue[2].size;
+ queue[2].reloc = queue[1].reloc;
+ queue[2].size = queue[1].size;
+ queue[1].reloc = tmp1;
+ queue[1].size = tmp2;
+ return;
+ }
+ abort();
+}
+
+/* Search for a particular relocation in the relocation queue. */
+
+static int
+som_reloc_queue_find (p, size, queue)
+ unsigned char *p;
+ unsigned int size;
+ struct reloc_queue *queue;
+{
+ if (queue[0].reloc && !memcmp (p, queue[0].reloc, size)
+ && size == queue[0].size)
+ return 0;
+ if (queue[1].reloc && !memcmp (p, queue[1].reloc, size)
+ && size == queue[1].size)
+ return 1;
+ if (queue[2].reloc && !memcmp (p, queue[2].reloc, size)
+ && size == queue[2].size)
+ return 2;
+ if (queue[3].reloc && !memcmp (p, queue[3].reloc, size)
+ && size == queue[3].size)
+ return 3;
+ return -1;
+}
+
+static unsigned char *
+try_prev_fixup (abfd, subspace_reloc_sizep, p, size, queue)
+ bfd *abfd;
+ int *subspace_reloc_sizep;
+ unsigned char *p;
+ unsigned int size;
+ struct reloc_queue *queue;
+{
+ int queue_index = som_reloc_queue_find (p, size, queue);
+
+ if (queue_index != -1)
+ {
+ /* Found this in a previous fixup. Undo the fixup we
+ just built and use R_PREV_FIXUP instead. We saved
+ a total of size - 1 bytes in the fixup stream. */
+ bfd_put_8 (abfd, R_PREV_FIXUP + queue_index, p);
+ p += 1;
+ *subspace_reloc_sizep += 1;
+ som_reloc_queue_fix (queue, queue_index);
+ }
+ else
+ {
+ som_reloc_queue_insert (p, size, queue);
+ *subspace_reloc_sizep += size;
+ p += size;
+ }
+ return p;
+}
+
+/* Emit the proper R_NO_RELOCATION fixups to map the next SKIP
+ bytes without any relocation. Update the size of the subspace
+ relocation stream via SUBSPACE_RELOC_SIZE_P; also return the
+ current pointer into the relocation stream. */
+
+static unsigned char *
+som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue)
+ bfd *abfd;
+ unsigned int skip;
+ unsigned char *p;
+ unsigned int *subspace_reloc_sizep;
+ struct reloc_queue *queue;
+{
+ /* Use a 4 byte R_NO_RELOCATION entry with a maximal value
+ then R_PREV_FIXUPs to get the difference down to a
+ reasonable size. */
+ if (skip >= 0x1000000)
+ {
+ skip -= 0x1000000;
+ bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
+ bfd_put_8 (abfd, 0xff, p + 1);
+ bfd_put_16 (abfd, 0xffff, p + 2);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
+ while (skip >= 0x1000000)
+ {
+ skip -= 0x1000000;
+ bfd_put_8 (abfd, R_PREV_FIXUP, p);
+ p++;
+ *subspace_reloc_sizep += 1;
+ /* No need to adjust queue here since we are repeating the
+ most recent fixup. */
+ }
+ }
+
+ /* The difference must be less than 0x1000000. Use one
+ more R_NO_RELOCATION entry to get to the right difference. */
+ if ((skip & 3) == 0 && skip <= 0xc0000 && skip > 0)
+ {
+ /* Difference can be handled in a simple single-byte
+ R_NO_RELOCATION entry. */
+ if (skip <= 0x60)
+ {
+ bfd_put_8 (abfd, R_NO_RELOCATION + (skip >> 2) - 1, p);
+ *subspace_reloc_sizep += 1;
+ p++;
+ }
+ /* Handle it with a two byte R_NO_RELOCATION entry. */
+ else if (skip <= 0x1000)
+ {
+ bfd_put_8 (abfd, R_NO_RELOCATION + 24 + (((skip >> 2) - 1) >> 8), p);
+ bfd_put_8 (abfd, (skip >> 2) - 1, p + 1);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
+ }
+ /* Handle it with a three byte R_NO_RELOCATION entry. */
+ else
+ {
+ bfd_put_8 (abfd, R_NO_RELOCATION + 28 + (((skip >> 2) - 1) >> 16), p);
+ bfd_put_16 (abfd, (skip >> 2) - 1, p + 1);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
+ }
+ }
+ /* Ugh. Punt and use a 4 byte entry. */
+ else if (skip > 0)
+ {
+ bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
+ bfd_put_8 (abfd, (skip - 1) >> 16, p + 1);
+ bfd_put_16 (abfd, skip - 1, p + 2);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
+ }
+ return p;
+}
+
+/* Emit the proper R_DATA_OVERRIDE fixups to handle a nonzero addend
+ from a BFD relocation. Update the size of the subspace relocation
+ stream via SUBSPACE_RELOC_SIZE_P; also return the current pointer
+ into the relocation stream. */
+
+static unsigned char *
+som_reloc_addend (abfd, addend, p, subspace_reloc_sizep, queue)
+ bfd *abfd;
+ int addend;
+ unsigned char *p;
+ unsigned int *subspace_reloc_sizep;
+ struct reloc_queue *queue;
+{
+ if ((unsigned)(addend) + 0x80 < 0x100)
+ {
+ bfd_put_8 (abfd, R_DATA_OVERRIDE + 1, p);
+ bfd_put_8 (abfd, addend, p + 1);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
+ }
+ else if ((unsigned) (addend) + 0x8000 < 0x10000)
+ {
+ bfd_put_8 (abfd, R_DATA_OVERRIDE + 2, p);
+ bfd_put_16 (abfd, addend, p + 1);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
+ }
+ else if ((unsigned) (addend) + 0x800000 < 0x1000000)
+ {
+ bfd_put_8 (abfd, R_DATA_OVERRIDE + 3, p);
+ bfd_put_8 (abfd, addend >> 16, p + 1);
+ bfd_put_16 (abfd, addend, p + 2);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
+ }
+ else
+ {
+ bfd_put_8 (abfd, R_DATA_OVERRIDE + 4, p);
+ bfd_put_32 (abfd, addend, p + 1);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue);
+ }
+ return p;
+}
+
+/* Handle a single function call relocation. */
+
+static unsigned char *
+som_reloc_call (abfd, p, subspace_reloc_sizep, bfd_reloc, sym_num, queue)
+ bfd *abfd;
+ unsigned char *p;
+ unsigned int *subspace_reloc_sizep;
+ arelent *bfd_reloc;
+ int sym_num;
+ struct reloc_queue *queue;
+{
+ int arg_bits = HPPA_R_ARG_RELOC (bfd_reloc->addend);
+ int rtn_bits = arg_bits & 0x3;
+ int type, done = 0;
+
+ /* You'll never believe all this is necessary to handle relocations
+ for function calls. Having to compute and pack the argument
+ relocation bits is the real nightmare.
+
+ If you're interested in how this works, just forget it. You really
+ do not want to know about this braindamage. */
+
+ /* First see if this can be done with a "simple" relocation. Simple
+ relocations have a symbol number < 0x100 and have simple encodings
+ of argument relocations. */
+
+ if (sym_num < 0x100)
+ {
+ switch (arg_bits)
+ {
+ case 0:
+ case 1:
+ type = 0;
+ break;
+ case 1 << 8:
+ case 1 << 8 | 1:
+ type = 1;
+ break;
+ case 1 << 8 | 1 << 6:
+ case 1 << 8 | 1 << 6 | 1:
+ type = 2;
+ break;
+ case 1 << 8 | 1 << 6 | 1 << 4:
+ case 1 << 8 | 1 << 6 | 1 << 4 | 1:
+ type = 3;
+ break;
+ case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2:
+ case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2 | 1:
+ type = 4;
+ break;
+ default:
+ /* Not one of the easy encodings. This will have to be
+ handled by the more complex code below. */
+ type = -1;
+ break;
+ }
+ if (type != -1)
+ {
+ /* Account for the return value too. */
+ if (rtn_bits)
+ type += 5;
+
+ /* Emit a 2 byte relocation. Then see if it can be handled
+ with a relocation which is already in the relocation queue. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type + type, p);
+ bfd_put_8 (abfd, sym_num, p + 1);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
+ done = 1;
+ }
+ }
+
+ /* If this could not be handled with a simple relocation, then do a hard
+ one. Hard relocations occur if the symbol number was too high or if
+ the encoding of argument relocation bits is too complex. */
+ if (! done)
+ {
+ /* Don't ask about these magic sequences. I took them straight
+ from gas-1.36 which took them from the a.out man page. */
+ type = rtn_bits;
+ if ((arg_bits >> 6 & 0xf) == 0xe)
+ type += 9 * 40;
+ else
+ type += (3 * (arg_bits >> 8 & 3) + (arg_bits >> 6 & 3)) * 40;
+ if ((arg_bits >> 2 & 0xf) == 0xe)
+ type += 9 * 4;
+ else
+ type += (3 * (arg_bits >> 4 & 3) + (arg_bits >> 2 & 3)) * 4;
+
+ /* Output the first two bytes of the relocation. These describe
+ the length of the relocation and encoding style. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type + 10
+ + 2 * (sym_num >= 0x100) + (type >= 0x100),
+ p);
+ bfd_put_8 (abfd, type, p + 1);
+
+ /* Now output the symbol index and see if this bizarre relocation
+ just happened to be in the relocation queue. */
+ if (sym_num < 0x100)
+ {
+ bfd_put_8 (abfd, sym_num, p + 2);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
+ }
+ else
+ {
+ bfd_put_8 (abfd, sym_num >> 16, p + 2);
+ bfd_put_16 (abfd, sym_num, p + 3);
+ p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue);
+ }
+ }
+ return p;
+}
+
+
+/* Return the logarithm of X, base 2, considering X unsigned.
+ Abort -1 if X is not a power or two or is zero. */
+
+static int
+log2 (x)
+ unsigned int x;
+{
+ int log = 0;
+
+ /* Test for 0 or a power of 2. */
+ if (x == 0 || x != (x & -x))
+ return -1;
+
+ while ((x >>= 1) != 0)
+ log++;
+ return log;
+}
+
+static bfd_reloc_status_type
+hppa_som_reloc (abfd, reloc_entry, symbol_in, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ if (output_bfd)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+ return bfd_reloc_ok;
+}
+
+/* Given a generic HPPA relocation type, the instruction format,
+ and a field selector, return one or more appropriate SOM relocations. */
+
+int **
+hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
+ bfd *abfd;
+ int base_type;
+ int format;
+ enum hppa_reloc_field_selector_type_alt field;
+ int sym_diff;
+ asymbol *sym;
+{
+ int *final_type, **final_types;
+
+ final_types = (int **) bfd_alloc (abfd, sizeof (int *) * 6);
+ final_type = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types || !final_type)
+ return NULL;
+
+ /* The field selector may require additional relocations to be
+ generated. It's impossible to know at this moment if additional
+ relocations will be needed, so we make them. The code to actually
+ write the relocation/fixup stream is responsible for removing
+ any redundant relocations. */
+ switch (field)
+ {
+ case e_fsel:
+ case e_psel:
+ case e_lpsel:
+ case e_rpsel:
+ final_types[0] = final_type;
+ final_types[1] = NULL;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_tsel:
+ case e_ltsel:
+ case e_rtsel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ if (field == e_tsel)
+ *final_types[0] = R_FSEL;
+ else if (field == e_ltsel)
+ *final_types[0] = R_LSEL;
+ else
+ *final_types[0] = R_RSEL;
+ final_types[1] = final_type;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_lssel:
+ case e_rssel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ *final_types[0] = R_S_MODE;
+ final_types[1] = final_type;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_lsel:
+ case e_rsel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ *final_types[0] = R_N_MODE;
+ final_types[1] = final_type;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_ldsel:
+ case e_rdsel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ *final_types[0] = R_D_MODE;
+ final_types[1] = final_type;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_lrsel:
+ case e_rrsel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ *final_types[0] = R_R_MODE;
+ final_types[1] = final_type;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_nsel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ *final_types[0] = R_N1SEL;
+ final_types[1] = final_type;
+ final_types[2] = NULL;
+ *final_type = base_type;
+ break;
+
+ case e_nlsel:
+ case e_nlrsel:
+ final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0])
+ return NULL;
+ *final_types[0] = R_N0SEL;
+ final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
+ if (!final_types[1])
+ return NULL;
+ if (field == e_nlsel)
+ *final_types[1] = R_N_MODE;
+ else
+ *final_types[1] = R_R_MODE;
+ final_types[2] = final_type;
+ final_types[3] = NULL;
+ *final_type = base_type;
+ break;
+ }
+
+ switch (base_type)
+ {
+ case R_HPPA:
+ /* The difference of two symbols needs *very* special handling. */
+ if (sym_diff)
+ {
+ final_types[0] = (int *)bfd_alloc (abfd, sizeof (int));
+ final_types[1] = (int *)bfd_alloc (abfd, sizeof (int));
+ final_types[2] = (int *)bfd_alloc (abfd, sizeof (int));
+ final_types[3] = (int *)bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0] || !final_types[1] || !final_types[2])
+ return NULL;
+ if (field == e_fsel)
+ *final_types[0] = R_FSEL;
+ else if (field == e_rsel)
+ *final_types[0] = R_RSEL;
+ else if (field == e_lsel)
+ *final_types[0] = R_LSEL;
+ *final_types[1] = R_COMP2;
+ *final_types[2] = R_COMP2;
+ *final_types[3] = R_COMP1;
+ final_types[4] = final_type;
+ if (format == 32)
+ *final_types[4] = R_DATA_EXPR;
+ else
+ *final_types[4] = R_CODE_EXPR;
+ final_types[5] = NULL;
+ break;
+ }
+ /* PLABELs get their own relocation type. */
+ else if (field == e_psel
+ || field == e_lpsel
+ || field == e_rpsel)
+ {
+ /* A PLABEL relocation that has a size of 32 bits must
+ be a R_DATA_PLABEL. All others are R_CODE_PLABELs. */
+ if (format == 32)
+ *final_type = R_DATA_PLABEL;
+ else
+ *final_type = R_CODE_PLABEL;
+ }
+ /* PIC stuff. */
+ else if (field == e_tsel
+ || field == e_ltsel
+ || field == e_rtsel)
+ *final_type = R_DLT_REL;
+ /* A relocation in the data space is always a full 32bits. */
+ else if (format == 32)
+ {
+ *final_type = R_DATA_ONE_SYMBOL;
+
+ /* If there's no SOM symbol type associated with this BFD
+ symbol, then set the symbol type to ST_DATA.
+
+ Only do this if the type is going to default later when
+ we write the object file.
+
+ This is done so that the linker never encounters an
+ R_DATA_ONE_SYMBOL reloc involving an ST_CODE symbol.
+
+ This allows the compiler to generate exception handling
+ tables.
+
+ Note that one day we may need to also emit BEGIN_BRTAB and
+ END_BRTAB to prevent the linker from optimizing away insns
+ in exception handling regions. */
+ if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN
+ && (sym->flags & BSF_SECTION_SYM) == 0
+ && (sym->flags & BSF_FUNCTION) == 0
+ && ! bfd_is_com_section (sym->section))
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_DATA;
+ }
+ break;
+
+
+ case R_HPPA_GOTOFF:
+ /* More PLABEL special cases. */
+ if (field == e_psel
+ || field == e_lpsel
+ || field == e_rpsel)
+ *final_type = R_DATA_PLABEL;
+ break;
+
+ case R_HPPA_COMPLEX:
+ /* The difference of two symbols needs *very* special handling. */
+ if (sym_diff)
+ {
+ final_types[0] = (int *)bfd_alloc (abfd, sizeof (int));
+ final_types[1] = (int *)bfd_alloc (abfd, sizeof (int));
+ final_types[2] = (int *)bfd_alloc (abfd, sizeof (int));
+ final_types[3] = (int *)bfd_alloc (abfd, sizeof (int));
+ if (!final_types[0] || !final_types[1] || !final_types[2])
+ return NULL;
+ if (field == e_fsel)
+ *final_types[0] = R_FSEL;
+ else if (field == e_rsel)
+ *final_types[0] = R_RSEL;
+ else if (field == e_lsel)
+ *final_types[0] = R_LSEL;
+ *final_types[1] = R_COMP2;
+ *final_types[2] = R_COMP2;
+ *final_types[3] = R_COMP1;
+ final_types[4] = final_type;
+ if (format == 32)
+ *final_types[4] = R_DATA_EXPR;
+ else
+ *final_types[4] = R_CODE_EXPR;
+ final_types[5] = NULL;
+ break;
+ }
+ else
+ break;
+
+ case R_HPPA_NONE:
+ case R_HPPA_ABS_CALL:
+ case R_HPPA_PCREL_CALL:
+ /* Right now we can default all these. */
+ break;
+ }
+ return final_types;
+}
+
+/* Return the address of the correct entry in the PA SOM relocation
+ howto table. */
+
+/*ARGSUSED*/
+static reloc_howto_type *
+som_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ if ((int) code < (int) R_NO_RELOCATION + 255)
+ {
+ BFD_ASSERT ((int) som_hppa_howto_table[(int) code].type == (int) code);
+ return &som_hppa_howto_table[(int) code];
+ }
+
+ return (reloc_howto_type *) 0;
+}
+
+/* Perform some initialization for an object. Save results of this
+ initialization in the BFD. */
+
+static const bfd_target *
+som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset)
+ bfd *abfd;
+ struct header *file_hdrp;
+ struct som_exec_auxhdr *aux_hdrp;
+ unsigned long current_offset;
+{
+ asection *section;
+ int found;
+
+ /* som_mkobject will set bfd_error if som_mkobject fails. */
+ if (som_mkobject (abfd) != true)
+ return 0;
+
+ /* Set BFD flags based on what information is available in the SOM. */
+ abfd->flags = BFD_NO_FLAGS;
+ if (file_hdrp->symbol_total)
+ abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+
+ switch (file_hdrp->a_magic)
+ {
+ case DEMAND_MAGIC:
+ abfd->flags |= (D_PAGED | WP_TEXT | EXEC_P);
+ break;
+ case SHARE_MAGIC:
+ abfd->flags |= (WP_TEXT | EXEC_P);
+ break;
+ case EXEC_MAGIC:
+ abfd->flags |= (EXEC_P);
+ break;
+ case RELOC_MAGIC:
+ abfd->flags |= HAS_RELOC;
+ break;
+#ifdef SHL_MAGIC
+ case SHL_MAGIC:
+#endif
+#ifdef DL_MAGIC
+ case DL_MAGIC:
+#endif
+ abfd->flags |= DYNAMIC;
+ break;
+
+ default:
+ break;
+ }
+
+ /* Allocate space to hold the saved exec header information. */
+ obj_som_exec_data (abfd) = (struct som_exec_data *)
+ bfd_zalloc (abfd, sizeof (struct som_exec_data ));
+ if (obj_som_exec_data (abfd) == NULL)
+ return NULL;
+
+ /* The braindamaged OSF1 linker switched exec_flags and exec_entry!
+
+ We used to identify OSF1 binaries based on NEW_VERSION_ID, but
+ apparently the latest HPUX linker is using NEW_VERSION_ID now.
+
+ It's about time, OSF has used the new id since at least 1992;
+ HPUX didn't start till nearly 1995!.
+
+ The new approach examines the entry field. If it's zero or not 4
+ byte aligned then it's not a proper code address and we guess it's
+ really the executable flags. */
+ found = 0;
+ for (section = abfd->sections; section; section = section->next)
+ {
+ if ((section->flags & SEC_CODE) == 0)
+ continue;
+ if (aux_hdrp->exec_entry >= section->vma
+ && aux_hdrp->exec_entry < section->vma + section->_cooked_size)
+ found = 1;
+ }
+ if (aux_hdrp->exec_entry == 0
+ || (aux_hdrp->exec_entry & 0x3) != 0
+ || ! found)
+ {
+ bfd_get_start_address (abfd) = aux_hdrp->exec_flags;
+ obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_entry;
+ }
+ else
+ {
+ bfd_get_start_address (abfd) = aux_hdrp->exec_entry + current_offset;
+ obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags;
+ }
+
+ bfd_default_set_arch_mach (abfd, bfd_arch_hppa, pa10);
+ bfd_get_symcount (abfd) = file_hdrp->symbol_total;
+
+ /* Initialize the saved symbol table and string table to NULL.
+ Save important offsets and sizes from the SOM header into
+ the BFD. */
+ obj_som_stringtab (abfd) = (char *) NULL;
+ obj_som_symtab (abfd) = (som_symbol_type *) NULL;
+ obj_som_sorted_syms (abfd) = NULL;
+ obj_som_stringtab_size (abfd) = file_hdrp->symbol_strings_size;
+ obj_som_sym_filepos (abfd) = file_hdrp->symbol_location + current_offset;
+ obj_som_str_filepos (abfd) = (file_hdrp->symbol_strings_location
+ + current_offset);
+ obj_som_reloc_filepos (abfd) = (file_hdrp->fixup_request_location
+ + current_offset);
+ obj_som_exec_data (abfd)->system_id = file_hdrp->system_id;
+
+ return abfd->xvec;
+}
+
+/* Convert all of the space and subspace info into BFD sections. Each space
+ contains a number of subspaces, which in turn describe the mapping between
+ regions of the exec file, and the address space that the program runs in.
+ BFD sections which correspond to spaces will overlap the sections for the
+ associated subspaces. */
+
+static boolean
+setup_sections (abfd, file_hdr, current_offset)
+ bfd *abfd;
+ struct header *file_hdr;
+ unsigned long current_offset;
+{
+ char *space_strings;
+ unsigned int space_index, i;
+ unsigned int total_subspaces = 0;
+ asection **subspace_sections, *section;
+
+ /* First, read in space names */
+
+ space_strings = bfd_malloc (file_hdr->space_strings_size);
+ if (!space_strings && file_hdr->space_strings_size != 0)
+ goto error_return;
+
+ if (bfd_seek (abfd, current_offset + file_hdr->space_strings_location,
+ SEEK_SET) < 0)
+ goto error_return;
+ if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd)
+ != file_hdr->space_strings_size)
+ goto error_return;
+
+ /* Loop over all of the space dictionaries, building up sections */
+ for (space_index = 0; space_index < file_hdr->space_total; space_index++)
+ {
+ struct space_dictionary_record space;
+ struct subspace_dictionary_record subspace, save_subspace;
+ int subspace_index;
+ asection *space_asect;
+ char *newname;
+
+ /* Read the space dictionary element */
+ if (bfd_seek (abfd,
+ (current_offset + file_hdr->space_location
+ + space_index * sizeof space),
+ SEEK_SET) < 0)
+ goto error_return;
+ if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space)
+ goto error_return;
+
+ /* Setup the space name string */
+ space.name.n_name = space.name.n_strx + space_strings;
+
+ /* Make a section out of it */
+ newname = bfd_alloc (abfd, strlen (space.name.n_name) + 1);
+ if (!newname)
+ goto error_return;
+ strcpy (newname, space.name.n_name);
+
+ space_asect = bfd_make_section_anyway (abfd, newname);
+ if (!space_asect)
+ goto error_return;
+
+ if (space.is_loadable == 0)
+ space_asect->flags |= SEC_DEBUGGING;
+
+ /* Set up all the attributes for the space. */
+ if (bfd_som_set_section_attributes (space_asect, space.is_defined,
+ space.is_private, space.sort_key,
+ space.space_number) == false)
+ goto error_return;
+
+ /* If the space has no subspaces, then we're done. */
+ if (space.subspace_quantity == 0)
+ continue;
+
+ /* Now, read in the first subspace for this space */
+ if (bfd_seek (abfd,
+ (current_offset + file_hdr->subspace_location
+ + space.subspace_index * sizeof subspace),
+ SEEK_SET) < 0)
+ goto error_return;
+ if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace)
+ goto error_return;
+ /* Seek back to the start of the subspaces for loop below */
+ if (bfd_seek (abfd,
+ (current_offset + file_hdr->subspace_location
+ + space.subspace_index * sizeof subspace),
+ SEEK_SET) < 0)
+ goto error_return;
+
+ /* Setup the start address and file loc from the first subspace record */
+ space_asect->vma = subspace.subspace_start;
+ space_asect->filepos = subspace.file_loc_init_value + current_offset;
+ space_asect->alignment_power = log2 (subspace.alignment);
+ if (space_asect->alignment_power == -1)
+ goto error_return;
+
+ /* Initialize save_subspace so we can reliably determine if this
+ loop placed any useful values into it. */
+ memset (&save_subspace, 0, sizeof (struct subspace_dictionary_record));
+
+ /* Loop over the rest of the subspaces, building up more sections */
+ for (subspace_index = 0; subspace_index < space.subspace_quantity;
+ subspace_index++)
+ {
+ asection *subspace_asect;
+
+ /* Read in the next subspace */
+ if (bfd_read (&subspace, 1, sizeof subspace, abfd)
+ != sizeof subspace)
+ goto error_return;
+
+ /* Setup the subspace name string */
+ subspace.name.n_name = subspace.name.n_strx + space_strings;
+
+ newname = bfd_alloc (abfd, strlen (subspace.name.n_name) + 1);
+ if (!newname)
+ goto error_return;
+ strcpy (newname, subspace.name.n_name);
+
+ /* Make a section out of this subspace */
+ subspace_asect = bfd_make_section_anyway (abfd, newname);
+ if (!subspace_asect)
+ goto error_return;
+
+ /* Store private information about the section. */
+ if (bfd_som_set_subsection_attributes (subspace_asect, space_asect,
+ subspace.access_control_bits,
+ subspace.sort_key,
+ subspace.quadrant) == false)
+ goto error_return;
+
+ /* Keep an easy mapping between subspaces and sections.
+ Note we do not necessarily read the subspaces in the
+ same order in which they appear in the object file.
+
+ So to make the target index come out correctly, we
+ store the location of the subspace header in target
+ index, then sort using the location of the subspace
+ header as the key. Then we can assign correct
+ subspace indices. */
+ total_subspaces++;
+ subspace_asect->target_index = bfd_tell (abfd) - sizeof (subspace);
+
+ /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
+ by the access_control_bits in the subspace header. */
+ switch (subspace.access_control_bits >> 4)
+ {
+ /* Readonly data. */
+ case 0x0:
+ subspace_asect->flags |= SEC_DATA | SEC_READONLY;
+ break;
+
+ /* Normal data. */
+ case 0x1:
+ subspace_asect->flags |= SEC_DATA;
+ break;
+
+ /* Readonly code and the gateways.
+ Gateways have other attributes which do not map
+ into anything BFD knows about. */
+ case 0x2:
+ case 0x4:
+ case 0x5:
+ case 0x6:
+ case 0x7:
+ subspace_asect->flags |= SEC_CODE | SEC_READONLY;
+ break;
+
+ /* dynamic (writable) code. */
+ case 0x3:
+ subspace_asect->flags |= SEC_CODE;
+ break;
+ }
+
+ if (subspace.dup_common || subspace.is_common)
+ subspace_asect->flags |= SEC_IS_COMMON;
+ else if (subspace.subspace_length > 0)
+ subspace_asect->flags |= SEC_HAS_CONTENTS;
+
+ if (subspace.is_loadable)
+ subspace_asect->flags |= SEC_ALLOC | SEC_LOAD;
+ else
+ subspace_asect->flags |= SEC_DEBUGGING;
+
+ if (subspace.code_only)
+ subspace_asect->flags |= SEC_CODE;
+
+ /* Both file_loc_init_value and initialization_length will
+ be zero for a BSS like subspace. */
+ if (subspace.file_loc_init_value == 0
+ && subspace.initialization_length == 0)
+ subspace_asect->flags &= ~(SEC_DATA | SEC_LOAD | SEC_HAS_CONTENTS);
+
+ /* This subspace has relocations.
+ The fixup_request_quantity is a byte count for the number of
+ entries in the relocation stream; it is not the actual number
+ of relocations in the subspace. */
+ if (subspace.fixup_request_quantity != 0)
+ {
+ subspace_asect->flags |= SEC_RELOC;
+ subspace_asect->rel_filepos = subspace.fixup_request_index;
+ som_section_data (subspace_asect)->reloc_size
+ = subspace.fixup_request_quantity;
+ /* We can not determine this yet. When we read in the
+ relocation table the correct value will be filled in. */
+ subspace_asect->reloc_count = -1;
+ }
+
+ /* Update save_subspace if appropriate. */
+ if (subspace.file_loc_init_value > save_subspace.file_loc_init_value)
+ save_subspace = subspace;
+
+ subspace_asect->vma = subspace.subspace_start;
+ subspace_asect->_cooked_size = subspace.subspace_length;
+ subspace_asect->_raw_size = subspace.subspace_length;
+ subspace_asect->filepos = (subspace.file_loc_init_value
+ + current_offset);
+ subspace_asect->alignment_power = log2 (subspace.alignment);
+ if (subspace_asect->alignment_power == -1)
+ goto error_return;
+ }
+
+ /* This can happen for a .o which defines symbols in otherwise
+ empty subspaces. */
+ if (!save_subspace.file_loc_init_value)
+ {
+ space_asect->_cooked_size = 0;
+ space_asect->_raw_size = 0;
+ }
+ else
+ {
+ /* Setup the sizes for the space section based upon the info in the
+ last subspace of the space. */
+ space_asect->_cooked_size = (save_subspace.subspace_start
+ - space_asect->vma
+ + save_subspace.subspace_length);
+ space_asect->_raw_size = (save_subspace.file_loc_init_value
+ - space_asect->filepos
+ + save_subspace.initialization_length);
+ }
+ }
+ /* Now that we've read in all the subspace records, we need to assign
+ a target index to each subspace. */
+ subspace_sections = (asection **) bfd_malloc (total_subspaces
+ * sizeof (asection *));
+ if (subspace_sections == NULL)
+ goto error_return;
+
+ for (i = 0, section = abfd->sections; section; section = section->next)
+ {
+ if (!som_is_subspace (section))
+ continue;
+
+ subspace_sections[i] = section;
+ i++;
+ }
+ qsort (subspace_sections, total_subspaces,
+ sizeof (asection *), compare_subspaces);
+
+ /* subspace_sections is now sorted in the order in which the subspaces
+ appear in the object file. Assign an index to each one now. */
+ for (i = 0; i < total_subspaces; i++)
+ subspace_sections[i]->target_index = i;
+
+ if (space_strings != NULL)
+ free (space_strings);
+
+ if (subspace_sections != NULL)
+ free (subspace_sections);
+
+ return true;
+
+ error_return:
+ if (space_strings != NULL)
+ free (space_strings);
+
+ if (subspace_sections != NULL)
+ free (subspace_sections);
+ return false;
+}
+
+/* Read in a SOM object and make it into a BFD. */
+
+static const bfd_target *
+som_object_p (abfd)
+ bfd *abfd;
+{
+ struct header file_hdr;
+ struct som_exec_auxhdr aux_hdr;
+ unsigned long current_offset = 0;
+ struct lst_header lst_header;
+ struct som_entry som_entry;
+#define ENTRY_SIZE sizeof(struct som_entry)
+
+ if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (!_PA_RISC_ID (file_hdr.system_id))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ switch (file_hdr.a_magic)
+ {
+ case RELOC_MAGIC:
+ case EXEC_MAGIC:
+ case SHARE_MAGIC:
+ case DEMAND_MAGIC:
+#ifdef DL_MAGIC
+ case DL_MAGIC:
+#endif
+#ifdef SHL_MAGIC
+ case SHL_MAGIC:
+#endif
+#ifdef SHARED_MAGIC_CNX
+ case SHARED_MAGIC_CNX:
+#endif
+ break;
+
+#ifdef EXECLIBMAGIC
+ case EXECLIBMAGIC:
+ /* Read the lst header and determine where the SOM directory begins */
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (bfd_read ((PTR) & lst_header, 1, SLSTHDR, abfd) != SLSTHDR)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* Position to and read the first directory entry */
+
+ if (bfd_seek (abfd, lst_header.dir_loc, SEEK_SET) < 0)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (bfd_read ((PTR) & som_entry, 1, ENTRY_SIZE, abfd) != ENTRY_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* Now position to the first SOM */
+
+ if (bfd_seek (abfd, som_entry.location, SEEK_SET) < 0)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ current_offset = som_entry.location;
+
+ /* And finally, re-read the som header */
+
+ if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ break;
+#endif
+
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (file_hdr.version_id != VERSION_ID
+ && file_hdr.version_id != NEW_VERSION_ID)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* If the aux_header_size field in the file header is zero, then this
+ object is an incomplete executable (a .o file). Do not try to read
+ a non-existant auxiliary header. */
+ memset (&aux_hdr, 0, sizeof (struct som_exec_auxhdr));
+ if (file_hdr.aux_header_size != 0)
+ {
+ if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ }
+
+ if (!setup_sections (abfd, &file_hdr, current_offset))
+ {
+ /* setup_sections does not bubble up a bfd error code. */
+ bfd_set_error (bfd_error_bad_value);
+ return 0;
+ }
+
+ /* This appears to be a valid SOM object. Do some initialization. */
+ return som_object_setup (abfd, &file_hdr, &aux_hdr, current_offset);
+}
+
+/* Create a SOM object. */
+
+static boolean
+som_mkobject (abfd)
+ bfd *abfd;
+{
+ /* Allocate memory to hold backend information. */
+ abfd->tdata.som_data = (struct som_data_struct *)
+ bfd_zalloc (abfd, sizeof (struct som_data_struct));
+ if (abfd->tdata.som_data == NULL)
+ return false;
+ return true;
+}
+
+/* Initialize some information in the file header. This routine makes
+ not attempt at doing the right thing for a full executable; it
+ is only meant to handle relocatable objects. */
+
+static boolean
+som_prep_headers (abfd)
+ bfd *abfd;
+{
+ struct header *file_hdr;
+ asection *section;
+
+ /* Make and attach a file header to the BFD. */
+ file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
+ if (file_hdr == NULL)
+ return false;
+ obj_som_file_hdr (abfd) = file_hdr;
+
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ {
+
+ /* Make and attach an exec header to the BFD. */
+ obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *)
+ bfd_zalloc (abfd, sizeof (struct som_exec_auxhdr));
+ if (obj_som_exec_hdr (abfd) == NULL)
+ return false;
+
+ if (abfd->flags & D_PAGED)
+ file_hdr->a_magic = DEMAND_MAGIC;
+ else if (abfd->flags & WP_TEXT)
+ file_hdr->a_magic = SHARE_MAGIC;
+#ifdef SHL_MAGIC
+ else if (abfd->flags & DYNAMIC)
+ file_hdr->a_magic = SHL_MAGIC;
+#endif
+ else
+ file_hdr->a_magic = EXEC_MAGIC;
+ }
+ else
+ file_hdr->a_magic = RELOC_MAGIC;
+
+ /* Only new format SOM is supported. */
+ file_hdr->version_id = NEW_VERSION_ID;
+
+ /* These fields are optional, and embedding timestamps is not always
+ a wise thing to do, it makes comparing objects during a multi-stage
+ bootstrap difficult. */
+ file_hdr->file_time.secs = 0;
+ file_hdr->file_time.nanosecs = 0;
+
+ file_hdr->entry_space = 0;
+ file_hdr->entry_subspace = 0;
+ file_hdr->entry_offset = 0;
+ file_hdr->presumed_dp = 0;
+
+ /* Now iterate over the sections translating information from
+ BFD sections to SOM spaces/subspaces. */
+
+ for (section = abfd->sections; section != NULL; section = section->next)
+ {
+ /* Ignore anything which has not been marked as a space or
+ subspace. */
+ if (!som_is_space (section) && !som_is_subspace (section))
+ continue;
+
+ if (som_is_space (section))
+ {
+ /* Allocate space for the space dictionary. */
+ som_section_data (section)->space_dict
+ = (struct space_dictionary_record *)
+ bfd_zalloc (abfd, sizeof (struct space_dictionary_record));
+ if (som_section_data (section)->space_dict == NULL)
+ return false;
+ /* Set space attributes. Note most attributes of SOM spaces
+ are set based on the subspaces it contains. */
+ som_section_data (section)->space_dict->loader_fix_index = -1;
+ som_section_data (section)->space_dict->init_pointer_index = -1;
+
+ /* Set more attributes that were stuffed away in private data. */
+ som_section_data (section)->space_dict->sort_key =
+ som_section_data (section)->copy_data->sort_key;
+ som_section_data (section)->space_dict->is_defined =
+ som_section_data (section)->copy_data->is_defined;
+ som_section_data (section)->space_dict->is_private =
+ som_section_data (section)->copy_data->is_private;
+ som_section_data (section)->space_dict->space_number =
+ som_section_data (section)->copy_data->space_number;
+ }
+ else
+ {
+ /* Allocate space for the subspace dictionary. */
+ som_section_data (section)->subspace_dict
+ = (struct subspace_dictionary_record *)
+ bfd_zalloc (abfd, sizeof (struct subspace_dictionary_record));
+ if (som_section_data (section)->subspace_dict == NULL)
+ return false;
+
+ /* Set subspace attributes. Basic stuff is done here, additional
+ attributes are filled in later as more information becomes
+ available. */
+ if (section->flags & SEC_IS_COMMON)
+ {
+ som_section_data (section)->subspace_dict->dup_common = 1;
+ som_section_data (section)->subspace_dict->is_common = 1;
+ }
+
+ if (section->flags & SEC_ALLOC)
+ som_section_data (section)->subspace_dict->is_loadable = 1;
+
+ if (section->flags & SEC_CODE)
+ som_section_data (section)->subspace_dict->code_only = 1;
+
+ som_section_data (section)->subspace_dict->subspace_start =
+ section->vma;
+ som_section_data (section)->subspace_dict->subspace_length =
+ bfd_section_size (abfd, section);
+ som_section_data (section)->subspace_dict->initialization_length =
+ bfd_section_size (abfd, section);
+ som_section_data (section)->subspace_dict->alignment =
+ 1 << section->alignment_power;
+
+ /* Set more attributes that were stuffed away in private data. */
+ som_section_data (section)->subspace_dict->sort_key =
+ som_section_data (section)->copy_data->sort_key;
+ som_section_data (section)->subspace_dict->access_control_bits =
+ som_section_data (section)->copy_data->access_control_bits;
+ som_section_data (section)->subspace_dict->quadrant =
+ som_section_data (section)->copy_data->quadrant;
+ }
+ }
+ return true;
+}
+
+/* Return true if the given section is a SOM space, false otherwise. */
+
+static boolean
+som_is_space (section)
+ asection *section;
+{
+ /* If no copy data is available, then it's neither a space nor a
+ subspace. */
+ if (som_section_data (section)->copy_data == NULL)
+ return false;
+
+ /* If the containing space isn't the same as the given section,
+ then this isn't a space. */
+ if (som_section_data (section)->copy_data->container != section
+ && (som_section_data (section)->copy_data->container->output_section
+ != section))
+ return false;
+
+ /* OK. Must be a space. */
+ return true;
+}
+
+/* Return true if the given section is a SOM subspace, false otherwise. */
+
+static boolean
+som_is_subspace (section)
+ asection *section;
+{
+ /* If no copy data is available, then it's neither a space nor a
+ subspace. */
+ if (som_section_data (section)->copy_data == NULL)
+ return false;
+
+ /* If the containing space is the same as the given section,
+ then this isn't a subspace. */
+ if (som_section_data (section)->copy_data->container == section
+ || (som_section_data (section)->copy_data->container->output_section
+ == section))
+ return false;
+
+ /* OK. Must be a subspace. */
+ return true;
+}
+
+/* Return true if the given space containins the given subspace. It
+ is safe to assume space really is a space, and subspace really
+ is a subspace. */
+
+static boolean
+som_is_container (space, subspace)
+ asection *space, *subspace;
+{
+ return (som_section_data (subspace)->copy_data->container == space
+ || (som_section_data (subspace)->copy_data->container->output_section
+ == space));
+}
+
+/* Count and return the number of spaces attached to the given BFD. */
+
+static unsigned long
+som_count_spaces (abfd)
+ bfd *abfd;
+{
+ int count = 0;
+ asection *section;
+
+ for (section = abfd->sections; section != NULL; section = section->next)
+ count += som_is_space (section);
+
+ return count;
+}
+
+/* Count the number of subspaces attached to the given BFD. */
+
+static unsigned long
+som_count_subspaces (abfd)
+ bfd *abfd;
+{
+ int count = 0;
+ asection *section;
+
+ for (section = abfd->sections; section != NULL; section = section->next)
+ count += som_is_subspace (section);
+
+ return count;
+}
+
+/* Return -1, 0, 1 indicating the relative ordering of sym1 and sym2.
+
+ We desire symbols to be ordered starting with the symbol with the
+ highest relocation count down to the symbol with the lowest relocation
+ count. Doing so compacts the relocation stream. */
+
+static int
+compare_syms (arg1, arg2)
+ const PTR arg1;
+ const PTR arg2;
+
+{
+ asymbol **sym1 = (asymbol **) arg1;
+ asymbol **sym2 = (asymbol **) arg2;
+ unsigned int count1, count2;
+
+ /* Get relocation count for each symbol. Note that the count
+ is stored in the udata pointer for section symbols! */
+ if ((*sym1)->flags & BSF_SECTION_SYM)
+ count1 = (*sym1)->udata.i;
+ else
+ count1 = som_symbol_data (*sym1)->reloc_count;
+
+ if ((*sym2)->flags & BSF_SECTION_SYM)
+ count2 = (*sym2)->udata.i;
+ else
+ count2 = som_symbol_data (*sym2)->reloc_count;
+
+ /* Return the appropriate value. */
+ if (count1 < count2)
+ return 1;
+ else if (count1 > count2)
+ return -1;
+ return 0;
+}
+
+/* Return -1, 0, 1 indicating the relative ordering of subspace1
+ and subspace. */
+
+static int
+compare_subspaces (arg1, arg2)
+ const PTR arg1;
+ const PTR arg2;
+
+{
+ asection **subspace1 = (asection **) arg1;
+ asection **subspace2 = (asection **) arg2;
+ unsigned int count1, count2;
+
+ if ((*subspace1)->target_index < (*subspace2)->target_index)
+ return -1;
+ else if ((*subspace2)->target_index < (*subspace1)->target_index)
+ return 1;
+ else
+ return 0;
+}
+
+/* Perform various work in preparation for emitting the fixup stream. */
+
+static void
+som_prep_for_fixups (abfd, syms, num_syms)
+ bfd *abfd;
+ asymbol **syms;
+ unsigned long num_syms;
+{
+ int i;
+ asection *section;
+ asymbol **sorted_syms;
+
+ /* Most SOM relocations involving a symbol have a length which is
+ dependent on the index of the symbol. So symbols which are
+ used often in relocations should have a small index. */
+
+ /* First initialize the counters for each symbol. */
+ for (i = 0; i < num_syms; i++)
+ {
+ /* Handle a section symbol; these have no pointers back to the
+ SOM symbol info. So we just use the udata field to hold the
+ relocation count. */
+ if (som_symbol_data (syms[i]) == NULL
+ || syms[i]->flags & BSF_SECTION_SYM)
+ {
+ syms[i]->flags |= BSF_SECTION_SYM;
+ syms[i]->udata.i = 0;
+ }
+ else
+ som_symbol_data (syms[i])->reloc_count = 0;
+ }
+
+ /* Now that the counters are initialized, make a weighted count
+ of how often a given symbol is used in a relocation. */
+ for (section = abfd->sections; section != NULL; section = section->next)
+ {
+ int i;
+
+ /* Does this section have any relocations? */
+ if (section->reloc_count <= 0)
+ continue;
+
+ /* Walk through each relocation for this section. */
+ for (i = 1; i < section->reloc_count; i++)
+ {
+ arelent *reloc = section->orelocation[i];
+ int scale;
+
+ /* A relocation against a symbol in the *ABS* section really
+ does not have a symbol. Likewise if the symbol isn't associated
+ with any section. */
+ if (reloc->sym_ptr_ptr == NULL
+ || bfd_is_abs_section ((*reloc->sym_ptr_ptr)->section))
+ continue;
+
+ /* Scaling to encourage symbols involved in R_DP_RELATIVE
+ and R_CODE_ONE_SYMBOL relocations to come first. These
+ two relocations have single byte versions if the symbol
+ index is very small. */
+ if (reloc->howto->type == R_DP_RELATIVE
+ || reloc->howto->type == R_CODE_ONE_SYMBOL)
+ scale = 2;
+ else
+ scale = 1;
+
+ /* Handle section symbols by storing the count in the udata
+ field. It will not be used and the count is very important
+ for these symbols. */
+ if ((*reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM)
+ {
+ (*reloc->sym_ptr_ptr)->udata.i =
+ (*reloc->sym_ptr_ptr)->udata.i + scale;
+ continue;
+ }
+
+ /* A normal symbol. Increment the count. */
+ som_symbol_data (*reloc->sym_ptr_ptr)->reloc_count += scale;
+ }
+ }
+
+ /* Sort a copy of the symbol table, rather than the canonical
+ output symbol table. */
+ sorted_syms = (asymbol **) bfd_zalloc (abfd, num_syms * sizeof (asymbol *));
+ memcpy (sorted_syms, syms, num_syms * sizeof (asymbol *));
+ qsort (sorted_syms, num_syms, sizeof (asymbol *), compare_syms);
+ obj_som_sorted_syms (abfd) = sorted_syms;
+
+ /* Compute the symbol indexes, they will be needed by the relocation
+ code. */
+ for (i = 0; i < num_syms; i++)
+ {
+ /* A section symbol. Again, there is no pointer to backend symbol
+ information, so we reuse the udata field again. */
+ if (sorted_syms[i]->flags & BSF_SECTION_SYM)
+ sorted_syms[i]->udata.i = i;
+ else
+ som_symbol_data (sorted_syms[i])->index = i;
+ }
+}
+
+static boolean
+som_write_fixups (abfd, current_offset, total_reloc_sizep)
+ bfd *abfd;
+ unsigned long current_offset;
+ unsigned int *total_reloc_sizep;
+{
+ unsigned int i, j;
+ /* Chunk of memory that we can use as buffer space, then throw
+ away. */
+ unsigned char tmp_space[SOM_TMP_BUFSIZE];
+ unsigned char *p;
+ unsigned int total_reloc_size = 0;
+ unsigned int subspace_reloc_size = 0;
+ unsigned int num_spaces = obj_som_file_hdr (abfd)->space_total;
+ asection *section = abfd->sections;
+
+ memset (tmp_space, 0, SOM_TMP_BUFSIZE);
+ p = tmp_space;
+
+ /* All the fixups for a particular subspace are emitted in a single
+ stream. All the subspaces for a particular space are emitted
+ as a single stream.
+
+ So, to get all the locations correct one must iterate through all the
+ spaces, for each space iterate through its subspaces and output a
+ fixups stream. */
+ for (i = 0; i < num_spaces; i++)
+ {
+ asection *subsection;
+
+ /* Find a space. */
+ while (!som_is_space (section))
+ section = section->next;
+
+ /* Now iterate through each of its subspaces. */
+ for (subsection = abfd->sections;
+ subsection != NULL;
+ subsection = subsection->next)
+ {
+ int reloc_offset, current_rounding_mode;
+
+ /* Find a subspace of this space. */
+ if (!som_is_subspace (subsection)
+ || !som_is_container (section, subsection))
+ continue;
+
+ /* If this subspace does not have real data, then we are
+ finised with it. */
+ if ((subsection->flags & SEC_HAS_CONTENTS) == 0)
+ {
+ som_section_data (subsection)->subspace_dict->fixup_request_index
+ = -1;
+ continue;
+ }
+
+ /* This subspace has some relocations. Put the relocation stream
+ index into the subspace record. */
+ som_section_data (subsection)->subspace_dict->fixup_request_index
+ = total_reloc_size;
+
+ /* To make life easier start over with a clean slate for
+ each subspace. Seek to the start of the relocation stream
+ for this subspace in preparation for writing out its fixup
+ stream. */
+ if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) < 0)
+ return false;
+
+ /* Buffer space has already been allocated. Just perform some
+ initialization here. */
+ p = tmp_space;
+ subspace_reloc_size = 0;
+ reloc_offset = 0;
+ som_initialize_reloc_queue (reloc_queue);
+ current_rounding_mode = R_N_MODE;
+
+ /* Translate each BFD relocation into one or more SOM
+ relocations. */
+ for (j = 0; j < subsection->reloc_count; j++)
+ {
+ arelent *bfd_reloc = subsection->orelocation[j];
+ unsigned int skip;
+ int sym_num;
+
+ /* Get the symbol number. Remember it's stored in a
+ special place for section symbols. */
+ if ((*bfd_reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM)
+ sym_num = (*bfd_reloc->sym_ptr_ptr)->udata.i;
+ else
+ sym_num = som_symbol_data (*bfd_reloc->sym_ptr_ptr)->index;
+
+ /* If there is not enough room for the next couple relocations,
+ then dump the current buffer contents now. Also reinitialize
+ the relocation queue.
+
+ No single BFD relocation could ever translate into more
+ than 100 bytes of SOM relocations (20bytes is probably the
+ upper limit, but leave lots of space for growth). */
+ if (p - tmp_space + 100 > SOM_TMP_BUFSIZE)
+ {
+ if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
+ != p - tmp_space)
+ return false;
+
+ p = tmp_space;
+ som_initialize_reloc_queue (reloc_queue);
+ }
+
+ /* Emit R_NO_RELOCATION fixups to map any bytes which were
+ skipped. */
+ skip = bfd_reloc->address - reloc_offset;
+ p = som_reloc_skip (abfd, skip, p,
+ &subspace_reloc_size, reloc_queue);
+
+ /* Update reloc_offset for the next iteration.
+
+ Many relocations do not consume input bytes. They
+ are markers, or set state necessary to perform some
+ later relocation. */
+ switch (bfd_reloc->howto->type)
+ {
+ case R_ENTRY:
+ case R_ALT_ENTRY:
+ case R_EXIT:
+ case R_N_MODE:
+ case R_S_MODE:
+ case R_D_MODE:
+ case R_R_MODE:
+ case R_FSEL:
+ case R_LSEL:
+ case R_RSEL:
+ case R_COMP1:
+ case R_COMP2:
+ case R_BEGIN_BRTAB:
+ case R_END_BRTAB:
+ case R_BEGIN_TRY:
+ case R_END_TRY:
+ case R_N0SEL:
+ case R_N1SEL:
+ reloc_offset = bfd_reloc->address;
+ break;
+
+ default:
+ reloc_offset = bfd_reloc->address + 4;
+ break;
+ }
+
+ /* Now the actual relocation we care about. */
+ switch (bfd_reloc->howto->type)
+ {
+ case R_PCREL_CALL:
+ case R_ABS_CALL:
+ p = som_reloc_call (abfd, p, &subspace_reloc_size,
+ bfd_reloc, sym_num, reloc_queue);
+ break;
+
+ case R_CODE_ONE_SYMBOL:
+ case R_DP_RELATIVE:
+ /* Account for any addend. */
+ if (bfd_reloc->addend)
+ p = som_reloc_addend (abfd, bfd_reloc->addend, p,
+ &subspace_reloc_size, reloc_queue);
+
+ if (sym_num < 0x20)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type + sym_num, p);
+ subspace_reloc_size += 1;
+ p += 1;
+ }
+ else if (sym_num < 0x100)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type + 32, p);
+ bfd_put_8 (abfd, sym_num, p + 1);
+ p = try_prev_fixup (abfd, &subspace_reloc_size, p,
+ 2, reloc_queue);
+ }
+ else if (sym_num < 0x10000000)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type + 33, p);
+ bfd_put_8 (abfd, sym_num >> 16, p + 1);
+ bfd_put_16 (abfd, sym_num, p + 2);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 4, reloc_queue);
+ }
+ else
+ abort ();
+ break;
+
+ case R_DATA_ONE_SYMBOL:
+ case R_DATA_PLABEL:
+ case R_CODE_PLABEL:
+ case R_DLT_REL:
+ /* Account for any addend using R_DATA_OVERRIDE. */
+ if (bfd_reloc->howto->type != R_DATA_ONE_SYMBOL
+ && bfd_reloc->addend)
+ p = som_reloc_addend (abfd, bfd_reloc->addend, p,
+ &subspace_reloc_size, reloc_queue);
+
+ if (sym_num < 0x100)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ bfd_put_8 (abfd, sym_num, p + 1);
+ p = try_prev_fixup (abfd, &subspace_reloc_size, p,
+ 2, reloc_queue);
+ }
+ else if (sym_num < 0x10000000)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type + 1, p);
+ bfd_put_8 (abfd, sym_num >> 16, p + 1);
+ bfd_put_16 (abfd, sym_num, p + 2);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 4, reloc_queue);
+ }
+ else
+ abort ();
+ break;
+
+ case R_ENTRY:
+ {
+ int tmp;
+ arelent *tmp_reloc = NULL;
+ bfd_put_8 (abfd, R_ENTRY, p);
+
+ /* R_ENTRY relocations have 64 bits of associated
+ data. Unfortunately the addend field of a bfd
+ relocation is only 32 bits. So, we split up
+ the 64bit unwind information and store part in
+ the R_ENTRY relocation, and the rest in the R_EXIT
+ relocation. */
+ bfd_put_32 (abfd, bfd_reloc->addend, p + 1);
+
+ /* Find the next R_EXIT relocation. */
+ for (tmp = j; tmp < subsection->reloc_count; tmp++)
+ {
+ tmp_reloc = subsection->orelocation[tmp];
+ if (tmp_reloc->howto->type == R_EXIT)
+ break;
+ }
+
+ if (tmp == subsection->reloc_count)
+ abort ();
+
+ bfd_put_32 (abfd, tmp_reloc->addend, p + 5);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 9, reloc_queue);
+ break;
+ }
+
+ case R_N_MODE:
+ case R_S_MODE:
+ case R_D_MODE:
+ case R_R_MODE:
+ /* If this relocation requests the current rounding
+ mode, then it is redundant. */
+ if (bfd_reloc->howto->type != current_rounding_mode)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ subspace_reloc_size += 1;
+ p += 1;
+ current_rounding_mode = bfd_reloc->howto->type;
+ }
+ break;
+
+ case R_EXIT:
+ case R_ALT_ENTRY:
+ case R_FSEL:
+ case R_LSEL:
+ case R_RSEL:
+ case R_BEGIN_BRTAB:
+ case R_END_BRTAB:
+ case R_BEGIN_TRY:
+ case R_N0SEL:
+ case R_N1SEL:
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ subspace_reloc_size += 1;
+ p += 1;
+ break;
+
+ case R_END_TRY:
+ /* The end of a exception handling region. The reloc's
+ addend contains the offset of the exception handling
+ code. */
+ if (bfd_reloc->addend == 0)
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ else if (bfd_reloc->addend < 1024)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type + 1, p);
+ bfd_put_8 (abfd, bfd_reloc->addend / 4, p + 1);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 2, reloc_queue);
+ }
+ else
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type + 2, p);
+ bfd_put_8 (abfd, (bfd_reloc->addend / 4) >> 16, p + 1);
+ bfd_put_16 (abfd, bfd_reloc->addend / 4, p + 2);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 4, reloc_queue);
+ }
+ break;
+
+ case R_COMP1:
+ /* The only time we generate R_COMP1, R_COMP2 and
+ R_CODE_EXPR relocs is for the difference of two
+ symbols. Hence we can cheat here. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ bfd_put_8 (abfd, 0x44, p + 1);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 2, reloc_queue);
+ break;
+
+ case R_COMP2:
+ /* The only time we generate R_COMP1, R_COMP2 and
+ R_CODE_EXPR relocs is for the difference of two
+ symbols. Hence we can cheat here. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ bfd_put_8 (abfd, 0x80, p + 1);
+ bfd_put_8 (abfd, sym_num >> 16, p + 2);
+ bfd_put_16 (abfd, sym_num, p + 3);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 5, reloc_queue);
+ break;
+
+ case R_CODE_EXPR:
+ case R_DATA_EXPR:
+ /* The only time we generate R_COMP1, R_COMP2 and
+ R_CODE_EXPR relocs is for the difference of two
+ symbols. Hence we can cheat here. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ subspace_reloc_size += 1;
+ p += 1;
+ break;
+
+ /* Put a "R_RESERVED" relocation in the stream if
+ we hit something we do not understand. The linker
+ will complain loudly if this ever happens. */
+ default:
+ bfd_put_8 (abfd, 0xff, p);
+ subspace_reloc_size += 1;
+ p += 1;
+ break;
+ }
+ }
+
+ /* Last BFD relocation for a subspace has been processed.
+ Map the rest of the subspace with R_NO_RELOCATION fixups. */
+ p = som_reloc_skip (abfd, bfd_section_size (abfd, subsection)
+ - reloc_offset,
+ p, &subspace_reloc_size, reloc_queue);
+
+ /* Scribble out the relocations. */
+ if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
+ != p - tmp_space)
+ return false;
+ p = tmp_space;
+
+ total_reloc_size += subspace_reloc_size;
+ som_section_data (subsection)->subspace_dict->fixup_request_quantity
+ = subspace_reloc_size;
+ }
+ section = section->next;
+ }
+ *total_reloc_sizep = total_reloc_size;
+ return true;
+}
+
+/* Write out the space/subspace string table. */
+
+static boolean
+som_write_space_strings (abfd, current_offset, string_sizep)
+ bfd *abfd;
+ unsigned long current_offset;
+ unsigned int *string_sizep;
+{
+ /* Chunk of memory that we can use as buffer space, then throw
+ away. */
+ unsigned char tmp_space[SOM_TMP_BUFSIZE];
+ unsigned char *p;
+ unsigned int strings_size = 0;
+ asection *section;
+
+ memset (tmp_space, 0, SOM_TMP_BUFSIZE);
+ p = tmp_space;
+
+ /* Seek to the start of the space strings in preparation for writing
+ them out. */
+ if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ return false;
+
+ /* Walk through all the spaces and subspaces (order is not important)
+ building up and writing string table entries for their names. */
+ for (section = abfd->sections; section != NULL; section = section->next)
+ {
+ int length;
+
+ /* Only work with space/subspaces; avoid any other sections
+ which might have been made (.text for example). */
+ if (!som_is_space (section) && !som_is_subspace (section))
+ continue;
+
+ /* Get the length of the space/subspace name. */
+ length = strlen (section->name);
+
+ /* If there is not enough room for the next entry, then dump the
+ current buffer contents now. Each entry will take 4 bytes to
+ hold the string length + the string itself + null terminator. */
+ if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE)
+ {
+ if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
+ != p - tmp_space)
+ return false;
+ /* Reset to beginning of the buffer space. */
+ p = tmp_space;
+ }
+
+ /* First element in a string table entry is the length of the
+ string. Alignment issues are already handled. */
+ bfd_put_32 (abfd, length, p);
+ p += 4;
+ strings_size += 4;
+
+ /* Record the index in the space/subspace records. */
+ if (som_is_space (section))
+ som_section_data (section)->space_dict->name.n_strx = strings_size;
+ else
+ som_section_data (section)->subspace_dict->name.n_strx = strings_size;
+
+ /* Next comes the string itself + a null terminator. */
+ strcpy (p, section->name);
+ p += length + 1;
+ strings_size += length + 1;
+
+ /* Always align up to the next word boundary. */
+ while (strings_size % 4)
+ {
+ bfd_put_8 (abfd, 0, p);
+ p++;
+ strings_size++;
+ }
+ }
+
+ /* Done with the space/subspace strings. Write out any information
+ contained in a partial block. */
+ if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
+ return false;
+ *string_sizep = strings_size;
+ return true;
+}
+
+/* Write out the symbol string table. */
+
+static boolean
+som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
+ compilation_unit)
+ bfd *abfd;
+ unsigned long current_offset;
+ asymbol **syms;
+ unsigned int num_syms;
+ unsigned int *string_sizep;
+ COMPUNIT *compilation_unit;
+{
+ unsigned int i;
+
+ /* Chunk of memory that we can use as buffer space, then throw
+ away. */
+ unsigned char tmp_space[SOM_TMP_BUFSIZE];
+ unsigned char *p;
+ unsigned int strings_size = 0;
+ unsigned char *comp[4];
+
+ /* This gets a bit gruesome because of the compilation unit. The
+ strings within the compilation unit are part of the symbol
+ strings, but don't have symbol_dictionary entries. So, manually
+ write them and update the compliation unit header. On input, the
+ compilation unit header contains local copies of the strings.
+ Move them aside. */
+ if (compilation_unit)
+ {
+ comp[0] = compilation_unit->name.n_name;
+ comp[1] = compilation_unit->language_name.n_name;
+ comp[2] = compilation_unit->product_id.n_name;
+ comp[3] = compilation_unit->version_id.n_name;
+ }
+
+ memset (tmp_space, 0, SOM_TMP_BUFSIZE);
+ p = tmp_space;
+
+ /* Seek to the start of the space strings in preparation for writing
+ them out. */
+ if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ return false;
+
+ if (compilation_unit)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ int length = strlen (comp[i]);
+
+ /* If there is not enough room for the next entry, then dump
+ the current buffer contents now. */
+ if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE)
+ {
+ if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
+ != p - tmp_space)
+ return false;
+ /* Reset to beginning of the buffer space. */
+ p = tmp_space;
+ }
+
+ /* First element in a string table entry is the length of
+ the string. This must always be 4 byte aligned. This is
+ also an appropriate time to fill in the string index
+ field in the symbol table entry. */
+ bfd_put_32 (abfd, length, p);
+ strings_size += 4;
+ p += 4;
+
+ /* Next comes the string itself + a null terminator. */
+ strcpy (p, comp[i]);
+
+ switch (i)
+ {
+ case 0:
+ obj_som_compilation_unit (abfd)->name.n_strx = strings_size;
+ break;
+ case 1:
+ obj_som_compilation_unit (abfd)->language_name.n_strx =
+ strings_size;
+ break;
+ case 2:
+ obj_som_compilation_unit (abfd)->product_id.n_strx =
+ strings_size;
+ break;
+ case 3:
+ obj_som_compilation_unit (abfd)->version_id.n_strx =
+ strings_size;
+ break;
+ }
+
+ p += length + 1;
+ strings_size += length + 1;
+
+ /* Always align up to the next word boundary. */
+ while (strings_size % 4)
+ {
+ bfd_put_8 (abfd, 0, p);
+ strings_size++;
+ p++;
+ }
+ }
+ }
+
+ for (i = 0; i < num_syms; i++)
+ {
+ int length = strlen (syms[i]->name);
+
+ /* If there is not enough room for the next entry, then dump the
+ current buffer contents now. */
+ if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE)
+ {
+ if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
+ != p - tmp_space)
+ return false;
+ /* Reset to beginning of the buffer space. */
+ p = tmp_space;
+ }
+
+ /* First element in a string table entry is the length of the
+ string. This must always be 4 byte aligned. This is also
+ an appropriate time to fill in the string index field in the
+ symbol table entry. */
+ bfd_put_32 (abfd, length, p);
+ strings_size += 4;
+ p += 4;
+
+ /* Next comes the string itself + a null terminator. */
+ strcpy (p, syms[i]->name);
+
+ som_symbol_data(syms[i])->stringtab_offset = strings_size;
+ p += length + 1;
+ strings_size += length + 1;
+
+ /* Always align up to the next word boundary. */
+ while (strings_size % 4)
+ {
+ bfd_put_8 (abfd, 0, p);
+ strings_size++;
+ p++;
+ }
+ }
+
+ /* Scribble out any partial block. */
+ if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
+ return false;
+
+ *string_sizep = strings_size;
+ return true;
+}
+
+/* Compute variable information to be placed in the SOM headers,
+ space/subspace dictionaries, relocation streams, etc. Begin
+ writing parts of the object file. */
+
+static boolean
+som_begin_writing (abfd)
+ bfd *abfd;
+{
+ unsigned long current_offset = 0;
+ int strings_size = 0;
+ unsigned int total_reloc_size = 0;
+ unsigned long num_spaces, num_subspaces, i;
+ asection *section;
+ unsigned int total_subspaces = 0;
+ struct som_exec_auxhdr *exec_header = NULL;
+
+ /* The file header will always be first in an object file,
+ everything else can be in random locations. To keep things
+ "simple" BFD will lay out the object file in the manner suggested
+ by the PRO ABI for PA-RISC Systems. */
+
+ /* Before any output can really begin offsets for all the major
+ portions of the object file must be computed. So, starting
+ with the initial file header compute (and sometimes write)
+ each portion of the object file. */
+
+ /* Make room for the file header, it's contents are not complete
+ yet, so it can not be written at this time. */
+ current_offset += sizeof (struct header);
+
+ /* Any auxiliary headers will follow the file header. Right now
+ we support only the copyright and version headers. */
+ obj_som_file_hdr (abfd)->aux_header_location = current_offset;
+ obj_som_file_hdr (abfd)->aux_header_size = 0;
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ {
+ /* Parts of the exec header will be filled in later, so
+ delay writing the header itself. Fill in the defaults,
+ and write it later. */
+ current_offset += sizeof (struct som_exec_auxhdr);
+ obj_som_file_hdr (abfd)->aux_header_size
+ += sizeof (struct som_exec_auxhdr);
+ exec_header = obj_som_exec_hdr (abfd);
+ exec_header->som_auxhdr.type = EXEC_AUX_ID;
+ exec_header->som_auxhdr.length = 40;
+ }
+ if (obj_som_version_hdr (abfd) != NULL)
+ {
+ unsigned int len;
+
+ if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ return false;
+
+ /* Write the aux_id structure and the string length. */
+ len = sizeof (struct aux_id) + sizeof (unsigned int);
+ obj_som_file_hdr (abfd)->aux_header_size += len;
+ current_offset += len;
+ if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len)
+ return false;
+
+ /* Write the version string. */
+ len = obj_som_version_hdr (abfd)->header_id.length - sizeof (int);
+ obj_som_file_hdr (abfd)->aux_header_size += len;
+ current_offset += len;
+ if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string,
+ len, 1, abfd) != len)
+ return false;
+ }
+
+ if (obj_som_copyright_hdr (abfd) != NULL)
+ {
+ unsigned int len;
+
+ if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ return false;
+
+ /* Write the aux_id structure and the string length. */
+ len = sizeof (struct aux_id) + sizeof (unsigned int);
+ obj_som_file_hdr (abfd)->aux_header_size += len;
+ current_offset += len;
+ if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len)
+ return false;
+
+ /* Write the copyright string. */
+ len = obj_som_copyright_hdr (abfd)->header_id.length - sizeof (int);
+ obj_som_file_hdr (abfd)->aux_header_size += len;
+ current_offset += len;
+ if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright,
+ len, 1, abfd) != len)
+ return false;
+ }
+
+ /* Next comes the initialization pointers; we have no initialization
+ pointers, so current offset does not change. */
+ obj_som_file_hdr (abfd)->init_array_location = current_offset;
+ obj_som_file_hdr (abfd)->init_array_total = 0;
+
+ /* Next are the space records. These are fixed length records.
+
+ Count the number of spaces to determine how much room is needed
+ in the object file for the space records.
+
+ The names of the spaces are stored in a separate string table,
+ and the index for each space into the string table is computed
+ below. Therefore, it is not possible to write the space headers
+ at this time. */
+ num_spaces = som_count_spaces (abfd);
+ obj_som_file_hdr (abfd)->space_location = current_offset;
+ obj_som_file_hdr (abfd)->space_total = num_spaces;
+ current_offset += num_spaces * sizeof (struct space_dictionary_record);
+
+ /* Next are the subspace records. These are fixed length records.
+
+ Count the number of subspaes to determine how much room is needed
+ in the object file for the subspace records.
+
+ A variety if fields in the subspace record are still unknown at
+ this time (index into string table, fixup stream location/size, etc). */
+ num_subspaces = som_count_subspaces (abfd);
+ obj_som_file_hdr (abfd)->subspace_location = current_offset;
+ obj_som_file_hdr (abfd)->subspace_total = num_subspaces;
+ current_offset += num_subspaces * sizeof (struct subspace_dictionary_record);
+
+ /* Next is the string table for the space/subspace names. We will
+ build and write the string table on the fly. At the same time
+ we will fill in the space/subspace name index fields. */
+
+ /* The string table needs to be aligned on a word boundary. */
+ if (current_offset % 4)
+ current_offset += (4 - (current_offset % 4));
+
+ /* Mark the offset of the space/subspace string table in the
+ file header. */
+ obj_som_file_hdr (abfd)->space_strings_location = current_offset;
+
+ /* Scribble out the space strings. */
+ if (som_write_space_strings (abfd, current_offset, &strings_size) == false)
+ return false;
+
+ /* Record total string table size in the header and update the
+ current offset. */
+ obj_som_file_hdr (abfd)->space_strings_size = strings_size;
+ current_offset += strings_size;
+
+ /* Next is the compilation unit. */
+ obj_som_file_hdr (abfd)->compiler_location = current_offset;
+ obj_som_file_hdr (abfd)->compiler_total = 0;
+ if (obj_som_compilation_unit (abfd))
+ {
+ obj_som_file_hdr (abfd)->compiler_total = 1;
+ current_offset += COMPUNITSZ;
+ }
+
+ /* Now compute the file positions for the loadable subspaces, taking
+ care to make sure everything stays properly aligned. */
+
+ section = abfd->sections;
+ for (i = 0; i < num_spaces; i++)
+ {
+ asection *subsection;
+ int first_subspace;
+ unsigned int subspace_offset = 0;
+
+ /* Find a space. */
+ while (!som_is_space (section))
+ section = section->next;
+
+ first_subspace = 1;
+ /* Now look for all its subspaces. */
+ for (subsection = abfd->sections;
+ subsection != NULL;
+ subsection = subsection->next)
+ {
+
+ if (!som_is_subspace (subsection)
+ || !som_is_container (section, subsection)
+ || (subsection->flags & SEC_ALLOC) == 0)
+ continue;
+
+ /* If this is the first subspace in the space, and we are
+ building an executable, then take care to make sure all
+ the alignments are correct and update the exec header. */
+ if (first_subspace
+ && (abfd->flags & (EXEC_P | DYNAMIC)))
+ {
+ /* Demand paged executables have each space aligned to a
+ page boundary. Sharable executables (write-protected
+ text) have just the private (aka data & bss) space aligned
+ to a page boundary. Ugh. Not true for HPUX.
+
+ The HPUX kernel requires the text to always be page aligned
+ within the file regardless of the executable's type. */
+ if (abfd->flags & (D_PAGED | DYNAMIC)
+ || (subsection->flags & SEC_CODE)
+ || ((abfd->flags & WP_TEXT)
+ && (subsection->flags & SEC_DATA)))
+ current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
+
+ /* Update the exec header. */
+ if (subsection->flags & SEC_CODE && exec_header->exec_tfile == 0)
+ {
+ exec_header->exec_tmem = section->vma;
+ exec_header->exec_tfile = current_offset;
+ }
+ if (subsection->flags & SEC_DATA && exec_header->exec_dfile == 0)
+ {
+ exec_header->exec_dmem = section->vma;
+ exec_header->exec_dfile = current_offset;
+ }
+
+ /* Keep track of exactly where we are within a particular
+ space. This is necessary as the braindamaged HPUX
+ loader will create holes between subspaces *and*
+ subspace alignments are *NOT* preserved. What a crock. */
+ subspace_offset = subsection->vma;
+
+ /* Only do this for the first subspace within each space. */
+ first_subspace = 0;
+ }
+ else if (abfd->flags & (EXEC_P | DYNAMIC))
+ {
+ /* The braindamaged HPUX loader may have created a hole
+ between two subspaces. It is *not* sufficient to use
+ the alignment specifications within the subspaces to
+ account for these holes -- I've run into at least one
+ case where the loader left one code subspace unaligned
+ in a final executable.
+
+ To combat this we keep a current offset within each space,
+ and use the subspace vma fields to detect and preserve
+ holes. What a crock!
+
+ ps. This is not necessary for unloadable space/subspaces. */
+ current_offset += subsection->vma - subspace_offset;
+ if (subsection->flags & SEC_CODE)
+ exec_header->exec_tsize += subsection->vma - subspace_offset;
+ else
+ exec_header->exec_dsize += subsection->vma - subspace_offset;
+ subspace_offset += subsection->vma - subspace_offset;
+ }
+
+
+ subsection->target_index = total_subspaces++;
+ /* This is real data to be loaded from the file. */
+ if (subsection->flags & SEC_LOAD)
+ {
+ /* Update the size of the code & data. */
+ if (abfd->flags & (EXEC_P | DYNAMIC)
+ && subsection->flags & SEC_CODE)
+ exec_header->exec_tsize += subsection->_cooked_size;
+ else if (abfd->flags & (EXEC_P | DYNAMIC)
+ && subsection->flags & SEC_DATA)
+ exec_header->exec_dsize += subsection->_cooked_size;
+ som_section_data (subsection)->subspace_dict->file_loc_init_value
+ = current_offset;
+ subsection->filepos = current_offset;
+ current_offset += bfd_section_size (abfd, subsection);
+ subspace_offset += bfd_section_size (abfd, subsection);
+ }
+ /* Looks like uninitialized data. */
+ else
+ {
+ /* Update the size of the bss section. */
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ exec_header->exec_bsize += subsection->_cooked_size;
+
+ som_section_data (subsection)->subspace_dict->file_loc_init_value
+ = 0;
+ som_section_data (subsection)->subspace_dict->
+ initialization_length = 0;
+ }
+ }
+ /* Goto the next section. */
+ section = section->next;
+ }
+
+ /* Finally compute the file positions for unloadable subspaces.
+ If building an executable, start the unloadable stuff on its
+ own page. */
+
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
+
+ obj_som_file_hdr (abfd)->unloadable_sp_location = current_offset;
+ section = abfd->sections;
+ for (i = 0; i < num_spaces; i++)
+ {
+ asection *subsection;
+
+ /* Find a space. */
+ while (!som_is_space (section))
+ section = section->next;
+
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
+
+ /* Now look for all its subspaces. */
+ for (subsection = abfd->sections;
+ subsection != NULL;
+ subsection = subsection->next)
+ {
+
+ if (!som_is_subspace (subsection)
+ || !som_is_container (section, subsection)
+ || (subsection->flags & SEC_ALLOC) != 0)
+ continue;
+
+ subsection->target_index = total_subspaces++;
+ /* This is real data to be loaded from the file. */
+ if ((subsection->flags & SEC_LOAD) == 0)
+ {
+ som_section_data (subsection)->subspace_dict->file_loc_init_value
+ = current_offset;
+ subsection->filepos = current_offset;
+ current_offset += bfd_section_size (abfd, subsection);
+ }
+ /* Looks like uninitialized data. */
+ else
+ {
+ som_section_data (subsection)->subspace_dict->file_loc_init_value
+ = 0;
+ som_section_data (subsection)->subspace_dict->
+ initialization_length = bfd_section_size (abfd, subsection);
+ }
+ }
+ /* Goto the next section. */
+ section = section->next;
+ }
+
+ /* If building an executable, then make sure to seek to and write
+ one byte at the end of the file to make sure any necessary
+ zeros are filled in. Ugh. */
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
+ if (bfd_seek (abfd, current_offset - 1, SEEK_SET) < 0)
+ return false;
+ if (bfd_write ((PTR) "", 1, 1, abfd) != 1)
+ return false;
+
+ obj_som_file_hdr (abfd)->unloadable_sp_size
+ = current_offset - obj_som_file_hdr (abfd)->unloadable_sp_location;
+
+ /* Loader fixups are not supported in any way shape or form. */
+ obj_som_file_hdr (abfd)->loader_fixup_location = 0;
+ obj_som_file_hdr (abfd)->loader_fixup_total = 0;
+
+ /* Done. Store the total size of the SOM so far. */
+ obj_som_file_hdr (abfd)->som_length = current_offset;
+
+ return true;
+}
+
+/* Finally, scribble out the various headers to the disk. */
+
+static boolean
+som_finish_writing (abfd)
+ bfd *abfd;
+{
+ int num_spaces = som_count_spaces (abfd);
+ asymbol **syms = bfd_get_outsymbols (abfd);
+ int i, num_syms, strings_size;
+ int subspace_index = 0;
+ file_ptr location;
+ asection *section;
+ unsigned long current_offset;
+ unsigned int total_reloc_size;
+
+ /* Next is the symbol table. These are fixed length records.
+
+ Count the number of symbols to determine how much room is needed
+ in the object file for the symbol table.
+
+ The names of the symbols are stored in a separate string table,
+ and the index for each symbol name into the string table is computed
+ below. Therefore, it is not possible to write the symbol table
+ at this time.
+
+ These used to be output before the subspace contents, but they
+ were moved here to work around a stupid bug in the hpux linker
+ (fixed in hpux10). */
+ current_offset = obj_som_file_hdr (abfd)->som_length;
+
+ /* Make sure we're on a word boundary. */
+ if (current_offset % 4)
+ current_offset += (4 - (current_offset % 4));
+
+ num_syms = bfd_get_symcount (abfd);
+ obj_som_file_hdr (abfd)->symbol_location = current_offset;
+ obj_som_file_hdr (abfd)->symbol_total = num_syms;
+ current_offset += num_syms * sizeof (struct symbol_dictionary_record);
+
+ /* Next are the symbol strings.
+ Align them to a word boundary. */
+ if (current_offset % 4)
+ current_offset += (4 - (current_offset % 4));
+ obj_som_file_hdr (abfd)->symbol_strings_location = current_offset;
+
+ /* Scribble out the symbol strings. */
+ if (som_write_symbol_strings (abfd, current_offset, syms,
+ num_syms, &strings_size,
+ obj_som_compilation_unit (abfd))
+ == false)
+ return false;
+
+ /* Record total string table size in header and update the
+ current offset. */
+ obj_som_file_hdr (abfd)->symbol_strings_size = strings_size;
+ current_offset += strings_size;
+
+ /* Do prep work before handling fixups. */
+ som_prep_for_fixups (abfd,
+ bfd_get_outsymbols (abfd),
+ bfd_get_symcount (abfd));
+
+ /* At the end of the file is the fixup stream which starts on a
+ word boundary. */
+ if (current_offset % 4)
+ current_offset += (4 - (current_offset % 4));
+ obj_som_file_hdr (abfd)->fixup_request_location = current_offset;
+
+ /* Write the fixups and update fields in subspace headers which
+ relate to the fixup stream. */
+ if (som_write_fixups (abfd, current_offset, &total_reloc_size) == false)
+ return false;
+
+ /* Record the total size of the fixup stream in the file header. */
+ obj_som_file_hdr (abfd)->fixup_request_total = total_reloc_size;
+
+ /* Done. Store the total size of the SOM. */
+ obj_som_file_hdr (abfd)->som_length = current_offset + total_reloc_size;
+
+ /* Now that the symbol table information is complete, build and
+ write the symbol table. */
+ if (som_build_and_write_symbol_table (abfd) == false)
+ return false;
+
+ /* Subspaces are written first so that we can set up information
+ about them in their containing spaces as the subspace is written. */
+
+ /* Seek to the start of the subspace dictionary records. */
+ location = obj_som_file_hdr (abfd)->subspace_location;
+ if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ return false;
+
+ section = abfd->sections;
+ /* Now for each loadable space write out records for its subspaces. */
+ for (i = 0; i < num_spaces; i++)
+ {
+ asection *subsection;
+
+ /* Find a space. */
+ while (!som_is_space (section))
+ section = section->next;
+
+ /* Now look for all its subspaces. */
+ for (subsection = abfd->sections;
+ subsection != NULL;
+ subsection = subsection->next)
+ {
+
+ /* Skip any section which does not correspond to a space
+ or subspace. Or does not have SEC_ALLOC set (and therefore
+ has no real bits on the disk). */
+ if (!som_is_subspace (subsection)
+ || !som_is_container (section, subsection)
+ || (subsection->flags & SEC_ALLOC) == 0)
+ continue;
+
+ /* If this is the first subspace for this space, then save
+ the index of the subspace in its containing space. Also
+ set "is_loadable" in the containing space. */
+
+ if (som_section_data (section)->space_dict->subspace_quantity == 0)
+ {
+ som_section_data (section)->space_dict->is_loadable = 1;
+ som_section_data (section)->space_dict->subspace_index
+ = subspace_index;
+ }
+
+ /* Increment the number of subspaces seen and the number of
+ subspaces contained within the current space. */
+ subspace_index++;
+ som_section_data (section)->space_dict->subspace_quantity++;
+
+ /* Mark the index of the current space within the subspace's
+ dictionary record. */
+ som_section_data (subsection)->subspace_dict->space_index = i;
+
+ /* Dump the current subspace header. */
+ if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
+ sizeof (struct subspace_dictionary_record), 1, abfd)
+ != sizeof (struct subspace_dictionary_record))
+ return false;
+ }
+ /* Goto the next section. */
+ section = section->next;
+ }
+
+ /* Now repeat the process for unloadable subspaces. */
+ section = abfd->sections;
+ /* Now for each space write out records for its subspaces. */
+ for (i = 0; i < num_spaces; i++)
+ {
+ asection *subsection;
+
+ /* Find a space. */
+ while (!som_is_space (section))
+ section = section->next;
+
+ /* Now look for all its subspaces. */
+ for (subsection = abfd->sections;
+ subsection != NULL;
+ subsection = subsection->next)
+ {
+
+ /* Skip any section which does not correspond to a space or
+ subspace, or which SEC_ALLOC set (and therefore handled
+ in the loadable spaces/subspaces code above). */
+
+ if (!som_is_subspace (subsection)
+ || !som_is_container (section, subsection)
+ || (subsection->flags & SEC_ALLOC) != 0)
+ continue;
+
+ /* If this is the first subspace for this space, then save
+ the index of the subspace in its containing space. Clear
+ "is_loadable". */
+
+ if (som_section_data (section)->space_dict->subspace_quantity == 0)
+ {
+ som_section_data (section)->space_dict->is_loadable = 0;
+ som_section_data (section)->space_dict->subspace_index
+ = subspace_index;
+ }
+
+ /* Increment the number of subspaces seen and the number of
+ subspaces contained within the current space. */
+ som_section_data (section)->space_dict->subspace_quantity++;
+ subspace_index++;
+
+ /* Mark the index of the current space within the subspace's
+ dictionary record. */
+ som_section_data (subsection)->subspace_dict->space_index = i;
+
+ /* Dump this subspace header. */
+ if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
+ sizeof (struct subspace_dictionary_record), 1, abfd)
+ != sizeof (struct subspace_dictionary_record))
+ return false;
+ }
+ /* Goto the next section. */
+ section = section->next;
+ }
+
+ /* All the subspace dictiondary records are written, and all the
+ fields are set up in the space dictionary records.
+
+ Seek to the right location and start writing the space
+ dictionary records. */
+ location = obj_som_file_hdr (abfd)->space_location;
+ if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ return false;
+
+ section = abfd->sections;
+ for (i = 0; i < num_spaces; i++)
+ {
+
+ /* Find a space. */
+ while (!som_is_space (section))
+ section = section->next;
+
+ /* Dump its header */
+ if (bfd_write ((PTR) som_section_data (section)->space_dict,
+ sizeof (struct space_dictionary_record), 1, abfd)
+ != sizeof (struct space_dictionary_record))
+ return false;
+
+ /* Goto the next section. */
+ section = section->next;
+ }
+
+ /* Write the compilation unit record if there is one. */
+ if (obj_som_compilation_unit (abfd))
+ {
+ location = obj_som_file_hdr (abfd)->compiler_location;
+ if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ return false;
+
+ if (bfd_write ((PTR) obj_som_compilation_unit (abfd),
+ COMPUNITSZ, 1, abfd) != COMPUNITSZ)
+ return false;
+ }
+
+ /* Setting of the system_id has to happen very late now that copying of
+ BFD private data happens *after* section contents are set. */
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ obj_som_file_hdr(abfd)->system_id = obj_som_exec_data (abfd)->system_id;
+ else if (bfd_get_mach (abfd) == pa20)
+ obj_som_file_hdr(abfd)->system_id = CPU_PA_RISC2_0;
+ else if (bfd_get_mach (abfd) == pa11)
+ obj_som_file_hdr(abfd)->system_id = CPU_PA_RISC1_1;
+ else
+ obj_som_file_hdr(abfd)->system_id = CPU_PA_RISC1_0;
+
+ /* Compute the checksum for the file header just before writing
+ the header to disk. */
+ obj_som_file_hdr (abfd)->checksum = som_compute_checksum (abfd);
+
+ /* Only thing left to do is write out the file header. It is always
+ at location zero. Seek there and write it. */
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ return false;
+ if (bfd_write ((PTR) obj_som_file_hdr (abfd),
+ sizeof (struct header), 1, abfd)
+ != sizeof (struct header))
+ return false;
+
+ /* Now write the exec header. */
+ if (abfd->flags & (EXEC_P | DYNAMIC))
+ {
+ long tmp, som_length;
+ struct som_exec_auxhdr *exec_header;
+
+ exec_header = obj_som_exec_hdr (abfd);
+ exec_header->exec_entry = bfd_get_start_address (abfd);
+ exec_header->exec_flags = obj_som_exec_data (abfd)->exec_flags;
+
+ /* Oh joys. Ram some of the BSS data into the DATA section
+ to be compatable with how the hp linker makes objects
+ (saves memory space). */
+ tmp = exec_header->exec_dsize;
+ tmp = SOM_ALIGN (tmp, PA_PAGESIZE);
+ exec_header->exec_bsize -= (tmp - exec_header->exec_dsize);
+ if (exec_header->exec_bsize < 0)
+ exec_header->exec_bsize = 0;
+ exec_header->exec_dsize = tmp;
+
+ /* Now perform some sanity checks. The idea is to catch bogons now and
+ inform the user, instead of silently generating a bogus file. */
+ som_length = obj_som_file_hdr (abfd)->som_length;
+ if (exec_header->exec_tfile + exec_header->exec_tsize > som_length
+ || exec_header->exec_dfile + exec_header->exec_dsize > som_length)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
+ SEEK_SET) < 0)
+ return false;
+
+ if (bfd_write ((PTR) exec_header, AUX_HDR_SIZE, 1, abfd)
+ != AUX_HDR_SIZE)
+ return false;
+ }
+ return true;
+}
+
+/* Compute and return the checksum for a SOM file header. */
+
+static unsigned long
+som_compute_checksum (abfd)
+ bfd *abfd;
+{
+ unsigned long checksum, count, i;
+ unsigned long *buffer = (unsigned long *) obj_som_file_hdr (abfd);
+
+ checksum = 0;
+ count = sizeof (struct header) / sizeof (unsigned long);
+ for (i = 0; i < count; i++)
+ checksum ^= *(buffer + i);
+
+ return checksum;
+}
+
+static void
+som_bfd_derive_misc_symbol_info (abfd, sym, info)
+ bfd *abfd;
+ asymbol *sym;
+ struct som_misc_symbol_info *info;
+{
+ /* Initialize. */
+ memset (info, 0, sizeof (struct som_misc_symbol_info));
+
+ /* The HP SOM linker requires detailed type information about
+ all symbols (including undefined symbols!). Unfortunately,
+ the type specified in an import/export statement does not
+ always match what the linker wants. Severe braindamage. */
+
+ /* Section symbols will not have a SOM symbol type assigned to
+ them yet. Assign all section symbols type ST_DATA. */
+ if (sym->flags & BSF_SECTION_SYM)
+ info->symbol_type = ST_DATA;
+ else
+ {
+ /* Common symbols must have scope SS_UNSAT and type
+ ST_STORAGE or the linker will choke. */
+ if (bfd_is_com_section (sym->section))
+ {
+ info->symbol_scope = SS_UNSAT;
+ info->symbol_type = ST_STORAGE;
+ }
+
+ /* It is possible to have a symbol without an associated
+ type. This happens if the user imported the symbol
+ without a type and the symbol was never defined
+ locally. If BSF_FUNCTION is set for this symbol, then
+ assign it type ST_CODE (the HP linker requires undefined
+ external functions to have type ST_CODE rather than ST_ENTRY). */
+ else if ((som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN
+ || som_symbol_data (sym)->som_type == SYMBOL_TYPE_CODE)
+ && bfd_is_und_section (sym->section)
+ && sym->flags & BSF_FUNCTION)
+ info->symbol_type = ST_CODE;
+
+ /* Handle function symbols which were defined in this file.
+ They should have type ST_ENTRY. Also retrieve the argument
+ relocation bits from the SOM backend information. */
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_ENTRY
+ || (som_symbol_data (sym)->som_type == SYMBOL_TYPE_CODE
+ && (sym->flags & BSF_FUNCTION))
+ || (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN
+ && (sym->flags & BSF_FUNCTION)))
+ {
+ info->symbol_type = ST_ENTRY;
+ info->arg_reloc = som_symbol_data (sym)->tc_data.ap.hppa_arg_reloc;
+ info->priv_level= som_symbol_data (sym)->tc_data.ap.hppa_priv_level;
+ }
+
+ /* For unknown symbols set the symbol's type based on the symbol's
+ section (ST_DATA for DATA sections, ST_CODE for CODE sections). */
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN)
+ {
+ if (sym->section->flags & SEC_CODE)
+ info->symbol_type = ST_CODE;
+ else
+ info->symbol_type = ST_DATA;
+ }
+
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN)
+ info->symbol_type = ST_DATA;
+
+ /* From now on it's a very simple mapping. */
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_ABSOLUTE)
+ info->symbol_type = ST_ABSOLUTE;
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_CODE)
+ info->symbol_type = ST_CODE;
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_DATA)
+ info->symbol_type = ST_DATA;
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_MILLICODE)
+ info->symbol_type = ST_MILLICODE;
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_PLABEL)
+ info->symbol_type = ST_PLABEL;
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_PRI_PROG)
+ info->symbol_type = ST_PRI_PROG;
+ else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_SEC_PROG)
+ info->symbol_type = ST_SEC_PROG;
+ }
+
+ /* Now handle the symbol's scope. Exported data which is not
+ in the common section has scope SS_UNIVERSAL. Note scope
+ of common symbols was handled earlier! */
+ if (bfd_is_und_section (sym->section))
+ info->symbol_scope = SS_UNSAT;
+ else if (sym->flags & BSF_EXPORT && ! bfd_is_com_section (sym->section))
+ info->symbol_scope = SS_UNIVERSAL;
+ /* Anything else which is not in the common section has scope
+ SS_LOCAL. */
+ else if (! bfd_is_com_section (sym->section))
+ info->symbol_scope = SS_LOCAL;
+
+ /* Now set the symbol_info field. It has no real meaning
+ for undefined or common symbols, but the HP linker will
+ choke if it's not set to some "reasonable" value. We
+ use zero as a reasonable value. */
+ if (bfd_is_com_section (sym->section)
+ || bfd_is_und_section (sym->section)
+ || bfd_is_abs_section (sym->section))
+ info->symbol_info = 0;
+ /* For all other symbols, the symbol_info field contains the
+ subspace index of the space this symbol is contained in. */
+ else
+ info->symbol_info = sym->section->target_index;
+
+ /* Set the symbol's value. */
+ info->symbol_value = sym->value + sym->section->vma;
+}
+
+/* Build and write, in one big chunk, the entire symbol table for
+ this BFD. */
+
+static boolean
+som_build_and_write_symbol_table (abfd)
+ bfd *abfd;
+{
+ unsigned int num_syms = bfd_get_symcount (abfd);
+ file_ptr symtab_location = obj_som_file_hdr (abfd)->symbol_location;
+ asymbol **bfd_syms = obj_som_sorted_syms (abfd);
+ struct symbol_dictionary_record *som_symtab = NULL;
+ int i, symtab_size;
+
+ /* Compute total symbol table size and allocate a chunk of memory
+ to hold the symbol table as we build it. */
+ symtab_size = num_syms * sizeof (struct symbol_dictionary_record);
+ som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
+ if (som_symtab == NULL && symtab_size != 0)
+ goto error_return;
+ memset (som_symtab, 0, symtab_size);
+
+ /* Walk over each symbol. */
+ for (i = 0; i < num_syms; i++)
+ {
+ struct som_misc_symbol_info info;
+
+ /* This is really an index into the symbol strings table.
+ By the time we get here, the index has already been
+ computed and stored into the name field in the BFD symbol. */
+ som_symtab[i].name.n_strx = som_symbol_data(bfd_syms[i])->stringtab_offset;
+
+ /* Derive SOM information from the BFD symbol. */
+ som_bfd_derive_misc_symbol_info (abfd, bfd_syms[i], &info);
+
+ /* Now use it. */
+ som_symtab[i].symbol_type = info.symbol_type;
+ som_symtab[i].symbol_scope = info.symbol_scope;
+ som_symtab[i].arg_reloc = info.arg_reloc;
+ som_symtab[i].symbol_info = info.symbol_info;
+ som_symtab[i].xleast = 3;
+ som_symtab[i].symbol_value = info.symbol_value | info.priv_level;
+ }
+
+ /* Everything is ready, seek to the right location and
+ scribble out the symbol table. */
+ if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
+ return false;
+
+ if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size)
+ goto error_return;
+
+ if (som_symtab != NULL)
+ free (som_symtab);
+ return true;
+ error_return:
+ if (som_symtab != NULL)
+ free (som_symtab);
+ return false;
+}
+
+/* Write an object in SOM format. */
+
+static boolean
+som_write_object_contents (abfd)
+ bfd *abfd;
+{
+ if (abfd->output_has_begun == false)
+ {
+ /* Set up fixed parts of the file, space, and subspace headers.
+ Notify the world that output has begun. */
+ som_prep_headers (abfd);
+ abfd->output_has_begun = true;
+ /* Start writing the object file. This include all the string
+ tables, fixup streams, and other portions of the object file. */
+ som_begin_writing (abfd);
+ }
+
+ return (som_finish_writing (abfd));
+}
+
+
+/* Read and save the string table associated with the given BFD. */
+
+static boolean
+som_slurp_string_table (abfd)
+ bfd *abfd;
+{
+ char *stringtab;
+
+ /* Use the saved version if its available. */
+ if (obj_som_stringtab (abfd) != NULL)
+ return true;
+
+ /* I don't think this can currently happen, and I'm not sure it should
+ really be an error, but it's better than getting unpredictable results
+ from the host's malloc when passed a size of zero. */
+ if (obj_som_stringtab_size (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return false;
+ }
+
+ /* Allocate and read in the string table. */
+ stringtab = bfd_malloc (obj_som_stringtab_size (abfd));
+ if (stringtab == NULL)
+ return false;
+ memset (stringtab, 0, obj_som_stringtab_size (abfd));
+
+ if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
+ return false;
+
+ if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
+ != obj_som_stringtab_size (abfd))
+ return false;
+
+ /* Save our results and return success. */
+ obj_som_stringtab (abfd) = stringtab;
+ return true;
+}
+
+/* Return the amount of data (in bytes) required to hold the symbol
+ table for this object. */
+
+static long
+som_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ if (!som_slurp_symbol_table (abfd))
+ return -1;
+
+ return (bfd_get_symcount (abfd) + 1) * (sizeof (asymbol *));
+}
+
+/* Convert from a SOM subspace index to a BFD section. */
+
+static asection *
+bfd_section_from_som_symbol (abfd, symbol)
+ bfd *abfd;
+ struct symbol_dictionary_record *symbol;
+{
+ asection *section;
+
+ /* The meaning of the symbol_info field changes for functions
+ within executables. So only use the quick symbol_info mapping for
+ incomplete objects and non-function symbols in executables. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
+ || (symbol->symbol_type != ST_ENTRY
+ && symbol->symbol_type != ST_PRI_PROG
+ && symbol->symbol_type != ST_SEC_PROG
+ && symbol->symbol_type != ST_MILLICODE))
+ {
+ unsigned int index = symbol->symbol_info;
+ for (section = abfd->sections; section != NULL; section = section->next)
+ if (section->target_index == index && som_is_subspace (section))
+ return section;
+
+ /* Could be a symbol from an external library (such as an OMOS
+ shared library). Don't abort. */
+ return bfd_abs_section_ptr;
+
+ }
+ else
+ {
+ unsigned int value = symbol->symbol_value;
+
+ /* For executables we will have to use the symbol's address and
+ find out what section would contain that address. Yuk. */
+ for (section = abfd->sections; section; section = section->next)
+ {
+ if (value >= section->vma
+ && value <= section->vma + section->_cooked_size
+ && som_is_subspace (section))
+ return section;
+ }
+
+ /* Could be a symbol from an external library (such as an OMOS
+ shared library). Don't abort. */
+ return bfd_abs_section_ptr;
+
+ }
+}
+
+/* Read and save the symbol table associated with the given BFD. */
+
+static unsigned int
+som_slurp_symbol_table (abfd)
+ bfd *abfd;
+{
+ int symbol_count = bfd_get_symcount (abfd);
+ int symsize = sizeof (struct symbol_dictionary_record);
+ char *stringtab;
+ struct symbol_dictionary_record *buf = NULL, *bufp, *endbufp;
+ som_symbol_type *sym, *symbase;
+
+ /* Return saved value if it exists. */
+ if (obj_som_symtab (abfd) != NULL)
+ goto successful_return;
+
+ /* Special case. This is *not* an error. */
+ if (symbol_count == 0)
+ goto successful_return;
+
+ if (!som_slurp_string_table (abfd))
+ goto error_return;
+
+ stringtab = obj_som_stringtab (abfd);
+
+ symbase = ((som_symbol_type *)
+ bfd_malloc (symbol_count * sizeof (som_symbol_type)));
+ if (symbase == NULL)
+ goto error_return;
+ memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
+
+ /* Read in the external SOM representation. */
+ buf = bfd_malloc (symbol_count * symsize);
+ if (buf == NULL && symbol_count * symsize != 0)
+ goto error_return;
+ if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
+ goto error_return;
+ if (bfd_read (buf, symbol_count * symsize, 1, abfd)
+ != symbol_count * symsize)
+ goto error_return;
+
+ /* Iterate over all the symbols and internalize them. */
+ endbufp = buf + symbol_count;
+ for (bufp = buf, sym = symbase; bufp < endbufp; ++bufp)
+ {
+
+ /* I don't think we care about these. */
+ if (bufp->symbol_type == ST_SYM_EXT
+ || bufp->symbol_type == ST_ARG_EXT)
+ continue;
+
+ /* Set some private data we care about. */
+ if (bufp->symbol_type == ST_NULL)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_UNKNOWN;
+ else if (bufp->symbol_type == ST_ABSOLUTE)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_ABSOLUTE;
+ else if (bufp->symbol_type == ST_DATA)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_DATA;
+ else if (bufp->symbol_type == ST_CODE)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_CODE;
+ else if (bufp->symbol_type == ST_PRI_PROG)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_PRI_PROG;
+ else if (bufp->symbol_type == ST_SEC_PROG)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_SEC_PROG;
+ else if (bufp->symbol_type == ST_ENTRY)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_ENTRY;
+ else if (bufp->symbol_type == ST_MILLICODE)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_MILLICODE;
+ else if (bufp->symbol_type == ST_PLABEL)
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_PLABEL;
+ else
+ som_symbol_data (sym)->som_type = SYMBOL_TYPE_UNKNOWN;
+ som_symbol_data (sym)->tc_data.ap.hppa_arg_reloc = bufp->arg_reloc;
+
+ /* Some reasonable defaults. */
+ sym->symbol.the_bfd = abfd;
+ sym->symbol.name = bufp->name.n_strx + stringtab;
+ sym->symbol.value = bufp->symbol_value;
+ sym->symbol.section = 0;
+ sym->symbol.flags = 0;
+
+ switch (bufp->symbol_type)
+ {
+ case ST_ENTRY:
+ case ST_MILLICODE:
+ sym->symbol.flags |= BSF_FUNCTION;
+ som_symbol_data (sym)->tc_data.ap.hppa_priv_level =
+ sym->symbol.value & 0x3;
+ sym->symbol.value &= ~0x3;
+ break;
+
+ case ST_STUB:
+ case ST_CODE:
+ case ST_PRI_PROG:
+ case ST_SEC_PROG:
+ som_symbol_data (sym)->tc_data.ap.hppa_priv_level =
+ sym->symbol.value & 0x3;
+ sym->symbol.value &= ~0x3;
+ /* If the symbol's scope is ST_UNSAT, then these are
+ undefined function symbols. */
+ if (bufp->symbol_scope == SS_UNSAT)
+ sym->symbol.flags |= BSF_FUNCTION;
+
+
+ default:
+ break;
+ }
+
+ /* Handle scoping and section information. */
+ switch (bufp->symbol_scope)
+ {
+ /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols,
+ so the section associated with this symbol can't be known. */
+ case SS_EXTERNAL:
+ if (bufp->symbol_type != ST_STORAGE)
+ sym->symbol.section = bfd_und_section_ptr;
+ else
+ sym->symbol.section = bfd_com_section_ptr;
+ sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL);
+ break;
+
+ case SS_UNSAT:
+ if (bufp->symbol_type != ST_STORAGE)
+ sym->symbol.section = bfd_und_section_ptr;
+ else
+ sym->symbol.section = bfd_com_section_ptr;
+ break;
+
+ case SS_UNIVERSAL:
+ sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL);
+ sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp);
+ sym->symbol.value -= sym->symbol.section->vma;
+ break;
+
+#if 0
+ /* SS_GLOBAL and SS_LOCAL are two names for the same thing.
+ Sound dumb? It is. */
+ case SS_GLOBAL:
+#endif
+ case SS_LOCAL:
+ sym->symbol.flags |= BSF_LOCAL;
+ sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp);
+ sym->symbol.value -= sym->symbol.section->vma;
+ break;
+ }
+
+ /* Mark section symbols and symbols used by the debugger.
+ Note $START$ is a magic code symbol, NOT a section symbol. */
+ if (sym->symbol.name[0] == '$'
+ && sym->symbol.name[strlen (sym->symbol.name) - 1] == '$'
+ && !strcmp (sym->symbol.name, sym->symbol.section->name))
+ sym->symbol.flags |= BSF_SECTION_SYM;
+ else if (!strncmp (sym->symbol.name, "L$0\002", 4))
+ {
+ sym->symbol.flags |= BSF_SECTION_SYM;
+ sym->symbol.name = sym->symbol.section->name;
+ }
+ else if (!strncmp (sym->symbol.name, "L$0\001", 4))
+ sym->symbol.flags |= BSF_DEBUGGING;
+
+ /* Note increment at bottom of loop, since we skip some symbols
+ we can not include it as part of the for statement. */
+ sym++;
+ }
+
+ /* We modify the symbol count to record the number of BFD symbols we
+ created. */
+ bfd_get_symcount (abfd) = sym - symbase;
+
+ /* Save our results and return success. */
+ obj_som_symtab (abfd) = symbase;
+ successful_return:
+ if (buf != NULL)
+ free (buf);
+ return (true);
+
+ error_return:
+ if (buf != NULL)
+ free (buf);
+ return false;
+}
+
+/* Canonicalize a SOM symbol table. Return the number of entries
+ in the symbol table. */
+
+static long
+som_get_symtab (abfd, location)
+ bfd *abfd;
+ asymbol **location;
+{
+ int i;
+ som_symbol_type *symbase;
+
+ if (!som_slurp_symbol_table (abfd))
+ return -1;
+
+ i = bfd_get_symcount (abfd);
+ symbase = obj_som_symtab (abfd);
+
+ for (; i > 0; i--, location++, symbase++)
+ *location = &symbase->symbol;
+
+ /* Final null pointer. */
+ *location = 0;
+ return (bfd_get_symcount (abfd));
+}
+
+/* Make a SOM symbol. There is nothing special to do here. */
+
+static asymbol *
+som_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ som_symbol_type *new =
+ (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
+ if (new == NULL)
+ return 0;
+ new->symbol.the_bfd = abfd;
+
+ return &new->symbol;
+}
+
+/* Print symbol information. */
+
+static void
+som_print_symbol (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+ fprintf (file, "som ");
+ fprintf_vma (file, symbol->value);
+ fprintf (file, " %lx", (long) symbol->flags);
+ break;
+ case bfd_print_symbol_all:
+ {
+ CONST char *section_name;
+ section_name = symbol->section ? symbol->section->name : "(*none*)";
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+ fprintf (file, " %s\t%s", section_name, symbol->name);
+ break;
+ }
+ }
+}
+
+static boolean
+som_bfd_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ return (name[0] == 'L' && name[1] == '$');
+}
+
+/* Count or process variable-length SOM fixup records.
+
+ To avoid code duplication we use this code both to compute the number
+ of relocations requested by a stream, and to internalize the stream.
+
+ When computing the number of relocations requested by a stream the
+ variables rptr, section, and symbols have no meaning.
+
+ Return the number of relocations requested by the fixup stream. When
+ not just counting
+
+ This needs at least two or three more passes to get it cleaned up. */
+
+static unsigned int
+som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count)
+ unsigned char *fixup;
+ unsigned int end;
+ arelent *internal_relocs;
+ asection *section;
+ asymbol **symbols;
+ boolean just_count;
+{
+ unsigned int op, varname, deallocate_contents = 0;
+ unsigned char *end_fixups = &fixup[end];
+ const struct fixup_format *fp;
+ char *cp;
+ unsigned char *save_fixup;
+ int variables[26], stack[20], c, v, count, prev_fixup, *sp, saved_unwind_bits;
+ const int *subop;
+ arelent *rptr= internal_relocs;
+ unsigned int offset = 0;
+
+#define var(c) variables[(c) - 'A']
+#define push(v) (*sp++ = (v))
+#define pop() (*--sp)
+#define emptystack() (sp == stack)
+
+ som_initialize_reloc_queue (reloc_queue);
+ memset (variables, 0, sizeof (variables));
+ memset (stack, 0, sizeof (stack));
+ count = 0;
+ prev_fixup = 0;
+ saved_unwind_bits = 0;
+ sp = stack;
+
+ while (fixup < end_fixups)
+ {
+
+ /* Save pointer to the start of this fixup. We'll use
+ it later to determine if it is necessary to put this fixup
+ on the queue. */
+ save_fixup = fixup;
+
+ /* Get the fixup code and its associated format. */
+ op = *fixup++;
+ fp = &som_fixup_formats[op];
+
+ /* Handle a request for a previous fixup. */
+ if (*fp->format == 'P')
+ {
+ /* Get pointer to the beginning of the prev fixup, move
+ the repeated fixup to the head of the queue. */
+ fixup = reloc_queue[fp->D].reloc;
+ som_reloc_queue_fix (reloc_queue, fp->D);
+ prev_fixup = 1;
+
+ /* Get the fixup code and its associated format. */
+ op = *fixup++;
+ fp = &som_fixup_formats[op];
+ }
+
+ /* If this fixup will be passed to BFD, set some reasonable defaults. */
+ if (! just_count
+ && som_hppa_howto_table[op].type != R_NO_RELOCATION
+ && som_hppa_howto_table[op].type != R_DATA_OVERRIDE)
+ {
+ rptr->address = offset;
+ rptr->howto = &som_hppa_howto_table[op];
+ rptr->addend = 0;
+ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+
+ /* Set default input length to 0. Get the opcode class index
+ into D. */
+ var ('L') = 0;
+ var ('D') = fp->D;
+ var ('U') = saved_unwind_bits;
+
+ /* Get the opcode format. */
+ cp = fp->format;
+
+ /* Process the format string. Parsing happens in two phases,
+ parse RHS, then assign to LHS. Repeat until no more
+ characters in the format string. */
+ while (*cp)
+ {
+ /* The variable this pass is going to compute a value for. */
+ varname = *cp++;
+
+ /* Start processing RHS. Continue until a NULL or '=' is found. */
+ do
+ {
+ c = *cp++;
+
+ /* If this is a variable, push it on the stack. */
+ if (isupper (c))
+ push (var (c));
+
+ /* If this is a lower case letter, then it represents
+ additional data from the fixup stream to be pushed onto
+ the stack. */
+ else if (islower (c))
+ {
+ int bits = (c - 'a') * 8;
+ for (v = 0; c > 'a'; --c)
+ v = (v << 8) | *fixup++;
+ if (varname == 'V')
+ v = sign_extend (v, bits);
+ push (v);
+ }
+
+ /* A decimal constant. Push it on the stack. */
+ else if (isdigit (c))
+ {
+ v = c - '0';
+ while (isdigit (*cp))
+ v = (v * 10) + (*cp++ - '0');
+ push (v);
+ }
+ else
+
+ /* An operator. Pop two two values from the stack and
+ use them as operands to the given operation. Push
+ the result of the operation back on the stack. */
+ switch (c)
+ {
+ case '+':
+ v = pop ();
+ v += pop ();
+ push (v);
+ break;
+ case '*':
+ v = pop ();
+ v *= pop ();
+ push (v);
+ break;
+ case '<':
+ v = pop ();
+ v = pop () << v;
+ push (v);
+ break;
+ default:
+ abort ();
+ }
+ }
+ while (*cp && *cp != '=');
+
+ /* Move over the equal operator. */
+ cp++;
+
+ /* Pop the RHS off the stack. */
+ c = pop ();
+
+ /* Perform the assignment. */
+ var (varname) = c;
+
+ /* Handle side effects. and special 'O' stack cases. */
+ switch (varname)
+ {
+ /* Consume some bytes from the input space. */
+ case 'L':
+ offset += c;
+ break;
+ /* A symbol to use in the relocation. Make a note
+ of this if we are not just counting. */
+ case 'S':
+ if (! just_count)
+ rptr->sym_ptr_ptr = &symbols[c];
+ break;
+ /* Argument relocation bits for a function call. */
+ case 'R':
+ if (! just_count)
+ {
+ unsigned int tmp = var ('R');
+ rptr->addend = 0;
+
+ if ((som_hppa_howto_table[op].type == R_PCREL_CALL
+ && R_PCREL_CALL + 10 > op)
+ || (som_hppa_howto_table[op].type == R_ABS_CALL
+ && R_ABS_CALL + 10 > op))
+ {
+ /* Simple encoding. */
+ if (tmp > 4)
+ {
+ tmp -= 5;
+ rptr->addend |= 1;
+ }
+ if (tmp == 4)
+ rptr->addend |= 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2;
+ else if (tmp == 3)
+ rptr->addend |= 1 << 8 | 1 << 6 | 1 << 4;
+ else if (tmp == 2)
+ rptr->addend |= 1 << 8 | 1 << 6;
+ else if (tmp == 1)
+ rptr->addend |= 1 << 8;
+ }
+ else
+ {
+ unsigned int tmp1, tmp2;
+
+ /* First part is easy -- low order two bits are
+ directly copied, then shifted away. */
+ rptr->addend = tmp & 0x3;
+ tmp >>= 2;
+
+ /* Diving the result by 10 gives us the second
+ part. If it is 9, then the first two words
+ are a double precision paramater, else it is
+ 3 * the first arg bits + the 2nd arg bits. */
+ tmp1 = tmp / 10;
+ tmp -= tmp1 * 10;
+ if (tmp1 == 9)
+ rptr->addend += (0xe << 6);
+ else
+ {
+ /* Get the two pieces. */
+ tmp2 = tmp1 / 3;
+ tmp1 -= tmp2 * 3;
+ /* Put them in the addend. */
+ rptr->addend += (tmp2 << 8) + (tmp1 << 6);
+ }
+
+ /* What's left is the third part. It's unpacked
+ just like the second. */
+ if (tmp == 9)
+ rptr->addend += (0xe << 2);
+ else
+ {
+ tmp2 = tmp / 3;
+ tmp -= tmp2 * 3;
+ rptr->addend += (tmp2 << 4) + (tmp << 2);
+ }
+ }
+ rptr->addend = HPPA_R_ADDEND (rptr->addend, 0);
+ }
+ break;
+ /* Handle the linker expression stack. */
+ case 'O':
+ switch (op)
+ {
+ case R_COMP1:
+ subop = comp1_opcodes;
+ break;
+ case R_COMP2:
+ subop = comp2_opcodes;
+ break;
+ case R_COMP3:
+ subop = comp3_opcodes;
+ break;
+ default:
+ abort ();
+ }
+ while (*subop <= (unsigned char) c)
+ ++subop;
+ --subop;
+ break;
+ /* The lower 32unwind bits must be persistent. */
+ case 'U':
+ saved_unwind_bits = var ('U');
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /* If we used a previous fixup, clean up after it. */
+ if (prev_fixup)
+ {
+ fixup = save_fixup + 1;
+ prev_fixup = 0;
+ }
+ /* Queue it. */
+ else if (fixup > save_fixup + 1)
+ som_reloc_queue_insert (save_fixup, fixup - save_fixup, reloc_queue);
+
+ /* We do not pass R_DATA_OVERRIDE or R_NO_RELOCATION
+ fixups to BFD. */
+ if (som_hppa_howto_table[op].type != R_DATA_OVERRIDE
+ && som_hppa_howto_table[op].type != R_NO_RELOCATION)
+ {
+ /* Done with a single reloction. Loop back to the top. */
+ if (! just_count)
+ {
+ if (som_hppa_howto_table[op].type == R_ENTRY)
+ rptr->addend = var ('T');
+ else if (som_hppa_howto_table[op].type == R_EXIT)
+ rptr->addend = var ('U');
+ else if (som_hppa_howto_table[op].type == R_PCREL_CALL
+ || som_hppa_howto_table[op].type == R_ABS_CALL)
+ ;
+ else if (som_hppa_howto_table[op].type == R_DATA_ONE_SYMBOL)
+ {
+ unsigned addend = var ('V');
+
+ /* Try what was specified in R_DATA_OVERRIDE first
+ (if anything). Then the hard way using the
+ section contents. */
+ rptr->addend = var ('V');
+
+ if (rptr->addend == 0 && !section->contents)
+ {
+ /* Got to read the damn contents first. We don't
+ bother saving the contents (yet). Add it one
+ day if the need arises. */
+ section->contents = bfd_malloc (section->_raw_size);
+ if (section->contents == NULL)
+ return -1;
+
+ deallocate_contents = 1;
+ bfd_get_section_contents (section->owner,
+ section,
+ section->contents,
+ 0,
+ section->_raw_size);
+ }
+ else if (rptr->addend == 0)
+ rptr->addend = bfd_get_32 (section->owner,
+ (section->contents
+ + offset - var ('L')));
+
+ }
+ else
+ rptr->addend = var ('V');
+ rptr++;
+ }
+ count++;
+ /* Now that we've handled a "full" relocation, reset
+ some state. */
+ memset (variables, 0, sizeof (variables));
+ memset (stack, 0, sizeof (stack));
+ }
+ }
+ if (deallocate_contents)
+ free (section->contents);
+
+ return count;
+
+#undef var
+#undef push
+#undef pop
+#undef emptystack
+}
+
+/* Read in the relocs (aka fixups in SOM terms) for a section.
+
+ som_get_reloc_upper_bound calls this routine with JUST_COUNT
+ set to true to indicate it only needs a count of the number
+ of actual relocations. */
+
+static boolean
+som_slurp_reloc_table (abfd, section, symbols, just_count)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ boolean just_count;
+{
+ char *external_relocs;
+ unsigned int fixup_stream_size;
+ arelent *internal_relocs;
+ unsigned int num_relocs;
+
+ fixup_stream_size = som_section_data (section)->reloc_size;
+ /* If there were no relocations, then there is nothing to do. */
+ if (section->reloc_count == 0)
+ return true;
+
+ /* If reloc_count is -1, then the relocation stream has not been
+ parsed. We must do so now to know how many relocations exist. */
+ if (section->reloc_count == -1)
+ {
+ external_relocs = (char *) bfd_malloc (fixup_stream_size);
+ if (external_relocs == (char *) NULL)
+ return false;
+ /* Read in the external forms. */
+ if (bfd_seek (abfd,
+ obj_som_reloc_filepos (abfd) + section->rel_filepos,
+ SEEK_SET)
+ != 0)
+ return false;
+ if (bfd_read (external_relocs, 1, fixup_stream_size, abfd)
+ != fixup_stream_size)
+ return false;
+
+ /* Let callers know how many relocations found.
+ also save the relocation stream as we will
+ need it again. */
+ section->reloc_count = som_set_reloc_info (external_relocs,
+ fixup_stream_size,
+ NULL, NULL, NULL, true);
+
+ som_section_data (section)->reloc_stream = external_relocs;
+ }
+
+ /* If the caller only wanted a count, then return now. */
+ if (just_count)
+ return true;
+
+ num_relocs = section->reloc_count;
+ external_relocs = som_section_data (section)->reloc_stream;
+ /* Return saved information about the relocations if it is available. */
+ if (section->relocation != (arelent *) NULL)
+ return true;
+
+ internal_relocs = (arelent *)
+ bfd_zalloc (abfd, (num_relocs * sizeof (arelent)));
+ if (internal_relocs == (arelent *) NULL)
+ return false;
+
+ /* Process and internalize the relocations. */
+ som_set_reloc_info (external_relocs, fixup_stream_size,
+ internal_relocs, section, symbols, false);
+
+ /* We're done with the external relocations. Free them. */
+ free (external_relocs);
+ som_section_data (section)->reloc_stream = NULL;
+
+ /* Save our results and return success. */
+ section->relocation = internal_relocs;
+ return (true);
+}
+
+/* Return the number of bytes required to store the relocation
+ information associated with the given section. */
+
+static long
+som_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ /* If section has relocations, then read in the relocation stream
+ and parse it to determine how many relocations exist. */
+ if (asect->flags & SEC_RELOC)
+ {
+ if (! som_slurp_reloc_table (abfd, asect, NULL, true))
+ return -1;
+ return (asect->reloc_count + 1) * sizeof (arelent *);
+ }
+ /* There are no relocations. */
+ return 0;
+}
+
+/* Convert relocations from SOM (external) form into BFD internal
+ form. Return the number of relocations. */
+
+static long
+som_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr;
+ int count;
+
+ if (som_slurp_reloc_table (abfd, section, symbols, false) == false)
+ return -1;
+
+ count = section->reloc_count;
+ tblptr = section->relocation;
+
+ while (count--)
+ *relptr++ = tblptr++;
+
+ *relptr = (arelent *) NULL;
+ return section->reloc_count;
+}
+
+extern const bfd_target som_vec;
+
+/* A hook to set up object file dependent section information. */
+
+static boolean
+som_new_section_hook (abfd, newsect)
+ bfd *abfd;
+ asection *newsect;
+{
+ newsect->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
+ if (!newsect->used_by_bfd)
+ return false;
+ newsect->alignment_power = 3;
+
+ /* We allow more than three sections internally */
+ return true;
+}
+
+/* Copy any private info we understand from the input symbol
+ to the output symbol. */
+
+static boolean
+som_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol)
+ bfd *ibfd;
+ asymbol *isymbol;
+ bfd *obfd;
+ asymbol *osymbol;
+{
+ struct som_symbol *input_symbol = (struct som_symbol *) isymbol;
+ struct som_symbol *output_symbol = (struct som_symbol *) osymbol;
+
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_som_flavour
+ || obfd->xvec->flavour != bfd_target_som_flavour)
+ return false;
+
+ /* The only private information we need to copy is the argument relocation
+ bits. */
+ output_symbol->tc_data.ap.hppa_arg_reloc =
+ input_symbol->tc_data.ap.hppa_arg_reloc;
+
+ return true;
+}
+
+/* Copy any private info we understand from the input section
+ to the output section. */
+static boolean
+som_bfd_copy_private_section_data (ibfd, isection, obfd, osection)
+ bfd *ibfd;
+ asection *isection;
+ bfd *obfd;
+ asection *osection;
+{
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_som_flavour
+ || obfd->xvec->flavour != bfd_target_som_flavour
+ || (!som_is_space (isection) && !som_is_subspace (isection)))
+ return true;
+
+ som_section_data (osection)->copy_data
+ = (struct som_copyable_section_data_struct *)
+ bfd_zalloc (obfd, sizeof (struct som_copyable_section_data_struct));
+ if (som_section_data (osection)->copy_data == NULL)
+ return false;
+
+ memcpy (som_section_data (osection)->copy_data,
+ som_section_data (isection)->copy_data,
+ sizeof (struct som_copyable_section_data_struct));
+
+ /* Reparent if necessary. */
+ if (som_section_data (osection)->copy_data->container)
+ som_section_data (osection)->copy_data->container =
+ som_section_data (osection)->copy_data->container->output_section;
+
+ return true;
+}
+
+/* Copy any private info we understand from the input bfd
+ to the output bfd. */
+
+static boolean
+som_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd, *obfd;
+{
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_som_flavour
+ || obfd->xvec->flavour != bfd_target_som_flavour)
+ return true;
+
+ /* Allocate some memory to hold the data we need. */
+ obj_som_exec_data (obfd) = (struct som_exec_data *)
+ bfd_zalloc (obfd, sizeof (struct som_exec_data));
+ if (obj_som_exec_data (obfd) == NULL)
+ return false;
+
+ /* Now copy the data. */
+ memcpy (obj_som_exec_data (obfd), obj_som_exec_data (ibfd),
+ sizeof (struct som_exec_data));
+
+ return true;
+}
+
+/* Set backend info for sections which can not be described
+ in the BFD data structures. */
+
+boolean
+bfd_som_set_section_attributes (section, defined, private, sort_key, spnum)
+ asection *section;
+ int defined;
+ int private;
+ unsigned int sort_key;
+ int spnum;
+{
+ /* Allocate memory to hold the magic information. */
+ if (som_section_data (section)->copy_data == NULL)
+ {
+ som_section_data (section)->copy_data
+ = (struct som_copyable_section_data_struct *)
+ bfd_zalloc (section->owner,
+ sizeof (struct som_copyable_section_data_struct));
+ if (som_section_data (section)->copy_data == NULL)
+ return false;
+ }
+ som_section_data (section)->copy_data->sort_key = sort_key;
+ som_section_data (section)->copy_data->is_defined = defined;
+ som_section_data (section)->copy_data->is_private = private;
+ som_section_data (section)->copy_data->container = section;
+ som_section_data (section)->copy_data->space_number = spnum;
+ return true;
+}
+
+/* Set backend info for subsections which can not be described
+ in the BFD data structures. */
+
+boolean
+bfd_som_set_subsection_attributes (section, container, access,
+ sort_key, quadrant)
+ asection *section;
+ asection *container;
+ int access;
+ unsigned int sort_key;
+ int quadrant;
+{
+ /* Allocate memory to hold the magic information. */
+ if (som_section_data (section)->copy_data == NULL)
+ {
+ som_section_data (section)->copy_data
+ = (struct som_copyable_section_data_struct *)
+ bfd_zalloc (section->owner,
+ sizeof (struct som_copyable_section_data_struct));
+ if (som_section_data (section)->copy_data == NULL)
+ return false;
+ }
+ som_section_data (section)->copy_data->sort_key = sort_key;
+ som_section_data (section)->copy_data->access_control_bits = access;
+ som_section_data (section)->copy_data->quadrant = quadrant;
+ som_section_data (section)->copy_data->container = container;
+ return true;
+}
+
+/* Set the full SOM symbol type. SOM needs far more symbol information
+ than any other object file format I'm aware of. It is mandatory
+ to be able to know if a symbol is an entry point, millicode, data,
+ code, absolute, storage request, or procedure label. If you get
+ the symbol type wrong your program will not link. */
+
+void
+bfd_som_set_symbol_type (symbol, type)
+ asymbol *symbol;
+ unsigned int type;
+{
+ som_symbol_data (symbol)->som_type = type;
+}
+
+/* Attach an auxiliary header to the BFD backend so that it may be
+ written into the object file. */
+boolean
+bfd_som_attach_aux_hdr (abfd, type, string)
+ bfd *abfd;
+ int type;
+ char *string;
+{
+ if (type == VERSION_AUX_ID)
+ {
+ int len = strlen (string);
+ int pad = 0;
+
+ if (len % 4)
+ pad = (4 - (len % 4));
+ obj_som_version_hdr (abfd) = (struct user_string_aux_hdr *)
+ bfd_zalloc (abfd, sizeof (struct aux_id)
+ + sizeof (unsigned int) + len + pad);
+ if (!obj_som_version_hdr (abfd))
+ return false;
+ obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
+ obj_som_version_hdr (abfd)->header_id.length = len + pad;
+ obj_som_version_hdr (abfd)->header_id.length += sizeof (int);
+ obj_som_version_hdr (abfd)->string_length = len;
+ strncpy (obj_som_version_hdr (abfd)->user_string, string, len);
+ }
+ else if (type == COPYRIGHT_AUX_ID)
+ {
+ int len = strlen (string);
+ int pad = 0;
+
+ if (len % 4)
+ pad = (4 - (len % 4));
+ obj_som_copyright_hdr (abfd) = (struct copyright_aux_hdr *)
+ bfd_zalloc (abfd, sizeof (struct aux_id)
+ + sizeof (unsigned int) + len + pad);
+ if (!obj_som_copyright_hdr (abfd))
+ return false;
+ obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
+ obj_som_copyright_hdr (abfd)->header_id.length = len + pad;
+ obj_som_copyright_hdr (abfd)->header_id.length += sizeof (int);
+ obj_som_copyright_hdr (abfd)->string_length = len;
+ strcpy (obj_som_copyright_hdr (abfd)->copyright, string);
+ }
+ return true;
+}
+
+/* Attach an compilation unit header to the BFD backend so that it may be
+ written into the object file. */
+
+boolean
+bfd_som_attach_compilation_unit (abfd, name, language_name, product_id,
+ version_id)
+ bfd *abfd;
+ const char *name;
+ const char *language_name;
+ const char *product_id;
+ const char *version_id;
+{
+ COMPUNIT *n = (COMPUNIT *) bfd_zalloc (abfd, COMPUNITSZ);
+ if (n == NULL)
+ return false;
+
+#define STRDUP(f) \
+ if (f != NULL) \
+ { \
+ n->f.n_name = bfd_alloc (abfd, strlen (f) + 1); \
+ if (n->f.n_name == NULL) \
+ return false; \
+ strcpy (n->f.n_name, f); \
+ }
+
+ STRDUP (name);
+ STRDUP (language_name);
+ STRDUP (product_id);
+ STRDUP (version_id);
+
+#undef STRDUP
+
+ obj_som_compilation_unit (abfd) = n;
+
+ return true;
+}
+
+static boolean
+som_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (count == 0 || ((section->flags & SEC_HAS_CONTENTS) == 0))
+ return true;
+ if ((bfd_size_type)(offset+count) > section->_raw_size
+ || bfd_seek (abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1
+ || bfd_read (location, (bfd_size_type)1, count, abfd) != count)
+ return (false); /* on error */
+ return (true);
+}
+
+static boolean
+som_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (abfd->output_has_begun == false)
+ {
+ /* Set up fixed parts of the file, space, and subspace headers.
+ Notify the world that output has begun. */
+ som_prep_headers (abfd);
+ abfd->output_has_begun = true;
+ /* Start writing the object file. This include all the string
+ tables, fixup streams, and other portions of the object file. */
+ som_begin_writing (abfd);
+ }
+
+ /* Only write subspaces which have "real" contents (eg. the contents
+ are not generated at run time by the OS). */
+ if (!som_is_subspace (section)
+ || ((section->flags & SEC_HAS_CONTENTS) == 0))
+ return true;
+
+ /* Seek to the proper offset within the object file and write the
+ data. */
+ offset += som_section_data (section)->subspace_dict->file_loc_init_value;
+ if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ return false;
+
+ if (bfd_write ((PTR) location, 1, count, abfd) != count)
+ return false;
+ return true;
+}
+
+static boolean
+som_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ /* Allow any architecture to be supported by the SOM backend */
+ return bfd_default_set_arch_mach (abfd, arch, machine);
+}
+
+static boolean
+som_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
+ functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ return (false);
+}
+
+static int
+som_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+ (*_bfd_error_handler) (_("som_sizeof_headers unimplemented"));
+ fflush (stderr);
+ abort ();
+ return (0);
+}
+
+/* Return the single-character symbol type corresponding to
+ SOM section S, or '?' for an unknown SOM section. */
+
+static char
+som_section_type (s)
+ const char *s;
+{
+ const struct section_to_type *t;
+
+ for (t = &stt[0]; t->section; t++)
+ if (!strcmp (s, t->section))
+ return t->type;
+ return '?';
+}
+
+static int
+som_decode_symclass (symbol)
+ asymbol *symbol;
+{
+ char c;
+
+ if (bfd_is_com_section (symbol->section))
+ return 'C';
+ if (bfd_is_und_section (symbol->section))
+ return 'U';
+ if (bfd_is_ind_section (symbol->section))
+ return 'I';
+ if (!(symbol->flags & (BSF_GLOBAL|BSF_LOCAL)))
+ return '?';
+
+ if (bfd_is_abs_section (symbol->section)
+ || (som_symbol_data (symbol) != NULL
+ && som_symbol_data (symbol)->som_type == SYMBOL_TYPE_ABSOLUTE))
+ c = 'a';
+ else if (symbol->section)
+ c = som_section_type (symbol->section->name);
+ else
+ return '?';
+ if (symbol->flags & BSF_GLOBAL)
+ c = toupper (c);
+ return c;
+}
+
+/* Return information about SOM symbol SYMBOL in RET. */
+
+static void
+som_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ ret->type = som_decode_symclass (symbol);
+ if (ret->type != 'U')
+ ret->value = symbol->value+symbol->section->vma;
+ else
+ ret->value = 0;
+ ret->name = symbol->name;
+}
+
+/* Count the number of symbols in the archive symbol table. Necessary
+ so that we can allocate space for all the carsyms at once. */
+
+static boolean
+som_bfd_count_ar_symbols (abfd, lst_header, count)
+ bfd *abfd;
+ struct lst_header *lst_header;
+ symindex *count;
+{
+ unsigned int i;
+ unsigned int *hash_table = NULL;
+ file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
+
+ hash_table =
+ (unsigned int *) bfd_malloc (lst_header->hash_size
+ * sizeof (unsigned int));
+ if (hash_table == NULL && lst_header->hash_size != 0)
+ goto error_return;
+
+ /* Don't forget to initialize the counter! */
+ *count = 0;
+
+ /* Read in the hash table. The has table is an array of 32bit file offsets
+ which point to the hash chains. */
+ if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
+ != lst_header->hash_size * 4)
+ goto error_return;
+
+ /* Walk each chain counting the number of symbols found on that particular
+ chain. */
+ for (i = 0; i < lst_header->hash_size; i++)
+ {
+ struct lst_symbol_record lst_symbol;
+
+ /* An empty chain has zero as it's file offset. */
+ if (hash_table[i] == 0)
+ continue;
+
+ /* Seek to the first symbol in this hash chain. */
+ if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
+ goto error_return;
+
+ /* Read in this symbol and update the counter. */
+ if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
+ != sizeof (lst_symbol))
+ goto error_return;
+
+ (*count)++;
+
+ /* Now iterate through the rest of the symbols on this chain. */
+ while (lst_symbol.next_entry)
+ {
+
+ /* Seek to the next symbol. */
+ if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
+ < 0)
+ goto error_return;
+
+ /* Read the symbol in and update the counter. */
+ if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
+ != sizeof (lst_symbol))
+ goto error_return;
+
+ (*count)++;
+ }
+ }
+ if (hash_table != NULL)
+ free (hash_table);
+ return true;
+
+ error_return:
+ if (hash_table != NULL)
+ free (hash_table);
+ return false;
+}
+
+/* Fill in the canonical archive symbols (SYMS) from the archive described
+ by ABFD and LST_HEADER. */
+
+static boolean
+som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
+ bfd *abfd;
+ struct lst_header *lst_header;
+ carsym **syms;
+{
+ unsigned int i, len;
+ carsym *set = syms[0];
+ unsigned int *hash_table = NULL;
+ struct som_entry *som_dict = NULL;
+ file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
+
+ hash_table =
+ (unsigned int *) bfd_malloc (lst_header->hash_size
+ * sizeof (unsigned int));
+ if (hash_table == NULL && lst_header->hash_size != 0)
+ goto error_return;
+
+ som_dict =
+ (struct som_entry *) bfd_malloc (lst_header->module_count
+ * sizeof (struct som_entry));
+ if (som_dict == NULL && lst_header->module_count != 0)
+ goto error_return;
+
+ /* Read in the hash table. The has table is an array of 32bit file offsets
+ which point to the hash chains. */
+ if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
+ != lst_header->hash_size * 4)
+ goto error_return;
+
+ /* Seek to and read in the SOM dictionary. We will need this to fill
+ in the carsym's filepos field. */
+ if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) < 0)
+ goto error_return;
+
+ if (bfd_read ((PTR) som_dict, lst_header->module_count,
+ sizeof (struct som_entry), abfd)
+ != lst_header->module_count * sizeof (struct som_entry))
+ goto error_return;
+
+ /* Walk each chain filling in the carsyms as we go along. */
+ for (i = 0; i < lst_header->hash_size; i++)
+ {
+ struct lst_symbol_record lst_symbol;
+
+ /* An empty chain has zero as it's file offset. */
+ if (hash_table[i] == 0)
+ continue;
+
+ /* Seek to and read the first symbol on the chain. */
+ if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
+ goto error_return;
+
+ if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
+ != sizeof (lst_symbol))
+ goto error_return;
+
+ /* Get the name of the symbol, first get the length which is stored
+ as a 32bit integer just before the symbol.
+
+ One might ask why we don't just read in the entire string table
+ and index into it. Well, according to the SOM ABI the string
+ index can point *anywhere* in the archive to save space, so just
+ using the string table would not be safe. */
+ if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
+ + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
+ goto error_return;
+
+ if (bfd_read (&len, 1, 4, abfd) != 4)
+ goto error_return;
+
+ /* Allocate space for the name and null terminate it too. */
+ set->name = bfd_zalloc (abfd, len + 1);
+ if (!set->name)
+ goto error_return;
+ if (bfd_read (set->name, 1, len, abfd) != len)
+ goto error_return;
+
+ set->name[len] = 0;
+
+ /* Fill in the file offset. Note that the "location" field points
+ to the SOM itself, not the ar_hdr in front of it. */
+ set->file_offset = som_dict[lst_symbol.som_index].location
+ - sizeof (struct ar_hdr);
+
+ /* Go to the next symbol. */
+ set++;
+
+ /* Iterate through the rest of the chain. */
+ while (lst_symbol.next_entry)
+ {
+ /* Seek to the next symbol and read it in. */
+ if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET) <0)
+ goto error_return;
+
+ if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
+ != sizeof (lst_symbol))
+ goto error_return;
+
+ /* Seek to the name length & string and read them in. */
+ if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
+ + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
+ goto error_return;
+
+ if (bfd_read (&len, 1, 4, abfd) != 4)
+ goto error_return;
+
+ /* Allocate space for the name and null terminate it too. */
+ set->name = bfd_zalloc (abfd, len + 1);
+ if (!set->name)
+ goto error_return;
+
+ if (bfd_read (set->name, 1, len, abfd) != len)
+ goto error_return;
+ set->name[len] = 0;
+
+ /* Fill in the file offset. Note that the "location" field points
+ to the SOM itself, not the ar_hdr in front of it. */
+ set->file_offset = som_dict[lst_symbol.som_index].location
+ - sizeof (struct ar_hdr);
+
+ /* Go on to the next symbol. */
+ set++;
+ }
+ }
+ /* If we haven't died by now, then we successfully read the entire
+ archive symbol table. */
+ if (hash_table != NULL)
+ free (hash_table);
+ if (som_dict != NULL)
+ free (som_dict);
+ return true;
+
+ error_return:
+ if (hash_table != NULL)
+ free (hash_table);
+ if (som_dict != NULL)
+ free (som_dict);
+ return false;
+}
+
+/* Read in the LST from the archive. */
+static boolean
+som_slurp_armap (abfd)
+ bfd *abfd;
+{
+ struct lst_header lst_header;
+ struct ar_hdr ar_header;
+ unsigned int parsed_size;
+ struct artdata *ardata = bfd_ardata (abfd);
+ char nextname[17];
+ int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+
+ /* Special cases. */
+ if (i == 0)
+ return true;
+ if (i != 16)
+ return false;
+
+ if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) < 0)
+ return false;
+
+ /* For archives without .o files there is no symbol table. */
+ if (strncmp (nextname, "/ ", 16))
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
+
+ /* Read in and sanity check the archive header. */
+ if (bfd_read ((PTR) &ar_header, 1, sizeof (struct ar_hdr), abfd)
+ != sizeof (struct ar_hdr))
+ return false;
+
+ if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return false;
+ }
+
+ /* How big is the archive symbol table entry? */
+ errno = 0;
+ parsed_size = strtol (ar_header.ar_size, NULL, 10);
+ if (errno != 0)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return false;
+ }
+
+ /* Save off the file offset of the first real user data. */
+ ardata->first_file_filepos = bfd_tell (abfd) + parsed_size;
+
+ /* Read in the library symbol table. We'll make heavy use of this
+ in just a minute. */
+ if (bfd_read ((PTR) & lst_header, 1, sizeof (struct lst_header), abfd)
+ != sizeof (struct lst_header))
+ return false;
+
+ /* Sanity check. */
+ if (lst_header.a_magic != LIBMAGIC)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return false;
+ }
+
+ /* Count the number of symbols in the library symbol table. */
+ if (som_bfd_count_ar_symbols (abfd, &lst_header, &ardata->symdef_count)
+ == false)
+ return false;
+
+ /* Get back to the start of the library symbol table. */
+ if (bfd_seek (abfd, ardata->first_file_filepos - parsed_size
+ + sizeof (struct lst_header), SEEK_SET) < 0)
+ return false;
+
+ /* Initializae the cache and allocate space for the library symbols. */
+ ardata->cache = 0;
+ ardata->symdefs = (carsym *) bfd_alloc (abfd,
+ (ardata->symdef_count
+ * sizeof (carsym)));
+ if (!ardata->symdefs)
+ return false;
+
+ /* Now fill in the canonical archive symbols. */
+ if (som_bfd_fill_in_ar_symbols (abfd, &lst_header, &ardata->symdefs)
+ == false)
+ return false;
+
+ /* Seek back to the "first" file in the archive. Note the "first"
+ file may be the extended name table. */
+ if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) < 0)
+ return false;
+
+ /* Notify the generic archive code that we have a symbol map. */
+ bfd_has_map (abfd) = true;
+ return true;
+}
+
+/* Begin preparing to write a SOM library symbol table.
+
+ As part of the prep work we need to determine the number of symbols
+ and the size of the associated string section. */
+
+static boolean
+som_bfd_prep_for_ar_write (abfd, num_syms, stringsize)
+ bfd *abfd;
+ unsigned int *num_syms, *stringsize;
+{
+ bfd *curr_bfd = abfd->archive_head;
+
+ /* Some initialization. */
+ *num_syms = 0;
+ *stringsize = 0;
+
+ /* Iterate over each BFD within this archive. */
+ while (curr_bfd != NULL)
+ {
+ unsigned int curr_count, i;
+ som_symbol_type *sym;
+
+ /* Don't bother for non-SOM objects. */
+ if (curr_bfd->format != bfd_object
+ || curr_bfd->xvec->flavour != bfd_target_som_flavour)
+ {
+ curr_bfd = curr_bfd->next;
+ continue;
+ }
+
+ /* Make sure the symbol table has been read, then snag a pointer
+ to it. It's a little slimey to grab the symbols via obj_som_symtab,
+ but doing so avoids allocating lots of extra memory. */
+ if (som_slurp_symbol_table (curr_bfd) == false)
+ return false;
+
+ sym = obj_som_symtab (curr_bfd);
+ curr_count = bfd_get_symcount (curr_bfd);
+
+ /* Examine each symbol to determine if it belongs in the
+ library symbol table. */
+ for (i = 0; i < curr_count; i++, sym++)
+ {
+ struct som_misc_symbol_info info;
+
+ /* Derive SOM information from the BFD symbol. */
+ som_bfd_derive_misc_symbol_info (curr_bfd, &sym->symbol, &info);
+
+ /* Should we include this symbol? */
+ if (info.symbol_type == ST_NULL
+ || info.symbol_type == ST_SYM_EXT
+ || info.symbol_type == ST_ARG_EXT)
+ continue;
+
+ /* Only global symbols and unsatisfied commons. */
+ if (info.symbol_scope != SS_UNIVERSAL
+ && info.symbol_type != ST_STORAGE)
+ continue;
+
+ /* Do no include undefined symbols. */
+ if (bfd_is_und_section (sym->symbol.section))
+ continue;
+
+ /* Bump the various counters, being careful to honor
+ alignment considerations in the string table. */
+ (*num_syms)++;
+ *stringsize = *stringsize + strlen (sym->symbol.name) + 5;
+ while (*stringsize % 4)
+ (*stringsize)++;
+ }
+
+ curr_bfd = curr_bfd->next;
+ }
+ return true;
+}
+
+/* Hash a symbol name based on the hashing algorithm presented in the
+ SOM ABI. */
+static unsigned int
+som_bfd_ar_symbol_hash (symbol)
+ asymbol *symbol;
+{
+ unsigned int len = strlen (symbol->name);
+
+ /* Names with length 1 are special. */
+ if (len == 1)
+ return 0x1000100 | (symbol->name[0] << 16) | symbol->name[0];
+
+ return ((len & 0x7f) << 24) | (symbol->name[1] << 16)
+ | (symbol->name[len-2] << 8) | symbol->name[len-1];
+}
+
+/* Do the bulk of the work required to write the SOM library
+ symbol table. */
+
+static boolean
+som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength)
+ bfd *abfd;
+ unsigned int nsyms, string_size;
+ struct lst_header lst;
+ unsigned elength;
+{
+ file_ptr lst_filepos;
+ char *strings = NULL, *p;
+ struct lst_symbol_record *lst_syms = NULL, *curr_lst_sym;
+ bfd *curr_bfd;
+ unsigned int *hash_table = NULL;
+ struct som_entry *som_dict = NULL;
+ struct lst_symbol_record **last_hash_entry = NULL;
+ unsigned int curr_som_offset, som_index = 0;
+
+ hash_table =
+ (unsigned int *) bfd_malloc (lst.hash_size * sizeof (unsigned int));
+ if (hash_table == NULL && lst.hash_size != 0)
+ goto error_return;
+ som_dict =
+ (struct som_entry *) bfd_malloc (lst.module_count
+ * sizeof (struct som_entry));
+ if (som_dict == NULL && lst.module_count != 0)
+ goto error_return;
+
+ last_hash_entry =
+ ((struct lst_symbol_record **)
+ bfd_malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
+ if (last_hash_entry == NULL && lst.hash_size != 0)
+ goto error_return;
+
+ /* Lots of fields are file positions relative to the start
+ of the lst record. So save its location. */
+ lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
+
+ /* Some initialization. */
+ memset (hash_table, 0, 4 * lst.hash_size);
+ memset (som_dict, 0, lst.module_count * sizeof (struct som_entry));
+ memset (last_hash_entry, 0,
+ lst.hash_size * sizeof (struct lst_symbol_record *));
+
+ /* Symbols have som_index fields, so we have to keep track of the
+ index of each SOM in the archive.
+
+ The SOM dictionary has (among other things) the absolute file
+ position for the SOM which a particular dictionary entry
+ describes. We have to compute that information as we iterate
+ through the SOMs/symbols. */
+ som_index = 0;
+
+ /* We add in the size of the archive header twice as the location
+ in the SOM dictionary is the actual offset of the SOM, not the
+ archive header before the SOM. */
+ curr_som_offset = 8 + 2 * sizeof (struct ar_hdr) + lst.file_end;
+
+ /* Make room for the archive header and the contents of the
+ extended string table. Note that elength includes the size
+ of the archive header for the extended name table! */
+ if (elength)
+ curr_som_offset += elength;
+
+ /* Make sure we're properly aligned. */
+ curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
+
+ /* FIXME should be done with buffers just like everything else... */
+ lst_syms = bfd_malloc (nsyms * sizeof (struct lst_symbol_record));
+ if (lst_syms == NULL && nsyms != 0)
+ goto error_return;
+ strings = bfd_malloc (string_size);
+ if (strings == NULL && string_size != 0)
+ goto error_return;
+
+ p = strings;
+ curr_lst_sym = lst_syms;
+
+ curr_bfd = abfd->archive_head;
+ while (curr_bfd != NULL)
+ {
+ unsigned int curr_count, i;
+ som_symbol_type *sym;
+
+ /* Don't bother for non-SOM objects. */
+ if (curr_bfd->format != bfd_object
+ || curr_bfd->xvec->flavour != bfd_target_som_flavour)
+ {
+ curr_bfd = curr_bfd->next;
+ continue;
+ }
+
+ /* Make sure the symbol table has been read, then snag a pointer
+ to it. It's a little slimey to grab the symbols via obj_som_symtab,
+ but doing so avoids allocating lots of extra memory. */
+ if (som_slurp_symbol_table (curr_bfd) == false)
+ goto error_return;
+
+ sym = obj_som_symtab (curr_bfd);
+ curr_count = bfd_get_symcount (curr_bfd);
+
+ for (i = 0; i < curr_count; i++, sym++)
+ {
+ struct som_misc_symbol_info info;
+
+ /* Derive SOM information from the BFD symbol. */
+ som_bfd_derive_misc_symbol_info (curr_bfd, &sym->symbol, &info);
+
+ /* Should we include this symbol? */
+ if (info.symbol_type == ST_NULL
+ || info.symbol_type == ST_SYM_EXT
+ || info.symbol_type == ST_ARG_EXT)
+ continue;
+
+ /* Only global symbols and unsatisfied commons. */
+ if (info.symbol_scope != SS_UNIVERSAL
+ && info.symbol_type != ST_STORAGE)
+ continue;
+
+ /* Do no include undefined symbols. */
+ if (bfd_is_und_section (sym->symbol.section))
+ continue;
+
+ /* If this is the first symbol from this SOM, then update
+ the SOM dictionary too. */
+ if (som_dict[som_index].location == 0)
+ {
+ som_dict[som_index].location = curr_som_offset;
+ som_dict[som_index].length = arelt_size (curr_bfd);
+ }
+
+ /* Fill in the lst symbol record. */
+ curr_lst_sym->hidden = 0;
+ curr_lst_sym->secondary_def = 0;
+ curr_lst_sym->symbol_type = info.symbol_type;
+ curr_lst_sym->symbol_scope = info.symbol_scope;
+ curr_lst_sym->check_level = 0;
+ curr_lst_sym->must_qualify = 0;
+ curr_lst_sym->initially_frozen = 0;
+ curr_lst_sym->memory_resident = 0;
+ curr_lst_sym->is_common = bfd_is_com_section (sym->symbol.section);
+ curr_lst_sym->dup_common = 0;
+ curr_lst_sym->xleast = 3;
+ curr_lst_sym->arg_reloc = info.arg_reloc;
+ curr_lst_sym->name.n_strx = p - strings + 4;
+ curr_lst_sym->qualifier_name.n_strx = 0;
+ curr_lst_sym->symbol_info = info.symbol_info;
+ curr_lst_sym->symbol_value = info.symbol_value | info.priv_level;
+ curr_lst_sym->symbol_descriptor = 0;
+ curr_lst_sym->reserved = 0;
+ curr_lst_sym->som_index = som_index;
+ curr_lst_sym->symbol_key = som_bfd_ar_symbol_hash (&sym->symbol);
+ curr_lst_sym->next_entry = 0;
+
+ /* Insert into the hash table. */
+ if (hash_table[curr_lst_sym->symbol_key % lst.hash_size])
+ {
+ struct lst_symbol_record *tmp;
+
+ /* There is already something at the head of this hash chain,
+ so tack this symbol onto the end of the chain. */
+ tmp = last_hash_entry[curr_lst_sym->symbol_key % lst.hash_size];
+ tmp->next_entry
+ = (curr_lst_sym - lst_syms) * sizeof (struct lst_symbol_record)
+ + lst.hash_size * 4
+ + lst.module_count * sizeof (struct som_entry)
+ + sizeof (struct lst_header);
+ }
+ else
+ {
+ /* First entry in this hash chain. */
+ hash_table[curr_lst_sym->symbol_key % lst.hash_size]
+ = (curr_lst_sym - lst_syms) * sizeof (struct lst_symbol_record)
+ + lst.hash_size * 4
+ + lst.module_count * sizeof (struct som_entry)
+ + sizeof (struct lst_header);
+ }
+
+ /* Keep track of the last symbol we added to this chain so we can
+ easily update its next_entry pointer. */
+ last_hash_entry[curr_lst_sym->symbol_key % lst.hash_size]
+ = curr_lst_sym;
+
+
+ /* Update the string table. */
+ bfd_put_32 (abfd, strlen (sym->symbol.name), p);
+ p += 4;
+ strcpy (p, sym->symbol.name);
+ p += strlen (sym->symbol.name) + 1;
+ while ((int)p % 4)
+ {
+ bfd_put_8 (abfd, 0, p);
+ p++;
+ }
+
+ /* Head to the next symbol. */
+ curr_lst_sym++;
+ }
+
+ /* Keep track of where each SOM will finally reside; then look
+ at the next BFD. */
+ curr_som_offset += arelt_size (curr_bfd) + sizeof (struct ar_hdr);
+
+ /* A particular object in the archive may have an odd length; the
+ linker requires objects begin on an even boundary. So round
+ up the current offset as necessary. */
+ curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
+ curr_bfd = curr_bfd->next;
+ som_index++;
+ }
+
+ /* Now scribble out the hash table. */
+ if (bfd_write ((PTR) hash_table, lst.hash_size, 4, abfd)
+ != lst.hash_size * 4)
+ goto error_return;
+
+ /* Then the SOM dictionary. */
+ if (bfd_write ((PTR) som_dict, lst.module_count,
+ sizeof (struct som_entry), abfd)
+ != lst.module_count * sizeof (struct som_entry))
+ goto error_return;
+
+ /* The library symbols. */
+ if (bfd_write ((PTR) lst_syms, nsyms, sizeof (struct lst_symbol_record), abfd)
+ != nsyms * sizeof (struct lst_symbol_record))
+ goto error_return;
+
+ /* And finally the strings. */
+ if (bfd_write ((PTR) strings, string_size, 1, abfd) != string_size)
+ goto error_return;
+
+ if (hash_table != NULL)
+ free (hash_table);
+ if (som_dict != NULL)
+ free (som_dict);
+ if (last_hash_entry != NULL)
+ free (last_hash_entry);
+ if (lst_syms != NULL)
+ free (lst_syms);
+ if (strings != NULL)
+ free (strings);
+ return true;
+
+ error_return:
+ if (hash_table != NULL)
+ free (hash_table);
+ if (som_dict != NULL)
+ free (som_dict);
+ if (last_hash_entry != NULL)
+ free (last_hash_entry);
+ if (lst_syms != NULL)
+ free (lst_syms);
+ if (strings != NULL)
+ free (strings);
+
+ return false;
+}
+
+/* Write out the LST for the archive.
+
+ You'll never believe this is really how armaps are handled in SOM... */
+
+/*ARGSUSED*/
+static boolean
+som_write_armap (abfd, elength, map, orl_count, stridx)
+ bfd *abfd;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int orl_count;
+ int stridx;
+{
+ bfd *curr_bfd;
+ struct stat statbuf;
+ unsigned int i, lst_size, nsyms, stringsize;
+ struct ar_hdr hdr;
+ struct lst_header lst;
+ int *p;
+
+ /* We'll use this for the archive's date and mode later. */
+ if (stat (abfd->filename, &statbuf) != 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return false;
+ }
+ /* Fudge factor. */
+ bfd_ardata (abfd)->armap_timestamp = statbuf.st_mtime + 60;
+
+ /* Account for the lst header first. */
+ lst_size = sizeof (struct lst_header);
+
+ /* Start building the LST header. */
+ /* FIXME: Do we need to examine each element to determine the
+ largest id number? */
+ lst.system_id = CPU_PA_RISC1_0;
+ lst.a_magic = LIBMAGIC;
+ lst.version_id = VERSION_ID;
+ lst.file_time.secs = 0;
+ lst.file_time.nanosecs = 0;
+
+ lst.hash_loc = lst_size;
+ lst.hash_size = SOM_LST_HASH_SIZE;
+
+ /* Hash table is a SOM_LST_HASH_SIZE 32bit offsets. */
+ lst_size += 4 * SOM_LST_HASH_SIZE;
+
+ /* We need to count the number of SOMs in this archive. */
+ curr_bfd = abfd->archive_head;
+ lst.module_count = 0;
+ while (curr_bfd != NULL)
+ {
+ /* Only true SOM objects count. */
+ if (curr_bfd->format == bfd_object
+ && curr_bfd->xvec->flavour == bfd_target_som_flavour)
+ lst.module_count++;
+ curr_bfd = curr_bfd->next;
+ }
+ lst.module_limit = lst.module_count;
+ lst.dir_loc = lst_size;
+ lst_size += sizeof (struct som_entry) * lst.module_count;
+
+ /* We don't support import/export tables, auxiliary headers,
+ or free lists yet. Make the linker work a little harder
+ to make our life easier. */
+
+ lst.export_loc = 0;
+ lst.export_count = 0;
+ lst.import_loc = 0;
+ lst.aux_loc = 0;
+ lst.aux_size = 0;
+
+ /* Count how many symbols we will have on the hash chains and the
+ size of the associated string table. */
+ if (som_bfd_prep_for_ar_write (abfd, &nsyms, &stringsize) == false)
+ return false;
+
+ lst_size += sizeof (struct lst_symbol_record) * nsyms;
+
+ /* For the string table. One day we might actually use this info
+ to avoid small seeks/reads when reading archives. */
+ lst.string_loc = lst_size;
+ lst.string_size = stringsize;
+ lst_size += stringsize;
+
+ /* SOM ABI says this must be zero. */
+ lst.free_list = 0;
+ lst.file_end = lst_size;
+
+ /* Compute the checksum. Must happen after the entire lst header
+ has filled in. */
+ p = (int *)&lst;
+ lst.checksum = 0;
+ for (i = 0; i < sizeof (struct lst_header)/sizeof (int) - 1; i++)
+ lst.checksum ^= *p++;
+
+ sprintf (hdr.ar_name, "/ ");
+ sprintf (hdr.ar_date, "%ld", bfd_ardata (abfd)->armap_timestamp);
+ sprintf (hdr.ar_uid, "%ld", (long) getuid ());
+ sprintf (hdr.ar_gid, "%ld", (long) getgid ());
+ sprintf (hdr.ar_mode, "%-8o", (unsigned int) statbuf.st_mode);
+ sprintf (hdr.ar_size, "%-10d", (int) lst_size);
+ hdr.ar_fmag[0] = '`';
+ hdr.ar_fmag[1] = '\012';
+
+ /* Turn any nulls into spaces. */
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+ if (((char *) (&hdr))[i] == '\0')
+ (((char *) (&hdr))[i]) = ' ';
+
+ /* Scribble out the ar header. */
+ if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
+ != sizeof (struct ar_hdr))
+ return false;
+
+ /* Now scribble out the lst header. */
+ if (bfd_write ((PTR) &lst, 1, sizeof (struct lst_header), abfd)
+ != sizeof (struct lst_header))
+ return false;
+
+ /* Build and write the armap. */
+ if (som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength)
+ == false)
+ return false;
+
+ /* Done. */
+ return true;
+}
+
+/* Free all information we have cached for this BFD. We can always
+ read it again later if we need it. */
+
+static boolean
+som_bfd_free_cached_info (abfd)
+ bfd *abfd;
+{
+ asection *o;
+
+ if (bfd_get_format (abfd) != bfd_object)
+ return true;
+
+#define FREE(x) if (x != NULL) { free (x); x = NULL; }
+ /* Free the native string and symbol tables. */
+ FREE (obj_som_symtab (abfd));
+ FREE (obj_som_stringtab (abfd));
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ /* Free the native relocations. */
+ o->reloc_count = -1;
+ FREE (som_section_data (o)->reloc_stream);
+ /* Free the generic relocations. */
+ FREE (o->relocation);
+ }
+#undef FREE
+
+ return true;
+}
+
+/* End of miscellaneous support functions. */
+
+/* Linker support functions. */
+static boolean
+som_bfd_link_split_section (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ return (som_is_subspace (sec) && sec->_raw_size > 240000);
+}
+
+#define som_close_and_cleanup som_bfd_free_cached_info
+
+#define som_read_ar_hdr _bfd_generic_read_ar_hdr
+#define som_openr_next_archived_file bfd_generic_openr_next_archived_file
+#define som_get_elt_at_index _bfd_generic_get_elt_at_index
+#define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define som_truncate_arname bfd_bsd_truncate_arname
+#define som_slurp_extended_name_table _bfd_slurp_extended_name_table
+#define som_construct_extended_name_table \
+ _bfd_archive_coff_construct_extended_name_table
+#define som_update_armap_timestamp bfd_true
+#define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
+
+#define som_get_lineno _bfd_nosymbols_get_lineno
+#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define som_read_minisymbols _bfd_generic_read_minisymbols
+#define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+#define som_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#define som_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define som_bfd_relax_section bfd_generic_relax_section
+#define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define som_bfd_final_link _bfd_generic_final_link
+
+#define som_bfd_gc_sections bfd_generic_gc_sections
+
+
+const bfd_target som_vec =
+{
+ "som", /* name */
+ bfd_target_som_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | DYNAMIC),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+
+/* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ 0,
+ '/', /* ar_pad_char */
+ 14, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ {_bfd_dummy_target,
+ som_object_p, /* bfd_check_format */
+ bfd_generic_archive_p,
+ _bfd_dummy_target
+ },
+ {
+ bfd_false,
+ som_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+ {
+ bfd_false,
+ som_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+#undef som
+
+ BFD_JUMP_TABLE_GENERIC (som),
+ BFD_JUMP_TABLE_COPY (som),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (som),
+ BFD_JUMP_TABLE_SYMBOLS (som),
+ BFD_JUMP_TABLE_RELOCS (som),
+ BFD_JUMP_TABLE_WRITE (som),
+ BFD_JUMP_TABLE_LINK (som),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
+
+#endif /* HOST_HPPAHPUX || HOST_HPPABSD || HOST_HPPAOSF */
diff --git a/bfd/som.h b/bfd/som.h
new file mode 100644
index 00000000000..af378042189
--- /dev/null
+++ b/bfd/som.h
@@ -0,0 +1,237 @@
+/* HP PA-RISC SOM object file format: definitions internal to BFD.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1998
+ Free Software Foundation, Inc.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifndef _SOM_H
+#define _SOM_H
+
+#include "libhppa.h"
+
+#include <a.out.h>
+#include <lst.h>
+#include <ar.h>
+
+/* The SOM BFD backend doesn't currently use anything from these
+ two include files, but it's likely to need them in the future. */
+#ifdef R_DLT_REL
+#include <shl.h>
+#include <dl.h>
+#endif
+
+#if defined(HOST_HPPABSD) || defined (HOST_HPPAOSF)
+/* BSD uses a completely different scheme for object file identification.
+ so for now, define _PA_RISC_ID to accept any random value for a model
+ number. */
+#undef _PA_RISC_ID
+#define _PA_RISC_ID(__m_num) 1
+#endif /* HOST_HPPABSD */
+
+#define FILE_HDR_SIZE sizeof(struct header)
+#define AUX_HDR_SIZE sizeof(struct som_exec_auxhdr)
+
+typedef struct som_symbol
+ {
+ asymbol symbol;
+ unsigned int som_type;
+
+ /* Structured like the ELF tc_data union. Allows more code sharing
+ in GAS this way. */
+ union
+ {
+ struct
+ {
+ unsigned int hppa_arg_reloc;
+ unsigned int hppa_priv_level;
+ } ap;
+ PTR any;
+ }
+ tc_data;
+
+ /* Index of this symbol in the symbol table. Only used when
+ building relocation streams for incomplete objects. */
+ int index;
+
+ /* How many times this symbol is used in a relocation. By sorting
+ the symbols from most used to least used we can significantly
+ reduce the size of the relocation stream for incomplete objects. */
+ int reloc_count;
+
+ /* During object file writing, the offset of the name of this symbol
+ in the SOM string table. */
+ int stringtab_offset;
+ }
+som_symbol_type;
+
+/* A structure containing all the magic information stored in a BFD's
+ private data which needs to be copied during an objcopy/strip run. */
+struct som_exec_data
+ {
+ /* Sort-of a magic number. BSD uses it to distinguish between
+ native executables and hpux executables. */
+ short system_id;
+
+ /* Magic exec flags. These control things like whether or not
+ null pointer dereferencing is allowed and the like. */
+ long exec_flags;
+
+ /* Add more stuff here as needed. Good examples of information
+ we might want to pass would be presumed_dp, entry_* and maybe
+ others from the file header. */
+ };
+
+struct somdata
+ {
+ /* All the magic information about an executable which lives
+ in the private BFD structure and needs to be copied from
+ the input bfd to the output bfd during a objcopy/strip. */
+ struct som_exec_data *exec_data;
+
+ /* These three fields are only used when writing files and are
+ generated from scratch. They need not be copied for objcopy
+ or strip to work. */
+ struct header *file_hdr;
+ struct copyright_aux_hdr *copyright_aux_hdr;
+ struct user_string_aux_hdr *version_aux_hdr;
+ struct som_exec_auxhdr *exec_hdr;
+ COMPUNIT *comp_unit;
+
+ /* Pointers to a saved copy of the symbol and string tables. These
+ need not be copied for objcopy or strip to work. */
+ som_symbol_type *symtab;
+ char *stringtab;
+ asymbol **sorted_syms;
+
+ /* We remember these offsets so that after check_file_format, we have
+ no dependencies on the particular format of the exec_hdr.
+ These offsets need not be copied for objcopy or strip to work. */
+
+ file_ptr sym_filepos;
+ file_ptr str_filepos;
+ file_ptr reloc_filepos;
+ unsigned stringtab_size;
+ };
+
+struct som_data_struct
+ {
+ struct somdata a;
+ };
+
+/* Substructure of som_section_data_struct used to hold information
+ which can't be represented by the generic BFD section structure,
+ but which must be copied during objcopy or strip. */
+struct som_copyable_section_data_struct
+ {
+ /* Various fields in space and subspace headers that we need
+ to pass around. */
+ unsigned int sort_key : 8;
+ unsigned int access_control_bits : 7;
+ unsigned int is_defined : 1;
+ unsigned int is_private : 1;
+ unsigned int quadrant : 2;
+
+ /* For subspaces, this points to the section which represents the
+ space in which the subspace is contained. For spaces it points
+ back to the section for this space. */
+ asection *container;
+
+ /* The user-specified space number. It is wrong to use this as
+ an index since duplicates and holes are allowed. */
+ int space_number;
+
+ /* Add more stuff here as needed. Good examples of information
+ we might want to pass would be initialization pointers,
+ and the many subspace flags we do not represent yet. */
+ };
+
+/* Used to keep extra SOM specific information for a given section.
+
+ reloc_size holds the size of the relocation stream, note this
+ is very different from the number of relocations as SOM relocations
+ are variable length.
+
+ reloc_stream is the actual stream of relocation entries. */
+
+struct som_section_data_struct
+ {
+ struct som_copyable_section_data_struct *copy_data;
+ unsigned int reloc_size;
+ char *reloc_stream;
+ struct space_dictionary_record *space_dict;
+ struct subspace_dictionary_record *subspace_dict;
+ };
+
+#define somdata(bfd) ((bfd)->tdata.som_data->a)
+#define obj_som_exec_data(bfd) (somdata(bfd).exec_data)
+#define obj_som_file_hdr(bfd) (somdata(bfd).file_hdr)
+#define obj_som_exec_hdr(bfd) (somdata(bfd).exec_hdr)
+#define obj_som_copyright_hdr(bfd) (somdata(bfd).copyright_aux_hdr)
+#define obj_som_version_hdr(bfd) (somdata(bfd).version_aux_hdr)
+#define obj_som_compilation_unit(bfd) (somdata(bfd).comp_unit)
+#define obj_som_symtab(bfd) (somdata(bfd).symtab)
+#define obj_som_stringtab(bfd) (somdata(bfd).stringtab)
+#define obj_som_sym_filepos(bfd) (somdata(bfd).sym_filepos)
+#define obj_som_str_filepos(bfd) (somdata(bfd).str_filepos)
+#define obj_som_stringtab_size(bfd) (somdata(bfd).stringtab_size)
+#define obj_som_reloc_filepos(bfd) (somdata(bfd).reloc_filepos)
+#define obj_som_sorted_syms(bfd) (somdata(bfd).sorted_syms)
+#define som_section_data(sec) \
+ ((struct som_section_data_struct *)sec->used_by_bfd)
+#define som_symbol_data(symbol) ((som_symbol_type *) symbol)
+
+
+/* Defines groups of basic relocations. FIXME: These should
+ be the only basic relocations created by GAS. The rest
+ should be internal to the BFD backend.
+
+ The idea is both SOM and ELF define these basic relocation
+ types so they map into a SOM or ELF specific reloation as
+ appropriate. This allows GAS to share much more code
+ between the two object formats. */
+
+#define R_HPPA_NONE R_NO_RELOCATION
+#define R_HPPA R_CODE_ONE_SYMBOL
+#define R_HPPA_PCREL_CALL R_PCREL_CALL
+#define R_HPPA_ABS_CALL R_ABS_CALL
+#define R_HPPA_GOTOFF R_DP_RELATIVE
+#define R_HPPA_ENTRY R_ENTRY
+#define R_HPPA_EXIT R_EXIT
+#define R_HPPA_COMPLEX R_COMP1
+#define R_HPPA_BEGIN_BRTAB R_BEGIN_BRTAB
+#define R_HPPA_END_BRTAB R_END_BRTAB
+#define R_HPPA_BEGIN_TRY R_BEGIN_TRY
+#define R_HPPA_END_TRY R_END_TRY
+
+/* Exported functions, mostly for use by GAS. */
+boolean bfd_som_set_section_attributes PARAMS ((asection *, int, int,
+ unsigned int, int));
+boolean bfd_som_set_subsection_attributes PARAMS ((asection *, asection *,
+ int, unsigned int, int));
+void bfd_som_set_symbol_type PARAMS ((asymbol *, unsigned int));
+boolean bfd_som_attach_aux_hdr PARAMS ((bfd *, int, char *));
+int ** hppa_som_gen_reloc_type
+ PARAMS ((bfd *, int, int, enum hppa_reloc_field_selector_type_alt,
+ int, asymbol *));
+boolean bfd_som_attach_compilation_unit
+ PARAMS ((bfd *, const char *, const char *, const char *, const char *));
+
+#endif /* _SOM_H */
diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c
new file mode 100644
index 00000000000..86d4e7e9444
--- /dev/null
+++ b/bfd/sparclinux.c
@@ -0,0 +1,770 @@
+/* BFD back-end for linux flavored sparc a.out binaries.
+ Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA. */
+
+#define TARGET_PAGE_SIZE 4096
+#define ZMAGIC_DISK_BLOCK_SIZE 1024
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define TEXT_START_ADDR 0x0
+#define N_SHARED_LIB(x) 0
+#define BYTES_IN_WORD 4
+
+#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_UNKNOWN)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#define DEFAULT_ARCH bfd_arch_sparc
+#define MY(OP) CAT(sparclinux_,OP)
+#define TARGETNAME "a.out-sparc-linux"
+
+extern const bfd_target MY(vec);
+
+/* We always generate QMAGIC files in preference to ZMAGIC files. It
+ would be possible to make this a linker option, if that ever
+ becomes important. */
+
+static void MY_final_link_callback
+ PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+
+static boolean sparclinux_bfd_final_link
+ PARAMS ((bfd *abfd, struct bfd_link_info *info));
+
+static boolean
+sparclinux_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ obj_aout_subformat (abfd) = q_magic_format;
+ return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
+}
+
+#define MY_bfd_final_link sparclinux_bfd_final_link
+
+/* Set the machine type correctly. */
+
+static boolean sparclinux_write_object_contents PARAMS ((bfd *abfd));
+
+static boolean
+sparclinux_write_object_contents (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ N_SET_MACHTYPE (*execp, M_SPARC);
+
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ WRITE_HEADERS(abfd, execp);
+
+ return true;
+}
+
+#define MY_write_object_contents sparclinux_write_object_contents
+/* Code to link against Linux a.out shared libraries. */
+
+/* See if a symbol name is a reference to the global offset table. */
+
+#ifndef GOT_REF_PREFIX
+#define GOT_REF_PREFIX "__GOT_"
+#endif
+
+#define IS_GOT_SYM(name) \
+ (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
+
+/* See if a symbol name is a reference to the procedure linkage table. */
+
+#ifndef PLT_REF_PREFIX
+#define PLT_REF_PREFIX "__PLT_"
+#endif
+
+#define IS_PLT_SYM(name) \
+ (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
+
+/* This string is used to generate specialized error messages. */
+
+#ifndef NEEDS_SHRLIB
+#define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
+#endif
+
+/* This special symbol is a set vector that contains a list of
+ pointers to fixup tables. It will be present in any dynamicly
+ linked file. The linker generated fixup table should also be added
+ to the list, and it should always appear in the second slot (the
+ first one is a dummy with a magic number that is defined in
+ crt0.o). */
+
+#ifndef SHARABLE_CONFLICTS
+#define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
+#endif
+
+/* We keep a list of fixups. The terminology is a bit strange, but
+ each fixup contains two 32 bit numbers. A regular fixup contains
+ an address and a pointer, and at runtime we should store the
+ address at the location pointed to by the pointer. A builtin fixup
+ contains two pointers, and we should read the address using one
+ pointer and store it at the location pointed to by the other
+ pointer. Builtin fixups come into play when we have duplicate
+ __GOT__ symbols for the same variable. The builtin fixup will copy
+ the GOT pointer from one over into the other. */
+
+struct fixup
+{
+ struct fixup *next;
+ struct linux_link_hash_entry *h;
+ bfd_vma value;
+
+ /* Nonzero if this is a jump instruction that needs to be fixed,
+ zero if this is just a pointer */
+ char jump;
+
+ char builtin;
+};
+
+/* We don't need a special hash table entry structure, but we do need
+ to keep some information between linker passes, so we use a special
+ hash table. */
+
+struct linux_link_hash_entry
+{
+ struct aout_link_hash_entry root;
+};
+
+struct linux_link_hash_table
+{
+ struct aout_link_hash_table root;
+
+ /* First dynamic object found in link. */
+ bfd *dynobj;
+
+ /* Number of fixups. */
+ size_t fixup_count;
+
+ /* Number of builtin fixups. */
+ size_t local_builtins;
+
+ /* List of fixups. */
+ struct fixup *fixup_list;
+};
+
+static struct bfd_hash_entry *linux_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *linux_link_hash_table_create
+ PARAMS ((bfd *));
+static struct fixup *new_fixup
+ PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
+ bfd_vma, int));
+static boolean linux_link_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean linux_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
+ bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
+static boolean linux_tally_symbols
+ PARAMS ((struct linux_link_hash_entry *, PTR));
+static boolean linux_finish_dynamic_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+/* Routine to create an entry in an Linux link hash table. */
+
+static struct bfd_hash_entry *
+linux_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct linux_link_hash_entry *) NULL)
+ ret = ((struct linux_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
+ if (ret == NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct linux_link_hash_entry *)
+ NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != NULL)
+ {
+ /* Set local fields; there aren't any. */
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a Linux link hash table. */
+
+static struct bfd_link_hash_table *
+linux_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct linux_link_hash_table *ret;
+
+ ret = ((struct linux_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
+ if (ret == (struct linux_link_hash_table *) NULL)
+ return (struct bfd_link_hash_table *) NULL;
+ if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
+ linux_link_hash_newfunc))
+ {
+ free (ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->dynobj = NULL;
+ ret->fixup_count = 0;
+ ret->local_builtins = 0;
+ ret->fixup_list = NULL;
+
+ return &ret->root.root;
+}
+
+/* Look up an entry in a Linux link hash table. */
+
+#define linux_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct linux_link_hash_entry *) \
+ aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
+ (follow)))
+
+/* Traverse a Linux link hash table. */
+
+#define linux_link_hash_traverse(table, func, info) \
+ (aout_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the Linux link hash table from the info structure. This is
+ just a cast. */
+
+#define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
+
+/* Store the information for a new fixup. */
+
+static struct fixup *
+new_fixup (info, h, value, builtin)
+ struct bfd_link_info *info;
+ struct linux_link_hash_entry *h;
+ bfd_vma value;
+ int builtin;
+{
+ struct fixup *f;
+
+ f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
+ sizeof (struct fixup));
+ if (f == NULL)
+ return f;
+ f->next = linux_hash_table (info)->fixup_list;
+ linux_hash_table (info)->fixup_list = f;
+ f->h = h;
+ f->value = value;
+ f->builtin = builtin;
+ f->jump = 0;
+ ++linux_hash_table (info)->fixup_count;
+ return f;
+}
+
+/* We come here once we realize that we are going to link to a shared
+ library. We need to create a special section that contains the
+ fixup table, and we ultimately need to add a pointer to this into
+ the set vector for SHARABLE_CONFLICTS. At this point we do not
+ know the size of the section, but that's OK - we just need to
+ create it for now. */
+
+static boolean
+linux_link_create_dynamic_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ flagword flags;
+ register asection *s;
+
+ /* Note that we set the SEC_IN_MEMORY flag. */
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+
+ /* We choose to use the name ".linux-dynamic" for the fixup table.
+ Why not? */
+ s = bfd_make_section (abfd, ".linux-dynamic");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+ s->_raw_size = 0;
+ s->contents = 0;
+
+ return true;
+}
+
+/* Function to add a single symbol to the linker hash table. This is
+ a wrapper around _bfd_generic_link_add_one_symbol which handles the
+ tweaking needed for dynamic linking support. */
+
+static boolean
+linux_add_one_symbol (info, abfd, name, flags, section, value, string,
+ copy, collect, hashp)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ const char *string;
+ boolean copy;
+ boolean collect;
+ struct bfd_link_hash_entry **hashp;
+{
+ struct linux_link_hash_entry *h;
+ boolean insert;
+
+ /* Look up and see if we already have this symbol in the hash table.
+ If we do, and the defining entry is from a shared library, we
+ need to create the dynamic sections.
+
+ FIXME: What if abfd->xvec != info->hash->creator? We may want to
+ be able to link Linux a.out and ELF objects together, but serious
+ confusion is possible. */
+
+ insert = false;
+
+ if (! info->relocateable
+ && linux_hash_table (info)->dynobj == NULL
+ && strcmp (name, SHARABLE_CONFLICTS) == 0
+ && (flags & BSF_CONSTRUCTOR) != 0
+ && abfd->xvec == info->hash->creator)
+ {
+ if (! linux_link_create_dynamic_sections (abfd, info))
+ return false;
+ linux_hash_table (info)->dynobj = abfd;
+ insert = true;
+ }
+
+ if (bfd_is_abs_section (section)
+ && abfd->xvec == info->hash->creator)
+ {
+ h = linux_link_hash_lookup (linux_hash_table (info), name, false,
+ false, false);
+ if (h != NULL
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak))
+ {
+ struct fixup *f;
+
+ if (hashp != NULL)
+ *hashp = (struct bfd_link_hash_entry *) h;
+
+ f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
+ if (f == NULL)
+ return false;
+ f->jump = IS_PLT_SYM (name);
+
+ return true;
+ }
+ }
+
+ /* Do the usual procedure for adding a symbol. */
+ if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
+ value, string, copy, collect,
+ hashp))
+ return false;
+
+ /* Insert a pointer to our table in the set vector. The dynamic
+ linker requires this information */
+ if (insert)
+ {
+ asection *s;
+
+ /* Here we do our special thing to add the pointer to the
+ dynamic section in the SHARABLE_CONFLICTS set vector. */
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ BFD_ASSERT (s != NULL);
+
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
+ BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
+ return false;
+ }
+
+ return true;
+}
+
+/* We will crawl the hash table and come here for every global symbol.
+ We will examine each entry and see if there are indications that we
+ need to add a fixup. There are two possible cases - one is where
+ you have duplicate definitions of PLT or GOT symbols - these will
+ have already been caught and added as "builtin" fixups. If we find
+ that the corresponding non PLT/GOT symbol is also present, we
+ convert it to a regular fixup instead.
+
+ This function is called via linux_link_hash_traverse. */
+
+static boolean
+linux_tally_symbols (h, data)
+ struct linux_link_hash_entry *h;
+ PTR data;
+{
+ struct bfd_link_info *info = (struct bfd_link_info *) data;
+ struct fixup *f, *f1;
+ int is_plt;
+ struct linux_link_hash_entry *h1, *h2;
+ boolean exists;
+
+ if (h->root.root.type == bfd_link_hash_undefined
+ && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
+ sizeof NEEDS_SHRLIB - 1) == 0)
+ {
+ const char *name;
+ char *p;
+ char *alloc = NULL;
+
+ name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
+ p = strrchr (name, '_');
+ if (p != NULL)
+ alloc = (char *) bfd_malloc (strlen (name) + 1);
+
+ if (p == NULL || alloc == NULL)
+ (*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
+ name);
+ else
+ {
+ strcpy (alloc, name);
+ p = strrchr (alloc, '_');
+ *p++ = '\0';
+ (*_bfd_error_handler)
+ (_("Output file requires shared library `%s.so.%s'\n"),
+ alloc, p);
+ free (alloc);
+ }
+
+ abort ();
+ }
+
+ /* If this symbol is not a PLT/GOT, we do not even need to look at
+ it. */
+ is_plt = IS_PLT_SYM (h->root.root.root.string);
+
+ if (is_plt || IS_GOT_SYM (h->root.root.root.string))
+ {
+ /* Look up this symbol twice. Once just as a regular lookup,
+ and then again following all of the indirect links until we
+ reach a real symbol. */
+ h1 = linux_link_hash_lookup (linux_hash_table (info),
+ (h->root.root.root.string
+ + sizeof PLT_REF_PREFIX - 1),
+ false, false, true);
+ /* h2 does not follow indirect symbols. */
+ h2 = linux_link_hash_lookup (linux_hash_table (info),
+ (h->root.root.root.string
+ + sizeof PLT_REF_PREFIX - 1),
+ false, false, false);
+
+ /* The real symbol must exist but if it is also an ABS symbol,
+ there is no need to have a fixup. This is because they both
+ came from the same library. If on the other hand, we had to
+ use an indirect symbol to get to the real symbol, we add the
+ fixup anyway, since there are cases where these symbols come
+ from different shared libraries */
+ if (h1 != NULL
+ && (((h1->root.root.type == bfd_link_hash_defined
+ || h1->root.root.type == bfd_link_hash_defweak)
+ && ! bfd_is_abs_section (h1->root.root.u.def.section))
+ || h2->root.root.type == bfd_link_hash_indirect))
+ {
+ /* See if there is a "builtin" fixup already present
+ involving this symbol. If so, convert it to a regular
+ fixup. In the end, this relaxes some of the requirements
+ about the order of performing fixups. */
+ exists = false;
+ for (f1 = linux_hash_table (info)->fixup_list;
+ f1 != NULL;
+ f1 = f1->next)
+ {
+ if ((f1->h != h && f1->h != h1)
+ || (! f1->builtin && ! f1->jump))
+ continue;
+ if (f1->h == h1)
+ exists = true;
+ if (! exists
+ && bfd_is_abs_section (h->root.root.u.def.section))
+ {
+ f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
+ f->jump = is_plt;
+ }
+ f1->h = h1;
+ f1->jump = is_plt;
+ f1->builtin = 0;
+ exists = true;
+ }
+ if (! exists
+ && bfd_is_abs_section (h->root.root.u.def.section))
+ {
+ f = new_fixup (info, h1, h->root.root.u.def.value, 0);
+ if (f == NULL)
+ {
+ /* FIXME: No way to return error. */
+ abort ();
+ }
+ f->jump = is_plt;
+ }
+ }
+
+ /* Quick and dirty way of stripping these symbols from the
+ symtab. */
+ if (bfd_is_abs_section (h->root.root.u.def.section))
+ h->root.written = true;
+ }
+
+ return true;
+}
+
+/* This is called to set the size of the .linux-dynamic section is.
+ It is called by the Linux linker emulation before_allocation
+ routine. We have finished reading all of the input files, and now
+ we just scan the hash tables to find out how many additional fixups
+ are required. */
+
+boolean
+bfd_sparclinux_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ struct fixup *f;
+ asection *s;
+
+ if (output_bfd->xvec != &MY(vec))
+ return true;
+
+ /* First find the fixups... */
+ linux_link_hash_traverse (linux_hash_table (info),
+ linux_tally_symbols,
+ (PTR) info);
+
+ /* If there are builtin fixups, leave room for a marker. This is
+ used by the dynamic linker so that it knows that all that follow
+ are builtin fixups instead of regular fixups. */
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (f->builtin)
+ {
+ ++linux_hash_table (info)->fixup_count;
+ ++linux_hash_table (info)->local_builtins;
+ break;
+ }
+ }
+
+ if (linux_hash_table (info)->dynobj == NULL)
+ {
+ if (linux_hash_table (info)->fixup_count > 0)
+ abort ();
+ return true;
+ }
+
+ /* Allocate memory for our fixup table. We will fill it in later. */
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ if (s != NULL)
+ {
+ s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ memset (s->contents, 0, (size_t) s->_raw_size);
+ }
+
+ return true;
+}
+
+/* We come here once we are ready to actually write the fixup table to
+ the output file. Scan the fixup tables and so forth and generate
+ the stuff we need. */
+
+static boolean
+linux_finish_dynamic_link (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ asection *s, *os, *is;
+ bfd_byte *fixup_table;
+ struct linux_link_hash_entry *h;
+ struct fixup *f;
+ unsigned int new_addr;
+ int section_offset;
+ unsigned int fixups_written;
+
+ if (linux_hash_table (info)->dynobj == NULL)
+ return true;
+
+ s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
+ ".linux-dynamic");
+ BFD_ASSERT (s != NULL);
+ os = s->output_section;
+ fixups_written = 0;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup table file offset: %x VMA: %x\n",
+ os->filepos + s->output_offset,
+ os->vma + s->output_offset);
+#endif
+
+ fixup_table = s->contents;
+ bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
+ fixup_table += 4;
+
+ /* Fill in fixup table. */
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (f->builtin)
+ continue;
+
+ if (f->h->root.root.type != bfd_link_hash_defined
+ && f->h->root.root.type != bfd_link_hash_defweak)
+ {
+ (*_bfd_error_handler)
+ (_("Symbol %s not defined for fixups\n"),
+ f->h->root.root.root.string);
+ continue;
+ }
+
+ is = f->h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = f->h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
+ new_addr, f->value);
+#endif
+
+ if (f->jump)
+ {
+ /* Relative address */
+ new_addr = new_addr - (f->value + 5);
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value + 1, fixup_table);
+ fixup_table += 4;
+ }
+ else
+ {
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value, fixup_table);
+ fixup_table += 4;
+ }
+ ++fixups_written;
+ }
+
+ if (linux_hash_table (info)->local_builtins != 0)
+ {
+ /* Special marker so we know to switch to the other type of fixup */
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
+ {
+ if (! f->builtin)
+ continue;
+
+ if (f->h->root.root.type != bfd_link_hash_defined
+ && f->h->root.root.type != bfd_link_hash_defweak)
+ {
+ (*_bfd_error_handler)
+ (_("Symbol %s not defined for fixups\n"),
+ f->h->root.root.root.string);
+ continue;
+ }
+
+ is = f->h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = f->h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
+ new_addr, f->value);
+#endif
+
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, f->value, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ }
+ }
+
+ if (linux_hash_table (info)->fixup_count != fixups_written)
+ {
+ (*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
+ while (linux_hash_table (info)->fixup_count > fixups_written)
+ {
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ bfd_put_32 (output_bfd, 0, fixup_table);
+ fixup_table += 4;
+ ++fixups_written;
+ }
+ }
+
+ h = linux_link_hash_lookup (linux_hash_table (info),
+ "__BUILTIN_FIXUPS__",
+ false, false, false);
+
+ if (h != NULL
+ && (h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak))
+ {
+ is = h->root.root.u.def.section;
+ section_offset = is->output_section->vma + is->output_offset;
+ new_addr = h->root.root.u.def.value + section_offset;
+
+#ifdef LINUX_LINK_DEBUG
+ printf ("Builtin fixup table at %x\n", new_addr);
+#endif
+
+ bfd_put_32 (output_bfd, new_addr, fixup_table);
+ }
+ else
+ bfd_put_32 (output_bfd, 0, fixup_table);
+
+ if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
+ return false;
+
+ if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
+ != s->_raw_size)
+ return false;
+
+ return true;
+}
+
+#define MY_bfd_link_hash_table_create linux_link_hash_table_create
+#define MY_add_one_symbol linux_add_one_symbol
+#define MY_finish_dynamic_link linux_finish_dynamic_link
+
+#define MY_zmagic_contiguous 1
+
+#include "aout-target.h"
diff --git a/bfd/sparclynx.c b/bfd/sparclynx.c
new file mode 100644
index 00000000000..dbfcae55cbe
--- /dev/null
+++ b/bfd/sparclynx.c
@@ -0,0 +1,266 @@
+/* BFD support for Sparc binaries under LynxOS.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 97, 1998
+ Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if 0
+#define BYTES_IN_WORD 4
+#define N_SHARED_LIB(x) 0
+
+#define TEXT_START_ADDR 0
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_sparc
+
+#endif
+
+#define MY(OP) CAT(sparclynx_aout_,OP)
+#define TARGETNAME "a.out-sparc-lynx"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "aout/sun4.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#include "aout/aout64.h"
+#include "aout/stab_gnu.h"
+#include "aout/ar.h"
+
+/* This is needed to reject a NewsOS file, e.g. in
+ gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
+ I needed to add M_UNKNOWN to recognize a 68000 object, so this will
+ probably no longer reject a NewsOS object. <ian@cygnus.com>. */
+#define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
+ || (mtype) == M_68010 \
+ || (mtype) == M_68020 \
+ || (mtype) == M_SPARC)
+
+/*
+The file @code{aoutf1.h} contains the code for BFD's
+a.out back end. Control over the generated back end is given by these
+two preprocessor names:
+@table @code
+@item ARCH_SIZE
+This value should be either 32 or 64, depending upon the size of an
+int in the target format. It changes the sizes of the structs which
+perform the memory/disk mapping of structures.
+
+The 64 bit backend may only be used if the host compiler supports 64
+ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
+With this name defined, @emph{all} bfd operations are performed with 64bit
+arithmetic, not just those to a 64bit target.
+
+@item TARGETNAME
+The name put into the target vector.
+@item
+@end table
+
+*/
+
+/*SUPPRESS558*/
+/*SUPPRESS529*/
+
+void
+NAME(lynx,set_arch_mach) (abfd, machtype)
+ bfd *abfd;
+ int machtype;
+{
+ /* Determine the architecture and machine type of the object file. */
+ enum bfd_architecture arch;
+ long machine;
+ switch (machtype)
+ {
+
+ case M_UNKNOWN:
+ /* Some Sun3s make magic numbers without cpu types in them, so
+ we'll default to the 68000. */
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68000;
+ break;
+
+ case M_68010:
+ case M_HP200:
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68010;
+ break;
+
+ case M_68020:
+ case M_HP300:
+ arch = bfd_arch_m68k;
+ machine = bfd_mach_m68020;
+ break;
+
+ case M_SPARC:
+ arch = bfd_arch_sparc;
+ machine = 0;
+ break;
+
+ case M_386:
+ case M_386_DYNIX:
+ arch = bfd_arch_i386;
+ machine = 0;
+ break;
+
+ case M_29K:
+ arch = bfd_arch_a29k;
+ machine = 0;
+ break;
+
+ case M_HPUX:
+ arch = bfd_arch_m68k;
+ machine = 0;
+ break;
+
+ default:
+ arch = bfd_arch_obscure;
+ machine = 0;
+ break;
+ }
+ bfd_set_arch_mach (abfd, arch, machine);
+}
+
+#define SET_ARCH_MACH(ABFD, EXEC) \
+ NAME(lynx,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
+ choose_reloc_size(ABFD);
+
+/* Determine the size of a relocation entry, based on the architecture */
+static void
+choose_reloc_size (abfd)
+ bfd *abfd;
+{
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_sparc:
+ case bfd_arch_a29k:
+ obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
+ break;
+ default:
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ break;
+ }
+}
+
+/* Write an object file in LynxOS format.
+ Section contents have already been written. We write the
+ file header, symbols, and relocation. */
+
+static boolean
+NAME(aout,sparclynx_write_object_contents) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes;
+ struct internal_exec *execp = exec_hdr (abfd);
+
+ /* Magic number, maestro, please! */
+ switch (bfd_get_arch (abfd))
+ {
+ case bfd_arch_m68k:
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_m68010:
+ N_SET_MACHTYPE (*execp, M_68010);
+ break;
+ default:
+ case bfd_mach_m68020:
+ N_SET_MACHTYPE (*execp, M_68020);
+ break;
+ }
+ break;
+ case bfd_arch_sparc:
+ N_SET_MACHTYPE (*execp, M_SPARC);
+ break;
+ case bfd_arch_i386:
+ N_SET_MACHTYPE (*execp, M_386);
+ break;
+ case bfd_arch_a29k:
+ N_SET_MACHTYPE (*execp, M_29K);
+ break;
+ default:
+ N_SET_MACHTYPE (*execp, M_UNKNOWN);
+ }
+
+ choose_reloc_size (abfd);
+
+ N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
+
+ WRITE_HEADERS (abfd, execp);
+
+ return true;
+}
+
+#define MY_set_sizes sparclynx_set_sizes
+static boolean
+sparclynx_set_sizes (abfd)
+ bfd *abfd;
+{
+ switch (bfd_get_arch (abfd))
+ {
+ default:
+ return false;
+ case bfd_arch_sparc:
+ adata (abfd).page_size = 0x2000;
+ adata (abfd).segment_size = 0x2000;
+ adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+ return true;
+ case bfd_arch_m68k:
+ adata (abfd).page_size = 0x2000;
+ adata (abfd).segment_size = 0x20000;
+ adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+ return true;
+ }
+}
+
+static CONST struct aout_backend_data sparclynx_aout_backend =
+{
+ 0, 1, 0, 1, 0, sparclynx_set_sizes, 0,
+ 0, /* add_dynamic_symbols */
+ 0, /* add_one_symbol */
+ 0, /* link_dynamic_object */
+ 0, /* write_dynamic_symbol */
+ 0, /* check_dynamic_reloc */
+ 0 /* finish_dynamic_link */
+};
+
+
+#define MY_bfd_debug_info_start bfd_void
+#define MY_bfd_debug_info_end bfd_void
+#define MY_bfd_debug_info_accumulate \
+ (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
+
+#define MY_write_object_contents NAME(aout,sparclynx_write_object_contents)
+#define MY_backend_data &sparclynx_aout_backend
+
+#define TARGET_IS_BIG_ENDIAN_P
+
+#ifdef LYNX_CORE
+
+char *lynx_core_file_failing_command ();
+int lynx_core_file_failing_signal ();
+boolean lynx_core_file_matches_executable_p ();
+const bfd_target *lynx_core_file_p ();
+
+#define MY_core_file_failing_command lynx_core_file_failing_command
+#define MY_core_file_failing_signal lynx_core_file_failing_signal
+#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
+#define MY_core_file_p lynx_core_file_p
+
+#endif /* LYNX_CORE */
+
+#include "aout-target.h"
diff --git a/bfd/sparcnetbsd.c b/bfd/sparcnetbsd.c
new file mode 100644
index 00000000000..4277bb8914d
--- /dev/null
+++ b/bfd/sparcnetbsd.c
@@ -0,0 +1,34 @@
+/* BFD back-end for NetBSD/sparc a.out-ish binaries.
+ Copyright (C) 1990, 91, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#define TARGET_IS_BIG_ENDIAN_P
+
+/* SPARC chips use either 4K or 8K pages, but object files always
+ assume 8K page alignment so they will work on either one. */
+#define TARGET_PAGE_SIZE 0x2000
+
+#define DEFAULT_ARCH bfd_arch_sparc
+#define DEFAULT_MID M_SPARC_NETBSD
+
+#define MY(OP) CAT(sparcnetbsd_,OP)
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-sparc-netbsd"
+
+#include "netbsd.h"
diff --git a/bfd/srec.c b/bfd/srec.c
new file mode 100644
index 00000000000..70d2f96175e
--- /dev/null
+++ b/bfd/srec.c
@@ -0,0 +1,1377 @@
+/* BFD back-end for s-record objects.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SUBSECTION
+ S-Record handling
+
+DESCRIPTION
+
+ Ordinary S-Records cannot hold anything but addresses and
+ data, so that's all that we implement.
+
+ The only interesting thing is that S-Records may come out of
+ order and there is no header, so an initial scan is required
+ to discover the minimum and maximum addresses used to create
+ the vma and size of the only section we create. We
+ arbitrarily call this section ".text".
+
+ When bfd_get_section_contents is called the file is read
+ again, and this time the data is placed into a bfd_alloc'd
+ area.
+
+ Any number of sections may be created for output, we save them
+ up and output them when it's time to close the bfd.
+
+ An s record looks like:
+
+EXAMPLE
+ S<type><length><address><data><checksum>
+
+DESCRIPTION
+ Where
+ o length
+ is the number of bytes following upto the checksum. Note that
+ this is not the number of chars following, since it takes two
+ chars to represent a byte.
+ o type
+ is one of:
+ 0) header record
+ 1) two byte address data record
+ 2) three byte address data record
+ 3) four byte address data record
+ 7) four byte address termination record
+ 8) three byte address termination record
+ 9) two byte address termination record
+
+ o address
+ is the start address of the data following, or in the case of
+ a termination record, the start address of the image
+ o data
+ is the data.
+ o checksum
+ is the sum of all the raw byte data in the record, from the length
+ upwards, modulo 256 and subtracted from 255.
+
+
+SUBSECTION
+ Symbol S-Record handling
+
+DESCRIPTION
+ Some ICE equipment understands an addition to the standard
+ S-Record format; symbols and their addresses can be sent
+ before the data.
+
+ The format of this is:
+ ($$ <modulename>
+ (<space> <symbol> <address>)*)
+ $$
+
+ so a short symbol table could look like:
+
+EXAMPLE
+ $$ flash.x
+ $$ flash.c
+ _port6 $0
+ _delay $4
+ _start $14
+ _etext $8036
+ _edata $8036
+ _end $8036
+ $$
+
+DESCRIPTION
+ We allow symbols to be anywhere in the data stream - the module names
+ are always ignored.
+
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libiberty.h"
+#include <ctype.h>
+
+static void srec_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static void srec_print_symbol
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+static void srec_init PARAMS ((void));
+static boolean srec_mkobject PARAMS ((bfd *));
+static int srec_get_byte PARAMS ((bfd *, boolean *));
+static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
+static boolean srec_scan PARAMS ((bfd *));
+static const bfd_target *srec_object_p PARAMS ((bfd *));
+static const bfd_target *symbolsrec_object_p PARAMS ((bfd *));
+static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
+
+static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma,
+ const bfd_byte *,
+ const bfd_byte *));
+static boolean srec_write_header PARAMS ((bfd *));
+static boolean srec_write_symbols PARAMS ((bfd *));
+static boolean srec_new_symbol PARAMS ((bfd *, const char *, bfd_vma));
+static boolean srec_get_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static boolean srec_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+static boolean srec_set_section_contents
+ PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
+static boolean internal_srec_write_object_contents PARAMS ((bfd *, int));
+static boolean srec_write_object_contents PARAMS ((bfd *));
+static boolean symbolsrec_write_object_contents PARAMS ((bfd *));
+static int srec_sizeof_headers PARAMS ((bfd *, boolean));
+static asymbol *srec_make_empty_symbol PARAMS ((bfd *));
+static long srec_get_symtab_upper_bound PARAMS ((bfd *));
+static long srec_get_symtab PARAMS ((bfd *, asymbol **));
+
+/* Macros for converting between hex and binary. */
+
+static CONST char digs[] = "0123456789ABCDEF";
+
+#define NIBBLE(x) hex_value(x)
+#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
+#define TOHEX(d, x, ch) \
+ d[1] = digs[(x) & 0xf]; \
+ d[0] = digs[((x)>>4)&0xf]; \
+ ch += ((x) & 0xff);
+#define ISHEX(x) hex_p(x)
+
+/* Initialize by filling in the hex conversion array. */
+
+static void
+srec_init ()
+{
+ static boolean inited = false;
+
+ if (inited == false)
+ {
+ inited = true;
+ hex_init ();
+ }
+}
+
+/* The maximum number of bytes on a line is FF */
+#define MAXCHUNK 0xff
+/* The number of bytes we fit onto a line on output */
+#define CHUNK 21
+
+/* When writing an S-record file, the S-records can not be output as
+ they are seen. This structure is used to hold them in memory. */
+
+struct srec_data_list_struct
+{
+ struct srec_data_list_struct *next;
+ bfd_byte *data;
+ bfd_vma where;
+ bfd_size_type size;
+};
+
+typedef struct srec_data_list_struct srec_data_list_type;
+
+/* When scanning the S-record file, a linked list of srec_symbol
+ structures is built to represent the symbol table (if there is
+ one). */
+
+struct srec_symbol
+{
+ struct srec_symbol *next;
+ const char *name;
+ bfd_vma val;
+};
+
+/* The S-record tdata information. */
+
+typedef struct srec_data_struct
+ {
+ srec_data_list_type *head;
+ srec_data_list_type *tail;
+ unsigned int type;
+ struct srec_symbol *symbols;
+ struct srec_symbol *symtail;
+ asymbol *csymbols;
+ }
+tdata_type;
+
+static boolean srec_write_section PARAMS ((bfd *, tdata_type *,
+ srec_data_list_type *));
+static boolean srec_write_terminator PARAMS ((bfd *, tdata_type *));
+
+/* Set up the S-record tdata information. */
+
+static boolean
+srec_mkobject (abfd)
+ bfd *abfd;
+{
+ srec_init ();
+
+ if (abfd->tdata.srec_data == NULL)
+ {
+ tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
+ if (tdata == NULL)
+ return false;
+ abfd->tdata.srec_data = tdata;
+ tdata->type = 1;
+ tdata->head = NULL;
+ tdata->tail = NULL;
+ tdata->symbols = NULL;
+ tdata->symtail = NULL;
+ tdata->csymbols = NULL;
+ }
+
+ return true;
+}
+
+/* Read a byte from an S record file. Set *ERRORPTR if an error
+ occurred. Return EOF on error or end of file. */
+
+static int
+srec_get_byte (abfd, errorptr)
+ bfd *abfd;
+ boolean *errorptr;
+{
+ bfd_byte c;
+
+ if (bfd_read (&c, 1, 1, abfd) != 1)
+ {
+ if (bfd_get_error () != bfd_error_file_truncated)
+ *errorptr = true;
+ return EOF;
+ }
+
+ return (int) (c & 0xff);
+}
+
+/* Report a problem in an S record file. FIXME: This probably should
+ not call fprintf, but we really do need some mechanism for printing
+ error messages. */
+
+static void
+srec_bad_byte (abfd, lineno, c, error)
+ bfd *abfd;
+ unsigned int lineno;
+ int c;
+ boolean error;
+{
+ if (c == EOF)
+ {
+ if (! error)
+ bfd_set_error (bfd_error_file_truncated);
+ }
+ else
+ {
+ char buf[10];
+
+ if (! isprint (c))
+ sprintf (buf, "\\%03o", (unsigned int) c);
+ else
+ {
+ buf[0] = c;
+ buf[1] = '\0';
+ }
+ (*_bfd_error_handler)
+ (_("%s:%d: Unexpected character `%s' in S-record file\n"),
+ bfd_get_filename (abfd), lineno, buf);
+ bfd_set_error (bfd_error_bad_value);
+ }
+}
+
+/* Add a new symbol found in an S-record file. */
+
+static boolean
+srec_new_symbol (abfd, name, val)
+ bfd *abfd;
+ const char *name;
+ bfd_vma val;
+{
+ struct srec_symbol *n;
+
+ n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
+ if (n == NULL)
+ return false;
+
+ n->name = name;
+ n->val = val;
+
+ if (abfd->tdata.srec_data->symbols == NULL)
+ abfd->tdata.srec_data->symbols = n;
+ else
+ abfd->tdata.srec_data->symtail->next = n;
+ abfd->tdata.srec_data->symtail = n;
+ n->next = NULL;
+
+ ++abfd->symcount;
+
+ return true;
+}
+
+/* Read the S record file and turn it into sections. We create a new
+ section for each contiguous set of bytes. */
+
+static boolean
+srec_scan (abfd)
+ bfd *abfd;
+{
+ int c;
+ unsigned int lineno = 1;
+ boolean error = false;
+ bfd_byte *buf = NULL;
+ size_t bufsize = 0;
+ asection *sec = NULL;
+ char *symbuf = NULL;
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto error_return;
+
+ while ((c = srec_get_byte (abfd, &error)) != EOF)
+ {
+ /* We only build sections from contiguous S-records, so if this
+ is not an S-record, then stop building a section. */
+ if (c != 'S' && c != '\r' && c != '\n')
+ sec = NULL;
+
+ switch (c)
+ {
+ default:
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+
+ case '\n':
+ ++lineno;
+ break;
+
+ case '\r':
+ break;
+
+ case '$':
+ /* Starting a module name, which we ignore. */
+ while ((c = srec_get_byte (abfd, &error)) != '\n'
+ && c != EOF)
+ ;
+ if (c == EOF)
+ {
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+
+ ++lineno;
+
+ break;
+
+ case ' ':
+ do
+ {
+ unsigned int alc;
+ char *p, *symname;
+ bfd_vma symval;
+
+ /* Starting a symbol definition. */
+ while ((c = srec_get_byte (abfd, &error)) != EOF
+ && (c == ' ' || c == '\t'))
+ ;
+
+ if (c == '\n' || c == '\r')
+ break;
+
+ if (c == EOF)
+ {
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+
+ alc = 10;
+ symbuf = (char *) bfd_malloc (alc + 1);
+ if (symbuf == NULL)
+ goto error_return;
+
+ p = symbuf;
+
+ *p++ = c;
+ while ((c = srec_get_byte (abfd, &error)) != EOF
+ && ! isspace (c))
+ {
+ if ((unsigned int) (p - symbuf) >= alc)
+ {
+ char *n;
+
+ alc *= 2;
+ n = (char *) bfd_realloc (symbuf, alc + 1);
+ if (n == NULL)
+ goto error_return;
+ p = n + (p - symbuf);
+ symbuf = n;
+ }
+
+ *p++ = c;
+ }
+
+ if (c == EOF)
+ {
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+
+ *p++ = '\0';
+ symname = bfd_alloc (abfd, p - symbuf);
+ if (symname == NULL)
+ goto error_return;
+ strcpy (symname, symbuf);
+ free (symbuf);
+ symbuf = NULL;
+
+ while ((c = srec_get_byte (abfd, &error)) != EOF
+ && (c == ' ' || c == '\t'))
+ ;
+ if (c == EOF)
+ {
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+
+ /* Skip a dollar sign before the hex value. */
+ if (c == '$')
+ {
+ c = srec_get_byte (abfd, &error);
+ if (c == EOF)
+ {
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+ }
+
+ symval = 0;
+ while (ISHEX (c))
+ {
+ symval <<= 4;
+ symval += NIBBLE (c);
+ c = srec_get_byte (abfd, &error);
+ }
+
+ if (! srec_new_symbol (abfd, symname, symval))
+ goto error_return;
+ }
+ while (c == ' ' || c == '\t');
+
+ if (c == '\n')
+ ++lineno;
+ else if (c != '\r')
+ {
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+
+ break;
+
+ case 'S':
+ {
+ file_ptr pos;
+ char hdr[3];
+ unsigned int bytes;
+ bfd_vma address;
+ bfd_byte *data;
+
+ /* Starting an S-record. */
+
+ pos = bfd_tell (abfd) - 1;
+
+ if (bfd_read (hdr, 1, 3, abfd) != 3)
+ goto error_return;
+
+ if (! ISHEX (hdr[1]) || ! ISHEX (hdr[2]))
+ {
+ if (! ISHEX (hdr[1]))
+ c = hdr[1];
+ else
+ c = hdr[2];
+ srec_bad_byte (abfd, lineno, c, error);
+ goto error_return;
+ }
+
+ bytes = HEX (hdr + 1);
+ if (bytes * 2 > bufsize)
+ {
+ if (buf != NULL)
+ free (buf);
+ buf = (bfd_byte *) bfd_malloc (bytes * 2);
+ if (buf == NULL)
+ goto error_return;
+ bufsize = bytes * 2;
+ }
+
+ if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
+ goto error_return;
+
+ /* Ignore the checksum byte. */
+ --bytes;
+
+ address = 0;
+ data = buf;
+ switch (hdr[0])
+ {
+ case '0':
+ case '5':
+ /* Prologue--ignore the file name, but stop building a
+ section at this point. */
+ sec = NULL;
+ break;
+
+ case '3':
+ address = HEX (data);
+ data += 2;
+ --bytes;
+ /* Fall through. */
+ case '2':
+ address = (address << 8) | HEX (data);
+ data += 2;
+ --bytes;
+ /* Fall through. */
+ case '1':
+ address = (address << 8) | HEX (data);
+ data += 2;
+ address = (address << 8) | HEX (data);
+ data += 2;
+ bytes -= 2;
+
+ if (sec != NULL
+ && sec->vma + sec->_raw_size == address)
+ {
+ /* This data goes at the end of the section we are
+ currently building. */
+ sec->_raw_size += bytes;
+ }
+ else
+ {
+ char secbuf[20];
+ char *secname;
+
+ sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
+ secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
+ strcpy (secname, secbuf);
+ sec = bfd_make_section (abfd, secname);
+ if (sec == NULL)
+ goto error_return;
+ sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
+ sec->vma = address;
+ sec->lma = address;
+ sec->_raw_size = bytes;
+ sec->filepos = pos;
+ }
+
+ break;
+
+ case '7':
+ address = HEX (data);
+ data += 2;
+ /* Fall through. */
+ case '8':
+ address = (address << 8) | HEX (data);
+ data += 2;
+ /* Fall through. */
+ case '9':
+ address = (address << 8) | HEX (data);
+ data += 2;
+ address = (address << 8) | HEX (data);
+ data += 2;
+
+ /* This is a termination record. */
+ abfd->start_address = address;
+
+ if (buf != NULL)
+ free (buf);
+
+ return true;
+ }
+ }
+ break;
+ }
+ }
+
+ if (error)
+ goto error_return;
+
+ if (buf != NULL)
+ free (buf);
+
+ return true;
+
+ error_return:
+ if (symbuf != NULL)
+ free (symbuf);
+ if (buf != NULL)
+ free (buf);
+ return false;
+}
+
+/* Check whether an existing file is an S-record file. */
+
+static const bfd_target *
+srec_object_p (abfd)
+ bfd *abfd;
+{
+ bfd_byte b[4];
+
+ srec_init ();
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_read (b, 1, 4, abfd) != 4)
+ return NULL;
+
+ if (b[0] != 'S' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (! srec_mkobject (abfd)
+ || ! srec_scan (abfd))
+ return NULL;
+
+ if (abfd->symcount > 0)
+ abfd->flags |= HAS_SYMS;
+
+ return abfd->xvec;
+}
+
+/* Check whether an existing file is an S-record file with symbols. */
+
+static const bfd_target *
+symbolsrec_object_p (abfd)
+ bfd *abfd;
+{
+ char b[2];
+
+ srec_init ();
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_read (b, 1, 2, abfd) != 2)
+ return NULL;
+
+ if (b[0] != '$' || b[1] != '$')
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (! srec_mkobject (abfd)
+ || ! srec_scan (abfd))
+ return NULL;
+
+ if (abfd->symcount > 0)
+ abfd->flags |= HAS_SYMS;
+
+ return abfd->xvec;
+}
+
+/* Read in the contents of a section in an S-record file. */
+
+static boolean
+srec_read_section (abfd, section, contents)
+ bfd *abfd;
+ asection *section;
+ bfd_byte *contents;
+{
+ int c;
+ bfd_size_type sofar = 0;
+ boolean error = false;
+ bfd_byte *buf = NULL;
+ size_t bufsize = 0;
+
+ if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
+ goto error_return;
+
+ while ((c = srec_get_byte (abfd, &error)) != EOF)
+ {
+ bfd_byte hdr[3];
+ unsigned int bytes;
+ bfd_vma address;
+ bfd_byte *data;
+
+ if (c == '\r' || c == '\n')
+ continue;
+
+ /* This is called after srec_scan has already been called, so we
+ ought to know the exact format. */
+ BFD_ASSERT (c == 'S');
+
+ if (bfd_read (hdr, 1, 3, abfd) != 3)
+ goto error_return;
+
+ BFD_ASSERT (ISHEX (hdr[1]) && ISHEX (hdr[2]));
+
+ bytes = HEX (hdr + 1);
+
+ if (bytes * 2 > bufsize)
+ {
+ if (buf != NULL)
+ free (buf);
+ buf = (bfd_byte *) bfd_malloc (bytes * 2);
+ if (buf == NULL)
+ goto error_return;
+ bufsize = bytes * 2;
+ }
+
+ if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
+ goto error_return;
+
+ address = 0;
+ data = buf;
+ switch (hdr[0])
+ {
+ default:
+ BFD_ASSERT (sofar == section->_raw_size);
+ if (buf != NULL)
+ free (buf);
+ return true;
+
+ case '3':
+ address = HEX (data);
+ data += 2;
+ --bytes;
+ /* Fall through. */
+ case '2':
+ address = (address << 8) | HEX (data);
+ data += 2;
+ --bytes;
+ /* Fall through. */
+ case '1':
+ address = (address << 8) | HEX (data);
+ data += 2;
+ address = (address << 8) | HEX (data);
+ data += 2;
+ bytes -= 2;
+
+ if (address != section->vma + sofar)
+ {
+ /* We've come to the end of this section. */
+ BFD_ASSERT (sofar == section->_raw_size);
+ if (buf != NULL)
+ free (buf);
+ return true;
+ }
+
+ /* Don't consider checksum. */
+ --bytes;
+
+ while (bytes-- != 0)
+ {
+ contents[sofar] = HEX (data);
+ data += 2;
+ ++sofar;
+ }
+
+ break;
+ }
+ }
+
+ if (error)
+ goto error_return;
+
+ BFD_ASSERT (sofar == section->_raw_size);
+
+ if (buf != NULL)
+ free (buf);
+
+ return true;
+
+ error_return:
+ if (buf != NULL)
+ free (buf);
+ return false;
+}
+
+/* Get the contents of a section in an S-record file. */
+
+static boolean
+srec_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (section->used_by_bfd == NULL)
+ {
+ section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
+ if (section->used_by_bfd == NULL
+ && section->_raw_size != 0)
+ return false;
+
+ if (! srec_read_section (abfd, section, section->used_by_bfd))
+ return false;
+ }
+
+ memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
+ (size_t) count);
+
+ return true;
+}
+
+/* Set the architecture. We accept an unknown architecture here. */
+
+static boolean
+srec_set_arch_mach (abfd, arch, mach)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long mach;
+{
+ if (arch == bfd_arch_unknown)
+ {
+ abfd->arch_info = &bfd_default_arch_struct;
+ return true;
+ }
+ return bfd_default_set_arch_mach (abfd, arch, mach);
+}
+
+/* we have to save up all the Srecords for a splurge before output */
+
+static boolean
+srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type bytes_to_do;
+{
+ tdata_type *tdata = abfd->tdata.srec_data;
+ register srec_data_list_type *entry;
+
+ entry = ((srec_data_list_type *)
+ bfd_alloc (abfd, sizeof (srec_data_list_type)));
+ if (entry == NULL)
+ return false;
+
+ if (bytes_to_do
+ && (section->flags & SEC_ALLOC)
+ && (section->flags & SEC_LOAD))
+ {
+ bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
+ if (data == NULL)
+ return false;
+ memcpy ((PTR) data, location, (size_t) bytes_to_do);
+
+ if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
+ {
+
+ }
+ else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
+ && tdata->type <= 2)
+ {
+ tdata->type = 2;
+ }
+ else
+ {
+ tdata->type = 3;
+ }
+
+ entry->data = data;
+ entry->where = section->lma + offset;
+ entry->size = bytes_to_do;
+
+ /* Sort the records by address. Optimize for the common case of
+ adding a record to the end of the list. */
+ if (tdata->tail != NULL
+ && entry->where >= tdata->tail->where)
+ {
+ tdata->tail->next = entry;
+ entry->next = NULL;
+ tdata->tail = entry;
+ }
+ else
+ {
+ register srec_data_list_type **look;
+
+ for (look = &tdata->head;
+ *look != NULL && (*look)->where < entry->where;
+ look = &(*look)->next)
+ ;
+ entry->next = *look;
+ *look = entry;
+ if (entry->next == NULL)
+ tdata->tail = entry;
+ }
+ }
+ return true;
+}
+
+/* Write a record of type, of the supplied number of bytes. The
+ supplied bytes and length don't have a checksum. That's worked out
+ here
+*/
+static boolean
+srec_write_record (abfd, type, address, data, end)
+ bfd *abfd;
+ int type;
+ bfd_vma address;
+ const bfd_byte *data;
+ const bfd_byte *end;
+{
+ char buffer[MAXCHUNK];
+ unsigned int check_sum = 0;
+ CONST bfd_byte *src = data;
+ char *dst = buffer;
+ char *length;
+ bfd_size_type wrlen;
+
+ *dst++ = 'S';
+ *dst++ = '0' + type;
+
+ length = dst;
+ dst += 2; /* leave room for dst*/
+
+ switch (type)
+ {
+ case 3:
+ case 7:
+ TOHEX (dst, (address >> 24), check_sum);
+ dst += 2;
+ case 8:
+ case 2:
+ TOHEX (dst, (address >> 16), check_sum);
+ dst += 2;
+ case 9:
+ case 1:
+ case 0:
+ TOHEX (dst, (address >> 8), check_sum);
+ dst += 2;
+ TOHEX (dst, (address), check_sum);
+ dst += 2;
+ break;
+
+ }
+ for (src = data; src < end; src++)
+ {
+ TOHEX (dst, *src, check_sum);
+ dst += 2;
+ }
+
+ /* Fill in the length */
+ TOHEX (length, (dst - length) / 2, check_sum);
+ check_sum &= 0xff;
+ check_sum = 255 - check_sum;
+ TOHEX (dst, check_sum, check_sum);
+ dst += 2;
+
+ *dst++ = '\r';
+ *dst++ = '\n';
+ wrlen = dst - buffer;
+ if (bfd_write ((PTR) buffer, 1, wrlen, abfd) != wrlen)
+ return false;
+ return true;
+}
+
+
+
+static boolean
+srec_write_header (abfd)
+ bfd *abfd;
+{
+ bfd_byte buffer[MAXCHUNK];
+ bfd_byte *dst = buffer;
+ unsigned int i;
+
+ /* I'll put an arbitary 40 char limit on header size */
+ for (i = 0; i < 40 && abfd->filename[i]; i++)
+ {
+ *dst++ = abfd->filename[i];
+ }
+ return srec_write_record (abfd, 0, 0, buffer, dst);
+}
+
+static boolean
+srec_write_section (abfd, tdata, list)
+ bfd *abfd;
+ tdata_type *tdata;
+ srec_data_list_type *list;
+{
+ unsigned int bytes_written = 0;
+ bfd_byte *location = list->data;
+
+ while (bytes_written < list->size)
+ {
+ bfd_vma address;
+
+ unsigned int bytes_this_chunk = list->size - bytes_written;
+
+ if (bytes_this_chunk > CHUNK)
+ {
+ bytes_this_chunk = CHUNK;
+ }
+
+ address = list->where + bytes_written;
+
+ if (! srec_write_record (abfd,
+ tdata->type,
+ address,
+ location,
+ location + bytes_this_chunk))
+ return false;
+
+ bytes_written += bytes_this_chunk;
+ location += bytes_this_chunk;
+ }
+
+ return true;
+}
+
+static boolean
+srec_write_terminator (abfd, tdata)
+ bfd *abfd;
+ tdata_type *tdata;
+{
+ bfd_byte buffer[2];
+
+ return srec_write_record (abfd, 10 - tdata->type,
+ abfd->start_address, buffer, buffer);
+}
+
+
+
+static boolean
+srec_write_symbols (abfd)
+ bfd *abfd;
+{
+ char buffer[MAXCHUNK];
+ /* Dump out the symbols of a bfd */
+ int i;
+ int count = bfd_get_symcount (abfd);
+
+ if (count)
+ {
+ size_t len;
+ asymbol **table = bfd_get_outsymbols (abfd);
+ sprintf (buffer, "$$ %s\r\n", abfd->filename);
+
+ len = strlen (buffer);
+ if (bfd_write (buffer, len, 1, abfd) != len)
+ return false;
+
+ for (i = 0; i < count; i++)
+ {
+ asymbol *s = table[i];
+ if (! bfd_is_local_label (abfd, s)
+ && (s->flags & BSF_DEBUGGING) == 0)
+ {
+ /* Just dump out non debug symbols */
+ bfd_size_type l;
+ char buf2[40], *p;
+
+ sprintf_vma (buf2,
+ s->value + s->section->output_section->lma
+ + s->section->output_offset);
+ p = buf2;
+ while (p[0] == '0' && p[1] != 0)
+ p++;
+ sprintf (buffer, " %s $%s\r\n", s->name, p);
+ l = strlen (buffer);
+ if (bfd_write (buffer, l, 1, abfd) != l)
+ return false;
+ }
+ }
+ sprintf (buffer, "$$ \r\n");
+ len = strlen (buffer);
+ if (bfd_write (buffer, len, 1, abfd) != len)
+ return false;
+ }
+
+ return true;
+}
+
+static boolean
+internal_srec_write_object_contents (abfd, symbols)
+ bfd *abfd;
+ int symbols;
+{
+ tdata_type *tdata = abfd->tdata.srec_data;
+ srec_data_list_type *list;
+
+ if (symbols)
+ {
+ if (! srec_write_symbols (abfd))
+ return false;
+ }
+
+ if (! srec_write_header (abfd))
+ return false;
+
+ /* Now wander though all the sections provided and output them */
+ list = tdata->head;
+
+ while (list != (srec_data_list_type *) NULL)
+ {
+ if (! srec_write_section (abfd, tdata, list))
+ return false;
+ list = list->next;
+ }
+ return srec_write_terminator (abfd, tdata);
+}
+
+static boolean
+srec_write_object_contents (abfd)
+ bfd *abfd;
+{
+ return internal_srec_write_object_contents (abfd, 0);
+}
+
+static boolean
+symbolsrec_write_object_contents (abfd)
+ bfd *abfd;
+{
+ return internal_srec_write_object_contents (abfd, 1);
+}
+
+/*ARGSUSED*/
+static int
+srec_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+static asymbol *
+srec_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+/* Return the amount of memory needed to read the symbol table. */
+
+static long
+srec_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
+}
+
+/* Return the symbol table. */
+
+static long
+srec_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ unsigned int symcount = bfd_get_symcount (abfd);
+ asymbol *csymbols;
+ unsigned int i;
+
+ csymbols = abfd->tdata.srec_data->csymbols;
+ if (csymbols == NULL)
+ {
+ asymbol *c;
+ struct srec_symbol *s;
+
+ csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
+ if (csymbols == NULL && symcount != 0)
+ return false;
+ abfd->tdata.srec_data->csymbols = csymbols;
+
+ for (s = abfd->tdata.srec_data->symbols, c = csymbols;
+ s != NULL;
+ s = s->next, ++c)
+ {
+ c->the_bfd = abfd;
+ c->name = s->name;
+ c->value = s->val;
+ c->flags = BSF_GLOBAL;
+ c->section = bfd_abs_section_ptr;
+ c->udata.p = NULL;
+ }
+ }
+
+ for (i = 0; i < symcount; i++)
+ *alocation++ = csymbols++;
+ *alocation = NULL;
+
+ return symcount;
+}
+
+/*ARGSUSED*/
+static void
+srec_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+/*ARGSUSED*/
+static void
+srec_print_symbol (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ default:
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+ fprintf (file, " %-5s %s",
+ symbol->section->name,
+ symbol->name);
+
+ }
+}
+
+#define srec_close_and_cleanup _bfd_generic_close_and_cleanup
+#define srec_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define srec_new_section_hook _bfd_generic_new_section_hook
+
+#define srec_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define srec_get_lineno _bfd_nosymbols_get_lineno
+#define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define srec_read_minisymbols _bfd_generic_read_minisymbols
+#define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define srec_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
+#define srec_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
+#define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define srec_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+#define srec_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define srec_bfd_relax_section bfd_generic_relax_section
+#define srec_bfd_gc_sections bfd_generic_gc_sections
+#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define srec_bfd_final_link _bfd_generic_final_link
+#define srec_bfd_link_split_section _bfd_generic_link_split_section
+
+const bfd_target srec_vec =
+{
+ "srec", /* name */
+ bfd_target_srec_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ srec_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ srec_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ srec_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (srec),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (srec),
+ BFD_JUMP_TABLE_RELOCS (srec),
+ BFD_JUMP_TABLE_WRITE (srec),
+ BFD_JUMP_TABLE_LINK (srec),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
+
+
+
+const bfd_target symbolsrec_vec =
+{
+ "symbolsrec", /* name */
+ bfd_target_srec_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ symbolsrec_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ srec_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ symbolsrec_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (srec),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (srec),
+ BFD_JUMP_TABLE_RELOCS (srec),
+ BFD_JUMP_TABLE_WRITE (srec),
+ BFD_JUMP_TABLE_LINK (srec),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/stab-syms.c b/bfd/stab-syms.c
new file mode 100644
index 00000000000..f4fe6c8ba3c
--- /dev/null
+++ b/bfd/stab-syms.c
@@ -0,0 +1,57 @@
+/* Table of stab names for the BFD library.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+
+#define ARCH_SIZE 32 /* Value doesn't matter. */
+#include "libaout.h"
+#include "aout/aout64.h"
+
+/* Ignore duplicate stab codes; just return the string for the first
+ one. */
+#define __define_stab(NAME, CODE, STRING) __define_name(CODE, STRING)
+#define __define_stab_duplicate(NAME, CODE, STRING)
+
+/* These are not really stab symbols, but it is
+ convenient to have them here for the sake of nm.
+ For completeness, we could also add N_TEXT etc, but those
+ are never needed, since nm treats those specially. */
+#define EXTRA_SYMBOLS \
+ __define_name (N_SETA, "SETA")/* Absolute set element symbol */ \
+ __define_name (N_SETT, "SETT")/* Text set element symbol */ \
+ __define_name (N_SETD, "SETD")/* Data set element symbol */ \
+ __define_name (N_SETB, "SETB")/* Bss set element symbol */ \
+ __define_name (N_SETV, "SETV")/* Pointer to set vector in data area. */ \
+ __define_name (N_INDR, "INDR") \
+ __define_name (N_WARNING, "WARNING")
+
+const char *
+bfd_get_stab_name (code)
+ int code;
+{
+ switch (code)
+ {
+#define __define_name(val, str) case val: return str;
+#include "aout/stab.def"
+ EXTRA_SYMBOLS
+ }
+
+ return (const char *) 0;
+}
diff --git a/bfd/stabs.c b/bfd/stabs.c
new file mode 100644
index 00000000000..ffc000d499e
--- /dev/null
+++ b/bfd/stabs.c
@@ -0,0 +1,651 @@
+/* Stabs in sections linking support.
+ Copyright 1996, 1997, 1998 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file contains support for linking stabs in sections, as used
+ on COFF and ELF. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "aout/stab_gnu.h"
+
+#include <ctype.h>
+
+/* Stabs entries use a 12 byte format:
+ 4 byte string table index
+ 1 byte stab type
+ 1 byte stab other field
+ 2 byte stab desc field
+ 4 byte stab value
+ FIXME: This will have to change for a 64 bit object format.
+
+ The stabs symbols are divided into compilation units. For the
+ first entry in each unit, the type of 0, the value is the length of
+ the string table for this unit, and the desc field is the number of
+ stabs symbols for this unit. */
+
+#define STRDXOFF (0)
+#define TYPEOFF (4)
+#define OTHEROFF (5)
+#define DESCOFF (6)
+#define VALOFF (8)
+#define STABSIZE (12)
+
+/* A hash table used for header files with N_BINCL entries. */
+
+struct stab_link_includes_table
+{
+ struct bfd_hash_table root;
+};
+
+/* A linked list of totals that we have found for a particular header
+ file. */
+
+struct stab_link_includes_totals
+{
+ struct stab_link_includes_totals *next;
+ bfd_vma total;
+};
+
+/* An entry in the header file hash table. */
+
+struct stab_link_includes_entry
+{
+ struct bfd_hash_entry root;
+ /* List of totals we have found for this file. */
+ struct stab_link_includes_totals *totals;
+};
+
+/* Look up an entry in an the header file hash table. */
+
+#define stab_link_includes_lookup(table, string, create, copy) \
+ ((struct stab_link_includes_entry *) \
+ bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
+
+/* This structure is used to hold a list of N_BINCL symbols, some of
+ which might be converted into N_EXCL symbols. */
+
+struct stab_excl_list
+{
+ /* The next symbol to convert. */
+ struct stab_excl_list *next;
+ /* The offset to this symbol in the section contents. */
+ bfd_size_type offset;
+ /* The value to use for the symbol. */
+ bfd_vma val;
+ /* The type of this symbol (N_BINCL or N_EXCL). */
+ int type;
+};
+
+/* This structure is stored with each .stab section. */
+
+struct stab_section_info
+{
+ /* This is a linked list of N_BINCL symbols which should be
+ converted into N_EXCL symbols. */
+ struct stab_excl_list *excls;
+
+ /* This is used to map input stab offsets within their sections
+ to output stab offsets, to take into account stabs that have
+ been deleted. If it is NULL, the output offsets are the same
+ as the input offsets, because no stabs have been deleted from
+ this section. Otherwise the i'th entry is the number of
+ bytes of stabs that have been deleted prior to the i'th
+ stab. */
+ bfd_size_type *cumulative_skips;
+
+ /* This is an array of string indices. For each stab symbol, we
+ store the string index here. If a stab symbol should not be
+ included in the final output, the string index is -1. */
+ bfd_size_type stridxs[1];
+};
+
+/* This structure is used to keep track of stabs in sections
+ information while linking. */
+
+struct stab_info
+{
+ /* A hash table used to hold stabs strings. */
+ struct bfd_strtab_hash *strings;
+ /* The header file hash table. */
+ struct stab_link_includes_table includes;
+ /* The first .stabstr section. */
+ asection *stabstr;
+};
+
+static struct bfd_hash_entry *stab_link_includes_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+/* The function to create a new entry in the header file hash table. */
+
+static struct bfd_hash_entry *
+stab_link_includes_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct stab_link_includes_entry *ret =
+ (struct stab_link_includes_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct stab_link_includes_entry *) NULL)
+ ret = ((struct stab_link_includes_entry *)
+ bfd_hash_allocate (table,
+ sizeof (struct stab_link_includes_entry)));
+ if (ret == (struct stab_link_includes_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct stab_link_includes_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+ if (ret)
+ {
+ /* Set local fields. */
+ ret->totals = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* This function is called for each input file from the add_symbols
+ pass of the linker. */
+
+boolean
+_bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo)
+ bfd *abfd;
+ PTR *psinfo;
+ asection *stabsec;
+ asection *stabstrsec;
+ PTR *psecinfo;
+{
+ boolean first;
+ struct stab_info *sinfo;
+ bfd_size_type count;
+ struct stab_section_info *secinfo;
+ bfd_byte *stabbuf = NULL;
+ bfd_byte *stabstrbuf = NULL;
+ bfd_byte *sym, *symend;
+ bfd_size_type stroff, next_stroff, skip;
+ bfd_size_type *pstridx;
+
+ if (stabsec->_raw_size == 0
+ || stabstrsec->_raw_size == 0)
+ {
+ /* This file does not contain stabs debugging information. */
+ return true;
+ }
+
+ if (stabsec->_raw_size % STABSIZE != 0)
+ {
+ /* Something is wrong with the format of these stab symbols.
+ Don't try to optimize them. */
+ return true;
+ }
+
+ if ((stabstrsec->flags & SEC_RELOC) != 0)
+ {
+ /* We shouldn't see relocations in the strings, and we aren't
+ prepared to handle them. */
+ return true;
+ }
+
+ if ((stabsec->output_section != NULL
+ && bfd_is_abs_section (stabsec->output_section))
+ || (stabstrsec->output_section != NULL
+ && bfd_is_abs_section (stabstrsec->output_section)))
+ {
+ /* At least one of the sections is being discarded from the
+ link, so we should just ignore them. */
+ return true;
+ }
+
+ first = false;
+
+ if (*psinfo == NULL)
+ {
+ /* Initialize the stabs information we need to keep track of. */
+ first = true;
+ *psinfo = (PTR) bfd_alloc (abfd, sizeof (struct stab_info));
+ if (*psinfo == NULL)
+ goto error_return;
+ sinfo = (struct stab_info *) *psinfo;
+ sinfo->strings = _bfd_stringtab_init ();
+ if (sinfo->strings == NULL)
+ goto error_return;
+ if (! bfd_hash_table_init_n (&sinfo->includes.root,
+ stab_link_includes_newfunc,
+ 251))
+ goto error_return;
+ sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
+ sinfo->stabstr->flags |= SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
+ }
+
+ sinfo = (struct stab_info *) *psinfo;
+
+ /* Initialize the information we are going to store for this .stab
+ section. */
+
+ count = stabsec->_raw_size / STABSIZE;
+
+ *psecinfo = bfd_alloc (abfd,
+ (sizeof (struct stab_section_info)
+ + (count - 1) * sizeof (bfd_size_type)));
+ if (*psecinfo == NULL)
+ goto error_return;
+
+ secinfo = (struct stab_section_info *) *psecinfo;
+ secinfo->excls = NULL;
+ secinfo->cumulative_skips = NULL;
+ memset (secinfo->stridxs, 0, count * sizeof (bfd_size_type));
+
+ /* Read the stabs information from abfd. */
+
+ stabbuf = (bfd_byte *) bfd_malloc (stabsec->_raw_size);
+ stabstrbuf = (bfd_byte *) bfd_malloc (stabstrsec->_raw_size);
+ if (stabbuf == NULL || stabstrbuf == NULL)
+ goto error_return;
+
+ if (! bfd_get_section_contents (abfd, stabsec, stabbuf, 0,
+ stabsec->_raw_size)
+ || ! bfd_get_section_contents (abfd, stabstrsec, stabstrbuf, 0,
+ stabstrsec->_raw_size))
+ goto error_return;
+
+ /* Look through the stabs symbols, work out the new string indices,
+ and identify N_BINCL symbols which can be eliminated. */
+
+ stroff = 0;
+ next_stroff = 0;
+ skip = 0;
+
+ symend = stabbuf + stabsec->_raw_size;
+ for (sym = stabbuf, pstridx = secinfo->stridxs;
+ sym < symend;
+ sym += STABSIZE, ++pstridx)
+ {
+ int type;
+ const char *string;
+
+ if (*pstridx != 0)
+ {
+ /* This symbol has already been handled by an N_BINCL pass. */
+ continue;
+ }
+
+ type = sym[TYPEOFF];
+
+ if (type == 0)
+ {
+ /* Special type 0 stabs indicate the offset to the next
+ string table. We only copy the very first one. */
+ stroff = next_stroff;
+ next_stroff += bfd_get_32 (abfd, sym + 8);
+ if (! first)
+ {
+ *pstridx = (bfd_size_type) -1;
+ ++skip;
+ continue;
+ }
+ first = false;
+ }
+
+ /* Store the string in the hash table, and record the index. */
+ string = ((char *) stabstrbuf
+ + stroff
+ + bfd_get_32 (abfd, sym + STRDXOFF));
+ *pstridx = _bfd_stringtab_add (sinfo->strings, string, true, true);
+
+ /* An N_BINCL symbol indicates the start of the stabs entries
+ for a header file. We need to scan ahead to the next N_EINCL
+ symbol, ignoring nesting, adding up all the characters in the
+ symbol names, not including the file numbers in types (the
+ first number after an open parenthesis). */
+ if (type == N_BINCL)
+ {
+ bfd_vma val;
+ int nest;
+ bfd_byte *incl_sym;
+ struct stab_link_includes_entry *incl_entry;
+ struct stab_link_includes_totals *t;
+ struct stab_excl_list *ne;
+
+ val = 0;
+ nest = 0;
+ for (incl_sym = sym + STABSIZE;
+ incl_sym < symend;
+ incl_sym += STABSIZE)
+ {
+ int incl_type;
+
+ incl_type = incl_sym[TYPEOFF];
+ if (incl_type == 0)
+ break;
+ else if (incl_type == N_EINCL)
+ {
+ if (nest == 0)
+ break;
+ --nest;
+ }
+ else if (incl_type == N_BINCL)
+ ++nest;
+ else if (nest == 0)
+ {
+ const char *str;
+
+ str = ((char *) stabstrbuf
+ + stroff
+ + bfd_get_32 (abfd, incl_sym + STRDXOFF));
+ for (; *str != '\0'; str++)
+ {
+ val += *str;
+ if (*str == '(')
+ {
+ /* Skip the file number. */
+ ++str;
+ while (isdigit ((unsigned char) *str))
+ ++str;
+ --str;
+ }
+ }
+ }
+ }
+
+ /* If we have already included a header file with the same
+ value, then replaced this one with an N_EXCL symbol. */
+ incl_entry = stab_link_includes_lookup (&sinfo->includes, string,
+ true, true);
+ if (incl_entry == NULL)
+ goto error_return;
+
+ for (t = incl_entry->totals; t != NULL; t = t->next)
+ if (t->total == val)
+ break;
+
+ /* Record this symbol, so that we can set the value
+ correctly. */
+ ne = (struct stab_excl_list *) bfd_alloc (abfd, sizeof *ne);
+ if (ne == NULL)
+ goto error_return;
+ ne->offset = sym - stabbuf;
+ ne->val = val;
+ ne->type = N_BINCL;
+ ne->next = secinfo->excls;
+ secinfo->excls = ne;
+
+ if (t == NULL)
+ {
+ /* This is the first time we have seen this header file
+ with this set of stabs strings. */
+ t = ((struct stab_link_includes_totals *)
+ bfd_hash_allocate (&sinfo->includes.root, sizeof *t));
+ if (t == NULL)
+ goto error_return;
+ t->total = val;
+ t->next = incl_entry->totals;
+ incl_entry->totals = t;
+ }
+ else
+ {
+ bfd_size_type *incl_pstridx;
+
+ /* We have seen this header file before. Tell the final
+ pass to change the type to N_EXCL. */
+ ne->type = N_EXCL;
+
+ /* Mark the skipped symbols. */
+
+ nest = 0;
+ for (incl_sym = sym + STABSIZE, incl_pstridx = pstridx + 1;
+ incl_sym < symend;
+ incl_sym += STABSIZE, ++incl_pstridx)
+ {
+ int incl_type;
+
+ incl_type = incl_sym[TYPEOFF];
+
+ if (incl_type == N_EINCL)
+ {
+ if (nest == 0)
+ {
+ *incl_pstridx = (bfd_size_type) -1;
+ ++skip;
+ break;
+ }
+ --nest;
+ }
+ else if (incl_type == N_BINCL)
+ ++nest;
+ else if (nest == 0)
+ {
+ *incl_pstridx = (bfd_size_type) -1;
+ ++skip;
+ }
+ }
+ }
+ }
+ }
+
+ free (stabbuf);
+ stabbuf = NULL;
+ free (stabstrbuf);
+ stabstrbuf = NULL;
+
+ /* We need to set the section sizes such that the linker will
+ compute the output section sizes correctly. We set the .stab
+ size to not include the entries we don't want. We set
+ SEC_EXCLUDE for the .stabstr section, so that it will be dropped
+ from the link. We record the size of the strtab in the first
+ .stabstr section we saw, and make sure we don't set SEC_EXCLUDE
+ for that section. */
+ stabsec->_cooked_size = (count - skip) * STABSIZE;
+ if (stabsec->_cooked_size == 0)
+ stabsec->flags |= SEC_EXCLUDE;
+ stabstrsec->flags |= SEC_EXCLUDE;
+ sinfo->stabstr->_cooked_size = _bfd_stringtab_size (sinfo->strings);
+
+ /* Calculate the `cumulative_skips' array now that stabs have been
+ deleted for this section. */
+
+ if (skip != 0)
+ {
+ bfd_size_type i, offset;
+ bfd_size_type *pskips;
+
+ secinfo->cumulative_skips =
+ (bfd_size_type *) bfd_alloc (abfd, count * sizeof (bfd_size_type));
+ if (secinfo->cumulative_skips == NULL)
+ goto error_return;
+
+ pskips = secinfo->cumulative_skips;
+ pstridx = secinfo->stridxs;
+ offset = 0;
+
+ for (i = 0; i < count; i++, pskips++, pstridx++)
+ {
+ *pskips = offset;
+ if (*pstridx == (bfd_size_type) -1)
+ offset += STABSIZE;
+ }
+
+ BFD_ASSERT (offset != 0);
+ }
+
+ return true;
+
+ error_return:
+ if (stabbuf != NULL)
+ free (stabbuf);
+ if (stabstrbuf != NULL)
+ free (stabstrbuf);
+ return false;
+}
+
+/* Write out the stab section. This is called with the relocated
+ contents. */
+
+boolean
+_bfd_write_section_stabs (output_bfd, psinfo, stabsec, psecinfo, contents)
+ bfd *output_bfd;
+ PTR *psinfo;
+ asection *stabsec;
+ PTR *psecinfo;
+ bfd_byte *contents;
+{
+ struct stab_info *sinfo;
+ struct stab_section_info *secinfo;
+ struct stab_excl_list *e;
+ bfd_byte *sym, *tosym, *symend;
+ bfd_size_type *pstridx;
+
+ sinfo = (struct stab_info *) *psinfo;
+ secinfo = (struct stab_section_info *) *psecinfo;
+
+ if (secinfo == NULL)
+ return bfd_set_section_contents (output_bfd, stabsec->output_section,
+ contents, stabsec->output_offset,
+ stabsec->_raw_size);
+
+ /* Handle each N_BINCL entry. */
+ for (e = secinfo->excls; e != NULL; e = e->next)
+ {
+ bfd_byte *excl_sym;
+
+ BFD_ASSERT (e->offset < stabsec->_raw_size);
+ excl_sym = contents + e->offset;
+ bfd_put_32 (output_bfd, e->val, excl_sym + VALOFF);
+ excl_sym[TYPEOFF] = e->type;
+ }
+
+ /* Copy over all the stabs symbols, omitting the ones we don't want,
+ and correcting the string indices for those we do want. */
+ tosym = contents;
+ symend = contents + stabsec->_raw_size;
+ for (sym = contents, pstridx = secinfo->stridxs;
+ sym < symend;
+ sym += STABSIZE, ++pstridx)
+ {
+ if (*pstridx != (bfd_size_type) -1)
+ {
+ if (tosym != sym)
+ memcpy (tosym, sym, STABSIZE);
+ bfd_put_32 (output_bfd, *pstridx, tosym + STRDXOFF);
+
+ if (sym[TYPEOFF] == 0)
+ {
+ /* This is the header symbol for the stabs section. We
+ don't really need one, since we have merged all the
+ input stabs sections into one, but we generate one
+ for the benefit of readers which expect to see one. */
+ BFD_ASSERT (sym == contents);
+ bfd_put_32 (output_bfd, _bfd_stringtab_size (sinfo->strings),
+ tosym + VALOFF);
+ bfd_put_16 (output_bfd,
+ stabsec->output_section->_raw_size / STABSIZE - 1,
+ tosym + DESCOFF);
+ }
+
+ tosym += STABSIZE;
+ }
+ }
+
+ BFD_ASSERT ((bfd_size_type) (tosym - contents) == stabsec->_cooked_size);
+
+ return bfd_set_section_contents (output_bfd, stabsec->output_section,
+ contents, stabsec->output_offset,
+ stabsec->_cooked_size);
+}
+
+/* Write out the .stabstr section. */
+
+boolean
+_bfd_write_stab_strings (output_bfd, psinfo)
+ bfd *output_bfd;
+ PTR *psinfo;
+{
+ struct stab_info *sinfo;
+
+ sinfo = (struct stab_info *) *psinfo;
+
+ if (sinfo == NULL)
+ return true;
+
+ if (bfd_is_abs_section (sinfo->stabstr->output_section))
+ {
+ /* The section was discarded from the link. */
+ return true;
+ }
+
+ BFD_ASSERT ((sinfo->stabstr->output_offset
+ + _bfd_stringtab_size (sinfo->strings))
+ <= sinfo->stabstr->output_section->_raw_size);
+
+ if (bfd_seek (output_bfd,
+ (sinfo->stabstr->output_section->filepos
+ + sinfo->stabstr->output_offset),
+ SEEK_SET) != 0)
+ return false;
+
+ if (! _bfd_stringtab_emit (output_bfd, sinfo->strings))
+ return false;
+
+ /* We no longer need the stabs information. */
+ _bfd_stringtab_free (sinfo->strings);
+ bfd_hash_table_free (&sinfo->includes.root);
+
+ return true;
+}
+
+/* Adjust an address in the .stab section. Given OFFSET within
+ STABSEC, this returns the new offset in the adjusted stab section,
+ or -1 if the address refers to a stab which has been removed. */
+
+bfd_vma
+_bfd_stab_section_offset (output_bfd, psinfo, stabsec, psecinfo, offset)
+ bfd *output_bfd;
+ PTR *psinfo;
+ asection *stabsec;
+ PTR *psecinfo;
+ bfd_vma offset;
+{
+ struct stab_section_info *secinfo;
+
+ secinfo = (struct stab_section_info *) *psecinfo;
+
+ if (secinfo == NULL)
+ return offset;
+
+ if (offset >= stabsec->_raw_size)
+ return offset - (stabsec->_cooked_size - stabsec->_raw_size);
+
+ if (secinfo->cumulative_skips)
+ {
+ bfd_vma i;
+
+ i = offset / STABSIZE;
+
+ if (secinfo->stridxs [i] == (bfd_size_type) -1)
+ return (bfd_vma) -1;
+
+ return offset - secinfo->cumulative_skips [i];
+ }
+
+ return offset;
+}
diff --git a/bfd/stamp-h.in b/bfd/stamp-h.in
new file mode 100644
index 00000000000..9788f70238c
--- /dev/null
+++ b/bfd/stamp-h.in
@@ -0,0 +1 @@
+timestamp
diff --git a/bfd/sunos.c b/bfd/sunos.c
new file mode 100644
index 00000000000..e34f87803cf
--- /dev/null
+++ b/bfd/sunos.c
@@ -0,0 +1,2948 @@
+/* BFD backend for SunOS binaries.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGETNAME "a.out-sunos-big"
+#define MY(OP) CAT(sunos_big_,OP)
+
+#include "bfd.h"
+#include "bfdlink.h"
+#include "libaout.h"
+
+/* Static routines defined in this file. */
+
+static boolean sunos_read_dynamic_info PARAMS ((bfd *));
+static long sunos_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
+static boolean sunos_slurp_dynamic_symtab PARAMS ((bfd *));
+static long sunos_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
+static long sunos_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
+static long sunos_canonicalize_dynamic_reloc
+ PARAMS ((bfd *, arelent **, asymbol **));
+static struct bfd_hash_entry *sunos_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *sunos_link_hash_table_create
+ PARAMS ((bfd *));
+static boolean sunos_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *, boolean));
+static boolean sunos_add_dynamic_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, struct external_nlist **,
+ bfd_size_type *, char **));
+static boolean sunos_add_one_symbol
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
+ bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
+static boolean sunos_scan_relocs
+ PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_size_type));
+static boolean sunos_scan_std_relocs
+ PARAMS ((struct bfd_link_info *, bfd *, asection *,
+ const struct reloc_std_external *, bfd_size_type));
+static boolean sunos_scan_ext_relocs
+ PARAMS ((struct bfd_link_info *, bfd *, asection *,
+ const struct reloc_ext_external *, bfd_size_type));
+static boolean sunos_link_dynamic_object
+ PARAMS ((struct bfd_link_info *, bfd *));
+static boolean sunos_write_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct aout_link_hash_entry *));
+static boolean sunos_check_dynamic_reloc
+ PARAMS ((struct bfd_link_info *, bfd *, asection *,
+ struct aout_link_hash_entry *, PTR, bfd_byte *, boolean *,
+ bfd_vma *));
+static boolean sunos_finish_dynamic_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+#define MY_get_dynamic_symtab_upper_bound sunos_get_dynamic_symtab_upper_bound
+#define MY_canonicalize_dynamic_symtab sunos_canonicalize_dynamic_symtab
+#define MY_get_dynamic_reloc_upper_bound sunos_get_dynamic_reloc_upper_bound
+#define MY_canonicalize_dynamic_reloc sunos_canonicalize_dynamic_reloc
+#define MY_bfd_link_hash_table_create sunos_link_hash_table_create
+#define MY_add_dynamic_symbols sunos_add_dynamic_symbols
+#define MY_add_one_symbol sunos_add_one_symbol
+#define MY_link_dynamic_object sunos_link_dynamic_object
+#define MY_write_dynamic_symbol sunos_write_dynamic_symbol
+#define MY_check_dynamic_reloc sunos_check_dynamic_reloc
+#define MY_finish_dynamic_link sunos_finish_dynamic_link
+
+/* ??? Where should this go? */
+#define MACHTYPE_OK(mtype) \
+ (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
+ || ((mtype) == M_SPARCLET \
+ && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \
+ || ((mtype) == M_SPARCLITE_LE \
+ && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \
+ || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
+ && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
+
+/* Include the usual a.out support. */
+#include "aoutf1.h"
+
+/* The SunOS 4.1.4 /usr/include/locale.h defines valid as a macro. */
+#undef valid
+
+/* SunOS shared library support. We store a pointer to this structure
+ in obj_aout_dynamic_info (abfd). */
+
+struct sunos_dynamic_info
+{
+ /* Whether we found any dynamic information. */
+ boolean valid;
+ /* Dynamic information. */
+ struct internal_sun4_dynamic_link dyninfo;
+ /* Number of dynamic symbols. */
+ unsigned long dynsym_count;
+ /* Read in nlists for dynamic symbols. */
+ struct external_nlist *dynsym;
+ /* asymbol structures for dynamic symbols. */
+ aout_symbol_type *canonical_dynsym;
+ /* Read in dynamic string table. */
+ char *dynstr;
+ /* Number of dynamic relocs. */
+ unsigned long dynrel_count;
+ /* Read in dynamic relocs. This may be reloc_std_external or
+ reloc_ext_external. */
+ PTR dynrel;
+ /* arelent structures for dynamic relocs. */
+ arelent *canonical_dynrel;
+};
+
+/* The hash table of dynamic symbols is composed of two word entries.
+ See include/aout/sun4.h for details. */
+
+#define HASH_ENTRY_SIZE (2 * BYTES_IN_WORD)
+
+/* Read in the basic dynamic information. This locates the __DYNAMIC
+ structure and uses it to find the dynamic_link structure. It
+ creates and saves a sunos_dynamic_info structure. If it can't find
+ __DYNAMIC, it sets the valid field of the sunos_dynamic_info
+ structure to false to avoid doing this work again. */
+
+static boolean
+sunos_read_dynamic_info (abfd)
+ bfd *abfd;
+{
+ struct sunos_dynamic_info *info;
+ asection *dynsec;
+ bfd_vma dynoff;
+ struct external_sun4_dynamic dyninfo;
+ unsigned long dynver;
+ struct external_sun4_dynamic_link linkinfo;
+
+ if (obj_aout_dynamic_info (abfd) != (PTR) NULL)
+ return true;
+
+ if ((abfd->flags & DYNAMIC) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ info = ((struct sunos_dynamic_info *)
+ bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
+ if (!info)
+ return false;
+ info->valid = false;
+ info->dynsym = NULL;
+ info->dynstr = NULL;
+ info->canonical_dynsym = NULL;
+ info->dynrel = NULL;
+ info->canonical_dynrel = NULL;
+ obj_aout_dynamic_info (abfd) = (PTR) info;
+
+ /* This code used to look for the __DYNAMIC symbol to locate the dynamic
+ linking information.
+ However this inhibits recovering the dynamic symbols from a
+ stripped object file, so blindly assume that the dynamic linking
+ information is located at the start of the data section.
+ We could verify this assumption later by looking through the dynamic
+ symbols for the __DYNAMIC symbol. */
+ if ((abfd->flags & DYNAMIC) == 0)
+ return true;
+ if (! bfd_get_section_contents (abfd, obj_datasec (abfd), (PTR) &dyninfo,
+ (file_ptr) 0, sizeof dyninfo))
+ return true;
+
+ dynver = GET_WORD (abfd, dyninfo.ld_version);
+ if (dynver != 2 && dynver != 3)
+ return true;
+
+ dynoff = GET_WORD (abfd, dyninfo.ld);
+
+ /* dynoff is a virtual address. It is probably always in the .data
+ section, but this code should work even if it moves. */
+ if (dynoff < bfd_get_section_vma (abfd, obj_datasec (abfd)))
+ dynsec = obj_textsec (abfd);
+ else
+ dynsec = obj_datasec (abfd);
+ dynoff -= bfd_get_section_vma (abfd, dynsec);
+ if (dynoff > bfd_section_size (abfd, dynsec))
+ return true;
+
+ /* This executable appears to be dynamically linked in a way that we
+ can understand. */
+ if (! bfd_get_section_contents (abfd, dynsec, (PTR) &linkinfo, dynoff,
+ (bfd_size_type) sizeof linkinfo))
+ return true;
+
+ /* Swap in the dynamic link information. */
+ info->dyninfo.ld_loaded = GET_WORD (abfd, linkinfo.ld_loaded);
+ info->dyninfo.ld_need = GET_WORD (abfd, linkinfo.ld_need);
+ info->dyninfo.ld_rules = GET_WORD (abfd, linkinfo.ld_rules);
+ info->dyninfo.ld_got = GET_WORD (abfd, linkinfo.ld_got);
+ info->dyninfo.ld_plt = GET_WORD (abfd, linkinfo.ld_plt);
+ info->dyninfo.ld_rel = GET_WORD (abfd, linkinfo.ld_rel);
+ info->dyninfo.ld_hash = GET_WORD (abfd, linkinfo.ld_hash);
+ info->dyninfo.ld_stab = GET_WORD (abfd, linkinfo.ld_stab);
+ info->dyninfo.ld_stab_hash = GET_WORD (abfd, linkinfo.ld_stab_hash);
+ info->dyninfo.ld_buckets = GET_WORD (abfd, linkinfo.ld_buckets);
+ info->dyninfo.ld_symbols = GET_WORD (abfd, linkinfo.ld_symbols);
+ info->dyninfo.ld_symb_size = GET_WORD (abfd, linkinfo.ld_symb_size);
+ info->dyninfo.ld_text = GET_WORD (abfd, linkinfo.ld_text);
+ info->dyninfo.ld_plt_sz = GET_WORD (abfd, linkinfo.ld_plt_sz);
+
+ /* Reportedly the addresses need to be offset by the size of the
+ exec header in an NMAGIC file. */
+ if (adata (abfd).magic == n_magic)
+ {
+ unsigned long exec_bytes_size = adata (abfd).exec_bytes_size;
+
+ info->dyninfo.ld_need += exec_bytes_size;
+ info->dyninfo.ld_rules += exec_bytes_size;
+ info->dyninfo.ld_rel += exec_bytes_size;
+ info->dyninfo.ld_hash += exec_bytes_size;
+ info->dyninfo.ld_stab += exec_bytes_size;
+ info->dyninfo.ld_symbols += exec_bytes_size;
+ }
+
+ /* The only way to get the size of the symbol information appears to
+ be to determine the distance between it and the string table. */
+ info->dynsym_count = ((info->dyninfo.ld_symbols - info->dyninfo.ld_stab)
+ / EXTERNAL_NLIST_SIZE);
+ BFD_ASSERT (info->dynsym_count * EXTERNAL_NLIST_SIZE
+ == (unsigned long) (info->dyninfo.ld_symbols
+ - info->dyninfo.ld_stab));
+
+ /* Similarly, the relocs end at the hash table. */
+ info->dynrel_count = ((info->dyninfo.ld_hash - info->dyninfo.ld_rel)
+ / obj_reloc_entry_size (abfd));
+ BFD_ASSERT (info->dynrel_count * obj_reloc_entry_size (abfd)
+ == (unsigned long) (info->dyninfo.ld_hash
+ - info->dyninfo.ld_rel));
+
+ info->valid = true;
+
+ return true;
+}
+
+/* Return the amount of memory required for the dynamic symbols. */
+
+static long
+sunos_get_dynamic_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ struct sunos_dynamic_info *info;
+
+ if (! sunos_read_dynamic_info (abfd))
+ return -1;
+
+ info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
+ if (! info->valid)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ return (info->dynsym_count + 1) * sizeof (asymbol *);
+}
+
+/* Read the external dynamic symbols. */
+
+static boolean
+sunos_slurp_dynamic_symtab (abfd)
+ bfd *abfd;
+{
+ struct sunos_dynamic_info *info;
+
+ /* Get the general dynamic information. */
+ if (obj_aout_dynamic_info (abfd) == NULL)
+ {
+ if (! sunos_read_dynamic_info (abfd))
+ return false;
+ }
+
+ info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
+ if (! info->valid)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return false;
+ }
+
+ /* Get the dynamic nlist structures. */
+ if (info->dynsym == (struct external_nlist *) NULL)
+ {
+ info->dynsym = ((struct external_nlist *)
+ bfd_alloc (abfd,
+ (info->dynsym_count
+ * EXTERNAL_NLIST_SIZE)));
+ if (info->dynsym == NULL && info->dynsym_count != 0)
+ return false;
+ if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
+ || (bfd_read ((PTR) info->dynsym, info->dynsym_count,
+ EXTERNAL_NLIST_SIZE, abfd)
+ != info->dynsym_count * EXTERNAL_NLIST_SIZE))
+ {
+ if (info->dynsym != NULL)
+ {
+ bfd_release (abfd, info->dynsym);
+ info->dynsym = NULL;
+ }
+ return false;
+ }
+ }
+
+ /* Get the dynamic strings. */
+ if (info->dynstr == (char *) NULL)
+ {
+ info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
+ if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
+ return false;
+ if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0
+ || (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size,
+ abfd)
+ != info->dyninfo.ld_symb_size))
+ {
+ if (info->dynstr != NULL)
+ {
+ bfd_release (abfd, info->dynstr);
+ info->dynstr = NULL;
+ }
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Read in the dynamic symbols. */
+
+static long
+sunos_canonicalize_dynamic_symtab (abfd, storage)
+ bfd *abfd;
+ asymbol **storage;
+{
+ struct sunos_dynamic_info *info;
+ unsigned long i;
+
+ if (! sunos_slurp_dynamic_symtab (abfd))
+ return -1;
+
+ info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
+
+#ifdef CHECK_DYNAMIC_HASH
+ /* Check my understanding of the dynamic hash table by making sure
+ that each symbol can be located in the hash table. */
+ {
+ bfd_size_type table_size;
+ bfd_byte *table;
+ bfd_size_type i;
+
+ if (info->dyninfo.ld_buckets > info->dynsym_count)
+ abort ();
+ table_size = info->dyninfo.ld_stab - info->dyninfo.ld_hash;
+ table = (bfd_byte *) bfd_malloc (table_size);
+ if (table == NULL && table_size != 0)
+ abort ();
+ if (bfd_seek (abfd, info->dyninfo.ld_hash, SEEK_SET) != 0
+ || bfd_read ((PTR) table, 1, table_size, abfd) != table_size)
+ abort ();
+ for (i = 0; i < info->dynsym_count; i++)
+ {
+ unsigned char *name;
+ unsigned long hash;
+
+ name = ((unsigned char *) info->dynstr
+ + GET_WORD (abfd, info->dynsym[i].e_strx));
+ hash = 0;
+ while (*name != '\0')
+ hash = (hash << 1) + *name++;
+ hash &= 0x7fffffff;
+ hash %= info->dyninfo.ld_buckets;
+ while (GET_WORD (abfd, table + hash * HASH_ENTRY_SIZE) != i)
+ {
+ hash = GET_WORD (abfd,
+ table + hash * HASH_ENTRY_SIZE + BYTES_IN_WORD);
+ if (hash == 0 || hash >= table_size / HASH_ENTRY_SIZE)
+ abort ();
+ }
+ }
+ free (table);
+ }
+#endif /* CHECK_DYNAMIC_HASH */
+
+ /* Get the asymbol structures corresponding to the dynamic nlist
+ structures. */
+ if (info->canonical_dynsym == (aout_symbol_type *) NULL)
+ {
+ info->canonical_dynsym = ((aout_symbol_type *)
+ bfd_alloc (abfd,
+ (info->dynsym_count
+ * sizeof (aout_symbol_type))));
+ if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
+ return -1;
+
+ if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
+ info->dynsym, info->dynsym_count,
+ info->dynstr,
+ info->dyninfo.ld_symb_size,
+ true))
+ {
+ if (info->canonical_dynsym != NULL)
+ {
+ bfd_release (abfd, info->canonical_dynsym);
+ info->canonical_dynsym = NULL;
+ }
+ return -1;
+ }
+ }
+
+ /* Return pointers to the dynamic asymbol structures. */
+ for (i = 0; i < info->dynsym_count; i++)
+ *storage++ = (asymbol *) (info->canonical_dynsym + i);
+ *storage = NULL;
+
+ return info->dynsym_count;
+}
+
+/* Return the amount of memory required for the dynamic relocs. */
+
+static long
+sunos_get_dynamic_reloc_upper_bound (abfd)
+ bfd *abfd;
+{
+ struct sunos_dynamic_info *info;
+
+ if (! sunos_read_dynamic_info (abfd))
+ return -1;
+
+ info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
+ if (! info->valid)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ return (info->dynrel_count + 1) * sizeof (arelent *);
+}
+
+/* Read in the dynamic relocs. */
+
+static long
+sunos_canonicalize_dynamic_reloc (abfd, storage, syms)
+ bfd *abfd;
+ arelent **storage;
+ asymbol **syms;
+{
+ struct sunos_dynamic_info *info;
+ unsigned long i;
+
+ /* Get the general dynamic information. */
+ if (obj_aout_dynamic_info (abfd) == (PTR) NULL)
+ {
+ if (! sunos_read_dynamic_info (abfd))
+ return -1;
+ }
+
+ info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
+ if (! info->valid)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ /* Get the dynamic reloc information. */
+ if (info->dynrel == NULL)
+ {
+ info->dynrel = (PTR) bfd_alloc (abfd,
+ (info->dynrel_count
+ * obj_reloc_entry_size (abfd)));
+ if (info->dynrel == NULL && info->dynrel_count != 0)
+ return -1;
+ if (bfd_seek (abfd, info->dyninfo.ld_rel, SEEK_SET) != 0
+ || (bfd_read ((PTR) info->dynrel, info->dynrel_count,
+ obj_reloc_entry_size (abfd), abfd)
+ != info->dynrel_count * obj_reloc_entry_size (abfd)))
+ {
+ if (info->dynrel != NULL)
+ {
+ bfd_release (abfd, info->dynrel);
+ info->dynrel = NULL;
+ }
+ return -1;
+ }
+ }
+
+ /* Get the arelent structures corresponding to the dynamic reloc
+ information. */
+ if (info->canonical_dynrel == (arelent *) NULL)
+ {
+ arelent *to;
+
+ info->canonical_dynrel = ((arelent *)
+ bfd_alloc (abfd,
+ (info->dynrel_count
+ * sizeof (arelent))));
+ if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
+ return -1;
+
+ to = info->canonical_dynrel;
+
+ if (obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE)
+ {
+ register struct reloc_ext_external *p;
+ struct reloc_ext_external *pend;
+
+ p = (struct reloc_ext_external *) info->dynrel;
+ pend = p + info->dynrel_count;
+ for (; p < pend; p++, to++)
+ NAME(aout,swap_ext_reloc_in) (abfd, p, to, syms,
+ info->dynsym_count);
+ }
+ else
+ {
+ register struct reloc_std_external *p;
+ struct reloc_std_external *pend;
+
+ p = (struct reloc_std_external *) info->dynrel;
+ pend = p + info->dynrel_count;
+ for (; p < pend; p++, to++)
+ NAME(aout,swap_std_reloc_in) (abfd, p, to, syms,
+ info->dynsym_count);
+ }
+ }
+
+ /* Return pointers to the dynamic arelent structures. */
+ for (i = 0; i < info->dynrel_count; i++)
+ *storage++ = info->canonical_dynrel + i;
+ *storage = NULL;
+
+ return info->dynrel_count;
+}
+
+/* Code to handle linking of SunOS shared libraries. */
+
+/* A SPARC procedure linkage table entry is 12 bytes. The first entry
+ in the table is a jump which is filled in by the runtime linker.
+ The remaining entries are branches back to the first entry,
+ followed by an index into the relocation table encoded to look like
+ a sethi of %g0. */
+
+#define SPARC_PLT_ENTRY_SIZE (12)
+
+static const bfd_byte sparc_plt_first_entry[SPARC_PLT_ENTRY_SIZE] =
+{
+ /* sethi %hi(0),%g1; address filled in by runtime linker. */
+ 0x3, 0, 0, 0,
+ /* jmp %g1; offset filled in by runtime linker. */
+ 0x81, 0xc0, 0x60, 0,
+ /* nop */
+ 0x1, 0, 0, 0
+};
+
+/* save %sp, -96, %sp */
+#define SPARC_PLT_ENTRY_WORD0 0x9de3bfa0
+/* call; address filled in later. */
+#define SPARC_PLT_ENTRY_WORD1 0x40000000
+/* sethi; reloc index filled in later. */
+#define SPARC_PLT_ENTRY_WORD2 0x01000000
+
+/* This sequence is used when for the jump table entry to a defined
+ symbol in a complete executable. It is used when linking PIC
+ compiled code which is not being put into a shared library. */
+/* sethi <address to be filled in later>, %g1 */
+#define SPARC_PLT_PIC_WORD0 0x03000000
+/* jmp %g1 + <address to be filled in later> */
+#define SPARC_PLT_PIC_WORD1 0x81c06000
+/* nop */
+#define SPARC_PLT_PIC_WORD2 0x01000000
+
+/* An m68k procedure linkage table entry is 8 bytes. The first entry
+ in the table is a jump which is filled in the by the runtime
+ linker. The remaining entries are branches back to the first
+ entry, followed by a two byte index into the relocation table. */
+
+#define M68K_PLT_ENTRY_SIZE (8)
+
+static const bfd_byte m68k_plt_first_entry[M68K_PLT_ENTRY_SIZE] =
+{
+ /* jmps @# */
+ 0x4e, 0xf9,
+ /* Filled in by runtime linker with a magic address. */
+ 0, 0, 0, 0,
+ /* Not used? */
+ 0, 0
+};
+
+/* bsrl */
+#define M68K_PLT_ENTRY_WORD0 (0x61ff)
+/* Remaining words filled in later. */
+
+/* An entry in the SunOS linker hash table. */
+
+struct sunos_link_hash_entry
+{
+ struct aout_link_hash_entry root;
+
+ /* If this is a dynamic symbol, this is its index into the dynamic
+ symbol table. This is initialized to -1. As the linker looks at
+ the input files, it changes this to -2 if it will be added to the
+ dynamic symbol table. After all the input files have been seen,
+ the linker will know whether to build a dynamic symbol table; if
+ it does build one, this becomes the index into the table. */
+ long dynindx;
+
+ /* If this is a dynamic symbol, this is the index of the name in the
+ dynamic symbol string table. */
+ long dynstr_index;
+
+ /* The offset into the global offset table used for this symbol. If
+ the symbol does not require a GOT entry, this is 0. */
+ bfd_vma got_offset;
+
+ /* The offset into the procedure linkage table used for this symbol.
+ If the symbol does not require a PLT entry, this is 0. */
+ bfd_vma plt_offset;
+
+ /* Some linker flags. */
+ unsigned char flags;
+ /* Symbol is referenced by a regular object. */
+#define SUNOS_REF_REGULAR 01
+ /* Symbol is defined by a regular object. */
+#define SUNOS_DEF_REGULAR 02
+ /* Symbol is referenced by a dynamic object. */
+#define SUNOS_REF_DYNAMIC 04
+ /* Symbol is defined by a dynamic object. */
+#define SUNOS_DEF_DYNAMIC 010
+ /* Symbol is a constructor symbol in a regular object. */
+#define SUNOS_CONSTRUCTOR 020
+};
+
+/* The SunOS linker hash table. */
+
+struct sunos_link_hash_table
+{
+ struct aout_link_hash_table root;
+
+ /* The object which holds the dynamic sections. */
+ bfd *dynobj;
+
+ /* Whether we have created the dynamic sections. */
+ boolean dynamic_sections_created;
+
+ /* Whether we need the dynamic sections. */
+ boolean dynamic_sections_needed;
+
+ /* Whether we need the .got table. */
+ boolean got_needed;
+
+ /* The number of dynamic symbols. */
+ size_t dynsymcount;
+
+ /* The number of buckets in the hash table. */
+ size_t bucketcount;
+
+ /* The list of dynamic objects needed by dynamic objects included in
+ the link. */
+ struct bfd_link_needed_list *needed;
+
+ /* The offset of __GLOBAL_OFFSET_TABLE_ into the .got section. */
+ bfd_vma got_base;
+};
+
+/* Routine to create an entry in an SunOS link hash table. */
+
+static struct bfd_hash_entry *
+sunos_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct sunos_link_hash_entry *ret = (struct sunos_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct sunos_link_hash_entry *) NULL)
+ ret = ((struct sunos_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct sunos_link_hash_entry)));
+ if (ret == (struct sunos_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct sunos_link_hash_entry *)
+ NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != NULL)
+ {
+ /* Set local fields. */
+ ret->dynindx = -1;
+ ret->dynstr_index = -1;
+ ret->got_offset = 0;
+ ret->plt_offset = 0;
+ ret->flags = 0;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a SunOS link hash table. */
+
+static struct bfd_link_hash_table *
+sunos_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct sunos_link_hash_table *ret;
+
+ ret = ((struct sunos_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct sunos_link_hash_table)));
+ if (ret == (struct sunos_link_hash_table *) NULL)
+ return (struct bfd_link_hash_table *) NULL;
+ if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
+ sunos_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->dynobj = NULL;
+ ret->dynamic_sections_created = false;
+ ret->dynamic_sections_needed = false;
+ ret->got_needed = false;
+ ret->dynsymcount = 0;
+ ret->bucketcount = 0;
+ ret->needed = NULL;
+ ret->got_base = 0;
+
+ return &ret->root.root;
+}
+
+/* Look up an entry in an SunOS link hash table. */
+
+#define sunos_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct sunos_link_hash_entry *) \
+ aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
+ (follow)))
+
+/* Traverse a SunOS link hash table. */
+
+#define sunos_link_hash_traverse(table, func, info) \
+ (aout_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the SunOS link hash table from the info structure. This is
+ just a cast. */
+
+#define sunos_hash_table(p) ((struct sunos_link_hash_table *) ((p)->hash))
+
+static boolean sunos_scan_dynamic_symbol
+ PARAMS ((struct sunos_link_hash_entry *, PTR));
+
+/* Create the dynamic sections needed if we are linking against a
+ dynamic object, or if we are linking PIC compiled code. ABFD is a
+ bfd we can attach the dynamic sections to. The linker script will
+ look for these special sections names and put them in the right
+ place in the output file. See include/aout/sun4.h for more details
+ of the dynamic linking information. */
+
+static boolean
+sunos_create_dynamic_sections (abfd, info, needed)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean needed;
+{
+ asection *s;
+
+ if (! sunos_hash_table (info)->dynamic_sections_created)
+ {
+ flagword flags;
+
+ sunos_hash_table (info)->dynobj = abfd;
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+
+ /* The .dynamic section holds the basic dynamic information: the
+ sun4_dynamic structure, the dynamic debugger information, and
+ the sun4_dynamic_link structure. */
+ s = bfd_make_section (abfd, ".dynamic");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ /* The .got section holds the global offset table. The address
+ is put in the ld_got field. */
+ s = bfd_make_section (abfd, ".got");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ /* The .plt section holds the procedure linkage table. The
+ address is put in the ld_plt field. */
+ s = bfd_make_section (abfd, ".plt");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ /* The .dynrel section holds the dynamic relocs. The address is
+ put in the ld_rel field. */
+ s = bfd_make_section (abfd, ".dynrel");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ /* The .hash section holds the dynamic hash table. The address
+ is put in the ld_hash field. */
+ s = bfd_make_section (abfd, ".hash");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ /* The .dynsym section holds the dynamic symbols. The address
+ is put in the ld_stab field. */
+ s = bfd_make_section (abfd, ".dynsym");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ /* The .dynstr section holds the dynamic symbol string table.
+ The address is put in the ld_symbols field. */
+ s = bfd_make_section (abfd, ".dynstr");
+ if (s == NULL
+ || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
+ || ! bfd_set_section_alignment (abfd, s, 2))
+ return false;
+
+ sunos_hash_table (info)->dynamic_sections_created = true;
+ }
+
+ if ((needed && ! sunos_hash_table (info)->dynamic_sections_needed)
+ || info->shared)
+ {
+ bfd *dynobj;
+
+ dynobj = sunos_hash_table (info)->dynobj;
+
+ s = bfd_get_section_by_name (dynobj, ".got");
+ if (s->_raw_size == 0)
+ s->_raw_size = BYTES_IN_WORD;
+
+ sunos_hash_table (info)->dynamic_sections_needed = true;
+ sunos_hash_table (info)->got_needed = true;
+ }
+
+ return true;
+}
+
+/* Add dynamic symbols during a link. This is called by the a.out
+ backend linker for each object it encounters. */
+
+static boolean
+sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ struct external_nlist **symsp;
+ bfd_size_type *sym_countp;
+ char **stringsp;
+{
+ asection *s;
+ bfd *dynobj;
+ struct sunos_dynamic_info *dinfo;
+ unsigned long need;
+
+ /* Make sure we have all the required sections. */
+ if (info->hash->creator == abfd->xvec)
+ {
+ if (! sunos_create_dynamic_sections (abfd, info,
+ (((abfd->flags & DYNAMIC) != 0
+ && ! info->relocateable)
+ ? true
+ : false)))
+ return false;
+ }
+
+ /* There is nothing else to do for a normal object. */
+ if ((abfd->flags & DYNAMIC) == 0)
+ return true;
+
+ dynobj = sunos_hash_table (info)->dynobj;
+
+ /* We do not want to include the sections in a dynamic object in the
+ output file. We hack by simply clobbering the list of sections
+ in the BFD. This could be handled more cleanly by, say, a new
+ section flag; the existing SEC_NEVER_LOAD flag is not the one we
+ want, because that one still implies that the section takes up
+ space in the output file. If this is the first object we have
+ seen, we must preserve the dynamic sections we just created. */
+ if (abfd != dynobj)
+ abfd->sections = NULL;
+ else
+ {
+ asection *s;
+
+ for (s = abfd->sections;
+ (s->flags & SEC_LINKER_CREATED) == 0;
+ s = s->next)
+ ;
+ abfd->sections = s;
+ }
+
+ /* The native linker seems to just ignore dynamic objects when -r is
+ used. */
+ if (info->relocateable)
+ return true;
+
+ /* There's no hope of using a dynamic object which does not exactly
+ match the format of the output file. */
+ if (info->hash->creator != abfd->xvec)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ /* Make sure we have a .need and a .rules sections. These are only
+ needed if there really is a dynamic object in the link, so they
+ are not added by sunos_create_dynamic_sections. */
+ if (bfd_get_section_by_name (dynobj, ".need") == NULL)
+ {
+ /* The .need section holds the list of names of shared objets
+ which must be included at runtime. The address of this
+ section is put in the ld_need field. */
+ s = bfd_make_section (dynobj, ".need");
+ if (s == NULL
+ || ! bfd_set_section_flags (dynobj, s,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, s, 2))
+ return false;
+ }
+
+ if (bfd_get_section_by_name (dynobj, ".rules") == NULL)
+ {
+ /* The .rules section holds the path to search for shared
+ objects. The address of this section is put in the ld_rules
+ field. */
+ s = bfd_make_section (dynobj, ".rules");
+ if (s == NULL
+ || ! bfd_set_section_flags (dynobj, s,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, s, 2))
+ return false;
+ }
+
+ /* Pick up the dynamic symbols and return them to the caller. */
+ if (! sunos_slurp_dynamic_symtab (abfd))
+ return false;
+
+ dinfo = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
+ *symsp = dinfo->dynsym;
+ *sym_countp = dinfo->dynsym_count;
+ *stringsp = dinfo->dynstr;
+
+ /* Record information about any other objects needed by this one. */
+ need = dinfo->dyninfo.ld_need;
+ while (need != 0)
+ {
+ bfd_byte buf[16];
+ unsigned long name, flags;
+ unsigned short major_vno, minor_vno;
+ struct bfd_link_needed_list *needed, **pp;
+ char *namebuf, *p;
+ size_t alc;
+ bfd_byte b;
+ char *namecopy;
+
+ if (bfd_seek (abfd, need, SEEK_SET) != 0
+ || bfd_read (buf, 1, 16, abfd) != 16)
+ return false;
+
+ /* For the format of an ld_need entry, see aout/sun4.h. We
+ should probably define structs for this manipulation. */
+
+ name = bfd_get_32 (abfd, buf);
+ flags = bfd_get_32 (abfd, buf + 4);
+ major_vno = (unsigned short)bfd_get_16 (abfd, buf + 8);
+ minor_vno = (unsigned short)bfd_get_16 (abfd, buf + 10);
+ need = bfd_get_32 (abfd, buf + 12);
+
+ needed = ((struct bfd_link_needed_list *)
+ bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
+ if (needed == NULL)
+ return false;
+ needed->by = abfd;
+
+ /* We return the name as [-l]name[.maj][.min]. */
+ alc = 30;
+ namebuf = (char *) bfd_malloc (alc + 1);
+ if (namebuf == NULL)
+ return false;
+ p = namebuf;
+
+ if ((flags & 0x80000000) != 0)
+ {
+ *p++ = '-';
+ *p++ = 'l';
+ }
+ if (bfd_seek (abfd, name, SEEK_SET) != 0)
+ {
+ free (namebuf);
+ return false;
+ }
+
+ do
+ {
+ if (bfd_read (&b, 1, 1, abfd) != 1)
+ {
+ free (namebuf);
+ return false;
+ }
+
+ if ((size_t) (p - namebuf) >= alc)
+ {
+ char *n;
+
+ alc *= 2;
+ n = (char *) bfd_realloc (namebuf, alc + 1);
+ if (n == NULL)
+ {
+ free (namebuf);
+ return false;
+ }
+ p = n + (p - namebuf);
+ namebuf = n;
+ }
+
+ *p++ = b;
+ }
+ while (b != '\0');
+
+ if (major_vno == 0)
+ *p = '\0';
+ else
+ {
+ char majbuf[30];
+ char minbuf[30];
+
+ sprintf (majbuf, ".%d", major_vno);
+ if (minor_vno == 0)
+ minbuf[0] = '\0';
+ else
+ sprintf (minbuf, ".%d", minor_vno);
+
+ if ((p - namebuf) + strlen (majbuf) + strlen (minbuf) >= alc)
+ {
+ char *n;
+
+ alc = (p - namebuf) + strlen (majbuf) + strlen (minbuf);
+ n = (char *) bfd_realloc (namebuf, alc + 1);
+ if (n == NULL)
+ {
+ free (namebuf);
+ return false;
+ }
+ p = n + (p - namebuf);
+ namebuf = n;
+ }
+
+ strcpy (p, majbuf);
+ strcat (p, minbuf);
+ }
+
+ namecopy = bfd_alloc (abfd, strlen (namebuf) + 1);
+ if (namecopy == NULL)
+ {
+ free (namebuf);
+ return false;
+ }
+ strcpy (namecopy, namebuf);
+ free (namebuf);
+ needed->name = namecopy;
+
+ needed->next = NULL;
+
+ for (pp = &sunos_hash_table (info)->needed;
+ *pp != NULL;
+ pp = &(*pp)->next)
+ ;
+ *pp = needed;
+ }
+
+ return true;
+}
+
+/* Function to add a single symbol to the linker hash table. This is
+ a wrapper around _bfd_generic_link_add_one_symbol which handles the
+ tweaking needed for dynamic linking support. */
+
+static boolean
+sunos_add_one_symbol (info, abfd, name, flags, section, value, string,
+ copy, collect, hashp)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ const char *name;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ const char *string;
+ boolean copy;
+ boolean collect;
+ struct bfd_link_hash_entry **hashp;
+{
+ struct sunos_link_hash_entry *h;
+ int new_flag;
+
+ if ((flags & (BSF_INDIRECT | BSF_WARNING | BSF_CONSTRUCTOR)) != 0
+ || ! bfd_is_und_section (section))
+ h = sunos_link_hash_lookup (sunos_hash_table (info), name, true, copy,
+ false);
+ else
+ h = ((struct sunos_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (abfd, info, name, true, copy, false));
+ if (h == NULL)
+ return false;
+
+ if (hashp != NULL)
+ *hashp = (struct bfd_link_hash_entry *) h;
+
+ /* Treat a common symbol in a dynamic object as defined in the .bss
+ section of the dynamic object. We don't want to allocate space
+ for it in our process image. */
+ if ((abfd->flags & DYNAMIC) != 0
+ && bfd_is_com_section (section))
+ section = obj_bsssec (abfd);
+
+ if (! bfd_is_und_section (section)
+ && h->root.root.type != bfd_link_hash_new
+ && h->root.root.type != bfd_link_hash_undefined
+ && h->root.root.type != bfd_link_hash_defweak)
+ {
+ /* We are defining the symbol, and it is already defined. This
+ is a potential multiple definition error. */
+ if ((abfd->flags & DYNAMIC) != 0)
+ {
+ /* The definition we are adding is from a dynamic object.
+ We do not want this new definition to override the
+ existing definition, so we pretend it is just a
+ reference. */
+ section = bfd_und_section_ptr;
+ }
+ else if (h->root.root.type == bfd_link_hash_defined
+ && h->root.root.u.def.section->owner != NULL
+ && (h->root.root.u.def.section->owner->flags & DYNAMIC) != 0)
+ {
+ /* The existing definition is from a dynamic object. We
+ want to override it with the definition we just found.
+ Clobber the existing definition. */
+ h->root.root.type = bfd_link_hash_undefined;
+ h->root.root.u.undef.abfd = h->root.root.u.def.section->owner;
+ }
+ else if (h->root.root.type == bfd_link_hash_common
+ && (h->root.root.u.c.p->section->owner->flags & DYNAMIC) != 0)
+ {
+ /* The existing definition is from a dynamic object. We
+ want to override it with the definition we just found.
+ Clobber the existing definition. We can't set it to new,
+ because it is on the undefined list. */
+ h->root.root.type = bfd_link_hash_undefined;
+ h->root.root.u.undef.abfd = h->root.root.u.c.p->section->owner;
+ }
+ }
+
+ if ((abfd->flags & DYNAMIC) != 0
+ && abfd->xvec == info->hash->creator
+ && (h->flags & SUNOS_CONSTRUCTOR) != 0)
+ {
+ /* The existing symbol is a constructor symbol, and this symbol
+ is from a dynamic object. A constructor symbol is actually a
+ definition, although the type will be bfd_link_hash_undefined
+ at this point. We want to ignore the definition from the
+ dynamic object. */
+ section = bfd_und_section_ptr;
+ }
+ else if ((flags & BSF_CONSTRUCTOR) != 0
+ && (abfd->flags & DYNAMIC) == 0
+ && h->root.root.type == bfd_link_hash_defined
+ && h->root.root.u.def.section->owner != NULL
+ && (h->root.root.u.def.section->owner->flags & DYNAMIC) != 0)
+ {
+ /* The existing symbol is defined by a dynamic object, and this
+ is a constructor symbol. As above, we want to force the use
+ of the constructor symbol from the regular object. */
+ h->root.root.type = bfd_link_hash_new;
+ }
+
+ /* Do the usual procedure for adding a symbol. */
+ if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
+ value, string, copy, collect,
+ hashp))
+ return false;
+
+ if (abfd->xvec == info->hash->creator)
+ {
+ /* Set a flag in the hash table entry indicating the type of
+ reference or definition we just found. Keep a count of the
+ number of dynamic symbols we find. A dynamic symbol is one
+ which is referenced or defined by both a regular object and a
+ shared object. */
+ if ((abfd->flags & DYNAMIC) == 0)
+ {
+ if (bfd_is_und_section (section))
+ new_flag = SUNOS_REF_REGULAR;
+ else
+ new_flag = SUNOS_DEF_REGULAR;
+ }
+ else
+ {
+ if (bfd_is_und_section (section))
+ new_flag = SUNOS_REF_DYNAMIC;
+ else
+ new_flag = SUNOS_DEF_DYNAMIC;
+ }
+ h->flags |= new_flag;
+
+ if (h->dynindx == -1
+ && (h->flags & (SUNOS_DEF_REGULAR | SUNOS_REF_REGULAR)) != 0)
+ {
+ ++sunos_hash_table (info)->dynsymcount;
+ h->dynindx = -2;
+ }
+
+ if ((flags & BSF_CONSTRUCTOR) != 0
+ && (abfd->flags & DYNAMIC) == 0)
+ h->flags |= SUNOS_CONSTRUCTOR;
+ }
+
+ return true;
+}
+
+/* Return the list of objects needed by BFD. */
+
+/*ARGSUSED*/
+struct bfd_link_needed_list *
+bfd_sunos_get_needed_list (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (info->hash->creator != &MY(vec))
+ return NULL;
+ return sunos_hash_table (info)->needed;
+}
+
+/* Record an assignment made to a symbol by a linker script. We need
+ this in case some dynamic object refers to this symbol. */
+
+boolean
+bfd_sunos_record_link_assignment (output_bfd, info, name)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ const char *name;
+{
+ struct sunos_link_hash_entry *h;
+
+ if (output_bfd->xvec != &MY(vec))
+ return true;
+
+ /* This is called after we have examined all the input objects. If
+ the symbol does not exist, it merely means that no object refers
+ to it, and we can just ignore it at this point. */
+ h = sunos_link_hash_lookup (sunos_hash_table (info), name,
+ false, false, false);
+ if (h == NULL)
+ return true;
+
+ /* In a shared library, the __DYNAMIC symbol does not appear in the
+ dynamic symbol table. */
+ if (! info->shared || strcmp (name, "__DYNAMIC") != 0)
+ {
+ h->flags |= SUNOS_DEF_REGULAR;
+
+ if (h->dynindx == -1)
+ {
+ ++sunos_hash_table (info)->dynsymcount;
+ h->dynindx = -2;
+ }
+ }
+
+ return true;
+}
+
+/* Set up the sizes and contents of the dynamic sections created in
+ sunos_add_dynamic_symbols. This is called by the SunOS linker
+ emulation before_allocation routine. We must set the sizes of the
+ sections before the linker sets the addresses of the various
+ sections. This unfortunately requires reading all the relocs so
+ that we can work out which ones need to become dynamic relocs. If
+ info->keep_memory is true, we keep the relocs in memory; otherwise,
+ we discard them, and will read them again later. */
+
+boolean
+bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
+ srulesptr)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ asection **sdynptr;
+ asection **sneedptr;
+ asection **srulesptr;
+{
+ bfd *dynobj;
+ size_t dynsymcount;
+ struct sunos_link_hash_entry *h;
+ asection *s;
+ size_t bucketcount;
+ size_t hashalloc;
+ size_t i;
+ bfd *sub;
+
+ *sdynptr = NULL;
+ *sneedptr = NULL;
+ *srulesptr = NULL;
+
+ if (info->relocateable)
+ return true;
+
+ if (output_bfd->xvec != &MY(vec))
+ return true;
+
+ /* Look through all the input BFD's and read their relocs. It would
+ be better if we didn't have to do this, but there is no other way
+ to determine the number of dynamic relocs we need, and, more
+ importantly, there is no other way to know which symbols should
+ get an entry in the procedure linkage table. */
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ if ((sub->flags & DYNAMIC) == 0
+ && sub->xvec == output_bfd->xvec)
+ {
+ if (! sunos_scan_relocs (info, sub, obj_textsec (sub),
+ exec_hdr (sub)->a_trsize)
+ || ! sunos_scan_relocs (info, sub, obj_datasec (sub),
+ exec_hdr (sub)->a_drsize))
+ return false;
+ }
+ }
+
+ dynobj = sunos_hash_table (info)->dynobj;
+ dynsymcount = sunos_hash_table (info)->dynsymcount;
+
+ /* If there were no dynamic objects in the link, and we don't need
+ to build a global offset table, there is nothing to do here. */
+ if (! sunos_hash_table (info)->dynamic_sections_needed
+ && ! sunos_hash_table (info)->got_needed)
+ return true;
+
+ /* If __GLOBAL_OFFSET_TABLE_ was mentioned, define it. */
+ h = sunos_link_hash_lookup (sunos_hash_table (info),
+ "__GLOBAL_OFFSET_TABLE_", false, false, false);
+ if (h != NULL && (h->flags & SUNOS_REF_REGULAR) != 0)
+ {
+ h->flags |= SUNOS_DEF_REGULAR;
+ if (h->dynindx == -1)
+ {
+ ++sunos_hash_table (info)->dynsymcount;
+ h->dynindx = -2;
+ }
+ h->root.root.type = bfd_link_hash_defined;
+ h->root.root.u.def.section = bfd_get_section_by_name (dynobj, ".got");
+
+ /* If the .got section is more than 0x1000 bytes, we set
+ __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section,
+ so that 13 bit relocations have a greater chance of working. */
+ s = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (s != NULL);
+ if (s->_raw_size >= 0x1000)
+ h->root.root.u.def.value = 0x1000;
+ else
+ h->root.root.u.def.value = 0;
+
+ sunos_hash_table (info)->got_base = h->root.root.u.def.value;
+ }
+
+ /* If there are any shared objects in the link, then we need to set
+ up the dynamic linking information. */
+ if (sunos_hash_table (info)->dynamic_sections_needed)
+ {
+ *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ /* The .dynamic section is always the same size. */
+ s = *sdynptr;
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = (sizeof (struct external_sun4_dynamic)
+ + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
+ + sizeof (struct external_sun4_dynamic_link));
+
+ /* Set the size of the .dynsym and .hash sections. We counted
+ the number of dynamic symbols as we read the input files. We
+ will build the dynamic symbol table (.dynsym) and the hash
+ table (.hash) when we build the final symbol table, because
+ until then we do not know the correct value to give the
+ symbols. We build the dynamic symbol string table (.dynstr)
+ in a traversal of the symbol table using
+ sunos_scan_dynamic_symbol. */
+ s = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (s != NULL);
+ s->_raw_size = dynsymcount * sizeof (struct external_nlist);
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ if (s->contents == NULL && s->_raw_size != 0)
+ return false;
+
+ /* The number of buckets is just the number of symbols divided
+ by four. To compute the final size of the hash table, we
+ must actually compute the hash table. Normally we need
+ exactly as many entries in the hash table as there are
+ dynamic symbols, but if some of the buckets are not used we
+ will need additional entries. In the worst case, every
+ symbol will hash to the same bucket, and we will need
+ BUCKETCOUNT - 1 extra entries. */
+ if (dynsymcount >= 4)
+ bucketcount = dynsymcount / 4;
+ else if (dynsymcount > 0)
+ bucketcount = dynsymcount;
+ else
+ bucketcount = 1;
+ s = bfd_get_section_by_name (dynobj, ".hash");
+ BFD_ASSERT (s != NULL);
+ hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
+ if (s->contents == NULL && dynsymcount > 0)
+ return false;
+ memset (s->contents, 0, hashalloc);
+ for (i = 0; i < bucketcount; i++)
+ PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
+ s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
+
+ sunos_hash_table (info)->bucketcount = bucketcount;
+
+ /* Scan all the symbols, place them in the dynamic symbol table,
+ and build the dynamic hash table. We reuse dynsymcount as a
+ counter for the number of symbols we have added so far. */
+ sunos_hash_table (info)->dynsymcount = 0;
+ sunos_link_hash_traverse (sunos_hash_table (info),
+ sunos_scan_dynamic_symbol,
+ (PTR) info);
+ BFD_ASSERT (sunos_hash_table (info)->dynsymcount == dynsymcount);
+
+ /* The SunOS native linker seems to align the total size of the
+ symbol strings to a multiple of 8. I don't know if this is
+ important, but it can't hurt much. */
+ s = bfd_get_section_by_name (dynobj, ".dynstr");
+ BFD_ASSERT (s != NULL);
+ if ((s->_raw_size & 7) != 0)
+ {
+ bfd_size_type add;
+ bfd_byte *contents;
+
+ add = 8 - (s->_raw_size & 7);
+ contents = (bfd_byte *) bfd_realloc (s->contents,
+ (size_t) (s->_raw_size + add));
+ if (contents == NULL)
+ return false;
+ memset (contents + s->_raw_size, 0, (size_t) add);
+ s->contents = contents;
+ s->_raw_size += add;
+ }
+ }
+
+ /* Now that we have worked out the sizes of the procedure linkage
+ table and the dynamic relocs, allocate storage for them. */
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+ if (s->_raw_size != 0)
+ {
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+
+ /* Fill in the first entry in the table. */
+ switch (bfd_get_arch (dynobj))
+ {
+ case bfd_arch_sparc:
+ memcpy (s->contents, sparc_plt_first_entry, SPARC_PLT_ENTRY_SIZE);
+ break;
+
+ case bfd_arch_m68k:
+ memcpy (s->contents, m68k_plt_first_entry, M68K_PLT_ENTRY_SIZE);
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ s = bfd_get_section_by_name (dynobj, ".dynrel");
+ if (s->_raw_size != 0)
+ {
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ }
+ /* We use the reloc_count field to keep track of how many of the
+ relocs we have output so far. */
+ s->reloc_count = 0;
+
+ /* Make space for the global offset table. */
+ s = bfd_get_section_by_name (dynobj, ".got");
+ s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+
+ *sneedptr = bfd_get_section_by_name (dynobj, ".need");
+ *srulesptr = bfd_get_section_by_name (dynobj, ".rules");
+
+ return true;
+}
+
+/* Scan the relocs for an input section. */
+
+static boolean
+sunos_scan_relocs (info, abfd, sec, rel_size)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ asection *sec;
+ bfd_size_type rel_size;
+{
+ PTR relocs;
+ PTR free_relocs = NULL;
+
+ if (rel_size == 0)
+ return true;
+
+ if (! info->keep_memory)
+ relocs = free_relocs = bfd_malloc ((size_t) rel_size);
+ else
+ {
+ struct aout_section_data_struct *n;
+
+ n = ((struct aout_section_data_struct *)
+ bfd_alloc (abfd, sizeof (struct aout_section_data_struct)));
+ if (n == NULL)
+ relocs = NULL;
+ else
+ {
+ set_aout_section_data (sec, n);
+ relocs = bfd_malloc ((size_t) rel_size);
+ aout_section_data (sec)->relocs = relocs;
+ }
+ }
+ if (relocs == NULL)
+ return false;
+
+ if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
+ || bfd_read (relocs, 1, rel_size, abfd) != rel_size)
+ goto error_return;
+
+ if (obj_reloc_entry_size (abfd) == RELOC_STD_SIZE)
+ {
+ if (! sunos_scan_std_relocs (info, abfd, sec,
+ (struct reloc_std_external *) relocs,
+ rel_size))
+ goto error_return;
+ }
+ else
+ {
+ if (! sunos_scan_ext_relocs (info, abfd, sec,
+ (struct reloc_ext_external *) relocs,
+ rel_size))
+ goto error_return;
+ }
+
+ if (free_relocs != NULL)
+ free (free_relocs);
+
+ return true;
+
+ error_return:
+ if (free_relocs != NULL)
+ free (free_relocs);
+ return false;
+}
+
+/* Scan the relocs for an input section using standard relocs. We
+ need to figure out what to do for each reloc against a dynamic
+ symbol. If the symbol is in the .text section, an entry is made in
+ the procedure linkage table. Note that this will do the wrong
+ thing if the symbol is actually data; I don't think the Sun 3
+ native linker handles this case correctly either. If the symbol is
+ not in the .text section, we must preserve the reloc as a dynamic
+ reloc. FIXME: We should also handle the PIC relocs here by
+ building global offset table entries. */
+
+static boolean
+sunos_scan_std_relocs (info, abfd, sec, relocs, rel_size)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ asection *sec;
+ const struct reloc_std_external *relocs;
+ bfd_size_type rel_size;
+{
+ bfd *dynobj;
+ asection *splt = NULL;
+ asection *srel = NULL;
+ struct sunos_link_hash_entry **sym_hashes;
+ const struct reloc_std_external *rel, *relend;
+
+ /* We only know how to handle m68k plt entries. */
+ if (bfd_get_arch (abfd) != bfd_arch_m68k)
+ {
+ bfd_set_error (bfd_error_invalid_target);
+ return false;
+ }
+
+ dynobj = NULL;
+
+ sym_hashes = (struct sunos_link_hash_entry **) obj_aout_sym_hashes (abfd);
+
+ relend = relocs + rel_size / RELOC_STD_SIZE;
+ for (rel = relocs; rel < relend; rel++)
+ {
+ int r_index;
+ struct sunos_link_hash_entry *h;
+
+ /* We only want relocs against external symbols. */
+ if (bfd_header_big_endian (abfd))
+ {
+ if ((rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG) == 0)
+ continue;
+ }
+ else
+ {
+ if ((rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE) == 0)
+ continue;
+ }
+
+ /* Get the symbol index. */
+ if (bfd_header_big_endian (abfd))
+ r_index = ((rel->r_index[0] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[2]);
+ else
+ r_index = ((rel->r_index[2] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[0]);
+
+ /* Get the hash table entry. */
+ h = sym_hashes[r_index];
+ if (h == NULL)
+ {
+ /* This should not normally happen, but it will in any case
+ be caught in the relocation phase. */
+ continue;
+ }
+
+ /* At this point common symbols have already been allocated, so
+ we don't have to worry about them. We need to consider that
+ we may have already seen this symbol and marked it undefined;
+ if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
+ will be zero. */
+ if (h->root.root.type != bfd_link_hash_defined
+ && h->root.root.type != bfd_link_hash_defweak
+ && h->root.root.type != bfd_link_hash_undefined)
+ continue;
+
+ if ((h->flags & SUNOS_DEF_DYNAMIC) == 0
+ || (h->flags & SUNOS_DEF_REGULAR) != 0)
+ continue;
+
+ if (dynobj == NULL)
+ {
+ asection *sgot;
+
+ if (! sunos_create_dynamic_sections (abfd, info, false))
+ return false;
+ dynobj = sunos_hash_table (info)->dynobj;
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ srel = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (splt != NULL && srel != NULL);
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (sgot != NULL);
+ if (sgot->_raw_size == 0)
+ sgot->_raw_size = BYTES_IN_WORD;
+ sunos_hash_table (info)->got_needed = true;
+ }
+
+ BFD_ASSERT ((h->flags & SUNOS_REF_REGULAR) != 0);
+ BFD_ASSERT (h->plt_offset != 0
+ || ((h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ ? (h->root.root.u.def.section->owner->flags
+ & DYNAMIC) != 0
+ : (h->root.root.u.undef.abfd->flags & DYNAMIC) != 0));
+
+ /* This reloc is against a symbol defined only by a dynamic
+ object. */
+
+ if (h->root.root.type == bfd_link_hash_undefined)
+ {
+ /* Presumably this symbol was marked as being undefined by
+ an earlier reloc. */
+ srel->_raw_size += RELOC_STD_SIZE;
+ }
+ else if ((h->root.root.u.def.section->flags & SEC_CODE) == 0)
+ {
+ bfd *sub;
+
+ /* This reloc is not in the .text section. It must be
+ copied into the dynamic relocs. We mark the symbol as
+ being undefined. */
+ srel->_raw_size += RELOC_STD_SIZE;
+ sub = h->root.root.u.def.section->owner;
+ h->root.root.type = bfd_link_hash_undefined;
+ h->root.root.u.undef.abfd = sub;
+ }
+ else
+ {
+ /* This symbol is in the .text section. We must give it an
+ entry in the procedure linkage table, if we have not
+ already done so. We change the definition of the symbol
+ to the .plt section; this will cause relocs against it to
+ be handled correctly. */
+ if (h->plt_offset == 0)
+ {
+ if (splt->_raw_size == 0)
+ splt->_raw_size = M68K_PLT_ENTRY_SIZE;
+ h->plt_offset = splt->_raw_size;
+
+ if ((h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ h->root.root.u.def.section = splt;
+ h->root.root.u.def.value = splt->_raw_size;
+ }
+
+ splt->_raw_size += M68K_PLT_ENTRY_SIZE;
+
+ /* We may also need a dynamic reloc entry. */
+ if ((h->flags & SUNOS_DEF_REGULAR) == 0)
+ srel->_raw_size += RELOC_STD_SIZE;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Scan the relocs for an input section using extended relocs. We
+ need to figure out what to do for each reloc against a dynamic
+ symbol. If the reloc is a WDISP30, and the symbol is in the .text
+ section, an entry is made in the procedure linkage table.
+ Otherwise, we must preserve the reloc as a dynamic reloc. */
+
+static boolean
+sunos_scan_ext_relocs (info, abfd, sec, relocs, rel_size)
+ struct bfd_link_info *info;
+ bfd *abfd;
+ asection *sec;
+ const struct reloc_ext_external *relocs;
+ bfd_size_type rel_size;
+{
+ bfd *dynobj;
+ struct sunos_link_hash_entry **sym_hashes;
+ const struct reloc_ext_external *rel, *relend;
+ asection *splt = NULL;
+ asection *sgot = NULL;
+ asection *srel = NULL;
+
+ /* We only know how to handle SPARC plt entries. */
+ if (bfd_get_arch (abfd) != bfd_arch_sparc)
+ {
+ bfd_set_error (bfd_error_invalid_target);
+ return false;
+ }
+
+ dynobj = NULL;
+
+ sym_hashes = (struct sunos_link_hash_entry **) obj_aout_sym_hashes (abfd);
+
+ relend = relocs + rel_size / RELOC_EXT_SIZE;
+ for (rel = relocs; rel < relend; rel++)
+ {
+ unsigned int r_index;
+ int r_extern;
+ int r_type;
+ struct sunos_link_hash_entry *h = NULL;
+
+ /* Swap in the reloc information. */
+ if (bfd_header_big_endian (abfd))
+ {
+ r_index = ((rel->r_index[0] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[2]);
+ r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
+ r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
+ >> RELOC_EXT_BITS_TYPE_SH_BIG);
+ }
+ else
+ {
+ r_index = ((rel->r_index[2] << 16)
+ | (rel->r_index[1] << 8)
+ | rel->r_index[0]);
+ r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
+ r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
+ >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
+ }
+
+ if (r_extern)
+ {
+ h = sym_hashes[r_index];
+ if (h == NULL)
+ {
+ /* This should not normally happen, but it will in any
+ case be caught in the relocation phase. */
+ continue;
+ }
+ }
+
+ /* If this is a base relative reloc, we need to make an entry in
+ the .got section. */
+ if (r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22)
+ {
+ if (dynobj == NULL)
+ {
+ if (! sunos_create_dynamic_sections (abfd, info, false))
+ return false;
+ dynobj = sunos_hash_table (info)->dynobj;
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srel = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
+
+ /* Make sure we have an initial entry in the .got table. */
+ if (sgot->_raw_size == 0)
+ sgot->_raw_size = BYTES_IN_WORD;
+ sunos_hash_table (info)->got_needed = true;
+ }
+
+ if (r_extern)
+ {
+ if (h->got_offset != 0)
+ continue;
+
+ h->got_offset = sgot->_raw_size;
+ }
+ else
+ {
+ if (r_index >= bfd_get_symcount (abfd))
+ {
+ /* This is abnormal, but should be caught in the
+ relocation phase. */
+ continue;
+ }
+
+ if (adata (abfd).local_got_offsets == NULL)
+ {
+ adata (abfd).local_got_offsets =
+ (bfd_vma *) bfd_zalloc (abfd,
+ (bfd_get_symcount (abfd)
+ * sizeof (bfd_vma)));
+ if (adata (abfd).local_got_offsets == NULL)
+ return false;
+ }
+
+ if (adata (abfd).local_got_offsets[r_index] != 0)
+ continue;
+
+ adata (abfd).local_got_offsets[r_index] = sgot->_raw_size;
+ }
+
+ sgot->_raw_size += BYTES_IN_WORD;
+
+ /* If we are making a shared library, or if the symbol is
+ defined by a dynamic object, we will need a dynamic reloc
+ entry. */
+ if (info->shared
+ || (h != NULL
+ && (h->flags & SUNOS_DEF_DYNAMIC) != 0
+ && (h->flags & SUNOS_DEF_REGULAR) == 0))
+ srel->_raw_size += RELOC_EXT_SIZE;
+
+ continue;
+ }
+
+ /* Otherwise, we are only interested in relocs against symbols
+ defined in dynamic objects but not in regular objects. We
+ only need to consider relocs against external symbols. */
+ if (! r_extern)
+ {
+ /* But, if we are creating a shared library, we need to
+ generate an absolute reloc. */
+ if (info->shared)
+ {
+ if (dynobj == NULL)
+ {
+ if (! sunos_create_dynamic_sections (abfd, info, true))
+ return false;
+ dynobj = sunos_hash_table (info)->dynobj;
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srel = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
+ }
+
+ srel->_raw_size += RELOC_EXT_SIZE;
+ }
+
+ continue;
+ }
+
+ /* At this point common symbols have already been allocated, so
+ we don't have to worry about them. We need to consider that
+ we may have already seen this symbol and marked it undefined;
+ if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
+ will be zero. */
+ if (h->root.root.type != bfd_link_hash_defined
+ && h->root.root.type != bfd_link_hash_defweak
+ && h->root.root.type != bfd_link_hash_undefined)
+ continue;
+
+ if (r_type != RELOC_JMP_TBL
+ && ! info->shared
+ && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
+ || (h->flags & SUNOS_DEF_REGULAR) != 0))
+ continue;
+
+ if (r_type == RELOC_JMP_TBL
+ && ! info->shared
+ && (h->flags & SUNOS_DEF_DYNAMIC) == 0
+ && (h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ /* This symbol is apparently undefined. Don't do anything
+ here; just let the relocation routine report an undefined
+ symbol. */
+ continue;
+ }
+
+ if (strcmp (h->root.root.root.string, "__GLOBAL_OFFSET_TABLE_") == 0)
+ continue;
+
+ if (dynobj == NULL)
+ {
+ if (! sunos_create_dynamic_sections (abfd, info, false))
+ return false;
+ dynobj = sunos_hash_table (info)->dynobj;
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+ srel = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
+
+ /* Make sure we have an initial entry in the .got table. */
+ if (sgot->_raw_size == 0)
+ sgot->_raw_size = BYTES_IN_WORD;
+ sunos_hash_table (info)->got_needed = true;
+ }
+
+ BFD_ASSERT (r_type == RELOC_JMP_TBL
+ || info->shared
+ || (h->flags & SUNOS_REF_REGULAR) != 0);
+ BFD_ASSERT (r_type == RELOC_JMP_TBL
+ || info->shared
+ || h->plt_offset != 0
+ || ((h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ ? (h->root.root.u.def.section->owner->flags
+ & DYNAMIC) != 0
+ : (h->root.root.u.undef.abfd->flags & DYNAMIC) != 0));
+
+ /* This reloc is against a symbol defined only by a dynamic
+ object, or it is a jump table reloc from PIC compiled code. */
+
+ if (r_type != RELOC_JMP_TBL
+ && h->root.root.type == bfd_link_hash_undefined)
+ {
+ /* Presumably this symbol was marked as being undefined by
+ an earlier reloc. */
+ srel->_raw_size += RELOC_EXT_SIZE;
+ }
+ else if (r_type != RELOC_JMP_TBL
+ && (h->root.root.u.def.section->flags & SEC_CODE) == 0)
+ {
+ bfd *sub;
+
+ /* This reloc is not in the .text section. It must be
+ copied into the dynamic relocs. We mark the symbol as
+ being undefined. */
+ srel->_raw_size += RELOC_EXT_SIZE;
+ if ((h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ sub = h->root.root.u.def.section->owner;
+ h->root.root.type = bfd_link_hash_undefined;
+ h->root.root.u.undef.abfd = sub;
+ }
+ }
+ else
+ {
+ /* This symbol is in the .text section. We must give it an
+ entry in the procedure linkage table, if we have not
+ already done so. We change the definition of the symbol
+ to the .plt section; this will cause relocs against it to
+ be handled correctly. */
+ if (h->plt_offset == 0)
+ {
+ if (splt->_raw_size == 0)
+ splt->_raw_size = SPARC_PLT_ENTRY_SIZE;
+ h->plt_offset = splt->_raw_size;
+
+ if ((h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ if (h->root.root.type == bfd_link_hash_undefined)
+ h->root.root.type = bfd_link_hash_defined;
+ h->root.root.u.def.section = splt;
+ h->root.root.u.def.value = splt->_raw_size;
+ }
+
+ splt->_raw_size += SPARC_PLT_ENTRY_SIZE;
+
+ /* We will also need a dynamic reloc entry, unless this
+ is a JMP_TBL reloc produced by linking PIC compiled
+ code, and we are not making a shared library. */
+ if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
+ srel->_raw_size += RELOC_EXT_SIZE;
+ }
+
+ /* If we are creating a shared library, we need to copy over
+ any reloc other than a jump table reloc. */
+ if (info->shared && r_type != RELOC_JMP_TBL)
+ srel->_raw_size += RELOC_EXT_SIZE;
+ }
+ }
+
+ return true;
+}
+
+/* Build the hash table of dynamic symbols, and to mark as written all
+ symbols from dynamic objects which we do not plan to write out. */
+
+static boolean
+sunos_scan_dynamic_symbol (h, data)
+ struct sunos_link_hash_entry *h;
+ PTR data;
+{
+ struct bfd_link_info *info = (struct bfd_link_info *) data;
+
+ /* Set the written flag for symbols we do not want to write out as
+ part of the regular symbol table. This is all symbols which are
+ not defined in a regular object file. For some reason symbols
+ which are referenced by a regular object and defined by a dynamic
+ object do not seem to show up in the regular symbol table. It is
+ possible for a symbol to have only SUNOS_REF_REGULAR set here, it
+ is an undefined symbol which was turned into a common symbol
+ because it was found in an archive object which was not included
+ in the link. */
+ if ((h->flags & SUNOS_DEF_REGULAR) == 0
+ && (h->flags & SUNOS_DEF_DYNAMIC) != 0
+ && strcmp (h->root.root.root.string, "__DYNAMIC") != 0)
+ h->root.written = true;
+
+ /* If this symbol is defined by a dynamic object and referenced by a
+ regular object, see whether we gave it a reasonable value while
+ scanning the relocs. */
+
+ if ((h->flags & SUNOS_DEF_REGULAR) == 0
+ && (h->flags & SUNOS_DEF_DYNAMIC) != 0
+ && (h->flags & SUNOS_REF_REGULAR) != 0)
+ {
+ if ((h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ && ((h->root.root.u.def.section->owner->flags & DYNAMIC) != 0)
+ && h->root.root.u.def.section->output_section == NULL)
+ {
+ bfd *sub;
+
+ /* This symbol is currently defined in a dynamic section
+ which is not being put into the output file. This
+ implies that there is no reloc against the symbol. I'm
+ not sure why this case would ever occur. In any case, we
+ change the symbol to be undefined. */
+ sub = h->root.root.u.def.section->owner;
+ h->root.root.type = bfd_link_hash_undefined;
+ h->root.root.u.undef.abfd = sub;
+ }
+ }
+
+ /* If this symbol is defined or referenced by a regular file, add it
+ to the dynamic symbols. */
+ if ((h->flags & (SUNOS_DEF_REGULAR | SUNOS_REF_REGULAR)) != 0)
+ {
+ asection *s;
+ size_t len;
+ bfd_byte *contents;
+ unsigned char *name;
+ unsigned long hash;
+ bfd *dynobj;
+
+ BFD_ASSERT (h->dynindx == -2);
+
+ dynobj = sunos_hash_table (info)->dynobj;
+
+ h->dynindx = sunos_hash_table (info)->dynsymcount;
+ ++sunos_hash_table (info)->dynsymcount;
+
+ len = strlen (h->root.root.root.string);
+
+ /* We don't bother to construct a BFD hash table for the strings
+ which are the names of the dynamic symbols. Using a hash
+ table for the regular symbols is beneficial, because the
+ regular symbols includes the debugging symbols, which have
+ long names and are often duplicated in several object files.
+ There are no debugging symbols in the dynamic symbols. */
+ s = bfd_get_section_by_name (dynobj, ".dynstr");
+ BFD_ASSERT (s != NULL);
+ contents = (bfd_byte *) bfd_realloc (s->contents,
+ s->_raw_size + len + 1);
+ if (contents == NULL)
+ return false;
+ s->contents = contents;
+
+ h->dynstr_index = s->_raw_size;
+ strcpy ((char *) contents + s->_raw_size, h->root.root.root.string);
+ s->_raw_size += len + 1;
+
+ /* Add it to the dynamic hash table. */
+ name = (unsigned char *) h->root.root.root.string;
+ hash = 0;
+ while (*name != '\0')
+ hash = (hash << 1) + *name++;
+ hash &= 0x7fffffff;
+ hash %= sunos_hash_table (info)->bucketcount;
+
+ s = bfd_get_section_by_name (dynobj, ".hash");
+ BFD_ASSERT (s != NULL);
+
+ if (GET_SWORD (dynobj, s->contents + hash * HASH_ENTRY_SIZE) == -1)
+ PUT_WORD (dynobj, h->dynindx, s->contents + hash * HASH_ENTRY_SIZE);
+ else
+ {
+ bfd_vma next;
+
+ next = GET_WORD (dynobj,
+ (s->contents
+ + hash * HASH_ENTRY_SIZE
+ + BYTES_IN_WORD));
+ PUT_WORD (dynobj, s->_raw_size / HASH_ENTRY_SIZE,
+ s->contents + hash * HASH_ENTRY_SIZE + BYTES_IN_WORD);
+ PUT_WORD (dynobj, h->dynindx, s->contents + s->_raw_size);
+ PUT_WORD (dynobj, next, s->contents + s->_raw_size + BYTES_IN_WORD);
+ s->_raw_size += HASH_ENTRY_SIZE;
+ }
+ }
+
+ return true;
+}
+
+/* Link a dynamic object. We actually don't have anything to do at
+ this point. This entry point exists to prevent the regular linker
+ code from doing anything with the object. */
+
+/*ARGSUSED*/
+static boolean
+sunos_link_dynamic_object (info, abfd)
+ struct bfd_link_info *info;
+ bfd *abfd;
+{
+ return true;
+}
+
+/* Write out a dynamic symbol. This is called by the final traversal
+ over the symbol table. */
+
+static boolean
+sunos_write_dynamic_symbol (output_bfd, info, harg)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct aout_link_hash_entry *harg;
+{
+ struct sunos_link_hash_entry *h = (struct sunos_link_hash_entry *) harg;
+ int type;
+ bfd_vma val;
+ asection *s;
+ struct external_nlist *outsym;
+
+ /* If this symbol is in the procedure linkage table, fill in the
+ table entry. */
+ if (h->plt_offset != 0)
+ {
+ bfd *dynobj;
+ asection *splt;
+ bfd_byte *p;
+ asection *s;
+ bfd_vma r_address;
+
+ dynobj = sunos_hash_table (info)->dynobj;
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ p = splt->contents + h->plt_offset;
+
+ s = bfd_get_section_by_name (dynobj, ".dynrel");
+
+ r_address = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt_offset);
+
+ switch (bfd_get_arch (output_bfd))
+ {
+ case bfd_arch_sparc:
+ if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD0, p);
+ bfd_put_32 (output_bfd,
+ (SPARC_PLT_ENTRY_WORD1
+ + (((- (h->plt_offset + 4) >> 2)
+ & 0x3fffffff))),
+ p + 4);
+ bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD2 + s->reloc_count,
+ p + 8);
+ }
+ else
+ {
+ bfd_vma val;
+
+ val = (h->root.root.u.def.section->output_section->vma
+ + h->root.root.u.def.section->output_offset
+ + h->root.root.u.def.value);
+ bfd_put_32 (output_bfd,
+ SPARC_PLT_PIC_WORD0 + ((val >> 10) & 0x3fffff),
+ p);
+ bfd_put_32 (output_bfd,
+ SPARC_PLT_PIC_WORD1 + (val & 0x3ff),
+ p + 4);
+ bfd_put_32 (output_bfd, SPARC_PLT_PIC_WORD2, p + 8);
+ }
+ break;
+
+ case bfd_arch_m68k:
+ if (! info->shared && (h->flags & SUNOS_DEF_REGULAR) != 0)
+ abort ();
+ bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
+ bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
+ bfd_put_16 (output_bfd, s->reloc_count, p + 6);
+ r_address += 2;
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* We also need to add a jump table reloc, unless this is the
+ result of a JMP_TBL reloc from PIC compiled code. */
+ if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ BFD_ASSERT (h->dynindx >= 0);
+ BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
+ < s->_raw_size);
+ p = s->contents + s->reloc_count * obj_reloc_entry_size (output_bfd);
+ if (obj_reloc_entry_size (output_bfd) == RELOC_STD_SIZE)
+ {
+ struct reloc_std_external *srel;
+
+ srel = (struct reloc_std_external *) p;
+ PUT_WORD (output_bfd, r_address, srel->r_address);
+ if (bfd_header_big_endian (output_bfd))
+ {
+ srel->r_index[0] = (bfd_byte)(h->dynindx >> 16);
+ srel->r_index[1] = (bfd_byte)(h->dynindx >> 8);
+ srel->r_index[2] = (bfd_byte)(h->dynindx);
+ srel->r_type[0] = (RELOC_STD_BITS_EXTERN_BIG
+ | RELOC_STD_BITS_JMPTABLE_BIG);
+ }
+ else
+ {
+ srel->r_index[2] = (bfd_byte)(h->dynindx >> 16);
+ srel->r_index[1] = (bfd_byte)(h->dynindx >> 8);
+ srel->r_index[0] = (bfd_byte)h->dynindx;
+ srel->r_type[0] = (RELOC_STD_BITS_EXTERN_LITTLE
+ | RELOC_STD_BITS_JMPTABLE_LITTLE);
+ }
+ }
+ else
+ {
+ struct reloc_ext_external *erel;
+
+ erel = (struct reloc_ext_external *) p;
+ PUT_WORD (output_bfd, r_address, erel->r_address);
+ if (bfd_header_big_endian (output_bfd))
+ {
+ erel->r_index[0] = (bfd_byte)(h->dynindx >> 16);
+ erel->r_index[1] = (bfd_byte)(h->dynindx >> 8);
+ erel->r_index[2] = (bfd_byte)h->dynindx;
+ erel->r_type[0] =
+ (RELOC_EXT_BITS_EXTERN_BIG
+ | (RELOC_JMP_SLOT << RELOC_EXT_BITS_TYPE_SH_BIG));
+ }
+ else
+ {
+ erel->r_index[2] = (bfd_byte)(h->dynindx >> 16);
+ erel->r_index[1] = (bfd_byte)(h->dynindx >> 8);
+ erel->r_index[0] = (bfd_byte)h->dynindx;
+ erel->r_type[0] =
+ (RELOC_EXT_BITS_EXTERN_LITTLE
+ | (RELOC_JMP_SLOT << RELOC_EXT_BITS_TYPE_SH_LITTLE));
+ }
+ PUT_WORD (output_bfd, (bfd_vma) 0, erel->r_addend);
+ }
+
+ ++s->reloc_count;
+ }
+ }
+
+ /* If this is not a dynamic symbol, we don't have to do anything
+ else. We only check this after handling the PLT entry, because
+ we can have a PLT entry for a nondynamic symbol when linking PIC
+ compiled code from a regular object. */
+ if (h->dynindx < 0)
+ return true;
+
+ switch (h->root.root.type)
+ {
+ default:
+ case bfd_link_hash_new:
+ abort ();
+ /* Avoid variable not initialized warnings. */
+ return true;
+ case bfd_link_hash_undefined:
+ type = N_UNDF | N_EXT;
+ val = 0;
+ break;
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ {
+ asection *sec;
+ asection *output_section;
+
+ sec = h->root.root.u.def.section;
+ output_section = sec->output_section;
+ BFD_ASSERT (bfd_is_abs_section (output_section)
+ || output_section->owner == output_bfd);
+ if (h->plt_offset != 0
+ && (h->flags & SUNOS_DEF_REGULAR) == 0)
+ {
+ type = N_UNDF | N_EXT;
+ val = 0;
+ }
+ else
+ {
+ if (output_section == obj_textsec (output_bfd))
+ type = (h->root.root.type == bfd_link_hash_defined
+ ? N_TEXT
+ : N_WEAKT);
+ else if (output_section == obj_datasec (output_bfd))
+ type = (h->root.root.type == bfd_link_hash_defined
+ ? N_DATA
+ : N_WEAKD);
+ else if (output_section == obj_bsssec (output_bfd))
+ type = (h->root.root.type == bfd_link_hash_defined
+ ? N_BSS
+ : N_WEAKB);
+ else
+ type = (h->root.root.type == bfd_link_hash_defined
+ ? N_ABS
+ : N_WEAKA);
+ type |= N_EXT;
+ val = (h->root.root.u.def.value
+ + output_section->vma
+ + sec->output_offset);
+ }
+ }
+ break;
+ case bfd_link_hash_common:
+ type = N_UNDF | N_EXT;
+ val = h->root.root.u.c.size;
+ break;
+ case bfd_link_hash_undefweak:
+ type = N_WEAKU;
+ val = 0;
+ break;
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+ /* FIXME: Ignore these for now. The circumstances under which
+ they should be written out are not clear to me. */
+ return true;
+ }
+
+ s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym");
+ BFD_ASSERT (s != NULL);
+ outsym = ((struct external_nlist *)
+ (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
+
+ bfd_h_put_8 (output_bfd, type, outsym->e_type);
+ bfd_h_put_8 (output_bfd, 0, outsym->e_other);
+
+ /* FIXME: The native linker doesn't use 0 for desc. It seems to use
+ one less than the desc value in the shared library, although that
+ seems unlikely. */
+ bfd_h_put_16 (output_bfd, 0, outsym->e_desc);
+
+ PUT_WORD (output_bfd, h->dynstr_index, outsym->e_strx);
+ PUT_WORD (output_bfd, val, outsym->e_value);
+
+ return true;
+}
+
+/* This is called for each reloc against an external symbol. If this
+ is a reloc which are are going to copy as a dynamic reloc, then
+ copy it over, and tell the caller to not bother processing this
+ reloc. */
+
+/*ARGSUSED*/
+static boolean
+sunos_check_dynamic_reloc (info, input_bfd, input_section, harg, reloc,
+ contents, skip, relocationp)
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ struct aout_link_hash_entry *harg;
+ PTR reloc;
+ bfd_byte *contents;
+ boolean *skip;
+ bfd_vma *relocationp;
+{
+ struct sunos_link_hash_entry *h = (struct sunos_link_hash_entry *) harg;
+ bfd *dynobj;
+ boolean baserel;
+ boolean jmptbl;
+ boolean pcrel;
+ asection *s;
+ bfd_byte *p;
+ long indx;
+
+ *skip = false;
+
+ dynobj = sunos_hash_table (info)->dynobj;
+
+ if (h != NULL
+ && h->plt_offset != 0
+ && (info->shared
+ || (h->flags & SUNOS_DEF_REGULAR) == 0))
+ {
+ asection *splt;
+
+ /* Redirect the relocation to the PLT entry. */
+ splt = bfd_get_section_by_name (dynobj, ".plt");
+ *relocationp = (splt->output_section->vma
+ + splt->output_offset
+ + h->plt_offset);
+ }
+
+ if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
+ {
+ struct reloc_std_external *srel;
+
+ srel = (struct reloc_std_external *) reloc;
+ if (bfd_header_big_endian (input_bfd))
+ {
+ baserel = (0 != (srel->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
+ jmptbl = (0 != (srel->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
+ pcrel = (0 != (srel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
+ }
+ else
+ {
+ baserel = (0 != (srel->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE));
+ jmptbl = (0 != (srel->r_type[0] & RELOC_STD_BITS_JMPTABLE_LITTLE));
+ pcrel = (0 != (srel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
+ }
+ }
+ else
+ {
+ struct reloc_ext_external *erel;
+ int r_type;
+
+ erel = (struct reloc_ext_external *) reloc;
+ if (bfd_header_big_endian (input_bfd))
+ r_type = ((erel->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
+ >> RELOC_EXT_BITS_TYPE_SH_BIG);
+ else
+ r_type = ((erel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
+ >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
+ baserel = (r_type == RELOC_BASE10
+ || r_type == RELOC_BASE13
+ || r_type == RELOC_BASE22);
+ jmptbl = r_type == RELOC_JMP_TBL;
+ pcrel = (r_type == RELOC_DISP8
+ || r_type == RELOC_DISP16
+ || r_type == RELOC_DISP32
+ || r_type == RELOC_WDISP30
+ || r_type == RELOC_WDISP22);
+ /* We don't consider the PC10 and PC22 types to be PC relative,
+ because they are pcrel_offset. */
+ }
+
+ if (baserel)
+ {
+ bfd_vma *got_offsetp;
+ asection *sgot;
+
+ if (h != NULL)
+ got_offsetp = &h->got_offset;
+ else if (adata (input_bfd).local_got_offsets == NULL)
+ got_offsetp = NULL;
+ else
+ {
+ struct reloc_std_external *srel;
+ int r_index;
+
+ srel = (struct reloc_std_external *) reloc;
+ if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
+ {
+ if (bfd_header_big_endian (input_bfd))
+ r_index = ((srel->r_index[0] << 16)
+ | (srel->r_index[1] << 8)
+ | srel->r_index[2]);
+ else
+ r_index = ((srel->r_index[2] << 16)
+ | (srel->r_index[1] << 8)
+ | srel->r_index[0]);
+ }
+ else
+ {
+ struct reloc_ext_external *erel;
+
+ erel = (struct reloc_ext_external *) reloc;
+ if (bfd_header_big_endian (input_bfd))
+ r_index = ((erel->r_index[0] << 16)
+ | (erel->r_index[1] << 8)
+ | erel->r_index[2]);
+ else
+ r_index = ((erel->r_index[2] << 16)
+ | (erel->r_index[1] << 8)
+ | erel->r_index[0]);
+ }
+
+ got_offsetp = adata (input_bfd).local_got_offsets + r_index;
+ }
+
+ BFD_ASSERT (got_offsetp != NULL && *got_offsetp != 0);
+
+ sgot = bfd_get_section_by_name (dynobj, ".got");
+
+ /* We set the least significant bit to indicate whether we have
+ already initialized the GOT entry. */
+ if ((*got_offsetp & 1) == 0)
+ {
+ if (h == NULL
+ || (! info->shared
+ && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
+ || (h->flags & SUNOS_DEF_REGULAR) != 0)))
+ PUT_WORD (dynobj, *relocationp, sgot->contents + *got_offsetp);
+ else
+ PUT_WORD (dynobj, 0, sgot->contents + *got_offsetp);
+
+ if (info->shared
+ || (h != NULL
+ && (h->flags & SUNOS_DEF_DYNAMIC) != 0
+ && (h->flags & SUNOS_DEF_REGULAR) == 0))
+ {
+ /* We need to create a GLOB_DAT or 32 reloc to tell the
+ dynamic linker to fill in this entry in the table. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
+ < s->_raw_size);
+
+ p = (s->contents
+ + s->reloc_count * obj_reloc_entry_size (dynobj));
+
+ if (h != NULL)
+ indx = h->dynindx;
+ else
+ indx = 0;
+
+ if (obj_reloc_entry_size (dynobj) == RELOC_STD_SIZE)
+ {
+ struct reloc_std_external *srel;
+
+ srel = (struct reloc_std_external *) p;
+ PUT_WORD (dynobj,
+ (*got_offsetp
+ + sgot->output_section->vma
+ + sgot->output_offset),
+ srel->r_address);
+ if (bfd_header_big_endian (dynobj))
+ {
+ srel->r_index[0] = (bfd_byte)(indx >> 16);
+ srel->r_index[1] = (bfd_byte)(indx >> 8);
+ srel->r_index[2] = (bfd_byte)indx;
+ if (h == NULL)
+ srel->r_type[0] = 2 << RELOC_STD_BITS_LENGTH_SH_BIG;
+ else
+ srel->r_type[0] =
+ (RELOC_STD_BITS_EXTERN_BIG
+ | RELOC_STD_BITS_BASEREL_BIG
+ | RELOC_STD_BITS_RELATIVE_BIG
+ | (2 << RELOC_STD_BITS_LENGTH_SH_BIG));
+ }
+ else
+ {
+ srel->r_index[2] = (bfd_byte)(indx >> 16);
+ srel->r_index[1] = (bfd_byte)(indx >> 8);
+ srel->r_index[0] = (bfd_byte)indx;
+ if (h == NULL)
+ srel->r_type[0] = 2 << RELOC_STD_BITS_LENGTH_SH_LITTLE;
+ else
+ srel->r_type[0] =
+ (RELOC_STD_BITS_EXTERN_LITTLE
+ | RELOC_STD_BITS_BASEREL_LITTLE
+ | RELOC_STD_BITS_RELATIVE_LITTLE
+ | (2 << RELOC_STD_BITS_LENGTH_SH_LITTLE));
+ }
+ }
+ else
+ {
+ struct reloc_ext_external *erel;
+
+ erel = (struct reloc_ext_external *) p;
+ PUT_WORD (dynobj,
+ (*got_offsetp
+ + sgot->output_section->vma
+ + sgot->output_offset),
+ erel->r_address);
+ if (bfd_header_big_endian (dynobj))
+ {
+ erel->r_index[0] = (bfd_byte)(indx >> 16);
+ erel->r_index[1] = (bfd_byte)(indx >> 8);
+ erel->r_index[2] = (bfd_byte)indx;
+ if (h == NULL)
+ erel->r_type[0] =
+ RELOC_32 << RELOC_EXT_BITS_TYPE_SH_BIG;
+ else
+ erel->r_type[0] =
+ (RELOC_EXT_BITS_EXTERN_BIG
+ | (RELOC_GLOB_DAT << RELOC_EXT_BITS_TYPE_SH_BIG));
+ }
+ else
+ {
+ erel->r_index[2] = (bfd_byte)(indx >> 16);
+ erel->r_index[1] = (bfd_byte)(indx >> 8);
+ erel->r_index[0] = (bfd_byte)indx;
+ if (h == NULL)
+ erel->r_type[0] =
+ RELOC_32 << RELOC_EXT_BITS_TYPE_SH_LITTLE;
+ else
+ erel->r_type[0] =
+ (RELOC_EXT_BITS_EXTERN_LITTLE
+ | (RELOC_GLOB_DAT
+ << RELOC_EXT_BITS_TYPE_SH_LITTLE));
+ }
+ PUT_WORD (dynobj, 0, erel->r_addend);
+ }
+
+ ++s->reloc_count;
+ }
+
+ *got_offsetp |= 1;
+ }
+
+ *relocationp = (sgot->vma
+ + (*got_offsetp &~ 1)
+ - sunos_hash_table (info)->got_base);
+
+ /* There is nothing else to do for a base relative reloc. */
+ return true;
+ }
+
+ if (! sunos_hash_table (info)->dynamic_sections_needed)
+ return true;
+ if (! info->shared)
+ {
+ if (h == NULL
+ || h->dynindx == -1
+ || h->root.root.type != bfd_link_hash_undefined
+ || (h->flags & SUNOS_DEF_REGULAR) != 0
+ || (h->flags & SUNOS_DEF_DYNAMIC) == 0
+ || (h->root.root.u.undef.abfd->flags & DYNAMIC) == 0)
+ return true;
+ }
+ else
+ {
+ if (h != NULL
+ && (h->dynindx == -1
+ || jmptbl
+ || strcmp (h->root.root.root.string,
+ "__GLOBAL_OFFSET_TABLE_") == 0))
+ return true;
+ }
+
+ /* It looks like this is a reloc we are supposed to copy. */
+
+ s = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->_raw_size);
+
+ p = s->contents + s->reloc_count * obj_reloc_entry_size (dynobj);
+
+ /* Copy the reloc over. */
+ memcpy (p, reloc, obj_reloc_entry_size (dynobj));
+
+ if (h != NULL)
+ indx = h->dynindx;
+ else
+ indx = 0;
+
+ /* Adjust the address and symbol index. */
+ if (obj_reloc_entry_size (dynobj) == RELOC_STD_SIZE)
+ {
+ struct reloc_std_external *srel;
+
+ srel = (struct reloc_std_external *) p;
+ PUT_WORD (dynobj,
+ (GET_WORD (dynobj, srel->r_address)
+ + input_section->output_section->vma
+ + input_section->output_offset),
+ srel->r_address);
+ if (bfd_header_big_endian (dynobj))
+ {
+ srel->r_index[0] = (bfd_byte)(indx >> 16);
+ srel->r_index[1] = (bfd_byte)(indx >> 8);
+ srel->r_index[2] = (bfd_byte)indx;
+ }
+ else
+ {
+ srel->r_index[2] = (bfd_byte)(indx >> 16);
+ srel->r_index[1] = (bfd_byte)(indx >> 8);
+ srel->r_index[0] = (bfd_byte)indx;
+ }
+ /* FIXME: We may have to change the addend for a PC relative
+ reloc. */
+ }
+ else
+ {
+ struct reloc_ext_external *erel;
+
+ erel = (struct reloc_ext_external *) p;
+ PUT_WORD (dynobj,
+ (GET_WORD (dynobj, erel->r_address)
+ + input_section->output_section->vma
+ + input_section->output_offset),
+ erel->r_address);
+ if (bfd_header_big_endian (dynobj))
+ {
+ erel->r_index[0] = (bfd_byte)(indx >> 16);
+ erel->r_index[1] = (bfd_byte)(indx >> 8);
+ erel->r_index[2] = (bfd_byte)indx;
+ }
+ else
+ {
+ erel->r_index[2] = (bfd_byte)(indx >> 16);
+ erel->r_index[1] = (bfd_byte)(indx >> 8);
+ erel->r_index[0] = (bfd_byte)indx;
+ }
+ if (pcrel && h != NULL)
+ {
+ /* Adjust the addend for the change in address. */
+ PUT_WORD (dynobj,
+ (GET_WORD (dynobj, erel->r_addend)
+ - (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma)),
+ erel->r_addend);
+ }
+ }
+
+ ++s->reloc_count;
+
+ if (h != NULL)
+ *skip = true;
+
+ return true;
+}
+
+/* Finish up the dynamic linking information. */
+
+static boolean
+sunos_finish_dynamic_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd *dynobj;
+ asection *o;
+ asection *s;
+ asection *sdyn;
+
+ if (! sunos_hash_table (info)->dynamic_sections_needed
+ && ! sunos_hash_table (info)->got_needed)
+ return true;
+
+ dynobj = sunos_hash_table (info)->dynobj;
+
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+ BFD_ASSERT (sdyn != NULL);
+
+ /* Finish up the .need section. The linker emulation code filled it
+ in, but with offsets from the start of the section instead of
+ real addresses. Now that we know the section location, we can
+ fill in the final values. */
+ s = bfd_get_section_by_name (dynobj, ".need");
+ if (s != NULL && s->_raw_size != 0)
+ {
+ file_ptr filepos;
+ bfd_byte *p;
+
+ filepos = s->output_section->filepos + s->output_offset;
+ p = s->contents;
+ while (1)
+ {
+ bfd_vma val;
+
+ PUT_WORD (dynobj, GET_WORD (dynobj, p) + filepos, p);
+ val = GET_WORD (dynobj, p + 12);
+ if (val == 0)
+ break;
+ PUT_WORD (dynobj, val + filepos, p + 12);
+ p += 16;
+ }
+ }
+
+ /* The first entry in the .got section is the address of the
+ dynamic information, unless this is a shared library. */
+ s = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (s != NULL);
+ if (info->shared || sdyn->_raw_size == 0)
+ PUT_WORD (dynobj, 0, s->contents);
+ else
+ PUT_WORD (dynobj, sdyn->output_section->vma + sdyn->output_offset,
+ s->contents);
+
+ for (o = dynobj->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_HAS_CONTENTS) != 0
+ && o->contents != NULL)
+ {
+ BFD_ASSERT (o->output_section != NULL
+ && o->output_section->owner == abfd);
+ if (! bfd_set_section_contents (abfd, o->output_section,
+ o->contents, o->output_offset,
+ o->_raw_size))
+ return false;
+ }
+ }
+
+ if (sdyn->_raw_size > 0)
+ {
+ struct external_sun4_dynamic esd;
+ struct external_sun4_dynamic_link esdl;
+
+ /* Finish up the dynamic link information. */
+ PUT_WORD (dynobj, (bfd_vma) 3, esd.ld_version);
+ PUT_WORD (dynobj,
+ sdyn->output_section->vma + sdyn->output_offset + sizeof esd,
+ esd.ldd);
+ PUT_WORD (dynobj,
+ (sdyn->output_section->vma
+ + sdyn->output_offset
+ + sizeof esd
+ + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
+ esd.ld);
+
+ if (! bfd_set_section_contents (abfd, sdyn->output_section, &esd,
+ sdyn->output_offset, sizeof esd))
+ return false;
+
+ PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_loaded);
+
+ s = bfd_get_section_by_name (dynobj, ".need");
+ if (s == NULL || s->_raw_size == 0)
+ PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_need);
+ else
+ PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
+ esdl.ld_need);
+
+ s = bfd_get_section_by_name (dynobj, ".rules");
+ if (s == NULL || s->_raw_size == 0)
+ PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_rules);
+ else
+ PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
+ esdl.ld_rules);
+
+ s = bfd_get_section_by_name (dynobj, ".got");
+ BFD_ASSERT (s != NULL);
+ PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
+ esdl.ld_got);
+
+ s = bfd_get_section_by_name (dynobj, ".plt");
+ BFD_ASSERT (s != NULL);
+ PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
+ esdl.ld_plt);
+ PUT_WORD (dynobj, s->_raw_size, esdl.ld_plt_sz);
+
+ s = bfd_get_section_by_name (dynobj, ".dynrel");
+ BFD_ASSERT (s != NULL);
+ BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
+ == s->_raw_size);
+ PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
+ esdl.ld_rel);
+
+ s = bfd_get_section_by_name (dynobj, ".hash");
+ BFD_ASSERT (s != NULL);
+ PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
+ esdl.ld_hash);
+
+ s = bfd_get_section_by_name (dynobj, ".dynsym");
+ BFD_ASSERT (s != NULL);
+ PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
+ esdl.ld_stab);
+
+ PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_stab_hash);
+
+ PUT_WORD (dynobj, (bfd_vma) sunos_hash_table (info)->bucketcount,
+ esdl.ld_buckets);
+
+ s = bfd_get_section_by_name (dynobj, ".dynstr");
+ BFD_ASSERT (s != NULL);
+ PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
+ esdl.ld_symbols);
+ PUT_WORD (dynobj, s->_raw_size, esdl.ld_symb_size);
+
+ /* The size of the text area is the size of the .text section
+ rounded up to a page boundary. FIXME: Should the page size be
+ conditional on something? */
+ PUT_WORD (dynobj,
+ BFD_ALIGN (obj_textsec (abfd)->_raw_size, 0x2000),
+ esdl.ld_text);
+
+ if (! bfd_set_section_contents (abfd, sdyn->output_section, &esdl,
+ (sdyn->output_offset
+ + sizeof esd
+ + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
+ sizeof esdl))
+ return false;
+
+ abfd->flags |= DYNAMIC;
+ }
+
+ return true;
+}
diff --git a/bfd/syms.c b/bfd/syms.c
new file mode 100644
index 00000000000..f69d1f21fa4
--- /dev/null
+++ b/bfd/syms.c
@@ -0,0 +1,1253 @@
+/* Generic symbol-table support for the BFD library.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SECTION
+ Symbols
+
+ BFD tries to maintain as much symbol information as it can when
+ it moves information from file to file. BFD passes information
+ to applications though the <<asymbol>> structure. When the
+ application requests the symbol table, BFD reads the table in
+ the native form and translates parts of it into the internal
+ format. To maintain more than the information passed to
+ applications, some targets keep some information ``behind the
+ scenes'' in a structure only the particular back end knows
+ about. For example, the coff back end keeps the original
+ symbol table structure as well as the canonical structure when
+ a BFD is read in. On output, the coff back end can reconstruct
+ the output symbol table so that no information is lost, even
+ information unique to coff which BFD doesn't know or
+ understand. If a coff symbol table were read, but were written
+ through an a.out back end, all the coff specific information
+ would be lost. The symbol table of a BFD
+ is not necessarily read in until a canonicalize request is
+ made. Then the BFD back end fills in a table provided by the
+ application with pointers to the canonical information. To
+ output symbols, the application provides BFD with a table of
+ pointers to pointers to <<asymbol>>s. This allows applications
+ like the linker to output a symbol as it was read, since the ``behind
+ the scenes'' information will be still available.
+@menu
+@* Reading Symbols::
+@* Writing Symbols::
+@* Mini Symbols::
+@* typedef asymbol::
+@* symbol handling functions::
+@end menu
+
+INODE
+Reading Symbols, Writing Symbols, Symbols, Symbols
+SUBSECTION
+ Reading symbols
+
+ There are two stages to reading a symbol table from a BFD:
+ allocating storage, and the actual reading process. This is an
+ excerpt from an application which reads the symbol table:
+
+| long storage_needed;
+| asymbol **symbol_table;
+| long number_of_symbols;
+| long i;
+|
+| storage_needed = bfd_get_symtab_upper_bound (abfd);
+|
+| if (storage_needed < 0)
+| FAIL
+|
+| if (storage_needed == 0) {
+| return ;
+| }
+| symbol_table = (asymbol **) xmalloc (storage_needed);
+| ...
+| number_of_symbols =
+| bfd_canonicalize_symtab (abfd, symbol_table);
+|
+| if (number_of_symbols < 0)
+| FAIL
+|
+| for (i = 0; i < number_of_symbols; i++) {
+| process_symbol (symbol_table[i]);
+| }
+
+ All storage for the symbols themselves is in an objalloc
+ connected to the BFD; it is freed when the BFD is closed.
+
+
+INODE
+Writing Symbols, Mini Symbols, Reading Symbols, Symbols
+SUBSECTION
+ Writing symbols
+
+ Writing of a symbol table is automatic when a BFD open for
+ writing is closed. The application attaches a vector of
+ pointers to pointers to symbols to the BFD being written, and
+ fills in the symbol count. The close and cleanup code reads
+ through the table provided and performs all the necessary
+ operations. The BFD output code must always be provided with an
+ ``owned'' symbol: one which has come from another BFD, or one
+ which has been created using <<bfd_make_empty_symbol>>. Here is an
+ example showing the creation of a symbol table with only one element:
+
+| #include "bfd.h"
+| main()
+| {
+| bfd *abfd;
+| asymbol *ptrs[2];
+| asymbol *new;
+|
+| abfd = bfd_openw("foo","a.out-sunos-big");
+| bfd_set_format(abfd, bfd_object);
+| new = bfd_make_empty_symbol(abfd);
+| new->name = "dummy_symbol";
+| new->section = bfd_make_section_old_way(abfd, ".text");
+| new->flags = BSF_GLOBAL;
+| new->value = 0x12345;
+|
+| ptrs[0] = new;
+| ptrs[1] = (asymbol *)0;
+|
+| bfd_set_symtab(abfd, ptrs, 1);
+| bfd_close(abfd);
+| }
+|
+| ./makesym
+| nm foo
+| 00012345 A dummy_symbol
+
+ Many formats cannot represent arbitary symbol information; for
+ instance, the <<a.out>> object format does not allow an
+ arbitary number of sections. A symbol pointing to a section
+ which is not one of <<.text>>, <<.data>> or <<.bss>> cannot
+ be described.
+
+INODE
+Mini Symbols, typedef asymbol, Writing Symbols, Symbols
+SUBSECTION
+ Mini Symbols
+
+ Mini symbols provide read-only access to the symbol table.
+ They use less memory space, but require more time to access.
+ They can be useful for tools like nm or objdump, which may
+ have to handle symbol tables of extremely large executables.
+
+ The <<bfd_read_minisymbols>> function will read the symbols
+ into memory in an internal form. It will return a <<void *>>
+ pointer to a block of memory, a symbol count, and the size of
+ each symbol. The pointer is allocated using <<malloc>>, and
+ should be freed by the caller when it is no longer needed.
+
+ The function <<bfd_minisymbol_to_symbol>> will take a pointer
+ to a minisymbol, and a pointer to a structure returned by
+ <<bfd_make_empty_symbol>>, and return a <<asymbol>> structure.
+ The return value may or may not be the same as the value from
+ <<bfd_make_empty_symbol>> which was passed in.
+
+*/
+
+
+
+/*
+DOCDD
+INODE
+typedef asymbol, symbol handling functions, Mini Symbols, Symbols
+
+*/
+/*
+SUBSECTION
+ typedef asymbol
+
+ An <<asymbol>> has the form:
+
+*/
+
+/*
+CODE_FRAGMENT
+
+.
+.typedef struct symbol_cache_entry
+.{
+. {* A pointer to the BFD which owns the symbol. This information
+. is necessary so that a back end can work out what additional
+. information (invisible to the application writer) is carried
+. with the symbol.
+.
+. This field is *almost* redundant, since you can use section->owner
+. instead, except that some symbols point to the global sections
+. bfd_{abs,com,und}_section. This could be fixed by making
+. these globals be per-bfd (or per-target-flavor). FIXME. *}
+.
+. struct _bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field. *}
+.
+. {* The text of the symbol. The name is left alone, and not copied; the
+. application may not alter it. *}
+. CONST char *name;
+.
+. {* The value of the symbol. This really should be a union of a
+. numeric value with a pointer, since some flags indicate that
+. a pointer to another symbol is stored here. *}
+. symvalue value;
+.
+. {* Attributes of a symbol: *}
+.
+.#define BSF_NO_FLAGS 0x00
+.
+. {* The symbol has local scope; <<static>> in <<C>>. The value
+. is the offset into the section of the data. *}
+.#define BSF_LOCAL 0x01
+.
+. {* The symbol has global scope; initialized data in <<C>>. The
+. value is the offset into the section of the data. *}
+.#define BSF_GLOBAL 0x02
+.
+. {* The symbol has global scope and is exported. The value is
+. the offset into the section of the data. *}
+.#define BSF_EXPORT BSF_GLOBAL {* no real difference *}
+.
+. {* A normal C symbol would be one of:
+. <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
+. <<BSF_GLOBAL>> *}
+.
+. {* The symbol is a debugging record. The value has an arbitary
+. meaning. *}
+.#define BSF_DEBUGGING 0x08
+.
+. {* The symbol denotes a function entry point. Used in ELF,
+. perhaps others someday. *}
+.#define BSF_FUNCTION 0x10
+.
+. {* Used by the linker. *}
+.#define BSF_KEEP 0x20
+.#define BSF_KEEP_G 0x40
+.
+. {* A weak global symbol, overridable without warnings by
+. a regular global symbol of the same name. *}
+.#define BSF_WEAK 0x80
+.
+. {* This symbol was created to point to a section, e.g. ELF's
+. STT_SECTION symbols. *}
+.#define BSF_SECTION_SYM 0x100
+.
+. {* The symbol used to be a common symbol, but now it is
+. allocated. *}
+.#define BSF_OLD_COMMON 0x200
+.
+. {* The default value for common data. *}
+.#define BFD_FORT_COMM_DEFAULT_VALUE 0
+.
+. {* In some files the type of a symbol sometimes alters its
+. location in an output file - ie in coff a <<ISFCN>> symbol
+. which is also <<C_EXT>> symbol appears where it was
+. declared and not at the end of a section. This bit is set
+. by the target BFD part to convey this information. *}
+.
+.#define BSF_NOT_AT_END 0x400
+.
+. {* Signal that the symbol is the label of constructor section. *}
+.#define BSF_CONSTRUCTOR 0x800
+.
+. {* Signal that the symbol is a warning symbol. The name is a
+. warning. The name of the next symbol is the one to warn about;
+. if a reference is made to a symbol with the same name as the next
+. symbol, a warning is issued by the linker. *}
+.#define BSF_WARNING 0x1000
+.
+. {* Signal that the symbol is indirect. This symbol is an indirect
+. pointer to the symbol with the same name as the next symbol. *}
+.#define BSF_INDIRECT 0x2000
+.
+. {* BSF_FILE marks symbols that contain a file name. This is used
+. for ELF STT_FILE symbols. *}
+.#define BSF_FILE 0x4000
+.
+. {* Symbol is from dynamic linking information. *}
+.#define BSF_DYNAMIC 0x8000
+.
+. {* The symbol denotes a data object. Used in ELF, and perhaps
+. others someday. *}
+.#define BSF_OBJECT 0x10000
+.
+. flagword flags;
+.
+. {* A pointer to the section to which this symbol is
+. relative. This will always be non NULL, there are special
+. sections for undefined and absolute symbols. *}
+. struct sec *section;
+.
+. {* Back end special data. *}
+. union
+. {
+. PTR p;
+. bfd_vma i;
+. } udata;
+.
+.} asymbol;
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "aout/stab_gnu.h"
+
+static char coff_section_type PARAMS ((const char *));
+
+/*
+DOCDD
+INODE
+symbol handling functions, , typedef asymbol, Symbols
+SUBSECTION
+ Symbol handling functions
+*/
+
+/*
+FUNCTION
+ bfd_get_symtab_upper_bound
+
+DESCRIPTION
+ Return the number of bytes required to store a vector of pointers
+ to <<asymbols>> for all the symbols in the BFD @var{abfd},
+ including a terminal NULL pointer. If there are no symbols in
+ the BFD, then return 0. If an error occurs, return -1.
+
+.#define bfd_get_symtab_upper_bound(abfd) \
+. BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
+
+*/
+
+/*
+FUNCTION
+ bfd_is_local_label
+
+SYNOPSIS
+ boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
+
+DESCRIPTION
+ Return true if the given symbol @var{sym} in the BFD @var{abfd} is
+ a compiler generated local label, else return false.
+*/
+
+boolean
+bfd_is_local_label (abfd, sym)
+ bfd *abfd;
+ asymbol *sym;
+{
+ if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
+ return false;
+ if (sym->name == NULL)
+ return false;
+ return bfd_is_local_label_name (abfd, sym->name);
+}
+
+/*
+FUNCTION
+ bfd_is_local_label_name
+
+SYNOPSIS
+ boolean bfd_is_local_label_name(bfd *abfd, const char *name);
+
+DESCRIPTION
+ Return true if a symbol with the name @var{name} in the BFD
+ @var{abfd} is a compiler generated local label, else return
+ false. This just checks whether the name has the form of a
+ local label.
+
+.#define bfd_is_local_label_name(abfd, name) \
+. BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
+*/
+
+/*
+FUNCTION
+ bfd_canonicalize_symtab
+
+DESCRIPTION
+ Read the symbols from the BFD @var{abfd}, and fills in
+ the vector @var{location} with pointers to the symbols and
+ a trailing NULL.
+ Return the actual number of symbol pointers, not
+ including the NULL.
+
+
+.#define bfd_canonicalize_symtab(abfd, location) \
+. BFD_SEND (abfd, _bfd_canonicalize_symtab,\
+. (abfd, location))
+
+*/
+
+
+/*
+FUNCTION
+ bfd_set_symtab
+
+SYNOPSIS
+ boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
+
+DESCRIPTION
+ Arrange that when the output BFD @var{abfd} is closed,
+ the table @var{location} of @var{count} pointers to symbols
+ will be written.
+*/
+
+boolean
+bfd_set_symtab (abfd, location, symcount)
+ bfd *abfd;
+ asymbol **location;
+ unsigned int symcount;
+{
+ if ((abfd->format != bfd_object) || (bfd_read_p (abfd)))
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ bfd_get_outsymbols (abfd) = location;
+ bfd_get_symcount (abfd) = symcount;
+ return true;
+}
+
+/*
+FUNCTION
+ bfd_print_symbol_vandf
+
+SYNOPSIS
+ void bfd_print_symbol_vandf(PTR file, asymbol *symbol);
+
+DESCRIPTION
+ Print the value and flags of the @var{symbol} supplied to the
+ stream @var{file}.
+*/
+void
+bfd_print_symbol_vandf (arg, symbol)
+ PTR arg;
+ asymbol *symbol;
+{
+ FILE *file = (FILE *) arg;
+ flagword type = symbol->flags;
+ if (symbol->section != (asection *) NULL)
+ {
+ fprintf_vma (file, symbol->value + symbol->section->vma);
+ }
+ else
+ {
+ fprintf_vma (file, symbol->value);
+ }
+
+ /* This presumes that a symbol can not be both BSF_DEBUGGING and
+ BSF_DYNAMIC, nor more than one of BSF_FUNCTION, BSF_FILE, and
+ BSF_OBJECT. */
+ fprintf (file, " %c%c%c%c%c%c%c",
+ ((type & BSF_LOCAL)
+ ? (type & BSF_GLOBAL) ? '!' : 'l'
+ : (type & BSF_GLOBAL) ? 'g' : ' '),
+ (type & BSF_WEAK) ? 'w' : ' ',
+ (type & BSF_CONSTRUCTOR) ? 'C' : ' ',
+ (type & BSF_WARNING) ? 'W' : ' ',
+ (type & BSF_INDIRECT) ? 'I' : ' ',
+ (type & BSF_DEBUGGING) ? 'd' : (type & BSF_DYNAMIC) ? 'D' : ' ',
+ ((type & BSF_FUNCTION)
+ ? 'F'
+ : ((type & BSF_FILE)
+ ? 'f'
+ : ((type & BSF_OBJECT) ? 'O' : ' '))));
+}
+
+
+/*
+FUNCTION
+ bfd_make_empty_symbol
+
+DESCRIPTION
+ Create a new <<asymbol>> structure for the BFD @var{abfd}
+ and return a pointer to it.
+
+ This routine is necessary because each back end has private
+ information surrounding the <<asymbol>>. Building your own
+ <<asymbol>> and pointing to it will not create the private
+ information, and will cause problems later on.
+
+.#define bfd_make_empty_symbol(abfd) \
+. BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
+*/
+
+/*
+FUNCTION
+ bfd_make_debug_symbol
+
+DESCRIPTION
+ Create a new <<asymbol>> structure for the BFD @var{abfd},
+ to be used as a debugging symbol. Further details of its use have
+ yet to be worked out.
+
+.#define bfd_make_debug_symbol(abfd,ptr,size) \
+. BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
+*/
+
+struct section_to_type
+{
+ CONST char *section;
+ char type;
+};
+
+/* Map section names to POSIX/BSD single-character symbol types.
+ This table is probably incomplete. It is sorted for convenience of
+ adding entries. Since it is so short, a linear search is used. */
+static CONST struct section_to_type stt[] =
+{
+ {"*DEBUG*", 'N'},
+ {".bss", 'b'},
+ {"zerovars", 'b'}, /* MRI .bss */
+ {".data", 'd'},
+ {"vars", 'd'}, /* MRI .data */
+ {".rdata", 'r'}, /* Read only data. */
+ {".rodata", 'r'}, /* Read only data. */
+ {".sbss", 's'}, /* Small BSS (uninitialized data). */
+ {".scommon", 'c'}, /* Small common. */
+ {".sdata", 'g'}, /* Small initialized data. */
+ {".text", 't'},
+ {"code", 't'}, /* MRI .text */
+ {0, 0}
+};
+
+/* Return the single-character symbol type corresponding to
+ section S, or '?' for an unknown COFF section.
+
+ Check for any leading string which matches, so .text5 returns
+ 't' as well as .text */
+
+static char
+coff_section_type (s)
+ const char *s;
+{
+ CONST struct section_to_type *t;
+
+ for (t = &stt[0]; t->section; t++)
+ if (!strncmp (s, t->section, strlen (t->section)))
+ return t->type;
+
+ return '?';
+}
+
+#ifndef islower
+#define islower(c) ((c) >= 'a' && (c) <= 'z')
+#endif
+#ifndef toupper
+#define toupper(c) (islower(c) ? ((c) & ~0x20) : (c))
+#endif
+
+/*
+FUNCTION
+ bfd_decode_symclass
+
+DESCRIPTION
+ Return a character corresponding to the symbol
+ class of @var{symbol}, or '?' for an unknown class.
+
+SYNOPSIS
+ int bfd_decode_symclass(asymbol *symbol);
+*/
+int
+bfd_decode_symclass (symbol)
+ asymbol *symbol;
+{
+ char c;
+
+ if (bfd_is_com_section (symbol->section))
+ return 'C';
+ if (bfd_is_und_section (symbol->section))
+ return 'U';
+ if (bfd_is_ind_section (symbol->section))
+ return 'I';
+ if (symbol->flags & BSF_WEAK)
+ return 'W';
+ if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
+ return '?';
+
+ if (bfd_is_abs_section (symbol->section))
+ c = 'a';
+ else if (symbol->section)
+ c = coff_section_type (symbol->section->name);
+ else
+ return '?';
+ if (symbol->flags & BSF_GLOBAL)
+ c = toupper (c);
+ return c;
+
+ /* We don't have to handle these cases just yet, but we will soon:
+ N_SETV: 'v';
+ N_SETA: 'l';
+ N_SETT: 'x';
+ N_SETD: 'z';
+ N_SETB: 's';
+ N_INDR: 'i';
+ */
+}
+
+/*
+FUNCTION
+ bfd_symbol_info
+
+DESCRIPTION
+ Fill in the basic info about symbol that nm needs.
+ Additional info may be added by the back-ends after
+ calling this function.
+
+SYNOPSIS
+ void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
+*/
+
+void
+bfd_symbol_info (symbol, ret)
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ ret->type = bfd_decode_symclass (symbol);
+ if (ret->type != 'U')
+ ret->value = symbol->value + symbol->section->vma;
+ else
+ ret->value = 0;
+ ret->name = symbol->name;
+}
+
+/*
+FUNCTION
+ bfd_copy_private_symbol_data
+
+SYNOPSIS
+ boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
+
+DESCRIPTION
+ Copy private symbol information from @var{isym} in the BFD
+ @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
+ Return <<true>> on success, <<false>> on error. Possible error
+ returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{osec}.
+
+.#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
+. BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
+. (ibfd, isymbol, obfd, osymbol))
+
+*/
+
+/* The generic version of the function which returns mini symbols.
+ This is used when the backend does not provide a more efficient
+ version. It just uses BFD asymbol structures as mini symbols. */
+
+long
+_bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
+ bfd *abfd;
+ boolean dynamic;
+ PTR *minisymsp;
+ unsigned int *sizep;
+{
+ long storage;
+ asymbol **syms = NULL;
+ long symcount;
+
+ if (dynamic)
+ storage = bfd_get_dynamic_symtab_upper_bound (abfd);
+ else
+ storage = bfd_get_symtab_upper_bound (abfd);
+ if (storage < 0)
+ goto error_return;
+
+ syms = (asymbol **) bfd_malloc ((size_t) storage);
+ if (syms == NULL)
+ goto error_return;
+
+ if (dynamic)
+ symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
+ else
+ symcount = bfd_canonicalize_symtab (abfd, syms);
+ if (symcount < 0)
+ goto error_return;
+
+ *minisymsp = (PTR) syms;
+ *sizep = sizeof (asymbol *);
+ return symcount;
+
+ error_return:
+ if (syms != NULL)
+ free (syms);
+ return -1;
+}
+
+/* The generic version of the function which converts a minisymbol to
+ an asymbol. We don't worry about the sym argument we are passed;
+ we just return the asymbol the minisymbol points to. */
+
+/*ARGSUSED*/
+asymbol *
+_bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
+ bfd *abfd;
+ boolean dynamic;
+ const PTR minisym;
+ asymbol *sym;
+{
+ return *(asymbol **) minisym;
+}
+
+/* Look through stabs debugging information in .stab and .stabstr
+ sections to find the source file and line closest to a desired
+ location. This is used by COFF and ELF targets. It sets *pfound
+ to true if it finds some information. The *pinfo field is used to
+ pass cached information in and out of this routine; this first time
+ the routine is called for a BFD, *pinfo should be NULL. The value
+ placed in *pinfo should be saved with the BFD, and passed back each
+ time this function is called. */
+
+/* We use a cache by default. */
+
+#define ENABLE_CACHING
+
+/* We keep an array of indexentry structures to record where in the
+ stabs section we should look to find line number information for a
+ particular address. */
+
+struct indexentry
+{
+ bfd_vma val;
+ bfd_byte *stab;
+ bfd_byte *str;
+ char *directory_name;
+ char *file_name;
+ char *function_name;
+};
+
+/* Compare two indexentry structures. This is called via qsort. */
+
+static int
+cmpindexentry (a, b)
+ const PTR *a;
+ const PTR *b;
+{
+ const struct indexentry *contestantA = (const struct indexentry *) a;
+ const struct indexentry *contestantB = (const struct indexentry *) b;
+
+ if (contestantA->val < contestantB->val)
+ return -1;
+ else if (contestantA->val > contestantB->val)
+ return 1;
+ else
+ return 0;
+}
+
+/* A pointer to this structure is stored in *pinfo. */
+
+struct stab_find_info
+{
+ /* The .stab section. */
+ asection *stabsec;
+ /* The .stabstr section. */
+ asection *strsec;
+ /* The contents of the .stab section. */
+ bfd_byte *stabs;
+ /* The contents of the .stabstr section. */
+ bfd_byte *strs;
+
+ /* A table that indexes stabs by memory address. */
+ struct indexentry *indextable;
+ /* The number of entries in indextable. */
+ int indextablesize;
+
+#ifdef ENABLE_CACHING
+ /* Cached values to restart quickly. */
+ struct indexentry *cached_indexentry;
+ bfd_vma cached_offset;
+ bfd_byte *cached_stab;
+ char *cached_file_name;
+#endif
+
+ /* Saved ptr to malloc'ed filename. */
+ char *filename;
+};
+
+boolean
+_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
+ pfilename, pfnname, pline, pinfo)
+ bfd *abfd;
+ asymbol **symbols;
+ asection *section;
+ bfd_vma offset;
+ boolean *pfound;
+ const char **pfilename;
+ const char **pfnname;
+ unsigned int *pline;
+ PTR *pinfo;
+{
+ struct stab_find_info *info;
+ bfd_size_type stabsize, strsize;
+ bfd_byte *stab, *str, *last_stab;
+ bfd_size_type stroff;
+ struct indexentry *indexentry;
+ char *directory_name, *file_name;
+ int saw_fun;
+
+ *pfound = false;
+ *pfilename = bfd_get_filename (abfd);
+ *pfnname = NULL;
+ *pline = 0;
+
+ /* Stabs entries use a 12 byte format:
+ 4 byte string table index
+ 1 byte stab type
+ 1 byte stab other field
+ 2 byte stab desc field
+ 4 byte stab value
+ FIXME: This will have to change for a 64 bit object format.
+
+ The stabs symbols are divided into compilation units. For the
+ first entry in each unit, the type of 0, the value is the length
+ of the string table for this unit, and the desc field is the
+ number of stabs symbols for this unit. */
+
+#define STRDXOFF (0)
+#define TYPEOFF (4)
+#define OTHEROFF (5)
+#define DESCOFF (6)
+#define VALOFF (8)
+#define STABSIZE (12)
+
+ info = (struct stab_find_info *) *pinfo;
+ if (info != NULL)
+ {
+ if (info->stabsec == NULL || info->strsec == NULL)
+ {
+ /* No stabs debugging information. */
+ return true;
+ }
+
+ stabsize = info->stabsec->_raw_size;
+ strsize = info->strsec->_raw_size;
+ }
+ else
+ {
+ long reloc_size, reloc_count;
+ arelent **reloc_vector;
+ int i;
+ char *name;
+ char *file_name;
+ char *directory_name;
+ char *function_name;
+
+ info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
+ if (info == NULL)
+ return false;
+
+ /* FIXME: When using the linker --split-by-file or
+ --split-by-reloc options, it is possible for the .stab and
+ .stabstr sections to be split. We should handle that. */
+
+ info->stabsec = bfd_get_section_by_name (abfd, ".stab");
+ info->strsec = bfd_get_section_by_name (abfd, ".stabstr");
+
+ if (info->stabsec == NULL || info->strsec == NULL)
+ {
+ /* No stabs debugging information. Set *pinfo so that we
+ can return quickly in the info != NULL case above. */
+ *pinfo = (PTR) info;
+ return true;
+ }
+
+ stabsize = info->stabsec->_raw_size;
+ strsize = info->strsec->_raw_size;
+
+ info->stabs = (bfd_byte *) bfd_alloc (abfd, stabsize);
+ info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
+ if (info->stabs == NULL || info->strs == NULL)
+ return false;
+
+ if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
+ stabsize)
+ || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
+ strsize))
+ return false;
+
+ /* If this is a relocateable object file, we have to relocate
+ the entries in .stab. This should always be simple 32 bit
+ relocations against symbols defined in this object file, so
+ this should be no big deal. */
+ reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
+ if (reloc_size < 0)
+ return false;
+ reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ if (reloc_vector == NULL && reloc_size != 0)
+ return false;
+ reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
+ symbols);
+ if (reloc_count < 0)
+ {
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return false;
+ }
+ if (reloc_count > 0)
+ {
+ arelent **pr;
+
+ for (pr = reloc_vector; *pr != NULL; pr++)
+ {
+ arelent *r;
+ unsigned long val;
+ asymbol *sym;
+
+ r = *pr;
+ if (r->howto->rightshift != 0
+ || r->howto->size != 2
+ || r->howto->bitsize != 32
+ || r->howto->pc_relative
+ || r->howto->bitpos != 0
+ || r->howto->dst_mask != 0xffffffff)
+ {
+ (*_bfd_error_handler)
+ (_("Unsupported .stab relocation"));
+ bfd_set_error (bfd_error_invalid_operation);
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+ return false;
+ }
+
+ val = bfd_get_32 (abfd, info->stabs + r->address);
+ val &= r->howto->src_mask;
+ sym = *r->sym_ptr_ptr;
+ val += sym->value + sym->section->vma + r->addend;
+ bfd_put_32 (abfd, val, info->stabs + r->address);
+ }
+ }
+
+ if (reloc_vector != NULL)
+ free (reloc_vector);
+
+ /* First time through this function, build a table matching
+ function VM addresses to stabs, then sort based on starting
+ VM address. Do this in two passes: once to count how many
+ table entries we'll need, and a second to actually build the
+ table. */
+
+ info->indextablesize = 0;
+ saw_fun = 1;
+ for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE)
+ {
+ if (stab[TYPEOFF] == N_SO)
+ {
+ /* N_SO with null name indicates EOF */
+ if (bfd_get_32 (abfd, stab + STRDXOFF) == 0)
+ continue;
+
+ /* if we did not see a function def, leave space for one. */
+ if (saw_fun == 0)
+ ++info->indextablesize;
+
+ saw_fun = 0;
+
+ /* two N_SO's in a row is a filename and directory. Skip */
+ if (stab + STABSIZE < info->stabs + stabsize
+ && *(stab + STABSIZE + TYPEOFF) == N_SO)
+ {
+ stab += STABSIZE;
+ }
+ }
+ else if (stab[TYPEOFF] == N_FUN)
+ {
+ saw_fun = 1;
+ ++info->indextablesize;
+ }
+ }
+
+ if (saw_fun == 0)
+ ++info->indextablesize;
+
+ if (info->indextablesize == 0)
+ return true;
+ ++info->indextablesize;
+
+ info->indextable = ((struct indexentry *)
+ bfd_alloc (abfd,
+ (sizeof (struct indexentry)
+ * info->indextablesize)));
+ if (info->indextable == NULL)
+ return false;
+
+ file_name = NULL;
+ directory_name = NULL;
+ saw_fun = 1;
+
+ for (i = 0, stroff = 0, stab = info->stabs, str = info->strs;
+ i < info->indextablesize && stab < info->stabs + stabsize;
+ stab += STABSIZE)
+ {
+ switch (stab[TYPEOFF])
+ {
+ case 0:
+ /* This is the first entry in a compilation unit. */
+ if ((bfd_size_type) ((info->strs + strsize) - str) < stroff)
+ break;
+ str += stroff;
+ stroff = bfd_get_32 (abfd, stab + VALOFF);
+ break;
+
+ case N_SO:
+ /* The main file name. */
+
+ /* The following code creates a new indextable entry with
+ a NULL function name if there were no N_FUNs in a file.
+ Note that a N_SO without a file name is an EOF and
+ there could be 2 N_SO following it with the new filename
+ and directory. */
+ if (saw_fun == 0)
+ {
+ info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
+ info->indextable[i].stab = last_stab;
+ info->indextable[i].str = str;
+ info->indextable[i].directory_name = directory_name;
+ info->indextable[i].file_name = file_name;
+ info->indextable[i].function_name = NULL;
+ ++i;
+ }
+ saw_fun = 0;
+
+ file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
+ if (*file_name == '\0')
+ {
+ directory_name = NULL;
+ file_name = NULL;
+ saw_fun = 1;
+ }
+ else {
+ last_stab = stab;
+ if (stab + STABSIZE >= info->stabs + stabsize
+ || *(stab + STABSIZE + TYPEOFF) != N_SO)
+ {
+ directory_name = NULL;
+ }
+ else
+ {
+ /* Two consecutive N_SOs are a directory and a file
+ name. */
+ stab += STABSIZE;
+ directory_name = file_name;
+ file_name = ((char *) str
+ + bfd_get_32 (abfd, stab + STRDXOFF));
+ }
+ }
+ break;
+
+ case N_SOL:
+ /* The name of an include file. */
+ file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
+ break;
+
+ case N_FUN:
+ /* A function name. */
+ saw_fun = 1;
+ name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
+
+ if (*name == '\0')
+ name = NULL;
+
+ function_name = name;
+
+ if (name == NULL)
+ continue;
+
+ info->indextable[i].val = bfd_get_32 (abfd, stab + VALOFF);
+ info->indextable[i].stab = stab;
+ info->indextable[i].str = str;
+ info->indextable[i].directory_name = directory_name;
+ info->indextable[i].file_name = file_name;
+ info->indextable[i].function_name = function_name;
+ ++i;
+ break;
+ }
+ }
+
+ if (saw_fun == 0)
+ {
+ info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
+ info->indextable[i].stab = last_stab;
+ info->indextable[i].str = str;
+ info->indextable[i].directory_name = directory_name;
+ info->indextable[i].file_name = file_name;
+ info->indextable[i].function_name = NULL;
+ ++i;
+ }
+
+ info->indextable[i].val = (bfd_vma) -1;
+ info->indextable[i].stab = info->stabs + stabsize;
+ info->indextable[i].str = str;
+ info->indextable[i].directory_name = NULL;
+ info->indextable[i].file_name = NULL;
+ info->indextable[i].function_name = NULL;
+ ++i;
+
+ info->indextablesize = i;
+ qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry);
+
+ *pinfo = (PTR) info;
+ }
+
+ /* We are passed a section relative offset. The offsets in the
+ stabs information are absolute. */
+ offset += bfd_get_section_vma (abfd, section);
+
+#ifdef ENABLE_CACHING
+ if (info->cached_indexentry != NULL
+ && offset >= info->cached_offset
+ && offset < (info->cached_indexentry + 1)->val)
+ {
+ stab = info->cached_stab;
+ indexentry = info->cached_indexentry;
+ file_name = info->cached_file_name;
+ }
+ else
+#endif
+ {
+ /* Cache non-existant or invalid. Do binary search on
+ indextable. */
+
+ long low, high;
+ long mid = -1;
+
+ indexentry = NULL;
+
+ low = 0;
+ high = info->indextablesize - 1;
+ while (low != high)
+ {
+ mid = (high + low) / 2;
+ if (offset >= info->indextable[mid].val
+ && offset < info->indextable[mid + 1].val)
+ {
+ indexentry = &info->indextable[mid];
+ break;
+ }
+
+ if (info->indextable[mid].val > offset)
+ high = mid;
+ else
+ low = mid + 1;
+ }
+
+ if (indexentry == NULL)
+ return true;
+
+ stab = indexentry->stab + STABSIZE;
+ file_name = indexentry->file_name;
+ }
+
+ directory_name = indexentry->directory_name;
+ str = indexentry->str;
+
+ for (; stab < (indexentry+1)->stab; stab += STABSIZE)
+ {
+ boolean done;
+ bfd_vma val;
+
+ done = false;
+
+ switch (stab[TYPEOFF])
+ {
+ case N_SOL:
+ /* The name of an include file. */
+ val = bfd_get_32 (abfd, stab + VALOFF);
+ if (val <= offset)
+ {
+ file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
+ *pline = 0;
+ }
+ break;
+
+ case N_SLINE:
+ case N_DSLINE:
+ case N_BSLINE:
+ /* A line number. The value is relative to the start of the
+ current function. */
+ val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF);
+ if (val <= offset)
+ {
+ *pline = bfd_get_16 (abfd, stab + DESCOFF);
+
+#ifdef ENABLE_CACHING
+ info->cached_stab = stab;
+ info->cached_offset = val;
+ info->cached_file_name = file_name;
+ info->cached_indexentry = indexentry;
+#endif
+ }
+ if (val > offset)
+ done = true;
+ break;
+
+ case N_FUN:
+ case N_SO:
+ done = true;
+ break;
+ }
+
+ if (done)
+ break;
+ }
+
+ *pfound = true;
+
+ if (file_name[0] == '/' || directory_name == NULL)
+ *pfilename = file_name;
+ else
+ {
+ size_t dirlen;
+
+ dirlen = strlen (directory_name);
+ if (info->filename == NULL
+ || strncmp (info->filename, directory_name, dirlen) != 0
+ || strcmp (info->filename + dirlen, file_name) != 0)
+ {
+ if (info->filename != NULL)
+ free (info->filename);
+ info->filename = (char *) bfd_malloc (dirlen +
+ strlen (file_name)
+ + 1);
+ if (info->filename == NULL)
+ return false;
+ strcpy (info->filename, directory_name);
+ strcpy (info->filename + dirlen, file_name);
+ }
+
+ *pfilename = info->filename;
+ }
+
+ if (indexentry->function_name != NULL)
+ {
+ char *s;
+
+ /* This will typically be something like main:F(0,1), so we want
+ to clobber the colon. It's OK to change the name, since the
+ string is in our own local storage anyhow. */
+
+ s = strchr (indexentry->function_name, ':');
+ if (s != NULL)
+ *s = '\0';
+
+ *pfnname = indexentry->function_name;
+ }
+
+ return true;
+}
diff --git a/bfd/sysdep.h b/bfd/sysdep.h
new file mode 100644
index 00000000000..0a58983fa2d
--- /dev/null
+++ b/bfd/sysdep.h
@@ -0,0 +1,144 @@
+/* sysdep.h -- handle host dependencies for the BFD library
+ Copyright 1995, 96, 97, 98, 1999 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef BFD_SYSDEP_H
+#define BFD_SYSDEP_H
+
+#include "ansidecl.h"
+
+#include "config.h"
+
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO))
+extern int errno;
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#else
+extern char *strchr ();
+extern char *strrchr ();
+#endif
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef USE_BINARY_FOPEN
+#include "fopen-bin.h"
+#else
+#include "fopen-same.h"
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#else
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#endif
+
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#endif
+#ifndef O_WRONLY
+#define O_WRONLY 1
+#endif
+#ifndef O_RDWR
+#define O_RDWR 2
+#endif
+#ifndef O_ACCMODE
+#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+
+#ifdef NEED_DECLARATION_STRSTR
+extern char *strstr ();
+#endif
+
+#ifdef NEED_DECLARATION_MALLOC
+extern PTR malloc ();
+#endif
+
+#ifdef NEED_DECLARATION_REALLOC
+extern PTR realloc ();
+#endif
+
+#ifdef NEED_DECLARATION_FREE
+extern void free ();
+#endif
+
+#ifdef NEED_DECLARATION_GETENV
+extern char *getenv ();
+#endif
+
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#define _(String) dgettext (PACKAGE, String)
+#ifdef gettext_noop
+#define N_(String) gettext_noop (String)
+#else
+#define N_(String) (String)
+#endif
+#else
+/* Stubs that do something close enough. */
+#define textdomain(String) (String)
+#define gettext(String) (String)
+#define dgettext(Domain,Message) (Message)
+#define dcgettext(Domain,Message,Type) (Message)
+#define bindtextdomain(Domain,Directory) (Domain)
+#define _(String) (String)
+#define N_(String) (String)
+#endif
+
+#endif /* ! defined (BFD_SYSDEP_H) */
diff --git a/bfd/targets.c b/bfd/targets.c
new file mode 100644
index 00000000000..bb6e51d854e
--- /dev/null
+++ b/bfd/targets.c
@@ -0,0 +1,1079 @@
+/* Generic target-file-type support for the BFD library.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "fnmatch.h"
+
+/*
+SECTION
+ Targets
+
+DESCRIPTION
+ Each port of BFD to a different machine requries the creation
+ of a target back end. All the back end provides to the root
+ part of BFD is a structure containing pointers to functions
+ which perform certain low level operations on files. BFD
+ translates the applications's requests through a pointer into
+ calls to the back end routines.
+
+ When a file is opened with <<bfd_openr>>, its format and
+ target are unknown. BFD uses various mechanisms to determine
+ how to interpret the file. The operations performed are:
+
+ o Create a BFD by calling the internal routine
+ <<_bfd_new_bfd>>, then call <<bfd_find_target>> with the
+ target string supplied to <<bfd_openr>> and the new BFD pointer.
+
+ o If a null target string was provided to <<bfd_find_target>>,
+ look up the environment variable <<GNUTARGET>> and use
+ that as the target string.
+
+ o If the target string is still <<NULL>>, or the target string is
+ <<default>>, then use the first item in the target vector
+ as the target type, and set <<target_defaulted>> in the BFD to
+ cause <<bfd_check_format>> to loop through all the targets.
+ @xref{bfd_target}. @xref{Formats}.
+
+ o Otherwise, inspect the elements in the target vector
+ one by one, until a match on target name is found. When found,
+ use it.
+
+ o Otherwise return the error <<bfd_error_invalid_target>> to
+ <<bfd_openr>>.
+
+ o <<bfd_openr>> attempts to open the file using
+ <<bfd_open_file>>, and returns the BFD.
+
+ Once the BFD has been opened and the target selected, the file
+ format may be determined. This is done by calling
+ <<bfd_check_format>> on the BFD with a suggested format.
+ If <<target_defaulted>> has been set, each possible target
+ type is tried to see if it recognizes the specified format.
+ <<bfd_check_format>> returns <<true>> when the caller guesses right.
+@menu
+@* bfd_target::
+@end menu
+*/
+
+
+/*
+
+INODE
+ bfd_target, , Targets, Targets
+DOCDD
+SUBSECTION
+ bfd_target
+
+DESCRIPTION
+ This structure contains everything that BFD knows about a
+ target. It includes things like its byte order, name, and which
+ routines to call to do various operations.
+
+ Every BFD points to a target structure with its <<xvec>>
+ member.
+
+ The macros below are used to dispatch to functions through the
+ <<bfd_target>> vector. They are used in a number of macros further
+ down in @file{bfd.h}, and are also used when calling various
+ routines by hand inside the BFD implementation. The @var{arglist}
+ argument must be parenthesized; it contains all the arguments
+ to the called function.
+
+ They make the documentation (more) unpleasant to read, so if
+ someone wants to fix this and not break the above, please do.
+
+.#define BFD_SEND(bfd, message, arglist) \
+. ((*((bfd)->xvec->message)) arglist)
+.
+.#ifdef DEBUG_BFD_SEND
+.#undef BFD_SEND
+.#define BFD_SEND(bfd, message, arglist) \
+. (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
+. ((*((bfd)->xvec->message)) arglist) : \
+. (bfd_assert (__FILE__,__LINE__), NULL))
+.#endif
+
+ For operations which index on the BFD format:
+
+.#define BFD_SEND_FMT(bfd, message, arglist) \
+. (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
+.
+.#ifdef DEBUG_BFD_SEND
+.#undef BFD_SEND_FMT
+.#define BFD_SEND_FMT(bfd, message, arglist) \
+. (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
+. (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
+. (bfd_assert (__FILE__,__LINE__), NULL))
+.#endif
+
+ This is the structure which defines the type of BFD this is. The
+ <<xvec>> member of the struct <<bfd>> itself points here. Each
+ module that implements access to a different target under BFD,
+ defines one of these.
+
+
+ FIXME, these names should be rationalised with the names of
+ the entry points which call them. Too bad we can't have one
+ macro to define them both!
+
+.enum bfd_flavour {
+. bfd_target_unknown_flavour,
+. bfd_target_aout_flavour,
+. bfd_target_coff_flavour,
+. bfd_target_ecoff_flavour,
+. bfd_target_elf_flavour,
+. bfd_target_ieee_flavour,
+. bfd_target_nlm_flavour,
+. bfd_target_oasys_flavour,
+. bfd_target_tekhex_flavour,
+. bfd_target_srec_flavour,
+. bfd_target_ihex_flavour,
+. bfd_target_som_flavour,
+. bfd_target_os9k_flavour,
+. bfd_target_versados_flavour,
+. bfd_target_msdos_flavour,
+. bfd_target_ovax_flavour,
+. bfd_target_evax_flavour
+.};
+.
+.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
+.
+.{* Forward declaration. *}
+.typedef struct bfd_link_info _bfd_link_info;
+.
+.typedef struct bfd_target
+.{
+
+Identifies the kind of target, e.g., SunOS4, Ultrix, etc.
+
+. char *name;
+
+The "flavour" of a back end is a general indication about the contents
+of a file.
+
+. enum bfd_flavour flavour;
+
+The order of bytes within the data area of a file.
+
+. enum bfd_endian byteorder;
+
+The order of bytes within the header parts of a file.
+
+. enum bfd_endian header_byteorder;
+
+A mask of all the flags which an executable may have set -
+from the set <<BFD_NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>.
+
+. flagword object_flags;
+
+A mask of all the flags which a section may have set - from
+the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>.
+
+. flagword section_flags;
+
+The character normally found at the front of a symbol
+(if any), perhaps `_'.
+
+. char symbol_leading_char;
+
+The pad character for file names within an archive header.
+
+. char ar_pad_char;
+
+The maximum number of characters in an archive header.
+
+. unsigned short ar_max_namelen;
+
+Entries for byte swapping for data. These are different from the other
+entry points, since they don't take a BFD asthe first argument.
+Certain other handlers could do the same.
+
+. bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
+. bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
+. void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
+. bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
+. void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
+. bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
+. void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
+
+Byte swapping for the headers
+
+. bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
+. bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
+. void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
+. bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
+. void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
+. bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
+. void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
+
+Format dependent routines: these are vectors of entry points
+within the target vector structure, one for each format to check.
+
+Check the format of a file being read. Return a <<bfd_target *>> or zero.
+
+. const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
+
+Set the format of a file being written.
+
+. boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
+
+Write cached information into a file being written, at <<bfd_close>>.
+
+. boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
+
+The general target vector.
+
+.
+. {* Generic entry points. *}
+.#define BFD_JUMP_TABLE_GENERIC(NAME)\
+.CAT(NAME,_close_and_cleanup),\
+.CAT(NAME,_bfd_free_cached_info),\
+.CAT(NAME,_new_section_hook),\
+.CAT(NAME,_get_section_contents),\
+.CAT(NAME,_get_section_contents_in_window)
+.
+. {* Called when the BFD is being closed to do any necessary cleanup. *}
+. boolean (*_close_and_cleanup) PARAMS ((bfd *));
+. {* Ask the BFD to free all cached information. *}
+. boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
+. {* Called when a new section is created. *}
+. boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
+. {* Read the contents of a section. *}
+. boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+. file_ptr, bfd_size_type));
+. boolean (*_bfd_get_section_contents_in_window)
+. PARAMS ((bfd *, sec_ptr, bfd_window *,
+. file_ptr, bfd_size_type));
+.
+. {* Entry points to copy private data. *}
+.#define BFD_JUMP_TABLE_COPY(NAME)\
+.CAT(NAME,_bfd_copy_private_bfd_data),\
+.CAT(NAME,_bfd_merge_private_bfd_data),\
+.CAT(NAME,_bfd_copy_private_section_data),\
+.CAT(NAME,_bfd_copy_private_symbol_data),\
+.CAT(NAME,_bfd_set_private_flags),\
+.CAT(NAME,_bfd_print_private_bfd_data)\
+. {* Called to copy BFD general private data from one object file
+. to another. *}
+. boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
+. {* Called to merge BFD general private data from one object file
+. to a common output file when linking. *}
+. boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
+. {* Called to copy BFD private section data from one object file
+. to another. *}
+. boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
+. bfd *, sec_ptr));
+. {* Called to copy BFD private symbol data from one symbol
+. to another. *}
+. boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
+. bfd *, asymbol *));
+. {* Called to set private backend flags *}
+. boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
+.
+. {* Called to print private BFD data *}
+. boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
+.
+. {* Core file entry points. *}
+.#define BFD_JUMP_TABLE_CORE(NAME)\
+.CAT(NAME,_core_file_failing_command),\
+.CAT(NAME,_core_file_failing_signal),\
+.CAT(NAME,_core_file_matches_executable_p)
+. char * (*_core_file_failing_command) PARAMS ((bfd *));
+. int (*_core_file_failing_signal) PARAMS ((bfd *));
+. boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
+.
+. {* Archive entry points. *}
+.#define BFD_JUMP_TABLE_ARCHIVE(NAME)\
+.CAT(NAME,_slurp_armap),\
+.CAT(NAME,_slurp_extended_name_table),\
+.CAT(NAME,_construct_extended_name_table),\
+.CAT(NAME,_truncate_arname),\
+.CAT(NAME,_write_armap),\
+.CAT(NAME,_read_ar_hdr),\
+.CAT(NAME,_openr_next_archived_file),\
+.CAT(NAME,_get_elt_at_index),\
+.CAT(NAME,_generic_stat_arch_elt),\
+.CAT(NAME,_update_armap_timestamp)
+. boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
+. boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
+. boolean (*_bfd_construct_extended_name_table)
+. PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+. void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
+. boolean (*write_armap) PARAMS ((bfd *arch,
+. unsigned int elength,
+. struct orl *map,
+. unsigned int orl_count,
+. int stridx));
+. PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
+. bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
+.#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
+. bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
+. int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
+. boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
+.
+. {* Entry points used for symbols. *}
+.#define BFD_JUMP_TABLE_SYMBOLS(NAME)\
+.CAT(NAME,_get_symtab_upper_bound),\
+.CAT(NAME,_get_symtab),\
+.CAT(NAME,_make_empty_symbol),\
+.CAT(NAME,_print_symbol),\
+.CAT(NAME,_get_symbol_info),\
+.CAT(NAME,_bfd_is_local_label_name),\
+.CAT(NAME,_get_lineno),\
+.CAT(NAME,_find_nearest_line),\
+.CAT(NAME,_bfd_make_debug_symbol),\
+.CAT(NAME,_read_minisymbols),\
+.CAT(NAME,_minisymbol_to_symbol)
+. long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
+. long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
+. struct symbol_cache_entry **));
+. struct symbol_cache_entry *
+. (*_bfd_make_empty_symbol) PARAMS ((bfd *));
+. void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
+. struct symbol_cache_entry *,
+. bfd_print_symbol_type));
+.#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
+. void (*_bfd_get_symbol_info) PARAMS ((bfd *,
+. struct symbol_cache_entry *,
+. symbol_info *));
+.#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
+. boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
+.
+. alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
+. boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
+. struct sec *section, struct symbol_cache_entry **symbols,
+. bfd_vma offset, CONST char **file, CONST char **func,
+. unsigned int *line));
+. {* Back-door to allow format-aware applications to create debug symbols
+. while using BFD for everything else. Currently used by the assembler
+. when creating COFF files. *}
+. asymbol * (*_bfd_make_debug_symbol) PARAMS ((
+. bfd *abfd,
+. void *ptr,
+. unsigned long size));
+.#define bfd_read_minisymbols(b, d, m, s) \
+. BFD_SEND (b, _read_minisymbols, (b, d, m, s))
+. long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
+. unsigned int *));
+.#define bfd_minisymbol_to_symbol(b, d, m, f) \
+. BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
+. asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
+. asymbol *));
+.
+. {* Routines for relocs. *}
+.#define BFD_JUMP_TABLE_RELOCS(NAME)\
+.CAT(NAME,_get_reloc_upper_bound),\
+.CAT(NAME,_canonicalize_reloc),\
+.CAT(NAME,_bfd_reloc_type_lookup)
+. long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
+. long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
+. struct symbol_cache_entry **));
+. {* See documentation on reloc types. *}
+. reloc_howto_type *
+. (*reloc_type_lookup) PARAMS ((bfd *abfd,
+. bfd_reloc_code_real_type code));
+.
+. {* Routines used when writing an object file. *}
+.#define BFD_JUMP_TABLE_WRITE(NAME)\
+.CAT(NAME,_set_arch_mach),\
+.CAT(NAME,_set_section_contents)
+. boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
+. unsigned long));
+. boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+. file_ptr, bfd_size_type));
+.
+. {* Routines used by the linker. *}
+.#define BFD_JUMP_TABLE_LINK(NAME)\
+.CAT(NAME,_sizeof_headers),\
+.CAT(NAME,_bfd_get_relocated_section_contents),\
+.CAT(NAME,_bfd_relax_section),\
+.CAT(NAME,_bfd_link_hash_table_create),\
+.CAT(NAME,_bfd_link_add_symbols),\
+.CAT(NAME,_bfd_final_link),\
+.CAT(NAME,_bfd_link_split_section),\
+.CAT(NAME,_bfd_gc_sections)
+. int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
+. bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
+. struct bfd_link_info *, struct bfd_link_order *,
+. bfd_byte *data, boolean relocateable,
+. struct symbol_cache_entry **));
+.
+. boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
+. struct bfd_link_info *, boolean *again));
+.
+. {* Create a hash table for the linker. Different backends store
+. different information in this table. *}
+. struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
+.
+. {* Add symbols from this object file into the hash table. *}
+. boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+.
+. {* Do a link based on the link_order structures attached to each
+. section of the BFD. *}
+. boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
+.
+. {* Should this section be split up into smaller pieces during linking. *}
+. boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
+.
+. {* Remove sections that are not referenced from the output. *}
+. boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
+.
+. {* Routines to handle dynamic symbols and relocs. *}
+.#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
+.CAT(NAME,_get_dynamic_symtab_upper_bound),\
+.CAT(NAME,_canonicalize_dynamic_symtab),\
+.CAT(NAME,_get_dynamic_reloc_upper_bound),\
+.CAT(NAME,_canonicalize_dynamic_reloc)
+. {* Get the amount of memory required to hold the dynamic symbols. *}
+. long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
+. {* Read in the dynamic symbols. *}
+. long (*_bfd_canonicalize_dynamic_symtab)
+. PARAMS ((bfd *, struct symbol_cache_entry **));
+. {* Get the amount of memory required to hold the dynamic relocs. *}
+. long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
+. {* Read in the dynamic relocs. *}
+. long (*_bfd_canonicalize_dynamic_reloc)
+. PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
+.
+
+Data for use by back-end routines, which isn't generic enough to belong
+in this structure.
+
+. PTR backend_data;
+.} bfd_target;
+
+*/
+
+/* All known xvecs (even those that don't compile on all systems).
+ Alphabetized for easy reference.
+ They are listed a second time below, since
+ we can't intermix extern's and initializers. */
+extern const bfd_target a29kcoff_big_vec;
+extern const bfd_target a_out_adobe_vec;
+extern const bfd_target aout_arm_big_vec;
+extern const bfd_target aout_arm_little_vec;
+extern const bfd_target aout_mips_big_vec;
+extern const bfd_target aout_mips_little_vec;
+extern const bfd_target aout0_big_vec;
+extern const bfd_target apollocoff_vec;
+extern const bfd_target armcoff_little_vec;
+extern const bfd_target armcoff_big_vec;
+extern const bfd_target armpe_little_vec;
+extern const bfd_target armpe_big_vec;
+extern const bfd_target armpei_little_vec;
+extern const bfd_target armpei_big_vec;
+extern const bfd_target arm_epoc_pe_little_vec;
+extern const bfd_target arm_epoc_pe_big_vec;
+extern const bfd_target arm_epoc_pei_little_vec;
+extern const bfd_target arm_epoc_pei_big_vec;
+extern const bfd_target b_out_vec_big_host;
+extern const bfd_target b_out_vec_little_host;
+extern const bfd_target bfd_elf64_alpha_vec;
+extern const bfd_target bfd_elf32_bigarc_vec;
+extern const bfd_target bfd_elf32_bigarm_vec;
+extern const bfd_target bfd_elf32_bigarm_oabi_vec;
+extern const bfd_target bfd_elf32_littlearc_vec;
+extern const bfd_target bfd_elf32_littlearm_vec;
+extern const bfd_target bfd_elf32_littlearm_oabi_vec;
+extern const bfd_target bfd_elf32_big_generic_vec;
+extern const bfd_target bfd_elf32_bigmips_vec;
+extern const bfd_target bfd_elf64_bigmips_vec;
+extern const bfd_target bfd_elf32_d10v_vec;
+extern const bfd_target bfd_elf32_d30v_vec;
+extern const bfd_target bfd_elf32_hppa_vec;
+extern const bfd_target bfd_elf32_i386_vec;
+extern const bfd_target bfd_elf32_i860_vec;
+extern const bfd_target bfd_elf32_little_generic_vec;
+extern const bfd_target bfd_elf32_littlemips_vec;
+extern const bfd_target bfd_elf64_littlemips_vec;
+extern const bfd_target bfd_elf32_m32r_vec;
+extern const bfd_target bfd_elf32_m68k_vec;
+extern const bfd_target bfd_elf32_m88k_vec;
+extern const bfd_target bfd_elf32_mn10200_vec;
+extern const bfd_target bfd_elf32_mn10300_vec;
+extern const bfd_target bfd_elf32_powerpc_vec;
+extern const bfd_target bfd_elf32_powerpcle_vec;
+extern const bfd_target bfd_elf32_sh_vec;
+extern const bfd_target bfd_elf32_shl_vec;
+extern const bfd_target bfd_elf32_sparc_vec;
+extern const bfd_target bfd_elf32_v850_vec;
+extern const bfd_target bfd_elf32_fr30_vec;
+extern const bfd_target bfd_elf32_mcore_big_vec;
+extern const bfd_target bfd_elf32_mcore_little_vec;
+extern const bfd_target bfd_elf64_big_generic_vec;
+extern const bfd_target bfd_elf64_little_generic_vec;
+extern const bfd_target bfd_elf64_sparc_vec;
+extern const bfd_target demo_64_vec;
+extern const bfd_target ecoff_big_vec;
+extern const bfd_target ecoff_little_vec;
+extern const bfd_target ecoff_biglittle_vec;
+extern const bfd_target ecoffalpha_little_vec;
+extern const bfd_target h8300coff_vec;
+extern const bfd_target h8500coff_vec;
+extern const bfd_target host_aout_vec;
+extern const bfd_target hp300bsd_vec;
+extern const bfd_target hp300hpux_vec;
+extern const bfd_target som_vec;
+extern const bfd_target i386aout_vec;
+extern const bfd_target i386bsd_vec;
+extern const bfd_target i386dynix_vec;
+extern const bfd_target i386freebsd_vec;
+extern const bfd_target i386os9k_vec;
+extern const bfd_target i386coff_vec;
+extern const bfd_target bfd_powerpc_pe_vec;
+extern const bfd_target bfd_powerpcle_pe_vec;
+extern const bfd_target bfd_powerpc_pei_vec;
+extern const bfd_target bfd_powerpcle_pei_vec;
+extern const bfd_target i386pe_vec;
+extern const bfd_target i386pei_vec;
+extern const bfd_target go32coff_vec;
+extern const bfd_target go32stubbedcoff_vec;
+extern const bfd_target i386linux_vec;
+extern const bfd_target i386lynx_aout_vec;
+extern const bfd_target i386lynx_coff_vec;
+extern const bfd_target i386mach3_vec;
+extern const bfd_target i386msdos_vec;
+extern const bfd_target i386netbsd_vec;
+extern const bfd_target i860coff_vec;
+extern const bfd_target icoff_big_vec;
+extern const bfd_target icoff_little_vec;
+extern const bfd_target ieee_vec;
+extern const bfd_target m68kaux_coff_vec;
+extern const bfd_target m68kcoff_vec;
+extern const bfd_target m68kcoffun_vec;
+extern const bfd_target m68klinux_vec;
+extern const bfd_target m68klynx_aout_vec;
+extern const bfd_target m68klynx_coff_vec;
+extern const bfd_target m68knetbsd_vec;
+extern const bfd_target m68ksysvcoff_vec;
+extern const bfd_target m68k4knetbsd_vec;
+extern const bfd_target m88kbcs_vec;
+extern const bfd_target m88kmach3_vec;
+extern const bfd_target mcore_pe_big_vec;
+extern const bfd_target mcore_pe_little_vec;
+extern const bfd_target mcore_pei_big_vec;
+extern const bfd_target mcore_pei_little_vec;
+extern const bfd_target newsos3_vec;
+extern const bfd_target nlm32_i386_vec;
+extern const bfd_target nlm32_sparc_vec;
+extern const bfd_target nlm32_alpha_vec;
+extern const bfd_target nlm32_powerpc_vec;
+extern const bfd_target pc532netbsd_vec;
+extern const bfd_target oasys_vec;
+extern const bfd_target pc532machaout_vec;
+extern const bfd_target ppcboot_vec;
+extern const bfd_target riscix_vec;
+extern const bfd_target pmac_xcoff_vec;
+extern const bfd_target rs6000coff_vec;
+extern const bfd_target shcoff_vec;
+extern const bfd_target shlcoff_vec;
+extern const bfd_target shcoff_small_vec;
+extern const bfd_target shlcoff_small_vec;
+extern const bfd_target sparcle_aout_vec;
+extern const bfd_target sparclinux_vec;
+extern const bfd_target sparclynx_aout_vec;
+extern const bfd_target sparclynx_coff_vec;
+extern const bfd_target sparcnetbsd_vec;
+extern const bfd_target sparccoff_vec;
+extern const bfd_target sunos_big_vec;
+extern const bfd_target tekhex_vec;
+extern const bfd_target tic30_aout_vec;
+extern const bfd_target tic30_coff_vec;
+extern const bfd_target tic80coff_vec;
+extern const bfd_target vaxnetbsd_vec;
+extern const bfd_target versados_vec;
+extern const bfd_target vms_alpha_vec;
+extern const bfd_target vms_vax_vec;
+extern const bfd_target we32kcoff_vec;
+extern const bfd_target w65_vec;
+extern const bfd_target z8kcoff_vec;
+
+/* srec is always included. */
+extern const bfd_target srec_vec;
+extern const bfd_target symbolsrec_vec;
+
+/* binary is always included. */
+extern const bfd_target binary_vec;
+
+/* ihex is always included. */
+extern const bfd_target ihex_vec;
+
+/* All of the xvecs for core files. */
+extern const bfd_target aix386_core_vec;
+extern const bfd_target cisco_core_vec;
+extern const bfd_target hpux_core_vec;
+extern const bfd_target hppabsd_core_vec;
+extern const bfd_target irix_core_vec;
+extern const bfd_target netbsd_core_vec;
+extern const bfd_target osf_core_vec;
+extern const bfd_target sco5_core_vec;
+extern const bfd_target trad_core_vec;
+extern const bfd_target ptrace_core_vec;
+
+const bfd_target * const bfd_target_vector[] = {
+
+#ifdef SELECT_VECS
+
+ SELECT_VECS,
+
+#else /* not SELECT_VECS */
+
+#ifdef DEFAULT_VECTOR
+ &DEFAULT_VECTOR,
+#endif
+ /* This list is alphabetized to make it easy to compare
+ with other vector lists -- the decls above and
+ the case statement in configure.in.
+ Vectors that don't compile on all systems, or aren't finished,
+ should have an entry here with #if 0 around it, to show that
+ it wasn't omitted by mistake. */
+ &a29kcoff_big_vec,
+ &a_out_adobe_vec,
+#if 0 /* No one seems to use this. */
+ &aout_mips_big_vec,
+#endif
+ &aout_mips_little_vec,
+ &b_out_vec_big_host,
+ &b_out_vec_little_host,
+
+ /* This, and other vectors, may not be used in any *.mt configuration.
+ But that does not mean they are unnecessary. If configured with
+ --enable-targets=all, objdump or gdb should be able to examine
+ the file even if we don't recognize the machine type. */
+ &bfd_elf32_big_generic_vec,
+#ifdef BFD64
+ &bfd_elf64_alpha_vec,
+#endif
+ &bfd_elf32_bigarc_vec,
+ &bfd_elf32_bigarm_vec,
+ &bfd_elf32_bigarm_oabi_vec,
+ &bfd_elf32_bigmips_vec,
+#ifdef BFD64
+ &bfd_elf64_bigmips_vec,
+#endif
+ &bfd_elf32_d10v_vec,
+ &bfd_elf32_d30v_vec,
+ &bfd_elf32_hppa_vec,
+ &bfd_elf32_i386_vec,
+ &bfd_elf32_i860_vec,
+ &bfd_elf32_little_generic_vec,
+ &bfd_elf32_littlearc_vec,
+ &bfd_elf32_littlearm_vec,
+ &bfd_elf32_littlearm_oabi_vec,
+ &bfd_elf32_littlemips_vec,
+#ifdef BFD64
+ &bfd_elf64_littlemips_vec,
+#endif
+ &bfd_elf32_m32r_vec,
+ &bfd_elf32_mn10200_vec,
+ &bfd_elf32_mn10300_vec,
+ &bfd_elf32_m68k_vec,
+ &bfd_elf32_m88k_vec,
+ &bfd_elf32_sparc_vec,
+ &bfd_elf32_powerpc_vec,
+ &bfd_elf32_powerpcle_vec,
+ &bfd_elf32_v850_vec,
+ &bfd_elf32_fr30_vec,
+ &bfd_elf32_mcore_big_vec,
+ &bfd_elf32_mcore_little_vec,
+#ifdef BFD64 /* No one seems to use this. */
+ &bfd_elf64_big_generic_vec,
+ &bfd_elf64_little_generic_vec,
+#endif
+#if 0
+ &bfd_elf64_sparc_vec,
+#endif
+ /* We don't include cisco_core_vec. Although it has a magic number,
+ the magic number isn't at the beginning of the file, and thus
+ might spuriously match other kinds of files. */
+#ifdef BFD64
+ &demo_64_vec, /* Only compiled if host has long-long support */
+#endif
+ &ecoff_big_vec,
+ &ecoff_little_vec,
+ &ecoff_biglittle_vec,
+#ifdef BFD64
+ &ecoffalpha_little_vec,
+#endif
+ &h8300coff_vec,
+ &h8500coff_vec,
+#if 0
+ /* Since a.out files lack decent magic numbers, no way to recognize
+ which kind of a.out file it is. */
+ &host_aout_vec,
+#endif
+#if 0 /* Clashes with sunos_big_vec magic no. */
+ &hp300bsd_vec,
+#endif
+ &hp300hpux_vec,
+#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
+ &som_vec,
+#endif
+ &i386aout_vec,
+ &i386bsd_vec,
+ &i386coff_vec,
+ &i386freebsd_vec,
+ &i860coff_vec,
+ &bfd_powerpc_pe_vec,
+ &bfd_powerpcle_pe_vec,
+ &bfd_powerpc_pei_vec,
+ &bfd_powerpcle_pei_vec,
+ &go32coff_vec,
+ &go32stubbedcoff_vec,
+#if 0
+ /* Since a.out files lack decent magic numbers, no way to recognize
+ which kind of a.out file it is. */
+ &i386linux_vec,
+#endif
+ &i386lynx_aout_vec,
+ &i386lynx_coff_vec,
+#if 0
+ /* No distinguishing features for Mach 3 executables. */
+ &i386mach3_vec,
+#endif
+ &i386msdos_vec,
+ &i386netbsd_vec,
+ &i386os9k_vec,
+ &i386pe_vec,
+ &i386pei_vec,
+ &armcoff_little_vec,
+ &armcoff_big_vec,
+ &armpe_little_vec,
+ &armpe_big_vec,
+ &armpei_little_vec,
+ &armpei_big_vec,
+ &arm_epoc_pe_little_vec,
+ &arm_epoc_pe_big_vec,
+ &arm_epoc_pei_little_vec,
+ &arm_epoc_pei_big_vec,
+ &icoff_big_vec,
+ &icoff_little_vec,
+ &ieee_vec,
+ &m68kcoff_vec,
+ &m68kcoffun_vec,
+#if 0
+ /* Since a.out files lack decent magic numbers, no way to recognize
+ which kind of a.out file it is. */
+ &m68klinux_vec,
+#endif
+ &m68klynx_aout_vec,
+ &m68klynx_coff_vec,
+ &m68knetbsd_vec,
+ &m68ksysvcoff_vec,
+ &m88kbcs_vec,
+ &m88kmach3_vec,
+ &mcore_pe_big_vec,
+ &mcore_pe_little_vec,
+ &mcore_pei_big_vec,
+ &mcore_pei_little_vec,
+ &newsos3_vec,
+ &nlm32_i386_vec,
+ &nlm32_sparc_vec,
+#ifdef BFD64
+ &nlm32_alpha_vec,
+#endif
+ &pc532netbsd_vec,
+#if 0
+ /* We have no oasys tools anymore, so we can't test any of this
+ anymore. If you want to test the stuff yourself, go ahead...
+ steve@cygnus.com
+ Worse, since there is no magic number for archives, there
+ can be annoying target mis-matches. */
+ &oasys_vec,
+#endif
+ &pc532machaout_vec,
+#if 0
+ /* We have no way of distinguishing these from other a.out variants */
+ &aout_arm_big_vec,
+ &aout_arm_little_vec,
+ &riscix_vec,
+#endif
+#if 0
+ /* This has the same magic number as RS/6000. */
+ &pmac_xcoff_vec,
+#endif
+ &rs6000coff_vec,
+ &ppcboot_vec,
+ &shcoff_vec,
+ &shlcoff_vec,
+ &shcoff_small_vec,
+ &shlcoff_small_vec,
+ &sparcle_aout_vec,
+ &sparclinux_vec,
+ &sparclynx_aout_vec,
+ &sparclynx_coff_vec,
+ &sparcnetbsd_vec,
+ &sunos_big_vec,
+ &aout0_big_vec,
+ &tic30_aout_vec,
+ &tic30_coff_vec,
+ &tic80coff_vec,
+ &vaxnetbsd_vec,
+ &versados_vec,
+#ifdef BFD64
+ &vms_alpha_vec,
+#endif
+ &vms_vax_vec,
+ &we32kcoff_vec,
+ &z8kcoff_vec,
+
+#endif /* not SELECT_VECS */
+
+/* Always support S-records, for convenience. */
+ &srec_vec,
+ &symbolsrec_vec,
+/* And tekhex */
+ &tekhex_vec,
+/* Likewise for binary output. */
+ &binary_vec,
+/* Likewise for ihex. */
+ &ihex_vec,
+
+/* Add any required traditional-core-file-handler. */
+
+#ifdef AIX386_CORE
+ &aix386_core_vec,
+#endif
+#ifdef HPUX_CORE
+ &hpux_core_vec,
+#endif
+#ifdef HPPABSD_CORE
+ &hppabsd_core_vec,
+#endif
+#ifdef IRIX_CORE
+ &irix_core_vec,
+#endif
+#ifdef NETBSD_CORE
+ &netbsd_core_vec,
+#endif
+#ifdef OSF_CORE
+ &osf_core_vec,
+#endif
+#ifdef SCO5_CORE
+ &sco5_core_vec,
+#endif
+#ifdef TRAD_CORE
+ &trad_core_vec,
+#endif
+
+#ifdef PTRACE_CORE
+ &ptrace_core_vec,
+#endif
+
+ NULL /* end of list marker */
+};
+
+/* bfd_default_vector[0] contains either the address of the default vector,
+ if there is one, or zero if there isn't. */
+
+const bfd_target *bfd_default_vector[] = {
+#ifdef DEFAULT_VECTOR
+ &DEFAULT_VECTOR,
+#endif
+ NULL
+};
+
+/* When there is an ambiguous match, bfd_check_format_matches puts the
+ names of the matching targets in an array. This variable is the maximum
+ number of entries that the array could possibly need. */
+const size_t _bfd_target_vector_entries = sizeof(bfd_target_vector)/sizeof(*bfd_target_vector);
+
+/* This array maps configuration triplets onto BFD vectors. */
+
+struct targmatch
+{
+ /* The configuration triplet. */
+ const char *triplet;
+ /* The BFD vector. If this is NULL, then the vector is found by
+ searching forward for the next structure with a non NULL vector
+ field. */
+ const bfd_target *vector;
+};
+
+/* targmatch.h is built by Makefile out of config.bfd. */
+static const struct targmatch bfd_target_match[] = {
+#include "targmatch.h"
+ { NULL, NULL }
+};
+
+static const bfd_target *find_target PARAMS ((const char *));
+
+/* Find a target vector, given a name or configuration triplet. */
+
+static const bfd_target *
+find_target (name)
+ const char *name;
+{
+ const bfd_target * const *target;
+ const struct targmatch *match;
+
+ for (target = &bfd_target_vector[0]; *target != NULL; target++)
+ if (strcmp (name, (*target)->name) == 0)
+ return *target;
+
+ /* If we couldn't match on the exact name, try matching on the
+ configuration triplet. FIXME: We should run the triplet through
+ config.sub first, but that is hard. */
+ for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
+ {
+ if (fnmatch (match->triplet, name, 0) == 0)
+ {
+ while (match->vector == NULL)
+ ++match;
+ return match->vector;
+ break;
+ }
+ }
+
+ bfd_set_error (bfd_error_invalid_target);
+ return NULL;
+}
+
+/*
+FUNCTION
+ bfd_set_default_target
+
+SYNOPSIS
+ boolean bfd_set_default_target (const char *name);
+
+DESCRIPTION
+ Set the default target vector to use when recognizing a BFD.
+ This takes the name of the target, which may be a BFD target
+ name or a configuration triplet.
+*/
+
+boolean
+bfd_set_default_target (name)
+ const char *name;
+{
+ const bfd_target *target;
+
+ if (bfd_default_vector[0] != NULL
+ && strcmp (name, bfd_default_vector[0]->name) == 0)
+ return true;
+
+ target = find_target (name);
+ if (target == NULL)
+ return false;
+
+ bfd_default_vector[0] = target;
+ return true;
+}
+
+/*
+FUNCTION
+ bfd_find_target
+
+SYNOPSIS
+ const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd);
+
+DESCRIPTION
+ Return a pointer to the transfer vector for the object target
+ named @var{target_name}. If @var{target_name} is <<NULL>>, choose the
+ one in the environment variable <<GNUTARGET>>; if that is null or not
+ defined, then choose the first entry in the target list.
+ Passing in the string "default" or setting the environment
+ variable to "default" will cause the first entry in the target
+ list to be returned, and "target_defaulted" will be set in the
+ BFD. This causes <<bfd_check_format>> to loop over all the
+ targets to find the one that matches the file being read.
+*/
+
+const bfd_target *
+bfd_find_target (target_name, abfd)
+ const char *target_name;
+ bfd *abfd;
+{
+ const char *targname;
+ const bfd_target *target;
+
+ if (target_name != NULL)
+ targname = target_name;
+ else
+ targname = getenv ("GNUTARGET");
+
+ /* This is safe; the vector cannot be null */
+ if (targname == NULL || strcmp (targname, "default") == 0)
+ {
+ abfd->target_defaulted = true;
+ if (bfd_default_vector[0] != NULL)
+ abfd->xvec = bfd_default_vector[0];
+ else
+ abfd->xvec = bfd_target_vector[0];
+ return abfd->xvec;
+ }
+
+ abfd->target_defaulted = false;
+
+ target = find_target (targname);
+ if (target == NULL)
+ return NULL;
+
+ abfd->xvec = target;
+ return target;
+}
+
+/*
+FUNCTION
+ bfd_target_list
+
+SYNOPSIS
+ const char **bfd_target_list(void);
+
+DESCRIPTION
+ Return a freshly malloced NULL-terminated
+ vector of the names of all the valid BFD targets. Do not
+ modify the names.
+
+*/
+
+const char **
+bfd_target_list ()
+{
+ int vec_length= 0;
+#if defined (HOST_HPPAHPUX) && ! defined (__STDC__)
+ /* The native compiler on the HP9000/700 has a bug which causes it
+ to loop endlessly when compiling this file. This avoids it. */
+ volatile
+#endif
+ const bfd_target * const *target;
+ CONST char **name_list, **name_ptr;
+
+ for (target = &bfd_target_vector[0]; *target != NULL; target++)
+ vec_length++;
+
+ name_ptr = name_list = (CONST char **)
+ bfd_zmalloc ((vec_length + 1) * sizeof (char **));
+
+ if (name_list == NULL)
+ return NULL;
+
+ for (target = &bfd_target_vector[0]; *target != NULL; target++)
+ *(name_ptr++) = (*target)->name;
+
+ return name_list;
+}
diff --git a/bfd/targmatch.sed b/bfd/targmatch.sed
new file mode 100644
index 00000000000..2f40e723f2c
--- /dev/null
+++ b/bfd/targmatch.sed
@@ -0,0 +1,32 @@
+1,/START OF targmatch.h/ d
+/END OF targmatch.h/,$ d
+s/^#if/KEEP #if/
+s/^#endif/KEEP #endif/
+s/^[ ]*#.*$//
+s/^KEEP #/#/
+s/[ ]*\\$//
+t lab1
+ :lab1
+s/[| ][| ]*\([^|() ][^|() ]*\)[ ]*|/{ "\1", NULL },/g
+s/[| ][| ]*\([^|() ][^|() ]*\)[ ]*)/{ "\1",/g
+t lab2
+s/^[ ]*targ_defvec=\([^ ]*\)/#if !defined (SELECT_VECS) || defined (HAVE_\1)/
+t lab3
+s/.*=.*//
+s/;;//
+b
+ :lab2
+H
+d
+ :lab3
+G
+s/\n/%EOL%/g
+s/\(defined (HAVE_\)\([^)]*\)\(.*\)/\1\2\3\
+\&\2 },\
+#endif/
+s/%EOL%/\
+/g
+p
+s/.*//g
+s/\n//g
+h
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
new file mode 100644
index 00000000000..c88fe2dbaf2
--- /dev/null
+++ b/bfd/tekhex.c
@@ -0,0 +1,1065 @@
+/* BFD backend for Extended Tektronix Hex Format objects.
+ Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+SUBSECTION
+ Tektronix Hex Format handling
+
+DESCRIPTION
+
+ Tek Hex records can hold symbols and data, but not
+ relocations. Their main application is communication with
+ devices like PROM programmers and ICE equipment.
+
+ It seems that the sections are descibed as being really big,
+ the example I have says that the text section is 0..ffffffff.
+ BFD would barf with this, many apps would try to alloc 4GB to
+ read in the file.
+
+ Tex Hex may contain many sections, but the data which comes in
+ has no tag saying which section it belongs to, so we create
+ one section for each block of data, called "blknnnn" which we
+ stick all the data into.
+
+ TekHex may come out of order and there is no header, so an
+ initial scan is required to discover the minimum and maximum
+ addresses used to create the vma and size of the sections we
+ create.
+ We read in the data into pages of CHUNK_MASK+1 size and read
+ them out from that whenever we need to.
+
+ Any number of sections may be created for output, we save them
+ up and output them when it's time to close the bfd.
+
+
+ A TekHex record looks like:
+EXAMPLE
+ %<block length><type><checksum><stuff><cr>
+
+DESCRIPTION
+ Where
+ o length
+ is the number of bytes in the record not including the % sign.
+ o type
+ is one of:
+ 3) symbol record
+ 6) data record
+ 8) termination record
+
+
+The data can come out of order, and may be discontigous. This is a
+serial protocol, so big files are unlikely, so we keep a list of 8k chunks
+*/
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libiberty.h"
+
+typedef struct
+ {
+ bfd_vma low;
+ bfd_vma high;
+ } addr_range_type;
+
+typedef struct tekhex_symbol_struct
+ {
+
+ asymbol symbol;
+ struct tekhex_symbol_struct *prev;
+
+ } tekhex_symbol_type;
+
+static const char digs[] = "0123456789ABCDEF";
+
+static char sum_block[256];
+
+#define NOT_HEX 20
+#define NIBBLE(x) hex_value(x)
+#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
+#define TOHEX(d,x) \
+(d)[1] = digs[(x) & 0xf]; \
+(d)[0] = digs[((x)>>4)&0xf];
+#define ISHEX(x) hex_p(x)
+
+static void tekhex_init PARAMS ((void));
+static bfd_vma getvalue PARAMS ((char **));
+static void tekhex_print_symbol
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+static void tekhex_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static asymbol *tekhex_make_empty_symbol PARAMS ((bfd *));
+static int tekhex_sizeof_headers PARAMS ((bfd *, boolean));
+static boolean tekhex_write_object_contents PARAMS ((bfd *));
+static void out PARAMS ((bfd *, int, char *, char *));
+static void writesym PARAMS ((char **, CONST char *));
+static void writevalue PARAMS ((char **, bfd_vma));
+static boolean tekhex_set_section_contents
+ PARAMS ((bfd*, sec_ptr, PTR, file_ptr, bfd_size_type));
+static boolean tekhex_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+static boolean tekhex_get_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static void move_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type, boolean));
+static const bfd_target *tekhex_object_p PARAMS ((bfd *));
+static boolean tekhex_mkobject PARAMS ((bfd *));
+static long tekhex_get_symtab_upper_bound PARAMS ((bfd *));
+static long tekhex_get_symtab PARAMS ((bfd *, asymbol **));
+static void pass_over PARAMS ((bfd *, void (*)(bfd*, int, char *)));
+static void first_phase PARAMS ((bfd *, int, char *));
+static void insert_byte PARAMS ((bfd *, int, bfd_vma));
+static struct data_struct *find_chunk PARAMS ((bfd *, bfd_vma));
+static unsigned int getsym PARAMS ((char *, char **));
+
+/*
+Here's an example
+%3A6C6480004E56FFFC4E717063B0AEFFFC6D0652AEFFFC60F24E5E4E75
+%1B3709T_SEGMENT1108FFFFFFFF
+%2B3AB9T_SEGMENT7Dgcc_compiled$1087hello$c10
+%373829T_SEGMENT80int$t1$r1$$214741080char$t2$r2$0$12710
+%373769T_SEGMENT80long$int$t3$r1$$1080unsigned$int$t4$10
+%373CA9T_SEGMENT80long$unsigned$in1080short$int$t6$r1$10
+%373049T_SEGMENT80long$long$int$t71080short$unsigned$i10
+%373A29T_SEGMENT80long$long$unsign1080signed$char$t10$10
+%373D69T_SEGMENT80unsigned$char$t11080float$t12$r1$4$010
+%373D19T_SEGMENT80double$t13$r1$8$1080long$double$t14$10
+%2734D9T_SEGMENT8Bvoid$t15$151035_main10
+%2F3CA9T_SEGMENT81$1081$1681$1E81$21487main$F110
+%2832F9T_SEGMENT83i$18FFFFFFFC81$1481$214
+%07 8 10 10
+
+explanation:
+%3A6C6480004E56FFFC4E717063B0AEFFFC6D0652AEFFFC60F24E5E4E75
+ ^ ^^ ^ ^-data
+ | || +------ 4 char integer 0x8000
+ | |+-------- checksum
+ | +--------- type 6 (data record)
+ +----------- length 3a chars
+ <---------------------- 3a (58 chars) ------------------->
+
+%1B3709T_SEGMENT1108FFFFFFFF
+ ^ ^^ ^- 8 character integer 0xffffffff
+ | |+- 1 character integer 0
+ | +-- type 1 symbol (section definition)
+ +------------ 9 char symbol T_SEGMENT
+
+%2B3AB9T_SEGMENT7Dgcc_compiled$1087hello$c10
+%373829T_SEGMENT80int$t1$r1$$214741080char$t2$r2$0$12710
+%373769T_SEGMENT80long$int$t3$r1$$1080unsigned$int$t4$10
+%373CA9T_SEGMENT80long$unsigned$in1080short$int$t6$r1$10
+%373049T_SEGMENT80long$long$int$t71080short$unsigned$i10
+%373A29T_SEGMENT80long$long$unsign1080signed$char$t10$10
+%373D69T_SEGMENT80unsigned$char$t11080float$t12$r1$4$010
+%373D19T_SEGMENT80double$t13$r1$8$1080long$double$t14$10
+%2734D9T_SEGMENT8Bvoid$t15$151035_main10
+%2F3CA9T_SEGMENT81$1081$1681$1E81$21487main$F110
+%2832F9T_SEGMENT83i$18FFFFFFFC81$1481$214
+%0781010
+
+Turns into
+sac@thepub$ ./objdump -dx -m m68k f
+
+f: file format tekhex
+-----x--- 9/55728 -134219416 Sep 29 15:13 1995 f
+architecture: UNKNOWN!, flags 0x00000010:
+HAS_SYMS
+start address 0x00000000
+SECTION 0 [D00000000] : size 00020000 vma 00000000 align 2**0
+ ALLOC, LOAD
+SECTION 1 [D00008000] : size 00002001 vma 00008000 align 2**0
+
+SECTION 2 [T_SEGMENT] : size ffffffff vma 00000000 align 2**0
+
+SYMBOL TABLE:
+00000000 g T_SEGMENT gcc_compiled$
+00000000 g T_SEGMENT hello$c
+00000000 g T_SEGMENT int$t1$r1$$21474
+00000000 g T_SEGMENT char$t2$r2$0$127
+00000000 g T_SEGMENT long$int$t3$r1$$
+00000000 g T_SEGMENT unsigned$int$t4$
+00000000 g T_SEGMENT long$unsigned$in
+00000000 g T_SEGMENT short$int$t6$r1$
+00000000 g T_SEGMENT long$long$int$t7
+00000000 g T_SEGMENT short$unsigned$i
+00000000 g T_SEGMENT long$long$unsign
+00000000 g T_SEGMENT signed$char$t10$
+00000000 g T_SEGMENT unsigned$char$t1
+00000000 g T_SEGMENT float$t12$r1$4$0
+00000000 g T_SEGMENT double$t13$r1$8$
+00000000 g T_SEGMENT long$double$t14$
+00000000 g T_SEGMENT void$t15$15
+00000000 g T_SEGMENT _main
+00000000 g T_SEGMENT $
+00000000 g T_SEGMENT $
+00000000 g T_SEGMENT $
+00000010 g T_SEGMENT $
+00000000 g T_SEGMENT main$F1
+fcffffff g T_SEGMENT i$1
+00000000 g T_SEGMENT $
+00000010 g T_SEGMENT $
+
+
+RELOCATION RECORDS FOR [D00000000]: (none)
+
+RELOCATION RECORDS FOR [D00008000]: (none)
+
+RELOCATION RECORDS FOR [T_SEGMENT]: (none)
+
+Disassembly of section D00000000:
+...
+00008000 ($+)7ff0 linkw fp,#-4
+00008004 ($+)7ff4 nop
+00008006 ($+)7ff6 movel #99,d0
+00008008 ($+)7ff8 cmpl fp@(-4),d0
+0000800c ($+)7ffc blts 00008014 ($+)8004
+0000800e ($+)7ffe addql #1,fp@(-4)
+00008012 ($+)8002 bras 00008006 ($+)7ff6
+00008014 ($+)8004 unlk fp
+00008016 ($+)8006 rts
+...
+
+*/
+
+static void
+tekhex_init ()
+{
+ unsigned int i;
+ static boolean inited = false;
+ int val;
+
+ if (inited == false)
+ {
+ inited = true;
+ hex_init ();
+ val = 0;
+ for (i = 0; i < 10; i++)
+ {
+ sum_block[i + '0'] = val++;
+ }
+ for (i = 'A'; i <= 'Z'; i++)
+ {
+ sum_block[i] = val++;
+ }
+ sum_block['$'] = val++;
+ sum_block['%'] = val++;
+ sum_block['.'] = val++;
+ sum_block['_'] = val++;
+ for (i = 'a'; i <= 'z'; i++)
+ {
+ sum_block[i] = val++;
+ }
+ }
+}
+
+/* The maximum number of bytes on a line is FF */
+#define MAXCHUNK 0xff
+/* The number of bytes we fit onto a line on output */
+#define CHUNK 21
+
+/* We cannot output our tekhexords as we see them, we have to glue them
+ together, this is done in this structure : */
+
+struct tekhex_data_list_struct
+{
+ unsigned char *data;
+ bfd_vma where;
+ bfd_size_type size;
+ struct tekhex_data_list_struct *next;
+
+};
+typedef struct tekhex_data_list_struct tekhex_data_list_type;
+
+#define CHUNK_MASK 0x1fff
+
+struct data_struct
+ {
+ char chunk_data[CHUNK_MASK + 1];
+ char chunk_init[CHUNK_MASK + 1];
+ bfd_vma vma;
+ struct data_struct *next;
+ };
+
+typedef struct tekhex_data_struct
+{
+ tekhex_data_list_type *head;
+ unsigned int type;
+ struct tekhex_symbol_struct *symbols;
+ struct data_struct *data;
+} tdata_type;
+
+#define enda(x) (x->vma + x->size)
+
+static bfd_vma
+getvalue (srcp)
+ char **srcp;
+{
+ char *src = *srcp;
+ bfd_vma value = 0;
+ unsigned int len = hex_value(*src++);
+
+ if (len == 0)
+ len = 16;
+ while (len--)
+ {
+ value = value << 4 | hex_value(*src++);
+ }
+ *srcp = src;
+ return value;
+}
+
+static unsigned int
+getsym (dstp, srcp)
+ char *dstp;
+ char **srcp;
+{
+ char *src = *srcp;
+ unsigned int i;
+ unsigned int len = hex_value(*src++);
+
+ if (len == 0)
+ len = 16;
+ for (i = 0; i < len; i++)
+ dstp[i] = src[i];
+ dstp[i] = 0;
+ *srcp = src + i;
+ return len;
+}
+
+static struct data_struct *
+find_chunk (abfd, vma)
+ bfd *abfd;
+ bfd_vma vma;
+{
+ struct data_struct *d = abfd->tdata.tekhex_data->data;
+
+ vma &= ~CHUNK_MASK;
+ while (d && (d->vma) != vma)
+ {
+ d = d->next;
+ }
+ if (!d)
+ {
+ char *sname = bfd_alloc (abfd, 12);
+
+ /* No chunk for this address, so make one up */
+ d = (struct data_struct *)
+ bfd_alloc (abfd, sizeof (struct data_struct));
+
+ if (!sname || !d)
+ return NULL;
+
+ memset (d->chunk_init, 0, CHUNK_MASK + 1);
+ memset (d->chunk_data, 0, CHUNK_MASK + 1);
+ d->next = abfd->tdata.tekhex_data->data;
+ d->vma = vma;
+ abfd->tdata.tekhex_data->data = d;
+ }
+ return d;
+}
+
+static void
+insert_byte (abfd, value, addr)
+ bfd *abfd;
+ int value;
+ bfd_vma addr;
+{
+ /* Find the chunk that this byte needs and put it in */
+ struct data_struct *d = find_chunk (abfd, addr);
+
+ d->chunk_data[addr & CHUNK_MASK] = value;
+ d->chunk_init[addr & CHUNK_MASK] = 1;
+}
+
+/* The first pass is to find the names of all the sections, and see
+ how big the data is */
+static void
+first_phase (abfd, type, src)
+ bfd *abfd;
+ int type;
+ char *src;
+{
+ asection *section = bfd_abs_section_ptr;
+ int len;
+ char sym[17]; /* A symbol can only be 16chars long */
+
+ switch (type)
+ {
+ case '6':
+ /* Data record - read it and store it */
+ {
+ bfd_vma addr = getvalue (&src);
+
+ while (*src)
+ {
+ insert_byte (abfd, HEX (src), addr);
+ src += 2;
+ addr++;
+ }
+ }
+
+ return;
+ case '3':
+ /* Symbol record, read the segment */
+ len = getsym (sym, &src);
+ section = bfd_get_section_by_name (abfd, sym);
+ if (section == (asection *) NULL)
+ {
+ char *n = bfd_alloc (abfd, len + 1);
+
+ if (!n)
+ abort(); /* FIXME */
+ memcpy (n, sym, len + 1);
+ section = bfd_make_section (abfd, n);
+ }
+ while (*src)
+ {
+ switch (*src)
+ {
+ case '1': /* section range */
+ src++;
+ section->vma = getvalue (&src);
+ section->_raw_size = getvalue (&src) - section->vma;
+ section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
+ break;
+ case '0':
+ case '2':
+ case '3':
+ case '4':
+ case '6':
+ case '7':
+ case '8':
+ /* Symbols, add to section */
+ {
+ tekhex_symbol_type *new =
+ (tekhex_symbol_type *) bfd_alloc (abfd,
+ sizeof (tekhex_symbol_type));
+ char type = (*src);
+
+ if (!new)
+ abort(); /* FIXME */
+ new->symbol.the_bfd = abfd;
+ src++;
+ abfd->symcount++;
+ abfd->flags |= HAS_SYMS;
+ new->prev = abfd->tdata.tekhex_data->symbols;
+ abfd->tdata.tekhex_data->symbols = new;
+ len = getsym (sym, &src);
+ new->symbol.name = bfd_alloc (abfd, len + 1);
+ if (!new->symbol.name)
+ abort(); /* FIXME */
+ memcpy ((char *) (new->symbol.name), sym, len + 1);
+ new->symbol.section = section;
+ if (type <= '4')
+ new->symbol.flags = (BSF_GLOBAL | BSF_EXPORT);
+ else
+ new->symbol.flags = BSF_LOCAL;
+ new->symbol.value = getvalue (&src) - section->vma;
+ }
+ }
+ }
+ }
+}
+
+/* Pass over an tekhex, calling one of the above functions on each
+ record. */
+
+static void
+pass_over (abfd, func)
+ bfd *abfd;
+ void (*func) PARAMS ((bfd *, int, char *));
+{
+ unsigned int chars_on_line;
+ boolean eof = false;
+
+ /* To the front of the file */
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ abort ();
+ while (eof == false)
+ {
+ char buffer[MAXCHUNK];
+ char *src = buffer;
+ char type;
+
+ /* Find first '%' */
+ eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
+ while (*src != '%' && !eof)
+ {
+ eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
+ }
+ if (eof)
+ break;
+ src++;
+
+ /* Fetch the type and the length and the checksum */
+ if (bfd_read (src, 1, 5, abfd) != 5)
+ abort (); /* FIXME */
+
+ type = src[2];
+
+ if (!ISHEX (src[0]) || !ISHEX (src[1]))
+ break;
+
+ chars_on_line = HEX (src) - 5; /* Already read five char */
+
+ if (bfd_read (src, 1, chars_on_line, abfd) != chars_on_line)
+ abort (); /* FIXME */
+ src[chars_on_line] = 0; /* put a null at the end */
+
+ func (abfd, type, src);
+ }
+
+}
+
+static long
+tekhex_get_symtab (abfd, table)
+ bfd *abfd;
+ asymbol **table;
+{
+ tekhex_symbol_type *p = abfd->tdata.tekhex_data->symbols;
+ unsigned int c = bfd_get_symcount (abfd);
+
+ table[c] = 0;
+ while (p)
+ {
+ table[--c] = &(p->symbol);
+ p = p->prev;
+ }
+
+ return bfd_get_symcount (abfd);
+}
+
+static long
+tekhex_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ return (abfd->symcount + 1) * (sizeof (struct tekhex_asymbol_struct *));
+
+}
+
+static boolean
+tekhex_mkobject (abfd)
+ bfd *abfd;
+{
+ tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
+
+ if (!tdata)
+ return false;
+ abfd->tdata.tekhex_data = tdata;
+ tdata->type = 1;
+ tdata->head = (tekhex_data_list_type *) NULL;
+ tdata->symbols = (struct tekhex_symbol_struct *) NULL;
+ tdata->data = (struct data_struct *) NULL;
+ return true;
+}
+
+/*
+ Return true if the file looks like it's in TekHex format. Just look
+ for a percent sign and some hex digits */
+
+static const bfd_target *
+tekhex_object_p (abfd)
+ bfd *abfd;
+{
+ char b[4];
+
+ tekhex_init ();
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_read (b, 1, 4, abfd) != 4)
+ return NULL;
+
+ if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
+ return (const bfd_target *) NULL;
+
+ tekhex_mkobject (abfd);
+
+ pass_over (abfd, first_phase);
+ return abfd->xvec;
+}
+
+static void
+move_section_contents (abfd, section, locationp, offset, count, get)
+ bfd *abfd;
+ asection *section;
+ PTR locationp;
+ file_ptr offset;
+ bfd_size_type count;
+ boolean get;
+{
+ bfd_vma addr;
+ char *location = (char *) locationp;
+ bfd_vma prev_number = 1; /* Nothing can have this as a high bit*/
+ struct data_struct *d = (struct data_struct *) NULL;
+
+ for (addr = section->vma; count != 0; count--, addr++)
+ {
+
+ bfd_vma chunk_number = addr & ~CHUNK_MASK; /* Get high bits of address */
+ bfd_vma low_bits = addr & CHUNK_MASK;
+
+ if (chunk_number != prev_number)
+ {
+ /* Different chunk, so move pointer */
+ d = find_chunk (abfd, chunk_number);
+ }
+
+ if (get)
+ {
+ if (d->chunk_init[low_bits])
+ {
+ *location = d->chunk_data[low_bits];
+ }
+ else
+ {
+ *location = 0;
+ }
+ }
+ else
+ {
+ d->chunk_data[low_bits] = *location;
+ d->chunk_init[low_bits] = (*location != 0);
+ }
+
+ location++;
+
+ }
+
+}
+
+static boolean
+tekhex_get_section_contents (abfd, section, locationp, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR locationp;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (section->flags & (SEC_LOAD | SEC_ALLOC))
+ {
+ move_section_contents (abfd, section, locationp, offset, count, true);
+ return true;
+ }
+ else
+ return false;
+}
+
+static boolean
+tekhex_set_arch_mach (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
+{
+ return bfd_default_set_arch_mach (abfd, arch, machine);
+}
+
+/* we have to save up all the Tekhexords for a splurge before output,
+ */
+
+static boolean
+tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do)
+ bfd *abfd;
+ sec_ptr section;
+ PTR locationp;
+ file_ptr offset;
+ bfd_size_type bytes_to_do;
+{
+
+ if (abfd->output_has_begun == false)
+ {
+ /* The first time around, allocate enough sections to hold all the chunks */
+ asection *s = abfd->sections;
+ bfd_vma vma;
+
+ for (s = abfd->sections; s; s = s->next)
+ {
+ if (s->flags & SEC_LOAD)
+ {
+ for (vma = s->vma & ~CHUNK_MASK;
+ vma < s->vma + s->_raw_size;
+ vma += CHUNK_MASK)
+ find_chunk (abfd, vma);
+ }
+ }
+
+ }
+ if (section->flags & (SEC_LOAD | SEC_ALLOC))
+ {
+ move_section_contents (abfd, section, locationp, offset, bytes_to_do, false);
+ return true;
+ }
+ else
+ return false;
+
+}
+
+static void
+writevalue (dst, value)
+ char **dst;
+ bfd_vma value;
+{
+ char *p = *dst;
+ int len;
+ int shift;
+
+ for (len = 8, shift = 28; shift; shift -= 4, len--)
+ {
+ if ((value >> shift) & 0xf)
+ {
+ *p++ = len + '0';
+ while (len)
+ {
+ *p++ = digs[(value >> shift) & 0xf];
+ shift -= 4;
+ len--;
+ }
+ *dst = p;
+ return;
+
+ }
+ }
+ *p++ = '1';
+ *p++ = '0';
+ *dst = p;
+}
+
+static void
+writesym (dst, sym)
+ char **dst;
+ CONST char *sym;
+{
+ char *p = *dst;
+ int len = (sym ? strlen (sym) : 0);
+
+ if (len >= 16)
+ {
+ *p++ = '0';
+ len = 16;
+ }
+
+ else
+ {
+ if (len == 0)
+ {
+ *p++ = '1';
+ sym = "$";
+ len = 1;
+ }
+ else
+ {
+ *p++ = digs[len];
+ }
+ }
+
+ while (len--)
+ {
+ *p++ = *sym++;
+ }
+ *dst = p;
+}
+
+static void
+out (abfd, type, start, end)
+ bfd *abfd;
+ int type;
+ char *start;
+ char *end;
+{
+ int sum = 0;
+ char *s;
+ char front[6];
+ bfd_size_type wrlen;
+
+ front[0] = '%';
+ TOHEX (front + 1, end - start + 5);
+ front[3] = type;
+
+ for (s = start; s < end; s++)
+ {
+ sum += sum_block[(unsigned char) *s];
+ }
+
+ sum += sum_block[(unsigned char) front[1]]; /* length */
+ sum += sum_block[(unsigned char) front[2]];
+ sum += sum_block[(unsigned char) front[3]]; /* type */
+ TOHEX (front + 4, sum);
+ if (bfd_write (front, 1, 6, abfd) != 6)
+ abort ();
+ end[0] = '\n';
+ wrlen = end - start + 1;
+ if (bfd_write (start, 1, wrlen, abfd) != wrlen)
+ abort ();
+}
+
+static boolean
+tekhex_write_object_contents (abfd)
+ bfd *abfd;
+{
+ int bytes_written;
+ char buffer[100];
+ asymbol **p;
+ asection *s;
+ struct data_struct *d;
+
+ tekhex_init ();
+
+ bytes_written = 0;
+
+ /* And the raw data */
+ for (d = abfd->tdata.tekhex_data->data;
+ d != (struct data_struct *) NULL;
+ d = d->next)
+ {
+ int low;
+
+ CONST int span = 32;
+ int addr;
+
+ /* Write it in blocks of 32 bytes */
+
+ for (addr = 0; addr < CHUNK_MASK + 1; addr += span)
+ {
+ int need = 0;
+
+ /* Check to see if necessary */
+ for (low = 0; !need && low < span; low++)
+ {
+ if (d->chunk_init[addr + low])
+ need = 1;
+ }
+ if (need)
+ {
+ char *dst = buffer;
+
+ writevalue (&dst, addr + d->vma);
+ for (low = 0; low < span; low++)
+ {
+ TOHEX (dst, d->chunk_data[addr + low]);
+ dst += 2;
+ }
+ out (abfd, '6', buffer, dst);
+ }
+ }
+ }
+ /* write all the section headers for the sections */
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ {
+ char *dst = buffer;
+
+ writesym (&dst, s->name);
+ *dst++ = '1';
+ writevalue (&dst, s->vma);
+ writevalue (&dst, s->vma + s->_raw_size);
+ out (abfd, '3', buffer, dst);
+ }
+
+ /* And the symbols */
+ if (abfd->outsymbols)
+ {
+ for (p = abfd->outsymbols; *p; p++)
+ {
+ int section_code = bfd_decode_symclass (*p);
+
+ if (section_code != '?')
+ { /* do not include debug symbols */
+ asymbol *s = *p;
+ char *dst = buffer;
+
+ writesym (&dst, s->section->name);
+
+ switch (section_code)
+ {
+ case 'A':
+ *dst++ = '2';
+ break;
+ case 'a':
+ *dst++ = '6';
+ break;
+ case 'D':
+ case 'B':
+ case 'O':
+ *dst++ = '4';
+ break;
+ case 'd':
+ case 'b':
+ case 'o':
+ *dst++ = '8';
+ break;
+ case 'T':
+ *dst++ = '3';
+ break;
+ case 't':
+ *dst++ = '7';
+ break;
+ case 'C':
+ case 'U':
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+
+ writesym (&dst, s->name);
+ writevalue (&dst, s->value + s->section->vma);
+ out (abfd, '3', buffer, dst);
+ }
+ }
+ }
+
+ /* And the terminator */
+ if (bfd_write ("%0781010\n", 1, 9, abfd) != 9)
+ abort ();
+ return true;
+}
+
+static int
+tekhex_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+
+{
+ return 0;
+}
+
+static asymbol *
+tekhex_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ tekhex_symbol_type *new =
+ (tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));
+
+ if (!new)
+ return NULL;
+ new->symbol.the_bfd = abfd;
+ new->prev = (struct tekhex_symbol_struct *) NULL;
+ return &(new->symbol);
+}
+
+static void
+tekhex_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+static void
+tekhex_print_symbol (ignore_abfd, filep, symbol, how)
+ bfd *ignore_abfd;
+ PTR filep;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) filep;
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+ break;
+
+ case bfd_print_symbol_all:
+ {
+ CONST char *section_name = symbol->section->name;
+
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+
+ fprintf (file, " %-5s %s",
+ section_name,
+ symbol->name);
+ }
+ }
+}
+
+#define tekhex_close_and_cleanup _bfd_generic_close_and_cleanup
+#define tekhex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define tekhex_new_section_hook _bfd_generic_new_section_hook
+
+#define tekhex_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define tekhex_get_lineno _bfd_nosymbols_get_lineno
+#define tekhex_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define tekhex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define tekhex_read_minisymbols _bfd_generic_read_minisymbols
+#define tekhex_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define tekhex_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define tekhex_bfd_relax_section bfd_generic_relax_section
+#define tekhex_bfd_gc_sections bfd_generic_gc_sections
+#define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define tekhex_bfd_final_link _bfd_generic_final_link
+#define tekhex_bfd_link_split_section _bfd_generic_link_split_section
+
+#define tekhex_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+const bfd_target tekhex_vec =
+{
+ "tekhex", /* name */
+ bfd_target_tekhex_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (EXEC_P | /* object flags */
+ HAS_SYMS | HAS_LINENO | HAS_DEBUG | HAS_RELOC | HAS_LOCALS |
+ WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ tekhex_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ tekhex_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ tekhex_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (tekhex),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (tekhex),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (tekhex),
+ BFD_JUMP_TABLE_LINK (tekhex),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/trad-core.c b/bfd/trad-core.c
new file mode 100644
index 00000000000..21d920b0e87
--- /dev/null
+++ b/bfd/trad-core.c
@@ -0,0 +1,316 @@
+/* BFD back end for traditional Unix core files (U-area and raw sections)
+ Copyright 1988, 89, 91, 92, 93, 94, 95, 96, 1998
+ Free Software Foundation, Inc.
+ Written by John Gilmore of Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h" /* BFD a.out internal data structures */
+
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <signal.h>
+
+#include <sys/user.h> /* After a.out.h */
+
+#ifdef TRAD_HEADER
+#include TRAD_HEADER
+#endif
+
+ struct trad_core_struct
+ {
+ asection *data_section;
+ asection *stack_section;
+ asection *reg_section;
+ struct user u;
+ };
+
+#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
+#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
+#define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
+#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
+
+/* forward declarations */
+
+const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd));
+char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
+int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
+boolean trad_unix_core_file_matches_executable_p
+ PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+static void swap_abort PARAMS ((void));
+
+/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
+
+/* ARGSUSED */
+const bfd_target *
+trad_unix_core_file_p (abfd)
+ bfd *abfd;
+
+{
+ int val;
+ struct user u;
+ struct trad_core_struct *rawptr;
+
+#ifdef TRAD_CORE_USER_OFFSET
+ /* If defined, this macro is the file position of the user struct. */
+ if (bfd_seek (abfd, TRAD_CORE_USER_OFFSET, SEEK_SET) != 0)
+ return 0;
+#endif
+
+ val = bfd_read ((void *)&u, 1, sizeof u, abfd);
+ if (val != sizeof u)
+ {
+ /* Too small to be a core file */
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* Sanity check perhaps??? */
+ if (u.u_dsize > 0x1000000) /* Remember, it's in pages... */
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ if (u.u_ssize > 0x1000000)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* Check that the size claimed is no greater than the file size. */
+ {
+ FILE *stream = bfd_cache_lookup (abfd);
+ struct stat statbuf;
+ if (stream == NULL)
+ return 0;
+ if (fstat (fileno (stream), &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return 0;
+ }
+ if (NBPG * (UPAGES + u.u_dsize
+#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
+ - u.u_tsize
+#endif
+ + u.u_ssize) > statbuf.st_size)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+#ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE
+ if (NBPG * (UPAGES + u.u_dsize + u.u_ssize)
+#ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED
+ /* Some systems write the file too big. */
+ + TRAD_CORE_EXTRA_SIZE_ALLOWED
+#endif
+ < statbuf.st_size)
+ {
+ /* The file is too big. Maybe it's not a core file
+ or we otherwise have bad values for u_dsize and u_ssize). */
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+#endif
+ }
+
+ /* OK, we believe you. You're a core file (sure, sure). */
+
+ /* Allocate both the upage and the struct core_data at once, so
+ a single free() will free them both. */
+ rawptr = (struct trad_core_struct *)
+ bfd_zmalloc (sizeof (struct trad_core_struct));
+ if (rawptr == NULL)
+ return 0;
+
+ abfd->tdata.trad_core_data = rawptr;
+
+ rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */
+
+ /* Create the sections. This is raunchy, but bfd_close wants to free
+ them separately. */
+
+ core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_stacksec (abfd) == NULL)
+ return NULL;
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_datasec (abfd) == NULL)
+ return NULL;
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_regsec (abfd) == NULL)
+ return NULL;
+
+ core_stacksec (abfd)->name = ".stack";
+ core_datasec (abfd)->name = ".data";
+ core_regsec (abfd)->name = ".reg";
+
+ core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+ core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
+
+ core_datasec (abfd)->_raw_size = NBPG * u.u_dsize
+#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
+ - NBPG * u.u_tsize
+#endif
+ ;
+ core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize;
+ core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */
+
+ /* What a hack... we'd like to steal it from the exec file,
+ since the upage does not seem to provide it. FIXME. */
+#ifdef HOST_DATA_START_ADDR
+ core_datasec (abfd)->vma = HOST_DATA_START_ADDR;
+#else
+ core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize);
+#endif
+
+#ifdef HOST_STACK_START_ADDR
+ core_stacksec (abfd)->vma = HOST_STACK_START_ADDR;
+#else
+ core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);
+#endif
+
+ /* This is tricky. As the "register section", we give them the entire
+ upage and stack. u.u_ar0 points to where "register 0" is stored.
+ There are two tricks with this, though. One is that the rest of the
+ registers might be at positive or negative (or both) displacements
+ from *u_ar0. The other is that u_ar0 is sometimes an absolute address
+ in kernel memory, and on other systems it is an offset from the beginning
+ of the `struct user'.
+
+ As a practical matter, we don't know where the registers actually are,
+ so we have to pass the whole area to GDB. We encode the value of u_ar0
+ by setting the .regs section up so that its virtual memory address
+ 0 is at the place pointed to by u_ar0 (by setting the vma of the start
+ of the section to -u_ar0). GDB uses this info to locate the regs,
+ using minor trickery to get around the offset-or-absolute-addr problem. */
+ core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;
+
+ core_datasec (abfd)->filepos = NBPG * UPAGES;
+ core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize
+#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
+ - NBPG * u.u_tsize
+#endif
+ ;
+ core_regsec (abfd)->filepos = 0; /* Register segment is the upage */
+
+ /* Align to word at least */
+ core_stacksec (abfd)->alignment_power = 2;
+ core_datasec (abfd)->alignment_power = 2;
+ core_regsec (abfd)->alignment_power = 2;
+
+ abfd->sections = core_stacksec (abfd);
+ core_stacksec (abfd)->next = core_datasec (abfd);
+ core_datasec (abfd)->next = core_regsec (abfd);
+ abfd->section_count = 3;
+
+ return abfd->xvec;
+}
+
+char *
+trad_unix_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+#ifndef NO_CORE_COMMAND
+ char *com = abfd->tdata.trad_core_data->u.u_comm;
+ if (*com)
+ return com;
+ else
+#endif
+ return 0;
+}
+
+/* ARGSUSED */
+int
+trad_unix_core_file_failing_signal (ignore_abfd)
+ bfd *ignore_abfd;
+{
+#ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
+ return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd);
+#else
+ return -1; /* FIXME, where is it? */
+#endif
+}
+
+/* ARGSUSED */
+boolean
+trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd, *exec_bfd;
+{
+ return true; /* FIXME, We have no way of telling at this point */
+}
+
+/* If somebody calls any byte-swapping routines, shoot them. */
+static void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
+#define NO_SIGNED_GET \
+ ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
+
+const bfd_target trad_core_vec =
+ {
+ "trad-core",
+ bfd_target_unknown_flavour,
+ BFD_ENDIAN_UNKNOWN, /* target byte order */
+ BFD_ENDIAN_UNKNOWN, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* symbol prefix */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
+ NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
+
+ { /* bfd_check_format */
+ _bfd_dummy_target, /* unknown format */
+ _bfd_dummy_target, /* object file */
+ _bfd_dummy_target, /* archive */
+ trad_unix_core_file_p /* a core file */
+ },
+ { /* bfd_set_format */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+ { /* bfd_write_contents */
+ bfd_false, bfd_false,
+ bfd_false, bfd_false
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (trad_unix),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_generic),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0 /* backend_data */
+};
diff --git a/bfd/vaxnetbsd.c b/bfd/vaxnetbsd.c
new file mode 100644
index 00000000000..e137d093c6f
--- /dev/null
+++ b/bfd/vaxnetbsd.c
@@ -0,0 +1,33 @@
+/* BFD back-end for NetBSD/VAX a.out-ish binaries.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define BYTES_IN_WORD 4
+#undef TARGET_IS_BIG_ENDIAN_P
+
+#define TARGET_PAGE_SIZE 1024
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+#define DEFAULT_ARCH bfd_arch_vax
+#define DEFAULT_MID M_VAX_NETBSD
+
+#define MY(OP) CAT(vaxnetbsd_,OP)
+/* This needs to start with a.out so GDB knows it is an a.out variant. */
+#define TARGETNAME "a.out-vax-netbsd"
+
+#include "netbsd.h"
diff --git a/bfd/versados.c b/bfd/versados.c
new file mode 100644
index 00000000000..0dcd1080694
--- /dev/null
+++ b/bfd/versados.c
@@ -0,0 +1,923 @@
+/* BFD back-end for VERSAdos-E objects.
+ Copyright 1995, 96, 1997 Free Software Foundation, Inc.
+ Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
+
+ Versados is a Motorola trademark.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+ SUBSECTION
+ VERSAdos-E relocateable object file format
+
+ DESCRIPTION
+
+ This module supports reading of VERSAdos relocateable
+ object files.
+
+ A VERSAdos file looks like contains
+
+ o Indentification Record
+ o External Symbol Definition Record
+ o Object Text Recrod
+ o End Record
+
+
+ */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libiberty.h"
+
+
+static boolean versados_mkobject PARAMS ((bfd *));
+static boolean versados_scan PARAMS ((bfd *));
+static const bfd_target *versados_object_p PARAMS ((bfd *));
+
+
+#define VHEADER '1'
+#define VESTDEF '2'
+#define VOTR '3'
+#define VEND '4'
+
+
+#define ES_BASE 17 /* first symbol has esdid 17 */
+
+/* Per file target dependent information */
+
+/* one for each section */
+struct esdid
+ {
+ asection *section; /* ptr to bfd version */
+ unsigned char *contents; /* used to build image */
+ int pc;
+ int relocs; /* reloc count, valid end of pass 1 */
+ int donerel; /* have relocs been translated */
+ };
+
+typedef struct versados_data_struct
+ {
+ int es_done; /* count of symbol index, starts at ES_BASE */
+ asymbol *symbols; /* pointer to local symbols */
+ char *strings; /* strings of all the above */
+ int stringlen; /* len of string table (valid end of pass1) */
+ int nsecsyms; /* number of sections */
+
+ int ndefs; /* number of exported symbols (they dont get esdids) */
+ int nrefs; /* number of imported symbols (valid end of pass1) */
+
+ int ref_idx; /* current processed value of the above */
+ int def_idx;
+
+ int pass_2_done;
+
+ struct esdid e[16]; /* per section info */
+ int alert; /* to see if we're trampling */
+ asymbol *rest[256 - 16]; /* per symbol info */
+
+ }
+tdata_type;
+
+#define VDATA(abfd) (abfd->tdata.versados_data)
+#define EDATA(abfd, n) (abfd->tdata.versados_data->e[n])
+#define RDATA(abfd, n) (abfd->tdata.versados_data->rest[n])
+
+struct ext_otr
+ {
+ unsigned char size;
+ char type;
+ unsigned char map[4];
+ unsigned char esdid;
+ unsigned char data[200];
+ };
+
+struct ext_vheader
+ {
+ unsigned char size;
+ char type; /* record type */
+ char name[10]; /* module name */
+ char rev; /* module rev number */
+ char lang;
+ char vol[4];
+ char user[2];
+ char cat[8];
+ char fname[8];
+ char ext[2];
+ char time[3];
+ char date[3];
+ char rest[211];
+ };
+
+struct ext_esd
+ {
+ unsigned char size;
+ char type;
+ unsigned char esd_entries[1];
+ };
+#define ESD_ABS 0
+#define ESD_COMMON 1
+#define ESD_STD_REL_SEC 2
+#define ESD_SHRT_REL_SEC 3
+#define ESD_XDEF_IN_SEC 4
+#define ESD_XREF_SYM 7
+#define ESD_XREF_SEC 6
+#define ESD_XDEF_IN_ABS 5
+union ext_any
+ {
+ unsigned char size;
+ struct ext_vheader header;
+ struct ext_esd esd;
+ struct ext_otr otr;
+ };
+
+/* Initialize by filling in the hex conversion array. */
+
+
+
+
+
+/* Set up the tdata information. */
+
+static boolean
+versados_mkobject (abfd)
+ bfd *abfd;
+{
+ if (abfd->tdata.versados_data == NULL)
+ {
+ tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
+ if (tdata == NULL)
+ return false;
+ abfd->tdata.versados_data = tdata;
+ tdata->symbols = NULL;
+ VDATA (abfd)->alert = 0x12345678;
+ }
+
+ bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0);
+ return true;
+}
+
+
+/* Report a problem in an S record file. FIXME: This probably should
+ not call fprintf, but we really do need some mechanism for printing
+ error messages. */
+
+
+
+static asymbol *
+versados_new_symbol (abfd, snum, name, val, sec)
+ bfd *abfd;
+ int snum;
+ const char *name;
+ bfd_vma val;
+ asection *sec;
+{
+ asymbol *n = VDATA (abfd)->symbols + snum;
+ n->name = name;
+ n->value = val;
+ n->section = sec;
+ n->the_bfd = abfd;
+ n->flags = 0;
+ return n;
+}
+
+
+static int
+get_record (abfd, ptr)
+ bfd *abfd;
+ union ext_any *ptr;
+{
+ bfd_read (&ptr->size, 1, 1, abfd);
+ if (bfd_read ((char *) ptr + 1, 1, ptr->size, abfd) != ptr->size)
+ return 0;
+ return 1;
+}
+
+int
+get_4 (pp)
+ unsigned char **pp;
+{
+ unsigned char *p = *pp;
+ *pp += 4;
+ return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3] << 0);
+}
+
+void
+get_10 (pp, name)
+ unsigned char **pp;
+ char *name;
+{
+ char *p = (char *) *pp;
+ int len = 10;
+ *pp += len;
+ while (*p != ' '
+ && len)
+ {
+ *name++ = *p++;
+ len--;
+ }
+ *name = 0;
+}
+
+static char *
+new_symbol_string (abfd, name)
+ bfd *abfd;
+ char *name;
+{
+ char *n = VDATA (abfd)->strings;
+ strcpy (VDATA (abfd)->strings, name);
+ VDATA (abfd)->strings += strlen (VDATA (abfd)->strings) + 1;
+ return n;
+}
+
+
+static void
+process_esd (abfd, esd, pass)
+ bfd *abfd;
+ struct ext_esd *esd;
+ int pass;
+{
+ /* Read through the ext def for the est entries */
+ int togo = esd->size - 2;
+ bfd_vma size;
+ bfd_vma start;
+ asection *sec;
+ char name[11];
+ unsigned char *ptr = esd->esd_entries;
+ unsigned char *end = ptr + togo;
+ while (ptr < end)
+ {
+ int scn = *ptr & 0xf;
+ int typ = (*ptr >> 4) & 0xf;
+
+ /* Declare this section */
+ sprintf (name, "%d", scn);
+ sec = bfd_make_section_old_way (abfd, strdup (name));
+ sec->target_index = scn;
+ EDATA (abfd, scn).section = sec;
+ ptr++;
+ switch (typ)
+ {
+ default:
+ abort ();
+ case ESD_XREF_SEC:
+ case ESD_XREF_SYM:
+ {
+ int snum = VDATA (abfd)->ref_idx++;
+ get_10 (&ptr, name);
+ if (pass == 1)
+ {
+ VDATA (abfd)->stringlen += strlen (name) + 1;
+ }
+ else
+ {
+ int esidx;
+ asymbol *s;
+ char *n = new_symbol_string (abfd, name);
+ s = versados_new_symbol (abfd, snum, n, 0,
+ &bfd_und_section, scn);
+ esidx = VDATA (abfd)->es_done++;
+ RDATA (abfd, esidx - ES_BASE) = s;
+ }
+ }
+ break;
+
+
+ case ESD_ABS:
+ size = get_4 (&ptr);
+ start = get_4 (&ptr);
+ break;
+ case ESD_STD_REL_SEC:
+ case ESD_SHRT_REL_SEC:
+ {
+ sec->_raw_size = get_4 (&ptr);
+ sec->flags |= SEC_ALLOC;
+ }
+ break;
+ case ESD_XDEF_IN_ABS:
+ sec = (asection *) & bfd_abs_section;
+ case ESD_XDEF_IN_SEC:
+ {
+ int snum = VDATA (abfd)->def_idx++;
+ long val;
+ get_10 (&ptr, name);
+ val = get_4 (&ptr);
+ if (pass == 1)
+ {
+ /* Just remember the symbol */
+ VDATA (abfd)->stringlen += strlen (name) + 1;
+ }
+ else
+ {
+ asymbol *s;
+ char *n = new_symbol_string (abfd, name);
+ s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n, val, sec, scn);
+ s->flags |= BSF_GLOBAL;
+ }
+ }
+ break;
+ }
+ }
+}
+
+#define R_RELWORD 1
+#define R_RELLONG 2
+#define R_RELWORD_NEG 3
+#define R_RELLONG_NEG 4
+
+reloc_howto_type versados_howto_table[] =
+{
+ HOWTO (R_RELWORD, 0, 1, 16, false,
+ 0, complain_overflow_dont, 0,
+ "+v16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_RELLONG, 0, 2, 32, false,
+ 0, complain_overflow_dont, 0,
+ "+v32", true, 0xffffffff, 0xffffffff, false),
+
+ HOWTO (R_RELWORD_NEG, 0, -1, 16, false,
+ 0, complain_overflow_dont, 0,
+ "-v16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_RELLONG_NEG, 0, -2, 32, false,
+ 0, complain_overflow_dont, 0,
+ "-v32", true, 0xffffffff, 0xffffffff, false),
+};
+
+
+static int
+get_offset (len, ptr)
+ int len;
+ unsigned char *ptr;
+{
+ int val = 0;
+ if (len)
+ {
+ int i;
+ val = *ptr++;
+ if (val & 0x80)
+ val |= ~0xff;
+ for (i = 1; i < len; i++)
+ val = (val << 8) | *ptr++;
+ }
+
+ return val;
+}
+
+static void
+process_otr (abfd, otr, pass)
+ bfd *abfd;
+ struct ext_otr *otr;
+ int pass;
+{
+ unsigned long shift;
+ unsigned char *srcp = otr->data;
+ unsigned char *endp = (unsigned char *) otr + otr->size;
+ unsigned int bits = (otr->map[0] << 24)
+ | (otr->map[1] << 16)
+ | (otr->map[2] << 8)
+ | (otr->map[3] << 0);
+
+ struct esdid *esdid = &EDATA (abfd, otr->esdid - 1);
+ unsigned char *contents = esdid->contents;
+ int need_contents = 0;
+ unsigned int dst_idx = esdid->pc;
+
+ for (shift = (1 << 31); shift && srcp < endp; shift >>= 1)
+ {
+ if (bits & shift)
+ {
+ int flag = *srcp++;
+ int esdids = (flag >> 5) & 0x7;
+ int sizeinwords = ((flag >> 3) & 1) ? 2 : 1;
+ int offsetlen = flag & 0x7;
+ int j;
+
+
+ if (esdids == 0)
+ {
+ /* A zero esdid means the new pc is the offset given */
+ dst_idx += get_offset (offsetlen, srcp);
+ srcp += offsetlen;
+ }
+ else
+ {
+ int val = get_offset (offsetlen, srcp + esdids);
+ if (pass == 1)
+ need_contents = 1;
+ else
+ for (j = 0; j < sizeinwords * 2; j++)
+ {
+ contents[dst_idx + (sizeinwords * 2) - j - 1] = val;
+ val >>= 8;
+ }
+
+ for (j = 0; j < esdids; j++)
+ {
+ int esdid = *srcp++;
+
+ if (esdid)
+ {
+ int rn = EDATA (abfd, otr->esdid - 1).relocs++;
+ if (pass == 1)
+ {
+ /* this is the first pass over the data,
+ just remember that we need a reloc */
+ }
+ else
+ {
+ arelent *n =
+ EDATA (abfd, otr->esdid - 1).section->relocation + rn;
+ n->address = dst_idx;
+
+ n->sym_ptr_ptr = (asymbol **) esdid;
+ n->addend = 0;
+ n->howto = versados_howto_table + ((j & 1) * 2) + (sizeinwords - 1);
+ }
+ }
+ }
+ srcp += offsetlen;
+ dst_idx += sizeinwords * 2;
+ }
+ }
+ else
+ {
+ need_contents = 1;
+ if (dst_idx < esdid->section->_raw_size)
+ if (pass == 2)
+ {
+ /* absolute code, comes in 16 bit lumps */
+ contents[dst_idx] = srcp[0];
+ contents[dst_idx + 1] = srcp[1];
+ }
+ dst_idx += 2;
+ srcp += 2;
+ }
+ }
+ EDATA (abfd, otr->esdid - 1).pc = dst_idx;
+
+ if (!contents && need_contents)
+ esdid->contents = (unsigned char *) bfd_alloc (abfd, esdid->section->_raw_size);
+
+
+}
+
+static boolean
+versados_scan (abfd)
+ bfd *abfd;
+{
+ int loop = 1;
+ int i;
+ int j;
+ int nsecs = 0;
+
+ VDATA (abfd)->nrefs = 0;
+ VDATA (abfd)->ndefs = 0;
+ VDATA (abfd)->ref_idx = 0;
+ VDATA (abfd)->def_idx = 0;
+
+ while (loop)
+ {
+ union ext_any any;
+ if (!get_record (abfd, &any))
+ return true;
+ switch (any.header.type)
+ {
+ case VHEADER:
+ break;
+ case VEND:
+ loop = 0;
+ break;
+ case VESTDEF:
+ process_esd (abfd, &any.esd, 1);
+ break;
+ case VOTR:
+ process_otr (abfd, &any.otr, 1);
+ break;
+ }
+ }
+
+ /* Now allocate space for the relocs and sections */
+
+ VDATA (abfd)->nrefs = VDATA (abfd)->ref_idx;
+ VDATA (abfd)->ndefs = VDATA (abfd)->def_idx;
+ VDATA (abfd)->ref_idx = 0;
+ VDATA (abfd)->def_idx = 0;
+
+ abfd->symcount = VDATA (abfd)->nrefs + VDATA (abfd)->ndefs;
+
+ for (i = 0; i < 16; i++)
+ {
+ struct esdid *esdid = &EDATA (abfd, i);
+ if (esdid->section)
+ {
+ esdid->section->relocation
+ = (arelent *) bfd_alloc (abfd, sizeof (arelent) * esdid->relocs);
+
+ esdid->pc = 0;
+
+ if (esdid->contents)
+ esdid->section->flags |= SEC_HAS_CONTENTS | SEC_LOAD;
+
+ esdid->section->reloc_count = esdid->relocs;
+ if (esdid->relocs)
+ esdid->section->flags |= SEC_RELOC;
+
+ esdid->relocs = 0;
+
+ /* Add an entry into the symbol table for it */
+ nsecs++;
+ VDATA (abfd)->stringlen += strlen (esdid->section->name) + 1;
+ }
+ }
+
+ abfd->symcount += nsecs;
+
+ VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd,
+ sizeof (asymbol) * (abfd->symcount));
+
+ VDATA (abfd)->strings = bfd_alloc (abfd, VDATA (abfd)->stringlen);
+
+ if ((VDATA (abfd)->symbols == NULL && abfd->symcount > 0)
+ || (VDATA (abfd)->strings == NULL && VDATA (abfd)->stringlen > 0))
+ return false;
+
+ /* Actually fill in the section symbols,
+ we stick them at the end of the table */
+
+ for (j = VDATA (abfd)->nrefs + VDATA (abfd)->ndefs, i = 0; i < 16; i++)
+ {
+ struct esdid *esdid = &EDATA (abfd, i);
+ asection *sec = esdid->section;
+ if (sec)
+ {
+ asymbol *s = VDATA (abfd)->symbols + j;
+ s->name = new_symbol_string (abfd, sec->name);
+ s->section = sec;
+ s->flags = BSF_LOCAL;
+ s->value = 0;
+ s->the_bfd = abfd;
+ j++;
+ }
+ }
+ if (abfd->symcount)
+ abfd->flags |= HAS_SYMS;
+
+ /* Set this to nsecs - since we've already planted the section
+ symbols */
+ VDATA (abfd)->nsecsyms = nsecs;
+
+ VDATA (abfd)->ref_idx = 0;
+
+ return 1;
+}
+
+
+
+/* Check whether an existing file is a versados file. */
+
+static const bfd_target *
+versados_object_p (abfd)
+ bfd *abfd;
+{
+ struct ext_vheader ext;
+ unsigned char len;
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return NULL;
+
+ if (bfd_read (&len, 1, 1, abfd) != 1)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (bfd_read (&ext.type, 1, len, abfd) != len)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* We guess that the language field will never be larger than 10.
+ In sample files, it is always either 0 or 1. Checking for this
+ prevents confusion with Intel Hex files. */
+ if (ext.type != VHEADER
+ || ext.lang > 10)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ /* OK, looks like a record, build the tdata and read in. */
+
+ if (!versados_mkobject (abfd)
+ || !versados_scan (abfd))
+ return NULL;
+
+ return abfd->xvec;
+}
+
+
+static boolean
+versados_pass_2 (abfd)
+ bfd *abfd;
+{
+ union ext_any any;
+
+ if (VDATA (abfd)->pass_2_done)
+ return 1;
+
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ return 0;
+
+ VDATA (abfd)->es_done = ES_BASE;
+
+
+ /* read records till we get to where we want to be */
+
+ while (1)
+ {
+ get_record (abfd, &any);
+ switch (any.header.type)
+ {
+ case VEND:
+ VDATA (abfd)->pass_2_done = 1;
+ return 1;
+ case VESTDEF:
+ process_esd (abfd, &any.esd, 2);
+ break;
+ case VOTR:
+ process_otr (abfd, &any.otr, 2);
+ break;
+ }
+ }
+}
+
+static boolean
+versados_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (!versados_pass_2 (abfd))
+ return false;
+
+ memcpy (location,
+ EDATA (abfd, section->target_index).contents + offset,
+ (size_t) count);
+
+ return true;
+}
+
+#define versados_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+static boolean
+versados_set_section_contents (abfd, section, location, offset, bytes_to_do)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type bytes_to_do;
+{
+ return false;
+}
+
+
+/*ARGSUSED */
+static int
+versados_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+static asymbol *
+versados_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new)
+ new->the_bfd = abfd;
+ return new;
+}
+
+/* Return the amount of memory needed to read the symbol table. */
+
+static long
+versados_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
+}
+
+/* Return the symbol table. */
+
+static long
+versados_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ unsigned int symcount = bfd_get_symcount (abfd);
+ unsigned int i;
+ asymbol *s;
+
+ versados_pass_2 (abfd);
+
+ for (i = 0, s = VDATA (abfd)->symbols;
+ i < symcount;
+ s++, i++)
+ {
+ *alocation++ = s;
+ }
+
+ *alocation = NULL;
+
+ return symcount;
+}
+
+/*ARGSUSED */
+void
+versados_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+/*ARGSUSED */
+void
+versados_print_symbol (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ default:
+ bfd_print_symbol_vandf ((PTR) file, symbol);
+ fprintf (file, " %-5s %s",
+ symbol->section->name,
+ symbol->name);
+
+ }
+}
+
+long
+versados_get_reloc_upper_bound (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
+{
+ return (asect->reloc_count + 1) * sizeof (arelent *);
+}
+
+
+long
+versados_canonicalize_reloc (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ unsigned int count;
+ arelent *src;
+
+ versados_pass_2 (abfd);
+ src = section->relocation;
+ if (!EDATA (abfd, section->target_index).donerel)
+ {
+ EDATA (abfd, section->target_index).donerel = 1;
+ /* translate from indexes to symptr ptrs */
+ for (count = 0; count < section->reloc_count; count++)
+ {
+ int esdid = (int) src[count].sym_ptr_ptr;
+
+ if (esdid == 0)
+ {
+ src[count].sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ }
+ else if (esdid < ES_BASE) /* Section relative thing */
+ {
+ struct esdid *e = &EDATA (abfd, esdid - 1);
+ if (!section)
+ {
+ /** relocation relative to section which was
+ never declared ! */
+ }
+ src[count].sym_ptr_ptr = e->section->symbol_ptr_ptr;
+ }
+ else
+ {
+ src[count].sym_ptr_ptr = symbols + esdid - ES_BASE;
+ }
+
+ }
+ }
+
+ for (count = 0; count < section->reloc_count; count++)
+ {
+ *relptr++ = src++;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+}
+
+#define versados_close_and_cleanup _bfd_generic_close_and_cleanup
+#define versados_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define versados_new_section_hook _bfd_generic_new_section_hook
+
+#define versados_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define versados_get_lineno _bfd_nosymbols_get_lineno
+#define versados_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define versados_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define versados_read_minisymbols _bfd_generic_read_minisymbols
+#define versados_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define versados_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define versados_set_arch_mach bfd_default_set_arch_mach
+
+#define versados_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define versados_bfd_relax_section bfd_generic_relax_section
+#define versados_bfd_gc_sections bfd_generic_gc_sections
+#define versados_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define versados_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define versados_bfd_final_link _bfd_generic_final_link
+#define versados_bfd_link_split_section _bfd_generic_link_split_section
+
+const bfd_target versados_vec =
+{
+ "versados", /* name */
+ bfd_target_versados_flavour,
+ BFD_ENDIAN_BIG, /* target byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ versados_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ versados_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_false,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (versados),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (versados),
+ BFD_JUMP_TABLE_RELOCS (versados),
+ BFD_JUMP_TABLE_WRITE (versados),
+ BFD_JUMP_TABLE_LINK (versados),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ (PTR) 0
+};
diff --git a/bfd/vms-gsd.c b/bfd/vms-gsd.c
new file mode 100644
index 00000000000..6a52462a06d
--- /dev/null
+++ b/bfd/vms-gsd.c
@@ -0,0 +1,920 @@
+/* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and
+ EVAX (openVMS/Alpha) files.
+ Copyright 1996, 1997, 1998 Free Software Foundation Inc.
+
+ go and read the openVMS linker manual (esp. appendix B)
+ if you don't know what's going on here :-)
+
+ Written by Klaus K"ampf (kkaempf@rmi.de)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include <ctype.h>
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+
+#include "vms.h"
+
+/*-----------------------------------------------------------------------------*/
+
+/* typical sections for vax object files */
+
+#define VAX_CODE_NAME "$CODE"
+#define VAX_DATA_NAME "$DATA"
+#define VAX_ADDRESS_DATA_NAME "$ADDRESS_DATA"
+
+/* typical sections for evax object files */
+
+#define EVAX_ABS_NAME "$ABS$"
+#define EVAX_CODE_NAME "$CODE$"
+#define EVAX_LINK_NAME "$LINK$"
+#define EVAX_DATA_NAME "$DATA$"
+#define EVAX_BSS_NAME "$BSS$"
+#define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
+#define EVAX_READONLY_NAME "$READONLY$"
+#define EVAX_LITERAL_NAME "$LITERAL$"
+#define EVAX_COMMON_NAME "$COMMON$"
+#define EVAX_LOCAL_NAME "$LOCAL$"
+
+struct sec_flags_struct {
+ char *name; /* name of section */
+ int vflags_always;
+ flagword flags_always; /* flags we set always */
+ int vflags_hassize;
+ flagword flags_hassize; /* flags we set if the section has a size > 0 */
+};
+
+/* These flags are deccrtl/vaxcrtl (openVMS 6.2 VAX) compatible */
+
+static struct sec_flags_struct vax_section_flags[] = {
+ { VAX_CODE_NAME,
+ (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_SHR|GPS_S_M_EXE|GPS_S_M_RD),
+ (SEC_CODE),
+ (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_SHR|GPS_S_M_EXE|GPS_S_M_RD),
+ (SEC_IN_MEMORY|SEC_CODE|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { VAX_DATA_NAME,
+ (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD|GPS_S_M_WRT),
+ (SEC_DATA),
+ (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD|GPS_S_M_WRT),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { VAX_ADDRESS_DATA_NAME,
+ (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD),
+ (SEC_DATA|SEC_READONLY),
+ (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
+ { NULL,
+ (GPS_S_M_PIC|GPS_S_M_OVR|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD|GPS_S_M_WRT),
+ (SEC_DATA),
+ (GPS_S_M_PIC|GPS_S_M_OVR|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD|GPS_S_M_WRT),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) }
+};
+
+
+/* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible */
+
+static struct sec_flags_struct evax_section_flags[] = {
+ { EVAX_ABS_NAME,
+ (EGPS_S_V_SHR),
+ (SEC_DATA),
+ (EGPS_S_V_SHR),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { EVAX_CODE_NAME,
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_EXE),
+ (SEC_CODE),
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_EXE),
+ (SEC_IN_MEMORY|SEC_CODE|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { EVAX_LITERAL_NAME,
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD|EGPS_S_V_NOMOD),
+ (SEC_DATA|SEC_READONLY),
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
+ { EVAX_LINK_NAME,
+ (EGPS_S_V_REL|EGPS_S_V_RD),
+ (SEC_DATA|SEC_READONLY),
+ (EGPS_S_V_REL|EGPS_S_V_RD),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
+ { EVAX_DATA_NAME,
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
+ (SEC_DATA),
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { EVAX_BSS_NAME,
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
+ (SEC_NO_FLAGS),
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
+ (SEC_IN_MEMORY|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { EVAX_READONLYADDR_NAME,
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_RD),
+ (SEC_DATA|SEC_READONLY),
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_RD),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
+ { EVAX_READONLY_NAME,
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD|EGPS_S_V_NOMOD),
+ (SEC_DATA|SEC_READONLY),
+ (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
+ { EVAX_LOCAL_NAME,
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
+ (SEC_DATA),
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
+ { NULL,
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
+ (SEC_DATA),
+ (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
+ (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) }
+};
+
+/* Retrieve bfd section flags by name and size */
+
+static flagword
+vms_secflag_by_name (abfd, section_flags, name, size)
+ bfd *abfd;
+ struct sec_flags_struct *section_flags;
+ char *name;
+ int size;
+{
+ int i = 0;
+
+ while (section_flags[i].name != NULL)
+ {
+ if ((PRIV(is_vax)?
+ strcasecmp (name, section_flags[i].name):
+ strcmp (name, section_flags[i].name)) == 0)
+ {
+ if (size > 0)
+ return section_flags[i].flags_hassize;
+ else
+ return section_flags[i].flags_always;
+ }
+ i++;
+ }
+ if (size > 0)
+ return section_flags[i].flags_hassize;
+ return section_flags[i].flags_always;
+}
+
+
+/* Retrieve vms section flags by name and size */
+
+static flagword
+vms_esecflag_by_name (section_flags, name, size)
+ struct sec_flags_struct *section_flags;
+ char *name;
+ int size;
+{
+ int i = 0;
+
+ while (section_flags[i].name != NULL)
+ {
+ if (strcmp (name, section_flags[i].name) == 0)
+ {
+ if (size > 0)
+ return section_flags[i].vflags_hassize;
+ else
+ return section_flags[i].vflags_always;
+ }
+ i++;
+ }
+ if (size > 0)
+ return section_flags[i].vflags_hassize;
+ return section_flags[i].vflags_always;
+}
+
+/*-----------------------------------------------------------------------------*/
+#if VMS_DEBUG
+/* debug */
+
+struct flagdescstruct { char *name; flagword value; };
+
+/* Convert flag to printable string */
+
+static char *
+flag2str(flagdesc, flags)
+ struct flagdescstruct *flagdesc;
+ flagword flags;
+{
+
+ static char res[64];
+ int next = 0;
+
+ res[0] = 0;
+ while (flagdesc->name != NULL)
+ {
+ if ((flags & flagdesc->value) != 0)
+ {
+ if (next)
+ strcat(res, ",");
+ else
+ next = 1;
+ strcat (res, flagdesc->name);
+ }
+ flagdesc++;
+ }
+ return res;
+}
+#endif
+
+/*-----------------------------------------------------------------------------*/
+/* input routines */
+
+/* Process GSD/EGSD record
+ return 0 on success, -1 on error */
+
+int
+_bfd_vms_slurp_gsd (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ static struct flagdescstruct gpsflagdesc[] =
+ {
+ { "PIC", 0x0001 },
+ { "LIB", 0x0002 },
+ { "OVR", 0x0004 },
+ { "REL", 0x0008 },
+ { "GBL", 0x0010 },
+ { "SHR", 0x0020 },
+ { "EXE", 0x0040 },
+ { "RD", 0x0080 },
+ { "WRT", 0x0100 },
+ { "VEC", 0x0200 },
+ { "NOMOD", 0x0400 },
+ { "COM", 0x0800 },
+ { NULL, 0 }
+ };
+
+ static struct flagdescstruct gsyflagdesc[] =
+ {
+ { "WEAK", 0x0001 },
+ { "DEF", 0x0002 },
+ { "UNI", 0x0004 },
+ { "REL", 0x0008 },
+ { "COMM", 0x0010 },
+ { "VECEP", 0x0020 },
+ { "NORM", 0x0040 },
+ { NULL, 0 }
+ };
+#endif
+
+ int gsd_type, gsd_size;
+ asection *section;
+ unsigned char *vms_rec;
+ flagword new_flags, old_flags;
+ char *name;
+ asymbol *symbol;
+ vms_symbol_entry *entry;
+ unsigned long base_addr;
+ unsigned long align_addr;
+ static int psect_idx = 0;
+
+#if VMS_DEBUG
+ vms_debug (2, "GSD/EGSD (%d/%x)\n", objtype, objtype);
+#endif
+
+ switch (objtype)
+ {
+ case EOBJ_S_C_EGSD:
+ PRIV(vms_rec) += 8; /* skip type, size, l_temp */
+ PRIV(rec_size) -= 8;
+ break;
+ case OBJ_S_C_GSD:
+ PRIV(vms_rec) += 1;
+ PRIV(rec_size) -= 1;
+ break;
+ default:
+ return -1;
+ }
+
+ /* calculate base address for each section */
+ base_addr = 0L;
+
+ abfd->symcount = 0;
+
+ while (PRIV(rec_size) > 0)
+ {
+ vms_rec = PRIV(vms_rec);
+
+ if (objtype == OBJ_S_C_GSD)
+ {
+ gsd_type = *vms_rec;
+ }
+ else
+ {
+ _bfd_vms_get_header_values (abfd, vms_rec, &gsd_type, &gsd_size);
+ gsd_type += EVAX_OFFSET;
+ }
+
+#if VMS_DEBUG
+ vms_debug (3, "gsd_type %d\n", gsd_type);
+#endif
+
+ switch (gsd_type)
+ {
+ case GSD_S_C_PSC:
+ {
+ /*
+ * program section definition
+ */
+
+ asection *old_section = 0;
+
+#if VMS_DEBUG
+ vms_debug (4, "GSD_S_C_PSC\n");
+#endif
+ /* If this section isn't a bfd section. */
+
+ if (PRIV(is_vax) && (psect_idx < (abfd->section_count-1)))
+ {
+ /* check for temporary section from TIR record. */
+
+ if (psect_idx < PRIV(section_count))
+ old_section = PRIV(sections)[psect_idx];
+ else
+ old_section = 0;
+ }
+
+ name = _bfd_vms_save_counted_string (vms_rec + 8);
+ section = bfd_make_section (abfd, name);
+ if (!section)
+ {
+ fprintf (stderr, "bfd_make_section (%s) failed\n", name);
+ return -1;
+ }
+ old_flags = bfd_getl16 (vms_rec + 2);
+ section->_raw_size = bfd_getl32(vms_rec + 4); /* allocation */
+ new_flags = vms_secflag_by_name (abfd, vax_section_flags, name, section->_raw_size);
+ if (old_flags & EGPS_S_V_REL)
+ new_flags |= SEC_RELOC;
+ if (old_flags & GPS_S_M_OVR)
+ new_flags |= SEC_IS_COMMON;
+ if (!bfd_set_section_flags (abfd, section, new_flags))
+ {
+ fprintf (stderr, "bfd_set_section_flags (%s, %x) failed\n", name, new_flags);
+ return -1;
+ }
+ section->alignment_power = vms_rec[1];
+ align_addr = (1 << section->alignment_power);
+ if ((base_addr % align_addr) != 0)
+ base_addr += (align_addr - (base_addr % align_addr));
+ section->vma = (bfd_vma)base_addr;
+ base_addr += section->_raw_size;
+
+ /* global section is common symbol */
+
+ if (old_flags & GPS_S_M_GBL)
+ {
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+ symbol = entry->symbol;
+
+ symbol->value = 0;
+ symbol->section = section;
+ symbol->flags = (BSF_GLOBAL|BSF_SECTION_SYM|BSF_OLD_COMMON);
+ }
+
+ /* copy saved contents if old_section set */
+
+ if (old_section != 0)
+ {
+ section->contents = old_section->contents;
+ if (section->_raw_size < old_section->_raw_size)
+ {
+ fprintf (stderr, "Size mismatch section %s=%d, %s=%d\n", old_section->name, old_section->_raw_size, section->name, section->_raw_size);
+ return -1;
+ }
+ else if (section->_raw_size > old_section->_raw_size)
+ {
+ section->contents = ((unsigned char *)
+ bfd_realloc (old_section->contents, section->_raw_size));
+ if (section->contents == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ section->contents = ((unsigned char *)
+ bfd_malloc (section->_raw_size));
+ if (section->contents == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+ memset (section->contents, 0, (size_t)section->_raw_size);
+ }
+ section->_cooked_size = section->_raw_size;
+#if VMS_DEBUG
+ vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ",
+ section->index, name, old_flags, flag2str (gpsflagdesc, old_flags));
+ vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
+ section->_raw_size, section->vma, section->contents);
+#endif
+
+ gsd_size = vms_rec[8] + 9;
+
+ psect_idx++;
+ }
+ break;
+
+ case GSD_S_C_EPM:
+ case GSD_S_C_EPMW:
+#if VMS_DEBUG
+ vms_debug(4, "gsd epm\n");
+#endif
+ /*FALLTHRU*/
+ case GSD_S_C_SYM:
+ case GSD_S_C_SYMW:
+ {
+ int name_offset, value_offset;
+
+ /*
+ * symbol specification (definition or reference)
+ */
+
+#if VMS_DEBUG
+ vms_debug (4, "GSD_S_C_SYM(W)\n");
+#endif
+ old_flags = bfd_getl16 (vms_rec + 2);
+ new_flags = BSF_NO_FLAGS;
+
+ if (old_flags & GSY_S_M_WEAK)
+ new_flags |= BSF_WEAK;
+
+ switch (gsd_type)
+ {
+ case GSD_S_C_EPM:
+ name_offset = 11;
+ value_offset = 5;
+ new_flags |= BSF_FUNCTION;
+ break;
+ case GSD_S_C_EPMW:
+ name_offset = 12;
+ value_offset = 6;
+ new_flags |= BSF_FUNCTION;
+ break;
+ case GSD_S_C_SYM:
+ if (old_flags & GSY_S_M_DEF) /* symbol definition */
+ name_offset = 9;
+ else
+ name_offset = 4;
+ value_offset = 5;
+ break;
+ case GSD_S_C_SYMW:
+ if (old_flags & GSY_S_M_DEF) /* symbol definition */
+ name_offset = 10;
+ else
+ name_offset = 5;
+ value_offset = 6;
+ break;
+ }
+
+ /* save symbol in vms_symbol_table */
+
+ entry = _bfd_vms_enter_symbol (abfd,
+ _bfd_vms_save_counted_string (vms_rec + name_offset));
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+ symbol = entry->symbol;
+
+ if (old_flags & GSY_S_M_DEF) /* symbol definition */
+ {
+ int psect;
+
+ symbol->value = bfd_getl32 (vms_rec+value_offset);
+ if ((gsd_type == GSD_S_C_SYMW)
+ || (gsd_type == GSD_S_C_EPMW))
+ psect = bfd_getl16 (vms_rec + value_offset - 2);
+ else
+ psect = vms_rec[value_offset-1];
+
+ symbol->section = (asection *)psect;
+#if VMS_DEBUG
+ vms_debug(4, "gsd sym def #%d (%s, %d [%p], %04x=%s)\n", abfd->symcount,
+ symbol->name, (int)symbol->section, symbol->section, old_flags, flag2str(gsyflagdesc, old_flags));
+#endif
+ }
+ else /* symbol reference */
+ {
+ symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
+#if VMS_DEBUG
+ vms_debug (4, "gsd sym ref #%d (%s, %s [%p], %04x=%s)\n", abfd->symcount,
+ symbol->name, symbol->section->name, symbol->section, old_flags, flag2str (gsyflagdesc, old_flags));
+#endif
+ }
+
+ gsd_size = vms_rec[name_offset] + name_offset + 1;
+ symbol->flags = new_flags;
+ }
+
+ break;
+
+ case GSD_S_C_PRO:
+ case GSD_S_C_PROW:
+#if VMS_DEBUG
+ vms_debug(4, "gsd pro\n");
+#endif
+ break;
+ case GSD_S_C_IDC:
+#if VMS_DEBUG
+ vms_debug(4, "gsd idc\n");
+#endif
+ break;
+ case GSD_S_C_ENV:
+#if VMS_DEBUG
+ vms_debug(4, "gsd env\n");
+#endif
+ break;
+ case GSD_S_C_LSY:
+#if VMS_DEBUG
+ vms_debug(4, "gsd lsy\n");
+#endif
+ break;
+ case GSD_S_C_LEPM:
+#if VMS_DEBUG
+ vms_debug(4, "gsd lepm\n");
+#endif
+ break;
+ case GSD_S_C_LPRO:
+#if VMS_DEBUG
+ vms_debug(4, "gsd lpro\n");
+#endif
+ break;
+ case GSD_S_C_SPSC:
+#if VMS_DEBUG
+ vms_debug(4, "gsd spsc\n");
+#endif
+ break;
+ case GSD_S_C_SYMV:
+#if VMS_DEBUG
+ vms_debug(4, "gsd symv\n");
+#endif
+ break;
+ case GSD_S_C_EPMV:
+#if VMS_DEBUG
+ vms_debug(4, "gsd epmv\n");
+#endif
+ break;
+ case GSD_S_C_PROV:
+#if VMS_DEBUG
+ vms_debug(4, "gsd prov\n");
+#endif
+ break;
+
+ case EGSD_S_C_PSC + EVAX_OFFSET:
+ {
+ /* program section definition */
+
+ name = _bfd_vms_save_counted_string (vms_rec+12);
+ section = bfd_make_section (abfd, name);
+ if (!section)
+ return -1;
+ old_flags = bfd_getl16 (vms_rec + 6);
+ section->_raw_size = bfd_getl32 (vms_rec + 8); /* allocation */
+ new_flags = vms_secflag_by_name (abfd, evax_section_flags, name, (int) section->_raw_size);
+ if (old_flags & EGPS_S_V_REL)
+ new_flags |= SEC_RELOC;
+ if (!bfd_set_section_flags (abfd, section, new_flags))
+ return -1;
+ section->alignment_power = vms_rec[4];
+ align_addr = (1 << section->alignment_power);
+ if ((base_addr % align_addr) != 0)
+ base_addr += (align_addr - (base_addr % align_addr));
+ section->vma = (bfd_vma)base_addr;
+ base_addr += section->_raw_size;
+ section->contents = ((unsigned char *)
+ bfd_malloc (section->_raw_size));
+ if (section->contents == NULL)
+ return -1;
+ memset (section->contents, 0, (size_t) section->_raw_size);
+ section->_cooked_size = section->_raw_size;
+#if VMS_DEBUG
+ vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
+ section->index, name, old_flags, flag2str(gpsflagdesc, old_flags));
+ vms_debug(4, "%d bytes at 0x%08lx (mem %p)\n",
+ section->_raw_size, section->vma, section->contents);
+#endif
+ }
+ break;
+
+ case EGSD_S_C_SYM + EVAX_OFFSET:
+ {
+ /* symbol specification (definition or reference) */
+
+ symbol = _bfd_vms_make_empty_symbol (abfd);
+ if (symbol == 0)
+ return -1;
+
+ old_flags = bfd_getl16 (vms_rec + 6);
+ new_flags = BSF_NO_FLAGS;
+
+ if (old_flags & EGSY_S_V_WEAK)
+ new_flags |= BSF_WEAK;
+
+ if (vms_rec[6] & EGSY_S_V_DEF) /* symbol definition */
+ {
+ symbol->name =
+ _bfd_vms_save_counted_string (vms_rec+32);
+ if (old_flags & EGSY_S_V_NORM)
+ { /* proc def */
+ new_flags |= BSF_FUNCTION;
+ }
+ symbol->value = bfd_getl64 (vms_rec+8);
+ symbol->section = (asection *)((unsigned long) bfd_getl32 (vms_rec+28));
+#if VMS_DEBUG
+ vms_debug(4, "egsd sym def #%d (%s, %d, %04x=%s)\n", abfd->symcount,
+ symbol->name, (int)symbol->section, old_flags, flag2str(gsyflagdesc, old_flags));
+#endif
+ }
+ else /* symbol reference */
+ {
+ symbol->name =
+ _bfd_vms_save_counted_string (vms_rec+8);
+#if VMS_DEBUG
+ vms_debug(4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd->symcount,
+ symbol->name, old_flags, flag2str(gsyflagdesc, old_flags));
+#endif
+ symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
+ }
+
+ symbol->flags = new_flags;
+
+ /* save symbol in vms_symbol_table */
+
+ entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), symbol->name, true, false);
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+ if (entry->symbol != (asymbol *)NULL)
+ { /* FIXME ?, DEC C generates this */
+#if VMS_DEBUG
+ vms_debug(4, "EGSD_S_C_SYM: duplicate \"%s\"\n", symbol->name);
+#endif
+ }
+ else
+ {
+ entry->symbol = symbol;
+ PRIV(gsd_sym_count)++;
+ abfd->symcount++;
+ }
+ }
+ break;
+
+ case EGSD_S_C_IDC + EVAX_OFFSET:
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("unknown gsd/egsd subtype %d"), gsd_type);
+ bfd_set_error (bfd_error_bad_value);
+ return -1;
+
+ } /* switch */
+
+ PRIV(rec_size) -= gsd_size;
+ PRIV(vms_rec) += gsd_size;
+
+ } /* while (recsize > 0) */
+
+ if (abfd->symcount > 0)
+ abfd->flags |= HAS_SYMS;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------*/
+/* output routines */
+
+/* Write section and symbol directory of bfd abfd */
+
+int
+_bfd_vms_write_gsd (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+ asection *section;
+ asymbol *symbol;
+ int symnum;
+ int last_index = -1;
+ char dummy_name[10];
+ char *sname;
+ flagword new_flags, old_flags;
+ char *nptr, *uptr;
+
+#if VMS_DEBUG
+ vms_debug (2, "vms_write_gsd (%p, %d)\n", abfd, objtype);
+#endif
+
+ /* output sections */
+
+ section = abfd->sections;
+#if VMS_DEBUG
+ vms_debug (3, "%d sections found\n", abfd->section_count);
+#endif
+
+ /* egsd is quadword aligned */
+
+ _bfd_vms_output_alignment (abfd, 8);
+
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
+ _bfd_vms_output_long (abfd, 0);
+ _bfd_vms_output_push (abfd); /* prepare output for subrecords */
+
+ while (section != 0)
+ {
+#if VMS_DEBUG
+ vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->_raw_size);
+#endif
+
+ /* 13 bytes egsd, max 31 chars name -> should be 44 bytes */
+ if (_bfd_vms_output_check (abfd, 64) < 0)
+ {
+ _bfd_vms_output_pop (abfd);
+ _bfd_vms_output_end (abfd);
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
+ _bfd_vms_output_long (abfd, 0);
+ _bfd_vms_output_push (abfd); /* prepare output for subrecords */
+ }
+
+ /* Create dummy sections to keep consecutive indices */
+
+ while (section->index - last_index > 1)
+ {
+#if VMS_DEBUG
+ vms_debug (3, "index %d, last %d\n", section->index, last_index);
+#endif
+ _bfd_vms_output_begin (abfd, EGSD_S_C_PSC, -1);
+ _bfd_vms_output_short (abfd, 0);
+ _bfd_vms_output_short (abfd, 0);
+ _bfd_vms_output_long (abfd, 0);
+ sprintf (dummy_name, ".DUMMY%02d", last_index);
+ _bfd_vms_output_counted (abfd, dummy_name);
+ _bfd_vms_output_flush (abfd);
+ last_index++;
+ }
+
+ /* Don't know if this is neccesary for the linker but for now it keeps
+ vms_slurp_gsd happy */
+
+ sname = (char *)section->name;
+ if (*sname == '.')
+ {
+ sname++;
+ if ((*sname == 't') && (strcmp (sname, "text") == 0))
+ sname = PRIV(is_vax)?VAX_CODE_NAME:EVAX_CODE_NAME;
+ else if ((*sname == 'd') && (strcmp (sname, "data") == 0))
+ sname = PRIV(is_vax)?VAX_DATA_NAME:EVAX_DATA_NAME;
+ else if ((*sname == 'b') && (strcmp (sname, "bss") == 0))
+ sname = EVAX_BSS_NAME;
+ else if ((*sname == 'l') && (strcmp (sname, "link") == 0))
+ sname = EVAX_LINK_NAME;
+ else if ((*sname == 'r') && (strcmp (sname, "rdata") == 0))
+ sname = EVAX_READONLY_NAME;
+ else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
+ sname = EVAX_LITERAL_NAME;
+ else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
+ sname = EVAX_COMMON_NAME;
+ else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
+ sname = EVAX_LOCAL_NAME;
+ }
+ else
+ sname = _bfd_vms_length_hash_symbol (abfd, sname, EOBJ_S_C_SECSIZ);
+
+ _bfd_vms_output_begin (abfd, EGSD_S_C_PSC, -1);
+ _bfd_vms_output_short (abfd, section->alignment_power & 0xff);
+ if (bfd_is_com_section (section))
+ {
+ new_flags = (EGPS_S_V_OVR|EGPS_S_V_REL|EGPS_S_V_GBL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD|EGPS_S_V_COM);
+ }
+ else
+ {
+ new_flags = vms_esecflag_by_name (evax_section_flags, sname, section->_raw_size);
+ }
+ _bfd_vms_output_short (abfd, new_flags);
+ _bfd_vms_output_long (abfd, section->_raw_size);
+ _bfd_vms_output_counted (abfd, sname);
+ _bfd_vms_output_flush (abfd);
+
+ last_index = section->index;
+ section = section->next;
+ }
+
+ /* output symbols */
+
+#if VMS_DEBUG
+ vms_debug (3, "%d symbols found\n", abfd->symcount);
+#endif
+
+ bfd_set_start_address (abfd, (bfd_vma)-1);
+
+ for (symnum = 0; symnum < abfd->symcount; symnum++)
+ {
+
+ symbol = abfd->outsymbols[symnum];
+ if (*(symbol->name) == '_')
+ {
+ if (strcmp (symbol->name, "__main") == 0)
+ bfd_set_start_address (abfd, (bfd_vma)symbol->value);
+ }
+ old_flags = symbol->flags;
+
+ if (old_flags & BSF_FILE)
+ continue;
+
+ if (((old_flags & (BSF_GLOBAL|BSF_WEAK)) == 0) /* not xdef */
+ && (!bfd_is_und_section (symbol->section))) /* and not xref */
+ continue; /* dont output */
+
+ /* 13 bytes egsd, max 64 chars name -> should be 77 bytes */
+
+ if (_bfd_vms_output_check (abfd, 80) < 0)
+ {
+ _bfd_vms_output_pop (abfd);
+ _bfd_vms_output_end (abfd);
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
+ _bfd_vms_output_long (abfd, 0);
+ _bfd_vms_output_push (abfd); /* prepare output for subrecords */
+ }
+
+ _bfd_vms_output_begin (abfd, EGSD_S_C_SYM, -1);
+
+ _bfd_vms_output_short (abfd, 0); /* data type, alignment */
+
+ new_flags = 0;
+
+ if (old_flags & BSF_WEAK)
+ new_flags |= EGSY_S_V_WEAK;
+ if (bfd_is_com_section (symbol->section)) /* .comm */
+ new_flags |= (EGSY_S_V_WEAK|EGSY_S_V_COMM);
+
+ if (old_flags & BSF_FUNCTION)
+ {
+ new_flags |= EGSY_S_V_NORM;
+ new_flags |= EGSY_S_V_REL;
+ }
+ if (old_flags & (BSF_GLOBAL|BSF_WEAK))
+ {
+ new_flags |= EGSY_S_V_DEF;
+ if (!bfd_is_abs_section (symbol->section))
+ new_flags |= EGSY_S_V_REL;
+ }
+ _bfd_vms_output_short (abfd, new_flags);
+
+ if (old_flags & (BSF_GLOBAL|BSF_WEAK)) /* symbol definition */
+ {
+ if (old_flags & BSF_FUNCTION)
+ {
+ _bfd_vms_output_quad (abfd, symbol->value);
+ _bfd_vms_output_quad (abfd,
+ ((asymbol *)(symbol->udata.p))->value);
+ _bfd_vms_output_long (abfd,
+ (((asymbol *)(symbol->udata.p))
+ ->section->index));
+ _bfd_vms_output_long (abfd, symbol->section->index);
+ }
+ else
+ {
+ _bfd_vms_output_quad (abfd, symbol->value); /* L_VALUE */
+ _bfd_vms_output_quad (abfd, 0); /* L_CODE_ADDRESS */
+ _bfd_vms_output_long (abfd, 0); /* L_CA_PSINDX */
+ _bfd_vms_output_long (abfd, symbol->section->index);/* L_PSINDX */
+ }
+ }
+ _bfd_vms_output_counted (abfd, _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ));
+
+ _bfd_vms_output_flush (abfd);
+
+ }
+
+ _bfd_vms_output_alignment (abfd, 8);
+ _bfd_vms_output_pop (abfd);
+ _bfd_vms_output_end (abfd);
+
+ return 0;
+}
diff --git a/bfd/vms-hdr.c b/bfd/vms-hdr.c
new file mode 100644
index 00000000000..01d20aabefa
--- /dev/null
+++ b/bfd/vms-hdr.c
@@ -0,0 +1,461 @@
+/* vms-hdr.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
+ EVAX (openVMS/Alpha) files.
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ HDR record handling functions
+ EMH record handling functions
+ and
+ EOM record handling functions
+ EEOM record handling functions
+
+ Written by Klaus K"ampf (kkaempf@rmi.de)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <ctype.h>
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+
+#include "vms.h"
+
+/*---------------------------------------------------------------------------*/
+
+
+/* Read & process emh record
+ return 0 on success, -1 on error */
+
+int
+_bfd_vms_slurp_hdr (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+ unsigned char *ptr;
+ unsigned char *vms_rec;
+ int subtype;
+
+ vms_rec = PRIV(vms_rec);
+
+#if VMS_DEBUG
+ vms_debug(2, "HDR/EMH\n");
+#endif
+
+ switch (objtype)
+ {
+ case OBJ_S_C_HDR:
+ subtype = vms_rec[1];
+ break;
+ case EOBJ_S_C_EMH:
+ subtype = bfd_getl16 (vms_rec + 4) + EVAX_OFFSET;
+ break;
+ default:
+ subtype = -1;
+ }
+
+#if VMS_DEBUG
+ vms_debug(3, "subtype %d\n", subtype);
+#endif
+
+ switch (subtype)
+ {
+
+ case MHD_S_C_MHD:
+ /*
+ * module header
+ */
+ PRIV(hdr_data).hdr_b_strlvl = vms_rec[2];
+ PRIV(hdr_data).hdr_l_recsiz = bfd_getl16 (vms_rec + 3);
+ PRIV(hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 5);
+ ptr = vms_rec + 5 + vms_rec[5] + 1;
+ PRIV(hdr_data).hdr_t_version = _bfd_vms_save_counted_string (ptr);
+ ptr += *ptr + 1;
+ PRIV(hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
+
+ break;
+
+ case MHD_S_C_LNM:
+ /*
+ *
+ */
+ PRIV(hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
+ break;
+
+ case MHD_S_C_SRC:
+ /*
+ *
+ */
+ PRIV(hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
+ break;
+
+ case MHD_S_C_TTL:
+ /*
+ *
+ */
+ PRIV(hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
+ break;
+
+ case MHD_S_C_CPR:
+ /*
+ *
+ */
+ break;
+
+ case MHD_S_C_MTC:
+ /*
+ *
+ */
+ break;
+
+ case MHD_S_C_GTX:
+ /*
+ *
+ */
+ break;
+
+ case EMH_S_C_MHD + EVAX_OFFSET:
+ /*
+ * module header
+ */
+ PRIV(hdr_data).hdr_b_strlvl = vms_rec[6];
+ PRIV(hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8);
+ PRIV(hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12);
+ PRIV(hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16);
+ PRIV(hdr_data).hdr_t_name =
+ _bfd_vms_save_counted_string (vms_rec + 20);
+ ptr = vms_rec + 20 + vms_rec[20] + 1;
+ PRIV(hdr_data).hdr_t_version =
+ _bfd_vms_save_counted_string (ptr);
+ ptr += *ptr + 1;
+ PRIV(hdr_data).hdr_t_date =
+ _bfd_vms_save_sized_string (ptr, 17);
+
+ break;
+
+ case EMH_S_C_LNM + EVAX_OFFSET:
+ /*
+ *
+ */
+ PRIV(hdr_data).hdr_c_lnm =
+ _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
+ break;
+
+ case EMH_S_C_SRC + EVAX_OFFSET:
+ /*
+ *
+ */
+ PRIV(hdr_data).hdr_c_src =
+ _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
+ break;
+
+ case EMH_S_C_TTL + EVAX_OFFSET:
+ /*
+ *
+ */
+ PRIV(hdr_data).hdr_c_ttl =
+ _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
+ break;
+
+ case EMH_S_C_CPR + EVAX_OFFSET:
+ /*
+ *
+ */
+ break;
+
+ case EMH_S_C_MTC + EVAX_OFFSET:
+ /*
+ *
+ */
+ break;
+
+ case EMH_S_C_GTX + EVAX_OFFSET:
+ /*
+ *
+ */
+ break;
+
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return -1;
+
+ } /* switch */
+
+ return 0;
+}
+
+
+/*-----------------------------------------------------------------------------*/
+/* Output routines. */
+
+
+/* Manufacure a VMS like time on a unix based system.
+ stolen from obj-vms.c */
+
+static unsigned char *
+get_vms_time_string ()
+{
+ static unsigned char tbuf[18];
+#ifndef VMS
+#include <time.h>
+
+ char *pnt;
+ time_t timeb;
+ time (&timeb);
+ pnt = ctime (&timeb);
+ pnt[3] = 0;
+ pnt[7] = 0;
+ pnt[10] = 0;
+ pnt[16] = 0;
+ pnt[24] = 0;
+ sprintf (tbuf, "%2s-%3s-%s %s", pnt + 8, pnt + 4, pnt + 20, pnt + 11);
+#else
+#include <starlet.h>
+ struct
+ {
+ int Size;
+ unsigned char *Ptr;
+ } Descriptor;
+ Descriptor.Size = 17;
+ Descriptor.Ptr = tbuf;
+ SYS$ASCTIM (0, &Descriptor, 0, 0);
+#endif /* not VMS */
+
+#if VMS_DEBUG
+ vms_debug (6, "vmstimestring:'%s'\n", tbuf);
+#endif
+
+ return tbuf;
+}
+
+
+/* write object header for bfd abfd */
+
+int
+_bfd_vms_write_hdr (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+ asymbol *symbol;
+ int symnum;
+ int had_case = 0;
+ int had_file = 0;
+
+
+#if VMS_DEBUG
+ vms_debug (2, "vms_write_hdr (%p)\n", abfd);
+#endif
+
+ _bfd_vms_output_alignment (abfd, 2);
+
+ /* MHD */
+
+ if (objtype == OBJ_S_C_HDR)
+ {
+ }
+ else
+ {
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_MHD);
+ _bfd_vms_output_short (abfd, EOBJ_S_C_STRLVL);
+ _bfd_vms_output_long (abfd, 0);
+ _bfd_vms_output_long (abfd, 0);
+ _bfd_vms_output_long (abfd, MAX_OUTREC_SIZE);
+ }
+
+ if (bfd_get_filename (abfd) != 0)
+ {
+ /* strip path and suffix information */
+
+ char *fname, *fout, *fptr;
+
+ fptr = bfd_get_filename (abfd);
+ fname = (char *) alloca (strlen (fptr) + 1);
+ strcpy (fname, fptr);
+ fout = strrchr (fname, ']');
+ if (fout == 0)
+ fout = strchr (fname, ':');
+ if (fout != 0)
+ fout++;
+ else
+ fout = fname;
+
+ /* strip .obj suffix */
+
+ fptr = strrchr (fname, '.');
+ if ((fptr != 0)
+ && (strcasecmp (fptr, ".OBJ") == 0))
+ *fptr = 0;
+
+ fptr = fout;
+ while (*fptr != 0)
+ {
+ if (islower (*fptr))
+ *fptr = toupper (*fptr);
+ fptr++;
+ if ((*fptr == ';')
+ || ((fptr - fout) > 31))
+ *fptr = 0;
+ }
+ _bfd_vms_output_counted (abfd, fout);
+ }
+ else
+ _bfd_vms_output_counted (abfd, "NONAME");
+
+ _bfd_vms_output_counted (abfd, BFD_VERSION);
+ _bfd_vms_output_dump (abfd, get_vms_time_string (), 17);
+ _bfd_vms_output_fill (abfd, 0, 17);
+ _bfd_vms_output_flush (abfd);
+
+ /* LMN */
+
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_LNM);
+ _bfd_vms_output_dump (abfd, (unsigned char *)"GAS proGIS", 10);
+ _bfd_vms_output_flush (abfd);
+
+ /* SRC */
+
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_SRC);
+
+ for (symnum = 0; symnum < abfd->symcount; symnum++)
+ {
+ symbol = abfd->outsymbols[symnum];
+
+ if (symbol->flags & BSF_FILE)
+ {
+ char *s;
+
+ if (strncmp ((char *)symbol->name, "<CASE:", 6) == 0)
+ {
+ PRIV(flag_hash_long_names) = symbol->name[6] - '0';
+ PRIV(flag_show_after_trunc) = symbol->name[7] - '0';
+
+ if (had_file)
+ break;
+ had_case = 1;
+ continue;
+ }
+
+ _bfd_vms_output_dump (abfd, (unsigned char *)symbol->name, strlen (symbol->name));
+ if (had_case)
+ break;
+ had_file = 1;
+ }
+ }
+
+ if (symnum == abfd->symcount)
+ _bfd_vms_output_dump (abfd, (unsigned char *)"noname", 6);
+
+ _bfd_vms_output_flush (abfd);
+
+ /* TTL */
+
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_TTL);
+ _bfd_vms_output_dump (abfd, (unsigned char *)"TTL", 3);
+ _bfd_vms_output_flush (abfd);
+
+ /* CPR */
+
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_CPR);
+ _bfd_vms_output_dump (abfd,
+ (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
+ 39);
+ _bfd_vms_output_flush (abfd);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------*/
+
+/* Process EOM/EEOM record
+ return 0 on success, -1 on error */
+
+int
+_bfd_vms_slurp_eom (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+ unsigned char *vms_rec;
+
+#if VMS_DEBUG
+ vms_debug(2, "EOM/EEOM\n");
+#endif
+
+ vms_rec = PRIV(vms_rec);
+
+ if ((objtype == OBJ_S_C_EOM)
+ || (objtype == OBJ_S_C_EOMW))
+ {
+ }
+ else
+ {
+ PRIV(eom_data).eom_l_total_lps = bfd_getl32 (vms_rec + 4);
+ PRIV(eom_data).eom_b_comcod = *(vms_rec + 8);
+ if (PRIV(eom_data).eom_b_comcod > 1)
+ {
+ (*_bfd_error_handler) (_("Object module NOT error-free !\n"));
+ bfd_set_error (bfd_error_bad_value);
+ return -1;
+ }
+ PRIV(eom_data).eom_has_transfer = false;
+ if (PRIV(rec_size) > 10)
+ {
+ PRIV(eom_data).eom_has_transfer = true;
+ PRIV(eom_data).eom_b_tfrflg = *(vms_rec + 9);
+ PRIV(eom_data).eom_l_psindx = bfd_getl32 (vms_rec + 12);
+ PRIV(eom_data).eom_l_tfradr = bfd_getl32 (vms_rec + 16);
+
+ abfd->start_address = PRIV(eom_data).eom_l_tfradr;
+ }
+ }
+ return 0;
+}
+
+
+/* Write eom record for bfd abfd */
+
+int
+_bfd_vms_write_eom (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ vms_debug (2, "vms_write_eom (%p, %d)\n", abfd, objtype);
+#endif
+
+ _bfd_vms_output_begin (abfd, objtype, -1);
+ _bfd_vms_output_long (abfd, (unsigned long)(PRIV(vms_linkage_index) >> 1));
+ _bfd_vms_output_byte (abfd, 0); /* completion code */
+ _bfd_vms_output_byte (abfd, 0); /* fill byte */
+
+ if (bfd_get_start_address (abfd) != (bfd_vma)-1)
+ {
+ asection *section;
+
+ section = bfd_get_section_by_name (abfd, ".link");
+ if (section == 0)
+ {
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return -1;
+ }
+ _bfd_vms_output_short (abfd, 0);
+ _bfd_vms_output_long (abfd, (unsigned long)(section->index));
+ _bfd_vms_output_long (abfd,
+ (unsigned long) bfd_get_start_address (abfd));
+ _bfd_vms_output_long (abfd, 0);
+ }
+
+ _bfd_vms_output_end (abfd);
+ return 0;
+}
diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c
new file mode 100644
index 00000000000..a5fdae4cc28
--- /dev/null
+++ b/bfd/vms-misc.c
@@ -0,0 +1,1145 @@
+/* vms-misc.c -- Miscellaneous functions for VAX (openVMS/VAX) and
+ EVAX (openVMS/Alpha) files.
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ Written by Klaus K"ampf (kkaempf@rmi.de)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#if __STDC__
+#include <stdarg.h>
+#endif
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+
+#include "vms.h"
+
+/*-----------------------------------------------------------------------------*/
+#if VMS_DEBUG
+/* debug functions */
+
+/* debug function for all vms extensions
+ evaluates environment variable VMS_DEBUG for a
+ numerical value on the first call
+ all error levels below this value are printed
+
+ levels:
+ 1 toplevel bfd calls (functions from the bfd vector)
+ 2 functions called by bfd calls
+ ...
+ 9 almost everything
+
+ level is also identation level. Indentation is performed
+ if level > 0
+ */
+
+#if __STDC__
+void
+_bfd_vms_debug (int level, char *format, ...)
+{
+ static int min_level = -1;
+ static FILE *output = NULL;
+ char *eptr;
+ va_list args;
+ int abslvl = (level > 0)?level:-level;
+
+ if (min_level == -1)
+ {
+ if ((eptr = getenv("VMS_DEBUG")) != NULL)
+ {
+ min_level = atoi(eptr);
+ output = stderr;
+ }
+ else
+ min_level = 0;
+ }
+ if (output == NULL)
+ return;
+ if (abslvl > min_level)
+ return;
+
+ while(--level>0)
+ fprintf(output, " ");
+ va_start(args, format);
+ vfprintf(output, format, args);
+ fflush(output);
+ va_end(args);
+
+ return;
+}
+
+#else /* not __STDC__ */
+
+void
+_bfd_vms_debug (level, format, a1, a2, a3, a4, a5, a6)
+ int level;
+ char *format;
+ long a1; long a2; long a3;
+ long a4; long a5; long a6;
+{
+ static int min_level = -1;
+ static FILE *output = NULL;
+ char *eptr;
+
+ if (min_level == -1)
+ {
+ if ((eptr = getenv("VMS_DEBUG")) != NULL)
+ {
+ min_level = atoi(eptr);
+ output = stderr;
+ }
+ else
+ min_level = 0;
+ }
+ if (output == NULL)
+ return;
+ if (level > min_level)
+ return;
+
+ while(--level>0)
+ fprintf(output, " ");
+ fprintf(output, format, a1, a2, a3, a4, a5, a6);
+ fflush(output);
+
+ return;
+}
+#endif /* __STDC__ */
+
+
+/* a debug function
+ hex dump 'size' bytes starting at 'ptr' */
+
+void
+_bfd_hexdump (level, ptr, size, offset)
+ int level;
+ unsigned char *ptr;
+ int size;
+ int offset;
+{
+ unsigned char *lptr = ptr;
+ int count = 0;
+ long start = offset;
+
+ while (size-- > 0)
+ {
+ if ((count%16) == 0)
+ vms_debug (level, "%08lx:", start);
+ vms_debug (-level, " %02x", *ptr++);
+ count++;
+ start++;
+ if (size == 0)
+ {
+ while ((count%16) != 0)
+ {
+ vms_debug (-level, " ");
+ count++;
+ }
+ }
+ if ((count%16) == 0)
+ {
+ vms_debug (-level, " ");
+ while (lptr < ptr)
+ {
+ vms_debug (-level, "%c", (*lptr < 32)?'.':*lptr);
+ lptr++;
+ }
+ vms_debug (-level, "\n");
+ }
+ }
+ if ((count%16) != 0)
+ vms_debug (-level, "\n");
+
+ return;
+}
+#endif
+
+
+/* hash functions
+
+ These are needed when reading an object file. */
+
+/* allocate new vms_hash_entry
+ keep the symbol name and a pointer to the bfd symbol in the table */
+
+struct bfd_hash_entry *
+_bfd_vms_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ vms_symbol_entry *ret;
+
+#if VMS_DEBUG
+ vms_debug (5, "_bfd_vms_hash_newfunc(%p, %p, %s)\n", entry, table, string);
+#endif
+
+ if (entry == (struct bfd_hash_entry *)NULL)
+ {
+ ret = (vms_symbol_entry *)
+ bfd_hash_allocate (table, sizeof (vms_symbol_entry));
+ if (ret == (vms_symbol_entry *) NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return (struct bfd_hash_entry *)NULL;
+ }
+ }
+
+ /* Call the allocation method of the base class. */
+
+ ret = (vms_symbol_entry *) bfd_hash_newfunc ((struct bfd_hash_entry *)ret, table, string);
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_hash_newfunc ret %p\n", ret);
+#endif
+
+ ret->symbol = (asymbol *)NULL;
+
+ return (struct bfd_hash_entry *)ret;
+}
+
+
+/* object file input functions */
+
+/* Return type and length from record header (buf) on Alpha. */
+
+void
+_bfd_vms_get_header_values (abfd, buf, type, length)
+ bfd *abfd;
+ unsigned char *buf;
+ int *type;
+ int *length;
+{
+ if (type != 0)
+ *type = bfd_getl16 (buf);
+ buf += 2;
+ if (length != 0)
+ *length = bfd_getl16 (buf);
+
+#if VMS_DEBUG
+ vms_debug (10, "_bfd_vms_get_header_values type %x, length %x\n", (type?*type:0), (length?*length:0));
+#endif
+
+
+ return;
+}
+
+
+/* Get next record from object file to vms_buf
+ set PRIV(buf_size) and return it
+
+ this is a little tricky since it should be portable.
+
+ the openVMS object file has 'variable length' which means that
+ read() returns data in chunks of (hopefully) correct and expected
+ size. The linker (and other tools on vms) depend on that. Unix doesn't
+ know about 'formatted' files, so reading and writing such an object
+ file in a unix environment is not trivial.
+
+ With the tool 'file' (available on all vms ftp sites), one
+ can view and change the attributes of a file. Changing from
+ 'variable length' to 'fixed length, 512 bytes' reveals the
+ record length at the first 2 bytes of every record. The same
+ happens during the transfer of object files from vms to unix,
+ at least with ucx, dec's implementation of tcp/ip.
+
+ The vms format repeats the length at bytes 2 & 3 of every record.
+
+ On the first call (file_format == FF_UNKNOWN) we check if
+ the first and the third byte pair (!) of the record match.
+ If they do it's an object file in an unix environment or with
+ wrong attributes (FF_FOREIGN), else we should be in a vms
+ environment where read() returns the record size (FF_NATIVE).
+
+ reading is always done in 2 steps.
+ first just the record header is read and the length extracted
+ by get_header_values
+ then the read buffer is adjusted and the remaining bytes are
+ read in.
+
+ all file i/o is always done on even file positions */
+
+int
+_bfd_vms_get_record (abfd)
+ bfd *abfd;
+{
+ int test_len, test_start, remaining;
+ unsigned char *vms_buf;
+
+#if VMS_DEBUG
+ vms_debug (8, "_bfd_vms_get_record\n");
+#endif
+
+ /* minimum is 6 bytes on Alpha
+ (2 bytes length, 2 bytes record id, 2 bytes length repeated)
+
+ on VAX there's no length information in the record
+ so start with OBJ_S_C_MAXRECSIZ */
+
+ if (PRIV(buf_size) == 0)
+ {
+ if (PRIV(is_vax))
+ {
+ PRIV(vms_buf) = (unsigned char *) malloc (OBJ_S_C_MAXRECSIZ);
+ PRIV(buf_size) = OBJ_S_C_MAXRECSIZ;
+ PRIV(file_format) = FF_VAX;
+ }
+ else
+ PRIV(vms_buf) = (unsigned char *) malloc (6);
+ }
+
+ vms_buf = PRIV(vms_buf);
+
+ if (vms_buf == 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+
+ switch (PRIV(file_format))
+ {
+ case FF_UNKNOWN:
+ case FF_FOREIGN:
+ test_len = 6; /* probe 6 bytes */
+ test_start = 2; /* where the record starts */
+ break;
+
+ case FF_NATIVE:
+ test_len = 4;
+ test_start = 0;
+ break;
+
+ case FF_VAX:
+ test_len = 0;
+ test_start = 0;
+ break;
+ }
+
+ /* skip odd alignment byte */
+
+ if (bfd_tell (abfd) & 1)
+ {
+ if (bfd_read (PRIV(vms_buf), 1, 1, abfd) != 1)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+ }
+
+ /* read the record header on Alpha. */
+
+ if ((test_len != 0)
+ && (bfd_read (PRIV(vms_buf), 1, test_len, abfd) != test_len))
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+
+ /* check file format on first call */
+
+ if (PRIV(file_format) == FF_UNKNOWN)
+ { /* record length repeats ? */
+ if ( (vms_buf[0] == vms_buf[4])
+ && (vms_buf[1] == vms_buf[5]))
+ {
+ PRIV(file_format) = FF_FOREIGN; /* Y: foreign environment */
+ test_start = 2;
+ }
+ else
+ {
+ PRIV(file_format) = FF_NATIVE; /* N: native environment */
+ test_start = 0;
+ }
+ }
+
+ if (PRIV(is_vax))
+ {
+ PRIV(rec_length) = bfd_read (vms_buf, 1, PRIV(buf_size), abfd);
+ if (PRIV(rec_length) <= 0)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+ PRIV(vms_rec) = vms_buf;
+ }
+ else /* Alpha */
+ {
+ /* extract vms record length */
+
+ _bfd_vms_get_header_values (abfd, vms_buf+test_start, NULL,
+ &PRIV(rec_length));
+
+ if (PRIV(rec_length) <= 0)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+
+ /* that's what the linker manual says */
+
+ if (PRIV(rec_length) > EOBJ_S_C_MAXRECSIZ)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+
+ /* adjust the buffer */
+
+ if (PRIV(rec_length) > PRIV(buf_size))
+ {
+ PRIV(vms_buf) = (unsigned char *) realloc (vms_buf, PRIV(rec_length));
+ vms_buf = PRIV(vms_buf);
+ if (vms_buf == 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return -1;
+ }
+ PRIV(buf_size) = PRIV(rec_length);
+ }
+
+ /* read the remaining record */
+
+ remaining = PRIV(rec_length) - test_len + test_start;
+
+#if VMS_DEBUG
+ vms_debug (10, "bfd_read remaining %d\n", remaining);
+#endif
+ if (bfd_read (vms_buf + test_len, 1, remaining, abfd) != remaining)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+ PRIV(vms_rec) = vms_buf + test_start;
+ }
+
+#if VMS_DEBUG
+ vms_debug (11, "bfd_read rec_length %d\n", PRIV(rec_length));
+#endif
+
+ return PRIV(rec_length);
+}
+
+
+/* get next vms record from file
+ update vms_rec and rec_length to new (remaining) values */
+
+int
+_bfd_vms_next_record (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (8, "_bfd_vms_next_record (len %d, size %d)\n",
+ PRIV(rec_length), PRIV(rec_size));
+#endif
+
+ if (PRIV(rec_length) > 0)
+ {
+ PRIV(vms_rec) += PRIV(rec_size);
+ }
+ else
+ {
+ if (_bfd_vms_get_record (abfd) <= 0)
+ return -1;
+ }
+
+ if (PRIV(is_vax))
+ {
+ PRIV(rec_type) = *(PRIV(vms_rec));
+ PRIV(rec_size) = PRIV(rec_length);
+ }
+ else
+ {
+ _bfd_vms_get_header_values (abfd, PRIV(vms_rec), &PRIV(rec_type),
+ &PRIV(rec_size));
+ }
+ PRIV(rec_length) -= PRIV(rec_size);
+
+#if VMS_DEBUG
+ vms_debug (8, "_bfd_vms_next_record: rec %p, size %d, length %d, type %d\n",
+ PRIV(vms_rec), PRIV(rec_size), PRIV(rec_length),
+ PRIV(rec_type));
+#endif
+
+ return PRIV(rec_type);
+}
+
+
+
+/* Copy sized string (string with fixed length) to new allocated area
+ size is string length (size of record) */
+
+char *
+_bfd_vms_save_sized_string (str, size)
+ unsigned char *str;
+ int size;
+{
+ char *newstr = bfd_malloc (size + 1);
+
+ if (newstr == NULL)
+ return 0;
+ strncpy (newstr, (char *)str, size);
+ newstr[size] = 0;
+
+ return newstr;
+}
+
+/* Copy counted string (string with length at first byte) to new allocated area
+ ptr points to length byte on entry */
+
+char *
+_bfd_vms_save_counted_string (ptr)
+ unsigned char *ptr;
+{
+ int len = *ptr++;
+
+ return _bfd_vms_save_sized_string (ptr, len);
+}
+
+
+/* stack routines for vms ETIR commands */
+
+/* Push value and section index */
+
+void
+_bfd_vms_push (abfd, val, psect)
+ bfd *abfd;
+ uquad val;
+ int psect;
+{
+ static int last_psect;
+
+#if VMS_DEBUG
+ vms_debug (4, "<push %016lx(%d) at %d>\n", val, psect, PRIV(stackptr));
+#endif
+
+ if (psect >= 0)
+ last_psect = psect;
+
+ PRIV(stack[PRIV(stackptr)]).value = val;
+ PRIV(stack[PRIV(stackptr)]).psect = last_psect;
+ PRIV(stackptr)++;
+ if (PRIV(stackptr) >= STACKSIZE)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ (*_bfd_error_handler) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV(stackptr));
+ exit (1);
+ }
+ return;
+}
+
+
+/* Pop value and section index */
+
+uquad
+_bfd_vms_pop (abfd, psect)
+ bfd *abfd;
+ int *psect;
+{
+ uquad value;
+
+ if (PRIV(stackptr) == 0)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ (*_bfd_error_handler) (_("Stack underflow in _bfd_vms_pop"));
+ exit (1);
+ }
+ PRIV(stackptr)--;
+ value = PRIV(stack[PRIV(stackptr)]).value;
+ if ((psect != NULL) && (PRIV(stack[PRIV(stackptr)]).psect >= 0))
+ *psect = PRIV(stack[PRIV(stackptr)]).psect;
+
+#if VMS_DEBUG
+ vms_debug (4, "<pop %016lx(%d)>\n", value, PRIV(stack[PRIV(stackptr)]).psect);
+#endif
+
+ return value;
+}
+
+
+/* object file output functions */
+
+/* GAS tends to write sections in little chunks (bfd_set_section_contents)
+ which we can't use directly. So we save the little chunks in linked
+ lists (one per section) and write them later. */
+
+/* Add a new vms_section structure to vms_section_table
+ - forward chaining - */
+
+static vms_section *
+add_new_contents (abfd, section)
+ bfd *abfd;
+ sec_ptr section;
+{
+ vms_section *sptr, *newptr;
+
+ sptr = PRIV(vms_section_table)[section->index];
+ if (sptr != NULL)
+ return sptr;
+
+ newptr = (vms_section *) bfd_malloc (sizeof (vms_section));
+ if (newptr == (vms_section *) NULL)
+ return NULL;
+ newptr->contents = (unsigned char *) bfd_alloc (abfd, (int)section->_raw_size);
+ if (newptr->contents == (unsigned char *)NULL)
+ return NULL;
+ newptr->offset = 0;
+ newptr->size = section->_raw_size;
+ newptr->next = 0;
+ PRIV(vms_section_table)[section->index] = newptr;
+ return newptr;
+}
+
+
+/* Save section data & offset to an vms_section structure
+ vms_section_table[] holds the vms_section chain */
+
+boolean
+_bfd_save_vms_section (abfd, section, data, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR data;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ vms_section *sptr;
+
+ if (section->index >= VMS_SECTION_COUNT)
+ {
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ if (count == (bfd_size_type)0)
+ return true;
+ sptr = add_new_contents (abfd, section);
+ if (sptr == NULL)
+ return false;
+ memcpy (sptr->contents + offset, data, (size_t) count);
+
+ return true;
+}
+
+
+/* Get vms_section pointer to saved contents for section # index */
+
+vms_section *
+_bfd_get_vms_section (abfd, index)
+ bfd *abfd;
+ int index;
+{
+ if (index >= VMS_SECTION_COUNT)
+ {
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return NULL;
+ }
+ return PRIV(vms_section_table)[index];
+}
+
+
+/* Object output routines */
+
+/* Begin new record or record header
+ write 2 bytes rectype
+ write 2 bytes record length (filled in at flush)
+ write 2 bytes header type (ommitted if rechead == -1) */
+
+void
+_bfd_vms_output_begin (abfd, rectype, rechead)
+ bfd *abfd;
+ int rectype;
+ int rechead;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_begin(type %d, head %d)\n", rectype,
+ rechead);
+#endif
+
+ _bfd_vms_output_short (abfd,rectype);
+
+ /* save current output position to fill in lenght later */
+
+ if (PRIV(push_level) > 0)
+ PRIV(length_pos) = PRIV(output_size);
+
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_begin: length_pos = %d\n",
+ PRIV(length_pos));
+#endif
+
+ _bfd_vms_output_short (abfd,0); /* placeholder for length */
+
+ if (rechead != -1)
+ _bfd_vms_output_short (abfd,rechead);
+
+ return;
+}
+
+
+/* Set record/subrecord alignment */
+
+void
+_bfd_vms_output_alignment (abfd, alignto)
+ bfd *abfd;
+ int alignto;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_alignment(%d)\n", alignto);
+#endif
+
+ PRIV(output_alignment) = alignto;
+ return;
+}
+
+
+/* Prepare for subrecord fields */
+
+void
+_bfd_vms_output_push (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (6, "vms_output_push(pushed_size = %d)\n", PRIV(output_size));
+#endif
+
+ PRIV(push_level)++;
+ PRIV(pushed_size) = PRIV(output_size);
+ return;
+}
+
+
+/* End of subrecord fields */
+
+void
+_bfd_vms_output_pop (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (6, "vms_output_pop(pushed_size = %d)\n", PRIV(pushed_size));
+#endif
+
+ _bfd_vms_output_flush (abfd);
+ PRIV(length_pos) = 2;
+
+#if VMS_DEBUG
+ vms_debug (6, "vms_output_pop: length_pos = %d\n", PRIV(length_pos));
+#endif
+
+ PRIV(pushed_size) = 0;
+ PRIV(push_level)--;
+ return;
+}
+
+
+/* Flush unwritten output, ends current record */
+
+void
+_bfd_vms_output_flush (abfd)
+ bfd *abfd;
+{
+ int real_size = PRIV(output_size);
+ int aligncount;
+ int length;
+
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_flush(real_size = %d, pushed_size %d at lenpos %d)\n",
+ real_size, PRIV(pushed_size), PRIV(length_pos));
+#endif
+
+ if (PRIV(push_level) > 0)
+ length = real_size - PRIV(pushed_size);
+ else
+ length = real_size;
+
+ if (length == 0)
+ return;
+ aligncount = (PRIV(output_alignment)
+ - (length % PRIV(output_alignment))) % PRIV(output_alignment);
+
+#if VMS_DEBUG
+ vms_debug (6, "align: adding %d bytes\n", aligncount);
+#endif
+
+ while(aligncount-- > 0)
+ {
+ PRIV(output_buf)[real_size++] = 0;
+#if 0
+ /* this is why I *love* vms: inconsistency :-}
+ alignment is added to the subrecord length
+ but not to the record length */
+ if (PRIV(push_level) > 0)
+#endif
+ length++;
+ }
+
+ /* put length to buffer */
+ PRIV(output_size) = PRIV(length_pos);
+ _bfd_vms_output_short (abfd, (unsigned int)length);
+
+ if (PRIV(push_level) == 0)
+ {
+#ifndef VMS
+ /* write length first, see FF_FOREIGN in the input routines */
+ fwrite (PRIV(output_buf)+2, 2, 1, (FILE *)abfd->iostream);
+#endif
+ fwrite (PRIV(output_buf), real_size, 1, (FILE *)abfd->iostream);
+
+ PRIV(output_size) = 0;
+ }
+ else
+ {
+ PRIV(output_size) = real_size;
+ PRIV(pushed_size) = PRIV(output_size);
+ }
+
+ return;
+}
+
+
+/* End record output */
+
+void
+_bfd_vms_output_end (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_end\n");
+#endif
+
+ _bfd_vms_output_flush (abfd);
+
+ return;
+}
+
+
+/* check remaining buffer size
+
+ return what's left. */
+
+int
+_bfd_vms_output_check (abfd, size)
+ bfd *abfd;
+ int size;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_check(%d)\n", size);
+#endif
+
+ return (MAX_OUTREC_SIZE - (PRIV(output_size) + size + MIN_OUTREC_LUFT));
+}
+
+
+/* Output byte (8 bit) value */
+
+void
+_bfd_vms_output_byte (abfd, value)
+ bfd *abfd;
+ unsigned int value;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_byte(%02x)\n", value);
+#endif
+
+ bfd_put_8 (abfd, value & 0xff, PRIV(output_buf) + PRIV(output_size));
+ PRIV(output_size) += 1;
+ return;
+}
+
+
+/* Output short (16 bit) value */
+
+void
+_bfd_vms_output_short (abfd, value)
+ bfd *abfd;
+ unsigned int value;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_short (%04x)\n", value);
+#endif
+
+ bfd_put_16 (abfd, value & 0xffff, PRIV(output_buf) + PRIV(output_size));
+ PRIV(output_size) += 2;
+ return;
+}
+
+
+/* Output long (32 bit) value */
+
+void
+_bfd_vms_output_long (abfd, value)
+ bfd *abfd;
+ unsigned long value;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_long (%08lx)\n", value);
+#endif
+
+ bfd_put_32 (abfd, value, PRIV(output_buf) + PRIV(output_size));
+ PRIV(output_size) += 4;
+ return;
+}
+
+
+/* Output quad (64 bit) value */
+
+void
+_bfd_vms_output_quad (abfd, value)
+ bfd *abfd;
+ uquad value;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_quad(%016lx)\n", value);
+#endif
+
+ bfd_put_64(abfd, value, PRIV(output_buf) + PRIV(output_size));
+ PRIV(output_size) += 8;
+ return;
+}
+
+
+/* Output c-string as counted string */
+
+void
+_bfd_vms_output_counted (abfd, value)
+ bfd *abfd;
+ char *value;
+{
+int len;
+
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_counted(%s)\n", value);
+#endif
+
+ len = strlen (value);
+ if (len == 0)
+ {
+ (*_bfd_error_handler) (_("_bfd_vms_output_counted called with zero bytes"));
+ return;
+ }
+ if (len > 255)
+ {
+ (*_bfd_error_handler) (_("_bfd_vms_output_counted called with too many bytes"));
+ return;
+ }
+ _bfd_vms_output_byte (abfd, len & 0xff);
+ _bfd_vms_output_dump (abfd, (unsigned char *)value, len);
+}
+
+
+/* Output character area */
+
+void
+_bfd_vms_output_dump (abfd, data, length)
+ bfd *abfd;
+ unsigned char *data;
+ int length;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_dump(%d)\n", length);
+#endif
+
+ if (length == 0)
+ return;
+
+ memcpy (PRIV(output_buf) + PRIV(output_size), data, length);
+ PRIV(output_size) += length;
+
+ return;
+}
+
+
+/* Output count bytes of value */
+
+void
+_bfd_vms_output_fill (abfd, value, count)
+ bfd *abfd;
+ int value;
+ int count;
+{
+#if VMS_DEBUG
+ vms_debug (6, "_bfd_vms_output_fill(val %02x times %d)\n", value, count);
+#endif
+
+ if (count == 0)
+ return;
+ memset (PRIV(output_buf) + PRIV(output_size), value, count);
+ PRIV(output_size) += count;
+
+ return;
+}
+
+/* this hash routine borrowed from GNU-EMACS, and strengthened slightly ERY*/
+
+static int
+hash_string (ptr)
+ const char *ptr;
+{
+ register const unsigned char *p = (unsigned char *) ptr;
+ register const unsigned char *end = p + strlen (ptr);
+ register unsigned char c;
+ register int hash = 0;
+
+ while (p != end)
+ {
+ c = *p++;
+ hash = ((hash << 3) + (hash << 15) + (hash >> 28) + c);
+ }
+ return hash;
+}
+
+/* Generate a length-hashed VMS symbol name (limited to maxlen chars). */
+
+char *
+_bfd_vms_length_hash_symbol (abfd, in, maxlen)
+ bfd *abfd;
+ const char *in;
+ int maxlen;
+{
+ long int init;
+ long int result;
+ int in_len;
+ char *pnt = 0;
+ char *new_name;
+ const char *old_name;
+ int i;
+ static char outbuf[EOBJ_S_C_SYMSIZ+1];
+ char *out = outbuf;
+
+#if VMS_DEBUG
+ vms_debug(4, "_bfd_vms_length_hash_symbol \"%s\"\n", in);
+#endif
+
+ if (maxlen > EOBJ_S_C_SYMSIZ)
+ maxlen = EOBJ_S_C_SYMSIZ;
+
+ new_name = out; /* save this for later. */
+
+ /* We may need to truncate the symbol, save the hash for later. */
+
+ in_len = strlen (in);
+
+ result = (in_len > maxlen) ? hash_string (in) : 0;
+
+ old_name = in;
+
+ /* Do the length checking. */
+
+ if (in_len <= maxlen)
+ {
+ i = in_len;
+ }
+ else
+ {
+ if (PRIV(flag_hash_long_names))
+ i = maxlen-9;
+ else
+ i = maxlen;
+ }
+
+ strncpy (out, in, i);
+ in += i;
+ out += i;
+
+ if ((in_len > maxlen)
+ && PRIV(flag_hash_long_names))
+ sprintf (out, "_%08x", result);
+ else
+ *out = 0;
+
+#if VMS_DEBUG
+ vms_debug(4, "--> [%d]\"%s\"\n", strlen (outbuf), outbuf);
+#endif
+
+ if (in_len > maxlen
+ && PRIV(flag_hash_long_names)
+ && PRIV(flag_show_after_trunc))
+ printf (_("Symbol %s replaced by %s\n"), old_name, new_name);
+
+ return outbuf;
+}
+
+
+/* Allocate and initialize a new symbol. */
+
+static asymbol *
+new_symbol (abfd, name)
+ bfd *abfd;
+ char *name;
+{
+ asymbol *symbol;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (7, "new_symbol %s\n", name);
+#endif
+
+ symbol = _bfd_vms_make_empty_symbol (abfd);
+ if (symbol == 0)
+ return symbol;
+ symbol->name = name;
+ symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
+
+ return symbol;
+}
+
+
+/* Allocate and enter a new private symbol. */
+
+vms_symbol_entry *
+_bfd_vms_enter_symbol (abfd, name)
+ bfd *abfd;
+ char *name;
+{
+ vms_symbol_entry *entry;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (6, "_bfd_vms_enter_symbol %s\n", name);
+#endif
+
+ entry = (vms_symbol_entry *)
+ bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
+ if (entry == 0)
+ {
+#if VMS_DEBUG
+ _bfd_vms_debug (8, "creating hash entry for %s\n", name);
+#endif
+ entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, true, false);
+ if (entry != 0)
+ {
+ asymbol *symbol;
+ symbol = new_symbol (abfd, name);
+ if (symbol != 0)
+ {
+ entry->symbol = symbol;
+ PRIV(gsd_sym_count)++;
+ abfd->symcount++;
+ }
+ else
+ entry = 0;
+ }
+ else
+ (*_bfd_error_handler) (_("failed to enter %s"), name);
+ }
+ else
+ {
+#if VMS_DEBUG
+ _bfd_vms_debug (8, "found hash entry for %s\n", name);
+#endif
+ }
+
+#if VMS_DEBUG
+ _bfd_vms_debug (7, "-> entry %p, entry->symbol %p\n", entry, entry->symbol);
+#endif
+ return entry;
+}
diff --git a/bfd/vms-tir.c b/bfd/vms-tir.c
new file mode 100644
index 00000000000..782f52bfc04
--- /dev/null
+++ b/bfd/vms-tir.c
@@ -0,0 +1,2489 @@
+/* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and
+ EVAX (openVMS/Alpha) files.
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ TIR record handling functions
+ ETIR record handling functions
+
+ go and read the openVMS linker manual (esp. appendix B)
+ if you don't know what's going on here :-)
+
+ Written by Klaus K"ampf (kkaempf@rmi.de)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* The following type abbreviations are used:
+
+ cs counted string (ascii string with length byte)
+ by byte (1 byte)
+ sh short (2 byte, 16 bit)
+ lw longword (4 byte, 32 bit)
+ qw quadword (8 byte, 64 bit)
+ da data stream */
+
+#include <ctype.h>
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+
+#include "vms.h"
+
+static void image_set_ptr PARAMS ((bfd *abfd, int psect, uquad offset));
+static void image_inc_ptr PARAMS ((bfd *abfd, uquad offset));
+static void image_dump PARAMS ((bfd *abfd, unsigned char *ptr, int size, int offset));
+static void image_write_b PARAMS ((bfd *abfd, unsigned int value));
+static void image_write_w PARAMS ((bfd *abfd, unsigned int value));
+static void image_write_l PARAMS ((bfd *abfd, unsigned long value));
+static void image_write_q PARAMS ((bfd *abfd, uquad value));
+
+/*-----------------------------------------------------------------------------*/
+
+static int
+check_section (abfd, size)
+ bfd *abfd;
+ int size;
+{
+ int offset;
+
+ offset = PRIV(image_ptr) - PRIV(image_section)->contents;
+ if ((offset + size) > PRIV(image_section)->_raw_size)
+ {
+ PRIV(image_section)->contents = bfd_realloc (PRIV(image_section)->contents, offset + size);
+ if (PRIV(image_section)->contents == 0)
+ {
+ (*_bfd_error_handler) (_("No Mem !"));
+ return -1;
+ }
+ PRIV(image_section)->_raw_size = offset + size;
+ PRIV(image_ptr) = PRIV(image_section)->contents + offset;
+ }
+
+ return 0;
+}
+
+/* routines to fill sections contents during tir/etir read */
+
+/* Initialize image buffer pointer to be filled */
+
+static void
+image_set_ptr (abfd, psect, offset)
+ bfd *abfd;
+ int psect;
+ uquad offset;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "image_set_ptr (%d=%s, %d)\n",
+ psect, PRIV(sections)[psect]->name, offset);
+#endif
+
+ PRIV(image_ptr) = PRIV(sections)[psect]->contents + offset;
+ PRIV(image_section) = PRIV(sections)[psect];
+ return;
+}
+
+
+/* Increment image buffer pointer by offset */
+
+static void
+image_inc_ptr (abfd, offset)
+ bfd *abfd;
+ uquad offset;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "image_inc_ptr (%d)\n", offset);
+#endif
+
+ PRIV(image_ptr) += offset;
+
+ return;
+}
+
+
+/* Dump multiple bytes to section image */
+
+static void
+image_dump (abfd, ptr, size, offset)
+ bfd *abfd;
+ unsigned char *ptr;
+ int size;
+ int offset;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, PRIV(image_ptr));
+ _bfd_hexdump (9, ptr, size, offset);
+#endif
+
+ if (PRIV(is_vax) && check_section (abfd, size))
+ return;
+
+ while (size-- > 0)
+ *PRIV(image_ptr)++ = *ptr++;
+ return;
+}
+
+
+/* Write byte to section image */
+
+static void
+image_write_b (abfd, value)
+ bfd *abfd;
+ unsigned int value;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (6, "image_write_b(%02x)\n", (int)value);
+#endif
+
+ if (PRIV(is_vax) && check_section (abfd, 1))
+ return;
+
+ *PRIV(image_ptr)++ = (value & 0xff);
+ return;
+}
+
+
+/* Write 2-byte word to image */
+
+static void
+image_write_w (abfd, value)
+ bfd *abfd;
+ unsigned int value;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (6, "image_write_w(%04x)\n", (int)value);
+#endif
+
+ if (PRIV(is_vax) && check_section (abfd, 2))
+ return;
+
+ bfd_putl16 (value, PRIV(image_ptr));
+ PRIV(image_ptr) += 2;
+
+ return;
+}
+
+
+/* Write 4-byte long to image */
+
+static void
+image_write_l (abfd, value)
+ bfd *abfd;
+ unsigned long value;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (6, "image_write_l (%08lx)\n", value);
+#endif
+
+ if (PRIV(is_vax) && check_section (abfd, 4))
+ return;
+
+ bfd_putl32 (value, PRIV(image_ptr));
+ PRIV(image_ptr) += 4;
+
+ return;
+}
+
+
+/* Write 8-byte quad to image */
+
+static void
+image_write_q (abfd, value)
+ bfd *abfd;
+ uquad value;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (6, "image_write_q (%016lx)\n", value);
+#endif
+
+ if (PRIV(is_vax) && check_section (abfd, 8))
+ return;
+
+ bfd_putl64 (value, PRIV(image_ptr));
+ PRIV(image_ptr) += 8;
+
+ return;
+}
+
+
+#define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
+
+/* etir_sta
+
+ vms stack commands
+
+ handle sta_xxx commands in etir section
+ ptr points to data area in record
+
+ see table B-8 of the openVMS linker manual */
+
+static boolean
+etir_sta (abfd, cmd, ptr)
+ bfd *abfd;
+ int cmd;
+ unsigned char *ptr;
+{
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "etir_sta %d/%x\n", cmd, cmd);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ switch (cmd)
+ {
+ /* stack */
+
+ /* stack global
+ arg: cs symbol name
+
+ stack 32 bit value of symbol (high bits set to 0) */
+
+ case ETIR_S_C_STA_GBL:
+ {
+ char *name;
+ vms_symbol_entry *entry;
+
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = (vms_symbol_entry *)
+ bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+#if VMS_DEBUG
+ _bfd_vms_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name);
+#endif
+ _bfd_vms_push (abfd, (uquad)0, -1);
+ }
+ else
+ {
+ _bfd_vms_push (abfd, (uquad)(entry->symbol->value), -1);
+ }
+ }
+ break;
+
+ /* stack longword
+ arg: lw value
+
+ stack 32 bit value, sign extend to 64 bit */
+
+ case ETIR_S_C_STA_LW:
+ _bfd_vms_push (abfd, (uquad)bfd_getl32 (ptr), -1);
+ break;
+
+ /* stack global
+ arg: qw value
+
+ stack 64 bit value of symbol */
+
+ case ETIR_S_C_STA_QW:
+ _bfd_vms_push (abfd, (uquad)bfd_getl64(ptr), -1);
+ break;
+
+ /* stack psect base plus quadword offset
+ arg: lw section index
+ qw signed quadword offset (low 32 bits)
+
+ stack qw argument and section index
+ (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */
+
+ case ETIR_S_C_STA_PQ:
+ {
+ uquad dummy;
+ int psect;
+
+ psect = bfd_getl32 (ptr);
+ if (psect >= PRIV(section_count))
+ {
+ (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ"));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ dummy = bfd_getl64 (ptr+4);
+ _bfd_vms_push (abfd, dummy, psect);
+ }
+ break;
+
+ /* all not supported */
+
+ case ETIR_S_C_STA_LI:
+ case ETIR_S_C_STA_MOD:
+ case ETIR_S_C_STA_CKARG:
+
+ (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd);
+ return false;
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd);
+ return false;
+ break;
+ }
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "etir_sta true\n");
+#endif
+ return true;
+}
+
+
+/*
+ etir_sto
+
+ vms store commands
+
+ handle sto_xxx commands in etir section
+ ptr points to data area in record
+
+ see table B-9 of the openVMS linker manual */
+
+static boolean
+etir_sto (abfd, cmd, ptr)
+ bfd *abfd;
+ int cmd;
+ unsigned char *ptr;
+{
+ uquad dummy;
+ int psect;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "etir_sto %d/%x\n", cmd, cmd);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ switch (cmd)
+ {
+
+ /* store byte: pop stack, write byte
+ arg: - */
+
+ case ETIR_S_C_STO_B:
+ dummy = _bfd_vms_pop (abfd, &psect);
+#if 0
+ if (is_share) /* FIXME */
+ (*_bfd_error_handler) ("ETIR_S_C_STO_B: byte fixups not supported");
+#endif
+ image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
+ break;
+
+ /* store word: pop stack, write word
+ arg: - */
+
+ case ETIR_S_C_STO_W:
+ dummy = _bfd_vms_pop (abfd, &psect);
+#if 0
+ if (is_share) /* FIXME */
+ (*_bfd_error_handler) ("ETIR_S_C_STO_B: word fixups not supported");
+#endif
+ image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
+ break;
+
+ /* store longword: pop stack, write longword
+ arg: - */
+
+ case ETIR_S_C_STO_LW:
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy += (PRIV(sections)[psect])->vma;
+ image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
+ break;
+
+ /* store quadword: pop stack, write quadword
+ arg: - */
+
+ case ETIR_S_C_STO_QW:
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy += (PRIV(sections)[psect])->vma;
+ image_write_q (abfd, dummy); /* FIXME: check top bits */
+ break;
+
+ /* store immediate repeated: pop stack for repeat count
+ arg: lw byte count
+ da data */
+
+ case ETIR_S_C_STO_IMMR:
+ {
+ unsigned long size;
+
+ size = bfd_getl32 (ptr);
+ dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ while (dummy-- > 0L)
+ image_dump (abfd, ptr+4, size, 0);
+ }
+ break;
+
+ /* store global: write symbol value
+ arg: cs global symbol name */
+
+ case ETIR_S_C_STO_GBL:
+ {
+ vms_symbol_entry *entry;
+ char *name;
+
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+ (*_bfd_error_handler) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""),
+ name);
+ return false;
+ }
+ else
+ image_write_q (abfd, (uquad)(entry->symbol->value)); /* FIXME, reloc */
+ }
+ break;
+
+ /* store code address: write address of entry point
+ arg: cs global symbol name (procedure) */
+
+ case ETIR_S_C_STO_CA:
+ {
+ vms_symbol_entry *entry;
+ char *name;
+
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+ (*_bfd_error_handler) (_("ETIR_S_C_STO_CA: no symbol \"%s\""),
+ name);
+ return false;
+ }
+ else
+ image_write_q (abfd, (uquad)(entry->symbol->value)); /* FIXME, reloc */
+ }
+ break;
+
+ /* not supported */
+
+ case ETIR_S_C_STO_RB:
+ case ETIR_S_C_STO_AB:
+ (*_bfd_error_handler) (_("ETIR_S_C_STO_RB/AB: Not supported"));
+ break;
+
+ /* store offset to psect: pop stack, add low 32 bits to base of psect
+ arg: - */
+
+ case ETIR_S_C_STO_OFF:
+ {
+ uquad q;
+ int psect;
+
+ q = _bfd_vms_pop (abfd, &psect);
+ q += (PRIV(sections)[psect])->vma;
+ image_write_q (abfd, q);
+ }
+ break;
+
+ /* store immediate
+ arg: lw count of bytes
+ da data */
+
+ case ETIR_S_C_STO_IMM:
+ {
+ int size;
+
+ size = bfd_getl32 (ptr);
+ image_dump (abfd, ptr+4, size, 0);
+ }
+ break;
+
+ /* this code is 'reserved to digital' according to the openVMS linker manual,
+ however it is generated by the DEC C compiler and defined in the include file.
+ FIXME, since the following is just a guess
+ store global longword: store 32bit value of symbol
+ arg: cs symbol name */
+
+ case ETIR_S_C_STO_GBL_LW:
+ {
+ vms_symbol_entry *entry;
+ char *name;
+
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
+ if (entry == (vms_symbol_entry *)NULL)
+ {
+#if VMS_DEBUG
+ _bfd_vms_debug (3, "ETIR_S_C_STO_GBL_LW: no symbol \"%s\"\n", name);
+#endif
+ image_write_l (abfd, (unsigned long)0); /* FIXME, reloc */
+ }
+ else
+ image_write_l (abfd, (unsigned long)(entry->symbol->value)); /* FIXME, reloc */
+ }
+ break;
+
+ /* not supported */
+
+ case ETIR_S_C_STO_LP_PSB:
+ (*_bfd_error_handler) (_("ETIR_S_C_STO_LP_PSB: Not supported"));
+ break;
+
+ /* */
+
+ case ETIR_S_C_STO_HINT_GBL:
+ (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));
+ break;
+
+ /* */
+
+ case ETIR_S_C_STO_HINT_PS:
+ (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_PS: not implemented"));
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved STO cmd %d"), cmd);
+ break;
+ }
+
+ return true;
+}
+
+/* stack operator commands
+ all 32 bit signed arithmetic
+ all word just like a stack calculator
+ arguments are popped from stack, results are pushed on stack
+
+ see table B-10 of the openVMS linker manual */
+
+static boolean
+etir_opr (abfd, cmd, ptr)
+ bfd *abfd;
+ int cmd;
+ unsigned char *ptr;
+{
+ long op1, op2;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "etir_opr %d/%x\n", cmd, cmd);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ switch (cmd)
+ {
+ /* operation */
+
+ /* no-op */
+
+ case ETIR_S_C_OPR_NOP:
+ break;
+
+ /* add */
+
+ case ETIR_S_C_OPR_ADD:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op1 + op2), -1);
+ break;
+
+ /* subtract */
+
+ case ETIR_S_C_OPR_SUB:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op2 - op1), -1);
+ break;
+
+ /* multiply */
+
+ case ETIR_S_C_OPR_MUL:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op1 * op2), -1);
+ break;
+
+ /* divide */
+
+ case ETIR_S_C_OPR_DIV:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ if (op2 == 0)
+ _bfd_vms_push (abfd, (uquad)0L, -1);
+ else
+ _bfd_vms_push (abfd, (uquad)(op2 / op1), -1);
+ break;
+
+ /* logical and */
+
+ case ETIR_S_C_OPR_AND:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op1 & op2), -1);
+ break;
+
+ /* logical inclusive or */
+
+ case ETIR_S_C_OPR_IOR:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op1 | op2), -1);
+ break;
+
+ /* logical exclusive or */
+
+ case ETIR_S_C_OPR_EOR:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op1 ^ op2), -1);
+ break;
+
+ /* negate */
+
+ case ETIR_S_C_OPR_NEG:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(-op1), -1);
+ break;
+
+ /* complement */
+
+ case ETIR_S_C_OPR_COM:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)(op1 ^ -1L), -1);
+ break;
+
+ /* insert field */
+
+ case ETIR_S_C_OPR_INSV:
+ (void)_bfd_vms_pop (abfd, NULL);
+ (*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported"));
+ break;
+
+ /* arithmetic shift */
+
+ case ETIR_S_C_OPR_ASH:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ if (op2 < 0) /* shift right */
+ op1 >>= -op2;
+ else /* shift left */
+ op1 <<= op2;
+ _bfd_vms_push (abfd, (uquad)op1, -1);
+ break;
+
+ /* unsigned shift */
+
+ case ETIR_S_C_OPR_USH:
+ (*_bfd_error_handler) (_("ETIR_S_C_OPR_USH: Not supported"));
+ break;
+
+ /* rotate */
+
+ case ETIR_S_C_OPR_ROT:
+ (*_bfd_error_handler) (_("ETIR_S_C_OPR_ROT: Not supported"));
+ break;
+
+ /* select */
+
+ case ETIR_S_C_OPR_SEL:
+ if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
+ (void)_bfd_vms_pop (abfd, NULL);
+ else
+ {
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ (void)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad)op1, -1);
+ }
+ break;
+
+ /* redefine symbol to current location */
+
+ case ETIR_S_C_OPR_REDEF:
+ (*_bfd_error_handler) (_("ETIR_S_C_OPR_REDEF: Not supported"));
+ break;
+
+ /* define a literal */
+
+ case ETIR_S_C_OPR_DFLIT:
+ (*_bfd_error_handler) (_("ETIR_S_C_OPR_DFLIT: Not supported"));
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved OPR cmd %d"), cmd);
+ break;
+ }
+
+ return true;
+}
+
+
+/* control commands
+
+ see table B-11 of the openVMS linker manual */
+
+static boolean
+etir_ctl (abfd, cmd, ptr)
+ bfd *abfd;
+ int cmd;
+ unsigned char *ptr;
+{
+ uquad dummy;
+ int psect;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "etir_ctl %d/%x\n", cmd, cmd);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ switch (cmd)
+ {
+ /* set relocation base: pop stack, set image location counter
+ arg: - */
+
+ case ETIR_S_C_CTL_SETRB:
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_set_ptr (abfd, psect, dummy);
+ break;
+
+ /* augment relocation base: increment image location counter by offset
+ arg: lw offset value */
+
+ case ETIR_S_C_CTL_AUGRB:
+ dummy = bfd_getl32 (ptr);
+ image_inc_ptr (abfd, dummy);
+ break;
+
+ /* define location: pop index, save location counter under index
+ arg: - */
+
+ case ETIR_S_C_CTL_DFLOC:
+ dummy = _bfd_vms_pop (abfd, NULL);
+ /* FIXME */
+ break;
+
+ /* set location: pop index, restore location counter from index
+ arg: - */
+
+ case ETIR_S_C_CTL_STLOC:
+ dummy = _bfd_vms_pop (abfd, &psect);
+ /* FIXME */
+ break;
+
+ /* stack defined location: pop index, push location counter from index
+ arg: - */
+
+ case ETIR_S_C_CTL_STKDL:
+ dummy = _bfd_vms_pop (abfd, &psect);
+ /* FIXME */
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved CTL cmd %d"), cmd);
+ break;
+ }
+ return true;
+}
+
+
+/* store conditional commands
+
+ see table B-12 and B-13 of the openVMS linker manual */
+
+static boolean
+etir_stc (abfd, cmd, ptr)
+ bfd *abfd;
+ int cmd;
+ unsigned char *ptr;
+{
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "etir_stc %d/%x\n", cmd, cmd);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ switch (cmd)
+ {
+ /* 200 Store-conditional Linkage Pair
+ arg: */
+
+ case ETIR_S_C_STC_LP:
+ (*_bfd_error_handler) (_("ETIR_S_C_STC_LP: not supported"));
+ break;
+
+ /* 201 Store-conditional Linkage Pair with Procedure Signature
+ arg: lw linkage index
+ cs procedure name
+ by signature length
+ da signature */
+
+ case ETIR_S_C_STC_LP_PSB:
+ image_inc_ptr (abfd, 16); /* skip entry,procval */
+ break;
+
+ /* 202 Store-conditional Address at global address
+ arg: lw linkage index
+ cs global name */
+
+ case ETIR_S_C_STC_GBL:
+ (*_bfd_error_handler) (_("ETIR_S_C_STC_GBL: not supported"));
+ break;
+
+ /* 203 Store-conditional Code Address at global address
+ arg: lw linkage index
+ cs procedure name */
+
+ case ETIR_S_C_STC_GCA:
+ (*_bfd_error_handler) (_("ETIR_S_C_STC_GCA: not supported"));
+ break;
+
+ /* 204 Store-conditional Address at psect + offset
+ arg: lw linkage index
+ lw psect index
+ qw offset */
+
+ case ETIR_S_C_STC_PS:
+ (*_bfd_error_handler) (_("ETIR_S_C_STC_PS: not supported"));
+ break;
+
+ /* 205 Store-conditional NOP at address of global
+ arg: */
+
+ case ETIR_S_C_STC_NOP_GBL:
+
+ /* 206 Store-conditional NOP at pect + offset
+ arg: */
+
+ case ETIR_S_C_STC_NOP_PS:
+
+ /* 207 Store-conditional BSR at global address
+ arg: */
+
+ case ETIR_S_C_STC_BSR_GBL:
+
+ /* 208 Store-conditional BSR at pect + offset
+ arg: */
+
+ case ETIR_S_C_STC_BSR_PS:
+
+ /* 209 Store-conditional LDA at global address
+ arg: */
+
+ case ETIR_S_C_STC_LDA_GBL:
+
+ /* 210 Store-conditional LDA at psect + offset
+ arg: */
+
+ case ETIR_S_C_STC_LDA_PS:
+
+ /* 211 Store-conditional BSR or Hint at global address
+ arg: */
+
+ case ETIR_S_C_STC_BOH_GBL:
+
+ /* 212 Store-conditional BSR or Hint at pect + offset
+ arg: */
+
+ case ETIR_S_C_STC_BOH_PS:
+
+ /* 213 Store-conditional NOP,BSR or HINT at global address
+ arg: */
+
+ case ETIR_S_C_STC_NBH_GBL:
+
+ /* 214 Store-conditional NOP,BSR or HINT at psect + offset
+ arg: */
+
+ case ETIR_S_C_STC_NBH_PS:
+/* FIXME (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */
+ break;
+
+ default:
+#if VMS_DEBUG
+ _bfd_vms_debug (3, "Reserved STC cmd %d", cmd);
+#endif
+ break;
+ }
+ return true;
+}
+
+
+static asection *
+new_section (abfd, idx)
+ bfd *abfd;
+ int idx;
+{
+ asection *section;
+ char sname[16];
+ char *name;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "new_section %d\n", idx);
+#endif
+ sprintf (sname, SECTION_NAME_TEMPLATE, idx);
+
+ name = bfd_malloc (strlen (sname) + 1);
+ if (name == 0)
+ return 0;
+ strcpy (name, sname);
+
+ section = bfd_malloc (sizeof (asection));
+ if (section == 0)
+ {
+#if VMS_DEBUG
+ _bfd_vms_debug (6, "bfd_make_section (%s) failed", name);
+#endif
+ return 0;
+ }
+
+ section->_raw_size = 0;
+ section->vma = 0;
+ section->contents = 0;
+ section->_cooked_size = 0;
+ section->name = name;
+ section->index = idx;
+
+ return section;
+}
+
+
+static int
+alloc_section (abfd, idx)
+ bfd *abfd;
+ int idx;
+{
+ asection *section;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "alloc_section %d\n", idx);
+#endif
+
+ PRIV(sections) = ((asection **)
+ bfd_realloc (PRIV(sections), (idx+1) * sizeof (asection *)));
+ if (PRIV(sections) == 0)
+ return -1;
+
+ while (PRIV(section_count) <= idx)
+ {
+ PRIV(sections)[PRIV(section_count)] = new_section (abfd, PRIV(section_count));
+ if (PRIV(sections)[PRIV(section_count)] == 0)
+ return -1;
+ PRIV(section_count)++;
+ }
+
+ return 0;
+}
+
+
+/*
+ * tir_sta
+ *
+ * vax stack commands
+ *
+ * handle sta_xxx commands in tir section
+ * ptr points to data area in record
+ *
+ * see table 7-3 of the VAX/VMS linker manual
+ */
+
+static unsigned char *
+tir_sta (bfd *abfd, unsigned char *ptr)
+{
+ int cmd = *ptr++;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "tir_sta %d\n", cmd);
+#endif
+
+ switch (cmd)
+ {
+ /* stack */
+ case TIR_S_C_STA_GBL:
+ /*
+ * stack global
+ * arg: cs symbol name
+ *
+ * stack 32 bit value of symbol (high bits set to 0)
+ */
+ {
+ char *name;
+ vms_symbol_entry *entry;
+
+ name = _bfd_vms_save_counted_string (ptr);
+
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *)NULL)
+ return 0;
+
+ _bfd_vms_push (abfd, (unsigned long)(entry->symbol->value), -1);
+ ptr += *ptr + 1;
+ }
+ break;
+
+ case TIR_S_C_STA_SB:
+ /*
+ * stack signed byte
+ * arg: by value
+ *
+ * stack byte value, sign extend to 32 bit
+ */
+ _bfd_vms_push (abfd, (long)*ptr++, -1);
+ break;
+
+ case TIR_S_C_STA_SW:
+ /*
+ * stack signed short word
+ * arg: sh value
+ *
+ * stack 16 bit value, sign extend to 32 bit
+ */
+ _bfd_vms_push (abfd, (long)bfd_getl16(ptr), -1);
+ ptr += 2;
+ break;
+
+ case TIR_S_C_STA_LW:
+ /*
+ * stack signed longword
+ * arg: lw value
+ *
+ * stack 32 bit value
+ */
+ _bfd_vms_push (abfd, (long)bfd_getl32 (ptr), -1);
+ ptr += 4;
+ break;
+
+ case TIR_S_C_STA_PB:
+ case TIR_S_C_STA_WPB:
+ /*
+ * stack psect base plus byte offset (word index)
+ * arg: by section index
+ * (sh section index)
+ * by signed byte offset
+ *
+ */
+ {
+ unsigned long dummy;
+ int psect;
+
+ if (cmd == TIR_S_C_STA_PB)
+ psect = *ptr++;
+ else
+ {
+ psect = bfd_getl16(ptr);
+ ptr += 2;
+ }
+
+ if (psect >= PRIV(section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+
+ dummy = (long)*ptr++;
+ dummy += (PRIV(sections)[psect])->vma;
+ _bfd_vms_push (abfd, dummy, psect);
+ }
+ break;
+
+ case TIR_S_C_STA_PW:
+ case TIR_S_C_STA_WPW:
+ /*
+ * stack psect base plus word offset (word index)
+ * arg: by section index
+ * (sh section index)
+ * sh signed short offset
+ *
+ */
+ {
+ unsigned long dummy;
+ int psect;
+
+ if (cmd == TIR_S_C_STA_PW)
+ psect = *ptr++;
+ else
+ {
+ psect = bfd_getl16(ptr);
+ ptr += 2;
+ }
+
+ if (psect >= PRIV(section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+
+ dummy = bfd_getl16(ptr); ptr+=2;
+ dummy += (PRIV(sections)[psect])->vma;
+ _bfd_vms_push (abfd, dummy, psect);
+ }
+ break;
+
+ case TIR_S_C_STA_PL:
+ case TIR_S_C_STA_WPL:
+ /*
+ * stack psect base plus long offset (word index)
+ * arg: by section index
+ * (sh section index)
+ * lw signed longword offset
+ *
+ */
+ {
+ unsigned long dummy;
+ int psect;
+
+ if (cmd == TIR_S_C_STA_PL)
+ psect = *ptr++;
+ else
+ {
+ psect = bfd_getl16(ptr);
+ ptr += 2;
+ }
+
+ if (psect >= PRIV(section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+
+ dummy = bfd_getl32 (ptr); ptr += 4;
+ dummy += (PRIV(sections)[psect])->vma;
+ _bfd_vms_push (abfd, dummy, psect);
+ }
+ break;
+
+ case TIR_S_C_STA_UB:
+ /*
+ * stack unsigned byte
+ * arg: by value
+ *
+ * stack byte value
+ */
+ _bfd_vms_push (abfd, (unsigned long)*ptr++, -1);
+ break;
+
+ case TIR_S_C_STA_UW:
+ /*
+ * stack unsigned short word
+ * arg: sh value
+ *
+ * stack 16 bit value
+ */
+ _bfd_vms_push (abfd, (unsigned long)bfd_getl16(ptr), -1);
+ ptr += 2;
+ break;
+
+ case TIR_S_C_STA_BFI:
+ /*
+ * stack byte from image
+ * arg: -
+ *
+ */
+ /*FALLTHRU*/
+ case TIR_S_C_STA_WFI:
+ /*
+ * stack byte from image
+ * arg: -
+ *
+ */
+ /*FALLTHRU*/
+ case TIR_S_C_STA_LFI:
+ /*
+ * stack byte from image
+ * arg: -
+ *
+ */
+ (*_bfd_error_handler) (_("Stack-from-image not implemented"));
+ return NULL;
+
+ case TIR_S_C_STA_EPM:
+ /*
+ * stack entry point mask
+ * arg: cs symbol name
+ *
+ * stack (unsigned) entry point mask of symbol
+ * err if symbol is no entry point
+ */
+ {
+ char *name;
+ vms_symbol_entry *entry;
+
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *)NULL)
+ return 0;
+
+ (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented"));
+ _bfd_vms_push (abfd, 0L, -1);
+ ptr += *ptr + 1;
+ }
+ break;
+
+ case TIR_S_C_STA_CKARG:
+ /*
+ * compare procedure argument
+ * arg: cs symbol name
+ * by argument index
+ * da argument descriptor
+ *
+ * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
+ * and stack TRUE (args match) or FALSE (args dont match) value
+ */
+ (*_bfd_error_handler) (_("PASSMECH not fully implemented"));
+ _bfd_vms_push (abfd, 1L, -1);
+ break;
+
+ case TIR_S_C_STA_LSY:
+ /*
+ * stack local symbol value
+ * arg: sh environment index
+ * cs symbol name
+ */
+ {
+ int envidx;
+ char *name;
+ vms_symbol_entry *entry;
+
+ envidx = bfd_getl16(ptr); ptr += 2;
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *)NULL)
+ return 0;
+ (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented"));
+ _bfd_vms_push (abfd, 0L, -1);
+ ptr += *ptr + 1;
+ }
+ break;
+
+ case TIR_S_C_STA_LIT:
+ /*
+ * stack literal
+ * arg: by literal index
+ *
+ * stack literal
+ */
+ ptr++;
+ _bfd_vms_push (abfd, 0L, -1);
+ (*_bfd_error_handler) (_("Stack-literal not fully implemented"));
+ break;
+
+ case TIR_S_C_STA_LEPM:
+ /*
+ * stack local symbol entry point mask
+ * arg: sh environment index
+ * cs symbol name
+ *
+ * stack (unsigned) entry point mask of symbol
+ * err if symbol is no entry point
+ */
+ {
+ int envidx;
+ char *name;
+ vms_symbol_entry *entry;
+
+ envidx = bfd_getl16(ptr); ptr += 2;
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *)NULL)
+ return 0;
+ (*_bfd_error_handler) (_("Stack-local-symbol-entry-point-mask not fully implemented"));
+ _bfd_vms_push (abfd, 0L, -1);
+ ptr += *ptr + 1;
+ }
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved STA cmd %d"), ptr[-1]);
+ return NULL;
+ break;
+ }
+
+ return ptr;
+}
+
+
+/*
+ * tir_sto
+ *
+ * vax store commands
+ *
+ * handle sto_xxx commands in tir section
+ * ptr points to data area in record
+ *
+ * see table 7-4 of the VAX/VMS linker manual
+ */
+
+static unsigned char *
+tir_sto (bfd *abfd, unsigned char *ptr)
+{
+ unsigned long dummy;
+ int size;
+ int psect;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "tir_sto %d\n", *ptr);
+#endif
+
+ switch (*ptr++)
+ {
+ case TIR_S_C_STO_SB:
+ /*
+ * store signed byte: pop stack, write byte
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_SW:
+ /*
+ * store signed word: pop stack, write word
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_LW:
+ /*
+ * store longword: pop stack, write longword
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_BD:
+ /*
+ * store byte displaced: pop stack, sub lc+1, write byte
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy -= ((PRIV(sections)[psect])->vma + 1);
+ image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_WD:
+ /*
+ * store word displaced: pop stack, sub lc+2, write word
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy -= ((PRIV(sections)[psect])->vma + 2);
+ image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */
+ break;
+ case TIR_S_C_STO_LD:
+ /*
+ * store long displaced: pop stack, sub lc+4, write long
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy -= ((PRIV(sections)[psect])->vma + 4);
+ image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
+ break;
+ case TIR_S_C_STO_LI:
+ /*
+ * store short literal: pop stack, write byte
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
+ break;
+ case TIR_S_C_STO_PIDR:
+ /*
+ * store position independent data reference: pop stack, write longword
+ * arg: -
+ * FIXME: incomplete !
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_l (abfd, dummy & 0xffffffff);
+ break;
+ case TIR_S_C_STO_PICR:
+ /*
+ * store position independent code reference: pop stack, write longword
+ * arg: -
+ * FIXME: incomplete !
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_b (abfd, 0x9f);
+ image_write_l (abfd, dummy & 0xffffffff);
+ break;
+ case TIR_S_C_STO_RIVB:
+ /*
+ * store repeated immediate variable bytes
+ * 1-byte count n field followed by n bytes of data
+ * pop stack, write n bytes <stack> times
+ */
+ size = *ptr++;
+ dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ while (dummy-- > 0L)
+ image_dump (abfd, ptr, size, 0);
+ ptr += size;
+ break;
+ case TIR_S_C_STO_B:
+ /*
+ * store byte from top longword
+ */
+ dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ image_write_b (abfd, dummy & 0xff);
+ break;
+ case TIR_S_C_STO_W:
+ /*
+ * store word from top longword
+ */
+ dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ image_write_w (abfd, dummy & 0xffff);
+ break;
+ case TIR_S_C_STO_RB:
+ /*
+ * store repeated byte from top longword
+ */
+ size = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ while (size-- > 0)
+ image_write_b (abfd, dummy & 0xff);
+ break;
+ case TIR_S_C_STO_RW:
+ /*
+ * store repeated word from top longword
+ */
+ size = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ while (size-- > 0)
+ image_write_w (abfd, dummy & 0xffff);
+ break;
+
+ case TIR_S_C_STO_RSB:
+ case TIR_S_C_STO_RSW:
+ case TIR_S_C_STO_RL:
+ case TIR_S_C_STO_VPS:
+ case TIR_S_C_STO_USB:
+ case TIR_S_C_STO_USW:
+ case TIR_S_C_STO_RUB:
+ case TIR_S_C_STO_RUW:
+ case TIR_S_C_STO_PIRR:
+ (*_bfd_error_handler) (_("Unimplemented STO cmd %d"), ptr[-1]);
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved STO cmd %d"), ptr[-1]);
+ break;
+ }
+
+ return ptr;
+}
+
+
+/*
+ * stack operator commands
+ * all 32 bit signed arithmetic
+ * all word just like a stack calculator
+ * arguments are popped from stack, results are pushed on stack
+ *
+ * see table 7-5 of the VAX/VMS linker manual
+ */
+
+static unsigned char *
+tir_opr (bfd *abfd, unsigned char *ptr)
+{
+ long op1, op2;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "tir_opr %d\n", *ptr);
+#endif
+
+ switch (*ptr++)
+ {
+ /* operation */
+ case TIR_S_C_OPR_NOP:
+ /*
+ * no-op
+ */
+ break;
+
+ case TIR_S_C_OPR_ADD:
+ /*
+ * add
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op1 + op2), -1);
+ break;
+
+ case TIR_S_C_OPR_SUB:
+ /*
+ * subtract
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op2 - op1), -1);
+ break;
+
+ case TIR_S_C_OPR_MUL:
+ /*
+ * multiply
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op1 * op2), -1);
+ break;
+
+ case TIR_S_C_OPR_DIV:
+ /*
+ * divide
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ if (op2 == 0)
+ _bfd_vms_push (abfd, (unsigned long)0L, -1);
+ else
+ _bfd_vms_push (abfd, (unsigned long)(op2 / op1), -1);
+ break;
+
+ case TIR_S_C_OPR_AND:
+ /*
+ * logical and
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op1 & op2), -1);
+ break;
+
+ case TIR_S_C_OPR_IOR:
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ /*
+ * logical inclusive or
+ */
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op1 | op2), -1);
+ break;
+
+ case TIR_S_C_OPR_EOR:
+ /*
+ * logical exclusive or
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op1 ^ op2), -1);
+ break;
+
+ case TIR_S_C_OPR_NEG:
+ /*
+ * negate
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(-op1), -1);
+ break;
+
+ case TIR_S_C_OPR_COM:
+ /*
+ * complement
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)(op1 ^ -1L), -1);
+ break;
+
+ case TIR_S_C_OPR_INSV:
+ /*
+ * insert field
+ */
+ (void)_bfd_vms_pop (abfd, NULL);
+ (*_bfd_error_handler) ("TIR_S_C_OPR_INSV incomplete");
+ break;
+
+ case TIR_S_C_OPR_ASH:
+ /*
+ * arithmetic shift
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ if (HIGHBIT(op1)) /* shift right */
+ op2 >>= op1;
+ else /* shift left */
+ op2 <<= op1;
+ _bfd_vms_push (abfd, (unsigned long)op2, -1);
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_ASH incomplete"));
+ break;
+
+ case TIR_S_C_OPR_USH:
+ /*
+ * unsigned shift
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ if (HIGHBIT(op1)) /* shift right */
+ op2 >>= op1;
+ else /* shift left */
+ op2 <<= op1;
+ _bfd_vms_push (abfd, (unsigned long)op2, -1);
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_USH incomplete"));
+ break;
+
+ case TIR_S_C_OPR_ROT:
+ /*
+ * rotate
+ */
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op2 = (long)_bfd_vms_pop (abfd, NULL);
+ if (HIGHBIT(0)) /* shift right */
+ op2 >>= op1;
+ else /* shift left */
+ op2 <<= op1;
+ _bfd_vms_push (abfd, (unsigned long)op2, -1);
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_ROT incomplete"));
+ break;
+
+ case TIR_S_C_OPR_SEL:
+ /*
+ * select
+ */
+ if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
+ (void)_bfd_vms_pop (abfd, NULL);
+ else
+ {
+ op1 = (long)_bfd_vms_pop (abfd, NULL);
+ (void)_bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (unsigned long)op1, -1);
+ }
+ break;
+
+ case TIR_S_C_OPR_REDEF:
+ /*
+ * redefine symbol to current location
+ */
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_REDEF not supported"));
+ break;
+
+ case TIR_S_C_OPR_DFLIT:
+ /*
+ * define a literal
+ */
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_DFLIT not supported"));
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved OPR cmd %d"), ptr[-1]);
+ break;
+ }
+
+ return ptr;
+}
+
+
+static unsigned char *
+tir_ctl (bfd *abfd, unsigned char *ptr)
+/*
+ * control commands
+ *
+ * see table 7-6 of the VAX/VMS linker manual
+ */
+{
+ unsigned long dummy;
+ int psect;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (5, "tir_ctl %d\n", *ptr);
+#endif
+
+ switch (*ptr++)
+ {
+ case TIR_S_C_CTL_SETRB:
+ /*
+ * set relocation base: pop stack, set image location counter
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ if (psect >= PRIV(section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+ image_set_ptr (abfd, psect, dummy);
+ break;
+ case TIR_S_C_CTL_AUGRB:
+ /*
+ * augment relocation base: increment image location counter by offset
+ * arg: lw offset value
+ */
+ dummy = bfd_getl32 (ptr);
+ image_inc_ptr (abfd, dummy);
+ break;
+ case TIR_S_C_CTL_DFLOC:
+ /*
+ * define location: pop index, save location counter under index
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, NULL);
+ (*_bfd_error_handler) (_("TIR_S_C_CTL_DFLOC not fully implemented"));
+ break;
+ case TIR_S_C_CTL_STLOC:
+ /*
+ * set location: pop index, restore location counter from index
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ (*_bfd_error_handler) (_("TIR_S_C_CTL_STLOC not fully implemented"));
+ break;
+ case TIR_S_C_CTL_STKDL:
+ /*
+ * stack defined location: pop index, push location counter from index
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ (*_bfd_error_handler) (_("TIR_S_C_CTL_STKDL not fully implemented"));
+ break;
+ default:
+ (*_bfd_error_handler) (_("Reserved CTL cmd %d"), ptr[-1]);
+ break;
+ }
+ return ptr;
+}
+
+
+/*
+ * handle command from TIR section
+ */
+
+static unsigned char *
+tir_cmd (bfd *abfd, unsigned char *ptr)
+{
+ struct {
+ int mincod;
+ int maxcod;
+ unsigned char * (*explain)(bfd *, unsigned char *);
+ } tir_table[] = {
+ { 0, TIR_S_C_MAXSTACOD, tir_sta }
+ ,{ TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto }
+ ,{ TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr }
+ ,{ TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl }
+ ,{ -1, -1, NULL }
+ };
+ int i = 0;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "tir_cmd %d/%x\n", *ptr, *ptr);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ if (*ptr & 0x80) /* store immediate */
+ {
+ i = 128 - (*ptr++ & 0x7f);
+ image_dump (abfd, ptr, i, 0);
+ ptr += i;
+ }
+ else
+ {
+ while (tir_table[i].mincod >= 0)
+ {
+ if ( (tir_table[i].mincod <= *ptr)
+ && (*ptr <= tir_table[i].maxcod))
+ {
+ ptr = tir_table[i].explain (abfd, ptr);
+ break;
+ }
+ i++;
+ }
+ if (tir_table[i].mincod < 0)
+ {
+ (*_bfd_error_handler) (_("Obj code %d not found"), *ptr);
+ ptr = 0;
+ }
+ }
+
+ return ptr;
+}
+
+
+/* handle command from ETIR section */
+
+static int
+etir_cmd (abfd, cmd, ptr)
+ bfd *abfd;
+ int cmd;
+ unsigned char *ptr;
+{
+ static struct {
+ int mincod;
+ int maxcod;
+ boolean (*explain) PARAMS((bfd *, int, unsigned char *));
+ } etir_table[] = {
+ { ETIR_S_C_MINSTACOD, ETIR_S_C_MAXSTACOD, etir_sta },
+ { ETIR_S_C_MINSTOCOD, ETIR_S_C_MAXSTOCOD, etir_sto },
+ { ETIR_S_C_MINOPRCOD, ETIR_S_C_MAXOPRCOD, etir_opr },
+ { ETIR_S_C_MINCTLCOD, ETIR_S_C_MAXCTLCOD, etir_ctl },
+ { ETIR_S_C_MINSTCCOD, ETIR_S_C_MAXSTCCOD, etir_stc },
+ { -1, -1, NULL }
+ };
+
+ int i = 0;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "etir_cmd %d/%x\n", cmd, cmd);
+ _bfd_hexdump (8, ptr, 16, (int)ptr);
+#endif
+
+ while (etir_table[i].mincod >= 0)
+ {
+ if ( (etir_table[i].mincod <= cmd)
+ && (cmd <= etir_table[i].maxcod))
+ {
+ if (!etir_table[i].explain (abfd, cmd, ptr))
+ return -1;
+ break;
+ }
+ i++;
+ }
+
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "etir_cmd: = 0\n");
+#endif
+ return 0;
+}
+
+
+/* Text Information and Relocation Records (OBJ$C_TIR)
+ handle tir record */
+
+static int
+analyze_tir (abfd, ptr, length)
+ bfd *abfd;
+ unsigned char *ptr;
+ unsigned int length;
+{
+ unsigned char *maxptr;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (3, "analyze_tir: %d bytes\n", length);
+#endif
+
+ maxptr = ptr + length;
+
+ while (ptr < maxptr)
+ {
+ ptr = tir_cmd (abfd, ptr);
+ if (ptr == 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/* Text Information and Relocation Records (EOBJ$C_ETIR)
+ handle etir record */
+
+static int
+analyze_etir (abfd, ptr, length)
+ bfd *abfd;
+ unsigned char *ptr;
+ unsigned int length;
+{
+ int cmd;
+ unsigned char *maxptr;
+ int result = 0;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (3, "analyze_etir: %d bytes\n", length);
+#endif
+
+ maxptr = ptr + length;
+
+ while (ptr < maxptr)
+ {
+ cmd = bfd_getl16 (ptr);
+ length = bfd_getl16 (ptr + 2);
+ result = etir_cmd (abfd, cmd, ptr+4);
+ if (result != 0)
+ break;
+ ptr += length;
+ }
+
+#if VMS_DEBUG
+ _bfd_vms_debug (3, "analyze_etir: = %d\n", result);
+#endif
+
+ return result;
+}
+
+
+/* process ETIR record
+
+ return 0 on success, -1 on error */
+
+int
+_bfd_vms_slurp_tir (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+ int result;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "TIR/ETIR\n");
+#endif
+
+ switch (objtype)
+ {
+ case EOBJ_S_C_ETIR:
+ PRIV(vms_rec) += 4; /* skip type, size */
+ PRIV(rec_size) -= 4;
+ result = analyze_etir (abfd, PRIV(vms_rec), PRIV(rec_size));
+ break;
+ case OBJ_S_C_TIR:
+ PRIV(vms_rec) += 1; /* skip type */
+ PRIV(rec_size) -= 1;
+ result = analyze_tir (abfd, PRIV(vms_rec), PRIV(rec_size));
+ break;
+ default:
+ result = -1;
+ break;
+ }
+
+ return result;
+}
+
+
+/* process EDBG record
+ return 0 on success, -1 on error
+
+ not implemented yet */
+
+int
+_bfd_vms_slurp_dbg (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "DBG/EDBG\n");
+#endif
+
+ abfd->flags |= (HAS_DEBUG | HAS_LINENO);
+ return 0;
+}
+
+
+/* process ETBT record
+ return 0 on success, -1 on error
+
+ not implemented yet */
+
+int
+_bfd_vms_slurp_tbt (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "TBT/ETBT\n");
+#endif
+
+ return 0;
+}
+
+
+/* process LNK record
+ return 0 on success, -1 on error
+
+ not implemented yet */
+
+int
+_bfd_vms_slurp_lnk (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "LNK\n");
+#endif
+
+ return 0;
+}
+
+/*----------------------------------------------------------------------*/
+/* */
+/* WRITE ETIR SECTION */
+/* */
+/* this is still under construction and therefore not documented */
+/* */
+/*----------------------------------------------------------------------*/
+
+static void start_etir_record PARAMS ((bfd *abfd, int index, uquad offset, boolean justoffset));
+static void sto_imm PARAMS ((bfd *abfd, vms_section *sptr, bfd_vma vaddr, int index));
+static void end_etir_record PARAMS ((bfd *abfd));
+
+static void
+sto_imm (abfd, sptr, vaddr, index)
+ bfd *abfd;
+ vms_section *sptr;
+ bfd_vma vaddr;
+ int index;
+{
+ int size;
+ int ssize;
+ unsigned char *cptr;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (8, "sto_imm %d bytes\n", sptr->size);
+ _bfd_hexdump (9, sptr->contents, (int)sptr->size, (int)vaddr);
+#endif
+
+ ssize = sptr->size;
+ cptr = sptr->contents;
+
+ while (ssize > 0)
+ {
+
+ size = ssize; /* try all the rest */
+
+ if (_bfd_vms_output_check (abfd, size) < 0)
+ { /* doesn't fit, split ! */
+ end_etir_record (abfd);
+ start_etir_record (abfd, index, vaddr, false);
+ size = _bfd_vms_output_check (abfd, 0); /* get max size */
+ if (size > ssize) /* more than what's left ? */
+ size = ssize;
+ }
+
+ _bfd_vms_output_begin (abfd, ETIR_S_C_STO_IMM, -1);
+ _bfd_vms_output_long (abfd, (unsigned long)(size));
+ _bfd_vms_output_dump (abfd, cptr, size);
+ _bfd_vms_output_flush (abfd);
+
+#if VMS_DEBUG
+ _bfd_vms_debug (10, "dumped %d bytes\n", size);
+ _bfd_hexdump (10, cptr, (int)size, (int)vaddr);
+#endif
+
+ vaddr += size;
+ ssize -= size;
+ cptr += size;
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*/
+
+/* start ETIR record for section #index at virtual addr offset. */
+
+static void
+start_etir_record (abfd, index, offset, justoffset)
+ bfd *abfd;
+ int index;
+ uquad offset;
+ boolean justoffset;
+{
+ if (!justoffset)
+ {
+ _bfd_vms_output_begin (abfd, EOBJ_S_C_ETIR, -1); /* one ETIR per section */
+ _bfd_vms_output_push (abfd);
+ }
+
+ _bfd_vms_output_begin (abfd, ETIR_S_C_STA_PQ, -1); /* push start offset */
+ _bfd_vms_output_long (abfd, (unsigned long)index);
+ _bfd_vms_output_quad (abfd, (uquad)offset);
+ _bfd_vms_output_flush (abfd);
+
+ _bfd_vms_output_begin (abfd, ETIR_S_C_CTL_SETRB, -1); /* start = pop () */
+ _bfd_vms_output_flush (abfd);
+
+ return;
+}
+
+
+/* end etir record */
+static void
+end_etir_record (abfd)
+ bfd *abfd;
+{
+ _bfd_vms_output_pop (abfd);
+ _bfd_vms_output_end (abfd);
+}
+
+/* write section contents for bfd abfd */
+
+int
+_bfd_vms_write_tir (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+ asection *section;
+ vms_section *sptr;
+ int nextoffset;
+
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "vms_write_tir (%p, %d)\n", abfd, objtype);
+#endif
+
+ _bfd_vms_output_alignment (abfd, 4);
+
+ nextoffset = 0;
+ PRIV(vms_linkage_index) = 1;
+
+ /* dump all other sections */
+
+ section = abfd->sections;
+
+ while (section != NULL)
+ {
+
+#if VMS_DEBUG
+ _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, (int)(section->_raw_size));
+#endif
+
+ if (section->flags & SEC_RELOC)
+ {
+ int i;
+
+ if ((i = section->reloc_count) <= 0)
+ {
+ (*_bfd_error_handler) (_("SEC_RELOC with no relocs in section %s"),
+ section->name);
+ }
+#if VMS_DEBUG
+ else
+ {
+ arelent **rptr;
+ _bfd_vms_debug (4, "%d relocations:\n", i);
+ rptr = section->orelocation;
+ while (i-- > 0)
+ {
+ _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n",
+ (*(*rptr)->sym_ptr_ptr)->name,
+ (*(*rptr)->sym_ptr_ptr)->section->name,
+ (long)(*(*rptr)->sym_ptr_ptr)->value,
+ (*rptr)->address, (*rptr)->addend,
+ bfd_get_reloc_size((*rptr)->howto),
+ (*rptr)->howto->name);
+ rptr++;
+ }
+ }
+#endif
+ }
+
+ if ((section->flags & SEC_HAS_CONTENTS)
+ && (! bfd_is_com_section (section)))
+ {
+ bfd_vma vaddr; /* virtual addr in section */
+
+ sptr = _bfd_get_vms_section (abfd, section->index);
+ if (sptr == NULL)
+ {
+ bfd_set_error (bfd_error_no_contents);
+ return -1;
+ }
+
+ vaddr = (bfd_vma)(sptr->offset);
+
+ start_etir_record (abfd, section->index, (uquad) sptr->offset,
+ false);
+
+ while (sptr != NULL) /* one STA_PQ, CTL_SETRB per vms_section */
+ {
+
+ if (section->flags & SEC_RELOC) /* check for relocs */
+ {
+ arelent **rptr = section->orelocation;
+ int i = section->reloc_count;
+ for (;;)
+ {
+ bfd_size_type addr = (*rptr)->address;
+ int len = bfd_get_reloc_size ((*rptr)->howto);
+ if (sptr->offset < addr) /* sptr starts before reloc */
+ {
+ int before = addr - sptr->offset;
+ if (sptr->size <= before) /* complete before */
+ {
+ sto_imm (abfd, sptr, vaddr, section->index);
+ vaddr += sptr->size;
+ break;
+ }
+ else /* partly before */
+ {
+ int after = sptr->size - before;
+ sptr->size = before;
+ sto_imm (abfd, sptr, vaddr, section->index);
+ vaddr += sptr->size;
+ sptr->contents += before;
+ sptr->offset += before;
+ sptr->size = after;
+ }
+ }
+ else if (sptr->offset == addr) /* sptr starts at reloc */
+ {
+ asymbol *sym = *(*rptr)->sym_ptr_ptr;
+ asection *sec = sym->section;
+
+ switch ((*rptr)->howto->type)
+ {
+ case ALPHA_R_IGNORE:
+ break;
+
+ case ALPHA_R_REFLONG:
+ {
+ if (bfd_is_und_section (sym->section))
+ {
+ if (_bfd_vms_output_check (abfd,
+ strlen((char *)sym->name))
+ < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_GBL_LW,
+ -1);
+ _bfd_vms_output_counted (abfd,
+ _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_flush (abfd);
+ }
+ else if (bfd_is_abs_section (sym->section))
+ {
+ if (_bfd_vms_output_check (abfd, 16) < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STA_LW,
+ -1);
+ _bfd_vms_output_quad (abfd,
+ (uquad)sym->value);
+ _bfd_vms_output_flush (abfd);
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_LW,
+ -1);
+ _bfd_vms_output_flush (abfd);
+ }
+ else
+ {
+ if (_bfd_vms_output_check (abfd, 32) < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STA_PQ,
+ -1);
+ _bfd_vms_output_long (abfd,
+ (unsigned long)(sec->index));
+ _bfd_vms_output_quad (abfd,
+ ((uquad)(*rptr)->addend
+ + (uquad)sym->value));
+ _bfd_vms_output_flush (abfd);
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_LW,
+ -1);
+ _bfd_vms_output_flush (abfd);
+ }
+ }
+ break;
+
+ case ALPHA_R_REFQUAD:
+ {
+ if (bfd_is_und_section (sym->section))
+ {
+ if (_bfd_vms_output_check (abfd,
+ strlen((char *)sym->name))
+ < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_GBL,
+ -1);
+ _bfd_vms_output_counted (abfd,
+ _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_flush (abfd);
+ }
+ else if (bfd_is_abs_section (sym->section))
+ {
+ if (_bfd_vms_output_check (abfd, 16) < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STA_QW,
+ -1);
+ _bfd_vms_output_quad (abfd,
+ (uquad)sym->value);
+ _bfd_vms_output_flush (abfd);
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_QW,
+ -1);
+ _bfd_vms_output_flush (abfd);
+ }
+ else
+ {
+ if (_bfd_vms_output_check (abfd, 32) < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STA_PQ,
+ -1);
+ _bfd_vms_output_long (abfd,
+ (unsigned long)(sec->index));
+ _bfd_vms_output_quad (abfd,
+ ((uquad)(*rptr)->addend
+ + (uquad)sym->value));
+ _bfd_vms_output_flush (abfd);
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_OFF,
+ -1);
+ _bfd_vms_output_flush (abfd);
+ }
+ }
+ break;
+
+ case ALPHA_R_HINT:
+ {
+ int hint_size;
+
+ hint_size = sptr->size;
+ sptr->size = len;
+ sto_imm (abfd, sptr, vaddr, section->index);
+ sptr->size = hint_size;
+#if 0
+ vms_output_begin(abfd, ETIR_S_C_STO_HINT_GBL, -1);
+ vms_output_long(abfd, (unsigned long)(sec->index));
+ vms_output_quad(abfd, (uquad)addr);
+
+ vms_output_counted(abfd, _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ vms_output_flush(abfd);
+#endif
+ }
+ break;
+ case ALPHA_R_LINKAGE:
+ {
+ if (_bfd_vms_output_check (abfd, 64) < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd, section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STC_LP_PSB,
+ -1);
+ _bfd_vms_output_long (abfd,
+ (unsigned long)PRIV(vms_linkage_index));
+ PRIV(vms_linkage_index) += 2;
+ _bfd_vms_output_counted (abfd,
+ _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_byte (abfd, 0);
+ _bfd_vms_output_flush (abfd);
+ }
+ break;
+
+ case ALPHA_R_CODEADDR:
+ {
+ if (_bfd_vms_output_check (abfd,
+ strlen((char *)sym->name))
+ < 0)
+ {
+ end_etir_record (abfd);
+ start_etir_record (abfd,
+ section->index,
+ vaddr, false);
+ }
+ _bfd_vms_output_begin (abfd,
+ ETIR_S_C_STO_CA,
+ -1);
+ _bfd_vms_output_counted (abfd,
+ _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_flush (abfd);
+ }
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Unhandled relocation %s"),
+ (*rptr)->howto->name);
+ break;
+ }
+
+ vaddr += len;
+
+ if (len == sptr->size)
+ {
+ break;
+ }
+ else
+ {
+ sptr->contents += len;
+ sptr->offset += len;
+ sptr->size -= len;
+ i--;
+ rptr++;
+ }
+ }
+ else /* sptr starts after reloc */
+ {
+ i--; /* check next reloc */
+ rptr++;
+ }
+
+ if (i==0) /* all reloc checked */
+ {
+ if (sptr->size > 0)
+ {
+ sto_imm (abfd, sptr, vaddr, section->index); /* dump rest */
+ vaddr += sptr->size;
+ }
+ break;
+ }
+ } /* for (;;) */
+ } /* if SEC_RELOC */
+ else /* no relocs, just dump */
+ {
+ sto_imm (abfd, sptr, vaddr, section->index);
+ vaddr += sptr->size;
+ }
+
+ sptr = sptr->next;
+
+ } /* while (sptr != 0) */
+
+ end_etir_record (abfd);
+
+ } /* has_contents */
+
+ section = section->next;
+ }
+
+ _bfd_vms_output_alignment(abfd, 2);
+ return 0;
+}
+
+
+/* write traceback data for bfd abfd */
+
+int
+_bfd_vms_write_tbt (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "vms_write_tbt (%p, %d)\n", abfd, objtype);
+#endif
+
+ return 0;
+}
+
+
+/* write debug info for bfd abfd */
+
+int
+_bfd_vms_write_dbg (abfd, objtype)
+ bfd *abfd;
+ int objtype;
+{
+#if VMS_DEBUG
+ _bfd_vms_debug (2, "vms_write_dbg (%p, objtype)\n", abfd, objtype);
+#endif
+
+ return 0;
+}
diff --git a/bfd/vms.c b/bfd/vms.c
new file mode 100644
index 00000000000..a5fc13ad942
--- /dev/null
+++ b/bfd/vms.c
@@ -0,0 +1,1947 @@
+/* vms.c -- BFD back-end for VAX (openVMS/VAX) and
+ EVAX (openVMS/Alpha) files.
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ Written by Klaus K"ampf (kkaempf@rmi.de)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+
+#include "vms.h"
+
+static boolean vms_initialize PARAMS ((bfd *));
+static int priv_section_count;
+static boolean fill_section_ptr PARAMS ((struct bfd_hash_entry *, PTR));
+static boolean vms_fixup_sections PARAMS ((bfd *));
+static boolean copy_symbols PARAMS ((struct bfd_hash_entry *, PTR));
+static bfd_reloc_status_type reloc_nil
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static const struct bfd_target *vms_object_p PARAMS ((bfd *abfd));
+static const struct bfd_target *vms_archive_p PARAMS ((bfd *abfd));
+static boolean vms_mkobject PARAMS ((bfd *abfd));
+static boolean vms_write_object_contents PARAMS ((bfd *abfd));
+static boolean vms_close_and_cleanup PARAMS ((bfd *abfd));
+static boolean vms_bfd_free_cached_info PARAMS ((bfd *abfd));
+static boolean vms_new_section_hook PARAMS ((bfd *abfd, asection *section));
+static boolean vms_get_section_contents
+ PARAMS ((bfd *abfd, asection *section, PTR x1, file_ptr x2,
+ bfd_size_type x3));
+static boolean vms_get_section_contents_in_window
+ PARAMS ((bfd *abfd, asection *section, bfd_window *w, file_ptr offset,
+ bfd_size_type count));
+static boolean vms_bfd_copy_private_bfd_data PARAMS ((bfd *src, bfd *dest));
+static boolean vms_bfd_copy_private_section_data
+ PARAMS ((bfd *srcbfd, asection *srcsec, bfd *dstbfd, asection *dstsec));
+static boolean vms_bfd_copy_private_symbol_data
+ PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym));
+static boolean vms_bfd_print_private_bfd_data
+ PARAMS ((bfd *abfd, void *file));
+static char *vms_core_file_failing_command PARAMS ((bfd *abfd));
+static int vms_core_file_failing_signal PARAMS ((bfd *abfd));
+static boolean vms_core_file_matches_executable_p
+ PARAMS ((bfd *abfd, bfd *bbfd));
+static boolean vms_slurp_armap PARAMS ((bfd *abfd));
+static boolean vms_slurp_extended_name_table PARAMS ((bfd *abfd));
+static boolean vms_construct_extended_name_table
+ PARAMS ((bfd *abfd, char **tabloc, bfd_size_type *tablen,
+ const char **name));
+static void vms_truncate_arname
+ PARAMS ((bfd *abfd, CONST char *pathname, char *arhdr));
+static boolean vms_write_armap
+ PARAMS ((bfd *arch, unsigned int elength, struct orl *map,
+ unsigned int orl_count, int stridx));
+static PTR vms_read_ar_hdr PARAMS ((bfd *abfd));
+static bfd *vms_get_elt_at_index PARAMS ((bfd *abfd, symindex index));
+static bfd *vms_openr_next_archived_file PARAMS ((bfd *arch, bfd *prev));
+static boolean vms_update_armap_timestamp PARAMS ((bfd *abfd));
+static int vms_generic_stat_arch_elt PARAMS ((bfd *abfd, struct stat *stat));
+static long vms_get_symtab_upper_bound PARAMS ((bfd *abfd));
+static long vms_get_symtab PARAMS ((bfd *abfd, asymbol **symbols));
+static void vms_print_symbol
+ PARAMS ((bfd *abfd, PTR file, asymbol *symbol, bfd_print_symbol_type how));
+static void vms_get_symbol_info
+ PARAMS ((bfd *abfd, asymbol *symbol, symbol_info *ret));
+static boolean vms_bfd_is_local_label_name PARAMS ((bfd *abfd, const char *));
+static alent *vms_get_lineno PARAMS ((bfd *abfd, asymbol *symbol));
+static boolean vms_find_nearest_line
+ PARAMS ((bfd *abfd, asection *section, asymbol **symbols, bfd_vma offset,
+ const char **file, const char **func, unsigned int *line));
+static asymbol *vms_bfd_make_debug_symbol
+ PARAMS ((bfd *abfd, void *ptr, unsigned long size));
+static long vms_read_minisymbols
+ PARAMS ((bfd *abfd, boolean dynamic, PTR *minisymsp, unsigned int *sizep));
+static asymbol *vms_minisymbol_to_symbol
+ PARAMS ((bfd *abfd, boolean dynamic, const PTR minisym, asymbol *sym));
+static long vms_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
+static long vms_canonicalize_reloc
+ PARAMS ((bfd *abfd, asection *srcsec, arelent **location,
+ asymbol **symbols));
+static const struct reloc_howto_struct *vms_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static boolean vms_set_arch_mach
+ PARAMS ((bfd *abfd, enum bfd_architecture arch, unsigned long mach));
+static boolean vms_set_section_contents
+ PARAMS ((bfd *abfd, asection *section, PTR location, file_ptr offset,
+ bfd_size_type count));
+static int vms_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
+static bfd_byte *vms_bfd_get_relocated_section_contents
+ PARAMS ((bfd *abfd, struct bfd_link_info *link_info,
+ struct bfd_link_order *link_order, bfd_byte *data,
+ boolean relocateable, asymbol **symbols));
+static boolean vms_bfd_relax_section
+ PARAMS ((bfd *abfd, asection *section, struct bfd_link_info *link_info,
+ boolean *again));
+static boolean vms_bfd_gc_sections
+ PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
+static struct bfd_link_hash_table *vms_bfd_link_hash_table_create
+ PARAMS ((bfd *abfd));
+static boolean vms_bfd_link_add_symbols
+ PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
+static boolean vms_bfd_final_link
+ PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
+static boolean vms_bfd_link_split_section
+ PARAMS ((bfd *abfd, asection *section));
+static long vms_get_dynamic_symtab_upper_bound PARAMS ((bfd *abfd));
+static long vms_canonicalize_dynamic_symtab
+ PARAMS ((bfd *abfd, asymbol **symbols));
+static long vms_get_dynamic_reloc_upper_bound PARAMS ((bfd *abfd));
+static long vms_canonicalize_dynamic_reloc
+ PARAMS ((bfd *abfd, arelent **arel, asymbol **symbols));
+static boolean vms_bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
+static boolean vms_bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags));
+
+#define vms_make_empty_symbol _bfd_vms_make_empty_symbol
+
+/*===========================================================================*/
+
+const bfd_target vms_alpha_vec =
+{
+
+ "vms-alpha", /* name */
+ bfd_target_evax_flavour,
+ false, /* data byte order is little */
+ false, /* header byte order is little */
+
+ (HAS_RELOC | HAS_SYMS
+ | WP_TEXT | D_PAGED), /* object flags */
+ (SEC_ALLOC | SEC_LOAD | SEC_RELOC
+ | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* sect flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ 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_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16,
+
+ {_bfd_dummy_target, vms_object_p, /* bfd_check_format */
+ vms_archive_p, _bfd_dummy_target},
+ {bfd_false, vms_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, vms_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (vms),
+ BFD_JUMP_TABLE_COPY (vms),
+ BFD_JUMP_TABLE_CORE (vms),
+ BFD_JUMP_TABLE_ARCHIVE (vms),
+ BFD_JUMP_TABLE_SYMBOLS (vms),
+ BFD_JUMP_TABLE_RELOCS (vms),
+ BFD_JUMP_TABLE_WRITE (vms),
+ BFD_JUMP_TABLE_LINK (vms),
+ BFD_JUMP_TABLE_DYNAMIC (vms),
+
+ (PTR) 0
+};
+
+const bfd_target vms_vax_vec =
+{
+
+ "vms-vax", /* name */
+ bfd_target_ovax_flavour,
+ false, /* data byte order is little */
+ false, /* header byte order is little */
+
+ (HAS_RELOC | HAS_SYMS /* object flags */
+ | WP_TEXT | D_PAGED
+ | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
+
+ (SEC_ALLOC | SEC_LOAD | SEC_RELOC
+ | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* sect flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {_bfd_dummy_target, vms_object_p, /* bfd_check_format */
+ vms_archive_p, _bfd_dummy_target},
+ {bfd_false, vms_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+ {bfd_false, vms_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (vms),
+ BFD_JUMP_TABLE_COPY (vms),
+ BFD_JUMP_TABLE_CORE (vms),
+ BFD_JUMP_TABLE_ARCHIVE (vms),
+ BFD_JUMP_TABLE_SYMBOLS (vms),
+ BFD_JUMP_TABLE_RELOCS (vms),
+ BFD_JUMP_TABLE_WRITE (vms),
+ BFD_JUMP_TABLE_LINK (vms),
+ BFD_JUMP_TABLE_DYNAMIC (vms),
+
+ (PTR) 0
+};
+
+/*===========================================================================*/
+
+/* Initialize private data */
+
+static boolean
+vms_initialize (abfd)
+ bfd *abfd;
+{
+ int i;
+
+ if (abfd->tdata.any != 0)
+ return true;
+
+ bfd_set_start_address (abfd, (bfd_vma)-1);
+
+ abfd->tdata.any = ((struct vms_private_data_struct*)
+ bfd_malloc (sizeof (struct vms_private_data_struct)));
+ if (abfd->tdata.any == 0)
+ return false;
+
+#ifdef __ALPHA
+ PRIV(is_vax) = 0;
+#else
+ PRIV(is_vax) = 1;
+#endif
+ PRIV(vms_buf) = 0;
+ PRIV(buf_size) = 0;
+ PRIV(rec_length) = 0;
+ PRIV(file_format) = FF_UNKNOWN;
+ PRIV(fixup_done) = false;
+ PRIV(sections) = NULL;
+
+ PRIV(stack) = ((struct stack_struct *)
+ bfd_malloc (sizeof (struct stack_struct) * STACKSIZE));
+ if (PRIV(stack) == 0)
+ {
+ vms_init_no_mem1:
+ free (abfd->tdata.any);
+ abfd->tdata.any = 0;
+ return false;
+ }
+ PRIV(stackptr) = 0;
+
+ PRIV(vms_symbol_table) = ((struct bfd_hash_table *)
+ bfd_malloc (sizeof (struct bfd_hash_table)));
+ if (PRIV(vms_symbol_table) == 0)
+ {
+ vms_init_no_mem2:
+ free (PRIV(stack));
+ PRIV(stack) = 0;
+ goto vms_init_no_mem1;
+ }
+
+ if (!bfd_hash_table_init (PRIV(vms_symbol_table), _bfd_vms_hash_newfunc))
+ return false;
+
+ PRIV(location_stack) = ((struct location_struct *)
+ bfd_malloc (sizeof (struct location_struct)
+ * LOCATION_SAVE_SIZE));
+ if (PRIV(location_stack) == 0)
+ {
+ vms_init_no_mem3:
+ free (PRIV(vms_symbol_table));
+ PRIV(vms_symbol_table) = 0;
+ goto vms_init_no_mem2;
+ }
+
+ for (i = 0; i < VMS_SECTION_COUNT; i++)
+ PRIV(vms_section_table)[i] = NULL;
+
+ PRIV(output_buf) = (unsigned char *) malloc (MAX_OUTREC_SIZE);
+ if (PRIV(output_buf) == 0)
+ {
+ free (PRIV(location_stack));
+ PRIV(location_stack) = 0;
+ goto vms_init_no_mem3;
+ }
+ PRIV(push_level) = 0;
+ PRIV(pushed_size) = 0;
+ PRIV(length_pos) = 2;
+ PRIV(output_size) = 0;
+ PRIV(output_alignment) = 1;
+
+ return true;
+}
+
+
+/* Fill symbol->section with section ptr
+ symbol->section is filled with the section index for defined symbols
+ during reading the GSD/EGSD section. But we need the pointer to the
+ bfd section later.
+
+ It has the correct value for referenced (undefined section) symbols
+
+ called from bfd_hash_traverse in vms_fixup_sections */
+
+static boolean
+fill_section_ptr (entry, sections)
+ struct bfd_hash_entry *entry;
+ PTR sections;
+{
+ asection *sec;
+ asymbol *sym;
+
+ sym = ((vms_symbol_entry *)entry)->symbol;
+ sec = sym->section;
+
+#if VMS_DEBUG
+ vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
+#endif
+
+ /* fill forward references (these contain section number, not section ptr). */
+
+ if ((int)sec < priv_section_count)
+ {
+ sec = ((vms_symbol_entry *)entry)->symbol->section =
+ ((asection **)sections)[(int)sec];
+ }
+
+ if (strcmp (sym->name, sec->name) == 0)
+ sym->flags |= BSF_SECTION_SYM;
+
+ return true;
+}
+
+
+/* Fixup sections
+ set up all pointers and arrays, counters and sizes are fixed now
+
+ we build a private sections vector for easy access since sections
+ are always referenced by an index number.
+
+ alloc PRIV(sections) according to abfd->section_count
+ copy abfd->sections to PRIV(sections) */
+
+static boolean
+vms_fixup_sections (abfd)
+ bfd *abfd;
+{
+ asection *s;
+
+ if (PRIV(fixup_done))
+ return true;
+
+ /*
+ * traverse symbol table and fill in all section pointers
+ */
+
+ /* can't provide section count as argument to fill_section_ptr(). */
+ priv_section_count = PRIV(section_count);
+ bfd_hash_traverse (PRIV(vms_symbol_table), fill_section_ptr,
+ (PTR)(PRIV(sections)));
+
+ PRIV(fixup_done) = true;
+
+ return true;
+}
+
+/*===========================================================================*/
+
+/* Check the format for a file being read.
+ Return a (bfd_target *) if it's an object file or zero if not. */
+
+static const struct bfd_target *
+vms_object_p (abfd)
+ bfd *abfd;
+{
+ int err = 0;
+ int prev_type;
+ const struct bfd_target *target_vector = 0;
+ const bfd_arch_info_type *arch = 0;
+
+#if VMS_DEBUG
+ vms_debug (1, "vms_object_p(%p)\n", abfd);
+#endif
+
+ if (!vms_initialize (abfd))
+ {
+ fprintf (stderr, "vms_initialize () failed !!\n");
+ return 0;
+ }
+
+ if (bfd_seek (abfd, 0L, SEEK_SET))
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return 0;
+ }
+
+ prev_type = -1;
+
+ do
+ {
+#if VMS_DEBUG
+ vms_debug (7, "reading at %08lx\n", bfd_tell(abfd));
+#endif
+ if (_bfd_vms_next_record (abfd) < 0)
+ {
+#if VMS_DEBUG
+ vms_debug (2, "next_record failed\n");
+#endif
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if ((prev_type == EOBJ_S_C_EGSD)
+ && (PRIV(rec_type) != EOBJ_S_C_EGSD))
+ {
+ if (vms_fixup_sections (abfd) == false)
+ {
+#if VMS_DEBUG
+ vms_debug (2, "vms_fixup_sections failed\n");
+#endif
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ }
+
+ prev_type = PRIV(rec_type);
+
+ if (target_vector == 0)
+ {
+ if (prev_type <= OBJ_S_C_MAXRECTYP)
+ target_vector = &vms_vax_vec;
+ else
+ target_vector = &vms_alpha_vec;
+ }
+
+ switch (prev_type)
+ {
+ case OBJ_S_C_HDR:
+ case EOBJ_S_C_EMH:
+ err = _bfd_vms_slurp_hdr (abfd, prev_type);
+ break;
+ case OBJ_S_C_EOM:
+ case OBJ_S_C_EOMW:
+ case EOBJ_S_C_EEOM:
+ err = _bfd_vms_slurp_eom (abfd, prev_type);
+ break;
+ case OBJ_S_C_GSD:
+ case EOBJ_S_C_EGSD:
+ err = _bfd_vms_slurp_gsd (abfd, prev_type);
+ break;
+ case OBJ_S_C_TIR:
+ case EOBJ_S_C_ETIR:
+ err = _bfd_vms_slurp_tir (abfd, prev_type);
+ break;
+ case OBJ_S_C_DBG:
+ case EOBJ_S_C_EDBG:
+ err = _bfd_vms_slurp_dbg (abfd, prev_type);
+ break;
+ case OBJ_S_C_TBT:
+ case EOBJ_S_C_ETBT:
+ err = _bfd_vms_slurp_tbt (abfd, prev_type);
+ break;
+ case OBJ_S_C_LNK:
+ err = _bfd_vms_slurp_lnk (abfd, prev_type);
+ break;
+ default:
+ err = -1;
+ }
+ if (err != 0)
+ {
+#if VMS_DEBUG
+ vms_debug (2, "slurp type %d failed with %d\n", prev_type, err);
+#endif
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ }
+ while ((prev_type != EOBJ_S_C_EEOM) && (prev_type != OBJ_S_C_EOM) && (prev_type != OBJ_S_C_EOMW));
+
+ if (target_vector == &vms_vax_vec)
+ {
+ if (vms_fixup_sections (abfd) == false)
+ {
+#if VMS_DEBUG
+ vms_debug (2, "vms_fixup_sections failed\n");
+#endif
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ /* set arch_info to vax */
+
+ arch = bfd_scan_arch ("vax");
+ PRIV (is_vax) = 1;
+#if VMS_DEBUG
+ vms_debug (2, "arch is vax\n");
+#endif
+ }
+ else if (target_vector == &vms_alpha_vec)
+ {
+ /* set arch_info to alpha */
+
+ arch = bfd_scan_arch ("alpha");
+ PRIV (is_vax) = 0;
+#if VMS_DEBUG
+ vms_debug (2, "arch is alpha\n");
+#endif
+ }
+
+ if (arch == 0)
+ {
+#if VMS_DEBUG
+ vms_debug (2, "arch not found\n");
+#endif
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+ abfd->arch_info = arch;
+
+ return target_vector;
+}
+
+
+/* Check the format for a file being read.
+ Return a (bfd_target *) if it's an archive file or zero. */
+
+static const struct bfd_target *
+vms_archive_p (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_archive_p(%p)\n", abfd);
+#endif
+
+ return 0;
+}
+
+
+/* Set the format of a file being written. */
+
+static boolean
+vms_mkobject (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_mkobject(%p)\n", abfd);
+#endif
+
+ if (!vms_initialize (abfd))
+ {
+ fprintf (stderr, "vms_initialize () failed !!\n");
+ return 0;
+ }
+
+ {
+#ifdef __VAX
+ const bfd_arch_info_type *arch = bfd_scan_arch ("vax");
+#else
+ const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");
+#endif
+ if (arch == 0)
+ {
+ bfd_set_error(bfd_error_wrong_format);
+ return 0;
+ }
+ abfd->arch_info = arch;
+ }
+
+ return true;
+}
+
+
+/* Write cached information into a file being written, at bfd_close. */
+
+static boolean
+vms_write_object_contents (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_write_object_contents(%p)\n", abfd);
+#endif
+
+ if (abfd->section_count > 0) /* we have sections */
+ {
+ if (PRIV(is_vax))
+ {
+ if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0)
+ return false;
+ if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0)
+ return false;
+ if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0)
+ return false;
+ if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0)
+ return false;
+ if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0)
+ return false;
+ if (abfd->section_count > 255)
+ {
+ if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
+ return false;
+ }
+ else
+ {
+ if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
+ return false;
+ }
+ }
+ else
+ {
+ if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0)
+ return false;
+ if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0)
+ return false;
+ if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0)
+ return false;
+ if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0)
+ return false;
+ if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0)
+ return false;
+ if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0)
+ return false;
+ }
+ }
+ return true;
+}
+
+/*-- 4.1, generic -----------------------------------------------------------*/
+
+/* Called when the BFD is being closed to do any necessary cleanup. */
+
+static boolean
+vms_close_and_cleanup (abfd)
+ bfd *abfd;
+{
+ asection *sec;
+ vms_section *es, *es1;
+ vms_reloc *er, *er1;
+ int i;
+
+#if VMS_DEBUG
+ vms_debug (1, "vms_close_and_cleanup(%p)\n", abfd);
+#endif
+ if (abfd == 0)
+ return true;
+
+ if (PRIV(vms_buf) != NULL)
+ {
+ free (PRIV(vms_buf));
+ PRIV(vms_buf) = NULL;
+ }
+ PRIV(buf_size) = 0;
+
+ if (PRIV(output_buf) != 0)
+ {
+ free (PRIV(output_buf));
+ PRIV(output_buf) = 0;
+ }
+
+ sec = abfd->sections;
+ while (sec != NULL)
+ {
+ if (sec->contents)
+ free (sec->contents);
+ sec = sec->next;
+ }
+
+ if (PRIV(sections) != NULL)
+ {
+ free (PRIV(sections));
+ PRIV(sections) = NULL;
+ }
+
+ if (PRIV(vms_symbol_table))
+ {
+ bfd_hash_table_free (PRIV(vms_symbol_table));
+ PRIV(vms_symbol_table) = 0;
+ }
+
+ if (PRIV(stack))
+ {
+ free (PRIV(stack));
+ PRIV(stack) = 0;
+ }
+
+ if (PRIV(location_stack))
+ {
+ free (PRIV(location_stack));
+ PRIV(location_stack) = 0;
+ }
+
+ for (i = 0; i < VMS_SECTION_COUNT; i++)
+ {
+ es = PRIV(vms_section_table)[i];
+ while (es != NULL)
+ {
+ es1 = es->next;
+ free (es);
+ es = es1;
+ }
+ PRIV(vms_section_table)[i] = NULL;
+ }
+
+ free (abfd->tdata.any);
+ abfd->tdata.any = NULL;
+
+ return true;
+}
+
+
+/* Ask the BFD to free all cached information. */
+static boolean
+vms_bfd_free_cached_info (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_free_cached_info(%p)\n", abfd);
+#endif
+ return true;
+}
+
+
+/* Called when a new section is created. */
+
+static boolean
+vms_new_section_hook (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n", abfd, section->index, section->name, abfd->section_count);
+#endif
+ bfd_set_section_alignment(abfd, section, 4);
+
+ if (abfd->section_count > PRIV(section_count))
+ {
+ PRIV(sections) = ((asection **)
+ bfd_realloc (PRIV(sections), abfd->section_count * sizeof (asection *)));
+ if (PRIV(sections) == 0)
+ return false;
+ PRIV(section_count) = abfd->section_count;
+ }
+#if VMS_DEBUG
+ vms_debug (6, "section_count: %d\n", PRIV(section_count));
+#endif
+ PRIV(sections)[section->index] = section;
+#if VMS_DEBUG
+ vms_debug (7, "%d: %s\n", section->index, section->name);
+#endif
+
+ return true;
+}
+
+
+/* Read the contents of a section.
+ buf points to a buffer of buf_size bytes to be filled with
+ section data (starting at offset into section) */
+
+static boolean
+vms_get_section_contents (abfd, section, buf, offset, buf_size)
+ bfd *abfd;
+ asection *section;
+ PTR buf;
+ file_ptr offset;
+ bfd_size_type buf_size;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_section_contents(%p, %s, %p, off %ld, size %d)\n",
+ abfd, section->name, buf, offset, (int)buf_size);
+#endif
+
+ /* shouldn't be called, since all sections are IN_MEMORY */
+
+ return false;
+}
+
+/* Read the contents of a section.
+ buf points to a buffer of buf_size bytes to be filled with
+ section data (starting at offset into section) */
+
+static boolean
+vms_get_section_contents_in_window (abfd, section, w, offset, count)
+ bfd *abfd;
+ asection *section;
+ bfd_window *w;
+ file_ptr offset;
+ bfd_size_type count;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n",
+ abfd, section->name, w, offset, (int)count);
+#endif
+
+ /* shouldn't be called, since all sections are IN_MEMORY */
+
+ return false;
+}
+
+/*-- Part 4.2, copy private data --------------------------------------------*/
+
+/* Called to copy BFD general private data from one object file
+ to another. */
+
+static boolean
+vms_bfd_copy_private_bfd_data (src, dest)
+ bfd *src;
+ bfd *dest;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_copy_private_bfd_data(%p, %p)\n", src, dest);
+#endif
+ return true;
+}
+
+
+/* Merge private BFD information from the BFD @var{ibfd} to the
+ the output file BFD @var{obfd} when linking. Return <<true>>
+ on success, <<false>> on error. Possible error returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{obfd}. */
+
+static boolean
+vms_bfd_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+#if VMS_DEBUG
+ vms_debug (1,"vms_bfd_merge_private_bfd_data(%p, %p)\n", ibfd, obfd);
+#endif
+ return true;
+}
+
+
+/* Set private BFD flag information in the BFD @var{abfd}.
+ Return <<true>> on success, <<false>> on error. Possible error
+ returns are:
+
+ o <<bfd_error_no_memory>> -
+ Not enough memory exists to create private data for @var{obfd}. */
+
+static boolean
+vms_bfd_set_private_flags (abfd, flags)
+ bfd *abfd;
+ flagword flags;
+{
+#if VMS_DEBUG
+ vms_debug (1,"vms_bfd_set_private_flags(%p, %lx)\n", abfd, (long)flags);
+#endif
+ return true;
+}
+
+
+/* Called to copy BFD private section data from one object file
+ to another. */
+
+static boolean
+vms_bfd_copy_private_section_data (srcbfd, srcsec, dstbfd, dstsec)
+ bfd *srcbfd;
+ asection *srcsec;
+ bfd *dstbfd;
+ asection *dstsec;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_copy_private_section_data(%p, %s, %p, %s)\n",
+ srcbfd, srcsec->name, dstbfd, dstsec->name);
+#endif
+ return true;
+}
+
+/* Called to copy BFD private symbol data from one object file
+ to another. */
+
+static boolean
+vms_bfd_copy_private_symbol_data (ibfd, isym, obfd, osym)
+ bfd *ibfd;
+ asymbol *isym;
+ bfd *obfd;
+ asymbol *osym;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n",
+ ibfd, isym->name, obfd, osym->name);
+#endif
+ return true;
+}
+
+/*-- Part 4.3, core file ----------------------------------------------------*/
+
+/* Return a read-only string explaining which program was running
+ when it failed and produced the core file abfd. */
+
+static char *
+vms_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_core_file_failing_command(%p)\n", abfd);
+#endif
+ return 0;
+}
+
+
+/* Returns the signal number which caused the core dump which
+ generated the file the BFD abfd is attached to. */
+
+static int
+vms_core_file_failing_signal (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_core_file_failing_signal(%p)\n", abfd);
+#endif
+ return 0;
+}
+
+
+/* Return true if the core file attached to core_bfd was generated
+ by a run of the executable file attached to exec_bfd, false otherwise. */
+
+static boolean
+vms_core_file_matches_executable_p (abfd, bbfd)
+ bfd *abfd;
+ bfd *bbfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_core_file_matches_executable_p(%p, %p)\n", abfd, bbfd);
+#endif
+ return false;
+}
+
+/*-- Part 4.4, archive ------------------------------------------------------*/
+
+/* ??? do something with an archive map.
+ Return false on error, true otherwise. */
+
+static boolean
+vms_slurp_armap (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_slurp_armap(%p)\n", abfd);
+#endif
+ return false;
+}
+
+
+/* ??? do something with an extended name table.
+ Return false on error, true otherwise. */
+
+static boolean
+vms_slurp_extended_name_table (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_slurp_extended_name_table(%p)\n", abfd);
+#endif
+ return false;
+}
+
+
+/* ??? do something with an extended name table.
+ Return false on error, true otherwise. */
+
+static boolean
+vms_construct_extended_name_table (abfd, tabloc, tablen, name)
+ bfd *abfd;
+ char **tabloc;
+ bfd_size_type *tablen;
+ const char **name;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_construct_extended_name_table(%p)\n", abfd);
+#endif
+ return false;
+}
+
+
+/* Truncate the name of an archive to match system-dependent restrictions */
+
+static void
+vms_truncate_arname (abfd, pathname, arhdr)
+ bfd *abfd;
+ CONST char *pathname;
+ char *arhdr;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_truncate_arname(%p, %s, %s)\n", abfd, pathname, arhdr);
+#endif
+ return;
+}
+
+
+/* ??? write archive map */
+
+static boolean
+vms_write_armap (arch, elength, map, orl_count, stridx)
+ bfd *arch;
+ unsigned int elength;
+ struct orl *map;
+ unsigned int orl_count;
+ int stridx;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_write_armap(%p, %d, %p, %d %d)\n",
+ arch, elength, map, orl_count, stridx);
+#endif
+ return true;
+}
+
+/* Read archive header ??? */
+
+static PTR
+vms_read_ar_hdr (abfd)
+ bfd * abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_read_ar_hdr(%p)\n", abfd);
+#endif
+ return (PTR)0;
+}
+
+
+/* Provided a BFD, @var{archive}, containing an archive and NULL, open
+ an input BFD on the first contained element and returns that.
+ Subsequent calls should pass the archive and the previous return value
+ to return a created BFD to the next contained element.
+ NULL is returned when there are no more. */
+
+static bfd *
+vms_openr_next_archived_file (arch, prev)
+ bfd *arch;
+ bfd *prev;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_openr_next_archived_file(%p, %p)\n", arch, prev);
+#endif
+ return false;
+}
+
+
+/* Return the BFD which is referenced by the symbol in ABFD indexed by
+ INDEX. INDEX should have been returned by bfd_get_next_mapent. */
+
+static bfd *
+vms_get_elt_at_index (abfd, index)
+ bfd *abfd;
+ symindex index;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_elt_at_index(%p, %p)\n", abfd, index);
+#endif
+ return _bfd_generic_get_elt_at_index(abfd, index);
+}
+
+
+/* ???
+ -> bfd_generic_stat_arch_elt */
+
+static int
+vms_generic_stat_arch_elt (abfd, stat)
+ bfd *abfd;
+ struct stat *stat;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_generic_stat_arch_elt(%p, %p)\n", abfd, stat);
+#endif
+ return bfd_generic_stat_arch_elt(abfd, stat);
+}
+
+
+/* This is a new function in bfd 2.5 */
+
+static boolean
+vms_update_armap_timestamp (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_update_armap_timestamp(%p)\n", abfd);
+#endif
+ return true;
+}
+
+/*-- Part 4.5, symbols --------------------------------------------------------*/
+
+/* Return the number of bytes required to store a vector of pointers
+ to asymbols for all the symbols in the BFD abfd, including a
+ terminal NULL pointer. If there are no symbols in the BFD,
+ then return 0. If an error occurs, return -1. */
+
+static long
+vms_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_symtab_upper_bound(%p), %d symbols\n", abfd, PRIV(gsd_sym_count));
+#endif
+ return (PRIV(gsd_sym_count)+1) * sizeof(asymbol *);
+}
+
+
+/* Copy symbols from hash table to symbol vector
+
+ called from bfd_hash_traverse in vms_get_symtab
+ init counter to 0 if entry == 0 */
+
+static boolean
+copy_symbols (entry, arg)
+ struct bfd_hash_entry *entry;
+ PTR arg;
+{
+ bfd *abfd = (bfd *) arg;
+
+ if (entry == NULL) /* init counter */
+ PRIV(symnum) = 0;
+ else /* fill vector, inc counter */
+ PRIV(symcache)[PRIV(symnum)++] = ((vms_symbol_entry *)entry)->symbol;
+
+ return true;
+}
+
+
+/* Read the symbols from the BFD abfd, and fills in the vector
+ location with pointers to the symbols and a trailing NULL.
+
+ return # of symbols read */
+
+static long
+vms_get_symtab (abfd, symbols)
+ bfd *abfd;
+ asymbol **symbols;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_symtab(%p, <ret>)\n", abfd);
+#endif
+
+ /* init counter */
+ (void)copy_symbols((struct bfd_hash_entry *)0, abfd);
+
+ /* traverse table and fill symbols vector */
+
+ PRIV(symcache) = symbols;
+ bfd_hash_traverse(PRIV(vms_symbol_table), copy_symbols, (PTR)abfd);
+
+ symbols[PRIV(gsd_sym_count)] = NULL;
+
+ return PRIV(gsd_sym_count);
+}
+
+
+/* Create a new asymbol structure for the BFD abfd and return a pointer
+ to it.
+ This routine is necessary because each back end has private information
+ surrounding the asymbol. Building your own asymbol and pointing to it
+ will not create the private information, and will cause problems later on. */
+
+asymbol *
+_bfd_vms_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *symbol = (asymbol *)bfd_zalloc(abfd, sizeof(asymbol));
+
+#if VMS_DEBUG
+ vms_debug (1, "_bfd_vms_make_empty_symbol(%p)\n", abfd);
+#endif
+
+ if (symbol == 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return 0;
+ }
+ symbol->the_bfd = abfd;
+
+ return symbol;
+}
+
+
+/* Print symbol to file according to how. how is one of
+ bfd_print_symbol_name just print the name
+ bfd_print_symbol_more print more (???)
+ bfd_print_symbol_all print all we know, which is not much right now :-) */
+
+static void
+vms_print_symbol (abfd, file, symbol, how)
+ bfd *abfd;
+ PTR file;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_print_symbol(%p, %p, %p, %d)\n", abfd, file, symbol, how);
+#endif
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ case bfd_print_symbol_more:
+ fprintf((FILE *)file," %s", symbol->name);
+ break;
+
+ break;
+
+ case bfd_print_symbol_all:
+ {
+ CONST char *section_name = symbol->section->name;
+
+ bfd_print_symbol_vandf((PTR)file,symbol);
+
+ fprintf((FILE *)file," %-8s %s", section_name, symbol->name);
+ }
+ break;
+ }
+ return;
+}
+
+
+/* Return information about symbol in ret.
+
+ fill type, value and name
+ type:
+ A absolute
+ B bss segment symbol
+ C common symbol
+ D data segment symbol
+ f filename
+ t a static function symbol
+ T text segment symbol
+ U undefined
+ - debug */
+
+static void
+vms_get_symbol_info (abfd, symbol, ret)
+ bfd *abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ asection *sec;
+
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_symbol_info(%p, %p, %p)\n", abfd, symbol, ret);
+#endif
+
+ sec = symbol->section;
+
+ if (ret == 0)
+ return;
+
+ if (bfd_is_com_section (sec))
+ ret->type = 'C';
+ else if (bfd_is_abs_section (sec))
+ ret->type = 'A';
+ else if (bfd_is_und_section (sec))
+ ret->type = 'U';
+ else if (bfd_is_ind_section (sec))
+ ret->type = 'I';
+ else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
+ ret->type = 'T';
+ else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
+ ret->type = 'D';
+ else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+ ret->type = 'B';
+ else
+ ret->type = '-';
+
+ if (ret->type != 'U')
+ ret->value = symbol->value + symbol->section->vma;
+ else
+ ret->value = 0;
+ ret->name = symbol->name;
+
+ return;
+}
+
+
+/* Return true if the given symbol sym in the BFD abfd is
+ a compiler generated local label, else return false. */
+
+static boolean
+vms_bfd_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_is_local_label_name(%p, %s)\n", abfd, name);
+#endif
+ return name[0] == '$';
+}
+
+
+/* Get source line number for symbol */
+
+static alent *
+vms_get_lineno (abfd, symbol)
+ bfd *abfd;
+ asymbol *symbol;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_lineno(%p, %p)\n", abfd, symbol);
+#endif
+ return 0;
+}
+
+
+/* Provided a BFD, a section and an offset into the section, calculate and
+ return the name of the source file and the line nearest to the wanted
+ location. */
+
+static boolean
+vms_find_nearest_line (abfd, section, symbols, offset, file, func, line)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **file;
+ CONST char **func;
+ unsigned int *line;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_find_nearest_line(%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
+ abfd, section->name, symbols, (long int)offset);
+#endif
+ return false;
+}
+
+
+/* Back-door to allow format-aware applications to create debug symbols
+ while using BFD for everything else. Currently used by the assembler
+ when creating COFF files. */
+
+static asymbol *
+vms_bfd_make_debug_symbol (abfd, ptr, size)
+ bfd *abfd;
+ void *ptr;
+ unsigned long size;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_make_debug_symbol(%p, %p, %ld)\n", abfd, ptr, size);
+#endif
+ return 0;
+}
+
+
+/* Read minisymbols. For minisymbols, we use the unmodified a.out
+ symbols. The minisymbol_to_symbol function translates these into
+ BFD asymbol structures. */
+
+static long
+vms_read_minisymbols (abfd, dynamic, minisymsp, sizep)
+ bfd *abfd;
+ boolean dynamic;
+ PTR *minisymsp;
+ unsigned int *sizep;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_read_minisymbols(%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
+#endif
+ return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
+}
+
+/* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
+ unmodified a.out symbol. The SYM argument is a structure returned
+ by bfd_make_empty_symbol, which we fill in here. */
+
+static asymbol *
+vms_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
+ bfd *abfd;
+ boolean dynamic;
+ const PTR minisym;
+ asymbol *sym;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_minisymbol_to_symbol(%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
+#endif
+ return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
+}
+
+/*-- Part 4.6, relocations --------------------------------------------------*/
+
+/* Return the number of bytes required to store the relocation information
+ associated with section sect attached to bfd abfd.
+ If an error occurs, return -1. */
+
+static long
+vms_get_reloc_upper_bound (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_reloc_upper_bound(%p, %s)\n", abfd, section->name);
+#endif
+ return -1L;
+}
+
+
+/* Call the back end associated with the open BFD abfd and translate the
+ external form of the relocation information attached to sec into the
+ internal canonical form. Place the table into memory at loc, which has
+ been preallocated, usually by a call to bfd_get_reloc_upper_bound.
+ Returns the number of relocs, or -1 on error. */
+
+static long
+vms_canonicalize_reloc (abfd, section, location, symbols)
+ bfd *abfd;
+ asection *section;
+ arelent **location;
+ asymbol **symbols;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_canonicalize_reloc(%p, %s, <ret>, <ret>)\n", abfd, section->name);
+#endif
+ return false;
+}
+
+/*---------------------------------------------------------------------------*/
+/* this is just copied from ecoff-alpha, needs to be fixed probably */
+
+/* How to process the various reloc types. */
+
+static bfd_reloc_status_type
+reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc;
+ asymbol *sym;
+ PTR data;
+ asection *sec;
+ bfd *output_bfd;
+ char **error_message;
+{
+#if VMS_DEBUG
+ vms_debug (1, "reloc_nil(abfd %p, output_bfd %p)\n", abfd, output_bfd);
+ vms_debug (2, "In section %s, symbol %s\n",
+ sec->name, sym->name);
+ vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
+ reloc->sym_ptr_ptr[0]->name,
+ (unsigned long)reloc->address,
+ (unsigned long)reloc->addend, reloc->howto->name);
+ vms_debug (2, "data at %p\n", data);
+/* _bfd_hexdump (2, data, bfd_get_reloc_size(reloc->howto),0); */
+#endif
+
+ return bfd_reloc_ok;
+}
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+static reloc_howto_type alpha_howto_table[] =
+{
+ HOWTO (ALPHA_R_IGNORE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ reloc_nil, /* special_function */
+ "IGNORE", /* name */
+ true, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ true), /* 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 */
+ reloc_nil, /* special_function */
+ "REFQUAD", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* 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. */
+ 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 */
+ reloc_nil, /* special_function */
+ "BRADDR", /* name */
+ true, /* partial_inplace */
+ 0x1fffff, /* src_mask */
+ 0x1fffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A hint for a jump to a register. */
+ HOWTO (ALPHA_R_HINT, /* type */
+ 2, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 14, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ reloc_nil, /* special_function */
+ "HINT", /* name */
+ true, /* partial_inplace */
+ 0x3fff, /* src_mask */
+ 0x3fff, /* dst_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 */
+ reloc_nil, /* special_function */
+ "SREL16", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_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 */
+ reloc_nil, /* special_function */
+ "SREL32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_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 */
+ reloc_nil, /* special_function */
+ "SREL64", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_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 */
+ reloc_nil, /* special_function */
+ "OP_PUSH", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_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 */
+ reloc_nil, /* special_function */
+ "OP_STORE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ MINUS_ONE, /* dst_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 */
+ reloc_nil, /* special_function */
+ "OP_PSUB", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_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 */
+ reloc_nil, /* special_function */
+ "OP_PRSHIFT", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Hack. Linkage is done by linker. */
+ HOWTO (ALPHA_R_LINKAGE, /* type */
+ 0, /* rightshift */
+ 8, /* size (0 = byte, 1 = short, 2 = long) */
+ 256, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ reloc_nil, /* special_function */
+ "LINKAGE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_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 */
+ reloc_nil, /* special_function */
+ "REFLONG", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* A 64 bit reference to a procedure, written as 32 bit value. */
+ HOWTO (ALPHA_R_CODEADDR, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed,/* complain_on_overflow */
+ reloc_nil, /* special_function */
+ "CODEADDR", /* name */
+ false, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+};
+
+/* Return a pointer to a howto structure which, when invoked, will perform
+ the relocation code on data from the architecture noted. */
+
+static const struct reloc_howto_struct *
+vms_bfd_reloc_type_lookup (abfd, code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
+{
+ int alpha_type;
+
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_reloc_type_lookup(%p, %d)\t", abfd, code);
+#endif
+
+ switch (code)
+ {
+ case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
+ case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
+ case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
+ case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
+ case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
+ case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
+ case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
+ case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
+ case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
+ case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
+ case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
+ default:
+ (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
+ return (const struct reloc_howto_struct *) NULL;
+ }
+#if VMS_DEBUG
+ vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
+#endif
+ return &alpha_howto_table[alpha_type];
+}
+
+
+/*-- Part 4.7, writing an object file ---------------------------------------*/
+
+/* Set the architecture and machine type in BFD abfd to arch and mach.
+ Find the correct pointer to a structure and insert it into the arch_info
+ pointer. */
+
+static boolean
+vms_set_arch_mach (abfd, arch, mach)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long mach;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_set_arch_mach(%p, %d, %ld)\n", abfd, arch, mach);
+#endif
+ abfd->arch_info = bfd_scan_arch("alpha");
+
+ return true;
+}
+
+
+/* Sets the contents of the section section in BFD abfd to the data starting
+ in memory at data. The data is written to the output section starting at
+ offset offset for count bytes.
+
+ Normally true is returned, else false. Possible error returns are:
+ o bfd_error_no_contents - The output section does not have the
+ SEC_HAS_CONTENTS attribute, so nothing can be written to it.
+ o and some more too */
+
+static boolean
+vms_set_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_set_section_contents(%p, sec %s, loc %p, off %ld, count %d)\n",
+ abfd, section->name, location, (long int)offset, (int)count);
+ vms_debug (2, "secraw %d, seccooked %d\n", (int)section->_raw_size, (int)section->_cooked_size);
+#endif
+ return _bfd_save_vms_section(abfd, section, location, offset, count);
+}
+
+
+/*-- Part 4.8, linker -------------------------------------------------------*/
+
+/* Get the size of the section headers. */
+
+static int
+vms_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_sizeof_headers(%p, %s)\n", abfd, (reloc)?"True":"False");
+#endif
+ return 0;
+}
+
+
+/* Provides default handling of relocation effort for back ends
+ which can't be bothered to do it efficiently. */
+
+static bfd_byte *
+vms_bfd_get_relocated_section_contents (abfd, link_info, link_order, data,
+ relocateable, symbols)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+ struct bfd_link_order *link_order;
+ bfd_byte *data;
+ boolean relocateable;
+ asymbol **symbols;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_get_relocated_section_contents(%p, %p, %p, %p, %s, %p)\n",
+ abfd, link_info, link_order, data, (relocateable)?"True":"False", symbols);
+#endif
+ return 0;
+}
+
+
+/* ??? */
+
+static boolean
+vms_bfd_relax_section (abfd, section, link_info, again)
+ bfd *abfd;
+ asection *section;
+ struct bfd_link_info *link_info;
+ boolean *again;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_relax_section(%p, %s, %p, <ret>)\n",
+ abfd, section->name, link_info);
+#endif
+ return true;
+}
+
+static boolean
+vms_bfd_gc_sections (abfd, link_info)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_gc_sections(%p, %p)\n", abfd, link_info);
+#endif
+ return true;
+}
+
+
+/* Create a hash table for the linker. Different backends store
+ different information in this table. */
+
+static struct bfd_link_hash_table *
+vms_bfd_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_link_hash_table_create(%p)\n", abfd);
+#endif
+ return 0;
+}
+
+
+/* Add symbols from this object file into the hash table. */
+
+static boolean
+vms_bfd_link_add_symbols (abfd, link_info)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_link_add_symbols(%p, %p)\n", abfd, link_info);
+#endif
+ return false;
+}
+
+
+/* Do a link based on the link_order structures attached to each
+ section of the BFD. */
+
+static boolean
+vms_bfd_final_link (abfd, link_info)
+ bfd *abfd;
+ struct bfd_link_info *link_info;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_final_link(%p, %p)\n", abfd, link_info);
+#endif
+ return true;
+}
+
+/* Should this section be split up into smaller pieces during linking. */
+
+static boolean
+vms_bfd_link_split_section (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_link_split_section(%p, %s)\n", abfd, section->name);
+#endif
+ return false;
+}
+
+/*-- Part 4.9, dynamic symbols and relocations ------------------------------*/
+
+/* Get the amount of memory required to hold the dynamic symbols. */
+
+static long
+vms_get_dynamic_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_dynamic_symtab_upper_bound(%p)\n", abfd);
+#endif
+ return 0;
+}
+
+static boolean
+vms_bfd_print_private_bfd_data (abfd, file)
+ bfd *abfd;
+ void *file;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_bfd_print_private_bfd_data(%p)\n", abfd);
+#endif
+ return 0;
+}
+
+
+/* Read in the dynamic symbols. */
+
+static long
+vms_canonicalize_dynamic_symtab (abfd, symbols)
+ bfd *abfd;
+ asymbol **symbols;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_canonicalize_dynamic_symtab(%p, <ret>)\n", abfd);
+#endif
+ return 0L;
+}
+
+
+/* Get the amount of memory required to hold the dynamic relocs. */
+
+static long
+vms_get_dynamic_reloc_upper_bound (abfd)
+ bfd *abfd;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_get_dynamic_reloc_upper_bound(%p)\n", abfd);
+#endif
+ return 0L;
+}
+
+
+/* Read in the dynamic relocs. */
+
+static long
+vms_canonicalize_dynamic_reloc (abfd, arel, symbols)
+ bfd *abfd;
+ arelent **arel;
+ asymbol **symbols;
+{
+#if VMS_DEBUG
+ vms_debug (1, "vms_canonicalize_dynamic_reloc(%p)\n", abfd);
+#endif
+ return 0L;
+}
diff --git a/bfd/vms.h b/bfd/vms.h
new file mode 100644
index 00000000000..d6bdd02a720
--- /dev/null
+++ b/bfd/vms.h
@@ -0,0 +1,675 @@
+#undef vms
+/* vms.h -- Header file for VMS (Alpha and Vax) support.
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+
+ Written by Klaus K"ampf (kkaempf@rmi.de)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef VMS_H
+#define VMS_H
+
+
+/* Constants starting with 'Exxx_' are for openVMS/Alpha (EVAX object language) */
+
+/* VMS Text, information and relocation record (TIR/ETIR) definitions. */
+
+#define TIR_S_C_STA_GBL 0
+#define TIR_S_C_STA_SB 1
+#define TIR_S_C_STA_SW 2
+#define TIR_S_C_STA_LW 3
+#define TIR_S_C_STA_PB 4
+#define TIR_S_C_STA_PW 5
+#define TIR_S_C_STA_PL 6
+#define TIR_S_C_STA_UB 7
+#define TIR_S_C_STA_UW 8
+#define TIR_S_C_STA_BFI 9
+#define TIR_S_C_STA_WFI 10
+#define TIR_S_C_STA_LFI 11
+#define TIR_S_C_STA_EPM 12
+#define TIR_S_C_STA_CKARG 13
+#define TIR_S_C_STA_WPB 14
+#define TIR_S_C_STA_WPW 15
+#define TIR_S_C_STA_WPL 16
+#define TIR_S_C_STA_LSY 17
+#define TIR_S_C_STA_LIT 18
+#define TIR_S_C_STA_LEPM 19
+#define TIR_S_C_MAXSTACOD 19
+#define TIR_S_C_MINSTOCOD 20
+#define TIR_S_C_STO_SB 20
+#define TIR_S_C_STO_SW 21
+#define TIR_S_C_STO_L 22
+#define TIR_S_C_STO_LW 22
+#define TIR_S_C_STO_BD 23
+#define TIR_S_C_STO_WD 24
+#define TIR_S_C_STO_LD 25
+#define TIR_S_C_STO_LI 26
+#define TIR_S_C_STO_PIDR 27
+#define TIR_S_C_STO_PICR 28
+#define TIR_S_C_STO_RSB 29
+#define TIR_S_C_STO_RSW 30
+#define TIR_S_C_STO_RL 31
+#define TIR_S_C_STO_VPS 32
+#define TIR_S_C_STO_USB 33
+#define TIR_S_C_STO_USW 34
+#define TIR_S_C_STO_RUB 35
+#define TIR_S_C_STO_RUW 36
+#define TIR_S_C_STO_B 37
+#define TIR_S_C_STO_W 38
+#define TIR_S_C_STO_RB 39
+#define TIR_S_C_STO_RW 40
+#define TIR_S_C_STO_RIVB 41
+#define TIR_S_C_STO_PIRR 42
+#define TIR_S_C_MAXSTOCOD 42
+#define TIR_S_C_MINOPRCOD 50
+#define TIR_S_C_OPR_NOP 50
+#define TIR_S_C_OPR_ADD 51
+#define TIR_S_C_OPR_SUB 52
+#define TIR_S_C_OPR_MUL 53
+#define TIR_S_C_OPR_DIV 54
+#define TIR_S_C_OPR_AND 55
+#define TIR_S_C_OPR_IOR 56
+#define TIR_S_C_OPR_EOR 57
+#define TIR_S_C_OPR_NEG 58
+#define TIR_S_C_OPR_COM 59
+#define TIR_S_C_OPR_INSV 60
+#define TIR_S_C_OPR_ASH 61
+#define TIR_S_C_OPR_USH 62
+#define TIR_S_C_OPR_ROT 63
+#define TIR_S_C_OPR_SEL 64
+#define TIR_S_C_OPR_REDEF 65
+#define TIR_S_C_OPR_DFLIT 66
+#define TIR_S_C_MAXOPRCOD 66
+#define TIR_S_C_MINCTLCOD 80
+#define TIR_S_C_CTL_SETRB 80
+#define TIR_S_C_CTL_AUGRB 81
+#define TIR_S_C_CTL_DFLOC 82
+#define TIR_S_C_CTL_STLOC 83
+#define TIR_S_C_CTL_STKDL 84
+#define TIR_S_C_MAXCTLCOD 84
+
+#define ETIR_S_C_MINSTACOD 0 /* Minimum store code */
+#define ETIR_S_C_STA_GBL 0 /* Stack global symbol value */
+#define ETIR_S_C_STA_LW 1 /* Stack longword */
+#define ETIR_S_C_STA_QW 2 /* Stack quadword */
+#define ETIR_S_C_STA_PQ 3 /* Stack psect base plus quadword offset */
+#define ETIR_S_C_STA_LI 4 /* Stack literal */
+#define ETIR_S_C_STA_MOD 5 /* Stack module */
+#define ETIR_S_C_STA_CKARG 6 /* Check Arguments */
+#define ETIR_S_C_MAXSTACOD 6 /* Maximum stack code */
+#define ETIR_S_C_MINSTOCOD 50 /* Minimum store code */
+#define ETIR_S_C_STO_B 50 /* Store byte */
+#define ETIR_S_C_STO_W 51 /* Store word */
+#define ETIR_S_C_STO_LW 52 /* Store longword */
+#define ETIR_S_C_STO_QW 53 /* Store quadword */
+#define ETIR_S_C_STO_IMMR 54 /* Store immediate Repeated */
+#define ETIR_S_C_STO_GBL 55 /* Store global */
+#define ETIR_S_C_STO_CA 56 /* Store code address */
+#define ETIR_S_C_STO_RB 57 /* Store relative branch */
+#define ETIR_S_C_STO_AB 58 /* Store absolute branch */
+#define ETIR_S_C_STO_OFF 59 /* Store offset within psect */
+#define ETIR_S_C_STO_IMM 61 /* Store immediate */
+#define ETIR_S_C_STO_GBL_LW 62 /* Store global Longword */
+#define ETIR_S_C_STO_LP_PSB 63 /* STO_LP_PSB not valid in level 2 use STC_LP_PSB */
+#define ETIR_S_C_STO_HINT_GBL 64 /* Store 14 bit HINT at global address */
+#define ETIR_S_C_STO_HINT_PS 65 /* Store 14 bit HINT at psect + offset */
+#define ETIR_S_C_MAXSTOCOD 65 /* Maximum store code */
+#define ETIR_S_C_MINOPRCOD 100 /* Minimum operate code */
+#define ETIR_S_C_OPR_NOP 100 /* No-op */
+#define ETIR_S_C_OPR_ADD 101 /* Add */
+#define ETIR_S_C_OPR_SUB 102 /* Subtract */
+#define ETIR_S_C_OPR_MUL 103 /* Multiply */
+#define ETIR_S_C_OPR_DIV 104 /* Divide */
+#define ETIR_S_C_OPR_AND 105 /* Logical AND */
+#define ETIR_S_C_OPR_IOR 106 /* Logical inclusive OR */
+#define ETIR_S_C_OPR_EOR 107 /* Logical exclusive OR */
+#define ETIR_S_C_OPR_NEG 108 /* Negate */
+#define ETIR_S_C_OPR_COM 109 /* Complement */
+#define ETIR_S_C_OPR_INSV 110 /* Insert bit field */
+#define ETIR_S_C_OPR_ASH 111 /* Arithmetic shift */
+#define ETIR_S_C_OPR_USH 112 /* Unsigned shift */
+#define ETIR_S_C_OPR_ROT 113 /* Rotate */
+#define ETIR_S_C_OPR_SEL 114 /* Select one of three longwords on top of stack */
+#define ETIR_S_C_OPR_REDEF 115 /* Redefine this symbol after pass 2 */
+#define ETIR_S_C_OPR_DFLIT 116 /* Define a literal */
+#define ETIR_S_C_MAXOPRCOD 116 /* Maximum operate code */
+#define ETIR_S_C_MINCTLCOD 150 /* Minimum control code */
+#define ETIR_S_C_CTL_SETRB 150 /* Set relocation base */
+#define ETIR_S_C_CTL_AUGRB 151 /* Augment relocation base */
+#define ETIR_S_C_CTL_DFLOC 152 /* Define debug location */
+#define ETIR_S_C_CTL_STLOC 153 /* Set debug location */
+#define ETIR_S_C_CTL_STKDL 154 /* Stack debug location */
+#define ETIR_S_C_MAXCTLCOD 154 /* Maximum control code */
+#define ETIR_S_C_MINSTCCOD 200 /* Minimum store-conditional code */
+#define ETIR_S_C_STC_LP 200 /* Store-conditional Linkage Pair */
+#define ETIR_S_C_STC_LP_PSB 201 /* Store-conditional Linkage Pair with Procedure Signature */
+#define ETIR_S_C_STC_GBL 202 /* Store-conditional Address at global address */
+#define ETIR_S_C_STC_GCA 203 /* Store-conditional Code Address at global address */
+#define ETIR_S_C_STC_PS 204 /* Store-conditional Address at psect + offset */
+#define ETIR_S_C_STC_NOP_GBL 205 /* Store-conditional NOP at address of global */
+#define ETIR_S_C_STC_NOP_PS 206 /* Store-conditional NOP at pect + offset */
+#define ETIR_S_C_STC_BSR_GBL 207 /* Store-conditional BSR at global address */
+#define ETIR_S_C_STC_BSR_PS 208 /* Store-conditional BSR at pect + offset */
+#define ETIR_S_C_STC_LDA_GBL 209 /* Store-conditional LDA at global address */
+#define ETIR_S_C_STC_LDA_PS 210 /* Store-conditional LDA at psect + offset */
+#define ETIR_S_C_STC_BOH_GBL 211 /* Store-conditional BSR or Hint at global address */
+#define ETIR_S_C_STC_BOH_PS 212 /* Store-conditional BSR or Hint at pect + offset */
+#define ETIR_S_C_STC_NBH_GBL 213 /* Store-conditional NOP,BSR or HINT at global address */
+#define ETIR_S_C_STC_NBH_PS 214 /* Store-conditional NOP,BSR or HINT at psect + offset */
+#define ETIR_S_C_MAXSTCCOD 214 /* Maximum store-conditional code */
+
+/* VMS Global symbol definition record (GSD/EGSD). */
+
+#define GSD_S_K_ENTRIES 1
+#define GSD_S_C_ENTRIES 1
+#define GSD_S_C_PSC 0
+#define GSD_S_C_SYM 1
+#define GSD_S_C_EPM 2
+#define GSD_S_C_PRO 3
+#define GSD_S_C_SYMW 4
+#define GSD_S_C_EPMW 5
+#define GSD_S_C_PROW 6
+#define GSD_S_C_IDC 7
+#define GSD_S_C_ENV 8
+#define GSD_S_C_LSY 9
+#define GSD_S_C_LEPM 10
+#define GSD_S_C_LPRO 11
+#define GSD_S_C_SPSC 12
+#define GSD_S_C_SYMV 13
+#define GSD_S_C_EPMV 14
+#define GSD_S_C_PROV 15
+#define GSD_S_C_MAXRECTYP 15
+
+#define EGSD_S_K_ENTRIES 2 /* Offset to first entry in record */
+#define EGSD_S_C_ENTRIES 2 /* Offset to first entry in record */
+#define EGSD_S_C_PSC 0 /* Psect definition */
+#define EGSD_S_C_SYM 1 /* Symbol specification */
+#define EGSD_S_C_IDC 2 /* Random entity check */
+#define EGSD_S_C_SPSC 5 /* Shareable image psect definition */
+#define EGSD_S_C_SYMV 6 /* Vectored (dual-valued) versions of SYM, */
+#define EGSD_S_C_SYMM 7 /* Masked versions of SYM, */
+#define EGSD_S_C_SYMG 8 /* EGST - gst version of SYM */
+#define EGSD_S_C_MAXRECTYP 8 /* Maximum entry type defined */
+
+#define GPS_S_M_PIC 1
+#define GPS_S_M_LIB 2
+#define GPS_S_M_OVR 4
+#define GPS_S_M_REL 8
+#define GPS_S_M_GBL 16
+#define GPS_S_M_SHR 32
+#define GPS_S_M_EXE 64
+#define GPS_S_M_RD 128
+#define GPS_S_M_WRT 256
+#define GPS_S_M_VEC 512
+#define GPS_S_K_NAME 9
+#define GPS_S_C_NAME 9
+
+#define EGPS_S_V_PIC 0x0001
+#define EGPS_S_V_LIB 0x0002
+#define EGPS_S_V_OVR 0x0004
+#define EGPS_S_V_REL 0x0008
+#define EGPS_S_V_GBL 0x0010
+#define EGPS_S_V_SHR 0x0020
+#define EGPS_S_V_EXE 0x0040
+#define EGPS_S_V_RD 0x0080
+#define EGPS_S_V_WRT 0x0100
+#define EGPS_S_V_VEC 0x0200
+#define EGPS_S_V_NOMOD 0x0400
+#define EGPS_S_V_COM 0x0800
+
+#define GSY_S_M_WEAK 1
+#define GSY_S_M_DEF 2
+#define GSY_S_M_UNI 4
+#define GSY_S_M_REL 8
+
+#define EGSY_S_V_WEAK 0x0001
+#define EGSY_S_V_DEF 0x0002
+#define EGSY_S_V_UNI 0x0004
+#define EGSY_S_V_REL 0x0008
+#define EGSY_S_V_COMM 0x0010
+#define EGSY_S_V_VECEP 0x0020
+#define EGSY_S_V_NORM 0x0040
+
+#define LSY_S_M_DEF 2
+#define LSY_S_M_REL 8
+
+#define ENV_S_M_DEF 1
+#define ENV_S_M_NESTED 2
+
+/*
+ * Debugger symbol definitions: These are done by hand, as no
+ * machine-readable version seems
+ * to be available.
+ */
+#define DST_S_C_C 7 /* Language == "C" */
+#define DST_S_C_CXX 15 /* Language == "C++" */
+#define DST_S_C_VERSION 153
+#define DST_S_C_SOURCE 155 /* Source file */
+#define DST_S_C_PROLOG 162
+#define DST_S_C_BLKBEG 176 /* Beginning of block */
+#define DST_S_C_BLKEND 177 /* End of block */
+#define DST_S_C_ENTRY 181
+#define DST_S_C_PSECT 184
+#define DST_S_C_LINE_NUM 185 /* Line Number */
+#define DST_S_C_LBLORLIT 186
+#define DST_S_C_LABEL 187
+#define DST_S_C_MODBEG 188 /* Beginning of module */
+#define DST_S_C_MODEND 189 /* End of module */
+#define DST_S_C_RTNBEG 190 /* Beginning of routine */
+#define DST_S_C_RTNEND 191 /* End of routine */
+#define DST_S_C_DELTA_PC_W 1 /* Incr PC */
+#define DST_S_C_INCR_LINUM 2 /* Incr Line # */
+#define DST_S_C_INCR_LINUM_W 3 /* Incr Line # */
+#define DST_S_C_SET_LINUM_INCR 4
+#define DST_S_C_SET_LINUM_INCR_W 5
+#define DST_S_C_RESET_LINUM_INCR 6
+#define DST_S_C_BEG_STMT_MODE 7
+#define DST_S_C_END_STMT_MODE 8
+#define DST_S_C_SET_LINE_NUM 9 /* Set Line # */
+#define DST_S_C_SET_PC 10
+#define DST_S_C_SET_PC_W 11
+#define DST_S_C_SET_PC_L 12
+#define DST_S_C_SET_STMTNUM 13
+#define DST_S_C_TERM 14 /* End of lines */
+#define DST_S_C_TERM_W 15 /* End of lines */
+#define DST_S_C_SET_ABS_PC 16 /* Set PC */
+#define DST_S_C_DELTA_PC_L 17 /* Incr PC */
+#define DST_S_C_INCR_LINUM_L 18 /* Incr Line # */
+#define DST_S_C_SET_LINUM_B 19 /* Set Line # */
+#define DST_S_C_SET_LINUM_L 20 /* Set Line # */
+#define DST_S_C_TERM_L 21 /* End of lines */
+/* these are used with DST_S_C_SOURCE */
+#define DST_S_C_SRC_DECLFILE 1 /* Declare source file */
+#define DST_S_C_SRC_SETFILE 2 /* Set source file */
+#define DST_S_C_SRC_SETREC_L 3 /* Set record, longword value */
+#define DST_S_C_SRC_SETREC_W 4 /* Set record, word value */
+#define DST_S_C_SRC_DEFLINES_W 10 /* # of line, word counter */
+#define DST_S_C_SRC_DEFLINES_B 11 /* # of line, byte counter */
+#define DST_S_C_SRC_FORMFEED 16 /* ^L counts as a record */
+/* the following are the codes for the various data types. Anything not on
+ * the list is included under 'advanced_type'
+ */
+#define DBG_S_C_UCHAR 0x02
+#define DBG_S_C_USINT 0x03
+#define DBG_S_C_ULINT 0x04
+#define DBG_S_C_UQUAD 0x05
+#define DBG_S_C_SCHAR 0x06
+#define DBG_S_C_SSINT 0x07
+#define DBG_S_C_SLINT 0x08
+#define DBG_S_C_SQUAD 0x09
+#define DBG_S_C_REAL4 0x0a
+#define DBG_S_C_REAL8 0x0b /* D_float double */
+#define DBG_S_C_COMPLX4 0x0c /* 2xF_float complex float */
+#define DBG_S_C_COMPLX8 0x0d /* 2xD_float complex double */
+#define DBG_S_C_REAL8_G 0x1b /* G_float double */
+#define DBG_S_C_COMPLX8_G 0x1d /* 2xG_float complex double */
+#define DBG_S_C_FUNCTION_ADDR 0x17
+#define DBG_S_C_ADVANCED_TYPE 0xa3
+/* Some of these are just for future reference. [pr]
+ */
+#define DBG_S_C_UBITA 0x01 /* unsigned, aligned bit field */
+#define DBG_S_C_UBITU 0x22 /* unsigned, unaligned bit field */
+#define DBG_S_C_SBITA 0x29 /* signed, aligned bit field */
+#define DBG_S_C_SBITU 0x2a /* signed, unaligned bit field */
+#define DBG_S_C_CSTRING 0x2e /* asciz ('\0' terminated) string */
+#define DBG_S_C_WCHAR 0x38 /* wchar_t */
+/* These are descriptor class codes.
+ */
+#define DSC_K_CLASS_S 0x01 /* static (fixed length) */
+#define DSC_K_CLASS_D 0x02 /* dynamic string (not via malloc!) */
+#define DSC_K_CLASS_A 0x04 /* array */
+#define DSC_K_CLASS_UBS 0x0d /* unaligned bit string */
+/* These are the codes that are used to generate the definitions of struct
+ * union and enum records
+ */
+#define DBG_S_C_ENUM_ITEM 0xa4
+#define DBG_S_C_ENUM_START 0xa5
+#define DBG_S_C_ENUM_END 0xa6
+#define DBG_S_C_STRUCT_ITEM DST_K_VFLAGS_BITOFFS /* 0xff */
+#define DBG_S_C_STRUCT_START 0xab
+#define DBG_S_C_STRUCT_END 0xac
+#define DST_K_TYPSPEC 0xaf /* type specification */
+/* These codes are used in the generation of the symbol definition records
+ */
+#define DST_K_VFLAGS_NOVAL 0x80 /* struct definition only */
+#define DST_K_VFLAGS_DSC 0xfa /* descriptor used */
+#define DST_K_VFLAGS_TVS 0xfb /* trailing value specified */
+#define DST_K_VS_FOLLOWS 0xfd /* value spec follows */
+#define DST_K_VFLAGS_BITOFFS 0xff /* value contains bit offset */
+#define DST_K_VALKIND_LITERAL 0
+#define DST_K_VALKIND_ADDR 1
+#define DST_K_VALKIND_DESC 2
+#define DST_K_VALKIND_REG 3
+#define DST_K_REG_VAX_AP 0x0c /* R12 */
+#define DST_K_REG_VAX_FP 0x0d /* R13 */
+#define DST_K_REG_VAX_SP 0x0e /* R14 */
+#define DST_V_VALKIND 0 /* offset of valkind field */
+#define DST_V_INDIRECT 2 /* offset to indirect bit */
+#define DST_V_DISP 3 /* offset to displacement bit */
+#define DST_V_REGNUM 4 /* offset to register number */
+#define DST_M_INDIRECT (1<<DST_V_INDIRECT)
+#define DST_M_DISP (1<<DST_V_DISP)
+#define DBG_C_FUNCTION_PARAM /* 0xc9 */ \
+ (DST_K_VALKIND_ADDR|DST_M_DISP|(DST_K_REG_VAX_AP<<DST_V_REGNUM))
+#define DBG_C_LOCAL_SYM /* 0xd9 */ \
+ (DST_K_VALKIND_ADDR|DST_M_DISP|(DST_K_REG_VAX_FP<<DST_V_REGNUM))
+/* Kinds of value specifications
+ */
+#define DST_K_VS_ALLOC_SPLIT 3 /* split lifetime */
+/* Kinds of type specifications
+ */
+#define DST_K_TS_ATOM 0x01 /* atomic type specification */
+#define DST_K_TS_DSC 0x02 /* descriptor type spec */
+#define DST_K_TS_IND 0x03 /* indirect type specification */
+#define DST_K_TS_TPTR 0x04 /* typed pointer type spec */
+#define DST_K_TS_PTR 0x05 /* pointer type spec */
+#define DST_K_TS_ARRAY 0x07 /* array type spec */
+#define DST_K_TS_NOV_LENG 0x0e /* novel length type spec */
+/* These are the codes that are used in the suffix records to determine the
+ * actual data type
+ */
+#define DBG_S_C_BASIC DST_K_TS_ATOM
+#define DBG_S_C_BASIC_ARRAY DST_K_TS_DSC
+#define DBG_S_C_STRUCT DST_K_TS_IND
+#define DBG_S_C_POINTER DST_K_TS_TPTR
+#define DBG_S_C_VOID DST_K_TS_PTR
+#define DBG_S_C_COMPLEX_ARRAY DST_K_TS_ARRAY
+
+/* VMS Module header record (EMH) definitions. */
+
+#define MHD_S_C_MHD 0
+#define MHD_S_C_LNM 1
+#define MHD_S_C_SRC 2
+#define MHD_S_C_TTL 3
+#define MHD_S_C_CPR 4
+#define MHD_S_C_MTC 5
+#define MHD_S_C_GTX 6
+#define MHD_S_C_MAXHDRTYP 6
+
+#define EMH_S_C_MHD 0 /* Main header record */
+#define EMH_S_C_LNM 1 /* Language name and version */
+#define EMH_S_C_SRC 2 /* Source file specification */
+#define EMH_S_C_TTL 3 /* Title text of module */
+#define EMH_S_C_CPR 4 /* Copyright notice */
+#define EMH_S_C_MTC 5 /* Maintenance status */
+#define EMH_S_C_GTX 6 /* General text */
+#define EMH_S_C_MAXHDRTYP 6 /* Maximum allowable type */
+
+/* vms.c. */
+
+extern asymbol *_bfd_vms_make_empty_symbol PARAMS ((bfd *abfd));
+
+/* vms-gsd.c. */
+
+extern int _bfd_vms_slurp_gsd PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_write_gsd PARAMS ((bfd *abfd, int objtype));
+
+/* vms-mhd.c. */
+
+extern int _bfd_vms_slurp_hdr PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_write_hdr PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_slurp_eom PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_write_eom PARAMS ((bfd *abfd, int objtype));
+
+/* vms-tir.c. */
+
+extern int _bfd_vms_slurp_tir PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_slurp_dbg PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_slurp_tbt PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_slurp_lnk PARAMS ((bfd *abfd, int objtype));
+
+extern int _bfd_vms_write_tir PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_write_tbt PARAMS ((bfd *abfd, int objtype));
+extern int _bfd_vms_write_dbg PARAMS ((bfd *abfd, int objtype));
+
+/* The r_type field in a reloc is one of the following values. */
+#define ALPHA_R_IGNORE 0
+#define ALPHA_R_REFQUAD 1
+#define ALPHA_R_BRADDR 2
+#define ALPHA_R_HINT 3
+#define ALPHA_R_SREL16 4
+#define ALPHA_R_SREL32 5
+#define ALPHA_R_SREL64 6
+#define ALPHA_R_OP_PUSH 7
+#define ALPHA_R_OP_STORE 8
+#define ALPHA_R_OP_PSUB 9
+#define ALPHA_R_OP_PRSHIFT 10
+#define ALPHA_R_LINKAGE 11
+#define ALPHA_R_REFLONG 12
+#define ALPHA_R_CODEADDR 13
+
+/* Object language definitions. */
+
+#define OBJ_S_C_HDR 0 /*VAX module header record */
+#define OBJ_S_C_GSD 1 /*VAX global symbol definition record */
+#define OBJ_S_C_TIR 2 /*VAX text information record */
+#define OBJ_S_C_EOM 3 /*VAX end of module record */
+#define OBJ_S_C_DBG 4 /*VAX Debugger information record */
+#define OBJ_S_C_TBT 5 /*VAX Traceback information record */
+#define OBJ_S_C_LNK 6 /*VAX linker options record */
+#define OBJ_S_C_EOMW 7 /*VAX end of module word-psect record */
+#define OBJ_S_C_MAXRECTYP 7 /*VAX Last assigned record type */
+#define EOBJ_S_C_EMH 8 /*EVAX module header record */
+#define EOBJ_S_C_EEOM 9 /*EVAX end of module record */
+#define EOBJ_S_C_EGSD 10 /*EVAX global symbol definition record */
+#define EOBJ_S_C_ETIR 11 /*EVAX text information record */
+#define EOBJ_S_C_EDBG 12 /*EVAX Debugger information record */
+#define EOBJ_S_C_ETBT 13 /*EVAX Traceback information record */
+#define EOBJ_S_C_MAXRECTYP 13 /*EVAX Last assigned record type */
+#define OBJ_S_K_SUBTYP 1
+#define OBJ_S_C_SUBTYP 1
+#define EOBJ_S_K_SUBTYP 4
+#define EOBJ_S_C_SUBTYP 4
+#define OBJ_S_C_MAXRECSIZ 2048 /*Maximum legal record size */
+#define EOBJ_S_C_MAXRECSIZ 8192 /*Maximum legal record size */
+#define OBJ_S_C_STRLVL 0 /*Structure level */
+#define EOBJ_S_C_STRLVL 2 /*Structure level */
+#define OBJ_S_C_SYMSIZ 31 /*Maximum symbol length */
+#define EOBJ_S_C_SYMSIZ 64 /*Maximum symbol length */
+#define EOBJ_S_C_SECSIZ 31 /*Maximum section name length */
+#define OBJ_S_C_STOREPLIM -1 /*Maximum repeat count on store commands */
+#define EOBJ_S_C_STOREPLIM -1 /*Maximum repeat count on store commands */
+#define OBJ_S_C_PSCALILIM 9 /*Maximum p-sect alignment */
+#define EOBJ_S_C_PSCALILIM 16 /*Maximum p-sect alignment */
+
+#define EVAX_OFFSET 256 /*type offset for EVAX codes in switch */
+/* Miscellaneous definitions. */
+
+#if __GNUC__
+typedef unsigned long long uquad;
+#else
+typedef unsigned long uquad;
+#endif
+
+#define MAX_OUTREC_SIZE 4096
+#define MIN_OUTREC_LUFT 64
+
+typedef struct _vms_section {
+ unsigned char *contents;
+ bfd_vma offset;
+ bfd_size_type size;
+ struct _vms_section *next;
+} vms_section;
+
+extern boolean _bfd_save_vms_section
+ PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
+ bfd_size_type count));
+extern vms_section *_bfd_get_vms_section PARAMS ((bfd *abfd, int index));
+
+typedef struct _vms_reloc {
+ struct _vms_reloc *next;
+ arelent *reloc;
+ asection *section;
+} vms_reloc;
+
+/* vms module header */
+
+struct hdr_struc {
+ int hdr_b_strlvl;
+ long hdr_l_arch1;
+ long hdr_l_arch2;
+ long hdr_l_recsiz;
+ char *hdr_t_name;
+ char *hdr_t_version;
+ char *hdr_t_date;
+ char *hdr_c_lnm;
+ char *hdr_c_src;
+ char *hdr_c_ttl;
+};
+
+
+/* vms end of module */
+
+struct eom_struc {
+ long eom_l_total_lps;
+ unsigned char eom_b_comcod;
+ boolean eom_has_transfer;
+ unsigned char eom_b_tfrflg;
+ long eom_l_psindx;
+ long eom_l_tfradr;
+};
+
+enum file_format_enum { FF_UNKNOWN, FF_FOREIGN, FF_NATIVE, FF_VAX };
+
+typedef struct vms_symbol_struct {
+ struct bfd_hash_entry bfd_hash;
+ asymbol *symbol;
+} vms_symbol_entry;
+
+/* stack value for push/pop commands */
+
+struct stack_struct {
+ uquad value;
+ int psect;
+};
+#define STACKSIZE 8192
+
+/* location stack definitions for CTL_DFLOC, CTL_STLOC, and CTL_STKDL */
+
+struct location_struct {
+ unsigned long value;
+ int psect;
+};
+#define LOCATION_SAVE_SIZE 32
+
+#define VMS_SECTION_COUNT 1024
+
+struct vms_private_data_struct {
+ int is_vax;
+ boolean fixup_done; /* Flag to indicate if all
+ section pointers and PRIV(sections)
+ are set up correctly */
+ unsigned char *vms_buf; /* buffer to record */
+ int buf_size; /* max size of buffer */
+ unsigned char *vms_rec; /* actual record ptr */
+ int rec_length; /* remaining record length */
+ int rec_size; /* actual record size */
+ int rec_type; /* actual record type */
+ enum file_format_enum file_format;
+
+ struct hdr_struc hdr_data; /* data from HDR/EMH record */
+ struct eom_struc eom_data; /* data from EOM/EEOM record */
+ int section_count; /* # of sections in following array */
+ asection **sections; /* array of GSD/EGSD sections */
+ int gsd_sym_count; /* # of GSD/EGSD symbols */
+ asymbol **symbols; /* vector of GSD/EGSD symbols */
+ struct proc_value *procedure;
+
+ struct stack_struct *stack;
+ int stackptr;
+
+ vms_section *vms_section_table[VMS_SECTION_COUNT];
+
+ struct bfd_hash_table *vms_symbol_table;
+ struct symbol_cache_entry **symcache;
+ int symnum;
+
+ struct location_struct *location_stack;
+
+ asection *image_section; /* section for image_ptr */
+ unsigned char *image_ptr; /* a pointer to section->contents */
+
+ unsigned char pdsc[8]; /* procedure descriptor */
+
+ /* Output routine storage */
+
+ unsigned char *output_buf; /* output data */
+ int push_level;
+ int pushed_size;
+ int length_pos;
+ int output_size;
+ int output_alignment;
+
+ /* linkage index counter
+ used by conditional store commands (ETIR_S_C_STC_) */
+
+ int vms_linkage_index;
+
+ /* see tc-alpha.c of gas for a description. */
+ int flag_hash_long_names; /* -+, hash instead of truncate */
+ int flag_show_after_trunc; /* -H, show hashing/truncation */
+};
+
+#define PRIV(name) ((struct vms_private_data_struct *)abfd->tdata.any)->name
+
+#define SECTION_NAME_TEMPLATE "__SEC__%d"
+
+#if VMS_DEBUG
+extern void _bfd_vms_debug PARAMS((int level, char *format, ...));
+extern void _bfd_hexdump
+ PARAMS ((int level, unsigned char *ptr, int size, int offset));
+
+#define vms_debug _bfd_vms_debug
+#endif
+
+extern struct bfd_hash_entry *_bfd_vms_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
+ const char *string));
+extern void _bfd_vms_get_header_values
+ PARAMS ((bfd *abfd, unsigned char *buf, int *type, int *length));
+extern int _bfd_vms_get_record PARAMS ((bfd *abfd));
+extern int _bfd_vms_next_record PARAMS ((bfd *abfd));
+
+extern char *_bfd_vms_save_sized_string PARAMS ((unsigned char *str, int size));
+extern char *_bfd_vms_save_counted_string PARAMS ((unsigned char *ptr));
+extern void _bfd_vms_push PARAMS ((bfd *abfd, uquad val, int psect));
+extern uquad _bfd_vms_pop PARAMS ((bfd *abfd, int *psect));
+
+extern boolean _bfd_save_vms_section
+ PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
+ bfd_size_type count));
+extern void _bfd_vms_output_begin
+ PARAMS ((bfd *abfd, int rectype, int rechead));
+extern void _bfd_vms_output_alignment PARAMS ((bfd *abfd, int alignto));
+extern void _bfd_vms_output_push PARAMS ((bfd *abfd));
+extern void _bfd_vms_output_pop PARAMS ((bfd *abfd));
+extern void _bfd_vms_output_flush PARAMS ((bfd *abfd));
+extern void _bfd_vms_output_end PARAMS ((bfd *abfd));
+extern int _bfd_vms_output_check PARAMS ((bfd *abfd, int size));
+extern void _bfd_vms_output_byte PARAMS ((bfd *abfd, unsigned int value));
+extern void _bfd_vms_output_short PARAMS ((bfd *abfd, unsigned int value));
+extern void _bfd_vms_output_long PARAMS ((bfd *abfd, unsigned long value));
+extern void _bfd_vms_output_quad PARAMS ((bfd *abfd, uquad value));
+extern void _bfd_vms_output_counted PARAMS ((bfd *abfd, char *value));
+extern void _bfd_vms_output_dump PARAMS ((bfd *abfd, unsigned char *data,
+ int length));
+extern void _bfd_vms_output_fill PARAMS ((bfd *abfd, int value, int length));
+extern char *_bfd_vms_length_hash_symbol PARAMS ((bfd *abfd, const char *in, int maxlen));
+
+extern vms_symbol_entry *_bfd_vms_enter_symbol PARAMS ((bfd *abfd, char *name));
+
+#endif /* VMS_H */
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
new file mode 100644
index 00000000000..c882d237328
--- /dev/null
+++ b/bfd/xcofflink.c
@@ -0,0 +1,6635 @@
+/* POWER/PowerPC XCOFF linker support.
+ Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+/* This file holds the XCOFF linker code. */
+
+#define STRING_SIZE_SIZE (4)
+
+/* In order to support linking different object file formats into an
+ XCOFF format, we need to be able to determine whether a particular
+ bfd_target is an XCOFF vector. FIXME: We need to rethink this
+ whole approach. */
+#define XCOFF_XVECP(xv) \
+ (strcmp ((xv)->name, "aixcoff-rs6000") == 0 \
+ || strcmp ((xv)->name, "xcoff-powermac") == 0)
+
+/* Get the XCOFF hash table entries for a BFD. */
+#define obj_xcoff_sym_hashes(bfd) \
+ ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
+
+/* XCOFF relocation types. These probably belong in a header file
+ somewhere. The relocations are described in the function
+ _bfd_ppc_xcoff_relocate_section in this file. */
+
+#define R_POS (0x00)
+#define R_NEG (0x01)
+#define R_REL (0x02)
+#define R_TOC (0x03)
+#define R_RTB (0x04)
+#define R_GL (0x05)
+#define R_TCL (0x06)
+#define R_BA (0x08)
+#define R_BR (0x0a)
+#define R_RL (0x0c)
+#define R_RLA (0x0d)
+#define R_REF (0x0f)
+#define R_TRL (0x12)
+#define R_TRLA (0x13)
+#define R_RRTBI (0x14)
+#define R_RRTBA (0x15)
+#define R_CAI (0x16)
+#define R_CREL (0x17)
+#define R_RBA (0x18)
+#define R_RBAC (0x19)
+#define R_RBR (0x1a)
+#define R_RBRC (0x1b)
+
+/* The first word of global linkage code. This must be modified by
+ filling in the correct TOC offset. */
+
+#define XCOFF_GLINK_FIRST (0x81820000) /* lwz r12,0(r2) */
+
+/* The remaining words of global linkage code. */
+
+static unsigned long xcoff_glink_code[] =
+{
+ 0x90410014, /* stw r2,20(r1) */
+ 0x800c0000, /* lwz r0,0(r12) */
+ 0x804c0004, /* lwz r2,4(r12) */
+ 0x7c0903a6, /* mtctr r0 */
+ 0x4e800420, /* bctr */
+ 0x0, /* start of traceback table */
+ 0x000c8000, /* traceback table */
+ 0x0 /* traceback table */
+};
+
+#define XCOFF_GLINK_SIZE \
+ (((sizeof xcoff_glink_code / sizeof xcoff_glink_code[0]) * 4) + 4)
+
+/* We reuse the SEC_ROM flag as a mark flag for garbage collection.
+ This flag will only be used on input sections. */
+
+#define SEC_MARK (SEC_ROM)
+
+/* The ldhdr structure. This appears at the start of the .loader
+ section. */
+
+struct internal_ldhdr
+{
+ /* The version number: currently always 1. */
+ unsigned long l_version;
+ /* The number of symbol table entries. */
+ bfd_size_type l_nsyms;
+ /* The number of relocation table entries. */
+ bfd_size_type l_nreloc;
+ /* The length of the import file string table. */
+ bfd_size_type l_istlen;
+ /* The number of import files. */
+ bfd_size_type l_nimpid;
+ /* The offset from the start of the .loader section to the first
+ entry in the import file table. */
+ bfd_size_type l_impoff;
+ /* The length of the string table. */
+ bfd_size_type l_stlen;
+ /* The offset from the start of the .loader section to the first
+ entry in the string table. */
+ bfd_size_type l_stoff;
+};
+
+struct external_ldhdr
+{
+ bfd_byte l_version[4];
+ bfd_byte l_nsyms[4];
+ bfd_byte l_nreloc[4];
+ bfd_byte l_istlen[4];
+ bfd_byte l_nimpid[4];
+ bfd_byte l_impoff[4];
+ bfd_byte l_stlen[4];
+ bfd_byte l_stoff[4];
+};
+
+#define LDHDRSZ (8 * 4)
+
+/* The ldsym structure. This is used to represent a symbol in the
+ .loader section. */
+
+struct internal_ldsym
+{
+ union
+ {
+ /* The symbol name if <= SYMNMLEN characters. */
+ char _l_name[SYMNMLEN];
+ struct
+ {
+ /* Zero if the symbol name is more than SYMNMLEN characters. */
+ long _l_zeroes;
+ /* The offset in the string table if the symbol name is more
+ than SYMNMLEN characters. */
+ long _l_offset;
+ } _l_l;
+ } _l;
+ /* The symbol value. */
+ bfd_vma l_value;
+ /* The symbol section number. */
+ short l_scnum;
+ /* The symbol type and flags. */
+ char l_smtype;
+ /* The symbol storage class. */
+ char l_smclas;
+ /* The import file ID. */
+ bfd_size_type l_ifile;
+ /* Offset to the parameter type check string. */
+ bfd_size_type l_parm;
+};
+
+struct external_ldsym
+{
+ union
+ {
+ bfd_byte _l_name[SYMNMLEN];
+ struct
+ {
+ bfd_byte _l_zeroes[4];
+ bfd_byte _l_offset[4];
+ } _l_l;
+ } _l;
+ bfd_byte l_value[4];
+ bfd_byte l_scnum[2];
+ bfd_byte l_smtype[1];
+ bfd_byte l_smclas[1];
+ bfd_byte l_ifile[4];
+ bfd_byte l_parm[4];
+};
+
+#define LDSYMSZ (8 + 3 * 4 + 2 + 2)
+
+/* These flags are for the l_smtype field (the lower three bits are an
+ XTY_* value). */
+
+/* Imported symbol. */
+#define L_IMPORT (0x40)
+/* Entry point. */
+#define L_ENTRY (0x20)
+/* Exported symbol. */
+#define L_EXPORT (0x10)
+
+/* The ldrel structure. This is used to represent a reloc in the
+ .loader section. */
+
+struct internal_ldrel
+{
+ /* The reloc address. */
+ bfd_vma l_vaddr;
+ /* The symbol table index in the .loader section symbol table. */
+ bfd_size_type l_symndx;
+ /* The relocation type and size. */
+ short l_rtype;
+ /* The section number this relocation applies to. */
+ short l_rsecnm;
+};
+
+struct external_ldrel
+{
+ bfd_byte l_vaddr[4];
+ bfd_byte l_symndx[4];
+ bfd_byte l_rtype[2];
+ bfd_byte l_rsecnm[2];
+};
+
+#define LDRELSZ (2 * 4 + 2 * 2)
+
+/* The list of import files. */
+
+struct xcoff_import_file
+{
+ /* The next entry in the list. */
+ struct xcoff_import_file *next;
+ /* The path. */
+ const char *path;
+ /* The file name. */
+ const char *file;
+ /* The member name. */
+ const char *member;
+};
+
+/* An entry in the XCOFF linker hash table. */
+
+struct xcoff_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+
+ /* Symbol index in output file. Set to -1 initially. Set to -2 if
+ there is a reloc against this symbol. */
+ long indx;
+
+ /* If we have created a TOC entry for this symbol, this is the .tc
+ section which holds it. */
+ asection *toc_section;
+
+ union
+ {
+ /* If we have created a TOC entry (the XCOFF_SET_TOC flag is
+ set), this is the offset in toc_section. */
+ bfd_vma toc_offset;
+ /* If the TOC entry comes from an input file, this is set to the
+ symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol. */
+ long toc_indx;
+ } u;
+
+ /* If this symbol is a function entry point which is called, this
+ field holds a pointer to the function descriptor. If this symbol
+ is a function descriptor, this field holds a pointer to the
+ function entry point. */
+ struct xcoff_link_hash_entry *descriptor;
+
+ /* The .loader symbol table entry, if there is one. */
+ struct internal_ldsym *ldsym;
+
+ /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table
+ index. If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set,
+ this is the l_ifile value. */
+ long ldindx;
+
+ /* Some linker flags. */
+ unsigned short flags;
+ /* Symbol is referenced by a regular object. */
+#define XCOFF_REF_REGULAR (01)
+ /* Symbol is defined by a regular object. */
+#define XCOFF_DEF_REGULAR (02)
+ /* Symbol is defined by a dynamic object. */
+#define XCOFF_DEF_DYNAMIC (04)
+ /* Symbol is used in a reloc being copied into the .loader section. */
+#define XCOFF_LDREL (010)
+ /* Symbol is the entry point. */
+#define XCOFF_ENTRY (020)
+ /* Symbol is called; this is, it appears in a R_BR reloc. */
+#define XCOFF_CALLED (040)
+ /* Symbol needs the TOC entry filled in. */
+#define XCOFF_SET_TOC (0100)
+ /* Symbol is explicitly imported. */
+#define XCOFF_IMPORT (0200)
+ /* Symbol is explicitly exported. */
+#define XCOFF_EXPORT (0400)
+ /* Symbol has been processed by xcoff_build_ldsyms. */
+#define XCOFF_BUILT_LDSYM (01000)
+ /* Symbol is mentioned by a section which was not garbage collected. */
+#define XCOFF_MARK (02000)
+ /* Symbol size is recorded in size_list list from hash table. */
+#define XCOFF_HAS_SIZE (04000)
+ /* Symbol is a function descriptor. */
+#define XCOFF_DESCRIPTOR (010000)
+ /* Multiple definitions have been for the symbol. */
+#define XCOFF_MULTIPLY_DEFINED (020000)
+
+ /* The storage mapping class. */
+ unsigned char smclas;
+};
+
+/* The XCOFF linker hash table. */
+
+struct xcoff_link_hash_table
+{
+ struct bfd_link_hash_table root;
+
+ /* The .debug string hash table. We need to compute this while
+ reading the input files, so that we know how large the .debug
+ section will be before we assign section positions. */
+ struct bfd_strtab_hash *debug_strtab;
+
+ /* The .debug section we will use for the final output. */
+ asection *debug_section;
+
+ /* The .loader section we will use for the final output. */
+ asection *loader_section;
+
+ /* A count of non TOC relative relocs which will need to be
+ allocated in the .loader section. */
+ size_t ldrel_count;
+
+ /* The .loader section header. */
+ struct internal_ldhdr ldhdr;
+
+ /* The .gl section we use to hold global linkage code. */
+ asection *linkage_section;
+
+ /* The .tc section we use to hold toc entries we build for global
+ linkage code. */
+ asection *toc_section;
+
+ /* The .ds section we use to hold function descriptors which we
+ create for exported symbols. */
+ asection *descriptor_section;
+
+ /* The list of import files. */
+ struct xcoff_import_file *imports;
+
+ /* Required alignment of sections within the output file. */
+ unsigned long file_align;
+
+ /* Whether the .text section must be read-only. */
+ boolean textro;
+
+ /* Whether garbage collection was done. */
+ boolean gc;
+
+ /* A linked list of symbols for which we have size information. */
+ struct xcoff_link_size_list
+ {
+ struct xcoff_link_size_list *next;
+ struct xcoff_link_hash_entry *h;
+ bfd_size_type size;
+ } *size_list;
+
+ /* Magic sections: _text, _etext, _data, _edata, _end, end. */
+ asection *special_sections[6];
+};
+
+/* Information we keep for each section in the output file during the
+ final link phase. */
+
+struct xcoff_link_section_info
+{
+ /* The relocs to be output. */
+ struct internal_reloc *relocs;
+ /* For each reloc against a global symbol whose index was not known
+ when the reloc was handled, the global hash table entry. */
+ struct xcoff_link_hash_entry **rel_hashes;
+ /* If there is a TOC relative reloc against a global symbol, and the
+ index of the TOC symbol is not known when the reloc was handled,
+ an entry is added to this linked list. This is not an array,
+ like rel_hashes, because this case is quite uncommon. */
+ struct xcoff_toc_rel_hash
+ {
+ struct xcoff_toc_rel_hash *next;
+ struct xcoff_link_hash_entry *h;
+ struct internal_reloc *rel;
+ } *toc_rel_hashes;
+};
+
+/* Information that we pass around while doing the final link step. */
+
+struct xcoff_final_link_info
+{
+ /* General link information. */
+ struct bfd_link_info *info;
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* Hash table for long symbol names. */
+ struct bfd_strtab_hash *strtab;
+ /* Array of information kept for each output section, indexed by the
+ target_index field. */
+ struct xcoff_link_section_info *section_info;
+ /* Symbol index of last C_FILE symbol (-1 if none). */
+ long last_file_index;
+ /* Contents of last C_FILE symbol. */
+ struct internal_syment last_file;
+ /* Symbol index of TOC symbol. */
+ long toc_symindx;
+ /* Start of .loader symbols. */
+ struct external_ldsym *ldsym;
+ /* Next .loader reloc to swap out. */
+ struct external_ldrel *ldrel;
+ /* File position of start of line numbers. */
+ file_ptr line_filepos;
+ /* Buffer large enough to hold swapped symbols of any input file. */
+ struct internal_syment *internal_syms;
+ /* Buffer large enough to hold output indices of symbols of any
+ input file. */
+ long *sym_indices;
+ /* Buffer large enough to hold output symbols for any input file. */
+ bfd_byte *outsyms;
+ /* Buffer large enough to hold external line numbers for any input
+ section. */
+ bfd_byte *linenos;
+ /* Buffer large enough to hold any input section. */
+ bfd_byte *contents;
+ /* Buffer large enough to hold external relocs of any input section. */
+ bfd_byte *external_relocs;
+};
+
+static void xcoff_swap_ldhdr_in
+ PARAMS ((bfd *, const struct external_ldhdr *, struct internal_ldhdr *));
+static void xcoff_swap_ldhdr_out
+ PARAMS ((bfd *, const struct internal_ldhdr *, struct external_ldhdr *));
+static void xcoff_swap_ldsym_in
+ PARAMS ((bfd *, const struct external_ldsym *, struct internal_ldsym *));
+static void xcoff_swap_ldsym_out
+ PARAMS ((bfd *, const struct internal_ldsym *, struct external_ldsym *));
+static void xcoff_swap_ldrel_in
+ PARAMS ((bfd *, const struct external_ldrel *, struct internal_ldrel *));
+static void xcoff_swap_ldrel_out
+ PARAMS ((bfd *, const struct internal_ldrel *, struct external_ldrel *));
+static struct bfd_hash_entry *xcoff_link_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static boolean xcoff_get_section_contents PARAMS ((bfd *, asection *));
+static struct internal_reloc *xcoff_read_internal_relocs
+ PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
+ struct internal_reloc *));
+static boolean xcoff_link_add_object_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean xcoff_link_check_archive_element
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *));
+static boolean xcoff_link_check_ar_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *));
+static boolean xcoff_link_check_dynamic_ar_symbols
+ PARAMS ((bfd *, struct bfd_link_info *, boolean *));
+static bfd_size_type xcoff_find_reloc
+ PARAMS ((struct internal_reloc *, bfd_size_type, bfd_vma));
+static boolean xcoff_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *));
+static boolean xcoff_link_add_dynamic_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean xcoff_mark_symbol
+ PARAMS ((struct bfd_link_info *, struct xcoff_link_hash_entry *));
+static boolean xcoff_mark PARAMS ((struct bfd_link_info *, asection *));
+static void xcoff_sweep PARAMS ((struct bfd_link_info *));
+static boolean xcoff_build_ldsyms
+ PARAMS ((struct xcoff_link_hash_entry *, PTR));
+static boolean xcoff_link_input_bfd
+ PARAMS ((struct xcoff_final_link_info *, bfd *));
+static boolean xcoff_write_global_symbol
+ PARAMS ((struct xcoff_link_hash_entry *, PTR));
+static boolean xcoff_reloc_link_order
+ PARAMS ((bfd *, struct xcoff_final_link_info *, asection *,
+ struct bfd_link_order *));
+static int xcoff_sort_relocs PARAMS ((const PTR, const PTR));
+
+/* Routines to swap information in the XCOFF .loader section. If we
+ ever need to write an XCOFF loader, this stuff will need to be
+ moved to another file shared by the linker (which XCOFF calls the
+ ``binder'') and the loader. */
+
+/* Swap in the ldhdr structure. */
+
+static void
+xcoff_swap_ldhdr_in (abfd, src, dst)
+ bfd *abfd;
+ const struct external_ldhdr *src;
+ struct internal_ldhdr *dst;
+{
+ dst->l_version = bfd_get_32 (abfd, src->l_version);
+ dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms);
+ dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc);
+ dst->l_istlen = bfd_get_32 (abfd, src->l_istlen);
+ dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid);
+ dst->l_impoff = bfd_get_32 (abfd, src->l_impoff);
+ dst->l_stlen = bfd_get_32 (abfd, src->l_stlen);
+ dst->l_stoff = bfd_get_32 (abfd, src->l_stoff);
+}
+
+/* Swap out the ldhdr structure. */
+
+static void
+xcoff_swap_ldhdr_out (abfd, src, dst)
+ bfd *abfd;
+ const struct internal_ldhdr *src;
+ struct external_ldhdr *dst;
+{
+ bfd_put_32 (abfd, src->l_version, dst->l_version);
+ bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
+ bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
+ bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
+ bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid);
+ bfd_put_32 (abfd, src->l_impoff, dst->l_impoff);
+ bfd_put_32 (abfd, src->l_stlen, dst->l_stlen);
+ bfd_put_32 (abfd, src->l_stoff, dst->l_stoff);
+}
+
+/* Swap in the ldsym structure. */
+
+static void
+xcoff_swap_ldsym_in (abfd, src, dst)
+ bfd *abfd;
+ const struct external_ldsym *src;
+ struct internal_ldsym *dst;
+{
+ if (bfd_get_32 (abfd, src->_l._l_l._l_zeroes) != 0)
+ memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);
+ else
+ {
+ dst->_l._l_l._l_zeroes = 0;
+ dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->_l._l_l._l_offset);
+ }
+ dst->l_value = bfd_get_32 (abfd, src->l_value);
+ dst->l_scnum = bfd_get_16 (abfd, src->l_scnum);
+ dst->l_smtype = bfd_get_8 (abfd, src->l_smtype);
+ dst->l_smclas = bfd_get_8 (abfd, src->l_smclas);
+ dst->l_ifile = bfd_get_32 (abfd, src->l_ifile);
+ dst->l_parm = bfd_get_32 (abfd, src->l_parm);
+}
+
+/* Swap out the ldsym structure. */
+
+static void
+xcoff_swap_ldsym_out (abfd, src, dst)
+ bfd *abfd;
+ const struct internal_ldsym *src;
+ struct external_ldsym *dst;
+{
+ if (src->_l._l_l._l_zeroes != 0)
+ memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);
+ else
+ {
+ bfd_put_32 (abfd, 0, dst->_l._l_l._l_zeroes);
+ bfd_put_32 (abfd, src->_l._l_l._l_offset, dst->_l._l_l._l_offset);
+ }
+ bfd_put_32 (abfd, src->l_value, dst->l_value);
+ bfd_put_16 (abfd, src->l_scnum, dst->l_scnum);
+ bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
+ bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
+ bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
+ bfd_put_32 (abfd, src->l_parm, dst->l_parm);
+}
+
+/* Swap in the ldrel structure. */
+
+static void
+xcoff_swap_ldrel_in (abfd, src, dst)
+ bfd *abfd;
+ const struct external_ldrel *src;
+ struct internal_ldrel *dst;
+{
+ dst->l_vaddr = bfd_get_32 (abfd, src->l_vaddr);
+ dst->l_symndx = bfd_get_32 (abfd, src->l_symndx);
+ dst->l_rtype = bfd_get_16 (abfd, src->l_rtype);
+ dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm);
+}
+
+/* Swap out the ldrel structure. */
+
+static void
+xcoff_swap_ldrel_out (abfd, src, dst)
+ bfd *abfd;
+ const struct internal_ldrel *src;
+ struct external_ldrel *dst;
+{
+ bfd_put_32 (abfd, src->l_vaddr, dst->l_vaddr);
+ bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
+ bfd_put_16 (abfd, src->l_rtype, dst->l_rtype);
+ bfd_put_16 (abfd, src->l_rsecnm, dst->l_rsecnm);
+}
+
+/* Routines to read XCOFF dynamic information. This don't really
+ belong here, but we already have the ldsym manipulation routines
+ here. */
+
+/* Read the contents of a section. */
+
+static boolean
+xcoff_get_section_contents (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ if (coff_section_data (abfd, sec) == NULL)
+ {
+ sec->used_by_bfd = bfd_zalloc (abfd,
+ sizeof (struct coff_section_tdata));
+ if (sec->used_by_bfd == NULL)
+ return false;
+ }
+
+ if (coff_section_data (abfd, sec)->contents == NULL)
+ {
+ coff_section_data (abfd, sec)->contents =
+ (bfd_byte *) bfd_malloc (sec->_raw_size);
+ if (coff_section_data (abfd, sec)->contents == NULL)
+ return false;
+
+ if (! bfd_get_section_contents (abfd, sec,
+ coff_section_data (abfd, sec)->contents,
+ (file_ptr) 0, sec->_raw_size))
+ return false;
+ }
+
+ return true;
+}
+
+/* Get the size required to hold the dynamic symbols. */
+
+long
+_bfd_xcoff_get_dynamic_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ asection *lsec;
+ bfd_byte *contents;
+ struct internal_ldhdr ldhdr;
+
+ if ((abfd->flags & DYNAMIC) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ lsec = bfd_get_section_by_name (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ if (! xcoff_get_section_contents (abfd, lsec))
+ return -1;
+ contents = coff_section_data (abfd, lsec)->contents;
+
+ xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);
+
+ return (ldhdr.l_nsyms + 1) * sizeof (asymbol *);
+}
+
+/* Get the dynamic symbols. */
+
+long
+_bfd_xcoff_canonicalize_dynamic_symtab (abfd, psyms)
+ bfd *abfd;
+ asymbol **psyms;
+{
+ asection *lsec;
+ bfd_byte *contents;
+ struct internal_ldhdr ldhdr;
+ const char *strings;
+ struct external_ldsym *elsym, *elsymend;
+ coff_symbol_type *symbuf;
+
+ if ((abfd->flags & DYNAMIC) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ lsec = bfd_get_section_by_name (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ if (! xcoff_get_section_contents (abfd, lsec))
+ return -1;
+ contents = coff_section_data (abfd, lsec)->contents;
+
+ coff_section_data (abfd, lsec)->keep_contents = true;
+
+ xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);
+
+ strings = (char *) contents + ldhdr.l_stoff;
+
+ symbuf = ((coff_symbol_type *)
+ bfd_zalloc (abfd, ldhdr.l_nsyms * sizeof (coff_symbol_type)));
+ if (symbuf == NULL)
+ return -1;
+
+ elsym = (struct external_ldsym *) (contents + LDHDRSZ);
+ elsymend = elsym + ldhdr.l_nsyms;
+ for (; elsym < elsymend; elsym++, symbuf++, psyms++)
+ {
+ struct internal_ldsym ldsym;
+
+ xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
+
+ symbuf->symbol.the_bfd = abfd;
+
+ if (ldsym._l._l_l._l_zeroes == 0)
+ symbuf->symbol.name = strings + ldsym._l._l_l._l_offset;
+ else
+ {
+ int i;
+
+ for (i = 0; i < SYMNMLEN; i++)
+ if (ldsym._l._l_name[i] == '\0')
+ break;
+ if (i < SYMNMLEN)
+ symbuf->symbol.name = (char *) elsym->_l._l_name;
+ else
+ {
+ char *c;
+
+ c = bfd_alloc (abfd, SYMNMLEN + 1);
+ if (c == NULL)
+ return -1;
+ memcpy (c, ldsym._l._l_name, SYMNMLEN);
+ c[SYMNMLEN] = '\0';
+ symbuf->symbol.name = c;
+ }
+ }
+
+ if (ldsym.l_smclas == XMC_XO)
+ symbuf->symbol.section = bfd_abs_section_ptr;
+ else
+ symbuf->symbol.section = coff_section_from_bfd_index (abfd,
+ ldsym.l_scnum);
+ symbuf->symbol.value = ldsym.l_value - symbuf->symbol.section->vma;
+
+ symbuf->symbol.flags = BSF_NO_FLAGS;
+ if ((ldsym.l_smtype & L_EXPORT) != 0)
+ symbuf->symbol.flags |= BSF_GLOBAL;
+
+ /* FIXME: We have no way to record the other information stored
+ with the loader symbol. */
+
+ *psyms = (asymbol *) symbuf;
+ }
+
+ *psyms = NULL;
+
+ return ldhdr.l_nsyms;
+}
+
+/* Get the size required to hold the dynamic relocs. */
+
+long
+_bfd_xcoff_get_dynamic_reloc_upper_bound (abfd)
+ bfd *abfd;
+{
+ asection *lsec;
+ bfd_byte *contents;
+ struct internal_ldhdr ldhdr;
+
+ if ((abfd->flags & DYNAMIC) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ lsec = bfd_get_section_by_name (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ if (! xcoff_get_section_contents (abfd, lsec))
+ return -1;
+ contents = coff_section_data (abfd, lsec)->contents;
+
+ xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);
+
+ return (ldhdr.l_nreloc + 1) * sizeof (arelent *);
+}
+
+/* The typical dynamic reloc. */
+
+static reloc_howto_type xcoff_dynamic_reloc =
+ 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, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false); /* pcrel_offset */
+
+/* Get the dynamic relocs. */
+
+long
+_bfd_xcoff_canonicalize_dynamic_reloc (abfd, prelocs, syms)
+ bfd *abfd;
+ arelent **prelocs;
+ asymbol **syms;
+{
+ asection *lsec;
+ bfd_byte *contents;
+ struct internal_ldhdr ldhdr;
+ arelent *relbuf;
+ struct external_ldrel *elrel, *elrelend;
+
+ if ((abfd->flags & DYNAMIC) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
+ lsec = bfd_get_section_by_name (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return -1;
+ }
+
+ if (! xcoff_get_section_contents (abfd, lsec))
+ return -1;
+ contents = coff_section_data (abfd, lsec)->contents;
+
+ xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);
+
+ relbuf = (arelent *) bfd_alloc (abfd, ldhdr.l_nreloc * sizeof (arelent));
+ if (relbuf == NULL)
+ return -1;
+
+ elrel = ((struct external_ldrel *)
+ (contents + LDHDRSZ + ldhdr.l_nsyms * LDSYMSZ));
+ elrelend = elrel + ldhdr.l_nreloc;
+ for (; elrel < elrelend; elrel++, relbuf++, prelocs++)
+ {
+ struct internal_ldrel ldrel;
+
+ xcoff_swap_ldrel_in (abfd, elrel, &ldrel);
+
+ if (ldrel.l_symndx >= 3)
+ relbuf->sym_ptr_ptr = syms + (ldrel.l_symndx - 3);
+ else
+ {
+ const char *name;
+ asection *sec;
+
+ switch (ldrel.l_symndx)
+ {
+ case 0:
+ name = ".text";
+ break;
+ case 1:
+ name = ".data";
+ break;
+ case 2:
+ name = ".bss";
+ break;
+ default:
+ abort ();
+ break;
+ }
+
+ sec = bfd_get_section_by_name (abfd, name);
+ if (sec == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return -1;
+ }
+
+ relbuf->sym_ptr_ptr = sec->symbol_ptr_ptr;
+ }
+
+ relbuf->address = ldrel.l_vaddr;
+ relbuf->addend = 0;
+
+ /* Most dynamic relocs have the same type. FIXME: This is only
+ correct if ldrel.l_rtype == 0. In other cases, we should use
+ a different howto. */
+ relbuf->howto = &xcoff_dynamic_reloc;
+
+ /* FIXME: We have no way to record the l_rsecnm field. */
+
+ *prelocs = relbuf;
+ }
+
+ *prelocs = NULL;
+
+ return ldhdr.l_nreloc;
+}
+
+/* Routine to create an entry in an XCOFF link hash table. */
+
+static struct bfd_hash_entry *
+xcoff_link_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct xcoff_link_hash_entry *ret = (struct xcoff_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct xcoff_link_hash_entry *) NULL)
+ ret = ((struct xcoff_link_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct xcoff_link_hash_entry)));
+ if (ret == (struct xcoff_link_hash_entry *) NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct xcoff_link_hash_entry *)
+ _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+ table, string));
+ if (ret != NULL)
+ {
+ /* Set local fields. */
+ ret->indx = -1;
+ ret->toc_section = NULL;
+ ret->u.toc_indx = -1;
+ ret->descriptor = NULL;
+ ret->ldsym = NULL;
+ ret->ldindx = -1;
+ ret->flags = 0;
+ ret->smclas = XMC_UA;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Create a XCOFF link hash table. */
+
+struct bfd_link_hash_table *
+_bfd_xcoff_bfd_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct xcoff_link_hash_table *ret;
+
+ ret = ((struct xcoff_link_hash_table *)
+ bfd_alloc (abfd, sizeof (struct xcoff_link_hash_table)));
+ if (ret == (struct xcoff_link_hash_table *) NULL)
+ return (struct bfd_link_hash_table *) NULL;
+ if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return (struct bfd_link_hash_table *) NULL;
+ }
+
+ ret->debug_strtab = _bfd_xcoff_stringtab_init ();
+ ret->debug_section = NULL;
+ ret->loader_section = NULL;
+ ret->ldrel_count = 0;
+ memset (&ret->ldhdr, 0, sizeof (struct internal_ldhdr));
+ ret->linkage_section = NULL;
+ ret->toc_section = NULL;
+ ret->descriptor_section = NULL;
+ ret->imports = NULL;
+ ret->file_align = 0;
+ ret->textro = false;
+ ret->gc = false;
+ memset (ret->special_sections, 0, sizeof ret->special_sections);
+
+ /* The linker will always generate a full a.out header. We need to
+ record that fact now, before the sizeof_headers routine could be
+ called. */
+ xcoff_data (abfd)->full_aouthdr = true;
+
+ return &ret->root;
+}
+
+/* Look up an entry in an XCOFF link hash table. */
+
+#define xcoff_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct xcoff_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
+ (follow)))
+
+/* Traverse an XCOFF link hash table. */
+
+#define xcoff_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the XCOFF link hash table from the info structure. This is
+ just a cast. */
+
+#define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
+
+/* Read internal relocs for an XCOFF csect. This is a wrapper around
+ _bfd_coff_read_internal_relocs which tries to take advantage of any
+ relocs which may have been cached for the enclosing section. */
+
+static struct internal_reloc *
+xcoff_read_internal_relocs (abfd, sec, cache, external_relocs,
+ require_internal, internal_relocs)
+ bfd *abfd;
+ asection *sec;
+ boolean cache;
+ bfd_byte *external_relocs;
+ boolean require_internal;
+ struct internal_reloc *internal_relocs;
+{
+ if (coff_section_data (abfd, sec) != NULL
+ && coff_section_data (abfd, sec)->relocs == NULL
+ && xcoff_section_data (abfd, sec) != NULL)
+ {
+ asection *enclosing;
+
+ enclosing = xcoff_section_data (abfd, sec)->enclosing;
+
+ if (enclosing != NULL
+ && (coff_section_data (abfd, enclosing) == NULL
+ || coff_section_data (abfd, enclosing)->relocs == NULL)
+ && cache
+ && enclosing->reloc_count > 0)
+ {
+ if (_bfd_coff_read_internal_relocs (abfd, enclosing, true,
+ external_relocs, false,
+ (struct internal_reloc *) NULL)
+ == NULL)
+ return NULL;
+ }
+
+ if (enclosing != NULL
+ && coff_section_data (abfd, enclosing) != NULL
+ && coff_section_data (abfd, enclosing)->relocs != NULL)
+ {
+ size_t off;
+
+ off = ((sec->rel_filepos - enclosing->rel_filepos)
+ / bfd_coff_relsz (abfd));
+ if (! require_internal)
+ return coff_section_data (abfd, enclosing)->relocs + off;
+ memcpy (internal_relocs,
+ coff_section_data (abfd, enclosing)->relocs + off,
+ sec->reloc_count * sizeof (struct internal_reloc));
+ return internal_relocs;
+ }
+ }
+
+ return _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
+ require_internal, internal_relocs);
+}
+
+/* Given an XCOFF BFD, add symbols to the global hash table as
+ appropriate. */
+
+boolean
+_bfd_xcoff_bfd_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_object:
+ return xcoff_link_add_object_symbols (abfd, info);
+
+ case bfd_archive:
+ /* If the archive has a map, do the usual search. We then need
+ to check the archive for stripped dynamic objects, because
+ they will not appear in the archive map even though they
+ should, perhaps, be included. If the archive has no map, we
+ just consider each object file in turn, since that apparently
+ is what the AIX native linker does. */
+ if (bfd_has_map (abfd))
+ {
+ if (! (_bfd_generic_link_add_archive_symbols
+ (abfd, info, xcoff_link_check_archive_element)))
+ return false;
+ }
+
+ {
+ bfd *member;
+
+ member = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
+ while (member != NULL)
+ {
+ if (bfd_check_format (member, bfd_object)
+ && (! bfd_has_map (abfd)
+ || ((member->flags & DYNAMIC) != 0
+ && (member->flags & HAS_SYMS) == 0)))
+ {
+ boolean needed;
+
+ if (! xcoff_link_check_archive_element (member, info, &needed))
+ return false;
+ if (needed)
+ member->archive_pass = -1;
+ }
+ member = bfd_openr_next_archived_file (abfd, member);
+ }
+ }
+
+ return true;
+
+ default:
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+}
+
+/* Add symbols from an XCOFF object file. */
+
+static boolean
+xcoff_link_add_object_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (! _bfd_coff_get_external_symbols (abfd))
+ return false;
+ if (! xcoff_link_add_symbols (abfd, info))
+ return false;
+ if (! info->keep_memory)
+ {
+ if (! _bfd_coff_free_symbols (abfd))
+ return false;
+ }
+ return true;
+}
+
+/* Check a single archive element to see if we need to include it in
+ the link. *PNEEDED is set according to whether this element is
+ needed in the link or not. This is called via
+ _bfd_generic_link_add_archive_symbols. */
+
+static boolean
+xcoff_link_check_archive_element (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ if (! _bfd_coff_get_external_symbols (abfd))
+ return false;
+
+ if (! xcoff_link_check_ar_symbols (abfd, info, pneeded))
+ return false;
+
+ if (*pneeded)
+ {
+ if (! xcoff_link_add_symbols (abfd, info))
+ return false;
+ }
+
+ if (! info->keep_memory || ! *pneeded)
+ {
+ if (! _bfd_coff_free_symbols (abfd))
+ return false;
+ }
+
+ return true;
+}
+
+/* Look through the symbols to see if this object file should be
+ included in the link. */
+
+static boolean
+xcoff_link_check_ar_symbols (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ bfd_size_type symesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
+
+ *pneeded = false;
+
+ if ((abfd->flags & DYNAMIC) != 0
+ && ! info->static_link
+ && info->hash->creator == abfd->xvec)
+ return xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded);
+
+ symesz = bfd_coff_symesz (abfd);
+ esym = (bfd_byte *) obj_coff_external_syms (abfd);
+ esym_end = esym + obj_raw_syment_count (abfd) * symesz;
+ while (esym < esym_end)
+ {
+ struct internal_syment sym;
+
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
+
+ if (sym.n_sclass == C_EXT && sym.n_scnum != N_UNDEF)
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ struct bfd_link_hash_entry *h;
+
+ /* This symbol is externally visible, and is defined by this
+ object file. */
+
+ name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
+ if (name == NULL)
+ return false;
+ h = bfd_link_hash_lookup (info->hash, name, false, false, true);
+
+ /* We are only interested in symbols that are currently
+ undefined. If a symbol is currently known to be common,
+ XCOFF linkers do not bring in an object file which
+ defines it. We also don't bring in symbols to satisfy
+ undefined references in shared objects. */
+ if (h != (struct bfd_link_hash_entry *) NULL
+ && h->type == bfd_link_hash_undefined
+ && (info->hash->creator != abfd->xvec
+ || (((struct xcoff_link_hash_entry *) h)->flags
+ & XCOFF_DEF_DYNAMIC) == 0))
+ {
+ if (! (*info->callbacks->add_archive_element) (info, abfd, name))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+ }
+
+ esym += (sym.n_numaux + 1) * symesz;
+ }
+
+ /* We do not need this object file. */
+ return true;
+}
+
+/* Look through the loader symbols to see if this dynamic object
+ should be included in the link. The native linker uses the loader
+ symbols, not the normal symbol table, so we do too. */
+
+static boolean
+xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ boolean *pneeded;
+{
+ asection *lsec;
+ bfd_byte *buf;
+ struct internal_ldhdr ldhdr;
+ const char *strings;
+ struct external_ldsym *elsym, *elsymend;
+
+ *pneeded = false;
+
+ lsec = bfd_get_section_by_name (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ /* There are no symbols, so don't try to include it. */
+ return true;
+ }
+
+ if (! xcoff_get_section_contents (abfd, lsec))
+ return false;
+ buf = coff_section_data (abfd, lsec)->contents;
+
+ xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) buf, &ldhdr);
+
+ strings = (char *) buf + ldhdr.l_stoff;
+
+ elsym = (struct external_ldsym *) (buf + LDHDRSZ);
+ elsymend = elsym + ldhdr.l_nsyms;
+ for (; elsym < elsymend; elsym++)
+ {
+ struct internal_ldsym ldsym;
+ char nambuf[SYMNMLEN + 1];
+ const char *name;
+ struct bfd_link_hash_entry *h;
+
+ xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
+
+ /* We are only interested in exported symbols. */
+ if ((ldsym.l_smtype & L_EXPORT) == 0)
+ continue;
+
+ if (ldsym._l._l_l._l_zeroes == 0)
+ name = strings + ldsym._l._l_l._l_offset;
+ else
+ {
+ memcpy (nambuf, ldsym._l._l_name, SYMNMLEN);
+ nambuf[SYMNMLEN] = '\0';
+ name = nambuf;
+ }
+
+ h = bfd_link_hash_lookup (info->hash, name, false, false, true);
+
+ /* We are only interested in symbols that are currently
+ undefined. At this point we know that we are using an XCOFF
+ hash table. */
+ if (h != NULL
+ && h->type == bfd_link_hash_undefined
+ && (((struct xcoff_link_hash_entry *) h)->flags
+ & XCOFF_DEF_DYNAMIC) == 0)
+ {
+ if (! (*info->callbacks->add_archive_element) (info, abfd, name))
+ return false;
+ *pneeded = true;
+ return true;
+ }
+ }
+
+ /* We do not need this shared object. */
+
+ if (buf != NULL && ! coff_section_data (abfd, lsec)->keep_contents)
+ {
+ free (coff_section_data (abfd, lsec)->contents);
+ coff_section_data (abfd, lsec)->contents = NULL;
+ }
+
+ return true;
+}
+
+/* Returns the index of reloc in RELOCS with the least address greater
+ than or equal to ADDRESS. The relocs are sorted by address. */
+
+static bfd_size_type
+xcoff_find_reloc (relocs, count, address)
+ struct internal_reloc *relocs;
+ bfd_size_type count;
+ bfd_vma address;
+{
+ bfd_size_type min, max, this;
+
+ if (count < 2)
+ {
+ if (count == 1 && relocs[0].r_vaddr < address)
+ return 1;
+ else
+ return 0;
+ }
+
+ min = 0;
+ max = count;
+
+ /* Do a binary search over (min,max]. */
+ while (min + 1 < max)
+ {
+ bfd_vma raddr;
+
+ this = (max + min) / 2;
+ raddr = relocs[this].r_vaddr;
+ if (raddr > address)
+ max = this;
+ else if (raddr < address)
+ min = this;
+ else
+ {
+ min = this;
+ break;
+ }
+ }
+
+ if (relocs[min].r_vaddr < address)
+ return min + 1;
+
+ while (min > 0
+ && relocs[min - 1].r_vaddr == address)
+ --min;
+
+ return min;
+}
+
+/* Add all the symbols from an object file to the hash table.
+
+ XCOFF is a weird format. A normal XCOFF .o files will have three
+ COFF sections--.text, .data, and .bss--but each COFF section will
+ contain many csects. These csects are described in the symbol
+ table. From the linker's point of view, each csect must be
+ considered a section in its own right. For example, a TOC entry is
+ handled as a small XMC_TC csect. The linker must be able to merge
+ different TOC entries together, which means that it must be able to
+ extract the XMC_TC csects from the .data section of the input .o
+ file.
+
+ From the point of view of our linker, this is, of course, a hideous
+ nightmare. We cope by actually creating sections for each csect,
+ and discarding the original sections. We then have to handle the
+ relocation entries carefully, since the only way to tell which
+ csect they belong to is to examine the address. */
+
+static boolean
+xcoff_link_add_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ unsigned int n_tmask;
+ unsigned int n_btshft;
+ boolean default_copy;
+ bfd_size_type symcount;
+ struct xcoff_link_hash_entry **sym_hash;
+ asection **csect_cache;
+ bfd_size_type linesz;
+ asection *o;
+ asection *last_real;
+ boolean keep_syms;
+ asection *csect;
+ unsigned int csect_index;
+ asection *first_csect;
+ bfd_size_type symesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
+ struct reloc_info_struct
+ {
+ struct internal_reloc *relocs;
+ asection **csects;
+ bfd_byte *linenos;
+ } *reloc_info = NULL;
+
+ keep_syms = obj_coff_keep_syms (abfd);
+
+ if ((abfd->flags & DYNAMIC) != 0
+ && ! info->static_link)
+ {
+ if (! xcoff_link_add_dynamic_symbols (abfd, info))
+ return false;
+ }
+
+ if (info->hash->creator == abfd->xvec)
+ {
+ /* We need to build a .loader section, so we do it here. This
+ won't work if we're producing an XCOFF output file with no
+ XCOFF input files. FIXME. */
+ if (xcoff_hash_table (info)->loader_section == NULL)
+ {
+ asection *lsec;
+
+ lsec = bfd_make_section_anyway (abfd, ".loader");
+ if (lsec == NULL)
+ goto error_return;
+ xcoff_hash_table (info)->loader_section = lsec;
+ lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+ }
+ /* Likewise for the linkage section. */
+ if (xcoff_hash_table (info)->linkage_section == NULL)
+ {
+ asection *lsec;
+
+ lsec = bfd_make_section_anyway (abfd, ".gl");
+ if (lsec == NULL)
+ goto error_return;
+ xcoff_hash_table (info)->linkage_section = lsec;
+ lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+ lsec->alignment_power = 2;
+ }
+ /* Likewise for the TOC section. */
+ if (xcoff_hash_table (info)->toc_section == NULL)
+ {
+ asection *tsec;
+
+ tsec = bfd_make_section_anyway (abfd, ".tc");
+ if (tsec == NULL)
+ goto error_return;
+ xcoff_hash_table (info)->toc_section = tsec;
+ tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+ tsec->alignment_power = 2;
+ }
+ /* Likewise for the descriptor section. */
+ if (xcoff_hash_table (info)->descriptor_section == NULL)
+ {
+ asection *dsec;
+
+ dsec = bfd_make_section_anyway (abfd, ".ds");
+ if (dsec == NULL)
+ goto error_return;
+ xcoff_hash_table (info)->descriptor_section = dsec;
+ dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+ dsec->alignment_power = 2;
+ }
+ /* Likewise for the .debug section. */
+ if (xcoff_hash_table (info)->debug_section == NULL
+ && info->strip != strip_all)
+ {
+ asection *dsec;
+
+ dsec = bfd_make_section_anyway (abfd, ".debug");
+ if (dsec == NULL)
+ goto error_return;
+ xcoff_hash_table (info)->debug_section = dsec;
+ dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+ }
+ }
+
+ if ((abfd->flags & DYNAMIC) != 0
+ && ! info->static_link)
+ return true;
+
+ n_tmask = coff_data (abfd)->local_n_tmask;
+ n_btshft = coff_data (abfd)->local_n_btshft;
+
+ /* Define macros so that ISFCN, et. al., macros work correctly. */
+#define N_TMASK n_tmask
+#define N_BTSHFT n_btshft
+
+ if (info->keep_memory)
+ default_copy = false;
+ else
+ default_copy = true;
+
+ symcount = obj_raw_syment_count (abfd);
+
+ /* We keep a list of the linker hash table entries that correspond
+ to each external symbol. */
+ sym_hash = ((struct xcoff_link_hash_entry **)
+ bfd_alloc (abfd,
+ (symcount
+ * sizeof (struct xcoff_link_hash_entry *))));
+ if (sym_hash == NULL && symcount != 0)
+ goto error_return;
+ coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
+ memset (sym_hash, 0,
+ (size_t) symcount * sizeof (struct xcoff_link_hash_entry *));
+
+ /* Because of the weird stuff we are doing with XCOFF csects, we can
+ not easily determine which section a symbol is in, so we store
+ the information in the tdata for the input file. */
+ csect_cache = ((asection **)
+ bfd_alloc (abfd, symcount * sizeof (asection *)));
+ if (csect_cache == NULL && symcount != 0)
+ goto error_return;
+ xcoff_data (abfd)->csects = csect_cache;
+ memset (csect_cache, 0, (size_t) symcount * sizeof (asection *));
+
+ /* While splitting sections into csects, we need to assign the
+ relocs correctly. The relocs and the csects must both be in
+ order by VMA within a given section, so we handle this by
+ scanning along the relocs as we process the csects. We index
+ into reloc_info using the section target_index. */
+ reloc_info = ((struct reloc_info_struct *)
+ bfd_malloc ((abfd->section_count + 1)
+ * sizeof (struct reloc_info_struct)));
+ if (reloc_info == NULL)
+ goto error_return;
+ memset ((PTR) reloc_info, 0,
+ (abfd->section_count + 1) * sizeof (struct reloc_info_struct));
+
+ /* Read in the relocs and line numbers for each section. */
+ linesz = bfd_coff_linesz (abfd);
+ last_real = NULL;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ last_real = o;
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ reloc_info[o->target_index].relocs =
+ xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL,
+ false, (struct internal_reloc *) NULL);
+ reloc_info[o->target_index].csects =
+ (asection **) bfd_malloc (o->reloc_count * sizeof (asection *));
+ if (reloc_info[o->target_index].csects == NULL)
+ goto error_return;
+ memset (reloc_info[o->target_index].csects, 0,
+ o->reloc_count * sizeof (asection *));
+ }
+
+ if ((info->strip == strip_none || info->strip == strip_some)
+ && o->lineno_count > 0)
+ {
+ bfd_byte *linenos;
+
+ linenos = (bfd_byte *) bfd_malloc (o->lineno_count * linesz);
+ if (linenos == NULL)
+ goto error_return;
+ reloc_info[o->target_index].linenos = linenos;
+ if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
+ || (bfd_read (linenos, linesz, o->lineno_count, abfd)
+ != linesz * o->lineno_count))
+ goto error_return;
+ }
+ }
+
+ /* Don't let the linker relocation routines discard the symbols. */
+ obj_coff_keep_syms (abfd) = true;
+
+ csect = NULL;
+ csect_index = 0;
+ first_csect = NULL;
+
+ symesz = bfd_coff_symesz (abfd);
+ BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
+ esym = (bfd_byte *) obj_coff_external_syms (abfd);
+ esym_end = esym + symcount * symesz;
+ while (esym < esym_end)
+ {
+ struct internal_syment sym;
+ union internal_auxent aux;
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ int smtyp;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ struct xcoff_link_hash_entry *set_toc;
+
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
+
+ /* In this pass we are only interested in symbols with csect
+ information. */
+ if (sym.n_sclass != C_EXT && sym.n_sclass != C_HIDEXT)
+ {
+ if (sym.n_sclass == C_FILE && csect != NULL)
+ {
+ xcoff_section_data (abfd, csect)->last_symndx =
+ ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz);
+ csect = NULL;
+ }
+
+ if (csect != NULL)
+ *csect_cache = csect;
+ else if (first_csect == NULL || sym.n_sclass == C_FILE)
+ *csect_cache = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ else
+ *csect_cache = NULL;
+ esym += (sym.n_numaux + 1) * symesz;
+ sym_hash += sym.n_numaux + 1;
+ csect_cache += sym.n_numaux + 1;
+ continue;
+ }
+
+ name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
+ if (name == NULL)
+ goto error_return;
+
+ /* If this symbol has line number information attached to it,
+ and we're not stripping it, count the number of entries and
+ add them to the count for this csect. In the final link pass
+ we are going to attach line number information by symbol,
+ rather than by section, in order to more easily handle
+ garbage collection. */
+ if ((info->strip == strip_none || info->strip == strip_some)
+ && sym.n_numaux > 1
+ && csect != NULL
+ && ISFCN (sym.n_type))
+ {
+ union internal_auxent auxlin;
+
+ bfd_coff_swap_aux_in (abfd, (PTR) (esym + symesz),
+ sym.n_type, sym.n_sclass,
+ 0, sym.n_numaux, (PTR) &auxlin);
+ if (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
+ {
+ asection *enclosing;
+ bfd_size_type linoff;
+
+ enclosing = xcoff_section_data (abfd, csect)->enclosing;
+ if (enclosing == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: `%s' has line numbers but no enclosing section"),
+ bfd_get_filename (abfd), name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ linoff = (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr
+ - enclosing->line_filepos);
+ if (linoff < enclosing->lineno_count * linesz)
+ {
+ struct internal_lineno lin;
+ bfd_byte *linpstart;
+
+ linpstart = (reloc_info[enclosing->target_index].linenos
+ + linoff);
+ bfd_coff_swap_lineno_in (abfd, (PTR) linpstart, (PTR) &lin);
+ if (lin.l_lnno == 0
+ && ((bfd_size_type) lin.l_addr.l_symndx
+ == ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz)))
+ {
+ bfd_byte *linpend, *linp;
+
+ linpend = (reloc_info[enclosing->target_index].linenos
+ + enclosing->lineno_count * linesz);
+ for (linp = linpstart + linesz;
+ linp < linpend;
+ linp += linesz)
+ {
+ bfd_coff_swap_lineno_in (abfd, (PTR) linp,
+ (PTR) &lin);
+ if (lin.l_lnno == 0)
+ break;
+ }
+ csect->lineno_count += (linp - linpstart) / linesz;
+ /* The setting of line_filepos will only be
+ useful if all the line number entries for a
+ csect are contiguous; this only matters for
+ error reporting. */
+ if (csect->line_filepos == 0)
+ csect->line_filepos =
+ auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr;
+ }
+ }
+ }
+ }
+
+ /* Pick up the csect auxiliary information. */
+
+ if (sym.n_numaux == 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: class %d symbol `%s' has no aux entries"),
+ bfd_get_filename (abfd), sym.n_sclass, name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ bfd_coff_swap_aux_in (abfd,
+ (PTR) (esym + symesz * sym.n_numaux),
+ sym.n_type, sym.n_sclass,
+ sym.n_numaux - 1, sym.n_numaux,
+ (PTR) &aux);
+
+ smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp);
+
+ flags = BSF_GLOBAL;
+ section = NULL;
+ value = 0;
+ set_toc = NULL;
+
+ switch (smtyp)
+ {
+ default:
+ (*_bfd_error_handler)
+ (_("%s: symbol `%s' has unrecognized csect type %d"),
+ bfd_get_filename (abfd), name, smtyp);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+
+ case XTY_ER:
+ /* This is an external reference. */
+ if (sym.n_sclass == C_HIDEXT
+ || sym.n_scnum != N_UNDEF
+ || aux.x_csect.x_scnlen.l != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"),
+ bfd_get_filename (abfd), name, sym.n_sclass, sym.n_scnum,
+ aux.x_csect.x_scnlen.l);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ /* An XMC_XO external reference is actually a reference to
+ an absolute location. */
+ if (aux.x_csect.x_smclas != XMC_XO)
+ section = bfd_und_section_ptr;
+ else
+ {
+ section = bfd_abs_section_ptr;
+ value = sym.n_value;
+ }
+ break;
+
+ case XTY_SD:
+ /* This is a csect definition. */
+
+ if (csect != NULL)
+ {
+ xcoff_section_data (abfd, csect)->last_symndx =
+ ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz);
+ }
+
+ csect = NULL;
+ csect_index = -1;
+
+ /* When we see a TOC anchor, we record the TOC value. */
+ if (aux.x_csect.x_smclas == XMC_TC0)
+ {
+ if (sym.n_sclass != C_HIDEXT
+ || aux.x_csect.x_scnlen.l != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: XMC_TC0 symbol `%s' is class %d scnlen %d"),
+ bfd_get_filename (abfd), name, sym.n_sclass,
+ aux.x_csect.x_scnlen.l);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ xcoff_data (abfd)->toc = sym.n_value;
+ }
+
+ /* We must merge TOC entries for the same symbol. We can
+ merge two TOC entries if they are both C_HIDEXT, they
+ both have the same name, they are both 4 bytes long, and
+ they both have a relocation table entry for an external
+ symbol with the same name. Unfortunately, this means
+ that we must look through the relocations. Ick. */
+ if (aux.x_csect.x_smclas == XMC_TC
+ && sym.n_sclass == C_HIDEXT
+ && aux.x_csect.x_scnlen.l == 4
+ && info->hash->creator == abfd->xvec)
+ {
+ asection *enclosing;
+ struct internal_reloc *relocs;
+ bfd_size_type relindx;
+ struct internal_reloc *rel;
+
+ enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ if (enclosing == NULL)
+ goto error_return;
+
+ relocs = reloc_info[enclosing->target_index].relocs;
+ relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,
+ sym.n_value);
+ rel = relocs + relindx;
+ if (relindx < enclosing->reloc_count
+ && rel->r_vaddr == (bfd_vma) sym.n_value
+ && rel->r_size == 31
+ && rel->r_type == R_POS)
+ {
+ bfd_byte *erelsym;
+ struct internal_syment relsym;
+
+ erelsym = ((bfd_byte *) obj_coff_external_syms (abfd)
+ + rel->r_symndx * symesz);
+ bfd_coff_swap_sym_in (abfd, (PTR) erelsym, (PTR) &relsym);
+ if (relsym.n_sclass == C_EXT)
+ {
+ const char *relname;
+ char relbuf[SYMNMLEN + 1];
+ boolean copy;
+ struct xcoff_link_hash_entry *h;
+
+ /* At this point we know that the TOC entry is
+ for an externally visible symbol. */
+ relname = _bfd_coff_internal_syment_name (abfd, &relsym,
+ relbuf);
+ if (relname == NULL)
+ goto error_return;
+
+ /* We only merge TOC entries if the TC name is
+ the same as the symbol name. This handles
+ the normal case, but not common cases like
+ SYM.P4 which gcc generates to store SYM + 4
+ in the TOC. FIXME. */
+ if (strcmp (name, relname) == 0)
+ {
+ copy = (! info->keep_memory
+ || relsym._n._n_n._n_zeroes != 0
+ || relsym._n._n_n._n_offset == 0);
+ h = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ relname, true, copy,
+ false);
+ if (h == NULL)
+ goto error_return;
+
+ /* At this point h->root.type could be
+ bfd_link_hash_new. That should be OK,
+ since we know for sure that we will come
+ across this symbol as we step through the
+ file. */
+
+ /* We store h in *sym_hash for the
+ convenience of the relocate_section
+ function. */
+ *sym_hash = h;
+
+ if (h->toc_section != NULL)
+ {
+ asection **rel_csects;
+
+ /* We already have a TOC entry for this
+ symbol, so we can just ignore this
+ one. */
+ rel_csects =
+ reloc_info[enclosing->target_index].csects;
+ rel_csects[relindx] = bfd_und_section_ptr;
+ break;
+ }
+
+ /* We are about to create a TOC entry for
+ this symbol. */
+ set_toc = h;
+ }
+ }
+ }
+ }
+
+ /* We need to create a new section. We get the name from
+ the csect storage mapping class, so that the linker can
+ accumulate similar csects together. */
+ {
+ static const char *csect_name_by_class[] =
+ {
+ ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
+ ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0",
+ ".td"
+ };
+ const char *csect_name;
+ asection *enclosing;
+
+ if ((aux.x_csect.x_smclas >=
+ sizeof csect_name_by_class / sizeof csect_name_by_class[0])
+ || csect_name_by_class[aux.x_csect.x_smclas] == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: symbol `%s' has unrecognized smclas %d"),
+ bfd_get_filename (abfd), name, aux.x_csect.x_smclas);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ csect_name = csect_name_by_class[aux.x_csect.x_smclas];
+ csect = bfd_make_section_anyway (abfd, csect_name);
+ if (csect == NULL)
+ goto error_return;
+ enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ if (enclosing == NULL)
+ goto error_return;
+ if (! bfd_is_abs_section (enclosing)
+ && ((bfd_vma) sym.n_value < enclosing->vma
+ || ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l
+ > enclosing->vma + enclosing->_raw_size)))
+ {
+ (*_bfd_error_handler)
+ (_("%s: csect `%s' not in enclosing section"),
+ bfd_get_filename (abfd), name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ csect->vma = sym.n_value;
+ csect->filepos = (enclosing->filepos
+ + sym.n_value
+ - enclosing->vma);
+ csect->_raw_size = aux.x_csect.x_scnlen.l;
+ csect->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+ csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
+
+ /* Record the enclosing section in the tdata for this new
+ section. */
+ csect->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (csect->used_by_bfd == NULL)
+ goto error_return;
+ coff_section_data (abfd, csect)->tdata =
+ bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
+ if (coff_section_data (abfd, csect)->tdata == NULL)
+ goto error_return;
+ xcoff_section_data (abfd, csect)->enclosing = enclosing;
+ xcoff_section_data (abfd, csect)->lineno_count =
+ enclosing->lineno_count;
+
+ if (enclosing->owner == abfd)
+ {
+ struct internal_reloc *relocs;
+ bfd_size_type relindx;
+ struct internal_reloc *rel;
+ asection **rel_csect;
+
+ relocs = reloc_info[enclosing->target_index].relocs;
+ relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,
+ csect->vma);
+ rel = relocs + relindx;
+ rel_csect = (reloc_info[enclosing->target_index].csects
+ + relindx);
+ csect->rel_filepos = (enclosing->rel_filepos
+ + relindx * bfd_coff_relsz (abfd));
+ while (relindx < enclosing->reloc_count
+ && *rel_csect == NULL
+ && rel->r_vaddr < csect->vma + csect->_raw_size)
+ {
+ *rel_csect = csect;
+ csect->flags |= SEC_RELOC;
+ ++csect->reloc_count;
+ ++relindx;
+ ++rel;
+ ++rel_csect;
+ }
+ }
+
+ /* There are a number of other fields and section flags
+ which we do not bother to set. */
+
+ csect_index = ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz);
+
+ xcoff_section_data (abfd, csect)->first_symndx = csect_index;
+
+ if (first_csect == NULL)
+ first_csect = csect;
+
+ /* If this symbol is C_EXT, we treat it as starting at the
+ beginning of the newly created section. */
+ if (sym.n_sclass == C_EXT)
+ {
+ section = csect;
+ value = 0;
+ }
+
+ /* If this is a TOC section for a symbol, record it. */
+ if (set_toc != NULL)
+ set_toc->toc_section = csect;
+ }
+ break;
+
+ case XTY_LD:
+ /* This is a label definition. The x_scnlen field is the
+ symbol index of the csect. I believe that this must
+ always follow the appropriate XTY_SD symbol, so I will
+ insist on it. */
+ {
+ boolean bad;
+
+ bad = false;
+ if (aux.x_csect.x_scnlen.l < 0
+ || (aux.x_csect.x_scnlen.l
+ >= esym - (bfd_byte *) obj_coff_external_syms (abfd)))
+ bad = true;
+ if (! bad)
+ {
+ section = xcoff_data (abfd)->csects[aux.x_csect.x_scnlen.l];
+ if (section == NULL
+ || (section->flags & SEC_HAS_CONTENTS) == 0)
+ bad = true;
+ }
+ if (bad)
+ {
+ (*_bfd_error_handler)
+ (_("%s: misplaced XTY_LD `%s'"),
+ bfd_get_filename (abfd), name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ value = sym.n_value - csect->vma;
+ }
+ break;
+
+ case XTY_CM:
+ /* This is an unitialized csect. We could base the name on
+ the storage mapping class, but we don't bother except for
+ an XMC_TD symbol. If this csect is externally visible,
+ it is a common symbol. We put XMC_TD symbols in sections
+ named .tocbss, and rely on the linker script to put that
+ in the TOC area. */
+
+ if (csect != NULL)
+ {
+ xcoff_section_data (abfd, csect)->last_symndx =
+ ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz);
+ }
+
+ if (aux.x_csect.x_smclas == XMC_TD)
+ csect = bfd_make_section_anyway (abfd, ".tocbss");
+ else
+ csect = bfd_make_section_anyway (abfd, ".bss");
+ if (csect == NULL)
+ goto error_return;
+ csect->vma = sym.n_value;
+ csect->_raw_size = aux.x_csect.x_scnlen.l;
+ csect->flags |= SEC_ALLOC;
+ csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
+ /* There are a number of other fields and section flags
+ which we do not bother to set. */
+
+ csect_index = ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz);
+
+ csect->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (csect->used_by_bfd == NULL)
+ goto error_return;
+ coff_section_data (abfd, csect)->tdata =
+ bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
+ if (coff_section_data (abfd, csect)->tdata == NULL)
+ goto error_return;
+ xcoff_section_data (abfd, csect)->first_symndx = csect_index;
+
+ if (first_csect == NULL)
+ first_csect = csect;
+
+ if (sym.n_sclass == C_EXT)
+ {
+ csect->flags |= SEC_IS_COMMON;
+ csect->_raw_size = 0;
+ section = csect;
+ value = aux.x_csect.x_scnlen.l;
+ }
+
+ break;
+ }
+
+ /* Check for magic symbol names. */
+ if ((smtyp == XTY_SD || smtyp == XTY_CM)
+ && aux.x_csect.x_smclas != XMC_TC
+ && aux.x_csect.x_smclas != XMC_TD)
+ {
+ int i;
+
+ i = -1;
+ if (name[0] == '_')
+ {
+ if (strcmp (name, "_text") == 0)
+ i = 0;
+ else if (strcmp (name, "_etext") == 0)
+ i = 1;
+ else if (strcmp (name, "_data") == 0)
+ i = 2;
+ else if (strcmp (name, "_edata") == 0)
+ i = 3;
+ else if (strcmp (name, "_end") == 0)
+ i = 4;
+ }
+ else if (name[0] == 'e' && strcmp (name, "end") == 0)
+ i = 5;
+
+ if (i != -1)
+ xcoff_hash_table (info)->special_sections[i] = csect;
+ }
+
+ /* Now we have enough information to add the symbol to the
+ linker hash table. */
+
+ if (sym.n_sclass == C_EXT)
+ {
+ boolean copy;
+
+ BFD_ASSERT (section != NULL);
+
+ /* We must copy the name into memory if we got it from the
+ syment itself, rather than the string table. */
+ copy = default_copy;
+ if (sym._n._n_n._n_zeroes != 0
+ || sym._n._n_n._n_offset == 0)
+ copy = true;
+
+ /* The AIX linker appears to only detect multiple symbol
+ definitions when there is a reference to the symbol. If
+ a symbol is defined multiple times, and the only
+ references are from the same object file, the AIX linker
+ appears to permit it. It does not merge the different
+ definitions, but handles them independently. On the
+ other hand, if there is a reference, the linker reports
+ an error.
+
+ This matters because the AIX <net/net_globals.h> header
+ file actually defines an initialized array, so we have to
+ actually permit that to work.
+
+ Just to make matters even more confusing, the AIX linker
+ appears to permit multiple symbol definitions whenever
+ the second definition is in an archive rather than an
+ object file. This may be a consequence of the manner in
+ which it handles archives: I think it may load the entire
+ archive in as separate csects, and then let garbage
+ collection discard symbols.
+
+ We also have to handle the case of statically linking a
+ shared object, which will cause symbol redefinitions,
+ although this is an easier case to detect. */
+
+ if (info->hash->creator == abfd->xvec)
+ {
+ if (! bfd_is_und_section (section))
+ *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ name, true, copy, false);
+ else
+ *sym_hash = ((struct xcoff_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (abfd, info, name,
+ true, copy, false));
+ if (*sym_hash == NULL)
+ goto error_return;
+ if (((*sym_hash)->root.type == bfd_link_hash_defined
+ || (*sym_hash)->root.type == bfd_link_hash_defweak)
+ && ! bfd_is_und_section (section)
+ && ! bfd_is_com_section (section))
+ {
+ /* This is a second definition of a defined symbol. */
+ if ((abfd->flags & DYNAMIC) != 0
+ && ((*sym_hash)->smclas != XMC_GL
+ || aux.x_csect.x_smclas == XMC_GL
+ || ((*sym_hash)->root.u.def.section->owner->flags
+ & DYNAMIC) == 0))
+ {
+ /* The new symbol is from a shared library, and
+ either the existing symbol is not global
+ linkage code or this symbol is global linkage
+ code. If the existing symbol is global
+ linkage code and the new symbol is not, then
+ we want to use the new symbol. */
+ section = bfd_und_section_ptr;
+ value = 0;
+ }
+ else if (((*sym_hash)->root.u.def.section->owner->flags
+ & DYNAMIC) != 0)
+ {
+ /* The existing symbol is from a shared library.
+ Replace it. */
+ (*sym_hash)->root.type = bfd_link_hash_undefined;
+ (*sym_hash)->root.u.undef.abfd =
+ (*sym_hash)->root.u.def.section->owner;
+ }
+ else if (abfd->my_archive != NULL)
+ {
+ /* This is a redefinition in an object contained
+ in an archive. Just ignore it. See the
+ comment above. */
+ section = bfd_und_section_ptr;
+ value = 0;
+ }
+ else if ((*sym_hash)->root.next != NULL
+ || info->hash->undefs_tail == &(*sym_hash)->root)
+ {
+ /* This symbol has been referenced. In this
+ case, we just continue and permit the
+ multiple definition error. See the comment
+ above about the behaviour of the AIX linker. */
+ }
+ else if ((*sym_hash)->smclas == aux.x_csect.x_smclas)
+ {
+ /* The symbols are both csects of the same
+ class. There is at least a chance that this
+ is a semi-legitimate redefinition. */
+ section = bfd_und_section_ptr;
+ value = 0;
+ (*sym_hash)->flags |= XCOFF_MULTIPLY_DEFINED;
+ }
+ }
+ else if (((*sym_hash)->flags & XCOFF_MULTIPLY_DEFINED) != 0
+ && ((*sym_hash)->root.type == bfd_link_hash_defined
+ || (*sym_hash)->root.type == bfd_link_hash_defweak)
+ && (bfd_is_und_section (section)
+ || bfd_is_com_section (section)))
+ {
+ /* This is a reference to a multiply defined symbol.
+ Report the error now. See the comment above
+ about the behaviour of the AIX linker. We could
+ also do this with warning symbols, but I'm not
+ sure the XCOFF linker is wholly prepared to
+ handle them, and that would only be a warning,
+ not an error. */
+ if (! ((*info->callbacks->multiple_definition)
+ (info, (*sym_hash)->root.root.string,
+ (bfd *) NULL, (asection *) NULL, 0,
+ (*sym_hash)->root.u.def.section->owner,
+ (*sym_hash)->root.u.def.section,
+ (*sym_hash)->root.u.def.value)))
+ goto error_return;
+ /* Try not to give this error too many times. */
+ (*sym_hash)->flags &= ~XCOFF_MULTIPLY_DEFINED;
+ }
+ }
+
+ /* _bfd_generic_link_add_one_symbol may call the linker to
+ generate an error message, and the linker may try to read
+ the symbol table to give a good error. Right now, the
+ line numbers are in an inconsistent state, since they are
+ counted both in the real sections and in the new csects.
+ We need to leave the count in the real sections so that
+ the linker can report the line number of the error
+ correctly, so temporarily clobber the link to the csects
+ so that the linker will not try to read the line numbers
+ a second time from the csects. */
+ BFD_ASSERT (last_real->next == first_csect);
+ last_real->next = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, name, flags, section, value,
+ (const char *) NULL, copy, true,
+ (struct bfd_link_hash_entry **) sym_hash)))
+ goto error_return;
+ last_real->next = first_csect;
+
+ if (smtyp == XTY_CM)
+ {
+ if ((*sym_hash)->root.type != bfd_link_hash_common
+ || (*sym_hash)->root.u.c.p->section != csect)
+ {
+ /* We don't need the common csect we just created. */
+ csect->_raw_size = 0;
+ }
+ else
+ {
+ (*sym_hash)->root.u.c.p->alignment_power
+ = csect->alignment_power;
+ }
+ }
+
+ if (info->hash->creator == abfd->xvec)
+ {
+ int flag;
+
+ if (smtyp == XTY_ER || smtyp == XTY_CM)
+ flag = XCOFF_REF_REGULAR;
+ else
+ flag = XCOFF_DEF_REGULAR;
+ (*sym_hash)->flags |= flag;
+
+ if ((*sym_hash)->smclas == XMC_UA
+ || flag == XCOFF_DEF_REGULAR)
+ (*sym_hash)->smclas = aux.x_csect.x_smclas;
+ }
+ }
+
+ *csect_cache = csect;
+
+ esym += (sym.n_numaux + 1) * symesz;
+ sym_hash += sym.n_numaux + 1;
+ csect_cache += sym.n_numaux + 1;
+ }
+
+ BFD_ASSERT (last_real == NULL || last_real->next == first_csect);
+
+ /* Make sure that we have seen all the relocs. */
+ for (o = abfd->sections; o != first_csect; o = o->next)
+ {
+ /* Reset the section size and the line number count, since the
+ data is now attached to the csects. Don't reset the size of
+ the .debug section, since we need to read it below in
+ bfd_xcoff_size_dynamic_sections. */
+ if (strcmp (bfd_get_section_name (abfd, o), ".debug") != 0)
+ o->_raw_size = 0;
+ o->lineno_count = 0;
+
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ bfd_size_type i;
+ struct internal_reloc *rel;
+ asection **rel_csect;
+
+ rel = reloc_info[o->target_index].relocs;
+ rel_csect = reloc_info[o->target_index].csects;
+ for (i = 0; i < o->reloc_count; i++, rel++, rel_csect++)
+ {
+ if (*rel_csect == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: reloc %s:%d not in csect"),
+ bfd_get_filename (abfd), o->name, i);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+
+ /* We identify all symbols which are called, so that we
+ can create glue code for calls to functions imported
+ from dynamic objects. */
+ if (info->hash->creator == abfd->xvec
+ && *rel_csect != bfd_und_section_ptr
+ && (rel->r_type == R_BR
+ || rel->r_type == R_RBR)
+ && obj_xcoff_sym_hashes (abfd)[rel->r_symndx] != NULL)
+ {
+ struct xcoff_link_hash_entry *h;
+
+ h = obj_xcoff_sym_hashes (abfd)[rel->r_symndx];
+ h->flags |= XCOFF_CALLED;
+ /* If the symbol name starts with a period, it is
+ the code of a function. If the symbol is
+ currently undefined, then add an undefined symbol
+ for the function descriptor. This should do no
+ harm, because any regular object that defines the
+ function should also define the function
+ descriptor. It helps, because it means that we
+ will identify the function descriptor with a
+ dynamic object if a dynamic object defines it. */
+ if (h->root.root.string[0] == '.'
+ && h->descriptor == NULL)
+ {
+ struct xcoff_link_hash_entry *hds;
+
+ hds = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ h->root.root.string + 1,
+ true, false, true);
+ if (hds == NULL)
+ goto error_return;
+ if (hds->root.type == bfd_link_hash_new)
+ {
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, hds->root.root.string,
+ (flagword) 0, bfd_und_section_ptr,
+ (bfd_vma) 0, (const char *) NULL, false,
+ true,
+ (struct bfd_link_hash_entry **) &hds)))
+ goto error_return;
+ }
+ hds->flags |= XCOFF_DESCRIPTOR;
+ BFD_ASSERT ((hds->flags & XCOFF_CALLED) == 0
+ && (h->flags & XCOFF_DESCRIPTOR) == 0);
+ hds->descriptor = h;
+ h->descriptor = hds;
+ }
+ }
+ }
+
+ free (reloc_info[o->target_index].csects);
+ reloc_info[o->target_index].csects = NULL;
+
+ /* Reset SEC_RELOC and the reloc_count, since the reloc
+ information is now attached to the csects. */
+ o->flags &=~ SEC_RELOC;
+ o->reloc_count = 0;
+
+ /* If we are not keeping memory, free the reloc information. */
+ if (! info->keep_memory
+ && coff_section_data (abfd, o) != NULL
+ && coff_section_data (abfd, o)->relocs != NULL
+ && ! coff_section_data (abfd, o)->keep_relocs)
+ {
+ free (coff_section_data (abfd, o)->relocs);
+ coff_section_data (abfd, o)->relocs = NULL;
+ }
+ }
+
+ /* Free up the line numbers. FIXME: We could cache these
+ somewhere for the final link, to avoid reading them again. */
+ if (reloc_info[o->target_index].linenos != NULL)
+ {
+ free (reloc_info[o->target_index].linenos);
+ reloc_info[o->target_index].linenos = NULL;
+ }
+ }
+
+ free (reloc_info);
+
+ obj_coff_keep_syms (abfd) = keep_syms;
+
+ return true;
+
+ error_return:
+ if (reloc_info != NULL)
+ {
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if (reloc_info[o->target_index].csects != NULL)
+ free (reloc_info[o->target_index].csects);
+ if (reloc_info[o->target_index].linenos != NULL)
+ free (reloc_info[o->target_index].linenos);
+ }
+ free (reloc_info);
+ }
+ obj_coff_keep_syms (abfd) = keep_syms;
+ return false;
+}
+
+#undef N_TMASK
+#undef N_BTSHFT
+
+/* This function is used to add symbols from a dynamic object to the
+ global symbol table. */
+
+static boolean
+xcoff_link_add_dynamic_symbols (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ asection *lsec;
+ bfd_byte *buf;
+ struct internal_ldhdr ldhdr;
+ const char *strings;
+ struct external_ldsym *elsym, *elsymend;
+ struct xcoff_import_file *n;
+ const char *bname;
+ const char *mname;
+ const char *s;
+ unsigned int c;
+ struct xcoff_import_file **pp;
+
+ /* We can only handle a dynamic object if we are generating an XCOFF
+ output file. */
+ if (info->hash->creator != abfd->xvec)
+ {
+ (*_bfd_error_handler)
+ (_("%s: XCOFF shared object when not producing XCOFF output"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+
+ /* The symbols we use from a dynamic object are not the symbols in
+ the normal symbol table, but, rather, the symbols in the export
+ table. If there is a global symbol in a dynamic object which is
+ not in the export table, the loader will not be able to find it,
+ so we don't want to find it either. Also, on AIX 4.1.3, shr.o in
+ libc.a has symbols in the export table which are not in the
+ symbol table. */
+
+ /* Read in the .loader section. FIXME: We should really use the
+ o_snloader field in the a.out header, rather than grabbing the
+ section by name. */
+ lsec = bfd_get_section_by_name (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: dynamic object with no .loader section"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_no_symbols);
+ return false;
+ }
+
+ if (! xcoff_get_section_contents (abfd, lsec))
+ return false;
+ buf = coff_section_data (abfd, lsec)->contents;
+
+ /* Remove the sections from this object, so that they do not get
+ included in the link. */
+ abfd->sections = NULL;
+
+ xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) buf, &ldhdr);
+
+ strings = (char *) buf + ldhdr.l_stoff;
+
+ elsym = (struct external_ldsym *) (buf + LDHDRSZ);
+ elsymend = elsym + ldhdr.l_nsyms;
+ BFD_ASSERT (sizeof (struct external_ldsym) == LDSYMSZ);
+ for (; elsym < elsymend; elsym++)
+ {
+ struct internal_ldsym ldsym;
+ char nambuf[SYMNMLEN + 1];
+ const char *name;
+ struct xcoff_link_hash_entry *h;
+
+ xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
+
+ /* We are only interested in exported symbols. */
+ if ((ldsym.l_smtype & L_EXPORT) == 0)
+ continue;
+
+ if (ldsym._l._l_l._l_zeroes == 0)
+ name = strings + ldsym._l._l_l._l_offset;
+ else
+ {
+ memcpy (nambuf, ldsym._l._l_name, SYMNMLEN);
+ nambuf[SYMNMLEN] = '\0';
+ name = nambuf;
+ }
+
+ /* Normally we could not call xcoff_link_hash_lookup in an add
+ symbols routine, since we might not be using an XCOFF hash
+ table. However, we verified above that we are using an XCOFF
+ hash table. */
+
+ h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true,
+ true, true);
+ if (h == NULL)
+ return false;
+
+ h->flags |= XCOFF_DEF_DYNAMIC;
+
+ /* If the symbol is undefined, and the BFD it was found in is
+ not a dynamic object, change the BFD to this dynamic object,
+ so that we can get the correct import file ID. */
+ if ((h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ && (h->root.u.undef.abfd == NULL
+ || (h->root.u.undef.abfd->flags & DYNAMIC) == 0))
+ h->root.u.undef.abfd = abfd;
+
+ if (h->root.type == bfd_link_hash_new)
+ {
+ h->root.type = bfd_link_hash_undefined;
+ h->root.u.undef.abfd = abfd;
+ /* We do not want to add this to the undefined symbol list. */
+ }
+
+ if (h->smclas == XMC_UA
+ || h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ h->smclas = ldsym.l_smclas;
+
+ /* Unless this is an XMC_XO symbol, we don't bother to actually
+ define it, since we don't have a section to put it in anyhow.
+ Instead, the relocation routines handle the DEF_DYNAMIC flag
+ correctly. */
+
+ if (h->smclas == XMC_XO
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak))
+ {
+ /* This symbol has an absolute value. */
+ h->root.type = bfd_link_hash_defined;
+ h->root.u.def.section = bfd_abs_section_ptr;
+ h->root.u.def.value = ldsym.l_value;
+ }
+
+ /* If this symbol defines a function descriptor, then it
+ implicitly defines the function code as well. */
+ if (h->smclas == XMC_DS
+ || (h->smclas == XMC_XO && name[0] != '.'))
+ h->flags |= XCOFF_DESCRIPTOR;
+ if ((h->flags & XCOFF_DESCRIPTOR) != 0)
+ {
+ struct xcoff_link_hash_entry *hds;
+
+ hds = h->descriptor;
+ if (hds == NULL)
+ {
+ char *dsnm;
+
+ dsnm = bfd_malloc (strlen (name) + 2);
+ if (dsnm == NULL)
+ return false;
+ dsnm[0] = '.';
+ strcpy (dsnm + 1, name);
+ hds = xcoff_link_hash_lookup (xcoff_hash_table (info), dsnm,
+ true, true, true);
+ free (dsnm);
+ if (hds == NULL)
+ return false;
+
+ if (hds->root.type == bfd_link_hash_new)
+ {
+ hds->root.type = bfd_link_hash_undefined;
+ hds->root.u.undef.abfd = abfd;
+ /* We do not want to add this to the undefined
+ symbol list. */
+ }
+
+ hds->descriptor = h;
+ h->descriptor = hds;
+ }
+
+ hds->flags |= XCOFF_DEF_DYNAMIC;
+ if (hds->smclas == XMC_UA)
+ hds->smclas = XMC_PR;
+
+ /* An absolute symbol appears to actually define code, not a
+ function descriptor. This is how some math functions are
+ implemented on AIX 4.1. */
+ if (h->smclas == XMC_XO
+ && (hds->root.type == bfd_link_hash_undefined
+ || hds->root.type == bfd_link_hash_undefweak))
+ {
+ hds->smclas = XMC_XO;
+ hds->root.type = bfd_link_hash_defined;
+ hds->root.u.def.section = bfd_abs_section_ptr;
+ hds->root.u.def.value = ldsym.l_value;
+ }
+ }
+ }
+
+ if (buf != NULL && ! coff_section_data (abfd, lsec)->keep_contents)
+ {
+ free (coff_section_data (abfd, lsec)->contents);
+ coff_section_data (abfd, lsec)->contents = NULL;
+ }
+
+ /* Record this file in the import files. */
+
+ n = ((struct xcoff_import_file *)
+ bfd_alloc (abfd, sizeof (struct xcoff_import_file)));
+ if (n == NULL)
+ return false;
+ n->next = NULL;
+
+ /* For some reason, the path entry in the import file list for a
+ shared object appears to always be empty. The file name is the
+ base name. */
+ n->path = "";
+ if (abfd->my_archive == NULL)
+ {
+ bname = bfd_get_filename (abfd);
+ mname = "";
+ }
+ else
+ {
+ bname = bfd_get_filename (abfd->my_archive);
+ mname = bfd_get_filename (abfd);
+ }
+ s = strrchr (bname, '/');
+ if (s != NULL)
+ bname = s + 1;
+ n->file = bname;
+ n->member = mname;
+
+ /* We start c at 1 because the first import file number is reserved
+ for LIBPATH. */
+ for (pp = &xcoff_hash_table (info)->imports, c = 1;
+ *pp != NULL;
+ pp = &(*pp)->next, ++c)
+ ;
+ *pp = n;
+
+ xcoff_data (abfd)->import_file_id = c;
+
+ return true;
+}
+
+/* Routines that are called after all the input files have been
+ handled, but before the sections are laid out in memory. */
+
+/* Mark a symbol as not being garbage, including the section in which
+ it is defined. */
+
+static INLINE boolean
+xcoff_mark_symbol (info, h)
+ struct bfd_link_info *info;
+ struct xcoff_link_hash_entry *h;
+{
+ if ((h->flags & XCOFF_MARK) != 0)
+ return true;
+
+ h->flags |= XCOFF_MARK;
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *hsec;
+
+ hsec = h->root.u.def.section;
+ if (! bfd_is_abs_section (hsec)
+ && (hsec->flags & SEC_MARK) == 0)
+ {
+ if (! xcoff_mark (info, hsec))
+ return false;
+ }
+ }
+
+ if (h->toc_section != NULL
+ && (h->toc_section->flags & SEC_MARK) == 0)
+ {
+ if (! xcoff_mark (info, h->toc_section))
+ return false;
+ }
+
+ return true;
+}
+
+/* The mark phase of garbage collection. For a given section, mark
+ it, and all the sections which define symbols to which it refers.
+ Because this function needs to look at the relocs, we also count
+ the number of relocs which need to be copied into the .loader
+ section. */
+
+static boolean
+xcoff_mark (info, sec)
+ struct bfd_link_info *info;
+ asection *sec;
+{
+ if (bfd_is_abs_section (sec)
+ || (sec->flags & SEC_MARK) != 0)
+ return true;
+
+ sec->flags |= SEC_MARK;
+
+ if (sec->owner->xvec == info->hash->creator
+ && coff_section_data (sec->owner, sec) != NULL
+ && xcoff_section_data (sec->owner, sec) != NULL)
+ {
+ register struct xcoff_link_hash_entry **hp, **hpend;
+ struct internal_reloc *rel, *relend;
+
+ /* Mark all the symbols in this section. */
+
+ hp = (obj_xcoff_sym_hashes (sec->owner)
+ + xcoff_section_data (sec->owner, sec)->first_symndx);
+ hpend = (obj_xcoff_sym_hashes (sec->owner)
+ + xcoff_section_data (sec->owner, sec)->last_symndx);
+ for (; hp < hpend; hp++)
+ {
+ register struct xcoff_link_hash_entry *h;
+
+ h = *hp;
+ if (h != NULL
+ && (h->flags & XCOFF_MARK) == 0)
+ {
+ if (! xcoff_mark_symbol (info, h))
+ return false;
+ }
+ }
+
+ /* Look through the section relocs. */
+
+ if ((sec->flags & SEC_RELOC) != 0
+ && sec->reloc_count > 0)
+ {
+ rel = xcoff_read_internal_relocs (sec->owner, sec, true,
+ (bfd_byte *) NULL, false,
+ (struct internal_reloc *) NULL);
+ if (rel == NULL)
+ return false;
+ relend = rel + sec->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ asection *rsec;
+ struct xcoff_link_hash_entry *h;
+
+ if ((unsigned int) rel->r_symndx
+ > obj_raw_syment_count (sec->owner))
+ continue;
+
+ h = obj_xcoff_sym_hashes (sec->owner)[rel->r_symndx];
+ if (h != NULL
+ && (h->flags & XCOFF_MARK) == 0)
+ {
+ if (! xcoff_mark_symbol (info, h))
+ return false;
+ }
+
+ rsec = xcoff_data (sec->owner)->csects[rel->r_symndx];
+ if (rsec != NULL
+ && (rsec->flags & SEC_MARK) == 0)
+ {
+ if (! xcoff_mark (info, rsec))
+ return false;
+ }
+
+ /* See if this reloc needs to be copied into the .loader
+ section. */
+ switch (rel->r_type)
+ {
+ default:
+ if (h == NULL
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_common
+ || ((h->flags & XCOFF_CALLED) != 0
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ && h->root.root.string[0] == '.'
+ && h->descriptor != NULL
+ && ((h->descriptor->flags & XCOFF_DEF_DYNAMIC) != 0
+ || ((h->descriptor->flags & XCOFF_IMPORT) != 0
+ && (h->descriptor->flags
+ & XCOFF_DEF_REGULAR) == 0))))
+ break;
+ /* Fall through. */
+ case R_POS:
+ case R_NEG:
+ case R_RL:
+ case R_RLA:
+ ++xcoff_hash_table (info)->ldrel_count;
+ if (h != NULL)
+ h->flags |= XCOFF_LDREL;
+ break;
+ case R_TOC:
+ case R_GL:
+ case R_TCL:
+ case R_TRL:
+ case R_TRLA:
+ /* We should never need a .loader reloc for a TOC
+ relative reloc. */
+ break;
+ }
+ }
+
+ if (! info->keep_memory
+ && coff_section_data (sec->owner, sec) != NULL
+ && coff_section_data (sec->owner, sec)->relocs != NULL
+ && ! coff_section_data (sec->owner, sec)->keep_relocs)
+ {
+ free (coff_section_data (sec->owner, sec)->relocs);
+ coff_section_data (sec->owner, sec)->relocs = NULL;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* The sweep phase of garbage collection. Remove all garbage
+ sections. */
+
+static void
+xcoff_sweep (info)
+ struct bfd_link_info *info;
+{
+ bfd *sub;
+
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *o;
+
+ for (o = sub->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_MARK) == 0)
+ {
+ /* Keep all sections from non-XCOFF input files. Keep
+ special sections. Keep .debug sections for the
+ moment. */
+ if (sub->xvec != info->hash->creator
+ || o == xcoff_hash_table (info)->debug_section
+ || o == xcoff_hash_table (info)->loader_section
+ || o == xcoff_hash_table (info)->linkage_section
+ || o == xcoff_hash_table (info)->toc_section
+ || o == xcoff_hash_table (info)->descriptor_section
+ || strcmp (o->name, ".debug") == 0)
+ o->flags |= SEC_MARK;
+ else
+ {
+ o->_raw_size = 0;
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ }
+ }
+ }
+ }
+}
+
+/* Record the number of elements in a set. This is used to output the
+ correct csect length. */
+
+boolean
+bfd_xcoff_link_record_set (output_bfd, info, harg, size)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct bfd_link_hash_entry *harg;
+ bfd_size_type size;
+{
+ struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
+ struct xcoff_link_size_list *n;
+
+ if (! XCOFF_XVECP (output_bfd->xvec))
+ return true;
+
+ /* This will hardly ever be called. I don't want to burn four bytes
+ per global symbol, so instead the size is kept on a linked list
+ attached to the hash table. */
+
+ n = ((struct xcoff_link_size_list *)
+ bfd_alloc (output_bfd, sizeof (struct xcoff_link_size_list)));
+ if (n == NULL)
+ return false;
+ n->next = xcoff_hash_table (info)->size_list;
+ n->h = h;
+ n->size = size;
+ xcoff_hash_table (info)->size_list = n;
+
+ h->flags |= XCOFF_HAS_SIZE;
+
+ return true;
+}
+
+/* Import a symbol. */
+
+boolean
+bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
+ impmember)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct bfd_link_hash_entry *harg;
+ bfd_vma val;
+ const char *imppath;
+ const char *impfile;
+ const char *impmember;
+{
+ struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
+
+ if (! XCOFF_XVECP (output_bfd->xvec))
+ return true;
+
+ /* A symbol name which starts with a period is the code for a
+ function. If the symbol is undefined, then add an undefined
+ symbol for the function descriptor, and import that instead. */
+ if (h->root.root.string[0] == '.'
+ && h->root.type == bfd_link_hash_undefined
+ && val == (bfd_vma) -1)
+ {
+ struct xcoff_link_hash_entry *hds;
+
+ hds = h->descriptor;
+ if (hds == NULL)
+ {
+ hds = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ h->root.root.string + 1,
+ true, false, true);
+ if (hds == NULL)
+ return false;
+ if (hds->root.type == bfd_link_hash_new)
+ {
+ hds->root.type = bfd_link_hash_undefined;
+ hds->root.u.undef.abfd = h->root.u.undef.abfd;
+ }
+ hds->flags |= XCOFF_DESCRIPTOR;
+ BFD_ASSERT ((hds->flags & XCOFF_CALLED) == 0
+ && (h->flags & XCOFF_DESCRIPTOR) == 0);
+ hds->descriptor = h;
+ h->descriptor = hds;
+ }
+
+ /* Now, if the descriptor is undefined, import the descriptor
+ rather than the symbol we were told to import. FIXME: Is
+ this correct in all cases? */
+ if (hds->root.type == bfd_link_hash_undefined)
+ h = hds;
+ }
+
+ h->flags |= XCOFF_IMPORT;
+
+ if (val != (bfd_vma) -1)
+ {
+ if (h->root.type == bfd_link_hash_defined
+ && (! bfd_is_abs_section (h->root.u.def.section)
+ || h->root.u.def.value != val))
+ {
+ if (! ((*info->callbacks->multiple_definition)
+ (info, h->root.root.string, h->root.u.def.section->owner,
+ h->root.u.def.section, h->root.u.def.value,
+ output_bfd, bfd_abs_section_ptr, val)))
+ return false;
+ }
+
+ h->root.type = bfd_link_hash_defined;
+ h->root.u.def.section = bfd_abs_section_ptr;
+ h->root.u.def.value = val;
+ }
+
+ /* We overload the ldindx field to hold the l_ifile value for this
+ symbol. */
+ BFD_ASSERT (h->ldsym == NULL);
+ BFD_ASSERT ((h->flags & XCOFF_BUILT_LDSYM) == 0);
+ if (imppath == NULL)
+ h->ldindx = -1;
+ else
+ {
+ unsigned int c;
+ struct xcoff_import_file **pp;
+
+ /* We start c at 1 because the first entry in the import list is
+ reserved for the library search path. */
+ for (pp = &xcoff_hash_table (info)->imports, c = 1;
+ *pp != NULL;
+ pp = &(*pp)->next, ++c)
+ {
+ if (strcmp ((*pp)->path, imppath) == 0
+ && strcmp ((*pp)->file, impfile) == 0
+ && strcmp ((*pp)->member, impmember) == 0)
+ break;
+ }
+
+ if (*pp == NULL)
+ {
+ struct xcoff_import_file *n;
+
+ n = ((struct xcoff_import_file *)
+ bfd_alloc (output_bfd, sizeof (struct xcoff_import_file)));
+ if (n == NULL)
+ return false;
+ n->next = NULL;
+ n->path = imppath;
+ n->file = impfile;
+ n->member = impmember;
+ *pp = n;
+ }
+
+ h->ldindx = c;
+ }
+
+ return true;
+}
+
+/* Export a symbol. */
+
+boolean
+bfd_xcoff_export_symbol (output_bfd, info, harg, syscall)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct bfd_link_hash_entry *harg;
+ boolean syscall;
+{
+ struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
+
+ if (! XCOFF_XVECP (output_bfd->xvec))
+ return true;
+
+ h->flags |= XCOFF_EXPORT;
+
+ /* FIXME: I'm not at all sure what syscall is supposed to mean, so
+ I'm just going to ignore it until somebody explains it. */
+
+ /* See if this is a function descriptor. It may be one even though
+ it is not so marked. */
+ if ((h->flags & XCOFF_DESCRIPTOR) == 0
+ && h->root.root.string[0] != '.')
+ {
+ char *fnname;
+ struct xcoff_link_hash_entry *hfn;
+
+ fnname = (char *) bfd_malloc (strlen (h->root.root.string) + 2);
+ if (fnname == NULL)
+ return false;
+ fnname[0] = '.';
+ strcpy (fnname + 1, h->root.root.string);
+ hfn = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ fnname, false, false, true);
+ free (fnname);
+ if (hfn != NULL
+ && hfn->smclas == XMC_PR
+ && (hfn->root.type == bfd_link_hash_defined
+ || hfn->root.type == bfd_link_hash_defweak))
+ {
+ h->flags |= XCOFF_DESCRIPTOR;
+ h->descriptor = hfn;
+ hfn->descriptor = h;
+ }
+ }
+
+ /* Make sure we don't garbage collect this symbol. */
+ if (! xcoff_mark_symbol (info, h))
+ return false;
+
+ /* If this is a function descriptor, make sure we don't garbage
+ collect the associated function code. We normally don't have to
+ worry about this, because the descriptor will be attached to a
+ section with relocs, but if we are creating the descriptor
+ ourselves those relocs will not be visible to the mark code. */
+ if ((h->flags & XCOFF_DESCRIPTOR) != 0)
+ {
+ if (! xcoff_mark_symbol (info, h->descriptor))
+ return false;
+ }
+
+ return true;
+}
+
+/* Count a reloc against a symbol. This is called for relocs
+ generated by the linker script, typically for global constructors
+ and destructors. */
+
+boolean
+bfd_xcoff_link_count_reloc (output_bfd, info, name)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ const char *name;
+{
+ struct xcoff_link_hash_entry *h;
+
+ if (! XCOFF_XVECP (output_bfd->xvec))
+ return true;
+
+ h = ((struct xcoff_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (output_bfd, info, name, false, false,
+ false));
+ if (h == NULL)
+ {
+ (*_bfd_error_handler) (_("%s: no such symbol"), name);
+ bfd_set_error (bfd_error_no_symbols);
+ return false;
+ }
+
+ h->flags |= XCOFF_REF_REGULAR | XCOFF_LDREL;
+ ++xcoff_hash_table (info)->ldrel_count;
+
+ /* Mark the symbol to avoid garbage collection. */
+ if (! xcoff_mark_symbol (info, h))
+ return false;
+
+ return true;
+}
+
+/* This function is called for each symbol to which the linker script
+ assigns a value. */
+
+boolean
+bfd_xcoff_record_link_assignment (output_bfd, info, name)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ const char *name;
+{
+ struct xcoff_link_hash_entry *h;
+
+ if (! XCOFF_XVECP (output_bfd->xvec))
+ return true;
+
+ h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true, true,
+ false);
+ if (h == NULL)
+ return false;
+
+ h->flags |= XCOFF_DEF_REGULAR;
+
+ return true;
+}
+
+/* This structure is used to pass information through
+ xcoff_link_hash_traverse. */
+
+struct xcoff_loader_info
+{
+ /* Set if a problem occurred. */
+ boolean failed;
+ /* Output BFD. */
+ bfd *output_bfd;
+ /* Link information structure. */
+ struct bfd_link_info *info;
+ /* Whether all defined symbols should be exported. */
+ boolean export_defineds;
+ /* Number of ldsym structures. */
+ size_t ldsym_count;
+ /* Size of string table. */
+ size_t string_size;
+ /* String table. */
+ bfd_byte *strings;
+ /* Allocated size of string table. */
+ size_t string_alc;
+};
+
+/* Build the .loader section. This is called by the XCOFF linker
+ emulation before_allocation routine. We must set the size of the
+ .loader section before the linker lays out the output file.
+ LIBPATH is the library path to search for shared objects; this is
+ normally built from the -L arguments passed to the linker. ENTRY
+ is the name of the entry point symbol (the -e linker option).
+ FILE_ALIGN is the alignment to use for sections within the file
+ (the -H linker option). MAXSTACK is the maximum stack size (the
+ -bmaxstack linker option). MAXDATA is the maximum data size (the
+ -bmaxdata linker option). GC is whether to do garbage collection
+ (the -bgc linker option). MODTYPE is the module type (the
+ -bmodtype linker option). TEXTRO is whether the text section must
+ be read only (the -btextro linker option). EXPORT_DEFINEDS is
+ whether all defined symbols should be exported (the -unix linker
+ option). SPECIAL_SECTIONS is set by this routine to csects with
+ magic names like _end. */
+
+boolean
+bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
+ file_align, maxstack, maxdata, gc,
+ modtype, textro, export_defineds,
+ special_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ const char *libpath;
+ const char *entry;
+ unsigned long file_align;
+ unsigned long maxstack;
+ unsigned long maxdata;
+ boolean gc;
+ int modtype;
+ boolean textro;
+ boolean export_defineds;
+ asection **special_sections;
+{
+ struct xcoff_link_hash_entry *hentry;
+ asection *lsec;
+ struct xcoff_loader_info ldinfo;
+ int i;
+ size_t impsize, impcount;
+ struct xcoff_import_file *fl;
+ struct internal_ldhdr *ldhdr;
+ bfd_size_type stoff;
+ register char *out;
+ asection *sec;
+ bfd *sub;
+ struct bfd_strtab_hash *debug_strtab;
+ bfd_byte *debug_contents = NULL;
+
+ if (! XCOFF_XVECP (output_bfd->xvec))
+ {
+ for (i = 0; i < 6; i++)
+ special_sections[i] = NULL;
+ return true;
+ }
+
+ ldinfo.failed = false;
+ ldinfo.output_bfd = output_bfd;
+ ldinfo.info = info;
+ ldinfo.export_defineds = export_defineds;
+ ldinfo.ldsym_count = 0;
+ ldinfo.string_size = 0;
+ ldinfo.strings = NULL;
+ ldinfo.string_alc = 0;
+
+ xcoff_data (output_bfd)->maxstack = maxstack;
+ xcoff_data (output_bfd)->maxdata = maxdata;
+ xcoff_data (output_bfd)->modtype = modtype;
+
+ xcoff_hash_table (info)->file_align = file_align;
+ xcoff_hash_table (info)->textro = textro;
+
+ hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry,
+ false, false, true);
+ if (hentry != NULL)
+ hentry->flags |= XCOFF_ENTRY;
+
+ /* Garbage collect unused sections. */
+ if (info->relocateable
+ || ! gc
+ || hentry == NULL
+ || (hentry->root.type != bfd_link_hash_defined
+ && hentry->root.type != bfd_link_hash_defweak))
+ {
+ gc = false;
+ xcoff_hash_table (info)->gc = false;
+
+ /* We still need to call xcoff_mark, in order to set ldrel_count
+ correctly. */
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *o;
+
+ for (o = sub->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & SEC_MARK) == 0)
+ {
+ if (! xcoff_mark (info, o))
+ goto error_return;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (! xcoff_mark (info, hentry->root.u.def.section))
+ goto error_return;
+ xcoff_sweep (info);
+ xcoff_hash_table (info)->gc = true;
+ }
+
+ /* Return special sections to the caller. */
+ for (i = 0; i < 6; i++)
+ {
+ asection *sec;
+
+ sec = xcoff_hash_table (info)->special_sections[i];
+ if (sec != NULL
+ && gc
+ && (sec->flags & SEC_MARK) == 0)
+ sec = NULL;
+ special_sections[i] = sec;
+ }
+
+ if (info->input_bfds == NULL)
+ {
+ /* I'm not sure what to do in this bizarre case. */
+ return true;
+ }
+
+ xcoff_link_hash_traverse (xcoff_hash_table (info), xcoff_build_ldsyms,
+ (PTR) &ldinfo);
+ if (ldinfo.failed)
+ goto error_return;
+
+ /* Work out the size of the import file names. Each import file ID
+ consists of three null terminated strings: the path, the file
+ name, and the archive member name. The first entry in the list
+ of names is the path to use to find objects, which the linker has
+ passed in as the libpath argument. For some reason, the path
+ entry in the other import file names appears to always be empty. */
+ impsize = strlen (libpath) + 3;
+ impcount = 1;
+ for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)
+ {
+ ++impcount;
+ impsize += (strlen (fl->path)
+ + strlen (fl->file)
+ + strlen (fl->member)
+ + 3);
+ }
+
+ /* Set up the .loader section header. */
+ ldhdr = &xcoff_hash_table (info)->ldhdr;
+ ldhdr->l_version = 1;
+ ldhdr->l_nsyms = ldinfo.ldsym_count;
+ ldhdr->l_nreloc = xcoff_hash_table (info)->ldrel_count;
+ ldhdr->l_istlen = impsize;
+ ldhdr->l_nimpid = impcount;
+ ldhdr->l_impoff = (LDHDRSZ
+ + ldhdr->l_nsyms * LDSYMSZ
+ + ldhdr->l_nreloc * LDRELSZ);
+ ldhdr->l_stlen = ldinfo.string_size;
+ stoff = ldhdr->l_impoff + impsize;
+ if (ldinfo.string_size == 0)
+ ldhdr->l_stoff = 0;
+ else
+ ldhdr->l_stoff = stoff;
+
+ /* We now know the final size of the .loader section. Allocate
+ space for it. */
+ lsec = xcoff_hash_table (info)->loader_section;
+ lsec->_raw_size = stoff + ldhdr->l_stlen;
+ lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->_raw_size);
+ if (lsec->contents == NULL)
+ goto error_return;
+
+ /* Set up the header. */
+ xcoff_swap_ldhdr_out (output_bfd, ldhdr,
+ (struct external_ldhdr *) lsec->contents);
+
+ /* Set up the import file names. */
+ out = (char *) lsec->contents + ldhdr->l_impoff;
+ strcpy (out, libpath);
+ out += strlen (libpath) + 1;
+ *out++ = '\0';
+ *out++ = '\0';
+ for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)
+ {
+ register const char *s;
+
+ s = fl->path;
+ while ((*out++ = *s++) != '\0')
+ ;
+ s = fl->file;
+ while ((*out++ = *s++) != '\0')
+ ;
+ s = fl->member;
+ while ((*out++ = *s++) != '\0')
+ ;
+ }
+
+ BFD_ASSERT ((bfd_size_type) ((bfd_byte *) out - lsec->contents) == stoff);
+
+ /* Set up the symbol string table. */
+ if (ldinfo.string_size > 0)
+ {
+ memcpy (out, ldinfo.strings, ldinfo.string_size);
+ free (ldinfo.strings);
+ ldinfo.strings = NULL;
+ }
+
+ /* We can't set up the symbol table or the relocs yet, because we
+ don't yet know the final position of the various sections. The
+ .loader symbols are written out when the corresponding normal
+ symbols are written out in xcoff_link_input_bfd or
+ xcoff_write_global_symbol. The .loader relocs are written out
+ when the corresponding normal relocs are handled in
+ xcoff_link_input_bfd. */
+
+ /* Allocate space for the magic sections. */
+ sec = xcoff_hash_table (info)->linkage_section;
+ if (sec->_raw_size > 0)
+ {
+ sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
+ if (sec->contents == NULL)
+ goto error_return;
+ }
+ sec = xcoff_hash_table (info)->toc_section;
+ if (sec->_raw_size > 0)
+ {
+ sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
+ if (sec->contents == NULL)
+ goto error_return;
+ }
+ sec = xcoff_hash_table (info)->descriptor_section;
+ if (sec->_raw_size > 0)
+ {
+ sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
+ if (sec->contents == NULL)
+ goto error_return;
+ }
+
+ /* Now that we've done garbage collection, figure out the contents
+ of the .debug section. */
+ debug_strtab = xcoff_hash_table (info)->debug_strtab;
+
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *subdeb;
+ bfd_size_type symcount;
+ unsigned long *debug_index;
+ asection **csectpp;
+ bfd_byte *esym, *esymend;
+ bfd_size_type symesz;
+
+ if (sub->xvec != info->hash->creator)
+ continue;
+ subdeb = bfd_get_section_by_name (sub, ".debug");
+ if (subdeb == NULL || subdeb->_raw_size == 0)
+ continue;
+
+ if (info->strip == strip_all
+ || info->strip == strip_debugger
+ || info->discard == discard_all)
+ {
+ subdeb->_raw_size = 0;
+ continue;
+ }
+
+ if (! _bfd_coff_get_external_symbols (sub))
+ goto error_return;
+
+ symcount = obj_raw_syment_count (sub);
+ debug_index = ((unsigned long *)
+ bfd_zalloc (sub, symcount * sizeof (unsigned long)));
+ if (debug_index == NULL)
+ goto error_return;
+ xcoff_data (sub)->debug_indices = debug_index;
+
+ /* Grab the contents of the .debug section. We use malloc and
+ copy the names into the debug stringtab, rather than
+ bfd_alloc, because I expect that, when linking many files
+ together, many of the strings will be the same. Storing the
+ strings in the hash table should save space in this case. */
+ debug_contents = (bfd_byte *) bfd_malloc (subdeb->_raw_size);
+ if (debug_contents == NULL)
+ goto error_return;
+ if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents,
+ (file_ptr) 0, subdeb->_raw_size))
+ goto error_return;
+
+ csectpp = xcoff_data (sub)->csects;
+
+ symesz = bfd_coff_symesz (sub);
+ esym = (bfd_byte *) obj_coff_external_syms (sub);
+ esymend = esym + symcount * symesz;
+ while (esym < esymend)
+ {
+ struct internal_syment sym;
+
+ bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym);
+
+ *debug_index = (unsigned long) -1;
+
+ if (sym._n._n_n._n_zeroes == 0
+ && *csectpp != NULL
+ && (! gc
+ || ((*csectpp)->flags & SEC_MARK) != 0
+ || *csectpp == bfd_abs_section_ptr)
+ && bfd_coff_symname_in_debug (sub, &sym))
+ {
+ char *name;
+ bfd_size_type indx;
+
+ name = (char *) debug_contents + sym._n._n_n._n_offset;
+ indx = _bfd_stringtab_add (debug_strtab, name, true, true);
+ if (indx == (bfd_size_type) -1)
+ goto error_return;
+ *debug_index = indx;
+ }
+
+ esym += (sym.n_numaux + 1) * symesz;
+ csectpp += sym.n_numaux + 1;
+ debug_index += sym.n_numaux + 1;
+ }
+
+ free (debug_contents);
+ debug_contents = NULL;
+
+ /* Clear the size of subdeb, so that it is not included directly
+ in the output file. */
+ subdeb->_raw_size = 0;
+
+ if (! info->keep_memory)
+ {
+ if (! _bfd_coff_free_symbols (sub))
+ goto error_return;
+ }
+ }
+
+ if (info->strip != strip_all)
+ xcoff_hash_table (info)->debug_section->_raw_size =
+ _bfd_stringtab_size (debug_strtab);
+
+ return true;
+
+ error_return:
+ if (ldinfo.strings != NULL)
+ free (ldinfo.strings);
+ if (debug_contents != NULL)
+ free (debug_contents);
+ return false;
+}
+
+/* Add a symbol to the .loader symbols, if necessary. */
+
+static boolean
+xcoff_build_ldsyms (h, p)
+ struct xcoff_link_hash_entry *h;
+ PTR p;
+{
+ struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p;
+ size_t len;
+
+ /* If this is a final link, and the symbol was defined as a common
+ symbol in a regular object file, and there was no definition in
+ any dynamic object, then the linker will have allocated space for
+ the symbol in a common section but the XCOFF_DEF_REGULAR flag
+ will not have been set. */
+ if (h->root.type == bfd_link_hash_defined
+ && (h->flags & XCOFF_DEF_REGULAR) == 0
+ && (h->flags & XCOFF_REF_REGULAR) != 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) == 0
+ && (bfd_is_abs_section (h->root.u.def.section)
+ || (h->root.u.def.section->owner->flags & DYNAMIC) == 0))
+ h->flags |= XCOFF_DEF_REGULAR;
+
+ /* If all defined symbols should be exported, mark them now. We
+ don't want to export the actual functions, just the function
+ descriptors. */
+ if (ldinfo->export_defineds
+ && (h->flags & XCOFF_DEF_REGULAR) != 0
+ && h->root.root.string[0] != '.')
+ {
+ boolean export;
+
+ /* We don't export a symbol which is being defined by an object
+ included from an archive which contains a shared object. The
+ rationale is that if an archive contains both an unshared and
+ a shared object, then there must be some reason that the
+ unshared object is unshared, and we don't want to start
+ providing a shared version of it. In particular, this solves
+ a bug involving the _savefNN set of functions. gcc will call
+ those functions without providing a slot to restore the TOC,
+ so it is essential that these functions be linked in directly
+ and not from a shared object, which means that a shared
+ object which also happens to link them in must not export
+ them. This is confusing, but I haven't been able to think of
+ a different approach. Note that the symbols can, of course,
+ be exported explicitly. */
+ export = true;
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->root.u.def.section->owner != NULL
+ && h->root.u.def.section->owner->my_archive != NULL)
+ {
+ bfd *arbfd, *member;
+
+ arbfd = h->root.u.def.section->owner->my_archive;
+ member = bfd_openr_next_archived_file (arbfd, (bfd *) NULL);
+ while (member != NULL)
+ {
+ if ((member->flags & DYNAMIC) != 0)
+ {
+ export = false;
+ break;
+ }
+ member = bfd_openr_next_archived_file (arbfd, member);
+ }
+ }
+
+ if (export)
+ h->flags |= XCOFF_EXPORT;
+ }
+
+ /* We don't want to garbage collect symbols which are not defined in
+ XCOFF files. This is a convenient place to mark them. */
+ if (xcoff_hash_table (ldinfo->info)->gc
+ && (h->flags & XCOFF_MARK) == 0
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->owner == NULL
+ || (h->root.u.def.section->owner->xvec
+ != ldinfo->info->hash->creator)))
+ h->flags |= XCOFF_MARK;
+
+ /* If this symbol is called and defined in a dynamic object, or it
+ is imported, then we need to set up global linkage code for it.
+ (Unless we did garbage collection and we didn't need this
+ symbol.) */
+ if ((h->flags & XCOFF_CALLED) != 0
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ && h->root.root.string[0] == '.'
+ && h->descriptor != NULL
+ && ((h->descriptor->flags & XCOFF_DEF_DYNAMIC) != 0
+ || ((h->descriptor->flags & XCOFF_IMPORT) != 0
+ && (h->descriptor->flags & XCOFF_DEF_REGULAR) == 0))
+ && (! xcoff_hash_table (ldinfo->info)->gc
+ || (h->flags & XCOFF_MARK) != 0))
+ {
+ asection *sec;
+ struct xcoff_link_hash_entry *hds;
+
+ sec = xcoff_hash_table (ldinfo->info)->linkage_section;
+ h->root.type = bfd_link_hash_defined;
+ h->root.u.def.section = sec;
+ h->root.u.def.value = sec->_raw_size;
+ h->smclas = XMC_GL;
+ h->flags |= XCOFF_DEF_REGULAR;
+ sec->_raw_size += XCOFF_GLINK_SIZE;
+
+ /* The global linkage code requires a TOC entry for the
+ descriptor. */
+ hds = h->descriptor;
+ BFD_ASSERT ((hds->root.type == bfd_link_hash_undefined
+ || hds->root.type == bfd_link_hash_undefweak)
+ && (hds->flags & XCOFF_DEF_REGULAR) == 0);
+ hds->flags |= XCOFF_MARK;
+ if (hds->toc_section == NULL)
+ {
+ hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section;
+ hds->u.toc_offset = hds->toc_section->_raw_size;
+ hds->toc_section->_raw_size += 4;
+ ++xcoff_hash_table (ldinfo->info)->ldrel_count;
+ ++hds->toc_section->reloc_count;
+ hds->indx = -2;
+ hds->flags |= XCOFF_SET_TOC | XCOFF_LDREL;
+
+ /* We need to call xcoff_build_ldsyms recursively here,
+ because we may already have passed hds on the traversal. */
+ xcoff_build_ldsyms (hds, p);
+ }
+ }
+
+ /* If this symbol is exported, but not defined, we need to try to
+ define it. */
+ if ((h->flags & XCOFF_EXPORT) != 0
+ && (h->flags & XCOFF_IMPORT) == 0
+ && (h->flags & XCOFF_DEF_REGULAR) == 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) == 0
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak))
+ {
+ if ((h->flags & XCOFF_DESCRIPTOR) != 0
+ && (h->descriptor->root.type == bfd_link_hash_defined
+ || h->descriptor->root.type == bfd_link_hash_defweak))
+ {
+ asection *sec;
+
+ /* This is an undefined function descriptor associated with
+ a defined entry point. We can build up a function
+ descriptor ourselves. Believe it or not, the AIX linker
+ actually does this, and there are cases where we need to
+ do it as well. */
+ sec = xcoff_hash_table (ldinfo->info)->descriptor_section;
+ h->root.type = bfd_link_hash_defined;
+ h->root.u.def.section = sec;
+ h->root.u.def.value = sec->_raw_size;
+ h->smclas = XMC_DS;
+ h->flags |= XCOFF_DEF_REGULAR;
+ sec->_raw_size += 12;
+
+ /* A function descriptor uses two relocs: one for the
+ associated code, and one for the TOC address. */
+ xcoff_hash_table (ldinfo->info)->ldrel_count += 2;
+ sec->reloc_count += 2;
+
+ /* We handle writing out the contents of the descriptor in
+ xcoff_write_global_symbol. */
+ }
+ else
+ {
+ (*_bfd_error_handler)
+ (_("warning: attempt to export undefined symbol `%s'"),
+ h->root.root.string);
+ h->ldsym = NULL;
+ return true;
+ }
+ }
+
+ /* If this is still a common symbol, and it wasn't garbage
+ collected, we need to actually allocate space for it in the .bss
+ section. */
+ if (h->root.type == bfd_link_hash_common
+ && (! xcoff_hash_table (ldinfo->info)->gc
+ || (h->flags & XCOFF_MARK) != 0)
+ && h->root.u.c.p->section->_raw_size == 0)
+ {
+ BFD_ASSERT (bfd_is_com_section (h->root.u.c.p->section));
+ h->root.u.c.p->section->_raw_size = h->root.u.c.size;
+ }
+
+ /* We need to add a symbol to the .loader section if it is mentioned
+ in a reloc which we are copying to the .loader section and it was
+ not defined or common, or if it is the entry point, or if it is
+ being exported. */
+
+ if (((h->flags & XCOFF_LDREL) == 0
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_common)
+ && (h->flags & XCOFF_ENTRY) == 0
+ && (h->flags & XCOFF_EXPORT) == 0)
+ {
+ h->ldsym = NULL;
+ return true;
+ }
+
+ /* We don't need to add this symbol if we did garbage collection and
+ we did not mark this symbol. */
+ if (xcoff_hash_table (ldinfo->info)->gc
+ && (h->flags & XCOFF_MARK) == 0)
+ {
+ h->ldsym = NULL;
+ return true;
+ }
+
+ /* We may have already processed this symbol due to the recursive
+ call above. */
+ if ((h->flags & XCOFF_BUILT_LDSYM) != 0)
+ return true;
+
+ /* We need to add this symbol to the .loader symbols. */
+
+ BFD_ASSERT (h->ldsym == NULL);
+ h->ldsym = ((struct internal_ldsym *)
+ bfd_zalloc (ldinfo->output_bfd,
+ sizeof (struct internal_ldsym)));
+ if (h->ldsym == NULL)
+ {
+ ldinfo->failed = true;
+ return false;
+ }
+
+ if ((h->flags & XCOFF_IMPORT) != 0)
+ h->ldsym->l_ifile = h->ldindx;
+
+ /* The first 3 symbol table indices are reserved to indicate the
+ sections. */
+ h->ldindx = ldinfo->ldsym_count + 3;
+
+ ++ldinfo->ldsym_count;
+
+ len = strlen (h->root.root.string);
+ if (len <= SYMNMLEN)
+ strncpy (h->ldsym->_l._l_name, h->root.root.string, SYMNMLEN);
+ else
+ {
+ if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
+ {
+ size_t newalc;
+ bfd_byte *newstrings;
+
+ newalc = ldinfo->string_alc * 2;
+ if (newalc == 0)
+ newalc = 32;
+ while (ldinfo->string_size + len + 3 > newalc)
+ newalc *= 2;
+
+ newstrings = ((bfd_byte *)
+ bfd_realloc ((PTR) ldinfo->strings, newalc));
+ if (newstrings == NULL)
+ {
+ ldinfo->failed = true;
+ return false;
+ }
+ ldinfo->string_alc = newalc;
+ ldinfo->strings = newstrings;
+ }
+
+ bfd_put_16 (ldinfo->output_bfd, len + 1,
+ ldinfo->strings + ldinfo->string_size);
+ strcpy (ldinfo->strings + ldinfo->string_size + 2, h->root.root.string);
+ h->ldsym->_l._l_l._l_zeroes = 0;
+ h->ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
+ ldinfo->string_size += len + 3;
+ }
+
+ h->flags |= XCOFF_BUILT_LDSYM;
+
+ return true;
+}
+
+/* Do the final link step. */
+
+boolean
+_bfd_xcoff_bfd_final_link (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ bfd_size_type symesz;
+ struct xcoff_final_link_info finfo;
+ asection *o;
+ struct bfd_link_order *p;
+ size_t max_contents_size;
+ size_t max_sym_count;
+ size_t max_lineno_count;
+ size_t max_reloc_count;
+ size_t max_output_reloc_count;
+ file_ptr rel_filepos;
+ unsigned int relsz;
+ file_ptr line_filepos;
+ unsigned int linesz;
+ bfd *sub;
+ bfd_byte *external_relocs = NULL;
+ char strbuf[STRING_SIZE_SIZE];
+
+ if (info->shared)
+ abfd->flags |= DYNAMIC;
+
+ symesz = bfd_coff_symesz (abfd);
+
+ finfo.info = info;
+ finfo.output_bfd = abfd;
+ finfo.strtab = NULL;
+ finfo.section_info = NULL;
+ finfo.last_file_index = -1;
+ finfo.toc_symindx = -1;
+ finfo.internal_syms = NULL;
+ finfo.sym_indices = NULL;
+ finfo.outsyms = NULL;
+ finfo.linenos = NULL;
+ finfo.contents = NULL;
+ finfo.external_relocs = NULL;
+
+ finfo.ldsym = ((struct external_ldsym *)
+ (xcoff_hash_table (info)->loader_section->contents
+ + LDHDRSZ));
+ finfo.ldrel = ((struct external_ldrel *)
+ (xcoff_hash_table (info)->loader_section->contents
+ + LDHDRSZ
+ + xcoff_hash_table (info)->ldhdr.l_nsyms * LDSYMSZ));
+
+ xcoff_data (abfd)->coff.link_info = info;
+
+ finfo.strtab = _bfd_stringtab_init ();
+ if (finfo.strtab == NULL)
+ goto error_return;
+
+ /* Count the line number and relocation entries required for the
+ output file. Determine a few maximum sizes. */
+ max_contents_size = 0;
+ max_lineno_count = 0;
+ max_reloc_count = 0;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order)
+ {
+ asection *sec;
+
+ sec = p->u.indirect.section;
+
+ /* Mark all sections which are to be included in the
+ link. This will normally be every section. We need
+ to do this so that we can identify any sections which
+ the linker has decided to not include. */
+ sec->linker_mark = true;
+
+ if (info->strip == strip_none
+ || info->strip == strip_some)
+ o->lineno_count += sec->lineno_count;
+
+ o->reloc_count += sec->reloc_count;
+
+ if (sec->_raw_size > max_contents_size)
+ max_contents_size = sec->_raw_size;
+ if (sec->lineno_count > max_lineno_count)
+ max_lineno_count = sec->lineno_count;
+ if (coff_section_data (sec->owner, sec) != NULL
+ && xcoff_section_data (sec->owner, sec) != NULL
+ && (xcoff_section_data (sec->owner, sec)->lineno_count
+ > max_lineno_count))
+ max_lineno_count =
+ xcoff_section_data (sec->owner, sec)->lineno_count;
+ if (sec->reloc_count > max_reloc_count)
+ max_reloc_count = sec->reloc_count;
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ ++o->reloc_count;
+ }
+ }
+
+ /* Compute the file positions for all the sections. */
+ if (abfd->output_has_begun)
+ {
+ if (xcoff_hash_table (info)->file_align != 0)
+ abort ();
+ }
+ else
+ {
+ bfd_vma file_align;
+
+ file_align = xcoff_hash_table (info)->file_align;
+ if (file_align != 0)
+ {
+ boolean saw_contents;
+ int indx;
+ asection **op;
+ file_ptr sofar;
+
+ /* Insert .pad sections before every section which has
+ contents and is loaded, if it is preceded by some other
+ section which has contents and is loaded. */
+ saw_contents = true;
+ for (op = &abfd->sections; *op != NULL; op = &(*op)->next)
+ {
+ if (strcmp ((*op)->name, ".pad") == 0)
+ saw_contents = false;
+ else if (((*op)->flags & SEC_HAS_CONTENTS) != 0
+ && ((*op)->flags & SEC_LOAD) != 0)
+ {
+ if (! saw_contents)
+ saw_contents = true;
+ else
+ {
+ asection *n, *hold;
+
+ hold = *op;
+ *op = NULL;
+ n = bfd_make_section_anyway (abfd, ".pad");
+ BFD_ASSERT (*op == n);
+ n->next = hold;
+ n->flags = SEC_HAS_CONTENTS;
+ n->alignment_power = 0;
+ saw_contents = false;
+ }
+ }
+ }
+
+ /* Reset the section indices after inserting the new
+ sections. */
+ indx = 0;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ ++indx;
+ o->target_index = indx;
+ }
+ BFD_ASSERT ((unsigned int) indx == abfd->section_count);
+
+ /* Work out appropriate sizes for the .pad sections to force
+ each section to land on a page boundary. This bit of
+ code knows what compute_section_file_positions is going
+ to do. */
+ sofar = bfd_coff_filhsz (abfd);
+ sofar += bfd_coff_aoutsz (abfd);
+ sofar += abfd->section_count * bfd_coff_scnhsz (abfd);
+ for (o = abfd->sections; o != NULL; o = o->next)
+ if (o->reloc_count >= 0xffff || o->lineno_count >= 0xffff)
+ sofar += bfd_coff_scnhsz (abfd);
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if (strcmp (o->name, ".pad") == 0)
+ {
+ bfd_vma pageoff;
+
+ BFD_ASSERT (o->_raw_size == 0);
+ pageoff = sofar & (file_align - 1);
+ if (pageoff != 0)
+ {
+ o->_raw_size = file_align - pageoff;
+ sofar += file_align - pageoff;
+ o->flags |= SEC_HAS_CONTENTS;
+ }
+ }
+ else
+ {
+ if ((o->flags & SEC_HAS_CONTENTS) != 0)
+ sofar += BFD_ALIGN (o->_raw_size,
+ 1 << o->alignment_power);
+ }
+ }
+ }
+
+ if (! bfd_coff_compute_section_file_positions (abfd))
+ goto error_return;
+ }
+
+ /* Allocate space for the pointers we need to keep for the relocs. */
+ {
+ unsigned int i;
+
+ /* We use section_count + 1, rather than section_count, because
+ the target_index fields are 1 based. */
+ finfo.section_info =
+ ((struct xcoff_link_section_info *)
+ bfd_malloc ((abfd->section_count + 1)
+ * sizeof (struct xcoff_link_section_info)));
+ if (finfo.section_info == NULL)
+ goto error_return;
+ for (i = 0; i <= abfd->section_count; i++)
+ {
+ finfo.section_info[i].relocs = NULL;
+ finfo.section_info[i].rel_hashes = NULL;
+ finfo.section_info[i].toc_rel_hashes = NULL;
+ }
+ }
+
+ /* Set the file positions for the relocs. */
+ rel_filepos = obj_relocbase (abfd);
+ relsz = bfd_coff_relsz (abfd);
+ max_output_reloc_count = 0;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if (o->reloc_count == 0)
+ o->rel_filepos = 0;
+ else
+ {
+ /* A stripped file has no relocs. However, we still
+ allocate the buffers, so that later code doesn't have to
+ worry about whether we are stripping or not. */
+ if (info->strip == strip_all)
+ o->rel_filepos = 0;
+ else
+ {
+ o->flags |= SEC_RELOC;
+ o->rel_filepos = rel_filepos;
+ rel_filepos += o->reloc_count * relsz;
+ }
+
+ /* We don't know the indices of global symbols until we have
+ written out all the local symbols. For each section in
+ the output file, we keep an array of pointers to hash
+ table entries. Each entry in the array corresponds to a
+ reloc. When we find a reloc against a global symbol, we
+ set the corresponding entry in this array so that we can
+ fix up the symbol index after we have written out all the
+ local symbols.
+
+ Because of this problem, we also keep the relocs in
+ memory until the end of the link. This wastes memory.
+ We could backpatch the file later, I suppose, although it
+ would be slow. */
+ finfo.section_info[o->target_index].relocs =
+ ((struct internal_reloc *)
+ bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+ finfo.section_info[o->target_index].rel_hashes =
+ ((struct xcoff_link_hash_entry **)
+ bfd_malloc (o->reloc_count
+ * sizeof (struct xcoff_link_hash_entry *)));
+ if (finfo.section_info[o->target_index].relocs == NULL
+ || finfo.section_info[o->target_index].rel_hashes == NULL)
+ goto error_return;
+
+ if (o->reloc_count > max_output_reloc_count)
+ max_output_reloc_count = o->reloc_count;
+ }
+ }
+
+ /* We now know the size of the relocs, so we can determine the file
+ positions of the line numbers. */
+ line_filepos = rel_filepos;
+ finfo.line_filepos = line_filepos;
+ linesz = bfd_coff_linesz (abfd);
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ if (o->lineno_count == 0)
+ o->line_filepos = 0;
+ else
+ {
+ o->line_filepos = line_filepos;
+ line_filepos += o->lineno_count * linesz;
+ }
+
+ /* Reset the reloc and lineno counts, so that we can use them to
+ count the number of entries we have output so far. */
+ o->reloc_count = 0;
+ o->lineno_count = 0;
+ }
+
+ obj_sym_filepos (abfd) = line_filepos;
+
+ /* Figure out the largest number of symbols in an input BFD. Take
+ the opportunity to clear the output_has_begun fields of all the
+ input BFD's. We want at least 6 symbols, since that is the
+ number which xcoff_write_global_symbol may need. */
+ max_sym_count = 6;
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ size_t sz;
+
+ sub->output_has_begun = false;
+ sz = obj_raw_syment_count (sub);
+ if (sz > max_sym_count)
+ max_sym_count = sz;
+ }
+
+ /* Allocate some buffers used while linking. */
+ finfo.internal_syms = ((struct internal_syment *)
+ bfd_malloc (max_sym_count
+ * sizeof (struct internal_syment)));
+ finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
+ finfo.outsyms = ((bfd_byte *)
+ bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
+ finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
+ * bfd_coff_linesz (abfd));
+ finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+ finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
+ if ((finfo.internal_syms == NULL && max_sym_count > 0)
+ || (finfo.sym_indices == NULL && max_sym_count > 0)
+ || finfo.outsyms == NULL
+ || (finfo.linenos == NULL && max_lineno_count > 0)
+ || (finfo.contents == NULL && max_contents_size > 0)
+ || (finfo.external_relocs == NULL && max_reloc_count > 0))
+ goto error_return;
+
+ obj_raw_syment_count (abfd) = 0;
+ xcoff_data (abfd)->toc = (bfd_vma) -1;
+
+ /* We now know the position of everything in the file, except that
+ we don't know the size of the symbol table and therefore we don't
+ know where the string table starts. We just build the string
+ table in memory as we go along. We process all the relocations
+ for a single input file at once. */
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ for (p = o->link_order_head; p != NULL; p = p->next)
+ {
+ if (p->type == bfd_indirect_link_order
+ && p->u.indirect.section->owner->xvec == abfd->xvec)
+ {
+ sub = p->u.indirect.section->owner;
+ if (! sub->output_has_begun)
+ {
+ if (! xcoff_link_input_bfd (&finfo, sub))
+ goto error_return;
+ sub->output_has_begun = true;
+ }
+ }
+ else if (p->type == bfd_section_reloc_link_order
+ || p->type == bfd_symbol_reloc_link_order)
+ {
+ if (! xcoff_reloc_link_order (abfd, &finfo, o, p))
+ goto error_return;
+ }
+ else
+ {
+ if (! _bfd_default_link_order (abfd, info, o, p))
+ goto error_return;
+ }
+ }
+ }
+
+ /* Free up the buffers used by xcoff_link_input_bfd. */
+
+ if (finfo.internal_syms != NULL)
+ {
+ free (finfo.internal_syms);
+ finfo.internal_syms = NULL;
+ }
+ if (finfo.sym_indices != NULL)
+ {
+ free (finfo.sym_indices);
+ finfo.sym_indices = NULL;
+ }
+ if (finfo.linenos != NULL)
+ {
+ free (finfo.linenos);
+ finfo.linenos = NULL;
+ }
+ if (finfo.contents != NULL)
+ {
+ free (finfo.contents);
+ finfo.contents = NULL;
+ }
+ if (finfo.external_relocs != NULL)
+ {
+ free (finfo.external_relocs);
+ finfo.external_relocs = NULL;
+ }
+
+ /* The value of the last C_FILE symbol is supposed to be -1. Write
+ it out again. */
+ if (finfo.last_file_index != -1)
+ {
+ finfo.last_file.n_value = -1;
+ bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
+ (PTR) finfo.outsyms);
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + finfo.last_file_index * symesz),
+ SEEK_SET) != 0
+ || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
+ goto error_return;
+ }
+
+ /* Write out all the global symbols which do not come from XCOFF
+ input files. */
+ xcoff_link_hash_traverse (xcoff_hash_table (info),
+ xcoff_write_global_symbol,
+ (PTR) &finfo);
+
+ if (finfo.outsyms != NULL)
+ {
+ free (finfo.outsyms);
+ finfo.outsyms = NULL;
+ }
+
+ /* Now that we have written out all the global symbols, we know the
+ symbol indices to use for relocs against them, and we can finally
+ write out the relocs. */
+ external_relocs = (bfd_byte *) bfd_malloc (max_output_reloc_count * relsz);
+ if (external_relocs == NULL && max_output_reloc_count != 0)
+ goto error_return;
+
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct internal_reloc *irel;
+ struct internal_reloc *irelend;
+ struct xcoff_link_hash_entry **rel_hash;
+ struct xcoff_toc_rel_hash *toc_rel_hash;
+ bfd_byte *erel;
+
+ /* A stripped file has no relocs. */
+ if (info->strip == strip_all)
+ {
+ o->reloc_count = 0;
+ continue;
+ }
+
+ if (o->reloc_count == 0)
+ continue;
+
+ irel = finfo.section_info[o->target_index].relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = finfo.section_info[o->target_index].rel_hashes;
+ for (; irel < irelend; irel++, rel_hash++, erel += relsz)
+ {
+ if (*rel_hash != NULL)
+ {
+ if ((*rel_hash)->indx < 0)
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, (*rel_hash)->root.root.string,
+ (bfd *) NULL, o, irel->r_vaddr)))
+ goto error_return;
+ (*rel_hash)->indx = 0;
+ }
+ irel->r_symndx = (*rel_hash)->indx;
+ }
+ }
+
+ for (toc_rel_hash = finfo.section_info[o->target_index].toc_rel_hashes;
+ toc_rel_hash != NULL;
+ toc_rel_hash = toc_rel_hash->next)
+ {
+ if (toc_rel_hash->h->u.toc_indx < 0)
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, toc_rel_hash->h->root.root.string,
+ (bfd *) NULL, o, toc_rel_hash->rel->r_vaddr)))
+ goto error_return;
+ toc_rel_hash->h->u.toc_indx = 0;
+ }
+ toc_rel_hash->rel->r_symndx = toc_rel_hash->h->u.toc_indx;
+ }
+
+ /* XCOFF requires that the relocs be sorted by address. We tend
+ to produce them in the order in which their containing csects
+ appear in the symbol table, which is not necessarily by
+ address. So we sort them here. There may be a better way to
+ do this. */
+ qsort ((PTR) finfo.section_info[o->target_index].relocs,
+ o->reloc_count, sizeof (struct internal_reloc),
+ xcoff_sort_relocs);
+
+ irel = finfo.section_info[o->target_index].relocs;
+ irelend = irel + o->reloc_count;
+ erel = external_relocs;
+ for (; irel < irelend; irel++, rel_hash++, erel += relsz)
+ bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
+
+ if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
+ || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
+ abfd) != relsz * o->reloc_count)
+ goto error_return;
+ }
+
+ if (external_relocs != NULL)
+ {
+ free (external_relocs);
+ external_relocs = NULL;
+ }
+
+ /* Free up the section information. */
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ finfo.section_info = NULL;
+ }
+
+ /* Write out the loader section contents. */
+ BFD_ASSERT ((bfd_byte *) finfo.ldrel
+ == (xcoff_hash_table (info)->loader_section->contents
+ + xcoff_hash_table (info)->ldhdr.l_impoff));
+ o = xcoff_hash_table (info)->loader_section;
+ if (! bfd_set_section_contents (abfd, o->output_section,
+ o->contents, o->output_offset,
+ o->_raw_size))
+ goto error_return;
+
+ /* Write out the magic sections. */
+ o = xcoff_hash_table (info)->linkage_section;
+ if (o->_raw_size > 0
+ && ! bfd_set_section_contents (abfd, o->output_section, o->contents,
+ o->output_offset, o->_raw_size))
+ goto error_return;
+ o = xcoff_hash_table (info)->toc_section;
+ if (o->_raw_size > 0
+ && ! bfd_set_section_contents (abfd, o->output_section, o->contents,
+ o->output_offset, o->_raw_size))
+ goto error_return;
+ o = xcoff_hash_table (info)->descriptor_section;
+ if (o->_raw_size > 0
+ && ! bfd_set_section_contents (abfd, o->output_section, o->contents,
+ o->output_offset, o->_raw_size))
+ goto error_return;
+
+ /* Write out the string table. */
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + obj_raw_syment_count (abfd) * symesz),
+ SEEK_SET) != 0)
+ goto error_return;
+ bfd_h_put_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ (bfd_byte *) strbuf);
+ if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ goto error_return;
+ if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+ goto error_return;
+
+ _bfd_stringtab_free (finfo.strtab);
+
+ /* Write out the debugging string table. */
+ o = xcoff_hash_table (info)->debug_section;
+ if (o != NULL)
+ {
+ struct bfd_strtab_hash *debug_strtab;
+
+ debug_strtab = xcoff_hash_table (info)->debug_strtab;
+ BFD_ASSERT (o->output_section->_raw_size - o->output_offset
+ >= _bfd_stringtab_size (debug_strtab));
+ if (bfd_seek (abfd,
+ o->output_section->filepos + o->output_offset,
+ SEEK_SET) != 0)
+ goto error_return;
+ if (! _bfd_stringtab_emit (abfd, debug_strtab))
+ goto error_return;
+ }
+
+ /* Setting bfd_get_symcount to 0 will cause write_object_contents to
+ not try to write out the symbols. */
+ bfd_get_symcount (abfd) = 0;
+
+ return true;
+
+ error_return:
+ if (finfo.strtab != NULL)
+ _bfd_stringtab_free (finfo.strtab);
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ }
+ if (finfo.internal_syms != NULL)
+ free (finfo.internal_syms);
+ if (finfo.sym_indices != NULL)
+ free (finfo.sym_indices);
+ if (finfo.outsyms != NULL)
+ free (finfo.outsyms);
+ if (finfo.linenos != NULL)
+ free (finfo.linenos);
+ if (finfo.contents != NULL)
+ free (finfo.contents);
+ if (finfo.external_relocs != NULL)
+ free (finfo.external_relocs);
+ if (external_relocs != NULL)
+ free (external_relocs);
+ return false;
+}
+
+/* Link an input file into the linker output file. This function
+ handles all the sections and relocations of the input file at once. */
+
+static boolean
+xcoff_link_input_bfd (finfo, input_bfd)
+ struct xcoff_final_link_info *finfo;
+ bfd *input_bfd;
+{
+ bfd *output_bfd;
+ const char *strings;
+ bfd_size_type syment_base;
+ unsigned int n_tmask;
+ unsigned int n_btshft;
+ boolean copy, hash;
+ bfd_size_type isymesz;
+ bfd_size_type osymesz;
+ bfd_size_type linesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
+ struct xcoff_link_hash_entry **sym_hash;
+ struct internal_syment *isymp;
+ asection **csectpp;
+ unsigned long *debug_index;
+ long *indexp;
+ unsigned long output_index;
+ bfd_byte *outsym;
+ unsigned int incls;
+ asection *oline;
+ boolean keep_syms;
+ asection *o;
+
+ /* We can just skip DYNAMIC files, unless this is a static link. */
+ if ((input_bfd->flags & DYNAMIC) != 0
+ && ! finfo->info->static_link)
+ return true;
+
+ /* Move all the symbols to the output file. */
+
+ output_bfd = finfo->output_bfd;
+ strings = NULL;
+ syment_base = obj_raw_syment_count (output_bfd);
+ isymesz = bfd_coff_symesz (input_bfd);
+ osymesz = bfd_coff_symesz (output_bfd);
+ linesz = bfd_coff_linesz (input_bfd);
+ BFD_ASSERT (linesz == bfd_coff_linesz (output_bfd));
+
+ n_tmask = coff_data (input_bfd)->local_n_tmask;
+ n_btshft = coff_data (input_bfd)->local_n_btshft;
+
+ /* Define macros so that ISFCN, et. al., macros work correctly. */
+#define N_TMASK n_tmask
+#define N_BTSHFT n_btshft
+
+ copy = false;
+ if (! finfo->info->keep_memory)
+ copy = true;
+ hash = true;
+ if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ hash = false;
+
+ if (! _bfd_coff_get_external_symbols (input_bfd))
+ return false;
+
+ esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
+ esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
+ sym_hash = obj_xcoff_sym_hashes (input_bfd);
+ csectpp = xcoff_data (input_bfd)->csects;
+ debug_index = xcoff_data (input_bfd)->debug_indices;
+ isymp = finfo->internal_syms;
+ indexp = finfo->sym_indices;
+ output_index = syment_base;
+ outsym = finfo->outsyms;
+ incls = 0;
+ oline = NULL;
+
+ while (esym < esym_end)
+ {
+ struct internal_syment isym;
+ union internal_auxent aux;
+ int smtyp = 0;
+ boolean skip;
+ boolean require;
+ int add;
+
+ bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
+
+ /* If this is a C_EXT or C_HIDEXT symbol, we need the csect
+ information. */
+ if (isymp->n_sclass == C_EXT || isymp->n_sclass == C_HIDEXT)
+ {
+ BFD_ASSERT (isymp->n_numaux > 0);
+ bfd_coff_swap_aux_in (input_bfd,
+ (PTR) (esym + isymesz * isymp->n_numaux),
+ isymp->n_type, isymp->n_sclass,
+ isymp->n_numaux - 1, isymp->n_numaux,
+ (PTR) &aux);
+ smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp);
+ }
+
+ /* Make a copy of *isymp so that the relocate_section function
+ always sees the original values. This is more reliable than
+ always recomputing the symbol value even if we are stripping
+ the symbol. */
+ isym = *isymp;
+
+ /* If this symbol is in the .loader section, swap out the
+ .loader symbol information. If this is an external symbol
+ reference to a defined symbol, though, then wait until we get
+ to the definition. */
+ if (isym.n_sclass == C_EXT
+ && *sym_hash != NULL
+ && (*sym_hash)->ldsym != NULL
+ && (smtyp != XTY_ER
+ || (*sym_hash)->root.type == bfd_link_hash_undefined))
+ {
+ struct xcoff_link_hash_entry *h;
+ struct internal_ldsym *ldsym;
+
+ h = *sym_hash;
+ ldsym = h->ldsym;
+ if (isym.n_scnum > 0)
+ {
+ ldsym->l_scnum = (*csectpp)->output_section->target_index;
+ ldsym->l_value = (isym.n_value
+ + (*csectpp)->output_section->vma
+ + (*csectpp)->output_offset
+ - (*csectpp)->vma);
+ }
+ else
+ {
+ ldsym->l_scnum = isym.n_scnum;
+ ldsym->l_value = isym.n_value;
+ }
+
+ ldsym->l_smtype = smtyp;
+ if (((h->flags & XCOFF_DEF_REGULAR) == 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
+ || (h->flags & XCOFF_IMPORT) != 0)
+ ldsym->l_smtype |= L_IMPORT;
+ if (((h->flags & XCOFF_DEF_REGULAR) != 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
+ || (h->flags & XCOFF_EXPORT) != 0)
+ ldsym->l_smtype |= L_EXPORT;
+ if ((h->flags & XCOFF_ENTRY) != 0)
+ ldsym->l_smtype |= L_ENTRY;
+
+ ldsym->l_smclas = aux.x_csect.x_smclas;
+
+ if (ldsym->l_ifile == (bfd_size_type) -1)
+ ldsym->l_ifile = 0;
+ else if (ldsym->l_ifile == 0)
+ {
+ if ((ldsym->l_smtype & L_IMPORT) == 0)
+ ldsym->l_ifile = 0;
+ else
+ {
+ bfd *impbfd;
+
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ impbfd = h->root.u.def.section->owner;
+ else if (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ impbfd = h->root.u.undef.abfd;
+ else
+ impbfd = NULL;
+
+ if (impbfd == NULL)
+ ldsym->l_ifile = 0;
+ else
+ {
+ BFD_ASSERT (impbfd->xvec == finfo->output_bfd->xvec);
+ ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
+ }
+ }
+ }
+
+ ldsym->l_parm = 0;
+
+ BFD_ASSERT (h->ldindx >= 0);
+ BFD_ASSERT (LDSYMSZ == sizeof (struct external_ldsym));
+ xcoff_swap_ldsym_out (finfo->output_bfd, ldsym,
+ finfo->ldsym + h->ldindx - 3);
+ h->ldsym = NULL;
+
+ /* Fill in snentry now that we know the target_index. */
+ if ((h->flags & XCOFF_ENTRY) != 0
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ xcoff_data (output_bfd)->snentry =
+ h->root.u.def.section->output_section->target_index;
+ }
+
+ *indexp = -1;
+
+ skip = false;
+ require = false;
+ add = 1 + isym.n_numaux;
+
+ /* If we are skipping this csect, we want to skip this symbol. */
+ if (*csectpp == NULL)
+ skip = true;
+
+ /* If we garbage collected this csect, we want to skip this
+ symbol. */
+ if (! skip
+ && xcoff_hash_table (finfo->info)->gc
+ && ((*csectpp)->flags & SEC_MARK) == 0
+ && *csectpp != bfd_abs_section_ptr)
+ skip = true;
+
+ /* An XCOFF linker always skips C_STAT symbols. */
+ if (! skip
+ && isymp->n_sclass == C_STAT)
+ skip = true;
+
+ /* We skip all but the first TOC anchor. */
+ if (! skip
+ && isymp->n_sclass == C_HIDEXT
+ && aux.x_csect.x_smclas == XMC_TC0)
+ {
+ if (finfo->toc_symindx != -1)
+ skip = true;
+ else
+ {
+ bfd_vma tocval, tocend;
+
+ tocval = ((*csectpp)->output_section->vma
+ + (*csectpp)->output_offset
+ + isym.n_value
+ - (*csectpp)->vma);
+ /* We want to find out if tocval is a good value to use
+ as the TOC anchor--that is, whether we can access all
+ of the TOC using a 16 bit offset from tocval. This
+ test assumes that the TOC comes at the end of the
+ output section, as it does in the default linker
+ script. FIXME: This doesn't handle .tocbss sections
+ created from XMC_TD common symbols correctly. */
+
+ tocend = ((*csectpp)->output_section->vma
+ + (*csectpp)->output_section->_raw_size);
+
+ if (tocval + 0x10000 < tocend)
+ {
+ (*_bfd_error_handler)
+ (_("TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling"),
+ (unsigned long) (tocend - tocval));
+ bfd_set_error (bfd_error_file_too_big);
+ return false;
+ }
+
+ if (tocval + 0x8000 < tocend)
+ {
+ bfd_vma tocadd;
+
+ tocadd = tocend - (tocval + 0x8000);
+ tocval += tocadd;
+ isym.n_value += tocadd;
+ }
+
+ finfo->toc_symindx = output_index;
+ xcoff_data (finfo->output_bfd)->toc = tocval;
+ xcoff_data (finfo->output_bfd)->sntoc =
+ (*csectpp)->output_section->target_index;
+ require = true;
+ }
+ }
+
+ /* If we are stripping all symbols, we want to skip this one. */
+ if (! skip
+ && finfo->info->strip == strip_all)
+ skip = true;
+
+ /* We can skip resolved external references. */
+ if (! skip
+ && isym.n_sclass == C_EXT
+ && smtyp == XTY_ER
+ && (*sym_hash)->root.type != bfd_link_hash_undefined)
+ skip = true;
+
+ /* We can skip common symbols if they got defined somewhere
+ else. */
+ if (! skip
+ && isym.n_sclass == C_EXT
+ && smtyp == XTY_CM
+ && ((*sym_hash)->root.type != bfd_link_hash_common
+ || (*sym_hash)->root.u.c.p->section != *csectpp)
+ && ((*sym_hash)->root.type != bfd_link_hash_defined
+ || (*sym_hash)->root.u.def.section != *csectpp))
+ skip = true;
+
+ /* Skip local symbols if we are discarding them. */
+ if (! skip
+ && finfo->info->discard == discard_all
+ && isym.n_sclass != C_EXT
+ && (isym.n_sclass != C_HIDEXT
+ || smtyp != XTY_SD))
+ skip = true;
+
+ /* If we stripping debugging symbols, and this is a debugging
+ symbol, then skip it. */
+ if (! skip
+ && finfo->info->strip == strip_debugger
+ && isym.n_scnum == N_DEBUG)
+ skip = true;
+
+ /* If some symbols are stripped based on the name, work out the
+ name and decide whether to skip this symbol. We don't handle
+ this correctly for symbols whose names are in the .debug
+ section; to get it right we would need a new bfd_strtab_hash
+ function to return the string given the index. */
+ if (! skip
+ && (finfo->info->strip == strip_some
+ || finfo->info->discard == discard_l)
+ && (debug_index == NULL || *debug_index == (unsigned long) -1))
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
+ if (name == NULL)
+ return false;
+
+ if ((finfo->info->strip == strip_some
+ && (bfd_hash_lookup (finfo->info->keep_hash, name, false,
+ false) == NULL))
+ || (finfo->info->discard == discard_l
+ && (isym.n_sclass != C_EXT
+ && (isym.n_sclass != C_HIDEXT
+ || smtyp != XTY_SD))
+ && bfd_is_local_label_name (input_bfd, name)))
+ skip = true;
+ }
+
+ /* We can not skip the first TOC anchor. */
+ if (skip
+ && require
+ && finfo->info->strip != strip_all)
+ skip = false;
+
+ /* We now know whether we are to skip this symbol or not. */
+ if (! skip)
+ {
+ /* Adjust the symbol in order to output it. */
+
+ if (isym._n._n_n._n_zeroes == 0
+ && isym._n._n_n._n_offset != 0)
+ {
+ /* This symbol has a long name. Enter it in the string
+ table we are building. If *debug_index != -1, the
+ name has already been entered in the .debug section. */
+ if (debug_index != NULL && *debug_index != (unsigned long) -1)
+ isym._n._n_n._n_offset = *debug_index;
+ else
+ {
+ const char *name;
+ bfd_size_type indx;
+
+ name = _bfd_coff_internal_syment_name (input_bfd, &isym,
+ (char *) NULL);
+ if (name == NULL)
+ return false;
+ indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
+ }
+ }
+
+ if (isym.n_sclass != C_BSTAT
+ && isym.n_sclass != C_ESTAT
+ && isym.n_sclass != C_DECL
+ && isym.n_scnum > 0)
+ {
+ isym.n_scnum = (*csectpp)->output_section->target_index;
+ isym.n_value += ((*csectpp)->output_section->vma
+ + (*csectpp)->output_offset
+ - (*csectpp)->vma);
+ }
+
+ /* The value of a C_FILE symbol is the symbol index of the
+ next C_FILE symbol. The value of the last C_FILE symbol
+ is -1. We try to get this right, below, just before we
+ write the symbols out, but in the general case we may
+ have to write the symbol out twice. */
+ if (isym.n_sclass == C_FILE)
+ {
+ if (finfo->last_file_index != -1
+ && finfo->last_file.n_value != (long) output_index)
+ {
+ /* We must correct the value of the last C_FILE entry. */
+ finfo->last_file.n_value = output_index;
+ if ((bfd_size_type) finfo->last_file_index >= syment_base)
+ {
+ /* The last C_FILE symbol is in this input file. */
+ bfd_coff_swap_sym_out (output_bfd,
+ (PTR) &finfo->last_file,
+ (PTR) (finfo->outsyms
+ + ((finfo->last_file_index
+ - syment_base)
+ * osymesz)));
+ }
+ else
+ {
+ /* We have already written out the last C_FILE
+ symbol. We need to write it out again. We
+ borrow *outsym temporarily. */
+ bfd_coff_swap_sym_out (output_bfd,
+ (PTR) &finfo->last_file,
+ (PTR) outsym);
+ if (bfd_seek (output_bfd,
+ (obj_sym_filepos (output_bfd)
+ + finfo->last_file_index * osymesz),
+ SEEK_SET) != 0
+ || (bfd_write (outsym, osymesz, 1, output_bfd)
+ != osymesz))
+ return false;
+ }
+ }
+
+ finfo->last_file_index = output_index;
+ finfo->last_file = isym;
+ }
+
+ /* The value of a C_BINCL or C_EINCL symbol is a file offset
+ into the line numbers. We update the symbol values when
+ we handle the line numbers. */
+ if (isym.n_sclass == C_BINCL
+ || isym.n_sclass == C_EINCL)
+ {
+ isym.n_value = finfo->line_filepos;
+ ++incls;
+ }
+
+ /* Output the symbol. */
+
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
+
+ *indexp = output_index;
+
+ if (isym.n_sclass == C_EXT)
+ {
+ long indx;
+ struct xcoff_link_hash_entry *h;
+
+ indx = ((esym - (bfd_byte *) obj_coff_external_syms (input_bfd))
+ / isymesz);
+ h = obj_xcoff_sym_hashes (input_bfd)[indx];
+ BFD_ASSERT (h != NULL);
+ h->indx = output_index;
+ }
+
+ /* If this is a symbol in the TOC which we may have merged
+ (class XMC_TC), remember the symbol index of the TOC
+ symbol. */
+ if (isym.n_sclass == C_HIDEXT
+ && aux.x_csect.x_smclas == XMC_TC
+ && *sym_hash != NULL)
+ {
+ BFD_ASSERT (((*sym_hash)->flags & XCOFF_SET_TOC) == 0);
+ BFD_ASSERT ((*sym_hash)->toc_section != NULL);
+ (*sym_hash)->u.toc_indx = output_index;
+ }
+
+ output_index += add;
+ outsym += add * osymesz;
+ }
+
+ esym += add * isymesz;
+ isymp += add;
+ csectpp += add;
+ sym_hash += add;
+ if (debug_index != NULL)
+ debug_index += add;
+ ++indexp;
+ for (--add; add > 0; --add)
+ *indexp++ = -1;
+ }
+
+ /* Fix up the aux entries and the C_BSTAT symbols. This must be
+ done in a separate pass, because we don't know the correct symbol
+ indices until we have already decided which symbols we are going
+ to keep. */
+
+ esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
+ esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
+ isymp = finfo->internal_syms;
+ indexp = finfo->sym_indices;
+ csectpp = xcoff_data (input_bfd)->csects;
+ outsym = finfo->outsyms;
+ while (esym < esym_end)
+ {
+ int add;
+
+ add = 1 + isymp->n_numaux;
+
+ if (*indexp < 0)
+ esym += add * isymesz;
+ else
+ {
+ int i;
+
+ if (isymp->n_sclass == C_BSTAT)
+ {
+ struct internal_syment isym;
+ unsigned long indx;
+
+ /* The value of a C_BSTAT symbol is the symbol table
+ index of the containing csect. */
+ bfd_coff_swap_sym_in (output_bfd, (PTR) outsym, (PTR) &isym);
+ indx = isym.n_value;
+ if (indx < obj_raw_syment_count (input_bfd))
+ {
+ long symindx;
+
+ symindx = finfo->sym_indices[indx];
+ if (symindx < 0)
+ isym.n_value = 0;
+ else
+ isym.n_value = symindx;
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &isym,
+ (PTR) outsym);
+ }
+ }
+
+ esym += isymesz;
+ outsym += osymesz;
+
+ for (i = 0; i < isymp->n_numaux && esym < esym_end; i++)
+ {
+ union internal_auxent aux;
+
+ bfd_coff_swap_aux_in (input_bfd, (PTR) esym, isymp->n_type,
+ isymp->n_sclass, i, isymp->n_numaux,
+ (PTR) &aux);
+
+ if (isymp->n_sclass == C_FILE)
+ {
+ /* This is the file name (or some comment put in by
+ the compiler). If it is long, we must put it in
+ the string table. */
+ if (aux.x_file.x_n.x_zeroes == 0
+ && aux.x_file.x_n.x_offset != 0)
+ {
+ const char *filename;
+ bfd_size_type indx;
+
+ BFD_ASSERT (aux.x_file.x_n.x_offset
+ >= STRING_SIZE_SIZE);
+ if (strings == NULL)
+ {
+ strings = _bfd_coff_read_string_table (input_bfd);
+ if (strings == NULL)
+ return false;
+ }
+ filename = strings + aux.x_file.x_n.x_offset;
+ indx = _bfd_stringtab_add (finfo->strtab, filename,
+ hash, copy);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ aux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+ }
+ }
+ else if ((isymp->n_sclass == C_EXT
+ || isymp->n_sclass == C_HIDEXT)
+ && i + 1 == isymp->n_numaux)
+ {
+ /* We don't support type checking. I don't know if
+ anybody does. */
+ aux.x_csect.x_parmhash = 0;
+ /* I don't think anybody uses these fields, but we'd
+ better clobber them just in case. */
+ aux.x_csect.x_stab = 0;
+ aux.x_csect.x_snstab = 0;
+ if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_LD)
+ {
+ unsigned long indx;
+
+ indx = aux.x_csect.x_scnlen.l;
+ if (indx < obj_raw_syment_count (input_bfd))
+ {
+ long symindx;
+
+ symindx = finfo->sym_indices[indx];
+ if (symindx < 0)
+ aux.x_sym.x_tagndx.l = 0;
+ else
+ aux.x_sym.x_tagndx.l = symindx;
+ }
+ }
+ }
+ else if (isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
+ {
+ unsigned long indx;
+
+ if (ISFCN (isymp->n_type)
+ || ISTAG (isymp->n_sclass)
+ || isymp->n_sclass == C_BLOCK
+ || isymp->n_sclass == C_FCN)
+ {
+ indx = aux.x_sym.x_fcnary.x_fcn.x_endndx.l;
+ if (indx > 0
+ && indx < obj_raw_syment_count (input_bfd))
+ {
+ /* We look forward through the symbol for
+ the index of the next symbol we are going
+ to include. I don't know if this is
+ entirely right. */
+ while (finfo->sym_indices[indx] < 0
+ && indx < obj_raw_syment_count (input_bfd))
+ ++indx;
+ if (indx >= obj_raw_syment_count (input_bfd))
+ indx = output_index;
+ else
+ indx = finfo->sym_indices[indx];
+ aux.x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
+ }
+ }
+
+ indx = aux.x_sym.x_tagndx.l;
+ if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
+ {
+ long symindx;
+
+ symindx = finfo->sym_indices[indx];
+ if (symindx < 0)
+ aux.x_sym.x_tagndx.l = 0;
+ else
+ aux.x_sym.x_tagndx.l = symindx;
+ }
+ }
+
+ /* Copy over the line numbers, unless we are stripping
+ them. We do this on a symbol by symbol basis in
+ order to more easily handle garbage collection. */
+ if ((isymp->n_sclass == C_EXT
+ || isymp->n_sclass == C_HIDEXT)
+ && i == 0
+ && isymp->n_numaux > 1
+ && ISFCN (isymp->n_type)
+ && aux.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
+ {
+ if (finfo->info->strip != strip_none
+ && finfo->info->strip != strip_some)
+ aux.x_sym.x_fcnary.x_fcn.x_lnnoptr = 0;
+ else
+ {
+ asection *enclosing;
+ unsigned int enc_count;
+ bfd_size_type linoff;
+ struct internal_lineno lin;
+
+ o = *csectpp;
+ enclosing = xcoff_section_data (abfd, o)->enclosing;
+ enc_count = xcoff_section_data (abfd, o)->lineno_count;
+ if (oline != enclosing)
+ {
+ if (bfd_seek (input_bfd,
+ enclosing->line_filepos,
+ SEEK_SET) != 0
+ || (bfd_read (finfo->linenos, linesz,
+ enc_count, input_bfd)
+ != linesz * enc_count))
+ return false;
+ oline = enclosing;
+ }
+
+ linoff = (aux.x_sym.x_fcnary.x_fcn.x_lnnoptr
+ - enclosing->line_filepos);
+
+ bfd_coff_swap_lineno_in (input_bfd,
+ (PTR) (finfo->linenos + linoff),
+ (PTR) &lin);
+ if (lin.l_lnno != 0
+ || ((bfd_size_type) lin.l_addr.l_symndx
+ != ((esym
+ - isymesz
+ - ((bfd_byte *)
+ obj_coff_external_syms (input_bfd)))
+ / isymesz)))
+ aux.x_sym.x_fcnary.x_fcn.x_lnnoptr = 0;
+ else
+ {
+ bfd_byte *linpend, *linp;
+ bfd_vma offset;
+ bfd_size_type count;
+
+ lin.l_addr.l_symndx = *indexp;
+ bfd_coff_swap_lineno_out (output_bfd, (PTR) &lin,
+ (PTR) (finfo->linenos
+ + linoff));
+
+ linpend = (finfo->linenos
+ + enc_count * linesz);
+ offset = (o->output_section->vma
+ + o->output_offset
+ - o->vma);
+ for (linp = finfo->linenos + linoff + linesz;
+ linp < linpend;
+ linp += linesz)
+ {
+ bfd_coff_swap_lineno_in (input_bfd, (PTR) linp,
+ (PTR) &lin);
+ if (lin.l_lnno == 0)
+ break;
+ lin.l_addr.l_paddr += offset;
+ bfd_coff_swap_lineno_out (output_bfd,
+ (PTR) &lin,
+ (PTR) linp);
+ }
+
+ count = (linp - (finfo->linenos + linoff)) / linesz;
+
+ aux.x_sym.x_fcnary.x_fcn.x_lnnoptr =
+ (o->output_section->line_filepos
+ + o->output_section->lineno_count * linesz);
+
+ if (bfd_seek (output_bfd,
+ aux.x_sym.x_fcnary.x_fcn.x_lnnoptr,
+ SEEK_SET) != 0
+ || (bfd_write (finfo->linenos + linoff,
+ linesz, count, output_bfd)
+ != linesz * count))
+ return false;
+
+ o->output_section->lineno_count += count;
+
+ if (incls > 0)
+ {
+ struct internal_syment *iisp, *iispend;
+ long *iindp;
+ bfd_byte *oos;
+ int iiadd;
+
+ /* Update any C_BINCL or C_EINCL symbols
+ that refer to a line number in the
+ range we just output. */
+ iisp = finfo->internal_syms;
+ iispend = (iisp
+ + obj_raw_syment_count (input_bfd));
+ iindp = finfo->sym_indices;
+ oos = finfo->outsyms;
+ while (iisp < iispend)
+ {
+ if (*iindp >= 0
+ && (iisp->n_sclass == C_BINCL
+ || iisp->n_sclass == C_EINCL)
+ && ((bfd_size_type) iisp->n_value
+ >= enclosing->line_filepos + linoff)
+ && ((bfd_size_type) iisp->n_value
+ < (enclosing->line_filepos
+ + enc_count * linesz)))
+ {
+ struct internal_syment iis;
+
+ bfd_coff_swap_sym_in (output_bfd,
+ (PTR) oos,
+ (PTR) &iis);
+ iis.n_value =
+ (iisp->n_value
+ - enclosing->line_filepos
+ - linoff
+ + aux.x_sym.x_fcnary.x_fcn.x_lnnoptr);
+ bfd_coff_swap_sym_out (output_bfd,
+ (PTR) &iis,
+ (PTR) oos);
+ --incls;
+ }
+
+ iiadd = 1 + iisp->n_numaux;
+ if (*iindp >= 0)
+ oos += iiadd * osymesz;
+ iisp += iiadd;
+ iindp += iiadd;
+ }
+ }
+ }
+ }
+ }
+
+ bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, isymp->n_type,
+ isymp->n_sclass, i, isymp->n_numaux,
+ (PTR) outsym);
+ outsym += osymesz;
+ esym += isymesz;
+ }
+ }
+
+ indexp += add;
+ isymp += add;
+ csectpp += add;
+ }
+
+ /* If we swapped out a C_FILE symbol, guess that the next C_FILE
+ symbol will be the first symbol in the next input file. In the
+ normal case, this will save us from writing out the C_FILE symbol
+ again. */
+ if (finfo->last_file_index != -1
+ && (bfd_size_type) finfo->last_file_index >= syment_base)
+ {
+ finfo->last_file.n_value = output_index;
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &finfo->last_file,
+ (PTR) (finfo->outsyms
+ + ((finfo->last_file_index - syment_base)
+ * osymesz)));
+ }
+
+ /* Write the modified symbols to the output file. */
+ if (outsym > finfo->outsyms)
+ {
+ if (bfd_seek (output_bfd,
+ obj_sym_filepos (output_bfd) + syment_base * osymesz,
+ SEEK_SET) != 0
+ || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
+ output_bfd)
+ != (bfd_size_type) (outsym - finfo->outsyms)))
+ return false;
+
+ BFD_ASSERT ((obj_raw_syment_count (output_bfd)
+ + (outsym - finfo->outsyms) / osymesz)
+ == output_index);
+
+ obj_raw_syment_count (output_bfd) = output_index;
+ }
+
+ /* Don't let the linker relocation routines discard the symbols. */
+ keep_syms = obj_coff_keep_syms (input_bfd);
+ obj_coff_keep_syms (input_bfd) = true;
+
+ /* Relocate the contents of each section. */
+ for (o = input_bfd->sections; o != NULL; o = o->next)
+ {
+ bfd_byte *contents;
+
+ if (! o->linker_mark)
+ {
+ /* This section was omitted from the link. */
+ continue;
+ }
+
+ if ((o->flags & SEC_HAS_CONTENTS) == 0
+ || o->_raw_size == 0
+ || (o->flags & SEC_IN_MEMORY) != 0)
+ continue;
+
+ /* We have set filepos correctly for the sections we created to
+ represent csects, so bfd_get_section_contents should work. */
+ if (coff_section_data (input_bfd, o) != NULL
+ && coff_section_data (input_bfd, o)->contents != NULL)
+ contents = coff_section_data (input_bfd, o)->contents;
+ else
+ {
+ if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
+ (file_ptr) 0, o->_raw_size))
+ return false;
+ contents = finfo->contents;
+ }
+
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ int target_index;
+ struct internal_reloc *internal_relocs;
+ struct internal_reloc *irel;
+ bfd_vma offset;
+ struct internal_reloc *irelend;
+ struct xcoff_link_hash_entry **rel_hash;
+ long r_symndx;
+
+ /* Read in the relocs. */
+ target_index = o->output_section->target_index;
+ internal_relocs = (xcoff_read_internal_relocs
+ (input_bfd, o, false, finfo->external_relocs,
+ true,
+ (finfo->section_info[target_index].relocs
+ + o->output_section->reloc_count)));
+ if (internal_relocs == NULL)
+ return false;
+
+ /* Call processor specific code to relocate the section
+ contents. */
+ if (! bfd_coff_relocate_section (output_bfd, finfo->info,
+ input_bfd, o,
+ contents,
+ internal_relocs,
+ finfo->internal_syms,
+ xcoff_data (input_bfd)->csects))
+ return false;
+
+ offset = o->output_section->vma + o->output_offset - o->vma;
+ irel = internal_relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = (finfo->section_info[target_index].rel_hashes
+ + o->output_section->reloc_count);
+ for (; irel < irelend; irel++, rel_hash++)
+ {
+ struct xcoff_link_hash_entry *h = NULL;
+ struct internal_ldrel ldrel;
+ boolean quiet;
+
+ *rel_hash = NULL;
+
+ /* Adjust the reloc address and symbol index. */
+
+ irel->r_vaddr += offset;
+
+ r_symndx = irel->r_symndx;
+
+ if (r_symndx == -1)
+ h = NULL;
+ else
+ h = obj_xcoff_sym_hashes (input_bfd)[r_symndx];
+
+ if (r_symndx != -1 && finfo->info->strip != strip_all)
+ {
+ if (h != NULL
+ && h->smclas != XMC_TD
+ && (irel->r_type == R_TOC
+ || irel->r_type == R_GL
+ || irel->r_type == R_TCL
+ || irel->r_type == R_TRL
+ || irel->r_type == R_TRLA))
+ {
+ /* This is a TOC relative reloc with a symbol
+ attached. The symbol should be the one which
+ this reloc is for. We want to make this
+ reloc against the TOC address of the symbol,
+ not the symbol itself. */
+ BFD_ASSERT (h->toc_section != NULL);
+ BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
+ if (h->u.toc_indx != -1)
+ irel->r_symndx = h->u.toc_indx;
+ else
+ {
+ struct xcoff_toc_rel_hash *n;
+ struct xcoff_link_section_info *si;
+
+ n = ((struct xcoff_toc_rel_hash *)
+ bfd_alloc (finfo->output_bfd,
+ sizeof (struct xcoff_toc_rel_hash)));
+ if (n == NULL)
+ return false;
+ si = finfo->section_info + target_index;
+ n->next = si->toc_rel_hashes;
+ n->h = h;
+ n->rel = irel;
+ si->toc_rel_hashes = n;
+ }
+ }
+ else if (h != NULL)
+ {
+ /* This is a global symbol. */
+ if (h->indx >= 0)
+ irel->r_symndx = h->indx;
+ else
+ {
+ /* This symbol is being written at the end
+ of the file, and we do not yet know the
+ symbol index. We save the pointer to the
+ hash table entry in the rel_hash list.
+ We set the indx field to -2 to indicate
+ that this symbol must not be stripped. */
+ *rel_hash = h;
+ h->indx = -2;
+ }
+ }
+ else
+ {
+ long indx;
+
+ indx = finfo->sym_indices[r_symndx];
+
+ if (indx == -1)
+ {
+ struct internal_syment *is;
+
+ /* Relocations against a TC0 TOC anchor are
+ automatically transformed to be against
+ the TOC anchor in the output file. */
+ is = finfo->internal_syms + r_symndx;
+ if (is->n_sclass == C_HIDEXT
+ && is->n_numaux > 0)
+ {
+ PTR auxptr;
+ union internal_auxent aux;
+
+ auxptr = ((PTR)
+ (((bfd_byte *)
+ obj_coff_external_syms (input_bfd))
+ + ((r_symndx + is->n_numaux)
+ * isymesz)));
+ bfd_coff_swap_aux_in (input_bfd, auxptr,
+ is->n_type, is->n_sclass,
+ is->n_numaux - 1,
+ is->n_numaux,
+ (PTR) &aux);
+ if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_SD
+ && aux.x_csect.x_smclas == XMC_TC0)
+ indx = finfo->toc_symindx;
+ }
+ }
+
+ if (indx != -1)
+ irel->r_symndx = indx;
+ else
+ {
+ struct internal_syment *is;
+ const char *name;
+ char buf[SYMNMLEN + 1];
+
+ /* This reloc is against a symbol we are
+ stripping. It would be possible to handle
+ this case, but I don't think it's worth it. */
+ is = finfo->internal_syms + r_symndx;
+
+ name = (_bfd_coff_internal_syment_name
+ (input_bfd, is, buf));
+ if (name == NULL)
+ return false;
+
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, o,
+ irel->r_vaddr)))
+ return false;
+ }
+ }
+ }
+
+ quiet = false;
+ switch (irel->r_type)
+ {
+ default:
+ if (h == NULL
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_common)
+ break;
+ /* Fall through. */
+ case R_POS:
+ case R_NEG:
+ case R_RL:
+ case R_RLA:
+ /* This reloc needs to be copied into the .loader
+ section. */
+ ldrel.l_vaddr = irel->r_vaddr;
+ if (r_symndx == -1)
+ ldrel.l_symndx = -1;
+ else if (h == NULL
+ || (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_common))
+ {
+ asection *sec;
+
+ if (h == NULL)
+ sec = xcoff_data (input_bfd)->csects[r_symndx];
+ else if (h->root.type == bfd_link_hash_common)
+ sec = h->root.u.c.p->section;
+ else
+ sec = h->root.u.def.section;
+ sec = sec->output_section;
+
+ if (strcmp (sec->name, ".text") == 0)
+ ldrel.l_symndx = 0;
+ else if (strcmp (sec->name, ".data") == 0)
+ ldrel.l_symndx = 1;
+ else if (strcmp (sec->name, ".bss") == 0)
+ ldrel.l_symndx = 2;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in unrecognized section `%s'"),
+ bfd_get_filename (input_bfd),
+ sec->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ }
+ else
+ {
+ if (! finfo->info->relocateable
+ && (h->flags & XCOFF_DEF_DYNAMIC) == 0
+ && (h->flags & XCOFF_IMPORT) == 0)
+ {
+ /* We already called the undefined_symbol
+ callback for this relocation, in
+ _bfd_ppc_xcoff_relocate_section. Don't
+ issue any more warnings. */
+ quiet = true;
+ }
+ if (h->ldindx < 0 && ! quiet)
+ {
+ (*_bfd_error_handler)
+ (_("%s: `%s' in loader reloc but not loader sym"),
+ bfd_get_filename (input_bfd),
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ ldrel.l_symndx = h->ldindx;
+ }
+ ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
+ ldrel.l_rsecnm = o->output_section->target_index;
+ if (xcoff_hash_table (finfo->info)->textro
+ && strcmp (o->output_section->name, ".text") == 0
+ && ! quiet)
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in read-only section %s"),
+ bfd_get_filename (input_bfd),
+ bfd_get_section_name (finfo->output_bfd,
+ o->output_section));
+ bfd_set_error (bfd_error_invalid_operation);
+ return false;
+ }
+ xcoff_swap_ldrel_out (output_bfd, &ldrel,
+ finfo->ldrel);
+ BFD_ASSERT (sizeof (struct external_ldrel) == LDRELSZ);
+ ++finfo->ldrel;
+ break;
+
+ case R_TOC:
+ case R_GL:
+ case R_TCL:
+ case R_TRL:
+ case R_TRLA:
+ /* We should never need a .loader reloc for a TOC
+ relative reloc. */
+ break;
+ }
+ }
+
+ o->output_section->reloc_count += o->reloc_count;
+ }
+
+ /* Write out the modified section contents. */
+ if (! bfd_set_section_contents (output_bfd, o->output_section,
+ contents, o->output_offset,
+ (o->_cooked_size != 0
+ ? o->_cooked_size
+ : o->_raw_size)))
+ return false;
+ }
+
+ obj_coff_keep_syms (input_bfd) = keep_syms;
+
+ if (! finfo->info->keep_memory)
+ {
+ if (! _bfd_coff_free_symbols (input_bfd))
+ return false;
+ }
+
+ return true;
+}
+
+#undef N_TMASK
+#undef N_BTSHFT
+
+/* Write out a non-XCOFF global symbol. */
+
+static boolean
+xcoff_write_global_symbol (h, p)
+ struct xcoff_link_hash_entry *h;
+ PTR p;
+{
+ struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) p;
+ bfd *output_bfd;
+ bfd_byte *outsym;
+ struct internal_syment isym;
+ union internal_auxent aux;
+
+ output_bfd = finfo->output_bfd;
+ outsym = finfo->outsyms;
+
+ /* If this symbol was garbage collected, just skip it. */
+ if (xcoff_hash_table (finfo->info)->gc
+ && (h->flags & XCOFF_MARK) == 0)
+ return true;
+
+ /* If we need a .loader section entry, write it out. */
+ if (h->ldsym != NULL)
+ {
+ struct internal_ldsym *ldsym;
+ bfd *impbfd;
+
+ ldsym = h->ldsym;
+
+ if (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ {
+ ldsym->l_value = 0;
+ ldsym->l_scnum = N_UNDEF;
+ ldsym->l_smtype = XTY_ER;
+ impbfd = h->root.u.undef.abfd;
+ }
+ else if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ ldsym->l_value = (sec->output_section->vma
+ + sec->output_offset
+ + h->root.u.def.value);
+ ldsym->l_scnum = sec->output_section->target_index;
+ ldsym->l_smtype = XTY_SD;
+ impbfd = sec->owner;
+ }
+ else
+ abort ();
+
+ if (((h->flags & XCOFF_DEF_REGULAR) == 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
+ || (h->flags & XCOFF_IMPORT) != 0)
+ ldsym->l_smtype |= L_IMPORT;
+ if (((h->flags & XCOFF_DEF_REGULAR) != 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
+ || (h->flags & XCOFF_EXPORT) != 0)
+ ldsym->l_smtype |= L_EXPORT;
+ if ((h->flags & XCOFF_ENTRY) != 0)
+ ldsym->l_smtype |= L_ENTRY;
+
+ ldsym->l_smclas = h->smclas;
+
+ if (ldsym->l_ifile == (bfd_size_type) -1)
+ ldsym->l_ifile = 0;
+ else if (ldsym->l_ifile == 0)
+ {
+ if ((ldsym->l_smtype & L_IMPORT) == 0)
+ ldsym->l_ifile = 0;
+ else if (impbfd == NULL)
+ ldsym->l_ifile = 0;
+ else
+ {
+ BFD_ASSERT (impbfd->xvec == output_bfd->xvec);
+ ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
+ }
+ }
+
+ ldsym->l_parm = 0;
+
+ BFD_ASSERT (h->ldindx >= 0);
+ BFD_ASSERT (LDSYMSZ == sizeof (struct external_ldsym));
+ xcoff_swap_ldsym_out (output_bfd, ldsym, finfo->ldsym + h->ldindx - 3);
+ h->ldsym = NULL;
+ }
+
+ /* If this symbol needs global linkage code, write it out. */
+ if (h->root.type == bfd_link_hash_defined
+ && (h->root.u.def.section
+ == xcoff_hash_table (finfo->info)->linkage_section))
+ {
+ bfd_byte *p;
+ bfd_vma tocoff;
+ unsigned int i;
+
+ p = h->root.u.def.section->contents + h->root.u.def.value;
+
+ /* The first instruction in the global linkage code loads a
+ specific TOC element. */
+ tocoff = (h->descriptor->toc_section->output_section->vma
+ + h->descriptor->toc_section->output_offset
+ - xcoff_data (output_bfd)->toc);
+ if ((h->descriptor->flags & XCOFF_SET_TOC) != 0)
+ tocoff += h->descriptor->u.toc_offset;
+ bfd_put_32 (output_bfd, XCOFF_GLINK_FIRST | (tocoff & 0xffff), p);
+ for (i = 0, p += 4;
+ i < sizeof xcoff_glink_code / sizeof xcoff_glink_code[0];
+ i++, p += 4)
+ bfd_put_32 (output_bfd, xcoff_glink_code[i], p);
+ }
+
+ /* If we created a TOC entry for this symbol, write out the required
+ relocs. */
+ if ((h->flags & XCOFF_SET_TOC) != 0)
+ {
+ asection *tocsec;
+ asection *osec;
+ int oindx;
+ struct internal_reloc *irel;
+ struct internal_ldrel ldrel;
+ struct internal_syment irsym;
+ union internal_auxent iraux;
+
+ tocsec = h->toc_section;
+ osec = tocsec->output_section;
+ oindx = osec->target_index;
+ irel = finfo->section_info[oindx].relocs + osec->reloc_count;
+ irel->r_vaddr = (osec->vma
+ + tocsec->output_offset
+ + h->u.toc_offset);
+ if (h->indx >= 0)
+ irel->r_symndx = h->indx;
+ else
+ {
+ h->indx = -2;
+ irel->r_symndx = obj_raw_syment_count (output_bfd);
+ }
+ irel->r_type = R_POS;
+ irel->r_size = 31;
+ finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
+ ++osec->reloc_count;
+
+ BFD_ASSERT (h->ldindx >= 0);
+ ldrel.l_vaddr = irel->r_vaddr;
+ ldrel.l_symndx = h->ldindx;
+ ldrel.l_rtype = (31 << 8) | R_POS;
+ ldrel.l_rsecnm = oindx;
+ xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
+ ++finfo->ldrel;
+
+ /* We need to emit a symbol to define a csect which holds the
+ reloc. */
+ if (finfo->info->strip != strip_all)
+ {
+ if (strlen (h->root.root.string) <= SYMNMLEN)
+ strncpy (irsym._n._n_name, h->root.root.string, SYMNMLEN);
+ else
+ {
+ boolean hash;
+ bfd_size_type indx;
+
+ hash = true;
+ if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ hash = false;
+ indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string,
+ hash, false);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ irsym._n._n_n._n_zeroes = 0;
+ irsym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
+ }
+
+ irsym.n_value = irel->r_vaddr;
+ irsym.n_scnum = osec->target_index;
+ irsym.n_sclass = C_HIDEXT;
+ irsym.n_type = T_NULL;
+ irsym.n_numaux = 1;
+
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &irsym, (PTR) outsym);
+ outsym += bfd_coff_symesz (output_bfd);
+
+ memset (&iraux, 0, sizeof iraux);
+ iraux.x_csect.x_smtyp = XTY_SD;
+ iraux.x_csect.x_scnlen.l = 4;
+ iraux.x_csect.x_smclas = XMC_TC;
+
+ bfd_coff_swap_aux_out (output_bfd, (PTR) &iraux, T_NULL, C_HIDEXT,
+ 0, 1, (PTR) outsym);
+ outsym += bfd_coff_auxesz (output_bfd);
+
+ if (h->indx >= 0)
+ {
+ /* We aren't going to write out the symbols below, so we
+ need to write them out now. */
+ if (bfd_seek (output_bfd,
+ (obj_sym_filepos (output_bfd)
+ + (obj_raw_syment_count (output_bfd)
+ * bfd_coff_symesz (output_bfd))),
+ SEEK_SET) != 0
+ || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
+ output_bfd)
+ != (bfd_size_type) (outsym - finfo->outsyms)))
+ return false;
+ obj_raw_syment_count (output_bfd) +=
+ (outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);
+
+ outsym = finfo->outsyms;
+ }
+ }
+ }
+
+ /* If this symbol is a specially defined function descriptor, write
+ it out. The first word is the address of the function code
+ itself, the second word is the address of the TOC, and the third
+ word is zero. */
+ if ((h->flags & XCOFF_DESCRIPTOR) != 0
+ && h->root.type == bfd_link_hash_defined
+ && (h->root.u.def.section
+ == xcoff_hash_table (finfo->info)->descriptor_section))
+ {
+ asection *sec;
+ asection *osec;
+ int oindx;
+ bfd_byte *p;
+ struct xcoff_link_hash_entry *hentry;
+ asection *esec;
+ struct internal_reloc *irel;
+ struct internal_ldrel ldrel;
+ asection *tsec;
+
+ sec = h->root.u.def.section;
+ osec = sec->output_section;
+ oindx = osec->target_index;
+ p = sec->contents + h->root.u.def.value;
+
+ hentry = h->descriptor;
+ BFD_ASSERT (hentry != NULL
+ && (hentry->root.type == bfd_link_hash_defined
+ || hentry->root.type == bfd_link_hash_defweak));
+ esec = hentry->root.u.def.section;
+ bfd_put_32 (output_bfd,
+ (esec->output_section->vma
+ + esec->output_offset
+ + hentry->root.u.def.value),
+ p);
+
+ irel = finfo->section_info[oindx].relocs + osec->reloc_count;
+ irel->r_vaddr = (osec->vma
+ + sec->output_offset
+ + h->root.u.def.value);
+ irel->r_symndx = esec->output_section->target_index;
+ irel->r_type = R_POS;
+ irel->r_size = 31;
+ finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
+ ++osec->reloc_count;
+
+ ldrel.l_vaddr = irel->r_vaddr;
+ if (strcmp (esec->output_section->name, ".text") == 0)
+ ldrel.l_symndx = 0;
+ else if (strcmp (esec->output_section->name, ".data") == 0)
+ ldrel.l_symndx = 1;
+ else if (strcmp (esec->output_section->name, ".bss") == 0)
+ ldrel.l_symndx = 2;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in unrecognized section `%s'"),
+ bfd_get_filename (output_bfd),
+ esec->output_section->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ ldrel.l_rtype = (31 << 8) | R_POS;
+ ldrel.l_rsecnm = oindx;
+ xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
+ ++finfo->ldrel;
+
+ bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4);
+
+ tsec = coff_section_from_bfd_index (output_bfd,
+ xcoff_data (output_bfd)->sntoc);
+
+ ++irel;
+ irel->r_vaddr = (osec->vma
+ + sec->output_offset
+ + h->root.u.def.value
+ + 4);
+ irel->r_symndx = tsec->output_section->target_index;
+ irel->r_type = R_POS;
+ irel->r_size = 31;
+ finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
+ ++osec->reloc_count;
+
+ ldrel.l_vaddr = irel->r_vaddr;
+ if (strcmp (tsec->output_section->name, ".text") == 0)
+ ldrel.l_symndx = 0;
+ else if (strcmp (tsec->output_section->name, ".data") == 0)
+ ldrel.l_symndx = 1;
+ else if (strcmp (tsec->output_section->name, ".bss") == 0)
+ ldrel.l_symndx = 2;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in unrecognized section `%s'"),
+ bfd_get_filename (output_bfd),
+ tsec->output_section->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ ldrel.l_rtype = (31 << 8) | R_POS;
+ ldrel.l_rsecnm = oindx;
+ xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
+ ++finfo->ldrel;
+ }
+
+ if (h->indx >= 0 || finfo->info->strip == strip_all)
+ {
+ BFD_ASSERT (outsym == finfo->outsyms);
+ return true;
+ }
+
+ if (h->indx != -2
+ && (finfo->info->strip == strip_all
+ || (finfo->info->strip == strip_some
+ && (bfd_hash_lookup (finfo->info->keep_hash,
+ h->root.root.string, false, false)
+ == NULL))))
+ {
+ BFD_ASSERT (outsym == finfo->outsyms);
+ return true;
+ }
+
+ if (h->indx != -2
+ && (h->flags & (XCOFF_REF_REGULAR | XCOFF_DEF_REGULAR)) == 0)
+ {
+ BFD_ASSERT (outsym == finfo->outsyms);
+ return true;
+ }
+
+ memset (&aux, 0, sizeof aux);
+
+ h->indx = obj_raw_syment_count (output_bfd);
+
+ if (strlen (h->root.root.string) <= SYMNMLEN)
+ strncpy (isym._n._n_name, h->root.root.string, SYMNMLEN);
+ else
+ {
+ boolean hash;
+ bfd_size_type indx;
+
+ hash = true;
+ if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ hash = false;
+ indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, hash,
+ false);
+ if (indx == (bfd_size_type) -1)
+ return false;
+ isym._n._n_n._n_zeroes = 0;
+ isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
+ }
+
+ if (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ {
+ isym.n_value = 0;
+ isym.n_scnum = N_UNDEF;
+ isym.n_sclass = C_EXT;
+ aux.x_csect.x_smtyp = XTY_ER;
+ }
+ else if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->smclas == XMC_XO)
+ {
+ BFD_ASSERT (bfd_is_abs_section (h->root.u.def.section));
+ isym.n_value = h->root.u.def.value;
+ isym.n_scnum = N_UNDEF;
+ isym.n_sclass = C_EXT;
+ aux.x_csect.x_smtyp = XTY_ER;
+ }
+ else if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ struct xcoff_link_size_list *l;
+
+ isym.n_value = (h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset
+ + h->root.u.def.value);
+ isym.n_scnum = h->root.u.def.section->output_section->target_index;
+ isym.n_sclass = C_HIDEXT;
+ aux.x_csect.x_smtyp = XTY_SD;
+
+ if ((h->flags & XCOFF_HAS_SIZE) != 0)
+ {
+ for (l = xcoff_hash_table (finfo->info)->size_list;
+ l != NULL;
+ l = l->next)
+ {
+ if (l->h == h)
+ {
+ aux.x_csect.x_scnlen.l = l->size;
+ break;
+ }
+ }
+ }
+ }
+ else if (h->root.type == bfd_link_hash_common)
+ {
+ isym.n_value = (h->root.u.c.p->section->output_section->vma
+ + h->root.u.c.p->section->output_offset);
+ isym.n_scnum = h->root.u.c.p->section->output_section->target_index;
+ isym.n_sclass = C_EXT;
+ aux.x_csect.x_smtyp = XTY_CM;
+ aux.x_csect.x_scnlen.l = h->root.u.c.size;
+ }
+ else
+ abort ();
+
+ isym.n_type = T_NULL;
+ isym.n_numaux = 1;
+
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
+ outsym += bfd_coff_symesz (output_bfd);
+
+ aux.x_csect.x_smclas = h->smclas;
+
+ bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, T_NULL, isym.n_sclass, 0, 1,
+ (PTR) outsym);
+ outsym += bfd_coff_auxesz (output_bfd);
+
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->smclas != XMC_XO)
+ {
+ /* We just output an SD symbol. Now output an LD symbol. */
+
+ h->indx += 2;
+
+ isym.n_sclass = C_EXT;
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
+ outsym += bfd_coff_symesz (output_bfd);
+
+ aux.x_csect.x_smtyp = XTY_LD;
+ aux.x_csect.x_scnlen.l = obj_raw_syment_count (output_bfd);
+
+ bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, T_NULL, C_EXT, 0, 1,
+ (PTR) outsym);
+ outsym += bfd_coff_auxesz (output_bfd);
+ }
+
+ if (bfd_seek (output_bfd,
+ (obj_sym_filepos (output_bfd)
+ + (obj_raw_syment_count (output_bfd)
+ * bfd_coff_symesz (output_bfd))),
+ SEEK_SET) != 0
+ || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1, output_bfd)
+ != (bfd_size_type) (outsym - finfo->outsyms)))
+ return false;
+ obj_raw_syment_count (output_bfd) +=
+ (outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);
+
+ return true;
+}
+
+/* Handle a link order which is supposed to generate a reloc. */
+
+static boolean
+xcoff_reloc_link_order (output_bfd, finfo, output_section, link_order)
+ bfd *output_bfd;
+ struct xcoff_final_link_info *finfo;
+ asection *output_section;
+ struct bfd_link_order *link_order;
+{
+ reloc_howto_type *howto;
+ struct xcoff_link_hash_entry *h;
+ asection *hsec;
+ bfd_vma hval;
+ bfd_vma addend;
+ struct internal_reloc *irel;
+ struct xcoff_link_hash_entry **rel_hash_ptr;
+ struct internal_ldrel ldrel;
+
+ if (link_order->type == bfd_section_reloc_link_order)
+ {
+ /* We need to somehow locate a symbol in the right section. The
+ symbol must either have a value of zero, or we must adjust
+ the addend by the value of the symbol. FIXME: Write this
+ when we need it. The old linker couldn't handle this anyhow. */
+ abort ();
+ }
+
+ howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
+ if (howto == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ h = ((struct xcoff_link_hash_entry *)
+ bfd_wrapped_link_hash_lookup (output_bfd, finfo->info,
+ link_order->u.reloc.p->u.name,
+ false, false, true));
+ if (h == NULL)
+ {
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
+ (asection *) NULL, (bfd_vma) 0)))
+ return false;
+ return true;
+ }
+
+ if (h->root.type == bfd_link_hash_common)
+ {
+ hsec = h->root.u.c.p->section;
+ hval = 0;
+ }
+ else if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ hsec = h->root.u.def.section;
+ hval = h->root.u.def.value;
+ }
+ else
+ {
+ hsec = NULL;
+ hval = 0;
+ }
+
+ addend = link_order->u.reloc.p->addend;
+ if (hsec != NULL)
+ addend += (hsec->output_section->vma
+ + hsec->output_offset
+ + hval);
+
+ if (addend != 0)
+ {
+ bfd_size_type size;
+ bfd_byte *buf;
+ bfd_reloc_status_type rstat;
+ boolean ok;
+
+ size = bfd_get_reloc_size (howto);
+ buf = (bfd_byte *) bfd_zmalloc (size);
+ if (buf == NULL)
+ return false;
+
+ rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
+ switch (rstat)
+ {
+ case bfd_reloc_ok:
+ break;
+ default:
+ case bfd_reloc_outofrange:
+ abort ();
+ case bfd_reloc_overflow:
+ if (! ((*finfo->info->callbacks->reloc_overflow)
+ (finfo->info, link_order->u.reloc.p->u.name,
+ howto->name, addend, (bfd *) NULL, (asection *) NULL,
+ (bfd_vma) 0)))
+ {
+ free (buf);
+ return false;
+ }
+ break;
+ }
+ ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
+ (file_ptr) link_order->offset, size);
+ free (buf);
+ if (! ok)
+ return false;
+ }
+
+ /* Store the reloc information in the right place. It will get
+ swapped and written out at the end of the final_link routine. */
+
+ irel = (finfo->section_info[output_section->target_index].relocs
+ + output_section->reloc_count);
+ rel_hash_ptr = (finfo->section_info[output_section->target_index].rel_hashes
+ + output_section->reloc_count);
+
+ memset (irel, 0, sizeof (struct internal_reloc));
+ *rel_hash_ptr = NULL;
+
+ irel->r_vaddr = output_section->vma + link_order->offset;
+
+ if (h->indx >= 0)
+ irel->r_symndx = h->indx;
+ else
+ {
+ /* Set the index to -2 to force this symbol to get written out. */
+ h->indx = -2;
+ *rel_hash_ptr = h;
+ irel->r_symndx = 0;
+ }
+
+ irel->r_type = howto->type;
+ irel->r_size = howto->bitsize - 1;
+ if (howto->complain_on_overflow == complain_overflow_signed)
+ irel->r_size |= 0x80;
+
+ ++output_section->reloc_count;
+
+ /* Now output the reloc to the .loader section. */
+
+ ldrel.l_vaddr = irel->r_vaddr;
+
+ if (hsec != NULL)
+ {
+ const char *secname;
+
+ secname = hsec->output_section->name;
+
+ if (strcmp (secname, ".text") == 0)
+ ldrel.l_symndx = 0;
+ else if (strcmp (secname, ".data") == 0)
+ ldrel.l_symndx = 1;
+ else if (strcmp (secname, ".bss") == 0)
+ ldrel.l_symndx = 2;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in unrecognized section `%s'"),
+ bfd_get_filename (output_bfd), secname);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ }
+ else
+ {
+ if (h->ldindx < 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: `%s' in loader reloc but not loader sym"),
+ bfd_get_filename (output_bfd),
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ ldrel.l_symndx = h->ldindx;
+ }
+
+ ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
+ ldrel.l_rsecnm = output_section->target_index;
+ xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
+ ++finfo->ldrel;
+
+ return true;
+}
+
+/* Sort relocs by VMA. This is called via qsort. */
+
+static int
+xcoff_sort_relocs (p1, p2)
+ const PTR p1;
+ const PTR p2;
+{
+ const struct internal_reloc *r1 = (const struct internal_reloc *) p1;
+ const struct internal_reloc *r2 = (const struct internal_reloc *) p2;
+
+ if (r1->r_vaddr > r2->r_vaddr)
+ return 1;
+ else if (r1->r_vaddr < r2->r_vaddr)
+ return -1;
+ else
+ return 0;
+}
+
+/* This is the relocation function for the RS/6000/POWER/PowerPC.
+ This is currently the only processor which uses XCOFF; I hope that
+ will never change. */
+
+boolean
+_bfd_ppc_xcoff_relocate_section (output_bfd, info, input_bfd,
+ input_section, contents, relocs, syms,
+ sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ struct xcoff_link_hash_entry *h;
+ struct internal_syment *sym;
+ bfd_vma addend;
+ bfd_vma val;
+ struct reloc_howto_struct howto;
+ bfd_reloc_status_type rstat;
+
+ /* Relocation type R_REF is a special relocation type which is
+ merely used to prevent garbage collection from occurring for
+ the csect including the symbol which it references. */
+ if (rel->r_type == R_REF)
+ continue;
+
+ symndx = rel->r_symndx;
+
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ addend = 0;
+ }
+ else
+ {
+ h = obj_xcoff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ addend = - sym->n_value;
+ }
+
+ /* We build the howto information on the fly. */
+
+ howto.type = rel->r_type;
+ howto.rightshift = 0;
+ howto.size = 2;
+ howto.bitsize = (rel->r_size & 0x1f) + 1;
+ howto.pc_relative = false;
+ howto.bitpos = 0;
+ if ((rel->r_size & 0x80) != 0)
+ howto.complain_on_overflow = complain_overflow_signed;
+ else
+ howto.complain_on_overflow = complain_overflow_bitfield;
+ howto.special_function = NULL;
+ howto.name = "internal";
+ howto.partial_inplace = true;
+ if (howto.bitsize == 32)
+ howto.src_mask = howto.dst_mask = 0xffffffff;
+ else
+ {
+ howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1;
+ if (howto.bitsize == 16)
+ howto.size = 1;
+ }
+ howto.pcrel_offset = false;
+
+ val = 0;
+
+ if (h == NULL)
+ {
+ asection *sec;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
+ else
+ {
+ sec = sections[symndx];
+ /* Hack to make sure we use the right TOC anchor value
+ if this reloc is against the TOC anchor. */
+ if (sec->name[3] == '0'
+ && strcmp (sec->name, ".tc0") == 0)
+ val = xcoff_data (output_bfd)->toc;
+ else
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma);
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
+
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_common)
+ {
+ asection *sec;
+
+ sec = h->root.u.c.p->section;
+ val = (sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0
+ || (h->flags & XCOFF_IMPORT) != 0)
+ {
+ /* Every symbol in a shared object is defined somewhere. */
+ val = 0;
+ }
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+
+ /* Don't try to process the reloc. It can't help, and
+ it may generate another error. */
+ continue;
+ }
+ }
+
+ /* I took the relocation type definitions from two documents:
+ the PowerPC AIX Version 4 Application Binary Interface, First
+ Edition (April 1992), and the PowerOpen ABI, Big-Endian
+ 32-Bit Hardware Implementation (June 30, 1994). Differences
+ between the documents are noted below. */
+
+ switch (rel->r_type)
+ {
+ case R_RTB:
+ case R_RRTBI:
+ case R_RRTBA:
+ /* These relocs are defined by the PowerPC ABI to be
+ relative branches which use half of the difference
+ between the symbol and the program counter. I can't
+ quite figure out when this is useful. These relocs are
+ not defined by the PowerOpen ABI. */
+ default:
+ (*_bfd_error_handler)
+ (_("%s: unsupported relocation type 0x%02x"),
+ bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ case R_POS:
+ /* Simple positive relocation. */
+ break;
+ case R_NEG:
+ /* Simple negative relocation. */
+ val = - val;
+ break;
+ case R_REL:
+ /* Simple PC relative relocation. */
+ howto.pc_relative = true;
+ break;
+ case R_TOC:
+ /* TOC relative relocation. The value in the instruction in
+ the input file is the offset from the input file TOC to
+ the desired location. We want the offset from the final
+ TOC to the desired location. We have:
+ isym = iTOC + in
+ iinsn = in + o
+ osym = oTOC + on
+ oinsn = on + o
+ so we must change insn by on - in.
+ */
+ case R_GL:
+ /* Global linkage relocation. The value of this relocation
+ is the address of the entry in the TOC section. */
+ case R_TCL:
+ /* Local object TOC address. I can't figure out the
+ difference between this and case R_GL. */
+ case R_TRL:
+ /* TOC relative relocation. A TOC relative load instruction
+ which may be changed to a load address instruction.
+ FIXME: We don't currently implement this optimization. */
+ case R_TRLA:
+ /* TOC relative relocation. This is a TOC relative load
+ address instruction which may be changed to a load
+ instruction. FIXME: I don't know if this is the correct
+ implementation. */
+ if (h != NULL && h->smclas != XMC_TD)
+ {
+ if (h->toc_section == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
+ bfd_get_filename (input_bfd), rel->r_vaddr,
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
+ val = (h->toc_section->output_section->vma
+ + h->toc_section->output_offset);
+ }
+
+ val = ((val - xcoff_data (output_bfd)->toc)
+ - (sym->n_value - xcoff_data (input_bfd)->toc));
+ addend = 0;
+ break;
+ case R_BA:
+ /* Absolute branch. We don't want to mess with the lower
+ two bits of the instruction. */
+ case R_CAI:
+ /* The PowerPC ABI defines this as an absolute call which
+ may be modified to become a relative call. The PowerOpen
+ ABI does not define this relocation type. */
+ case R_RBA:
+ /* Absolute branch which may be modified to become a
+ relative branch. */
+ case R_RBAC:
+ /* The PowerPC ABI defines this as an absolute branch to a
+ fixed address which may be modified to an absolute branch
+ to a symbol. The PowerOpen ABI does not define this
+ relocation type. */
+ case R_RBRC:
+ /* The PowerPC ABI defines this as an absolute branch to a
+ fixed address which may be modified to a relative branch.
+ The PowerOpen ABI does not define this relocation type. */
+ howto.src_mask &= ~3;
+ howto.dst_mask = howto.src_mask;
+ break;
+ case R_BR:
+ /* Relative branch. We don't want to mess with the lower
+ two bits of the instruction. */
+ case R_CREL:
+ /* The PowerPC ABI defines this as a relative call which may
+ be modified to become an absolute call. The PowerOpen
+ ABI does not define this relocation type. */
+ case R_RBR:
+ /* A relative branch which may be modified to become an
+ absolute branch. FIXME: We don't implement this,
+ although we should for symbols of storage mapping class
+ XMC_XO. */
+ howto.pc_relative = true;
+ howto.src_mask &= ~3;
+ howto.dst_mask = howto.src_mask;
+ break;
+ case R_RL:
+ /* The PowerPC AIX ABI describes this as a load which may be
+ changed to a load address. The PowerOpen ABI says this
+ is the same as case R_POS. */
+ break;
+ case R_RLA:
+ /* The PowerPC AIX ABI describes this as a load address
+ which may be changed to a load. The PowerOpen ABI says
+ this is the same as R_POS. */
+ break;
+ }
+
+ /* If we see an R_BR or R_RBR reloc which is jumping to global
+ linkage code, and it is followed by an appropriate cror nop
+ instruction, we replace the cror with lwz r2,20(r1). This
+ restores the TOC after the glink code. Contrariwise, if the
+ call is followed by a lwz r2,20(r1), but the call is not
+ going to global linkage code, we can replace the load with a
+ cror. */
+ if ((rel->r_type == R_BR || rel->r_type == R_RBR)
+ && h != NULL
+ && h->root.type == bfd_link_hash_defined
+ && (rel->r_vaddr - input_section->vma + 8
+ <= input_section->_cooked_size))
+ {
+ bfd_byte *pnext;
+ unsigned long next;
+
+ pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
+ next = bfd_get_32 (input_bfd, pnext);
+
+ /* The _ptrgl function is magic. It is used by the AIX
+ compiler to call a function through a pointer. */
+ if (h->smclas == XMC_GL
+ || strcmp (h->root.root.string, "._ptrgl") == 0)
+ {
+ if (next == 0x4def7b82 /* cror 15,15,15 */
+ || next == 0x4ffffb82) /* cror 31,31,31 */
+ bfd_put_32 (input_bfd, 0x80410014, pnext); /* lwz r1,20(r1) */
+ }
+ else
+ {
+ if (next == 0x80410014) /* lwz r1,20(r1) */
+ bfd_put_32 (input_bfd, 0x4ffffb82, pnext); /* cror 31,31,31 */
+ }
+ }
+
+ /* A PC relative reloc includes the section address. */
+ if (howto.pc_relative)
+ addend += input_section->vma;
+
+ rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section,
+ contents,
+ rel->r_vaddr - input_section->vma,
+ val, addend);
+
+ switch (rstat)
+ {
+ default:
+ abort ();
+ case bfd_reloc_ok:
+ break;
+ case bfd_reloc_overflow:
+ {
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ char howto_name[10];
+
+ if (symndx == -1)
+ name = "*ABS*";
+ else if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+ if (name == NULL)
+ return false;
+ }
+ sprintf (howto_name, "0x%02x", rel->r_type);
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto_name, (bfd_vma) 0, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
diff --git a/config-ml.in b/config-ml.in
new file mode 100644
index 00000000000..503f7cf1a18
--- /dev/null
+++ b/config-ml.in
@@ -0,0 +1,687 @@
+# Configure fragment invoked in the post-target section for subdirs
+# wanting multilib support.
+#
+# It is advisable to support a few --enable/--disable options to let the
+# user select which libraries s/he really wants.
+#
+# Subdirectories wishing to use multilib should put the following lines
+# in the "post-target" section of configure.in.
+#
+# if [ "${srcdir}" = "." ] ; then
+# if [ "${with_target_subdir}" != "." ] ; then
+# . ${with_multisrctop}../../config-ml.in
+# else
+# . ${with_multisrctop}../config-ml.in
+# fi
+# else
+# . ${srcdir}/../config-ml.in
+# fi
+#
+# See librx/configure.in in the libg++ distribution for an example of how
+# to handle autoconf'd libraries.
+#
+# Things are complicated because 6 separate cases must be handled:
+# 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
+#
+# srcdir=. is special. It must handle make programs that don't handle VPATH.
+# To implement this, a symlink tree is built for each library and for each
+# multilib subdir.
+#
+# The build tree is layed out as
+#
+# ./
+# libg++
+# newlib
+# m68020/
+# libg++
+# newlib
+# m68881/
+# libg++
+# newlib
+#
+# The nice feature about this arrangement is that inter-library references
+# in the build tree work without having to care where you are. Note that
+# inter-library references also work in the source tree because symlink trees
+# are built when srcdir=.
+#
+# Unfortunately, trying to access the libraries in the build tree requires
+# the user to manually choose which library to use as GCC won't be able to
+# find the right one. This is viewed as the lesser of two evils.
+#
+# Configure variables:
+# ${with_target_subdir} = "." for native, or ${target_alias} for cross.
+# Set by top level Makefile.
+# ${with_multisrctop} = how many levels of multilibs there are in the source
+# tree. It exists to handle the case of configuring in the source tree:
+# ${srcdir} is not constant.
+# ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881).
+#
+# Makefile variables:
+# MULTISRCTOP = number of multilib levels in source tree (+1 if cross)
+# (FIXME: note that this is different than ${with_multisrctop}. Check out.).
+# MULTIBUILDTOP = number of multilib levels in build tree
+# MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...)
+# (only defined in each library's main Makefile).
+# MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000)
+# (only defined in each multilib subdir).
+
+# FIXME: Multilib is currently disabled by default for everything other than
+# newlib. It is up to each target to turn on multilib support for the other
+# libraries as desired.
+
+# We have to handle being invoked by both Cygnus configure and Autoconf.
+#
+# Cygnus configure incoming variables:
+# srcdir, subdir, host, arguments
+#
+# Autoconf incoming variables:
+# srcdir, host, ac_configure_args
+#
+# We *could* figure srcdir and host out, but we'd have to do work that
+# our caller has already done to figure them out and requiring these two
+# seems reasonable.
+# Note that `host' in this case is GCC's `target'. Target libraries are
+# configured for a particular host.
+
+if [ -n "${ac_configure_args}" ]; then
+ Makefile=${ac_file-Makefile}
+ ml_config_shell=${CONFIG_SHELL-/bin/sh}
+ ml_arguments="${ac_configure_args}"
+ ml_realsrcdir=${srcdir}
+else
+ Makefile=${Makefile-Makefile}
+ ml_config_shell=${config_shell-/bin/sh}
+ ml_arguments="${arguments}"
+ if [ -n "${subdir}" -a "${subdir}" != "." ] ; then
+ ml_realsrcdir=${srcdir}/${subdir}
+ else
+ ml_realsrcdir=${srcdir}
+ fi
+fi
+
+# Scan all the arguments and set all the ones we need.
+
+ml_verbose=--verbose
+for option in ${ml_arguments}
+do
+ case $option in
+ --*) ;;
+ -*) option=-$option ;;
+ esac
+
+ case $option in
+ --*=*)
+ optarg=`echo $option | sed -e 's/^[^=]*=//'`
+ ;;
+ esac
+
+ case $option in
+ --disable-*)
+ enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
+ eval $enableopt=no
+ ;;
+ --enable-*)
+ case "$option" in
+ *=*) ;;
+ *) optarg=yes ;;
+ esac
+ enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
+ eval $enableopt="$optarg"
+ ;;
+ --norecursion | --no*)
+ ml_norecursion=yes
+ ;;
+ --silent | --sil* | --quiet | --q*)
+ ml_verbose=--silent
+ ;;
+ --verbose | --v | --verb*)
+ ml_verbose=--verbose
+ ;;
+ --with-*)
+ case "$option" in
+ *=*) ;;
+ *) optarg=yes ;;
+ esac
+ withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
+ eval $withopt="$optarg"
+ ;;
+ --without-*)
+ withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
+ eval $withopt=no
+ ;;
+ esac
+done
+
+# Only do this if --enable-multilib.
+if [ "${enable_multilib}" = yes ]; then
+
+# Compute whether this is the library's top level directory
+# (ie: not a multilib subdirectory, and not a subdirectory like libg++/src).
+# ${with_multisubdir} tells us we're in the right branch, but we could be
+# in a subdir of that.
+# ??? The previous version could void this test by separating the process into
+# two files: one that only the library's toplevel configure.in ran (to
+# configure the multilib subdirs), and another that all configure.in's ran to
+# update the Makefile. It seemed reasonable to collapse all multilib support
+# into one file, but it does leave us with having to perform this test.
+ml_toplevel_p=no
+if [ -z "${with_multisubdir}" ]; then
+ if [ "${srcdir}" = "." ]; then
+ # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
+ # ${with_target_subdir} = "." for native, otherwise target alias.
+ if [ "${with_target_subdir}" = "." ]; then
+ if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
+ ml_toplevel_p=yes
+ fi
+ else
+ if [ -f ${ml_realsrcdir}/../../config-ml.in ]; then
+ ml_toplevel_p=yes
+ fi
+ fi
+ else
+ # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
+ if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
+ ml_toplevel_p=yes
+ fi
+ fi
+fi
+
+# If this is the library's top level directory, set multidirs to the
+# multilib subdirs to support. This lives at the top because we need
+# `multidirs' set right away.
+
+if [ "${ml_toplevel_p}" = yes ]; then
+
+multidirs=
+for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
+ dir=`echo $i | sed -e 's/;.*$//'`
+ if [ "${dir}" = "." ]; then
+ true
+ else
+ if [ -z "${multidirs}" ]; then
+ multidirs="${dir}"
+ else
+ multidirs="${multidirs} ${dir}"
+ fi
+ fi
+done
+
+# Target libraries are configured for the host they run on, so we check
+# $host here, not $target.
+
+case "${host}" in
+arc-*-elf*)
+ if [ x$enable_biendian != xyes ]
+ then
+ old_multidirs=${multidirs}
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "${x}" in
+ *be*) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ ;;
+arm-*-*)
+ if [ x"$enable_fpu" = xno ]
+ then
+ old_multidirs=${multidirs}
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "${x}" in
+ *fpu*) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x"$enable_26bit" = xno ]
+ then
+ old_multidirs=${multidirs}
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "${x}" in
+ *26bit*) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x"$enable_underscore" = xno ]
+ then
+ old_multidirs=${multidirs}
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "${x}" in
+ *under*) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x"$enable_interwork" = xno ]
+ then
+ old_multidirs=${multidirs}
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "${x}" in
+ *interwork*) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_biendian = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *le* ) : ;;
+ *be* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ ;;
+m68*-*-*)
+ if [ x$enable_softfloat = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *soft-float* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_m68881 = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *m68881* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_m68000 = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *m68000* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_m68020 = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *m68020* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ ;;
+mips*-*-*)
+ if [ x$enable_single_float = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *single* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_biendian = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *el* ) : ;;
+ *eb* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_softfloat = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *soft-float* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ ;;
+powerpc*-*-* | rs6000*-*-*)
+ if [ x$enable_softfloat = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *soft-float* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_powercpu = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ power | */power | */power/* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_powerpccpu = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *powerpc* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_powerpcos = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *mcall-linux* | *mcall-solaris* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_biendian = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *mlittle* | *mbig* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_sysv = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *mcall-sysv* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ if [ x$enable_aix = xno ]
+ then
+ old_multidirs="${multidirs}"
+ multidirs=""
+ for x in ${old_multidirs}; do
+ case "$x" in
+ *mcall-aix* ) : ;;
+ *) multidirs="${multidirs} ${x}" ;;
+ esac
+ done
+ fi
+ ;;
+esac
+
+# Remove extraneous blanks from multidirs.
+# Tests like `if [ -n "$multidirs" ]' require it.
+multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
+
+# Add code to library's top level makefile to handle building the multilib
+# subdirs.
+
+cat > Multi.tem <<\EOF
+
+# FIXME: There should be an @-sign in front of the `if'.
+# Leave out until this is tested a bit more.
+multi-do:
+ if [ -z "$(MULTIDIRS)" ]; then \
+ true; \
+ else \
+ rootpre=`pwd`/; export rootpre; \
+ srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
+ lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
+ compiler="$(CC)"; \
+ for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
+ dir=`echo $$i | sed -e 's/;.*$$//'`; \
+ if [ "$${dir}" = "." ]; then \
+ true; \
+ else \
+ if [ -d ../$${dir}/$${lib} ]; then \
+ flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
+ if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
+ CFLAGS="$(CFLAGS) $${flags}" \
+ CXXFLAGS="$(CXXFLAGS) $${flags}" \
+ LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
+ LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
+ LDFLAGS="$(LDFLAGS) $${flags}" \
+ $(DO)); then \
+ true; \
+ else \
+ exit 1; \
+ fi; \
+ else true; \
+ fi; \
+ fi; \
+ done; \
+ fi
+
+# FIXME: There should be an @-sign in front of the `if'.
+# Leave out until this is tested a bit more.
+multi-clean:
+ if [ -z "$(MULTIDIRS)" ]; then \
+ true; \
+ else \
+ lib=`pwd | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
+ for dir in Makefile $(MULTIDIRS); do \
+ if [ -f ../$${dir}/$${lib}/Makefile ]; then \
+ if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
+ then true; \
+ else exit 1; \
+ fi; \
+ else true; \
+ fi; \
+ done; \
+ fi
+EOF
+
+cat ${Makefile} Multi.tem > Makefile.tem
+rm -f ${Makefile} Multi.tem
+mv Makefile.tem ${Makefile}
+
+fi # ${ml_toplevel_p} = yes
+
+if [ "${ml_verbose}" = --verbose ]; then
+ echo "Adding multilib support to Makefile in ${ml_realsrcdir}"
+ if [ "${ml_toplevel_p}" = yes ]; then
+ echo "multidirs=${multidirs}"
+ fi
+ echo "with_multisubdir=${with_multisubdir}"
+fi
+
+if [ "${srcdir}" = "." ]; then
+ if [ "${with_target_subdir}" != "." ]; then
+ ml_srcdotdot="../"
+ else
+ ml_srcdotdot=""
+ fi
+else
+ ml_srcdotdot=""
+fi
+
+if [ -z "${with_multisubdir}" ]; then
+ ml_subdir=
+ ml_builddotdot=
+ : # ml_srcdotdot= # already set
+else
+ ml_subdir="/${with_multisubdir}"
+ # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
+ ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
+ if [ "$srcdir" = "." ]; then
+ ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
+ else
+ : # ml_srcdotdot= # already set
+ fi
+fi
+
+if [ "${ml_toplevel_p}" = yes ]; then
+ ml_do='$(MAKE)'
+ ml_clean='$(MAKE)'
+else
+ ml_do=true
+ ml_clean=true
+fi
+
+# TOP is used by newlib and should not be used elsewhere for this purpose.
+# MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
+# when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
+# FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
+# delete TOP. Newlib may wish to continue to use TOP for its own purposes
+# of course.
+# MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
+# and lists the subdirectories to recurse into.
+# MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
+# (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
+# a leading '/'.
+# MULTIDO is used for targets like all, install, and check where
+# $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
+# MULTICLEAN is used for the *clean targets.
+#
+# ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
+# currently kept separate because we don't want the *clean targets to require
+# the existence of the compiler (which MULTIDO currently requires) and
+# therefore we'd have to record the directory options as well as names
+# (currently we just record the names and use --print-multi-lib to get the
+# options).
+
+sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
+ -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
+ -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
+ -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
+ -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
+ -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
+ -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
+ ${Makefile} > Makefile.tem
+rm -f ${Makefile}
+mv Makefile.tem ${Makefile}
+
+# If this is the library's top level, configure each multilib subdir.
+# This is done at the end because this is the loop that runs configure
+# in each multilib subdir and it seemed reasonable to finish updating the
+# Makefile before going on to configure the subdirs.
+
+if [ "${ml_toplevel_p}" = yes ]; then
+
+# We must freshly configure each subdirectory. This bit of code is
+# actually partially stolen from the main configure script. FIXME.
+
+if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
+
+ if [ "${ml_verbose}" = --verbose ]; then
+ echo "Running configure in multilib subdirs ${multidirs}"
+ echo "pwd: `pwd`"
+ fi
+
+ ml_origdir=`pwd`
+ ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
+ # cd to top-level-build-dir/${with_target_subdir}
+ cd ..
+
+ for ml_dir in ${multidirs}; do
+
+ if [ "${ml_verbose}" = --verbose ]; then
+ echo "Running configure in multilib subdir ${ml_dir}"
+ echo "pwd: `pwd`"
+ fi
+
+ if [ -d ${ml_dir} ]; then true; else mkdir ${ml_dir}; fi
+ if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
+
+ # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
+ dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
+
+ case ${srcdir} in
+ ".")
+ echo Building symlink tree in `pwd`/${ml_dir}/${ml_libdir}
+ if [ "${with_target_subdir}" != "." ]; then
+ ml_unsubdir="../"
+ else
+ ml_unsubdir=""
+ fi
+ (cd ${ml_dir}/${ml_libdir};
+ ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
+ if [ -f ${ml_dir}/${ml_libdir}/Makefile ]; then
+ if [ x"${MAKE}" = x ]; then
+ (cd ${ml_dir}/${ml_libdir}; make distclean)
+ else
+ (cd ${ml_dir}/${ml_libdir}; ${MAKE} distclean)
+ fi
+ fi
+ ml_newsrcdir="."
+ ml_srcdiroption=
+ multisrctop=${dotdot}
+ ;;
+ *)
+ case "${srcdir}" in
+ /*) # absolute path
+ ml_newsrcdir=${srcdir}
+ ;;
+ *) # otherwise relative
+ ml_newsrcdir=${dotdot}${srcdir}
+ ;;
+ esac
+ ml_srcdiroption="-srcdir=${ml_newsrcdir}"
+ multisrctop=
+ ;;
+ esac
+
+ case "${progname}" in
+ /*) ml_recprog=${progname} ;;
+ *) ml_recprog=${dotdot}${progname} ;;
+ esac
+
+ # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
+ ML_POPDIR=`pwd`
+ cd ${ml_dir}/${ml_libdir}
+
+ if [ -f ${ml_newsrcdir}/configure ]; then
+ ml_recprog=${ml_newsrcdir}/configure
+ fi
+ if eval ${ml_config_shell} ${ml_recprog} \
+ --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
+ ${ml_arguments} ${ml_srcdiroption} ; then
+ true
+ else
+ exit 1
+ fi
+
+ cd ${ML_POPDIR}
+
+ done
+
+ cd ${ml_origdir}
+fi
+
+fi # ${ml_toplevel_p} = yes
+fi # ${enable_multilib} = yes
diff --git a/config.guess b/config.guess
new file mode 100755
index 00000000000..3c75a80de33
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1008 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# The master version of this file is at the FSF in /home/gd/gnu/lib.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ cat <<EOF >dummy.s
+ .globl main
+ .ent main
+main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ ${CC-cc} dummy.s -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+ fi
+ rm -f dummy.s dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-cbm-sysv4
+ exit 0;;
+ amiga:NetBSD:*:*)
+ echo m68k-cbm-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ arm32:NetBSD:*:*)
+ echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ SR2?01:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:NetBSD:*:*)
+ echo m68k-atari-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3*:NetBSD:*:*)
+ echo m68k-sun-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:NetBSD:*:*)
+ echo m68k-apple-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ sed 's/^ //' << EOF >dummy.c
+ int main (argc, argv) int argc; char **argv; {
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy \
+ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
+ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i?86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ sed 's/^ //' << EOF >dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:4)
+ if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=4.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ *9??*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9] )
+
+ sed 's/^ //' << EOF >dummy.c
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy`
+ rm -f dummy.c dummy
+ esac
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ sed 's/^ //' << EOF >dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i?86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ hppa*:OpenBSD:*:*)
+ echo hppa-unknown-openbsd
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*X-MP:*:*:*)
+ echo xmp-cray-unicos
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY-2:*:*:*)
+ echo cray2-cray-unicos
+ exit 0 ;;
+ F300:UNIX_System_V:*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ F301:UNIX_System_V:*:*)
+ echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+ exit 0 ;;
+ hp3[0-9][05]:NetBSD:*:*)
+ echo m68k-hp-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:BSD/386:*:* | *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ if test -x /usr/bin/objformat; then
+ if test "elf" = "`/usr/bin/objformat`"; then
+ echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
+ exit 0
+ fi
+ fi
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ *:NetBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ i*:[Cc][Yy][Gg][Ww][Ii][Nn]*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin32
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than generic posix subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # change UNAME_MACHINE based on the output of uname instead of
+ # i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin32
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ *:Linux:*:*)
+ # uname on the ARM produces all sorts of strangeness, and we need to
+ # filter it out.
+ case "$UNAME_MACHINE" in
+ armv*) UNAME_MACHINE=$UNAME_MACHINE ;;
+ arm* | sa110*) UNAME_MACHINE="arm" ;;
+ esac
+
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us.
+ ld_help_string=`ld --help 2>&1`
+ ld_supported_emulations=`echo $ld_help_string \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
+ i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
+ sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
+ armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
+ m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
+ elf32ppc)
+ # Determine Lib Version
+ cat >dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#if defined(__GLIBC__)
+ printf("%s %s\n", __libc_version, __libc_release);
+#else
+ printf("unkown\n");
+#endif
+ return 0;
+}
+EOF
+ LIBC=""
+ ${CC-cc} dummy.c -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy | grep 1\.99 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f dummy.c dummy
+ echo powerpc-unknown-linux-gnu${LIBC} ; exit 0 ;;
+ esac
+
+ if test "${UNAME_MACHINE}" = "alpha" ; then
+ sed 's/^ //' <<EOF >dummy.s
+ .globl main
+ .ent main
+ main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ LIBC=""
+ ${CC-cc} dummy.s -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+
+ objdump --private-headers dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f dummy.s dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+ elif test "${UNAME_MACHINE}" = "mips" ; then
+ cat >dummy.c <<EOF
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ else
+ # Either a pre-BFD a.out linker (linux-gnuoldld)
+ # or one that does not give us useful --help.
+ # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+ # If ld does not provide *any* "supported emulations:"
+ # that means it is gnuoldld.
+ echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
+ test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+
+ case "${UNAME_MACHINE}" in
+ i?86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ cat >dummy.c <<EOF
+#include <features.h>
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#ifdef __ELF__
+# ifdef __GLIBC__
+# if __GLIBC__ >= 2
+ printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+ printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ fi ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+ i?86:DYNIX/ptx:4*:*)
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i?86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ i?86:*:5:7)
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+# 5.0.4c returns "Pent II". 5.0.5 returns PentII
+ (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*PentII' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pent II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ pc:*:*:*)
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ i?86:LynxOS:2.*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:*:6*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+ printf ("vax-dec-bsd\n"); exit (0);
+#else
+ printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+#echo '(Unable to guess system type)' 1>&2
+
+exit 1
diff --git a/config.if b/config.if
new file mode 100644
index 00000000000..bcc026908d8
--- /dev/null
+++ b/config.if
@@ -0,0 +1,87 @@
+#! /dev/null
+# Don't call it directly. This shell script fragment is called to
+# determine:
+#
+# 1. libstcxx_interface: the interface name for libstdc++.
+# 2. cxx_interface: the interface name for c++.
+# 3. libc_interface: the interface name for libc.
+#
+
+# Get the top level src dir.
+if [ -z "${topsrcdir}" -a -z "${top_srcdir}" ]
+then
+ echo "Undefined top level src dir: topsrcdir and top_srcdir are empty" >&2
+ exit 1
+fi
+
+if [ -n "${topsrcdir}" ]
+then
+ if_topsrcdir=${topsrcdir}
+else
+ if_topsrcdir=${top_srcdir}
+fi
+
+if [ -f ${if_topsrcdir}/libstdc++/Makefile.in ]; then
+# We check libstdc++ for libstdcxx_interface.
+libstdcxx_interface=`grep "^INTERFACE" ${if_topsrcdir}/libstdc++/Makefile.in | sed 's/INTERFACE[ ]*=[ ]*\(.*\)/\1/'`
+else
+libstdcxx_interface=
+fi
+
+if [ -f ${if_topsrcdir}/gcc/cp/Makefile.in ]; then
+# We check gcc/cp for cxx_interface.
+cxx_interface=`grep "^INTERFACE" ${if_topsrcdir}/gcc/cp/Makefile.in | sed 's/INTERFACE[ ]*=[ ]*\(.*\)/\1/'`
+else
+cxx_interface=
+fi
+
+# The trickiest part is libc_interface.
+if [ -z "${libc_interface}" ]
+then
+ case ${target_os} in
+ *linux*libc1*|*linux*libc5*)
+ case ${target_alias} in
+ *alpha*|*powerpc*)
+ libc_interface=-libc5.9-
+ ;;
+ *)
+ libc_interface=-libc5-
+ ;;
+ esac
+ ;;
+ *linux*gnu*)
+ # We have to work harder to figure it out.
+ if [ ${target_alias} = ${build_alias} ]
+ then
+ dummy=if$$
+ cat >$dummy.c <<EOF
+#include <features.h>
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ printf("%d\n", __GLIBC_MINOR__);
+ return 0;
+}
+EOF
+ ${CC-cc} $dummy.c -o $dummy 2>/dev/null
+ if [ "$?" = 0 ]
+ then
+ libc_interface=-libc6.`./$dummy`-
+ rm -f $dummy.c $dummy
+ else
+ # It should never happen.
+ echo "Cannot find the GNU C library minor version number." >&2
+ rm -f $dummy.c $dummy
+ exit 1
+ fi
+ else
+ # Cross compiling. Assume glibc 2.1.
+ libc_interface=-libc6.1-
+ fi
+ ;;
+ *)
+ libc_interface=-
+ ;;
+ esac
+fi
diff --git a/config.sub b/config.sub
new file mode 100755
index 00000000000..3d4f5fd21b1
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1292 @@
+#! /bin/sh
+# Configuration validation subroutine script, version 1.1.
+# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc.
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+if [ x$1 = x ]
+then
+ echo Configuration name missing. 1>&2
+ echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
+ echo "or $0 ALIAS" 1>&2
+ echo where ALIAS is a recognized configuration type. 1>&2
+ exit 1
+fi
+
+# First pass through any local machine types.
+case $1 in
+ *local*)
+ echo $1
+ exit 0
+ ;;
+ *)
+ ;;
+esac
+
+# CYGNUS LOCAL marketing-names
+# Here we handle any "marketing" names - translating them to
+# standard triplets
+case $1 in
+ mips-tx39-elf)
+ set mipstx39-unknown-elf
+ ;;
+ *)
+ ;;
+esac
+# END CYGNUS LOCAL marketing-names
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ linux-gnu*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond ) # EGCS LOCAL
+ os=
+ basic_machine=$1
+ ;;
+ -scout) # EGCS LOCAL
+ ;;
+ -wrs) # EGCS LOCAL
+ os=vxworks
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+ | arme[lb] | pyramid | mn10200 | mn10300 \
+ | tron | a29k | 580 | i960 | h8300 \
+ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+ | alpha | alphaev[45678] | alphaev56 | alphapca5[67] \
+ | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp11 \
+ | mips64 | mipsel | mips64el | mips64orion | mips64orionel \
+ | mipstx39 | mipstx39el \
+ | sparc | sparclet | sparclite | sparc64 | sparc86x | v850 \
+ | c4x)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m88110 | m680[012346]0 | m683?2 | m68360 | m5200 | z8k | v70 \
+ | h8500 | w65 | fr30 | mcore) # CYGNUS / EGCS LOCAL
+ basic_machine=$basic_machine-unknown
+ ;;
+ strongarm) # CYGNUS LOCAL nickc/strongarm
+ basic_machine=$basic_machine-unknown
+ ;;
+ thumb)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # CYGNUS LOCAL vr4111/gavin
+ mips64vr4111 | mips64vr4111el)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # END CYGNUS LOCAL vr4111/gavin
+ mips64vr4300 | mips64vr4300el) # EGCS LOCAL jsmith/vr4300
+ basic_machine=$basic_machine-unknown
+ ;;
+ mips64vr4100 | mips64vr4100el) # EGCS LOCAL jsmith/vr4100
+ basic_machine=$basic_machine-unknown
+ ;;
+ mips64vr5000 | mips64vr5000el) # EGCS LOCAL ian/vr5000
+ basic_machine=$basic_machine-unknown
+ ;;
+ mips16)
+ basic_machine=$basic_machine-unknown
+ ;;
+ tic30) # CYGNUS LOCAL ian/tic30
+ basic_machine=$basic_machine-unknown
+ ;;
+ c30) # CYGNUS LOCAL ian/tic30
+ basic_machine=tic30-unknown
+ ;;
+
+ tic80) # CYGNUS LOCAL fnf/TIc80
+ basic_machine=$basic_machine-unknown
+ ;;
+ v850e) # CYGNUS LOCAL jtc/v850
+ basic_machine=$basic_machine-unknown
+ ;;
+ v850ea) # CYGNUS LOCAL jtc/v850
+ basic_machine=$basic_machine-unknown
+ ;;
+ d10v)
+ basic_machine=$basic_machine-unknown
+ ;;
+ d30v) # CYGNUS LOCAL hunt/d30v
+ basic_machine=$basic_machine-unknown
+ ;;
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i[34567]86)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
+ | xmp-* | ymp-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* \
+ | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
+ | alpha-* | alphaev[45678]-* | alphaev56-* | alphapca5[67]-* \
+ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* \
+ | xps100-* | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | sparcv9-* | sparc86x-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mipstx39-* | mipstx39el-* \
+ | f301-* | arm*-* \
+ | fr30-* | mcore-*) # CYGNUS LOCAL
+ ;;
+ m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | h8500-* | d10v-*) # EGCS LOCAL
+ ;;
+ strongarm-*) # CYGNUS LOCAL nickc/strongarm
+ ;;
+ thumb-*) # EGCS LOCAL angela/thumb
+ ;;
+ v850-*) # EGCS LOCAL
+ ;;
+ v850e-*) # CYGNUS LOCAL
+ ;;
+ v850ea-*) # CYGNUS LOCAL
+ ;;
+ d30v-*) # EGCS LOCAL
+ ;;
+ # CYGNUS LOCAL vr4111/gavin
+ mips64vr4111-* | mips64vr4111el-*)
+ ;;
+ # END CYGNUS LOCAL vr4111/gavin
+ mips64vr4300-* | mips64vr4300el-*) # EGCS LOCAL jsmith/vr4300
+ ;;
+ mips64vr4100-* | mips64vr4100el-*) # EGCS LOCAL jsmith/vr4100
+ ;;
+ mips16-*) # EGCS LOCAL krk/mips16
+ ;;
+ tic30-*) # EGCS LOCAL ian/tic30
+ ;;
+ c30-*) # EGCS LOCAL ian/tic30
+ basic_machine=tic30-unknown
+ ;;
+ tic80-*) # CYGNUS LOCAL fnf/TIc80
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd) # EGCS LOCAL
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif) # EGCS LOCAL
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k) # EGCS LOCAL
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-cbm
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-cbm
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-cbm
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd) # EGCS LOCAL
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ cray2)
+ basic_machine=cray2-cray
+ os=-unicos
+ ;;
+ [ctj]90-cray)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE) # EGCS LOCAL
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray) # EGCS LOCAL
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms) # EGCS LOCAL
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ w89k-*) # EGCS LOCAL
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ op50n-*) # EGCS LOCAL
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ op60c-*) # EGCS LOCAL
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ hppro) # EGCS LOCAL
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9] )
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9] )
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9] )
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | \
+ hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893 )
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679] )
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf) # EGCS LOCAL
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i[34567]86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i[34567]86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i[34567]86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i[34567]86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach) # EGCS LOCAL
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta) # EGCS LOCAL
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ i386-go32 | go32) # EGCS LOCAL
+ basic_machine=i386-unknown
+ os=-go32
+ ;;
+ i386-mingw32 | mingw32)
+ basic_machine=i386-unknown
+ os=-mingw32
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux-gnu
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux-gnu
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor) # EGCS LOCAL
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ msdos) # EGCS LOCAL
+ basic_machine=i386-unknown
+ os=-msdos
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown # EGCS LOCAL
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-corel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70) # EGCS LOCAL
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960) # EGCS LOCAL
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ OSE68000 | ose68000) # EGCS LOCAL
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k) # EGCS LOCAL
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | nexen)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | k6 | 6x86)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | nexen-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | k6-* | 6x86-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=rs6000-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ rom68k) # EGCS LOCAL
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ sa29200) # EGCS LOCAL
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sparclite-wrs) # EGCS LOCAL
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000) # EGCS LOCAL
+ basic_machine=m68k-tandem
+ ;;
+ stratus) # EGCS LOCAL
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810) # EGCS LOCAL
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*) # EGCS LOCAL
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ xmp)
+ basic_machine=xmp-cray
+ os=-unicos
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ z8k-*-coff) # EGCS LOCAL
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k) # EGCS LOCAL
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n) # EGCS LOCAL
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c) # EGCS LOCAL
+ basic_machine=hppa1.1-oki
+ ;;
+ mips)
+ if [ x$os = x-linux-gnu ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sparc | sparcv9)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw) # EGCS LOCAL
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw) # EGCS LOCAL
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* )
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ # EGCS LOCAL
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mon960* | -lnews* )
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ # END EGCS LOCAL
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -386bsd) # EGCS LOCAL
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*) # EGCS LOCAL
+ os=-ose
+ ;;
+ -es1800*) # EGCS LOCAL
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-corel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco) # EGCS LOCAL
+ os=-aout
+ ;;
+ mips*-cisco) # EGCS LOCAL
+ os=-elf
+ ;;
+ mips*-*) # EGCS LOCAL
+ os=-elf
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec) # EGCS LOCAL
+ os=-proelf
+ ;;
+ *-winbond) # EGCS LOCAL
+ os=-proelf
+ ;;
+ *-oki) # EGCS LOCAL
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f301-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k) # EGCS LOCAL
+ os=-coff
+ ;;
+ *-*bug) # EGCS LOCAL
+ os=-coff
+ ;;
+ *-apple) # EGCS LOCAL
+ os=-macos
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*) # EGCS LOCAL
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*) # EGCS LOCAL
+ vendor=apple
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
diff --git a/config/ChangeLog b/config/ChangeLog
new file mode 100644
index 00000000000..7d6fc609368
--- /dev/null
+++ b/config/ChangeLog
@@ -0,0 +1,392 @@
+1999-04-07 Michael Meissner <meissner@cygnus.com>
+
+ * mt-d30v: New file, pass -g -Os -Wa,-C as default options.
+
+1999-02-08 Syd Polk <spolk@cygnus.com>
+
+ * acinclude.m4: Added macros to find itcl files.
+ Export TCL_CFLAGS from tclConfig.sh.
+ Export TCL_LIB_FULL_PATH, TK_LIB_FULL_PATH, ITCL_LIB_FULL_PATH,
+ ITK_LIB_FULL_PATH, and TIX_LIB_FULL_PATH
+ Replace TIX macros with better ones from snavigator.
+
+Tue Feb 2 22:51:21 1999 Philip Blundell <philb@gnu.org>
+
+ * mh-armpic: New file. Patch from Jim Pick <jim@jimpick.com>.
+ * mt-armpic: Likewise.
+
+Mon Jan 18 19:41:08 1999 Christopher Faylor <cgf@cygnus.com>
+
+ * cygwin.mh: Activate commented out dependencies for
+ gdb: libtermcap.
+
+Wed Nov 18 20:29:46 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * cygwin.mh: Add extra libtermcap target information.
+ Add commented out dependency for gdb to libtermcap for
+ future readline requirement.
+
+Mon Nov 2 15:15:33 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * mh-cygwin32: delete
+ * mh-cygwin: was mh-cygwin32
+
+1998-10-26 Syd Polk <spolk@cygnus.com>
+
+ * acinclude.m4: TCLHDIR and TKHDIR need to be run through
+ cygpath for Microsoft builds.
+
+1998-10-20 Syd Polk <spolk@cygnus.com>
+
+ * acinclude.m4: Re-exported TCL_LIBS and TCL_LD_SEARCH_FLAGS
+ because itcl needs them.
+
+Mon Aug 31 17:50:53 1998 David Edelsohn <edelsohn@mhpcc.edu>
+
+ * mh-aix43 (NM_FOR_TARGET): Add -X32_64 as well.
+
+Sat Aug 29 14:32:55 1998 David Edelsohn <edelsohn@mhpcc.edu>
+
+ * mh-aix43: New file.
+
+Mon Aug 10 00:15:47 1998 HJ Lu (hjl@gnu.org)
+
+ * mt-linux (CXXFLAGS_FOR_TARGET): Add -D_GNU_SOURCE.
+
+1998-05-29 Rob Savoye <rob@chinadoll.cygnus.com>
+
+ * acinclude.m4: New collection of generic autoconf macros.
+
+Wed Apr 22 12:24:28 1998 Michael Meissner <meissner@cygnus.com>
+
+ * mt-ospace: New file, support using -Os instead of -O2 to compile
+ the libraries.
+
+Wed Apr 22 10:53:14 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * mt-linux (CXXFLAGS_FOR_TARGET): Set this instead of CXXFLAGS.
+
+Sat Apr 11 22:43:17 1998 J. Kean Johnston <jkj@sco.com>
+
+ * mh-svsv5: New file - support for SCO UnixWare 7 / SVR5.
+
+Thu Mar 26 01:54:25 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * mh-cygwin32: stop configuring and building dosrel.
+
+Thu Sep 11 16:43:27 1997 Jim Wilson <wilson@cygnus.com>
+
+ * mh-elfalphapic, mt-elfalphapic: New files.
+
+Wed Jul 23 12:32:18 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
+
+ * mh-go32 (CFLAGS): Don't set -fno-omit-frame-pointer.
+
+Mon Jun 16 19:06:41 1997 Geoff Keating <geoffk@ozemail.com.au>
+
+ * mh-ppcpic: New file.
+ * mt-ppcpic: New file.
+
+Thu Mar 27 15:52:40 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * mh-cygwin32: override CXXFLAGS, setting to -O2 only
+ (no debug)
+
+Tue Mar 25 18:16:43 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * mh-cygwin32: override LIBGCC2_DEBUG_CFLAGS so debug info
+ isn't included in cygwin32-hosted libgcc2.a by default
+
+Wed Jan 8 19:56:43 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * mh-cygwin32: override CFLAGS so debug info isn't included
+ in cygwin32-hosted tools by default
+
+Tue Dec 31 16:04:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-linux: Remove.
+
+Mon Nov 11 10:29:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * mt-ppc: Delete file, options moved to newlib configure.
+
+Fri Oct 4 12:21:03 1996 Angela Marie Thomas (angela@cygnus.com)
+
+ * mh-dgux386: New file. x86 dgux specific flags
+
+Mon Sep 30 15:10:07 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw (EXTRALIBS_PPC_XCOFF): New, was EXTRALIBS_PPC.
+ (EXTRALIBS_PPC): Use shared libraries instead of xcoff.
+
+Sat Aug 17 04:56:25 1996 Geoffrey Noer <noer@skaro.cygnus.com>
+
+ * mh-cygwin32: don't -D_WIN32 here anymore
+
+Thu Aug 15 19:46:44 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw (SEGFLAG_68K, SEGFLAG_PPC): Remove.
+ (EXTRALIBS_PPC): Add libgcc.xcoff.
+
+Thu Aug 8 14:51:47 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * mt-ppc: New file, add -mrelocatable-lib and -mno-eabi to all
+ target builds for PowerPC eabi targets.
+
+Fri Jul 12 12:06:01 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw: New subdir, Mac MPW configuration support bits.
+
+Mon Jul 8 17:30:52 1996 Jim Wilson <wilson@cygnus.com>
+
+ * mh-irix6: New file.
+
+Mon Jul 8 15:15:37 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * mt-sparcpic (PICFLAG_FOR_TARGET): Use -fPIC.
+
+Fri Jul 5 11:49:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-irix4 (RANLIB): Don't define; Irix 4 does have ranlib.
+
+Sun Jun 23 22:59:25 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * mh-cygwin32: new file. Like mh-go32 without the CFLAGS entry.
+
+Tue Mar 26 14:10:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-go32 (CFLAGS): Define.
+
+Thu Mar 14 19:20:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-necv4: New file.
+
+Thu Feb 15 13:07:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-cxux (CC): New variable.
+ (CFLAGS, LDFLAGS): Remove.
+ * mh-ncrsvr43 (CC): New variable.
+ (CFLAGS): Remove.
+ * mh-solaris (CFLAGS): Remove.
+
+ * mh-go32: Remove most variable settings, since they presumed a
+ Canadian Cross, which is now handled correctly by the configure
+ script.
+
+ * mh-sparcpic (PICFLAG): Set to -fPIC, not -fpic.
+
+Mon Feb 12 14:53:39 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * mh-m68kpic, mt-m68kpic: New files.
+
+Thu Feb 1 14:15:42 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw (CC_MWC68K): Add options similar to those used
+ in CC_MWCPPC, and -mc68020 -model far.
+ (AR_MWLINK68K): Add -xm library.
+ (AR_AR): Define.
+ (CC_LD_MWLINK68K): Remove -d.
+ (EXTRALIBS_MWC68K): Define.
+
+Thu Jan 25 16:05:33 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-ncrsvr43 (CFLAGS): Remove -Hnocopyr.
+
+Tue Nov 7 15:41:30 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw (CC_MWC68K, CC_MWCPPC): Remove unused include path.
+ (CC_MWCPPC): Add -mpw_chars, disable warnings, add comments
+ explaining reasons for various flags.
+ (EXTRALIBS_PPC, EXTRALIBS_MWCPPC ): Put runtime library first.
+
+Fri Oct 13 14:44:25 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * mh-aix, mh-sun: Removed.
+
+ * mh-decstation (X11_EXTRA_CFLAGS): Define.
+
+ * mh-sco, mh-solaris, mh-sysv4 (X11_EXTRA_LIBS): Define.
+
+ * mh-hp300, mh-hpux, mh-hpux8, mh-solaris, mh-sun3, mh-sysv4: Don't
+ hardcode location of X stuff here.
+
+Thu Sep 28 13:14:56 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw: Add definitions for various 68K and PowerMac
+ compilers, add definitions for library and link steps for
+ PowerMacs.
+
+Thu Sep 14 08:20:04 1995 Fred Fish <fnf@cygnus.com>
+
+ * mh-hp300 (CC): Add "CC = cc -Wp,-H256000" to avoid
+ "too much defining" errors from the HPUX compiler.
+
+Thu Aug 17 17:28:56 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ * mh-hp300 (RANLIB): Use "ar ts", in case GNU ar was used and
+ didn't build a symbol table.
+
+Thu Jun 22 17:47:24 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw (CC): Define ANSI_PROTOTYPES.
+
+Mon Apr 10 12:29:48 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-mh-mpw (EXTRALIBS): Always link in Math.o, CSANELIB.o,
+ and ToolLibs.o.
+
+ * mpw-mh-mpw (CC): Define ALMOST_STDC.
+ (CFLAGS): Remove ALMOST_STDC, -mc68881.
+ (LDFLAGS): add -w.
+
+ * mpw-mh-mpw (CFLAGS): Add -b option to put strings at the ends of
+ functions.
+
+ * mpw-mh-mpw: New file, host makefile definitions for MPW.
+
+Fri Mar 31 11:35:17 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * mt-netware: New file.
+
+Mon Mar 13 12:31:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-hpux8: New file.
+ * mh-hpux: Use X11R5 rather than X11R4.
+
+Thu Feb 9 11:04:13 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mh-linux (SYSV): Don't define.
+ (RANLIB): Don't define.
+
+Wed Jan 11 16:29:34 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * m?-*pic (LIBCXXFLAGS): Add -fno-implicit-templates.
+
+Thu Nov 3 17:27:19 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * mh-irix4 (CC): Increase maximum string length.
+
+ * mh-sco (CC): Define away const, it doesn't work right; elements
+ of arrays of ptr-to-const are considered const themselves.
+
+Sat Jul 16 12:17:49 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * mh-cxux: New file, from Bob Rusk (rrusk@mail.csd.harris.com).
+
+Sat Jun 4 17:22:12 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * mh-ncrsvr43: New file from Tom McConnell
+ <tmcconne@sedona.intel.com>.
+
+Thu May 19 00:32:11 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * mh-hpux (CC): Add -Wp,-H256000 to avoid "too much defining"
+ errors from the HPUX 8 compilers.
+
+Wed May 4 20:14:47 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * mh-lynxrs6k: set SHELL to /bin/bash
+
+Tue Apr 12 12:38:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mh-irix4 (CC): Change -XNh1500 to -XNh2000.
+
+Sat Dec 25 20:03:45 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * mt-hppa: Delete.
+
+Tue Nov 16 22:54:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * mh-a68bsd: Define CC to gcc.
+
+Mon Nov 15 16:56:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * mh-linux: Don't put -static in LDFLAGS. Add comments.
+
+Mon Nov 15 13:37:58 1993 david d `zoo' zuhn (zoo@cirdan.cygnus.com)
+
+ * mh-sysv4 (AR_FLAGS): change from cq to cr
+
+Fri Nov 5 08:12:32 1993 D. V. Henkel-Wallace (gumby@blues.cygnus.com)
+
+ * mh-unixware: remove. It's the same as sysv4, and config.guess
+ can't tell the difference. So don't allow skew.
+
+Wed Oct 20 20:35:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * mh-hp300: Revert yesterday's change, but add comment explaining.
+
+Tue Oct 19 18:58:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * mh-hp300: Don't define CFLAGS to empty. Why should hp300 be
+ different from anything else? ("gdb doesn't understand the native
+ debug format" isn't a good enough answer because we might be using
+ gcc).
+
+Tue Oct 5 12:17:40 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * mh-alphaosf: Remove, no longer necessary now that gdb knows
+ how to handle OSF/1 shared libraries.
+
+Tue Jul 6 11:27:33 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * mh-alphaosf: New file.
+
+Thu Jul 1 15:49:33 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * mh-riscos: New file.
+
+Mon Jun 14 12:03:18 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
+
+ * mh-aix, mh-aix386, mh-decstation, mh-delta88, mh-hpux, mh-irix4,
+ mh-ncr3000, mh-solaris, mh-sysv, mh-sysv4: remove INSTALL=cp line,
+ now that we're using install.sh globally
+
+Fri Jun 4 16:09:34 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mh-sysv4 (INSTALL): Use cp, not /usr/ucb/install.
+
+Thu Apr 8 11:21:52 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mt-a29k, mt-ebmon29k, mt-os68k, mt-ose68000, mt-ose68k,
+ mt-vxworks68, mt-vxworks960: Removed obsolete, unused target
+ Makefile fragment files.
+
+Mon Mar 8 15:05:25 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * mh-aix386: New file; old mh-aix, plus no-op RANLIB.
+
+Thu Oct 1 13:50:48 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * mh-solaris: INSTALL is NOT /usr/ucb/install
+
+Mon Aug 24 14:25:35 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * mt-ose68000, mt-ose68k: renamed from mt-OSE*.
+
+Tue Jul 21 02:11:01 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * mt-OSE68k, mt-680000: new configs.
+
+Thu Jul 16 17:12:09 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * mh-irix4: merged changes from progressive.
+
+Tue Jun 9 23:29:38 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Everywhere: Change RANLIB=echo>/dev/null (which confuses
+ some shells - and I don't blame them) to RANLIB=true.
+ * mh-solaris: Use /usr/ucb/install for INSTALL.
+
+Sun May 31 14:45:23 1992 Mark Eichin (eichin at cygnus.com)
+
+ * mh-solaris2: Add new configuration for Solaris 2 (sysv, no ranlib)
+
+Fri Apr 10 23:10:08 1992 Fred Fish (fnf@cygnus.com)
+
+ * mh-ncr3000: Add new configuration for NCR 3000.
+
+Tue Dec 10 00:10:55 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * ChangeLog: fresh changelog.
+
diff --git a/config/acinclude.m4 b/config/acinclude.m4
new file mode 100755
index 00000000000..f799ced44dd
--- /dev/null
+++ b/config/acinclude.m4
@@ -0,0 +1,1994 @@
+dnl This file is included into all any other acinclude file that needs
+dnl to use these macros.
+
+dnl This is copied from autoconf 2.12, but does calls our own AC_PROG_CC_WORKS,
+dnl and doesn't call AC_PROG_CXX_GNU, cause we test for that in AC_PROG_CC_WORKS.
+dnl We are probably using a cross compiler, which will not be able to fully
+dnl link an executable. This should really be fixed in autoconf itself.
+dnl Find a working G++ cross compiler. This only works for the GNU C++ compiler.
+AC_DEFUN(CYG_AC_PROG_CXX_CROSS,
+[AC_BEFORE([$0], [AC_PROG_CXXCPP])
+AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
+
+CYG_AC_PROG_GXX_WORKS
+
+if test $ac_cv_prog_gxx = yes; then
+ GXX=yes
+dnl Check whether -g works, even if CXXFLAGS is set, in case the package
+dnl plays around with CXXFLAGS (such as to build both debugging and
+dnl normal versions of a library), tasteless as that idea is.
+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS=
+ AC_PROG_CXX_G
+ if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ elif test $ac_cv_prog_cxx_g = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-O2"
+ fi
+else
+ GXX=
+ test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
+fi
+])
+
+dnl See if the G++ compiler we found works.
+AC_DEFUN(CYG_AC_PROG_GXX_WORKS,
+[AC_MSG_CHECKING([whether the G++ compiler ($CXX $CXXFLAGS $LDFLAGS) actually works])
+AC_LANG_SAVE
+AC_LANG_CPLUSPLUS
+dnl Try a test case. We only compile, because it's close to impossible
+dnl to get a correct fully linked executable with a cross compiler. For
+dnl most cross compilers, this test is bogus. For G++, we can use various
+dnl other compile line options to get a decent idea that the cross compiler
+dnl actually does work, even though we can't produce an executable without
+dnl more info about the target it's being compiled for. This only works
+dnl for the GNU C++ compiler.
+
+dnl Transform the name of the compiler to it's cross variant, unless
+dnl CXX is set. This is also what CXX gets set to in the generated
+dnl Makefile.
+if test x"${CXX}" = xc++ ; then
+ CXX=`echo gcc | sed -e "${program_transform_name}"`
+fi
+
+dnl Get G++'s full path to libgcc.a
+libgccpath=`${CXX} --print-libgcc`
+
+dnl If we don't have a path with libgcc.a on the end, this isn't G++.
+if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
+ ac_cv_prog_gxx=yes
+else
+ ac_cv_prog_gxx=no
+fi
+
+dnl If we are using G++, look for the files that need to exist if this
+dnl compiler works.
+if test x"${ac_cv_prog_gxx}" = xyes ; then
+ gccfiles=`echo $libgccpath | sed -e 's:/libgcc.a::'`
+ if test -f ${gccfiles}/specs -a -f ${gccfiles}/cpp -a -f ${gccfiles}/cc1plus; then
+ gccfiles=yes
+ else
+ gccfiles=no
+ fi
+ gcclibs=`echo $libgccpath | sed -e 's:lib/gcc-lib/::' -e 's:/libgcc.a::' -e 's,\(.*\)/.*,\1,g'`/lib
+ if test -d ${gcclibs}/ldscripts -a -f ${gcclibs}/libc.a -a -f ${gcclibs}/libstdc++.a ; then
+ gcclibs=yes
+ else
+ gcclibs=no
+ fi
+fi
+
+dnl If everything is OK, then we can safely assume the compiler works.
+if test x"${gccfiles}" = xno -o x"${gcclibs}" = xno; then
+ ac_cv_prog_cxx_works=no
+ AC_MSG_ERROR(${CXX} is a non-working cross compiler)
+else
+ ac_cv_prog_cxx_works=yes
+fi
+
+AC_LANG_RESTORE
+AC_MSG_RESULT($ac_cv_prog_cxx_works)
+if test x"$ac_cv_prog_cxx_works" = xno; then
+ AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
+fi
+AC_MSG_CHECKING([whether the G++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
+AC_MSG_RESULT($ac_cv_prog_cxx_cross)
+cross_compiling=$ac_cv_prog_cxx_cross
+AC_SUBST(CXX)
+])
+
+dnl ====================================================================
+dnl Find a working GCC cross compiler. This only works for the GNU gcc compiler.
+dnl This is based on the macros above for G++.
+AC_DEFUN(CYG_AC_PROG_CC_CROSS,
+[AC_BEFORE([$0], [AC_PROG_CCPP])
+AC_CHECK_PROGS(CC, cc, gcc)
+
+CYG_AC_PROG_GCC_WORKS
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+dnl Check whether -g works, even if CFLAGS is set, in case the package
+dnl plays around with CFLAGS (such as to build both debugging and
+dnl normal versions of a library), tasteless as that idea is.
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ AC_PROG_CC_G
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ elif test $ac_cv_prog_cc_g = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-O2"
+ fi
+else
+ GXX=
+ test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+])
+
+dnl See if the GCC compiler we found works.
+AC_DEFUN(CYG_AC_PROG_GCC_WORKS,
+[AC_MSG_CHECKING([whether the Gcc compiler ($CC $CFLAGS $LDFLAGS) actually works])
+AC_LANG_SAVE
+AC_LANG_C
+dnl Try a test case. We only compile, because it's close to impossible
+dnl to get a correct fully linked executable with a cross
+dnl compiler. For most cross compilers, this test is bogus. For G++,
+dnl we can use various other compile line options to get a decent idea
+dnl that the cross compiler actually does work, even though we can't
+dnl produce an executable without more info about the target it's
+dnl being compiled for. This only works for the GNU C++ compiler.
+
+dnl Transform the name of the compiler to it's cross variant, unless
+dnl CXX is set. This is also what CC gets set to in the generated Makefile.
+if test x"${CC}" = xcc ; then
+ CC=`echo gcc | sed -e "${program_transform_name}"`
+fi
+
+dnl Get Gcc's full path to libgcc.a
+libgccpath=`${CC} --print-libgcc`
+
+dnl If we don't have a path with libgcc.a on the end, this isn't G++.
+if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+
+dnl If we are using Gcc, look for the files that need to exist if this
+dnl compiler works.
+if test x"${ac_cv_prog_gcc}" = xyes ; then
+ gccfiles=`echo $libgccpath | sed -e 's:/libgcc.a::'`
+ if test -f ${gccfiles}/specs -a -f ${gccfiles}/cpp -a -f ${gccfiles}/cc1plus; then
+ gccfiles=yes
+ else
+ gccfiles=no
+ fi
+ gcclibs=`echo $libgccpath | sed -e 's:lib/gcc-lib/::' -e 's:/libgcc.a::' -e 's,\(.*\)/.*,\1,g'`/lib
+ if test -d ${gcclibs}/ldscripts -a -f ${gcclibs}/libc.a -a -f ${gcclibs}/libstdc++.a ; then
+ gcclibs=yes
+ else
+ gcclibs=no
+ fi
+fi
+
+dnl If everything is OK, then we can safely assume the compiler works.
+if test x"${gccfiles}" = xno -o x"${gcclibs}" = xno; then
+ ac_cv_prog_cc_works=no
+ AC_MSG_ERROR(${CC} is a non-working cross compiler)
+else
+ ac_cv_prog_cc_works=yes
+fi
+
+AC_LANG_RESTORE
+AC_MSG_RESULT($ac_cv_prog_cc_works)
+if test x"$ac_cv_prog_cc_works" = xno; then
+ AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
+fi
+AC_MSG_CHECKING([whether the Gcc compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
+AC_MSG_RESULT($ac_cv_prog_cc_cross)
+cross_compiling=$ac_cv_prog_cc_cross
+AC_SUBST(CC)
+])
+
+dnl ====================================================================
+dnl Find the BFD library in the build tree. This is used to access and
+dnl manipulate object or executable files.
+AC_DEFUN(CYG_AC_PATH_BFD, [
+AC_MSG_CHECKING(for the bfd header in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+dnl Look for the header file
+AC_CACHE_VAL(ac_cv_c_bfdh,[
+for i in $dirlist; do
+ if test -f "$i/bfd/bfd.h" ; then
+ ac_cv_c_bfdh=`(cd $i/bfd; pwd)`
+ break
+ fi
+done
+])
+if test x"${ac_cv_c_bfdh}" != x; then
+ BFDHDIR="-I${ac_cv_c_bfdh}"
+ AC_MSG_RESULT(${ac_cv_c_bfdh})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(BFDHDIR)
+
+dnl Look for the library
+AC_MSG_CHECKING(for the bfd library in the build tree)
+AC_CACHE_VAL(ac_cv_c_bfdlib,[
+for i in $dirlist; do
+ if test -f "$i/bfd/Makefile" ; then
+ ac_cv_c_bfdlib=`(cd $i/bfd; pwd)`
+ fi
+done
+])
+dnl We list two directories cause bfd now uses libtool
+if test x"${ac_cv_c_bfdlib}" != x; then
+ BFDLIB="-L${ac_cv_c_bfdlib} -L${ac_cv_c_bfdlib}/.libs"
+ AC_MSG_RESULT(${ac_cv_c_bfdlib})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(BFDLIB)
+])
+
+dnl ====================================================================
+dnl Find the libiberty library. This defines many commonly used C
+dnl functions that exists in various states based on the underlying OS.
+AC_DEFUN(CYG_AC_PATH_LIBERTY, [
+AC_MSG_CHECKING(for the liberty library in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_liberty,[
+for i in $dirlist; do
+ if test -f "$i/libiberty/Makefile" ; then
+ ac_cv_c_liberty=`(cd $i/libiberty; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_liberty}" != x; then
+ LIBERTY="-L${ac_cv_c_liberty}"
+ AC_MSG_RESULT(${ac_cv_c_liberty})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(LIBERTY)
+])
+
+dnl ====================================================================
+dnl Find the opcodes library. This is used to do dissasemblies.
+AC_DEFUN(CYG_AC_PATH_OPCODES, [
+AC_MSG_CHECKING(for the opcodes library in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_opc,[
+for i in $dirlist; do
+ if test -f "$i/opcodes/Makefile" ; then
+ ac_cv_c_opc=`(cd $i/opcodes; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_opc}" != x; then
+ OPCODESLIB="-L${ac_cv_c_opc}"
+ AC_MSG_RESULT(${ac_cv_c_opc})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(OPCODESLIB)
+])
+
+dnl ====================================================================
+dnl Look for the DejaGnu header file in the source tree. This file
+dnl defines the functions used to testing support.
+AC_DEFUN(CYG_AC_PATH_DEJAGNU, [
+AC_MSG_CHECKING(for the testing support files in the source tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_dejagnu,[
+for i in $dirlist; do
+ if test -f "$srcdir/$i/ecc/ecc/infra/testlib/current/include/dejagnu.h" ; then
+ ac_cv_c_dejagnu=`(cd $srcdir/$i/ecc/ecc/infra/testlib/current/include; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_dejagnu}" != x; then
+ DEJAGNUHDIR="-I${ac_cv_c_dejagnu}"
+ AC_MSG_RESULT(${ac_cv_c_dejagnu})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_CACHE_VAL(ac_cv_c_dejagnulib,[
+for i in $dirlist; do
+ if test -f "$srcdir/$i/infra/testlib/current/lib/hostutil.exp" ; then
+ ac_cv_c_dejagnulib=`(cd $srcdir/$i/infra/testlib/current/lib; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_dejagnulib}" != x; then
+ DEJAGNULIB="${ac_cv_c_dejagnulib}"
+else
+ DEJAGNULIB=""
+fi
+AC_MSG_CHECKING(for runtest in the source tree)
+AC_CACHE_VAL(ac_cv_c_runtest,[
+for i in $dirlist; do
+ if test -f "$srcdir/$i/dejagnu/runtest" ; then
+ ac_cv_c_runtest=`(cd $srcdir/$i/dejagnu; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_runtest}" != x; then
+ RUNTESTDIR="${ac_cv_c_runtest}"
+ AC_MSG_RESULT(${ac_cv_c_runtest})
+else
+ RUNTESTDIR=""
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(RUNTESTDIR)
+AC_SUBST(DEJAGNULIB)
+AC_SUBST(DEJAGNUHDIR)
+])
+
+dnl ====================================================================
+dnl Find the libintl library in the build tree. This is for
+dnl internationalization support.
+AC_DEFUN(CYG_AC_PATH_INTL, [
+AC_MSG_CHECKING(for the intl header in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+dnl Look for the header file
+AC_CACHE_VAL(ac_cv_c_intlh,[
+for i in $dirlist; do
+ if test -f "$i/intl/libintl.h" ; then
+ ac_cv_c_intlh=`(cd $i/intl; pwd)`
+ break
+ fi
+done
+])
+if test x"${ac_cv_c_intlh}" != x; then
+ INTLHDIR="-I${ac_cv_c_intlh}"
+ AC_MSG_RESULT(${ac_cv_c_intlh})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(INTLHDIR)
+
+dnl Look for the library
+AC_MSG_CHECKING(for the libintl library in the build tree)
+AC_CACHE_VAL(ac_cv_c_intllib,[
+for i in $dirlist; do
+ if test -f "$i/intl/Makefile" ; then
+ ac_cv_c_intllib=`(cd $i/intl; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_intllib}" != x; then
+ INTLLIB="-L${ac_cv_c_intllib} -lintl"
+ AC_MSG_RESULT(${ac_cv_c_intllib})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(INTLLIB)
+])
+
+dnl ====================================================================
+dnl Find the simulator library.
+AC_DEFUN(CYG_AC_PATH_SIM, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.. ../../../../../../../../../.."
+case "$target_cpu" in
+ powerpc) target_dir=ppc ;;
+ sparc*) target_dir=erc32 ;;
+ mips*) target_dir=mips ;;
+ *) target_dir=$target_cpu ;;
+esac
+dnl First look for the header file
+AC_MSG_CHECKING(for the simulator header file)
+AC_CACHE_VAL(ac_cv_c_simh,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/include/remote-sim.h" ; then
+ ac_cv_c_simh=`(cd ${srcdir}/$i/include; pwd)`
+ break
+ fi
+done
+])
+if test x"${ac_cv_c_simh}" != x; then
+ SIMHDIR="-I${ac_cv_c_simh}"
+ AC_MSG_RESULT(${ac_cv_c_simh})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(SIMHDIR)
+
+dnl See whether it's a devo or Foundry branch simulator
+AC_MSG_CHECKING(Whether this is a devo simulator )
+AC_CACHE_VAL(ac_cv_c_simdevo,[
+ CPPFLAGS="$CPPFLAGS $SIMHDIR"
+ AC_EGREP_HEADER([SIM_DESC sim_open.*struct _bfd], remote-sim.h,
+ ac_cv_c_simdevo=yes,
+ ac_cv_c_simdevo=no)
+])
+if test x"$ac_cv_c_simdevo" = x"yes" ; then
+ AC_DEFINE(HAVE_DEVO_SIM)
+fi
+AC_MSG_RESULT(${ac_cv_c_simdevo})
+AC_SUBST(HAVE_DEVO_SIM)
+
+dnl Next look for the library
+AC_MSG_CHECKING(for the simulator library)
+AC_CACHE_VAL(ac_cv_c_simlib,[
+for i in $dirlist; do
+ if test -f "$i/sim/$target_dir/Makefile" ; then
+ ac_cv_c_simlib=`(cd $i/sim/$target_dir; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_simlib}" != x; then
+ SIMLIB="-L${ac_cv_c_simlib}"
+else
+ AC_MSG_RESULT(none)
+ dnl FIXME: this is kinda bogus, cause umtimately the TM will build
+ dnl all the libraries for several architectures. But for now, this
+ dnl will work till then.
+dnl AC_MSG_CHECKING(for the simulator installed with the compiler libraries)
+ dnl Transform the name of the compiler to it's cross variant, unless
+ dnl CXX is set. This is also what CXX gets set to in the generated
+ dnl Makefile.
+ CROSS_GCC=`echo gcc | sed -e "s/^/$target/"`
+
+ dnl Get G++'s full path to libgcc.a
+changequote(,)
+ gccpath=`${CROSS_GCC} --print-libgcc | sed -e 's:[a-z0-9A-Z\.\-]*/libgcc.a::' -e 's:lib/gcc-lib/::'`lib
+changequote([,])
+ if test -f $gccpath/libsim.a -o -f $gccpath/libsim.so ; then
+ ac_cv_c_simlib="$gccpath/"
+ SIMLIB="-L${ac_cv_c_simlib}"
+ AC_MSG_RESULT(${ac_cv_c_simlib})
+ else
+ AM_CONDITIONAL(PSIM, test x$psim = xno)
+ SIMLIB=""
+ AC_MSG_RESULT(none)
+dnl ac_cv_c_simlib=none
+ fi
+fi
+AC_SUBST(SIMLIB)
+])
+
+dnl ====================================================================
+dnl Find the libiberty library.
+AC_DEFUN(CYG_AC_PATH_LIBIBERTY, [
+AC_MSG_CHECKING(for the libiberty library in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_libib,[
+for i in $dirlist; do
+ if test -f "$i/libiberty/Makefile" ; then
+ ac_cv_c_libib=`(cd $i/libiberty/; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_libib}" != x; then
+ LIBIBERTY="-L${ac_cv_c_libib}"
+ AC_MSG_RESULT(${ac_cv_c_libib})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(LIBIBERTY)
+])
+
+dnl ====================================================================
+AC_DEFUN(CYG_AC_PATH_DEVO, [
+AC_MSG_CHECKING(for devo headers in the source tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_devoh,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/include/remote-sim.h" ; then
+ ac_cv_c_devoh=`(cd ${srcdir}/$i/include; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_devoh}" != x; then
+ DEVOHDIR="-I${ac_cv_c_devoh}"
+ AC_MSG_RESULT(${ac_cv_c_devoh})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(DEVOHDIR)
+])
+
+dnl ====================================================================
+dnl find the IDE library and headers.
+AC_DEFUN(CYG_AC_PATH_IDE, [
+AC_MSG_CHECKING(for IDE headers in the source tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+IDEHDIR=
+IDELIB=
+AC_CACHE_VAL(ac_cv_c_ideh,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/libide/src/event.h" ; then
+ ac_cv_c_ideh=`(cd ${srcdir}/$i/libide/src; pwd)`;
+ fi
+done
+])
+if test x"${ac_cv_c_ideh}" != x; then
+ IDEHDIR="-I${ac_cv_c_ideh}"
+ AC_MSG_RESULT(${ac_cv_c_ideh})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_MSG_CHECKING(for LIBIDE TCL headers in the source tree)
+AC_CACHE_VAL(ac_cv_c_idetclh,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/libidetcl/src/idetcl.h" ; then
+ ac_cv_c_idetclh=`(cd ${srcdir}/$i/libidetcl/src; pwd)`;
+ fi
+done
+])
+if test x"${ac_cv_c_idetclh}" != x; then
+ IDEHDIR="${IDEHDIR} -I${ac_cv_c_idetclh}"
+ AC_MSG_RESULT(${ac_cv_c_idetclh})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_MSG_CHECKING(for IDE headers in the build tree)
+AC_CACHE_VAL(ac_cv_c_ideh2,[
+for i in $dirlist; do
+ if test -f "$i/libide/src/Makefile" ; then
+ ac_cv_c_ideh2=`(cd $i/libide/src; pwd)`;
+ fi
+done
+])
+if test x"${ac_cv_c_ideh2}" != x; then
+ IDEHDIR="${IDEHDIR} -I${ac_cv_c_ideh2}"
+ AC_MSG_RESULT(${ac_cv_c_ideh2})
+else
+ AC_MSG_RESULT(none)
+fi
+
+dnl look for the library
+AC_MSG_CHECKING(for IDE library)
+AC_CACHE_VAL(ac_cv_c_idelib,[
+if test x"${ac_cv_c_idelib}" = x ; then
+ for i in $dirlist; do
+ if test -f "$i/libide/src/Makefile" ; then
+ ac_cv_c_idelib=`(cd $i/libide/src; pwd)`
+ break
+ fi
+ done
+fi])
+if test x"${ac_cv_c_idelib}" != x ; then
+ IDELIB="-L${ac_cv_c_idelib}"
+ AC_MSG_RESULT(${ac_cv_c_idelib})
+else
+ AC_MSG_RESULT(none)
+fi
+
+dnl find libiddetcl.a if it exists
+AC_MSG_CHECKING(for IDE TCL library)
+AC_CACHE_VAL(ac_cv_c_idetcllib,[
+if test x"${ac_cv_c_idetcllib}" = x ; then
+ for i in $dirlist; do
+ if test -f "$i/libidetcl/src/Makefile" ; then
+ ac_cv_c_idetcllib=`(cd $i/libidetcl/src; pwd)`
+ break
+ fi
+ done
+fi
+])
+if test x"${ac_cv_c_idetcllib}" != x ; then
+ IDELIB="${IDELIB} -L${ac_cv_c_idetcllib}"
+ IDETCLLIB="-lidetcl"
+ AC_MSG_RESULT(${ac_cv_c_idetcllib})
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(IDEHDIR)
+AC_SUBST(IDELIB)
+AC_SUBST(IDETCLLIB)
+])
+
+dnl ====================================================================
+dnl Find all the ILU headers and libraries
+AC_DEFUN(CYG_AC_PATH_ILU, [
+AC_MSG_CHECKING(for ILU kernel headers in the source tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_iluh,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/ilu/runtime/kernel/method.h" ; then
+ ac_cv_c_iluh=`(cd ${srcdir}/$i/ilu/runtime/kernel; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_iluh}" != x; then
+ ILUHDIR="-I${ac_cv_c_iluh}"
+ AC_MSG_RESULT(${ac_cv_c_iluh})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_MSG_CHECKING(for ILU kernel headers in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+AC_CACHE_VAL(ac_cv_c_iluh5,[
+for i in $dirlist; do
+ if test -f "$i/ilu/runtime/kernel/iluconf.h" ; then
+ ac_cv_c_iluh5=`(cd $i/ilu/runtime/kernel; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_iluh5}" != x; then
+ ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh5}"
+ AC_MSG_RESULT(${ac_cv_c_iluh5})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_MSG_CHECKING(for ILU C++ headers in the source tree)
+AC_CACHE_VAL(ac_cv_c_iluh2,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/ilu/stubbers/cpp/resource.h" ; then
+ ac_cv_c_iluh2=`(cd ${srcdir}/$i/ilu/stubbers/cpp; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_iluh2}" != x; then
+ ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh2}"
+ AC_MSG_RESULT(${ac_cv_c_iluh2})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_MSG_CHECKING(for ILU C headers)
+AC_CACHE_VAL(ac_cv_c_iluh3,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/ilu/stubbers/c/resource.h" ; then
+ ac_cv_c_iluh3=`(cd ${srcdir}/$i/ilu/stubbers/c ; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_iluh3}" != x; then
+ ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh3}"
+ AC_MSG_RESULT(${ac_cv_c_iluh3})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_MSG_CHECKING(for ILU C runtime headers)
+AC_CACHE_VAL(ac_cv_c_iluh4,[
+for i in $dirlist; do
+ if test -f "${srcdir}/$i/ilu/runtime/c/ilucstub.h" ; then
+ ac_cv_c_iluh4=`(cd ${srcdir}/$i/ilu/runtime/c ; pwd)`
+ fi
+done
+])
+if test x"${ac_cv_c_iluh4}" != x; then
+ ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh4}"
+ AC_MSG_RESULT(${ac_cv_c_iluh4})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_CACHE_VAL(ac_cv_c_ilupath,[
+for i in $dirlist; do
+ if test -f "$i/ilu/Makefile" ; then
+ ac_cv_c_ilupath=`(cd $i/ilu; pwd)`
+ break
+ fi
+done
+])
+ILUTOP=${ac_cv_c_ilupath}
+
+AC_MSG_CHECKING(for the ILU library in the build tree)
+AC_CACHE_VAL(ac_cv_c_ilulib,[
+if test -f "$ac_cv_c_ilupath/runtime/kernel/Makefile" ; then
+ ac_cv_c_ilulib=`(cd $ac_cv_c_ilupath/runtime/kernel; pwd)`
+ AC_MSG_RESULT(found ${ac_cv_c_ilulib}/libilu.a)
+else
+ AC_MSG_RESULT(no)
+fi])
+
+AC_MSG_CHECKING(for the ILU C++ bindings library in the build tree)
+AC_CACHE_VAL(ac_cv_c_ilulib2,[
+if test -f "$ac_cv_c_ilupath/runtime/cpp/Makefile" ; then
+ ac_cv_c_ilulib2=`(cd $ac_cv_c_ilupath/runtime/cpp; pwd)`
+ AC_MSG_RESULT(found ${ac_cv_c_ilulib2}/libilu-c++.a)
+else
+ AC_MSG_RESULT(no)
+fi])
+
+AC_MSG_CHECKING(for the ILU C bindings library in the build tree)
+AC_CACHE_VAL(ac_cv_c_ilulib3,[
+if test -f "$ac_cv_c_ilupath/runtime/c/Makefile" ; then
+ ac_cv_c_ilulib3=`(cd $ac_cv_c_ilupath/runtime/c; pwd)`
+ AC_MSG_RESULT(found ${ac_cv_c_ilulib3}/libilu-c.a)
+else
+ AC_MSG_RESULT(no)
+fi])
+
+AC_MSG_CHECKING(for the ILU Tk bindings library in the build tree)
+AC_CACHE_VAL(ac_cv_c_ilulib4,[
+if test -f "$ac_cv_c_ilupath/runtime/mainloop/Makefile" ; then
+ ac_cv_c_ilulib4=`(cd $ac_cv_c_ilupath/runtime/mainloop; pwd)`
+ AC_MSG_RESULT(found ${ac_cv_c_ilulib4}/libilu-tk.a)
+else
+ AC_MSG_RESULT(no)
+fi])
+
+if test x"${ac_cv_c_ilulib}" = x -a x"${ac_cv_c_ilulib2}" = x; then
+ ILUHDIR=""
+fi
+
+if test x"${ac_cv_c_ilulib}" != x -a x"${ac_cv_c_ilulib2}" != x; then
+ ILULIB="-L${ac_cv_c_ilulib} -L${ac_cv_c_ilulib2} -L${ac_cv_c_ilulib3} -L${ac_cv_c_ilulib4}"
+else
+ ILULIB=""
+fi
+
+if test x"${ILULIB}" = x; then
+ AC_MSG_CHECKING(for ILU libraries installed with the compiler)
+ AC_CACHE_VAL(ac_cv_c_ilulib5,[
+ NATIVE_GCC=`echo gcc | sed -e "${program_transform_name}"`
+
+ dnl Get G++'s full path to it's libraries
+ ac_cv_c_ilulib5=`${NATIVE_GCC} --print-libgcc | sed -e 's:lib/gcc-lib/.*::'`lib
+ if test -f $ac_cv_c_ilulib5/libilu-c.a -o -f $ac_cv_c_ilulib5/libilu-c.so ; then
+ if test x"${ILUHDIR}" = x; then
+ ILUHDIR="-I${ac_cv_c_ilulib5}/../include"
+ fi
+ ILULIB="-L${ac_cv_c_ilulib5}"
+ AC_MSG_RESULT(${ac_cv_c_ilulib5})
+ else
+ ac_cv_c_ilulib=none
+ AC_MSG_RESULT(none)
+ fi
+fi])
+AC_SUBST(ILUHDIR)
+AC_SUBST(ILULIB)
+AC_SUBST(ILUTOP)
+])
+
+dnl ====================================================================
+dnl This defines the byte order for the host. We can't use
+dnl AC_C_BIGENDIAN, cause we want to create a config file and
+dnl substitue the real value, so the header files work right
+AC_DEFUN(CYG_AC_C_ENDIAN, [
+AC_MSG_CHECKING(to see if this is a little endian host)
+AC_CACHE_VAL(ac_cv_c_little_endian, [
+ac_cv_c_little_endian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if !BYTE_ORDER || !_BIG_ENDIAN || !_LITTLE_ENDIAN
+ bogus endian macros
+#endif], [# It does; now see whether it defined to _LITTLE_ENDIAN or not.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if BYTE_ORDER != _LITTLE_ENDIAN
+ not big endian
+#endif], ac_cv_c_little_endian=yes, ac_cv_c_little_endian=no)
+])
+if test ${ac_cv_c_little_endian} = unknown; then
+old_cflags=$CFLAGS
+CFLAGS=-g
+AC_TRY_RUN([
+main () {
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long l;
+ char c[sizeof (long)];
+ } u;
+ u.l = 1;
+ exit (u.c[0] == 1);
+}],
+ac_cv_c_little_endian=no,
+ac_cv_c_little_endian=yes,[
+dnl Yes, this is ugly, and only used for a canadian cross anyway. This
+dnl is just to keep configure from stopping here.
+case "${host}" in
+changequote(,)
+ i[3456]86-*-*) ac_cv_c_little_endian=yes ;;
+ sparc*-*-*) ac_cv_c_little_endian=no ;;
+changequote([,])
+ *) AC_MSG_WARN(Can't cross compile this test) ;;
+esac])
+CFLAGS=$old_cflags
+fi])
+
+if test x"${ac_cv_c_little_endian}" = xyes; then
+ AC_DEFINE(LITTLE_ENDIAN_HOST)
+ ENDIAN="CYG_LSBFIRST";
+else
+ ENDIAN="CYG_MSBFIRST";
+fi
+AC_MSG_RESULT(${ac_cv_c_little_endian})
+AC_SUBST(ENDIAN)
+])
+
+dnl ====================================================================
+dnl Look for the path to libgcc, so we can use it to directly link
+dnl in libgcc.a with LD.
+AC_DEFUN(CYG_AC_PATH_LIBGCC,
+[AC_MSG_CHECKING([Looking for the path to libgcc.a])
+AC_LANG_SAVE
+AC_LANG_C
+
+dnl Get Gcc's full path to libgcc.a
+libgccpath=`${CC} --print-libgcc`
+
+dnl If we don't have a path with libgcc.a on the end, this isn't G++.
+if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+
+dnl
+if test x"${ac_cv_prog_gcc}" = xyes ; then
+ gccpath=`echo $libgccpath | sed -e 's:/libgcc.a::'`
+ LIBGCC="-L${gccpath}"
+ AC_MSG_RESULT(${gccpath})
+else
+ LIBGCC=""
+ AC_MSG_ERROR(Not using gcc)
+fi
+
+AC_LANG_RESTORE
+AC_SUBST(LIBGCC)
+])
+
+dnl ====================================================================
+dnl Ok, lets find the tcl source trees so we can use the headers
+dnl Warning: transition of version 9 to 10 will break this algorithm
+dnl because 10 sorts before 9. We also look for just tcl. We have to
+dnl be careful that we don't match stuff like tclX by accident.
+dnl the alternative search directory is involked by --with-tclinclude
+AC_DEFUN(CYG_AC_PATH_TCL, [
+ CYG_AC_PATH_TCLH
+ CYG_AC_PATH_TCLCONFIG
+ CYG_AC_LOAD_TCLCONFIG
+])
+AC_DEFUN(CYG_AC_PATH_TCLH, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+no_tcl=true
+AC_MSG_CHECKING(for Tcl headers in the source tree)
+AC_ARG_WITH(tclinclude, [ --with-tclinclude directory where tcl headers are], with_tclinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_tclh,[
+dnl first check to see if --with-tclinclude was specified
+if test x"${with_tclinclude}" != x ; then
+ if test -f ${with_tclinclude}/tcl.h ; then
+ ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
+ elif test -f ${with_tclinclude}/generic/tcl.h ; then
+ ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
+ else
+ AC_MSG_ERROR([${with_tclinclude} directory doesn't contain headers])
+ fi
+fi
+
+dnl next check if it came with Tcl configuration file
+if test x"${ac_cv_c_tclconfig}" != x ; then
+ for i in $dirlist; do
+ if test -f $ac_cv_c_tclconfig/$i/generic/tcl.h ; then
+ ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/$i/generic; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_tclh}" = x ; then
+ dnl find the top level Tcl source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/tcl* 2>/dev/null`" ; then
+ tclpath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Tcl source dir. We do it this way, cause there
+ dnl might be multiple version of Tcl, and we want the most recent one.
+ for i in `ls -dr $tclpath/tcl* 2>/dev/null ` ; do
+ if test -f $i/generic/tcl.h ; then
+ ac_cv_c_tclh=`(cd $i/generic; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl check if its installed with the compiler
+if test x"${ac_cv_c_tclh}" = x ; then
+ dnl Get the path to the compiler
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/include
+ if test -f $ccpath/tcl.h; then
+ ac_cv_c_tclh=$ccpath
+ fi
+fi
+
+dnl see if one is installed
+if test x"${ac_cv_c_tclh}" = x ; then
+ AC_MSG_RESULT(none)
+ AC_CHECK_HEADER(tcl.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
+else
+ AC_MSG_RESULT(${ac_cv_c_tclh})
+fi
+])
+ TCLHDIR=""
+if test x"${ac_cv_c_tclh}" = x ; then
+ AC_MSG_ERROR([Can't find any Tcl headers])
+fi
+if test x"${ac_cv_c_tclh}" != x ; then
+ no_tcl=""
+ if test x"${ac_cv_c_tclh}" != x"installed" ; then
+ if test x"${CC}" = xcl ; then
+ tmp="`cygpath --windows ${ac_cv_c_tclh}`"
+ ac_cv_c_tclh="`echo $tmp | sed -e s#\\\\\\\\#/#g`"
+ fi
+ AC_MSG_RESULT(${ac_cv_c_tclh})
+ TCLHDIR="-I${ac_cv_c_tclh}"
+ fi
+fi
+
+AC_SUBST(TCLHDIR)
+])
+
+dnl ====================================================================
+dnl Ok, lets find the tcl configuration
+AC_DEFUN(CYG_AC_PATH_TCLCONFIG, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+dnl First, look for one uninstalled.
+dnl the alternative search directory is invoked by --with-tclconfig
+if test x"${no_tcl}" = x ; then
+ dnl we reset no_tcl in case something fails here
+ no_tcl=true
+ AC_ARG_WITH(tclconfig, [ --with-tclconfig directory containing tcl configuration (tclConfig.sh)],
+ with_tclconfig=${withval})
+ AC_MSG_CHECKING([for Tcl configuration script])
+ AC_CACHE_VAL(ac_cv_c_tclconfig,[
+
+ dnl First check to see if --with-tclconfig was specified.
+ if test x"${with_tclconfig}" != x ; then
+ if test -f "${with_tclconfig}/tclConfig.sh" ; then
+ ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
+ else
+ AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
+ fi
+ fi
+
+ dnl next check if it came with Tcl configuration file in the source tree
+ if test x"${ac_cv_c_tclconfig}" = x ; then
+ for i in $dirlist; do
+ if test -f $srcdir/$i/unix/tclConfig.sh ; then
+ ac_cv_c_tclconfig=`(cd $srcdir/$i/unix; pwd)`
+ break
+ fi
+ done
+ fi
+ dnl check in a few other locations
+ if test x"${ac_cv_c_tclconfig}" = x ; then
+ dnl find the top level Tcl source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $i/tcl* 2>/dev/null`" ; then
+ tclconfpath=$i
+ break
+ fi
+ done
+
+ dnl find the exact Tcl dir. We do it this way, cause there
+ dnl might be multiple version of Tcl, and we want the most recent one.
+ for i in `ls -dr $tclconfpath/tcl* 2>/dev/null ` ; do
+ if test -f $i/unix/tclConfig.sh ; then
+ ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
+ break
+ fi
+ done
+ fi
+
+ dnl Check to see if it's installed. We have to look in the $CC path
+ dnl to find it, cause our $prefix may not match the compilers.
+ if test x"${ac_cv_c_tclconfig}" = x ; then
+ dnl Get the path to the compiler
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/lib
+ if test -f $ccpath/tclConfig.sh; then
+ ac_cv_c_tclconfig=$ccpath
+ fi
+ fi
+ ]) dnl end of cache_val
+
+ if test x"${ac_cv_c_tclconfig}" = x ; then
+ TCLCONFIG=""
+ AC_MSG_WARN(Can't find Tcl configuration definitions)
+ else
+ no_tcl=""
+ TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
+ AC_MSG_RESULT(${TCLCONFIG})
+ fi
+fi
+AC_SUBST(TCLCONFIG)
+])
+
+dnl Defined as a separate macro so we don't have to cache the values
+dnl from PATH_TCLCONFIG (because this can also be cached).
+AC_DEFUN(CYG_AC_LOAD_TCLCONFIG, [
+ . $TCLCONFIG
+
+dnl AC_SUBST(TCL_VERSION)
+dnl AC_SUBST(TCL_MAJOR_VERSION)
+dnl AC_SUBST(TCL_MINOR_VERSION)
+dnl AC_SUBST(TCL_CC)
+ AC_SUBST(TCL_DEFS)
+
+dnl not used, don't export to save symbols
+ AC_SUBST(TCL_LIB_FILE)
+ AC_SUBST(TCL_LIB_FULL_PATH)
+ AC_SUBST(TCL_LIBS)
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TCL_PREFIX)
+
+ AC_SUBST(TCL_CFLAGS)
+
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TCL_EXEC_PREFIX)
+
+ AC_SUBST(TCL_SHLIB_CFLAGS)
+ AC_SUBST(TCL_SHLIB_LD)
+dnl don't export, not used outside of configure
+dnl AC_SUBST(TCL_SHLIB_LD_LIBS)
+dnl AC_SUBST(TCL_SHLIB_SUFFIX)
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TCL_DL_LIBS)
+ AC_SUBST(TCL_LD_FLAGS)
+ AC_SUBST(TCL_LD_SEARCH_FLAGS)
+dnl don't export, not used outside of configure
+dnl AC_SUBST(TCL_COMPAT_OBJS)
+ AC_SUBST(TCL_RANLIB)
+ AC_SUBST(TCL_BUILD_LIB_SPEC)
+ AC_SUBST(TCL_LIB_SPEC)
+dnl AC_SUBST(TCL_LIB_VERSIONS_OK)
+
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TCL_SHARED_LIB_SUFFIX)
+
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
+])
+
+dnl ====================================================================
+AC_DEFUN(CYG_AC_PATH_TK, [
+ CYG_AC_PATH_TKH
+ CYG_AC_PATH_TKCONFIG
+ CYG_AC_LOAD_TKCONFIG
+])
+AC_DEFUN(CYG_AC_PATH_TKH, [
+#
+# Ok, lets find the tk source trees so we can use the headers
+# If the directory (presumably symlink) named "tk" exists, use that one
+# in preference to any others. Same logic is used when choosing library
+# and again with Tcl. The search order is the best place to look first, then in
+# decreasing significance. The loop breaks if the trigger file is found.
+# Note the gross little conversion here of srcdir by cd'ing to the found
+# directory. This converts the path from a relative to an absolute, so
+# recursive cache variables for the path will work right. We check all
+# the possible paths in one loop rather than many seperate loops to speed
+# things up.
+# the alternative search directory is involked by --with-tkinclude
+#
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+no_tk=true
+AC_MSG_CHECKING(for Tk headers in the source tree)
+AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where tk headers are], with_tkinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_tkh,[
+dnl first check to see if --with-tkinclude was specified
+if test x"${with_tkinclude}" != x ; then
+ if test -f ${with_tkinclude}/tk.h ; then
+ ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
+ elif test -f ${with_tkinclude}/generic/tk.h ; then
+ ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
+ else
+ AC_MSG_ERROR([${with_tkinclude} directory doesn't contain headers])
+ fi
+fi
+
+dnl next check if it came with Tk configuration file
+if test x"${ac_cv_c_tkconfig}" != x ; then
+ for i in $dirlist; do
+ if test -f $ac_cv_c_tkconfig/$i/generic/tk.h ; then
+ ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/$i/generic; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_tkh}" = x ; then
+ dnl find the top level Tk source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/tk* 2>/dev/null`" ; then
+ tkpath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Tk source dir. We do it this way, cause there
+ dnl might be multiple version of Tk, and we want the most recent one.
+ for i in `ls -dr $tkpath/tk* 2>/dev/null ` ; do
+ if test -f $i/generic/tk.h ; then
+ ac_cv_c_tkh=`(cd $i/generic; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl see if one is installed
+if test x"${ac_cv_c_tkh}" = x ; then
+ AC_MSG_RESULT(none)
+ dnl Get the path to the compiler. We do it this way instead of using
+ dnl AC_CHECK_HEADER, cause this doesn't depend in having X configured.
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/include
+ if test -f $ccpath/tk.h; then
+ ac_cv_c_tkh=$ccpath
+ fi
+else
+ AC_MSG_RESULT(${ac_cv_c_tkh})
+fi
+])
+ TKHDIR=""
+if test x"${ac_cv_c_tkh}" = x ; then
+ AC_MSG_ERROR([Can't find any Tk headers])
+fi
+if test x"${ac_cv_c_tkh}" != x ; then
+ no_tk=""
+ if test x"${ac_cv_c_tkh}" != x"installed" ; then
+ if test x"${CC}" = xcl ; then
+ tmp="`cygpath --windows ${ac_cv_c_tkh}`"
+ ac_cv_c_tkh="`echo $tmp | sed -e s#\\\\\\\\#/#g`"
+ fi
+ AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
+ TKHDIR="-I${ac_cv_c_tkh}"
+ fi
+fi
+
+AC_SUBST(TKHDIR)
+])
+
+AC_DEFUN(CYG_AC_PATH_TKCONFIG, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+dnl First, look for one uninstalled.
+dnl the alternative search directory is invoked by --with-tkconfig
+if test x"${no_tk}" = x ; then
+ dnl we reset no_tk in case something fails here
+ no_tk=true
+ AC_ARG_WITH(tkconfig, [ --with-tkconfig directory containing tk configuration (tkConfig.sh)],
+ with_tkconfig=${withval})
+ AC_MSG_CHECKING([for Tk configuration script])
+ AC_CACHE_VAL(ac_cv_c_tkconfig,[
+
+ dnl First check to see if --with-tkconfig was specified.
+ if test x"${with_tkconfig}" != x ; then
+ if test -f "${with_tkconfig}/tkConfig.sh" ; then
+ ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
+ else
+ AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
+ fi
+ fi
+
+ dnl next check if it came with Tk configuration file in the source tree
+ if test x"${ac_cv_c_tkconfig}" = x ; then
+ for i in $dirlist; do
+ if test -f $srcdir/$i/unix/tkConfig.sh ; then
+ ac_cv_c_tkconfig=`(cd $srcdir/$i/unix; pwd)`
+ break
+ fi
+ done
+ fi
+ dnl check in a few other locations
+ if test x"${ac_cv_c_tkconfig}" = x ; then
+ dnl find the top level Tk source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $i/tk* 2>/dev/null`" ; then
+ tkconfpath=$i
+ break
+ fi
+ done
+
+ dnl find the exact Tk dir. We do it this way, cause there
+ dnl might be multiple version of Tk, and we want the most recent one.
+ for i in `ls -dr $tkconfpath/tk* 2>/dev/null ` ; do
+ if test -f $i/unix/tkConfig.sh ; then
+ ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
+ break
+ fi
+ done
+ fi
+
+ dnl Check to see if it's installed. We have to look in the $CC path
+ dnl to find it, cause our $prefix may not match the compilers.
+ if test x"${ac_cv_c_tkconfig}" = x ; then
+ dnl Get the path to the compiler
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/lib
+ if test -f $ccpath/tkConfig.sh; then
+ ac_cv_c_tkconfig=$ccpath
+ fi
+ fi
+ ]) dnl end of cache_val
+
+ if test x"${ac_cv_c_tkconfig}" = x ; then
+ TKCONFIG=""
+ AC_MSG_WARN(Can't find Tk configuration definitions)
+ else
+ no_tk=""
+ TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
+ AC_MSG_RESULT(${TKCONFIG})
+ fi
+fi
+AC_SUBST(TKCONFIG)
+])
+
+dnl Defined as a separate macro so we don't have to cache the values
+dnl from PATH_TKCONFIG (because this can also be cached).
+AC_DEFUN(CYG_AC_LOAD_TKCONFIG, [
+ if test -f "$TKCONFIG" ; then
+ . $TKCONFIG
+ fi
+
+ AC_SUBST(TK_VERSION)
+dnl not actually used, don't export to save symbols
+dnl AC_SUBST(TK_MAJOR_VERSION)
+dnl AC_SUBST(TK_MINOR_VERSION)
+ AC_SUBST(TK_DEFS)
+
+dnl not used, don't export to save symbols
+ AC_SUBST(TK_LIB_FILE)
+ AC_SUBST(TK_LIB_FULL_PATH)
+ AC_SUBST(TK_LIBS)
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TK_PREFIX)
+
+dnl not used, don't export to save symbols
+dnl AC_SUBST(TK_EXEC_PREFIX)
+ AC_SUBST(TK_BUILD_INCLUDES)
+ AC_SUBST(TK_XINCLUDES)
+ AC_SUBST(TK_XLIBSW)
+ AC_SUBST(TK_BUILD_LIB_SPEC)
+ AC_SUBST(TK_LIB_SPEC)
+])
+
+dnl ====================================================================
+dnl Ok, lets find the itcl source trees so we can use the headers
+dnl the alternative search directory is involked by --with-itclinclude
+AC_DEFUN(CYG_AC_PATH_ITCL, [
+ CYG_AC_PATH_ITCLH
+ CYG_AC_PATH_ITCLLIB
+ CYG_AC_PATH_ITCLSH
+ CYG_AC_PATH_ITCLMKIDX
+])
+AC_DEFUN(CYG_AC_PATH_ITCLH, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+no_itcl=true
+AC_MSG_CHECKING(for Itcl headers in the source tree)
+AC_ARG_WITH(itclinclude, [ --with-itclinclude directory where itcl headers are], with_itclinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_itclh,[
+dnl first check to see if --with-itclinclude was specified
+if test x"${with_itclinclude}" != x ; then
+ if test -f ${with_itclinclude}/itcl.h ; then
+ ac_cv_c_itclh=`(cd ${with_itclinclude}; pwd)`
+ elif test -f ${with_itclinclude}/src/itcl.h ; then
+ ac_cv_c_itclh=`(cd ${with_itclinclude}/src; pwd)`
+ else
+ AC_MSG_ERROR([${with_itclinclude} directory doesn't contain headers])
+ fi
+fi
+
+dnl next check if it came with Itcl configuration file
+if test x"${ac_cv_c_itclconfig}" != x ; then
+ for i in $dirlist; do
+ if test -f $ac_cv_c_itclconfig/$i/src/itcl.h ; then
+ ac_cv_c_itclh=`(cd $ac_cv_c_itclconfig/$i/src; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_itclh}" = x ; then
+ dnl find the top level Itcl source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
+ itclpath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Itcl source dir. We do it this way, cause there
+ dnl might be multiple version of Itcl, and we want the most recent one.
+ for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
+ if test -f $i/src/itcl.h ; then
+ ac_cv_c_itclh=`(cd $i/src; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl see if one is installed
+if test x"${ac_cv_c_itclh}" = x ; then
+ AC_MSG_RESULT(none)
+ AC_CHECK_HEADER(itcl.h, ac_cv_c_itclh=installed, ac_cv_c_itclh="")
+else
+ AC_MSG_RESULT(${ac_cv_c_itclh})
+fi
+])
+ ITCLHDIR=""
+if test x"${ac_cv_c_itclh}" = x ; then
+ AC_MSG_ERROR([Can't find any Itcl headers])
+fi
+if test x"${ac_cv_c_itclh}" != x ; then
+ no_itcl=""
+ if test x"${ac_cv_c_itclh}" != x"installed" ; then
+ AC_MSG_RESULT(${ac_cv_c_itclh})
+ ITCLHDIR="-I${ac_cv_c_itclh}"
+ fi
+fi
+
+AC_SUBST(ITCLHDIR)
+])
+
+dnl Ok, lets find the itcl library
+dnl First, look for one uninstalled.
+dnl the alternative search directory is invoked by --with-itcllib
+AC_DEFUN(CYG_AC_PATH_ITCLLIB, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+if test x"${no_itcl}" = x ; then
+ dnl we reset no_itcl incase something fails here
+ no_itcl=true
+ AC_ARG_WITH(itcllib,
+ [ --with-itcllib directory where the itcl library is],
+ with_itcllib=${withval})
+ AC_MSG_CHECKING([for Itcl library])
+ AC_CACHE_VAL(ac_cv_c_itcllib,[
+ dnl First check to see if --with-itcllib was specified.
+ if test x"${with_itcllib}" != x ; then
+ if test -f "${with_itcllib}/libitcl$TCL_SHARED_LIB_SUFFIX" ; then
+ ac_cv_c_itcllib=`(cd ${with_itcllib}; pwd)`/libitcl$TCL_SHARED_LIB_SUFFIX
+ else
+ if test -f "${with_itcllib}/libitcl$TCL_UNSHARED_LIB_SUFFIX"; then
+ ac_cv_c_itcllib=`(cd ${with_itcllib}; pwd)`/libitcl$TCL_UNSHARED_LIB_SUFFIX
+ fi
+ fi
+ fi
+ dnl then check for a Itcl library. Since these are uninstalled,
+ dnl use the simple lib name root.
+ if test x"${ac_cv_c_itcllib}" = x ; then
+ dnl find the top level Itcl build directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $i/itcl* 2>/dev/null`" ; then
+ itclpath=$i/itcl
+ break
+ fi
+ done
+ dnl Itcl 7.5 and greater puts library in subdir. Look there first.
+ if test -f "$itclpath/src/libitcl.$TCL_SHLIB_SUFFIX" ; then
+ ac_cv_c_itcllib=`(cd $itclpath/src; pwd)`
+ elif test -f "$itclpath/src/libitcl.a"; then
+ ac_cv_c_itcllib=`(cd $itclpath/src; pwd)`
+ fi
+ fi
+ dnl check in a few other private locations
+ if test x"${ac_cv_c_itcllib}" = x ; then
+ for i in ${dirlist}; do
+ if test -n "`ls -dr ${srcdir}/$i/itcl* 2>/dev/null`" ; then
+ itclpath=${srcdir}/$i
+ break
+ fi
+ done
+ for i in `ls -dr ${itclpath}/itcl* 2>/dev/null` ; do
+ dnl Itcl 7.5 and greater puts library in subdir. Look there first.
+ if test -f "$i/src/libitcl$TCL_SHLIB_SUFFIX" ; then
+ ac_cv_c_itcllib=`(cd $i/src; pwd)`
+ break
+ elif test -f "$i/src/libitcl.a"; then
+ ac_cv_c_itcllib=`(cd $i/src; pwd)`
+ break
+ fi
+ done
+ fi
+
+ dnl see if one is conveniently installed with the compiler
+ if test x"${ac_cv_c_itcllib}" = x ; then
+ dnl Get the path to the compiler
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/lib
+ dnl Itcl 7.5 and greater puts library in subdir. Look there first.
+ if test -f "${ccpath}/libitcl$TCL_SHLIB_SUFFIX" ; then
+ ac_cv_c_itcllib=`(cd ${ccpath}; pwd)`
+ elif test -f "${ccpath}/libitcl.a"; then
+ ac_cv_c_itcllib=`(cd ${ccpath}; pwd)`
+ fi
+ fi
+ ])
+ if test x"${ac_cv_c_itcllib}" = x ; then
+ ITCLLIB=""
+ AC_MSG_WARN(Can't find Itcl library)
+ else
+ ITCLLIB="-L${ac_cv_c_itcllib}"
+ AC_MSG_RESULT(${ac_cv_c_itcllib})
+ no_itcl=""
+ fi
+fi
+
+AC_PROVIDE([$0])
+AC_SUBST(ITCLLIB)
+])
+
+
+dnl ====================================================================
+dnl Ok, lets find the itcl source trees so we can use the itcl_sh script
+dnl the alternative search directory is involked by --with-itclinclude
+AC_DEFUN(CYG_AC_PATH_ITCLSH, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+no_itcl=true
+AC_MSG_CHECKING(for the itcl_sh script)
+AC_ARG_WITH(itclinclude, [ --with-itclinclude directory where itcl headers are], with_itclinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_itclsh,[
+dnl first check to see if --with-itclinclude was specified
+if test x"${with_itclinclude}" != x ; then
+ if test -f ${with_itclinclude}/itcl_sh ; then
+ ac_cv_c_itclsh=`(cd ${with_itclinclude}; pwd)`
+ elif test -f ${with_itclinclude}/src/itcl_sh ; then
+ ac_cv_c_itclsh=`(cd ${with_itclinclude}/src; pwd)`
+ else
+ AC_MSG_ERROR([${with_itclinclude} directory doesn't contain itcl_sh])
+ fi
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_itclsh}" = x ; then
+ dnl find the top level Itcl source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
+ itclpath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Itcl source dir. We do it this way, cause there
+ dnl might be multiple version of Itcl, and we want the most recent one.
+ for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
+ if test -f $i/src/itcl_sh ; then
+ ac_cv_c_itclsh=`(cd $i/src; pwd)`/itcl_sh
+ break
+ fi
+ done
+fi
+
+dnl see if one is installed
+if test x"${ac_cv_c_itclsh}" = x ; then
+ AC_MSG_RESULT(none)
+ AC_PATH_PROG(ac_cv_c_itclsh, itcl_sh)
+else
+ AC_MSG_RESULT(${ac_cv_c_itclsh})
+fi
+])
+
+if test x"${ac_cv_c_itclsh}" = x ; then
+ AC_MSG_ERROR([Can't find the itcl_sh script])
+fi
+if test x"${ac_cv_c_itclsh}" != x ; then
+ no_itcl=""
+ AC_MSG_RESULT(${ac_cv_c_itclsh})
+ ITCLSH="${ac_cv_c_itclsh}"
+fi
+AC_SUBST(ITCLSH)
+])
+
+
+dnl ====================================================================
+dnl Ok, lets find the itcl source trees so we can use the itcl_sh script
+dnl the alternative search directory is involked by --with-itclinclude
+AC_DEFUN(CYG_AC_PATH_ITCLMKIDX, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+no_itcl=true
+AC_MSG_CHECKING(for itcl_mkindex.tcl script)
+AC_ARG_WITH(itclinclude, [ --with-itclinclude directory where itcl headers are], with_itclinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_itclmkidx,[
+dnl first check to see if --with-itclinclude was specified
+if test x"${with_itclinclude}" != x ; then
+ if test -f ${with_itclinclude}/itcl_sh ; then
+ ac_cv_c_itclmkidx=`(cd ${with_itclinclude}; pwd)`
+ elif test -f ${with_itclinclude}/src/itcl_sh ; then
+ ac_cv_c_itclmkidx=`(cd ${with_itclinclude}/src; pwd)`
+ else
+ AC_MSG_ERROR([${with_itclinclude} directory doesn't contain itcl_sh])
+ fi
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_itclmkidx}" = x ; then
+ dnl find the top level Itcl source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
+ itclpath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Itcl source dir. We do it this way, cause there
+ dnl might be multiple version of Itcl, and we want the most recent one.
+ for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
+ if test -f $i/library/itcl_mkindex.tcl ; then
+ ac_cv_c_itclmkidx=`(cd $i/library; pwd)`/itcl_mkindex.tcl
+ break
+ fi
+ done
+fi
+if test x"${ac_cv_c_itclmkidx}" = x ; then
+ dnl Get the path to the compiler
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/share
+ dnl Itcl 7.5 and greater puts library in subdir. Look there first.
+ for i in `ls -dr $ccpath/itcl* 2>/dev/null ` ; do
+ if test -f $i/itcl_mkindex.tcl ; then
+ ac_cv_c_itclmkidx=`(cd $i; pwd)`/itcl_mkindex.tcl
+ break
+ fi
+ done
+fi
+])
+
+if test x"${ac_cv_c_itclmkidx}" = x ; then
+ AC_MSG_ERROR([Can't find the itcl_mkindex.tcl script])
+fi
+if test x"${ac_cv_c_itclmkidx}" != x ; then
+ no_itcl=""
+ AC_MSG_RESULT(${ac_cv_c_itclmkidx})
+ ITCLMKIDX="${ac_cv_c_itclmkidx}"
+else
+ AC_MSG_RESULT(none)
+fi
+AC_SUBST(ITCLMKIDX)
+])
+
+dnl ====================================================================
+dnl Ok, lets find the tix source trees so we can use the headers
+dnl the alternative search directory is involked by --with-tixinclude
+AC_DEFUN(CYG_AC_PATH_TIX, [
+ CYG_AC_PATH_TIXH
+ CYG_AC_PATH_TIXLIB
+])
+AC_DEFUN(CYG_AC_PATH_TIXH, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+no_tix=true
+AC_MSG_CHECKING(for Tix headers in the source tree)
+AC_ARG_WITH(tixinclude, [ --with-tixinclude directory where tix headers are], with_tixinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_tixh,[
+dnl first check to see if --with-tixinclude was specified
+if test x"${with_tixinclude}" != x ; then
+ if test -f ${with_tixinclude}/tix.h ; then
+ ac_cv_c_tixh=`(cd ${with_tixinclude}; pwd)`
+ elif test -f ${with_tixinclude}/generic/tix.h ; then
+ ac_cv_c_tixh=`(cd ${with_tixinclude}/generic; pwd)`
+ else
+ AC_MSG_ERROR([${with_tixinclude} directory doesn't contain headers])
+ fi
+fi
+
+dnl next check if it came with Tix configuration file
+if test x"${ac_cv_c_tixconfig}" != x ; then
+ for i in $dirlist; do
+ if test -f $ac_cv_c_tixconfig/$i/generic/tix.h ; then
+ ac_cv_c_tixh=`(cd $ac_cv_c_tixconfig/$i/generic; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_tixh}" = x ; then
+ dnl find the top level Tix source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/tix* 2>/dev/null`" ; then
+ tixpath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Tix source dir. We do it this way, cause there
+ dnl might be multiple version of Tix, and we want the most recent one.
+ for i in `ls -dr $tixpath/tix* 2>/dev/null ` ; do
+ if test -f $i/generic/tix.h ; then
+ ac_cv_c_tixh=`(cd $i/generic; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl see if one is installed
+if test x"${ac_cv_c_tixh}" = x ; then
+ AC_MSG_RESULT(none)
+ dnl Get the path to the compiler
+
+ dnl Get the path to the compiler. We do it this way instead of using
+ dnl AC_CHECK_HEADER, cause this doesn't depend in having X configured.
+ ccpath=`which ${CC} | sed -e 's:/bin/.*::'`/include
+ if test -f $ccpath/tix.h; then
+ ac_cv_c_tixh=installed
+ fi
+else
+ AC_MSG_RESULT(${ac_cv_c_tixh})
+fi
+])
+if test x"${ac_cv_c_tixh}" = x ; then
+ AC_MSG_ERROR([Can't find any Tix headers])
+fi
+if test x"${ac_cv_c_tixh}" != x ; then
+ no_tix=""
+ AC_MSG_RESULT(${ac_cv_c_tixh})
+ if test x"${ac_cv_c_tixh}" != x"installed" ; then
+ TIXHDIR="-I${ac_cv_c_tixh}"
+ fi
+fi
+
+AC_SUBST(TIXHDIR)
+])
+
+AC_DEFUN(CYG_AC_PATH_TIXCONFIG, [
+#
+# Ok, lets find the tix configuration
+# First, look for one uninstalled.
+# the alternative search directory is invoked by --with-tixconfig
+#
+
+if test x"${no_tix}" = x ; then
+ # we reset no_tix in case something fails here
+ no_tix=true
+ AC_ARG_WITH(tixconfig, [ --with-tixconfig directory containing tix configuration (tixConfig.sh)],
+ with_tixconfig=${withval})
+ AC_MSG_CHECKING([for Tix configuration])
+ AC_CACHE_VAL(ac_cv_c_tixconfig,[
+
+ # First check to see if --with-tixconfig was specified.
+ if test x"${with_tixconfig}" != x ; then
+ if test -f "${with_tixconfig}/tixConfig.sh" ; then
+ ac_cv_c_tixconfig=`(cd ${with_tixconfig}; pwd)`
+ else
+ AC_MSG_ERROR([${with_tixconfig} directory doesn't contain tixConfig.sh])
+ fi
+ fi
+
+ # then check for a private Tix library
+ if test x"${ac_cv_c_tixconfig}" = x ; then
+ for i in \
+ ../tix \
+ `ls -dr ../tix[[4]]* 2>/dev/null` \
+ ../../tix \
+ `ls -dr ../../tix[[4]]* 2>/dev/null` \
+ ../../../tix \
+ `ls -dr ../../../tix[[4]]* 2>/dev/null` ; do
+ if test -f "$i/tixConfig.sh" ; then
+ ac_cv_c_tixconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ # check in a few common install locations
+ if test x"${ac_cv_c_tixconfig}" = x ; then
+ for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
+ if test -f "$i/tixConfig.sh" ; then
+ ac_cv_c_tkconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ # check in a few other private locations
+ if test x"${ac_cv_c_tixconfig}" = x ; then
+ for i in \
+ ${srcdir}/../tix \
+ `ls -dr ${srcdir}/../tix[[4-9]]* 2>/dev/null` ; do
+ if test -f "$i/tixConfig.sh" ; then
+ ac_cv_c_tixconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ ])
+ if test x"${ac_cv_c_tixconfig}" = x ; then
+ TIXCONFIG="# no Tix configs found"
+ AC_MSG_WARN(Can't find Tix configuration definitions)
+ else
+ no_tix=
+ TIXCONFIG=${ac_cv_c_tixconfig}/tixConfig.sh
+ AC_MSG_RESULT(found $TIXCONFIG)
+ fi
+fi
+
+])
+
+# Defined as a separate macro so we don't have to cache the values
+# from PATH_TIXCONFIG (because this can also be cached).
+AC_DEFUN(CYG_AC_LOAD_TIXCONFIG, [
+ if test -f "$TIXCONFIG" ; then
+ . $TIXCONFIG
+ fi
+
+ AC_SUBST(TIX_BUILD_LIB_SPEC)
+ AC_SUBST(TIX_LIB_FULL_PATH)
+])
+
+AC_DEFUN(CYG_AC_PATH_ITCLCONFIG, [
+#
+# Ok, lets find the itcl configuration
+# First, look for one uninstalled.
+# the alternative search directory is invoked by --with-itclconfig
+#
+
+if test x"${no_itcl}" = x ; then
+ # we reset no_itcl in case something fails here
+ no_itcl=true
+ AC_ARG_WITH(itclconfig, [ --with-itclconfig directory containing itcl configuration (itclConfig.sh)],
+ with_itclconfig=${withval})
+ AC_MSG_CHECKING([for Itcl configuration])
+ AC_CACHE_VAL(ac_cv_c_itclconfig,[
+
+ # First check to see if --with-itclconfig was specified.
+ if test x"${with_itclconfig}" != x ; then
+ if test -f "${with_itclconfig}/itclConfig.sh" ; then
+ ac_cv_c_itclconfig=`(cd ${with_itclconfig}; pwd)`
+ else
+ AC_MSG_ERROR([${with_itclconfig} directory doesn't contain itclConfig.sh])
+ fi
+ fi
+
+ # then check for a private itcl library
+ if test x"${ac_cv_c_itclconfig}" = x ; then
+ for i in \
+ ../itcl/itcl \
+ `ls -dr ../itcl/itcl[[3]]* 2>/dev/null` \
+ ../../itcl/itcl \
+ `ls -dr ../../itcl/itcl[[3]]* 2>/dev/null` \
+ ../../../itcl/itcl \
+ `ls -dr ../../../itcl/itcl[[3]]* 2>/dev/null` ; do
+ if test -f "$i/itclConfig.sh" ; then
+ ac_cv_c_itclconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ # check in a few common install locations
+ if test x"${ac_cv_c_itclconfig}" = x ; then
+ for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
+ if test -f "$i/itclConfig.sh" ; then
+ ac_cv_c_itclconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ # check in a few other private locations
+ if test x"${ac_cv_c_itclconfig}" = x ; then
+ for i in \
+ ${srcdir}/../itcl/itcl \
+ `ls -dr ${srcdir}/../itcl/itcl[[3]]* 2>/dev/null` ; do
+ if test -f "$i/itcl/itclConfig.sh" ; then
+ ac_cv_c_itclconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ ])
+ if test x"${ac_cv_c_itclconfig}" = x ; then
+ ITCLCONFIG="# no itcl configs found"
+ AC_MSG_WARN(Can't find itcl configuration definitions)
+ else
+ no_itcl=
+ ITCLCONFIG=${ac_cv_c_itclconfig}/itclConfig.sh
+ AC_MSG_RESULT(found $ITCLCONFIG)
+ fi
+fi
+
+])
+
+# Defined as a separate macro so we don't have to cache the values
+# from PATH_ITCLCONFIG (because this can also be cached).
+AC_DEFUN(CYG_AC_LOAD_ITCLCONFIG, [
+ if test -f "$ITCLCONFIG" ; then
+ . $ITCLCONFIG
+ fi
+
+ AC_SUBST(ITCL_BUILD_LIB_SPEC)
+ AC_SUBST(ITCL_SH)
+ AC_SUBST(ITCL_LIB_FILE)
+ AC_SUBST(ITCL_LIB_FULL_PATH)
+
+])
+
+
+AC_DEFUN(CYG_AC_PATH_ITKCONFIG, [
+#
+# Ok, lets find the itk configuration
+# First, look for one uninstalled.
+# the alternative search directory is invoked by --with-itkconfig
+#
+
+if test x"${no_itk}" = x ; then
+ # we reset no_itk in case something fails here
+ no_itk=true
+ AC_ARG_WITH(itkconfig, [ --with-itkconfig directory containing itk configuration (itkConfig.sh)],
+ with_itkconfig=${withval})
+ AC_MSG_CHECKING([for Itk configuration])
+ AC_CACHE_VAL(ac_cv_c_itkconfig,[
+
+ # First check to see if --with-itkconfig was specified.
+ if test x"${with_itkconfig}" != x ; then
+ if test -f "${with_itkconfig}/itkConfig.sh" ; then
+ ac_cv_c_itkconfig=`(cd ${with_itkconfig}; pwd)`
+ else
+ AC_MSG_ERROR([${with_itkconfig} directory doesn't contain itkConfig.sh])
+ fi
+ fi
+
+ # then check for a private itk library
+ if test x"${ac_cv_c_itkconfig}" = x ; then
+ for i in \
+ ../itcl/itk \
+ `ls -dr ../itcl/itk[[3]]* 2>/dev/null` \
+ ../../itcl/itk \
+ `ls -dr ../../itcl/itk[[3]]* 2>/dev/null` \
+ ../../../itcl/itk \
+ `ls -dr ../../../itcl/itk[[3]]* 2>/dev/null` ; do
+ if test -f "$i/itkConfig.sh" ; then
+ ac_cv_c_itkconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ # check in a few common install locations
+ if test x"${ac_cv_c_itkconfig}" = x ; then
+ for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
+ if test -f "$i/itcl/itkConfig.sh" ; then
+ ac_cv_c_itkconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ # check in a few other private locations
+ if test x"${ac_cv_c_itkconfig}" = x ; then
+ for i in \
+ ${srcdir}/../itcl/itk \
+ `ls -dr ${srcdir}/../itcl/itk[[3]]* 2>/dev/null` ; do
+ if test -f "$i/itkConfig.sh" ; then
+ ac_cv_c_itkconfig=`(cd $i; pwd)`
+ break
+ fi
+ done
+ fi
+ ])
+ if test x"${ac_cv_c_itkconfig}" = x ; then
+ ITCLCONFIG="# no itk configs found"
+ AC_MSG_WARN(Can't find itk configuration definitions)
+ else
+ no_itk=
+ ITKCONFIG=${ac_cv_c_itkconfig}/itkConfig.sh
+ AC_MSG_RESULT(found $ITKCONFIG)
+ fi
+fi
+
+])
+
+# Defined as a separate macro so we don't have to cache the values
+# from PATH_ITKCONFIG (because this can also be cached).
+AC_DEFUN(CYG_AC_LOAD_ITKCONFIG, [
+ if test -f "$ITKCONFIG" ; then
+ . $ITKCONFIG
+ fi
+
+ AC_SUBST(ITK_BUILD_LIB_SPEC)
+ AC_SUBST(ITK_LIB_FILE)
+ AC_SUBST(ITK_LIB_FULL_PATH)
+])
+
+
+dnl ====================================================================
+dnl Ok, lets find the libgui source trees so we can use the headers
+dnl the alternative search directory is involked by --with-libguiinclude
+AC_DEFUN(CYG_AC_PATH_LIBGUI, [
+ CYG_AC_PATH_LIBGUIH
+ CYG_AC_PATH_LIBGUILIB
+])
+AC_DEFUN(CYG_AC_PATH_LIBGUIH, [
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../..../../../../../../../../../../.."
+no_libgui=true
+AC_MSG_CHECKING(for Libgui headers in the source tree)
+AC_ARG_WITH(libguiinclude, [ --with-libguiinclude directory where libgui headers are], with_libguiinclude=${withval})
+AC_CACHE_VAL(ac_cv_c_libguih,[
+dnl first check to see if --with-libguiinclude was specified
+if test x"${with_libguiinclude}" != x ; then
+ if test -f ${with_libguiinclude}/guitcl.h ; then
+ ac_cv_c_libguih=`(cd ${with_libguiinclude}; pwd)`
+ elif test -f ${with_libguiinclude}/src/guitcl.h ; then
+ ac_cv_c_libguih=`(cd ${with_libguiinclude}/src; pwd)`
+ else
+ AC_MSG_ERROR([${with_libguiinclude} directory doesn't contain headers])
+ fi
+fi
+
+dnl next check if it came with Libgui configuration file
+if test x"${ac_cv_c_libguiconfig}" != x ; then
+ for i in $dirlist; do
+ if test -f $ac_cv_c_libguiconfig/$i/src/guitcl.h ; then
+ ac_cv_c_libguih=`(cd $ac_cv_c_libguiconfig/$i/src; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl next check in private source directory
+dnl since ls returns lowest version numbers first, reverse its output
+if test x"${ac_cv_c_libguih}" = x ; then
+ dnl find the top level Libgui source directory
+ for i in $dirlist; do
+ if test -n "`ls -dr $srcdir/$i/libgui* 2>/dev/null`" ; then
+ libguipath=$srcdir/$i
+ break
+ fi
+ done
+
+ dnl find the exact Libgui source dir. We do it this way, cause there
+ dnl might be multiple version of Libgui, and we want the most recent one.
+ for i in `ls -dr $libguipath/libgui* 2>/dev/null ` ; do
+ if test -f $i/src/guitcl.h ; then
+ ac_cv_c_libguih=`(cd $i/src; pwd)`
+ break
+ fi
+ done
+fi
+
+dnl see if one is installed
+if test x"${ac_cv_c_libguih}" = x ; then
+ AC_MSG_RESULT(none)
+ AC_CHECK_HEADER(guitcl.h, ac_cv_c_libguih=installed, ac_cv_c_libguih="")
+fi
+])
+LIBGUIHDIR=""
+if test x"${ac_cv_c_libguih}" = x ; then
+ AC_MSG_WARN([Can't find any Libgui headers])
+fi
+if test x"${ac_cv_c_libguih}" != x ; then
+ no_libgui=""
+ if test x"${ac_cv_c_libguih}" != x"installed" ; then
+ LIBGUIHDIR="-I${ac_cv_c_libguih}"
+ fi
+fi
+AC_MSG_RESULT(${ac_cv_c_libguih})
+AC_SUBST(LIBGUIHDIR)
+])
+
+dnl ====================================================================
+dnl find the GUI library
+AC_DEFUN(CYG_AC_PATH_LIBGUILIB, [
+AC_MSG_CHECKING(for GUI library in the build tree)
+dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
+dnl look for the library
+AC_MSG_CHECKING(for GUI library)
+AC_CACHE_VAL(ac_cv_c_libguilib,[
+if test x"${ac_cv_c_libguilib}" = x ; then
+ for i in $dirlist; do
+ if test -f "$i/libgui/src/Makefile" ; then
+ ac_cv_c_libguilib=`(cd $i/libgui/src; pwd)`
+ break
+ fi
+ done
+fi
+])
+if test x"${ac_cv_c_libguilib}" != x ; then
+ GUILIB="${GUILIB} -L${ac_cv_c_libguilib}"
+ LIBGUILIB="-lgui"
+ AC_MSG_RESULT(${ac_cv_c_libguilib})
+else
+ AC_MSG_RESULT(none)
+fi
+
+AC_SUBST(GUILIB)
+AC_SUBST(LIBGUILIB)
+])
diff --git a/config/mh-a68bsd b/config/mh-a68bsd
new file mode 100644
index 00000000000..c991289dd5f
--- /dev/null
+++ b/config/mh-a68bsd
@@ -0,0 +1,12 @@
+RANLIB=true
+
+#None of the Apollo compilers can compile gas or binutils. The preprocessor
+# chokes on bfd, the compiler won't let you assign integers to enums, and
+# other problems. Defining CC to gcc is a questionable way to say "don't use
+# the apollo compiler" (the preferred version of GCC could be called cc,
+# or whatever), but I'm not sure leaving CC as cc is any better...
+
+#CC=cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DNO_STDARG
+CC=gcc
+
+BISON=yacc
diff --git a/config/mh-aix386 b/config/mh-aix386
new file mode 100644
index 00000000000..4accd1cddfb
--- /dev/null
+++ b/config/mh-aix386
@@ -0,0 +1 @@
+RANLIB = @:
diff --git a/config/mh-aix43 b/config/mh-aix43
new file mode 100644
index 00000000000..9eb750c2966
--- /dev/null
+++ b/config/mh-aix43
@@ -0,0 +1,4 @@
+# AIX 4.3 and above requires -X32_64 flag to all ar and nm commands
+# to handle both 32-bit and 64-bit objects.
+AR_FOR_TARGET=ar -X32_64
+NM_FOR_TARGET=nm -X32_64
diff --git a/config/mh-apollo68 b/config/mh-apollo68
new file mode 100644
index 00000000000..4497ed93585
--- /dev/null
+++ b/config/mh-apollo68
@@ -0,0 +1,3 @@
+HDEFINES = -DUSG
+RANLIB=true
+CC= cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DUSG
diff --git a/config/mh-armpic b/config/mh-armpic
new file mode 100644
index 00000000000..35cf2c8ee4e
--- /dev/null
+++ b/config/mh-armpic
@@ -0,0 +1 @@
+PICFLAG=-fPIC
diff --git a/config/mh-cxux b/config/mh-cxux
new file mode 100644
index 00000000000..54b2a16c834
--- /dev/null
+++ b/config/mh-cxux
@@ -0,0 +1,14 @@
+# Configuration for Harris CX/UX 7 (and maybe 6), based on sysv4 configuration.
+
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4
+RANLIB = true
+
+# C++ debugging is not yet supported under SVR4 (DWARF)
+CXXFLAGS=-O
+
+# The l flag generates a warning from the SVR4 archiver, remove it.
+AR_FLAGS = cq
+
+# Under CX/UX, we want to tell the compiler to use ANSI mode.
+CC=cc -Xa
diff --git a/config/mh-cygwin b/config/mh-cygwin
new file mode 100644
index 00000000000..241027fb8de
--- /dev/null
+++ b/config/mh-cygwin
@@ -0,0 +1,6 @@
+EXTRA_TARGET_HOST_ALL_MODULES=all-libtermcap
+EXTRA_TARGET_HOST_INSTALL_MODULES=install-libtermcap
+
+all-gdb: all-libtermcap
+
+install-gdb: all-libtermcap
diff --git a/config/mh-decstation b/config/mh-decstation
new file mode 100644
index 00000000000..37201926d5f
--- /dev/null
+++ b/config/mh-decstation
@@ -0,0 +1,5 @@
+CC = cc -Wf,-XNg1000
+
+# for X11, since the native DECwindows include files are really broken when
+# it comes to function prototypes.
+X11_EXTRA_CFLAGS = "-DNeedFunctionPrototypes=0"
diff --git a/config/mh-delta88 b/config/mh-delta88
new file mode 100644
index 00000000000..bc9c45302d5
--- /dev/null
+++ b/config/mh-delta88
@@ -0,0 +1,4 @@
+RANLIB = true
+
+
+
diff --git a/config/mh-dgux b/config/mh-dgux
new file mode 100644
index 00000000000..e7d85d6126a
--- /dev/null
+++ b/config/mh-dgux
@@ -0,0 +1,4 @@
+HDEFINES=-DHOST_SYS=DGUX_SYS
+CC=gcc -Wall -ansi -D__using_DGUX
+RANLIB=true
+
diff --git a/config/mh-dgux386 b/config/mh-dgux386
new file mode 100644
index 00000000000..15885c3e042
--- /dev/null
+++ b/config/mh-dgux386
@@ -0,0 +1,22 @@
+# from mh-dgux
+HDEFINES=-DHOST_SYS=DGUX_SYS
+CC=gcc -Wall -ansi -D__using_DGUX
+RANLIB = true
+
+# from mh-sysv4
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4
+RANLIB = true
+
+# C++ debugging is not yet supported under SVR4 (DWARF)
+CXXFLAGS=-O
+
+# The l flag generates a warning from the SVR4 archiver, remove it.
+AR_FLAGS = cr
+
+X11_EXTRA_LIBS = -lnsl
+
+# from angela
+# no debugging due to broken compiler, use BSD style timeofday
+CFLAGS=-O -D_BSD_TIMEOFDAY_FLAVOR
+
diff --git a/config/mh-djgpp b/config/mh-djgpp
new file mode 100644
index 00000000000..f12007b0e0f
--- /dev/null
+++ b/config/mh-djgpp
@@ -0,0 +1,4 @@
+# We don't want to use debugging information on DOS. Unfortunately,
+# this requires that we set CFLAGS.
+# This used to set -fno-omit-frame-pointer.
+CFLAGS=-O2
diff --git a/config/mh-elfalphapic b/config/mh-elfalphapic
new file mode 100644
index 00000000000..35cf2c8ee4e
--- /dev/null
+++ b/config/mh-elfalphapic
@@ -0,0 +1 @@
+PICFLAG=-fPIC
diff --git a/config/mh-hp300 b/config/mh-hp300
new file mode 100644
index 00000000000..761724d92de
--- /dev/null
+++ b/config/mh-hp300
@@ -0,0 +1,13 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV
+# Avoid "too much defining" errors from HPUX compiler.
+CC = cc -Wp,-H256000
+# If "ar" in $PATH is GNU ar, the symbol table may need rebuilding.
+# If it's HP/UX ar, this should be harmless.
+RANLIB = ar ts
+
+# Native cc can't bootstrap gcc with -g. Defining CFLAGS here loses (a)
+# for non-gcc directories, (b) if we are compiling with gcc, not
+# native cc. Neither (a) nor (b) has a trivial fix though.
+
+CFLAGS =
diff --git a/config/mh-hpux b/config/mh-hpux
new file mode 100644
index 00000000000..4d71c9dc837
--- /dev/null
+++ b/config/mh-hpux
@@ -0,0 +1,4 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+CC = cc -Wp,-H256000
+SYSV = -DSYSV
+RANLIB = true
diff --git a/config/mh-hpux8 b/config/mh-hpux8
new file mode 100644
index 00000000000..4d71c9dc837
--- /dev/null
+++ b/config/mh-hpux8
@@ -0,0 +1,4 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+CC = cc -Wp,-H256000
+SYSV = -DSYSV
+RANLIB = true
diff --git a/config/mh-interix b/config/mh-interix
new file mode 100644
index 00000000000..19b8ecfd339
--- /dev/null
+++ b/config/mh-interix
@@ -0,0 +1,14 @@
+# The shell may not be in /bin.
+SHELL = sh
+RANLIB = true
+
+# We don't want debugging info in Interix-hosted toolchains.
+# Accomplish this by overriding CFLAGS. This is also a workaround
+# for LD crash when building shared libstdc++.
+CFLAGS=-O2
+CXXFLAGS=-O2
+
+# We also need to override LIBGCC2_DEBUG_CFLAGS so libgcc2 will be
+# built without debugging information
+
+LIBGCC2_DEBUG_CFLAGS=
diff --git a/config/mh-irix4 b/config/mh-irix4
new file mode 100644
index 00000000000..6872145e833
--- /dev/null
+++ b/config/mh-irix4
@@ -0,0 +1,7 @@
+# Makefile changes for SGI's running IRIX-4.x.
+# Tell compiler to use K&R C. We can't compile under the SGI Ansi
+# environment. Also bump switch table size so that cp-parse will
+# compile. Bump string length limit so linker builds.
+
+CC = cc -cckr -Wf,-XNg1500 -Wf,-XNk1000 -Wf,-XNh2000 -Wf,-XNl8192
+SYSV = -DSYSV
diff --git a/config/mh-irix5 b/config/mh-irix5
new file mode 100644
index 00000000000..8bd7c99f844
--- /dev/null
+++ b/config/mh-irix5
@@ -0,0 +1,3 @@
+# Makefile changes for SGI's running IRIX-5.x.
+SYSV = -DSYSV
+RANLIB = true
diff --git a/config/mh-irix6 b/config/mh-irix6
new file mode 100644
index 00000000000..6d25c16b2f4
--- /dev/null
+++ b/config/mh-irix6
@@ -0,0 +1,7 @@
+# Makefile changes for SGI's running IRIX-6.x.
+SYSV = -DSYSV
+RANLIB = true
+# Specify the ABI, to ensure that all Irix 6 systems will behave the same.
+# Also, using -32 avoids bugs that exist in the n32/n64 support in some
+# versions of the SGI compiler.
+CC = cc -32
diff --git a/config/mh-lynxos b/config/mh-lynxos
new file mode 100644
index 00000000000..9afcb79fca7
--- /dev/null
+++ b/config/mh-lynxos
@@ -0,0 +1,2 @@
+# /bin/cc is less than useful for our purposes. Always use GCC
+CC = /bin/gcc
diff --git a/config/mh-lynxrs6k b/config/mh-lynxrs6k
new file mode 100644
index 00000000000..b2793996eff
--- /dev/null
+++ b/config/mh-lynxrs6k
@@ -0,0 +1,8 @@
+# LynxOS running on the rs6000 doesn't have ranlib
+RANLIB = true
+
+# /bin/cc is less than useful for our purposes. Always use GCC
+CC = /usr/cygnus/progressive/bin/gcc
+
+# /bin/sh is too buggy, so use /bin/bash instead.
+SHELL = /bin/bash
diff --git a/config/mh-m68kpic b/config/mh-m68kpic
new file mode 100644
index 00000000000..92e48d90fbd
--- /dev/null
+++ b/config/mh-m68kpic
@@ -0,0 +1 @@
+PICFLAG=-fpic
diff --git a/config/mh-mingw32 b/config/mh-mingw32
new file mode 100644
index 00000000000..8c4839d89d6
--- /dev/null
+++ b/config/mh-mingw32
@@ -0,0 +1,12 @@
+# We don't want debugging info in Win32-hosted toolchains.
+# Accomplish this by overriding CFLAGS.
+CFLAGS=-O2
+CXXFLAGS=-O2
+
+# We also need to override LIBGCC2_DEBUG_CFLAGS so libgcc2 will be
+# built without debugging information
+
+LIBGCC2_DEBUG_CFLAGS=
+
+# custom installation rules for mingw32 (append .exe to binaries, etc.)
+# INSTALL_DOSREL=install-dosrel
diff --git a/config/mh-ncr3000 b/config/mh-ncr3000
new file mode 100644
index 00000000000..5bbd8037009
--- /dev/null
+++ b/config/mh-ncr3000
@@ -0,0 +1,17 @@
+# Host configuration file for an NCR 3000 (i486/SVR4) system.
+
+# The NCR 3000 ships with a MetaWare compiler installed as /bin/cc.
+# This compiler not only emits obnoxious copyright messages every time
+# you run it, but it chokes and dies on a whole bunch of GNU source
+# files. Default to using the AT&T compiler installed in /usr/ccs/ATT/cc.
+# Unfortunately though, the AT&T compiler sometimes generates code that
+# the assembler barfs on if -g is used, so disable it by default as well.
+CC = /usr/ccs/ATT/cc
+CFLAGS =
+
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4
+RANLIB = true
+
+# The l flag generates a warning from the SVR4 archiver, remove it.
+AR_FLAGS = cq
diff --git a/config/mh-ncrsvr43 b/config/mh-ncrsvr43
new file mode 100644
index 00000000000..43b09912ca9
--- /dev/null
+++ b/config/mh-ncrsvr43
@@ -0,0 +1,9 @@
+# Host configuration file for an NCR 3000 (i486/SVR43) system.
+
+# The MetaWare compiler will generate a copyright message unless you
+# turn it off by adding the -Hnocopyr flag.
+CC = cc -Hnocopyr
+
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4
+RANLIB = true
diff --git a/config/mh-necv4 b/config/mh-necv4
new file mode 100644
index 00000000000..e887736f8be
--- /dev/null
+++ b/config/mh-necv4
@@ -0,0 +1,11 @@
+# Host Makefile fragment for NEC MIPS SVR4.
+
+# The C compiler on NEC MIPS SVR4 needs bigger tables.
+CC = cc -ZXNd=5000 -ZXNg=1000
+
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4
+RANLIB = true
+
+# NEC -lX11 needs some other libraries.
+X11_EXTRA_LIBS = -lsocket -lnsl
diff --git a/config/mh-papic b/config/mh-papic
new file mode 100644
index 00000000000..35cf2c8ee4e
--- /dev/null
+++ b/config/mh-papic
@@ -0,0 +1 @@
+PICFLAG=-fPIC
diff --git a/config/mh-ppcpic b/config/mh-ppcpic
new file mode 100644
index 00000000000..35cf2c8ee4e
--- /dev/null
+++ b/config/mh-ppcpic
@@ -0,0 +1 @@
+PICFLAG=-fPIC
diff --git a/config/mh-riscos b/config/mh-riscos
new file mode 100644
index 00000000000..e586b30b1a9
--- /dev/null
+++ b/config/mh-riscos
@@ -0,0 +1,15 @@
+# This is for a MIPS running RISC/os 4.52C.
+
+# This is needed for GDB, but needs to be in the top-level make because
+# if a library is compiled with the bsd headers and gets linked with the
+# sysv system libraries all hell can break loose (e.g. a jmp_buf might be
+# a different size).
+# ptrace(2) apparently has problems in the BSD environment. No workaround is
+# known except to select the sysv environment. Could we use /proc instead?
+# These "sysv environments" and "bsd environments" often end up being a pain.
+#
+# This is not part of CFLAGS because perhaps not all C compilers have this
+# option.
+CC= cc -systype sysv
+
+RANLIB = true
diff --git a/config/mh-sco b/config/mh-sco
new file mode 100644
index 00000000000..cc337c98f93
--- /dev/null
+++ b/config/mh-sco
@@ -0,0 +1,10 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV
+RANLIB = true
+# You may need this if you don't have bison.
+# BISON = yacc -Sm10400
+# The native C compiler botches some simple uses of const. Unfortunately,
+# it doesn't defined anything like "__sco__" for us to test for in ansidecl.h.
+CC = cc -Dconst=
+
+X11_EXTRA_LIBS = -lsocket -lm -lintl -lmalloc
diff --git a/config/mh-solaris b/config/mh-solaris
new file mode 100644
index 00000000000..ddbea549b93
--- /dev/null
+++ b/config/mh-solaris
@@ -0,0 +1,6 @@
+# Makefile changes for Suns running Solaris 2
+
+SYSV = -DSYSV
+RANLIB = true
+
+X11_EXTRA_LIBS = -lnsl -lsocket
diff --git a/config/mh-sparcpic b/config/mh-sparcpic
new file mode 100644
index 00000000000..f6dbc22e3ca
--- /dev/null
+++ b/config/mh-sparcpic
@@ -0,0 +1 @@
+PICFLAG=`case "${LIBCFLAGS} ${LIBCXXFLAGS}" in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
diff --git a/config/mh-sun3 b/config/mh-sun3
new file mode 100644
index 00000000000..dcd5155b736
--- /dev/null
+++ b/config/mh-sun3
@@ -0,0 +1,3 @@
+# Sun's C compiler needs the -J flag to be able to compile cp-parse.c
+# without overflowing the jump tables (-J says to use a 32 bit table)
+CC = cc -J
diff --git a/config/mh-sysv b/config/mh-sysv
new file mode 100644
index 00000000000..16b1187b447
--- /dev/null
+++ b/config/mh-sysv
@@ -0,0 +1,3 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV
+RANLIB = true
diff --git a/config/mh-sysv4 b/config/mh-sysv4
new file mode 100644
index 00000000000..81066510600
--- /dev/null
+++ b/config/mh-sysv4
@@ -0,0 +1,11 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4
+RANLIB = true
+
+# C++ debugging is not yet supported under SVR4 (DWARF)
+CXXFLAGS=-O
+
+# The l flag generates a warning from the SVR4 archiver, remove it.
+AR_FLAGS = cr
+
+X11_EXTRA_LIBS = -lnsl
diff --git a/config/mh-sysv5 b/config/mh-sysv5
new file mode 100644
index 00000000000..1fa38e53cc8
--- /dev/null
+++ b/config/mh-sysv5
@@ -0,0 +1,8 @@
+# Define SYSV as -DSYSV if you are using a System V operating system.
+SYSV = -DSYSV -DSVR4 -DSVR5
+RANLIB = true
+
+# The l flag generates a warning from the SVR4 archiver, remove it.
+AR_FLAGS = cr
+
+X11_EXTRA_LIBS = -lnsl
diff --git a/config/mh-vaxult2 b/config/mh-vaxult2
new file mode 100644
index 00000000000..3de2dc8ffe3
--- /dev/null
+++ b/config/mh-vaxult2
@@ -0,0 +1,2 @@
+# The old BSD pcc isn't up to compiling parts of gdb so use gcc
+CC = gcc
diff --git a/config/mh-x86pic b/config/mh-x86pic
new file mode 100644
index 00000000000..92e48d90fbd
--- /dev/null
+++ b/config/mh-x86pic
@@ -0,0 +1 @@
+PICFLAG=-fpic
diff --git a/config/mpw-mh-mpw b/config/mpw-mh-mpw
new file mode 100644
index 00000000000..543ef4fb2a1
--- /dev/null
+++ b/config/mpw-mh-mpw
@@ -0,0 +1,157 @@
+# This is an MPW makefile fragment.
+
+# Since there are a multiplicity of Mac compilers and two different
+# processors, this file is primarily a library of options for each
+# compiler. Somebody else (such as a configure or build script) will
+# make the actual choice.
+
+# Compiler to use for compiling.
+
+CC_MPW_C = C -d MPW_C -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -mc68020 -model far -b -w
+
+CC_SC = SC -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -mc68020 -model far -b -i '' -i :
+
+CC_MWC68K = MWC68K -d MPW -enum int -mpw_chars -sym on -w off -mc68020 -model far
+
+CC_PPCC = PPCC -d powerc=1 -d pascal= -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -w
+
+CC_MRC = MrC -d powerc=1 -d pascal= -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -i '' -i : -jm
+
+CC_SMrC = SMrC -d MPW
+
+# "-mpw_chars" is necessary because GNU sources often mix signed and
+# unsigned casually.
+# "-w off" is not a great idea, but CW7 is complaining about enum
+# assignments.
+# "-opt global,peep,l4,speed" is sometimes good, and sometimes bad.
+# We must use {CIncludes} so that MPW tools will work; {MWCIncludes}
+# defines stdout, islower, etc, in ways that are incompatible with MPW's
+# runtime. However, this cannot be done via -i "{CIncludes}", since
+# that does not affect how <>-type includes happen; instead, the variable
+# MWCIncludes must be set to point at {CIncludes}.
+
+CC_MWCPPC = MWCPPC -d MPW -enum int -mpw_chars -sym on -w off
+
+# Note that GCC does *not* wire in a definition of "pascal", so that
+# it can be handled in another way if desired.
+
+CC_68K_GCC = gC -Dpascal= -DANSI_PROTOTYPES -DMPW
+
+CC_PPC_GCC = gC -Dpowerc=1 -Dpascal= -DANSI_PROTOTYPES -DMPW
+
+# Nothing for the default CFLAGS.
+
+CFLAGS =
+
+# Tool to use for making libraries/archives.
+
+AR_LIB = Lib
+
+AR_MWLINK68K = MWLink68K -xm library
+
+AR_PPCLINK = PPCLink -xm library
+
+AR_MWLINKPPC = MWLinkPPC -xm library
+
+AR_AR = ar
+
+AR_FLAGS = -o
+
+RANLIB_NULL = null-command
+
+RANLIB_RANLIB = ranlib
+
+# Compiler and/or linker to use for linking.
+
+CC_LD_LINK = Link -w -d -model far {CC_LD_TOOL_FLAGS}
+
+CC_LD_MWLINK68K = MWLink68K -w {CC_LD_TOOL_FLAGS} -sym on -model far
+
+CC_LD_PPCLINK = PPCLink -main __start -outputformat xcoff
+
+CC_LD_MWLINKPPC = MWLinkPPC -w {CC_LD_TOOL_FLAGS} -sym on
+
+CC_LD_GLD = gC
+
+# Extension for linker output.
+
+PROG_EXT_68K =
+
+PROG_EXT_XCOFF = .xcoff
+
+# Nothing for the default LDFLAGS.
+
+LDFLAGS = -w
+
+CC_LD_TOOL_FLAGS = -c 'MPS ' -t MPST
+
+# Libraries to link against.
+
+# It would appear that the math libraries are not
+# needed except to provide a definition for scalb,
+# which is called from ldexp, which is referenced
+# in the m68k opcodes library.
+
+EXTRALIBS_C = \Option-d
+ "{CLibraries}"StdClib.o \Option-d
+ "{CLibraries}"Math.o \Option-d
+ "{CLibraries}"CSANELib.o \Option-d
+ "{Libraries}"Stubs.o \Option-d
+ "{Libraries}"Runtime.o \Option-d
+ "{Libraries}"Interface.o \Option-d
+ "{Libraries}"ToolLibs.o
+
+EXTRALIBS_MWC68K = \Option-d
+ "{CLibraries}"StdClib.o \Option-d
+ "{CLibraries}"Math.o \Option-d
+ "{CLibraries}"CSANELib.o \Option-d
+ "{Libraries}"Stubs.o \Option-d
+ "{Libraries}"Runtime.o \Option-d
+ "{Libraries}"Interface.o \Option-d
+ "{Libraries}"ToolLibs.o \Option-d
+ "{MW68KLibraries}MPW ANSI (4i) C.68K.Lib"
+
+EXTRALIBS_PPC_XCOFF = \Option-d
+ "{PPCLibraries}"StdCRuntime.o \Option-d
+ "{PPCLibraries}"InterfaceLib.xcoff \Option-d
+ "{PPCLibraries}"MathLib.xcoff \Option-d
+ "{PPCLibraries}"StdCLib.xcoff \Option-d
+ "{PPCLibraries}"PPCToolLibs.o \Option-d
+ "{PPCLibraries}"PPCCRuntime.o \Option-d
+ "{GCCPPCLibraries}"libgcc.xcoff
+
+EXTRALIBS_PPC = \Option-d
+ "{PPCLibraries}"StdCRuntime.o \Option-d
+ "{SharedLibraries}"InterfaceLib \Option-d
+ "{SharedLibraries}"MathLib \Option-d
+ "{SharedLibraries}"StdCLib \Option-d
+ "{PPCLibraries}"PPCToolLibs.o \Option-d
+ "{PPCLibraries}"PPCCRuntime.o \Option-d
+ "{GCCPPCLibraries}"libgcc.xcoff
+
+EXTRALIBS_MWCPPC = \Option-d
+ "{MWPPCLibraries}"MWStdCRuntime.Lib \Option-d
+ "{MWPPCLibraries}"InterfaceLib \Option-d
+ "{MWPPCLibraries}"StdCLib \Option-d
+ "{MWPPCLibraries}"MathLib \Option-d
+ "{MWPPCLibraries}"PPCToolLibs.o
+
+# Tool to make PEF with, if needed.
+
+MAKEPEF_NULL = null-command
+
+MAKEPEF_PPC = MakePEF
+
+MAKEPEF_FLAGS = \Option-d
+ -l InterfaceLib.xcoff=InterfaceLib \Option-d
+ -l MathLib.xcoff=MathLib \Option-d
+ -l StdCLib.xcoff=StdCLib
+
+MAKEPEF_TOOL_FLAGS = -ft MPST -fc 'MPS '
+
+# Resource compiler to use.
+
+REZ_68K = Rez
+
+REZ_PPC = Rez -d WANT_CFRG
+
diff --git a/config/mpw/ChangeLog b/config/mpw/ChangeLog
new file mode 100644
index 00000000000..3cdefbf7a75
--- /dev/null
+++ b/config/mpw/ChangeLog
@@ -0,0 +1,53 @@
+Tue Nov 26 12:34:12 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed: Fix some comments.
+
+Mon Sep 16 14:42:52 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed (HLDENV): Edit out all references.
+
+Thu Aug 15 19:49:23 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * true: New script, identical to mpw-true.
+ * g-mpw-make.sed: Add @DASH_C_FLAG@ and @SEGMENT_FLAG()@
+ to the editors for compile commands.
+
+Thu Aug 1 15:01:42 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-true, mpw-touch, null-command: New scripts.
+ * README: Describe usage in more detail.
+
+Tue Dec 12 14:51:51 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed: Don't edit out "version=" occurrences.
+
+Fri Dec 1 11:46:18 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed (bindir, libdir): Edit the positions of
+ pathname separators to work with other pathnames better.
+
+Tue Nov 7 15:08:07 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed: Add comment about Duplicate vs Catenate,
+ add additional pattern for editing link-compile commands.
+
+Tue Oct 24 14:28:51 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed: Add handling for *.tab.[hc] files.
+ (CHILL_FOR_TARGET, CHILL_LIB): Edit out tricky definitions
+ of these.
+
+Thu Sep 28 21:05:10 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * g-mpw-make.sed: New file, generic sed commands to translate
+ Unix makefiles into MPW makefile syntax.
+
+Fri Mar 17 11:51:20 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * README: Clarify instructions.
+ * fi: Remove.
+
+Wed Dec 21 15:45:53 1994 Stan Shebs <shebs@andros.cygnus.com>
+
+ * MoveIfChange, README, fi, forward-include, open-brace,
+ tr-7to8-src: New files.
diff --git a/config/mpw/MoveIfChange b/config/mpw/MoveIfChange
new file mode 100644
index 00000000000..0dbc12582f5
--- /dev/null
+++ b/config/mpw/MoveIfChange
@@ -0,0 +1,19 @@
+# Rename a file only if it is different from a previously existing
+# file of the same name. This is useful for keeping make from doing
+# too much work if the contents of a file haven't changed.
+
+# This is an MPW translation of the standard GNU sh script move-if-change.
+
+Set exit 0
+
+If "`exists -f "{2}"`"
+ Compare "{1}" "{2}" >dev:null
+ If {status} != 0
+ Rename -y "{1}" "{2}"
+ Else
+ Echo "{2}" is unchanged
+ Delete -i -y "{1}"
+ End
+Else
+ Rename -y "{1}" "{2}"
+End
diff --git a/config/mpw/README b/config/mpw/README
new file mode 100644
index 00000000000..554700adc81
--- /dev/null
+++ b/config/mpw/README
@@ -0,0 +1,23 @@
+This directory contains MPW scripts and related files that are needed to
+build Cygnus GNU tools for MPW. The scripts should be somewhere on the
+command path; our usual practice has been to have a separate directory
+for the scripts, and put the tools (byacc, flex, and sed at least) there
+also; then it's easier to drag the support bits around as a group, or to
+upgrade MPW versions. The complete package of scripts and tool binaries
+is usually available as pub/mac/buildtools.cpt.hqx on ftp.cygnus.com.
+
+"tr-7to8-src" is actually the source to an MPW script that transforms
+sequences like "\Option-d" into the actual 8-bit chars that MPW needs.
+It's only the source because it can't itself include any 8-bit chars.
+It *can* be processed into a genuine "tr-7to8" by using itself:
+
+ tr-7to8 tr-7to8-src | sed -e 's/Src//' >new-tr-7to8
+
+Use this to verify:
+
+ compare tr-7to8 new-tr-7to8
+
+If you don't have a working tr-7to8, then you will have to manually
+replace all occurrences of "\Option-d" with real Option-d (which looks
+like a delta), then do similarly with all the other "\Option-..."
+strings, and then change "\SrcOption-d" into the string "\Option-d".
diff --git a/config/mpw/forward-include b/config/mpw/forward-include
new file mode 100644
index 00000000000..ddd6bd71105
--- /dev/null
+++ b/config/mpw/forward-include
@@ -0,0 +1,3 @@
+Echo '#include' ¶""{1}"¶" >"{2}".tem
+MoveIfChange "{2}".tem "{2}"
+
diff --git a/config/mpw/g-mpw-make.sed b/config/mpw/g-mpw-make.sed
new file mode 100644
index 00000000000..e7d3c770736
--- /dev/null
+++ b/config/mpw/g-mpw-make.sed
@@ -0,0 +1,293 @@
+# Sed commands to translate Unix makefiles into MPW makefiles.
+# These are nominally generic, but work best on the makefiles used
+# for GNU programs.
+
+# Whack out any commented-out lines that are probably commands;
+# they can only cause trouble later on.
+/^# /d
+
+# Change dependency char.
+/:$/s/:/ \\Option-f/g
+/^[^ :#][^:]*:/s/\([ ]*\):\([ ]*\)/ \\Option-f /g
+
+# Change syntax of Makefile vars.
+/\$/s/\${\([a-zA-Z0-9_-]*\)}/{\1}/g
+/\$/s/\$(\([a-zA-Z0-9_-]*\))/{\1}/g
+/ $@/s/ $@/ {Targ}/
+
+# Double-$ are literals to Unix but not to MPW make.
+/\$\$/s/\$\$/$/g
+
+# Change pathname syntax.
+/\//s,\.\./\/\.\./,:::,g
+/\//s,\.\./,::,g
+/\.\//s,\./,:,g
+/\//s,/,:,g
+# Undo excess changes.
+/and/s,and:or$,and/or,
+/and/s,and:or ,and/or ,
+/want/s,want:need,want/need,
+# Fixing up sed commands.
+/-e/s_":\([^:]*\):d"_"/\1/d"_g
+/-e/s_":\([^:]*\):,:\([^:]*\):d"_"/\1/,/\2/d"_g
+
+/=/s/ = \.$/ = :/
+
+# Make these go away so that later edits not confused.
+/HLDENV/s/{HLDENV}//
+
+# Comment out any explicit srcdir setting.
+/srcdir/s/^srcdir/# srcdir/
+
+/BASEDIR/s/^BASEDIR =.*$/BASEDIR = "{srcroot}"/
+/{BASEDIR}:/s/{BASEDIR}:/{BASEDIR}/g
+/{srcdir}:/s/{srcdir}:/"{srcdir}"/g
+/"{srcdir}":/s/"{srcdir}":/"{srcdir}"/g
+
+# Tweak some conventions that are backwards for the Mac.
+/bindir/s/{exec_prefix}:bin/{exec_prefix}bin:/
+/libdir/s/{exec_prefix}:lib/{exec_prefix}lib:/
+
+# Comment out settings of anything set by mpw host config.
+/CC/s/^CC *=/#CC =/
+/CFLAGS/s/^CFLAGS *=/#CFLAGS =/
+/AR/s/^AR *=/#AR =/
+/AR_FLAGS/s/^AR_FLAGS *=/#AR_FLAGS =/
+/RANLIB/s/^RANLIB *=/#RANLIB =/
+/CC_LD/s/^CC_LD *=/#CC_LD =/
+/LDFLAGS/s/^LDFLAGS *=/#LDFLAGS =/
+
+# Change -I usages.
+/-I/s/-I\./-i :/g
+/-I/s/-I::bfd/-i ::bfd:/g
+/-I/s/-I::include/-i ::include:/g
+/-I/s/-I/-i /g
+
+# Change -D usage.
+/-D/s/\([ =]\)-D\([^ ]*\)/\1-d \2/g
+
+# Change continuation char.
+/\\$/s/\\$/\\Option-d/
+
+# Change wildcard char.
+/\*/s/\*/\\Option-x/g
+
+# Change path of various types of source files. This rule does not allow
+# for file names with multiple dots in the name.
+/\.[chly]/s/\([ ><=]\)\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/\1"{s}"\2.\3/g
+/\.[chly]/s/^\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/"{s}"\1.\2/
+# Allow files named *.tab.[ch] as a special case.
+/\.tab\.[ch]/s/\([ ><=]\)\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/\1"{s}"\2.\3/g
+/\.tab\.[ch]/s/^\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/"{s}"\1.\2/
+# Fix some overenthusiasms.
+/{s}/s/"{s}""{srcdir}"/"{srcdir}"/g
+/{s}/s/"{s}"{\([a-zA-Z0-9_]*\)dir}/"{\1dir}"/g
+/{s}/s/"{s}"{\([a-zA-Z0-9_]*\)DIR}/"{\1DIR}"/g
+/{s}/s/"{s}""{\([a-zA-Z0-9_]*\)dir}"/"{\1dir}"/g
+/{s}/s/"{s}""{\([a-zA-Z0-9_]*\)DIR}"/"{\1DIR}"/g
+/{s}/s/"{s}":/:/g
+/{s}/s/^"{s}"//g
+/{s}/s/"{s}""{s}"/"{s}"/g
+/{s}/s/"{s}""{srcdir}"/"{s}"/g
+/{s}/s/"{srcdir}""{s}"/"{s}"/g
+
+# The .def files are also typically source files.
+/\.def/s/\([ ><]\)\([-a-zA-Z0-9_${}:"]*\)\.def/\1"{s}"\2.def/g
+/\.def/s/^\([-a-zA-Z0-9_${}:"]*\)\.def/"{s}"\1.def/g
+
+# Change extension and path of objects.
+/\.o/s/\([ =]\)\([-a-zA-Z0-9_${}:"]*\)\.o/\1"{o}"\2.c.o/g
+/\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.o/"{o}"\1.c.o/
+# Allow *.tab.o files as a special case of a 2-dot-name file.
+/\.o/s/\([ =]\)\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/\1"{o}"\2.tab.c.o/g
+/\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/"{o}"\1.tab.c.o/
+# Clean up.
+/"{o}"/s/"{o}""{o}"/"{o}"/g
+/"{o}"/s/^"{o}"\([a-zA-Z0-9_]*\)=/\1=/
+
+# Change extension of libs.
+/\.a/s/lib\([a-z]*\)\.a/lib\1.o/g
+
+# Remove non-fail option.
+/-/s/^\([ ]*\)-/\1/
+# Fix overeagernesses - assumes no one-letter commands.
+/^[ ]*[a-z] /s/^\([ ]*\)\([a-z]\) /\1-\2 /
+
+# Remove non-echo option. (watch out for autoconf things)
+/@/s/^\([ ]*\)@/\1/
+
+# Change cp to Duplicate.
+# Catenate is perhaps more accurate, but the pattern would have to
+# identify the output file and add a '>' redirection into it.
+/cp/s/^\([ ]*\)cp /\1Duplicate -d -y /
+# Change mv to Rename.
+/mv/s/^\([ ]*\)mv /\1Rename -y /
+/Rename/s/^\([ ]*\)Rename -y -f/\1Rename -y/
+# Change rm to Delete.
+/rm -rf/s/^\([ ]*\)rm -rf /\1Delete -i -y /
+/rm -f/s/^\([ ]*\)rm -f /\1Delete -i -y /
+/rm/s/^\([ ]*\)rm /\1Delete -i -y /
+# Note that we don't mess with ln - directory-specific scripts
+# must decide what to do with symlinks.
+# Change cat to Catenate.
+/cat/s/^\([ ]*\)cat /\1Catenate /
+# Change touch to mpw-touch.
+/touch/s/^\([ ]*\)touch /\1mpw-touch /
+# Change mkdir to NewFolder.
+/mkdir/s/^\([ ]*\)mkdir /\1NewFolder /
+# Change var setting to Set.
+/=/s/^\([ ]*\)\([-a-zA-Z0-9_]*\)=\([^;]*\); \\Option-d/\1Set \2 \3/
+
+# Change tests.
+/if /s/if \[ *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/
+/if /s/if \[ *-f \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/
+/if /s/if \[ ! *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/
+/if /s/if \[ ! *-f \([^ ]*\) ] *; *then \\Option-d/If "`Exists "\1"`" == ""/
+
+/if /s/if \[ *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/
+/if /s/if \[ *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/
+/if /s/if \[ ! *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/
+/if /s/if \[ ! *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" == ""/
+
+/if /s/if \[ -d \([^ ]*\) ] *; then true *; else mkdir \([^ ;]*\) *; fi/If "`Exists "\1"`" != "" NewFolder \2 End If/
+
+/if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *\\Option-d/If "\1" == "\2"/
+/if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *then *\\Option-d/If "\1" == "\2"/
+
+/if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/
+/if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/
+
+/if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/
+/if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/
+
+/^[ ]*else true$/c\
+ Else\
+ mpw-true\
+
+
+/else/s/^\([ ]*\)else[ ]*$/\1Else/
+/else/s/^\([ ]*\)else[; ]*\\Option-d$/\1Else/
+
+/^[ ]*else[ ]*true[ ]*$/c\
+ Else\
+ mpw-true
+
+/^[ ]*else[ ]*true[; ]*fi$/c\
+ Else\
+ mpw-true\
+ End If
+
+/fi/s/^\([ ]*\)fi *$/\1End/
+/fi/s/^\([ ]*\)fi *; *\\Option-d/\1End/
+
+# Change looping.
+/for/s/^\([ ]*\)for \([-a-zA-Z0-9_]*\) in \([^;]*\); *do *\\Option-d/\1For \2 In \3/
+/^\([ ]*\)do *\\Option-d/d
+/done/s/^\([ ]*\)done *; *\\Option-d/\1End/
+/done/s/^\([ ]*\)done$/\1End/
+
+# Trailing semicolons and continued lines are unneeded sh syntax.
+/; \\Option-d/s/; \\Option-d//
+
+# Change move-if-change to MoveIfChange.
+/move-if-change/s/\([^ ]*\)move-if-change/MoveIfChange/g
+
+# Change $(SHELL) to the script name by itself.
+/SHELL/s/^\([ ]*\){SHELL} /\1/
+
+# Change syntax of default rule dependency.
+/^\.c\.o/s/^\.c\.o \\Option-f$/.c.o \\Option-f .c/
+
+# Change default rule's action.
+/{CC} -c/s/{CC} -c \(.*\) \$<$/{CC} @DASH_C_FLAG@ {DepDir}{Default}.c \1 @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o/
+
+# This is pretty disgusting, but I can't seem to detect empty rules.
+/Option-f$/s/Option-f$/Option-f _oldest/g
+
+# Remove -c from explicit compiler calls. (but should not if GCC)
+# Handle the case of a source file that is "{xxx}"file.c.
+/ -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\)\.c/{\1CC}\2 @DASH_C_FLAG@ \3"\4"\5.c -o "{o}"\5.c.o/
+# Handle the case of a source file that is "{xxx}"dir:file.c.
+/ -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\):\([-a-z_]*\)\.c/{\1CC}\2 @DASH_C_FLAG@ \3"\4"\5:\6.c -o "{o}"\6.c.o/
+
+# Change linking cc to linking sequence.
+/-o/s/^\([ ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\){LDFLAGS} \(.*\)-o \([^ ]*\) \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \5 -o \6{PROG_EXT} \7\
+\1{MAKEPEF} \6{PROG_EXT} -o \6 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
+\1{REZ} "{s}"\6.r -o \6 -append -d PROG_NAME='"'\6'"' -d VERSION_STRING='"'{version}'"'/
+/-o/s/^\([ ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\)-o \([^ ]*\) \(.*\){LDFLAGS} \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \6 -o \5{PROG_EXT} \7\
+\1{MAKEPEF} \5{PROG_EXT} -o \5 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
+\1{REZ} "{s}"\5.r -o \5 -append -d PROG_NAME='"'\5'"' -d VERSION_STRING='"'{version}'"'/
+/-o/s/^\([ ]*\){HOST_CC} \(.*\)-o \([^ ]*\) \(.*\)$/\1{HOST_CC_LD} \2 -o \3{PROG_EXT} \4\
+\1{MAKEPEF} \3{PROG_EXT} -o \3 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
+\1{REZ} "{s}"\3.r -o \3 -append -d PROG_NAME='"'\3'"' -d VERSION_STRING='"'{version}'"'/
+
+# Comment out .NOEXPORT rules.
+/\.NOEXPORT/s/^\.NOEXPORT/#\.NOEXPORT/
+# Comment out .PHONY rules.
+/\.PHONY/s/^\.PHONY/#\.PHONY/
+# Comment out .PRECIOUS rules.
+/\.PRECIOUS/s/^\.PRECIOUS/#\.PRECIOUS/
+# Comment out .SUFFIXES rules.
+/\.SUFFIXES/s/^\.SUFFIXES/#\.SUFFIXES/
+
+# Set the install program appropriately.
+/INSTALL/s/^INSTALL *= *`.*`:install.sh -c/INSTALL = Duplicate -y/
+
+# Don't try to decide whether to use the tree's own tools.
+/bison/s/`.*bison:bison.*`/bison -y/
+/byacc/s/`.*byacc:byacc.*`/byacc/
+/flex/s/`.*flex:flex.*`/flex/
+
+# Turn transformed C comments in echo commands back into comments.
+/echo/s,echo '\(.*\):\\Option-x\(.*\)\\Option-x:\(.*\)',echo '\1/*\2*/\3',
+
+# Whack out various clever expressions that search for tools, since
+# the clever code is too /bin/sh specific.
+
+/^AR_FOR_TARGET = `/,/`$/c\
+AR_FOR_TARGET = ::binutils:ar\
+
+
+/^RANLIB_FOR_TARGET = `/,/`$/c\
+RANLIB_FOR_TARGET = ::binutils:ranlib\
+
+
+/^RANLIB_TEST_FOR_TARGET = /,/ranlib ] )$/c\
+RANLIB_TEST_FOR_TARGET = \
+
+
+/^EXPECT = `/,/`$/c\
+EXPECT = \
+
+
+/^RUNTEST = `/,/`$/c\
+RUNTEST = \
+
+
+/^CC_FOR_TARGET = `/,/`$/c\
+CC_FOR_TARGET = \
+
+
+/^CXX_FOR_TARGET = `/,/`$/c\
+CXX_FOR_TARGET = \
+
+
+/^CHILL_FOR_TARGET = `/,/`$/c\
+CHILL_FOR_TARGET = \
+
+
+/^CHILL_LIB = `/,/`$/c\
+CHILL_LIB = \
+
+/sanit/s/{start-sanit...-[a-z0-9]*}//
+/sanit/s/{end-sanit...-[a-z0-9]*}//
+
+# Add standard defines and default rules.
+/^# srcdir/a\
+\
+s = "{srcdir}"\
+\
+o = :\
+\
+"{o}" \\Option-f : "{s}"
+
diff --git a/config/mpw/mpw-touch b/config/mpw/mpw-touch
new file mode 100644
index 00000000000..c743a5122b5
--- /dev/null
+++ b/config/mpw/mpw-touch
@@ -0,0 +1,7 @@
+# "Touch" command.
+
+If "`Exists "{1}"`" != ""
+ SetFile -m . "{1}"
+Else
+ Echo ' ' > "{1}"
+End If
diff --git a/config/mpw/mpw-true b/config/mpw/mpw-true
new file mode 100644
index 00000000000..0506530d3c6
--- /dev/null
+++ b/config/mpw/mpw-true
@@ -0,0 +1 @@
+Exit 0
diff --git a/config/mpw/null-command b/config/mpw/null-command
new file mode 100644
index 00000000000..4844c8ec553
--- /dev/null
+++ b/config/mpw/null-command
@@ -0,0 +1 @@
+# This command does nothing.
diff --git a/config/mpw/open-brace b/config/mpw/open-brace
new file mode 100644
index 00000000000..58465dcc18c
--- /dev/null
+++ b/config/mpw/open-brace
@@ -0,0 +1,4 @@
+# MPW makefiles seem not to have any way to get a literal open
+# brace into a rule anywhere, so this does the job.
+
+Echo '{'
diff --git a/config/mpw/tr-7to8-src b/config/mpw/tr-7to8-src
new file mode 100644
index 00000000000..b20b649c895
--- /dev/null
+++ b/config/mpw/tr-7to8-src
@@ -0,0 +1,9 @@
+StreamEdit -e \Option-d
+ '/\Option-x/ \Option-d
+ Replace /\Option-d\SrcOption-d/ "\Option-d\Option-d" -c \Option-5 ; \Option-d
+ Replace /\Option-d\SrcOption-f/ "\Option-d\Option-f" -c \Option-5 ; \Option-d
+ Replace /\Option-d\SrcOption-8/ "\Option-d\Option-8" -c \Option-5 ; \Option-d
+ Replace /\Option-d\SrcOption-5/ "\Option-d\Option-5" -c \Option-5 ; \Option-d
+ Replace /\Option-d\SrcOption-x/ "\Option-d\Option-x" -c \Option-5 ; \Option-d
+ Replace /\Option-d\SrcOption-r/ "\Option-d\Option-r" -c \Option-5' \Option-d
+ "{1}"
diff --git a/config/mpw/true b/config/mpw/true
new file mode 100644
index 00000000000..0506530d3c6
--- /dev/null
+++ b/config/mpw/true
@@ -0,0 +1 @@
+Exit 0
diff --git a/config/mt-armpic b/config/mt-armpic
new file mode 100644
index 00000000000..35b8c9e4dc2
--- /dev/null
+++ b/config/mt-armpic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-d30v b/config/mt-d30v
new file mode 100644
index 00000000000..d34b774b3f6
--- /dev/null
+++ b/config/mt-d30v
@@ -0,0 +1,4 @@
+# Build libraries optimizing for space, not speed.
+# Turn off warnings about symbols named the same as registers
+ CFLAGS_FOR_TARGET = -g -Os -Wa,-C
+ CXXFLAGS_FOR_TARGET = -g -Os -Wa,-C
diff --git a/config/mt-elfalphapic b/config/mt-elfalphapic
new file mode 100644
index 00000000000..35b8c9e4dc2
--- /dev/null
+++ b/config/mt-elfalphapic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-linux b/config/mt-linux
new file mode 100644
index 00000000000..a09e6f18af5
--- /dev/null
+++ b/config/mt-linux
@@ -0,0 +1,2 @@
+# When using glibc 2 on Linux we must always use vtable thunks.
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -fvtable-thunks -D_GNU_SOURCE
diff --git a/config/mt-m68kpic b/config/mt-m68kpic
new file mode 100644
index 00000000000..ff987275575
--- /dev/null
+++ b/config/mt-m68kpic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=-fpic
diff --git a/config/mt-netware b/config/mt-netware
new file mode 100644
index 00000000000..9482f9b36d2
--- /dev/null
+++ b/config/mt-netware
@@ -0,0 +1 @@
+GDB_NLM_DEPS = all-gcc all-ld
diff --git a/config/mt-ospace b/config/mt-ospace
new file mode 100644
index 00000000000..7f091041d8a
--- /dev/null
+++ b/config/mt-ospace
@@ -0,0 +1,3 @@
+# Build libraries optimizing for space, not speed.
+ CFLAGS_FOR_TARGET = -g -Os
+ CXXFLAGS_FOR_TARGET = -g -Os
diff --git a/config/mt-papic b/config/mt-papic
new file mode 100644
index 00000000000..35b8c9e4dc2
--- /dev/null
+++ b/config/mt-papic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-ppcpic b/config/mt-ppcpic
new file mode 100644
index 00000000000..35b8c9e4dc2
--- /dev/null
+++ b/config/mt-ppcpic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-sparcpic b/config/mt-sparcpic
new file mode 100644
index 00000000000..fd0ec271afc
--- /dev/null
+++ b/config/mt-sparcpic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=`case "${LIBCFLAGS} ${LIBCXXFLAGS}" in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
diff --git a/config/mt-v810 b/config/mt-v810
new file mode 100644
index 00000000000..97da6c26592
--- /dev/null
+++ b/config/mt-v810
@@ -0,0 +1,4 @@
+CC_FOR_TARGET = ca732 -ansi
+AS_FOR_TARGET = as732
+AR_FOR_TARGET = ar732
+RANLIB_FOR_TARGET = true
diff --git a/config/mt-x86pic b/config/mt-x86pic
new file mode 100644
index 00000000000..ff987275575
--- /dev/null
+++ b/config/mt-x86pic
@@ -0,0 +1 @@
+PICFLAG_FOR_TARGET=-fpic
diff --git a/configure b/configure
new file mode 100755
index 00000000000..cad60b77c50
--- /dev/null
+++ b/configure
@@ -0,0 +1,1595 @@
+#!/bin/sh
+
+### WARNING: this file contains embedded tabs. Do not run untabify on this file.
+
+# Configuration script
+# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 1997
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was originally written by K. Richard Pixley.
+
+#
+# Shell script to create proper links to machine-dependent files in
+# preparation for compilation.
+#
+# If configure succeeds, it leaves its status in config.status.
+# If configure fails after disturbing the status quo,
+# config.status is removed.
+#
+
+export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
+
+remove=rm
+hard_link=ln
+symbolic_link='ln -s'
+
+#for Test
+#remove="echo rm"
+#hard_link="echo ln"
+#symbolic_link="echo ln -s"
+
+# clear some things potentially inherited from environment.
+
+Makefile=Makefile
+Makefile_in=Makefile.in
+arguments=
+build_alias=
+cache_file=config.cache
+cache_file_option=
+configdirs=
+extraconfigdirs=
+diroptions=
+exec_prefix=
+exec_prefixoption=
+fatal=
+floating_point=default
+gas=default
+gcc_version=
+gcc_version_trigger=
+host_alias=NOHOST
+host_makefile_frag=
+moveifchange=
+norecursion=
+other_options=
+package_makefile_frag=
+package_makefile_rules_frag=
+prefix=/usr/local
+progname=
+program_prefix=
+program_prefixoption=
+program_suffix=
+program_suffixoption=
+program_transform_name=
+program_transform_nameoption=
+redirect=
+removing=
+site=
+site_makefile_frag=
+site_option=
+srcdir=
+srctrigger=
+subdirs=
+target_alias=NOTARGET
+target_makefile_frag=
+undefs=NOUNDEFS
+version="$Revision$"
+x11=default
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+### we might need to use some other shell than /bin/sh for running subshells
+
+### If we are on Windows, search for the shell. This will permit people
+### to not have /bin/sh, but to be able to see /SOME/PATH/sh configure
+### without also having to set CONFIG_SHELL. This code will work when
+### using bash, which sets OSTYPE.
+case "${OSTYPE}" in
+*win32*)
+ if [ x${CONFIG_SHELL} = x ]; then
+ if [ ! -f /bin/sh ]; then
+ if [ x${SHELL} != x ] && [ -f ${SHELL} ]; then
+ CONFIG_SHELL=${SHELL}
+ export CONFIG_SHELL
+ else
+ for prog in sh sh.exe bash bash.exe; do
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/$prog; then
+ CONFIG_SHELL=$dir/$prog
+ export CONFIG_SHELL
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ test -n "${CONFIG_SHELL}" && break
+ done
+ fi
+ fi
+ fi
+ ;;
+esac
+
+config_shell=${CONFIG_SHELL-/bin/sh}
+
+NO_EDIT="This file was generated automatically by configure. Do not edit."
+
+## this is a little touchy and won't always work, but...
+##
+## if the argv[0] starts with a slash then it is an absolute name that can (and
+## must) be used as is.
+##
+## otherwise, if argv[0] has no slash in it, we can assume that it is on the
+## path. Since PATH might include "." we also add `pwd` to the end of PATH.
+##
+
+progname=$0
+# if PWD already has a value, it is probably wrong.
+if [ -n "$PWD" ]; then PWD=`pwd`; fi
+
+case "${progname}" in
+/*) ;;
+*/*) ;;
+*)
+ PATH=$PATH:${PWD=`pwd`} ; export PATH
+ ;;
+esac
+
+# Loop over all args
+
+while :
+do
+
+# Break out if there are no more args
+ case $# in
+ 0)
+ break
+ ;;
+ esac
+
+# Get the first arg, and shuffle
+ option=$1
+ shift
+
+# Make all options have two hyphens
+ orig_option=$option # Save original for error messages
+ case $option in
+ --*) ;;
+ -*) option=-$option ;;
+ esac
+
+# Split out the argument for options that take them
+ case $option in
+ --*=*)
+ optarg=`echo $option | sed -e 's/^[^=]*=//'`
+ arguments="$arguments $option"
+ ;;
+# These options have mandatory values. Since we didn't find an = sign,
+# the value must be in the next argument
+ --bu* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-* | --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
+ optarg=$1
+ shift
+ arguments="$arguments $option=$optarg"
+ ;;
+ --v)
+ arguments="$arguments -v"
+ ;;
+ --*)
+ arguments="$arguments $option"
+ ;;
+ esac
+
+# Now, process the options
+ case $option in
+
+ --bi*)
+ bindir=$optarg
+ diroptions="$diroptions --bindir=$optarg"
+ ;;
+ --build* | --bu*)
+ case "$build_alias" in
+ "") build_alias=$optarg ;;
+ *) echo '***' Can only configure for one build machine at a time. 1>&2
+ fatal=yes
+ ;;
+ esac
+ ;;
+ --cache*)
+ cache_file=$optarg
+ ;;
+ --da*)
+ datadir=$optarg
+ diroptions="$diroptions --datadir=$optarg"
+ ;;
+ --disable-*)
+ enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
+ eval $enableopt=no
+ disableoptions="$disableoptions $option"
+ ;;
+ --enable-*)
+ case "$option" in
+ *=*) ;;
+ *) optarg=yes ;;
+ esac
+
+ enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
+ eval "$enableopt='$optarg'"
+ enableoptions="$enableoptions '$option'"
+ ;;
+ --exec-prefix* | --ex*)
+ exec_prefix=$optarg
+ exec_prefixoption="--exec-prefix=$optarg"
+ ;;
+ --gas | --g*)
+ gas=yes
+ ;;
+ --help | --he*)
+ fatal=yes
+ ;;
+ --host* | --ho*)
+ case $host_alias in
+ NOHOST) host_alias=$optarg ;;
+ *) echo '***' Can only configure for one host at a time. 1>&2
+ fatal=yes
+ ;;
+ esac
+ ;;
+ --inc*)
+ includedir=$optarg
+ diroptions="$diroptions --includedir=$optarg"
+ ;;
+ --inf*)
+ infodir=$optarg
+ diroptions="$diroptions --infodir=$optarg"
+ ;;
+ --libd*)
+ libdir=$optarg
+ diroptions="$diroptions --libdir=$optarg"
+ ;;
+ --libe*)
+ libexecdir=$optarg
+ diroptions="$diroptions --libexecdir=$optarg"
+ ;;
+ --lo*)
+ localstatedir=$optarg
+ diroptions="$diroptions --localstatedir=$optarg"
+ ;;
+ --ma*)
+ mandir=$optarg
+ diroptions="$diroptions --mandir=$optarg"
+ ;;
+ --nfp | --nf*)
+ floating_point=no
+ floating_pointoption="--nfp"
+ ;;
+ --norecursion | --no*)
+ norecursion=yes
+ ;;
+ --ol*)
+ oldincludedir=$optarg
+ diroptions="$diroptions --oldincludedir=$optarg"
+ ;;
+ --prefix* | --pre*)
+ prefix=$optarg
+ prefixoption="--prefix=$optarg"
+ ;;
+ --program-prefix* | --program-p*)
+ program_prefix=$optarg
+ program_prefixoption="--program-prefix=$optarg"
+ ;;
+ --program-suffix* | --program-s*)
+ program_suffix=$optarg
+ program_suffixoption="--program-suffix=$optarg"
+ ;;
+ --program-transform-name* | --program-t*)
+ # Double any backslashes or dollar signs in the argument
+ program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
+ program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
+ ;;
+ --rm)
+ removing=--rm
+ ;;
+ --sb*)
+ sbindir=$optarg
+ diroptions="$diroptions --sbindir=$optarg"
+ ;;
+ --sh*)
+ sharedstatedir=$optarg
+ diroptions="$diroptions --sharedstatedir=$optarg"
+ ;;
+ --silent | --sil* | --quiet | --q*)
+ redirect=">/dev/null"
+ verbose=--silent
+ ;;
+ --site* | --sit*)
+ site=$optarg
+ site_option="--site=$optarg"
+ ;;
+ --srcdir*/ | --sr*/)
+ # Remove trailing slashes. Otherwise, when the file name gets
+ # bolted into an object file as debug info, it has two slashes
+ # in it. Ordinarily this is ok, but emacs takes double slash
+ # to mean "forget the first part".
+ srcdir=`echo $optarg | sed -e 's:/$::'`
+ ;;
+ --srcdir* | --sr*)
+ srcdir=$optarg
+ ;;
+ --sy*)
+ sysconfdir=$optarg
+ diroptions="$diroptions --sysconfdir=$optarg"
+ ;;
+ --target* | --ta*)
+ case $target_alias in
+ NOTARGET) target_alias=$optarg ;;
+ *) echo '***' Can only configure for one target at a time. 1>&2
+ fatal=yes
+ ;;
+ esac
+ ;;
+ --tmpdir* | --tm*)
+ TMPDIR=$optarg
+ tmpdiroption="--tmpdir=$optarg"
+ ;;
+ --verbose | --v | --verb*)
+ redirect=
+ verbose=--verbose
+ ;;
+ --version | --V | --vers*)
+ echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
+ exit 0
+ ;;
+ --with-*)
+ case "$option" in
+ *=*) ;;
+ *) optarg=yes ;;
+ esac
+
+ withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
+ eval $withopt="$optarg"
+ withoptions="$withoptions $option"
+ ;;
+ --without-*)
+ withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
+ eval $withopt=no
+ withoutoptions="$withoutoptions $option"
+ ;;
+ --x) with_x=yes
+ withoptions="$withoptions --with-x"
+ ;;
+ --x-i* | --x-l*) other_options="$other_options $orig_option"
+ ;;
+ --*)
+ echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
+ exit 1
+ ;;
+ *)
+ case $undefs in
+ NOUNDEFS) undefs=$option ;;
+ *) echo '***' Can only configure for one host and one target at a time. 1>&2
+ fatal=yes
+ ;;
+ esac
+ ;;
+ esac
+done
+
+# process host and target
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET UNDEFS
+#
+# The rules are:
+# 1. You aren't allowed to specify --host, --target, and undefs at the
+# same time.
+# 2. Host defaults to undefs.
+# 3. If undefs is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target defaults to undefs.
+# 5. If undefs is not specified, then target defaults to host.
+
+case "${fatal}" in
+"")
+ # Make sure that host, target & undefs aren't all specified at the
+ # same time.
+ case $host_alias---$target_alias---$undefs in
+ NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
+ ;;
+ *) echo '***' Can only configure for one host and one target at a time. 1>&2
+ fatal=yes
+ break 2
+ ;;
+ esac
+
+ # Now, do defaulting for host.
+ case $host_alias in
+ NOHOST)
+ case $undefs in
+ NOUNDEFS)
+ # Neither --host option nor undefs were present.
+ # Call config.guess.
+ guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
+ if host_alias=`${config_shell} ${guesssys}`
+ then
+ # If the string we are going to use for
+ # the target is a prefix of the string
+ # we just guessed for the host, then
+ # assume we are running native, and force
+ # the same string for both target and host.
+ case $target_alias in
+ NOTARGET) ;;
+ *)
+ if expr $host_alias : $target_alias >/dev/null
+ then
+ host_alias=$target_alias
+ fi
+ ;;
+ esac
+ echo "Configuring for a ${host_alias} host." 1>&2
+ arguments="--host=$host_alias $arguments"
+ else
+ echo 'Config.guess failed to determine the host type. You need to specify one.' 1>&2
+ fatal=yes
+ fi
+ ;;
+ *)
+ host_alias=$undefs
+ arguments="--host=$host_alias $arguments"
+ undefs=NOUNDEFS
+ ;;
+ esac
+ esac
+
+ # Do defaulting for target. If --target option isn't present, default
+ # to undefs. If undefs isn't present, default to host.
+ case $target_alias in
+ NOTARGET)
+ case $undefs in
+ NOUNDEFS)
+ target_alias=$host_alias
+ ;;
+ *)
+ target_alias=$undefs
+ arguments="--target=$target_alias $arguments"
+ ;;
+ esac
+ esac
+ ;;
+*) ;;
+esac
+
+if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
+ exec 1>&2
+ echo Usage: configure [OPTIONS] [HOST]
+ echo
+ echo Options: [defaults in brackets]
+ echo ' --prefix=MYDIR install into MYDIR [/usr/local]'
+ echo ' --exec-prefix=MYDIR install host-dependent files into MYDIR [/usr/local]'
+ echo ' --help print this message [normal config]'
+ echo ' --build=BUILD configure for building on BUILD [BUILD=HOST]'
+ echo ' --host=HOST configure for HOST [determined via config.guess]'
+ echo ' --norecursion configure this directory only [recurse]'
+ echo ' --program-prefix=FOO prepend FOO to installed program names [""]'
+ echo ' --program-suffix=FOO append FOO to installed program names [""]'
+ echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
+ echo ' --site=SITE configure with site-specific makefile for SITE'
+ echo ' --srcdir=DIR find the sources in DIR [. or ..]'
+ echo ' --target=TARGET configure for TARGET [TARGET=HOST]'
+ echo ' --tmpdir=TMPDIR create temporary files in TMPDIR [/tmp]'
+ echo ' --nfp configure for software floating point [hard float]'
+ echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
+ echo ' --without-FOO package FOO is NOT available'
+ echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
+ echo ' --disable-FOO do not include feature FOO'
+ echo
+ echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
+ echo
+ if [ -r config.status ] ; then
+ cat config.status
+ fi
+
+ exit 1
+fi
+
+configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
+moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
+topsrcdir=`cd \`dirname ${progname}\`; pwd`
+
+
+# this is a hack. sun4 must always be a valid host alias or this will fail.
+if ${config_shell} ${configsub} sun4 >/dev/null 2>&1 ; then
+ true
+else
+ echo '***' cannot find config.sub. 1>&2
+ exit 1
+fi
+
+touch config.junk
+if ${config_shell} ${moveifchange} config.junk config.trash ; then
+ true
+else
+ echo '***' cannot find move-if-change. 1>&2
+ exit 1
+fi
+rm -f config.junk config.trash
+
+case "${srcdir}" in
+"")
+ if [ -r configure.in ] ; then
+ srcdir=.
+ else
+ if [ -r ${progname}.in ] ; then
+ srcdir=`echo ${progname} | sed 's:/configure$::'`
+ else
+ echo '***' "Can't find configure.in. Try using --srcdir=some_dir" 1>&2
+ exit 1
+ fi
+ fi
+ ;;
+*)
+ # Set srcdir to "." if that's what it is.
+ # This is important for multilib support.
+ if [ ! -d ${srcdir} ] ; then
+ echo "Invalid source directory ${srcdir}" >&2
+ exit 1
+ fi
+ pwd=`pwd`
+ srcpwd=`cd ${srcdir} ; pwd`
+ if [ "${pwd}" = "${srcpwd}" ] ; then
+ srcdir=.
+ fi
+esac
+
+### warn about some conflicting configurations.
+
+case "${srcdir}" in
+".") ;;
+*)
+ if [ -f ${srcdir}/config.status ] ; then
+ echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
+ exit 1
+ fi
+esac
+
+
+# default exec_prefix
+case "${exec_prefixoption}" in
+"") exec_prefix="\$(prefix)" ;;
+*) ;;
+esac
+
+# Define the trigger file to make sure configure will re-run whenever
+# the gcc version number changes.
+if [ "${with_gcc_version_trigger+set}" = set ]; then
+ gcc_version_trigger="$with_gcc_version_trigger"
+ gcc_version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < ${with_gcc_version_trigger}`
+else
+ # If gcc's sources are available, define the trigger file.
+ if [ -f ${topsrcdir}/gcc/version.c ] ; then
+ gcc_version_trigger=${topsrcdir}/gcc/version.c
+ gcc_version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < ${gcc_version_trigger}`
+ case "$arguments" in
+ *--with-gcc-version-trigger=$gcc_version_trigger* )
+ ;;
+ * )
+ # Make sure configure.in knows about this.
+ arguments="--with-gcc-version-trigger=$gcc_version_trigger $arguments"
+ ;;
+ esac
+ withoptions="--with-gcc-version-trigger=$gcc_version_trigger $withoptions"
+ fi
+fi
+
+### break up ${srcdir}/configure.in.
+case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
+"")
+ echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
+ # Check for a directory that's been converted to use autoconf since
+ # it was last configured.
+ if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
+ echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
+ if [ -r ${srcdir}/configure ] ; then
+ echo '***' Running the local configure script. 1>&2
+ case "${cache_file}" in
+ "") cache_file_option= ;;
+ *) cache_file_option="--cache-file=${cache_file}" ;;
+ esac
+ srcdiroption="--srcdir=${srcdir}"
+ case "${build_alias}" in
+ "") buildopt= ;;
+ *) buildopt="--build=${build_alias}" ;;
+ esac
+ eval exec ${config_shell} ${srcdir}/configure ${verbose} \
+ ${buildopt} --host=${host_alias} --target=${target_alias} \
+ ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
+ ${srcdiroption} ${diroptions} \
+ ${program_prefixoption} ${program_suffixoption} \
+ ${program_transform_nameoption} ${site_option} \
+ ${withoptions} ${withoutoptions} \
+ ${enableoptions} ${disableoptions} ${floating_pointoption} \
+ ${cache_file_option} ${removing} ${other_options} ${redirect}
+ else
+ echo '***' There is no configure script present though. 1>&2
+ fi
+ fi
+ exit 1
+ ;;
+*) ;;
+esac
+
+case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
+"")
+ echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
+ exit 1
+ ;;
+*) ;;
+esac
+
+case "${TMPDIR}" in
+"") TMPDIR=/tmp ; export TMPDIR ;;
+*) ;;
+esac
+
+# keep this filename short for &%*%$*# 14 char file names
+tmpfile=${TMPDIR}/cONf$$
+# Note that under many versions of sh a trap handler for 0 will *override* any
+# exit status you explicitly specify! At this point, the only non-error exit
+# is at the end of the script; these actions are duplicated there, minus
+# the "exit 1". Don't use "exit 0" anywhere after this without resetting the
+# trap handler, or you'll lose.
+trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
+
+# split ${srcdir}/configure.in into common, per-host, per-target,
+# and post-target parts. Post-target is optional.
+sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
+sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
+if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
+ sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
+ sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
+else
+ sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
+ echo >${tmpfile}.pos
+fi
+
+### do common part of configure.in
+
+# If the language specific compiler does not exist, but the "gcc" directory does,
+# we will skip this directory; in this case the sub-directory's common part
+# of configure.in will create a small shell script "skip-this-dir" containing
+# commands to completely clean up any temporary or created files.
+
+. ${tmpfile}.com
+
+if test -f skip-this-dir; then
+ # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
+ # and reset the trap handler.
+ trap 0
+ rm -f Makefile* ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
+ # Execute the final clean-up actions
+ ${config_shell} skip-this-dir
+ # and stop configuring this directory.
+ exit 0
+fi
+
+# some sanity checks on configure.in
+case "${srctrigger}" in
+"")
+ echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2
+ exit 1
+ ;;
+*) ;;
+esac
+
+case "${build_alias}" in
+"")
+ if result=`${config_shell} ${configsub} ${host_alias}` ; then
+ build_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ build_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ build_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ build=${build_cpu}-${build_vendor}-${build_os}
+ build_alias=${host_alias}
+ fi
+ ;;
+*)
+ if result=`${config_shell} ${configsub} ${build_alias}` ; then
+ buildopt="--build=${build_alias}"
+ build_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ build_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ build_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ build=${build_cpu}-${build_vendor}-${build_os}
+ else
+ echo "Unrecognized build system name ${build_alias}." 1>&2
+ exit 1
+ fi
+ ;;
+esac
+
+if result=`${config_shell} ${configsub} ${host_alias}` ; then
+ true
+else
+ echo "Unrecognized host system name ${host_alias}." 1>&2
+ exit 1
+fi
+host_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+host=${host_cpu}-${host_vendor}-${host_os}
+
+. ${tmpfile}.hst
+
+if result=`${config_shell} ${configsub} ${target_alias}` ; then
+ true
+else
+ echo "Unrecognized target system name ${target_alias}." 1>&2
+ exit 1
+fi
+target_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+target=${target_cpu}-${target_vendor}-${target_os}
+
+. ${tmpfile}.tgt
+
+# Find the source files, if location was not specified.
+case "${srcdir}" in
+"")
+ srcdirdefaulted=1
+ srcdir=.
+ if [ ! -r ${srctrigger} ] ; then
+ srcdir=..
+ fi
+ ;;
+*) ;;
+esac
+
+if [ ! -r ${srcdir}/${srctrigger} ] ; then
+ case "${srcdirdefaulted}" in
+ "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
+ *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
+ esac
+
+ echo '***' \(At least ${srctrigger} is missing.\) 1>&2
+ exit 1
+fi
+
+# Some systems (e.g., one of the i386-aix systems the gas testers are
+# using) don't handle "\$" correctly, so don't use it here.
+tooldir='$(exec_prefix)'/${target_alias}
+
+if [ "${host_alias}" != "${target_alias}" ] ; then
+ if [ "${program_prefixoption}" = "" ] ; then
+ if [ "${program_suffixoption}" = "" ] ; then
+ if [ "${program_transform_nameoption}" = "" ] ; then
+ program_prefix=${target_alias}- ;
+ fi
+ fi
+ fi
+fi
+
+# Merge program_prefix and program_suffix onto program_transform_name.
+# (program_suffix used to use $, but it's hard to preserve $ through both
+# make and sh.)
+if [ "${program_suffix}" != "" ] ; then
+ program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
+fi
+
+if [ "${program_prefix}" != "" ] ; then
+ program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
+fi
+
+# If CC and CXX are not set in the environment, and the Makefile
+# exists, try to extract them from it. This is to handle running
+# ./config.status by hand.
+if [ -z "${CC}" ] && [ -r Makefile ]; then
+ sed -n -e ':loop
+/\\$/ N
+s/\\\n//g
+t loop
+/^CC[ ]*=/ s/CC[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
+ CC=`tail -1 Makefile.cc`
+ rm -f Makefile.cc
+fi
+
+if [ -z "${CFLAGS}" ] && [ -r Makefile ]; then
+ sed -n -e ':loop
+/\\$/ N
+s/\\\n//g
+t loop
+/^CFLAGS[ ]*=/ s/CFLAGS[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
+ CFLAGS=`tail -1 Makefile.cc`
+ rm -f Makefile.cc
+fi
+
+if [ -z "${CXX}" ] && [ -r Makefile ]; then
+ sed -n -e ':loop
+/\\$/ N
+s/\\\n//g
+t loop
+/^CXX[ ]*=/ s/CXX[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
+ CXX=`tail -1 Makefile.cc`
+ rm -f Makefile.cc
+fi
+
+if [ -z "${CXXFLAGS}" ] && [ -r Makefile ]; then
+ sed -n -e ':loop
+/\\$/ N
+s/\\\n//g
+t loop
+/^CXXFLAGS[ ]*=/ s/CXXFLAGS[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
+ CXXFLAGS=`tail -1 Makefile.cc`
+ rm -f Makefile.cc
+fi
+
+# Generate a default definition for YACC. This is used if the makefile can't
+# locate bison or byacc in objdir.
+
+for prog in 'bison -y' byacc yacc
+do
+ set dummy $prog; tmp=$2
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/$tmp; then
+ DEFAULT_YACC="$prog"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+
+ test -n "$DEFAULT_YACC" && break
+done
+
+# Generate a default definition for M4. This is used if the makefile can't
+# locate m4 in objdir.
+
+for prog in gm4 gnum4 m4
+do
+ set dummy $prog; tmp=$2
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/$tmp; then
+ DEFAULT_M4="$prog"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+
+ test -n "$DEFAULT_M4" && break
+done
+
+# Generate a default definition for LEX. This is used if the makefile can't
+# locate flex in objdir.
+
+for prog in flex lex
+do
+ set dummy $prog; tmp=$2
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/$tmp; then
+ DEFAULT_LEX="$prog"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+
+ test -n "$DEFAULT_LEX" && break
+done
+
+if [ "${build}" != "${host}" ]; then
+ # If we are doing a Canadian Cross, in which the host and build systems
+ # are not the same, we set reasonable default values for the tools.
+
+ tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
+ tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET"
+ tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET GCC_FOR_TARGET HOST_PREFIX"
+ tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
+ tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
+ tools="${tools} WINDRES WINDRES_FOR_TARGET YACC"
+
+ for var in ${tools}; do
+ if [ -z "`eval 'echo $'"${var}"`" ] && [ -r Makefile ]; then
+ sed -n -e ':loop
+/\\$/ N
+s/\\\n//g
+t loop
+/^'"${var}"'[ ]*=/ s/'"${var}"'[ ]*=[ ]*\(.*\)/\1/p' \
+ < Makefile > Makefile.v
+ t=`tail -1 Makefile.v`
+ if [ -n "${t}" ]; then
+ eval "${var}='${t}'"
+ fi
+ rm -f Makefile.v
+ fi
+ done
+
+ AR=${AR-${host_alias}-ar}
+ AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar}
+ AS=${AS-${host_alias}-as}
+ AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as}
+ BISON=${BISON-bison}
+ CC=${CC-${host_alias}-gcc}
+ CFLAGS=${CFLAGS-"-g -O2"}
+ CXX=${CXX-${host_alias}-c++}
+ CXXFLAGS=${CXXFLAGS-"-g -O2"}
+ CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
+ CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
+ CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-c++}
+ DLLTOOL=${DLLTOOL-${host_alias}-dlltool}
+ DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool}
+ GCC_FOR_TARGET=${GCC_FOR_TARGET-${CC_FOR_TARGET-${target_alias}-gcc}}
+ HOST_PREFIX=${build_alias}-
+ HOST_PREFIX_1=${build_alias}-
+ LD=${LD-${host_alias}-ld}
+ LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld}
+ MAKEINFO=${MAKEINFO-makeinfo}
+ NM=${NM-${host_alias}-nm}
+ NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm}
+ RANLIB=${RANLIB-${host_alias}-ranlib}
+ RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib}
+ WINDRES=${WINDRES-${host_alias}-windres}
+ WINDRES_FOR_TARGET=${WINDRES_FOR_TARGET-${target_alias}-windres}
+
+ if [ -z "${YACC}" ]; then
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/bison; then
+ YACC="bison -y"
+ break
+ fi
+ if test -f $dir/byacc; then
+ YACC=byacc
+ break
+ fi
+ if test -f $dir/yacc; then
+ YACC=yacc
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if [ -z "${YACC}" ]; then
+ YACC="bison -y"
+ fi
+ fi
+
+ if [ -z "${LEX}" ]; then
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/flex; then
+ LEX=flex
+ break
+ fi
+ if test -f $dir/lex; then
+ LEX=lex
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ LEX=${LEX-flex}
+ fi
+
+ # Export variables which autoconf might try to set.
+ export AS
+ export AR
+ export CC_FOR_BUILD
+ export DLLTOOL
+ export LD
+ export NM
+ export RANLIB
+ export WINDRES
+else
+ # If CC is still not set, try to get gcc.
+ if [ -z "${CC}" ]; then
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/gcc; then
+ CC="gcc"
+ echo 'void f(){}' > conftest.c
+ if test -z "`${CC} -g -c conftest.c 2>&1`"; then
+ CFLAGS=${CFLAGS-"-g -O2"}
+ CXXFLAGS=${CXXFLAGS-"-g -O2"}
+ else
+ CFLAGS=${CFLAGS-"-O2"}
+ CXXFLAGS=${CXXFLAGS-"-O2"}
+ fi
+ rm -f conftest*
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ CC=${CC-cc}
+ else
+ if test -z "${CFLAGS}"; then
+ # Here CC is set but CFLAGS is not. Use a quick hack to use -O2 if CC
+ # is set to a version of gcc.
+ case "${CC}" in
+ *gcc)
+ echo 'void f(){}' > conftest.c
+ if test -z "`${CC} -g -c conftest.c 2>&1`"; then
+ CFLAGS=${CFLAGS-"-g -O2"}
+ CXXFLAGS=${CXXFLAGS-"-g -O2"}
+ else
+ CFLAGS=${CFLAGS-"-O2"}
+ CXXFLAGS=${CXXFLAGS-"-O2"}
+ fi
+ rm -f conftest*
+ ;;
+ esac
+ fi
+ fi
+
+ CXX=${CXX-"c++"}
+ CFLAGS=${CFLAGS-"-g"}
+ CXXFLAGS=${CXXFLAGS-"-g -O2"}
+fi
+
+export CC
+export CXX
+export CFLAGS
+export CXXFLAGS
+
+
+for subdir in . ${subdirs} ; do
+
+ # ${subdir} is relative path from . to the directory we're currently
+ # configuring.
+ # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
+ invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
+
+ ### figure out what to do with srcdir
+ case "${srcdir}" in
+ ".") # no -srcdir option. We're building in place.
+ makesrcdir=. ;;
+ /*) # absolute path
+ makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
+ ;;
+ *) # otherwise relative
+ case "${subdir}" in
+ .) makesrcdir=${srcdir} ;;
+ *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
+ esac
+ ;;
+ esac
+
+ if [ "${subdir}/" != "./" ] ; then
+ Makefile=${subdir}/Makefile
+ fi
+
+ if [ ! -d ${subdir} ] ; then
+ if mkdir ${subdir} ; then
+ true
+ else
+ echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
+ exit 1
+ fi
+ fi
+
+ case "${removing}" in
+ "")
+ case "${subdir}" in
+ .) ;;
+ *) eval echo Building in ${subdir} ${redirect} ;;
+ esac
+
+ # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
+ # Set up the list of links to be made.
+ # ${links} is the list of link names, and ${files} is the list of names to link to.
+
+ # Make the links.
+ configlinks="${links}"
+ if [ -r ${subdir}/config.status ] ; then
+ mv -f ${subdir}/config.status ${subdir}/config.back
+ fi
+ while [ -n "${files}" ] ; do
+ # set file to car of files, files to cdr of files
+ set ${files}; file=$1; shift; files=$*
+ set ${links}; link=$1; shift; links=$*
+
+ if [ ! -r ${srcdir}/${file} ] ; then
+ if [ ! -r ${file} ] ; then
+
+ echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
+ echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
+ exit 1
+ else
+ srcfile=${file}
+ fi
+ else
+ srcfile=${srcdir}/${file}
+ fi
+
+ ${remove} -f ${link}
+ # Make a symlink if possible, otherwise try a hard link
+ if ${symbolic_link} ${srcfile} ${link} >/dev/null 2>&1 ; then
+ true
+ else
+ # We need to re-remove the file because Lynx leaves a
+ # very strange directory there when it fails an NFS symlink.
+ ${remove} -r -f ${link}
+ ${hard_link} ${srcfile} ${link}
+ fi
+ if [ ! -r ${link} ] ; then
+ echo '***' "${progname}: unable to link \"${link}\" to \"${srcfile}\"." 1>&2
+ exit 1
+ fi
+
+ echo "Linked \"${link}\" to \"${srcfile}\"."
+ done
+
+ # Create a .gdbinit file which runs the one in srcdir
+ # and tells GDB to look there for source files.
+
+ if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
+ case ${srcdir} in
+ .) ;;
+ *) cat > ${subdir}/.gdbinit <<EOF
+# ${NO_EDIT}
+dir ${makesrcdir}
+dir .
+source ${makesrcdir}/.gdbinit
+EOF
+ ;;
+ esac
+ fi
+
+ # Install a makefile, and make it set VPATH
+ # if necessary so that the sources are found.
+ # Also change its value of srcdir.
+ # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
+ # been somewhat optimized and is perhaps a bit twisty.
+
+ # code is order so as to try to sed the smallest input files we know.
+ # so do these separately because I don't trust the order of sed -e expressions.
+
+ # the five makefile fragments MUST end up in the resulting Makefile in this order:
+ # package macros, target, host, site, and package rules.
+
+ if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
+
+ # Conditionalize the makefile for this package from "Makefile.in" (or whatever it's called) into Makefile.tem.
+ rm -f ${subdir}/${Makefile}.tem
+ case "${package_makefile_rules_frag}" in
+ "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
+ *)
+ if [ ! -f ${package_makefile_rules_frag} ] ; then
+ package_makefile_rules_frag=${srcdir}/${package_makefile_rules_frag}
+ fi
+ if [ -f ${package_makefile_rules_frag} ] ; then
+ sed -e "/^####/ r ${package_makefile_rules_frag}" ${srcdir}/${subdir}/${Makefile_in} > ${Makefile}.tem
+ else
+ echo '***' Expected package makefile rules fragment \"${package_makefile_rules_frag}\" 1>&2
+ echo '***' is missing in ${PWD=`pwd`}. 1>&2
+ cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
+ fi
+ esac
+ # working copy now in ${Makefile}.tem
+
+ # Conditionalize for this site.
+ rm -f ${Makefile}
+ case "${site}" in
+ "") mv ${subdir}/Makefile.tem ${Makefile} ;;
+ *)
+ site_makefile_frag=${srcdir}/config/ms-${site}
+
+ if [ -f ${site_makefile_frag} ] ; then
+ sed -e "/^####/ r ${site_makefile_frag}" ${subdir}/Makefile.tem \
+ > ${Makefile}
+ else
+ mv ${subdir}/Makefile.tem ${Makefile}
+ site_makefile_frag=
+ fi
+ ;;
+ esac
+ # working copy now in ${Makefile}
+
+ # Conditionalize the makefile for this host.
+ rm -f ${subdir}/Makefile.tem
+ case "${host_makefile_frag}" in
+ "") mv ${Makefile} ${subdir}/Makefile.tem ;;
+ *)
+ if [ ! -f ${host_makefile_frag} ] ; then
+ host_makefile_frag=${srcdir}/${host_makefile_frag}
+ fi
+ if [ -f ${host_makefile_frag} ] ; then
+ sed -e "/^####/ r ${host_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
+ else
+ echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
+ echo '***' is missing in ${PWD=`pwd`}. 1>&2
+ mv ${Makefile} ${subdir}/Makefile.tem
+ fi
+ esac
+ # working copy now in ${subdir)/Makefile.tem
+
+ # Conditionalize the makefile for this target.
+ rm -f ${Makefile}
+ case "${target_makefile_frag}" in
+ "") mv ${subdir}/Makefile.tem ${Makefile} ;;
+ *)
+ if [ ! -f ${target_makefile_frag} ] ; then
+ target_makefile_frag=${srcdir}/${target_makefile_frag}
+ fi
+ if [ -f ${target_makefile_frag} ] ; then
+ sed -e "/^####/ r ${target_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
+ else
+ mv ${subdir}/Makefile.tem ${Makefile}
+ target_makefile_frag=
+ fi
+ ;;
+ esac
+ # working copy now in ${Makefile}
+
+ # Emit the default values of this package's macros.
+ rm -f ${subdir}/Makefile.tem
+ case "${package_makefile_frag}" in
+ "") mv ${Makefile} ${subdir}/Makefile.tem ;;
+ *)
+ if [ ! -f ${package_makefile_frag} ] ; then
+ package_makefile_frag=${srcdir}/${package_makefile_frag}
+ fi
+ if [ -f ${package_makefile_frag} ] ; then
+ sed -e "/^####/ r ${package_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
+ else
+ echo '***' Expected package makefile fragment \"${package_makefile_rules_frag}\" 1>&2
+ echo '***' is missing in ${PWD=`pwd`}. 1>&2
+ mv ${Makefile} ${subdir}/Makefile.tem
+ fi
+ esac
+ # real copy now in ${subdir}/Makefile.tem
+
+ # prepend warning about editting, and a bunch of variables.
+ rm -f ${Makefile}
+ cat > ${Makefile} <<EOF
+# ${NO_EDIT}
+VPATH = ${makesrcdir}
+links = ${configlinks}
+host_alias = ${host_alias}
+host_cpu = ${host_cpu}
+host_vendor = ${host_vendor}
+host_os = ${host_os}
+host_canonical = ${host_cpu}-${host_vendor}-${host_os}
+target_alias = ${target_alias}
+target_cpu = ${target_cpu}
+target_vendor = ${target_vendor}
+target_os = ${target_os}
+target_canonical = ${target_cpu}-${target_vendor}-${target_os}
+EOF
+ case "${build}" in
+ "") ;;
+ *) cat >> ${Makefile} << EOF
+build_alias = ${build_alias}
+build_cpu = ${build_cpu}
+build_vendor = ${build_vendor}
+build_os = ${build_os}
+build_canonical = ${build_cpu}-${build_vendor}-${build_os}
+EOF
+ esac
+
+ case "${package_makefile_frag}" in
+ "") ;;
+ /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
+ *) echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
+ esac
+
+ case "${target_makefile_frag}" in
+ "") ;;
+ /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
+ *) echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
+ esac
+
+ case "${host_makefile_frag}" in
+ "") ;;
+ /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
+ *) echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
+ esac
+
+ if [ "${site_makefile_frag}" != "" ] ; then
+ echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
+ fi
+
+ # record if we want to build shared libs.
+ if test -z "${enable_shared}"; then
+ echo enable_shared = no >> ${Makefile}
+ else
+ echo enable_shared = ${enable_shared} >> ${Makefile}
+ fi
+ # record if we want to rumtime library stuff installed in libsubdir.
+ if test -z "${enable_version_specific_runtime_libs}"; then
+ echo enable_version_specific_runtime_libs = no >> ${Makefile}
+ else
+ echo enable_version_specific_runtime_libs = ${enable_version_specific_runtime_libs} >> ${Makefile}
+ fi
+
+ # Emit a macro which describes the file containing gcc's
+ # version number.
+ echo gcc_version_trigger = ${gcc_version_trigger} >> ${Makefile}
+ # And emit a macro defining gcc's version number.
+ echo gcc_version = ${gcc_version} >> ${Makefile}
+
+ # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
+ # remove any form feeds.
+ if [ -z "${subdirs}" ]; then
+ rm -f ${subdir}/Makefile.tm2
+ sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
+ -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
+ ${subdir}/Makefile.tem > ${subdir}/Makefile.tm2
+ rm -f ${subdir}/Makefile.tem
+ mv ${subdir}/Makefile.tm2 ${subdir}/Makefile.tem
+ fi
+ sed -e "s|^prefix[ ]*=.*$|prefix = ${prefix}|" \
+ -e "s|^exec_prefix[ ]*=.*$|exec_prefix = ${exec_prefix}|" \
+ -e "s|^bindir[ ]*=.*$|bindir = ${bindir}|" \
+ -e "s|^sbindir[ ]*=.*$|sbindir = ${sbindir}|" \
+ -e "s|^libexecdir[ ]*=.*$|libexecdir = ${libexecdir}|" \
+ -e "s|^datadir[ ]*=.*$|datadir = ${datadir}|" \
+ -e "s|^sysconfdir[ ]*=.*$|sysconfdir = ${sysconfdir}|" \
+ -e "s|^sharedstatedir[ ]*=.*$|sharedstatedir = ${sharedstatedir}|" \
+ -e "s|^localstatedir[ ]*=.*$|localstatedir = ${localstatedir}|" \
+ -e "s|^libdir[ ]*=.*$|libdir = ${libdir}|" \
+ -e "s|^includedir[ ]*=.*$|includedir = ${includedir}|" \
+ -e "s|^oldincludedir[ ]*=.*$|oldincludedir = ${oldincludedir}|" \
+ -e "s|^infodir[ ]*=.*$|infodir = ${infodir}|" \
+ -e "s|^mandir[ ]*=.*$|mandir = ${mandir}|" \
+ -e "/^CC[ ]*=/{
+ :loop1
+ /\\\\$/ N
+ s/\\\\\\n//g
+ t loop1
+ s%^CC[ ]*=.*$%CC = ${CC}%
+ }" \
+ -e "/^CXX[ ]*=/{
+ :loop2
+ /\\\\$/ N
+ s/\\\\\\n//g
+ t loop2
+ s%^CXX[ ]*=.*$%CXX = ${CXX}%
+ }" \
+ -e "/^CFLAGS[ ]*=/{
+ :loop3
+ /\\\\$/ N
+ s/\\\\\\n//g
+ t loop3
+ s%^CFLAGS[ ]*=.*$%CFLAGS = ${CFLAGS}%
+ }" \
+ -e "/^CXXFLAGS[ ]*=/{
+ :loop4
+ /\\\\$/ N
+ s/\\\\\\n//g
+ t loop4
+ s%^CXXFLAGS[ ]*=.*$%CXXFLAGS = ${CXXFLAGS}%
+ }" \
+ -e "s|^SHELL[ ]*=.*$|SHELL = ${config_shell}|" \
+ -e "s|^srcdir[ ]*=.*$|srcdir = ${makesrcdir}|" \
+ -e "s/ //" \
+ -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
+ -e "s:^program_suffix[ ]*=.*$:program_suffix = ${program_suffix}:" \
+ -e "s:^program_transform_name[ ]*=.*$:program_transform_name = ${program_transform_name}:" \
+ -e "s|^tooldir[ ]*=.*$|tooldir = ${tooldir}|" \
+ -e "s:^DEFAULT_YACC[ ]*=.*$:DEFAULT_YACC = ${DEFAULT_YACC}:" \
+ -e "s:^DEFAULT_LEX[ ]*=.*$:DEFAULT_LEX = ${DEFAULT_LEX}:" \
+ -e "s:^DEFAULT_M4[ ]*=.*$:DEFAULT_M4 = ${DEFAULT_M4}:" \
+ ${subdir}/Makefile.tem >> ${Makefile}
+
+
+ # If this is a Canadian Cross, preset the values of many more
+ # tools.
+ if [ "${build}" != "${host}" ]; then
+ for var in ${tools}; do
+ val=`eval 'echo $'"${var}"`
+ sed -e "/^${var}[ ]*=/{
+ :loop1
+ /\\\\$/ N
+ /\\\\$/ b loop1
+ s/\\\\\\n//g
+ s%^${var}[ ]*=.*$%${var} = ${val}%
+ }" ${Makefile} > ${Makefile}.tem
+ mv -f ${Makefile}.tem ${Makefile}
+ done
+ fi
+
+ # final copy now in ${Makefile}
+
+ else
+ echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
+ fi
+
+ rm -f ${subdir}/Makefile.tem
+
+ case "${host_makefile_frag}" in
+ "") using= ;;
+ *) using="and \"${host_makefile_frag}\"" ;;
+ esac
+
+ case "${target_makefile_frag}" in
+ "") ;;
+ *) using="${using} and \"${target_makefile_frag}\"" ;;
+ esac
+
+ case "${site_makefile_frag}" in
+ "") ;;
+ *) using="${using} and \"${site_makefile_frag}\"" ;;
+ esac
+
+ newusing=`echo "${using}" | sed 's/and/using/'`
+ using=${newusing}
+ echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
+
+ . ${tmpfile}.pos
+
+ # describe the chosen configuration in config.status.
+ # Make that file a shellscript which will reestablish
+ # the same configuration. Used in Makefiles to rebuild
+ # Makefiles.
+
+ case "${norecursion}" in
+ "") arguments="${arguments} --norecursion" ;;
+ *) ;;
+ esac
+
+ if [ ${subdir} = . ] ; then
+ echo "#!/bin/sh
+# ${NO_EDIT}
+# This directory was configured as follows:
+${progname}" ${arguments} "
+# ${using}" > ${subdir}/config.new
+ else
+ echo "#!/bin/sh
+# ${NO_EDIT}
+# This directory was configured as follows:
+cd ${invsubdir}
+${progname}" ${arguments} "
+# ${using}" > ${subdir}/config.new
+ fi
+ chmod a+x ${subdir}/config.new
+ if [ -r ${subdir}/config.back ] ; then
+ mv -f ${subdir}/config.back ${subdir}/config.status
+ fi
+ ${config_shell} ${moveifchange} ${subdir}/config.new ${subdir}/config.status
+ ;;
+
+ *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
+ esac
+done
+
+# If there are subdirectories, then recur.
+if [ -z "${norecursion}" ] && [ -n "${configdirs}" ] ; then
+ for configdir in ${configdirs} ${extraconfigdirs} ; do
+
+ # If configdir contains ',' it is
+ # srcdir,builddir,target_alias
+ # These come from extraconfigdirs.
+ case ${configdir} in
+ *,*)
+ eval `echo ${configdir} | sed -e 's/\([^,]*\),\([^,]*\),\(.*\)/cfg_dir=\1 bld_dir=\2 tgt_alias=\3/'`
+ ;;
+ *)
+ cfg_dir=${configdir}
+ bld_dir=${configdir}
+ tgt_alias=${target_alias}
+ ;;
+ esac
+
+ if [ -d ${srcdir}/${cfg_dir} ] ; then
+ eval echo Configuring ${configdir}... ${redirect}
+ case "${srcdir}" in
+ ".") ;;
+ *)
+ if [ ! -d ./${bld_dir} ] ; then
+ if mkdir ./${bld_dir} ; then
+ true
+ else
+ echo '***' "${progname}: could not make ${PWD=`pwd`}/${bld_dir}" 1>&2
+ exit 1
+ fi
+ fi
+ ;;
+ esac
+
+ POPDIR=${PWD=`pwd`}
+ cd ${bld_dir}
+
+### figure out what to do with srcdir
+ case "${srcdir}" in
+ ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
+ /*) # absolute path
+ newsrcdir=${srcdir}/${cfg_dir}
+ srcdiroption="--srcdir=${newsrcdir}"
+ ;;
+ ?:*) # absolute path on win32
+ newsrcdir=${srcdir}/${cfg_dir}
+ srcdiroption="--srcdir=${newsrcdir}"
+ ;;
+ *) # otherwise relative
+ newsrcdir=../${srcdir}/${cfg_dir}
+ srcdiroption="--srcdir=${newsrcdir}"
+ ;;
+ esac
+
+ # Handle --cache-file=../XXX
+ case "${cache_file}" in
+ "") # empty
+ ;;
+ /*) # absolute path
+ cache_file_option="--cache-file=${cache_file}"
+ ;;
+ ?:*) # absolute path on win32
+ cache_file_option="--cache-file=${cache_file}"
+ ;;
+ *) # relative path
+ cache_file_option="--cache-file=../${cache_file}"
+ ;;
+ esac
+
+### check for guested configure, otherwise fix possibly relative progname
+ if [ -f ${newsrcdir}/configure ] ; then
+ recprog=${newsrcdir}/configure
+ elif [ -f ${newsrcdir}/configure.in ] ; then
+ case "${progname}" in
+ /*) recprog=${progname} ;;
+ ?:*) recprog=${progname} ;;
+ *) recprog=../${progname} ;;
+ esac
+ else
+ eval echo No configuration information in ${cfg_dir} ${redirect}
+ recprog=
+ fi
+
+### The recursion line is here.
+ if [ ! -z "${recprog}" ] ; then
+ if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${tgt_alias} \
+ ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
+ ${srcdiroption} ${diroptions} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${floating_pointoption} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
+ true
+ else
+ echo Configure in `pwd` failed, exiting. 1>&2
+ exit 1
+ fi
+ fi
+
+ cd ${POPDIR}
+ fi
+ done
+fi
+
+# Perform the same cleanup as the trap handler, minus the "exit 1" of course,
+# and reset the trap handler.
+rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
+trap 0
+
+exit 0
+
+#
+# Local Variables:
+# fill-column: 131
+# End:
+#
+
+# end of configure
diff --git a/configure.bat b/configure.bat
new file mode 100644
index 00000000000..d76a37ecd9d
--- /dev/null
+++ b/configure.bat
@@ -0,0 +1,17 @@
+@echo off
+
+chdir libiberty
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\bfd
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\opcodes
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\gprof
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\binutils
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\gas
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\ld
+call configure %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..
diff --git a/configure.in b/configure.in
new file mode 100644
index 00000000000..e4e5c43c69d
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,1184 @@
+#! /bin/bash
+##############################################################################
+
+## This file is a shell script fragment that supplies the information
+## necessary to tailor a template configure script into the configure
+## script appropriate for this directory. For more information, check
+## any existing configure script.
+
+## Be warned, there are two types of configure.in files. There are those
+## used by Autoconf, which are macros which are expanded into a configure
+## script by autoconf. The other sort, of which this is one, is executed
+## by Cygnus configure.
+
+## For more information on these two systems, check out the documentation
+## for 'Autoconf' (autoconf.texi) and 'Configure' (configure.texi).
+
+# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+##############################################################################
+
+### To add a new directory to the tree, first choose whether it is a target
+### or a host dependent tool. Then put it into the appropriate list
+### (library or tools, host or target), doing a dependency sort. For
+### example, gdb requires that byacc (or bison) be built first, so it is in
+### the ${host_tools} list after byacc and bison.
+
+
+# these libraries are used by various programs built for the host environment
+#
+host_libs="intl mmalloc libiberty opcodes bfd readline gash db tcl tk tcl8.1 tk8.1 tclX itcl tix libgui"
+
+if [ "${enable_gdbgui}" = "yes" ] ; then
+ host_libs="${host_libs} libgui"
+fi
+
+# these tools are built for the host environment
+# Note, the powerpc-eabi build depends on sim occurring before gdb in order to
+# know that we are building the simulator.
+host_tools="texinfo byacc flex bison binutils ld gas gcc sim gdb make patch prms send-pr gprof gdbtest tgas etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool ispell grep diff rcs cvssrc fileutils shellutils time textutils wdiff find emacs emacs19 uudecode hello tar gzip indent recode release sed utils guile perl apache inet gawk findutils snavigator libtool gettext zip"
+
+# these libraries are built for the target environment, and are built after
+# the host libraries and the host tools (which may be a cross compiler)
+#
+target_libs="target-libiberty \
+ target-libgloss \
+ target-newlib \
+ target-libio \
+ target-librx \
+ target-libstdc++ \
+ target-libg++"
+
+# these tools are built using the target libs, and are intended to run only
+# in the target environment
+#
+# note: any program that *uses* libraries that are in the "target_libs"
+# list belongs in this list. those programs are also very likely
+# candidates for the "native_only" list which follows
+#
+target_tools="target-examples target-groff target-gperf"
+
+################################################################################
+
+## These two lists are of directories that are to be removed from the
+## ${configdirs} list for either cross-compilations or for native-
+## compilations. For example, it doesn't make that much sense to
+## cross-compile Emacs, nor is it terribly useful to compile target-libiberty in
+## a native environment.
+
+# directories to be built in the native environment only
+#
+# This must be a single line because of the way it is searched by grep in
+# the code below.
+native_only="autoconf automake libtool cvssrc emacs emacs19 fileutils find gawk gettext grep gzip hello indent ispell m4 rcs recode sed shellutils tar textutils gash uudecode wdiff gprof target-groff guile perl apache inet time ash bash bzip2 prms snavigator gnuserv target-gperf"
+
+# directories to be built in a cross environment only
+#
+cross_only="target-libgloss target-newlib target-cygmon target-opcodes target-libstub"
+
+## All tools belong in one of the four categories, and are assigned above
+## We assign ${configdirs} this way to remove all embedded newlines. This
+## is important because configure will choke if they ever get through.
+## ${configdirs} is directories we build using the host tools.
+## ${target_configdirs} is directories we build using the target tools.
+#
+configdirs=`echo ${host_libs} ${host_tools}`
+target_configdirs=`echo ${target_libs} ${target_tools}`
+
+################################################################################
+
+srctrigger=move-if-change
+srcname="gnu development package"
+
+# This gets set non-empty for some net releases of packages.
+appdirs=""
+
+# per-host:
+
+# Work in distributions that contain no compiler tools, like Autoconf.
+if [ -d ${srcdir}/config ]; then
+case "${host}" in
+ m68k-hp-hpux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-hp300"
+ ;;
+ m68k-apollo-sysv*)
+ host_makefile_frag="${host_makefile_frag} config/mh-apollo68"
+ ;;
+ m68k-apollo-bsd*)
+ host_makefile_frag="${host_makefile_frag} config/mh-a68bsd"
+ ;;
+ m88k-dg-dgux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-dgux"
+ ;;
+ m88k-harris-cxux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-cxux"
+ ;;
+ m88k-motorola-sysv*)
+ host_makefile_frag="${host_makefile_frag} config/mh-delta88"
+ ;;
+ mips*-dec-ultrix*)
+ host_makefile_frag="${host_makefile_frag} config/mh-decstation"
+ ;;
+ mips*-nec-sysv4*)
+ host_makefile_frag="${host_makefile_frag} config/mh-necv4"
+ ;;
+ mips*-sgi-irix6*)
+ host_makefile_frag="${host_makefile_frag} config/mh-irix6"
+ ;;
+ mips*-sgi-irix5*)
+ host_makefile_frag="${host_makefile_frag} config/mh-irix5"
+ ;;
+ mips*-sgi-irix4*)
+ host_makefile_frag="${host_makefile_frag} config/mh-irix4"
+ ;;
+ mips*-sgi-irix3*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv"
+ ;;
+ mips*-*-sysv4*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv4"
+ ;;
+ mips*-*-sysv*)
+ host_makefile_frag="${host_makefile_frag} config/mh-riscos"
+ ;;
+ i[3456]86-*-sysv5*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv5"
+ ;;
+ i[3456]86-*-dgux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-dgux386"
+ ;;
+ i[3456]86-ncr-sysv4.3*)
+ host_makefile_frag="${host_makefile_frag} config/mh-ncrsvr43"
+ ;;
+ i[3456]86-ncr-sysv4*)
+ host_makefile_frag="${host_makefile_frag} config/mh-ncr3000"
+ ;;
+ i[3456]86-*-sco3.2v5*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv"
+ ;;
+ i[3456]86-*-sco*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sco"
+ ;;
+ i[3456]86-*-udk*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv5"
+ ;;
+ i[3456]86-*-isc*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv"
+ ;;
+ i[3456]86-*-solaris2*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv4"
+ ;;
+ i[3456]86-*-aix*)
+ host_makefile_frag="${host_makefile_frag} config/mh-aix386"
+ ;;
+ i[3456]86-*-msdosdjgpp*)
+ host_makefile_frag="${host_makefile_frag} config/mh-djgpp"
+ ;;
+ *-cygwin*)
+ host_makefile_frag="${host_makefile_frag} config/mh-cygwin"
+ ;;
+ *-mingw32*)
+ host_makefile_frag="${host_makefile_frag} config/mh-mingw32"
+ ;;
+ *-interix*)
+ host_makefile_frag="${host_makefile_frag} config/mh-interix"
+ ;;
+ *-windows*)
+ host_makefile_frag="${host_makefile_frag} config/mh-windows"
+ ;;
+ vax-*-ultrix2*)
+ host_makefile_frag="${host_makefile_frag} config/mh-vaxult2"
+ ;;
+ *-*-solaris2*)
+ host_makefile_frag="${host_makefile_frag} config/mh-solaris"
+ ;;
+ m68k-sun-sunos*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sun3"
+ ;;
+ *-hp-hpux[78]*)
+ host_makefile_frag="${host_makefile_frag} config/mh-hpux8"
+ ;;
+ *-hp-hpux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-hpux"
+ ;;
+ *-*-hiux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-hpux"
+ ;;
+ rs6000-*-lynxos*)
+ host_makefile_frag="${host_makefile_frag} config/mh-lynxrs6k"
+ ;;
+ *-*-lynxos*)
+ host_makefile_frag="${host_makefile_frag} config/mh-lynxos"
+ ;;
+ *-*-aix4.[3456789]* | *-*-aix[56789].*)
+ host_makefile_frag="${host_makefile_frag} config/mh-aix43"
+ ;;
+ *-*-sysv4*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv4"
+ ;;
+ *-*-sysv*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sysv"
+ ;;
+esac
+fi
+
+# If we aren't going to be using gcc, see if we can extract a definition
+# of CC from the fragment.
+if [ -z "${CC}" ] && [ "${build}" = "${host}" ]; then
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
+ found=
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/gcc; then
+ found=yes
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if [ -z "${found}" ] && [ -n "${host_makefile_frag}" ] && [ -f "${srcdir}/${host_makefile_frag}" ]; then
+ xx=`sed -n -e 's/^[ ]*CC[ ]*=[ ]*\(.*\)$/\1/p' < ${srcdir}/${host_makefile_frag}`
+ if [ -n "${xx}" ] ; then
+ CC=$xx
+ fi
+ fi
+fi
+
+# We default to --with-shared on platforms where -fpic is meaningless.
+# Well, we don't yet, but we will.
+if false && [ "${host}" = "${target}" ] && [ x${enable_shared} = x ]; then
+ case "${target}" in
+ alpha*-dec-osf*) enable_shared=yes ;;
+ alpha*-*-linux*) enable_shared=yes ;;
+ mips-sgi-irix5*) enable_shared=yes ;;
+ *) enable_shared=no ;;
+ esac
+fi
+
+case "${enable_shared}" in
+ yes) shared=yes ;;
+ no) shared=no ;;
+ "") shared=no ;;
+ *) shared=yes ;;
+esac
+
+if [ x${shared} = xyes ]; then
+ case "${host}" in
+ alpha*-*-linux*)
+ host_makefile_frag="${host_makefile_frag} config/mh-elfalphapic"
+ ;;
+ arm*-*-*)
+ host_makefile_frag="${host_makefile_frag} config/mh-armpic"
+ ;;
+ hppa*-*-*)
+ host_makefile_frag="${host_makefile_frag} config/mh-papic"
+ ;;
+ i[3456]86-*-cygwin*)
+ # We don't want -fPIC on Cygwin.
+ ;;
+ i[3456]86-*-*)
+ host_makefile_frag="${host_makefile_frag} config/mh-x86pic"
+ ;;
+ sparc64-*-*)
+ host_makefile_frag="${host_makefile_frag} config/mh-sparcpic"
+ ;;
+ powerpc*-*-aix*)
+ # We don't want -fPIC on AIX.
+ ;;
+ powerpc*-*-*)
+ host_makefile_frag="${host_makefile_frag} config/mh-ppcpic"
+ ;;
+ *-*-*)
+ if test -f ${srcdir}/config/mh-${host_cpu}pic; then
+ host_makefile_frag="${host_makefile_frag} config/mh-${host_cpu}pic"
+ fi
+ ;;
+ esac
+fi
+
+rm -f mh-frag
+if [ -n "${host_makefile_frag}" ] ; then
+ for f in ${host_makefile_frag}
+ do
+ cat ${srcdir}/$f >> mh-frag
+ done
+ host_makefile_frag=mh-frag
+fi
+
+# per-target:
+
+case "${target}" in
+ v810*)
+ target_makefile_frag="${target_makefile_frag} config/mt-v810"
+ ;;
+ i[3456]86-*-netware*)
+ target_makefile_frag="${target_makefile_frag} config/mt-netware"
+ ;;
+ powerpc-*-netware*)
+ target_makefile_frag="${target_makefile_frag} config/mt-netware"
+ ;;
+ *-*-linux-gnu)
+ target_makefile_frag="${target_makefile_frag} config/mt-linux"
+ ;;
+esac
+
+# If --enable-target-optspace always use -Os instead of -O2 to build
+# the target libraries, similarly if it is not specified, use -Os
+# on selected platforms.
+case "${enable_target_optspace}:${target}" in
+ yes:*)
+ target_makefile_frag="${target_makefile_frag} config/mt-ospace"
+ ;;
+ # CYGNUS LOCAL d10v, d30v, fr30
+ :d30v-*)
+ target_makefile_frag="${target_makefile_frag} config/mt-d30v"
+ ;;
+ :m32r-* | :d10v-* | :fr30-*)
+ target_makefile_frag="${target_makefile_frag} config/mt-ospace"
+ ;;
+ no:* | :*)
+ ;;
+ *)
+ echo "*** bad value \"${enable_target_optspace}\" for --enable-target-optspace flag; ignored" 1>&2
+ ;;
+esac
+
+skipdirs=
+gasdir=gas
+use_gnu_ld=
+use_gnu_as=
+
+# some tools are so dependent upon X11 that if we're not building with X,
+# it's not even worth trying to configure, much less build, that tool.
+
+case ${with_x} in
+ yes | "") # the default value for this tree is that X11 is available
+ ;;
+ no)
+ skipdirs="${skipdirs} tk libgui gash"
+ ;;
+ *)
+ echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2
+ ;;
+esac
+
+# Some tools are only suitable for building in a "native" situation.
+# Those are added when we have a host==target configuration. For cross
+# toolchains, we add some directories that should only be useful in a
+# cross-compiler.
+
+is_cross_compiler=
+
+if [ x"${host}" = x"${target}" ] ; then
+ # when doing a native toolchain, don't build the targets
+ # that are in the 'cross only' list
+ skipdirs="${skipdirs} ${cross_only}"
+ is_cross_compiler=no
+else
+ # similarly, don't build the targets in the 'native only'
+ # list when building a cross compiler
+ skipdirs="${skipdirs} ${native_only}"
+ is_cross_compiler=yes
+fi
+
+# We always want to use the same name for this directory, so that dejagnu
+# can reliably find it.
+target_subdir=${target_alias}
+
+if [ ! -d ${target_subdir} ] ; then
+ if mkdir ${target_subdir} ; then true
+ else
+ echo "'*** could not make ${PWD=`pwd`}/${target_subdir}" 1>&2
+ exit 1
+ fi
+fi
+
+copy_dirs=
+
+# Handle --with-headers=XXX. The contents of the named directory are
+# copied to $(tooldir)/sys-include.
+if [ x"${with_headers}" != x ]; then
+ if [ x${is_cross_compiler} = xno ]; then
+ echo 1>&2 '***' --with-headers is only supported when cross compiling
+ exit 1
+ fi
+ case "${exec_prefixoption}" in
+ "") x=${prefix} ;;
+ *) x=${exec_prefix} ;;
+ esac
+ copy_dirs="${copy_dirs} ${with_headers} $x/${target_alias}/sys-include"
+fi
+
+# Handle --with-libs=XXX. Multiple directories are permitted. The
+# contents are copied to $(tooldir)/lib.
+if [ x"${with_libs}" != x ]; then
+ if [ x${is_cross_compiler} = xno ]; then
+ echo 1>&2 '***' --with-libs is only supported when cross compiling
+ exit 1
+ fi
+ # Copy the libraries in reverse order, so that files in the first named
+ # library override files in subsequent libraries.
+ case "${exec_prefixoption}" in
+ "") x=${prefix} ;;
+ *) x=${exec_prefix} ;;
+ esac
+ for l in ${with_libs}; do
+ copy_dirs="$l $x/${target_alias}/lib ${copy_dirs}"
+ done
+fi
+
+# If both --with-headers and --with-libs are specified, default to
+# --without-newlib.
+if [ x"${with_headers}" != x ] && [ x"${with_libs}" != x ]; then
+ if [ x"${with_newlib}" = x ]; then
+ with_newlib=no
+ fi
+fi
+
+# Recognize --with-newlib/--without-newlib.
+if [ x${with_newlib} = xno ]; then
+ skipdirs="${skipdirs} target-newlib"
+elif [ x${with_newlib} = xyes ]; then
+ skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
+fi
+
+# Default to using --with-stabs for certain targets.
+if [ x${with_stabs} = x ]; then
+ case "${target}" in
+ mips*-*-irix6*)
+ ;;
+ mips*-*-* | alpha*-*-osf*)
+ with_stabs=yes;
+ withoptions="${withoptions} --with-stabs"
+ ;;
+ esac
+fi
+
+# Handle ${copy_dirs}
+set fnord ${copy_dirs}
+shift
+while [ $# != 0 ]; do
+ if [ -f $2/COPIED ] && [ x"`cat $2/COPIED`" = x"$1" ]; then
+ :
+ else
+ echo Copying $1 to $2
+
+ # Use the install script to create the directory and all required
+ # parent directories.
+ if [ -d $2 ]; then
+ :
+ else
+ echo >config.temp
+ ${srcdir}/install-sh -c -m 644 config.temp $2/COPIED
+ fi
+
+ # Copy the directory, assuming we have tar.
+ # FIXME: Should we use B in the second tar? Not all systems support it.
+ (cd $1; tar -cf - .) | (cd $2; tar -xpf -)
+
+ # It is the responsibility of the user to correctly adjust all
+ # symlinks. If somebody can figure out how to handle them correctly
+ # here, feel free to add the code.
+
+ echo $1 > $2/COPIED
+ fi
+ shift; shift
+done
+
+# Configure extra directories which are host specific
+
+case "${host}" in
+ i[3456]86-*-go32*)
+ configdirs="$configdirs dosrel" ;;
+ i[3456]86-*-mingw32*)
+ configdirs="$configdirs dosrel" ;;
+ *-cygwin*)
+ configdirs="$configdirs libtermcap dosrel" ;;
+esac
+
+# Remove more programs from consideration, based on the host or
+# target this usually means that a port of the program doesn't
+# exist yet.
+
+noconfigdirs=""
+
+case "${host}" in
+ i[3456]86-*-vsta)
+ noconfigdirs="tcl expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff guile perl apache inet itcl tix db snavigator gnuserv gettext"
+ ;;
+ i[3456]86-*-go32* | i[3456]86-*-msdosdjgpp*)
+ noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr uudecode dejagnu diff guile perl apache inet itcl tix db snavigator gnuserv gettext"
+ ;;
+ i[3456]86-*-mingw32*)
+ # noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr uudecode dejagnu diff guile perl apache inet itcl tix db snavigator gnuserv"
+ noconfigdirs="expect dejagnu cvs autoconf automake send-pr gprof rcs guile perl texinfo apache inet libtool"
+ ;;
+ i[3456]86-*-beos*)
+ noconfigdirs="$noconfigdirs tk itcl tix libgui gdb"
+ ;;
+ *-*-cygwin*)
+ noconfigdirs="autoconf automake send-pr gprof rcs guile perl texinfo apache inet"
+ ;;
+ *-*-netbsd*)
+ noconfigdirs="rcs"
+ ;;
+ ppc*-*-pe)
+ noconfigdirs="patch diff make tk tcl expect dejagnu cvssrc autoconf automake texinfo bison send-pr gprof rcs guile perl apache inet itcl tix db snavigator gnuserv"
+ ;;
+esac
+
+
+case "${target}" in
+ *-*-netware)
+ noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-librx target-newlib target-libiberty target-libgloss"
+ ;;
+ *-*-rtems*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ *-*-vxworks*)
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
+ alpha*-dec-osf*)
+ # ld works, but does not support shared libraries. emacs doesn't
+ # work. newlib is not 64 bit ready. I'm not sure about fileutils.
+ # gas doesn't generate exception information.
+ noconfigdirs="$noconfigdirs gas ld emacs fileutils target-newlib target-libgloss"
+ ;;
+ alpha*-*-*vms*)
+ noconfigdirs="$noconfigdirs gdb ld target-newlib target-libgloss"
+ ;;
+ alpha*-*-linux*)
+ # newlib is not 64 bit ready
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ # linux has rx in libc
+ skipdirs="$skipdirs target-librx"
+ ;;
+ alpha*-*-*)
+ # newlib is not 64 bit ready
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
+ arc-*-*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ arm-*-pe*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ arm-*-coff*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-cygmon"
+ fi
+ ;;
+ arm-*-elf*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-cygmon"
+ fi
+ ;;
+ arm-*-oabi*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ c4x-*-*)
+ noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss"
+ ;;
+ thumb-*-coff)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+# CYGNUS LOCAL clm/arm-elf
+ thumb-*-elf)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ thumb-*-oabi)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+# END CYGNUS LOCAL
+# CYGNUS LOCAL nickc/strongarm
+ strongarm-*-elf)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-cygmon"
+ fi
+ ;;
+ strongarm-*-coff)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-cygmon"
+ fi
+ ;;
+# END CYGNUS LOCAL
+ thumb-*-pe) # CYGNUS LOCAL nickc/thumb
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ arm-*-riscix*)
+ noconfigdirs="$noconfigdirs ld target-libgloss"
+ ;;
+ d10v-*-*)
+ noconfigdirs="$noconfigdirs target-librx target-libg++ target-libstdc++ target-libio"
+ ;;
+# CYGNUS LOCAL d30v
+ d30v-*-*)
+ ;;
+# END CYGNUS LOCAL
+# CYGNUS LOCAL fr30
+ fr30-*-elf*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
+ fi
+ ;;
+# END CYGNUS LOCAL
+ h8300*-*-* | \
+ h8500-*-*)
+ noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss"
+ ;;
+ hppa*-*-*elf* | \
+ hppa*-*-lites*)
+ # Do configure ld/binutils/gas for this case.
+ ;;
+ hppa*-*-*)
+ # HP's C compiler doesn't handle Emacs correctly (but on BSD and Mach
+ # cc is gcc, and on any system a user should be able to link cc to
+ # whatever they want. FIXME, emacs emacs19).
+ case "${CC}" in
+ "" | cc*) noconfigdirs="$noconfigdirs emacs emacs19" ;;
+ *) ;;
+ esac
+ noconfigdirs="$noconfigdirs ld shellutils"
+ ;;
+ i[3456]86-*-coff | i[3456]86-*-elf)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-libstub target-cygmon"
+ fi
+ ;;
+ i[3456]86-*-go32* | i[3456]-*-msdosdjgpp*)
+ # but don't build gdb
+ noconfigdirs="$noconfigdirs gdb target-libg++ target-libstdc++ target-libio target-librx"
+ ;;
+ *-*-linux*)
+ # linux has rx in libc
+ skipdirs="$skipdirs target-librx"
+ ;;
+ i[3456]86-*-mingw32*)
+ target_configdirs="$target_configdirs target-mingw"
+ noconfigdirs="$noconfigdirs expect target-libgloss"
+
+ # Can't build gdb for mingw32 if not native.
+ case "${host}" in
+ i[3456]86-*-mingw32) ;; # keep gdb tcl tk expect etc.
+ *) noconfigdirs="$noconfigdirs gdb tcl tk expect itcl tix db snavigator gnuserv"
+ ;;
+ esac
+ ;;
+ *-*-cygwin*)
+ target_configdirs="$target_configdirs target-libtermcap target-winsup"
+ noconfigdirs="$noconfigdirs target-libgloss"
+ # always build newlib.
+ skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
+
+ # Can't build gdb for Cygwin if not native.
+ case "${host}" in
+ *-*-cygwin*) ;; # keep gdb tcl tk expect etc.
+ *) noconfigdirs="$noconfigdirs gdb tcl tk expect itcl tix libgui db snavigator gnuserv"
+ ;;
+ esac
+ ;;
+ i[3456]86-*-pe)
+ noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss"
+ ;;
+ i[3456]86-*-sco3.2v5*)
+ # The linker does not yet know about weak symbols in COFF,
+ # and is not configured to handle mixed ELF and COFF.
+ noconfigdirs="$noconfigdirs ld target-libgloss"
+ ;;
+ i[3456]86-*-sco*)
+ noconfigdirs="$noconfigdirs gprof target-libgloss"
+ ;;
+ i[3456]86-*-solaris2*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ i[3456]86-*-sysv4*)
+ # The SYSV4 C compiler doesn't handle Emacs correctly
+ case "${CC}" in
+ "" | cc*) noconfigdirs="$noconfigdirs emacs emacs19" ;;
+ *) ;;
+ esac
+ # but that's okay since emacs doesn't work anyway
+ noconfigdirs="$noconfigdirs emacs emacs19 target-libgloss"
+ ;;
+ i[3456]86-*-beos*)
+ noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
+ ;;
+ m68k-*-elf*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-cygmon"
+ fi
+ ;;
+ m68k-*-coff*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-cygmon"
+ fi
+ ;;
+ mn10200-*-*)
+ noconfigdirs="$noconfigdirs"
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-libstub target-cygmon"
+ fi
+ ;;
+ mn10300-*-*)
+ noconfigdirs="$noconfigdirs"
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
+ fi
+ ;;
+ powerpc-*-aix*)
+ # copied from rs6000-*-* entry
+ noconfigdirs="$noconfigdirs gprof cvssrc target-libgloss"
+ # This is needed until gcc and ld are fixed to work together.
+ use_gnu_ld=no
+ ;;
+ powerpc*-*-winnt* | powerpc*-*-pe* | ppc*-*-pe)
+ target_configdirs="$target_configdirs target-winsup"
+ noconfigdirs="$noconfigdirs gdb tcl tk make expect target-libgloss itcl tix db snavigator gnuserv"
+ # always build newlib.
+ skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
+ ;;
+ # This is temporary until we can link against shared libraries
+ powerpcle-*-solaris*)
+ noconfigdirs="$noconfigdirs gdb sim make tcl tk expect itcl tix db snavigator gnuserv"
+ ;;
+ powerpc-*-eabi)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
+ fi
+ ;;
+ rs6000-*-lynxos*)
+ # The CVS server code doesn't work on the RS/6000
+ # Newlib makes problems for libg++ in crosses.
+ noconfigdirs="$noconfigdirs target-newlib gprof cvssrc"
+ ;;
+ rs6000-*-aix*)
+ noconfigdirs="$noconfigdirs gprof"
+ # This is needed until gcc and ld are fixed to work together.
+ use_gnu_ld=no
+ ;;
+ rs6000-*-*)
+ noconfigdirs="$noconfigdirs gprof"
+ ;;
+ m68k-apollo-*)
+ noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss"
+ ;;
+ mips*-*-irix5*)
+ # The GNU linker does not support shared libraries.
+ # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work)
+ noconfigdirs="$noconfigdirs ld gprof emacs target-libgloss"
+ ;;
+ mips*-*-irix6*)
+ # The GNU assembler and linker do not support IRIX 6.
+ # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work)
+ noconfigdirs="$noconfigdirs ld gas gprof emacs target-libgloss"
+ ;;
+ mips*-dec-bsd*)
+ noconfigdirs="$noconfigdirs gprof target-libgloss"
+ ;;
+ mips*-*-bsd*)
+ noconfigdirs="$noconfigdirs gprof target-libgloss"
+ ;;
+ mipstx39-*-*)
+ noconfigdirs="$noconfigdirs gprof" # same as generic mips
+ target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
+ ;;
+ mips*-*-*)
+ noconfigdirs="$noconfigdirs gprof"
+ ;;
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss"
+ ;;
+ sh-*-*)
+ case "${host}" in
+ i[3456]86-*-vsta) ;; # don't add gprof back in
+ i[3456]86-*-go32*) ;; # don't add gprof back in
+ i[3456]86-*-msdosdjgpp*) ;; # don't add gprof back in
+ *) skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'` ;;
+ esac
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ sparc-*-elf*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-libstub target-cygmon"
+ fi
+ ;;
+ sparc64-*-elf*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-libstub target-cygmon"
+ fi
+ ;;
+ sparclite-*-*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
+ fi
+ ;;
+ sparc-*-sunos4*)
+ if [ x${is_cross_compiler} != xno ] ; then
+ noconfigdirs="$noconfigdirs gdb gdbtest target-newlib target-libgloss"
+ else
+ use_gnu_ld=no
+ fi
+ ;;
+ v810-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils gas gcc gdb ld target-libio target-libg++ target-libstdc++ opcodes target-libgloss"
+ ;;
+ v850-*-*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ v850e-*-*) # CYGNUS LOCAL v850e
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;;
+ v850ea-*-*)
+ noconfigdirs="$noconfigdirs target-libgloss"
+ ;; # END CYGNUS LOCAL
+ vax-*-vms)
+ noconfigdirs="$noconfigdirs bfd binutils gdb ld target-newlib opcodes target-libgloss"
+ ;;
+ vax-*-*)
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
+ *-*-lynxos*)
+ # Newlib makes problems for libg++ in crosses.
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
+ *-*-macos* | \
+ *-*-mpw*)
+ # Macs want a resource compiler.
+ configdirs="$configdirs grez"
+ ;;
+esac
+
+# If we aren't building newlib, then don't build libgloss, since libgloss
+# depends upon some newlib header files.
+case "${noconfigdirs}" in
+ *target-libgloss*) ;;
+ *target-newlib*) noconfigdirs="$noconfigdirs target-libgloss" ;;
+esac
+
+# Make sure we don't let GNU ld be added if we didn't want it.
+if [ x$with_gnu_ld = xno ]; then
+ use_gnu_ld=no
+ noconfigdirs="$noconfigdirs ld"
+fi
+
+# Make sure we don't let GNU as be added if we didn't want it.
+if [ x$with_gnu_as = xno ]; then
+ use_gnu_as=no
+ noconfigdirs="$noconfigdirs gas"
+fi
+
+# Remove the entries in $skipdirs and $noconfigdirs from $configdirs and
+# $target_configdirs.
+# If we have the source for $noconfigdirs entries, add them to $notsupp.
+
+notsupp=""
+for dir in . $skipdirs $noconfigdirs ; do
+ dirname=`echo $dir | sed -e s/target-//g`
+ if [ $dir != . ] && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+ configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"`
+ if [ -r $srcdir/$dirname/configure ] \
+ || [ -r $srcdir/$dirname/configure.in ]; then
+ if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+ true
+ else
+ notsupp="$notsupp $dir"
+ fi
+ fi
+ fi
+ if [ $dir != . ] && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+ target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"`
+ if [ -r $srcdir/$dirname/configure ] \
+ || [ -r $srcdir/$dirname/configure.in ]; then
+ if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+ true
+ else
+ notsupp="$notsupp $dir"
+ fi
+ fi
+ fi
+done
+
+# Sometimes the tools are distributed with libiberty but with no other
+# libraries. In that case, we don't want to build target-libiberty.
+if [ -n "${target_configdirs}" ]; then
+ others=
+ for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
+ if [ "$i" != "libiberty" ]; then
+ if [ -r $srcdir/$i/configure ] || [ -r $srcdir/$i/configure.in ]; then
+ others=yes;
+ break;
+ fi
+ fi
+ done
+ if [ -z "${others}" ]; then
+ target_configdirs=
+ fi
+fi
+
+# Deconfigure all subdirectories, in case we are changing the
+# configuration from one where a subdirectory is supported to one where it
+# is not.
+if [ -z "${norecursion}" ] && [ -n "${configdirs}" ]; then
+ for i in `echo ${configdirs} | sed -e s/target-//g` ; do
+ rm -f $i/Makefile
+ done
+fi
+if [ -z "${norecursion}" ] && [ -n "${target_configdirs}" ]; then
+ for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
+ rm -f ${target_subdir}/$i/Makefile
+ done
+fi
+
+# Produce a warning message for the subdirs we can't configure.
+# This isn't especially interesting in the Cygnus tree, but in the individual
+# FSF releases, it's important to let people know when their machine isn't
+# supported by the one or two programs in a package.
+
+if [ -n "${notsupp}" ] && [ -z "${norecursion}" ]; then
+ # If $appdirs is non-empty, at least one of those directories must still
+ # be configured, or we error out. (E.g., if the gas release supports a
+ # specified target in some subdirs but not the gas subdir, we shouldn't
+ # pretend that all is well.)
+ if [ -n "$appdirs" ]; then
+ for dir in $appdirs ; do
+ if [ -r $dir/Makefile.in ]; then
+ if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+ appdirs=""
+ break
+ fi
+ if echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+ appdirs=""
+ break
+ fi
+ fi
+ done
+ if [ -n "$appdirs" ]; then
+ echo "*** This configuration is not supported by this package." 1>&2
+ exit 1
+ fi
+ fi
+ # Okay, some application will build, or we don't care to check. Still
+ # notify of subdirs not getting built.
+ echo "*** This configuration is not supported in the following subdirectories:" 1>&2
+ echo " ${notsupp}" 1>&2
+ echo " (Any other directories should still work fine.)" 1>&2
+fi
+
+# Set with_gnu_as and with_gnu_ld as appropriate.
+#
+# This is done by determining whether or not the appropriate directory
+# is available, and by checking whether or not specific configurations
+# have requested that this magic not happen.
+#
+# The command line options always override the explicit settings in
+# configure.in, and the settings in configure.in override this magic.
+#
+# If the default for a toolchain is to use GNU as and ld, and you don't
+# want to do that, then you should use the --without-gnu-as and
+# --without-gnu-ld options for the configure script.
+
+if [ x${use_gnu_as} = x ] ; then
+ if [ x${with_gnu_as} != xno ] && echo " ${configdirs} " | grep " ${gasdir} " > /dev/null 2>&1 && [ -d ${srcdir}/${gasdir} ] ; then
+ with_gnu_as=yes
+ withoptions="$withoptions --with-gnu-as"
+ fi
+fi
+
+if [ x${use_gnu_ld} = x ] ; then
+ if [ x${with_gnu_ld} != xno ] && echo " ${configdirs} " | grep " ld " > /dev/null 2>&1 && [ -d ${srcdir}/ld ] ; then
+ with_gnu_ld=yes
+ withoptions="$withoptions --with-gnu-ld"
+ fi
+fi
+
+# If using newlib, add --with-newlib to the withoptions so that gcc/configure
+# can detect this case.
+
+if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 && [ -d ${srcdir}/newlib ] ; then
+ with_newlib=yes
+ withoptions="$withoptions --with-newlib"
+fi
+
+if [ x${shared} = xyes ]; then
+ case "${target}" in
+ hppa*)
+ target_makefile_frag="${target_makefile_frag} config/mt-papic"
+ ;;
+ i[3456]86-*)
+ target_makefile_frag="${target_makefile_frag} config/mt-x86pic"
+ ;;
+ powerpc*-*)
+ target_makefile_frag="${target_makefile_frag} config/mt-ppcpic"
+ ;;
+ alpha*-*-linux*)
+ target_makefile_frag="${target_makefile_frag} config/mt-elfalphapic"
+ ;;
+ *)
+ if test -f ${srcdir}/config/mt-${target_cpu}pic; then
+ target_makefile_frag="${target_makefile_frag} config/mt-${target_cpu}pic"
+ fi
+ ;;
+ esac
+fi
+
+rm -f mt-frag
+if [ -n "${target_makefile_frag}" ] ; then
+ for f in ${target_makefile_frag}
+ do
+ cat ${srcdir}/$f >> mt-frag
+ done
+ target_makefile_frag=mt-frag
+fi
+
+# post-target:
+
+# Make sure that the compiler is able to generate an executable. If it
+# can't, we are probably in trouble. We don't care whether we can run the
+# executable--we might be using a cross compiler--we only care whether it
+# can be created. At this point the main configure script has set CC.
+echo "int main () { return 0; }" > conftest.c
+${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
+if [ $? = 0 ] && [ -s conftest -o -s conftest.exe ]; then
+ :
+else
+ echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
+ echo 1>&2 "*** You must set the environment variable CC to a working compiler."
+ rm -f conftest*
+ exit 1
+fi
+rm -f conftest*
+
+# The Solaris /usr/ucb/cc compiler does not appear to work.
+case "${host}" in
+ sparc-sun-solaris2*)
+ CCBASE="`echo ${CC-cc} | sed 's/ .*$//'`"
+ if [ "`/usr/bin/which $CCBASE`" = "/usr/ucb/cc" ] ; then
+ could_use=
+ [ -d /opt/SUNWspro/bin ] && could_use="/opt/SUNWspro/bin"
+ if [ -d /opt/cygnus/bin ] ; then
+ if [ "$could_use" = "" ] ; then
+ could_use="/opt/cygnus/bin"
+ else
+ could_use="$could_use or /opt/cygnus/bin"
+ fi
+ fi
+ if [ "$could_use" = "" ] ; then
+ echo "Warning: compilation may fail because you're using"
+ echo "/usr/ucb/cc. You should change your PATH or CC "
+ echo "variable and rerun configure."
+ else
+ echo "Warning: compilation may fail because you're using"
+ echo "/usr/ucb/cc, when you should use the C compiler from"
+ echo "$could_use. You should change your"
+ echo "PATH or CC variable and rerun configure."
+ fi
+ fi
+ ;;
+esac
+
+# If --enable-shared was set, we must set LD_LIBRARY_PATH so that the
+# binutils tools will find libbfd.so.
+if [ "${shared}" = "yes" ]; then
+ sed -e 's/^SET_LIB_PATH[ ]*=.*$/SET_LIB_PATH = $(REALLY_SET_LIB_PATH)/' \
+ Makefile > Makefile.tem
+ rm -f Makefile
+ mv -f Makefile.tem Makefile
+
+ case "${host}" in
+ *-*-hpux*)
+ sed -e 's/^RPATH_ENVVAR[ ]*=.*$/RPATH_ENVVAR = SHLIB_PATH/' \
+ Makefile > Makefile.tem
+ rm -f Makefile
+ mv -f Makefile.tem Makefile
+ ;;
+ esac
+fi
+
+# Record target_configdirs and the configure arguments in Makefile.
+target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
+targargs=`echo "${arguments}" | \
+ sed -e 's/--no[^ ]*//' \
+ -e 's/--cache[a-z-]*=[^ ]*//' \
+ -e 's/--ho[a-z-]*=[^ ]*//' \
+ -e 's/--bu[a-z-]*=[^ ]*//' \
+ -e 's/--ta[a-z-]*=[^ ]*//'`
+
+# Passing a --with-cross-host argument lets the target libraries know
+# whether they are being built with a cross-compiler or being built
+# native. However, it would be better to use other mechanisms to make the
+# sorts of decisions they want to make on this basis. Please consider
+# this option to be deprecated. FIXME.
+if [ x${is_cross_compiler} = xyes ]; then
+ targargs="--with-cross-host=${host_alias} ${targargs}"
+fi
+
+# Default to --enable-multilib.
+if [ x${enable_multilib} = x ]; then
+ targargs="--enable-multilib ${targargs}"
+fi
+
+# Pass --with-newlib if appropriate. Note that target_configdirs has
+# changed from the earlier setting of with_newlib.
+if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && [ -d ${srcdir}/newlib ] ; then
+ targargs="--with-newlib ${targargs}"
+fi
+
+# provide a proper gxx_include_dir.
+# Note, if you change the default, make sure to fix both here and in
+# the gcc, libio, libstdc++ and libg++ subdirectories.
+# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
+gxx_include_dir=
+if test -n "${with_gxx_include_dir}"; then
+ case "${with_gxx_include_dir}" in
+ yes )
+ echo "configure.in: error: bad value ${withval} given for g++ include directory" 1>&2
+ exit 1
+ ;;
+ no )
+ ;;
+ * )
+ gxx_include_dir=${with_gxx_include_dir}
+ ;;
+ esac
+fi
+if test x${gxx_include_dir} = x; then
+ if test x${enable_version_specific_runtime_libs} = xyes; then
+ gxx_include_dir='${libsubdir}/include/g++'
+ else
+ . ${topsrcdir}/config.if
+ gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface}
+ fi
+else
+ gxx_include_dir=${gxx_include_dir}
+fi
+
+targargs="--host=${target_alias} --build=${build_alias} ${targargs}"
+sed -e "s:^TARGET_CONFIGDIRS[ ]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
+ -e "s%^CONFIG_ARGUMENTS[ ]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \
+ -e "s%^TARGET_SUBDIR[ ]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
+ -e "s%^gxx_include_dir[ ]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
+ Makefile > Makefile.tem
+rm -f Makefile
+mv -f Makefile.tem Makefile
+
+#
+# Local Variables:
+# fill-column: 131
+# End:
+#
diff --git a/etc/ChangeLog b/etc/ChangeLog
new file mode 100644
index 00000000000..0453a3e1339
--- /dev/null
+++ b/etc/ChangeLog
@@ -0,0 +1,507 @@
+1999-04-01 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ * add-log.el, add-log.vi: New files.
+
+Wed Jan 20 01:33:50 1999 Angela Marie Thomas (angela@cygnus.com)
+
+ * comp-tools-verify: Remove some checks that are no longer valid.
+
+1998-12-03 Nick Clifton <nickc@cygnus.com>
+
+ * targetdoc/fr30.texi: New document.
+
+Thu Oct 1 21:15:59 1998 Angela Marie Thomas (angela@cygnus.com)
+
+ * comp-tools-fix, cross-tools-fix: Replace /usr/include
+ with ${FIXINCDIR}.
+
+Tue Aug 11 19:22:11 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * make-rel-sym-tree (version): Update calculation.
+
+Fri Jun 12 21:34:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.texi: Various additions.
+ * Makefile.in (TEXI2HTML, DVIPS): New variables.
+ (standards.ps): New target.
+ (configure.dvi): Copy .tin files in as well.
+ (configure.ps, configure.html): New targets.
+ (clean): Remove configdev.jpg and configbuild.jpg.
+ * configdev.fig: New file.
+ * configdev.ein: New file (EPS version of configdev.fig).
+ * configdev.jin: New file (JPEG version of configdev.fig).
+ * configbuild.fig: New file.
+ * configbuild.ein: New file (EPS version of configbuild.fig).
+ * configbuild.jin: New file (JPEG version of configbuild.fig).
+
+Wed Jun 10 14:41:25 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.texi: New file.
+ * configdev.tin: New file.
+ * configbuild.tin: New file.
+ * Makefile.in (MAKEINFO): Use makeinfo from texinfo directory if
+ it exists.
+ (TEXI2DVI): Likewise for texi2dvi.
+ (INFOFILES): Add configure.info.
+ (DVIFILES): Add configure.dvi.
+ (info): Only build info files if the source files exist.
+ (install-info): Only install info files if they exist.
+ (dvi): Only build DVI files if the sources files exist.
+ (configure.info): New target.
+ (configure.dvi): New target.
+ (clean): Remove configdev and configbuild derived files.
+
+ Remove obsolete documentation.
+ * intro.texi: Remove.
+ * install.texi: Remove.
+ * config-names.texi: Remove.
+ * screen1.eps: Remove.
+ * screen1.obj: Remove.
+ * screen2.eps: Remove.
+ * screen2.obj: Remove.
+ * Makefile.in: Remove references to the above.
+
+Thu May 21 14:34:51 1998 Nick Clifton <nickc@cygnus.com>
+
+ * targetdoc/arm-interwork.texi: Add note about ignoring linker
+ warning message when using --support-old-code.
+
+Mon May 18 14:27:37 1998 Angela Marie Thomas (angela@cygnus.com)
+
+ * Install.in, comp-tools-fix, comp-tools-verify, cross-tools-fix:
+ Use $GCCvn rather than substitute everywhere.
+
+Thu May 14 14:43:10 1998 Nick Clifton <nickc@cygnus.com>
+
+ * targetdoc/arm-interwork.texi: Document dlltool support of
+ interworking.
+
+Thu May 7 16:49:38 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * Install.in: Remove references to TCL_LIBRARY, TK_LIBRARY,
+ and GDBTK_FILENAME.
+
+Wed Apr 1 17:11:44 1998 Nick Clifton <nickc@cygnus.com>
+
+ * targetdoc/arm-interwork.texi: Document ARM/thumb interworking.
+
+Tue Mar 31 15:28:20 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * standards.texi, make-stds.texi: Update to current FSF versions.
+ * Makefile.in (standards.info): Depend upon make-std.texi.
+
+Tue Mar 24 16:13:26 1998 Stu Grossman <grossman@bhuna.cygnus.co.uk>
+
+ * configure: Regenerate with autoconf 2.12.1 to fix shell issues
+ for NT native builds.
+
+Mon Mar 9 16:41:04 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * make-rel-sym-tree (binprogs): Add objcopy.
+
+Tue Feb 24 18:11:58 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * make-rel-sym-tree: as.new -> as-new, ld.new -> ld-new
+ nm.new -> nm-new. Make symlinks to crt*.o.
+
+Fri Nov 21 12:54:58 1997 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * Makefile.in: Add --no-split argument to avoid creating files
+ with names longer than 14 characters.
+
+Thu Sep 25 13:13:11 1997 Jason Molenda (crash@pern.cygnus.com)
+
+ * intro.texi: Add closing ifset.
+
+Mon Sep 1 10:31:32 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * Install.in: Move setting HOST and TARGET to the beginning
+ of the file for editing convenience.
+
+Mon Sep 1 10:28:37 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * Install.in.: More friendly options/messages when extracting
+ from a file instead of a tape device.
+
+Tue Jun 17 15:50:23 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * Install.in: Add /usr/bsd to PATH for Irix (home of compress)
+
+Thu Jun 12 13:47:00 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * Install.in (show_exec_prefix_msg): fix quoting
+
+Wed Jun 4 15:31:43 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * rebuilding.texi: Removed.
+
+Sat May 24 18:02:20 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * cross-tools-fix: Remove host check since it doesn't matter
+ for this case.
+ * Install.in (guess_system): clean up more unused hosts.
+ * Install.in, cross-tools-fix, comp-tools-fix, comp-tools-verify:
+ Hack for host check to not warn the user for certain cases.
+
+Fri May 23 23:46:10 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * subst-strings: Remove a lot of unused code
+ * Install.in: Remove reference to TAPEdflt, use variables instead of
+ string substitution when able.
+
+Fri Apr 11 17:25:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Change file named in AC_INIT to Makefile.in.
+ * configure: Rebuild.
+
+Fri Apr 11 18:12:42 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Install.in (guess_system): Back out change to INSTALLHOST to
+ call all IRIX systems "mips-sgi-irix4"
+
+ * Makefile.in: Remove references to configure.texi and cfg-paper.texi.
+
+Thu Apr 10 23:26:45 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * srctree.texi, emacs-relnotes.texi, cfg-paper.texi: Remove.
+ * Install.in: Remove Ultrix-specific hacks.
+ Update Cygnus phone numbers.
+ (guess_system): Remove some old systems (Ultrix, OSF1 v1 & 2,
+ m68k-HPUX, m68k SunOS, etc.)
+ (show_gnu_root_msg): Remove.
+ Removed all the remove option code.
+
+Thu Apr 10 23:23:33 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * configure.man, configure.texi: Remote.
+
+Mon Apr 7 18:15:00 1997 Brendan Kehoe <brendan@cygnus.com>
+
+ * Fix the version string for OSF1 4.0 to recognize either
+ V4.* or X4.*
+
+Mon Apr 7 15:34:47 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * standards.texi, make-stds.texi: Update to current FSF versions.
+
+Tue Nov 19 15:36:14 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * make-rel-sym-tree: New file.
+
+Wed Oct 23 00:34:07 1996 Angela Marie Thomas (angela@cygnus.com)
+
+ * Lots of patches from progressive...
+ * Install.in: restore DDOPTS for AIX 4.x
+ * Install.in, subst-strings: add case for DG Aviion
+ * subst-strings: fix typo in INSTALLdir var setting
+ * comp-tools-verify: set SHLIB_PATH for shared libs
+ * Install.in, subst-strings: add case for solaris2.5
+ * Install.in: fix regression for hppa1.1 check
+ * comp-tools-fix: set LD_LIBRARY_PATH
+ * comp-tools-fix: If fixincludes fixes /usr/include/limits.h,
+ install it as syslimits.h.
+
+Wed Oct 16 19:20:42 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * Install.in (guess_system): Treat powerpc-ibm-aix4.1 the same as
+ rs6000-ibm-aix4.1, since the compiler now uses common mode by
+ default.
+
+Wed Oct 2 15:39:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * configure.in (AC_PROG_INSTALL): Added.
+ * Makefile.in (distclean): Remove config.cache.
+
+Wed Oct 2 14:33:58 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * configure.in: Switch to autoconf configure.in.
+ * configure: New.
+ * Makefile.in: Use autoconf-substituted values.
+
+Tue Jun 25 18:56:08 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (datadir): Changed to $(prefix)/share.
+
+Fri Mar 29 11:38:01 1996 J.T. Conklin (jtc@lisa.cygnus.com)
+
+ * configure.man: Changed to be recognized by catman -w on Solaris.
+
+Wed Dec 6 15:40:28 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * comp-tools-fix (fixincludes): Define FIXPROTO_DEFINES from
+ .../install-tools/fixproto-defines.
+
+Sun Nov 12 19:31:27 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * comp-tools-verify (verify_cxx_initializers): delete argv,
+ argc declarations, add -static to compile line.
+ (verify_cxx_hello_world): delete argv, argc declarations, add
+ -static to compile line.
+
+Wed Sep 20 13:21:52 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (maintainer-clean): New target, synonym for
+ realclean.
+
+Mon Aug 28 17:25:49 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Install.in (PATH): add /usr/ucb to $PATH (for SunOS 4.1.x).
+
+Tue Aug 15 21:51:58 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Install.in (guess_system): Match OSF/1 v3.x as the same as
+ v2.x--v2.x binaries are upward compatible.
+
+Tue Aug 15 21:46:54 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Install.in (guess_system): recognize HP 9000/800 systems as the
+ same as HP 9000/700 systems.
+
+Tue Aug 8 13:11:56 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * Install.in: For emacs, run show_emacs_alternate_msg and exit.
+ (show_emacs_alternate_msg): New message saying how emacs can't be
+ installed in an alternate prefix.
+
+Thu Jun 8 00:42:56 1995 Angela Marie Thomas <angela@cirdan.cygnus.com>
+
+ * subst-strings: change du commands to $BINDIR/. & $SRCDIR/. just
+ in case they are symlinks.
+
+Tue Apr 18 14:23:10 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * cdk-fix: Extracted table of targets that don't need their
+ headers fixed from gcc's configure script.
+
+ * cdk-fix, cdk-verify: Use ${HOST} instead of ||HOSTstr||
+
+ * cdk-fix, cdk-verify: New files, install script fragments used
+ for Cygnus Developer's Kit.
+
+ * Install.in (do_mkdir): New function.
+
+ * Install.in: Added support for --with and --without options.
+ Changed so that tape commands are not run when extracting
+ from a file.
+ (do_mt): Changed to take only one argument.
+
+Wed Mar 29 11:16:38 1995 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Install.in: catch UNAME==alpha-dec-osf2.x and correct entry for
+ alpha-dec-osf1.x
+
+Fri Jan 27 12:04:29 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * subst-strings (mips-sgi-irix5): New entry in table.
+
+Thu Jan 19 12:15:44 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * Install.in: Major rewrite, bundle dependent code (for example,
+ fixincludes for comp-tools) will be inserted into the Install
+ script when it is generated.
+
+Tue Jan 17 16:51:32 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * Makefile.in (Makefile): Rebuild using $(SHELL).
+
+Thu Nov 3 19:30:33 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * Makefile.in (install-info): Depend on info.
+
+Fri Aug 19 16:16:38 1994 Jason Molenda (crash@phydeaux.cygnus.com)
+
+ * Install.in: set $FIX_HEADER so fixproto can find fix-header.
+
+Fri May 6 16:18:58 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Makefile.in (install-info): add a semicolon in the if statement.
+
+Fri Apr 29 16:56:07 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * cfg-paper.texi: Update some outdated information.
+
+ * Makefile.in (install-info): Pass file, not directory, as last
+ arg to INSTALL_DATA.
+ (uninstall): New target.
+
+Thu Apr 28 14:42:22 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure.texi: Comment out @smallbook.
+
+ * Makefile.in: Define TEXI2DVI and TEXIDIR, and use the latter.
+ Remove info files in realclean, not clean, per coding standards.
+ Remove TeX output in clean.
+
+Tue Apr 26 17:18:03 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: fixincludes output is actually put in fixincludes.log,
+ but echo'ed messages claim it is fixinc.log. This is the same
+ messages as I logged in March 4 1994, but for some reason we found
+ the change hadn't been done. I'll have to dig through the logs
+ and find out what I really did do that day. :)
+
+Mon Apr 25 20:28:19 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: use eval to call do_mt() for Ultrix brokenness.
+
+Mon Apr 25 20:00:00 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in(do_mt): exit with error status 1 if # of parameters
+ != 3.
+
+Mon Apr 25 19:42:36 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: lose TAPE_FORWARD and TAPE_REWIND, add do_mt()
+ to do all tape movement operations. Currently untested. Addresses
+ PR # 4886 from bull.
+
+ * Install.in: add 1994 to the copyright thing.
+
+Fri Apr 22 19:05:13 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * standards.texi: Update from FSF.
+
+Fri Apr 22 15:46:10 1994 Jason Molenda (crash@cygnus.com)
+
+ * Install.in: Add $DDOPTS, has ``bs=124b'' for all systems except
+ AIX (some versions of AIX don't understand bs=124b. Silly OS).
+
+Mon Apr 4 22:55:05 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: null out $TOOLS before adding stuff to it
+ non-destructively.
+
+Wed Mar 30 21:45:35 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * standards.texi: Fix typo.
+
+ * configure.texi, configure.man: Document --disable-.
+
+Mon Mar 28 13:22:15 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * standards.texi: Update from FSF.
+
+Sat Mar 26 09:21:44 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * standards.texi, make-stds.texi: Update from FSF.
+
+Fri Mar 25 22:59:45 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure.texi, configure.man: Document --enable-* options.
+
+Wed Mar 23 23:38:24 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: set CPP to be gcc -E for fixincludes.
+
+Wed Mar 23 13:42:48 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: set PATH to $PATH:/bin:/usr/bin so we can pick
+ up native tools even if the user doesn't have them in his
+ path.
+
+ * Install.in: ``hppa-1.1-hp-hpux'' -> ``hppa1.1-hp-hpux''.
+
+Tue Mar 15 22:09:20 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: TAPE_REWIND and TAPE_FORWARD variables for Unixunaware,
+ added switch statement to detect if system is Unixunaware.
+
+Fri Mar 4 12:10:30 1994 Jason Molenda (crash@sendai.cygnus.com)
+
+ * Install.in: fixincludes output is actually put in fixincludes.log,
+ but echo'ed messages claim it is fixinc.log.
+
+Wed Nov 3 02:58:02 1993 Jeffrey Osier (jeffrey@thepub.cygnus.com)
+
+ * subst-strings: output TEXBUNDLE for more install notes matching
+ * install-texi.in: PRMS info now exists
+
+Tue Oct 26 16:57:12 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * subst-strings: match solaris*. Also, add default case to catch
+ and error out for unrecognized systems.
+
+Thu Aug 19 18:21:31 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Install.in: handle the new fixproto work
+
+Mon Jul 19 12:05:41 1993 david d `zoo' zuhn (zoo@cirdan.cygnus.com)
+
+ * Install.in: remove "MT=tctl" for AIX (not needed, and barely
+ worked anyway)
+
+Mon Jun 14 19:09:22 1993 Jeffrey Osier (jeffrey@cygnus.com)
+
+ * subst-strings: changed HOST to recognize Solaris for install notes
+
+Thu Jun 10 16:01:25 1993 Jeffrey Osier (jeffrey@cygnus.com)
+
+ * dos-inst.texi: new file.
+
+Wed Jun 9 19:23:59 1993 Jeffrey Osier (jeffrey@rtl.cygnus.com)
+
+ * install-texi.in: added conditionals (nearly complete)
+ cleaned up
+ added support for other releases (not done)
+
+Wed Jun 9 15:53:58 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * Makefile.in (install-info): Use INSTALL_DATA.
+ ({dist,real}clean): Also delete Makefile and config.status.
+
+Fri Jun 4 17:09:56 1993 Jeffrey Osier (jeffrey@cygnus.com)
+
+ * subst-strings: added data for OS_STRING
+
+ * subst-strings: added support for OS_STRING
+
+Thu Jun 3 00:37:01 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Install.in: pull COPYING and COPYING.LIB off of the tape
+
+Tue Jun 1 16:52:08 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * subst-strings: replace RELEASE_DIR too
+
+Mon Mar 22 23:55:27 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: add installcheck target
+
+Wed Mar 17 02:21:15 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Install.in: fix 'source only' extraction bug where it looked for
+ the src dir under H-<host>/src instead of src; also remove stray
+ reference to EMACSHIBIN
+
+Mon Mar 15 01:25:45 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * make-stds.texi: added 'installcheck' to the standard targets
+
+Tue Mar 9 19:48:28 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * standards.texi: added INFO-DIR-ENTRY, updated version from the FSF
+
+Tue Feb 9 12:40:23 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (standards.info): Added -I$(srcdir) to find
+ make-stds.texi.
+
+Mon Feb 1 16:32:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * standards.texi: updated to latest FSF version, which includes:
+
+ * make-stds.texi: new file
+
+Mon Nov 30 01:31:40 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * install-texi.in, relnotes.texi, intro.texi: changed Cygnus phone
+ numbers from the old Palo Alto ones to the new Mtn. View numbers
+
+Mon Nov 16 16:50:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: define $(RM) to "rm -f"
+
+Sun Oct 11 16:05:48 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * intro.texi: added INFO-DIR-ENTRY
+
diff --git a/etc/Makefile.in b/etc/Makefile.in
new file mode 100644
index 00000000000..eedc8c9c1ac
--- /dev/null
+++ b/etc/Makefile.in
@@ -0,0 +1,156 @@
+#
+# Makefile.in for etc
+#
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)
+datadir = @datadir@
+
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+
+SHELL = /bin/sh
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+MAKEINFO = `if [ -f ../texinfo/makeinfo/makeinfo ]; \
+ then echo ../texinfo/makeinfo/makeinfo; \
+ else echo makeinfo; fi`
+TEXI2DVI = `if [ -f ../texinfo/util/texi2dvi ]; \
+ then echo ../texinfo/util/texi2dvi; \
+ else echo texi2dvi; fi`
+TEXI2HTML = texi2html
+DVIPS = dvips
+
+# Where to find texinfo.tex to format documentation with TeX.
+TEXIDIR = $(srcdir)/../texinfo
+
+#### Host, target, and site specific Makefile fragments come in here.
+###
+
+INFOFILES = standards.info configure.info
+DVIFILES = standards.dvi configure.dvi
+
+all:
+
+install:
+
+uninstall:
+
+info:
+ for f in $(INFOFILES); do \
+ if test -f $(srcdir)/`echo $$f | sed -e 's/.info$$/.texi/'`; then \
+ if $(MAKE) "MAKEINFO=$(MAKEINFO)" $$f; then \
+ true; \
+ else \
+ exit 1; \
+ fi; \
+ fi; \
+ done
+
+install-info: info
+ $(SHELL) $(srcdir)/../mkinstalldirs $(infodir)
+ if test ! -f standards.info; then cd $(srcdir); fi; \
+ if test -f standards.info; then \
+ for i in standards.info*; do \
+ $(INSTALL_DATA) $$i $(infodir)/$$i; \
+ done; \
+ fi
+ if test ! -f configure.info; then cd $(srcdir); fi; \
+ if test -f configure.info; then \
+ for i in configure.info*; do \
+ $(INSTALL_DATA) $$i $(infodir)/$$i; \
+ done; \
+ fi
+
+dvi:
+ for f in $(DVIFILES); do \
+ if test -f $(srcdir)/`echo $$f | sed -e 's/.dvi$$/.texi/'`; then \
+ if $(MAKE) "TEXI2DVI=$(TEXI2DVI)" $$f; then \
+ true; \
+ else \
+ exit 1; \
+ fi; \
+ fi; \
+ done
+
+standards.info: $(srcdir)/standards.texi $(srcdir)/make-stds.texi
+ $(MAKEINFO) --no-split -I$(srcdir) -o standards.info $(srcdir)/standards.texi
+
+standards.dvi: $(srcdir)/standards.texi
+ TEXINPUTS=$(TEXIDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/standards.texi
+
+standards.ps: standards.dvi
+ $(DVIPS) standards.dvi -o standards.ps
+
+# makeinfo requires images to be in the current directory.
+configure.info: $(srcdir)/configure.texi $(srcdir)/configdev.tin $(srcdir)/configbuild.tin
+ rm -f configdev.txt configbuild.txt
+ cp $(srcdir)/configdev.tin configdev.txt
+ cp $(srcdir)/configbuild.tin configbuild.txt
+ $(MAKEINFO) -I$(srcdir) -o configure.info $(srcdir)/configure.texi
+ rm -f configdev.txt configbuild.txt
+
+# texi2dvi wants both the .txt and the .eps files.
+configure.dvi: $(srcdir)/configure.texi $(srcdir)/configdev.tin $(srcdir)/configbuild.tin $(srcdir)/configdev.ein $(srcdir)/configbuild.ein
+ rm -f configdev.txt configbuild.txt
+ cp $(srcdir)/configdev.tin configdev.txt
+ cp $(srcdir)/configbuild.tin configbuild.txt
+ rm -f configdev.eps configbuild.eps
+ cp $(srcdir)/configdev.ein configdev.eps
+ cp $(srcdir)/configbuild.ein configbuild.eps
+ TEXINPUTS=$(TEXIDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/configure.texi
+ rm -f configdev.txt configbuild.txt
+ rm -f configdev.eps configbuild.eps
+
+# dvips requires images to be in the current directory
+configure.ps: configure.dvi $(srcdir)/configdev.ein $(srcdir)/configbuild.ein
+ rm -f configdev.eps configbuild.eps
+ cp $(srcdir)/configdev.ein configdev.eps
+ cp $(srcdir)/configbuild.ein configbuild.eps
+ $(DVIPS) configure.dvi -o configure.ps
+ rm -f configdev.eps configbuild.eps
+
+configure.html: $(srcdir)/configure.texi
+ $(TEXI2HTML) -split_chapter $(srcdir)/configure.texi
+
+clean:
+ rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.log
+ rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs
+ rm -f configdev.txt configbuild.txt configdev.eps configbuild.eps
+ rm -f configdev.jpg configbuild.jpg
+
+mostlyclean: clean
+
+distclean: clean
+ rm -f Makefile config.status config.cache
+
+maintainer-clean realclean: distclean
+ rm -f *.info*
+
+Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
+ $(SHELL) ./config.status
+
+## these last targets are for standards.texi conformance
+dist:
+check:
+installcheck:
+TAGS:
diff --git a/etc/add-log.el b/etc/add-log.el
new file mode 100644
index 00000000000..60c88e8c949
--- /dev/null
+++ b/etc/add-log.el
@@ -0,0 +1,573 @@
+;;; ============ NOTE WELL! =============
+;;;
+;;; You only need to use this file if you're using a version of Emacs
+;;; prior to 20.1 to work on GDB. The only difference between this
+;;; and the standard add-log.el provided with 19.34 is that it
+;;; generates dates using the terser format used by Emacs 20. This is
+;;; the format recommended for use in GDB ChangeLogs.
+;;;
+;;; To use this code, you should create a directory `~/elisp', save the code
+;;; below in `~/elisp/add-log.el', and then put something like this in
+;;; your `~/.emacs' file, to tell Emacs where to find it:
+;;;
+;;; (setq load-path
+;;; (cons (expand-file-name "~/elisp")
+;;; load-path))
+;;;
+;;; If you want, you can also byte-compile it --- it'll run a little
+;;; faster, and use a little less memory. (Not that those matter much for
+;;; this file.) To do that, after you've saved the text as
+;;; ~/elisp/add-log.el, bring it up in Emacs, and type
+;;;
+;;; C-u M-x byte-compile-file
+;;;
+;;; --- Jim Blandy
+
+;;; add-log.el --- change log maintenance commands for Emacs
+
+;; Copyright (C) 1985, 1986, 1988, 1993, 1994 Free Software Foundation, Inc.
+
+;; Keywords: maint
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This facility is documented in the Emacs Manual.
+
+;;; Code:
+
+(defvar change-log-default-name nil
+ "*Name of a change log file for \\[add-change-log-entry].")
+
+(defvar add-log-current-defun-function nil
+ "\
+*If non-nil, function to guess name of current function from surrounding text.
+\\[add-change-log-entry] calls this function (if nil, `add-log-current-defun'
+instead) with no arguments. It returns a string or nil if it cannot guess.")
+
+;;;###autoload
+(defvar add-log-full-name nil
+ "*Full name of user, for inclusion in ChangeLog daily headers.
+This defaults to the value returned by the `user-full-name' function.")
+
+;;;###autoload
+(defvar add-log-mailing-address nil
+ "*Electronic mail address of user, for inclusion in ChangeLog daily headers.
+This defaults to the value of `user-mail-address'.")
+
+(defvar change-log-font-lock-keywords
+ '(("^[SMTWF].+" . font-lock-function-name-face) ; Date line.
+ ("^\t\\* \\([^ :\n]+\\)" 1 font-lock-comment-face) ; File name.
+ ("(\\([^)\n]+\\)):" 1 font-lock-keyword-face)) ; Function name.
+ "Additional expressions to highlight in Change Log mode.")
+
+(defvar change-log-mode-map nil
+ "Keymap for Change Log major mode.")
+(if change-log-mode-map
+ nil
+ (setq change-log-mode-map (make-sparse-keymap))
+ (define-key change-log-mode-map "\M-q" 'change-log-fill-paragraph))
+
+(defun change-log-name ()
+ (or change-log-default-name
+ (if (eq system-type 'vax-vms)
+ "$CHANGE_LOG$.TXT"
+ (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
+ "changelo"
+ "ChangeLog"))))
+
+;;;###autoload
+(defun prompt-for-change-log-name ()
+ "Prompt for a change log name."
+ (let* ((default (change-log-name))
+ (name (expand-file-name
+ (read-file-name (format "Log file (default %s): " default)
+ nil default))))
+ ;; Handle something that is syntactically a directory name.
+ ;; Look for ChangeLog or whatever in that directory.
+ (if (string= (file-name-nondirectory name) "")
+ (expand-file-name (file-name-nondirectory default)
+ name)
+ ;; Handle specifying a file that is a directory.
+ (if (file-directory-p name)
+ (expand-file-name (file-name-nondirectory default)
+ (file-name-as-directory name))
+ name))))
+
+;;;###autoload
+(defun find-change-log (&optional file-name)
+ "Find a change log file for \\[add-change-log-entry] and return the name.
+
+Optional arg FILE-NAME specifies the file to use.
+If FILE-NAME is nil, use the value of `change-log-default-name'.
+If 'change-log-default-name' is nil, behave as though it were 'ChangeLog'
+\(or whatever we use on this operating system).
+
+If 'change-log-default-name' contains a leading directory component, then
+simply find it in the current directory. Otherwise, search in the current
+directory and its successive parents for a file so named.
+
+Once a file is found, `change-log-default-name' is set locally in the
+current buffer to the complete file name."
+ ;; If user specified a file name or if this buffer knows which one to use,
+ ;; just use that.
+ (or file-name
+ (setq file-name (and change-log-default-name
+ (file-name-directory change-log-default-name)
+ change-log-default-name))
+ (progn
+ ;; Chase links in the source file
+ ;; and use the change log in the dir where it points.
+ (setq file-name (or (and buffer-file-name
+ (file-name-directory
+ (file-chase-links buffer-file-name)))
+ default-directory))
+ (if (file-directory-p file-name)
+ (setq file-name (expand-file-name (change-log-name) file-name)))
+ ;; Chase links before visiting the file.
+ ;; This makes it easier to use a single change log file
+ ;; for several related directories.
+ (setq file-name (file-chase-links file-name))
+ (setq file-name (expand-file-name file-name))
+ ;; Move up in the dir hierarchy till we find a change log file.
+ (let ((file1 file-name)
+ parent-dir)
+ (while (and (not (or (get-file-buffer file1) (file-exists-p file1)))
+ (progn (setq parent-dir
+ (file-name-directory
+ (directory-file-name
+ (file-name-directory file1))))
+ ;; Give up if we are already at the root dir.
+ (not (string= (file-name-directory file1)
+ parent-dir))))
+ ;; Move up to the parent dir and try again.
+ (setq file1 (expand-file-name
+ (file-name-nondirectory (change-log-name))
+ parent-dir)))
+ ;; If we found a change log in a parent, use that.
+ (if (or (get-file-buffer file1) (file-exists-p file1))
+ (setq file-name file1)))))
+ ;; Make a local variable in this buffer so we needn't search again.
+ (set (make-local-variable 'change-log-default-name) file-name)
+ file-name)
+
+;;;###autoload
+(defun add-change-log-entry (&optional whoami file-name other-window new-entry)
+ "Find change log file and add an entry for today.
+Optional arg (interactive prefix) non-nil means prompt for user name and site.
+Second arg is file name of change log. If nil, uses `change-log-default-name'.
+Third arg OTHER-WINDOW non-nil means visit in other window.
+Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
+never append to an existing entry."
+ (interactive (list current-prefix-arg
+ (prompt-for-change-log-name)))
+ (or add-log-full-name
+ (setq add-log-full-name (user-full-name)))
+ (or add-log-mailing-address
+ (setq add-log-mailing-address user-mail-address))
+ (if whoami
+ (progn
+ (setq add-log-full-name (read-input "Full name: " add-log-full-name))
+ ;; Note that some sites have room and phone number fields in
+ ;; full name which look silly when inserted. Rather than do
+ ;; anything about that here, let user give prefix argument so that
+ ;; s/he can edit the full name field in prompter if s/he wants.
+ (setq add-log-mailing-address
+ (read-input "Mailing address: " add-log-mailing-address))))
+ (let ((defun (funcall (or add-log-current-defun-function
+ 'add-log-current-defun)))
+ paragraph-end entry)
+
+ (setq file-name (expand-file-name (find-change-log file-name)))
+
+ ;; Set ENTRY to the file name to use in the new entry.
+ (and buffer-file-name
+ ;; Never want to add a change log entry for the ChangeLog file itself.
+ (not (string= buffer-file-name file-name))
+ (setq entry (if (string-match
+ (concat "^" (regexp-quote (file-name-directory
+ file-name)))
+ buffer-file-name)
+ (substring buffer-file-name (match-end 0))
+ (file-name-nondirectory buffer-file-name))))
+
+ (if (and other-window (not (equal file-name buffer-file-name)))
+ (find-file-other-window file-name)
+ (find-file file-name))
+ (or (eq major-mode 'change-log-mode)
+ (change-log-mode))
+ (undo-boundary)
+ (goto-char (point-min))
+ (let ((heading (format "%s %s <%s>"
+ (format-time-string "%Y-%m-%d")
+ add-log-full-name
+ add-log-mailing-address)))
+ (if (looking-at (regexp-quote heading))
+ (forward-line 1)
+ (insert heading "\n\n")))
+
+ ;; Search only within the first paragraph.
+ (if (looking-at "\n*[^\n* \t]")
+ (skip-chars-forward "\n")
+ (forward-paragraph 1))
+ (setq paragraph-end (point))
+ (goto-char (point-min))
+
+ ;; Now insert the new line for this entry.
+ (cond ((re-search-forward "^\\s *\\*\\s *$" paragraph-end t)
+ ;; Put this file name into the existing empty entry.
+ (if entry
+ (insert entry)))
+ ((and (not new-entry)
+ (let (case-fold-search)
+ (re-search-forward
+ (concat (regexp-quote (concat "* " entry))
+ ;; Don't accept `foo.bar' when
+ ;; looking for `foo':
+ "\\(\\s \\|[(),:]\\)")
+ paragraph-end t)))
+ ;; Add to the existing entry for the same file.
+ (re-search-forward "^\\s *$\\|^\\s \\*")
+ (goto-char (match-beginning 0))
+ ;; Delete excess empty lines; make just 2.
+ (while (and (not (eobp)) (looking-at "^\\s *$"))
+ (delete-region (point) (save-excursion (forward-line 1) (point))))
+ (insert "\n\n")
+ (forward-line -2)
+ (indent-relative-maybe))
+ (t
+ ;; Make a new entry.
+ (forward-line 1)
+ (while (looking-at "\\sW")
+ (forward-line 1))
+ (while (and (not (eobp)) (looking-at "^\\s *$"))
+ (delete-region (point) (save-excursion (forward-line 1) (point))))
+ (insert "\n\n\n")
+ (forward-line -2)
+ (indent-to left-margin)
+ (insert "* " (or entry ""))))
+ ;; Now insert the function name, if we have one.
+ ;; Point is at the entry for this file,
+ ;; either at the end of the line or at the first blank line.
+ (if defun
+ (progn
+ ;; Make it easy to get rid of the function name.
+ (undo-boundary)
+ (insert (if (save-excursion
+ (beginning-of-line 1)
+ (looking-at "\\s *$"))
+ ""
+ " ")
+ "(" defun "): "))
+ ;; No function name, so put in a colon unless we have just a star.
+ (if (not (save-excursion
+ (beginning-of-line 1)
+ (looking-at "\\s *\\(\\*\\s *\\)?$")))
+ (insert ": ")))))
+
+;;;###autoload
+(defun add-change-log-entry-other-window (&optional whoami file-name)
+ "Find change log file in other window and add an entry for today.
+Optional arg (interactive prefix) non-nil means prompt for user name and site.
+Second arg is file name of change log. \
+If nil, uses `change-log-default-name'."
+ (interactive (if current-prefix-arg
+ (list current-prefix-arg
+ (prompt-for-change-log-name))))
+ (add-change-log-entry whoami file-name t))
+;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
+
+;;;###autoload
+(defun change-log-mode ()
+ "Major mode for editing change logs; like Indented Text Mode.
+Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74.
+New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window].
+Each entry behaves as a paragraph, and the entries for one day as a page.
+Runs `change-log-mode-hook'."
+ (interactive)
+ (kill-all-local-variables)
+ (indented-text-mode)
+ (setq major-mode 'change-log-mode
+ mode-name "Change Log"
+ left-margin 8
+ fill-column 74
+ indent-tabs-mode t
+ tab-width 8)
+ (use-local-map change-log-mode-map)
+ ;; Let each entry behave as one paragraph:
+ ;; We really do want "^" in paragraph-start below: it is only the lines that
+ ;; begin at column 0 (despite the left-margin of 8) that we are looking for.
+ (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\sw")
+ (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\sw")
+ ;; Let all entries for one day behave as one page.
+ ;; Match null string on the date-line so that the date-line
+ ;; is grouped with what follows.
+ (set (make-local-variable 'page-delimiter) "^\\<\\|^\f")
+ (set (make-local-variable 'version-control) 'never)
+ (set (make-local-variable 'adaptive-fill-regexp) "\\s *")
+ (set (make-local-variable 'font-lock-defaults)
+ '(change-log-font-lock-keywords t))
+ (run-hooks 'change-log-mode-hook))
+
+;; It might be nice to have a general feature to replace this. The idea I
+;; have is a variable giving a regexp matching text which should not be
+;; moved from bol by filling. change-log-mode would set this to "^\\s *\\s(".
+;; But I don't feel up to implementing that today.
+(defun change-log-fill-paragraph (&optional justify)
+ "Fill the paragraph, but preserve open parentheses at beginning of lines.
+Prefix arg means justify as well."
+ (interactive "P")
+ (let ((end (save-excursion (forward-paragraph) (point)))
+ (beg (save-excursion (backward-paragraph)(point)))
+ (paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
+ (fill-region beg end justify)))
+
+(defvar add-log-current-defun-header-regexp
+ "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[-_a-zA-Z]+\\)[ \t]*[:=]"
+ "*Heuristic regexp used by `add-log-current-defun' for unknown major modes.")
+
+;;;###autoload
+(defun add-log-current-defun ()
+ "Return name of function definition point is in, or nil.
+
+Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...),
+Texinfo (@node titles), Perl, and Fortran.
+
+Other modes are handled by a heuristic that looks in the 10K before
+point for uppercase headings starting in the first column or
+identifiers followed by `:' or `=', see variable
+`add-log-current-defun-header-regexp'.
+
+Has a preference of looking backwards."
+ (condition-case nil
+ (save-excursion
+ (let ((location (point)))
+ (cond ((memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode
+ lisp-interaction-mode))
+ ;; If we are now precisely at the beginning of a defun,
+ ;; make sure beginning-of-defun finds that one
+ ;; rather than the previous one.
+ (or (eobp) (forward-char 1))
+ (beginning-of-defun)
+ ;; Make sure we are really inside the defun found, not after it.
+ (if (and (looking-at "\\s(")
+ (progn (end-of-defun)
+ (< location (point)))
+ (progn (forward-sexp -1)
+ (>= location (point))))
+ (progn
+ (if (looking-at "\\s(")
+ (forward-char 1))
+ (forward-sexp 1)
+ (skip-chars-forward " '")
+ (buffer-substring (point)
+ (progn (forward-sexp 1) (point))))))
+ ((and (memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
+ (save-excursion (beginning-of-line)
+ ;; Use eq instead of = here to avoid
+ ;; error when at bob and char-after
+ ;; returns nil.
+ (while (eq (char-after (- (point) 2)) ?\\)
+ (forward-line -1))
+ (looking-at "[ \t]*#[ \t]*define[ \t]")))
+ ;; Handle a C macro definition.
+ (beginning-of-line)
+ (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
+ (forward-line -1))
+ (search-forward "define")
+ (skip-chars-forward " \t")
+ (buffer-substring (point)
+ (progn (forward-sexp 1) (point))))
+ ((memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
+ (beginning-of-line)
+ ;; See if we are in the beginning part of a function,
+ ;; before the open brace. If so, advance forward.
+ (while (not (looking-at "{\\|\\(\\s *$\\)"))
+ (forward-line 1))
+ (or (eobp)
+ (forward-char 1))
+ (beginning-of-defun)
+ (if (progn (end-of-defun)
+ (< location (point)))
+ (progn
+ (backward-sexp 1)
+ (let (beg tem)
+
+ (forward-line -1)
+ ;; Skip back over typedefs of arglist.
+ (while (and (not (bobp))
+ (looking-at "[ \t\n]"))
+ (forward-line -1))
+ ;; See if this is using the DEFUN macro used in Emacs,
+ ;; or the DEFUN macro used by the C library.
+ (if (condition-case nil
+ (and (save-excursion
+ (end-of-line)
+ (while (= (preceding-char) ?\\)
+ (end-of-line 2))
+ (backward-sexp 1)
+ (beginning-of-line)
+ (setq tem (point))
+ (looking-at "DEFUN\\b"))
+ (>= location tem))
+ (error nil))
+ (progn
+ (goto-char tem)
+ (down-list 1)
+ (if (= (char-after (point)) ?\")
+ (progn
+ (forward-sexp 1)
+ (skip-chars-forward " ,")))
+ (buffer-substring (point)
+ (progn (forward-sexp 1) (point))))
+ (if (looking-at "^[+-]")
+ (get-method-definition)
+ ;; Ordinary C function syntax.
+ (setq beg (point))
+ (if (and (condition-case nil
+ ;; Protect against "Unbalanced parens" error.
+ (progn
+ (down-list 1) ; into arglist
+ (backward-up-list 1)
+ (skip-chars-backward " \t")
+ t)
+ (error nil))
+ ;; Verify initial pos was after
+ ;; real start of function.
+ (save-excursion
+ (goto-char beg)
+ ;; For this purpose, include the line
+ ;; that has the decl keywords. This
+ ;; may also include some of the
+ ;; comments before the function.
+ (while (and (not (bobp))
+ (save-excursion
+ (forward-line -1)
+ (looking-at "[^\n\f]")))
+ (forward-line -1))
+ (>= location (point)))
+ ;; Consistency check: going down and up
+ ;; shouldn't take us back before BEG.
+ (> (point) beg))
+ (let (end middle)
+ ;; Don't include any final newline
+ ;; in the name we use.
+ (if (= (preceding-char) ?\n)
+ (forward-char -1))
+ (setq end (point))
+ (backward-sexp 1)
+ ;; Now find the right beginning of the name.
+ ;; Include certain keywords if they
+ ;; precede the name.
+ (setq middle (point))
+ (forward-word -1)
+ ;; Ignore these subparts of a class decl
+ ;; and move back to the class name itself.
+ (while (looking-at "public \\|private ")
+ (skip-chars-backward " \t:")
+ (setq end (point))
+ (backward-sexp 1)
+ (setq middle (point))
+ (forward-word -1))
+ (and (bolp)
+ (looking-at "struct \\|union \\|class ")
+ (setq middle (point)))
+ (buffer-substring middle end)))))))))
+ ((memq major-mode
+ '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
+ plain-tex-mode latex-mode;; cmutex.el
+ ))
+ (if (re-search-backward
+ "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
+ (progn
+ (goto-char (match-beginning 0))
+ (buffer-substring (1+ (point));; without initial backslash
+ (progn
+ (end-of-line)
+ (point))))))
+ ((eq major-mode 'texinfo-mode)
+ (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
+ (buffer-substring (match-beginning 1)
+ (match-end 1))))
+ ((eq major-mode 'perl-mode)
+ (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t)
+ (buffer-substring (match-beginning 1)
+ (match-end 1))))
+ ((eq major-mode 'fortran-mode)
+ ;; must be inside function body for this to work
+ (beginning-of-fortran-subprogram)
+ (let ((case-fold-search t)) ; case-insensitive
+ ;; search for fortran subprogram start
+ (if (re-search-forward
+ "^[ \t]*\\(program\\|subroutine\\|function\
+\\|[ \ta-z0-9*]*[ \t]+function\\)"
+ nil t)
+ (progn
+ ;; move to EOL or before first left paren
+ (if (re-search-forward "[(\n]" nil t)
+ (progn (forward-char -1)
+ (skip-chars-backward " \t"))
+ (end-of-line))
+ ;; Use the name preceding that.
+ (buffer-substring (point)
+ (progn (forward-sexp -1)
+ (point)))))))
+ (t
+ ;; If all else fails, try heuristics
+ (let (case-fold-search)
+ (end-of-line)
+ (if (re-search-backward add-log-current-defun-header-regexp
+ (- (point) 10000)
+ t)
+ (buffer-substring (match-beginning 1)
+ (match-end 1))))))))
+ (error nil)))
+
+(defvar get-method-definition-md)
+
+;; Subroutine used within get-method-definition.
+;; Add the last match in the buffer to the end of `md',
+;; followed by the string END; move to the end of that match.
+(defun get-method-definition-1 (end)
+ (setq get-method-definition-md
+ (concat get-method-definition-md
+ (buffer-substring (match-beginning 1) (match-end 1))
+ end))
+ (goto-char (match-end 0)))
+
+;; For objective C, return the method name if we are in a method.
+(defun get-method-definition ()
+ (let ((get-method-definition-md "["))
+ (save-excursion
+ (if (re-search-backward "^@implementation\\s-*\\([A-Za-z_]*\\)" nil t)
+ (get-method-definition-1 " ")))
+ (save-excursion
+ (cond
+ ((re-search-forward "^\\([-+]\\)[ \t\n\f\r]*\\(([^)]*)\\)?\\s-*" nil t)
+ (get-method-definition-1 "")
+ (while (not (looking-at "[{;]"))
+ (looking-at
+ "\\([A-Za-z_]*:?\\)\\s-*\\(([^)]*)\\)?[A-Za-z_]*[ \t\n\f\r]*")
+ (get-method-definition-1 ""))
+ (concat get-method-definition-md "]"))))))
+
+
+(provide 'add-log)
+
+;;; add-log.el ends here
diff --git a/etc/add-log.vi b/etc/add-log.vi
new file mode 100644
index 00000000000..efb8c77aa2b
--- /dev/null
+++ b/etc/add-log.vi
@@ -0,0 +1,11 @@
+Here is a vi macro to create entries in the recommended format for
+GDB's ChangeLogs.
+
+map  1GO:r !date '+\%Y-\%m-\%d'2GA Jason Molenda (:r !whoamikJxA@:r !hostnameA)kJxkddjO * k$
+
+It contains control and escape sequences, so don't just cut and paste it.
+You'll need to change the "Jason Molenda" bit, of course. :-) Put this
+in your $HOME/.exrc and when you type control-X in move-around-mode,
+you'll have a changelog template inserted.
+
+--- Jason Molenda
diff --git a/etc/configbuild.ein b/etc/configbuild.ein
new file mode 100644
index 00000000000..7a0e214f2d5
--- /dev/null
+++ b/etc/configbuild.ein
@@ -0,0 +1,149 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: configbuild.fig
+%%Creator: fig2dev Version 3.1 Patchlevel 1
+%%CreationDate: Fri Jun 12 20:13:16 1998
+%%For: ian@tito.cygnus.com (Ian Lance Taylor)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 322 173
+%%Pages: 0
+%%BeginSetup
+%%IncludeFeature: *PageSize Letter
+%%EndSetup
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {} def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-62.0 226.0 translate
+1 -1 scale
+
+/clp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+ 0.06000 0.06000 sc
+7.500 slw
+% Polyline
+n 1050 900 m 2100 900 l 2100 1425 l 1050 1425 l clp gs col-1 s gr
+% Polyline
+n 1500 1425 m 1500 2100 l gs col-1 s gr
+n 1530.00 1980.00 m 1500.00 2100.00 l 1470.00 1980.00 l 1500.50 1980.50 l 1530.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 1500 2625 m 1500 3300 l gs col-1 s gr
+n 1530.00 3180.00 m 1500.00 3300.00 l 1470.00 3180.00 l 1500.50 3180.50 l 1530.00 3180.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 2925 900 m 3825 900 l 3825 1425 l 2925 1425 l clp gs col-1 s gr
+% Polyline
+n 1155 2100 m 1050 2100 1050 2520 105 arcto 4 {pop} repeat 1050 2625 2220 2625 105 arcto 4 {pop} repeat 2325 2625 2325 2205 105 arcto 4 {pop} repeat 2325 2100 1155 2100 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 2850 2100 m 4125 2100 l 4125 2625 l 2850 2625 l clp gs col-1 s gr
+% Polyline
+n 3375 1425 m 3375 2100 l gs col-1 s gr
+n 3405.00 1980.00 m 3375.00 2100.00 l 3345.00 1980.00 l 3375.50 1980.50 l 3405.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 5100 900 m 6300 900 l 6300 1350 l 5100 1350 l clp gs col-1 s gr
+% Polyline
+n 5625 1350 m 5625 2100 l gs col-1 s gr
+n 5655.00 1980.00 m 5625.00 2100.00 l 5595.00 1980.00 l 5625.50 1980.50 l 5655.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 5205 2100 m 5100 2100 5100 2520 105 arcto 4 {pop} repeat 5100 2625 6270 2625 105 arcto 4 {pop} repeat 6375 2625 6375 2205 105 arcto 4 {pop} repeat 6375 2100 5205 2100 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 5625 2625 m 5625 3300 l gs col-1 s gr
+n 5655.00 3180.00 m 5625.00 3300.00 l 5595.00 3180.00 l 5625.50 3180.50 l 5655.00 3180.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 5100 3300 m 6225 3300 l 6225 3750 l 5100 3750 l clp gs col-1 s gr
+% Polyline
+ [1 50.0] 50.000000 setdash
+n 2850 2400 m 2325 2400 l gs col-1 s gr [] 0 setdash
+n 2445.00 2430.00 m 2325.00 2400.00 l 2445.00 2370.00 l 2445.50 2400.50 l 2445.00 2430.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+ [1 50.0] 50.000000 setdash
+n 4125 2400 m 5100 2400 l gs col-1 s gr [] 0 setdash
+n 4980.00 2370.00 m 5100.00 2400.00 l 4980.00 2430.00 l 4980.50 2400.50 l 4980.00 2370.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 1050 3300 m 1950 3300 l 1950 3750 l 1050 3750 l clp gs col-1 s gr
+/Times-Roman findfont 180.00 scalefont setfont
+1200 1200 m
+gs 1 -1 sc (config.in) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3000 1200 m
+gs 1 -1 sc (configure) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3000 2400 m
+gs 1 -1 sc (config.status) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+1200 2400 m
+gs 1 -1 sc (config.status) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+1200 3600 m
+gs 1 -1 sc (config.h) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+5250 1200 m
+gs 1 -1 sc (Makefile.in) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+5250 2400 m
+gs 1 -1 sc (config.status) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+5250 3600 m
+gs 1 -1 sc (Makefile) col-1 show gr
+$F2psEnd
+restore
diff --git a/etc/configbuild.fig b/etc/configbuild.fig
new file mode 100644
index 00000000000..747592d3d62
--- /dev/null
+++ b/etc/configbuild.fig
@@ -0,0 +1,50 @@
+#FIG 3.1
+Portrait
+Center
+Inches
+1200 2
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 1050 900 2100 900 2100 1425 1050 1425 1050 900
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 1500 1425 1500 2100
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 1500 2625 1500 3300
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 2925 900 3825 900 3825 1425 2925 1425 2925 900
+2 4 0 1 -1 7 0 0 -1 0.000 0 0 7 0 0 5
+ 2325 2625 2325 2100 1050 2100 1050 2625 2325 2625
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 2850 2100 4125 2100 4125 2625 2850 2625 2850 2100
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3375 1425 3375 2100
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 5100 900 6300 900 6300 1350 5100 1350 5100 900
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 5625 1350 5625 2100
+2 4 0 1 -1 7 0 0 -1 0.000 0 0 7 0 0 5
+ 6375 2625 6375 2100 5100 2100 5100 2625 6375 2625
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 5625 2625 5625 3300
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 5100 3300 6225 3300 6225 3750 5100 3750 5100 3300
+2 1 2 1 -1 7 0 0 -1 3.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 2850 2400 2325 2400
+2 1 2 1 -1 7 0 0 -1 3.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 4125 2400 5100 2400
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 1050 3300 1950 3300 1950 3750 1050 3750 1050 3300
+4 0 -1 0 0 0 12 0.0000000 4 180 645 1200 1200 config.in\001
+4 0 -1 0 0 0 12 0.0000000 4 180 705 3000 1200 configure\001
+4 0 -1 0 0 0 12 0.0000000 4 180 990 3000 2400 config.status\001
+4 0 -1 0 0 0 12 0.0000000 4 180 990 1200 2400 config.status\001
+4 0 -1 0 0 0 12 0.0000000 4 180 600 1200 3600 config.h\001
+4 0 -1 0 0 0 12 0.0000000 4 135 855 5250 1200 Makefile.in\001
+4 0 -1 0 0 0 12 0.0000000 4 180 990 5250 2400 config.status\001
+4 0 -1 0 0 0 12 0.0000000 4 135 675 5250 3600 Makefile\001
diff --git a/etc/configbuild.jin b/etc/configbuild.jin
new file mode 100644
index 00000000000..44cd9397aa1
--- /dev/null
+++ b/etc/configbuild.jin
Binary files differ
diff --git a/etc/configbuild.tin b/etc/configbuild.tin
new file mode 100644
index 00000000000..cfdd6fe0743
--- /dev/null
+++ b/etc/configbuild.tin
@@ -0,0 +1,9 @@
+ config.in *configure* Makefile.in
+ | | |
+ | v |
+ | config.status |
+ | | |
+ *config.status*<======+==========>*config.status*
+ | |
+ v v
+ config.h Makefile
diff --git a/etc/configdev.ein b/etc/configdev.ein
new file mode 100644
index 00000000000..7f837850d69
--- /dev/null
+++ b/etc/configdev.ein
@@ -0,0 +1,185 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: configdev.fig
+%%Creator: fig2dev Version 3.1 Patchlevel 1
+%%CreationDate: Mon Jun 15 17:35:19 1998
+%%For: ian@tito.cygnus.com (Ian Lance Taylor)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 344 317
+%%Pages: 0
+%%BeginSetup
+%%IncludeFeature: *PageSize Letter
+%%EndSetup
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {} def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-62.0 370.0 translate
+1 -1 scale
+
+/clp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+ 0.06000 0.06000 sc
+7.500 slw
+% Polyline
+n 1050 900 m 2100 900 l 2100 1425 l 1050 1425 l clp gs col-1 s gr
+% Polyline
+n 2925 900 m 3975 900 l 3975 1425 l 2925 1425 l clp gs col-1 s gr
+% Polyline
+n 5550 900 m 6750 900 l 6750 1350 l 5550 1350 l clp gs col-1 s gr
+% Polyline
+n 3750 1800 m 5025 1800 l 5025 2250 l 3750 2250 l clp gs col-1 s gr
+% Polyline
+n 1155 2100 m 1050 2100 1050 2520 105 arcto 4 {pop} repeat 1050 2625 2070 2625 105 arcto 4 {pop} repeat 2175 2625 2175 2205 105 arcto 4 {pop} repeat 2175 2100 1155 2100 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 5550 3300 m 6675 3300 l 6675 3750 l 5550 3750 l clp gs col-1 s gr
+% Polyline
+n 5655 2100 m 5550 2100 5550 2520 105 arcto 4 {pop} repeat 5550 2625 6495 2625 105 arcto 4 {pop} repeat 6600 2625 6600 2205 105 arcto 4 {pop} repeat 6600 2100 5655 2100 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 3750 3600 m 4875 3600 l 4875 4050 l 3750 4050 l clp gs col-1 s gr
+% Polyline
+n 3855 2700 m 3750 2700 3750 3045 105 arcto 4 {pop} repeat 3750 3150 4545 3150 105 arcto 4 {pop} repeat 4650 3150 4650 2805 105 arcto 4 {pop} repeat 4650 2700 3855 2700 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 2850 5700 m 3750 5700 l 3750 6150 l 2850 6150 l clp gs col-1 s gr
+% Polyline
+n 3030 4800 m 2925 4800 2925 5145 105 arcto 4 {pop} repeat 2925 5250 3645 5250 105 arcto 4 {pop} repeat 3750 5250 3750 4905 105 arcto 4 {pop} repeat 3750 4800 3030 4800 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 1500 1425 m 1500 2100 l gs col-1 s gr
+n 1530.00 1980.00 m 1500.00 2100.00 l 1470.00 1980.00 l 1500.50 1980.50 l 1530.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 3300 1425 m 3300 4800 l gs col-1 s gr
+n 3330.00 4680.00 m 3300.00 4800.00 l 3270.00 4680.00 l 3300.50 4680.50 l 3330.00 4680.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 3300 1575 m 1875 1575 l 1875 2100 l gs col-1 s gr
+n 1905.00 1980.00 m 1875.00 2100.00 l 1845.00 1980.00 l 1875.50 1980.50 l 1905.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 3300 1575 m 5700 1575 l 5700 2100 l gs col-1 s gr
+n 5730.00 1980.00 m 5700.00 2100.00 l 5670.00 1980.00 l 5700.50 1980.50 l 5730.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 6225 1350 m 6225 2100 l gs col-1 s gr
+n 6255.00 1980.00 m 6225.00 2100.00 l 6195.00 1980.00 l 6225.50 1980.50 l 6255.00 1980.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 6075 2625 m 6075 3300 l gs col-1 s gr
+n 6105.00 3180.00 m 6075.00 3300.00 l 6045.00 3180.00 l 6075.50 3180.50 l 6105.00 3180.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 4200 2250 m 4200 2700 l gs col-1 s gr
+n 4230.00 2580.00 m 4200.00 2700.00 l 4170.00 2580.00 l 4200.50 2580.50 l 4230.00 2580.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 4200 3150 m 4200 3600 l gs col-1 s gr
+n 4230.00 3480.00 m 4200.00 3600.00 l 4170.00 3480.00 l 4200.50 3480.50 l 4230.00 3480.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 4200 4050 m 4200 4500 l 3675 4500 l 3675 4800 l gs col-1 s gr
+n 3705.00 4680.00 m 3675.00 4800.00 l 3645.00 4680.00 l 3675.50 4680.50 l 3705.00 4680.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 3375 5250 m 3375 5700 l gs col-1 s gr
+n 3405.00 5580.00 m 3375.00 5700.00 l 3345.00 5580.00 l 3375.50 5580.50 l 3405.00 5580.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 3300 2925 m 3750 2925 l gs col-1 s gr
+n 3630.00 2895.00 m 3750.00 2925.00 l 3630.00 2955.00 l 3630.50 2925.50 l 3630.00 2895.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 1500 2625 m 1500 3300 l gs col-1 s gr
+n 1530.00 3180.00 m 1500.00 3300.00 l 1470.00 3180.00 l 1500.50 3180.50 l 1530.00 3180.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+% Polyline
+n 1050 3300 m 2100 3300 l 2100 3750 l 1050 3750 l clp gs col-1 s gr
+% Polyline
+n 4875 3825 m 5250 3825 l 5250 2400 l 5550 2400 l gs col-1 s gr
+n 5430.00 2370.00 m 5550.00 2400.00 l 5430.00 2430.00 l 5430.50 2400.50 l 5430.00 2370.00 l clp gs 0.00 setgray ef gr gs col-1 s gr
+/Times-Roman findfont 180.00 scalefont setfont
+1200 1200 m
+gs 1 -1 sc (acconfig.h) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3000 1200 m
+gs 1 -1 sc (configure.in) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+5700 1200 m
+gs 1 -1 sc (Makefile.am) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3900 2100 m
+gs 1 -1 sc (acinclude.m4) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+1200 2400 m
+gs 1 -1 sc (autoheader) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+1200 3600 m
+gs 1 -1 sc (config.in) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+5700 3600 m
+gs 1 -1 sc (Makefile.in) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+5700 2400 m
+gs 1 -1 sc (automake) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3900 3900 m
+gs 1 -1 sc (aclocal.m4) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3900 3000 m
+gs 1 -1 sc (aclocal) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3000 6000 m
+gs 1 -1 sc (configure) col-1 show gr
+/Times-Roman findfont 180.00 scalefont setfont
+3000 5100 m
+gs 1 -1 sc (autoconf) col-1 show gr
+$F2psEnd
+restore
diff --git a/etc/configdev.fig b/etc/configdev.fig
new file mode 100644
index 00000000000..4d386ec4ff7
--- /dev/null
+++ b/etc/configdev.fig
@@ -0,0 +1,80 @@
+#FIG 3.1
+Portrait
+Center
+Inches
+1200 2
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 1050 900 2100 900 2100 1425 1050 1425 1050 900
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 2925 900 3975 900 3975 1425 2925 1425 2925 900
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 5550 900 6750 900 6750 1350 5550 1350 5550 900
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 3750 1800 5025 1800 5025 2250 3750 2250 3750 1800
+2 4 0 1 -1 7 0 0 -1 0.000 0 0 7 0 0 5
+ 2175 2625 2175 2100 1050 2100 1050 2625 2175 2625
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 5550 3300 6675 3300 6675 3750 5550 3750 5550 3300
+2 4 0 1 -1 7 0 0 -1 0.000 0 0 7 0 0 5
+ 6600 2625 6600 2100 5550 2100 5550 2625 6600 2625
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 3750 3600 4875 3600 4875 4050 3750 4050 3750 3600
+2 4 0 1 -1 7 0 0 -1 0.000 0 0 7 0 0 5
+ 4650 3150 4650 2700 3750 2700 3750 3150 4650 3150
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 2850 5700 3750 5700 3750 6150 2850 6150 2850 5700
+2 4 0 1 -1 7 0 0 -1 0.000 0 0 7 0 0 5
+ 3750 5250 3750 4800 2925 4800 2925 5250 3750 5250
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 1500 1425 1500 2100
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3300 1425 3300 4800
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 3
+ 1 1 1.00 60.00 120.00
+ 3300 1575 1875 1575 1875 2100
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 3
+ 1 1 1.00 60.00 120.00
+ 3300 1575 5700 1575 5700 2100
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 6225 1350 6225 2100
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 6075 2625 6075 3300
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 4200 2250 4200 2700
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 4200 3150 4200 3600
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 4
+ 1 1 1.00 60.00 120.00
+ 4200 4050 4200 4500 3675 4500 3675 4800
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3375 5250 3375 5700
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3300 2925 3750 2925
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 1500 2625 1500 3300
+2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
+ 1050 3300 2100 3300 2100 3750 1050 3750 1050 3300
+2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 4
+ 1 1 1.00 60.00 120.00
+ 4875 3825 5250 3825 5250 2400 5550 2400
+4 0 -1 0 0 0 12 0.0000000 4 180 780 1200 1200 acconfig.h\001
+4 0 -1 0 0 0 12 0.0000000 4 180 885 3000 1200 configure.in\001
+4 0 -1 0 0 0 12 0.0000000 4 135 945 5700 1200 Makefile.am\001
+4 0 -1 0 0 0 12 0.0000000 4 135 990 3900 2100 acinclude.m4\001
+4 0 -1 0 0 0 12 0.0000000 4 135 840 1200 2400 autoheader\001
+4 0 -1 0 0 0 12 0.0000000 4 180 645 1200 3600 config.in\001
+4 0 -1 0 0 0 12 0.0000000 4 135 855 5700 3600 Makefile.in\001
+4 0 -1 0 0 0 12 0.0000000 4 135 735 5700 2400 automake\001
+4 0 -1 0 0 0 12 0.0000000 4 135 810 3900 3900 aclocal.m4\001
+4 0 -1 0 0 0 12 0.0000000 4 135 540 3900 3000 aclocal\001
+4 0 -1 0 0 0 12 0.0000000 4 180 705 3000 6000 configure\001
+4 0 -1 0 0 0 12 0.0000000 4 135 660 3000 5100 autoconf\001
diff --git a/etc/configdev.jin b/etc/configdev.jin
new file mode 100644
index 00000000000..9b11a71acd7
--- /dev/null
+++ b/etc/configdev.jin
Binary files differ
diff --git a/etc/configdev.tin b/etc/configdev.tin
new file mode 100644
index 00000000000..c9b6f34f4d7
--- /dev/null
+++ b/etc/configdev.tin
@@ -0,0 +1,17 @@
+ acconfig.h configure.in Makefile.am
+ | | |
+ | --------------+---------------------- |
+ | | | | |
+ v v | acinclude.m4 | |
+ *autoheader* | | v v
+ | | v --->*automake*
+ v |--->*aclocal* | |
+ config.in | | | v
+ | v | Makefile.in
+ | aclocal.m4---
+ | |
+ v v
+ *autoconf*
+ |
+ v
+ configure
diff --git a/etc/configure b/etc/configure
new file mode 100755
index 00000000000..101fcefecfc
--- /dev/null
+++ b/etc/configure
@@ -0,0 +1,862 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.12.1
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.12.1"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=Makefile.in
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:555: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set) 2>&1 | grep ac_space` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.12.1"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/etc/configure.in b/etc/configure.in
new file mode 100644
index 00000000000..b785068009e
--- /dev/null
+++ b/etc/configure.in
@@ -0,0 +1,7 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.5)
+AC_INIT(Makefile.in)
+
+AC_PROG_INSTALL
+
+AC_OUTPUT(Makefile)
diff --git a/etc/configure.texi b/etc/configure.texi
new file mode 100644
index 00000000000..91401671f92
--- /dev/null
+++ b/etc/configure.texi
@@ -0,0 +1,2644 @@
+\input texinfo
+@c %**start of header
+@setfilename configure.info
+@settitle The GNU configure and build system
+@setchapternewpage off
+@c %**end of header
+
+@dircategory GNU admin
+@direntry
+* configure: (configure). The GNU configure and build system
+@end direntry
+
+@ifinfo
+This file documents the GNU configure and build system.
+
+Copyright (C) 1998 Cygnus Solutions.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+
+
+@end ignore
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Foundation.
+@end ifinfo
+
+@titlepage
+@title The GNU configure and build system
+@author Ian Lance Taylor
+
+@page
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1998 Cygnus Solutions
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation
+approved by the Free Software Foundation.
+@end titlepage
+
+@ifinfo
+@node Top
+@top GNU configure and build system
+
+The GNU configure and build system.
+
+@menu
+* Introduction:: Introduction.
+* Getting Started:: Getting Started.
+* Files:: Files.
+* Configuration Names:: Configuration Names.
+* Cross Compilation Tools:: Cross Compilation Tools.
+* Canadian Cross:: Canadian Cross.
+* Cygnus Configure:: Cygnus Configure.
+* Multilibs:: Multilibs.
+* FAQ:: Frequently Asked Questions.
+* Index:: Index.
+@end menu
+
+@end ifinfo
+
+@node Introduction
+@chapter Introduction
+
+This document describes the GNU configure and build systems. It
+describes how autoconf, automake, libtool, and make fit together. It
+also includes a discussion of the older Cygnus configure system.
+
+This document does not describe in detail how to use each of the tools;
+see the respective manuals for that. Instead, it describes which files
+the developer must write, which files are machine generated and how they
+are generated, and where certain common problems should be addressed.
+
+@ifnothtml
+This document draws on several sources, including the autoconf manual by
+David MacKenzie (@pxref{Top, , autoconf overview, autoconf, Autoconf}),
+the automake manual by David MacKenzie and Tom Tromey (@pxref{Top, ,
+automake overview, automake, GNU Automake}), the libtool manual by
+Gordon Matzigkeit (@pxref{Top, , libtool overview, libtool, GNU
+libtool}), and the Cygnus configure manual by K. Richard Pixley.
+@end ifnothtml
+@ifhtml
+This document draws on several sources, including
+@uref{http://www.delorie.com/gnu/docs/autoconf/autoconf_toc.html, the
+autoconf manual} by David MacKenzie,
+@uref{http://www.delorie.com/gnu/docs/automake/automake_toc.html, the
+automake manual} by David MacKenzie and Tom Tromey,
+@uref{http://www.delorie.com/gnu/docs/libtool/libtool_toc.html, the
+libtool manual} by Gordon Matzigkeit, and the Cygnus configure manual by
+K. Richard Pixley.
+@end ifhtml
+
+@menu
+* Goals:: Goals.
+* Tools:: The tools.
+* History:: History.
+* Building:: Building.
+@end menu
+
+@node Goals
+@section Goals
+@cindex goals
+
+The GNU configure and build system has two main goals.
+
+The first is to simplify the development of portable programs. The
+system permits the developer to concentrate on writing the program,
+simplifying many details of portability across Unix and even Windows
+systems, and permitting the developer to describe how to build the
+program using simple rules rather than complex Makefiles.
+
+The second is to simplify the building of programs distributed as source
+code. All programs are built using a simple, standardized, two step
+process. The program builder need not install any special tools in
+order to build the program.
+
+@node Tools
+@section Tools
+
+The GNU configure and build system is comprised of several different
+tools. Program developers must build and install all of these tools.
+
+People who just want to build programs from distributed sources normally
+do not need any special tools beyond a Unix shell, a make program, and a
+C compiler.
+
+@table @asis
+@item autoconf
+provides a general portability framework, based on testing the features
+of the host system at build time.
+@item automake
+a system for describing how to build a program, permitting the developer
+to write a simplified @file{Makefile}.
+@item libtool
+a standardized approach to building shared libraries.
+@item gettext
+provides a framework for translation of text messages into other
+languages; not really discussed in this document.
+@item m4
+autoconf requires the GNU version of m4; the standard Unix m4 does not
+suffice.
+@item perl
+automake requires perl.
+@end table
+
+@node History
+@section History
+@cindex history
+
+This is a very brief and probably inaccurate history.
+
+As the number of Unix variants increased during the 1980s, it became
+harder to write programs which could run on all variants. While it was
+often possible to use @code{#ifdef} to identify particular systems,
+developers frequently did not have access to every system, and the
+characteristics of some systems changed from version to version.
+
+By 1992, at least three different approaches had been developed:
+@itemize @bullet
+@item
+The Metaconfig program, by Larry Wall, Harlan Stenn, and Raphael
+Manfredi.
+@item
+The Cygnus configure script, by K. Richard Pixley, and the gcc configure
+script, by Richard Stallman. These use essentially the same approach,
+and the developers communicated regularly.
+@item
+The autoconf program, by David MacKenzie.
+@end itemize
+
+The Metaconfig program is still used for Perl and a few other programs.
+It is part of the Dist package. I do not know if it is being developed.
+
+In 1994, David MacKenzie and others modified autoconf to incorporate all
+the features of Cygnus configure. Since then, there has been a slow but
+steady conversion of GNU programs from Cygnus configure to autoconf. gcc
+has been converted, eliminating the gcc configure script.
+
+GNU autoconf was regularly maintained until late 1996. As of this
+writing in June, 1998, it has no public maintainer.
+
+Most programs are built using the make program, which requires the
+developer to write Makefiles describing how to build the programs.
+Since most programs are built in pretty much the same way, this led to a
+lot of duplication.
+
+The X Window system is built using the imake tool, which uses a database
+of rules to eliminate the duplication. However, building a tool which
+was developed using imake requires that the builder have imake
+installed, violating one of the goals of the GNU system.
+
+The new BSD make provides a standard library of Makefile fragments,
+which permits developers to write very simple Makefiles. However, this
+requires that the builder install the new BSD make program.
+
+In 1994, David MacKenzie wrote the first version of automake, which
+permitted writing a simple build description which was converted into a
+Makefile which could be used by the standard make program. In 1995, Tom
+Tromey completely rewrote automake in Perl, and he continues to enhance
+it.
+
+Various free packages built libraries, and by around 1995 several
+included support to build shared libraries on various platforms.
+However, there was no consistent approach. In early 1996, Gordon
+Matzigkeit began working on libtool, which provided a standardized
+approach to building shared libraries. This was integrated into
+automake from the start.
+
+The development of automake and libtool was driven by the GNITS project,
+a group of GNU maintainers who designed standardized tools to help meet
+the GNU coding standards.
+
+@node Building
+@section Building
+
+Most readers of this document should already know how to build a tool by
+running @samp{configure} and @samp{make}. This section may serve as a
+quick introduction or reminder.
+
+Building a tool is normally as simple as running @samp{configure}
+followed by @samp{make}. You should normally run @samp{configure} from
+an empty directory, using some path to refer to the @samp{configure}
+script in the source directory. The directory in which you run
+@samp{configure} is called the @dfn{object directory}.
+
+In order to use a object directory which is different from the source
+directory, you must be using the GNU version of @samp{make}, which has
+the required @samp{VPATH} support. Despite this restriction, using a
+different object directory is highly recommended:
+@itemize @bullet
+@item
+It keeps the files generated during the build from cluttering up your
+sources.
+@item
+It permits you to remove the built files by simply removing the entire
+build directory.
+@item
+It permits you to build from the same sources with several sets of
+configure options simultaneously.
+@end itemize
+
+If you don't have GNU @samp{make}, you will have to run @samp{configure}
+in the source directory. All GNU packages should support this; in
+particular, GNU packages should not assume the presence of GNU
+@samp{make}.
+
+After running @samp{configure}, you can build the tools by running
+@samp{make}.
+
+To install the tools, run @samp{make install}. Installing the tools
+will copy the programs and any required support files to the
+@dfn{installation directory}. The location of the installation
+directory is controlled by @samp{configure} options, as described below.
+
+In the Cygnus tree at present, the info files are built and installed as
+a separate step. To build them, run @samp{make info}. To install them,
+run @samp{make install-info}.
+
+All @samp{configure} scripts support a wide variety of options. The
+most interesting ones are @samp{--with} and @samp{--enable} options
+which are generally specific to particular tools. You can usually use
+the @samp{--help} option to get a list of interesting options for a
+particular configure script.
+
+The only generic options you are likely to use are the @samp{--prefix}
+and @samp{--exec-prefix} options. These options are used to specify the
+installation directory.
+
+The directory named by the @samp{--prefix} option will hold machine
+independent files such as info files.
+
+The directory named by the @samp{--exec-prefix} option, which is
+normally a subdirectory of the @samp{--prefix} directory, will hold
+machine dependent files such as executables.
+
+The default for @samp{--prefix} is @file{/usr/local}. The default for
+@samp{--exec-prefix} is the value used for @samp{--prefix}.
+
+The convention used in Cygnus releases is to use a @samp{--prefix}
+option of @file{/usr/cygnus/@var{release}}, where @var{release} is the
+name of the release, and to use a @samp{--exec-prefix} option of
+@file{/usr/cygnus/@var{release}/H-@var{host}}, where @var{host} is the
+configuration name of the host system (@pxref{Configuration Names}).
+
+Do not use either the source or the object directory as the installation
+directory. That will just lead to confusion.
+
+@node Getting Started
+@chapter Getting Started
+
+To start using the GNU configure and build system with your software
+package, you must write three files, and you must run some tools to
+manually generate additional files.
+
+@menu
+* Write configure.in:: Write configure.in.
+* Write Makefile.am:: Write Makefile.am.
+* Write acconfig.h:: Write acconfig.h.
+* Generate files:: Generate files.
+* Getting Started Example:: Example.
+@end menu
+
+@node Write configure.in
+@section Write configure.in
+@cindex @file{configure.in}, writing
+
+You must first write the file @file{configure.in}. This is an autoconf
+input file, and the autoconf manual describes in detail what this file
+should look like.
+
+You will write tests in your @file{configure.in} file to check for
+conditions that may change from one system to another, such as the
+presence of particular header files or functions.
+
+For example, not all systems support the @samp{gettimeofday} function.
+If you want to use the @samp{gettimeofday} function when it is
+available, and to use some other function when it is not, you would
+check for this by putting @samp{AC_CHECK_FUNCS(gettimeofday)} in
+@file{configure.in}.
+
+When the configure script is run at build time, this will arrange to
+define the preprocessor macro @samp{HAVE_GETTIMEOFDAY} to the value 1 if
+the @samp{gettimeofday} function is available, and to not define the
+macro at all if the function is not available. Your code can then use
+@samp{#ifdef} to test whether it is safe to call @samp{gettimeofday}.
+
+If you have an existing body of code, the @samp{autoscan} program may
+help identify potential portability problems, and hence configure tests
+that you will want to use.
+@ifnothtml
+@xref{Invoking autoscan, , , autoconf, the autoconf manual}.
+@end ifnothtml
+@ifhtml
+See @uref{http://www.delorie.com/gnu/docs/autoconf/autoconf_4.html, the
+autoscan documentation}.
+@end ifhtml
+
+Another handy tool for an existing body of code is @samp{ifnames}. This
+will show you all the preprocessor conditionals that the code already
+uses.
+@ifnothtml
+@xref{Invoking ifnames, , , autoconf, the autoconf manual}.
+@end ifnothtml
+@ifhtml
+See @uref{http://www.delorie.com/gnu/docs/autoconf/autoconf_5.html, the
+ifnames documentation}.
+@end ifhtml
+
+Besides the portability tests which are specific to your particular
+package, every @file{configure.in} file should contain the following
+macros.
+
+@table @samp
+@item AC_INIT
+@cindex @samp{AC_INIT}
+This macro takes a single argument, which is the name of a file in your
+package. For example, @samp{AC_INIT(foo.c)}.
+
+@item AC_PREREQ(@var{VERSION})
+@cindex @samp{AC_PREREQ}
+This macro is optional. It may be used to indicate the version of
+@samp{autoconf} that you are using. This will prevent users from
+running an earlier version of @samp{autoconf} and perhaps getting an
+invalid @file{configure} script. For example, @samp{AC_PREREQ(2.12)}.
+
+@item AM_INIT_AUTOMAKE
+@cindex @samp{AM_INIT_AUTOMAKE}
+This macro takes two arguments: the name of the package, and a version
+number. For example, @samp{AM_INIT_AUTOMAKE(foo, 1.0)}. (This macro is
+not needed if you are not using automake).
+
+@item AM_CONFIG_HEADER
+@cindex @samp{AM_CONFIG_HEADER}
+This macro names the header file which will hold the preprocessor macro
+definitions at run time. Normally this should be @file{config.h}. Your
+sources would then use @samp{#include "config.h"} to include it.
+
+This macro may optionally name the input file for that header file; by
+default, this is @file{config.h.in}, but that file name works poorly on
+DOS filesystems. Therefore, it is often better to name it explicitly as
+@file{config.in}.
+
+This is what you should normally put in @file{configure.in}:
+@example
+AM_CONFIG_HEADER(config.h:config.in)
+@end example
+
+@cindex @samp{AC_CONFIG_HEADER}
+(If you are not using automake, use @samp{AC_CONFIG_HEADER} rather than
+@samp{AM_CONFIG_HEADER}).
+
+@item AM_MAINTAINER_MODE
+@cindex @samp{AM_MAINTAINER_MODE}
+This macro always appears in Cygnus configure scripts. Other programs
+may or may not use it.
+
+If this macro is used, the @samp{--enable-maintainer-mode} option is
+required to enable automatic rebuilding of generated files used by the
+configure system. This of course requires that developers be aware of,
+and use, that option.
+
+If this macro is not used, then the generated files will always be
+rebuilt automatically. This will cause problems if the wrong versions
+of autoconf, automake, or others are in the builder's @samp{PATH}.
+
+(If you are not using automake, you do not need to use this macro).
+
+@item AC_EXEEXT
+@cindex @samp{AC_EXEEXT}
+@cindex @samp{AM_EXEEXT}
+Either this macro or @samp{AM_EXEEXT} always appears in Cygnus configure
+files. Other programs may or may not use one of them.
+
+This macro looks for the executable suffix used on the host system. On
+Unix systems, this is the empty string. On Windows systems, this is
+@samp{.exe}. This macro directs automake to use the executable suffix
+as appropriate when creating programs. This macro does not take any
+arguments.
+
+The @samp{AC_EXEEXT} form is new, and is part of a Cygnus patch to
+autoconf to support compiling with Visual C++. Older programs use
+@samp{AM_EXEEXT} instead.
+
+(Programs which do not use automake use neither @samp{AC_EXEEXT} nor
+@samp{AM_EXEEXT}).
+
+@item AC_PROG_CC
+@cindex @samp{AC_PROG_CC}
+If you are writing C code, you will normally want to use this macro. It
+locates the C compiler to use. It does not take any arguments.
+
+However, if this @file{configure.in} file is for a library which is to
+be compiled by a cross compiler which may not fully work, then you will
+not want to use @samp{AC_PROG_CC}. Instead, you will want to use a
+variant which does not call the macro @samp{AC_PROG_CC_WORKS}. Examples
+can be found in various @file{configure.in} files for libraries that are
+compiled with cross compilers, such as libiberty or libgloss. This is
+essentially a bug in autoconf, and there will probably be a better
+workaround at some point.
+
+@item AC_PROG_CXX
+@cindex @samp{AC_PROG_CXX}
+If you are writing C++ code, you will want to use this macro. It
+locates the C++ compiler to use. It does not take any arguments. The
+same cross compiler comments apply as for @samp{AC_PROG_CC}.
+
+@item AM_PROG_LIBTOOL
+@cindex @samp{AM_PROG_LIBTOOL}
+If you want to build libraries, and you want to permit them to be
+shared, or you want to link against libraries which were built using
+libtool, then you will need this macro. This macro is required in order
+to use libtool.
+
+@cindex @samp{AM_DISABLE_SHARED}
+By default, this will cause all libraries to be built as shared
+libraries. To prevent this--to change the default--use
+@samp{AM_DISABLE_SHARED} before @samp{AM_PROG_LIBTOOL}. The configure
+options @samp{--enable-shared} and @samp{--disable-shared} may be used
+to override the default at build time.
+
+@item AC_DEFINE(_GNU_SOURCE)
+@cindex @samp{_GNU_SOURCE}
+GNU packages should normally include this line before any other feature
+tests. This defines the macro @samp{_GNU_SOURCE} when compiling, which
+directs the libc header files to provide the standard GNU system
+interfaces including all GNU extensions. If this macro is not defined,
+certain GNU extensions may not be available.
+
+@item AC_OUTPUT
+@cindex @samp{AC_OUTPUT}
+This macro takes a list of file names which the configure process should
+produce. This is normally a list of one or more @file{Makefile} files
+in different directories. If your package lives entirely in a single
+directory, you would use simply @samp{AC_OUTPUT(Makefile)}. If you also
+have, for example, a @file{lib} subdirectory, you would use
+@samp{AC_OUTPUT(Makefile lib/Makefile)}.
+@end table
+
+If you want to use locally defined macros in your @file{configure.in}
+file, then you will need to write a @file{acinclude.m4} file which
+defines them (if not using automake, this file is called
+@file{aclocal.m4}). Alternatively, you can put separate macros in an
+@file{m4} subdirectory, and put @samp{ACLOCAL_AMFLAGS = -I m4} in your
+@file{Makefile.am} file so that the @samp{aclocal} program will be able
+to find them.
+
+The different macro prefixes indicate which tool defines the macro.
+Macros which start with @samp{AC_} are part of autoconf. Macros which
+start with @samp{AM_} are provided by automake or libtool.
+
+@node Write Makefile.am
+@section Write Makefile.am
+@cindex @file{Makefile.am}, writing
+
+You must write the file @file{Makefile.am}. This is an automake input
+file, and the automake manual describes in detail what this file should
+look like.
+
+The automake commands in @file{Makefile.am} mostly look like variable
+assignments in a @file{Makefile}. automake recognizes special variable
+names, and automatically add make rules to the output as needed.
+
+There will be one @file{Makefile.am} file for each directory in your
+package. For each directory with subdirectories, the @file{Makefile.am}
+file should contain the line
+@smallexample
+SUBDIRS = @var{dir} @var{dir} @dots{}
+@end smallexample
+@noindent
+where each @var{dir} is the name of a subdirectory.
+
+For each @file{Makefile.am}, there should be a corresponding
+@file{Makefile} in the @samp{AC_OUTPUT} macro in @file{configure.in}.
+
+Every @file{Makefile.am} written at Cygnus should contain the line
+@smallexample
+AUTOMAKE_OPTIONS = cygnus
+@end smallexample
+@noindent
+This puts automake into Cygnus mode. See the automake manual for
+details.
+
+You may to include the version number of @samp{automake} that you are
+using on the @samp{AUTOMAKE_OPTIONS} line. For example,
+@smallexample
+AUTOMAKE_OPTIONS = cygnus 1.3
+@end smallexample
+@noindent
+This will prevent users from running an earlier version of
+@samp{automake} and perhaps getting an invalid @file{Makefile.in}.
+
+If your package builds a program, then in the directory where that
+program is built you will normally want a line like
+@smallexample
+bin_PROGRAMS = @var{program}
+@end smallexample
+@noindent
+where @var{program} is the name of the program. You will then want a
+line like
+@smallexample
+@var{program}_SOURCES = @var{file} @var{file} @dots{}
+@end smallexample
+@noindent
+where each @var{file} is the name of a source file to link into the
+program (e.g., @samp{foo.c}).
+
+If your package builds a library, and you do not want the library to
+ever be built as a shared library, then in the directory where that
+library is built you will normally want a line like
+@smallexample
+lib_LIBRARIES = lib@var{name}.a
+@end smallexample
+@noindent
+where @samp{lib@var{name}.a} is the name of the library. You will then
+want a line like
+@smallexample
+lib@var{name}_a_SOURCES = @var{file} @var{file} @dots{}
+@end smallexample
+@noindent
+where each @var{file} is the name of a source file to add to the
+library.
+
+If your package builds a library, and you want to permit building the
+library as a shared library, then in the directory where that library is
+built you will normally want a line like
+@smallexample
+lib_LTLIBRARIES = lib@var{name}.la
+@end smallexample
+The use of @samp{LTLIBRARIES}, and the @samp{.la} extension, indicate a
+library to be built using libtool. As usual, you will then want a line
+like
+@smallexample
+lib@var{name}_la_SOURCES = @var{file} @var{file} @dots{}
+@end smallexample
+
+The strings @samp{bin} and @samp{lib} that appear above in
+@samp{bin_PROGRAMS} and @samp{lib_LIBRARIES} are not arbitrary. They
+refer to particular directories, which may be set by the @samp{--bindir}
+and @samp{--libdir} options to @file{configure}. If those options are
+not used, the default values are based on the @samp{--prefix} or
+@samp{--exec-prefix} options to @file{configure}. It is possible to use
+other names if the program or library should be installed in some other
+directory.
+
+The @file{Makefile.am} file may also contain almost anything that may
+appear in a normal @file{Makefile}. automake also supports many other
+special variables, as well as conditionals.
+
+See the automake manual for more information.
+
+@node Write acconfig.h
+@section Write acconfig.h
+@cindex @file{acconfig.h}, writing
+
+If you are generating a portability header file, (i.e., you are using
+@samp{AM_CONFIG_HEADER} in @file{configure.in}), then you will have to
+write a @file{acconfig.h} file. It will have to contain the following
+lines.
+
+@smallexample
+/* Name of package. */
+#undef PACKAGE
+
+/* Version of package. */
+#undef VERSION
+@end smallexample
+
+This requirement is really a bug in the system, and the requirement may
+be eliminated at some later date.
+
+The @file{acconfig.h} file will also similar comment and @samp{#undef}
+lines for any unusual macros in the @file{configure.in} file, including
+any macro which appears in a @samp{AC_DEFINE} macro.
+
+In particular, if you are writing a GNU package and therefore include
+@samp{AC_DEFINE(_GNU_SOURCE)} in @file{configure.in} as suggested above,
+you will need lines like this in @file{acconfig.h}:
+@smallexample
+/* Enable GNU extensions. */
+#undef _GNU_SOURCE
+@end smallexample
+
+Normally the @samp{autoheader} program will inform you of any such
+requirements by printing an error message when it is run. However, if
+you do anything particular odd in your @file{configure.in} file, you
+will have to make sure that the right entries appear in
+@file{acconfig.h}, since otherwise the results of the tests may not be
+available in the @file{config.h} file which your code will use.
+
+(Thee @samp{PACKAGE} and @samp{VERSION} lines are not required if you
+are not using automake, and in that case you may not need a
+@file{acconfig.h} file at all).
+
+@node Generate files
+@section Generate files
+
+Once you have written @file{configure.in}, @file{Makefile.am},
+@file{acconfig.h}, and possibly @file{acinclude.m4}, you must use
+autoconf and automake programs to produce the first versions of the
+generated files. This is done by executing the following sequence of
+commands.
+
+@smallexample
+aclocal
+autoconf
+autoheader
+automake
+@end smallexample
+
+The @samp{aclocal} and @samp{automake} commands are part of the automake
+package, and the @samp{autoconf} and @samp{autoheader} commands are part
+of the autoconf package.
+
+If you are using a @file{m4} subdirectory for your macros, you will need
+to use the @samp{-I m4} option when you run @samp{aclocal}.
+
+If you are not using the Cygnus tree, use the @samp{-a} option when
+running @samp{automake} command in order to copy the required support
+files into your source directory.
+
+If you are using libtool, you must build and install the libtool package
+with the same @samp{--prefix} and @samp{--exec-prefix} options as you
+used with the autoconf and automake packages. You must do this before
+running any of the above commands. If you are not using the Cygnus
+tree, you will need to run the @samp{libtoolize} program to copy the
+libtool support files into your directory.
+
+Once you have managed to run these commands without getting any errors,
+you should create a new empty directory, and run the @samp{configure}
+script which will have been created by @samp{autoconf} with the
+@samp{--enable-maintainer-mode} option. This will give you a set of
+Makefiles which will include rules to automatically rebuild all the
+generated files.
+
+After doing that, whenever you have changed some of the input files and
+want to regenerated the other files, go to your object directory and run
+@samp{make}. Doing this is more reliable than trying to rebuild the
+files manually, because there are complex order dependencies and it is
+easy to forget something.
+
+@node Getting Started Example
+@section Example
+
+Let's consider a trivial example.
+
+Suppose we want to write a simple version of @samp{touch}. Our program,
+which we will call @samp{poke}, will take a single file name argument,
+and use the @samp{utime} system call to set the modification and access
+times of the file to the current time. We want this program to be
+highly portable.
+
+We'll first see what this looks like without using autoconf and
+automake, and then see what it looks like with them.
+
+@menu
+* Getting Started Example 1:: First Try.
+* Getting Started Example 2:: Second Try.
+* Getting Started Example 3:: Third Try.
+* Generate Files in Example:: Generate Files.
+@end menu
+
+@node Getting Started Example 1
+@subsection First Try
+
+Here is our first try at @samp{poke.c}. Note that we've written it
+without ANSI/ISO C prototypes, since we want it to be highly portable.
+
+@example
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <utime.h>
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+@{
+ if (argc != 2)
+ @{
+ fprintf (stderr, "Usage: poke file\n");
+ exit (1);
+ @}
+
+ if (utime (argv[1], NULL) < 0)
+ @{
+ perror ("utime");
+ exit (1);
+ @}
+
+ exit (0);
+@}
+@end example
+
+We also write a simple @file{Makefile}.
+
+@example
+CC = gcc
+CFLAGS = -g -O2
+
+all: poke
+
+poke: poke.o
+ $(CC) -o poke $(CFLAGS) $(LDFLAGS) poke.o
+@end example
+
+So far, so good.
+
+Unfortunately, there are a few problems.
+
+On older Unix systems derived from BSD 4.3, the @samp{utime} system call
+does not accept a second argument of @samp{NULL}. On those systems, we
+need to pass a pointer to @samp{struct utimbuf} structure.
+Unfortunately, even older systems don't define that structure; on those
+systems, we need to pass an array of two @samp{long} values.
+
+The header file @file{stdlib.h} was invented by ANSI C, and older
+systems don't have a copy. We included it above to get a declaration of
+@samp{exit}.
+
+We can find some of these portability problems by running
+@samp{autoscan}, which will create a @file{configure.scan} file which we
+can use as a prototype for our @file{configure.in} file. I won't show
+the output, but it will notice the potential problems with @samp{utime}
+and @file{stdlib.h}.
+
+In our @file{Makefile}, we don't provide any way to install the program.
+This doesn't matter much for such a simple example, but a real program
+will need an @samp{install} target. For that matter, we will also want
+a @samp{clean} target.
+
+@node Getting Started Example 2
+@subsection Second Try
+
+Here is our second try at this program.
+
+We modify @file{poke.c} to use preprocessor macros to control what
+features are available. (I've cheated a bit by using the same macro
+names which autoconf will use).
+
+@example
+#include <stdio.h>
+
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+#include <sys/types.h>
+
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+
+#ifndef HAVE_UTIME_NULL
+
+#include <time.h>
+
+#ifndef HAVE_STRUCT_UTIMBUF
+
+struct utimbuf
+@{
+ long actime;
+ long modtime;
+@};
+
+#endif
+
+static int
+utime_now (file)
+ char *file;
+@{
+ struct utimbuf now;
+
+ now.actime = now.modtime = time (NULL);
+ return utime (file, &now);
+@}
+
+#define utime(f, p) utime_now (f)
+
+#endif /* HAVE_UTIME_NULL */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+@{
+ if (argc != 2)
+ @{
+ fprintf (stderr, "Usage: poke file\n");
+ exit (1);
+ @}
+
+ if (utime (argv[1], NULL) < 0)
+ @{
+ perror ("utime");
+ exit (1);
+ @}
+
+ exit (0);
+@}
+@end example
+
+Here is the associated @file{Makefile}. We've added support for the
+preprocessor flags we use. We've also added @samp{install} and
+@samp{clean} targets.
+
+@example
+# Set this to your installation directory.
+bindir = /usr/local/bin
+
+# Uncomment this if you have the standard ANSI/ISO C header files.
+# STDC_HDRS = -DSTDC_HEADERS
+
+# Uncomment this if you have utime.h.
+# UTIME_H = -DHAVE_UTIME_H
+
+# Uncomment this if utime (FILE, NULL) works on your system.
+# UTIME_NULL = -DHAVE_UTIME_NULL
+
+# Uncomment this if struct utimbuf is defined in utime.h.
+# UTIMBUF = -DHAVE_STRUCT_UTIMBUF
+
+CC = gcc
+CFLAGS = -g -O2
+
+ALL_CFLAGS = $(STDC_HDRS) $(UTIME_H) $(UTIME_NULL) $(UTIMBUF) $(CFLAGS)
+
+all: poke
+
+poke: poke.o
+ $(CC) -o poke $(ALL_CFLAGS) $(LDFLAGS) poke.o
+
+.c.o:
+ $(CC) -c $(ALL_CFLAGS) poke.c
+
+install: poke
+ cp poke $(bindir)/poke
+
+clean:
+ rm poke poke.o
+@end example
+
+Some problems with this approach should be clear.
+
+Users who want to compile poke will have to know how @samp{utime} works
+on their systems, so that they can uncomment the @file{Makefile}
+correctly.
+
+The installation is done using @samp{cp}, but many systems have an
+@samp{install} program which may be used, and which supports optional
+features such as stripping debugging information out of the installed
+binary.
+
+The use of @file{Makefile} variables like @samp{CC}, @samp{CFLAGS} and
+@samp{LDFLAGS} follows the requirements of the GNU standards. This is
+convenient for all packages, since it reduces surprises for users.
+However, it is easy to get the details wrong, and wind up with a
+slightly nonstandard distribution.
+
+@node Getting Started Example 3
+@subsection Third Try
+
+For our third try at this program, we will write a @file{configure.in}
+script to discover the configuration features on the host system, rather
+than requiring the user to edit the @file{Makefile}. We will also write
+a @file{Makefile.am} rather than a @file{Makefile}.
+
+The only change to @file{poke.c} is to add a line at the start of the
+file:
+@smallexample
+#include "config.h"
+@end smallexample
+
+The new @file{configure.in} file is as follows.
+
+@example
+AC_INIT(poke.c)
+AM_INIT_AUTOMAKE(poke, 1.0)
+AM_CONFIG_HEADER(config.h:config.in)
+AC_PROG_CC
+AC_HEADER_STDC
+AC_CHECK_HEADERS(utime.h)
+AC_EGREP_HEADER(utimbuf, utime.h, AC_DEFINE(HAVE_STRUCT_UTIMBUF))
+AC_FUNC_UTIME_NULL
+AC_OUTPUT(Makefile)
+@end example
+
+The first four macros in this file, and the last one, were described
+above; see @ref{Write configure.in}. If we omit these macros, then when
+we run @samp{automake} we will get a reminder that we need them.
+
+The other macros are standard autoconf macros.
+
+@table @samp
+@item AC_HEADER_STDC
+Check for standard C headers.
+@item AC_CHECK_HEADERS
+Check whether a particular header file exists.
+@item AC_EGREP_HEADER
+Check for a particular string in a particular header file, in this case
+checking for @samp{utimbuf} in @file{utime.h}.
+@item AC_FUNC_UTIME_NULL
+Check whether @samp{utime} accepts a NULL second argument to set the
+file change time to the current time.
+@end table
+
+See the autoconf manual for a more complete description.
+
+The new @file{Makefile.am} file is as follows. Note how simple this is
+compared to our earlier @file{Makefile}.
+
+@example
+bin_PROGRAMS = poke
+
+poke_SOURCES = poke.c
+@end example
+
+This means that we should build a single program name @samp{poke}. It
+should be installed in the binary directory, which we called
+@samp{bindir} earlier. The program @samp{poke} is built from the source
+file @file{poke.c}.
+
+We must also write a @file{acconfig.h} file. Besides @samp{PACKAGE} and
+@samp{VERSION}, which must be mentioned for all packages which use
+automake, we must include @samp{HAVE_STRUCT_UTIMBUF}, since we mentioned
+it in an @samp{AC_DEFINE}.
+
+@example
+/* Name of package. */
+#undef PACKAGE
+
+/* Version of package. */
+#undef VERSION
+
+/* Whether utime.h defines struct utimbuf. */
+#undef HAVE_STRUCT_UTIMBUF
+@end example
+
+@node Generate Files in Example
+@subsection Generate Files
+
+We must now generate the other files, using the following commands.
+
+@smallexample
+aclocal
+autoconf
+autoheader
+automake
+@end smallexample
+
+When we run @samp{autoheader}, it will remind us of any macros we forgot
+to add to @file{acconfig.h}.
+
+When we run @samp{automake}, it will want to add some files to our
+distribution. It will add them automatically if we use the
+@samp{--add-missing} option.
+
+By default, @samp{automake} will run in GNU mode, which means that it
+will want us to create certain additional files; as of this writing, it
+will want @file{NEWS}, @file{README}, @file{AUTHORS}, and
+@file{ChangeLog}, all of which are files which should appear in a
+standard GNU distribution. We can either add those files, or run
+@samp{automake} with the @samp{--foreign} option.
+
+Running these tools will generate the following files, all of which are
+described in the next chapter.
+
+@itemize @bullet
+@item
+@file{aclocal.m4}
+@item
+@file{configure}
+@item
+@file{config.in}
+@item
+@file{Makefile.in}
+@item
+@file{stamp-h.in}
+@end itemize
+
+@node Files
+@chapter Files
+
+As was seen in the previous chapter, the GNU configure and build system
+uses a number of different files. The developer must write a few files.
+The others are generated by various tools.
+
+The system is rather flexible, and can be used in many different ways.
+In describing the files that it uses, I will describe the common case,
+and mention some other cases that may arise.
+
+@menu
+* Developer Files:: Developer Files.
+* Build Files:: Build Files.
+* Support Files:: Support Files.
+@end menu
+
+@node Developer Files
+@section Developer Files
+
+This section describes the files written or generated by the developer
+of a package.
+
+@menu
+* Developer Files Picture:: Developer Files Picture.
+* Written Developer Files:: Written Developer Files.
+* Generated Developer Files:: Generated Developer Files.
+@end menu
+
+@node Developer Files Picture
+@subsection Developer Files Picture
+
+Here is a picture of the files which are written by the developer, the
+generated files which would be included with a complete source
+distribution, and the tools which create those files.
+@ifinfo
+The file names are plain text and the tool names are enclosed by
+@samp{*} characters
+@end ifinfo
+@ifnotinfo
+The file names are in rectangles with square corners and the tool names
+are in rectangles with rounded corners
+@end ifnotinfo
+(e.g., @samp{autoheader} is the name of a tool, not the name of a file).
+
+@image{configdev}
+
+@node Written Developer Files
+@subsection Written Developer Files
+
+The following files would be written by the developer.
+
+@table @file
+@item configure.in
+@cindex @file{configure.in}
+This is the configuration script. This script contains invocations of
+autoconf macros. It may also contain ordinary shell script code. This
+file will contain feature tests for portability issues. The last thing
+in the file will normally be an @samp{AC_OUTPUT} macro listing which
+files to create when the builder runs the configure script. This file
+is always required when using the GNU configure system. @xref{Write
+configure.in}.
+
+@item Makefile.am
+@cindex @file{Makefile.am}
+This is the automake input file. It describes how the code should be
+built. It consists of definitions of automake variables. It may also
+contain ordinary Makefile targets. This file is only needed when using
+automake (newer tools normally use automake, but there are still older
+tools which have not been converted, in which the developer writes
+@file{Makefile.in} directly). @xref{Write Makefile.am}.
+
+@item acconfig.h
+@cindex @file{acconfig.h}
+When the configure script creates a portability header file, by using
+@samp{AM_CONFIG_HEADER} (or, if not using automake,
+@samp{AC_CONFIG_HEADER}), this file is used to describe macros which are
+not recognized by the @samp{autoheader} command. This is normally a
+fairly uninteresting file, consisting of a collection of @samp{#undef}
+lines with comments. Normally any call to @samp{AC_DEFINE} in
+@file{configure.in} will require a line in this file. @xref{Write
+acconfig.h}.
+
+@item acinclude.m4
+@cindex @file{acinclude.m4}
+This file is not always required. It defines local autoconf macros.
+These macros may then be used in @file{configure.in}. If you don't need
+any local autoconf macros, then you don't need this file at all. In
+fact, in general, you never need local autoconf macros, since you can
+put everything in @file{configure.in}, but sometimes a local macro is
+convenient.
+
+Newer tools may omit @file{acinclude.m4}, and instead use a
+subdirectory, typically named @file{m4}, and define
+@samp{ACLOCAL_AMFLAGS = -I m4} in @file{Makefile.am} to force
+@samp{aclocal} to look there for macro definitions. The macro
+definitions are then placed in separate files in that directory.
+
+The @file{acinclude.m4} file is only used when using automake; in older
+tools, the developer writes @file{aclocal.m4} directly, if it is needed.
+@end table
+
+@node Generated Developer Files
+@subsection Generated Developer Files
+
+The following files would be generated by the developer.
+
+When using automake, these files are normally not generated manually
+after the first time. Instead, the generated @file{Makefile} contains
+rules to automatically rebuild the files as required. When
+@samp{AM_MAINTAINER_MODE} is used in @file{configure.in} (the normal
+case in Cygnus code), the automatic rebuilding rules will only be
+defined if you configure using the @samp{--enable-maintainer-mode}
+option.
+
+When using automatic rebuilding, it is important to ensure that all the
+various tools have been built and installed on your @samp{PATH}. Using
+automatic rebuilding is highly recommended, so much so that I'm not
+going to explain what you have to do if you don't use it.
+
+@table @file
+@item configure
+@cindex @file{configure}
+This is the configure script which will be run when building the
+package. This is generated by @samp{autoconf} from @file{configure.in}
+and @file{aclocal.m4}. This is a shell script.
+
+@item Makefile.in
+@cindex @file{Makefile.in}
+This is the file which the configure script will turn into the
+@file{Makefile} at build time. This file is generated by
+@samp{automake} from @file{Makefile.am}. If you aren't using automake,
+you must write this file yourself. This file is pretty much a normal
+@file{Makefile}, with some configure substitutions for certain
+variables.
+
+@item aclocal.m4
+@cindex @file{aclocal.m4}
+This file is created by the @samp{aclocal} program, based on the
+contents of @file{configure.in} and @file{acinclude.m4} (or, as noted in
+the description of @file{acinclude.m4} above, on the contents of an
+@file{m4} subdirectory). This file contains definitions of autoconf
+macros which @samp{autoconf} will use when generating the file
+@file{configure}. These autoconf macros may be defined by you in
+@file{acinclude.m4} or they may be defined by other packages such as
+automake, libtool or gettext. If you aren't using automake, you will
+normally write this file yourself; in that case, if @file{configure.in}
+uses only standard autoconf macros, this file will not be needed at all.
+
+@item config.in
+@cindex @file{config.in}
+@cindex @file{config.h.in}
+This file is created by @samp{autoheader} based on @file{acconfig.h} and
+@file{configure.in}. At build time, the configure script will define
+some of the macros in it to create @file{config.h}, which may then be
+included by your program. This permits your C code to use preprocessor
+conditionals to change its behaviour based on the characteristics of the
+host system. This file may also be called @file{config.h.in}.
+
+@item stamp.h-in
+@cindex @file{stamp-h.in}
+This rather uninteresting file, which I omitted from the picture, is
+generated by @samp{automake}. It always contains the string
+@samp{timestamp}. It is used as a timestamp file indicating whether
+@file{config.in} is up to date. Using a timestamp file means that
+@file{config.in} can be marked as up to date without actually changing
+its modification time. This is useful since @file{config.in} depends
+upon @file{configure.in}, but it is easy to change @file{configure.in}
+in a way which does not affect @file{config.in}.
+@end table
+
+@node Build Files
+@section Build Files
+
+This section describes the files which are created at configure and
+build time. These are the files which somebody who builds the package
+will see.
+
+Of course, the developer will also build the package. The distinction
+between developer files and build files is not that the developer does
+not see the build files, but that somebody who only builds the package
+does not have to worry about the developer files.
+
+@menu
+* Build Files Picture:: Build Files Picture.
+* Build Files Description:: Build Files Description.
+@end menu
+
+@node Build Files Picture
+@subsection Build Files Picture
+
+Here is a picture of the files which will be created at build time.
+@file{config.status} is both a created file and a shell script which is
+run to create other files, and the picture attempts to show that.
+
+@image{configbuild}
+
+@node Build Files Description
+@subsection Build Files Description
+
+This is a description of the files which are created at build time.
+
+@table @file
+@item config.status
+@cindex @file{config.status}
+The first step in building a package is to run the @file{configure}
+script. The @file{configure} script will create the file
+@file{config.status}, which is itself a shell script. When you first
+run @file{configure}, it will automatically run @file{config.status}.
+An @file{Makefile} derived from an automake generated @file{Makefile.in}
+will contain rules to automatically run @file{config.status} again when
+necessary to recreate certain files if their inputs change.
+
+@item Makefile
+@cindex @file{Makefile}
+This is the file which make will read to build the program. The
+@file{config.status} script will transform @file{Makefile.in} into
+@file{Makefile}.
+
+@item config.h
+@cindex @file{config.h}
+This file defines C preprocessor macros which C code can use to adjust
+its behaviour on different systems. The @file{config.status} script
+will transform @file{config.in} into @file{config.h}.
+
+@item config.cache
+@cindex @file{config.cache}
+This file did not fit neatly into the picture, and I omitted it. It is
+used by the @file{configure} script to cache results between runs. This
+can be an important speedup. If you modify @file{configure.in} in such
+a way that the results of old tests should change (perhaps you have
+added a new library to @samp{LDFLAGS}), then you will have to remove
+@file{config.cache} to force the tests to be rerun.
+
+The autoconf manual explains how to set up a site specific cache file.
+This can speed up running @file{configure} scripts on your system.
+
+@item stamp.h
+@cindex @file{stamp-h}
+This file, which I omitted from the picture, is similar to
+@file{stamp-h.in}. It is used as a timestamp file indicating whether
+@file{config.h} is up to date. This is useful since @file{config.h}
+depends upon @file{config.status}, but it is easy for
+@file{config.status} to change in a way which does not affect
+@file{config.h}.
+@end table
+
+@node Support Files
+@section Support Files
+
+The GNU configure and build system requires several support files to be
+included with your distribution. You do not normally need to concern
+yourself with these. If you are using the Cygnus tree, most are already
+present. Otherwise, they will be installed with your source by
+@samp{automake} (with the @samp{--add-missing} option) and
+@samp{libtoolize}.
+
+You don't have to put the support files in the top level directory. You
+can put them in a subdirectory, and use the @samp{AC_CONFIG_AUX_DIR}
+macro in @file{configure.in} to tell @samp{automake} and the
+@file{configure} script where they are.
+
+In this section, I describe the support files, so that you can know what
+they are and why they are there.
+
+@table @file
+@item ABOUT-NLS
+Added by automake if you are using gettext. This is a documentation
+file about the gettext project.
+@item ansi2knr.c
+Used by an automake generated @file{Makefile} if you put @samp{ansi2knr}
+in @samp{AUTOMAKE_OPTIONS} in @file{Makefile.am}. This permits
+compiling ANSI C code with a K&R C compiler.
+@item ansi2knr.1
+The man page which goes with @file{ansi2knr.c}.
+@item config.guess
+A shell script which determines the configuration name for the system on
+which it is run.
+@item config.sub
+A shell script which canonicalizes a configuration name entered by a
+user.
+@item elisp-comp
+Used to compile Emacs LISP files.
+@item install-sh
+A shell script which installs a program. This is used if the configure
+script can not find an install binary.
+@item ltconfig
+Used by libtool. This is a shell script which configures libtool for
+the particular system on which it is used.
+@item ltmain.sh
+Used by libtool. This is the actual libtool script which is used, after
+it is configured by @file{ltconfig} to build a library.
+@item mdate-sh
+A shell script used by an automake generated @file{Makefile} to pretty
+print the modification time of a file. This is used to maintain version
+numbers for texinfo files.
+@item missing
+A shell script used if some tool is missing entirely. This is used by
+an automake generated @file{Makefile} to avoid certain sorts of
+timestamp problems.
+@item mkinstalldirs
+A shell script which creates a directory, including all parent
+directories. This is used by an automake generated @file{Makefile}
+during installation.
+@item texinfo.tex
+Required if you have any texinfo files. This is used when converting
+Texinfo files into DVI using @samp{texi2dvi} and @TeX{}.
+@item ylwrap
+A shell script used by an automake generated @file{Makefile} to run
+programs like @samp{bison}, @samp{yacc}, @samp{flex}, and @samp{lex}.
+These programs default to producing output files with a fixed name, and
+the @file{ylwrap} script runs them in a subdirectory to avoid file name
+conflicts when using a parallel make program.
+@end table
+
+@node Configuration Names
+@chapter Configuration Names
+@cindex configuration names
+@cindex configuration triplets
+@cindex triplets
+@cindex host names
+@cindex host triplets
+@cindex canonical system names
+@cindex system names
+@cindex system types
+
+The GNU configure system names all systems using a @dfn{configuration
+name}. All such names used to be triplets (they may now contain four
+parts in certain cases), and the term @dfn{configuration triplet} is
+still seen.
+
+@menu
+* Configuration Name Definition:: Configuration Name Definition.
+* Using Configuration Names:: Using Configuration Names.
+@end menu
+
+@node Configuration Name Definition
+@section Configuration Name Definition
+
+This is a string of the form
+@var{cpu}-@var{manufacturer}-@var{operating_system}. In some cases,
+this is extended to a four part form:
+@var{cpu}-@var{manufacturer}-@var{kernel}-@var{operating_system}.
+
+When using a configuration name in a configure option, it is normally
+not necessary to specify an entire name. In particular, the
+@var{manufacturer} field is often omitted, leading to strings such as
+@samp{i386-linux} or @samp{sparc-sunos}. The shell script
+@file{config.sub} will translate these shortened strings into the
+canonical form. autoconf will arrange for @file{config.sub} to be run
+automatically when it is needed.
+
+The fields of a configuration name are as follows:
+
+@table @var
+@item cpu
+The type of processor. This is typically something like @samp{i386} or
+@samp{sparc}. More specific variants are used as well, such as
+@samp{mipsel} to indicate a little endian MIPS processor.
+@item manufacturer
+A somewhat freeform field which indicates the manufacturer of the
+system. This is often simply @samp{unknown}. Other common strings are
+@samp{pc} for an IBM PC compatible system, or the name of a workstation
+vendor, such as @samp{sun}.
+@item operating_system
+The name of the operating system which is run on the system. This will
+be something like @samp{solaris2.5} or @samp{irix6.3}. There is no
+particular restriction on the version number, and strings like
+@samp{aix4.1.4.0} are seen. For an embedded system, which has no
+operating system, this field normally indicates the type of object file
+format, such as @samp{elf} or @samp{coff}.
+@item kernel
+This is used mainly for GNU/Linux. A typical GNU/Linux configuration
+name is @samp{i586-pc-linux-gnulibc1}. In this case the kernel,
+@samp{linux}, is separated from the operating system, @samp{gnulibc1}.
+@end table
+
+The shell script @file{config.guess} will normally print the correct
+configuration name for the system on which it is run. It does by
+running @samp{uname} and by examining other characteristics of the
+system.
+
+Because @file{config.guess} can normally determine the configuration
+name for a machine, it is normally only necessary to specify a
+configuration name when building a cross-compiler or when building using
+a cross-compiler.
+
+@node Using Configuration Names
+@section Using Configuration Names
+
+A configure script will sometimes have to make a decision based on a
+configuration name. You will need to do this if you have to compile
+code differently based on something which can not be tested using a
+standard autoconf feature test.
+
+It is normally better to test for particular features, rather than to
+test for a particular system. This is because as Unix evolves,
+different systems copy features from one another. Even if you need to
+determine whether the feature is supported based on a configuration
+name, you should define a macro which describes the feature, rather than
+defining a macro which describes the particular system you are on.
+
+Testing for a particular system is normally done using a case statement
+in @file{configure.in}. The case statement might look something like
+the following, assuming that @samp{host} is a shell variable holding a
+canonical configuration name (which will be the case if
+@file{configure.in} uses the @samp{AC_CANONICAL_HOST} or
+@samp{AC_CANONICAL_SYSTEM} macro).
+
+@smallexample
+case "$@{host@}" in
+i[3456]86-*-linux-gnu*) do something ;;
+sparc*-sun-solaris2.[56789]*) do something ;;
+sparc*-sun-solaris*) do something ;;
+mips*-*-elf*) do something ;;
+esac
+@end smallexample
+
+It is particularly important to use @samp{*} after the operating system
+field, in order to match the version number which will be generated by
+@file{config.guess}.
+
+In most cases you must be careful to match a range of processor types.
+For most processor families, a trailing @samp{*} suffices, as in
+@samp{mips*} above. For the i386 family, something along the lines of
+@samp{i[3456]86} suffices at present. For the m68k family, you will
+need something like @samp{m68*}. Of course, if you do not need to match
+on the processor, it is simpler to just replace the entire field by a
+@samp{*}, as in @samp{*-*-irix*}.
+
+@node Cross Compilation Tools
+@chapter Cross Compilation Tools
+@cindex cross tools
+
+The GNU configure and build system can be used to build @dfn{cross
+compilation} tools. A cross compilation tool is a tool which runs on
+one system and produces code which runs on another system.
+
+@menu
+* Cross Compilation Concepts:: Cross Compilation Concepts.
+* Host and Target:: Host and Target.
+* Using the Host Type:: Using the Host Type.
+* Specifying the Target:: Specifying the Target.
+* Using the Target Type:: Using the Target Type.
+* Cross Tools in the Cygnus Tree:: Cross Tools in the Cygnus Tree
+@end menu
+
+@node Cross Compilation Concepts
+@section Cross Compilation Concepts
+
+@cindex cross compiler
+A compiler which produces programs which run on a different system is a
+cross compilation compiler, or simply a @dfn{cross compiler}.
+Similarly, we speak of cross assemblers, cross linkers, etc.
+
+In the normal case, a compiler produces code which runs on the same
+system as the one on which the compiler runs. When it is necessary to
+distinguish this case from the cross compilation case, such a compiler
+is called a @dfn{native compiler}. Similarly, we speak of native
+assemblers, etc.
+
+Although the debugger is not strictly speaking a compilation tool, it is
+nevertheless meaningful to speak of a cross debugger: a debugger which
+is used to debug code which runs on another system. Everything that is
+said below about configuring cross compilation tools applies to the
+debugger as well.
+
+@node Host and Target
+@section Host and Target
+@cindex host system
+@cindex target system
+
+When building cross compilation tools, there are two different systems
+involved: the system on which the tools will run, and the system for
+which the tools generate code.
+
+The system on which the tools will run is called the @dfn{host} system.
+
+The system for which the tools generate code is called the @dfn{target}
+system.
+
+For example, suppose you have a compiler which runs on a GNU/Linux
+system and generates ELF programs for a MIPS embedded system. In this
+case the GNU/Linux system is the host, and the MIPS ELF system is the
+target. Such a compiler could be called a GNU/Linux cross MIPS ELF
+compiler, or, equivalently, a @samp{i386-linux-gnu} cross
+@samp{mips-elf} compiler.
+
+Naturally, most programs are not cross compilation tools. For those
+programs, it does not make sense to speak of a target. It only makes
+sense to speak of a target for tools like @samp{gcc} or the
+@samp{binutils} which actually produce running code. For example, it
+does not make sense to speak of the target of a tool like @samp{bison}
+or @samp{make}.
+
+Most cross compilation tools can also serve as native tools. For a
+native compilation tool, it is still meaningful to speak of a target.
+For a native tool, the target is the same as the host. For example, for
+a GNU/Linux native compiler, the host is GNU/Linux, and the target is
+also GNU/Linux.
+
+@node Using the Host Type
+@section Using the Host Type
+
+In almost all cases the host system is the system on which you run the
+@samp{configure} script, and on which you build the tools (for the case
+when they differ, @pxref{Canadian Cross}).
+
+@cindex @samp{AC_CANONICAL_HOST}
+If your configure script needs to know the configuration name of the
+host system, and the package is not a cross compilation tool and
+therefore does not have a target, put @samp{AC_CANONICAL_HOST} in
+@file{configure.in}. This macro will arrange to define a few shell
+variables when the @samp{configure} script is run.
+
+@table @samp
+@item host
+The canonical configuration name of the host. This will normally be
+determined by running the @file{config.guess} shell script, although the
+user is permitted to override this by using an explicit @samp{--host}
+option.
+@item host_alias
+In the unusual case that the user used an explicit @samp{--host} option,
+this will be the argument to @samp{--host}. In the normal case, this
+will be the same as the @samp{host} variable.
+@item host_cpu
+@itemx host_vendor
+@itemx host_os
+The first three parts of the canonical configuration name.
+@end table
+
+The shell variables may be used by putting shell code in
+@file{configure.in}. For an example, see @ref{Using Configuration
+Names}.
+
+@node Specifying the Target
+@section Specifying the Target
+
+By default, the @samp{configure} script will assume that the target is
+the same as the host. This is the more common case; for example, it
+leads to a native compiler rather than a cross compiler.
+
+@cindex @samp{--target} option
+@cindex target option
+@cindex configure target
+If you want to build a cross compilation tool, you must specify the
+target explicitly by using the @samp{--target} option when you run
+@samp{configure}. The argument to @samp{--target} is the configuration
+name of the system for which you wish to generate code.
+@xref{Configuration Names}.
+
+For example, to build tools which generate code for a MIPS ELF embedded
+system, you would use @samp{--target mips-elf}.
+
+@node Using the Target Type
+@section Using the Target Type
+
+@cindex @samp{AC_CANONICAL_SYSTEM}
+When writing @file{configure.in} for a cross compilation tool, you will
+need to use information about the target. To do this, put
+@samp{AC_CANONICAL_SYSTEM} in @file{configure.in}.
+
+@samp{AC_CANONICAL_SYSTEM} will look for a @samp{--target} option and
+canonicalize it using the @file{config.sub} shell script. It will also
+run @samp{AC_CANONICAL_HOST} (@pxref{Using the Host Type}).
+
+The target type will be recorded in the following shell variables. Note
+that the host versions of these variables will also be defined by
+@samp{AC_CANONICAL_HOST}.
+
+@table @samp
+@item target
+The canonical configuration name of the target.
+@item target_alias
+The argument to the @samp{--target} option. If the user did not specify
+a @samp{--target} option, this will be the same as @samp{host_alias}.
+@item target_cpu
+@itemx target_vendor
+@itemx target_os
+The first three parts of the canonical target configuration name.
+@end table
+
+Note that if @samp{host} and @samp{target} are the same string, you can
+assume a native configuration. If they are different, you can assume a
+cross configuration.
+
+It is arguably possible for @samp{host} and @samp{target} to represent
+the same system, but for the strings to not be identical. For example,
+if @samp{config.guess} returns @samp{sparc-sun-sunos4.1.4}, and somebody
+configures with @samp{--target sparc-sun-sunos4.1}, then the slight
+differences between the two versions of SunOS may be unimportant for
+your tool. However, in the general case it can be quite difficult to
+determine whether the differences between two configuration names are
+significant or not. Therefore, by convention, if the user specifies a
+@samp{--target} option without specifying a @samp{--host} option, it is
+assumed that the user wants to configure a cross compilation tool.
+
+The variables @samp{target} and @samp{target_alias} should be handled
+differently.
+
+In general, whenever the user may actually see a string,
+@samp{target_alias} should be used. This includes anything which may
+appear in the file system, such as a directory name or part of a tool
+name. It also includes any tool output, unless it is clearly labelled
+as the canonical target configuration name. This permits the user to
+use the @samp{--target} option to specify how the tool will appear to
+the outside world.
+
+On the other hand, when checking for characteristics of the target
+system, @samp{target} should be used. This is because a wide variety of
+@samp{--target} options may map into the same canonical configuration
+name. You should not attempt to duplicate the canonicalization done by
+@samp{config.sub} in your own code.
+
+By convention, cross tools are installed with a prefix of the argument
+used with the @samp{--target} option, also known as @samp{target_alias}
+(@pxref{Using the Target Type}). If the user does not use the
+@samp{--target} option, and thus is building a native tool, no prefix is
+used.
+
+For example, if gcc is configured with @samp{--target mips-elf}, then
+the installed binary will be named @samp{mips-elf-gcc}. If gcc is
+configured without a @samp{--target} option, then the installed binary
+will be named @samp{gcc}.
+
+The autoconf macro @samp{AC_ARG_PROGRAM} will handle this for you. If
+you are using automake, no more need be done; the programs will
+automatically be installed with the correct prefixes. Otherwise, see
+the autoconf documentation for @samp{AC_ARG_PROGRAM}.
+
+@node Cross Tools in the Cygnus Tree
+@section Cross Tools in the Cygnus Tree
+
+The Cygnus tree is used for various packages including gdb, the GNU
+binutils, and egcs. It is also, of course, used for Cygnus releases.
+
+In the Cygnus tree, the top level @file{configure} script uses the old
+Cygnus configure system, not autoconf. The top level @file{Makefile.in}
+is written to build packages based on what is in the source tree, and
+supports building a large number of tools in a single
+@samp{configure}/@samp{make} step.
+
+The Cygnus tree may be configured with a @samp{--target} option. The
+@samp{--target} option applies recursively to every subdirectory, and
+permits building an entire set of cross tools at once.
+
+@menu
+* Host and Target Libraries:: Host and Target Libraries.
+* Target Library Configure Scripts:: Target Library Configure Scripts.
+* Make Targets in Cygnus Tree:: Make Targets in Cygnus Tree.
+* Target libiberty:: Target libiberty
+@end menu
+
+@node Host and Target Libraries
+@subsection Host and Target Libraries
+
+The Cygnus tree distinguishes host libraries from target libraries.
+
+Host libraries are built with the compiler used to build the programs
+which run on the host, which is called the host compiler. This includes
+libraries such as @samp{bfd} and @samp{tcl}. These libraries are built
+with the host compiler, and are linked into programs like the binutils
+or gcc which run on the host.
+
+Target libraries are built with the target compiler. If gcc is present
+in the source tree, then the target compiler is the gcc that is built
+using the host compiler. Target libraries are libraries such as
+@samp{newlib} and @samp{libstdc++}. These libraries are not linked into
+the host programs, but are instead made available for use with programs
+built with the target compiler.
+
+For the rest of this section, assume that gcc is present in the source
+tree, so that it will be used to build the target libraries.
+
+There is a complication here. The configure process needs to know which
+compiler you are going to use to build a tool; otherwise, the feature
+tests will not work correctly. The Cygnus tree handles this by not
+configuring the target libraries until the target compiler is built. In
+order to permit everything to build using a single
+@samp{configure}/@samp{make}, the configuration of the target libraries
+is actually triggered during the make step.
+
+When the target libraries are configured, the @samp{--target} option is
+not used. Instead, the @samp{--host} option is used with the argument
+of the @samp{--target} option for the overall configuration. If no
+@samp{--target} option was used for the overall configuration, the
+@samp{--host} option will be passed with the output of the
+@file{config.guess} shell script. Any @samp{--build} option is passed
+down unchanged.
+
+This translation of configuration options is done because since the
+target libraries are compiled with the target compiler, they are being
+built in order to run on the target of the overall configuration. By
+the definition of host, this means that their host system is the same as
+the target system of the overall configuration.
+
+The same process is used for both a native configuration and a cross
+configuration. Even when using a native configuration, the target
+libraries will be configured and built using the newly built compiler.
+This is particularly important for the C++ libraries, since there is no
+reason to assume that the C++ compiler used to build the host tools (if
+there even is one) uses the same ABI as the g++ compiler which will be
+used to build the target libraries.
+
+There is one difference between a native configuration and a cross
+configuration. In a native configuration, the target libraries are
+normally configured and built as siblings of the host tools. In a cross
+configuration, the target libraries are normally built in a subdirectory
+whose name is the argument to @samp{--target}. This is mainly for
+historical reasons.
+
+To summarize, running @samp{configure} in the Cygnus tree configures all
+the host libraries and tools, but does not configure any of the target
+libraries. Running @samp{make} then does the following steps:
+
+@itemize @bullet
+@item
+Build the host libraries.
+@item
+Build the host programs, including gcc. Note that we call gcc both a
+host program (since it runs on the host) and a target compiler (since it
+generates code for the target).
+@item
+Using the newly built target compiler, configure the target libraries.
+@item
+Build the target libraries.
+@end itemize
+
+The steps need not be done in precisely this order, since they are
+actually controlled by @file{Makefile} targets.
+
+@node Target Library Configure Scripts
+@subsection Target Library Configure Scripts
+
+There are a few things you must know in order to write a configure
+script for a target library. This is just a quick sketch, and beginners
+shouldn't worry if they don't follow everything here.
+
+The target libraries are configured and built using a newly built target
+compiler. There may not be any startup files or libraries for this
+target compiler. In fact, those files will probably be built as part of
+some target library, which naturally means that they will not exist when
+your target library is configured.
+
+This means that the configure script for a target library may not use
+any test which requires doing a link. This unfortunately includes many
+useful autoconf macros, such as @samp{AC_CHECK_FUNCS}. autoconf macros
+which do a compile but not a link, such as @samp{AC_CHECK_HEADERS}, may
+be used.
+
+This is a severe restriction, but normally not a fatal one, as target
+libraries can often assume the presence of other target libraries, and
+thus know which functions will be available.
+
+As of this writing, the autoconf macro @samp{AC_PROG_CC} does a link to
+make sure that the compiler works. This may fail in a target library,
+so target libraries must use a different set of macros to locate the
+compiler. See the @file{configure.in} file in a directory like
+@file{libiberty} or @file{libgloss} for an example.
+
+As noted in the previous section, target libraries are sometimes built
+in directories which are siblings to the host tools, and are sometimes
+built in a subdirectory. The @samp{--with-target-subdir} configure
+option will be passed when the library is configured. Its value will be
+an empty string if the target library is a sibling. Its value will be
+the name of the subdirectory if the target library is in a subdirectory.
+
+If the overall build is not a native build (i.e., the overall configure
+used the @samp{--target} option), then the library will be configured
+with the @samp{--with-cross-host} option. The value of this option will
+be the host system of the overall build. Recall that the host system of
+the library will be the target of the overall build. If the overall
+build is a native build, the @samp{--with-cross-host} option will not be
+used.
+
+A library which can be built both standalone and as a target library may
+want to install itself into different directories depending upon the
+case. When built standalone, or when built native, the library should
+be installed in @samp{$(libdir)}. When built as a target library which
+is not native, the library should be installed in @samp{$(tooldir)/lib}.
+The @samp{--with-cross-host} option may be used to distinguish these
+cases.
+
+This same test of @samp{--with-cross-host} may be used to see whether it
+is OK to use link tests in the configure script. If the
+@samp{--with-cross-host} option is not used, then the library is being
+built either standalone or native, and a link should work.
+
+@node Make Targets in Cygnus Tree
+@subsection Make Targets in Cygnus Tree
+
+The top level @file{Makefile} in the Cygnus tree defines targets for
+every known subdirectory.
+
+For every subdirectory @var{dir} which holds a host library or program,
+the @file{Makefile} target @samp{all-@var{dir}} will build that library
+or program.
+
+There are dependencies among host tools. For example, building gcc
+requires first building gas, because the gcc build process invokes the
+target assembler. These dependencies are reflected in the top level
+@file{Makefile}.
+
+For every subdirectory @var{dir} which holds a target library, the
+@file{Makefile} target @samp{configure-target-@var{dir}} will configure
+that library. The @file{Makefile} target @samp{all-target-@var{dir}}
+will build that library.
+
+Every @samp{configure-target-@var{dir}} target depends upon
+@samp{all-gcc}, since gcc, the target compiler, is required to configure
+the tool. Every @samp{all-target-@var{dir}} target depends upon the
+corresponding @samp{configure-target-@var{dir}} target.
+
+There are several other targets which may be of interest for each
+directory: @samp{install-@var{dir}}, @samp{clean-@var{dir}}, and
+@samp{check-@var{dir}}. There are also corresponding @samp{target}
+versions of these for the target libraries , such as
+@samp{install-target-@var{dir}}.
+
+@node Target libiberty
+@subsection Target libiberty
+
+The @file{libiberty} subdirectory is currently a special case, in that
+it is the only directory which is built both using the host compiler and
+using the target compiler.
+
+This is because the files in @file{libiberty} are used when building the
+host tools, and they are also incorporated into the @file{libstdc++}
+target library as support code.
+
+This duality does not pose any particular difficulties. It means that
+there are targets for both @samp{all-libiberty} and
+@samp{all-target-libiberty}.
+
+In a native configuration, when target libraries are not built in a
+subdirectory, the same objects are normally used as both the host build
+and the target build. This is normally OK, since libiberty contains
+only C code, and in a native configuration the results of the host
+compiler and the target compiler are normally interoperable.
+
+Irix 6 is again an exception here, since the SGI native compiler
+defaults to using the @samp{O32} ABI, and gcc defaults to using the
+@samp{N32} ABI. On Irix 6, the target libraries are built in a
+subdirectory even for a native configuration, avoiding this problem.
+
+There are currently no other libraries built for both the host and the
+target, but there is no conceptual problem with adding more.
+
+@node Canadian Cross
+@chapter Canadian Cross
+@cindex canadian cross
+@cindex building with a cross compiler
+@cindex cross compiler, building with
+
+It is possible to use the GNU configure and build system to build a
+program which will run on a system which is different from the system on
+which the tools are built. In other words, it is possible to build
+programs using a cross compiler.
+
+This is referred to as a @dfn{Canadian Cross}.
+
+@menu
+* Canadian Cross Example:: Canadian Cross Example.
+* Canadian Cross Concepts:: Canadian Cross Concepts.
+* Build Cross Host Tools:: Build Cross Host Tools.
+* Build and Host Options:: Build and Host Options.
+* CCross not in Cygnus Tree:: Canadian Cross not in Cygnus Tree.
+* CCross in Cygnus Tree:: Canadian Cross in Cygnus Tree.
+* Supporting Canadian Cross:: Supporting Canadian Cross.
+@end menu
+
+@node Canadian Cross Example
+@section Canadian Cross Example
+
+Here is an example of a Canadian Cross.
+
+While running on a GNU/Linux, you can build a program which will run on
+a Solaris system. You would use a GNU/Linux cross Solaris compiler to
+build the program.
+
+Of course, you could not run the resulting program on your GNU/Linux
+system. You would have to copy it over to a Solaris system before you
+would run it.
+
+Of course, you could also simply build the programs on the Solaris
+system in the first place. However, perhaps the Solaris system is not
+available for some reason; perhaps you actually don't have one, but you
+want to build the tools for somebody else to use. Or perhaps your
+GNU/Linux system is much faster than your Solaris system.
+
+A Canadian Cross build is most frequently used when building programs to
+run on a non-Unix system, such as DOS or Windows. It may be simpler to
+configure and build on a Unix system than to support the configuration
+machinery on a non-Unix system.
+
+@node Canadian Cross Concepts
+@section Canadian Cross Concepts
+
+When building a Canadian Cross, there are at least two different systems
+involved: the system on which the tools are being built, and the system
+on which the tools will run.
+
+The system on which the tools are being built is called the @dfn{build}
+system.
+
+The system on which the tools will run is called the host system.
+
+For example, if you are building a Solaris program on a GNU/Linux
+system, as in the previous section, the build system would be GNU/Linux,
+and the host system would be Solaris.
+
+It is, of course, possible to build a cross compiler using a Canadian
+Cross (i.e., build a cross compiler using a cross compiler). In this
+case, the system for which the resulting cross compiler generates code
+is called the target system. (For a more complete discussion of host
+and target systems, @pxref{Host and Target}).
+
+An example of building a cross compiler using a Canadian Cross would be
+building a Windows cross MIPS ELF compiler on a GNU/Linux system. In
+this case the build system would be GNU/Linux, the host system would be
+Windows, and the target system would be MIPS ELF.
+
+The name Canadian Cross comes from the case when the build, host, and
+target systems are all different. At the time that these issues were
+all being hashed out, Canada had three national political parties.
+
+@node Build Cross Host Tools
+@section Build Cross Host Tools
+
+In order to configure a program for a Canadian Cross build, you must
+first build and install the set of cross tools you will use to build the
+program.
+
+These tools will be build cross host tools. That is, they will run on
+the build system, and will produce code that runs on the host system.
+
+It is easy to confuse the meaning of build and host here. Always
+remember that the build system is where you are doing the build, and the
+host system is where the resulting program will run. Therefore, you
+need a build cross host compiler.
+
+In general, you must have a complete cross environment in order to do
+the build. This normally means a cross compiler, cross assembler, and
+so forth, as well as libraries and include files for the host system.
+
+@node Build and Host Options
+@section Build and Host Options
+@cindex configuring a canadian cross
+@cindex canadian cross, configuring
+
+When you run @file{configure}, you must use both the @samp{--build} and
+@samp{--host} options.
+
+@cindex @samp{--build} option
+@cindex build option
+@cindex configure build system
+The @samp{--build} option is used to specify the configuration name of
+the build system. This can normally be the result of running the
+@file{config.guess} shell script, and it is reasonable to use
+@samp{--build=`config.guess`}.
+
+@cindex @samp{--host} option
+@cindex host option
+@cindex configure host
+The @samp{--host} option is used to specify the configuration name of
+the host system.
+
+As we explained earlier, @file{config.guess} is used to set the default
+value for the @samp{--host} option (@pxref{Using the Host Type}). We
+can now see that since @file{config.guess} returns the type of system on
+which it is run, it really identifies the build system. Since the host
+system is normally the same as the build system (i.e., people do not
+normally build using a cross compiler), it is reasonable to use the
+result of @file{config.guess} as the default for the host system when
+the @samp{--host} option is not used.
+
+It might seem that if the @samp{--host} option were used without the
+@samp{--build} option that the configure script could run
+@file{config.guess} to determine the build system, and presume a
+Canadian Cross if the result of @file{config.guess} differed from the
+@samp{--host} option. However, for historical reasons, some configure
+scripts are routinely run using an explicit @samp{--host} option, rather
+than using the default from @file{config.guess}. As noted earlier, it
+is difficult or impossible to reliably compare configuration names
+(@pxref{Using the Target Type}). Therefore, by convention, if the
+@samp{--host} option is used, but the @samp{--build} option is not used,
+then the build system defaults to the host system.
+
+@node CCross not in Cygnus Tree
+@section Canadian Cross not in Cygnus Tree.
+
+If you are not using the Cygnus tree, you must explicitly specify the
+cross tools which you want to use to build the program. This is done by
+setting environment variables before running the @file{configure}
+script.
+
+You must normally set at least the environment variables @samp{CC},
+@samp{AR}, and @samp{RANLIB} to the cross tools which you want to use to
+build.
+
+For some programs, you must set additional cross tools as well, such as
+@samp{AS}, @samp{LD}, or @samp{NM}.
+
+You would set these environment variables to the build cross tools which
+you are going to use.
+
+For example, if you are building a Solaris program on a GNU/Linux
+system, and your GNU/Linux cross Solaris compiler were named
+@samp{solaris-gcc}, then you would set the environment variable
+@samp{CC} to @samp{solaris-gcc}.
+
+@node CCross in Cygnus Tree
+@section Canadian Cross in Cygnus Tree
+@cindex canadian cross in cygnus tree
+
+This section describes configuring and building a Canadian Cross when
+using the Cygnus tree.
+
+@menu
+* Standard Cygnus CCross:: Building a Normal Program.
+* Cross Cygnus CCross:: Building a Cross Program.
+@end menu
+
+@node Standard Cygnus CCross
+@subsection Building a Normal Program
+
+When configuring a Canadian Cross in the Cygnus tree, all the
+appropriate environment variables are automatically set to
+@samp{@var{host}-@var{tool}}, where @var{host} is the value used for the
+@samp{--host} option, and @var{tool} is the name of the tool (e.g.,
+@samp{gcc}, @samp{as}, etc.). These tools must be on your @samp{PATH}.
+
+Adding a prefix of @var{host} will give the usual name for the build
+cross host tools. To see this, consider that when these cross tools
+were built, they were configured to run on the build system and to
+produce code for the host system. That is, they were configured with a
+@samp{--target} option that is the same as the system which we are now
+calling the host. Recall that the default name for installed cross
+tools uses the target system as a prefix (@pxref{Using the Target
+Type}). Since that is the system which we are now calling the host,
+@var{host} is the right prefix to use.
+
+For example, if you configure with @samp{--build=i386-linux-gnu} and
+@samp{--host=solaris}, then the Cygnus tree will automatically default
+to using the compiler @samp{solaris-gcc}. You must have previously
+built and installed this compiler, probably by doing a build with no
+@samp{--host} option and with a @samp{--target} option of
+@samp{solaris}.
+
+@node Cross Cygnus CCross
+@subsection Building a Cross Program
+
+There are additional considerations if you want to build a cross
+compiler, rather than a native compiler, in the Cygnus tree using a
+Canadian Cross.
+
+When you build a cross compiler using the Cygnus tree, then the target
+libraries will normally be built with the newly built target compiler
+(@pxref{Host and Target Libraries}). However, this will not work when
+building with a Canadian Cross. This is because the newly built target
+compiler will be a program which runs on the host system, and therefore
+will not be able to run on the build system.
+
+Therefore, when building a cross compiler with the Cygnus tree, you must
+first install a set of build cross target tools. These tools will be
+used when building the target libraries.
+
+Note that this is not a requirement of a Canadian Cross in general. For
+example, it would be possible to build just the host cross target tools
+on the build system, to copy the tools to the host system, and to build
+the target libraries on the host system. The requirement for build
+cross target tools is imposed by the Cygnus tree, which expects to be
+able to build both host programs and target libraries in a single
+@samp{configure}/@samp{make} step. Because it builds these in a single
+step, it expects to be able to build the target libraries on the build
+system, which means that it must use a build cross target toolchain.
+
+For example, suppose you want to build a Windows cross MIPS ELF compiler
+on a GNU/Linux system. You must have previously installed both a
+GNU/Linux cross Windows compiler and a GNU/Linux cross MIPS ELF
+compiler.
+
+In order to build the Windows (configuration name @samp{i386-cygwin32})
+cross MIPS ELF (configure name @samp{mips-elf}) compiler, you might
+execute the following commands (long command lines are broken across
+lines with a trailing backslash as a continuation character).
+
+@example
+mkdir linux-x-cygwin32
+cd linux-x-cygwin32
+@var{srcdir}/configure --target i386-cygwin32 --prefix=@var{installdir} \
+ --exec-prefix=@var{installdir}/H-i386-linux
+make
+make install
+cd ..
+mkdir linux-x-mips-elf
+cd linux-x-mips-elf
+@var{srcdir}/configure --target mips-elf --prefix=@var{installdir} \
+ --exec-prefix=@var{installdir}/H-i386-linux
+make
+make install
+cd ..
+mkdir cygwin32-x-mips-elf
+cd cygwin32-x-mips-elf
+@var{srcdir}/configure --build=i386-linux-gnu --host=i386-cygwin32 \
+ --target=mips-elf --prefix=@var{wininstalldir} \
+ --exec-prefix=@var{wininstalldir}/H-i386-cygwin32
+make
+make install
+@end example
+
+You would then copy the contents of @var{wininstalldir} over to the
+Windows machine, and run the resulting programs.
+
+@node Supporting Canadian Cross
+@section Supporting Canadian Cross
+
+If you want to make it possible to build a program you are developing
+using a Canadian Cross, you must take some care when writing your
+configure and make rules. Simple cases will normally work correctly.
+However, it is not hard to write configure and make tests which will
+fail in a Canadian Cross.
+
+@menu
+* CCross in Configure:: Supporting Canadian Cross in Configure Scripts.
+* CCross in Make:: Supporting Canadian Cross in Makefiles.
+@end menu
+
+@node CCross in Configure
+@subsection Supporting Canadian Cross in Configure Scripts
+@cindex canadian cross in configure
+
+In a @file{configure.in} file, after calling @samp{AC_PROG_CC}, you can
+find out whether this is a Canadian Cross configure by examining the
+shell variable @samp{cross_compiling}. In a Canadian Cross, which means
+that the compiler is a cross compiler, @samp{cross_compiling} will be
+@samp{yes}. In a normal configuration, @samp{cross_compiling} will be
+@samp{no}.
+
+You ordinarily do not need to know the type of the build system in a
+configure script. However, if you do need that information, you can get
+it by using the macro @samp{AC_CANONICAL_SYSTEM}, the same macro that is
+used to determine the target system. This macro will set the variables
+@samp{build}, @samp{build_alias}, @samp{build_cpu}, @samp{build_vendor},
+and @samp{build_os}, which correspond to the similar @samp{target} and
+@samp{host} variables, except that they describe the build system.
+
+When writing tests in @file{configure.in}, you must remember that you
+want to test the host environment, not the build environment.
+
+Macros like @samp{AC_CHECK_FUNCS} which use the compiler will test the
+host environment. That is because the tests will be done by running the
+compiler, which is actually a build cross host compiler. If the
+compiler can find the function, that means that the function is present
+in the host environment.
+
+Tests like @samp{test -f /dev/ptyp0}, on the other hand, will test the
+build environment. Remember that the configure script is running on the
+build system, not the host system. If your configure scripts examines
+files, those files will be on the build system. Whatever you determine
+based on those files may or may not be the case on the host system.
+
+Most autoconf macros will work correctly for a Canadian Cross. The main
+exception is @samp{AC_TRY_RUN}. This macro tries to compile and run a
+test program. This will fail in a Canadian Cross, because the program
+will be compiled for the host system, which means that it will not run
+on the build system.
+
+The @samp{AC_TRY_RUN} macro provides an optional argument to tell the
+configure script what to do in a Canadian Cross. If that argument is
+not present, you will get a warning when you run @samp{autoconf}:
+@smallexample
+warning: AC_TRY_RUN called without default to allow cross compiling
+@end smallexample
+@noindent
+This tells you that the resulting @file{configure} script will not work
+with a Canadian Cross.
+
+In some cases while it may better to perform a test at configure time,
+it is also possible to perform the test at run time. In such a case you
+can use the cross compiling argument to @samp{AC_TRY_RUN} to tell your
+program that the test could not be performed at configure time.
+
+There are a few other autoconf macros which will not work correctly with
+a Canadian Cross: a partial list is @samp{AC_FUNC_GETPGRP},
+@samp{AC_FUNC_SETPGRP}, @samp{AC_FUNC_SETVBUF_REVERSED}, and
+@samp{AC_SYS_RESTARTABLE_SYSCALLS}. The @samp{AC_CHECK_SIZEOF} macro is
+generally not very useful with a Canadian Cross; it permits an optional
+argument indicating the default size, but there is no way to know what
+the correct default should be.
+
+@node CCross in Make
+@subsection Supporting Canadian Cross in Makefiles.
+@cindex canadian cross in makefile
+
+The main Canadian Cross issue in a @file{Makefile} arises when you want
+to use a subsidiary program to generate code or data which you will then
+include in your real program.
+
+If you compile this subsidiary program using @samp{$(CC)} in the usual
+way, you will not be able to run it. This is because @samp{$(CC)} will
+build a program for the host system, but the program is being built on
+the build system.
+
+You must instead use a compiler for the build system, rather than the
+host system. In the Cygnus tree, this make variable
+@samp{$(CC_FOR_BUILD)} will hold a compiler for the build system.
+
+Note that you should not include @file{config.h} in a file you are
+compiling with @samp{$(CC_FOR_BUILD)}. The @file{configure} script will
+build @file{config.h} with information for the host system. However,
+you are compiling the file using a compiler for the build system (a
+native compiler). Subsidiary programs are normally simple filters which
+do no user interaction, and it is normally possible to write them in a
+highly portable fashion so that the absence of @file{config.h} is not
+crucial.
+
+@cindex @samp{HOST_CC}
+The gcc @file{Makefile.in} shows a complex situation in which certain
+files, such as @file{rtl.c}, must be compiled into both subsidiary
+programs run on the build system and into the final program. This
+approach may be of interest for advanced build system hackers. Note
+that the build system compiler is rather confusingly called
+@samp{HOST_CC}.
+
+@node Cygnus Configure
+@chapter Cygnus Configure
+@cindex cygnus configure
+
+The Cygnus configure script predates autoconf. All of its interesting
+features have been incorporated into autoconf. No new programs should
+be written to use the Cygnus configure script.
+
+However, the Cygnus configure script is still used in a few places: at
+the top of the Cygnus tree and in a few target libraries in the Cygnus
+tree. Until those uses have been replaced with autoconf, some brief
+notes are appropriate here. This is not complete documentation, but it
+should be possible to use this as a guide while examining the scripts
+themselves.
+
+@menu
+* Cygnus Configure Basics:: Cygnus Configure Basics.
+* Cygnus Configure in C++ Libraries:: Cygnus Configure in C++ Libraries.
+@end menu
+
+@node Cygnus Configure Basics
+@section Cygnus Configure Basics
+
+Cygnus configure does not use any generated files; there is no program
+corresponding to @samp{autoconf}. Instead, there is a single shell
+script named @samp{configure} which may be found at the top of the
+Cygnus tree. This shell script was written by hand; it was not
+generated by autoconf, and it is incorrect, and indeed harmful, to run
+@samp{autoconf} in the top level of a Cygnus tree.
+
+Cygnus configure works in a particular directory by examining the file
+@file{configure.in} in that directory. That file is broken into four
+separate shell scripts.
+
+The first is the contents of @file{configure.in} up to a line that
+starts with @samp{# per-host:}. This is the common part.
+
+The second is the rest of @file{configure.in} up to a line that starts
+with @samp{# per-target:}. This is the per host part.
+
+The third is the rest of @file{configure.in} up to a line that starts
+with @samp{# post-target:}. This is the per target part.
+
+The fourth is the remainder of @file{configure.in}. This is the post
+target part.
+
+If any of these comment lines are missing, the corresponding shell
+script is empty.
+
+Cygnus configure will first execute the common part. This must set the
+shell variable @samp{srctrigger} to the name of a source file, to
+confirm that Cygnus configure is looking at the right directory. This
+may set the shell variables @samp{package_makefile_frag} and
+@samp{package_makefile_rules_frag}.
+
+Cygnus configure will next set the @samp{build} and @samp{host} shell
+variables, and execute the per host part. This may set the shell
+variable @samp{host_makefile_frag}.
+
+Cygnus configure will next set the @samp{target} variable, and execute
+the per target part. This may set the shell variable
+@samp{target_makefile_frag}.
+
+Any of these scripts may set the @samp{subdirs} shell variable. This
+variable is a list of subdirectories where a @file{Makefile.in} file may
+be found. Cygnus configure will automatically look for a
+@file{Makefile.in} file in the current directory. The @samp{subdirs}
+shell variable is not normally used, and I believe that the only
+directory which uses it at present is @file{newlib}.
+
+For each @file{Makefile.in}, Cygnus configure will automatically create
+a @file{Makefile} by adding definitions for @samp{make} variables such
+as @samp{host} and @samp{target}, and automatically editing the values
+of @samp{make} variables such as @samp{prefix} if they are present.
+
+Also, if any of the @samp{makefile_frag} shell variables are set, Cygnus
+configure will interpret them as file names relative to either the
+working directory or the source directory, and will read the contents of
+the file into the generated @file{Makefile}. The file contents will be
+read in after the first line in @file{Makefile.in} which starts with
+@samp{####}.
+
+These @file{Makefile} fragments are used to customize behaviour for a
+particular host or target. They serve to select particular files to
+compile, and to define particular preprocessor macros by providing
+values for @samp{make} variables which are then used during compilation.
+Cygnus configure, unlike autoconf, normally does not do feature tests,
+and normally requires support to be added manually for each new host.
+
+The @file{Makefile} fragment support is similar to the autoconf
+@samp{AC_SUBST_FILE} macro.
+
+After creating each @file{Makefile}, the post target script will be run
+(i.e., it may be run several times). This script may further customize
+the @file{Makefile}. When it is run, the shell variable @samp{Makefile}
+will hold the name of the @file{Makefile}, including the appropriate
+directory component.
+
+Like an autoconf generated @file{configure} script, Cygnus configure
+will create a file named @file{config.status} which, when run, will
+automatically recreate the configuration. The @file{config.status} file
+will simply execute the Cygnus configure script again with the
+appropriate arguments.
+
+Any of the parts of @file{configure.in} may set the shell variables
+@samp{files} and @samp{links}. Cygnus configure will set up symlinks
+from the names in @samp{links} to the files named in @samp{files}. This
+is similar to the autoconf @samp{AC_LINK_FILES} macro.
+
+Finally, any of the parts of @file{configure.in} may set the shell
+variable @samp{configdirs} to a set of subdirectories. If it is set,
+Cygnus configure will recursively run the configure process in each
+subdirectory. If the subdirectory uses Cygnus configure, it will
+contain a @file{configure.in} file but no @file{configure} file, in
+which case Cygnus configure will invoke itself recursively. If the
+subdirectory has a @file{configure} file, Cygnus configure assumes that
+it is an autoconf generated @file{configure} script, and simply invokes
+it directly.
+
+@node Cygnus Configure in C++ Libraries
+@section Cygnus Configure in C++ Libraries
+@cindex @file{libstdc++} configure
+@cindex @file{libio} configure
+@cindex @file{libg++} configure
+
+The C++ library configure system, written by Per Bothner, deserves
+special mention. It uses Cygnus configure, but it does feature testing
+like that done by autoconf generated @file{configure} scripts. This
+approach is used in the libraries @file{libio}, @file{libstdc++}, and
+@file{libg++}.
+
+Most of the @file{Makefile} information is written out by the shell
+script @file{libio/config.shared}. Each @file{configure.in} file sets
+certain shell variables, and then invokes @file{config.shared} to create
+two package @file{Makefile} fragments. These fragments are then
+incorporated into the resulting @file{Makefile} by the Cygnus configure
+script.
+
+The file @file{_G_config.h} is created in the @file{libio} object
+directory by running the shell script @file{libio/gen-params}. This
+shell script uses feature tests to define macros and typedefs in
+@file{_G_config.h}.
+
+@node Multilibs
+@chapter Multilibs
+@cindex multilibs
+
+For some targets gcc may have different processor requirements depending
+upon command line options. An obvious example is the
+@samp{-msoft-float} option supported on several processors. This option
+means that the floating point registers are not available, which means
+that floating point operations must be done by calling an emulation
+subroutine rather than by using machine instructions.
+
+For such options, gcc is often configured to compile target libraries
+twice: once with @samp{-msoft-float} and once without. When gcc
+compiles target libraries more than once, the resulting libraries are
+called @dfn{multilibs}.
+
+Multilibs are not really part of the GNU configure and build system, but
+we discuss them here since they require support in the @file{configure}
+scripts and @file{Makefile}s used for target libraries.
+
+@menu
+* Multilibs in gcc:: Multilibs in gcc.
+* Multilibs in Target Libraries:: Multilibs in Target Libraries.
+@end menu
+
+@node Multilibs in gcc
+@section Multilibs in gcc
+
+In gcc, multilibs are defined by setting the variable
+@samp{MULTILIB_OPTIONS} in the target @file{Makefile} fragment. Several
+other @samp{MULTILIB} variables may also be defined there. @xref{Target
+Fragment, , The Target Makefile Fragment, gcc, Using and Porting GNU
+CC}.
+
+If you have built gcc, you can see what multilibs it uses by running it
+with the @samp{-print-multi-lib} option. The output @samp{.;} means
+that no multilibs are used. In general, the output is a sequence of
+lines, one per multilib. The first part of each line, up to the
+@samp{;}, is the name of the multilib directory. The second part is a
+list of compiler options separated by @samp{@@} characters.
+
+Multilibs are built in a tree of directories. The top of the tree,
+represented by @samp{.} in the list of multilib directories, is the
+default library to use when no special compiler options are used. The
+subdirectories of the tree hold versions of the library to use when
+particular compiler options are used.
+
+@node Multilibs in Target Libraries
+@section Multilibs in Target Libraries
+
+The target libraries in the Cygnus tree are automatically built with
+multilibs. That means that each library is built multiple times.
+
+This default is set in the top level @file{configure.in} file, by adding
+@samp{--enable-multilib} to the list of arguments passed to configure
+when it is run for the target libraries (@pxref{Host and Target
+Libraries}).
+
+Each target library uses the shell script @file{config-ml.in}, written
+by Doug Evans, to prepare to build target libraries. This shell script
+is invoked after the @file{Makefile} has been created by the
+@file{configure} script. If multilibs are not enabled, it does nothing,
+otherwise it modifies the @file{Makefile} to support multilibs.
+
+The @file{config-ml.in} script makes one copy of the @file{Makefile} for
+each multilib in the appropriate subdirectory. When configuring in the
+source directory (which is not recommended), it will build a symlink
+tree of the sources in each subdirectory.
+
+The @file{config-ml.in} script sets several variables in the various
+@file{Makefile}s. The @file{Makefile.in} must have definitions for
+these variables already; @file{config-ml.in} simply changes the existing
+values. The @file{Makefile} should use default values for these
+variables which will do the right thing in the subdirectories.
+
+@table @samp
+@item MULTISRCTOP
+@file{config-ml.in} will set this to a sequence of @samp{../} strings,
+where the number of strings is the number of multilib levels in the
+source tree. The default value should be the empty string.
+@item MULTIBUILDTOP
+@file{config-ml.in} will set this to a sequence of @samp{../} strings,
+where the number of strings is number of multilib levels in the object
+directory. The default value should be the empty string. This will
+differ from @samp{MULTISRCTOP} when configuring in the source tree
+(which is not recommended).
+@item MULTIDIRS
+In the top level @file{Makefile} only, @file{config-ml.in} will set this
+to the list of multilib subdirectories. The default value should be the
+empty string.
+@item MULTISUBDIR
+@file{config-ml.in} will set this to the installed subdirectory name to
+use for this subdirectory, with a leading @samp{/}. The default value
+shold be the empty string.
+@item MULTIDO
+@itemx MULTICLEAN
+In the top level @file{Makefile} only, @file{config-ml.in} will set
+these variables to commands to use when doing a recursive make. These
+variables should both default to the string @samp{true}, so that by
+default nothing happens.
+@end table
+
+All references to the parent of the source directory should use the
+variable @samp{MULTISRCTOP}. Instead of writing @samp{$(srcdir)/..},
+you must write @samp{$(srcdir)/$(MULTISRCTOP)..}.
+
+Similarly, references to the parent of the object directory should use
+the variable @samp{MULTIBUILDTOP}.
+
+In the installation target, the libraries should be installed in the
+subdirectory @samp{MULTISUBDIR}. Instead of installing
+@samp{$(libdir)/libfoo.a}, install
+@samp{$(libdir)$(MULTISUBDIR)/libfoo.a}.
+
+The @file{config-ml.in} script also modifies the top level
+@file{Makefile} to add @samp{multi-do} and @samp{multi-clean} targets
+which are used when building multilibs.
+
+The default target of the @file{Makefile} should include the following
+command:
+@smallexample
+@@$(MULTIDO) $(FLAGS_TO_PASS) DO=all multi-do
+@end smallexample
+@noindent
+This assumes that @samp{$(FLAGS_TO_PASS)} is defined as a set of
+variables to pass to a recursive invocation of @samp{make}. This will
+build all the multilibs. Note that the default value of @samp{MULTIDO}
+is @samp{true}, so by default this command will do nothing. It will
+only do something in the top level @file{Makefile} if multilibs were
+enabled.
+
+The @samp{install} target of the @file{Makefile} should include the
+following command:
+@smallexample
+@@$(MULTIDO) $(FLAGS_TO_PASS) DO=install multi-do
+@end smallexample
+
+In general, any operation, other than clean, which should be performed
+on all the multilibs should use a @samp{$(MULTIDO)} line, setting the
+variable @samp{DO} to the target of each recursive call to @samp{make}.
+
+The @samp{clean} targets (@samp{clean}, @samp{mostlyclean}, etc.) should
+use @samp{$(MULTICLEAN)}. For example, the @samp{clean} target should
+do this:
+@smallexample
+@@$(MULTICLEAN) DO=clean multi-clean
+@end smallexample
+
+@node FAQ
+@chapter Frequently Asked Questions
+
+@table @asis
+@item Which do I run first, @samp{autoconf} or @samp{automake}?
+Except when you first add autoconf or automake support to a package, you
+shouldn't run either by hand. Instead, configure with the
+@samp{--enable-maintainer-mode} option, and let @samp{make} take care of
+it.
+
+@cindex undefined macros
+@item @samp{autoconf} says something about undefined macros.
+This means that you have macros in your @file{configure.in} which are
+not defined by @samp{autoconf}. You may be using an old version of
+@samp{autoconf}; try building and installing a newer one. Make sure the
+newly installled @samp{autoconf} is first on your @samp{PATH}. Also,
+see the next question.
+
+@cindex @samp{CY_GNU_GETTEXT} in @file{configure}
+@cindex @samp{AM_PROG_LIBTOOL} in @file{configure}
+@item My @file{configure} script has stuff like @samp{CY_GNU_GETTEXT} in it.
+This means that you have macros in your @file{configure.in} which should
+be defined in your @file{aclocal.m4} file, but aren't. This usually
+means that @samp{aclocal} was not able to appropriate definitions of the
+macros. Make sure that you have installed all the packages you need.
+In particular, make sure that you have installed libtool (this is where
+@samp{AM_PROG_LIBTOOL} is defined) and gettext (this is where
+@samp{CY_GNU_GETTEXT} is defined, at least in the Cygnus version of
+gettext).
+
+@cindex @file{Makefile}, garbage characters
+@item My @file{Makefile} has @samp{@@} characters in it.
+This may mean that you tried to use an autoconf substitution in your
+@file{Makefile.in} without adding the appropriate @samp{AC_SUBST} call
+to your @file{configure} script. Or it may just mean that you need to
+rebuild @file{Makefile} in your build directory. To rebuild
+@file{Makefile} from @file{Makefile.in}, run the shell script
+@file{config.status} with no arguments. If you need to force
+@file{configure} to run again, first run @samp{config.status --recheck}.
+These runs are normally done automatically by @file{Makefile} targets,
+but if your @file{Makefile} has gotten messed up you'll need to help
+them along.
+
+@cindex @samp{config.status --recheck}
+@item Why do I have to run both @samp{config.status --recheck} and @samp{config.status}?
+Normally, you don't; they will be run automatically by @file{Makefile}
+targets. If you do need to run them, use @samp{config.status --recheck}
+to run the @file{configure} script again with the same arguments as the
+first time you ran it. Use @samp{config.status} (with no arguments) to
+regenerate all files (@file{Makefile}, @file{config.h}, etc.) based on
+the results of the configure script. The two cases are separate because
+it isn't always necessary to regenerate all the files after running
+@samp{config.status --recheck}. The @file{Makefile} targets generated
+by automake will use the environment variables @samp{CONFIG_FILES} and
+@samp{CONFIG_HEADERS} to only regenerate files as they are needed.
+
+@item What is the Cygnus tree?
+The Cygnus tree is used for various packages including gdb, the GNU
+binutils, and egcs. It is also, of course, used for Cygnus releases.
+It is the build system which was developed at Cygnus, using the Cygnus
+configure script. It permits building many different packages with a
+single configure and make. The configure scripts in the tree are being
+converted to autoconf, but the general build structure remains intact.
+
+@item Why do I have to keep rebuilding and reinstalling the tools?
+I know, it's a pain. Unfortunately, there are bugs in the tools
+themselves which need to be fixed, and each time that happens everybody
+who uses the tools need to reinstall new versions of them. I don't know
+if there is going to be a clever fix until the tools stabilize.
+
+@item Why not just have a Cygnus tree @samp{make} target to update the tools?
+The tools unfortunately need to be installed before they can be used.
+That means that they must be built using an appropriate prefix, and it
+seems unwise to assume that every configuration uses an appropriate
+prefix. It might be possible to make them work in place, or it might be
+possible to install them in some subdirectory; so far these approaches
+have not been implemented.
+@end table
+
+@node Index
+@unnumbered Index
+
+@printindex cp
+
+@contents
+@bye
diff --git a/etc/make-stds.texi b/etc/make-stds.texi
new file mode 100644
index 00000000000..2149764b8e9
--- /dev/null
+++ b/etc/make-stds.texi
@@ -0,0 +1,914 @@
+@comment This file is included by both standards.texi and make.texinfo.
+@comment It was broken out of standards.texi on 1/6/93 by roland.
+
+@node Makefile Conventions
+@chapter Makefile Conventions
+@comment standards.texi does not print an index, but make.texinfo does.
+@cindex makefile, conventions for
+@cindex conventions for makefiles
+@cindex standards for makefiles
+
+This
+@ifinfo
+node
+@end ifinfo
+@iftex
+@ifset CODESTD
+section
+@end ifset
+@ifclear CODESTD
+chapter
+@end ifclear
+@end iftex
+describes conventions for writing the Makefiles for GNU programs.
+
+@menu
+* Makefile Basics:: General Conventions for Makefiles
+* Utilities in Makefiles:: Utilities in Makefiles
+* Command Variables:: Variables for Specifying Commands
+* Directory Variables:: Variables for Installation Directories
+* Standard Targets:: Standard Targets for Users
+* Install Command Categories:: Three categories of commands in the `install'
+ rule: normal, pre-install and post-install.
+@end menu
+
+@node Makefile Basics
+@section General Conventions for Makefiles
+
+Every Makefile should contain this line:
+
+@example
+SHELL = /bin/sh
+@end example
+
+@noindent
+to avoid trouble on systems where the @code{SHELL} variable might be
+inherited from the environment. (This is never a problem with GNU
+@code{make}.)
+
+Different @code{make} programs have incompatible suffix lists and
+implicit rules, and this sometimes creates confusion or misbehavior. So
+it is a good idea to set the suffix list explicitly using only the
+suffixes you need in the particular Makefile, like this:
+
+@example
+.SUFFIXES:
+.SUFFIXES: .c .o
+@end example
+
+@noindent
+The first line clears out the suffix list, the second introduces all
+suffixes which may be subject to implicit rules in this Makefile.
+
+Don't assume that @file{.} is in the path for command execution. When
+you need to run programs that are a part of your package during the
+make, please make sure that it uses @file{./} if the program is built as
+part of the make or @file{$(srcdir)/} if the file is an unchanging part
+of the source code. Without one of these prefixes, the current search
+path is used.
+
+The distinction between @file{./} (the @dfn{build directory}) and
+@file{$(srcdir)/} (the @dfn{source directory}) is important because
+users can build in a separate directory using the @samp{--srcdir} option
+to @file{configure}. A rule of the form:
+
+@smallexample
+foo.1 : foo.man sedscript
+ sed -e sedscript foo.man > foo.1
+@end smallexample
+
+@noindent
+will fail when the build directory is not the source directory, because
+@file{foo.man} and @file{sedscript} are in the the source directory.
+
+When using GNU @code{make}, relying on @samp{VPATH} to find the source
+file will work in the case where there is a single dependency file,
+since the @code{make} automatic variable @samp{$<} will represent the
+source file wherever it is. (Many versions of @code{make} set @samp{$<}
+only in implicit rules.) A Makefile target like
+
+@smallexample
+foo.o : bar.c
+ $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
+@end smallexample
+
+@noindent
+should instead be written as
+
+@smallexample
+foo.o : bar.c
+ $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@@
+@end smallexample
+
+@noindent
+in order to allow @samp{VPATH} to work correctly. When the target has
+multiple dependencies, using an explicit @samp{$(srcdir)} is the easiest
+way to make the rule work well. For example, the target above for
+@file{foo.1} is best written as:
+
+@smallexample
+foo.1 : foo.man sedscript
+ sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@@
+@end smallexample
+
+GNU distributions usually contain some files which are not source
+files---for example, Info files, and the output from Autoconf, Automake,
+Bison or Flex. Since these files normally appear in the source
+directory, they should always appear in the source directory, not in the
+build directory. So Makefile rules to update them should put the
+updated files in the source directory.
+
+However, if a file does not appear in the distribution, then the
+Makefile should not put it in the source directory, because building a
+program in ordinary circumstances should not modify the source directory
+in any way.
+
+Try to make the build and installation targets, at least (and all their
+subtargets) work correctly with a parallel @code{make}.
+
+@node Utilities in Makefiles
+@section Utilities in Makefiles
+
+Write the Makefile commands (and any shell scripts, such as
+@code{configure}) to run in @code{sh}, not in @code{csh}. Don't use any
+special features of @code{ksh} or @code{bash}.
+
+The @code{configure} script and the Makefile rules for building and
+installation should not use any utilities directly except these:
+
+@c dd find
+@c gunzip gzip md5sum
+@c mkfifo mknod tee uname
+
+@example
+cat cmp cp diff echo egrep expr false grep install-info
+ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
+@end example
+
+The compression program @code{gzip} can be used in the @code{dist} rule.
+
+Stick to the generally supported options for these programs. For
+example, don't use @samp{mkdir -p}, convenient as it may be, because
+most systems don't support it.
+
+It is a good idea to avoid creating symbolic links in makefiles, since a
+few systems don't support them.
+
+The Makefile rules for building and installation can also use compilers
+and related programs, but should do so via @code{make} variables so that the
+user can substitute alternatives. Here are some of the programs we
+mean:
+
+@example
+ar bison cc flex install ld ldconfig lex
+make makeinfo ranlib texi2dvi yacc
+@end example
+
+Use the following @code{make} variables to run those programs:
+
+@example
+$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
+$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
+@end example
+
+When you use @code{ranlib} or @code{ldconfig}, you should make sure
+nothing bad happens if the system does not have the program in question.
+Arrange to ignore an error from that command, and print a message before
+the command to tell the user that failure of this command does not mean
+a problem. (The Autoconf @samp{AC_PROG_RANLIB} macro can help with
+this.)
+
+If you use symbolic links, you should implement a fallback for systems
+that don't have symbolic links.
+
+Additional utilities that can be used via Make variables are:
+
+@example
+chgrp chmod chown mknod
+@end example
+
+It is ok to use other utilities in Makefile portions (or scripts)
+intended only for particular systems where you know those utilities
+exist.
+
+@node Command Variables
+@section Variables for Specifying Commands
+
+Makefiles should provide variables for overriding certain commands, options,
+and so on.
+
+In particular, you should run most utility programs via variables.
+Thus, if you use Bison, have a variable named @code{BISON} whose default
+value is set with @samp{BISON = bison}, and refer to it with
+@code{$(BISON)} whenever you need to use Bison.
+
+File management utilities such as @code{ln}, @code{rm}, @code{mv}, and
+so on, need not be referred to through variables in this way, since users
+don't need to replace them with other programs.
+
+Each program-name variable should come with an options variable that is
+used to supply options to the program. Append @samp{FLAGS} to the
+program-name variable name to get the options variable name---for
+example, @code{BISONFLAGS}. (The names @code{CFLAGS} for the C
+compiler, @code{YFLAGS} for yacc, and @code{LFLAGS} for lex, are
+exceptions to this rule, but we keep them because they are standard.)
+Use @code{CPPFLAGS} in any compilation command that runs the
+preprocessor, and use @code{LDFLAGS} in any compilation command that
+does linking as well as in any direct use of @code{ld}.
+
+If there are C compiler options that @emph{must} be used for proper
+compilation of certain files, do not include them in @code{CFLAGS}.
+Users expect to be able to specify @code{CFLAGS} freely themselves.
+Instead, arrange to pass the necessary options to the C compiler
+independently of @code{CFLAGS}, by writing them explicitly in the
+compilation commands or by defining an implicit rule, like this:
+
+@smallexample
+CFLAGS = -g
+ALL_CFLAGS = -I. $(CFLAGS)
+.c.o:
+ $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
+@end smallexample
+
+Do include the @samp{-g} option in @code{CFLAGS}, because that is not
+@emph{required} for proper compilation. You can consider it a default
+that is only recommended. If the package is set up so that it is
+compiled with GCC by default, then you might as well include @samp{-O}
+in the default value of @code{CFLAGS} as well.
+
+Put @code{CFLAGS} last in the compilation command, after other variables
+containing compiler options, so the user can use @code{CFLAGS} to
+override the others.
+
+@code{CFLAGS} should be used in every invocation of the C compiler,
+both those which do compilation and those which do linking.
+
+Every Makefile should define the variable @code{INSTALL}, which is the
+basic command for installing a file into the system.
+
+Every Makefile should also define the variables @code{INSTALL_PROGRAM}
+and @code{INSTALL_DATA}. (The default for each of these should be
+@code{$(INSTALL)}.) Then it should use those variables as the commands
+for actual installation, for executables and nonexecutables
+respectively. Use these variables as follows:
+
+@example
+$(INSTALL_PROGRAM) foo $(bindir)/foo
+$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
+@end example
+
+Optionally, you may prepend the value of @code{DESTDIR} to the target
+filename. Doing this allows the installer to create a snapshot of the
+installation to be copied onto the real target filesystem later. Do not
+set the value of @code{DESTDIR} in your Makefile, and do not include it
+in any installed files. With support for @code{DESTDIR}, the above
+examples become:
+
+@example
+$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
+$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
+@end example
+
+@noindent
+Always use a file name, not a directory name, as the second argument of
+the installation commands. Use a separate command for each file to be
+installed.
+
+@node Directory Variables
+@section Variables for Installation Directories
+
+Installation directories should always be named by variables, so it is
+easy to install in a nonstandard place. The standard names for these
+variables are described below. They are based on a standard filesystem
+layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and
+other modern operating systems.
+
+These two variables set the root for the installation. All the other
+installation directories should be subdirectories of one of these two,
+and nothing should be directly installed into these two directories.
+
+@table @samp
+@item prefix
+A prefix used in constructing the default values of the variables listed
+below. The default value of @code{prefix} should be @file{/usr/local}.
+When building the complete GNU system, the prefix will be empty and
+@file{/usr} will be a symbolic link to @file{/}.
+(If you are using Autoconf, write it as @samp{@@prefix@@}.)
+
+Running @samp{make install} with a different value of @code{prefix}
+from the one used to build the program should @var{not} recompile
+the program.
+
+@item exec_prefix
+A prefix used in constructing the default values of some of the
+variables listed below. The default value of @code{exec_prefix} should
+be @code{$(prefix)}.
+(If you are using Autoconf, write it as @samp{@@exec_prefix@@}.)
+
+Generally, @code{$(exec_prefix)} is used for directories that contain
+machine-specific files (such as executables and subroutine libraries),
+while @code{$(prefix)} is used directly for other directories.
+
+Running @samp{make install} with a different value of @code{exec_prefix}
+from the one used to build the program should @var{not} recompile the
+program.
+@end table
+
+Executable programs are installed in one of the following directories.
+
+@table @samp
+@item bindir
+The directory for installing executable programs that users can run.
+This should normally be @file{/usr/local/bin}, but write it as
+@file{$(exec_prefix)/bin}.
+(If you are using Autoconf, write it as @samp{@@bindir@@}.)
+
+@item sbindir
+The directory for installing executable programs that can be run from
+the shell, but are only generally useful to system administrators. This
+should normally be @file{/usr/local/sbin}, but write it as
+@file{$(exec_prefix)/sbin}.
+(If you are using Autoconf, write it as @samp{@@sbindir@@}.)
+
+@item libexecdir
+@comment This paragraph adjusted to avoid overfull hbox --roland 5jul94
+The directory for installing executable programs to be run by other
+programs rather than by users. This directory should normally be
+@file{/usr/local/libexec}, but write it as @file{$(exec_prefix)/libexec}.
+(If you are using Autoconf, write it as @samp{@@libexecdir@@}.)
+@end table
+
+Data files used by the program during its execution are divided into
+categories in two ways.
+
+@itemize @bullet
+@item
+Some files are normally modified by programs; others are never normally
+modified (though users may edit some of these).
+
+@item
+Some files are architecture-independent and can be shared by all
+machines at a site; some are architecture-dependent and can be shared
+only by machines of the same kind and operating system; others may never
+be shared between two machines.
+@end itemize
+
+This makes for six different possibilities. However, we want to
+discourage the use of architecture-dependent files, aside from object
+files and libraries. It is much cleaner to make other data files
+architecture-independent, and it is generally not hard.
+
+Therefore, here are the variables Makefiles should use to specify
+directories:
+
+@table @samp
+@item datadir
+The directory for installing read-only architecture independent data
+files. This should normally be @file{/usr/local/share}, but write it as
+@file{$(prefix)/share}.
+(If you are using Autoconf, write it as @samp{@@datadir@@}.)
+As a special exception, see @file{$(infodir)}
+and @file{$(includedir)} below.
+
+@item sysconfdir
+The directory for installing read-only data files that pertain to a
+single machine--that is to say, files for configuring a host. Mailer
+and network configuration files, @file{/etc/passwd}, and so forth belong
+here. All the files in this directory should be ordinary ASCII text
+files. This directory should normally be @file{/usr/local/etc}, but
+write it as @file{$(prefix)/etc}.
+(If you are using Autoconf, write it as @samp{@@sysconfdir@@}.)
+
+Do not install executables here in this directory (they probably belong
+in @file{$(libexecdir)} or @file{$(sbindir)}). Also do not install
+files that are modified in the normal course of their use (programs
+whose purpose is to change the configuration of the system excluded).
+Those probably belong in @file{$(localstatedir)}.
+
+@item sharedstatedir
+The directory for installing architecture-independent data files which
+the programs modify while they run. This should normally be
+@file{/usr/local/com}, but write it as @file{$(prefix)/com}.
+(If you are using Autoconf, write it as @samp{@@sharedstatedir@@}.)
+
+@item localstatedir
+The directory for installing data files which the programs modify while
+they run, and that pertain to one specific machine. Users should never
+need to modify files in this directory to configure the package's
+operation; put such configuration information in separate files that go
+in @file{$(datadir)} or @file{$(sysconfdir)}. @file{$(localstatedir)}
+should normally be @file{/usr/local/var}, but write it as
+@file{$(prefix)/var}.
+(If you are using Autoconf, write it as @samp{@@localstatedir@@}.)
+
+@item libdir
+The directory for object files and libraries of object code. Do not
+install executables here, they probably ought to go in @file{$(libexecdir)}
+instead. The value of @code{libdir} should normally be
+@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}.
+(If you are using Autoconf, write it as @samp{@@libdir@@}.)
+
+@item infodir
+The directory for installing the Info files for this package. By
+default, it should be @file{/usr/local/info}, but it should be written
+as @file{$(prefix)/info}.
+(If you are using Autoconf, write it as @samp{@@infodir@@}.)
+
+@item lispdir
+The directory for installing any Emacs Lisp files in this package. By
+default, it should be @file{/usr/local/share/emacs/site-lisp}, but it
+should be written as @file{$(prefix)/share/emacs/site-lisp}.
+
+If you are using Autoconf, write the default as @samp{@@lispdir@@}.
+In order to make @samp{@@lispdir@@} work, you need the following lines
+in your @file{configure.in} file:
+
+@example
+lispdir='$@{datadir@}/emacs/site-lisp'
+AC_SUBST(lispdir)
+@end example
+
+@item includedir
+@c rewritten to avoid overfull hbox --roland
+The directory for installing header files to be included by user
+programs with the C @samp{#include} preprocessor directive. This
+should normally be @file{/usr/local/include}, but write it as
+@file{$(prefix)/include}.
+(If you are using Autoconf, write it as @samp{@@includedir@@}.)
+
+Most compilers other than GCC do not look for header files in directory
+@file{/usr/local/include}. So installing the header files this way is
+only useful with GCC. Sometimes this is not a problem because some
+libraries are only really intended to work with GCC. But some libraries
+are intended to work with other compilers. They should install their
+header files in two places, one specified by @code{includedir} and one
+specified by @code{oldincludedir}.
+
+@item oldincludedir
+The directory for installing @samp{#include} header files for use with
+compilers other than GCC. This should normally be @file{/usr/include}.
+(If you are using Autoconf, you can write it as @samp{@@oldincludedir@@}.)
+
+The Makefile commands should check whether the value of
+@code{oldincludedir} is empty. If it is, they should not try to use
+it; they should cancel the second installation of the header files.
+
+A package should not replace an existing header in this directory unless
+the header came from the same package. Thus, if your Foo package
+provides a header file @file{foo.h}, then it should install the header
+file in the @code{oldincludedir} directory if either (1) there is no
+@file{foo.h} there or (2) the @file{foo.h} that exists came from the Foo
+package.
+
+To tell whether @file{foo.h} came from the Foo package, put a magic
+string in the file---part of a comment---and @code{grep} for that string.
+@end table
+
+Unix-style man pages are installed in one of the following:
+
+@table @samp
+@item mandir
+The top-level directory for installing the man pages (if any) for this
+package. It will normally be @file{/usr/local/man}, but you should
+write it as @file{$(prefix)/man}.
+(If you are using Autoconf, write it as @samp{@@mandir@@}.)
+
+@item man1dir
+The directory for installing section 1 man pages. Write it as
+@file{$(mandir)/man1}.
+@item man2dir
+The directory for installing section 2 man pages. Write it as
+@file{$(mandir)/man2}
+@item @dots{}
+
+@strong{Don't make the primary documentation for any GNU software be a
+man page. Write a manual in Texinfo instead. Man pages are just for
+the sake of people running GNU software on Unix, which is a secondary
+application only.}
+
+@item manext
+The file name extension for the installed man page. This should contain
+a period followed by the appropriate digit; it should normally be @samp{.1}.
+
+@item man1ext
+The file name extension for installed section 1 man pages.
+@item man2ext
+The file name extension for installed section 2 man pages.
+@item @dots{}
+Use these names instead of @samp{manext} if the package needs to install man
+pages in more than one section of the manual.
+@end table
+
+And finally, you should set the following variable:
+
+@table @samp
+@item srcdir
+The directory for the sources being compiled. The value of this
+variable is normally inserted by the @code{configure} shell script.
+(If you are using Autconf, use @samp{srcdir = @@srcdir@@}.)
+@end table
+
+For example:
+
+@smallexample
+@c I have changed some of the comments here slightly to fix an overfull
+@c hbox, so the make manual can format correctly. --roland
+# Common prefix for installation directories.
+# NOTE: This directory must exist when you start the install.
+prefix = /usr/local
+exec_prefix = $(prefix)
+# Where to put the executable for the command `gcc'.
+bindir = $(exec_prefix)/bin
+# Where to put the directories used by the compiler.
+libexecdir = $(exec_prefix)/libexec
+# Where to put the Info files.
+infodir = $(prefix)/info
+@end smallexample
+
+If your program installs a large number of files into one of the
+standard user-specified directories, it might be useful to group them
+into a subdirectory particular to that program. If you do this, you
+should write the @code{install} rule to create these subdirectories.
+
+Do not expect the user to include the subdirectory name in the value of
+any of the variables listed above. The idea of having a uniform set of
+variable names for installation directories is to enable the user to
+specify the exact same values for several different GNU packages. In
+order for this to be useful, all the packages must be designed so that
+they will work sensibly when the user does so.
+
+@node Standard Targets
+@section Standard Targets for Users
+
+All GNU programs should have the following targets in their Makefiles:
+
+@table @samp
+@item all
+Compile the entire program. This should be the default target. This
+target need not rebuild any documentation files; Info files should
+normally be included in the distribution, and DVI files should be made
+only when explicitly asked for.
+
+By default, the Make rules should compile and link with @samp{-g}, so
+that executable programs have debugging symbols. Users who don't mind
+being helpless can strip the executables later if they wish.
+
+@item install
+Compile the program and copy the executables, libraries, and so on to
+the file names where they should reside for actual use. If there is a
+simple test to verify that a program is properly installed, this target
+should run that test.
+
+Do not strip executables when installing them. Devil-may-care users can
+use the @code{install-strip} target to do that.
+
+If possible, write the @code{install} target rule so that it does not
+modify anything in the directory where the program was built, provided
+@samp{make all} has just been done. This is convenient for building the
+program under one user name and installing it under another.
+
+The commands should create all the directories in which files are to be
+installed, if they don't already exist. This includes the directories
+specified as the values of the variables @code{prefix} and
+@code{exec_prefix}, as well as all subdirectories that are needed.
+One way to do this is by means of an @code{installdirs} target
+as described below.
+
+Use @samp{-} before any command for installing a man page, so that
+@code{make} will ignore any errors. This is in case there are systems
+that don't have the Unix man page documentation system installed.
+
+The way to install Info files is to copy them into @file{$(infodir)}
+with @code{$(INSTALL_DATA)} (@pxref{Command Variables}), and then run
+the @code{install-info} program if it is present. @code{install-info}
+is a program that edits the Info @file{dir} file to add or update the
+menu entry for the given Info file; it is part of the Texinfo package.
+Here is a sample rule to install an Info file:
+
+@comment This example has been carefully formatted for the Make manual.
+@comment Please do not reformat it without talking to roland@gnu.ai.mit.edu.
+@smallexample
+$(DESTDIR)$(infodir)/foo.info: foo.info
+ $(POST_INSTALL)
+# There may be a newer info file in . than in srcdir.
+ -if test -f foo.info; then d=.; \
+ else d=$(srcdir); fi; \
+ $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@@; \
+# Run install-info only if it exists.
+# Use `if' instead of just prepending `-' to the
+# line so we notice real errors from install-info.
+# We use `$(SHELL) -c' because some shells do not
+# fail gracefully when there is an unknown command.
+ if $(SHELL) -c 'install-info --version' \
+ >/dev/null 2>&1; then \
+ install-info --dir-file=$(DESTDIR)$(infodir)/dir \
+ $(DESTDIR)$(infodir)/foo.info; \
+ else true; fi
+@end smallexample
+
+When writing the @code{install} target, you must classify all the
+commands into three categories: normal ones, @dfn{pre-installation}
+commands and @dfn{post-installation} commands. @xref{Install Command
+Categories}.
+
+@item uninstall
+Delete all the installed files---the copies that the @samp{install}
+target creates.
+
+This rule should not modify the directories where compilation is done,
+only the directories where files are installed.
+
+The uninstallation commands are divided into three categories, just like
+the installation commands. @xref{Install Command Categories}.
+
+@item install-strip
+Like @code{install}, but strip the executable files while installing
+them. In many cases, the definition of this target can be very simple:
+
+@smallexample
+install-strip:
+ $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
+ install
+@end smallexample
+
+Normally we do not recommend stripping an executable unless you are sure
+the program has no bugs. However, it can be reasonable to install a
+stripped executable for actual execution while saving the unstripped
+executable elsewhere in case there is a bug.
+
+@comment The gratuitous blank line here is to make the table look better
+@comment in the printed Make manual. Please leave it in.
+@item clean
+
+Delete all files from the current directory that are normally created by
+building the program. Don't delete the files that record the
+configuration. Also preserve files that could be made by building, but
+normally aren't because the distribution comes with them.
+
+Delete @file{.dvi} files here if they are not part of the distribution.
+
+@item distclean
+Delete all files from the current directory that are created by
+configuring or building the program. If you have unpacked the source
+and built the program without creating any other files, @samp{make
+distclean} should leave only the files that were in the distribution.
+
+@item mostlyclean
+Like @samp{clean}, but may refrain from deleting a few files that people
+normally don't want to recompile. For example, the @samp{mostlyclean}
+target for GCC does not delete @file{libgcc.a}, because recompiling it
+is rarely necessary and takes a lot of time.
+
+@item maintainer-clean
+Delete almost everything from the current directory that can be
+reconstructed with this Makefile. This typically includes everything
+deleted by @code{distclean}, plus more: C source files produced by
+Bison, tags tables, Info files, and so on.
+
+The reason we say ``almost everything'' is that running the command
+@samp{make maintainer-clean} should not delete @file{configure} even if
+@file{configure} can be remade using a rule in the Makefile. More generally,
+@samp{make maintainer-clean} should not delete anything that needs to
+exist in order to run @file{configure} and then begin to build the
+program. This is the only exception; @code{maintainer-clean} should
+delete everything else that can be rebuilt.
+
+The @samp{maintainer-clean} target is intended to be used by a maintainer of
+the package, not by ordinary users. You may need special tools to
+reconstruct some of the files that @samp{make maintainer-clean} deletes.
+Since these files are normally included in the distribution, we don't
+take care to make them easy to reconstruct. If you find you need to
+unpack the full distribution again, don't blame us.
+
+To help make users aware of this, the commands for the special
+@code{maintainer-clean} target should start with these two:
+
+@smallexample
+@@echo 'This command is intended for maintainers to use; it'
+@@echo 'deletes files that may need special tools to rebuild.'
+@end smallexample
+
+@item TAGS
+Update a tags table for this program.
+@c ADR: how?
+
+@item info
+Generate any Info files needed. The best way to write the rules is as
+follows:
+
+@smallexample
+info: foo.info
+
+foo.info: foo.texi chap1.texi chap2.texi
+ $(MAKEINFO) $(srcdir)/foo.texi
+@end smallexample
+
+@noindent
+You must define the variable @code{MAKEINFO} in the Makefile. It should
+run the @code{makeinfo} program, which is part of the Texinfo
+distribution.
+
+Normally a GNU distribution comes with Info files, and that means the
+Info files are present in the source directory. Therefore, the Make
+rule for an info file should update it in the source directory. When
+users build the package, ordinarily Make will not update the Info files
+because they will already be up to date.
+
+@item dvi
+Generate DVI files for all Texinfo documentation.
+For example:
+
+@smallexample
+dvi: foo.dvi
+
+foo.dvi: foo.texi chap1.texi chap2.texi
+ $(TEXI2DVI) $(srcdir)/foo.texi
+@end smallexample
+
+@noindent
+You must define the variable @code{TEXI2DVI} in the Makefile. It should
+run the program @code{texi2dvi}, which is part of the Texinfo
+distribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real work
+of formatting. @TeX{} is not distributed with Texinfo.} Alternatively,
+write just the dependencies, and allow GNU @code{make} to provide the command.
+
+@item dist
+Create a distribution tar file for this program. The tar file should be
+set up so that the file names in the tar file start with a subdirectory
+name which is the name of the package it is a distribution for. This
+name can include the version number.
+
+For example, the distribution tar file of GCC version 1.40 unpacks into
+a subdirectory named @file{gcc-1.40}.
+
+The easiest way to do this is to create a subdirectory appropriately
+named, use @code{ln} or @code{cp} to install the proper files in it, and
+then @code{tar} that subdirectory.
+
+Compress the tar file file with @code{gzip}. For example, the actual
+distribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}.
+
+The @code{dist} target should explicitly depend on all non-source files
+that are in the distribution, to make sure they are up to date in the
+distribution.
+@ifset CODESTD
+@xref{Releases, , Making Releases}.
+@end ifset
+@ifclear CODESTD
+@xref{Releases, , Making Releases, standards, GNU Coding Standards}.
+@end ifclear
+
+@item check
+Perform self-tests (if any). The user must build the program before
+running the tests, but need not install the program; you should write
+the self-tests so that they work when the program is built but not
+installed.
+@end table
+
+The following targets are suggested as conventional names, for programs
+in which they are useful.
+
+@table @code
+@item installcheck
+Perform installation tests (if any). The user must build and install
+the program before running the tests. You should not assume that
+@file{$(bindir)} is in the search path.
+
+@item installdirs
+It's useful to add a target named @samp{installdirs} to create the
+directories where files are installed, and their parent directories.
+There is a script called @file{mkinstalldirs} which is convenient for
+this; you can find it in the Texinfo package.
+@c It's in /gd/gnu/lib/mkinstalldirs.
+You can use a rule like this:
+
+@comment This has been carefully formatted to look decent in the Make manual.
+@comment Please be sure not to make it extend any further to the right.--roland
+@smallexample
+# Make sure all installation directories (e.g. $(bindir))
+# actually exist by making them if necessary.
+installdirs: mkinstalldirs
+ $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
+ $(libdir) $(infodir) \
+ $(mandir)
+@end smallexample
+
+This rule should not modify the directories where compilation is done.
+It should do nothing but create installation directories.
+@end table
+
+@node Install Command Categories
+@section Install Command Categories
+
+@cindex pre-installation commands
+@cindex post-installation commands
+When writing the @code{install} target, you must classify all the
+commands into three categories: normal ones, @dfn{pre-installation}
+commands and @dfn{post-installation} commands.
+
+Normal commands move files into their proper places, and set their
+modes. They may not alter any files except the ones that come entirely
+from the package they belong to.
+
+Pre-installation and post-installation commands may alter other files;
+in particular, they can edit global configuration files or data bases.
+
+Pre-installation commands are typically executed before the normal
+commands, and post-installation commands are typically run after the
+normal commands.
+
+The most common use for a post-installation command is to run
+@code{install-info}. This cannot be done with a normal command, since
+it alters a file (the Info directory) which does not come entirely and
+solely from the package being installed. It is a post-installation
+command because it needs to be done after the normal command which
+installs the package's Info files.
+
+Most programs don't need any pre-installation commands, but we have the
+feature just in case it is needed.
+
+To classify the commands in the @code{install} rule into these three
+categories, insert @dfn{category lines} among them. A category line
+specifies the category for the commands that follow.
+
+A category line consists of a tab and a reference to a special Make
+variable, plus an optional comment at the end. There are three
+variables you can use, one for each category; the variable name
+specifies the category. Category lines are no-ops in ordinary execution
+because these three Make variables are normally undefined (and you
+@emph{should not} define them in the makefile).
+
+Here are the three possible category lines, each with a comment that
+explains what it means:
+
+@smallexample
+ $(PRE_INSTALL) # @r{Pre-install commands follow.}
+ $(POST_INSTALL) # @r{Post-install commands follow.}
+ $(NORMAL_INSTALL) # @r{Normal commands follow.}
+@end smallexample
+
+If you don't use a category line at the beginning of the @code{install}
+rule, all the commands are classified as normal until the first category
+line. If you don't use any category lines, all the commands are
+classified as normal.
+
+These are the category lines for @code{uninstall}:
+
+@smallexample
+ $(PRE_UNINSTALL) # @r{Pre-uninstall commands follow.}
+ $(POST_UNINSTALL) # @r{Post-uninstall commands follow.}
+ $(NORMAL_UNINSTALL) # @r{Normal commands follow.}
+@end smallexample
+
+Typically, a pre-uninstall command would be used for deleting entries
+from the Info directory.
+
+If the @code{install} or @code{uninstall} target has any dependencies
+which act as subroutines of installation, then you should start
+@emph{each} dependency's commands with a category line, and start the
+main target's commands with a category line also. This way, you can
+ensure that each command is placed in the right category regardless of
+which of the dependencies actually run.
+
+Pre-installation and post-installation commands should not run any
+programs except for these:
+
+@example
+[ basename bash cat chgrp chmod chown cmp cp dd diff echo
+egrep expand expr false fgrep find getopt grep gunzip gzip
+hostname install install-info kill ldconfig ln ls md5sum
+mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
+test touch true uname xargs yes
+@end example
+
+@cindex binary packages
+The reason for distinguishing the commands in this way is for the sake
+of making binary packages. Typically a binary package contains all the
+executables and other files that need to be installed, and has its own
+method of installing them---so it does not need to run the normal
+installation commands. But installing the binary package does need to
+execute the pre-installation and post-installation commands.
+
+Programs to build binary packages work by extracting the
+pre-installation and post-installation commands. Here is one way of
+extracting the pre-installation commands:
+
+@smallexample
+make -n install -o all \
+ PRE_INSTALL=pre-install \
+ POST_INSTALL=post-install \
+ NORMAL_INSTALL=normal-install \
+ | gawk -f pre-install.awk
+@end smallexample
+
+@noindent
+where the file @file{pre-install.awk} could contain this:
+
+@smallexample
+$0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ @{on = 0@}
+on @{print $0@}
+$0 ~ /^\t[ \t]*pre_install[ \t]*$/ @{on = 1@}
+@end smallexample
+
+The resulting file of pre-installation commands is executed as a shell
+script as part of installing the binary package.
diff --git a/etc/standards.texi b/etc/standards.texi
new file mode 100644
index 00000000000..910bf8b0479
--- /dev/null
+++ b/etc/standards.texi
@@ -0,0 +1,3093 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename standards.info
+@settitle GNU Coding Standards
+@c This date is automagically updated when you save this file:
+@set lastupdate March 13, 1998
+@c %**end of header
+
+@ifinfo
+@format
+START-INFO-DIR-ENTRY
+* Standards: (standards). GNU coding standards.
+END-INFO-DIR-ENTRY
+@end format
+@end ifinfo
+
+@c @setchapternewpage odd
+@setchapternewpage off
+
+@c This is used by a cross ref in make-stds.texi
+@set CODESTD 1
+@iftex
+@set CHAPTER chapter
+@end iftex
+@ifinfo
+@set CHAPTER node
+@end ifinfo
+
+@ifinfo
+GNU Coding Standards
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+@end ignore
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Free Software Foundation.
+@end ifinfo
+
+@titlepage
+@title GNU Coding Standards
+@author Richard Stallman
+@author last updated @value{lastupdate}
+@page
+
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1992, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Free Software Foundation.
+@end titlepage
+
+@ifinfo
+@node Top, Preface, (dir), (dir)
+@top Version
+
+Last updated @value{lastupdate}.
+@end ifinfo
+
+@menu
+* Preface:: About the GNU Coding Standards
+* Intellectual Property:: Keeping Free Software Free
+* Design Advice:: General Program Design
+* Program Behavior:: Program Behavior for All Programs
+* Writing C:: Making The Best Use of C
+* Documentation:: Documenting Programs
+* Managing Releases:: The Release Process
+@end menu
+
+@node Preface
+@chapter About the GNU Coding Standards
+
+The GNU Coding Standards were written by Richard Stallman and other GNU
+Project volunteers. Their purpose is to make the GNU system clean,
+consistent, and easy to install. This document can also be read as a
+guide to writing portable, robust and reliable programs. It focuses on
+programs written in C, but many of the rules and principles are useful
+even if you write in another programming language. The rules often
+state reasons for writing in a certain way.
+
+Corrections or suggestions for this document should be sent to
+@email{gnu@@gnu.org}. If you make a suggestion, please include a
+suggested new wording for it; our time is limited. We prefer a context
+diff to the @file{standards.texi} or @file{make-stds.texi} files, but if
+you don't have those files, please mail your suggestion anyway.
+
+This release of the GNU Coding Standards was last updated
+@value{lastupdate}.
+
+@node Intellectual Property
+@chapter Keeping Free Software Free
+
+This @value{CHAPTER} discusses how you can make sure that GNU software
+remains unencumbered.
+
+@menu
+* Reading Non-Free Code:: Referring to Proprietary Programs
+* Contributions:: Accepting Contributions
+@end menu
+
+@node Reading Non-Free Code
+@section Referring to Proprietary Programs
+
+Don't in any circumstances refer to Unix source code for or during
+your work on GNU! (Or to any other proprietary programs.)
+
+If you have a vague recollection of the internals of a Unix program,
+this does not absolutely mean you can't write an imitation of it, but
+do try to organize the imitation internally along different lines,
+because this is likely to make the details of the Unix version
+irrelevant and dissimilar to your results.
+
+For example, Unix utilities were generally optimized to minimize
+memory use; if you go for speed instead, your program will be very
+different. You could keep the entire input file in core and scan it
+there instead of using stdio. Use a smarter algorithm discovered more
+recently than the Unix program. Eliminate use of temporary files. Do
+it in one pass instead of two (we did this in the assembler).
+
+Or, on the contrary, emphasize simplicity instead of speed. For some
+applications, the speed of today's computers makes simpler algorithms
+adequate.
+
+Or go for generality. For example, Unix programs often have static
+tables or fixed-size strings, which make for arbitrary limits; use
+dynamic allocation instead. Make sure your program handles NULs and
+other funny characters in the input files. Add a programming language
+for extensibility and write part of the program in that language.
+
+Or turn some parts of the program into independently usable libraries.
+Or use a simple garbage collector instead of tracking precisely when
+to free memory, or use a new GNU facility such as obstacks.
+
+
+@node Contributions
+@section Accepting Contributions
+
+If someone else sends you a piece of code to add to the program you are
+working on, we need legal papers to use it---the same sort of legal
+papers we will need to get from you. @emph{Each} significant
+contributor to a program must sign some sort of legal papers in order
+for us to have clear title to the program. The main author alone is not
+enough.
+
+So, before adding in any contributions from other people, please tell
+us, so we can arrange to get the papers. Then wait until we tell you
+that we have received the signed papers, before you actually use the
+contribution.
+
+This applies both before you release the program and afterward. If
+you receive diffs to fix a bug, and they make significant changes, we
+need legal papers for that change.
+
+This also applies to comments and documentation files. For copyright
+law, comments and code are just text. Copyright applies to all kinds of
+text, so we need legal papers for all kinds.
+
+You don't need papers for changes of a few lines here or there, since
+they are not significant for copyright purposes. Also, you don't need
+papers if all you get from the suggestion is some ideas, not actual code
+which you use. For example, if you write a different solution to the
+problem, you don't need to get papers.
+
+We know this is frustrating; it's frustrating for us as well. But if
+you don't wait, you are going out on a limb---for example, what if the
+contributor's employer won't sign a disclaimer? You might have to take
+that code out again!
+
+The very worst thing is if you forget to tell us about the other
+contributor. We could be very embarrassed in court some day as a
+result.
+
+We have more detailed advice for maintainers of programs; if you have
+reached the stage of actually maintaining a program for GNU (whether
+released or not), please ask us for a copy.
+
+@node Design Advice
+@chapter General Program Design
+
+This @value{CHAPTER} discusses some of the issues you should take into
+account when designing your program.
+
+@menu
+* Compatibility:: Compatibility with other implementations
+* Using Extensions:: Using non-standard features
+* ANSI C:: Using ANSI C features
+* Source Language:: Using languages other than C
+@end menu
+
+@node Compatibility
+@section Compatibility with Other Implementations
+
+With occasional exceptions, utility programs and libraries for GNU
+should be upward compatible with those in Berkeley Unix, and upward
+compatible with @sc{ansi} C if @sc{ansi} C specifies their behavior, and
+upward compatible with @sc{POSIX} if @sc{POSIX} specifies their
+behavior.
+
+When these standards conflict, it is useful to offer compatibility
+modes for each of them.
+
+@sc{ansi} C and @sc{POSIX} prohibit many kinds of extensions. Feel free
+to make the extensions anyway, and include a @samp{--ansi},
+@samp{--posix}, or @samp{--compatible} option to turn them off.
+However, if the extension has a significant chance of breaking any real
+programs or scripts, then it is not really upward compatible. Try to
+redesign its interface.
+
+Many GNU programs suppress extensions that conflict with POSIX if the
+environment variable @code{POSIXLY_CORRECT} is defined (even if it is
+defined with a null value). Please make your program recognize this
+variable if appropriate.
+
+When a feature is used only by users (not by programs or command
+files), and it is done poorly in Unix, feel free to replace it
+completely with something totally different and better. (For example,
+@code{vi} is replaced with Emacs.) But it is nice to offer a compatible
+feature as well. (There is a free @code{vi} clone, so we offer it.)
+
+Additional useful features not in Berkeley Unix are welcome.
+
+@node Using Extensions
+@section Using Non-standard Features
+
+Many GNU facilities that already exist support a number of convenient
+extensions over the comparable Unix facilities. Whether to use these
+extensions in implementing your program is a difficult question.
+
+On the one hand, using the extensions can make a cleaner program.
+On the other hand, people will not be able to build the program
+unless the other GNU tools are available. This might cause the
+program to work on fewer kinds of machines.
+
+With some extensions, it might be easy to provide both alternatives.
+For example, you can define functions with a ``keyword'' @code{INLINE}
+and define that as a macro to expand into either @code{inline} or
+nothing, depending on the compiler.
+
+In general, perhaps it is best not to use the extensions if you can
+straightforwardly do without them, but to use the extensions if they
+are a big improvement.
+
+An exception to this rule are the large, established programs (such as
+Emacs) which run on a great variety of systems. Such programs would
+be broken by use of GNU extensions.
+
+Another exception is for programs that are used as part of
+compilation: anything that must be compiled with other compilers in
+order to bootstrap the GNU compilation facilities. If these require
+the GNU compiler, then no one can compile them without having them
+installed already. That would be no good.
+
+@node ANSI C
+@section @sc{ansi} C and pre-@sc{ansi} C
+
+Do not ever use the ``trigraph'' feature of @sc{ansi} C.
+
+@sc{ansi} C is widespread enough now that it is ok to write new programs
+that use @sc{ansi} C features (and therefore will not work in
+non-@sc{ansi} compilers). And if a program is already written in
+@sc{ansi} C, there's no need to convert it to support non-@sc{ansi}
+compilers.
+
+However, it is easy to support non-@sc{ansi} compilers in most programs,
+so you might still consider doing so when you write a program. Instead
+of writing function definitions in @sc{ansi} prototype form,
+
+@example
+int
+foo (int x, int y)
+@dots{}
+@end example
+
+@noindent
+write the definition in pre-@sc{ansi} style like this,
+
+@example
+int
+foo (x, y)
+ int x, y;
+@dots{}
+@end example
+
+@noindent
+and use a separate declaration to specify the argument prototype:
+
+@example
+int foo (int, int);
+@end example
+
+You need such a declaration anyway, in a header file, to get the benefit
+of @sc{ansi} C prototypes in all the files where the function is called.
+And once you have it, you lose nothing by writing the function
+definition in the pre-@sc{ansi} style.
+
+If you don't know non-@sc{ansi} C, there's no need to learn it; just
+write in @sc{ansi} C.
+
+@node Source Language
+@section Using Languages Other Than C
+
+Using a language other than C is like using a non-standard feature: it
+will cause trouble for users. Even if GCC supports the other language,
+users may find it inconvenient to have to install the compiler for that
+other language in order to build your program. For example, if you
+write your program in C++, people will have to install the C++ compiler
+in order to compile your program. Thus, it is better if you write in C.
+
+But there are three situations when there is no disadvantage in using
+some other language:
+
+@itemize @bullet
+@item
+It is okay to use another language if your program contains an
+interpreter for that language.
+
+For example, if your program links with GUILE, it is ok to write part of
+the program in Scheme or another language supported by GUILE.
+
+@item
+It is okay to use another language in a tool specifically intended for
+use with that language.
+
+This is okay because the only people who want to build the tool will be
+those who have installed the other language anyway.
+
+@item
+If an application is of interest to a narrow community, then perhaps
+it's not important if the application is inconvenient to install.
+@end itemize
+
+C has one other advantage over C++ and other compiled languages: more
+people know C, so more people will find it easy to read and modify the
+program if it is written in C.
+
+@node Program Behavior
+@chapter Program Behavior for All Programs
+
+This @value{CHAPTER} describes how to write robust software. It also
+describes general standards for error messages, the command line interface,
+and how libraries should behave.
+
+@menu
+* Semantics:: Writing robust programs
+* Libraries:: Library behavior
+* Errors:: Formatting error messages
+* User Interfaces:: Standards for command line interfaces
+* Option Table:: Table of long options.
+* Memory Usage:: When and how to care about memory needs
+@end menu
+
+@node Semantics
+@section Writing Robust Programs
+
+Avoid arbitrary limits on the length or number of @emph{any} data
+structure, including file names, lines, files, and symbols, by allocating
+all data structures dynamically. In most Unix utilities, ``long lines
+are silently truncated''. This is not acceptable in a GNU utility.
+
+Utilities reading files should not drop NUL characters, or any other
+nonprinting characters @emph{including those with codes above 0177}. The
+only sensible exceptions would be utilities specifically intended for
+interface to certain types of printers that can't handle those characters.
+
+Check every system call for an error return, unless you know you wish to
+ignore errors. Include the system error text (from @code{perror} or
+equivalent) in @emph{every} error message resulting from a failing
+system call, as well as the name of the file if any and the name of the
+utility. Just ``cannot open foo.c'' or ``stat failed'' is not
+sufficient.
+
+Check every call to @code{malloc} or @code{realloc} to see if it
+returned zero. Check @code{realloc} even if you are making the block
+smaller; in a system that rounds block sizes to a power of 2,
+@code{realloc} may get a different block if you ask for less space.
+
+In Unix, @code{realloc} can destroy the storage block if it returns
+zero. GNU @code{realloc} does not have this bug: if it fails, the
+original block is unchanged. Feel free to assume the bug is fixed. If
+you wish to run your program on Unix, and wish to avoid lossage in this
+case, you can use the GNU @code{malloc}.
+
+You must expect @code{free} to alter the contents of the block that was
+freed. Anything you want to fetch from the block, you must fetch before
+calling @code{free}.
+
+If @code{malloc} fails in a noninteractive program, make that a fatal
+error. In an interactive program (one that reads commands from the
+user), it is better to abort the command and return to the command
+reader loop. This allows the user to kill other processes to free up
+virtual memory, and then try the command again.
+
+Use @code{getopt_long} to decode arguments, unless the argument syntax
+makes this unreasonable.
+
+When static storage is to be written in during program execution, use
+explicit C code to initialize it. Reserve C initialized declarations
+for data that will not be changed.
+@c ADR: why?
+
+Try to avoid low-level interfaces to obscure Unix data structures (such
+as file directories, utmp, or the layout of kernel memory), since these
+are less likely to work compatibly. If you need to find all the files
+in a directory, use @code{readdir} or some other high-level interface.
+These will be supported compatibly by GNU.
+
+By default, the GNU system will provide the signal handling functions of
+@sc{BSD} and of @sc{POSIX}. So GNU software should be written to use
+these.
+
+In error checks that detect ``impossible'' conditions, just abort.
+There is usually no point in printing any message. These checks
+indicate the existence of bugs. Whoever wants to fix the bugs will have
+to read the source code and run a debugger. So explain the problem with
+comments in the source. The relevant data will be in variables, which
+are easy to examine with the debugger, so there is no point moving them
+elsewhere.
+
+Do not use a count of errors as the exit status for a program.
+@emph{That does not work}, because exit status values are limited to 8
+bits (0 through 255). A single run of the program might have 256
+errors; if you try to return 256 as the exit status, the parent process
+will see 0 as the status, and it will appear that the program succeeded.
+
+If you make temporary files, check the @code{TMPDIR} environment
+variable; if that variable is defined, use the specified directory
+instead of @file{/tmp}.
+
+@node Libraries
+@section Library Behavior
+
+Try to make library functions reentrant. If they need to do dynamic
+storage allocation, at least try to avoid any nonreentrancy aside from
+that of @code{malloc} itself.
+
+Here are certain name conventions for libraries, to avoid name
+conflicts.
+
+Choose a name prefix for the library, more than two characters long.
+All external function and variable names should start with this
+prefix. In addition, there should only be one of these in any given
+library member. This usually means putting each one in a separate
+source file.
+
+An exception can be made when two external symbols are always used
+together, so that no reasonable program could use one without the
+other; then they can both go in the same file.
+
+External symbols that are not documented entry points for the user
+should have names beginning with @samp{_}. They should also contain
+the chosen name prefix for the library, to prevent collisions with
+other libraries. These can go in the same files with user entry
+points if you like.
+
+Static functions and variables can be used as you like and need not
+fit any naming convention.
+
+@node Errors
+@section Formatting Error Messages
+
+Error messages from compilers should look like this:
+
+@example
+@var{source-file-name}:@var{lineno}: @var{message}
+@end example
+
+Error messages from other noninteractive programs should look like this:
+
+@example
+@var{program}:@var{source-file-name}:@var{lineno}: @var{message}
+@end example
+
+@noindent
+when there is an appropriate source file, or like this:
+
+@example
+@var{program}: @var{message}
+@end example
+
+@noindent
+when there is no relevant source file.
+
+In an interactive program (one that is reading commands from a
+terminal), it is better not to include the program name in an error
+message. The place to indicate which program is running is in the
+prompt or with the screen layout. (When the same program runs with
+input from a source other than a terminal, it is not interactive and
+would do best to print error messages using the noninteractive style.)
+
+The string @var{message} should not begin with a capital letter when
+it follows a program name and/or file name. Also, it should not end
+with a period.
+
+Error messages from interactive programs, and other messages such as
+usage messages, should start with a capital letter. But they should not
+end with a period.
+
+@node User Interfaces
+@section Standards for Command Line Interfaces
+
+Please don't make the behavior of a utility depend on the name used
+to invoke it. It is useful sometimes to make a link to a utility
+with a different name, and that should not change what it does.
+
+Instead, use a run time option or a compilation switch or both
+to select among the alternate behaviors.
+
+Likewise, please don't make the behavior of the program depend on the
+type of output device it is used with. Device independence is an
+important principle of the system's design; do not compromise it
+merely to save someone from typing an option now and then.
+
+If you think one behavior is most useful when the output is to a
+terminal, and another is most useful when the output is a file or a
+pipe, then it is usually best to make the default behavior the one that
+is useful with output to a terminal, and have an option for the other
+behavior.
+
+Compatibility requires certain programs to depend on the type of output
+device. It would be disastrous if @code{ls} or @code{sh} did not do so
+in the way all users expect. In some of these cases, we supplement the
+program with a preferred alternate version that does not depend on the
+output device type. For example, we provide a @code{dir} program much
+like @code{ls} except that its default output format is always
+multi-column format.
+
+It is a good idea to follow the @sc{POSIX} guidelines for the
+command-line options of a program. The easiest way to do this is to use
+@code{getopt} to parse them. Note that the GNU version of @code{getopt}
+will normally permit options anywhere among the arguments unless the
+special argument @samp{--} is used. This is not what @sc{POSIX}
+specifies; it is a GNU extension.
+
+Please define long-named options that are equivalent to the
+single-letter Unix-style options. We hope to make GNU more user
+friendly this way. This is easy to do with the GNU function
+@code{getopt_long}.
+
+One of the advantages of long-named options is that they can be
+consistent from program to program. For example, users should be able
+to expect the ``verbose'' option of any GNU program which has one, to be
+spelled precisely @samp{--verbose}. To achieve this uniformity, look at
+the table of common long-option names when you choose the option names
+for your program (@pxref{Option Table}).
+
+It is usually a good idea for file names given as ordinary arguments to
+be input files only; any output files would be specified using options
+(preferably @samp{-o} or @samp{--output}). Even if you allow an output
+file name as an ordinary argument for compatibility, try to provide an
+option as another way to specify it. This will lead to more consistency
+among GNU utilities, and fewer idiosyncracies for users to remember.
+
+All programs should support two standard options: @samp{--version}
+and @samp{--help}.
+
+@table @code
+@item --version
+This option should direct the program to information about its name,
+version, origin and legal status, all on standard output, and then exit
+successfully. Other options and arguments should be ignored once this
+is seen, and the program should not perform its normal function.
+
+The first line is meant to be easy for a program to parse; the version
+number proper starts after the last space. In addition, it contains
+the canonical name for this program, in this format:
+
+@example
+GNU Emacs 19.30
+@end example
+
+@noindent
+The program's name should be a constant string; @emph{don't} compute it
+from @code{argv[0]}. The idea is to state the standard or canonical
+name for the program, not its file name. There are other ways to find
+out the precise file name where a command is found in @code{PATH}.
+
+If the program is a subsidiary part of a larger package, mention the
+package name in parentheses, like this:
+
+@example
+emacsserver (GNU Emacs) 19.30
+@end example
+
+@noindent
+If the package has a version number which is different from this
+program's version number, you can mention the package version number
+just before the close-parenthesis.
+
+If you @strong{need} to mention the version numbers of libraries which
+are distributed separately from the package which contains this program,
+you can do so by printing an additional line of version info for each
+library you want to mention. Use the same format for these lines as for
+the first line.
+
+Please do not mention all of the libraries that the program uses ``just
+for completeness''---that would produce a lot of unhelpful clutter.
+Please mention library version numbers only if you find in practice that
+they are very important to you in debugging.
+
+The following line, after the version number line or lines, should be a
+copyright notice. If more than one copyright notice is called for, put
+each on a separate line.
+
+Next should follow a brief statement that the program is free software,
+and that users are free to copy and change it on certain conditions. If
+the program is covered by the GNU GPL, say so here. Also mention that
+there is no warranty, to the extent permitted by law.
+
+It is ok to finish the output with a list of the major authors of the
+program, as a way of giving credit.
+
+Here's an example of output that follows these rules:
+
+@smallexample
+GNU Emacs 19.34.5
+Copyright (C) 1996 Free Software Foundation, Inc.
+GNU Emacs comes with NO WARRANTY,
+to the extent permitted by law.
+You may redistribute copies of GNU Emacs
+under the terms of the GNU General Public License.
+For more information about these matters,
+see the files named COPYING.
+@end smallexample
+
+You should adapt this to your program, of course, filling in the proper
+year, copyright holder, name of program, and the references to
+distribution terms, and changing the rest of the wording as necessary.
+
+This copyright notice only needs to mention the most recent year in
+which changes were made---there's no need to list the years for previous
+versions' changes. You don't have to mention the name of the program in
+these notices, if that is inconvenient, since it appeared in the first
+line.
+
+@item --help
+This option should output brief documentation for how to invoke the
+program, on standard output, then exit successfully. Other options and
+arguments should be ignored once this is seen, and the program should
+not perform its normal function.
+
+Near the end of the @samp{--help} option's output there should be a line
+that says where to mail bug reports. It should have this format:
+
+@example
+Report bugs to @var{mailing-address}.
+@end example
+@end table
+
+@node Option Table
+@section Table of Long Options
+
+Here is a table of long options used by GNU programs. It is surely
+incomplete, but we aim to list all the options that a new program might
+want to be compatible with. If you use names not already in the table,
+please send @email{gnu@@gnu.org} a list of them, with their
+meanings, so we can update the table.
+
+@c Please leave newlines between items in this table; it's much easier
+@c to update when it isn't completely squashed together and unreadable.
+@c When there is more than one short option for a long option name, put
+@c a semicolon between the lists of the programs that use them, not a
+@c period. --friedman
+
+@table @samp
+@item after-date
+@samp{-N} in @code{tar}.
+
+@item all
+@samp{-a} in @code{du}, @code{ls}, @code{nm}, @code{stty}, @code{uname},
+and @code{unexpand}.
+
+@item all-text
+@samp{-a} in @code{diff}.
+
+@item almost-all
+@samp{-A} in @code{ls}.
+
+@item append
+@samp{-a} in @code{etags}, @code{tee}, @code{time};
+@samp{-r} in @code{tar}.
+
+@item archive
+@samp{-a} in @code{cp}.
+
+@item archive-name
+@samp{-n} in @code{shar}.
+
+@item arglength
+@samp{-l} in @code{m4}.
+
+@item ascii
+@samp{-a} in @code{diff}.
+
+@item assign
+@samp{-v} in @code{gawk}.
+
+@item assume-new
+@samp{-W} in Make.
+
+@item assume-old
+@samp{-o} in Make.
+
+@item auto-check
+@samp{-a} in @code{recode}.
+
+@item auto-pager
+@samp{-a} in @code{wdiff}.
+
+@item auto-reference
+@samp{-A} in @code{ptx}.
+
+@item avoid-wraps
+@samp{-n} in @code{wdiff}.
+
+@item backward-search
+@samp{-B} in @code{ctags}.
+
+@item basename
+@samp{-f} in @code{shar}.
+
+@item batch
+Used in GDB.
+
+@item baud
+Used in GDB.
+
+@item before
+@samp{-b} in @code{tac}.
+
+@item binary
+@samp{-b} in @code{cpio} and @code{diff}.
+
+@item bits-per-code
+@samp{-b} in @code{shar}.
+
+@item block-size
+Used in @code{cpio} and @code{tar}.
+
+@item blocks
+@samp{-b} in @code{head} and @code{tail}.
+
+@item break-file
+@samp{-b} in @code{ptx}.
+
+@item brief
+Used in various programs to make output shorter.
+
+@item bytes
+@samp{-c} in @code{head}, @code{split}, and @code{tail}.
+
+@item c@t{++}
+@samp{-C} in @code{etags}.
+
+@item catenate
+@samp{-A} in @code{tar}.
+
+@item cd
+Used in various programs to specify the directory to use.
+
+@item changes
+@samp{-c} in @code{chgrp} and @code{chown}.
+
+@item classify
+@samp{-F} in @code{ls}.
+
+@item colons
+@samp{-c} in @code{recode}.
+
+@item command
+@samp{-c} in @code{su};
+@samp{-x} in GDB.
+
+@item compare
+@samp{-d} in @code{tar}.
+
+@item compat
+Used in @code{gawk}.
+
+@item compress
+@samp{-Z} in @code{tar} and @code{shar}.
+
+@item concatenate
+@samp{-A} in @code{tar}.
+
+@item confirmation
+@samp{-w} in @code{tar}.
+
+@item context
+Used in @code{diff}.
+
+@item copyleft
+@samp{-W copyleft} in @code{gawk}.
+
+@item copyright
+@samp{-C} in @code{ptx}, @code{recode}, and @code{wdiff};
+@samp{-W copyright} in @code{gawk}.
+
+@item core
+Used in GDB.
+
+@item count
+@samp{-q} in @code{who}.
+
+@item count-links
+@samp{-l} in @code{du}.
+
+@item create
+Used in @code{tar} and @code{cpio}.
+
+@item cut-mark
+@samp{-c} in @code{shar}.
+
+@item cxref
+@samp{-x} in @code{ctags}.
+
+@item date
+@samp{-d} in @code{touch}.
+
+@item debug
+@samp{-d} in Make and @code{m4};
+@samp{-t} in Bison.
+
+@item define
+@samp{-D} in @code{m4}.
+
+@item defines
+@samp{-d} in Bison and @code{ctags}.
+
+@item delete
+@samp{-D} in @code{tar}.
+
+@item dereference
+@samp{-L} in @code{chgrp}, @code{chown}, @code{cpio}, @code{du},
+@code{ls}, and @code{tar}.
+
+@item dereference-args
+@samp{-D} in @code{du}.
+
+@item diacritics
+@samp{-d} in @code{recode}.
+
+@item dictionary-order
+@samp{-d} in @code{look}.
+
+@item diff
+@samp{-d} in @code{tar}.
+
+@item digits
+@samp{-n} in @code{csplit}.
+
+@item directory
+Specify the directory to use, in various programs. In @code{ls}, it
+means to show directories themselves rather than their contents. In
+@code{rm} and @code{ln}, it means to not treat links to directories
+specially.
+
+@item discard-all
+@samp{-x} in @code{strip}.
+
+@item discard-locals
+@samp{-X} in @code{strip}.
+
+@item dry-run
+@samp{-n} in Make.
+
+@item ed
+@samp{-e} in @code{diff}.
+
+@item elide-empty-files
+@samp{-z} in @code{csplit}.
+
+@item end-delete
+@samp{-x} in @code{wdiff}.
+
+@item end-insert
+@samp{-z} in @code{wdiff}.
+
+@item entire-new-file
+@samp{-N} in @code{diff}.
+
+@item environment-overrides
+@samp{-e} in Make.
+
+@item eof
+@samp{-e} in @code{xargs}.
+
+@item epoch
+Used in GDB.
+
+@item error-limit
+Used in @code{makeinfo}.
+
+@item error-output
+@samp{-o} in @code{m4}.
+
+@item escape
+@samp{-b} in @code{ls}.
+
+@item exclude-from
+@samp{-X} in @code{tar}.
+
+@item exec
+Used in GDB.
+
+@item exit
+@samp{-x} in @code{xargs}.
+
+@item exit-0
+@samp{-e} in @code{unshar}.
+
+@item expand-tabs
+@samp{-t} in @code{diff}.
+
+@item expression
+@samp{-e} in @code{sed}.
+
+@item extern-only
+@samp{-g} in @code{nm}.
+
+@item extract
+@samp{-i} in @code{cpio};
+@samp{-x} in @code{tar}.
+
+@item faces
+@samp{-f} in @code{finger}.
+
+@item fast
+@samp{-f} in @code{su}.
+
+@item fatal-warnings
+@samp{-E} in @code{m4}.
+
+@item file
+@samp{-f} in @code{info}, @code{gawk}, Make, @code{mt}, and @code{tar};
+@samp{-n} in @code{sed};
+@samp{-r} in @code{touch}.
+
+@item field-separator
+@samp{-F} in @code{gawk}.
+
+@item file-prefix
+@samp{-b} in Bison.
+
+@item file-type
+@samp{-F} in @code{ls}.
+
+@item files-from
+@samp{-T} in @code{tar}.
+
+@item fill-column
+Used in @code{makeinfo}.
+
+@item flag-truncation
+@samp{-F} in @code{ptx}.
+
+@item fixed-output-files
+@samp{-y} in Bison.
+
+@item follow
+@samp{-f} in @code{tail}.
+
+@item footnote-style
+Used in @code{makeinfo}.
+
+@item force
+@samp{-f} in @code{cp}, @code{ln}, @code{mv}, and @code{rm}.
+
+@item force-prefix
+@samp{-F} in @code{shar}.
+
+@item format
+Used in @code{ls}, @code{time}, and @code{ptx}.
+
+@item freeze-state
+@samp{-F} in @code{m4}.
+
+@item fullname
+Used in GDB.
+
+@item gap-size
+@samp{-g} in @code{ptx}.
+
+@item get
+@samp{-x} in @code{tar}.
+
+@item graphic
+@samp{-i} in @code{ul}.
+
+@item graphics
+@samp{-g} in @code{recode}.
+
+@item group
+@samp{-g} in @code{install}.
+
+@item gzip
+@samp{-z} in @code{tar} and @code{shar}.
+
+@item hashsize
+@samp{-H} in @code{m4}.
+
+@item header
+@samp{-h} in @code{objdump} and @code{recode}
+
+@item heading
+@samp{-H} in @code{who}.
+
+@item help
+Used to ask for brief usage information.
+
+@item here-delimiter
+@samp{-d} in @code{shar}.
+
+@item hide-control-chars
+@samp{-q} in @code{ls}.
+
+@item idle
+@samp{-u} in @code{who}.
+
+@item ifdef
+@samp{-D} in @code{diff}.
+
+@item ignore
+@samp{-I} in @code{ls};
+@samp{-x} in @code{recode}.
+
+@item ignore-all-space
+@samp{-w} in @code{diff}.
+
+@item ignore-backups
+@samp{-B} in @code{ls}.
+
+@item ignore-blank-lines
+@samp{-B} in @code{diff}.
+
+@item ignore-case
+@samp{-f} in @code{look} and @code{ptx};
+@samp{-i} in @code{diff} and @code{wdiff}.
+
+@item ignore-errors
+@samp{-i} in Make.
+
+@item ignore-file
+@samp{-i} in @code{ptx}.
+
+@item ignore-indentation
+@samp{-I} in @code{etags}.
+
+@item ignore-init-file
+@samp{-f} in Oleo.
+
+@item ignore-interrupts
+@samp{-i} in @code{tee}.
+
+@item ignore-matching-lines
+@samp{-I} in @code{diff}.
+
+@item ignore-space-change
+@samp{-b} in @code{diff}.
+
+@item ignore-zeros
+@samp{-i} in @code{tar}.
+
+@item include
+@samp{-i} in @code{etags};
+@samp{-I} in @code{m4}.
+
+@item include-dir
+@samp{-I} in Make.
+
+@item incremental
+@samp{-G} in @code{tar}.
+
+@item info
+@samp{-i}, @samp{-l}, and @samp{-m} in Finger.
+
+@item initial
+@samp{-i} in @code{expand}.
+
+@item initial-tab
+@samp{-T} in @code{diff}.
+
+@item inode
+@samp{-i} in @code{ls}.
+
+@item interactive
+@samp{-i} in @code{cp}, @code{ln}, @code{mv}, @code{rm};
+@samp{-e} in @code{m4};
+@samp{-p} in @code{xargs};
+@samp{-w} in @code{tar}.
+
+@item intermix-type
+@samp{-p} in @code{shar}.
+
+@item jobs
+@samp{-j} in Make.
+
+@item just-print
+@samp{-n} in Make.
+
+@item keep-going
+@samp{-k} in Make.
+
+@item keep-files
+@samp{-k} in @code{csplit}.
+
+@item kilobytes
+@samp{-k} in @code{du} and @code{ls}.
+
+@item language
+@samp{-l} in @code{etags}.
+
+@item less-mode
+@samp{-l} in @code{wdiff}.
+
+@item level-for-gzip
+@samp{-g} in @code{shar}.
+
+@item line-bytes
+@samp{-C} in @code{split}.
+
+@item lines
+Used in @code{split}, @code{head}, and @code{tail}.
+
+@item link
+@samp{-l} in @code{cpio}.
+
+@item lint
+@itemx lint-old
+Used in @code{gawk}.
+
+@item list
+@samp{-t} in @code{cpio};
+@samp{-l} in @code{recode}.
+
+@item list
+@samp{-t} in @code{tar}.
+
+@item literal
+@samp{-N} in @code{ls}.
+
+@item load-average
+@samp{-l} in Make.
+
+@item login
+Used in @code{su}.
+
+@item machine
+No listing of which programs already use this;
+someone should check to
+see if any actually do, and tell @email{gnu@@gnu.org}.
+
+@item macro-name
+@samp{-M} in @code{ptx}.
+
+@item mail
+@samp{-m} in @code{hello} and @code{uname}.
+
+@item make-directories
+@samp{-d} in @code{cpio}.
+
+@item makefile
+@samp{-f} in Make.
+
+@item mapped
+Used in GDB.
+
+@item max-args
+@samp{-n} in @code{xargs}.
+
+@item max-chars
+@samp{-n} in @code{xargs}.
+
+@item max-lines
+@samp{-l} in @code{xargs}.
+
+@item max-load
+@samp{-l} in Make.
+
+@item max-procs
+@samp{-P} in @code{xargs}.
+
+@item mesg
+@samp{-T} in @code{who}.
+
+@item message
+@samp{-T} in @code{who}.
+
+@item minimal
+@samp{-d} in @code{diff}.
+
+@item mixed-uuencode
+@samp{-M} in @code{shar}.
+
+@item mode
+@samp{-m} in @code{install}, @code{mkdir}, and @code{mkfifo}.
+
+@item modification-time
+@samp{-m} in @code{tar}.
+
+@item multi-volume
+@samp{-M} in @code{tar}.
+
+@item name-prefix
+@samp{-a} in Bison.
+
+@item nesting-limit
+@samp{-L} in @code{m4}.
+
+@item net-headers
+@samp{-a} in @code{shar}.
+
+@item new-file
+@samp{-W} in Make.
+
+@item no-builtin-rules
+@samp{-r} in Make.
+
+@item no-character-count
+@samp{-w} in @code{shar}.
+
+@item no-check-existing
+@samp{-x} in @code{shar}.
+
+@item no-common
+@samp{-3} in @code{wdiff}.
+
+@item no-create
+@samp{-c} in @code{touch}.
+
+@item no-defines
+@samp{-D} in @code{etags}.
+
+@item no-deleted
+@samp{-1} in @code{wdiff}.
+
+@item no-dereference
+@samp{-d} in @code{cp}.
+
+@item no-inserted
+@samp{-2} in @code{wdiff}.
+
+@item no-keep-going
+@samp{-S} in Make.
+
+@item no-lines
+@samp{-l} in Bison.
+
+@item no-piping
+@samp{-P} in @code{shar}.
+
+@item no-prof
+@samp{-e} in @code{gprof}.
+
+@item no-regex
+@samp{-R} in @code{etags}.
+
+@item no-sort
+@samp{-p} in @code{nm}.
+
+@item no-split
+Used in @code{makeinfo}.
+
+@item no-static
+@samp{-a} in @code{gprof}.
+
+@item no-time
+@samp{-E} in @code{gprof}.
+
+@item no-timestamp
+@samp{-m} in @code{shar}.
+
+@item no-validate
+Used in @code{makeinfo}.
+
+@item no-wait
+Used in @code{emacsclient}.
+
+@item no-warn
+Used in various programs to inhibit warnings.
+
+@item node
+@samp{-n} in @code{info}.
+
+@item nodename
+@samp{-n} in @code{uname}.
+
+@item nonmatching
+@samp{-f} in @code{cpio}.
+
+@item nstuff
+@samp{-n} in @code{objdump}.
+
+@item null
+@samp{-0} in @code{xargs}.
+
+@item number
+@samp{-n} in @code{cat}.
+
+@item number-nonblank
+@samp{-b} in @code{cat}.
+
+@item numeric-sort
+@samp{-n} in @code{nm}.
+
+@item numeric-uid-gid
+@samp{-n} in @code{cpio} and @code{ls}.
+
+@item nx
+Used in GDB.
+
+@item old-archive
+@samp{-o} in @code{tar}.
+
+@item old-file
+@samp{-o} in Make.
+
+@item one-file-system
+@samp{-l} in @code{tar}, @code{cp}, and @code{du}.
+
+@item only-file
+@samp{-o} in @code{ptx}.
+
+@item only-prof
+@samp{-f} in @code{gprof}.
+
+@item only-time
+@samp{-F} in @code{gprof}.
+
+@item output
+In various programs, specify the output file name.
+
+@item output-prefix
+@samp{-o} in @code{shar}.
+
+@item override
+@samp{-o} in @code{rm}.
+
+@item overwrite
+@samp{-c} in @code{unshar}.
+
+@item owner
+@samp{-o} in @code{install}.
+
+@item paginate
+@samp{-l} in @code{diff}.
+
+@item paragraph-indent
+Used in @code{makeinfo}.
+
+@item parents
+@samp{-p} in @code{mkdir} and @code{rmdir}.
+
+@item pass-all
+@samp{-p} in @code{ul}.
+
+@item pass-through
+@samp{-p} in @code{cpio}.
+
+@item port
+@samp{-P} in @code{finger}.
+
+@item portability
+@samp{-c} in @code{cpio} and @code{tar}.
+
+@item posix
+Used in @code{gawk}.
+
+@item prefix-builtins
+@samp{-P} in @code{m4}.
+
+@item prefix
+@samp{-f} in @code{csplit}.
+
+@item preserve
+Used in @code{tar} and @code{cp}.
+
+@item preserve-environment
+@samp{-p} in @code{su}.
+
+@item preserve-modification-time
+@samp{-m} in @code{cpio}.
+
+@item preserve-order
+@samp{-s} in @code{tar}.
+
+@item preserve-permissions
+@samp{-p} in @code{tar}.
+
+@item print
+@samp{-l} in @code{diff}.
+
+@item print-chars
+@samp{-L} in @code{cmp}.
+
+@item print-data-base
+@samp{-p} in Make.
+
+@item print-directory
+@samp{-w} in Make.
+
+@item print-file-name
+@samp{-o} in @code{nm}.
+
+@item print-symdefs
+@samp{-s} in @code{nm}.
+
+@item printer
+@samp{-p} in @code{wdiff}.
+
+@item prompt
+@samp{-p} in @code{ed}.
+
+@item query-user
+@samp{-X} in @code{shar}.
+
+@item question
+@samp{-q} in Make.
+
+@item quiet
+Used in many programs to inhibit the usual output. @strong{Note:} every
+program accepting @samp{--quiet} should accept @samp{--silent} as a
+synonym.
+
+@item quiet-unshar
+@samp{-Q} in @code{shar}
+
+@item quote-name
+@samp{-Q} in @code{ls}.
+
+@item rcs
+@samp{-n} in @code{diff}.
+
+@item re-interval
+Used in @code{gawk}.
+
+@item read-full-blocks
+@samp{-B} in @code{tar}.
+
+@item readnow
+Used in GDB.
+
+@item recon
+@samp{-n} in Make.
+
+@item record-number
+@samp{-R} in @code{tar}.
+
+@item recursive
+Used in @code{chgrp}, @code{chown}, @code{cp}, @code{ls}, @code{diff},
+and @code{rm}.
+
+@item reference-limit
+Used in @code{makeinfo}.
+
+@item references
+@samp{-r} in @code{ptx}.
+
+@item regex
+@samp{-r} in @code{tac} and @code{etags}.
+
+@item release
+@samp{-r} in @code{uname}.
+
+@item reload-state
+@samp{-R} in @code{m4}.
+
+@item relocation
+@samp{-r} in @code{objdump}.
+
+@item rename
+@samp{-r} in @code{cpio}.
+
+@item replace
+@samp{-i} in @code{xargs}.
+
+@item report-identical-files
+@samp{-s} in @code{diff}.
+
+@item reset-access-time
+@samp{-a} in @code{cpio}.
+
+@item reverse
+@samp{-r} in @code{ls} and @code{nm}.
+
+@item reversed-ed
+@samp{-f} in @code{diff}.
+
+@item right-side-defs
+@samp{-R} in @code{ptx}.
+
+@item same-order
+@samp{-s} in @code{tar}.
+
+@item same-permissions
+@samp{-p} in @code{tar}.
+
+@item save
+@samp{-g} in @code{stty}.
+
+@item se
+Used in GDB.
+
+@item sentence-regexp
+@samp{-S} in @code{ptx}.
+
+@item separate-dirs
+@samp{-S} in @code{du}.
+
+@item separator
+@samp{-s} in @code{tac}.
+
+@item sequence
+Used by @code{recode} to chose files or pipes for sequencing passes.
+
+@item shell
+@samp{-s} in @code{su}.
+
+@item show-all
+@samp{-A} in @code{cat}.
+
+@item show-c-function
+@samp{-p} in @code{diff}.
+
+@item show-ends
+@samp{-E} in @code{cat}.
+
+@item show-function-line
+@samp{-F} in @code{diff}.
+
+@item show-tabs
+@samp{-T} in @code{cat}.
+
+@item silent
+Used in many programs to inhibit the usual output.
+@strong{Note:} every program accepting
+@samp{--silent} should accept @samp{--quiet} as a synonym.
+
+@item size
+@samp{-s} in @code{ls}.
+
+@item sort
+Used in @code{ls}.
+
+@item source
+@samp{-W source} in @code{gawk}.
+
+@item sparse
+@samp{-S} in @code{tar}.
+
+@item speed-large-files
+@samp{-H} in @code{diff}.
+
+@item split-at
+@samp{-E} in @code{unshar}.
+
+@item split-size-limit
+@samp{-L} in @code{shar}.
+
+@item squeeze-blank
+@samp{-s} in @code{cat}.
+
+@item start-delete
+@samp{-w} in @code{wdiff}.
+
+@item start-insert
+@samp{-y} in @code{wdiff}.
+
+@item starting-file
+Used in @code{tar} and @code{diff} to specify which file within
+a directory to start processing with.
+
+@item statistics
+@samp{-s} in @code{wdiff}.
+
+@item stdin-file-list
+@samp{-S} in @code{shar}.
+
+@item stop
+@samp{-S} in Make.
+
+@item strict
+@samp{-s} in @code{recode}.
+
+@item strip
+@samp{-s} in @code{install}.
+
+@item strip-all
+@samp{-s} in @code{strip}.
+
+@item strip-debug
+@samp{-S} in @code{strip}.
+
+@item submitter
+@samp{-s} in @code{shar}.
+
+@item suffix
+@samp{-S} in @code{cp}, @code{ln}, @code{mv}.
+
+@item suffix-format
+@samp{-b} in @code{csplit}.
+
+@item sum
+@samp{-s} in @code{gprof}.
+
+@item summarize
+@samp{-s} in @code{du}.
+
+@item symbolic
+@samp{-s} in @code{ln}.
+
+@item symbols
+Used in GDB and @code{objdump}.
+
+@item synclines
+@samp{-s} in @code{m4}.
+
+@item sysname
+@samp{-s} in @code{uname}.
+
+@item tabs
+@samp{-t} in @code{expand} and @code{unexpand}.
+
+@item tabsize
+@samp{-T} in @code{ls}.
+
+@item terminal
+@samp{-T} in @code{tput} and @code{ul}.
+@samp{-t} in @code{wdiff}.
+
+@item text
+@samp{-a} in @code{diff}.
+
+@item text-files
+@samp{-T} in @code{shar}.
+
+@item time
+Used in @code{ls} and @code{touch}.
+
+@item to-stdout
+@samp{-O} in @code{tar}.
+
+@item total
+@samp{-c} in @code{du}.
+
+@item touch
+@samp{-t} in Make, @code{ranlib}, and @code{recode}.
+
+@item trace
+@samp{-t} in @code{m4}.
+
+@item traditional
+@samp{-t} in @code{hello};
+@samp{-W traditional} in @code{gawk};
+@samp{-G} in @code{ed}, @code{m4}, and @code{ptx}.
+
+@item tty
+Used in GDB.
+
+@item typedefs
+@samp{-t} in @code{ctags}.
+
+@item typedefs-and-c++
+@samp{-T} in @code{ctags}.
+
+@item typeset-mode
+@samp{-t} in @code{ptx}.
+
+@item uncompress
+@samp{-z} in @code{tar}.
+
+@item unconditional
+@samp{-u} in @code{cpio}.
+
+@item undefine
+@samp{-U} in @code{m4}.
+
+@item undefined-only
+@samp{-u} in @code{nm}.
+
+@item update
+@samp{-u} in @code{cp}, @code{ctags}, @code{mv}, @code{tar}.
+
+@item usage
+Used in @code{gawk}; same as @samp{--help}.
+
+@item uuencode
+@samp{-B} in @code{shar}.
+
+@item vanilla-operation
+@samp{-V} in @code{shar}.
+
+@item verbose
+Print more information about progress. Many programs support this.
+
+@item verify
+@samp{-W} in @code{tar}.
+
+@item version
+Print the version number.
+
+@item version-control
+@samp{-V} in @code{cp}, @code{ln}, @code{mv}.
+
+@item vgrind
+@samp{-v} in @code{ctags}.
+
+@item volume
+@samp{-V} in @code{tar}.
+
+@item what-if
+@samp{-W} in Make.
+
+@item whole-size-limit
+@samp{-l} in @code{shar}.
+
+@item width
+@samp{-w} in @code{ls} and @code{ptx}.
+
+@item word-regexp
+@samp{-W} in @code{ptx}.
+
+@item writable
+@samp{-T} in @code{who}.
+
+@item zeros
+@samp{-z} in @code{gprof}.
+@end table
+
+@node Memory Usage
+@section Memory Usage
+
+If it typically uses just a few meg of memory, don't bother making any
+effort to reduce memory usage. For example, if it is impractical for
+other reasons to operate on files more than a few meg long, it is
+reasonable to read entire input files into core to operate on them.
+
+However, for programs such as @code{cat} or @code{tail}, that can
+usefully operate on very large files, it is important to avoid using a
+technique that would artificially limit the size of files it can handle.
+If a program works by lines and could be applied to arbitrary
+user-supplied input files, it should keep only a line in memory, because
+this is not very hard and users will want to be able to operate on input
+files that are bigger than will fit in core all at once.
+
+If your program creates complicated data structures, just make them in
+core and give a fatal error if @code{malloc} returns zero.
+
+@node Writing C
+@chapter Making The Best Use of C
+
+This @value{CHAPTER} provides advice on how best to use the C language
+when writing GNU software.
+
+@menu
+* Formatting:: Formatting Your Source Code
+* Comments:: Commenting Your Work
+* Syntactic Conventions:: Clean Use of C Constructs
+* Names:: Naming Variables and Functions
+* System Portability:: Portability between different operating systems
+* CPU Portability:: Supporting the range of CPU types
+* System Functions:: Portability and ``standard'' library functions
+* Internationalization:: Techniques for internationalization
+* Mmap:: How you can safely use @code{mmap}.
+@end menu
+
+@node Formatting
+@section Formatting Your Source Code
+
+It is important to put the open-brace that starts the body of a C
+function in column zero, and avoid putting any other open-brace or
+open-parenthesis or open-bracket in column zero. Several tools look
+for open-braces in column zero to find the beginnings of C functions.
+These tools will not work on code not formatted that way.
+
+It is also important for function definitions to start the name of the
+function in column zero. This helps people to search for function
+definitions, and may also help certain tools recognize them. Thus,
+the proper format is this:
+
+@example
+static char *
+concat (s1, s2) /* Name starts in column zero here */
+ char *s1, *s2;
+@{ /* Open brace in column zero here */
+ @dots{}
+@}
+@end example
+
+@noindent
+or, if you want to use @sc{ansi} C, format the definition like this:
+
+@example
+static char *
+concat (char *s1, char *s2)
+@{
+ @dots{}
+@}
+@end example
+
+In @sc{ansi} C, if the arguments don't fit nicely on one line,
+split it like this:
+
+@example
+int
+lots_of_args (int an_integer, long a_long, short a_short,
+ double a_double, float a_float)
+@dots{}
+@end example
+
+For the body of the function, we prefer code formatted like this:
+
+@example
+if (x < foo (y, z))
+ haha = bar[4] + 5;
+else
+ @{
+ while (z)
+ @{
+ haha += foo (z, z);
+ z--;
+ @}
+ return ++x + bar ();
+ @}
+@end example
+
+We find it easier to read a program when it has spaces before the
+open-parentheses and after the commas. Especially after the commas.
+
+When you split an expression into multiple lines, split it
+before an operator, not after one. Here is the right way:
+
+@example
+if (foo_this_is_long && bar > win (x, y, z)
+ && remaining_condition)
+@end example
+
+Try to avoid having two operators of different precedence at the same
+level of indentation. For example, don't write this:
+
+@example
+mode = (inmode[j] == VOIDmode
+ || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
+ ? outmode[j] : inmode[j]);
+@end example
+
+Instead, use extra parentheses so that the indentation shows the nesting:
+
+@example
+mode = ((inmode[j] == VOIDmode
+ || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
+ ? outmode[j] : inmode[j]);
+@end example
+
+Insert extra parentheses so that Emacs will indent the code properly.
+For example, the following indentation looks nice if you do it by hand,
+but Emacs would mess it up:
+
+@example
+v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
+ + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
+@end example
+
+But adding a set of parentheses solves the problem:
+
+@example
+v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
+ + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
+@end example
+
+Format do-while statements like this:
+
+@example
+do
+ @{
+ a = foo (a);
+ @}
+while (a > 0);
+@end example
+
+Please use formfeed characters (control-L) to divide the program into
+pages at logical places (but not within a function). It does not matter
+just how long the pages are, since they do not have to fit on a printed
+page. The formfeeds should appear alone on lines by themselves.
+
+
+@node Comments
+@section Commenting Your Work
+
+Every program should start with a comment saying briefly what it is for.
+Example: @samp{fmt - filter for simple filling of text}.
+
+Please write the comments in a GNU program in English, because English
+is the one language that nearly all programmers in all countries can
+read. If you do not write English well, please write comments in
+English as well as you can, then ask other people to help rewrite them.
+If you can't write comments in English, please find someone to work with
+you and translate your comments into English.
+
+Please put a comment on each function saying what the function does,
+what sorts of arguments it gets, and what the possible values of
+arguments mean and are used for. It is not necessary to duplicate in
+words the meaning of the C argument declarations, if a C type is being
+used in its customary fashion. If there is anything nonstandard about
+its use (such as an argument of type @code{char *} which is really the
+address of the second character of a string, not the first), or any
+possible values that would not work the way one would expect (such as,
+that strings containing newlines are not guaranteed to work), be sure
+to say so.
+
+Also explain the significance of the return value, if there is one.
+
+Please put two spaces after the end of a sentence in your comments, so
+that the Emacs sentence commands will work. Also, please write
+complete sentences and capitalize the first word. If a lower-case
+identifier comes at the beginning of a sentence, don't capitalize it!
+Changing the spelling makes it a different identifier. If you don't
+like starting a sentence with a lower case letter, write the sentence
+differently (e.g., ``The identifier lower-case is @dots{}'').
+
+The comment on a function is much clearer if you use the argument
+names to speak about the argument values. The variable name itself
+should be lower case, but write it in upper case when you are speaking
+about the value rather than the variable itself. Thus, ``the inode
+number NODE_NUM'' rather than ``an inode''.
+
+There is usually no purpose in restating the name of the function in
+the comment before it, because the reader can see that for himself.
+There might be an exception when the comment is so long that the function
+itself would be off the bottom of the screen.
+
+There should be a comment on each static variable as well, like this:
+
+@example
+/* Nonzero means truncate lines in the display;
+ zero means continue them. */
+int truncate_lines;
+@end example
+
+Every @samp{#endif} should have a comment, except in the case of short
+conditionals (just a few lines) that are not nested. The comment should
+state the condition of the conditional that is ending, @emph{including
+its sense}. @samp{#else} should have a comment describing the condition
+@emph{and sense} of the code that follows. For example:
+
+@example
+@group
+#ifdef foo
+ @dots{}
+#else /* not foo */
+ @dots{}
+#endif /* not foo */
+@end group
+@group
+#ifdef foo
+ @dots{}
+#endif /* foo */
+@end group
+@end example
+
+@noindent
+but, by contrast, write the comments this way for a @samp{#ifndef}:
+
+@example
+@group
+#ifndef foo
+ @dots{}
+#else /* foo */
+ @dots{}
+#endif /* foo */
+@end group
+@group
+#ifndef foo
+ @dots{}
+#endif /* not foo */
+@end group
+@end example
+
+@node Syntactic Conventions
+@section Clean Use of C Constructs
+
+Please explicitly declare all arguments to functions.
+Don't omit them just because they are @code{int}s.
+
+Declarations of external functions and functions to appear later in the
+source file should all go in one place near the beginning of the file
+(somewhere before the first function definition in the file), or else
+should go in a header file. Don't put @code{extern} declarations inside
+functions.
+
+It used to be common practice to use the same local variables (with
+names like @code{tem}) over and over for different values within one
+function. Instead of doing this, it is better declare a separate local
+variable for each distinct purpose, and give it a name which is
+meaningful. This not only makes programs easier to understand, it also
+facilitates optimization by good compilers. You can also move the
+declaration of each local variable into the smallest scope that includes
+all its uses. This makes the program even cleaner.
+
+Don't use local variables or parameters that shadow global identifiers.
+
+Don't declare multiple variables in one declaration that spans lines.
+Start a new declaration on each line, instead. For example, instead
+of this:
+
+@example
+@group
+int foo,
+ bar;
+@end group
+@end example
+
+@noindent
+write either this:
+
+@example
+int foo, bar;
+@end example
+
+@noindent
+or this:
+
+@example
+int foo;
+int bar;
+@end example
+
+@noindent
+(If they are global variables, each should have a comment preceding it
+anyway.)
+
+When you have an @code{if}-@code{else} statement nested in another
+@code{if} statement, always put braces around the @code{if}-@code{else}.
+Thus, never write like this:
+
+@example
+if (foo)
+ if (bar)
+ win ();
+ else
+ lose ();
+@end example
+
+@noindent
+always like this:
+
+@example
+if (foo)
+ @{
+ if (bar)
+ win ();
+ else
+ lose ();
+ @}
+@end example
+
+If you have an @code{if} statement nested inside of an @code{else}
+statement, either write @code{else if} on one line, like this,
+
+@example
+if (foo)
+ @dots{}
+else if (bar)
+ @dots{}
+@end example
+
+@noindent
+with its @code{then}-part indented like the preceding @code{then}-part,
+or write the nested @code{if} within braces like this:
+
+@example
+if (foo)
+ @dots{}
+else
+ @{
+ if (bar)
+ @dots{}
+ @}
+@end example
+
+Don't declare both a structure tag and variables or typedefs in the
+same declaration. Instead, declare the structure tag separately
+and then use it to declare the variables or typedefs.
+
+Try to avoid assignments inside @code{if}-conditions. For example,
+don't write this:
+
+@example
+if ((foo = (char *) malloc (sizeof *foo)) == 0)
+ fatal ("virtual memory exhausted");
+@end example
+
+@noindent
+instead, write this:
+
+@example
+foo = (char *) malloc (sizeof *foo);
+if (foo == 0)
+ fatal ("virtual memory exhausted");
+@end example
+
+Don't make the program ugly to placate @code{lint}. Please don't insert any
+casts to @code{void}. Zero without a cast is perfectly fine as a null
+pointer constant, except when calling a varargs function.
+
+@node Names
+@section Naming Variables and Functions
+
+The names of global variables and functions in a program serve as
+comments of a sort. So don't choose terse names---instead, look for
+names that give useful information about the meaning of the variable or
+function. In a GNU program, names should be English, like other
+comments.
+
+Local variable names can be shorter, because they are used only within
+one context, where (presumably) comments explain their purpose.
+
+Please use underscores to separate words in a name, so that the Emacs
+word commands can be useful within them. Stick to lower case; reserve
+upper case for macros and @code{enum} constants, and for name-prefixes
+that follow a uniform convention.
+
+For example, you should use names like @code{ignore_space_change_flag};
+don't use names like @code{iCantReadThis}.
+
+Variables that indicate whether command-line options have been
+specified should be named after the meaning of the option, not after
+the option-letter. A comment should state both the exact meaning of
+the option and its letter. For example,
+
+@example
+@group
+/* Ignore changes in horizontal whitespace (-b). */
+int ignore_space_change_flag;
+@end group
+@end example
+
+When you want to define names with constant integer values, use
+@code{enum} rather than @samp{#define}. GDB knows about enumeration
+constants.
+
+Use file names of 14 characters or less, to avoid creating gratuitous
+problems on older System V systems. You can use the program
+@code{doschk} to test for this. @code{doschk} also tests for potential
+name conflicts if the files were loaded onto an MS-DOS file
+system---something you may or may not care about.
+
+@node System Portability
+@section Portability between System Types
+
+In the Unix world, ``portability'' refers to porting to different Unix
+versions. For a GNU program, this kind of portability is desirable, but
+not paramount.
+
+The primary purpose of GNU software is to run on top of the GNU kernel,
+compiled with the GNU C compiler, on various types of @sc{cpu}. The
+amount and kinds of variation among GNU systems on different @sc{cpu}s
+will be comparable to the variation among Linux-based GNU systems or
+among BSD systems today. So the kinds of portability that are absolutely
+necessary are quite limited.
+
+But many users do run GNU software on non-GNU Unix or Unix-like systems.
+So supporting a variety of Unix-like systems is desirable, although not
+paramount.
+
+The easiest way to achieve portability to most Unix-like systems is to
+use Autoconf. It's unlikely that your program needs to know more
+information about the host platform than Autoconf can provide, simply
+because most of the programs that need such knowledge have already been
+written.
+
+Avoid using the format of semi-internal data bases (e.g., directories)
+when there is a higher-level alternative (@code{readdir}).
+
+As for systems that are not like Unix, such as MSDOS, Windows, the
+Macintosh, VMS, and MVS, supporting them is usually so much work that it
+is better if you don't.
+
+The planned GNU kernel is not finished yet, but you can tell which
+facilities it will provide by looking at the GNU C Library Manual. The
+GNU kernel is based on Mach, so the features of Mach will also be
+available. However, if you use Mach features, you'll probably have
+trouble debugging your program today.
+
+@node CPU Portability
+@section Portability between @sc{cpu}s
+
+Even GNU systems will differ because of differences among @sc{cpu}
+types---for example, difference in byte ordering and alignment
+requirements. It is absolutely essential to handle these differences.
+However, don't make any effort to cater to the possibility that an
+@code{int} will be less than 32 bits. We don't support 16-bit machines
+in GNU.
+
+Don't assume that the address of an @code{int} object is also the
+address of its least-significant byte. This is false on big-endian
+machines. Thus, don't make the following mistake:
+
+@example
+int c;
+@dots{}
+while ((c = getchar()) != EOF)
+ write(file_descriptor, &c, 1);
+@end example
+
+When calling functions, you need not worry about the difference between
+pointers of various types, or between pointers and integers. On most
+machines, there's no difference anyway. As for the few machines where
+there is a difference, all of them support @sc{ansi} C, so you can use
+prototypes (conditionalized to be active only in @sc{ansi} C) to make
+the code work on those systems.
+
+In certain cases, it is ok to pass integer and pointer arguments
+indiscriminately to the same function, and use no prototype on any
+system. For example, many GNU programs have error-reporting functions
+that pass their arguments along to @code{printf} and friends:
+
+@example
+error (s, a1, a2, a3)
+ char *s;
+ int a1, a2, a3;
+@{
+ fprintf (stderr, "error: ");
+ fprintf (stderr, s, a1, a2, a3);
+@}
+@end example
+
+@noindent
+In practice, this works on all machines, and it is much simpler than any
+``correct'' alternative. Be sure @emph{not} to use a prototype
+for such functions.
+
+However, avoid casting pointers to integers unless you really need to.
+These assumptions really reduce portability, and in most programs they
+are easy to avoid. In the cases where casting pointers to integers is
+essential---such as, a Lisp interpreter which stores type information as
+well as an address in one word---it is ok to do so, but you'll have to
+make explicit provisions to handle different word sizes.
+
+@node System Functions
+@section Calling System Functions
+
+C implementations differ substantially. @sc{ansi} C reduces but does not
+eliminate the incompatibilities; meanwhile, many users wish to compile
+GNU software with pre-@sc{ansi} compilers. This chapter gives
+recommendations for how to use the more or less standard C library
+functions to avoid unnecessary loss of portability.
+
+@itemize @bullet
+@item
+Don't use the value of @code{sprintf}. It returns the number of
+characters written on some systems, but not on all systems.
+
+@item
+@code{main} should be declared to return type @code{int}. It should
+terminate either by calling @code{exit} or by returning the integer
+status code; make sure it cannot ever return an undefined value.
+
+@item
+Don't declare system functions explicitly.
+
+Almost any declaration for a system function is wrong on some system.
+To minimize conflicts, leave it to the system header files to declare
+system functions. If the headers don't declare a function, let it
+remain undeclared.
+
+While it may seem unclean to use a function without declaring it, in
+practice this works fine for most system library functions on the
+systems where this really happens; thus, the disadvantage is only
+theoretical. By contrast, actual declarations have frequently caused
+actual conflicts.
+
+@item
+If you must declare a system function, don't specify the argument types.
+Use an old-style declaration, not an @sc{ansi} prototype. The more you
+specify about the function, the more likely a conflict.
+
+@item
+In particular, don't unconditionally declare @code{malloc} or
+@code{realloc}.
+
+Most GNU programs use those functions just once, in functions
+conventionally named @code{xmalloc} and @code{xrealloc}. These
+functions call @code{malloc} and @code{realloc}, respectively, and
+check the results.
+
+Because @code{xmalloc} and @code{xrealloc} are defined in your program,
+you can declare them in other files without any risk of type conflict.
+
+On most systems, @code{int} is the same length as a pointer; thus, the
+calls to @code{malloc} and @code{realloc} work fine. For the few
+exceptional systems (mostly 64-bit machines), you can use
+@strong{conditionalized} declarations of @code{malloc} and
+@code{realloc}---or put these declarations in configuration files
+specific to those systems.
+
+@item
+The string functions require special treatment. Some Unix systems have
+a header file @file{string.h}; others have @file{strings.h}. Neither
+file name is portable. There are two things you can do: use Autoconf to
+figure out which file to include, or don't include either file.
+
+@item
+If you don't include either strings file, you can't get declarations for
+the string functions from the header file in the usual way.
+
+That causes less of a problem than you might think. The newer @sc{ansi}
+string functions should be avoided anyway because many systems still
+don't support them. The string functions you can use are these:
+
+@example
+strcpy strncpy strcat strncat
+strlen strcmp strncmp
+strchr strrchr
+@end example
+
+The copy and concatenate functions work fine without a declaration as
+long as you don't use their values. Using their values without a
+declaration fails on systems where the width of a pointer differs from
+the width of @code{int}, and perhaps in other cases. It is trivial to
+avoid using their values, so do that.
+
+The compare functions and @code{strlen} work fine without a declaration
+on most systems, possibly all the ones that GNU software runs on.
+You may find it necessary to declare them @strong{conditionally} on a
+few systems.
+
+The search functions must be declared to return @code{char *}. Luckily,
+there is no variation in the data type they return. But there is
+variation in their names. Some systems give these functions the names
+@code{index} and @code{rindex}; other systems use the names
+@code{strchr} and @code{strrchr}. Some systems support both pairs of
+names, but neither pair works on all systems.
+
+You should pick a single pair of names and use it throughout your
+program. (Nowadays, it is better to choose @code{strchr} and
+@code{strrchr} for new programs, since those are the standard @sc{ansi}
+names.) Declare both of those names as functions returning @code{char
+*}. On systems which don't support those names, define them as macros
+in terms of the other pair. For example, here is what to put at the
+beginning of your file (or in a header) if you want to use the names
+@code{strchr} and @code{strrchr} throughout:
+
+@example
+#ifndef HAVE_STRCHR
+#define strchr index
+#endif
+#ifndef HAVE_STRRCHR
+#define strrchr rindex
+#endif
+
+char *strchr ();
+char *strrchr ();
+@end example
+@end itemize
+
+Here we assume that @code{HAVE_STRCHR} and @code{HAVE_STRRCHR} are
+macros defined in systems where the corresponding functions exist.
+One way to get them properly defined is to use Autoconf.
+
+@node Internationalization
+@section Internationalization
+
+GNU has a library called GNU gettext that makes it easy to translate the
+messages in a program into various languages. You should use this
+library in every program. Use English for the messages as they appear
+in the program, and let gettext provide the way to translate them into
+other languages.
+
+Using GNU gettext involves putting a call to the @code{gettext} macro
+around each string that might need translation---like this:
+
+@example
+printf (gettext ("Processing file `%s'..."));
+@end example
+
+@noindent
+This permits GNU gettext to replace the string @code{"Processing file
+`%s'..."} with a translated version.
+
+Once a program uses gettext, please make a point of writing calls to
+@code{gettext} when you add new strings that call for translation.
+
+Using GNU gettext in a package involves specifying a @dfn{text domain
+name} for the package. The text domain name is used to separate the
+translations for this package from the translations for other packages.
+Normally, the text domain name should be the same as the name of the
+package---for example, @samp{fileutils} for the GNU file utilities.
+
+To enable gettext to work well, avoid writing code that makes
+assumptions about the structure of words or sentences. When you want
+the precise text of a sentence to vary depending on the data, use two or
+more alternative string constants each containing a complete sentences,
+rather than inserting conditionalized words or phrases into a single
+sentence framework.
+
+Here is an example of what not to do:
+
+@example
+printf ("%d file%s processed", nfiles,
+ nfiles != 1 ? "s" : "");
+@end example
+
+@noindent
+The problem with that example is that it assumes that plurals are made
+by adding `s'. If you apply gettext to the format string, like this,
+
+@example
+printf (gettext ("%d file%s processed"), nfiles,
+ nfiles != 1 ? "s" : "");
+@end example
+
+@noindent
+the message can use different words, but it will still be forced to use
+`s' for the plural. Here is a better way:
+
+@example
+printf ((nfiles != 1 ? "%d files processed"
+ : "%d file processed"),
+ nfiles);
+@end example
+
+@noindent
+This way, you can apply gettext to each of the two strings
+independently:
+
+@example
+printf ((nfiles != 1 ? gettext ("%d files processed")
+ : gettext ("%d file processed")),
+ nfiles);
+@end example
+
+@noindent
+This can be any method of forming the plural of the word for ``file'', and
+also handles languages that require agreement in the word for
+``processed''.
+
+A similar problem appears at the level of sentence structure with this
+code:
+
+@example
+printf ("# Implicit rule search has%s been done.\n",
+ f->tried_implicit ? "" : " not");
+@end example
+
+@noindent
+Adding @code{gettext} calls to this code cannot give correct results for
+all languages, because negation in some languages requires adding words
+at more than one place in the sentence. By contrast, adding
+@code{gettext} calls does the job straightfowardly if the code starts
+out like this:
+
+@example
+printf (f->tried_implicit
+ ? "# Implicit rule search has been done.\n",
+ : "# Implicit rule search has not been done.\n");
+@end example
+
+@node Mmap
+@section Mmap
+
+Don't assume that @code{mmap} either works on all files or fails
+for all files. It may work on some files and fail on others.
+
+The proper way to use @code{mmap} is to try it on the specific file for
+which you want to use it---and if @code{mmap} doesn't work, fall back on
+doing the job in another way using @code{read} and @code{write}.
+
+The reason this precaution is needed is that the GNU kernel (the HURD)
+provides a user-extensible file system, in which there can be many
+different kinds of ``ordinary files.'' Many of them support
+@code{mmap}, but some do not. It is important to make programs handle
+all these kinds of files.
+
+@node Documentation
+@chapter Documenting Programs
+
+@menu
+* GNU Manuals:: Writing proper manuals.
+* Manual Structure Details:: Specific structure conventions.
+* NEWS File:: NEWS files supplement manuals.
+* Change Logs:: Recording Changes
+* Man Pages:: Man pages are secondary.
+* Reading other Manuals:: How far you can go in learning
+ from other manuals.
+@end menu
+
+@node GNU Manuals
+@section GNU Manuals
+
+The preferred way to document part of the GNU system is to write a
+manual in the Texinfo formatting language. See the Texinfo manual,
+either the hardcopy, or the on-line version available through
+@code{info} or the Emacs Info subsystem (@kbd{C-h i}).
+
+Programmers often find it most natural to structure the documentation
+following the structure of the implementation, which they know. But
+this structure is not necessarily good for explaining how to use the
+program; it may be irrelevant and confusing for a user.
+
+At every level, from the sentences in a paragraph to the grouping of
+topics into separate manuals, the right way to structure documentation
+is according to the concepts and questions that a user will have in mind
+when reading it. Sometimes this structure of ideas matches the
+structure of the implementation of the software being documented---but
+often they are different. Often the most important part of learning to
+write good documentation is learning to notice when you are structuring
+the documentation like the implementation, and think about better
+alternatives.
+
+For example, each program in the GNU system probably ought to be
+documented in one manual; but this does not mean each program should
+have its own manual. That would be following the structure of the
+implementation, rather than the structure that helps the user
+understand.
+
+Instead, each manual should cover a coherent @emph{topic}. For example,
+instead of a manual for @code{diff} and a manual for @code{diff3}, we
+have one manual for ``comparison of files'' which covers both of those
+programs, as well as @code{cmp}. By documenting these programs
+together, we can make the whole subject clearer.
+
+The manual which discusses a program should document all of the
+program's command-line options and all of its commands. It should give
+examples of their use. But don't organize the manual as a list of
+features. Instead, organize it logically, by subtopics. Address the
+questions that a user will ask when thinking about the job that the
+program does.
+
+In general, a GNU manual should serve both as tutorial and reference.
+It should be set up for convenient access to each topic through Info,
+and for reading straight through (appendixes aside). A GNU manual
+should give a good introduction to a beginner reading through from the
+start, and should also provide all the details that hackers want.
+
+That is not as hard as it first sounds. Arrange each chapter as a
+logical breakdown of its topic, but order the sections, and write their
+text, so that reading the chapter straight through makes sense. Do
+likewise when structuring the book into chapters, and when structuring a
+section into paragraphs. The watchword is, @emph{at each point, address
+the most fundamental and important issue raised by the preceding text.}
+
+If necessary, add extra chapters at the beginning of the manual which
+are purely tutorial and cover the basics of the subject. These provide
+the framework for a beginner to understand the rest of the manual. The
+Bison manual provides a good example of how to do this.
+
+Don't use Unix man pages as a model for how to write GNU documentation;
+most of them are terse, badly structured, and give inadequate
+explanation of the underlying concepts. (There are, of course
+exceptions.) Also Unix man pages use a particular format which is
+different from what we use in GNU manuals.
+
+Please do not use the term ``pathname'' that is used in Unix
+documentation; use ``file name'' (two words) instead. We use the term
+``path'' only for search paths, which are lists of file names.
+
+Please do not use the term ``illegal'' to refer to erroneous input to a
+computer program. Please use ``invalid'' for this, and reserve the term
+``illegal'' for violations of law.
+
+@node Manual Structure Details
+@section Manual Structure Details
+
+The title page of the manual should state the version of the programs or
+packages documented in the manual. The Top node of the manual should
+also contain this information. If the manual is changing more
+frequently than or independent of the program, also state a version
+number for the manual in both of these places.
+
+Each program documented in the manual should should have a node named
+@samp{@var{program} Invocation} or @samp{Invoking @var{program}}. This
+node (together with its subnodes, if any) should describe the program's
+command line arguments and how to run it (the sort of information people
+would look in a man page for). Start with an @samp{@@example}
+containing a template for all the options and arguments that the program
+uses.
+
+Alternatively, put a menu item in some menu whose item name fits one of
+the above patterns. This identifies the node which that item points to
+as the node for this purpose, regardless of the node's actual name.
+
+There will be automatic features for specifying a program name and
+quickly reading just this part of its manual.
+
+If one manual describes several programs, it should have such a node for
+each program described.
+
+@node NEWS File
+@section The NEWS File
+
+In addition to its manual, the package should have a file named
+@file{NEWS} which contains a list of user-visible changes worth
+mentioning. In each new release, add items to the front of the file and
+identify the version they pertain to. Don't discard old items; leave
+them in the file after the newer items. This way, a user upgrading from
+any previous version can see what is new.
+
+If the @file{NEWS} file gets very long, move some of the older items
+into a file named @file{ONEWS} and put a note at the end referring the
+user to that file.
+
+@node Change Logs
+@section Change Logs
+
+Keep a change log to describe all the changes made to program source
+files. The purpose of this is so that people investigating bugs in the
+future will know about the changes that might have introduced the bug.
+Often a new bug can be found by looking at what was recently changed.
+More importantly, change logs can help you eliminate conceptual
+inconsistencies between different parts of a program, by giving you a
+history of how the conflicting concepts arose and who they came from.
+
+@menu
+* Change Log Concepts::
+* Style of Change Logs::
+* Simple Changes::
+* Conditional Changes::
+@end menu
+
+@node Change Log Concepts
+@subsection Change Log Concepts
+
+You can think of the change log as a conceptual ``undo list'' which
+explains how earlier versions were different from the current version.
+People can see the current version; they don't need the change log
+to tell them what is in it. What they want from a change log is a
+clear explanation of how the earlier version differed.
+
+The change log file is normally called @file{ChangeLog} and covers an
+entire directory. Each directory can have its own change log, or a
+directory can use the change log of its parent directory--it's up to
+you.
+
+Another alternative is to record change log information with a version
+control system such as RCS or CVS. This can be converted automatically
+to a @file{ChangeLog} file.
+
+There's no need to describe the full purpose of the changes or how they
+work together. If you think that a change calls for explanation, you're
+probably right. Please do explain it---but please put the explanation
+in comments in the code, where people will see it whenever they see the
+code. For example, ``New function'' is enough for the change log when
+you add a function, because there should be a comment before the
+function definition to explain what it does.
+
+However, sometimes it is useful to write one line to describe the
+overall purpose of a batch of changes.
+
+The easiest way to add an entry to @file{ChangeLog} is with the Emacs
+command @kbd{M-x add-change-log-entry}. An entry should have an
+asterisk, the name of the changed file, and then in parentheses the name
+of the changed functions, variables or whatever, followed by a colon.
+Then describe the changes you made to that function or variable.
+
+@node Style of Change Logs
+@subsection Style of Change Logs
+
+Here are some examples of change log entries:
+
+@example
+* register.el (insert-register): Return nil.
+(jump-to-register): Likewise.
+
+* sort.el (sort-subr): Return nil.
+
+* tex-mode.el (tex-bibtex-file, tex-file, tex-region):
+Restart the tex shell if process is gone or stopped.
+(tex-shell-running): New function.
+
+* expr.c (store_one_arg): Round size up for move_block_to_reg.
+(expand_call): Round up when emitting USE insns.
+* stmt.c (assign_parms): Round size up for move_block_from_reg.
+@end example
+
+It's important to name the changed function or variable in full. Don't
+abbreviate function or variable names, and don't combine them.
+Subsequent maintainers will often search for a function name to find all
+the change log entries that pertain to it; if you abbreviate the name,
+they won't find it when they search.
+
+For example, some people are tempted to abbreviate groups of function
+names by writing @samp{* register.el (@{insert,jump-to@}-register)};
+this is not a good idea, since searching for @code{jump-to-register} or
+@code{insert-register} would not find that entry.
+
+Separate unrelated change log entries with blank lines. When two
+entries represent parts of the same change, so that they work together,
+then don't put blank lines between them. Then you can omit the file
+name and the asterisk when successive entries are in the same file.
+
+@node Simple Changes
+@subsection Simple Changes
+
+Certain simple kinds of changes don't need much detail in the change
+log.
+
+When you change the calling sequence of a function in a simple fashion,
+and you change all the callers of the function, there is no need to make
+individual entries for all the callers that you changed. Just write in
+the entry for the function being called, ``All callers changed.''
+
+@example
+* keyboard.c (Fcommand_execute): New arg SPECIAL.
+All callers changed.
+@end example
+
+When you change just comments or doc strings, it is enough to write an
+entry for the file, without mentioning the functions. Just ``Doc
+fixes'' is enough for the change log.
+
+There's no need to make change log entries for documentation files.
+This is because documentation is not susceptible to bugs that are hard
+to fix. Documentation does not consist of parts that must interact in a
+precisely engineered fashion. To correct an error, you need not know
+the history of the erroneous passage; it is enough to compare what the
+documentation says with the way the program actually works.
+
+@node Conditional Changes
+@subsection Conditional Changes
+
+C programs often contain compile-time @code{#if} conditionals. Many
+changes are conditional; sometimes you add a new definition which is
+entirely contained in a conditional. It is very useful to indicate in
+the change log the conditions for which the change applies.
+
+Our convention for indicating conditional changes is to use square
+brackets around the name of the condition.
+
+Here is a simple example, describing a change which is conditional but
+does not have a function or entity name associated with it:
+
+@example
+* xterm.c [SOLARIS2]: Include string.h.
+@end example
+
+Here is an entry describing a new definition which is entirely
+conditional. This new definition for the macro @code{FRAME_WINDOW_P} is
+used only when @code{HAVE_X_WINDOWS} is defined:
+
+@example
+* frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined.
+@end example
+
+Here is an entry for a change within the function @code{init_display},
+whose definition as a whole is unconditional, but the changes themselves
+are contained in a @samp{#ifdef HAVE_LIBNCURSES} conditional:
+
+@example
+* dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
+@end example
+
+Here is an entry for a change that takes affect only when
+a certain macro is @emph{not} defined:
+
+@example
+(gethostname) [!HAVE_SOCKETS]: Replace with winsock version.
+@end example
+
+@node Man Pages
+@section Man Pages
+
+In the GNU project, man pages are secondary. It is not necessary or
+expected for every GNU program to have a man page, but some of them do.
+It's your choice whether to include a man page in your program.
+
+When you make this decision, consider that supporting a man page
+requires continual effort each time the program is changed. The time
+you spend on the man page is time taken away from more useful work.
+
+For a simple program which changes little, updating the man page may be
+a small job. Then there is little reason not to include a man page, if
+you have one.
+
+For a large program that changes a great deal, updating a man page may
+be a substantial burden. If a user offers to donate a man page, you may
+find this gift costly to accept. It may be better to refuse the man
+page unless the same person agrees to take full responsibility for
+maintaining it---so that you can wash your hands of it entirely. If
+this volunteer later ceases to do the job, then don't feel obliged to
+pick it up yourself; it may be better to withdraw the man page from the
+distribution until someone else agrees to update it.
+
+When a program changes only a little, you may feel that the
+discrepancies are small enough that the man page remains useful without
+updating. If so, put a prominent note near the beginning of the man
+page explaining that you don't maintain it and that the Texinfo manual
+is more authoritative. The note should say how to access the Texinfo
+documentation.
+
+@node Reading other Manuals
+@section Reading other Manuals
+
+There may be non-free books or documentation files that describe the
+program you are documenting.
+
+It is ok to use these documents for reference, just as the author of a
+new algebra textbook can read other books on algebra. A large portion
+of any non-fiction book consists of facts, in this case facts about how
+a certain program works, and these facts are necessarily the same for
+everyone who writes about the subject. But be careful not to copy your
+outline structure, wording, tables or examples from preexisting non-free
+documentation. Copying from free documentation may be ok; please check
+with the FSF about the individual case.
+
+@node Managing Releases
+@chapter The Release Process
+
+Making a release is more than just bundling up your source files in a
+tar file and putting it up for FTP. You should set up your software so
+that it can be configured to run on a variety of systems. Your Makefile
+should conform to the GNU standards described below, and your directory
+layout should also conform to the standards discussed below. Doing so
+makes it easy to include your package into the larger framework of
+all GNU software.
+
+@menu
+* Configuration:: How Configuration Should Work
+* Makefile Conventions:: Makefile Conventions
+* Releases:: Making Releases
+@end menu
+
+@node Configuration
+@section How Configuration Should Work
+
+Each GNU distribution should come with a shell script named
+@code{configure}. This script is given arguments which describe the
+kind of machine and system you want to compile the program for.
+
+The @code{configure} script must record the configuration options so
+that they affect compilation.
+
+One way to do this is to make a link from a standard name such as
+@file{config.h} to the proper configuration file for the chosen system.
+If you use this technique, the distribution should @emph{not} contain a
+file named @file{config.h}. This is so that people won't be able to
+build the program without configuring it first.
+
+Another thing that @code{configure} can do is to edit the Makefile. If
+you do this, the distribution should @emph{not} contain a file named
+@file{Makefile}. Instead, it should include a file @file{Makefile.in} which
+contains the input used for editing. Once again, this is so that people
+won't be able to build the program without configuring it first.
+
+If @code{configure} does write the @file{Makefile}, then @file{Makefile}
+should have a target named @file{Makefile} which causes @code{configure}
+to be rerun, setting up the same configuration that was set up last
+time. The files that @code{configure} reads should be listed as
+dependencies of @file{Makefile}.
+
+All the files which are output from the @code{configure} script should
+have comments at the beginning explaining that they were generated
+automatically using @code{configure}. This is so that users won't think
+of trying to edit them by hand.
+
+The @code{configure} script should write a file named @file{config.status}
+which describes which configuration options were specified when the
+program was last configured. This file should be a shell script which,
+if run, will recreate the same configuration.
+
+The @code{configure} script should accept an option of the form
+@samp{--srcdir=@var{dirname}} to specify the directory where sources are found
+(if it is not the current directory). This makes it possible to build
+the program in a separate directory, so that the actual source directory
+is not modified.
+
+If the user does not specify @samp{--srcdir}, then @code{configure} should
+check both @file{.} and @file{..} to see if it can find the sources. If
+it finds the sources in one of these places, it should use them from
+there. Otherwise, it should report that it cannot find the sources, and
+should exit with nonzero status.
+
+Usually the easy way to support @samp{--srcdir} is by editing a
+definition of @code{VPATH} into the Makefile. Some rules may need to
+refer explicitly to the specified source directory. To make this
+possible, @code{configure} can add to the Makefile a variable named
+@code{srcdir} whose value is precisely the specified directory.
+
+The @code{configure} script should also take an argument which specifies the
+type of system to build the program for. This argument should look like
+this:
+
+@example
+@var{cpu}-@var{company}-@var{system}
+@end example
+
+For example, a Sun 3 might be @samp{m68k-sun-sunos4.1}.
+
+The @code{configure} script needs to be able to decode all plausible
+alternatives for how to describe a machine. Thus, @samp{sun3-sunos4.1}
+would be a valid alias. For many programs, @samp{vax-dec-ultrix} would
+be an alias for @samp{vax-dec-bsd}, simply because the differences
+between Ultrix and @sc{BSD} are rarely noticeable, but a few programs
+might need to distinguish them.
+@c Real 4.4BSD now runs on some Suns.
+
+There is a shell script called @file{config.sub} that you can use
+as a subroutine to validate system types and canonicalize aliases.
+
+Other options are permitted to specify in more detail the software
+or hardware present on the machine, and include or exclude optional
+parts of the package:
+
+@table @samp
+@item --enable-@var{feature}@r{[}=@var{parameter}@r{]}
+Configure the package to build and install an optional user-level
+facility called @var{feature}. This allows users to choose which
+optional features to include. Giving an optional @var{parameter} of
+@samp{no} should omit @var{feature}, if it is built by default.
+
+No @samp{--enable} option should @strong{ever} cause one feature to
+replace another. No @samp{--enable} option should ever substitute one
+useful behavior for another useful behavior. The only proper use for
+@samp{--enable} is for questions of whether to build part of the program
+or exclude it.
+
+@item --with-@var{package}
+@c @r{[}=@var{parameter}@r{]}
+The package @var{package} will be installed, so configure this package
+to work with @var{package}.
+
+@c Giving an optional @var{parameter} of
+@c @samp{no} should omit @var{package}, if it is used by default.
+
+Possible values of @var{package} include
+@samp{gnu-as} (or @samp{gas}), @samp{gnu-ld}, @samp{gnu-libc},
+@samp{gdb},
+@samp{x},
+and
+@samp{x-toolkit}.
+
+Do not use a @samp{--with} option to specify the file name to use to
+find certain files. That is outside the scope of what @samp{--with}
+options are for.
+
+@item --nfp
+The target machine has no floating point processor.
+
+@item --gas
+The target machine assembler is GAS, the GNU assembler.
+This is obsolete; users should use @samp{--with-gnu-as} instead.
+
+@item --x
+The target machine has the X Window System installed.
+This is obsolete; users should use @samp{--with-x} instead.
+@end table
+
+All @code{configure} scripts should accept all of these ``detail''
+options, whether or not they make any difference to the particular
+package at hand. In particular, they should accept any option that
+starts with @samp{--with-} or @samp{--enable-}. This is so users will
+be able to configure an entire GNU source tree at once with a single set
+of options.
+
+You will note that the categories @samp{--with-} and @samp{--enable-}
+are narrow: they @strong{do not} provide a place for any sort of option
+you might think of. That is deliberate. We want to limit the possible
+configuration options in GNU software. We do not want GNU programs to
+have idiosyncratic configuration options.
+
+Packages that perform part of the compilation process may support cross-compilation.
+In such a case, the host and target machines for the program may be
+different. The @code{configure} script should normally treat the
+specified type of system as both the host and the target, thus producing
+a program which works for the same type of machine that it runs on.
+
+The way to build a cross-compiler, cross-assembler, or what have you, is
+to specify the option @samp{--host=@var{hosttype}} when running
+@code{configure}. This specifies the host system without changing the
+type of target system. The syntax for @var{hosttype} is the same as
+described above.
+
+Bootstrapping a cross-compiler requires compiling it on a machine other
+than the host it will run on. Compilation packages accept a
+configuration option @samp{--build=@var{hosttype}} for specifying the
+configuration on which you will compile them, in case that is different
+from the host.
+
+Programs for which cross-operation is not meaningful need not accept the
+@samp{--host} option, because configuring an entire operating system for
+cross-operation is not a meaningful thing.
+
+Some programs have ways of configuring themselves automatically. If
+your program is set up to do this, your @code{configure} script can simply
+ignore most of its arguments.
+
+@comment The makefile standards are in a separate file that is also
+@comment included by make.texinfo. Done by roland@gnu.ai.mit.edu on 1/6/93.
+@comment For this document, turn chapters into sections, etc.
+@lowersections
+@include make-stds.texi
+@raisesections
+
+@node Releases
+@section Making Releases
+
+Package the distribution of @code{Foo version 69.96} up in a gzipped tar
+file with the name @file{foo-69.96.tar.gz}. It should unpack into a
+subdirectory named @file{foo-69.96}.
+
+Building and installing the program should never modify any of the files
+contained in the distribution. This means that all the files that form
+part of the program in any way must be classified into @dfn{source
+files} and @dfn{non-source files}. Source files are written by humans
+and never changed automatically; non-source files are produced from
+source files by programs under the control of the Makefile.
+
+Naturally, all the source files must be in the distribution. It is okay
+to include non-source files in the distribution, provided they are
+up-to-date and machine-independent, so that building the distribution
+normally will never modify them. We commonly include non-source files
+produced by Bison, @code{lex}, @TeX{}, and @code{makeinfo}; this helps avoid
+unnecessary dependencies between our distributions, so that users can
+install whichever packages they want to install.
+
+Non-source files that might actually be modified by building and
+installing the program should @strong{never} be included in the
+distribution. So if you do distribute non-source files, always make
+sure they are up to date when you make a new distribution.
+
+Make sure that the directory into which the distribution unpacks (as
+well as any subdirectories) are all world-writable (octal mode 777).
+This is so that old versions of @code{tar} which preserve the
+ownership and permissions of the files from the tar archive will be
+able to extract all the files even if the user is unprivileged.
+
+Make sure that all the files in the distribution are world-readable.
+
+Make sure that no file name in the distribution is more than 14
+characters long. Likewise, no file created by building the program
+should have a name longer than 14 characters. The reason for this is
+that some systems adhere to a foolish interpretation of the POSIX
+standard, and refuse to open a longer name, rather than truncating as
+they did in the past.
+
+Don't include any symbolic links in the distribution itself. If the tar
+file contains symbolic links, then people cannot even unpack it on
+systems that don't support symbolic links. Also, don't use multiple
+names for one file in different directories, because certain file
+systems cannot handle this and that prevents unpacking the
+distribution.
+
+Try to make sure that all the file names will be unique on MS-DOS. A
+name on MS-DOS consists of up to 8 characters, optionally followed by a
+period and up to three characters. MS-DOS will truncate extra
+characters both before and after the period. Thus,
+@file{foobarhacker.c} and @file{foobarhacker.o} are not ambiguous; they
+are truncated to @file{foobarha.c} and @file{foobarha.o}, which are
+distinct.
+
+Include in your distribution a copy of the @file{texinfo.tex} you used
+to test print any @file{*.texinfo} or @file{*.texi} files.
+
+Likewise, if your program uses small GNU software packages like regex,
+getopt, obstack, or termcap, include them in the distribution file.
+Leaving them out would make the distribution file a little smaller at
+the expense of possible inconvenience to a user who doesn't know what
+other files to get.
+
+@contents
+
+@bye
+Local variables:
+update-date-leading-regexp: "@c This date is automagically updated when you save this file:\n@set lastupdate "
+update-date-trailing-regexp: ""
+eval: (load "/gd/gnuorg/update-date.el")
+eval: (add-hook 'write-file-hooks 'update-date)
+End:
diff --git a/include/COPYING b/include/COPYING
new file mode 100644
index 00000000000..60549be514a
--- /dev/null
+++ b/include/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/include/ChangeLog b/include/ChangeLog
new file mode 100644
index 00000000000..fbadf92fdf4
--- /dev/null
+++ b/include/ChangeLog
@@ -0,0 +1,1527 @@
+1999-04-11 Richard Henderson <rth@cygnus.com>
+
+ * bfdlink.h (bfd_elf_version_expr): Rename `match' to `pattern'.
+ Add `match' callback function.
+
+1999-04-10 Richard Henderson <rth@cygnus.com>
+
+ * bfdlink.h (bfd_link_info): Add no_undefined.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * dis-asm.h: Add prototype for print_insn_mcore.
+
+1999-04-02 Mark Mitchell <mark@codesourcery.com>
+
+ * splay-tree.h (splay_tree_compare_pointers): Declare.
+
+1999-03-30 Mark Mitchell <mark@codesourcery.com>
+
+ * splay-tree.h (splay_tree_compare_ints): Declare.
+
+Wed Mar 24 12:46:29 1999 Andrew Cagney <cagney@amy.cygnus.com>
+
+ * libiberty.h (basename): Cygwin{,32} should have the prototype.
+
+1999-02-22 Jim Lemke <jlemke@cygnus.com>
+
+ * bfdlink.h (bfd_link_info): add field "mpc860c0".
+
+Mon Feb 1 21:05:46 1999 Catherine Moore <clm@cygnus.com>
+
+ * dis-asm.h (print_insn_i386_att): Declare.
+ (print_insn_i386_intel): Declare.
+
+998-12-30 Michael Meissner <meissner@cygnus.com>
+
+ * dis-asm.h (INIT_DISASSEMBLE_INFO_NO_ARCH): Cast STREAM and
+ FPRINTF_FUNC to avoid compiler warnings.
+
+Wed Dec 30 16:07:14 1998 David Taylor <taylor@texas.cygnus.com>
+
+ * dis-asm.h: change void * to PTR (two places).
+
+Mon Dec 14 09:53:31 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * demangle.h: Don't check IN_GCC anymore.
+ * splay-tree.h: Likewise.
+
+Tue Dec 8 00:30:31 1998 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ The following changes were made by Elena Zannoni
+ <ezannoni@kwikemart.cygnus.com> and Edith Epstein
+ <eepstein@sophia.cygnus.com> as part of a project to merge in
+ changes made by HP; HP did not create ChangeLog entries.
+
+ * dis-asm.h (struct disassemble_info): change the type of stream
+ from FILE* to void*, for use with gdb's new type GDB_FILE.
+ (fprintf_ftype): change FILE* parameter type to void*.
+
+ * demangle.h: (DMGL_EDG): new macro for Kuck and Associates
+ (DMGL_STYLE_MASK): modify to include Kuck and Assoc style
+ (demangling_styles): add new edg_demangling style
+ (EDG_DEMANGLING_STYLE_STRING): new macro
+ (EDG_DEMANGLING): new macro
+
+ * demangle.h (DMGL_HP): new macro, for HP/aCC compiler.
+ (DMGL_STYLE_MASK): modify to include new HP's style.
+ (demangling_styles): add new hp_demangling value.
+ (HP_DEMANGLING_STYLE_STRING): new macro.
+ (ARM_DEMANGLING): coerce to int.
+ (HP_DEMANGLING): new macro.
+
+ * hp-symtab.h: rewritten, from HP.
+ (quick_procedure): change type of language field to unsigned int
+ (quick_module): change type of language field to unsigned int
+ (struct dntt_type_svar): add field thread_specific.
+ (hp_language): add languages modcal and dmpascal.
+
+Mon Nov 30 15:25:58 1998 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * elf/sh.h (elf_sh_reloc_type): Add R_SH_FIRST_INVALID_RELOC,
+ R_SH_LAST_INVALID_RELOC, R_SH_SWITCH8 and R_SH_max.
+
+Fri Nov 20 13:14:00 1998 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * libiberty.h (basename): Add prototype for FreeBSD.
+
+Fri Nov 13 19:19:11 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * libiberty.h: Prototype xcalloc.
+
+Sun Nov 8 17:42:25 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * ansidecl.h: Wrap problematic macros with !IN_GCC.
+
+ * demangle.h: Never define PARAMS().
+ * splay-tree.h: Likewise.
+
+Sat Nov 7 18:30:20 1998 Peter Schauer <peter.schauer@regent.e-technik.tu-muenchen.de>
+
+ * dis-asm.h (print_insn_vax): Declare.
+
+Sat Nov 7 16:04:03 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * demangle.h: Don't include gansidecl.h.
+ * splay-tree.h: Likewise.
+
+1998-10-26 16:03 Ulrich Drepper <drepper@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Add new field optimize.
+
+Thu Oct 22 19:58:00 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * splay-tree.h: Wrap function pointer parameter declarations in
+ PARAMS() macro.
+
+1998-10-21 Mark Mitchell <mark@markmitchell.com>
+
+ * splay-tree.h: New file.
+
+Fri Oct 9 00:02:03 1998 Jeffrey A Law (law@cygnus.com)
+
+ * Merge devo and egcs include directories.
+
+Sat Sep 5 12:16:33 1998 Jeffrey A Law (law@cygnus.com)
+
+ * getopt.h, obstack.h: Updated from gcc.
+
+1998-08-03 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * libiberty.h (xexit): Change decl to use modern GCC attribute
+ to indicate exit does not return.
+
+Mon Jun 1 13:48:32 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * obstack.h: Update to latest FSF version.
+
+Tue May 26 20:57:43 1998 Stan Cox <scox@equinox.cygnus.com>
+
+ * elf/sparc.h (EF_SPARC_LEDATA, R_SPARC_32LE): Added.
+
+Tue Feb 24 13:05:02 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * dis-asm.h (disassemble_info): Member `symbol' renamed to `symbols'
+ and made an "asymbol **". New member num_symbols.
+ (INIT_DISASSEMBLE_INFO_NO_ARCH): Update.
+
+Tue Feb 17 12:32:18 1998 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_fetch_register, sim_store_register): Add
+ register length parameter. Functions return actual length of
+ register.
+
+Thu Feb 12 16:29:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * getopt.h: Update to latest FSF version.
+
+Wed Feb 11 16:56:06 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * symcat.h: New file.
+
+Mon Feb 2 17:13:31 1998 Steve Haworth <steve@pm.cse.rmit.EDU.AU>
+
+ * dis-asm.h (print_insn_tic30): Declare.
+
+Thu Jan 22 16:23:59 1998 Fred Fish <fnf@cygnus.com>
+
+ * dis-asm.h: Add flag INSN_HAS_RELOC to tell disassembly
+ function there is a reloc on this line.
+
+Mon Dec 8 11:22:23 1997 Nick Clifton <nickc@cygnus.com>
+
+ * dis-asm.h: Remove prototype of disasm_symaddr() as this function
+ no longer exists.
+
+Tue Dec 2 10:20:53 1997 Nick Clifton <nickc@cygnus.com>
+
+ * dis-asm.h (disasm_symaddr): New prototype.
+
+Mon Dec 1 20:24:18 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * coff/sh.h (R_SH_SWITCH8): New.
+
+Mon Dec 1 11:29:35 1997 Doug Evans <devans@canuck.cygnus.com>
+
+ * callback.h (CB_SYSCALL): Comment out arg names in prototypes.
+
+Wed Nov 26 16:47:58 1997 Michael Meissner <meissner@cygnus.com>
+
+ * callback.h (CB_SYSCALL): Consistantly use names for prototype
+ arguments.
+
+Wed Nov 26 11:39:30 1997 Doug Evans <devans@canuck.cygnus.com>
+
+ * callback.h (CB_SYSCALL): Change byte count arguments to
+ {read,write}_mem to `int'. New member `magic'.
+ (CB_SYSCALL_MAGIC,CB_SYSCALL_INIT): New macros.
+
+Tue Nov 25 01:35:52 1997 Doug Evans <devans@seba.cygnus.com>
+
+ * callback.h (struct stat): Move forward decl up.
+ (host_callback): Pass stat struct pointer to stat,fstat.
+ (CB_SYS_nnn): Reorganize.
+ (CB_SYSCALL): New members p1,p2.
+ (cb_host_to_target_stat): Delete fourth arg.
+
+Sat Nov 22 23:34:15 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_stop_reason): Clarify sim_signalled SIGRC
+ argument.
+
+Mon Nov 17 14:00:51 1997 Doug Evans <devans@seba.cygnus.com>
+
+ * callback.h (CB_TARGET_DEFS_MAP): Renamed from target_defs_map.
+ (host_callback): Add stat, fstat, syscall_map, errno_map, open_map,
+ signal_map, stat_map.
+ (errn_map,open_map): Renamed to cb_init_foo_map.
+ (cb_host_to_target_errno,cb_target_to_host_open): Renamed from
+ host_to_target_errno,target_to_host_open.
+ (cb_read_target_syscall_maps): Add prototype.
+ (cb_target_to_host_syscall): Likewise.
+ (cb_host_to_target_stat): Likewise.
+ (cb_syscall): Likewise.
+ (CB_SYS_{exit,open,close,read,write,lseek,unlink,getpid,kill,fstat,
+ argvlen,argv,chdir,stat,chmod,utime,time}): Define.
+ (CB_SYSCALL): New type.
+ (CB_RC): New enum.
+
+Fri Nov 7 10:34:09 1997 Rob Savoye <rob@darkstar.cygnus.com>
+
+ * libiberty.h: Add extern "C" { so it can be used with C++
+ programs.
+ * remote-sim.h: Add extern "C" { so it can be used with C++
+ programs.
+
+Tue Oct 14 16:07:51 1997 Nick Clifton <nickc@cygnus.com>
+
+ * dis-asm.h (struct disassemble_info): New field
+ 'symbol_at_address_func'.
+ (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialise new field with
+ generic_symbol_at_address.
+
+Mon Oct 13 10:17:15 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h: Clarify sim_read, sim_write MEM argument.
+
+Wed Sep 24 18:03:10 1997 Stu Grossman <grossman@babylon-5.cygnus.com>
+
+ * remote-sim.h (SIM_RC): Add a bunch of new return codes for
+ breakpoint stuff.
+ * Add functions to tell the simulator to set/clear/enable/disable
+ intrinsic breakpoints.
+
+Thu Aug 28 19:41:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * libiberty.h (dupargv): Add prototype.
+
+Tue Aug 26 12:25:49 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_create_inferior): Add ABFD arg. Document.
+
+Mon Aug 25 10:50:51 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_open): Add ABFD arg. Document.
+
+Fri Aug 8 16:43:56 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * dis-asm.h (arc_get_disassembler): Declare.
+
+Wed Jul 30 11:39:50 1997 Per Bothner <bothner@deneb.cygnus.com>
+
+ * demangle.h (DMGL_JAVA): New option to request Java demangling.
+
+Tue Jul 22 17:59:54 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * libiberty.h (PEXECUTE_*): Define.
+ (pexecute, pwait): Declare.
+
+Fri Jun 6 13:02:33 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_kill): Mark as depreciated.
+
+Fri May 23 13:43:41 1997 Fred Fish <fnf@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Add task_link member.
+
+Thu May 22 11:32:49 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h: Review documentation. Clarify restrictions on
+ when functions can be called.
+
+Wed May 21 16:47:53 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_set_profile_size): Add prototype, document as
+ depreciated.
+
+Tue May 20 09:32:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_open): Add callback struct.
+ (sim_set_callbacks): Drop SIM_DESC argument. Document.
+ (sim_size): Remove recently added SIM_DESC argument. Document.
+
+Mon May 19 19:14:44 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h: Pass SD into sim_size.
+
+Thu May 15 01:24:16 1997 Mark Alexander <marka@cygnus.com>
+
+ * obstack.h (obstack_specify_allocation_with_arg, obstack_chunkfun,
+ obstack_freefun): Eliminate compile warnings in gdb.
+
+Tue May 13 10:21:14 1997 Nick Clifton <nickc@cygnus.com>
+
+ * coff/arm.h (constants): Added new flag bits F_APCS_26 and
+ F_APCS_SET for the f_flags field of the filehdr structure. Added new
+ flags: F_APCS26, F_ARM_2, F_ARM_3, F_ARM_7, F_ARM_7T to store
+ information in the flags field of the internal_f structure used by BFD
+ routines.
+
+Tue Apr 22 10:24:34 1997 Fred Fish <fnf@cygnus.com>
+
+ * floatformat.h (floatformat_byteorders): Add comments for previous
+ formats and add floatformat_littlebyte_bigword, primarily for ARM.
+ Add declaration for floatformat_ieee_double_littlebyte_bigword.
+
+Fri Apr 18 13:04:49 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.h (sim_stop): New interface - asynchronous
+ notification of a request to stop / suspend the running
+ simulation.
+
+ * remote-sim.h (enum sim_stop): Add sim_running and sim_polling as
+ states for use internal to simulators.
+
+ * callback.h (struct host_callback_strut): Put a magic number at
+ the end of the struct to allow basic checking.
+ (struct host_callback_struct ): Add poll_quit - so
+ that the console etc can be polled at regular intervals.
+
+Thu Apr 17 02:17:12 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * remote-sim.h (struct _bfd): Declare.
+ (sim_load): Return SIM_RC. New arg `abfd'.
+ (sim_create_inferior): Return SIM_RC. Delete arg `start_address'.
+
+Wed Apr 2 17:09:12 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * remote-sim.h (sim_trace, sim_size): Make these global. They
+ will go away shortly.
+
+Wed Apr 2 15:23:49 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * remote-sim.h (SIM_OPEN_KIND, SIM_RC): New enums.
+ (sim_open): New argument `kind'.
+
+Wed Apr 2 14:45:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * COPYING: Update FSF address.
+
+Fri Mar 28 15:29:54 1997 Mike Meissner <meissner@cygnus.com>
+
+ * callback.h (top level): Include stdarg.h or varargs.h if
+ va_start is not defined.
+ (host_callback_struct): Make {,e}vprintf_filtered take a va_list
+ instead of void *, since va_list might be an array or structure
+ type.
+
+Fri Mar 28 15:44:41 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * libiberty.h (basename): Add prototype for glibc and linux.
+
+Mon Mar 17 19:22:12 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * objalloc.h: New file.
+
+Mon Mar 17 14:57:55 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * remote-sim.h: New file, copied in from gdb/remote-sim.h. One
+ day this will be placed in a directory of its own.
+
+Sat Mar 15 19:00:14 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * obstack.h: Update to current FSF version.
+
+Thu Mar 6 15:46:59 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * callback.h (struct host_callback_struct): Add callbacks -
+ flush_stdout, write_stderr, flush_stderr, vprintf_filtered,
+ evprintf_filtered. Delete redundant callbacks - printf_filtered.
+
+Thu Feb 27 23:18:27 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Remove lprefix and lprefix_len
+ fields.
+
+Tue Feb 25 00:10:49 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * dis-asm.h (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialize
+ bytes_per_chunk and display_endian.
+
+Mon Feb 24 17:47:02 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Eric Youngdale <eric@andante.jic.com>:
+ * bfdlink.h (struct bfd_elf_version_expr): Define.
+ (struct bfd_elf_version_deps): Define.
+ (struct bfd_elf_version_tree): Define.
+
+Thu Feb 6 14:20:01 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * dis-asm.h: (disassemble_info): Add new fields
+ bytes_per_chunk and display_endian to control the
+ display of raw instructions.
+
+Fri Dec 27 22:17:37 1996 Fred Fish <fnf@cygnus.com>
+
+ * dis-asm.h (print_insn_tic80): Declare.
+
+Sun Dec 8 17:11:12 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * callback.h (host_callback): New member `error'.
+
+Wed Nov 20 00:40:23 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * callback.h: New file, moved here from gdb.
+
+Mon Nov 18 16:34:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * libiberty.h: Checkin again; last checkin failed due to sticky tag.
+
+Wed Nov 13 08:22:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * libiberty.h: Revert last commit due to conflicts with hpux
+ system headers.
+
+Tue Nov 12 16:31:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * libiberty.h: Move prototypes from argv.c here.
+
+Thu Oct 31 14:56:18 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * ansidecl.h (VPARAMS,VA_START): Define.
+
+Fri Oct 25 12:08:04 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * dis-asm.h (disassemble_info): Add bytes_per_line field.
+ (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialize bytes_per_line field.
+
+Thu Oct 24 17:10:01 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * dis-asm.h (disassemble_info): Add symbol field.
+ (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialize symbol field.
+
+Thu Oct 17 11:17:40 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * dis-asm.h (print_insn_m32r): Declare.
+
+Mon Oct 14 23:56:52 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * libiberty.h: Declare parameter types for xmalloc and xrealloc.
+
+Thu Oct 3 13:45:27 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * fnmatch.h: New file.
+
+Thu Oct 3 10:33:14 1996 Jeffrey A Law (law@cygnus.com)
+
+ * dis-asm.h (print_insn_mn10x00): Delete declaration.
+ (print_insn_mn10200, print_insn_mn10300): Declare.
+
+Wed Oct 2 21:24:43 1996 Jeffrey A Law (law@cygnus.com)
+
+ * dis-asm.h (print_insn_mn10x00): Declare.
+
+Mon Sep 30 13:56:11 1996 Fred Fish <fnf@cygnus.com>
+
+ * libiberty.h: Remove #ifndef PRIVATE_XMALLOC.
+
+Sat Aug 31 13:27:06 1996 Jeffrey A Law (law@cygnus.com)
+
+ * dis-asm.h (print_insn_v850): Declare.
+
+Tue Aug 13 16:10:30 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * obstack.h: Change bcopy to memcpy. Works better on Posix
+ systems, which generally lack bcopy.
+
+Mon Aug 12 17:03:18 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * ansidecl.h: Change WIN32 to _WIN32.
+
+Fri Jul 26 13:58:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * dis-asm.h: Add flavour field.
+ (print_insn_alpha): Declare.
+ (print_insn_alpha_osf, print_insn_alpha_vms): Don't declare.
+ (INIT_DISASSEMBLE_INFO): Initialize flavour field.
+
+Tue Jul 23 17:37:58 1996 Fred Fish <fnf@cygnus.com>
+
+ * libiberty.h (PRIVATE_XMALLOC): Enclose xmalloc/xrealloc
+ definitions inside #ifndef so that programs that want to
+ can define PRIVATE_XMALLOC and then define xmalloc and
+ xrealloc anyway they want.
+ (basename): Document in source that we can't declare the
+ parameter type because it is declared inconsistently across
+ different systems.
+
+Mon Jul 22 13:16:13 1996 Richard Henderson <rth@tamu.edu>
+
+ * dis-asm.h (print_insn_alpha): Don't declare.
+ (print_insn_alpha_osf, print_insn_alpha_vms): Declare.
+
+Wed Jul 17 14:45:12 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * dis-asm.h: (print_insn_d10v): Declare.
+
+Mon Jul 15 16:55:38 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * dis-asm.h: Get rid of decls for print_insn_i8086,
+ print_insn_sparc64 and print_insn_sparclite.
+ * (INIT_DISASSEMBLE_INFO): Split into two pieces. One,
+ INIT_DISASSEMBLE_INFO_NO_ARCH inits everything except for endian,
+ mach, and arch.
+
+Fri Jul 12 10:19:27 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * dis-asm.h (print_insn_i8086): Declare.
+
+Wed Jul 3 16:02:39 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * dis-asm.h (print_insn_sparclite): Declare.
+
+Tue Jun 18 16:02:46 1996 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * dis-asm.h (print_insn_h8300s): Declare.
+
+Tue Jun 18 15:11:33 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * fopen-vms.h: New file.
+
+Tue Jun 4 18:58:16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Add notice_all field.
+
+Fri Apr 26 10:33:12 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * demangle.h (#ifdef IN_GCC): #include "gansidecl.h".
+ (PROTO,PTR,const): Delete.
+
+Mon Apr 22 17:27:42 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Add traditional_format field.
+
+Mon Apr 15 15:16:56 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * libiberty.h (choose_temp_base): Add prototype.
+
+Tue Mar 12 17:29:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (bfd_wrapped_link_hash_lookup): Declare.
+ (struct bfd_link_info): Add wrap_hash field.
+
+Wed Feb 14 16:49:17 1996 Martin Anantharaman <martin@mail.imech.uni-duisburg.de>
+
+ * ieee.h (ieee_record_enum_type): Define
+ ieee_external_reference_info_enum.
+
+Fri Feb 2 17:09:25 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * dis-asm.h (DISASM_RAW_INSN): Delete.
+
+Tue Jan 23 09:21:47 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * dis-asm.h (INIT_DISASSEMBLE_INFO): Set endian to BFD_ENDIAN_UNKNOWN.
+ New argument FPRINTF_FUNC.
+
+Mon Jan 22 16:37:59 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * dis-asm.h (disassemble_info): New members arch, mach, endian.
+ (INIT_DISASSEMBLE_INFO): Initialize them.
+ (DISASM_RAW_INSN{,FLAG}): Define.
+
+Thu Jan 18 11:32:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * demangle.h (cplus_demangle_opname): Change opname parameter to
+ const char *.
+ (cplus_mangle_opname): Change return type and opname parameter to
+ const char *.
+
+Fri Jan 5 00:01:22 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ieee.h (enum ieee_record): Add ieee_asn_record_enum,
+ ieee_at_record_enum, ieee_ty_record_enum, ieee_atn_record_enum,
+ ieee_bb_record_enum, and ieee_be_record_enum.
+
+Wed Jan 3 13:12:09 1996 Fred Fish <fnf@cygnus.com>
+
+ * obstack.h: Update copyright to 1996.
+ (_obstack_memory_used): Declare.
+ (obstack_memory_used): Define macro.
+
+Thu Dec 28 11:42:12 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libiberty.h (xstrdup): Declare.
+
+Thu Dec 21 14:47:17 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * wait.h: Protect all macros with #ifndef.
+
+Tue Oct 24 21:45:40 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Add static_link field.
+
+Tue Sep 12 16:28:04 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_callbacks): Add symbol parameter to
+ warning callback.
+
+Fri Sep 1 13:11:51 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_callbacks): Change warning callback
+ to take BFD, section, and address arguments.
+
+Thu Aug 31 16:45:12 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Remove PE stuff.
+
+Tue Aug 22 03:18:23 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ * libiberty.h: Declare xstrerror. From Pat Rankin.
+
+Mon Aug 21 18:11:36 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Remove PE stuff.
+
+Wed Aug 2 08:14:12 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * dis-asm.h (print_insn_sparc64): Declare.
+
+Mon Jul 10 13:26:49 1995 Eric Youngdale <eric@aib.com>
+
+ * bfdlink.h (struct bfd_link_info): Add new field symbolic.
+
+Sun Jul 2 17:48:40 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Change type of base_file to
+ PTR.
+
+Thu Jun 29 00:02:45 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * bfdlink.h (struct bfd_link_info): Added base_file member.
+
+Tue Jun 20 16:40:04 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * ansidecl.h: win32s is ANSI enough.
+
+Thu May 18 04:25:50 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
+
+ * dis-asm.h (print_insn_arm): Delete declaration.
+ (print_insn_{little,big}_arm): New declarations.
+
+ * floatformat.h (floatformat_arm_ext): Declare.
+
+Sat May 13 10:14:08 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * coff/pe.h: New file.
+ * bfdlink.h (subsytem, stack_heap_parameters): New.
+ * coff/i386.h (NT_SECTION_ALIGNMENT, NT_FILE_ALIGNMENT,
+ NT_DEF_RESERVE, NT_DEF_COMMIT): New.
+ * coff/internal.h (internal_filehdr): New fields for PE.
+ (IMAGE_DATA_DIRECTORY): New.
+ (internal_aouthdr): New fields for PE.
+
+Thu May 4 14:36:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * demangle.h: Don't include ansidecl.h if IN_GCC.
+
+Tue Feb 21 00:37:28 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * hp-symtab.h: Don't use bitfield enumerations, the HP C compiler
+ does not handle them correctly.
+
+Thu Feb 9 14:20:27 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * libiberty.h (basename): Don't declare parameter type; some
+ systems have this in their header files.
+
+Wed Feb 8 17:35:38 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (struct bfd_link_hash_entry): Change format of common
+ symbol information, to remove restrictions on maximum size and
+ alignment power, by using a pointer to a structure instead.
+
+Mon Feb 6 14:55:32 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * bfdlink.h (enum bfd_link_hash_type): Rename bfd_link_hash_weak
+ to bfd_link_hash_undefweak. Add bfd_link_hash_defweak.
+
+Mon Jan 16 21:00:23 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * dis-asm.h (GDB_INIT_DISASSEMBLE_INFO, etc): Remove all
+ GDB-specific definitions.
+
+Sun Jan 15 18:39:35 1995 Steve Chamberlain <sac@splat>
+
+ * dis-asm.h (print_insn_w65): Declare.
+
+Thu Jan 12 17:51:17 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * libiberty.h (hex_p): Fix sense of test.
+
+Wed Jan 11 22:36:40 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * libiberty.h (_hex_array_size, _hex_bad, _hex_value, hex_init,
+ hex_p, hex_value): New macros and declarations, for hex.c.
+
+Fri Jan 6 17:44:14 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * dis-asm.h: Make idempotent.
+
+Wed Dec 14 13:08:43 1994 Stan Shebs <shebs@andros.cygnus.com>
+
+ * progress.h: New file, empty definitions for progress macros.
+
+Fri Nov 25 00:14:05 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * hp-symtab.h: New file describing the debug symbols emitted
+ by the HP C compilers.
+
+Fri Nov 11 15:48:37 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * bfdlink.h (struct bfd_link_hash_entry): Change u.c.size from 24
+ to 26 bits, and change u.c.alignment_power from 8 to 6 bits. 6
+ bit in the alignment power is enough for a 64 bit address space.
+
+Mon Oct 31 13:02:51 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * demangle.h (cplus_mangle_opname): Declare.
+
+Tue Oct 25 11:38:02 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * bfdlink.h (struct bfd_link_callbacks): Fix comments for
+ multiple_common field.
+
+Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+ * aout/aout64.h: Only define QMAGIC if it isn't already defined.
+
+ * dis-asm.h: Add support for the ARM.
+
+Wed Aug 10 12:51:41 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * libiberty.h (strsignal): Document its existence even if we
+ can't declare it.
+
+Tue Aug 2 14:40:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * os9k.h: Remove u_int16, u_int32, and owner_id typedefs and
+ expand their uses. Those names conflict with Mach headers.
+
+Fri Jul 22 14:17:12 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * bfdlink.h (struct bfd_link_hash_entry): Change u.c.size into a
+ bitfield. Add field u.c.alignment_power.
+
+Sun Jul 10 00:26:39 1994 Ian Dall (dall@hfrd.dsto.gov.au)
+
+ * dis-asm.h: Add print_insn_ns32k declaration.
+
+Mon Jun 20 17:13:29 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * bfdlink.h (bfd_link_hash_table): Make creator a const pointer.
+
+Sat Jun 18 16:09:32 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * demangle.h (cplus_demangle_opname): Declare.
+
+Thu Jun 16 15:19:03 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfdlink.h (struct bfd_link_info): Add new field shared.
+
+Mon Jun 6 14:39:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfdlink.h (struct bfd_link_hash_entry): Remove written field:
+ not needed for all backends.
+
+Thu Apr 28 19:06:50 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * dis-asm.h (disassembler): Declare.
+
+Fri Apr 1 00:38:17 1994 Jim Wilson (wilson@mole.gnu.ai.mit.edu)
+
+ * obstack.h: Delete use of IN_GCC to control whether
+ stddef.h or gstddef.h is included.
+
+Tue Mar 22 13:06:02 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfdlink.h (enum bfd_link_order_type): Add bfd_data_link_order.
+ (struct bfd_link_order): Add data field to union.
+
+Mon Mar 21 18:45:26 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfdlink.h (struct bfd_link_callbacks): Change bitsize argument
+ to add_to_set to reloc. Remove bitsize argument from constructor.
+ Comment that reloc_overflow, reloc_dangerous and unattached_reloc
+ must handle NULL pointers for reloc location.
+ (enum bfd_link_order_type): Add bfd_section_reloc_link_order and
+ bfd_symbol_reloc_link_order.
+ (struct bfd_link_order): Add reloc field to union.
+ (struct bfd_link_order_reloc): Define.
+
+Mon Mar 14 12:27:50 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * ieee-float.h: Removed; no longer used.
+
+Tue Mar 1 18:10:49 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * os9k.h: os9000 target specific header file, the header of the
+ object file is used now.
+
+Sun Feb 27 21:52:26 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * floatformat.h: New file, intended to replace ieee-float.h.
+
+Sun Feb 20 17:15:42 1994 Ian Lance Taylor (ian@lisa.cygnus.com)
+
+ * ansidecl.h (ANSI_PROTOTYPES): Define if using ANSI prototypes.
+
+Wed Feb 16 01:07:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * libiberty.h: Don't declare strsignal, to avoid conflicts with
+ Solaris system header files.
+
+Sat Feb 12 22:11:32 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * libiberty.h (xexit): Use __volatile__ to avoid losing if
+ compiling with gcc -traditional.
+
+Thu Feb 10 14:05:41 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * libiberty.h: New file. Declares functions provided by
+ libiberty.
+
+Tue Feb 8 05:19:52 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ Handle obstack_chunk_alloc returning NULL. This allows
+ obstacks to be used by libraries, without forcing them
+ to call exit or longjmp.
+ * obstack.h (struct obstack): Add alloc_failed flag.
+ _obstack_begin, _obstack_begin_1): Declare to return int, not void.
+ (obstack_finish): If alloc_failed, return NULL.
+ (obstack_base, obstack_next_free, objstack_object_size):
+ If alloc_failed, return 0.
+ (obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow,
+ obstack_int_grow, obstack_blank): If alloc_failed, do nothing that
+ could corrupt the obstack.
+
+Mon Jan 24 15:06:05 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfdlink.h (struct bfd_link_callbacks): Add name, reloc_name and
+ addend argments to reloc_overflow callback.
+
+Fri Jan 21 19:13:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * dis-asm.h (print_insn_big_powerpc, print_insn_little_powerpc,
+ print_insn_rs6000): Declare.
+
+Thu Jan 6 14:15:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfdlink.h (struct bfd_link_callbacks): Add bitsize argument to
+ add_to_set field. Add new callback named constructor.
+
+Thu Dec 30 10:44:06 1993 Ian Lance Taylor (ian@rtl.cygnus.com)
+
+ * bfdlink.h: New file for new BFD linker backend routines.
+
+Mon Nov 29 10:43:57 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * dis-asm.h (enum dis_insn_tyupe): Remove non-ANSI trailing comma.
+
+Sat Oct 2 20:42:26 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * dis-asm.h: Move comment to right place.
+
+Mon Aug 9 19:03:35 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * obstack.h (obstack_chunkfun, obstack_freefun): Add defns from
+ previous version. Are these Cygnus local changes?
+
+Fri Aug 6 17:05:47 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * getopt.h, obstack.h: Update to latest FSF version.
+
+Mon Aug 2 16:37:14 1993 Stu Grossman (grossman at cygnus.com)
+
+ * coff/i386.h: Add Lynx magic number.
+
+Mon Aug 2 14:45:29 1993 John Gilmore (gnu@cygnus.com)
+
+ * dis-asm.h: Move enum outside of struct defn to avoid warnings.
+
+Mon Aug 2 08:49:30 1993 Stu Grossman (grossman at cygnus.com)
+
+ * wait.h (WEXITSTATUS, WSTOPSIG): Mask down to 8 bits. This is
+ for systems that store stuff into the high 16 bits of a wait
+ status.
+
+Fri Jul 30 18:38:02 1993 John Gilmore (gnu@cygnus.com)
+
+ * dis-asm.h: Add new fields insn_info_valid, branch_delay_insns,
+ data_size, insn_type, target, target2. These are used to return
+ information from the instruction decoders back to the calling
+ program. Add comments, make more readable.
+
+Mon Jul 19 22:14:14 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * nlm: New directory containing NLM/NetWare includes.
+
+Thu Jul 15 12:10:04 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * dis-asm.h (struct disassemble_info): New field application_data.
+
+Thu Jul 15 12:41:15 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * dis-asm.h: Added declaration of print_insn_m88k.
+
+Thu Jul 8 09:05:26 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * opcode/h8300.h: Lots of little fixes for the h8/300h.
+
+Fri Jul 2 10:31:59 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * ansidecl.h: Use ANSI macros if __mips and _SYSTYPE_SVR4 are
+ defined, since RISC/OS cc handles ANSI declarations in SVR4 mode
+ but does not define __STDC__.
+
+Sun Jun 20 18:27:52 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * dis-asm.h: Don't need to include ansidecl.h any more.
+
+Fri Jun 18 03:22:10 1993 John Gilmore (gnu@cygnus.com)
+
+ * oasys.h: Eliminate "int8_type", "int16_type", "int32_type", and
+ their variants. These changes are coordinated with corresponding
+ changes in ../bfd/oasys.c.
+
+Wed Jun 16 10:43:08 1993 Fred Fish (fnf@cygnus.com)
+
+ * bfd.h: Note that it has been removed.
+
+Tue Jun 8 12:16:03 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ Support for H8/300-H
+ * dis-asm.h (print_insn_h8300, print_insn_h8300h): Declare it.
+ * coff/h8300.h: New magic number.
+ * coff/internal.h: New relocations.
+ * opcode/h8300.h: Lots of new opcodes.
+
+Tue Jun 1 07:35:03 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * ansidecl.h (const): Don't define it if it's already defined.
+
+Thu May 27 18:19:51 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * dis-asm.h (print_insn_hppa): Declare it.
+
+ * bfd.h: Moved to bfd directory. Small stub here includes it
+ without requiring "-I../bfd".
+
+Thu Apr 29 12:06:13 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * bfd.h: Updated with BSF_FUNCTION.
+
+Mon Apr 26 18:15:50 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.h, dis-asm.h: Updated with Hitachi SH.
+
+Fri Apr 23 18:41:38 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.h: Updated with alpha changes.
+ * dis-asm.h: Added alpha.
+
+Fri Apr 16 17:35:30 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * bfd.h: Update for signed bfd_*get_*.
+
+Thu Apr 15 09:24:21 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * bfd.h: Updated for file_truncated error.
+
+Thu Apr 8 10:53:47 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * ansidecl.h: If no ANSI, define const to be empty.
+
+Thu Apr 1 09:00:10 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * dis-asm.h: Declare a29k and i960 print_insn_*.
+
+ * dis-asm.h: Add print_address_func and related stuff.
+
+ * dis-asm.h (dis_asm_read_memory): Fix prototype.
+
+Wed Mar 31 17:40:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * dis-asm.h: Add print_insn_sparc.
+
+Wed Mar 31 17:51:42 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd.h: Updated for BFD_RELOC_MIPS_GPREL and bfd_[gs]et_gp_size
+ prototypes.
+
+Wed Mar 31 16:35:12 1993 Stu Grossman (grossman@cygnus.com)
+
+ * dis-asm.h: (disassemble_info): Fix typo in prototype of
+ dis_asm_memory_error().
+
+Tue Mar 30 19:09:23 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * dis-asm.h (disassembler_info): Add read_memory_func,
+ memory_error_func, buffer, and length.
+ ({GDB_,}INIT_DISASSEMBLE_INFO): Set them.
+ print_insn_*: Remove second argument.
+
+Tue Mar 30 14:48:55 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.h: Update for lma field of section.
+
+Tue Mar 30 12:22:55 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * ansidecl.h: Use ANSI versions on AIX regardless of __STDC__.
+
+Fri Mar 19 14:49:49 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * dis-asm.h: Add h8500.
+
+Thu Mar 18 13:49:09 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * ieee-float.h: Moved from ../gdb.
+ * dis-asm.h: New file. Interface to dis-assembler.
+
+Thu Mar 11 10:52:57 1993 Fred Fish (fnf@cygnus.com)
+
+ * demangle.h (DMGL_NO_OPTS): Add define (set to 0) to use
+ in place of bare 0, for readability reasons.
+
+Tue Mar 2 17:50:11 1993 Fred Fish (fnf@cygnus.com)
+
+ * demangle.h: Replace all references to cfront with ARM.
+
+Tue Feb 23 12:21:14 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd.h: Update for new elements in JUMP_TABLE.
+
+Tue Feb 16 00:51:30 1993 John Gilmore (gnu@cygnus.com)
+
+ * bfd.h: Update for BFD_VERSION 2.1.
+
+Tue Jan 26 11:49:20 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd.h: Update for SEC_IS_COMMON flag.
+
+Tue Jan 19 12:25:12 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.h: Update for bfd_asymbol_value bug fix.
+
+Fri Jan 8 16:37:18 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * bfd.h: Update to include ECOFF tdata and target_flavour.
+
+Sun Dec 27 17:52:30 1992 Fred Fish (fnf@cygnus.com)
+
+ * bfd.h: Add declaration for bfd_get_size().
+
+Tue Dec 22 22:42:46 1992 Fred Fish (fnf@cygnus.com)
+
+ * demangle.h: Protect file from multiple inclusions with
+ #if !defined(DEMANGLE_H)...#define DEMANGLE_H...#endif.
+
+Mon Dec 21 21:25:50 1992 Stu Grossman (grossman at cygnus.com)
+
+ * bfd.h: Update to get hppa_core_struct from bfd.c.
+
+Thu Dec 17 00:42:35 1992 John Gilmore (gnu@cygnus.com)
+
+ * bfd.h: Update to get tekhex tdata name change from bfd.
+
+Mon Nov 9 23:55:42 1992 John Gilmore (gnu@cygnus.com)
+
+ * ansidecl.h: Update comments to discourage use of EXFUN.
+
+Thu Nov 5 16:35:44 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * bfd.h: Update to bring in SEC_SHARED_LIBRARY.
+
+Thu Nov 5 03:21:32 1992 John Gilmore (gnu@cygnus.com)
+
+ * bfd.h: Update to match EXFUN, bfd_seclet_struct, and SDEF
+ cleanups in bfd.
+
+Wed Nov 4 07:28:05 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * bout.h (N_CALLNAME, N_BALNAME): Define as char-type values, so
+ widening works consistently.
+
+Fri Oct 16 03:17:08 1992 John Gilmore (gnu@cygnus.com)
+
+ * getopt.h: Update to Revised Standard FSF Version.
+
+Thu Oct 15 21:43:22 1992 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * getopt.h (struct option): use the provided enum for has_arg.
+
+ * demangle.h (AUTO_DEMANGLING, GNU_DEMANGLING,
+ LUCID_DEMANGLING): ultrix compilers require enums to be
+ enums and ints to be ints and casts where they meet. cast some
+ enums into ints.
+
+Thu Oct 15 04:35:51 1992 John Gilmore (gnu@cygnus.com)
+
+ * bfd.h: Update after comment changes.
+
+Thu Oct 8 09:03:02 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.h (bfd_get_symbol_leading_char): new macro for getting in xvec
+
+Thu Sep 3 09:10:50 1992 Stu Grossman (grossman at cygnus.com)
+
+ * bfd.h (struct reloc_howto_struct): size needs to be signed if
+ it's going to hold negative values.
+
+Sun Aug 30 17:50:27 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * demangle.h: New file, moved from ../gdb. Made independent
+ of gdb. Allow demangling style option to be passed as a
+ parameter to cplus_demangle(), but using the
+ current_demangling_style global as the default.
+
+Sat Aug 29 10:07:55 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.h: Merge comment change from current FSF version.
+
+Thu Aug 27 12:59:29 1992 Brendan Kehoe (brendan@cygnus.com)
+
+ * bfd.h: add we32k
+
+Tue Aug 25 15:07:47 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.h: new after Z8000 stuff
+
+Mon Aug 17 09:01:23 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * bfd.h: Regenerated after page/segment size changes.
+
+Sat Aug 1 13:46:31 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.h: Merge changes from current FSF version.
+
+Mon Jul 20 21:06:23 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.h (area_id, flags): Remove, replace with extra_arg,
+ use_extra_arg, and maybe_empty_object.
+ * obstack.h (OBSTACK_MAYBE_EMPTY_OBJECT, OBSTACK_MMALLOC_LIKE):
+ Remove, replaced by maybe_empty_object and use_extra_arg bitfields.
+ * obstack.h (obstack_full_begin, _obstack_begin): Remove area_id
+ and flags arguments.
+ * obstack.h (obstack_alloc_arg): New macro to set extra_arg.
+
+Thu Jul 16 08:12:44 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * bfd.h: new after adding BFD_IS_RELAXABLE
+
+Sat Jul 4 03:22:23 1992 John Gilmore (gnu at cygnus.com)
+
+ * bfd.h: Regen after adding BSF_FILE.
+
+Mon Jun 29 14:18:36 1992 Fred Fish (fnf at sunfish)
+
+ * obstack.h: Convert bcopy() use to memcpy(), which is more
+ portable, more standard, and can take advantage of gcc's builtin
+ functions for increased performance.
+
+Thu Jun 25 04:46:08 1992 John Gilmore (gnu at cygnus.com)
+
+ * ansidecl.h (PARAMS): Incorporate this macro from gdb's defs.h.
+ It's a cleaner way to forward-declare function prototypes.
+
+Fri Jun 19 15:46:32 1992 Stu Grossman (grossman at cygnus.com)
+
+ * bfd.h: HPPA merge.
+
+Tue Jun 16 21:30:56 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * getopt.h: gratuitous white space changes merged from other prep
+ releases.
+
+Thu Jun 11 01:10:55 1992 John Gilmore (gnu at cygnus.com)
+
+ * bfd.h: Regen'd from bfd.c after removing elf_core_tdata_struct.
+
+Mon May 18 17:29:03 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * getopt.h: merged changes from make-3.62.11.
+
+ * getopt.h: merged changes from grep-1.6 (alpha).
+
+Fri May 8 14:53:32 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * getopt.h: merged changes from bison-1.18.
+
+Sat Mar 14 17:25:20 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.h: Add "area_id" and "flags" members to obstack
+ structure. Add obstack_chunkfun() and obstack_freefun() to
+ set functions explicitly. Convert maybe_empty_object to
+ a bit in "flags".
+
+Thu Feb 27 22:01:02 1992 Per Bothner (bothner@cygnus.com)
+
+ * wait.h (WIFSTOPPED): Add IBM rs6000-specific version.
+
+Fri Feb 21 20:49:20 1992 John Gilmore (gnu at cygnus.com)
+
+ * obstack.h: Add obstack_full_begin.
+ * bfd.h, obstack.h: Protolint.
+
+Thu Jan 30 01:18:42 1992 John Gilmore (gnu at cygnus.com)
+
+ * bfd.h: Remove comma from enum declaration.
+
+Mon Jan 27 22:01:13 1992 Steve Chamberlain (sac at cygnus.com)
+
+ * bfd.h : new target entr, bfd_relax_section
+
+Wed Dec 18 17:19:44 1991 Stu Grossman (grossman at cygnus.com)
+
+ * bfd.h, ieee.h, opcode/m68k.h, opcode/sparc.h: ANSIfy enums.
+
+Thu Dec 12 20:59:56 1991 John Gilmore (gnu at cygnus.com)
+
+ * fopen-same.h, fopen-bin.h: New files for configuring
+ whether fopen distinguishes binary files or not. For use
+ by host-dependent config files.
+
+Sat Nov 30 20:46:43 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * bfd.h: change the documentation format.
+
+ * created coff, elf and opcode and aout directories. Moved:
+
+ aout64.h ==> aout/aout64.h
+ ar.h ==> aout/ar.h
+ a.out.encap.h ==> aout/encap.h
+ a.out.host.h ==> aout/host.h
+ a.out.hp.h ==> aout/hp.h
+ a.out.sun4.h ==> aout/sun4.h
+ ranlib.h ==> aout/ranlib.h
+ reloc.h ==> aout/reloc.h
+ stab.def ==> aout/stab.def
+ stab.gnu.h ==> aout/stab_gnu.h
+
+ coff-a29k.h ==> coff/a29k.h
+ coff-h8300.h ==> coff/h8300.h
+ coff-i386.h ==> coff/i386.h
+ coff-i960.h ==> coff/i960.h
+ internalcoff.h ==> coff/internal.h
+ coff-m68k.h ==> coff/m68k.h
+ coff-m88k.h ==> coff/m88k.h
+ coff-mips.h ==> coff/mips.h
+ coff-rs6000.h ==> coff/rs6000.h
+
+ elf-common.h ==> elf/common.h
+ dwarf.h ==> elf/dwarf.h
+ elf-external.h ==> elf/external.h
+ elf-internal.h ==> elf/internal.h
+
+ a29k-opcode.h ==> opcode/a29k.h
+ arm-opcode.h ==> opcode/arm.h
+ h8300-opcode.h ==> opcode/h8300.h
+ i386-opcode.h ==> opcode/i386.h
+ i860-opcode.h ==> opcode/i860.h
+ i960-opcode.h ==> opcode/i960.h
+ m68k-opcode.h ==> opcode/m68k.h
+ m88k-opcode.h ==> opcode/m88k.h
+ mips-opcode.h ==> opcode/mips.h
+ np1-opcode.h ==> opcode/np1.h
+ ns32k-opcode.h ==> opcode/ns32k.h
+ pn-opcode.h ==> opcode/pn.h
+ pyr-opcode.h ==> opcode/pyr.h
+ sparc-opcode.h ==> opcode/sparc.h
+ tahoe-opcode.h ==> opcode/tahoe.h
+ vax-opcode.h ==> opcode/vax.h
+
+
+
+Wed Nov 27 10:38:31 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * internalcoff.h: (internal_scnhdr) took out #def dependency, now
+ s_nreloc and s_nlnno are always long. (internal_reloc): allways
+ has an offset field now.
+
+Fri Nov 22 08:12:58 1991 John Gilmore (gnu at cygnus.com)
+
+ * coff-rs6000.h: Lint; use unsigned chars for external fields.
+ * internalcoff.h: Lint; cast storage classes to signed char.
+
+Thu Nov 21 21:01:05 1991 Per Bothner (bothner at cygnus.com)
+
+ * stab.def: Remove the GNU extended type codes (e.g. N_SETT).
+ * aout64.h: The heuristic for distinguishing between
+ sunos-style and bsd-style ZMAGIC files (wrt. where the
+ text segment starts) is moved into (the default definition of)
+ the macro N_HEADER_IN_TEXT. This definition is only used
+ if no other definition is used - e.g. bfd/newsos3.c defines
+ N_HEADER_IN_TEXT(x) to be always 0 (as before).
+
+Thu Nov 21 11:53:03 1991 John Gilmore (gnu at cygnus.com)
+
+ * aout64.h (N_TXTADDR, N_TXTOFF, N_TXTSIZE): New definitions
+ that should handle all uses. LOGICAL_ versions deleted.
+ Eliminate N_HEADER_IN_TEXT, using a_entry to determine which
+ kind of zmagic a.out file we are looking at.
+ * coff-rs6000.h: Typo.
+
+Tue Nov 19 18:43:37 1991 Per Bothner (bothner at cygnus.com)
+
+ (Note: This is a revised entry, as was aout64.h.)
+ * aout64.h: Some cleanups of N_TXTADDR and N_TXTOFF:
+ Will now work for both old- and new-style ZMAGIC files,
+ depending on N_HEADER_IN_TEXT macro.
+ Add LOGICAL_TXTADDR, LOICAL_TXTOFF and LOGICAL_TXTSIZE
+ that don't count the exec header as part
+ of the text segment, to be consistent with bfd.
+ * a.out.sun4.h: Simplified/fixed for previous change.
+
+Mon Nov 18 00:02:06 1991 Fred Fish (fnf at cygnus.com)
+
+ * dwarf.h: Update to DWARF draft 5 version from gcc2.
+
+Thu Nov 14 19:44:59 1991 Per Bothner (bothner at cygnus.com)
+
+ * stab.def: Added defs for extended GNU symbol types,
+ such as N_SETT. These are normally ifdef'd out (because
+ of conflicts with a.out.gnu.h), but are used by bfb_stab_name().
+
+Thu Nov 14 19:17:03 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf-common.h: Add defines to support ELF symbol table code.
+
+Mon Nov 11 19:01:06 1991 Fred Fish (fnf at cygnus.com)
+
+ * elf-internal.h, elf-external.h, elf-common.h: Add support for
+ note sections, which are used in ELF core files to hold copies
+ of various /proc structures.
+
+Thu Nov 7 08:58:26 1991 Steve Chamberlain (sac at cygnus.com)
+
+ * internalcoff.h: took out the M88 dependency in the lineno
+ struct.
+ * coff-m88k.h: defines GET_LINENO_LNNO and PUT_LINENO_LNNO to use
+ 32bit linno entries.
+ * a29k-opcode.h: fixed encoding of mtacc
+
+Sun Nov 3 11:54:22 1991 Per Bothner (bothner at cygnus.com)
+
+ * bfd.h: Updated from ../bfd/bfd-in.h (q.v).
+
+Fri Nov 1 11:13:53 1991 John Gilmore (gnu at cygnus.com)
+
+ * internalcoff.h: Add x_csect defines.
+
+Fri Oct 25 03:18:20 1991 John Gilmore (gnu at cygnus.com)
+
+ * Rename COFF-related files in `coff-ARCH.h' form.
+ coff-a29k.h, coff-i386.h, coff-i960.h, coff-m68k.h, coff-m88k.h,
+ coff-mips.h, coff-rs6000.h to be exact.
+
+Thu Oct 24 22:11:11 1991 John Gilmore (gnu at cygnus.com)
+
+ RS/6000 support, by Metin G. Ozisik, Mimi Phûông-Thåo Võ, and
+ John Gilmore.
+
+ * a.out.gnu.h: Update slightly.
+ * bfd.h: Add new error code, fix doc, add bfd_arch_rs6000.
+ * internalcoff.h: Add more F_ codes for filehdr. Add
+ rs/6000-dependent fields to aouthdr. Add storage classes
+ to syments. Add 6000-specific auxent. Add r_size in reloc.
+ * rs6000coff.c: New file.
+
+Thu Oct 24 04:13:20 1991 Fred Fish (fnf at cygnus.com)
+
+ * dwarf.h: New file for dwarf support. Copied from gcc2
+ distribution.
+
+Wed Oct 16 13:31:45 1991 John Gilmore (gnu at cygnus.com)
+
+ * aout64.h: Remove PAGE_SIZE defines; they are target-dependent.
+ Add N_FN_SEQ for N_FN symbol type used on Sequent machines.
+ * stab.def: Include N_FN_SEQ in table.
+ * bout.h: External formats of structures use unsigned chars.
+
+Fri Oct 11 12:40:43 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * bfd.h:upgrade from bfd.c
+ * internalcoff.h: add n_name, n_zeroes and n_offset macros
+ * amdcoff.h: Define OMAGIC and AOUTHDRSZ.
+
+Fri Oct 11 10:58:06 1991 Per Bothner (bothner at cygnus.com)
+
+ * a.out.host.h: Change SEGMENT_SIZE to 0x1000 for Sony.
+ * bfd.h (align_power): Add (actually move) comment.
+
+Tue Oct 8 15:29:32 1991 Per Bothner (bothner at cygnus.com)
+
+ * sys/h-rtbsd.h: Define MISSING_VFPRINT (for binutils/bucomm.c).
+
+Sun Oct 6 19:24:39 1991 John Gilmore (gnu at cygnus.com)
+
+ * aout64.h: Move struct internal_exec to ../bfd/libaout.h so
+ it can be shared by all `a.out-family' code. Rename
+ EXTERNAL_LIST_SIZE to EXTERNAL_NLIST_SIZE. Use basic types
+ for nlist members, and make strx integral rather than pointer.
+ More commentary on n_type values.
+ * bout.h: Provide a struct external_exec rather than an
+ internal_exec.
+ * m68kcoff.h: Remove `tagentries' which snuck in from the i960
+ COFF port.
+
+Fri Oct 4 01:25:59 1991 John Gilmore (gnu at cygnus.com)
+
+ * h8300-opcode.h: Remove `_enum' from the typedef for an enum.
+ * bfd.h: Update to match bfd changes.
+
+ * sys/h-i386mach.h, sysdep.h: Add 386 Mach host support.
+
+Tue Oct 1 04:58:42 1991 John Gilmore (gnu at cygnus.com)
+
+ * bfd.h, elf-common.h, elf-external.h, elf-internal.h:
+ Add preliminary ELF support, sufficient for GDB, from Fred Fish.
+ * sysdep.h, sys/h-amix.h: Support Amiga SVR4.
+
+ * sys/h-vaxult.h: Make it work. (David Taylor <taylor@think.com>)
+ * a.out.vax.h: Remove unused and confusing file.
+
+Mon Sep 30 12:52:35 1991 Per Bothner (bothner at cygnus.com)
+
+ * sysdep.h: Define NEWSOS3_SYS, and use it.
+
+Fri Sep 20 13:38:21 1991 John Gilmore (gnu at cygnus.com)
+
+ * a.out.gnu.h (N_FN): Its value *really is* 0x1F.
+ Fix it, and add comments warning about or-ing N_EXT with it
+ and/or N_WARNING.
+ * aout64.h (N_FN): Fix value, add comments about N_EXT.
+ * stab.def (table at end): Update to show all the type
+ values <0x20, including low order bits. Move N_FN to
+ its rightful place.
+
+Tue Sep 17 17:41:37 1991 Stu Grossman (grossman at cygnus.com)
+
+ * sys/h-irix3.h: sgi/irix support.
+
+Tue Sep 17 07:52:59 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * stab.def (N_DEFD): Add GNU Modula-2 debug stab, from Andrew
+ Beers.
+
+Thu Sep 12 14:12:59 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * internalcoff.h (SYMNMLEN, FILNMLEN, DIMNUM): Define these
+ for internalcoff, separately from the various external coff's.
+ * amdcoff.h, bcs88kcoff.h, i386coff.h, intel-coff.h, m68kcoff.h,
+ m88k-bcs.h: Prefix SYMNMLEN, FILNMLEN, and DIMNUM with E_'s for
+ the external struct definitions.
+ * ecoff.h: Remove these #define's, kludge no longer needed.
+
+ * sys/h-ultra3.h: Add new Ultracomputer host.
+ * sysdep.h: Add ULTRA3_SYM1_SYS and use it.
+
+Tue Sep 10 10:11:46 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * i386coff.h (LINESZ): Always 6, not based on sizeof().
+ (Fix from Peter Schauer <pes@regent.e-technik.tu-muenchen.de>.)
+
+Wed Sep 4 08:58:37 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * a.out.gnu.h, aout64.h: Add N_WARNING. Change N_FN to 0x0E,
+ to match SunOS and BSD. Add N_COMM as 0x12 for SunOS shared lib
+ support.
+ * stab.def: Add N_COMM to table, fix overlap comment.
+
+Tue Sep 3 06:29:20 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ Merge with latest FSF versions of these files.
+
+ * stab.gnu.h: Add LAST_UNUSED_STAB_CODE.
+ * stab.def: Update to GPL2. Move N_WARNING out, since not a
+ debug symbol. Change comments, and reorder table to numeric
+ order. Update final table comment.
+ (N_DSLINE, N_BSLINE): Renumber from 0x66 and 0x68, to 0x46 and 0x48.
+
+ * obstack.h: GPL2. Merge.
+
+Fri Aug 23 01:54:23 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * a.out.gnu.h, a.out.sun4.h: Make SEGMENT_SIZE able to depend
+ on the particular a.out being examined.
+ * a.out.sun4.h: Define segment sizes for Sun-3's and Sun-4's.
+ * FIXME: a.out.gnu.h is almost obsolete.
+ * FIXME: a.out.sun4.h should be renamed a.out.sun.h now.
+
+Wed Aug 21 20:32:13 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * Start a ChangeLog for the includes directory.
+
+ * a.out.gnu.h (N_FN): Fix value -- was 15, should be 0x1E.
+ * stab.def: Update allocation table in comments at end,
+ to reflect reality as I know it.
+
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/include/ansidecl.h b/include/ansidecl.h
new file mode 100644
index 00000000000..cdb9fb71961
--- /dev/null
+++ b/include/ansidecl.h
@@ -0,0 +1,163 @@
+/* ANSI and traditional C compatability macros
+ Copyright 1991, 1992, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ANSI and traditional C compatibility macros
+
+ ANSI C is assumed if __STDC__ is #defined.
+
+ Macro ANSI C definition Traditional C definition
+ ----- ---- - ---------- ----------- - ----------
+ PTR `void *' `char *'
+ LONG_DOUBLE `long double' `double'
+ VOLATILE `volatile' `'
+ SIGNED `signed' `'
+ PTRCONST `void *const' `char *'
+ ANSI_PROTOTYPES 1 not defined
+
+ CONST is also defined, but is obsolete. Just use const.
+
+ obsolete -- DEFUN (name, arglist, args)
+
+ Defines function NAME.
+
+ ARGLIST lists the arguments, separated by commas and enclosed in
+ parentheses. ARGLIST becomes the argument list in traditional C.
+
+ ARGS list the arguments with their types. It becomes a prototype in
+ ANSI C, and the type declarations in traditional C. Arguments should
+ be separated with `AND'. For functions with a variable number of
+ arguments, the last thing listed should be `DOTS'.
+
+ obsolete -- DEFUN_VOID (name)
+
+ Defines a function NAME, which takes no arguments.
+
+ obsolete -- EXFUN (name, (prototype)) -- obsolete.
+
+ Replaced by PARAMS. Do not use; will disappear someday soon.
+ Was used in external function declarations.
+ In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
+ parentheses). In traditional C it is `NAME()'.
+ For a function that takes no arguments, PROTOTYPE should be `(void)'.
+
+ obsolete -- PROTO (type, name, (prototype) -- obsolete.
+
+ This one has also been replaced by PARAMS. Do not use.
+
+ PARAMS ((args))
+
+ We could use the EXFUN macro to handle prototype declarations, but
+ the name is misleading and the result is ugly. So we just define a
+ simple macro to handle the parameter lists, as in:
+
+ static int foo PARAMS ((int, char));
+
+ This produces: `static int foo();' or `static int foo (int, char);'
+
+ EXFUN would have done it like this:
+
+ static int EXFUN (foo, (int, char));
+
+ but the function is not external...and it's hard to visually parse
+ the function name out of the mess. EXFUN should be considered
+ obsolete; new code should be written to use PARAMS.
+
+ DOTS is also obsolete.
+
+ Examples:
+
+ extern int printf PARAMS ((const char *format, ...));
+*/
+
+#ifndef _ANSIDECL_H
+
+#define _ANSIDECL_H 1
+
+
+/* Every source file includes this file,
+ so they will all get the switch for lint. */
+/* LINTLIBRARY */
+
+
+#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
+/* All known AIX compilers implement these things (but don't always
+ define __STDC__). The RISC/OS MIPS compiler defines these things
+ in SVR4 mode, but does not define __STDC__. */
+
+#define PTR void *
+#define PTRCONST void *CONST
+#define LONG_DOUBLE long double
+
+#ifndef IN_GCC
+#define AND ,
+#define NOARGS void
+#define VOLATILE volatile
+#define SIGNED signed
+#endif /* ! IN_GCC */
+
+#define PARAMS(paramlist) paramlist
+#define ANSI_PROTOTYPES 1
+
+#define VPARAMS(ARGS) ARGS
+#define VA_START(va_list,var) va_start(va_list,var)
+
+/* These are obsolete. Do not use. */
+#ifndef IN_GCC
+#define CONST const
+#define DOTS , ...
+#define PROTO(type, name, arglist) type name arglist
+#define EXFUN(name, proto) name proto
+#define DEFUN(name, arglist, args) name(args)
+#define DEFUN_VOID(name) name(void)
+#endif /* ! IN_GCC */
+
+#else /* Not ANSI C. */
+
+#define PTR char *
+#define PTRCONST PTR
+#define LONG_DOUBLE double
+
+#ifndef IN_GCC
+#define AND ;
+#define NOARGS
+#define VOLATILE
+#define SIGNED
+#endif /* !IN_GCC */
+
+#ifndef const /* some systems define it in header files for non-ansi mode */
+#define const
+#endif
+
+#define PARAMS(paramlist) ()
+
+#define VPARAMS(ARGS) (va_alist) va_dcl
+#define VA_START(va_list,var) va_start(va_list)
+
+/* These are obsolete. Do not use. */
+#ifndef IN_GCC
+#define CONST
+#define DOTS
+#define PROTO(type, name, arglist) type name ()
+#define EXFUN(name, proto) name()
+#define DEFUN(name, arglist, args) name arglist args;
+#define DEFUN_VOID(name) name()
+#endif /* ! IN_GCC */
+
+#endif /* ANSI C. */
+
+#endif /* ansidecl.h */
diff --git a/include/aout/ChangeLog b/include/aout/ChangeLog
new file mode 100644
index 00000000000..854cfd5b5cb
--- /dev/null
+++ b/include/aout/ChangeLog
@@ -0,0 +1,178 @@
+Sun Jun 28 11:33:48 1998 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
+
+ * stab.def: Add N_ALIAS from SunPro F77.
+
+Mon Mar 11 12:15:52 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * stab.def: Use __define_stab_duplicate rather than __define_stab
+ for duplicate entries N_BROWS and N_MOD2.
+ * stab_gnu.h (__define_stab_duplicate): Define before including
+ stab.def.
+
+Fri Oct 27 17:47:16 1995 Niklas Hallqvist <niklas@appli.se>
+
+ * aout64.h, host.h, hp300hpux.h, sun4.h: Changed PAGE_SIZE to
+ TARGET_PAGE_SIZE.
+
+Tue Sep 12 12:07:02 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * sun4.h (struct internal_sun4_dynamic_link): Change all fields
+ from long to unsigned long.
+
+Wed Jul 12 00:15:13 1995 Ken Raeburn <raeburn@kr-pc.cygnus.com>
+
+ * sun4.h (PAGE_SIZE): Undefine before defining.
+
+Thu Jun 16 14:22:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * aout64.h (BMAGIC): Define.
+
+Sat Jun 11 16:16:09 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ Add weak symbols as an extension to a.out.
+ * aout64.h (N_WEAKU, N_WEAKA, N_WEAKT, N_WEAKD, N_WEAKB): Define.
+ * stab.def: Update symbol value table.
+
+Thu Jun 2 17:13:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * sun4.h (EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE): Correct from 28 to
+ 24. Fix up ld_got comment.
+
+Wed Mar 30 00:31:49 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * dynix3.h: Cleanup, adapt to current bfd version.
+
+Sat Feb 26 10:25:53 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * aout64.h: Add casts to avoid warnings from SVR4 cc.
+
+Fri Feb 11 12:56:04 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * ar.h (ARMAG, ARMAGB, ARFMAG): Change '\n' to '\012', for greater
+ portability.
+
+Fri Jan 21 00:59:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * sun4.h: Added information about SunOS shared libraries.
+
+Fri Jan 7 08:20:13 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * aout64.h (N_TXTADDR): Add comment regarding OMAGIC and NMAGIC.
+
+Sat Dec 25 14:55:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aout64.h (N_DATOFF): Don't pad (revert change of 8 Jul 1993).
+
+Tue Nov 16 15:43:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aout64.h: New macros ZMAGIC_DISK_BLOCK_SIZE and N_DISK_BLOCK_SIZE
+ for Linux ZMAGIC.
+ (N_TXTOFF, N_DATOFF): Use them.
+
+Thu Nov 4 00:33:48 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * aout64.h (RELOC_STD_BITS_RELATIVE_LITTLE): Fixed value to match
+ sun3 system; used to overlap other fields.
+ (RELOC_STD_BITS_JMPTABLE_LITTLE): Likewise.
+
+Wed Nov 3 13:48:27 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * aout64.h (RELOC_STD_BITS_BASEREL_LITTLE): Make it 0x10 (Ken's
+ suggestion) to avoid conflict with RELOC_STD_BITS_EXTERN_LITTLE.
+
+Fri Oct 29 15:09:52 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * hp300hpux.h (N_SHARED_LIB): Define to be 0.
+
+Mon Sep 13 21:00:56 1993 John Gilmore (gnu@cygnus.com)
+
+ * ar.h (ARMAP_TIME_OFFSET): Add and describe.
+
+Mon Aug 23 Sean Fagan (sef@cygnus.com)
+
+ * aout64.h [ARCH_SIZE != 64]: Allow N_BADMAG to be overridden.
+
+Mon Aug 16 14:30:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * stab_gnu.h: Include aout/stab.def not just stab.def.
+
+Sun Jul 18 21:41:47 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * dynix3.h: New, for symmetry running dynix.
+
+Thu Jul 8 12:52:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aout64.h (N_BADMAG): Recognize QMAGIC.
+ N_TXTOFF, N_TXTADDR, N_TXTSIZE: Special code for QMAGIC.
+ N_DATOFF: Pad text size if we need to.
+
+Fri Jun 18 19:19:38 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * stab.def (N_ECOML): Fix comment.
+
+Mon May 31 09:21:30 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * stab.def: Remove Solaris information on N_FUN stabstring grammar;
+ I've transferred it to gdb/doc/stabs.texinfo, where it belongs.
+
+Mon May 10 05:48:43 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * hp300hpux.h: Patch from Glenn Engel for linker problem and
+ compatibility fix:
+ (OMAGIC, NMAGIC): New definitions.
+ (SHAREMAGIC): Deleted.
+ (HPUX_DOT_O_MAGIC): New macro.
+ (_N_BADMAG): Adjusted.
+ (N_HEADER_IN_TEXT, N_DATADDR): New macros.
+
+Thu Apr 29 12:07:37 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * hp300hpux.h: New file from Glenn Engel, glenne@lsid.hp.com.
+
+Tue Apr 27 05:51:04 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * aout64.h (struct external_exec, *MAGIC, N_BADMAG): Don't define
+ if `external_exec' is already defined as a macro.
+ (N_DATOFF, N_TRELOFF, N_DRELOFF, N_SYMOFF, N_STROFF): Don't define
+ if already defined.
+ (struct external_nlist, EXTERNAL_NLIST_SIZE): Don't define if
+ `external_nlist' is already defined as a macro.
+
+Sat Aug 15 04:23:02 1992 John Gilmore (gnu@cygnus.com)
+
+ * adobe.h: Add description of a.out.adobe format.
+
+Fri Jul 3 00:36:52 1992 John Gilmore (gnu at cygnus.com)
+
+ * stab.def: Update more Solaris definitions.
+ * stab_gnu.h: Add N_SO language types, and Solaris basic float types.
+
+Sun Jun 14 10:53:53 1992 John Gilmore (gnu at cygnus.com)
+
+ * stab.def: Update descriptions of Solaris-2 stabs; add N_UNDF.
+
+Thu Jun 11 01:12:07 1992 John Gilmore (gnu at cygnus.com)
+
+ * stab.def: Add N_OBJ and N_OPT from Solaris-2.
+
+Thu Jan 30 18:12:44 1992 John Gilmore (gnu at cygnus.com)
+
+ * aout/aout64.h: N_TXTSIZE needs some more parentheses.
+ I don't trust C precedence.
+
+Wed Dec 18 14:32:01 1991 Per Bothner (bothner at cygnus.com)
+
+ * aout/aout64.h: Move common sunos-specific test
+ to recognize shared libraries into new macro N_SHARED_LIB.
+ Use it to simplify&reformat N_TXTADDR, N_TXTOFF, N_TXTSIZE.
+
+Sat Nov 30 20:34:52 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * ChangeLog, aout64.h, ar.h, encap.h, host.h, hp.h, ranlib.h,
+ reloc.h, stab.def, stab_gnu.h, sun4.h: All moved from the
+ devo/include directory
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/include/aout/adobe.h b/include/aout/adobe.h
new file mode 100644
index 00000000000..3d2f15c6cb7
--- /dev/null
+++ b/include/aout/adobe.h
@@ -0,0 +1,297 @@
+/* `a.out.adobe' differences from standard a.out files */
+
+#ifndef __A_OUT_ADOBE_H__
+#define __A_OUT_ADOBE_H__
+
+#define BYTES_IN_WORD 4
+
+/* Struct external_exec is the same. */
+
+/* This is the layout on disk of the 32-bit or 64-bit exec header. */
+
+struct external_exec
+{
+ bfd_byte e_info[4]; /* magic number and stuff */
+ bfd_byte e_text[BYTES_IN_WORD]; /* length of text section in bytes */
+ bfd_byte e_data[BYTES_IN_WORD]; /* length of data section in bytes */
+ bfd_byte e_bss[BYTES_IN_WORD]; /* length of bss area in bytes */
+ bfd_byte e_syms[BYTES_IN_WORD]; /* length of symbol table in bytes */
+ bfd_byte e_entry[BYTES_IN_WORD]; /* start address */
+ bfd_byte e_trsize[BYTES_IN_WORD]; /* length of text relocation info */
+ bfd_byte e_drsize[BYTES_IN_WORD]; /* length of data relocation info */
+};
+
+#define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
+
+/* Magic numbers for a.out files */
+
+#undef ZMAGIC
+#define ZMAGIC 0xAD0BE /* Cute, eh? */
+#undef OMAGIC
+#undef NMAGIC
+
+#define N_BADMAG(x) ((x).a_info != ZMAGIC)
+
+/* By default, segment size is constant. But some machines override this
+ to be a function of the a.out header (e.g. machine type). */
+#ifndef N_SEGSIZE
+#define N_SEGSIZE(x) SEGMENT_SIZE
+#endif
+#undef N_SEGSIZE /* FIXMEXXXX */
+
+/* Segment information for the a.out.Adobe format is specified after the
+ file header. It contains N segment descriptors, followed by one with
+ a type of zero.
+
+ The actual text of the segments starts at N_TXTOFF in the file,
+ regardless of how many or how few segment headers there are. */
+
+struct external_segdesc {
+ unsigned char e_type[1];
+ unsigned char e_size[3];
+ unsigned char e_virtbase[4];
+ unsigned char e_filebase[4];
+};
+
+struct internal_segdesc {
+ unsigned int a_type:8; /* Segment type N_TEXT, N_DATA, 0 */
+ unsigned int a_size:24; /* Segment size */
+ bfd_vma a_virtbase; /* Virtual address */
+ unsigned int a_filebase; /* Base address in object file */
+};
+
+#define N_TXTADDR(x) \
+
+/* This is documented to be at 1024, but appears to really be at 2048.
+ FIXME?! */
+#define N_TXTOFF(x) 2048
+
+#define N_TXTSIZE(x) ((x).a_text)
+
+#define N_DATADDR(x)
+
+#define N_BSSADDR(x)
+
+/* Offsets of the various portions of the file after the text segment. */
+
+#define N_DATOFF(x) ( N_TXTOFF(x) + N_TXTSIZE(x) )
+#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
+#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
+#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
+#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
+
+/* Symbols */
+struct external_nlist {
+ bfd_byte e_strx[BYTES_IN_WORD]; /* index into string table of name */
+ bfd_byte e_type[1]; /* type of symbol */
+ bfd_byte e_other[1]; /* misc info (usually empty) */
+ bfd_byte e_desc[2]; /* description field */
+ bfd_byte e_value[BYTES_IN_WORD]; /* value of symbol */
+};
+
+#define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
+
+struct internal_nlist {
+ unsigned long n_strx; /* index into string table of name */
+ unsigned char n_type; /* type of symbol */
+ unsigned char n_other; /* misc info (usually empty) */
+ unsigned short n_desc; /* description field */
+ bfd_vma n_value; /* value of symbol */
+};
+
+/* The n_type field is the symbol type, containing: */
+
+#define N_UNDF 0 /* Undefined symbol */
+#define N_ABS 2 /* Absolute symbol -- defined at particular addr */
+#define N_TEXT 4 /* Text sym -- defined at offset in text seg */
+#define N_DATA 6 /* Data sym -- defined at offset in data seg */
+#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */
+#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
+#define N_FN 0x1f /* File name of .o file */
+#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */
+/* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT,
+ N_DATA, or N_BSS. When the low-order bit of other types is set,
+ (e.g. N_WARNING versus N_FN), they are two different types. */
+#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */
+#define N_TYPE 0x1e
+#define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */
+
+#define N_INDR 0x0a
+
+/* The following symbols refer to set elements.
+ All the N_SET[ATDB] symbols with the same name form one set.
+ Space is allocated for the set in the text section, and each set
+ elements value is stored into one word of the space.
+ The first word of the space is the length of the set (number of elements).
+
+ The address of the set is made into an N_SETV symbol
+ whose name is the same as the name of the set.
+ This symbol acts like a N_DATA global symbol
+ in that it can satisfy undefined external references. */
+
+/* These appear as input to LD, in a .o file. */
+#define N_SETA 0x14 /* Absolute set element symbol */
+#define N_SETT 0x16 /* Text set element symbol */
+#define N_SETD 0x18 /* Data set element symbol */
+#define N_SETB 0x1A /* Bss set element symbol */
+
+/* This is output from LD. */
+#define N_SETV 0x1C /* Pointer to set vector in data area. */
+
+/* Warning symbol. The text gives a warning message, the next symbol
+ in the table will be undefined. When the symbol is referenced, the
+ message is printed. */
+
+#define N_WARNING 0x1e
+
+/* Relocations
+
+ There are two types of relocation flavours for a.out systems,
+ standard and extended. The standard form is used on systems where the
+ instruction has room for all the bits of an offset to the operand, whilst
+ the extended form is used when an address operand has to be split over n
+ instructions. Eg, on the 68k, each move instruction can reference
+ the target with a displacement of 16 or 32 bits. On the sparc, move
+ instructions use an offset of 14 bits, so the offset is stored in
+ the reloc field, and the data in the section is ignored.
+*/
+
+/* This structure describes a single relocation to be performed.
+ The text-relocation section of the file is a vector of these structures,
+ all of which apply to the text section.
+ Likewise, the data-relocation section applies to the data section. */
+
+struct reloc_std_external {
+ bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
+ bfd_byte r_index[3]; /* symbol table index of symbol */
+ bfd_byte r_type[1]; /* relocation type */
+};
+
+#define RELOC_STD_BITS_PCREL_BIG 0x80
+#define RELOC_STD_BITS_PCREL_LITTLE 0x01
+
+#define RELOC_STD_BITS_LENGTH_BIG 0x60
+#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
+#define RELOC_STD_BITS_LENGTH_LITTLE 0x06
+#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
+
+#define RELOC_STD_BITS_EXTERN_BIG 0x10
+#define RELOC_STD_BITS_EXTERN_LITTLE 0x08
+
+#define RELOC_STD_BITS_BASEREL_BIG 0x08
+#define RELOC_STD_BITS_BASEREL_LITTLE 0x08
+
+#define RELOC_STD_BITS_JMPTABLE_BIG 0x04
+#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
+
+#define RELOC_STD_BITS_RELATIVE_BIG 0x02
+#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
+
+#define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
+
+struct reloc_std_internal
+{
+ bfd_vma r_address; /* Address (within segment) to be relocated. */
+ /* The meaning of r_symbolnum depends on r_extern. */
+ unsigned int r_symbolnum:24;
+ /* Nonzero means value is a pc-relative offset
+ and it should be relocated for changes in its own address
+ as well as for changes in the symbol or section specified. */
+ unsigned int r_pcrel:1;
+ /* Length (as exponent of 2) of the field to be relocated.
+ Thus, a value of 2 indicates 1<<2 bytes. */
+ unsigned int r_length:2;
+ /* 1 => relocate with value of symbol.
+ r_symbolnum is the index of the symbol
+ in files the symbol table.
+ 0 => relocate with the address of a segment.
+ r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
+ (the N_EXT bit may be set also, but signifies nothing). */
+ unsigned int r_extern:1;
+ /* The next three bits are for SunOS shared libraries, and seem to
+ be undocumented. */
+ unsigned int r_baserel:1; /* Linkage table relative */
+ unsigned int r_jmptable:1; /* pc-relative to jump table */
+ unsigned int r_relative:1; /* "relative relocation" */
+ /* unused */
+ unsigned int r_pad:1; /* Padding -- set to zero */
+};
+
+
+/* EXTENDED RELOCS */
+
+struct reloc_ext_external {
+ bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
+ bfd_byte r_index[3]; /* symbol table index of symbol */
+ bfd_byte r_type[1]; /* relocation type */
+ bfd_byte r_addend[BYTES_IN_WORD]; /* datum addend */
+};
+
+#define RELOC_EXT_BITS_EXTERN_BIG 0x80
+#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
+
+#define RELOC_EXT_BITS_TYPE_BIG 0x1F
+#define RELOC_EXT_BITS_TYPE_SH_BIG 0
+#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
+#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
+
+/* Bytes per relocation entry */
+#define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD)
+
+enum reloc_type
+{
+ /* simple relocations */
+ RELOC_8, /* data[0:7] = addend + sv */
+ RELOC_16, /* data[0:15] = addend + sv */
+ RELOC_32, /* data[0:31] = addend + sv */
+ /* pc-rel displacement */
+ RELOC_DISP8, /* data[0:7] = addend - pc + sv */
+ RELOC_DISP16, /* data[0:15] = addend - pc + sv */
+ RELOC_DISP32, /* data[0:31] = addend - pc + sv */
+ /* Special */
+ RELOC_WDISP30, /* data[0:29] = (addend + sv - pc)>>2 */
+ RELOC_WDISP22, /* data[0:21] = (addend + sv - pc)>>2 */
+ RELOC_HI22, /* data[0:21] = (addend + sv)>>10 */
+ RELOC_22, /* data[0:21] = (addend + sv) */
+ RELOC_13, /* data[0:12] = (addend + sv) */
+ RELOC_LO10, /* data[0:9] = (addend + sv) */
+ RELOC_SFA_BASE,
+ RELOC_SFA_OFF13,
+ /* P.I.C. (base-relative) */
+ RELOC_BASE10, /* Not sure - maybe we can do this the */
+ RELOC_BASE13, /* right way now */
+ RELOC_BASE22,
+ /* for some sort of pc-rel P.I.C. (?) */
+ RELOC_PC10,
+ RELOC_PC22,
+ /* P.I.C. jump table */
+ RELOC_JMP_TBL,
+ /* reputedly for shared libraries somehow */
+ RELOC_SEGOFF16,
+ RELOC_GLOB_DAT,
+ RELOC_JMP_SLOT,
+ RELOC_RELATIVE,
+
+ RELOC_11,
+ RELOC_WDISP2_14,
+ RELOC_WDISP19,
+ RELOC_HHI22, /* data[0:21] = (addend + sv) >> 42 */
+ RELOC_HLO10, /* data[0:9] = (addend + sv) >> 32 */
+
+ /* 29K relocation types */
+ RELOC_JUMPTARG,
+ RELOC_CONST,
+ RELOC_CONSTH,
+
+ NO_RELOC
+ };
+
+
+struct reloc_internal {
+ bfd_vma r_address; /* offset of of data to relocate */
+ long r_index; /* symbol table index of symbol */
+ enum reloc_type r_type; /* relocation type */
+ bfd_vma r_addend; /* datum addend */
+};
+
+#endif /* __A_OUT_ADOBE_H__ */
diff --git a/include/aout/aout64.h b/include/aout/aout64.h
new file mode 100644
index 00000000000..76f1140b682
--- /dev/null
+++ b/include/aout/aout64.h
@@ -0,0 +1,475 @@
+/* `a.out' object-file definitions, including extensions to 64-bit fields */
+
+#ifndef __A_OUT_64_H__
+#define __A_OUT_64_H__
+
+/* This is the layout on disk of the 32-bit or 64-bit exec header. */
+
+#ifndef external_exec
+struct external_exec
+{
+ bfd_byte e_info[4]; /* magic number and stuff */
+ bfd_byte e_text[BYTES_IN_WORD]; /* length of text section in bytes */
+ bfd_byte e_data[BYTES_IN_WORD]; /* length of data section in bytes */
+ bfd_byte e_bss[BYTES_IN_WORD]; /* length of bss area in bytes */
+ bfd_byte e_syms[BYTES_IN_WORD]; /* length of symbol table in bytes */
+ bfd_byte e_entry[BYTES_IN_WORD]; /* start address */
+ bfd_byte e_trsize[BYTES_IN_WORD]; /* length of text relocation info */
+ bfd_byte e_drsize[BYTES_IN_WORD]; /* length of data relocation info */
+};
+
+#define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
+
+/* Magic numbers for a.out files */
+
+#if ARCH_SIZE==64
+#define OMAGIC 0x1001 /* Code indicating object file */
+#define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */
+#define NMAGIC 0x1003 /* Code indicating pure executable. */
+
+/* There is no 64-bit QMAGIC as far as I know. */
+
+#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
+ && N_MAGIC(x) != NMAGIC \
+ && N_MAGIC(x) != ZMAGIC)
+#else
+#define OMAGIC 0407 /* ...object file or impure executable. */
+#define NMAGIC 0410 /* Code indicating pure executable. */
+#define ZMAGIC 0413 /* Code indicating demand-paged executable. */
+#define BMAGIC 0415 /* Used by a b.out object. */
+
+/* This indicates a demand-paged executable with the header in the text.
+ It is used by 386BSD (and variants) and Linux, at least. */
+#ifndef QMAGIC
+#define QMAGIC 0314
+#endif
+# ifndef N_BADMAG
+# define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
+ && N_MAGIC(x) != NMAGIC \
+ && N_MAGIC(x) != ZMAGIC \
+ && N_MAGIC(x) != QMAGIC)
+# endif /* N_BADMAG */
+#endif
+
+#endif
+
+#ifdef QMAGIC
+#define N_IS_QMAGIC(x) (N_MAGIC (x) == QMAGIC)
+#else
+#define N_IS_QMAGIC(x) (0)
+#endif
+
+/* The difference between TARGET_PAGE_SIZE and N_SEGSIZE is that TARGET_PAGE_SIZE is
+ the finest granularity at which you can page something, thus it
+ controls the padding (if any) before the text segment of a ZMAGIC
+ file. N_SEGSIZE is the resolution at which things can be marked as
+ read-only versus read/write, so it controls the padding between the
+ text segment and the data segment (in memory; on disk the padding
+ between them is TARGET_PAGE_SIZE). TARGET_PAGE_SIZE and N_SEGSIZE are the same
+ for most machines, but different for sun3. */
+
+/* By default, segment size is constant. But some machines override this
+ to be a function of the a.out header (e.g. machine type). */
+
+#ifndef N_SEGSIZE
+#define N_SEGSIZE(x) SEGMENT_SIZE
+#endif
+
+/* Virtual memory address of the text section.
+ This is getting very complicated. A good reason to discard a.out format
+ for something that specifies these fields explicitly. But til then...
+
+ * OMAGIC and NMAGIC files:
+ (object files: text for "relocatable addr 0" right after the header)
+ start at 0, offset is EXEC_BYTES_SIZE, size as stated.
+ * The text address, offset, and size of ZMAGIC files depend
+ on the entry point of the file:
+ * entry point below TEXT_START_ADDR:
+ (hack for SunOS shared libraries)
+ start at 0, offset is 0, size as stated.
+ * If N_HEADER_IN_TEXT(x) is true (which defaults to being the
+ case when the entry point is EXEC_BYTES_SIZE or further into a page):
+ no padding is needed; text can start after exec header. Sun
+ considers the text segment of such files to include the exec header;
+ for BFD's purposes, we don't, which makes more work for us.
+ start at TEXT_START_ADDR + EXEC_BYTES_SIZE, offset is EXEC_BYTES_SIZE,
+ size as stated minus EXEC_BYTES_SIZE.
+ * If N_HEADER_IN_TEXT(x) is false (which defaults to being the case when
+ the entry point is less than EXEC_BYTES_SIZE into a page (e.g. page
+ aligned)): (padding is needed so that text can start at a page boundary)
+ start at TEXT_START_ADDR, offset TARGET_PAGE_SIZE, size as stated.
+
+ Specific configurations may want to hardwire N_HEADER_IN_TEXT,
+ for efficiency or to allow people to play games with the entry point.
+ In that case, you would #define N_HEADER_IN_TEXT(x) as 1 for sunos,
+ and as 0 for most other hosts (Sony News, Vax Ultrix, etc).
+ (Do this in the appropriate bfd target file.)
+ (The default is a heuristic that will break if people try changing
+ the entry point, perhaps with the ld -e flag.)
+
+ * QMAGIC is always like a ZMAGIC for which N_HEADER_IN_TEXT is true,
+ and for which the starting address is TARGET_PAGE_SIZE (or should this be
+ SEGMENT_SIZE?) (TEXT_START_ADDR only applies to ZMAGIC, not to QMAGIC).
+ */
+
+/* This macro is only relevant for ZMAGIC files; QMAGIC always has the header
+ in the text. */
+#ifndef N_HEADER_IN_TEXT
+#define N_HEADER_IN_TEXT(x) (((x).a_entry & (TARGET_PAGE_SIZE-1)) >= EXEC_BYTES_SIZE)
+#endif
+
+/* Sun shared libraries, not linux. This macro is only relevant for ZMAGIC
+ files. */
+#ifndef N_SHARED_LIB
+#define N_SHARED_LIB(x) ((x).a_entry < TEXT_START_ADDR)
+#endif
+
+/* Returning 0 not TEXT_START_ADDR for OMAGIC and NMAGIC is based on
+ the assumption that we are dealing with a .o file, not an
+ executable. This is necessary for OMAGIC (but means we don't work
+ right on the output from ld -N); more questionable for NMAGIC. */
+
+#ifndef N_TXTADDR
+#define N_TXTADDR(x) \
+ (/* The address of a QMAGIC file is always one page in, */ \
+ /* with the header in the text. */ \
+ N_IS_QMAGIC (x) ? TARGET_PAGE_SIZE + EXEC_BYTES_SIZE : \
+ N_MAGIC(x) != ZMAGIC ? 0 : /* object file or NMAGIC */\
+ N_SHARED_LIB(x) ? 0 : \
+ N_HEADER_IN_TEXT(x) ? \
+ TEXT_START_ADDR + EXEC_BYTES_SIZE : /* no padding */\
+ TEXT_START_ADDR /* a page of padding */\
+ )
+#endif
+
+/* If N_HEADER_IN_TEXT is not true for ZMAGIC, there is some padding
+ to make the text segment start at a certain boundary. For most
+ systems, this boundary is TARGET_PAGE_SIZE. But for Linux, in the
+ time-honored tradition of crazy ZMAGIC hacks, it is 1024 which is
+ not what TARGET_PAGE_SIZE needs to be for QMAGIC. */
+
+#ifndef ZMAGIC_DISK_BLOCK_SIZE
+#define ZMAGIC_DISK_BLOCK_SIZE TARGET_PAGE_SIZE
+#endif
+
+#define N_DISK_BLOCK_SIZE(x) \
+ (N_MAGIC(x) == ZMAGIC ? ZMAGIC_DISK_BLOCK_SIZE : TARGET_PAGE_SIZE)
+
+/* Offset in an a.out of the start of the text section. */
+#ifndef N_TXTOFF
+#define N_TXTOFF(x) \
+ (/* For {O,N,Q}MAGIC, no padding. */ \
+ N_MAGIC(x) != ZMAGIC ? EXEC_BYTES_SIZE : \
+ N_SHARED_LIB(x) ? 0 : \
+ N_HEADER_IN_TEXT(x) ? \
+ EXEC_BYTES_SIZE : /* no padding */\
+ ZMAGIC_DISK_BLOCK_SIZE /* a page of padding */\
+ )
+#endif
+/* Size of the text section. It's always as stated, except that we
+ offset it to `undo' the adjustment to N_TXTADDR and N_TXTOFF
+ for ZMAGIC files that nominally include the exec header
+ as part of the first page of text. (BFD doesn't consider the
+ exec header to be part of the text segment.) */
+#ifndef N_TXTSIZE
+#define N_TXTSIZE(x) \
+ (/* For QMAGIC, we don't consider the header part of the text section. */\
+ N_IS_QMAGIC (x) ? (x).a_text - EXEC_BYTES_SIZE : \
+ (N_MAGIC(x) != ZMAGIC || N_SHARED_LIB(x)) ? (x).a_text : \
+ N_HEADER_IN_TEXT(x) ? \
+ (x).a_text - EXEC_BYTES_SIZE: /* no padding */\
+ (x).a_text /* a page of padding */\
+ )
+#endif
+/* The address of the data segment in virtual memory.
+ It is the text segment address, plus text segment size, rounded
+ up to a N_SEGSIZE boundary for pure or pageable files. */
+#ifndef N_DATADDR
+#define N_DATADDR(x) \
+ (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+N_TXTSIZE(x)) \
+ : (N_SEGSIZE(x) + ((N_TXTADDR(x)+N_TXTSIZE(x)-1) & ~(N_SEGSIZE(x)-1))))
+#endif
+/* The address of the BSS segment -- immediately after the data segment. */
+
+#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
+
+/* Offsets of the various portions of the file after the text segment. */
+
+/* For {Q,Z}MAGIC, there is padding to make the data segment start on
+ a page boundary. Most of the time the a_text field (and thus
+ N_TXTSIZE) already contains this padding. It is possible that for
+ BSDI and/or 386BSD it sometimes doesn't contain the padding, and
+ perhaps we should be adding it here. But this seems kind of
+ questionable and probably should be BSDI/386BSD-specific if we do
+ do it.
+
+ For NMAGIC (at least for hp300 BSD, probably others), there is
+ padding in memory only, not on disk, so we must *not* ever pad here
+ for NMAGIC. */
+
+#ifndef N_DATOFF
+#define N_DATOFF(x) \
+ (N_TXTOFF(x) + N_TXTSIZE(x))
+#endif
+
+#ifndef N_TRELOFF
+#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
+#endif
+#ifndef N_DRELOFF
+#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
+#endif
+#ifndef N_SYMOFF
+#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
+#endif
+#ifndef N_STROFF
+#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
+#endif
+
+/* Symbols */
+#ifndef external_nlist
+struct external_nlist {
+ bfd_byte e_strx[BYTES_IN_WORD]; /* index into string table of name */
+ bfd_byte e_type[1]; /* type of symbol */
+ bfd_byte e_other[1]; /* misc info (usually empty) */
+ bfd_byte e_desc[2]; /* description field */
+ bfd_byte e_value[BYTES_IN_WORD]; /* value of symbol */
+};
+#define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
+#endif
+
+struct internal_nlist {
+ unsigned long n_strx; /* index into string table of name */
+ unsigned char n_type; /* type of symbol */
+ unsigned char n_other; /* misc info (usually empty) */
+ unsigned short n_desc; /* description field */
+ bfd_vma n_value; /* value of symbol */
+};
+
+/* The n_type field is the symbol type, containing: */
+
+#define N_UNDF 0 /* Undefined symbol */
+#define N_ABS 2 /* Absolute symbol -- defined at particular addr */
+#define N_TEXT 4 /* Text sym -- defined at offset in text seg */
+#define N_DATA 6 /* Data sym -- defined at offset in data seg */
+#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */
+#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
+#define N_FN 0x1f /* File name of .o file */
+#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */
+/* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT,
+ N_DATA, or N_BSS. When the low-order bit of other types is set,
+ (e.g. N_WARNING versus N_FN), they are two different types. */
+#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */
+#define N_TYPE 0x1e
+#define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */
+
+#define N_INDR 0x0a
+
+/* The following symbols refer to set elements.
+ All the N_SET[ATDB] symbols with the same name form one set.
+ Space is allocated for the set in the text section, and each set
+ elements value is stored into one word of the space.
+ The first word of the space is the length of the set (number of elements).
+
+ The address of the set is made into an N_SETV symbol
+ whose name is the same as the name of the set.
+ This symbol acts like a N_DATA global symbol
+ in that it can satisfy undefined external references. */
+
+/* These appear as input to LD, in a .o file. */
+#define N_SETA 0x14 /* Absolute set element symbol */
+#define N_SETT 0x16 /* Text set element symbol */
+#define N_SETD 0x18 /* Data set element symbol */
+#define N_SETB 0x1A /* Bss set element symbol */
+
+/* This is output from LD. */
+#define N_SETV 0x1C /* Pointer to set vector in data area. */
+
+/* Warning symbol. The text gives a warning message, the next symbol
+ in the table will be undefined. When the symbol is referenced, the
+ message is printed. */
+
+#define N_WARNING 0x1e
+
+/* Weak symbols. These are a GNU extension to the a.out format. The
+ semantics are those of ELF weak symbols. Weak symbols are always
+ externally visible. The N_WEAK? values are squeezed into the
+ available slots. The value of a N_WEAKU symbol is 0. The values
+ of the other types are the definitions. */
+#define N_WEAKU 0x0d /* Weak undefined symbol. */
+#define N_WEAKA 0x0e /* Weak absolute symbol. */
+#define N_WEAKT 0x0f /* Weak text symbol. */
+#define N_WEAKD 0x10 /* Weak data symbol. */
+#define N_WEAKB 0x11 /* Weak bss symbol. */
+
+/* Relocations
+
+ There are two types of relocation flavours for a.out systems,
+ standard and extended. The standard form is used on systems where the
+ instruction has room for all the bits of an offset to the operand, whilst
+ the extended form is used when an address operand has to be split over n
+ instructions. Eg, on the 68k, each move instruction can reference
+ the target with a displacement of 16 or 32 bits. On the sparc, move
+ instructions use an offset of 14 bits, so the offset is stored in
+ the reloc field, and the data in the section is ignored.
+*/
+
+/* This structure describes a single relocation to be performed.
+ The text-relocation section of the file is a vector of these structures,
+ all of which apply to the text section.
+ Likewise, the data-relocation section applies to the data section. */
+
+struct reloc_std_external {
+ bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
+ bfd_byte r_index[3]; /* symbol table index of symbol */
+ bfd_byte r_type[1]; /* relocation type */
+};
+
+#define RELOC_STD_BITS_PCREL_BIG ((unsigned int) 0x80)
+#define RELOC_STD_BITS_PCREL_LITTLE ((unsigned int) 0x01)
+
+#define RELOC_STD_BITS_LENGTH_BIG ((unsigned int) 0x60)
+#define RELOC_STD_BITS_LENGTH_SH_BIG 5
+#define RELOC_STD_BITS_LENGTH_LITTLE ((unsigned int) 0x06)
+#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
+
+#define RELOC_STD_BITS_EXTERN_BIG ((unsigned int) 0x10)
+#define RELOC_STD_BITS_EXTERN_LITTLE ((unsigned int) 0x08)
+
+#define RELOC_STD_BITS_BASEREL_BIG ((unsigned int) 0x08)
+#define RELOC_STD_BITS_BASEREL_LITTLE ((unsigned int) 0x10)
+
+#define RELOC_STD_BITS_JMPTABLE_BIG ((unsigned int) 0x04)
+#define RELOC_STD_BITS_JMPTABLE_LITTLE ((unsigned int) 0x20)
+
+#define RELOC_STD_BITS_RELATIVE_BIG ((unsigned int) 0x02)
+#define RELOC_STD_BITS_RELATIVE_LITTLE ((unsigned int) 0x40)
+
+#define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
+
+struct reloc_std_internal
+{
+ bfd_vma r_address; /* Address (within segment) to be relocated. */
+ /* The meaning of r_symbolnum depends on r_extern. */
+ unsigned int r_symbolnum:24;
+ /* Nonzero means value is a pc-relative offset
+ and it should be relocated for changes in its own address
+ as well as for changes in the symbol or section specified. */
+ unsigned int r_pcrel:1;
+ /* Length (as exponent of 2) of the field to be relocated.
+ Thus, a value of 2 indicates 1<<2 bytes. */
+ unsigned int r_length:2;
+ /* 1 => relocate with value of symbol.
+ r_symbolnum is the index of the symbol
+ in files the symbol table.
+ 0 => relocate with the address of a segment.
+ r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
+ (the N_EXT bit may be set also, but signifies nothing). */
+ unsigned int r_extern:1;
+ /* The next three bits are for SunOS shared libraries, and seem to
+ be undocumented. */
+ unsigned int r_baserel:1; /* Linkage table relative */
+ unsigned int r_jmptable:1; /* pc-relative to jump table */
+ unsigned int r_relative:1; /* "relative relocation" */
+ /* unused */
+ unsigned int r_pad:1; /* Padding -- set to zero */
+};
+
+
+/* EXTENDED RELOCS */
+
+struct reloc_ext_external {
+ bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
+ bfd_byte r_index[3]; /* symbol table index of symbol */
+ bfd_byte r_type[1]; /* relocation type */
+ bfd_byte r_addend[BYTES_IN_WORD]; /* datum addend */
+};
+
+#define RELOC_EXT_BITS_EXTERN_BIG ((unsigned int) 0x80)
+#define RELOC_EXT_BITS_EXTERN_LITTLE ((unsigned int) 0x01)
+
+#define RELOC_EXT_BITS_TYPE_BIG ((unsigned int) 0x1F)
+#define RELOC_EXT_BITS_TYPE_SH_BIG 0
+#define RELOC_EXT_BITS_TYPE_LITTLE ((unsigned int) 0xF8)
+#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
+
+/* Bytes per relocation entry */
+#define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD)
+
+enum reloc_type
+{
+ /* simple relocations */
+ RELOC_8, /* data[0:7] = addend + sv */
+ RELOC_16, /* data[0:15] = addend + sv */
+ RELOC_32, /* data[0:31] = addend + sv */
+ /* pc-rel displacement */
+ RELOC_DISP8, /* data[0:7] = addend - pc + sv */
+ RELOC_DISP16, /* data[0:15] = addend - pc + sv */
+ RELOC_DISP32, /* data[0:31] = addend - pc + sv */
+ /* Special */
+ RELOC_WDISP30, /* data[0:29] = (addend + sv - pc)>>2 */
+ RELOC_WDISP22, /* data[0:21] = (addend + sv - pc)>>2 */
+ RELOC_HI22, /* data[0:21] = (addend + sv)>>10 */
+ RELOC_22, /* data[0:21] = (addend + sv) */
+ RELOC_13, /* data[0:12] = (addend + sv) */
+ RELOC_LO10, /* data[0:9] = (addend + sv) */
+ RELOC_SFA_BASE,
+ RELOC_SFA_OFF13,
+ /* P.I.C. (base-relative) */
+ RELOC_BASE10, /* Not sure - maybe we can do this the */
+ RELOC_BASE13, /* right way now */
+ RELOC_BASE22,
+ /* for some sort of pc-rel P.I.C. (?) */
+ RELOC_PC10,
+ RELOC_PC22,
+ /* P.I.C. jump table */
+ RELOC_JMP_TBL,
+ /* reputedly for shared libraries somehow */
+ RELOC_SEGOFF16,
+ RELOC_GLOB_DAT,
+ RELOC_JMP_SLOT,
+ RELOC_RELATIVE,
+
+ RELOC_11,
+ RELOC_WDISP2_14,
+ RELOC_WDISP19,
+ RELOC_HHI22, /* data[0:21] = (addend + sv) >> 42 */
+ RELOC_HLO10, /* data[0:9] = (addend + sv) >> 32 */
+
+ /* 29K relocation types */
+ RELOC_JUMPTARG,
+ RELOC_CONST,
+ RELOC_CONSTH,
+
+ /* All the new ones I can think of, for sparc v9 */
+
+ RELOC_64, /* data[0:63] = addend + sv */
+ RELOC_DISP64, /* data[0:63] = addend - pc + sv */
+ RELOC_WDISP21, /* data[0:20] = (addend + sv - pc)>>2 */
+ RELOC_DISP21, /* data[0:20] = addend - pc + sv */
+ RELOC_DISP14, /* data[0:13] = addend - pc + sv */
+ /* Q .
+ What are the other ones,
+ Since this is a clean slate, can we throw away the ones we dont
+ understand ? Should we sort the values ? What about using a
+ microcode format like the 68k ?
+ */
+ NO_RELOC
+ };
+
+
+struct reloc_internal {
+ bfd_vma r_address; /* offset of of data to relocate */
+ long r_index; /* symbol table index of symbol */
+ enum reloc_type r_type; /* relocation type */
+ bfd_vma r_addend; /* datum addend */
+};
+
+/* Q.
+ Should the length of the string table be 4 bytes or 8 bytes ?
+
+ Q.
+ What about archive indexes ?
+
+ */
+
+#endif /* __A_OUT_64_H__ */
diff --git a/include/aout/ar.h b/include/aout/ar.h
new file mode 100644
index 00000000000..7b5dcdabd10
--- /dev/null
+++ b/include/aout/ar.h
@@ -0,0 +1,36 @@
+/* archive file definition for GNU software */
+
+/* So far this is correct for BSDish archives. Don't forget that
+ files must begin on an even byte boundary. */
+
+#ifndef __GNU_AR_H__
+#define __GNU_AR_H__
+
+/* Note that the usual '\n' in magic strings may translate to different
+ characters, as allowed by ANSI. '\012' has a fixed value, and remains
+ compatible with existing BSDish archives. */
+
+#define ARMAG "!<arch>\012" /* For COFF and a.out archives */
+#define ARMAGB "!<bout>\012" /* For b.out archives */
+#define SARMAG 8
+#define ARFMAG "`\012"
+
+/* The ar_date field of the armap (__.SYMDEF) member of an archive
+ must be greater than the modified date of the entire file, or
+ BSD-derived linkers complain. We originally write the ar_date with
+ this offset from the real file's mod-time. After finishing the
+ file, we rewrite ar_date if it's not still greater than the mod date. */
+
+#define ARMAP_TIME_OFFSET 60
+
+struct ar_hdr {
+ char ar_name[16]; /* name of this member */
+ char ar_date[12]; /* file mtime */
+ char ar_uid[6]; /* owner uid; printed as decimal */
+ char ar_gid[6]; /* owner gid; printed as decimal */
+ char ar_mode[8]; /* file mode, printed as octal */
+ char ar_size[10]; /* file size, printed as decimal */
+ char ar_fmag[2]; /* should contain ARFMAG */
+};
+
+#endif /* __GNU_AR_H__ */
diff --git a/include/aout/dynix3.h b/include/aout/dynix3.h
new file mode 100644
index 00000000000..efeeebfc4cc
--- /dev/null
+++ b/include/aout/dynix3.h
@@ -0,0 +1,71 @@
+/*
+ * a.out specifics for Sequent Symmetry running Dynix 3.x
+ */
+#ifndef A_OUT_DYNIX3_H
+#define A_OUT_DYNIX3_H
+
+#define external_exec dynix_external_exec
+
+/* struct exec for Dynix 3
+ *
+ * a_gdtbl and a_bootstrap are only for standalone binaries.
+ * Shared data fields are not supported by the kernel as of Dynix 3.1,
+ * but are supported by Dynix compiler programs.
+ */
+struct dynix_external_exec {
+ unsigned char e_info[4];
+ unsigned char e_text[4];
+ unsigned char e_data[4];
+ unsigned char e_bss[4];
+ unsigned char e_syms[4];
+ unsigned char e_entry[4];
+ unsigned char e_trsize[4];
+ unsigned char e_drsize[4];
+ unsigned char e_g_code[8], e_g_data[8], e_g_desc[8];
+ unsigned char e_shdata[4];
+ unsigned char e_shbss[4];
+ unsigned char e_shdrsize[4];
+ unsigned char e_bootstrap[44];
+ unsigned char e_reserved[12];
+ unsigned char e_version[4];
+};
+
+#define EXEC_BYTES_SIZE (128)
+
+/*
+ * All executables under Dynix are demand paged with read-only text,
+ * Thus no NMAGIC.
+ *
+ * ZMAGIC has a page of 0s at virtual 0,
+ * XMAGIC has an invalid page at virtual 0
+ */
+#define OMAGIC 0x12eb /* .o */
+#define ZMAGIC 0x22eb /* zero @ 0, demand load */
+#define XMAGIC 0x32eb /* invalid @ 0, demand load */
+#define SMAGIC 0x42eb /* standalone, not supported here */
+
+#define N_BADMAG(x) ((OMAGIC != N_MAGIC(x)) && \
+ (ZMAGIC != N_MAGIC(x)) && \
+ (XMAGIC != N_MAGIC(x)) && \
+ (SMAGIC != N_MAGIC(x)))
+
+#define N_ADDRADJ(x) ((ZMAGIC == N_MAGIC(x) || XMAGIC == N_MAGIC(x)) ? 0x1000 : 0)
+
+#define N_TXTOFF(x) (EXEC_BYTES_SIZE)
+#define N_DATOFF(x) (N_TXTOFF(x) + N_TXTSIZE(x))
+#define N_SHDATOFF(x) (N_DATOFF(x) + (x).a_data)
+#define N_TRELOFF(x) (N_SHDATOFF(x) + (x).a_shdata)
+#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
+#define N_SHDRELOFF(x) (N_DRELOFF(x) + (x).a_drsize)
+#define N_SYMOFF(x) (N_SHDRELOFF(x) + (x).a_shdrsize)
+#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
+
+#define N_TXTADDR(x) \
+ (((OMAGIC == N_MAGIC(x)) || (SMAGIC == N_MAGIC(x))) ? 0 \
+ : TEXT_START_ADDR + EXEC_BYTES_SIZE)
+
+#define N_TXTSIZE(x) \
+ (((OMAGIC == N_MAGIC(x)) || (SMAGIC == N_MAGIC(x))) ? ((x).a_text) \
+ : ((x).a_text - N_ADDRADJ(x) - EXEC_BYTES_SIZE))
+
+#endif /* A_OUT_DYNIX3_H */
diff --git a/include/aout/encap.h b/include/aout/encap.h
new file mode 100644
index 00000000000..b215d49be16
--- /dev/null
+++ b/include/aout/encap.h
@@ -0,0 +1,135 @@
+/* Yet Another Try at encapsulating bsd object files in coff.
+ Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
+ Written by Pace Willisson 12/9/88
+
+ This file is obsolete. It needs to be converted to just define a bunch
+ of stuff that BFD can use to do coff-encapsulated files. --gnu@cygnus.com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+ * We only use the coff headers to tell the kernel
+ * how to exec the file. Therefore, the only fields that need to
+ * be filled in are the scnptr and vaddr for the text and data
+ * sections, and the vaddr for the bss. As far as coff is concerned,
+ * there is no symbol table, relocation, or line numbers.
+ *
+ * A normal bsd header (struct exec) is placed after the coff headers,
+ * and before the real text. I defined a the new fields 'a_machtype'
+ * and a_flags. If a_machtype is M_386, and a_flags & A_ENCAP is
+ * true, then the bsd header is preceeded by a coff header. Macros
+ * like N_TXTOFF and N_TXTADDR use this field to find the bsd header.
+ *
+ * The only problem is to track down the bsd exec header. The
+ * macros HEADER_OFFSET, etc do this.
+ */
+
+#define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */
+
+/* Describe the COFF header used for encapsulation. */
+
+struct coffheader
+{
+ /* filehdr */
+ unsigned short f_magic;
+ unsigned short f_nscns;
+ long f_timdat;
+ long f_symptr;
+ long f_nsyms;
+ unsigned short f_opthdr;
+ unsigned short f_flags;
+ /* aouthdr */
+ short magic;
+ short vstamp;
+ long tsize;
+ long dsize;
+ long bsize;
+ long entry;
+ long text_start;
+ long data_start;
+ struct coffscn
+ {
+ char s_name[8];
+ long s_paddr;
+ long s_vaddr;
+ long s_size;
+ long s_scnptr;
+ long s_relptr;
+ long s_lnnoptr;
+ unsigned short s_nreloc;
+ unsigned short s_nlnno;
+ long s_flags;
+ } scns[3];
+};
+
+/* Describe some of the parameters of the encapsulation,
+ including how to find the encapsulated BSD header. */
+
+/* FIXME, this is dumb. The same tools can't handle a.outs for different
+ architectures, just because COFF_MAGIC is different; so you need a
+ separate GNU nm for every architecture!!? Unfortunately, it needs to
+ be this way, since the COFF_MAGIC value is determined by the kernel
+ we're trying to fool here. */
+
+#define COFF_MAGIC_I386 0514 /* I386MAGIC */
+#define COFF_MAGIC_M68K 0520 /* MC68MAGIC */
+#define COFF_MAGIC_A29K 0x17A /* Used by asm29k cross-tools */
+
+#ifdef COFF_MAGIC
+short __header_offset_temp;
+#define HEADER_OFFSET(f) \
+ (__header_offset_temp = 0, \
+ fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \
+ fseek ((f), -sizeof (short), 1), \
+ __header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
+#else
+#define HEADER_OFFSET(f) 0
+#endif
+
+#define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1))
+
+/* Describe the characteristics of the BSD header
+ that appears inside the encapsulation. */
+
+/* Encapsulated coff files that are linked ZMAGIC have a text segment
+ offset just past the header (and a matching TXTADDR), excluding
+ the headers from the text segment proper but keeping the physical
+ layout and the virtual memory layout page-aligned.
+
+ Non-encapsulated a.out files that are linked ZMAGIC have a text
+ segment that starts at 0 and an N_TXTADR similarly offset to 0.
+ They too are page-aligned with each other, but they include the
+ a.out header as part of the text.
+
+ The _N_HDROFF gets sizeof struct exec added to it, so we have
+ to compensate here. See <a.out.gnu.h>. */
+
+#undef _N_HDROFF
+#undef N_TXTADDR
+#undef N_DATADDR
+
+#define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
+ sizeof (struct coffheader) : 0)
+
+/* Address of text segment in memory after it is loaded. */
+#define N_TXTADDR(x) \
+ ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
+ sizeof (struct coffheader) + sizeof (struct exec) : 0)
+#define SEGMENT_SIZE 0x400000
+
+#define N_DATADDR(x) \
+ ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
+ (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
+ (N_TXTADDR(x)+(x).a_text))
diff --git a/include/aout/host.h b/include/aout/host.h
new file mode 100644
index 00000000000..8e36212716c
--- /dev/null
+++ b/include/aout/host.h
@@ -0,0 +1,22 @@
+/* Parameters about the a.out format, based on the host system on which
+ the program is compiled. */
+
+/* Address of data segment in memory after it is loaded.
+ It is up to you to define SEGMENT_SIZE
+ on machines not listed here. */
+#ifndef SEGMENT_SIZE
+#if defined(hp300) || defined(pyr)
+#define SEGMENT_SIZE page_size
+#endif
+#ifdef sony
+#define SEGMENT_SIZE 0x1000
+#endif /* Sony. */
+#ifdef is68k
+#define SEGMENT_SIZE 0x20000
+#endif
+#if defined(m68k) && defined(PORTAR)
+#define TARGET_PAGE_SIZE 0x400
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#endif
+#endif /*!defined(SEGMENT_SIZE)*/
+
diff --git a/include/aout/hp.h b/include/aout/hp.h
new file mode 100644
index 00000000000..002f49cf453
--- /dev/null
+++ b/include/aout/hp.h
@@ -0,0 +1,82 @@
+/* Special version of <a.out.h> for use under hp-ux.
+ Copyright 1988, 1991 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* THIS FILE IS OBSOLETE. It needs to be revised as a variant "external"
+ a.out format for use with BFD. */
+
+/* The `exec' structure and overall layout must be close to HP's when
+ we are running on an HP system, otherwise we will not be able to
+ execute the resulting file. */
+
+/* Allow this file to be included twice. */
+#ifndef __GNU_EXEC_MACROS__
+
+struct exec
+{
+ unsigned short a_machtype; /* machine type */
+ unsigned short a_magic; /* magic number */
+ unsigned long a_spare1;
+ unsigned long a_spare2;
+ unsigned long a_text; /* length of text, in bytes */
+ unsigned long a_data; /* length of data, in bytes */
+ unsigned long a_bss; /* length of uninitialized data area for file, in bytes */
+ unsigned long a_trsize; /* length of relocation info for text, in bytes */
+ unsigned long a_drsize; /* length of relocation info for data, in bytes */
+ unsigned long a_spare3; /* HP = pascal interface size */
+ unsigned long a_spare4; /* HP = symbol table size */
+ unsigned long a_spare5; /* HP = debug name table size */
+ unsigned long a_entry; /* start address */
+ unsigned long a_spare6; /* HP = source line table size */
+ unsigned long a_spare7; /* HP = value table size */
+ unsigned long a_syms; /* length of symbol table data in file, in bytes */
+ unsigned long a_spare8;
+};
+
+/* Tell a.out.gnu.h not to define `struct exec'. */
+#define __STRUCT_EXEC_OVERRIDE__
+
+#include "../a.out.gnu.h"
+
+#undef N_MAGIC
+#undef N_MACHTYPE
+#undef N_FLAGS
+#undef N_SET_INFO
+#undef N_SET_MAGIC
+#undef N_SET_MACHTYPE
+#undef N_SET_FLAGS
+
+#define N_MAGIC(exec) ((exec) . a_magic)
+#define N_MACHTYPE(exec) ((exec) . a_machtype)
+#define N_SET_MAGIC(exec, magic) (((exec) . a_magic) = (magic))
+#define N_SET_MACHTYPE(exec, machtype) (((exec) . a_machtype) = (machtype))
+
+#undef N_BADMAG
+#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x)))
+
+#define _N_BADMACH(x) \
+(((N_MACHTYPE (x)) != HP9000S200_ID) && \
+ ((N_MACHTYPE (x)) != HP98x6_ID))
+
+#define HP98x6_ID 0x20A
+#define HP9000S200_ID 0x20C
+
+#undef _N_HDROFF
+#define _N_HDROFF(x) (SEGMENT_SIZE - (sizeof (struct exec)))
+
+#define SEGMENT_SIZE 0x1000
+
+#endif /* __GNU_EXEC_MACROS__ */
diff --git a/include/aout/hp300hpux.h b/include/aout/hp300hpux.h
new file mode 100644
index 00000000000..44d5196144d
--- /dev/null
+++ b/include/aout/hp300hpux.h
@@ -0,0 +1,119 @@
+/* Special version of <a.out.h> for use under hp-ux.
+ Copyright (C) 1988,1993 Free Software Foundation, Inc. */
+
+struct hp300hpux_exec_bytes
+{
+ unsigned char e_info[4]; /* a_machtype/a_magic */
+ unsigned char e_spare1[4];
+ unsigned char e_spare2[4];
+ unsigned char e_text[4]; /* length of text, in bytes */
+ unsigned char e_data[4]; /* length of data, in bytes */
+ unsigned char e_bss[4]; /* length of uninitialized data area , in bytes */
+ unsigned char e_trsize[4]; /* length of relocation info for text, in bytes*/
+ unsigned char e_drsize[4]; /* length of relocation info for data, in bytes*/
+ unsigned char e_passize[4];/* HP = pascal interface size */
+ unsigned char e_syms[4]; /* HP = symbol table size */
+ unsigned char e_spare5[4]; /* HP = debug name table size */
+ unsigned char e_entry[4]; /* start address */
+ unsigned char e_spare6[4]; /* HP = source line table size */
+ unsigned char e_supsize[4];/* HP = value table size */
+ unsigned char e_drelocs[4];
+ unsigned char e_extension[4]; /* file offset of extension */
+};
+#define EXEC_BYTES_SIZE 64
+
+struct hp300hpux_nlist_bytes
+ {
+ unsigned char e_value[4];
+ unsigned char e_type[1];
+ unsigned char e_length[1]; /* length of ascii symbol name */
+ unsigned char e_almod[2]; /* alignment mod */
+ unsigned char e_shlib[2]; /* info about dynamic linking */
+ };
+#define EXTERNAL_NLIST_SIZE 10
+
+struct hp300hpux_reloc
+ {
+ unsigned char r_address[4];/* offset of of data to relocate */
+ unsigned char r_index[2]; /* symbol table index of symbol */
+ unsigned char r_type[1]; /* relocation type */
+ unsigned char r_length[1]; /* length of item to reloc */
+ };
+
+struct hp300hpux_header_extension
+{
+ unsigned char e_syms[4];
+ unsigned char unique_headers[12*4];
+ unsigned char e_header[2]; /* type of header */
+ unsigned char e_version[2]; /* version */
+ unsigned char e_size[4]; /* bytes following*/
+ unsigned char e_extension[4];/* file offset of next extension */
+};
+#define EXTERNAL_EXTENSION_HEADER_SIZE (16*4)
+
+/* hpux separates object files (0x106) and impure executables (0x107) */
+/* but the bfd code does not distinguish between them. Since we want to*/
+/* read hpux .o files, we add an special define and use it below in */
+/* offset and address calculations. */
+
+#define HPUX_DOT_O_MAGIC 0x106
+#define OMAGIC 0x107 /* object file or impure executable. */
+#define NMAGIC 0x108 /* Code indicating pure executable. */
+#define ZMAGIC 0x10B /* demand-paged executable. */
+
+#define N_HEADER_IN_TEXT(x) 0
+
+#if 0 /* libaout.h only uses the lower 8 bits */
+#define HP98x6_ID 0x20A
+#define HP9000S200_ID 0x20C
+#endif
+#define HP98x6_ID 0x0A
+#define HP9000S200_ID 0x0C
+
+#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x)))
+
+#define N_DATADDR(x) \
+ ((N_MAGIC(x)==OMAGIC || N_MAGIC(x)==HPUX_DOT_O_MAGIC) ? \
+ (N_TXTADDR(x)+N_TXTSIZE(x)) \
+ : (N_SEGSIZE(x) + ((N_TXTADDR(x)+N_TXTSIZE(x)-1) & ~(N_SEGSIZE(x)-1))))
+
+#define _N_BADMACH(x) \
+(((N_MACHTYPE (x)) != HP9000S200_ID) && \
+ ((N_MACHTYPE (x)) != HP98x6_ID))
+
+#define _N_BADMAG(x) (N_MAGIC(x) != HPUX_DOT_O_MAGIC \
+ && N_MAGIC(x) != OMAGIC \
+ && N_MAGIC(x) != NMAGIC \
+ && N_MAGIC(x) != ZMAGIC )
+
+#undef _N_HDROFF
+#define _N_HDROFF(x) (SEGMENT_SIZE - (sizeof (struct exec)))
+
+#undef N_DATOFF
+#undef N_PASOFF
+#undef N_SYMOFF
+#undef N_SUPOFF
+#undef N_TRELOFF
+#undef N_DRELOFF
+#undef N_STROFF
+
+#define N_DATOFF(x) ( N_TXTOFF(x) + N_TXTSIZE(x) )
+#define N_PASOFF(x) ( N_DATOFF(x) + (x).a_data)
+#define N_SYMOFF(x) ( N_PASOFF(x) /* + (x).a_passize*/ )
+#define N_SUPOFF(x) ( N_SYMOFF(x) + (x).a_syms )
+#define N_TRELOFF(x) ( N_SUPOFF(x) /* + 0 (x).a_supsize*/ )
+#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
+#define N_EXTHOFF(x) ( N_DRELOFF(x) /* + 0 (x).a_drsize */)
+#define N_STROFF(x) ( 0 /* no string table */ )
+
+/* use these when the file has gnu symbol tables */
+#define N_GNU_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
+#define N_GNU_DRELOFF(x) (N_GNU_TRELOFF(x) + (x).a_trsize)
+#define N_GNU_SYMOFF(x) (N_GNU_DRELOFF(x) + (x).a_drsize)
+
+#define TARGET_PAGE_SIZE 0x1000
+#define SEGMENT_SIZE 0x1000
+#define TEXT_START_ADDR 0
+
+#undef N_SHARED_LIB
+#define N_SHARED_LIB(x) ( 0 /* no shared libraries */ )
diff --git a/include/aout/hppa.h b/include/aout/hppa.h
new file mode 100644
index 00000000000..7e185de768a
--- /dev/null
+++ b/include/aout/hppa.h
@@ -0,0 +1,7 @@
+#include "filehdr.h"
+#include "aouthdr.h"
+#include "scnhdr.h"
+#include "spacehdr.h"
+#include "syms.h"
+
+
diff --git a/include/aout/ranlib.h b/include/aout/ranlib.h
new file mode 100644
index 00000000000..982600514b6
--- /dev/null
+++ b/include/aout/ranlib.h
@@ -0,0 +1,62 @@
+/* ranlib.h -- archive library index member definition for GNU.
+ Copyright 1990-1991 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* The Symdef member of an archive contains two things:
+ a table that maps symbol-string offsets to file offsets,
+ and a symbol-string table. All the symbol names are
+ run together (each with trailing null) in the symbol-string
+ table. There is a single longword bytecount on the front
+ of each of these tables. Thus if we have two symbols,
+ "foo" and "_bar", that are in archive members at offsets
+ 200 and 900, it would look like this:
+ 16 ; byte count of index table
+ 0 ; offset of "foo" in string table
+ 200 ; offset of foo-module in file
+ 4 ; offset of "bar" in string table
+ 900 ; offset of bar-module in file
+ 9 ; byte count of string table
+ "foo\0_bar\0" ; string table */
+
+#define RANLIBMAG "__.SYMDEF" /* Archive file name containing index */
+#define RANLIBSKEW 3 /* Creation time offset */
+
+/* Format of __.SYMDEF:
+ First, a longword containing the size of the 'symdef' data that follows.
+ Second, zero or more 'symdef' structures.
+ Third, a longword containing the length of symbol name strings.
+ Fourth, zero or more symbol name strings (each followed by a null). */
+
+struct symdef
+ {
+ union
+ {
+ unsigned long string_offset; /* In the file */
+ char *name; /* In memory, sometimes */
+ } s;
+ /* this points to the front of the file header (AKA member header --
+ a struct ar_hdr), not to the front of the file or into the file).
+ in other words it only tells you which file to read */
+ unsigned long file_offset;
+ };
+
+/* Compatability with BSD code */
+
+#define ranlib symdef
+#define ran_un s
+#define ran_strx string_offset
+#define ran_name name
+#define ran_off file_offset
diff --git a/include/aout/reloc.h b/include/aout/reloc.h
new file mode 100644
index 00000000000..563c552a357
--- /dev/null
+++ b/include/aout/reloc.h
@@ -0,0 +1,66 @@
+/* reloc.h -- Header file for relocation information.
+ Copyright 1989-1991 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Relocation types for a.out files using reloc_info_extended
+ (SPARC and AMD 29000). */
+
+#ifndef _RELOC_H_READ_
+#define _RELOC_H_READ_ 1
+
+enum reloc_type
+ {
+ RELOC_8, RELOC_16, RELOC_32, /* simple relocations */
+ RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */
+ RELOC_WDISP30, RELOC_WDISP22,
+ RELOC_HI22, RELOC_22,
+ RELOC_13, RELOC_LO10,
+ RELOC_SFA_BASE, RELOC_SFA_OFF13,
+ RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */
+ RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */
+ RELOC_JMP_TBL, /* P.I.C. jump table */
+ RELOC_SEGOFF16, /* reputedly for shared libraries somehow */
+ RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
+ RELOC_11,
+ RELOC_WDISP2_14,
+ RELOC_WDISP19,
+ RELOC_HHI22,
+ RELOC_HLO10,
+
+ /* 29K relocation types */
+ RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
+
+ RELOC_WDISP14, RELOC_WDISP21,
+
+ NO_RELOC
+ };
+
+#define RELOC_TYPE_NAMES \
+"8", "16", "32", "DISP8", \
+"DISP16", "DISP32", "WDISP30", "WDISP22", \
+"HI22", "22", "13", "LO10", \
+"SFA_BASE", "SFAOFF13", "BASE10", "BASE13", \
+"BASE22", "PC10", "PC22", "JMP_TBL", \
+"SEGOFF16", "GLOB_DAT", "JMP_SLOT", "RELATIVE", \
+"11", "WDISP2_14", "WDISP19", "HHI22", \
+"HLO10", \
+"JUMPTARG", "CONST", "CONSTH", "WDISP14", \
+"WDISP21", \
+"NO_RELOC"
+
+#endif /* _RELOC_H_READ_ */
+
+/* end of reloc.h */
diff --git a/include/aout/stab.def b/include/aout/stab.def
new file mode 100644
index 00000000000..9c2d2dd142c
--- /dev/null
+++ b/include/aout/stab.def
@@ -0,0 +1,268 @@
+/* Table of DBX symbol codes for the GNU system.
+ Copyright (C) 1988, 91, 92, 93, 94, 95, 96, 1998
+ Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* New stab from Solaris 2. This uses an n_type of 0, which in a.out files
+ overlaps the N_UNDF used for ordinary symbols. In ELF files, the
+ debug information is in a different file section, so there is no conflict.
+ This symbol's n_value gives the size of the string section associated
+ with this file. The symbol's n_strx (relative to the just-updated
+ string section start address) gives the name of the source file,
+ e.g. "foo.c", without any path information. The symbol's n_desc gives
+ the count of upcoming symbols associated with this file (not including
+ this one). */
+/* __define_stab (N_UNDF, 0x00, "UNDF") */
+
+/* Global variable. Only the name is significant.
+ To find the address, look in the corresponding external symbol. */
+__define_stab (N_GSYM, 0x20, "GSYM")
+
+/* Function name for BSD Fortran. Only the name is significant.
+ To find the address, look in the corresponding external symbol. */
+__define_stab (N_FNAME, 0x22, "FNAME")
+
+/* Function name or text-segment variable for C. Value is its address.
+ Desc is supposedly starting line number, but GCC doesn't set it
+ and DBX seems not to miss it. */
+__define_stab (N_FUN, 0x24, "FUN")
+
+/* Data-segment variable with internal linkage. Value is its address.
+ "Static Sym". */
+__define_stab (N_STSYM, 0x26, "STSYM")
+
+/* BSS-segment variable with internal linkage. Value is its address. */
+__define_stab (N_LCSYM, 0x28, "LCSYM")
+
+/* Name of main routine. Only the name is significant. */
+__define_stab (N_MAIN, 0x2a, "MAIN")
+
+/* Solaris2: Read-only data symbols. */
+__define_stab (N_ROSYM, 0x2c, "ROSYM")
+
+/* Global symbol in Pascal.
+ Supposedly the value is its line number; I'm skeptical. */
+__define_stab (N_PC, 0x30, "PC")
+
+/* Number of symbols: 0, files,,funcs,lines according to Ultrix V4.0. */
+__define_stab (N_NSYMS, 0x32, "NSYMS")
+
+/* "No DST map for sym: name, ,0,type,ignored" according to Ultrix V4.0. */
+__define_stab (N_NOMAP, 0x34, "NOMAP")
+
+/* New stab from Solaris 2. Like N_SO, but for the object file. Two in
+ a row provide the build directory and the relative path of the .o from it.
+ Solaris2 uses this to avoid putting the stabs info into the linked
+ executable; this stab goes into the ".stab.index" section, and the debugger
+ reads the real stabs directly from the .o files instead. */
+__define_stab (N_OBJ, 0x38, "OBJ")
+
+/* New stab from Solaris 2. Options for the debugger, related to the
+ source language for this module. E.g. whether to use ANSI
+ integral promotions or traditional integral promotions. */
+__define_stab (N_OPT, 0x3c, "OPT")
+
+/* Register variable. Value is number of register. */
+__define_stab (N_RSYM, 0x40, "RSYM")
+
+/* Modula-2 compilation unit. Can someone say what info it contains? */
+__define_stab (N_M2C, 0x42, "M2C")
+
+/* Line number in text segment. Desc is the line number;
+ value is corresponding address. On Solaris2, the line number is
+ relative to the start of the current function. */
+__define_stab (N_SLINE, 0x44, "SLINE")
+
+/* Similar, for data segment. */
+__define_stab (N_DSLINE, 0x46, "DSLINE")
+
+/* Similar, for bss segment. */
+__define_stab (N_BSLINE, 0x48, "BSLINE")
+
+/* Sun's source-code browser stabs. ?? Don't know what the fields are.
+ Supposedly the field is "path to associated .cb file". THIS VALUE
+ OVERLAPS WITH N_BSLINE! */
+__define_stab_duplicate (N_BROWS, 0x48, "BROWS")
+
+/* GNU Modula-2 definition module dependency. Value is the modification time
+ of the definition file. Other is non-zero if it is imported with the
+ GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there
+ are enough empty fields? */
+__define_stab(N_DEFD, 0x4a, "DEFD")
+
+/* New in Solaris2. Function start/body/end line numbers. */
+__define_stab(N_FLINE, 0x4C, "FLINE")
+
+/* THE FOLLOWING TWO STAB VALUES CONFLICT. Happily, one is for Modula-2
+ and one is for C++. Still,... */
+/* GNU C++ exception variable. Name is variable name. */
+__define_stab (N_EHDECL, 0x50, "EHDECL")
+/* Modula2 info "for imc": name,,0,0,0 according to Ultrix V4.0. */
+__define_stab_duplicate (N_MOD2, 0x50, "MOD2")
+
+/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if
+ this entry is immediately followed by a CAUGHT stab saying what exception
+ was caught. Multiple CAUGHT stabs means that multiple exceptions
+ can be caught here. If Desc is 0, it means all exceptions are caught
+ here. */
+__define_stab (N_CATCH, 0x54, "CATCH")
+
+/* Structure or union element. Value is offset in the structure. */
+__define_stab (N_SSYM, 0x60, "SSYM")
+
+/* Solaris2: Last stab emitted for module. */
+__define_stab (N_ENDM, 0x62, "ENDM")
+
+/* Name of main source file.
+ Value is starting text address of the compilation.
+ If multiple N_SO's appear, the first to contain a trailing / is the
+ compilation directory. The first to not contain a trailing / is the
+ source file name, relative to the compilation directory. Others (perhaps
+ resulting from cfront) are ignored.
+ On Solaris2, value is undefined, but desc is a source-language code. */
+
+__define_stab (N_SO, 0x64, "SO")
+
+/* SunPro F77: Name of alias. */
+__define_stab (N_ALIAS, 0x6c, "ALIAS")
+
+/* Automatic variable in the stack. Value is offset from frame pointer.
+ Also used for type descriptions. */
+__define_stab (N_LSYM, 0x80, "LSYM")
+
+/* Beginning of an include file. Only Sun uses this.
+ In an object file, only the name is significant.
+ The Sun linker puts data into some of the other fields. */
+__define_stab (N_BINCL, 0x82, "BINCL")
+
+/* Name of sub-source file (#include file).
+ Value is starting text address of the compilation. */
+__define_stab (N_SOL, 0x84, "SOL")
+
+/* Parameter variable. Value is offset from argument pointer.
+ (On most machines the argument pointer is the same as the frame pointer. */
+__define_stab (N_PSYM, 0xa0, "PSYM")
+
+/* End of an include file. No name.
+ This and N_BINCL act as brackets around the file's output.
+ In an object file, there is no significant data in this entry.
+ The Sun linker puts data into some of the fields. */
+__define_stab (N_EINCL, 0xa2, "EINCL")
+
+/* Alternate entry point. Value is its address. */
+__define_stab (N_ENTRY, 0xa4, "ENTRY")
+
+/* Beginning of lexical block.
+ The desc is the nesting level in lexical blocks.
+ The value is the address of the start of the text for the block.
+ The variables declared inside the block *precede* the N_LBRAC symbol.
+ On Solaris2, the value is relative to the start of the current function. */
+__define_stab (N_LBRAC, 0xc0, "LBRAC")
+
+/* Place holder for deleted include file. Replaces a N_BINCL and everything
+ up to the corresponding N_EINCL. The Sun linker generates these when
+ it finds multiple identical copies of the symbols from an include file.
+ This appears only in output from the Sun linker. */
+__define_stab (N_EXCL, 0xc2, "EXCL")
+
+/* Modula-2 scope information. Can someone say what info it contains? */
+__define_stab (N_SCOPE, 0xc4, "SCOPE")
+
+/* End of a lexical block. Desc matches the N_LBRAC's desc.
+ The value is the address of the end of the text for the block.
+ On Solaris2, the value is relative to the start of the current function. */
+__define_stab (N_RBRAC, 0xe0, "RBRAC")
+
+/* Begin named common block. Only the name is significant. */
+__define_stab (N_BCOMM, 0xe2, "BCOMM")
+
+/* End named common block. Only the name is significant
+ (and it should match the N_BCOMM). */
+__define_stab (N_ECOMM, 0xe4, "ECOMM")
+
+/* Member of a common block; value is offset within the common block.
+ This should occur within a BCOMM/ECOMM pair. */
+__define_stab (N_ECOML, 0xe8, "ECOML")
+
+/* Solaris2: Pascal "with" statement: type,,0,0,offset */
+__define_stab (N_WITH, 0xea, "WITH")
+
+/* These STAB's are used on Gould systems for Non-Base register symbols
+ or something like that. FIXME. I have assigned the values at random
+ since I don't have a Gould here. Fixups from Gould folk welcome... */
+__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
+__define_stab (N_NBDATA, 0xF2, "NBDATA")
+__define_stab (N_NBBSS, 0xF4, "NBBSS")
+__define_stab (N_NBSTS, 0xF6, "NBSTS")
+__define_stab (N_NBLCS, 0xF8, "NBLCS")
+
+/* Second symbol entry containing a length-value for the preceding entry.
+ The value is the length. */
+__define_stab (N_LENG, 0xfe, "LENG")
+
+/* The above information, in matrix format.
+
+ STAB MATRIX
+ _________________________________________________
+ | 00 - 1F are not dbx stab symbols |
+ | In most cases, the low bit is the EXTernal bit|
+
+ | 00 UNDEF | 02 ABS | 04 TEXT | 06 DATA |
+ | 01 |EXT | 03 |EXT | 05 |EXT | 07 |EXT |
+
+ | 08 BSS | 0A INDR | 0C FN_SEQ | 0E WEAKA |
+ | 09 |EXT | 0B | 0D WEAKU | 0F WEAKT |
+
+ | 10 WEAKD | 12 COMM | 14 SETA | 16 SETT |
+ | 11 WEAKB | 13 | 15 | 17 |
+
+ | 18 SETD | 1A SETB | 1C SETV | 1E WARNING|
+ | 19 | 1B | 1D | 1F FN |
+
+ |_______________________________________________|
+ | Debug entries with bit 01 set are unused. |
+ | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM |
+ | 28 LCSYM | 2A MAIN | 2C ROSYM | 2E |
+ | 30 PC | 32 NSYMS | 34 NOMAP | 36 |
+ | 38 OBJ | 3A | 3C OPT | 3E |
+ | 40 RSYM | 42 M2C | 44 SLINE | 46 DSLINE |
+ | 48 BSLINE*| 4A DEFD | 4C FLINE | 4E |
+ | 50 EHDECL*| 52 | 54 CATCH | 56 |
+ | 58 | 5A | 5C | 5E |
+ | 60 SSYM | 62 ENDM | 64 SO | 66 |
+ | 68 | 6A | 6C ALIAS | 6E |
+ | 70 | 72 | 74 | 76 |
+ | 78 | 7A | 7C | 7E |
+ | 80 LSYM | 82 BINCL | 84 SOL | 86 |
+ | 88 | 8A | 8C | 8E |
+ | 90 | 92 | 94 | 96 |
+ | 98 | 9A | 9C | 9E |
+ | A0 PSYM | A2 EINCL | A4 ENTRY | A6 |
+ | A8 | AA | AC | AE |
+ | B0 | B2 | B4 | B6 |
+ | B8 | BA | BC | BE |
+ | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 |
+ | C8 | CA | CC | CE |
+ | D0 | D2 | D4 | D6 |
+ | D8 | DA | DC | DE |
+ | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 |
+ | E8 ECOML | EA WITH | EC | EE |
+ | F0 | F2 | F4 | F6 |
+ | F8 | FA | FC | FE LENG |
+ +-----------------------------------------------+
+ * 50 EHDECL is also MOD2.
+ * 48 BSLINE is also BROWS.
+ */
diff --git a/include/aout/stab_gnu.h b/include/aout/stab_gnu.h
new file mode 100644
index 00000000000..7d18e14a263
--- /dev/null
+++ b/include/aout/stab_gnu.h
@@ -0,0 +1,37 @@
+#ifndef __GNU_STAB__
+
+/* Indicate the GNU stab.h is in use. */
+
+#define __GNU_STAB__
+
+#define __define_stab(NAME, CODE, STRING) NAME=CODE,
+#define __define_stab_duplicate(NAME, CODE, STRING) NAME=CODE,
+
+enum __stab_debug_code
+{
+#include "aout/stab.def"
+LAST_UNUSED_STAB_CODE
+};
+
+#undef __define_stab
+
+/* Definitions of "desc" field for N_SO stabs in Solaris2. */
+
+#define N_SO_AS 1
+#define N_SO_C 2
+#define N_SO_ANSI_C 3
+#define N_SO_CC 4 /* C++ */
+#define N_SO_FORTRAN 5
+#define N_SO_PASCAL 6
+
+/* Solaris2: Floating point type values in basic types. */
+
+#define NF_NONE 0
+#define NF_SINGLE 1 /* IEEE 32-bit */
+#define NF_DOUBLE 2 /* IEEE 64-bit */
+#define NF_COMPLEX 3 /* Fortran complex */
+#define NF_COMPLEX16 4 /* Fortran double complex */
+#define NF_COMPLEX32 5 /* Fortran complex*16 */
+#define NF_LDOUBLE 6 /* Long double (whatever that is) */
+
+#endif /* __GNU_STAB_ */
diff --git a/include/aout/sun4.h b/include/aout/sun4.h
new file mode 100644
index 00000000000..f42a0dd4598
--- /dev/null
+++ b/include/aout/sun4.h
@@ -0,0 +1,219 @@
+/* SPARC-specific values for a.out files */
+
+/* Some systems, e.g., AIX, may have defined this in header files already
+ included. */
+#undef TARGET_PAGE_SIZE
+#define TARGET_PAGE_SIZE 0x2000 /* 8K. aka NBPG in <sys/param.h> */
+/* Note that some SPARCs have 4K pages, some 8K, some others. */
+
+#define SEG_SIZE_SPARC TARGET_PAGE_SIZE
+#define SEG_SIZE_SUN3 0x20000 /* Resolution of r/w protection hw */
+
+#define TEXT_START_ADDR TARGET_PAGE_SIZE /* Location 0 is not accessible */
+#define N_HEADER_IN_TEXT(x) 1
+
+/* Non-default definitions of the accessor macros... */
+
+/* Segment size varies on Sun-3 versus Sun-4. */
+
+#define N_SEGSIZE(x) (N_MACHTYPE(x) == M_SPARC? SEG_SIZE_SPARC: \
+ N_MACHTYPE(x) == M_68020? SEG_SIZE_SUN3: \
+ /* Guess? */ TARGET_PAGE_SIZE)
+
+/* Virtual Address of text segment from the a.out file. For OMAGIC,
+ (almost always "unlinked .o's" these days), should be zero.
+ Sun added a kludge so that shared libraries linked ZMAGIC get
+ an address of zero if a_entry (!!!) is lower than the otherwise
+ expected text address. These kludges have gotta go!
+ For linked files, should reflect reality if we know it. */
+
+/* This differs from the version in aout64.h (which we override by defining
+ it here) only for NMAGIC (we return TEXT_START_ADDR+EXEC_BYTES_SIZE;
+ they return 0). */
+
+#define N_TXTADDR(x) \
+ (N_MAGIC(x)==OMAGIC? 0 \
+ : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \
+ : TEXT_START_ADDR+EXEC_BYTES_SIZE)
+
+/* When a file is linked against a shared library on SunOS 4, the
+ dynamic bit in the exec header is set, and the first symbol in the
+ symbol table is __DYNAMIC. Its value is the address of the
+ following structure. */
+
+struct external_sun4_dynamic
+{
+ /* The version number of the structure. SunOS 4.1.x creates files
+ with version number 3, which is what this structure is based on.
+ According to gdb, version 2 is similar. I believe that version 2
+ used a different type of procedure linkage table, and there may
+ have been other differences. */
+ bfd_byte ld_version[4];
+ /* The virtual address of a 28 byte structure used in debugging.
+ The contents are filled in at run time by ld.so. */
+ bfd_byte ldd[4];
+ /* The virtual address of another structure with information about
+ how to relocate the executable at run time. */
+ bfd_byte ld[4];
+};
+
+/* The size of the debugging structure pointed to by the debugger
+ field of __DYNAMIC. */
+#define EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE (24)
+
+/* The structure pointed to by the linker field of __DYNAMIC. As far
+ as I can tell, most of the addresses in this structure are offsets
+ within the file, but some are actually virtual addresses. */
+
+struct internal_sun4_dynamic_link
+{
+ /* Linked list of loaded objects. This is filled in at runtime by
+ ld.so and probably by dlopen. */
+ unsigned long ld_loaded;
+
+ /* The address of the list of names of shared objects which must be
+ included at runtime. Each entry in the list is 16 bytes: the 4
+ byte address of the string naming the object (e.g., for -lc this
+ is "c"); 4 bytes of flags--the high bit is whether to search for
+ the object using the library path; the 2 byte major version
+ number; the 2 byte minor version number; the 4 byte address of
+ the next entry in the list (zero if this is the last entry). The
+ version numbers seem to only be non-zero when doing library
+ searching. */
+ unsigned long ld_need;
+
+ /* The address of the path to search for the shared objects which
+ must be included. This points to a string in PATH format which
+ is generated from the -L arguments to the linker. According to
+ the man page, ld.so implicitly adds ${LD_LIBRARY_PATH} to the
+ beginning of this string and /lib:/usr/lib:/usr/local/lib to the
+ end. The string is terminated by a null byte. This field is
+ zero if there is no additional path. */
+ unsigned long ld_rules;
+
+ /* The address of the global offset table. This appears to be a
+ virtual address, not a file offset. The first entry in the
+ global offset table seems to be the virtual address of the
+ sun4_dynamic structure (the same value as the __DYNAMIC symbol).
+ The global offset table is used for PIC code to hold the
+ addresses of variables. A dynamically linked file which does not
+ itself contain PIC code has a four byte global offset table. */
+ unsigned long ld_got;
+
+ /* The address of the procedure linkage table. This appears to be a
+ virtual address, not a file offset.
+
+ On a SPARC, the table is composed of 12 byte entries, each of
+ which consists of three instructions. The first entry is
+ sethi %hi(0),%g1
+ jmp %g1
+ nop
+ These instructions are changed by ld.so into a jump directly into
+ ld.so itself. Each subsequent entry is
+ save %sp, -96, %sp
+ call <address of first entry in procedure linkage table>
+ <reloc_number | 0x01000000>
+ The reloc_number is the number of the reloc to use to resolve
+ this entry. The reloc will be a JMP_SLOT reloc against some
+ symbol that is not defined in this object file but should be
+ defined in a shared object (if it is not, ld.so will report a
+ runtime error and exit). The constant 0x010000000 turns the
+ reloc number into a sethi of %g0, which does nothing since %g0 is
+ hardwired to zero.
+
+ When one of these entries is executed, it winds up calling into
+ ld.so. ld.so looks at the reloc number, available via the return
+ address, to determine which entry this is. It then looks at the
+ reloc and patches up the entry in the table into a sethi and jmp
+ to the real address followed by a nop. This means that the reloc
+ lookup only has to happen once, and it also means that the
+ relocation only needs to be done if the function is actually
+ called. The relocation is expensive because ld.so must look up
+ the symbol by name.
+
+ The size of the procedure linkage table is given by the ld_plt_sz
+ field. */
+ unsigned long ld_plt;
+
+ /* The address of the relocs. These are in the same format as
+ ordinary relocs. Symbol index numbers refer to the symbols
+ pointed to by ld_stab. I think the only way to determine the
+ number of relocs is to assume that all the bytes from ld_rel to
+ ld_hash contain reloc entries. */
+ unsigned long ld_rel;
+
+ /* The address of a hash table of symbols. The hash table has
+ roughly the same number of entries as there are dynamic symbols;
+ I think the only way to get the exact size is to assume that
+ every byte from ld_hash to ld_stab is devoted to the hash table.
+
+ Each entry in the hash table is eight bytes. The first four
+ bytes are a symbol index into the dynamic symbols. The second
+ four bytes are the index of the next hash table entry in the
+ bucket. The ld_buckets field gives the number of buckets, say B.
+ The first B entries in the hash table each start a bucket which
+ is chained through the second four bytes of each entry. A value
+ of zero ends the chain.
+
+ The hash function is simply
+ h = 0;
+ while (*string != '\0')
+ h = (h << 1) + *string++;
+ h &= 0x7fffffff;
+
+ To look up a symbol, compute the hash value of the name. Take
+ the modulos of hash value and the number of buckets. Start at
+ that entry in the hash table. See if the symbol (from the first
+ four bytes of the hash table entry) has the name you are looking
+ for. If not, use the chain field (the second four bytes of the
+ hash table entry) to move on to the next entry in this bucket.
+ If the chain field is zero you have reached the end of the
+ bucket, and the symbol is not in the hash table. */
+ unsigned long ld_hash;
+
+ /* The address of the symbol table. This is a list of
+ external_nlist structures. The string indices are relative to
+ the ld_symbols field. I think the only way to determine the
+ number of symbols is to assume that all the bytes between ld_stab
+ and ld_symbols are external_nlist structures. */
+ unsigned long ld_stab;
+
+ /* I don't know what this is for. It seems to always be zero. */
+ unsigned long ld_stab_hash;
+
+ /* The number of buckets in the hash table. */
+ unsigned long ld_buckets;
+
+ /* The address of the symbol string table. The first string in this
+ string table need not be the empty string. */
+ unsigned long ld_symbols;
+
+ /* The size in bytes of the symbol string table. */
+ unsigned long ld_symb_size;
+
+ /* The size in bytes of the text segment. */
+ unsigned long ld_text;
+
+ /* The size in bytes of the procedure linkage table. */
+ unsigned long ld_plt_sz;
+};
+
+/* The external form of the structure. */
+
+struct external_sun4_dynamic_link
+{
+ bfd_byte ld_loaded[4];
+ bfd_byte ld_need[4];
+ bfd_byte ld_rules[4];
+ bfd_byte ld_got[4];
+ bfd_byte ld_plt[4];
+ bfd_byte ld_rel[4];
+ bfd_byte ld_hash[4];
+ bfd_byte ld_stab[4];
+ bfd_byte ld_stab_hash[4];
+ bfd_byte ld_buckets[4];
+ bfd_byte ld_symbols[4];
+ bfd_byte ld_symb_size[4];
+ bfd_byte ld_text[4];
+ bfd_byte ld_plt_sz[4];
+};
diff --git a/include/bfdlink.h b/include/bfdlink.h
new file mode 100644
index 00000000000..a055fa082da
--- /dev/null
+++ b/include/bfdlink.h
@@ -0,0 +1,520 @@
+/* bfdlink.h -- header file for BFD link routines
+ Copyright 1993, 94, 95, 96, 97, 1999 Free Software Foundation, Inc.
+ Written by Steve Chamberlain and 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef BFDLINK_H
+#define BFDLINK_H
+
+/* Which symbols to strip during a link. */
+enum bfd_link_strip
+{
+ strip_none, /* Don't strip any symbols. */
+ strip_debugger, /* Strip debugging symbols. */
+ strip_some, /* keep_hash is the list of symbols to keep. */
+ strip_all /* Strip all symbols. */
+};
+
+/* Which local symbols to discard during a link. This is irrelevant
+ if strip_all is used. */
+enum bfd_link_discard
+{
+ discard_none, /* Don't discard any locals. */
+ discard_l, /* Discard local temporary symbols. */
+ discard_all /* Discard all locals. */
+};
+
+/* These are the possible types of an entry in the BFD link hash
+ table. */
+
+enum bfd_link_hash_type
+{
+ bfd_link_hash_new, /* Symbol is new. */
+ bfd_link_hash_undefined, /* Symbol seen before, but undefined. */
+ bfd_link_hash_undefweak, /* Symbol is weak and undefined. */
+ bfd_link_hash_defined, /* Symbol is defined. */
+ bfd_link_hash_defweak, /* Symbol is weak and defined. */
+ bfd_link_hash_common, /* Symbol is common. */
+ bfd_link_hash_indirect, /* Symbol is an indirect link. */
+ bfd_link_hash_warning /* Like indirect, but warn if referenced. */
+};
+
+/* The linking routines use a hash table which uses this structure for
+ its elements. */
+
+struct bfd_link_hash_entry
+{
+ /* Base hash table entry structure. */
+ struct bfd_hash_entry root;
+ /* Type of this entry. */
+ enum bfd_link_hash_type type;
+
+ /* Undefined and common symbols are kept in a linked list through
+ this field. This field is not in the union because that would
+ force us to remove entries from the list when we changed their
+ type, which would force the list to be doubly linked, which would
+ waste more memory. When an undefined or common symbol is
+ created, it should be added to this list, the head of which is in
+ the link hash table itself. As symbols are defined, they need
+ not be removed from the list; anything which reads the list must
+ doublecheck the symbol type.
+
+ Weak symbols are not kept on this list.
+
+ Defined and defweak symbols use this field as a reference marker.
+ If the field is not NULL, or this structure is the tail of the
+ undefined symbol list, the symbol has been referenced. If the
+ symbol is undefined and becomes defined, this field will
+ automatically be non-NULL since the symbol will have been on the
+ undefined symbol list. */
+ struct bfd_link_hash_entry *next;
+ /* A union of information depending upon the type. */
+ union
+ {
+ /* Nothing is kept for bfd_hash_new. */
+ /* bfd_link_hash_undefined, bfd_link_hash_undefweak. */
+ struct
+ {
+ bfd *abfd; /* BFD symbol was found in. */
+ } undef;
+ /* bfd_link_hash_defined, bfd_link_hash_defweak. */
+ struct
+ {
+ bfd_vma value; /* Symbol value. */
+ asection *section; /* Symbol section. */
+ } def;
+ /* bfd_link_hash_indirect, bfd_link_hash_warning. */
+ struct
+ {
+ struct bfd_link_hash_entry *link; /* Real symbol. */
+ const char *warning; /* Warning (bfd_link_hash_warning only). */
+ } i;
+ /* bfd_link_hash_common. */
+ struct
+ {
+ /* The linker needs to know three things about common
+ symbols: the size, the alignment, and the section in
+ which the symbol should be placed. We store the size
+ here, and we allocate a small structure to hold the
+ section and the alignment. The alignment is stored as a
+ power of two. We don't store all the information
+ directly because we don't want to increase the size of
+ the union; this structure is a major space user in the
+ linker. */
+ bfd_size_type size; /* Common symbol size. */
+ struct bfd_link_hash_common_entry
+ {
+ unsigned int alignment_power; /* Alignment. */
+ asection *section; /* Symbol section. */
+ } *p;
+ } c;
+ } u;
+};
+
+/* This is the link hash table. It is a derived class of
+ bfd_hash_table. */
+
+struct bfd_link_hash_table
+{
+ /* The hash table itself. */
+ struct bfd_hash_table table;
+ /* The back end which created this hash table. This indicates the
+ type of the entries in the hash table, which is sometimes
+ important information when linking object files of different
+ types together. */
+ const bfd_target *creator;
+ /* A linked list of undefined and common symbols, linked through the
+ next field in the bfd_link_hash_entry structure. */
+ struct bfd_link_hash_entry *undefs;
+ /* Entries are added to the tail of the undefs list. */
+ struct bfd_link_hash_entry *undefs_tail;
+};
+
+/* Look up an entry in a link hash table. If FOLLOW is true, this
+ follows bfd_link_hash_indirect and bfd_link_hash_warning links to
+ the real symbol. */
+extern struct bfd_link_hash_entry *bfd_link_hash_lookup
+ PARAMS ((struct bfd_link_hash_table *, const char *, boolean create,
+ boolean copy, boolean follow));
+
+/* Look up an entry in the main linker hash table if the symbol might
+ be wrapped. This should only be used for references to an
+ undefined symbol, not for definitions of a symbol. */
+
+extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean, boolean,
+ boolean));
+
+/* Traverse a link hash table. */
+extern void bfd_link_hash_traverse
+ PARAMS ((struct bfd_link_hash_table *,
+ boolean (*) (struct bfd_link_hash_entry *, PTR),
+ PTR));
+
+/* Add an entry to the undefs list. */
+extern void bfd_link_add_undef
+ PARAMS ((struct bfd_link_hash_table *, struct bfd_link_hash_entry *));
+
+/* This structure holds all the information needed to communicate
+ between BFD and the linker when doing a link. */
+
+struct bfd_link_info
+{
+ /* Function callbacks. */
+ const struct bfd_link_callbacks *callbacks;
+ /* true if BFD should generate a relocateable object file. */
+ boolean relocateable;
+ /* true if BFD should generate a "task linked" object file,
+ similar to relocatable but also with globals converted to statics. */
+ boolean task_link;
+ /* true if BFD should generate a shared object. */
+ boolean shared;
+ /* true if BFD should pre-bind symbols in a shared object. */
+ boolean symbolic;
+ /* true if shared objects should be linked directly, not shared. */
+ boolean static_link;
+ /* true if the output file should be in a traditional format. This
+ is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag
+ on the output file, but may be checked when reading the input
+ files. */
+ boolean traditional_format;
+ /* true if we want to produced optimized output files. This might
+ need much more time and therefore must be explicitly selected. */
+ boolean optimize;
+ /* true if BFD should generate errors for undefined symbols
+ even if generating a shared object. */
+ boolean no_undefined;
+ /* Which symbols to strip. */
+ enum bfd_link_strip strip;
+ /* Which local symbols to discard. */
+ enum bfd_link_discard discard;
+ /* true if symbols should be retained in memory, false if they
+ should be freed and reread. */
+ boolean keep_memory;
+ /* The list of input BFD's involved in the link. These are chained
+ together via the link_next field. */
+ bfd *input_bfds;
+ /* If a symbol should be created for each input BFD, this is section
+ where those symbols should be placed. It must be a section in
+ the output BFD. It may be NULL, in which case no such symbols
+ will be created. This is to support CREATE_OBJECT_SYMBOLS in the
+ linker command language. */
+ asection *create_object_symbols_section;
+ /* Hash table handled by BFD. */
+ struct bfd_link_hash_table *hash;
+ /* Hash table of symbols to keep. This is NULL unless strip is
+ strip_some. */
+ struct bfd_hash_table *keep_hash;
+ /* true if every symbol should be reported back via the notice
+ callback. */
+ boolean notice_all;
+ /* Hash table of symbols to report back via the notice callback. If
+ this is NULL, and notice_all is false, then no symbols are
+ reported back. */
+ struct bfd_hash_table *notice_hash;
+ /* Hash table of symbols which are being wrapped (the --wrap linker
+ option). If this is NULL, no symbols are being wrapped. */
+ struct bfd_hash_table *wrap_hash;
+ /* If a base output file is wanted, then this points to it */
+ PTR base_file;
+
+ /* If non-zero, specifies that branches which are problematic for the
+ MPC860 C0 (or earlier) should be checked for and modified. It gives the
+ number of bytes that should be checked at the end of each text page. */
+ int mpc860c0;
+};
+
+/* This structures holds a set of callback functions. These are
+ called by the BFD linker routines. The first argument to each
+ callback function is the bfd_link_info structure being used. Each
+ function returns a boolean value. If the function returns false,
+ then the BFD function which called it will return with a failure
+ indication. */
+
+struct bfd_link_callbacks
+{
+ /* A function which is called when an object is added from an
+ archive. ABFD is the archive element being added. NAME is the
+ name of the symbol which caused the archive element to be pulled
+ in. */
+ boolean (*add_archive_element) PARAMS ((struct bfd_link_info *,
+ bfd *abfd,
+ const char *name));
+ /* A function which is called when a symbol is found with multiple
+ definitions. NAME is the symbol which is defined multiple times.
+ OBFD is the old BFD, OSEC is the old section, OVAL is the old
+ value, NBFD is the new BFD, NSEC is the new section, and NVAL is
+ the new value. OBFD may be NULL. OSEC and NSEC may be
+ bfd_com_section or bfd_ind_section. */
+ boolean (*multiple_definition) PARAMS ((struct bfd_link_info *,
+ const char *name,
+ bfd *obfd,
+ asection *osec,
+ bfd_vma oval,
+ bfd *nbfd,
+ asection *nsec,
+ bfd_vma nval));
+ /* A function which is called when a common symbol is defined
+ multiple times. NAME is the symbol appearing multiple times.
+ OBFD is the BFD of the existing symbol; it may be NULL if this is
+ not known. OTYPE is the type of the existing symbol, which may
+ be bfd_link_hash_defined, bfd_link_hash_defweak,
+ bfd_link_hash_common, or bfd_link_hash_indirect. If OTYPE is
+ bfd_link_hash_common, OSIZE is the size of the existing symbol.
+ NBFD is the BFD of the new symbol. NTYPE is the type of the new
+ symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or
+ bfd_link_hash_indirect. If NTYPE is bfd_link_hash_common, NSIZE
+ is the size of the new symbol. */
+ boolean (*multiple_common) PARAMS ((struct bfd_link_info *,
+ const char *name,
+ bfd *obfd,
+ enum bfd_link_hash_type otype,
+ bfd_vma osize,
+ bfd *nbfd,
+ enum bfd_link_hash_type ntype,
+ bfd_vma nsize));
+ /* A function which is called to add a symbol to a set. ENTRY is
+ the link hash table entry for the set itself (e.g.,
+ __CTOR_LIST__). RELOC is the relocation to use for an entry in
+ the set when generating a relocateable file, and is also used to
+ get the size of the entry when generating an executable file.
+ ABFD, SEC and VALUE identify the value to add to the set. */
+ boolean (*add_to_set) PARAMS ((struct bfd_link_info *,
+ struct bfd_link_hash_entry *entry,
+ bfd_reloc_code_real_type reloc,
+ bfd *abfd, asection *sec, bfd_vma value));
+ /* A function which is called when the name of a g++ constructor or
+ destructor is found. This is only called by some object file
+ formats. CONSTRUCTOR is true for a constructor, false for a
+ destructor. This will use BFD_RELOC_CTOR when generating a
+ relocateable file. NAME is the name of the symbol found. ABFD,
+ SECTION and VALUE are the value of the symbol. */
+ boolean (*constructor) PARAMS ((struct bfd_link_info *,
+ boolean constructor,
+ const char *name, bfd *abfd, asection *sec,
+ bfd_vma value));
+ /* A function which is called to issue a linker warning. For
+ example, this is called when there is a reference to a warning
+ symbol. WARNING is the warning to be issued. SYMBOL is the name
+ of the symbol which triggered the warning; it may be NULL if
+ there is none. ABFD, SECTION and ADDRESS identify the location
+ which trigerred the warning; either ABFD or SECTION or both may
+ be NULL if the location is not known. */
+ boolean (*warning) PARAMS ((struct bfd_link_info *,
+ const char *warning, const char *symbol,
+ bfd *abfd, asection *section,
+ bfd_vma address));
+ /* A function which is called when a relocation is attempted against
+ an undefined symbol. NAME is the symbol which is undefined.
+ ABFD, SECTION and ADDRESS identify the location from which the
+ reference is made. In some cases SECTION may be NULL. */
+ boolean (*undefined_symbol) PARAMS ((struct bfd_link_info *,
+ const char *name, bfd *abfd,
+ asection *section, bfd_vma address));
+ /* A function which is called when a reloc overflow occurs. NAME is
+ the name of the symbol or section the reloc is against,
+ RELOC_NAME is the name of the relocation, and ADDEND is any
+ addend that is used. ABFD, SECTION and ADDRESS identify the
+ location at which the overflow occurs; if this is the result of a
+ bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
+ ABFD will be NULL. */
+ boolean (*reloc_overflow) PARAMS ((struct bfd_link_info *,
+ const char *name,
+ const char *reloc_name, bfd_vma addend,
+ bfd *abfd, asection *section,
+ bfd_vma address));
+ /* A function which is called when a dangerous reloc is performed.
+ The canonical example is an a29k IHCONST reloc which does not
+ follow an IHIHALF reloc. MESSAGE is an appropriate message.
+ ABFD, SECTION and ADDRESS identify the location at which the
+ problem occurred; if this is the result of a
+ bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
+ ABFD will be NULL. */
+ boolean (*reloc_dangerous) PARAMS ((struct bfd_link_info *,
+ const char *message,
+ bfd *abfd, asection *section,
+ bfd_vma address));
+ /* A function which is called when a reloc is found to be attached
+ to a symbol which is not being written out. NAME is the name of
+ the symbol. ABFD, SECTION and ADDRESS identify the location of
+ the reloc; if this is the result of a
+ bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
+ ABFD will be NULL. */
+ boolean (*unattached_reloc) PARAMS ((struct bfd_link_info *,
+ const char *name,
+ bfd *abfd, asection *section,
+ bfd_vma address));
+ /* A function which is called when a symbol in notice_hash is
+ defined or referenced. NAME is the symbol. ABFD, SECTION and
+ ADDRESS are the value of the symbol. If SECTION is
+ bfd_und_section, this is a reference. */
+ boolean (*notice) PARAMS ((struct bfd_link_info *, const char *name,
+ bfd *abfd, asection *section, bfd_vma address));
+};
+
+/* The linker builds link_order structures which tell the code how to
+ include input data in the output file. */
+
+/* These are the types of link_order structures. */
+
+enum bfd_link_order_type
+{
+ bfd_undefined_link_order, /* Undefined. */
+ bfd_indirect_link_order, /* Built from a section. */
+ bfd_fill_link_order, /* Fill with a 16 bit constant. */
+ bfd_data_link_order, /* Set to explicit data. */
+ bfd_section_reloc_link_order, /* Relocate against a section. */
+ bfd_symbol_reloc_link_order /* Relocate against a symbol. */
+};
+
+/* This is the link_order structure itself. These form a chain
+ attached to the section whose contents they are describing. */
+
+struct bfd_link_order
+{
+ /* Next link_order in chain. */
+ struct bfd_link_order *next;
+ /* Type of link_order. */
+ enum bfd_link_order_type type;
+ /* Offset within output section. */
+ bfd_vma offset;
+ /* Size within output section. */
+ bfd_size_type size;
+ /* Type specific information. */
+ union
+ {
+ struct
+ {
+ /* Section to include. If this is used, then
+ section->output_section must be the section the
+ link_order is attached to, section->output_offset must
+ equal the link_order offset field, and section->_raw_size
+ must equal the link_order size field. Maybe these
+ restrictions should be relaxed someday. */
+ asection *section;
+ } indirect;
+ struct
+ {
+ /* Value to fill with. */
+ unsigned int value;
+ } fill;
+ struct
+ {
+ /* Data to put into file. The size field gives the number
+ of bytes which this field points to. */
+ bfd_byte *contents;
+ } data;
+ struct
+ {
+ /* Description of reloc to generate. Used for
+ bfd_section_reloc_link_order and
+ bfd_symbol_reloc_link_order. */
+ struct bfd_link_order_reloc *p;
+ } reloc;
+ } u;
+};
+
+/* A linker order of type bfd_section_reloc_link_order or
+ bfd_symbol_reloc_link_order means to create a reloc against a
+ section or symbol, respectively. This is used to implement -Ur to
+ generate relocs for the constructor tables. The
+ bfd_link_order_reloc structure describes the reloc that BFD should
+ create. It is similar to a arelent, but I didn't use arelent
+ because the linker does not know anything about most symbols, and
+ any asymbol structure it creates will be partially meaningless.
+ This information could logically be in the bfd_link_order struct,
+ but I didn't want to waste the space since these types of relocs
+ are relatively rare. */
+
+struct bfd_link_order_reloc
+{
+ /* Reloc type. */
+ bfd_reloc_code_real_type reloc;
+
+ union
+ {
+ /* For type bfd_section_reloc_link_order, this is the section
+ the reloc should be against. This must be a section in the
+ output BFD, not any of the input BFDs. */
+ asection *section;
+ /* For type bfd_symbol_reloc_link_order, this is the name of the
+ symbol the reloc should be against. */
+ const char *name;
+ } u;
+
+ /* Addend to use. The object file should contain zero. The BFD
+ backend is responsible for filling in the contents of the object
+ file correctly. For some object file formats (e.g., COFF) the
+ addend must be stored into in the object file, and for some
+ (e.g., SPARC a.out) it is kept in the reloc. */
+ bfd_vma addend;
+};
+
+/* Allocate a new link_order for a section. */
+extern struct bfd_link_order *bfd_new_link_order PARAMS ((bfd *, asection *));
+
+/* These structures are used to describe version information for the
+ ELF linker. These structures could be manipulated entirely inside
+ BFD, but it would be a pain. Instead, the regular linker sets up
+ these structures, and then passes them into BFD. */
+
+/* Regular expressions for a version. */
+
+struct bfd_elf_version_expr
+{
+ /* Next regular expression for this version. */
+ struct bfd_elf_version_expr *next;
+ /* Regular expression. */
+ const char *pattern;
+ /* Matching function. */
+ int (*match) PARAMS((struct bfd_elf_version_expr *, const char *));
+};
+
+/* Version dependencies. */
+
+struct bfd_elf_version_deps
+{
+ /* Next dependency for this version. */
+ struct bfd_elf_version_deps *next;
+ /* The version which this version depends upon. */
+ struct bfd_elf_version_tree *version_needed;
+};
+
+/* A node in the version tree. */
+
+struct bfd_elf_version_tree
+{
+ /* Next version. */
+ struct bfd_elf_version_tree *next;
+ /* Name of this version. */
+ const char *name;
+ /* Version number. */
+ unsigned int vernum;
+ /* Regular expressions for global symbols in this version. */
+ struct bfd_elf_version_expr *globals;
+ /* Regular expressions for local symbols in this version. */
+ struct bfd_elf_version_expr *locals;
+ /* List of versions which this version depends upon. */
+ struct bfd_elf_version_deps *deps;
+ /* Index of the version name. This is used within BFD. */
+ unsigned int name_indx;
+ /* Whether this version tree was used. This is used within BFD. */
+ int used;
+};
+
+#endif
diff --git a/include/bout.h b/include/bout.h
new file mode 100644
index 00000000000..8fc28cc3d6d
--- /dev/null
+++ b/include/bout.h
@@ -0,0 +1,182 @@
+/*
+ * This file is a modified version of 'a.out.h'. It is to be used in all
+ * GNU tools modified to support the i80960 (or tools that operate on
+ * object files created by such tools).
+ *
+ * All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e.,
+ * object code is generated on, and executed under the direction of a symbolic
+ * debugger running on, a host system. We do not want to be subject to the
+ * vagaries of which host it is or whether it supports COFF or a.out format,
+ * or anything else. We DO want to:
+ *
+ * o always generate the same format object files, regardless of host.
+ *
+ * o have an 'a.out' header that we can modify for our own purposes
+ * (the 80960 is typically an embedded processor and may require
+ * enhanced linker support that the normal a.out.h header can't
+ * accommodate).
+ *
+ * As for byte-ordering, the following rules apply:
+ *
+ * o Text and data that is actually downloaded to the target is always
+ * in i80960 (little-endian) order.
+ *
+ * o All other numbers (in the header, symbols, relocation directives)
+ * are in host byte-order: object files CANNOT be lifted from a
+ * little-end host and used on a big-endian (or vice versa) without
+ * modification.
+ * ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER
+ * FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO
+ * USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <==
+ *
+ * o The downloader ('comm960') takes care to generate a pseudo-header
+ * with correct (i80960) byte-ordering before shipping text and data
+ * off to the NINDY monitor in the target systems. Symbols and
+ * relocation info are never sent to the target.
+ */
+
+
+#define BMAGIC 0415
+/* We don't accept the following (see N_BADMAG macro).
+ * They're just here so GNU code will compile.
+ */
+#define OMAGIC 0407 /* old impure format */
+#define NMAGIC 0410 /* read-only text */
+#define ZMAGIC 0413 /* demand load format */
+
+/* FILE HEADER
+ * All 'lengths' are given as a number of bytes.
+ * All 'alignments' are for relinkable files only; an alignment of
+ * 'n' indicates the corresponding segment must begin at an
+ * address that is a multiple of (2**n).
+ */
+struct external_exec {
+ /* Standard stuff */
+ unsigned char e_info[4]; /* Identifies this as a b.out file */
+ unsigned char e_text[4]; /* Length of text */
+ unsigned char e_data[4]; /* Length of data */
+ unsigned char e_bss[4]; /* Length of uninitialized data area */
+ unsigned char e_syms[4]; /* Length of symbol table */
+ unsigned char e_entry[4]; /* Runtime start address */
+ unsigned char e_trsize[4]; /* Length of text relocation info */
+ unsigned char e_drsize[4]; /* Length of data relocation info */
+
+ /* Added for i960 */
+ unsigned char e_tload[4]; /* Text runtime load address */
+ unsigned char e_dload[4]; /* Data runtime load address */
+ unsigned char e_talign[1]; /* Alignment of text segment */
+ unsigned char e_dalign[1]; /* Alignment of data segment */
+ unsigned char e_balign[1]; /* Alignment of bss segment */
+ unsigned char e_relaxable[1]; /* Assembled with enough info to allow linker to relax */
+};
+
+#define EXEC_BYTES_SIZE (sizeof (struct external_exec))
+
+/* These macros use the a_xxx field names, since they operate on the exec
+ structure after it's been byte-swapped and realigned on the host machine. */
+#define N_BADMAG(x) (((x).a_info)!=BMAGIC)
+#define N_TXTOFF(x) EXEC_BYTES_SIZE
+#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
+#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
+#define N_TRELOFF N_TROFF
+#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
+#define N_DRELOFF N_DROFF
+#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
+#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
+#define N_DATADDR(x) ( (x).a_dload )
+
+/* Address of text segment in memory after it is loaded. */
+#if !defined (N_TXTADDR)
+#define N_TXTADDR(x) 0
+#endif
+
+/* A single entry in the symbol table
+ */
+struct nlist {
+ union {
+ char *n_name;
+ struct nlist *n_next;
+ long n_strx; /* Index into string table */
+ } n_un;
+ unsigned char n_type; /* See below */
+ char n_other; /* Used in i80960 support -- see below */
+ short n_desc;
+ unsigned long n_value;
+};
+
+
+/* Legal values of n_type
+ */
+#define N_UNDF 0 /* Undefined symbol */
+#define N_ABS 2 /* Absolute symbol */
+#define N_TEXT 4 /* Text symbol */
+#define N_DATA 6 /* Data symbol */
+#define N_BSS 8 /* BSS symbol */
+#define N_FN 31 /* Filename symbol */
+
+#define N_EXT 1 /* External symbol (OR'd in with one of above) */
+#define N_TYPE 036 /* Mask for all the type bits */
+#define N_STAB 0340 /* Mask for all bits used for SDB entries */
+
+/* MEANING OF 'n_other'
+ *
+ * If non-zero, the 'n_other' fields indicates either a leaf procedure or
+ * a system procedure, as follows:
+ *
+ * 1 <= n_other <= 32 :
+ * The symbol is the entry point to a system procedure.
+ * 'n_value' is the address of the entry, as for any other
+ * procedure. The system procedure number (which can be used in
+ * a 'calls' instruction) is (n_other-1). These entries come from
+ * '.sysproc' directives.
+ *
+ * n_other == N_CALLNAME
+ * the symbol is the 'call' entry point to a leaf procedure.
+ * The *next* symbol in the symbol table must be the corresponding
+ * 'bal' entry point to the procedure (see following). These
+ * entries come from '.leafproc' directives in which two different
+ * symbols are specified (the first one is represented here).
+ *
+ *
+ * n_other == N_BALNAME
+ * the symbol is the 'bal' entry point to a leaf procedure.
+ * These entries result from '.leafproc' directives in which only
+ * one symbol is specified, or in which the same symbol is
+ * specified twice.
+ *
+ * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
+ * but not every N_BALNAME entry must have an N_CALLNAME entry.
+ */
+#define N_CALLNAME ((char)-1)
+#define N_BALNAME ((char)-2)
+#define IS_CALLNAME(x) (N_CALLNAME == (x))
+#define IS_BALNAME(x) (N_BALNAME == (x))
+#define IS_OTHER(x) ((x)>0 && (x) <=32)
+
+#define b_out_relocation_info relocation_info
+struct relocation_info {
+ int r_address; /* File address of item to be relocated */
+ unsigned
+#define r_index r_symbolnum
+ r_symbolnum:24,/* Index of symbol on which relocation is based,
+ * if r_extern is set. Otherwise set to
+ * either N_TEXT, N_DATA, or N_BSS to
+ * indicate section on which relocation is
+ * based.
+ */
+ r_pcrel:1, /* 1 => relocate PC-relative; else absolute
+ * On i960, pc-relative implies 24-bit
+ * address, absolute implies 32-bit.
+ */
+ r_length:2, /* Number of bytes to relocate:
+ * 0 => 1 byte
+ * 1 => 2 bytes -- used for 13 bit pcrel
+ * 2 => 4 bytes
+ */
+ r_extern:1,
+ r_bsr:1, /* Something for the GNU NS32K assembler */
+ r_disp:1, /* Something for the GNU NS32K assembler */
+ r_callj:1, /* 1 if relocation target is an i960 'callj' */
+ r_relaxable:1; /* 1 if enough info is left to relax
+ the data */
+};
diff --git a/include/callback.h b/include/callback.h
new file mode 100644
index 00000000000..30752842ed9
--- /dev/null
+++ b/include/callback.h
@@ -0,0 +1,270 @@
+/* Remote target system call callback support.
+ Copyright 1997 Free Software Foundation, Inc.
+ Contributed by Cygnus Solutions.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This interface isn't intended to be specific to any particular kind
+ of remote (hardware, simulator, whatever). As such, support for it
+ (e.g. sim/common/callback.c) should *not* live in the simulator source
+ tree, nor should it live in the gdb source tree. */
+
+/* There are various ways to handle system calls:
+
+ 1) Have a simulator intercept the appropriate trap instruction and
+ directly perform the system call on behalf of the target program.
+ This is the typical way of handling system calls for embedded targets.
+ [Handling system calls for embedded targets isn't that much of an
+ oxymoron as running compiler testsuites make use of the capability.]
+
+ This method of system call handling is done when STATE_ENVIRONMENT
+ is ENVIRONMENT_USER.
+
+ 2) Have a simulator emulate the hardware as much as possible.
+ If the program running on the real hardware communicates with some sort
+ of target manager, one would want to be able to run this program on the
+ simulator as well.
+
+ This method of system call handling is done when STATE_ENVIRONMENT
+ is ENVIRONMENT_OPERATING.
+*/
+
+#ifndef CALLBACK_H
+#define CALLBACK_H
+
+/* ??? The reason why we check for va_start here should be documented. */
+
+#ifndef va_start
+#include <ansidecl.h>
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+/* Mapping of host/target values. */
+/* ??? For debugging purposes, one might want to add a string of the
+ name of the symbol. */
+
+typedef struct {
+ int host_val;
+ int target_val;
+} CB_TARGET_DEFS_MAP;
+
+#define MAX_CALLBACK_FDS 10
+
+/* Forward decl for stat/fstat. */
+struct stat;
+
+typedef struct host_callback_struct host_callback;
+
+struct host_callback_struct
+{
+ int (*close) PARAMS ((host_callback *,int));
+ int (*get_errno) PARAMS ((host_callback *));
+ int (*isatty) PARAMS ((host_callback *, int));
+ int (*lseek) PARAMS ((host_callback *, int, long , int));
+ int (*open) PARAMS ((host_callback *, const char*, int mode));
+ int (*read) PARAMS ((host_callback *,int, char *, int));
+ int (*read_stdin) PARAMS (( host_callback *, char *, int));
+ int (*rename) PARAMS ((host_callback *, const char *, const char *));
+ int (*system) PARAMS ((host_callback *, const char *));
+ long (*time) PARAMS ((host_callback *, long *));
+ int (*unlink) PARAMS ((host_callback *, const char *));
+ int (*write) PARAMS ((host_callback *,int, const char *, int));
+ int (*write_stdout) PARAMS ((host_callback *, const char *, int));
+ void (*flush_stdout) PARAMS ((host_callback *));
+ int (*write_stderr) PARAMS ((host_callback *, const char *, int));
+ void (*flush_stderr) PARAMS ((host_callback *));
+ int (*stat) PARAMS ((host_callback *, const char *, struct stat *));
+ int (*fstat) PARAMS ((host_callback *, int, struct stat *));
+
+ /* When present, call to the client to give it the oportunity to
+ poll any io devices for a request to quit (indicated by a nonzero
+ return value). */
+ int (*poll_quit) PARAMS ((host_callback *));
+
+ /* Used when the target has gone away, so we can close open
+ handles and free memory etc etc. */
+ int (*shutdown) PARAMS ((host_callback *));
+ int (*init) PARAMS ((host_callback *));
+
+ /* depreciated, use vprintf_filtered - Talk to the user on a console. */
+ void (*printf_filtered) PARAMS ((host_callback *, const char *, ...));
+
+ /* Talk to the user on a console. */
+ void (*vprintf_filtered) PARAMS ((host_callback *, const char *, va_list));
+
+ /* Same as vprintf_filtered but to stderr. */
+ void (*evprintf_filtered) PARAMS ((host_callback *, const char *, va_list));
+
+ /* Print an error message and "exit".
+ In the case of gdb "exiting" means doing a longjmp back to the main
+ command loop. */
+ void (*error) PARAMS ((host_callback *, const char *, ...));
+
+ int last_errno; /* host format */
+
+ int fdmap[MAX_CALLBACK_FDS];
+ char fdopen[MAX_CALLBACK_FDS];
+ char alwaysopen[MAX_CALLBACK_FDS];
+
+ /* System call numbers. */
+ CB_TARGET_DEFS_MAP *syscall_map;
+ /* Errno values. */
+ CB_TARGET_DEFS_MAP *errno_map;
+ /* Flags to the open system call. */
+ CB_TARGET_DEFS_MAP *open_map;
+ /* Signal numbers. */
+ CB_TARGET_DEFS_MAP *signal_map;
+ /* Layout of `stat' struct.
+ The format is a series of "name,length" pairs separated by colons.
+ Empty space is indicated with a `name' of "space".
+ All padding must be explicitly mentioned.
+ Lengths are in bytes. If this needs to be extended to bits,
+ use "name.bits".
+ Example: "st_dev,4:st_ino,4:st_mode,4:..." */
+ const char *stat_map;
+
+ /* Marker for those wanting to do sanity checks.
+ This should remain the last member of this struct to help catch
+ miscompilation errors. */
+#define HOST_CALLBACK_MAGIC 4705 /* teds constant */
+ int magic;
+};
+
+extern host_callback default_callback;
+
+/* Canonical versions of system call numbers.
+ It's not intended to willy-nilly throw every system call ever heard
+ of in here. Only include those that have an important use.
+ ??? One can certainly start a discussion over the ones that are currently
+ here, but that will always be true. */
+
+/* These are used by the ANSI C support of libc. */
+#define CB_SYS_exit 1
+#define CB_SYS_open 2
+#define CB_SYS_close 3
+#define CB_SYS_read 4
+#define CB_SYS_write 5
+#define CB_SYS_lseek 6
+#define CB_SYS_unlink 7
+#define CB_SYS_getpid 8
+#define CB_SYS_kill 9
+#define CB_SYS_fstat 10
+/*#define CB_SYS_sbrk 11 - not currently a system call, but reserved. */
+
+/* ARGV support. */
+#define CB_SYS_argvlen 12
+#define CB_SYS_argv 13
+
+/* These are extras added for one reason or another. */
+#define CB_SYS_chdir 14
+#define CB_SYS_stat 15
+#define CB_SYS_chmod 16
+#define CB_SYS_utime 17
+#define CB_SYS_time 18
+
+/* Struct use to pass and return information necessary to perform a
+ system call. */
+/* FIXME: Need to consider target word size. */
+
+typedef struct cb_syscall {
+ /* The target's value of what system call to perform. */
+ int func;
+ /* The arguments to the syscall. */
+ long arg1, arg2, arg3, arg4;
+
+ /* The result. */
+ long result;
+ /* Some system calls have two results. */
+ long result2;
+ /* The target's errno value, or 0 if success.
+ This is converted to the target's value with host_to_target_errno. */
+ int errcode;
+
+ /* Working space to be used by memory read/write callbacks. */
+ PTR p1;
+ PTR p2;
+ long x1,x2;
+
+ /* Callbacks for reading/writing memory (e.g. for read/write syscalls).
+ ??? long or unsigned long might be better to use for the `count'
+ argument here. We mimic sim_{read,write} for now. Be careful to
+ test any changes with -Wall -Werror, mixed signed comparisons
+ will get you. */
+ int (*read_mem) PARAMS ((host_callback * /*cb*/, struct cb_syscall * /*sc*/,
+ unsigned long /*taddr*/, char * /*buf*/,
+ int /*bytes*/));
+ int (*write_mem) PARAMS ((host_callback * /*cb*/, struct cb_syscall * /*sc*/,
+ unsigned long /*taddr*/, const char * /*buf*/,
+ int /*bytes*/));
+
+ /* For sanity checking, should be last entry. */
+ int magic;
+} CB_SYSCALL;
+
+/* Magic number sanity checker. */
+#define CB_SYSCALL_MAGIC 0x12344321
+
+/* Macro to initialize CB_SYSCALL. Called first, before filling in
+ any fields. */
+#define CB_SYSCALL_INIT(sc) \
+do { \
+ memset ((sc), 0, sizeof (*(sc))); \
+ (sc)->magic = CB_SYSCALL_MAGIC; \
+} while (0)
+
+/* Return codes for various interface routines. */
+
+typedef enum {
+ CB_RC_OK = 0,
+ /* generic error */
+ CB_RC_ERR,
+ /* either file not found or no read access */
+ CB_RC_ACCESS,
+ CB_RC_NO_MEM
+} CB_RC;
+
+/* Read in target values for system call numbers, errno values, signals. */
+CB_RC cb_read_target_syscall_maps PARAMS ((host_callback *, const char *));
+
+/* Translate target to host syscall function numbers. */
+int cb_target_to_host_syscall PARAMS ((host_callback *, int));
+
+/* Translate host to target errno value. */
+int cb_host_to_target_errno PARAMS ((host_callback *, int));
+
+/* Translate target to host open flags. */
+int cb_target_to_host_open PARAMS ((host_callback *, int));
+
+/* Translate target signal number to host. */
+int cb_target_to_host_signal PARAMS ((host_callback *, int));
+
+/* Translate host signal number to target. */
+int cb_host_to_target_signal PARAMS ((host_callback *, int));
+
+/* Translate host stat struct to target.
+ If stat struct ptr is NULL, just compute target stat struct size.
+ Result is size of target stat struct or 0 if error. */
+int cb_host_to_target_stat PARAMS ((host_callback *, const struct stat *, PTR));
+
+/* Perform a system call. */
+CB_RC cb_syscall PARAMS ((host_callback *, CB_SYSCALL *));
+
+#endif
diff --git a/include/coff/ChangeLog b/include/coff/ChangeLog
new file mode 100644
index 00000000000..8ad6e0cec4a
--- /dev/null
+++ b/include/coff/ChangeLog
@@ -0,0 +1,793 @@
+1999-04-21 Nick Clifton <nickc@cygnus.com>
+
+ * mcore.h (GET_LINENO_LNNO): New macro.
+ (PUT_LINENO_LNNO): New macro.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * mcore.h: New header file. Defines for Motorolla's MCore
+ processor.
+
+Sun Dec 6 21:36:37 1998 Mark Elbrecht <snowball3@usa.net>
+
+ * internal.h (C_WEAKEXT): Define.
+
+Wed Jan 27 13:35:35 1999 Stan Cox <scox@cygnus.com>
+
+ * coff/arm.h (F_PIC_INT, F_ARM_2, F_ARM_3, F_ARM_4, F_APCS26):
+ Changed values to avoid clashing with IMAGE_FILE_* coff header
+ flag values.
+
+Wed Apr 1 16:06:15 1998 Nick Clifton <nickc@cygnus.com>
+
+ * internal.h: Document numbers associated with Thumb symbol
+ types.
+
+Fri Mar 27 17:16:57 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (ISPTR, ISFCN, ISARY): Add casts to unsigned long.
+
+Mon Feb 2 17:10:38 1998 Steve Haworth <steve@pm.cse.rmit.EDU.AU>
+
+ * tic30.h: New file.
+
+Fri Dec 12 11:49:07 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (R_MPPCR15W): New relocation type, for 15 bit PC relative
+ offsets.
+
+Tue Dec 2 10:21:40 1997 Nick Clifton <nickc@cygnus.com>
+
+ * arm.h (COFFARM): New define.
+
+Sat Nov 22 15:10:14 1997 Nick Clifton <nickc@cygnus.com>
+
+ * internal.h (C_THUMBEXTFUNC, C_THUMBSTATFUNC): Constants to
+ define static and external functions.
+
+ * arm.h: Add bits to support PIC and APCS-FLOAT type binaries,
+ when implemented.
+
+Fri Oct 3 14:25:17 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (R_PPL16B): Make constant uppercase for consistency.
+
+Tue Jul 22 18:18:58 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
+
+ * go32exe.h: New file.
+
+Tue Jul 8 12:23:55 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_TARGET_ID): Add define.
+ * internal.h (struct internal_filehdr): Add f_target_id field.
+
+Tue Jun 3 16:44:18 1997 Nick Clifton <nickc@cygnus.com>
+
+ * internal.h: Add storage classes for Thumb symbols
+
+Mon May 26 14:07:55 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * tic80.h (R_PPL16B): Correct value.
+
+Sat May 3 08:24:59 1997 Fred Fish <fnf@cygnus.com>
+
+ * internal.h (C_UEXT, C_STATLAB, C_EXTLAB, C_SYSTEM):
+ New storage classes for TIc80.
+
+Fri Apr 18 11:52:55 1997 Niklas Hallqvist <niklas@appli.se>
+
+ * alpha.h (ALPHA_ECOFF_BADMAG): Recognize *BSD/alpha magic too.
+ (ALPHA_R_LITERALSLEAZY): Define.
+ * ecoff.h (ALPHA_MAGIC_BSD): Define.
+
+Wed Jan 29 11:31:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i960.h (R_IPR13, R_ALIGN): Define.
+
+Mon Jan 27 13:34:30 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (R_IPRMED, R_OPTCALL, R_OPTCALLX): Move definitions
+ from here...
+ * i960.h (R_IPRMED, R_OPTCALL, R_OPTCALLX): ...to here.
+
+Wed Jan 22 20:10:47 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80MAGIC): Renamed to TIC80_AOUTHDR_MAGIC.
+
+Fri Dec 27 22:05:45 1996 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h: New file for TIc80 support.
+
+Thu Dec 19 16:18:11 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * arm.h (_LIT): Define.
+
+Fri Jun 28 12:54:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * pe.h (FILHSZ): Define.
+
+Wed Jun 26 16:24:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * All files: Define FILHSZ, AOUTSZ, AOUTHDRSZ, SCNHSZ, SYMESZ,
+ AUXESZ, LINESZ, RELSZ as numeric constants rather than uses of
+ sizeof. Define AOUTHDRSZ in all files.
+ * pe.h (AOUTSZ): Define by adding to AOUTHDRSZ.
+
+Fri Jun 21 11:17:46 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha.h: Add declarations for relocation types added for Alpha
+ OSF/1 3.0.
+
+Tue Jun 18 16:04:29 1996 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * h8300.h (H8300SMAGIC): Define.
+ (H8300SBADMAG): Define.
+
+Mon Jun 10 11:53:28 1996 Jeffrey A Law (law@cygnus.com)
+
+ * internal.h (R_BCC_INV, R_JMP_DEL): New relocations for
+ relaxing in the H8/300 series.
+
+Thu May 16 15:49:22 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sh.h (R_SH_CODE, R_SH_DATA, R_SH_LABEL): Define.
+
+Tue May 7 00:36:39 1996 Jeffrey A Law (law@cygnus.com)
+
+ * internal.h (R_JMPL2): Renamed from R_JMPL_B8 to be
+ consistent with other similar relocs.
+
+ * internal.h (H8/300 specific relocs): Add comments better
+ explaining what each reloc is used for.
+ (R_MOV16B1, R_MOV16B2): Renamed from R_MOVB1 and R_MOVB2.
+ (R_MOV24B1, R_MOV24B2): Renamed from R_MOVLB1 and R_MOVLB2.
+ (R_MOVL1, R_MOVL2): New relocs.
+
+Fri May 3 13:01:12 1996 Jeffrey A Law (law@cygnus.com)
+
+ * internal.h (R_PCRWORD_B): Define for the h8300 relaxing
+ linker.
+
+Wed May 1 19:21:03 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (SCNNMLEN): Define.
+ (struct internal_scnhdr): Use SCNNMLEN for s_name field.
+
+Fri Mar 29 13:41:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * pe.h: Define IMAGE_COMDAT codes.
+
+Wed Mar 27 17:29:42 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * arm.h (union external_auxent): Add x_checksum, x_associated, and
+ x_comdat fields to x_scn struct.
+ * i386.h (union external_auxent): Likewise.
+ * powerpc.h (union external_auxent): Likewise.
+ * internal.h (union internal_auxent): Likewise.
+
+Thu Mar 21 16:25:57 1996 David Mosberger-Tang <davidm@azstarnet.com>
+
+ * ecoff.h (struct ecoff_find_line): Add caching fields.
+
+Thu Mar 14 15:22:44 1996 Jeffrey A Law (law@cygnus.com)
+
+ * internal.h (R_MEM_INDIRECT): New reloc for the h8300.
+
+Fri Feb 9 10:44:11 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * aux-coff.h: Rename from aux.h, to avoid problems on hapless DOS
+ systems which think that aux is a com port.
+
+Mon Feb 5 18:35:00 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i960.h (F_I960HX): Define.
+
+Wed Jan 31 13:11:54 1996 Richard Henderson <rth@tamu.edu>
+
+ * aux.h: New file.
+ * internal.h, m68k.h: Protect against multiple inclusion.
+
+Wed Nov 22 13:48:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.h (_RCONST, STYP_RCONST, RELOC_SECTION_RCONST): Define.
+ (NUM_RELOC_SECTIONS): Update.
+ * symconst.h (scRConst): Define.
+
+Tue Nov 14 18:54:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (C_NT_WEAK): Define.
+
+Thu Nov 9 14:08:30 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * rs6000.h (STYP_OVRFLO): Define.
+
+Tue Nov 7 14:38:45 1995 Kim Knuttila <krk@cygnus.com>
+
+ * coff/powerpc.h (IMAGE_NT_OPTIONAL_HDR_MAGIC): Added define.
+ * coff/pe.h: Added defines for file level flags
+
+Mon Nov 6 17:28:01 1995 Harry Dolan <dolan@ssd.intel.com>
+
+ * i860.h: New file, based on i386.h.
+
+Wed Nov 1 15:25:18 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de>
+
+ * m68k.h (PAGEMAGICEXECSWAPPED): Define.
+ (PAGEMAGICPEXECSWAPPED): Define.
+ (PAGEMAGICPEXECTSHLIB): Define.
+ (PAGEMAGICPEXECPAGED): Define.
+ (_COMMENT): DEFINE.
+ * m88k.h (_COMMENT): Define.
+
+Wed Oct 18 18:36:19 1995 Geoffrey Noer <noer@cygnus.com>
+
+ * sym.h: #if 0'd out runtime_pdr struct because it chokes
+ Visual C++ and there aren't any references to it elsewhere in gdb.
+
+Mon Oct 16 11:12:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * rs6000.h (SMALL_AOUTSZ): Define.
+
+ * internal.h (XMC_TD): Define.
+
+Tue Oct 10 18:41:03 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (struct internal_aouthdr): Add o_cputype field.
+ * rs6000.h (AOUTHDR): Rename o_resv1 to o_cputype.
+
+Mon Oct 9 14:45:46 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * rs6000.h (AOUTHDR): Add o_maxdata field. Add comments.
+ (_PAD, _LOADER): Define.
+ (STYP_LOADER): Define.
+ * internal.h (struct internal_aouthdr): Add o_maxdata field.
+
+Thu Oct 5 10:02:57 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.h: Define section name macros and STYP macros for various
+ Alpha sections: .got, .hash, .dynsym, .dynstr, .rel.dyn, .conflic,
+ .comment, .liblist, .dynamic.
+
+Wed Oct 4 10:56:35 1995 Kim Knuttila <krk@cygnus.com>
+
+ * pe.h: Moved DOSMAGIC and NT_SIGNATURE defines here
+ * powerpc.h: removed DOSMAGIC, NT_SIGNATURE, and DEFAULT_* defines
+ Also removed other unused defines (various MAGIC ones)
+ * i386.h: removed DOSMAGIC, NT_SIGNATURE, and DEFAULT_* defines
+ * arm.h: removed DOSMAGIC, NT_SIGNATURE, and DEFAULT_* defines
+ * apollo.h: removed unused DEFAULT_* defines
+ * alpha.h: removed unused DEFAULT_* defines
+ * h8500.h: removed unused DEFAULT_* defines
+ * h8300.h: removed unused DEFAULT_* defines
+ * i960.h: removed unused DEFAULT_* defines
+ * m88k.h: removed unused DEFAULT_* defines
+ * we32k.h: removed unused DEFAULT_* defines
+ * rs6000.h: removed unused DEFAULT_* defines
+ * mips.h: removed unused DEFAULT_* defines
+ * m68k.h: removed unused DEFAULT_* defines
+ * z8k.h: removed unused DEFAULT_* defines
+ * w65.h: removed unused DEFAULT_* defines
+ * sparc.h: removed unused DEFAULT_* defines
+ * sh.h: removed unused DEFAULT_* defines
+
+Fri Sep 29 08:40:08 1995 Kim Knuttila <krk@cygnus.com>
+
+ * powerpc.h: Reformatted to GNU coding conventions.
+
+Wed Sep 27 06:50:50 1995 Kim Knuttila <krk@nellie>
+
+ * pe.h: added defines for more section characteristics
+ * powerpc.h (new file): base coff definitions for ppc PE
+
+Tue Sep 12 12:08:20 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (struct internal_syment): Change n_numaux field from
+ char to unsigned char.
+
+Fri Sep 1 15:39:36 1995 Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>
+
+ * mips.h (struct rpdr_ext): Define.
+
+Thu Aug 31 16:51:50 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * internal.h (internal_aouthdr, internal_filehdr):
+ don't indirect the pe stuff.
+
+Tue Aug 29 14:16:07 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * i386.h (NT_DEF_RESERVE, NT_DEF_COMMIT): Make the same
+ as 'the other' compiler.
+ * internal.h (NT_IMAGE_BASE): Deleted.
+ (NT_EXE_IMAGE_BASE, NT_DLL_IMAGE_BASE): New.
+ (PE_DEF_SECTION_ALIGNMENT, PE_DEF_FILE_ALIGNMENT): New.
+ (R_IMAGEBASE): New.
+
+Mon Aug 21 18:12:19 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * internal.h: (internal_filehdr): Moved PE stuff into
+ internal_extra_pe_filehdr.
+ (internal_aouthdr): Moved PE stuff into
+ interanl_extra_pe_aouthdr.
+
+Mon Jul 24 14:05:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h: Move R_SH_* relocs from here...
+ * sh.h: ...to here.
+ (R_SH_SWITCH16, R_SH_SWITCH32): Define.
+ (R_SH_USES, R_SH_COUNT, R_SH_ALIGN): Define.
+
+Thu Jun 29 00:04:25 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * internal.h (NT_DEF_RESERVE, NT_DEF_COMMIT): Increase a lot.
+
+Tue May 16 15:08:20 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * internal.h (NT_subsystem, NT_stack_heap): Delete
+
+Tue May 16 15:08:20 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * internal.h (NT_subsystem, NT_stack_heap): Now extern.
+
+Tue Feb 14 17:59:37 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ecoff.h (struct ecoff_fdrtab_entry): Define.
+ (struct ecoff_find_line): Define.
+
+Sat Feb 4 14:38:03 1995 David Mosberger-Tang <davidm@piston.cs.arizona.edu>
+
+ * sym.h (struct pdr): field "prof" added.
+
+ * alpha.h (PDR_BITS1_PROF_*): added, macros for PDR_BITS*_RESERVED_*
+ updated accordingly.
+
+Sun Jan 15 18:38:33 1995 Steve Chamberlain <sac@splat>
+
+ * w65.h: New file.
+
+Wed Nov 23 22:43:38 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * sh.h (SH_ARCH_MAGIC_BIG, SH_ARCH_MAGIC_LITTLE): New.
+ (SHBADMAG): Changed to suit.
+
+Tue Jul 26 17:46:08 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i960.h (F_I960JX): New macro.
+
+Wed Jul 6 00:48:57 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * alpha.h: Add definitions for alpha file header flags, encoding
+ the object type of the file.
+
+Mon Jun 20 13:47:01 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * ecoff.h (ecoff_swap_tir_in): Remove declaration.
+ (ecoff_swap_tir_out): Likewise.
+ (ecoff_swap_rndx_in, ecoff_swap_rndx_out): Likewise.
+ (struct ecoff_debug_swap): Add new fields: swap_tir_in,
+ swap_rndx_in, swap_tir_out, swap_rndx_out, read_debug_info.
+
+Sun Jun 12 03:51:52 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * symconst.h: Pick up SGI define for stIndirect.
+
+Fri Apr 22 13:05:28 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (REGINFO): Don't define.
+ (struct ecoff_reginfo): Don't define.
+
+ * sh.h (SH_ARCH_MAGIC): Rename from SHMAGIC. SHMAGIC is used by
+ several targets to mean a shared library.
+ (SHBADMAG): Corresponding change.
+
+Thu Apr 14 13:00:53 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (RELOC_BITS3_TYPE_BIG): Changed from 0x1e to 0x3e.
+ (RELOC_BITS3_TYPEHI_LITTLE): Define.
+ (RELOC_BITS3_TYPEHI_SH_LITTLE): Define.
+ (MIPS_R_PCREL16): Change value from 8 to 12 to match Irix 4.
+ (MIPS_R_RELHI): Define.
+ (MIPS_R_RELLO): Define.
+ (MIPS_R_SWITCH): Change value from 9 to 22.
+
+Thu Apr 7 14:19:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (MIPS_R_SWITCH): Define.
+
+Thu Mar 31 19:28:33 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * internal.h (internal_aouthdr): Added comments for Apollo fields.
+
+Thu Mar 31 16:28:02 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (STYP_ECOFF_LIB): Define as used on Irix 4.
+
+Fri Mar 25 17:16:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (struct ecoff_debug_info): Add adjust field.
+ (struct ecoff_value_adjust): Define.
+
+Tue Mar 22 13:22:47 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (MIPS_R_PCREL16): Define.
+
+Sat Feb 26 10:26:38 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff.h: Add casts to avoid warnings from SVR4 cc.
+
+Mon Feb 21 09:48:46 1994 Ian Lance Taylor (ian@lisa.cygnus.com)
+
+ * sym.h (struct runtime_pdr): Make field adr bfd_vma, not unsigned
+ long.
+ (SYMR): Make field value bfd_vma, not long.
+
+Fri Feb 4 23:35:53 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * rs6000.h (STYP_DEBUG): Define.
+
+Wed Feb 2 14:31:37 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * internal.h (union internal_auxent): Change x_csect.x_scnlen into
+ a union of a long and a pointer to a symbol. XCOFF sometimes uses
+ this field as a symbol index.
+
+Mon Jan 10 23:54:25 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (ecoff_debug_info): Remove fields line_end,
+ external_dnr_end, external_pdr_end, external_sym_end,
+ external_opt_end, external_aux_end, ss_end, external_fdr_end.
+ Replace ifdbase with ifdmap.
+
+Wed Jan 5 17:05:36 1994 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * ecoff.h (STYP_EXTENDESC, STYP_COMMENT, STYP_XDATA, STYP_PDATA):
+ Define.
+
+Wed Jan 5 16:58:24 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (NUM_RELOC_SECTIONS): Define.
+
+Tue Dec 21 09:24:56 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * sparc.h (struct external_reloc): Rename field r_addend to
+ r_offset.
+
+Sat Dec 11 16:12:32 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h (R_DISP7, R_SH_IMM16): New reloc types.
+
+Tue Nov 23 14:23:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (struct ecoff_debug_swap): Added *_end fields for all
+ the symbolic information pointers.
+
+ * sym.h: Named the EXTR structure ecoff_extr.
+
+Fri Nov 19 08:21:18 1993 Ken Raeburn (raeburn@rover.cygnus.com)
+
+ * sparc.h (RELSZ): Use correct size.
+
+Wed Nov 17 17:18:16 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (struct ecoff_debug_info): Define.
+
+Tue Nov 2 17:56:57 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (struct ecoff_debug_swap): Define.
+
+Thu Oct 28 17:07:50 1993 Stan Shebs (shebs@rtl.cygnus.com)
+
+ * i386.h (I386LYNXMAGIC): Rename to LYNXCOFFMAGIC.
+ * m68k.h (LYNXCOFFMAGIC): Define.
+ * sparc.h: New file.
+
+Tue Oct 19 15:34:50 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * alpha.h (external_aouthdr): Split four byte padding field into
+ two byte bldrev field and two byte padding field.
+
+ * ecoff.h (_LITA, _PDATA, _XDATA, STYP_LITA): Defined.
+
+Wed Oct 13 15:52:34 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ Sun Oct 10 17:27:10 1993 Troy Rollo (troy@cbme.unsw.edu.au)
+
+ * coff/internal.h: Added o_sri, o_inlib and o_vid for Apollos
+ as well as R_DIR16.
+
+ * coff/apollo.h: New file
+
+Mon Oct 11 17:16:48 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (REGINFO, struct ecoff_reginfo): Define.
+
+Tue Oct 5 10:52:53 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * rs6000.h: Change non-ASCII characters in comment to octal
+ escapes.
+
+Tue Sep 28 03:27:04 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * ecoff.h (_FINI, STYP_ECOFF_FINI): Add to support .fini section.
+
+Fri Sep 24 11:53:53 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (BADMAG): Recognize MIPS_MAGIC_LITTLE3 and MIPS_MAGIC_BIG3.
+ * ecoff.h: Define MIPS_MAGIC_LITTLE3 and MIPS_MAGIC_BIG3.
+
+Thu Sep 23 21:07:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * mips.h (BADMAG): Recognize MIPS_MAGIC_LITTLE2 and MIPS_MAGIC_BIG2.
+ * ecoff.h: Define MIPS_MAGIC_LITTLE2 and MIPS_MAGIC_BIG2.
+
+Thu Sep 16 20:27:21 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
+
+ * sym.h, symconst.h: Add comment stating these files are not part
+ of GDB, GAS, etc. In 1991, when we asked rms whether we could
+ include these files in GDB (although they are copyrighted by
+ someone besides the FSF), he said it was OK if they were not
+ considered part of GDB.
+
+Fri Sep 10 17:40:35 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (AUX_PUT_ANY): Cast val argument to bfd_vma.
+
+ * alpha.c (external_aouthdr): Need four bytes of padding between
+ vstamp and tsize.
+
+Tue Sep 7 14:20:43 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff.h (AUX_GET_ANY, AUX_PUT_ANY): Changed to reflect further
+ change in bfd swapping routine names.
+
+Tue Sep 7 10:15:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * ecoff.h (AUX_GET_ANY): Change name of _do_getb32 to reflect bfd
+ changes.
+
+Fri Aug 13 14:30:32 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff.h (RELOC_SECTION_NONE): Define.
+
+Thu Aug 12 11:24:42 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * alpha.h (struct external_reloc): Add r_symndx field.
+ (RELSZ): Correct.
+ (RELOC_BITS*): Correct.
+ (ALPHA_R_*): Define.
+ * ecoff.h (RELOC_SECTION_{XDATA,PDATA,FINI,LITA,ABS}): Define.
+ (r_extern): Undefine.
+ * internal.h (struct internal_reloc): Make r_vaddr bfd_vma rather
+ than long. Add r_extern field.
+
+ * alpha.h (PDR_BITS*): Define.
+ * sym.h (PDR): Give correct names to new fields.
+
+ * ecoff.h: Moved MIPS reloc definitions from here...
+ * mips.h: to here.
+
+Tue Aug 3 11:17:53 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * alpha.h: Corrected external symbolic debugging structures to
+ match actual usage.
+ * internal.h (internal_filehdr, internal_aouthdr,
+ internal_scnhdr): Changed type of some fields to bfd_vma so they
+ can hold 64 bits.
+ * sym.h (HDRR, FDR, PDR, EXTR): Likewise.
+ (PDR): Added new fields found on Alpha.
+ * symconst.h (magicSym2): Define; new value found on Alpha.
+
+ * ecoff.h: New file.
+ * alpha.h, mips.h: Moved common information into ecoff.h. Moved
+ external structure definitions in from ecoff-ext.h.
+ * ecoff-ext.h: Removed; information now in alpha.h and mips.h.
+
+Sun Jul 18 21:43:59 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * i386.h: Recognize I386PTXMAGIC.
+
+Fri Jul 16 09:54:35 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h (MIPS_AOUT_{OZ}MAGIC): Renamed from {OZ}MAGIC.
+
+Thu Jul 15 12:23:55 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m88k.h (union external_auxent): Move x_fcn back inside x_fcnary.
+ ({GET,PUT}_FCN_{LNNOPTR,ENDNDX}): Adjust accordingly.
+
+Sun Jul 11 18:00:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * m68k.h: Define MC68KBCSMAGIC.
+
+Thu Jun 10 11:46:28 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h (_INIT, STYP_MIPS_INIT): Define (used on Irix4).
+ (STYP_OTHER_LOAD): Define as STYP_MIPS_INIT.
+
+Wed Jun 9 15:09:09 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h (OMAGIC): Define.
+
+Mon Apr 26 18:04:47 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h, sh.h: Support for SH.
+
+Sat Apr 24 21:34:59 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * a29k.h: Define _LIT.
+
+Fri Apr 23 18:41:23 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * alpha.h: New file.
+
+Thu Apr 8 12:36:34 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * internal.h (C_SHADOW, C_VERSION): Copied in from m88k.h.
+ * m88k.h, i386.h, we32k.h: Don't define all the storage classes;
+ they're already in internal.h.
+
+Wed Apr 7 11:51:24 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * internal.h: Change n_sclass to unsigned char.
+ Change C_EFCN to 0xff, change RS/6000 dbx symbols
+ to no longer be signed.
+
+Fri Mar 19 14:52:56 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h: Add H8/500 reloc types.
+
+Wed Mar 17 09:46:03 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff-ext.h (AUX_PUT_ANY): Don't use void values in branches of
+ conditional expression.
+
+Thu Mar 4 14:12:06 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * ecoff-ext.h (AUX_GET_*): Rewrote to use new macro AUX_GET_ANY.
+ (AUX_PUT_*): New macros corresponding to the AUX_GET macros.
+ (ecoff_swap_tir_out): Added prototype.
+
+ * mips.h (N_BTMASK, N_TMASK, N_BTSHFT, N_TSHIFT): Define; these
+ are needed to interpret gcc debugging output.
+
+Tue Feb 9 07:43:27 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * we32k.h (BTYPE, ISPTR, ISFCN, ISARY, DECREF): Removed
+ more definitions duplicated in internal.h.
+
+Wed Feb 3 09:18:24 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h (RELOC_BITS3_TYPE_*): Correct for big endian machines.
+
+Mon Jan 25 11:35:51 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * internal.h (internal_aouthdr): Added additional fields used only
+ by MIPS ECOFF.
+
+Thu Jan 21 10:28:38 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h (AOUTHDR): Added additional fields used by ECOFF.
+
+Tue Jan 19 12:21:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * i386.h, we32k.h (N_*, T_*, DT_*): Removed still more definitions
+ duplicated in internal.h.
+
+ * mips.h (RELOC_SECTION_*, ECOFF_R_*): Defined constants for ECOFF
+ relocs.
+
+Fri Jan 15 18:17:00 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff-ext.h: Added prototypes for new ECOFF swapping functions.
+ (opt_ext): New structure.
+ * mips.h (ZMAGIC): Defined to be 0413.
+ (_LIB): Defined to be ".lib"
+ (external_reloc): MIPS ECOFF relocs are only 8 bytes. Added
+ macros to aid in swapping.
+
+Fri Jan 8 16:19:26 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ecoff-ext.h: Added prototypes for ECOFF swapping functions.
+ * internal.h (internal_scnhdr): Always provide s_align field, not
+ just on i960.
+ (internal_reloc): Always provide r_size field, not just on
+ RS/6000.
+ * mips.h (_RDATA, _SDATA, _SBSS, _LIT4, _LIT8, STYP_RDATA,
+ STYP_SDATA, STYP_SBSS, STYP_LIT4, STYP_LIT8): Defined.
+ (CODE_MASK, MIPS_IS_STAB, MIPS_MARK_STAB, MIPS_UNMARK_STAB,
+ STABS_SYMBOL): Moved in from gdb/mipsread.c.
+
+Wed Jan 6 14:01:46 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * i386.h, we32k.h: removed STYP_* defines, since they duplicated
+ those in internal.h.
+
+Tue Dec 29 15:40:07 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * i386.h: define I386AIXMAGIC for Danbury AIX PS/2 compiler.
+
+Sat Dec 12 16:07:57 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * i386.h: don't define BTYPE, ISPTR, ISFCN, ISARY, DECREF: they
+ are defined in internal.h.
+
+Thu Nov 12 09:52:01 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h: (internal_reloc): r_offset is now a long.
+ * z8k.h: slight comment enhancement
+
+Wed Sep 30 07:46:08 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h: changed z8k reloc types
+
+Fri Aug 28 10:16:31 1992 Brendan Kehoe (brendan@cygnus.com)
+
+ * we32k.h: new file
+
+Thu Aug 27 13:00:01 1992 Brendan Kehoe (brendan@cygnus.com)
+
+ * symconst.h: comment out cruft at the end of #endif
+
+Tue Aug 25 15:06:49 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h: added #define for STYP_LIT, removed from a29k and
+ h8300.
+
+ * z8k.h: added z8000 support
+
+Thu Jul 16 16:32:00 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * internal.h: added R_RELLONG_NEG reloc type
+
+Fri Jun 12 20:11:04 1992 John Gilmore (gnu at cygnus.com)
+
+ * symconst.h: Fix unterminated comment.
+
+Wed Jun 10 07:57:49 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * i386.h: a.out magic numbers from
+ mohring@informatik.tu-muenchen.de
+
+Mon Jun 8 20:13:33 1992 John Gilmore (gnu at cygnus.com)
+
+ * ecoff-ext.h, mips.h: Use unsigned chars everywhere.
+ (Suggested by Antti Miettinen.)
+
+Tue Apr 14 15:18:44 1992 John Gilmore (gnu at cygnus.com)
+
+ * sym.h: Add comments.
+ * symconst.h: Merge with Fred's changes.
+
+Tue Apr 14 14:30:05 1992 Fred Fish (fnf@cygnus.com)
+
+ * symconst.h: Pick up SGI defines for stStruct, stUnion, stEnum,
+ langCplusplus, and langCplusplusV2.
+
+Thu Apr 2 19:47:43 1992 John Gilmore (gnu at cygnus.com)
+
+ * sym.h, symconst.h: MIPS has provided redistributable versions
+ of these files. Thanks!
+ * ecoff-ext.h: Add weakext bit to match new sym.h.
+
+Fri Mar 6 00:10:46 1992 John Gilmore (gnu at cygnus.com)
+
+ * ecoff-ext.h: Add relative file descriptors.
+
+Thu Feb 27 11:53:04 1992 John Gilmore (gnu at cygnus.com)
+
+ * ecoff-ext.h: New file for external (in-file) form of ecoff
+ symbol structures.
+
+Thu Feb 6 11:33:32 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * h8300.h: made the external_lineno l_lnno field 4 bytes wide.
+ andded GET/PUT_LINENO_LNNO macros
+
+Sat Nov 30 20:38:35 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * ChangeLog, a29k.h, h8300.h, i386.h, i960.h, internal.h, m68k.h,
+ m88k.h, mips.h, rs6000.h: move from above coff-<foo>.h
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/include/coff/a29k.h b/include/coff/a29k.h
new file mode 100644
index 00000000000..8c3a646ca23
--- /dev/null
+++ b/include/coff/a29k.h
@@ -0,0 +1,305 @@
+/* COFF spec for AMD 290*0
+ Contributed by David Wood @ New York University.
+ */
+
+#ifndef AMD
+# define AMD
+#endif
+
+/****************************************************************/
+
+/*
+** File Header and related definitions
+*/
+
+struct external_filehdr
+{
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+/*
+** Magic numbers for Am29000
+** (AT&T will assign the "real" magic number)
+*/
+
+#define SIPFBOMAGIC 0572 /* Am29000 (Byte 0 is MSB) */
+#define SIPRBOMAGIC 0573 /* Am29000 (Byte 0 is LSB) */
+
+
+#define A29K_MAGIC_BIG SIPFBOMAGIC
+#define A29K_MAGIC_LITTLE SIPRBOMAGIC
+#define A29KBADMAG(x) (((x).f_magic!=A29K_MAGIC_BIG) && \
+ ((x).f_magic!=A29K_MAGIC_LITTLE))
+
+#define OMAGIC A29K_MAGIC_BIG
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+/*
+** File header flags currently known to us.
+**
+** Am29000 will use the F_AR32WR and F_AR32W flags to indicate
+** the byte ordering in the file.
+*/
+
+/*--------------------------------------------------------------*/
+
+/*
+** Optional (a.out) header
+*/
+
+typedef struct external_aouthdr
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+} AOUTHDR;
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+/* aouthdr magic numbers */
+#define NMAGIC 0410 /* separate i/d executable */
+#define SHMAGIC 0406 /* NYU/Ultra3 shared data executable
+ (writable text) */
+
+#define _ETEXT "_etext"
+
+/*--------------------------------------------------------------*/
+
+/*
+** Section header and related definitions
+*/
+
+struct external_scnhdr
+{
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _LIT ".lit"
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+/*
+** Section types - with additional section type for global
+** registers which will be relocatable for the Am29000.
+**
+** In instances where it is necessary for a linker to produce an
+** output file which contains text or data not based at virtual
+** address 0, e.g. for a ROM, then the linker should accept
+** address base information as command input and use PAD sections
+** to skip over unused addresses.
+*/
+
+#define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */
+#define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */
+#define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */
+
+/*--------------------------------------------------------------*/
+
+/*
+** Relocation information declaration and related definitions
+*/
+
+struct external_reloc {
+ char r_vaddr[4]; /* (virtual) address of reference */
+ char r_symndx[4]; /* index into symbol table */
+ char r_type[2]; /* relocation type */
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 10 /* sizeof (RELOC) */
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+/*
+** Relocation types for the Am29000
+*/
+
+#define R_ABS 0 /* reference is absolute */
+
+#define R_IREL 030 /* instruction relative (jmp/call) */
+#define R_IABS 031 /* instruction absolute (jmp/call) */
+#define R_ILOHALF 032 /* instruction low half (const) */
+#define R_IHIHALF 033 /* instruction high half (consth) part 1 */
+#define R_IHCONST 034 /* instruction high half (consth) part 2 */
+ /* constant offset of R_IHIHALF relocation */
+#define R_BYTE 035 /* relocatable byte value */
+#define R_HWORD 036 /* relocatable halfword value */
+#define R_WORD 037 /* relocatable word value */
+
+#define R_IGLBLRC 040 /* instruction global register RC */
+#define R_IGLBLRA 041 /* instruction global register RA */
+#define R_IGLBLRB 042 /* instruction global register RB */
+
+/*
+NOTE:
+All the "I" forms refer to 29000 instruction formats. The linker is
+expected to know how the numeric information is split and/or aligned
+within the instruction word(s). R_BYTE works for instructions, too.
+
+If the parameter to a CONSTH instruction is a relocatable type, two
+relocation records are written. The first has an r_type of R_IHIHALF
+(33 octal) and a normal r_vaddr and r_symndx. The second relocation
+record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which
+is redundant), and an r_symndx containing the 32-bit constant offset
+to the relocation instead of the actual symbol table index. This
+second record is always written, even if the constant offset is zero.
+The constant fields of the instruction are set to zero.
+*/
+
+/*--------------------------------------------------------------*/
+
+/*
+** Line number entry declaration and related definitions
+*/
+
+struct external_lineno
+{
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+#define LINENO struct external_lineno
+#define LINESZ 6 /* sizeof (LINENO) */
+
+/*--------------------------------------------------------------*/
+
+/*
+** Symbol entry declaration and related definitions
+*/
+
+#define E_SYMNMLEN 8 /* Number of characters in a symbol name */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+/*
+** Storage class definitions - new classes for global registers.
+*/
+
+#define C_GLBLREG 19 /* global register */
+#define C_EXTREG 20 /* external global register */
+#define C_DEFREG 21 /* ext. def. of global register */
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+/*
+** Derived symbol mask/shifts.
+*/
+
+#define N_BTMASK (0xf)
+#define N_BTSHFT (4)
+#define N_TMASK (0x30)
+#define N_TSHIFT (2)
+
+/*--------------------------------------------------------------*/
+
+/*
+** Auxiliary symbol table entry declaration and related
+** definitions.
+*/
+
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+};
+
+#define AUXENT union external_auxent
+#define AUXESZ 18
diff --git a/include/coff/alpha.h b/include/coff/alpha.h
new file mode 100644
index 00000000000..076cbcbd980
--- /dev/null
+++ b/include/coff/alpha.h
@@ -0,0 +1,362 @@
+/* ECOFF support on Alpha machines.
+ coff/ecoff.h must be included before this file. */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ unsigned char f_magic[2]; /* magic number */
+ unsigned char f_nscns[2]; /* number of sections */
+ unsigned char f_timdat[4]; /* time & date stamp */
+ unsigned char f_symptr[8]; /* file pointer to symtab */
+ unsigned char f_nsyms[4]; /* number of symtab entries */
+ unsigned char f_opthdr[2]; /* sizeof(optional hdr) */
+ unsigned char f_flags[2]; /* flags */
+};
+
+/* Magic numbers are defined in coff/ecoff.h. */
+#define ALPHA_ECOFF_BADMAG(x) \
+ ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD)
+
+/* The object type is encoded in the f_flags. */
+#define F_ALPHA_OBJECT_TYPE_MASK 0x3000
+#define F_ALPHA_NO_SHARED 0x1000
+#define F_ALPHA_SHARABLE 0x2000
+#define F_ALPHA_CALL_SHARED 0x3000
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 24
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct external_aouthdr
+{
+ unsigned char magic[2]; /* type of file */
+ unsigned char vstamp[2]; /* version stamp */
+ unsigned char bldrev[2]; /* ?? */
+ unsigned char padding[2]; /* pad to quadword boundary */
+ unsigned char tsize[8]; /* text size in bytes */
+ unsigned char dsize[8]; /* initialized data " " */
+ unsigned char bsize[8]; /* uninitialized data " " */
+ unsigned char entry[8]; /* entry pt. */
+ unsigned char text_start[8]; /* base of text used for this file */
+ unsigned char data_start[8]; /* base of data used for this file */
+ unsigned char bss_start[8]; /* base of bss used for this file */
+ unsigned char gprmask[4]; /* bitmask of general registers used */
+ unsigned char fprmask[4]; /* bitmask of floating point registers used */
+ unsigned char gp_value[8]; /* value for gp register */
+} AOUTHDR;
+
+/* compute size of a header */
+
+#define AOUTSZ 80
+#define AOUTHDRSZ 80
+
+/********************** SECTION HEADER **********************/
+
+struct external_scnhdr {
+ unsigned char s_name[8]; /* section name */
+ unsigned char s_paddr[8]; /* physical address, aliased s_nlib */
+ unsigned char s_vaddr[8]; /* virtual address */
+ unsigned char s_size[8]; /* section size */
+ unsigned char s_scnptr[8]; /* file ptr to raw data for section */
+ unsigned char s_relptr[8]; /* file ptr to relocation */
+ unsigned char s_lnnoptr[8]; /* file ptr to line numbers */
+ unsigned char s_nreloc[2]; /* number of relocation entries */
+ unsigned char s_nlnno[2]; /* number of line number entries*/
+ unsigned char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 64
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct external_reloc {
+ unsigned char r_vaddr[8];
+ unsigned char r_symndx[4];
+ unsigned char r_bits[4];
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
+/* Constants to unpack the r_bits field. The Alpha seems to always be
+ little endian, so I haven't bothered to define big endian variants
+ of these. */
+
+#define RELOC_BITS0_TYPE_LITTLE 0xff
+#define RELOC_BITS0_TYPE_SH_LITTLE 0
+
+#define RELOC_BITS1_EXTERN_LITTLE 0x01
+
+#define RELOC_BITS1_OFFSET_LITTLE 0x7e
+#define RELOC_BITS1_OFFSET_SH_LITTLE 1
+
+#define RELOC_BITS1_RESERVED_LITTLE 0x80
+#define RELOC_BITS1_RESERVED_SH_LITTLE 7
+#define RELOC_BITS2_RESERVED_LITTLE 0xff
+#define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE 1
+#define RELOC_BITS3_RESERVED_LITTLE 0x03
+#define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE 9
+
+#define RELOC_BITS3_SIZE_LITTLE 0xfc
+#define RELOC_BITS3_SIZE_SH_LITTLE 2
+
+/* The r_type field in a reloc is one of the following values. */
+#define ALPHA_R_IGNORE 0
+#define ALPHA_R_REFLONG 1
+#define ALPHA_R_REFQUAD 2
+#define ALPHA_R_GPREL32 3
+#define ALPHA_R_LITERAL 4
+#define ALPHA_R_LITUSE 5
+#define ALPHA_R_GPDISP 6
+#define ALPHA_R_BRADDR 7
+#define ALPHA_R_HINT 8
+#define ALPHA_R_SREL16 9
+#define ALPHA_R_SREL32 10
+#define ALPHA_R_SREL64 11
+#define ALPHA_R_OP_PUSH 12
+#define ALPHA_R_OP_STORE 13
+#define ALPHA_R_OP_PSUB 14
+#define ALPHA_R_OP_PRSHIFT 15
+#define ALPHA_R_GPVALUE 16
+#define ALPHA_R_GPRELHIGH 17
+#define ALPHA_R_GPRELLOW 18
+#define ALPHA_R_IMMED 19
+
+/* Overloaded reloc value used by Net- and OpenBSD. */
+#define ALPHA_R_LITERALSLEAZY 17
+
+/* With ALPHA_R_LITUSE, the r_size field is one of the following values. */
+#define ALPHA_R_LU_BASE 1
+#define ALPHA_R_LU_BYTOFF 2
+#define ALPHA_R_LU_JSR 3
+
+/* With ALPHA_R_IMMED, the r_size field is one of the following values. */
+#define ALPHA_R_IMMED_GP_16 1
+#define ALPHA_R_IMMED_GP_HI32 2
+#define ALPHA_R_IMMED_SCN_HI32 3
+#define ALPHA_R_IMMED_BR_HI32 4
+#define ALPHA_R_IMMED_LO32 5
+
+/********************** SYMBOLIC INFORMATION **********************/
+
+/* Written by John Gilmore. */
+
+/* ECOFF uses COFF-like section structures, but its own symbol format.
+ This file defines the symbol format in fields whose size and alignment
+ will not vary on different host systems. */
+
+/* File header as a set of bytes */
+
+struct hdr_ext {
+ unsigned char h_magic[2];
+ unsigned char h_vstamp[2];
+ unsigned char h_ilineMax[4];
+ unsigned char h_idnMax[4];
+ unsigned char h_ipdMax[4];
+ unsigned char h_isymMax[4];
+ unsigned char h_ioptMax[4];
+ unsigned char h_iauxMax[4];
+ unsigned char h_issMax[4];
+ unsigned char h_issExtMax[4];
+ unsigned char h_ifdMax[4];
+ unsigned char h_crfd[4];
+ unsigned char h_iextMax[4];
+ unsigned char h_cbLine[8];
+ unsigned char h_cbLineOffset[8];
+ unsigned char h_cbDnOffset[8];
+ unsigned char h_cbPdOffset[8];
+ unsigned char h_cbSymOffset[8];
+ unsigned char h_cbOptOffset[8];
+ unsigned char h_cbAuxOffset[8];
+ unsigned char h_cbSsOffset[8];
+ unsigned char h_cbSsExtOffset[8];
+ unsigned char h_cbFdOffset[8];
+ unsigned char h_cbRfdOffset[8];
+ unsigned char h_cbExtOffset[8];
+};
+
+/* File descriptor external record */
+
+struct fdr_ext {
+ unsigned char f_adr[8];
+ unsigned char f_cbLineOffset[8];
+ unsigned char f_cbLine[8];
+ unsigned char f_cbSs[8];
+ unsigned char f_rss[4];
+ unsigned char f_issBase[4];
+ unsigned char f_isymBase[4];
+ unsigned char f_csym[4];
+ unsigned char f_ilineBase[4];
+ unsigned char f_cline[4];
+ unsigned char f_ioptBase[4];
+ unsigned char f_copt[4];
+ unsigned char f_ipdFirst[4];
+ unsigned char f_cpd[4];
+ unsigned char f_iauxBase[4];
+ unsigned char f_caux[4];
+ unsigned char f_rfdBase[4];
+ unsigned char f_crfd[4];
+ unsigned char f_bits1[1];
+ unsigned char f_bits2[3];
+ unsigned char f_padding[4];
+};
+
+#define FDR_BITS1_LANG_BIG 0xF8
+#define FDR_BITS1_LANG_SH_BIG 3
+#define FDR_BITS1_LANG_LITTLE 0x1F
+#define FDR_BITS1_LANG_SH_LITTLE 0
+
+#define FDR_BITS1_FMERGE_BIG 0x04
+#define FDR_BITS1_FMERGE_LITTLE 0x20
+
+#define FDR_BITS1_FREADIN_BIG 0x02
+#define FDR_BITS1_FREADIN_LITTLE 0x40
+
+#define FDR_BITS1_FBIGENDIAN_BIG 0x01
+#define FDR_BITS1_FBIGENDIAN_LITTLE 0x80
+
+#define FDR_BITS2_GLEVEL_BIG 0xC0
+#define FDR_BITS2_GLEVEL_SH_BIG 6
+#define FDR_BITS2_GLEVEL_LITTLE 0x03
+#define FDR_BITS2_GLEVEL_SH_LITTLE 0
+
+/* We ignore the `reserved' field in bits2. */
+
+/* Procedure descriptor external record */
+
+struct pdr_ext {
+ unsigned char p_adr[8];
+ unsigned char p_cbLineOffset[8];
+ unsigned char p_isym[4];
+ unsigned char p_iline[4];
+ unsigned char p_regmask[4];
+ unsigned char p_regoffset[4];
+ unsigned char p_iopt[4];
+ unsigned char p_fregmask[4];
+ unsigned char p_fregoffset[4];
+ unsigned char p_frameoffset[4];
+ unsigned char p_lnLow[4];
+ unsigned char p_lnHigh[4];
+ unsigned char p_gp_prologue[1];
+ unsigned char p_bits1[1];
+ unsigned char p_bits2[1];
+ unsigned char p_localoff[1];
+ unsigned char p_framereg[2];
+ unsigned char p_pcreg[2];
+};
+
+#define PDR_BITS1_GP_USED_BIG 0x80
+#define PDR_BITS1_REG_FRAME_BIG 0x40
+#define PDR_BITS1_PROF_BIG 0x20
+#define PDR_BITS1_RESERVED_BIG 0x1f
+#define PDR_BITS1_RESERVED_SH_LEFT_BIG 8
+#define PDR_BITS2_RESERVED_BIG 0xff
+#define PDR_BITS2_RESERVED_SH_BIG 0
+
+#define PDR_BITS1_GP_USED_LITTLE 0x01
+#define PDR_BITS1_REG_FRAME_LITTLE 0x02
+#define PDR_BITS1_PROF_LITTLE 0x04
+#define PDR_BITS1_RESERVED_LITTLE 0xf8
+#define PDR_BITS1_RESERVED_SH_LITTLE 3
+#define PDR_BITS2_RESERVED_LITTLE 0xff
+#define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5
+
+/* Line numbers */
+
+struct line_ext {
+ unsigned char l_line[4];
+};
+
+/* Symbol external record */
+
+struct sym_ext {
+ unsigned char s_value[8];
+ unsigned char s_iss[4];
+ unsigned char s_bits1[1];
+ unsigned char s_bits2[1];
+ unsigned char s_bits3[1];
+ unsigned char s_bits4[1];
+};
+
+#define SYM_BITS1_ST_BIG 0xFC
+#define SYM_BITS1_ST_SH_BIG 2
+#define SYM_BITS1_ST_LITTLE 0x3F
+#define SYM_BITS1_ST_SH_LITTLE 0
+
+#define SYM_BITS1_SC_BIG 0x03
+#define SYM_BITS1_SC_SH_LEFT_BIG 3
+#define SYM_BITS1_SC_LITTLE 0xC0
+#define SYM_BITS1_SC_SH_LITTLE 6
+
+#define SYM_BITS2_SC_BIG 0xE0
+#define SYM_BITS2_SC_SH_BIG 5
+#define SYM_BITS2_SC_LITTLE 0x07
+#define SYM_BITS2_SC_SH_LEFT_LITTLE 2
+
+#define SYM_BITS2_RESERVED_BIG 0x10
+#define SYM_BITS2_RESERVED_LITTLE 0x08
+
+#define SYM_BITS2_INDEX_BIG 0x0F
+#define SYM_BITS2_INDEX_SH_LEFT_BIG 16
+#define SYM_BITS2_INDEX_LITTLE 0xF0
+#define SYM_BITS2_INDEX_SH_LITTLE 4
+
+#define SYM_BITS3_INDEX_SH_LEFT_BIG 8
+#define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4
+
+#define SYM_BITS4_INDEX_SH_LEFT_BIG 0
+#define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12
+
+/* External symbol external record */
+
+struct ext_ext {
+ struct sym_ext es_asym;
+ unsigned char es_bits1[1];
+ unsigned char es_bits2[3];
+ unsigned char es_ifd[4];
+};
+
+#define EXT_BITS1_JMPTBL_BIG 0x80
+#define EXT_BITS1_JMPTBL_LITTLE 0x01
+
+#define EXT_BITS1_COBOL_MAIN_BIG 0x40
+#define EXT_BITS1_COBOL_MAIN_LITTLE 0x02
+
+#define EXT_BITS1_WEAKEXT_BIG 0x20
+#define EXT_BITS1_WEAKEXT_LITTLE 0x04
+
+/* Dense numbers external record */
+
+struct dnr_ext {
+ unsigned char d_rfd[4];
+ unsigned char d_index[4];
+};
+
+/* Relative file descriptor */
+
+struct rfd_ext {
+ unsigned char rfd[4];
+};
+
+/* Optimizer symbol external record */
+
+struct opt_ext {
+ unsigned char o_bits1[1];
+ unsigned char o_bits2[1];
+ unsigned char o_bits3[1];
+ unsigned char o_bits4[1];
+ struct rndx_ext o_rndx;
+ unsigned char o_offset[4];
+};
+
+#define OPT_BITS2_VALUE_SH_LEFT_BIG 16
+#define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0
+
+#define OPT_BITS3_VALUE_SH_LEFT_BIG 8
+#define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8
+
+#define OPT_BITS4_VALUE_SH_LEFT_BIG 0
+#define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16
diff --git a/include/coff/apollo.h b/include/coff/apollo.h
new file mode 100644
index 00000000000..d1347f1f532
--- /dev/null
+++ b/include/coff/apollo.h
@@ -0,0 +1,252 @@
+/*** coff information for Apollo M68K */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+/* Motorola 68000/68008/68010/68020 */
+#define MC68MAGIC 0520
+#define MC68KWRMAGIC 0520 /* writeable text segments */
+#define MC68TVMAGIC 0521
+#define MC68KROMAGIC 0521 /* readonly shareable text segments */
+#define MC68KPGMAGIC 0522 /* demand paged text segments */
+#define M68MAGIC 0210
+#define M68TVMAGIC 0211
+
+/* Apollo 68000-based machines have a different magic number. This comes
+ * from /usr/include/apollo/filehdr.h
+ */
+#define APOLLOM68KMAGIC 0627
+
+#define OMAGIC M68MAGIC
+#define M68KBADMAG(x) (((x).f_magic!=MC68MAGIC) && ((x).f_magic!=MC68KWRMAGIC) && ((x).f_magic!=MC68TVMAGIC) && \
+ ((x).f_magic!=MC68KROMAGIC) && ((x).f_magic!=MC68KPGMAGIC) && ((x).f_magic!=M68MAGIC) && ((x).f_magic!=M68TVMAGIC) && \
+ ((x).f_magic!=APOLLOM68KMAGIC) )
+
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+ char o_sri[4]; /* Apollo specific - .sri data pointer */
+ char o_inlib[4]; /* Apollo specific - .inlib data pointer */
+ char vid[8]; /* Apollo specific - 64 bit version ID */
+}
+AOUTHDR;
+
+#define APOLLO_COFF_VERSION_NUMBER 1 /* the value of the aouthdr magic */
+#define AOUTHDRSZ 44
+#define AOUTSZ 44
+
+
+
+/********************** SECTION HEADER **********************/
+
+struct external_scnhdr {
+ /* Apollo allow for larger section names by allowing it to be in
+ * the string table.
+ */
+ char s_name[8];
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/* If s_zeores is all zeroes, s_offset gives the real location of the name
+ * in the string table.
+ */
+
+#define s_zeroes section_name.s_name
+#define s_offset (section_name.s_name+4)
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _TV ".tv"
+#define _INIT ".init"
+#define _FINI ".fini"
+#define _LINES ".lines"
+#define _BLOCKS ".blocks"
+#define _SRI ".sri" /* Static Resource Information (systype,
+ et al.) */
+#define _MIR ".mir" /* Module Information Records */
+#define _APTV ".aptv" /* Apollo-style transfer vectors. */
+#define _INLIB ".inlib" /* Shared Library information */
+#define _RWDI ".rwdi" /* Read/write data initialization directives for
+ compressed sections */
+#define _UNWIND ".unwind" /* Stack unwind information */
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+#ifdef M68K_COFF_OFFSET
+ char r_offset[4];
+#endif
+
+};
+
+
+#define RELOC struct external_reloc
+
+#ifdef M68K_COFF_OFFSET
+#define RELSZ 14
+#else
+#define RELSZ 10
+#endif
+
+/* Apollo specific STYP flags */
+
+#define STYP_RELOCATED_NOT_LOADED 0x00010000 /* Section is relocated normally during linking, but need
+ not be loaded during program execution */
+#define STYP_DEBUG 0x00020000 /* debug section */
+#define STYP_OVERLAY 0x00040000 /* Section is overlayed */
+#define STYP_INSTRUCTION 0x00200000 /* Section contains executable code */
+
+#define STYP_ZERO 0x00800000 /* Section is initialized to zero */
+#define STYP_INSTALLED 0x02000000 /* Section should be installable in KGT */
+#define STYP_LOOK_INSTALLED 0x04000000 /* Look for section in KGT */
+#define STYP_SECALIGN1 0x08000000 /* Specially aligned section */
+#define STYP_SECALIGN2 0x10000000 /* " " " */
+#define STYP_COMPRESSED 0x20000000 /* No section data per se (s_scnptr = 0), but there are
+ initialization directives for it in .rwdi section
+ (used in conjunction with STYP_BSS) */
diff --git a/include/coff/arm.h b/include/coff/arm.h
new file mode 100644
index 00000000000..dd578b1a76a
--- /dev/null
+++ b/include/coff/arm.h
@@ -0,0 +1,258 @@
+/*** coff information for the ARM */
+
+#define COFFARM 1
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+/* Bits for f_flags:
+ * F_RELFLG relocation info stripped from file
+ * F_EXEC file is executable (no unresolved external references)
+ * F_LNNO line numbers stripped from file
+ * F_LSYMS local symbols stripped from file
+ * F_INTERWORK file supports switching between ARM and Thumb instruction sets
+ * F_INTERWORK_SET the F_INTERWORK bit is valid
+ * F_APCS_FLOAT code passes float arguments in float registers
+ * F_PIC code is reentrant/position-independent
+ * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
+ * F_APCS_26 file uses 26 bit ARM Procedure Calling Standard
+ * F_APCS_SET the F_APCS_26, F_APCS_FLOAT and F_PIC bits have been initialised
+ */
+
+#define F_RELFLG (0x0001)
+#define F_EXEC (0x0002)
+#define F_LNNO (0x0004)
+#define F_LSYMS (0x0008)
+#define F_INTERWORK (0x0010)
+#define F_INTERWORK_SET (0x0020)
+#define F_APCS_FLOAT (0x0040)
+#undef F_AR16WR
+#define F_PIC (0x0080)
+#define F_AR32WR (0x0100)
+#define F_APCS_26 (0x0400)
+#define F_APCS_SET (0x0800)
+
+/* Bits stored in flags field of the internal_f structure */
+
+#define F_INTERWORK (0x0010)
+#define F_PIC_INT (0x0020)
+#define F_APCS_FLOAT (0x0040)
+#define F_ARM_ARCHITECTURE_MASK (0x0c00)
+#define F_ARM_2 (0x0000)
+#define F_ARM_2a (0x0000)
+#define F_ARM_3 (0x0400)
+#define F_ARM_3M (0x0400)
+#define F_ARM_4 (0x0800)
+#define F_ARM_4T (0x0c00)
+#define F_APCS26 (0x4000)
+
+/*
+ * ARMMAGIC ought to encoded the procesor type,
+ * but it is too late to change it now, instead
+ * the flags field of the internal_f structure
+ * is used as shown above.
+ *
+ * XXX - NC 5/6/97
+ */
+
+#define ARMMAGIC 0xa00 /* I just made this up */
+
+#define ARMBADMAG(x) (((x).f_magic != ARMMAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+
+
+}
+AOUTHDR;
+
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+#define OMAGIC 0404 /* object files, eg as output */
+#define ZMAGIC 0413 /* demand load format, eg normal ld output */
+#define STMAGIC 0401 /* target shlib */
+#define SHMAGIC 0443 /* host shlib */
+
+
+/* define some NT default values */
+/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */
+#define NT_SECTION_ALIGNMENT 0x1000
+#define NT_FILE_ALIGNMENT 0x200
+#define NT_DEF_RESERVE 0x100000
+#define NT_DEF_COMMIT 0x1000
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _COMMENT ".comment"
+#define _LIB ".lib"
+
+/* We use the .rdata section to hold read only data. */
+#define _LIT ".rdata"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+#define N_BTMASK (0xf)
+#define N_TMASK (0x30)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ char x_checksum[4]; /* section COMDAT checksum */
+ char x_associated[2]; /* COMDAT associated section index */
+ char x_comdat[1]; /* COMDAT selection number */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+# define _ETEXT "etext"
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+ char r_offset[4];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 14
diff --git a/include/coff/aux-coff.h b/include/coff/aux-coff.h
new file mode 100644
index 00000000000..c89c124d3e0
--- /dev/null
+++ b/include/coff/aux-coff.h
@@ -0,0 +1,31 @@
+/* Modifications of internal.h and m68k.h needed by A/UX
+ Suggested by Ian Lance Taylor <ian@cygnus.com> */
+
+#ifndef GNU_COFF_AUX_H
+#define GNU_COFF_AUX_H 1
+
+#include "coff/internal.h"
+#include "coff/m68k.h"
+
+/* Section contains 64-byte padded pathnames of shared libraries */
+#undef STYP_LIB
+#define STYP_LIB 0x200
+
+/* Section contains shared library initialization code */
+#undef STYP_INIT
+#define STYP_INIT 0x400
+
+/* Section contains .ident information */
+#undef STYP_IDENT
+#define STYP_IDENT 0x800
+
+/* Section types used by bfd and gas not defined (directly) by A/UX */
+#undef STYP_OVER
+#define STYP_OVER 0
+#undef STYP_INFO
+#define STYP_INFO STYP_IDENT
+
+/* Traditional name of the section tagged with STYP_LIB */
+#define _LIB ".lib"
+
+#endif /* GNU_COFF_AUX_H */
diff --git a/include/coff/ecoff.h b/include/coff/ecoff.h
new file mode 100644
index 00000000000..9e4202e4757
--- /dev/null
+++ b/include/coff/ecoff.h
@@ -0,0 +1,421 @@
+#ifndef ECOFF_H
+#define ECOFF_H
+
+/* Generic ECOFF support.
+ This does not include symbol information, found in sym.h and
+ symconst.h. */
+
+/* Mips magic numbers used in filehdr. MIPS_MAGIC_LITTLE is used on
+ little endian machines. MIPS_MAGIC_BIG is used on big endian
+ machines. Where is MIPS_MAGIC_1 from? */
+#define MIPS_MAGIC_1 0x0180
+#define MIPS_MAGIC_LITTLE 0x0162
+#define MIPS_MAGIC_BIG 0x0160
+
+/* These are the magic numbers used for MIPS code compiled at ISA
+ level 2. */
+#define MIPS_MAGIC_LITTLE2 0x0166
+#define MIPS_MAGIC_BIG2 0x0163
+
+/* These are the magic numbers used for MIPS code compiled at ISA
+ level 3. */
+#define MIPS_MAGIC_LITTLE3 0x142
+#define MIPS_MAGIC_BIG3 0x140
+
+/* Alpha magic numbers used in filehdr. */
+#define ALPHA_MAGIC 0x183
+#define ALPHA_MAGIC_BSD 0x185
+
+/* Magic numbers used in a.out header. */
+#define ECOFF_AOUT_OMAGIC 0407 /* not demand paged (ld -N). */
+#define ECOFF_AOUT_ZMAGIC 0413 /* demand load format, eg normal ld output */
+
+/* Names of special sections. */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _RDATA ".rdata"
+#define _SDATA ".sdata"
+#define _SBSS ".sbss"
+#define _LITA ".lita"
+#define _LIT4 ".lit4"
+#define _LIT8 ".lit8"
+#define _LIB ".lib"
+#define _INIT ".init"
+#define _FINI ".fini"
+#define _PDATA ".pdata"
+#define _XDATA ".xdata"
+#define _GOT ".got"
+#define _HASH ".hash"
+#define _DYNSYM ".dynsym"
+#define _DYNSTR ".dynstr"
+#define _RELDYN ".rel.dyn"
+#define _CONFLIC ".conflic"
+#define _COMMENT ".comment"
+#define _LIBLIST ".liblist"
+#define _DYNAMIC ".dynamic"
+#define _RCONST ".rconst"
+
+/* ECOFF uses some additional section flags. */
+#define STYP_RDATA 0x100
+#define STYP_SDATA 0x200
+#define STYP_SBSS 0x400
+#define STYP_GOT 0x1000
+#define STYP_DYNAMIC 0x2000
+#define STYP_DYNSYM 0x4000
+#define STYP_RELDYN 0x8000
+#define STYP_DYNSTR 0x10000
+#define STYP_HASH 0x20000
+#define STYP_LIBLIST 0x40000
+#define STYP_CONFLIC 0x100000
+#define STYP_ECOFF_FINI 0x1000000
+#define STYP_EXTENDESC 0x2000000 /* 0x02FFF000 bits => scn type, rest clr */
+#define STYP_LITA 0x4000000
+#define STYP_LIT8 0x8000000
+#define STYP_LIT4 0x10000000
+#define STYP_ECOFF_LIB 0x40000000
+#define STYP_ECOFF_INIT 0x80000000
+#define STYP_OTHER_LOAD (STYP_ECOFF_INIT | STYP_ECOFF_FINI)
+
+/* extended section types */
+#define STYP_COMMENT 0x2100000
+#define STYP_RCONST 0x2200000
+#define STYP_XDATA 0x2400000
+#define STYP_PDATA 0x2800000
+
+/* The linker needs a section to hold small common variables while
+ linking. There is no convenient way to create it when the linker
+ needs it, so we always create one for each BFD. We then avoid
+ writing it out. */
+#define SCOMMON ".scommon"
+
+/* If the extern bit in a reloc is 1, then r_symndx is an index into
+ the external symbol table. If the extern bit is 0, then r_symndx
+ indicates a section, and is one of the following values. */
+#define RELOC_SECTION_NONE 0
+#define RELOC_SECTION_TEXT 1
+#define RELOC_SECTION_RDATA 2
+#define RELOC_SECTION_DATA 3
+#define RELOC_SECTION_SDATA 4
+#define RELOC_SECTION_SBSS 5
+#define RELOC_SECTION_BSS 6
+#define RELOC_SECTION_INIT 7
+#define RELOC_SECTION_LIT8 8
+#define RELOC_SECTION_LIT4 9
+#define RELOC_SECTION_XDATA 10
+#define RELOC_SECTION_PDATA 11
+#define RELOC_SECTION_FINI 12
+#define RELOC_SECTION_LITA 13
+#define RELOC_SECTION_ABS 14
+#define RELOC_SECTION_RCONST 15
+
+#define NUM_RELOC_SECTIONS 16
+
+/********************** STABS **********************/
+
+/* gcc uses mips-tfile to output type information in special stabs
+ entries. These must match the corresponding definition in
+ gcc/config/mips.h. At some point, these should probably go into a
+ shared include file, but currently gcc and gdb do not share any
+ directories. */
+#define CODE_MASK 0x8F300
+#define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
+#define ECOFF_MARK_STAB(code) ((code)+CODE_MASK)
+#define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK)
+#define STABS_SYMBOL "@stabs"
+
+/********************** COFF **********************/
+
+/* gcc also uses mips-tfile to output COFF debugging information.
+ These are the values it uses when outputting the .type directive.
+ These should also be in a shared include file. */
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+/********************** AUX **********************/
+
+/* The auxiliary type information is the same on all known ECOFF
+ targets. I can't see any reason that it would ever change, so I am
+ going to gamble and define the external structures here, in the
+ target independent ECOFF header file. The internal forms are
+ defined in coff/sym.h, which was originally donated by MIPS
+ Computer Systems. */
+
+/* Type information external record */
+
+struct tir_ext {
+ unsigned char t_bits1[1];
+ unsigned char t_tq45[1];
+ unsigned char t_tq01[1];
+ unsigned char t_tq23[1];
+};
+
+#define TIR_BITS1_FBITFIELD_BIG ((unsigned int) 0x80)
+#define TIR_BITS1_FBITFIELD_LITTLE ((unsigned int) 0x01)
+
+#define TIR_BITS1_CONTINUED_BIG ((unsigned int) 0x40)
+#define TIR_BITS1_CONTINUED_LITTLE ((unsigned int) 0x02)
+
+#define TIR_BITS1_BT_BIG ((unsigned int) 0x3F)
+#define TIR_BITS1_BT_SH_BIG 0
+#define TIR_BITS1_BT_LITTLE ((unsigned int) 0xFC)
+#define TIR_BITS1_BT_SH_LITTLE 2
+
+#define TIR_BITS_TQ4_BIG ((unsigned int) 0xF0)
+#define TIR_BITS_TQ4_SH_BIG 4
+#define TIR_BITS_TQ5_BIG ((unsigned int) 0x0F)
+#define TIR_BITS_TQ5_SH_BIG 0
+#define TIR_BITS_TQ4_LITTLE ((unsigned int) 0x0F)
+#define TIR_BITS_TQ4_SH_LITTLE 0
+#define TIR_BITS_TQ5_LITTLE ((unsigned int) 0xF0)
+#define TIR_BITS_TQ5_SH_LITTLE 4
+
+#define TIR_BITS_TQ0_BIG ((unsigned int) 0xF0)
+#define TIR_BITS_TQ0_SH_BIG 4
+#define TIR_BITS_TQ1_BIG ((unsigned int) 0x0F)
+#define TIR_BITS_TQ1_SH_BIG 0
+#define TIR_BITS_TQ0_LITTLE ((unsigned int) 0x0F)
+#define TIR_BITS_TQ0_SH_LITTLE 0
+#define TIR_BITS_TQ1_LITTLE ((unsigned int) 0xF0)
+#define TIR_BITS_TQ1_SH_LITTLE 4
+
+#define TIR_BITS_TQ2_BIG ((unsigned int) 0xF0)
+#define TIR_BITS_TQ2_SH_BIG 4
+#define TIR_BITS_TQ3_BIG ((unsigned int) 0x0F)
+#define TIR_BITS_TQ3_SH_BIG 0
+#define TIR_BITS_TQ2_LITTLE ((unsigned int) 0x0F)
+#define TIR_BITS_TQ2_SH_LITTLE 0
+#define TIR_BITS_TQ3_LITTLE ((unsigned int) 0xF0)
+#define TIR_BITS_TQ3_SH_LITTLE 4
+
+/* Relative symbol external record */
+
+struct rndx_ext {
+ unsigned char r_bits[4];
+};
+
+#define RNDX_BITS0_RFD_SH_LEFT_BIG 4
+#define RNDX_BITS1_RFD_BIG ((unsigned int) 0xF0)
+#define RNDX_BITS1_RFD_SH_BIG 4
+
+#define RNDX_BITS0_RFD_SH_LEFT_LITTLE 0
+#define RNDX_BITS1_RFD_LITTLE ((unsigned int) 0x0F)
+#define RNDX_BITS1_RFD_SH_LEFT_LITTLE 8
+
+#define RNDX_BITS1_INDEX_BIG ((unsigned int) 0x0F)
+#define RNDX_BITS1_INDEX_SH_LEFT_BIG 16
+#define RNDX_BITS2_INDEX_SH_LEFT_BIG 8
+#define RNDX_BITS3_INDEX_SH_LEFT_BIG 0
+
+#define RNDX_BITS1_INDEX_LITTLE ((unsigned int) 0xF0)
+#define RNDX_BITS1_INDEX_SH_LITTLE 4
+#define RNDX_BITS2_INDEX_SH_LEFT_LITTLE 4
+#define RNDX_BITS3_INDEX_SH_LEFT_LITTLE 12
+
+/* Auxiliary symbol information external record */
+
+union aux_ext {
+ struct tir_ext a_ti;
+ struct rndx_ext a_rndx;
+ unsigned char a_dnLow[4];
+ unsigned char a_dnHigh[4];
+ unsigned char a_isym[4];
+ unsigned char a_iss[4];
+ unsigned char a_width[4];
+ unsigned char a_count[4];
+};
+
+#define AUX_GET_ANY(bigend, ax, field) \
+ ((bigend) ? bfd_getb32 ((ax)->field) : bfd_getl32 ((ax)->field))
+
+#define AUX_GET_DNLOW(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnLow)
+#define AUX_GET_DNHIGH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnHigh)
+#define AUX_GET_ISYM(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_isym)
+#define AUX_GET_ISS(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_iss)
+#define AUX_GET_WIDTH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_width)
+#define AUX_GET_COUNT(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_count)
+
+#define AUX_PUT_ANY(bigend, val, ax, field) \
+ ((bigend) \
+ ? (bfd_putb32 ((bfd_vma) (val), (ax)->field), 0) \
+ : (bfd_putl32 ((bfd_vma) (val), (ax)->field), 0))
+
+#define AUX_PUT_DNLOW(bigend, val, ax) \
+ AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
+#define AUX_PUT_DNHIGH(bigend, val, ax) \
+ AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
+#define AUX_PUT_ISYM(bigend, val, ax) \
+ AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
+#define AUX_PUT_ISS(bigend, val, ax) \
+ AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
+#define AUX_PUT_WIDTH(bigend, val, ax) \
+ AUX_PUT_ANY ((bigend), (val), (ax), a_width)
+#define AUX_PUT_COUNT(bigend, val, ax) \
+ AUX_PUT_ANY ((bigend), (val), (ax), a_count)
+
+/********************** SYMBOLS **********************/
+
+/* For efficiency, gdb deals directly with the unswapped symbolic
+ information (that way it only takes the time to swap information
+ that it really needs to read). gdb originally retrieved the
+ information directly from the BFD backend information, but that
+ strategy, besides being sort of ugly, does not work for MIPS ELF,
+ which also uses ECOFF debugging information. This structure holds
+ pointers to the (mostly) unswapped symbolic information. */
+
+struct ecoff_debug_info
+{
+ /* The swapped ECOFF symbolic header. */
+ HDRR symbolic_header;
+
+ /* Pointers to the unswapped symbolic information. Note that the
+ pointers to external structures point to different sorts of
+ information on different ECOFF targets. The ecoff_debug_swap
+ structure provides the sizes of the structures and the functions
+ needed to swap the information in and out. These pointers are
+ all pointers to arrays, not single structures. They will be NULL
+ if there are no instances of the relevant structure. These
+ fields are also used by the assembler to output ECOFF debugging
+ information. */
+ unsigned char *line;
+ PTR external_dnr; /* struct dnr_ext */
+ PTR external_pdr; /* struct pdr_ext */
+ PTR external_sym; /* struct sym_ext */
+ PTR external_opt; /* struct opt_ext */
+ union aux_ext *external_aux;
+ char *ss;
+ char *ssext;
+ PTR external_fdr; /* struct fdr_ext */
+ PTR external_rfd; /* struct rfd_ext */
+ PTR external_ext; /* struct ext_ext */
+
+ /* These fields are used when linking. They may disappear at some
+ point. */
+ char *ssext_end;
+ PTR external_ext_end;
+
+ /* When linking, this field holds a mapping from the input FDR
+ numbers to the output numbers, and is used when writing out the
+ external symbols. It is NULL if no mapping is required. */
+ RFDT *ifdmap;
+
+ /* The swapped FDR information. Currently this is never NULL, but
+ code using this structure should probably double-check in case
+ this changes in the future. This is a pointer to an array, not a
+ single structure. */
+ FDR *fdr;
+
+ /* When relaxing MIPS embedded PIC code, we may need to adjust
+ symbol values when they are output. This is a linked list of
+ structures indicating how values should be adjusted. There is no
+ requirement that the entries be in any order, or that they not
+ overlap. This field is normally NULL, in which case no
+ adjustments need to be made. */
+ struct ecoff_value_adjust *adjust;
+};
+
+/* This structure describes how to adjust symbol values when
+ outputting MIPS embedded PIC code. These adjustments only apply to
+ the internal symbols, as the external symbol values will come from
+ the hash table and have already been adjusted. */
+
+struct ecoff_value_adjust
+{
+ /* Next entry on adjustment list. */
+ struct ecoff_value_adjust *next;
+ /* Starting VMA of adjustment. This is the VMA in the ECOFF file,
+ not the offset from the start of the section. Thus it should
+ indicate a particular section. */
+ bfd_vma start;
+ /* Ending VMA of adjustment. */
+ bfd_vma end;
+ /* Adjustment. This should be added to the value of the symbol, or
+ FDR. This is zero for the last entry in the array. */
+ long adjust;
+};
+
+/* These structures are used by the ECOFF find_nearest_line function. */
+
+struct ecoff_fdrtab_entry
+{
+ /* Base address in .text of this FDR. */
+ bfd_vma base_addr;
+ FDR *fdr;
+};
+
+struct ecoff_find_line
+{
+ /* Allocated memory to hold function and file names. */
+ char *find_buffer;
+
+ /* FDR table, sorted by address: */
+ long fdrtab_len;
+ struct ecoff_fdrtab_entry *fdrtab;
+
+ /* Cache entry for most recently found line information. The sect
+ field is NULL if this cache does not contain valid information. */
+ struct
+ {
+ asection *sect;
+ bfd_vma start;
+ bfd_vma stop;
+ const char *filename;
+ const char *functionname;
+ unsigned int line_num;
+ } cache;
+};
+
+/********************** SWAPPING **********************/
+
+/* The generic ECOFF code needs to be able to swap debugging
+ information in and out in the specific format used by a particular
+ ECOFF implementation. This structure provides the information
+ needed to do this. */
+
+struct ecoff_debug_swap
+{
+ /* Symbol table magic number. */
+ int sym_magic;
+ /* Alignment of debugging information. E.g., 4. */
+ bfd_size_type debug_align;
+ /* Sizes of external symbolic information. */
+ bfd_size_type external_hdr_size;
+ bfd_size_type external_dnr_size;
+ bfd_size_type external_pdr_size;
+ bfd_size_type external_sym_size;
+ bfd_size_type external_opt_size;
+ bfd_size_type external_fdr_size;
+ bfd_size_type external_rfd_size;
+ bfd_size_type external_ext_size;
+ /* Functions to swap in external symbolic data. */
+ void (*swap_hdr_in) PARAMS ((bfd *, PTR, HDRR *));
+ void (*swap_dnr_in) PARAMS ((bfd *, PTR, DNR *));
+ void (*swap_pdr_in) PARAMS ((bfd *, PTR, PDR *));
+ void (*swap_sym_in) PARAMS ((bfd *, PTR, SYMR *));
+ void (*swap_opt_in) PARAMS ((bfd *, PTR, OPTR *));
+ void (*swap_fdr_in) PARAMS ((bfd *, PTR, FDR *));
+ void (*swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *));
+ void (*swap_ext_in) PARAMS ((bfd *, PTR, EXTR *));
+ void (*swap_tir_in) PARAMS ((int, const struct tir_ext *, TIR *));
+ void (*swap_rndx_in) PARAMS ((int, const struct rndx_ext *, RNDXR *));
+ /* Functions to swap out external symbolic data. */
+ void (*swap_hdr_out) PARAMS ((bfd *, const HDRR *, PTR));
+ void (*swap_dnr_out) PARAMS ((bfd *, const DNR *, PTR));
+ void (*swap_pdr_out) PARAMS ((bfd *, const PDR *, PTR));
+ void (*swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR));
+ void (*swap_opt_out) PARAMS ((bfd *, const OPTR *, PTR));
+ void (*swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR));
+ void (*swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR));
+ void (*swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR));
+ void (*swap_tir_out) PARAMS ((int, const TIR *, struct tir_ext *));
+ void (*swap_rndx_out) PARAMS ((int, const RNDXR *, struct rndx_ext *));
+ /* Function to read symbol data and set up pointers in
+ ecoff_debug_info structure. The section argument is used for
+ ELF, not straight ECOFF. */
+ boolean (*read_debug_info) PARAMS ((bfd *, asection *,
+ struct ecoff_debug_info *));
+};
+
+#endif /* ! defined (ECOFF_H) */
diff --git a/include/coff/go32exe.h b/include/coff/go32exe.h
new file mode 100644
index 00000000000..5bd26c13401
--- /dev/null
+++ b/include/coff/go32exe.h
@@ -0,0 +1,20 @@
+/* COFF information for PC running go32. */
+
+#define STUBSIZE 2048
+
+struct external_filehdr_go32_exe {
+ char stub[STUBSIZE]; /* the stub to load the image */
+ /* the standard COFF header */
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+#undef FILHDR
+#define FILHDR struct external_filehdr_go32_exe
+#undef FILHSZ
+#define FILHSZ STUBSIZE+20
diff --git a/include/coff/h8300.h b/include/coff/h8300.h
new file mode 100644
index 00000000000..9b62394f380
--- /dev/null
+++ b/include/coff/h8300.h
@@ -0,0 +1,204 @@
+/*** coff information for Hitachi H8/300 and H8/300-H */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+
+#define H8300MAGIC 0x8300
+#define H8300HMAGIC 0x8301
+#define H8300SMAGIC 0x8302
+
+#define H8300BADMAG(x) (((x).f_magic!=H8300MAGIC))
+#define H8300HBADMAG(x) (((x).f_magic!=H8300HMAGIC))
+#define H8300SBADMAG(x) (((x).f_magic!=H8300SMAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[4]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the h8 don't have room in the instruction for the entire
+ offset - eg the strange jump and high page addressing modes */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_offset[4];
+ char r_type[2];
+ char r_stuff[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
+
+
+
diff --git a/include/coff/h8500.h b/include/coff/h8500.h
new file mode 100644
index 00000000000..0305bf2b76b
--- /dev/null
+++ b/include/coff/h8500.h
@@ -0,0 +1,201 @@
+/*** coff information for Hitachi H8/500 */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+
+#define H8500MAGIC 0x8500
+
+
+#define H8500BADMAG(x) ((0xffff && ((x).f_magic)!=H8500MAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[4]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the h8 don't have room in the instruction for the entire
+ offset - eg the strange jump and high page addressing modes */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_offset[4];
+ char r_type[2];
+ char r_stuff[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
+
+
+
diff --git a/include/coff/i386.h b/include/coff/i386.h
new file mode 100644
index 00000000000..5ebf4a2e023
--- /dev/null
+++ b/include/coff/i386.h
@@ -0,0 +1,228 @@
+/*** coff information for Intel 386/486. */
+
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+/* Bits for f_flags:
+ * F_RELFLG relocation info stripped from file
+ * F_EXEC file is executable (no unresolved external references)
+ * F_LNNO line numbers stripped from file
+ * F_LSYMS local symbols stripped from file
+ * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
+ */
+
+#define F_RELFLG (0x0001)
+#define F_EXEC (0x0002)
+#define F_LNNO (0x0004)
+#define F_LSYMS (0x0008)
+
+
+
+#define I386MAGIC 0x14c
+#define I386PTXMAGIC 0x154
+#define I386AIXMAGIC 0x175
+
+/* This is Lynx's all-platform magic number for executables. */
+
+#define LYNXCOFFMAGIC 0415
+
+#define I386BADMAG(x) (((x).f_magic != I386MAGIC) \
+ && (x).f_magic != I386AIXMAGIC \
+ && (x).f_magic != I386PTXMAGIC \
+ && (x).f_magic != LYNXCOFFMAGIC)
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+
+
+}
+AOUTHDR;
+
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+#define OMAGIC 0404 /* object files, eg as output */
+#define ZMAGIC 0413 /* demand load format, eg normal ld output */
+#define STMAGIC 0401 /* target shlib */
+#define SHMAGIC 0443 /* host shlib */
+
+
+/* define some NT default values */
+/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */
+#define NT_SECTION_ALIGNMENT 0x1000
+#define NT_FILE_ALIGNMENT 0x200
+#define NT_DEF_RESERVE 0x100000
+#define NT_DEF_COMMIT 0x1000
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _COMMENT ".comment"
+#define _LIB ".lib"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+#define N_BTMASK (0xf)
+#define N_TMASK (0x30)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ char x_checksum[4]; /* section COMDAT checksum */
+ char x_associated[2]; /* COMDAT associated section index */
+ char x_comdat[1]; /* COMDAT selection number */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+# define _ETEXT "etext"
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 10
+
diff --git a/include/coff/i860.h b/include/coff/i860.h
new file mode 100644
index 00000000000..73686e92b7d
--- /dev/null
+++ b/include/coff/i860.h
@@ -0,0 +1,205 @@
+/* This file was hacked from i386.h [dolan@ssd.intel.com] */
+
+/*** coff information for Intel 860. */
+
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+/* Bits for f_flags:
+ * F_RELFLG relocation info stripped from file
+ * F_EXEC file is executable (no unresolved external references)
+ * F_LNNO line numbers stripped from file
+ * F_LSYMS local symbols stripped from file
+ * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
+ */
+
+#define F_RELFLG (0x0001)
+#define F_EXEC (0x0002)
+#define F_LNNO (0x0004)
+#define F_LSYMS (0x0008)
+
+
+
+#define I860MAGIC 0x14d
+
+#define I860BADMAG(x) ((x).f_magic != I860MAGIC)
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+/* FIXME: What are the a.out magic numbers? */
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _COMMENT ".comment"
+#define _LIB ".lib"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+#define N_BTMASK (0xf)
+#define N_TMASK (0x30)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+# define _ETEXT "etext"
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 10
diff --git a/include/coff/i960.h b/include/coff/i960.h
new file mode 100644
index 00000000000..0935836c14a
--- /dev/null
+++ b/include/coff/i960.h
@@ -0,0 +1,275 @@
+/*** coff information for 80960. Origins: Intel corp, natch. */
+
+/* NOTE: Tagentries (cf TAGBITS) are no longer used by the 960 */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+#define OMAGIC (0407) /* old impure format. data immediately
+ follows text. both sections are rw. */
+#define NMAGIC (0410) /* split i&d, read-only text */
+
+/*
+* Intel 80960 (I960) processor flags.
+* F_I960TYPE == mask for processor type field.
+*/
+
+#define F_I960TYPE (0xf000)
+#define F_I960CORE (0x1000)
+#define F_I960KB (0x2000)
+#define F_I960SB (0x2000)
+#define F_I960MC (0x3000)
+#define F_I960XA (0x4000)
+#define F_I960CA (0x5000)
+#define F_I960KA (0x6000)
+#define F_I960SA (0x6000)
+#define F_I960JX (0x7000)
+#define F_I960HX (0x8000)
+
+
+/** i80960 Magic Numbers
+*/
+
+#define I960ROMAGIC (0x160) /* read-only text segments */
+#define I960RWMAGIC (0x161) /* read-write text segments */
+
+#define I960BADMAG(x) (((x).f_magic!=I960ROMAGIC) && ((x).f_magic!=I960RWMAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+typedef struct {
+ unsigned long phys_addr;
+ unsigned long bitarray;
+} TAGBITS;
+
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+ char tagentries[4]; /* number of tag entries to follow */
+}
+AOUTHDR;
+
+/* return a pointer to the tag bits array */
+
+#define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1))
+
+/* compute size of a header */
+
+/*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/
+#define AOUTSZ 32
+#define AOUTHDRSZ 32
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+ char s_align[4]; /* section alignment */
+};
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 44
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+ char padding[2]; /* force alignment */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_flags[2];
+ char e_type[4];
+ char e_sclass[1];
+ char e_numaux[1];
+ char pad2[2];
+};
+
+
+
+
+#define N_BTMASK (0x1f)
+#define N_TMASK (0x60)
+#define N_BTSHFT (5)
+#define N_TSHIFT (2)
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+ /******************************************
+ * I960-specific *2nd* aux. entry formats
+ ******************************************/
+ struct {
+ /* This is a very old typo that keeps getting propagated. */
+#define x_stdindx x_stindx
+ char x_stindx[4]; /* sys. table entry */
+ } x_sc; /* system call entry */
+
+ struct {
+ char x_balntry[4]; /* BAL entry point */
+ } x_bal; /* BAL-callable function */
+
+ struct {
+ char x_timestamp[4]; /* time stamp */
+ char x_idstring[20]; /* producer identity string */
+ } x_ident; /* Producer ident info */
+
+};
+
+
+
+#define SYMENT struct external_syment
+#define SYMESZ 24
+#define AUXENT union external_auxent
+#define AUXESZ 24
+
+# define _ETEXT "_etext"
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+ char pad[2];
+};
+
+/* r_type values for the i960. */
+
+/* The i960 uses R_RELLONG, which is defined in internal.h as 0x11.
+ It is an absolute 32 bit relocation. */
+
+#define R_IPRMED (0x19) /* 24-bit ip-relative relocation */
+#define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */
+#define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */
+
+/* The following relocation types are defined use by relaxing linkers,
+ which convert 32 bit calls (which require a 64 bit instruction)
+ into 24 bit calls (which require a 32 bit instruction) when
+ possible. It will be possible whenever the target of the call is
+ within a 24 bit range of the call instruction.
+
+ It is always safe to ignore these relocations. They only serve to
+ mark points which the relaxing linker will have to consider. The
+ assembler must ensure that the correct code is generated even if
+ the relocations are ignored. In particular, this means that the
+ R_IPR13 relocation may not appear with an external symbol. */
+
+#define R_IPR13 (0x1d) /* 13 bit ip-relative branch */
+#define R_ALIGN (0x1e) /* alignment marker. This has no
+ associated symbol. Instead, the
+ r_symndx field indicates the
+ require alignment at this point in
+ the file. It must be a power of 2. */
+
+#define RELOC struct external_reloc
+#define RELSZ 12
+
diff --git a/include/coff/internal.h b/include/coff/internal.h
new file mode 100644
index 00000000000..d5ea9510334
--- /dev/null
+++ b/include/coff/internal.h
@@ -0,0 +1,728 @@
+/* Internal format of COFF object file data structures, for GNU BFD.
+ This file is part of BFD, the Binary File Descriptor library. */
+
+#ifndef GNU_COFF_INTERNAL_H
+#define GNU_COFF_INTERNAL_H 1
+
+/* First, make "signed char" work, even on old compilers. */
+#ifndef signed
+#ifndef __STDC__
+#define signed /**/
+#endif
+#endif
+
+/********************** FILE HEADER **********************/
+
+/* extra stuff in a PE header. */
+
+struct internal_extra_pe_filehdr
+{
+ /* DOS header data follows for PE stuff */
+ unsigned short e_magic; /* Magic number, 0x5a4d */
+ unsigned short e_cblp; /* Bytes on last page of file, 0x90 */
+ unsigned short e_cp; /* Pages in file, 0x3 */
+ unsigned short e_crlc; /* Relocations, 0x0 */
+ unsigned short e_cparhdr; /* Size of header in paragraphs, 0x4 */
+ unsigned short e_minalloc; /* Minimum extra paragraphs needed, 0x0 */
+ unsigned short e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */
+ unsigned short e_ss; /* Initial (relative) SS value, 0x0 */
+ unsigned short e_sp; /* Initial SP value, 0xb8 */
+ unsigned short e_csum; /* Checksum, 0x0 */
+ unsigned short e_ip; /* Initial IP value, 0x0 */
+ unsigned short e_cs; /* Initial (relative) CS value, 0x0 */
+ unsigned short e_lfarlc; /* File address of relocation table, 0x40 */
+ unsigned short e_ovno; /* Overlay number, 0x0 */
+ unsigned short e_res[4]; /* Reserved words, all 0x0 */
+ unsigned short e_oemid; /* OEM identifier (for e_oeminfo), 0x0 */
+ unsigned short e_oeminfo; /* OEM information; e_oemid specific, 0x0 */
+ unsigned short e_res2[10]; /* Reserved words, all 0x0 */
+ bfd_vma e_lfanew; /* File address of new exe header, 0x80 */
+ unsigned long dos_message[16]; /* text which always follows dos header */
+ bfd_vma nt_signature; /* required NT signature, 0x4550 */
+};
+
+struct internal_filehdr
+{
+ struct internal_extra_pe_filehdr pe;
+
+ /* standard coff internal info */
+ unsigned short f_magic; /* magic number */
+ unsigned short f_nscns; /* number of sections */
+ long f_timdat; /* time & date stamp */
+ bfd_vma f_symptr; /* file pointer to symtab */
+ long f_nsyms; /* number of symtab entries */
+ unsigned short f_opthdr; /* sizeof(optional hdr) */
+ unsigned short f_flags; /* flags */
+ unsigned short f_target_id; /* (TIc80 specific) */
+};
+
+
+/* Bits for f_flags:
+ * F_RELFLG relocation info stripped from file
+ * F_EXEC file is executable (no unresolved external references)
+ * F_LNNO line numbers stripped from file
+ * F_LSYMS local symbols stripped from file
+ * F_AR16WR file is 16-bit little-endian
+ * F_AR32WR file is 32-bit little-endian
+ * F_AR32W file is 32-bit big-endian
+ * F_DYNLOAD rs/6000 aix: dynamically loadable w/imports & exports
+ * F_SHROBJ rs/6000 aix: file is a shared object
+ * F_DLL PE format DLL
+ */
+
+#define F_RELFLG (0x0001)
+#define F_EXEC (0x0002)
+#define F_LNNO (0x0004)
+#define F_LSYMS (0x0008)
+#define F_AR16WR (0x0080)
+#define F_AR32WR (0x0100)
+#define F_AR32W (0x0200)
+#define F_DYNLOAD (0x1000)
+#define F_SHROBJ (0x2000)
+#define F_DLL (0x2000)
+
+/* extra structure which is used in the optional header */
+typedef struct _IMAGE_DATA_DIRECTORY
+{
+ bfd_vma VirtualAddress;
+ long Size;
+} IMAGE_DATA_DIRECTORY;
+#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
+
+/* default image base for NT */
+#define NT_EXE_IMAGE_BASE 0x400000
+#define NT_DLL_IMAGE_BASE 0x10000000
+
+/* Extra stuff in a PE aouthdr */
+
+#define PE_DEF_SECTION_ALIGNMENT 0x1000
+#define PE_DEF_FILE_ALIGNMENT 0x200
+
+struct internal_extra_pe_aouthdr
+{
+ /* PE stuff */
+ bfd_vma ImageBase; /* address of specific location in memory that
+ file is located, NT default 0x10000 */
+
+ bfd_vma SectionAlignment; /* section alignment default 0x1000 */
+ bfd_vma FileAlignment; /* file alignment default 0x200 */
+ short MajorOperatingSystemVersion; /* minimum version of the operating */
+ short MinorOperatingSystemVersion; /* system req'd for exe, default to 1*/
+ short MajorImageVersion; /* user defineable field to store version of */
+ short MinorImageVersion; /* exe or dll being created, default to 0 */
+ short MajorSubsystemVersion; /* minimum subsystem version required to */
+ short MinorSubsystemVersion; /* run exe; default to 3.1 */
+ long Reserved1; /* seems to be 0 */
+ long SizeOfImage; /* size of memory to allocate for prog */
+ long SizeOfHeaders; /* size of PE header and section table */
+ long CheckSum; /* set to 0 */
+ short Subsystem;
+
+ /* type of subsystem exe uses for user interface,
+ possible values:
+ 1 - NATIVE Doesn't require a subsystem
+ 2 - WINDOWS_GUI runs in Windows GUI subsystem
+ 3 - WINDOWS_CUI runs in Windows char sub. (console app)
+ 5 - OS2_CUI runs in OS/2 character subsystem
+ 7 - POSIX_CUI runs in Posix character subsystem */
+ short DllCharacteristics; /* flags for DLL init, use 0 */
+ bfd_vma SizeOfStackReserve; /* amount of memory to reserve */
+ bfd_vma SizeOfStackCommit; /* amount of memory initially committed for
+ initial thread's stack, default is 0x1000 */
+ bfd_vma SizeOfHeapReserve; /* amount of virtual memory to reserve and */
+ bfd_vma SizeOfHeapCommit; /* commit, don't know what to defaut it to */
+ long LoaderFlags; /* can probably set to 0 */
+ long NumberOfRvaAndSizes; /* number of entries in next entry, 16 */
+ IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+};
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+struct internal_aouthdr
+{
+ short magic; /* type of file */
+ short vstamp; /* version stamp */
+ bfd_vma tsize; /* text size in bytes, padded to FW bdry*/
+ bfd_vma dsize; /* initialized data " " */
+ bfd_vma bsize; /* uninitialized data " " */
+ bfd_vma entry; /* entry pt. */
+ bfd_vma text_start; /* base of text used for this file */
+ bfd_vma data_start; /* base of data used for this file */
+
+ /* i960 stuff */
+ unsigned long tagentries; /* number of tag entries to follow */
+
+ /* RS/6000 stuff */
+ unsigned long o_toc; /* address of TOC */
+ short o_snentry; /* section number for entry point */
+ short o_sntext; /* section number for text */
+ short o_sndata; /* section number for data */
+ short o_sntoc; /* section number for toc */
+ short o_snloader; /* section number for loader section */
+ short o_snbss; /* section number for bss */
+ short o_algntext; /* max alignment for text */
+ short o_algndata; /* max alignment for data */
+ short o_modtype; /* Module type field, 1R,RE,RO */
+ short o_cputype; /* Encoded CPU type */
+ unsigned long o_maxstack; /* max stack size allowed. */
+ unsigned long o_maxdata; /* max data size allowed. */
+
+ /* ECOFF stuff */
+ bfd_vma bss_start; /* Base of bss section. */
+ bfd_vma gp_value; /* GP register value. */
+ unsigned long gprmask; /* General registers used. */
+ unsigned long cprmask[4]; /* Coprocessor registers used. */
+ unsigned long fprmask; /* Floating pointer registers used. */
+
+ /* Apollo stuff */
+ long o_inlib; /* inlib data */
+ long o_sri; /* Static Resource Information */
+ long vid[2]; /* Version id */
+
+
+ struct internal_extra_pe_aouthdr pe;
+
+};
+
+/********************** STORAGE CLASSES **********************/
+
+/* This used to be defined as -1, but now n_sclass is unsigned. */
+#define C_EFCN 0xff /* physical end of function */
+#define C_NULL 0
+#define C_AUTO 1 /* automatic variable */
+#define C_EXT 2 /* external symbol */
+#define C_STAT 3 /* static */
+#define C_REG 4 /* register variable */
+#define C_EXTDEF 5 /* external definition */
+#define C_LABEL 6 /* label */
+#define C_ULABEL 7 /* undefined label */
+#define C_MOS 8 /* member of structure */
+#define C_ARG 9 /* function argument */
+#define C_STRTAG 10 /* structure tag */
+#define C_MOU 11 /* member of union */
+#define C_UNTAG 12 /* union tag */
+#define C_TPDEF 13 /* type definition */
+#define C_USTATIC 14 /* undefined static */
+#define C_ENTAG 15 /* enumeration tag */
+#define C_MOE 16 /* member of enumeration */
+#define C_REGPARM 17 /* register parameter */
+#define C_FIELD 18 /* bit field */
+#define C_AUTOARG 19 /* auto argument */
+#define C_LASTENT 20 /* dummy entry (end of block) */
+#define C_BLOCK 100 /* ".bb" or ".eb" */
+#define C_FCN 101 /* ".bf" or ".ef" */
+#define C_EOS 102 /* end of structure */
+#define C_FILE 103 /* file name */
+#define C_LINE 104 /* line # reformatted as symbol table entry */
+#define C_ALIAS 105 /* duplicate tag */
+#define C_HIDDEN 106 /* ext symbol in dmert public lib */
+
+#define C_WEAKEXT 127 /* weak symbol -- GNU extension */
+
+/* New storage classes for TIc80 */
+#define C_UEXT 19 /* Tentative external definition */
+#define C_STATLAB 20 /* Static load time label */
+#define C_EXTLAB 21 /* External load time label */
+#define C_SYSTEM 23 /* System Wide variable */
+
+/* New storage classes for WINDOWS_NT */
+#define C_SECTION 104 /* section name */
+#define C_NT_WEAK 105 /* weak external */
+
+ /* New storage classes for 80960 */
+
+/* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */
+#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */
+
+#define C_SCALL 107 /* Procedure reachable via system call */
+#define C_LEAFEXT 108 /* External leaf */
+#define C_LEAFSTAT 113 /* Static leaf */
+#define C_OPTVAR 109 /* Optimized variable */
+#define C_DEFINE 110 /* Preprocessor #define */
+#define C_PRAGMA 111 /* Advice to compiler or linker */
+#define C_SEGMENT 112 /* 80960 segment name */
+
+ /* Storage classes for m88k */
+#define C_SHADOW 107 /* shadow symbol */
+#define C_VERSION 108 /* coff version symbol */
+
+ /* New storage classes for RS/6000 */
+#define C_HIDEXT 107 /* Un-named external symbol */
+#define C_BINCL 108 /* Marks beginning of include file */
+#define C_EINCL 109 /* Marks ending of include file */
+
+ /* storage classes for stab symbols for RS/6000 */
+#define C_GSYM (0x80)
+#define C_LSYM (0x81)
+#define C_PSYM (0x82)
+#define C_RSYM (0x83)
+#define C_RPSYM (0x84)
+#define C_STSYM (0x85)
+#define C_TCSYM (0x86)
+#define C_BCOMM (0x87)
+#define C_ECOML (0x88)
+#define C_ECOMM (0x89)
+#define C_DECL (0x8c)
+#define C_ENTRY (0x8d)
+#define C_FUN (0x8e)
+#define C_BSTAT (0x8f)
+#define C_ESTAT (0x90)
+
+/* Storage classes for Thumb symbols */
+#define C_THUMBEXT (128 + C_EXT) /* 130 */
+#define C_THUMBSTAT (128 + C_STAT) /* 131 */
+#define C_THUMBLABEL (128 + C_LABEL) /* 134 */
+#define C_THUMBEXTFUNC (C_THUMBEXT + 20) /* 150 */
+#define C_THUMBSTATFUNC (C_THUMBSTAT + 20) /* 151 */
+
+/********************** SECTION HEADER **********************/
+
+#define SCNNMLEN (8)
+
+struct internal_scnhdr
+{
+ char s_name[SCNNMLEN]; /* section name */
+
+ /* Physical address, aliased s_nlib.
+ In the pei format, this field is the virtual section size
+ (the size of the section after being loaded int memory),
+ NOT the physical address. */
+ bfd_vma s_paddr;
+
+ bfd_vma s_vaddr; /* virtual address */
+ bfd_vma s_size; /* section size */
+ bfd_vma s_scnptr; /* file ptr to raw data for section */
+ bfd_vma s_relptr; /* file ptr to relocation */
+ bfd_vma s_lnnoptr; /* file ptr to line numbers */
+ unsigned long s_nreloc; /* number of relocation entries */
+ unsigned long s_nlnno; /* number of line number entries*/
+ long s_flags; /* flags */
+ long s_align; /* used on I960 */
+};
+
+/*
+ * s_flags "type"
+ */
+#define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */
+#define STYP_DSECT (0x0001) /* "dummy": relocated only*/
+#define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */
+#define STYP_GROUP (0x0004) /* "grouped": formed of input sections */
+#define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */
+#define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated,
+ loaded; reloc & lineno entries processed normally */
+#define STYP_TEXT (0x0020) /* section contains text only */
+#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
+ will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
+ update all process invocations. */
+#define STYP_DATA (0x0040) /* section contains data only */
+#define STYP_BSS (0x0080) /* section contains bss only */
+#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
+#define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */
+#define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */
+#define STYP_LIB (0x0800) /* for .lib: same as INFO */
+#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
+#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
+
+ word of contiguous bytes
+ beginning on a word boundary. */
+
+#define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */
+
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+
+struct internal_lineno
+{
+ union
+ {
+ long l_symndx; /* function name symbol index, iff l_lnno == 0*/
+ long l_paddr; /* (physical) address of line number */
+ } l_addr;
+ unsigned long l_lnno; /* line number */
+};
+
+/********************** SYMBOLS **********************/
+
+#define SYMNMLEN 8 /* # characters in a symbol name */
+#define FILNMLEN 14 /* # characters in a file name */
+#define DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct internal_syment
+{
+ union
+ {
+ char _n_name[SYMNMLEN]; /* old COFF version */
+ struct
+ {
+ long _n_zeroes; /* new == 0 */
+ long _n_offset; /* offset into string table */
+ } _n_n;
+ char *_n_nptr[2]; /* allows for overlaying */
+ } _n;
+ long n_value; /* value of symbol */
+ short n_scnum; /* section number */
+ unsigned short n_flags; /* copy of flags from filhdr */
+ unsigned short n_type; /* type and derived type */
+ unsigned char n_sclass; /* storage class */
+ unsigned char n_numaux; /* number of aux. entries */
+};
+
+#define n_name _n._n_name
+#define n_zeroes _n._n_n._n_zeroes
+#define n_offset _n._n_n._n_offset
+
+
+/* Relocatable symbols have number of the section in which they are defined,
+ or one of the following: */
+
+#define N_UNDEF ((short)0) /* undefined symbol */
+#define N_ABS ((short)-1) /* value of symbol is absolute */
+#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
+#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
+#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
+
+/*
+ * Type of a symbol, in low N bits of the word
+ */
+#define T_NULL 0
+#define T_VOID 1 /* function argument (only used by compiler) */
+#define T_CHAR 2 /* character */
+#define T_SHORT 3 /* short integer */
+#define T_INT 4 /* integer */
+#define T_LONG 5 /* long integer */
+#define T_FLOAT 6 /* floating point */
+#define T_DOUBLE 7 /* double word */
+#define T_STRUCT 8 /* structure */
+#define T_UNION 9 /* union */
+#define T_ENUM 10 /* enumeration */
+#define T_MOE 11 /* member of enumeration*/
+#define T_UCHAR 12 /* unsigned character */
+#define T_USHORT 13 /* unsigned short */
+#define T_UINT 14 /* unsigned integer */
+#define T_ULONG 15 /* unsigned long */
+#define T_LNGDBL 16 /* long double */
+
+/*
+ * derived types, in n_type
+*/
+#define DT_NON (0) /* no derived type */
+#define DT_PTR (1) /* pointer */
+#define DT_FCN (2) /* function */
+#define DT_ARY (3) /* array */
+
+#define BTYPE(x) ((x) & N_BTMASK)
+
+#define ISPTR(x) \
+ (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_PTR << N_BTSHFT))
+#define ISFCN(x) \
+ (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_FCN << N_BTSHFT))
+#define ISARY(x) \
+ (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_ARY << N_BTSHFT))
+#define ISTAG(x) \
+ ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG)
+#define DECREF(x) \
+ ((((x) >> N_TSHIFT) & ~ N_BTMASK) | ((x) & N_BTMASK))
+
+union internal_auxent
+{
+ struct
+ {
+
+ union
+ {
+ long l; /* str, un, or enum tag indx */
+ struct coff_ptr_struct *p;
+ } x_tagndx;
+
+ union
+ {
+ struct
+ {
+ unsigned short x_lnno; /* declaration line number */
+ unsigned short x_size; /* str/union/array size */
+ } x_lnsz;
+ long x_fsize; /* size of function */
+ } x_misc;
+
+ union
+ {
+ struct
+ { /* if ISFCN, tag, or .bb */
+ long x_lnnoptr; /* ptr to fcn line # */
+ union
+ { /* entry ndx past block end */
+ long l;
+ struct coff_ptr_struct *p;
+ } x_endndx;
+ } x_fcn;
+
+ struct
+ { /* if ISARY, up to 4 dimen. */
+ unsigned short x_dimen[DIMNUM];
+ } x_ary;
+ } x_fcnary;
+
+ unsigned short x_tvndx; /* tv index */
+ } x_sym;
+
+ union
+ {
+ char x_fname[FILNMLEN];
+ struct
+ {
+ long x_zeroes;
+ long x_offset;
+ } x_n;
+ } x_file;
+
+ struct
+ {
+ long x_scnlen; /* section length */
+ unsigned short x_nreloc; /* # relocation entries */
+ unsigned short x_nlinno; /* # line numbers */
+ unsigned long x_checksum; /* section COMDAT checksum for PE */
+ unsigned short x_associated; /* COMDAT associated section index for PE */
+ unsigned char x_comdat; /* COMDAT selection number for PE */
+ } x_scn;
+
+ struct
+ {
+ long x_tvfill; /* tv fill value */
+ unsigned short x_tvlen; /* length of .tv */
+ unsigned short x_tvran[2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+ /******************************************
+ * RS/6000-specific auxent - last auxent for every external symbol
+ ******************************************/
+ struct
+ {
+ union
+ { /* csect length or enclosing csect */
+ long l;
+ struct coff_ptr_struct *p;
+ } x_scnlen;
+ long x_parmhash; /* parm type hash index */
+ unsigned short x_snhash; /* sect num with parm hash */
+ unsigned char x_smtyp; /* symbol align and type */
+ /* 0-4 - Log 2 of alignment */
+ /* 5-7 - symbol type */
+ unsigned char x_smclas; /* storage mapping class */
+ long x_stab; /* dbx stab info index */
+ unsigned short x_snstab; /* sect num with dbx stab */
+ } x_csect; /* csect definition information */
+
+/* x_smtyp values: */
+
+#define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */
+#define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */
+/* Symbol type values: */
+#define XTY_ER 0 /* External reference */
+#define XTY_SD 1 /* Csect definition */
+#define XTY_LD 2 /* Label definition */
+#define XTY_CM 3 /* .BSS */
+#define XTY_EM 4 /* Error message */
+#define XTY_US 5 /* "Reserved for internal use" */
+
+/* x_smclas values: */
+
+#define XMC_PR 0 /* Read-only program code */
+#define XMC_RO 1 /* Read-only constant */
+#define XMC_DB 2 /* Read-only debug dictionary table */
+#define XMC_TC 3 /* Read-write general TOC entry */
+#define XMC_UA 4 /* Read-write unclassified */
+#define XMC_RW 5 /* Read-write data */
+#define XMC_GL 6 /* Read-only global linkage */
+#define XMC_XO 7 /* Read-only extended operation */
+#define XMC_SV 8 /* Read-only supervisor call */
+#define XMC_BS 9 /* Read-write BSS */
+#define XMC_DS 10 /* Read-write descriptor csect */
+#define XMC_UC 11 /* Read-write unnamed Fortran common */
+#define XMC_TI 12 /* Read-only traceback index csect */
+#define XMC_TB 13 /* Read-only traceback table csect */
+/* 14 ??? */
+#define XMC_TC0 15 /* Read-write TOC anchor */
+#define XMC_TD 16 /* Read-write data in TOC */
+
+ /******************************************
+ * I960-specific *2nd* aux. entry formats
+ ******************************************/
+ struct
+ {
+ /* This is a very old typo that keeps getting propagated. */
+#define x_stdindx x_stindx
+ long x_stindx; /* sys. table entry */
+ } x_sc; /* system call entry */
+
+ struct
+ {
+ unsigned long x_balntry; /* BAL entry point */
+ } x_bal; /* BAL-callable function */
+
+ struct
+ {
+ unsigned long x_timestamp; /* time stamp */
+ char x_idstring[20]; /* producer identity string */
+ } x_ident; /* Producer ident info */
+
+};
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct internal_reloc
+{
+ bfd_vma r_vaddr; /* Virtual address of reference */
+ long r_symndx; /* Index into symbol table */
+ unsigned short r_type; /* Relocation type */
+ unsigned char r_size; /* Used by RS/6000 and ECOFF */
+ unsigned char r_extern; /* Used by ECOFF */
+ unsigned long r_offset; /* Used by Alpha ECOFF, SPARC, others */
+};
+
+#define R_RELBYTE 017
+#define R_RELWORD 020
+#define R_PCRBYTE 022
+#define R_PCRWORD 023
+#define R_PCRLONG 024
+
+#define R_DIR16 01
+#define R_DIR32 06
+#define R_PCLONG 020
+#define R_RELBYTE 017
+#define R_RELWORD 020
+#define R_IMAGEBASE 07
+
+
+#define R_PCR16L 128
+#define R_PCR26L 129
+#define R_VRT16 130
+#define R_HVRT16 131
+#define R_LVRT16 132
+#define R_VRT32 133
+#define R_RELLONG (0x11) /* Direct 32-bit relocation */
+#define R_IPRSHORT (0x18)
+#define R_IPRLONG (0x1a)
+#define R_GETSEG (0x1d)
+#define R_GETPA (0x1e)
+#define R_TAGWORD (0x1f)
+#define R_JUMPTARG 0x20 /* strange 29k 00xx00xx reloc */
+
+
+/* This reloc identifies mov.b instructions with a 16bit absolute
+ address. The linker tries to turn insns with this reloc into
+ an absolute 8-bit address. */
+#define R_MOV16B1 0x41
+
+/* This reloc identifies mov.b instructions which had a 16bit
+ absolute address which have been shortened into a 8-bit
+ absolute address. */
+#define R_MOV16B2 0x42
+
+/* This reloc identifies jmp insns with a 16bit target address;
+ the linker tries to turn these insns into bra insns with
+ an 8bit pc-relative target. */
+#define R_JMP1 0x43
+
+/* This reloc identifies a bra with an 8-bit pc-relative
+ target that was formerlly a jmp insn with a 16bit target. */
+#define R_JMP2 0x44
+
+/* ??? */
+#define R_RELLONG_NEG 0x45
+
+/* This reloc identifies jmp insns with a 24bit target address;
+ the linker tries to turn these insns into bra insns with
+ an 8bit pc-relative target. */
+#define R_JMPL1 0x46
+
+/* This reloc identifies a bra with an 8-bit pc-relative
+ target that was formerlly a jmp insn with a 24bit target. */
+#define R_JMPL2 0x47
+
+/* This reloc identifies mov.b instructions with a 24bit absolute
+ address. The linker tries to turn insns with this reloc into
+ an absolute 8-bit address. */
+
+#define R_MOV24B1 0x48
+
+/* This reloc identifies mov.b instructions which had a 24bit
+ absolute address which have been shortened into a 8-bit
+ absolute address. */
+#define R_MOV24B2 0x49
+
+/* An h8300 memory indirect jump/call. Forces the address of the jump/call
+ target into the function vector (in page zero), and the address of the
+ vector entry to be placed in the jump/call instruction. */
+#define R_MEM_INDIRECT 0x4a
+
+/* This reloc identifies a 16bit pc-relative branch target which was
+ shortened into an 8bit pc-relative branch target. */
+#define R_PCRWORD_B 0x4b
+
+/* This reloc identifies mov.[wl] instructions with a 32/24 bit
+ absolute address; the linker may turn this into a mov.[wl]
+ insn with a 16bit absolute address. */
+#define R_MOVL1 0x4c
+
+/* This reloc identifies mov.[wl] insns which formerlly had
+ a 32/24bit absolute address and how have a 16bit absolute address. */
+#define R_MOVL2 0x4d
+
+/* This reloc identifies a bCC:8 which will have it's condition
+ inverted and its target redirected to the target of the branch
+ in the following insn. */
+#define R_BCC_INV 0x4e
+
+/* This reloc identifies a jmp instruction that has been deleted. */
+#define R_JMP_DEL 0x4f
+
+/* Z8k modes */
+#define R_IMM16 0x01 /* 16 bit abs */
+#define R_JR 0x02 /* jr 8 bit disp */
+#define R_IMM4L 0x23 /* low nibble */
+#define R_IMM8 0x22 /* 8 bit abs */
+#define R_IMM32 R_RELLONG /* 32 bit abs */
+#define R_CALL R_DA /* Absolute address which could be a callr */
+#define R_JP R_DA /* Absolute address which could be a jp */
+#define R_REL16 0x04 /* 16 bit PC rel */
+#define R_CALLR 0x05 /* callr 12 bit disp */
+#define R_SEG 0x10 /* set if in segmented mode */
+#define R_IMM4H 0x24 /* high nibble */
+#define R_DISP7 0x25 /* djnz displacement */
+
+/* H8500 modes */
+
+#define R_H8500_IMM8 1 /* 8 bit immediate */
+#define R_H8500_IMM16 2 /* 16 bit immediate */
+#define R_H8500_PCREL8 3 /* 8 bit pcrel */
+#define R_H8500_PCREL16 4 /* 16 bit pcrel */
+#define R_H8500_HIGH8 5 /* high 8 bits of 24 bit address */
+#define R_H8500_LOW16 7 /* low 16 bits of 24 bit immediate */
+#define R_H8500_IMM24 6 /* 24 bit immediate */
+#define R_H8500_IMM32 8 /* 32 bit immediate */
+#define R_H8500_HIGH16 9 /* high 16 bits of 32 bit immediate */
+
+/* W65 modes */
+
+#define R_W65_ABS8 1 /* addr & 0xff */
+#define R_W65_ABS16 2 /* addr & 0xffff */
+#define R_W65_ABS24 3 /* addr & 0xffffff */
+
+#define R_W65_ABS8S8 4 /* (addr >> 8) & 0xff */
+#define R_W65_ABS8S16 5 /* (addr >> 16) & 0xff */
+
+#define R_W65_ABS16S8 6 /* (addr >> 8) & 0ffff */
+#define R_W65_ABS16S16 7 /* (addr >> 16) & 0ffff */
+
+#define R_W65_PCR8 8
+#define R_W65_PCR16 9
+
+#define R_W65_DP 10 /* direct page 8 bits only */
+
+#endif /* GNU_COFF_INTERNAL_H */
diff --git a/include/coff/m68k.h b/include/coff/m68k.h
new file mode 100644
index 00000000000..c9147ed01b5
--- /dev/null
+++ b/include/coff/m68k.h
@@ -0,0 +1,225 @@
+/*** coff information for M68K */
+
+#ifndef GNU_COFF_M68K_H
+#define GNU_COFF_M68K_H 1
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+/* Motorola 68000/68008/68010/68020 */
+#define MC68MAGIC 0520
+#define MC68KWRMAGIC 0520 /* writeable text segments */
+#define MC68TVMAGIC 0521
+#define MC68KROMAGIC 0521 /* readonly shareable text segments */
+#define MC68KPGMAGIC 0522 /* demand paged text segments */
+#define M68MAGIC 0210
+#define M68TVMAGIC 0211
+
+/* this is the magic of the Bull dpx/2 */
+#define MC68KBCSMAGIC 0526
+
+/* This is Lynx's all-platform magic number for executables. */
+
+#define LYNXCOFFMAGIC 0415
+
+#define OMAGIC M68MAGIC
+
+/* This intentionally does not include MC68KBCSMAGIC; it only includes
+ magic numbers which imply that names do not have underscores. */
+#define M68KBADMAG(x) (((x).f_magic!=MC68MAGIC) && ((x).f_magic!=MC68KWRMAGIC) && ((x).f_magic!=MC68TVMAGIC) && \
+ ((x).f_magic!=MC68KROMAGIC) && ((x).f_magic!=MC68KPGMAGIC) && ((x).f_magic!=M68MAGIC) && ((x).f_magic!=M68TVMAGIC) && ((x).f_magic!=LYNXCOFFMAGIC) )
+
+/* Magic numbers for the a.out header. */
+
+#define PAGEMAGICEXECSWAPPED 0407 /* executable (swapped) */
+#define PAGEMAGICPEXECSWAPPED 0410 /* pure executable (swapped) */
+#define PAGEMAGICPEXECTSHLIB 0443 /* pure executable (target shared library) */
+#define PAGEMAGICPEXECPAGED 0413 /* pure executable (paged) */
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _COMMENT ".comment"
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+#ifdef M68K_COFF_OFFSET
+ char r_offset[4];
+#endif
+
+};
+
+
+#define RELOC struct external_reloc
+
+#ifdef M68K_COFF_OFFSET
+#define RELSZ 14
+#else
+#define RELSZ 10
+#endif
+
+#endif /* GNU_COFF_M68K_H */
diff --git a/include/coff/m88k.h b/include/coff/m88k.h
new file mode 100644
index 00000000000..e06eb4165ec
--- /dev/null
+++ b/include/coff/m88k.h
@@ -0,0 +1,219 @@
+/*** coff information for 88k bcs */
+
+/********************** FILE HEADER **********************/
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+#define MC88MAGIC 0540 /* 88k BCS executable */
+#define MC88DMAGIC 0541 /* DG/UX executable */
+#define MC88OMAGIC 0555 /* Object file */
+
+#define MC88BADMAG(x) (((x).f_magic!=MC88MAGIC) &&((x).f_magic!=MC88DMAGIC) && ((x).f_magic != MC88OMAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+#define PAGEMAGIC3 0414 /* Split i&d, zero mapped */
+#define PAGEMAGICBCS 0413
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+/* compute size of a header */
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr
+{
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[4]; /* number of relocation entries */
+ char s_nlnno[4]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 44
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _COMMENT ".comment"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno{
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+
+ char l_lnno[4];
+
+};
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+ char pad2[2];
+};
+
+
+
+
+#define N_BTMASK 017
+#define N_TMASK 060
+#define N_BTSHFT 4
+#define N_TSHIFT 2
+
+
+/* Note that this isn't the same shape as other coffs */
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ /* 4 */
+ union {
+ char x_fsize[4]; /* size of function */
+ struct {
+ char x_lnno[4]; /* declaration line number */
+ char x_size[4]; /* str/union/array size */
+ } x_lnsz;
+ } x_misc;
+
+ /* 12 */
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ /* 20 */
+
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[4]; /* # relocation entries */
+ char x_nlinno[4]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+};
+
+#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *)ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define PUT_FCN_LNNOPTR(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#define PUT_FCN_ENDNDX(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
+#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
+#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
+#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
+#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
+#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_nreloc)
+#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_nlinno)
+#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
+#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
+#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_32(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno))
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+
+
+#define SYMENT struct external_syment
+#define SYMESZ 20
+#define AUXENT union external_auxent
+#define AUXESZ 20
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+ char r_offset[2];
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 12
+
+#define NO_TVNDX
diff --git a/include/coff/mcore.h b/include/coff/mcore.h
new file mode 100644
index 00000000000..974b62e1630
--- /dev/null
+++ b/include/coff/mcore.h
@@ -0,0 +1,245 @@
+/* Motorolla MCore support for BFD.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the MCore COFF/PE ABI. */
+
+#ifndef _COFF_MORE_H
+#define _COFF_MORE_H
+
+
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+#define IMAGE_REL_MCORE_ABSOLUTE 0x0000
+#define IMAGE_REL_MCORE_ADDR32 0x0001
+#define IMAGE_REL_MCORE_PCREL_IMM8BY4 0x0002
+#define IMAGE_REL_MCORE_PCREL_IMM11BY2 0x0003
+#define IMAGE_REL_MCORE_PCREL_IMM4BY2 0x0004
+#define IMAGE_REL_MCORE_PCREL_32 0x0005
+#define IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2 0x0006
+
+#define PEMCORE
+
+typedef struct
+{
+ char magic [2]; /* type of file */
+ char vstamp [2]; /* version stamp */
+ char tsize [4]; /* text size in bytes, padded to FW bdry*/
+ char dsize [4]; /* initialized data " " */
+ char bsize [4]; /* uninitialized data " " */
+ char entry [4]; /* entry pt. */
+ char text_start [4]; /* base of text used for this file */
+ char data_start [4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+#define OMAGIC 0404 /* object files, eg as output */
+#define ZMAGIC 0413 /* demand load format, eg normal ld output */
+#define STMAGIC 0401 /* target shlib */
+#define SHMAGIC 0443 /* host shlib */
+
+/* From winnt.h */
+#define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
+
+
+/* Define some NT default values. */
+#define NT_SECTION_ALIGNMENT 0x1000
+#define NT_FILE_ALIGNMENT 0x200
+#define NT_DEF_RESERVE 0x100000
+#define NT_DEF_COMMIT 0x1000
+
+
+struct external_reloc
+{
+ char r_vaddr [4];
+ char r_symndx [4];
+ char r_type [2];
+ char r_offset [4];
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 14
+
+#define MCOREMAGIC 0xb00 /* I just made this up */
+
+#define MCOREBADMAG(x) (((x).f_magic!= MCOREMAGIC))
+
+struct external_filehdr
+{
+ char f_magic [2]; /* magic number */
+ char f_nscns [2]; /* number of sections */
+ char f_timdat [4]; /* time & date stamp */
+ char f_symptr [4]; /* file pointer to symtab */
+ char f_nsyms [4]; /* number of symtab entries */
+ char f_opthdr [2]; /* sizeof(optional hdr) */
+ char f_flags [2]; /* flags */
+};
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union
+ {
+ char e_name [E_SYMNMLEN];
+ struct
+ {
+ char e_zeroes [4];
+ char e_offset [4];
+ } e;
+ } e;
+
+ char e_value [4];
+ char e_scnum [2];
+ char e_type [2];
+ char e_sclass [1];
+ char e_numaux [1];
+};
+
+#define N_BTMASK 0xf
+#define N_TMASK 0x30
+#define N_BTSHFT 4
+#define N_TSHIFT 2
+
+union external_auxent
+{
+ struct
+ {
+ char x_tagndx [4]; /* str, un, or enum tag indx */
+
+ union
+ {
+ struct
+ {
+ char x_lnno [2]; /* declaration line number */
+ char x_size [2]; /* str/union/array size */
+ } x_lnsz;
+
+ char x_fsize [4]; /* size of function */
+
+ } x_misc;
+
+ union
+ {
+ struct /* if ISFCN, tag, or .bb */
+ {
+ char x_lnnoptr [4]; /* ptr to fcn line # */
+ char x_endndx [4]; /* entry ndx past block end */
+ } x_fcn;
+
+ struct /* if ISARY, up to 4 dimen. */
+ {
+ char x_dimen [E_DIMNUM][2];
+ } x_ary;
+
+ } x_fcnary;
+
+ char x_tvndx [2]; /* tv index */
+
+ } x_sym;
+
+ union
+ {
+ char x_fname [E_FILNMLEN];
+
+ struct
+ {
+ char x_zeroes [4];
+ char x_offset [4];
+ } x_n;
+
+ } x_file;
+
+ struct
+ {
+ char x_scnlen [4]; /* section length */
+ char x_nreloc [2]; /* # relocation entries */
+ char x_nlinno [2]; /* # line numbers */
+ char x_checksum [4]; /* section COMDAT checksum */
+ char x_associated [2]; /* COMDAT associated section index */
+ char x_comdat [1]; /* COMDAT selection number */
+ } x_scn;
+
+ struct
+ {
+ char x_tvfill [4]; /* tv fill value */
+ char x_tvlen [2]; /* length of .tv */
+ char x_tvran [2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ Line numbers are grouped on a per function basis; first entry in a function
+ grouping will have l_lnno = 0 and in place of physical address will be the
+ symbol table index of the function name. */
+struct external_lineno
+{
+ union
+ {
+ char l_symndx [4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr [4]; /* (physical) address of line number */
+ } l_addr;
+
+ char l_lnno [2]; /* line number */
+};
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32 (abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32 (abfd, val, (bfd_byte *) (ext->l_lnno));
+
+struct external_scnhdr
+{
+ char s_name [8]; /* section name */
+ char s_paddr [4]; /* physical address, aliased s_nlib */
+ char s_vaddr [4]; /* virtual address */
+ char s_size [4]; /* section size */
+ char s_scnptr [4]; /* file ptr to raw data for section */
+ char s_relptr [4]; /* file ptr to relocation */
+ char s_lnnoptr [4]; /* file ptr to line numbers */
+ char s_nreloc [2]; /* number of relocation entries */
+ char s_nlnno [2]; /* number of line number entries*/
+ char s_flags [4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/* Names of "special" sections. */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+
+#endif /* __COFF_MCORE_H */
diff --git a/include/coff/mips.h b/include/coff/mips.h
new file mode 100644
index 00000000000..d4665b1f396
--- /dev/null
+++ b/include/coff/mips.h
@@ -0,0 +1,369 @@
+/* ECOFF support on MIPS machines.
+ coff/ecoff.h must be included before this file. */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ unsigned char f_magic[2]; /* magic number */
+ unsigned char f_nscns[2]; /* number of sections */
+ unsigned char f_timdat[4]; /* time & date stamp */
+ unsigned char f_symptr[4]; /* file pointer to symtab */
+ unsigned char f_nsyms[4]; /* number of symtab entries */
+ unsigned char f_opthdr[2]; /* sizeof(optional hdr) */
+ unsigned char f_flags[2]; /* flags */
+};
+
+/* Magic numbers are defined in coff/ecoff.h. */
+#define MIPS_ECOFF_BADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
+ ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\
+ ((x).f_magic!=MIPS_MAGIC_BIG) && \
+ ((x).f_magic!=MIPS_MAGIC_LITTLE2) && \
+ ((x).f_magic!=MIPS_MAGIC_BIG2) && \
+ ((x).f_magic!=MIPS_MAGIC_LITTLE3) && \
+ ((x).f_magic!=MIPS_MAGIC_BIG3))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct external_aouthdr
+{
+ unsigned char magic[2]; /* type of file */
+ unsigned char vstamp[2]; /* version stamp */
+ unsigned char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ unsigned char dsize[4]; /* initialized data " " */
+ unsigned char bsize[4]; /* uninitialized data " " */
+ unsigned char entry[4]; /* entry pt. */
+ unsigned char text_start[4]; /* base of text used for this file */
+ unsigned char data_start[4]; /* base of data used for this file */
+ unsigned char bss_start[4]; /* base of bss used for this file */
+ unsigned char gprmask[4]; /* ?? */
+ unsigned char cprmask[4][4]; /* ?? */
+ unsigned char gp_value[4]; /* value for gp register */
+} AOUTHDR;
+
+/* compute size of a header */
+
+#define AOUTSZ 56
+#define AOUTHDRSZ 56
+
+/********************** SECTION HEADER **********************/
+
+struct external_scnhdr {
+ unsigned char s_name[8]; /* section name */
+ unsigned char s_paddr[4]; /* physical address, aliased s_nlib */
+ unsigned char s_vaddr[4]; /* virtual address */
+ unsigned char s_size[4]; /* section size */
+ unsigned char s_scnptr[4]; /* file ptr to raw data for section */
+ unsigned char s_relptr[4]; /* file ptr to relocation */
+ unsigned char s_lnnoptr[4]; /* file ptr to line numbers */
+ unsigned char s_nreloc[2]; /* number of relocation entries */
+ unsigned char s_nlnno[2]; /* number of line number entries*/
+ unsigned char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct external_reloc {
+ unsigned char r_vaddr[4];
+ unsigned char r_bits[4];
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 8
+
+/* MIPS ECOFF uses a packed 8 byte format for relocs. These constants
+ are used to unpack the r_bits field. */
+
+#define RELOC_BITS0_SYMNDX_SH_LEFT_BIG 16
+#define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE 0
+
+#define RELOC_BITS1_SYMNDX_SH_LEFT_BIG 8
+#define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE 8
+
+#define RELOC_BITS2_SYMNDX_SH_LEFT_BIG 0
+#define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE 16
+
+/* Originally, ECOFF used four bits for the reloc type and had three
+ reserved bits. Irix 4 added another bit for the reloc type, which
+ was easy because it was big endian and one of the spare bits became
+ the new most significant bit. To make this also work for little
+ endian ECOFF, we need to wrap one of the reserved bits around to
+ become the most significant bit of the reloc type. */
+#define RELOC_BITS3_TYPE_BIG 0x3E
+#define RELOC_BITS3_TYPE_SH_BIG 1
+#define RELOC_BITS3_TYPE_LITTLE 0x78
+#define RELOC_BITS3_TYPE_SH_LITTLE 3
+#define RELOC_BITS3_TYPEHI_LITTLE 0x04
+#define RELOC_BITS3_TYPEHI_SH_LITTLE 2
+
+#define RELOC_BITS3_EXTERN_BIG 0x01
+#define RELOC_BITS3_EXTERN_LITTLE 0x80
+
+/* The r_type field in a reloc is one of the following values. I
+ don't know if any other values can appear. These seem to be all
+ that occur in the Ultrix 4.2 libraries. */
+#define MIPS_R_IGNORE 0
+#define MIPS_R_REFHALF 1
+#define MIPS_R_REFWORD 2
+#define MIPS_R_JMPADDR 3
+#define MIPS_R_REFHI 4
+#define MIPS_R_REFLO 5
+#define MIPS_R_GPREL 6
+#define MIPS_R_LITERAL 7
+
+/* These reloc types are a Cygnus extension used when generating
+ position independent code for embedded systems. The numbers are
+ taken from Irix 4, but at least for internal relocs Irix 5 does not
+ give them the same meaning. For an internal reloc the symbol index
+ of RELHI and RELLO is modified as described below for
+ MIPS_R_SWITCH. */
+#define MIPS_R_PCREL16 12
+#define MIPS_R_RELHI 13
+#define MIPS_R_RELLO 14
+
+/* This reloc type is a Cygnus extension used when generating position
+ independent code for embedded systems. It is used for an entry in
+ a switch table, which looks like this:
+ .word $L3-$LS12
+ The object file will contain the correct difference, and does not
+ require adjustment. However, when the linker is relaxing PC
+ relative calls, it is possible for $L3 to move farther away. This
+ reloc always appears in the .text section, and is always against
+ the .text section. However, the symbol index is not
+ RELOC_SECTION_TEXT. It is, instead, the distance between this
+ switch table entry and $LS12. Thus, the original value of $L12 is
+ vaddr - symndx
+ and the original value of $L3 is
+ vaddr - symndx + addend
+ where addend is the value in the object file. Knowing this, the
+ linker can know whether the addend in the object file must be
+ adjusted. */
+#define MIPS_R_SWITCH 22
+
+/********************** STABS **********************/
+
+#define MIPS_IS_STAB ECOFF_IS_STAB
+#define MIPS_MARK_STAB ECOFF_MARK_STAB
+#define MIPS_UNMARK_STAB ECOFF_UNMARK_STAB
+
+/********************** SYMBOLIC INFORMATION **********************/
+
+/* Written by John Gilmore. */
+
+/* ECOFF uses COFF-like section structures, but its own symbol format.
+ This file defines the symbol format in fields whose size and alignment
+ will not vary on different host systems. */
+
+/* File header as a set of bytes */
+
+struct hdr_ext {
+ unsigned char h_magic[2];
+ unsigned char h_vstamp[2];
+ unsigned char h_ilineMax[4];
+ unsigned char h_cbLine[4];
+ unsigned char h_cbLineOffset[4];
+ unsigned char h_idnMax[4];
+ unsigned char h_cbDnOffset[4];
+ unsigned char h_ipdMax[4];
+ unsigned char h_cbPdOffset[4];
+ unsigned char h_isymMax[4];
+ unsigned char h_cbSymOffset[4];
+ unsigned char h_ioptMax[4];
+ unsigned char h_cbOptOffset[4];
+ unsigned char h_iauxMax[4];
+ unsigned char h_cbAuxOffset[4];
+ unsigned char h_issMax[4];
+ unsigned char h_cbSsOffset[4];
+ unsigned char h_issExtMax[4];
+ unsigned char h_cbSsExtOffset[4];
+ unsigned char h_ifdMax[4];
+ unsigned char h_cbFdOffset[4];
+ unsigned char h_crfd[4];
+ unsigned char h_cbRfdOffset[4];
+ unsigned char h_iextMax[4];
+ unsigned char h_cbExtOffset[4];
+};
+
+/* File descriptor external record */
+
+struct fdr_ext {
+ unsigned char f_adr[4];
+ unsigned char f_rss[4];
+ unsigned char f_issBase[4];
+ unsigned char f_cbSs[4];
+ unsigned char f_isymBase[4];
+ unsigned char f_csym[4];
+ unsigned char f_ilineBase[4];
+ unsigned char f_cline[4];
+ unsigned char f_ioptBase[4];
+ unsigned char f_copt[4];
+ unsigned char f_ipdFirst[2];
+ unsigned char f_cpd[2];
+ unsigned char f_iauxBase[4];
+ unsigned char f_caux[4];
+ unsigned char f_rfdBase[4];
+ unsigned char f_crfd[4];
+ unsigned char f_bits1[1];
+ unsigned char f_bits2[3];
+ unsigned char f_cbLineOffset[4];
+ unsigned char f_cbLine[4];
+};
+
+#define FDR_BITS1_LANG_BIG 0xF8
+#define FDR_BITS1_LANG_SH_BIG 3
+#define FDR_BITS1_LANG_LITTLE 0x1F
+#define FDR_BITS1_LANG_SH_LITTLE 0
+
+#define FDR_BITS1_FMERGE_BIG 0x04
+#define FDR_BITS1_FMERGE_LITTLE 0x20
+
+#define FDR_BITS1_FREADIN_BIG 0x02
+#define FDR_BITS1_FREADIN_LITTLE 0x40
+
+#define FDR_BITS1_FBIGENDIAN_BIG 0x01
+#define FDR_BITS1_FBIGENDIAN_LITTLE 0x80
+
+#define FDR_BITS2_GLEVEL_BIG 0xC0
+#define FDR_BITS2_GLEVEL_SH_BIG 6
+#define FDR_BITS2_GLEVEL_LITTLE 0x03
+#define FDR_BITS2_GLEVEL_SH_LITTLE 0
+
+/* We ignore the `reserved' field in bits2. */
+
+/* Procedure descriptor external record */
+
+struct pdr_ext {
+ unsigned char p_adr[4];
+ unsigned char p_isym[4];
+ unsigned char p_iline[4];
+ unsigned char p_regmask[4];
+ unsigned char p_regoffset[4];
+ unsigned char p_iopt[4];
+ unsigned char p_fregmask[4];
+ unsigned char p_fregoffset[4];
+ unsigned char p_frameoffset[4];
+ unsigned char p_framereg[2];
+ unsigned char p_pcreg[2];
+ unsigned char p_lnLow[4];
+ unsigned char p_lnHigh[4];
+ unsigned char p_cbLineOffset[4];
+};
+
+/* Runtime procedure table */
+
+struct rpdr_ext {
+ unsigned char p_adr[4];
+ unsigned char p_regmask[4];
+ unsigned char p_regoffset[4];
+ unsigned char p_fregmask[4];
+ unsigned char p_fregoffset[4];
+ unsigned char p_frameoffset[4];
+ unsigned char p_framereg[2];
+ unsigned char p_pcreg[2];
+ unsigned char p_irpss[4];
+ unsigned char p_reserved[4];
+ unsigned char p_exception_info[4];
+};
+
+/* Line numbers */
+
+struct line_ext {
+ unsigned char l_line[4];
+};
+
+/* Symbol external record */
+
+struct sym_ext {
+ unsigned char s_iss[4];
+ unsigned char s_value[4];
+ unsigned char s_bits1[1];
+ unsigned char s_bits2[1];
+ unsigned char s_bits3[1];
+ unsigned char s_bits4[1];
+};
+
+#define SYM_BITS1_ST_BIG 0xFC
+#define SYM_BITS1_ST_SH_BIG 2
+#define SYM_BITS1_ST_LITTLE 0x3F
+#define SYM_BITS1_ST_SH_LITTLE 0
+
+#define SYM_BITS1_SC_BIG 0x03
+#define SYM_BITS1_SC_SH_LEFT_BIG 3
+#define SYM_BITS1_SC_LITTLE 0xC0
+#define SYM_BITS1_SC_SH_LITTLE 6
+
+#define SYM_BITS2_SC_BIG 0xE0
+#define SYM_BITS2_SC_SH_BIG 5
+#define SYM_BITS2_SC_LITTLE 0x07
+#define SYM_BITS2_SC_SH_LEFT_LITTLE 2
+
+#define SYM_BITS2_RESERVED_BIG 0x10
+#define SYM_BITS2_RESERVED_LITTLE 0x08
+
+#define SYM_BITS2_INDEX_BIG 0x0F
+#define SYM_BITS2_INDEX_SH_LEFT_BIG 16
+#define SYM_BITS2_INDEX_LITTLE 0xF0
+#define SYM_BITS2_INDEX_SH_LITTLE 4
+
+#define SYM_BITS3_INDEX_SH_LEFT_BIG 8
+#define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4
+
+#define SYM_BITS4_INDEX_SH_LEFT_BIG 0
+#define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12
+
+/* External symbol external record */
+
+struct ext_ext {
+ unsigned char es_bits1[1];
+ unsigned char es_bits2[1];
+ unsigned char es_ifd[2];
+ struct sym_ext es_asym;
+};
+
+#define EXT_BITS1_JMPTBL_BIG 0x80
+#define EXT_BITS1_JMPTBL_LITTLE 0x01
+
+#define EXT_BITS1_COBOL_MAIN_BIG 0x40
+#define EXT_BITS1_COBOL_MAIN_LITTLE 0x02
+
+#define EXT_BITS1_WEAKEXT_BIG 0x20
+#define EXT_BITS1_WEAKEXT_LITTLE 0x04
+
+/* Dense numbers external record */
+
+struct dnr_ext {
+ unsigned char d_rfd[4];
+ unsigned char d_index[4];
+};
+
+/* Relative file descriptor */
+
+struct rfd_ext {
+ unsigned char rfd[4];
+};
+
+/* Optimizer symbol external record */
+
+struct opt_ext {
+ unsigned char o_bits1[1];
+ unsigned char o_bits2[1];
+ unsigned char o_bits3[1];
+ unsigned char o_bits4[1];
+ struct rndx_ext o_rndx;
+ unsigned char o_offset[4];
+};
+
+#define OPT_BITS2_VALUE_SH_LEFT_BIG 16
+#define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0
+
+#define OPT_BITS3_VALUE_SH_LEFT_BIG 8
+#define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8
+
+#define OPT_BITS4_VALUE_SH_LEFT_BIG 0
+#define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16
diff --git a/include/coff/pe.h b/include/coff/pe.h
new file mode 100644
index 00000000000..7e676a50882
--- /dev/null
+++ b/include/coff/pe.h
@@ -0,0 +1,169 @@
+/* PE COFF header information */
+
+#ifndef _PE_H
+#define _PE_H
+
+/* NT specific file attributes */
+#define IMAGE_FILE_RELOCS_STRIPPED 0x0001
+#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
+#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
+#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
+#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
+#define IMAGE_FILE_32BIT_MACHINE 0x0100
+#define IMAGE_FILE_DEBUG_STRIPPED 0x0200
+#define IMAGE_FILE_SYSTEM 0x1000
+#define IMAGE_FILE_DLL 0x2000
+#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
+
+/* additional flags to be set for section headers to allow the NT loader to
+ read and write to the section data (to replace the addresses of data in
+ dlls for one thing); also to execute the section in .text's case */
+#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
+#define IMAGE_SCN_MEM_EXECUTE 0x20000000
+#define IMAGE_SCN_MEM_READ 0x40000000
+#define IMAGE_SCN_MEM_WRITE 0x80000000
+
+/*
+ * Section characteristics added for ppc-nt
+ */
+
+#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved. */
+
+#define IMAGE_SCN_CNT_CODE 0x00000020 /* Section contains code. */
+#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 /* Section contains initialized data. */
+#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 /* Section contains uninitialized data. */
+
+#define IMAGE_SCN_LNK_OTHER 0x00000100 /* Reserved. */
+#define IMAGE_SCN_LNK_INFO 0x00000200 /* Section contains comments or some other type of information. */
+#define IMAGE_SCN_LNK_REMOVE 0x00000800 /* Section contents will not become part of image. */
+#define IMAGE_SCN_LNK_COMDAT 0x00001000 /* Section contents comdat. */
+
+#define IMAGE_SCN_MEM_FARDATA 0x00008000
+
+#define IMAGE_SCN_MEM_PURGEABLE 0x00020000
+#define IMAGE_SCN_MEM_16BIT 0x00020000
+#define IMAGE_SCN_MEM_LOCKED 0x00040000
+#define IMAGE_SCN_MEM_PRELOAD 0x00080000
+
+#define IMAGE_SCN_ALIGN_1BYTES 0x00100000
+#define IMAGE_SCN_ALIGN_2BYTES 0x00200000
+#define IMAGE_SCN_ALIGN_4BYTES 0x00300000
+#define IMAGE_SCN_ALIGN_8BYTES 0x00400000
+#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default alignment if no others are specified. */
+#define IMAGE_SCN_ALIGN_32BYTES 0x00600000
+#define IMAGE_SCN_ALIGN_64BYTES 0x00700000
+
+
+#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 /* Section contains extended relocations. */
+#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 /* Section is not cachable. */
+#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 /* Section is not pageable. */
+#define IMAGE_SCN_MEM_SHARED 0x10000000 /* Section is shareable. */
+
+/* COMDAT selection codes. */
+
+#define IMAGE_COMDAT_SELECT_NODUPLICATES (1) /* Warn if duplicates. */
+#define IMAGE_COMDAT_SELECT_ANY (2) /* No warning. */
+#define IMAGE_COMDAT_SELECT_SAME_SIZE (3) /* Warn if different size. */
+#define IMAGE_COMDAT_SELECT_EXACT_MATCH (4) /* Warn if different. */
+#define IMAGE_COMDAT_SELECT_ASSOCIATIVE (5) /* Base on other section. */
+
+/* Magic values that are true for all dos/nt implementations */
+#define DOSMAGIC 0x5a4d
+#define NT_SIGNATURE 0x00004550
+
+ /* NT allows long filenames, we want to accommodate this. This may break
+ some of the bfd functions */
+#undef FILNMLEN
+#define FILNMLEN 18 /* # characters in a file name */
+
+
+#ifdef COFF_IMAGE_WITH_PE
+/* The filehdr is only weired in images */
+
+#undef FILHDR
+struct external_PE_filehdr
+{
+ /* DOS header fields */
+ char e_magic[2]; /* Magic number, 0x5a4d */
+ char e_cblp[2]; /* Bytes on last page of file, 0x90 */
+ char e_cp[2]; /* Pages in file, 0x3 */
+ char e_crlc[2]; /* Relocations, 0x0 */
+ char e_cparhdr[2]; /* Size of header in paragraphs, 0x4 */
+ char e_minalloc[2]; /* Minimum extra paragraphs needed, 0x0 */
+ char e_maxalloc[2]; /* Maximum extra paragraphs needed, 0xFFFF */
+ char e_ss[2]; /* Initial (relative) SS value, 0x0 */
+ char e_sp[2]; /* Initial SP value, 0xb8 */
+ char e_csum[2]; /* Checksum, 0x0 */
+ char e_ip[2]; /* Initial IP value, 0x0 */
+ char e_cs[2]; /* Initial (relative) CS value, 0x0 */
+ char e_lfarlc[2]; /* File address of relocation table, 0x40 */
+ char e_ovno[2]; /* Overlay number, 0x0 */
+ char e_res[4][2]; /* Reserved words, all 0x0 */
+ char e_oemid[2]; /* OEM identifier (for e_oeminfo), 0x0 */
+ char e_oeminfo[2]; /* OEM information; e_oemid specific, 0x0 */
+ char e_res2[10][2]; /* Reserved words, all 0x0 */
+ char e_lfanew[4]; /* File address of new exe header, 0x80 */
+ char dos_message[16][4]; /* other stuff, always follow DOS header */
+ char nt_signature[4]; /* required NT signature, 0x4550 */
+
+ /* From standard header */
+
+
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+
+};
+
+
+#define FILHDR struct external_PE_filehdr
+#undef FILHSZ
+#define FILHSZ 152
+
+#endif
+
+typedef struct
+{
+ AOUTHDR standard;
+
+ /* NT extra fields; see internal.h for descriptions */
+ char ImageBase[4];
+ char SectionAlignment[4];
+ char FileAlignment[4];
+ char MajorOperatingSystemVersion[2];
+ char MinorOperatingSystemVersion[2];
+ char MajorImageVersion[2];
+ char MinorImageVersion[2];
+ char MajorSubsystemVersion[2];
+ char MinorSubsystemVersion[2];
+ char Reserved1[4];
+ char SizeOfImage[4];
+ char SizeOfHeaders[4];
+ char CheckSum[4];
+ char Subsystem[2];
+ char DllCharacteristics[2];
+ char SizeOfStackReserve[4];
+ char SizeOfStackCommit[4];
+ char SizeOfHeapReserve[4];
+ char SizeOfHeapCommit[4];
+ char LoaderFlags[4];
+ char NumberOfRvaAndSizes[4];
+ /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
+ char DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
+
+} PEAOUTHDR;
+
+
+#undef AOUTSZ
+#define AOUTSZ (AOUTHDRSZ + 196)
+
+#undef E_FILNMLEN
+#define E_FILNMLEN 18 /* # characters in a file name */
+#endif
+
+
+
diff --git a/include/coff/powerpc.h b/include/coff/powerpc.h
new file mode 100644
index 00000000000..9552cf9f45e
--- /dev/null
+++ b/include/coff/powerpc.h
@@ -0,0 +1,199 @@
+/* Basic coff information for the PowerPC
+ *
+ * Based on coff/rs6000.h, coff/i386.h and others.
+ *
+ * Initial release: Kim Knuttila (krk@cygnus.com)
+ */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+/* Bits for f_flags:
+ * F_RELFLG relocation info stripped from file
+ * F_EXEC file is executable (no unresolved external references)
+ * F_LNNO line numbers stripped from file
+ * F_LSYMS local symbols stripped from file
+ * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
+ */
+
+#define F_RELFLG (0x0001)
+#define F_EXEC (0x0002)
+#define F_LNNO (0x0004)
+#define F_LSYMS (0x0008)
+
+/* extra NT defines */
+#define PPCMAGIC 0760 /* peeked on aa PowerPC Windows NT box */
+#define DOSMAGIC 0x5a4d /* from arm.h, i386.h */
+#define NT_SIGNATURE 0x00004550 /* from arm.h, i386.h */
+
+/* from winnt.h */
+#define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
+
+#define PPCBADMAG(x) ((x).f_magic != PPCMAGIC)
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+/********************** SECTION HEADER **********************/
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries */
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _COMMENT ".comment"
+#define _LIB ".lib"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0 */
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+
+/* Allow the file name length to be overridden in the including file */
+#ifndef E_FILNMLEN
+#define E_FILNMLEN 14
+#endif
+
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+
+#define N_BTMASK (0xf)
+#define N_TMASK (0x30)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ char x_checksum[4]; /* section COMDAT checksum */
+ char x_associated[2]; /* COMDAT associated section index */
+ char x_comdat[1]; /* COMDAT selection number */
+ } x_scn;
+};
+
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+#define _ETEXT "etext"
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 10
+
diff --git a/include/coff/rs6000.h b/include/coff/rs6000.h
new file mode 100644
index 00000000000..0def1d95d15
--- /dev/null
+++ b/include/coff/rs6000.h
@@ -0,0 +1,243 @@
+/* IBM RS/6000 "XCOFF" file definitions for BFD.
+ Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ FIXME: Can someone provide a transliteration of this name into ASCII?
+ Using the following chars caused a compiler warning on HIUX (so I replaced
+ them with octal escapes), and isn't useful without an understanding of what
+ character set it is.
+ Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM
+ and John Gilmore of Cygnus Support. */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+ /* IBM RS/6000 */
+#define U802WRMAGIC 0730 /* writeable text segments **chh** */
+#define U802ROMAGIC 0735 /* readonly sharable text segments */
+#define U802TOCMAGIC 0737 /* readonly text segments and TOC */
+
+#define BADMAG(x) \
+ ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \
+ (x).f_magic != U802TOCMAGIC)
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ unsigned char magic[2]; /* type of file */
+ unsigned char vstamp[2]; /* version stamp */
+ unsigned char tsize[4]; /* text size in bytes, padded to FW bdry */
+ unsigned char dsize[4]; /* initialized data " " */
+ unsigned char bsize[4]; /* uninitialized data " " */
+ unsigned char entry[4]; /* entry pt. */
+ unsigned char text_start[4]; /* base of text used for this file */
+ unsigned char data_start[4]; /* base of data used for this file */
+ unsigned char o_toc[4]; /* address of TOC */
+ unsigned char o_snentry[2]; /* section number of entry point */
+ unsigned char o_sntext[2]; /* section number of .text section */
+ unsigned char o_sndata[2]; /* section number of .data section */
+ unsigned char o_sntoc[2]; /* section number of TOC */
+ unsigned char o_snloader[2]; /* section number of .loader section */
+ unsigned char o_snbss[2]; /* section number of .bss section */
+ unsigned char o_algntext[2]; /* .text alignment */
+ unsigned char o_algndata[2]; /* .data alignment */
+ unsigned char o_modtype[2]; /* module type (??) */
+ unsigned char o_cputype[2]; /* cpu type */
+ unsigned char o_maxstack[4]; /* max stack size (??) */
+ unsigned char o_maxdata[4]; /* max data size (??) */
+ unsigned char o_resv2[12]; /* reserved */
+}
+AOUTHDR;
+
+#define AOUTSZ 72
+#define SMALL_AOUTSZ (28)
+#define AOUTHDRSZ 72
+
+#define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */
+#define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */
+#define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _PAD ".pad"
+#define _LOADER ".loader"
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/* XCOFF uses a special .loader section with type STYP_LOADER. */
+#define STYP_LOADER 0x1000
+
+/* XCOFF uses a special .debug section with type STYP_DEBUG. */
+#define STYP_DEBUG 0x2000
+
+/* XCOFF handles line number or relocation overflow by creating
+ another section header with STYP_OVRFLO set. */
+#define STYP_OVRFLO 0x8000
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+ struct {
+ unsigned char x_scnlen[4];
+ unsigned char x_parmhash[4];
+ unsigned char x_snhash[2];
+ unsigned char x_smtyp[1];
+ unsigned char x_smclas[1];
+ unsigned char x_stab[4];
+ unsigned char x_snstab[2];
+ } x_csect;
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+#define DBXMASK 0x80 /* for dbx storage mask */
+#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_size[1];
+ char r_type[1];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 10
+
+#define DEFAULT_DATA_SECTION_ALIGNMENT 4
+#define DEFAULT_BSS_SECTION_ALIGNMENT 4
+#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
+/* For new sections we havn't heard of before */
+#define DEFAULT_SECTION_ALIGNMENT 4
diff --git a/include/coff/sh.h b/include/coff/sh.h
new file mode 100644
index 00000000000..41957df7f93
--- /dev/null
+++ b/include/coff/sh.h
@@ -0,0 +1,269 @@
+/*** coff information for Hitachi SH */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+
+#define SH_ARCH_MAGIC_BIG 0x0500
+#define SH_ARCH_MAGIC_LITTLE 0x0550 /* Little endian SH */
+
+
+#define SHBADMAG(x) \
+ (((x).f_magic!=SH_ARCH_MAGIC_BIG) && \
+ ((x).f_magic!=SH_ARCH_MAGIC_LITTLE))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[4]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the h8 don't have room in the instruction for the entire
+ offset - eg the strange jump and high page addressing modes */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_offset[4];
+ char r_type[2];
+ char r_stuff[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
+/* SH relocation types. Not all of these are actually used. */
+
+#define R_SH_UNUSED 0 /* only used internally */
+#define R_SH_PCREL8 3 /* 8 bit pcrel */
+#define R_SH_PCREL16 4 /* 16 bit pcrel */
+#define R_SH_HIGH8 5 /* high 8 bits of 24 bit address */
+#define R_SH_LOW16 7 /* low 16 bits of 24 bit immediate */
+#define R_SH_IMM24 6 /* 24 bit immediate */
+#define R_SH_PCDISP8BY4 9 /* PC rel 8 bits *4 +ve */
+#define R_SH_PCDISP8BY2 10 /* PC rel 8 bits *2 +ve */
+#define R_SH_PCDISP8 11 /* 8 bit branch */
+#define R_SH_PCDISP 12 /* 12 bit branch */
+#define R_SH_IMM32 14 /* 32 bit immediate */
+#define R_SH_IMM8 16 /* 8 bit immediate */
+#define R_SH_IMM8BY2 17 /* 8 bit immediate *2 */
+#define R_SH_IMM8BY4 18 /* 8 bit immediate *4 */
+#define R_SH_IMM4 19 /* 4 bit immediate */
+#define R_SH_IMM4BY2 20 /* 4 bit immediate *2 */
+#define R_SH_IMM4BY4 21 /* 4 bit immediate *4 */
+#define R_SH_PCRELIMM8BY2 22 /* PC rel 8 bits *2 unsigned */
+#define R_SH_PCRELIMM8BY4 23 /* PC rel 8 bits *4 unsigned */
+#define R_SH_IMM16 24 /* 16 bit immediate */
+
+/* The switch table reloc types are used for relaxing. They are
+ generated for expressions such as
+ .word L1 - L2
+ The r_offset field holds the difference between the reloc address
+ and L2. */
+#define R_SH_SWITCH8 33 /* 8 bit switch table entry */
+#define R_SH_SWITCH16 25 /* 16 bit switch table entry */
+#define R_SH_SWITCH32 26 /* 32 bit switch table entry */
+
+/* The USES reloc type is used for relaxing. The compiler will
+ generate .uses pseudo-ops when it finds a function call which it
+ can relax. The r_offset field of the USES reloc holds the PC
+ relative offset to the instruction which loads the register used in
+ the function call. */
+#define R_SH_USES 27 /* .uses pseudo-op */
+
+/* The COUNT reloc type is used for relaxing. The assembler will
+ generate COUNT relocs for addresses referred to by the register
+ loads associated with USES relocs. The r_offset field of the COUNT
+ reloc holds the number of times the address is referenced in the
+ object file. */
+#define R_SH_COUNT 28 /* Count of constant pool uses */
+
+/* The ALIGN reloc type is used for relaxing. The r_offset field is
+ the power of two to which subsequent portions of the object file
+ must be aligned. */
+#define R_SH_ALIGN 29 /* .align pseudo-op */
+
+/* The CODE and DATA reloc types are used for aligning load and store
+ instructions. The assembler will generate a CODE reloc before a
+ block of instructions. It will generate a DATA reloc before data.
+ A section should be processed assuming it contains data, unless a
+ CODE reloc is seen. The only relevant pieces of information in the
+ CODE and DATA relocs are the section and the address. The symbol
+ and offset are meaningless. */
+#define R_SH_CODE 30 /* start of code */
+#define R_SH_DATA 31 /* start of data */
+
+/* The LABEL reloc type is used for aligning load and store
+ instructions. The assembler will generate a LABEL reloc for each
+ label within a block of instructions. This permits the linker to
+ avoid swapping instructions which are the targets of branches. */
+#define R_SH_LABEL 32 /* label */
+
+/* NB: R_SH_SWITCH8 is 33 */
diff --git a/include/coff/sparc.h b/include/coff/sparc.h
new file mode 100644
index 00000000000..82a24f01e7a
--- /dev/null
+++ b/include/coff/sparc.h
@@ -0,0 +1,210 @@
+/*** coff information for Sparc. */
+
+/* This file is an amalgamation of several standard include files that
+ define coff format, such as filehdr.h, aouthdr.h, and so forth. In
+ addition, all datatypes have been translated into character arrays of
+ (presumed) equivalent size. This is necessary so that this file can
+ be used with different systems while still yielding the same results. */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr
+{
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+#define F_RELFLG (0x0001) /* relocation info stripped */
+#define F_EXEC (0x0002) /* file is executable */
+#define F_LNNO (0x0004) /* line numbers stripped */
+#define F_LSYMS (0x0008) /* local symbols stripped */
+
+#define SPARCMAGIC (0540)
+
+/* This is Lynx's all-platform magic number for executables. */
+
+#define LYNXCOFFMAGIC (0415)
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+#define OMAGIC 0404 /* object files, eg as output */
+#define ZMAGIC 0413 /* demand load format, eg normal ld output */
+#define STMAGIC 0401 /* target shlib */
+#define SHMAGIC 0443 /* host shlib */
+
+/********************** SECTION HEADER **********************/
+
+struct external_scnhdr
+{
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/* Names of "special" sections. */
+
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _TV ".tv"
+#define _INIT ".init"
+#define _FINI ".fini"
+#define _COMMENT ".comment"
+#define _LIB ".lib"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ Line numbers are grouped on a per function basis; first entry in a function
+ grouping will have l_lnno = 0 and in place of physical address will be the
+ symbol table index of the function name. */
+
+struct external_lineno
+{
+ union {
+ char l_symndx[4]; /* fn name symbol index, iff l_lnno == 0 */
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+#define LINENO struct external_lineno
+#define LINESZ (6)
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN (8) /* # characters in a symbol name */
+#define E_FILNMLEN (14) /* # characters in a file name */
+#define E_DIMNUM (4) /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+#if 0 /* of doubtful value */
+ char e_nptr[2][4];
+ struct {
+ char e_leading_zero[1];
+ char e_dbx_type[1];
+ char e_dbx_desc[2];
+ } e_dbx;
+#endif
+ } e;
+
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+ char padding[2];
+};
+
+#define N_BTMASK (0xf)
+#define N_TMASK (0x30)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+union external_auxent
+{
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* .tv section info (in auxent of sym .tv)) */
+
+ char x_fill[20]; /* forces to 20-byte size */
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 20
+#define AUXENT union external_auxent
+#define AUXESZ 20
+
+#define _ETEXT "etext"
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+ char r_spare[2];
+ char r_offset[4];
+};
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
diff --git a/include/coff/sym.h b/include/coff/sym.h
new file mode 100644
index 00000000000..76204af59ad
--- /dev/null
+++ b/include/coff/sym.h
@@ -0,0 +1,484 @@
+/* Declarations of internal format of MIPS ECOFF symbols.
+ Originally contributed by MIPS Computer Systems and Third Eye Software.
+ Changes contributed by Cygnus Support are in the public domain.
+
+ This file is just aggregated with the files that make up the GNU
+ release; it is not considered part of GAS, GDB, or other GNU
+ programs. */
+
+/*
+ * |-----------------------------------------------------------|
+ * | Copyright (c) 1992, 1991, 1990 MIPS Computer Systems, Inc.|
+ * | MIPS Computer Systems, Inc. grants reproduction and use |
+ * | rights to all parties, PROVIDED that this comment is |
+ * | maintained in the copy. |
+ * |-----------------------------------------------------------|
+ */
+#ifndef _SYM_H
+#define _SYM_H
+
+/* (C) Copyright 1984 by Third Eye Software, Inc.
+ *
+ * Third Eye Software, Inc. grants reproduction and use rights to
+ * all parties, PROVIDED that this comment is maintained in the copy.
+ *
+ * Third Eye makes no claims about the applicability of this
+ * symbol table to a particular use.
+ */
+
+/*
+ * This file contains the definition of the Third Eye Symbol Table.
+ *
+ * Symbols are assumed to be in 'encounter order' - i.e. the order that
+ * the things they represent were encountered by the compiler/assembler/loader.
+ * EXCEPT for globals! These are assumed to be bunched together,
+ * probably right after the last 'normal' symbol. Globals ARE sorted
+ * in ascending order.
+ *
+ * -----------------------------------------------------------------------
+ * A brief word about Third Eye naming/use conventions:
+ *
+ * All arrays and index's are 0 based.
+ * All "ifooMax" values are the highest legal value PLUS ONE. This makes
+ * them good for allocating arrays, etc. All checks are "ifoo < ifooMax".
+ *
+ * "isym" Index into the SYMbol table.
+ * "ipd" Index into the Procedure Descriptor array.
+ * "ifd" Index into the File Descriptor array.
+ * "iss" Index into String Space.
+ * "cb" Count of Bytes.
+ * "rgPd" array whose domain is "0..ipdMax-1" and RanGe is PDR.
+ * "rgFd" array whose domain is "0..ifdMax-1" and RanGe is FDR.
+ */
+
+
+/*
+ * Symbolic Header (HDR) structure.
+ * As long as all the pointers are set correctly,
+ * we don't care WHAT order the various sections come out in!
+ *
+ * A file produced solely for the use of CDB will probably NOT have
+ * any instructions or data areas in it, as these are available
+ * in the original.
+ */
+
+typedef struct {
+ short magic; /* to verify validity of the table */
+ short vstamp; /* version stamp */
+ long ilineMax; /* number of line number entries */
+ bfd_vma cbLine; /* number of bytes for line number entries */
+ bfd_vma cbLineOffset; /* offset to start of line number entries*/
+ long idnMax; /* max index into dense number table */
+ bfd_vma cbDnOffset; /* offset to start dense number table */
+ long ipdMax; /* number of procedures */
+ bfd_vma cbPdOffset; /* offset to procedure descriptor table */
+ long isymMax; /* number of local symbols */
+ bfd_vma cbSymOffset; /* offset to start of local symbols*/
+ long ioptMax; /* max index into optimization symbol entries */
+ bfd_vma cbOptOffset; /* offset to optimization symbol entries */
+ long iauxMax; /* number of auxillary symbol entries */
+ bfd_vma cbAuxOffset; /* offset to start of auxillary symbol entries*/
+ long issMax; /* max index into local strings */
+ bfd_vma cbSsOffset; /* offset to start of local strings */
+ long issExtMax; /* max index into external strings */
+ bfd_vma cbSsExtOffset; /* offset to start of external strings */
+ long ifdMax; /* number of file descriptor entries */
+ bfd_vma cbFdOffset; /* offset to file descriptor table */
+ long crfd; /* number of relative file descriptor entries */
+ bfd_vma cbRfdOffset; /* offset to relative file descriptor table */
+ long iextMax; /* max index into external symbols */
+ bfd_vma cbExtOffset; /* offset to start of external symbol entries*/
+ /* If you add machine dependent fields, add them here */
+ } HDRR, *pHDRR;
+#define cbHDRR sizeof(HDRR)
+#define hdrNil ((pHDRR)0)
+
+/*
+ * The FDR and PDR structures speed mapping of address <-> name.
+ * They are sorted in ascending memory order and are kept in
+ * memory by CDB at runtime.
+ */
+
+/*
+ * File Descriptor
+ *
+ * There is one of these for EVERY FILE, whether compiled with
+ * full debugging symbols or not. The name of a file should be
+ * the path name given to the compiler. This allows the user
+ * to simply specify the names of the directories where the COMPILES
+ * were done, and we will be able to find their files.
+ * A field whose comment starts with "R - " indicates that it will be
+ * setup at runtime.
+ */
+typedef struct fdr {
+ bfd_vma adr; /* memory address of beginning of file */
+ long rss; /* file name (of source, if known) */
+ long issBase; /* file's string space */
+ bfd_vma cbSs; /* number of bytes in the ss */
+ long isymBase; /* beginning of symbols */
+ long csym; /* count file's of symbols */
+ long ilineBase; /* file's line symbols */
+ long cline; /* count of file's line symbols */
+ long ioptBase; /* file's optimization entries */
+ long copt; /* count of file's optimization entries */
+ unsigned short ipdFirst;/* start of procedures for this file */
+ short cpd; /* count of procedures for this file */
+ long iauxBase; /* file's auxiliary entries */
+ long caux; /* count of file's auxiliary entries */
+ long rfdBase; /* index into the file indirect table */
+ long crfd; /* count file indirect entries */
+ unsigned lang: 5; /* language for this file */
+ unsigned fMerge : 1; /* whether this file can be merged */
+ unsigned fReadin : 1; /* true if it was read in (not just created) */
+ unsigned fBigendian : 1;/* if set, was compiled on big endian machine */
+ /* aux's will be in compile host's sex */
+ unsigned glevel : 2; /* level this file was compiled with */
+ unsigned reserved : 22; /* reserved for future use */
+ bfd_vma cbLineOffset; /* byte offset from header for this file ln's */
+ bfd_vma cbLine; /* size of lines for this file */
+ } FDR, *pFDR;
+#define cbFDR sizeof(FDR)
+#define fdNil ((pFDR)0)
+#define ifdNil -1
+#define ifdTemp 0
+#define ilnNil -1
+
+
+/*
+ * Procedure Descriptor
+ *
+ * There is one of these for EVERY TEXT LABEL.
+ * If a procedure is in a file with full symbols, then isym
+ * will point to the PROC symbols, else it will point to the
+ * global symbol for the label.
+ */
+
+typedef struct pdr {
+ bfd_vma adr; /* memory address of start of procedure */
+ long isym; /* start of local symbol entries */
+ long iline; /* start of line number entries*/
+ long regmask; /* save register mask */
+ long regoffset; /* save register offset */
+ long iopt; /* start of optimization symbol entries*/
+ long fregmask; /* save floating point register mask */
+ long fregoffset; /* save floating point register offset */
+ long frameoffset; /* frame size */
+ short framereg; /* frame pointer register */
+ short pcreg; /* offset or reg of return pc */
+ long lnLow; /* lowest line in the procedure */
+ long lnHigh; /* highest line in the procedure */
+ bfd_vma cbLineOffset; /* byte offset for this procedure from the fd base */
+ /* These fields are new for 64 bit ECOFF. */
+ unsigned gp_prologue : 8; /* byte size of GP prologue */
+ unsigned gp_used : 1; /* true if the procedure uses GP */
+ unsigned reg_frame : 1; /* true if register frame procedure */
+ unsigned prof : 1; /* true if compiled with -pg */
+ unsigned reserved : 13; /* reserved: must be zero */
+ unsigned localoff : 8; /* offset of local variables from vfp */
+ } PDR, *pPDR;
+#define cbPDR sizeof(PDR)
+#define pdNil ((pPDR) 0)
+#define ipdNil -1
+
+/*
+ * The structure of the runtime procedure descriptor created by the loader
+ * for use by the static exception system.
+ */
+/*
+ * If 0'd out because exception_info chokes Visual C++ and because there
+ * don't seem to be any references to this structure elsewhere in gdb.
+ */
+#if 0
+typedef struct runtime_pdr {
+ bfd_vma adr; /* memory address of start of procedure */
+ long regmask; /* save register mask */
+ long regoffset; /* save register offset */
+ long fregmask; /* save floating point register mask */
+ long fregoffset; /* save floating point register offset */
+ long frameoffset; /* frame size */
+ short framereg; /* frame pointer register */
+ short pcreg; /* offset or reg of return pc */
+ long irpss; /* index into the runtime string table */
+ long reserved;
+ struct exception_info *exception_info;/* pointer to exception array */
+} RPDR, *pRPDR;
+#define cbRPDR sizeof(RPDR)
+#define rpdNil ((pRPDR) 0)
+#endif
+
+/*
+ * Line Numbers
+ *
+ * Line Numbers are segregated from the normal symbols because they
+ * are [1] smaller , [2] are of no interest to your
+ * average loader, and [3] are never needed in the middle of normal
+ * scanning and therefore slow things down.
+ *
+ * By definition, the first LINER for any given procedure will have
+ * the first line of a procedure and represent the first address.
+ */
+
+typedef long LINER, *pLINER;
+#define lineNil ((pLINER)0)
+#define cbLINER sizeof(LINER)
+#define ilineNil -1
+
+
+
+/*
+ * The Symbol Structure (GFW, to those who Know!)
+ */
+
+typedef struct {
+ long iss; /* index into String Space of name */
+ bfd_vma value; /* value of symbol */
+ unsigned st : 6; /* symbol type */
+ unsigned sc : 5; /* storage class - text, data, etc */
+ unsigned reserved : 1; /* reserved */
+ unsigned index : 20; /* index into sym/aux table */
+ } SYMR, *pSYMR;
+#define symNil ((pSYMR)0)
+#define cbSYMR sizeof(SYMR)
+#define isymNil -1
+#define indexNil 0xfffff
+#define issNil -1
+#define issNull 0
+
+
+/* The following converts a memory resident string to an iss.
+ * This hack is recognized in SbFIss, in sym.c of the debugger.
+ */
+#define IssFSb(sb) (0x80000000 | ((unsigned long)(sb)))
+
+/* E X T E R N A L S Y M B O L R E C O R D
+ *
+ * Same as the SYMR except it contains file context to determine where
+ * the index is.
+ */
+typedef struct ecoff_extr {
+ unsigned jmptbl:1; /* symbol is a jump table entry for shlibs */
+ unsigned cobol_main:1; /* symbol is a cobol main procedure */
+ unsigned weakext:1; /* symbol is weak external */
+ unsigned reserved:13; /* reserved for future use */
+ int ifd; /* where the iss and index fields point into */
+ SYMR asym; /* symbol for the external */
+ } EXTR, *pEXTR;
+#define extNil ((pEXTR)0)
+#define cbEXTR sizeof(EXTR)
+
+
+/* A U X I L L A R Y T Y P E I N F O R M A T I O N */
+
+/*
+ * Type Information Record
+ */
+typedef struct {
+ unsigned fBitfield : 1; /* set if bit width is specified */
+ unsigned continued : 1; /* indicates additional TQ info in next AUX */
+ unsigned bt : 6; /* basic type */
+ unsigned tq4 : 4;
+ unsigned tq5 : 4;
+ /* ---- 16 bit boundary ---- */
+ unsigned tq0 : 4;
+ unsigned tq1 : 4; /* 6 type qualifiers - tqPtr, etc. */
+ unsigned tq2 : 4;
+ unsigned tq3 : 4;
+ } TIR, *pTIR;
+#define cbTIR sizeof(TIR)
+#define tiNil ((pTIR)0)
+#define itqMax 6
+
+/*
+ * Relative symbol record
+ *
+ * If the rfd field is 4095, the index field indexes into the global symbol
+ * table.
+ */
+
+typedef struct {
+ unsigned rfd : 12; /* index into the file indirect table */
+ unsigned index : 20; /* index int sym/aux/iss tables */
+ } RNDXR, *pRNDXR;
+#define cbRNDXR sizeof(RNDXR)
+#define rndxNil ((pRNDXR)0)
+
+/* dense numbers or sometimes called block numbers are stored in this type,
+ * a rfd of 0xffffffff is an index into the global table.
+ */
+typedef struct {
+ unsigned long rfd; /* index into the file table */
+ unsigned long index; /* index int sym/aux/iss tables */
+ } DNR, *pDNR;
+#define cbDNR sizeof(DNR)
+#define dnNil ((pDNR)0)
+
+
+
+/*
+ * Auxillary information occurs only if needed.
+ * It ALWAYS occurs in this order when present.
+
+ isymMac used by stProc only
+ TIR type info
+ TIR additional TQ info (if first TIR was not enough)
+ rndx if (bt == btStruct,btUnion,btEnum,btSet,btRange,
+ btTypedef):
+ rsym.index == iaux for btSet or btRange
+ else rsym.index == isym
+ dimLow btRange, btSet
+ dimMac btRange, btSet
+ rndx0 As many as there are tq arrays
+ dimLow0
+ dimHigh0
+ ...
+ rndxMax-1
+ dimLowMax-1
+ dimHighMax-1
+ width in bits if (bit field), width in bits.
+ */
+#define cAuxMax (6 + (idimMax*3))
+
+/* a union of all possible info in the AUX universe */
+typedef union {
+ TIR ti; /* type information record */
+ RNDXR rndx; /* relative index into symbol table */
+ long dnLow; /* low dimension */
+ long dnHigh; /* high dimension */
+ long isym; /* symbol table index (end of proc) */
+ long iss; /* index into string space (not used) */
+ long width; /* width for non-default sized struc fields */
+ long count; /* count of ranges for variant arm */
+ } AUXU, *pAUXU;
+#define cbAUXU sizeof(AUXU)
+#define auxNil ((pAUXU)0)
+#define iauxNil -1
+
+
+/*
+ * Optimization symbols
+ *
+ * Optimization symbols contain some overlap information with the normal
+ * symbol table. In particular, the proc information
+ * is somewhat redundant but necessary to easily find the other information
+ * present.
+ *
+ * All of the offsets are relative to the beginning of the last otProc
+ */
+
+typedef struct {
+ unsigned ot: 8; /* optimization type */
+ unsigned value: 24; /* address where we are moving it to */
+ RNDXR rndx; /* points to a symbol or opt entry */
+ unsigned long offset; /* relative offset this occured */
+ } OPTR, *pOPTR;
+#define optNil ((pOPTR) 0)
+#define cbOPTR sizeof(OPTR)
+#define ioptNil -1
+
+/*
+ * File Indirect
+ *
+ * When a symbol is referenced across files the following procedure is used:
+ * 1) use the file index to get the File indirect entry.
+ * 2) use the file indirect entry to get the File descriptor.
+ * 3) add the sym index to the base of that file's sym table
+ *
+ */
+
+typedef long RFDT, *pRFDT;
+#define cbRFDT sizeof(RFDT)
+#define rfdNil -1
+
+/*
+ * The file indirect table in the mips loader is known as an array of FITs.
+ * This is done to keep the code in the loader readable in the area where
+ * these tables are merged. Note this is only a name change.
+ */
+typedef long FIT, *pFIT;
+#define cbFIT sizeof(FIT)
+#define ifiNil -1
+#define fiNil ((pFIT) 0)
+
+#ifdef _LANGUAGE_PASCAL
+#define ifdNil -1
+#define ilnNil -1
+#define ipdNil -1
+#define ilineNil -1
+#define isymNil -1
+#define indexNil 16#fffff
+#define issNil -1
+#define issNull 0
+#define itqMax 6
+#define iauxNil -1
+#define ioptNil -1
+#define rfdNil -1
+#define ifiNil -1
+#endif /* _LANGUAGE_PASCAL */
+
+
+/* Dense numbers
+ *
+ * Rather than use file index, symbol index pairs to represent symbols
+ * and globals, we use dense number so that they can be easily embeded
+ * in intermediate code and the programs that process them can
+ * use direct access tabls instead of hash table (which would be
+ * necesary otherwise because of the sparse name space caused by
+ * file index, symbol index pairs. Dense number are represented
+ * by RNDXRs.
+ */
+
+/*
+ * The following table defines the meaning of each SYM field as
+ * a function of the "st". (scD/B == scData OR scBss)
+ *
+ * Note: the value "isymMac" is used by symbols that have the concept
+ * of enclosing a block of related information. This value is the
+ * isym of the first symbol AFTER the end associated with the primary
+ * symbol. For example if a procedure was at isym==90 and had an
+ * isymMac==155, the associated end would be at isym==154, and the
+ * symbol at 155 would probably (although not necessarily) be the
+ * symbol for the next procedure. This allows rapid skipping over
+ * internal information of various sorts. "stEnd"s ALWAYS have the
+ * isym of the primary symbol that started the block.
+ *
+
+ST SC VALUE INDEX
+-------- ------ -------- ------
+stFile scText address isymMac
+stLabel scText address ---
+stGlobal scD/B address iaux
+stStatic scD/B address iaux
+stParam scAbs offset iaux
+stLocal scAbs offset iaux
+stProc scText address iaux (isymMac is first AUX)
+stStaticProc scText address iaux (isymMac is first AUX)
+
+stMember scNil ordinal --- (if member of enum)
+ (mipsread thinks the case below has a bit, not byte, offset.)
+stMember scNil byte offset iaux (if member of struct/union)
+stMember scBits bit offset iaux (bit field spec)
+
+stBlock scText address isymMac (text block)
+ (the code seems to think that rather than scNil, we see scInfo for
+ the two cases below.)
+stBlock scNil cb isymMac (struct/union member define)
+stBlock scNil cMembers isymMac (enum member define)
+
+ (New types added by SGI to simplify things:)
+stStruct scInfo cb isymMac (struct type define)
+stUnion scInfo cb isymMac (union type define)
+stEnum scInfo cMembers isymMac (enum type define)
+
+stEnd scText address isymStart
+stEnd scNil ------- isymStart (struct/union/enum)
+
+stTypedef scNil ------- iaux
+stRegReloc sc??? value old register number
+stForward sc??? new address isym to original symbol
+
+stConstant scInfo value --- (scalar)
+stConstant scInfo iss --- (complex, e.g. string)
+
+ *
+ */
+#endif
diff --git a/include/coff/symconst.h b/include/coff/symconst.h
new file mode 100644
index 00000000000..f40eef2a311
--- /dev/null
+++ b/include/coff/symconst.h
@@ -0,0 +1,177 @@
+/* Declarations of constants for internal format of MIPS ECOFF symbols.
+ Originally contributed by MIPS Computer Systems and Third Eye Software.
+ Changes contributed by Cygnus Support are in the public domain.
+
+ This file is just aggregated with the files that make up the GNU
+ release; it is not considered part of GAS, GDB, or other GNU
+ programs. */
+
+/*
+ * |-----------------------------------------------------------|
+ * | Copyright (c) 1992, 1991, 1990 MIPS Computer Systems, Inc.|
+ * | MIPS Computer Systems, Inc. grants reproduction and use |
+ * | rights to all parties, PROVIDED that this comment is |
+ * | maintained in the copy. |
+ * |-----------------------------------------------------------|
+ */
+
+/* (C) Copyright 1984 by Third Eye Software, Inc.
+ *
+ * Third Eye Software, Inc. grants reproduction and use rights to
+ * all parties, PROVIDED that this comment is maintained in the copy.
+ *
+ * Third Eye makes no claims about the applicability of this
+ * symbol table to a particular use.
+ */
+
+/* glevels for field in FDR */
+#define GLEVEL_0 2
+#define GLEVEL_1 1
+#define GLEVEL_2 0 /* for upward compat reasons. */
+#define GLEVEL_3 3
+
+/* magic number fo symheader */
+#define magicSym 0x7009
+/* The Alpha uses this value instead, for some reason. */
+#define magicSym2 0x1992
+
+/* Language codes */
+#define langC 0
+#define langPascal 1
+#define langFortran 2
+#define langAssembler 3 /* one Assembley inst might map to many mach */
+#define langMachine 4
+#define langNil 5
+#define langAda 6
+#define langPl1 7
+#define langCobol 8
+#define langStdc 9 /* FIXME: Collides with SGI langCplusplus */
+#define langCplusplus 9 /* FIXME: Collides with langStdc */
+#define langCplusplusV2 10 /* SGI addition */
+#define langMax 11 /* maximun allowed 32 -- 5 bits */
+
+/* The following are value definitions for the fields in the SYMR */
+
+/*
+ * Storage Classes
+ */
+
+#define scNil 0
+#define scText 1 /* text symbol */
+#define scData 2 /* initialized data symbol */
+#define scBss 3 /* un-initialized data symbol */
+#define scRegister 4 /* value of symbol is register number */
+#define scAbs 5 /* value of symbol is absolute */
+#define scUndefined 6 /* who knows? */
+#define scCdbLocal 7 /* variable's value is IN se->va.?? */
+#define scBits 8 /* this is a bit field */
+#define scCdbSystem 9 /* variable's value is IN CDB's address space */
+#define scDbx 9 /* overlap dbx internal use */
+#define scRegImage 10 /* register value saved on stack */
+#define scInfo 11 /* symbol contains debugger information */
+#define scUserStruct 12 /* address in struct user for current process */
+#define scSData 13 /* load time only small data */
+#define scSBss 14 /* load time only small common */
+#define scRData 15 /* load time only read only data */
+#define scVar 16 /* Var parameter (fortran,pascal) */
+#define scCommon 17 /* common variable */
+#define scSCommon 18 /* small common */
+#define scVarRegister 19 /* Var parameter in a register */
+#define scVariant 20 /* Variant record */
+#define scSUndefined 21 /* small undefined(external) data */
+#define scInit 22 /* .init section symbol */
+#define scBasedVar 23 /* Fortran or PL/1 ptr based var */
+#define scXData 24 /* exception handling data */
+#define scPData 25 /* Procedure section */
+#define scFini 26 /* .fini section */
+#define scRConst 27 /* .rconst section */
+#define scMax 32
+
+
+/*
+ * Symbol Types
+ */
+
+#define stNil 0 /* Nuthin' special */
+#define stGlobal 1 /* external symbol */
+#define stStatic 2 /* static */
+#define stParam 3 /* procedure argument */
+#define stLocal 4 /* local variable */
+#define stLabel 5 /* label */
+#define stProc 6 /* " " Procedure */
+#define stBlock 7 /* beginnning of block */
+#define stEnd 8 /* end (of anything) */
+#define stMember 9 /* member (of anything - struct/union/enum */
+#define stTypedef 10 /* type definition */
+#define stFile 11 /* file name */
+#define stRegReloc 12 /* register relocation */
+#define stForward 13 /* forwarding address */
+#define stStaticProc 14 /* load time only static procs */
+#define stConstant 15 /* const */
+#define stStaParam 16 /* Fortran static parameters */
+ /* These new symbol types have been recently added to SGI machines. */
+#define stStruct 26 /* Beginning of block defining a struct type */
+#define stUnion 27 /* Beginning of block defining a union type */
+#define stEnum 28 /* Beginning of block defining an enum type */
+#define stIndirect 34 /* Indirect type specification */
+ /* Pseudo-symbols - internal to debugger */
+#define stStr 60 /* string */
+#define stNumber 61 /* pure number (ie. 4 NOR 2+2) */
+#define stExpr 62 /* 2+2 vs. 4 */
+#define stType 63 /* post-coersion SER */
+#define stMax 64
+
+/* definitions for fields in TIR */
+
+/* type qualifiers for ti.tq0 -> ti.(itqMax-1) */
+#define tqNil 0 /* bt is what you see */
+#define tqPtr 1 /* pointer */
+#define tqProc 2 /* procedure */
+#define tqArray 3 /* duh */
+#define tqFar 4 /* longer addressing - 8086/8 land */
+#define tqVol 5 /* volatile */
+#define tqConst 6 /* const */
+#define tqMax 8
+
+/* basic types as seen in ti.bt */
+#define btNil 0 /* undefined (also, enum members) */
+#define btAdr 1 /* address - integer same size as pointer */
+#define btChar 2 /* character */
+#define btUChar 3 /* unsigned character */
+#define btShort 4 /* short */
+#define btUShort 5 /* unsigned short */
+#define btInt 6 /* int */
+#define btUInt 7 /* unsigned int */
+#define btLong 8 /* long */
+#define btULong 9 /* unsigned long */
+#define btFloat 10 /* float (real) */
+#define btDouble 11 /* Double (real) */
+#define btStruct 12 /* Structure (Record) */
+#define btUnion 13 /* Union (variant) */
+#define btEnum 14 /* Enumerated */
+#define btTypedef 15 /* defined via a typedef, isymRef points */
+#define btRange 16 /* subrange of int */
+#define btSet 17 /* pascal sets */
+#define btComplex 18 /* fortran complex */
+#define btDComplex 19 /* fortran double complex */
+#define btIndirect 20 /* forward or unnamed typedef */
+#define btFixedDec 21 /* Fixed Decimal */
+#define btFloatDec 22 /* Float Decimal */
+#define btString 23 /* Varying Length Character String */
+#define btBit 24 /* Aligned Bit String */
+#define btPicture 25 /* Picture */
+#define btVoid 26 /* void */
+#define btLongLong 27 /* long long */
+#define btULongLong 28 /* unsigned long long */
+#define btMax 64
+
+#if (_MFG == _MIPS)
+/* optimization type codes */
+#define otNil 0
+#define otReg 1 /* move var to reg */
+#define otBlock 2 /* begin basic block */
+#define otProc 3 /* procedure */
+#define otInline 4 /* inline procedure */
+#define otEnd 5 /* whatever you started */
+#define otMax 6 /* KEEP UP TO DATE */
+#endif /* (_MFG == _MIPS) */
diff --git a/include/coff/tic30.h b/include/coff/tic30.h
new file mode 100644
index 00000000000..10b026cebe2
--- /dev/null
+++ b/include/coff/tic30.h
@@ -0,0 +1,203 @@
+/*** coff information for Texas Instruments TMS320C3X */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+#define TIC30MAGIC 0xC000
+
+#define TIC30BADMAG(x) (((x).f_magic!=TIC30MAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[4]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the z8k don't have room in the instruction for the entire
+ offset - eg with segments */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_offset[4];
+ char r_type[2];
+ char r_stuff[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
+/* TMS320C30 relocation types. */
+
+#define R_TIC30_ABS16 0x100 /* 16 bit absolute. */
+#define R_TIC30_ABS24 0x101 /* 24 bit absolute. */
+#define R_TIC30_ABS32 0x102 /* 32 bit absolute. */
+#define R_TIC30_LDP 0x103 /* LDP bits 23-16 to 7-0. */
+#define R_TIC30_PC16 0x104 /* 16 bit pc relative. */
diff --git a/include/coff/tic80.h b/include/coff/tic80.h
new file mode 100644
index 00000000000..5d938f7b1f0
--- /dev/null
+++ b/include/coff/tic80.h
@@ -0,0 +1,228 @@
+/*** coff information for TI TMS320C80 (MVP) */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+ char f_target_id[2]; /* target id (TIc80 specific) */
+};
+
+#define TIC80_ARCH_MAGIC 0x0C1 /* Goes in the file header magic number field */
+#define TIC80_TARGET_ID 0x95 /* Goes in the target id field */
+
+#define TIC80BADMAG(x) ((x).f_magic != TIC80_ARCH_MAGIC)
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 22
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+#define TIC80_AOUTHDR_MAGIC 0x108 /* Goes in the optional file header magic number field */
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[2]; /* flags */
+ char s_reserved[1]; /* reserved (TIc80 specific) */
+ char s_mempage[1]; /* memory page number (TIc80) */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _CINIT ".cinit"
+#define _CONST ".const"
+#define _SWITCH ".switch"
+#define _STACK ".stack"
+#define _SYSMEM ".sysmem"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+/* FIXME - need to correlate with TIc80 Code Generation Tools User's Guide, CG:A-25 */
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the h8 don't have room in the instruction for the entire
+ offset - eg the strange jump and high page addressing modes */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_reserved[2];
+ char r_type[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 12
+
+/* TIc80 relocation types. */
+
+#define R_ABS 0x00 /* Absolute address - no relocation */
+#define R_RELLONGX 0x11 /* PP: 32 bits, direct */
+#define R_PPBASE 0x34 /* PP: Global base address type */
+#define R_PPLBASE 0x35 /* PP: Local base address type */
+#define R_PP15 0x38 /* PP: Global 15 bit offset */
+#define R_PP15W 0x39 /* PP: Global 15 bit offset divided by 4 */
+#define R_PP15H 0x3A /* PP: Global 15 bit offset divided by 2 */
+#define R_PP16B 0x3B /* PP: Global 16 bit offset for bytes */
+#define R_PPL15 0x3C /* PP: Local 15 bit offset */
+#define R_PPL15W 0x3D /* PP: Local 15 bit offset divided by 4 */
+#define R_PPL15H 0x3E /* PP: Local 15 bit offset divided by 2 */
+#define R_PPL16B 0x3F /* PP: Local 16 bit offset for bytes */
+#define R_PPN15 0x40 /* PP: Global 15 bit negative offset */
+#define R_PPN15W 0x41 /* PP: Global 15 bit negative offset divided by 4 */
+#define R_PPN15H 0x42 /* PP: Global 15 bit negative offset divided by 2 */
+#define R_PPN16B 0x43 /* PP: Global 16 bit negative byte offset */
+#define R_PPLN15 0x44 /* PP: Local 15 bit negative offset */
+#define R_PPLN15W 0x45 /* PP: Local 15 bit negative offset divided by 4 */
+#define R_PPLN15H 0x46 /* PP: Local 15 bit negative offset divided by 2 */
+#define R_PPLN16B 0x47 /* PP: Local 16 bit negative byte offset */
+#define R_MPPCR15W 0x4E /* MP: 15 bit PC-relative divided by 4 */
+#define R_MPPCR 0x4F /* MP: 32 bit PC-relative divided by 4 */
diff --git a/include/coff/w65.h b/include/coff/w65.h
new file mode 100644
index 00000000000..3378c2324d2
--- /dev/null
+++ b/include/coff/w65.h
@@ -0,0 +1,201 @@
+/*** coff information for WDC 65816 */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+
+#define W65MAGIC 0x6500
+
+
+#define W65BADMAG(x) (((x).f_magic!=W65MAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[4]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the w65 don't have room in the instruction for the entire
+ offset - eg the strange jump and high page addressing modes */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_offset[4];
+ char r_type[2];
+ char r_stuff[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
+
+
+
diff --git a/include/coff/we32k.h b/include/coff/we32k.h
new file mode 100644
index 00000000000..553fa35cdad
--- /dev/null
+++ b/include/coff/we32k.h
@@ -0,0 +1,206 @@
+/*** coff information for we32k */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+/* Bits for f_flags:
+ * F_RELFLG relocation info stripped from file
+ * F_EXEC file is executable (no unresolved external references)
+ * F_LNNO line numbers stripped from file
+ * F_LSYMS local symbols stripped from file
+ * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
+ */
+
+#define F_RELFLG (0x0001)
+#define F_EXEC (0x0002)
+#define F_LNNO (0x0004)
+#define F_LSYMS (0x0008)
+#define F_BM32B (0020000)
+#define F_BM32MAU (0040000)
+
+#define WE32KMAGIC 0x170 /* we32k sans transfer vector */
+#define FBOMAGIC 0x170 /* we32k sans transfer vector */
+#define MTVMAGIC 0x171 /* we32k with transfer vector */
+#define RBOMAGIC 0x172 /* reserved */
+#define WE32KBADMAG(x) (((x).f_magic != WE32KMAGIC) \
+ && ((x).f_magic != FBOMAGIC) \
+ && ((x).f_magic != RBOMAGIC) \
+ && ((x).f_magic != MTVMAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+#define AOUTSZ 28
+#define AOUTHDRSZ 28
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _TV ".tv"
+#define _INIT ".init"
+#define _FINI ".fini"
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[2]; /* line number */
+};
+
+
+#define LINENO struct external_lineno
+#define LINESZ 6
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+#define N_BTMASK (0xf)
+#define N_TMASK (0x30)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+# define _ETEXT "etext"
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_type[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 10
+
diff --git a/include/coff/z8k.h b/include/coff/z8k.h
new file mode 100644
index 00000000000..19b846ca2e1
--- /dev/null
+++ b/include/coff/z8k.h
@@ -0,0 +1,201 @@
+/*** coff information for Zilog Z800N */
+
+/********************** FILE HEADER **********************/
+
+struct external_filehdr {
+ char f_magic[2]; /* magic number */
+ char f_nscns[2]; /* number of sections */
+ char f_timdat[4]; /* time & date stamp */
+ char f_symptr[4]; /* file pointer to symtab */
+ char f_nsyms[4]; /* number of symtab entries */
+ char f_opthdr[2]; /* sizeof(optional hdr) */
+ char f_flags[2]; /* flags */
+};
+
+
+/* Type of cpu is stored in flags */
+#define F_Z8001 0x1000
+#define F_Z8002 0x2000
+#define F_MACHMASK 0xf000
+
+#define Z8KMAGIC 0x8000
+
+#define Z8KBADMAG(x) (((x).f_magic!=Z8KMAGIC))
+
+#define FILHDR struct external_filehdr
+#define FILHSZ 20
+
+
+/********************** AOUT "OPTIONAL HEADER" **********************/
+
+
+typedef struct
+{
+ char magic[2]; /* type of file */
+ char vstamp[2]; /* version stamp */
+ char tsize[4]; /* text size in bytes, padded to FW bdry*/
+ char dsize[4]; /* initialized data " " */
+ char bsize[4]; /* uninitialized data " " */
+ char entry[4]; /* entry pt. */
+ char text_start[4]; /* base of text used for this file */
+ char data_start[4]; /* base of data used for this file */
+}
+AOUTHDR;
+
+
+#define AOUTHDRSZ 28
+#define AOUTSZ 28
+
+
+
+
+/********************** SECTION HEADER **********************/
+
+
+struct external_scnhdr {
+ char s_name[8]; /* section name */
+ char s_paddr[4]; /* physical address, aliased s_nlib */
+ char s_vaddr[4]; /* virtual address */
+ char s_size[4]; /* section size */
+ char s_scnptr[4]; /* file ptr to raw data for section */
+ char s_relptr[4]; /* file ptr to relocation */
+ char s_lnnoptr[4]; /* file ptr to line numbers */
+ char s_nreloc[2]; /* number of relocation entries */
+ char s_nlnno[2]; /* number of line number entries*/
+ char s_flags[4]; /* flags */
+};
+
+/*
+ * names of "special" sections
+ */
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+
+
+#define SCNHDR struct external_scnhdr
+#define SCNHSZ 40
+
+
+/********************** LINE NUMBERS **********************/
+
+/* 1 line number entry for every "breakpointable" source line in a section.
+ * Line numbers are grouped on a per function basis; first entry in a function
+ * grouping will have l_lnno = 0 and in place of physical address will be the
+ * symbol table index of the function name.
+ */
+struct external_lineno {
+ union {
+ char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
+ char l_paddr[4]; /* (physical) address of line number */
+ } l_addr;
+ char l_lnno[4]; /* line number */
+};
+
+#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
+
+#define LINENO struct external_lineno
+#define LINESZ 8
+
+
+/********************** SYMBOLS **********************/
+
+#define E_SYMNMLEN 8 /* # characters in a symbol name */
+#define E_FILNMLEN 14 /* # characters in a file name */
+#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
+
+struct external_syment
+{
+ union {
+ char e_name[E_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+
+
+
+#define N_BTMASK (017)
+#define N_TMASK (060)
+#define N_BTSHFT (4)
+#define N_TSHIFT (2)
+
+
+union external_auxent {
+ struct {
+ char x_tagndx[4]; /* str, un, or enum tag indx */
+ union {
+ struct {
+ char x_lnno[2]; /* declaration line number */
+ char x_size[2]; /* str/union/array size */
+ } x_lnsz;
+ char x_fsize[4]; /* size of function */
+ } x_misc;
+ union {
+ struct { /* if ISFCN, tag, or .bb */
+ char x_lnnoptr[4]; /* ptr to fcn line # */
+ char x_endndx[4]; /* entry ndx past block end */
+ } x_fcn;
+ struct { /* if ISARY, up to 4 dimen. */
+ char x_dimen[E_DIMNUM][2];
+ } x_ary;
+ } x_fcnary;
+ char x_tvndx[2]; /* tv index */
+ } x_sym;
+
+ union {
+ char x_fname[E_FILNMLEN];
+ struct {
+ char x_zeroes[4];
+ char x_offset[4];
+ } x_n;
+ } x_file;
+
+ struct {
+ char x_scnlen[4]; /* section length */
+ char x_nreloc[2]; /* # relocation entries */
+ char x_nlinno[2]; /* # line numbers */
+ } x_scn;
+
+ struct {
+ char x_tvfill[4]; /* tv fill value */
+ char x_tvlen[2]; /* length of .tv */
+ char x_tvran[2][2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+
+
+};
+
+#define SYMENT struct external_syment
+#define SYMESZ 18
+#define AUXENT union external_auxent
+#define AUXESZ 18
+
+
+
+/********************** RELOCATION DIRECTIVES **********************/
+
+/* The external reloc has an offset field, because some of the reloc
+ types on the z8k don't have room in the instruction for the entire
+ offset - eg with segments */
+
+struct external_reloc {
+ char r_vaddr[4];
+ char r_symndx[4];
+ char r_offset[4];
+ char r_type[2];
+ char r_stuff[2];
+};
+
+
+#define RELOC struct external_reloc
+#define RELSZ 16
+
diff --git a/include/demangle.h b/include/demangle.h
new file mode 100644
index 00000000000..63fe5e2adf4
--- /dev/null
+++ b/include/demangle.h
@@ -0,0 +1,95 @@
+/* Defs for interface to demanglers.
+ Copyright 1992, 1995, 1996 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+#if !defined (DEMANGLE_H)
+#define DEMANGLE_H
+
+#include <ansidecl.h>
+
+/* Options passed to cplus_demangle (in 2nd parameter). */
+
+#define DMGL_NO_OPTS 0 /* For readability... */
+#define DMGL_PARAMS (1 << 0) /* Include function args */
+#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
+#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */
+
+#define DMGL_AUTO (1 << 8)
+#define DMGL_GNU (1 << 9)
+#define DMGL_LUCID (1 << 10)
+#define DMGL_ARM (1 << 11)
+#define DMGL_HP (1 << 12) /* For the HP aCC compiler; same as ARM
+ except for template arguments, etc. */
+#define DMGL_EDG (1 << 13)
+
+/* If none of these are set, use 'current_demangling_style' as the default. */
+#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG)
+
+/* Enumeration of possible demangling styles.
+
+ Lucid and ARM styles are still kept logically distinct, even though
+ they now both behave identically. The resulting style is actual the
+ union of both. I.E. either style recognizes both "__pt__" and "__rf__"
+ for operator "->", even though the first is lucid style and the second
+ is ARM style. (FIXME?) */
+
+extern enum demangling_styles
+{
+ unknown_demangling = 0,
+ auto_demangling = DMGL_AUTO,
+ gnu_demangling = DMGL_GNU,
+ lucid_demangling = DMGL_LUCID,
+ arm_demangling = DMGL_ARM,
+ hp_demangling = DMGL_HP,
+ edg_demangling = DMGL_EDG
+} current_demangling_style;
+
+/* Define string names for the various demangling styles. */
+
+#define AUTO_DEMANGLING_STYLE_STRING "auto"
+#define GNU_DEMANGLING_STYLE_STRING "gnu"
+#define LUCID_DEMANGLING_STYLE_STRING "lucid"
+#define ARM_DEMANGLING_STYLE_STRING "arm"
+#define HP_DEMANGLING_STYLE_STRING "hp"
+#define EDG_DEMANGLING_STYLE_STRING "edg"
+
+/* Some macros to test what demangling style is active. */
+
+#define CURRENT_DEMANGLING_STYLE current_demangling_style
+#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
+#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
+#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
+#define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
+#define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
+#define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
+
+extern char *
+cplus_demangle PARAMS ((const char *mangled, int options));
+
+extern int
+cplus_demangle_opname PARAMS ((const char *opname, char *result, int options));
+
+extern const char *
+cplus_mangle_opname PARAMS ((const char *opname, int options));
+
+/* Note: This sets global state. FIXME if you care about multi-threading. */
+
+extern void
+set_cplus_marker_for_demangling PARAMS ((int ch));
+
+#endif /* DEMANGLE_H */
diff --git a/include/dis-asm.h b/include/dis-asm.h
new file mode 100644
index 00000000000..666ed690152
--- /dev/null
+++ b/include/dis-asm.h
@@ -0,0 +1,243 @@
+/* Interface between the opcode library and its callers.
+ Written by Cygnus Support, 1993.
+
+ The opcode library (libopcodes.a) provides instruction decoders for
+ a large variety of instruction sets, callable with an identical
+ interface, for making instruction-processing programs more independent
+ of the instruction set being processed. */
+
+#ifndef DIS_ASM_H
+#define DIS_ASM_H
+
+#include <stdio.h>
+#include "bfd.h"
+
+typedef int (*fprintf_ftype) PARAMS((PTR, const char*, ...));
+
+enum dis_insn_type {
+ dis_noninsn, /* Not a valid instruction */
+ dis_nonbranch, /* Not a branch instruction */
+ dis_branch, /* Unconditional branch */
+ dis_condbranch, /* Conditional branch */
+ dis_jsr, /* Jump to subroutine */
+ dis_condjsr, /* Conditional jump to subroutine */
+ dis_dref, /* Data reference instruction */
+ dis_dref2 /* Two data references in instruction */
+};
+
+/* This struct is passed into the instruction decoding routine,
+ and is passed back out into each callback. The various fields are used
+ for conveying information from your main routine into your callbacks,
+ for passing information into the instruction decoders (such as the
+ addresses of the callback functions), or for passing information
+ back from the instruction decoders to their callers.
+
+ It must be initialized before it is first passed; this can be done
+ by hand, or using one of the initialization macros below. */
+
+typedef struct disassemble_info {
+ fprintf_ftype fprintf_func;
+ PTR stream;
+ PTR application_data;
+
+ /* Target description. We could replace this with a pointer to the bfd,
+ but that would require one. There currently isn't any such requirement
+ so to avoid introducing one we record these explicitly. */
+ /* The bfd_flavour. This can be bfd_target_unknown_flavour. */
+ enum bfd_flavour flavour;
+ /* The bfd_arch value. */
+ enum bfd_architecture arch;
+ /* The bfd_mach value. */
+ unsigned long mach;
+ /* Endianness (for bi-endian cpus). Mono-endian cpus can ignore this. */
+ enum bfd_endian endian;
+
+ /* An array of pointers to symbols either at the location being disassembled
+ or at the start of the function being disassembled. The array is sorted
+ so that the first symbol is intended to be the one used. The others are
+ present for any misc. purposes. This is not set reliably, but if it is
+ not NULL, it is correct. */
+ asymbol **symbols;
+ /* Number of symbols in array. */
+ int num_symbols;
+
+ /* For use by the disassembler.
+ The top 16 bits are reserved for public use (and are documented here).
+ The bottom 16 bits are for the internal use of the disassembler. */
+ unsigned long flags;
+#define INSN_HAS_RELOC 0x80000000
+ PTR private_data;
+
+ /* Function used to get bytes to disassemble. MEMADDR is the
+ address of the stuff to be disassembled, MYADDR is the address to
+ put the bytes in, and LENGTH is the number of bytes to read.
+ INFO is a pointer to this struct.
+ Returns an errno value or 0 for success. */
+ int (*read_memory_func)
+ PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int length,
+ struct disassemble_info *info));
+
+ /* Function which should be called if we get an error that we can't
+ recover from. STATUS is the errno value from read_memory_func and
+ MEMADDR is the address that we were trying to read. INFO is a
+ pointer to this struct. */
+ void (*memory_error_func)
+ PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info));
+
+ /* Function called to print ADDR. */
+ void (*print_address_func)
+ PARAMS ((bfd_vma addr, struct disassemble_info *info));
+
+ /* Function called to determine if there is a symbol at the given ADDR.
+ If there is, the function returns 1, otherwise it returns 0.
+ This is used by ports which support an overlay manager where
+ the overlay number is held in the top part of an address. In
+ some circumstances we want to include the overlay number in the
+ address, (normally because there is a symbol associated with
+ that address), but sometimes we want to mask out the overlay bits. */
+ int (* symbol_at_address_func)
+ PARAMS ((bfd_vma addr, struct disassemble_info * info));
+
+ /* These are for buffer_read_memory. */
+ bfd_byte *buffer;
+ bfd_vma buffer_vma;
+ int buffer_length;
+
+ /* This variable may be set by the instruction decoder. It suggests
+ the number of bytes objdump should display on a single line. If
+ the instruction decoder sets this, it should always set it to
+ the same value in order to get reasonable looking output. */
+ int bytes_per_line;
+
+ /* the next two variables control the way objdump displays the raw data */
+ /* For example, if bytes_per_line is 8 and bytes_per_chunk is 4, the */
+ /* output will look like this:
+ 00: 00000000 00000000
+ with the chunks displayed according to "display_endian". */
+ int bytes_per_chunk;
+ enum bfd_endian display_endian;
+
+ /* Results from instruction decoders. Not all decoders yet support
+ this information. This info is set each time an instruction is
+ decoded, and is only valid for the last such instruction.
+
+ To determine whether this decoder supports this information, set
+ insn_info_valid to 0, decode an instruction, then check it. */
+
+ char insn_info_valid; /* Branch info has been set. */
+ char branch_delay_insns; /* How many sequential insn's will run before
+ a branch takes effect. (0 = normal) */
+ char data_size; /* Size of data reference in insn, in bytes */
+ enum dis_insn_type insn_type; /* Type of instruction */
+ bfd_vma target; /* Target address of branch or dref, if known;
+ zero if unknown. */
+ bfd_vma target2; /* Second target address for dref2 */
+
+} disassemble_info;
+
+
+/* Standard disassemblers. Disassemble one instruction at the given
+ target address. Return number of bytes processed. */
+typedef int (*disassembler_ftype)
+ PARAMS((bfd_vma, disassemble_info *));
+
+extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_little_mips PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_i386_att PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_i386_intel PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_m68k PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_z8001 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_z8002 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_h8300 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_h8300h PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_h8300s PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_h8500 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_alpha PARAMS ((bfd_vma, disassemble_info*));
+extern disassembler_ftype arc_get_disassembler PARAMS ((int, int));
+extern int print_insn_big_arm PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_little_arm PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_sparc PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_big_a29k PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_little_a29k PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_i960 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_sh PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_shl PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_hppa PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_fr30 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_m32r PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_m88k PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_mcore PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_mn10200 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_mn10300 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_ns32k PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_big_powerpc PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_w65 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_d10v PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_d30v PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_v850 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_tic30 PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_vax PARAMS ((bfd_vma, disassemble_info*));
+extern int print_insn_tic80 PARAMS ((bfd_vma, disassemble_info*));
+
+/* Fetch the disassembler for a given BFD, if that support is available. */
+extern disassembler_ftype disassembler PARAMS ((bfd *));
+
+
+/* This block of definitions is for particular callers who read instructions
+ into a buffer before calling the instruction decoder. */
+
+/* Here is a function which callers may wish to use for read_memory_func.
+ It gets bytes from a buffer. */
+extern int buffer_read_memory
+ PARAMS ((bfd_vma, bfd_byte *, int, struct disassemble_info *));
+
+/* This function goes with buffer_read_memory.
+ It prints a message using info->fprintf_func and info->stream. */
+extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *));
+
+
+/* Just print the address in hex. This is included for completeness even
+ though both GDB and objdump provide their own (to print symbolic
+ addresses). */
+extern void generic_print_address
+ PARAMS ((bfd_vma, struct disassemble_info *));
+
+/* Always true. */
+extern int generic_symbol_at_address
+ PARAMS ((bfd_vma, struct disassemble_info *));
+
+/* Macro to initialize a disassemble_info struct. This should be called
+ by all applications creating such a struct. */
+#define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC) \
+ (INFO).flavour = bfd_target_unknown_flavour, \
+ (INFO).arch = bfd_arch_unknown, \
+ (INFO).mach = 0, \
+ (INFO).endian = BFD_ENDIAN_UNKNOWN, \
+ INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC)
+
+/* Call this macro to initialize only the internal variables for the
+ disassembler. Architecture dependent things such as byte order, or machine
+ variant are not touched by this macro. This makes things much easier for
+ GDB which must initialize these things seperatly. */
+
+#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
+ (INFO).fprintf_func = (fprintf_ftype)(FPRINTF_FUNC), \
+ (INFO).stream = (PTR)(STREAM), \
+ (INFO).symbols = NULL, \
+ (INFO).num_symbols = 0, \
+ (INFO).buffer = NULL, \
+ (INFO).buffer_vma = 0, \
+ (INFO).buffer_length = 0, \
+ (INFO).read_memory_func = buffer_read_memory, \
+ (INFO).memory_error_func = perror_memory, \
+ (INFO).print_address_func = generic_print_address, \
+ (INFO).symbol_at_address_func = generic_symbol_at_address, \
+ (INFO).flags = 0, \
+ (INFO).bytes_per_line = 0, \
+ (INFO).bytes_per_chunk = 0, \
+ (INFO).display_endian = BFD_ENDIAN_UNKNOWN, \
+ (INFO).insn_info_valid = 0
+
+#endif /* ! defined (DIS_ASM_H) */
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
new file mode 100644
index 00000000000..deaccd412e2
--- /dev/null
+++ b/include/elf/ChangeLog
@@ -0,0 +1,719 @@
+1999-04-21 Nick Clifton <nickc@cygnus.com>
+
+ * reloc-macros.h (START_RELOC_NUMBERS): Prepend an underscore to
+ fake reloc entry name (if possible), in order to avoid conflicts
+ with typedefs of the same name.
+
+1999-04-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips.h (EF_MIPS_32BITMODE): New.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * mcore.h: New header file. Defines for Motorolla's MCore
+ processor.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * common.h: Add new constants defined in: "System V Application
+ Binary Interface - DRAFT - April 29, 1998" found at the web site:
+ http://www.sco.com/developer/gabi/contents.html
+
+ (EM_MMA): Removed. Replaced with EM_MCORE as Motorolla own this
+ value.
+
+1999-03-31 Nick Clifton <nickc@cygnus.com>
+
+ * reloc-macros.h: Fixed to not generate an enum with a trailing
+ comma.
+
+1999-03-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips.h (E_MIPS_MACH_5000): New.
+
+1999-03-10 Ulrich Drepper <drepper@cygnus.com>
+
+ * common.h: Add definitions for a few more Solaris ELF extensions.
+
+Thu Feb 18 18:58:26 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * external.h: Only use attribute if __GNUC__ is defined.
+
+1999-02-17 Nick Clifton <nickc@cygnus.com>
+
+ Patch submitted by: Scott Bambrough <scottb@corelcomputer.com>
+
+ * elf/external.h: struct Elf_External_Versym must be packed on
+ ARM. Code uses sizeof(Elf_External_Versym) and assumes it is
+ equal to sizeof(char[2]). Reported by Jim Pick <jim@jimpick.com>
+
+1999-02-02 Nick Clifton <nickc@cygnus.com>
+
+ * dwarf2.h (DWARF2_External_ARange): New structure.
+ (DWARF2_Internal_ARange): New structure.
+
+Mon Feb 1 11:33:56 1999 Catherine Moore <clm@cygnus.com>
+
+ * arm.h: Renumber relocs to conform to standard.
+ (EF_NEW_ABI): Define.
+ (EF_OLD_ABI): Define.
+ * arm-oabi.h: New file.
+
+1999-01-28 Nick Clifton <nickc@cygnus.com>
+
+ * fr30.h: Add R_FR30_GNU_VT{INHERIT,ENTRY} relocs.
+
+1999-01-27 Nick Clifton <nickc@cygnus.com>
+
+ * dwarf2.h: Add typedefs for structures found in dwarf2 sections.
+
+1998-12-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips.h (E_MIPS_MACH_4111): New.
+
+1998-12-15 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips.h (EF_MIPS_ABI,E_MIPS_ABI_O32,E_MIPS_ABI_O64,
+ E_MIPS_ABI_EABI32,E_MIPS_ABI_EABI64):
+
+1998-12-03 Nick Clifton <nickc@cygnus.com>
+
+ * fr30.h: Add R_FR30_48 reloc.
+
+1998-12-02 Ulrich Drepper <drepper@cygnus.com>
+
+ * mips.h: Add external data type for conflict section.
+
+ * mips.h: Add more LL_* options from Irix 6.5.
+
+ * mips.h: Add R_MIPS_JALR and adjust R_MIPS_max appropriately.
+
+Tue Nov 10 15:12:28 1998 Nick Clifton <nickc@cygnus.com>
+
+ * common.h (EM_CYGNUS_FR30): Reduce to a 16 bit value.
+
+Tue Nov 10 15:17:28 1998 Catherine Moore <clm@cygnus.com>
+
+ * d10v.h: Add vtable relocs.
+
+Wed Nov 4 15:56:50 1998 Nick Clifton <nickc@cygnus.com>
+
+ * common.h (EM_CYGNUS_FR30): New machine number.
+
+ * fr30.h: New file: Definitions for the FR30.
+
+Fri Oct 30 11:54:15 1998 Catherine Moore <clm@cygnus.com>
+
+ From Philip Blundell <pb@nexus.co.uk>:
+ * arm.h (R_ARM_COPY, et al.): New relocs, used by Linux for PIC.
+ (EF_ALIGN8): New flag.
+
+Tue Oct 20 11:19:50 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * common.h (NT_LWPSTATUS): Close comment accidentally left open.
+
+Mon Oct 19 20:24:11 1998 Catherine Moore <clm@cygnus.com>
+
+ * sh.h: Add vtable relocs.
+
+Mon Oct 19 01:44:42 1998 Felix Lee <flee@cygnus.com>
+
+ * common.h (NT_PSTATUS, NT_FPREGS, NT_PSINFO,
+ NT_LWPSTATUS,NT_LWPSINFO): added.
+ * internal.h (Elf_Internal_Note): new structure members.
+
+Fri Oct 16 14:11:25 1998 Catherine Moore <clm@cygnus.com>
+
+ * m32r.h: Add vtable relocs.
+
+Tue Oct 6 09:22:22 1998 Catherine Moore <clm@cygnus.com>
+
+ * sparc.h: Add vtable relocs.
+
+Mon Oct 5 09:39:22 1998 Catherine Moore <clm@cygnus.com>
+
+ * v850.h: Add vtable relocs.
+
+Sun Oct 4 21:17:51 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h (R_386_max): Change from 252 to 24.
+
+Mon Sep 21 12:24:44 1998 Catherine Moore <clm@cygnus.com>
+
+ * i386.h: Change vtable reloc numbers.
+
+Sun Sep 20 00:54:22 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k.h: Add vtable relocs and R_68K_max.
+
+Tue Sep 15 09:56:49 CDT 1998 Catherine Moore <clm@cygnus.com>
+
+ * arm.h: Add vtable relocs.
+
+Mon Aug 31 11:25:27 1998 Catherine Moore <clm@cygnus.com>
+
+ * arm.h: Define STT_ARM_TFUNC. Remove ST_THUMB_xxxx
+ definitions.
+
+Sat Aug 29 22:25:51 1998 Richard Henderson <rth@cygnus.com>
+
+ * i386.h: Add vtable relocs.
+
+1998-08-25 16:42 Ulrich Drepper <drepper@cygnus.com>
+
+ * common.h: Add SYMINFO_* macros to access Elf*_Syminfo information.
+
+ * external.h: Add Elf_External_Syminfo definition.
+
+ * internal.h: Add Elf_Internal_Syminfo, Elf32_Internal_Syminfo,
+ and Elf64_Syminfo definitions.
+
+Sun Aug 9 20:26:49 CDT 1998 Catherine Moore <clm@cygnus.com>
+
+ * arm.h: Add ST_THUMB definitions.
+
+Wed Aug 5 15:52:35 1998 Nick Clifton <nickc@cygnus.com>
+
+ * arm.h: Add ELF header flags to specify compile time optins:
+ EF_INTERWORK: New flag.
+ EF_APCS_26: New flag.
+ EF_APCS_FLOAT: New flag.
+ EF_PIC: New flag.
+
+1998-07-31 21:28 Ulrich Drepper <drepper@cygnus.com>
+
+ * mips.h: Add missing RHF_* constants.
+
+Fri Jul 31 10:01:40 1998 Catherine Moore <clm@cygnus.com>
+
+ * arm.h: Add R_ARM_THM_PC9 relocation.
+
+1998-07-30 16:25 Ulrich Drepper <drepper@cygnus.com>
+
+ * common.h: Add new DT_* entries and there flag macros from Solaris.
+
+Tue Jul 28 18:14:07 1998 Stan Cox <scox@equinox.cygnus.com>
+
+ * sparc.h: (R_SPARC_REV32): Added for little endian data e.g. sparc 86x.
+
+Fri Jul 24 11:22:06 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h: Add R_MN10300_24 relocation.
+
+1998-07-24 Ulrich Drepper <drepper@cygnus.com>
+
+ * mips.h: Add MIPS64 relocation names and values.
+
+Wed Jul 22 19:29:00 Catherine Moore <clm@cygnus.com>
+
+ * arm.h: Rename relocations.
+
+1998-07-22 Ulrich Drepper <drepper@cygnus.com>
+
+ * ppc.h: Define enum as elf_ppc_reloc_type.
+
+Wed Jul 22 16:22:11 1998 Nick Clifton <nickc@cygnus.com>
+
+ * reloc-macros.h: New file. Provides relocation macros:
+ START_RELOC_NUMBERS, RELOC_NUMBER, FAKE_RELOC, EMPTY_RELOC and
+ END_RELOC_NUMBERS used by other elf header files.
+
+ * alpha.h: Use reloc-macros.h.
+ * arc.h: Use reloc-macros.h.
+ * arm.h: Use reloc-macros.h.
+ * d10v.h: Use reloc-macros.h.
+ * d30v.h: Use reloc-macros.h.
+ * hppa.h: Use reloc-macros.h.
+ * i386.h: Use reloc-macros.h.
+ * m32r.h: Use reloc-macros.h.
+ * m68k.h: Use reloc-macros.h.
+ * mips.h: Use reloc-macros.h.
+ * mn10200.h: Use reloc-macros.h.
+ * mn10300.h: Use reloc-macros.h.
+ * ppc.h: Use reloc-macros.h.
+ * sh.h: Use reloc-macros.h.
+ * sparc.h: Use reloc-macros.h.
+ * v850.h: Use reloc-macros.h.
+
+1998-07-22 13:07 Ulrich Drepper <drepper@cygnus.com>
+
+ * mn10300.h: Rewrite relocation definition using macros.
+ * mips.h: Likewise.
+ * ppc.h: Likewise.
+ * alpha.h: Likewise.
+ * arm.h: Likewise.
+ * d10v.h: Likewise.
+ * d30v.h: Likewise.
+ * m32r.h: Likewise.
+ * m68k.h: Likewise.
+ * mn10200.h: Likewise.
+ * sh.h: Likewise.
+ * sparc.h: Likewise.
+
+1998-07-21 13:07 Ulrich Drepper <drepper@cygnus.com>
+
+ * arm.h: New file.
+ * d10v.h: New file.
+ * d30v.h: New file.
+ * i386.h: New file.
+ * m68k.h: New file.
+ * mn10200.h: New file.
+ * sh.h: New file.
+
+ * mips.h: Add R_MIPS_* and SHT_MIPS_* entries.
+
+ * mn10300.h: Add R_MN10300_* entries.
+
+ * ppc.h: Add R_PPC_* entries.
+
+1998-07-20 07:11 Ulrich Drepper <drepper@cygnus.com>
+
+ * mips.h: Add ODK_*, OEX_*, OPAD_*, OHW_*, and OGP_* constants.
+ Define Elf32_External_Lib.
+
+1998-07-19 15:24 Ulrich Drepper <drepper@cygnus.com>
+
+ * mips.h (PT_MIPS_OPTIONS): New symbol.
+ Add lots of DT_MIPS_* symbols.
+
+Fri Jun 26 10:46:35 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h: New file.
+
+Thu Jun 18 19:27:56 1998 Nick Clifton <nickc@cygnus.com>
+
+ * common.h (EM_960, EM_V800, EM_FR20, EM_RH32, EM_MMA,
+ EM_OLD_ALPHA): Add these constants.
+
+Thu Jun 11 17:59:01 1998 Nick Clifton <nickc@cygnus.com>
+
+ * common.h (EM_486, EM_S370): Add these constants.
+
+Tue Jun 9 09:35:29 1998 Nick Clifton <nickc@cygnus.com>
+
+ * common.h (EM_ARM): Add this constant.
+
+Wed May 6 09:45:30 1998 Gavin Koch <gavin@cygnus.com>
+
+ * mips.h (EF_MIPS_MACH,E_MIPS_MACH_*): Added.
+
+Sat Apr 25 18:35:06 1998 Richard Henderson <rth@cygnus.com>
+
+ * alpha.h (STO_ALPHA_NOPV, STO_ALPHA_STD_GPLOAD): New.
+
+Wed Apr 15 15:42:45 1998 Richard Henderson <rth@cygnus.com>
+
+ * common.h (EM_SPARC64): Move and rename to EM_OLD_SPARCV9.
+ (EM_SPARCV9): New. This is the official ABI name and number.
+
+Sat Feb 28 17:04:41 1998 Richard Henderson <rth@cygnus.com>
+
+ * alpha.h (EF_ALPHA_32BIT, EF_ALPHA_CANRELAX): New.
+
+Mon Dec 15 15:07:49 1997 Nick Clifton <nickc@cygnus.com>
+
+ * m32r.h (EF_M32R_ARCH, E_M32R_ARCH): New flags to
+ specify machine architecture.
+
+Fri Dec 5 11:20:08 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h: New constants: SHN_V850_SCOMMON, SHN_V850_TCOMMON,
+ SHN_V850_ZCOMMON, SHT_V850_SCOMMON, SHT_V850_TCOMMON,
+ SHT_V850_ZCOMMON to handle v850 common sections.
+ enum reloc_type renamed to v850_reloc_type to avoid name
+ conflict.
+
+Thu Oct 23 13:55:24 1997 Richard Henderson <rth@cygnus.com>
+
+ * sparc.h (enum elf_sparc_reloc_type): Add UA64 & UA16.
+
+Thu Oct 23 00:42:04 1997 Richard Henderson <rth@dot.cygnus.com>
+
+ * sparc.h (DT_SPARC_REGISTER): New macro.
+ (DT_SPARC_PLTFMT): In support of old sparc64-linux .plts; will
+ go away soon.
+
+Tue Sep 30 13:26:58 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (EF_SPARC_HAL_R1, EF_SPARC_EXT_MASK): New macros.
+ (EF_SPARCV9_{MM,TSO,PSO,RMO}): New macros.
+ (SHN_BEFORE,SHN_AFTER): New macros.
+ (SHF_EXCLUDE,SHF_ORDERED): New macros.
+ (STT_REGISTER): New macro.
+ (R_SPARC_GLOB_JMP): Deleted, but slot reserved.
+ (R_SPARC_{DISP64,PLT64,HIX22,LOX10}): New relocations.
+ (R_SPARC_{H44,M44,L44,REGISTER}): New relocations.
+ (ELF64_R_TYPE_{DATA,ID,INFO}): New macros.
+
+Wed Sep 17 16:41:42 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h: Add R_V850_CALLT_6_7_OFFSET and R_V850_CALLT_16_16_OFFSET.
+
+Tue Sep 16 14:16:17 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (reloc_type): Add R_V850_TDA_16_16_OFFSET.
+
+Wed Sep 3 15:11:14 1997 Richard Henderson <rth@cygnus.com>
+
+ * mips.h: Correct typo in comment.
+
+Wed Sep 3 11:25:57 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (reloc_type): Remove R_V850_16_PCREL.
+
+Tue Sep 2 17:41:05 1997 Nick Clifton <nickc@cygnus.com>
+
+ * common.h: Remove magic number for V850E.
+ * common.h: Remove magic number for V850EA.
+ * v850.h: Add new flags for e_flags field in elf header.
+
+Mon Aug 25 16:06:47 1997 Nick Clifton <nickc@cygnus.com>
+
+ * common.h (EM_CYGNUS_V850E): backend magic number for v850e.
+ * common.h (EM_CYGNUS_V850EA): backend magic number for v850ea.
+
+Mon Aug 18 11:05:23 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (reloc_type): Add 16 bit PC relative relocation.
+
+Fri Aug 15 05:10:09 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * arc.h (enum reloc): Move here from elf32-arc.c.
+
+Fri Aug 8 17:05:29 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * arc.h: New file.
+ * common.h (EM_CYGNUS_ARC): Define.
+
+Mon Jun 16 14:46:12 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (Elf_Internal_Ehdr): Change e_phoff and e_shoff from
+ bfd_signed_vma to bfd_size_type, as they are not signed.
+
+Wed Mar 5 15:35:26 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * m32r.h (SHF_M32R_CAN_RELAX): Define.
+
+Mon Feb 24 17:49:01 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * external.h: Dump the 32/64 bit specific forms of the version
+ structures, and just define them as size independent.
+
+ * common.h (VERSYM_HIDDEN, VERSYM_VERSION): Define.
+
+Fri Feb 21 13:00:34 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * m32r.h (enum reloc_type): Add R_M32R_SDA16.
+ (SHN_M32R_SCOMMON): Define.
+
+Wed Feb 19 15:35:31 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Eric Youngdale <eric@andante.jic.com>:
+ * external.h, internal.h, common.h: Added new structures and
+ definitions for ELF versions.
+
+Tue Feb 18 17:40:36 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * common.h (EM_CYGNUS_D30V): Define.
+
+Mon Jan 27 11:54:44 1997 Doug Evans <dje@seba.cygnus.com>
+
+ * m32r.h (enum reloc_type): Add R_M32R_HI16_[SU]LO,R_M32R_LO16.
+
+Fri Jan 3 11:32:51 1997 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * v850.h (V850_OTHER_{TDA_BYTE,ERROR}): New bits for the st_other
+ field.
+ (SHN_V850_*): Remove v850 specific section indexes, which are not
+ needed.
+ (enum reloc_type): Move the v850 relocations here from
+ elf32-v850.c
+
+Thu Jan 2 19:30:23 1997 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * v850.h: New file, provide V850 specific definitions.
+
+Tue Dec 31 14:44:32 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * common.h (DT_AUXILIARY): Define.
+ (DT_FILTER): Define.
+
+Wed Dec 4 05:03:37 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * dwarf2.h: Update.
+
+Tue Nov 26 10:44:47 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (STO_MIPS16): Define.
+
+Tue Nov 12 15:45:42 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h: Remove empty file.
+
+Tue Oct 8 11:31:24 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (EF_MIPS_ABI2): Define.
+
+Thu Oct 3 10:01:40 1996 Jeffrey A Law (law@cygnus.com)
+
+ * common.h: Break mn10x00 support into mn10200 and mn10300.
+
+Wed Oct 2 21:26:43 1996 Jeffrey A Law (law@cygnus.com)
+
+ * common.h (EM_CYGNUS_MN10x00): Define.
+
+Mon Sep 23 09:18:04 1996 Doug Evans <dje@seba.cygnus.com>
+
+ * m32r.h: New file.
+
+Fri Aug 30 17:06:21 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * common.h (EM_SH): Define.
+
+Tue Aug 20 14:47:54 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * common.h (EM_CYGNUS_V850): Define.
+
+Mon Aug 19 10:59:10 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * common.h (EM_CYGNUS_M32R): Define.
+
+Mon Jul 22 18:59:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (SHT_MIPS_IFACE, SHT_MIPS_CONTENT): Define.
+ (SHT_MIPS_SYMBOL_LIB): Define.
+ (SHF_MIPS_MERGE, SHF_MIPS_ADDR32, SHF_MIPS_ADDR64): Define.
+ (SHF_MIPS_NOSTRIP, SHF_MIPS_LOCAL, SHF_MIPS_NAMES): Define.
+
+Thu Jul 18 19:12:15 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * dwarf2.h: New file.
+
+Jul 18 13:20:39 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * common.h (EM_CYGNUS_D10V): Define.
+ * d10v.h: New file.
+
+Fri Jun 21 12:33:24 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha.h: New file.
+ * common.h (EM_ALPHA): Define.
+
+Fri May 31 17:28:05 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (Elf_External_Options, Elf_Internal_Options): Define.
+ (bfd_mips_elf_swap_options_in): Declare.
+ (bfd_mips_elf_swap_options_out): Declare.
+ (ODK_*): Define.
+ (Elf64_External_RegInfo, Elf64_Internal_RegInfo): Define.
+ (bfd_mips_elf64_swap_reginfo_in): Declare.
+ (bfd_mips_elf64_swap_reginfo_out): Declare.
+
+Thu May 30 12:35:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (E_MIPS_ARCH_4): Define.
+
+Wed May 29 15:35:33 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (Elf64_Mips_External_Rel): Define.
+ (Elf64_Mips_Internal_Rel): Define.
+ (Elf64_Mips_External_Rela, Elf64_Mips_Internal_Rela): Define.
+ (RSS_*): Define.
+
+Mon Apr 22 18:26:30 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (R_SPARC_[56]): Always define.
+
+Mon Feb 19 01:55:56 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (R_SPARC_{PLT32,HIPLT22,LOPLT10,PCPLT32,PCPLT22,
+ PCPLT10,5,6}): Don't define ifdef SPARC64_OLD_RELOCS.
+
+Tue Feb 6 11:33:58 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (enum sparc_elf_reloc_type): Define.
+
+Wed Jan 17 09:09:16 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * common.h: Define EM_SPARC32PLUS.
+ * sparc.h: New file.
+
+Thu Jan 11 16:27:34 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc.h (SHF_EXCLUDE, SHT_ORDERED): New fields from the abi.
+
+Thu Nov 30 16:47:18 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (struct elf_segment_map): Add includes_filehdr and
+ includes_phdrs fields.
+
+Tue Nov 28 16:58:10 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * internal.h (struct elf_segment_map): Define.
+
+Tue Oct 31 15:19:36 1995 Fred Fish <fnf@cygnus.com>
+
+ * common.h, dwarf.h, external.h, hppa.h, internal.h,
+ mips.h, ppc.h: Protect against multiple inclusions.
+
+Thu Sep 21 13:51:58 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc.h (EF_PPC_RELOCATABLE_LIB): Add new flag bit.
+
+Fri Sep 1 15:32:17 1995 Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>
+
+ * mips.h: Add some definitions used on Irix 5.
+
+Tue Jun 20 10:18:28 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppa.h (CPU_PA_RISC1_0): Protect from redefinitions.
+ (CPU_PA_RISC1_1): Likewise.
+
+Wed Mar 8 18:14:37 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc.h: New file for PowerPC support.
+
+Tue Feb 14 13:59:13 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * common.h (EM_PPC): Use offical value of 20, not 17.
+ (EM_PPC_OLD): Define this to be the old value of EM_PPC.
+
+Tue Jan 24 09:40:59 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * common.h (EM_PPC): New macro, PowerPC machine id.
+
+Tue Jan 17 10:51:38 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * mips.h (SHT_MIPS_MSYM, SHT_MIPS_DWARF, SHT_MIPS_EVENTS): Define.
+
+Mon Oct 17 13:43:59 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * internal.h (Elf_Internal_Shdr): Remove rawdata and size fields.
+ Add bfd_section field.
+
+Tue May 24 16:11:50 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (Elf32_External_gptab): Define.
+
+Mon May 16 13:22:04 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * common.h (EM_HPPA): Delete.
+ (EM_PARISC): Add.
+ * hppa.h: New file.
+
+Mon May 9 13:27:03 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * common.h (SHN_LORESERVE): Rename from SHN_LORESERV.
+ (ELF32_R_TYPE, ELF32_R_INFO): Don't rely on size of unsigned char.
+ (ELF64_R_TYPE): Don't rely on size of unsigned long.
+
+Mon Apr 25 15:53:09 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * internal.h (Elf_Internal_Shdr): Use PTR, not void *.
+
+Fri Mar 11 00:34:59 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * mips.h (SHN_MIPS_TEXT, SHN_MIPS_DATA): Define.
+
+Sat Mar 5 14:08:54 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * internal.h: Remove Elf32_*, Elf64_* typedefs. These names
+ cause conflicts with system headers, e.g. link.h in gdb/solib.c.
+ Combine 32- and 64-bit versions of *_Internal_Dyn.
+ * common.h: Replace uses of Elf64_Word, Elf64_Xword typedefs
+ by their expansion.
+ * mips.h: Replace uses of Elf32_Word, Elf32_Sword, Elf32_Addr
+ typedefs by their expansion. Add DT_MIPS_RLD_MAP definition.
+
+Fri Feb 18 10:39:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * common.h (EM_CYGNUS_POWERPC): Define. This may be temporary,
+ depending upon how quickly I can find a real PowerPC ABI.
+
+Mon Feb 7 08:27:13 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * internal.h: Change HOST_64_BIT to BFD_HOST_64_BIT.
+
+Wed Feb 2 14:12:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * common.h: Add comments regarding value of EM_HPPA and how to
+ pick an unofficial value.
+
+Wed Nov 17 17:14:26 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (SHT_MIPS_OPTIONS): Define.
+
+Mon Nov 8 17:57:00 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h: Added some more MIPS ABI macro definitions.
+
+Wed Nov 3 22:07:17 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * common.h (EM_MIPS_RS4_BE): New macro.
+
+Tue Oct 12 07:28:18 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h: New file. MIPS ABI specific information.
+
+Mon Jun 21 13:13:43 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * internal.h: Combined 32- and 64-bit versions of all structures
+ except *_Internal_Dyn. This will simply the assembler interface,
+ and some bfd code.
+
+Tue May 25 02:00:16 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * external.h, internal.h, common.h: Added 64-bit versions of some
+ structures and macros. Renamed old versions to put "32" in the
+ name. Some are unchanged.
+
+Thu Apr 29 12:12:20 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * common.h (EM_HPPA, NT_VERSION, STN_UNDEF, DT_*): New macros.
+ * external.h (Elf_External_Dyn): New type.
+
+ * internal.h (Elf_Intenral_Shdr): New field `size'.
+ (Elf_Internal_Dyn): New type.
+
+Tue Apr 20 16:03:45 1993 Fred Fish (fnf@cygnus.com)
+
+ * dwarf.h (LANG_CHILL): Change value to one randomly picked in
+ the user defined range, to reduce probability of collisions.
+
+Sun Nov 15 09:34:02 1992 Fred Fish (fnf@cygnus.com)
+
+ * dwarf.h (AT_src_coords): Whitespace change only.
+ * dwarf.h (AT_body_begin, AT_body_end, LANG_MODULA2):
+ Add from latest gcc.
+ * dwarf.h (LANG_CHILL): Add as GNU extension.
+
+Sat Aug 1 13:46:53 1992 Fred Fish (fnf@cygnus.com)
+
+ * dwarf.h: Replace with current version from gcc distribution.
+
+Fri Jun 19 19:05:09 1992 John Gilmore (gnu at cygnus.com)
+
+ * internal.h: Add real struct tags to all the Type_Defs, so they
+ can be used in prototypes where the Type_Defs are not known.
+
+Fri Apr 3 20:58:58 1992 Mark Eichin (eichin at cygnus.com)
+
+ * common.h: added ELF_R_{SYM,TYPE,INFO} for handling relocation
+ info
+ added EM_MIPS, and corrected value of EM_860 based on System V ABI
+ manual.
+
+ * external.h: added Elf_External_{Rel,Rela}.
+
+ * internal.h: added Elf_Internal_{Rel,Rela}.
+ added rawdata to Elf_Internal_Shdr.
+
+Sat Nov 30 20:43:59 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * common.h, dwarf.h, external.h, internal.h, ChangeLog; moved from
+ ../elf-<foo>
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/include/elf/alpha.h b/include/elf/alpha.h
new file mode 100644
index 00000000000..1ae9d5efd6d
--- /dev/null
+++ b/include/elf/alpha.h
@@ -0,0 +1,108 @@
+/* ALPHA ELF support for BFD.
+ Copyright (C) 1996, 1998 Free Software Foundation, Inc.
+
+ By Eric Youngdale, <eric@aib.com>. No processor supplement available
+ for this platform.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the ALPHA ELF ABI. Note
+ that most of this is not actually implemented by BFD. */
+
+#ifndef _ELF_ALPHA_H
+#define _ELF_ALPHA_H
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* All addresses must be below 2GB. */
+#define EF_ALPHA_32BIT 0x00000001
+
+/* All relocations needed for relaxation with code movement are present. */
+#define EF_ALPHA_CANRELAX 0x00000002
+
+/* Processor specific section flags. */
+
+/* This section must be in the global data area. */
+#define SHF_ALPHA_GPREL 0x10000000
+
+/* Section contains some sort of debugging information. The exact
+ format is unspecified. It's probably ECOFF symbols. */
+#define SHT_ALPHA_DEBUG 0x70000001
+
+/* Section contains register usage information. */
+#define SHT_ALPHA_REGINFO 0x70000002
+
+/* A section of type SHT_MIPS_REGINFO contains the following
+ structure. */
+typedef struct
+{
+ /* Mask of general purpose registers used. */
+ unsigned long ri_gprmask;
+ /* Mask of co-processor registers used. */
+ unsigned long ri_cprmask[4];
+ /* GP register value for this object file. */
+ long ri_gp_value;
+} Elf64_RegInfo;
+
+/* Special values for the st_other field in the symbol table. */
+
+#define STO_ALPHA_NOPV 0x80
+#define STO_ALPHA_STD_GPLOAD 0x88
+
+#include "elf/reloc-macros.h"
+
+/* Alpha relocs. */
+START_RELOC_NUMBERS (elf_alpha_reloc_type)
+ RELOC_NUMBER (R_ALPHA_NONE, 0) /* No reloc */
+ RELOC_NUMBER (R_ALPHA_REFLONG, 1) /* Direct 32 bit */
+ RELOC_NUMBER (R_ALPHA_REFQUAD, 2) /* Direct 64 bit */
+ RELOC_NUMBER (R_ALPHA_GPREL32, 3) /* GP relative 32 bit */
+ RELOC_NUMBER (R_ALPHA_LITERAL, 4) /* GP relative 16 bit w/optimization */
+ RELOC_NUMBER (R_ALPHA_LITUSE, 5) /* Optimization hint for LITERAL */
+ RELOC_NUMBER (R_ALPHA_GPDISP, 6) /* Add displacement to GP */
+ RELOC_NUMBER (R_ALPHA_BRADDR, 7) /* PC+4 relative 23 bit shifted */
+ RELOC_NUMBER (R_ALPHA_HINT, 8) /* PC+4 relative 16 bit shifted */
+ RELOC_NUMBER (R_ALPHA_SREL16, 9) /* PC relative 16 bit */
+ RELOC_NUMBER (R_ALPHA_SREL32, 10) /* PC relative 32 bit */
+ RELOC_NUMBER (R_ALPHA_SREL64, 11) /* PC relative 64 bit */
+
+/* Inherited these from ECOFF, but they are not particularly useful
+ and are depreciated. And not implemented in the BFD, btw. */
+ RELOC_NUMBER (R_ALPHA_OP_PUSH, 12) /* OP stack push */
+ RELOC_NUMBER (R_ALPHA_OP_STORE, 13) /* OP stack pop and store */
+ RELOC_NUMBER (R_ALPHA_OP_PSUB, 14) /* OP stack subtract */
+ RELOC_NUMBER (R_ALPHA_OP_PRSHIFT, 15) /* OP stack right shift */
+
+ RELOC_NUMBER (R_ALPHA_GPVALUE, 16)
+ RELOC_NUMBER (R_ALPHA_GPRELHIGH, 17)
+ RELOC_NUMBER (R_ALPHA_GPRELLOW, 18)
+ RELOC_NUMBER (R_ALPHA_IMMED_GP_16, 19)
+ RELOC_NUMBER (R_ALPHA_IMMED_GP_HI32, 20)
+ RELOC_NUMBER (R_ALPHA_IMMED_SCN_HI32, 21)
+ RELOC_NUMBER (R_ALPHA_IMMED_BR_HI32, 22)
+ RELOC_NUMBER (R_ALPHA_IMMED_LO32, 23)
+
+/* These relocations are specific to shared libraries. */
+ RELOC_NUMBER (R_ALPHA_COPY, 24) /* Copy symbol at runtime */
+ RELOC_NUMBER (R_ALPHA_GLOB_DAT, 25) /* Create GOT entry */
+ RELOC_NUMBER (R_ALPHA_JMP_SLOT, 26) /* Create PLT entry */
+ RELOC_NUMBER (R_ALPHA_RELATIVE, 27) /* Adjust by program base */
+
+ EMPTY_RELOC (R_ALPHA_max)
+END_RELOC_NUMBERS
+
+#endif /* _ELF_ALPHA_H */
diff --git a/include/elf/arc.h b/include/elf/arc.h
new file mode 100644
index 00000000000..334b55fa6d0
--- /dev/null
+++ b/include/elf/arc.h
@@ -0,0 +1,54 @@
+/* ARC ELF support for BFD.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ Contributed by Doug Evans, (dje@cygnus.com)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the ARC ELF ABI. */
+
+#ifndef _ELF_ARC_H
+#define _ELF_ARC_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_arc_reloc_type)
+ RELOC_NUMBER (R_ARC_NONE, 0)
+ RELOC_NUMBER (R_ARC_32, 1)
+ RELOC_NUMBER (R_ARC_B26, 2)
+ RELOC_NUMBER (R_ARC_B22_PCREL, 3)
+ EMPTY_RELOC (R_ARC_max)
+END_RELOC_NUMBERS
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* Four bit ARC machine type field. */
+#define EF_ARC_MACH 0x0000000f
+
+/* Various CPU types. */
+#define E_ARC_MACH_BASE 0x00000000
+#define E_ARC_MACH_UNUSED1 0x00000001
+#define E_ARC_MACH_UNUSED2 0x00000002
+#define E_ARC_MACH_UNUSED4 0x00000003
+
+/* Leave bits 0xf0 alone in case we ever have more than 16 cpu types.
+ Highly unlikely, but what the heck. */
+
+/* File contains position independent code. */
+#define EF_ARC_PIC 0x00000100
+
+#endif /* _ELF_ARC_H */
diff --git a/include/elf/arm-oabi.h b/include/elf/arm-oabi.h
new file mode 100644
index 00000000000..6109842e83d
--- /dev/null
+++ b/include/elf/arm-oabi.h
@@ -0,0 +1,87 @@
+/* ARM ELF support for BFD.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_ARM_H
+#define _ELF_ARM_H
+
+#include "elf/reloc-macros.h"
+
+/* Processor specific flags for the ELF header e_flags field. */
+#define EF_ARM_RELEXEC 0x01
+#define EF_ARM_HASENTRY 0x02
+#define EF_INTERWORK 0x04
+#define EF_APCS_26 0x08
+#define EF_APCS_FLOAT 0x10
+#define EF_PIC 0x20
+#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */
+#define EF_NEW_ABI 0x80
+#define EF_OLD_ABI 0x100
+
+/* Local aliases for some flags to match names used by COFF port. */
+#define F_INTERWORK EF_INTERWORK
+#define F_APCS26 EF_APCS_26
+#define F_APCS_FLOAT EF_APCS_FLOAT
+#define F_PIC EF_PIC
+
+/* Additional symbol types for Thumb */
+#define STT_ARM_TFUNC 0xd
+
+/* ARM-specific values for sh_flags */
+#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point */
+#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step */
+
+/* ARM-specific program header flags */
+#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base */
+
+/* Relocation types. */
+START_RELOC_NUMBERS (elf_arm_reloc_type)
+ RELOC_NUMBER (R_ARM_NONE, 0)
+ RELOC_NUMBER (R_ARM_PC24, 1)
+ RELOC_NUMBER (R_ARM_ABS32, 2)
+ RELOC_NUMBER (R_ARM_REL32, 3)
+ RELOC_NUMBER (R_ARM_ABS8, 4)
+ RELOC_NUMBER (R_ARM_ABS16, 5)
+ RELOC_NUMBER (R_ARM_ABS12, 6)
+ RELOC_NUMBER (R_ARM_THM_ABS5, 7)
+ RELOC_NUMBER (R_ARM_THM_PC22, 8)
+ RELOC_NUMBER (R_ARM_SBREL32, 9)
+ RELOC_NUMBER (R_ARM_AMP_VCALL9, 10)
+ RELOC_NUMBER (R_ARM_THM_PC11, 11) /* cygnus extension to abi: thumb unconditional branch */
+ RELOC_NUMBER (R_ARM_THM_PC9, 12) /* cygnus extension to abi: thumb conditional branch */
+ RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 13)
+ RELOC_NUMBER (R_ARM_GNU_VTENTRY, 14)
+ RELOC_NUMBER (R_ARM_COPY, 20) /* copy symbol at runtime */
+ RELOC_NUMBER (R_ARM_GLOB_DAT, 21) /* create GOT entry */
+ RELOC_NUMBER (R_ARM_JUMP_SLOT, 22) /* create PLT entry */
+ RELOC_NUMBER (R_ARM_RELATIVE, 23) /* adjust by program base */
+ RELOC_NUMBER (R_ARM_GOTOFF, 24) /* 32 bit offset to GOT */
+ RELOC_NUMBER (R_ARM_GOTPC, 25) /* 32 bit PC relative offset to GOT */
+ RELOC_NUMBER (R_ARM_GOT32, 26) /* 32 bit GOT entry */
+ RELOC_NUMBER (R_ARM_PLT32, 27) /* 32 bit PLT address */
+ FAKE_RELOC (FIRST_INVALID_RELOC, 28)
+ FAKE_RELOC (LAST_INVALID_RELOC, 249)
+ RELOC_NUMBER (R_ARM_RSBREL32, 250)
+ RELOC_NUMBER (R_ARM_THM_RPC22, 251)
+ RELOC_NUMBER (R_ARM_RREL32, 252)
+ RELOC_NUMBER (R_ARM_RABS32, 253)
+ RELOC_NUMBER (R_ARM_RPC24, 254)
+ RELOC_NUMBER (R_ARM_RBASE, 255)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/arm.h b/include/elf/arm.h
new file mode 100644
index 00000000000..2c94b13e204
--- /dev/null
+++ b/include/elf/arm.h
@@ -0,0 +1,96 @@
+/* ARM ELF support for BFD.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_ARM_H
+#define _ELF_ARM_H
+
+#include "elf/reloc-macros.h"
+
+/* Processor specific flags for the ELF header e_flags field. */
+#define EF_ARM_RELEXEC 0x01
+#define EF_ARM_HASENTRY 0x02
+#define EF_INTERWORK 0x04
+#define EF_APCS_26 0x08
+#define EF_APCS_FLOAT 0x10
+#define EF_PIC 0x20
+#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */
+#define EF_NEW_ABI 0x80
+#define EF_OLD_ABI 0x100
+
+/* Local aliases for some flags to match names used by COFF port. */
+#define F_INTERWORK EF_INTERWORK
+#define F_APCS26 EF_APCS_26
+#define F_APCS_FLOAT EF_APCS_FLOAT
+#define F_PIC EF_PIC
+
+/* Additional symbol types for Thumb */
+#define STT_ARM_TFUNC 0xd
+
+/* ARM-specific values for sh_flags */
+#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point */
+#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step */
+
+/* ARM-specific program header flags */
+#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base */
+
+/* Relocation types. */
+START_RELOC_NUMBERS (elf_arm_reloc_type)
+ RELOC_NUMBER (R_ARM_NONE, 0)
+ RELOC_NUMBER (R_ARM_PC24, 1)
+ RELOC_NUMBER (R_ARM_ABS32, 2)
+ RELOC_NUMBER (R_ARM_REL32, 3)
+ RELOC_NUMBER (R_ARM_PC13, 4)
+ RELOC_NUMBER (R_ARM_ABS16, 5)
+ RELOC_NUMBER (R_ARM_ABS12, 6)
+ RELOC_NUMBER (R_ARM_THM_ABS5, 7)
+ RELOC_NUMBER (R_ARM_ABS8, 8)
+ RELOC_NUMBER (R_ARM_SBREL32, 9)
+ RELOC_NUMBER (R_ARM_THM_PC22, 10)
+ RELOC_NUMBER (R_ARM_THM_PC8, 11)
+ RELOC_NUMBER (R_ARM_AMP_VCALL9, 12)
+ RELOC_NUMBER (R_ARM_SWI24, 13)
+ RELOC_NUMBER (R_ARM_THM_SWI8, 14)
+ RELOC_NUMBER (R_ARM_XPC25, 15)
+ RELOC_NUMBER (R_ARM_THM_XPC22, 16)
+ RELOC_NUMBER (R_ARM_COPY, 20) /* copy symbol at runtime */
+ RELOC_NUMBER (R_ARM_GLOB_DAT, 21) /* create GOT entry */
+ RELOC_NUMBER (R_ARM_JUMP_SLOT, 22) /* create PLT entry */
+ RELOC_NUMBER (R_ARM_RELATIVE, 23) /* adjust by program base */
+ RELOC_NUMBER (R_ARM_GOTOFF, 24) /* 32 bit offset to GOT */
+ RELOC_NUMBER (R_ARM_GOTPC, 25) /* 32 bit PC relative offset to GOT */
+ RELOC_NUMBER (R_ARM_GOT32, 26) /* 32 bit GOT entry */
+ RELOC_NUMBER (R_ARM_PLT32, 27) /* 32 bit PLT address */
+ FAKE_RELOC (FIRST_INVALID_RELOC1, 28)
+ FAKE_RELOC (LAST_INVALID_RELOC1, 99)
+ RELOC_NUMBER (R_ARM_GNU_VTENTRY, 100)
+ RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 101)
+ RELOC_NUMBER (R_ARM_THM_PC11, 102) /* cygnus extension to abi: thumb unconditional branch */
+ RELOC_NUMBER (R_ARM_THM_PC9, 103) /* cygnus extension to abi: thumb conditional branch */
+ FAKE_RELOC (FIRST_INVALID_RELOC2, 104)
+ FAKE_RELOC (LAST_INVALID_RELOC2, 248)
+ RELOC_NUMBER (R_ARM_RXPC25, 249)
+ RELOC_NUMBER (R_ARM_RSBREL32, 250)
+ RELOC_NUMBER (R_ARM_THM_RPC22, 251)
+ RELOC_NUMBER (R_ARM_RREL32, 252)
+ RELOC_NUMBER (R_ARM_RABS32, 253)
+ RELOC_NUMBER (R_ARM_RPC24, 254)
+ RELOC_NUMBER (R_ARM_RBASE, 255)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/common.h b/include/elf/common.h
new file mode 100644
index 00000000000..cda3ba0d9d5
--- /dev/null
+++ b/include/elf/common.h
@@ -0,0 +1,454 @@
+/* ELF support for BFD.
+ Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, from information published
+ in "UNIX System V Release 4, Programmers Guide: ANSI C and
+ Programming Support Tools".
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of ELF support for BFD, and contains the portions
+ that are common to both the internal and external representations.
+ For example, ELFMAG0 is the byte 0x7F in both the internal (in-memory)
+ and external (in-file) representations. */
+
+#ifndef _ELF_COMMON_H
+#define _ELF_COMMON_H
+
+/* Fields in e_ident[] */
+
+#define EI_MAG0 0 /* File identification byte 0 index */
+#define ELFMAG0 0x7F /* Magic number byte 0 */
+
+#define EI_MAG1 1 /* File identification byte 1 index */
+#define ELFMAG1 'E' /* Magic number byte 1 */
+
+#define EI_MAG2 2 /* File identification byte 2 index */
+#define ELFMAG2 'L' /* Magic number byte 2 */
+
+#define EI_MAG3 3 /* File identification byte 3 index */
+#define ELFMAG3 'F' /* Magic number byte 3 */
+
+#define EI_CLASS 4 /* File class */
+#define ELFCLASSNONE 0 /* Invalid class */
+#define ELFCLASS32 1 /* 32-bit objects */
+#define ELFCLASS64 2 /* 64-bit objects */
+
+#define EI_DATA 5 /* Data encoding */
+#define ELFDATANONE 0 /* Invalid data encoding */
+#define ELFDATA2LSB 1 /* 2's complement, little endian */
+#define ELFDATA2MSB 2 /* 2's complement, big endian */
+
+#define EI_VERSION 6 /* File version */
+
+#define EI_OSABI 7 /* Operating System/ABI indication */
+#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
+#define ELFOSABI_HPUX 1 /* HP-UX operating system */
+#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
+
+#define EI_ABIVERSION 8 /* ABI version */
+
+#define EI_PAD 9 /* Start of padding bytes */
+
+
+/* Values for e_type, which identifies the object file type */
+
+#define ET_NONE 0 /* No file type */
+#define ET_REL 1 /* Relocatable file */
+#define ET_EXEC 2 /* Executable file */
+#define ET_DYN 3 /* Shared object file */
+#define ET_CORE 4 /* Core file */
+#define ET_LOOS 0xFE00 /* Operating system-specific */
+#define ET_HIOS 0xFEFF /* Operating system-specific */
+#define ET_LOPROC 0xFF00 /* Processor-specific */
+#define ET_HIPROC 0xFFFF /* Processor-specific */
+
+/* Values for e_machine, which identifies the architecture */
+
+#define EM_NONE 0 /* No machine */
+#define EM_M32 1 /* AT&T WE 32100 */
+#define EM_SPARC 2 /* SUN SPARC */
+#define EM_386 3 /* Intel 80386 */
+#define EM_68K 4 /* Motorola m68k family */
+#define EM_88K 5 /* Motorola m88k family */
+#define EM_486 6 /* Intel 80486 */
+#define EM_860 7 /* Intel 80860 */
+#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
+#define EM_S370 9 /* Amdahl */
+#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
+
+#define EM_PARISC 15 /* HPPA */
+#define EM_VPP550 17 /* Fujitsu VPP500 */
+#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
+#define EM_960 19 /* Intel 80960 */
+#define EM_PPC 20 /* PowerPC */
+
+#define EM_V800 36 /* NEC V800 series */
+#define EM_FR20 37 /* Fujitsu FR20 */
+#define EM_RH32 38 /* TRW RH32 */
+#define EM_MCORE 39 /* Motorolla MCore */ /* May also be taken by Fujitsu MMA */
+#define EM_ARM 40 /* ARM */
+#define EM_OLD_ALPHA 41 /* Digital Alpha */
+#define EM_SH 42 /* Hitachi SH */
+#define EM_SPARCV9 43 /* SPARC v9 64-bit */
+#define EM_TRICORE 44 /* Siemens Tricore embedded processor */
+#define EM_ARC 45 /* Argonaut RISC Core, Argonaut Technologies Inc. */
+#define EM_H8_300 46 /* Hitachi H8/300 */
+#define EM_H8_300H 47 /* Hitachi H8/300H */
+#define EM_H8S 48 /* Hitachi H8S */
+#define EM_H8_500 49 /* Hitachi H8/500 */
+#define EM_IA_64 50 /* Intel MercedTM Processor */
+#define EM_MIPS_X 51 /* Stanford MIPS-X */
+#define EM_COLDFIRE 52 /* Motorola Coldfire */
+#define EM_68HC12 53 /* Motorola M68HC12 */
+
+/* If it is necessary to assign new unofficial EM_* values, please pick large
+ random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
+ with official or non-GNU unofficial values.
+
+ NOTE: Do not just increment the most recent number by one.
+ Somebody else somewhere will do exactly the same thing, and you
+ will have a collision. Instead, pick a random number. */
+
+/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */
+#define EM_CYGNUS_POWERPC 0x9025
+
+/* Old version of Sparc v9, from before the ABI; this should be
+ removed shortly. */
+#define EM_OLD_SPARCV9 11
+
+/* Old version of PowerPC, this should be removed shortly. */
+#define EM_PPC_OLD 17
+
+/* Cygnus ARC ELF backend. Written in the absence of an ABI. */
+#define EM_CYGNUS_ARC 0x9040
+
+/* Cygnus M32R ELF backend. Written in the absence of an ABI. */
+#define EM_CYGNUS_M32R 0x9041
+
+/* Alpha backend magic number. Written in the absence of an ABI. */
+#define EM_ALPHA 0x9026
+
+/* D10V backend magic number. Written in the absence of an ABI. */
+#define EM_CYGNUS_D10V 0x7650
+
+/* D30V backend magic number. Written in the absence of an ABI. */
+#define EM_CYGNUS_D30V 0x7676
+
+/* V850 backend magic number. Written in the absense of an ABI. */
+#define EM_CYGNUS_V850 0x9080
+
+/* mn10200 and mn10300 backend magic numbers.
+ Written in the absense of an ABI. */
+#define EM_CYGNUS_MN10200 0xdead
+#define EM_CYGNUS_MN10300 0xbeef
+
+/* FR30 magic number - no EABI available. */
+#define EM_CYGNUS_FR30 0x3330
+
+/* See the above comment before you add a new EM_* value here. */
+
+/* Values for e_version */
+
+#define EV_NONE 0 /* Invalid ELF version */
+#define EV_CURRENT 1 /* Current version */
+
+/* Values for program header, p_type field */
+
+#define PT_NULL 0 /* Program header table entry unused */
+#define PT_LOAD 1 /* Loadable program segment */
+#define PT_DYNAMIC 2 /* Dynamic linking information */
+#define PT_INTERP 3 /* Program interpreter */
+#define PT_NOTE 4 /* Auxiliary information */
+#define PT_SHLIB 5 /* Reserved, unspecified semantics */
+#define PT_PHDR 6 /* Entry for header table itself */
+#define PT_LOOS 0x60000000 /* OS-specific */
+#define PT_HIOS 0x6fffffff /* OS-specific */
+#define PT_LOPROC 0x70000000 /* Processor-specific */
+#define PT_HIPROC 0x7FFFFFFF /* Processor-specific */
+
+/* Program segment permissions, in program header p_flags field */
+
+#define PF_X (1 << 0) /* Segment is executable */
+#define PF_W (1 << 1) /* Segment is writable */
+#define PF_R (1 << 2) /* Segment is readable */
+#define PF_MASKOS 0x0F000000 /* OS-specific reserved bits */
+#define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
+
+/* Values for section header, sh_type field */
+
+#define SHT_NULL 0 /* Section header table entry unused */
+#define SHT_PROGBITS 1 /* Program specific (private) data */
+#define SHT_SYMTAB 2 /* Link editing symbol table */
+#define SHT_STRTAB 3 /* A string table */
+#define SHT_RELA 4 /* Relocation entries with addends */
+#define SHT_HASH 5 /* A symbol hash table */
+#define SHT_DYNAMIC 6 /* Information for dynamic linking */
+#define SHT_NOTE 7 /* Information that marks file */
+#define SHT_NOBITS 8 /* Section occupies no space in file */
+#define SHT_REL 9 /* Relocation entries, no addends */
+#define SHT_SHLIB 10 /* Reserved, unspecified semantics */
+#define SHT_DYNSYM 11 /* Dynamic linking symbol table */
+
+#define SHT_LOOS 0x60000000 /* Operating system specific semantics, lo */
+#define SHT_HIOS 0x6fffffff /* Operating system specific semantics, hi */
+
+/* The next three section types are defined by Solaris, and are named
+ SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU*
+ versions. */
+#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */
+#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */
+#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */
+
+#define SHT_GNU_verdef SHT_SUNW_verdef
+#define SHT_GNU_verneed SHT_SUNW_verneed
+#define SHT_GNU_versym SHT_SUNW_versym
+
+#define SHT_LOPROC 0x70000000 /* Processor-specific semantics, lo */
+#define SHT_HIPROC 0x7FFFFFFF /* Processor-specific semantics, hi */
+#define SHT_LOUSER 0x80000000 /* Application-specific semantics */
+#define SHT_HIUSER 0x8FFFFFFF /* Application-specific semantics */
+
+/* Values for section header, sh_flags field */
+
+#define SHF_WRITE (1 << 0) /* Writable data during execution */
+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
+#define SHF_EXECINSTR (1 << 2) /* Executable machine instructions */
+#define SHF_MASKOS 0x0F000000 /* OS-specific semantics */
+#define SHF_MASKPROC 0xF0000000 /* Processor-specific semantics */
+
+/* Values of note segment descriptor types for core files. */
+
+#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
+#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
+#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
+
+/* Note segments for core files on dir-style procfs systems. */
+
+#define NT_PSTATUS 10 /* Has a struct pstatus */
+#define NT_FPREGS 12 /* Has a struct fpregset */
+#define NT_PSINFO 13 /* Has a struct psinfo */
+#define NT_LWPSTATUS 16 /* Has a struct lwpstatus_t */
+#define NT_LWPSINFO 17 /* Has a struct lwpsinfo_t */
+
+/* Values of note segment descriptor types for object files. */
+/* (Only for hppa right now. Should this be moved elsewhere?) */
+
+#define NT_VERSION 1 /* Contains a version string. */
+
+/* These three macros disassemble and assemble a symbol table st_info field,
+ which contains the symbol binding and symbol type. The STB_ and STT_
+ defines identify the binding and type. */
+
+#define ELF_ST_BIND(val) (((unsigned int)(val)) >> 4)
+#define ELF_ST_TYPE(val) ((val) & 0xF)
+#define ELF_ST_INFO(bind,type) (((bind) << 4) + ((type) & 0xF))
+
+#define STN_UNDEF 0 /* undefined symbol index */
+
+#define STB_LOCAL 0 /* Symbol not visible outside obj */
+#define STB_GLOBAL 1 /* Symbol visible outside obj */
+#define STB_WEAK 2 /* Like globals, lower precedence */
+#define STB_LOOS 10 /* OS-specific semantics */
+#define STB_HIOS 12 /* OS-specific semantics */
+#define STB_LOPROC 13 /* Application-specific semantics */
+#define STB_HIPROC 15 /* Application-specific semantics */
+
+#define STT_NOTYPE 0 /* Symbol type is unspecified */
+#define STT_OBJECT 1 /* Symbol is a data object */
+#define STT_FUNC 2 /* Symbol is a code object */
+#define STT_SECTION 3 /* Symbol associated with a section */
+#define STT_FILE 4 /* Symbol gives a file name */
+#define STT_LOOS 10 /* OS-specific semantics */
+#define STT_HIOS 12 /* OS-specific semantics */
+#define STT_LOPROC 13 /* Application-specific semantics */
+#define STT_HIPROC 15 /* Application-specific semantics */
+
+/* Special section indices, which may show up in st_shndx fields, among
+ other places. */
+
+#define SHN_UNDEF 0 /* Undefined section reference */
+#define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */
+#define SHN_LOPROC 0xFF00 /* Begin range of appl-specific */
+#define SHN_HIPROC 0xFF1F /* End range of appl-specific */
+#define SHN_LOOS 0xFF20 /* OS specific semantics, lo */
+#define SHN_HIOS 0xFF3F /* OS specific semantics, hi */
+#define SHN_ABS 0xFFF1 /* Associated symbol is absolute */
+#define SHN_COMMON 0xFFF2 /* Associated symbol is in common */
+#define SHN_HIRESERVE 0xFFFF /* End range of reserved indices */
+
+/* relocation info handling macros */
+
+#define ELF32_R_SYM(i) ((i) >> 8)
+#define ELF32_R_TYPE(i) ((i) & 0xff)
+#define ELF32_R_INFO(s,t) (((s) << 8) + ((t) & 0xff))
+
+#define ELF64_R_SYM(i) ((i) >> 32)
+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
+#define ELF64_R_INFO(s,t) (((bfd_vma) (s) << 32) + (bfd_vma) (t))
+
+/* Dynamic section tags */
+
+#define DT_NULL 0
+#define DT_NEEDED 1
+#define DT_PLTRELSZ 2
+#define DT_PLTGOT 3
+#define DT_HASH 4
+#define DT_STRTAB 5
+#define DT_SYMTAB 6
+#define DT_RELA 7
+#define DT_RELASZ 8
+#define DT_RELAENT 9
+#define DT_STRSZ 10
+#define DT_SYMENT 11
+#define DT_INIT 12
+#define DT_FINI 13
+#define DT_SONAME 14
+#define DT_RPATH 15
+#define DT_SYMBOLIC 16
+#define DT_REL 17
+#define DT_RELSZ 18
+#define DT_RELENT 19
+#define DT_PLTREL 20
+#define DT_DEBUG 21
+#define DT_TEXTREL 22
+#define DT_JMPREL 23
+#define DT_BIND_NOW 24
+#define DT_INIT_ARRAY 25
+#define DT_FINI_ARRAY 26
+#define DT_INIT_ARRAYSZ 27
+#define DT_FINI_ARRAYSZ 28
+
+#define DT_LOOS 0x60000000
+#define DT_HIOS 0x6fffffff
+
+/* The next four dynamic tags are used on Solaris. We support them
+ everywhere. */
+#define DT_VALRNGLO 0x6ffffd00
+#define DT_PLTPADSZ 0x6ffffdf9
+#define DT_MOVEENT 0x6ffffdfa
+#define DT_MOVESZ 0x6ffffdfb
+#define DT_FEATURE_1 0x6ffffdfc
+#define DT_POSFLAG_1 0x6ffffdfd
+#define DT_SYMINSZ 0x6ffffdfe
+#define DT_SYMINENT 0x6ffffdff
+#define DT_VALRNGHI 0x6ffffdff
+
+#define DT_ADDRRNGLO 0x6ffffe00
+#define DT_SYMINFO 0x6ffffeff
+#define DT_ADDRRNGHI 0x6ffffeff
+
+#define DT_RELACOUNT 0x6ffffff9
+#define DT_RELCOUNT 0x6ffffffa
+#define DT_FLAGS_1 0x6ffffffb
+#define DT_VERDEF 0x6ffffffc
+#define DT_VERDEFNUM 0x6ffffffd
+#define DT_VERNEED 0x6ffffffe
+#define DT_VERNEEDNUM 0x6fffffff
+
+/* This tag is a GNU extension to the Solaris version scheme. */
+#define DT_VERSYM 0x6ffffff0
+
+#define DT_LOPROC 0x70000000
+#define DT_HIPROC 0x7fffffff
+
+/* These section tags are used on Solaris. We support them
+ everywhere, and hope they do not conflict. */
+
+#define DT_AUXILIARY 0x7ffffffd
+#define DT_USED 0x7ffffffe
+#define DT_FILTER 0x7fffffff
+
+/* Values used in DT_FEATURE_1 .dynamic entry. */
+#define DTF_1_PARINIT 0x00000001
+
+/* Flag values used in the DT_POSFLAG_1 .dynamic entry. */
+#define DF_P1_LAZYLOAD 0x00000001
+#define DF_P1_GROUPPERM 0x00000002
+
+/* Flag value in in the DT_1_FLAGS .dynamic entry. */
+#define DF_1_NOW 0x00000001
+#define DF_1_GLOBAL 0x00000002
+#define DF_1_GROUP 0x00000004
+#define DF_1_NODELETE 0x00000008
+#define DF_1_LOADFLTR 0x00000010
+#define DF_1_INITFIRST 0x00000020
+#define DF_1_NOOPEN 0x00000040
+#define DF_1_ORIGIN 0x00000080
+#define DF_1_DIRECT 0x00000100
+#define DF_1_TRANS 0x00000200
+#define DF_1_INTERPOSE 0x00000400
+
+/* These constants are used for the version number of a Elf32_Verdef
+ structure. */
+
+#define VER_DEF_NONE 0
+#define VER_DEF_CURRENT 1
+
+/* These constants appear in the vd_flags field of a Elf32_Verdef
+ structure. */
+
+#define VER_FLG_BASE 0x1
+#define VER_FLG_WEAK 0x2
+
+/* These special constants can be found in an Elf32_Versym field. */
+
+#define VER_NDX_LOCAL 0
+#define VER_NDX_GLOBAL 1
+
+/* These constants are used for the version number of a Elf32_Verneed
+ structure. */
+
+#define VER_NEED_NONE 0
+#define VER_NEED_CURRENT 1
+
+/* This flag appears in a Versym structure. It means that the symbol
+ is hidden, and is only visible with an explicit version number.
+ This is a GNU extension. */
+
+#define VERSYM_HIDDEN 0x8000
+
+/* This is the mask for the rest of the Versym information. */
+
+#define VERSYM_VERSION 0x7fff
+
+/* This is a special token which appears as part of a symbol name. It
+ indictes that the rest of the name is actually the name of a
+ version node, and is not part of the actual name. This is a GNU
+ extension. For example, the symbol name `stat@ver2' is taken to
+ mean the symbol `stat' in version `ver2'. */
+
+#define ELF_VER_CHR '@'
+
+/* Possible values for si_boundto. */
+#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
+#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
+#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
+
+/* Possible bitmasks for si_flags. */
+#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
+#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
+#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
+#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
+ loaded */
+/* Syminfo version values. */
+#define SYMINFO_NONE 0
+#define SYMINFO_CURRENT 1
+#define SYMINFO_NUM 2
+
+#endif /* _ELF_COMMON_H */
diff --git a/include/elf/d10v.h b/include/elf/d10v.h
new file mode 100644
index 00000000000..63b79c801b1
--- /dev/null
+++ b/include/elf/d10v.h
@@ -0,0 +1,38 @@
+/* d10v ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_D10V_H
+#define _ELF_D10V_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocation types. */
+START_RELOC_NUMBERS (elf_d10v_reloc_type)
+ RELOC_NUMBER (R_D10V_NONE, 0)
+ RELOC_NUMBER (R_D10V_10_PCREL_R, 1)
+ RELOC_NUMBER (R_D10V_10_PCREL_L, 2)
+ RELOC_NUMBER (R_D10V_16, 3)
+ RELOC_NUMBER (R_D10V_18, 4)
+ RELOC_NUMBER (R_D10V_18_PCREL, 5)
+ RELOC_NUMBER (R_D10V_32, 6)
+ RELOC_NUMBER (R_D10V_GNU_VTINHERIT, 7)
+ RELOC_NUMBER (R_D10V_GNU_VTENTRY, 8)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/d30v.h b/include/elf/d30v.h
new file mode 100644
index 00000000000..adbad192325
--- /dev/null
+++ b/include/elf/d30v.h
@@ -0,0 +1,42 @@
+/* d30v ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_D30V_H
+#define _ELF_D30V_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_d30v_reloc_type)
+ RELOC_NUMBER (R_D30V_NONE, 0)
+ RELOC_NUMBER (R_D30V_6, 1)
+ RELOC_NUMBER (R_D30V_9_PCREL, 2)
+ RELOC_NUMBER (R_D30V_9_PCREL_R, 3)
+ RELOC_NUMBER (R_D30V_15, 4)
+ RELOC_NUMBER (R_D30V_15_PCREL, 5)
+ RELOC_NUMBER (R_D30V_15_PCREL_R, 6)
+ RELOC_NUMBER (R_D30V_21, 7)
+ RELOC_NUMBER (R_D30V_21_PCREL, 8)
+ RELOC_NUMBER (R_D30V_21_PCREL_R, 9)
+ RELOC_NUMBER (R_D30V_32, 10)
+ RELOC_NUMBER (R_D30V_32_PCREL, 11)
+ RELOC_NUMBER (R_D30V_32_NORMAL, 12)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/dwarf.h b/include/elf/dwarf.h
new file mode 100644
index 00000000000..4333d5eda40
--- /dev/null
+++ b/include/elf/dwarf.h
@@ -0,0 +1,319 @@
+/* Declarations and definitions of codes relating to the DWARF symbolic
+ debugging information format.
+
+ Written by Ron Guilmette (rfg@ncd.com)
+
+Copyright (C) 1992 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file is derived from the DWARF specification (a public document)
+ Revision 1.0.1 (April 8, 1992) developed by the UNIX International
+ Programming Languages Special Interest Group (UI/PLSIG) and distributed
+ by UNIX International. Copies of this specification are available from
+ UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054.
+*/
+
+#ifndef _ELF_DWARF_H
+#define _ELF_DWARF_H
+
+/* Tag names and codes. */
+
+enum dwarf_tag {
+ TAG_padding = 0x0000,
+ TAG_array_type = 0x0001,
+ TAG_class_type = 0x0002,
+ TAG_entry_point = 0x0003,
+ TAG_enumeration_type = 0x0004,
+ TAG_formal_parameter = 0x0005,
+ TAG_global_subroutine = 0x0006,
+ TAG_global_variable = 0x0007,
+ /* 0x0008 -- reserved */
+ /* 0x0009 -- reserved */
+ TAG_label = 0x000a,
+ TAG_lexical_block = 0x000b,
+ TAG_local_variable = 0x000c,
+ TAG_member = 0x000d,
+ /* 0x000e -- reserved */
+ TAG_pointer_type = 0x000f,
+ TAG_reference_type = 0x0010,
+ TAG_compile_unit = 0x0011,
+ TAG_string_type = 0x0012,
+ TAG_structure_type = 0x0013,
+ TAG_subroutine = 0x0014,
+ TAG_subroutine_type = 0x0015,
+ TAG_typedef = 0x0016,
+ TAG_union_type = 0x0017,
+ TAG_unspecified_parameters = 0x0018,
+ TAG_variant = 0x0019,
+ TAG_common_block = 0x001a,
+ TAG_common_inclusion = 0x001b,
+ TAG_inheritance = 0x001c,
+ TAG_inlined_subroutine = 0x001d,
+ TAG_module = 0x001e,
+ TAG_ptr_to_member_type = 0x001f,
+ TAG_set_type = 0x0020,
+ TAG_subrange_type = 0x0021,
+ TAG_with_stmt = 0x0022,
+
+ /* GNU extensions */
+
+ TAG_format_label = 0x8000, /* for FORTRAN 77 and Fortran 90 */
+ TAG_namelist = 0x8001, /* For Fortran 90 */
+ TAG_function_template = 0x8002, /* for C++ */
+ TAG_class_template = 0x8003 /* for C++ */
+};
+
+#define TAG_lo_user 0x8000 /* implementation-defined range start */
+#define TAG_hi_user 0xffff /* implementation-defined range end */
+#define TAG_source_file TAG_compile_unit /* for backward compatibility */
+
+/* Form names and codes. */
+
+enum dwarf_form {
+ FORM_ADDR = 0x1,
+ FORM_REF = 0x2,
+ FORM_BLOCK2 = 0x3,
+ FORM_BLOCK4 = 0x4,
+ FORM_DATA2 = 0x5,
+ FORM_DATA4 = 0x6,
+ FORM_DATA8 = 0x7,
+ FORM_STRING = 0x8
+};
+
+/* Attribute names and codes. */
+
+enum dwarf_attribute {
+ AT_sibling = (0x0010|FORM_REF),
+ AT_location = (0x0020|FORM_BLOCK2),
+ AT_name = (0x0030|FORM_STRING),
+ AT_fund_type = (0x0050|FORM_DATA2),
+ AT_mod_fund_type = (0x0060|FORM_BLOCK2),
+ AT_user_def_type = (0x0070|FORM_REF),
+ AT_mod_u_d_type = (0x0080|FORM_BLOCK2),
+ AT_ordering = (0x0090|FORM_DATA2),
+ AT_subscr_data = (0x00a0|FORM_BLOCK2),
+ AT_byte_size = (0x00b0|FORM_DATA4),
+ AT_bit_offset = (0x00c0|FORM_DATA2),
+ AT_bit_size = (0x00d0|FORM_DATA4),
+ /* (0x00e0|FORM_xxxx) -- reserved */
+ AT_element_list = (0x00f0|FORM_BLOCK4),
+ AT_stmt_list = (0x0100|FORM_DATA4),
+ AT_low_pc = (0x0110|FORM_ADDR),
+ AT_high_pc = (0x0120|FORM_ADDR),
+ AT_language = (0x0130|FORM_DATA4),
+ AT_member = (0x0140|FORM_REF),
+ AT_discr = (0x0150|FORM_REF),
+ AT_discr_value = (0x0160|FORM_BLOCK2),
+ /* (0x0170|FORM_xxxx) -- reserved */
+ /* (0x0180|FORM_xxxx) -- reserved */
+ AT_string_length = (0x0190|FORM_BLOCK2),
+ AT_common_reference = (0x01a0|FORM_REF),
+ AT_comp_dir = (0x01b0|FORM_STRING),
+ AT_const_value_string = (0x01c0|FORM_STRING),
+ AT_const_value_data2 = (0x01c0|FORM_DATA2),
+ AT_const_value_data4 = (0x01c0|FORM_DATA4),
+ AT_const_value_data8 = (0x01c0|FORM_DATA8),
+ AT_const_value_block2 = (0x01c0|FORM_BLOCK2),
+ AT_const_value_block4 = (0x01c0|FORM_BLOCK4),
+ AT_containing_type = (0x01d0|FORM_REF),
+ AT_default_value_addr = (0x01e0|FORM_ADDR),
+ AT_default_value_data2 = (0x01e0|FORM_DATA2),
+ AT_default_value_data4 = (0x01e0|FORM_DATA4),
+ AT_default_value_data8 = (0x01e0|FORM_DATA8),
+ AT_default_value_string = (0x01e0|FORM_STRING),
+ AT_friends = (0x01f0|FORM_BLOCK2),
+ AT_inline = (0x0200|FORM_STRING),
+ AT_is_optional = (0x0210|FORM_STRING),
+ AT_lower_bound_ref = (0x0220|FORM_REF),
+ AT_lower_bound_data2 = (0x0220|FORM_DATA2),
+ AT_lower_bound_data4 = (0x0220|FORM_DATA4),
+ AT_lower_bound_data8 = (0x0220|FORM_DATA8),
+ AT_private = (0x0240|FORM_STRING),
+ AT_producer = (0x0250|FORM_STRING),
+ AT_program = (0x0230|FORM_STRING),
+ AT_protected = (0x0260|FORM_STRING),
+ AT_prototyped = (0x0270|FORM_STRING),
+ AT_public = (0x0280|FORM_STRING),
+ AT_pure_virtual = (0x0290|FORM_STRING),
+ AT_return_addr = (0x02a0|FORM_BLOCK2),
+ AT_abstract_origin = (0x02b0|FORM_REF),
+ AT_start_scope = (0x02c0|FORM_DATA4),
+ AT_stride_size = (0x02e0|FORM_DATA4),
+ AT_upper_bound_ref = (0x02f0|FORM_REF),
+ AT_upper_bound_data2 = (0x02f0|FORM_DATA2),
+ AT_upper_bound_data4 = (0x02f0|FORM_DATA4),
+ AT_upper_bound_data8 = (0x02f0|FORM_DATA8),
+ AT_virtual = (0x0300|FORM_STRING),
+
+ /* GNU extensions. */
+
+ AT_sf_names = (0x8000|FORM_DATA4),
+ AT_src_info = (0x8010|FORM_DATA4),
+ AT_mac_info = (0x8020|FORM_DATA4),
+ AT_src_coords = (0x8030|FORM_DATA4),
+ AT_body_begin = (0x8040|FORM_ADDR),
+ AT_body_end = (0x8050|FORM_ADDR)
+};
+
+#define AT_lo_user 0x8000 /* implementation-defined range start */
+#define AT_hi_user 0xffff /* implementation-defined range end */
+
+/* Location atom names and codes. */
+
+enum dwarf_location_atom {
+ OP_REG = 0x01,
+ OP_BASEREG = 0x02,
+ OP_ADDR = 0x03,
+ OP_CONST = 0x04,
+ OP_DEREF2 = 0x05,
+ OP_DEREF4 = 0x06,
+ OP_ADD = 0x07
+};
+
+#define OP_LO_USER 0x80 /* implementation-defined range start */
+#define OP_HI_USER 0xff /* implementation-defined range end */
+
+/* Fundamental type names and codes. */
+
+enum dwarf_fundamental_type {
+ FT_char = 0x0001,
+ FT_signed_char = 0x0002,
+ FT_unsigned_char = 0x0003,
+ FT_short = 0x0004,
+ FT_signed_short = 0x0005,
+ FT_unsigned_short = 0x0006,
+ FT_integer = 0x0007,
+ FT_signed_integer = 0x0008,
+ FT_unsigned_integer = 0x0009,
+ FT_long = 0x000a,
+ FT_signed_long = 0x000b,
+ FT_unsigned_long = 0x000c,
+ FT_pointer = 0x000d, /* an alias for (void *) */
+ FT_float = 0x000e,
+ FT_dbl_prec_float = 0x000f,
+ FT_ext_prec_float = 0x0010, /* breaks "classic" svr4 SDB */
+ FT_complex = 0x0011, /* breaks "classic" svr4 SDB */
+ FT_dbl_prec_complex = 0x0012, /* breaks "classic" svr4 SDB */
+ /* 0x0013 -- reserved */
+ FT_void = 0x0014,
+ FT_boolean = 0x0015, /* breaks "classic" svr4 SDB */
+ FT_ext_prec_complex = 0x0016, /* breaks "classic" svr4 SDB */
+ FT_label = 0x0017,
+
+ /* GNU extensions
+ The low order byte must indicate the size (in bytes) for the type.
+ All of these types will probably break "classic" svr4 SDB */
+
+ FT_long_long = 0x8008,
+ FT_signed_long_long = 0x8108,
+ FT_unsigned_long_long = 0x8208,
+
+ FT_int8 = 0x9001,
+ FT_signed_int8 = 0x9101,
+ FT_unsigned_int8 = 0x9201,
+ FT_int16 = 0x9302,
+ FT_signed_int16 = 0x9402,
+ FT_unsigned_int16 = 0x9502,
+ FT_int32 = 0x9604,
+ FT_signed_int32 = 0x9704,
+ FT_unsigned_int32 = 0x9804,
+ FT_int64 = 0x9908,
+ FT_signed_int64 = 0x9a08,
+ FT_unsigned_int64 = 0x9b08,
+
+ FT_real32 = 0xa004,
+ FT_real64 = 0xa108,
+ FT_real96 = 0xa20c,
+ FT_real128 = 0xa310
+};
+
+#define FT_lo_user 0x8000 /* implementation-defined range start */
+#define FT_hi_user 0xffff /* implementation defined range end */
+
+/* Type modifier names and codes. */
+
+enum dwarf_type_modifier {
+ MOD_pointer_to = 0x01,
+ MOD_reference_to = 0x02,
+ MOD_const = 0x03,
+ MOD_volatile = 0x04
+};
+
+#define MOD_lo_user 0x80 /* implementation-defined range start */
+#define MOD_hi_user 0xff /* implementation-defined range end */
+
+/* Array ordering names and codes. */
+
+enum dwarf_array_dim_ordering {
+ ORD_row_major = 0,
+ ORD_col_major = 1
+};
+
+/* Array subscript format names and codes. */
+
+enum dwarf_subscr_data_formats {
+ FMT_FT_C_C = 0x0,
+ FMT_FT_C_X = 0x1,
+ FMT_FT_X_C = 0x2,
+ FMT_FT_X_X = 0x3,
+ FMT_UT_C_C = 0x4,
+ FMT_UT_C_X = 0x5,
+ FMT_UT_X_C = 0x6,
+ FMT_UT_X_X = 0x7,
+ FMT_ET = 0x8
+};
+
+/* Derived from above for ease of use. */
+
+#define FMT_CODE(_FUNDAMENTAL_TYPE_P, _UB_CONST_P, _LB_CONST_P) \
+ (((_FUNDAMENTAL_TYPE_P) ? 0 : 4) \
+ | ((_UB_CONST_P) ? 0 : 2) \
+ | ((_LB_CONST_P) ? 0 : 1))
+
+/* Source language names and codes. */
+
+enum dwarf_source_language {
+ LANG_C89 = 0x00000001,
+ LANG_C = 0x00000002,
+ LANG_ADA83 = 0x00000003,
+ LANG_C_PLUS_PLUS = 0x00000004,
+ LANG_COBOL74 = 0x00000005,
+ LANG_COBOL85 = 0x00000006,
+ LANG_FORTRAN77 = 0x00000007,
+ LANG_FORTRAN90 = 0x00000008,
+ LANG_PASCAL83 = 0x00000009,
+ LANG_MODULA2 = 0x0000000a,
+
+ /* GNU extensions */
+
+ LANG_CHILL = 0x00009af3 /* random value for GNU Chill */
+};
+
+#define LANG_lo_user 0x00008000 /* implementation-defined range start */
+#define LANG_hi_user 0x0000ffff /* implementation-defined range end */
+
+/* Names and codes for GNU "macinfo" extension. */
+
+enum dwarf_macinfo_record_type {
+ MACINFO_start = 's',
+ MACINFO_resume = 'r',
+ MACINFO_define = 'd',
+ MACINFO_undef = 'u'
+};
+
+#endif /* _ELF_DWARF_H */
diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
new file mode 100644
index 00000000000..b2cbb24d95d
--- /dev/null
+++ b/include/elf/dwarf2.h
@@ -0,0 +1,637 @@
+/* Declarations and definitions of codes relating to the DWARF symbolic
+ debugging information format.
+ Copyright (C) 1992, 1993, 1995, 1996, 1999 Free Software Foundation, Inc.
+
+ Written by Gary Funck (gary@intrepid.com) The Ada Joint Program
+ Office (AJPO), Florida State Unviversity and Silicon Graphics Inc.
+ provided support for this effort -- June 21, 1995.
+
+ Derived from the DWARF 1 implementation written by Ron Guilmette
+ (rfg@netcom.com), November 1990.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+GNU CC 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 GNU CC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file is derived from the DWARF specification (a public document)
+ Revision 2.0.0 (July 27, 1993) developed by the UNIX International
+ Programming Languages Special Interest Group (UI/PLSIG) and distributed
+ by UNIX International. Copies of this specification are available from
+ UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054. */
+
+#ifndef _ELF_DWARF2_H
+#define _ELF_DWARF2_H
+
+/* Structure found in the .debug_line section. */
+typedef struct
+{
+ unsigned char li_length [4];
+ unsigned char li_version [2];
+ unsigned char li_prologue_length [4];
+ unsigned char li_min_insn_length [1];
+ unsigned char li_default_is_stmt [1];
+ unsigned char li_line_base [1];
+ unsigned char li_line_range [1];
+ unsigned char li_opcode_base [1];
+}
+DWARF2_External_LineInfo;
+
+typedef struct
+{
+ unsigned long li_length;
+ unsigned short li_version;
+ unsigned int li_prologue_length;
+ unsigned char li_min_insn_length;
+ unsigned char li_default_is_stmt;
+ int li_line_base;
+ unsigned char li_line_range;
+ unsigned char li_opcode_base;
+}
+DWARF2_Internal_LineInfo;
+
+/* Structure found in .debug_pubnames section. */
+typedef struct
+{
+ unsigned char pn_length [4];
+ unsigned char pn_version [2];
+ unsigned char pn_offset [4];
+ unsigned char pn_size [4];
+}
+DWARF2_External_PubNames;
+
+typedef struct
+{
+ unsigned long pn_length;
+ unsigned short pn_version;
+ unsigned long pn_offset;
+ unsigned long pn_size;
+}
+DWARF2_Internal_PubNames;
+
+/* Strcuture found in .debug_info section. */
+typedef struct
+{
+ unsigned char cu_length [4];
+ unsigned char cu_version [2];
+ unsigned char cu_abbrev_offset [4];
+ unsigned char cu_pointer_size [1];
+}
+DWARF2_External_CompUnit;
+
+typedef struct
+{
+ unsigned long cu_length;
+ unsigned short cu_version;
+ unsigned long cu_abbrev_offset;
+ unsigned char cu_pointer_size;
+}
+DWARF2_Internal_CompUnit;
+
+typedef struct
+{
+ unsigned char ar_length [4];
+ unsigned char ar_version [2];
+ unsigned char ar_info_offset [4];
+ unsigned char ar_pointer_size [1];
+ unsigned char ar_segment_size [1];
+}
+DWARF2_External_ARange;
+
+typedef struct
+{
+ unsigned long ar_length;
+ unsigned short ar_version;
+ unsigned long ar_info_offset;
+ unsigned char ar_pointer_size;
+ unsigned char ar_segment_size;
+}
+DWARF2_Internal_ARange;
+
+
+/* Tag names and codes. */
+
+enum dwarf_tag
+ {
+ DW_TAG_padding = 0x00,
+ DW_TAG_array_type = 0x01,
+ DW_TAG_class_type = 0x02,
+ DW_TAG_entry_point = 0x03,
+ DW_TAG_enumeration_type = 0x04,
+ DW_TAG_formal_parameter = 0x05,
+ DW_TAG_imported_declaration = 0x08,
+ DW_TAG_label = 0x0a,
+ DW_TAG_lexical_block = 0x0b,
+ DW_TAG_member = 0x0d,
+ DW_TAG_pointer_type = 0x0f,
+ DW_TAG_reference_type = 0x10,
+ DW_TAG_compile_unit = 0x11,
+ DW_TAG_string_type = 0x12,
+ DW_TAG_structure_type = 0x13,
+ DW_TAG_subroutine_type = 0x15,
+ DW_TAG_typedef = 0x16,
+ DW_TAG_union_type = 0x17,
+ DW_TAG_unspecified_parameters = 0x18,
+ DW_TAG_variant = 0x19,
+ DW_TAG_common_block = 0x1a,
+ DW_TAG_common_inclusion = 0x1b,
+ DW_TAG_inheritance = 0x1c,
+ DW_TAG_inlined_subroutine = 0x1d,
+ DW_TAG_module = 0x1e,
+ DW_TAG_ptr_to_member_type = 0x1f,
+ DW_TAG_set_type = 0x20,
+ DW_TAG_subrange_type = 0x21,
+ DW_TAG_with_stmt = 0x22,
+ DW_TAG_access_declaration = 0x23,
+ DW_TAG_base_type = 0x24,
+ DW_TAG_catch_block = 0x25,
+ DW_TAG_const_type = 0x26,
+ DW_TAG_constant = 0x27,
+ DW_TAG_enumerator = 0x28,
+ DW_TAG_file_type = 0x29,
+ DW_TAG_friend = 0x2a,
+ DW_TAG_namelist = 0x2b,
+ DW_TAG_namelist_item = 0x2c,
+ DW_TAG_packed_type = 0x2d,
+ DW_TAG_subprogram = 0x2e,
+ DW_TAG_template_type_param = 0x2f,
+ DW_TAG_template_value_param = 0x30,
+ DW_TAG_thrown_type = 0x31,
+ DW_TAG_try_block = 0x32,
+ DW_TAG_variant_part = 0x33,
+ DW_TAG_variable = 0x34,
+ DW_TAG_volatile_type = 0x35,
+ /* SGI/MIPS Extensions */
+ DW_TAG_MIPS_loop = 0x4081,
+ /* GNU extensions */
+ DW_TAG_format_label = 0x4101, /* for FORTRAN 77 and Fortran 90 */
+ DW_TAG_function_template = 0x4102, /* for C++ */
+ DW_TAG_class_template = 0x4103 /* for C++ */
+ };
+
+#define DW_TAG_lo_user 0x4080
+#define DW_TAG_hi_user 0xffff
+
+/* flag that tells whether entry has a child or not */
+#define DW_children_no 0
+#define DW_children_yes 1
+
+/* Form names and codes. */
+enum dwarf_form
+ {
+ DW_FORM_addr = 0x01,
+ DW_FORM_block2 = 0x03,
+ DW_FORM_block4 = 0x04,
+ DW_FORM_data2 = 0x05,
+ DW_FORM_data4 = 0x06,
+ DW_FORM_data8 = 0x07,
+ DW_FORM_string = 0x08,
+ DW_FORM_block = 0x09,
+ DW_FORM_block1 = 0x0a,
+ DW_FORM_data1 = 0x0b,
+ DW_FORM_flag = 0x0c,
+ DW_FORM_sdata = 0x0d,
+ DW_FORM_strp = 0x0e,
+ DW_FORM_udata = 0x0f,
+ DW_FORM_ref_addr = 0x10,
+ DW_FORM_ref1 = 0x11,
+ DW_FORM_ref2 = 0x12,
+ DW_FORM_ref4 = 0x13,
+ DW_FORM_ref8 = 0x14,
+ DW_FORM_ref_udata = 0x15,
+ DW_FORM_indirect = 0x16
+ };
+
+/* Attribute names and codes. */
+
+enum dwarf_attribute
+ {
+ DW_AT_sibling = 0x01,
+ DW_AT_location = 0x02,
+ DW_AT_name = 0x03,
+ DW_AT_ordering = 0x09,
+ DW_AT_subscr_data = 0x0a,
+ DW_AT_byte_size = 0x0b,
+ DW_AT_bit_offset = 0x0c,
+ DW_AT_bit_size = 0x0d,
+ DW_AT_element_list = 0x0f,
+ DW_AT_stmt_list = 0x10,
+ DW_AT_low_pc = 0x11,
+ DW_AT_high_pc = 0x12,
+ DW_AT_language = 0x13,
+ DW_AT_member = 0x14,
+ DW_AT_discr = 0x15,
+ DW_AT_discr_value = 0x16,
+ DW_AT_visibility = 0x17,
+ DW_AT_import = 0x18,
+ DW_AT_string_length = 0x19,
+ DW_AT_common_reference = 0x1a,
+ DW_AT_comp_dir = 0x1b,
+ DW_AT_const_value = 0x1c,
+ DW_AT_containing_type = 0x1d,
+ DW_AT_default_value = 0x1e,
+ DW_AT_inline = 0x20,
+ DW_AT_is_optional = 0x21,
+ DW_AT_lower_bound = 0x22,
+ DW_AT_producer = 0x25,
+ DW_AT_prototyped = 0x27,
+ DW_AT_return_addr = 0x2a,
+ DW_AT_start_scope = 0x2c,
+ DW_AT_stride_size = 0x2e,
+ DW_AT_upper_bound = 0x2f,
+ DW_AT_abstract_origin = 0x31,
+ DW_AT_accessibility = 0x32,
+ DW_AT_address_class = 0x33,
+ DW_AT_artificial = 0x34,
+ DW_AT_base_types = 0x35,
+ DW_AT_calling_convention = 0x36,
+ DW_AT_count = 0x37,
+ DW_AT_data_member_location = 0x38,
+ DW_AT_decl_column = 0x39,
+ DW_AT_decl_file = 0x3a,
+ DW_AT_decl_line = 0x3b,
+ DW_AT_declaration = 0x3c,
+ DW_AT_discr_list = 0x3d,
+ DW_AT_encoding = 0x3e,
+ DW_AT_external = 0x3f,
+ DW_AT_frame_base = 0x40,
+ DW_AT_friend = 0x41,
+ DW_AT_identifier_case = 0x42,
+ DW_AT_macro_info = 0x43,
+ DW_AT_namelist_items = 0x44,
+ DW_AT_priority = 0x45,
+ DW_AT_segment = 0x46,
+ DW_AT_specification = 0x47,
+ DW_AT_static_link = 0x48,
+ DW_AT_type = 0x49,
+ DW_AT_use_location = 0x4a,
+ DW_AT_variable_parameter = 0x4b,
+ DW_AT_virtuality = 0x4c,
+ DW_AT_vtable_elem_location = 0x4d,
+ /* SGI/MIPS Extensions */
+ DW_AT_MIPS_fde = 0x2001,
+ DW_AT_MIPS_loop_begin = 0x2002,
+ DW_AT_MIPS_tail_loop_begin = 0x2003,
+ DW_AT_MIPS_epilog_begin = 0x2004,
+ DW_AT_MIPS_loop_unroll_factor = 0x2005,
+ DW_AT_MIPS_software_pipeline_depth = 0x2006,
+ DW_AT_MIPS_linkage_name = 0x2007,
+ DW_AT_MIPS_stride = 0x2008,
+ DW_AT_MIPS_abstract_name = 0x2009,
+ DW_AT_MIPS_clone_origin = 0x200a,
+ DW_AT_MIPS_has_inlines = 0x200b,
+ /* GNU extensions. */
+ DW_AT_sf_names = 0x2101,
+ DW_AT_src_info = 0x2102,
+ DW_AT_mac_info = 0x2103,
+ DW_AT_src_coords = 0x2104,
+ DW_AT_body_begin = 0x2105,
+ DW_AT_body_end = 0x2106
+ };
+
+#define DW_AT_lo_user 0x2000 /* implementation-defined range start */
+#define DW_AT_hi_user 0x3ff0 /* implementation-defined range end */
+
+/* Location atom names and codes. */
+
+enum dwarf_location_atom
+ {
+ DW_OP_addr = 0x03,
+ DW_OP_deref = 0x06,
+ DW_OP_const1u = 0x08,
+ DW_OP_const1s = 0x09,
+ DW_OP_const2u = 0x0a,
+ DW_OP_const2s = 0x0b,
+ DW_OP_const4u = 0x0c,
+ DW_OP_const4s = 0x0d,
+ DW_OP_const8u = 0x0e,
+ DW_OP_const8s = 0x0f,
+ DW_OP_constu = 0x10,
+ DW_OP_consts = 0x11,
+ DW_OP_dup = 0x12,
+ DW_OP_drop = 0x13,
+ DW_OP_over = 0x14,
+ DW_OP_pick = 0x15,
+ DW_OP_swap = 0x16,
+ DW_OP_rot = 0x17,
+ DW_OP_xderef = 0x18,
+ DW_OP_abs = 0x19,
+ DW_OP_and = 0x1a,
+ DW_OP_div = 0x1b,
+ DW_OP_minus = 0x1c,
+ DW_OP_mod = 0x1d,
+ DW_OP_mul = 0x1e,
+ DW_OP_neg = 0x1f,
+ DW_OP_not = 0x20,
+ DW_OP_or = 0x21,
+ DW_OP_plus = 0x22,
+ DW_OP_plus_uconst = 0x23,
+ DW_OP_shl = 0x24,
+ DW_OP_shr = 0x25,
+ DW_OP_shra = 0x26,
+ DW_OP_xor = 0x27,
+ DW_OP_bra = 0x28,
+ DW_OP_eq = 0x29,
+ DW_OP_ge = 0x2a,
+ DW_OP_gt = 0x2b,
+ DW_OP_le = 0x2c,
+ DW_OP_lt = 0x2d,
+ DW_OP_ne = 0x2e,
+ DW_OP_skip = 0x2f,
+ DW_OP_lit0 = 0x30,
+ DW_OP_lit1 = 0x31,
+ DW_OP_lit2 = 0x32,
+ DW_OP_lit3 = 0x33,
+ DW_OP_lit4 = 0x34,
+ DW_OP_lit5 = 0x35,
+ DW_OP_lit6 = 0x36,
+ DW_OP_lit7 = 0x37,
+ DW_OP_lit8 = 0x38,
+ DW_OP_lit9 = 0x39,
+ DW_OP_lit10 = 0x3a,
+ DW_OP_lit11 = 0x3b,
+ DW_OP_lit12 = 0x3c,
+ DW_OP_lit13 = 0x3d,
+ DW_OP_lit14 = 0x3e,
+ DW_OP_lit15 = 0x3f,
+ DW_OP_lit16 = 0x40,
+ DW_OP_lit17 = 0x41,
+ DW_OP_lit18 = 0x42,
+ DW_OP_lit19 = 0x43,
+ DW_OP_lit20 = 0x44,
+ DW_OP_lit21 = 0x45,
+ DW_OP_lit22 = 0x46,
+ DW_OP_lit23 = 0x47,
+ DW_OP_lit24 = 0x48,
+ DW_OP_lit25 = 0x49,
+ DW_OP_lit26 = 0x4a,
+ DW_OP_lit27 = 0x4b,
+ DW_OP_lit28 = 0x4c,
+ DW_OP_lit29 = 0x4d,
+ DW_OP_lit30 = 0x4e,
+ DW_OP_lit31 = 0x4f,
+ DW_OP_reg0 = 0x50,
+ DW_OP_reg1 = 0x51,
+ DW_OP_reg2 = 0x52,
+ DW_OP_reg3 = 0x53,
+ DW_OP_reg4 = 0x54,
+ DW_OP_reg5 = 0x55,
+ DW_OP_reg6 = 0x56,
+ DW_OP_reg7 = 0x57,
+ DW_OP_reg8 = 0x58,
+ DW_OP_reg9 = 0x59,
+ DW_OP_reg10 = 0x5a,
+ DW_OP_reg11 = 0x5b,
+ DW_OP_reg12 = 0x5c,
+ DW_OP_reg13 = 0x5d,
+ DW_OP_reg14 = 0x5e,
+ DW_OP_reg15 = 0x5f,
+ DW_OP_reg16 = 0x60,
+ DW_OP_reg17 = 0x61,
+ DW_OP_reg18 = 0x62,
+ DW_OP_reg19 = 0x63,
+ DW_OP_reg20 = 0x64,
+ DW_OP_reg21 = 0x65,
+ DW_OP_reg22 = 0x66,
+ DW_OP_reg23 = 0x67,
+ DW_OP_reg24 = 0x68,
+ DW_OP_reg25 = 0x69,
+ DW_OP_reg26 = 0x6a,
+ DW_OP_reg27 = 0x6b,
+ DW_OP_reg28 = 0x6c,
+ DW_OP_reg29 = 0x6d,
+ DW_OP_reg30 = 0x6e,
+ DW_OP_reg31 = 0x6f,
+ DW_OP_breg0 = 0x70,
+ DW_OP_breg1 = 0x71,
+ DW_OP_breg2 = 0x72,
+ DW_OP_breg3 = 0x73,
+ DW_OP_breg4 = 0x74,
+ DW_OP_breg5 = 0x75,
+ DW_OP_breg6 = 0x76,
+ DW_OP_breg7 = 0x77,
+ DW_OP_breg8 = 0x78,
+ DW_OP_breg9 = 0x79,
+ DW_OP_breg10 = 0x7a,
+ DW_OP_breg11 = 0x7b,
+ DW_OP_breg12 = 0x7c,
+ DW_OP_breg13 = 0x7d,
+ DW_OP_breg14 = 0x7e,
+ DW_OP_breg15 = 0x7f,
+ DW_OP_breg16 = 0x80,
+ DW_OP_breg17 = 0x81,
+ DW_OP_breg18 = 0x82,
+ DW_OP_breg19 = 0x83,
+ DW_OP_breg20 = 0x84,
+ DW_OP_breg21 = 0x85,
+ DW_OP_breg22 = 0x86,
+ DW_OP_breg23 = 0x87,
+ DW_OP_breg24 = 0x88,
+ DW_OP_breg25 = 0x89,
+ DW_OP_breg26 = 0x8a,
+ DW_OP_breg27 = 0x8b,
+ DW_OP_breg28 = 0x8c,
+ DW_OP_breg29 = 0x8d,
+ DW_OP_breg30 = 0x8e,
+ DW_OP_breg31 = 0x8f,
+ DW_OP_regx = 0x90,
+ DW_OP_fbreg = 0x91,
+ DW_OP_bregx = 0x92,
+ DW_OP_piece = 0x93,
+ DW_OP_deref_size = 0x94,
+ DW_OP_xderef_size = 0x95,
+ DW_OP_nop = 0x96
+ };
+
+#define DW_OP_lo_user 0x80 /* implementation-defined range start */
+#define DW_OP_hi_user 0xff /* implementation-defined range end */
+
+/* Type encodings. */
+
+enum dwarf_type
+ {
+ DW_ATE_void = 0x0,
+ DW_ATE_address = 0x1,
+ DW_ATE_boolean = 0x2,
+ DW_ATE_complex_float = 0x3,
+ DW_ATE_float = 0x4,
+ DW_ATE_signed = 0x5,
+ DW_ATE_signed_char = 0x6,
+ DW_ATE_unsigned = 0x7,
+ DW_ATE_unsigned_char = 0x8
+ };
+
+#define DW_ATE_lo_user 0x80
+#define DW_ATE_hi_user 0xff
+
+/* Array ordering names and codes. */
+enum dwarf_array_dim_ordering
+ {
+ DW_ORD_row_major = 0,
+ DW_ORD_col_major = 1
+ };
+
+/* access attribute */
+enum dwarf_access_attribute
+ {
+ DW_ACCESS_public = 1,
+ DW_ACCESS_protected = 2,
+ DW_ACCESS_private = 3
+ };
+
+/* visibility */
+enum dwarf_visibility_attribute
+ {
+ DW_VIS_local = 1,
+ DW_VIS_exported = 2,
+ DW_VIS_qualified = 3
+ };
+
+/* virtuality */
+enum dwarf_virtuality_attribute
+ {
+ DW_VIRTUALITY_none = 0,
+ DW_VIRTUALITY_virtual = 1,
+ DW_VIRTUALITY_pure_virtual = 2
+ };
+
+/* case sensitivity */
+enum dwarf_id_case
+ {
+ DW_ID_case_sensitive = 0,
+ DW_ID_up_case = 1,
+ DW_ID_down_case = 2,
+ DW_ID_case_insensitive = 3
+ };
+
+/* calling convention */
+enum dwarf_calling_convention
+ {
+ DW_CC_normal = 0x1,
+ DW_CC_program = 0x2,
+ DW_CC_nocall = 0x3
+ };
+
+#define DW_CC_lo_user 0x40
+#define DW_CC_hi_user 0xff
+
+/* inline attribute */
+enum dwarf_inline_attribute
+ {
+ DW_INL_not_inlined = 0,
+ DW_INL_inlined = 1,
+ DW_INL_declared_not_inlined = 2,
+ DW_INL_declared_inlined = 3
+ };
+
+/* descriminant lists */
+enum dwarf_descrim_list
+ {
+ DW_DSC_label = 0,
+ DW_DSC_range = 1
+ };
+
+/* line number opcodes */
+enum dwarf_line_number_ops
+ {
+ DW_LNS_extended_op = 0,
+ DW_LNS_copy = 1,
+ DW_LNS_advance_pc = 2,
+ DW_LNS_advance_line = 3,
+ DW_LNS_set_file = 4,
+ DW_LNS_set_column = 5,
+ DW_LNS_negate_stmt = 6,
+ DW_LNS_set_basic_block = 7,
+ DW_LNS_const_add_pc = 8,
+ DW_LNS_fixed_advance_pc = 9
+ };
+
+/* line number extended opcodes */
+enum dwarf_line_number_x_ops
+ {
+ DW_LNE_end_sequence = 1,
+ DW_LNE_set_address = 2,
+ DW_LNE_define_file = 3
+ };
+
+/* call frame information */
+enum dwarf_call_frame_info
+ {
+ DW_CFA_advance_loc = 0x40,
+ DW_CFA_offset = 0x80,
+ DW_CFA_restore = 0xc0,
+ DW_CFA_nop = 0x00,
+ DW_CFA_set_loc = 0x01,
+ DW_CFA_advance_loc1 = 0x02,
+ DW_CFA_advance_loc2 = 0x03,
+ DW_CFA_advance_loc4 = 0x04,
+ DW_CFA_offset_extended = 0x05,
+ DW_CFA_restore_extended = 0x06,
+ DW_CFA_undefined = 0x07,
+ DW_CFA_same_value = 0x08,
+ DW_CFA_register = 0x09,
+ DW_CFA_remember_state = 0x0a,
+ DW_CFA_restore_state = 0x0b,
+ DW_CFA_def_cfa = 0x0c,
+ DW_CFA_def_cfa_register = 0x0d,
+ DW_CFA_def_cfa_offset = 0x0e,
+ /* SGI/MIPS specific */
+ DW_CFA_MIPS_advance_loc8 = 0x1d
+ };
+
+#define DW_CIE_ID 0xffffffff
+#define DW_CIE_VERSION 1
+
+#define DW_CFA_extended 0
+#define DW_CFA_low_user 0x1c
+#define DW_CFA_high_user 0x3f
+
+#define DW_CHILDREN_no 0x00
+#define DW_CHILDREN_yes 0x01
+
+#define DW_ADDR_none 0
+
+/* Source language names and codes. */
+
+enum dwarf_source_language
+ {
+ DW_LANG_C89 = 0x0001,
+ DW_LANG_C = 0x0002,
+ DW_LANG_Ada83 = 0x0003,
+ DW_LANG_C_plus_plus = 0x0004,
+ DW_LANG_Cobol74 = 0x0005,
+ DW_LANG_Cobol85 = 0x0006,
+ DW_LANG_Fortran77 = 0x0007,
+ DW_LANG_Fortran90 = 0x0008,
+ DW_LANG_Pascal83 = 0x0009,
+ DW_LANG_Modula2 = 0x000a,
+ DW_LANG_Mips_Assembler = 0x8001
+ };
+
+
+#define DW_LANG_lo_user 0x8000 /* implementation-defined range start */
+#define DW_LANG_hi_user 0xffff /* implementation-defined range start */
+
+/* Names and codes for macro information. */
+
+enum dwarf_macinfo_record_type
+ {
+ DW_MACINFO_define = 1,
+ DW_MACINFO_undef = 2,
+ DW_MACINFO_start_file = 3,
+ DW_MACINFO_end_file = 4,
+ DW_MACINFO_vendor_ext = 255
+ };
+
+#endif /* _ELF_DWARF2_H */
diff --git a/include/elf/external.h b/include/elf/external.h
new file mode 100644
index 00000000000..5cab77e5549
--- /dev/null
+++ b/include/elf/external.h
@@ -0,0 +1,256 @@
+/* ELF support for BFD.
+ Copyright (C) 1991, 92, 93, 95, 97, 98, 1999 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, from information published
+ in "UNIX System V Release 4, Programmers Guide: ANSI C and
+ Programming Support Tools".
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of ELF support for BFD, and contains the portions
+ that describe how ELF is represented externally by the BFD library.
+ I.E. it describes the in-file representation of ELF. It requires
+ the elf-common.h file which contains the portions that are common to
+ both the internal and external representations. */
+
+/* The 64-bit stuff is kind of random. Perhaps someone will publish a
+ spec someday. */
+
+#ifndef _ELF_EXTERNAL_H
+#define _ELF_EXTERNAL_H
+
+/* ELF Header (32-bit implementations) */
+
+typedef struct {
+ unsigned char e_ident[16]; /* ELF "magic number" */
+ unsigned char e_type[2]; /* Identifies object file type */
+ unsigned char e_machine[2]; /* Specifies required architecture */
+ unsigned char e_version[4]; /* Identifies object file version */
+ unsigned char e_entry[4]; /* Entry point virtual address */
+ unsigned char e_phoff[4]; /* Program header table file offset */
+ unsigned char e_shoff[4]; /* Section header table file offset */
+ unsigned char e_flags[4]; /* Processor-specific flags */
+ unsigned char e_ehsize[2]; /* ELF header size in bytes */
+ unsigned char e_phentsize[2]; /* Program header table entry size */
+ unsigned char e_phnum[2]; /* Program header table entry count */
+ unsigned char e_shentsize[2]; /* Section header table entry size */
+ unsigned char e_shnum[2]; /* Section header table entry count */
+ unsigned char e_shstrndx[2]; /* Section header string table index */
+} Elf32_External_Ehdr;
+
+typedef struct {
+ unsigned char e_ident[16]; /* ELF "magic number" */
+ unsigned char e_type[2]; /* Identifies object file type */
+ unsigned char e_machine[2]; /* Specifies required architecture */
+ unsigned char e_version[4]; /* Identifies object file version */
+ unsigned char e_entry[8]; /* Entry point virtual address */
+ unsigned char e_phoff[8]; /* Program header table file offset */
+ unsigned char e_shoff[8]; /* Section header table file offset */
+ unsigned char e_flags[4]; /* Processor-specific flags */
+ unsigned char e_ehsize[2]; /* ELF header size in bytes */
+ unsigned char e_phentsize[2]; /* Program header table entry size */
+ unsigned char e_phnum[2]; /* Program header table entry count */
+ unsigned char e_shentsize[2]; /* Section header table entry size */
+ unsigned char e_shnum[2]; /* Section header table entry count */
+ unsigned char e_shstrndx[2]; /* Section header string table index */
+} Elf64_External_Ehdr;
+
+/* Program header */
+
+typedef struct {
+ unsigned char p_type[4]; /* Identifies program segment type */
+ unsigned char p_offset[4]; /* Segment file offset */
+ unsigned char p_vaddr[4]; /* Segment virtual address */
+ unsigned char p_paddr[4]; /* Segment physical address */
+ unsigned char p_filesz[4]; /* Segment size in file */
+ unsigned char p_memsz[4]; /* Segment size in memory */
+ unsigned char p_flags[4]; /* Segment flags */
+ unsigned char p_align[4]; /* Segment alignment, file & memory */
+} Elf32_External_Phdr;
+
+typedef struct {
+ unsigned char p_type[4]; /* Identifies program segment type */
+ unsigned char p_flags[4]; /* Segment flags */
+ unsigned char p_offset[8]; /* Segment file offset */
+ unsigned char p_vaddr[8]; /* Segment virtual address */
+ unsigned char p_paddr[8]; /* Segment physical address */
+ unsigned char p_filesz[8]; /* Segment size in file */
+ unsigned char p_memsz[8]; /* Segment size in memory */
+ unsigned char p_align[8]; /* Segment alignment, file & memory */
+} Elf64_External_Phdr;
+
+/* Section header */
+
+typedef struct {
+ unsigned char sh_name[4]; /* Section name, index in string tbl */
+ unsigned char sh_type[4]; /* Type of section */
+ unsigned char sh_flags[4]; /* Miscellaneous section attributes */
+ unsigned char sh_addr[4]; /* Section virtual addr at execution */
+ unsigned char sh_offset[4]; /* Section file offset */
+ unsigned char sh_size[4]; /* Size of section in bytes */
+ unsigned char sh_link[4]; /* Index of another section */
+ unsigned char sh_info[4]; /* Additional section information */
+ unsigned char sh_addralign[4]; /* Section alignment */
+ unsigned char sh_entsize[4]; /* Entry size if section holds table */
+} Elf32_External_Shdr;
+
+typedef struct {
+ unsigned char sh_name[4]; /* Section name, index in string tbl */
+ unsigned char sh_type[4]; /* Type of section */
+ unsigned char sh_flags[8]; /* Miscellaneous section attributes */
+ unsigned char sh_addr[8]; /* Section virtual addr at execution */
+ unsigned char sh_offset[8]; /* Section file offset */
+ unsigned char sh_size[8]; /* Size of section in bytes */
+ unsigned char sh_link[4]; /* Index of another section */
+ unsigned char sh_info[4]; /* Additional section information */
+ unsigned char sh_addralign[8]; /* Section alignment */
+ unsigned char sh_entsize[8]; /* Entry size if section holds table */
+} Elf64_External_Shdr;
+
+/* Symbol table entry */
+
+typedef struct {
+ unsigned char st_name[4]; /* Symbol name, index in string tbl */
+ unsigned char st_value[4]; /* Value of the symbol */
+ unsigned char st_size[4]; /* Associated symbol size */
+ unsigned char st_info[1]; /* Type and binding attributes */
+ unsigned char st_other[1]; /* No defined meaning, 0 */
+ unsigned char st_shndx[2]; /* Associated section index */
+} Elf32_External_Sym;
+
+typedef struct {
+ unsigned char st_name[4]; /* Symbol name, index in string tbl */
+ unsigned char st_info[1]; /* Type and binding attributes */
+ unsigned char st_other[1]; /* No defined meaning, 0 */
+ unsigned char st_shndx[2]; /* Associated section index */
+ unsigned char st_value[8]; /* Value of the symbol */
+ unsigned char st_size[8]; /* Associated symbol size */
+} Elf64_External_Sym;
+
+/* Note segments */
+
+typedef struct {
+ unsigned char namesz[4]; /* Size of entry's owner string */
+ unsigned char descsz[4]; /* Size of the note descriptor */
+ unsigned char type[4]; /* Interpretation of the descriptor */
+ char name[1]; /* Start of the name+desc data */
+} Elf_External_Note;
+
+/* Relocation Entries */
+typedef struct {
+ unsigned char r_offset[4]; /* Location at which to apply the action */
+ unsigned char r_info[4]; /* index and type of relocation */
+} Elf32_External_Rel;
+
+typedef struct {
+ unsigned char r_offset[4]; /* Location at which to apply the action */
+ unsigned char r_info[4]; /* index and type of relocation */
+ unsigned char r_addend[4]; /* Constant addend used to compute value */
+} Elf32_External_Rela;
+
+typedef struct {
+ unsigned char r_offset[8]; /* Location at which to apply the action */
+ unsigned char r_info[8]; /* index and type of relocation */
+} Elf64_External_Rel;
+
+typedef struct {
+ unsigned char r_offset[8]; /* Location at which to apply the action */
+ unsigned char r_info[8]; /* index and type of relocation */
+ unsigned char r_addend[8]; /* Constant addend used to compute value */
+} Elf64_External_Rela;
+
+/* dynamic section structure */
+
+typedef struct {
+ unsigned char d_tag[4]; /* entry tag value */
+ union {
+ unsigned char d_val[4];
+ unsigned char d_ptr[4];
+ } d_un;
+} Elf32_External_Dyn;
+
+typedef struct {
+ unsigned char d_tag[8]; /* entry tag value */
+ union {
+ unsigned char d_val[8];
+ unsigned char d_ptr[8];
+ } d_un;
+} Elf64_External_Dyn;
+
+/* The version structures are currently size independent. They are
+ named without a 32 or 64. If that ever changes, these structures
+ will need to be renamed. */
+
+/* This structure appears in a SHT_GNU_verdef section. */
+
+typedef struct {
+ unsigned char vd_version[2];
+ unsigned char vd_flags[2];
+ unsigned char vd_ndx[2];
+ unsigned char vd_cnt[2];
+ unsigned char vd_hash[4];
+ unsigned char vd_aux[4];
+ unsigned char vd_next[4];
+} Elf_External_Verdef;
+
+/* This structure appears in a SHT_GNU_verdef section. */
+
+typedef struct {
+ unsigned char vda_name[4];
+ unsigned char vda_next[4];
+} Elf_External_Verdaux;
+
+/* This structure appears in a SHT_GNU_verneed section. */
+
+typedef struct {
+ unsigned char vn_version[2];
+ unsigned char vn_cnt[2];
+ unsigned char vn_file[4];
+ unsigned char vn_aux[4];
+ unsigned char vn_next[4];
+} Elf_External_Verneed;
+
+/* This structure appears in a SHT_GNU_verneed section. */
+
+typedef struct {
+ unsigned char vna_hash[4];
+ unsigned char vna_flags[2];
+ unsigned char vna_other[2];
+ unsigned char vna_name[4];
+ unsigned char vna_next[4];
+} Elf_External_Vernaux;
+
+/* This structure appears in a SHT_GNU_versym section. This is not a
+ standard ELF structure; ELF just uses Elf32_Half. */
+
+typedef struct {
+ unsigned char vs_vers[2];
+}
+#ifdef __GNUC__
+ __attribute__ ((packed))
+#endif
+ Elf_External_Versym;
+
+/* Structure for syminfo section. */
+typedef struct
+{
+ unsigned char si_boundto[2];
+ unsigned char si_flags[2];
+} Elf_External_Syminfo;
+
+#endif /* _ELF_EXTERNAL_H */
diff --git a/include/elf/fr30.h b/include/elf/fr30.h
new file mode 100644
index 00000000000..223b052973a
--- /dev/null
+++ b/include/elf/fr30.h
@@ -0,0 +1,43 @@
+/* FR30 ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_FR30_H
+#define _ELF_FR30_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_fr30_reloc_type)
+ RELOC_NUMBER (R_FR30_NONE, 0)
+ RELOC_NUMBER (R_FR30_8, 1)
+ RELOC_NUMBER (R_FR30_20, 2)
+ RELOC_NUMBER (R_FR30_32, 3)
+ RELOC_NUMBER (R_FR30_48, 4)
+ RELOC_NUMBER (R_FR30_6_IN_4, 5)
+ RELOC_NUMBER (R_FR30_8_IN_8, 6)
+ RELOC_NUMBER (R_FR30_9_IN_8, 7)
+ RELOC_NUMBER (R_FR30_10_IN_8, 8)
+ RELOC_NUMBER (R_FR30_9_PCREL, 9)
+ RELOC_NUMBER (R_FR30_12_PCREL, 10)
+ RELOC_NUMBER (R_FR30_GNU_VTINHERIT, 11)
+ RELOC_NUMBER (R_FR30_GNU_VTENTRY, 12)
+ EMPTY_RELOC (R_FR30_max)
+END_RELOC_NUMBERS
+
+#endif /* _ELF_FR30_H */
diff --git a/include/elf/hppa.h b/include/elf/hppa.h
new file mode 100644
index 00000000000..2952e2398d2
--- /dev/null
+++ b/include/elf/hppa.h
@@ -0,0 +1,187 @@
+/* HPPA ELF support for BFD.
+ Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the HPPA ELF ABI. Note
+ that most of this is not actually implemented by BFD. */
+
+#ifndef _ELF_HPPA_H
+#define _ELF_HPPA_H
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* Target processor IDs to be placed in the low 16 bits of the flags
+ field. Note these names are shared with SOM, and therefore do not
+ follow ELF naming conventions. */
+
+/* PA 1.0 big endian. */
+#ifndef CPU_PA_RISC1_0
+#define CPU_PA_RISC1_0 0x0000020b
+#endif
+
+/* PA 1.1 big endian. */
+#ifndef CPU_PA_RISC1_1
+#define CPU_PA_RISC1_1 0x00000210
+#endif
+
+/* PA 1.0 little endian (unsupported) is 0x0000028b. */
+/* PA 1.1 little endian (unsupported) is 0x00000290. */
+
+/* Trap null address dereferences. */
+#define ELF_PARISC_TRAPNIL 0x00010000
+
+/* .PARISC.archext section is present. */
+#define EF_PARISC_EXT 0x00020000
+
+/* Processor specific section types. */
+
+/* Holds the global offset table, a table of pointers to external
+ data. */
+#define SHT_PARISC_GOT SHT_LOPROC+0
+
+/* Nonloadable section containing information in architecture
+ extensions used by the code. */
+#define SHT_PARISC_ARCH SHT_LOPROC+1
+
+/* Section in which $global$ is defined. */
+#define SHT_PARISC_GLOBAL SHT_LOPROC+2
+
+/* Section holding millicode routines (mul, div, rem, dyncall, etc. */
+#define SHT_PARISC_MILLI SHT_LOPROC+3
+
+/* Section holding unwind information for use by debuggers. */
+#define SHT_PARISC_UNWIND SHT_LOPROC+4
+
+/* Section holding the procedure linkage table. */
+#define SHT_PARISC_PLT SHT_LOPROC+5
+
+/* Short initialized and uninitialized data. */
+#define SHT_PARISC_SDATA SHT_LOPROC+6
+#define SHT_PARISC_SBSS SHT_LOPROC+7
+
+/* Optional section holding argument location/relocation info. */
+#define SHT_PARISC_SYMEXTN SHT_LOPROC+8
+
+/* Option section for linker stubs. */
+#define SHT_PARISC_STUBS SHT_LOPROC+9
+
+/* Processor specific section flags. */
+
+/* This section is near the global data pointer and thus allows short
+ addressing modes to be used. */
+#define SHF_PARISC_SHORT 0x20000000
+
+/* Processor specific symbol types. */
+
+/* Millicode function entry point. */
+#define STT_PARISC_MILLICODE STT_LOPROC+0
+
+
+/* ELF/HPPA relocation types */
+
+#include "reloc-macros.h"
+
+START_RELOC_NUMBERS (elf32_hppa_reloc_type)
+ RELOC_NUMBER (R_PARISC_NONE, 0) /* No reloc */
+
+ /* These relocation types do simple base + offset relocations. */
+
+ RELOC_NUMBER (R_PARISC_DIR32, 0x01)
+ RELOC_NUMBER (R_PARISC_DIR21L, 0x02)
+ RELOC_NUMBER (R_PARISC_DIR17R, 0x03)
+ RELOC_NUMBER (R_PARISC_DIR17F, 0x04)
+ RELOC_NUMBER (R_PARISC_DIR14R, 0x06)
+
+ /* PC-relative relocation types
+ Typically used for calls.
+ Note PCREL17C and PCREL17F differ only in overflow handling.
+ PCREL17C never reports a relocation error.
+
+ When supporting argument relocations, function calls must be
+ accompanied by parameter relocation information. This information is
+ carried in the ten high-order bits of the addend field. The remaining
+ 22 bits of of the addend field are sign-extended to form the Addend.
+
+ Note the code to build argument relocations depends on the
+ addend being zero. A consequence of this limitation is GAS
+ can not perform relocation reductions for function symbols. */
+
+ RELOC_NUMBER (R_PARISC_PCREL21L, 0x0a)
+ RELOC_NUMBER (R_PARISC_PCREL17R, 0x0b)
+ RELOC_NUMBER (R_PARISC_PCREL17F, 0x0c)
+ RELOC_NUMBER (R_PARISC_PCREL17C, 0x0d)
+ RELOC_NUMBER (R_PARISC_PCREL14R, 0x0e)
+ RELOC_NUMBER (R_PARISC_PCREL14F, 0x0f)
+
+ /* DP-relative relocation types. */
+ RELOC_NUMBER (R_PARISC_DPREL21L, 0x12)
+ RELOC_NUMBER (R_PARISC_DPREL14R, 0x16)
+ RELOC_NUMBER (R_PARISC_DPREL14F, 0x17)
+
+ /* Data linkage table (DLT) relocation types
+
+ SOM DLT_REL fixup requests are used to for static data references
+ from position-independent code within shared libraries. They are
+ similar to the GOT relocation types in some SVR4 implementations. */
+
+ RELOC_NUMBER (R_PARISC_DLTREL21L, 0x1a)
+ RELOC_NUMBER (R_PARISC_DLTREL14R, 0x1e)
+ RELOC_NUMBER (R_PARISC_DLTREL14F, 0x1f)
+
+ /* DLT indirect relocation types */
+ RELOC_NUMBER (R_PARISC_DLTIND21L, 0x22)
+ RELOC_NUMBER (R_PARISC_DLTIND14R, 0x26)
+ RELOC_NUMBER (R_PARISC_DLTIND14F, 0x27)
+
+ /* Base relative relocation types. Ugh. These imply lots of state */
+ RELOC_NUMBER (R_PARISC_SETBASE, 0x28)
+ RELOC_NUMBER (R_PARISC_BASEREL32, 0x29)
+ RELOC_NUMBER (R_PARISC_BASEREL21L, 0x2a)
+ RELOC_NUMBER (R_PARISC_BASEREL17R, 0x2b)
+ RELOC_NUMBER (R_PARISC_BASEREL17F, 0x2c)
+ RELOC_NUMBER (R_PARISC_BASEREL14R, 0x2e)
+ RELOC_NUMBER (R_PARISC_BASEREL14F, 0x2f)
+
+ /* Segment relative relocation types. */
+ RELOC_NUMBER (R_PARISC_TEXTREL32, 0x31)
+ RELOC_NUMBER (R_PARISC_DATAREL32, 0x39)
+
+ /* Plabel relocation types. */
+ RELOC_NUMBER (R_PARISC_PLABEL32, 0x41)
+ RELOC_NUMBER (R_PARISC_PLABEL21L, 0x42)
+ RELOC_NUMBER (R_PARISC_PLABEL14R, 0x46)
+
+ /* PLT relocations. */
+ RELOC_NUMBER (R_PARISC_PLTIND21L, 0x82)
+ RELOC_NUMBER (R_PARISC_PLTIND14R, 0x86)
+ RELOC_NUMBER (R_PARISC_PLTIND14F, 0x87)
+
+ /* Misc relocation types. */
+ RELOC_NUMBER (R_PARISC_COPY, 0x88)
+ RELOC_NUMBER (R_PARISC_GLOB_DAT, 0x89)
+ RELOC_NUMBER (R_PARISC_JMP_SLOT, 0x8a)
+ RELOC_NUMBER (R_PARISC_RELATIVE, 0x8b)
+
+ EMPTY_RELOC (R_PARISC_UNIMPLEMENTED)
+END_RELOC_NUMBERS
+
+#ifndef RELOC_MACROS_GEN_FUNC
+typedef enum elf32_hppa_reloc_type elf32_hppa_reloc_type;
+#endif
+
+#endif /* _ELF_HPPA_H */
diff --git a/include/elf/i386.h b/include/elf/i386.h
new file mode 100644
index 00000000000..219f10511fe
--- /dev/null
+++ b/include/elf/i386.h
@@ -0,0 +1,49 @@
+/* ix86 ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_I386_H
+#define _ELF_I386_H
+
+#include "reloc-macros.h"
+
+START_RELOC_NUMBERS (elf_i386_reloc_type)
+ RELOC_NUMBER (R_386_NONE, 0) /* No reloc */
+ RELOC_NUMBER (R_386_32, 1) /* Direct 32 bit */
+ RELOC_NUMBER (R_386_PC32, 2) /* PC relative 32 bit */
+ RELOC_NUMBER (R_386_GOT32, 3) /* 32 bit GOT entry */
+ RELOC_NUMBER (R_386_PLT32, 4) /* 32 bit PLT address */
+ RELOC_NUMBER (R_386_COPY, 5) /* Copy symbol at runtime */
+ RELOC_NUMBER (R_386_GLOB_DAT, 6) /* Create GOT entry */
+ RELOC_NUMBER (R_386_JUMP_SLOT, 7) /* Create PLT entry */
+ RELOC_NUMBER (R_386_RELATIVE, 8) /* Adjust by program base */
+ RELOC_NUMBER (R_386_GOTOFF, 9) /* 32 bit offset to GOT */
+ RELOC_NUMBER (R_386_GOTPC, 10) /* 32 bit PC relative offset to GOT */
+ FAKE_RELOC (FIRST_INVALID_RELOC, 11)
+ FAKE_RELOC (LAST_INVALID_RELOC, 19)
+ RELOC_NUMBER (R_386_16, 20)
+ RELOC_NUMBER (R_386_PC16, 21)
+ RELOC_NUMBER (R_386_8, 22)
+ RELOC_NUMBER (R_386_PC8, 23)
+ RELOC_NUMBER (R_386_max, 24)
+ /* These are GNU extensions to enable C++ vtable garbage collection. */
+ RELOC_NUMBER (R_386_GNU_VTINHERIT, 250)
+ RELOC_NUMBER (R_386_GNU_VTENTRY, 251)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/internal.h b/include/elf/internal.h
new file mode 100644
index 00000000000..a9b81a0707b
--- /dev/null
+++ b/include/elf/internal.h
@@ -0,0 +1,312 @@
+/* ELF support for BFD.
+ Copyright (C) 1991, 92, 93, 94, 95, 97, 1998 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, from information published
+ in "UNIX System V Release 4, Programmers Guide: ANSI C and
+ Programming Support Tools".
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of ELF support for BFD, and contains the portions
+ that describe how ELF is represented internally in the BFD library.
+ I.E. it describes the in-memory representation of ELF. It requires
+ the elf-common.h file which contains the portions that are common to
+ both the internal and external representations. */
+
+
+/* NOTE that these structures are not kept in the same order as they appear
+ in the object file. In some cases they've been reordered for more optimal
+ packing under various circumstances. */
+
+#ifndef _ELF_INTERNAL_H
+#define _ELF_INTERNAL_H
+
+/* ELF Header */
+
+#define EI_NIDENT 16 /* Size of e_ident[] */
+
+typedef struct elf_internal_ehdr {
+ unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */
+ bfd_vma e_entry; /* Entry point virtual address */
+ bfd_size_type e_phoff; /* Program header table file offset */
+ bfd_size_type e_shoff; /* Section header table file offset */
+ unsigned long e_version; /* Identifies object file version */
+ unsigned long e_flags; /* Processor-specific flags */
+ unsigned short e_type; /* Identifies object file type */
+ unsigned short e_machine; /* Specifies required architecture */
+ unsigned short e_ehsize; /* ELF header size in bytes */
+ unsigned short e_phentsize; /* Program header table entry size */
+ unsigned short e_phnum; /* Program header table entry count */
+ unsigned short e_shentsize; /* Section header table entry size */
+ unsigned short e_shnum; /* Section header table entry count */
+ unsigned short e_shstrndx; /* Section header string table index */
+} Elf_Internal_Ehdr;
+
+#define elf32_internal_ehdr elf_internal_ehdr
+#define Elf32_Internal_Ehdr Elf_Internal_Ehdr
+#define elf64_internal_ehdr elf_internal_ehdr
+#define Elf64_Internal_Ehdr Elf_Internal_Ehdr
+
+/* Program header */
+
+struct elf_internal_phdr {
+ unsigned long p_type; /* Identifies program segment type */
+ unsigned long p_flags; /* Segment flags */
+ bfd_vma p_offset; /* Segment file offset */
+ bfd_vma p_vaddr; /* Segment virtual address */
+ bfd_vma p_paddr; /* Segment physical address */
+ bfd_vma p_filesz; /* Segment size in file */
+ bfd_vma p_memsz; /* Segment size in memory */
+ bfd_vma p_align; /* Segment alignment, file & memory */
+};
+
+typedef struct elf_internal_phdr Elf_Internal_Phdr;
+#define elf32_internal_phdr elf_internal_phdr
+#define Elf32_Internal_Phdr Elf_Internal_Phdr
+#define elf64_internal_phdr elf_internal_phdr
+#define Elf64_Internal_Phdr Elf_Internal_Phdr
+
+/* Section header */
+
+typedef struct elf_internal_shdr {
+ unsigned int sh_name; /* Section name, index in string tbl */
+ unsigned int sh_type; /* Type of section */
+ bfd_vma sh_flags; /* Miscellaneous section attributes */
+ bfd_vma sh_addr; /* Section virtual addr at execution */
+ bfd_size_type sh_size; /* Size of section in bytes */
+ bfd_size_type sh_entsize; /* Entry size if section holds table */
+ unsigned long sh_link; /* Index of another section */
+ unsigned long sh_info; /* Additional section information */
+ file_ptr sh_offset; /* Section file offset */
+ unsigned int sh_addralign; /* Section alignment */
+
+ /* The internal rep also has some cached info associated with it. */
+ asection * bfd_section; /* Associated BFD section. */
+ PTR contents; /* Section contents. */
+} Elf_Internal_Shdr;
+
+#define elf32_internal_shdr elf_internal_shdr
+#define Elf32_Internal_Shdr Elf_Internal_Shdr
+#define elf64_internal_shdr elf_internal_shdr
+#define Elf64_Internal_Shdr Elf_Internal_Shdr
+
+/* Symbol table entry */
+
+struct elf_internal_sym {
+ bfd_vma st_value; /* Value of the symbol */
+ bfd_vma st_size; /* Associated symbol size */
+ unsigned long st_name; /* Symbol name, index in string tbl */
+ unsigned char st_info; /* Type and binding attributes */
+ unsigned char st_other; /* No defined meaning, 0 */
+ unsigned short st_shndx; /* Associated section index */
+};
+
+typedef struct elf_internal_sym Elf_Internal_Sym;
+
+#define elf32_internal_sym elf_internal_sym
+#define elf64_internal_sym elf_internal_sym
+#define Elf32_Internal_Sym Elf_Internal_Sym
+#define Elf64_Internal_Sym Elf_Internal_Sym
+
+/* Note segments */
+
+typedef struct elf_internal_note {
+ unsigned long namesz; /* Size of entry's owner string */
+ unsigned long descsz; /* Size of the note descriptor */
+ unsigned long type; /* Interpretation of the descriptor */
+ char * namedata; /* Start of the name+desc data */
+ char * descdata; /* Start of the desc data */
+ bfd_vma descpos; /* File offset of the descdata */
+} Elf_Internal_Note;
+#define Elf32_Internal_Note Elf_Internal_Note
+#define elf32_internal_note elf_internal_note
+
+/* Relocation Entries */
+
+typedef struct elf_internal_rel {
+ bfd_vma r_offset; /* Location at which to apply the action */
+ /* This needs to support 64-bit values in elf64. */
+ bfd_vma r_info; /* index and type of relocation */
+} Elf_Internal_Rel;
+
+#define elf32_internal_rel elf_internal_rel
+#define Elf32_Internal_Rel Elf_Internal_Rel
+#define elf64_internal_rel elf_internal_rel
+#define Elf64_Internal_Rel Elf_Internal_Rel
+
+typedef struct elf_internal_rela {
+ bfd_vma r_offset; /* Location at which to apply the action */
+ bfd_vma r_info; /* Index and Type of relocation */
+ bfd_signed_vma r_addend; /* Constant addend used to compute value */
+} Elf_Internal_Rela;
+
+#define elf32_internal_rela elf_internal_rela
+#define elf64_internal_rela elf_internal_rela
+#define Elf32_Internal_Rela Elf_Internal_Rela
+#define Elf64_Internal_Rela Elf_Internal_Rela
+
+/* dynamic section structure */
+
+typedef struct elf_internal_dyn {
+ /* This needs to support 64-bit values in elf64. */
+ bfd_vma d_tag; /* entry tag value */
+ union {
+ /* This needs to support 64-bit values in elf64. */
+ bfd_vma d_val;
+ bfd_vma d_ptr;
+ } d_un;
+} Elf_Internal_Dyn;
+
+#define elf32_internal_dyn elf_internal_dyn
+#define elf64_internal_dyn elf_internal_dyn
+#define Elf32_Internal_Dyn Elf_Internal_Dyn
+#define Elf64_Internal_Dyn Elf_Internal_Dyn
+
+/* This structure appears in a SHT_GNU_verdef section. */
+
+typedef struct elf_internal_verdef {
+ unsigned short vd_version; /* Version number of structure. */
+ unsigned short vd_flags; /* Flags (VER_FLG_*). */
+ unsigned short vd_ndx; /* Version index. */
+ unsigned short vd_cnt; /* Number of verdaux entries. */
+ unsigned long vd_hash; /* Hash of name. */
+ unsigned long vd_aux; /* Offset to verdaux entries. */
+ unsigned long vd_next; /* Offset to next verdef. */
+
+ /* These fields are set up when BFD reads in the structure. FIXME:
+ It would be cleaner to store these in a different structure. */
+ bfd *vd_bfd; /* BFD. */
+ const char *vd_nodename; /* Version name. */
+ struct elf_internal_verdef *vd_nextdef; /* vd_next as pointer. */
+ struct elf_internal_verdaux *vd_auxptr; /* vd_aux as pointer. */
+ unsigned int vd_exp_refno; /* Used by the linker. */
+} Elf_Internal_Verdef;
+
+/* This structure appears in a SHT_GNU_verdef section. */
+
+typedef struct elf_internal_verdaux {
+ unsigned long vda_name; /* String table offset of name. */
+ unsigned long vda_next; /* Offset to next verdaux. */
+
+ /* These fields are set up when BFD reads in the structure. FIXME:
+ It would be cleaner to store these in a different structure. */
+ const char *vda_nodename; /* vda_name as pointer. */
+ struct elf_internal_verdaux *vda_nextptr; /* vda_next as pointer. */
+} Elf_Internal_Verdaux;
+
+/* This structure appears in a SHT_GNU_verneed section. */
+
+typedef struct elf_internal_verneed {
+ unsigned short vn_version; /* Version number of structure. */
+ unsigned short vn_cnt; /* Number of vernaux entries. */
+ unsigned long vn_file; /* String table offset of library name. */
+ unsigned long vn_aux; /* Offset to vernaux entries. */
+ unsigned long vn_next; /* Offset to next verneed. */
+
+ /* These fields are set up when BFD reads in the structure. FIXME:
+ It would be cleaner to store these in a different structure. */
+ bfd *vn_bfd; /* BFD. */
+ const char *vn_filename; /* vn_file as pointer. */
+ struct elf_internal_vernaux *vn_auxptr; /* vn_aux as pointer. */
+ struct elf_internal_verneed *vn_nextref; /* vn_nextref as pointer. */
+} Elf_Internal_Verneed;
+
+/* This structure appears in a SHT_GNU_verneed section. */
+
+typedef struct elf_internal_vernaux {
+ unsigned long vna_hash; /* Hash of dependency name. */
+ unsigned short vna_flags; /* Flags (VER_FLG_*). */
+ unsigned short vna_other; /* Unused. */
+ unsigned long vna_name; /* String table offset to version name. */
+ unsigned long vna_next; /* Offset to next vernaux. */
+
+ /* These fields are set up when BFD reads in the structure. FIXME:
+ It would be cleaner to store these in a different structure. */
+ const char *vna_nodename; /* vna_name as pointer. */
+ struct elf_internal_vernaux *vna_nextptr; /* vna_next as pointer. */
+} Elf_Internal_Vernaux;
+
+/* This structure appears in a SHT_GNU_versym section. This is not a
+ standard ELF structure; ELF just uses Elf32_Half. */
+
+typedef struct elf_internal_versym {
+ unsigned short vs_vers;
+} Elf_Internal_Versym;
+
+/* Structure for syminfo section. */
+typedef struct
+{
+ unsigned short int si_boundto;
+ unsigned short int si_flags;
+} Elf_Internal_Syminfo;
+
+
+#define elf32_internal_verdef elf_internal_verdef
+#define elf64_internal_verdef elf_internal_verdef
+#define elf32_internal_verdaux elf_internal_verdaux
+#define elf64_internal_verdaux elf_internal_verdaux
+#define elf32_internal_verneed elf_internal_verneed
+#define elf64_internal_verneed elf_internal_verneed
+#define elf32_internal_vernaux elf_internal_vernaux
+#define elf64_internal_vernaux elf_internal_vernaux
+#define elf32_internal_versym elf_internal_versym
+#define elf64_internal_versym elf_internal_versym
+
+#define Elf32_Internal_Verdef Elf_Internal_Verdef
+#define Elf64_Internal_Verdef Elf_Internal_Verdef
+#define Elf32_Internal_Verdaux Elf_Internal_Verdaux
+#define Elf64_Internal_Verdaux Elf_Internal_Verdaux
+#define Elf32_Internal_Verneed Elf_Internal_Verneed
+#define Elf64_Internal_Verneed Elf_Internal_Verneed
+#define Elf32_Internal_Vernaux Elf_Internal_Vernaux
+#define Elf64_Internal_Vernaux Elf_Internal_Vernaux
+#define Elf32_Internal_Versym Elf_Internal_Versym
+#define Elf64_Internal_Versym Elf_Internal_Versym
+#define Elf32_Internal_Syminfo Elf_Internal_Syminfo
+#define Elf64_Internal_Syminfo Elf_Internal_Syminfo
+
+/* This structure is used to describe how sections should be assigned
+ to program segments. */
+
+struct elf_segment_map
+{
+ /* Next program segment. */
+ struct elf_segment_map *next;
+ /* Program segment type. */
+ unsigned long p_type;
+ /* Program segment flags. */
+ unsigned long p_flags;
+ /* Program segment physical address. */
+ bfd_vma p_paddr;
+ /* Whether the p_flags field is valid; if not, the flags are based
+ on the section flags. */
+ unsigned int p_flags_valid : 1;
+ /* Whether the p_paddr field is valid; if not, the physical address
+ is based on the section lma values. */
+ unsigned int p_paddr_valid : 1;
+ /* Whether this segment includes the file header. */
+ unsigned int includes_filehdr : 1;
+ /* Whether this segment includes the program headers. */
+ unsigned int includes_phdrs : 1;
+ /* Number of sections (may be 0). */
+ unsigned int count;
+ /* Sections. Actual number of elements is in count field. */
+ asection *sections[1];
+};
+
+#endif /* _ELF_INTERNAL_H */
diff --git a/include/elf/m32r.h b/include/elf/m32r.h
new file mode 100644
index 00000000000..0537d1369cd
--- /dev/null
+++ b/include/elf/m32r.h
@@ -0,0 +1,66 @@
+/* M32R ELF support for BFD.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_M32R_H
+#define _ELF_M32R_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_m32r_reloc_type)
+ RELOC_NUMBER (R_M32R_NONE, 0)
+ RELOC_NUMBER (R_M32R_16, 1)
+ RELOC_NUMBER (R_M32R_32, 2)
+ RELOC_NUMBER (R_M32R_24, 3)
+ RELOC_NUMBER (R_M32R_10_PCREL, 4)
+ RELOC_NUMBER (R_M32R_18_PCREL, 5)
+ RELOC_NUMBER (R_M32R_26_PCREL, 6)
+ RELOC_NUMBER (R_M32R_HI16_ULO, 7)
+ RELOC_NUMBER (R_M32R_HI16_SLO, 8)
+ RELOC_NUMBER (R_M32R_LO16, 9)
+ RELOC_NUMBER (R_M32R_SDA16, 10)
+ RELOC_NUMBER (R_M32R_GNU_VTINHERIT, 11)
+ RELOC_NUMBER (R_M32R_GNU_VTENTRY, 12)
+ EMPTY_RELOC (R_M32R_max)
+END_RELOC_NUMBERS
+
+/* Processor specific section indices. These sections do not actually
+ exist. Symbols with a st_shndx field corresponding to one of these
+ values have a special meaning. */
+
+/* Small common symbol. */
+#define SHN_M32R_SCOMMON 0xff00
+
+/* Processor specific section flags. */
+
+/* This section contains sufficient relocs to be relaxed.
+ When relaxing, even relocs of branch instructions the assembler could
+ complete must be present because relaxing may cause the branch target to
+ move. */
+#define SHF_M32R_CAN_RELAX 0x10000000
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* Two bit m32r architecture field. */
+#define EF_M32R_ARCH 0x30000000
+
+/* m32r code. */
+#define E_M32R_ARCH 0x00000000
+
+#endif
diff --git a/include/elf/m68k.h b/include/elf/m68k.h
new file mode 100644
index 00000000000..db31cdcda45
--- /dev/null
+++ b/include/elf/m68k.h
@@ -0,0 +1,56 @@
+/* MC68k ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_M68K_H
+#define _ELF_M68K_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocation types. */
+START_RELOC_NUMBERS (elf_m68k_reloc_type)
+ RELOC_NUMBER (R_68K_NONE, 0) /* No reloc */
+ RELOC_NUMBER (R_68K_32, 1) /* Direct 32 bit */
+ RELOC_NUMBER (R_68K_16, 2) /* Direct 16 bit */
+ RELOC_NUMBER (R_68K_8, 3) /* Direct 8 bit */
+ RELOC_NUMBER (R_68K_PC32, 4) /* PC relative 32 bit */
+ RELOC_NUMBER (R_68K_PC16, 5) /* PC relative 16 bit */
+ RELOC_NUMBER (R_68K_PC8, 6) /* PC relative 8 bit */
+ RELOC_NUMBER (R_68K_GOT32, 7) /* 32 bit PC relative GOT entry */
+ RELOC_NUMBER (R_68K_GOT16, 8) /* 16 bit PC relative GOT entry */
+ RELOC_NUMBER (R_68K_GOT8, 9) /* 8 bit PC relative GOT entry */
+ RELOC_NUMBER (R_68K_GOT32O, 10) /* 32 bit GOT offset */
+ RELOC_NUMBER (R_68K_GOT16O, 11) /* 16 bit GOT offset */
+ RELOC_NUMBER (R_68K_GOT8O, 12) /* 8 bit GOT offset */
+ RELOC_NUMBER (R_68K_PLT32, 13) /* 32 bit PC relative PLT address */
+ RELOC_NUMBER (R_68K_PLT16, 14) /* 16 bit PC relative PLT address */
+ RELOC_NUMBER (R_68K_PLT8, 15) /* 8 bit PC relative PLT address */
+ RELOC_NUMBER (R_68K_PLT32O, 16) /* 32 bit PLT offset */
+ RELOC_NUMBER (R_68K_PLT16O, 17) /* 16 bit PLT offset */
+ RELOC_NUMBER (R_68K_PLT8O, 18) /* 8 bit PLT offset */
+ RELOC_NUMBER (R_68K_COPY, 19) /* Copy symbol at runtime */
+ RELOC_NUMBER (R_68K_GLOB_DAT, 20) /* Create GOT entry */
+ RELOC_NUMBER (R_68K_JMP_SLOT, 21) /* Create PLT entry */
+ RELOC_NUMBER (R_68K_RELATIVE, 22) /* Adjust by program base */
+ /* These are GNU extensions to enable C++ vtable garbage collection. */
+ RELOC_NUMBER (R_68K_GNU_VTINHERIT, 23)
+ RELOC_NUMBER (R_68K_GNU_VTENTRY, 24)
+ EMPTY_RELOC (R_68K_max)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/mcore.h b/include/elf/mcore.h
new file mode 100644
index 00000000000..a7c4dad112d
--- /dev/null
+++ b/include/elf/mcore.h
@@ -0,0 +1,43 @@
+/* Motorolla MCore support for BFD.
+ Copyright (C) 1995, 1999 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the MCore ELF ABI. */
+#ifndef _ELF_MORE_H
+#define _ELF_MORE_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_mcore_reloc_type)
+ RELOC_NUMBER (R_MCORE_NONE, 0)
+ RELOC_NUMBER (R_MCORE_ADDR32, 1)
+ RELOC_NUMBER (R_MCORE_PCRELIMM8BY4, 2)
+ RELOC_NUMBER (R_MCORE_PCRELIMM11BY2, 3)
+ RELOC_NUMBER (R_MCORE_PCRELIMM4BY2, 4)
+ RELOC_NUMBER (R_MCORE_PCREL32, 5)
+ RELOC_NUMBER (R_MCORE_PCRELJSR_IMM11BY2, 6)
+ RELOC_NUMBER (R_MCORE_GNU_VTINHERIT, 7)
+ RELOC_NUMBER (R_MCORE_GNU_VTENTRY, 8)
+ EMPTY_RELOC (R_MCORE_max)
+END_RELOC_NUMBERS
+
+/* Section Attributes. */
+#define SHF_MCORE_NOREAD 0x80000000
+
+#endif /* _ELF_MCORE_H */
diff --git a/include/elf/mips.h b/include/elf/mips.h
new file mode 100644
index 00000000000..c967248da91
--- /dev/null
+++ b/include/elf/mips.h
@@ -0,0 +1,860 @@
+/* MIPS ELF support for BFD.
+ Copyright (C) 1993, 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
+
+ By Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>, from
+ information in the System V Application Binary Interface, MIPS
+ Processor Supplement.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the MIPS ELF ABI. Note
+ that most of this is not actually implemented by BFD. */
+
+#ifndef _ELF_MIPS_H
+#define _ELF_MIPS_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocation types. */
+START_RELOC_NUMBERS (elf_mips_reloc_type)
+ RELOC_NUMBER (R_MIPS_NONE, 0)
+ RELOC_NUMBER (R_MIPS_16, 1)
+ RELOC_NUMBER (R_MIPS_32, 2)
+ RELOC_NUMBER (R_MIPS_REL32, 3)
+ RELOC_NUMBER (R_MIPS_26, 4)
+ RELOC_NUMBER (R_MIPS_HI16, 5)
+ RELOC_NUMBER (R_MIPS_LO16, 6)
+ RELOC_NUMBER (R_MIPS_GPREL16, 7)
+ RELOC_NUMBER (R_MIPS_LITERAL, 8)
+ RELOC_NUMBER (R_MIPS_GOT16, 9)
+ RELOC_NUMBER (R_MIPS_PC16, 10)
+ RELOC_NUMBER (R_MIPS_CALL16, 11)
+ RELOC_NUMBER (R_MIPS_GPREL32, 12)
+ /* The remaining relocs are defined on Irix, although they are not
+ in the MIPS ELF ABI. */
+ RELOC_NUMBER (R_MIPS_UNUSED1, 13)
+ RELOC_NUMBER (R_MIPS_UNUSED2, 14)
+ RELOC_NUMBER (R_MIPS_UNUSED3, 15)
+ RELOC_NUMBER (R_MIPS_SHIFT5, 16)
+ RELOC_NUMBER (R_MIPS_SHIFT6, 17)
+ RELOC_NUMBER (R_MIPS_64, 18)
+ RELOC_NUMBER (R_MIPS_GOT_DISP, 19)
+ RELOC_NUMBER (R_MIPS_GOT_PAGE, 20)
+ RELOC_NUMBER (R_MIPS_GOT_OFST, 21)
+ RELOC_NUMBER (R_MIPS_GOT_HI16, 22)
+ RELOC_NUMBER (R_MIPS_GOT_LO16, 23)
+ RELOC_NUMBER (R_MIPS_SUB, 24)
+ RELOC_NUMBER (R_MIPS_INSERT_A, 25)
+ RELOC_NUMBER (R_MIPS_INSERT_B, 26)
+ RELOC_NUMBER (R_MIPS_DELETE, 27)
+ RELOC_NUMBER (R_MIPS_HIGHER, 28)
+ RELOC_NUMBER (R_MIPS_HIGHEST, 29)
+ RELOC_NUMBER (R_MIPS_CALL_HI16, 30)
+ RELOC_NUMBER (R_MIPS_CALL_LO16, 31)
+ RELOC_NUMBER (R_MIPS_SCN_DISP, 32)
+ RELOC_NUMBER (R_MIPS_REL16, 33)
+ RELOC_NUMBER (R_MIPS_ADD_IMMEDIATE, 34)
+ RELOC_NUMBER (R_MIPS_PJUMP, 35)
+ RELOC_NUMBER (R_MIPS_RELGOT, 36)
+ RELOC_NUMBER (R_MIPS_JALR, 37)
+ RELOC_NUMBER (R_MIPS_max, 38)
+ /* These relocs are used for the mips16. */
+ RELOC_NUMBER (R_MIPS16_26, 100)
+ RELOC_NUMBER (R_MIPS16_GPREL, 101)
+ /* These are GNU extensions to enable C++ vtable garbage collection. */
+ RELOC_NUMBER (R_MIPS_GNU_VTINHERIT, 253)
+ RELOC_NUMBER (R_MIPS_GNU_VTENTRY, 254)
+END_RELOC_NUMBERS
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* At least one .noreorder directive appears in the source. */
+#define EF_MIPS_NOREORDER 0x00000001
+
+/* File contains position independent code. */
+#define EF_MIPS_PIC 0x00000002
+
+/* Code in file uses the standard calling sequence for calling
+ position independent code. */
+#define EF_MIPS_CPIC 0x00000004
+
+/* Code in file uses new ABI (-n32 on Irix 6). */
+#define EF_MIPS_ABI2 0x00000020
+
+/* Indicates code compiled for a 64-bit machine in 32-bit mode.
+ (regs are 32-bits wide.) */
+#define EF_MIPS_32BITMODE 0x00000100
+
+/* Four bit MIPS architecture field. */
+#define EF_MIPS_ARCH 0xf0000000
+
+/* -mips1 code. */
+#define E_MIPS_ARCH_1 0x00000000
+
+/* -mips2 code. */
+#define E_MIPS_ARCH_2 0x10000000
+
+/* -mips3 code. */
+#define E_MIPS_ARCH_3 0x20000000
+
+/* -mips4 code. */
+#define E_MIPS_ARCH_4 0x30000000
+
+/* The ABI of the file. Also see EF_MIPS_ABI2 above. */
+#define EF_MIPS_ABI 0x0000F000
+
+/* The original o32 abi. */
+#define E_MIPS_ABI_O32 0x00001000
+
+/* O32 extended to work on 64 bit architectures */
+#define E_MIPS_ABI_O64 0x00002000
+
+/* EABI in 32 bit mode */
+#define E_MIPS_ABI_EABI32 0x00003000
+
+/* EABI in 64 bit mode */
+#define E_MIPS_ABI_EABI64 0x00004000
+
+
+/* Machine variant if we know it. This field was invented at Cygnus,
+ but it is hoped that other vendors will adopt it. If some standard
+ is developed, this code should be changed to follow it. */
+
+#define EF_MIPS_MACH 0x00FF0000
+
+/* Cygnus is choosing values between 80 and 9F;
+ 00 - 7F should be left for a future standard;
+ the rest are open. */
+
+#define E_MIPS_MACH_3900 0x00810000
+
+#define E_MIPS_MACH_4010 0x00820000
+#define E_MIPS_MACH_4100 0x00830000
+#define E_MIPS_MACH_4650 0x00850000
+#define E_MIPS_MACH_4111 0x00880000
+
+
+/* Processor specific section indices. These sections do not actually
+ exist. Symbols with a st_shndx field corresponding to one of these
+ values have a special meaning. */
+
+/* Defined and allocated common symbol. Value is virtual address. If
+ relocated, alignment must be preserved. */
+#define SHN_MIPS_ACOMMON 0xff00
+
+/* Defined and allocated text symbol. Value is virtual address.
+ Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */
+#define SHN_MIPS_TEXT 0xff01
+
+/* Defined and allocated data symbol. Value is virtual address.
+ Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */
+#define SHN_MIPS_DATA 0xff02
+
+/* Small common symbol. */
+#define SHN_MIPS_SCOMMON 0xff03
+
+/* Small undefined symbol. */
+#define SHN_MIPS_SUNDEFINED 0xff04
+
+/* Processor specific section types. */
+
+/* Section contains the set of dynamic shared objects used when
+ statically linking. */
+#define SHT_MIPS_LIBLIST 0x70000000
+
+/* I'm not sure what this is, but it's used on Irix 5. */
+#define SHT_MIPS_MSYM 0x70000001
+
+/* Section contains list of symbols whose definitions conflict with
+ symbols defined in shared objects. */
+#define SHT_MIPS_CONFLICT 0x70000002
+
+/* Section contains the global pointer table. */
+#define SHT_MIPS_GPTAB 0x70000003
+
+/* Section contains microcode information. The exact format is
+ unspecified. */
+#define SHT_MIPS_UCODE 0x70000004
+
+/* Section contains some sort of debugging information. The exact
+ format is unspecified. It's probably ECOFF symbols. */
+#define SHT_MIPS_DEBUG 0x70000005
+
+/* Section contains register usage information. */
+#define SHT_MIPS_REGINFO 0x70000006
+
+/* ??? */
+#define SHT_MIPS_PACKAGE 0x70000007
+
+/* ??? */
+#define SHT_MIPS_PACKSYM 0x70000008
+
+/* ??? */
+#define SHT_MIPS_RELD 0x70000009
+
+/* Section contains interface information. */
+#define SHT_MIPS_IFACE 0x7000000b
+
+/* Section contains description of contents of another section. */
+#define SHT_MIPS_CONTENT 0x7000000c
+
+/* Section contains miscellaneous options. */
+#define SHT_MIPS_OPTIONS 0x7000000d
+
+/* ??? */
+#define SHT_MIPS_SHDR 0x70000010
+
+/* ??? */
+#define SHT_MIPS_FDESC 0x70000011
+
+/* ??? */
+#define SHT_MIPS_EXTSYM 0x70000012
+
+/* ??? */
+#define SHT_MIPS_DENSE 0x70000013
+
+/* ??? */
+#define SHT_MIPS_PDESC 0x70000014
+
+/* ??? */
+#define SHT_MIPS_LOCSYM 0x70000015
+
+/* ??? */
+#define SHT_MIPS_AUXSYM 0x70000016
+
+/* ??? */
+#define SHT_MIPS_OPTSYM 0x70000017
+
+/* ??? */
+#define SHT_MIPS_LOCSTR 0x70000018
+
+/* ??? */
+#define SHT_MIPS_LINE 0x70000019
+
+/* ??? */
+#define SHT_MIPS_RFDESC 0x7000001a
+
+/* ??? */
+#define SHT_MIPS_DELTASYM 0x7000001b
+
+/* ??? */
+#define SHT_MIPS_DELTAINST 0x7000001c
+
+/* ??? */
+#define SHT_MIPS_DELTACLASS 0x7000001d
+
+/* DWARF debugging section. */
+#define SHT_MIPS_DWARF 0x7000001e
+
+/* ??? */
+#define SHT_MIPS_DELTADECL 0x7000001f
+
+/* List of libraries the binary depends on. Includes a time stamp, version
+ number. */
+#define SHT_MIPS_SYMBOL_LIB 0x70000020
+
+/* Events section. */
+#define SHT_MIPS_EVENTS 0x70000021
+
+/* ??? */
+#define SHT_MIPS_TRANSLATE 0x70000022
+
+/* ??? */
+#define SHT_MIPS_PIXIE 0x70000023
+
+/* ??? */
+#define SHT_MIPS_XLATE 0x70000024
+
+/* ??? */
+#define SHT_MIPS_XLATE_DEBUG 0x70000025
+
+/* ??? */
+#define SHT_MIPS_WHIRL 0x70000026
+
+/* ??? */
+#define SHT_MIPS_EH_REGION 0x70000027
+
+/* ??? */
+#define SHT_MIPS_XLATE_OLD 0x70000028
+
+/* ??? */
+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
+
+
+/* A section of type SHT_MIPS_LIBLIST contains an array of the
+ following structure. The sh_link field is the section index of the
+ string table. The sh_info field is the number of entries in the
+ section. */
+typedef struct
+{
+ /* String table index for name of shared object. */
+ unsigned long l_name;
+ /* Time stamp. */
+ unsigned long l_time_stamp;
+ /* Checksum of symbol names and common sizes. */
+ unsigned long l_checksum;
+ /* String table index for version. */
+ unsigned long l_version;
+ /* Flags. */
+ unsigned long l_flags;
+} Elf32_Lib;
+
+/* The external version of Elf32_Lib. */
+typedef struct
+{
+ unsigned char l_name[4];
+ unsigned char l_time_stamp[4];
+ unsigned char l_checksum[4];
+ unsigned char l_version[4];
+ unsigned char l_flags[4];
+} Elf32_External_Lib;
+
+/* The l_flags field of an Elf32_Lib structure may contain the
+ following flags. */
+
+/* Require an exact match at runtime. */
+#define LL_EXACT_MATCH 0x00000001
+
+/* Ignore version incompatibilities at runtime. */
+#define LL_IGNORE_INT_VER 0x00000002
+
+/* Require matching minor version number. */
+#define LL_REQUIRE_MINOR 0x00000004
+
+/* ??? */
+#define LL_EXPORTS 0x00000008
+
+/* Delay loading of this library until really needed. */
+#define LL_DELAY_LOAD 0x00000010
+
+/* ??? Delta C++ stuff ??? */
+#define LL_DELTA 0x00000020
+
+
+/* A section of type SHT_MIPS_CONFLICT is an array of indices into the
+ .dynsym section. Each element has the following type. */
+typedef unsigned long Elf32_Conflict;
+typedef unsigned char Elf32_External_Conflict[4];
+
+typedef unsigned long Elf64_Conflict;
+typedef unsigned char Elf64_External_Conflict[8];
+
+/* A section of type SHT_MIPS_GPTAB contains information about how
+ much GP space would be required for different -G arguments. This
+ information is only used so that the linker can provide informative
+ suggestions as to the best -G value to use. The sh_info field is
+ the index of the section for which this information applies. The
+ contents of the section are an array of the following union. The
+ first element uses the gt_header field. The remaining elements use
+ the gt_entry field. */
+typedef union
+{
+ struct
+ {
+ /* -G value actually used for this object file. */
+ unsigned long gt_current_g_value;
+ /* Unused. */
+ unsigned long gt_unused;
+ } gt_header;
+ struct
+ {
+ /* If this -G argument has been used... */
+ unsigned long gt_g_value;
+ /* ...this many GP section bytes would be required. */
+ unsigned long gt_bytes;
+ } gt_entry;
+} Elf32_gptab;
+
+/* The external version of Elf32_gptab. */
+
+typedef union
+{
+ struct
+ {
+ unsigned char gt_current_g_value[4];
+ unsigned char gt_unused[4];
+ } gt_header;
+ struct
+ {
+ unsigned char gt_g_value[4];
+ unsigned char gt_bytes[4];
+ } gt_entry;
+} Elf32_External_gptab;
+
+/* A section of type SHT_MIPS_REGINFO contains the following
+ structure. */
+typedef struct
+{
+ /* Mask of general purpose registers used. */
+ unsigned long ri_gprmask;
+ /* Mask of co-processor registers used. */
+ unsigned long ri_cprmask[4];
+ /* GP register value for this object file. */
+ long ri_gp_value;
+} Elf32_RegInfo;
+
+/* The external version of the Elf_RegInfo structure. */
+typedef struct
+{
+ unsigned char ri_gprmask[4];
+ unsigned char ri_cprmask[4][4];
+ unsigned char ri_gp_value[4];
+} Elf32_External_RegInfo;
+
+/* MIPS ELF .reginfo swapping routines. */
+extern void bfd_mips_elf32_swap_reginfo_in
+ PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *));
+extern void bfd_mips_elf32_swap_reginfo_out
+ PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *));
+
+/* Processor specific section flags. */
+
+/* This section must be in the global data area. */
+#define SHF_MIPS_GPREL 0x10000000
+
+/* This section should be merged. */
+#define SHF_MIPS_MERGE 0x20000000
+
+/* This section contains 32 bit addresses. */
+#define SHF_MIPS_ADDR32 0x40000000
+
+/* This section contains 64 bit addresses. */
+#define SHF_MIPS_ADDR64 0x80000000
+
+/* This section may not be stripped. */
+#define SHF_MIPS_NOSTRIP 0x08000000
+
+/* This section is local to threads. */
+#define SHF_MIPS_LOCAL 0x04000000
+
+/* Linker should generate implicit weak names for this section. */
+#define SHF_MIPS_NAMES 0x02000000
+
+/* Processor specific program header types. */
+
+/* Register usage information. Identifies one .reginfo section. */
+#define PT_MIPS_REGINFO 0x70000000
+
+/* Runtime procedure table. */
+#define PT_MIPS_RTPROC 0x70000001
+
+/* Options (for what ???). */
+#define PT_MIPS_OPTIONS 0x70000002
+
+/* Processor specific dynamic array tags. */
+
+/* 32 bit version number for runtime linker interface. */
+#define DT_MIPS_RLD_VERSION 0x70000001
+
+/* Time stamp. */
+#define DT_MIPS_TIME_STAMP 0x70000002
+
+/* Checksum of external strings and common sizes. */
+#define DT_MIPS_ICHECKSUM 0x70000003
+
+/* Index of version string in string table. */
+#define DT_MIPS_IVERSION 0x70000004
+
+/* 32 bits of flags. */
+#define DT_MIPS_FLAGS 0x70000005
+
+/* Base address of the segment. */
+#define DT_MIPS_BASE_ADDRESS 0x70000006
+
+/* ??? */
+#define DT_MIPS_MSYM 0x70000007
+
+/* Address of .conflict section. */
+#define DT_MIPS_CONFLICT 0x70000008
+
+/* Address of .liblist section. */
+#define DT_MIPS_LIBLIST 0x70000009
+
+/* Number of local global offset table entries. */
+#define DT_MIPS_LOCAL_GOTNO 0x7000000a
+
+/* Number of entries in the .conflict section. */
+#define DT_MIPS_CONFLICTNO 0x7000000b
+
+/* Number of entries in the .liblist section. */
+#define DT_MIPS_LIBLISTNO 0x70000010
+
+/* Number of entries in the .dynsym section. */
+#define DT_MIPS_SYMTABNO 0x70000011
+
+/* Index of first external dynamic symbol not referenced locally. */
+#define DT_MIPS_UNREFEXTNO 0x70000012
+
+/* Index of first dynamic symbol in global offset table. */
+#define DT_MIPS_GOTSYM 0x70000013
+
+/* Number of page table entries in global offset table. */
+#define DT_MIPS_HIPAGENO 0x70000014
+
+/* Address of run time loader map, used for debugging. */
+#define DT_MIPS_RLD_MAP 0x70000016
+
+/* Delta C++ class definition. */
+#define DT_MIPS_DELTA_CLASS 0x70000017
+
+/* Number of entries in DT_MIPS_DELTA_CLASS. */
+#define DT_MIPS_DELTA_CLASS_NO 0x70000018
+
+/* Delta C++ class instances. */
+#define DT_MIPS_DELTA_INSTANCE 0x70000019
+
+/* Number of entries in DT_MIPS_DELTA_INSTANCE. */
+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a
+
+/* Delta relocations. */
+#define DT_MIPS_DELTA_RELOC 0x7000001b
+
+/* Number of entries in DT_MIPS_DELTA_RELOC. */
+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c
+
+/* Delta symbols that Delta relocations refer to. */
+#define DT_MIPS_DELTA_SYM 0x7000001d
+
+/* Number of entries in DT_MIPS_DELTA_SYM. */
+#define DT_MIPS_DELTA_SYM_NO 0x7000001e
+
+/* Delta symbols that hold class declarations. */
+#define DT_MIPS_DELTA_CLASSSYM 0x70000020
+
+/* Number of entries in DT_MIPS_DELTA_CLASSSYM. */
+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021
+
+/* Flags indicating information about C++ flavor. */
+#define DT_MIPS_CXX_FLAGS 0x70000022
+
+/* Pixie information (???). */
+#define DT_MIPS_PIXIE_INIT 0x70000023
+
+/* ??? */
+#define DT_MIPS_SYMBOL_LIB 0x70000024
+
+/* ??? */
+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
+
+/* ??? */
+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
+
+/* ??? */
+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
+
+/* ??? */
+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
+
+/* Address of `.MIPS.options'. */
+#define DT_MIPS_OPTIONS 0x70000029
+
+/* Address of `.interface'. */
+#define DT_MIPS_INTERFACE 0x7000002a
+
+/* ??? */
+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
+
+/* Size of the .interface section. */
+#define DT_MIPS_INTERFACE_SIZE 0x7000002c
+
+/* Size of rld_text_resolve function stored in the GOT. */
+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d
+
+/* Default suffix of DSO to be added by rld on dlopen() calls. */
+#define DT_MIPS_PERF_SUFFIX 0x7000002e
+
+/* Size of compact relocation section (O32). */
+#define DT_MIPS_COMPACT_SIZE 0x7000002f
+
+/* GP value for auxiliary GOTs. */
+#define DT_MIPS_GP_VALUE 0x70000030
+
+/* Address of auxiliary .dynamic. */
+#define DT_MIPS_AUX_DYNAMIC 0x70000031
+
+/* Flags which may appear in a DT_MIPS_FLAGS entry. */
+
+/* No flags. */
+#define RHF_NONE 0x00000000
+
+/* Uses shortcut pointers. */
+#define RHF_QUICKSTART 0x00000001
+
+/* Hash size is not a power of two. */
+#define RHF_NOTPOT 0x00000002
+
+/* Ignore LD_LIBRARY_PATH. */
+#define RHS_NO_LIBRARY_REPLACEMENT \
+ 0x00000004
+
+#define RHF_NO_MOVE 0x00000008
+#define RHF_SGI_ONLY 0x00000010
+#define RHF_GUARANTEE_INIT 0x00000020
+#define RHF_DELTA_C_PLUS_PLUS 0x00000040
+#define RHF_GUARANTEE_START_INIT 0x00000080
+#define RHF_PIXIE 0x00000100
+#define RHF_DEFAULT_DELAY_LOAD 0x00000200
+#define RHF_REQUICKSTART 0x00000400
+#define RHF_REQUICKSTARTED 0x00000800
+#define RHF_CORD 0x00001000
+#define RHF_NO_UNRES_UNDEF 0x00002000
+#define RHF_RLD_ORDER_SAFE 0x00004000
+
+/* Special values for the st_other field in the symbol table. These
+ are used in an Irix 5 dynamic symbol table. */
+
+#define STO_DEFAULT 0x00
+#define STO_INTERNAL 0x01
+#define STO_HIDDEN 0x02
+#define STO_PROTECTED 0x03
+
+/* This value is used for a mips16 .text symbol. */
+#define STO_MIPS16 0xf0
+
+/* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each
+ relocation entry specifies up to three actual relocations, all at
+ the same address. The first relocation which required a symbol
+ uses the symbol in the r_sym field. The second relocation which
+ requires a symbol uses the symbol in the r_ssym field. If all
+ three relocations require a symbol, the third one uses a zero
+ value. */
+
+/* An entry in a 64 bit SHT_REL section. */
+
+typedef struct
+{
+ /* Address of relocation. */
+ unsigned char r_offset[8];
+ /* Symbol index. */
+ unsigned char r_sym[4];
+ /* Special symbol. */
+ unsigned char r_ssym[1];
+ /* Third relocation. */
+ unsigned char r_type3[1];
+ /* Second relocation. */
+ unsigned char r_type2[1];
+ /* First relocation. */
+ unsigned char r_type[1];
+} Elf64_Mips_External_Rel;
+
+typedef struct
+{
+ /* Address of relocation. */
+ bfd_vma r_offset;
+ /* Symbol index. */
+ unsigned long r_sym;
+ /* Special symbol. */
+ unsigned char r_ssym;
+ /* Third relocation. */
+ unsigned char r_type3;
+ /* Second relocation. */
+ unsigned char r_type2;
+ /* First relocation. */
+ unsigned char r_type;
+} Elf64_Mips_Internal_Rel;
+
+/* An entry in a 64 bit SHT_RELA section. */
+
+typedef struct
+{
+ /* Address of relocation. */
+ unsigned char r_offset[8];
+ /* Symbol index. */
+ unsigned char r_sym[4];
+ /* Special symbol. */
+ unsigned char r_ssym[1];
+ /* Third relocation. */
+ unsigned char r_type3[1];
+ /* Second relocation. */
+ unsigned char r_type2[1];
+ /* First relocation. */
+ unsigned char r_type[1];
+ /* Addend. */
+ unsigned char r_addend[8];
+} Elf64_Mips_External_Rela;
+
+typedef struct
+{
+ /* Address of relocation. */
+ bfd_vma r_offset;
+ /* Symbol index. */
+ unsigned long r_sym;
+ /* Special symbol. */
+ unsigned char r_ssym;
+ /* Third relocation. */
+ unsigned char r_type3;
+ /* Second relocation. */
+ unsigned char r_type2;
+ /* First relocation. */
+ unsigned char r_type;
+ /* Addend. */
+ bfd_signed_vma r_addend;
+} Elf64_Mips_Internal_Rela;
+
+/* Values found in the r_ssym field of a relocation entry. */
+
+/* No relocation. */
+#define RSS_UNDEF 0
+
+/* Value of GP. */
+#define RSS_GP 1
+
+/* Value of GP in object being relocated. */
+#define RSS_GP0 2
+
+/* Address of location being relocated. */
+#define RSS_LOC 3
+
+/* A SHT_MIPS_OPTIONS section contains a series of options, each of
+ which starts with this header. */
+
+typedef struct
+{
+ /* Type of option. */
+ unsigned char kind[1];
+ /* Size of option descriptor, including header. */
+ unsigned char size[1];
+ /* Section index of affected section, or 0 for global option. */
+ unsigned char section[2];
+ /* Information specific to this kind of option. */
+ unsigned char info[4];
+} Elf_External_Options;
+
+typedef struct
+{
+ /* Type of option. */
+ unsigned char kind;
+ /* Size of option descriptor, including header. */
+ unsigned char size;
+ /* Section index of affected section, or 0 for global option. */
+ unsigned short section;
+ /* Information specific to this kind of option. */
+ unsigned long info;
+} Elf_Internal_Options;
+
+/* MIPS ELF option header swapping routines. */
+extern void bfd_mips_elf_swap_options_in
+ PARAMS ((bfd *, const Elf_External_Options *, Elf_Internal_Options *));
+extern void bfd_mips_elf_swap_options_out
+ PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *));
+
+/* Values which may appear in the kind field of an Elf_Options
+ structure. */
+
+/* Undefined. */
+#define ODK_NULL 0
+
+/* Register usage and GP value. */
+#define ODK_REGINFO 1
+
+/* Exception processing information. */
+#define ODK_EXCEPTIONS 2
+
+/* Section padding information. */
+#define ODK_PAD 3
+
+/* Hardware workarounds performed. */
+#define ODK_HWPATCH 4
+
+/* Fill value used by the linker. */
+#define ODK_FILL 5
+
+/* Reserved space for desktop tools. */
+#define ODK_TAGS 6
+
+/* Hardware workarounds, AND bits when merging. */
+#define ODK_HWAND 7
+
+/* Hardware workarounds, OR bits when merging. */
+#define ODK_HWOR 8
+
+/* GP group to use for text/data sections. */
+#define ODK_GP_GROUP 9
+
+/* ID information. */
+#define ODK_IDENT 10
+
+/* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_RegInfo
+ structure. In the 64 bit ABI, it is the following structure. The
+ info field of the options header is not used. */
+
+typedef struct
+{
+ /* Mask of general purpose registers used. */
+ unsigned char ri_gprmask[4];
+ /* Padding. */
+ unsigned char ri_pad[4];
+ /* Mask of co-processor registers used. */
+ unsigned char ri_cprmask[4][4];
+ /* GP register value for this object file. */
+ unsigned char ri_gp_value[8];
+} Elf64_External_RegInfo;
+
+typedef struct
+{
+ /* Mask of general purpose registers used. */
+ unsigned long ri_gprmask;
+ /* Padding. */
+ unsigned long ri_pad;
+ /* Mask of co-processor registers used. */
+ unsigned long ri_cprmask[4];
+ /* GP register value for this object file. */
+ bfd_vma ri_gp_value;
+} Elf64_Internal_RegInfo;
+
+/* MIPS ELF reginfo swapping routines. */
+extern void bfd_mips_elf64_swap_reginfo_in
+ PARAMS ((bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *));
+extern void bfd_mips_elf64_swap_reginfo_out
+ PARAMS ((bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *));
+
+/* Masks for the info work of an ODK_EXCEPTIONS descriptor. */
+#define OEX_FPU_MIN 0x1f /* FPEs which must be enabled. */
+#define OEX_FPU_MAX 0x1f00 /* FPEs which may be enabled. */
+#define OEX_PAGE0 0x10000 /* Page zero must be mapped. */
+#define OEX_SMM 0x20000 /* Force sequential memory mode. */
+#define OEX_FPDBUG 0x40000 /* Force floating-point debug mode. */
+#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults. */
+
+/* Masks of the FP exceptions for OEX_FPU_MIN and OEX_FPU_MAX. */
+#define OEX_FPU_INVAL 0x10 /* Invalid operation exception. */
+#define OEX_FPU_DIV0 0x08 /* Division by zero exception. */
+#define OEX_FPU_OFLO 0x04 /* Overflow exception. */
+#define OEX_FPU_UFLO 0x02 /* Underflow exception. */
+#define OEX_FPU_INEX 0x01 /* Inexact exception. */
+
+/* Masks for the info word of an ODK_PAD descriptor. */
+#define OPAD_PREFIX 0x01
+#define OPAD_POSTFIX 0x02
+#define OPAD_SYMBOL 0x04
+
+/* Masks for the info word of an ODK_HWPATCH descriptor. */
+#define OHW_R4KEOP 0x01 /* R4000 end-of-page patch. */
+#define OHW_R8KPFETCH 0x02 /* May need R8000 prefetch patch. */
+#define OHW_R5KEOP 0x04 /* R5000 end-of-page patch. */
+#define OHW_R5KCVTL 0x08 /* R5000 cvt.[ds].l bug (clean == 1). */
+
+/* Masks for the info word of an ODK_IDENT/ODK_GP_GROUP descriptor. */
+#define OGP_GROUP 0x0000ffff /* GP group number. */
+#define OGP_SELF 0xffff0000 /* Self-contained GP groups. */
+
+/* Masks for the info word of an ODK_HWAND/ODK_HWOR descriptor. */
+#define OHWA0_R4KEOP_CHECKED 0x00000001
+#define OHWA0_R4KEOP_CLEAN 0x00000002
+
+
+#endif /* _ELF_MIPS_H */
diff --git a/include/elf/mn10200.h b/include/elf/mn10200.h
new file mode 100644
index 00000000000..5e29e0ad211
--- /dev/null
+++ b/include/elf/mn10200.h
@@ -0,0 +1,39 @@
+/* MN10200 ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the MN10200 ELF ABI. */
+
+#ifndef _ELF_MN10200_H
+#define _ELF_MN10200_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_mn10200_reloc_type)
+ RELOC_NUMBER (R_MN10200_NONE, 0)
+ RELOC_NUMBER (R_MN10200_32, 1)
+ RELOC_NUMBER (R_MN10200_16, 2)
+ RELOC_NUMBER (R_MN10200_8, 3)
+ RELOC_NUMBER (R_MN10200_24, 4)
+ RELOC_NUMBER (R_MN10200_PCREL8, 5)
+ RELOC_NUMBER (R_MN10200_PCREL16, 6)
+ RELOC_NUMBER (R_MN10200_PCREL24, 7)
+END_RELOC_NUMBERS
+
+#endif /* _ELF_MN10200_H */
diff --git a/include/elf/mn10300.h b/include/elf/mn10300.h
new file mode 100644
index 00000000000..64a0750451f
--- /dev/null
+++ b/include/elf/mn10300.h
@@ -0,0 +1,53 @@
+/* MN10300 ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the MN10300 ELF ABI. */
+
+#ifndef _ELF_MN10300_H
+#define _ELF_MN10300_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_mn10300_reloc_type)
+ RELOC_NUMBER (R_MN10300_NONE, 0)
+ RELOC_NUMBER (R_MN10300_32, 1)
+ RELOC_NUMBER (R_MN10300_16, 2)
+ RELOC_NUMBER (R_MN10300_8, 3)
+ RELOC_NUMBER (R_MN10300_PCREL32, 4)
+ RELOC_NUMBER (R_MN10300_PCREL16, 5)
+ RELOC_NUMBER (R_MN10300_PCREL8, 6)
+ RELOC_NUMBER (R_MN10300_GNU_VTINHERIT, 7)
+ RELOC_NUMBER (R_MN10300_GNU_VTENTRY, 8)
+ RELOC_NUMBER (R_MN10300_24, 9)
+ EMPTY_RELOC (R_MN10300_MAX)
+END_RELOC_NUMBERS
+
+/* Machine variant if we know it. This field was invented at Cygnus,
+ but it is hoped that other vendors will adopt it. If some standard
+ is developed, this code should be changed to follow it. */
+
+#define EF_MN10300_MACH 0x00FF0000
+
+/* Cygnus is choosing values between 80 and 9F;
+ 00 - 7F should be left for a future standard;
+ the rest are open. */
+
+#define E_MN10300_MACH_MN10300 0x00810000
+#endif /* _ELF_MN10300_H */
diff --git a/include/elf/ppc.h b/include/elf/ppc.h
new file mode 100644
index 00000000000..b3116d8ad01
--- /dev/null
+++ b/include/elf/ppc.h
@@ -0,0 +1,127 @@
+/* PPC ELF support for BFD.
+ Copyright (C) 1995, 1998 Free Software Foundation, Inc.
+
+ By Michael Meissner, Cygnus Support, <meissner@cygnus.com>, from information
+ in the System V Application Binary Interface, PowerPC Processor Supplement
+ and the PowerPC Embedded Application Binary Interface (eabi).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the PPC ELF ABI. Note
+ that most of this is not actually implemented by BFD. */
+
+#ifndef _ELF_PPC_H
+#define _ELF_PPC_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+START_RELOC_NUMBERS (elf_ppc_reloc_type)
+ RELOC_NUMBER (R_PPC_NONE, 0)
+ RELOC_NUMBER (R_PPC_ADDR32, 1)
+ RELOC_NUMBER (R_PPC_ADDR24, 2)
+ RELOC_NUMBER (R_PPC_ADDR16, 3)
+ RELOC_NUMBER (R_PPC_ADDR16_LO, 4)
+ RELOC_NUMBER (R_PPC_ADDR16_HI, 5)
+ RELOC_NUMBER (R_PPC_ADDR16_HA, 6)
+ RELOC_NUMBER (R_PPC_ADDR14, 7)
+ RELOC_NUMBER (R_PPC_ADDR14_BRTAKEN, 8)
+ RELOC_NUMBER (R_PPC_ADDR14_BRNTAKEN, 9)
+ RELOC_NUMBER (R_PPC_REL24, 10)
+ RELOC_NUMBER (R_PPC_REL14, 11)
+ RELOC_NUMBER (R_PPC_REL14_BRTAKEN, 12)
+ RELOC_NUMBER (R_PPC_REL14_BRNTAKEN, 13)
+ RELOC_NUMBER (R_PPC_GOT16, 14)
+ RELOC_NUMBER (R_PPC_GOT16_LO, 15)
+ RELOC_NUMBER (R_PPC_GOT16_HI, 16)
+ RELOC_NUMBER (R_PPC_GOT16_HA, 17)
+ RELOC_NUMBER (R_PPC_PLTREL24, 18)
+ RELOC_NUMBER (R_PPC_COPY, 19)
+ RELOC_NUMBER (R_PPC_GLOB_DAT, 20)
+ RELOC_NUMBER (R_PPC_JMP_SLOT, 21)
+ RELOC_NUMBER (R_PPC_RELATIVE, 22)
+ RELOC_NUMBER (R_PPC_LOCAL24PC, 23)
+ RELOC_NUMBER (R_PPC_UADDR32, 24)
+ RELOC_NUMBER (R_PPC_UADDR16, 25)
+ RELOC_NUMBER (R_PPC_REL32, 26)
+ RELOC_NUMBER (R_PPC_PLT32, 27)
+ RELOC_NUMBER (R_PPC_PLTREL32, 28)
+ RELOC_NUMBER (R_PPC_PLT16_LO, 29)
+ RELOC_NUMBER (R_PPC_PLT16_HI, 30)
+ RELOC_NUMBER (R_PPC_PLT16_HA, 31)
+ RELOC_NUMBER (R_PPC_SDAREL16, 32)
+ RELOC_NUMBER (R_PPC_SECTOFF, 33)
+ RELOC_NUMBER (R_PPC_SECTOFF_LO, 34)
+ RELOC_NUMBER (R_PPC_SECTOFF_HI, 35)
+ RELOC_NUMBER (R_PPC_SECTOFF_HA, 36)
+
+/* The remaining relocs are from the Embedded ELF ABI, and are not
+ in the SVR4 ELF ABI. */
+ RELOC_NUMBER (R_PPC_EMB_NADDR32, 101)
+ RELOC_NUMBER (R_PPC_EMB_NADDR16, 102)
+ RELOC_NUMBER (R_PPC_EMB_NADDR16_LO, 103)
+ RELOC_NUMBER (R_PPC_EMB_NADDR16_HI, 104)
+ RELOC_NUMBER (R_PPC_EMB_NADDR16_HA, 105)
+ RELOC_NUMBER (R_PPC_EMB_SDAI16, 106)
+ RELOC_NUMBER (R_PPC_EMB_SDA2I16, 107)
+ RELOC_NUMBER (R_PPC_EMB_SDA2REL, 108)
+ RELOC_NUMBER (R_PPC_EMB_SDA21, 109)
+ RELOC_NUMBER (R_PPC_EMB_MRKREF, 110)
+ RELOC_NUMBER (R_PPC_EMB_RELSEC16, 111)
+ RELOC_NUMBER (R_PPC_EMB_RELST_LO, 112)
+ RELOC_NUMBER (R_PPC_EMB_RELST_HI, 113)
+ RELOC_NUMBER (R_PPC_EMB_RELST_HA, 114)
+ RELOC_NUMBER (R_PPC_EMB_BIT_FLD, 115)
+ RELOC_NUMBER (R_PPC_EMB_RELSDA, 116)
+
+ /* These are GNU extensions to enable C++ vtable garbage collection. */
+ RELOC_NUMBER (R_PPC_GNU_VTINHERIT, 253)
+ RELOC_NUMBER (R_PPC_GNU_VTENTRY, 254)
+
+/* This is a phony reloc to handle any old fashioned TOC16 references
+ that may still be in object files. */
+ RELOC_NUMBER (R_PPC_TOC16, 255)
+
+ EMPTY_RELOC (R_PPC_max)
+END_RELOC_NUMBERS
+
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
+
+ /* CYGNUS local bits below */
+#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag */
+#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag */
+
+/* Processor specific section headers, sh_type field */
+
+#define SHT_ORDERED SHT_HIPROC /* Link editor is to sort the \
+ entries in this section \
+ based on the address \
+ specified in the associated \
+ symbol table entry. */
+
+/* Processor specific section flags, sh_flags field */
+
+#define SHF_EXCLUDE 0x80000000 /* Link editor is to exclude \
+ this section from executable \
+ and shared objects that it \
+ builds when those objects \
+ are not to be furhter \
+ relocated. */
+#endif /* _ELF_PPC_H */
diff --git a/include/elf/reloc-macros.h b/include/elf/reloc-macros.h
new file mode 100644
index 00000000000..976229129c0
--- /dev/null
+++ b/include/elf/reloc-macros.h
@@ -0,0 +1,116 @@
+/* Generic relocation support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* These macros are used by the various *.h target specific header
+ files to either generate an enum containing all the known relocations
+ for that target, or if RELOC_MACROS_GEN_FUNC is defined, a recognition
+ function is generated instead. (This is used by binutils/readelf.c)
+
+ Given a header file like this:
+
+ START_RELOC_NUMBERS (foo)
+ RELOC_NUMBER (R_foo_NONE, 0)
+ RELOC_NUMBER (R_foo_32, 1)
+ FAKE_RELOC (R_foo_illegal, 2)
+ EMPTY_RELOC (R_foo_max)
+ END_RELOC_NUMBERS
+
+ Then the following will be produced by default (ie if
+ RELOC_MACROS_GEN_FUNC is *not* defined).
+
+ enum foo
+ {
+ foo = -1,
+ R_foo_NONE = 0,
+ R_foo_32 = 1,
+ R_foo_illegal = 2,
+ R_foo_max
+ };
+
+ If RELOC_MACROS_GEN_FUNC *is* defined, then instead the
+ following function will be generated:
+
+ static char * foo PARAMS ((unsigned long rtype));
+ static char *
+ foo (rtype)
+ unsigned long rtype;
+ {
+ switch (rtype)
+ {
+ case 0: return "R_foo_NONE";
+ case 1: return "R_foo_32";
+ default: return NULL;
+ }
+ }
+ */
+
+#ifndef _RELOC_MACROS_H
+#define _RELOC_MACROS_H
+
+#ifdef RELOC_MACROS_GEN_FUNC
+
+/* This function takes the relocation number and returns the
+ string version name of the name of that relocation. If
+ the relocation is not recognised, NULL is returned. */
+
+#define START_RELOC_NUMBERS(name) \
+static const char * name PARAMS ((unsigned long rtype)); \
+static const char * \
+name (rtype) \
+ unsigned long rtype; \
+{ \
+ switch (rtype) \
+ {
+
+#ifdef __STDC__
+#define RELOC_NUMBER(name, number) case number : return #name ;
+#else
+#define RELOC_NUMBER(name, number) case number : return "name" ;
+#endif
+
+#define FAKE_RELOC(name, number)
+#define EMPTY_RELOC(name)
+
+#define END_RELOC_NUMBERS \
+ default: return NULL; \
+ } \
+}
+
+
+#else /* Default to generating enum. */
+
+/* Some compilers cannot cope with an enum that ends with a trailing
+ comma, so START_RELOC_NUMBERS creates a fake reloc entry, (initialised
+ to -1 so that the first real entry will still default to 0). Further
+ entries then prepend a comma to their definitions, creating a list
+ of enumerator entries that will satisfy these compilers. */
+#ifdef __STDC__
+#define START_RELOC_NUMBERS(name) enum name { _##name = -1
+#else
+#define START_RELOC_NUMBERS(name) enum name { name = -1
+#endif
+
+#define RELOC_NUMBER(name, number) , name = number
+#define FAKE_RELOC(name, number) , name = number
+#define EMPTY_RELOC(name) , name
+#define END_RELOC_NUMBERS };
+
+#endif
+
+#endif /* RELOC_MACROS_H */
diff --git a/include/elf/sh.h b/include/elf/sh.h
new file mode 100644
index 00000000000..4a476679ab6
--- /dev/null
+++ b/include/elf/sh.h
@@ -0,0 +1,55 @@
+/* SH ELF support for BFD.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_SH_H
+#define _ELF_SH_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations. */
+/* Relocations 25ff are GNU extensions.
+ 25..33 are used for relaxation and use the same constants as COFF uses. */
+START_RELOC_NUMBERS (elf_sh_reloc_type)
+ RELOC_NUMBER (R_SH_NONE, 0)
+ RELOC_NUMBER (R_SH_DIR32, 1)
+ RELOC_NUMBER (R_SH_REL32, 2)
+ RELOC_NUMBER (R_SH_DIR8WPN, 3)
+ RELOC_NUMBER (R_SH_IND12W, 4)
+ RELOC_NUMBER (R_SH_DIR8WPL, 5)
+ RELOC_NUMBER (R_SH_DIR8WPZ, 6)
+ RELOC_NUMBER (R_SH_DIR8BP, 7)
+ RELOC_NUMBER (R_SH_DIR8W, 8)
+ RELOC_NUMBER (R_SH_DIR8L, 9)
+ FAKE_RELOC (R_SH_FIRST_INVALID_RELOC, 10)
+ FAKE_RELOC (R_SH_LAST_INVALID_RELOC, 24)
+ RELOC_NUMBER (R_SH_SWITCH16, 25)
+ RELOC_NUMBER (R_SH_SWITCH32, 26)
+ RELOC_NUMBER (R_SH_USES, 27)
+ RELOC_NUMBER (R_SH_COUNT, 28)
+ RELOC_NUMBER (R_SH_ALIGN, 29)
+ RELOC_NUMBER (R_SH_CODE, 30)
+ RELOC_NUMBER (R_SH_DATA, 31)
+ RELOC_NUMBER (R_SH_LABEL, 32)
+ RELOC_NUMBER (R_SH_SWITCH8, 33)
+ RELOC_NUMBER (R_SH_GNU_VTINHERIT, 34)
+ RELOC_NUMBER (R_SH_GNU_VTENTRY, 35)
+ EMPTY_RELOC (R_SH_max)
+END_RELOC_NUMBERS
+
+#endif
diff --git a/include/elf/sparc.h b/include/elf/sparc.h
new file mode 100644
index 00000000000..c9e4cdd4040
--- /dev/null
+++ b/include/elf/sparc.h
@@ -0,0 +1,156 @@
+/* SPARC ELF support for BFD.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ By Doug Evans, Cygnus Support, <dje@cygnus.com>.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _ELF_SPARC_H
+#define _ELF_SPARC_H
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* These are defined by Sun. */
+
+#define EF_SPARC_32PLUS_MASK 0xffff00 /* bits indicating V8+ type */
+#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
+#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
+#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
+
+#define EF_SPARC_LEDATA 0x800000 /* little endian data */
+
+/* This name is used in the V9 ABI. */
+#define EF_SPARC_EXT_MASK 0xffff00 /* reserved for vendor extensions */
+
+/* V9 memory models */
+#define EF_SPARCV9_MM 0x3 /* memory model mask */
+#define EF_SPARCV9_TSO 0x0 /* total store ordering */
+#define EF_SPARCV9_PSO 0x1 /* partial store ordering */
+#define EF_SPARCV9_RMO 0x2 /* relaxed store ordering */
+
+/* Section indices. */
+
+#define SHN_BEFORE 0xff00 /* used with SHF_ORDERED */
+#define SHN_AFTER 0xff01 /* used with SHF_ORDERED */
+
+/* Section flags. */
+
+#define SHF_EXCLUDE 0x80000000 /* exclude from linking */
+#define SHF_ORDERED 0x40000000 /* treat sh_link,sh_info specially */
+
+/* Symbol types. */
+
+#define STT_REGISTER 13 /* global reg reserved to app. */
+
+#include "elf/reloc-macros.h"
+
+/* Relocation types. */
+START_RELOC_NUMBERS (elf_sparc_reloc_type)
+ RELOC_NUMBER (R_SPARC_NONE, 0)
+ RELOC_NUMBER (R_SPARC_8, 1)
+ RELOC_NUMBER (R_SPARC_16, 2)
+ RELOC_NUMBER (R_SPARC_32, 3)
+ RELOC_NUMBER (R_SPARC_DISP8, 4)
+ RELOC_NUMBER (R_SPARC_DISP16, 5)
+ RELOC_NUMBER (R_SPARC_DISP32, 6)
+ RELOC_NUMBER (R_SPARC_WDISP30, 7)
+ RELOC_NUMBER (R_SPARC_WDISP22, 8)
+ RELOC_NUMBER (R_SPARC_HI22, 9)
+ RELOC_NUMBER (R_SPARC_22, 10)
+ RELOC_NUMBER (R_SPARC_13, 11)
+ RELOC_NUMBER (R_SPARC_LO10, 12)
+ RELOC_NUMBER (R_SPARC_GOT10, 13)
+ RELOC_NUMBER (R_SPARC_GOT13, 14)
+ RELOC_NUMBER (R_SPARC_GOT22, 15)
+ RELOC_NUMBER (R_SPARC_PC10, 16)
+ RELOC_NUMBER (R_SPARC_PC22, 17)
+ RELOC_NUMBER (R_SPARC_WPLT30, 18)
+ RELOC_NUMBER (R_SPARC_COPY, 19)
+ RELOC_NUMBER (R_SPARC_GLOB_DAT, 20)
+ RELOC_NUMBER (R_SPARC_JMP_SLOT, 21)
+ RELOC_NUMBER (R_SPARC_RELATIVE, 22)
+ RELOC_NUMBER (R_SPARC_UA32, 23)
+
+ /* ??? These 6 relocs are new but not currently used. For binary
+ compatility in the sparc64-elf toolchain, we leave them out.
+ A non-binary upward compatible change is expected for sparc64-elf. */
+#ifndef SPARC64_OLD_RELOCS
+ /* ??? New relocs on the UltraSPARC. Not sure what they're for yet. */
+ RELOC_NUMBER (R_SPARC_PLT32, 24)
+ RELOC_NUMBER (R_SPARC_HIPLT22, 25)
+ RELOC_NUMBER (R_SPARC_LOPLT10, 26)
+ RELOC_NUMBER (R_SPARC_PCPLT32, 27)
+ RELOC_NUMBER (R_SPARC_PCPLT22, 28)
+ RELOC_NUMBER (R_SPARC_PCPLT10, 29)
+#endif
+
+ /* v9 relocs */
+ RELOC_NUMBER (R_SPARC_10, 30)
+ RELOC_NUMBER (R_SPARC_11, 31)
+ RELOC_NUMBER (R_SPARC_64, 32)
+ RELOC_NUMBER (R_SPARC_OLO10, 33)
+ RELOC_NUMBER (R_SPARC_HH22, 34)
+ RELOC_NUMBER (R_SPARC_HM10, 35)
+ RELOC_NUMBER (R_SPARC_LM22, 36)
+ RELOC_NUMBER (R_SPARC_PC_HH22, 37)
+ RELOC_NUMBER (R_SPARC_PC_HM10, 38)
+ RELOC_NUMBER (R_SPARC_PC_LM22, 39)
+ RELOC_NUMBER (R_SPARC_WDISP16, 40)
+ RELOC_NUMBER (R_SPARC_WDISP19, 41)
+ RELOC_NUMBER (R_SPARC_UNUSED_42, 42)
+ RELOC_NUMBER (R_SPARC_7, 43)
+ RELOC_NUMBER (R_SPARC_5, 44)
+ RELOC_NUMBER (R_SPARC_6, 45)
+ RELOC_NUMBER (R_SPARC_DISP64, 46)
+ RELOC_NUMBER (R_SPARC_PLT64, 47)
+ RELOC_NUMBER (R_SPARC_HIX22, 48)
+ RELOC_NUMBER (R_SPARC_LOX10, 49)
+ RELOC_NUMBER (R_SPARC_H44, 50)
+ RELOC_NUMBER (R_SPARC_M44, 51)
+ RELOC_NUMBER (R_SPARC_L44, 52)
+ RELOC_NUMBER (R_SPARC_REGISTER, 53)
+ RELOC_NUMBER (R_SPARC_UA64, 54)
+ RELOC_NUMBER (R_SPARC_UA16, 55)
+
+ /* little endian data relocs */
+ RELOC_NUMBER (R_SPARC_REV32, 56)
+
+ RELOC_NUMBER (R_SPARC_GNU_VTINHERIT, 250)
+ RELOC_NUMBER (R_SPARC_GNU_VTENTRY, 251)
+
+ EMPTY_RELOC (R_SPARC_max)
+END_RELOC_NUMBERS
+
+/* Relocation macros. */
+
+#define ELF64_R_TYPE_DATA(info) (((bfd_vma) (info) << 32) >> 40)
+#define ELF64_R_TYPE_ID(info) (((bfd_vma) (info) << 56) >> 56)
+#define ELF64_R_TYPE_INFO(data, type) (((bfd_vma) (data) << 8) \
+ + (bfd_vma) (type))
+
+#define DT_SPARC_REGISTER 0x70000001
+
+/*
+ * FIXME: NOT ABI -- GET RID OF THIS
+ * Defines the format used by the .plt. Currently defined values are
+ * 0 -- reserved to SI
+ * 1 -- absolute address in .got.plt
+ * 2 -- got-relative address in .got.plt
+ */
+
+#define DT_SPARC_PLTFMT 0x70000001
+
+#endif /* _ELF_SPARC_H */
diff --git a/include/elf/v850.h b/include/elf/v850.h
new file mode 100644
index 00000000000..d443b7fdc0d
--- /dev/null
+++ b/include/elf/v850.h
@@ -0,0 +1,111 @@
+/* V850 ELF support for BFD.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ Created by Michael Meissner, Cygnus Support <meissner@cygnus.com>
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file holds definitions specific to the MIPS ELF ABI. Note
+ that most of this is not actually implemented by BFD. */
+
+#ifndef _ELF_V850_H
+#define _ELF_V850_H
+
+/* Processor specific flags for the ELF header e_flags field. */
+
+/* Four bit V850 architecture field. */
+#define EF_V850_ARCH 0xf0000000
+
+/* v850 code. */
+#define E_V850_ARCH 0x00000000
+
+/* v850e code. */
+#define E_V850E_ARCH 0x10000000
+
+/* v850ea code. */
+#define E_V850EA_ARCH 0x20000000
+
+
+/* Flags for the st_other field */
+#define V850_OTHER_SDA 0x01 /* symbol had SDA relocations */
+#define V850_OTHER_ZDA 0x02 /* symbol had ZDA relocations */
+#define V850_OTHER_TDA 0x04 /* symbol had TDA relocations */
+#define V850_OTHER_TDA_BYTE 0x08 /* symbol had TDA byte relocations */
+#define V850_OTHER_ERROR 0x80 /* symbol had an error reported */
+
+/* V850 relocations */
+#include "elf/reloc-macros.h"
+
+START_RELOC_NUMBERS (v850_reloc_type)
+ RELOC_NUMBER (R_V850_NONE, 0)
+ RELOC_NUMBER (R_V850_9_PCREL, 1)
+ RELOC_NUMBER (R_V850_22_PCREL, 2)
+ RELOC_NUMBER (R_V850_HI16_S, 3)
+ RELOC_NUMBER (R_V850_HI16, 4)
+ RELOC_NUMBER (R_V850_LO16, 5)
+ RELOC_NUMBER (R_V850_32, 6)
+ RELOC_NUMBER (R_V850_16, 7)
+ RELOC_NUMBER (R_V850_8, 8)
+ RELOC_NUMBER( R_V850_SDA_16_16_OFFSET, 9) /* For ld.b, st.b, set1, clr1, not1, tst1, movea, movhi */
+ RELOC_NUMBER( R_V850_SDA_15_16_OFFSET, 10) /* For ld.w, ld.h, ld.hu, st.w, st.h */
+ RELOC_NUMBER( R_V850_ZDA_16_16_OFFSET, 11) /* For ld.b, st.b, set1, clr1, not1, tst1, movea, movhi */
+ RELOC_NUMBER( R_V850_ZDA_15_16_OFFSET, 12) /* For ld.w, ld.h, ld.hu, st.w, st.h */
+ RELOC_NUMBER( R_V850_TDA_6_8_OFFSET, 13) /* For sst.w, sld.w */
+ RELOC_NUMBER( R_V850_TDA_7_8_OFFSET, 14) /* For sst.h, sld.h */
+ RELOC_NUMBER( R_V850_TDA_7_7_OFFSET, 15) /* For sst.b, sld.b */
+ RELOC_NUMBER( R_V850_TDA_16_16_OFFSET, 16) /* For set1, clr1, not1, tst1, movea, movhi */
+/* CYGNUS LOCAL v850e */
+ RELOC_NUMBER( R_V850_TDA_4_5_OFFSET, 17) /* For sld.hu */
+ RELOC_NUMBER( R_V850_TDA_4_4_OFFSET, 18) /* For sld.bu */
+ RELOC_NUMBER( R_V850_SDA_16_16_SPLIT_OFFSET, 19) /* For ld.bu */
+ RELOC_NUMBER( R_V850_ZDA_16_16_SPLIT_OFFSET, 20) /* For ld.bu */
+ RELOC_NUMBER( R_V850_CALLT_6_7_OFFSET, 21) /* For callt */
+ RELOC_NUMBER( R_V850_CALLT_16_16_OFFSET, 22) /* For callt */
+/* END CYGNUS LOCAL */
+ RELOC_NUMBER (R_V850_GNU_VTINHERIT, 23)
+ RELOC_NUMBER (R_V850_GNU_VTENTRY, 24)
+
+ EMPTY_RELOC (R_V850_max)
+END_RELOC_NUMBERS
+
+
+/* Processor specific section indices. These sections do not actually
+ exist. Symbols with a st_shndx field corresponding to one of these
+ values have a special meaning. */
+
+/* Small data area common symbol. */
+#define SHN_V850_SCOMMON 0xff00
+
+/* Tiny data area common symbol. */
+#define SHN_V850_TCOMMON 0xff01
+
+/* Zero data area common symbol. */
+#define SHN_V850_ZCOMMON 0xff02
+
+
+/* Processor specific section types. */
+
+/* Section contains the .scommon data. */
+#define SHT_V850_SCOMMON 0x70000000
+
+/* Section contains the .scommon data. */
+#define SHT_V850_TCOMMON 0x70000001
+
+/* Section contains the .scommon data. */
+#define SHT_V850_ZCOMMON 0x70000002
+
+
+#endif /* _ELF_V850_H */
diff --git a/include/floatformat.h b/include/floatformat.h
new file mode 100644
index 00000000000..90daca21bcb
--- /dev/null
+++ b/include/floatformat.h
@@ -0,0 +1,111 @@
+/* IEEE floating point support declarations, for GDB, the GNU Debugger.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if !defined (FLOATFORMAT_H)
+#define FLOATFORMAT_H 1
+
+#include "ansidecl.h"
+
+/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
+ bytes are concatenated according to the byteorder flag, then each of those
+ fields is contiguous. We number the bits with 0 being the most significant
+ (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
+ contains with the *_start and *_len fields. */
+
+/* What is the order of the bytes. */
+
+enum floatformat_byteorders {
+
+ /* Standard little endian byte order.
+ EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
+
+ floatformat_little,
+
+ /* Standard big endian byte order.
+ EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
+
+ floatformat_big,
+
+ /* Little endian byte order but big endian word order.
+ EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
+
+ floatformat_littlebyte_bigword
+
+};
+
+enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
+
+struct floatformat
+{
+ enum floatformat_byteorders byteorder;
+ unsigned int totalsize; /* Total size of number in bits */
+
+ /* Sign bit is always one bit long. 1 means negative, 0 means positive. */
+ unsigned int sign_start;
+
+ unsigned int exp_start;
+ unsigned int exp_len;
+ /* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */
+ unsigned int exp_bias;
+ /* Exponent value which indicates NaN. This is the actual value stored in
+ the float, not adjusted by the exp_bias. This usually consists of all
+ one bits. */
+ unsigned int exp_nan;
+
+ unsigned int man_start;
+ unsigned int man_len;
+
+ /* Is the integer bit explicit or implicit? */
+ enum floatformat_intbit intbit;
+};
+
+/* floatformats for IEEE single and double, big and little endian. */
+
+extern const struct floatformat floatformat_ieee_single_big;
+extern const struct floatformat floatformat_ieee_single_little;
+extern const struct floatformat floatformat_ieee_double_big;
+extern const struct floatformat floatformat_ieee_double_little;
+
+/* floatformat for ARM IEEE double, little endian bytes and big endian words */
+
+extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
+
+/* floatformats for various extendeds. */
+
+extern const struct floatformat floatformat_i387_ext;
+extern const struct floatformat floatformat_m68881_ext;
+extern const struct floatformat floatformat_i960_ext;
+extern const struct floatformat floatformat_m88110_ext;
+extern const struct floatformat floatformat_arm_ext;
+
+/* Convert from FMT to a double.
+ FROM is the address of the extended float.
+ Store the double in *TO. */
+
+extern void
+floatformat_to_double PARAMS ((const struct floatformat *, char *, double *));
+
+/* The converse: convert the double *FROM to FMT
+ and store where TO points. */
+
+extern void
+floatformat_from_double PARAMS ((const struct floatformat *,
+ double *, char *));
+
+#endif /* defined (FLOATFORMAT_H) */
diff --git a/include/fnmatch.h b/include/fnmatch.h
new file mode 100644
index 00000000000..d5eb7000977
--- /dev/null
+++ b/include/fnmatch.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, 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, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef _FNMATCH_H
+
+#define _FNMATCH_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
+#undef __P
+#define __P(args) args
+#else /* Not C++ or ANSI C. */
+#undef __P
+#define __P(args) ()
+/* We can get away without defining `const' here only because in this file
+ it is used only inside the prototype for `fnmatch', which is elided in
+ non-ANSI C where `const' is problematical. */
+#endif /* C++ or ANSI C. */
+
+
+/* We #undef these before defining them because some losing systems
+ (HP-UX A.08.07 for example) define these in <unistd.h>. */
+#undef FNM_PATHNAME
+#undef FNM_NOESCAPE
+#undef FNM_PERIOD
+
+/* Bits set in the FLAGS argument to `fnmatch'. */
+#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
+#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
+#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
+
+#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
+#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
+#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
+#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
+#endif
+
+/* Value returned by `fnmatch' if STRING does not match PATTERN. */
+#define FNM_NOMATCH 1
+
+/* Match STRING against the filename pattern PATTERN,
+ returning zero if it matches, FNM_NOMATCH if not. */
+extern int fnmatch __P ((const char *__pattern, const char *__string,
+ int __flags));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* fnmatch.h */
diff --git a/include/fopen-bin.h b/include/fopen-bin.h
new file mode 100644
index 00000000000..b868f63d46d
--- /dev/null
+++ b/include/fopen-bin.h
@@ -0,0 +1,27 @@
+/* Macros for the 'type' part of an fopen, freopen or fdopen.
+
+ <Read|Write>[Update]<Binary file|text file>
+
+ This version is for "binary" systems, where text and binary files are
+ different. An example is Mess-Dose. Many Unix systems could also
+ cope with a "b" in the string, indicating binary files, but some reject this
+ (and thereby don't conform to ANSI C, but what else is new?).
+
+ This file is designed for inclusion by host-dependent .h files. No
+ user application should include it directly, since that would make
+ the application unable to be configured for both "same" and "binary"
+ variant systems. */
+
+#define FOPEN_RB "rb"
+#define FOPEN_WB "wb"
+#define FOPEN_AB "ab"
+#define FOPEN_RUB "r+b"
+#define FOPEN_WUB "w+b"
+#define FOPEN_AUB "a+b"
+
+#define FOPEN_RT "r"
+#define FOPEN_WT "w"
+#define FOPEN_AT "a"
+#define FOPEN_RUT "r+"
+#define FOPEN_WUT "w+"
+#define FOPEN_AUT "a+"
diff --git a/include/fopen-same.h b/include/fopen-same.h
new file mode 100644
index 00000000000..0f37529d33e
--- /dev/null
+++ b/include/fopen-same.h
@@ -0,0 +1,27 @@
+/* Macros for the 'type' part of an fopen, freopen or fdopen.
+
+ <Read|Write>[Update]<Binary file|text file>
+
+ This version is for "same" systems, where text and binary files are
+ the same. An example is Unix. Many Unix systems could also add a
+ "b" to the string, indicating binary files, but some reject this
+ (and thereby don't conform to ANSI C, but what else is new?).
+
+ This file is designed for inclusion by host-dependent .h files. No
+ user application should include it directly, since that would make
+ the application unable to be configured for both "same" and "binary"
+ variant systems. */
+
+#define FOPEN_RB "r"
+#define FOPEN_WB "w"
+#define FOPEN_AB "a"
+#define FOPEN_RUB "r+"
+#define FOPEN_WUB "w+"
+#define FOPEN_AUB "a+"
+
+#define FOPEN_RT "r"
+#define FOPEN_WT "w"
+#define FOPEN_AT "a"
+#define FOPEN_RUT "r+"
+#define FOPEN_WUT "w+"
+#define FOPEN_AUT "a+"
diff --git a/include/fopen-vms.h b/include/fopen-vms.h
new file mode 100644
index 00000000000..da76b7fb59c
--- /dev/null
+++ b/include/fopen-vms.h
@@ -0,0 +1,24 @@
+/* Macros for the 'type' part of an fopen, freopen or fdopen.
+
+ <Read|Write>[Update]<Binary file|text file>
+
+ This version is for VMS systems, where text and binary files are
+ different.
+ This file is designed for inclusion by host-dependent .h files. No
+ user application should include it directly, since that would make
+ the application unable to be configured for both "same" and "binary"
+ variant systems. */
+
+#define FOPEN_RB "rb","rfm=var"
+#define FOPEN_WB "wb","rfm=var"
+#define FOPEN_AB "ab","rfm=var"
+#define FOPEN_RUB "r+b","rfm=var"
+#define FOPEN_WUB "w+b","rfm=var"
+#define FOPEN_AUB "a+b","rfm=var"
+
+#define FOPEN_RT "r"
+#define FOPEN_WT "w"
+#define FOPEN_AT "a"
+#define FOPEN_RUT "r+"
+#define FOPEN_WUT "w+"
+#define FOPEN_AUT "a+"
diff --git a/include/gdbm.h b/include/gdbm.h
new file mode 100644
index 00000000000..3ebc26d198a
--- /dev/null
+++ b/include/gdbm.h
@@ -0,0 +1,91 @@
+/* GNU DBM - DataBase Manager include file
+ Copyright 1989, 1991 Free Software Foundation, Inc.
+ Written by Philip A. Nelson.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* You may contact the author by:
+ e-mail: phil@wwu.edu
+ us-mail: Philip A. Nelson
+ Computer Science Department
+ Western Washington University
+ Bellingham, WA 98226
+ phone: (206) 676-3035
+
+*************************************************************************/
+
+/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
+ can create the database. */
+#define GDBM_READER 0
+#define GDBM_WRITER 1
+#define GDBM_WRCREAT 2
+#define GDBM_NEWDB 3
+
+/* Parameters to gdbm_store for simple insertion or replacement. */
+#define GDBM_INSERT 0
+#define GDBM_REPLACE 1
+
+
+/* The data and key structure. This structure is defined for compatibility. */
+typedef struct {
+ char *dptr;
+ int dsize;
+ } datum;
+
+
+/* The file information header. This is good enough for most applications. */
+typedef struct {int dummy[10];} *GDBM_FILE;
+
+
+/* These are the routines! */
+
+extern GDBM_FILE gdbm_open ();
+
+extern void gdbm_close ();
+
+extern datum gdbm_fetch ();
+
+extern int gdbm_store ();
+
+extern int gdbm_delete ();
+
+extern datum gdbm_firstkey ();
+
+extern datum gdbm_nextkey ();
+
+extern int gdbm_reorganize ();
+
+
+/* gdbm sends back the following error codes in the variable gdbm_errno. */
+typedef enum { NO_ERROR,
+ MALLOC_ERROR,
+ BLOCK_SIZE_ERROR,
+ FILE_OPEN_ERROR,
+ FILE_WRITE_ERROR,
+ FILE_SEEK_ERROR,
+ FILE_READ_ERROR,
+ BAD_MAGIC_NUMBER,
+ EMPTY_DATABASE,
+ CANT_BE_READER,
+ CANT_BE_WRITER,
+ READER_CANT_RECOVER,
+ READER_CANT_DELETE,
+ READER_CANT_STORE,
+ READER_CANT_REORGANIZE,
+ UNKNOWN_UPDATE,
+ ITEM_NOT_FOUND,
+ REORGANIZE_FAILED,
+ CANNOT_REPLACE}
+ gdbm_error;
diff --git a/include/getopt.h b/include/getopt.h
new file mode 100644
index 00000000000..fb30719a860
--- /dev/null
+++ b/include/getopt.h
@@ -0,0 +1,133 @@
+/* Declarations for getopt.
+ Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct option
+{
+#if defined (__STDC__) && __STDC__
+ const char *name;
+#else
+ char *name;
+#endif
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+#if defined (__STDC__) && __STDC__
+#ifdef __GNU_LIBRARY__
+/* Many other libraries have conflicting prototypes for getopt, with
+ differences in the consts, in stdlib.h. To avoid compilation
+ errors, only prototype getopt for the GNU C library. */
+extern int getopt (int argc, char *const *argv, const char *shortopts);
+#else /* not __GNU_LIBRARY__ */
+extern int getopt ();
+#endif /* __GNU_LIBRARY__ */
+extern int getopt_long (int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+extern int getopt_long_only (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind);
+
+/* Internal only. Users should not call this directly. */
+extern int _getopt_internal (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+#else /* not __STDC__ */
+extern int getopt ();
+extern int getopt_long ();
+extern int getopt_long_only ();
+
+extern int _getopt_internal ();
+#endif /* __STDC__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* getopt.h */
diff --git a/include/hp-symtab.h b/include/hp-symtab.h
new file mode 100644
index 00000000000..fff56688ed2
--- /dev/null
+++ b/include/hp-symtab.h
@@ -0,0 +1,1871 @@
+/* Definitions and structures for reading debug symbols from the
+ native HP C compiler.
+
+ Written by the Center for Software Science at the University of Utah
+ and by Cygnus Support.
+
+ Copyright 1994 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef HP_SYMTAB_INCLUDED
+#define HP_SYMTAB_INCLUDED
+
+/* General information:
+
+ This header file defines and describes only the data structures
+ necessary to read debug symbols produced by the HP C compiler,
+ HP ANSI C++ compiler, and HP FORTRAN 90 compiler using the
+ SOM object file format.
+ (For a full description of the debug format, ftp hpux-symtab.h from
+ jaguar.cs.utah.edu:/dist).
+
+ Additional notes (Rich Title)
+ This file is a reverse-engineered version of a file called
+ "symtab.h" which exists internal to HP's Computer Languages Organization
+ in /CLO/Components/DDE/obj/som/symtab.h. Because HP's version of
+ the file is copyrighted and not distributed, it is necessary for
+ GDB to use the reverse-engineered version that follows.
+ Work was done by Cygnus to reverse-engineer the C subset of symtab.h.
+ The WDB project has extended this to also contain the C++
+ symbol definitions, the F90 symbol definitions,
+ and the DOC (debugging-optimized-code) symbol definitions.
+ In some cases (the C++ symbol definitions)
+ I have added internal documentation here that
+ goes beyond what is supplied in HP's symtab.h. If we someday
+ unify these files again, the extra comments should be merged back
+ into HP's symtab.h.
+
+ -------------------------------------------------------------------
+
+ Debug symbols are contained entirely within an unloadable space called
+ $DEBUG$. $DEBUG$ contains several subspaces which group related
+ debug symbols.
+
+ $GNTT$ contains information for global variables, types and contants.
+
+ $LNTT$ contains information for procedures (including nesting), scoping
+ information, local variables, types, and constants.
+
+ $SLT$ contains source line information so that code addresses may be
+ mapped to source lines.
+
+ $VT$ contains various strings and constants for named objects (variables,
+ typedefs, functions, etc). Strings are stored as null-terminated character
+ lists. Constants always begin on word boundaries. The first byte of
+ the VT must be zero (a null string).
+
+ $XT$ is not currently used by GDB.
+
+ Many structures within the subspaces point to other structures within
+ the same subspace, or to structures within a different subspace. These
+ pointers are represented as a structure index from the beginning of
+ the appropriate subspace. */
+
+/* Used to describe where a constant is stored. */
+enum location_type
+{
+ LOCATION_IMMEDIATE,
+ LOCATION_PTR,
+ LOCATION_VT,
+};
+
+/* Languages supported by this debug format. Within the data structures
+ this type is limited to 4 bits for a maximum of 16 languages. */
+enum hp_language
+{
+ HP_LANGUAGE_UNKNOWN,
+ HP_LANGUAGE_C,
+ HP_LANGUAGE_F77,
+ HP_LANGUAGE_PASCAL,
+ HP_LANGUAGE_MODCAL,
+ HP_LANGUAGE_COBOL,
+ HP_LANGUAGE_BASIC,
+ HP_LANGUAGE_ADA,
+ HP_LANGUAGE_CPLUSPLUS,
+ HP_LANGUAGE_DMPASCAL
+};
+
+
+/* Basic data types available in this debug format. Within the data
+ structures this type is limited to 5 bits for a maximum of 32 basic
+ data types. */
+enum hp_type
+{
+ HP_TYPE_UNDEFINED, /* 0 */
+ HP_TYPE_BOOLEAN, /* 1 */
+ HP_TYPE_CHAR, /* 2 */
+ HP_TYPE_INT, /* 3 */
+ HP_TYPE_UNSIGNED_INT, /* 4 */
+ HP_TYPE_REAL, /* 5 */
+ HP_TYPE_COMPLEX, /* 6 */
+ HP_TYPE_STRING200, /* 7 */
+ HP_TYPE_LONGSTRING200, /* 8 */
+ HP_TYPE_TEXT, /* 9 */
+ HP_TYPE_FLABEL, /* 10 */
+ HP_TYPE_FTN_STRING_SPEC, /* 11 */
+ HP_TYPE_MOD_STRING_SPEC, /* 12 */
+ HP_TYPE_PACKED_DECIMAL, /* 13 */
+ HP_TYPE_REAL_3000, /* 14 */
+ HP_TYPE_MOD_STRING_3000, /* 15 */
+ HP_TYPE_ANYPOINTER, /* 16 */
+ HP_TYPE_GLOBAL_ANYPOINTER, /* 17 */
+ HP_TYPE_LOCAL_ANYPOINTER, /* 18 */
+ HP_TYPE_COMPLEXS3000, /* 19 */
+ HP_TYPE_FTN_STRING_S300_COMPAT, /* 20 */
+ HP_TYPE_FTN_STRING_VAX_COMPAT, /* 21 */
+ HP_TYPE_BOOLEAN_S300_COMPAT, /* 22 */
+ HP_TYPE_BOOLEAN_VAX_COMPAT, /* 23 */
+ HP_TYPE_WIDE_CHAR, /* 24 */
+ HP_TYPE_LONG, /* 25 */
+ HP_TYPE_UNSIGNED_LONG, /* 26 */
+ HP_TYPE_DOUBLE, /* 27 */
+ HP_TYPE_TEMPLATE_ARG, /* 28 */
+ HP_TYPE_VOID /* 29 */
+};
+
+/* An immediate name and type table entry.
+
+ extension and immediate will always be one.
+ global will always be zero.
+ hp_type is the basic type this entry describes.
+ bitlength is the length in bits for the basic type. */
+struct dnttp_immediate
+{
+ unsigned int extension: 1;
+ unsigned int immediate: 1;
+ unsigned int global: 1;
+ unsigned int type: 5;
+ unsigned int bitlength: 24;
+};
+
+/* A nonimmediate name and type table entry.
+
+ extension will always be one.
+ immediate will always be zero.
+ if global is zero, this entry points into the LNTT
+ if global is one, this entry points into the GNTT
+ index is the index within the GNTT or LNTT for this entry. */
+struct dnttp_nonimmediate
+{
+ unsigned int extension: 1;
+ unsigned int immediate: 1;
+ unsigned int global: 1;
+ unsigned int index: 29;
+};
+
+/* A pointer to an entry in the GNTT and LNTT tables. It has two
+ forms depending on the type being described.
+
+ The immediate form is used for simple entries and is one
+ word.
+
+ The nonimmediate form is used for complex entries and contains
+ an index into the LNTT or GNTT which describes the entire type.
+
+ If a dnttpointer is -1, then it is a NIL entry. */
+
+#define DNTTNIL (-1)
+typedef union dnttpointer
+{
+ struct dnttp_immediate dntti;
+ struct dnttp_nonimmediate dnttp;
+ int word;
+} dnttpointer;
+
+/* An index into the source line table. As with dnttpointers, a sltpointer
+ of -1 indicates a NIL entry. */
+#define SLTNIL (-1)
+typedef int sltpointer;
+
+/* Index into DOC (= "Debugging Optimized Code") line table */
+#define LTNIL (-1)
+typedef int ltpointer;
+
+/* Index into context table */
+#define CTXTNIL (-1)
+typedef int ctxtpointer;
+
+/* Unsigned byte offset into the VT. */
+typedef unsigned int vtpointer;
+
+/* A DNTT entry (used within the GNTT and LNTT).
+
+ DNTT entries are variable sized objects, but are always a multiple
+ of 3 words (we call each group of 3 words a "block").
+
+ The first bit in each block is an extension bit. This bit is zero
+ for the first block of a DNTT entry. If the entry requires more
+ than one block, then this bit is set to one in all blocks after
+ the first one. */
+
+/* Each DNTT entry describes a particular debug symbol (beginning of
+ a source file, a function, variables, structures, etc.
+
+ The type of the DNTT entry is stored in the "kind" field within the
+ DNTT entry itself. */
+
+enum dntt_entry_type
+{
+ DNTT_TYPE_NIL = -1,
+ DNTT_TYPE_SRCFILE,
+ DNTT_TYPE_MODULE,
+ DNTT_TYPE_FUNCTION,
+ DNTT_TYPE_ENTRY,
+ DNTT_TYPE_BEGIN,
+ DNTT_TYPE_END,
+ DNTT_TYPE_IMPORT,
+ DNTT_TYPE_LABEL,
+ DNTT_TYPE_FPARAM,
+ DNTT_TYPE_SVAR,
+ DNTT_TYPE_DVAR,
+ DNTT_TYPE_HOLE1,
+ DNTT_TYPE_CONST,
+ DNTT_TYPE_TYPEDEF,
+ DNTT_TYPE_TAGDEF,
+ DNTT_TYPE_POINTER,
+ DNTT_TYPE_ENUM,
+ DNTT_TYPE_MEMENUM,
+ DNTT_TYPE_SET,
+ DNTT_TYPE_SUBRANGE,
+ DNTT_TYPE_ARRAY,
+ DNTT_TYPE_STRUCT,
+ DNTT_TYPE_UNION,
+ DNTT_TYPE_FIELD,
+ DNTT_TYPE_VARIANT,
+ DNTT_TYPE_FILE,
+ DNTT_TYPE_FUNCTYPE,
+ DNTT_TYPE_WITH,
+ DNTT_TYPE_COMMON,
+ DNTT_TYPE_COBSTRUCT,
+ DNTT_TYPE_XREF,
+ DNTT_TYPE_SA,
+ DNTT_TYPE_MACRO,
+ DNTT_TYPE_BLOCKDATA,
+ DNTT_TYPE_CLASS_SCOPE,
+ DNTT_TYPE_REFERENCE,
+ DNTT_TYPE_PTRMEM,
+ DNTT_TYPE_PTRMEMFUNC,
+ DNTT_TYPE_CLASS,
+ DNTT_TYPE_GENFIELD,
+ DNTT_TYPE_VFUNC,
+ DNTT_TYPE_MEMACCESS,
+ DNTT_TYPE_INHERITANCE,
+ DNTT_TYPE_FRIEND_CLASS,
+ DNTT_TYPE_FRIEND_FUNC,
+ DNTT_TYPE_MODIFIER,
+ DNTT_TYPE_OBJECT_ID,
+ DNTT_TYPE_MEMFUNC,
+ DNTT_TYPE_TEMPLATE,
+ DNTT_TYPE_TEMPLATE_ARG,
+ DNTT_TYPE_FUNC_TEMPLATE,
+ DNTT_TYPE_LINK,
+ DNTT_TYPE_DYN_ARRAY_DESC,
+ DNTT_TYPE_DESC_SUBRANGE,
+ DNTT_TYPE_BEGIN_EXT,
+ DNTT_TYPE_INLN,
+ DNTT_TYPE_INLN_LIST,
+ DNTT_TYPE_ALIAS,
+ DNTT_TYPE_DOC_FUNCTION,
+ DNTT_TYPE_DOC_MEMFUNC,
+ DNTT_TYPE_MAX
+};
+
+/* DNTT_TYPE_SRCFILE:
+
+ One DNTT_TYPE_SRCFILE symbol is output for the start of each source
+ file and at the begin and end of an included file. A DNTT_TYPE_SRCFILE
+ entry is also output before each DNTT_TYPE_FUNC symbol so that debuggers
+ can determine what file a function was defined in.
+
+ LANGUAGE describes the source file's language.
+
+ NAME points to an VT entry providing the source file's name.
+
+ Note the name used for DNTT_TYPE_SRCFILE entries are exactly as seen
+ by the compiler (ie they may be relative or absolute). C include files
+ via <> inclusion must use absolute paths.
+
+ ADDRESS points to an SLT entry from which line number and code locations
+ may be determined. */
+
+struct dntt_type_srcfile
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10; /* DNTT_TYPE_SRCFILE */
+ unsigned int language: 4;
+ unsigned int unused: 17;
+ vtpointer name;
+ sltpointer address;
+};
+
+/* DNTT_TYPE_MODULE:
+
+ A DNTT_TYPE_MODULE symbol is emitted for the start of a pascal
+ module or C source file. A module indicates a compilation unit
+ for name-scoping purposes; in that regard there should be
+ a 1-1 correspondence between GDB "symtab"'s and MODULE symbol records.
+
+ Each DNTT_TYPE_MODULE must have an associated DNTT_TYPE_END symbol.
+
+ NAME points to a VT entry providing the module's name. Note C
+ source files are considered nameless modules.
+
+ ALIAS point to a VT entry providing a secondary name.
+
+ ADDRESS points to an SLT entry from which line number and code locations
+ may be determined. */
+
+struct dntt_type_module
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10; /* DNTT_TYPE_MODULE */
+ unsigned int unused: 21;
+ vtpointer name;
+ vtpointer alias;
+ dnttpointer unused2;
+ sltpointer address;
+};
+
+/* DNTT_TYPE_FUNCTION,
+ DNTT_TYPE_ENTRY,
+ DNTT_TYPE_BLOCKDATA,
+ DNTT_TYPE_MEMFUNC:
+
+ A DNTT_TYPE_FUNCTION symbol is emitted for each function definition;
+ a DNTT_TYPE_ENTRY symbols is used for secondary entry points. Both
+ symbols used the dntt_type_function structure.
+ A DNTT_TYPE_BLOCKDATA symbol is emitted ...?
+ A DNTT_TYPE_MEMFUNC symbol is emitted for inlined member functions (C++).
+
+ Each of DNTT_TYPE_FUNCTION must have a matching DNTT_TYPE_END.
+
+ GLOBAL is nonzero if the function has global scope.
+
+ LANGUAGE describes the function's source language.
+
+ OPT_LEVEL describes the optimization level the function was compiled
+ with.
+
+ VARARGS is nonzero if the function uses varargs.
+
+ NAME points to a VT entry providing the function's name.
+
+ ALIAS points to a VT entry providing a secondary name for the function.
+
+ FIRSTPARAM points to a LNTT entry which describes the parameter list.
+
+ ADDRESS points to an SLT entry from which line number and code locations
+ may be determined.
+
+ ENTRYADDR is the memory address corresponding the the function's entry point
+
+ RETVAL points to a LNTT entry describing the function's return value.
+
+ LOWADDR is the lowest memory address associated with this function.
+
+ HIADDR is the highest memory address associated with this function. */
+
+struct dntt_type_function
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10; /* DNTT_TYPE_FUNCTION,
+ DNTT_TYPE_ENTRY,
+ DNTT_TYPE_BLOCKDATA
+ or DNTT_TYPE_MEMFUNC */
+ unsigned int global: 1;
+ unsigned int language: 4;
+ unsigned int nest_level: 5;
+ unsigned int opt_level: 2;
+ unsigned int varargs: 1;
+ unsigned int lang_info: 4;
+ unsigned int inlined: 1;
+ unsigned int localalloc: 1;
+ unsigned int expansion: 1;
+ unsigned int unused: 1;
+ vtpointer name;
+ vtpointer alias;
+ dnttpointer firstparam;
+ sltpointer address;
+ CORE_ADDR entryaddr;
+ dnttpointer retval;
+ CORE_ADDR lowaddr;
+ CORE_ADDR hiaddr;
+};
+
+/* DNTT_TYPE_BEGIN:
+
+ A DNTT_TYPE_BEGIN symbol is emitted to begin a new nested scope.
+ Every DNTT_TYPE_BEGIN symbol must have a matching DNTT_TYPE_END symbol.
+
+ CLASSFLAG is nonzero if this is the beginning of a c++ class definition.
+
+ ADDRESS points to an SLT entry from which line number and code locations
+ may be determined. */
+
+struct dntt_type_begin
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int classflag: 1;
+ unsigned int unused: 20;
+ sltpointer address;
+};
+
+/* DNTT_TYPE_END:
+
+ A DNTT_TYPE_END symbol is emitted when closing a scope started by
+ a DNTT_TYPE_MODULE, DNTT_TYPE_FUNCTION, DNTT_TYPE_WITH,
+ DNTT_TYPE_COMMON, DNTT_TYPE_BEGIN, and DNTT_TYPE_CLASS_SCOPE symbols.
+
+ ENDKIND describes what type of scope the DNTT_TYPE_END is closing
+ (one of the above 6 kinds).
+
+ CLASSFLAG is nonzero if this is the end of a c++ class definition.
+
+ ADDRESS points to an SLT entry from which line number and code locations
+ may be determined.
+
+ BEGINSCOPE points to the LNTT entry which opened the scope. */
+
+struct dntt_type_end
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int endkind: 10;
+ unsigned int classflag: 1;
+ unsigned int unused: 10;
+ sltpointer address;
+ dnttpointer beginscope;
+};
+
+/* DNTT_TYPE_IMPORT is unused by GDB. */
+/* DNTT_TYPE_LABEL is unused by GDB. */
+
+/* DNTT_TYPE_FPARAM:
+
+ A DNTT_TYPE_FPARAM symbol is emitted for a function argument. When
+ chained together the symbols represent an argument list for a function.
+
+ REGPARAM is nonzero if this parameter was passed in a register.
+
+ INDIRECT is nonzero if this parameter is a pointer to the parameter
+ (pass by reference or pass by value for large items).
+
+ LONGADDR is nonzero if the parameter is a 64bit pointer.
+
+ NAME is a pointer into the VT for the parameter's name.
+
+ LOCATION describes where the parameter is stored. Depending on the
+ parameter type LOCATION could be a register number, or an offset
+ from the stack pointer.
+
+ TYPE points to a NTT entry describing the type of this parameter.
+
+ NEXTPARAM points to the LNTT entry describing the next parameter. */
+
+struct dntt_type_fparam
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int regparam: 1;
+ unsigned int indirect: 1;
+ unsigned int longaddr: 1;
+ unsigned int copyparam: 1;
+ unsigned int dflt: 1;
+ unsigned int unused: 16;
+ vtpointer name;
+ int location;
+ dnttpointer type;
+ dnttpointer nextparam;
+ int misc;
+};
+
+/* DNTT_TYPE_SVAR:
+
+ A DNTT_TYPE_SVAR is emitted to describe a variable in static storage.
+
+ GLOBAL is nonzero if the variable has global scope.
+
+ INDIRECT is nonzero if the variable is a pointer to an object.
+
+ LONGADDR is nonzero if the variable is in long pointer space.
+
+ STATICMEM is nonzero if the variable is a member of a class.
+
+ A_UNION is nonzero if the variable is an anonymous union member.
+
+ NAME is a pointer into the VT for the variable's name.
+
+ LOCATION provides the memory address for the variable.
+
+ TYPE is a pointer into either the GNTT or LNTT which describes
+ the type of this variable. */
+
+struct dntt_type_svar
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int global: 1;
+ unsigned int indirect: 1;
+ unsigned int longaddr: 1;
+ unsigned int staticmem: 1;
+ unsigned int a_union: 1;
+ unsigned int unused1: 1;
+ unsigned int thread_specific: 1;
+ unsigned int unused2: 14;
+ vtpointer name;
+ CORE_ADDR location;
+ dnttpointer type;
+ unsigned int offset;
+ unsigned int displacement;
+};
+
+/* DNTT_TYPE_DVAR:
+
+ A DNTT_TYPE_DVAR is emitted to describe automatic variables and variables
+ held in registers.
+
+ GLOBAL is nonzero if the variable has global scope.
+
+ INDIRECT is nonzero if the variable is a pointer to an object.
+
+ REGVAR is nonzero if the variable is in a register.
+
+ A_UNION is nonzero if the variable is an anonymous union member.
+
+ NAME is a pointer into the VT for the variable's name.
+
+ LOCATION provides the memory address or register number for the variable.
+
+ TYPE is a pointer into either the GNTT or LNTT which describes
+ the type of this variable. */
+
+struct dntt_type_dvar
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int global: 1;
+ unsigned int indirect: 1;
+ unsigned int regvar: 1;
+ unsigned int a_union: 1;
+ unsigned int unused: 17;
+ vtpointer name;
+ int location;
+ dnttpointer type;
+ unsigned int offset;
+};
+
+/* DNTT_TYPE_CONST:
+
+ A DNTT_TYPE_CONST symbol is emitted for program constants.
+
+ GLOBAL is nonzero if the constant has global scope.
+
+ INDIRECT is nonzero if the constant is a pointer to an object.
+
+ LOCATION_TYPE describes where to find the constant's value
+ (in the VT, memory, or embedded in an instruction).
+
+ CLASSMEM is nonzero if the constant is a member of a class.
+
+ NAME is a pointer into the VT for the constant's name.
+
+ LOCATION provides the memory address, register number or pointer
+ into the VT for the constant's value.
+
+ TYPE is a pointer into either the GNTT or LNTT which describes
+ the type of this variable. */
+
+struct dntt_type_const
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int global: 1;
+ unsigned int indirect: 1;
+ unsigned int: 3;
+ unsigned int classmem: 1;
+ unsigned int unused: 15;
+ vtpointer name;
+ CORE_ADDR location;
+ dnttpointer type;
+ unsigned int offset;
+ unsigned int displacement;
+};
+
+/* DNTT_TYPE_TYPEDEF and DNTT_TYPE_TAGDEF:
+
+ The same structure is used to describe typedefs and tagdefs.
+
+ DNTT_TYPE_TYPEDEFS are associated with C "typedefs".
+
+ DNTT_TYPE_TAGDEFs are associated with C "struct", "union", and "enum"
+ tags, which may have the same name as a typedef in the same scope.
+ Also they are associated with C++ "class" tags, which implicitly have
+ the same name as the class type.
+
+ GLOBAL is nonzero if the typedef/tagdef has global scope.
+
+ TYPEINFO is used to determine if full type information is available
+ for a tag. (usually 1, but can be zero for opaque types in C).
+
+ NAME is a pointer into the VT for the constant's name.
+
+ TYPE points to the underlying type for the typedef/tagdef in the
+ GNTT or LNTT. */
+
+struct dntt_type_type
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10; /* DNTT_TYPE_TYPEDEF or
+ DNTT_TYPE_TAGDEF
+ */
+ unsigned int global: 1;
+ unsigned int typeinfo: 1;
+ unsigned int unused: 19;
+ vtpointer name;
+ dnttpointer type; /* Underlying type, which for TAGDEF's may be
+ * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION,
+ * DNTT_TYPE_ENUM, or DNTT_TYPE_CLASS.
+ * For TYPEDEF's other underlying types
+ * are also possible.
+ */
+};
+
+/* DNTT_TYPE_POINTER:
+
+ Used to describe a pointer to an underlying type.
+
+ POINTSTO is a pointer into the GNTT or LNTT for the type which this
+ pointer points to.
+
+ BITLENGTH is the length of the pointer (not the underlying type). */
+
+struct dntt_type_pointer
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int unused: 21;
+ dnttpointer pointsto;
+ unsigned int bitlength;
+};
+
+
+/* DNTT_TYPE_ENUM:
+
+ Used to describe enumerated types.
+
+ FIRSTMEM is a pointer to a DNTT_TYPE_MEMENUM in the GNTT/LNTT which
+ describes the first member (and contains a pointer to the chain of
+ members).
+
+ BITLENGTH is the number of bits used to hold the values of the enum's
+ members. */
+
+struct dntt_type_enum
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int unused: 21;
+ dnttpointer firstmem;
+ unsigned int bitlength;
+};
+
+/* DNTT_TYPE_MEMENUM
+
+ Used to describe members of an enumerated type.
+
+ CLASSMEM is nonzero if this member is part of a class.
+
+ NAME points into the VT for the name of this member.
+
+ VALUE is the value of this enumeration member.
+
+ NEXTMEM points to the next DNTT_TYPE_MEMENUM in the chain. */
+
+struct dntt_type_memenum
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int classmem: 1;
+ unsigned int unused: 20;
+ vtpointer name;
+ unsigned int value;
+ dnttpointer nextmem;
+};
+
+/* DNTT_TYPE_SET
+
+ Used to describe PASCAL "set" type.
+
+ DECLARATION describes the bitpacking of the set.
+
+ SUBTYPE points to a DNTT entry describing the type of the members.
+
+ BITLENGTH is the size of the set. */
+
+struct dntt_type_set
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int declaration: 2;
+ unsigned int unused: 19;
+ dnttpointer subtype;
+ unsigned int bitlength;
+};
+
+/* DNTT_TYPE_SUBRANGE
+
+ Used to describe subrange type.
+
+ DYN_LOW describes the lower bound of the subrange:
+
+ 00 for a constant lower bound (found in LOWBOUND).
+
+ 01 for a dynamic lower bound with the lower bound found in the the
+ memory address pointed to by LOWBOUND.
+
+ 10 for a dynamic lower bound described by an variable found in the
+ DNTT/LNTT (LOWBOUND would be a pointer into the DNTT/LNTT).
+
+ DYN_HIGH is similar to DYN_LOW, except it describes the upper bound.
+
+ SUBTYPE points to the type of the subrange.
+
+ BITLENGTH is the length in bits needed to describe the subrange's
+ values. */
+
+struct dntt_type_subrange
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int dyn_low: 2;
+ unsigned int dyn_high: 2;
+ unsigned int unused: 17;
+ int lowbound;
+ int highbound;
+ dnttpointer subtype;
+ unsigned int bitlength;
+};
+
+/* DNTT_TYPE_ARRAY
+
+ Used to describe an array type.
+
+ DECLARATION describes the bit packing used in the array.
+
+ ARRAYISBYTES is nonzero if the field in arraylength describes the
+ length in bytes rather than in bits. A value of zero is used to
+ describe an array with size 2**32.
+
+ ELEMISBYTES is nonzero if the length if each element in the array
+ is describes in bytes rather than bits. A value of zero is used
+ to an element with size 2**32.
+
+ ELEMORDER is nonzero if the elements are indexed in increasing order.
+
+ JUSTIFIED if the elements are left justified to index zero.
+
+ ARRAYLENGTH is the length of the array.
+
+ INDEXTYPE is a DNTT pointer to the type used to index the array.
+
+ ELEMTYPE is a DNTT pointer to the type for the array elements.
+
+ ELEMLENGTH is the length of each element in the array (including
+ any padding).
+
+ Multi-dimensional arrays are represented by ELEMTYPE pointing to
+ another DNTT_TYPE_ARRAY. */
+
+struct dntt_type_array
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int declaration: 2;
+ unsigned int dyn_low: 2;
+ unsigned int dyn_high: 2;
+ unsigned int arrayisbytes: 1;
+ unsigned int elemisbytes: 1;
+ unsigned int elemorder: 1;
+ unsigned int justified: 1;
+ unsigned int unused: 11;
+ unsigned int arraylength;
+ dnttpointer indextype;
+ dnttpointer elemtype;
+ unsigned int elemlength;
+};
+
+/* DNTT_TYPE_STRUCT
+
+ DNTT_TYPE_STRUCT is used to describe a C structure.
+
+ DECLARATION describes the bitpacking used.
+
+ FIRSTFIELD is a DNTT pointer to the first field of the structure
+ (each field contains a pointer to the next field, walk the list
+ to access all fields of the structure).
+
+ VARTAGFIELD and VARLIST are used for Pascal variant records.
+
+ BITLENGTH is the size of the structure in bits. */
+
+struct dntt_type_struct
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int declaration: 2;
+ unsigned int unused: 19;
+ dnttpointer firstfield;
+ dnttpointer vartagfield;
+ dnttpointer varlist;
+ unsigned int bitlength;
+};
+
+/* DNTT_TYPE_UNION
+
+ DNTT_TYPE_UNION is used to describe a C union.
+
+ FIRSTFIELD is a DNTT pointer to the beginning of the field chain.
+
+ BITLENGTH is the size of the union in bits. */
+
+struct dntt_type_union
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int unused: 21;
+ dnttpointer firstfield;
+ unsigned int bitlength;
+};
+
+/* DNTT_TYPE_FIELD
+
+ DNTT_TYPE_FIELD describes one field in a structure or union
+ or C++ class.
+
+ VISIBILITY is used to describe the visibility of the field
+ (for c++. public = 0, protected = 1, private = 2).
+
+ A_UNION is nonzero if this field is a member of an anonymous union.
+
+ STATICMEM is nonzero if this field is a static member of a template.
+
+ NAME is a pointer into the VT for the name of the field.
+
+ BITOFFSET gives the offset of this field in bits from the beginning
+ of the structure or union this field is a member of.
+
+ TYPE is a DNTT pointer to the type describing this field.
+
+ BITLENGTH is the size of the entry in bits.
+
+ NEXTFIELD is a DNTT pointer to the next field in the chain. */
+
+struct dntt_type_field
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int visibility: 2;
+ unsigned int a_union: 1;
+ unsigned int staticmem: 1;
+ unsigned int unused: 17;
+ vtpointer name;
+ unsigned int bitoffset;
+ dnttpointer type;
+ unsigned int bitlength;
+ dnttpointer nextfield;
+};
+
+/* DNTT_TYPE_VARIANT is unused by GDB. */
+/* DNTT_TYPE_FILE is unused by GDB. */
+
+/* DNTT_TYPE_FUNCTYPE
+
+ I think this is used to describe a function type (e.g., would
+ be emitted as part of a function-pointer description).
+
+ VARARGS is nonzero if this function uses varargs.
+
+ FIRSTPARAM is a DNTT pointer to the first entry in the parameter
+ chain.
+
+ RETVAL is a DNTT pointer to the type of the return value. */
+
+struct dntt_type_functype
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int varargs: 1;
+ unsigned int info: 4;
+ unsigned int unused: 16;
+ unsigned int bitlength;
+ dnttpointer firstparam;
+ dnttpointer retval;
+};
+
+/* DNTT_TYPE_WITH is emitted by C++ to indicate "with" scoping semantics.
+ (Probably also emitted by PASCAL to support "with"...).
+
+ C++ example: Say "memfunc" is a method of class "c", and say
+ "m" is a data member of class "c". Then from within "memfunc",
+ it is legal to reference "m" directly (e.g. you don't have to
+ say "this->m". The symbol table indicates
+ this by emitting a DNTT_TYPE_WITH symbol within the function "memfunc",
+ pointing to the type symbol for class "c".
+
+ In GDB, this symbol record is unnecessary,
+ because GDB's symbol lookup algorithm
+ infers the "with" semantics when it sees a "this" argument to the member
+ function. So GDB can safely ignore the DNTT_TYPE_WITH record.
+
+ A DNTT_TYPE_WITH has a matching DNTT_TYPE_END symbol
+ */
+
+struct dntt_type_with {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_WITH */
+ unsigned int addrtype: 2; /* 0 => STATTYPE */
+ /* 1 => DYNTYPE */
+ /* 2 => REGTYPE */
+ unsigned int indirect: 1; /* 1 => pointer to object */
+ unsigned int longaddr: 1; /* 1 => in long pointer space */
+ unsigned int nestlevel: 6; /* # of nesting levels back */
+ unsigned int doc_ranges: 1; /* 1 => location is range list */
+ unsigned int unused: 10;
+ long location; /* where stored (allocated) */
+ sltpointer address;
+ dnttpointer type; /* type of with expression */
+ vtpointer name; /* name of with expression */
+ unsigned long offset; /* byte offset from location */
+};
+
+/* DNTT_TYPE_COMMON is unsupported by GDB. */
+/* A DNTT_TYPE_COMMON symbol must have a matching DNTT_TYPE_END symbol */
+
+/* DNTT_TYPE_COBSTRUCT is unsupported by GDB. */
+/* DNTT_TYPE_XREF is unsupported by GDB. */
+/* DNTT_TYPE_SA is unsupported by GDB. */
+/* DNTT_TYPE_MACRO is unsupported by GDB */
+
+/* DNTT_TYPE_BLOCKDATA has the same structure as DNTT_TYPE_FUNCTION */
+
+/* The following are the C++ specific SOM records */
+
+/* The purpose of the DNTT_TYPE_CLASS_SCOPE is to bracket C++ methods
+ and indicate the method name belongs in the "class scope" rather
+ than in the module they are being defined in. For example:
+
+ class c {
+ ...
+ void memfunc(); // member function
+ };
+
+ void c::memfunc() // definition of class c's "memfunc"
+ {
+ ...
+ }
+
+ main()
+ {
+ ...
+ }
+
+ In the above, the name "memfunc" is not directly visible from "main".
+ I.e., you have to say "break c::memfunc".
+ If it were a normal function (not a method), it would be visible
+ via the simple "break memfunc". Since "memfunc" otherwise looks
+ like a normal FUNCTION in the symbol table, the bracketing
+ CLASS_SCOPE is what is used to indicate it is really a method.
+
+
+ A DNTT_TYPE_CLASS_SCOPE symbol must have a matching DNTT_TYPE_END symbol
+*/
+
+struct dntt_type_class_scope {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_CLASS_SCOPE */
+ unsigned int unused: 21;
+ sltpointer address ; /* pointer to SLT entry */
+ dnttpointer type ; /* pointer to class type DNTT */
+};
+
+/* C++ reference parameter.
+ The structure of this record is the same as DNTT_TYPE_POINTER -
+ refer to struct dntt_type_pointer.
+ */
+
+/* The next two describe C++ pointer-to-data-member type, and
+ pointer-to-member-function type, respectively.
+ DNTT_TYPE_PTRMEM and DNTT_TYPE_PTRMEMFUNC have the same structure
+ */
+
+struct dntt_type_ptrmem {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_PTRMEM */
+ unsigned int unused: 21;
+ dnttpointer pointsto ; /* pointer to class DNTT */
+ dnttpointer memtype ; /* type of member */
+};
+
+struct dntt_type_ptrmemfunc {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_PTRMEMFUNC */
+ unsigned int unused: 21;
+ dnttpointer pointsto ; /* pointer to class DNTT */
+ dnttpointer memtype ; /* type of member */
+};
+
+/* The DNTT_TYPE_CLASS symbol is emitted to describe a class type.
+ * "memberlist" points to a chained list of FIELD or GENFIELD records
+ * indicating the class members. "parentlist" points to a chained list
+ * of INHERITANCE records indicating classes from which we inherit
+ * fields.
+ */
+
+struct dntt_type_class
+{
+ unsigned int extension: 1; /* always 0 */
+ unsigned int kind: 10; /* always DNTT_TYPE_CLASS */
+ unsigned int abstract: 1; /* is this an abstract class? */
+ unsigned int class_decl: 2; /* 0=class,1=union,2=struct */
+ unsigned int expansion: 1; /* 1=template expansion */
+ unsigned int unused: 17;
+ dnttpointer memberlist ; /* ptr to chain of [GEN]FIELDs */
+ unsigned long vtbl_loc ; /* offset in obj of ptr to vtbl */
+ dnttpointer parentlist ; /* ptr to K_INHERITANCE list */
+ unsigned long bitlength ; /* total at this level */
+ dnttpointer identlist ; /* ptr to chain of class ident's */
+ dnttpointer friendlist ; /* ptr to K_FRIEND list */
+ dnttpointer templateptr ; /* ptr to template */
+ dnttpointer nextexp ; /* ptr to next expansion */
+};
+
+/* Class members are indicated via either the FIELD record (for
+ data members, same as for C struct fields), or by the GENFIELD record
+ (for member functions).
+ */
+
+struct dntt_type_genfield {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_GENFIELD */
+ unsigned int visibility: 2; /* pub = 0, prot = 1, priv = 2 */
+ unsigned int a_union: 1; /* 1 => anonymous union member */
+ unsigned int unused: 18;
+ dnttpointer field ; /* pointer to field or qualifier */
+ dnttpointer nextfield ; /* pointer to next field */
+};
+
+/* C++ virtual functions */
+
+struct dntt_type_vfunc {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_VFUNC */
+ unsigned int pure: 1; /* pure virtual function ? */
+ unsigned int unused: 20;
+ dnttpointer funcptr ; /* points to FUNCTION symbol */
+ unsigned long vtbl_offset ; /* offset into vtbl for virtual */
+};
+
+/* Not precisely sure what this is intended for - DDE ignores it */
+
+struct dntt_type_memaccess {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_MEMACCESS */
+ unsigned int unused: 21;
+ dnttpointer classptr ; /* pointer to base class */
+ dnttpointer field ; /* pointer field */
+};
+
+/* The DNTT_TYPE_INHERITANCE record describes derived classes.
+ * In particular, the "parentlist" field of the CLASS record points
+ * to a list of INHERITANCE records for classes from which we
+ * inherit members.
+ */
+
+struct dntt_type_inheritance {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_INHERITANCE */
+ unsigned int Virtual: 1; /* virtual base class ? */
+ unsigned int visibility: 2; /* pub = 0, prot = 1, priv = 2 */
+ unsigned int unused: 18;
+ dnttpointer classname ; /* first parent class, if any */
+ unsigned long offset ; /* offset to start of base class */
+ dnttpointer next ; /* pointer to next K_INHERITANCE */
+ unsigned long future[2] ; /* padding to 3-word block end */
+};
+
+/* C++ "friend" classes ... */
+
+struct dntt_type_friend_class {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_FRIEND_CLASS */
+ unsigned int unused: 21;
+ dnttpointer classptr ; /* pointer to class DNTT */
+ dnttpointer next ; /* next DNTT_FRIEND */
+};
+
+struct dntt_type_friend_func {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_FRIEND_FUNC */
+ unsigned int unused: 21;
+ dnttpointer funcptr ; /* pointer to function */
+ dnttpointer classptr ; /* pointer to class DNTT */
+ dnttpointer next ; /* next DNTT_FRIEND */
+ unsigned long future[2] ; /* padding to 3-word block end */
+};
+
+/* DDE appears to ignore the DNTT_TYPE_MODIFIER record.
+ * It could perhaps be used to give better "ptype" output in GDB;
+ * otherwise it is probably safe for GDB to ignore it also.
+ */
+
+struct dntt_type_modifier {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_MODIFIER */
+ unsigned int m_const: 1; /* const */
+ unsigned int m_static: 1; /* static */
+ unsigned int m_void: 1; /* void */
+ unsigned int m_volatile: 1; /* volatile */
+ unsigned int m_duplicate: 1; /* duplicate */
+ unsigned int unused: 16;
+ dnttpointer type ; /* subtype */
+ unsigned long future ; /* padding to 3-word block end */
+};
+
+/* I'm not sure what this was intended for - DDE ignores it */
+
+struct dntt_type_object_id {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_OBJECT_ID */
+ unsigned int indirect: 1; /* Is object_ident addr of addr? */
+ unsigned int unused: 20;
+ unsigned long object_ident ; /* object identifier */
+ unsigned long offset ; /* offset to start of base class */
+ dnttpointer next ; /* pointer to next K_OBJECT_ID */
+ unsigned long segoffset ; /* for linker fixup */
+ unsigned long future ; /* padding to 3-word block end */
+};
+
+/* No separate dntt_type_memfunc; same as dntt_type_func */
+
+/* Symbol records to support templates. These only get used
+ * in DDE's "describe" output (like GDB's "ptype").
+ */
+
+/* The TEMPLATE record is the header for a template-class.
+ * Like the CLASS record, a TEMPLATE record has a memberlist that
+ * points to a list of template members. It also has an arglist
+ * pointing to a list of TEMPLATE_ARG records.
+ */
+
+struct dntt_type_template {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_TEMPLATE */
+ unsigned int abstract: 1; /* is this an abstract class? */
+ unsigned int class_decl: 2; /* 0=class,1=union,2=struct */
+ unsigned int unused: 18;
+ dnttpointer memberlist ; /* ptr to chain of K_[GEN]FIELDs */
+ long unused2 ; /* offset in obj of ptr to vtbl */
+ dnttpointer parentlist ; /* ptr to K_INHERITANCE list */
+ unsigned long bitlength ; /* total at this level */
+ dnttpointer identlist ; /* ptr to chain of class ident's */
+ dnttpointer friendlist ; /* ptr to K_FRIEND list */
+ dnttpointer arglist ; /* ptr to argument list */
+ dnttpointer expansions ; /* ptr to expansion list */
+};
+
+/* Template-class arguments are a list of TEMPL_ARG records
+ * chained together. The "name" field is the name of the formal.
+ * E.g.:
+ * template <class T> class q { ... };
+ * Then "T" is the name of the formal argument.
+ */
+struct dntt_type_templ_arg {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_TEMPL_ARG */
+ unsigned int usagetype: 1; /* 0 type-name 1 expression */
+ unsigned int unused: 20;
+ vtpointer name ; /* name of argument */
+ dnttpointer type ; /* for non type arguments */
+ dnttpointer nextarg ; /* Next argument if any */
+ long future[2] ; /* padding to 3-word block end */
+};
+
+/* FUNC_TEMPLATE records are sort of like FUNCTION, but are emitted
+ * for template member functions. E.g.,
+ * template <class T> class q {
+ ...
+ void f();
+ ...
+ };
+ * Within the list of FIELDs/GENFIELDs defining the member list
+ * of the template "q", "f" would appear as a FUNC_TEMPLATE.
+ * We'll also see instances of FUNCTION "f" records for each
+ * instantiation of the template.
+ */
+
+struct dntt_type_func_template {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_FUNC_TEMPLATE */
+ unsigned int public: 1; /* 1 => globally visible */
+ unsigned int language: 4; /* type of language */
+ unsigned int level: 5; /* nesting level (top level = 0)*/
+ unsigned int optimize: 2; /* level of optimization */
+ unsigned int varargs: 1; /* ellipses. Pascal/800 later */
+ unsigned int info: 4; /* lang-specific stuff; F_xxxx */
+ unsigned int inlined: 1;
+ unsigned int localloc: 1; /* 0 at top, 1 at end of block */
+ unsigned int unused: 2;
+ vtpointer name ; /* name of function */
+ vtpointer alias ; /* alternate name, if any */
+ dnttpointer firstparam ; /* first FPARAM, if any */
+ dnttpointer retval ; /* return type, if any */
+ dnttpointer arglist ; /* ptr to argument list */
+};
+
+/* LINK is apparently intended to link together function template
+ * definitions with their instantiations. However, it is not clear
+ * why this would be needed, except to provide the information on
+ * a "ptype" command. And as far as I can tell, aCC does not
+ * generate this record.
+ */
+
+struct dntt_type_link {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* always DNTT_TYPE_LINK */
+ unsigned int linkKind: 4; /* always LINK_UNKNOWN */
+ unsigned int unused: 17;
+ long future1 ; /* expansion */
+ dnttpointer ptr1 ; /* link from template */
+ dnttpointer ptr2 ; /* to expansion */
+ long future[2] ; /* padding to 3-word block end */
+};
+
+/* end of C++ specific SOM's */
+
+/* DNTT_TYPE_DYN_ARRAY_DESC is unused by GDB */
+/* DNTT_TYPE_DESC_SUBRANGE is unused by GDB */
+/* DNTT_TYPE_BEGIN_EXT is unused by GDB */
+/* DNTT_TYPE_INLN is unused by GDB */
+/* DNTT_TYPE_INLN_LIST is unused by GDB */
+/* DNTT_TYPE_ALIAS is unused by GDB */
+
+struct dntt_type_doc_function {
+ unsigned int extension: 1; /* always zero */
+ unsigned int kind: 10; /* K_DOC_FUNCTION or */
+ /* K_DOC_MEMFUNC */
+ unsigned int global: 1; /* 1 => globally visible */
+ unsigned int language: 4; /* type of language */
+ unsigned int level: 5; /* nesting level (top level = 0)*/
+ unsigned int optimize: 2; /* level of optimization */
+ unsigned int varargs: 1; /* ellipses. Pascal/800 later */
+ unsigned int info: 4; /* lang-specific stuff; F_xxxx */
+ unsigned int inlined: 1;
+ unsigned int localloc: 1; /* 0 at top, 1 at end of block */
+ unsigned int expansion: 1; /* 1 = function expansion */
+ unsigned int doc_clone: 1;
+ vtpointer name; /* name of function */
+ vtpointer alias; /* alternate name, if any */
+ dnttpointer firstparam; /* first FPARAM, if any */
+ sltpointer address; /* code and text locations */
+ CORE_ADDR entryaddr; /* address of entry point */
+ dnttpointer retval; /* return type, if any */
+ CORE_ADDR lowaddr; /* lowest address of function */
+ CORE_ADDR hiaddr; /* highest address of function */
+ dnttpointer inline_list; /* pointer to first inline */
+ ltpointer lt_offset; /* start of frag/cp line table */
+ ctxtpointer ctxt_offset; /* start of context table for this routine */
+};
+
+/* DNTT_TYPE_DOC_MEMFUNC is unused by GDB */
+
+/* DNTT_TYPE_GENERIC and DNTT_TYPE_BLOCK are convience structures
+ so we can examine a DNTT entry in a generic fashion. */
+struct dntt_type_generic
+{
+ unsigned int word[9];
+};
+
+struct dntt_type_block
+{
+ unsigned int extension: 1;
+ unsigned int kind: 10;
+ unsigned int unused: 21;
+ unsigned int word[2];
+};
+
+/* One entry in a DNTT (either the LNTT or GNTT).
+ * This is a union of the above 60 or so structure definitions.
+ */
+union dnttentry
+{
+ struct dntt_type_srcfile dsfile;
+ struct dntt_type_module dmodule;
+ struct dntt_type_function dfunc;
+ struct dntt_type_function dentry;
+ struct dntt_type_begin dbegin;
+ struct dntt_type_end dend;
+ struct dntt_type_fparam dfparam;
+ struct dntt_type_svar dsvar;
+ struct dntt_type_dvar ddvar;
+ struct dntt_type_const dconst;
+ struct dntt_type_type dtype;
+ struct dntt_type_type dtag;
+ struct dntt_type_pointer dptr;
+ struct dntt_type_enum denum;
+ struct dntt_type_memenum dmember;
+ struct dntt_type_set dset;
+ struct dntt_type_subrange dsubr;
+ struct dntt_type_array darray;
+ struct dntt_type_struct dstruct;
+ struct dntt_type_union dunion;
+ struct dntt_type_field dfield;
+ struct dntt_type_functype dfunctype;
+ struct dntt_type_with dwith;
+ struct dntt_type_function dblockdata;
+ struct dntt_type_class_scope dclass_scope;
+ struct dntt_type_pointer dreference;
+ struct dntt_type_ptrmem dptrmem;
+ struct dntt_type_ptrmemfunc dptrmemfunc;
+ struct dntt_type_class dclass;
+ struct dntt_type_genfield dgenfield;
+ struct dntt_type_vfunc dvfunc;
+ struct dntt_type_memaccess dmemaccess;
+ struct dntt_type_inheritance dinheritance;
+ struct dntt_type_friend_class dfriend_class;
+ struct dntt_type_friend_func dfriend_func;
+ struct dntt_type_modifier dmodifier;
+ struct dntt_type_object_id dobject_id;
+ struct dntt_type_template dtemplate;
+ struct dntt_type_templ_arg dtempl_arg;
+ struct dntt_type_func_template dfunc_template;
+ struct dntt_type_link dlink;
+ struct dntt_type_doc_function ddocfunc;
+ struct dntt_type_generic dgeneric;
+ struct dntt_type_block dblock;
+};
+
+/* Source line entry types. */
+enum slttype
+{
+ SLT_NORMAL,
+ SLT_SRCFILE,
+ SLT_MODULE,
+ SLT_FUNCTION,
+ SLT_ENTRY,
+ SLT_BEGIN,
+ SLT_END,
+ SLT_WITH,
+ SLT_EXIT,
+ SLT_ASSIST,
+ SLT_MARKER,
+ SLT_CLASS_SCOPE,
+ SLT_INLN,
+ SLT_NORMAL_OFFSET,
+};
+
+/* A normal source line entry. Simply provides a mapping of a source
+ line number to a code address.
+
+ SLTDESC will always be SLT_NORMAL or SLT_EXIT. */
+
+struct slt_normal
+{
+ unsigned int sltdesc: 4;
+ unsigned int line: 28;
+ CORE_ADDR address;
+};
+
+struct slt_normal_off
+{
+ unsigned int sltdesc: 4;
+ unsigned int offset: 6;
+ unsigned int line: 22;
+ CORE_ADDR address;
+};
+
+/* A special source line entry. Provides a mapping of a declaration
+ to a line number. These entries point back into the DNTT which
+ references them. */
+
+struct slt_special
+{
+ unsigned int sltdesc: 4;
+ unsigned int line: 28;
+ dnttpointer backptr;
+};
+
+/* Used to describe nesting.
+
+ For nested languages, an slt_assist entry must follow each SLT_FUNC
+ entry in the SLT. The address field will point forward to the
+ first slt_normal entry within the function's scope. */
+
+struct slt_assist
+{
+ unsigned int sltdesc: 4;
+ unsigned int unused: 28;
+ sltpointer address;
+};
+
+struct slt_generic
+{
+ unsigned int word[2];
+};
+
+union sltentry
+{
+ struct slt_normal snorm;
+ struct slt_normal_off snormoff;
+ struct slt_special sspec;
+ struct slt_assist sasst;
+ struct slt_generic sgeneric;
+};
+
+/* $LINES$ declarations
+ * This is the line table used for optimized code, which is only present
+ * in the new $PROGRAM_INFO$ debug space.
+ */
+
+#define DST_LN_ESCAPE_FLAG1 15
+#define DST_LN_ESCAPE_FLAG2 14
+#define DST_LN_CTX_SPEC1 13
+#define DST_LN_CTX_SPEC2 12
+
+/*
+ Escape function codes:
+*/
+typedef enum
+ {
+ dst_ln_pad, /* pad byte */
+ dst_ln_escape_1, /* reserved */
+ dst_ln_dpc1_dln1, /* 1 byte line delta, 1 byte pc delta */
+ dst_ln_dpc2_dln2, /* 2 bytes line delta, 2 bytes pc delta */
+ dst_ln_pc4_ln4, /* 4 bytes ABSOLUTE line number, 4 bytes ABSOLUTE pc */
+ dst_ln_dpc0_dln1, /* 1 byte line delta, pc delta = 0 */
+ dst_ln_ln_off_1, /* statement escape, stmt # = 1 (2nd stmt on line) */
+ dst_ln_ln_off, /* statement escape, stmt # = next byte */
+ dst_ln_entry, /* entry escape, next byte is entry number */
+ dst_ln_exit, /* exit escape */
+ dst_ln_stmt_end, /* gap escape, 4 bytes pc delta */
+ dst_ln_stmt_cp, /* current stmt is a critical point */
+ dst_ln_escape_12, /* reserved */
+ dst_ln_escape_13, /* this is an exception site record */
+ dst_ln_nxt_byte, /* next byte contains the real escape code */
+ dst_ln_end, /* end escape, final entry follows */
+ dst_ln_escape1_END_OF_ENUM
+ }
+ dst_ln_escape1_t;
+
+typedef enum
+ {
+ dst_ln_ctx_1, /* next byte describes context switch with 5-bit */
+ /* index into the image table and 3-bit run length. */
+ /* If run length is 0, end with another cxt specifier or ctx_end */
+ dst_ln_ctx_2, /* next 2 bytes switch context: 13 bit index, 3 bit run length */
+ dst_ln_ctx_4, /* next 4 bytes switch context: 29 bit index, 3 bit run length */
+ dst_ln_ctx_end, /* end current context */
+ dst_ln_col_run_1, /* next byte is column position of start of next statement, */
+ /* following byte is length of statement */
+ dst_ln_col_run_2, /* next 2 bytes is column position of start of next statement, */
+ /* following 2 bytes is length of statement */
+ dst_ln_init_base1, /* next 4 bytes are absolute PC, followed by 1 byte of line number */
+ dst_ln_init_base2, /* next 4 bytes are absolute PC, followed by 2 bytes of line number */
+ dst_ln_init_base3, /* next 4 bytes are absolute PC, followed by 3 bytes of line number */
+ dst_ln_escape2_END_OF_ENUM
+ }
+ dst_ln_escape2_t;
+
+typedef union
+ {
+ struct
+ {
+ unsigned int pc_delta : 4; /* 4 bit pc delta */
+ int ln_delta : 4; /* 4 bit line number delta */
+ }
+ delta;
+
+ struct
+ {
+ unsigned int esc_flag : 4; /* alias for pc_delta */
+ unsigned int esc_code : 4; /* escape function code (dst_ln_escape1_t, or ...2_t */
+ }
+ esc;
+
+ struct
+ {
+ unsigned int esc_flag : 4; /* dst_ln_ctx_spec1, or dst_ln_ctx_spec2 */
+ unsigned int run_length : 2;
+ unsigned int ctx_index : 2; /* ...spec2 contains index; ...spec1, index - 4 */
+ }
+ ctx_spec;
+
+ char sdata; /* signed data byte */
+ unsigned char udata; /* unsigned data byte */
+ }
+ dst_ln_entry_t,
+ *dst_ln_entry_ptr_t;
+
+/* Warning: although the above union occupies only 1 byte the compiler treats
+ * it as having size 2 (the minimum size of a struct). Therefore a sequence of
+ * dst_ln_entry_t's cannot be described as an array, and walking through such a
+ * sequence requires convoluted code such as
+ * ln_ptr = (dst_ln_entry_ptr_t) (char*) ln_ptr + 1
+ * We regret the inconvenience. */
+
+/* Structure for interpreting the byte following a dst_ln_ctx1 entry */
+typedef struct {
+ unsigned int ctx1_index : 5; /* 5 bit index into context table */
+ unsigned int ctx1_run_length : 3; /* 3 bit run length */
+} dst_ln_ctx1_t,
+ *dst_ln_ctx1_ptr_t;
+
+/* Structure for interpreting the bytes following a dst_ln_ctx2 entry */
+typedef struct {
+ unsigned int ctx2_index : 13; /* 13 bit index into context table */
+ unsigned int ctx2_run_length : 3; /* 3 bit run length */
+} dst_ln_ctx2_t,
+ *dst_ln_ctx2_ptr_t;
+
+/* Structure for interpreting the bytes following a dst_ln_ctx4 entry */
+typedef struct {
+ unsigned int ctx4_index : 29; /* 29 bit index into context table */
+ unsigned int ctx4_run_length : 3; /* 3 bit run length */
+} dst_ln_ctx4_t,
+ *dst_ln_ctx4_ptr_t;
+
+
+/* PXDB definitions.
+ *
+ * PXDB is a post-processor which takes the executable file
+ * and massages the debug information so that the debugger may
+ * start up and run more efficiently. Some of the tasks
+ * performed by PXDB are:
+ *
+ * o Remove duplicate global type and variable information
+ * from the GNTT,
+ *
+ * o Append the GNTT onto the end of the LNTT and place both
+ * back in the LNTT section,
+ *
+ * o Build quick look-up tables (description follows) for
+ * files, procedures, modules, and paragraphs (for Cobol),
+ * placing these in the GNTT section,
+ *
+ * o Reconstruct the header appearing in the header section
+ * to access this information.
+ *
+ * The "quick look-up" tables are in the $GNTT$ sub-space, in
+ * the following order:
+ *
+ * Procedures -sorted by address
+ * Source files -sorted by address (of the
+ * generated code from routines)
+ * Modules -sorted by address
+ * Classes -<unsorted?>
+ * Address Alias -sorted by index <?>
+ * Object IDs -sorted by object identifier
+ *
+ * Most quick entries have (0-based) indices into the LNTT tables to
+ * the full entries for the item it describes.
+ *
+ * The post-PXDB header is in the $HEADER$ sub-space. Alas, it
+ * occurs in different forms, depending on the optimization level
+ * in the compilation step and whether PXDB was run or not. The
+ * worst part is the forms aren't self-describing, so we'll have
+ * to grovel in the bits to figure out what kind we're looking at
+ * (see hp_get_header in hp-psymtab-read.c).
+ */
+
+/* PXDB versions
+ */
+#define PXDB_VERSION_CPLUSPLUS 1
+#define PXDB_VERSION_7_4 2
+#define PXDB_VERSION_CPP_30 3
+#define PXDB_VERSION_DDE_3_2A 4
+#define PXDB_VERSION_DDE_3_2 5
+#define PXDB_VERSION_DDE_4_0 6
+
+#define PXDB_VERSION_2_1 1
+
+/* Header version for the case that there is no DOC info
+ * but the executable has been processed by pxdb (the easy
+ * case, from "cc -g").
+ */
+typedef struct PXDB_struct {
+ int pd_entries; /* # of entries in function look-up table */
+ int fd_entries; /* # of entries in file look-up table */
+ int md_entries; /* # of entries in module look-up table */
+ unsigned int pxdbed : 1; /* 1 => file has been preprocessed */
+ unsigned int bighdr : 1; /* 1 => this header contains 'time' word */
+ unsigned int sa_header : 1;/* 1 => created by SA version of pxdb */
+ /* used for version check in xdb */
+ unsigned int inlined: 1; /* one or more functions have been inlined */
+ unsigned int spare:12;
+ short version; /* pxdb header version */
+ int globals; /* index into the DNTT where GNTT begins */
+ unsigned int time; /* modify time of file before being pxdbed */
+ int pg_entries; /* # of entries in label look-up table */
+ int functions; /* actual number of functions */
+ int files; /* actual number of files */
+ int cd_entries; /* # of entries in class look-up table */
+ int aa_entries; /* # of entries in addr alias look-up table */
+ int oi_entries; /* # of entries in object id look-up table */
+} PXDB_header, *PXDB_header_ptr;
+
+/* Header version for the case that there is no DOC info and the
+ * executable has NOT been processed by pxdb.
+ */
+typedef struct XDB_header_struct {
+ long gntt_length;
+ long lntt_length;
+ long slt_length;
+ long vt_length;
+ long xt_length;
+} XDB_header;
+
+/* Header version for the case that there is DOC info and the
+ * executable has been processed by pxdb.
+ */
+typedef struct DOC_info_PXDB_header_struct {
+ unsigned int xdb_header: 1; /* bit set if this is post-3.1 xdb */
+ unsigned int doc_header: 1; /* bit set if this is doc-style header*/
+ unsigned int version: 8; /* version of pxdb see defines
+ * PXDB_VERSION_* in this file */
+ unsigned int reserved_for_flags: 16;/* for future use; -- must be
+ * set to zero
+ */
+ unsigned int has_aux_pd_table: 1; /* $GNTT$ has aux PD table */
+ unsigned int has_expr_table: 1; /* space has $EXPR$ */
+ unsigned int has_range_table: 1; /* space has $RANGE$ */
+ unsigned int has_context_table: 1; /* space has $SRC_CTXT$ */
+ unsigned int has_lines_table: 1; /* space contains a $LINES$
+ * subspace for line tables.
+ */
+ unsigned int has_lt_offset_map: 1; /* space contains an lt_offset
+ * subspace for line table mapping
+ */
+ /* the following fields are the same as those in the PXDB_header in $DEBUG$ */
+ int pd_entries; /* # of entries in function look-up table */
+ int fd_entries; /* # of entries in file look-up table */
+ int md_entries; /* # of entries in module look-up table */
+ unsigned int pxdbed : 1; /* 1 => file has been preprocessed */
+ unsigned int bighdr : 1; /* 1 => this header contains 'time' word */
+ unsigned int sa_header : 1;/* 1 => created by SA version of pxdb */
+ /* used for version check in xdb */
+ unsigned int inlined: 1; /* one or more functions have been inlined */
+ unsigned int spare : 28;
+ int globals; /* index into the DNTT where GNTT begins */
+ unsigned int time; /* modify time of file before being pxdbed */
+ int pg_entries; /* # of entries in label look-up table */
+ int functions; /* actual number of functions */
+ int files; /* actual number of files */
+ int cd_entries; /* # of entries in class look-up table */
+ int aa_entries; /* # of entries in addr alias look-up table */
+ int oi_entries; /* # of entries in object id look-up table */
+} DOC_info_PXDB_header;
+
+/* Header version for the case that there is DOC info and the
+ * executable has NOT been processed by pxdb.
+ */
+typedef struct DOC_info_header_struct {
+ unsigned int xdb_header: 1; /* bit set if this is post-3.1 xdb */
+ unsigned int doc_header: 1; /* bit set if this is doc-style header*/
+ unsigned int version: 8; /* version of debug/header
+ format. For 10.0 the value
+ will be 1. For "Davis" the
+ value is 2.
+ */
+ unsigned int reserved_for_flags: 18; /* for future use; -- must be
+ set to zero
+ */
+ unsigned int has_range_table: 1; /* space contains a $RANGE$
+ subspace for variable ranges.
+ */
+ unsigned int has_context_table: 1; /* space contains a $CTXT$
+ subspace for context/inline
+ table.
+ */
+ unsigned int has_lines_table: 1; /* space contains a $LINES$
+ subspace for line tables.
+ */
+ unsigned int has_lt_offset_map: 1; /* space contains an lt_offset
+ subspace for line table mapping
+ */
+
+ long gntt_length; /* same as old header */
+ long lntt_length; /* same as old header */
+ long slt_length; /* same as old header */
+ long vt_length; /* same as old header */
+ long xt_length; /* same as old header */
+ long ctxt_length; /* present only if version >= 2 */
+ long range_length; /* present only if version >= 2 */
+ long expr_length; /* present only if version >= 2 */
+
+} DOC_info_header;
+
+typedef union GenericDebugHeader_union
+{
+ PXDB_header no_doc;
+ DOC_info_PXDB_header doc;
+ XDB_header no_pxdb_no_doc;
+ DOC_info_header no_pxdb_doc;
+} GenericDebugHeader;
+
+
+/* Procedure Descriptor:
+ *
+ * An element of the procedure quick look-up table
+ */
+typedef struct quick_procedure {
+ long isym; /* 0-based index of first symbol*/
+ /* for procedure in $LNTT$, */
+ /* i.e. the procedure itself */
+ CORE_ADDR adrStart; /* memory adr of start of proc */
+ CORE_ADDR adrEnd; /* memory adr of end of proc */
+ char *sbAlias; /* alias name of procedure */
+ char *sbProc; /* real name of procedure */
+ CORE_ADDR adrBp; /* address of entry breakpoint */
+ CORE_ADDR adrExitBp; /* address of exit breakpoint */
+ int icd; /* member of this class (index) */
+ unsigned int ipd; /* index of template for this */
+ /* function (index) */
+ unsigned int unused: 5;
+ unsigned int no_lt_offset: 1;/* no entry in lt_offset table */
+ unsigned int fTemplate: 1; /* function template */
+ unsigned int fExpansion: 1; /* function expansion */
+ unsigned int linked : 1; /* linked with other expansions */
+ unsigned int duplicate: 1; /* clone of another procedure */
+ unsigned int overloaded:1; /* overloaded function */
+ unsigned int member: 1; /* class member function */
+ unsigned int constructor:1; /* constructor function */
+ unsigned int destructor:1; /* destructor function */
+ unsigned int Static: 1; /* static function */
+ unsigned int Virtual: 1; /* virtual function */
+ unsigned int constant: 1; /* constant function */
+ unsigned int pure: 1; /* pure (virtual) function */
+ unsigned int language: 4; /* procedure's language */
+ unsigned int inlined: 1; /* function has been inlined */
+ unsigned int Operator: 1; /* operator function */
+ unsigned int stub: 1; /* bodyless function */
+ unsigned int optimize: 2; /* optimization level */
+ unsigned int level: 5; /* nesting level (top=0) */
+} quick_procedure_entry, *quick_procedure_entry_ptr;
+
+/* Source File Descriptor:
+ *
+ * An element of the source file quick look-up table
+ */
+typedef struct quick_source {
+ long isym; /* 0-based index in $LNTT$ of */
+ /* first symbol for this file */
+ CORE_ADDR adrStart; /* mem adr of start of file's code */
+ CORE_ADDR adrEnd; /* mem adr of end of file's code */
+ char *sbFile; /* name of source file */
+ unsigned int fHasDecl: 1; /* do we have a .d file? */
+ unsigned int fWarned: 1; /* have warned about age problems? */
+ unsigned int fSrcfile: 1; /* 0 => include 1=> source */
+ unsigned short ilnMac; /* lines in file (0 if don't know) */
+ int ipd; /* 0-based index of first procedure*/
+ /* in this file, in the quick */
+ /* look-up table of procedures */
+ unsigned int *rgLn; /* line pointer array, if any */
+} quick_file_entry, *quick_file_entry_ptr;
+
+/* Module Descriptor:
+ *
+ * An element of the module quick reference table
+ */
+typedef struct quick_module {
+ long isym; /* 0-based index of first */
+ /* symbol for module */
+ CORE_ADDR adrStart; /* adr of start of mod. */
+ CORE_ADDR adrEnd; /* adr of end of mod. */
+ char *sbAlias; /* alias name of module */
+ char *sbMod; /* real name of module */
+ unsigned int imports: 1; /* module have any imports? */
+ unsigned int vars_in_front: 1; /* module globals in front? */
+ unsigned int vars_in_gaps: 1; /* module globals in gaps? */
+ unsigned int language: 4; /* type of language */
+ unsigned int unused : 25;
+ unsigned int unused2; /* space for future stuff */
+} quick_module_entry, *quick_module_entry_ptr;
+
+/* Auxiliary Procedure Descriptor:
+ *
+ * An element of the auxiliary procedure quick look-up table
+ */
+typedef struct quick_aux_procedure {
+ long isym_inln; /* start on inline list for proc */
+ long spare;
+} quick_aux_procedure_entry, *quick_aux_procedure_entry_ptr;
+
+/* Paragraph Descriptor:
+ *
+ * An element of the paragraph quick look-up table
+ */
+typedef struct quick_paragraph {
+ long isym; /* first symbol for label (index) */
+ CORE_ADDR adrStart; /* memory adr of start of label */
+ CORE_ADDR adrEnd; /* memory adr of end of label */
+ char *sbLab; /* name of label */
+ unsigned int inst; /* Used in xdb to store inst @ bp */
+ unsigned int sect: 1; /* true = section, false = parag. */
+ unsigned int unused: 31; /* future use */
+} quick_paragraph_entry, *quick_paragraph_entry_ptr;
+
+/*
+ * Class Descriptor:
+ *
+ * An element of the class quick look-up table
+ */
+typedef struct quick_class {
+ char *sbClass; /* name of class */
+ long isym; /* class symbol (tag) */
+ unsigned int type : 2; /* 0=class, 1=union, 2=struct */
+ unsigned int fTemplate : 1;/* class template */
+ unsigned int expansion : 1;/* template expansion */
+ unsigned int unused :28;
+ sltpointer lowscope; /* beginning of defined scope */
+ sltpointer hiscope; /* end of defined scope */
+} quick_class_entry, *quick_class_entry_ptr;
+
+/* Address Alias Entry
+ *
+ * An element of the address alias quick look-up table
+ */
+typedef struct quick_alias {
+ CORE_ADDR low;
+ CORE_ADDR high;
+ int index;
+ unsigned int unused : 31;
+ unsigned int alternate : 1; /* alternate unnamed aliases? */
+} quick_alias_entry, *quick_alias_entry_ptr;
+
+/* Object Identification Entry
+ *
+ * An element of the object identification quick look-up table
+ */
+
+typedef struct quick_obj_ID {
+ CORE_ADDR obj_ident; /* class identifier */
+ long isym; /* class symbol */
+ long offset; /* offset to object start */
+} quick_obj_ID_entry, *quick_obj_ID_entry_ptr;
+
+
+#endif /* HP_SYMTAB_INCLUDED */
+
diff --git a/include/ieee.h b/include/ieee.h
new file mode 100644
index 00000000000..5ade39d33e3
--- /dev/null
+++ b/include/ieee.h
@@ -0,0 +1,139 @@
+/* IEEE Standard 695-1980 "Universal Format for Object Modules" header file
+ Contributed by Cygnus Support. */
+
+#define N_W_VARIABLES 8
+#define Module_Beginning 0xe0
+
+typedef struct ieee_module {
+ char *processor;
+ char *module_name;
+} ieee_module_begin_type;
+
+#define Address_Descriptor 0xec
+typedef struct ieee_address {
+bfd_vma number_of_bits_mau;
+ bfd_vma number_of_maus_in_address;
+
+ unsigned char byte_order;
+#define IEEE_LITTLE 0xcc
+#define IEEE_BIG 0xcd
+} ieee_address_descriptor_type;
+
+typedef union ieee_w_variable {
+ file_ptr offset[N_W_VARIABLES];
+ struct {
+ file_ptr extension_record;
+ file_ptr environmental_record;
+ file_ptr section_part;
+ file_ptr external_part;
+ file_ptr debug_information_part;
+ file_ptr data_part;
+ file_ptr trailer_part;
+ file_ptr me_record;
+ } r;
+} ieee_w_variable_type;
+
+
+
+
+
+typedef enum ieee_record
+{
+ ieee_number_start_enum = 0x00,
+ ieee_number_end_enum=0x7f,
+ ieee_number_repeat_start_enum = 0x80,
+ ieee_number_repeat_end_enum = 0x88,
+ ieee_number_repeat_4_enum = 0x84,
+ ieee_number_repeat_3_enum = 0x83,
+ ieee_number_repeat_2_enum = 0x82,
+ ieee_number_repeat_1_enum = 0x81,
+ ieee_module_beginning_enum = 0xe0,
+ ieee_module_end_enum = 0xe1,
+ ieee_extension_length_1_enum = 0xde,
+ ieee_extension_length_2_enum = 0xdf,
+ ieee_section_type_enum = 0xe6,
+ ieee_section_alignment_enum = 0xe7,
+ ieee_external_symbol_enum = 0xe8,
+ ieee_comma = 0x90,
+ ieee_external_reference_enum = 0xe9,
+ ieee_set_current_section_enum = 0xe5,
+ ieee_address_descriptor_enum = 0xec,
+ ieee_load_constant_bytes_enum = 0xed,
+ ieee_load_with_relocation_enum = 0xe4,
+
+ ieee_variable_A_enum = 0xc1,
+ ieee_variable_B_enum = 0xc2,
+ ieee_variable_C_enum = 0xc3,
+ ieee_variable_D_enum = 0xc4,
+ ieee_variable_E_enum = 0xc5,
+ ieee_variable_F_enum = 0xc6,
+ ieee_variable_G_enum = 0xc7,
+ ieee_variable_H_enum = 0xc8,
+ ieee_variable_I_enum = 0xc9,
+ ieee_variable_J_enum = 0xca,
+ ieee_variable_K_enum = 0xcb,
+ ieee_variable_L_enum = 0xcc,
+ ieee_variable_M_enum = 0xcd,
+ ieee_variable_N_enum = 0xce,
+ ieee_variable_O_enum = 0xcf,
+ ieee_variable_P_enum = 0xd0,
+ ieee_variable_Q_enum = 0xd1,
+ ieee_variable_R_enum = 0xd2,
+ ieee_variable_S_enum = 0xd3,
+ ieee_variable_T_enum = 0xd4,
+ ieee_variable_U_enum = 0xd5,
+ ieee_variable_V_enum = 0xd6,
+ ieee_variable_W_enum = 0xd7,
+ ieee_variable_X_enum = 0xd8,
+ ieee_variable_Y_enum = 0xd9,
+ ieee_variable_Z_enum = 0xda,
+ ieee_function_plus_enum = 0xa5,
+ ieee_function_minus_enum = 0xa6,
+ ieee_function_signed_open_b_enum = 0xba,
+ ieee_function_signed_close_b_enum = 0xbb,
+
+ ieee_function_unsigned_open_b_enum = 0xbc,
+ ieee_function_unsigned_close_b_enum = 0xbd,
+
+ ieee_function_either_open_b_enum = 0xbe,
+ ieee_function_either_close_b_enum = 0xbf,
+ ieee_record_seperator_enum = 0xdb,
+
+ ieee_e2_first_byte_enum = 0xe2,
+ ieee_section_size_enum = 0xe2d3,
+ ieee_physical_region_size_enum = 0xe2c1,
+ ieee_region_base_address_enum = 0xe2c2,
+ ieee_mau_size_enum = 0xe2c6,
+ ieee_m_value_enum = 0xe2cd,
+ ieee_section_base_address_enum = 0xe2cc,
+ ieee_asn_record_enum = 0xe2ce,
+ ieee_section_offset_enum = 0xe2d2,
+ ieee_value_starting_address_enum = 0xe2c7,
+ ieee_assign_value_to_variable_enum = 0xe2d7,
+ ieee_set_current_pc_enum = 0xe2d0,
+ ieee_value_record_enum = 0xe2c9,
+ ieee_nn_record = 0xf0,
+ ieee_at_record_enum = 0xf1,
+ ieee_ty_record_enum = 0xf2,
+ ieee_attribute_record_enum = 0xf1c9,
+ ieee_atn_record_enum = 0xf1ce,
+ ieee_external_reference_info_record_enum = 0xf1d8,
+ ieee_weak_external_reference_enum= 0xf4,
+ ieee_repeat_data_enum = 0xf7,
+ ieee_bb_record_enum = 0xf8,
+ ieee_be_record_enum = 0xf9
+} ieee_record_enum_type;
+
+
+typedef struct ieee_section {
+ unsigned int section_index;
+ unsigned int section_type;
+ char *section_name;
+ unsigned int parent_section_index;
+ unsigned int sibling_section_index;
+ unsigned int context_index;
+} ieee_section_type;
+#define IEEE_REFERENCE_BASE 11
+#define IEEE_PUBLIC_BASE 32
+#define IEEE_SECTION_NUMBER_BASE 1
+
diff --git a/include/libiberty.h b/include/libiberty.h
new file mode 100644
index 00000000000..cf313662ef4
--- /dev/null
+++ b/include/libiberty.h
@@ -0,0 +1,180 @@
+/* Function declarations for libiberty.
+ Written by Cygnus Support, 1994.
+
+ The libiberty library provides a number of functions which are
+ missing on some operating systems. We do not declare those here,
+ to avoid conflicts with the system header files on operating
+ systems that do support those functions. In this file we only
+ declare those functions which are specific to libiberty. */
+
+#ifndef LIBIBERTY_H
+#define LIBIBERTY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ansidecl.h"
+
+/* Build an argument vector from a string. Allocates memory using
+ malloc. Use freeargv to free the vector. */
+
+extern char **buildargv PARAMS ((char *));
+
+/* Free a vector returned by buildargv. */
+
+extern void freeargv PARAMS ((char **));
+
+/* Duplicate an argument vector. Allocates memory using malloc. Use
+ freeargv to free the vector. */
+
+extern char **dupargv PARAMS ((char **));
+
+
+/* Return the last component of a path name. Note that we can't use a
+ prototype here because the parameter is declared inconsistently
+ across different systems, sometimes as "char *" and sometimes as
+ "const char *" */
+
+#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__)
+extern char *basename PARAMS ((const char *));
+#else
+extern char *basename ();
+#endif
+
+/* Concatenate an arbitrary number of strings, up to (char *) NULL.
+ Allocates memory using xmalloc. */
+
+extern char *concat PARAMS ((const char *, ...));
+
+/* Check whether two file descriptors refer to the same file. */
+
+extern int fdmatch PARAMS ((int fd1, int fd2));
+
+/* Get the amount of time the process has run, in microseconds. */
+
+extern long get_run_time PARAMS ((void));
+
+/* Choose a temporary directory to use for scratch files. */
+
+extern char *choose_temp_base PARAMS ((void));
+
+/* Allocate memory filled with spaces. Allocates using malloc. */
+
+extern const char *spaces PARAMS ((int count));
+
+/* Return the maximum error number for which strerror will return a
+ string. */
+
+extern int errno_max PARAMS ((void));
+
+/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
+ "EINVAL"). */
+
+extern const char *strerrno PARAMS ((int));
+
+/* Given the name of an errno value, return the value. */
+
+extern int strtoerrno PARAMS ((const char *));
+
+/* ANSI's strerror(), but more robust. */
+
+extern char *xstrerror PARAMS ((int));
+
+/* Return the maximum signal number for which strsignal will return a
+ string. */
+
+extern int signo_max PARAMS ((void));
+
+/* Return a signal message string for a signal number
+ (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
+/* This is commented out as it can conflict with one in system headers.
+ We still document its existence though. */
+
+/*extern const char *strsignal PARAMS ((int));*/
+
+/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
+ "SIGHUP"). */
+
+extern const char *strsigno PARAMS ((int));
+
+/* Given the name of a signal, return its number. */
+
+extern int strtosigno PARAMS ((const char *));
+
+/* Register a function to be run by xexit. Returns 0 on success. */
+
+extern int xatexit PARAMS ((void (*fn) (void)));
+
+/* Exit, calling all the functions registered with xatexit. */
+
+#ifndef __GNUC__
+extern void xexit PARAMS ((int status));
+#else
+void xexit PARAMS ((int status)) __attribute__ ((noreturn));
+#endif
+
+/* Set the program name used by xmalloc. */
+
+extern void xmalloc_set_program_name PARAMS ((const char *));
+
+/* Allocate memory without fail. If malloc fails, this will print a
+ message to stderr (using the name set by xmalloc_set_program_name,
+ if any) and then call xexit. */
+
+#ifdef ANSI_PROTOTYPES
+/* Get a definition for size_t. */
+#include <stddef.h>
+#endif
+extern PTR xmalloc PARAMS ((size_t));
+
+/* Reallocate memory without fail. This works like xmalloc.
+
+ FIXME: We do not declare the parameter types for the same reason as
+ xmalloc. */
+
+extern PTR xrealloc PARAMS ((PTR, size_t));
+
+/* Allocate memory without fail and set it to zero. This works like
+ xmalloc. */
+
+extern PTR xcalloc PARAMS ((size_t, size_t));
+
+/* Copy a string into a memory buffer without fail. */
+
+extern char *xstrdup PARAMS ((const char *));
+
+/* hex character manipulation routines */
+
+#define _hex_array_size 256
+#define _hex_bad 99
+extern char _hex_value[_hex_array_size];
+extern void hex_init PARAMS ((void));
+#define hex_p(c) (hex_value (c) != _hex_bad)
+/* If you change this, note well: Some code relies on side effects in
+ the argument being performed exactly once. */
+#define hex_value(c) (_hex_value[(unsigned char) (c)])
+
+/* Definitions used by the pexecute routine. */
+
+#define PEXECUTE_FIRST 1
+#define PEXECUTE_LAST 2
+#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
+#define PEXECUTE_SEARCH 4
+#define PEXECUTE_VERBOSE 8
+
+/* Execute a program. */
+
+extern int pexecute PARAMS ((const char *, char * const *, const char *,
+ const char *, char **, char **, int));
+
+/* Wait for pexecute to finish. */
+
+extern int pwait PARAMS ((int, int *, int));
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* ! defined (LIBIBERTY_H) */
diff --git a/include/mpw/ChangeLog b/include/mpw/ChangeLog
new file mode 100644
index 00000000000..8dbad87eab4
--- /dev/null
+++ b/include/mpw/ChangeLog
@@ -0,0 +1,61 @@
+Tue Feb 27 12:23:04 1996 Raymond Jou <rjou@mexican.cygnus.com>
+
+ * mpw.h (HAVE_VPRINTF): Add and define to have the value 1.
+
+Fri Dec 29 14:40:46 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.h (HAVE_STDLIB_H, etc): Define to have the value 1.
+ (HAVE_FCNTL_H): Define.
+
+Mon Dec 11 15:39:06 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.h (open, access): Define as mpw_open and mpw_access.
+
+Thu Nov 9 15:38:37 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.h: Include unix.h if USE_MW_HEADERS, otherwise include
+ various original MPW include files (ioctl.h, etc).
+ (EIO): Define if not defined.
+ * sys/ioctl.h: Remove, not needed.
+
+Wed Oct 25 12:30:44 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.h: Don't include errno.h or ioctl.h.
+ (ENOENT, EACCES, ENOSYS): Define if not defined.
+ (fdopen): Declare if __STDC__.
+ (R_OK, W_OK, X_OK): Define if not defined.
+
+Tue Sep 26 14:57:21 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.h: New file, universally useful MPW host definitions.
+ Many of these used to live in bfd/hosts/mpw.h.
+ * grp.h: Remove RCS comment.
+ * sys/ioctl.h: Add a comment line.
+
+Wed Dec 14 13:12:14 1994 Stan Shebs <shebs@andros.cygnus.com>
+
+ * spin.h: New file, cursor spinning for progress.
+
+Thu Jun 30 15:32:07 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * fcntl.h (open): Allow optional third arg.
+
+Thu Apr 14 12:54:51 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * dir.h, dirent.h, fcntl.h, grp.h, pwd.h, stat.h: New files.
+ * sys/ioctl.h: New file.
+
+Mon Feb 21 09:44:45 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * sys/stat.h (struct stat): New field st_rsize.
+ (S_IFMT, etc): Use different bit positions.
+ (fstat): Add parameter names to prototype.
+
+Mon Jan 31 19:30:16 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * README: New file.
+ * utime.h, varargs.h: New files, simulated Posix.
+ * sys/{file,param,resource,stat,time,types}.h: New files, more
+ simulated Posix.
+
+
diff --git a/include/mpw/README b/include/mpw/README
new file mode 100644
index 00000000000..10e92de79f6
--- /dev/null
+++ b/include/mpw/README
@@ -0,0 +1 @@
+This is a collection of include files that help imitate Posix in MPW.
diff --git a/include/mpw/dir.h b/include/mpw/dir.h
new file mode 100644
index 00000000000..e6ccd2d5922
--- /dev/null
+++ b/include/mpw/dir.h
@@ -0,0 +1,23 @@
+/* The <dir.h> header gives the layout of a directory. */
+
+#pragma once
+
+#ifndef _DIR_H
+#define _DIR_H
+
+#ifndef _TYPES_H /* not quite right */
+#include <sys/types.h>
+#endif
+
+#define DIRBLKSIZ 512 /* size of directory block */
+
+#ifndef DIRSIZ
+#define DIRSIZ 14
+#endif
+
+struct direct {
+ ino_t d_ino;
+ char d_name[DIRSIZ];
+};
+
+#endif /* _DIR_H */
diff --git a/include/mpw/dirent.h b/include/mpw/dirent.h
new file mode 100644
index 00000000000..38000b2c5f3
--- /dev/null
+++ b/include/mpw/dirent.h
@@ -0,0 +1,31 @@
+#ifndef __dirent_h
+#define __dirent_h
+
+#include "sys/dir.h"
+
+struct dirent {
+ long d_ino; /* inode number of entry */
+ off_t d_off; /* offset of disk directory entry */
+ unsigned short d_reclen; /* length of this record */
+ char d_name[1]; /* name of file */
+};
+
+/*
+#define DIRENTBASESIZE \
+ (((struct dirent *) 0)->d_name - (char *) 0)
+#define DIRENTSIZE(namelen) \
+ ((DIRENTBASESIZE + (namelen) + NBPW) & ~(NBPW - 1))
+*/
+
+/* from Mips posix/dirent.h */
+
+/*
+#undef rewinddir
+*/
+
+extern DIR *opendir();
+extern struct dirent *readdir();
+extern void rewinddir();
+extern int closedir();
+
+#endif /* ! __dirent_h */
diff --git a/include/mpw/fcntl.h b/include/mpw/fcntl.h
new file mode 100644
index 00000000000..30999b4b17d
--- /dev/null
+++ b/include/mpw/fcntl.h
@@ -0,0 +1,124 @@
+/*
+ * FCntl.h -- faccess(), fcntl(), and open() mode flags
+ *
+ * Portions copyright American Telephone & Telegraph
+ * Used with permission, Apple Computer Inc. (1985,1988,1990,1992)
+ * All rights reserved.
+ */
+
+#ifndef __FCNTL__
+#define __FCNTL__
+
+#ifndef __TYPES__
+#include <Types.h>
+#endif
+
+/*
+ * For use by lseek():
+ */
+
+#ifndef __STDIO__ /* these defns exactly paralled in StdIO.h for fseek() */
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define SEEK_SET 0
+#endif
+
+/*
+ * faccess() commands; for general use
+ */
+ /* 'd' => "directory" ops */
+#define F_DELETE (('d'<<8)|0x01)
+#define F_RENAME (('d'<<8)|0x02)
+
+/*
+ * more faccess() commands; for use only by MPW tools
+ */
+
+#define F_OPEN (('d'<<8)|0x00) /* reserved for operating system use */
+ /* 'e' => "editor" ops */
+#define F_GTABINFO (('e'<<8)|0x00) /* get tab offset for file */
+#define F_STABINFO (('e'<<8)|0x01) /* set " " " " */
+#define F_GFONTINFO (('e'<<8)|0x02) /* get font number and size for file */
+#define F_SFONTINFO (('e'<<8)|0x03) /* set " " " " " " */
+#define F_GPRINTREC (('e'<<8)|0x04) /* get print record for file */
+#define F_SPRINTREC (('e'<<8)|0x05) /* set " " " " */
+#define F_GSELINFO (('e'<<8)|0x06) /* get selection information for file */
+#define F_SSELINFO (('e'<<8)|0x07) /* set " " " " */
+#define F_GWININFO (('e'<<8)|0x08) /* get current window position */
+#define F_SWININFO (('e'<<8)|0x09) /* set " " " */
+#define F_GSCROLLINFO (('e'<<8)|0x0A) /* get scroll information */
+#define F_SSCROLLINFO (('e'<<8)|0x0B) /* set " " */
+#define F_GMARKER (('e'<<8)|0x0D) /* Get Marker */
+#define F_SMARKER (('e'<<8)|0x0C) /* Set " */
+#define F_GSAVEONCLOSE (('e'<<8)|0x0F) /* Get Save on close */
+#define F_SSAVEONCLOSE (('e'<<8)|0x0E) /* Set " " " */
+
+/*
+ * argument structures used by various faccess() commands
+ */
+
+struct MarkElement {
+ int start; /* start position of mark */
+ int end; /* end position */
+ unsigned char charCount; /* number of chars in mark name */
+ char name[64]; /* mark name */
+} ; /* note: marker names may be up to 64 characters long */
+
+#ifndef __cplusplus
+typedef struct MarkElement MarkElement;
+#endif
+
+struct SelectionRecord {
+ long startingPos;
+ long endingPos;
+ long displayTop;
+};
+
+#ifndef __cplusplus
+typedef struct SelectionRecord SelectionRecord;
+#endif
+
+
+/*
+ * Mode values accessible to open()
+ */
+#define O_RDONLY 0 /* Bits 0 and 1 are used internally */
+#define O_WRONLY 1 /* Values 0..2 are historical */
+#define O_RDWR 2 /* NOTE: it goes 0, 1, 2, *!* 8, 16, 32, ... */
+#define O_APPEND (1<< 3) /* append (writes guaranteed at the end) */
+#define O_RSRC (1<< 4) /* Open the resource fork */
+#define O_ALIAS (1<< 5) /* Open alias file */
+#define O_CREAT (1<< 8) /* Open with file create */
+#define O_TRUNC (1<< 9) /* Open with truncation */
+#define O_EXCL (1<<10) /* w/ O_CREAT: Exclusive "create-only" */
+#define O_BINARY (1<<11) /* Open as a binary stream */
+#define O_NRESOLVE (1<<14) /* Don't resolve any aliases */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * function prototypes
+ */
+int close(int);
+int creat(const char*);
+int dup(int filedes); /* OBSOLETE: fcntl(filedes, F_DUPFD, 0) is preferred */
+int faccess(char*, unsigned int, long*);
+int fcntl(int, unsigned int, int);
+long lseek(int, long, int);
+int open(const char*, int, ...);
+int read(int, char*, unsigned);
+int unlink(char*);
+int write(int, const char*, unsigned);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * fcntl() commands
+ */
+#define F_DUPFD 0 /* Duplicate files (file descriptor) */
+
+#endif __FCNTL__
diff --git a/include/mpw/grp.h b/include/mpw/grp.h
new file mode 100644
index 00000000000..faf2c6a6be9
--- /dev/null
+++ b/include/mpw/grp.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include "sys/types.h"
+
+struct group {
+ char *gr_name;
+ gid_t gr_gid;
+ char *gr_passwd;
+ char **gr_mem;
+};
diff --git a/include/mpw/mpw.h b/include/mpw/mpw.h
new file mode 100644
index 00000000000..58702e725ff
--- /dev/null
+++ b/include/mpw/mpw.h
@@ -0,0 +1,130 @@
+/* Mac MPW host-specific definitions. */
+
+#ifndef __INCLUDE_MPW_H
+#define __INCLUDE_MPW_H
+
+#ifndef MPW
+#define MPW
+#endif
+
+/* MPW C is basically ANSI, but doesn't actually enable __STDC__,
+ nor does it allow __STDC__ to be #defined. */
+
+#ifndef ALMOST_STDC
+#define ALMOST_STDC
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+
+#define HAVE_TIME_T_IN_TIME_H 1
+
+#define HAVE_STDLIB_H 1
+
+#define HAVE_ERRNO_H 1
+
+#define HAVE_STDDEF_H 1
+
+#define HAVE_STRING_H 1
+
+#define HAVE_STDARG_H 1
+
+#define HAVE_VPRINTF 1
+
+#ifdef USE_MW_HEADERS
+
+#include <unix.h>
+
+#else
+
+#include <fcntl.h>
+#include <ioctl.h>
+#include <sys/stat.h>
+
+#define HAVE_FCNTL_H 1
+
+#ifndef O_ACCMODE
+#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+#endif
+
+#ifndef fileno
+#define fileno(fp) ((fp)->_file)
+#endif
+
+/* stdio.h does not define this if __STDC__, so define here. */
+
+#ifdef __STDC__
+FILE *fdopen(int fildes, const char *mode);
+#endif
+
+#endif /* USE_MW_HEADERS */
+
+/* Add ersatz definitions, for systems that lack them. */
+
+#ifndef EIO
+#define EIO 96
+#endif
+#ifndef ENOENT
+#define ENOENT 97
+#endif
+#ifndef EACCES
+#define EACCES 98
+#endif
+#ifndef ENOSYS
+#define ENOSYS 99
+#endif
+
+#ifndef R_OK
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#endif
+
+/* Binary files have different characteristics; for instance, no cr/nl
+ translation. */
+
+#define USE_BINARY_FOPEN
+
+#include <spin.h>
+
+#ifdef MPW_C
+#undef __PTR_TO_INT
+#define __PTR_TO_INT(P) ((int)(P))
+#undef __INT_TO_PTR
+#define __INT_TO_PTR(P) ((char *)(P))
+#endif /* MPW_C */
+
+#define NO_FCNTL
+
+int fstat ();
+
+FILE *mpw_fopen ();
+int mpw_fseek ();
+int mpw_fread ();
+int mpw_fwrite ();
+int mpw_access ();
+int mpw_open ();
+int mpw_creat ();
+void mpw_abort (void);
+
+/* Map these standard functions to improved versions in libiberty. */
+
+#define fopen mpw_fopen
+#define fseek mpw_fseek
+#define fread mpw_fread
+#define fwrite mpw_fwrite
+#define open mpw_open
+#define access mpw_access
+#define creat mpw_creat
+#define abort mpw_abort
+
+#define POSIX_UTIME
+
+#define LOSING_TOTALLY
+
+/* Define this so that files will be closed before being unlinked. */
+
+#define CLOSE_BEFORE_UNLINK
+
+#endif /* __INCLUDE_MPW_H */
diff --git a/include/mpw/pwd.h b/include/mpw/pwd.h
new file mode 100644
index 00000000000..2d4fb70401a
--- /dev/null
+++ b/include/mpw/pwd.h
@@ -0,0 +1,15 @@
+#ifndef __pwd_h
+#define __pwd_h
+
+#include <sys/types.h>
+
+struct passwd {
+ char *pw_name;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ char *pw_dir;
+ char *pw_shell;
+ char *pw_passwd;
+};
+
+#endif /* ! __pwd_h */
diff --git a/include/mpw/spin.h b/include/mpw/spin.h
new file mode 100644
index 00000000000..867d14502c0
--- /dev/null
+++ b/include/mpw/spin.h
@@ -0,0 +1,64 @@
+/* Progress macros that use SpinCursor in MPW.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _SPIN_H
+#define _SPIN_H
+
+/* For MPW, progress macros just need to "spin the cursor" frequently,
+ preferably several times per second on a 68K Mac. */
+
+/* In order to determine if we're meeting the goal, define this macro
+ and information about frequency of spinning will be collected and
+ displayed. */
+
+#define SPIN_MEASUREMENT
+
+#include <CursorCtl.h>
+
+/* Programs use this macro to indicate the start of a lengthy
+ activity. STR identifies the particular activity, while N
+ indicates the expected duration, in unspecified units. If N is
+ zero, then the expected time to completion is unknown. */
+
+#undef START_PROGRESS
+#define START_PROGRESS(STR,N) mpw_start_progress (STR, N, __FILE__, __LINE__);
+
+/* Programs use this macro to indicate that progress has been made on a
+ lengthy activity. */
+
+#undef PROGRESS
+#ifdef SPIN_MEASUREMENT
+#define PROGRESS(X) mpw_progress_measured (X, __FILE__, __LINE__);
+#else
+#define PROGRESS(X) mpw_progress (X);
+#endif
+
+/* Programs use this macro to indicate the end of a lengthy activity.
+ STR must match a STR passed to START_PROGRESS previously. */
+
+#undef END_PROGRESS
+#define END_PROGRESS(STR) mpw_end_progress (STR, __FILE__, __LINE__);
+
+extern void mpw_start_progress (char *, int, char *, int);
+
+extern void mpw_progress (int);
+
+extern void mpw_progress_measured (int, char *, int);
+
+extern void mpw_end_progress (char *, char *, int);
+
+#endif /* _SPIN_H */
diff --git a/include/mpw/stat.h b/include/mpw/stat.h
new file mode 100644
index 00000000000..057b8d53113
--- /dev/null
+++ b/include/mpw/stat.h
@@ -0,0 +1,75 @@
+/* The <sys/stat.h> header defines a struct that is used in the stat() and
+ * fstat functions. The information in this struct comes from the i-node of
+ * some file. These calls are the only approved way to inspect i-nodes.
+ */
+
+#ifndef _STAT_H
+#define _STAT_H
+
+#ifndef _TYPES_H /* not quite right */
+#include <sys/types.h>
+#endif
+
+struct stat {
+ dev_t st_dev; /* major/minor device number */
+ ino_t st_ino; /* i-node number */
+ mode_t st_mode; /* file mode, protection bits, etc. */
+ short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/
+ uid_t st_uid; /* uid of the file's owner */
+ short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
+ dev_t st_rdev;
+ off_t st_size; /* file size */
+ time_t st_atime; /* time of last access */
+ time_t st_mtime; /* time of last data modification */
+ time_t st_ctime; /* time of last file status change */
+};
+
+/* Traditional mask definitions for st_mode. */
+#define S_IFMT 0170000 /* type of file */
+#define S_IFREG 0100000 /* regular */
+#define S_IFBLK 0060000 /* block special */
+#define S_IFDIR 0040000 /* directory */
+#define S_IFCHR 0020000 /* character special */
+#define S_IFIFO 0010000 /* this is a FIFO */
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+ /* next is reserved for future use */
+#define S_ISVTX 01000 /* save swapped text even after use */
+
+/* POSIX masks for st_mode. */
+#define S_IRWXU 00700 /* owner: rwx------ */
+#define S_IRUSR 00400 /* owner: r-------- */
+#define S_IWUSR 00200 /* owner: -w------- */
+#define S_IXUSR 00100 /* owner: --x------ */
+
+#define S_IRWXG 00070 /* group: ---rwx--- */
+#define S_IRGRP 00040 /* group: ---r----- */
+#define S_IWGRP 00020 /* group: ----w---- */
+#define S_IXGRP 00010 /* group: -----x--- */
+
+#define S_IRWXO 00007 /* others: ------rwx */
+#define S_IROTH 00004 /* others: ------r-- */
+#define S_IWOTH 00002 /* others: -------w- */
+#define S_IXOTH 00001 /* others: --------x */
+
+/* The following macros test st_mode (from POSIX Sec. 5.6.1.1. */
+#define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* is a reg file */
+#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */
+#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* is a char spec */
+#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* is a block spec */
+#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */
+
+
+/* Function Prototypes. */
+#ifndef _ANSI_H
+#include <ansi.h>
+#endif
+
+_PROTOTYPE( int chmod, (const char *_path, int _mode) );
+_PROTOTYPE( int fstat, (int _fildes, struct stat *_buf) );
+_PROTOTYPE( int mkdir, (const char *_path, int _mode) );
+_PROTOTYPE( int mkfifo, (const char *_path, int _mode) );
+_PROTOTYPE( int stat , (const char *_path, struct stat *_buf) );
+_PROTOTYPE( mode_t umask, (int _cmask) );
+
+#endif /* _STAT_H */
diff --git a/include/mpw/sys/file.h b/include/mpw/sys/file.h
new file mode 100644
index 00000000000..40a8c178f10
--- /dev/null
+++ b/include/mpw/sys/file.h
@@ -0,0 +1 @@
+/* empty */
diff --git a/include/mpw/sys/param.h b/include/mpw/sys/param.h
new file mode 100644
index 00000000000..40a8c178f10
--- /dev/null
+++ b/include/mpw/sys/param.h
@@ -0,0 +1 @@
+/* empty */
diff --git a/include/mpw/sys/resource.h b/include/mpw/sys/resource.h
new file mode 100644
index 00000000000..d39439d61d5
--- /dev/null
+++ b/include/mpw/sys/resource.h
@@ -0,0 +1,9 @@
+#ifndef __SYS_RESOURCE_H__
+#define __SYS_RESOURCE_H__
+
+struct rusage {
+ struct timeval ru_utime;
+ struct timeval ru_stime;
+};
+
+#endif /* __SYS_RESOURCE_H__ */
diff --git a/include/mpw/sys/stat.h b/include/mpw/sys/stat.h
new file mode 100644
index 00000000000..b65c72e10c6
--- /dev/null
+++ b/include/mpw/sys/stat.h
@@ -0,0 +1,44 @@
+/* Imitation sys/stat.h. */
+
+#ifndef __SYS_STAT_H__
+#define __SYS_STAT_H__
+
+#include <sys/types.h>
+#include <time.h>
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ short st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ off_t st_rsize;
+ time_t st_atime;
+ int st_spare1;
+ time_t st_mtime;
+ int st_spare2;
+ time_t st_ctime;
+ int st_spare3;
+ long st_blksize;
+ long st_blocks;
+ long st_spare4[2];
+};
+
+#define S_IFMT 0170000L
+#define S_IFDIR 0040000L
+#define S_IFREG 0100000L
+#define S_IREAD 0400
+#define S_IWRITE 0200
+#define S_IEXEC 0100
+
+#define S_IFIFO 010000 /* FIFO special */
+#define S_IFCHR 020000 /* character special */
+#define S_IFBLK 030000 /* block special */
+
+int stat (char *path, struct stat *buf);
+int fstat (int fd, struct stat *buf);
+
+#endif /* __SYS_STAT_H___ */
diff --git a/include/mpw/sys/time.h b/include/mpw/sys/time.h
new file mode 100644
index 00000000000..f9e485232a2
--- /dev/null
+++ b/include/mpw/sys/time.h
@@ -0,0 +1,13 @@
+/* Imitation sys/time.h. */
+
+#ifndef __SYS_TIME_H__
+#define __SYS_TIME_H__
+
+#include <time.h>
+
+struct timeval {
+ long tv_sec;
+ long tv_usec;
+};
+
+#endif /* __SYS_TIME_H__ */
diff --git a/include/mpw/sys/types.h b/include/mpw/sys/types.h
new file mode 100644
index 00000000000..d7d9c9f44ba
--- /dev/null
+++ b/include/mpw/sys/types.h
@@ -0,0 +1,15 @@
+/* Imitation sys/types.h. */
+
+#ifndef __SYS_TYPES_H__
+#define __SYS_TYPES_H__
+
+#include <Types.h>
+
+typedef short dev_t;
+typedef short ino_t;
+typedef unsigned short mode_t;
+typedef unsigned short uid_t;
+typedef unsigned short gid_t;
+typedef long off_t;
+
+#endif /* __SYS_TYPES_H__ */
diff --git a/include/mpw/utime.h b/include/mpw/utime.h
new file mode 100644
index 00000000000..e8bf66f2ba5
--- /dev/null
+++ b/include/mpw/utime.h
@@ -0,0 +1,7 @@
+
+struct utimbuf {
+ time_t actime;
+ time_t modtime;
+};
+
+int utime (char *, struct utimbuf *);
diff --git a/include/mpw/varargs.h b/include/mpw/varargs.h
new file mode 100644
index 00000000000..acb9e4504a2
--- /dev/null
+++ b/include/mpw/varargs.h
@@ -0,0 +1,9 @@
+/* varargs.h. */
+#ifndef __va_list__
+#define __va_list__
+typedef char *va_list;
+#endif
+#define va_dcl int va_alist;
+#define va_start(list) list = (char *) &va_alist
+#define va_end(list)
+#define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1]
diff --git a/include/nlm/ChangeLog b/include/nlm/ChangeLog
new file mode 100644
index 00000000000..d9ea3d09e0a
--- /dev/null
+++ b/include/nlm/ChangeLog
@@ -0,0 +1,83 @@
+Fri May 6 13:31:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * external.h (nlmNAME(External_Custom_Header)): Add length,
+ dataOffset, and dataStamp field.
+ (nlmNAME(External_Cygnus_Ext_Header)): Remove.
+ * internal.h (Nlm_Internal_Custom_Header): Add hdrLength,
+ dataOffset, dataStamp and hdr fields.
+
+Fri Apr 22 11:12:39 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * external.h (struct nlmNAME(external_cygnus_ext_header)): Rename
+ from nlmNAME(external_cygnus_section_header). Change stamp field
+ to 8 bytes. Add bytes field.
+ * internal.h (nlm_internal_cygnus_ext_header): Rename from
+ nlm_internal_cygnus_section_header. Change stamp field to 8
+ bytes.
+
+Thu Apr 21 11:57:09 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * internal.h (struct nlm_internal_cygnus_section_header): Define.
+ * external.h (struct nlmNAME(external_cygnus_section_header):
+ Define.
+
+Wed Apr 20 14:27:43 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * internal.h (struct nlm_internal_custom_header): Remove
+ debugRecOffset and debugRecLength fields. Add data field.
+ * external.h (struct nlmNAME(external_custom_header)): Remove
+ debugRecOffset and debugRecLength fields.
+
+Mon Feb 7 08:28:40 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * internal.h: Change HOST_64_BIT to BFD_HOST_64_BIT.
+
+Thu Dec 2 14:14:48 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * alpha-ext.h: New file describing formats of information in Alpha
+ NetWare files.
+ * common.h: Define some non-external Alpha information.
+
+Wed Nov 17 17:38:58 1993 Sean Eric Fagan (sef@cygnus.com)
+
+ * external.h: Don't define external_fixed_header here.
+ * i386-ext.h, sparc32-ext.h: New header files to define
+ external_fixed_header for particular CPU's.
+
+Wed Oct 27 11:45:56 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * internal.h (Nlm_Internal_Extended_Header): Added fields
+ sharedDebugRecordOffset and sharedDebugRecordCount.
+ * external.h (NlmNAME(External_Extended_Header)): Likewise.
+
+ * common.h (NLM_SIGNATURE): Do not define (it's different for each
+ backend).
+
+Tue Aug 31 13:24:15 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * internal.h: Change length fields of type char to type unsigned
+ char.
+
+Sat Jul 31 02:12:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * common.h (NLM_HIBIT, NLM_HEADER_VERSION): Define.
+
+Thu Jul 22 16:09:47 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * common.h (NLM_CAT*, NLM_ARCH_SIZE, NLM_TARGET_LONG_SIZE,
+ NLM_TARGET_ADDRESS_SIZE, NLM_NAME, NlmNAME, nlmNAME): New
+ macros.
+ * external.h (TARGET_LONG_SIZE, TARGET_ADDRESS_SIZE): Remove
+ macros, convert usages to NLM_ equivalents.
+ * external.h: Use nlmNAME and NlmNAME macros to derive both
+ 32 and 64 bit versions.
+
+Mon Jul 19 22:12:40 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * (common.h, external.h, internal.h): New files for NLM/NetWare
+ support.
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/include/nlm/alpha-ext.h b/include/nlm/alpha-ext.h
new file mode 100644
index 00000000000..37199dd1dc0
--- /dev/null
+++ b/include/nlm/alpha-ext.h
@@ -0,0 +1,166 @@
+/* Alpha NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+ 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 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* An Alpha NLM starts with an instance of this structure. */
+
+struct nlm32_alpha_external_prefix_header
+{
+ /* Magic number. Must be NLM32_ALPHA_MAGIC. */
+ unsigned char magic[4];
+ /* Format descriptor. Current value is 2. */
+ unsigned char format[4];
+ /* Size of prefix header. */
+ unsigned char size[4];
+ /* Padding. */
+ unsigned char pad1[4];
+ /* More fields may be added later, supposedly. */
+};
+
+/* The external format of an Alpha NLM reloc. This is the same as an
+ Alpha ECOFF reloc. */
+
+struct nlm32_alpha_external_reloc
+{
+ unsigned char r_vaddr[8];
+ unsigned char r_symndx[4];
+ unsigned char r_bits[4];
+};
+
+/* Constants to unpack the r_bits field of a reloc. */
+
+#define RELOC_BITS0_TYPE_LITTLE 0xff
+#define RELOC_BITS0_TYPE_SH_LITTLE 0
+
+#define RELOC_BITS1_EXTERN_LITTLE 0x01
+
+#define RELOC_BITS1_OFFSET_LITTLE 0x7e
+#define RELOC_BITS1_OFFSET_SH_LITTLE 1
+
+#define RELOC_BITS1_RESERVED_LITTLE 0x80
+#define RELOC_BITS1_RESERVED_SH_LITTLE 7
+#define RELOC_BITS2_RESERVED_LITTLE 0xff
+#define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE 1
+#define RELOC_BITS3_RESERVED_LITTLE 0x03
+#define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE 9
+
+#define RELOC_BITS3_SIZE_LITTLE 0xfc
+#define RELOC_BITS3_SIZE_SH_LITTLE 2
+
+/* The external format of the fixed header. */
+
+typedef struct nlm32_alpha_external_fixed_header
+{
+
+ /* The signature field identifies the file as an NLM. It must contain
+ the signature string, which depends upon the NLM target. */
+
+ unsigned char signature[24];
+
+ /* The version of the header. At this time, the highest version number
+ is 4. */
+
+ unsigned char version[4];
+
+ /* The name of the module, which must be a DOS name (1-8 characters followed
+ by a period and a 1-3 character extension). The first byte is the byte
+ length of the name and the last byte is a null terminator byte. This
+ field is fixed length, and any unused bytes should be null bytes. The
+ value is set by the OUTPUT keyword to NLMLINK. */
+
+ unsigned char moduleName[14];
+
+ /* Padding to make it come out correct. */
+
+ unsigned char pad1[2];
+
+ /* The byte offset of the code image from the start of the file. */
+
+ unsigned char codeImageOffset[4];
+
+ /* The size of the code image, in bytes. */
+
+ unsigned char codeImageSize[4];
+
+ /* The byte offset of the data image from the start of the file. */
+
+ unsigned char dataImageOffset[4];
+
+ /* The size of the data image, in bytes. */
+
+ unsigned char dataImageSize[4];
+
+ /* The size of the uninitialized data region that the loader is to be
+ allocated at load time. Uninitialized data follows the initialized
+ data in the NLM address space. */
+
+ unsigned char uninitializedDataSize[4];
+
+ /* The byte offset of the custom data from the start of the file. The
+ custom data is set by the CUSTOM keyword to NLMLINK. It is possible
+ for this to be EOF if there is no custom data. */
+
+ unsigned char customDataOffset[4];
+
+ /* The size of the custom data, in bytes. */
+
+ unsigned char customDataSize[4];
+
+ /* The byte offset of the module dependencies from the start of the file.
+ The module dependencies are determined by the MODULE keyword in
+ NLMLINK. */
+
+ unsigned char moduleDependencyOffset[4];
+
+ /* The number of module dependencies at the moduleDependencyOffset. */
+
+ unsigned char numberOfModuleDependencies[4];
+
+ /* The byte offset of the relocation fixup data from the start of the file */
+
+ unsigned char relocationFixupOffset[4];
+
+ unsigned char numberOfRelocationFixups[4];
+
+ unsigned char externalReferencesOffset[4];
+
+ unsigned char numberOfExternalReferences[4];
+
+ unsigned char publicsOffset[4];
+
+ unsigned char numberOfPublics[4];
+
+ /* The byte offset of the internal debug info from the start of the file.
+ It is possible for this to be EOF if there is no debug info. */
+
+ unsigned char debugInfoOffset[4];
+
+ unsigned char numberOfDebugRecords[4];
+
+ unsigned char codeStartOffset[4];
+
+ unsigned char exitProcedureOffset[4];
+
+ unsigned char checkUnloadProcedureOffset[4];
+
+ unsigned char moduleType[4];
+
+ unsigned char flags[4];
+
+} Nlm32_alpha_External_Fixed_Header;
diff --git a/include/nlm/common.h b/include/nlm/common.h
new file mode 100644
index 00000000000..e96550a92f6
--- /dev/null
+++ b/include/nlm/common.h
@@ -0,0 +1,124 @@
+/* NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of NLM support for BFD, and contains the portions
+ that are common to both the internal and external representations. */
+
+/* Semi-portable string concatenation in cpp.
+ The NLM_CAT4 hack is to avoid a problem with some strict ANSI C
+ preprocessors. The problem is, "32_" or "64_" are not a valid
+ preprocessing tokens, and we don't want extra underscores (e.g.,
+ "nlm_32_"). The XNLM_CAT2 macro will cause the inner NLM_CAT macros
+ to be evaluated first, producing still-valid pp-tokens. Then the
+ final concatenation can be done. (Sigh.) */
+
+#ifdef SABER
+# define NLM_CAT(a,b) a##b
+# define NLM_CAT3(a,b,c) a##b##c
+# define NLM_CAT4(a,b,c,d) a##b##c##d
+#else
+# ifdef __STDC__
+# define NLM_CAT(a,b) a##b
+# define NLM_CAT3(a,b,c) a##b##c
+# define XNLM_CAT2(a,b) NLM_CAT(a,b)
+# define NLM_CAT4(a,b,c,d) XNLM_CAT2(NLM_CAT(a,b),NLM_CAT(c,d))
+# else
+# define NLM_CAT(a,b) a/**/b
+# define NLM_CAT3(a,b,c) a/**/b/**/c
+# define NLM_CAT4(a,b,c,d) a/**/b/**/c/**/d
+# endif
+#endif
+
+/* If NLM_ARCH_SIZE is not defined, default to 32. NLM_ARCH_SIZE is
+ optionally defined by the application. */
+
+#ifndef NLM_ARCH_SIZE
+# define NLM_ARCH_SIZE 32
+#endif
+
+#if NLM_ARCH_SIZE == 32
+# define NLM_TARGET_LONG_SIZE 4
+# define NLM_TARGET_ADDRESS_SIZE 4
+# define NLM_NAME(x,y) NLM_CAT4(x,32,_,y)
+# define NLM_HIBIT (((bfd_vma) 1) << 31)
+#endif
+#if NLM_ARCH_SIZE == 64
+# define NLM_TARGET_LONG_SIZE 8
+# define NLM_TARGET_ADDRESS_SIZE 8
+# define NLM_NAME(x,y) NLM_CAT4(x,64,_,y)
+# define NLM_HIBIT (((bfd_vma) 1) << 63)
+#endif
+
+#define NlmNAME(X) NLM_NAME(Nlm,X)
+#define nlmNAME(X) NLM_NAME(nlm,X)
+
+/* Give names to things that should not change. */
+
+#define NLM_MAX_DESCRIPTION_LENGTH 127
+#define NLM_MAX_SCREEN_NAME_LENGTH 71
+#define NLM_MAX_THREAD_NAME_LENGTH 71
+#define NLM_MAX_COPYRIGHT_MESSAGE_LENGTH 255
+#define NLM_OTHER_DATA_LENGTH 400 /* FIXME */
+#define NLM_OLD_THREAD_NAME_LENGTH 5
+#define NLM_SIGNATURE_SIZE 24
+#define NLM_HEADER_VERSION 4
+#define NLM_MODULE_NAME_SIZE 14
+#define NLM_DEFAULT_STACKSIZE (8 * 1024)
+
+/* Alpha information. This should probably be in a separate Alpha
+ header file, but it can't go in alpha-ext.h because some of it is
+ needed by nlmconv.c. */
+
+/* Magic number in Alpha prefix header. */
+#define NLM32_ALPHA_MAGIC (0x83561840)
+
+/* The r_type field in an Alpha reloc is one of the following values. */
+#define ALPHA_R_IGNORE 0
+#define ALPHA_R_REFLONG 1
+#define ALPHA_R_REFQUAD 2
+#define ALPHA_R_GPREL32 3
+#define ALPHA_R_LITERAL 4
+#define ALPHA_R_LITUSE 5
+#define ALPHA_R_GPDISP 6
+#define ALPHA_R_BRADDR 7
+#define ALPHA_R_HINT 8
+#define ALPHA_R_SREL16 9
+#define ALPHA_R_SREL32 10
+#define ALPHA_R_SREL64 11
+#define ALPHA_R_OP_PUSH 12
+#define ALPHA_R_OP_STORE 13
+#define ALPHA_R_OP_PSUB 14
+#define ALPHA_R_OP_PRSHIFT 15
+#define ALPHA_R_GPVALUE 16
+#define ALPHA_R_NW_RELOC 250
+
+/* A local reloc, other than ALPHA_R_GPDISP or ALPHA_R_IGNORE, must be
+ against one of these symbol indices. */
+#define ALPHA_RELOC_SECTION_TEXT 1
+#define ALPHA_RELOC_SECTION_DATA 3
+
+/* An ALPHA_R_NW_RELOC has one of these values in the size field. If
+ it is SETGP, the r_vaddr field holds the GP value to use. If it is
+ LITA, the r_vaddr field holds the address of the .lita section and
+ the r_symndx field holds the size of the .lita section. */
+#define ALPHA_R_NW_RELOC_SETGP 1
+#define ALPHA_R_NW_RELOC_LITA 2
diff --git a/include/nlm/external.h b/include/nlm/external.h
new file mode 100644
index 00000000000..f77a5bb3dda
--- /dev/null
+++ b/include/nlm/external.h
@@ -0,0 +1,174 @@
+/* NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of NLM support for BFD, and contains the portions
+ that describe how NLM is represented externally by the BFD library.
+ I.E. it describes the in-file representation of NLM. It requires
+ the nlm/common.h file which contains the portions that are common to
+ both the internal and external representations.
+
+ Note that an NLM header consists of three parts:
+
+ (1) A fixed length header that has specific fields of known length,
+ at specific offsets in the file.
+
+ (2) A variable length header that has specific fields in a specific
+ order, but some fields may be variable length.
+
+ (3) A auxiliary header that has various optional fields in no specific
+ order. There is no way to identify the end of the auxiliary headers
+ except by finding a header without a recognized 'stamp'.
+
+ The exact format of the fixed length header unfortunately varies
+ from one NLM target to another, due to padding. Each target
+ defines the correct external format in a separate header file.
+
+*/
+
+/* NLM Header */
+
+/* The version header is one of the optional auxiliary headers and
+ follows the fixed length and variable length NLM headers. */
+
+typedef struct nlmNAME(external_version_header)
+{
+
+ /* The header is recognized by "VeRsIoN#" in the stamp field. */
+ char stamp[8];
+
+ unsigned char majorVersion[NLM_TARGET_LONG_SIZE];
+
+ unsigned char minorVersion[NLM_TARGET_LONG_SIZE];
+
+ unsigned char revision[NLM_TARGET_LONG_SIZE];
+
+ unsigned char year[NLM_TARGET_LONG_SIZE];
+
+ unsigned char month[NLM_TARGET_LONG_SIZE];
+
+ unsigned char day[NLM_TARGET_LONG_SIZE];
+
+} NlmNAME(External_Version_Header);
+
+
+typedef struct nlmNAME(external_copyright_header)
+{
+
+ /* The header is recognized by "CoPyRiGhT=" in the stamp field. */
+
+ char stamp[10];
+
+ unsigned char copyrightMessageLength[1];
+
+ /* There is a variable length field here called 'copyrightMessage'
+ that is the length specified by copyrightMessageLength. */
+
+} NlmNAME(External_Copyright_Header);
+
+
+typedef struct nlmNAME(external_extended_header)
+{
+
+ /* The header is recognized by "MeSsAgEs" in the stamp field. */
+
+ char stamp[8];
+
+ unsigned char languageID[NLM_TARGET_LONG_SIZE];
+
+ unsigned char messageFileOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char messageFileLength[NLM_TARGET_LONG_SIZE];
+
+ unsigned char messageCount[NLM_TARGET_LONG_SIZE];
+
+ unsigned char helpFileOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char helpFileLength[NLM_TARGET_LONG_SIZE];
+
+ unsigned char RPCDataOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char RPCDataLength[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedCodeOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedCodeLength[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedDataOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedDataLength[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedRelocationFixupOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedRelocationFixupCount[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedExternalReferenceOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedExternalReferenceCount[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedPublicsOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedPublicsCount[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedDebugRecordOffset[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedDebugRecordCount[NLM_TARGET_LONG_SIZE];
+
+ unsigned char sharedInitializationOffset[NLM_TARGET_ADDRESS_SIZE];
+
+ unsigned char SharedExitProcedureOffset[NLM_TARGET_ADDRESS_SIZE];
+
+ unsigned char productID[NLM_TARGET_LONG_SIZE];
+
+ unsigned char reserved0[NLM_TARGET_LONG_SIZE];
+
+ unsigned char reserved1[NLM_TARGET_LONG_SIZE];
+
+ unsigned char reserved2[NLM_TARGET_LONG_SIZE];
+
+ unsigned char reserved3[NLM_TARGET_LONG_SIZE];
+
+ unsigned char reserved4[NLM_TARGET_LONG_SIZE];
+
+ unsigned char reserved5[NLM_TARGET_LONG_SIZE];
+
+} NlmNAME(External_Extended_Header);
+
+
+typedef struct nlmNAME(external_custom_header)
+{
+
+ /* The header is recognized by "CuStHeAd" in the stamp field. */
+ char stamp[8];
+
+ /* Length of this header. */
+ unsigned char length[NLM_TARGET_LONG_SIZE];
+
+ /* Offset to data. */
+ unsigned char dataOffset[NLM_TARGET_LONG_SIZE];
+
+ /* Length of data. */
+ unsigned char dataLength[NLM_TARGET_LONG_SIZE];
+
+ /* Stamp for this customer header--we recognize "CyGnUsEx". */
+ char dataStamp[8];
+
+} NlmNAME(External_Custom_Header);
diff --git a/include/nlm/i386-ext.h b/include/nlm/i386-ext.h
new file mode 100644
index 00000000000..d33ad2da770
--- /dev/null
+++ b/include/nlm/i386-ext.h
@@ -0,0 +1,116 @@
+/* i386 NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* The external format of the fixed header. */
+
+typedef struct nlm32_i386_external_fixed_header
+{
+
+ /* The signature field identifies the file as an NLM. It must contain
+ the signature string, which depends upon the NLM target. */
+
+ unsigned char signature[24];
+
+ /* The version of the header. At this time, the highest version number
+ is 4. */
+
+ unsigned char version[4];
+
+ /* The name of the module, which must be a DOS name (1-8 characters followed
+ by a period and a 1-3 character extension). The first byte is the byte
+ length of the name and the last byte is a null terminator byte. This
+ field is fixed length, and any unused bytes should be null bytes. The
+ value is set by the OUTPUT keyword to NLMLINK. */
+
+ unsigned char moduleName[14];
+
+ /* The byte offset of the code image from the start of the file. */
+
+ unsigned char codeImageOffset[4];
+
+ /* The size of the code image, in bytes. */
+
+ unsigned char codeImageSize[4];
+
+ /* The byte offset of the data image from the start of the file. */
+
+ unsigned char dataImageOffset[4];
+
+ /* The size of the data image, in bytes. */
+
+ unsigned char dataImageSize[4];
+
+ /* The size of the uninitialized data region that the loader is to be
+ allocated at load time. Uninitialized data follows the initialized
+ data in the NLM address space. */
+
+ unsigned char uninitializedDataSize[4];
+
+ /* The byte offset of the custom data from the start of the file. The
+ custom data is set by the CUSTOM keyword to NLMLINK. It is possible
+ for this to be EOF if there is no custom data. */
+
+ unsigned char customDataOffset[4];
+
+ /* The size of the custom data, in bytes. */
+
+ unsigned char customDataSize[4];
+
+ /* The byte offset of the module dependencies from the start of the file.
+ The module dependencies are determined by the MODULE keyword in
+ NLMLINK. */
+
+ unsigned char moduleDependencyOffset[4];
+
+ /* The number of module dependencies at the moduleDependencyOffset. */
+
+ unsigned char numberOfModuleDependencies[4];
+
+ /* The byte offset of the relocation fixup data from the start of the file */
+
+ unsigned char relocationFixupOffset[4];
+
+ unsigned char numberOfRelocationFixups[4];
+
+ unsigned char externalReferencesOffset[4];
+
+ unsigned char numberOfExternalReferences[4];
+
+ unsigned char publicsOffset[4];
+
+ unsigned char numberOfPublics[4];
+
+ /* The byte offset of the internal debug info from the start of the file.
+ It is possible for this to be EOF if there is no debug info. */
+
+ unsigned char debugInfoOffset[4];
+
+ unsigned char numberOfDebugRecords[4];
+
+ unsigned char codeStartOffset[4];
+
+ unsigned char exitProcedureOffset[4];
+
+ unsigned char checkUnloadProcedureOffset[4];
+
+ unsigned char moduleType[4];
+
+ unsigned char flags[4];
+
+} Nlm32_i386_External_Fixed_Header;
diff --git a/include/nlm/internal.h b/include/nlm/internal.h
new file mode 100644
index 00000000000..dd27dc407f5
--- /dev/null
+++ b/include/nlm/internal.h
@@ -0,0 +1,309 @@
+/* NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of NLM support for BFD, and contains the portions
+ that describe how NLM is represented internally in the BFD library.
+ I.E. it describes the in-memory representation of NLM. It requires
+ the nlm/common.h file which contains the portions that are common to
+ both the internal and external representations. */
+
+#if 0
+
+/* Types used by various structures, functions, etc. */
+
+typedef unsigned long Nlm32_Addr; /* Unsigned program address */
+typedef unsigned long Nlm32_Off; /* Unsigned file offset */
+typedef long Nlm32_Sword; /* Signed large integer */
+typedef unsigned long Nlm32_Word; /* Unsigned large integer */
+typedef unsigned short Nlm32_Half; /* Unsigned medium integer */
+typedef unsigned char Nlm32_Char; /* Unsigned tiny integer */
+
+#ifdef BFD_HOST_64_BIT
+typedef unsigned BFD_HOST_64_BIT Nlm64_Addr;
+typedef unsigned BFD_HOST_64_BIT Nlm64_Off;
+typedef BFD_HOST_64_BIT Nlm64_Sxword;
+typedef unsigned BFD_HOST_64_BIT Nlm64_Xword;
+#endif
+typedef long Nlm64_Sword;
+typedef unsigned long Nlm64_Word;
+typedef unsigned short Nlm64_Half;
+
+#endif /* 0 */
+
+/* This structure contains the internal form of the portion of the NLM
+ header that is fixed length. */
+
+typedef struct nlm_internal_fixed_header
+{
+ /* The signature field identifies the file as an NLM. It must contain
+ the signature string, which depends upon the NLM target. */
+
+ char signature[NLM_SIGNATURE_SIZE];
+
+ /* The version of the header. At this time, the highest version number
+ is 4. */
+
+ long version;
+
+ /* The name of the module, which must be a DOS name (1-8 characters followed
+ by a period and a 1-3 character extension. The first byte is the byte
+ length of the name and the last byte is a null terminator byte. This
+ field is fixed length, and any unused bytes should be null bytes. The
+ value is set by the OUTPUT keyword to NLMLINK. */
+
+ char moduleName[NLM_MODULE_NAME_SIZE];
+
+ /* The byte offset of the code image from the start of the file. */
+
+ file_ptr codeImageOffset;
+
+ /* The size of the code image, in bytes. */
+
+ bfd_size_type codeImageSize;
+
+ /* The byte offset of the data image from the start of the file. */
+
+ file_ptr dataImageOffset;
+
+ /* The size of the data image, in bytes. */
+
+ bfd_size_type dataImageSize;
+
+ /* The size of the uninitialized data region that the loader is to be
+ allocated at load time. Uninitialized data follows the initialized
+ data in the NLM address space. */
+
+ bfd_size_type uninitializedDataSize;
+
+ /* The byte offset of the custom data from the start of the file. The
+ custom data is set by the CUSTOM keyword to NLMLINK. */
+
+ file_ptr customDataOffset;
+
+ /* The size of the custom data, in bytes. */
+
+ bfd_size_type customDataSize;
+
+ /* The byte offset of the module dependencies from the start of the file.
+ The module dependencies are determined by the MODULE keyword in
+ NLMLINK. */
+
+ file_ptr moduleDependencyOffset;
+
+ /* The number of module dependencies at the moduleDependencyOffset. */
+
+ long numberOfModuleDependencies;
+
+ /* The byte offset of the relocation fixup data from the start of the file */
+
+ file_ptr relocationFixupOffset;
+ long numberOfRelocationFixups;
+ file_ptr externalReferencesOffset;
+ long numberOfExternalReferences;
+ file_ptr publicsOffset;
+ long numberOfPublics;
+ file_ptr debugInfoOffset;
+ long numberOfDebugRecords;
+ file_ptr codeStartOffset;
+ file_ptr exitProcedureOffset;
+ file_ptr checkUnloadProcedureOffset;
+ long moduleType;
+ long flags;
+} Nlm_Internal_Fixed_Header;
+
+#define nlm32_internal_fixed_header nlm_internal_fixed_header
+#define Nlm32_Internal_Fixed_Header Nlm_Internal_Fixed_Header
+#define nlm64_internal_fixed_header nlm_internal_fixed_header
+#define Nlm64_Internal_Fixed_Header Nlm_Internal_Fixed_Header
+
+/* This structure contains the portions of the NLM header that are either
+ variable in size in the external representation, or else are not at a
+ fixed offset relative to the start of the NLM header due to preceding
+ variable sized fields.
+
+ Note that all the fields must exist in the external header, and in
+ the order used here (the same order is used in the internal form
+ for consistency, not out of necessity). */
+
+typedef struct nlm_internal_variable_header
+{
+
+ /* The descriptionLength field contains the length of the text in
+ descriptionText, excluding the null terminator. The descriptionText
+ field contains the NLM description obtained from the DESCRIPTION
+ keyword in NLMLINK plus the null byte terminator. The descriptionText
+ can be up to NLM_MAX_DESCRIPTION_LENGTH characters. */
+
+ unsigned char descriptionLength;
+ char descriptionText[NLM_MAX_DESCRIPTION_LENGTH + 1];
+
+ /* The stackSize field contains the size of the stack in bytes, as
+ specified by the STACK or STACKSIZE keyword in NLMLINK. If no size
+ is specified, the default is NLM_DEFAULT_STACKSIZE. */
+
+ long stackSize;
+
+ /* The reserved field is included only for completeness. It should contain
+ zero. */
+
+ long reserved;
+
+ /* This field is fixed length, should contain " LONG" (note leading
+ space), and is unused. */
+
+ char oldThreadName[NLM_OLD_THREAD_NAME_LENGTH];
+
+ /* The screenNameLength field contains the length of the actual text stored
+ in the screenName field, excluding the null byte terminator. The
+ screenName field contains the screen name as specified by the SCREENNAME
+ keyword in NLMLINK, and can be up to NLM_MAX_SCREEN_NAME_LENGTH
+ characters. */
+
+ unsigned char screenNameLength;
+ char screenName[NLM_MAX_SCREEN_NAME_LENGTH + 1];
+
+ /* The threadNameLength field contains the length of the actual text stored
+ in the threadName field, excluding the null byte terminator. The
+ threadName field contains the thread name as specified by the THREADNAME
+ keyword in NLMLINK, and can be up to NLM_MAX_THREAD_NAME_LENGTH
+ characters. */
+
+ unsigned char threadNameLength;
+ char threadName[NLM_MAX_THREAD_NAME_LENGTH + 1];
+
+} Nlm_Internal_Variable_Header;
+
+#define nlm32_internal_variable_header nlm_internal_variable_header
+#define Nlm32_Internal_Variable_Header Nlm_Internal_Variable_Header
+#define nlm64_internal_variable_header nlm_internal_variable_header
+#define Nlm64_Internal_Variable_Header Nlm_Internal_Variable_Header
+
+/* The version header is one of the optional auxiliary headers and
+ follows the fixed length and variable length NLM headers. */
+
+typedef struct nlm_internal_version_header
+{
+ /* The header is recognized by "VeRsIoN#" in the stamp field. */
+ char stamp[8];
+ long majorVersion;
+ long minorVersion;
+ long revision;
+ long year;
+ long month;
+ long day;
+} Nlm_Internal_Version_Header;
+
+#define nlm32_internal_version_header nlm_internal_version_header
+#define Nlm32_Internal_Version_Header Nlm_Internal_Version_Header
+#define nlm64_internal_version_header nlm_internal_version_header
+#define Nlm64_Internal_Version_Header Nlm_Internal_Version_Header
+
+typedef struct nlm_internal_copyright_header
+{
+ /* The header is recognized by "CoPyRiGhT=" in the stamp field. */
+ char stamp[10];
+ unsigned char copyrightMessageLength;
+ char copyrightMessage[NLM_MAX_COPYRIGHT_MESSAGE_LENGTH];
+} Nlm_Internal_Copyright_Header;
+
+#define nlm32_internal_copyright_header nlm_internal_copyright_header
+#define Nlm32_Internal_Copyright_Header Nlm_Internal_Copyright_Header
+#define nlm64_internal_copyright_header nlm_internal_copyright_header
+#define Nlm64_Internal_Copyright_Header Nlm_Internal_Copyright_Header
+
+typedef struct nlm_internal_extended_header
+{
+ /* The header is recognized by "MeSsAgEs" in the stamp field. */
+ char stamp[8];
+ long languageID;
+ file_ptr messageFileOffset;
+ bfd_size_type messageFileLength;
+ long messageCount;
+ file_ptr helpFileOffset;
+ bfd_size_type helpFileLength;
+ file_ptr RPCDataOffset;
+ bfd_size_type RPCDataLength;
+ file_ptr sharedCodeOffset;
+ bfd_size_type sharedCodeLength;
+ file_ptr sharedDataOffset;
+ bfd_size_type sharedDataLength;
+ file_ptr sharedRelocationFixupOffset;
+ long sharedRelocationFixupCount;
+ file_ptr sharedExternalReferenceOffset;
+ long sharedExternalReferenceCount;
+ file_ptr sharedPublicsOffset;
+ long sharedPublicsCount;
+ file_ptr sharedDebugRecordOffset;
+ long sharedDebugRecordCount;
+ bfd_vma SharedInitializationOffset;
+ bfd_vma SharedExitProcedureOffset;
+ long productID;
+ long reserved0;
+ long reserved1;
+ long reserved2;
+ long reserved3;
+ long reserved4;
+ long reserved5;
+} Nlm_Internal_Extended_Header;
+
+#define nlm32_internal_extended_header nlm_internal_extended_header
+#define Nlm32_Internal_Extended_Header Nlm_Internal_Extended_Header
+#define nlm64_internal_extended_header nlm_internal_extended_header
+#define Nlm64_Internal_Extended_Header Nlm_Internal_Extended_Header
+
+/* The format of a custom header as stored internally is different
+ from the external format. This is how we store a custom header
+ which we do not recognize. */
+
+typedef struct nlm_internal_custom_header
+{
+ /* The header is recognized by "CuStHeAd" in the stamp field. */
+ char stamp[8];
+ bfd_size_type hdrLength;
+ file_ptr dataOffset;
+ bfd_size_type dataLength;
+ char dataStamp[8];
+ PTR hdr;
+} Nlm_Internal_Custom_Header;
+
+#define nlm32_internal_custom_header nlm_internal_custom_header
+#define Nlm32_Internal_Custom_Header Nlm_Internal_Custom_Header
+#define nlm64_internal_custom_header nlm_internal_custom_header
+#define Nlm64_Internal_Custom_Header Nlm_Internal_Custom_Header
+
+/* The internal Cygnus header is written out externally as a custom
+ header. We don't try to replicate that structure here. */
+
+typedef struct nlm_internal_cygnus_ext_header
+{
+ /* The header is recognized by "CyGnUsEx" in the stamp field. */
+ char stamp[8];
+ /* File location of debugging information. */
+ file_ptr offset;
+ /* Length of debugging information. */
+ bfd_size_type length;
+} Nlm_Internal_Cygnus_Ext_Header;
+
+#define nlm32_internal_cygnus_ext_header nlm_internal_cygnus_ext_header
+#define Nlm32_Internal_Cygnus_Ext_Header Nlm_Internal_Cygnus_Ext_Header
+#define nlm64_internal_cygnus_ext_header nlm_internal_cygnus_ext_header
+#define Nlm64_Internal_Cygnus_Ext_Header Nlm_Internal_Cygnus_Ext_Header
diff --git a/include/nlm/ppc-ext.h b/include/nlm/ppc-ext.h
new file mode 100644
index 00000000000..0aae10772f5
--- /dev/null
+++ b/include/nlm/ppc-ext.h
@@ -0,0 +1,163 @@
+/* PowerPC NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef OLDFORMAT
+
+/* The format of a PowerPC NLM changed. These structures are only
+ used in the old format. */
+
+/* A PowerPC NLM starts with an instance of this structure. */
+
+struct nlm32_powerpc_external_prefix_header
+{
+ /* Signature. Must be "AppleNLM". */
+ char signature[8];
+ /* Version number. Current value is 1. */
+ unsigned char headerVersion[4];
+ /* ??. Should be set to 0. */
+ unsigned char origins[4];
+ /* File creation date in standard Unix time format (seconds since
+ 1/1/70). */
+ unsigned char date[4];
+};
+
+#define NLM32_POWERPC_SIGNATURE "AppleNLM"
+#define NLM32_POWERPC_HEADER_VERSION 1
+
+/* The external format of a PowerPC NLM reloc. This is the same as an
+ XCOFF dynamic reloc. */
+
+struct nlm32_powerpc_external_reloc
+{
+ /* Address. */
+ unsigned char l_vaddr[4];
+ /* Symbol table index. This is 0 for .text and 1 for .data. 2
+ means .bss, but I don't know if it is used. In XCOFF, larger
+ numbers are indices into the dynamic symbol table, but they are
+ presumably not used in an NLM. */
+ unsigned char l_symndx[4];
+ /* Relocation type. */
+ unsigned char l_rtype[2];
+ /* Section number being relocated. */
+ unsigned char l_rsecnm[2];
+};
+
+#endif /* OLDFORMAT */
+
+/* The external format of the fixed header. */
+
+typedef struct nlm32_powerpc_external_fixed_header
+{
+
+ /* The signature field identifies the file as an NLM. It must contain
+ the signature string, which depends upon the NLM target. */
+
+ unsigned char signature[24];
+
+ /* The version of the header. At this time, the highest version number
+ is 4. */
+
+ unsigned char version[4];
+
+ /* The name of the module, which must be a DOS name (1-8 characters followed
+ by a period and a 1-3 character extension). The first byte is the byte
+ length of the name and the last byte is a null terminator byte. This
+ field is fixed length, and any unused bytes should be null bytes. The
+ value is set by the OUTPUT keyword to NLMLINK. */
+
+ unsigned char moduleName[14];
+
+ /* Padding to make it come out correct. */
+
+ unsigned char pad1[2];
+
+ /* The byte offset of the code image from the start of the file. */
+
+ unsigned char codeImageOffset[4];
+
+ /* The size of the code image, in bytes. */
+
+ unsigned char codeImageSize[4];
+
+ /* The byte offset of the data image from the start of the file. */
+
+ unsigned char dataImageOffset[4];
+
+ /* The size of the data image, in bytes. */
+
+ unsigned char dataImageSize[4];
+
+ /* The size of the uninitialized data region that the loader is to be
+ allocated at load time. Uninitialized data follows the initialized
+ data in the NLM address space. */
+
+ unsigned char uninitializedDataSize[4];
+
+ /* The byte offset of the custom data from the start of the file. The
+ custom data is set by the CUSTOM keyword to NLMLINK. It is possible
+ for this to be EOF if there is no custom data. */
+
+ unsigned char customDataOffset[4];
+
+ /* The size of the custom data, in bytes. */
+
+ unsigned char customDataSize[4];
+
+ /* The byte offset of the module dependencies from the start of the file.
+ The module dependencies are determined by the MODULE keyword in
+ NLMLINK. */
+
+ unsigned char moduleDependencyOffset[4];
+
+ /* The number of module dependencies at the moduleDependencyOffset. */
+
+ unsigned char numberOfModuleDependencies[4];
+
+ /* The byte offset of the relocation fixup data from the start of the file */
+
+ unsigned char relocationFixupOffset[4];
+
+ unsigned char numberOfRelocationFixups[4];
+
+ unsigned char externalReferencesOffset[4];
+
+ unsigned char numberOfExternalReferences[4];
+
+ unsigned char publicsOffset[4];
+
+ unsigned char numberOfPublics[4];
+
+ /* The byte offset of the internal debug info from the start of the file.
+ It is possible for this to be EOF if there is no debug info. */
+
+ unsigned char debugInfoOffset[4];
+
+ unsigned char numberOfDebugRecords[4];
+
+ unsigned char codeStartOffset[4];
+
+ unsigned char exitProcedureOffset[4];
+
+ unsigned char checkUnloadProcedureOffset[4];
+
+ unsigned char moduleType[4];
+
+ unsigned char flags[4];
+
+} Nlm32_powerpc_External_Fixed_Header;
diff --git a/include/nlm/sparc32-ext.h b/include/nlm/sparc32-ext.h
new file mode 100644
index 00000000000..0deb2dee923
--- /dev/null
+++ b/include/nlm/sparc32-ext.h
@@ -0,0 +1,120 @@
+/* SPARC NLM (NetWare Loadable Module) support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* The external format of the fixed header. */
+
+typedef struct nlm32_sparc_external_fixed_header
+{
+
+ /* The signature field identifies the file as an NLM. It must contain
+ the signature string, which depends upon the NLM target. */
+
+ unsigned char signature[24];
+
+ /* The version of the header. At this time, the highest version number
+ is 4. */
+
+ unsigned char version[4];
+
+ /* The name of the module, which must be a DOS name (1-8 characters followed
+ by a period and a 1-3 character extension). The first byte is the byte
+ length of the name and the last byte is a null terminator byte. This
+ field is fixed length, and any unused bytes should be null bytes. The
+ value is set by the OUTPUT keyword to NLMLINK. */
+
+ unsigned char moduleName[14];
+
+ /* Padding to make it come out correct. */
+
+ unsigned char pad1[2];
+
+ /* The byte offset of the code image from the start of the file. */
+
+ unsigned char codeImageOffset[4];
+
+ /* The size of the code image, in bytes. */
+
+ unsigned char codeImageSize[4];
+
+ /* The byte offset of the data image from the start of the file. */
+
+ unsigned char dataImageOffset[4];
+
+ /* The size of the data image, in bytes. */
+
+ unsigned char dataImageSize[4];
+
+ /* The size of the uninitialized data region that the loader is to be
+ allocated at load time. Uninitialized data follows the initialized
+ data in the NLM address space. */
+
+ unsigned char uninitializedDataSize[4];
+
+ /* The byte offset of the custom data from the start of the file. The
+ custom data is set by the CUSTOM keyword to NLMLINK. It is possible
+ for this to be EOF if there is no custom data. */
+
+ unsigned char customDataOffset[4];
+
+ /* The size of the custom data, in bytes. */
+
+ unsigned char customDataSize[4];
+
+ /* The byte offset of the module dependencies from the start of the file.
+ The module dependencies are determined by the MODULE keyword in
+ NLMLINK. */
+
+ unsigned char moduleDependencyOffset[4];
+
+ /* The number of module dependencies at the moduleDependencyOffset. */
+
+ unsigned char numberOfModuleDependencies[4];
+
+ /* The byte offset of the relocation fixup data from the start of the file */
+
+ unsigned char relocationFixupOffset[4];
+
+ unsigned char numberOfRelocationFixups[4];
+
+ unsigned char externalReferencesOffset[4];
+
+ unsigned char numberOfExternalReferences[4];
+
+ unsigned char publicsOffset[4];
+
+ unsigned char numberOfPublics[4];
+
+ /* The byte offset of the internal debug info from the start of the file.
+ It is possible for this to be EOF if there is no debug info. */
+
+ unsigned char debugInfoOffset[4];
+
+ unsigned char numberOfDebugRecords[4];
+
+ unsigned char codeStartOffset[4];
+
+ unsigned char exitProcedureOffset[4];
+
+ unsigned char checkUnloadProcedureOffset[4];
+
+ unsigned char moduleType[4];
+
+ unsigned char flags[4];
+
+} Nlm32_sparc_External_Fixed_Header;
diff --git a/include/oasys.h b/include/oasys.h
new file mode 100644
index 00000000000..867d2503134
--- /dev/null
+++ b/include/oasys.h
@@ -0,0 +1,152 @@
+/* Oasys object format header file for BFD.
+ Contributed by Cygnus Support. */
+
+#define OASYS_MAX_SEC_COUNT 16
+/* **** */
+
+typedef struct oasys_archive_header {
+ unsigned int version;
+ char create_date[12];
+ char revision_date[12];
+ unsigned int mod_count;
+ file_ptr mod_tbl_offset;
+ unsigned int sym_tbl_size;
+ unsigned int sym_count;
+ file_ptr sym_tbl_offset;
+ unsigned int xref_count;
+ file_ptr xref_lst_offset;
+} oasys_archive_header_type;
+
+typedef struct oasys_extarchive_header {
+ bfd_byte version[4];
+ bfd_byte create_date[12];
+ bfd_byte revision_date[12];
+ bfd_byte mod_count[4];
+ bfd_byte mod_tbl_offset[4];
+ bfd_byte sym_tbl_size[4];
+ bfd_byte sym_count[4];
+ bfd_byte sym_tbl_offset[4];
+ bfd_byte xref_count[4];
+ bfd_byte xref_lst_offset[4];
+} oasys_extarchive_header_type;
+
+typedef struct oasys_module_table {
+ int mod_number;
+ char mod_date[12];
+ unsigned int mod_size;
+ unsigned int dep_count;
+ unsigned int depee_count;
+ file_ptr file_offset;
+ unsigned int sect_count;
+ char *module_name;
+ unsigned int module_name_size;
+} oasys_module_table_type;
+
+
+typedef struct oasys_extmodule_table_a {
+ bfd_byte mod_number[4];
+ bfd_byte mod_date[12];
+ bfd_byte mod_size[4];
+ bfd_byte dep_count[4];
+ bfd_byte depee_count[4];
+ bfd_byte sect_count[4];
+ bfd_byte file_offset[4];
+ bfd_byte mod_name[32];
+} oasys_extmodule_table_type_a_type;
+
+typedef struct oasys_extmodule_table_b {
+ bfd_byte mod_number[4];
+ bfd_byte mod_date[12];
+ bfd_byte mod_size[4];
+ bfd_byte dep_count[4];
+ bfd_byte depee_count[4];
+ bfd_byte sect_count[4];
+ bfd_byte file_offset[4];
+ bfd_byte mod_name_length[4];
+} oasys_extmodule_table_type_b_type;
+
+
+typedef enum oasys_record {
+ oasys_record_is_end_enum = 0,
+ oasys_record_is_data_enum = 1,
+ oasys_record_is_symbol_enum = 2,
+ oasys_record_is_header_enum = 3,
+ oasys_record_is_named_section_enum = 4,
+ oasys_record_is_com_enum = 5,
+ oasys_record_is_debug_enum = 6,
+ oasys_record_is_section_enum = 7,
+ oasys_record_is_debug_file_enum = 8,
+ oasys_record_is_module_enum = 9,
+ oasys_record_is_local_enum = 10
+} oasys_record_enum_type;
+
+
+
+typedef struct oasys_record_header {
+ unsigned char length;
+ unsigned char check_sum;
+ unsigned char type;
+ unsigned char fill;
+} oasys_record_header_type;
+
+typedef struct oasys_data_record {
+ oasys_record_header_type header;
+ unsigned char relb;
+ bfd_byte addr[4];
+ /* maximum total size of data record is 255 bytes */
+ bfd_byte data[246];
+} oasys_data_record_type;
+
+typedef struct oasys_header_record {
+ oasys_record_header_type header;
+ unsigned char version_number;
+ unsigned char rev_number;
+ char module_name[26-6];
+ char description[64-26];
+} oasys_header_record_type;
+
+#define OASYS_VERSION_NUMBER 0
+#define OASYS_REV_NUMBER 0
+
+typedef struct oasys_symbol_record {
+ oasys_record_header_type header;
+ unsigned char relb;
+ bfd_byte value[4];
+ bfd_byte refno[2];
+ char name[64];
+} oasys_symbol_record_type;
+
+#define RELOCATION_PCREL_BIT 0x80
+#define RELOCATION_32BIT_BIT 0x40
+#define RELOCATION_TYPE_BITS 0x30
+#define RELOCATION_TYPE_ABS 0x00
+#define RELOCATION_TYPE_REL 0x10
+#define RELOCATION_TYPE_UND 0x20
+#define RELOCATION_TYPE_COM 0x30
+#define RELOCATION_SECT_BITS 0x0f
+
+typedef struct oasys_section_record {
+ oasys_record_header_type header;
+ unsigned char relb;
+ bfd_byte value[4];
+ bfd_byte vma[4];
+ bfd_byte fill[3];
+} oasys_section_record_type;
+
+typedef struct oasys_end_record {
+ oasys_record_header_type header;
+ unsigned char relb;
+ bfd_byte entry[4];
+ bfd_byte fill[2];
+ bfd_byte zero;
+} oasys_end_record_type;
+
+typedef union oasys_record_union {
+ oasys_record_header_type header;
+ oasys_data_record_type data;
+ oasys_section_record_type section;
+ oasys_symbol_record_type symbol;
+ oasys_header_record_type first;
+ oasys_end_record_type end;
+ bfd_byte pad[256];
+} oasys_record_union_type;
diff --git a/include/objalloc.h b/include/objalloc.h
new file mode 100644
index 00000000000..0b451cdc295
--- /dev/null
+++ b/include/objalloc.h
@@ -0,0 +1,116 @@
+/* objalloc.h -- routines to allocate memory for objects
+ Copyright 1997 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, 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, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef OBJALLOC_H
+#define OBJALLOC_H
+
+#include "ansidecl.h"
+
+/* These routines allocate space for an object. The assumption is
+ that the object will want to allocate space as it goes along, but
+ will never want to free any particular block. There is a function
+ to free a block, which also frees all more recently allocated
+ blocks. There is also a function to free all the allocated space.
+
+ This is essentially a specialization of obstacks. The main
+ difference is that a block may not be allocated a bit at a time.
+ Another difference is that these routines are always built on top
+ of malloc, and always pass an malloc failure back to the caller,
+ unlike more recent versions of obstacks. */
+
+/* This is what an objalloc structure looks like. Callers should not
+ refer to these fields, nor should they allocate these structure
+ themselves. Instead, they should only create them via
+ objalloc_init, and only access them via the functions and macros
+ listed below. The structure is only defined here so that we can
+ access it via macros. */
+
+struct objalloc
+{
+ char *current_ptr;
+ unsigned int current_space;
+ PTR chunks;
+};
+
+/* Work out the required alignment. */
+
+struct objalloc_align { char x; double d; };
+
+#if defined (__STDC__) && __STDC__
+#ifndef offsetof
+#include <stddef.h>
+#endif
+#define OBJALLOC_ALIGN \
+ ((ptrdiff_t) ((char *) &((struct objalloc_align *) 0)->d - (char *) 0))
+#else
+#define OBJALLOC_ALIGN \
+ ((long) ((char *) &((struct objalloc_align *) 0)->d - (char *) 0))
+#endif
+
+/* Create an objalloc structure. Returns NULL if malloc fails. */
+
+extern struct objalloc *objalloc_create PARAMS ((void));
+
+/* Allocate space from an objalloc structure. Returns NULL if malloc
+ fails. */
+
+extern PTR _objalloc_alloc PARAMS ((struct objalloc *, unsigned long));
+
+/* The macro version of objalloc_alloc. We only define this if using
+ gcc, because otherwise we would have to evaluate the arguments
+ multiple times, or use a temporary field as obstack.h does. */
+
+#if defined (__GNUC__) && defined (__STDC__) && __STDC__
+
+/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
+ does not implement __extension__. But that compiler doesn't define
+ __GNUC_MINOR__. */
+#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
+#define __extension__
+#endif
+
+#define objalloc_alloc(o, l) \
+ __extension__ \
+ ({ struct objalloc *__o = (o); \
+ unsigned long __len = (l); \
+ if (__len == 0) \
+ __len = 1; \
+ __len = (__len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); \
+ (__len <= __o->current_space \
+ ? (__o->current_ptr += __len, \
+ __o->current_space -= __len, \
+ (PTR) (__o->current_ptr - __len)) \
+ : _objalloc_alloc (__o, __len)); })
+
+#else /* ! __GNUC__ */
+
+#define objalloc_alloc(o, l) _objalloc_alloc ((o), (l))
+
+#endif /* ! __GNUC__ */
+
+/* Free an entire objalloc structure. */
+
+extern void objalloc_free PARAMS ((struct objalloc *));
+
+/* Free a block allocated by objalloc_alloc. This also frees all more
+ recently allocated blocks. */
+
+extern void objalloc_free_block PARAMS ((struct objalloc *, PTR));
+
+#endif /* OBJALLOC_H */
diff --git a/include/obstack.h b/include/obstack.h
new file mode 100644
index 00000000000..38e96777660
--- /dev/null
+++ b/include/obstack.h
@@ -0,0 +1,593 @@
+/* obstack.h - object stack macros
+ Copyright (C) 1988,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
+
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* Summary:
+
+All the apparent functions defined here are macros. The idea
+is that you would use these pre-tested macros to solve a
+very specific set of problems, and they would run fast.
+Caution: no side-effects in arguments please!! They may be
+evaluated MANY times!!
+
+These macros operate a stack of objects. Each object starts life
+small, and may grow to maturity. (Consider building a word syllable
+by syllable.) An object can move while it is growing. Once it has
+been "finished" it never changes address again. So the "top of the
+stack" is typically an immature growing object, while the rest of the
+stack is of mature, fixed size and fixed address objects.
+
+These routines grab large chunks of memory, using a function you
+supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
+by calling `obstack_chunk_free'. You must define them and declare
+them before using any obstack macros.
+
+Each independent stack is represented by a `struct obstack'.
+Each of the obstack macros expects a pointer to such a structure
+as the first argument.
+
+One motivation for this package is the problem of growing char strings
+in symbol tables. Unless you are "fascist pig with a read-only mind"
+--Gosper's immortal quote from HAKMEM item 154, out of context--you
+would not like to put any arbitrary upper limit on the length of your
+symbols.
+
+In practice this often means you will build many short symbols and a
+few long symbols. At the time you are reading a symbol you don't know
+how long it is. One traditional method is to read a symbol into a
+buffer, realloc()ating the buffer every time you try to read a symbol
+that is longer than the buffer. This is beaut, but you still will
+want to copy the symbol from the buffer to a more permanent
+symbol-table entry say about half the time.
+
+With obstacks, you can work differently. Use one obstack for all symbol
+names. As you read a symbol, grow the name in the obstack gradually.
+When the name is complete, finalize it. Then, if the symbol exists already,
+free the newly read name.
+
+The way we do this is to take a large chunk, allocating memory from
+low addresses. When you want to build a symbol in the chunk you just
+add chars above the current "high water mark" in the chunk. When you
+have finished adding chars, because you got to the end of the symbol,
+you know how long the chars are, and you can create a new object.
+Mostly the chars will not burst over the highest address of the chunk,
+because you would typically expect a chunk to be (say) 100 times as
+long as an average object.
+
+In case that isn't clear, when we have enough chars to make up
+the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
+so we just point to it where it lies. No moving of chars is
+needed and this is the second win: potentially long strings need
+never be explicitly shuffled. Once an object is formed, it does not
+change its address during its lifetime.
+
+When the chars burst over a chunk boundary, we allocate a larger
+chunk, and then copy the partly formed object from the end of the old
+chunk to the beginning of the new larger chunk. We then carry on
+accreting characters to the end of the object as we normally would.
+
+A special macro is provided to add a single char at a time to a
+growing object. This allows the use of register variables, which
+break the ordinary 'growth' macro.
+
+Summary:
+ We allocate large chunks.
+ We carve out one object at a time from the current chunk.
+ Once carved, an object never moves.
+ We are free to append data of any size to the currently
+ growing object.
+ Exactly one object is growing in an obstack at any one time.
+ You can run one obstack per control block.
+ You may have as many control blocks as you dare.
+ Because of the way we do it, you can `unwind' an obstack
+ back to a previous state. (You may remove objects much
+ as you would with a stack.)
+*/
+
+
+/* Don't do the contents of this file more than once. */
+
+#ifndef _OBSTACK_H
+#define _OBSTACK_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* We use subtraction of (char *) 0 instead of casting to int
+ because on word-addressable machines a simple cast to int
+ may ignore the byte-within-word field of the pointer. */
+
+#ifndef __PTR_TO_INT
+# define __PTR_TO_INT(P) ((P) - (char *) 0)
+#endif
+
+#ifndef __INT_TO_PTR
+# define __INT_TO_PTR(P) ((P) + (char *) 0)
+#endif
+
+/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
+ defined, as with GNU C, use that; that way we don't pollute the
+ namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is
+ available, include it and use ptrdiff_t. In traditional C, long is
+ the best that we can do. */
+
+#ifdef __PTRDIFF_TYPE__
+# define PTR_INT_TYPE __PTRDIFF_TYPE__
+#else
+# ifdef HAVE_STDDEF_H
+# include <stddef.h>
+# define PTR_INT_TYPE ptrdiff_t
+# else
+# define PTR_INT_TYPE long
+# endif
+#endif
+
+#if defined _LIBC || defined HAVE_STRING_H
+# include <string.h>
+# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
+#else
+# ifdef memcpy
+# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
+# else
+# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
+# endif
+#endif
+
+struct _obstack_chunk /* Lives at front of each chunk. */
+{
+ char *limit; /* 1 past end of this chunk */
+ struct _obstack_chunk *prev; /* address of prior chunk or NULL */
+ char contents[4]; /* objects begin here */
+};
+
+struct obstack /* control current object in current chunk */
+{
+ long chunk_size; /* preferred size to allocate chunks in */
+ struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
+ char *object_base; /* address of object we are building */
+ char *next_free; /* where to add next char to current object */
+ char *chunk_limit; /* address of char after current chunk */
+ PTR_INT_TYPE temp; /* Temporary for some macros. */
+ int alignment_mask; /* Mask of alignment for each object. */
+#if defined __STDC__ && __STDC__
+ /* These prototypes vary based on `use_extra_arg', and we use
+ casts to the prototypeless function type in all assignments,
+ but having prototypes here quiets -Wstrict-prototypes. */
+ struct _obstack_chunk *(*chunkfun) (void *, long);
+ void (*freefun) (void *, struct _obstack_chunk *);
+ void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
+#else
+ struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
+ void (*freefun) (); /* User's function to free a chunk. */
+ char *extra_arg; /* first arg for chunk alloc/dealloc funcs */
+#endif
+ unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
+ unsigned maybe_empty_object:1;/* There is a possibility that the current
+ chunk contains a zero-length object. This
+ prevents freeing the chunk if we allocate
+ a bigger chunk to replace it. */
+ unsigned alloc_failed:1; /* No longer used, as we now call the failed
+ handler on error, but retained for binary
+ compatibility. */
+};
+
+/* Declare the external functions we use; they are in obstack.c. */
+
+#if defined __STDC__ && __STDC__
+extern void _obstack_newchunk (struct obstack *, int);
+extern void _obstack_free (struct obstack *, void *);
+extern int _obstack_begin (struct obstack *, int, int,
+ void *(*) (long), void (*) (void *));
+extern int _obstack_begin_1 (struct obstack *, int, int,
+ void *(*) (void *, long),
+ void (*) (void *, void *), void *);
+extern int _obstack_memory_used (struct obstack *);
+#else
+extern void _obstack_newchunk ();
+extern void _obstack_free ();
+extern int _obstack_begin ();
+extern int _obstack_begin_1 ();
+extern int _obstack_memory_used ();
+#endif
+
+#if defined __STDC__ && __STDC__
+
+/* Do the function-declarations after the structs
+ but before defining the macros. */
+
+void obstack_init (struct obstack *obstack);
+
+void * obstack_alloc (struct obstack *obstack, int size);
+
+void * obstack_copy (struct obstack *obstack, void *address, int size);
+void * obstack_copy0 (struct obstack *obstack, void *address, int size);
+
+void obstack_free (struct obstack *obstack, void *block);
+
+void obstack_blank (struct obstack *obstack, int size);
+
+void obstack_grow (struct obstack *obstack, void *data, int size);
+void obstack_grow0 (struct obstack *obstack, void *data, int size);
+
+void obstack_1grow (struct obstack *obstack, int data_char);
+void obstack_ptr_grow (struct obstack *obstack, void *data);
+void obstack_int_grow (struct obstack *obstack, int data);
+
+void * obstack_finish (struct obstack *obstack);
+
+int obstack_object_size (struct obstack *obstack);
+
+int obstack_room (struct obstack *obstack);
+void obstack_make_room (struct obstack *obstack, int size);
+void obstack_1grow_fast (struct obstack *obstack, int data_char);
+void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
+void obstack_int_grow_fast (struct obstack *obstack, int data);
+void obstack_blank_fast (struct obstack *obstack, int size);
+
+void * obstack_base (struct obstack *obstack);
+void * obstack_next_free (struct obstack *obstack);
+int obstack_alignment_mask (struct obstack *obstack);
+int obstack_chunk_size (struct obstack *obstack);
+int obstack_memory_used (struct obstack *obstack);
+
+#endif /* __STDC__ */
+
+/* Non-ANSI C cannot really support alternative functions for these macros,
+ so we do not declare them. */
+
+/* Error handler called when `obstack_chunk_alloc' failed to allocate
+ more memory. This can be set to a user defined function. The
+ default action is to print a message and abort. */
+#if defined __STDC__ && __STDC__
+extern void (*obstack_alloc_failed_handler) (void);
+#else
+extern void (*obstack_alloc_failed_handler) ();
+#endif
+
+/* Exit value used when `print_and_abort' is used. */
+extern int obstack_exit_failure;
+
+/* Pointer to beginning of object being allocated or to be allocated next.
+ Note that this might not be the final address of the object
+ because a new chunk might be needed to hold the final size. */
+
+#define obstack_base(h) ((h)->object_base)
+
+/* Size for allocating ordinary chunks. */
+
+#define obstack_chunk_size(h) ((h)->chunk_size)
+
+/* Pointer to next byte not yet allocated in current chunk. */
+
+#define obstack_next_free(h) ((h)->next_free)
+
+/* Mask specifying low bits that should be clear in address of an object. */
+
+#define obstack_alignment_mask(h) ((h)->alignment_mask)
+
+/* To prevent prototype warnings provide complete argument list in
+ standard C version. */
+#if defined __STDC__ && __STDC__
+
+# define obstack_init(h) \
+ _obstack_begin ((h), 0, 0, \
+ (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
+
+# define obstack_begin(h, size) \
+ _obstack_begin ((h), (size), 0, \
+ (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
+
+# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
+ _obstack_begin ((h), (size), (alignment), \
+ (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
+
+# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
+ _obstack_begin_1 ((h), (size), (alignment), \
+ (void *(*) (void *, long)) (chunkfun), \
+ (void (*) (void *, void *)) (freefun), (arg))
+
+# define obstack_chunkfun(h, newchunkfun) \
+ ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
+
+# define obstack_freefun(h, newfreefun) \
+ ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
+
+#else
+
+# define obstack_init(h) \
+ _obstack_begin ((h), 0, 0, \
+ (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
+
+# define obstack_begin(h, size) \
+ _obstack_begin ((h), (size), 0, \
+ (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
+
+# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
+ _obstack_begin ((h), (size), (alignment), \
+ (void *(*) ()) (chunkfun), (void (*) ()) (freefun))
+
+# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
+ _obstack_begin_1 ((h), (size), (alignment), \
+ (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
+
+# define obstack_chunkfun(h, newchunkfun) \
+ ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
+
+# define obstack_freefun(h, newfreefun) \
+ ((h) -> freefun = (void (*)()) (newfreefun))
+
+#endif
+
+#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
+
+#define obstack_blank_fast(h,n) ((h)->next_free += (n))
+
+#define obstack_memory_used(h) _obstack_memory_used (h)
+
+#if defined __GNUC__ && defined __STDC__ && __STDC__
+/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
+ does not implement __extension__. But that compiler doesn't define
+ __GNUC_MINOR__. */
+# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
+# define __extension__
+# endif
+
+/* For GNU C, if not -traditional,
+ we can define these macros to compute all args only once
+ without using a global variable.
+ Also, we can avoid using the `temp' slot, to make faster code. */
+
+# define obstack_object_size(OBSTACK) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ (unsigned) (__o->next_free - __o->object_base); })
+
+# define obstack_room(OBSTACK) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ (unsigned) (__o->chunk_limit - __o->next_free); })
+
+# define obstack_make_room(OBSTACK,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ if (__o->chunk_limit - __o->next_free < __len) \
+ _obstack_newchunk (__o, __len); \
+ (void) 0; })
+
+# define obstack_empty_p(OBSTACK) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
+
+# define obstack_grow(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ if (__o->next_free + __len > __o->chunk_limit) \
+ _obstack_newchunk (__o, __len); \
+ _obstack_memcpy (__o->next_free, (char *) (where), __len); \
+ __o->next_free += __len; \
+ (void) 0; })
+
+# define obstack_grow0(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ if (__o->next_free + __len + 1 > __o->chunk_limit) \
+ _obstack_newchunk (__o, __len + 1); \
+ _obstack_memcpy (__o->next_free, (char *) (where), __len); \
+ __o->next_free += __len; \
+ *(__o->next_free)++ = 0; \
+ (void) 0; })
+
+# define obstack_1grow(OBSTACK,datum) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ if (__o->next_free + 1 > __o->chunk_limit) \
+ _obstack_newchunk (__o, 1); \
+ *(__o->next_free)++ = (datum); \
+ (void) 0; })
+
+/* These assume that the obstack alignment is good enough for pointers or ints,
+ and that the data added so far to the current object
+ shares that much alignment. */
+
+# define obstack_ptr_grow(OBSTACK,datum) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
+ _obstack_newchunk (__o, sizeof (void *)); \
+ *((void **)__o->next_free)++ = ((void *)datum); \
+ (void) 0; })
+
+# define obstack_int_grow(OBSTACK,datum) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ if (__o->next_free + sizeof (int) > __o->chunk_limit) \
+ _obstack_newchunk (__o, sizeof (int)); \
+ *((int *)__o->next_free)++ = ((int)datum); \
+ (void) 0; })
+
+# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
+# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
+
+# define obstack_blank(OBSTACK,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ if (__o->chunk_limit - __o->next_free < __len) \
+ _obstack_newchunk (__o, __len); \
+ __o->next_free += __len; \
+ (void) 0; })
+
+# define obstack_alloc(OBSTACK,length) \
+__extension__ \
+({ struct obstack *__h = (OBSTACK); \
+ obstack_blank (__h, (length)); \
+ obstack_finish (__h); })
+
+# define obstack_copy(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__h = (OBSTACK); \
+ obstack_grow (__h, (where), (length)); \
+ obstack_finish (__h); })
+
+# define obstack_copy0(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__h = (OBSTACK); \
+ obstack_grow0 (__h, (where), (length)); \
+ obstack_finish (__h); })
+
+/* The local variable is named __o1 to avoid a name conflict
+ when obstack_blank is called. */
+# define obstack_finish(OBSTACK) \
+__extension__ \
+({ struct obstack *__o1 = (OBSTACK); \
+ void *value; \
+ value = (void *) __o1->object_base; \
+ if (__o1->next_free == value) \
+ __o1->maybe_empty_object = 1; \
+ __o1->next_free \
+ = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
+ & ~ (__o1->alignment_mask)); \
+ if (__o1->next_free - (char *)__o1->chunk \
+ > __o1->chunk_limit - (char *)__o1->chunk) \
+ __o1->next_free = __o1->chunk_limit; \
+ __o1->object_base = __o1->next_free; \
+ value; })
+
+# define obstack_free(OBSTACK, OBJ) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ void *__obj = (OBJ); \
+ if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
+ __o->next_free = __o->object_base = __obj; \
+ else (obstack_free) (__o, __obj); })
+
+#else /* not __GNUC__ or not __STDC__ */
+
+# define obstack_object_size(h) \
+ (unsigned) ((h)->next_free - (h)->object_base)
+
+# define obstack_room(h) \
+ (unsigned) ((h)->chunk_limit - (h)->next_free)
+
+# define obstack_empty_p(h) \
+ ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
+
+/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
+ so that we can avoid having void expressions
+ in the arms of the conditional expression.
+ Casting the third operand to void was tried before,
+ but some compilers won't accept it. */
+
+# define obstack_make_room(h,length) \
+( (h)->temp = (length), \
+ (((h)->next_free + (h)->temp > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
+
+# define obstack_grow(h,where,length) \
+( (h)->temp = (length), \
+ (((h)->next_free + (h)->temp > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
+ _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
+ (h)->next_free += (h)->temp)
+
+# define obstack_grow0(h,where,length) \
+( (h)->temp = (length), \
+ (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
+ _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
+ (h)->next_free += (h)->temp, \
+ *((h)->next_free)++ = 0)
+
+# define obstack_1grow(h,datum) \
+( (((h)->next_free + 1 > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), 1), 0) : 0), \
+ (*((h)->next_free)++ = (datum)))
+
+# define obstack_ptr_grow(h,datum) \
+( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
+ (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
+
+# define obstack_int_grow(h,datum) \
+( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
+ (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
+
+# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
+# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
+
+# define obstack_blank(h,length) \
+( (h)->temp = (length), \
+ (((h)->chunk_limit - (h)->next_free < (h)->temp) \
+ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
+ ((h)->next_free += (h)->temp))
+
+# define obstack_alloc(h,length) \
+ (obstack_blank ((h), (length)), obstack_finish ((h)))
+
+# define obstack_copy(h,where,length) \
+ (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
+
+# define obstack_copy0(h,where,length) \
+ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
+
+# define obstack_finish(h) \
+( ((h)->next_free == (h)->object_base \
+ ? (((h)->maybe_empty_object = 1), 0) \
+ : 0), \
+ (h)->temp = __PTR_TO_INT ((h)->object_base), \
+ (h)->next_free \
+ = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
+ & ~ ((h)->alignment_mask)), \
+ (((h)->next_free - (char *) (h)->chunk \
+ > (h)->chunk_limit - (char *) (h)->chunk) \
+ ? ((h)->next_free = (h)->chunk_limit) : 0), \
+ (h)->object_base = (h)->next_free, \
+ __INT_TO_PTR ((h)->temp))
+
+# if defined __STDC__ && __STDC__
+# define obstack_free(h,obj) \
+( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
+ (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+ ? (int) ((h)->next_free = (h)->object_base \
+ = (h)->temp + (char *) (h)->chunk) \
+ : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
+# else
+# define obstack_free(h,obj) \
+( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
+ (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+ ? (int) ((h)->next_free = (h)->object_base \
+ = (h)->temp + (char *) (h)->chunk) \
+ : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
+# endif
+
+#endif /* not __GNUC__ or not __STDC__ */
+
+#ifdef __cplusplus
+} /* C++ */
+#endif
+
+#endif /* obstack.h */
diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog
new file mode 100644
index 00000000000..79bc3cc7cb8
--- /dev/null
+++ b/include/opcode/ChangeLog
@@ -0,0 +1,1873 @@
+1999-04-14 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (CGEN_ATTR): Delete member num_nonbools.
+ (CGEN_ATTR_TYPE): Update.
+ (CGEN_ATTR_MASK): Number booleans starting at 0.
+ (CGEN_ATTR_VALUE): Update.
+ (CGEN_INSN_ATTR): Update.
+
+Mon Apr 12 23:43:27 1999 Jeffrey A Law (law@cygnus.com)
+
+ * hppa.h (fmpyfadd, fmpynfadd, fneg, fnegabs): New PA2.0
+ instructions.
+
+Tue Mar 23 11:24:38 1999 Jeffrey A Law (law@cygnus.com)
+
+ * hppa.h (bb, bvb): Tweak opcode/mask.
+
+
+1999-03-22 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (CGEN_ISA,CGEN_MACH): New typedefs.
+ (struct cgen_cpu_desc): Rename member mach to machs. New member isas.
+ New members word_bitsize,default_insn_bitsize,base_insn-bitsize,
+ min_insn_bitsize,max_insn_bitsize,isa_table,mach_table,rebuild_tables.
+ Delete member max_insn_size.
+ (enum cgen_cpu_open_arg): New enum.
+ (cpu_open): Update prototype.
+ (cpu_open_1): Declare.
+ (cgen_set_cpu): Delete.
+
+1999-03-11 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (CGEN_HW_TABLE): Delete `num_init_entries' member.
+ (CGEN_OPERAND_NIL): New macro.
+ (CGEN_OPERAND): New member `type'.
+ (@arch@_cgen_operand_table): Delete decl.
+ (CGEN_OPERAND_INDEX,CGEN_OPERAND_TYPE,CGEN_OPERAND_ENTRY): Delete.
+ (CGEN_OPERAND_TABLE): New struct.
+ (cgen_operand_lookup_by_name,cgen_operand_lookup_by_num): Declare.
+ (CGEN_OPINST): Pointer to operand table entry replaced with enum.
+ (CGEN_CPU_TABLE): New member `isa'. Change member `operand_table',
+ now a CGEN_OPERAND_TABLE. Add CGEN_CPU_DESC arg to
+ {get,set}_{int,vma}_operand.
+ (@arch@_cgen_cpu_open): New arg `isa'.
+ (cgen_set_cpu): Ditto.
+
+Fri Feb 26 02:36:45 1999 Richard Henderson <rth@cygnus.com>
+
+ * i386.h: Fill in cmov and fcmov alternates. Add fcomi short forms.
+
+1999-02-25 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (enum cgen_asm_type): Add CGEN_ASM_NONE.
+ (CGEN_HW_ENTRY): Delete member `next'. Change type of `type' to
+ enum cgen_hw_type.
+ (CGEN_HW_TABLE): New struct.
+ (hw_table): Delete declaration.
+ (CGEN_OPERAND): Change member hw to hw_type, change type from pointer
+ to table entry to enum.
+ (CGEN_OPINST): Ditto.
+ (CGEN_CPU_TABLE): Change member hw_list to hw_table.
+
+Sat Feb 13 14:13:44 1999 Richard Henderson <rth@cygnus.com>
+
+ * alpha.h (AXP_OPCODE_EV6): New.
+ (AXP_OPCODE_NOPAL): Include it.
+
+1999-02-09 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (CGEN_CPU_DESC): Renamed from CGEN_OPCODE_DESC.
+ All uses updated. New members int_insn_p, max_insn_size,
+ parse_operand,insert_operand,extract_operand,print_operand,
+ sizeof_fields,set_fields_bitsize,get_int_operand,set_int_operand,
+ get_vma_operand,set_vma_operand,parse_handlers,insert_handlers,
+ extract_handlers,print_handlers.
+ (CGEN_ATTR): Change type of num_nonbools to unsigned int.
+ (CGEN_ATTR_BOOL_OFFSET): New macro.
+ (CGEN_ATTR_MASK): Subtract it to compute bit number.
+ (CGEN_ATTR_VALUE): Redo bool/nonbool attr calculation.
+ (cgen_opcode_handler): Renamed from cgen_base.
+ (CGEN_HW_ATTR_VALUE): Renamed from CGEN_HW_ATTR, all uses updated.
+ (CGEN_OPERAND_ATTR_VALUE): Renamed from CGEN_OPERAND_ATTR,
+ all uses updated.
+ (CGEN_OPERAND_INDEX): Rewrite to use table entry, not global.
+ (enum cgen_opinst_type): Renamed from cgen_operand_instance_type.
+ (CGEN_IFLD_ATTR_VALUE): Renamed from CGEN_IFLD_ATTR, all uses updated.
+ (CGEN_OPCODE,CGEN_IBASE): New types.
+ (CGEN_INSN): Rewrite.
+ (CGEN_{ASM,DIS}_HASH*): Delete.
+ (init_opcode_table,init_ibld_table): Declare.
+ (CGEN_INSN_ATTR): New type.
+
+Mon Feb 1 21:09:14 1999 Catherine Moore <clm@cygnus.com>
+
+ * i386.h (d_Suf, x_Suf, sld_Suf, sldx_Suf, bwld_Suf): Define.
+ (x_FP, d_FP, dls_FP, sldx_FP): Define.
+ Change *Suf definitions to include x and d suffixes.
+ (movsx): Use w_Suf and b_Suf.
+ (movzx): Likewise.
+ (movs): Use bwld_Suf.
+ (fld): Change ordering. Use sld_FP.
+ (fild): Add Intel Syntax equivalent of fildq.
+ (fst): Use sld_FP.
+ (fist): Use sld_FP.
+ (fstp): Use sld_FP. Add x_FP version.
+ (fistp): LLongMem version for Intel Syntax.
+ (fcom, fcomp): Use sld_FP.
+ (fadd, fiadd, fsub): Use sld_FP.
+ (fsubr): Use sld_FP.
+ (fmul, fimul, fdvi, fidiv, fdivr): Use sld_FP.
+
+1999-01-27 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (enum cgen_mode): Add CGEN_MODE_TARGET_MAX, CGEN_MODE_INT,
+ CGEN_MODE_UINT.
+
+Sat Jan 16 01:29:25 1999 Jeffrey A Law (law@cygnus.com)
+
+ * hppa.h (bv): Fix mask.
+
+1999-01-05 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (CGEN_ATTR_VALUE_TYPE): New typedef.
+ (CGEN_ATTR): Use it.
+ (CGEN_ATTR_TYPE,CGEN_ATTR_ENTRY): Ditto.
+ (CGEN_ATTR_TABLE): New member dfault.
+
+1998-12-30 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips.h (MIPS16_INSN_BRANCH): New.
+
+Wed Dec 9 10:38:48 1998 David Taylor <taylor@texas.cygnus.com>
+
+ The following is part of a change made by Edith Epstein
+ <eepstein@sophia.cygnus.com> as part of a project to merge in
+ changes by HP; HP did not create ChangeLog entries.
+
+ * hppa.h (completer_chars): list of chars to not put a space
+ after.
+
+Sun Dec 6 13:21:34 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h (i386_optab): Permit w suffix on processor control and
+ status word instructions.
+
+1998-11-30 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (struct cgen_hw_entry): Delete const on attrs member.
+ (struct cgen_keyword_entry): Ditto.
+ (struct cgen_operand): Ditto.
+ (CGEN_IFLD): New typedef, with associated access macros.
+ (CGEN_IFMT): New typedef, with associated access macros.
+ (CGEN_IFMT): Renamed from CGEN_FORMAT. New member `iflds'.
+ (CGEN_IVALUE): New typedef.
+ (struct cgen_insn): Delete const on syntax,attrs members.
+ `format' now points to format data. Type of `value' is now
+ CGEN_IVALUE.
+ (struct cgen_opcode_table): New member ifld_table.
+
+1998-11-18 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen.h (cgen_extract_fn): Update type of `base_insn' arg.
+ (CGEN_OPERAND_INSTANCE): New member `attrs'.
+ (CGEN_OPERAND_INSTANCE_{ATTRS,ATTR}): New macros.
+ (cgen_dis_lookup_insn): Update type of `base_insn' arg.
+ (cgen_opcode_table): Update type of dis_hash fn.
+ (extract_operand): Update type of `insn_value' arg.
+
+Thu Oct 29 11:38:36 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * cgen.h (CGEN_VERSION_{MAJOR,MINOR,FIXLEVEL}): Delete.
+
+Tue Oct 27 08:57:59 1998 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips.h (INSN_MULT): Added.
+
+Tue Oct 20 11:31:34 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (MAX_MNEM_SIZE): Rename from MAX_OPCODE_SIZE.
+
+Mon Oct 19 12:50:00 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_INSN_INT): New typedef.
+ (CGEN_INT_INSN_P): Renamed from CGEN_INT_INSN.
+ (CGEN_INSN_BYTES): Renamed from cgen_insn_t.
+ (CGEN_INSN_BYTES_PTR): New typedef.
+ (CGEN_EXTRACT_INFO): New typedef.
+ (cgen_insert_fn,cgen_extract_fn): Update.
+ (cgen_opcode_table): New member `insn_endian'.
+ (assemble_insn,lookup_insn,lookup_get_insn_operands): Update.
+ (insert_operand,extract_operand): Update.
+ (cgen_get_insn_value,cgen_put_insn_value): Add prototypes.
+
+Fri Oct 9 13:38:13 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_ATTR_BOOLS): New macro.
+ (struct CGEN_HW_ENTRY): New member `attrs'.
+ (CGEN_HW_ATTR): New macro.
+ (struct CGEN_OPERAND_INSTANCE): New member `name'.
+ (CGEN_INSN_INVALID_P): New macro.
+
+Mon Oct 5 00:21:07 1998 Jeffrey A Law (law@cygnus.com)
+
+ * hppa.h: Add "fid".
+
+Sun Oct 4 21:00:00 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ From Robert Andrew Dale <rob@nb.net>
+ * i386.h (i386_optab): Add AMD 3DNow! instructions.
+ (AMD_3DNOW_OPCODE): Define.
+
+Tue Sep 22 17:53:47 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v.h (EITHER_BUT_PREFER_MU): Define.
+
+Mon Aug 10 14:09:38 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * cgen.h (cgen_insn): #if 0 out element `cdx'.
+
+Mon Aug 3 12:21:57 1998 Doug Evans <devans@seba.cygnus.com>
+
+ Move all global state data into opcode table struct, and treat
+ opcode table as something that is "opened/closed".
+ * cgen.h (CGEN_OPCODE_DESC): New type.
+ (all fns): New first arg of opcode table descriptor.
+ (cgen_set_parse_operand_fn): Add prototype.
+ (cgen_current_machine,cgen_current_endian): Delete.
+ (CGEN_OPCODE_TABLE): New members mach,endian,operand_table,
+ parse_operand_fn,asm_hash_table,asm_hash_table_entries,
+ dis_hash_table,dis_hash_table_entries.
+ (opcode_open,opcode_close): Add prototypes.
+
+ * cgen.h (cgen_insn): New element `cdx'.
+
+Thu Jul 30 21:44:25 1998 Frank Ch. Eigler <fche@cygnus.com>
+
+ * d30v.h (FLAG_LKR): New flag for "left-kills-right" instructions.
+
+Tue Jul 28 10:59:07 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h: Add "no_match_operands" field for instructions.
+ (MN10300_MAX_OPERANDS): Define.
+
+Fri Jul 24 11:44:24 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * cgen.h (cgen_macro_insn_count): Declare.
+
+Tue Jul 21 13:12:13 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_VERSION_{MAJOR,MINOR,FIXLEVEL}): Define.
+ (cgen_insert_fn,cgen_extract_fn): New arg `pc'.
+ (get_operand,put_operand): Replaced with get_{int,vma}_operand,
+ set_{int,vma}_operand.
+
+Fri Jun 26 11:09:06 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h: Add "machine" field for instructions.
+ (MN103, AM30): Define machine types.
+
+Fri Jun 19 16:09:09 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h: Use FP, not sl_Suf, for fxsave and fxrstor.
+
+1998-06-18 Ulrich Drepper <drepper@cygnus.com>
+
+ * i386.h: Add support for fxsave, fxrstor, sysenter and sysexit.
+
+Sat Jun 13 11:31:35 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (i386_optab): Add general form of aad and aam. Add ud2a
+ and ud2b.
+ (i386_regtab): Allow cr0..7, db0..7, dr0..7, tr0..7, not just
+ those that happen to be implemented on pentiums.
+
+Tue Jun 9 12:16:01 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h: Change occurences of Data16 to Size16, Data32 to Size32,
+ IgnoreDataSize to IgnoreSize. Flag address and data size prefixes
+ with Size16|IgnoreSize or Size32|IgnoreSize.
+
+Mon Jun 8 12:15:52 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (REPNE): Rename to REPNE_PREFIX_OPCODE.
+ (REPE): Rename to REPE_PREFIX_OPCODE.
+ (i386_regtab_end): Remove.
+ (i386_prefixtab, i386_prefixtab_end): Remove.
+ (i386_optab): Use NULL as sentinel rather than "" to suit rewrite
+ of md_begin.
+ (MAX_OPCODE_SIZE): Define.
+ (i386_optab_end): Remove.
+ (sl_Suf): Define.
+ (sl_FP): Use sl_Suf.
+
+ * i386.h (i386_optab): Allow 16 bit displacement for `mov
+ mem,acc'. Combine 16 and 32 bit forms of various insns. Allow 16
+ bit form of ljmp. Add IsPrefix modifier to prefixes. Add addr32,
+ data32, dword, and adword prefixes.
+ (i386_regtab): Add BaseIndex modifier to valid 16 bit base/index
+ regs.
+
+Fri Jun 5 23:42:43 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (i386_regtab): Remove BaseIndex modifier from esp.
+
+ * i386.h: Allow `l' suffix on fld, fst, fstp, fcom, fcomp with
+ register operands, because this is a common idiom. Flag them with
+ a warning. Allow illegal faddp, fsubp, fsubrp, fmulp, fdivp,
+ fdivrp because gcc erroneously generates them. Also flag with a
+ warning.
+
+ * i386.h: Add suffix modifiers to most insns, and tighter operand
+ checks in some cases. Fix a number of UnixWare compatibility
+ issues with float insns. Merge some floating point opcodes, using
+ new FloatMF modifier.
+ (WORD_PREFIX_OPCODE): Rename to DATA_PREFIX_OPCODE for
+ consistency.
+
+ * i386.h: Change occurence of ShortformW to W|ShortForm. Add
+ IgnoreDataSize where appropriate.
+
+Wed Jun 3 18:28:45 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h: (one_byte_segment_defaults): Remove.
+ (two_byte_segment_defaults): Remove.
+ (i386_regtab): Add BaseIndex to 32 bit regs reg_type.
+
+Fri May 15 15:59:04 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (cgen_hw_lookup_by_name): Renamed from cgen_hw_lookup.
+ (cgen_hw_lookup_by_num): Declare.
+
+Thu May 7 09:27:58 1998 Frank Ch. Eigler <fche@cygnus.com>
+
+ * mips.h (OP_{SH,MASK}_CODE2): Added "q" operand format for lower
+ ten bits of MIPS ISA1 "break" instruction, and for "sdbbp"
+
+Thu May 7 02:14:08 1998 Doug Evans <devans@charmed.cygnus.com>
+
+ * cgen.h (cgen_asm_init_parse): Delete.
+ (cgen_save_fixups,cgen_restore_fixups,cgen_swap_fixups): Delete.
+ (cgen_asm_record_register,cgen_asm_finish_insn): Delete.
+
+Mon Apr 27 10:13:11 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_ATTR_TYPE): Delete `const', moved to uses.
+ (cgen_asm_finish_insn): Update prototype.
+ (cgen_insn): New members num, data.
+ (CGEN_INSN_TABLE): Members asm_hash, asm_hash_table_size,
+ dis_hash, dis_hash_table_size moved to ...
+ (CGEN_OPCODE_TABLE). Here. Renamed from CGEN_OPCODE_DATA.
+ All uses updated. New members asm_hash_p, dis_hash_p.
+ (CGEN_MINSN_EXPANSION): New struct.
+ (cgen_expand_macro_insn): Declare.
+ (cgen_macro_insn_count): Declare.
+ (get_insn_operands): Update prototype.
+ (lookup_get_insn_operands): Declare.
+
+Tue Apr 21 17:11:32 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (i386_optab): Change iclrKludge and imulKludge to
+ regKludge. Add operands types for string instructions.
+
+Mon Apr 20 14:40:29 1998 Tom Tromey <tromey@cygnus.com>
+
+ * i386.h (X): Renamed from `Z_' to preserve formatting of opcode
+ table.
+
+Sun Apr 19 13:54:06 1998 Tom Tromey <tromey@cygnus.com>
+
+ * i386.h (Z_): Renamed from `_' to avoid clash with common alias
+ for `gettext'.
+
+Fri Apr 3 12:04:48 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h: Remove NoModrm flag from all insns: it's never checked.
+ Add IsString flag to string instructions.
+ (IS_STRING): Don't define.
+ (LOCK_PREFIX_OPCODE, CS_PREFIX_OPCODE, DS_PREFIX_OPCODE): Define.
+ (ES_PREFIX_OPCODE, FS_PREFIX_OPCODE, GS_PREFIX_OPCODE): Define.
+ (SS_PREFIX_OPCODE): Define.
+
+Mon Mar 30 21:31:56 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Revert March 24 patch; no more LinearAddress.
+
+Mon Mar 30 10:25:54 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (i386_optab): Remove fwait (9b) from all floating point
+ instructions, and instead add FWait opcode modifier. Add short
+ form of fldenv and fstenv.
+ (FWAIT_OPCODE): Define.
+
+ * i386.h (i386_optab): Change second operand constraint of `mov
+ sreg,reg|mem' instruction from Reg16|Mem to WordReg|WordMem to
+ allow legal instructions such as `movl %gs,%esi'
+
+Fri Mar 27 18:30:52 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * h8300.h: Various changes to fully bracket initializers.
+
+Tue Mar 24 18:32:47 1998 H.J. Lu <hjl@gnu.org>
+
+ * i386.h: Set LinearAddress for lidt and lgdt.
+
+Mon Mar 2 10:44:07 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_BOOL_ATTR): New macro.
+
+Thu Feb 26 15:54:31 1998 Michael Meissner <meissner@cygnus.com>
+
+ * d30v.h (FLAG_DELAY): New flag for delayed branches/jumps.
+
+Mon Feb 23 10:38:21 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_CAT3): Delete. Use CONCAT3 now.
+ (cgen_insn): Record syntax and format entries here, rather than
+ separately.
+
+Tue Feb 17 21:42:56 1998 Nick Clifton <nickc@cygnus.com>
+
+ * cgen.h (CGEN_SYNTAX_MAKE_FIELD): New macro.
+
+Tue Feb 17 16:00:56 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (cgen_insert_fn): Change type of result to const char *.
+ (cgen_parse_{signed,unsigned}_integer): Delete min,max arguments.
+ (CGEN_{INSN,KEYWORD,OPERAND}_NBOOL_ATTRS): Renamed from ..._MAX_ATTRS.
+
+Thu Feb 12 18:30:41 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * cgen.h (lookup_insn): New argument alias_p.
+
+Thu Feb 12 03:41:00 1998 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+Fix rac to accept only a0:
+ * d10v.h (OPERAND_ACC): Split into:
+ (OPERAND_ACC0, OPERAND_ACC1) .
+ (OPERAND_GPR): Define.
+
+Wed Feb 11 17:31:53 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_FIELDS): Define here.
+ (CGEN_HW_ENTRY): New member `type'.
+ (hw_list): Delete decl.
+ (enum cgen_mode): Declare.
+ (CGEN_OPERAND): New member `hw'.
+ (enum cgen_operand_instance_type): Declare.
+ (CGEN_OPERAND_INSTANCE): New type.
+ (CGEN_INSN): New member `operands'.
+ (CGEN_OPCODE_DATA): Make hw_list const.
+ (get_insn_operands,lookup_insn): Add prototypes for.
+
+Tue Feb 3 17:11:23 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (CGEN_INSN_MAX_ATTRS): Renamed from CGEN_MAX_INSN_ATTRS.
+ (CGEN_HW_ENTRY): Move `next' entry to end of struct.
+ (CGEN_KEYWORD_MAX_ATTRS): Renamed from CGEN_MAX_KEYWORD_ATTRS.
+ (CGEN_OPERAND_MAX_ATTRS): Renamed from CGEN_MAX_OPERAND_ATTRS.
+
+Mon Feb 2 19:19:15 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * cgen.h: Correct typo in comment end marker.
+
+Mon Feb 2 17:10:38 1998 Steve Haworth <steve@pm.cse.rmit.EDU.AU>
+
+ * tic30.h: New file.
+
+Thu Jan 22 17:54:56 1998 Nick Clifton <nickc@cygnus.com>
+
+ * cgen.h: Add prototypes for cgen_save_fixups(),
+ cgen_restore_fixups(), and cgen_swap_fixups(). Change prototype
+ of cgen_asm_finish_insn() to return a char *.
+
+Wed Jan 14 17:21:43 1998 Nick Clifton <nickc@cygnus.com>
+
+ * cgen.h: Formatting changes to improve readability.
+
+Mon Jan 12 11:37:36 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen.h (*): Clean up pass over `struct foo' usage.
+ (CGEN_ATTR): Make unsigned char.
+ (CGEN_ATTR_TYPE): Update.
+ (CGEN_ATTR_{ENTRY,TABLE}): New types.
+ (cgen_base): Move member `attrs' to cgen_insn.
+ (CGEN_KEYWORD): New member `null_entry'.
+ (CGEN_{SYNTAX,FORMAT}): New types.
+ (cgen_insn): Format and syntax separated from each other.
+
+Tue Dec 16 15:15:52 1997 Michael Meissner <meissner@cygnus.com>
+
+ * d30v.h (d30v_opcode): Reorder flags somewhat, add new flags for
+ 2 word load/store, ADDppp/SUBppp, 16/32 bit multiply. Make
+ flags_{used,set} long.
+ (d30v_operand): Make flags field long.
+
+Mon Dec 1 12:24:44 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k.h: Fix comment describing operand types.
+
+Sun Nov 23 22:31:27 1997 Michael Meissner <meissner@cygnus.com>
+
+ * d30v.h (SHORT_CMPU): Add case for cmpu instruction, and move
+ everything else after down.
+
+Tue Nov 18 18:45:14 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * d10v.h (OPERAND_FLAG): Split into:
+ (OPERAND_FFLAG, OPERAND_CFLAG) .
+
+Thu Nov 13 11:04:24 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips.h (struct mips_opcode): Changed comments to reflect new
+ field usage.
+
+Fri Oct 24 22:36:20 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ * mips.h: Added to comments a quick-ref list of all assigned
+ operand type characters.
+ (OP_{MASK,SH}_PERFREG): New macros.
+
+Wed Oct 22 17:28:33 1997 Richard Henderson <rth@cygnus.com>
+
+ * sparc.h: Add '_' and '/' for v9a asr's.
+ Patch from David Miller <davem@vger.rutgers.edu>
+
+Tue Oct 14 13:22:29 1997 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h: Bit ops with absolute addresses not in the 8 bit
+ area are not available in the base model (H8/300).
+
+Thu Sep 25 13:03:41 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k.h: Remove documentation of ` operand specifier.
+
+Wed Sep 24 19:00:34 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k.h: Document q and v operand specifiers.
+
+Mon Sep 15 18:28:37 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (struct v850_opcode): Add processors field.
+ (PROCESSOR_V850, PROCESSOR_ALL): New bit constants.
+ (PROCESSOR_V850E, PROCESSOR_NOT_V850): New bit constants.
+ (PROCESSOR_V850EA): New bit constants.
+
+Mon Sep 15 11:29:43 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ Merge changes from Martin Hunt:
+
+ * d30v.h: Allow up to 64 control registers. Add
+ SHORT_A5S format.
+
+ * d30v.h (LONG_Db): New form for delayed branches.
+
+ * d30v.h: (LONG_Db): New form for repeati.
+
+ * d30v.h (SHORT_D2B): New form.
+
+ * d30v.h (SHORT_A2): New form.
+
+ * d30v.h (OPERAND_2REG): Add new operand to indicate 2
+ registers are used. Needed for VLIW optimization.
+
+Mon Sep 8 14:05:45 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen.h: Move assembler interface section
+ up so cgen_parse_operand_result is defined for cgen_parse_address.
+ (cgen_parse_address): Update prototype.
+
+Tue Sep 2 15:32:32 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (V850_OPREAND_ADJUST_SHORT_MEMORY): Removed.
+
+Tue Aug 26 12:21:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h (two_byte_segment_defaults): Correct base register 5 in
+ modes 1 and 2 to be ss rather than ds. From Gabriel Paubert
+ <paubert@iram.es>.
+
+ * i386.h: Set ud2 to 0x0f0b. From Gabriel Paubert
+ <paubert@iram.es>.
+
+ * i386.h: Comment fixes for ficom[p]?{s,l} from Gabriel Paubert
+ <paubert@iram.es>.
+
+ * i386.h (JUMP_ON_CX_ZERO): Uncomment (define again).
+ (JUMP_ON_ECX_ZERO): Remove commented out macro.
+
+Fri Aug 22 10:38:29 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (V850_NOT_R0): New flag.
+
+Mon Aug 18 11:05:58 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (struct v850_opcode): Remove flags field.
+
+Wed Aug 13 18:45:48 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850.h (struct v850_opcode): Add flags field.
+ (struct v850_operand): Extend meaning of 'bits' and 'shift'
+ fields.
+ (V850E_INSTRUCTION, V850EA_INSTRUCTION): New flags.
+ (V850E_PUSH_POP, V850E_IMMEDIATE16, V850E_IMMEDIATE32): New flags.
+
+Fri Aug 8 16:58:42 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * arc.h: New file.
+
+Thu Jul 24 21:16:58 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (sparc_opcodes): Declare as const.
+
+Thu Jul 10 12:53:25 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mips.h (FP_S, FP_D): Define. Bitmasks indicating if an insn
+ uses single or double precision floating point resources.
+ (INSN_NO_ISA, INSN_ISA1): Define.
+ (cpu specific INSN macros): Tweak into bitmasks outside the range
+ of INSN_ISA field.
+
+Mon Jun 16 14:10:00 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * i386.h: Fix pand opcode.
+
+Mon Jun 2 11:35:09 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips.h: Widen INSN_ISA and move it to a more convenient
+ bit position. Add INSN_3900.
+
+Tue May 20 11:25:29 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips.h (struct mips_opcode): added new field membership.
+
+Mon May 12 16:26:50 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * i386.h (movd): only Reg32 is allowed.
+
+ * i386.h: add fcomp and ud2. From Wayne Scott
+ <wscott@ichips.intel.com>.
+
+Mon May 5 17:16:21 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Add MMX instructions.
+
+Mon May 5 12:45:19 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * i386.h: Remove W modifier from conditional move instructions.
+
+Mon Apr 14 14:56:58 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Change the opcodes for fsubp, fsubrp, fdivp, and fdivrp
+ with no arguments to match that generated by the UnixWare
+ assembler.
+
+Thu Apr 10 14:35:00 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen.h (<cpu>_cgen_assemble_insn): New arg for errmsg.
+ (cgen_parse_operand_fn): Declare.
+ (cgen_init_parse_operand): Declare.
+ (cgen_parse_operand): Renamed from cgen_asm_parse_operand,
+ new argument `want'.
+ (enum cgen_parse_operand_result): Renamed from cgen_asm_result.
+ (enum cgen_parse_operand_type): New enum.
+
+Sat Apr 5 13:14:05 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Revert last patch for the NON_BROKEN_OPCODES cases.
+
+Fri Apr 4 11:46:11 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen.h: New file.
+
+Fri Apr 4 14:02:32 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Correct opcode values for fsubp, fsubrp, fdivp, and
+ fdivrp.
+
+Tue Mar 25 22:57:26 1997 Stu Grossman (grossman@critters.cygnus.com)
+
+ * v850.h (extract): Make unsigned.
+
+Mon Mar 24 14:38:15 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Add iclr.
+
+Thu Mar 20 19:49:10 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Change DW to W for cmpxchg and xadd, since they don't
+ take a direction bit.
+
+Sat Mar 15 19:03:29 1997 H.J. Lu <hjl@lucon.org>
+
+ * sparc.h (sparc_opcode_lookup_arch): Use full prototype.
+
+Fri Mar 14 15:22:01 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc.h: Include <ansidecl.h>. Update function declarations to
+ use prototypes, and to use const when appropriate.
+
+Thu Mar 6 14:18:30 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_RELAX): Define.
+
+Mon Feb 24 15:15:56 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h: Change pre_defined_registers to
+ d10v_predefined_registers and reg_name_cnt to d10v_reg_name_cnt.
+
+Sat Feb 22 21:25:00 1997 Dawn Perchik <dawn@cygnus.com>
+
+ * mips.h: Add macros for cop0, cop1 cop2 and cop3.
+ Change mips_opcodes from const array to a pointer,
+ and change bfd_mips_num_opcodes from const int to int,
+ so that we can increase the size of the mips opcodes table
+ dynamically.
+
+Fri Feb 21 16:34:18 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d30v.h (FLAG_X): Remove unused flag.
+
+Tue Feb 18 17:37:20 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d30v.h: New file.
+
+Fri Feb 14 13:16:15 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (PDS_NAME): Macro to access name field of predefined symbols.
+ (PDS_VALUE): Macro to access value field of predefined symbols.
+ (tic80_next_predefined_symbol): Add prototype.
+
+Mon Feb 10 10:32:17 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (tic80_symbol_to_value): Change prototype to match
+ change in function, added class parameter.
+
+Thu Feb 6 17:30:15 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_OPERAND_ENDMASK): Add for flagging TIc80
+ endmask fields, which are somewhat weird in that 0 and 32 are
+ treated exactly the same.
+
+Thu Jan 30 13:46:18 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h: Change all the OPERAND defines to use the form (1 << X)
+ rather than a constant that is 2**X. Reorder them to put bits for
+ operands that have symbolic names in the upper bits, so they can
+ be packed into an int where the lower bits contain the value that
+ corresponds to that symbolic name.
+ (predefined_symbo): Add struct.
+ (tic80_predefined_symbols): Declare array of translations.
+ (tic80_num_predefined_symbols): Declare size of that array.
+ (tic80_value_to_symbol): Declare function.
+ (tic80_symbol_to_value): Declare function.
+
+Wed Jan 29 09:37:25 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200.h (MN10200_OPERAND_RELAX): Define.
+
+Sat Jan 18 15:18:59 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_NO_R0_DEST): Add for opcodes where r0 cannot
+ be the destination register.
+
+Thu Jan 16 20:48:55 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (struct tic80_opcode): Change "format" field to "flags".
+ (FMT_UNUSED, FMT_SI, FMT_LI, FMT_REG): Delete.
+ (TIC80_VECTOR): Define a flag bit for the flags. This one means
+ that the opcode can have two vector instructions in a single
+ 32 bit word and we have to encode/decode both.
+
+Tue Jan 14 19:37:09 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_OPERAND_PCREL): Renamed from
+ TIC80_OPERAND_RELATIVE for PC relative.
+ (TIC80_OPERAND_BASEREL): New flag bit for register
+ base relative.
+
+Mon Jan 13 15:56:38 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_OPERAND_FLOAT): Add for floating point operands.
+
+Mon Jan 6 10:51:15 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_OPERAND_SCALED): Operand may have optional
+ ":s" modifier for scaling.
+
+Sun Jan 5 12:12:19 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_OPERAND_M_SI): Add operand modifier for ":m".
+ (TIC80_OPERAND_M_LI): Ditto
+
+Sat Jan 4 19:02:44 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (TIC80_OPERAND_BITNUM): Renamed from TIC80_OPERAND_CC_SZ.
+ (TIC80_OPERAND_CC): New define for condition code operand.
+ (TIC80_OPERAND_CR): New define for control register operand.
+
+Fri Jan 3 16:22:23 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h (struct tic80_opcode): Name changed.
+ (struct tic80_opcode): Remove format field.
+ (struct tic80_operand): Add insertion and extraction functions.
+ (TIC80_OPERAND_*): Remove old bogus values, start adding new
+ correct ones.
+ (FMT_*): Ditto.
+
+Tue Dec 31 15:05:41 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * v850.h (V850_OPERAND_ADJUST_SHORT_MEMORY): New flag to adjust
+ type IV instruction offsets.
+
+Fri Dec 27 22:23:10 1996 Fred Fish <fnf@cygnus.com>
+
+ * tic80.h: New file.
+
+Wed Dec 18 10:06:31 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200.h (MN10200_OPERAND_NOCHECK): Define.
+
+Sat Dec 14 10:48:31 1996 Fred Fish <fnf@ninemoons.com>
+
+ * mn10200.h: Fix comment, mn10200_operand not powerpc_operand.
+ * mn10300.h: Fix comment, mn10300_operand not powerpc_operand.
+ * v850.h: Fix comment, v850_operand not powerpc_operand.
+
+Mon Dec 9 16:45:39 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200.h: Flesh out structures and definitions needed by
+ the mn10200 assembler & disassembler.
+
+Tue Nov 26 10:46:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h: Add mips16 definitions.
+
+Mon Nov 25 17:56:54 1996 J.T. Conklin <jtc@cygnus.com>
+
+ * m68k.h: Document new <, >, m, n, o and p operand specifiers.
+
+Wed Nov 20 10:59:41 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_PCREL): Define.
+ (MN10300_OPERAND_MEMADDR): Define.
+
+Tue Nov 19 13:30:40 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_REG_LIST): Define.
+
+Wed Nov 6 13:41:08 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_SPLIT): Define.
+
+Tue Nov 5 13:26:12 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_EXTENDED): Define.
+
+Mon Nov 4 12:52:48 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_REPEATED): Define.
+
+Fri Nov 1 10:31:02 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha.h: Don't include "bfd.h"; private relocation types are now
+ negative to minimize problems with shared libraries. Organize
+ instruction subsets by AMASK extensions and PALcode
+ implementation.
+ (struct alpha_operand): Move flags slot for better packing.
+
+Tue Oct 29 12:19:10 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850.h (V850_OPERAND_RELAX): New operand flag.
+
+Thu Oct 10 14:29:11 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (FMT_*): Move operand format definitions
+ here.
+
+Tue Oct 8 14:48:07 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (MN10300_OPERAND_PAREN): Define.
+
+Mon Oct 7 16:52:11 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300.h (mn10300_opcode): Add "format" field.
+ (MN10300_OPERAND_*): Define.
+
+Thu Oct 3 10:33:46 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10x00.h: Delete.
+ * mn10200.h, mn10300.h: New files.
+
+Wed Oct 2 21:31:26 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10x00.h: New file.
+
+Fri Sep 27 18:26:46 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * v850.h: Add new flag to indicate this instruction uses a PC
+ displacement.
+
+Fri Sep 13 14:58:13 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (stmac): Add missing instruction.
+
+Sat Aug 31 16:02:03 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850.h (v850_opcode): Remove "size" field. Add "memop"
+ field.
+
+Fri Aug 23 10:39:08 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850.h (V850_OPERAND_EP): Define.
+
+ * v850.h (v850_opcode): Add size field.
+
+Thu Aug 22 16:51:25 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * v850.h (v850_operands): Add insert and extract fields, pointers
+ to functions used to handle unusual operand encoding.
+ (V850_OPERAND_REG, V850_OPERAND_SRG, V850_OPERAND_CC,
+ V850_OPERAND_SIGNED): Defined.
+
+Wed Aug 21 17:45:10 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * v850.h (v850_operands): Add flags field.
+ (OPERAND_REG, OPERAND_NUM): Defined.
+
+Tue Aug 20 14:52:02 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * v850.h: New file.
+
+Fri Aug 16 14:44:15 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * mips.h (OP_SH_LOCC, OP_SH_HICC, OP_MASK_CC, OP_SH_COP1NORM,
+ OP_MASK_COP1NORM, OP_SH_COP1SPEC, OP_MASK_COP1SPEC,
+ OP_MASK_COP1SCLR, OP_MASK_COP1CMP, OP_SH_COP1CMP, OP_SH_FORMAT,
+ OP_MASK_FORMAT, OP_SH_TRUE, OP_MASK_TRUE, OP_SH_GE, OP_MASK_GE,
+ OP_SH_UNSIGNED, OP_MASK_UNSIGNED, OP_SH_HINT, OP_MASK_HINT):
+ Defined.
+
+Fri Aug 16 00:15:15 1996 Jeffrey A Law (law@cygnus.com)
+
+ * hppa.h (pitlb, pitlbe, iitlba, iitlbp, fic, fice): Accept
+ a 3 bit space id instead of a 2 bit space id.
+
+Thu Aug 15 13:11:46 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h: Add some additional defines to support the
+ assembler in determining which operations can be done in parallel.
+
+Tue Aug 6 11:13:22 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (SN): Define.
+ (eepmov.b): Renamed from "eepmov"
+ (nop, bpt, rte, rts, sleep, clrmac): These have no size associated
+ with them.
+
+Fri Jul 26 11:47:10 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h (OPERAND_SHIFT): New operand flag.
+
+Thu Jul 25 12:06:22 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h: Changes for divs, parallel-only instructions, and
+ signed numbers.
+
+Mon Jul 22 11:21:15 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h (pd_reg): Define. Putting the definition here allows
+ the assembler and disassembler to share the same struct.
+
+Mon Jul 22 12:15:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i960.h (i960_opcodes): "halt" takes an argument. From Stephen
+ Williams <steve@icarus.com>.
+
+Wed Jul 17 14:46:38 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v.h: New file.
+
+Thu Jul 11 12:09:15 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (band, bclr): Force high bit of immediate nibble to zero.
+
+Wed Jul 3 14:30:12 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * m68k.h (mcf5200): New macro.
+ Document names of coldfire control registers.
+
+Tue Jul 2 23:05:45 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (SRC_IN_DST): Define.
+
+ * h8300.h (UNOP3): Mark the register operand in this insn
+ as a source operand, not a destination operand.
+ (SHIFT_2, SHIFT_IMM): Remove. Eliminate all references.
+ (UNOP3): Change SHIFT_IMM to IMM for H8/S bitops. Mark
+ register operand with SRC_IN_DST.
+
+Fri Jun 21 13:52:17 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha.h: New file.
+
+Thu Jun 20 15:02:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rs6k.h: Remove obsolete file.
+
+Wed Jun 19 15:29:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Correct opcode values for faddp, fsubp, fsubrp, fmulp,
+ fdivp, and fdivrp. Add ffreep.
+
+Tue Jun 18 16:06:00 1996 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * h8300.h: Reorder various #defines for readability.
+ (ABS32SRC, ABS32DST, DSP32LIST, ABS32LIST, A32LIST): Define.
+ (BITOP): Accept additional (unused) argument. All callers changed.
+ (EBITOP): Likewise.
+ (O_LAST): Bump.
+ (ldc, stc, movb, movw, movl): Use 32bit offsets and absolutes.
+
+ * h8300.h (EXR, SHIFT_2, MACREG, SHIFT_IMM, RDINC): Define.
+ (O_TAS, O_CLRMAC, O_LDMAC, O_MAC, O_LDM, O_STM): Define.
+ (BITOP, EBITOP): Handle new H8/S addressing modes for
+ bit insns.
+ (UNOP3): Handle new shift/rotate insns on the H8/S.
+ (insns using exr): New instructions.
+ (tas, mac, ldmac, clrmac, ldm, stm): New instructions.
+
+Thu May 23 16:56:48 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (add.l): Undo Apr 5th change. The manual I had
+ was incorrect.
+
+Mon May 6 23:38:22 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (START): Remove.
+ (MEMRELAX): Define. Mark absolute memory operands in mov.b, mov.w
+ and mov.l insns that can be relaxed.
+
+Tue Apr 30 18:30:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386.h: Remove Abs32 from lcall.
+
+Mon Apr 22 17:09:23 1996 Doug Evans <dje@blues.cygnus.com>
+
+ * sparc.h (SPARC_OPCODE_ARCH_V9_P): New macro.
+ (SLCPOP): New macro.
+ Mark X,Y opcode letters as in use.
+
+Thu Apr 11 17:28:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc.h (F_FLOAT, F_FBR): Define.
+
+Fri Apr 5 16:55:34 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300.h (ABS8MEM): Renamed from ABSMOV. Remove ABSMOV
+ from all insns.
+ (ABS8SRC,ABS8DST): Add ABS8MEM.
+ (add.l): Fix reg+reg variant.
+ (eepmov.w): Renamed from eepmovw.
+ (ldc,stc): Fix many cases.
+
+Sun Mar 31 13:30:03 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (SPARC_OPCODE_ARCH_MASK): New macro.
+
+Thu Mar 7 15:08:23 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (O): Mark operand letter as in use.
+
+Tue Feb 20 20:46:21 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (sparc_{encode,decode}_sparclet_cpreg): Declare.
+ Mark operand letters uU as in use.
+
+Mon Feb 19 01:59:08 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (sparc_opcode_arch_val): Add SPARC_OPCODE_ARCH_SPARCLET.
+ (sparc_opcode_arch): Delete member `conflicts'. Add `supported'.
+ (SPARC_OPCODE_SUPPORTED): New macro.
+ (SPARC_OPCODE_CONFLICT_P): Rewrite.
+ (F_NOTV9): Delete.
+
+Fri Feb 16 12:23:34 1996 Jeffrey A Law (law@cygnus.com)
+
+ * sparc.h (sparc_opcode_lookup_arch) Make return type in
+ declaration consistent with return type in definition.
+
+Wed Feb 14 18:14:11 1996 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386.h (i386_optab): Remove Data32 from pushf and popf.
+
+Thu Feb 8 14:27:21 1996 James Carlson <carlson@xylogics.com>
+
+ * i386.h (i386_regtab): Add 80486 test registers.
+
+Mon Feb 5 18:35:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i960.h (I_HX): Define.
+ (i960_opcodes): Add HX instruction.
+
+Mon Jan 29 12:43:39 1996 Ken Raeburn <raeburn@cygnus.com>
+
+ * i386.h: Fix waiting forms of finit, fstenv, fsave, fstsw, fstcw,
+ and fclex.
+
+Wed Jan 24 22:36:59 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (enum sparc_opcode_arch_val): Replaces sparc_architecture.
+ (SPARC_OPCODE_CONFLICT_P): Renamed from ARCHITECTURES_CONFLICT_P.
+ (bfd_* defines): Delete.
+ (sparc_opcode_archs): Replaces architecture_pname.
+ (sparc_opcode_lookup_arch): Declare.
+ (NUMOPCODES): Delete.
+
+Mon Jan 22 08:24:32 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc.h (enum sparc_architecture): Add v9a.
+ (ARCHITECTURES_CONFLICT_P): Update.
+
+Thu Dec 28 13:27:53 1995 John Hassey <hassey@rtp.dg.com>
+
+ * i386.h: Added Pentium Pro instructions.
+
+Thu Nov 2 22:59:22 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k.h: Document new 'W' operand place.
+
+Tue Oct 24 10:49:10 1995 Jeffrey A Law (law@cygnus.com)
+
+ * hppa.h: Add lci and syncdma instructions.
+
+Mon Oct 23 11:09:16 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
+
+ * mips.h: Added INSN_4100 flag to mark NEC VR4100 specific
+ instructions.
+
+Mon Oct 16 10:28:15 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc.h (PPC_OPCODE_{COMMON,ANY}): New opcode flags for
+ assembler's -mcom and -many switches.
+
+Wed Oct 11 16:56:33 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * i386.h: Fix cmpxchg8b extension opcode description.
+
+Thu Oct 5 18:03:36 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * i386.h: Add Pentium instructions wrmsr, rdtsc, rdmsr, cmpxchg8b,
+ and register cr4.
+
+Tue Sep 19 15:26:43 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k.h: Change comment: split type P into types 0, 1 and 2.
+
+Wed Aug 30 13:50:55 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (sparc_{encode,decode}_prefetch): Declare.
+
+Tue Aug 29 15:34:58 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (sparc_{encode,decode}_{asi,membar}): Declare.
+
+Wed Aug 2 18:32:19 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68kmri.h: Remove.
+
+ * m68k.h: Move tables into opcodes/m68k-opc.c, leaving just the
+ declarations. Remove F_ALIAS and flag field of struct
+ m68k_opcode. Change arch field of struct m68k_opcode to unsigned
+ int. Make name and args fields of struct m68k_opcode const.
+
+Wed Aug 2 08:16:46 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc.h (F_NOTV9): Define.
+
+Tue Jul 11 14:20:42 1995 Jeff Spiegel <jeffs@lsil.com>
+
+ * mips.h (INSN_4010): Define.
+
+Wed Jun 21 18:49:51 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * m68k.h (TBL1): Reverse sense of "round" argument in result.
+
+ Changes from Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>:
+ * m68k.h: Fix argument descriptions of coprocessor
+ instructions to allow only alterable operands where appropriate.
+ [!NO_DEFAULT_SIZES]: An omitted size defaults to `w'.
+ (m68k_opcode_aliases): Add more aliases.
+
+Fri Apr 14 22:15:34 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * m68k.h: Added explcitly short-sized conditional branches, and a
+ bunch of aliases (fmov*, ftest*, tdivul) to support gcc's
+ svr4-based configurations.
+
+Mon Mar 13 21:30:01 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Mon Feb 27 08:36:39 1995 Bryan Ford <baford@cs.utah.edu>
+ * i386.h: added missing Data16/Data32 flags to a few instructions.
+
+Wed Mar 8 15:19:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (OP_MASK_FR, OP_SH_FR): Define.
+ (OP_MASK_BCC, OP_SH_BCC): Define.
+ (OP_MASK_PREFX, OP_SH_PREFX): Define.
+ (OP_MASK_CCC, OP_SH_CCC): Define.
+ (INSN_READ_FPR_R): Define.
+ (INSN_RFE): Delete.
+
+Wed Mar 8 03:13:23 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * m68k.h (enum m68k_architecture): Deleted.
+ (struct m68k_opcode_alias): New type.
+ (m68k_opcodes): Now const. Deleted opcode aliases with exactly
+ matching constraints, values and flags. As a side effect of this,
+ the MOTOROLA_SYNTAX_ONLY and MIT_SYNTAX_ONLY macros, which so far
+ as I know were never used, now may need re-examining.
+ (numopcodes): Now const.
+ (m68k_opcode_aliases, numaliases): New variables.
+ (endop): Deleted.
+ [DONT_DEFINE_TABLE]: Declare numopcodes, numaliases, and
+ m68k_opcode_aliases; update declaration of m68k_opcodes.
+
+Mon Mar 6 10:02:00 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppa.h (delay_type): Delete unused enumeration.
+ (pa_opcode): Replace unused delayed field with an architecture
+ field.
+ (pa_opcodes): Mark each instruction as either PA1.0 or PA1.1.
+
+Fri Mar 3 16:10:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (INSN_ISA4): Define.
+
+Fri Feb 24 19:13:37 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (M_DLA_AB, M_DLI): Define.
+
+Thu Feb 23 17:33:09 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppa.h (fstwx): Fix single-bit error.
+
+Wed Feb 15 12:19:52 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips.h (M_ULD, M_ULD_A, M_USD, M_USD_A): Define.
+
+Mon Feb 6 10:35:23 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * i386.h: added cpuid instruction , and dr[0-7] aliases for the
+ debug registers. From Charles Hannum (mycroft@netbsd.org).
+
+Mon Feb 6 03:31:54 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Changes from Bryan Ford <baford@schirf.cs.utah.edu> for 16-bit
+ i386 support:
+ * i386.h (MOV_AX_DISP32): New macro.
+ (i386_optab): Added Data16 and Data32 as needed. Added "w" forms
+ of several call/return instructions.
+ (ADDR_PREFIX_OPCODE): New macro.
+
+Mon Jan 23 16:45:43 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ Sat Jan 21 17:50:38 1995 Pat Rankin (rankin@eql.caltech.edu)
+
+ * ../include/opcode/vax.h (struct vot_wot, field `args'): make
+ it pointer to const char;
+ (struct vot, field `name'): ditto.
+
+Thu Jan 19 14:47:53 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * vax.h: Supply and properly group all values in end sentinel.
+
+Tue Jan 17 10:55:30 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * mips.h (INSN_ISA, INSN_4650): Define.
+
+Wed Oct 19 13:34:17 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * a29k.h: Add operand type 'I' for `inv' and `iretinv'. On
+ systems with a separate instruction and data cache, such as the
+ 29040, these instructions take an optional argument.
+
+Wed Sep 14 17:44:20 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * mips.h (INSN_STORE_MEMORY): Correct value to not conflict with
+ INSN_TRAP.
+
+Tue Sep 6 11:39:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * mips.h (INSN_STORE_MEMORY): Define.
+
+Thu Jul 28 19:28:07 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * sparc.h: Document new operand type 'x'.
+
+Tue Jul 26 17:48:05 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i960.h (I_CX2): New instruction category. It includes
+ instructions available on Cx and Jx processors.
+ (I_JX): New instruction category, for JX-only instructions.
+ (i960_opcodes): Put eshro and sysctl in I_CX2 category. Added
+ Jx-only instructions, in I_JX category.
+
+Wed Jul 13 18:43:47 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * ns32k.h (endop): Made pointer const too.
+
+Sun Jul 10 11:01:09 1994 Ian Dall (dall@hfrd.dsto.gov.au)
+
+ * ns32k.h: Drop Q operand type as there is no correct use
+ for it. Add I and Z operand types which allow better checking.
+
+Thu Jul 7 12:34:48 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * h8300.h (xor.l) :fix bit pattern.
+ (L_2): New size of operand.
+ (trapa): Use it.
+
+Fri Jun 10 16:38:11 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m68k.h: Move "trap" before "tpcc" to change disassembly.
+
+Fri Jun 3 15:57:36 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * sparc.h: Include v9 definitions.
+
+Thu Jun 2 12:23:17 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * m68k.h (m68060): Defined.
+ (m68040up, mfloat, mmmu): Include it.
+ (struct m68k_opcode): Widen `arch' field.
+ (m68k_opcodes): Updated for M68060. Removed comments that were
+ instructions commented out by "JF" years ago.
+
+Thu Apr 28 18:31:14 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * m68k.h (struct m68k_opcode): Shorten `arch' field to 8 bits, and
+ add a one-bit `flags' field.
+ (F_ALIAS): New macro.
+
+Wed Apr 27 11:29:52 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * h8300.h (dec, inc): Get encoding right.
+
+Mon Apr 4 13:12:43 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc.h (struct powerpc_operand): Removed signedp field; just use
+ a flag instead.
+ (PPC_OPERAND_SIGNED): Define.
+ (PPC_OPERAND_SIGNOPT): Define.
+
+Thu Mar 31 19:34:08 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i386.h (IS_JUMP_ON_ECX_ZERO, "jcxz" pattern): Operand size
+ prefix is 0x66, not 0x67. Patch from H.J. Lu (hlu@nynexst.com).
+
+Thu Mar 3 15:51:05 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i386.h: Reverse last change. It'll be handled in gas instead.
+
+Thu Feb 24 15:29:05 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i386.h (sar): Disabled the two-operand Imm1 form, since it was
+ slower on the 486 and used the implicit shift count despite the
+ explicit operand. The one-operand form is still available to get
+ the shorter form with the implicit shift count.
+
+Thu Feb 17 12:27:52 1994 Torbjorn Granlund (tege@mexican.cygnus.com)
+
+ * hppa.h: Fix typo in fstws arg string.
+
+Wed Feb 9 21:23:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc.h (struct powerpc_opcode): Make operands field unsigned.
+
+Mon Feb 7 19:14:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc.h (PPC_OPCODE_601): Define.
+
+Fri Feb 4 23:43:50 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * hppa.h (addb): Use '@' for addb and addib pseudo ops.
+ (so we can determine valid completers for both addb and addb[tf].)
+
+ * hppa.h (xmpyu): No floating point format specifier for the
+ xmpyu instruction.
+
+Fri Feb 4 23:36:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc.h (PPC_OPERAND_NEXT): Define.
+ (PPC_OPERAND_NEGATIVE): Change value to make room for above.
+ (struct powerpc_macro): Define.
+ (powerpc_macros, powerpc_num_macros): Declare.
+
+Fri Jan 21 19:13:50 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc.h: New file. Header file for PowerPC opcode table.
+
+Mon Jan 17 00:14:23 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * hppa.h: More minor template fixes for sfu and copr (to allow
+ for easier disassembly).
+
+ * hppa.h: Fix templates for all the sfu and copr instructions.
+
+Wed Dec 15 15:12:42 1993 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i386.h (push): Permit Imm16 operand too.
+
+Sat Dec 11 16:14:06 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * h8300.h (andc): Exists in base arch.
+
+Wed Dec 1 12:15:32 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * From Hisashi MINAMINO <minamino@sramhc.sra.co.jp>
+ * hppa.h: #undef NONE to avoid conflict with hiux include files.
+
+Sun Nov 21 22:06:57 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * hppa.h: Add FP quadword store instructions.
+
+Wed Nov 17 17:13:16 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h: (M_J_A): Added.
+ (M_LA): Removed.
+
+Mon Nov 8 12:12:47 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (OP_MASK_CACHE, OP_SH_CACHE): Define. From Ted Lemon
+ <mellon@pepper.ncd.com>.
+
+Sun Nov 7 00:30:11 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * hppa.h: Immediate field in probei instructions is unsigned,
+ not low-sign extended.
+
+Wed Nov 3 10:30:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * m88k.h (RRI10MASK): Change from 0xfc00ffe0 to 0xfc00fc00.
+
+Tue Nov 2 12:41:30 1993 Ken Raeburn (raeburn@rover.cygnus.com)
+
+ * i386.h: Add "fxch" without operand.
+
+Mon Nov 1 18:13:03 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (M_JAL_1, M_JAL_2, M_JAL_A): Added.
+
+Sat Oct 2 22:26:11 1993 Jeffrey A Law (law@snake.cs.utah.edu)
+
+ * hppa.h: Add gfw and gfr to the opcode table.
+
+Wed Sep 29 16:23:00 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * m88k.h: extended to handle m88110.
+
+Tue Sep 28 19:19:08 1993 Jeffrey A Law (law@snake.cs.utah.edu)
+
+ * hppa.h (be, ble): Use operand type 'z' to denote absolute branch
+ addresses.
+
+Tue Sep 14 14:04:35 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * i960.h (i960_opcodes): Properly bracket initializers.
+
+Mon Sep 13 12:50:52 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * m88k.h (BOFLAG): rewrite to avoid nested comment.
+
+Mon Sep 13 15:46:06 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m68k.h (two): Protect second argument with parentheses.
+
+Fri Sep 10 16:29:47 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * i386.h (i386_optab): Added new instruction "rsm" (for i386sl).
+ Deleted old in/out instructions in "#if 0" section.
+
+Thu Sep 9 17:42:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * i386.h (i386_optab): Properly bracket initializers.
+
+Wed Aug 25 13:50:56 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hppa.h (pa_opcode): Use '|' for movb and movib insns. (From
+ Jeff Law, law@cs.utah.edu).
+
+Mon Aug 23 16:55:03 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * i386.h (lcall): Accept Imm32 operand also.
+
+Mon Aug 23 12:43:11 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (M_ABSU): Removed (absolute value of unsigned number??).
+ (M_DABS): Added.
+
+Thu Aug 19 15:08:37 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h (INSN_*): Changed values. Removed unused definitions.
+ Added INSN_COND_BRANCH_LIKELY, INSN_ISA2 and INSN_ISA3. Split
+ INSN_LOAD_DELAY into INSN_LOAD_MEMORY_DELAY and
+ INSN_LOAD_COPROC_DELAY. Split INSN_COPROC_DELAY into
+ INSN_COPROC_MOVE_DELAY and INSN_COPROC_MEMORY_DELAY.
+ (M_*): Added new values for r6000 and r4000 macros.
+ (ANY_DELAY): Removed.
+
+Wed Aug 18 15:37:48 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h: Added M_LI_S and M_LI_SS.
+
+Tue Aug 17 07:08:08 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * h8300.h: Get some rare mov.bs correct.
+
+Thu Aug 5 09:15:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * sparc.h: Don't define const ourself; rely on ansidecl.h having
+ been included.
+
+Fri Jul 30 18:41:11 1993 John Gilmore (gnu@cygnus.com)
+
+ * sparc.h (F_JSR, F_UNBR, F_CONDBR): Add new flags to mark
+ jump instructions, for use in disassemblers.
+
+Thu Jul 22 07:25:27 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * m88k.h: Make bitfields just unsigned, not unsigned long or
+ unsigned short.
+
+Wed Jul 21 11:55:31 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * hppa.h: New argument type 'y'. Use in various float instructions.
+
+Mon Jul 19 17:17:03 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * hppa.h (break): First immediate field is unsigned.
+
+ * hppa.h: Add rfir instruction.
+
+Sun Jul 18 16:28:08 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * mips.h: Split the actual table out into ../../opcodes/mips-opc.c.
+
+Fri Jul 16 09:59:29 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h: Reworked the hazard information somewhat, and fixed some
+ bugs in the instruction hazard descriptions.
+
+Thu Jul 15 12:42:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m88k.h: Corrected a couple of opcodes.
+
+Tue Jul 6 15:17:35 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips.h: Replaced with version from Ralph Campbell and OSF. The
+ new version includes instruction hazard information, but is
+ otherwise reasonably similar.
+
+Thu Jul 1 20:36:17 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * h8300.h: Fix typo in UNOP3 (affected sh[al][lr].l).
+
+Fri Jun 11 18:38:44 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ Patches from Jeff Law, law@cs.utah.edu:
+ * hppa.h: Clean up some of the OLD_TABLE, non-OLD_TABLE braindamage.
+ Make the tables be the same for the following instructions:
+ "bb", "addb[tf]", "addib[tf]", "add", "add[loc]", "addco",
+ "sh[123]add", "sh[123]add[lo]", "sub", "sub[obt]", "sub[bt]o",
+ "ds", "comclr", "addi", "addi[ot]", "addito", "subi", "subio",
+ "comiclr", "fadd", "fsub", "fmpy", "fdiv", "fsqrt", "fabs",
+ "frnd", "fcpy", "fcnvff", "fcnvxf", "fcnvfx", "fcnvfxt",
+ "fcmp", and "ftest".
+
+ * hppa.h: Make new and old tables the same for "break", "mtctl",
+ "mfctl", "bb", "ssm", "rsm", "xmpyu", "fmpyadd", "fmpysub".
+ Fix typo in last patch. Collapse several #ifdefs into a
+ single #ifdef.
+
+ * hppa.h: Delete remaining OLD_TABLE code. Bring some
+ of the comments up-to-date.
+
+ * hppa.h: Update "free list" of letters and update
+ comments describing each letter's function.
+
+Fri Jun 4 15:41:37 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * h8300.h: checkpoint, includes H8/300-H opcodes.
+
+Thu Jun 3 15:42:59 1993 Stu Grossman (grossman@cygnus.com)
+
+ * Patches from Jeffrey Law <law@cs.utah.edu>.
+ * hppa.h: Rework single precision FP
+ instructions so that they correctly disassemble code
+ PA1.1 code.
+
+Thu May 27 19:21:22 1993 Bruce Bauman (boot@osf.org)
+
+ * i386.h (i386_optab, mov pattern): Remove Mem16 restriction from
+ mov to allow instructions like mov ss,xyz(ecx) to assemble.
+
+Tue May 25 00:39:40 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * hppa.h: Use new version from Utah if OLD_TABLE isn't defined;
+ gdb will define it for now.
+
+Mon May 24 15:20:06 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * sparc.h: Don't end enumerator list with comma.
+
+Fri May 14 15:15:50 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Based on patches from davidj@ICSI.Berkeley.EDU (David Johnson):
+ * mips.h (OP_MASK_COPZ, OP_SH_COPZ): Define.
+ ("bc2t"): Correct typo.
+ ("[ls]wc[023]"): Use T rather than t.
+ ("c[0123]"): Define general coprocessor instructions.
+
+Mon May 10 06:02:25 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * m68k.h: Move split point for gcc compilation more towards
+ middle.
+
+Fri Apr 9 13:26:16 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * rs6k.h: Clean up instructions for primary opcode 19 (many were
+ simply wrong, ics, rfi, & rfsvc were missing).
+ Add "a" to opr_ext for "bb". Doc fix.
+
+Thu Mar 18 13:45:31 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * i386.h: 486 extensions from John Hassey (hassey@dg-rtp.dg.com).
+ * mips.h: Add casts, to suppress warnings about shifting too much.
+ * m68k.h: Document the placement code '9'.
+
+Thu Feb 18 02:03:14 1993 John Gilmore (gnu@cygnus.com)
+
+ * m68k.h (BREAK_UP_BIG_DECL, AND_OTHER_PART): Add kludge which
+ allows callers to break up the large initialized struct full of
+ opcodes into two half-sized ones. This permits GCC to compile
+ this module, since it takes exponential space for initializers.
+ (numopcodes, endop): Revise to use AND_OTHER_PART in size calcs.
+
+Thu Feb 4 02:06:56 1993 John Gilmore (gnu@cygnus.com)
+
+ * a29k.h: Remove RCS crud, update GPL to v2, update copyrights.
+ * convex.h: Added, from GDB's convx-opcode.h. Added CONST to all
+ initialized structs in it.
+
+Thu Jan 28 21:32:22 1993 John Gilmore (gnu@cygnus.com)
+
+ Delta 88 changes inspired by Carl Greco, <cgreco@Creighton.Edu>:
+ * m88k.h (PMEM): Avoid previous definition from <sys/param.h>.
+ (AND): Change to AND_ to avoid ansidecl.h `AND' conflict.
+
+Sat Jan 23 18:10:49 PST 1993 Ralph Campbell (ralphc@pyramid.com)
+
+ * mips.h: document "i" and "j" operands correctly.
+
+Thu Jan 7 15:58:13 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips.h: Removed endianness dependency.
+
+Sun Jan 3 14:13:35 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * h8300.h: include info on number of cycles per instruction.
+
+Mon Dec 21 21:29:08 1992 Stu Grossman (grossman at cygnus.com)
+
+ * hppa.h: Move handy aliases to the front. Fix masks for extract
+ and deposit instructions.
+
+Sat Dec 12 16:09:48 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * i386.h: accept shld and shrd both with and without the shift
+ count argument, which is always %cl.
+
+Fri Nov 27 17:13:18 1992 Ken Raeburn (raeburn at cygnus.com)
+
+ * i386.h (i386_optab_end, i386_regtab_end): Now const.
+ (one_byte_segment_defaults, two_byte_segment_defaults,
+ i386_prefixtab_end): Ditto.
+
+Mon Nov 23 10:47:25 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * vax.h (bb*): Use "v" (bitfield type), not "a" (address operand)
+ for operand 2; from John Carr, jfc@dsg.dec.com.
+
+Wed Nov 4 07:36:49 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * m68k.h: Define FIXED_SIZE_BRANCH, so bsr and bra instructions
+ always use 16-bit offsets. Makes calculated-size jump tables
+ feasible.
+
+Fri Oct 16 22:52:43 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * i386.h: Fix one-operand forms of in* and out* patterns.
+
+Tue Sep 22 14:08:14 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * m68k.h: Added CPU32 support.
+
+Tue Sep 22 00:38:41 1992 John Gilmore (gnu@cygnus.com)
+
+ * mips.h (break): Disassemble the argument. Patch from
+ jonathan@cs.stanford.edu (Jonathan Stone).
+
+Wed Sep 9 11:25:28 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * m68k.h: merged Motorola and MIT syntax.
+
+Thu Sep 3 09:33:22 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * m68k.h (pmove): make the tests less strict, the 68k book is
+ wrong.
+
+Tue Aug 25 23:25:19 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * m68k.h (m68ec030): Defined as alias for 68030.
+ (m68k_opcodes): New type characters "3" for 68030 MMU regs and "t"
+ for immediate 0-7 added. Set up some opcodes (ptest, bkpt) to use
+ them. Tightened description of "fmovex" to distinguish it from
+ some "pmove" encodings. Added "pmove" for 68030 MMU regs, cleaned
+ up descriptions that claimed versions were available for chips not
+ supporting them. Added "pmovefd".
+
+Mon Aug 24 12:04:51 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * m68k.h: fix where the . goes in divull
+
+Wed Aug 19 11:22:24 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * m68k.h: the cas2 instruction is supposed to be written with
+ indirection on the last two operands, which can be either data or
+ address registers. Added a new operand type 'r' which accepts
+ either register type. Added new cases for cas2l and cas2w which
+ use them. Corrected masks for cas2 which failed to recognize use
+ of address register.
+
+Fri Aug 14 14:20:38 1992 Per Bothner (bothner@cygnus.com)
+
+ * m68k.h: Merged in patches (mostly m68040-specific) from
+ Colin Smith <colin@wrs.com>.
+
+ * m68k.h: Merged m68kmri.h and m68k.h (using the former as a
+ base). Also cleaned up duplicates, re-ordered instructions for
+ the sake of dis-assembling (so aliases come after standard names).
+ * m68kmri.h: Now just defines some macros, and #includes m68k.h.
+
+Wed Aug 12 16:38:15 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * m68kmri.h: added various opcodes. Moved jbxx to bxxes. Filled in
+ all missing .s
+
+Mon Aug 10 23:22:33 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * sparc.h: Moved tables to BFD library.
+
+ * i386.h (i386_optab): Add fildq, fistpq aliases used by gcc.
+
+Sun Jun 28 13:29:03 1992 Fred Fish (fnf@cygnus.com)
+
+ * h8300.h: Finish filling in all the holes in the opcode table,
+ so that the Lucid C compiler can digest this as well...
+
+Fri Jun 26 21:27:17 1992 John Gilmore (gnu at cygnus.com)
+
+ * i386.h: Add setc, setnc, addr16, data16, repz, repnz aliases.
+ Fix opcodes on various sizes of fild/fist instructions
+ (16bit=no suffix, 32bit="l" suffix, 64bit="ll" suffix).
+ Use tabs to indent for comments. Fixes suggested by Minh Tran-Le.
+
+Thu Jun 25 16:13:26 1992 Stu Grossman (grossman at cygnus.com)
+
+ * h8300.h: Fill in all the holes in the opcode table so that the
+ losing HPUX C compiler can digest this...
+
+Thu Jun 11 12:15:25 1992 John Gilmore (gnu at cygnus.com)
+
+ * mips.h: Fix decoding of coprocessor instructions, somewhat.
+ (Fix by Eric Anderson, 3jean@maas-neotek.arc.nasa.gov.)
+
+Thu May 28 11:17:44 1992 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * sparc.h: Add new architecture variant sparclite; add its scan
+ and divscc opcodes. Define ARCHITECTURES_CONFLICT_P macro.
+
+Tue May 5 14:23:27 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * mips.h: Add some more opcode synonyms (from Frank Yellin,
+ fy@lucid.com).
+
+Thu Apr 16 18:25:26 1992 Per Bothner (bothner@cygnus.com)
+
+ * rs6k.h: New version from IBM (Metin).
+
+Thu Apr 9 00:31:19 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * rs6k.h: Fix incorrect extended opcode for instructions `fm'
+ and `fd'. (From metin@ibmpa.awdpa.ibm.com (Metin G. Ozisik).)
+
+Tue Apr 7 13:38:47 1992 Stu Grossman (grossman at cygnus.com)
+
+ * rs6k.h: Move from ../../gdb/rs6k-opcode.h.
+
+Fri Apr 3 11:30:20 1992 Fred Fish (fnf@cygnus.com)
+
+ * m68k.h (one, two): Cast macro args to unsigned to suppress
+ complaints from compiler and lint about integer overflow during
+ shift.
+
+Sun Mar 29 12:22:08 1992 John Gilmore (gnu at cygnus.com)
+
+ * sparc.h (OP): Avoid signed overflow when shifting to high order bit.
+
+Fri Mar 6 00:22:38 1992 John Gilmore (gnu at cygnus.com)
+
+ * mips.h: Make bitfield layout depend on the HOST compiler,
+ not on the TARGET system.
+
+Fri Feb 21 01:29:51 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * i386.h: added inb, inw, outb, outw opcodes, added att syntax for
+ scmp, slod, smov, ssca, ssto. Curtesy Minh Tran-Le
+ <TRANLE@INTELLICORP.COM>.
+
+Thu Jan 30 07:31:44 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * h8300.h: turned op_type enum into #define list
+
+Thu Jan 30 01:07:24 1992 John Gilmore (gnu at cygnus.com)
+
+ * sparc.h: Remove "cypress" architecture. Remove "fitox" and
+ similar instructions -- they've been renamed to "fitoq", etc.
+ REALLY fix tsubcctv. Fix "fcmpeq" and "fcmpq" which had wrong
+ number of arguments.
+ * h8300.h: Remove extra ; which produces compiler warning.
+
+Tue Jan 28 22:59:22 1992 Stu Grossman (grossman at cygnus.com)
+
+ * sparc.h: fix opcode for tsubcctv.
+
+Tue Jan 7 17:19:39 1992 K. Richard Pixley (rich at cygnus.com)
+
+ * sparc.h: fba and cba are now aliases for fb and cb respectively.
+
+Fri Dec 27 10:55:50 1991 Per Bothner (bothner at cygnus.com)
+
+ * sparc.h (nop): Made the 'lose' field be even tighter,
+ so only a standard 'nop' is disassembled as a nop.
+
+Sun Dec 22 12:18:18 1991 Michael Tiemann (tiemann at cygnus.com)
+
+ * sparc.h (nop): Add RD_GO to `lose' so that only %g0 in dest is
+ disassembled as a nop.
+
+Tue Dec 10 00:22:20 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * sparc.h: fix a typo.
+
+Sat Nov 30 20:40:51 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * a29k.h, arm.h, h8300.h, i386.h, i860.h, i960.h , m68k.h,
+ m88k.h, mips.h , np1.h, ns32k.h, pn.h, pyr.h, sparc.h, tahoe.h,
+ vax.h, ChangeLog: renamed from ../<foo>-opcode.h
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/include/opcode/a29k.h b/include/opcode/a29k.h
new file mode 100644
index 00000000000..002e127d15e
--- /dev/null
+++ b/include/opcode/a29k.h
@@ -0,0 +1,285 @@
+/* Table of opcodes for the AMD 29000 family.
+ Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+
+This file is part of GDB and GAS.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+struct a29k_opcode {
+ /* Name of the instruction. */
+ char *name;
+
+ /* Opcode word */
+ unsigned long opcode;
+
+ /* A string of characters which describe the operands.
+ Valid characters are:
+ , Itself. The character appears in the assembly code.
+ a RA. The register number is in bits 8-15 of the instruction.
+ b RB. The register number is in bits 0-7 of the instruction.
+ c RC. The register number is in bits 16-23 of the instruction.
+ i An immediate operand is in bits 0-7 of the instruction.
+ x Bits 0-7 and 16-23 of the instruction are bits 0-7 and 8-15
+ (respectively) of the immediate operand.
+ h Same as x but the instruction contains bits 16-31 of the
+ immediate operand.
+ X Same as x but bits 16-31 of the signed immediate operand
+ are set to 1 (thus the operand is always negative).
+ P,A Bits 0-7 and 16-23 of the instruction are bits 2-9 and 10-17
+ (respectively) of the immediate operand.
+ P=PC-relative, sign-extended to 32 bits.
+ A=Absolute, zero-extended to 32 bits.
+ e CE bit (bit 23) for a load/store instruction.
+ n Control field (bits 16-22) for a load/store instruction.
+ v Immediate operand in bits 16-23 of the instruction.
+ (used for trap numbers).
+ s SA. Special-purpose register number in bits 8-15
+ of the instruction.
+ u UI--bit 7 of the instruction.
+ r RND--bits 4-6 of the instruction.
+ d FD--bits 2-3 of the instruction.
+ f FS--bits 0-1 of the instruction.
+ I ID--bits 16-17 of the instruction.
+
+ Extensions for 29050:
+
+ d FMT--bits 2-3 of the instruction (not really new).
+ f ACN--bits 0-1 of the instruction (not really new).
+ F FUNC--Special function in bits 18-21 of the instruction.
+ C ACN--bits 16-17 specifying the accumlator register. */
+ char *args;
+};
+
+#ifndef CONST
+#define CONST
+#endif /* CONST */
+
+static CONST struct a29k_opcode a29k_opcodes[] =
+{
+
+{ "add", 0x14000000, "c,a,b" },
+{ "add", 0x15000000, "c,a,i" },
+{ "addc", 0x1c000000, "c,a,b" },
+{ "addc", 0x1d000000, "c,a,i" },
+{ "addcs", 0x18000000, "c,a,b" },
+{ "addcs", 0x19000000, "c,a,i" },
+{ "addcu", 0x1a000000, "c,a,b" },
+{ "addcu", 0x1b000000, "c,a,i" },
+{ "adds", 0x10000000, "c,a,b" },
+{ "adds", 0x11000000, "c,a,i" },
+{ "addu", 0x12000000, "c,a,b" },
+{ "addu", 0x13000000, "c,a,i" },
+{ "and", 0x90000000, "c,a,b" },
+{ "and", 0x91000000, "c,a,i" },
+{ "andn", 0x9c000000, "c,a,b" },
+{ "andn", 0x9d000000, "c,a,i" },
+{ "aseq", 0x70000000, "v,a,b" },
+{ "aseq", 0x71000000, "v,a,i" },
+{ "asge", 0x5c000000, "v,a,b" },
+{ "asge", 0x5d000000, "v,a,i" },
+{ "asgeu", 0x5e000000, "v,a,b" },
+{ "asgeu", 0x5f000000, "v,a,i" },
+{ "asgt", 0x58000000, "v,a,b" },
+{ "asgt", 0x59000000, "v,a,i" },
+{ "asgtu", 0x5a000000, "v,a,b" },
+{ "asgtu", 0x5b000000, "v,a,i" },
+{ "asle", 0x54000000, "v,a,b" },
+{ "asle", 0x55000000, "v,a,i" },
+{ "asleu", 0x56000000, "v,a,b" },
+{ "asleu", 0x57000000, "v,a,i" },
+{ "aslt", 0x50000000, "v,a,b" },
+{ "aslt", 0x51000000, "v,a,i" },
+{ "asltu", 0x52000000, "v,a,b" },
+{ "asltu", 0x53000000, "v,a,i" },
+{ "asneq", 0x72000000, "v,a,b" },
+{ "asneq", 0x73000000, "v,a,i" },
+{ "call", 0xa8000000, "a,P" },
+{ "call", 0xa9000000, "a,A" },
+{ "calli", 0xc8000000, "a,b" },
+{ "class", 0xe6000000, "c,a,f" },
+{ "clz", 0x08000000, "c,b" },
+{ "clz", 0x09000000, "c,i" },
+{ "const", 0x03000000, "a,x" },
+{ "consth", 0x02000000, "a,h" },
+{ "consthz", 0x05000000, "a,h" },
+{ "constn", 0x01000000, "a,X" },
+{ "convert", 0xe4000000, "c,a,u,r,d,f" },
+{ "cpbyte", 0x2e000000, "c,a,b" },
+{ "cpbyte", 0x2f000000, "c,a,i" },
+{ "cpeq", 0x60000000, "c,a,b" },
+{ "cpeq", 0x61000000, "c,a,i" },
+{ "cpge", 0x4c000000, "c,a,b" },
+{ "cpge", 0x4d000000, "c,a,i" },
+{ "cpgeu", 0x4e000000, "c,a,b" },
+{ "cpgeu", 0x4f000000, "c,a,i" },
+{ "cpgt", 0x48000000, "c,a,b" },
+{ "cpgt", 0x49000000, "c,a,i" },
+{ "cpgtu", 0x4a000000, "c,a,b" },
+{ "cpgtu", 0x4b000000, "c,a,i" },
+{ "cple", 0x44000000, "c,a,b" },
+{ "cple", 0x45000000, "c,a,i" },
+{ "cpleu", 0x46000000, "c,a,b" },
+{ "cpleu", 0x47000000, "c,a,i" },
+{ "cplt", 0x40000000, "c,a,b" },
+{ "cplt", 0x41000000, "c,a,i" },
+{ "cpltu", 0x42000000, "c,a,b" },
+{ "cpltu", 0x43000000, "c,a,i" },
+{ "cpneq", 0x62000000, "c,a,b" },
+{ "cpneq", 0x63000000, "c,a,i" },
+{ "dadd", 0xf1000000, "c,a,b" },
+{ "ddiv", 0xf7000000, "c,a,b" },
+{ "deq", 0xeb000000, "c,a,b" },
+{ "dge", 0xef000000, "c,a,b" },
+{ "dgt", 0xed000000, "c,a,b" },
+{ "div", 0x6a000000, "c,a,b" },
+{ "div", 0x6b000000, "c,a,i" },
+{ "div0", 0x68000000, "c,b" },
+{ "div0", 0x69000000, "c,i" },
+{ "divide", 0xe1000000, "c,a,b" },
+{ "dividu", 0xe3000000, "c,a,b" },
+{ "divl", 0x6c000000, "c,a,b" },
+{ "divl", 0x6d000000, "c,a,i" },
+{ "divrem", 0x6e000000, "c,a,b" },
+{ "divrem", 0x6f000000, "c,a,i" },
+{ "dmac", 0xd9000000, "F,C,a,b" },
+{ "dmsm", 0xdb000000, "c,a,b" },
+{ "dmul", 0xf5000000, "c,a,b" },
+{ "dsub", 0xf3000000, "c,a,b" },
+{ "emulate", 0xd7000000, "v,a,b" },
+{ "exbyte", 0x0a000000, "c,a,b" },
+{ "exbyte", 0x0b000000, "c,a,i" },
+{ "exhw", 0x7c000000, "c,a,b" },
+{ "exhw", 0x7d000000, "c,a,i" },
+{ "exhws", 0x7e000000, "c,a" },
+{ "extract", 0x7a000000, "c,a,b" },
+{ "extract", 0x7b000000, "c,a,i" },
+{ "fadd", 0xf0000000, "c,a,b" },
+{ "fdiv", 0xf6000000, "c,a,b" },
+{ "fdmul", 0xf9000000, "c,a,b" },
+{ "feq", 0xea000000, "c,a,b" },
+{ "fge", 0xee000000, "c,a,b" },
+{ "fgt", 0xec000000, "c,a,b" },
+{ "fmac", 0xd8000000, "F,C,a,b" },
+{ "fmsm", 0xda000000, "c,a,b" },
+{ "fmul", 0xf4000000, "c,a,b" },
+{ "fsub", 0xf2000000, "c,a,b" },
+{ "halt", 0x89000000, "" },
+{ "inbyte", 0x0c000000, "c,a,b" },
+{ "inbyte", 0x0d000000, "c,a,i" },
+{ "inhw", 0x78000000, "c,a,b" },
+{ "inhw", 0x79000000, "c,a,i" },
+{ "inv", 0x9f000000, "I" },
+{ "iret", 0x88000000, "" },
+{ "iretinv", 0x8c000000, "I" },
+{ "jmp", 0xa0000000, "P" },
+{ "jmp", 0xa1000000, "A" },
+{ "jmpf", 0xa4000000, "a,P" },
+{ "jmpf", 0xa5000000, "a,A" },
+{ "jmpfdec", 0xb4000000, "a,P" },
+{ "jmpfdec", 0xb5000000, "a,A" },
+{ "jmpfi", 0xc4000000, "a,b" },
+{ "jmpi", 0xc0000000, "b" },
+{ "jmpt", 0xac000000, "a,P" },
+{ "jmpt", 0xad000000, "a,A" },
+{ "jmpti", 0xcc000000, "a,b" },
+{ "load", 0x16000000, "e,n,a,b" },
+{ "load", 0x17000000, "e,n,a,i" },
+{ "loadl", 0x06000000, "e,n,a,b" },
+{ "loadl", 0x07000000, "e,n,a,i" },
+{ "loadm", 0x36000000, "e,n,a,b" },
+{ "loadm", 0x37000000, "e,n,a,i" },
+{ "loadset", 0x26000000, "e,n,a,b" },
+{ "loadset", 0x27000000, "e,n,a,i" },
+{ "mfacc", 0xe9000100, "c,d,f" },
+{ "mfsr", 0xc6000000, "c,s" },
+{ "mftlb", 0xb6000000, "c,a" },
+{ "mtacc", 0xe8010000, "a,d,f" },
+{ "mtsr", 0xce000000, "s,b" },
+{ "mtsrim", 0x04000000, "s,x" },
+{ "mttlb", 0xbe000000, "a,b" },
+{ "mul", 0x64000000, "c,a,b" },
+{ "mul", 0x65000000, "c,a,i" },
+{ "mull", 0x66000000, "c,a,b" },
+{ "mull", 0x67000000, "c,a,i" },
+{ "multiplu", 0xe2000000, "c,a,b" },
+{ "multiply", 0xe0000000, "c,a,b" },
+{ "multm", 0xde000000, "c,a,b" },
+{ "multmu", 0xdf000000, "c,a,b" },
+{ "mulu", 0x74000000, "c,a,b" },
+{ "mulu", 0x75000000, "c,a,i" },
+{ "nand", 0x9a000000, "c,a,b" },
+{ "nand", 0x9b000000, "c,a,i" },
+{ "nop", 0x70400101, "" },
+{ "nor", 0x98000000, "c,a,b" },
+{ "nor", 0x99000000, "c,a,i" },
+{ "or", 0x92000000, "c,a,b" },
+{ "or", 0x93000000, "c,a,i" },
+{ "orn", 0xaa000000, "c,a,b" },
+{ "orn", 0xab000000, "c,a,i" },
+
+/* The description of "setip" in Chapter 8 ("instruction set") of the user's
+ manual claims that these are absolute register numbers. But section
+ 7.2.1 explains that they are not. The latter is correct, so print
+ these normally ("lr0", "lr5", etc.). */
+{ "setip", 0x9e000000, "c,a,b" },
+
+{ "sll", 0x80000000, "c,a,b" },
+{ "sll", 0x81000000, "c,a,i" },
+{ "sqrt", 0xe5000000, "c,a,f" },
+{ "sra", 0x86000000, "c,a,b" },
+{ "sra", 0x87000000, "c,a,i" },
+{ "srl", 0x82000000, "c,a,b" },
+{ "srl", 0x83000000, "c,a,i" },
+{ "store", 0x1e000000, "e,n,a,b" },
+{ "store", 0x1f000000, "e,n,a,i" },
+{ "storel", 0x0e000000, "e,n,a,b" },
+{ "storel", 0x0f000000, "e,n,a,i" },
+{ "storem", 0x3e000000, "e,n,a,b" },
+{ "storem", 0x3f000000, "e,n,a,i" },
+{ "sub", 0x24000000, "c,a,b" },
+{ "sub", 0x25000000, "c,a,i" },
+{ "subc", 0x2c000000, "c,a,b" },
+{ "subc", 0x2d000000, "c,a,i" },
+{ "subcs", 0x28000000, "c,a,b" },
+{ "subcs", 0x29000000, "c,a,i" },
+{ "subcu", 0x2a000000, "c,a,b" },
+{ "subcu", 0x2b000000, "c,a,i" },
+{ "subr", 0x34000000, "c,a,b" },
+{ "subr", 0x35000000, "c,a,i" },
+{ "subrc", 0x3c000000, "c,a,b" },
+{ "subrc", 0x3d000000, "c,a,i" },
+{ "subrcs", 0x38000000, "c,a,b" },
+{ "subrcs", 0x39000000, "c,a,i" },
+{ "subrcu", 0x3a000000, "c,a,b" },
+{ "subrcu", 0x3b000000, "c,a,i" },
+{ "subrs", 0x30000000, "c,a,b" },
+{ "subrs", 0x31000000, "c,a,i" },
+{ "subru", 0x32000000, "c,a,b" },
+{ "subru", 0x33000000, "c,a,i" },
+{ "subs", 0x20000000, "c,a,b" },
+{ "subs", 0x21000000, "c,a,i" },
+{ "subu", 0x22000000, "c,a,b" },
+{ "subu", 0x23000000, "c,a,i" },
+{ "xnor", 0x96000000, "c,a,b" },
+{ "xnor", 0x97000000, "c,a,i" },
+{ "xor", 0x94000000, "c,a,b" },
+{ "xor", 0x95000000, "c,a,i" },
+
+{ "", 0x0, "" } /* Dummy entry, not included in NUM_OPCODES. This
+ lets code examine entry i+1 without checking
+ if we've run off the end of the table. */
+};
+
+CONST unsigned int num_opcodes = (((sizeof a29k_opcodes) / (sizeof a29k_opcodes[0])) - 1);
diff --git a/include/opcode/alpha.h b/include/opcode/alpha.h
new file mode 100644
index 00000000000..d18eb04451e
--- /dev/null
+++ b/include/opcode/alpha.h
@@ -0,0 +1,238 @@
+/* alpha.h -- Header file for Alpha opcode table
+ Copyright 1996, 1999 Free Software Foundation, Inc.
+ Contributed by Richard Henderson <rth@tamu.edu>,
+ patterned after the PPC opcode table written by Ian Lance Taylor.
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef OPCODE_ALPHA_H
+#define OPCODE_ALPHA_H
+
+/* The opcode table is an array of struct alpha_opcode. */
+
+struct alpha_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* The opcode itself. Those bits which will be filled in with
+ operands are zeroes. */
+ unsigned opcode;
+
+ /* The opcode mask. This is used by the disassembler. This is a
+ mask containing ones indicating those bits which must match the
+ opcode field, and zeroes indicating those bits which need not
+ match (and are presumably filled in by operands). */
+ unsigned mask;
+
+ /* One bit flags for the opcode. These are primarily used to
+ indicate specific processors and environments support the
+ instructions. The defined values are listed below. */
+ unsigned flags;
+
+ /* An array of operand codes. Each code is an index into the
+ operand table. They appear in the order which the operands must
+ appear in assembly code, and are terminated by a zero. */
+ unsigned char operands[4];
+};
+
+/* The table itself is sorted by major opcode number, and is otherwise
+ in the order in which the disassembler should consider
+ instructions. */
+extern const struct alpha_opcode alpha_opcodes[];
+extern const int alpha_num_opcodes;
+
+/* Values defined for the flags field of a struct alpha_opcode. */
+
+/* CPU Availability */
+#define AXP_OPCODE_BASE 0x0001 /* Base architecture -- all cpus. */
+#define AXP_OPCODE_EV4 0x0002 /* EV4 specific PALcode insns. */
+#define AXP_OPCODE_EV5 0x0004 /* EV5 specific PALcode insns. */
+#define AXP_OPCODE_EV6 0x0008 /* EV6 specific PALcode insns. */
+#define AXP_OPCODE_BWX 0x0100 /* Byte/word extension (amask bit 0). */
+#define AXP_OPCODE_CIX 0x0200 /* "Count" extension (amask bit 1). */
+#define AXP_OPCODE_MAX 0x0400 /* Multimedia extension (amask bit 8). */
+
+#define AXP_OPCODE_NOPAL (~(AXP_OPCODE_EV4|AXP_OPCODE_EV5|AXP_OPCODE_EV6))
+
+/* A macro to extract the major opcode from an instruction. */
+#define AXP_OP(i) (((i) >> 26) & 0x3F)
+
+/* The total number of major opcodes. */
+#define AXP_NOPS 0x40
+
+
+/* The operands table is an array of struct alpha_operand. */
+
+struct alpha_operand
+{
+ /* The number of bits in the operand. */
+ int bits;
+
+ /* How far the operand is left shifted in the instruction. */
+ int shift;
+
+ /* The default relocation type for this operand. */
+ int default_reloc;
+
+ /* One bit syntax flags. */
+ unsigned flags;
+
+ /* Insertion function. This is used by the assembler. To insert an
+ operand value into an instruction, check this field.
+
+ If it is NULL, execute
+ i |= (op & ((1 << o->bits) - 1)) << o->shift;
+ (i is the instruction which we are filling in, o is a pointer to
+ this structure, and op is the opcode value; this assumes twos
+ complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction and the operand value. It will return the new value
+ of the instruction. If the ERRMSG argument is not NULL, then if
+ the operand value is illegal, *ERRMSG will be set to a warning
+ string (the operand will be inserted in any case). If the
+ operand value is legal, *ERRMSG will be unchanged (most operands
+ can accept any value). */
+ unsigned (*insert) PARAMS ((unsigned instruction, int op,
+ const char **errmsg));
+
+ /* Extraction function. This is used by the disassembler. To
+ extract this operand type from an instruction, check this field.
+
+ If it is NULL, compute
+ op = ((i) >> o->shift) & ((1 << o->bits) - 1);
+ if ((o->flags & AXP_OPERAND_SIGNED) != 0
+ && (op & (1 << (o->bits - 1))) != 0)
+ op -= 1 << o->bits;
+ (i is the instruction, o is a pointer to this structure, and op
+ is the result; this assumes twos complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction value. It will return the value of the operand. If
+ the INVALID argument is not NULL, *INVALID will be set to
+ non-zero if this operand type can not actually be extracted from
+ this operand (i.e., the instruction does not match). If the
+ operand is valid, *INVALID will not be changed. */
+ int (*extract) PARAMS ((unsigned instruction, int *invalid));
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the alpha_opcodes table. */
+
+extern const struct alpha_operand alpha_operands[];
+extern const int alpha_num_operands;
+
+/* Values defined for the flags field of a struct alpha_operand. */
+
+/* Mask for selecting the type for typecheck purposes */
+#define AXP_OPERAND_TYPECHECK_MASK \
+ (AXP_OPERAND_PARENS | AXP_OPERAND_COMMA | AXP_OPERAND_IR | \
+ AXP_OPERAND_FPR | AXP_OPERAND_RELATIVE | AXP_OPERAND_SIGNED | \
+ AXP_OPERAND_UNSIGNED)
+
+/* This operand does not actually exist in the assembler input. This
+ is used to support extended mnemonics, for which two operands fields
+ are identical. The assembler should call the insert function with
+ any op value. The disassembler should call the extract function,
+ ignore the return value, and check the value placed in the invalid
+ argument. */
+#define AXP_OPERAND_FAKE 01
+
+/* The operand should be wrapped in parentheses rather than separated
+ from the previous by a comma. This is used for the load and store
+ instructions which want their operands to look like "Ra,disp(Rb)". */
+#define AXP_OPERAND_PARENS 02
+
+/* Used in combination with PARENS, this supresses the supression of
+ the comma. This is used for "jmp Ra,(Rb),hint". */
+#define AXP_OPERAND_COMMA 04
+
+/* This operand names an integer register. */
+#define AXP_OPERAND_IR 010
+
+/* This operand names a floating point register. */
+#define AXP_OPERAND_FPR 020
+
+/* This operand is a relative branch displacement. The disassembler
+ prints these symbolically if possible. */
+#define AXP_OPERAND_RELATIVE 040
+
+/* This operand takes signed values. */
+#define AXP_OPERAND_SIGNED 0100
+
+/* This operand takes unsigned values. This exists primarily so that
+ a flags value of 0 can be treated as end-of-arguments. */
+#define AXP_OPERAND_UNSIGNED 0200
+
+/* Supress overflow detection on this field. This is used for hints. */
+#define AXP_OPERAND_NOOVERFLOW 0400
+
+/* Mask for optional argument default value. */
+#define AXP_OPERAND_OPTIONAL_MASK 07000
+
+/* This operand defaults to zero. This is used for jump hints. */
+#define AXP_OPERAND_DEFAULT_ZERO 01000
+
+/* This operand should default to the first (real) operand and is used
+ in conjunction with AXP_OPERAND_OPTIONAL. This allows
+ "and $0,3,$0" to be written as "and $0,3", etc. I don't like
+ it, but it's what DEC does. */
+#define AXP_OPERAND_DEFAULT_FIRST 02000
+
+/* Similarly, this operand should default to the second (real) operand.
+ This allows "negl $0" instead of "negl $0,$0". */
+#define AXP_OPERAND_DEFAULT_SECOND 04000
+
+
+/* Register common names */
+
+#define AXP_REG_V0 0
+#define AXP_REG_T0 1
+#define AXP_REG_T1 2
+#define AXP_REG_T2 3
+#define AXP_REG_T3 4
+#define AXP_REG_T4 5
+#define AXP_REG_T5 6
+#define AXP_REG_T6 7
+#define AXP_REG_T7 8
+#define AXP_REG_S0 9
+#define AXP_REG_S1 10
+#define AXP_REG_S2 11
+#define AXP_REG_S3 12
+#define AXP_REG_S4 13
+#define AXP_REG_S5 14
+#define AXP_REG_FP 15
+#define AXP_REG_A0 16
+#define AXP_REG_A1 17
+#define AXP_REG_A2 18
+#define AXP_REG_A3 19
+#define AXP_REG_A4 20
+#define AXP_REG_A5 21
+#define AXP_REG_T8 22
+#define AXP_REG_T9 23
+#define AXP_REG_T10 24
+#define AXP_REG_T11 25
+#define AXP_REG_RA 26
+#define AXP_REG_PV 27
+#define AXP_REG_T12 27
+#define AXP_REG_AT 28
+#define AXP_REG_GP 29
+#define AXP_REG_SP 30
+#define AXP_REG_ZERO 31
+
+#endif /* OPCODE_ALPHA_H */
diff --git a/include/opcode/arc.h b/include/opcode/arc.h
new file mode 100644
index 00000000000..a1e0ca15263
--- /dev/null
+++ b/include/opcode/arc.h
@@ -0,0 +1,274 @@
+/* Opcode table for the ARC.
+ Copyright 1994, 1995, 1997 Free Software Foundation, Inc.
+ Contributed by Doug Evans (dje@cygnus.com).
+
+This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
+the GNU Binutils.
+
+GAS/GDB is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* List of the various cpu types.
+ The tables currently use bit masks to say whether the instruction or
+ whatever is supported by a particular cpu. This lets us have one entry
+ apply to several cpus.
+
+ This duplicates bfd_mach_arc_xxx. For now I wish to isolate this from bfd
+ and bfd from this. Also note that these numbers are bit values as we want
+ to allow for things available on more than one ARC (but not necessarily all
+ ARCs). */
+
+/* The `base' cpu must be 0 (table entries are omitted for the base cpu).
+ The cpu type is treated independently of endianness.
+ The complete `mach' number includes endianness.
+ These values are internal to opcodes/bfd/binutils/gas. */
+#define ARC_MACH_BASE 0
+#define ARC_MACH_UNUSED1 1
+#define ARC_MACH_UNUSED2 2
+#define ARC_MACH_UNUSED4 4
+/* Additional cpu values can be inserted here and ARC_MACH_BIG moved down. */
+#define ARC_MACH_BIG 8
+
+/* Mask of number of bits necessary to record cpu type. */
+#define ARC_MACH_CPU_MASK 7
+/* Mask of number of bits necessary to record cpu type + endianness. */
+#define ARC_MACH_MASK 15
+
+/* Type to denote an ARC instruction (at least a 32 bit unsigned int). */
+typedef unsigned int arc_insn;
+
+struct arc_opcode {
+ char *syntax; /* syntax of insn */
+ unsigned long mask, value; /* recognize insn if (op&mask)==value */
+ int flags; /* various flag bits */
+
+/* Values for `flags'. */
+
+/* Return CPU number, given flag bits. */
+#define ARC_OPCODE_CPU(bits) ((bits) & ARC_MACH_CPU_MASK)
+/* Return MACH number, given flag bits. */
+#define ARC_OPCODE_MACH(bits) ((bits) & ARC_MACH_MASK)
+/* First opcode flag bit available after machine mask. */
+#define ARC_OPCODE_FLAG_START ((ARC_MACH_MASK + 1) << 0)
+/* This insn is a conditional branch. */
+#define ARC_OPCODE_COND_BRANCH (ARC_OPCODE_FLAG_START)
+
+ /* These values are used to optimize assembly and disassembly. Each insn is
+ on a list of related insns (same first letter for assembly, same insn code
+ for disassembly). */
+ struct arc_opcode *next_asm; /* Next instruction to try during assembly. */
+ struct arc_opcode *next_dis; /* Next instruction to try during disassembly. */
+
+ /* Macros to create the hash values for the lists. */
+#define ARC_HASH_OPCODE(string) \
+ ((string)[0] >= 'a' && (string)[0] <= 'z' ? (string)[0] - 'a' : 26)
+#define ARC_HASH_ICODE(insn) \
+ ((unsigned int) (insn) >> 27)
+
+ /* Macros to access `next_asm', `next_dis' so users needn't care about the
+ underlying mechanism. */
+#define ARC_OPCODE_NEXT_ASM(op) ((op)->next_asm)
+#define ARC_OPCODE_NEXT_DIS(op) ((op)->next_dis)
+};
+
+struct arc_operand_value {
+ char *name; /* eg: "eq" */
+ short value; /* eg: 1 */
+ unsigned char type; /* index into `arc_operands' */
+ unsigned char flags; /* various flag bits */
+
+/* Values for `flags'. */
+
+/* Return CPU number, given flag bits. */
+#define ARC_OPVAL_CPU(bits) ((bits) & ARC_MACH_CPU_MASK)
+/* Return MACH number, given flag bits. */
+#define ARC_OPVAL_MACH(bits) ((bits) & ARC_MACH_MASK)
+};
+
+struct arc_operand {
+ /* One of the insn format chars. */
+ unsigned char fmt;
+
+ /* The number of bits in the operand (may be unused for a modifier). */
+ unsigned char bits;
+
+ /* How far the operand is left shifted in the instruction, or
+ the modifier's flag bit (may be unused for a modifier. */
+ unsigned char shift;
+
+ /* Various flag bits. */
+ int flags;
+
+/* Values for `flags'. */
+
+/* This operand is a suffix to the opcode. */
+#define ARC_OPERAND_SUFFIX 1
+
+/* This operand is a relative branch displacement. The disassembler
+ prints these symbolically if possible. */
+#define ARC_OPERAND_RELATIVE_BRANCH 2
+
+/* This operand is an absolute branch address. The disassembler
+ prints these symbolically if possible. */
+#define ARC_OPERAND_ABSOLUTE_BRANCH 4
+
+/* This operand is an address. The disassembler
+ prints these symbolically if possible. */
+#define ARC_OPERAND_ADDRESS 8
+
+/* This operand is a long immediate value. */
+#define ARC_OPERAND_LIMM 0x10
+
+/* This operand takes signed values. */
+#define ARC_OPERAND_SIGNED 0x20
+
+/* This operand takes signed values, but also accepts a full positive
+ range of values. That is, if bits is 16, it takes any value from
+ -0x8000 to 0xffff. */
+#define ARC_OPERAND_SIGNOPT 0x40
+
+/* This operand should be regarded as a negative number for the
+ purposes of overflow checking (i.e., the normal most negative
+ number is disallowed and one more than the normal most positive
+ number is allowed). This flag will only be set for a signed
+ operand. */
+#define ARC_OPERAND_NEGATIVE 0x80
+
+/* This operand doesn't really exist. The program uses these operands
+ in special ways. */
+#define ARC_OPERAND_FAKE 0x100
+
+/* Modifier values. */
+/* A dot is required before a suffix. Eg: .le */
+#define ARC_MOD_DOT 0x1000
+
+/* A normal register is allowed (not used, but here for completeness). */
+#define ARC_MOD_REG 0x2000
+
+/* An auxiliary register name is expected. */
+#define ARC_MOD_AUXREG 0x4000
+
+/* Sum of all ARC_MOD_XXX bits. */
+#define ARC_MOD_BITS 0x7000
+
+/* Non-zero if the operand type is really a modifier. */
+#define ARC_MOD_P(X) ((X) & ARC_MOD_BITS)
+
+ /* Insertion function. This is used by the assembler. To insert an
+ operand value into an instruction, check this field.
+
+ If it is NULL, execute
+ i |= (p & ((1 << o->bits) - 1)) << o->shift;
+ (I is the instruction which we are filling in, O is a pointer to
+ this structure, and OP is the opcode value; this assumes twos
+ complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction and the operand value. It will return the new value
+ of the instruction. If the ERRMSG argument is not NULL, then if
+ the operand value is illegal, *ERRMSG will be set to a warning
+ string (the operand will be inserted in any case). If the
+ operand value is legal, *ERRMSG will be unchanged.
+
+ REG is non-NULL when inserting a register value. */
+
+ arc_insn (*insert) PARAMS ((arc_insn insn,
+ const struct arc_operand *operand, int mods,
+ const struct arc_operand_value *reg, long value,
+ const char **errmsg));
+
+ /* Extraction function. This is used by the disassembler. To
+ extract this operand type from an instruction, check this field.
+
+ If it is NULL, compute
+ op = ((i) >> o->shift) & ((1 << o->bits) - 1);
+ if ((o->flags & ARC_OPERAND_SIGNED) != 0
+ && (op & (1 << (o->bits - 1))) != 0)
+ op -= 1 << o->bits;
+ (I is the instruction, O is a pointer to this structure, and OP
+ is the result; this assumes twos complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction value. It will return the value of the operand. If
+ the INVALID argument is not NULL, *INVALID will be set to
+ non-zero if this operand type can not actually be extracted from
+ this operand (i.e., the instruction does not match). If the
+ operand is valid, *INVALID will not be changed.
+
+ INSN is a pointer to an array of two `arc_insn's. The first element is
+ the insn, the second is the limm if present.
+
+ Operands that have a printable form like registers and suffixes have
+ their struct arc_operand_value pointer stored in OPVAL. */
+
+ long (*extract) PARAMS ((arc_insn *insn,
+ const struct arc_operand *operand,
+ int mods, const struct arc_operand_value **opval,
+ int *invalid));
+};
+
+/* Bits that say what version of cpu we have.
+ These should be passed to arc_init_opcode_tables.
+ At present, all there is is the cpu type. */
+
+/* CPU number, given value passed to `arc_init_opcode_tables'. */
+#define ARC_HAVE_CPU(bits) ((bits) & ARC_MACH_CPU_MASK)
+/* MACH number, given value passed to `arc_init_opcode_tables'. */
+#define ARC_HAVE_MACH(bits) ((bits) & ARC_MACH_MASK)
+
+/* Special register values: */
+#define ARC_REG_SHIMM_UPDATE 61
+#define ARC_REG_SHIMM 63
+#define ARC_REG_LIMM 62
+
+/* Non-zero if REG is a constant marker. */
+#define ARC_REG_CONSTANT_P(REG) ((REG) >= 61)
+
+/* Positions and masks of various fields: */
+#define ARC_SHIFT_REGA 21
+#define ARC_SHIFT_REGB 15
+#define ARC_SHIFT_REGC 9
+#define ARC_MASK_REG 63
+
+/* Delay slot types. */
+#define ARC_DELAY_NONE 0 /* no delay slot */
+#define ARC_DELAY_NORMAL 1 /* delay slot in both cases */
+#define ARC_DELAY_JUMP 2 /* delay slot only if branch taken */
+
+/* Non-zero if X will fit in a signed 9 bit field. */
+#define ARC_SHIMM_CONST_P(x) ((long) (x) >= -256 && (long) (x) <= 255)
+
+extern const struct arc_operand arc_operands[];
+extern const int arc_operand_count;
+extern /*const*/ struct arc_opcode arc_opcodes[];
+extern const int arc_opcodes_count;
+extern const struct arc_operand_value arc_suffixes[];
+extern const int arc_suffixes_count;
+extern const struct arc_operand_value arc_reg_names[];
+extern const int arc_reg_names_count;
+extern unsigned char arc_operand_map[];
+
+/* Utility fns in arc-opc.c. */
+int arc_get_opcode_mach PARAMS ((int, int));
+/* `arc_opcode_init_tables' must be called before `arc_xxx_supported'. */
+void arc_opcode_init_tables PARAMS ((int));
+void arc_opcode_init_insert PARAMS ((void));
+void arc_opcode_init_extract PARAMS ((void));
+const struct arc_opcode *arc_opcode_lookup_asm PARAMS ((const char *));
+const struct arc_opcode *arc_opcode_lookup_dis PARAMS ((unsigned int));
+int arc_opcode_limm_p PARAMS ((long *));
+const struct arc_operand_value *arc_opcode_lookup_suffix PARAMS ((const struct arc_operand *type, int value));
+int arc_opcode_supported PARAMS ((const struct arc_opcode *));
+int arc_opval_supported PARAMS ((const struct arc_operand_value *));
diff --git a/include/opcode/arm.h b/include/opcode/arm.h
new file mode 100644
index 00000000000..c7087eb9ed4
--- /dev/null
+++ b/include/opcode/arm.h
@@ -0,0 +1,294 @@
+/* ARM opcode list.
+ Copyright (C) 1989, Free Software Foundation, Inc.
+
+This file is part of GDB and GAS.
+
+GDB and GAS are 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 1, or (at your option)
+any later version.
+
+GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* types of instruction (encoded in bits 26 and 27 of the instruction) */
+
+#define TYPE_ARITHMETIC 0
+#define TYPE_LDR_STR 1
+#define TYPE_BLOCK_BRANCH 2
+#define TYPE_SWI 3
+
+/* bit 25 decides whether an instruction is a block move or a branch */
+#define SUBTYPE_BLOCK 0
+#define SUBTYPE_BRANCH 1
+
+/* codes to distinguish the arithmetic instructions */
+
+#define OPCODE_AND 0
+#define OPCODE_EOR 1
+#define OPCODE_SUB 2
+#define OPCODE_RSB 3
+#define OPCODE_ADD 4
+#define OPCODE_ADC 5
+#define OPCODE_SBC 6
+#define OPCODE_RSC 7
+#define OPCODE_TST 8
+#define OPCODE_TEQ 9
+#define OPCODE_CMP 10
+#define OPCODE_CMN 11
+#define OPCODE_ORR 12
+#define OPCODE_MOV 13
+#define OPCODE_BIC 14
+#define OPCODE_MVN 15
+
+/* condition codes */
+
+#define COND_EQ 0
+#define COND_NE 1
+#define COND_CS 2
+#define COND_CC 3
+#define COND_MI 4
+#define COND_PL 5
+#define COND_VS 6
+#define COND_VC 7
+#define COND_HI 8
+#define COND_LS 9
+#define COND_GE 10
+#define COND_LT 11
+#define COND_GT 12
+#define COND_LE 13
+#define COND_AL 14
+#define COND_NV 15
+
+/* Describes the format of an ARM machine instruction */
+
+struct generic_fmt {
+ unsigned rest :25; /* the rest of the instruction */
+ unsigned subtype :1; /* used to decide between block and branch */
+ unsigned type :2; /* one of TYPE_* */
+ unsigned cond :4; /* one of COND_* defined above */
+};
+
+struct arith_fmt {
+ unsigned operand2 :12; /* #nn or rn or rn shift #m or rn shift rm */
+ unsigned dest :4; /* place where the answer goes */
+ unsigned operand1 :4; /* first operand to instruction */
+ unsigned set :1; /* == 1 means set processor flags */
+ unsigned opcode :4; /* one of OPCODE_* defined above */
+ unsigned immed :1; /* operand2 is an immediate value */
+ unsigned type :2; /* == TYPE_ARITHMETIC */
+ unsigned cond :4; /* one of COND_* defined above */
+};
+
+struct ldr_str_fmt {
+ unsigned offset :12; /* #nn or rn or rn shift #m */
+ unsigned reg :4; /* destination for LDR, source for STR */
+ unsigned base :4; /* base register */
+ unsigned is_load :1; /* == 1 for LDR */
+ unsigned writeback :1; /* == 1 means write back (base+offset) into base */
+ unsigned byte :1; /* == 1 means byte access else word */
+ unsigned up :1; /* == 1 means add offset else subtract it */
+ unsigned pre_index :1; /* == 1 means [a,b] form else [a],b form */
+ unsigned immed :1; /* == 0 means immediate offset */
+ unsigned type :2; /* == TYPE_LDR_STR */
+ unsigned cond :4; /* one of COND_* defined above */
+};
+
+struct block_fmt {
+ unsigned mask :16; /* register mask */
+ unsigned base :4; /* register used as base of move */
+ unsigned is_load :1; /* == 1 for LDM */
+ unsigned writeback :1; /* == 1 means update base after move */
+ unsigned set :1; /* == 1 means set flags in pc if included in mask */
+ unsigned increment :1; /* == 1 means increment base register */
+ unsigned before :1; /* == 1 means inc/dec before each move */
+ unsigned is_block :1; /* == SUBTYPE_BLOCK */
+ unsigned type :2; /* == TYPE_BLOCK_BRANCH */
+ unsigned cond :4; /* one of COND_* defined above */
+};
+
+struct branch_fmt {
+ unsigned dest :24; /* destination of the branch */
+ unsigned link :1; /* branch with link (function call) */
+ unsigned is_branch :1; /* == SUBTYPE_BRANCH */
+ unsigned type :2; /* == TYPE_BLOCK_BRANCH */
+ unsigned cond :4; /* one of COND_* defined above */
+};
+
+#define ROUND_N 0
+#define ROUND_P 1
+#define ROUND_M 2
+#define ROUND_Z 3
+
+#define FLOAT2_MVF 0
+#define FLOAT2_MNF 1
+#define FLOAT2_ABS 2
+#define FLOAT2_RND 3
+#define FLOAT2_SQT 4
+#define FLOAT2_LOG 5
+#define FLOAT2_LGN 6
+#define FLOAT2_EXP 7
+#define FLOAT2_SIN 8
+#define FLOAT2_COS 9
+#define FLOAT2_TAN 10
+#define FLOAT2_ASN 11
+#define FLOAT2_ACS 12
+#define FLOAT2_ATN 13
+
+#define FLOAT3_ADF 0
+#define FLOAT3_MUF 1
+#define FLOAT3_SUF 2
+#define FLOAT3_RSF 3
+#define FLOAT3_DVF 4
+#define FLOAT3_RDF 5
+#define FLOAT3_POW 6
+#define FLOAT3_RPW 7
+#define FLOAT3_RMF 8
+#define FLOAT3_FML 9
+#define FLOAT3_FDV 10
+#define FLOAT3_FRD 11
+#define FLOAT3_POL 12
+
+struct float2_fmt {
+ unsigned operand2 :3; /* second operand */
+ unsigned immed :1; /* == 1 if second operand is a constant */
+ unsigned pad1 :1; /* == 0 */
+ unsigned rounding :2; /* ROUND_* */
+ unsigned is_double :1; /* == 1 if precision is double (only if not extended) */
+ unsigned pad2 :4; /* == 1 */
+ unsigned dest :3; /* destination */
+ unsigned is_2_op :1; /* == 1 if 2 operand ins */
+ unsigned operand1 :3; /* first operand (only of is_2_op == 0) */
+ unsigned is_extended :1; /* == 1 if precision is extended */
+ unsigned opcode :4; /* FLOAT2_* or FLOAT3_* depending on is_2_op */
+ unsigned must_be_2 :2; /* == 2 */
+ unsigned type :2; /* == TYPE_SWI */
+ unsigned cond :4; /* COND_* */
+};
+
+struct swi_fmt {
+ unsigned argument :24; /* argument to SWI (syscall number) */
+ unsigned must_be_3 :2; /* == 3 */
+ unsigned type :2; /* == TYPE_SWI */
+ unsigned cond :4; /* one of COND_* defined above */
+};
+
+union insn_fmt {
+ struct generic_fmt generic;
+ struct arith_fmt arith;
+ struct ldr_str_fmt ldr_str;
+ struct block_fmt block;
+ struct branch_fmt branch;
+ struct swi_fmt swi;
+ unsigned long ins;
+};
+
+struct opcode {
+ unsigned long value, mask; /* recognise instruction if (op&mask)==value */
+ char *assembler; /* how to disassemble this instruction */
+};
+
+/* format of the assembler string :
+
+ %% %
+ %<bitfield>d print the bitfield in decimal
+ %<bitfield>x print the bitfield in hex
+ %<bitfield>r print as an ARM register
+ %<bitfield>f print a floating point constant if >7 else an fp register
+ %c print condition code (always bits 28-31)
+ %P print floating point precision in arithmetic insn
+ %Q print floating point precision in ldf/stf insn
+ %R print floating point rounding mode
+ %<bitnum>'c print specified char iff bit is one
+ %<bitnum>`c print specified char iff bit is zero
+ %<bitnum>?ab print a if bit is one else print b
+ %p print 'p' iff bits 12-15 are 15
+ %o print operand2 (immediate or register + shift)
+ %a print address for ldr/str instruction
+ %b print branch destination
+ %A print address for ldc/stc/ldf/stf instruction
+ %m print register mask for ldm/stm instruction
+*/
+
+static struct opcode opcodes[] = {
+ /* ARM instructions */
+ 0x00000090, 0x0fe000f0, "mul%20's %12-15r, %16-19r, %0-3r",
+ 0x00200090, 0x0fe000f0, "mla%20's %12-15r, %16-19r, %0-3r, %8-11r",
+ 0x00000000, 0x0de00000, "and%c%20's %12-15r, %16-19r, %o",
+ 0x00200000, 0x0de00000, "eor%c%20's %12-15r, %16-19r, %o",
+ 0x00400000, 0x0de00000, "sub%c%20's %12-15r, %16-19r, %o",
+ 0x00600000, 0x0de00000, "rsb%c%20's %12-15r, %16-19r, %o",
+ 0x00800000, 0x0de00000, "add%c%20's %12-15r, %16-19r, %o",
+ 0x00a00000, 0x0de00000, "adc%c%20's %12-15r, %16-19r, %o",
+ 0x00c00000, 0x0de00000, "sbc%c%20's %12-15r, %16-19r, %o",
+ 0x00e00000, 0x0de00000, "rsc%c%20's %12-15r, %16-19r, %o",
+ 0x01000000, 0x0de00000, "tst%c%p %16-19r, %o",
+ 0x01200000, 0x0de00000, "teq%c%p %16-19r, %o",
+ 0x01400000, 0x0de00000, "cmp%c%p %16-19r, %o",
+ 0x01600000, 0x0de00000, "cmn%c%p %16-19r, %o",
+ 0x01800000, 0x0de00000, "orr%c%20's %12-15r, %16-19r, %o",
+ 0x01a00000, 0x0de00000, "mov%c%20's %12-15r, %o",
+ 0x01c00000, 0x0de00000, "bic%c%20's %12-15r, %16-19r, %o",
+ 0x01e00000, 0x0de00000, "mvn%c%20's %12-15r, %o",
+ 0x04000000, 0x0c100000, "str%c%22'b %12-15r, %a",
+ 0x04100000, 0x0c100000, "ldr%c%22'b %12-15r, %a",
+ 0x08000000, 0x0e100000, "stm%c%23?id%24?ba %16-19r%22`!, %m",
+ 0x08100000, 0x0e100000, "ldm%c%23?id%24?ba %16-19r%22`!, %m%22'^",
+ 0x0a000000, 0x0e000000, "b%c%24'l %b",
+ 0x0f000000, 0x0f000000, "swi%c %0-23x",
+ /* Floating point coprocessor instructions */
+ 0x0e000100, 0x0ff08f10, "adf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e100100, 0x0ff08f10, "muf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e200100, 0x0ff08f10, "suf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e300100, 0x0ff08f10, "rsf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e400100, 0x0ff08f10, "dvf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e500100, 0x0ff08f10, "rdf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e600100, 0x0ff08f10, "pow%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e700100, 0x0ff08f10, "rpw%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e800100, 0x0ff08f10, "rmf%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e900100, 0x0ff08f10, "fml%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0ea00100, 0x0ff08f10, "fdv%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0eb00100, 0x0ff08f10, "frd%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0ec00100, 0x0ff08f10, "pol%c%P%R %12-14f, %16-18f, %0-3f",
+ 0x0e008100, 0x0ff08f10, "mvf%c%P%R %12-14f, %0-3f",
+ 0x0e108100, 0x0ff08f10, "mnf%c%P%R %12-14f, %0-3f",
+ 0x0e208100, 0x0ff08f10, "abs%c%P%R %12-14f, %0-3f",
+ 0x0e308100, 0x0ff08f10, "rnd%c%P%R %12-14f, %0-3f",
+ 0x0e408100, 0x0ff08f10, "sqt%c%P%R %12-14f, %0-3f",
+ 0x0e508100, 0x0ff08f10, "log%c%P%R %12-14f, %0-3f",
+ 0x0e608100, 0x0ff08f10, "lgn%c%P%R %12-14f, %0-3f",
+ 0x0e708100, 0x0ff08f10, "exp%c%P%R %12-14f, %0-3f",
+ 0x0e808100, 0x0ff08f10, "sin%c%P%R %12-14f, %0-3f",
+ 0x0e908100, 0x0ff08f10, "cos%c%P%R %12-14f, %0-3f",
+ 0x0ea08100, 0x0ff08f10, "tan%c%P%R %12-14f, %0-3f",
+ 0x0eb08100, 0x0ff08f10, "asn%c%P%R %12-14f, %0-3f",
+ 0x0ec08100, 0x0ff08f10, "acs%c%P%R %12-14f, %0-3f",
+ 0x0ed08100, 0x0ff08f10, "atn%c%P%R %12-14f, %0-3f",
+ 0x0e000110, 0x0ff00f1f, "flt%c%P%R %16-18f, %12-15r",
+ 0x0e100110, 0x0fff0f98, "fix%c%R %12-15r, %0-2f",
+ 0x0e200110, 0x0fff0fff, "wfs%c %12-15r",
+ 0x0e300110, 0x0fff0fff, "rfs%c %12-15r",
+ 0x0e400110, 0x0fff0fff, "wfc%c %12-15r",
+ 0x0e500110, 0x0fff0fff, "rfc%c %12-15r",
+ 0x0e90f110, 0x0ff8fff0, "cmf%c %16-18f, %0-3f",
+ 0x0eb0f110, 0x0ff8fff0, "cnf%c %16-18f, %0-3f",
+ 0x0ed0f110, 0x0ff8fff0, "cmfe%c %16-18f, %0-3f",
+ 0x0ef0f110, 0x0ff8fff0, "cnfe%c %16-18f, %0-3f",
+ 0x0c000100, 0x0e100f00, "stf%c%Q %12-14f, %A",
+ 0x0c100100, 0x0e100f00, "ldf%c%Q %12-14f, %A",
+ /* Generic coprocessor instructions */
+ 0x0e000000, 0x0f000010, "cdp%c %8-11d, %20-23d, cr%12-15d, cr%16-19d, cr%0-3d, {%5-7d}",
+ 0x0e000010, 0x0f100010, "mrc%c %8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}",
+ 0x0e100010, 0x0f100010, "mcr%c %8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}",
+ 0x0c000000, 0x0e100000, "stc%c%22`l %8-11d, cr%12-15d, %A",
+ 0x0c100000, 0x0e100000, "ldc%c%22`l %8-11d, cr%12-15d, %A",
+ /* the rest */
+ 0x00000000, 0x00000000, "undefined instruction %0-31x",
+};
+#define N_OPCODES (sizeof opcodes / sizeof opcodes[0])
diff --git a/include/opcode/cgen.h b/include/opcode/cgen.h
new file mode 100644
index 00000000000..84542a37ce1
--- /dev/null
+++ b/include/opcode/cgen.h
@@ -0,0 +1,1380 @@
+/* Header file for targets using CGEN: Cpu tools GENerator.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GDB, the GNU debugger, and the GNU Binutils.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef CGEN_H
+#define CGEN_H
+
+/* ??? This file requires bfd.h but only to get bfd_vma.
+ Seems like an awful lot to require just to get such a fundamental type.
+ Perhaps the definition of bfd_vma can be moved outside of bfd.h.
+ Or perhaps one could duplicate its definition in another file.
+ Until such time, this file conditionally compiles definitions that require
+ bfd_vma using BFD_VERSION. */
+
+/* Enums must be defined before they can be used.
+ Allow them to be used in struct definitions, even though the enum must
+ be defined elsewhere.
+ If CGEN_ARCH isn't defined, this file is being included by something other
+ than <arch>-desc.h. */
+
+/* Prepend the arch name, defined in <arch>-desc.h, and _cgen_ to symbol S.
+ The lack of spaces in the arg list is important for non-stdc systems.
+ This file is included by <arch>-desc.h.
+ It can be included independently of <arch>-desc.h, in which case the arch
+ dependent portions will be declared as "unknown_cgen_foo". */
+
+#ifndef CGEN_SYM
+#define CGEN_SYM(s) CONCAT3 (unknown,_cgen_,s)
+#endif
+
+/* This file contains the static (unchanging) pieces and as much other stuff
+ as we can reasonably put here. It's generally cleaner to put stuff here
+ rather than having it machine generated if possible. */
+
+/* The assembler syntax is made up of expressions (duh...).
+ At the lowest level the values are mnemonics, register names, numbers, etc.
+ Above that are subexpressions, if any (an example might be the
+ "effective address" in m68k cpus). Subexpressions are wip.
+ At the second highest level are the insns themselves. Above that are
+ pseudo-insns, synthetic insns, and macros, if any. */
+
+/* Lots of cpu's have a fixed insn size, or one which rarely changes,
+ and it's generally easier to handle these by treating the insn as an
+ integer type, rather than an array of characters. So we allow targets
+ to control this. When an integer type the value is in host byte order,
+ when an array of characters the value is in target byte order. */
+
+typedef unsigned int CGEN_INSN_INT;
+#if CGEN_INT_INSN_P
+typedef CGEN_INSN_INT CGEN_INSN_BYTES;
+typedef CGEN_INSN_INT *CGEN_INSN_BYTES_PTR;
+#else
+typedef unsigned char *CGEN_INSN_BYTES;
+typedef unsigned char *CGEN_INSN_BYTES_PTR;
+#endif
+
+#ifdef __GNUC__
+#define CGEN_INLINE __inline__
+#else
+#define CGEN_INLINE
+#endif
+
+enum cgen_endian
+{
+ CGEN_ENDIAN_UNKNOWN,
+ CGEN_ENDIAN_LITTLE,
+ CGEN_ENDIAN_BIG
+};
+
+/* Forward decl. */
+
+typedef struct cgen_insn CGEN_INSN;
+
+/* Opaque pointer version for use by external world. */
+
+typedef struct cgen_cpu_desc *CGEN_CPU_DESC;
+
+/* Attributes.
+ Attributes are used to describe various random things associated with
+ an object (ifield, hardware, operand, insn, whatever) and are specified
+ as name/value pairs.
+ Integer attributes computed at compile time are currently all that's
+ supported, though adding string attributes and run-time computation is
+ straightforward. Integer attribute values are always host int's
+ (signed or unsigned). For portability, this means 32 bits.
+ Integer attributes are further categorized as boolean, bitset, integer,
+ and enum types. Boolean attributes appear frequently enough that they're
+ recorded in one host int. This limits the maximum number of boolean
+ attributes to 32, though that's a *lot* of attributes. */
+
+/* Type of attribute values. */
+
+typedef int CGEN_ATTR_VALUE_TYPE;
+
+/* Struct to record attribute information. */
+
+typedef struct
+{
+ /* Boolean attributes. */
+ unsigned int bool;
+ /* Non-boolean integer attributes. */
+ CGEN_ATTR_VALUE_TYPE nonbool[1];
+} CGEN_ATTR;
+
+/* Define a structure member for attributes with N non-boolean entries.
+ There is no maximum number of non-boolean attributes.
+ There is a maximum of 32 boolean attributes (since they are all recorded
+ in one host int). */
+
+#define CGEN_ATTR_TYPE(n) \
+struct { unsigned int bool; \
+ CGEN_ATTR_VALUE_TYPE nonbool[(n) ? (n) : 1]; }
+
+/* Return the boolean attributes. */
+
+#define CGEN_ATTR_BOOLS(a) ((a)->bool)
+
+/* Non-boolean attribute numbers are offset by this much. */
+
+#define CGEN_ATTR_NBOOL_OFFSET 32
+
+/* Given a boolean attribute number, return its mask. */
+
+#define CGEN_ATTR_MASK(attr) (1 << (attr))
+
+/* Return the value of boolean attribute ATTR in ATTRS. */
+
+#define CGEN_BOOL_ATTR(attrs, attr) ((CGEN_ATTR_MASK (attr) & (attrs)) != 0)
+
+/* Return value of attribute ATTR in ATTR_TABLE for OBJ.
+ OBJ is a pointer to the entity that has the attributes
+ (??? not used at present but is reserved for future purposes - eventually
+ the goal is to allow recording attributes in source form and computing
+ them lazily at runtime, not sure of the details yet). */
+
+#define CGEN_ATTR_VALUE(obj, attr_table, attr) \
+((unsigned int) (attr) < CGEN_ATTR_NBOOL_OFFSET \
+ ? ((CGEN_ATTR_BOOLS (attr_table) & CGEN_ATTR_MASK (attr)) != 0) \
+ : ((attr_table)->nonbool[(attr) - CGEN_ATTR_NBOOL_OFFSET]))
+
+/* Attribute name/value tables.
+ These are used to assist parsing of descriptions at run-time. */
+
+typedef struct
+{
+ const char * name;
+ CGEN_ATTR_VALUE_TYPE value;
+} CGEN_ATTR_ENTRY;
+
+/* For each domain (ifld,hw,operand,insn), list of attributes. */
+
+typedef struct
+{
+ const char * name;
+ const CGEN_ATTR_ENTRY * dfault;
+ const CGEN_ATTR_ENTRY * vals;
+} CGEN_ATTR_TABLE;
+
+/* Instruction set variants. */
+
+typedef struct {
+ const char *name;
+
+ /* Default instruction size (in bits).
+ This is used by the assembler when it encounters an unknown insn. */
+ unsigned int default_insn_bitsize;
+
+ /* Base instruction size (in bits).
+ For non-LIW cpus this is generally the length of the smallest insn.
+ For LIW cpus its wip (work-in-progress). For the m32r its 32. */
+ unsigned int base_insn_bitsize;
+
+ /* Minimum/maximum instruction size (in bits). */
+ unsigned int min_insn_bitsize;
+ unsigned int max_insn_bitsize;
+} CGEN_ISA;
+
+/* Machine variants. */
+
+typedef struct {
+ const char *name;
+ /* The argument to bfd_arch_info->scan. */
+ const char *bfd_name;
+ /* one of enum mach_attr */
+ int num;
+} CGEN_MACH;
+
+/* Parse result (also extraction result).
+
+ The result of parsing an insn is stored here.
+ To generate the actual insn, this is passed to the insert handler.
+ When printing an insn, the result of extraction is stored here.
+ To print the insn, this is passed to the print handler.
+
+ It is machine generated so we don't define it here,
+ but we do need a forward decl for the handler fns.
+
+ There is one member for each possible field in the insn.
+ The type depends on the field.
+ Also recorded here is the computed length of the insn for architectures
+ where it varies.
+*/
+
+typedef struct cgen_fields CGEN_FIELDS;
+
+/* Total length of the insn, as recorded in the `fields' struct. */
+/* ??? The field insert handler has lots of opportunities for optimization
+ if it ever gets inlined. On architectures where insns all have the same
+ size, may wish to detect that and make this macro a constant - to allow
+ further optimizations. */
+
+#define CGEN_FIELDS_BITSIZE(fields) ((fields)->length)
+
+/* Extraction support for variable length insn sets. */
+
+/* When disassembling we don't know the number of bytes to read at the start.
+ So the first CGEN_BASE_INSN_SIZE bytes are read at the start and the rest
+ are read when needed. This struct controls this. It is basically the
+ disassemble_info stuff, except that we provide a cache for values already
+ read (since bytes can typically be read several times to fetch multiple
+ operands that may be in them), and that extraction of fields is needed
+ in contexts other than disassembly. */
+
+typedef struct {
+ /* A pointer to the disassemble_info struct.
+ We don't require dis-asm.h so we use PTR for the type here.
+ If NULL, BYTES is full of valid data (VALID == -1). */
+ PTR dis_info;
+ /* Points to a working buffer of sufficient size. */
+ unsigned char *insn_bytes;
+ /* Mask of bytes that are valid in INSN_BYTES. */
+ unsigned int valid;
+} CGEN_EXTRACT_INFO;
+
+/* Associated with each insn or expression is a set of "handlers" for
+ performing operations like parsing, printing, etc. These require a bfd_vma
+ value to be passed around but we don't want all applications to need bfd.h.
+ So this stuff is only provided if bfd.h has been included. */
+
+/* Parse handler.
+ CD is a cpu table descriptor.
+ INSN is a pointer to a struct describing the insn being parsed.
+ STRP is a pointer to a pointer to the text being parsed.
+ FIELDS is a pointer to a cgen_fields struct in which the results are placed.
+ If the expression is successfully parsed, *STRP is updated.
+ If not it is left alone.
+ The result is NULL if success or an error message. */
+typedef const char * (cgen_parse_fn)
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *insn_,
+ const char **strp_, CGEN_FIELDS *fields_));
+
+/* Insert handler.
+ CD is a cpu table descriptor.
+ INSN is a pointer to a struct describing the insn being parsed.
+ FIELDS is a pointer to a cgen_fields struct from which the values
+ are fetched.
+ INSNP is a pointer to a buffer in which to place the insn.
+ PC is the pc value of the insn.
+ The result is an error message or NULL if success. */
+
+#ifdef BFD_VERSION
+typedef const char * (cgen_insert_fn)
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *insn_,
+ CGEN_FIELDS *fields_, CGEN_INSN_BYTES_PTR insnp_,
+ bfd_vma pc_));
+#else
+typedef const char * (cgen_insert_fn) ();
+#endif
+
+/* Extract handler.
+ CD is a cpu table descriptor.
+ INSN is a pointer to a struct describing the insn being parsed.
+ The second argument is a pointer to a struct controlling extraction
+ (only used for variable length insns).
+ EX_INFO is a pointer to a struct for controlling reading of further
+ bytes for the insn.
+ BASE_INSN is the first CGEN_BASE_INSN_SIZE bytes (host order).
+ FIELDS is a pointer to a cgen_fields struct in which the results are placed.
+ PC is the pc value of the insn.
+ The result is the length of the insn in bits or zero if not recognized. */
+
+#ifdef BFD_VERSION
+typedef int (cgen_extract_fn)
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *insn_,
+ CGEN_EXTRACT_INFO *ex_info_, CGEN_INSN_INT base_insn_,
+ CGEN_FIELDS *fields_, bfd_vma pc_));
+#else
+typedef int (cgen_extract_fn) ();
+#endif
+
+/* Print handler.
+ CD is a cpu table descriptor.
+ INFO is a pointer to the disassembly info.
+ Eg: disassemble_info. It's defined as `PTR' so this file can be included
+ without dis-asm.h.
+ INSN is a pointer to a struct describing the insn being printed.
+ FIELDS is a pointer to a cgen_fields struct.
+ PC is the pc value of the insn.
+ LEN is the length of the insn, in bits. */
+
+#ifdef BFD_VERSION
+typedef void (cgen_print_fn)
+ PARAMS ((CGEN_CPU_DESC, PTR info_, const CGEN_INSN *insn_,
+ CGEN_FIELDS *fields_, bfd_vma pc_, int len_));
+#else
+typedef void (cgen_print_fn) ();
+#endif
+
+/* Parse/insert/extract/print handlers.
+
+ Indices into the handler tables.
+ We could use pointers here instead, but 90% of them are generally identical
+ and that's a lot of redundant data. Making these unsigned char indices
+ into tables of pointers saves a bit of space.
+ Using indices also keeps assembler code out of the disassembler and
+ vice versa. */
+
+struct cgen_opcode_handler
+{
+ unsigned char parse, insert, extract, print;
+};
+
+/* Assembler interface.
+
+ The interface to the assembler is intended to be clean in the sense that
+ libopcodes.a is a standalone entity and could be used with any assembler.
+ Not that one would necessarily want to do that but rather that it helps
+ keep a clean interface. The interface will obviously be slanted towards
+ GAS, but at least it's a start.
+ ??? Note that one possible user of the assembler besides GAS is GDB.
+
+ Parsing is controlled by the assembler which calls
+ CGEN_SYM (assemble_insn). If it can parse and build the entire insn
+ it doesn't call back to the assembler. If it needs/wants to call back
+ to the assembler, cgen_parse_operand_fn is called which can either
+
+ - return a number to be inserted in the insn
+ - return a "register" value to be inserted
+ (the register might not be a register per pe)
+ - queue the argument and return a marker saying the expression has been
+ queued (eg: a fix-up)
+ - return an error message indicating the expression wasn't recognizable
+
+ The result is an error message or NULL for success.
+ The parsed value is stored in the bfd_vma *. */
+
+/* Values for indicating what the caller wants. */
+
+enum cgen_parse_operand_type
+{
+ CGEN_PARSE_OPERAND_INIT,
+ CGEN_PARSE_OPERAND_INTEGER,
+ CGEN_PARSE_OPERAND_ADDRESS
+};
+
+/* Values for indicating what was parsed. */
+
+enum cgen_parse_operand_result
+{
+ CGEN_PARSE_OPERAND_RESULT_NUMBER,
+ CGEN_PARSE_OPERAND_RESULT_REGISTER,
+ CGEN_PARSE_OPERAND_RESULT_QUEUED,
+ CGEN_PARSE_OPERAND_RESULT_ERROR
+};
+
+#ifdef BFD_VERSION /* Don't require bfd.h unnecessarily. */
+typedef const char * (cgen_parse_operand_fn)
+ PARAMS ((CGEN_CPU_DESC,
+ enum cgen_parse_operand_type, const char **, int, int,
+ enum cgen_parse_operand_result *, bfd_vma *));
+#else
+typedef const char * (cgen_parse_operand_fn) ();
+#endif
+
+/* Set the cgen_parse_operand_fn callback. */
+
+extern void cgen_set_parse_operand_fn
+ PARAMS ((CGEN_CPU_DESC, cgen_parse_operand_fn));
+
+/* Called before trying to match a table entry with the insn. */
+
+extern void cgen_init_parse_operand PARAMS ((CGEN_CPU_DESC));
+
+/* Operand values (keywords, integers, symbols, etc.) */
+
+/* Types of assembler elements. */
+
+enum cgen_asm_type
+{
+ CGEN_ASM_NONE, CGEN_ASM_KEYWORD, CGEN_ASM_MAX
+};
+
+#ifndef CGEN_ARCH
+enum cgen_hw_type { CGEN_HW_MAX };
+#endif
+
+/* List of hardware elements. */
+
+typedef struct
+{
+ char *name;
+ enum cgen_hw_type type;
+ /* There is currently no example where both index specs and value specs
+ are required, so for now both are clumped under "asm_data". */
+ enum cgen_asm_type asm_type;
+ PTR asm_data;
+#ifndef CGEN_HW_NBOOL_ATTRS
+#define CGEN_HW_NBOOL_ATTRS 1
+#endif
+ CGEN_ATTR_TYPE (CGEN_HW_NBOOL_ATTRS) attrs;
+#define CGEN_HW_ATTRS(hw) (&(hw)->attrs)
+} CGEN_HW_ENTRY;
+
+/* Return value of attribute ATTR in HW. */
+
+#define CGEN_HW_ATTR_VALUE(hw, attr) \
+CGEN_ATTR_VALUE ((hw), CGEN_HW_ATTRS (hw), (attr))
+
+/* Table of hardware elements for selected mach, computed at runtime.
+ enum cgen_hw_type is an index into this table (specifically `entries'). */
+
+typedef struct {
+ /* Pointer to null terminated table of all compiled in entries. */
+ const CGEN_HW_ENTRY *init_entries;
+ unsigned int entry_size; /* since the attribute member is variable sized */
+ /* Array of all entries, initial and run-time added. */
+ const CGEN_HW_ENTRY **entries;
+ /* Number of elements in `entries'. */
+ unsigned int num_entries;
+ /* For now, xrealloc is called each time a new entry is added at runtime.
+ ??? May wish to keep track of some slop to reduce the number of calls to
+ xrealloc, except that there's unlikely to be many and not expected to be
+ in speed critical code. */
+} CGEN_HW_TABLE;
+
+extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_name
+ PARAMS ((CGEN_CPU_DESC, const char *));
+extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_num
+ PARAMS ((CGEN_CPU_DESC, int));
+
+/* This struct is used to describe things like register names, etc. */
+
+typedef struct cgen_keyword_entry
+{
+ /* Name (as in register name). */
+ char * name;
+
+ /* Value (as in register number).
+ The value cannot be -1 as that is used to indicate "not found".
+ IDEA: Have "FUNCTION" attribute? [function is called to fetch value]. */
+ int value;
+
+ /* Attributes.
+ This should, but technically needn't, appear last. It is a variable sized
+ array in that one architecture may have 1 nonbool attribute and another
+ may have more. Having this last means the non-architecture specific code
+ needn't care. The goal is to eventually record
+ attributes in their raw form, evaluate them at run-time, and cache the
+ values, so this worry will go away anyway. */
+ /* ??? Moving this last should be done by treating keywords like insn lists
+ and moving the `next' fields into a CGEN_KEYWORD_LIST struct. */
+ /* FIXME: Not used yet. */
+#ifndef CGEN_KEYWORD_NBOOL_ATTRS
+#define CGEN_KEYWORD_NBOOL_ATTRS 1
+#endif
+ CGEN_ATTR_TYPE (CGEN_KEYWORD_NBOOL_ATTRS) attrs;
+
+ /* ??? Putting these here means compiled in entries can't be const.
+ Not a really big deal, but something to consider. */
+ /* Next name hash table entry. */
+ struct cgen_keyword_entry *next_name;
+ /* Next value hash table entry. */
+ struct cgen_keyword_entry *next_value;
+} CGEN_KEYWORD_ENTRY;
+
+/* Top level struct for describing a set of related keywords
+ (e.g. register names).
+
+ This struct supports run-time entry of new values, and hashed lookups. */
+
+typedef struct cgen_keyword
+{
+ /* Pointer to initial [compiled in] values. */
+ CGEN_KEYWORD_ENTRY *init_entries;
+
+ /* Number of entries in `init_entries'. */
+ unsigned int num_init_entries;
+
+ /* Hash table used for name lookup. */
+ CGEN_KEYWORD_ENTRY **name_hash_table;
+
+ /* Hash table used for value lookup. */
+ CGEN_KEYWORD_ENTRY **value_hash_table;
+
+ /* Number of entries in the hash_tables. */
+ unsigned int hash_table_size;
+
+ /* Pointer to null keyword "" entry if present. */
+ const CGEN_KEYWORD_ENTRY *null_entry;
+} CGEN_KEYWORD;
+
+/* Structure used for searching. */
+
+typedef struct
+{
+ /* Table being searched. */
+ const CGEN_KEYWORD *table;
+
+ /* Specification of what is being searched for. */
+ const char *spec;
+
+ /* Current index in hash table. */
+ unsigned int current_hash;
+
+ /* Current element in current hash chain. */
+ CGEN_KEYWORD_ENTRY *current_entry;
+} CGEN_KEYWORD_SEARCH;
+
+/* Lookup a keyword from its name. */
+
+const CGEN_KEYWORD_ENTRY *cgen_keyword_lookup_name
+ PARAMS ((CGEN_KEYWORD *, const char *));
+
+/* Lookup a keyword from its value. */
+
+const CGEN_KEYWORD_ENTRY *cgen_keyword_lookup_value
+ PARAMS ((CGEN_KEYWORD *, int));
+
+/* Add a keyword. */
+
+void cgen_keyword_add PARAMS ((CGEN_KEYWORD *, CGEN_KEYWORD_ENTRY *));
+
+/* Keyword searching.
+ This can be used to retrieve every keyword, or a subset. */
+
+CGEN_KEYWORD_SEARCH cgen_keyword_search_init
+ PARAMS ((CGEN_KEYWORD *, const char *));
+const CGEN_KEYWORD_ENTRY *cgen_keyword_search_next
+ PARAMS ((CGEN_KEYWORD_SEARCH *));
+
+/* Operand value support routines. */
+
+extern const char *cgen_parse_keyword
+ PARAMS ((CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *));
+#ifdef BFD_VERSION /* Don't require bfd.h unnecessarily. */
+extern const char *cgen_parse_signed_integer
+ PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
+extern const char *cgen_parse_unsigned_integer
+ PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
+extern const char *cgen_parse_address
+ PARAMS ((CGEN_CPU_DESC, const char **, int, int,
+ enum cgen_parse_operand_result *, bfd_vma *));
+extern const char *cgen_validate_signed_integer
+ PARAMS ((long, long, long));
+extern const char *cgen_validate_unsigned_integer
+ PARAMS ((unsigned long, unsigned long, unsigned long));
+#endif
+
+/* Operand modes. */
+
+/* ??? This duplicates the values in arch.h. Revisit.
+ These however need the CGEN_ prefix [as does everything in this file]. */
+/* ??? Targets may need to add their own modes so we may wish to move this
+ to <arch>-opc.h, or add a hook. */
+
+enum cgen_mode {
+ CGEN_MODE_VOID, /* ??? rename simulator's VM to VOID? */
+ CGEN_MODE_BI, CGEN_MODE_QI, CGEN_MODE_HI, CGEN_MODE_SI, CGEN_MODE_DI,
+ CGEN_MODE_UBI, CGEN_MODE_UQI, CGEN_MODE_UHI, CGEN_MODE_USI, CGEN_MODE_UDI,
+ CGEN_MODE_SF, CGEN_MODE_DF, CGEN_MODE_XF, CGEN_MODE_TF,
+ CGEN_MODE_TARGET_MAX,
+ CGEN_MODE_INT, CGEN_MODE_UINT,
+ CGEN_MODE_MAX
+};
+
+/* FIXME: Until simulator is updated. */
+
+#define CGEN_MODE_VM CGEN_MODE_VOID
+
+/* Operands. */
+
+#ifndef CGEN_ARCH
+enum cgen_operand_type { CGEN_OPERAND_MAX };
+#endif
+
+/* "nil" indicator for the operand instance table */
+#define CGEN_OPERAND_NIL CGEN_OPERAND_MAX
+
+/* This struct defines each entry in the operand table. */
+
+typedef struct
+{
+ /* Name as it appears in the syntax string. */
+ char *name;
+
+ /* Operand type. */
+ enum cgen_operand_type type;
+
+ /* The hardware element associated with this operand. */
+ enum cgen_hw_type hw_type;
+
+ /* FIXME: We don't yet record ifield definitions, which we should.
+ When we do it might make sense to delete start/length (since they will
+ be duplicated in the ifield's definition) and replace them with a
+ pointer to the ifield entry. */
+
+ /* Bit position.
+ This is just a hint, and may be unused in more complex operands.
+ May be unused for a modifier. */
+ unsigned char start;
+
+ /* The number of bits in the operand.
+ This is just a hint, and may be unused in more complex operands.
+ May be unused for a modifier. */
+ unsigned char length;
+
+#if 0 /* ??? Interesting idea but relocs tend to get too complicated,
+ and ABI dependent, for simple table lookups to work. */
+ /* Ideally this would be the internal (external?) reloc type. */
+ int reloc_type;
+#endif
+
+ /* Attributes.
+ This should, but technically needn't, appear last. It is a variable sized
+ array in that one architecture may have 1 nonbool attribute and another
+ may have more. Having this last means the non-architecture specific code
+ needn't care, now or tomorrow. The goal is to eventually record
+ attributes in their raw form, evaluate them at run-time, and cache the
+ values, so this worry will go away anyway. */
+#ifndef CGEN_OPERAND_NBOOL_ATTRS
+#define CGEN_OPERAND_NBOOL_ATTRS 1
+#endif
+ CGEN_ATTR_TYPE (CGEN_OPERAND_NBOOL_ATTRS) attrs;
+#define CGEN_OPERAND_ATTRS(operand) (&(operand)->attrs)
+} CGEN_OPERAND;
+
+/* Return value of attribute ATTR in OPERAND. */
+
+#define CGEN_OPERAND_ATTR_VALUE(operand, attr) \
+CGEN_ATTR_VALUE ((operand), CGEN_OPERAND_ATTRS (operand), (attr))
+
+/* Table of operands for selected mach/isa, computed at runtime.
+ enum cgen_operand_type is an index into this table (specifically
+ `entries'). */
+
+typedef struct {
+ /* Pointer to null terminated table of all compiled in entries. */
+ const CGEN_OPERAND *init_entries;
+ unsigned int entry_size; /* since the attribute member is variable sized */
+ /* Array of all entries, initial and run-time added. */
+ const CGEN_OPERAND **entries;
+ /* Number of elements in `entries'. */
+ unsigned int num_entries;
+ /* For now, xrealloc is called each time a new entry is added at runtime.
+ ??? May wish to keep track of some slop to reduce the number of calls to
+ xrealloc, except that there's unlikely to be many and not expected to be
+ in speed critical code. */
+} CGEN_OPERAND_TABLE;
+
+extern const CGEN_OPERAND * cgen_operand_lookup_by_name
+ PARAMS ((CGEN_CPU_DESC, const char *));
+extern const CGEN_OPERAND * cgen_operand_lookup_by_num
+ PARAMS ((CGEN_CPU_DESC, int));
+
+/* Instruction operand instances.
+
+ For each instruction, a list of the hardware elements that are read and
+ written are recorded. */
+
+/* The type of the instance. */
+
+enum cgen_opinst_type {
+ /* End of table marker. */
+ CGEN_OPINST_END = 0,
+ CGEN_OPINST_INPUT, CGEN_OPINST_OUTPUT
+};
+
+typedef struct
+{
+ /* Input or output indicator. */
+ enum cgen_opinst_type type;
+
+ /* Name of operand. */
+ const char *name;
+
+ /* The hardware element referenced. */
+ enum cgen_hw_type hw_type;
+
+ /* The mode in which the operand is being used. */
+ enum cgen_mode mode;
+
+ /* The operand table entry CGEN_OPERAND_NIL if there is none
+ (i.e. an explicit hardware reference). */
+ enum cgen_operand_type op_type;
+
+ /* If `operand' is "nil", the index (e.g. into array of registers). */
+ int index;
+
+ /* Attributes.
+ ??? This perhaps should be a real attribute struct but there's
+ no current need, so we save a bit of space and just have a set of
+ flags. The interface is such that this can easily be made attributes
+ should it prove useful. */
+ unsigned int attrs;
+#define CGEN_OPINST_ATTRS(opinst) ((opinst)->attrs)
+/* Return value of attribute ATTR in OPINST. */
+#define CGEN_OPINST_ATTR(opinst, attr) \
+((CGEN_OPINST_ATTRS (opinst) & (attr)) != 0)
+/* Operand is conditionally referenced (read/written). */
+#define CGEN_OPINST_COND_REF 1
+} CGEN_OPINST;
+
+/* Syntax string.
+
+ Each insn format and subexpression has one of these.
+
+ The syntax "string" consists of characters (n > 0 && n < 128), and operand
+ values (n >= 128), and is terminated by 0. Operand values are 128 + index
+ into the operand table. The operand table doesn't exist in C, per se, as
+ the data is recorded in the parse/insert/extract/print switch statements. */
+
+#ifndef CGEN_MAX_SYNTAX_BYTES
+#define CGEN_MAX_SYNTAX_BYTES 16
+#endif
+
+typedef struct
+{
+ unsigned char syntax[CGEN_MAX_SYNTAX_BYTES];
+} CGEN_SYNTAX;
+
+#define CGEN_SYNTAX_STRING(syn) (syn->syntax)
+#define CGEN_SYNTAX_CHAR_P(c) ((c) < 128)
+#define CGEN_SYNTAX_CHAR(c) (c)
+#define CGEN_SYNTAX_FIELD(c) ((c) - 128)
+#define CGEN_SYNTAX_MAKE_FIELD(c) ((c) + 128)
+
+/* ??? I can't currently think of any case where the mnemonic doesn't come
+ first [and if one ever doesn't building the hash tables will be tricky].
+ However, we treat mnemonics as just another operand of the instruction.
+ A value of 1 means "this is where the mnemonic appears". 1 isn't
+ special other than it's a non-printable ASCII char. */
+
+#define CGEN_SYNTAX_MNEMONIC 1
+#define CGEN_SYNTAX_MNEMONIC_P(ch) ((ch) == CGEN_SYNTAX_MNEMONIC)
+
+/* Instruction fields.
+
+ ??? We currently don't allow adding fields at run-time.
+ Easy to fix when needed. */
+
+typedef struct cgen_ifld {
+ /* Enum of ifield. */
+ int num;
+#define CGEN_IFLD_NUM(f) ((f)->num)
+
+ /* Name of the field, distinguishes it from all other fields. */
+ const char *name;
+#define CGEN_IFLD_NAME(f) ((f)->name)
+
+ /* Default offset, in bits, from the start of the insn to the word
+ containing the field. */
+ int word_offset;
+#define CGEN_IFLD_WORD_OFFSET(f) ((f)->word_offset)
+
+ /* Default length of the word containing the field. */
+ int word_size;
+#define CGEN_IFLD_WORD_SIZE(f) ((f)->word_size)
+
+ /* Default starting bit number.
+ Whether lsb=0 or msb=0 is determined by CGEN_INSN_LSB0_P. */
+ int start;
+#define CGEN_IFLD_START(f) ((f)->start)
+
+ /* Length of the field, in bits. */
+ int length;
+#define CGEN_IFLD_LENGTH(f) ((f)->length)
+
+#ifndef CGEN_IFLD_NBOOL_ATTRS
+#define CGEN_IFLD_NBOOL_ATTRS 1
+#endif
+ CGEN_ATTR_TYPE (CGEN_IFLD_NBOOL_ATTRS) attrs;
+#define CGEN_IFLD_ATTRS(f) (&(f)->attrs)
+} CGEN_IFLD;
+
+/* Return value of attribute ATTR in IFLD. */
+#define CGEN_IFLD_ATTR_VALUE(ifld, attr) \
+CGEN_ATTR_VALUE ((ifld), CGEN_IFLD_ATTRS (ifld), (attr))
+
+/* Instruction data. */
+
+/* Instruction formats.
+
+ Instructions are grouped by format. Associated with an instruction is its
+ format. Each insn's opcode table entry contains a format table entry.
+ ??? There is usually very few formats compared with the number of insns,
+ so one can reduce the size of the opcode table by recording the format table
+ as a separate entity. Given that we currently don't, format table entries
+ are also distinguished by their operands. This increases the size of the
+ table, but reduces the number of tables. It's all minutiae anyway so it
+ doesn't really matter [at this point in time].
+
+ ??? Support for variable length ISA's is wip. */
+
+/* Accompanying each iformat description is a list of its fields. */
+
+typedef struct {
+ const CGEN_IFLD *ifld;
+#define CGEN_IFMT_IFLD_IFLD(ii) ((ii)->ifld)
+} CGEN_IFMT_IFLD;
+
+#ifndef CGEN_MAX_IFMT_OPERANDS
+#define CGEN_MAX_IFMT_OPERANDS 1
+#endif
+
+typedef struct
+{
+ /* Length that MASK and VALUE have been calculated to
+ [VALUE is recorded elsewhere].
+ Normally it is base_insn_bitsize. On [V]LIW architectures where the base
+ insn size may be larger than the size of an insn, this field is less than
+ base_insn_bitsize. */
+ unsigned char mask_length;
+#define CGEN_IFMT_MASK_LENGTH(ifmt) ((ifmt)->mask_length)
+
+ /* Total length of instruction, in bits. */
+ unsigned char length;
+#define CGEN_IFMT_LENGTH(ifmt) ((ifmt)->length)
+
+ /* Mask to apply to the first MASK_LENGTH bits.
+ Each insn's value is stored with the insn.
+ The first step in recognizing an insn for disassembly is
+ (opcode & mask) == value. */
+ CGEN_INSN_INT mask;
+#define CGEN_IFMT_MASK(ifmt) ((ifmt)->mask)
+
+ /* Instruction fields.
+ +1 for trailing NULL. */
+ CGEN_IFMT_IFLD iflds[CGEN_MAX_IFMT_OPERANDS + 1];
+#define CGEN_IFMT_IFLDS(ifmt) ((ifmt)->iflds)
+} CGEN_IFMT;
+
+/* Instruction values. */
+
+typedef struct
+{
+ /* The opcode portion of the base insn. */
+ CGEN_INSN_INT base_value;
+
+#ifdef CGEN_MAX_EXTRA_OPCODE_OPERANDS
+ /* Extra opcode values beyond base_value. */
+ unsigned long ifield_values[CGEN_MAX_EXTRA_OPCODE_OPERANDS];
+#endif
+} CGEN_IVALUE;
+
+/* Instruction opcode table.
+ This contains the syntax and format data of an instruction. */
+
+/* ??? Some ports already have an opcode table yet still need to use the rest
+ of what cgen_insn has. Plus keeping the opcode data with the operand
+ instance data can create a pretty big file. So we keep them separately.
+ Not sure this is a good idea in the long run. */
+
+typedef struct
+{
+ /* Indices into parse/insert/extract/print handler tables. */
+ struct cgen_opcode_handler handlers;
+#define CGEN_OPCODE_HANDLERS(opc) (& (opc)->handlers)
+
+ /* Syntax string. */
+ CGEN_SYNTAX syntax;
+#define CGEN_OPCODE_SYNTAX(opc) (& (opc)->syntax)
+
+ /* Format entry. */
+ const CGEN_IFMT *format;
+#define CGEN_OPCODE_FORMAT(opc) ((opc)->format)
+#define CGEN_OPCODE_MASK_BITSIZE(opc) CGEN_IFMT_MASK_LENGTH (CGEN_OPCODE_FORMAT (opc))
+#define CGEN_OPCODE_BITSIZE(opc) CGEN_IFMT_LENGTH (CGEN_OPCODE_FORMAT (opc))
+#define CGEN_OPCODE_IFLDS(opc) CGEN_IFMT_IFLDS (CGEN_OPCODE_FORMAT (opc))
+
+ /* Instruction opcode value. */
+ CGEN_IVALUE value;
+#define CGEN_OPCODE_VALUE(opc) (& (opc)->value)
+#define CGEN_OPCODE_BASE_VALUE(opc) (CGEN_OPCODE_VALUE (opc)->base_value)
+#define CGEN_OPCODE_BASE_MASK(opc) CGEN_IFMT_MASK (CGEN_OPCODE_FORMAT (opc))
+} CGEN_OPCODE;
+
+/* Instruction attributes.
+ This is made a published type as applications can cache a pointer to
+ the attributes for speed. */
+
+#ifndef CGEN_INSN_NBOOL_ATTRS
+#define CGEN_INSN_NBOOL_ATTRS 1
+#endif
+typedef CGEN_ATTR_TYPE (CGEN_INSN_NBOOL_ATTRS) CGEN_INSN_ATTR_TYPE;
+
+/* Enum of architecture independent attributes. */
+
+#ifndef CGEN_ARCH
+/* ??? Numbers here are recorded in two places. */
+typedef enum cgen_insn_attr {
+ CGEN_INSN_ALIAS = 0
+} CGEN_INSN_ATTR;
+#endif
+
+/* This struct defines each entry in the instruction table. */
+
+typedef struct
+{
+ /* Each real instruction is enumerated. */
+ /* ??? This may go away in time. */
+ int num;
+#define CGEN_INSN_NUM(insn) ((insn)->base->num)
+
+ /* Name of entry (that distinguishes it from all other entries). */
+ /* ??? If mnemonics have operands, try to print full mnemonic. */
+ const char *name;
+#define CGEN_INSN_NAME(insn) ((insn)->base->name)
+
+ /* Mnemonic. This is used when parsing and printing the insn.
+ In the case of insns that have operands on the mnemonics, this is
+ only the constant part. E.g. for conditional execution of an `add' insn,
+ where the full mnemonic is addeq, addne, etc., and the condition is
+ treated as an operand, this is only "add". */
+ const char *mnemonic;
+#define CGEN_INSN_MNEMONIC(insn) ((insn)->base->mnemonic)
+
+ /* Total length of instruction, in bits. */
+ int bitsize;
+#define CGEN_INSN_BITSIZE(insn) ((insn)->base->bitsize)
+
+#if 0 /* ??? Disabled for now as there is a problem with embedded newlines
+ and the table is already pretty big. Should perhaps be moved
+ to a file of its own. */
+ /* Semantics, as RTL. */
+ /* ??? Plain text or bytecodes? */
+ /* ??? Note that the operand instance table could be computed at run-time
+ if we parse this and cache the results. Something to eventually do. */
+ const char *rtx;
+#define CGEN_INSN_RTX(insn) ((insn)->base->rtx)
+#endif
+
+ /* Attributes.
+ This must appear last. It is a variable sized array in that one
+ architecture may have 1 nonbool attribute and another may have more.
+ Having this last means the non-architecture specific code needn't
+ care. The goal is to eventually record attributes in their raw form,
+ evaluate them at run-time, and cache the values, so this worry will go
+ away anyway. */
+ CGEN_INSN_ATTR_TYPE attrs;
+#define CGEN_INSN_ATTRS(insn) (&(insn)->base->attrs)
+/* Return value of attribute ATTR in INSN. */
+#define CGEN_INSN_ATTR_VALUE(insn, attr) \
+CGEN_ATTR_VALUE ((insn), CGEN_INSN_ATTRS (insn), (attr))
+} CGEN_IBASE;
+
+/* Return non-zero if INSN is the "invalid" insn marker. */
+
+#define CGEN_INSN_INVALID_P(insn) (CGEN_INSN_MNEMONIC (insn) == 0)
+
+/* Main struct contain instruction information.
+ BASE is always present, the rest is present only if asked for. */
+
+struct cgen_insn
+{
+ /* ??? May be of use to put a type indicator here.
+ Then this struct could different info for different classes of insns. */
+ /* ??? A speedup can be had by moving `base' into this struct.
+ Maybe later. */
+ const CGEN_IBASE *base;
+ const CGEN_OPCODE *opcode;
+ const CGEN_OPINST *opinst;
+};
+
+/* Instruction lists.
+ This is used for adding new entries and for creating the hash lists. */
+
+typedef struct cgen_insn_list
+{
+ struct cgen_insn_list *next;
+ const CGEN_INSN *insn;
+} CGEN_INSN_LIST;
+
+/* Table of instructions. */
+
+typedef struct
+{
+ const CGEN_INSN *init_entries;
+ unsigned int entry_size; /* since the attribute member is variable sized */
+ unsigned int num_init_entries;
+ CGEN_INSN_LIST *new_entries;
+} CGEN_INSN_TABLE;
+
+/* Return number of instructions. This includes any added at run-time. */
+
+extern int cgen_insn_count PARAMS ((CGEN_CPU_DESC));
+extern int cgen_macro_insn_count PARAMS ((CGEN_CPU_DESC));
+
+/* Macros to access the other insn elements not recorded in CGEN_IBASE. */
+
+/* Fetch INSN's operand instance table. */
+/* ??? Doesn't handle insns added at runtime. */
+#define CGEN_INSN_OPERANDS(insn) ((insn)->opinst)
+
+/* Return INSN's opcode table entry. */
+#define CGEN_INSN_OPCODE(insn) ((insn)->opcode)
+
+/* Return INSN's handler data. */
+#define CGEN_INSN_HANDLERS(insn) CGEN_OPCODE_HANDLERS (CGEN_INSN_OPCODE (insn))
+
+/* Return INSN's syntax. */
+#define CGEN_INSN_SYNTAX(insn) CGEN_OPCODE_SYNTAX (CGEN_INSN_OPCODE (insn))
+
+/* Return size of base mask in bits. */
+#define CGEN_INSN_MASK_BITSIZE(insn) \
+ CGEN_OPCODE_MASK_BITSIZE (CGEN_INSN_OPCODE (insn))
+
+/* Return mask of base part of INSN. */
+#define CGEN_INSN_BASE_MASK(insn) \
+ CGEN_OPCODE_BASE_MASK (CGEN_INSN_OPCODE (insn))
+
+/* Return value of base part of INSN. */
+#define CGEN_INSN_BASE_VALUE(insn) \
+ CGEN_OPCODE_BASE_VALUE (CGEN_INSN_OPCODE (insn))
+
+/* Macro instructions.
+ Macro insns aren't real insns, they map to one or more real insns.
+ E.g. An architecture's "nop" insn may actually be an "mv r0,r0" or
+ some such.
+
+ Macro insns can expand to nothing (e.g. a nop that is optimized away).
+ This is useful in multi-insn macros that build a constant in a register.
+ Of course this isn't the default behaviour and must be explicitly enabled.
+
+ Assembly of macro-insns is relatively straightforward. Disassembly isn't.
+ However, disassembly of at least some kinds of macro insns is important
+ in order that the disassembled code preserve the readability of the original
+ insn. What is attempted here is to disassemble all "simple" macro-insns,
+ where "simple" is currently defined to mean "expands to one real insn".
+
+ Simple macro-insns are handled specially. They are emitted as ALIAS's
+ of real insns. This simplifies their handling since there's usually more
+ of them than any other kind of macro-insn, and proper disassembly of them
+ falls out for free. */
+
+/* For each macro-insn there may be multiple expansion possibilities,
+ depending on the arguments. This structure is accessed via the `data'
+ member of CGEN_INSN. */
+
+typedef struct cgen_minsn_expansion {
+ /* Function to do the expansion.
+ If the expansion fails (e.g. "no match") NULL is returned.
+ Space for the expansion is obtained with malloc.
+ It is up to the caller to free it. */
+ const char * (* fn) PARAMS ((const struct cgen_minsn_expansion *,
+ const char *, const char **, int *,
+ CGEN_OPERAND **));
+#define CGEN_MIEXPN_FN(ex) ((ex)->fn)
+
+ /* Instruction(s) the macro expands to.
+ The format of STR is defined by FN.
+ It is typically the assembly code of the real insn, but it could also be
+ the original Scheme expression or a tokenized form of it (with FN being
+ an appropriate interpreter). */
+ const char * str;
+#define CGEN_MIEXPN_STR(ex) ((ex)->str)
+} CGEN_MINSN_EXPANSION;
+
+/* Normal expander.
+ When supported, this function will convert the input string to another
+ string and the parser will be invoked recursively. The output string
+ may contain further macro invocations. */
+
+extern const char * cgen_expand_macro_insn
+ PARAMS ((CGEN_CPU_DESC, const struct cgen_minsn_expansion *,
+ const char *, const char **, int *, CGEN_OPERAND **));
+
+/* The assembler insn table is hashed based on some function of the mnemonic
+ (the actually hashing done is up to the target, but we provide a few
+ examples like the first letter or a function of the entire mnemonic). */
+
+extern CGEN_INSN_LIST * cgen_asm_lookup_insn
+ PARAMS ((CGEN_CPU_DESC, const char *));
+#define CGEN_ASM_LOOKUP_INSN(cd, string) cgen_asm_lookup_insn ((cd), (string))
+#define CGEN_ASM_NEXT_INSN(insn) ((insn)->next)
+
+/* The disassembler insn table is hashed based on some function of machine
+ instruction (the actually hashing done is up to the target). */
+
+extern CGEN_INSN_LIST * cgen_dis_lookup_insn
+ PARAMS ((CGEN_CPU_DESC, const char *, CGEN_INSN_INT));
+/* FIXME: delete these two */
+#define CGEN_DIS_LOOKUP_INSN(cd, buf, value) cgen_dis_lookup_insn ((cd), (buf), (value))
+#define CGEN_DIS_NEXT_INSN(insn) ((insn)->next)
+
+/* The CPU description.
+ A copy of this is created when the cpu table is "opened".
+ All global state information is recorded here.
+ Access macros are provided for "public" members. */
+
+typedef struct cgen_cpu_desc
+{
+ /* Bitmap of selected machine(s) (a la BFD machine number). */
+ int machs;
+
+ /* Bitmap of selected isa(s).
+ ??? Simultaneous multiple isas might not make sense, but it's not (yet)
+ precluded. */
+ int isas;
+
+ /* Current endian. */
+ enum cgen_endian endian;
+#define CGEN_CPU_ENDIAN(cd) ((cd)->endian)
+
+ /* Current insn endian. */
+ enum cgen_endian insn_endian;
+#define CGEN_CPU_INSN_ENDIAN(cd) ((cd)->insn_endian)
+
+ /* Word size (in bits). */
+ /* ??? Or maybe maximum word size - might we ever need to allow a cpu table
+ to be opened for both sparc32/sparc64?
+ ??? Another alternative is to create a table of selected machs and
+ lazily fetch the data from there. */
+ unsigned int word_bitsize;
+
+ /* Indicator if sizes are unknown.
+ This is used by default_insn_bitsize,base_insn_bitsize if there is a
+ difference between the selected isa's. */
+#define CGEN_SIZE_UNKNOWN 65535
+
+ /* Default instruction size (in bits).
+ This is used by the assembler when it encounters an unknown insn. */
+ unsigned int default_insn_bitsize;
+
+ /* Base instruction size (in bits).
+ For non-LIW cpus this is generally the length of the smallest insn.
+ For LIW cpus its wip (work-in-progress). For the m32r its 32. */
+ unsigned int base_insn_bitsize;
+
+ /* Minimum/maximum instruction size (in bits). */
+ unsigned int min_insn_bitsize;
+ unsigned int max_insn_bitsize;
+
+ /* Instruction set variants. */
+ const CGEN_ISA *isa_table;
+
+ /* Machine variants. */
+ const CGEN_MACH *mach_table;
+
+ /* Hardware elements. */
+ CGEN_HW_TABLE hw_table;
+
+ /* Instruction fields. */
+ const CGEN_IFLD *ifld_table;
+
+ /* Operands. */
+ CGEN_OPERAND_TABLE operand_table;
+
+ /* Main instruction table. */
+ CGEN_INSN_TABLE insn_table;
+#define CGEN_CPU_INSN_TABLE(cd) (& (cd)->insn_table)
+
+ /* Macro instructions are defined separately and are combined with real
+ insns during hash table computation. */
+ CGEN_INSN_TABLE macro_insn_table;
+
+ /* Copy of CGEN_INT_INSN_P. */
+ int int_insn_p;
+
+ /* Called to rebuild the tables after something has changed. */
+ void (*rebuild_tables) PARAMS ((CGEN_CPU_DESC));
+
+ /* Operand parser callback. */
+ cgen_parse_operand_fn * parse_operand_fn;
+
+ /* Parse/insert/extract/print cover fns for operands. */
+ const char * (*parse_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, const char **,
+ CGEN_FIELDS *fields_));
+#ifdef BFD_VERSION
+ const char * (*insert_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_,
+ CGEN_INSN_BYTES_PTR, bfd_vma pc_));
+ int (*extract_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
+ CGEN_FIELDS *fields_, bfd_vma pc_));
+ void (*print_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, PTR info_, CGEN_FIELDS * fields_,
+ void const *attrs_, bfd_vma pc_, int length_));
+#else
+ const char * (*insert_operand) ();
+ int (*extract_operand) ();
+ void (*print_operand) ();
+#endif
+#define CGEN_CPU_PARSE_OPERAND(cd) ((cd)->parse_operand)
+#define CGEN_CPU_INSERT_OPERAND(cd) ((cd)->insert_operand)
+#define CGEN_CPU_EXTRACT_OPERAND(cd) ((cd)->extract_operand)
+#define CGEN_CPU_PRINT_OPERAND(cd) ((cd)->print_operand)
+
+ /* Size of CGEN_FIELDS struct. */
+ unsigned int sizeof_fields;
+#define CGEN_CPU_SIZEOF_FIELDS(cd) ((cd)->sizeof_fields)
+
+ /* Set the bitsize field. */
+ void (*set_fields_bitsize) PARAMS ((CGEN_FIELDS *fields_, int size_));
+#define CGEN_CPU_SET_FIELDS_BITSIZE(cd) ((cd)->set_fields_bitsize)
+
+ /* CGEN_FIELDS accessors. */
+ int (*get_int_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, const CGEN_FIELDS *fields_));
+ void (*set_int_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_, int value_));
+#ifdef BFD_VERSION
+ bfd_vma (*get_vma_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, const CGEN_FIELDS *fields_));
+ void (*set_vma_operand)
+ PARAMS ((CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_, bfd_vma value_));
+#else
+ long (*get_vma_operand) ();
+ void (*set_vma_operand) ();
+#endif
+#define CGEN_CPU_GET_INT_OPERAND(cd) ((cd)->get_int_operand)
+#define CGEN_CPU_SET_INT_OPERAND(cd) ((cd)->set_int_operand)
+#define CGEN_CPU_GET_VMA_OPERAND(cd) ((cd)->get_vma_operand)
+#define CGEN_CPU_SET_VMA_OPERAND(cd) ((cd)->set_vma_operand)
+
+ /* Instruction parse/insert/extract/print handlers. */
+ /* FIXME: make these types uppercase. */
+ cgen_parse_fn * const *parse_handlers;
+ cgen_insert_fn * const *insert_handlers;
+ cgen_extract_fn * const *extract_handlers;
+ cgen_print_fn * const *print_handlers;
+#define CGEN_PARSE_FN(cd, insn) (cd->parse_handlers[(insn)->opcode->handlers.parse])
+#define CGEN_INSERT_FN(cd, insn) (cd->insert_handlers[(insn)->opcode->handlers.insert])
+#define CGEN_EXTRACT_FN(cd, insn) (cd->extract_handlers[(insn)->opcode->handlers.extract])
+#define CGEN_PRINT_FN(cd, insn) (cd->print_handlers[(insn)->opcode->handlers.print])
+
+ /* Return non-zero if insn should be added to hash table. */
+ int (* asm_hash_p) PARAMS ((const CGEN_INSN *));
+
+ /* Assembler hash function. */
+ unsigned int (* asm_hash) PARAMS ((const char *));
+
+ /* Number of entries in assembler hash table. */
+ unsigned int asm_hash_size;
+
+ /* Return non-zero if insn should be added to hash table. */
+ int (* dis_hash_p) PARAMS ((const CGEN_INSN *));
+
+ /* Disassembler hash function. */
+ unsigned int (* dis_hash) PARAMS ((const char *, CGEN_INSN_INT));
+
+ /* Number of entries in disassembler hash table. */
+ unsigned int dis_hash_size;
+
+ /* Assembler instruction hash table. */
+ CGEN_INSN_LIST **asm_hash_table;
+ CGEN_INSN_LIST *asm_hash_table_entries;
+
+ /* Disassembler instruction hash table. */
+ CGEN_INSN_LIST **dis_hash_table;
+ CGEN_INSN_LIST *dis_hash_table_entries;
+} CGEN_CPU_TABLE;
+
+/* wip */
+#ifndef CGEN_WORD_ENDIAN
+#define CGEN_WORD_ENDIAN(cd) CGEN_CPU_ENDIAN (cd)
+#endif
+#ifndef CGEN_INSN_WORD_ENDIAN
+#define CGEN_INSN_WORD_ENDIAN(cd) CGEN_CPU_INSN_ENDIAN (cd)
+#endif
+
+/* Prototypes of major functions. */
+/* FIXME: Move more CGEN_SYM-defined functions into CGEN_CPU_DESC.
+ Not the init fns though, as that would drag in things that mightn't be
+ used and might not even exist. */
+
+/* Argument types to cpu_open. */
+
+enum cgen_cpu_open_arg {
+ CGEN_CPU_OPEN_END,
+ /* Select instruction set(s), arg is bitmap or 0 meaning "unspecified". */
+ CGEN_CPU_OPEN_ISAS,
+ /* Select machine(s), arg is bitmap or 0 meaning "unspecified". */
+ CGEN_CPU_OPEN_MACHS,
+ /* Select machine, arg is mach's bfd name.
+ Multiple machines can be specified by repeated use. */
+ CGEN_CPU_OPEN_BFDMACH,
+ /* Select endian, arg is CGEN_ENDIAN_*. */
+ CGEN_CPU_OPEN_ENDIAN
+};
+
+/* Open a cpu descriptor table for use.
+ ??? We only support ISO C stdargs here, not K&R.
+ Laziness, plus experiment to see if anything requires K&R - eventually
+ K&R will no longer be supported - e.g. GDB is currently trying this. */
+
+extern CGEN_CPU_DESC CGEN_SYM (cpu_open) (enum cgen_cpu_open_arg, ...);
+
+/* Cover fn to handle simple case. */
+
+extern CGEN_CPU_DESC CGEN_SYM (cpu_open_1) PARAMS ((const char *mach_name_,
+ enum cgen_endian endian_));
+
+/* Close it. */
+
+extern void CGEN_SYM (cpu_close) PARAMS ((CGEN_CPU_DESC));
+
+/* Initialize the opcode table for use.
+ Called by init_asm/init_dis. */
+
+extern void CGEN_SYM (init_opcode_table) PARAMS ((CGEN_CPU_DESC cd_));
+
+/* Initialize the ibld table for use.
+ Called by init_asm/init_dis. */
+
+extern void CGEN_SYM (init_ibld_table) PARAMS ((CGEN_CPU_DESC cd_));
+
+/* Initialize an cpu table for assembler or disassembler use.
+ These must be called immediately after cpu_open. */
+
+extern void CGEN_SYM (init_asm) PARAMS ((CGEN_CPU_DESC));
+extern void CGEN_SYM (init_dis) PARAMS ((CGEN_CPU_DESC));
+
+/* Initialize the operand instance table for use. */
+
+extern void CGEN_SYM (init_opinst_table) PARAMS ((CGEN_CPU_DESC cd_));
+
+/* Assemble an instruction. */
+
+extern const CGEN_INSN * CGEN_SYM (assemble_insn)
+ PARAMS ((CGEN_CPU_DESC, const char *, CGEN_FIELDS *,
+ CGEN_INSN_BYTES_PTR, char **));
+
+extern const CGEN_KEYWORD CGEN_SYM (operand_mach);
+extern int CGEN_SYM (get_mach) PARAMS ((const char *));
+
+/* Operand index computation. */
+extern const CGEN_INSN * cgen_lookup_insn
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN * insn_,
+ CGEN_INSN_INT int_value_, unsigned char *bytes_value_,
+ int length_, CGEN_FIELDS *fields_, int alias_p_));
+extern void cgen_get_insn_operands
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN * insn_,
+ const CGEN_FIELDS *fields_, int *indices_));
+extern const CGEN_INSN * cgen_lookup_get_insn_operands
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *insn_,
+ CGEN_INSN_INT int_value_, unsigned char *bytes_value_,
+ int length_, int *indices_, CGEN_FIELDS *fields_));
+
+/* Cover fns to bfd_get/set. */
+
+extern CGEN_INSN_INT cgen_get_insn_value
+ PARAMS ((CGEN_CPU_DESC, unsigned char *, int));
+extern void cgen_put_insn_value
+ PARAMS ((CGEN_CPU_DESC, unsigned char *, int, CGEN_INSN_INT));
+
+/* Read in a cpu description file.
+ ??? For future concerns, including adding instructions to the assembler/
+ disassembler at run-time. */
+
+extern const char * cgen_read_cpu_file
+ PARAMS ((CGEN_CPU_DESC, const char * filename_));
+
+#endif /* CGEN_H */
diff --git a/include/opcode/convex.h b/include/opcode/convex.h
new file mode 100644
index 00000000000..efaeebb65a5
--- /dev/null
+++ b/include/opcode/convex.h
@@ -0,0 +1,1711 @@
+/* Information for instruction disassembly on the Convex.
+ Copyright 1989, 1993 Free Software Foundation.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef CONST
+#define CONST
+#endif /* CONST */
+
+#define xxx 0
+#define rrr 1
+#define rr 2
+#define rxr 3
+#define r 4
+#define nops 5
+#define nr 6
+#define pcrel 7
+#define lr 8
+#define rxl 9
+#define rlr 10
+#define rrl 11
+#define iml 12
+#define imr 13
+#define a1r 14
+#define a1l 15
+#define a2r 16
+#define a2l 17
+#define a3 18
+#define a4 19
+#define a5 20
+#define V 1
+#define S 2
+#define VM 3
+#define A 4
+#define VL 5
+#define VS 6
+#define VLS 7
+#define PSW 8
+/* Prevent an error during "make depend". */
+#if !defined (PC)
+#define PC 9
+#endif
+#define ITR 10
+#define VV 11
+#define ITSR 12
+#define TOC 13
+#define CIR 14
+#define TTR 15
+#define VMU 16
+#define VML 17
+#define ICR 18
+#define TCPU 19
+#define CPUID 20
+#define TID 21
+
+CONST char *op[] = {
+ "",
+ "v0\0v1\0v2\0v3\0v4\0v5\0v6\0v7",
+ "s0\0s1\0s2\0s3\0s4\0s5\0s6\0s7",
+ "vm",
+ "sp\0a1\0a2\0a3\0a4\0a5\0ap\0fp",
+ "vl",
+ "vs",
+ "vls",
+ "psw",
+ "pc",
+ "itr",
+ "vv",
+ "itsr",
+ "toc",
+ "cir",
+ "ttr",
+ "vmu",
+ "vml",
+ "icr",
+ "tcpu",
+ "cpuid",
+ "tid",
+};
+
+CONST struct formstr format0[] = {
+ {0,0,rrr,V,S,S}, /* mov */
+ {0,0,rrr,S,S,V}, /* mov */
+ {1,1,rrr,V,V,V}, /* merg.t */
+ {2,1,rrr,V,V,V}, /* mask.t */
+ {1,2,rrr,V,S,V}, /* merg.f */
+ {2,2,rrr,V,S,V}, /* mask.f */
+ {1,1,rrr,V,S,V}, /* merg.t */
+ {2,1,rrr,V,S,V}, /* mask.t */
+ {3,3,rrr,V,V,V}, /* mul.s */
+ {3,4,rrr,V,V,V}, /* mul.d */
+ {4,3,rrr,V,V,V}, /* div.s */
+ {4,4,rrr,V,V,V}, /* div.d */
+ {3,3,rrr,V,S,V}, /* mul.s */
+ {3,4,rrr,V,S,V}, /* mul.d */
+ {4,3,rrr,V,S,V}, /* div.s */
+ {4,4,rrr,V,S,V}, /* div.d */
+ {5,0,rrr,V,V,V}, /* and */
+ {6,0,rrr,V,V,V}, /* or */
+ {7,0,rrr,V,V,V}, /* xor */
+ {8,0,rrr,V,V,V}, /* shf */
+ {5,0,rrr,V,S,V}, /* and */
+ {6,0,rrr,V,S,V}, /* or */
+ {7,0,rrr,V,S,V}, /* xor */
+ {8,0,rrr,V,S,V}, /* shf */
+ {9,3,rrr,V,V,V}, /* add.s */
+ {9,4,rrr,V,V,V}, /* add.d */
+ {10,3,rrr,V,V,V}, /* sub.s */
+ {10,4,rrr,V,V,V}, /* sub.d */
+ {9,3,rrr,V,S,V}, /* add.s */
+ {9,4,rrr,V,S,V}, /* add.d */
+ {10,3,rrr,V,S,V}, /* sub.s */
+ {10,4,rrr,V,S,V}, /* sub.d */
+ {9,5,rrr,V,V,V}, /* add.b */
+ {9,6,rrr,V,V,V}, /* add.h */
+ {9,7,rrr,V,V,V}, /* add.w */
+ {9,8,rrr,V,V,V}, /* add.l */
+ {9,5,rrr,V,S,V}, /* add.b */
+ {9,6,rrr,V,S,V}, /* add.h */
+ {9,7,rrr,V,S,V}, /* add.w */
+ {9,8,rrr,V,S,V}, /* add.l */
+ {10,5,rrr,V,V,V}, /* sub.b */
+ {10,6,rrr,V,V,V}, /* sub.h */
+ {10,7,rrr,V,V,V}, /* sub.w */
+ {10,8,rrr,V,V,V}, /* sub.l */
+ {10,5,rrr,V,S,V}, /* sub.b */
+ {10,6,rrr,V,S,V}, /* sub.h */
+ {10,7,rrr,V,S,V}, /* sub.w */
+ {10,8,rrr,V,S,V}, /* sub.l */
+ {3,5,rrr,V,V,V}, /* mul.b */
+ {3,6,rrr,V,V,V}, /* mul.h */
+ {3,7,rrr,V,V,V}, /* mul.w */
+ {3,8,rrr,V,V,V}, /* mul.l */
+ {3,5,rrr,V,S,V}, /* mul.b */
+ {3,6,rrr,V,S,V}, /* mul.h */
+ {3,7,rrr,V,S,V}, /* mul.w */
+ {3,8,rrr,V,S,V}, /* mul.l */
+ {4,5,rrr,V,V,V}, /* div.b */
+ {4,6,rrr,V,V,V}, /* div.h */
+ {4,7,rrr,V,V,V}, /* div.w */
+ {4,8,rrr,V,V,V}, /* div.l */
+ {4,5,rrr,V,S,V}, /* div.b */
+ {4,6,rrr,V,S,V}, /* div.h */
+ {4,7,rrr,V,S,V}, /* div.w */
+ {4,8,rrr,V,S,V}, /* div.l */
+};
+
+CONST struct formstr format1[] = {
+ {11,0,xxx,0,0,0}, /* exit */
+ {12,0,a3,0,0,0}, /* jmp */
+ {13,2,a3,0,0,0}, /* jmpi.f */
+ {13,1,a3,0,0,0}, /* jmpi.t */
+ {14,2,a3,0,0,0}, /* jmpa.f */
+ {14,1,a3,0,0,0}, /* jmpa.t */
+ {15,2,a3,0,0,0}, /* jmps.f */
+ {15,1,a3,0,0,0}, /* jmps.t */
+ {16,0,a3,0,0,0}, /* tac */
+ {17,0,a1r,A,0,0}, /* ldea */
+ {18,8,a1l,VLS,0,0}, /* ld.l */
+ {18,9,a1l,VM,0,0}, /* ld.x */
+ {19,0,a3,0,0,0}, /* tas */
+ {20,0,a3,0,0,0}, /* pshea */
+ {21,8,a2l,VLS,0,0}, /* st.l */
+ {21,9,a2l,VM,0,0}, /* st.x */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {22,0,a3,0,0,0}, /* call */
+ {23,0,a3,0,0,0}, /* calls */
+ {24,0,a3,0,0,0}, /* callq */
+ {25,0,a1r,A,0,0}, /* pfork */
+ {26,5,a2r,S,0,0}, /* ste.b */
+ {26,6,a2r,S,0,0}, /* ste.h */
+ {26,7,a2r,S,0,0}, /* ste.w */
+ {26,8,a2r,S,0,0}, /* ste.l */
+ {18,5,a1r,A,0,0}, /* ld.b */
+ {18,6,a1r,A,0,0}, /* ld.h */
+ {18,7,a1r,A,0,0}, /* ld.w */
+ {27,7,a1r,A,0,0}, /* incr.w */
+ {21,5,a2r,A,0,0}, /* st.b */
+ {21,6,a2r,A,0,0}, /* st.h */
+ {21,7,a2r,A,0,0}, /* st.w */
+ {27,8,a1r,S,0,0}, /* incr.l */
+ {18,5,a1r,S,0,0}, /* ld.b */
+ {18,6,a1r,S,0,0}, /* ld.h */
+ {18,7,a1r,S,0,0}, /* ld.w */
+ {18,8,a1r,S,0,0}, /* ld.l */
+ {21,5,a2r,S,0,0}, /* st.b */
+ {21,6,a2r,S,0,0}, /* st.h */
+ {21,7,a2r,S,0,0}, /* st.w */
+ {21,8,a2r,S,0,0}, /* st.l */
+ {18,5,a1r,V,0,0}, /* ld.b */
+ {18,6,a1r,V,0,0}, /* ld.h */
+ {18,7,a1r,V,0,0}, /* ld.w */
+ {18,8,a1r,V,0,0}, /* ld.l */
+ {21,5,a2r,V,0,0}, /* st.b */
+ {21,6,a2r,V,0,0}, /* st.h */
+ {21,7,a2r,V,0,0}, /* st.w */
+ {21,8,a2r,V,0,0}, /* st.l */
+};
+
+CONST struct formstr format2[] = {
+ {28,5,rr,A,A,0}, /* cvtw.b */
+ {28,6,rr,A,A,0}, /* cvtw.h */
+ {29,7,rr,A,A,0}, /* cvtb.w */
+ {30,7,rr,A,A,0}, /* cvth.w */
+ {28,5,rr,S,S,0}, /* cvtw.b */
+ {28,6,rr,S,S,0}, /* cvtw.h */
+ {29,7,rr,S,S,0}, /* cvtb.w */
+ {30,7,rr,S,S,0}, /* cvth.w */
+ {28,3,rr,S,S,0}, /* cvtw.s */
+ {31,7,rr,S,S,0}, /* cvts.w */
+ {32,3,rr,S,S,0}, /* cvtd.s */
+ {31,4,rr,S,S,0}, /* cvts.d */
+ {31,8,rr,S,S,0}, /* cvts.l */
+ {32,8,rr,S,S,0}, /* cvtd.l */
+ {33,3,rr,S,S,0}, /* cvtl.s */
+ {33,4,rr,S,S,0}, /* cvtl.d */
+ {34,0,rr,A,A,0}, /* ldpa */
+ {8,0,nr,A,0,0}, /* shf */
+ {18,6,nr,A,0,0}, /* ld.h */
+ {18,7,nr,A,0,0}, /* ld.w */
+ {33,7,rr,S,S,0}, /* cvtl.w */
+ {28,8,rr,S,S,0}, /* cvtw.l */
+ {35,1,rr,S,S,0}, /* plc.t */
+ {36,0,rr,S,S,0}, /* tzc */
+ {37,6,rr,A,A,0}, /* eq.h */
+ {37,7,rr,A,A,0}, /* eq.w */
+ {37,6,nr,A,0,0}, /* eq.h */
+ {37,7,nr,A,0,0}, /* eq.w */
+ {37,5,rr,S,S,0}, /* eq.b */
+ {37,6,rr,S,S,0}, /* eq.h */
+ {37,7,rr,S,S,0}, /* eq.w */
+ {37,8,rr,S,S,0}, /* eq.l */
+ {38,6,rr,A,A,0}, /* leu.h */
+ {38,7,rr,A,A,0}, /* leu.w */
+ {38,6,nr,A,0,0}, /* leu.h */
+ {38,7,nr,A,0,0}, /* leu.w */
+ {38,5,rr,S,S,0}, /* leu.b */
+ {38,6,rr,S,S,0}, /* leu.h */
+ {38,7,rr,S,S,0}, /* leu.w */
+ {38,8,rr,S,S,0}, /* leu.l */
+ {39,6,rr,A,A,0}, /* ltu.h */
+ {39,7,rr,A,A,0}, /* ltu.w */
+ {39,6,nr,A,0,0}, /* ltu.h */
+ {39,7,nr,A,0,0}, /* ltu.w */
+ {39,5,rr,S,S,0}, /* ltu.b */
+ {39,6,rr,S,S,0}, /* ltu.h */
+ {39,7,rr,S,S,0}, /* ltu.w */
+ {39,8,rr,S,S,0}, /* ltu.l */
+ {40,6,rr,A,A,0}, /* le.h */
+ {40,7,rr,A,A,0}, /* le.w */
+ {40,6,nr,A,0,0}, /* le.h */
+ {40,7,nr,A,0,0}, /* le.w */
+ {40,5,rr,S,S,0}, /* le.b */
+ {40,6,rr,S,S,0}, /* le.h */
+ {40,7,rr,S,S,0}, /* le.w */
+ {40,8,rr,S,S,0}, /* le.l */
+ {41,6,rr,A,A,0}, /* lt.h */
+ {41,7,rr,A,A,0}, /* lt.w */
+ {41,6,nr,A,0,0}, /* lt.h */
+ {41,7,nr,A,0,0}, /* lt.w */
+ {41,5,rr,S,S,0}, /* lt.b */
+ {41,6,rr,S,S,0}, /* lt.h */
+ {41,7,rr,S,S,0}, /* lt.w */
+ {41,8,rr,S,S,0}, /* lt.l */
+ {9,7,rr,S,A,0}, /* add.w */
+ {8,0,rr,A,A,0}, /* shf */
+ {0,0,rr,A,A,0}, /* mov */
+ {0,0,rr,S,A,0}, /* mov */
+ {0,7,rr,S,S,0}, /* mov.w */
+ {8,0,rr,S,S,0}, /* shf */
+ {0,0,rr,S,S,0}, /* mov */
+ {0,0,rr,A,S,0}, /* mov */
+ {5,0,rr,A,A,0}, /* and */
+ {6,0,rr,A,A,0}, /* or */
+ {7,0,rr,A,A,0}, /* xor */
+ {42,0,rr,A,A,0}, /* not */
+ {5,0,rr,S,S,0}, /* and */
+ {6,0,rr,S,S,0}, /* or */
+ {7,0,rr,S,S,0}, /* xor */
+ {42,0,rr,S,S,0}, /* not */
+ {40,3,rr,S,S,0}, /* le.s */
+ {40,4,rr,S,S,0}, /* le.d */
+ {41,3,rr,S,S,0}, /* lt.s */
+ {41,4,rr,S,S,0}, /* lt.d */
+ {9,3,rr,S,S,0}, /* add.s */
+ {9,4,rr,S,S,0}, /* add.d */
+ {10,3,rr,S,S,0}, /* sub.s */
+ {10,4,rr,S,S,0}, /* sub.d */
+ {37,3,rr,S,S,0}, /* eq.s */
+ {37,4,rr,S,S,0}, /* eq.d */
+ {43,6,rr,A,A,0}, /* neg.h */
+ {43,7,rr,A,A,0}, /* neg.w */
+ {3,3,rr,S,S,0}, /* mul.s */
+ {3,4,rr,S,S,0}, /* mul.d */
+ {4,3,rr,S,S,0}, /* div.s */
+ {4,4,rr,S,S,0}, /* div.d */
+ {9,6,rr,A,A,0}, /* add.h */
+ {9,7,rr,A,A,0}, /* add.w */
+ {9,6,nr,A,0,0}, /* add.h */
+ {9,7,nr,A,0,0}, /* add.w */
+ {9,5,rr,S,S,0}, /* add.b */
+ {9,6,rr,S,S,0}, /* add.h */
+ {9,7,rr,S,S,0}, /* add.w */
+ {9,8,rr,S,S,0}, /* add.l */
+ {10,6,rr,A,A,0}, /* sub.h */
+ {10,7,rr,A,A,0}, /* sub.w */
+ {10,6,nr,A,0,0}, /* sub.h */
+ {10,7,nr,A,0,0}, /* sub.w */
+ {10,5,rr,S,S,0}, /* sub.b */
+ {10,6,rr,S,S,0}, /* sub.h */
+ {10,7,rr,S,S,0}, /* sub.w */
+ {10,8,rr,S,S,0}, /* sub.l */
+ {3,6,rr,A,A,0}, /* mul.h */
+ {3,7,rr,A,A,0}, /* mul.w */
+ {3,6,nr,A,0,0}, /* mul.h */
+ {3,7,nr,A,0,0}, /* mul.w */
+ {3,5,rr,S,S,0}, /* mul.b */
+ {3,6,rr,S,S,0}, /* mul.h */
+ {3,7,rr,S,S,0}, /* mul.w */
+ {3,8,rr,S,S,0}, /* mul.l */
+ {4,6,rr,A,A,0}, /* div.h */
+ {4,7,rr,A,A,0}, /* div.w */
+ {4,6,nr,A,0,0}, /* div.h */
+ {4,7,nr,A,0,0}, /* div.w */
+ {4,5,rr,S,S,0}, /* div.b */
+ {4,6,rr,S,S,0}, /* div.h */
+ {4,7,rr,S,S,0}, /* div.w */
+ {4,8,rr,S,S,0}, /* div.l */
+};
+
+CONST struct formstr format3[] = {
+ {32,3,rr,V,V,0}, /* cvtd.s */
+ {31,4,rr,V,V,0}, /* cvts.d */
+ {33,4,rr,V,V,0}, /* cvtl.d */
+ {32,8,rr,V,V,0}, /* cvtd.l */
+ {0,0,rrl,S,S,VM}, /* mov */
+ {0,0,rlr,S,VM,S}, /* mov */
+ {0,0,0,0,0,0},
+ {44,0,rr,S,S,0}, /* lop */
+ {36,0,rr,V,V,0}, /* tzc */
+ {44,0,rr,V,V,0}, /* lop */
+ {0,0,0,0,0,0},
+ {42,0,rr,V,V,0}, /* not */
+ {8,0,rr,S,V,0}, /* shf */
+ {35,1,rr,V,V,0}, /* plc.t */
+ {45,2,rr,V,V,0}, /* cprs.f */
+ {45,1,rr,V,V,0}, /* cprs.t */
+ {37,3,rr,V,V,0}, /* eq.s */
+ {37,4,rr,V,V,0}, /* eq.d */
+ {43,3,rr,V,V,0}, /* neg.s */
+ {43,4,rr,V,V,0}, /* neg.d */
+ {37,3,rr,S,V,0}, /* eq.s */
+ {37,4,rr,S,V,0}, /* eq.d */
+ {43,3,rr,S,S,0}, /* neg.s */
+ {43,4,rr,S,S,0}, /* neg.d */
+ {40,3,rr,V,V,0}, /* le.s */
+ {40,4,rr,V,V,0}, /* le.d */
+ {41,3,rr,V,V,0}, /* lt.s */
+ {41,4,rr,V,V,0}, /* lt.d */
+ {40,3,rr,S,V,0}, /* le.s */
+ {40,4,rr,S,V,0}, /* le.d */
+ {41,3,rr,S,V,0}, /* lt.s */
+ {41,4,rr,S,V,0}, /* lt.d */
+ {37,5,rr,V,V,0}, /* eq.b */
+ {37,6,rr,V,V,0}, /* eq.h */
+ {37,7,rr,V,V,0}, /* eq.w */
+ {37,8,rr,V,V,0}, /* eq.l */
+ {37,5,rr,S,V,0}, /* eq.b */
+ {37,6,rr,S,V,0}, /* eq.h */
+ {37,7,rr,S,V,0}, /* eq.w */
+ {37,8,rr,S,V,0}, /* eq.l */
+ {40,5,rr,V,V,0}, /* le.b */
+ {40,6,rr,V,V,0}, /* le.h */
+ {40,7,rr,V,V,0}, /* le.w */
+ {40,8,rr,V,V,0}, /* le.l */
+ {40,5,rr,S,V,0}, /* le.b */
+ {40,6,rr,S,V,0}, /* le.h */
+ {40,7,rr,S,V,0}, /* le.w */
+ {40,8,rr,S,V,0}, /* le.l */
+ {41,5,rr,V,V,0}, /* lt.b */
+ {41,6,rr,V,V,0}, /* lt.h */
+ {41,7,rr,V,V,0}, /* lt.w */
+ {41,8,rr,V,V,0}, /* lt.l */
+ {41,5,rr,S,V,0}, /* lt.b */
+ {41,6,rr,S,V,0}, /* lt.h */
+ {41,7,rr,S,V,0}, /* lt.w */
+ {41,8,rr,S,V,0}, /* lt.l */
+ {43,5,rr,V,V,0}, /* neg.b */
+ {43,6,rr,V,V,0}, /* neg.h */
+ {43,7,rr,V,V,0}, /* neg.w */
+ {43,8,rr,V,V,0}, /* neg.l */
+ {43,5,rr,S,S,0}, /* neg.b */
+ {43,6,rr,S,S,0}, /* neg.h */
+ {43,7,rr,S,S,0}, /* neg.w */
+ {43,8,rr,S,S,0}, /* neg.l */
+};
+
+CONST struct formstr format4[] = {
+ {46,0,nops,0,0,0}, /* nop */
+ {47,0,pcrel,0,0,0}, /* br */
+ {48,2,pcrel,0,0,0}, /* bri.f */
+ {48,1,pcrel,0,0,0}, /* bri.t */
+ {49,2,pcrel,0,0,0}, /* bra.f */
+ {49,1,pcrel,0,0,0}, /* bra.t */
+ {50,2,pcrel,0,0,0}, /* brs.f */
+ {50,1,pcrel,0,0,0}, /* brs.t */
+};
+
+CONST struct formstr format5[] = {
+ {51,5,rr,V,V,0}, /* ldvi.b */
+ {51,6,rr,V,V,0}, /* ldvi.h */
+ {51,7,rr,V,V,0}, /* ldvi.w */
+ {51,8,rr,V,V,0}, /* ldvi.l */
+ {28,3,rr,V,V,0}, /* cvtw.s */
+ {31,7,rr,V,V,0}, /* cvts.w */
+ {28,8,rr,V,V,0}, /* cvtw.l */
+ {33,7,rr,V,V,0}, /* cvtl.w */
+ {52,5,rxr,V,V,0}, /* stvi.b */
+ {52,6,rxr,V,V,0}, /* stvi.h */
+ {52,7,rxr,V,V,0}, /* stvi.w */
+ {52,8,rxr,V,V,0}, /* stvi.l */
+ {52,5,rxr,S,V,0}, /* stvi.b */
+ {52,6,rxr,S,V,0}, /* stvi.h */
+ {52,7,rxr,S,V,0}, /* stvi.w */
+ {52,8,rxr,S,V,0}, /* stvi.l */
+};
+
+CONST struct formstr format6[] = {
+ {53,0,r,A,0,0}, /* ldsdr */
+ {54,0,r,A,0,0}, /* ldkdr */
+ {55,3,r,S,0,0}, /* ln.s */
+ {55,4,r,S,0,0}, /* ln.d */
+ {56,0,nops,0,0,0}, /* patu */
+ {57,0,r,A,0,0}, /* pate */
+ {58,0,nops,0,0,0}, /* pich */
+ {59,0,nops,0,0,0}, /* plch */
+ {0,0,lr,PSW,A,0}, /* mov */
+ {0,0,rxl,A,PSW,0}, /* mov */
+ {0,0,lr,PC,A,0}, /* mov */
+ {60,0,r,S,0,0}, /* idle */
+ {0,0,lr,ITR,S,0}, /* mov */
+ {0,0,rxl,S,ITR,0}, /* mov */
+ {0,0,0,0,0,0},
+ {0,0,rxl,S,ITSR,0}, /* mov */
+ {61,0,nops,0,0,0}, /* rtnq */
+ {62,0,nops,0,0,0}, /* cfork */
+ {63,0,nops,0,0,0}, /* rtn */
+ {64,0,nops,0,0,0}, /* wfork */
+ {65,0,nops,0,0,0}, /* join */
+ {66,0,nops,0,0,0}, /* rtnc */
+ {67,3,r,S,0,0}, /* exp.s */
+ {67,4,r,S,0,0}, /* exp.d */
+ {68,3,r,S,0,0}, /* sin.s */
+ {68,4,r,S,0,0}, /* sin.d */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {69,3,r,S,0,0}, /* cos.s */
+ {69,4,r,S,0,0}, /* cos.d */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {70,7,r,A,0,0}, /* psh.w */
+ {0,0,0,0,0,0},
+ {71,7,r,A,0,0}, /* pop.w */
+ {0,0,0,0,0,0},
+ {70,7,r,S,0,0}, /* psh.w */
+ {70,8,r,S,0,0}, /* psh.l */
+ {71,7,r,S,0,0}, /* pop.w */
+ {71,8,r,S,0,0}, /* pop.l */
+ {72,0,nops,0,0,0}, /* eni */
+ {73,0,nops,0,0,0}, /* dsi */
+ {74,0,nops,0,0,0}, /* bkpt */
+ {75,0,nops,0,0,0}, /* msync */
+ {76,0,r,S,0,0}, /* mski */
+ {77,0,r,S,0,0}, /* xmti */
+ {0,0,rxl,S,VV,0}, /* mov */
+ {78,0,nops,0,0,0}, /* tstvv */
+ {0,0,lr,VS,A,0}, /* mov */
+ {0,0,rxl,A,VS,0}, /* mov */
+ {0,0,lr,VL,A,0}, /* mov */
+ {0,0,rxl,A,VL,0}, /* mov */
+ {0,7,lr,VS,S,0}, /* mov.w */
+ {0,7,rxl,S,VS,0}, /* mov.w */
+ {0,7,lr,VL,S,0}, /* mov.w */
+ {0,7,rxl,S,VL,0}, /* mov.w */
+ {79,0,r,A,0,0}, /* diag */
+ {80,0,nops,0,0,0}, /* pbkpt */
+ {81,3,r,S,0,0}, /* sqrt.s */
+ {81,4,r,S,0,0}, /* sqrt.d */
+ {82,0,nops,0,0,0}, /* casr */
+ {0,0,0,0,0,0},
+ {83,3,r,S,0,0}, /* atan.s */
+ {83,4,r,S,0,0}, /* atan.d */
+};
+
+CONST struct formstr format7[] = {
+ {84,5,r,V,0,0}, /* sum.b */
+ {84,6,r,V,0,0}, /* sum.h */
+ {84,7,r,V,0,0}, /* sum.w */
+ {84,8,r,V,0,0}, /* sum.l */
+ {85,0,r,V,0,0}, /* all */
+ {86,0,r,V,0,0}, /* any */
+ {87,0,r,V,0,0}, /* parity */
+ {0,0,0,0,0,0},
+ {88,5,r,V,0,0}, /* max.b */
+ {88,6,r,V,0,0}, /* max.h */
+ {88,7,r,V,0,0}, /* max.w */
+ {88,8,r,V,0,0}, /* max.l */
+ {89,5,r,V,0,0}, /* min.b */
+ {89,6,r,V,0,0}, /* min.h */
+ {89,7,r,V,0,0}, /* min.w */
+ {89,8,r,V,0,0}, /* min.l */
+ {84,3,r,V,0,0}, /* sum.s */
+ {84,4,r,V,0,0}, /* sum.d */
+ {90,3,r,V,0,0}, /* prod.s */
+ {90,4,r,V,0,0}, /* prod.d */
+ {88,3,r,V,0,0}, /* max.s */
+ {88,4,r,V,0,0}, /* max.d */
+ {89,3,r,V,0,0}, /* min.s */
+ {89,4,r,V,0,0}, /* min.d */
+ {90,5,r,V,0,0}, /* prod.b */
+ {90,6,r,V,0,0}, /* prod.h */
+ {90,7,r,V,0,0}, /* prod.w */
+ {90,8,r,V,0,0}, /* prod.l */
+ {35,2,lr,VM,S,0}, /* plc.f */
+ {35,1,lr,VM,S,0}, /* plc.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr formatx[] = {
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr format1a[] = {
+ {91,0,imr,A,0,0}, /* halt */
+ {92,0,a4,0,0,0}, /* sysc */
+ {18,6,imr,A,0,0}, /* ld.h */
+ {18,7,imr,A,0,0}, /* ld.w */
+ {5,0,imr,A,0,0}, /* and */
+ {6,0,imr,A,0,0}, /* or */
+ {7,0,imr,A,0,0}, /* xor */
+ {8,0,imr,A,0,0}, /* shf */
+ {9,6,imr,A,0,0}, /* add.h */
+ {9,7,imr,A,0,0}, /* add.w */
+ {10,6,imr,A,0,0}, /* sub.h */
+ {10,7,imr,A,0,0}, /* sub.w */
+ {3,6,imr,A,0,0}, /* mul.h */
+ {3,7,imr,A,0,0}, /* mul.w */
+ {4,6,imr,A,0,0}, /* div.h */
+ {4,7,imr,A,0,0}, /* div.w */
+ {18,7,iml,VL,0,0}, /* ld.w */
+ {18,7,iml,VS,0,0}, /* ld.w */
+ {0,0,0,0,0,0},
+ {8,7,imr,S,0,0}, /* shf.w */
+ {93,0,a5,0,0,0}, /* trap */
+ {0,0,0,0,0,0},
+ {37,6,imr,A,0,0}, /* eq.h */
+ {37,7,imr,A,0,0}, /* eq.w */
+ {38,6,imr,A,0,0}, /* leu.h */
+ {38,7,imr,A,0,0}, /* leu.w */
+ {39,6,imr,A,0,0}, /* ltu.h */
+ {39,7,imr,A,0,0}, /* ltu.w */
+ {40,6,imr,A,0,0}, /* le.h */
+ {40,7,imr,A,0,0}, /* le.w */
+ {41,6,imr,A,0,0}, /* lt.h */
+ {41,7,imr,A,0,0}, /* lt.w */
+};
+
+CONST struct formstr format1b[] = {
+ {18,4,imr,S,0,0}, /* ld.d */
+ {18,10,imr,S,0,0}, /* ld.u */
+ {18,8,imr,S,0,0}, /* ld.l */
+ {18,7,imr,S,0,0}, /* ld.w */
+ {5,0,imr,S,0,0}, /* and */
+ {6,0,imr,S,0,0}, /* or */
+ {7,0,imr,S,0,0}, /* xor */
+ {8,0,imr,S,0,0}, /* shf */
+ {9,6,imr,S,0,0}, /* add.h */
+ {9,7,imr,S,0,0}, /* add.w */
+ {10,6,imr,S,0,0}, /* sub.h */
+ {10,7,imr,S,0,0}, /* sub.w */
+ {3,6,imr,S,0,0}, /* mul.h */
+ {3,7,imr,S,0,0}, /* mul.w */
+ {4,6,imr,S,0,0}, /* div.h */
+ {4,7,imr,S,0,0}, /* div.w */
+ {9,3,imr,S,0,0}, /* add.s */
+ {10,3,imr,S,0,0}, /* sub.s */
+ {3,3,imr,S,0,0}, /* mul.s */
+ {4,3,imr,S,0,0}, /* div.s */
+ {40,3,imr,S,0,0}, /* le.s */
+ {41,3,imr,S,0,0}, /* lt.s */
+ {37,6,imr,S,0,0}, /* eq.h */
+ {37,7,imr,S,0,0}, /* eq.w */
+ {38,6,imr,S,0,0}, /* leu.h */
+ {38,7,imr,S,0,0}, /* leu.w */
+ {39,6,imr,S,0,0}, /* ltu.h */
+ {39,7,imr,S,0,0}, /* ltu.w */
+ {40,6,imr,S,0,0}, /* le.h */
+ {40,7,imr,S,0,0}, /* le.w */
+ {41,6,imr,S,0,0}, /* lt.h */
+ {41,7,imr,S,0,0}, /* lt.w */
+};
+
+CONST struct formstr e0_format0[] = {
+ {10,3,rrr,S,V,V}, /* sub.s */
+ {10,4,rrr,S,V,V}, /* sub.d */
+ {4,3,rrr,S,V,V}, /* div.s */
+ {4,4,rrr,S,V,V}, /* div.d */
+ {10,11,rrr,S,V,V}, /* sub.s.f */
+ {10,12,rrr,S,V,V}, /* sub.d.f */
+ {4,11,rrr,S,V,V}, /* div.s.f */
+ {4,12,rrr,S,V,V}, /* div.d.f */
+ {3,11,rrr,V,V,V}, /* mul.s.f */
+ {3,12,rrr,V,V,V}, /* mul.d.f */
+ {4,11,rrr,V,V,V}, /* div.s.f */
+ {4,12,rrr,V,V,V}, /* div.d.f */
+ {3,11,rrr,V,S,V}, /* mul.s.f */
+ {3,12,rrr,V,S,V}, /* mul.d.f */
+ {4,11,rrr,V,S,V}, /* div.s.f */
+ {4,12,rrr,V,S,V}, /* div.d.f */
+ {5,2,rrr,V,V,V}, /* and.f */
+ {6,2,rrr,V,V,V}, /* or.f */
+ {7,2,rrr,V,V,V}, /* xor.f */
+ {8,2,rrr,V,V,V}, /* shf.f */
+ {5,2,rrr,V,S,V}, /* and.f */
+ {6,2,rrr,V,S,V}, /* or.f */
+ {7,2,rrr,V,S,V}, /* xor.f */
+ {8,2,rrr,V,S,V}, /* shf.f */
+ {9,11,rrr,V,V,V}, /* add.s.f */
+ {9,12,rrr,V,V,V}, /* add.d.f */
+ {10,11,rrr,V,V,V}, /* sub.s.f */
+ {10,12,rrr,V,V,V}, /* sub.d.f */
+ {9,11,rrr,V,S,V}, /* add.s.f */
+ {9,12,rrr,V,S,V}, /* add.d.f */
+ {10,11,rrr,V,S,V}, /* sub.s.f */
+ {10,12,rrr,V,S,V}, /* sub.d.f */
+ {9,13,rrr,V,V,V}, /* add.b.f */
+ {9,14,rrr,V,V,V}, /* add.h.f */
+ {9,15,rrr,V,V,V}, /* add.w.f */
+ {9,16,rrr,V,V,V}, /* add.l.f */
+ {9,13,rrr,V,S,V}, /* add.b.f */
+ {9,14,rrr,V,S,V}, /* add.h.f */
+ {9,15,rrr,V,S,V}, /* add.w.f */
+ {9,16,rrr,V,S,V}, /* add.l.f */
+ {10,13,rrr,V,V,V}, /* sub.b.f */
+ {10,14,rrr,V,V,V}, /* sub.h.f */
+ {10,15,rrr,V,V,V}, /* sub.w.f */
+ {10,16,rrr,V,V,V}, /* sub.l.f */
+ {10,13,rrr,V,S,V}, /* sub.b.f */
+ {10,14,rrr,V,S,V}, /* sub.h.f */
+ {10,15,rrr,V,S,V}, /* sub.w.f */
+ {10,16,rrr,V,S,V}, /* sub.l.f */
+ {3,13,rrr,V,V,V}, /* mul.b.f */
+ {3,14,rrr,V,V,V}, /* mul.h.f */
+ {3,15,rrr,V,V,V}, /* mul.w.f */
+ {3,16,rrr,V,V,V}, /* mul.l.f */
+ {3,13,rrr,V,S,V}, /* mul.b.f */
+ {3,14,rrr,V,S,V}, /* mul.h.f */
+ {3,15,rrr,V,S,V}, /* mul.w.f */
+ {3,16,rrr,V,S,V}, /* mul.l.f */
+ {4,13,rrr,V,V,V}, /* div.b.f */
+ {4,14,rrr,V,V,V}, /* div.h.f */
+ {4,15,rrr,V,V,V}, /* div.w.f */
+ {4,16,rrr,V,V,V}, /* div.l.f */
+ {4,13,rrr,V,S,V}, /* div.b.f */
+ {4,14,rrr,V,S,V}, /* div.h.f */
+ {4,15,rrr,V,S,V}, /* div.w.f */
+ {4,16,rrr,V,S,V}, /* div.l.f */
+};
+
+CONST struct formstr e0_format1[] = {
+ {0,0,0,0,0,0},
+ {94,0,a3,0,0,0}, /* tst */
+ {95,0,a3,0,0,0}, /* lck */
+ {96,0,a3,0,0,0}, /* ulk */
+ {17,0,a1r,S,0,0}, /* ldea */
+ {97,0,a1r,A,0,0}, /* spawn */
+ {98,0,a1r,A,0,0}, /* ldcmr */
+ {99,0,a2r,A,0,0}, /* stcmr */
+ {100,0,a1r,A,0,0}, /* popr */
+ {101,0,a2r,A,0,0}, /* pshr */
+ {102,7,a1r,A,0,0}, /* rcvr.w */
+ {103,7,a2r,A,0,0}, /* matm.w */
+ {104,7,a2r,A,0,0}, /* sndr.w */
+ {104,8,a2r,S,0,0}, /* sndr.l */
+ {102,8,a1r,S,0,0}, /* rcvr.l */
+ {103,8,a2r,S,0,0}, /* matm.l */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {105,7,a2r,A,0,0}, /* putr.w */
+ {105,8,a2r,S,0,0}, /* putr.l */
+ {106,7,a1r,A,0,0}, /* getr.w */
+ {106,8,a1r,S,0,0}, /* getr.l */
+ {26,13,a2r,S,0,0}, /* ste.b.f */
+ {26,14,a2r,S,0,0}, /* ste.h.f */
+ {26,15,a2r,S,0,0}, /* ste.w.f */
+ {26,16,a2r,S,0,0}, /* ste.l.f */
+ {107,7,a2r,A,0,0}, /* matr.w */
+ {108,7,a2r,A,0,0}, /* mat.w */
+ {109,7,a1r,A,0,0}, /* get.w */
+ {110,7,a1r,A,0,0}, /* rcv.w */
+ {0,0,0,0,0,0},
+ {111,7,a1r,A,0,0}, /* inc.w */
+ {112,7,a2r,A,0,0}, /* put.w */
+ {113,7,a2r,A,0,0}, /* snd.w */
+ {107,8,a2r,S,0,0}, /* matr.l */
+ {108,8,a2r,S,0,0}, /* mat.l */
+ {109,8,a1r,S,0,0}, /* get.l */
+ {110,8,a1r,S,0,0}, /* rcv.l */
+ {0,0,0,0,0,0},
+ {111,8,a1r,S,0,0}, /* inc.l */
+ {112,8,a2r,S,0,0}, /* put.l */
+ {113,8,a2r,S,0,0}, /* snd.l */
+ {18,13,a1r,V,0,0}, /* ld.b.f */
+ {18,14,a1r,V,0,0}, /* ld.h.f */
+ {18,15,a1r,V,0,0}, /* ld.w.f */
+ {18,16,a1r,V,0,0}, /* ld.l.f */
+ {21,13,a2r,V,0,0}, /* st.b.f */
+ {21,14,a2r,V,0,0}, /* st.h.f */
+ {21,15,a2r,V,0,0}, /* st.w.f */
+ {21,16,a2r,V,0,0}, /* st.l.f */
+};
+
+CONST struct formstr e0_format2[] = {
+ {28,5,rr,V,V,0}, /* cvtw.b */
+ {28,6,rr,V,V,0}, /* cvtw.h */
+ {29,7,rr,V,V,0}, /* cvtb.w */
+ {30,7,rr,V,V,0}, /* cvth.w */
+ {28,13,rr,V,V,0}, /* cvtw.b.f */
+ {28,14,rr,V,V,0}, /* cvtw.h.f */
+ {29,15,rr,V,V,0}, /* cvtb.w.f */
+ {30,15,rr,V,V,0}, /* cvth.w.f */
+ {31,8,rr,V,V,0}, /* cvts.l */
+ {32,7,rr,V,V,0}, /* cvtd.w */
+ {33,3,rr,V,V,0}, /* cvtl.s */
+ {28,4,rr,V,V,0}, /* cvtw.d */
+ {31,16,rr,V,V,0}, /* cvts.l.f */
+ {32,15,rr,V,V,0}, /* cvtd.w.f */
+ {33,11,rr,V,V,0}, /* cvtl.s.f */
+ {28,12,rr,V,V,0}, /* cvtw.d.f */
+ {114,0,rr,S,S,0}, /* enal */
+ {8,7,rr,S,S,0}, /* shf.w */
+ {115,0,rr,S,S,0}, /* enag */
+ {0,0,0,0,0,0},
+ {28,4,rr,S,S,0}, /* cvtw.d */
+ {32,7,rr,S,S,0}, /* cvtd.w */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {116,3,rr,S,S,0}, /* frint.s */
+ {116,4,rr,S,S,0}, /* frint.d */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {116,3,rr,V,V,0}, /* frint.s */
+ {116,4,rr,V,V,0}, /* frint.d */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {116,11,rr,V,V,0}, /* frint.s.f */
+ {116,12,rr,V,V,0}, /* frint.d.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {81,3,rr,V,V,0}, /* sqrt.s */
+ {81,4,rr,V,V,0}, /* sqrt.d */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {81,11,rr,V,V,0}, /* sqrt.s.f */
+ {81,12,rr,V,V,0}, /* sqrt.d.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e0_format3[] = {
+ {32,11,rr,V,V,0}, /* cvtd.s.f */
+ {31,12,rr,V,V,0}, /* cvts.d.f */
+ {33,12,rr,V,V,0}, /* cvtl.d.f */
+ {32,16,rr,V,V,0}, /* cvtd.l.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {36,2,rr,V,V,0}, /* tzc.f */
+ {44,2,rr,V,V,0}, /* lop.f */
+ {117,2,rr,V,V,0}, /* xpnd.f */
+ {42,2,rr,V,V,0}, /* not.f */
+ {8,2,rr,S,V,0}, /* shf.f */
+ {35,17,rr,V,V,0}, /* plc.t.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {37,11,rr,V,V,0}, /* eq.s.f */
+ {37,12,rr,V,V,0}, /* eq.d.f */
+ {43,11,rr,V,V,0}, /* neg.s.f */
+ {43,12,rr,V,V,0}, /* neg.d.f */
+ {37,11,rr,S,V,0}, /* eq.s.f */
+ {37,12,rr,S,V,0}, /* eq.d.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {40,11,rr,V,V,0}, /* le.s.f */
+ {40,12,rr,V,V,0}, /* le.d.f */
+ {41,11,rr,V,V,0}, /* lt.s.f */
+ {41,12,rr,V,V,0}, /* lt.d.f */
+ {40,11,rr,S,V,0}, /* le.s.f */
+ {40,12,rr,S,V,0}, /* le.d.f */
+ {41,11,rr,S,V,0}, /* lt.s.f */
+ {41,12,rr,S,V,0}, /* lt.d.f */
+ {37,13,rr,V,V,0}, /* eq.b.f */
+ {37,14,rr,V,V,0}, /* eq.h.f */
+ {37,15,rr,V,V,0}, /* eq.w.f */
+ {37,16,rr,V,V,0}, /* eq.l.f */
+ {37,13,rr,S,V,0}, /* eq.b.f */
+ {37,14,rr,S,V,0}, /* eq.h.f */
+ {37,15,rr,S,V,0}, /* eq.w.f */
+ {37,16,rr,S,V,0}, /* eq.l.f */
+ {40,13,rr,V,V,0}, /* le.b.f */
+ {40,14,rr,V,V,0}, /* le.h.f */
+ {40,15,rr,V,V,0}, /* le.w.f */
+ {40,16,rr,V,V,0}, /* le.l.f */
+ {40,13,rr,S,V,0}, /* le.b.f */
+ {40,14,rr,S,V,0}, /* le.h.f */
+ {40,15,rr,S,V,0}, /* le.w.f */
+ {40,16,rr,S,V,0}, /* le.l.f */
+ {41,13,rr,V,V,0}, /* lt.b.f */
+ {41,14,rr,V,V,0}, /* lt.h.f */
+ {41,15,rr,V,V,0}, /* lt.w.f */
+ {41,16,rr,V,V,0}, /* lt.l.f */
+ {41,13,rr,S,V,0}, /* lt.b.f */
+ {41,14,rr,S,V,0}, /* lt.h.f */
+ {41,15,rr,S,V,0}, /* lt.w.f */
+ {41,16,rr,S,V,0}, /* lt.l.f */
+ {43,13,rr,V,V,0}, /* neg.b.f */
+ {43,14,rr,V,V,0}, /* neg.h.f */
+ {43,15,rr,V,V,0}, /* neg.w.f */
+ {43,16,rr,V,V,0}, /* neg.l.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e0_format4[] = {
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e0_format5[] = {
+ {51,13,rr,V,V,0}, /* ldvi.b.f */
+ {51,14,rr,V,V,0}, /* ldvi.h.f */
+ {51,15,rr,V,V,0}, /* ldvi.w.f */
+ {51,16,rr,V,V,0}, /* ldvi.l.f */
+ {28,11,rr,V,V,0}, /* cvtw.s.f */
+ {31,15,rr,V,V,0}, /* cvts.w.f */
+ {28,16,rr,V,V,0}, /* cvtw.l.f */
+ {33,15,rr,V,V,0}, /* cvtl.w.f */
+ {52,13,rxr,V,V,0}, /* stvi.b.f */
+ {52,14,rxr,V,V,0}, /* stvi.h.f */
+ {52,15,rxr,V,V,0}, /* stvi.w.f */
+ {52,16,rxr,V,V,0}, /* stvi.l.f */
+ {52,13,rxr,S,V,0}, /* stvi.b.f */
+ {52,14,rxr,S,V,0}, /* stvi.h.f */
+ {52,15,rxr,S,V,0}, /* stvi.w.f */
+ {52,16,rxr,S,V,0}, /* stvi.l.f */
+};
+
+CONST struct formstr e0_format6[] = {
+ {0,0,rxl,S,CIR,0}, /* mov */
+ {0,0,lr,CIR,S,0}, /* mov */
+ {0,0,lr,TOC,S,0}, /* mov */
+ {0,0,lr,CPUID,S,0}, /* mov */
+ {0,0,rxl,S,TTR,0}, /* mov */
+ {0,0,lr,TTR,S,0}, /* mov */
+ {118,0,nops,0,0,0}, /* ctrsl */
+ {119,0,nops,0,0,0}, /* ctrsg */
+ {0,0,rxl,S,VMU,0}, /* mov */
+ {0,0,lr,VMU,S,0}, /* mov */
+ {0,0,rxl,S,VML,0}, /* mov */
+ {0,0,lr,VML,S,0}, /* mov */
+ {0,0,rxl,S,ICR,0}, /* mov */
+ {0,0,lr,ICR,S,0}, /* mov */
+ {0,0,rxl,S,TCPU,0}, /* mov */
+ {0,0,lr,TCPU,S,0}, /* mov */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {120,0,nops,0,0,0}, /* stop */
+ {0,0,0,0,0,0},
+ {0,0,rxl,S,TID,0}, /* mov */
+ {0,0,lr,TID,S,0}, /* mov */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e0_format7[] = {
+ {84,13,r,V,0,0}, /* sum.b.f */
+ {84,14,r,V,0,0}, /* sum.h.f */
+ {84,15,r,V,0,0}, /* sum.w.f */
+ {84,16,r,V,0,0}, /* sum.l.f */
+ {85,2,r,V,0,0}, /* all.f */
+ {86,2,r,V,0,0}, /* any.f */
+ {87,2,r,V,0,0}, /* parity.f */
+ {0,0,0,0,0,0},
+ {88,13,r,V,0,0}, /* max.b.f */
+ {88,14,r,V,0,0}, /* max.h.f */
+ {88,15,r,V,0,0}, /* max.w.f */
+ {88,16,r,V,0,0}, /* max.l.f */
+ {89,13,r,V,0,0}, /* min.b.f */
+ {89,14,r,V,0,0}, /* min.h.f */
+ {89,15,r,V,0,0}, /* min.w.f */
+ {89,16,r,V,0,0}, /* min.l.f */
+ {84,11,r,V,0,0}, /* sum.s.f */
+ {84,12,r,V,0,0}, /* sum.d.f */
+ {90,11,r,V,0,0}, /* prod.s.f */
+ {90,12,r,V,0,0}, /* prod.d.f */
+ {88,11,r,V,0,0}, /* max.s.f */
+ {88,12,r,V,0,0}, /* max.d.f */
+ {89,11,r,V,0,0}, /* min.s.f */
+ {89,12,r,V,0,0}, /* min.d.f */
+ {90,13,r,V,0,0}, /* prod.b.f */
+ {90,14,r,V,0,0}, /* prod.h.f */
+ {90,15,r,V,0,0}, /* prod.w.f */
+ {90,16,r,V,0,0}, /* prod.l.f */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e1_format0[] = {
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {10,18,rrr,S,V,V}, /* sub.s.t */
+ {10,19,rrr,S,V,V}, /* sub.d.t */
+ {4,18,rrr,S,V,V}, /* div.s.t */
+ {4,19,rrr,S,V,V}, /* div.d.t */
+ {3,18,rrr,V,V,V}, /* mul.s.t */
+ {3,19,rrr,V,V,V}, /* mul.d.t */
+ {4,18,rrr,V,V,V}, /* div.s.t */
+ {4,19,rrr,V,V,V}, /* div.d.t */
+ {3,18,rrr,V,S,V}, /* mul.s.t */
+ {3,19,rrr,V,S,V}, /* mul.d.t */
+ {4,18,rrr,V,S,V}, /* div.s.t */
+ {4,19,rrr,V,S,V}, /* div.d.t */
+ {5,1,rrr,V,V,V}, /* and.t */
+ {6,1,rrr,V,V,V}, /* or.t */
+ {7,1,rrr,V,V,V}, /* xor.t */
+ {8,1,rrr,V,V,V}, /* shf.t */
+ {5,1,rrr,V,S,V}, /* and.t */
+ {6,1,rrr,V,S,V}, /* or.t */
+ {7,1,rrr,V,S,V}, /* xor.t */
+ {8,1,rrr,V,S,V}, /* shf.t */
+ {9,18,rrr,V,V,V}, /* add.s.t */
+ {9,19,rrr,V,V,V}, /* add.d.t */
+ {10,18,rrr,V,V,V}, /* sub.s.t */
+ {10,19,rrr,V,V,V}, /* sub.d.t */
+ {9,18,rrr,V,S,V}, /* add.s.t */
+ {9,19,rrr,V,S,V}, /* add.d.t */
+ {10,18,rrr,V,S,V}, /* sub.s.t */
+ {10,19,rrr,V,S,V}, /* sub.d.t */
+ {9,20,rrr,V,V,V}, /* add.b.t */
+ {9,21,rrr,V,V,V}, /* add.h.t */
+ {9,22,rrr,V,V,V}, /* add.w.t */
+ {9,23,rrr,V,V,V}, /* add.l.t */
+ {9,20,rrr,V,S,V}, /* add.b.t */
+ {9,21,rrr,V,S,V}, /* add.h.t */
+ {9,22,rrr,V,S,V}, /* add.w.t */
+ {9,23,rrr,V,S,V}, /* add.l.t */
+ {10,20,rrr,V,V,V}, /* sub.b.t */
+ {10,21,rrr,V,V,V}, /* sub.h.t */
+ {10,22,rrr,V,V,V}, /* sub.w.t */
+ {10,23,rrr,V,V,V}, /* sub.l.t */
+ {10,20,rrr,V,S,V}, /* sub.b.t */
+ {10,21,rrr,V,S,V}, /* sub.h.t */
+ {10,22,rrr,V,S,V}, /* sub.w.t */
+ {10,23,rrr,V,S,V}, /* sub.l.t */
+ {3,20,rrr,V,V,V}, /* mul.b.t */
+ {3,21,rrr,V,V,V}, /* mul.h.t */
+ {3,22,rrr,V,V,V}, /* mul.w.t */
+ {3,23,rrr,V,V,V}, /* mul.l.t */
+ {3,20,rrr,V,S,V}, /* mul.b.t */
+ {3,21,rrr,V,S,V}, /* mul.h.t */
+ {3,22,rrr,V,S,V}, /* mul.w.t */
+ {3,23,rrr,V,S,V}, /* mul.l.t */
+ {4,20,rrr,V,V,V}, /* div.b.t */
+ {4,21,rrr,V,V,V}, /* div.h.t */
+ {4,22,rrr,V,V,V}, /* div.w.t */
+ {4,23,rrr,V,V,V}, /* div.l.t */
+ {4,20,rrr,V,S,V}, /* div.b.t */
+ {4,21,rrr,V,S,V}, /* div.h.t */
+ {4,22,rrr,V,S,V}, /* div.w.t */
+ {4,23,rrr,V,S,V}, /* div.l.t */
+};
+
+CONST struct formstr e1_format1[] = {
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {26,20,a2r,S,0,0}, /* ste.b.t */
+ {26,21,a2r,S,0,0}, /* ste.h.t */
+ {26,22,a2r,S,0,0}, /* ste.w.t */
+ {26,23,a2r,S,0,0}, /* ste.l.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {18,20,a1r,V,0,0}, /* ld.b.t */
+ {18,21,a1r,V,0,0}, /* ld.h.t */
+ {18,22,a1r,V,0,0}, /* ld.w.t */
+ {18,23,a1r,V,0,0}, /* ld.l.t */
+ {21,20,a2r,V,0,0}, /* st.b.t */
+ {21,21,a2r,V,0,0}, /* st.h.t */
+ {21,22,a2r,V,0,0}, /* st.w.t */
+ {21,23,a2r,V,0,0}, /* st.l.t */
+};
+
+CONST struct formstr e1_format2[] = {
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {28,20,rr,V,V,0}, /* cvtw.b.t */
+ {28,21,rr,V,V,0}, /* cvtw.h.t */
+ {29,22,rr,V,V,0}, /* cvtb.w.t */
+ {30,22,rr,V,V,0}, /* cvth.w.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {31,23,rr,V,V,0}, /* cvts.l.t */
+ {32,22,rr,V,V,0}, /* cvtd.w.t */
+ {33,18,rr,V,V,0}, /* cvtl.s.t */
+ {28,19,rr,V,V,0}, /* cvtw.d.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {116,18,rr,V,V,0}, /* frint.s.t */
+ {116,19,rr,V,V,0}, /* frint.d.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {81,18,rr,V,V,0}, /* sqrt.s.t */
+ {81,19,rr,V,V,0}, /* sqrt.d.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e1_format3[] = {
+ {32,18,rr,V,V,0}, /* cvtd.s.t */
+ {31,19,rr,V,V,0}, /* cvts.d.t */
+ {33,19,rr,V,V,0}, /* cvtl.d.t */
+ {32,23,rr,V,V,0}, /* cvtd.l.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {36,1,rr,V,V,0}, /* tzc.t */
+ {44,1,rr,V,V,0}, /* lop.t */
+ {117,1,rr,V,V,0}, /* xpnd.t */
+ {42,1,rr,V,V,0}, /* not.t */
+ {8,1,rr,S,V,0}, /* shf.t */
+ {35,24,rr,V,V,0}, /* plc.t.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {37,18,rr,V,V,0}, /* eq.s.t */
+ {37,19,rr,V,V,0}, /* eq.d.t */
+ {43,18,rr,V,V,0}, /* neg.s.t */
+ {43,19,rr,V,V,0}, /* neg.d.t */
+ {37,18,rr,S,V,0}, /* eq.s.t */
+ {37,19,rr,S,V,0}, /* eq.d.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {40,18,rr,V,V,0}, /* le.s.t */
+ {40,19,rr,V,V,0}, /* le.d.t */
+ {41,18,rr,V,V,0}, /* lt.s.t */
+ {41,19,rr,V,V,0}, /* lt.d.t */
+ {40,18,rr,S,V,0}, /* le.s.t */
+ {40,19,rr,S,V,0}, /* le.d.t */
+ {41,18,rr,S,V,0}, /* lt.s.t */
+ {41,19,rr,S,V,0}, /* lt.d.t */
+ {37,20,rr,V,V,0}, /* eq.b.t */
+ {37,21,rr,V,V,0}, /* eq.h.t */
+ {37,22,rr,V,V,0}, /* eq.w.t */
+ {37,23,rr,V,V,0}, /* eq.l.t */
+ {37,20,rr,S,V,0}, /* eq.b.t */
+ {37,21,rr,S,V,0}, /* eq.h.t */
+ {37,22,rr,S,V,0}, /* eq.w.t */
+ {37,23,rr,S,V,0}, /* eq.l.t */
+ {40,20,rr,V,V,0}, /* le.b.t */
+ {40,21,rr,V,V,0}, /* le.h.t */
+ {40,22,rr,V,V,0}, /* le.w.t */
+ {40,23,rr,V,V,0}, /* le.l.t */
+ {40,20,rr,S,V,0}, /* le.b.t */
+ {40,21,rr,S,V,0}, /* le.h.t */
+ {40,22,rr,S,V,0}, /* le.w.t */
+ {40,23,rr,S,V,0}, /* le.l.t */
+ {41,20,rr,V,V,0}, /* lt.b.t */
+ {41,21,rr,V,V,0}, /* lt.h.t */
+ {41,22,rr,V,V,0}, /* lt.w.t */
+ {41,23,rr,V,V,0}, /* lt.l.t */
+ {41,20,rr,S,V,0}, /* lt.b.t */
+ {41,21,rr,S,V,0}, /* lt.h.t */
+ {41,22,rr,S,V,0}, /* lt.w.t */
+ {41,23,rr,S,V,0}, /* lt.l.t */
+ {43,20,rr,V,V,0}, /* neg.b.t */
+ {43,21,rr,V,V,0}, /* neg.h.t */
+ {43,22,rr,V,V,0}, /* neg.w.t */
+ {43,23,rr,V,V,0}, /* neg.l.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e1_format4[] = {
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e1_format5[] = {
+ {51,20,rr,V,V,0}, /* ldvi.b.t */
+ {51,21,rr,V,V,0}, /* ldvi.h.t */
+ {51,22,rr,V,V,0}, /* ldvi.w.t */
+ {51,23,rr,V,V,0}, /* ldvi.l.t */
+ {28,18,rr,V,V,0}, /* cvtw.s.t */
+ {31,22,rr,V,V,0}, /* cvts.w.t */
+ {28,23,rr,V,V,0}, /* cvtw.l.t */
+ {33,22,rr,V,V,0}, /* cvtl.w.t */
+ {52,20,rxr,V,V,0}, /* stvi.b.t */
+ {52,21,rxr,V,V,0}, /* stvi.h.t */
+ {52,22,rxr,V,V,0}, /* stvi.w.t */
+ {52,23,rxr,V,V,0}, /* stvi.l.t */
+ {52,20,rxr,S,V,0}, /* stvi.b.t */
+ {52,21,rxr,S,V,0}, /* stvi.h.t */
+ {52,22,rxr,S,V,0}, /* stvi.w.t */
+ {52,23,rxr,S,V,0}, /* stvi.l.t */
+};
+
+CONST struct formstr e1_format6[] = {
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+CONST struct formstr e1_format7[] = {
+ {84,20,r,V,0,0}, /* sum.b.t */
+ {84,21,r,V,0,0}, /* sum.h.t */
+ {84,22,r,V,0,0}, /* sum.w.t */
+ {84,23,r,V,0,0}, /* sum.l.t */
+ {85,1,r,V,0,0}, /* all.t */
+ {86,1,r,V,0,0}, /* any.t */
+ {87,1,r,V,0,0}, /* parity.t */
+ {0,0,0,0,0,0},
+ {88,20,r,V,0,0}, /* max.b.t */
+ {88,21,r,V,0,0}, /* max.h.t */
+ {88,22,r,V,0,0}, /* max.w.t */
+ {88,23,r,V,0,0}, /* max.l.t */
+ {89,20,r,V,0,0}, /* min.b.t */
+ {89,21,r,V,0,0}, /* min.h.t */
+ {89,22,r,V,0,0}, /* min.w.t */
+ {89,23,r,V,0,0}, /* min.l.t */
+ {84,18,r,V,0,0}, /* sum.s.t */
+ {84,19,r,V,0,0}, /* sum.d.t */
+ {90,18,r,V,0,0}, /* prod.s.t */
+ {90,19,r,V,0,0}, /* prod.d.t */
+ {88,18,r,V,0,0}, /* max.s.t */
+ {88,19,r,V,0,0}, /* max.d.t */
+ {89,18,r,V,0,0}, /* min.s.t */
+ {89,19,r,V,0,0}, /* min.d.t */
+ {90,20,r,V,0,0}, /* prod.b.t */
+ {90,21,r,V,0,0}, /* prod.h.t */
+ {90,22,r,V,0,0}, /* prod.w.t */
+ {90,23,r,V,0,0}, /* prod.l.t */
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+ {0,0,0,0,0,0},
+};
+
+char *lop[] = {
+ "mov", /* 0 */
+ "merg", /* 1 */
+ "mask", /* 2 */
+ "mul", /* 3 */
+ "div", /* 4 */
+ "and", /* 5 */
+ "or", /* 6 */
+ "xor", /* 7 */
+ "shf", /* 8 */
+ "add", /* 9 */
+ "sub", /* 10 */
+ "exit", /* 11 */
+ "jmp", /* 12 */
+ "jmpi", /* 13 */
+ "jmpa", /* 14 */
+ "jmps", /* 15 */
+ "tac", /* 16 */
+ "ldea", /* 17 */
+ "ld", /* 18 */
+ "tas", /* 19 */
+ "pshea", /* 20 */
+ "st", /* 21 */
+ "call", /* 22 */
+ "calls", /* 23 */
+ "callq", /* 24 */
+ "pfork", /* 25 */
+ "ste", /* 26 */
+ "incr", /* 27 */
+ "cvtw", /* 28 */
+ "cvtb", /* 29 */
+ "cvth", /* 30 */
+ "cvts", /* 31 */
+ "cvtd", /* 32 */
+ "cvtl", /* 33 */
+ "ldpa", /* 34 */
+ "plc", /* 35 */
+ "tzc", /* 36 */
+ "eq", /* 37 */
+ "leu", /* 38 */
+ "ltu", /* 39 */
+ "le", /* 40 */
+ "lt", /* 41 */
+ "not", /* 42 */
+ "neg", /* 43 */
+ "lop", /* 44 */
+ "cprs", /* 45 */
+ "nop", /* 46 */
+ "br", /* 47 */
+ "bri", /* 48 */
+ "bra", /* 49 */
+ "brs", /* 50 */
+ "ldvi", /* 51 */
+ "stvi", /* 52 */
+ "ldsdr", /* 53 */
+ "ldkdr", /* 54 */
+ "ln", /* 55 */
+ "patu", /* 56 */
+ "pate", /* 57 */
+ "pich", /* 58 */
+ "plch", /* 59 */
+ "idle", /* 60 */
+ "rtnq", /* 61 */
+ "cfork", /* 62 */
+ "rtn", /* 63 */
+ "wfork", /* 64 */
+ "join", /* 65 */
+ "rtnc", /* 66 */
+ "exp", /* 67 */
+ "sin", /* 68 */
+ "cos", /* 69 */
+ "psh", /* 70 */
+ "pop", /* 71 */
+ "eni", /* 72 */
+ "dsi", /* 73 */
+ "bkpt", /* 74 */
+ "msync", /* 75 */
+ "mski", /* 76 */
+ "xmti", /* 77 */
+ "tstvv", /* 78 */
+ "diag", /* 79 */
+ "pbkpt", /* 80 */
+ "sqrt", /* 81 */
+ "casr", /* 82 */
+ "atan", /* 83 */
+ "sum", /* 84 */
+ "all", /* 85 */
+ "any", /* 86 */
+ "parity", /* 87 */
+ "max", /* 88 */
+ "min", /* 89 */
+ "prod", /* 90 */
+ "halt", /* 91 */
+ "sysc", /* 92 */
+ "trap", /* 93 */
+ "tst", /* 94 */
+ "lck", /* 95 */
+ "ulk", /* 96 */
+ "spawn", /* 97 */
+ "ldcmr", /* 98 */
+ "stcmr", /* 99 */
+ "popr", /* 100 */
+ "pshr", /* 101 */
+ "rcvr", /* 102 */
+ "matm", /* 103 */
+ "sndr", /* 104 */
+ "putr", /* 105 */
+ "getr", /* 106 */
+ "matr", /* 107 */
+ "mat", /* 108 */
+ "get", /* 109 */
+ "rcv", /* 110 */
+ "inc", /* 111 */
+ "put", /* 112 */
+ "snd", /* 113 */
+ "enal", /* 114 */
+ "enag", /* 115 */
+ "frint", /* 116 */
+ "xpnd", /* 117 */
+ "ctrsl", /* 118 */
+ "ctrsg", /* 119 */
+ "stop", /* 120 */
+};
+
+char *rop[] = {
+ "", /* 0 */
+ ".t", /* 1 */
+ ".f", /* 2 */
+ ".s", /* 3 */
+ ".d", /* 4 */
+ ".b", /* 5 */
+ ".h", /* 6 */
+ ".w", /* 7 */
+ ".l", /* 8 */
+ ".x", /* 9 */
+ ".u", /* 10 */
+ ".s.f", /* 11 */
+ ".d.f", /* 12 */
+ ".b.f", /* 13 */
+ ".h.f", /* 14 */
+ ".w.f", /* 15 */
+ ".l.f", /* 16 */
+ ".t.f", /* 17 */
+ ".s.t", /* 18 */
+ ".d.t", /* 19 */
+ ".b.t", /* 20 */
+ ".h.t", /* 21 */
+ ".w.t", /* 22 */
+ ".l.t", /* 23 */
+ ".t.t", /* 24 */
+};
diff --git a/include/opcode/d10v.h b/include/opcode/d10v.h
new file mode 100644
index 00000000000..4b74c9862d4
--- /dev/null
+++ b/include/opcode/d10v.h
@@ -0,0 +1,194 @@
+/* d10v.h -- Header file for D10V opcode table
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+ Written by Martin Hunt (hunt@cygnus.com), Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef D10V_H
+#define D10V_H
+
+/* Format Specifier */
+#define FM00 0
+#define FM01 0x40000000
+#define FM10 0x80000000
+#define FM11 0xC0000000
+
+#define NOP 0x5e00
+#define OPCODE_DIVS 0x14002800
+
+/* The opcode table is an array of struct d10v_opcode. */
+
+struct d10v_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* the opcode format */
+ int format;
+
+ /* These numbers were picked so we can do if( i & SHORT_OPCODE) */
+#define SHORT_OPCODE 1
+#define LONG_OPCODE 8
+#define SHORT_2 1 /* short with 2 operands */
+#define SHORT_B 3 /* short with 8-bit branch */
+#define LONG_B 8 /* long with 16-bit branch */
+#define LONG_L 10 /* long with 3 operands */
+#define LONG_R 12 /* reserved */
+
+ /* just a placeholder for variable-length instructions */
+ /* for example, "bra" will be a fake for "bra.s" and bra.l" */
+ /* which will immediately follow in the opcode table. */
+#define OPCODE_FAKE 32
+
+ /* the number of cycles */
+ int cycles;
+
+ /* the execution unit(s) used */
+ int unit;
+#define EITHER 0
+#define IU 1
+#define MU 2
+#define BOTH 3
+
+ /* execution type; parallel or sequential */
+ /* this field is used to decide if two instructions */
+ /* can be executed in parallel */
+ int exec_type;
+#define PARONLY 1 /* parallel only */
+#define SEQ 2 /* must be sequential */
+#define PAR 4 /* may be parallel */
+#define BRANCH_LINK 8 /* subroutine call. must be aligned */
+#define RMEM 16 /* reads memory */
+#define WMEM 32 /* writes memory */
+#define RF0 64 /* reads f0 */
+#define WF0 128 /* modifies f0 */
+#define WCAR 256 /* write Carry */
+#define BRANCH 512 /* branch, no link */
+
+ /* the opcode */
+ long opcode;
+
+ /* mask. if( (i & mask) == opcode ) then match */
+ long mask;
+
+ /* An array of operand codes. Each code is an index into the
+ operand table. They appear in the order which the operands must
+ appear in assembly code, and are terminated by a zero. */
+ unsigned char operands[6];
+};
+
+/* The table itself is sorted by major opcode number, and is otherwise
+ in the order in which the disassembler should consider
+ instructions. */
+extern const struct d10v_opcode d10v_opcodes[];
+extern const int d10v_num_opcodes;
+
+/* The operands table is an array of struct d10v_operand. */
+struct d10v_operand
+{
+ /* The number of bits in the operand. */
+ int bits;
+
+ /* How far the operand is left shifted in the instruction. */
+ int shift;
+
+ /* One bit syntax flags. */
+ int flags;
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the d10v_opcodes table. */
+
+extern const struct d10v_operand d10v_operands[];
+
+/* Values defined for the flags field of a struct d10v_operand. */
+
+/* the operand must be an even number */
+#define OPERAND_EVEN (1)
+
+/* the operand must be an odd number */
+#define OPERAND_ODD (2)
+
+/* this is the destination register; it will be modified */
+/* this is used by the optimizer */
+#define OPERAND_DEST (4)
+
+/* number or symbol */
+#define OPERAND_NUM (8)
+
+/* address or label */
+#define OPERAND_ADDR (0x10)
+
+/* register */
+#define OPERAND_REG (0x20)
+
+/* postincrement + */
+#define OPERAND_PLUS (0x40)
+
+/* postdecrement - */
+#define OPERAND_MINUS (0x80)
+
+/* @ */
+#define OPERAND_ATSIGN (0x100)
+
+/* @( */
+#define OPERAND_ATPAR (0x200)
+
+/* accumulator 0 */
+#define OPERAND_ACC0 (0x400)
+
+/* accumulator 1 */
+#define OPERAND_ACC1 (0x800)
+
+/* f0 / f1 flag register */
+#define OPERAND_FFLAG (0x1000)
+
+/* c flag register */
+#define OPERAND_CFLAG (0x2000)
+
+/* control register */
+#define OPERAND_CONTROL (0x4000)
+
+/* predecrement mode '@-sp' */
+#define OPERAND_ATMINUS (0x8000)
+
+/* signed number */
+#define OPERAND_SIGNED (0x10000)
+
+/* special accumulator shifts need a 4-bit number */
+/* 1 <= x <= 16 */
+#define OPERAND_SHIFT (0x20000)
+
+/* general purpose register */
+#define OPERAND_GPR (0x40000)
+
+/* Structure to hold information about predefined registers. */
+struct pd_reg
+{
+ char *name; /* name to recognize */
+ char *pname; /* name to print for this register */
+ int value;
+};
+
+extern const struct pd_reg d10v_predefined_registers[];
+int d10v_reg_name_cnt();
+
+/* an expressionS only has one register type, so we fake it */
+/* by setting high bits to indicate type */
+#define REGISTER_MASK 0xFF
+
+#endif /* D10V_H */
diff --git a/include/opcode/d30v.h b/include/opcode/d30v.h
new file mode 100644
index 00000000000..b828dab32ae
--- /dev/null
+++ b/include/opcode/d30v.h
@@ -0,0 +1,273 @@
+/* d30v.h -- Header file for D30V opcode table
+ Copyright 1997 Free Software Foundation, Inc.
+ Written by Martin Hunt (hunt@cygnus.com), Cygnus Solutions
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef D30V_H
+#define D30V_H
+
+#define NOP 0x00F00000
+
+/* Structure to hold information about predefined registers. */
+struct pd_reg
+{
+ char *name; /* name to recognize */
+ char *pname; /* name to print for this register */
+ int value;
+};
+
+extern const struct pd_reg pre_defined_registers[];
+int reg_name_cnt();
+
+/* the number of control registers */
+#define MAX_CONTROL_REG 64
+
+/* define the format specifiers */
+#define FM00 0
+#define FM01 0x80000000
+#define FM10 0x8000000000000000LL
+#define FM11 0x8000000080000000LL
+
+/* define the opcode classes */
+#define BRA 0
+#define LOGIC 1
+#define IMEM 2
+#define IALU1 4
+#define IALU2 5
+
+/* define the execution condition codes */
+#define ECC_AL 0 /* ALways (default) */
+#define ECC_TX 1 /* F0=True, F1=Don't care */
+#define ECC_FX 2 /* F0=False, F1=Don't care */
+#define ECC_XT 3 /* F0=Don't care, F1=True */
+#define ECC_XF 4 /* F0=Don't care, F1=False */
+#define ECC_TT 5 /* F0=True, F1=True */
+#define ECC_TF 6 /* F0=True, F1=False */
+#define ECC_RESERVED 7 /* reserved */
+#define ECC_MAX ECC_RESERVED
+
+extern const char *d30v_ecc_names[];
+
+/* condition code table for CMP and CMPU */
+extern const char *d30v_cc_names[];
+
+/* The opcode table is an array of struct d30v_opcode. */
+struct d30v_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* the opcode */
+ int op1; /* first part, "IALU1" for example */
+ int op2; /* the rest of the opcode */
+
+ /* opcode format(s). These numbers correspond to entries */
+ /* in the d30v_format_table */
+ unsigned char format[4];
+
+#define SHORT_M 1
+#define SHORT_M2 5 /* for ld2w and st2w */
+#define SHORT_A 9
+#define SHORT_B1 11
+#define SHORT_B2 12
+#define SHORT_B3 13
+#define SHORT_B3b 15
+#define SHORT_D1 17
+#define SHORT_D2 19
+#define SHORT_D2B 21
+#define SHORT_U 23 /* unary SHORT_A. ABS for example */
+#define SHORT_F 25 /* SHORT_A with flag registers */
+#define SHORT_AF 27 /* SHORT_A with only the first register a flag register */
+#define SHORT_T 29 /* for trap instruction */
+#define SHORT_A5 30 /* SHORT_A with a 5-bit immediate instead of 6 */
+#define SHORT_CMP 32 /* special form for CMPcc */
+#define SHORT_CMPU 34 /* special form for CMPUcc */
+#define SHORT_A1 36 /* special form of SHORT_A for MACa opcodes where a=1 */
+#define SHORT_AA 38 /* SHORT_A with the first register an accumulator */
+#define SHORT_RA 40 /* SHORT_A with the second register an accumulator */
+#define SHORT_MODINC 42
+#define SHORT_MODDEC 43
+#define SHORT_C1 44
+#define SHORT_C2 45
+#define SHORT_UF 46
+#define SHORT_A2 47
+#define SHORT_A5S 49
+#define SHORT_NONE 51 /* no operands */
+#define LONG 52
+#define LONG_U 53 /* unary LONG */
+#define LONG_AF 54 /* LONG with the first register a flag register */
+#define LONG_CMP 55 /* special form for CMPcc and CMPUcc */
+#define LONG_M 56 /* Memory long for ldb, stb */
+#define LONG_M2 57 /* Memory long for ld2w, st2w */
+#define LONG_2 58 /* LONG with 2 operands; bratnz */
+#define LONG_2b 59 /* LONG_2 with modifier of 3 */
+#define LONG_D 60 /* for DBRAI*/
+#define LONG_Db 61 /* for repeati*/
+
+ /* the execution unit(s) used */
+ int unit;
+#define EITHER 0
+#define IU 1
+#define MU 2
+#define EITHER_BUT_PREFER_MU 3
+
+ /* this field is used to decide if two instructions */
+ /* can be executed in parallel */
+ long flags_used;
+ long flags_set;
+#define FLAG_0 (1L<<0)
+#define FLAG_1 (1L<<1)
+#define FLAG_2 (1L<<2)
+#define FLAG_3 (1L<<3)
+#define FLAG_4 (1L<<4) /* S (saturation) */
+#define FLAG_5 (1L<<5) /* V (overflow) */
+#define FLAG_6 (1L<<6) /* VA (accumulated overflow) */
+#define FLAG_7 (1L<<7) /* C (carry/borrow) */
+#define FLAG_SM (1L<<8) /* SM (stack mode) */
+#define FLAG_RP (1L<<9) /* RP (repeat enable) */
+#define FLAG_CONTROL (1L<<10) /* control registers */
+#define FLAG_A0 (1L<<11) /* A0 */
+#define FLAG_A1 (1L<<12) /* A1 */
+#define FLAG_JMP (1L<<13) /* instruction is a branch */
+#define FLAG_JSR (1L<<14) /* subroutine call. must be aligned */
+#define FLAG_MEM (1L<<15) /* reads/writes memory */
+#define FLAG_2WORD (1L<<16) /* 2 word/4 byte operation */
+#define FLAG_MUL16 (1L<<17) /* 16 bit multiply */
+#define FLAG_MUL32 (1L<<18) /* 32 bit multiply */
+#define FLAG_ADDSUBppp (1L<<19) /* ADDppp or SUBppp */
+#define FLAG_DELAY (1L<<20) /* This is a delayed branch or jump */
+#define FLAG_LKR (1L<<21) /* insn in left slot kills right slot */
+#define FLAG_CVVA (FLAG_5|FLAG_6|FLAG_7)
+#define FLAG_C FLAG_7
+#define FLAG_ALL (FLAG_0 | \
+ FLAG_1 | \
+ FLAG_2 | \
+ FLAG_3 | \
+ FLAG_4 | \
+ FLAG_5 | \
+ FLAG_6 | \
+ FLAG_7 | \
+ FLAG_SM | \
+ FLAG_RP | \
+ FLAG_CONTROL)
+
+ int reloc_flag;
+#define RELOC_PCREL 1
+#define RELOC_ABS 2
+};
+
+extern const struct d30v_opcode d30v_opcode_table[];
+extern const int d30v_num_opcodes;
+
+/* The operands table is an array of struct d30v_operand. */
+struct d30v_operand
+{
+ /* the length of the field */
+ int length;
+
+ /* The number of significant bits in the operand. */
+ int bits;
+
+ /* position relative to Ra */
+ int position;
+
+ /* syntax flags. */
+ long flags;
+};
+extern const struct d30v_operand d30v_operand_table[];
+
+/* Values defined for the flags field of a struct d30v_operand. */
+
+/* this is the destination register; it will be modified */
+/* this is used by the optimizer */
+#define OPERAND_DEST (1)
+
+/* number or symbol */
+#define OPERAND_NUM (2)
+
+/* address or label */
+#define OPERAND_ADDR (4)
+
+/* register */
+#define OPERAND_REG (8)
+
+/* postincrement + */
+#define OPERAND_PLUS (0x10)
+
+/* postdecrement - */
+#define OPERAND_MINUS (0x20)
+
+/* signed number */
+#define OPERAND_SIGNED (0x40)
+
+/* this operand must be shifted left by 3 */
+#define OPERAND_SHIFT (0x80)
+
+/* flag register */
+#define OPERAND_FLAG (0x100)
+
+/* control register */
+#define OPERAND_CONTROL (0x200)
+
+/* accumulator */
+#define OPERAND_ACC (0x400)
+
+/* @ */
+#define OPERAND_ATSIGN (0x800)
+
+/* @( */
+#define OPERAND_ATPAR (0x1000)
+
+/* predecrement mode '@-sp' */
+#define OPERAND_ATMINUS (0x2000)
+
+/* this operand changes the instruction name */
+/* for example, CPMcc, CMPUcc */
+#define OPERAND_NAME (0x4000)
+
+/* fake operand for mvtsys and mvfsys */
+#define OPERAND_SPECIAL (0x8000)
+
+/* let the optimizer know that two registers are affected */
+#define OPERAND_2REG (0x10000)
+
+/* The format table is an array of struct d30v_format. */
+struct d30v_format
+{
+ int form; /* SHORT_A, LONG, etc */
+ int modifier; /* two bit modifier following opcode */
+ unsigned char operands[5];
+};
+extern const struct d30v_format d30v_format_table[];
+
+
+/* an instruction is defined by an opcode and a format */
+/* for example, "add" has one opcode, but three different */
+/* formats, 2 SHORT_A forms and a LONG form. */
+struct d30v_insn
+{
+ struct d30v_opcode *op; /* pointer to an entry in the opcode table */
+ struct d30v_format *form; /* pointer to an entry in the format table */
+ int ecc; /* execution condition code */
+};
+
+/* an expressionS only has one register type, so we fake it */
+/* by setting high bits to indicate type */
+#define REGISTER_MASK 0xFF
+
+#endif /* D30V_H */
diff --git a/include/opcode/h8300.h b/include/opcode/h8300.h
new file mode 100644
index 00000000000..3a05e4ee21c
--- /dev/null
+++ b/include/opcode/h8300.h
@@ -0,0 +1,604 @@
+/* Opcode table for the H8-300
+ Copyright (C) 1991, 92, 93, 95, 96, 97, 1998 Free Software Foundation.
+ Written by Steve Chamberlain, sac@cygnus.com.
+
+ This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* Instructions are stored as a sequence of nibbles.
+ If the nibble has value 15 or less then the representation is complete.
+ Otherwise, we record what it contains with several flags. */
+
+typedef int op_type;
+
+#define Hex0 0
+#define Hex1 1
+#define Hex2 2
+#define Hex3 3
+#define Hex4 4
+#define Hex5 5
+#define Hex6 6
+#define Hex7 7
+#define Hex8 8
+#define Hex9 9
+#define HexA 10
+#define HexB 11
+#define HexC 12
+#define HexD 13
+#define HexE 14
+#define HexF 15
+
+#define L_8 0x01
+#define L_16 0x02
+#define L_32 0x04
+#define L_P 0x08
+#define L_24 0x10
+#define MEMRELAX 0x20 /* move insn which may relax */
+#define SRC 0x40
+#define DST 0x80
+
+#define REG 0x100
+#define EXR 0x200
+#define MACREG 0x800
+#define SRC_IN_DST 0x400
+#define IMM 0x1000
+#define DISP 0x2000
+#define IND 0x4000
+#define INC 0x8000
+#define DEC 0x10000
+#define L_3 0x20000
+#define KBIT 0x40000
+#define DBIT 0x80000
+#define DISPREG 0x100000
+#define IGNORE 0x200000
+#define E 0x400000 /* FIXME: end of nibble sequence? */
+#define L_2 0x800000
+#define B30 0x1000000 /* bit 3 must be low */
+#define B31 0x2000000 /* bit 3 must be high */
+#define CCR 0x4000000
+#define ABS 0x8000000
+#define ABSJMP 0x10000000
+#define ABS8MEM 0x20000000
+#define PCREL 0x40000000
+#define MEMIND 0x80000000
+
+#define IMM3 IMM|L_3
+#define IMM2 IMM|L_2
+
+#define SIZE (L_2|L_3|L_8|L_16|L_32|L_P|L_24)
+#define MODE (REG|IMM|DISP|IND|INC|DEC|CCR|ABS|MEMIND|EXR)
+
+#define RD8 (DST|L_8|REG)
+#define RD16 (DST|L_16|REG)
+#define RD32 (DST|L_32|REG)
+#define RS8 (SRC|L_8|REG)
+#define RS16 (SRC|L_16|REG)
+#define RS32 (SRC|L_32|REG)
+
+#define RSP (SRC|L_P|REG)
+#define RDP (DST|L_P|REG)
+
+#define IMM8 (IMM|SRC|L_8)
+#define IMM16 (IMM|SRC|L_16)
+#define IMM32 (IMM|SRC|L_32)
+
+#define ABS8SRC (SRC|ABS|L_8|ABS8MEM)
+#define ABS8DST (DST|ABS|L_8|ABS8MEM)
+
+#define DISP8 (PCREL|L_8)
+#define DISP16 (PCREL|L_16)
+
+#define DISP8SRC (DISP|L_8|SRC)
+#define DISP16SRC (DISP|L_16|SRC)
+
+#define DISP8DST (DISP|L_8|DST)
+#define DISP16DST (DISP|L_16|DST)
+
+#define ABS16SRC (SRC|ABS|L_16)
+#define ABS16DST (DST|ABS|L_16)
+#define ABS24SRC (SRC|ABS|L_24)
+#define ABS24DST (DST|ABS|L_24)
+#define ABS32SRC (SRC|ABS|L_32)
+#define ABS32DST (DST|ABS|L_32)
+
+#define RDDEC (DST|DEC)
+#define RSINC (SRC|INC)
+#define RDINC (DST|INC)
+
+#define RDIND (DST|IND)
+#define RSIND (SRC|IND)
+
+#if 1
+#define OR8 RS8 /* ??? OR as in One Register? */
+#define OR16 RS16
+#define OR32 RS32
+#else
+#define OR8 RD8
+#define OR16 RD16
+#define OR32 RD32
+#endif
+
+struct code
+{
+ op_type nib[30];
+};
+
+struct arg
+{
+ op_type nib[3];
+};
+
+struct h8_opcode
+{
+ int how;
+ int inbase;
+ int time;
+ char *name;
+ struct arg args;
+ struct code data;
+ int length;
+ int noperands;
+ int idx;
+ int size;
+};
+
+#ifdef DEFINE_TABLE
+
+#define BITOP(code, imm, name, op00, op01,op10,op11, op20,op21,op30)\
+{ code, 1, 2, name, {{imm,RD8,E}}, {{op00, op01, imm, RD8, E, 0, 0, 0, 0}}, 0, 0, 0, 0},\
+{ code, 1, 6, name, {{imm,RDIND,E}},{{op10, op11, B30|RDIND, 0, op00,op01, imm, 0, E}}, 0, 0, 0, 0},\
+{ code, 1, 6, name, {{imm,ABS8DST,E}},{{op20, op21, ABS8DST, IGNORE, op00,op01, imm, 0,E}}, 0, 0, 0, 0}\
+,{ code, 0, 6, name, {{imm,ABS16DST,E}},{{0x6,0xa,0x1,op30,ABS16DST,IGNORE,IGNORE,IGNORE, op00,op01, imm, 0,E}}, 0, 0, 0, 0},\
+{ code, 0, 6, name, {{imm,ABS32DST,E}},{{0x6,0xa,0x3,op30,ABS32DST,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE, op00,op01, imm, 0,E}}, 0, 0, 0, 0}
+
+
+#define EBITOP(code, imm, name, op00, op01,op10,op11, op20,op21,op30)\
+ BITOP(code,imm, name, op00+1, op01, op10,op11, op20,op21,op30),\
+ BITOP(code,RS8, name, op00, op01, op10,op11, op20,op21,op30)
+
+#define WTWOP(code,name, op1, op2) \
+{ code, 1, 2, name, {{RS16, RD16, E}}, {{ op1, op2, RS16, RD16, E, 0, 0, 0, 0}}, 0, 0, 0, 0}
+
+#define BRANCH(code, name, op) \
+{ code, 1, 4,name,{{DISP8,E,0}}, {{ 0x4, op, DISP8, IGNORE, E, 0, 0, 0, 0}}, 0, 0, 0, 0}, \
+{ code, 0, 6,name,{{DISP16,E,0}}, {{ 0x5, 0x8, op, 0x0, DISP16, IGNORE, IGNORE, IGNORE, E,0}}, 0, 0, 0, 0}
+
+#define SOP(code, x,name) \
+{code, 1, x, name
+
+#define NEW_SOP(code, in,x,name) \
+{code, in, x, name
+#define EOP ,0,0,0 }
+
+#define TWOOP(code, name, op1, op2,op3) \
+{ code,1, 2,name, {{IMM8, RD8, E}}, {{ op1, RD8, IMM8, IGNORE, E, 0, 0, 0, 0}}, 0, 0, 0, 0},\
+{ code, 1, 2,name, {{RS8, RD8, E}}, {{ op2, op3, RS8, RD8, E, 0, 0, 0, 0}}, 0, 0, 0, 0}
+
+#define UNOP(code,name, op1, op2) \
+{ code, 1, 2, name, {{OR8, E, 0}}, {{ op1, op2, 0, OR8, E, 0, 0, 0, 0}}, 0, 0, 0, 0}
+
+#define UNOP3(code, name, op1, op2, op3) \
+{ O(code,SB), 1, 2, name, {{OR8, E, 0}}, {{op1, op2, op3+0, OR8, E, 0, 0, 0, 0}}, 0, 0, 0, 0}, \
+{ O(code,SW), 0, 2, name, {{OR16, E, 0}}, {{op1, op2, op3+1, OR16, E, 0, 0, 0, 0}}, 0, 0, 0, 0}, \
+{ O(code,SL), 0, 2, name, {{OR32, E, 0}}, {{op1, op2, op3+3, OR32|B30, E, 0, 0, 0, 0}}, 0, 0, 0, 0} \
+,{ O(code,SB), 1, 2, name, {{IMM, OR8 | SRC_IN_DST, E}}, {{op1, op2, op3+4, OR8 | SRC_IN_DST, E, 0, 0, 0, 0}}, 0, 0, 0, 0}, \
+{ O(code,SW), 0, 2, name, {{IMM, OR16 | SRC_IN_DST, E}}, {{op1, op2, op3+5, OR16 | SRC_IN_DST, E, 0, 0, 0, 0}}, 0, 0, 0, 0}, \
+{ O(code,SL), 0, 2, name, {{IMM, OR32 | SRC_IN_DST, E}}, {{op1, op2, op3+7, OR32 | SRC_IN_DST|B30 , E, 0, 0, 0, 0}}, 0, 0, 0, 0}
+
+
+#define IMM32LIST IMM32,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define IMM24LIST IMM24,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define IMM16LIST IMM16,IGNORE,IGNORE,IGNORE
+#define A16LIST L_16,IGNORE,IGNORE,IGNORE
+#define DISP24LIST DISP|L_24,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define DISP32LIST DISP|L_32,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define ABS24LIST ABS|L_24,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define ABS32LIST ABS|L_32,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define A24LIST L_24,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define A32LIST L_32,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE
+#define PREFIX32 0x0,0x1,0x0,0x0
+#define PREFIXLDC 0x0,0x1,0x4,0x0
+
+
+#define O(op, size) (op*4+size)
+
+#define O_RECOMPILE 0
+#define O_ADD 1
+#define O_ADDX 2
+#define O_AND 3
+#define O_BAND 4
+#define O_BRA 5
+#define O_BRN 6
+#define O_BHI 7
+#define O_BLS 8
+#define O_BCC 9
+#define O_BCS 10
+#define O_BNE 11
+#define O_BVC 12
+#define O_BVS 13
+#define O_BPL 14
+#define O_BMI 15
+#define O_BGE 16
+#define O_BLT 17
+#define O_BGT 18
+#define O_BLE 19
+#define O_ANDC 20
+#define O_BEQ 21
+#define O_BCLR 22
+#define O_BIAND 23
+#define O_BILD 24
+#define O_BIOR 25
+#define O_BIXOR 26
+#define O_BIST 27
+#define O_BLD 28
+#define O_BNOT 29
+#define O_BSET 30
+#define O_BSR 31
+#define O_BXOR 32
+#define O_CMP 33
+#define O_DAA 34
+#define O_DAS 35
+#define O_DEC 36
+#define O_DIVU 37
+#define O_DIVS 38
+#define O_INC 39
+#define O_LDC 40
+#define O_MOV_TO_MEM 41
+#define O_OR 42
+#define O_ROTL 43
+#define O_ROTR 44
+#define O_ROTXL 45
+#define O_ROTXR 46
+#define O_BPT 47
+#define O_SHAL 48
+#define O_SHAR 49
+#define O_SHLL 50
+#define O_SHLR 51
+#define O_SUB 52
+#define O_SUBS 53
+#define O_TRAPA 54
+#define O_XOR 55
+#define O_XORC 56
+#define O_BOR 57
+#define O_BST 58
+#define O_BTST 59
+#define O_EEPMOV 60
+#define O_EXTS 61
+#define O_EXTU 62
+#define O_JMP 63
+#define O_JSR 64
+#define O_MULU 65
+#define O_MULS 66
+#define O_NOP 67
+#define O_NOT 68
+#define O_ORC 69
+#define O_RTE 70
+#define O_STC 71
+#define O_SUBX 72
+#define O_NEG 73
+#define O_RTS 74
+#define O_SLEEP 75
+#define O_ILL 76
+#define O_ADDS 77
+#define O_SYSCALL 78
+#define O_MOV_TO_REG 79
+#define O_TAS 80
+#define O_CLRMAC 82
+#define O_LDMAC 83
+#define O_MAC 84
+#define O_LDM 85
+#define O_STM 86
+#define O_STMAC 87
+#define O_LAST 88
+#define SB 0
+#define SW 1
+#define SL 2
+#define SN 3
+
+
+/* FIXME: Lots of insns have "E, 0, 0, 0, 0" in the nibble code sequences.
+ Methinks the zeroes aren't necessary. Once confirmed, nuke 'em. */
+
+struct h8_opcode h8_opcodes[] =
+{
+ TWOOP(O(O_ADD,SB),"add.b", 0x8, 0x0,0x8),
+
+ NEW_SOP(O(O_ADD,SW),1,2,"add.w"),{{RS16,RD16,E}},{{0x0,0x9,RS16,RD16,E}} EOP,
+ NEW_SOP(O(O_ADD,SW),0,4,"add.w"),{{IMM16,RD16,E}},{{0x7,0x9,0x1,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}} EOP,
+ NEW_SOP(O(O_ADD,SL),0,2,"add.l"),{{RS32,RD32,E }}, {{0x0,0xA,B31|RS32,B30|RD32,E}} EOP,
+ NEW_SOP(O(O_ADD,SL),0,6,"add.l"),{{IMM32,RD32,E }},{{0x7,0xA,0x1,B30|RD32,IMM32LIST,E}} EOP,
+ NEW_SOP(O(O_ADDS,SL),1,2,"adds"), {{KBIT,RDP,E}}, {{0x0,0xB,KBIT,RDP,E,0,0,0,0}} EOP,
+
+ TWOOP(O(O_ADDX,SB),"addx",0x9,0x0,0xE),
+ TWOOP(O(O_AND,SB), "and.b",0xE,0x1,0x6),
+
+ NEW_SOP(O(O_AND,SW),0,2,"and.w"),{{RS16,RD16,E }},{{0x6,0x6,RS16,RD16,E}} EOP,
+ NEW_SOP(O(O_AND,SW),0,4,"and.w"),{{IMM16,RD16,E }},{{0x7,0x9,0x6,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}} EOP,
+
+ NEW_SOP(O(O_AND,SL),0,6,"and.l"),{{IMM32,RD32,E }},{{0x7,0xA,0x6,B30|RD32,IMM32LIST,E}} EOP,
+ NEW_SOP(O(O_AND,SL),0,2,"and.l") ,{{RS32,RD32,E }},{{0x0,0x1,0xF,0x0,0x6,0x6,B30|RS32,B30|RD32,E}} EOP,
+
+ NEW_SOP(O(O_ANDC,SB),1,2,"andc"), {{IMM8,CCR,E}},{{ 0x0,0x6,IMM8,IGNORE,E,0,0,0,0}} EOP,
+ NEW_SOP(O(O_ANDC,SB),1,2,"andc"), {{IMM8,EXR,E}},{{ 0x0,0x1,0x4,0x1,0x0,0x6,IMM8,IGNORE,E,0,0,0,0}} EOP,
+
+ BITOP(O(O_BAND,SB), IMM3|B30,"band",0x7,0x6,0x7,0xC,0x7,0xE,0x0),
+ BRANCH(O(O_BRA,SB),"bra",0x0),
+ BRANCH(O(O_BRA,SB),"bt",0x0),
+ BRANCH(O(O_BRN,SB),"brn",0x1),
+ BRANCH(O(O_BRN,SB),"bf",0x1),
+ BRANCH(O(O_BHI,SB),"bhi",0x2),
+ BRANCH(O(O_BLS,SB),"bls",0x3),
+ BRANCH(O(O_BCC,SB),"bcc",0x4),
+ BRANCH(O(O_BCC,SB),"bhs",0x4),
+ BRANCH(O(O_BCS,SB),"bcs",0x5),
+ BRANCH(O(O_BCS,SB),"blo",0x5),
+ BRANCH(O(O_BNE,SB),"bne",0x6),
+ BRANCH(O(O_BEQ,SB),"beq",0x7),
+ BRANCH(O(O_BVC,SB),"bvc",0x8),
+ BRANCH(O(O_BVS,SB),"bvs",0x9),
+ BRANCH(O(O_BPL,SB),"bpl",0xA),
+ BRANCH(O(O_BMI,SB),"bmi",0xB),
+ BRANCH(O(O_BGE,SB),"bge",0xC),
+ BRANCH(O(O_BLT,SB),"blt",0xD),
+ BRANCH(O(O_BGT,SB),"bgt",0xE),
+ BRANCH(O(O_BLE,SB),"ble",0xF),
+
+ EBITOP(O(O_BCLR,SB),IMM3|B30,"bclr", 0x6,0x2,0x7,0xD,0x7,0xF,0x8),
+ BITOP(O(O_BIAND,SB),IMM3|B31,"biand",0x7,0x6,0x7,0xC,0x7,0xE,0x0),
+ BITOP(O(O_BILD,SB), IMM3|B31,"bild", 0x7,0x7,0x7,0xC,0x7,0xE,0x0),
+ BITOP(O(O_BIOR,SB), IMM3|B31,"bior", 0x7,0x4,0x7,0xC,0x7,0xE,0x0),
+ BITOP(O(O_BIST,SB), IMM3|B31,"bist", 0x6,0x7,0x7,0xD,0x7,0xF,0x8),
+ BITOP(O(O_BIXOR,SB),IMM3|B31,"bixor",0x7,0x5,0x7,0xC,0x7,0xE,0x0),
+ BITOP(O(O_BLD,SB), IMM3|B30,"bld", 0x7,0x7,0x7,0xC,0x7,0xE,0x0),
+ EBITOP(O(O_BNOT,SB),IMM3|B30,"bnot", 0x6,0x1,0x7,0xD,0x7,0xF,0x8),
+ BITOP(O(O_BOR,SB), IMM3|B30,"bor", 0x7,0x4,0x7,0xC,0x7,0xE,0x0),
+ EBITOP(O(O_BSET,SB),IMM3|B30,"bset", 0x6,0x0,0x7,0xD,0x7,0xF,0x8),
+
+ SOP(O(O_BSR,SB),6,"bsr"),{{DISP8,E,0}},{{ 0x5,0x5,DISP8,IGNORE,E,0,0,0,0}} EOP,
+ SOP(O(O_BSR,SB),6,"bsr"),{{DISP16,E,0}},{{ 0x5,0xC,0x0,0x0,DISP16,IGNORE,IGNORE,IGNORE,E,0,0,0,0}} EOP,
+ BITOP(O(O_BST,SB), IMM3|B30,"bst",0x6,0x7,0x7,0xD,0x7,0xF,0x8),
+ EBITOP(O(O_BTST,SB), IMM3|B30,"btst",0x6,0x3,0x7,0xC,0x7,0xE,0x0),
+ BITOP(O(O_BXOR,SB), IMM3|B30,"bxor",0x7,0x5,0x7,0xC,0x7,0xE,0x0),
+
+ TWOOP(O(O_CMP,SB), "cmp.b",0xA,0x1,0xC),
+ WTWOP(O(O_CMP,SW), "cmp.w",0x1,0xD),
+
+ NEW_SOP(O(O_CMP,SW),1,2,"cmp.w"),{{RS16,RD16,E }},{{0x1,0xD,RS16,RD16,E}} EOP,
+ NEW_SOP(O(O_CMP,SW),0,4,"cmp.w"),{{IMM16,RD16,E }},{{0x7,0x9,0x2,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}} EOP,
+
+ NEW_SOP(O(O_CMP,SL),0,6,"cmp.l"),{{IMM32,RD32,E }},{{0x7,0xA,0x2,B30|RD32,IMM32LIST,E}} EOP,
+ NEW_SOP(O(O_CMP,SL),0,2,"cmp.l") ,{{RS32,RD32,E }},{{0x1,0xF,B31|RS32,B30|RD32,E}} EOP,
+
+ UNOP(O(O_DAA,SB), "daa",0x0,0xF),
+ UNOP(O(O_DAS,SB), "das",0x1,0xF),
+ UNOP(O(O_DEC,SB), "dec.b",0x1,0xA),
+
+ NEW_SOP(O(O_DEC, SW),0,2,"dec.w") ,{{DBIT,RD16,E }},{{0x1,0xB,0x5|DBIT,RD16,E}} EOP,
+ NEW_SOP(O(O_DEC, SL),0,2,"dec.l") ,{{DBIT,RD32,E }},{{0x1,0xB,0x7|DBIT,RD32|B30,E}} EOP,
+
+ NEW_SOP(O(O_DIVU,SB),1,6,"divxu.b"), {{RS8,RD16,E}}, {{0x5,0x1,RS8,RD16,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_DIVU,SW),0,20,"divxu.w"),{{RS16,RD32,E}},{{0x5,0x3,RS16,B30|RD32,E}}EOP,
+
+ NEW_SOP(O(O_DIVS,SB),0,20,"divxs.b") ,{{RS8,RD16,E }},{{0x0,0x1,0xD,0x0,0x5,0x1,RS8,RD16,E}} EOP,
+ NEW_SOP(O(O_DIVS,SW),0,02,"divxs.w") ,{{RS16,RD32,E }},{{0x0,0x1,0xD,0x0,0x5,0x3,RS16,B30|RD32,E}} EOP,
+
+ NEW_SOP(O(O_EEPMOV,SB),1,50,"eepmov.b"),{{E,0,0}},{{0x7,0xB,0x5,0xC,0x5,0x9,0x8,0xF,E}}EOP,
+ NEW_SOP(O(O_EEPMOV,SW),0,50,"eepmov.w"),{{E,0,0}},{{0x7,0xB,0xD,0x4,0x5,0x9,0x8,0xF,E}} EOP,
+
+ NEW_SOP(O(O_EXTS,SW),0,2,"exts.w"),{{OR16,E,0}},{{0x1,0x7,0xD,OR16,E }}EOP,
+ NEW_SOP(O(O_EXTS,SL),0,2,"exts.l"),{{OR32,E,0}},{{0x1,0x7,0xF,OR32|B30,E }}EOP,
+
+ NEW_SOP(O(O_EXTU,SW),0,2,"extu.w"),{{OR16,E,0}},{{0x1,0x7,0x5,OR16,E }}EOP,
+ NEW_SOP(O(O_EXTU,SL),0,2,"extu.l"),{{OR32,E,0}},{{0x1,0x7,0x7,OR32|B30,E }}EOP,
+
+ UNOP(O(O_INC,SB), "inc",0x0,0xA),
+
+ NEW_SOP(O(O_INC,SW),0,2,"inc.w") ,{{DBIT,RD16,E }},{{0x0,0xB,0x5|DBIT,RD16,E}} EOP,
+ NEW_SOP(O(O_INC,SL),0,2,"inc.l") ,{{DBIT,RD32,E }},{{0x0,0xB,0x7|DBIT,RD32|B30,E}} EOP,
+
+ SOP(O(O_JMP,SB),4,"jmp"),{{RSIND,E,0}},{{0x5,0x9,B30|RSIND,0x0,E,0,0,0,0}}EOP,
+ SOP(O(O_JMP,SB),6,"jmp"),{{SRC|ABSJMP,E,0}},{{0x5,0xA,SRC|ABSJMP,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_JMP,SB),8,"jmp"),{{SRC|MEMIND,E,0}},{{0x5,0xB,SRC|MEMIND,IGNORE,E,0,0,0,0}}EOP,
+
+ SOP(O(O_JSR,SB),6,"jsr"),{{SRC|RSIND,E,0}}, {{0x5,0xD,B30|RSIND,0x0,E,0,0,0,0}}EOP,
+ SOP(O(O_JSR,SB),8,"jsr"),{{SRC|ABSJMP,E,0}},{{0x5,0xE,SRC|ABSJMP,IGNORE,IGNORE,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_JSR,SB),8,"jsr"),{{SRC|MEMIND,E,0}},{{0x5,0xF,SRC|MEMIND,IGNORE,E,0,0,0,0}}EOP,
+
+ NEW_SOP(O(O_LDC,SB),1,2,"ldc"),{{IMM8,CCR,E}}, {{ 0x0,0x7,IMM8,IGNORE,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_LDC,SB),1,2,"ldc"),{{OR8,CCR,E}}, {{ 0x0,0x3,0x0,OR8,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{ABS16SRC,CCR,E}}, {{PREFIXLDC,0x6,0xB,0x0,0x0,ABS16SRC,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{ABS32SRC,CCR,E}}, {{PREFIXLDC,0x6,0xB,0x2,0x0,SRC|ABS32LIST,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{DISP|SRC|L_16,CCR,E}},{{PREFIXLDC,0x6,0xF,B30|DISPREG,0,DISP|L_16,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{DISP|SRC|L_32,CCR,E}},{{PREFIXLDC,0x7,0x8,B30|DISPREG,0,0x6,0xB,0x2,0x0,SRC|DISP32LIST,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{RSINC,CCR,E}}, {{PREFIXLDC,0x6,0xD,B30|RSINC,0x0,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{RSIND,CCR,E}}, {{PREFIXLDC,0x6,0x9,B30|RDIND,0x0,E}} EOP,
+
+ NEW_SOP(O(O_LDC,SB),1,2,"ldc"),{{IMM8,EXR,E}}, {{ 0x0,0x1,0x4,0x1,0x0,0x7,IMM8,IGNORE,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_LDC,SB),1,2,"ldc"),{{OR8,EXR,E}}, {{ 0x0,0x3,0x1,OR8,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{ABS16SRC,EXR,E}}, {{ 0x0,0x1,0x4,0x1,0x6,0xb,0x0,0x0,ABS16SRC,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{ABS32SRC,EXR,E}}, {{ 0x0,0x1,0x4,0x1,0x6,0xb,0x2,0x0,SRC|ABS32LIST,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{DISP|SRC|L_16,EXR,E}},{{ 0x0,0x1,0x4,0x1,0x6,0xf,B30|DISPREG,0,DISP|L_16,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{DISP|SRC|L_32,EXR,E}},{{ 0x0,0x1,0x4,0x1,0x7,0x8,B30|DISPREG,0,0x6,0xB,0x2,0x0,SRC|DISP32LIST,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{RSINC,EXR,E}}, {{ 0x0,0x1,0x4,0x1,0x6,0xd,B30|RSINC,0x0,E}}EOP,
+ NEW_SOP(O(O_LDC,SB),0,2,"ldc"),{{RSIND,EXR,E}}, {{ 0x0,0x1,0x4,0x1,0x6,0x9,B30|RDIND,0x0,E}} EOP,
+
+ SOP(O(O_MOV_TO_REG,SB),4,"mov.b"),{{ABS|SRC|L_16|MEMRELAX,RD8,E}}, {{ 0x6,0xA,0x0,RD8,SRC|ABS|MEMRELAX|A16LIST,E}}EOP,
+ SOP(O(O_MOV_TO_REG,SB),6,"mov.b"),{{ABS|SRC|L_32|MEMRELAX,RD8,E }}, {{ 0x6,0xA,0x2,RD8,SRC|ABS|MEMRELAX|A32LIST,E }}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),4,"mov.b"),{{RS8,ABS|L_16|MEMRELAX|DST,E}}, {{ 0x6,0xA,0x8,RS8,DST|ABS|MEMRELAX|A16LIST,E}}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),6,"mov.b"),{{RS8,ABS|DST|L_32|MEMRELAX,E }}, {{ 0x6,0xA,0xA,RS8,DST|ABS|MEMRELAX|A32LIST,E }}EOP,
+
+ SOP(O(O_MOV_TO_REG,SB),6,"mov.b"),{{DISP|L_32|SRC,RD8,E}}, {{ 0x7,0x8,B30|DISPREG,0x0,0x6,0xA,0x2,RD8,SRC|DISP32LIST,E}}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),6,"mov.b"),{{RS8,DISP|L_32|DST,E}}, {{ 0x7,0x8,B30|DISPREG,0x0,0x6,0xA,0xA,RS8,DST|DISP32LIST,E}}EOP,
+
+
+
+ SOP(O(O_MOV_TO_REG,SB),2,"mov.b"),{{RS8,RD8,E}}, {{ 0x0,0xC,RS8,RD8,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SB),2,"mov.b"),{{IMM8,RD8,E}}, {{ 0xF,RD8,IMM8,IGNORE,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SB),4,"mov.b"),{{RSIND,RD8,E}}, {{ 0x6,0x8,B30|RSIND,RD8,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SB),6,"mov.b"),{{DISP16SRC,RD8,E}}, {{ 0x6,0xE,B30|DISPREG,RD8,DISP16SRC,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_MOV_TO_REG,SB),6,"mov.b"),{{RSINC,RD8,E}}, {{ 0x6,0xC,B30|RSINC,RD8,E,0,0,0,0}}EOP,
+
+ SOP(O(O_MOV_TO_REG,SB),4,"mov.b"),{{ABS8SRC,RD8,E}}, {{ 0x2,RD8,ABS8SRC,IGNORE,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),4,"mov.b"),{{RS8,RDIND,E}}, {{ 0x6,0x8,RDIND|B31,RS8,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),6,"mov.b"),{{RS8,DISP16DST,E}}, {{ 0x6,0xE,DISPREG|B31,RS8,DISP16DST,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),6,"mov.b"),{{RS8,RDDEC|B31,E}}, {{ 0x6,0xC,RDDEC|B31,RS8,E,0,0,0,0}}EOP,
+
+ SOP(O(O_MOV_TO_MEM,SB),4,"mov.b"),{{RS8,ABS8DST,E}}, {{ 0x3,RS8,ABS8DST,IGNORE,E,0,0,0,0}}EOP,
+
+ SOP(O(O_MOV_TO_MEM,SW),6,"mov.w"),{{RS16,RDIND,E}}, {{ 0x6,0x9,RDIND|B31,RS16,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),6,"mov.w"),{{DISP|L_32|SRC,RD16,E}},{{ 0x7,0x8,B30|DISPREG,0x0,0x6,0xB,0x2,RD16,SRC|DISP32LIST,E}}EOP,
+ SOP(O(O_MOV_TO_MEM,SW),6,"mov.w"),{{RS16,DISP|L_32|DST,E}},{{ 0x7,0x8,B30|DISPREG,0x0,0x6,0xB,0xA,RS16,DST|DISP32LIST,E}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),6,"mov.w"),{{ABS|L_32|MEMRELAX|SRC,RD16,E }},{{ 0x6,0xB,0x2,RD16,SRC|MEMRELAX|ABS32LIST,E }}EOP,
+ SOP(O(O_MOV_TO_MEM,SW),6,"mov.w"),{{RS16,ABS|L_32|MEMRELAX|DST,E }},{{ 0x6,0xB,0xA,RS16,DST|MEMRELAX|ABS32LIST,E }}EOP,
+ SOP(O(O_MOV_TO_REG,SW),2,"mov.w"),{{RS16,RD16,E}}, {{ 0x0,0xD,RS16, RD16,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),4,"mov.w"),{{IMM16,RD16,E}}, {{ 0x7,0x9,0x0,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),4,"mov.w"),{{RSIND,RD16,E}}, {{ 0x6,0x9,B30|RSIND,RD16,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),6,"mov.w"),{{DISP16SRC,RD16,E}}, {{ 0x6,0xF,B30|DISPREG,RD16,DISP16SRC,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),6,"mov.w"),{{RSINC,RD16,E}}, {{ 0x6,0xD,B30|RSINC,RD16,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_REG,SW),6,"mov.w"),{{ABS16SRC,RD16,E}}, {{ 0x6,0xB,0x0,RD16,ABS16SRC,IGNORE,IGNORE,IGNORE,E}}EOP,
+
+ SOP(O(O_MOV_TO_MEM,SW),6,"mov.w"),{{RS16,DISP16DST,E}}, {{ 0x6,0xF,DISPREG|B31,RS16,DISP16DST,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_MOV_TO_MEM,SW),6,"mov.w"),{{RS16,RDDEC,E}}, {{ 0x6,0xD,RDDEC|B31,RS16,E,0,0,0,0}}EOP,
+ SOP(O(O_MOV_TO_MEM,SW),6,"mov.w"),{{RS16,ABS16DST,E}}, {{ 0x6,0xB,0x8,RS16,ABS16DST,IGNORE,IGNORE,IGNORE,E}}EOP,
+
+ SOP(O(O_MOV_TO_REG,SL),4,"mov.l"),{{IMM32,RD32,E}}, {{ 0x7,0xA,0x0,B30|RD32,IMM32LIST,E}}EOP,
+ SOP(O(O_MOV_TO_REG,SL),2,"mov.l"),{{RS32,RD32,E}}, {{ 0x0,0xF,B31|RS32,B30|RD32,E,0,0,0,0}}EOP,
+
+ SOP(O(O_MOV_TO_REG,SL),4,"mov.l"),{{RSIND,RD32,E}}, {{ PREFIX32,0x6,0x9,RSIND|B30,B30|RD32,E,0,0,0,0 }}EOP,
+ SOP(O(O_MOV_TO_REG,SL),6,"mov.l"),{{DISP16SRC,RD32,E}}, {{ PREFIX32,0x6,0xF,DISPREG|B30,B30|RD32,DISP16SRC,IGNORE,IGNORE,IGNORE,E }}EOP,
+ SOP(O(O_MOV_TO_REG,SL),6,"mov.l"),{{DISP|L_32|SRC,RD32,E}},{{ PREFIX32,0x7,0x8,B30|DISPREG,0x0,0x6,0xB,0x2,B30|RD32,SRC|DISP32LIST,E }}EOP,
+ SOP(O(O_MOV_TO_REG,SL),6,"mov.l"),{{RSINC,RD32,E}}, {{ PREFIX32,0x6,0xD,B30|RSINC,B30|RD32,E,0,0,0,0 }}EOP,
+ SOP(O(O_MOV_TO_REG,SL),6,"mov.l"),{{ABS16SRC,RD32,E}}, {{ PREFIX32,0x6,0xB,0x0,B30|RD32,ABS16SRC,IGNORE,IGNORE,IGNORE,E }}EOP,
+ SOP(O(O_MOV_TO_REG,SL),6,"mov.l"),{{ABS32SRC|MEMRELAX,RD32,E }}, {{ PREFIX32,0x6,0xB,0x2,B30|RD32,SRC|MEMRELAX|ABS32LIST,E }}EOP,
+ SOP(O(O_MOV_TO_MEM,SL),6,"mov.l"),{{RS32,RDIND,E}}, {{ PREFIX32,0x6,0x9,RDIND|B31,B30|RS32,E,0,0,0,0 }}EOP,
+ SOP(O(O_MOV_TO_MEM,SL),6,"mov.l"),{{RS32,DISP16DST,E}}, {{ PREFIX32,0x6,0xF,DISPREG|B31,B30|RS32,DISP16DST,IGNORE,IGNORE,IGNORE,E }}EOP,
+ SOP(O(O_MOV_TO_MEM,SL),6,"mov.l"),{{RS32,DISP|L_32|DST,E}},{{ PREFIX32,0x7,0x8,B31|DISPREG,0x0,0x6,0xB,0xA,B30|RS32,DST|DISP32LIST,E }}EOP,
+ SOP(O(O_MOV_TO_MEM,SL),6,"mov.l"),{{RS32,RDDEC,E}}, {{ PREFIX32,0x6,0xD,RDDEC|B31,B30|RS32,E,0,0,0,0 }}EOP,
+ SOP(O(O_MOV_TO_MEM,SL),6,"mov.l"),{{RS32,ABS16DST,E}}, {{ PREFIX32,0x6,0xB,0x8,B30|RS32,ABS16DST,IGNORE,IGNORE,IGNORE,E }}EOP,
+ SOP(O(O_MOV_TO_MEM,SL),6,"mov.l"),{{RS32,ABS32DST|MEMRELAX,E }}, {{ PREFIX32,0x6,0xB,0xA,B30|RS32,DST|MEMRELAX|ABS32LIST,E }}EOP,
+
+ SOP(O(O_MOV_TO_REG,SB),10,"movfpe"),{{ABS16SRC,RD8,E}},{{ 0x6,0xA,0x4,RD8,ABS16SRC,IGNORE,IGNORE,IGNORE,E}}EOP,
+ SOP(O(O_MOV_TO_MEM,SB),10,"movtpe"),{{RS8,ABS16DST,E}},{{ 0x6,0xA,0xC,RS8,ABS16DST,IGNORE,IGNORE,IGNORE,E}}EOP,
+
+ NEW_SOP(O(O_MULU,SB),1,14,"mulxu.b"),{{RS8,RD16,E}}, {{ 0x5,0x0,RS8,RD16,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_MULU,SW),0,14,"mulxu.w"),{{RS16,RD32,E}},{{ 0x5,0x2,RS16,B30|RD32,E,0,0,0,0}}EOP,
+
+ NEW_SOP(O(O_MULS,SB),0,20,"mulxs.b"),{{RS8,RD16,E}}, {{ 0x0,0x1,0xc,0x0,0x5,0x0,RS8,RD16,E}}EOP,
+ NEW_SOP(O(O_MULS,SW),0,20,"mulxs.w"),{{RS16,RD32,E}},{{ 0x0,0x1,0xc,0x0,0x5,0x2,RS16,B30|RD32,E}}EOP,
+
+ /* ??? This can use UNOP3. */
+ NEW_SOP(O(O_NEG,SB),1,2,"neg.b"),{{ OR8,E, 0}},{{ 0x1,0x7,0x8,OR8,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_NEG,SW),0,2,"neg.w"),{{ OR16,E,0}},{{ 0x1,0x7,0x9,OR16,E}}EOP,
+ NEW_SOP(O(O_NEG,SL),0,2,"neg.l"),{{ OR32,E,0}},{{ 0x1,0x7,0xB,B30|OR32,E}}EOP,
+
+ NEW_SOP(O(O_NOP,SN),1,2,"nop"),{{E,0,0}},{{ 0x0,0x0,0x0,0x0,E,0,0,0,0}}EOP,
+
+ /* ??? This can use UNOP3. */
+ NEW_SOP(O(O_NOT,SB),1,2,"not.b"),{{ OR8,E, 0}},{{ 0x1,0x7,0x0,OR8,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_NOT,SW),0,2,"not.w"),{{ OR16,E,0}},{{ 0x1,0x7,0x1,OR16,E}}EOP,
+ NEW_SOP(O(O_NOT,SL),0,2,"not.l"),{{ OR32,E,0}},{{ 0x1,0x7,0x3,B30|OR32,E}}EOP,
+
+ TWOOP(O(O_OR, SB),"or.b",0xC,0x1,0x4),
+ NEW_SOP(O(O_OR,SW),0,4,"or.w"),{{IMM16,RD16,E }},{{0x7,0x9,0x4,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}} EOP,
+ NEW_SOP(O(O_OR,SW),0,2,"or.w"),{{RS16,RD16,E }},{{0x6,0x4,RS16,RD16,E}} EOP,
+
+ NEW_SOP(O(O_OR,SL),0,6,"or.l"),{{IMM32,RD32,E }},{{0x7,0xA,0x4,B30|RD32,IMM32LIST,E}} EOP,
+ NEW_SOP(O(O_OR,SL),0,2,"or.l"),{{RS32,RD32,E }},{{0x0,0x1,0xF,0x0,0x6,0x4,B30|RS32,B30|RD32,E}} EOP,
+
+ NEW_SOP(O(O_ORC,SB),1,2,"orc"),{{IMM8,CCR,E}},{{ 0x0,0x4,IMM8,IGNORE,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_ORC,SB),1,2,"orc"),{{IMM8,EXR,E}},{{ 0x0,0x1,0x4,0x1,0x0,0x4,IMM8,IGNORE,E,0,0,0,0}}EOP,
+
+ NEW_SOP(O(O_MOV_TO_REG,SW),1,6,"pop.w"),{{OR16,E,0}},{{ 0x6,0xD,0x7,OR16,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_MOV_TO_REG,SL),0,6,"pop.l"),{{OR32,E,0}},{{ PREFIX32,0x6,0xD,0x7,OR32|B30,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_MOV_TO_MEM,SW),1,6,"push.w"),{{OR16,E,0}},{{ 0x6,0xD,0xF,OR16,E,0,0,0,0}}EOP,
+ NEW_SOP(O(O_MOV_TO_MEM,SL),0,6,"push.l"),{{OR32,E,0}},{{ PREFIX32,0x6,0xD,0xF,OR32|B30,E,0,0,0,0}}EOP,
+
+ UNOP3(O_ROTL, "rotl", 0x1,0x2,0x8),
+ UNOP3(O_ROTR, "rotr", 0x1,0x3,0x8),
+ UNOP3(O_ROTXL, "rotxl",0x1,0x2,0x0),
+ UNOP3(O_ROTXR, "rotxr",0x1,0x3,0x0),
+
+ SOP(O(O_BPT,SN), 10,"bpt"),{{E,0,0}},{{ 0x7,0xA,0xF,0xF,E,0,0,0,0}}EOP,
+ SOP(O(O_RTE,SN), 10,"rte"),{{E,0,0}},{{ 0x5,0x6,0x7,0x0,E,0,0,0,0}}EOP,
+ SOP(O(O_RTS,SN), 8,"rts"),{{E,0,0}},{{ 0x5,0x4,0x7,0x0,E,0,0,0,0}}EOP,
+
+ UNOP3(O_SHAL, "shal",0x1,0x0,0x8),
+ UNOP3(O_SHAR, "shar",0x1,0x1,0x8),
+ UNOP3(O_SHLL, "shll",0x1,0x0,0x0),
+ UNOP3(O_SHLR, "shlr",0x1,0x1,0x0),
+
+ SOP(O(O_SLEEP,SN),2,"sleep"),{{E,0,0}},{{ 0x0,0x1,0x8,0x0,E,0,0,0,0}} EOP,
+
+ NEW_SOP(O(O_STC,SB), 1,2,"stc"),{{CCR,RD8,E}},{{ 0x0,0x2,0x0,RD8,E,0,0,0,0}} EOP,
+
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{CCR,RSIND,E}}, {{PREFIXLDC,0x6,0x9,B31|RDIND,0x0,E}} EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{CCR,DISP|DST|L_16,E}},{{PREFIXLDC,0x6,0xF,B31|DISPREG,0,DST|DISP|L_16,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{CCR,DISP|DST|L_32,E}},{{PREFIXLDC,0x7,0x8,B30|DISPREG,0,0x6,0xB,0xA,0x0,DST|DISP32LIST,E}}EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{CCR,RDDEC,E}}, {{PREFIXLDC,0x6,0xD,B31|RDDEC,0x0,E}}EOP,
+
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{CCR,ABS16SRC,E}}, {{PREFIXLDC,0x6,0xB,0x8,0x0,ABS16DST,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{CCR,ABS32SRC,E}}, {{PREFIXLDC,0x6,0xB,0xA,0x0,DST|ABS32LIST,E}}EOP,
+
+ NEW_SOP(O(O_STC,SB), 1,2,"stc"),{{EXR,RD8,E}},{{ 0x0,0x2,0x1,RD8,E,0,0,0,0}} EOP,
+
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{EXR,RSIND,E}}, {{0x0,0x1,0x4,0x1,0x6,0x9,B31|RDIND,0x0,E}} EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{EXR,DISP|DST|L_16,E}},{{0x0,0x1,0x4,0x1,0x6,0xF,B31|DISPREG,0,DST|DISP|L_16,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{EXR,DISP|DST|L_32,E}},{{0x0,0x1,0x4,0x1,0x7,0x8,B30|DISPREG,0,0x6,0xB,0xA,0x0,DST|DISP32LIST,E}}EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{EXR,RDDEC,E}}, {{0x0,0x1,0x4,0x1,0x6,0xD,B31|RDDEC,0x0,E}}EOP,
+
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{EXR,ABS16SRC,E}}, {{0x0,0x1,0x4,0x1,0x6,0xB,0x8,0x0,ABS16DST,IGNORE,IGNORE,IGNORE,E}}EOP,
+ NEW_SOP(O(O_STC,SB),0,2,"stc"),{{EXR,ABS32SRC,E}}, {{0x0,0x1,0x4,0x1,0x6,0xB,0xA,0x0,DST|ABS32LIST,E}}EOP,
+
+ SOP(O(O_SUB,SB),2,"sub.b"),{{RS8,RD8,E}},{{ 0x1,0x8,RS8,RD8,E,0,0,0,0}}EOP,
+
+ NEW_SOP(O(O_SUB,SW),1,2,"sub.w"),{{RS16,RD16,E }}, {{0x1,0x9,RS16,RD16,E}} EOP,
+ NEW_SOP(O(O_SUB,SW),0,4,"sub.w"),{{IMM16,RD16,E }}, {{0x7,0x9,0x3,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}} EOP,
+ NEW_SOP(O(O_SUB,SL),0,2,"sub.l") ,{{RS32,RD32,E }}, {{0x1,0xA,B31|RS32,B30|RD32,E}} EOP,
+ NEW_SOP(O(O_SUB,SL),0,6,"sub.l"), {{IMM32,RD32,E }},{{0x7,0xA,0x3,B30|RD32,IMM32LIST,E}} EOP,
+
+ SOP(O(O_SUBS,SL),2,"subs"),{{KBIT,RDP,E}},{{ 0x1,0xB,KBIT,RDP,E,0,0,0,0}}EOP,
+ TWOOP(O(O_SUBX,SB),"subx",0xB,0x1,0xE),
+
+ NEW_SOP(O(O_TRAPA,SB),0,2,"trapa"),{{ IMM2,E}}, {{0x5,0x7,IMM2,IGNORE,E }}EOP,
+ NEW_SOP(O(O_TAS,SB),0,2,"tas"),{{RSIND,E}}, {{0x0,0x1,0xe,0x0,0x7,0xb,B30|RSIND,0xc,E }}EOP,
+
+ TWOOP(O(O_XOR, SB),"xor",0xD,0x1,0x5),
+
+ NEW_SOP(O(O_XOR,SW),0,4,"xor.w"),{{IMM16,RD16,E }},{{0x7,0x9,0x5,RD16,IMM16,IGNORE,IGNORE,IGNORE,E}} EOP,
+ NEW_SOP(O(O_XOR,SW),0,2,"xor.w"),{{RS16,RD16,E }},{{0x6,0x5,RS16,RD16,E}} EOP,
+
+ NEW_SOP(O(O_XOR,SL),0,6,"xor.l"),{{IMM32,RD32,E }},{{0x7,0xA,0x5,B30|RD32,IMM32LIST,E}} EOP,
+ NEW_SOP(O(O_XOR,SL),0,2,"xor.l") ,{{RS32,RD32,E }},{{0x0,0x1,0xF,0x0,0x6,0x5,B30|RS32,B30|RD32,E}} EOP,
+
+ SOP(O(O_XORC,SB),2,"xorc"),{{IMM8,CCR,E}},{{ 0x0,0x5,IMM8,IGNORE,E,0,0,0,0}}EOP,
+ SOP(O(O_XORC,SB),2,"xorc"),{{IMM8,EXR,E}},{{ 0x0,0x1,0x4,0x1,0x0,0x5,IMM8,IGNORE,E,0,0,0,0}}EOP,
+
+ NEW_SOP(O(O_CLRMAC,SN),1,2,"clrmac"),{{E, 0, 0}},{{0x0,0x1,0xa,0x0,E}} EOP,
+ NEW_SOP(O(O_MAC,SL),1,2,"mac"),{{RSINC,RDINC,E}},{{0x0,0x1,0x6,0x0,0x6,0xd,B30|RSINC,B30|RDINC,E}} EOP,
+ NEW_SOP(O(O_LDMAC,SL),1,2,"ldmac"),{{RS32,MACREG,E}},{{0x0,0x3,MACREG,RS32,E}} EOP,
+ NEW_SOP(O(O_STMAC,SL),1,2,"stmac"),{{MACREG,RD32,E}},{{0x0,0x2,MACREG,RD32,E}} EOP,
+ NEW_SOP(O(O_LDM,SL),0,6,"ldm.l"),{{RSINC, RS32, E}},{{ 0x0,0x1,IGNORE,0x0,0x6,0xD,0x7,IGNORE,E}}EOP,
+ NEW_SOP(O(O_STM,SL),0,6,"stm.l"),{{RS32, RDDEC, E}},{{0x0,0x1,IGNORE,0x0,0x6,0xD,0xF,IGNORE,E}}EOP,
+ { 0 }
+};
+#else
+extern struct h8_opcode h8_opcodes[] ;
+#endif
+
+
+
+
diff --git a/include/opcode/hppa.h b/include/opcode/hppa.h
new file mode 100644
index 00000000000..30ccb6ccffc
--- /dev/null
+++ b/include/opcode/hppa.h
@@ -0,0 +1,486 @@
+/* Table of opcodes for the PA-RISC.
+ Copyright (C) 1990, 1991, 1993, 1995, 1999 Free Software Foundation, Inc.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler.
+
+GAS/GDB 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 1, or (at your option)
+any later version.
+
+GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if !defined(__STDC__) && !defined(const)
+#define const
+#endif
+
+/*
+ * Structure of an opcode table entry.
+ */
+
+/* There are two kinds of delay slot nullification: normal which is
+ * controled by the nullification bit, and conditional, which depends
+ * on the direction of the branch and its success or failure.
+ *
+ * NONE is unfortunately #defined in the hiux system include files.
+ * #undef it away.
+ */
+#undef NONE
+struct pa_opcode
+{
+ const char *name;
+ unsigned long int match; /* Bits that must be set... */
+ unsigned long int mask; /* ... in these bits. */
+ char *args;
+ enum pa_arch arch;
+};
+
+
+/*
+ All hppa opcodes are 32 bits.
+
+ The match component is a mask saying which bits must match a
+ particular opcode in order for an instruction to be an instance
+ of that opcode.
+
+ The args component is a string containing one character
+ for each operand of the instruction.
+
+ Bit positions in this description follow HP usage of lsb = 31,
+ "at" is lsb of field.
+
+ In the args field, the following characters must match exactly:
+
+ '+,() '
+
+ In the args field, the following characters are unused:
+
+ ' "#$% *+- ./ :; '
+ ' [\] '
+ ' { } '
+
+ Here are all the characters:
+
+ ' !"#$%&'()*+-,./0123456789:;<=>?@'
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
+ 'abcdefghijklmnopqrstuvwxyz{|}~'
+
+Kinds of operands:
+ x integer register field at 15.
+ b integer register field at 10.
+ t integer register field at 31.
+ y floating point register field at 31
+ 5 5 bit immediate at 15.
+ s 2 bit space specifier at 17.
+ S 3 bit space specifier at 18.
+ c indexed load completer.
+ C short load and store completer.
+ Y Store Bytes Short completer
+ < non-negated compare/subtract conditions.
+ a compare/subtract conditions
+ d non-negated add conditions
+ & logical instruction conditions
+ U unit instruction conditions
+ > shift/extract/deposit conditions.
+ ~ bvb,bb conditions
+ V 5 bit immediate value at 31
+ i 11 bit immediate value at 31
+ j 14 bit immediate value at 31
+ k 21 bit immediate value at 31
+ n nullification for branch instructions
+ N nullification for spop and copr instructions
+ w 12 bit branch displacement
+ W 17 bit branch displacement (PC relative)
+ z 17 bit branch displacement (just a number, not an address)
+
+Also these:
+
+ p 5 bit shift count at 26 (to support the SHD instruction) encoded as
+ 31-p
+ P 5 bit bit position at 26
+ T 5 bit field length at 31 (encoded as 32-T)
+ A 13 bit immediate at 18 (to support the BREAK instruction)
+ ^ like b, but describes a control register
+ Z System Control Completer (to support LPA, LHA, etc.)
+ D 26 bit immediate at 31 (to support the DIAG instruction)
+
+ f 3 bit Special Function Unit identifier at 25
+ O 20 bit Special Function Unit operation split between 15 bits at 20
+ and 5 bits at 31
+ o 15 bit Special Function Unit operation at 20
+ 2 22 bit Special Function Unit operation split between 17 bits at 20
+ and 5 bits at 31
+ 1 15 bit Special Function Unit operation split between 10 bits at 20
+ and 5 bits at 31
+ 0 10 bit Special Function Unit operation split between 5 bits at 20
+ and 5 bits at 31
+ u 3 bit coprocessor unit identifier at 25
+ F Source Floating Point Operand Format Completer encoded 2 bits at 20
+ I Source Floating Point Operand Format Completer encoded 1 bits at 20
+ (for 0xe format FP instructions)
+ G Destination Floating Point Operand Format Completer encoded 2 bits at 18
+ M Floating-Point Compare Conditions (encoded as 5 bits at 31)
+ ? non-negated/negated compare/subtract conditions.
+ @ non-negated/negated add conditions.
+ ! non-negated add conditions.
+
+ s 2 bit space specifier at 17.
+ b register field at 10.
+ r 5 bit immediate value at 31 (for the break instruction)
+ (very similar to V above, except the value is unsigned instead of
+ low_sign_ext)
+ R 5 bit immediate value at 15 (for the ssm, rsm, probei instructions)
+ (same as r above, except the value is in a different location)
+ Q 5 bit immediate value at 10 (a bit position specified in
+ the bb instruction. It's the same as r above, except the
+ value is in a different location)
+ | shift/extract/deposit conditions when used in a conditional branch
+
+And these (PJH) for PA-89 F.P. registers and instructions:
+
+ v a 't' operand type extended to handle L/R register halves.
+ E a 'b' operand type extended to handle L/R register halves.
+ X an 'x' operand type extended to handle L/R register halves.
+ J a 'b' operand type further extended to handle extra 1.1 registers
+ K a 'x' operand type further extended to handle extra 1.1 registers
+ 4 a variation of the 'b' operand type for 'fmpyadd' and 'fmpysub'
+ 6 a variation of the 'x' operand type for 'fmpyadd' and 'fmpysub'
+ 7 a variation of the 't' operand type for 'fmpyadd' and 'fmpysub'
+ 8 5 bit register field at 20 (used in 'fmpyadd' and 'fmpysub')
+ 9 5 bit register field at 25 (used in 'fmpyadd' and 'fmpysub')
+ H Floating Point Operand Format at 26 for 'fmpyadd' and 'fmpysub'
+ (very similar to 'F')
+*/
+
+
+/* List of characters not to put a space after. Note that
+ "," is included, as the "spopN" operations use literal
+ commas in their completer sections. */
+static const char *const completer_chars = ",CcY<>?!@+&U~FfGHINnOoZMadu|/=0123%e$m}";
+
+/* The order of the opcodes in this table is significant:
+
+ * The assembler requires that all instances of the same mnemonic must be
+ consecutive. If they aren't, the assembler will bomb at runtime.
+
+ * The disassembler should not care about the order of the opcodes. */
+
+static const struct pa_opcode pa_opcodes[] =
+{
+
+
+/* pseudo-instructions */
+
+{ "b", 0xe8000000, 0xffe0e000, "nW", pa10}, /* bl foo,r0 */
+{ "ldi", 0x34000000, 0xffe0c000, "j,x", pa10}, /* ldo val(r0),r */
+{ "comib", 0x84000000, 0xfc000000, "?n5,b,w", pa10}, /* comib{tf}*/
+{ "comb", 0x80000000, 0xfc000000, "?nx,b,w", pa10}, /* comb{tf} */
+{ "addb", 0xa0000000, 0xfc000000, "@nx,b,w", pa10}, /* addb{tf} */
+{ "addib", 0xa4000000, 0xfc000000, "@n5,b,w", pa10}, /* addib{tf}*/
+{ "nop", 0x08000240, 0xffffffff, "", pa10}, /* or 0,0,0 */
+{ "copy", 0x08000240, 0xffe0ffe0, "x,t", pa10}, /* or r,0,t */
+{ "mtsar", 0x01601840, 0xffe0ffff, "x", pa10}, /* mtctl r,cr11 */
+
+/* Loads and Stores for integer registers. */
+{ "ldw", 0x48000000, 0xfc000000, "j(s,b),x", pa10},
+{ "ldw", 0x48000000, 0xfc000000, "j(b),x", pa10},
+{ "ldh", 0x44000000, 0xfc000000, "j(s,b),x", pa10},
+{ "ldh", 0x44000000, 0xfc000000, "j(b),x", pa10},
+{ "ldb", 0x40000000, 0xfc000000, "j(s,b),x", pa10},
+{ "ldb", 0x40000000, 0xfc000000, "j(b),x", pa10},
+{ "stw", 0x68000000, 0xfc000000, "x,j(s,b)", pa10},
+{ "stw", 0x68000000, 0xfc000000, "x,j(b)", pa10},
+{ "sth", 0x64000000, 0xfc000000, "x,j(s,b)", pa10},
+{ "sth", 0x64000000, 0xfc000000, "x,j(b)", pa10},
+{ "stb", 0x60000000, 0xfc000000, "x,j(s,b)", pa10},
+{ "stb", 0x60000000, 0xfc000000, "x,j(b)", pa10},
+{ "ldwm", 0x4c000000, 0xfc000000, "j(s,b),x", pa10},
+{ "ldwm", 0x4c000000, 0xfc000000, "j(b),x", pa10},
+{ "stwm", 0x6c000000, 0xfc000000, "x,j(s,b)", pa10},
+{ "stwm", 0x6c000000, 0xfc000000, "x,j(b)", pa10},
+{ "ldwx", 0x0c000080, 0xfc001fc0, "cx(s,b),t", pa10},
+{ "ldwx", 0x0c000080, 0xfc001fc0, "cx(b),t", pa10},
+{ "ldhx", 0x0c000040, 0xfc001fc0, "cx(s,b),t", pa10},
+{ "ldhx", 0x0c000040, 0xfc001fc0, "cx(b),t", pa10},
+{ "ldbx", 0x0c000000, 0xfc001fc0, "cx(s,b),t", pa10},
+{ "ldbx", 0x0c000000, 0xfc001fc0, "cx(b),t", pa10},
+{ "ldwax", 0x0c000180, 0xfc00dfc0, "cx(b),t", pa10},
+{ "ldcwx", 0x0c0001c0, 0xfc001fc0, "cx(s,b),t", pa10},
+{ "ldcwx", 0x0c0001c0, 0xfc001fc0, "cx(b),t", pa10},
+{ "ldws", 0x0c001080, 0xfc001fc0, "C5(s,b),t", pa10},
+{ "ldws", 0x0c001080, 0xfc001fc0, "C5(b),t", pa10},
+{ "ldhs", 0x0c001040, 0xfc001fc0, "C5(s,b),t", pa10},
+{ "ldhs", 0x0c001040, 0xfc001fc0, "C5(b),t", pa10},
+{ "ldbs", 0x0c001000, 0xfc001fc0, "C5(s,b),t", pa10},
+{ "ldbs", 0x0c001000, 0xfc001fc0, "C5(b),t", pa10},
+{ "ldwas", 0x0c001180, 0xfc00dfc0, "C5(b),t", pa10},
+{ "ldcws", 0x0c0011c0, 0xfc001fc0, "C5(s,b),t", pa10},
+{ "ldcws", 0x0c0011c0, 0xfc001fc0, "C5(b),t", pa10},
+{ "stws", 0x0c001280, 0xfc001fc0, "Cx,V(s,b)", pa10},
+{ "stws", 0x0c001280, 0xfc001fc0, "Cx,V(b)", pa10},
+{ "sths", 0x0c001240, 0xfc001fc0, "Cx,V(s,b)", pa10},
+{ "sths", 0x0c001240, 0xfc001fc0, "Cx,V(b)", pa10},
+{ "stbs", 0x0c001200, 0xfc001fc0, "Cx,V(s,b)", pa10},
+{ "stbs", 0x0c001200, 0xfc001fc0, "Cx,V(b)", pa10},
+{ "stwas", 0x0c001380, 0xfc00dfc0, "Cx,V(b)", pa10},
+{ "stbys", 0x0c001300, 0xfc001fc0, "Yx,V(s,b)", pa10},
+{ "stbys", 0x0c001300, 0xfc001fc0, "Yx,V(b)", pa10},
+
+/* Immediate instructions. */
+{ "ldo", 0x34000000, 0xfc00c000, "j(b),x", pa10},
+{ "ldil", 0x20000000, 0xfc000000, "k,b", pa10},
+{ "addil", 0x28000000, 0xfc000000, "k,b", pa10},
+
+/* Branching instructions. */
+{ "bl", 0xe8000000, 0xfc00e000, "nW,b", pa10},
+{ "gate", 0xe8002000, 0xfc00e000, "nW,b", pa10},
+{ "blr", 0xe8004000, 0xfc00e001, "nx,b", pa10},
+{ "bv", 0xe800c000, 0xfc00fffd, "nx(b)", pa10},
+{ "bv", 0xe800c000, 0xfc00fffd, "n(b)", pa10},
+{ "be", 0xe0000000, 0xfc000000, "nz(S,b)", pa10},
+{ "ble", 0xe4000000, 0xfc000000, "nz(S,b)", pa10},
+{ "movb", 0xc8000000, 0xfc000000, "|nx,b,w", pa10},
+{ "movib", 0xcc000000, 0xfc000000, "|n5,b,w", pa10},
+{ "combt", 0x80000000, 0xfc000000, "<nx,b,w", pa10},
+{ "combf", 0x88000000, 0xfc000000, "<nx,b,w", pa10},
+{ "comibt", 0x84000000, 0xfc000000, "<n5,b,w", pa10},
+{ "comibf", 0x8c000000, 0xfc000000, "<n5,b,w", pa10},
+{ "addbt", 0xa0000000, 0xfc000000, "!nx,b,w", pa10},
+{ "addbf", 0xa8000000, 0xfc000000, "!nx,b,w", pa10},
+{ "addibt", 0xa4000000, 0xfc000000, "!n5,b,w", pa10},
+{ "addibf", 0xac000000, 0xfc000000, "!n5,b,w", pa10},
+{ "bb", 0xc4004000, 0xfc004000, "~nx,Q,w", pa10},
+{ "bvb", 0xc0004000, 0xffe04000, "~nx,w", pa10},
+
+/* Computation Instructions */
+
+{ "add", 0x08000600, 0xfc000fe0, "dx,b,t", pa10},
+{ "addl", 0x08000a00, 0xfc000fe0, "dx,b,t", pa10},
+{ "addo", 0x08000e00, 0xfc000fe0, "dx,b,t", pa10},
+{ "addc", 0x08000700, 0xfc000fe0, "dx,b,t", pa10},
+{ "addco", 0x08000f00, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh1add", 0x08000640, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh1addl", 0x08000a40, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh1addo", 0x08000e40, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh2add", 0x08000680, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh2addl", 0x08000a80, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh2addo", 0x08000e80, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh3add", 0x080006c0, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh3addl", 0x08000ac0, 0xfc000fe0, "dx,b,t", pa10},
+{ "sh3addo", 0x08000ec0, 0xfc000fe0, "dx,b,t", pa10},
+{ "sub", 0x08000400, 0xfc000fe0, "ax,b,t", pa10},
+{ "subo", 0x08000c00, 0xfc000fe0, "ax,b,t", pa10},
+{ "subb", 0x08000500, 0xfc000fe0, "ax,b,t", pa10},
+{ "subbo", 0x08000d00, 0xfc000fe0, "ax,b,t", pa10},
+{ "subt", 0x080004c0, 0xfc000fe0, "ax,b,t", pa10},
+{ "subto", 0x08000cc0, 0xfc000fe0, "ax,b,t", pa10},
+{ "ds", 0x08000440, 0xfc000fe0, "ax,b,t", pa10},
+{ "comclr", 0x08000880, 0xfc000fe0, "ax,b,t", pa10},
+{ "or", 0x08000240, 0xfc000fe0, "&x,b,t", pa10},
+{ "xor", 0x08000280, 0xfc000fe0, "&x,b,t", pa10},
+{ "and", 0x08000200, 0xfc000fe0, "&x,b,t", pa10},
+{ "andcm", 0x08000000, 0xfc000fe0, "&x,b,t", pa10},
+{ "uxor", 0x08000380, 0xfc000fe0, "Ux,b,t", pa10},
+{ "uaddcm", 0x08000980, 0xfc000fe0, "Ux,b,t", pa10},
+{ "uaddcmt", 0x080009c0, 0xfc000fe0, "Ux,b,t", pa10},
+{ "dcor", 0x08000b80, 0xfc1f0fe0, "Ub,t", pa10},
+{ "idcor", 0x08000bc0, 0xfc1f0fe0, "Ub,t", pa10},
+{ "addi", 0xb4000000, 0xfc000800, "di,b,x", pa10},
+{ "addio", 0xb4000800, 0xfc000800, "di,b,x", pa10},
+{ "addit", 0xb0000000, 0xfc000800, "di,b,x", pa10},
+{ "addito", 0xb0000800, 0xfc000800, "di,b,x", pa10},
+{ "subi", 0x94000000, 0xfc000800, "ai,b,x", pa10},
+{ "subio", 0x94000800, 0xfc000800, "ai,b,x", pa10},
+{ "comiclr", 0x90000000, 0xfc000800, "ai,b,x", pa10},
+
+/* Extract and Deposit Instructions */
+
+{ "vshd", 0xd0000000, 0xfc001fe0, ">x,b,t", pa10},
+{ "shd", 0xd0000800, 0xfc001c00, ">x,b,p,t", pa10},
+{ "vextru", 0xd0001000, 0xfc001fe0, ">b,T,x", pa10},
+{ "vextrs", 0xd0001400, 0xfc001fe0, ">b,T,x", pa10},
+{ "extru", 0xd0001800, 0xfc001c00, ">b,P,T,x", pa10},
+{ "extrs", 0xd0001c00, 0xfc001c00, ">b,P,T,x", pa10},
+{ "zvdep", 0xd4000000, 0xfc001fe0, ">x,T,b", pa10},
+{ "vdep", 0xd4000400, 0xfc001fe0, ">x,T,b", pa10},
+{ "zdep", 0xd4000800, 0xfc001c00, ">x,p,T,b", pa10},
+{ "dep", 0xd4000c00, 0xfc001c00, ">x,p,T,b", pa10},
+{ "zvdepi", 0xd4001000, 0xfc001fe0, ">5,T,b", pa10},
+{ "vdepi", 0xd4001400, 0xfc001fe0, ">5,T,b", pa10},
+{ "zdepi", 0xd4001800, 0xfc001c00, ">5,p,T,b", pa10},
+{ "depi", 0xd4001c00, 0xfc001c00, ">5,p,T,b", pa10},
+
+/* System Control Instructions */
+
+{ "break", 0x00000000, 0xfc001fe0, "r,A", pa10},
+{ "rfi", 0x00000c00, 0xffffffff, "", pa10},
+{ "rfir", 0x00000ca0, 0xffffffff, "", pa11},
+{ "ssm", 0x00000d60, 0xffe0ffe0, "R,t", pa10},
+{ "rsm", 0x00000e60, 0xffe0ffe0, "R,t", pa10},
+{ "mtsm", 0x00001860, 0xffe0ffff, "x", pa10},
+{ "ldsid", 0x000010a0, 0xfc1f3fe0, "(s,b),t", pa10},
+{ "ldsid", 0x000010a0, 0xfc1f3fe0, "(b),t", pa10},
+{ "mtsp", 0x00001820, 0xffe01fff, "x,S", pa10},
+{ "mtctl", 0x00001840, 0xfc00ffff, "x,^", pa10},
+{ "mfsp", 0x000004a0, 0xffff1fe0, "S,t", pa10},
+{ "mfctl", 0x000008a0, 0xfc1fffe0, "^,t", pa10},
+{ "sync", 0x00000400, 0xffffffff, "", pa10},
+{ "syncdma", 0x00100400, 0xffffffff, "", pa10},
+{ "prober", 0x04001180, 0xfc003fe0, "(s,b),x,t", pa10},
+{ "prober", 0x04001180, 0xfc003fe0, "(b),x,t", pa10},
+{ "proberi", 0x04003180, 0xfc003fe0, "(s,b),R,t", pa10},
+{ "proberi", 0x04003180, 0xfc003fe0, "(b),R,t", pa10},
+{ "probew", 0x040011c0, 0xfc003fe0, "(s,b),x,t", pa10},
+{ "probew", 0x040011c0, 0xfc003fe0, "(b),x,t", pa10},
+{ "probewi", 0x040031c0, 0xfc003fe0, "(s,b),R,t", pa10},
+{ "probewi", 0x040031c0, 0xfc003fe0, "(b),R,t", pa10},
+{ "lpa", 0x04001340, 0xfc003fc0, "Zx(s,b),t", pa10},
+{ "lpa", 0x04001340, 0xfc003fc0, "Zx(b),t", pa10},
+{ "lha", 0x04001300, 0xfc003fc0, "Zx(s,b),t", pa10},
+{ "lha", 0x04001300, 0xfc003fc0, "Zx(b),t", pa10},
+{ "lci", 0x04001300, 0xfc003fe0, "x(s,b),t", pa10},
+{ "lci", 0x04001300, 0xfc003fe0, "x(b),t", pa10},
+{ "pdtlb", 0x04001200, 0xfc003fdf, "Zx(s,b)", pa10},
+{ "pdtlb", 0x04001200, 0xfc003fdf, "Zx(b)", pa10},
+{ "pitlb", 0x04000200, 0xfc001fdf, "Zx(S,b)", pa10},
+{ "pitlb", 0x04000200, 0xfc001fdf, "Zx(b)", pa10},
+{ "pdtlbe", 0x04001240, 0xfc003fdf, "Zx(s,b)", pa10},
+{ "pdtlbe", 0x04001240, 0xfc003fdf, "Zx(b)", pa10},
+{ "pitlbe", 0x04000240, 0xfc001fdf, "Zx(S,b)", pa10},
+{ "pitlbe", 0x04000240, 0xfc001fdf, "Zx(b)", pa10},
+{ "idtlba", 0x04001040, 0xfc003fff, "x,(s,b)", pa10},
+{ "idtlba", 0x04001040, 0xfc003fff, "x,(b)", pa10},
+{ "iitlba", 0x04000040, 0xfc001fff, "x,(S,b)", pa10},
+{ "iitlba", 0x04000040, 0xfc001fff, "x,(b)", pa10},
+{ "idtlbp", 0x04001000, 0xfc003fff, "x,(s,b)", pa10},
+{ "idtlbp", 0x04001000, 0xfc003fff, "x,(b)", pa10},
+{ "iitlbp", 0x04000000, 0xfc001fff, "x,(S,b)", pa10},
+{ "iitlbp", 0x04000000, 0xfc001fff, "x,(b)", pa10},
+{ "pdc", 0x04001380, 0xfc003fdf, "Zx(s,b)", pa10},
+{ "pdc", 0x04001380, 0xfc003fdf, "Zx(b)", pa10},
+{ "fdc", 0x04001280, 0xfc003fdf, "Zx(s,b)", pa10},
+{ "fdc", 0x04001280, 0xfc003fdf, "Zx(b)", pa10},
+{ "fic", 0x04000280, 0xfc001fdf, "Zx(S,b)", pa10},
+{ "fic", 0x04000280, 0xfc001fdf, "Zx(b)", pa10},
+{ "fdce", 0x040012c0, 0xfc003fdf, "Zx(s,b)", pa10},
+{ "fdce", 0x040012c0, 0xfc003fdf, "Zx(b)", pa10},
+{ "fice", 0x040002c0, 0xfc001fdf, "Zx(S,b)", pa10},
+{ "fice", 0x040002c0, 0xfc001fdf, "Zx(b)", pa10},
+{ "diag", 0x14000000, 0xfc000000, "D", pa10},
+
+/* gfw and gfr are not in the HP PA 1.1 manual, but they are in either
+ the Timex FPU or the Mustang ERS (not sure which) manual. */
+{ "gfw", 0x04001680, 0xfc003fdf, "Zx(s,b)", pa11},
+{ "gfw", 0x04001680, 0xfc003fdf, "Zx(b)", pa11},
+{ "gfr", 0x04001a80, 0xfc003fdf, "Zx(s,b)", pa11},
+{ "gfr", 0x04001a80, 0xfc003fdf, "Zx(b)", pa11},
+
+/* Floating Point Coprocessor Instructions */
+
+{ "fldwx", 0x24000000, 0xfc001f80, "cx(s,b),v", pa10},
+{ "fldwx", 0x24000000, 0xfc001f80, "cx(b),v", pa10},
+{ "flddx", 0x2c000000, 0xfc001fc0, "cx(s,b),y", pa10},
+{ "flddx", 0x2c000000, 0xfc001fc0, "cx(b),y", pa10},
+{ "fstwx", 0x24000200, 0xfc001f80, "cv,x(s,b)", pa10},
+{ "fstwx", 0x24000200, 0xfc001f80, "cv,x(b)", pa10},
+{ "fstdx", 0x2c000200, 0xfc001fc0, "cy,x(s,b)", pa10},
+{ "fstdx", 0x2c000200, 0xfc001fc0, "cy,x(b)", pa10},
+{ "fstqx", 0x3c000200, 0xfc001fc0, "cy,x(s,b)", pa10},
+{ "fstqx", 0x3c000200, 0xfc001fc0, "cy,x(b)", pa10},
+{ "fldws", 0x24001000, 0xfc001f80, "C5(s,b),v", pa10},
+{ "fldws", 0x24001000, 0xfc001f80, "C5(b),v", pa10},
+{ "fldds", 0x2c001000, 0xfc001fc0, "C5(s,b),y", pa10},
+{ "fldds", 0x2c001000, 0xfc001fc0, "C5(b),y", pa10},
+{ "fstws", 0x24001200, 0xfc001f80, "Cv,5(s,b)", pa10},
+{ "fstws", 0x24001200, 0xfc001f80, "Cv,5(b)", pa10},
+{ "fstds", 0x2c001200, 0xfc001fc0, "Cy,5(s,b)", pa10},
+{ "fstds", 0x2c001200, 0xfc001fc0, "Cy,5(b)", pa10},
+{ "fstqs", 0x3c001200, 0xfc001fc0, "Cy,5(s,b)", pa10},
+{ "fstqs", 0x3c001200, 0xfc001fc0, "Cy,5(b)", pa10},
+{ "fadd", 0x30000600, 0xfc00e7e0, "FE,X,v", pa10},
+{ "fadd", 0x38000600, 0xfc00e720, "IJ,K,v", pa10},
+{ "fsub", 0x30002600, 0xfc00e7e0, "FE,X,v", pa10},
+{ "fsub", 0x38002600, 0xfc00e720, "IJ,K,v", pa10},
+{ "fmpy", 0x30004600, 0xfc00e7e0, "FE,X,v", pa10},
+{ "fmpy", 0x38004600, 0xfc00e720, "IJ,K,v", pa10},
+{ "fdiv", 0x30006600, 0xfc00e7e0, "FE,X,v", pa10},
+{ "fdiv", 0x38006600, 0xfc00e720, "IJ,K,v", pa10},
+{ "fsqrt", 0x30008000, 0xfc1fe7e0, "FE,v", pa10},
+{ "fsqrt", 0x38008000, 0xfc1fe720, "FJ,v", pa10},
+{ "fabs", 0x30006000, 0xfc1fe7e0, "FE,v", pa10},
+{ "fabs", 0x38006000, 0xfc1fe720, "FJ,v", pa10},
+{ "frem", 0x30008600, 0xfc00e7e0, "FE,X,v", pa10},
+{ "frem", 0x38008600, 0xfc00e720, "FJ,K,v", pa10},
+{ "frnd", 0x3000a000, 0xfc1fe7e0, "FE,v", pa10},
+{ "frnd", 0x3800a000, 0xfc1fe720, "FJ,v", pa10},
+{ "fcpy", 0x30004000, 0xfc1fe7e0, "FE,v", pa10},
+{ "fcpy", 0x38004000, 0xfc1fe720, "FJ,v", pa10},
+{ "fcnvff", 0x30000200, 0xfc1f87e0, "FGE,v", pa10},
+{ "fcnvff", 0x38000200, 0xfc1f8720, "FGJ,v", pa10},
+{ "fcnvxf", 0x30008200, 0xfc1f87e0, "FGE,v", pa10},
+{ "fcnvxf", 0x38008200, 0xfc1f8720, "FGJ,v", pa10},
+{ "fcnvfx", 0x30010200, 0xfc1f87e0, "FGE,v", pa10},
+{ "fcnvfx", 0x38010200, 0xfc1f8720, "FGJ,v", pa10},
+{ "fcnvfxt", 0x30018200, 0xfc1f87e0, "FGE,v", pa10},
+{ "fcnvfxt", 0x38018200, 0xfc1f8720, "FGJ,v", pa10},
+{ "fmpyfadd", 0xb8000000, 0xfc000020, "FE,X,3,v", pa20},
+{ "fmpynfadd", 0xb8000020, 0xfc000020, "FE,X,3,v", pa20},
+{ "fneg", 0x3000c000, 0xfc1fe7e0, "FE,v", pa20},
+{ "fneg", 0x3800c000, 0xfc1fe720, "FJ,v", pa20},
+{ "fnegabs", 0x3000e000, 0xfc1fe7e0, "FE,v", pa20},
+{ "fnegabs", 0x3800e000, 0xfc1fe720, "FJ,v", pa20},
+{ "fcmp", 0x30000400, 0xfc00e7e0, "FME,X", pa10},
+{ "fcmp", 0x38000400, 0xfc00e720, "IMJ,K", pa10},
+{ "xmpyu", 0x38004700, 0xfc00e720, "E,X,v", pa11},
+{ "fmpyadd", 0x18000000, 0xfc000000, "H4,6,7,9,8", pa11},
+{ "fmpysub", 0x98000000, 0xfc000000, "H4,6,7,9,8", pa11},
+{ "ftest", 0x30002420, 0xffffffff, "", pa10},
+{ "fid", 0x30000000, 0xffffffff, "", pa11},
+
+
+/* Assist Instructions */
+
+{ "spop0", 0x10000000, 0xfc000600, "f,ON", pa10},
+{ "spop1", 0x10000200, 0xfc000600, "f,oNt", pa10},
+{ "spop2", 0x10000400, 0xfc000600, "f,1Nb", pa10},
+{ "spop3", 0x10000600, 0xfc000600, "f,0Nx,b", pa10},
+{ "copr", 0x30000000, 0xfc000000, "u,2N", pa10},
+{ "cldwx", 0x24000000, 0xfc001e00, "ucx(s,b),t", pa10},
+{ "cldwx", 0x24000000, 0xfc001e00, "ucx(b),t", pa10},
+{ "clddx", 0x2c000000, 0xfc001e00, "ucx(s,b),t", pa10},
+{ "clddx", 0x2c000000, 0xfc001e00, "ucx(b),t", pa10},
+{ "cstwx", 0x24000200, 0xfc001e00, "uct,x(s,b)", pa10},
+{ "cstwx", 0x24000200, 0xfc001e00, "uct,x(b)", pa10},
+{ "cstdx", 0x2c000200, 0xfc001e00, "uct,x(s,b)", pa10},
+{ "cstdx", 0x2c000200, 0xfc001e00, "uct,x(b)", pa10},
+{ "cldws", 0x24001000, 0xfc001e00, "uC5(s,b),t", pa10},
+{ "cldws", 0x24001000, 0xfc001e00, "uC5(b),t", pa10},
+{ "cldds", 0x2c001000, 0xfc001e00, "uC5(s,b),t", pa10},
+{ "cldds", 0x2c001000, 0xfc001e00, "uC5(b),t", pa10},
+{ "cstws", 0x24001200, 0xfc001e00, "uCt,5(s,b)", pa10},
+{ "cstws", 0x24001200, 0xfc001e00, "uCt,5(b)", pa10},
+{ "cstds", 0x2c001200, 0xfc001e00, "uCt,5(s,b)", pa10},
+{ "cstds", 0x2c001200, 0xfc001e00, "uCt,5(b)", pa10},
+};
+
+#define NUMOPCODES ((sizeof pa_opcodes)/(sizeof pa_opcodes[0]))
+
+/* SKV 12/18/92. Added some denotations for various operands. */
+
+#define PA_IMM11_AT_31 'i'
+#define PA_IMM14_AT_31 'j'
+#define PA_IMM21_AT_31 'k'
+#define PA_DISP12 'w'
+#define PA_DISP17 'W'
+
+#define N_HPPA_OPERAND_FORMATS 5
diff --git a/include/opcode/i386.h b/include/opcode/i386.h
new file mode 100644
index 00000000000..ef8fece15e1
--- /dev/null
+++ b/include/opcode/i386.h
@@ -0,0 +1,1063 @@
+/* opcode/i386.h -- Intel 80386 opcode table
+ Copyright 1989, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation.
+
+This file is part of GAS, the GNU Assembler, and GDB, the GNU Debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* The UnixWare assembler, and probably other AT&T derived ix86 Unix
+ assemblers, generate floating point instructions with reversed
+ source and destination registers in certain cases. Unfortunately,
+ gcc and possibly many other programs use this reversed syntax, so
+ we're stuck with it.
+
+ eg. `fsub %st(3),%st' results in st <- st - st(3) as expected, but
+ `fsub %st,%st(3)' results in st(3) <- st - st(3), rather than
+ the expected st(3) <- st(3) - st !
+
+ This happens with all the non-commutative arithmetic floating point
+ operations with two register operands, where the source register is
+ %st, and destination register is %st(i). Look for FloatDR below. */
+
+#ifndef UNIXWARE_COMPAT
+/* Set non-zero for broken, compatible instructions. Set to zero for
+ non-broken opcodes at your peril. gcc generates UnixWare
+ compatible instructions. */
+#define UNIXWARE_COMPAT 1
+#endif
+
+
+static const template i386_optab[] = {
+
+#define X None
+#define ReverseModrm (ReverseRegRegmem|Modrm)
+#define NoSuf (No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_dSuf|No_xSuf)
+#define b_Suf (No_wSuf|No_lSuf|No_sSuf|No_dSuf|No_xSuf)
+#define w_Suf (No_bSuf|No_lSuf|No_sSuf|No_dSuf|No_xSuf)
+#define l_Suf (No_bSuf|No_wSuf|No_sSuf|No_dSuf|No_xSuf)
+#define d_Suf (No_bSuf|No_wSuf|No_sSuf|No_lSuf|No_xSuf)
+#define x_Suf (No_bSuf|No_wSuf|No_sSuf|No_lSuf|No_dSuf)
+#define bw_Suf (No_lSuf|No_sSuf|No_dSuf|No_xSuf)
+#define bl_Suf (No_wSuf|No_sSuf|No_dSuf|No_xSuf)
+#define wl_Suf (No_bSuf|No_sSuf|No_dSuf|No_xSuf)
+#define sl_Suf (No_bSuf|No_wSuf|No_dSuf|No_xSuf)
+#define sld_Suf (No_bSuf|No_wSuf|No_xSuf)
+#define sldx_Suf (No_bSuf|No_wSuf)
+#define bwl_Suf (No_sSuf|No_dSuf|No_xSuf)
+#define bwld_Suf (No_sSuf|No_xSuf)
+#define FP (NoSuf|IgnoreSize)
+#define l_FP (l_Suf|IgnoreSize)
+#define d_FP (d_Suf|IgnoreSize)
+#define x_FP (x_Suf|IgnoreSize)
+#define sl_FP (sl_Suf|IgnoreSize)
+#define sld_FP (sld_Suf|IgnoreSize)
+#define sldx_FP (sldx_Suf|IgnoreSize)
+#if UNIXWARE_COMPAT
+#define FloatDR FloatD
+#else
+#define FloatDR (FloatD|FloatR)
+#endif
+
+/* move instructions */
+#define MOV_AX_DISP32 0xa0
+{ "mov", 2, 0xa0, X, bwl_Suf|D|W, { Disp16|Disp32, Acc, 0 } },
+{ "mov", 2, 0x88, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0 } },
+{ "mov", 2, 0xb0, X, bwl_Suf|W|ShortForm, { Imm, Reg, 0 } },
+{ "mov", 2, 0xc6, X, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0 } },
+/* The next two instructions accept WordReg so that a segment register
+ can be copied to a 32 bit register, and vice versa, without using a
+ size prefix. When moving to a 32 bit register, the upper 16 bits
+ are set to an implementation defined value (on the Pentium Pro,
+ the implementation defined value is zero). */
+{ "mov", 2, 0x8c, X, wl_Suf|Modrm, { SReg3|SReg2, WordReg|WordMem, 0 } },
+{ "mov", 2, 0x8e, X, wl_Suf|Modrm|IgnoreSize, { WordReg|WordMem, SReg3|SReg2, 0 } },
+/* move to/from control debug registers */
+{ "mov", 2, 0x0f20, X, l_Suf|D|Modrm|IgnoreSize, { Control, Reg32, 0} },
+{ "mov", 2, 0x0f21, X, l_Suf|D|Modrm|IgnoreSize, { Debug, Reg32, 0} },
+{ "mov", 2, 0x0f24, X, l_Suf|D|Modrm|IgnoreSize, { Test, Reg32, 0} },
+
+/* move with sign extend */
+/* "movsbl" & "movsbw" must not be unified into "movsb" to avoid
+ conflict with the "movs" string move instruction. */
+{"movsbl", 2, 0x0fbe, X, NoSuf|ReverseModrm, { Reg8|ByteMem, Reg32, 0} },
+{"movsbw", 2, 0x0fbe, X, NoSuf|ReverseModrm, { Reg8|ByteMem, Reg16, 0} },
+{"movswl", 2, 0x0fbf, X, NoSuf|ReverseModrm, { Reg16|ShortMem, Reg32, 0} },
+/* Intel Syntax */
+{"movsx", 2, 0x0fbf, X, w_Suf|ReverseModrm|IgnoreSize, { Reg16|ShortMem, Reg32, 0} },
+{"movsx", 2, 0x0fbe, X, b_Suf|ReverseModrm, { Reg8|ByteMem, WordReg, 0} },
+
+/* move with zero extend */
+{"movzb", 2, 0x0fb6, X, wl_Suf|ReverseModrm, { Reg8|ByteMem, WordReg, 0} },
+{"movzwl", 2, 0x0fb7, X, NoSuf|ReverseModrm, { Reg16|ShortMem, Reg32, 0} },
+/* Intel Syntax */
+{"movzx", 2, 0x0fb7, X, w_Suf|ReverseModrm|IgnoreSize, { Reg16|ShortMem, Reg32, 0} },
+{"movzx", 2, 0x0fb6, X, b_Suf|ReverseModrm, { Reg8|ByteMem, WordReg, 0} },
+
+/* push instructions */
+{"push", 1, 0x50, X, wl_Suf|ShortForm, { WordReg,0,0 } },
+{"push", 1, 0xff, 6, wl_Suf|Modrm, { WordReg|WordMem, 0, 0 } },
+{"push", 1, 0x6a, X, wl_Suf, { Imm8S, 0, 0} },
+{"push", 1, 0x68, X, wl_Suf, { Imm16|Imm32, 0, 0} },
+{"push", 1, 0x06, X, wl_Suf|Seg2ShortForm, { SReg2,0,0 } },
+{"push", 1, 0x0fa0, X, wl_Suf|Seg3ShortForm, { SReg3,0,0 } },
+/* push all */
+{"pusha", 0, 0x60, X, wl_Suf, { 0, 0, 0 } },
+
+/* pop instructions */
+{"pop", 1, 0x58, X, wl_Suf|ShortForm, { WordReg,0,0 } },
+{"pop", 1, 0x8f, 0, wl_Suf|Modrm, { WordReg|WordMem, 0, 0 } },
+#define POP_SEG_SHORT 0x07
+{"pop", 1, 0x07, X, wl_Suf|Seg2ShortForm, { SReg2,0,0 } },
+{"pop", 1, 0x0fa1, X, wl_Suf|Seg3ShortForm, { SReg3,0,0 } },
+/* pop all */
+{"popa", 0, 0x61, X, wl_Suf, { 0, 0, 0 } },
+
+/* xchg exchange instructions
+ xchg commutes: we allow both operand orders */
+{"xchg", 2, 0x90, X, wl_Suf|ShortForm, { WordReg, Acc, 0 } },
+{"xchg", 2, 0x90, X, wl_Suf|ShortForm, { Acc, WordReg, 0 } },
+{"xchg", 2, 0x86, X, bwl_Suf|W|Modrm, { Reg, Reg|AnyMem, 0 } },
+{"xchg", 2, 0x86, X, bwl_Suf|W|Modrm, { Reg|AnyMem, Reg, 0 } },
+
+/* in/out from ports */
+{"in", 2, 0xe4, X, bwl_Suf|W, { Imm8, Acc, 0 } },
+{"in", 2, 0xec, X, bwl_Suf|W, { InOutPortReg, Acc, 0 } },
+{"in", 1, 0xe4, X, bwl_Suf|W, { Imm8, 0, 0 } },
+{"in", 1, 0xec, X, bwl_Suf|W, { InOutPortReg, 0, 0 } },
+{"out", 2, 0xe6, X, bwl_Suf|W, { Acc, Imm8, 0 } },
+{"out", 2, 0xee, X, bwl_Suf|W, { Acc, InOutPortReg, 0 } },
+{"out", 1, 0xe6, X, bwl_Suf|W, { Imm8, 0, 0 } },
+{"out", 1, 0xee, X, bwl_Suf|W, { InOutPortReg, 0, 0 } },
+
+/* load effective address */
+{"lea", 2, 0x8d, X, wl_Suf|Modrm, { WordMem, WordReg, 0 } },
+
+/* load segment registers from memory */
+{"lds", 2, 0xc5, X, wl_Suf|Modrm, { WordMem, WordReg, 0} },
+{"les", 2, 0xc4, X, wl_Suf|Modrm, { WordMem, WordReg, 0} },
+{"lfs", 2, 0x0fb4, X, wl_Suf|Modrm, { WordMem, WordReg, 0} },
+{"lgs", 2, 0x0fb5, X, wl_Suf|Modrm, { WordMem, WordReg, 0} },
+{"lss", 2, 0x0fb2, X, wl_Suf|Modrm, { WordMem, WordReg, 0} },
+
+/* flags register instructions */
+{"clc", 0, 0xf8, X, NoSuf, { 0, 0, 0} },
+{"cld", 0, 0xfc, X, NoSuf, { 0, 0, 0} },
+{"cli", 0, 0xfa, X, NoSuf, { 0, 0, 0} },
+{"clts", 0, 0x0f06, X, NoSuf, { 0, 0, 0} },
+{"cmc", 0, 0xf5, X, NoSuf, { 0, 0, 0} },
+{"lahf", 0, 0x9f, X, NoSuf, { 0, 0, 0} },
+{"sahf", 0, 0x9e, X, NoSuf, { 0, 0, 0} },
+{"pushf", 0, 0x9c, X, wl_Suf, { 0, 0, 0} },
+{"popf", 0, 0x9d, X, wl_Suf, { 0, 0, 0} },
+{"stc", 0, 0xf9, X, NoSuf, { 0, 0, 0} },
+{"std", 0, 0xfd, X, NoSuf, { 0, 0, 0} },
+{"sti", 0, 0xfb, X, NoSuf, { 0, 0, 0} },
+
+/* arithmetic */
+{"add", 2, 0x00, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"add", 2, 0x83, 0, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"add", 2, 0x04, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"add", 2, 0x80, 0, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"inc", 1, 0x40, X, wl_Suf|ShortForm, { WordReg, 0, 0} },
+{"inc", 1, 0xfe, 0, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"sub", 2, 0x28, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"sub", 2, 0x83, 5, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"sub", 2, 0x2c, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"sub", 2, 0x80, 5, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"dec", 1, 0x48, X, wl_Suf|ShortForm, { WordReg, 0, 0} },
+{"dec", 1, 0xfe, 1, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"sbb", 2, 0x18, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"sbb", 2, 0x83, 3, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"sbb", 2, 0x1c, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"sbb", 2, 0x80, 3, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"cmp", 2, 0x38, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"cmp", 2, 0x83, 7, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"cmp", 2, 0x3c, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"cmp", 2, 0x80, 7, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"test", 2, 0x84, X, bwl_Suf|W|Modrm, { Reg|AnyMem, Reg, 0} },
+{"test", 2, 0x84, X, bwl_Suf|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"test", 2, 0xa8, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"test", 2, 0xf6, 0, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"and", 2, 0x20, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"and", 2, 0x83, 4, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"and", 2, 0x24, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"and", 2, 0x80, 4, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"or", 2, 0x08, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"or", 2, 0x83, 1, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"or", 2, 0x0c, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"or", 2, 0x80, 1, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"xor", 2, 0x30, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"xor", 2, 0x83, 6, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"xor", 2, 0x34, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"xor", 2, 0x80, 6, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+/* iclr with 1 operand is really xor with 2 operands. */
+{"clr", 1, 0x30, X, bwl_Suf|W|Modrm|regKludge, { Reg, 0, 0 } },
+
+{"adc", 2, 0x10, X, bwl_Suf|D|W|Modrm, { Reg, Reg|AnyMem, 0} },
+{"adc", 2, 0x83, 2, wl_Suf|Modrm, { Imm8S, WordReg|WordMem, 0} },
+{"adc", 2, 0x14, X, bwl_Suf|W, { Imm, Acc, 0} },
+{"adc", 2, 0x80, 2, bwl_Suf|W|Modrm, { Imm, Reg|AnyMem, 0} },
+
+{"neg", 1, 0xf6, 3, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+{"not", 1, 0xf6, 2, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"aaa", 0, 0x37, X, NoSuf, { 0, 0, 0} },
+{"aas", 0, 0x3f, X, NoSuf, { 0, 0, 0} },
+{"daa", 0, 0x27, X, NoSuf, { 0, 0, 0} },
+{"das", 0, 0x2f, X, NoSuf, { 0, 0, 0} },
+{"aad", 0, 0xd50a, X, NoSuf, { 0, 0, 0} },
+{"aad", 1, 0xd5, X, NoSuf, { Imm8S, 0, 0} },
+{"aam", 0, 0xd40a, X, NoSuf, { 0, 0, 0} },
+{"aam", 1, 0xd4, X, NoSuf, { Imm8S, 0, 0} },
+
+/* conversion insns */
+/* conversion: intel naming */
+{"cbw", 0, 0x98, X, NoSuf|Size16, { 0, 0, 0} },
+{"cwde", 0, 0x98, X, NoSuf|Size32, { 0, 0, 0} },
+{"cwd", 0, 0x99, X, NoSuf|Size16, { 0, 0, 0} },
+{"cdq", 0, 0x99, X, NoSuf|Size32, { 0, 0, 0} },
+/* att naming */
+{"cbtw", 0, 0x98, X, NoSuf|Size16, { 0, 0, 0} },
+{"cwtl", 0, 0x98, X, NoSuf|Size32, { 0, 0, 0} },
+{"cwtd", 0, 0x99, X, NoSuf|Size16, { 0, 0, 0} },
+{"cltd", 0, 0x99, X, NoSuf|Size32, { 0, 0, 0} },
+
+/* Warning! the mul/imul (opcode 0xf6) must only have 1 operand! They are
+ expanding 64-bit multiplies, and *cannot* be selected to accomplish
+ 'imul %ebx, %eax' (opcode 0x0faf must be used in this case)
+ These multiplies can only be selected with single operand forms. */
+{"mul", 1, 0xf6, 4, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+{"imul", 1, 0xf6, 5, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+{"imul", 2, 0x0faf, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"imul", 3, 0x6b, X, wl_Suf|ReverseModrm, { Imm8S, WordReg|WordMem, WordReg} },
+{"imul", 3, 0x69, X, wl_Suf|ReverseModrm, { Imm16|Imm32, WordReg|WordMem, WordReg} },
+/* imul with 2 operands mimics imul with 3 by putting the register in
+ both i.rm.reg & i.rm.regmem fields. regKludge enables this
+ transformation. */
+{"imul", 2, 0x6b, X, wl_Suf|Modrm|regKludge,{ Imm8S, WordReg, 0} },
+{"imul", 2, 0x69, X, wl_Suf|Modrm|regKludge,{ Imm16|Imm32, WordReg, 0} },
+
+{"div", 1, 0xf6, 6, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+{"div", 2, 0xf6, 6, bwl_Suf|W|Modrm, { Reg|AnyMem, Acc, 0} },
+{"idiv", 1, 0xf6, 7, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+{"idiv", 2, 0xf6, 7, bwl_Suf|W|Modrm, { Reg|AnyMem, Acc, 0} },
+
+{"rol", 2, 0xd0, 0, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"rol", 2, 0xc0, 0, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"rol", 2, 0xd2, 0, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"rol", 1, 0xd0, 0, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"ror", 2, 0xd0, 1, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"ror", 2, 0xc0, 1, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"ror", 2, 0xd2, 1, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"ror", 1, 0xd0, 1, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"rcl", 2, 0xd0, 2, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"rcl", 2, 0xc0, 2, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"rcl", 2, 0xd2, 2, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"rcl", 1, 0xd0, 2, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"rcr", 2, 0xd0, 3, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"rcr", 2, 0xc0, 3, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"rcr", 2, 0xd2, 3, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"rcr", 1, 0xd0, 3, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"sal", 2, 0xd0, 4, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"sal", 2, 0xc0, 4, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"sal", 2, 0xd2, 4, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"sal", 1, 0xd0, 4, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+{"shl", 2, 0xd0, 4, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"shl", 2, 0xc0, 4, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"shl", 2, 0xd2, 4, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"shl", 1, 0xd0, 4, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"shld", 3, 0x0fa4, X, wl_Suf|Modrm, { Imm8, WordReg, WordReg|WordMem} },
+{"shld", 3, 0x0fa5, X, wl_Suf|Modrm, { ShiftCount, WordReg, WordReg|WordMem} },
+{"shld", 2, 0x0fa5, X, wl_Suf|Modrm, { WordReg, WordReg|WordMem, 0} },
+
+{"shr", 2, 0xd0, 5, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"shr", 2, 0xc0, 5, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"shr", 2, 0xd2, 5, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"shr", 1, 0xd0, 5, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+{"shrd", 3, 0x0fac, X, wl_Suf|Modrm, { Imm8, WordReg, WordReg|WordMem} },
+{"shrd", 3, 0x0fad, X, wl_Suf|Modrm, { ShiftCount, WordReg, WordReg|WordMem} },
+{"shrd", 2, 0x0fad, X, wl_Suf|Modrm, { WordReg, WordReg|WordMem, 0} },
+
+{"sar", 2, 0xd0, 7, bwl_Suf|W|Modrm, { Imm1, Reg|AnyMem, 0} },
+{"sar", 2, 0xc0, 7, bwl_Suf|W|Modrm, { Imm8, Reg|AnyMem, 0} },
+{"sar", 2, 0xd2, 7, bwl_Suf|W|Modrm, { ShiftCount, Reg|AnyMem, 0} },
+{"sar", 1, 0xd0, 7, bwl_Suf|W|Modrm, { Reg|AnyMem, 0, 0} },
+
+/* control transfer instructions */
+{"call", 1, 0xe8, X, wl_Suf|JumpDword, { Disp16|Disp32, 0, 0} },
+{"call", 1, 0xff, 2, wl_Suf|Modrm, { WordReg|WordMem|JumpAbsolute, 0, 0} },
+/* Intel Syntax */
+{"call", 2, 0x9a, X, wl_Suf|JumpInterSegment, { Imm16, Imm16|Imm32, 0} },
+{"lcall", 2, 0x9a, X, wl_Suf|JumpInterSegment, { Imm16, Imm16|Imm32, 0} },
+{"lcall", 1, 0xff, 3, wl_Suf|Modrm, { WordMem, 0, 0} },
+
+#define JUMP_PC_RELATIVE 0xeb
+{"jmp", 1, 0xeb, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jmp", 1, 0xff, 4, wl_Suf|Modrm, { WordReg|WordMem|JumpAbsolute, 0, 0} },
+/* Intel Syntax */
+{"jmp", 2, 0xea, X, wl_Suf|JumpInterSegment, { Imm16, Imm16|Imm32, 0} },
+{"jmp", 1, 0xff, 5, wl_Suf|Modrm, { WordMem, 0, 0} },
+{"ljmp", 2, 0xea, X, wl_Suf|JumpInterSegment, { Imm16, Imm16|Imm32, 0} },
+{"ljmp", 1, 0xff, 5, wl_Suf|Modrm, { WordMem, 0, 0} },
+
+{"ret", 0, 0xc3, X, wl_Suf, { 0, 0, 0} },
+{"ret", 1, 0xc2, X, wl_Suf, { Imm16, 0, 0} },
+{"lret", 0, 0xcb, X, wl_Suf, { 0, 0, 0} },
+{"lret", 1, 0xca, X, wl_Suf, { Imm16, 0, 0} },
+{"enter", 2, 0xc8, X, wl_Suf, { Imm16, Imm8, 0} },
+{"leave", 0, 0xc9, X, wl_Suf, { 0, 0, 0} },
+
+/* conditional jumps */
+{"jo", 1, 0x70, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jno", 1, 0x71, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jb", 1, 0x72, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jc", 1, 0x72, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnae", 1, 0x72, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnb", 1, 0x73, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnc", 1, 0x73, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jae", 1, 0x73, X, NoSuf|Jump, { Disp, 0, 0} },
+{"je", 1, 0x74, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jz", 1, 0x74, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jne", 1, 0x75, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnz", 1, 0x75, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jbe", 1, 0x76, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jna", 1, 0x76, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnbe", 1, 0x77, X, NoSuf|Jump, { Disp, 0, 0} },
+{"ja", 1, 0x77, X, NoSuf|Jump, { Disp, 0, 0} },
+{"js", 1, 0x78, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jns", 1, 0x79, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jp", 1, 0x7a, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jpe", 1, 0x7a, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnp", 1, 0x7b, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jpo", 1, 0x7b, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jl", 1, 0x7c, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnge", 1, 0x7c, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnl", 1, 0x7d, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jge", 1, 0x7d, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jle", 1, 0x7e, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jng", 1, 0x7e, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jnle", 1, 0x7f, X, NoSuf|Jump, { Disp, 0, 0} },
+{"jg", 1, 0x7f, X, NoSuf|Jump, { Disp, 0, 0} },
+
+/* jcxz vs. jecxz is chosen on the basis of the address size prefix. */
+{"jcxz", 1, 0xe3, X, NoSuf|JumpByte|Size16, { Disp, 0, 0} },
+{"jecxz", 1, 0xe3, X, NoSuf|JumpByte|Size32, { Disp, 0, 0} },
+
+/* The loop instructions also use the address size prefix to select
+ %cx rather than %ecx for the loop count, so the `w' form of these
+ instructions emit an address size prefix rather than a data size
+ prefix. */
+{"loop", 1, 0xe2, X, wl_Suf|JumpByte, { Disp, 0, 0} },
+{"loopz", 1, 0xe1, X, wl_Suf|JumpByte, { Disp, 0, 0} },
+{"loope", 1, 0xe1, X, wl_Suf|JumpByte, { Disp, 0, 0} },
+{"loopnz", 1, 0xe0, X, wl_Suf|JumpByte, { Disp, 0, 0} },
+{"loopne", 1, 0xe0, X, wl_Suf|JumpByte, { Disp, 0, 0} },
+
+/* set byte on flag instructions */
+{"seto", 1, 0x0f90, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setno", 1, 0x0f91, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setb", 1, 0x0f92, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setc", 1, 0x0f92, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnae", 1, 0x0f92, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnb", 1, 0x0f93, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnc", 1, 0x0f93, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setae", 1, 0x0f93, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"sete", 1, 0x0f94, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setz", 1, 0x0f94, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setne", 1, 0x0f95, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnz", 1, 0x0f95, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setbe", 1, 0x0f96, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setna", 1, 0x0f96, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnbe", 1, 0x0f97, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"seta", 1, 0x0f97, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"sets", 1, 0x0f98, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setns", 1, 0x0f99, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setp", 1, 0x0f9a, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setpe", 1, 0x0f9a, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnp", 1, 0x0f9b, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setpo", 1, 0x0f9b, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setl", 1, 0x0f9c, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnge", 1, 0x0f9c, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnl", 1, 0x0f9d, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setge", 1, 0x0f9d, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setle", 1, 0x0f9e, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setng", 1, 0x0f9e, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setnle", 1, 0x0f9f, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+{"setg", 1, 0x0f9f, 0, b_Suf|Modrm, { Reg8|ByteMem, 0, 0} },
+
+/* string manipulation */
+{"cmps", 0, 0xa6, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"cmps", 2, 0xa6, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, AnyMem, 0} },
+{"scmp", 0, 0xa6, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"scmp", 2, 0xa6, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, AnyMem, 0} },
+{"ins", 0, 0x6c, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"ins", 2, 0x6c, X, bwld_Suf|W|IsString, { InOutPortReg, AnyMem|EsSeg, 0} },
+{"outs", 0, 0x6e, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"outs", 2, 0x6e, X, bwld_Suf|W|IsString, { AnyMem, InOutPortReg, 0} },
+{"lods", 0, 0xac, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"lods", 1, 0xac, X, bwld_Suf|W|IsString, { AnyMem, 0, 0} },
+{"lods", 2, 0xac, X, bwld_Suf|W|IsString, { AnyMem, Acc, 0} },
+{"slod", 0, 0xac, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"slod", 1, 0xac, X, bwld_Suf|W|IsString, { AnyMem, 0, 0} },
+{"slod", 2, 0xac, X, bwld_Suf|W|IsString, { AnyMem, Acc, 0} },
+{"movs", 0, 0xa4, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"movs", 2, 0xa4, X, bwld_Suf|W|IsString, { AnyMem, AnyMem|EsSeg, 0} },
+{"smov", 0, 0xa4, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"smov", 2, 0xa4, X, bwld_Suf|W|IsString, { AnyMem, AnyMem|EsSeg, 0} },
+{"scas", 0, 0xae, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"scas", 1, 0xae, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, 0, 0} },
+{"scas", 2, 0xae, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, Acc, 0} },
+{"ssca", 0, 0xae, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"ssca", 1, 0xae, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, 0, 0} },
+{"ssca", 2, 0xae, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, Acc, 0} },
+{"stos", 0, 0xaa, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"stos", 1, 0xaa, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, 0, 0} },
+{"stos", 2, 0xaa, X, bwld_Suf|W|IsString, { Acc, AnyMem|EsSeg, 0} },
+{"ssto", 0, 0xaa, X, bwld_Suf|W|IsString, { 0, 0, 0} },
+{"ssto", 1, 0xaa, X, bwld_Suf|W|IsString, { AnyMem|EsSeg, 0, 0} },
+{"ssto", 2, 0xaa, X, bwld_Suf|W|IsString, { Acc, AnyMem|EsSeg, 0} },
+{"xlat", 0, 0xd7, X, b_Suf|IsString, { 0, 0, 0} },
+{"xlat", 1, 0xd7, X, b_Suf|IsString, { AnyMem, 0, 0} },
+
+/* bit manipulation */
+{"bsf", 2, 0x0fbc, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"bsr", 2, 0x0fbd, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"bt", 2, 0x0fa3, X, wl_Suf|Modrm, { WordReg, WordReg|WordMem, 0} },
+{"bt", 2, 0x0fba, 4, wl_Suf|Modrm, { Imm8, WordReg|WordMem, 0} },
+{"btc", 2, 0x0fbb, X, wl_Suf|Modrm, { WordReg, WordReg|WordMem, 0} },
+{"btc", 2, 0x0fba, 7, wl_Suf|Modrm, { Imm8, WordReg|WordMem, 0} },
+{"btr", 2, 0x0fb3, X, wl_Suf|Modrm, { WordReg, WordReg|WordMem, 0} },
+{"btr", 2, 0x0fba, 6, wl_Suf|Modrm, { Imm8, WordReg|WordMem, 0} },
+{"bts", 2, 0x0fab, X, wl_Suf|Modrm, { WordReg, WordReg|WordMem, 0} },
+{"bts", 2, 0x0fba, 5, wl_Suf|Modrm, { Imm8, WordReg|WordMem, 0} },
+
+/* interrupts & op. sys insns */
+/* See gas/config/tc-i386.c for conversion of 'int $3' into the special
+ int 3 insn. */
+#define INT_OPCODE 0xcd
+#define INT3_OPCODE 0xcc
+{"int", 1, 0xcd, X, NoSuf, { Imm8, 0, 0} },
+{"int3", 0, 0xcc, X, NoSuf, { 0, 0, 0} },
+{"into", 0, 0xce, X, NoSuf, { 0, 0, 0} },
+{"iret", 0, 0xcf, X, wl_Suf, { 0, 0, 0} },
+/* i386sl, i486sl, later 486, and Pentium */
+{"rsm", 0, 0x0faa, X, NoSuf, { 0, 0, 0} },
+
+{"bound", 2, 0x62, X, wl_Suf|Modrm, { WordReg, WordMem, 0} },
+
+{"hlt", 0, 0xf4, X, NoSuf, { 0, 0, 0} },
+/* nop is actually 'xchgl %eax, %eax' */
+{"nop", 0, 0x90, X, NoSuf, { 0, 0, 0} },
+
+/* protection control */
+{"arpl", 2, 0x63, X, NoSuf|Modrm|IgnoreSize,{ Reg16, Reg16|ShortMem, 0} },
+{"lar", 2, 0x0f02, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"lgdt", 1, 0x0f01, 2, wl_Suf|Modrm, { WordMem, 0, 0} },
+{"lidt", 1, 0x0f01, 3, wl_Suf|Modrm, { WordMem, 0, 0} },
+{"lldt", 1, 0x0f00, 2, NoSuf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
+{"lmsw", 1, 0x0f01, 6, NoSuf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
+{"lsl", 2, 0x0f03, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"ltr", 1, 0x0f00, 3, NoSuf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
+
+{"sgdt", 1, 0x0f01, 0, wl_Suf|Modrm, { WordMem, 0, 0} },
+{"sidt", 1, 0x0f01, 1, wl_Suf|Modrm, { WordMem, 0, 0} },
+{"sldt", 1, 0x0f00, 0, wl_Suf|Modrm, { WordReg|WordMem, 0, 0} },
+{"smsw", 1, 0x0f01, 4, wl_Suf|Modrm, { WordReg|WordMem, 0, 0} },
+{"str", 1, 0x0f00, 1, NoSuf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
+
+{"verr", 1, 0x0f00, 4, NoSuf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
+{"verw", 1, 0x0f00, 5, NoSuf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
+
+/* floating point instructions */
+
+/* load */
+{"fld", 1, 0xd9c0, X, FP|ShortForm, { FloatReg, 0, 0} }, /* register */
+{"fld", 1, 0xd9, 0, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} }, /* %st0 <-- mem float/double */
+{"fld", 1, 0xd9c0, X, l_FP|ShortForm|Ugh, { FloatReg, 0, 0} },
+/* Intel Syntax */
+{"fld", 1, 0xdb, 5, x_FP|Modrm, { LLongMem, 0, 0} }, /* %st0 <-- mem efloat */
+{"fild", 1, 0xdf, 0, sl_Suf|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} }, /* %st0 <-- mem word(16)/dword(32) */
+/* Intel Syntax */
+{"fild", 1, 0xdf, 5, d_Suf|IgnoreSize|Modrm,{ LLongMem, 0, 0} }, /* %st0 <-- mem qword (64) */
+{"fildq", 1, 0xdf, 5, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 <-- mem qword (64) */
+{"fildll", 1, 0xdf, 5, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 <-- mem qword (64) */
+{"fldt", 1, 0xdb, 5, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 <-- mem efloat */
+{"fbld", 1, 0xdf, 4, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 <-- mem bcd */
+
+/* store (no pop) */
+{"fst", 1, 0xddd0, X, FP|ShortForm, { FloatReg, 0, 0} }, /* register */
+{"fst", 1, 0xd9, 2, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} }, /* %st0 --> mem float/double */
+{"fst", 1, 0xddd0, X, l_FP|ShortForm|Ugh, { FloatReg, 0, 0} },
+{"fist", 1, 0xdf, 2, sld_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} }, /* %st0 --> mem word(16)/dword(32) */
+
+/* store (with pop) */
+{"fstp", 1, 0xddd8, X, FP|ShortForm, { FloatReg, 0, 0} }, /* register */
+{"fstp", 1, 0xd9, 3, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} }, /* %st0 --> mem float/double */
+{"fstp", 1, 0xddd8, X, l_FP|ShortForm|Ugh, { FloatReg, 0, 0} },
+/* Intel Syntax */
+{"fstp", 1, 0xdb, 7, x_FP|Modrm, { LLongMem, 0, 0} }, /* %st0 --> mem efloat */
+{"fistp", 1, 0xdf, 3, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} }, /* %st0 --> mem word(16)/dword(32) */
+/* Intel Syntax */
+{"fistp", 1, 0xdf, 7, d_FP|Modrm, { LLongMem, 0, 0} }, /* %st0 --> mem qword (64) */
+{"fistpq", 1, 0xdf, 7, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 --> mem qword (64) */
+{"fistpll",1, 0xdf, 7, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 --> mem qword (64) */
+{"fstpt", 1, 0xdb, 7, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 --> mem efloat */
+{"fbstp", 1, 0xdf, 6, FP|Modrm, { LLongMem, 0, 0} }, /* %st0 --> mem bcd */
+
+/* exchange %st<n> with %st0 */
+{"fxch", 1, 0xd9c8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fxch", 0, 0xd9c9, X, FP, { 0, 0, 0} }, /* alias for fxch %st(1) */
+
+/* comparison (without pop) */
+{"fcom", 1, 0xd8d0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fcom", 0, 0xd8d1, X, FP, { 0, 0, 0} }, /* alias for fcom %st(1) */
+{"fcom", 1, 0xd8, 2, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} }, /* compare %st0, mem float/double */
+{"fcom", 1, 0xd8d0, X, l_FP|ShortForm|Ugh, { FloatReg, 0, 0} },
+{"ficom", 1, 0xde, 2, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} }, /* compare %st0, mem word/dword */
+
+/* comparison (with pop) */
+{"fcomp", 1, 0xd8d8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fcomp", 0, 0xd8d9, X, FP, { 0, 0, 0} }, /* alias for fcomp %st(1) */
+{"fcomp", 1, 0xd8, 3, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} }, /* compare %st0, mem float/double */
+{"fcomp", 1, 0xd8d8, X, l_FP|ShortForm|Ugh, { FloatReg, 0, 0} },
+{"ficomp", 1, 0xde, 3, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} }, /* compare %st0, mem word/dword */
+{"fcompp", 0, 0xded9, X, FP, { 0, 0, 0} }, /* compare %st0, %st1 & pop 2 */
+
+/* unordered comparison (with pop) */
+{"fucom", 1, 0xdde0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fucom", 0, 0xdde1, X, FP, { 0, 0, 0} }, /* alias for fucom %st(1) */
+{"fucomp", 1, 0xdde8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fucomp", 0, 0xdde9, X, FP, { 0, 0, 0} }, /* alias for fucomp %st(1) */
+{"fucompp",0, 0xdae9, X, FP, { 0, 0, 0} }, /* ucompare %st0, %st1 & pop twice */
+
+{"ftst", 0, 0xd9e4, X, FP, { 0, 0, 0} }, /* test %st0 */
+{"fxam", 0, 0xd9e5, X, FP, { 0, 0, 0} }, /* examine %st0 */
+
+/* load constants into %st0 */
+{"fld1", 0, 0xd9e8, X, FP, { 0, 0, 0} }, /* %st0 <-- 1.0 */
+{"fldl2t", 0, 0xd9e9, X, FP, { 0, 0, 0} }, /* %st0 <-- log2(10) */
+{"fldl2e", 0, 0xd9ea, X, FP, { 0, 0, 0} }, /* %st0 <-- log2(e) */
+{"fldpi", 0, 0xd9eb, X, FP, { 0, 0, 0} }, /* %st0 <-- pi */
+{"fldlg2", 0, 0xd9ec, X, FP, { 0, 0, 0} }, /* %st0 <-- log10(2) */
+{"fldln2", 0, 0xd9ed, X, FP, { 0, 0, 0} }, /* %st0 <-- ln(2) */
+{"fldz", 0, 0xd9ee, X, FP, { 0, 0, 0} }, /* %st0 <-- 0.0 */
+
+/* arithmetic */
+
+/* add */
+{"fadd", 2, 0xd8c0, X, FP|ShortForm|FloatD, { FloatReg, FloatAcc, 0} },
+{"fadd", 1, 0xd8c0, X, FP|ShortForm, { FloatReg, 0, 0} }, /* alias for fadd %st(i), %st */
+#if UNIXWARE_COMPAT
+{"fadd", 0, 0xdec1, X, FP|Ugh, { 0, 0, 0} }, /* alias for faddp */
+#endif
+{"fadd", 1, 0xd8, 0, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} },
+{"fiadd", 1, 0xde, 0, sld_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
+
+{"faddp", 2, 0xdec0, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"faddp", 1, 0xdec0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"faddp", 0, 0xdec1, X, FP, { 0, 0, 0} }, /* alias for faddp %st, %st(1) */
+{"faddp", 2, 0xdec0, X, FP|ShortForm|Ugh, { FloatReg, FloatAcc, 0} },
+
+/* subtract */
+{"fsub", 2, 0xd8e0, X, FP|ShortForm|FloatDR, { FloatReg, FloatAcc, 0} },
+{"fsub", 1, 0xd8e0, X, FP|ShortForm, { FloatReg, 0, 0} },
+#if UNIXWARE_COMPAT
+{"fsub", 0, 0xdee1, X, FP|Ugh, { 0, 0, 0} }, /* alias for fsubp */
+#endif
+{"fsub", 1, 0xd8, 4, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} },
+{"fisub", 1, 0xde, 4, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
+
+#if UNIXWARE_COMPAT
+{"fsubp", 2, 0xdee0, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fsubp", 1, 0xdee0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fsubp", 0, 0xdee1, X, FP, { 0, 0, 0} },
+{"fsubp", 2, 0xdee0, X, FP|ShortForm|Ugh, { FloatReg, FloatAcc, 0} },
+#else
+{"fsubp", 2, 0xdee8, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fsubp", 1, 0xdee8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fsubp", 0, 0xdee9, X, FP, { 0, 0, 0} },
+#endif
+
+/* subtract reverse */
+{"fsubr", 2, 0xd8e8, X, FP|ShortForm|FloatDR, { FloatReg, FloatAcc, 0} },
+{"fsubr", 1, 0xd8e8, X, FP|ShortForm, { FloatReg, 0, 0} },
+#if UNIXWARE_COMPAT
+{"fsubr", 0, 0xdee9, X, FP|Ugh, { 0, 0, 0} }, /* alias for fsubrp */
+#endif
+{"fsubr", 1, 0xd8, 5, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} },
+{"fisubr", 1, 0xde, 5, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
+
+#if UNIXWARE_COMPAT
+{"fsubrp", 2, 0xdee8, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fsubrp", 1, 0xdee8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fsubrp", 0, 0xdee9, X, FP, { 0, 0, 0} },
+{"fsubrp", 2, 0xdee8, X, FP|ShortForm|Ugh, { FloatReg, FloatAcc, 0} },
+#else
+{"fsubrp", 2, 0xdee0, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fsubrp", 1, 0xdee0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fsubrp", 0, 0xdee1, X, FP, { 0, 0, 0} },
+#endif
+
+/* multiply */
+{"fmul", 2, 0xd8c8, X, FP|ShortForm|FloatD, { FloatReg, FloatAcc, 0} },
+{"fmul", 1, 0xd8c8, X, FP|ShortForm, { FloatReg, 0, 0} },
+#if UNIXWARE_COMPAT
+{"fmul", 0, 0xdec9, X, FP|Ugh, { 0, 0, 0} }, /* alias for fmulp */
+#endif
+{"fmul", 1, 0xd8, 1, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} },
+{"fimul", 1, 0xde, 1, sld_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
+
+{"fmulp", 2, 0xdec8, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fmulp", 1, 0xdec8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fmulp", 0, 0xdec9, X, FP, { 0, 0, 0} },
+{"fmulp", 2, 0xdec8, X, FP|ShortForm|Ugh, { FloatReg, FloatAcc, 0} },
+
+/* divide */
+{"fdiv", 2, 0xd8f0, X, FP|ShortForm|FloatDR, { FloatReg, FloatAcc, 0} },
+{"fdiv", 1, 0xd8f0, X, FP|ShortForm, { FloatReg, 0, 0} },
+#if UNIXWARE_COMPAT
+{"fdiv", 0, 0xdef1, X, FP|Ugh, { 0, 0, 0} }, /* alias for fdivp */
+#endif
+{"fdiv", 1, 0xd8, 6, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} },
+{"fidiv", 1, 0xde, 6, sld_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
+
+#if UNIXWARE_COMPAT
+{"fdivp", 2, 0xdef0, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fdivp", 1, 0xdef0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fdivp", 0, 0xdef1, X, FP, { 0, 0, 0} },
+{"fdivp", 2, 0xdef0, X, FP|ShortForm|Ugh, { FloatReg, FloatAcc, 0} },
+#else
+{"fdivp", 2, 0xdef8, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fdivp", 1, 0xdef8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fdivp", 0, 0xdef9, X, FP, { 0, 0, 0} },
+#endif
+
+/* divide reverse */
+{"fdivr", 2, 0xd8f8, X, FP|ShortForm|FloatDR, { FloatReg, FloatAcc, 0} },
+{"fdivr", 1, 0xd8f8, X, FP|ShortForm, { FloatReg, 0, 0} },
+#if UNIXWARE_COMPAT
+{"fdivr", 0, 0xdef9, X, FP|Ugh, { 0, 0, 0} }, /* alias for fdivrp */
+#endif
+{"fdivr", 1, 0xd8, 7, sld_FP|FloatMF|Modrm, { LongMem|LLongMem, 0, 0} },
+{"fidivr", 1, 0xde, 7, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
+
+#if UNIXWARE_COMPAT
+{"fdivrp", 2, 0xdef8, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fdivrp", 1, 0xdef8, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fdivrp", 0, 0xdef9, X, FP, { 0, 0, 0} },
+{"fdivrp", 2, 0xdef8, X, FP|ShortForm|Ugh, { FloatReg, FloatAcc, 0} },
+#else
+{"fdivrp", 2, 0xdef0, X, FP|ShortForm, { FloatAcc, FloatReg, 0} },
+{"fdivrp", 1, 0xdef0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fdivrp", 0, 0xdef1, X, FP, { 0, 0, 0} },
+#endif
+
+{"f2xm1", 0, 0xd9f0, X, FP, { 0, 0, 0} },
+{"fyl2x", 0, 0xd9f1, X, FP, { 0, 0, 0} },
+{"fptan", 0, 0xd9f2, X, FP, { 0, 0, 0} },
+{"fpatan", 0, 0xd9f3, X, FP, { 0, 0, 0} },
+{"fxtract",0, 0xd9f4, X, FP, { 0, 0, 0} },
+{"fprem1", 0, 0xd9f5, X, FP, { 0, 0, 0} },
+{"fdecstp",0, 0xd9f6, X, FP, { 0, 0, 0} },
+{"fincstp",0, 0xd9f7, X, FP, { 0, 0, 0} },
+{"fprem", 0, 0xd9f8, X, FP, { 0, 0, 0} },
+{"fyl2xp1",0, 0xd9f9, X, FP, { 0, 0, 0} },
+{"fsqrt", 0, 0xd9fa, X, FP, { 0, 0, 0} },
+{"fsincos",0, 0xd9fb, X, FP, { 0, 0, 0} },
+{"frndint",0, 0xd9fc, X, FP, { 0, 0, 0} },
+{"fscale", 0, 0xd9fd, X, FP, { 0, 0, 0} },
+{"fsin", 0, 0xd9fe, X, FP, { 0, 0, 0} },
+{"fcos", 0, 0xd9ff, X, FP, { 0, 0, 0} },
+{"fchs", 0, 0xd9e0, X, FP, { 0, 0, 0} },
+{"fabs", 0, 0xd9e1, X, FP, { 0, 0, 0} },
+
+/* processor control */
+{"fninit", 0, 0xdbe3, X, FP, { 0, 0, 0} },
+{"finit", 0, 0xdbe3, X, FP|FWait, { 0, 0, 0} },
+{"fldcw", 1, 0xd9, 5, FP|Modrm, { ShortMem, 0, 0} },
+{"fnstcw", 1, 0xd9, 7, FP|Modrm, { ShortMem, 0, 0} },
+{"fstcw", 1, 0xd9, 7, FP|FWait|Modrm, { ShortMem, 0, 0} },
+{"fnstsw", 1, 0xdfe0, X, FP, { Acc, 0, 0} },
+{"fnstsw", 1, 0xdd, 7, FP|Modrm, { ShortMem, 0, 0} },
+{"fnstsw", 0, 0xdfe0, X, FP, { 0, 0, 0} },
+{"fstsw", 1, 0xdfe0, X, FP|FWait, { Acc, 0, 0} },
+{"fstsw", 1, 0xdd, 7, FP|FWait|Modrm, { ShortMem, 0, 0} },
+{"fstsw", 0, 0xdfe0, X, FP|FWait, { 0, 0, 0} },
+{"fnclex", 0, 0xdbe2, X, FP, { 0, 0, 0} },
+{"fclex", 0, 0xdbe2, X, FP|FWait, { 0, 0, 0} },
+/* Short forms of fldenv, fstenv use data size prefix.
+ FIXME: Are these the right suffixes? */
+{"fnstenv",1, 0xd9, 6, sl_Suf|Modrm, { LLongMem, 0, 0} },
+{"fstenv", 1, 0xd9, 6, sl_Suf|FWait|Modrm, { LLongMem, 0, 0} },
+{"fldenv", 1, 0xd9, 4, sl_Suf|Modrm, { LLongMem, 0, 0} },
+{"fnsave", 1, 0xdd, 6, sl_Suf|Modrm, { LLongMem, 0, 0} },
+{"fsave", 1, 0xdd, 6, sl_Suf|FWait|Modrm, { LLongMem, 0, 0} },
+{"frstor", 1, 0xdd, 4, sl_Suf|Modrm, { LLongMem, 0, 0} },
+
+{"ffree", 1, 0xddc0, X, FP|ShortForm, { FloatReg, 0, 0} },
+/* P6:free st(i), pop st */
+{"ffreep", 1, 0xdfc0, X, FP|ShortForm, { FloatReg, 0, 0} },
+{"fnop", 0, 0xd9d0, X, FP, { 0, 0, 0} },
+#define FWAIT_OPCODE 0x9b
+{"fwait", 0, 0x9b, X, FP, { 0, 0, 0} },
+
+/*
+ opcode prefixes; we allow them as seperate insns too
+*/
+#define ADDR_PREFIX_OPCODE 0x67
+{"addr16", 0, 0x67, X, NoSuf|IsPrefix|Size16|IgnoreSize, { 0, 0, 0} },
+{"addr32", 0, 0x67, X, NoSuf|IsPrefix|Size32|IgnoreSize, { 0, 0, 0} },
+{"aword", 0, 0x67, X, NoSuf|IsPrefix|Size16|IgnoreSize, { 0, 0, 0} },
+{"adword", 0, 0x67, X, NoSuf|IsPrefix|Size32|IgnoreSize, { 0, 0, 0} },
+#define DATA_PREFIX_OPCODE 0x66
+{"data16", 0, 0x66, X, NoSuf|IsPrefix|Size16|IgnoreSize, { 0, 0, 0} },
+{"data32", 0, 0x66, X, NoSuf|IsPrefix|Size32|IgnoreSize, { 0, 0, 0} },
+{"word", 0, 0x66, X, NoSuf|IsPrefix|Size16|IgnoreSize, { 0, 0, 0} },
+{"dword", 0, 0x66, X, NoSuf|IsPrefix|Size32|IgnoreSize, { 0, 0, 0} },
+#define LOCK_PREFIX_OPCODE 0xf0
+{"lock", 0, 0xf0, X, NoSuf|IsPrefix, { 0, 0, 0} },
+{"wait", 0, 0x9b, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define CS_PREFIX_OPCODE 0x2e
+{"cs", 0, 0x2e, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define DS_PREFIX_OPCODE 0x3e
+{"ds", 0, 0x3e, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define ES_PREFIX_OPCODE 0x26
+{"es", 0, 0x26, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define FS_PREFIX_OPCODE 0x64
+{"fs", 0, 0x64, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define GS_PREFIX_OPCODE 0x65
+{"gs", 0, 0x65, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define SS_PREFIX_OPCODE 0x36
+{"ss", 0, 0x36, X, NoSuf|IsPrefix, { 0, 0, 0} },
+#define REPNE_PREFIX_OPCODE 0xf2
+#define REPE_PREFIX_OPCODE 0xf3
+{"rep", 0, 0xf3, X, NoSuf|IsPrefix, { 0, 0, 0} },
+{"repe", 0, 0xf3, X, NoSuf|IsPrefix, { 0, 0, 0} },
+{"repz", 0, 0xf3, X, NoSuf|IsPrefix, { 0, 0, 0} },
+{"repne", 0, 0xf2, X, NoSuf|IsPrefix, { 0, 0, 0} },
+{"repnz", 0, 0xf2, X, NoSuf|IsPrefix, { 0, 0, 0} },
+
+/* 486 extensions */
+
+{"bswap", 1, 0x0fc8, X, NoSuf|ShortForm, { Reg32,0,0 } },
+{"xadd", 2, 0x0fc0, X, bwl_Suf|W|Modrm, { Reg, Reg|AnyMem, 0 } },
+{"cmpxchg", 2, 0x0fb0, X, bwl_Suf|W|Modrm, { Reg, Reg|AnyMem, 0 } },
+{"invd", 0, 0x0f08, X, NoSuf, { 0, 0, 0} },
+{"wbinvd", 0, 0x0f09, X, NoSuf, { 0, 0, 0} },
+{"invlpg", 1, 0x0f01, 7, NoSuf|Modrm, { AnyMem, 0, 0} },
+
+/* 586 and late 486 extensions */
+{"cpuid", 0, 0x0fa2, X, NoSuf, { 0, 0, 0} },
+
+/* Pentium extensions */
+{"wrmsr", 0, 0x0f30, X, NoSuf, { 0, 0, 0} },
+{"rdtsc", 0, 0x0f31, X, NoSuf, { 0, 0, 0} },
+{"rdmsr", 0, 0x0f32, X, NoSuf, { 0, 0, 0} },
+{"cmpxchg8b",1,0x0fc7, 1, NoSuf|Modrm, { LLongMem, 0, 0} },
+{"sysenter", 0, 0x0f34, X, NoSuf, { 0, 0, 0} },
+{"sysexit", 0, 0x0f35, X, NoSuf, { 0, 0, 0} },
+{"fxsave", 1, 0x0fae, 0, FP|Modrm, { LLongMem, 0, 0} },
+{"fxrstor", 1, 0x0fae, 1, FP|Modrm, { LLongMem, 0, 0} },
+
+/* Pentium Pro extensions */
+{"rdpmc", 0, 0x0f33, X, NoSuf, { 0, 0, 0} },
+
+{"ud2", 0, 0x0f0b, X, NoSuf, { 0, 0, 0} }, /* official undefined instr. */
+{"ud2a", 0, 0x0f0b, X, NoSuf, { 0, 0, 0} }, /* alias for ud2 */
+{"ud2b", 0, 0x0fb9, X, NoSuf, { 0, 0, 0} }, /* 2nd. official undefined instr. */
+
+{"cmovo", 2, 0x0f40, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovno", 2, 0x0f41, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovb", 2, 0x0f42, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovc", 2, 0x0f42, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnae", 2, 0x0f42, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovae", 2, 0x0f43, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnc", 2, 0x0f43, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnb", 2, 0x0f43, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmove", 2, 0x0f44, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovz", 2, 0x0f44, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovne", 2, 0x0f45, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnz", 2, 0x0f45, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovbe", 2, 0x0f46, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovna", 2, 0x0f46, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmova", 2, 0x0f47, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnbe", 2, 0x0f47, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovs", 2, 0x0f48, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovns", 2, 0x0f49, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovp", 2, 0x0f4a, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnp", 2, 0x0f4b, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovl", 2, 0x0f4c, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnge", 2, 0x0f4c, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovge", 2, 0x0f4d, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnl", 2, 0x0f4d, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovle", 2, 0x0f4e, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovng", 2, 0x0f4e, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovg", 2, 0x0f4f, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+{"cmovnle", 2, 0x0f4f, X, wl_Suf|ReverseModrm, { WordReg|WordMem, WordReg, 0} },
+
+{"fcmovb", 2, 0xdac0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovnae",2, 0xdac0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmove", 2, 0xdac8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovbe", 2, 0xdad0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovna", 2, 0xdad0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovu", 2, 0xdad8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovae", 2, 0xdbc0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovnb", 2, 0xdbc0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovne", 2, 0xdbc8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmova", 2, 0xdbd0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovnbe",2, 0xdbd0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcmovnu", 2, 0xdbd8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+
+{"fcomi", 2, 0xdbf0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcomi", 0, 0xdbf1, X, NoSuf|ShortForm, { 0, 0, 0} },
+{"fcomi", 1, 0xdbf0, X, NoSuf|ShortForm, { FloatReg, 0, 0} },
+{"fucomi", 2, 0xdbe8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fucomi", 0, 0xdbe9, X, NoSuf|ShortForm, { 0, 0, 0} },
+{"fucomi", 1, 0xdbe8, X, NoSuf|ShortForm, { FloatReg, 0, 0} },
+{"fcomip", 2, 0xdff0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcompi", 2, 0xdff0, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fcompi", 0, 0xdff1, X, NoSuf|ShortForm, { 0, 0, 0} },
+{"fcompi", 1, 0xdff0, X, NoSuf|ShortForm, { FloatReg, 0, 0} },
+{"fucomip", 2, 0xdfe8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fucompi", 2, 0xdfe8, X, NoSuf|ShortForm, { FloatReg, FloatAcc, 0} },
+{"fucompi", 0, 0xdfe9, X, NoSuf|ShortForm, { 0, 0, 0} },
+{"fucompi", 1, 0xdfe8, X, NoSuf|ShortForm, { FloatReg, 0, 0} },
+
+/* MMX instructions. */
+
+{"emms", 0, 0x0f77, X, NoSuf, { 0, 0, 0 } },
+{"movd", 2, 0x0f6e, X, NoSuf|Modrm, { Reg32|LongMem, RegMMX, 0 } },
+{"movd", 2, 0x0f7e, X, NoSuf|Modrm, { RegMMX, Reg32|LongMem, 0 } },
+{"movq", 2, 0x0f6f, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"movq", 2, 0x0f7f, X, NoSuf|Modrm, { RegMMX, RegMMX|LongMem, 0 } },
+{"packssdw", 2, 0x0f6b, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"packsswb", 2, 0x0f63, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"packuswb", 2, 0x0f67, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddb", 2, 0x0ffc, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddw", 2, 0x0ffd, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddd", 2, 0x0ffe, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddsb", 2, 0x0fec, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddsw", 2, 0x0fed, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddusb", 2, 0x0fdc, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"paddusw", 2, 0x0fdd, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pand", 2, 0x0fdb, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pandn", 2, 0x0fdf, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pcmpeqb", 2, 0x0f74, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pcmpeqw", 2, 0x0f75, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pcmpeqd", 2, 0x0f76, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pcmpgtb", 2, 0x0f64, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pcmpgtw", 2, 0x0f65, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pcmpgtd", 2, 0x0f66, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pmaddwd", 2, 0x0ff5, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pmulhw", 2, 0x0fe5, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pmullw", 2, 0x0fd5, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"por", 2, 0x0feb, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psllw", 2, 0x0ff1, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psllw", 2, 0x0f71, 6, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"pslld", 2, 0x0ff2, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pslld", 2, 0x0f72, 6, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psllq", 2, 0x0ff3, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psllq", 2, 0x0f73, 6, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psraw", 2, 0x0fe1, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psraw", 2, 0x0f71, 4, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psrad", 2, 0x0fe2, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psrad", 2, 0x0f72, 4, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psrlw", 2, 0x0fd1, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psrlw", 2, 0x0f71, 2, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psrld", 2, 0x0fd2, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psrld", 2, 0x0f72, 2, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psrlq", 2, 0x0fd3, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psrlq", 2, 0x0f73, 2, NoSuf|Modrm, { Imm8, RegMMX, 0 } },
+{"psubb", 2, 0x0ff8, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psubw", 2, 0x0ff9, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psubd", 2, 0x0ffa, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psubsb", 2, 0x0fe8, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psubsw", 2, 0x0fe9, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psubusb", 2, 0x0fd8, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"psubusw", 2, 0x0fd9, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"punpckhbw",2, 0x0f68, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"punpckhwd",2, 0x0f69, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"punpckhdq",2, 0x0f6a, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"punpcklbw",2, 0x0f60, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"punpcklwd",2, 0x0f61, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"punpckldq",2, 0x0f62, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pxor", 2, 0x0fef, X, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+
+
+/* AMD 3DNow! instructions */
+#define AMD_3DNOW_OPCODE 0x0f0f
+
+{"prefetch", 1, 0x0f0d, 0, NoSuf|Modrm, { ByteMem, 0, 0 } },
+{"prefetchw",1, 0x0f0d, 1, NoSuf|Modrm, { ByteMem, 0, 0 } },
+{"femms", 0, 0x0f0e, X, NoSuf, { 0, 0, 0 } },
+{"pavgusb", 2, 0x0f0f, 0xbf, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pf2id", 2, 0x0f0f, 0x1d, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfacc", 2, 0x0f0f, 0xae, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfadd", 2, 0x0f0f, 0x9e, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfcmpeq", 2, 0x0f0f, 0xb0, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfcmpge", 2, 0x0f0f, 0x90, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfcmpgt", 2, 0x0f0f, 0xa0, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfmax", 2, 0x0f0f, 0xa4, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfmin", 2, 0x0f0f, 0x94, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfmul", 2, 0x0f0f, 0xb4, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfrcp", 2, 0x0f0f, 0x96, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfrcpit1", 2, 0x0f0f, 0xa6, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfrcpit2", 2, 0x0f0f, 0xb6, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfrsqit1", 2, 0x0f0f, 0xa7, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfrsqrt", 2, 0x0f0f, 0x97, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfsub", 2, 0x0f0f, 0x9a, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pfsubr", 2, 0x0f0f, 0xaa, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pi2fd", 2, 0x0f0f, 0x0d, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+{"pmulhrw", 2, 0x0f0f, 0xb7, NoSuf|Modrm, { RegMMX|LongMem, RegMMX, 0 } },
+
+{NULL, 0, 0, 0, 0, { 0, 0, 0} } /* sentinel */
+};
+#undef X
+#undef ReverseModrm
+#undef NoSuf
+#undef b_Suf
+#undef w_Suf
+#undef l_Suf
+#undef bw_Suf
+#undef bl_Suf
+#undef wl_Suf
+#undef sl_Suf
+#undef bwl_Suf
+#undef FP
+#undef l_FP
+#undef sl_FP
+
+#define MAX_MNEM_SIZE 16 /* for parsing insn mnemonics from input */
+
+
+/* 386 register table */
+
+static const reg_entry i386_regtab[] = {
+ /* 8 bit regs */
+ {"al", Reg8|Acc, 0},
+ {"cl", Reg8|ShiftCount, 1},
+ {"dl", Reg8, 2},
+ {"bl", Reg8, 3},
+ {"ah", Reg8, 4},
+ {"ch", Reg8, 5},
+ {"dh", Reg8, 6},
+ {"bh", Reg8, 7},
+ /* 16 bit regs */
+ {"ax", Reg16|Acc, 0},
+ {"cx", Reg16, 1},
+ {"dx", Reg16|InOutPortReg, 2},
+ {"bx", Reg16|BaseIndex, 3},
+ {"sp", Reg16, 4},
+ {"bp", Reg16|BaseIndex, 5},
+ {"si", Reg16|BaseIndex, 6},
+ {"di", Reg16|BaseIndex, 7},
+ /* 32 bit regs */
+ {"eax", Reg32|BaseIndex|Acc, 0},
+ {"ecx", Reg32|BaseIndex, 1},
+ {"edx", Reg32|BaseIndex, 2},
+ {"ebx", Reg32|BaseIndex, 3},
+ {"esp", Reg32, 4},
+ {"ebp", Reg32|BaseIndex, 5},
+ {"esi", Reg32|BaseIndex, 6},
+ {"edi", Reg32|BaseIndex, 7},
+ /* segment registers */
+ {"es", SReg2, 0},
+ {"cs", SReg2, 1},
+ {"ss", SReg2, 2},
+ {"ds", SReg2, 3},
+ {"fs", SReg3, 4},
+ {"gs", SReg3, 5},
+ /* control registers */
+ {"cr0", Control, 0},
+ {"cr1", Control, 1},
+ {"cr2", Control, 2},
+ {"cr3", Control, 3},
+ {"cr4", Control, 4},
+ {"cr5", Control, 5},
+ {"cr6", Control, 6},
+ {"cr7", Control, 7},
+ /* debug registers */
+ {"db0", Debug, 0},
+ {"db1", Debug, 1},
+ {"db2", Debug, 2},
+ {"db3", Debug, 3},
+ {"db4", Debug, 4},
+ {"db5", Debug, 5},
+ {"db6", Debug, 6},
+ {"db7", Debug, 7},
+ {"dr0", Debug, 0},
+ {"dr1", Debug, 1},
+ {"dr2", Debug, 2},
+ {"dr3", Debug, 3},
+ {"dr4", Debug, 4},
+ {"dr5", Debug, 5},
+ {"dr6", Debug, 6},
+ {"dr7", Debug, 7},
+ /* test registers */
+ {"tr0", Test, 0},
+ {"tr1", Test, 1},
+ {"tr2", Test, 2},
+ {"tr3", Test, 3},
+ {"tr4", Test, 4},
+ {"tr5", Test, 5},
+ {"tr6", Test, 6},
+ {"tr7", Test, 7},
+ /* float registers */
+ {"st(0)", FloatReg|FloatAcc, 0},
+ {"st", FloatReg|FloatAcc, 0},
+ {"st(1)", FloatReg, 1},
+ {"st(2)", FloatReg, 2},
+ {"st(3)", FloatReg, 3},
+ {"st(4)", FloatReg, 4},
+ {"st(5)", FloatReg, 5},
+ {"st(6)", FloatReg, 6},
+ {"st(7)", FloatReg, 7},
+ {"mm0", RegMMX, 0},
+ {"mm1", RegMMX, 1},
+ {"mm2", RegMMX, 2},
+ {"mm3", RegMMX, 3},
+ {"mm4", RegMMX, 4},
+ {"mm5", RegMMX, 5},
+ {"mm6", RegMMX, 6},
+ {"mm7", RegMMX, 7}
+};
+
+#define MAX_REG_NAME_SIZE 8 /* for parsing register names from input */
+
+/* segment stuff */
+static const seg_entry cs = { "cs", 0x2e };
+static const seg_entry ds = { "ds", 0x3e };
+static const seg_entry ss = { "ss", 0x36 };
+static const seg_entry es = { "es", 0x26 };
+static const seg_entry fs = { "fs", 0x64 };
+static const seg_entry gs = { "gs", 0x65 };
+
+/* end of opcode/i386.h */
diff --git a/include/opcode/i860.h b/include/opcode/i860.h
new file mode 100644
index 00000000000..b6ebd25c648
--- /dev/null
+++ b/include/opcode/i860.h
@@ -0,0 +1,491 @@
+/* Table of opcodes for the i860.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler.
+
+GAS/GDB 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 1, or (at your option)
+any later version.
+
+GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if !defined(__STDC__) && !defined(const)
+#define const
+#endif
+
+/*
+ * Structure of an opcode table entry.
+ */
+struct i860_opcode
+{
+ const char *name;
+ unsigned long match; /* Bits that must be set. */
+ unsigned long lose; /* Bits that must not be set. */
+ const char *args;
+ /* Nonzero if this is a possible expand-instruction. */
+ char expand;
+};
+
+enum expand_type
+{
+ E_MOV = 1, E_ADDR, E_U32, E_AND, E_S32, E_DELAY
+};
+
+/*
+ All i860 opcodes are 32 bits, except for the pseudoinstructions
+ and the operations utilizing a 32-bit address expression, an
+ unsigned 32-bit constant, or a signed 32-bit constant.
+ These opcodes are expanded into a two-instruction sequence for
+ any situation where the immediate operand does not fit in 32 bits.
+ In the case of the add and subtract operations the expansion is
+ to a three-instruction sequence (ex: orh, or, adds). In cases
+ where the address is to be relocated, the instruction is
+ expanded to handle the worse case, this could be optimized at
+ the final link if the actual address were known.
+
+ The pseudoinstructions are: mov, fmov, pmov, nop, and fnop.
+ These instructions are implemented as a one or two instruction
+ sequence of other operations.
+
+ The match component is a mask saying which bits must match a
+ particular opcode in order for an instruction to be an instance
+ of that opcode.
+
+ The args component is a string containing one character
+ for each operand of the instruction.
+
+Kinds of operands:
+ # Number used by optimizer. It is ignored.
+ 1 src1 integer register.
+ 2 src2 integer register.
+ d dest register.
+ c ctrlreg control register.
+ i 16 bit immediate.
+ I 16 bit immediate, aligned.
+ 5 5 bit immediate.
+ l lbroff 26 bit PC relative immediate.
+ r sbroff 16 bit PC relative immediate.
+ s split 16 bit immediate.
+ S split 16 bit immediate, aligned.
+ e src1 floating point register.
+ f src2 floating point register.
+ g dest floating point register.
+
+*/
+
+/* The order of the opcodes in this table is significant:
+
+ * The assembler requires that all instances of the same mnemonic must be
+ consecutive. If they aren't, the assembler will bomb at runtime.
+
+ * The disassembler should not care about the order of the opcodes. */
+
+static struct i860_opcode i860_opcodes[] =
+{
+
+/* REG-Format Instructions */
+{ "ld.c", 0x30000000, 0xcc000000, "c,d", 0 }, /* ld.c csrc2,idest */
+{ "ld.b", 0x00000000, 0xfc000000, "1(2),d", 0 }, /* ld.b isrc1(isrc2),idest */
+{ "ld.b", 0x04000000, 0xf8000000, "I(2),d", E_ADDR }, /* ld.b #const(isrc2),idest */
+{ "ld.s", 0x10000000, 0xec000001, "1(2),d", 0 }, /* ld.s isrc1(isrc2),idest */
+{ "ld.s", 0x14000001, 0xe8000000, "I(2),d", E_ADDR }, /* ld.s #const(isrc2),idest */
+{ "ld.l", 0x10000001, 0xec000000, "1(2),d", 0 }, /* ld.l isrc1(isrc2),idest */
+{ "ld.l", 0x14000001, 0xe8000000, "I(2),d", E_ADDR }, /* ld.l #const(isrc2),idest */
+
+{ "st.c", 0x38000000, 0xc4000000, "1,c", 0 }, /* st.c isrc1ni,csrc2 */
+{ "st.b", 0x0c000000, 0xf0000000, "1,S(2)", E_ADDR }, /* st.b isrc1ni,#const(isrc2) */
+{ "st.s", 0x1c000000, 0xe0000000, "1,S(2)", E_ADDR }, /* st.s isrc1ni,#const(isrc2) */
+{ "st.l", 0x1c000001, 0xe0000000, "1,S(2)", E_ADDR }, /* st.l isrc1ni,#const(isrc2) */
+
+{ "ixfr", 0x08000000, 0xf4000000, "1,g", 0 }, /* ixfr isrc1ni,fdest */
+
+{ "fld.l", 0x20000002, 0xdc000001, "1(2),g", 0 }, /* fld.l isrc1(isrc2),fdest */
+{ "fld.l", 0x24000002, 0xd8000001, "i(2),g", E_ADDR }, /* fld.l #const(isrc2),fdest */
+{ "fld.l", 0x20000003, 0xdc000000, "1(2)++,g", 0 }, /* fld.l isrc1(isrc2)++,fdest */
+{ "fld.l", 0x24000003, 0xd8000000, "i(2)++,g", E_ADDR }, /* fld.l #const(isrc2)++,fdest */
+{ "fld.d", 0x20000000, 0xdc000007, "1(2),g", 0 }, /* fld.d isrc1(isrc2),fdest */
+{ "fld.d", 0x24000000, 0xd8000007, "i(2),g", E_ADDR }, /* fld.d #const(isrc2),fdest */
+{ "fld.d", 0x20000001, 0xdc000006, "1(2)++,g", 0 }, /* fld.d isrc1(isrc2)++,fdest */
+{ "fld.d", 0x24000001, 0xd8000006, "i(2)++,g", E_ADDR }, /* fld.d #const(isrc2)++,fdest */
+{ "fld.q", 0x20000004, 0xdc000003, "1(2),g", 0 }, /* fld.q isrc1(isrc2),fdest */
+{ "fld.q", 0x24000004, 0xd8000003, "i(2),g", E_ADDR }, /* fld.q #const(isrc2),fdest */
+{ "fld.q", 0x20000005, 0xdc000002, "1(2)++,g", 0 }, /* fld.q isrc1(isrc2)++,fdest */
+{ "fld.q", 0x24000005, 0xd8000002, "i(2)++,g", E_ADDR }, /* fld.q #const(isrc2)++,fdest */
+
+{ "pfld.l", 0x60000000, 0x9c000003, "1(2),g", 0 }, /* pfld.l isrc1(isrc2),fdest */
+{ "pfld.l", 0x64000000, 0x98000003, "i(2),g", E_ADDR }, /* pfld.l #const(isrc2),fdest */
+{ "pfld.l", 0x60000001, 0x9c000002, "1(2)++,g", 0 }, /* pfld.l isrc1(isrc2)++,fdest */
+{ "pfld.l", 0x64000001, 0x98000002, "i(2)++,g", E_ADDR }, /* pfld.l #const(isrc2)++,fdest */
+{ "pfld.d", 0x60000000, 0x9c000007, "1(2),g", 0 }, /* pfld.d isrc1(isrc2),fdest */
+{ "pfld.d", 0x64000000, 0x98000007, "i(2),g", E_ADDR }, /* pfld.d #const(isrc2),fdest */
+{ "pfld.d", 0x60000001, 0x9c000006, "1(2)++,g", 0 }, /* pfld.d isrc1(isrc2)++,fdest */
+{ "pfld.d", 0x64000001, 0x98000006, "i(2)++,g", E_ADDR }, /* pfld.d #const(isrc2)++,fdest */
+
+{ "fst.l", 0x28000002, 0xd4000001, "g,1(2)", 0 }, /* fst.l fdest,isrc1(isrc2) */
+{ "fst.l", 0x2c000002, 0xd0000001, "g,i(2)", E_ADDR }, /* fst.l fdest,#const(isrc2) */
+{ "fst.l", 0x28000003, 0xd4000000, "g,1(2)++", 0 }, /* fst.l fdest,isrc1(isrc2)++ */
+{ "fst.l", 0x2c000003, 0xd0000000, "g,i(2)++", E_ADDR }, /* fst.l fdest,#const(isrc2)++ */
+{ "fst.d", 0x28000000, 0xd4000007, "g,1(2)", 0 }, /* fst.d fdest,isrc1(isrc2) */
+{ "fst.d", 0x2c000000, 0xd0000007, "g,i(2)", E_ADDR }, /* fst.d fdest,#const(isrc2) */
+{ "fst.d", 0x28000001, 0xd4000006, "g,1(2)++", 0 }, /* fst.d fdest,isrc1(isrc2)++ */
+{ "fst.d", 0x2c000001, 0xd0000006, "g,i(2)++", E_ADDR }, /* fst.d fdest,#const(isrc2)++ */
+
+{ "pst.d", 0x3c000000, 0xc0000007, "g,i(2)", E_ADDR }, /* pst.d fdest,#const(isrc2) */
+{ "pst.d", 0x3c000001, 0xc0000006, "g,i(2)++", E_ADDR }, /* pst.d fdest,#const(isrc2)++ */
+
+{ "addu", 0x80000000, 0x7c000000, "1,2,d", 0 }, /* addu isrc1,isrc2,idest */
+{ "addu", 0x84000000, 0x78000000, "i,2,d", E_S32 }, /* addu #const,isrc2,idest */
+{ "adds", 0x90000000, 0x6c000000, "1,2,d", 0 }, /* adds isrc1,isrc2,idest */
+{ "adds", 0x94000000, 0x68000000, "i,2,d", E_S32 }, /* adds #const,isrc2,idest */
+{ "subu", 0x88000000, 0x74000000, "1,2,d", 0 }, /* subu isrc1,isrc2,idest */
+{ "subu", 0x8c000000, 0x70000000, "i,2,d", E_S32 }, /* subu #const,isrc2,idest */
+{ "subs", 0x98000000, 0x64000000, "1,2,d", 0 }, /* subs isrc1,isrc2,idest */
+{ "subs", 0x9c000000, 0x60000000, "i,2,d", E_S32 }, /* subs #const,isrc2,idest */
+
+{ "shl", 0xa0000000, 0x5c000000, "1,2,d", 0 }, /* shl isrc1,isrc2,idest */
+{ "shl", 0xa4000000, 0x58000000, "i,2,d", 0 }, /* shl #const,isrc2,idest */
+{ "shr", 0xa8000000, 0x54000000, "1,2,d", 0 }, /* shr isrc1,isrc2,idest */
+{ "shr", 0xac000000, 0x50000000, "i,2,d", 0 }, /* shr #const,isrc2,idest */
+{ "shrd", 0xb0000000, 0x4c000000, "1,2,d", 0 }, /* shrd isrc1,isrc2,idest */
+{ "shra", 0xb8000000, 0x44000000, "1,2,d", 0 }, /* shra isrc1,isrc2,idest */
+{ "shra", 0xbc000000, 0x40000000, "i,2,d", 0 }, /* shra #const,isrc2,idest */
+
+{ "mov", 0xa0000000, 0x5c00f800, "2,d", 0 }, /* shl r0,isrc2,idest */
+{ "mov", 0x94000000, 0x69e00000, "i,d", E_MOV }, /* adds #const,r0,idest */
+{ "nop", 0xa0000000, 0x5ffff800, "", 0 }, /* shl r0,r0,r0 */
+{ "fnop", 0xb0000000, 0x4ffff800, "", 0 }, /* shrd r0,r0,r0 */
+
+{ "trap", 0x44000000, 0xb8000000, "1,2,d", 0 }, /* trap isrc1ni,isrc2,idest */
+
+{ "flush", 0x34000000, 0xc81f0001, "i(2)", E_ADDR }, /* flush #const(isrc2) */
+{ "flush", 0x34000001, 0xc81f0000, "i(2)++", E_ADDR }, /* flush #const(isrc2)++ */
+
+{ "and", 0xc0000000, 0x3c000000, "1,2,d", 0 }, /* and isrc1,isrc2,idest */
+{ "and", 0xc4000000, 0x38000000, "i,2,d", E_AND }, /* and #const,isrc2,idest */
+{ "andh", 0xc8000000, 0x34000000, "1,2,d", 0 }, /* andh isrc1,isrc2,idest */
+{ "andh", 0xcc000000, 0x30000000, "i,2,d", 0 }, /* andh #const,isrc2,idest */
+{ "andnot", 0xd0000000, 0x2c000000, "1,2,d", 0 }, /* andnot isrc1,isrc2,idest */
+{ "andnot", 0xd4000000, 0x28000000, "i,2,d", E_U32 }, /* andnot #const,isrc2,idest */
+{ "andnoth", 0xd8000000, 0x24000000, "1,2,d", 0 }, /* andnoth isrc1,isrc2,idest */
+{ "andnoth", 0xdc000000, 0x20000000, "i,2,d", 0 }, /* andnoth #const,isrc2,idest */
+{ "or", 0xe0000000, 0x1c000000, "1,2,d", 0 }, /* or isrc1,isrc2,idest */
+{ "or", 0xe4000000, 0x18000000, "i,2,d", E_U32 }, /* or #const,isrc2,idest */
+{ "orh", 0xe8000000, 0x14000000, "1,2,d", 0 }, /* orh isrc1,isrc2,idest */
+{ "orh", 0xec000000, 0x10000000, "i,2,d", 0 }, /* orh #const,isrc2,idest */
+{ "xor", 0xf0000000, 0x0c000000, "1,2,d", 0 }, /* xor isrc1,isrc2,idest */
+{ "xor", 0xf4000000, 0x08000000, "i,2,d", E_U32 }, /* xor #const,isrc2,idest */
+{ "xorh", 0xf8000000, 0x04000000, "1,2,d", 0 }, /* xorh isrc1,isrc2,idest */
+{ "xorh", 0xfc000000, 0x00000000, "i,2,d", 0 }, /* xorh #const,isrc2,idest */
+
+{ "bte", 0x58000000, 0xa4000000, "1,2,s", 0 }, /* bte isrc1s,isrc2,sbroff */
+{ "bte", 0x5c000000, 0xa0000000, "5,2,s", 0 }, /* bte #const5,isrc2,sbroff */
+{ "btne", 0x50000000, 0xac000000, "1,2,s", 0 }, /* btne isrc1s,isrc2,sbroff */
+{ "btne", 0x54000000, 0xa8000000, "5,2,s", 0 }, /* btne #const5,isrc2,sbroff */
+{ "bla", 0xb4000000, 0x48000000, "1,2,s", E_DELAY }, /* bla isrc1s,isrc2,sbroff */
+{ "bri", 0x40000000, 0xbc000000, "1", E_DELAY }, /* bri isrc1ni */
+
+/* Core Escape Instruction Format */
+{ "lock", 0x4c000001, 0xb000001e, "", 0 }, /* lock set BL in dirbase */
+{ "calli", 0x4c000002, 0xb000001d, "1", E_DELAY }, /* calli isrc1ni */
+{ "intovr", 0x4c000004, 0xb000001b, "", 0 }, /* intovr trap on integer overflow */
+{ "unlock", 0x4c000007, 0xb0000018, "", 0 }, /* unlock clear BL in dirbase */
+
+/* CTRL-Format Instructions */
+{ "br", 0x68000000, 0x94000000, "l", E_DELAY }, /* br lbroff */
+{ "call", 0x6c000000, 0x90000000, "l", E_DELAY }, /* call lbroff */
+{ "bc", 0x70000000, 0x8c000000, "l", 0 }, /* bc lbroff */
+{ "bc.t", 0x74000000, 0x88000000, "l", E_DELAY }, /* bc.t lbroff */
+{ "bnc", 0x78000000, 0x84000000, "l", 0 }, /* bnc lbroff */
+{ "bnc.t", 0x7c000000, 0x80000000, "l", E_DELAY }, /* bnc.t lbroff */
+
+/* Floating Point Escape Instruction Format - pfam.p fsrc1,fsrc2,fdest */
+{ "r2p1.ss", 0x48000400, 0xb40003ff, "e,f,g", 0 },
+{ "r2p1.sd", 0x48000480, 0xb400037f, "e,f,g", 0 },
+{ "r2p1.dd", 0x48000580, 0xb400027f, "e,f,g", 0 },
+{ "r2pt.ss", 0x48000401, 0xb40003fe, "e,f,g", 0 },
+{ "r2pt.sd", 0x48000481, 0xb400037e, "e,f,g", 0 },
+{ "r2pt.dd", 0x48000581, 0xb400027e, "e,f,g", 0 },
+{ "r2ap1.ss", 0x48000402, 0xb40003fd, "e,f,g", 0 },
+{ "r2ap1.sd", 0x48000482, 0xb400037d, "e,f,g", 0 },
+{ "r2ap1.dd", 0x48000582, 0xb400027d, "e,f,g", 0 },
+{ "r2apt.ss", 0x48000403, 0xb40003fc, "e,f,g", 0 },
+{ "r2apt.sd", 0x48000483, 0xb400037c, "e,f,g", 0 },
+{ "r2apt.dd", 0x48000583, 0xb400027c, "e,f,g", 0 },
+{ "i2p1.ss", 0x48000404, 0xb40003fb, "e,f,g", 0 },
+{ "i2p1.sd", 0x48000484, 0xb400037b, "e,f,g", 0 },
+{ "i2p1.dd", 0x48000584, 0xb400027b, "e,f,g", 0 },
+{ "i2pt.ss", 0x48000405, 0xb40003fa, "e,f,g", 0 },
+{ "i2pt.sd", 0x48000485, 0xb400037a, "e,f,g", 0 },
+{ "i2pt.dd", 0x48000585, 0xb400027a, "e,f,g", 0 },
+{ "i2ap1.ss", 0x48000406, 0xb40003f9, "e,f,g", 0 },
+{ "i2ap1.sd", 0x48000486, 0xb4000379, "e,f,g", 0 },
+{ "i2ap1.dd", 0x48000586, 0xb4000279, "e,f,g", 0 },
+{ "i2apt.ss", 0x48000407, 0xb40003f8, "e,f,g", 0 },
+{ "i2apt.sd", 0x48000487, 0xb4000378, "e,f,g", 0 },
+{ "i2apt.dd", 0x48000587, 0xb4000278, "e,f,g", 0 },
+{ "rat1p2.ss", 0x48000408, 0xb40003f7, "e,f,g", 0 },
+{ "rat1p2.sd", 0x48000488, 0xb4000377, "e,f,g", 0 },
+{ "rat1p2.dd", 0x48000588, 0xb4000277, "e,f,g", 0 },
+{ "m12apm.ss", 0x48000409, 0xb40003f6, "e,f,g", 0 },
+{ "m12apm.sd", 0x48000489, 0xb4000376, "e,f,g", 0 },
+{ "m12apm.dd", 0x48000589, 0xb4000276, "e,f,g", 0 },
+{ "ra1p2.ss", 0x4800040a, 0xb40003f5, "e,f,g", 0 },
+{ "ra1p2.sd", 0x4800048a, 0xb4000375, "e,f,g", 0 },
+{ "ra1p2.dd", 0x4800058a, 0xb4000275, "e,f,g", 0 },
+{ "m12ttpa.ss", 0x4800040b, 0xb40003f4, "e,f,g", 0 },
+{ "m12ttpa.sd", 0x4800048b, 0xb4000374, "e,f,g", 0 },
+{ "m12ttpa.dd", 0x4800058b, 0xb4000274, "e,f,g", 0 },
+{ "iat1p2.ss", 0x4800040c, 0xb40003f3, "e,f,g", 0 },
+{ "iat1p2.sd", 0x4800048c, 0xb4000373, "e,f,g", 0 },
+{ "iat1p2.dd", 0x4800058c, 0xb4000273, "e,f,g", 0 },
+{ "m12tpm.ss", 0x4800040d, 0xb40003f2, "e,f,g", 0 },
+{ "m12tpm.sd", 0x4800048d, 0xb4000372, "e,f,g", 0 },
+{ "m12tpm.dd", 0x4800058d, 0xb4000272, "e,f,g", 0 },
+{ "ia1p2.ss", 0x4800040e, 0xb40003f1, "e,f,g", 0 },
+{ "ia1p2.sd", 0x4800048e, 0xb4000371, "e,f,g", 0 },
+{ "ia1p2.dd", 0x4800058e, 0xb4000271, "e,f,g", 0 },
+{ "m12tpa.ss", 0x4800040f, 0xb40003f0, "e,f,g", 0 },
+{ "m12tpa.sd", 0x4800048f, 0xb4000370, "e,f,g", 0 },
+{ "m12tpa.dd", 0x4800058f, 0xb4000270, "e,f,g", 0 },
+
+/* Floating Point Escape Instruction Format - pfsm.p fsrc1,fsrc2,fdest */
+{ "r2s1.ss", 0x48000410, 0xb40003ef, "e,f,g", 0 },
+{ "r2s1.sd", 0x48000490, 0xb400036f, "e,f,g", 0 },
+{ "r2s1.dd", 0x48000590, 0xb400026f, "e,f,g", 0 },
+{ "r2st.ss", 0x48000411, 0xb40003ee, "e,f,g", 0 },
+{ "r2st.sd", 0x48000491, 0xb400036e, "e,f,g", 0 },
+{ "r2st.dd", 0x48000591, 0xb400026e, "e,f,g", 0 },
+{ "r2as1.ss", 0x48000412, 0xb40003ed, "e,f,g", 0 },
+{ "r2as1.sd", 0x48000492, 0xb400036d, "e,f,g", 0 },
+{ "r2as1.dd", 0x48000592, 0xb400026d, "e,f,g", 0 },
+{ "r2ast.ss", 0x48000413, 0xb40003ec, "e,f,g", 0 },
+{ "r2ast.sd", 0x48000493, 0xb400036c, "e,f,g", 0 },
+{ "r2ast.dd", 0x48000593, 0xb400026c, "e,f,g", 0 },
+{ "i2s1.ss", 0x48000414, 0xb40003eb, "e,f,g", 0 },
+{ "i2s1.sd", 0x48000494, 0xb400036b, "e,f,g", 0 },
+{ "i2s1.dd", 0x48000594, 0xb400026b, "e,f,g", 0 },
+{ "i2st.ss", 0x48000415, 0xb40003ea, "e,f,g", 0 },
+{ "i2st.sd", 0x48000495, 0xb400036a, "e,f,g", 0 },
+{ "i2st.dd", 0x48000595, 0xb400026a, "e,f,g", 0 },
+{ "i2as1.ss", 0x48000416, 0xb40003e9, "e,f,g", 0 },
+{ "i2as1.sd", 0x48000496, 0xb4000369, "e,f,g", 0 },
+{ "i2as1.dd", 0x48000596, 0xb4000269, "e,f,g", 0 },
+{ "i2ast.ss", 0x48000417, 0xb40003e8, "e,f,g", 0 },
+{ "i2ast.sd", 0x48000497, 0xb4000368, "e,f,g", 0 },
+{ "i2ast.dd", 0x48000597, 0xb4000268, "e,f,g", 0 },
+{ "rat1s2.ss", 0x48000418, 0xb40003e7, "e,f,g", 0 },
+{ "rat1s2.sd", 0x48000498, 0xb4000367, "e,f,g", 0 },
+{ "rat1s2.dd", 0x48000598, 0xb4000267, "e,f,g", 0 },
+{ "m12asm.ss", 0x48000419, 0xb40003e6, "e,f,g", 0 },
+{ "m12asm.sd", 0x48000499, 0xb4000366, "e,f,g", 0 },
+{ "m12asm.dd", 0x48000599, 0xb4000266, "e,f,g", 0 },
+{ "ra1s2.ss", 0x4800041a, 0xb40003e5, "e,f,g", 0 },
+{ "ra1s2.sd", 0x4800049a, 0xb4000365, "e,f,g", 0 },
+{ "ra1s2.dd", 0x4800059a, 0xb4000265, "e,f,g", 0 },
+{ "m12ttsa.ss", 0x4800041b, 0xb40003e4, "e,f,g", 0 },
+{ "m12ttsa.sd", 0x4800049b, 0xb4000364, "e,f,g", 0 },
+{ "m12ttsa.dd", 0x4800059b, 0xb4000264, "e,f,g", 0 },
+{ "iat1s2.ss", 0x4800041c, 0xb40003e3, "e,f,g", 0 },
+{ "iat1s2.sd", 0x4800049c, 0xb4000363, "e,f,g", 0 },
+{ "iat1s2.dd", 0x4800059c, 0xb4000263, "e,f,g", 0 },
+{ "m12tsm.ss", 0x4800041d, 0xb40003e2, "e,f,g", 0 },
+{ "m12tsm.sd", 0x4800049d, 0xb4000362, "e,f,g", 0 },
+{ "m12tsm.dd", 0x4800059d, 0xb4000262, "e,f,g", 0 },
+{ "ia1s2.ss", 0x4800041e, 0xb40003e1, "e,f,g", 0 },
+{ "ia1s2.sd", 0x4800049e, 0xb4000361, "e,f,g", 0 },
+{ "ia1s2.dd", 0x4800059e, 0xb4000261, "e,f,g", 0 },
+{ "m12tsa.ss", 0x4800041f, 0xb40003e0, "e,f,g", 0 },
+{ "m12tsa.sd", 0x4800049f, 0xb4000360, "e,f,g", 0 },
+{ "m12tsa.dd", 0x4800059f, 0xb4000260, "e,f,g", 0 },
+
+/* Floating Point Escape Instruction Format - pfmam.p fsrc1,fsrc2,fdest */
+{ "mr2p1.ss", 0x48000000, 0xb40007ff, "e,f,g", 0 },
+{ "mr2p1.sd", 0x48000080, 0xb400077f, "e,f,g", 0 },
+{ "mr2p1.dd", 0x48000180, 0xb400067f, "e,f,g", 0 },
+{ "mr2pt.ss", 0x48000001, 0xb40007fe, "e,f,g", 0 },
+{ "mr2pt.sd", 0x48000081, 0xb400077e, "e,f,g", 0 },
+{ "mr2pt.dd", 0x48000181, 0xb400067e, "e,f,g", 0 },
+{ "mr2mp1.ss", 0x48000002, 0xb40007fd, "e,f,g", 0 },
+{ "mr2mp1.sd", 0x48000082, 0xb400077d, "e,f,g", 0 },
+{ "mr2mp1.dd", 0x48000182, 0xb400067d, "e,f,g", 0 },
+{ "mr2mpt.ss", 0x48000003, 0xb40007fc, "e,f,g", 0 },
+{ "mr2mpt.sd", 0x48000083, 0xb400077c, "e,f,g", 0 },
+{ "mr2mpt.dd", 0x48000183, 0xb400067c, "e,f,g", 0 },
+{ "mi2p1.ss", 0x48000004, 0xb40007fb, "e,f,g", 0 },
+{ "mi2p1.sd", 0x48000084, 0xb400077b, "e,f,g", 0 },
+{ "mi2p1.dd", 0x48000184, 0xb400067b, "e,f,g", 0 },
+{ "mi2pt.ss", 0x48000005, 0xb40007fa, "e,f,g", 0 },
+{ "mi2pt.sd", 0x48000085, 0xb400077a, "e,f,g", 0 },
+{ "mi2pt.dd", 0x48000185, 0xb400067a, "e,f,g", 0 },
+{ "mi2mp1.ss", 0x48000006, 0xb40007f9, "e,f,g", 0 },
+{ "mi2mp1.sd", 0x48000086, 0xb4000779, "e,f,g", 0 },
+{ "mi2mp1.dd", 0x48000186, 0xb4000679, "e,f,g", 0 },
+{ "mi2mpt.ss", 0x48000007, 0xb40007f8, "e,f,g", 0 },
+{ "mi2mpt.sd", 0x48000087, 0xb4000778, "e,f,g", 0 },
+{ "mi2mpt.dd", 0x48000187, 0xb4000678, "e,f,g", 0 },
+{ "mrmt1p2.ss", 0x48000008, 0xb40007f7, "e,f,g", 0 },
+{ "mrmt1p2.sd", 0x48000088, 0xb4000777, "e,f,g", 0 },
+{ "mrmt1p2.dd", 0x48000188, 0xb4000677, "e,f,g", 0 },
+{ "mm12mpm.ss", 0x48000009, 0xb40007f6, "e,f,g", 0 },
+{ "mm12mpm.sd", 0x48000089, 0xb4000776, "e,f,g", 0 },
+{ "mm12mpm.dd", 0x48000189, 0xb4000676, "e,f,g", 0 },
+{ "mrm1p2.ss", 0x4800000a, 0xb40007f5, "e,f,g", 0 },
+{ "mrm1p2.sd", 0x4800008a, 0xb4000775, "e,f,g", 0 },
+{ "mrm1p2.dd", 0x4800018a, 0xb4000675, "e,f,g", 0 },
+{ "mm12ttpm.ss",0x4800000b, 0xb40007f4, "e,f,g", 0 },
+{ "mm12ttpm.sd",0x4800008b, 0xb4000774, "e,f,g", 0 },
+{ "mm12ttpm.dd",0x4800018b, 0xb4000674, "e,f,g", 0 },
+{ "mimt1p2.ss", 0x4800000c, 0xb40007f3, "e,f,g", 0 },
+{ "mimt1p2.sd", 0x4800008c, 0xb4000773, "e,f,g", 0 },
+{ "mimt1p2.dd", 0x4800018c, 0xb4000673, "e,f,g", 0 },
+{ "mm12tpm.ss", 0x4800000d, 0xb40007f2, "e,f,g", 0 },
+{ "mm12tpm.sd", 0x4800008d, 0xb4000772, "e,f,g", 0 },
+{ "mm12tpm.dd", 0x4800018d, 0xb4000672, "e,f,g", 0 },
+{ "mim1p2.ss", 0x4800000e, 0xb40007f1, "e,f,g", 0 },
+{ "mim1p2.sd", 0x4800008e, 0xb4000771, "e,f,g", 0 },
+{ "mim1p2.dd", 0x4800018e, 0xb4000671, "e,f,g", 0 },
+
+/* Floating Point Escape Instruction Format - pfmsm.p fsrc1,fsrc2,fdest */
+{ "mr2s1.ss", 0x48000010, 0xb40007ef, "e,f,g", 0 },
+{ "mr2s1.sd", 0x48000090, 0xb400076f, "e,f,g", 0 },
+{ "mr2s1.dd", 0x48000190, 0xb400066f, "e,f,g", 0 },
+{ "mr2st.ss", 0x48000011, 0xb40007ee, "e,f,g", 0 },
+{ "mr2st.sd", 0x48000091, 0xb400076e, "e,f,g", 0 },
+{ "mr2st.dd", 0x48000191, 0xb400066e, "e,f,g", 0 },
+{ "mr2ms1.ss", 0x48000012, 0xb40007ed, "e,f,g", 0 },
+{ "mr2ms1.sd", 0x48000092, 0xb400076d, "e,f,g", 0 },
+{ "mr2ms1.dd", 0x48000192, 0xb400066d, "e,f,g", 0 },
+{ "mr2mst.ss", 0x48000013, 0xb40007ec, "e,f,g", 0 },
+{ "mr2mst.sd", 0x48000093, 0xb400076c, "e,f,g", 0 },
+{ "mr2mst.dd", 0x48000193, 0xb400066c, "e,f,g", 0 },
+{ "mi2s1.ss", 0x48000014, 0xb40007eb, "e,f,g", 0 },
+{ "mi2s1.sd", 0x48000094, 0xb400076b, "e,f,g", 0 },
+{ "mi2s1.dd", 0x48000194, 0xb400066b, "e,f,g", 0 },
+{ "mi2st.ss", 0x48000015, 0xb40007ea, "e,f,g", 0 },
+{ "mi2st.sd", 0x48000095, 0xb400076a, "e,f,g", 0 },
+{ "mi2st.dd", 0x48000195, 0xb400066a, "e,f,g", 0 },
+{ "mi2ms1.ss", 0x48000016, 0xb40007e9, "e,f,g", 0 },
+{ "mi2ms1.sd", 0x48000096, 0xb4000769, "e,f,g", 0 },
+{ "mi2ms1.dd", 0x48000196, 0xb4000669, "e,f,g", 0 },
+{ "mi2mst.ss", 0x48000017, 0xb40007e8, "e,f,g", 0 },
+{ "mi2mst.sd", 0x48000097, 0xb4000768, "e,f,g", 0 },
+{ "mi2mst.dd", 0x48000197, 0xb4000668, "e,f,g", 0 },
+{ "mrmt1s2.ss", 0x48000018, 0xb40007e7, "e,f,g", 0 },
+{ "mrmt1s2.sd", 0x48000098, 0xb4000767, "e,f,g", 0 },
+{ "mrmt1s2.dd", 0x48000198, 0xb4000667, "e,f,g", 0 },
+{ "mm12msm.ss", 0x48000019, 0xb40007e6, "e,f,g", 0 },
+{ "mm12msm.sd", 0x48000099, 0xb4000766, "e,f,g", 0 },
+{ "mm12msm.dd", 0x48000199, 0xb4000666, "e,f,g", 0 },
+{ "mrm1s2.ss", 0x4800001a, 0xb40007e5, "e,f,g", 0 },
+{ "mrm1s2.sd", 0x4800009a, 0xb4000765, "e,f,g", 0 },
+{ "mrm1s2.dd", 0x4800019a, 0xb4000665, "e,f,g", 0 },
+{ "mm12ttsm.ss",0x4800001b, 0xb40007e4, "e,f,g", 0 },
+{ "mm12ttsm.sd",0x4800009b, 0xb4000764, "e,f,g", 0 },
+{ "mm12ttsm.dd",0x4800019b, 0xb4000664, "e,f,g", 0 },
+{ "mimt1s2.ss", 0x4800001c, 0xb40007e3, "e,f,g", 0 },
+{ "mimt1s2.sd", 0x4800009c, 0xb4000763, "e,f,g", 0 },
+{ "mimt1s2.dd", 0x4800019c, 0xb4000663, "e,f,g", 0 },
+{ "mm12tsm.ss", 0x4800001d, 0xb40007e2, "e,f,g", 0 },
+{ "mm12tsm.sd", 0x4800009d, 0xb4000762, "e,f,g", 0 },
+{ "mm12tsm.dd", 0x4800019d, 0xb4000662, "e,f,g", 0 },
+{ "mim1s2.ss", 0x4800001e, 0xb40007e1, "e,f,g", 0 },
+{ "mim1s2.sd", 0x4800009e, 0xb4000761, "e,f,g", 0 },
+{ "mim1s2.dd", 0x4800019e, 0xb4000661, "e,f,g", 0 },
+
+
+{ "fmul.ss", 0x48000020, 0xb40007df, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */
+{ "fmul.sd", 0x480000a0, 0xb400075f, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */
+{ "fmul.dd", 0x480001a0, 0xb400065f, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */
+{ "pfmul.ss", 0x48000420, 0xb40003df, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */
+{ "pfmul.sd", 0x480004a0, 0xb400035f, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */
+{ "pfmul.dd", 0x480005a0, 0xb400025f, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */
+{ "pfmul3.dd", 0x480005a4, 0xb400025b, "e,f,g", 0 }, /* pfmul3.p fsrc1,fsrc2,fdest */
+{ "fmlow.dd", 0x480001a1, 0xb400065e, "e,f,g", 0 }, /* fmlow.dd fsrc1,fsrc2,fdest */
+{ "frcp.ss", 0x48000022, 0xb40007dd, "f,g", 0 }, /* frcp.p fsrc2,fdest */
+{ "frcp.sd", 0x480000a2, 0xb400075d, "f,g", 0 }, /* frcp.p fsrc2,fdest */
+{ "frcp.dd", 0x480001a2, 0xb400065d, "f,g", 0 }, /* frcp.p fsrc2,fdest */
+{ "frsqr.ss", 0x48000023, 0xb40007dc, "f,g", 0 }, /* frsqr.p fsrc2,fdest */
+{ "frsqr.sd", 0x480000a3, 0xb400075c, "f,g", 0 }, /* frsqr.p fsrc2,fdest */
+{ "frsqr.dd", 0x480001a3, 0xb400065c, "f,g", 0 }, /* frsqr.p fsrc2,fdest */
+{ "fadd.ss", 0x48000030, 0xb40007cf, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */
+{ "fadd.sd", 0x480000b0, 0xb400074f, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */
+{ "fadd.dd", 0x480001b0, 0xb400064f, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */
+{ "pfadd.ss", 0x48000430, 0xb40003cf, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */
+{ "pfadd.sd", 0x480004b0, 0xb400034f, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */
+{ "pfadd.dd", 0x480005b0, 0xb400024f, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */
+{ "fsub.ss", 0x48000031, 0xb40007ce, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */
+{ "fsub.sd", 0x480000b1, 0xb400074e, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */
+{ "fsub.dd", 0x480001b1, 0xb400064e, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */
+{ "pfsub.ss", 0x48000431, 0xb40003ce, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */
+{ "pfsub.sd", 0x480004b1, 0xb400034e, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */
+{ "pfsub.dd", 0x480005b1, 0xb400024e, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */
+{ "fix.ss", 0x48000032, 0xb40007cd, "e,g", 0 }, /* fix.p fsrc1,fdest */
+{ "fix.sd", 0x480000b2, 0xb400074d, "e,g", 0 }, /* fix.p fsrc1,fdest */
+{ "fix.dd", 0x480001b2, 0xb400064d, "e,g", 0 }, /* fix.p fsrc1,fdest */
+{ "pfix.ss", 0x48000432, 0xb40003cd, "e,g", 0 }, /* pfix.p fsrc1,fdest */
+{ "pfix.sd", 0x480004b2, 0xb400034d, "e,g", 0 }, /* pfix.p fsrc1,fdest */
+{ "pfix.dd", 0x480005b2, 0xb400024d, "e,g", 0 }, /* pfix.p fsrc1,fdest */
+{ "famov.ss", 0x48000033, 0xb40007cc, "e,g", 0 }, /* famov.p fsrc1,fdest */
+{ "famov.ds", 0x48000133, 0xb40006cc, "e,g", 0 }, /* famov.p fsrc1,fdest */
+{ "famov.sd", 0x480000b3, 0xb400074c, "e,g", 0 }, /* famov.p fsrc1,fdest */
+{ "famov.dd", 0x480001b3, 0xb400064c, "e,g", 0 }, /* famov.p fsrc1,fdest */
+{ "pfamov.ss", 0x48000433, 0xb40003cc, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
+{ "pfamov.ds", 0x48000533, 0xb40002cc, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
+{ "pfamov.sd", 0x480004b3, 0xb400034c, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
+{ "pfamov.dd", 0x480005b3, 0xb400024c, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
+/* pfgt has R bit cleared; pfle has R bit set */
+{ "pfgt.ss", 0x48000434, 0xb40003cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */
+{ "pfgt.sd", 0x48000434, 0xb40003cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */
+{ "pfgt.dd", 0x48000534, 0xb40002cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */
+/* pfgt has R bit cleared; pfle has R bit set */
+{ "pfle.ss", 0x480004b4, 0xb400034b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */
+{ "pfle.sd", 0x480004b4, 0xb400034b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */
+{ "pfle.dd", 0x480005b4, 0xb400024b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */
+{ "ftrunc.ss", 0x4800003a, 0xb40007c5, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */
+{ "ftrunc.sd", 0x480000ba, 0xb4000745, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */
+{ "ftrunc.dd", 0x480001ba, 0xb4000645, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */
+{ "pftrunc.ss", 0x4800043a, 0xb40003c5, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */
+{ "pftrunc.sd", 0x480004ba, 0xb4000345, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */
+{ "pftrunc.dd", 0x480005ba, 0xb4000245, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */
+{ "fxfr", 0x48000040, 0xb40007bf, "e,d", 0 }, /* fxfr fsrc1,idest */
+{ "fiadd.ss", 0x48000049, 0xb40007b6, "e,f,g", 0 }, /* fiadd.w fsrc1,fsrc2,fdest */
+{ "fiadd.dd", 0x480001c9, 0xb4000636, "e,f,g", 0 }, /* fiadd.w fsrc1,fsrc2,fdest */
+{ "pfiadd.ss", 0x48000449, 0xb40003b6, "e,f,g", 0 }, /* pfiadd.w fsrc1,fsrc2,fdest */
+{ "pfiadd.dd", 0x480005c9, 0xb4000236, "e,f,g", 0 }, /* pfiadd.w fsrc1,fsrc2,fdest */
+{ "fisub.ss", 0x4800004d, 0xb40007b2, "e,f,g", 0 }, /* fisub.w fsrc1,fsrc2,fdest */
+{ "fisub.dd", 0x480001cd, 0xb4000632, "e,f,g", 0 }, /* fisub.w fsrc1,fsrc2,fdest */
+{ "pfisub.ss", 0x4800044d, 0xb40003b2, "e,f,g", 0 }, /* pfisub.w fsrc1,fsrc2,fdest */
+{ "pfisub.dd", 0x480005cd, 0xb4000232, "e,f,g", 0 }, /* pfisub.w fsrc1,fsrc2,fdest */
+{ "fzchkl", 0x48000057, 0xb40007a8, "e,f,g", 0 }, /* fzchkl fsrc1,fsrc2,fdest */
+{ "pfzchkl", 0x48000457, 0xb40003a8, "e,f,g", 0 }, /* pfzchkl fsrc1,fsrc2,fdest */
+{ "fzchks", 0x4800005f, 0xb40007a0, "e,f,g", 0 }, /* fzchks fsrc1,fsrc2,fdest */
+{ "pfzchks", 0x4800045f, 0xb40003a0, "e,f,g", 0 }, /* pfzchks fsrc1,fsrc2,fdest */
+{ "faddp", 0x48000050, 0xb40007af, "e,f,g", 0 }, /* faddp fsrc1,fsrc2,fdest */
+{ "pfaddp", 0x48000450, 0xb40003af, "e,f,g", 0 }, /* pfaddp fsrc1,fsrc2,fdest */
+{ "faddz", 0x48000051, 0xb40007ae, "e,f,g", 0 }, /* faddz fsrc1,fsrc2,fdest */
+{ "pfaddz", 0x48000451, 0xb40003ae, "e,f,g", 0 }, /* pfaddz fsrc1,fsrc2,fdest */
+{ "form", 0x4800005a, 0xb40007a5, "e,g", 0 }, /* form fsrc1,fdest */
+{ "pform", 0x4800045a, 0xb40003a5, "e,g", 0 }, /* pform fsrc1,fdest */
+
+/* Floating point pseudo-instructions */
+{ "fmov.ss", 0x48000049, 0xb7e007b6, "e,g", 0 }, /* fiadd.ss fsrc1,f0,fdest */
+{ "fmov.dd", 0x480001c9, 0xb7e00636, "e,g", 0 }, /* fiadd.dd fsrc1,f0,fdest */
+{ "fmov.sd", 0x480000b0, 0xb7e0074f, "e,g", 0 }, /* fadd.sd fsrc1,f0,fdest */
+{ "fmov.ds", 0x48000130, 0xb7e006cf, "e,g", 0 }, /* fadd.ds fsrc1,f0,fdest */
+{ "pfmov.ds", 0x48000530, 0xb73002cf, "e,g", 0 }, /* pfadd.ds fsrc1,f0,fdest */
+{ "pfmov.dd", 0x480005c9, 0xb7e00236, "e,g", 0 }, /* pfiadd.dd fsrc1,f0,fdest */
+
+
+};
+
+#define NUMOPCODES ((sizeof i860_opcodes)/(sizeof i860_opcodes[0]))
+
+
diff --git a/include/opcode/i960.h b/include/opcode/i960.h
new file mode 100644
index 00000000000..b52fc338737
--- /dev/null
+++ b/include/opcode/i960.h
@@ -0,0 +1,509 @@
+/* Basic 80960 instruction formats.
+ *
+ * The 'COJ' instructions are actually COBR instructions with the 'b' in
+ * the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary:
+ * if the displacement will not fit in 13 bits, the assembler will replace them
+ * with the corresponding compare and branch instructions.
+ *
+ * All of the 'MEMn' instructions are the same format; the 'n' in the name
+ * indicates the default index scale factor (the size of the datum operated on).
+ *
+ * The FBRA formats are not actually an instruction format. They are the
+ * "convenience directives" for branching on floating-point comparisons,
+ * each of which generates 2 instructions (a 'bno' and one other branch).
+ *
+ * The CALLJ format is not actually an instruction format. It indicates that
+ * the instruction generated (a CTRL-format 'call') should have its relocation
+ * specially flagged for link-time replacement with a 'bal' or 'calls' if
+ * appropriate.
+ */
+
+#define CTRL 0
+#define COBR 1
+#define COJ 2
+#define REG 3
+#define MEM1 4
+#define MEM2 5
+#define MEM4 6
+#define MEM8 7
+#define MEM12 8
+#define MEM16 9
+#define FBRA 10
+#define CALLJ 11
+
+/* Masks for the mode bits in REG format instructions */
+#define M1 0x0800
+#define M2 0x1000
+#define M3 0x2000
+
+/* Generate the 12-bit opcode for a REG format instruction by placing the
+ * high 8 bits in instruction bits 24-31, the low 4 bits in instruction bits
+ * 7-10.
+ */
+
+#define REG_OPC(opc) ((opc & 0xff0) << 20) | ((opc & 0xf) << 7)
+
+/* Generate a template for a REG format instruction: place the opcode bits
+ * in the appropriate fields and OR in mode bits for the operands that will not
+ * be used. I.e.,
+ * set m1=1, if src1 will not be used
+ * set m2=1, if src2 will not be used
+ * set m3=1, if dst will not be used
+ *
+ * Setting the "unused" mode bits to 1 speeds up instruction execution(!).
+ * The information is also useful to us because some 1-operand REG instructions
+ * use the src1 field, others the dst field; and some 2-operand REG instructions
+ * use src1/src2, others src1/dst. The set mode bits enable us to distinguish.
+ */
+#define R_0(opc) ( REG_OPC(opc) | M1 | M2 | M3 ) /* No operands */
+#define R_1(opc) ( REG_OPC(opc) | M2 | M3 ) /* 1 operand: src1 */
+#define R_1D(opc) ( REG_OPC(opc) | M1 | M2 ) /* 1 operand: dst */
+#define R_2(opc) ( REG_OPC(opc) | M3 ) /* 2 ops: src1/src2 */
+#define R_2D(opc) ( REG_OPC(opc) | M2 ) /* 2 ops: src1/dst */
+#define R_3(opc) ( REG_OPC(opc) ) /* 3 operands */
+
+/* DESCRIPTOR BYTES FOR REGISTER OPERANDS
+ *
+ * Interpret names as follows:
+ * R: global or local register only
+ * RS: global, local, or (if target allows) special-function register only
+ * RL: global or local register, or integer literal
+ * RSL: global, local, or (if target allows) special-function register;
+ * or integer literal
+ * F: global, local, or floating-point register
+ * FL: global, local, or floating-point register; or literal (including
+ * floating point)
+ *
+ * A number appended to a name indicates that registers must be aligned,
+ * as follows:
+ * 2: register number must be multiple of 2
+ * 4: register number must be multiple of 4
+ */
+
+#define SFR 0x10 /* Mask for the "sfr-OK" bit */
+#define LIT 0x08 /* Mask for the "literal-OK" bit */
+#define FP 0x04 /* Mask for "floating-point-OK" bit */
+
+/* This macro ors the bits together. Note that 'align' is a mask
+ * for the low 0, 1, or 2 bits of the register number, as appropriate.
+ */
+#define OP(align,lit,fp,sfr) ( align | lit | fp | sfr )
+
+#define R OP( 0, 0, 0, 0 )
+#define RS OP( 0, 0, 0, SFR )
+#define RL OP( 0, LIT, 0, 0 )
+#define RSL OP( 0, LIT, 0, SFR )
+#define F OP( 0, 0, FP, 0 )
+#define FL OP( 0, LIT, FP, 0 )
+#define R2 OP( 1, 0, 0, 0 )
+#define RL2 OP( 1, LIT, 0, 0 )
+#define F2 OP( 1, 0, FP, 0 )
+#define FL2 OP( 1, LIT, FP, 0 )
+#define R4 OP( 3, 0, 0, 0 )
+#define RL4 OP( 3, LIT, 0, 0 )
+#define F4 OP( 3, 0, FP, 0 )
+#define FL4 OP( 3, LIT, FP, 0 )
+
+#define M 0x7f /* Memory operand (MEMA & MEMB format instructions) */
+
+/* Macros to extract info from the register operand descriptor byte 'od'.
+ */
+#define SFR_OK(od) (od & SFR) /* TRUE if sfr operand allowed */
+#define LIT_OK(od) (od & LIT) /* TRUE if literal operand allowed */
+#define FP_OK(od) (od & FP) /* TRUE if floating-point op allowed */
+#define REG_ALIGN(od,n) ((od & 0x3 & n) == 0)
+ /* TRUE if reg #n is properly aligned */
+#define MEMOP(od) (od == M) /* TRUE if operand is a memory operand*/
+
+/* Description of a single i80960 instruction */
+struct i960_opcode {
+ long opcode; /* 32 bits, constant fields filled in, rest zeroed */
+ char *name; /* Assembler mnemonic */
+ short iclass; /* Class: see #defines below */
+ char format; /* REG, COBR, CTRL, MEMn, COJ, FBRA, or CALLJ */
+ char num_ops; /* Number of operands */
+ char operand[3];/* Operand descriptors; same order as assembler instr */
+};
+
+/* Classes of 960 intructions:
+ * - each instruction falls into one class.
+ * - each target architecture supports one or more classes.
+ *
+ * EACH CONSTANT MUST CONTAIN 1 AND ONLY 1 SET BIT!: see targ_has_iclass().
+ */
+#define I_BASE 0x01 /* 80960 base instruction set */
+#define I_CX 0x02 /* 80960Cx instruction */
+#define I_DEC 0x04 /* Decimal instruction */
+#define I_FP 0x08 /* Floating point instruction */
+#define I_KX 0x10 /* 80960Kx instruction */
+#define I_MIL 0x20 /* Military instruction */
+#define I_CASIM 0x40 /* CA simulator instruction */
+#define I_CX2 0x80 /* Cx/Jx/Hx instructions */
+#define I_JX 0x100 /* Jx/Hx instruction */
+#define I_HX 0x200 /* Hx instructions */
+
+/******************************************************************************
+ *
+ * TABLE OF i960 INSTRUCTION DESCRIPTIONS
+ *
+ ******************************************************************************/
+
+const struct i960_opcode i960_opcodes[] = {
+
+ /* if a CTRL instruction has an operand, it's always a displacement */
+
+ /* callj default=='call' */
+ { 0x09000000, "callj", I_BASE, CALLJ, 1, { 0, 0, 0 } },
+ { 0x08000000, "b", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x09000000, "call", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x0a000000, "ret", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x0b000000, "bal", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x10000000, "bno", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* bf same as bno */
+ { 0x10000000, "bf", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* bru same as bno */
+ { 0x10000000, "bru", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x11000000, "bg", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* brg same as bg */
+ { 0x11000000, "brg", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x12000000, "be", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* bre same as be */
+ { 0x12000000, "bre", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x13000000, "bge", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* brge same as bge */
+ { 0x13000000, "brge", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x14000000, "bl", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* brl same as bl */
+ { 0x14000000, "brl", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x15000000, "bne", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* brlg same as bne */
+ { 0x15000000, "brlg", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x16000000, "ble", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* brle same as ble */
+ { 0x16000000, "brle", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x17000000, "bo", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* bt same as bo */
+ { 0x17000000, "bt", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ /* bro same as bo */
+ { 0x17000000, "bro", I_BASE, CTRL, 1, { 0, 0, 0 } },
+ { 0x18000000, "faultno", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ /* faultf same as faultno */
+ { 0x18000000, "faultf", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x19000000, "faultg", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x1a000000, "faulte", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x1b000000, "faultge", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x1c000000, "faultl", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x1d000000, "faultne", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x1e000000, "faultle", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ { 0x1f000000, "faulto", I_BASE, CTRL, 0, { 0, 0, 0 } },
+ /* faultt syn for faulto */
+ { 0x1f000000, "faultt", I_BASE, CTRL, 0, { 0, 0, 0 } },
+
+ { 0x01000000, "syscall", I_CASIM,CTRL, 0, { 0, 0, 0 } },
+
+ /* If a COBR (or COJ) has 3 operands, the last one is always a
+ * displacement and does not appear explicitly in the table.
+ */
+
+ { 0x20000000, "testno", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x21000000, "testg", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x22000000, "teste", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x23000000, "testge", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x24000000, "testl", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x25000000, "testne", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x26000000, "testle", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x27000000, "testo", I_BASE, COBR, 1, { R, 0, 0 } },
+ { 0x30000000, "bbc", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x31000000, "cmpobg", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x32000000, "cmpobe", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x33000000, "cmpobge", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x34000000, "cmpobl", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x35000000, "cmpobne", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x36000000, "cmpoble", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x37000000, "bbs", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x38000000, "cmpibno", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x39000000, "cmpibg", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x3a000000, "cmpibe", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x3b000000, "cmpibge", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x3c000000, "cmpibl", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x3d000000, "cmpibne", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x3e000000, "cmpible", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x3f000000, "cmpibo", I_BASE, COBR, 3, { RL, RS, 0 } },
+ { 0x31000000, "cmpojg", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x32000000, "cmpoje", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x33000000, "cmpojge", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x34000000, "cmpojl", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x35000000, "cmpojne", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x36000000, "cmpojle", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x38000000, "cmpijno", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x39000000, "cmpijg", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x3a000000, "cmpije", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x3b000000, "cmpijge", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x3c000000, "cmpijl", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x3d000000, "cmpijne", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x3e000000, "cmpijle", I_BASE, COJ, 3, { RL, RS, 0 } },
+ { 0x3f000000, "cmpijo", I_BASE, COJ, 3, { RL, RS, 0 } },
+
+ { 0x80000000, "ldob", I_BASE, MEM1, 2, { M, R, 0 } },
+ { 0x82000000, "stob", I_BASE, MEM1, 2, { R, M, 0 } },
+ { 0x84000000, "bx", I_BASE, MEM1, 1, { M, 0, 0 } },
+ { 0x85000000, "balx", I_BASE, MEM1, 2, { M, R, 0 } },
+ { 0x86000000, "callx", I_BASE, MEM1, 1, { M, 0, 0 } },
+ { 0x88000000, "ldos", I_BASE, MEM2, 2, { M, R, 0 } },
+ { 0x8a000000, "stos", I_BASE, MEM2, 2, { R, M, 0 } },
+ { 0x8c000000, "lda", I_BASE, MEM1, 2, { M, R, 0 } },
+ { 0x90000000, "ld", I_BASE, MEM4, 2, { M, R, 0 } },
+ { 0x92000000, "st", I_BASE, MEM4, 2, { R, M, 0 } },
+ { 0x98000000, "ldl", I_BASE, MEM8, 2, { M, R2, 0 } },
+ { 0x9a000000, "stl", I_BASE, MEM8, 2, { R2, M, 0 } },
+ { 0xa0000000, "ldt", I_BASE, MEM12, 2, { M, R4, 0 } },
+ { 0xa2000000, "stt", I_BASE, MEM12, 2, { R4, M, 0 } },
+ { 0xb0000000, "ldq", I_BASE, MEM16, 2, { M, R4, 0 } },
+ { 0xb2000000, "stq", I_BASE, MEM16, 2, { R4, M, 0 } },
+ { 0xc0000000, "ldib", I_BASE, MEM1, 2, { M, R, 0 } },
+ { 0xc2000000, "stib", I_BASE, MEM1, 2, { R, M, 0 } },
+ { 0xc8000000, "ldis", I_BASE, MEM2, 2, { M, R, 0 } },
+ { 0xca000000, "stis", I_BASE, MEM2, 2, { R, M, 0 } },
+
+ { R_3(0x580), "notbit", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x581), "and", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x582), "andnot", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x583), "setbit", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x584), "notand", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x586), "xor", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x587), "or", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x588), "nor", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x589), "xnor", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_2D(0x58a), "not", I_BASE, REG, 2, { RSL,RS, 0 } },
+ { R_3(0x58b), "ornot", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x58c), "clrbit", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x58d), "notor", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x58e), "nand", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x58f), "alterbit", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x590), "addo", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x591), "addi", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x592), "subo", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x593), "subi", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x598), "shro", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x59a), "shrdi", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x59b), "shri", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x59c), "shlo", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x59d), "rotate", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x59e), "shli", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_2(0x5a0), "cmpo", I_BASE, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x5a1), "cmpi", I_BASE, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x5a2), "concmpo", I_BASE, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x5a3), "concmpi", I_BASE, REG, 2, { RSL,RSL, 0 } },
+ { R_3(0x5a4), "cmpinco", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x5a5), "cmpinci", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x5a6), "cmpdeco", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x5a7), "cmpdeci", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_2(0x5ac), "scanbyte", I_BASE, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x5ae), "chkbit", I_BASE, REG, 2, { RSL,RSL, 0 } },
+ { R_3(0x5b0), "addc", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x5b2), "subc", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_2D(0x5cc), "mov", I_BASE, REG, 2, { RSL,RS, 0 } },
+ { R_2D(0x5dc), "movl", I_BASE, REG, 2, { RL2,R2, 0 } },
+ { R_2D(0x5ec), "movt", I_BASE, REG, 2, { RL4,R4, 0 } },
+ { R_2D(0x5fc), "movq", I_BASE, REG, 2, { RL4,R4, 0 } },
+ { R_3(0x610), "atmod", I_BASE, REG, 3, { RS, RSL,R } },
+ { R_3(0x612), "atadd", I_BASE, REG, 3, { RS, RSL,RS } },
+ { R_2D(0x640), "spanbit", I_BASE, REG, 2, { RSL,RS, 0 } },
+ { R_2D(0x641), "scanbit", I_BASE, REG, 2, { RSL,RS, 0 } },
+ { R_3(0x645), "modac", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x650), "modify", I_BASE, REG, 3, { RSL,RSL,R } },
+ { R_3(0x651), "extract", I_BASE, REG, 3, { RSL,RSL,R } },
+ { R_3(0x654), "modtc", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x655), "modpc", I_BASE, REG, 3, { RSL,RSL,R } },
+ { R_1(0x660), "calls", I_BASE, REG, 1, { RSL, 0, 0 } },
+ { R_0(0x66b), "mark", I_BASE, REG, 0, { 0, 0, 0 } },
+ { R_0(0x66c), "fmark", I_BASE, REG, 0, { 0, 0, 0 } },
+ { R_0(0x66d), "flushreg", I_BASE, REG, 0, { 0, 0, 0 } },
+ { R_0(0x66f), "syncf", I_BASE, REG, 0, { 0, 0, 0 } },
+ { R_3(0x670), "emul", I_BASE, REG, 3, { RSL,RSL,R2 } },
+ { R_3(0x671), "ediv", I_BASE, REG, 3, { RSL,RL2,RS } },
+ { R_2D(0x672), "cvtadr", I_CASIM,REG, 2, { RL, R2, 0 } },
+ { R_3(0x701), "mulo", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x708), "remo", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x70b), "divo", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x741), "muli", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x748), "remi", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x749), "modi", I_BASE, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x74b), "divi", I_BASE, REG, 3, { RSL,RSL,RS } },
+
+ /* Floating-point instructions */
+
+ { R_2D(0x674), "cvtir", I_FP, REG, 2, { RL, F, 0 } },
+ { R_2D(0x675), "cvtilr", I_FP, REG, 2, { RL, F, 0 } },
+ { R_3(0x676), "scalerl", I_FP, REG, 3, { RL, FL2,F2 } },
+ { R_3(0x677), "scaler", I_FP, REG, 3, { RL, FL, F } },
+ { R_3(0x680), "atanr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x681), "logepr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x682), "logr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x683), "remr", I_FP, REG, 3, { FL, FL, F } },
+ { R_2(0x684), "cmpor", I_FP, REG, 2, { FL, FL, 0 } },
+ { R_2(0x685), "cmpr", I_FP, REG, 2, { FL, FL, 0 } },
+ { R_2D(0x688), "sqrtr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x689), "expr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x68a), "logbnr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x68b), "roundr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x68c), "sinr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x68d), "cosr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x68e), "tanr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_1(0x68f), "classr", I_FP, REG, 1, { FL, 0, 0 } },
+ { R_3(0x690), "atanrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_3(0x691), "logeprl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_3(0x692), "logrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_3(0x693), "remrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_2(0x694), "cmporl", I_FP, REG, 2, { FL2,FL2, 0 } },
+ { R_2(0x695), "cmprl", I_FP, REG, 2, { FL2,FL2, 0 } },
+ { R_2D(0x698), "sqrtrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x699), "exprl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x69a), "logbnrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x69b), "roundrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x69c), "sinrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x69d), "cosrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x69e), "tanrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_1(0x69f), "classrl", I_FP, REG, 1, { FL2, 0, 0 } },
+ { R_2D(0x6c0), "cvtri", I_FP, REG, 2, { FL, R, 0 } },
+ { R_2D(0x6c1), "cvtril", I_FP, REG, 2, { FL, R2, 0 } },
+ { R_2D(0x6c2), "cvtzri", I_FP, REG, 2, { FL, R, 0 } },
+ { R_2D(0x6c3), "cvtzril", I_FP, REG, 2, { FL, R2, 0 } },
+ { R_2D(0x6c9), "movr", I_FP, REG, 2, { FL, F, 0 } },
+ { R_2D(0x6d9), "movrl", I_FP, REG, 2, { FL2,F2, 0 } },
+ { R_2D(0x6e1), "movre", I_FP, REG, 2, { FL4,F4, 0 } },
+ { R_3(0x6e2), "cpysre", I_FP, REG, 3, { FL4,FL4,F4 } },
+ { R_3(0x6e3), "cpyrsre", I_FP, REG, 3, { FL4,FL4,F4 } },
+ { R_3(0x78b), "divr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x78c), "mulr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x78d), "subr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x78f), "addr", I_FP, REG, 3, { FL, FL, F } },
+ { R_3(0x79b), "divrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_3(0x79c), "mulrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_3(0x79d), "subrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+ { R_3(0x79f), "addrl", I_FP, REG, 3, { FL2,FL2,F2 } },
+
+ /* These are the floating point branch instructions. Each actually
+ * generates 2 branch instructions: the first a CTRL instruction with
+ * the indicated opcode, and the second a 'bno'.
+ */
+
+ { 0x12000000, "brue", I_FP, FBRA, 1, { 0, 0, 0 } },
+ { 0x11000000, "brug", I_FP, FBRA, 1, { 0, 0, 0 } },
+ { 0x13000000, "bruge", I_FP, FBRA, 1, { 0, 0, 0 } },
+ { 0x14000000, "brul", I_FP, FBRA, 1, { 0, 0, 0 } },
+ { 0x16000000, "brule", I_FP, FBRA, 1, { 0, 0, 0 } },
+ { 0x15000000, "brulg", I_FP, FBRA, 1, { 0, 0, 0 } },
+
+
+ /* Decimal instructions */
+
+ { R_3(0x642), "daddc", I_DEC, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x643), "dsubc", I_DEC, REG, 3, { RSL,RSL,RS } },
+ { R_2D(0x644), "dmovt", I_DEC, REG, 2, { RSL,RS, 0 } },
+
+
+ /* KX extensions */
+
+ { R_2(0x600), "synmov", I_KX, REG, 2, { R, R, 0 } },
+ { R_2(0x601), "synmovl", I_KX, REG, 2, { R, R, 0 } },
+ { R_2(0x602), "synmovq", I_KX, REG, 2, { R, R, 0 } },
+ { R_2D(0x615), "synld", I_KX, REG, 2, { R, R, 0 } },
+
+
+ /* MC extensions */
+
+ { R_3(0x603), "cmpstr", I_MIL, REG, 3, { R, R, RL } },
+ { R_3(0x604), "movqstr", I_MIL, REG, 3, { R, R, RL } },
+ { R_3(0x605), "movstr", I_MIL, REG, 3, { R, R, RL } },
+ { R_2D(0x613), "inspacc", I_MIL, REG, 2, { R, R, 0 } },
+ { R_2D(0x614), "ldphy", I_MIL, REG, 2, { R, R, 0 } },
+ { R_3(0x617), "fill", I_MIL, REG, 3, { R, RL, RL } },
+ { R_2D(0x646), "condrec", I_MIL, REG, 2, { R, R, 0 } },
+ { R_2D(0x656), "receive", I_MIL, REG, 2, { R, R, 0 } },
+ { R_3(0x662), "send", I_MIL, REG, 3, { R, RL, R } },
+ { R_1(0x663), "sendserv", I_MIL, REG, 1, { R, 0, 0 } },
+ { R_1(0x664), "resumprcs", I_MIL, REG, 1, { R, 0, 0 } },
+ { R_1(0x665), "schedprcs", I_MIL, REG, 1, { R, 0, 0 } },
+ { R_0(0x666), "saveprcs", I_MIL, REG, 0, { 0, 0, 0 } },
+ { R_1(0x668), "condwait", I_MIL, REG, 1, { R, 0, 0 } },
+ { R_1(0x669), "wait", I_MIL, REG, 1, { R, 0, 0 } },
+ { R_1(0x66a), "signal", I_MIL, REG, 1, { R, 0, 0 } },
+ { R_1D(0x673), "ldtime", I_MIL, REG, 1, { R2, 0, 0 } },
+
+
+ /* CX extensions */
+
+ { R_3(0x5d8), "eshro", I_CX2, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x630), "sdma", I_CX, REG, 3, { RSL,RSL,RL } },
+ { R_3(0x631), "udma", I_CX, REG, 0, { 0, 0, 0 } },
+ { R_3(0x659), "sysctl", I_CX2, REG, 3, { RSL,RSL,RL } },
+
+
+ /* Jx extensions. */
+ { R_3(0x780), "addono", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x790), "addog", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7a0), "addoe", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7b0), "addoge", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7c0), "addol", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7d0), "addone", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7e0), "addole", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7f0), "addoo", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x781), "addino", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x791), "addig", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7a1), "addie", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7b1), "addige", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7c1), "addil", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7d1), "addine", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7e1), "addile", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7f1), "addio", I_JX, REG, 3, { RSL,RSL,RS } },
+
+ { R_2D(0x5ad), "bswap", I_JX, REG, 2, { RSL, RS, 0 } },
+
+ { R_2(0x594), "cmpob", I_JX, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x595), "cmpib", I_JX, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x596), "cmpos", I_JX, REG, 2, { RSL,RSL, 0 } },
+ { R_2(0x597), "cmpis", I_JX, REG, 2, { RSL,RSL, 0 } },
+
+ { R_3(0x784), "selno", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x794), "selg", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7a4), "sele", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7b4), "selge", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7c4), "sell", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7d4), "selne", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7e4), "selle", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7f4), "selo", I_JX, REG, 3, { RSL,RSL,RS } },
+
+ { R_3(0x782), "subono", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x792), "subog", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7a2), "suboe", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7b2), "suboge", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7c2), "subol", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7d2), "subone", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7e2), "subole", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7f2), "suboo", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x783), "subino", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x793), "subig", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7a3), "subie", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7b3), "subige", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7c3), "subil", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7d3), "subine", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7e3), "subile", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_3(0x7f3), "subio", I_JX, REG, 3, { RSL,RSL,RS } },
+
+ { R_3(0x65c), "dcctl", I_JX, REG, 3, { RSL,RSL,RL } },
+ { R_3(0x65b), "icctl", I_JX, REG, 3, { RSL,RSL,RS } },
+ { R_2D(0x658), "intctl", I_JX, REG, 2, { RSL, RS, 0 } },
+ { R_0(0x5b4), "intdis", I_JX, REG, 0, { 0, 0, 0 } },
+ { R_0(0x5b5), "inten", I_JX, REG, 0, { 0, 0, 0 } },
+ { R_0(0x65d), "halt", I_JX, REG, 1, { RSL, 0, 0 } },
+
+ /* Hx extensions. */
+ { 0xac000000, "dcinva", I_HX, MEM1, 1, { M, 0, 0 } },
+
+ /* END OF TABLE */
+
+ { 0, NULL, 0, 0, 0, { 0, 0, 0 } }
+};
+
+ /* end of i960-opcode.h */
diff --git a/include/opcode/m68k.h b/include/opcode/m68k.h
new file mode 100644
index 00000000000..ecb3f95dd96
--- /dev/null
+++ b/include/opcode/m68k.h
@@ -0,0 +1,315 @@
+/* Opcode table header for m680[01234]0/m6888[12]/m68851.
+ Copyright 1989, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation.
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+/* These are used as bit flags for the arch field in the m68k_opcode
+ structure. */
+#define _m68k_undef 0
+#define m68000 0x001
+#define m68008 m68000 /* synonym for -m68000. otherwise unused. */
+#define m68010 0x002
+#define m68020 0x004
+#define m68030 0x008
+#define m68ec030 m68030 /* similar enough to -m68030 to ignore differences;
+ gas will deal with the few differences. */
+#define m68040 0x010
+/* there is no 68050 */
+#define m68060 0x020
+#define m68881 0x040
+#define m68882 m68881 /* synonym for -m68881. otherwise unused. */
+#define m68851 0x080
+#define cpu32 0x100 /* e.g., 68332 */
+#define mcf5200 0x200
+
+ /* handy aliases */
+#define m68040up (m68040 | m68060)
+#define m68030up (m68030 | m68040up)
+#define m68020up (m68020 | m68030up)
+#define m68010up (m68010 | cpu32 | m68020up)
+#define m68000up (m68000 | m68010up)
+
+#define mfloat (m68881 | m68882 | m68040 | m68060)
+#define mmmu (m68851 | m68030 | m68040 | m68060)
+
+/* The structure used to hold information for an opcode. */
+
+struct m68k_opcode
+{
+ /* The opcode name. */
+ const char *name;
+ /* The opcode itself. */
+ unsigned long opcode;
+ /* The mask used by the disassembler. */
+ unsigned long match;
+ /* The arguments. */
+ const char *args;
+ /* The architectures which support this opcode. */
+ unsigned int arch;
+};
+
+/* The structure used to hold information for an opcode alias. */
+
+struct m68k_opcode_alias
+{
+ /* The alias name. */
+ const char *alias;
+ /* The instruction for which this is an alias. */
+ const char *primary;
+};
+
+/* We store four bytes of opcode for all opcodes because that is the
+ most any of them need. The actual length of an instruction is
+ always at least 2 bytes, and is as much longer as necessary to hold
+ the operands it has.
+
+ The match field is a mask saying which bits must match particular
+ opcode in order for an instruction to be an instance of that
+ opcode.
+
+ The args field is a string containing two characters for each
+ operand of the instruction. The first specifies the kind of
+ operand; the second, the place it is stored. */
+
+/* Kinds of operands:
+ Characters used: AaBCcDdFfIJkLlMmnOopQqRrSsTtUVvWXYZ0123|*~%;@!&$?/<>#^+-
+
+ D data register only. Stored as 3 bits.
+ A address register only. Stored as 3 bits.
+ a address register indirect only. Stored as 3 bits.
+ R either kind of register. Stored as 4 bits.
+ r either kind of register indirect only. Stored as 4 bits.
+ At the moment, used only for cas2 instruction.
+ F floating point coprocessor register only. Stored as 3 bits.
+ O an offset (or width): immediate data 0-31 or data register.
+ Stored as 6 bits in special format for BF... insns.
+ + autoincrement only. Stored as 3 bits (number of the address register).
+ - autodecrement only. Stored as 3 bits (number of the address register).
+ Q quick immediate data. Stored as 3 bits.
+ This matches an immediate operand only when value is in range 1 .. 8.
+ M moveq immediate data. Stored as 8 bits.
+ This matches an immediate operand only when value is in range -128..127
+ T trap vector immediate data. Stored as 4 bits.
+
+ k K-factor for fmove.p instruction. Stored as a 7-bit constant or
+ a three bit register offset, depending on the field type.
+
+ # immediate data. Stored in special places (b, w or l)
+ which say how many bits to store.
+ ^ immediate data for floating point instructions. Special places
+ are offset by 2 bytes from '#'...
+ B pc-relative address, converted to an offset
+ that is treated as immediate data.
+ d displacement and register. Stores the register as 3 bits
+ and stores the displacement in the entire second word.
+
+ C the CCR. No need to store it; this is just for filtering validity.
+ S the SR. No need to store, just as with CCR.
+ U the USP. No need to store, just as with CCR.
+
+ I Coprocessor ID. Not printed if 1. The Coprocessor ID is always
+ extracted from the 'd' field of word one, which means that an extended
+ coprocessor opcode can be skipped using the 'i' place, if needed.
+
+ s System Control register for the floating point coprocessor.
+
+ J Misc register for movec instruction, stored in 'j' format.
+ Possible values:
+ 0x000 SFC Source Function Code reg [60, 40, 30, 20, 10]
+ 0x001 DFC Data Function Code reg [60, 40, 30, 20, 10]
+ 0x002 CACR Cache Control Register [60, 40, 30, 20]
+ 0x003 TC MMU Translation Control [60, 40]
+ 0x004 ITT0 Instruction Transparent
+ Translation reg 0 [60, 40]
+ 0x005 ITT1 Instruction Transparent
+ Translation reg 1 [60, 40]
+ 0x006 DTT0 Data Transparent
+ Translation reg 0 [60, 40]
+ 0x007 DTT1 Data Transparent
+ Translation reg 1 [60, 40]
+ 0x008 BUSCR Bus Control Register [60]
+ 0x800 USP User Stack Pointer [60, 40, 30, 20, 10]
+ 0x801 VBR Vector Base reg [60, 40, 30, 20, 10]
+ 0x802 CAAR Cache Address Register [ 30, 20]
+ 0x803 MSP Master Stack Pointer [ 40, 30, 20]
+ 0x804 ISP Interrupt Stack Pointer [ 40, 30, 20]
+ 0x805 MMUSR MMU Status reg [ 40]
+ 0x806 URP User Root Pointer [60, 40]
+ 0x807 SRP Supervisor Root Pointer [60, 40]
+ 0x808 PCR Processor Configuration reg [60]
+ 0xC00 ROMBAR ROM Base Address Register [520X]
+ 0xC04 RAMBAR0 RAM Base Address Register 0 [520X]
+ 0xC05 RAMBAR1 RAM Base Address Register 0 [520X]
+ 0xC0F MBAR0 RAM Base Address Register 0 [520X]
+
+ L Register list of the type d0-d7/a0-a7 etc.
+ (New! Improved! Can also hold fp0-fp7, as well!)
+ The assembler tries to see if the registers match the insn by
+ looking at where the insn wants them stored.
+
+ l Register list like L, but with all the bits reversed.
+ Used for going the other way. . .
+
+ c cache identifier which may be "nc" for no cache, "ic"
+ for instruction cache, "dc" for data cache, or "bc"
+ for both caches. Used in cinv and cpush. Always
+ stored in position "d".
+
+ The remainder are all stored as 6 bits using an address mode and a
+ register number; they differ in which addressing modes they match.
+
+ * all (modes 0-6,7.0-4)
+ ~ alterable memory (modes 2-6,7.0,7.1)
+ (not 0,1,7.2-4)
+ % alterable (modes 0-6,7.0,7.1)
+ (not 7.2-4)
+ ; data (modes 0,2-6,7.0-4)
+ (not 1)
+ @ data, but not immediate (modes 0,2-6,7.0-3)
+ (not 1,7.4)
+ ! control (modes 2,5,6,7.0-3)
+ (not 0,1,3,4,7.4)
+ & alterable control (modes 2,5,6,7.0,7.1)
+ (not 0,1,7.2-4)
+ $ alterable data (modes 0,2-6,7.0,7.1)
+ (not 1,7.2-4)
+ ? alterable control, or data register (modes 0,2,5,6,7.0,7.1)
+ (not 1,3,4,7.2-4)
+ / control, or data register (modes 0,2,5,6,7.0-3)
+ (not 1,3,4,7.4)
+ > *save operands (modes 2,4,5,6,7.0,7.1)
+ (not 0,1,3,7.2-4)
+ < *restore operands (modes 2,3,5,6,7.0-3)
+ (not 0,1,4,7.4)
+
+ coldfire move operands:
+ m (modes 0-4)
+ n (modes 5,7.2)
+ o (modes 6,7.0,7.1,7.3,7.4)
+ p (modes 0-5)
+
+ coldfire bset/bclr/btst/mulsl/mulul operands:
+ q (modes 0,2-5)
+ v (modes 0,2-5,7.0,7.1)
+*/
+
+/* For the 68851: */
+/*
+ I didn't use much imagination in choosing the
+ following codes, so many of them aren't very
+ mnemonic. -rab
+
+ 0 32 bit pmmu register
+ Possible values:
+ 000 TC Translation Control Register (68030, 68851)
+
+ 1 16 bit pmmu register
+ 111 AC Access Control (68851)
+
+ 2 8 bit pmmu register
+ 100 CAL Current Access Level (68851)
+ 101 VAL Validate Access Level (68851)
+ 110 SCC Stack Change Control (68851)
+
+ 3 68030-only pmmu registers (32 bit)
+ 010 TT0 Transparent Translation reg 0
+ (aka Access Control reg 0 -- AC0 -- on 68ec030)
+ 011 TT1 Transparent Translation reg 1
+ (aka Access Control reg 1 -- AC1 -- on 68ec030)
+
+ W wide pmmu registers
+ Possible values:
+ 001 DRP Dma Root Pointer (68851)
+ 010 SRP Supervisor Root Pointer (68030, 68851)
+ 011 CRP Cpu Root Pointer (68030, 68851)
+
+ f function code register (68030, 68851)
+ 0 SFC
+ 1 DFC
+
+ V VAL register only (68851)
+
+ X BADx, BACx (16 bit)
+ 100 BAD Breakpoint Acknowledge Data (68851)
+ 101 BAC Breakpoint Acknowledge Control (68851)
+
+ Y PSR (68851) (MMUSR on 68030) (ACUSR on 68ec030)
+ Z PCSR (68851)
+
+ | memory (modes 2-6, 7.*)
+
+ t address test level (68030 only)
+ Stored as 3 bits, range 0-7.
+ Also used for breakpoint instruction now.
+
+*/
+
+/* Places to put an operand, for non-general operands:
+ s source, low bits of first word.
+ d dest, shifted 9 in first word
+ 1 second word, shifted 12
+ 2 second word, shifted 6
+ 3 second word, shifted 0
+ 4 third word, shifted 12
+ 5 third word, shifted 6
+ 6 third word, shifted 0
+ 7 second word, shifted 7
+ 8 second word, shifted 10
+ 9 second word, shifted 5
+ D store in both place 1 and place 3; for divul and divsl.
+ B first word, low byte, for branch displacements
+ W second word (entire), for branch displacements
+ L second and third words (entire), for branch displacements
+ (also overloaded for move16)
+ b second word, low byte
+ w second word (entire) [variable word/long branch offset for dbra]
+ W second word (entire) (must be signed 16 bit value)
+ l second and third word (entire)
+ g variable branch offset for bra and similar instructions.
+ The place to store depends on the magnitude of offset.
+ t store in both place 7 and place 8; for floating point operations
+ c branch offset for cpBcc operations.
+ The place to store is word two if bit six of word one is zero,
+ and words two and three if bit six of word one is one.
+ i Increment by two, to skip over coprocessor extended operands. Only
+ works with the 'I' format.
+ k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number.
+ Also used for dynamic fmovem instruction.
+ C floating point coprocessor constant - 7 bits. Also used for static
+ K-factors...
+ j Movec register #, stored in 12 low bits of second word.
+
+ Places to put operand, for general operands:
+ d destination, shifted 6 bits in first word
+ b source, at low bit of first word, and immediate uses one byte
+ w source, at low bit of first word, and immediate uses two bytes
+ l source, at low bit of first word, and immediate uses four bytes
+ s source, at low bit of first word.
+ Used sometimes in contexts where immediate is not allowed anyway.
+ f single precision float, low bit of 1st word, immediate uses 4 bytes
+ F double precision float, low bit of 1st word, immediate uses 8 bytes
+ x extended precision float, low bit of 1st word, immediate uses 12 bytes
+ p packed float, low bit of 1st word, immediate uses 12 bytes
+*/
+
+extern const struct m68k_opcode m68k_opcodes[];
+extern const struct m68k_opcode_alias m68k_opcode_aliases[];
+
+extern const int m68k_numopcodes, m68k_numaliases;
+
+/* end of m68k-opcode.h */
diff --git a/include/opcode/m88k.h b/include/opcode/m88k.h
new file mode 100644
index 00000000000..a17fa0361da
--- /dev/null
+++ b/include/opcode/m88k.h
@@ -0,0 +1,923 @@
+/* Table of opcodes for the motorola 88k family.
+ Copyright 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+
+This file is part of GDB and GAS.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+ * Disassembler Instruction Table
+ *
+ * The first field of the table is the opcode field. If an opcode
+ * is specified which has any non-opcode bits on, a system error
+ * will occur when the system attempts the install it into the
+ * instruction table. The second parameter is a pointer to the
+ * instruction mnemonic. Each operand is specified by offset, width,
+ * and type. The offset is the bit number of the least significant
+ * bit of the operand with bit 0 being the least significant bit of
+ * the instruction. The width is the number of bits used to specify
+ * the operand. The type specifies the output format to be used for
+ * the operand. The valid formats are: register, register indirect,
+ * hex constant, and bit field specification. The last field is a
+ * pointer to the next instruction in the linked list. These pointers
+ * are initialized by init_disasm().
+ *
+ * Structure Format
+ *
+ * struct INSTAB {
+ * UPINT opcode;
+ * char *mnemonic;
+ * struct OPSPEC op1,op2,op3;
+ * struct SIM_FLAGS flgs;
+ * struct INSTAB *next;
+ * }
+ *
+ * struct OPSPEC {
+ * UPINT offset:5;
+ * UPINT width:6;
+ * UPINT type:5;
+ * }
+ *
+ * Revision History
+ *
+ * Revision 1.0 11/08/85 Creation date
+ * 1.1 02/05/86 Updated instruction mnemonic table MD
+ * 1.2 06/16/86 Updated SIM_FLAGS for floating point
+ * 1.3 09/20/86 Updated for new encoding
+ * 05/11/89 R. Trawick adapted from Motorola disassembler
+ */
+
+#include <stdio.h>
+
+
+/*
+ * This file contains the structures and constants needed to build the M88000
+ * simulator. It is the main include file, containing all the
+ * structures, macros and definitions except for the floating point
+ * instruction set.
+ */
+
+/*
+ * The following flag informs the Simulator as to what type of byte ordering
+ * will be used. For instance, a BOFLAG = 1 indicates a DEC VAX and IBM type
+ * of ordering shall be used.
+*/
+
+/* # define BOFLAG 1 */ /* BYTE ORDERING FLAG */
+
+/* define the number of bits in the primary opcode field of the instruction,
+ * the destination field, the source 1 and source 2 fields.
+ */
+# define OP 8 /* size of opcode field */
+# define DEST 6 /* size of destination */
+# define SOURCE1 6 /* size of source1 */
+# define SOURCE2 6 /* size of source2 */
+
+# define REGs 32 /* number of registers */
+
+# define WORD long
+# define FLAG unsigned
+# define STATE short
+
+# define TRUE 1
+# define FALSE 0
+
+# define READ 0
+# define WRITE 1
+
+/* The next four equates define the priorities that the various classes
+ * of instructions have regarding writing results back into registers and
+ * signalling exceptions.
+ */
+/* PMEM is also defined in <sys/param.h> on Delta 88's. Sigh! */
+#undef PMEM
+
+# define PINT 0 /* Integer Priority */
+# define PFLT 1 /* Floating Point Priority */
+# define PMEM 2 /* Memory Priority */
+# define NA 3 /* Not Applicable, instruction doesnt write to regs */
+# define HIPRI 3 /* highest of these priorities */
+
+/* The instruction registers are an artificial mechanism to speed up
+ * simulator execution. In the real processor, an instruction register
+ * is 32 bits wide. In the simulator, the 32 bit instruction is kept in
+ * a structure field called rawop, and the instruction is partially decoded,
+ * and split into various fields and flags which make up the other fields
+ * of the structure.
+ * The partial decode is done when the instructions are initially loaded
+ * into simulator memory. The simulator code memory is not an array of
+ * 32 bit words, but is an array of instruction register structures.
+ * Yes this wastes memory, but it executes much quicker.
+ */
+
+struct IR_FIELDS {
+ unsigned op:OP,
+ dest: DEST,
+ src1: SOURCE1,
+ src2: SOURCE2;
+ int ltncy,
+ extime,
+ wb_pri; /* writeback priority */
+ unsigned imm_flags:2,/* immediate size */
+ rs1_used:1, /* register source 1 used */
+ rs2_used:1, /* register source 2 used */
+ rsd_used:1, /* register source/dest. used */
+ c_flag:1, /* complement */
+ u_flag:1, /* upper half word */
+ n_flag:1, /* execute next */
+ wb_flag:1, /* uses writeback slot */
+ dest_64:1, /* dest size */
+ s1_64:1, /* source 1 size */
+ s2_64:1, /* source 2 size */
+ scale_flag:1, /* scaled register */
+ brk_flg:1;
+ };
+
+struct mem_segs {
+ struct mem_wrd *seg; /* pointer (returned by calloc) to segment */
+ unsigned long baseaddr; /* base load address from file headers */
+ unsigned long endaddr; /* Ending address of segment */
+ int flags; /* segment control flags (none defined 12/5/86) */
+};
+
+#define MAXSEGS (10) /* max number of segment allowed */
+#define MEMSEGSIZE (sizeof(struct mem_segs))/* size of mem_segs structure */
+
+
+#define BRK_RD (0x01) /* break on memory read */
+#define BRK_WR (0x02) /* break on memory write */
+#define BRK_EXEC (0x04) /* break on execution */
+#define BRK_CNT (0x08) /* break on terminal count */
+
+
+struct mem_wrd {
+ struct IR_FIELDS opcode; /* simulator instruction break down */
+ union {
+ unsigned long l; /* memory element break down */
+ unsigned short s[2];
+ unsigned char c[4];
+ } mem;
+};
+
+#define MEMWRDSIZE (sizeof(struct mem_wrd)) /* size of each 32 bit memory model */
+
+/* External declarations */
+
+extern struct mem_segs memory[];
+extern struct PROCESSOR m78000;
+
+struct PROCESSOR {
+ unsigned WORD
+ ip, /* execute instruction pointer */
+ vbr, /* vector base register */
+ psr; /* processor status register */
+
+ WORD S1bus, /* source 1 */
+ S2bus, /* source 2 */
+ Dbus, /* destination */
+ DAbus, /* data address bus */
+ ALU,
+ Regs[REGs], /* data registers */
+ time_left[REGs], /* max clocks before reg is available */
+ wb_pri[REGs], /* writeback priority of reg */
+ SFU0_regs[REGs], /* integer unit control regs */
+ SFU1_regs[REGs], /* floating point control regs */
+ Scoreboard[REGs],
+ Vbr;
+ unsigned WORD scoreboard,
+ Psw,
+ Tpsw;
+ FLAG jump_pending:1; /* waiting for a jump instr. */
+ };
+
+# define i26bit 1 /* size of immediate field */
+# define i16bit 2
+# define i10bit 3
+
+/* Definitions for fields in psr */
+
+# define mode 31
+# define rbo 30
+# define ser 29
+# define carry 28
+# define sf7m 11
+# define sf6m 10
+# define sf5m 9
+# define sf4m 8
+# define sf3m 7
+# define sf2m 6
+# define sf1m 5
+# define mam 4
+# define inm 3
+# define exm 2
+# define trm 1
+# define ovfm 0
+
+#define MODEMASK (1<<(mode-1))
+# define SILENT 0 /* simulate without output to crt */
+# define VERBOSE 1 /* simulate in verbose mode */
+# define PR_INSTR 2 /* only print instructions */
+
+# define RESET 16 /* reset phase */
+
+# define PHASE1 0 /* data path phases */
+# define PHASE2 1
+
+/* the 1 clock operations */
+
+# define ADDU 1
+# define ADDC 2
+# define ADDUC 3
+# define ADD 4
+
+# define SUBU ADD+1
+# define SUBB ADD+2
+# define SUBUB ADD+3
+# define SUB ADD+4
+
+# define AND_ ADD+5
+# define OR ADD+6
+# define XOR ADD+7
+# define CMP ADD+8
+
+/* the LOADS */
+
+# define LDAB CMP+1
+# define LDAH CMP+2
+# define LDA CMP+3
+# define LDAD CMP+4
+
+# define LDB LDAD+1
+# define LDH LDAD+2
+# define LD LDAD+3
+# define LDD LDAD+4
+# define LDBU LDAD+5
+# define LDHU LDAD+6
+
+/* the STORES */
+
+# define STB LDHU+1
+# define STH LDHU+2
+# define ST LDHU+3
+# define STD LDHU+4
+
+/* the exchange */
+
+# define XMEMBU LDHU+5
+# define XMEM LDHU+6
+
+/* the branches */
+# define JSR STD+1
+# define BSR STD+2
+# define BR STD+3
+# define JMP STD+4
+# define BB1 STD+5
+# define BB0 STD+6
+# define RTN STD+7
+# define BCND STD+8
+
+/* the TRAPS */
+# define TB1 BCND+1
+# define TB0 BCND+2
+# define TCND BCND+3
+# define RTE BCND+4
+# define TBND BCND+5
+
+/* the MISC instructions */
+# define MUL TBND + 1
+# define DIV MUL +2
+# define DIVU MUL +3
+# define MASK MUL +4
+# define FF0 MUL +5
+# define FF1 MUL +6
+# define CLR MUL +7
+# define SET MUL +8
+# define EXT MUL +9
+# define EXTU MUL +10
+# define MAK MUL +11
+# define ROT MUL +12
+
+/* control register manipulations */
+
+# define LDCR ROT +1
+# define STCR ROT +2
+# define XCR ROT +3
+
+# define FLDCR ROT +4
+# define FSTCR ROT +5
+# define FXCR ROT +6
+
+
+# define NOP XCR +1
+
+/* floating point instructions */
+
+# define FADD NOP +1
+# define FSUB NOP +2
+# define FMUL NOP +3
+# define FDIV NOP +4
+# define FSQRT NOP +5
+# define FCMP NOP +6
+# define FIP NOP +7
+# define FLT NOP +8
+# define INT NOP +9
+# define NINT NOP +10
+# define TRNC NOP +11
+# define FLDC NOP +12
+# define FSTC NOP +13
+# define FXC NOP +14
+
+# define UEXT(src,off,wid) ((((unsigned int)(src))>>(off)) & ((1<<(wid)) - 1))
+# define SEXT(src,off,wid) (((((int)(src))<<(32-((off)+(wid)))) >>(32-(wid))) )
+# define MAKE(src,off,wid) \
+ ((((unsigned int)(src)) & ((1<<(wid)) - 1)) << (off))
+
+# define opword(n) (unsigned long) (memaddr->mem.l)
+
+/* Constants and Masks */
+
+#define SFU0 0x80000000
+#define SFU1 0x84000000
+#define SFU7 0x9c000000
+#define RRI10 0xf0000000
+#define RRR 0xf4000000
+#define SFUMASK 0xfc00ffe0
+#define RRRMASK 0xfc00ffe0
+#define RRI10MASK 0xfc00fc00
+#define DEFMASK 0xfc000000
+#define CTRL 0x0000f000
+#define CTRLMASK 0xfc00f800
+
+/* Operands types */
+
+enum operand_type {
+ HEX = 1,
+ REG = 2,
+ CONT = 3,
+ IND = 3,
+ BF = 4,
+ REGSC = 5 /* scaled register */,
+ CRREG = 6 /* control register */,
+ FCRREG = 7 /* floating point control register */,
+ PCREL = 8,
+ CONDMASK = 9,
+ XREG = 10, /* extended register */
+ DEC = 11, /* decimal */
+};
+
+/* Hashing Specification */
+
+#define HASHVAL 79
+
+/* Type definitions */
+
+typedef unsigned int UINT;
+
+/* Structure templates */
+
+#if never
+typedef struct {
+ unsigned int offset:5;
+ unsigned int width:6;
+ unsigned int type:5;
+} OPSPEC;
+#endif
+
+typedef struct {
+ unsigned int offset;
+ unsigned int width;
+ enum operand_type type;
+} OPSPEC;
+
+ struct SIM_FLAGS {
+ int ltncy, /* latency (max number of clocks needed to execute) */
+ extime, /* execution time (min number of clocks needed to execute) */
+ wb_pri; /* writeback slot priority */
+ unsigned op:OP, /* simulator version of opcode */
+ imm_flags:2, /* 10,16 or 26 bit immediate flags */
+ rs1_used:1, /* register source 1 used */
+ rs2_used:1, /* register source 2 used */
+ rsd_used:1, /* register source/dest used */
+ c_flag:1, /* complement */
+ u_flag:1, /* upper half word */
+ n_flag:1, /* execute next */
+ wb_flag:1, /* uses writeback slot */
+ dest_64:1, /* double precision dest */
+ s1_64:1, /* double precision source 1 */
+ s2_64:1, /* double precision source 2 */
+ scale_flag:1; /* register is scaled */
+};
+
+typedef struct INSTRUCTAB {
+ unsigned int opcode;
+ char *mnemonic;
+ OPSPEC op1,op2,op3;
+ struct SIM_FLAGS flgs;
+ struct INSTRUCTAB *next;
+} INSTAB;
+
+
+#define NO_OPERAND {0,0,0}
+
+/* Opcode Mnemonic Op 1 Spec Op 2 Spec Op 3 Spec Simflags Next */
+
+static INSTAB instructions[] = {
+ {0xf400c800,"jsr ",{0,5,REG} ,NO_OPERAND ,NO_OPERAND , {2,2,NA,JSR , 0,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xf400cc00,"jsr.n ",{0,5,REG} ,NO_OPERAND ,NO_OPERAND , {1,1,NA,JSR , 0,0,1,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xf400c000,"jmp ",{0,5,REG} ,NO_OPERAND ,NO_OPERAND , {2,2,NA,JMP , 0,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xf400c400,"jmp.n ",{0,5,REG} ,NO_OPERAND ,NO_OPERAND , {1,1,NA,JMP , 0,0,1,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xc8000000,"bsr ",{0,26,PCREL},NO_OPERAND ,NO_OPERAND , {2,2,NA,BSR , i26bit,0,0,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xcc000000,"bsr.n ",{0,26,PCREL},NO_OPERAND ,NO_OPERAND , {1,1,NA,BSR , i26bit,0,0,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xc0000000,"br ",{0,26,PCREL},NO_OPERAND ,NO_OPERAND , {2,2,NA,BR , i26bit,0,0,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xc4000000,"br.n ",{0,26,PCREL},NO_OPERAND ,NO_OPERAND , {1,1,NA,BR , i26bit,0,0,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xd0000000,"bb0 ",{21,5,HEX} ,{16,5,REG} ,{0,16,PCREL},{2,2,NA,BB0, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xd4000000,"bb0.n ",{21,5,HEX} ,{16,5,REG} ,{0,16,PCREL},{1,1,NA,BB0, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xd8000000,"bb1 ",{21,5,HEX},{16,5,REG} ,{0,16,PCREL},{2,2,NA,BB1, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xdc000000,"bb1.n ",{21,5,HEX},{16,5,REG} ,{0,16,PCREL},{1,1,NA,BB1, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xf000d000,"tb0 ",{21,5,HEX} ,{16,5,REG} ,{0,10,HEX}, {2,2,NA,TB0 , i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xf000d800,"tb1 ",{21,5,HEX} ,{16,5,REG} ,{0,10,HEX}, {2,2,NA,TB1 , i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xe8000000,"bcnd ",{21,5,CONDMASK},{16,5,REG},{0,16,PCREL},{2,2,NA,BCND, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xec000000,"bcnd.n ",{21,5,CONDMASK},{16,5,REG},{0,16,PCREL},{1,1,NA,BCND, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL },
+ {0xf000e800,"tcnd ",{21,5,CONDMASK},{16,5,REG},{0,10,HEX}, {2,2,NA,TCND, i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xf8000000,"tbnd ",{16,5,REG} ,{0,16,HEX} ,NO_OPERAND , {2,2,NA,TBND, i10bit,1,0,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xf400f800,"tbnd ",{16,5,REG} ,{0,5,REG} ,NO_OPERAND , {2,2,NA,TBND, 0,1,1,0,0,0,0,1,0,0,0,0}, NULL },
+ {0xf400fc00,"rte ",NO_OPERAND ,NO_OPERAND ,NO_OPERAND , {2,2,NA,RTE , 0,0,0,0,0,0,0,1,0,0,0,0}, NULL },
+ {0x1c000000,"ld.b ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDB ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001c00,"ld.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDB , 0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0x0c000000,"ld.bu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDBU, i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4000c00,"ld.bu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDBU ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0x18000000,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDH ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001800,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDH ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001a00,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDH ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL },
+ {0x08000000,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDHU, i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4000800,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDHU ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4000a00,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDHU ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL },
+ {0x14000000,"ld ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LD ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001400,"ld ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001600,"ld ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL },
+ {0x10000000,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDD ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001000,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001200,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL },
+ {0xf4001500,"ld.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4001700,"ld.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL },
+ {0x2c000000,"st.b ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STB ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4002c00,"st.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STB ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0x28000000,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STH ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4002800,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STH ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4002a00,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,STH ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL },
+ {0x24000000,"st ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,ST ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL },
+ {0xf4002400,"st ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0xf4002600,"st ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL },
+ {0x20000000,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STD ,i16bit,0,1,0,0,0,0,1,0,0,0,0} ,NULL },
+ {0xf4002000,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STD ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0xf4002200,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,STD ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL },
+ {0xf4002500,"st.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0xf4002700,"st.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL },
+/* m88100 only:
+ {0x00000000,"xmem.bu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,XMEMBU ,i16bit,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ */
+ {0xf4000000,"xmem.bu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+/* m88100 only:
+ {0x04000000,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,XMEM ,i16bit,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ */
+ {0xf4000400,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0xf4000600,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL },
+ {0xf4000500,"xmem.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0xf4000700,"xmem.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL },
+/* m88100 only:
+ {0xf4003e00,"lda.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL },
+ */
+ {0xf4003e00,"lda.x ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL },
+ {0xf4003a00,"lda.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL },
+ {0xf4003600,"lda ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDA , 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL },
+ {0xf4003200,"lda.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAD, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL },
+
+ {0x80004000,"ldcr ",{21,5,REG} ,{5,6,CRREG} ,NO_OPERAND ,{1,1,PINT,LDCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x80008000,"stcr ",{16,5,REG} ,{5,6,CRREG} ,NO_OPERAND ,{1,1,PINT,STCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x8000c000,"xcr ",{21,5,REG} ,{16,5,REG} ,{5,6,CRREG},{1,1,PINT,XCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+
+ {0xf4006000,"addu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006200,"addu.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006100,"addu.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006300,"addu.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006400,"subu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006600,"subu.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006500,"subu.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006700,"subu.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006800,"divu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {32,32,PINT,DIVU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4006900,"divu.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, NULL },
+ {0xf4006e00,"muls ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, NULL },
+ {0xf4006c00,"mulu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,4,PINT,MUL, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007000,"add ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007200,"add.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007100,"add.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007300,"add.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007400,"sub ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007600,"sub.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007500,"sub.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007700,"sub.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007800,"divs ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {32,32,PINT,DIV , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4007c00,"cmp ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,CMP, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+
+ {0x60000000,"addu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,ADDU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x64000000,"subu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,SUBU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+
+ {0x68000000,"divu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {32,32,PINT,DIVU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x6c000000,"mulu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {4,1,PINT,MUL, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x70000000,"add ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,ADD, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x74000000,"sub ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,SUB, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x78000000,"divs ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {32,32,PINT,DIV, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x7c000000,"cmp ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,CMP, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+
+ {0xf4004000,"and ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,AND_ ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4004400,"and.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,AND_ ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL },
+ {0xf4005800,"or ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,OR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4005c00,"or.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,OR ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL },
+ {0xf4005000,"xor ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,XOR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4005400,"xor.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,XOR ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL },
+ {0x40000000,"and ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,AND_ ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x44000000,"and.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,AND_ ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL },
+ {0x58000000,"or ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,OR ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x5c000000,"or.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,OR ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL },
+ {0x50000000,"xor ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,XOR ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x54000000,"xor.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,XOR ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL },
+ {0x48000000,"mask ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,MASK ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0x4c000000,"mask.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,MASK ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL },
+ {0xf400ec00,"ff0 ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {1,1,PINT,FF0 ,0,0,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf400e800,"ff1 ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {1,1,PINT,FF1 ,0,0,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf0008000,"clr ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,CLR ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf0008800,"set ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,SET ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf0009000,"ext ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,EXT ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf0009800,"extu ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,EXTU ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf000a000,"mak ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,MAK ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf000a800,"rot ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,ROT ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4008000,"clr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,CLR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4008800,"set ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SET ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4009000,"ext ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,EXT ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf4009800,"extu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,EXTU ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf400a000,"mak ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,MAK ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+ {0xf400a800,"rot ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ROT ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL },
+
+ {0x84002800,"fadd.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FADD ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84002880,"fadd.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL },
+ {0x84002a00,"fadd.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL },
+ {0x84002a80,"fadd.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL },
+ {0x84002820,"fadd.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x840028a0,"fadd.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL },
+ {0x84002a20,"fadd.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL },
+ {0x84002aa0,"fadd.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL },
+ {0x84003000,"fsub.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84003080,"fsub.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL },
+ {0x84003200,"fsub.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL },
+ {0x84003280,"fsub.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL },
+ {0x84003020,"fsub.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x840030a0,"fsub.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL },
+ {0x84003220,"fsub.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL },
+ {0x840032a0,"fsub.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL },
+ {0x84000000,"fmul.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84000080,"fmul.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL },
+ {0x84000200,"fmul.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL },
+ {0x84000280,"fmul.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL },
+ {0x84000020,"fmul.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x840000a0,"fmul.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL },
+ {0x84000220,"fmul.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL },
+ {0x840002a0,"fmul.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL },
+ {0x84007000,"fdiv.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {30,30,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84007080,"fdiv.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL },
+ {0x84007200,"fdiv.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL },
+ {0x84007280,"fdiv.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL },
+ {0x84007020,"fdiv.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x840070a0,"fdiv.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL },
+ {0x84007220,"fdiv.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL },
+ {0x840072a0,"fdiv.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL },
+ {0x84007800,"fsqrt.ss ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84007820,"fsqrt.sd ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84007880,"fsqrt.ds ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x840078a0,"fsqrt.dd ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {6,1,PFLT,FLT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x84003800,"fcmp.ss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84003880,"fcmp.sd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL },
+ {0x84003a00,"fcmp.ds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x84003a80,"fcmp.dd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL },
+ {0x84002000,"flt.s ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84002020,"flt.d ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {6,1,PFLT,FLT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x84004800,"int.s ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,INT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84004880,"int.d ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {6,1,PFLT,INT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x84005000,"nint.s ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,INT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84005080,"nint.d ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {6,1,PFLT,INT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL },
+ {0x84005800,"trnc.s ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {5,1,PFLT,TRNC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x84005880,"trnc.d ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND , {6,1,PFLT,TRNC ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL },
+
+ {0x80004800,"fldcr ",{21,5,REG} ,{5,6,FCRREG} ,NO_OPERAND , {1,1,PFLT,FLDC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x80008800,"fstcr ",{16,5,REG} ,{5,6,FCRREG} ,NO_OPERAND , {1,1,PFLT,FSTC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+ {0x8000c800,"fxcr ",{21,5,REG} ,{16,5,REG} ,{5,6,FCRREG} , {1,1,PFLT,FXC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL },
+
+/* The following are new for the 88110. */
+
+ {0x8400aaa0,"fadd.ddd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400aa80,"fadd.dds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400aac0,"fadd.ddx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400aa20,"fadd.dsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400aa00,"fadd.dss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400aa40,"fadd.dsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ab20,"fadd.dxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ab00,"fadd.dxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ab40,"fadd.dxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a8a0,"fadd.sdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a880,"fadd.sds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a8c0,"fadd.sdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a820,"fadd.ssd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a800,"fadd.sss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a840,"fadd.ssx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a920,"fadd.sxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a900,"fadd.sxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400a940,"fadd.sxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400aca0,"fadd.xdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ac80,"fadd.xds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400acc0,"fadd.xdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ac20,"fadd.xsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ac00,"fadd.xss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ac40,"fadd.xsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ad20,"fadd.xxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ad00,"fadd.xxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ad40,"fadd.xxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400ba80,"fcmp.sdd ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ba00,"fcmp.sds ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bb00,"fcmp.sdx ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b880,"fcmp.ssd ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b800,"fcmp.sss ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b900,"fcmp.ssx ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bc80,"fcmp.sxd ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bc00,"fcmp.sxs ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bd00,"fcmp.sxx ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400baa0,"fcmpu.sdd ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400ba20,"fcmpu.sds ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bb20,"fcmpu.sdx ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b8a0,"fcmpu.ssd ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b820,"fcmpu.sss ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b920,"fcmpu.ssx ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bca0,"fcmpu.sxd ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bc20,"fcmpu.sxs ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400bd20,"fcmpu.sxx ",{21,5,REG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x84000820,"fcvt.sd ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84000880,"fcvt.ds ",{21,5,REG} ,{0,5,REG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x84008880,"fcvt.ds ",{21,5,XREG} ,{0,5,XREG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x840088c0,"fcvt.dx ",{21,5,XREG} ,{0,5,XREG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008820,"fcvt.sd ",{21,5,XREG} ,{0,5,XREG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008840,"fcvt.sx ",{21,5,XREG} ,{0,5,XREG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008920,"fcvt.xd ",{21,5,XREG} ,{0,5,XREG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008900,"fcvt.xs ",{21,5,XREG} ,{0,5,XREG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400f2a0,"fdiv.ddd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f280,"fdiv.dds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f2c0,"fdiv.ddx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f220,"fdiv.dsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f200,"fdiv.dss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f240,"fdiv.dsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f320,"fdiv.dxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f300,"fdiv.dxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f340,"fdiv.dxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f0a0,"fdiv.sdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f080,"fdiv.sds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f0c0,"fdiv.sdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f020,"fdiv.ssd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f000,"fdiv.sss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f040,"fdiv.ssx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f120,"fdiv.sxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f100,"fdiv.sxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f140,"fdiv.sxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f4a0,"fdiv.xdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f480,"fdiv.xds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f4c0,"fdiv.xdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f420,"fdiv.xsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f400,"fdiv.xss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f440,"fdiv.xsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f520,"fdiv.xxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f500,"fdiv.xxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f540,"fdiv.xxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x84002220,"flt.ds ",{21,5,XREG} ,{0,5,REG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84002200,"flt.ss ",{21,5,XREG} ,{0,5,REG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84002240,"flt.xs ",{21,5,XREG} ,{0,5,REG} ,NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x840082a0,"fmul.ddd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008280,"fmul.dds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x840082c0,"fmul.ddx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008220,"fmul.dsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008200,"fmul.dss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008240,"fmul.dsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008320,"fmul.dxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008300,"fmul.dxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008340,"fmul.dxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x840080a0,"fmul.sdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008080,"fmul.sds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x840080c0,"fmul.sdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008020,"fmul.ssd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008000,"fmul.sss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008040,"fmul.ssx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008120,"fmul.sxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008100,"fmul.sxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008140,"fmul.sxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x840084a0,"fmul.xdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008480,"fmul.xds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x840084c0,"fmul.xdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008420,"fmul.xsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008400,"fmul.xss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008440,"fmul.xsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008520,"fmul.xxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008500,"fmul.xxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84008540,"fmul.xxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400f8a0,"fsqrt.dd ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f880,"fsqrt.ds ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f8c0,"fsqrt.dx ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f820,"fsqrt.sd ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f800,"fsqrt.ss ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f840,"fsqrt.sx ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f920,"fsqrt.xd ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f900,"fsqrt.xs ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400f940,"fsqrt.xx ",{21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400b2a0,"fsub.ddd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b280,"fsub.dds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b2c0,"fsub.ddx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b220,"fsub.dsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b200,"fsub.dss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b240,"fsub.dsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b320,"fsub.dxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b300,"fsub.dxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b340,"fsub.dxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b0a0,"fsub.sdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b080,"fsub.sds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b0c0,"fsub.sdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b020,"fsub.ssd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b000,"fsub.sss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b040,"fsub.ssx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b120,"fsub.sxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b100,"fsub.sxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b140,"fsub.sxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b4a0,"fsub.xdd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b480,"fsub.xds ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b4c0,"fsub.xdx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b420,"fsub.xsd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b400,"fsub.xss ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b440,"fsub.xsx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b520,"fsub.xxd ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b500,"fsub.xxs ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400b540,"fsub.xxx ",{21,5,XREG} ,{16,5,XREG} ,{0,5,XREG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400fc00,"illop", {0,2,DEC}, NO_OPERAND, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400c800,"int.ss ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400c880,"int.sd ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400c900,"int.sx ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x04000000,"ld ", {21,5,XREG}, {16,5,REG}, {0,16,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x00000000,"ld.d ", {21,5,XREG}, {16,5,REG}, {0,16,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x3c000000,"ld.x ", {21,5,XREG}, {16,5,REG}, {0,16,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf0001400,"ld ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001000,"ld.d ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001800,"ld.x ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001500,"ld.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001100,"ld.d.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001900,"ld.x.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf0001600,"ld ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001200,"ld.d ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001a00,"ld.x ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001700,"ld.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001300,"ld.d.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0001b00,"ld.x.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400c000,"mov.s ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400c080,"mov.d ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84004200,"mov.s ", {21,5,XREG}, {0,5,REG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x84004280,"mov.d ", {21,5,XREG}, {0,5,REG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400c300,"mov ", {21,5,XREG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf4006d00,"mulu.d ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400d080,"nint.sd ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400d000,"nint.ss ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400d100,"nint.sx ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88002020,"padd.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88002040,"padd.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88002060,"padd ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x880021e0,"padds.s ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880021a0,"padds.s.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880021c0,"padds.s.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880020e0,"padds.u ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880020a0,"padds.u.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880020c0,"padds.u.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88002160,"padds.us ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88002120,"padds.us.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88002140,"padds.us.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88003860,"pcmp ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88000000,"pmul ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88006260,"ppack.16 ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88006240,"ppack.16.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88006460,"ppack.32 ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88006420,"ppack.32.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88006440,"ppack.32.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88006160,"ppack.8 ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88007200,"prot ", {21,5,REG}, {16,5,REG}, {5,6,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88007800,"prot ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88003020,"psub.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88003040,"psub.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88003060,"psub ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x880031e0,"psubs.s ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880031a0,"psubs.s.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880031c0,"psubs.s.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880030e0,"psubs.u ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880030a0,"psubs.u.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x880030c0,"psubs.u.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88003160,"psubs.us ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88003120,"psubs.us.b ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88003140,"psubs.us.h ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x88006800,"punpk.n ", {21,5,REG}, {16,5,REG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x88006820,"punpk.b ", {21,5,REG}, {16,5,REG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x34000000,"st ", {21,5,XREG}, {16,5,REG}, {0,16,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x30000000,"st.d ", {21,5,XREG}, {16,5,REG}, {0,16,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x38000000,"st.x ", {21,5,XREG}, {16,5,REG}, {0,16,HEX}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf4002c80,"st.b.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002880,"st.h.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002480,"st.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002080,"st.d.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002d80,"st.b.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002980,"st.h.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002580,"st.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002180,"st.d.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf0002400,"st ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002000,"st.d ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002100,"st.d.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002180,"st.d.usr.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002080,"st.d.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002500,"st.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002580,"st.usr.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002480,"st.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002800,"st.x ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002900,"st.x.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002980,"st.x.usr.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002880,"st.x.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REG}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf4002f80,"st.b.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002e80,"st.b.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002380,"st.d.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002280,"st.d.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002b80,"st.h.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002a80,"st.h.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002780,"st.usr.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf4002680,"st.wt ", {21,5,REG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0xf0002600,"st ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002200,"st.d ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002300,"st.d.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002380,"st.d.usr.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002280,"st.d.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002700,"st.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002780,"st.usr.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002680,"st.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002a00,"st.x ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002b00,"st.x.usr ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002b80,"st.x.usr.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0xf0002a80,"st.x.wt ", {21,5,XREG}, {16,5,REG}, {0,5,REGSC}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+ {0x8400d880,"trnc.sd ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400d800,"trnc.ss ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+ {0x8400d900,"trnc.sx ", {21,5,REG}, {0,5,XREG}, NO_OPERAND, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL },
+
+};
+
+/*
+ * Local Variables:
+ * fill-column: 131
+ * End:
+ */
diff --git a/include/opcode/mips.h b/include/opcode/mips.h
new file mode 100644
index 00000000000..f0a8c7ef9f2
--- /dev/null
+++ b/include/opcode/mips.h
@@ -0,0 +1,723 @@
+/* mips.h. Mips opcode list for GDB, the GNU debugger.
+ Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Contributed by Ralph Campbell and OSF
+ Commented and modified by Ian Lance Taylor, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _MIPS_H_
+#define _MIPS_H_
+
+/* These are bit masks and shift counts to use to access the various
+ fields of an instruction. To retrieve the X field of an
+ instruction, use the expression
+ (i >> OP_SH_X) & OP_MASK_X
+ To set the same field (to j), use
+ i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
+
+ Make sure you use fields that are appropriate for the instruction,
+ of course.
+
+ The 'i' format uses OP, RS, RT and IMMEDIATE.
+
+ The 'j' format uses OP and TARGET.
+
+ The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
+
+ The 'b' format uses OP, RS, RT and DELTA.
+
+ The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
+
+ The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
+
+ A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
+ breakpoint instruction are not defined; Kane says the breakpoint
+ code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
+ only use ten bits). An optional two-operand form of break/sdbbp
+ allows the lower ten bits to be set too.
+
+ The syscall instruction uses SYSCALL.
+
+ The general coprocessor instructions use COPZ. */
+
+#define OP_MASK_OP 0x3f
+#define OP_SH_OP 26
+#define OP_MASK_RS 0x1f
+#define OP_SH_RS 21
+#define OP_MASK_FR 0x1f
+#define OP_SH_FR 21
+#define OP_MASK_FMT 0x1f
+#define OP_SH_FMT 21
+#define OP_MASK_BCC 0x7
+#define OP_SH_BCC 18
+#define OP_MASK_CODE 0x3ff
+#define OP_SH_CODE 16
+#define OP_MASK_CODE2 0x3ff
+#define OP_SH_CODE2 6
+#define OP_MASK_RT 0x1f
+#define OP_SH_RT 16
+#define OP_MASK_FT 0x1f
+#define OP_SH_FT 16
+#define OP_MASK_CACHE 0x1f
+#define OP_SH_CACHE 16
+#define OP_MASK_RD 0x1f
+#define OP_SH_RD 11
+#define OP_MASK_FS 0x1f
+#define OP_SH_FS 11
+#define OP_MASK_PREFX 0x1f
+#define OP_SH_PREFX 11
+#define OP_MASK_CCC 0x7
+#define OP_SH_CCC 8
+#define OP_MASK_SYSCALL 0xfffff
+#define OP_SH_SYSCALL 6
+#define OP_MASK_SHAMT 0x1f
+#define OP_SH_SHAMT 6
+#define OP_MASK_FD 0x1f
+#define OP_SH_FD 6
+#define OP_MASK_TARGET 0x3ffffff
+#define OP_SH_TARGET 0
+#define OP_MASK_COPZ 0x1ffffff
+#define OP_SH_COPZ 0
+#define OP_MASK_IMMEDIATE 0xffff
+#define OP_SH_IMMEDIATE 0
+#define OP_MASK_DELTA 0xffff
+#define OP_SH_DELTA 0
+#define OP_MASK_FUNCT 0x3f
+#define OP_SH_FUNCT 0
+#define OP_MASK_SPEC 0x3f
+#define OP_SH_SPEC 0
+#define OP_SH_LOCC 8 /* FP condition code */
+#define OP_SH_HICC 18 /* FP condition code */
+#define OP_MASK_CC 0x7
+#define OP_SH_COP1NORM 25 /* Normal COP1 encoding */
+#define OP_MASK_COP1NORM 0x1 /* a single bit */
+#define OP_SH_COP1SPEC 21 /* COP1 encodings */
+#define OP_MASK_COP1SPEC 0xf
+#define OP_MASK_COP1SCLR 0x4
+#define OP_MASK_COP1CMP 0x3
+#define OP_SH_COP1CMP 4
+#define OP_SH_FORMAT 21 /* FP short format field */
+#define OP_MASK_FORMAT 0x7
+#define OP_SH_TRUE 16
+#define OP_MASK_TRUE 0x1
+#define OP_SH_GE 17
+#define OP_MASK_GE 0x01
+#define OP_SH_UNSIGNED 16
+#define OP_MASK_UNSIGNED 0x1
+#define OP_SH_HINT 16
+#define OP_MASK_HINT 0x1f
+#define OP_SH_MMI 0 /* Multimedia (parallel) op */
+#define OP_MASK_MMI 0x3f
+#define OP_SH_MMISUB 6
+#define OP_MASK_MMISUB 0x1f
+#define OP_MASK_PERFREG 0x1f /* Performance monitoring */
+#define OP_SH_PERFREG 1
+
+/* This structure holds information for a particular instruction. */
+
+struct mips_opcode
+{
+ /* The name of the instruction. */
+ const char *name;
+ /* A string describing the arguments for this instruction. */
+ const char *args;
+ /* The basic opcode for the instruction. When assembling, this
+ opcode is modified by the arguments to produce the actual opcode
+ that is used. If pinfo is INSN_MACRO, then this is 0. */
+ unsigned long match;
+ /* If pinfo is not INSN_MACRO, then this is a bit mask for the
+ relevant portions of the opcode when disassembling. If the
+ actual opcode anded with the match field equals the opcode field,
+ then we have found the correct instruction. If pinfo is
+ INSN_MACRO, then this field is the macro identifier. */
+ unsigned long mask;
+ /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
+ of bits describing the instruction, notably any relevant hazard
+ information. */
+ unsigned long pinfo;
+ /* A collection of bits describing the instruction sets of which this
+ instruction or macro is a member. */
+ unsigned long membership;
+};
+
+/* These are the characters which may appears in the args field of an
+ instruction. They appear in the order in which the fields appear
+ when the instruction is used. Commas and parentheses in the args
+ string are ignored when assembling, and written into the output
+ when disassembling.
+
+ Each of these characters corresponds to a mask field defined above.
+
+ "<" 5 bit shift amount (OP_*_SHAMT)
+ ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
+ "a" 26 bit target address (OP_*_TARGET)
+ "b" 5 bit base register (OP_*_RS)
+ "c" 10 bit breakpoint code (OP_*_CODE)
+ "d" 5 bit destination register specifier (OP_*_RD)
+ "h" 5 bit prefx hint (OP_*_PREFX)
+ "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
+ "j" 16 bit signed immediate (OP_*_DELTA)
+ "k" 5 bit cache opcode in target register position (OP_*_CACHE)
+ "o" 16 bit signed offset (OP_*_DELTA)
+ "p" 16 bit PC relative branch target address (OP_*_DELTA)
+ "q" 10 bit extra breakpoint code (OP_*_CODE2)
+ "r" 5 bit same register used as both source and target (OP_*_RS)
+ "s" 5 bit source register specifier (OP_*_RS)
+ "t" 5 bit target register (OP_*_RT)
+ "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
+ "v" 5 bit same register used as both source and destination (OP_*_RS)
+ "w" 5 bit same register used as both target and destination (OP_*_RT)
+ "C" 25 bit coprocessor function code (OP_*_COPZ)
+ "B" 20 bit syscall function code (OP_*_SYSCALL)
+ "x" accept and ignore register name
+ "z" must be zero register
+
+ Floating point instructions:
+ "D" 5 bit destination register (OP_*_FD)
+ "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
+ "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
+ "S" 5 bit fs source 1 register (OP_*_FS)
+ "T" 5 bit ft source 2 register (OP_*_FT)
+ "R" 5 bit fr source 3 register (OP_*_FR)
+ "V" 5 bit same register used as floating source and destination (OP_*_FS)
+ "W" 5 bit same register used as floating target and destination (OP_*_FT)
+
+ Coprocessor instructions:
+ "E" 5 bit target register (OP_*_RT)
+ "G" 5 bit destination register (OP_*_RD)
+ "P" 5 bit performance-monitor register (OP_*_PERFREG)
+
+ Macro instructions:
+ "A" General 32 bit expression
+ "I" 32 bit immediate
+ "F" 64 bit floating point constant in .rdata
+ "L" 64 bit floating point constant in .lit8
+ "f" 32 bit floating point constant
+ "l" 32 bit floating point constant in .lit4
+
+ Other:
+ "()" parens surrounding optional value
+ "," separates operands
+
+ Characters used so far, for quick reference when adding more:
+ "<>(),"
+ "ABCDEFGILMNSTRVW"
+ "abcdfhijklopqrstuvwxz"
+*/
+
+/* These are the bits which may be set in the pinfo field of an
+ instructions, if it is not equal to INSN_MACRO. */
+
+/* Modifies the general purpose register in OP_*_RD. */
+#define INSN_WRITE_GPR_D 0x00000001
+/* Modifies the general purpose register in OP_*_RT. */
+#define INSN_WRITE_GPR_T 0x00000002
+/* Modifies general purpose register 31. */
+#define INSN_WRITE_GPR_31 0x00000004
+/* Modifies the floating point register in OP_*_FD. */
+#define INSN_WRITE_FPR_D 0x00000008
+/* Modifies the floating point register in OP_*_FS. */
+#define INSN_WRITE_FPR_S 0x00000010
+/* Modifies the floating point register in OP_*_FT. */
+#define INSN_WRITE_FPR_T 0x00000020
+/* Reads the general purpose register in OP_*_RS. */
+#define INSN_READ_GPR_S 0x00000040
+/* Reads the general purpose register in OP_*_RT. */
+#define INSN_READ_GPR_T 0x00000080
+/* Reads the floating point register in OP_*_FS. */
+#define INSN_READ_FPR_S 0x00000100
+/* Reads the floating point register in OP_*_FT. */
+#define INSN_READ_FPR_T 0x00000200
+/* Reads the floating point register in OP_*_FR. */
+#define INSN_READ_FPR_R 0x00000400
+/* Modifies coprocessor condition code. */
+#define INSN_WRITE_COND_CODE 0x00000800
+/* Reads coprocessor condition code. */
+#define INSN_READ_COND_CODE 0x00001000
+/* TLB operation. */
+#define INSN_TLB 0x00002000
+/* Reads coprocessor register other than floating point register. */
+#define INSN_COP 0x00004000
+/* Instruction loads value from memory, requiring delay. */
+#define INSN_LOAD_MEMORY_DELAY 0x00008000
+/* Instruction loads value from coprocessor, requiring delay. */
+#define INSN_LOAD_COPROC_DELAY 0x00010000
+/* Instruction has unconditional branch delay slot. */
+#define INSN_UNCOND_BRANCH_DELAY 0x00020000
+/* Instruction has conditional branch delay slot. */
+#define INSN_COND_BRANCH_DELAY 0x00040000
+/* Conditional branch likely: if branch not taken, insn nullified. */
+#define INSN_COND_BRANCH_LIKELY 0x00080000
+/* Moves to coprocessor register, requiring delay. */
+#define INSN_COPROC_MOVE_DELAY 0x00100000
+/* Loads coprocessor register from memory, requiring delay. */
+#define INSN_COPROC_MEMORY_DELAY 0x00200000
+/* Reads the HI register. */
+#define INSN_READ_HI 0x00400000
+/* Reads the LO register. */
+#define INSN_READ_LO 0x00800000
+/* Modifies the HI register. */
+#define INSN_WRITE_HI 0x01000000
+/* Modifies the LO register. */
+#define INSN_WRITE_LO 0x02000000
+/* Takes a trap (easier to keep out of delay slot). */
+#define INSN_TRAP 0x04000000
+/* Instruction stores value into memory. */
+#define INSN_STORE_MEMORY 0x08000000
+/* Instruction uses single precision floating point. */
+#define FP_S 0x10000000
+/* Instruction uses double precision floating point. */
+#define FP_D 0x20000000
+/* Instruction is part of the tx39's integer multiply family. */
+#define INSN_MULT 0x40000000
+/* Instruction synchronize shared memory. */
+#define INSN_SYNC 0x80000000
+
+/* Instruction is actually a macro. It should be ignored by the
+ disassembler, and requires special treatment by the assembler. */
+#define INSN_MACRO 0xffffffff
+
+
+
+
+
+/* MIPS ISA field--CPU level at which insn is supported. */
+#define INSN_ISA 0x0000000F
+/* An instruction which is not part of any basic MIPS ISA.
+ (ie it is a chip specific instruction) */
+#define INSN_NO_ISA 0x00000000
+/* MIPS ISA 1 instruction. */
+#define INSN_ISA1 0x00000001
+/* MIPS ISA 2 instruction (R6000 or R4000). */
+#define INSN_ISA2 0x00000002
+/* MIPS ISA 3 instruction (R4000). */
+#define INSN_ISA3 0x00000003
+/* MIPS ISA 4 instruction (R8000). */
+#define INSN_ISA4 0x00000004
+
+/* Chip specific instructions. These are bitmasks. */
+/* MIPS R4650 instruction. */
+#define INSN_4650 0x00000010
+/* LSI R4010 instruction. */
+#define INSN_4010 0x00000020
+/* NEC VR4100 instruction. */
+#define INSN_4100 0x00000040
+/* Toshiba R3900 instruction. */
+#define INSN_3900 0x00000080
+
+
+/* This is a list of macro expanded instructions.
+ *
+ * _I appended means immediate
+ * _A appended means address
+ * _AB appended means address with base register
+ * _D appended means 64 bit floating point constant
+ * _S appended means 32 bit floating point constant
+ */
+enum {
+ M_ABS,
+ M_ADD_I,
+ M_ADDU_I,
+ M_AND_I,
+ M_BEQ,
+ M_BEQ_I,
+ M_BEQL_I,
+ M_BGE,
+ M_BGEL,
+ M_BGE_I,
+ M_BGEL_I,
+ M_BGEU,
+ M_BGEUL,
+ M_BGEU_I,
+ M_BGEUL_I,
+ M_BGT,
+ M_BGTL,
+ M_BGT_I,
+ M_BGTL_I,
+ M_BGTU,
+ M_BGTUL,
+ M_BGTU_I,
+ M_BGTUL_I,
+ M_BLE,
+ M_BLEL,
+ M_BLE_I,
+ M_BLEL_I,
+ M_BLEU,
+ M_BLEUL,
+ M_BLEU_I,
+ M_BLEUL_I,
+ M_BLT,
+ M_BLTL,
+ M_BLT_I,
+ M_BLTL_I,
+ M_BLTU,
+ M_BLTUL,
+ M_BLTU_I,
+ M_BLTUL_I,
+ M_BNE,
+ M_BNE_I,
+ M_BNEL_I,
+ M_DABS,
+ M_DADD_I,
+ M_DADDU_I,
+ M_DDIV_3,
+ M_DDIV_3I,
+ M_DDIVU_3,
+ M_DDIVU_3I,
+ M_DIV_3,
+ M_DIV_3I,
+ M_DIVU_3,
+ M_DIVU_3I,
+ M_DLA_AB,
+ M_DLI,
+ M_DMUL,
+ M_DMUL_I,
+ M_DMULO,
+ M_DMULO_I,
+ M_DMULOU,
+ M_DMULOU_I,
+ M_DREM_3,
+ M_DREM_3I,
+ M_DREMU_3,
+ M_DREMU_3I,
+ M_DSUB_I,
+ M_DSUBU_I,
+ M_DSUBU_I_2,
+ M_J_A,
+ M_JAL_1,
+ M_JAL_2,
+ M_JAL_A,
+ M_L_DOB,
+ M_L_DAB,
+ M_LA_AB,
+ M_LB_A,
+ M_LB_AB,
+ M_LBU_A,
+ M_LBU_AB,
+ M_LD_A,
+ M_LD_OB,
+ M_LD_AB,
+ M_LDC1_AB,
+ M_LDC2_AB,
+ M_LDC3_AB,
+ M_LDL_AB,
+ M_LDR_AB,
+ M_LH_A,
+ M_LH_AB,
+ M_LHU_A,
+ M_LHU_AB,
+ M_LI,
+ M_LI_D,
+ M_LI_DD,
+ M_LI_S,
+ M_LI_SS,
+ M_LL_AB,
+ M_LLD_AB,
+ M_LS_A,
+ M_LW_A,
+ M_LW_AB,
+ M_LWC0_A,
+ M_LWC0_AB,
+ M_LWC1_A,
+ M_LWC1_AB,
+ M_LWC2_A,
+ M_LWC2_AB,
+ M_LWC3_A,
+ M_LWC3_AB,
+ M_LWL_A,
+ M_LWL_AB,
+ M_LWR_A,
+ M_LWR_AB,
+ M_LWU_AB,
+ M_MUL,
+ M_MUL_I,
+ M_MULO,
+ M_MULO_I,
+ M_MULOU,
+ M_MULOU_I,
+ M_NOR_I,
+ M_OR_I,
+ M_REM_3,
+ M_REM_3I,
+ M_REMU_3,
+ M_REMU_3I,
+ M_ROL,
+ M_ROL_I,
+ M_ROR,
+ M_ROR_I,
+ M_S_DA,
+ M_S_DOB,
+ M_S_DAB,
+ M_S_S,
+ M_SC_AB,
+ M_SCD_AB,
+ M_SD_A,
+ M_SD_OB,
+ M_SD_AB,
+ M_SDC1_AB,
+ M_SDC2_AB,
+ M_SDC3_AB,
+ M_SDL_AB,
+ M_SDR_AB,
+ M_SEQ,
+ M_SEQ_I,
+ M_SGE,
+ M_SGE_I,
+ M_SGEU,
+ M_SGEU_I,
+ M_SGT,
+ M_SGT_I,
+ M_SGTU,
+ M_SGTU_I,
+ M_SLE,
+ M_SLE_I,
+ M_SLEU,
+ M_SLEU_I,
+ M_SLT_I,
+ M_SLTU_I,
+ M_SNE,
+ M_SNE_I,
+ M_SB_A,
+ M_SB_AB,
+ M_SH_A,
+ M_SH_AB,
+ M_SW_A,
+ M_SW_AB,
+ M_SWC0_A,
+ M_SWC0_AB,
+ M_SWC1_A,
+ M_SWC1_AB,
+ M_SWC2_A,
+ M_SWC2_AB,
+ M_SWC3_A,
+ M_SWC3_AB,
+ M_SWL_A,
+ M_SWL_AB,
+ M_SWR_A,
+ M_SWR_AB,
+ M_SUB_I,
+ M_SUBU_I,
+ M_SUBU_I_2,
+ M_TEQ_I,
+ M_TGE_I,
+ M_TGEU_I,
+ M_TLT_I,
+ M_TLTU_I,
+ M_TNE_I,
+ M_TRUNCWD,
+ M_TRUNCWS,
+ M_ULD,
+ M_ULD_A,
+ M_ULH,
+ M_ULH_A,
+ M_ULHU,
+ M_ULHU_A,
+ M_ULW,
+ M_ULW_A,
+ M_USH,
+ M_USH_A,
+ M_USW,
+ M_USW_A,
+ M_USD,
+ M_USD_A,
+ M_XOR_I,
+ M_COP0,
+ M_COP1,
+ M_COP2,
+ M_COP3,
+ M_NUM_MACROS
+};
+
+
+/* The order of overloaded instructions matters. Label arguments and
+ register arguments look the same. Instructions that can have either
+ for arguments must apear in the correct order in this table for the
+ assembler to pick the right one. In other words, entries with
+ immediate operands must apear after the same instruction with
+ registers.
+
+ Many instructions are short hand for other instructions (i.e., The
+ jal <register> instruction is short for jalr <register>). */
+
+extern const struct mips_opcode mips_builtin_opcodes[];
+extern const int bfd_mips_num_builtin_opcodes;
+extern struct mips_opcode *mips_opcodes;
+extern int bfd_mips_num_opcodes;
+#define NUMOPCODES bfd_mips_num_opcodes
+
+
+/* The rest of this file adds definitions for the mips16 TinyRISC
+ processor. */
+
+/* These are the bitmasks and shift counts used for the different
+ fields in the instruction formats. Other than OP, no masks are
+ provided for the fixed portions of an instruction, since they are
+ not needed.
+
+ The I format uses IMM11.
+
+ The RI format uses RX and IMM8.
+
+ The RR format uses RX, and RY.
+
+ The RRI format uses RX, RY, and IMM5.
+
+ The RRR format uses RX, RY, and RZ.
+
+ The RRI_A format uses RX, RY, and IMM4.
+
+ The SHIFT format uses RX, RY, and SHAMT.
+
+ The I8 format uses IMM8.
+
+ The I8_MOVR32 format uses RY and REGR32.
+
+ The IR_MOV32R format uses REG32R and MOV32Z.
+
+ The I64 format uses IMM8.
+
+ The RI64 format uses RY and IMM5.
+ */
+
+#define MIPS16OP_MASK_OP 0x1f
+#define MIPS16OP_SH_OP 11
+#define MIPS16OP_MASK_IMM11 0x7ff
+#define MIPS16OP_SH_IMM11 0
+#define MIPS16OP_MASK_RX 0x7
+#define MIPS16OP_SH_RX 8
+#define MIPS16OP_MASK_IMM8 0xff
+#define MIPS16OP_SH_IMM8 0
+#define MIPS16OP_MASK_RY 0x7
+#define MIPS16OP_SH_RY 5
+#define MIPS16OP_MASK_IMM5 0x1f
+#define MIPS16OP_SH_IMM5 0
+#define MIPS16OP_MASK_RZ 0x7
+#define MIPS16OP_SH_RZ 2
+#define MIPS16OP_MASK_IMM4 0xf
+#define MIPS16OP_SH_IMM4 0
+#define MIPS16OP_MASK_REGR32 0x1f
+#define MIPS16OP_SH_REGR32 0
+#define MIPS16OP_MASK_REG32R 0x1f
+#define MIPS16OP_SH_REG32R 3
+#define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
+#define MIPS16OP_MASK_MOVE32Z 0x7
+#define MIPS16OP_SH_MOVE32Z 0
+#define MIPS16OP_MASK_IMM6 0x3f
+#define MIPS16OP_SH_IMM6 5
+
+/* These are the characters which may appears in the args field of an
+ instruction. They appear in the order in which the fields appear
+ when the instruction is used. Commas and parentheses in the args
+ string are ignored when assembling, and written into the output
+ when disassembling.
+
+ "y" 3 bit register (MIPS16OP_*_RY)
+ "x" 3 bit register (MIPS16OP_*_RX)
+ "z" 3 bit register (MIPS16OP_*_RZ)
+ "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
+ "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
+ "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
+ "0" zero register ($0)
+ "S" stack pointer ($sp or $29)
+ "P" program counter
+ "R" return address register ($ra or $31)
+ "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
+ "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
+ "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
+ "a" 26 bit jump address
+ "e" 11 bit extension value
+ "l" register list for entry instruction
+ "L" register list for exit instruction
+
+ The remaining codes may be extended. Except as otherwise noted,
+ the full extended operand is a 16 bit signed value.
+ "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
+ ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
+ "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
+ "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
+ "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
+ "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
+ "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
+ "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
+ "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
+ "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
+ "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
+ "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
+ "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
+ "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
+ "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
+ "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
+ "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
+ "q" 11 bit branch address (MIPS16OP_*_IMM11)
+ "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
+ "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
+ "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
+ */
+
+/* For the mips16, we use the same opcode table format and a few of
+ the same flags. However, most of the flags are different. */
+
+/* Modifies the register in MIPS16OP_*_RX. */
+#define MIPS16_INSN_WRITE_X 0x00000001
+/* Modifies the register in MIPS16OP_*_RY. */
+#define MIPS16_INSN_WRITE_Y 0x00000002
+/* Modifies the register in MIPS16OP_*_RZ. */
+#define MIPS16_INSN_WRITE_Z 0x00000004
+/* Modifies the T ($24) register. */
+#define MIPS16_INSN_WRITE_T 0x00000008
+/* Modifies the SP ($29) register. */
+#define MIPS16_INSN_WRITE_SP 0x00000010
+/* Modifies the RA ($31) register. */
+#define MIPS16_INSN_WRITE_31 0x00000020
+/* Modifies the general purpose register in MIPS16OP_*_REG32R. */
+#define MIPS16_INSN_WRITE_GPR_Y 0x00000040
+/* Reads the register in MIPS16OP_*_RX. */
+#define MIPS16_INSN_READ_X 0x00000080
+/* Reads the register in MIPS16OP_*_RY. */
+#define MIPS16_INSN_READ_Y 0x00000100
+/* Reads the register in MIPS16OP_*_MOVE32Z. */
+#define MIPS16_INSN_READ_Z 0x00000200
+/* Reads the T ($24) register. */
+#define MIPS16_INSN_READ_T 0x00000400
+/* Reads the SP ($29) register. */
+#define MIPS16_INSN_READ_SP 0x00000800
+/* Reads the RA ($31) register. */
+#define MIPS16_INSN_READ_31 0x00001000
+/* Reads the program counter. */
+#define MIPS16_INSN_READ_PC 0x00002000
+/* Reads the general purpose register in MIPS16OP_*_REGR32. */
+#define MIPS16_INSN_READ_GPR_X 0x00004000
+/* Is a branch insn. */
+#define MIPS16_INSN_BRANCH 0x00010000
+
+/* The following flags have the same value for the mips16 opcode
+ table:
+ INSN_UNCOND_BRANCH_DELAY
+ INSN_COND_BRANCH_DELAY
+ INSN_COND_BRANCH_LIKELY (never used)
+ INSN_READ_HI
+ INSN_READ_LO
+ INSN_WRITE_HI
+ INSN_WRITE_LO
+ INSN_TRAP
+ INSN_ISA3
+ */
+
+extern const struct mips_opcode mips16_opcodes[];
+extern const int bfd_mips16_num_opcodes;
+
+#endif /* _MIPS_H_ */
diff --git a/include/opcode/mn10200.h b/include/opcode/mn10200.h
new file mode 100644
index 00000000000..42fa94b0c6e
--- /dev/null
+++ b/include/opcode/mn10200.h
@@ -0,0 +1,110 @@
+/* mn10200.h -- Header file for Matsushita 10200 opcode table
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+ Written by Jeff Law, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef MN10200_H
+#define MN10200_H
+
+/* The opcode table is an array of struct mn10200_opcode. */
+
+struct mn10200_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* The opcode itself. Those bits which will be filled in with
+ operands are zeroes. */
+ unsigned long opcode;
+
+ /* The opcode mask. This is used by the disassembler. This is a
+ mask containing ones indicating those bits which must match the
+ opcode field, and zeroes indicating those bits which need not
+ match (and are presumably filled in by operands). */
+ unsigned long mask;
+
+ /* The format of this opcode. */
+ unsigned char format;
+
+ /* An array of operand codes. Each code is an index into the
+ operand table. They appear in the order which the operands must
+ appear in assembly code, and are terminated by a zero. */
+ unsigned char operands[8];
+};
+
+/* The table itself is sorted by major opcode number, and is otherwise
+ in the order in which the disassembler should consider
+ instructions. */
+extern const struct mn10200_opcode mn10200_opcodes[];
+extern const int mn10200_num_opcodes;
+
+
+/* The operands table is an array of struct mn10200_operand. */
+
+struct mn10200_operand
+{
+ /* The number of bits in the operand. */
+ int bits;
+
+ /* How far the operand is left shifted in the instruction. */
+ int shift;
+
+ /* One bit syntax flags. */
+ int flags;
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the mn10200_opcodes table. */
+
+extern const struct mn10200_operand mn10200_operands[];
+
+/* Values defined for the flags field of a struct mn10200_operand. */
+#define MN10200_OPERAND_DREG 0x1
+
+#define MN10200_OPERAND_AREG 0x2
+
+#define MN10200_OPERAND_PSW 0x4
+
+#define MN10200_OPERAND_MDR 0x8
+
+#define MN10200_OPERAND_SIGNED 0x10
+
+#define MN10200_OPERAND_PROMOTE 0x20
+
+#define MN10200_OPERAND_PAREN 0x40
+
+#define MN10200_OPERAND_REPEATED 0x80
+
+#define MN10200_OPERAND_EXTENDED 0x100
+
+#define MN10200_OPERAND_NOCHECK 0x200
+
+#define MN10200_OPERAND_PCREL 0x400
+
+#define MN10200_OPERAND_MEMADDR 0x800
+
+#define MN10200_OPERAND_RELAX 0x1000
+
+#define FMT_1 1
+#define FMT_2 2
+#define FMT_3 3
+#define FMT_4 4
+#define FMT_5 5
+#define FMT_6 6
+#define FMT_7 7
+#endif /* MN10200_H */
diff --git a/include/opcode/mn10300.h b/include/opcode/mn10300.h
new file mode 100644
index 00000000000..34e4b0b438f
--- /dev/null
+++ b/include/opcode/mn10300.h
@@ -0,0 +1,138 @@
+/* mn10300.h -- Header file for Matsushita 10300 opcode table
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+ Written by Jeff Law, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef MN10300_H
+#define MN10300_H
+
+/* The opcode table is an array of struct mn10300_opcode. */
+
+#define MN10300_MAX_OPERANDS 8
+struct mn10300_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* The opcode itself. Those bits which will be filled in with
+ operands are zeroes. */
+ unsigned long opcode;
+
+ /* The opcode mask. This is used by the disassembler. This is a
+ mask containing ones indicating those bits which must match the
+ opcode field, and zeroes indicating those bits which need not
+ match (and are presumably filled in by operands). */
+ unsigned long mask;
+
+ /* A bitmask. For each operand, nonzero if it must not have the same
+ register specification as all other operands with a nonzero bit in
+ this flag. ie 0x81 would indicate that operands 7 and 0 must not
+ match. Note that we count operands from left to right as they appear
+ in the operands specification below. */
+ unsigned int no_match_operands;
+
+ /* The format of this opcode. */
+ unsigned char format;
+
+ /* Bitmask indicating what cpu variants this opcode is available on.
+ We assume mn10300 base opcodes are available everywhere, so we only
+ have to note opcodes which are available on other variants. */
+ unsigned int machine;
+
+ /* An array of operand codes. Each code is an index into the
+ operand table. They appear in the order which the operands must
+ appear in assembly code, and are terminated by a zero. */
+ unsigned char operands[MN10300_MAX_OPERANDS];
+};
+
+/* The table itself is sorted by major opcode number, and is otherwise
+ in the order in which the disassembler should consider
+ instructions. */
+extern const struct mn10300_opcode mn10300_opcodes[];
+extern const int mn10300_num_opcodes;
+
+
+/* The operands table is an array of struct mn10300_operand. */
+
+struct mn10300_operand
+{
+ /* The number of bits in the operand. */
+ int bits;
+
+ /* How far the operand is left shifted in the instruction. */
+ int shift;
+
+ /* One bit syntax flags. */
+ int flags;
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the mn10300_opcodes table. */
+
+extern const struct mn10300_operand mn10300_operands[];
+
+/* Values defined for the flags field of a struct mn10300_operand. */
+#define MN10300_OPERAND_DREG 0x1
+
+#define MN10300_OPERAND_AREG 0x2
+
+#define MN10300_OPERAND_SP 0x4
+
+#define MN10300_OPERAND_PSW 0x8
+
+#define MN10300_OPERAND_MDR 0x10
+
+#define MN10300_OPERAND_SIGNED 0x20
+
+#define MN10300_OPERAND_PROMOTE 0x40
+
+#define MN10300_OPERAND_PAREN 0x80
+
+#define MN10300_OPERAND_REPEATED 0x100
+
+#define MN10300_OPERAND_EXTENDED 0x200
+
+#define MN10300_OPERAND_SPLIT 0x400
+
+#define MN10300_OPERAND_REG_LIST 0x800
+
+#define MN10300_OPERAND_PCREL 0x1000
+
+#define MN10300_OPERAND_MEMADDR 0x2000
+
+#define MN10300_OPERAND_RELAX 0x4000
+
+
+/* Opcode Formats. */
+#define FMT_S0 1
+#define FMT_S1 2
+#define FMT_S2 3
+#define FMT_S4 4
+#define FMT_S6 5
+#define FMT_D0 6
+#define FMT_D1 7
+#define FMT_D2 8
+#define FMT_D4 9
+#define FMT_D5 10
+
+/* Variants of the mn10300 which have additional opcodes. */
+#define MN103 300
+#define AM30 300
+
+
+#endif /* MN10300_H */
diff --git a/include/opcode/np1.h b/include/opcode/np1.h
new file mode 100644
index 00000000000..d23adc7566c
--- /dev/null
+++ b/include/opcode/np1.h
@@ -0,0 +1,422 @@
+/* Print GOULD NPL instructions for GDB, the GNU debugger.
+ Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+GDB 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 1, or (at your option)
+any later version.
+
+GDB 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 GDB; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+struct gld_opcode
+{
+ char *name;
+ unsigned long opcode;
+ unsigned long mask;
+ char *args;
+ int length;
+};
+
+/* We store four bytes of opcode for all opcodes because that
+ is the most any of them need. The actual length of an instruction
+ is always at least 2 bytes, and at most four. The length of the
+ instruction is based on the opcode.
+
+ The mask component is a mask saying which bits must match
+ particular opcode in order for an instruction to be an instance
+ of that opcode.
+
+ The args component is a string containing characters
+ that are used to format the arguments to the instruction. */
+
+/* Kinds of operands:
+ r Register in first field
+ R Register in second field
+ b Base register in first field
+ B Base register in second field
+ v Vector register in first field
+ V Vector register in first field
+ A Optional address register (base register)
+ X Optional index register
+ I Immediate data (16bits signed)
+ O Offset field (16bits signed)
+ h Offset field (15bits signed)
+ d Offset field (14bits signed)
+ S Shift count field
+
+ any other characters are printed as is...
+*/
+
+/* The assembler requires that this array be sorted as follows:
+ all instances of the same mnemonic must be consecutive.
+ All instances of the same mnemonic with the same number of operands
+ must be consecutive.
+ */
+struct gld_opcode gld_opcodes[] =
+{
+{ "lb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lnb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lbs", 0xec080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 },
+{ "lnh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "lw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lnw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "ld", 0xb4000002, 0xfc080002, "r,xOA,X", 4 },
+{ "lnd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "li", 0xf8000000, 0xfc7f0000, "r,I", 4 },
+{ "lpa", 0x50080000, 0xfc080000, "r,xOA,X", 4 },
+{ "la", 0x50000000, 0xfc080000, "r,xOA,X", 4 },
+{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 },
+{ "lbp", 0x90080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lhp", 0x90000001, 0xfc080001, "r,xOA,X", 4 },
+{ "lwp", 0x90000000, 0xfc080000, "r,xOA,X", 4 },
+{ "ldp", 0x90000002, 0xfc080002, "r,xOA,X", 4 },
+{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 },
+{ "lf", 0xbc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lfbr", 0xbc080000, 0xfc080000, "b,xOA,X", 4 },
+{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 },
+{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 },
+{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 },
+{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "stfbr", 0xdc080000, 0xfc080000, "b,xOA,X", 4 },
+{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 },
+{ "zmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "zmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "zmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "zmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "stbp", 0x94080000, 0xfc080000, "r,xOA,X", 4 },
+{ "sthp", 0x94000001, 0xfc080001, "r,xOA,X", 4 },
+{ "stwp", 0x94000000, 0xfc080000, "r,xOA,X", 4 },
+{ "stdp", 0x94000002, 0xfc080002, "r,xOA,X", 4 },
+{ "lil", 0xf80b0000, 0xfc7f0000, "r,D", 4 },
+{ "lwsl1", 0xec000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lwsl2", 0xfc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lwsl3", 0xfc080000, 0xfc080000, "r,xOA,X", 4 },
+
+{ "lvb", 0xb0080000, 0xfc080000, "v,xOA,X", 4 },
+{ "lvh", 0xb0000001, 0xfc080001, "v,xOA,X", 4 },
+{ "lvw", 0xb0000000, 0xfc080000, "v,xOA,X", 4 },
+{ "lvd", 0xb0000002, 0xfc080002, "v,xOA,X", 4 },
+{ "liv", 0x3c040000, 0xfc0f0000, "v,R", 2 },
+{ "livf", 0x3c080000, 0xfc0f0000, "v,R", 2 },
+{ "stvb", 0xd0080000, 0xfc080000, "v,xOA,X", 4 },
+{ "stvh", 0xd0000001, 0xfc080001, "v,xOA,X", 4 },
+{ "stvw", 0xd0000000, 0xfc080000, "v,xOA,X", 4 },
+{ "stvd", 0xd0000002, 0xfc080002, "v,xOA,X", 4 },
+
+{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 },
+{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 },
+{ "trnd", 0x2c0c0000, 0xfc0f0000, "r,R", 2 },
+{ "trabs", 0x2c010000, 0xfc0f0000, "r,R", 2 },
+{ "trabsd", 0x2c090000, 0xfc0f0000, "r,R", 2 },
+{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 },
+{ "xcr", 0x28040000, 0xfc0f0000, "r,R", 2 },
+{ "cxcr", 0x2c060000, 0xfc0f0000, "r,R", 2 },
+{ "cxcrd", 0x2c0e0000, 0xfc0f0000, "r,R", 2 },
+{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 },
+{ "trbr", 0x28030000, 0xfc0f0000, "b,R", 2 },
+{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 },
+{ "tbrbr", 0x28010000, 0xfc0f0000, "b,B", 2 },
+
+{ "trvv", 0x28050000, 0xfc0f0000, "v,V", 2 },
+{ "trvvn", 0x2c050000, 0xfc0f0000, "v,V", 2 },
+{ "trvvnd", 0x2c0d0000, 0xfc0f0000, "v,V", 2 },
+{ "trvab", 0x2c070000, 0xfc0f0000, "v,V", 2 },
+{ "trvabd", 0x2c0f0000, 0xfc0f0000, "v,V", 2 },
+{ "cmpv", 0x14060000, 0xfc0f0000, "v,V", 2 },
+{ "expv", 0x14070000, 0xfc0f0000, "v,V", 2 },
+{ "mrvvlt", 0x10030000, 0xfc0f0000, "v,V", 2 },
+{ "mrvvle", 0x10040000, 0xfc0f0000, "v,V", 2 },
+{ "mrvvgt", 0x14030000, 0xfc0f0000, "v,V", 2 },
+{ "mrvvge", 0x14040000, 0xfc0f0000, "v,V", 2 },
+{ "mrvveq", 0x10050000, 0xfc0f0000, "v,V", 2 },
+{ "mrvvne", 0x10050000, 0xfc0f0000, "v,V", 2 },
+{ "mrvrlt", 0x100d0000, 0xfc0f0000, "v,R", 2 },
+{ "mrvrle", 0x100e0000, 0xfc0f0000, "v,R", 2 },
+{ "mrvrgt", 0x140d0000, 0xfc0f0000, "v,R", 2 },
+{ "mrvrge", 0x140e0000, 0xfc0f0000, "v,R", 2 },
+{ "mrvreq", 0x100f0000, 0xfc0f0000, "v,R", 2 },
+{ "mrvrne", 0x140f0000, 0xfc0f0000, "v,R", 2 },
+{ "trvr", 0x140b0000, 0xfc0f0000, "r,V", 2 },
+{ "trrv", 0x140c0000, 0xfc0f0000, "v,R", 2 },
+
+{ "bu", 0x40000000, 0xff880000, "xOA,X", 4 },
+{ "bns", 0x70080000, 0xff880000, "xOA,X", 4 },
+{ "bnco", 0x70880000, 0xff880000, "xOA,X", 4 },
+{ "bge", 0x71080000, 0xff880000, "xOA,X", 4 },
+{ "bne", 0x71880000, 0xff880000, "xOA,X", 4 },
+{ "bunge", 0x72080000, 0xff880000, "xOA,X", 4 },
+{ "bunle", 0x72880000, 0xff880000, "xOA,X", 4 },
+{ "bgt", 0x73080000, 0xff880000, "xOA,X", 4 },
+{ "bnany", 0x73880000, 0xff880000, "xOA,X", 4 },
+{ "bs" , 0x70000000, 0xff880000, "xOA,X", 4 },
+{ "bco", 0x70800000, 0xff880000, "xOA,X", 4 },
+{ "blt", 0x71000000, 0xff880000, "xOA,X", 4 },
+{ "beq", 0x71800000, 0xff880000, "xOA,X", 4 },
+{ "buge", 0x72000000, 0xff880000, "xOA,X", 4 },
+{ "bult", 0x72800000, 0xff880000, "xOA,X", 4 },
+{ "ble", 0x73000000, 0xff880000, "xOA,X", 4 },
+{ "bany", 0x73800000, 0xff880000, "xOA,X", 4 },
+{ "brlnk", 0x44000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bib", 0x48000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bih", 0x48080000, 0xfc080000, "r,xOA,X", 4 },
+{ "biw", 0x4c000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bid", 0x4c080000, 0xfc080000, "r,xOA,X", 4 },
+{ "bivb", 0x60000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bivh", 0x60080000, 0xfc080000, "r,xOA,X", 4 },
+{ "bivw", 0x64000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bivd", 0x64080000, 0xfc080000, "r,xOA,X", 4 },
+{ "bvsb", 0x68000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bvsh", 0x68080000, 0xfc080000, "r,xOA,X", 4 },
+{ "bvsw", 0x6c000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bvsd", 0x6c080000, 0xfc080000, "r,xOA,X", 4 },
+
+{ "camb", 0x80080000, 0xfc080000, "r,xOA,X", 4 },
+{ "camh", 0x80000001, 0xfc080001, "r,xOA,X", 4 },
+{ "camw", 0x80000000, 0xfc080000, "r,xOA,X", 4 },
+{ "camd", 0x80000002, 0xfc080002, "r,xOA,X", 4 },
+{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 },
+{ "card", 0x14000000, 0xfc0f0000, "r,R", 2 },
+{ "ci", 0xf8050000, 0xfc7f0000, "r,I", 4 },
+{ "chkbnd", 0x5c080000, 0xfc080000, "r,xOA,X", 4 },
+
+{ "cavv", 0x10010000, 0xfc0f0000, "v,V", 2 },
+{ "cavr", 0x10020000, 0xfc0f0000, "v,R", 2 },
+{ "cavvd", 0x10090000, 0xfc0f0000, "v,V", 2 },
+{ "cavrd", 0x100b0000, 0xfc0f0000, "v,R", 2 },
+
+{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 },
+{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 },
+{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 },
+{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 },
+{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 },
+{ "ani", 0xf8080000, 0xfc7f0000, "r,I", 4 },
+{ "ormb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "ormh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "ormw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "ormd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 },
+{ "oi", 0xf8090000, 0xfc7f0000, "r,I", 4 },
+{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 },
+{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 },
+{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 },
+{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 },
+{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 },
+{ "eoi", 0xf80a0000, 0xfc7f0000, "r,I", 4 },
+
+{ "anvv", 0x04010000, 0xfc0f0000, "v,V", 2 },
+{ "anvr", 0x04020000, 0xfc0f0000, "v,R", 2 },
+{ "orvv", 0x08010000, 0xfc0f0000, "v,V", 2 },
+{ "orvr", 0x08020000, 0xfc0f0000, "v,R", 2 },
+{ "eovv", 0x0c010000, 0xfc0f0000, "v,V", 2 },
+{ "eovr", 0x0c020000, 0xfc0f0000, "v,R", 2 },
+
+{ "sacz", 0x100c0000, 0xfc0f0000, "r,R", 2 },
+{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 },
+{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 },
+{ "slc", 0x24400000, 0xfc600000, "r,S", 2 },
+{ "slad", 0x20400000, 0xfc600000, "r,S", 2 },
+{ "slld", 0x20600000, 0xfc600000, "r,S", 2 },
+{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 },
+{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 },
+{ "src", 0x24000000, 0xfc600000, "r,S", 2 },
+{ "srad", 0x20000000, 0xfc600000, "r,S", 2 },
+{ "srld", 0x20200000, 0xfc600000, "r,S", 2 },
+{ "sda", 0x3c030000, 0xfc0f0000, "r,R", 2 },
+{ "sdl", 0x3c020000, 0xfc0f0000, "r,R", 2 },
+{ "sdc", 0x3c010000, 0xfc0f0000, "r,R", 2 },
+{ "sdad", 0x3c0b0000, 0xfc0f0000, "r,R", 2 },
+{ "sdld", 0x3c0a0000, 0xfc0f0000, "r,R", 2 },
+
+{ "svda", 0x3c070000, 0xfc0f0000, "v,R", 2 },
+{ "svdl", 0x3c060000, 0xfc0f0000, "v,R", 2 },
+{ "svdc", 0x3c050000, 0xfc0f0000, "v,R", 2 },
+{ "svdad", 0x3c0e0000, 0xfc0f0000, "v,R", 2 },
+{ "svdld", 0x3c0d0000, 0xfc0f0000, "v,R", 2 },
+
+{ "sbm", 0xac080000, 0xfc080000, "f,xOA,X", 4 },
+{ "zbm", 0xac000000, 0xfc080000, "f,xOA,X", 4 },
+{ "tbm", 0xa8080000, 0xfc080000, "f,xOA,X", 4 },
+{ "incmb", 0xa0000000, 0xfc080000, "xOA,X", 4 },
+{ "incmh", 0xa0080000, 0xfc080000, "xOA,X", 4 },
+{ "incmw", 0xa4000000, 0xfc080000, "xOA,X", 4 },
+{ "incmd", 0xa4080000, 0xfc080000, "xOA,X", 4 },
+{ "sbmd", 0x7c080000, 0xfc080000, "r,xOA,X", 4 },
+{ "zbmd", 0x7c000000, 0xfc080000, "r,xOA,X", 4 },
+{ "tbmd", 0x78080000, 0xfc080000, "r,xOA,X", 4 },
+
+{ "ssm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 },
+{ "zsm", 0x9c000000, 0xfc080000, "f,xOA,X", 4 },
+{ "tsm", 0x98080000, 0xfc080000, "f,xOA,X", 4 },
+
+{ "admb", 0xc8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "admh", 0xc8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "admw", 0xc8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "admd", 0xc8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 },
+{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "adi", 0xf8010000, 0xfc0f0000, "r,I", 4 },
+{ "sumb", 0xcc080000, 0xfc080000, "r,xOA,X", 4 },
+{ "sumh", 0xcc000001, 0xfc080001, "r,xOA,X", 4 },
+{ "sumw", 0xcc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "sumd", 0xcc000002, 0xfc080002, "r,xOA,X", 4 },
+{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 },
+{ "sui", 0xf8020000, 0xfc0f0000, "r,I", 4 },
+{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 },
+{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 },
+{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 },
+{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 },
+{ "mprd", 0x3c0f0000, 0xfc0f0000, "r,R", 2 },
+{ "mpi", 0xf8030000, 0xfc0f0000, "r,I", 4 },
+{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 },
+{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 },
+{ "dvi", 0xf8040000, 0xfc0f0000, "r,I", 4 },
+{ "exs", 0x38080000, 0xfc0f0000, "r,R", 2 },
+
+{ "advv", 0x30000000, 0xfc0f0000, "v,V", 2 },
+{ "advvd", 0x30080000, 0xfc0f0000, "v,V", 2 },
+{ "adrv", 0x34000000, 0xfc0f0000, "v,R", 2 },
+{ "adrvd", 0x34080000, 0xfc0f0000, "v,R", 2 },
+{ "suvv", 0x30010000, 0xfc0f0000, "v,V", 2 },
+{ "suvvd", 0x30090000, 0xfc0f0000, "v,V", 2 },
+{ "surv", 0x34010000, 0xfc0f0000, "v,R", 2 },
+{ "survd", 0x34090000, 0xfc0f0000, "v,R", 2 },
+{ "mpvv", 0x30020000, 0xfc0f0000, "v,V", 2 },
+{ "mprv", 0x34020000, 0xfc0f0000, "v,R", 2 },
+
+{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 },
+{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 },
+{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 },
+{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 },
+{ "surfw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 },
+{ "surfd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 },
+{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 },
+{ "surfd", 0x380b0000, 0xfc0f0000, "r,R", 2 },
+{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 },
+{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 },
+{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 },
+{ "rfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "rfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 },
+{ "rrfw", 0x0c0e0000, 0xfc0f0000, "r", 2 },
+{ "rrfd", 0x0c0f0000, 0xfc0f0000, "r", 2 },
+
+{ "advvfw", 0x30040000, 0xfc0f0000, "v,V", 2 },
+{ "advvfd", 0x300c0000, 0xfc0f0000, "v,V", 2 },
+{ "adrvfw", 0x34040000, 0xfc0f0000, "v,R", 2 },
+{ "adrvfd", 0x340c0000, 0xfc0f0000, "v,R", 2 },
+{ "suvvfw", 0x30050000, 0xfc0f0000, "v,V", 2 },
+{ "suvvfd", 0x300d0000, 0xfc0f0000, "v,V", 2 },
+{ "survfw", 0x34050000, 0xfc0f0000, "v,R", 2 },
+{ "survfd", 0x340d0000, 0xfc0f0000, "v,R", 2 },
+{ "mpvvfw", 0x30060000, 0xfc0f0000, "v,V", 2 },
+{ "mpvvfd", 0x300e0000, 0xfc0f0000, "v,V", 2 },
+{ "mprvfw", 0x34060000, 0xfc0f0000, "v,R", 2 },
+{ "mprvfd", 0x340e0000, 0xfc0f0000, "v,R", 2 },
+{ "rvfw", 0x30070000, 0xfc0f0000, "v", 2 },
+{ "rvfd", 0x300f0000, 0xfc0f0000, "v", 2 },
+
+{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 },
+{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 },
+{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 },
+{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 },
+{ "cfpds", 0x3c090000, 0xfc0f0000, "r,R", 2 },
+
+{ "fltvw", 0x080d0000, 0xfc0f0000, "v,V", 2 },
+{ "fltvd", 0x080f0000, 0xfc0f0000, "v,V", 2 },
+{ "fixvw", 0x080c0000, 0xfc0f0000, "v,V", 2 },
+{ "fixvd", 0x080e0000, 0xfc0f0000, "v,V", 2 },
+{ "cfpvds", 0x0c0d0000, 0xfc0f0000, "v,V", 2 },
+
+{ "orvrn", 0x000a0000, 0xfc0f0000, "r,V", 2 },
+{ "andvrn", 0x00080000, 0xfc0f0000, "r,V", 2 },
+{ "frsteq", 0x04090000, 0xfc0f0000, "r,V", 2 },
+{ "sigma", 0x0c080000, 0xfc0f0000, "r,V", 2 },
+{ "sigmad", 0x0c0a0000, 0xfc0f0000, "r,V", 2 },
+{ "sigmf", 0x08080000, 0xfc0f0000, "r,V", 2 },
+{ "sigmfd", 0x080a0000, 0xfc0f0000, "r,V", 2 },
+{ "prodf", 0x04080000, 0xfc0f0000, "r,V", 2 },
+{ "prodfd", 0x040a0000, 0xfc0f0000, "r,V", 2 },
+{ "maxv", 0x10080000, 0xfc0f0000, "r,V", 2 },
+{ "maxvd", 0x100a0000, 0xfc0f0000, "r,V", 2 },
+{ "minv", 0x14080000, 0xfc0f0000, "r,V", 2 },
+{ "minvd", 0x140a0000, 0xfc0f0000, "r,V", 2 },
+
+{ "lpsd", 0xf0000000, 0xfc080000, "xOA,X", 4 },
+{ "ldc", 0xf0080000, 0xfc080000, "xOA,X", 4 },
+{ "spm", 0x040c0000, 0xfc0f0000, "r", 2 },
+{ "rpm", 0x040d0000, 0xfc0f0000, "r", 2 },
+{ "tritr", 0x00070000, 0xfc0f0000, "r", 2 },
+{ "trrit", 0x00060000, 0xfc0f0000, "r", 2 },
+{ "rpswt", 0x04080000, 0xfc0f0000, "r", 2 },
+{ "exr", 0xf8070000, 0xfc0f0000, "", 4 },
+{ "halt", 0x00000000, 0xfc0f0000, "", 2 },
+{ "wait", 0x00010000, 0xfc0f0000, "", 2 },
+{ "nop", 0x00020000, 0xfc0f0000, "", 2 },
+{ "eiae", 0x00030000, 0xfc0f0000, "", 2 },
+{ "efae", 0x000d0000, 0xfc0f0000, "", 2 },
+{ "diae", 0x000e0000, 0xfc0f0000, "", 2 },
+{ "dfae", 0x000f0000, 0xfc0f0000, "", 2 },
+{ "spvc", 0xf8060000, 0xfc0f0000, "r,T,N", 4 },
+{ "rdsts", 0x00090000, 0xfc0f0000, "r", 2 },
+{ "setcpu", 0x000c0000, 0xfc0f0000, "r", 2 },
+{ "cmc", 0x000b0000, 0xfc0f0000, "r", 2 },
+{ "trrcu", 0x00040000, 0xfc0f0000, "r", 2 },
+{ "attnio", 0x00050000, 0xfc0f0000, "", 2 },
+{ "fudit", 0x28080000, 0xfc0f0000, "", 2 },
+{ "break", 0x28090000, 0xfc0f0000, "", 2 },
+{ "frzss", 0x280a0000, 0xfc0f0000, "", 2 },
+{ "ripi", 0x04040000, 0xfc0f0000, "r,R", 2 },
+{ "xcp", 0x04050000, 0xfc0f0000, "r", 2 },
+{ "block", 0x04060000, 0xfc0f0000, "", 2 },
+{ "unblock", 0x04070000, 0xfc0f0000, "", 2 },
+{ "trsc", 0x08060000, 0xfc0f0000, "r,R", 2 },
+{ "tscr", 0x08070000, 0xfc0f0000, "r,R", 2 },
+{ "fq", 0x04080000, 0xfc0f0000, "r", 2 },
+{ "flupte", 0x2c080000, 0xfc0f0000, "r", 2 },
+{ "rviu", 0x040f0000, 0xfc0f0000, "", 2 },
+{ "ldel", 0x280c0000, 0xfc0f0000, "r,R", 2 },
+{ "ldu", 0x280d0000, 0xfc0f0000, "r,R", 2 },
+{ "stdecc", 0x280b0000, 0xfc0f0000, "r,R", 2 },
+{ "trpc", 0x08040000, 0xfc0f0000, "r", 2 },
+{ "tpcr", 0x08050000, 0xfc0f0000, "r", 2 },
+{ "ghalt", 0x0c050000, 0xfc0f0000, "r", 2 },
+{ "grun", 0x0c040000, 0xfc0f0000, "", 2 },
+{ "tmpr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 },
+{ "trmp", 0x2c0b0000, 0xfc0f0000, "r,R", 2 },
+
+{ "trrve", 0x28060000, 0xfc0f0000, "r", 2 },
+{ "trver", 0x28070000, 0xfc0f0000, "r", 2 },
+{ "trvlr", 0x280f0000, 0xfc0f0000, "r", 2 },
+
+{ "linkfl", 0x18000000, 0xfc0f0000, "r,R", 2 },
+{ "linkbl", 0x18020000, 0xfc0f0000, "r,R", 2 },
+{ "linkfp", 0x18010000, 0xfc0f0000, "r,R", 2 },
+{ "linkbp", 0x18030000, 0xfc0f0000, "r,R", 2 },
+{ "linkpl", 0x18040000, 0xfc0f0000, "r,R", 2 },
+{ "ulinkl", 0x18080000, 0xfc0f0000, "r,R", 2 },
+{ "ulinkp", 0x18090000, 0xfc0f0000, "r,R", 2 },
+{ "ulinktl", 0x180a0000, 0xfc0f0000, "r,R", 2 },
+{ "ulinktp", 0x180b0000, 0xfc0f0000, "r,R", 2 },
+};
+
+int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]);
+
+struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) /
+ sizeof(gld_opcodes[0]);
diff --git a/include/opcode/ns32k.h b/include/opcode/ns32k.h
new file mode 100644
index 00000000000..42bb8b87aad
--- /dev/null
+++ b/include/opcode/ns32k.h
@@ -0,0 +1,491 @@
+/* ns32k-opcode.h -- Opcode table for National Semi 32k processor
+ Copyright (C) 1987 Free Software Foundation, Inc.
+
+This file is part of GAS, the GNU Assembler.
+
+GAS 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 1, or (at your option)
+any later version.
+
+GAS 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 GAS; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#ifdef SEQUENT_COMPATABILITY
+#define DEF_MODEC 20
+#define DEF_MODEL 21
+#endif
+
+#ifndef DEF_MODEC
+#define DEF_MODEC 20
+#endif
+
+#ifndef DEF_MODEL
+#define DEF_MODEL 20
+#endif
+/*
+ After deciding the instruction entry (via hash.c) the instruction parser
+ will try to match the operands after the instruction to the required set
+ given in the entry operandfield. Every operand will result in a change in
+ the opcode or the addition of data to the opcode.
+ The operands in the source instruction are checked for inconsistent
+ semantics.
+
+ F : 32 bit float general form
+ L : 64 bit float "
+ B : byte "
+ W : word "
+ D : double-word "
+ A : double-word gen-address-form ie no regs, no immediate
+ I : integer writeable gen int except immediate (A + reg)
+ Z : floating writeable gen float except immediate (Z + freg)
+ d : displacement
+ b : displacement - pc relative addressing acb
+ p : displacement - pc relative addressing br bcond bsr cxp
+ q : quick
+ i : immediate (8 bits)
+ This is not a standard ns32k operandtype, it is used to build
+ instructions like svc arg1,arg2
+ Svc is the instruction SuperVisorCall and is sometimes used to
+ call OS-routines from usermode. Some args might be handy!
+ r : register number (3 bits)
+ O : setcfg instruction optionslist
+ C : cinv instruction optionslist
+ S : stringinstruction optionslist
+ U : registerlist save,enter
+ u : registerlist restore,exit
+ M : mmu register
+ P : cpu register
+ g : 3:rd operand of inss or exts instruction
+ G : 4:th operand of inss or exts instruction
+ Those operands are encoded in the same byte.
+ This byte is placed last in the instruction.
+ f : operand of sfsr
+ H : sequent-hack for bsr (Warning)
+
+column 1 instructions
+ 2 number of bits in opcode.
+ 3 number of bits in opcode explicitly
+ determined by the instruction type.
+ 4 opcodeseed, the number we build our opcode
+ from.
+ 5 operandtypes, used by operandparser.
+ 6 size in bytes of immediate
+*/
+struct ns32k_opcode {
+ char *name;
+ unsigned char opcode_id_size; /* not used by the assembler */
+ unsigned char opcode_size;
+ unsigned long opcode_seed;
+ char *operands;
+ unsigned char im_size; /* not used by dissassembler */
+ char *default_args; /* default to those args when none given */
+ char default_modec; /* default to this addr-mode when ambigous
+ ie when the argument of a general addr-mode
+ is a plain constant */
+ char default_model; /* is a plain label */
+};
+
+#ifdef comment
+/* This section was from the gdb version of this file. */
+
+#ifndef ns32k_opcodeT
+#define ns32k_opcodeT int
+#endif /* no ns32k_opcodeT */
+
+struct not_wot /* ns32k opcode table: wot to do with this */
+ /* particular opcode */
+{
+ int obits; /* number of opcode bits */
+ int ibits; /* number of instruction bits */
+ ns32k_opcodeT code; /* op-code (may be > 8 bits!) */
+ char *args; /* how to compile said opcode */
+};
+
+struct not /* ns32k opcode text */
+{
+ char * name; /* opcode name: lowercase string [key] */
+ struct not_wot detail; /* rest of opcode table [datum] */
+};
+
+/* Instructions look like this:
+
+ basic instruction--1, 2, or 3 bytes
+ index byte for operand A, if operand A is indexed--1 byte
+ index byte for operand B, if operand B is indexed--1 byte
+ addressing extension for operand A
+ addressing extension for operand B
+ implied operands
+
+ Operand A is the operand listed first in the following opcode table.
+ Operand B is the operand listed second in the following opcode table.
+ All instructions have at most 2 general operands, so this is enough.
+ The implied operands are associated with operands other than A and B.
+
+ Each operand has a digit and a letter.
+
+ The digit gives the position in the assembly language. The letter,
+ one of the following, tells us what kind of operand it is. */
+
+/* F : 32 bit float
+ * L : 64 bit float
+ * B : byte
+ * W : word
+ * D : double-word
+ * I : integer not immediate
+ * Z : floating not immediate
+ * d : displacement
+ * q : quick
+ * i : immediate (8 bits)
+ * r : register number (3 bits)
+ * p : displacement - pc relative addressing
+*/
+
+
+#endif /* comment */
+
+static const struct ns32k_opcode ns32k_opcodes[]=
+{
+ { "absf", 14,24, 0x35be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "absl", 14,24, 0x34be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "absb", 14,24, 0x304e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "absw", 14,24, 0x314e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "absd", 14,24, 0x334e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "acbb", 7,16, 0x4c, "2I1q3p", 1, "", DEF_MODEC,DEF_MODEL },
+ { "acbw", 7,16, 0x4d, "2I1q3p", 2, "", DEF_MODEC,DEF_MODEL },
+ { "acbd", 7,16, 0x4f, "2I1q3p", 4, "", DEF_MODEC,DEF_MODEL },
+ { "addf", 14,24, 0x01be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "addl", 14,24, 0x00be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "addb", 6,16, 0x00, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "addw", 6,16, 0x01, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "addd", 6,16, 0x03, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "addcb", 6,16, 0x10, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "addcw", 6,16, 0x11, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "addcd", 6,16, 0x13, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "addpb", 14,24, 0x3c4e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "addpw", 14,24, 0x3d4e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "addpd", 14,24, 0x3f4e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "addqb", 7,16, 0x0c, "2I1q", 1, "", DEF_MODEC,DEF_MODEL },
+ { "addqw", 7,16, 0x0d, "2I1q", 2, "", DEF_MODEC,DEF_MODEL },
+ { "addqd", 7,16, 0x0f, "2I1q", 4, "", DEF_MODEC,DEF_MODEL },
+ { "addr", 6,16, 0x27, "1A2I", 4, "", 21,21 },
+ { "adjspb", 11,16, 0x057c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
+ { "adjspw", 11,16, 0x057d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
+ { "adjspd", 11,16, 0x057f, "1D", 4, "", DEF_MODEC,DEF_MODEL },
+ { "andb", 6,16, 0x28, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "andw", 6,16, 0x29, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "andd", 6,16, 0x2b, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "ashb", 14,24, 0x044e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "ashw", 14,24, 0x054e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "ashd", 14,24, 0x074e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "beq", 8,8, 0x0a, "1p", 0, "", 21,21 },
+ { "bne", 8,8, 0x1a, "1p", 0, "", 21,21 },
+ { "bcs", 8,8, 0x2a, "1p", 0, "", 21,21 },
+ { "bcc", 8,8, 0x3a, "1p", 0, "", 21,21 },
+ { "bhi", 8,8, 0x4a, "1p", 0, "", 21,21 },
+ { "bls", 8,8, 0x5a, "1p", 0, "", 21,21 },
+ { "bgt", 8,8, 0x6a, "1p", 0, "", 21,21 },
+ { "ble", 8,8, 0x7a, "1p", 0, "", 21,21 },
+ { "bfs", 8,8, 0x8a, "1p", 0, "", 21,21 },
+ { "bfc", 8,8, 0x9a, "1p", 0, "", 21,21 },
+ { "blo", 8,8, 0xaa, "1p", 0, "", 21,21 },
+ { "bhs", 8,8, 0xba, "1p", 0, "", 21,21 },
+ { "blt", 8,8, 0xca, "1p", 0, "", 21,21 },
+ { "bge", 8,8, 0xda, "1p", 0, "", 21,21 },
+ { "but", 8,8, 0xea, "1p", 0, "", 21,21 },
+ { "buf", 8,8, 0xfa, "1p", 0, "", 21,21 },
+ { "bicb", 6,16, 0x08, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "bicw", 6,16, 0x09, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "bicd", 6,16, 0x0b, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "bicpsrb", 11,16, 0x17c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
+ { "bicpsrw", 11,16, 0x17d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
+ { "bispsrb", 11,16, 0x37c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
+ { "bispsrw", 11,16, 0x37d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
+ { "bpt", 8,8, 0xf2, "", 0, "", DEF_MODEC,DEF_MODEL },
+ { "br", 8,8, 0xea, "1p", 0, "", 21,21 },
+#ifdef SEQUENT_COMPATABILITY
+ { "bsr", 8,8, 0x02, "1H", 0, "", 21,21 },
+#else
+ { "bsr", 8,8, 0x02, "1p", 0, "", 21,21 },
+#endif
+ { "caseb", 11,16, 0x77c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
+ { "casew", 11,16, 0x77d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
+ { "cased", 11,16, 0x77f, "1D", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cbitb", 14,24, 0x084e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "cbitw", 14,24, 0x094e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "cbitd", 14,24, 0x0b4e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cbitib", 14,24, 0x0c4e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "cbitiw", 14,24, 0x0d4e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "cbitid", 14,24, 0x0f4e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "checkb", 11,24, 0x0ee, "2A3B1r", 1, "", DEF_MODEC,DEF_MODEL },
+ { "checkw", 11,24, 0x1ee, "2A3W1r", 2, "", DEF_MODEC,DEF_MODEL },
+ { "checkd", 11,24, 0x3ee, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cinv", 14,24, 0x271e, "2D1C", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cmpf", 14,24, 0x09be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cmpl", 14,24, 0x08be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
+ { "cmpb", 6,16, 0x04, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
+ { "cmpw", 6,16, 0x05, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
+ { "cmpd", 6,16, 0x07, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cmpmb", 14,24, 0x04ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL },
+ { "cmpmw", 14,24, 0x05ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL },
+ { "cmpmd", 14,24, 0x07ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cmpqb", 7,16, 0x1c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL },
+ { "cmpqw", 7,16, 0x1d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL },
+ { "cmpqd", 7,16, 0x1f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cmpsb", 16,24, 0x040e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "cmpsw", 16,24, 0x050e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "cmpsd", 16,24, 0x070e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "cmpst", 16,24, 0x840e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "comb", 14,24, 0x344e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "comw", 14,24, 0x354e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "comd", 14,24, 0x374e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cvtp", 11,24, 0x036e, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL },
+ { "cxp", 8,8, 0x22, "1p", 0, "", 21,21 },
+ { "cxpd", 11,16, 0x07f, "1A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "deib", 14,24, 0x2cce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "deiw", 14,24, 0x2dce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "deid", 14,24, 0x2fce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "dia", 8,8, 0xc2, "", 1, "", DEF_MODEC,DEF_MODEL },
+ { "divf", 14,24, 0x21be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "divl", 14,24, 0x20be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "divb", 14,24, 0x3cce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "divw", 14,24, 0x3dce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "divd", 14,24, 0x3fce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "enter", 8,8, 0x82, "1U2d", 0, "", DEF_MODEC,DEF_MODEL },
+ { "exit", 8,8, 0x92, "1u", 0, "", DEF_MODEC,DEF_MODEL },
+ { "extb", 11,24, 0x02e, "2I3B1r4d", 1, "", DEF_MODEC,DEF_MODEL },
+ { "extw", 11,24, 0x12e, "2I3W1r4d", 2, "", DEF_MODEC,DEF_MODEL },
+ { "extd", 11,24, 0x32e, "2I3D1r4d", 4, "", DEF_MODEC,DEF_MODEL },
+ { "extsb", 14,24, 0x0cce, "1I2I4G3g", 1, "", DEF_MODEC,DEF_MODEL },
+ { "extsw", 14,24, 0x0dce, "1I2I4G3g", 2, "", DEF_MODEC,DEF_MODEL },
+ { "extsd", 14,24, 0x0fce, "1I2I4G3g", 4, "", DEF_MODEC,DEF_MODEL },
+ { "ffsb", 14,24, 0x046e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "ffsw", 14,24, 0x056e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "ffsd", 14,24, 0x076e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "flag", 8,8, 0xd2, "", 0, "", DEF_MODEC,DEF_MODEL },
+ { "floorfb", 14,24, 0x3c3e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "floorfw", 14,24, 0x3d3e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "floorfd", 14,24, 0x3f3e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "floorlb", 14,24, 0x383e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "floorlw", 14,24, 0x393e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "floorld", 14,24, 0x3b3e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "ibitb", 14,24, 0x384e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "ibitw", 14,24, 0x394e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "ibitd", 14,24, 0x3b4e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "indexb", 11,24, 0x42e, "2B3B1r", 1, "", DEF_MODEC,DEF_MODEL },
+ { "indexw", 11,24, 0x52e, "2W3W1r", 2, "", DEF_MODEC,DEF_MODEL },
+ { "indexd", 11,24, 0x72e, "2D3D1r", 4, "", DEF_MODEC,DEF_MODEL },
+ { "insb", 11,24, 0x0ae, "2B3I1r4d", 1, "", DEF_MODEC,DEF_MODEL },
+ { "insw", 11,24, 0x1ae, "2W3I1r4d", 2, "", DEF_MODEC,DEF_MODEL },
+ { "insd", 11,24, 0x3ae, "2D3I1r4d", 4, "", DEF_MODEC,DEF_MODEL },
+ { "inssb", 14,24, 0x08ce, "1B2I4G3g", 1, "", DEF_MODEC,DEF_MODEL },
+ { "inssw", 14,24, 0x09ce, "1W2I4G3g", 2, "", DEF_MODEC,DEF_MODEL },
+ { "inssd", 14,24, 0x0bce, "1D2I4G3g", 4, "", DEF_MODEC,DEF_MODEL },
+ { "jsr", 11,16, 0x67f, "1A", 4, "", 21,21 },
+ { "jump", 11,16, 0x27f, "1A", 4, "", 21,21 },
+ { "lfsr", 19,24, 0x00f3e,"1D", 4, "", DEF_MODEC,DEF_MODEL },
+ { "lmr", 15,24, 0x0b1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL },
+ { "lprb", 7,16, 0x6c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL },
+ { "lprw", 7,16, 0x6d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL },
+ { "lprd", 7,16, 0x6f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL },
+ { "lshb", 14,24, 0x144e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "lshw", 14,24, 0x154e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "lshd", 14,24, 0x174e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "meib", 14,24, 0x24ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "meiw", 14,24, 0x25ce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "meid", 14,24, 0x27ce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "modb", 14,24, 0x38ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "modw", 14,24, 0x39ce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "modd", 14,24, 0x3bce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movf", 14,24, 0x05be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movl", 14,24, 0x04be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "movb", 6,16, 0x14, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movw", 6,16, 0x15, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movd", 6,16, 0x17, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movbf", 14,24, 0x043e, "1B2Z", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movwf", 14,24, 0x053e, "1W2Z", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movdf", 14,24, 0x073e, "1D2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movbl", 14,24, 0x003e, "1B2Z", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movwl", 14,24, 0x013e, "1W2Z", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movdl", 14,24, 0x033e, "1D2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movfl", 14,24, 0x1b3e, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movlf", 14,24, 0x163e, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "movmb", 14,24, 0x00ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movmw", 14,24, 0x01ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movmd", 14,24, 0x03ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movqb", 7,16, 0x5c, "2I1q", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movqw", 7,16, 0x5d, "2I1q", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movqd", 7,16, 0x5f, "2I1q", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movsb", 16,24, 0x000e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "movsw", 16,24, 0x010e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "movsd", 16,24, 0x030e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "movst", 16,24, 0x800e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "movsub", 14,24, 0x0cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movsuw", 14,24, 0x0dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movsud", 14,24, 0x0fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movusb", 14,24, 0x1cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movusw", 14,24, 0x1dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movusd", 14,24, 0x1fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "movxbd", 14,24, 0x1cce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movxwd", 14,24, 0x1dce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movxbw", 14,24, 0x10ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movzbd", 14,24, 0x18ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "movzwd", 14,24, 0x19ce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "movzbw", 14,24, 0x14ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "mulf", 14,24, 0x31be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "mull", 14,24, 0x30be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "mulb", 14,24, 0x20ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "mulw", 14,24, 0x21ce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "muld", 14,24, 0x23ce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "negf", 14,24, 0x15be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "negl", 14,24, 0x14be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "negb", 14,24, 0x204e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "negw", 14,24, 0x214e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "negd", 14,24, 0x234e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "nop", 8,8, 0xa2, "", 0, "", DEF_MODEC,DEF_MODEL },
+ { "notb", 14,24, 0x244e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "notw", 14,24, 0x254e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "notd", 14,24, 0x274e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "orb", 6,16, 0x18, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "orw", 6,16, 0x19, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "ord", 6,16, 0x1b, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "quob", 14,24, 0x30ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "quow", 14,24, 0x31ce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "quod", 14,24, 0x33ce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "rdval", 19,24, 0x0031e,"1A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "remb", 14,24, 0x34ce, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "remw", 14,24, 0x35ce, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "remd", 14,24, 0x37ce, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "restore", 8,8, 0x72, "1u", 0, "", DEF_MODEC,DEF_MODEL },
+ { "ret", 8,8, 0x12, "1d", 0, "", DEF_MODEC,DEF_MODEL },
+ { "reti", 8,8, 0x52, "", 0, "", DEF_MODEC,DEF_MODEL },
+ { "rett", 8,8, 0x42, "1d", 0, "", DEF_MODEC,DEF_MODEL },
+ { "rotb", 14,24, 0x004e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "rotw", 14,24, 0x014e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "rotd", 14,24, 0x034e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "roundfb", 14,24, 0x243e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "roundfw", 14,24, 0x253e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "roundfd", 14,24, 0x273e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "roundlb", 14,24, 0x203e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "roundlw", 14,24, 0x213e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "roundld", 14,24, 0x233e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "rxp", 8,8, 0x32, "1d", 0, "", DEF_MODEC,DEF_MODEL },
+ { "seqb", 11,16, 0x3c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "seqw", 11,16, 0x3d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "seqd", 11,16, 0x3f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sneb", 11,16, 0xbc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "snew", 11,16, 0xbd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sned", 11,16, 0xbf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "scsb", 11,16, 0x13c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "scsw", 11,16, 0x13d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "scsd", 11,16, 0x13f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sccb", 11,16, 0x1bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sccw", 11,16, 0x1bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sccd", 11,16, 0x1bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "shib", 11,16, 0x23c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "shiw", 11,16, 0x23d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "shid", 11,16, 0x23f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slsb", 11,16, 0x2bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slsw", 11,16, 0x2bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slsd", 11,16, 0x2bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sgtb", 11,16, 0x33c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sgtw", 11,16, 0x33d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sgtd", 11,16, 0x33f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sleb", 11,16, 0x3bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slew", 11,16, 0x3bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sled", 11,16, 0x3bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfsb", 11,16, 0x43c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfsw", 11,16, 0x43d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfsd", 11,16, 0x43f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfcb", 11,16, 0x4bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfcw", 11,16, 0x4bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfcd", 11,16, 0x4bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slob", 11,16, 0x53c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slow", 11,16, 0x53d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "slod", 11,16, 0x53f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "shsb", 11,16, 0x5bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "shsw", 11,16, 0x5bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "shsd", 11,16, 0x5bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sltb", 11,16, 0x63c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sltw", 11,16, 0x63d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sltd", 11,16, 0x63f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sgeb", 11,16, 0x6bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sgew", 11,16, 0x6bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sged", 11,16, 0x6bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sutb", 11,16, 0x73c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sutw", 11,16, 0x73d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sutd", 11,16, 0x73f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sufb", 11,16, 0x7bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sufw", 11,16, 0x7bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sufd", 11,16, 0x7bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
+ { "save", 8,8, 0x62, "1U", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sbitb", 14,24, 0x184e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL },
+ { "sbitw", 14,24, 0x194e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL },
+ { "sbitd", 14,24, 0x1b4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "sbitib", 14,24, 0x1c4e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL },
+ { "sbitiw", 14,24, 0x1d4e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL },
+ { "sbitid", 14,24, 0x1f4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "setcfg", 15,24, 0x0b0e, "1O", 0, "", DEF_MODEC,DEF_MODEL },
+ { "sfsr", 14,24, 0x373e, "1f", 0, "", DEF_MODEC,DEF_MODEL },
+ { "skpsb", 16,24, 0x0c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "skpsw", 16,24, 0x0d0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "skpsd", 16,24, 0x0f0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "skpst", 16,24, 0x8c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
+ { "smr", 15,24, 0x0f1e, "2I1M", 4, "", DEF_MODEC,DEF_MODEL },
+ { "sprb", 7,16, 0x2c, "2I1P", 1, "", DEF_MODEC,DEF_MODEL },
+ { "sprw", 7,16, 0x2d, "2I1P", 2, "", DEF_MODEC,DEF_MODEL },
+ { "sprd", 7,16, 0x2f, "2I1P", 4, "", DEF_MODEC,DEF_MODEL },
+ { "subf", 14,24, 0x11be, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "subl", 14,24, 0x10be, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "subb", 6,16, 0x20, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "subw", 6,16, 0x21, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "subd", 6,16, 0x23, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "subcb", 6,16, 0x30, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "subcw", 6,16, 0x31, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "subcd", 6,16, 0x33, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "subpb", 14,24, 0x2c4e, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "subpw", 14,24, 0x2d4e, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "subpd", 14,24, 0x2f4e, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+#ifdef NS32K_SVC_IMMED_OPERANDS
+ { "svc", 8,8, 0xe2, "2i1i", 1, "", DEF_MODEC,DEF_MODEL }, /* not really, but some unix uses it */
+#else
+ { "svc", 8,8, 0xe2, "", 0, "", DEF_MODEC,DEF_MODEL },
+#endif
+ { "tbitb", 6,16, 0x34, "1B2A", 1, "", DEF_MODEC,DEF_MODEL },
+ { "tbitw", 6,16, 0x35, "1W2A", 2, "", DEF_MODEC,DEF_MODEL },
+ { "tbitd", 6,16, 0x37, "1D2A", 4, "", DEF_MODEC,DEF_MODEL },
+ { "truncfb", 14,24, 0x2c3e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "truncfw", 14,24, 0x2d3e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "truncfd", 14,24, 0x2f3e, "1F2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "trunclb", 14,24, 0x283e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "trunclw", 14,24, 0x293e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "truncld", 14,24, 0x2b3e, "1L2I", 8, "", DEF_MODEC,DEF_MODEL },
+ { "wait", 8,8, 0xb2, "", 0, "", DEF_MODEC,DEF_MODEL },
+ { "wrval", 19,24, 0x0071e,"1A", 0, "", DEF_MODEC,DEF_MODEL },
+ { "xorb", 6,16, 0x38, "1B2I", 1, "", DEF_MODEC,DEF_MODEL },
+ { "xorw", 6,16, 0x39, "1W2I", 2, "", DEF_MODEC,DEF_MODEL },
+ { "xord", 6,16, 0x3b, "1D2I", 4, "", DEF_MODEC,DEF_MODEL },
+ { "dotf", 14,24, 0x0dfe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
+ { "dotl", 14,24, 0x0cfe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
+ { "logbf", 14,24, 0x15fe, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "logbl", 14,24, 0x14fe, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+ { "polyf", 14,24, 0x09fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
+ { "polyl", 14,24, 0x08fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
+ { "scalbf", 14,24, 0x11fe, "1F2Z", 4, "", DEF_MODEC,DEF_MODEL },
+ { "scalbl", 14,24, 0x10fe, "1L2Z", 8, "", DEF_MODEC,DEF_MODEL },
+};
+
+static const int numopcodes=sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]);
+
+static const struct ns32k_opcode *const endop = ns32k_opcodes+sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]);
+
+#define MAX_ARGS 4
+#define ARG_LEN 50
+
diff --git a/include/opcode/pn.h b/include/opcode/pn.h
new file mode 100644
index 00000000000..0f59a2a53ce
--- /dev/null
+++ b/include/opcode/pn.h
@@ -0,0 +1,282 @@
+/* Print GOULD PN (PowerNode) instructions for GDB, the GNU debugger.
+ Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+GDB 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 1, or (at your option)
+any later version.
+
+GDB 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 GDB; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+struct gld_opcode
+{
+ char *name;
+ unsigned long opcode;
+ unsigned long mask;
+ char *args;
+ int length;
+};
+
+/* We store four bytes of opcode for all opcodes because that
+ is the most any of them need. The actual length of an instruction
+ is always at least 2 bytes, and at most four. The length of the
+ instruction is based on the opcode.
+
+ The mask component is a mask saying which bits must match
+ particular opcode in order for an instruction to be an instance
+ of that opcode.
+
+ The args component is a string containing characters
+ that are used to format the arguments to the instruction. */
+
+/* Kinds of operands:
+ r Register in first field
+ R Register in second field
+ b Base register in first field
+ B Base register in second field
+ v Vector register in first field
+ V Vector register in first field
+ A Optional address register (base register)
+ X Optional index register
+ I Immediate data (16bits signed)
+ O Offset field (16bits signed)
+ h Offset field (15bits signed)
+ d Offset field (14bits signed)
+ S Shift count field
+
+ any other characters are printed as is...
+*/
+
+/* The assembler requires that this array be sorted as follows:
+ all instances of the same mnemonic must be consecutive.
+ All instances of the same mnemonic with the same number of operands
+ must be consecutive.
+ */
+struct gld_opcode gld_opcodes[] =
+{
+{ "abm", 0xa0080000, 0xfc080000, "f,xOA,X", 4 },
+{ "abr", 0x18080000, 0xfc0c0000, "r,f", 2 },
+{ "aci", 0xfc770000, 0xfc7f8000, "r,I", 4 },
+{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 },
+{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 },
+{ "adi", 0xc8010000, 0xfc7f0000, "r,I", 4 },
+{ "admb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "admd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "admh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "admw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 },
+{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 },
+{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 },
+{ "adrm", 0x38080000, 0xfc0f0000, "r,R", 2 },
+{ "ai", 0xfc030000, 0xfc07ffff, "I", 4 },
+{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 },
+{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 },
+{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 },
+{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 },
+{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 },
+{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "bcf", 0xf0000000, 0xfc080000, "I,xOA,X", 4 },
+{ "bct", 0xec000000, 0xfc080000, "I,xOA,X", 4 },
+{ "bei", 0x00060000, 0xffff0000, "", 2 },
+{ "bft", 0xf0000000, 0xff880000, "xOA,X", 4 },
+{ "bib", 0xf4000000, 0xfc780000, "r,xOA", 4 },
+{ "bid", 0xf4600000, 0xfc780000, "r,xOA", 4 },
+{ "bih", 0xf4200000, 0xfc780000, "r,xOA", 4 },
+{ "biw", 0xf4400000, 0xfc780000, "r,xOA", 4 },
+{ "bl", 0xf8800000, 0xff880000, "xOA,X", 4 },
+{ "bsub", 0x5c080000, 0xff8f0000, "", 2 },
+{ "bsubm", 0x28080000, 0xfc080000, "", 4 },
+{ "bu", 0xec000000, 0xff880000, "xOA,X", 4 },
+{ "call", 0x28080000, 0xfc0f0000, "", 2 },
+{ "callm", 0x5c080000, 0xff880000, "", 4 },
+{ "camb", 0x90080000, 0xfc080000, "r,xOA,X", 4 },
+{ "camd", 0x90000002, 0xfc080002, "r,xOA,X", 4 },
+{ "camh", 0x90000001, 0xfc080001, "r,xOA,X", 4 },
+{ "camw", 0x90000000, 0xfc080000, "r.xOA,X", 4 },
+{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 },
+{ "cd", 0xfc060000, 0xfc070000, "r,f", 4 },
+{ "cea", 0x000f0000, 0xffff0000, "", 2 },
+{ "ci", 0xc8050000, 0xfc7f0000, "r,I", 4 },
+{ "cmc", 0x040a0000, 0xfc7f0000, "r", 2 },
+{ "cmmb", 0x94080000, 0xfc080000, "r,xOA,X", 4 },
+{ "cmmd", 0x94000002, 0xfc080002, "r,xOA,X", 4 },
+{ "cmmh", 0x94000001, 0xfc080001, "r,xOA,X", 4 },
+{ "cmmw", 0x94000000, 0xfc080000, "r,xOA,X", 4 },
+{ "cmr", 0x14000000, 0xfc0f0000, "r,R", 2 },
+{ "daci", 0xfc7f0000, 0xfc7f8000, "r,I", 4 },
+{ "dae", 0x000e0000, 0xffff0000, "", 2 },
+{ "dai", 0xfc040000, 0xfc07ffff, "I", 4 },
+{ "dci", 0xfc6f0000, 0xfc7f8000, "r,I", 4 },
+{ "di", 0xfc010000, 0xfc07ffff, "I", 4 },
+{ "dvfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 },
+{ "dvfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "dvi", 0xc8040000, 0xfc7f0000, "r,I", 4 },
+{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 },
+{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 },
+{ "dvrfd", 0x380c0000, 0xfc0f0000, "r,R", 4 },
+{ "dvrfw", 0x38040000, 0xfc0f0000, "r,xOA,X", 4 },
+{ "eae", 0x00080000, 0xffff0000, "", 2 },
+{ "eci", 0xfc670000, 0xfc7f8080, "r,I", 4 },
+{ "ecwcs", 0xfc4f0000, 0xfc7f8000, "", 4 },
+{ "ei", 0xfc000000, 0xfc07ffff, "I", 4 },
+{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 },
+{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 },
+{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 },
+{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 },
+{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 },
+{ "eorm", 0x0c080000, 0xfc0f0000, "r,R", 2 },
+{ "es", 0x00040000, 0xfc7f0000, "r", 2 },
+{ "exm", 0xa8000000, 0xff880000, "xOA,X", 4 },
+{ "exr", 0xc8070000, 0xfc7f0000, "r", 2 },
+{ "exrr", 0xc8070002, 0xfc7f0002, "r", 2 },
+{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 },
+{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 },
+{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 },
+{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 },
+{ "grio", 0xfc3f0000, 0xfc7f8000, "r,I", 4 },
+{ "halt", 0x00000000, 0xffff0000, "", 2 },
+{ "hio", 0xfc370000, 0xfc7f8000, "r,I", 4 },
+{ "jwcs", 0xfa080000, 0xff880000, "xOA,X", 4 },
+{ "la", 0x50000000, 0xfc000000, "r,xOA,X", 4 },
+{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 },
+{ "lb", 0xac080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lcs", 0x00030000, 0xfc7f0000, "r", 2 },
+{ "ld", 0xac000002, 0xfc080002, "r,xOA,X", 4 },
+{ "lear", 0x80000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lf", 0xcc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lfbr", 0xcc080000, 0xfc080000, "b,xOA,X", 4 },
+{ "lh", 0xac000001, 0xfc080001, "r,xOA,X", 4 },
+{ "li", 0xc8000000, 0xfc7f0000, "r,I", 4 },
+{ "lmap", 0x2c070000, 0xfc7f0000, "r", 2 },
+{ "lmb", 0xb0080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lmd", 0xb0000002, 0xfc080002, "r,xOA,X", 4 },
+{ "lmh", 0xb0000001, 0xfc080001, "r,xOA,X", 4 },
+{ "lmw", 0xb0000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lnb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "lnd", 0xb4000002, 0xfc080002, "r,xOA,X", 4 },
+{ "lnh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 },
+{ "lnw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lpsd", 0xf9800000, 0xff880000, "r,xOA,X", 4 },
+{ "lpsdcm", 0xfa800000, 0xff880000, "r,xOA,X", 4 },
+{ "lw", 0xac000000, 0xfc080000, "r,xOA,X", 4 },
+{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 },
+{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 },
+{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "mpi", 0xc8030000, 0xfc7f0000, "r,I", 4 },
+{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 },
+{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 },
+{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 },
+{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 },
+{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 },
+{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 },
+{ "nop", 0x00020000, 0xffff0000, "", 2 },
+{ "ormb", 0x88080000, 0xfc080000, "r,xOA,X", 4 },
+{ "ormd", 0x88000002, 0xfc080002, "r,xOA,X", 4 },
+{ "ormh", 0x88000001, 0xfc080001, "r,xOA,X", 4 },
+{ "ormw", 0x88000000, 0xfc080000, "r,xOA,X", 4 },
+{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 },
+{ "orrm", 0x08080000, 0xfc0f0000, "r,R", 2 },
+{ "rdsts", 0x00090000, 0xfc7f0000, "r", 2 },
+{ "return", 0x280e0000, 0xfc7f0000, "", 2 },
+{ "ri", 0xfc020000, 0xfc07ffff, "I", 4 },
+{ "rnd", 0x00050000, 0xfc7f0000, "r", 2 },
+{ "rpswt", 0x040b0000, 0xfc7f0000, "r", 2 },
+{ "rschnl", 0xfc2f0000, 0xfc7f8000, "r,I", 4 },
+{ "rsctl", 0xfc470000, 0xfc7f8000, "r,I", 4 },
+{ "rwcs", 0x000b0000, 0xfc0f0000, "r,R", 2 },
+{ "sacz", 0x10080000, 0xfc0f0000, "r,R", 2 },
+{ "sbm", 0x98080000, 0xfc080000, "f,xOA,X", 4 },
+{ "sbr", 0x18000000, 0xfc0c0000, "r,f", 4 },
+{ "sea", 0x000d0000, 0xffff0000, "", 2 },
+{ "setcpu", 0x2c090000, 0xfc7f0000, "r", 2 },
+{ "sio", 0xfc170000, 0xfc7f8000, "r,I", 4 },
+{ "sipu", 0x000a0000, 0xffff0000, "", 2 },
+{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 },
+{ "slad", 0x20400000, 0xfc600000, "r,S", 2 },
+{ "slc", 0x24400000, 0xfc600000, "r,S", 2 },
+{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 },
+{ "slld", 0x20600000, 0xfc600000, "r,S", 2 },
+{ "smc", 0x04070000, 0xfc070000, "", 2 },
+{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 },
+{ "srad", 0x20000000, 0xfc600000, "r,S", 2 },
+{ "src", 0x24000000, 0xfc600000, "r,S", 2 },
+{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 },
+{ "srld", 0x20200000, 0xfc600000, "r,S", 2 },
+{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 },
+{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 },
+{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "stfbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 },
+{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 },
+{ "stmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "stmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "stmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "stmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "stpio", 0xfc270000, 0xfc7f8000, "r,I", 4 },
+{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 },
+{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 },
+{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 },
+{ "sufd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 },
+{ "sufw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 },
+{ "sui", 0xc8020000, 0xfc7f0000, "r,I", 4 },
+{ "sumb", 0xbc080000, 0xfc080000, "r,xOA,X", 4 },
+{ "sumd", 0xbc000002, 0xfc080002, "r,xOA,X", 4 },
+{ "sumh", 0xbc000001, 0xfc080001, "r,xOA,X", 4 },
+{ "sumw", 0xbc000000, 0xfc080000, "r,xOA,X", 4 },
+{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 },
+{ "surfd", 0x380b0000, 0xfc0f0000, "r,xOA,X", 4 },
+{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 },
+{ "surm", 0x3c080000, 0xfc0f0000, "r,R", 2 },
+{ "svc", 0xc8060000, 0xffff0000, "", 4 },
+{ "tbm", 0xa4080000, 0xfc080000, "f,xOA,X", 4 },
+{ "tbr", 0x180c0000, 0xfc0c0000, "r,f", 2 },
+{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 },
+{ "tccr", 0x28040000, 0xfc7f0000, "", 2 },
+{ "td", 0xfc050000, 0xfc070000, "r,f", 4 },
+{ "tio", 0xfc1f0000, 0xfc7f8000, "r,I", 4 },
+{ "tmapr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 },
+{ "tpcbr", 0x280c0000, 0xfc7f0000, "r", 2 },
+{ "trbr", 0x2c010000, 0xfc0f0000, "b,R", 2 },
+{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 },
+{ "trcc", 0x28050000, 0xfc7f0000, "", 2 },
+{ "trcm", 0x2c0b0000, 0xfc0f0000, "r,R", 2 },
+{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 },
+{ "trnm", 0x2c0c0000, 0xfc0f0000, "r,R", 2 },
+{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 },
+{ "trrm", 0x2c080000, 0xfc0f0000, "r,R", 2 },
+{ "trsc", 0x2c0e0000, 0xfc0f0000, "r,R", 2 },
+{ "trsw", 0x28000000, 0xfc7f0000, "r", 2 },
+{ "tscr", 0x2c0f0000, 0xfc0f0000, "r,R", 2 },
+{ "uei", 0x00070000, 0xffff0000, "", 2 },
+{ "wait", 0x00010000, 0xffff0000, "", 2 },
+{ "wcwcs", 0xfc5f0000, 0xfc7f8000, "", 4 },
+{ "wwcs", 0x000c0000, 0xfc0f0000, "r,R", 2 },
+{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 },
+{ "xcr", 0x2c050000, 0xfc0f0000, "r,R", 2 },
+{ "xcrm", 0x2c0d0000, 0xfc0f0000, "r,R", 2 },
+{ "zbm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 },
+{ "zbr", 0x18040000, 0xfc0c0000, "r,f", 2 },
+{ "zmb", 0xf8080000, 0xfc080000, "r,xOA,X", 4 },
+{ "zmd", 0xf8000002, 0xfc080002, "r,xOA,X", 4 },
+{ "zmh", 0xf8000001, 0xfc080001, "r,xOA,X", 4 },
+{ "zmw", 0xf8000000, 0xfc080000, "r,xOA,X", 4 },
+{ "zr", 0x0c000000, 0xfc0f0000, "r", 2 },
+};
+
+int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]);
+
+struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) /
+ sizeof(gld_opcodes[0]);
diff --git a/include/opcode/ppc.h b/include/opcode/ppc.h
new file mode 100644
index 00000000000..a9e3b24ab30
--- /dev/null
+++ b/include/opcode/ppc.h
@@ -0,0 +1,248 @@
+/* ppc.h -- Header file for PowerPC opcode table
+ Copyright 1994, 1995 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef PPC_H
+#define PPC_H
+
+/* The opcode table is an array of struct powerpc_opcode. */
+
+struct powerpc_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* The opcode itself. Those bits which will be filled in with
+ operands are zeroes. */
+ unsigned long opcode;
+
+ /* The opcode mask. This is used by the disassembler. This is a
+ mask containing ones indicating those bits which must match the
+ opcode field, and zeroes indicating those bits which need not
+ match (and are presumably filled in by operands). */
+ unsigned long mask;
+
+ /* One bit flags for the opcode. These are used to indicate which
+ specific processors support the instructions. The defined values
+ are listed below. */
+ unsigned long flags;
+
+ /* An array of operand codes. Each code is an index into the
+ operand table. They appear in the order which the operands must
+ appear in assembly code, and are terminated by a zero. */
+ unsigned char operands[8];
+};
+
+/* The table itself is sorted by major opcode number, and is otherwise
+ in the order in which the disassembler should consider
+ instructions. */
+extern const struct powerpc_opcode powerpc_opcodes[];
+extern const int powerpc_num_opcodes;
+
+/* Values defined for the flags field of a struct powerpc_opcode. */
+
+/* Opcode is defined for the PowerPC architecture. */
+#define PPC_OPCODE_PPC (01)
+
+/* Opcode is defined for the POWER (RS/6000) architecture. */
+#define PPC_OPCODE_POWER (02)
+
+/* Opcode is defined for the POWER2 (Rios 2) architecture. */
+#define PPC_OPCODE_POWER2 (04)
+
+/* Opcode is only defined on 32 bit architectures. */
+#define PPC_OPCODE_32 (010)
+
+/* Opcode is only defined on 64 bit architectures. */
+#define PPC_OPCODE_64 (020)
+
+/* Opcode is supported by the Motorola PowerPC 601 processor. The 601
+ is assumed to support all PowerPC (PPC_OPCODE_PPC) instructions,
+ but it also supports many additional POWER instructions. */
+#define PPC_OPCODE_601 (040)
+
+/* Opcode is supported in both the Power and PowerPC architectures
+ (ie, compiler's -mcpu=common or assembler's -mcom). */
+#define PPC_OPCODE_COMMON (0100)
+
+/* Opcode is supported for any Power or PowerPC platform (this is
+ for the assembler's -many option, and it eliminates duplicates). */
+#define PPC_OPCODE_ANY (0200)
+
+/* A macro to extract the major opcode from an instruction. */
+#define PPC_OP(i) (((i) >> 26) & 0x3f)
+
+/* The operands table is an array of struct powerpc_operand. */
+
+struct powerpc_operand
+{
+ /* The number of bits in the operand. */
+ int bits;
+
+ /* How far the operand is left shifted in the instruction. */
+ int shift;
+
+ /* Insertion function. This is used by the assembler. To insert an
+ operand value into an instruction, check this field.
+
+ If it is NULL, execute
+ i |= (op & ((1 << o->bits) - 1)) << o->shift;
+ (i is the instruction which we are filling in, o is a pointer to
+ this structure, and op is the opcode value; this assumes twos
+ complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction and the operand value. It will return the new value
+ of the instruction. If the ERRMSG argument is not NULL, then if
+ the operand value is illegal, *ERRMSG will be set to a warning
+ string (the operand will be inserted in any case). If the
+ operand value is legal, *ERRMSG will be unchanged (most operands
+ can accept any value). */
+ unsigned long (*insert) PARAMS ((unsigned long instruction, long op,
+ const char **errmsg));
+
+ /* Extraction function. This is used by the disassembler. To
+ extract this operand type from an instruction, check this field.
+
+ If it is NULL, compute
+ op = ((i) >> o->shift) & ((1 << o->bits) - 1);
+ if ((o->flags & PPC_OPERAND_SIGNED) != 0
+ && (op & (1 << (o->bits - 1))) != 0)
+ op -= 1 << o->bits;
+ (i is the instruction, o is a pointer to this structure, and op
+ is the result; this assumes twos complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction value. It will return the value of the operand. If
+ the INVALID argument is not NULL, *INVALID will be set to
+ non-zero if this operand type can not actually be extracted from
+ this operand (i.e., the instruction does not match). If the
+ operand is valid, *INVALID will not be changed. */
+ long (*extract) PARAMS ((unsigned long instruction, int *invalid));
+
+ /* One bit syntax flags. */
+ unsigned long flags;
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the powerpc_opcodes table. */
+
+extern const struct powerpc_operand powerpc_operands[];
+
+/* Values defined for the flags field of a struct powerpc_operand. */
+
+/* This operand takes signed values. */
+#define PPC_OPERAND_SIGNED (01)
+
+/* This operand takes signed values, but also accepts a full positive
+ range of values when running in 32 bit mode. That is, if bits is
+ 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode,
+ this flag is ignored. */
+#define PPC_OPERAND_SIGNOPT (02)
+
+/* This operand does not actually exist in the assembler input. This
+ is used to support extended mnemonics such as mr, for which two
+ operands fields are identical. The assembler should call the
+ insert function with any op value. The disassembler should call
+ the extract function, ignore the return value, and check the value
+ placed in the valid argument. */
+#define PPC_OPERAND_FAKE (04)
+
+/* The next operand should be wrapped in parentheses rather than
+ separated from this one by a comma. This is used for the load and
+ store instructions which want their operands to look like
+ reg,displacement(reg)
+ */
+#define PPC_OPERAND_PARENS (010)
+
+/* This operand may use the symbolic names for the CR fields, which
+ are
+ lt 0 gt 1 eq 2 so 3 un 3
+ cr0 0 cr1 1 cr2 2 cr3 3
+ cr4 4 cr5 5 cr6 6 cr7 7
+ These may be combined arithmetically, as in cr2*4+gt. These are
+ only supported on the PowerPC, not the POWER. */
+#define PPC_OPERAND_CR (020)
+
+/* This operand names a register. The disassembler uses this to print
+ register names with a leading 'r'. */
+#define PPC_OPERAND_GPR (040)
+
+/* This operand names a floating point register. The disassembler
+ prints these with a leading 'f'. */
+#define PPC_OPERAND_FPR (0100)
+
+/* This operand is a relative branch displacement. The disassembler
+ prints these symbolically if possible. */
+#define PPC_OPERAND_RELATIVE (0200)
+
+/* This operand is an absolute branch address. The disassembler
+ prints these symbolically if possible. */
+#define PPC_OPERAND_ABSOLUTE (0400)
+
+/* This operand is optional, and is zero if omitted. This is used for
+ the optional BF and L fields in the comparison instructions. The
+ assembler must count the number of operands remaining on the line,
+ and the number of operands remaining for the opcode, and decide
+ whether this operand is present or not. The disassembler should
+ print this operand out only if it is not zero. */
+#define PPC_OPERAND_OPTIONAL (01000)
+
+/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand
+ is omitted, then for the next operand use this operand value plus
+ 1, ignoring the next operand field for the opcode. This wretched
+ hack is needed because the Power rotate instructions can take
+ either 4 or 5 operands. The disassembler should print this operand
+ out regardless of the PPC_OPERAND_OPTIONAL field. */
+#define PPC_OPERAND_NEXT (02000)
+
+/* This operand should be regarded as a negative number for the
+ purposes of overflow checking (i.e., the normal most negative
+ number is disallowed and one more than the normal most positive
+ number is allowed). This flag will only be set for a signed
+ operand. */
+#define PPC_OPERAND_NEGATIVE (04000)
+
+/* The POWER and PowerPC assemblers use a few macros. We keep them
+ with the operands table for simplicity. The macro table is an
+ array of struct powerpc_macro. */
+
+struct powerpc_macro
+{
+ /* The macro name. */
+ const char *name;
+
+ /* The number of operands the macro takes. */
+ unsigned int operands;
+
+ /* One bit flags for the opcode. These are used to indicate which
+ specific processors support the instructions. The values are the
+ same as those for the struct powerpc_opcode flags field. */
+ unsigned long flags;
+
+ /* A format string to turn the macro into a normal instruction.
+ Each %N in the string is replaced with operand number N (zero
+ based). */
+ const char *format;
+};
+
+extern const struct powerpc_macro powerpc_macros[];
+extern const int powerpc_num_macros;
+
+#endif /* PPC_H */
diff --git a/include/opcode/pyr.h b/include/opcode/pyr.h
new file mode 100644
index 00000000000..06632b8d919
--- /dev/null
+++ b/include/opcode/pyr.h
@@ -0,0 +1,287 @@
+/* pyramid.opcode.h -- gdb initial attempt. */
+
+/* pyramid opcode table: wot to do with this
+ particular opcode */
+
+struct pyr_datum
+{
+ char nargs;
+ char * args; /* how to compile said opcode */
+ unsigned long mask; /* Bit vector: which operand modes are valid
+ for this opcode */
+ unsigned char code; /* op-code (always 6(?) bits */
+};
+
+typedef struct pyr_insn_format {
+ unsigned int mode :4;
+ unsigned int operator :8;
+ unsigned int index_scale :2;
+ unsigned int index_reg :6;
+ unsigned int operand_1 :6;
+ unsigned int operand_2:6;
+} pyr_insn_format;
+
+
+/* We store four bytes of opcode for all opcodes.
+ Pyramid is sufficiently RISCy that:
+ - insns are always an integral number of words;
+ - the length of any insn can be told from the first word of
+ the insn. (ie, if there are zero, one, or two words of
+ immediate operand/offset).
+
+
+ The args component is a string containing two characters for each
+ operand of the instruction. The first specifies the kind of operand;
+ the second, the place it is stored. */
+
+/* Kinds of operands:
+ mask assembler syntax description
+ 0x0001: movw Rn,Rn register to register
+ 0x0002: movw K,Rn quick immediate to register
+ 0x0004: movw I,Rn long immediate to register
+ 0x0008: movw (Rn),Rn register indirect to register
+ movw (Rn)[x],Rn register indirect to register
+ 0x0010: movw I(Rn),Rn offset register indirect to register
+ movw I(Rn)[x],Rn offset register indirect, indexed, to register
+
+ 0x0020: movw Rn,(Rn) register to register indirect
+ 0x0040: movw K,(Rn) quick immediate to register indirect
+ 0x0080: movw I,(Rn) long immediate to register indirect
+ 0x0100: movw (Rn),(Rn) register indirect to-register indirect
+ 0x0100: movw (Rn),(Rn) register indirect to-register indirect
+ 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect
+ 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect
+
+ 0x0400: movw Rn,I(Rn) register to register indirect+offset
+ 0x0800: movw K,I(Rn) quick immediate to register indirect+offset
+ 0x1000: movw I,I(Rn) long immediate to register indirect+offset
+ 0x1000: movw (Rn),I(Rn) register indirect to-register indirect+offset
+ 0x1000: movw I(Rn),I(Rn) register indirect+offset to register indirect
+ +offset
+ 0x0000: (irregular) ???
+
+
+ Each insn has a four-bit field encoding the type(s) of its operands.
+*/
+
+/* Some common combinations
+ */
+
+/* the first 5,(0x1|0x2|0x4|0x8|0x10) ie (1|2|4|8|16), ie ( 32 -1)*/
+#define GEN_TO_REG (31)
+
+#define UNKNOWN ((unsigned long)-1)
+#define ANY (GEN_TO_REG | (GEN_TO_REG << 5) | (GEN_TO_REG << 15))
+
+#define CONVERT (1|8|0x10|0x20|0x200)
+
+#define K_TO_REG (2)
+#define I_TO_REG (4)
+#define NOTK_TO_REG (GEN_TO_REG & ~K_TO_REG)
+#define NOTI_TO_REG (GEN_TO_REG & ~I_TO_REG)
+
+/* The assembler requires that this array be sorted as follows:
+ all instances of the same mnemonic must be consecutive.
+ All instances of the same mnemonic with the same number of operands
+ must be consecutive.
+ */
+
+struct pyr_opcode /* pyr opcode text */
+{
+ char * name; /* opcode name: lowercase string [key] */
+ struct pyr_datum datum; /* rest of opcode table [datum] */
+};
+
+#define pyr_how args
+#define pyr_nargs nargs
+#define pyr_mask mask
+#define pyr_name name
+
+struct pyr_opcode pyr_opcodes[] =
+{
+ {"movb", { 2, "", UNKNOWN, 0x11}, },
+ {"movh", { 2, "", UNKNOWN, 0x12} },
+ {"movw", { 2, "", ANY, 0x10} },
+ {"movl", { 2, "", ANY, 0x13} },
+ {"mnegw", { 2, "", (0x1|0x8|0x10), 0x14} },
+ {"mnegf", { 2, "", 0x1, 0x15} },
+ {"mnegd", { 2, "", 0x1, 0x16} },
+ {"mcomw", { 2, "", (0x1|0x8|0x10), 0x17} },
+ {"mabsw", { 2, "", (0x1|0x8|0x10), 0x18} },
+ {"mabsf", { 2, "", 0x1, 0x19} },
+ {"mabsd", { 2, "", 0x1, 0x1a} },
+ {"mtstw", { 2, "", (0x1|0x8|0x10), 0x1c} },
+ {"mtstf", { 2, "", 0x1, 0x1d} },
+ {"mtstd", { 2, "", 0x1, 0x1e} },
+ {"mova", { 2, "", 0x8|0x10, 0x1f} },
+ {"movzbw", { 2, "", (0x1|0x8|0x10), 0x20} },
+ {"movzhw", { 2, "", (0x1|0x8|0x10), 0x21} },
+ /* 2 insns out of order here */
+ {"movbl", { 2, "", 1, 0x4f} },
+ {"filbl", { 2, "", 1, 0x4e} },
+
+ {"cvtbw", { 2, "", CONVERT, 0x22} },
+ {"cvthw", { 2, "", CONVERT, 0x23} },
+ {"cvtwb", { 2, "", CONVERT, 0x24} },
+ {"cvtwh", { 2, "", CONVERT, 0x25} },
+ {"cvtwf", { 2, "", CONVERT, 0x26} },
+ {"cvtwd", { 2, "", CONVERT, 0x27} },
+ {"cvtfw", { 2, "", CONVERT, 0x28} },
+ {"cvtfd", { 2, "", CONVERT, 0x29} },
+ {"cvtdw", { 2, "", CONVERT, 0x2a} },
+ {"cvtdf", { 2, "", CONVERT, 0x2b} },
+
+ {"addw", { 2, "", GEN_TO_REG, 0x40} },
+ {"addwc", { 2, "", GEN_TO_REG, 0x41} },
+ {"subw", { 2, "", GEN_TO_REG, 0x42} },
+ {"subwb", { 2, "", GEN_TO_REG, 0x43} },
+ {"rsubw", { 2, "", GEN_TO_REG, 0x44} },
+ {"mulw", { 2, "", GEN_TO_REG, 0x45} },
+ {"emul", { 2, "", GEN_TO_REG, 0x47} },
+ {"umulw", { 2, "", GEN_TO_REG, 0x46} },
+ {"divw", { 2, "", GEN_TO_REG, 0x48} },
+ {"ediv", { 2, "", GEN_TO_REG, 0x4a} },
+ {"rdivw", { 2, "", GEN_TO_REG, 0x4b} },
+ {"udivw", { 2, "", GEN_TO_REG, 0x49} },
+ {"modw", { 2, "", GEN_TO_REG, 0x4c} },
+ {"umodw", { 2, "", GEN_TO_REG, 0x4d} },
+
+
+ {"addf", { 2, "", 1, 0x50} },
+ {"addd", { 2, "", 1, 0x51} },
+ {"subf", { 2, "", 1, 0x52} },
+ {"subd", { 2, "", 1, 0x53} },
+ {"mulf", { 2, "", 1, 0x56} },
+ {"muld", { 2, "", 1, 0x57} },
+ {"divf", { 2, "", 1, 0x58} },
+ {"divd", { 2, "", 1, 0x59} },
+
+
+ {"cmpb", { 2, "", UNKNOWN, 0x61} },
+ {"cmph", { 2, "", UNKNOWN, 0x62} },
+ {"cmpw", { 2, "", UNKNOWN, 0x60} },
+ {"ucmpb", { 2, "", UNKNOWN, 0x66} },
+ /* WHY no "ucmph"??? */
+ {"ucmpw", { 2, "", UNKNOWN, 0x65} },
+ {"xchw", { 2, "", UNKNOWN, 0x0f} },
+
+
+ {"andw", { 2, "", GEN_TO_REG, 0x30} },
+ {"orw", { 2, "", GEN_TO_REG, 0x31} },
+ {"xorw", { 2, "", GEN_TO_REG, 0x32} },
+ {"bicw", { 2, "", GEN_TO_REG, 0x33} },
+ {"lshlw", { 2, "", GEN_TO_REG, 0x38} },
+ {"ashlw", { 2, "", GEN_TO_REG, 0x3a} },
+ {"ashll", { 2, "", GEN_TO_REG, 0x3c} },
+ {"ashrw", { 2, "", GEN_TO_REG, 0x3b} },
+ {"ashrl", { 2, "", GEN_TO_REG, 0x3d} },
+ {"rotlw", { 2, "", GEN_TO_REG, 0x3e} },
+ {"rotrw", { 2, "", GEN_TO_REG, 0x3f} },
+
+ /* push and pop insns are "going away next release". */
+ {"pushw", { 2, "", GEN_TO_REG, 0x0c} },
+ {"popw", { 2, "", (0x1|0x8|0x10), 0x0d} },
+ {"pusha", { 2, "", (0x8|0x10), 0x0e} },
+
+ {"bitsw", { 2, "", UNKNOWN, 0x35} },
+ {"bitcw", { 2, "", UNKNOWN, 0x36} },
+ /* some kind of ibra/dbra insns??*/
+ {"icmpw", { 2, "", UNKNOWN, 0x67} },
+ {"dcmpw", { 2, "", (1|4|0x20|0x80|0x400|0x1000), 0x69} },/*FIXME*/
+ {"acmpw", { 2, "", 1, 0x6b} },
+
+ /* Call is written as a 1-op insn, but is always (dis)assembled as a 2-op
+ insn with a 2nd op of tr14. The assembler will have to grok this. */
+ {"call", { 2, "", GEN_TO_REG, 0x04} },
+ {"call", { 1, "", GEN_TO_REG, 0x04} },
+
+ {"callk", { 1, "", UNKNOWN, 0x06} },/* system call?*/
+ /* Ret is usually written as a 0-op insn, but gets disassembled as a
+ 1-op insn. The operand is always tr15. */
+ {"ret", { 0, "", UNKNOWN, 0x09} },
+ {"ret", { 1, "", UNKNOWN, 0x09} },
+ {"adsf", { 2, "", (1|2|4), 0x08} },
+ {"retd", { 2, "", UNKNOWN, 0x0a} },
+ {"btc", { 2, "", UNKNOWN, 0x01} },
+ {"bfc", { 2, "", UNKNOWN, 0x02} },
+ /* Careful: halt is 0x00000000. Jump must have some other (mode?)bit set?? */
+ {"jump", { 1, "", UNKNOWN, 0x00} },
+ {"btp", { 2, "", UNKNOWN, 0xf00} },
+ /* read control-stack pointer is another 1-or-2 operand insn. */
+ {"rcsp", { 2, "", UNKNOWN, 0x01f} },
+ {"rcsp", { 1, "", UNKNOWN, 0x01f} }
+};
+
+/* end: pyramid.opcode.h */
+/* One day I will have to take the time to find out what operands
+ are valid for these insns, and guess at what they mean.
+
+ I can't imagine what the "I???" insns (iglob, etc) do.
+
+ the arithmetic-sounding insns ending in "p" sound awfully like BCD
+ arithmetic insns:
+ dshlp -> Decimal SHift Left Packed
+ dshrp -> Decimal SHift Right Packed
+ and cvtlp would be convert long to packed.
+ I have no idea how the operands are interpreted; but having them be
+ a long register with (address, length) of an in-memory packed BCD operand
+ would not be surprising.
+ They are unlikely to be a packed bcd string: 64 bits of long give
+ is only 15 digits+sign, which isn't enough for COBOL.
+ */
+#if 0
+ {"wcsp", { 2, "", UNKNOWN, 0x00} }, /*write csp?*/
+ /* The OSx Operating System Porting Guide claims SSL does things
+ with tr12 (a register reserved to it) to do with static block-structure
+ references. SSL=Set Static Link? It's "Going away next release". */
+ {"ssl", { 2, "", UNKNOWN, 0x00} },
+ {"ccmps", { 2, "", UNKNOWN, 0x00} },
+ {"lcd", { 2, "", UNKNOWN, 0x00} },
+ {"uemul", { 2, "", UNKNOWN, 0x00} }, /*unsigned emul*/
+ {"srf", { 2, "", UNKNOWN, 0x00} }, /*Gidget time???*/
+ {"mnegp", { 2, "", UNKNOWN, 0x00} }, /move-neg phys?*/
+ {"ldp", { 2, "", UNKNOWN, 0x00} }, /*load phys?*/
+ {"ldti", { 2, "", UNKNOWN, 0x00} },
+ {"ldb", { 2, "", UNKNOWN, 0x00} },
+ {"stp", { 2, "", UNKNOWN, 0x00} },
+ {"stti", { 2, "", UNKNOWN, 0x00} },
+ {"stb", { 2, "", UNKNOWN, 0x00} },
+ {"stu", { 2, "", UNKNOWN, 0x00} },
+ {"addp", { 2, "", UNKNOWN, 0x00} },
+ {"subp", { 2, "", UNKNOWN, 0x00} },
+ {"mulp", { 2, "", UNKNOWN, 0x00} },
+ {"divp", { 2, "", UNKNOWN, 0x00} },
+ {"dshlp", { 2, "", UNKNOWN, 0x00} }, /* dec shl packed? */
+ {"dshrp", { 2, "", UNKNOWN, 0x00} }, /* dec shr packed? */
+ {"movs", { 2, "", UNKNOWN, 0x00} }, /*move (string?)?*/
+ {"cmpp", { 2, "", UNKNOWN, 0x00} }, /* cmp phys?*/
+ {"cmps", { 2, "", UNKNOWN, 0x00} }, /* cmp (string?)?*/
+ {"cvtlp", { 2, "", UNKNOWN, 0x00} }, /* cvt long to p??*/
+ {"cvtpl", { 2, "", UNKNOWN, 0x00} }, /* cvt p to l??*/
+ {"dintr", { 2, "", UNKNOWN, 0x00} }, /* ?? intr ?*/
+ {"rphysw", { 2, "", UNKNOWN, 0x00} }, /* read phys word?*/
+ {"wphysw", { 2, "", UNKNOWN, 0x00} }, /* write phys word?*/
+ {"cmovs", { 2, "", UNKNOWN, 0x00} },
+ {"rsubw", { 2, "", UNKNOWN, 0x00} },
+ {"bicpsw", { 2, "", UNKNOWN, 0x00} }, /* clr bit in psw? */
+ {"bispsw", { 2, "", UNKNOWN, 0x00} }, /* set bit in psw? */
+ {"eio", { 2, "", UNKNOWN, 0x00} }, /* ?? ?io ? */
+ {"callp", { 2, "", UNKNOWN, 0x00} }, /* call phys?*/
+ {"callr", { 2, "", UNKNOWN, 0x00} },
+ {"lpcxt", { 2, "", UNKNOWN, 0x00} }, /*load proc context*/
+ {"rei", { 2, "", UNKNOWN, 0x00} }, /*ret from intrpt*/
+ {"rport", { 2, "", UNKNOWN, 0x00} }, /*read-port?*/
+ {"rtod", { 2, "", UNKNOWN, 0x00} }, /*read-time-of-day?*/
+ {"ssi", { 2, "", UNKNOWN, 0x00} },
+ {"vtpa", { 2, "", UNKNOWN, 0x00} }, /*virt-to-phys-addr?*/
+ {"wicl", { 2, "", UNKNOWN, 0x00} }, /* write icl ? */
+ {"wport", { 2, "", UNKNOWN, 0x00} }, /*write-port?*/
+ {"wtod", { 2, "", UNKNOWN, 0x00} }, /*write-time-of-day?*/
+ {"flic", { 2, "", UNKNOWN, 0x00} },
+ {"iglob", { 2, "", UNKNOWN, 0x00} }, /* I global? */
+ {"iphys", { 2, "", UNKNOWN, 0x00} }, /* I physical? */
+ {"ipid", { 2, "", UNKNOWN, 0x00} }, /* I pid? */
+ {"ivect", { 2, "", UNKNOWN, 0x00} }, /* I vector? */
+ {"lamst", { 2, "", UNKNOWN, 0x00} },
+ {"tio", { 2, "", UNKNOWN, 0x00} },
+#endif
diff --git a/include/opcode/sparc.h b/include/opcode/sparc.h
new file mode 100644
index 00000000000..4f159bd896f
--- /dev/null
+++ b/include/opcode/sparc.h
@@ -0,0 +1,240 @@
+/* Definitions for opcode table for the sparc.
+ Copyright (C) 1989, 91, 92, 93, 94, 95, 96, 1997
+ Free Software Foundation, Inc.
+
+This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
+the GNU Binutils.
+
+GAS/GDB is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <ansidecl.h>
+
+/* The SPARC opcode table (and other related data) is defined in
+ the opcodes library in sparc-opc.c. If you change anything here, make
+ sure you fix up that file, and vice versa. */
+
+ /* FIXME-someday: perhaps the ,a's and such should be embedded in the
+ instruction's name rather than the args. This would make gas faster, pinsn
+ slower, but would mess up some macros a bit. xoxorich. */
+
+/* List of instruction sets variations.
+ These values are such that each element is either a superset of a
+ preceding each one or they conflict in which case SPARC_OPCODE_CONFLICT_P
+ returns non-zero.
+ The values are indices into `sparc_opcode_archs' defined in sparc-opc.c.
+ Don't change this without updating sparc-opc.c. */
+
+enum sparc_opcode_arch_val {
+ SPARC_OPCODE_ARCH_V6 = 0,
+ SPARC_OPCODE_ARCH_V7,
+ SPARC_OPCODE_ARCH_V8,
+ SPARC_OPCODE_ARCH_SPARCLET,
+ SPARC_OPCODE_ARCH_SPARCLITE,
+ /* v9 variants must appear last */
+ SPARC_OPCODE_ARCH_V9,
+ SPARC_OPCODE_ARCH_V9A, /* v9 with ultrasparc additions */
+ SPARC_OPCODE_ARCH_BAD /* error return from sparc_opcode_lookup_arch */
+};
+
+/* The highest architecture in the table. */
+#define SPARC_OPCODE_ARCH_MAX (SPARC_OPCODE_ARCH_BAD - 1)
+
+/* Given an enum sparc_opcode_arch_val, return the bitmask to use in
+ insn encoding/decoding. */
+#define SPARC_OPCODE_ARCH_MASK(arch) (1 << (arch))
+
+/* Given a valid sparc_opcode_arch_val, return non-zero if it's v9. */
+#define SPARC_OPCODE_ARCH_V9_P(arch) ((arch) >= SPARC_OPCODE_ARCH_V9)
+
+/* Table of cpu variants. */
+
+struct sparc_opcode_arch {
+ const char *name;
+ /* Mask of sparc_opcode_arch_val's supported.
+ EG: For v7 this would be
+ (SPARC_OPCODE_ARCH_MASK (..._V6) | SPARC_OPCODE_ARCH_MASK (..._V7)).
+ These are short's because sparc_opcode.architecture is. */
+ short supported;
+};
+
+extern const struct sparc_opcode_arch sparc_opcode_archs[];
+
+/* Given architecture name, look up it's sparc_opcode_arch_val value. */
+extern enum sparc_opcode_arch_val sparc_opcode_lookup_arch
+ PARAMS ((const char *));
+
+/* Return the bitmask of supported architectures for ARCH. */
+#define SPARC_OPCODE_SUPPORTED(ARCH) (sparc_opcode_archs[ARCH].supported)
+
+/* Non-zero if ARCH1 conflicts with ARCH2.
+ IE: ARCH1 as a supported bit set that ARCH2 doesn't, and vice versa. */
+#define SPARC_OPCODE_CONFLICT_P(ARCH1, ARCH2) \
+(((SPARC_OPCODE_SUPPORTED (ARCH1) & SPARC_OPCODE_SUPPORTED (ARCH2)) \
+ != SPARC_OPCODE_SUPPORTED (ARCH1)) \
+ && ((SPARC_OPCODE_SUPPORTED (ARCH1) & SPARC_OPCODE_SUPPORTED (ARCH2)) \
+ != SPARC_OPCODE_SUPPORTED (ARCH2)))
+
+/* Structure of an opcode table entry. */
+
+struct sparc_opcode {
+ const char *name;
+ unsigned long match; /* Bits that must be set. */
+ unsigned long lose; /* Bits that must not be set. */
+ const char *args;
+ /* This was called "delayed" in versions before the flags. */
+ char flags;
+ short architecture; /* Bitmask of sparc_opcode_arch_val's. */
+};
+
+#define F_DELAYED 1 /* Delayed branch */
+#define F_ALIAS 2 /* Alias for a "real" instruction */
+#define F_UNBR 4 /* Unconditional branch */
+#define F_CONDBR 8 /* Conditional branch */
+#define F_JSR 16 /* Subroutine call */
+#define F_FLOAT 32 /* Floating point instruction (not a branch) */
+#define F_FBR 64 /* Floating point branch */
+/* FIXME: Add F_ANACHRONISTIC flag for v9. */
+
+/*
+
+All sparc opcodes are 32 bits, except for the `set' instruction (really a
+macro), which is 64 bits. It is handled as a special case.
+
+The match component is a mask saying which bits must match a particular
+opcode in order for an instruction to be an instance of that opcode.
+
+The args component is a string containing one character for each operand of the
+instruction.
+
+Kinds of operands:
+ # Number used by optimizer. It is ignored.
+ 1 rs1 register.
+ 2 rs2 register.
+ d rd register.
+ e frs1 floating point register.
+ v frs1 floating point register (double/even).
+ V frs1 floating point register (quad/multiple of 4).
+ f frs2 floating point register.
+ B frs2 floating point register (double/even).
+ R frs2 floating point register (quad/multiple of 4).
+ g frsd floating point register.
+ H frsd floating point register (double/even).
+ J frsd floating point register (quad/multiple of 4).
+ b crs1 coprocessor register
+ c crs2 coprocessor register
+ D crsd coprocessor register
+ m alternate space register (asr) in rd
+ M alternate space register (asr) in rs1
+ h 22 high bits.
+ X 5 bit unsigned immediate
+ Y 6 bit unsigned immediate
+ K MEMBAR mask (7 bits). (v9)
+ j 10 bit Immediate. (v9)
+ I 11 bit Immediate. (v9)
+ i 13 bit Immediate.
+ n 22 bit immediate.
+ k 2+14 bit PC relative immediate. (v9)
+ G 19 bit PC relative immediate. (v9)
+ l 22 bit PC relative immediate.
+ L 30 bit PC relative immediate.
+ a Annul. The annul bit is set.
+ A Alternate address space. Stored as 8 bits.
+ C Coprocessor state register.
+ F floating point state register.
+ p Processor state register.
+ N Branch predict clear ",pn" (v9)
+ T Branch predict set ",pt" (v9)
+ z %icc. (v9)
+ Z %xcc. (v9)
+ q Floating point queue.
+ r Single register that is both rs1 and rd.
+ O Single register that is both rs2 and rd.
+ Q Coprocessor queue.
+ S Special case.
+ t Trap base register.
+ w Window invalid mask register.
+ y Y register.
+ u sparclet coprocessor registers in rd position
+ U sparclet coprocessor registers in rs1 position
+ E %ccr. (v9)
+ s %fprs. (v9)
+ P %pc. (v9)
+ W %tick. (v9)
+ o %asi. (v9)
+ 6 %fcc0. (v9)
+ 7 %fcc1. (v9)
+ 8 %fcc2. (v9)
+ 9 %fcc3. (v9)
+ ! Privileged Register in rd (v9)
+ ? Privileged Register in rs1 (v9)
+ * Prefetch function constant. (v9)
+ x OPF field (v9 impdep).
+ 0 32/64 bit immediate for set or setx (v9) insns
+ _ Ancillary state register in rd (v9a)
+ / Ancillary state register in rs1 (v9a)
+
+The following chars are unused: (note: ,[] are used as punctuation)
+[345]
+
+*/
+
+#define OP2(x) (((x)&0x7) << 22) /* op2 field of format2 insns */
+#define OP3(x) (((x)&0x3f) << 19) /* op3 field of format3 insns */
+#define OP(x) ((unsigned)((x)&0x3) << 30) /* op field of all insns */
+#define OPF(x) (((x)&0x1ff) << 5) /* opf field of float insns */
+#define OPF_LOW5(x) OPF((x)&0x1f) /* v9 */
+#define F3F(x, y, z) (OP(x) | OP3(y) | OPF(z)) /* format3 float insns */
+#define F3I(x) (((x)&0x1) << 13) /* immediate field of format 3 insns */
+#define F2(x, y) (OP(x) | OP2(y)) /* format 2 insns */
+#define F3(x, y, z) (OP(x) | OP3(y) | F3I(z)) /* format3 insns */
+#define F1(x) (OP(x))
+#define DISP30(x) ((x)&0x3fffffff)
+#define ASI(x) (((x)&0xff) << 5) /* asi field of format3 insns */
+#define RS2(x) ((x)&0x1f) /* rs2 field */
+#define SIMM13(x) ((x)&0x1fff) /* simm13 field */
+#define RD(x) (((x)&0x1f) << 25) /* destination register field */
+#define RS1(x) (((x)&0x1f) << 14) /* rs1 field */
+#define ASI_RS2(x) (SIMM13(x))
+#define MEMBAR(x) ((x)&0x7f)
+#define SLCPOP(x) (((x)&0x7f) << 6) /* sparclet cpop */
+
+#define ANNUL (1<<29)
+#define BPRED (1<<19) /* v9 */
+#define IMMED F3I(1)
+#define RD_G0 RD(~0)
+#define RS1_G0 RS1(~0)
+#define RS2_G0 RS2(~0)
+
+extern const struct sparc_opcode sparc_opcodes[];
+extern const int sparc_num_opcodes;
+
+extern int sparc_encode_asi PARAMS ((const char *));
+extern const char *sparc_decode_asi PARAMS ((int));
+extern int sparc_encode_membar PARAMS ((const char *));
+extern const char *sparc_decode_membar PARAMS ((int));
+extern int sparc_encode_prefetch PARAMS ((const char *));
+extern const char *sparc_decode_prefetch PARAMS ((int));
+extern int sparc_encode_sparclet_cpreg PARAMS ((const char *));
+extern const char *sparc_decode_sparclet_cpreg PARAMS ((int));
+
+/*
+ * Local Variables:
+ * fill-column: 131
+ * comment-column: 0
+ * End:
+ */
+
+/* end of sparc.h */
diff --git a/include/opcode/tahoe.h b/include/opcode/tahoe.h
new file mode 100644
index 00000000000..b5cee249ee4
--- /dev/null
+++ b/include/opcode/tahoe.h
@@ -0,0 +1,213 @@
+/*
+ * Ported by the State University of New York at Buffalo by the Distributed
+ * Computer Systems Lab, Department of Computer Science, 1991.
+ */
+
+#ifndef tahoe_opcodeT
+#define tahoe_opcodeT int
+#endif /* no tahoe_opcodeT */
+
+struct vot_wot /* tahoe opcode table: wot to do with this */
+ /* particular opcode */
+{
+ char * args; /* how to compile said opcode */
+ tahoe_opcodeT code; /* op-code (may be > 8 bits!) */
+};
+
+struct vot /* tahoe opcode text */
+{
+ char * name; /* opcode name: lowercase string [key] */
+ struct vot_wot detail; /* rest of opcode table [datum] */
+};
+
+#define vot_how args
+#define vot_code code
+#define vot_detail detail
+#define vot_name name
+
+static struct vot
+votstrs[] =
+{
+{ "halt", {"", 0x00 } },
+{ "sinf", {"", 0x05 } },
+{ "ldf", {"rl", 0x06 } },
+{ "ldd", {"rq", 0x07 } },
+{ "addb2", {"rbmb", 0x08 } },
+{ "movb", {"rbwb", 0x09 } },
+{ "addw2", {"rwmw", 0x0a } },
+{ "movw", {"rwww", 0x0b } },
+{ "addl2", {"rlml", 0x0c } },
+{ "movl", {"rlwl", 0x0d } },
+{ "bbs", {"rlvlbw", 0x0e } },
+{ "nop", {"", 0x10 } },
+{ "brb", {"bb", 0x11 } },
+{ "brw", {"bw", 0x13 } },
+{ "cosf", {"", 0x15 } },
+{ "lnf", {"rl", 0x16 } },
+{ "lnd", {"rq", 0x17 } },
+{ "addb3", {"rbrbwb", 0x18 } },
+{ "cmpb", {"rbwb", 0x19 } },
+{ "addw3", {"rwrwww", 0x1a } },
+{ "cmpw", {"rwww", 0x1b } },
+{ "addl3", {"rlrlwl", 0x1c } },
+{ "cmpl", {"rlwl", 0x1d } },
+{ "bbc", {"rlvlbw", 0x1e } },
+{ "rei", {"", 0x20 } },
+{ "bneq", {"bb", 0x21 } },
+{ "bnequ", {"bb", 0x21 } },
+{ "cvtwl", {"rwwl", 0x23 } },
+{ "stf", {"wl", 0x26 } },
+{ "std", {"wq", 0x27 } },
+{ "subb2", {"rbmb", 0x28 } },
+{ "mcomb", {"rbwb", 0x29 } },
+{ "subw2", {"rwmw", 0x2a } },
+{ "mcomw", {"rwww", 0x2b } },
+{ "subl2", {"rlml", 0x2c } },
+{ "mcoml", {"rlwl", 0x2d } },
+{ "emul", {"rlrlrlwq", 0x2e } },
+{ "aoblss", {"rlmlbw", 0x2f } },
+{ "bpt", {"", 0x30 } },
+{ "beql", {"bb", 0x31 } },
+{ "beqlu", {"bb", 0x31 } },
+{ "cvtwb", {"rwwb", 0x33 } },
+{ "logf", {"", 0x35 } },
+{ "cmpf", {"rl", 0x36 } },
+{ "cmpd", {"rq", 0x37 } },
+{ "subb3", {"rbrbwb", 0x38 } },
+{ "bitb", {"rbrb", 0x39 } },
+{ "subw3", {"rwrwww", 0x3a } },
+{ "bitw", {"rwrw", 0x3b } },
+{ "subl3", {"rlrlwl", 0x3c } },
+{ "bitl", {"rlrl", 0x3d } },
+{ "ediv", {"rlrqwlwl", 0x3e } },
+{ "aobleq", {"rlmlbw", 0x3f } },
+{ "ret", {"", 0x40 } },
+{ "bgtr", {"bb", 0x41 } },
+{ "sqrtf", {"", 0x45 } },
+{ "cmpf2", {"rl", 0x46 } },
+{ "cmpd2", {"rqrq", 0x47 } },
+{ "shll", {"rbrlwl", 0x48 } },
+{ "clrb", {"wb", 0x49 } },
+{ "shlq", {"rbrqwq", 0x4a } },
+{ "clrw", {"ww", 0x4b } },
+{ "mull2", {"rlml", 0x4c } },
+{ "clrl", {"wl", 0x4d } },
+{ "shal", {"rbrlwl", 0x4e } },
+{ "bleq", {"bb", 0x51 } },
+{ "expf", {"", 0x55 } },
+{ "tstf", {"", 0x56 } },
+{ "tstd", {"", 0x57 } },
+{ "shrl", {"rbrlwl", 0x58 } },
+{ "tstb", {"rb", 0x59 } },
+{ "shrq", {"rbrqwq", 0x5a } },
+{ "tstw", {"rw", 0x5b } },
+{ "mull3", {"rlrlwl", 0x5c } },
+{ "tstl", {"rl", 0x5d } },
+{ "shar", {"rbrlwl", 0x5e } },
+{ "bbssi", {"rlmlbw", 0x5f } },
+{ "ldpctx", {"", 0x60 } },
+{ "pushd", {"", 0x67 } },
+{ "incb", {"mb", 0x69 } },
+{ "incw", {"mw", 0x6b } },
+{ "divl2", {"rlml", 0x6c } },
+{ "incl", {"ml", 0x6d } },
+{ "cvtlb", {"rlwb", 0x6f } },
+{ "svpctx", {"", 0x70 } },
+{ "jmp", {"ab", 0x71 } },
+{ "cvlf", {"rl", 0x76 } },
+{ "cvld", {"rl", 0x77 } },
+{ "decb", {"mb", 0x79 } },
+{ "decw", {"mw", 0x7b } },
+{ "divl3", {"rlrlwl", 0x7c } },
+{ "decl", {"ml", 0x7d } },
+{ "cvtlw", {"rlww", 0x7f } },
+{ "bgeq", {"bb", 0x81 } },
+{ "movs2", {"abab", 0x82 } },
+{ "cvfl", {"wl", 0x86 } },
+{ "cvdl", {"wl", 0x87 } },
+{ "orb2", {"rbmb", 0x88 } },
+{ "cvtbl", {"rbwl", 0x89 } },
+{ "orw2", {"rwmw", 0x8a } },
+{ "bispsw", {"rw", 0x8b } },
+{ "orl2", {"rlml", 0x8c } },
+{ "adwc", {"rlml", 0x8d } },
+{ "adda", {"rlml", 0x8e } },
+{ "blss", {"bb", 0x91 } },
+{ "cmps2", {"abab", 0x92 } },
+{ "ldfd", {"rl", 0x97 } },
+{ "orb3", {"rbrbwb", 0x98 } },
+{ "cvtbw", {"rbww", 0x99 } },
+{ "orw3", {"rwrwww", 0x9a } },
+{ "bicpsw", {"rw", 0x9b } },
+{ "orl3", {"rlrlwl", 0x9c } },
+{ "sbwc", {"rlml", 0x9d } },
+{ "suba", {"rlml", 0x9e } },
+{ "bgtru", {"bb", 0xa1 } },
+{ "cvdf", {"", 0xa6 } },
+{ "andb2", {"rbmb", 0xa8 } },
+{ "movzbl", {"rbwl", 0xa9 } },
+{ "andw2", {"rwmw", 0xaa } },
+{ "loadr", {"rwal", 0xab } },
+{ "andl2", {"rlml", 0xac } },
+{ "mtpr", {"rlrl", 0xad } },
+{ "ffs", {"rlwl", 0xae } },
+{ "blequ", {"bb", 0xb1 } },
+{ "negf", {"", 0xb6 } },
+{ "negd", {"", 0xb7 } },
+{ "andb3", {"rbrbwb", 0xb8 } },
+{ "movzbw", {"rbww", 0xb9 } },
+{ "andw3", {"rwrwww", 0xba } },
+{ "storer", {"rwal", 0xbb } },
+{ "andl3", {"rlrlwl", 0xbc } },
+{ "mfpr", {"rlwl", 0xbd } },
+{ "ffc", {"rlwl", 0xbe } },
+{ "calls", {"rbab", 0xbf } },
+{ "prober", {"rbabrl", 0xc0 } },
+{ "bvc", {"bb", 0xc1 } },
+{ "movs3", {"ababrw", 0xc2 } },
+{ "movzwl", {"rwwl", 0xc3 } },
+{ "addf", {"rl", 0xc6 } },
+{ "addd", {"rq", 0xc7 } },
+{ "xorb2", {"rbmb", 0xc8 } },
+{ "movob", {"rbwb", 0xc9 } },
+{ "xorw2", {"rwmw", 0xca } },
+{ "movow", {"rwww", 0xcb } },
+{ "xorl2", {"rlml", 0xcc } },
+{ "movpsl", {"wl", 0xcd } },
+{ "kcall", {"rw", 0xcf } },
+{ "probew", {"rbabrl", 0xd0 } },
+{ "bvs", {"bb", 0xd1 } },
+{ "cmps3", {"ababrw", 0xd2 } },
+{ "subf", {"rq", 0xd6 } },
+{ "subd", {"rq", 0xd7 } },
+{ "xorb3", {"rbrbwb", 0xd8 } },
+{ "pushb", {"rb", 0xd9 } },
+{ "xorw3", {"rwrwww", 0xda } },
+{ "pushw", {"rw", 0xdb } },
+{ "xorl3", {"rlrlwl", 0xdc } },
+{ "pushl", {"rl", 0xdd } },
+{ "insque", {"abab", 0xe0 } },
+{ "bcs", {"bb", 0xe1 } },
+{ "bgequ", {"bb", 0xe1 } },
+{ "mulf", {"rq", 0xe6 } },
+{ "muld", {"rq", 0xe7 } },
+{ "mnegb", {"rbwb", 0xe8 } },
+{ "movab", {"abwl", 0xe9 } },
+{ "mnegw", {"rwww", 0xea } },
+{ "movaw", {"awwl", 0xeb } },
+{ "mnegl", {"rlwl", 0xec } },
+{ "moval", {"alwl", 0xed } },
+{ "remque", {"ab", 0xf0 } },
+{ "bcc", {"bb", 0xf1 } },
+{ "blssu", {"bb", 0xf1 } },
+{ "divf", {"rq", 0xf6 } },
+{ "divd", {"rq", 0xf7 } },
+{ "movblk", {"alalrw", 0xf8 } },
+{ "pushab", {"ab", 0xf9 } },
+{ "pushaw", {"aw", 0xfb } },
+{ "casel", {"rlrlrl", 0xfc } },
+{ "pushal", {"al", 0xfd } },
+{ "callf", {"rbab", 0xfe } },
+{ "" , "" } /* empty is end sentinel */
+
+};
diff --git a/include/opcode/tic30.h b/include/opcode/tic30.h
new file mode 100644
index 00000000000..a7002759118
--- /dev/null
+++ b/include/opcode/tic30.h
@@ -0,0 +1,691 @@
+/* tic30.h -- Header file for TI TMS320C30 opcode table
+ Copyright 1998 Free Software Foundation, Inc.
+ Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+/* FIXME: The opcode table should be in opcodes/tic30-opc.c, not in a
+ header file. */
+
+#ifndef _TMS320_H_
+#define _TMS320_H_
+
+struct _register
+{
+ char *name;
+ unsigned char opcode;
+ unsigned char regtype;
+};
+
+typedef struct _register reg;
+
+#define REG_Rn 0x01
+#define REG_ARn 0x02
+#define REG_DP 0x03
+#define REG_OTHER 0x04
+
+static const reg tic30_regtab[] = {
+ { "r0", 0x00, REG_Rn },
+ { "r1", 0x01, REG_Rn },
+ { "r2", 0x02, REG_Rn },
+ { "r3", 0x03, REG_Rn },
+ { "r4", 0x04, REG_Rn },
+ { "r5", 0x05, REG_Rn },
+ { "r6", 0x06, REG_Rn },
+ { "r7", 0x07, REG_Rn },
+ { "ar0",0x08, REG_ARn },
+ { "ar1",0x09, REG_ARn },
+ { "ar2",0x0A, REG_ARn },
+ { "ar3",0x0B, REG_ARn },
+ { "ar4",0x0C, REG_ARn },
+ { "ar5",0x0D, REG_ARn },
+ { "ar6",0x0E, REG_ARn },
+ { "ar7",0x0F, REG_ARn },
+ { "dp", 0x10, REG_DP },
+ { "ir0",0x11, REG_OTHER },
+ { "ir1",0x12, REG_OTHER },
+ { "bk", 0x13, REG_OTHER },
+ { "sp", 0x14, REG_OTHER },
+ { "st", 0x15, REG_OTHER },
+ { "ie", 0x16, REG_OTHER },
+ { "if", 0x17, REG_OTHER },
+ { "iof",0x18, REG_OTHER },
+ { "rs", 0x19, REG_OTHER },
+ { "re", 0x1A, REG_OTHER },
+ { "rc", 0x1B, REG_OTHER },
+ { "R0", 0x00, REG_Rn },
+ { "R1", 0x01, REG_Rn },
+ { "R2", 0x02, REG_Rn },
+ { "R3", 0x03, REG_Rn },
+ { "R4", 0x04, REG_Rn },
+ { "R5", 0x05, REG_Rn },
+ { "R6", 0x06, REG_Rn },
+ { "R7", 0x07, REG_Rn },
+ { "AR0",0x08, REG_ARn },
+ { "AR1",0x09, REG_ARn },
+ { "AR2",0x0A, REG_ARn },
+ { "AR3",0x0B, REG_ARn },
+ { "AR4",0x0C, REG_ARn },
+ { "AR5",0x0D, REG_ARn },
+ { "AR6",0x0E, REG_ARn },
+ { "AR7",0x0F, REG_ARn },
+ { "DP", 0x10, REG_DP },
+ { "IR0",0x11, REG_OTHER },
+ { "IR1",0x12, REG_OTHER },
+ { "BK", 0x13, REG_OTHER },
+ { "SP", 0x14, REG_OTHER },
+ { "ST", 0x15, REG_OTHER },
+ { "IE", 0x16, REG_OTHER },
+ { "IF", 0x17, REG_OTHER },
+ { "IOF",0x18, REG_OTHER },
+ { "RS", 0x19, REG_OTHER },
+ { "RE", 0x1A, REG_OTHER },
+ { "RC", 0x1B, REG_OTHER },
+ { "", 0, 0 }
+};
+
+static const reg *const tic30_regtab_end
+ = tic30_regtab + sizeof(tic30_regtab)/sizeof(tic30_regtab[0]);
+
+/* Indirect Addressing Modes Modification Fields */
+/* Indirect Addressing with Displacement */
+#define PreDisp_Add 0x00
+#define PreDisp_Sub 0x01
+#define PreDisp_Add_Mod 0x02
+#define PreDisp_Sub_Mod 0x03
+#define PostDisp_Add_Mod 0x04
+#define PostDisp_Sub_Mod 0x05
+#define PostDisp_Add_Circ 0x06
+#define PostDisp_Sub_Circ 0x07
+/* Indirect Addressing with Index Register IR0 */
+#define PreIR0_Add 0x08
+#define PreIR0_Sub 0x09
+#define PreIR0_Add_Mod 0x0A
+#define PreIR0_Sub_Mod 0x0B
+#define PostIR0_Add_Mod 0x0C
+#define PostIR0_Sub_Mod 0x0D
+#define PostIR0_Add_Circ 0x0E
+#define PostIR0_Sub_Circ 0x0F
+/* Indirect Addressing with Index Register IR1 */
+#define PreIR1_Add 0x10
+#define PreIR1_Sub 0x11
+#define PreIR1_Add_Mod 0x12
+#define PreIR1_Sub_Mod 0x13
+#define PostIR1_Add_Mod 0x14
+#define PostIR1_Sub_Mod 0x15
+#define PostIR1_Add_Circ 0x16
+#define PostIR1_Sub_Circ 0x17
+/* Indirect Addressing (Special Cases) */
+#define IndirectOnly 0x18
+#define PostIR0_Add_BitRev 0x19
+
+typedef struct {
+ char *syntax;
+ unsigned char modfield;
+ unsigned char displacement;
+} ind_addr_type;
+
+#define IMPLIED_DISP 0x01
+#define DISP_REQUIRED 0x02
+#define NO_DISP 0x03
+
+static const ind_addr_type tic30_indaddr_tab[] = {
+ { "*+ar", PreDisp_Add, IMPLIED_DISP },
+ { "*-ar", PreDisp_Sub, IMPLIED_DISP },
+ { "*++ar", PreDisp_Add_Mod, IMPLIED_DISP },
+ { "*--ar", PreDisp_Sub_Mod, IMPLIED_DISP },
+ { "*ar++", PostDisp_Add_Mod, IMPLIED_DISP },
+ { "*ar--", PostDisp_Sub_Mod, IMPLIED_DISP },
+ { "*ar++%", PostDisp_Add_Circ, IMPLIED_DISP },
+ { "*ar--%", PostDisp_Sub_Circ, IMPLIED_DISP },
+ { "*+ar()", PreDisp_Add, DISP_REQUIRED },
+ { "*-ar()", PreDisp_Sub, DISP_REQUIRED },
+ { "*++ar()", PreDisp_Add_Mod, DISP_REQUIRED },
+ { "*--ar()", PreDisp_Sub_Mod, DISP_REQUIRED },
+ { "*ar++()", PostDisp_Add_Mod, DISP_REQUIRED },
+ { "*ar--()", PostDisp_Sub_Mod, DISP_REQUIRED },
+ { "*ar++()%", PostDisp_Add_Circ, DISP_REQUIRED },
+ { "*ar--()%", PostDisp_Sub_Circ, DISP_REQUIRED },
+ { "*+ar(ir0)", PreIR0_Add, NO_DISP },
+ { "*-ar(ir0)", PreIR0_Sub, NO_DISP },
+ { "*++ar(ir0)", PreIR0_Add_Mod, NO_DISP },
+ { "*--ar(ir0)", PreIR0_Sub_Mod, NO_DISP },
+ { "*ar++(ir0)", PostIR0_Add_Mod, NO_DISP },
+ { "*ar--(ir0)", PostIR0_Sub_Mod, NO_DISP },
+ { "*ar++(ir0)%",PostIR0_Add_Circ, NO_DISP },
+ { "*ar--(ir0)%",PostIR0_Sub_Circ, NO_DISP },
+ { "*+ar(ir1)", PreIR1_Add, NO_DISP },
+ { "*-ar(ir1)", PreIR1_Sub, NO_DISP },
+ { "*++ar(ir1)", PreIR1_Add_Mod, NO_DISP },
+ { "*--ar(ir1)", PreIR1_Sub_Mod, NO_DISP },
+ { "*ar++(ir1)", PostIR1_Add_Mod, NO_DISP },
+ { "*ar--(ir1)", PostIR1_Sub_Mod, NO_DISP },
+ { "*ar++(ir1)%",PostIR1_Add_Circ, NO_DISP },
+ { "*ar--(ir1)%",PostIR1_Sub_Circ, NO_DISP },
+ { "*ar", IndirectOnly, NO_DISP },
+ { "*ar++(ir0)b",PostIR0_Add_BitRev, NO_DISP },
+ { "", 0,0 }
+};
+
+static const ind_addr_type *const tic30_indaddrtab_end
+ = tic30_indaddr_tab + sizeof(tic30_indaddr_tab)/sizeof(tic30_indaddr_tab[0]);
+
+/* Possible operand types */
+/* Register types */
+#define Rn 0x0001
+#define ARn 0x0002
+#define DPReg 0x0004
+#define OtherReg 0x0008
+/* Addressing mode types */
+#define Direct 0x0010
+#define Indirect 0x0020
+#define Imm16 0x0040
+#define Disp 0x0080
+#define Imm24 0x0100
+#define Abs24 0x0200
+/* 3 operand addressing mode types */
+#define op3T1 0x0400
+#define op3T2 0x0800
+/* Interrupt vector */
+#define IVector 0x1000
+/* Not required */
+#define NotReq 0x2000
+
+#define GAddr1 Rn | Direct | Indirect | Imm16
+#define GAddr2 GAddr1 | AllReg
+#define TAddr1 op3T1 | Rn | Indirect
+#define TAddr2 op3T2 | Rn | Indirect
+#define Reg Rn | ARn
+#define AllReg Reg | DPReg | OtherReg
+
+typedef struct _template
+{
+ char *name;
+ unsigned int operands; /* how many operands */
+ unsigned int base_opcode; /* base_opcode is the fundamental opcode byte */
+ /* the bits in opcode_modifier are used to generate the final opcode from
+ the base_opcode. These bits also are used to detect alternate forms of
+ the same instruction */
+ unsigned int opcode_modifier;
+
+ /* opcode_modifier bits: */
+#define AddressMode 0x00600000
+#define PCRel 0x02000000
+#define StackOp 0x001F0000
+#define Rotate StackOp
+
+ /* operand_types[i] describes the type of operand i. This is made
+ by OR'ing together all of the possible type masks. (e.g.
+ 'operand_types[i] = Reg|Imm' specifies that operand i can be
+ either a register or an immediate operand */
+ unsigned int operand_types[3];
+ /* This defines the number type of an immediate argument to an instruction. */
+ int imm_arg_type;
+#define Imm_None 0
+#define Imm_Float 1
+#define Imm_SInt 2
+#define Imm_UInt 3
+}
+template;
+
+static const template tic30_optab[] = {
+ { "absf" ,2,0x00000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "absi" ,2,0x00800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "addc" ,2,0x01000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "addc3" ,3,0x20000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "addf" ,2,0x01800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "addf3" ,3,0x20800000,AddressMode, { TAddr1, TAddr2, Rn }, Imm_None },
+ { "addi" ,2,0x02000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "addi3" ,3,0x21000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "and" ,2,0x02800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "and3" ,3,0x21800000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "andn" ,2,0x03000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "andn3" ,3,0x22000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "ash" ,2,0x03800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ash3" ,3,0x22800000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "b" ,1,0x68000000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bu" ,1,0x68000000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blo" ,1,0x68010000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bls" ,1,0x68020000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bhi" ,1,0x68030000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bhs" ,1,0x68040000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "beq" ,1,0x68050000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bne" ,1,0x68060000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blt" ,1,0x68070000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "ble" ,1,0x68080000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bgt" ,1,0x68090000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bge" ,1,0x680A0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bz" ,1,0x68050000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnz" ,1,0x68060000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bp" ,1,0x68090000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bn" ,1,0x68070000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnn" ,1,0x680A0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnv" ,1,0x680C0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bv" ,1,0x680D0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnuf" ,1,0x680E0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "buf" ,1,0x680F0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnc" ,1,0x68040000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bc" ,1,0x68010000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnlv" ,1,0x68100000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blv" ,1,0x68110000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnluf" ,1,0x68120000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bluf" ,1,0x68130000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bzuf" ,1,0x68140000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bd" ,1,0x68200000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bud" ,1,0x68200000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blod" ,1,0x68210000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blsd" ,1,0x68220000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bhid" ,1,0x68230000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bhsd" ,1,0x68240000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "beqd" ,1,0x68250000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bned" ,1,0x68260000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bltd" ,1,0x68270000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bled" ,1,0x68280000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bgtd" ,1,0x68290000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bged" ,1,0x682A0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bzd" ,1,0x68250000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnzd" ,1,0x68260000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bpd" ,1,0x68290000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnd" ,1,0x68270000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnnd" ,1,0x682A0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnvd" ,1,0x682C0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bvd" ,1,0x682D0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnufd" ,1,0x682E0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bufd" ,1,0x682F0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bncd" ,1,0x68240000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bcd" ,1,0x68210000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnlvd" ,1,0x68300000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blvd" ,1,0x68310000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bnlufd" ,1,0x68320000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "blufd" ,1,0x68330000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "bzufd" ,1,0x68340000,PCRel, { AllReg|Disp, 0, 0 }, Imm_None },
+ { "br" ,1,0x60000000,0, { Imm24, 0, 0 }, Imm_UInt },
+ { "brd" ,1,0x61000000,0, { Imm24, 0, 0 }, Imm_UInt },
+ { "call" ,1,0x62000000,0, { Imm24, 0, 0 }, Imm_UInt },
+ { "callu" ,1,0x70000000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "calllo" ,1,0x70010000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callls" ,1,0x70020000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callhi" ,1,0x70030000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callhs" ,1,0x70040000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "calleq" ,1,0x70050000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callne" ,1,0x70060000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "calllt" ,1,0x70070000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callle" ,1,0x70080000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callgt" ,1,0x70090000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callge" ,1,0x700A0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callz" ,1,0x70050000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnz" ,1,0x70060000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callp" ,1,0x70090000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "calln" ,1,0x70070000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnn" ,1,0x700A0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnv" ,1,0x700C0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callv" ,1,0x700D0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnuf",1,0x700E0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "calluf" ,1,0x700F0000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnc" ,1,0x70040000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callc" ,1,0x70010000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnlv",1,0x70100000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "calllv" ,1,0x70110000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callnluf",1,0x70120000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callluf",1,0x70130000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "callzuf",1,0x70140000,PCRel, { AllReg|Disp, 0, 0 }, Imm_UInt },
+ { "cmpf" ,2,0x04000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "cmpf3" ,2,0x23000000,AddressMode, { TAddr1, TAddr2, 0 }, Imm_None },
+ { "cmpi" ,2,0x04800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "cmpi3" ,2,0x23800000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, 0 }, Imm_None },
+ { "db" ,2,0x6C000000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbu" ,2,0x6C000000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblo" ,2,0x6C010000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbls" ,2,0x6C020000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbhi" ,2,0x6C030000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbhs" ,2,0x6C040000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbeq" ,2,0x6C050000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbne" ,2,0x6C060000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblt" ,2,0x6C070000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dble" ,2,0x6C080000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbgt" ,2,0x6C090000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbge" ,2,0x6C0A0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbz" ,2,0x6C050000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnz" ,2,0x6C060000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbp" ,2,0x6C090000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbn" ,2,0x6C070000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnn" ,2,0x6C0A0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnv" ,2,0x6C0C0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbv" ,2,0x6C0D0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnuf" ,2,0x6C0E0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbuf" ,2,0x6C0F0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnc" ,2,0x6C040000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbc" ,2,0x6C010000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnlv" ,2,0x6C100000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblv" ,2,0x6C110000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnluf" ,2,0x6C120000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbluf" ,2,0x6C130000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbzuf" ,2,0x6C140000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbd" ,2,0x6C200000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbud" ,2,0x6C200000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblod" ,2,0x6C210000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblsd" ,2,0x6C220000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbhid" ,2,0x6C230000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbhsd" ,2,0x6C240000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbeqd" ,2,0x6C250000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbned" ,2,0x6C260000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbltd" ,2,0x6C270000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbled" ,2,0x6C280000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbgtd" ,2,0x6C290000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbged" ,2,0x6C2A0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbzd" ,2,0x6C250000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnzd" ,2,0x6C260000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbpd" ,2,0x6C290000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnd" ,2,0x6C270000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnnd" ,2,0x6C2A0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnvd" ,2,0x6C2C0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbvd" ,2,0x6C2D0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnufd" ,2,0x6C2E0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbufd" ,2,0x6C2F0000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbncd" ,2,0x6C240000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbcd" ,2,0x6C210000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnlvd" ,2,0x6C300000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblvd" ,2,0x6C310000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbnlufd",2,0x6C320000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dblufd" ,2,0x6C330000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "dbzufd" ,2,0x6C340000,PCRel, { ARn, AllReg|Disp, 0 }, Imm_None },
+ { "fix" ,2,0x05000000,AddressMode, { GAddr1, AllReg, 0 }, Imm_Float },
+ { "float" ,2,0x05800000,AddressMode, { GAddr2, Rn, 0 }, Imm_SInt },
+ { "iack" ,1,0x1B000000,AddressMode, { Direct|Indirect, 0, 0 }, Imm_None },
+ { "idle" ,0,0x06000000,0, { 0, 0, 0 }, Imm_None },
+ { "idle2" ,0,0x06000001,0, { 0, 0, 0 }, Imm_None }, /* LC31 Only */
+ { "lde" ,2,0x06800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldf" ,2,0x07000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfu" ,2,0x40000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldflo" ,2,0x40800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfls" ,2,0x41000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfhi" ,2,0x41800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfhs" ,2,0x42000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfeq" ,2,0x42800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfne" ,2,0x43000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldflt" ,2,0x43800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfle" ,2,0x44000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfgt" ,2,0x44800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfge" ,2,0x45000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfz" ,2,0x42800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnz" ,2,0x43000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfp" ,2,0x44800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfn" ,2,0x43800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnn" ,2,0x45000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnv" ,2,0x46000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfv" ,2,0x46800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnuf" ,2,0x47000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfuf" ,2,0x47800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnc" ,2,0x42000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfc" ,2,0x40800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnlv" ,2,0x48000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldflv" ,2,0x48800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfnluf",2,0x49000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfluf" ,2,0x49800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfzuf" ,2,0x4A000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldfi" ,2,0x07800000,AddressMode, { Direct|Indirect, Rn, 0 }, Imm_None },
+ { "ldi" ,2,0x08000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldiu" ,2,0x50000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldilo" ,2,0x50800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldils" ,2,0x51000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldihi" ,2,0x51800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldihs" ,2,0x52000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldieq" ,2,0x52800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldine" ,2,0x53000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldilt" ,2,0x53800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldile" ,2,0x54000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldigt" ,2,0x54800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldige" ,2,0x55000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldiz" ,2,0x52800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinz" ,2,0x53000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldip" ,2,0x54800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldin" ,2,0x53800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinn" ,2,0x55000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinv" ,2,0x56000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldiv" ,2,0x56800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinuf" ,2,0x57000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldiuf" ,2,0x57800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinc" ,2,0x52000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldic" ,2,0x50800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinlv" ,2,0x58000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldilv" ,2,0x58800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldinluf",2,0x59000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldiluf" ,2,0x59800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldizuf" ,2,0x5A000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "ldii" ,2,0x08800000,AddressMode, { Direct|Indirect, AllReg, 0 }, Imm_None },
+ { "ldm" ,2,0x09000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "ldp" ,2,0x08700000,0, { Abs24|Direct, DPReg|NotReq, 0 }, Imm_UInt },
+ { "lopower",0,0x10800001,0, { 0, 0, 0 }, Imm_None }, /* LC31 Only */
+ { "lsh" ,2,0x09800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "lsh3" ,3,0x24000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "maxspeed",0,0x10800000,0, { 0, 0, 0 }, Imm_None }, /* LC31 Only */
+ { "mpyf" ,2,0x0A000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "mpyf3" ,3,0x24800000,AddressMode, { TAddr1, TAddr2, Rn }, Imm_None },
+ { "mpyi" ,2,0x0A800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "mpyi3" ,3,0x25000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "negb" ,2,0x0B000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "negf" ,2,0x0B800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "negi" ,2,0x0C000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "nop" ,1,0x0C800000,AddressMode, { AllReg|Indirect|NotReq, 0, 0 }, Imm_None },
+ { "norm" ,2,0x0D000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float }, /*Check another source*/
+ { "not" ,2,0x0D800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "or" ,2,0x10000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "or3" ,3,0x25800000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "pop" ,1,0x0E200000,StackOp, { AllReg, 0, 0 }, Imm_None },
+ { "popf" ,1,0x0EA00000,StackOp, { Rn, 0, 0 }, Imm_None },
+ { "push" ,1,0x0F200000,StackOp, { AllReg, 0, 0 }, Imm_None },
+ { "pushf" ,1,0x0FA00000,StackOp, { Rn, 0, 0 }, Imm_None },
+ { "reti" ,0,0x78000000,0, { 0, 0, 0 }, Imm_None },
+ { "retiu" ,0,0x78000000,0, { 0, 0, 0 }, Imm_None },
+ { "retilo" ,0,0x78010000,0, { 0, 0, 0 }, Imm_None },
+ { "retils" ,0,0x78020000,0, { 0, 0, 0 }, Imm_None },
+ { "retihi" ,0,0x78030000,0, { 0, 0, 0 }, Imm_None },
+ { "retihs" ,0,0x78040000,0, { 0, 0, 0 }, Imm_None },
+ { "retieq" ,0,0x78050000,0, { 0, 0, 0 }, Imm_None },
+ { "retine" ,0,0x78060000,0, { 0, 0, 0 }, Imm_None },
+ { "retilt" ,0,0x78070000,0, { 0, 0, 0 }, Imm_None },
+ { "retile" ,0,0x78080000,0, { 0, 0, 0 }, Imm_None },
+ { "retigt" ,0,0x78090000,0, { 0, 0, 0 }, Imm_None },
+ { "retige" ,0,0x780A0000,0, { 0, 0, 0 }, Imm_None },
+ { "retiz" ,0,0x78050000,0, { 0, 0, 0 }, Imm_None },
+ { "retinz" ,0,0x78060000,0, { 0, 0, 0 }, Imm_None },
+ { "retip" ,0,0x78090000,0, { 0, 0, 0 }, Imm_None },
+ { "retin" ,0,0x78070000,0, { 0, 0, 0 }, Imm_None },
+ { "retinn" ,0,0x780A0000,0, { 0, 0, 0 }, Imm_None },
+ { "retinv" ,0,0x780C0000,0, { 0, 0, 0 }, Imm_None },
+ { "retiv" ,0,0x780D0000,0, { 0, 0, 0 }, Imm_None },
+ { "retinuf",0,0x780E0000,0, { 0, 0, 0 }, Imm_None },
+ { "retiuf" ,0,0x780F0000,0, { 0, 0, 0 }, Imm_None },
+ { "retinc" ,0,0x78040000,0, { 0, 0, 0 }, Imm_None },
+ { "retic" ,0,0x78010000,0, { 0, 0, 0 }, Imm_None },
+ { "retinlv",0,0x78100000,0, { 0, 0, 0 }, Imm_None },
+ { "retilv" ,0,0x78110000,0, { 0, 0, 0 }, Imm_None },
+ { "retinluf",0,0x78120000,0, { 0, 0, 0 }, Imm_None },
+ { "retiluf",0,0x78130000,0, { 0, 0, 0 }, Imm_None },
+ { "retizuf",0,0x78140000,0, { 0, 0, 0 }, Imm_None },
+ { "rets" ,0,0x78800000,0, { 0, 0, 0 }, Imm_None },
+ { "retsu" ,0,0x78800000,0, { 0, 0, 0 }, Imm_None },
+ { "retslo" ,0,0x78810000,0, { 0, 0, 0 }, Imm_None },
+ { "retsls" ,0,0x78820000,0, { 0, 0, 0 }, Imm_None },
+ { "retshi" ,0,0x78830000,0, { 0, 0, 0 }, Imm_None },
+ { "retshs" ,0,0x78840000,0, { 0, 0, 0 }, Imm_None },
+ { "retseq" ,0,0x78850000,0, { 0, 0, 0 }, Imm_None },
+ { "retsne" ,0,0x78860000,0, { 0, 0, 0 }, Imm_None },
+ { "retslt" ,0,0x78870000,0, { 0, 0, 0 }, Imm_None },
+ { "retsle" ,0,0x78880000,0, { 0, 0, 0 }, Imm_None },
+ { "retsgt" ,0,0x78890000,0, { 0, 0, 0 }, Imm_None },
+ { "retsge" ,0,0x788A0000,0, { 0, 0, 0 }, Imm_None },
+ { "retsz" ,0,0x78850000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnz" ,0,0x78860000,0, { 0, 0, 0 }, Imm_None },
+ { "retsp" ,0,0x78890000,0, { 0, 0, 0 }, Imm_None },
+ { "retsn" ,0,0x78870000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnn" ,0,0x788A0000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnv" ,0,0x788C0000,0, { 0, 0, 0 }, Imm_None },
+ { "retsv" ,0,0x788D0000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnuf",0,0x788E0000,0, { 0, 0, 0 }, Imm_None },
+ { "retsuf" ,0,0x788F0000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnc" ,0,0x78840000,0, { 0, 0, 0 }, Imm_None },
+ { "retsc" ,0,0x78810000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnlv",0,0x78900000,0, { 0, 0, 0 }, Imm_None },
+ { "retslv" ,0,0x78910000,0, { 0, 0, 0 }, Imm_None },
+ { "retsnluf",0,0x78920000,0, { 0, 0, 0 }, Imm_None },
+ { "retsluf",0,0x78930000,0, { 0, 0, 0 }, Imm_None },
+ { "retszuf",0,0x78940000,0, { 0, 0, 0 }, Imm_None },
+ { "rnd" ,2,0x11000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "rol" ,1,0x11E00001,Rotate, { AllReg, 0, 0 }, Imm_None },
+ { "rolc" ,1,0x12600001,Rotate, { AllReg, 0, 0 }, Imm_None },
+ { "ror" ,1,0x12E0FFFF,Rotate, { AllReg, 0, 0 }, Imm_None },
+ { "rorc" ,1,0x1360FFFF,Rotate, { AllReg, 0, 0 }, Imm_None },
+ { "rptb" ,1,0x64000000,0, { Imm24, 0, 0 }, Imm_UInt },
+ { "rpts" ,1,0x139B0000,AddressMode, { GAddr2, 0, 0 }, Imm_UInt },
+ { "sigi" ,0,0x16000000,0, { 0, 0, 0 }, Imm_None },
+ { "stf" ,2,0x14000000,AddressMode, { Rn, Direct|Indirect, 0 }, Imm_Float },
+ { "stfi" ,2,0x14800000,AddressMode, { Rn, Direct|Indirect, 0 }, Imm_Float },
+ { "sti" ,2,0x15000000,AddressMode, { AllReg, Direct|Indirect, 0 }, Imm_SInt },
+ { "stii" ,2,0x15800000,AddressMode, { AllReg, Direct|Indirect, 0 }, Imm_SInt },
+ { "subb" ,2,0x16800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "subb3" ,3,0x26000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "subc" ,2,0x17000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "subf" ,2,0x17800000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "subf3" ,3,0x26800000,AddressMode, { TAddr1, TAddr2, Rn }, Imm_None },
+ { "subi" ,2,0x18000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "subi3" ,3,0x27000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "subrb" ,2,0x18800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "subrf" ,2,0x19000000,AddressMode, { GAddr1, Rn, 0 }, Imm_Float },
+ { "subri" ,2,0x19800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_SInt },
+ { "swi" ,0,0x66000000,0, { 0, 0, 0 }, Imm_None },
+ { "trap" ,1,0x74800020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapu" ,1,0x74800020,0, { IVector, 0, 0 }, Imm_None },
+ { "traplo" ,1,0x74810020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapls" ,1,0x74820020,0, { IVector, 0, 0 }, Imm_None },
+ { "traphi" ,1,0x74830020,0, { IVector, 0, 0 }, Imm_None },
+ { "traphs" ,1,0x74840020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapeq" ,1,0x74850020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapne" ,1,0x74860020,0, { IVector, 0, 0 }, Imm_None },
+ { "traplt" ,1,0x74870020,0, { IVector, 0, 0 }, Imm_None },
+ { "traple" ,1,0x74880020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapgt" ,1,0x74890020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapge" ,1,0x748A0020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapz" ,1,0x74850020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnz" ,1,0x74860020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapp" ,1,0x74890020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapn" ,1,0x74870020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnn" ,1,0x748A0020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnv" ,1,0x748C0020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapv" ,1,0x748D0020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnuf",1,0x748E0020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapuf" ,1,0x748F0020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnc" ,1,0x74840020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapc" ,1,0x74810020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnlv",1,0x74900020,0, { IVector, 0, 0 }, Imm_None },
+ { "traplv" ,1,0x74910020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapnluf",1,0x74920020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapluf",1,0x74930020,0, { IVector, 0, 0 }, Imm_None },
+ { "trapzuf",1,0x74940020,0, { IVector, 0, 0 }, Imm_None },
+ { "tstb" ,2,0x1A000000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "tstb3" ,2,0x27800000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, 0 }, Imm_None },
+ { "xor" ,2,0x1A800000,AddressMode, { GAddr2, AllReg, 0 }, Imm_UInt },
+ { "xor3" ,3,0x28000000,AddressMode, { TAddr1|AllReg, TAddr2|AllReg, AllReg }, Imm_None },
+ { "" ,0,0x00000000,0, { 0, 0, 0 }, 0 }
+};
+
+static const template *const tic30_optab_end =
+ tic30_optab + sizeof(tic30_optab)/sizeof(tic30_optab[0]);
+
+typedef struct {
+ char *name;
+ unsigned int operands_1;
+ unsigned int operands_2;
+ unsigned int base_opcode;
+ unsigned int operand_types[2][3];
+ /* Which operand fits into which part of the final opcode word. */
+ int oporder;
+} partemplate;
+
+/* oporder defines - not very descriptive. */
+#define OO_4op1 0
+#define OO_4op2 1
+#define OO_4op3 2
+#define OO_5op1 3
+#define OO_5op2 4
+#define OO_PField 5
+
+static const partemplate tic30_paroptab[] = {
+ { "q_absf_stf", 2,2,0xC8000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_absi_sti", 2,2,0xCA000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_addf3_stf", 3,2,0xCC000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "q_addi3_sti", 3,2,0xCE000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "q_and3_sti", 3,2,0xD0000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "q_ash3_sti", 3,2,0xD2000000, { { Rn, Indirect, Rn }, { Rn, Indirect, 0 } },
+ OO_5op2 },
+ { "q_fix_sti", 2,2,0xD4000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_float_stf", 2,2,0xD6000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_ldf_ldf", 2,2,0xC4000000, { { Indirect, Rn, 0 }, { Indirect, Rn, 0 } },
+ OO_4op2 },
+ { "q_ldf_stf", 2,2,0xD8000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_ldi_ldi", 2,2,0xC6000000, { { Indirect, Rn, 0 }, { Indirect, Rn, 0 } },
+ OO_4op2 },
+ { "q_ldi_sti", 2,2,0xDA000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_lsh3_sti", 3,2,0xDC000000, { { Rn, Indirect, Rn }, { Rn, Indirect, 0 } },
+ OO_5op2 },
+ { "q_mpyf3_addf3",3,3,0x80000000, { { Rn | Indirect, Rn | Indirect, Rn },
+ { Rn | Indirect, Rn | Indirect, Rn } }, OO_PField },
+ { "q_mpyf3_stf", 3,2,0xDE000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "q_mpyf3_subf3",3,3,0x84000000, { { Rn | Indirect, Rn | Indirect, Rn },
+ { Rn | Indirect, Rn | Indirect, Rn } }, OO_PField },
+ { "q_mpyi3_addi3",3,3,0x88000000, { { Rn | Indirect, Rn | Indirect, Rn },
+ { Rn | Indirect, Rn | Indirect, Rn } }, OO_PField },
+ { "q_mpyi3_sti", 3,2,0xE0000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "q_mpyi3_subi3",3,3,0x8C000000, { { Rn | Indirect, Rn | Indirect, Rn },
+ { Rn | Indirect, Rn | Indirect, Rn } }, OO_PField },
+ { "q_negf_stf", 2,2,0xE2000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_negi_sti", 2,2,0xE4000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_not_sti", 2,2,0xE6000000, { { Indirect, Rn, 0 }, { Rn, Indirect, 0 } },
+ OO_4op1 },
+ { "q_or3_sti", 3,2,0xE8000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "q_stf_stf", 2,2,0xC0000000, { { Rn, Indirect, 0 }, { Rn, Indirect, 0 } },
+ OO_4op3 },
+ { "q_sti_sti", 2,2,0xC2000000, { { Rn, Indirect, 0 }, { Rn, Indirect, 0 } },
+ OO_4op3 },
+ { "q_subf3_stf", 3,2,0xEA000000, { { Rn, Indirect, Rn }, { Rn, Indirect, 0 } },
+ OO_5op2 },
+ { "q_subi3_sti", 3,2,0xEC000000, { { Rn, Indirect, Rn }, { Rn, Indirect, 0 } },
+ OO_5op2 },
+ { "q_xor3_sti", 3,2,0xEE000000, { { Indirect, Rn, Rn }, { Rn, Indirect, 0 } },
+ OO_5op1 },
+ { "", 0,0,0x00000000, { { 0, 0, 0 }, { 0, 0, 0 } }, 0 }
+};
+
+static const partemplate *const tic30_paroptab_end =
+ tic30_paroptab + sizeof(tic30_paroptab)/sizeof(tic30_paroptab[0]);
+
+#endif
diff --git a/include/opcode/tic80.h b/include/opcode/tic80.h
new file mode 100644
index 00000000000..b99bc30b818
--- /dev/null
+++ b/include/opcode/tic80.h
@@ -0,0 +1,277 @@
+/* tic80.h -- Header file for TI TMS320C80 (MV) opcode table
+ Copyright 1996, 1997, 1999 Free Software Foundation, Inc.
+ Written by Fred Fish (fnf@cygnus.com), Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef TIC80_H
+#define TIC80_H
+
+/* The opcode table is an array of struct tic80_opcode. */
+
+struct tic80_opcode
+{
+ /* The opcode name. */
+
+ const char *name;
+
+ /* The opcode itself. Those bits which will be filled in with operands
+ are zeroes. */
+
+ unsigned long opcode;
+
+ /* The opcode mask. This is used by the disassembler. This is a mask
+ containing ones indicating those bits which must match the opcode
+ field, and zeroes indicating those bits which need not match (and are
+ presumably filled in by operands). */
+
+ unsigned long mask;
+
+ /* Special purpose flags for this opcode. */
+
+ unsigned char flags;
+
+ /* An array of operand codes. Each code is an index into the operand
+ table. They appear in the order which the operands must appear in
+ assembly code, and are terminated by a zero. FIXME: Adjust size to
+ match actual requirements when TIc80 support is complete */
+
+ unsigned char operands[8];
+};
+
+/* The table itself is sorted by major opcode number, and is otherwise in
+ the order in which the disassembler should consider instructions.
+ FIXME: This isn't currently true. */
+
+extern const struct tic80_opcode tic80_opcodes[];
+extern const int tic80_num_opcodes;
+
+
+/* The operands table is an array of struct tic80_operand. */
+
+struct tic80_operand
+{
+ /* The number of bits in the operand. */
+
+ int bits;
+
+ /* How far the operand is left shifted in the instruction. */
+
+ int shift;
+
+ /* Insertion function. This is used by the assembler. To insert an
+ operand value into an instruction, check this field.
+
+ If it is NULL, execute
+ i |= (op & ((1 << o->bits) - 1)) << o->shift;
+ (i is the instruction which we are filling in, o is a pointer to
+ this structure, and op is the opcode value; this assumes twos
+ complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction and the operand value. It will return the new value
+ of the instruction. If the ERRMSG argument is not NULL, then if
+ the operand value is illegal, *ERRMSG will be set to a warning
+ string (the operand will be inserted in any case). If the
+ operand value is legal, *ERRMSG will be unchanged (most operands
+ can accept any value). */
+
+ unsigned long (*insert) PARAMS ((unsigned long instruction, long op,
+ const char **errmsg));
+
+ /* Extraction function. This is used by the disassembler. To
+ extract this operand type from an instruction, check this field.
+
+ If it is NULL, compute
+ op = ((i) >> o->shift) & ((1 << o->bits) - 1);
+ if ((o->flags & TIC80_OPERAND_SIGNED) != 0
+ && (op & (1 << (o->bits - 1))) != 0)
+ op -= 1 << o->bits;
+ (i is the instruction, o is a pointer to this structure, and op
+ is the result; this assumes twos complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction value. It will return the value of the operand. If
+ the INVALID argument is not NULL, *INVALID will be set to
+ non-zero if this operand type can not actually be extracted from
+ this operand (i.e., the instruction does not match). If the
+ operand is valid, *INVALID will not be changed. */
+
+ long (*extract) PARAMS ((unsigned long instruction, int *invalid));
+
+ /* One bit syntax flags. */
+
+ unsigned long flags;
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the tic80_opcodes table. */
+
+extern const struct tic80_operand tic80_operands[];
+
+
+/* Values defined for the flags field of a struct tic80_operand.
+
+ Note that flags for all predefined symbols, such as the general purpose
+ registers (ex: r10), control registers (ex: FPST), condition codes (ex:
+ eq0.b), bit numbers (ex: gt.b), etc are large enough that they can be
+ or'd into an int where the lower bits contain the actual numeric value
+ that correponds to this predefined symbol. This way a single int can
+ contain both the value of the symbol and it's type.
+ */
+
+/* This operand must be an even register number. Floating point numbers
+ for example are stored in even/odd register pairs. */
+
+#define TIC80_OPERAND_EVEN (1 << 0)
+
+/* This operand must be an odd register number and must be one greater than
+ the register number of the previous operand. I.E. the second register in
+ an even/odd register pair. */
+
+#define TIC80_OPERAND_ODD (1 << 1)
+
+/* This operand takes signed values. */
+
+#define TIC80_OPERAND_SIGNED (1 << 2)
+
+/* This operand may be either a predefined constant name or a numeric value.
+ An example would be a condition code like "eq0.b" which has the numeric
+ value 0x2. */
+
+#define TIC80_OPERAND_NUM (1 << 3)
+
+/* This operand should be wrapped in parentheses rather than separated
+ from the previous one by a comma. This is used for various
+ instructions, like the load and store instructions, which want
+ their operands to look like "displacement(reg)" */
+
+#define TIC80_OPERAND_PARENS (1 << 4)
+
+/* This operand is a PC relative branch offset. The disassembler prints
+ these symbolically if possible. Note that the offsets are taken as word
+ offsets. */
+
+#define TIC80_OPERAND_PCREL (1 << 5)
+
+/* This flag is a hint to the disassembler for using hex as the prefered
+ printing format, even for small positive or negative immediate values.
+ Normally values in the range -999 to 999 are printed as signed decimal
+ values and other values are printed in hex. */
+
+#define TIC80_OPERAND_BITFIELD (1 << 6)
+
+/* This operand may have a ":m" modifier specified by bit 17 in a short
+ immediate form instruction. */
+
+#define TIC80_OPERAND_M_SI (1 << 7)
+
+/* This operand may have a ":m" modifier specified by bit 15 in a long
+ immediate or register form instruction. */
+
+#define TIC80_OPERAND_M_LI (1 << 8)
+
+/* This operand may have a ":s" modifier specified in bit 11 in a long
+ immediate or register form instruction. */
+
+#define TIC80_OPERAND_SCALED (1 << 9)
+
+/* This operand is a floating point value */
+
+#define TIC80_OPERAND_FLOAT (1 << 10)
+
+/* This operand is an byte offset from a base relocation. The lower
+ two bits of the final relocated address are ignored when the value is
+ written to the program counter. */
+
+#define TIC80_OPERAND_BASEREL (1 << 11)
+
+/* This operand is an "endmask" field for a shift instruction.
+ It is treated special in that it can have values of 0-32,
+ where 0 and 32 result in the same instruction. The assembler
+ must be able to accept both endmask values. This disassembler
+ has no way of knowing from the instruction which value was
+ given at assembly time, so it just uses '0'. */
+
+#define TIC80_OPERAND_ENDMASK (1 << 12)
+
+/* This operand is one of the 32 general purpose registers.
+ The disassembler prints these with a leading 'r'. */
+
+#define TIC80_OPERAND_GPR (1 << 27)
+
+/* This operand is a floating point accumulator register.
+ The disassembler prints these with a leading 'a'. */
+
+#define TIC80_OPERAND_FPA ( 1 << 28)
+
+/* This operand is a control register number, either numeric or
+ symbolic (like "EIF", "EPC", etc).
+ The disassembler prints these symbolically. */
+
+#define TIC80_OPERAND_CR (1 << 29)
+
+/* This operand is a condition code, either numeric or
+ symbolic (like "eq0.b", "ne0.w", etc).
+ The disassembler prints these symbolically. */
+
+#define TIC80_OPERAND_CC (1 << 30)
+
+/* This operand is a bit number, either numeric or
+ symbolic (like "eq.b", "or.f", etc).
+ The disassembler prints these symbolically.
+ Note that they appear in the instruction in 1's complement relative
+ to the values given in the manual. */
+
+#define TIC80_OPERAND_BITNUM (1 << 31)
+
+/* This mask is used to strip operand bits from an int that contains
+ both operand bits and a numeric value in the lsbs. */
+
+#define TIC80_OPERAND_MASK (TIC80_OPERAND_GPR | TIC80_OPERAND_FPA | TIC80_OPERAND_CR | TIC80_OPERAND_CC | TIC80_OPERAND_BITNUM)
+
+
+/* Flag bits for the struct tic80_opcode flags field. */
+
+#define TIC80_VECTOR 01 /* Is a vector instruction */
+#define TIC80_NO_R0_DEST 02 /* Register r0 cannot be a destination register */
+
+
+/* The opcodes library contains a table that allows translation from predefined
+ symbol names to numeric values, and vice versa. */
+
+/* Structure to hold information about predefined symbols. */
+
+struct predefined_symbol
+{
+ char *name; /* name to recognize */
+ int value;
+};
+
+#define PDS_NAME(pdsp) ((pdsp) -> name)
+#define PDS_VALUE(pdsp) ((pdsp) -> value)
+
+extern const struct predefined_symbol tic80_predefined_symbols[]; /* Translation array */
+extern const int tic80_num_predefined_symbols; /* How many members in the array */
+
+const char *tic80_value_to_symbol PARAMS ((int val, int class)); /* Translate value to symbolic name */
+int tic80_symbol_to_value PARAMS ((char *name, int class)); /* Translate symbolic name to value */
+
+const struct predefined_symbol *
+tic80_next_predefined_symbol PARAMS ((const struct predefined_symbol *));
+
+#endif /* TIC80_H */
diff --git a/include/opcode/v850.h b/include/opcode/v850.h
new file mode 100644
index 00000000000..88916f1b848
--- /dev/null
+++ b/include/opcode/v850.h
@@ -0,0 +1,166 @@
+/* v850.h -- Header file for NEC V850 opcode table
+ Copyright 1996 Free Software Foundation, Inc.
+ Written by J.T. Conklin, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef V850_H
+#define V850_H
+
+/* The opcode table is an array of struct v850_opcode. */
+
+struct v850_opcode
+{
+ /* The opcode name. */
+ const char *name;
+
+ /* The opcode itself. Those bits which will be filled in with
+ operands are zeroes. */
+ unsigned long opcode;
+
+ /* The opcode mask. This is used by the disassembler. This is a
+ mask containing ones indicating those bits which must match the
+ opcode field, and zeroes indicating those bits which need not
+ match (and are presumably filled in by operands). */
+ unsigned long mask;
+
+ /* An array of operand codes. Each code is an index into the
+ operand table. They appear in the order which the operands must
+ appear in assembly code, and are terminated by a zero. */
+ unsigned char operands[8];
+
+ /* Which (if any) operand is a memory operand. */
+ unsigned int memop;
+
+ /* Target processor(s). A bit field of processors which support
+ this instruction. Note a bit field is used as some instructions
+ are available on multiple, different processor types, whereas
+ other instructions are only available on one specific type. */
+ unsigned int processors;
+};
+
+/* Values for the processors field in the v850_opcode structure. */
+#define PROCESSOR_V850 (1 << 0) /* Just the V850. */
+#define PROCESSOR_ALL -1 /* Any processor. */
+#define PROCESSOR_V850E (1 << 1) /* Just the V850E. */
+#define PROCESSOR_NOT_V850 (~ PROCESSOR_V850) /* Any processor except the V850. */
+#define PROCESSOR_V850EA (1 << 2) /* Just the V850EA. */
+
+/* The table itself is sorted by major opcode number, and is otherwise
+ in the order in which the disassembler should consider
+ instructions. */
+extern const struct v850_opcode v850_opcodes[];
+extern const int v850_num_opcodes;
+
+
+/* The operands table is an array of struct v850_operand. */
+
+struct v850_operand
+{
+ /* The number of bits in the operand. */
+ /* If this value is -1 then the operand's bits are in a discontinous distribution in the instruction. */
+ int bits;
+
+ /* (bits >= 0): How far the operand is left shifted in the instruction. */
+ /* (bits == -1): Bit mask of the bits in the operand. */
+ int shift;
+
+ /* Insertion function. This is used by the assembler. To insert an
+ operand value into an instruction, check this field.
+
+ If it is NULL, execute
+ i |= (op & ((1 << o->bits) - 1)) << o->shift;
+ (i is the instruction which we are filling in, o is a pointer to
+ this structure, and op is the opcode value; this assumes twos
+ complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction and the operand value. It will return the new value
+ of the instruction. If the ERRMSG argument is not NULL, then if
+ the operand value is illegal, *ERRMSG will be set to a warning
+ string (the operand will be inserted in any case). If the
+ operand value is legal, *ERRMSG will be unchanged (most operands
+ can accept any value). */
+ unsigned long (* insert) PARAMS ((unsigned long instruction, long op,
+ const char ** errmsg));
+
+ /* Extraction function. This is used by the disassembler. To
+ extract this operand type from an instruction, check this field.
+
+ If it is NULL, compute
+ op = o->bits == -1 ? ((i) & o->shift) : ((i) >> o->shift) & ((1 << o->bits) - 1);
+ if (o->flags & V850_OPERAND_SIGNED)
+ op = (op << (32 - o->bits)) >> (32 - o->bits);
+ (i is the instruction, o is a pointer to this structure, and op
+ is the result; this assumes twos complement arithmetic).
+
+ If this field is not NULL, then simply call it with the
+ instruction value. It will return the value of the operand. If
+ the INVALID argument is not NULL, *INVALID will be set to
+ non-zero if this operand type can not actually be extracted from
+ this operand (i.e., the instruction does not match). If the
+ operand is valid, *INVALID will not be changed. */
+ unsigned long (* extract) PARAMS ((unsigned long instruction, int * invalid));
+
+ /* One bit syntax flags. */
+ int flags;
+};
+
+/* Elements in the table are retrieved by indexing with values from
+ the operands field of the v850_opcodes table. */
+
+extern const struct v850_operand v850_operands[];
+
+/* Values defined for the flags field of a struct v850_operand. */
+
+/* This operand names a general purpose register */
+#define V850_OPERAND_REG 0x01
+
+/* This operand names a system register */
+#define V850_OPERAND_SRG 0x02
+
+/* This operand names a condition code used in the setf instruction */
+#define V850_OPERAND_CC 0x04
+
+/* This operand takes signed values */
+#define V850_OPERAND_SIGNED 0x08
+
+/* This operand is the ep register. */
+#define V850_OPERAND_EP 0x10
+
+/* This operand is a PC displacement */
+#define V850_OPERAND_DISP 0x20
+
+/* This is a relaxable operand. Only used for D9->D22 branch relaxing
+ right now. We may need others in the future (or maybe handle them like
+ promoted operands on the mn10300?) */
+#define V850_OPERAND_RELAX 0x40
+
+/* The register specified must not be r0 */
+#define V850_NOT_R0 0x80
+
+/* CYGNUS LOCAL v850e */
+/* push/pop type instruction, V850E specific. */
+#define V850E_PUSH_POP 0x100
+
+/* 16 bit immediate follows instruction, V850E specific. */
+#define V850E_IMMEDIATE16 0x200
+
+/* 32 bit immediate follows instruction, V850E specific. */
+#define V850E_IMMEDIATE32 0x400
+
+#endif /* V850_H */
diff --git a/include/opcode/vax.h b/include/opcode/vax.h
new file mode 100644
index 00000000000..f3afebde7e3
--- /dev/null
+++ b/include/opcode/vax.h
@@ -0,0 +1,382 @@
+/* Vax opcde list.
+ Copyright (C) 1989, 1995 Free Software Foundation, Inc.
+
+This file is part of GDB and GAS.
+
+GDB and GAS are 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 1, or (at your option)
+any later version.
+
+GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef vax_opcodeT
+#define vax_opcodeT int
+#endif /* no vax_opcodeT */
+
+struct vot_wot /* vax opcode table: wot to do with this */
+ /* particular opcode */
+{
+ const char *args; /* how to compile said opcode */
+ vax_opcodeT code; /* op-code (may be > 8 bits!) */
+};
+
+struct vot /* vax opcode text */
+{
+ const char *name; /* opcode name: lowercase string [key] */
+ struct vot_wot detail; /* rest of opcode table [datum] */
+};
+
+#define vot_how args
+#define vot_code code
+#define vot_detail detail
+#define vot_name name
+
+static const struct vot
+votstrs[] =
+{
+{ "halt", {"", 0x00 } },
+{ "nop", {"", 0x01 } },
+{ "rei", {"", 0x02 } },
+{ "bpt", {"", 0x03 } },
+{ "ret", {"", 0x04 } },
+{ "rsb", {"", 0x05 } },
+{ "ldpctx", {"", 0x06 } },
+{ "svpctx", {"", 0x07 } },
+{ "cvtps", {"rwabrwab", 0x08 } },
+{ "cvtsp", {"rwabrwab", 0x09 } },
+{ "index", {"rlrlrlrlrlwl", 0x0a } },
+{ "crc", {"abrlrwab", 0x0b } },
+{ "prober", {"rbrwab", 0x0c } },
+{ "probew", {"rbrwab", 0x0d } },
+{ "insque", {"abab", 0x0e } },
+{ "remque", {"abwl", 0x0f } },
+{ "bsbb", {"bb", 0x10 } },
+{ "brb", {"bb", 0x11 } },
+{ "bneq", {"bb", 0x12 } },
+{ "bnequ", {"bb", 0x12 } },
+{ "beql", {"bb", 0x13 } },
+{ "beqlu", {"bb", 0x13 } },
+{ "bgtr", {"bb", 0x14 } },
+{ "bleq", {"bb", 0x15 } },
+{ "jsb", {"ab", 0x16 } },
+{ "jmp", {"ab", 0x17 } },
+{ "bgeq", {"bb", 0x18 } },
+{ "blss", {"bb", 0x19 } },
+{ "bgtru", {"bb", 0x1a } },
+{ "blequ", {"bb", 0x1b } },
+{ "bvc", {"bb", 0x1c } },
+{ "bvs", {"bb", 0x1d } },
+{ "bcc", {"bb", 0x1e } },
+{ "bgequ", {"bb", 0x1e } },
+{ "blssu", {"bb", 0x1f } },
+{ "bcs", {"bb", 0x1f } },
+{ "addp4", {"rwabrwab", 0x20 } },
+{ "addp6", {"rwabrwabrwab", 0x21 } },
+{ "subp4", {"rwabrwab", 0x22 } },
+{ "subp6", {"rwabrwabrwab", 0x23 } },
+{ "cvtpt", {"rwababrwab", 0x24 } },
+{ "mulp", {"rwabrwabrwab", 0x25 } },
+{ "cvttp", {"rwababrwab", 0x26 } },
+{ "divp", {"rwabrwabrwab", 0x27 } },
+{ "movc3", {"rwabab", 0x28 } },
+{ "cmpc3", {"rwabab", 0x29 } },
+{ "scanc", {"rwababrb", 0x2a } },
+{ "spanc", {"rwababrb", 0x2b } },
+{ "movc5", {"rwabrbrwab", 0x2c } },
+{ "cmpc5", {"rwabrbrwab", 0x2d } },
+{ "movtc", {"rwabrbabrwab", 0x2e } },
+{ "movtuc", {"rwabrbabrwab", 0x2f } },
+{ "bsbw", {"bw", 0x30 } },
+{ "brw", {"bw", 0x31 } },
+{ "cvtwl", {"rwwl", 0x32 } },
+{ "cvtwb", {"rwwb", 0x33 } },
+{ "movp", {"rwabab", 0x34 } },
+{ "cmpp3", {"rwabab", 0x35 } },
+{ "cvtpl", {"rwabwl", 0x36 } },
+{ "cmpp4", {"rwabrwab", 0x37 } },
+{ "editpc", {"rwababab", 0x38 } },
+{ "matchc", {"rwabrwab", 0x39 } },
+{ "locc", {"rbrwab", 0x3a } },
+{ "skpc", {"rbrwab", 0x3b } },
+{ "movzwl", {"rwwl", 0x3c } },
+{ "acbw", {"rwrwmwbw", 0x3d } },
+{ "movaw", {"awwl", 0x3e } },
+{ "pushaw", {"aw", 0x3f } },
+{ "addf2", {"rfmf", 0x40 } },
+{ "addf3", {"rfrfwf", 0x41 } },
+{ "subf2", {"rfmf", 0x42 } },
+{ "subf3", {"rfrfwf", 0x43 } },
+{ "mulf2", {"rfmf", 0x44 } },
+{ "mulf3", {"rfrfwf", 0x45 } },
+{ "divf2", {"rfmf", 0x46 } },
+{ "divf3", {"rfrfwf", 0x47 } },
+{ "cvtfb", {"rfwb", 0x48 } },
+{ "cvtfw", {"rfww", 0x49 } },
+{ "cvtfl", {"rfwl", 0x4a } },
+{ "cvtrfl", {"rfwl", 0x4b } },
+{ "cvtbf", {"rbwf", 0x4c } },
+{ "cvtwf", {"rwwf", 0x4d } },
+{ "cvtlf", {"rlwf", 0x4e } },
+{ "acbf", {"rfrfmfbw", 0x4f } },
+{ "movf", {"rfwf", 0x50 } },
+{ "cmpf", {"rfrf", 0x51 } },
+{ "mnegf", {"rfwf", 0x52 } },
+{ "tstf", {"rf", 0x53 } },
+{ "emodf", {"rfrbrfwlwf", 0x54 } },
+{ "polyf", {"rfrwab", 0x55 } },
+{ "cvtfd", {"rfwd", 0x56 } },
+ /* opcode 57 is not defined yet */
+{ "adawi", {"rwmw", 0x58 } },
+ /* opcode 59 is not defined yet */
+ /* opcode 5a is not defined yet */
+ /* opcode 5b is not defined yet */
+{ "insqhi", {"abaq", 0x5c } },
+{ "insqti", {"abaq", 0x5d } },
+{ "remqhi", {"aqwl", 0x5e } },
+{ "remqti", {"aqwl", 0x5f } },
+{ "addd2", {"rdmd", 0x60 } },
+{ "addd3", {"rdrdwd", 0x61 } },
+{ "subd2", {"rdmd", 0x62 } },
+{ "subd3", {"rdrdwd", 0x63 } },
+{ "muld2", {"rdmd", 0x64 } },
+{ "muld3", {"rdrdwd", 0x65 } },
+{ "divd2", {"rdmd", 0x66 } },
+{ "divd3", {"rdrdwd", 0x67 } },
+{ "cvtdb", {"rdwb", 0x68 } },
+{ "cvtdw", {"rdww", 0x69 } },
+{ "cvtdl", {"rdwl", 0x6a } },
+{ "cvtrdl", {"rdwl", 0x6b } },
+{ "cvtbd", {"rbwd", 0x6c } },
+{ "cvtwd", {"rwwd", 0x6d } },
+{ "cvtld", {"rlwd", 0x6e } },
+{ "acbd", {"rdrdmdbw", 0x6f } },
+{ "movd", {"rdwd", 0x70 } },
+{ "cmpd", {"rdrd", 0x71 } },
+{ "mnegd", {"rdwd", 0x72 } },
+{ "tstd", {"rd", 0x73 } },
+{ "emodd", {"rdrbrdwlwd", 0x74 } },
+{ "polyd", {"rdrwab", 0x75 } },
+{ "cvtdf", {"rdwf", 0x76 } },
+ /* opcode 77 is not defined yet */
+{ "ashl", {"rbrlwl", 0x78 } },
+{ "ashq", {"rbrqwq", 0x79 } },
+{ "emul", {"rlrlrlwq", 0x7a } },
+{ "ediv", {"rlrqwlwl", 0x7b } },
+{ "clrd", {"wd", 0x7c } },
+{ "clrg", {"wg", 0x7c } },
+{ "clrq", {"wd", 0x7c } },
+{ "movq", {"rqwq", 0x7d } },
+{ "movaq", {"aqwl", 0x7e } },
+{ "movad", {"adwl", 0x7e } },
+{ "pushaq", {"aq", 0x7f } },
+{ "pushad", {"ad", 0x7f } },
+{ "addb2", {"rbmb", 0x80 } },
+{ "addb3", {"rbrbwb", 0x81 } },
+{ "subb2", {"rbmb", 0x82 } },
+{ "subb3", {"rbrbwb", 0x83 } },
+{ "mulb2", {"rbmb", 0x84 } },
+{ "mulb3", {"rbrbwb", 0x85 } },
+{ "divb2", {"rbmb", 0x86 } },
+{ "divb3", {"rbrbwb", 0x87 } },
+{ "bisb2", {"rbmb", 0x88 } },
+{ "bisb3", {"rbrbwb", 0x89 } },
+{ "bicb2", {"rbmb", 0x8a } },
+{ "bicb3", {"rbrbwb", 0x8b } },
+{ "xorb2", {"rbmb", 0x8c } },
+{ "xorb3", {"rbrbwb", 0x8d } },
+{ "mnegb", {"rbwb", 0x8e } },
+{ "caseb", {"rbrbrb", 0x8f } },
+{ "movb", {"rbwb", 0x90 } },
+{ "cmpb", {"rbrb", 0x91 } },
+{ "mcomb", {"rbwb", 0x92 } },
+{ "bitb", {"rbrb", 0x93 } },
+{ "clrb", {"wb", 0x94 } },
+{ "tstb", {"rb", 0x95 } },
+{ "incb", {"mb", 0x96 } },
+{ "decb", {"mb", 0x97 } },
+{ "cvtbl", {"rbwl", 0x98 } },
+{ "cvtbw", {"rbww", 0x99 } },
+{ "movzbl", {"rbwl", 0x9a } },
+{ "movzbw", {"rbww", 0x9b } },
+{ "rotl", {"rbrlwl", 0x9c } },
+{ "acbb", {"rbrbmbbw", 0x9d } },
+{ "movab", {"abwl", 0x9e } },
+{ "pushab", {"ab", 0x9f } },
+{ "addw2", {"rwmw", 0xa0 } },
+{ "addw3", {"rwrwww", 0xa1 } },
+{ "subw2", {"rwmw", 0xa2 } },
+{ "subw3", {"rwrwww", 0xa3 } },
+{ "mulw2", {"rwmw", 0xa4 } },
+{ "mulw3", {"rwrwww", 0xa5 } },
+{ "divw2", {"rwmw", 0xa6 } },
+{ "divw3", {"rwrwww", 0xa7 } },
+{ "bisw2", {"rwmw", 0xa8 } },
+{ "bisw3", {"rwrwww", 0xa9 } },
+{ "bicw2", {"rwmw", 0xaa } },
+{ "bicw3", {"rwrwww", 0xab } },
+{ "xorw2", {"rwmw", 0xac } },
+{ "xorw3", {"rwrwww", 0xad } },
+{ "mnegw", {"rwww", 0xae } },
+{ "casew", {"rwrwrw", 0xaf } },
+{ "movw", {"rwww", 0xb0 } },
+{ "cmpw", {"rwrw", 0xb1 } },
+{ "mcomw", {"rwww", 0xb2 } },
+{ "bitw", {"rwrw", 0xb3 } },
+{ "clrw", {"ww", 0xb4 } },
+{ "tstw", {"rw", 0xb5 } },
+{ "incw", {"mw", 0xb6 } },
+{ "decw", {"mw", 0xb7 } },
+{ "bispsw", {"rw", 0xb8 } },
+{ "bicpsw", {"rw", 0xb9 } },
+{ "popr", {"rw", 0xba } },
+{ "pushr", {"rw", 0xbb } },
+{ "chmk", {"rw", 0xbc } },
+{ "chme", {"rw", 0xbd } },
+{ "chms", {"rw", 0xbe } },
+{ "chmu", {"rw", 0xbf } },
+{ "addl2", {"rlml", 0xc0 } },
+{ "addl3", {"rlrlwl", 0xc1 } },
+{ "subl2", {"rlml", 0xc2 } },
+{ "subl3", {"rlrlwl", 0xc3 } },
+{ "mull2", {"rlml", 0xc4 } },
+{ "mull3", {"rlrlwl", 0xc5 } },
+{ "divl2", {"rlml", 0xc6 } },
+{ "divl3", {"rlrlwl", 0xc7 } },
+{ "bisl2", {"rlml", 0xc8 } },
+{ "bisl3", {"rlrlwl", 0xc9 } },
+{ "bicl2", {"rlml", 0xca } },
+{ "bicl3", {"rlrlwl", 0xcb } },
+{ "xorl2", {"rlml", 0xcc } },
+{ "xorl3", {"rlrlwl", 0xcd } },
+{ "mnegl", {"rlwl", 0xce } },
+{ "casel", {"rlrlrl", 0xcf } },
+{ "movl", {"rlwl", 0xd0 } },
+{ "cmpl", {"rlrl", 0xd1 } },
+{ "mcoml", {"rlwl", 0xd2 } },
+{ "bitl", {"rlrl", 0xd3 } },
+{ "clrf", {"wf", 0xd4 } },
+{ "clrl", {"wl", 0xd4 } },
+{ "tstl", {"rl", 0xd5 } },
+{ "incl", {"ml", 0xd6 } },
+{ "decl", {"ml", 0xd7 } },
+{ "adwc", {"rlml", 0xd8 } },
+{ "sbwc", {"rlml", 0xd9 } },
+{ "mtpr", {"rlrl", 0xda } },
+{ "mfpr", {"rlwl", 0xdb } },
+{ "movpsl", {"wl", 0xdc } },
+{ "pushl", {"rl", 0xdd } },
+{ "moval", {"alwl", 0xde } },
+{ "movaf", {"afwl", 0xde } },
+{ "pushal", {"al", 0xdf } },
+{ "pushaf", {"af", 0xdf } },
+{ "bbs", {"rlvbbb", 0xe0 } },
+{ "bbc", {"rlvbbb", 0xe1 } },
+{ "bbss", {"rlvbbb", 0xe2 } },
+{ "bbcs", {"rlvbbb", 0xe3 } },
+{ "bbsc", {"rlvbbb", 0xe4 } },
+{ "bbcc", {"rlvbbb", 0xe5 } },
+{ "bbssi", {"rlvbbb", 0xe6 } },
+{ "bbcci", {"rlvbbb", 0xe7 } },
+{ "blbs", {"rlbb", 0xe8 } },
+{ "blbc", {"rlbb", 0xe9 } },
+{ "ffs", {"rlrbvbwl", 0xea } },
+{ "ffc", {"rlrbvbwl", 0xeb } },
+{ "cmpv", {"rlrbvbrl", 0xec } },
+{ "cmpzv", {"rlrbvbrl", 0xed } },
+{ "extv", {"rlrbvbwl", 0xee } },
+{ "extzv", {"rlrbvbwl", 0xef } },
+{ "insv", {"rlrlrbvb", 0xf0 } },
+{ "acbl", {"rlrlmlbw", 0xf1 } },
+{ "aoblss", {"rlmlbb", 0xf2 } },
+{ "aobleq", {"rlmlbb", 0xf3 } },
+{ "sobgeq", {"mlbb", 0xf4 } },
+{ "sobgtr", {"mlbb", 0xf5 } },
+{ "cvtlb", {"rlwb", 0xf6 } },
+{ "cvtlw", {"rlww", 0xf7 } },
+{ "ashp", {"rbrwabrbrwab", 0xf8 } },
+{ "cvtlp", {"rlrwab", 0xf9 } },
+{ "callg", {"abab", 0xfa } },
+{ "calls", {"rlab", 0xfb } },
+{ "xfc", {"", 0xfc } },
+ /* undefined opcodes here */
+{ "cvtdh", {"rdwh", 0x32fd } },
+{ "cvtgf", {"rgwh", 0x33fd } },
+{ "addg2", {"rgmg", 0x40fd } },
+{ "addg3", {"rgrgwg", 0x41fd } },
+{ "subg2", {"rgmg", 0x42fd } },
+{ "subg3", {"rgrgwg", 0x43fd } },
+{ "mulg2", {"rgmg", 0x44fd } },
+{ "mulg3", {"rgrgwg", 0x45fd } },
+{ "divg2", {"rgmg", 0x46fd } },
+{ "divg3", {"rgrgwg", 0x47fd } },
+{ "cvtgb", {"rgwb", 0x48fd } },
+{ "cvtgw", {"rgww", 0x49fd } },
+{ "cvtgl", {"rgwl", 0x4afd } },
+{ "cvtrgl", {"rgwl", 0x4bfd } },
+{ "cvtbg", {"rbwg", 0x4cfd } },
+{ "cvtwg", {"rwwg", 0x4dfd } },
+{ "cvtlg", {"rlwg", 0x4efd } },
+{ "acbg", {"rgrgmgbw", 0x4ffd } },
+{ "movg", {"rgwg", 0x50fd } },
+{ "cmpg", {"rgrg", 0x51fd } },
+{ "mnegg", {"rgwg", 0x52fd } },
+{ "tstg", {"rg", 0x53fd } },
+{ "emodg", {"rgrwrgwlwg", 0x54fd } },
+{ "polyg", {"rgrwab", 0x55fd } },
+{ "cvtgh", {"rgwh", 0x56fd } },
+ /* undefined opcodes here */
+{ "addh2", {"rhmh", 0x60fd } },
+{ "addh3", {"rhrhwh", 0x61fd } },
+{ "subh2", {"rhmh", 0x62fd } },
+{ "subh3", {"rhrhwh", 0x63fd } },
+{ "mulh2", {"rhmh", 0x64fd } },
+{ "mulh3", {"rhrhwh", 0x65fd } },
+{ "divh2", {"rhmh", 0x66fd } },
+{ "divh3", {"rhrhwh", 0x67fd } },
+{ "cvthb", {"rhwb", 0x68fd } },
+{ "cvthw", {"rhww", 0x69fd } },
+{ "cvthl", {"rhwl", 0x6afd } },
+{ "cvtrhl", {"rhwl", 0x6bfd } },
+{ "cvtbh", {"rbwh", 0x6cfd } },
+{ "cvtwh", {"rwwh", 0x6dfd } },
+{ "cvtlh", {"rlwh", 0x6efd } },
+{ "acbh", {"rhrhmhbw", 0x6ffd } },
+{ "movh", {"rhwh", 0x70fd } },
+{ "cmph", {"rhrh", 0x71fd } },
+{ "mnegh", {"rhwh", 0x72fd } },
+{ "tsth", {"rh", 0x73fd } },
+{ "emodh", {"rhrwrhwlwh", 0x74fd } },
+{ "polyh", {"rhrwab", 0x75fd } },
+{ "cvthg", {"rhwg", 0x76fd } },
+ /* undefined opcodes here */
+{ "clrh", {"wh", 0x7cfd } },
+{ "clro", {"wo", 0x7cfd } },
+{ "movo", {"rowo", 0x7dfd } },
+{ "movah", {"ahwl", 0x7efd } },
+{ "movao", {"aowl", 0x7efd } },
+{ "pushah", {"ah", 0x7ffd } },
+{ "pushao", {"ao", 0x7ffd } },
+ /* undefined opcodes here */
+{ "cvtfh", {"rfwh", 0x98fd } },
+{ "cvtfg", {"rfwg", 0x99fd } },
+ /* undefined opcodes here */
+{ "cvthf", {"rhwf", 0xf6fd } },
+{ "cvthd", {"rhwd", 0xf7fd } },
+ /* undefined opcodes here */
+{ "bugl", {"rl", 0xfdff } },
+{ "bugw", {"rw", 0xfeff } },
+ /* undefined opcodes here */
+
+{ "", {"", 0} } /* empty is end sentinel */
+
+}; /* votstrs */
+
+/* end: vax.opcode.h */
diff --git a/include/os9k.h b/include/os9k.h
new file mode 100644
index 00000000000..0f2eed2d3b1
--- /dev/null
+++ b/include/os9k.h
@@ -0,0 +1,169 @@
+#if !defined(_MODULE_H)
+#define _MODULE_H
+
+/* OS-9000 i386 module header definitions */
+#define _MPF386
+
+/* sizeof common header less parity field */
+#define N_M_PARITY (sizeof(mh_com)-sizeof(unisgned short))
+#define OLD_M_PARITY 46
+#define M_PARITY N_M_PARITY
+
+#ifdef _MPF68K
+#define MODSYNC 0x4afd /* module header sync code for 680x0 processors */
+#endif
+
+#ifdef _MPF386
+#define MODSYNC 0x4afc /* module header sync code for 80386 processors */
+#endif
+
+#define MODREV 1 /* module format revision 1 */
+#define CRCCON 0x800fe3 /* crc polynomial constant */
+
+/* Module access permission values */
+#define MP_OWNER_READ 0x0001
+#define MP_OWNER_WRITE 0x0002
+#define MP_OWNER_EXEC 0x0004
+#define MP_GROUP_READ 0x0010
+#define MP_GROUP_WRITE 0x0020
+#define MP_GROUP_EXEC 0x0040
+#define MP_WORLD_READ 0x0100
+#define MP_WORLD_WRITE 0x0200
+#define MP_WORLD_EXEC 0x0400
+#define MP_WORLD_ACCESS 0x0777
+#define MP_OWNER_MASK 0x000f
+#define MP_GROUP_MASK 0x00f0
+#define MP_WORLD_MASK 0x0f00
+#define MP_SYSTM_MASK 0xf000
+
+/* Module Type/Language values */
+#define MT_ANY 0
+#define MT_PROGRAM 0x0001
+#define MT_SUBROUT 0x0002
+#define MT_MULTI 0x0003
+#define MT_DATA 0x0004
+#define MT_TRAPLIB 0x000b
+#define MT_SYSTEM 0x000c
+#define MT_FILEMAN 0x000d
+#define MT_DEVDRVR 0x000e
+#define MT_DEVDESC 0x000f
+#define MT_MASK 0xff00
+
+#define ML_ANY 0
+#define ML_OBJECT 1
+#define ML_ICODE 2
+#define ML_PCODE 3
+#define ML_CCODE 4
+#define ML_CBLCODE 5
+#define ML_FRTNCODE 6
+#define ML_MASK 0x00ff
+
+#define mktypelang(type,lang) (((type)<<8)|(lang))
+
+/* Module Attribute values */
+#define MA_REENT 0x80
+#define MA_GHOST 0x40
+#define MA_SUPER 0x20
+#define MA_MASK 0xff00
+#define MR_MASK 0x00ff
+
+#define mkattrevs(attr, revs) (((attr)<<8)|(revs))
+
+#define m_user m_owner.grp_usr.usr
+#define m_group m_owner.grp_usr.grp
+#define m_group_user m_owner.group_user
+
+/* macro definitions for accessing module header fields */
+#define MODNAME(mod) ((u_char*)((u_char*)mod + ((Mh_com)mod)->m_name))
+#if 0
+/* Appears not to be used, and the u_int32 typedef is gone (because it
+ conflicted with a Mach header. */
+#define MODSIZE(mod) ((u_int32)((Mh_com)mod)->m_size)
+#endif /* 0 */
+#define MHCOM_BYTES_SIZE 80
+#define N_BADMAG(a) (((a).a_info) != MODSYNC)
+
+typedef struct mh_com {
+ /* sync bytes ($4afc). */
+ unsigned char m_sync[2];
+ unsigned char m_sysrev[2]; /* system revision check value */
+ unsigned char
+ m_size[4]; /* module size */
+ unsigned char
+ m_owner[4]; /* group/user id */
+ unsigned char
+ m_name[4]; /* offset to module name */
+ unsigned char
+ m_access[2], /* access permissions */
+ m_tylan[2], /* type/lang */
+ m_attrev[2], /* rev/attr */
+ m_edit[2]; /* edition */
+ unsigned char
+ m_needs[4], /* module hardware requirements flags. (reserved) */
+ m_usage[4], /* comment string offset */
+ m_symbol[4], /* symbol table offset */
+ m_exec[4], /* offset to execution entry point */
+ m_excpt[4], /* offset to exception entry point */
+ m_data[4], /* data storage requirement */
+ m_stack[4], /* stack size */
+ m_idata[4], /* offset to initialized data */
+ m_idref[4], /* offset to data reference lists */
+ m_init[4], /* initialization routine offset */
+ m_term[4]; /* termination routine offset */
+ unsigned char
+ m_ident[2]; /* ident code for ident program */
+ char
+ m_spare[8]; /* reserved bytes */
+ unsigned char
+ m_parity[2]; /* header parity */
+} mh_com,*Mh_com;
+
+/* Executable memory module */
+typedef mh_com *Mh_exec,mh_exec;
+
+/* Data memory module */
+typedef mh_com *Mh_data,mh_data;
+
+/* File manager memory module */
+typedef mh_com *Mh_fman,mh_fman;
+
+/* device driver module */
+typedef mh_com *Mh_drvr,mh_drvr;
+
+/* trap handler module */
+typedef mh_com mh_trap, *Mh_trap;
+
+/* Device descriptor module */
+typedef mh_com *Mh_dev,mh_dev;
+
+/* Configuration module */
+typedef mh_com *Mh_config, mh_config;
+
+#if 0
+
+#if !defined(_MODDIR_H)
+/* go get _os_fmod (and others) */
+#include <moddir.h>
+#endif
+
+error_code _os_crc(void *, u_int32, int *);
+error_code _os_datmod(char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_data **);
+error_code _os_get_moddir(void *, u_int32 *);
+error_code _os_initdata(mh_com *, void *);
+error_code _os_link(char **, mh_com **, void **, u_int16 *, u_int16 *);
+error_code _os_linkm(mh_com *, void **, u_int16 *, u_int16 *);
+error_code _os_load(char *, mh_com **, void **, u_int32, u_int16 *, u_int16 *, u_int32);
+error_code _os_mkmodule(char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_com **, u_int32);
+error_code _os_modaddr(void *, mh_com **);
+error_code _os_setcrc(mh_com *);
+error_code _os_slink(u_int32, char *, void **, void **, mh_com **);
+error_code _os_slinkm(u_int32, mh_com *, void **, void **);
+error_code _os_unlink(mh_com *);
+error_code _os_unload(char *, u_int32);
+error_code _os_tlink(u_int32, char *, void **, mh_trap **, void *, u_int32);
+error_code _os_tlinkm(u_int32, mh_com *, void **, void *, u_int32);
+error_code _os_iodel(mh_com *);
+error_code _os_vmodul(mh_com *, mh_com *, u_int32);
+#endif /* 0 */
+
+#endif
diff --git a/include/progress.h b/include/progress.h
new file mode 100644
index 00000000000..f18318a4514
--- /dev/null
+++ b/include/progress.h
@@ -0,0 +1,37 @@
+/* Default definitions for progress macros.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* The default definitions below are intended to be replaced by real
+ definitions, if building the tools for an interactive programming
+ environment. */
+
+#ifndef _PROGRESS_H
+#define _PROGRESS_H
+
+#ifndef START_PROGRESS
+#define START_PROGRESS(STR,N)
+#endif
+
+#ifndef PROGRESS
+#define PROGRESS(X)
+#endif
+
+#ifndef END_PROGRESS
+#define END_PROGRESS(STR)
+#endif
+
+#endif /* _PROGRESS_H */
diff --git a/include/regs/ChangeLog b/include/regs/ChangeLog
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/include/regs/ChangeLog
diff --git a/include/remote-sim.h b/include/remote-sim.h
new file mode 100644
index 00000000000..a4480b49ca5
--- /dev/null
+++ b/include/remote-sim.h
@@ -0,0 +1,321 @@
+/* This file defines the interface between the simulator and gdb.
+ Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if !defined (REMOTE_SIM_H)
+#define REMOTE_SIM_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This file is used when building stand-alone simulators, so isolate this
+ file from gdb. */
+
+/* Pick up CORE_ADDR_TYPE if defined (from gdb), otherwise use same value as
+ gdb does (unsigned int - from defs.h). */
+
+#ifndef CORE_ADDR_TYPE
+typedef unsigned int SIM_ADDR;
+#else
+typedef CORE_ADDR_TYPE SIM_ADDR;
+#endif
+
+
+/* Semi-opaque type used as result of sim_open and passed back to all
+ other routines. "desc" is short for "descriptor".
+ It is up to each simulator to define `sim_state'. */
+
+typedef struct sim_state *SIM_DESC;
+
+
+/* Values for `kind' arg to sim_open. */
+
+typedef enum {
+ SIM_OPEN_STANDALONE, /* simulator used standalone (run.c) */
+ SIM_OPEN_DEBUG /* simulator used by debugger (gdb) */
+} SIM_OPEN_KIND;
+
+
+/* Return codes from various functions. */
+
+typedef enum {
+ SIM_RC_FAIL = 0,
+ SIM_RC_OK = 1,
+ SIM_RC_UNKNOWN_BREAKPOINT = 2,
+ SIM_RC_INSUFFICIENT_RESOURCES = 3,
+ SIM_RC_DUPLICATE_BREAKPOINT = 4
+} SIM_RC;
+
+
+/* The bfd struct, as an opaque type. */
+
+struct _bfd;
+
+
+/* Main simulator entry points. */
+
+
+/* Create a fully initialized simulator instance.
+
+ (This function is called when the simulator is selected from the
+ gdb command line.)
+
+ KIND specifies how the simulator shall be used. Currently there
+ are only two kinds: stand-alone and debug.
+
+ CALLBACK specifies a standard host callback (defined in callback.h).
+
+ ABFD, when non NULL, designates a target program. The program is
+ not loaded.
+
+ ARGV is a standard ARGV pointer such as that passed from the
+ command line. The syntax of the argument list is is assumed to be
+ ``SIM-PROG { SIM-OPTION } [ TARGET-PROGRAM { TARGET-OPTION } ]''.
+ The trailing TARGET-PROGRAM and args are only valid for a
+ stand-alone simulator.
+
+ On success, the result is a non NULL descriptor that shall be
+ passed to the other sim_foo functions. While the simulator
+ configuration can be parameterized by (in decreasing precedence)
+ ARGV's SIM-OPTION, ARGV's TARGET-PROGRAM and the ABFD argument, the
+ successful creation of the simulator shall not dependent on the
+ presence of any of these arguments/options.
+
+ Hardware simulator: The created simulator shall be sufficiently
+ initialized to handle, with out restrictions any client requests
+ (including memory reads/writes, register fetch/stores and a
+ resume).
+
+ Process simulator: that process is not created until a call to
+ sim_create_inferior. FIXME: What should the state of the simulator
+ be? */
+
+SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, struct _bfd *abfd, char **argv));
+
+
+/* Destory a simulator instance.
+
+ QUITTING is non-zero if we cannot hang on errors.
+
+ This may involve freeing target memory and closing any open files
+ and mmap'd areas. You cannot assume sim_kill has already been
+ called. */
+
+void sim_close PARAMS ((SIM_DESC sd, int quitting));
+
+
+/* Load program PROG into the simulators memory.
+
+ If ABFD is non-NULL, the bfd for the file has already been opened.
+ The result is a return code indicating success.
+
+ Hardware simulator: Normally, each program section is written into
+ memory according to that sections LMA using physical (direct)
+ addressing. The exception being systems, such as PPC/CHRP, which
+ support more complicated program loaders. A call to this function
+ should not effect the state of the processor registers. Multiple
+ calls to this function are permitted and have an accumulative
+ effect.
+
+ Process simulator: Calls to this function may be ignored.
+
+ FIXME: Most hardware simulators load the image at the VMA using
+ virtual addressing.
+
+ FIXME: For some hardware targets, before a loaded program can be
+ executed, it requires the manipulation of VM registers and tables.
+ Such manipulation should probably (?) occure in
+ sim_create_inferior. */
+
+SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty));
+
+
+/* Prepare to run the simulated program.
+
+ ABFD, if not NULL, provides initial processor state information.
+ ARGV and ENV, if non NULL, are NULL terminated lists of pointers.
+
+ Hardware simulator: This function shall initialize the processor
+ registers to a known value. The program counter and possibly stack
+ pointer shall be set using information obtained from ABFD (or
+ hardware reset defaults). ARGV and ENV, dependant on the target
+ ABI, may be written to memory.
+
+ Process simulator: After a call to this function, a new process
+ instance shall exist. The TEXT, DATA, BSS and stack regions shall
+ all be initialized, ARGV and ENV shall be written to process
+ address space (according to the applicable ABI) and the program
+ counter and stack pointer set accordingly. */
+
+SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, struct _bfd *abfd, char **argv, char **env));
+
+
+/* Fetch LENGTH bytes of the simulated program's memory. Start fetch
+ at virtual address MEM and store in BUF. Result is number of bytes
+ read, or zero if error. */
+
+int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
+
+
+/* Store LENGTH bytes from BUF into the simulated program's
+ memory. Store bytes starting at virtual address MEM. Result is
+ number of bytes write, or zero if error. */
+
+int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
+
+
+/* Fetch register REGNO storing its raw (target endian) value in the
+ LENGTH byte buffer BUF. Return the actual size of the register or
+ zero if REGNO is not applicable.
+
+ Legacy implementations ignore LENGTH and always return -1.
+
+ If LENGTH does not match the size of REGNO no data is transfered
+ (the actual register size is still returned). */
+
+int sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf, int length));
+
+
+/* Store register REGNO from the raw (target endian) value in BUF.
+ Return the actual size of the register or zero if REGNO is not
+ applicable.
+
+ Legacy implementations ignore LENGTH and always return -1.
+
+ If LENGTH does not match the size of REGNO no data is transfered
+ (the actual register size is still returned). */
+
+int sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf, int length));
+
+
+/* Print whatever statistics the simulator has collected.
+
+ VERBOSE is currently unused and must always be zero. */
+
+void sim_info PARAMS ((SIM_DESC sd, int verbose));
+
+
+/* Run (or resume) the simulated program. */
+
+void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal));
+
+
+/* Asynchronous request to stop the simulation.
+ A nonzero return indicates that the simulator is able to handle
+ the request */
+
+int sim_stop PARAMS ((SIM_DESC sd));
+
+
+/* Fetch the REASON why the program stopped.
+
+ SIM_EXITED: The program has terminated. SIGRC indicates the target
+ dependant exit status.
+
+ SIM_STOPPED: The program has stopped. SIGRC uses the host's signal
+ numbering as a way of identifying the reaon: program interrupted by
+ user via a sim_stop request (SIGINT); a breakpoint instruction
+ (SIGTRAP); a completed single step (SIGTRAP); an internal error
+ condition (SIGABRT); an illegal instruction (SIGILL); Access to an
+ undefined memory region (SIGSEGV); Mis-aligned memory access
+ (SIGBUS).
+
+ SIM_SIGNALLED: The program has stopped. The simulator has
+ encountered target code that requires the (HOST) signal SIGRC to be
+ delivered to the simulated program. Ex: `kill (getpid (),
+ TARGET_SIGxxx)'. Where TARGET_SIGxxx has been translated into a
+ host signal. FIXME: This is not always possible..
+
+ SIM_RUNNING, SIM_POLLING: The return of one of these values
+ indicates a problem internal to the simulator. */
+
+enum sim_stop { sim_running, sim_polling, sim_exited, sim_stopped, sim_signalled };
+
+void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc));
+
+
+/* Passthru for other commands that the simulator might support.
+ Simulators should be prepared to deal with any combination of NULL
+ or empty CMD. */
+
+void sim_do_command PARAMS ((SIM_DESC sd, char *cmd));
+
+/* Call these functions to set and clear breakpoints at ADDR. */
+
+SIM_RC sim_set_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
+SIM_RC sim_clear_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
+SIM_RC sim_clear_all_breakpoints PARAMS ((SIM_DESC sd));
+
+/* These functions are used to enable and disable breakpoints. */
+
+SIM_RC sim_enable_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
+SIM_RC sim_disable_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
+SIM_RC sim_enable_all_breakpoints PARAMS ((SIM_DESC sd));
+SIM_RC sim_disable_all_breakpoints PARAMS ((SIM_DESC sd));
+
+
+/* Provide simulator with a default (global) host_callback_struct.
+ THIS PROCEDURE IS DEPRECIATED.
+ GDB and NRUN do not use this interface.
+ This procedure does not take a SIM_DESC argument as it is
+ used before sim_open. */
+
+void sim_set_callbacks PARAMS ((struct host_callback_struct *));
+
+
+/* Set the size of the simulator memory array.
+ THIS PROCEDURE IS DEPRECIATED.
+ GDB and NRUN do not use this interface.
+ This procedure does not take a SIM_DESC argument as it is
+ used before sim_open. */
+
+void sim_size PARAMS ((int i));
+
+
+/* Run a simulation with tracing enabled.
+ THIS PROCEDURE IS DEPRECIATED.
+ GDB and NRUN do not use this interface.
+ This procedure does not take a SIM_DESC argument as it is
+ used before sim_open. */
+
+int sim_trace PARAMS ((SIM_DESC sd));
+
+
+/* Configure the size of the profile buffer.
+ THIS PROCEDURE IS DEPRECIATED.
+ GDB and NRUN do not use this interface.
+ This procedure does not take a SIM_DESC argument as it is
+ used before sim_open. */
+
+void sim_set_profile_size PARAMS ((int n));
+
+
+/* Kill the running program.
+ THIS PROCEDURE IS DEPRECIATED.
+ GDB and NRUN do not use this interface.
+ This procedure will be replaced as part of the introduction of
+ multi-cpu simulators. */
+
+void sim_kill PARAMS ((SIM_DESC sd));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined (REMOTE_SIM_H) */
diff --git a/include/splay-tree.h b/include/splay-tree.h
new file mode 100644
index 00000000000..e828fe7e907
--- /dev/null
+++ b/include/splay-tree.h
@@ -0,0 +1,116 @@
+/* A splay-tree datatype.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ Contributed by Mark Mitchell (mark@markmitchell.com).
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* For an easily readable description of splay-trees, see:
+
+ Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
+ Algorithms. Harper-Collins, Inc. 1991.
+
+ The major feature of splay trees is that all basic tree operations
+ are amortized O(log n) time for a tree with n nodes. */
+
+#ifndef _SPLAY_TREE_H
+#define _SPLAY_TREE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ansidecl.h>
+
+/* Use typedefs for the key and data types to facilitate changing
+ these types, if necessary. These types should be sufficiently wide
+ that any pointer or scalar can be cast to these types, and then
+ cast back, without loss of precision. */
+typedef unsigned long int splay_tree_key;
+typedef unsigned long int splay_tree_value;
+
+/* Forward declaration for a node in the tree. */
+typedef struct splay_tree_node *splay_tree_node;
+
+/* The type of a function which compares two splay-tree keys. The
+ function should return values as for qsort. */
+typedef int (*splay_tree_compare_fn) PARAMS((splay_tree_key, splay_tree_key));
+
+/* The type of a function used to deallocate any resources associated
+ with the key. */
+typedef void (*splay_tree_delete_key_fn) PARAMS((splay_tree_key));
+
+/* The type of a function used to deallocate any resources associated
+ with the value. */
+typedef void (*splay_tree_delete_value_fn) PARAMS((splay_tree_value));
+
+/* The type of a function used to iterate over the tree. */
+typedef int (*splay_tree_foreach_fn) PARAMS((splay_tree_node, void*));
+
+/* The nodes in the splay tree. */
+struct splay_tree_node
+{
+ /* The key. */
+ splay_tree_key key;
+
+ /* The value. */
+ splay_tree_value value;
+
+ /* The left and right children, respectively. */
+ splay_tree_node left;
+ splay_tree_node right;
+};
+
+/* The splay tree itself. */
+typedef struct splay_tree
+{
+ /* The root of the tree. */
+ splay_tree_node root;
+
+ /* The comparision function. */
+ splay_tree_compare_fn comp;
+
+ /* The deallocate-key function. NULL if no cleanup is necessary. */
+ splay_tree_delete_key_fn delete_key;
+
+ /* The deallocate-value function. NULL if no cleanup is necessary. */
+ splay_tree_delete_value_fn delete_value;
+} *splay_tree;
+
+extern splay_tree splay_tree_new PARAMS((splay_tree_compare_fn,
+ splay_tree_delete_key_fn,
+ splay_tree_delete_value_fn));
+extern void splay_tree_delete PARAMS((splay_tree));
+extern void splay_tree_insert PARAMS((splay_tree,
+ splay_tree_key,
+ splay_tree_value));
+extern splay_tree_node splay_tree_lookup
+ PARAMS((splay_tree,
+ splay_tree_key));
+extern int splay_tree_foreach PARAMS((splay_tree,
+ splay_tree_foreach_fn,
+ void*));
+extern int splay_tree_compare_ints PARAMS((splay_tree_key,
+ splay_tree_key));
+extern int splay_tree_compare_pointers PARAMS((splay_tree_key,
+ splay_tree_key));
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _SPLAY_TREE_H */
diff --git a/include/symcat.h b/include/symcat.h
new file mode 100644
index 00000000000..01efada2618
--- /dev/null
+++ b/include/symcat.h
@@ -0,0 +1,40 @@
+/* Symbol concatenation utilities.
+
+ Copyright (C) 1998, Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef SYM_CAT_H
+#define SYM_CAT_H
+
+#if defined (__STDC__) || defined (ALMOST_STDC)
+#define CONCAT2(a,b) a##b
+#define CONCAT3(a,b,c) a##b##c
+#define CONCAT4(a,b,c,d) a##b##c##d
+#define STRINGX(s) #s
+#else
+#define CONCAT2(a,b) a/**/b
+#define CONCAT3(a,b,c) a/**/b/**/c
+#define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
+#define STRINGX(s) "?"
+#endif
+
+#define XCONCAT2(a,b) CONCAT2(a,b)
+#define XCONCAT3(a,b,c) CONCAT3(a,b,c)
+#define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
+
+#define XSTRING(s) STRINGX(s)
+
+#endif SYM_CAT_H
diff --git a/include/wait.h b/include/wait.h
new file mode 100644
index 00000000000..fa3c9ccb1d7
--- /dev/null
+++ b/include/wait.h
@@ -0,0 +1,63 @@
+/* Define how to access the int that the wait system call stores.
+ This has been compatible in all Unix systems since time immemorial,
+ but various well-meaning people have defined various different
+ words for the same old bits in the same old int (sometimes claimed
+ to be a struct). We just know it's an int and we use these macros
+ to access the bits. */
+
+/* The following macros are defined equivalently to their definitions
+ in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1
+ <sys/wait.h> defines, since our code does not use waitpid(). We
+ also fail to declare wait() and waitpid(). */
+
+#ifndef WIFEXITED
+#define WIFEXITED(w) (((w)&0377) == 0)
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
+#endif
+
+#ifndef WIFSTOPPED
+#ifdef IBM6000
+
+/* Unfortunately, the above comment (about being compatible in all Unix
+ systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate
+ status words like 0x57c (sigtrap received after load), and gdb would
+ choke on it. */
+
+#define WIFSTOPPED(w) ((w)&0x40)
+
+#else
+#define WIFSTOPPED(w) (((w)&0377) == 0177)
+#endif
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(w) ((w) & 0177)
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG WEXITSTATUS
+#endif
+
+/* These are not defined in POSIX, but are used by our programs. */
+
+#define WAITTYPE int
+
+#ifndef WCOREDUMP
+#define WCOREDUMP(w) (((w)&0200) != 0)
+#endif
+
+#ifndef WSETEXIT
+#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
+#endif
+
+#ifndef WSETSTOP
+#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
+#endif
+
diff --git a/install-sh b/install-sh
new file mode 100755
index 00000000000..e9de23842dc
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/intl/ChangeLog b/intl/ChangeLog
new file mode 100644
index 00000000000..ecff6f6b2cd
--- /dev/null
+++ b/intl/ChangeLog
@@ -0,0 +1,1022 @@
+1997-09-06 02:10 Ulrich Drepper <drepper@cygnus.com>
+
+ * intlh.inst.in: Reformat copyright.
+
+1997-08-19 15:22 Ulrich Drepper <drepper@cygnus.com>
+
+ * dcgettext.c (DCGETTEXT): Remove wrong comment.
+
+1997-08-16 00:13 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (install-data): Don't change directory to install.
+
+1997-08-01 14:30 Ulrich Drepper <drepper@cygnus.com>
+
+ * cat-compat.c: Fix copyright.
+
+ * localealias.c: Don't define strchr unless !HAVE_STRCHR.
+
+ * loadmsgcat.c: Update copyright. Fix typos.
+
+ * l10nflist.c: Don't define strchr unless !HAVE_STRCHR.
+ (_nl_make_l10nflist): Handle sponsor and revision correctly.
+
+ * gettext.c: Update copyright.
+ * gettext.h: Likewise.
+ * hash-string.h: Likewise.
+
+ * finddomain.c: Remoave dead code. Define strchr only if
+ !HAVE_STRCHR.
+
+ * explodename.c: Include <sys/types.h>.
+
+ * explodename.c: Reformat copyright text.
+ (_nl_explode_name): Fix typo.
+
+ * dcgettext.c: Define and use __set_errno.
+ (guess_category_value): Don't use setlocale if HAVE_LC_MESSAGES is
+ not defined.
+
+ * bindtextdom.c: Pretty printing.
+
+1997-05-01 02:25 Ulrich Drepper <drepper@cygnus.com>
+
+ * dcgettext.c (guess_category_value): Don't depend on
+ HAVE_LC_MESSAGES. We don't need the macro here.
+ Patch by Bruno Haible <haible@ilog.fr>.
+
+ * cat-compat.c (textdomain): DoN't refer to HAVE_SETLOCALE_NULL
+ macro. Instead use HAVE_LOCALE_NULL and define it when using
+ glibc, as in dcgettext.c.
+ Patch by Bruno Haible <haible@ilog.fr>.
+
+ * Makefile.in (CPPFLAGS): New variable. Reported by Franc,ois
+ Pinard.
+
+Mon Mar 10 06:51:17 1997 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in: Implement handling of libtool.
+
+ * gettextP.h: Change data structures for use of generic lowlevel
+ i18n file handling.
+
+Wed Dec 4 20:21:18 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * textdomain.c: Put parentheses around arguments of memcpy macro
+ definition.
+ * localealias.c: Likewise.
+ * l10nflist.c: Likewise.
+ * finddomain.c: Likewise.
+ * bindtextdom.c: Likewise.
+ Reported by Thomas Esken.
+
+Mon Nov 25 22:57:51 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * textdomain.c: Move definition of `memcpy` macro to right
+ position.
+
+Fri Nov 22 04:01:58 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * finddomain.c [!HAVE_STRING_H && !_LIBC]: Define memcpy using
+ bcopy if not already defined. Reported by Thomas Esken.
+ * bindtextdom.c: Likewise.
+ * l10nflist.c: Likewise.
+ * localealias.c: Likewise.
+ * textdomain.c: Likewise.
+
+Tue Oct 29 11:10:27 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (libdir): Change to use exec_prefix instead of
+ prefix. Reported by Knut-HåvardAksnes <etokna@eto.ericsson.se>.
+
+Sat Aug 31 03:07:09 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * l10nflist.c (_nl_normalize_codeset): We convert to lower case,
+ so don't prepend uppercase `ISO' for only numeric arg.
+
+Fri Jul 19 00:15:46 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * l10nflist.c: Move inclusion of argz.h, ctype.h, stdlib.h after
+ definition of _GNU_SOURCE. Patch by Roland McGrath.
+
+ * Makefile.in (uninstall): Fix another bug with `for' loop and
+ empty arguments. Patch by Jim Meyering. Correct name os
+ uninstalled files: no intl- prefix anymore.
+
+ * Makefile.in (install-data): Again work around shells which
+ cannot handle mpty for list. Reported by Jim Meyering.
+
+Sat Jul 13 18:11:35 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (install): Split goal. Now depend on install-exec
+ and install-data.
+ (install-exec, install-data): New goals. Created from former
+ install goal.
+ Reported by Karl Berry.
+
+Sat Jun 22 04:58:14 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (MKINSTALLDIRS): New variable. Path to
+ mkinstalldirs script.
+ (install): use MKINSTALLDIRS variable or if the script is not present
+ try to find it in the $top_scrdir).
+
+Wed Jun 19 02:56:56 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * l10nflist.c: Linux libc *partly* includes the argz_* functions.
+ Grr. Work around by renaming the static version and use macros
+ for renaming.
+
+Tue Jun 18 20:11:17 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * l10nflist.c: Correct presence test macros of __argz_* functions.
+
+ * l10nflist.c: Include <argz.h> based on test of it instead when
+ __argz_* functions are available.
+ Reported by Andreas Schwab.
+
+Thu Jun 13 15:17:44 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * explodename.c, l10nflist.c: Define NULL for dumb systems.
+
+Tue Jun 11 17:05:13 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * intlh.inst.in, libgettext.h (dcgettext): Rename local variable
+ result to __result to prevent name clash.
+
+ * l10nflist.c, localealias.c, dcgettext.c: Define _GNU_SOURCE to
+ get prototype for stpcpy and strcasecmp.
+
+ * intlh.inst.in, libgettext.h: Move declaration of
+ `_nl_msg_cat_cntr' outside __extension__ block to prevent warning
+ from gcc's -Wnested-extern option.
+
+Fri Jun 7 01:58:00 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (install): Remove comment.
+
+Thu Jun 6 17:28:17 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (install): Work around for another Buglix stupidity.
+ Always use an `else' close for `if's. Reported by Nelson Beebe.
+
+ * Makefile.in (intlh.inst): Correct typo in phony rule.
+ Reported by Nelson Beebe.
+
+Thu Jun 6 01:49:52 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * dcgettext.c (read_alias_file): Rename variable alloca_list to
+ block_list as the macro calls assume.
+ Patch by Eric Backus.
+
+ * localealias.c [!HAVE_ALLOCA]: Define alloca as macro using
+ malloc.
+ (read_alias_file): Rename varriabe alloca_list to block_list as the
+ macro calls assume.
+ Patch by Eric Backus.
+
+ * l10nflist.c: Correct conditional for <argz.h> inclusion.
+ Reported by Roland McGrath.
+
+ * Makefile.in (all): Depend on all-@USE_INCLUDED_LIBINTL@, not
+ all-@USE_NLS@.
+
+ * Makefile.in (install): intlh.inst comes from local dir, not
+ $(srcdir).
+
+ * Makefile.in (intlh.inst): Special handling of this goal. If
+ used in gettext, this is really a rul to construct this file. If
+ used in any other package it is defined as a .PHONY rule with
+ empty body.
+
+ * finddomain.c: Extract locale file information handling into
+ l10nfile.c. Rename local stpcpy__ function to stpcpy.
+
+ * dcgettext.c (stpcpy): Add local definition.
+
+ * l10nflist.c: Solve some portability problems. Patches partly by
+ Thomas Esken. Add local definition of stpcpy.
+
+Tue Jun 4 02:47:49 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * intlh.inst.in: Don't depend including <locale.h> on
+ HAVE_LOCALE_H. Instead configure must rewrite this fiile
+ depending on the result of the configure run.
+
+ * Makefile.in (install): libintl.inst is now called intlh.inst.
+ Add rules for updating intlh.inst from intlh.inst.in.
+
+ * libintl.inst: Renamed to intlh.inst.in.
+
+ * localealias.c, dcgettext.c [__GNUC__]: Define HAVE_ALLOCA to 1
+ because gcc has __buitlin_alloca.
+ Reported by Roland McGrath.
+
+Mon Jun 3 00:32:16 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (installcheck): New goal to fulfill needs of
+ automake's distcheck.
+
+ * Makefile.in (install): Reorder commands so that VERSION is
+ found.
+
+ * Makefile.in (gettextsrcdir): Now use subdirectory intl/ in
+ @datadir@/gettext.
+ (COMSRCS): Add l10nfile.c.
+ (OBJECTS): Add l10nfile.o.
+ (DISTFILES): Rename to DISTFILE.normal. Remove $(DISTFILES.common).
+ (DISTFILE.gettext): Remove $(DISTFILES.common).
+ (all-gettext): Remove goal.
+ (install): If $(PACKAGE) = gettext install, otherwose do nothing. No
+ package but gettext itself should install libintl.h + headers.
+ (dist): Extend goal to work for gettext, too.
+ (dist-gettext): Remove goal.
+
+ * dcgettext.c [!HAVE_ALLOCA]: Define macro alloca by using malloc.
+
+Sun Jun 2 17:33:06 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * loadmsgcat.c (_nl_load_domain): Parameter is now comes from
+ find_l10nfile.
+
+Sat Jun 1 02:23:03 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * l10nflist.c (__argz_next): Add definition.
+
+ * dcgettext.c [!HAVE_ALLOCA]: Add code for handling missing alloca
+ code. Use new l10nfile handling.
+
+ * localealias.c [!HAVE_ALLOCA]: Add code for handling missing
+ alloca code.
+
+ * l10nflist.c: Initial revision.
+
+Tue Apr 2 18:51:18 1996 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (all-gettext): New goal. Same as all-yes.
+
+Thu Mar 28 23:01:22 1996 Karl Eichwalder <ke@ke.central.de>
+
+ * Makefile.in (gettextsrcdir): Define using @datadir@.
+
+Tue Mar 26 12:39:14 1996 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c: Include <ctype.h>. Reported by Roland McGrath.
+
+Sat Mar 23 02:00:35 1996 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (stpcpy): Rename to stpcpy__ to prevent clashing
+ with external declaration.
+
+Sat Mar 2 00:47:09 1996 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (all-no): Rename from all_no.
+
+Sat Feb 17 00:25:59 1996 Ulrich Drepper <drepper@myware>
+
+ * gettextP.h [loaded_domain]: Array `successor' must now contain up
+ to 63 elements (because of codeset name normalization).
+
+ * finddomain.c: Implement codeset name normalization.
+
+Thu Feb 15 04:39:09 1996 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (all): Define to `all-@USE_NLS@'.
+ (all-yes, all_no): New goals. `all-no' is noop, `all-yes'
+ is former all.
+
+Mon Jan 15 21:46:01 1996 Howard Gayle <howard@hal.com>
+
+ * localealias.c (alias_compare): Increment string pointers in loop
+ of strcasecmp replacement.
+
+Fri Dec 29 21:16:34 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (install-src): Who commented this goal out ? :-)
+
+Fri Dec 29 15:08:16 1995 Ulrich Drepper <drepper@myware>
+
+ * dcgettext.c (DCGETTEXT): Save `errno'. Failing system calls
+ should not effect it because a missing catalog is no error.
+ Reported by Harald K<o:>nig <koenig@tat.physik.uni-tuebingen.de>.
+
+Tue Dec 19 22:09:13 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (Makefile): Explicitly use $(SHELL) for running
+ shell scripts.
+
+Fri Dec 15 17:34:59 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makefile.in (install-src): Only install library and header when
+ we use the own implementation. Don't do it when using the
+ system's gettext or catgets functions.
+
+ * dcgettext.c (find_msg): Must not swap domain->hash_size here.
+
+Sat Dec 9 16:24:37 1995 Ulrich Drepper <drepper@myware>
+
+ * localealias.c, libintl.inst, libgettext.h, hash-string.h,
+ gettextP.h, finddomain.c, dcgettext.c, cat-compat.c:
+ Use PARAMS instead of __P. Suggested by Roland McGrath.
+
+Tue Dec 5 11:39:14 1995 Larry Schwimmer <rosebud@cyclone.stanford.edu>
+
+ * libgettext.h: Use `#if !defined (_LIBINTL_H)' instead of `#if
+ !_LIBINTL_H' because Solaris defines _LIBINTL_H as empty.
+
+Mon Dec 4 15:42:07 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (install-src):
+ Install libintl.inst instead of libintl.h.install.
+
+Sat Dec 2 22:51:38 1995 Marcus Daniels <marcus@sysc.pdx.edu>
+
+ * cat-compat.c (textdomain):
+ Reverse order in which files are tried you load. First
+ try local file, when this failed absolute path.
+
+Wed Nov 29 02:03:53 1995 Nelson H. F. Beebe <beebe@math.utah.edu>
+
+ * cat-compat.c (bindtextdomain): Add missing { }.
+
+Sun Nov 26 18:21:41 1995 Ulrich Drepper <drepper@myware>
+
+ * libintl.inst: Add missing __P definition. Reported by Nelson Beebe.
+
+ * Makefile.in:
+ Add dummy `all' and `dvi' goals. Reported by Tom Tromey.
+
+Sat Nov 25 16:12:01 1995 Franc,ois Pinard <pinard@iro.umontreal.ca>
+
+ * hash-string.h: Capitalize arguments of macros.
+
+Sat Nov 25 12:01:36 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (DISTFILES): Prevent files names longer than 13
+ characters. libintl.h.glibc->libintl.glibc,
+ libintl.h.install->libintl.inst. Reported by Joshua R. Poulson.
+
+Sat Nov 25 11:31:12 1995 Eric Backus <ericb@lsid.hp.com>
+
+ * dcgettext.c: Fix bug in preprocessor conditionals.
+
+Sat Nov 25 02:35:27 1995 Nelson H. F. Beebe <beebe@math.utah.edu>
+
+ * libgettext.h: Solaris cc does not understand
+ #if !SYMBOL1 && !SYMBOL2. Sad but true.
+
+Thu Nov 23 16:22:14 1995 Ulrich Drepper <drepper@myware>
+
+ * hash-string.h (hash_string):
+ Fix for machine with >32 bit `unsigned long's.
+
+ * dcgettext.c (DCGETTEXT):
+ Fix horrible bug in loop for alternative translation.
+
+Thu Nov 23 01:45:29 1995 Ulrich Drepper <drepper@myware>
+
+ * po2tbl.sed.in, linux-msg.sed, xopen-msg.sed:
+ Some further simplifications in message number generation.
+
+Mon Nov 20 21:08:43 1995 Ulrich Drepper <drepper@myware>
+
+ * libintl.h.glibc: Use __const instead of const in prototypes.
+
+ * Makefile.in (install-src):
+ Install libintl.h.install instead of libintl.h. This
+ is a stripped-down version. Suggested by Peter Miller.
+
+ * libintl.h.install, libintl.h.glibc: Initial revision.
+
+ * localealias.c (_nl_expand_alias, read_alias_file):
+ Protect prototypes in type casts by __P.
+
+Tue Nov 14 16:43:58 1995 Ulrich Drepper <drepper@myware>
+
+ * hash-string.h: Correct prototype for hash_string.
+
+Sun Nov 12 12:42:30 1995 Ulrich Drepper <drepper@myware>
+
+ * hash-string.h (hash_string): Add prototype.
+
+ * gettextP.h: Fix copyright.
+ (SWAP): Add prototype.
+
+Wed Nov 8 22:56:33 1995 Ulrich Drepper <drepper@myware>
+
+ * localealias.c (read_alias_file): Forgot sizeof.
+ Avoid calling *printf function. This introduces a big overhead.
+ Patch by Roland McGrath.
+
+Tue Nov 7 14:21:08 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c, cat-compat.c: Wrong indentation in #if for stpcpy.
+
+ * finddomain.c (stpcpy):
+ Define substitution function local. The macro was to flaky.
+
+ * cat-compat.c: Fix typo.
+
+ * xopen-msg.sed, linux-msg.sed:
+ While bringing message number to right place only accept digits.
+
+ * linux-msg.sed, xopen-msg.sed: Now that the counter does not have
+ leading 0s we don't need to remove them. Reported by Marcus
+ Daniels.
+
+ * Makefile.in (../po/cat-id-tbl.o): Use $(top_srdir) in
+ dependency. Reported by Marcus Daniels.
+
+ * cat-compat.c: (stpcpy) [!_LIBC && !HAVE_STPCPY]: Define replacement.
+ Generally cleanup using #if instead of #ifndef.
+
+ * Makefile.in: Correct typos in comment. By Franc,ois Pinard.
+
+Mon Nov 6 00:27:02 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (install-src): Don't install libintl.h and libintl.a
+ if we use an available gettext implementation.
+
+Sun Nov 5 22:02:08 1995 Ulrich Drepper <drepper@myware>
+
+ * libgettext.h: Fix typo: HAVE_CATGETTS -> HAVE_CATGETS. Reported
+ by Franc,ois Pinard.
+
+ * libgettext.h: Use #if instead of #ifdef/#ifndef.
+
+ * finddomain.c:
+ Comments describing what has to be done should start with FIXME.
+
+Sun Nov 5 19:38:01 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (DISTFILES): Split. Use DISTFILES with normal meaning.
+ DISTFILES.common names the files common to both dist goals.
+ DISTFILES.gettext are the files only distributed in GNU gettext.
+
+Sun Nov 5 17:32:54 1995 Ulrich Drepper <drepper@myware>
+
+ * dcgettext.c (DCGETTEXT): Correct searching in derived locales.
+ This was necessary since a change in _nl_find_msg several weeks
+ ago. I really don't know this is still not fixed.
+
+Sun Nov 5 12:43:12 1995 Ulrich Drepper <drepper@myware>
+
+ * loadmsgcat.c (_nl_load_domain): Test for FILENAME == NULL. This
+ might mark a special condition.
+
+ * finddomain.c (make_entry_rec): Don't make illegal entry as decided.
+
+ * Makefile.in (dist): Suppress error message when ln failed.
+ Get files from $(srcdir) explicitly.
+
+ * libgettext.h (gettext_const): Rename to gettext_noop.
+
+Fri Nov 3 07:36:50 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (make_entry_rec):
+ Protect against wrong locale names by testing mask.
+
+ * libgettext.h (gettext_const): Add macro definition.
+ Capitalize macro arguments.
+
+Thu Nov 2 23:15:51 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (_nl_find_domain):
+ Test for pointer != NULL before accessing value.
+ Reported by Tom Tromey.
+
+ * gettext.c (NULL):
+ Define as (void*)0 instad of 0. Reported by Franc,ois Pinard.
+
+Mon Oct 30 21:28:52 1995 Ulrich Drepper <drepper@myware>
+
+ * po2tbl.sed.in: Serious typo bug fixed by Jim Meyering.
+
+Sat Oct 28 23:20:47 1995 Ulrich Drepper <drepper@myware>
+
+ * libgettext.h: Disable dcgettext optimization for Solaris 2.3.
+
+ * localealias.c (alias_compare):
+ Peter Miller reported that tolower in some systems is
+ even dumber than I thought. Protect call by `isupper'.
+
+Fri Oct 27 22:22:51 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (libdir, includedir): New variables.
+ (install-src): Install libintl.a and libintl.h in correct dirs.
+
+Fri Oct 27 22:07:29 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (SOURCES): Fix typo: intrl.compat.c -> intl-compat.c.
+
+ * po2tbl.sed.in: Patch for buggy SEDs by Christian von Roques.
+
+ * localealias.c:
+ Fix typo and superflous test. Reported by Christian von Roques.
+
+Fri Oct 6 11:52:05 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (_nl_find_domain):
+ Correct some remainder from the pre-CEN syntax. Now
+ we don't have a constant number of successors anymore.
+
+Wed Sep 27 21:41:13 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (DISTFILES): Add libintl.h.glibc.
+
+ * Makefile.in (dist-libc): Add goal for packing sources for glibc.
+ (COMSRCS, COMHDRS): Splitted to separate sources shared with glibc.
+
+ * loadmsgcat.c: Forget to continue #if line.
+
+ * localealias.c:
+ [_LIBC]: Rename strcasecmp to __strcasecmp to keep ANSI C name
+ space clean.
+
+ * dcgettext.c, finddomain.c: Better comment to last change.
+
+ * loadmsgcat.c:
+ [_LIBC]: Rename fstat, open, close, read, mmap, and munmap to
+ __fstat, __open, __close, __read, __mmap, and __munmap resp
+ to keep ANSI C name space clean.
+
+ * finddomain.c:
+ [_LIBC]: Rename stpcpy to __stpcpy to keep ANSI C name space clean.
+
+ * dcgettext.c:
+ [_LIBC]: Rename getced and stpcpy to __getcwd and __stpcpy resp to
+ keep ANSI C name space clean.
+
+ * libgettext.h:
+ Include sys/types.h for those old SysV systems out there.
+ Reported by Francesco Potorti`.
+
+ * loadmsgcat.c (use_mmap): Define if compiled for glibc.
+
+ * bindtextdom.c: Include all those standard headers
+ unconditionally if _LIBC is defined.
+
+ * finddomain.c: Fix 2 times defiend -> defined.
+
+ * textdomain.c: Include libintl.h instead of libgettext.h when
+ compiling for glibc. Include all those standard headers
+ unconditionally if _LIBC is defined.
+
+ * localealias.c, loadmsgcat.c: Prepare to be compiled in glibc.
+
+ * gettext.c:
+ Include libintl.h instead of libgettext.h when compiling for glibc.
+ Get NULL from stddef.h if we compile for glibc.
+
+ * finddomain.c: Include libintl.h instead of libgettext.h when
+ compiling for glibc. Include all those standard headers
+ unconditionally if _LIBC is defined.
+
+ * dcgettext.c: Include all those standard headers unconditionally
+ if _LIBC is defined.
+
+ * dgettext.c: If compiled in glibc include libintl.h instead of
+ libgettext.h.
+ (locale.h): Don't rely on HAVE_LOCALE_H when compiling for glibc.
+
+ * dcgettext.c: If compiled in glibc include libintl.h instead of
+ libgettext.h.
+ (getcwd): Don't rely on HAVE_GETCWD when compiling for glibc.
+
+ * bindtextdom.c:
+ If compiled in glibc include libintl.h instead of libgettext.h.
+
+Mon Sep 25 22:23:06 1995 Ulrich Drepper <drepper@myware>
+
+ * localealias.c (_nl_expand_alias): Don't call bsearch if NMAP <= 0.
+ Reported by Marcus Daniels.
+
+ * cat-compat.c (bindtextdomain):
+ String used in putenv must not be recycled.
+ Reported by Marcus Daniels.
+
+ * libgettext.h (__USE_GNU_GETTEXT):
+ Additional symbol to signal that we use GNU gettext
+ library.
+
+ * cat-compat.c (bindtextdomain):
+ Fix bug with the strange stpcpy replacement.
+ Reported by Nelson Beebe.
+
+Sat Sep 23 08:23:51 1995 Ulrich Drepper <drepper@myware>
+
+ * cat-compat.c: Include <string.h> for stpcpy prototype.
+
+ * localealias.c (read_alias_file):
+ While expand strdup code temporary variable `cp' hided
+ higher level variable with same name. Rename to `tp'.
+
+ * textdomain.c (textdomain):
+ Avoid warning by using temporary variable in strdup code.
+
+ * finddomain.c (_nl_find_domain): Remove unused variable `application'.
+
+Thu Sep 21 15:51:44 1995 Ulrich Drepper <drepper@myware>
+
+ * localealias.c (alias_compare):
+ Use strcasecmp() only if available. Else use
+ implementation in place.
+
+ * intl-compat.c:
+ Wrapper functions now call *__ functions instead of __*.
+
+ * libgettext.h: Declare prototypes for *__ functions instead for __*.
+
+ * cat-compat.c, loadmsgcat.c:
+ Don't use xmalloc, xstrdup, and stpcpy. These functions are not part
+ of the standard libc and so prevent libintl.a from being used
+ standalone.
+
+ * bindtextdom.c:
+ Don't use xmalloc, xstrdup, and stpcpy. These functions are not part
+ of the standard libc and so prevent libintl.a from being used
+ standalone.
+ Rename to bindtextdomain__ if not used in GNU C Library.
+
+ * dgettext.c:
+ Rename function to dgettext__ if not used in GNU C Library.
+
+ * gettext.c:
+ Don't use xmalloc, xstrdup, and stpcpy. These functions are not part
+ of the standard libc and so prevent libintl.a from being used
+ standalone.
+ Functions now called gettext__ if not used in GNU C Library.
+
+ * dcgettext.c, localealias.c, textdomain.c, finddomain.c:
+ Don't use xmalloc, xstrdup, and stpcpy. These functions are not part
+ of the standard libc and so prevent libintl.a from being used
+ standalone.
+
+Sun Sep 17 23:14:49 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c: Correct some bugs in handling of CEN standard
+ locale definitions.
+
+Thu Sep 7 01:49:28 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c: Implement CEN syntax.
+
+ * gettextP.h (loaded_domain): Extend number of successors to 31.
+
+Sat Aug 19 19:25:29 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (aliaspath): Remove path to X11 locale dir.
+
+ * Makefile.in: Make install-src depend on install. This helps
+ gettext to install the sources and other packages can use the
+ install goal.
+
+Sat Aug 19 15:19:33 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (uninstall): Remove stuff installed by install-src.
+
+Tue Aug 15 13:13:53 1995 Ulrich Drepper <drepper@myware>
+
+ * VERSION.in: Initial revision.
+
+ * Makefile.in (DISTFILES):
+ Add VERSION file. This is not necessary for gettext, but
+ for other packages using this library.
+
+Tue Aug 15 06:16:44 1995 Ulrich Drepper <drepper@myware>
+
+ * gettextP.h (_nl_find_domain):
+ New prototype after changing search strategy.
+
+ * finddomain.c (_nl_find_domain):
+ We now try only to find a specified catalog. Fall back to other
+ catalogs listed in the locale list is now done in __dcgettext.
+
+ * dcgettext.c (__dcgettext):
+ Now we provide message fall back even to different languages.
+ I.e. if a message is not available in one language all the other
+ in the locale list a tried. Formerly fall back was only possible
+ within one language. Implemented by moving one loop from
+ _nl_find_domain to here.
+
+Mon Aug 14 23:45:50 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (gettextsrcdir):
+ Directory where source of GNU gettext library are made
+ available.
+ (INSTALL, INSTALL_DATA): Programs used for installing sources.
+ (gettext-src): New. Rule to install GNU gettext sources for use in
+ gettextize shell script.
+
+Sun Aug 13 14:40:48 1995 Ulrich Drepper <drepper@myware>
+
+ * loadmsgcat.c (_nl_load_domain):
+ Use mmap for loading only when munmap function is
+ also available.
+
+ * Makefile.in (install): Depend on `all' goal.
+
+Wed Aug 9 11:04:33 1995 Ulrich Drepper <drepper@myware>
+
+ * localealias.c (read_alias_file):
+ Do not overwrite '\n' when terminating alias value string.
+
+ * localealias.c (read_alias_file):
+ Handle long lines. Ignore the rest not fitting in
+ the buffer after the initial `fgets' call.
+
+Wed Aug 9 00:54:29 1995 Ulrich Drepper <drepper@myware>
+
+ * gettextP.h (_nl_load_domain):
+ Add prototype, replacing prototype for _nl_load_msg_cat.
+
+ * finddomain.c (_nl_find_domain):
+ Remove unneeded variable filename and filename_len.
+ (expand_alias): Remove prototype because functions does not
+ exist anymore.
+
+ * localealias.c (read_alias_file):
+ Change type of fname_len parameter to int.
+ (xmalloc): Add prototype.
+
+ * loadmsgcat.c: Better prototypes for xmalloc.
+
+Tue Aug 8 22:30:39 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (_nl_find_domain):
+ Allow alias name to be constructed from the four components.
+
+ * Makefile.in (aliaspath): New variable. Set to preliminary value.
+ (SOURCES): Add localealias.c.
+ (OBJECTS): Add localealias.o.
+
+ * gettextP.h: Add prototype for _nl_expand_alias.
+
+ * finddomain.c: Aliasing handled in intl/localealias.c.
+
+ * localealias.c: Aliasing for locale names.
+
+ * bindtextdom.c: Better prototypes for xmalloc and xstrdup.
+
+Mon Aug 7 23:47:42 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (DISTFILES): gettext.perl is now found in misc/.
+
+ * cat-compat.c (bindtextdomain):
+ Correct implementation. dirname parameter was not used.
+ Reported by Marcus Daniels.
+
+ * gettextP.h (loaded_domain):
+ New fields `successor' and `decided' for oo, lazy
+ message handling implementation.
+
+ * dcgettext.c:
+ Adopt for oo, lazy message handliing.
+ Now we can inherit translations from less specific locales.
+ (find_msg): New function.
+
+ * loadmsgcat.c, finddomain.c:
+ Complete rewrite. Implement oo, lazy message handling :-).
+ We now have an additional environment variable `LANGUAGE' with
+ a higher priority than LC_ALL for the LC_MESSAGE locale.
+ Here we can set a colon separated list of specifications each
+ of the form `language[_territory[.codeset]][@modifier]'.
+
+Sat Aug 5 09:55:42 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (unistd.h):
+ Include to get _PC_PATH_MAX defined on system having it.
+
+Fri Aug 4 22:42:00 1995 Ulrich Drepper <drepper@myware>
+
+ * finddomain.c (stpcpy): Include prototype.
+
+ * Makefile.in (dist): Remove `copying instead' message.
+
+Wed Aug 2 18:52:03 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (ID, TAGS): Do not use $^.
+
+Tue Aug 1 20:07:11 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (TAGS, ID): Use $^ as command argument.
+ (TAGS): Give etags -o option t write to current directory,
+ not $(srcdir).
+ (ID): Use $(srcdir) instead os $(top_srcdir)/src.
+ (distclean): Remove ID.
+
+Sun Jul 30 11:51:46 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (gnulocaledir):
+ New variable, always using share/ for data directory.
+ (DEFS): Add GNULOCALEDIR, used in finddomain.c.
+
+ * finddomain.c (_nl_default_dirname):
+ Set to GNULOCALEDIR, because it always has to point
+ to the directory where GNU gettext Library writes it to.
+
+ * intl-compat.c (textdomain, bindtextdomain):
+ Undefine macros before function definition.
+
+Sat Jul 22 01:10:02 1995 Ulrich Drepper <drepper@myware>
+
+ * libgettext.h (_LIBINTL_H):
+ Protect definition in case where this file is included as
+ libgettext.h on Solaris machines. Add comment about this.
+
+Wed Jul 19 02:36:42 1995 Ulrich Drepper <drepper@myware>
+
+ * intl-compat.c (textdomain): Correct typo.
+
+Wed Jul 19 01:51:35 1995 Ulrich Drepper <drepper@myware>
+
+ * dcgettext.c (dcgettext): Function now called __dcgettext.
+
+ * dgettext.c (dgettext): Now called __dgettext and calls
+ __dcgettext.
+
+ * gettext.c (gettext):
+ Function now called __gettext and calls __dgettext.
+
+ * textdomain.c (textdomain): Function now called __textdomain.
+
+ * bindtextdom.c (bindtextdomain): Function now called
+ __bindtextdomain.
+
+ * intl-compat.c: Initial revision.
+
+ * Makefile.in (SOURCES): Add intl-compat.c.
+ (OBJECTS): We always compile the GNU gettext library functions.
+ OBJECTS contains all objects but cat-compat.o, ../po/cat-if-tbl.o,
+ and intl-compat.o.
+ (GETTOBJS): Contains now only intl-compat.o.
+
+ * libgettext.h:
+ Re-include protection matches dualistic character of libgettext.h.
+ For all functions in GNU gettext library define __ counter part.
+
+ * finddomain.c (strchr): Define as index if not found in C library.
+ (_nl_find_domain): For relative paths paste / in between.
+
+Tue Jul 18 16:37:45 1995 Ulrich Drepper <drepper@myware>
+
+ * loadmsgcat.c, finddomain.c: Add inclusion of sys/types.h.
+
+ * xopen-msg.sed: Fix bug with `msgstr ""' lines.
+ A little bit better comments.
+
+Tue Jul 18 01:18:27 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in:
+ po-mode.el, makelinks, combine-sh are now found in ../misc.
+
+ * po-mode.el, makelinks, combine-sh, elisp-comp:
+ Moved to ../misc/.
+
+ * libgettext.h, gettextP.h, gettext.h: Uniform test for __STDC__.
+
+Sun Jul 16 22:33:02 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (INSTALL, INSTALL_DATA): New variables.
+ (install-data, uninstall): Install/uninstall .elc file.
+
+ * po-mode.el (Installation comment):
+ Add .pox as possible extension of .po files.
+
+Sun Jul 16 13:23:27 1995 Ulrich Drepper <drepper@myware>
+
+ * elisp-comp: Complete new version by Franc,ois: This does not
+ fail when not compiling in the source directory.
+
+Sun Jul 16 00:12:17 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (../po/cat-id-tbl.o):
+ Use $(MAKE) instead of make for recursive make.
+
+ * Makefile.in (.el.elc): Use $(SHELL) instead of /bin/sh.
+ (install-exec): Add missing dummy goal.
+ (install-data, uninstall): @ in multi-line shell command at
+ beginning, not in front of echo. Reported by Eric Backus.
+
+Sat Jul 15 00:21:28 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (DISTFILES):
+ Rename libgettext.perl to gettext.perl to fit in 14 chars
+ file systems.
+
+ * gettext.perl:
+ Rename to gettext.perl to fit in 14 chars file systems.
+
+Thu Jul 13 23:17:20 1995 Ulrich Drepper <drepper@myware>
+
+ * cat-compat.c: If !STDC_HEADERS try to include malloc.h.
+
+Thu Jul 13 20:55:02 1995 Ulrich Drepper <drepper@myware>
+
+ * po2tbl.sed.in: Pretty printing.
+
+ * linux-msg.sed, xopen-msg.sed:
+ Correct bugs with handling substitute flags in branches.
+
+ * hash-string.h (hash_string):
+ Old K&R compilers don't under stand `unsigned char'.
+
+ * gettext.h (nls_uint32):
+ Some old K&R compilers (eg HP) don't understand `unsigned int'.
+
+ * cat-compat.c (msg_to_cat_id): De-ANSI-fy prototypes.
+
+Thu Jul 13 01:34:33 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (ELCFILES): New variable.
+ (DISTFILES): Add elisp-comp.
+ Add implicit rule for .el -> .elc compilation.
+ (install-data): install $ELCFILES
+ (clean): renamed po-to-tbl and po-to-msg to po2tbl and po2msg resp.
+
+ * elisp-comp: Initial revision
+
+Wed Jul 12 16:14:52 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in:
+ cat-id-tbl.c is now found in po/. This enables us to use an identical
+ intl/ directory in all packages.
+
+ * dcgettext.c (dcgettext): hashing does not work for table size <= 2.
+
+ * textdomain.c: fix typo (#if def -> #if defined)
+
+Tue Jul 11 18:44:43 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in (stamp-cat-id): use top_srcdir to address source files
+ (DISTFILES,distclean): move tupdate.perl to src/
+
+ * po-to-tbl.sed.in:
+ add additional jump to clear change flag to recognize multiline strings
+
+Tue Jul 11 01:32:50 1995 Ulrich Drepper <drepper@myware>
+
+ * textdomain.c: Protect inclusion of stdlib.h and string.h.
+
+ * loadmsgcat.c: Protect inclusion of stdlib.h.
+
+ * libgettext.h: Protect inclusion of locale.h.
+ Allow use in C++ programs.
+ Define NULL is not happened already.
+
+ * Makefile.in (DISTFILES): ship po-to-tbl.sed.in instead of
+ po-to-tbl.sed.
+ (distclean): remove po-to-tbl.sed and tupdate.perl.
+
+ * tupdate.perl.in: Substitute Perl path even in exec line.
+ Don't include entries without translation from old .po file.
+
+Tue Jul 4 00:41:51 1995 Ulrich Drepper <drepper@myware>
+
+ * tupdate.perl.in: use "Updated: " in msgid "".
+
+ * cat-compat.c: Fix typo (LOCALDIR -> LOCALEDIR).
+ Define getenv if !__STDC__.
+
+ * bindtextdom.c: Protect stdlib.h and string.h inclusion.
+ Define free if !__STDC__.
+
+ * finddomain.c: Change DEF_MSG_DOM_DIR to LOCALEDIR.
+ Define free if !__STDC__.
+
+ * cat-compat.c: Change DEF_MSG_DOM_DIR to LOCALEDIR.
+
+Mon Jul 3 23:56:30 1995 Ulrich Drepper <drepper@myware>
+
+ * Makefile.in: Use LOCALEDIR instead of DEF_MSG_DOM_DIR.
+ Remove unneeded $(srcdir) from Makefile.in dependency.
+
+ * makelinks: Add copyright and short description.
+
+ * po-mode.el: Last version for 0.7.
+
+ * tupdate.perl.in: Fix die message.
+
+ * dcgettext.c: Protect include of string.h.
+
+ * gettext.c: Protect include of stdlib.h and further tries to get NULL.
+
+ * finddomain.c: Some corrections in includes.
+
+ * Makefile.in (INCLUDES): Prune list correct path to Makefile.in.
+
+ * po-to-tbl.sed: Adopt for new .po file format.
+
+ * linux-msg.sed, xopen-msg.sed: Adopt for new .po file format.
+
+Sun Jul 2 23:55:03 1995 Ulrich Drepper <drepper@myware>
+
+ * tupdate.perl.in: Complete rewrite for new .po file format.
+
+Sun Jul 2 02:06:50 1995 Ulrich Drepper <drepper@myware>
+
+ * First official release. This directory contains all the code
+ needed to internationalize own packages. It provides functions
+ which allow to use the X/Open catgets function with an interface
+ like the Uniforum gettext function. For system which does not
+ have neither of those a complete implementation is provided.
diff --git a/intl/ChangeLog.Cygnus b/intl/ChangeLog.Cygnus
new file mode 100644
index 00000000000..6d32da6bba1
--- /dev/null
+++ b/intl/ChangeLog.Cygnus
@@ -0,0 +1,30 @@
+Tue May 26 18:29:09 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (distclean): Remove config.log.
+
+Sun May 10 22:35:54 1998 Jeffrey A Law (law@cygnus.com)
+
+ * po/Makefile.in (install-info): New target.
+
+Sun Apr 19 19:20:00 1998 Tom Tromey <tromey@cygnus.com>
+
+ * aclocal.m4, configure: Rebuilt.
+ * configure.in: Call AC_LINK_FILES so that <libintl.h> will
+ always exist.
+
+Fri Mar 27 16:37:25 1998 Tom Tromey <tromey@cygnus.com>
+
+ * aclocal.m4, configure: Rebuilt with new cygettext.m4.
+
+Wed Mar 25 15:00:14 1998 Tom Tromey <tromey@cygnus.com>
+
+ * configure.in: Build config.h from config.in.
+ * config.h.in: Removed.
+ * config.in: New file.
+
+ * config.h.in: New file.
+
+ * configure.in, configure, acconfig.h, aclocal.m4: New files.
+ * Makefile.in (OBJECTS): Depend on config.h, not ../config.h.
+ (Makefile): Rebuild Makefile here, not in `..'.
+
diff --git a/intl/Makefile.in b/intl/Makefile.in
new file mode 100644
index 00000000000..09647ded8eb
--- /dev/null
+++ b/intl/Makefile.in
@@ -0,0 +1,214 @@
+# Makefile for directory with message catalog handling in GNU NLS Utilities.
+# Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SHELL = /bin/sh
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = ..
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+transform = @program_transform_name@
+libdir = $(exec_prefix)/lib
+includedir = $(prefix)/include
+datadir = $(prefix)/@DATADIRNAME@
+localedir = $(datadir)/locale
+gnulocaledir = $(prefix)/share/locale
+gettextsrcdir = @datadir@/gettext/intl
+aliaspath = $(localedir):.
+subdir = intl
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+
+l = @l@
+
+AR = ar
+CC = @CC@
+LIBTOOL = @LIBTOOL@
+RANLIB = @RANLIB@
+
+DEFS = -DLOCALEDIR=\"$(localedir)\" -DGNULOCALEDIR=\"$(gnulocaledir)\" \
+-DLOCALE_ALIAS_PATH=\"$(aliaspath)\" @DEFS@
+CPPFLAGS = @CPPFLAGS@
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+
+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
+
+HEADERS = $(COMHDRS) libgettext.h loadinfo.h
+COMHDRS = gettext.h gettextP.h hash-string.h
+SOURCES = $(COMSRCS) intl-compat.c cat-compat.c
+COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \
+finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \
+explodename.c
+OBJECTS = @INTLOBJS@ bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \
+finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \
+explodename.$lo
+CATOBJS = cat-compat.$lo ../po/cat-id-tbl.$lo
+GETTOBJS = intl-compat.$lo
+DISTFILES.common = ChangeLog Makefile.in linux-msg.sed po2tbl.sed.in \
+xopen-msg.sed $(HEADERS) $(SOURCES)
+DISTFILES.normal = VERSION
+DISTFILES.gettext = libintl.glibc intlh.inst.in
+
+.SUFFIXES:
+.SUFFIXES: .c .o .lo
+.c.o:
+ $(COMPILE) $<
+.c.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) $<
+
+INCLUDES = -I. -I$(srcdir)
+
+all: all-@USE_INCLUDED_LIBINTL@
+
+all-yes: libintl.$la intlh.inst
+all-no:
+install-info:
+
+libintl.a: $(OBJECTS)
+ rm -f $@
+ $(AR) cru $@ $(OBJECTS)
+ $(RANLIB) $@
+
+libintl.la: $(OBJECTS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJECTS) \
+ -version-info 1:0 -rpath $(libdir)
+
+../po/cat-id-tbl.$lo: ../po/cat-id-tbl.c $(top_srcdir)/po/$(PACKAGE).pot
+ cd ../po && $(MAKE) cat-id-tbl.$lo
+
+check: all
+
+# This installation goal is only used in GNU gettext. Packages which
+# only use the library should use install instead.
+
+# We must not install the libintl.h/libintl.a files if we are on a
+# system which has the gettext() function in its C library or in a
+# separate library or use the catgets interface. A special case is
+# where configure found a previously installed GNU gettext library.
+# If you want to use the one which comes with this version of the
+# package, you have to use `configure --with-included-gettext'.
+install: install-exec install-data
+install-exec: all
+ if test "$(PACKAGE)" = "gettext" \
+ && test '@INTLOBJS@' = '$(GETTOBJS)'; then \
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $(libdir) $(includedir); \
+ else \
+ $(top_srcdir)/mkinstalldirs $(libdir) $(includedir); \
+ fi; \
+ $(INSTALL_DATA) intlh.inst $(includedir)/libintl.h; \
+ $(INSTALL_DATA) libintl.a $(libdir)/libintl.a; \
+ else \
+ : ; \
+ fi
+install-data: all
+ if test "$(PACKAGE)" = "gettext"; then \
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $(gettextsrcdir); \
+ else \
+ $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
+ fi; \
+ $(INSTALL_DATA) VERSION $(gettextsrcdir)/VERSION; \
+ dists="$(DISTFILES.common)"; \
+ for file in $$dists; do \
+ $(INSTALL_DATA) $(srcdir)/$$file $(gettextsrcdir)/$$file; \
+ done; \
+ else \
+ : ; \
+ fi
+
+# Define this as empty until I found a useful application.
+installcheck:
+
+uninstall:
+ dists="$(DISTFILES.common)"; \
+ for file in $$dists; do \
+ rm -f $(gettextsrcdir)/$$file; \
+ done
+
+info dvi:
+
+$(OBJECTS): config.h libgettext.h
+bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h
+dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h
+
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES)
+ here=`pwd`; cd $(srcdir) && etags -o $$here/TAGS $(HEADERS) $(SOURCES)
+
+id: ID
+
+ID: $(HEADERS) $(SOURCES)
+ here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES)
+
+
+mostlyclean:
+ rm -f *.a *.o *.lo core core.*
+
+clean: mostlyclean
+
+distclean: clean
+ rm -f Makefile ID TAGS po2msg.sed po2tbl.sed libintl.h config.log
+
+maintainer-clean: distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+
+# GNU gettext needs not contain the file `VERSION' but contains some
+# other files which should not be distributed in other packages.
+distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
+dist distdir: Makefile $(DISTFILES)
+ if test "$(PACKAGE)" = gettext; then \
+ additional="$(DISTFILES.gettext)"; \
+ else \
+ additional="$(DISTFILES.normal)"; \
+ fi; \
+ for file in $(DISTFILES.common) $$additional; do \
+ ln $(srcdir)/$$file $(distdir) 2> /dev/null \
+ || cp -p $(srcdir)/$$file $(distdir); \
+ done
+
+dist-libc:
+ tar zcvf intl-glibc.tar.gz $(COMSRCS) $(COMHDRS) libintl.h.glibc
+
+Makefile: Makefile.in config.status
+ CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+# The dependency for intlh.inst is different in gettext and all other
+# packages. Because we cannot you GNU make features we have to solve
+# the problem while rewriting Makefile.in.
+@GT_YES@intlh.inst: intlh.inst.in ../config.status
+@GT_YES@ cd .. \
+@GT_YES@ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
+@GT_YES@ $(SHELL) ./config.status
+@GT_NO@.PHONY: intlh.inst
+@GT_NO@intlh.inst:
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/intl/acconfig.h b/intl/acconfig.h
new file mode 100644
index 00000000000..70f81f80898
--- /dev/null
+++ b/intl/acconfig.h
@@ -0,0 +1,14 @@
+/* Define to 1 if NLS is requested. */
+#undef ENABLE_NLS
+
+/* Define as 1 if you have catgets and don't want to use GNU gettext. */
+#undef HAVE_CATGETS
+
+/* Define as 1 if you have gettext and don't want to use GNU gettext. */
+#undef HAVE_GETTEXT
+
+/* Define as 1 if you have the stpcpy function. */
+#undef HAVE_STPCPY
+
+/* Define if your locale.h file contains LC_MESSAGES. */
+#undef HAVE_LC_MESSAGES
diff --git a/intl/aclocal.m4 b/intl/aclocal.m4
new file mode 100644
index 00000000000..225439f2125
--- /dev/null
+++ b/intl/aclocal.m4
@@ -0,0 +1,387 @@
+dnl aclocal.m4 generated automatically by aclocal 1.3
+
+dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+dnl This Makefile.in is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated. We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+ case " <<$>>CONFIG_HEADERS " in
+ *" <<$>>am_file "*<<)>>
+ echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+ ;;
+ esac
+ am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+
+
+# serial 1
+
+AC_DEFUN(AM_PROG_INSTALL,
+[AC_REQUIRE([AC_PROG_INSTALL])
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+AC_SUBST(INSTALL_SCRIPT)dnl
+])
+
+# This file is derived from `gettext.m4'. The difference is that the
+# included macros assume Cygnus-style source and build trees.
+
+# Macro to add for using GNU gettext.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 3
+
+AC_DEFUN(CY_WITH_NLS,
+ [AC_MSG_CHECKING([whether NLS is requested])
+ dnl Default is enabled NLS
+ AC_ARG_ENABLE(nls,
+ [ --disable-nls do not use Native Language Support],
+ USE_NLS=$enableval, USE_NLS=yes)
+ AC_MSG_RESULT($USE_NLS)
+ AC_SUBST(USE_NLS)
+
+ USE_INCLUDED_LIBINTL=no
+
+ dnl If we use NLS figure out what method
+ if test "$USE_NLS" = "yes"; then
+ AC_DEFINE(ENABLE_NLS)
+ AC_MSG_CHECKING([whether included gettext is requested])
+ AC_ARG_WITH(included-gettext,
+ [ --with-included-gettext use the GNU gettext library included here],
+ nls_cv_force_use_gnu_gettext=$withval,
+ nls_cv_force_use_gnu_gettext=no)
+ AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ dnl User does not insist on using GNU NLS library. Figure out what
+ dnl to use. If gettext or catgets are available (in this order) we
+ dnl use this. Else we have to fall back to GNU NLS library.
+ dnl catgets is only used if permitted by option --with-catgets.
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+ CATOBJEXT=NONE
+
+ AC_CHECK_HEADER(libintl.h,
+ [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
+ [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
+ gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
+
+ if test "$gt_cv_func_gettext_libc" != "yes"; then
+ AC_CHECK_LIB(intl, bindtextdomain,
+ [AC_CACHE_CHECK([for gettext in libintl],
+ gt_cv_func_gettext_libintl,
+ [AC_TRY_LINK([], [return (int) gettext ("")],
+ gt_cv_func_gettext_libintl=yes,
+ gt_cv_func_gettext_libintl=no)])])
+ fi
+
+ if test "$gt_cv_func_gettext_libc" = "yes" \
+ || test "$gt_cv_func_gettext_libintl" = "yes"; then
+ AC_DEFINE(HAVE_GETTEXT)
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
+ if test "$MSGFMT" != "no"; then
+ AC_CHECK_FUNCS(dcgettext)
+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+ AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
+ return _nl_msg_cat_cntr],
+ [CATOBJEXT=.gmo
+ DATADIRNAME=share],
+ [CATOBJEXT=.mo
+ DATADIRNAME=lib])
+ INSTOBJEXT=.mo
+ fi
+ fi
+ ])
+
+ dnl In the standard gettext, we would now check for catgets.
+ dnl However, we never want to use catgets for our releases.
+
+ if test "$CATOBJEXT" = "NONE"; then
+ dnl Neither gettext nor catgets in included in the C library.
+ dnl Fall back on GNU gettext library.
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions used to generate GNU NLS library.
+ INTLOBJS="\$(GETTOBJS)"
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+ AC_SUBST(MSGFMT)
+ USE_INCLUDED_LIBINTL=yes
+ CATOBJEXT=.gmo
+ INSTOBJEXT=.mo
+ DATADIRNAME=share
+ INTLDEPS='$(top_builddir)/../intl/libintl.a'
+ INTLLIBS=$INTLDEPS
+ LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ dnl Test whether we really found GNU xgettext.
+ if test "$XGETTEXT" != ":"; then
+ dnl If it is no GNU xgettext we define it as : so that the
+ dnl Makefiles still can work.
+ if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
+ : ;
+ else
+ AC_MSG_RESULT(
+ [found xgettext programs is not GNU xgettext; ignore it])
+ XGETTEXT=":"
+ fi
+ fi
+
+ # We need to process the po/ directory.
+ POSUB=po
+ else
+ DATADIRNAME=share
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ # If this is used in GNU gettext we have to set USE_NLS to `yes'
+ # because some of the sources are only built for this goal.
+ if test "$PACKAGE" = gettext; then
+ USE_NLS=yes
+ USE_INCLUDED_LIBINTL=yes
+ fi
+
+ dnl These rules are solely for the distribution goal. While doing this
+ dnl we only have to keep exactly one list of the available catalogs
+ dnl in configure.in.
+ for lang in $ALL_LINGUAS; do
+ GMOFILES="$GMOFILES $lang.gmo"
+ POFILES="$POFILES $lang.po"
+ done
+
+ dnl Make all variables we use known to autoconf.
+ AC_SUBST(USE_INCLUDED_LIBINTL)
+ AC_SUBST(CATALOGS)
+ AC_SUBST(CATOBJEXT)
+ AC_SUBST(DATADIRNAME)
+ AC_SUBST(GMOFILES)
+ AC_SUBST(INSTOBJEXT)
+ AC_SUBST(INTLDEPS)
+ AC_SUBST(INTLLIBS)
+ AC_SUBST(INTLOBJS)
+ AC_SUBST(POFILES)
+ AC_SUBST(POSUB)
+ ])
+
+AC_DEFUN(CY_GNU_GETTEXT,
+ [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_PROG_RANLIB])dnl
+ AC_REQUIRE([AC_ISC_POSIX])dnl
+ AC_REQUIRE([AC_HEADER_STDC])dnl
+ AC_REQUIRE([AC_C_CONST])dnl
+ AC_REQUIRE([AC_C_INLINE])dnl
+ AC_REQUIRE([AC_TYPE_OFF_T])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+ AC_REQUIRE([AC_FUNC_MMAP])dnl
+
+ AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h values.h sys/param.h])
+ AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
+__argz_count __argz_stringify __argz_next])
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ AC_CHECK_FUNCS(stpcpy)
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ AC_DEFINE(HAVE_STPCPY)
+ fi
+
+ AM_LC_MESSAGES
+ CY_WITH_NLS
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ AC_MSG_CHECKING(for catalogs to be installed)
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ AC_MSG_RESULT($LINGUAS)
+ fi
+
+ dnl Construct list of names of catalog files to be constructed.
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ dnl The reference to <locale.h> in the installed <libintl.h> file
+ dnl must be resolved because we cannot expect the users of this
+ dnl to define HAVE_LOCALE_H.
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+ AC_SUBST(INCLUDE_LOCALE_H)
+
+ dnl Determine which catalog format we have (if any is needed)
+ dnl For now we know about two different formats:
+ dnl Linux libc-5 and the normal X/Open format
+ if test -f $srcdir/po2tbl.sed.in; then
+ if test "$CATOBJEXT" = ".cat"; then
+ AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
+
+ dnl Transform the SED scripts while copying because some dumb SEDs
+ dnl cannot handle comments.
+ sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
+ fi
+ dnl po2tbl.sed is always needed.
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/po2tbl.sed.in > po2tbl.sed
+ fi
+
+ dnl In the intl/Makefile.in we have a special dependency which makes
+ dnl only sense for gettext. We comment this out for non-gettext
+ dnl packages.
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+ AC_SUBST(GT_NO)
+ AC_SUBST(GT_YES)
+
+ MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
+ AC_SUBST(MKINSTALLDIRS)
+
+ dnl *** For now the libtool support in intl/Makefile is not for real.
+ l=
+ AC_SUBST(l)
+
+ dnl Generate list of files to be processed by xgettext which will
+ dnl be included in po/Makefile. But only do this if the po directory
+ dnl exists in srcdir.
+ if test -d $srcdir/po; then
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ fi
+ ])
+
+# Search path for a program which passes the given test.
+# Ulrich Drepper <drepper@cygnus.com>, 1996.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
+dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
+AC_DEFUN(AM_PATH_PROG_WITH_TEST,
+[# Extract the first word of "$2", so it can be a program name with args.
+set dummy $2; ac_word=[$]2
+AC_MSG_CHECKING([for $ac_word])
+AC_CACHE_VAL(ac_cv_path_$1,
+[case "[$]$1" in
+ /*)
+ ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in ifelse([$5], , $PATH, [$5]); do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if [$3]; then
+ ac_cv_path_$1="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+dnl If no 4th arg is given, leave the cache variable unset,
+dnl so AC_PATH_PROGS will keep looking.
+ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
+])dnl
+ ;;
+esac])dnl
+$1="$ac_cv_path_$1"
+if test -n "[$]$1"; then
+ AC_MSG_RESULT([$]$1)
+else
+ AC_MSG_RESULT(no)
+fi
+AC_SUBST($1)dnl
+])
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+AC_DEFUN(AM_LC_MESSAGES,
+ [if test $ac_cv_header_locale_h = yes; then
+ AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
+ [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+ am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ AC_DEFINE(HAVE_LC_MESSAGES)
+ fi
+ fi])
+
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
new file mode 100644
index 00000000000..9fcb8d9f29b
--- /dev/null
+++ b/intl/bindtextdom.c
@@ -0,0 +1,199 @@
+/* Implementation of the bindtextdomain(3) function
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#else
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# else
+void free ();
+# endif
+#endif
+
+#if defined HAVE_STRING_H || defined _LIBC
+# include <string.h>
+#else
+# include <strings.h>
+# ifndef memcpy
+# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
+# endif
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+#include "gettext.h"
+#include "gettextP.h"
+
+/* @@ end of prolog @@ */
+
+/* Contains the default location of the message catalogs. */
+extern const char _nl_default_dirname[];
+
+/* List with bindings of specific domains. */
+extern struct binding *_nl_domain_bindings;
+
+
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define BINDTEXTDOMAIN __bindtextdomain
+# define strdup(str) __strdup (str)
+#else
+# define BINDTEXTDOMAIN bindtextdomain__
+#endif
+
+/* Specify that the DOMAINNAME message catalog will be found
+ in DIRNAME rather than in the system locale data base. */
+char *
+BINDTEXTDOMAIN (domainname, dirname)
+ const char *domainname;
+ const char *dirname;
+{
+ struct binding *binding;
+
+ /* Some sanity checks. */
+ if (domainname == NULL || domainname[0] == '\0')
+ return NULL;
+
+ for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
+ {
+ int compare = strcmp (domainname, binding->domainname);
+ if (compare == 0)
+ /* We found it! */
+ break;
+ if (compare < 0)
+ {
+ /* It is not in the list. */
+ binding = NULL;
+ break;
+ }
+ }
+
+ if (dirname == NULL)
+ /* The current binding has be to returned. */
+ return binding == NULL ? (char *) _nl_default_dirname : binding->dirname;
+
+ if (binding != NULL)
+ {
+ /* The domain is already bound. If the new value and the old
+ one are equal we simply do nothing. Otherwise replace the
+ old binding. */
+ if (strcmp (dirname, binding->dirname) != 0)
+ {
+ char *new_dirname;
+
+ if (strcmp (dirname, _nl_default_dirname) == 0)
+ new_dirname = (char *) _nl_default_dirname;
+ else
+ {
+#if defined _LIBC || defined HAVE_STRDUP
+ new_dirname = strdup (dirname);
+ if (new_dirname == NULL)
+ return NULL;
+#else
+ size_t len = strlen (dirname) + 1;
+ new_dirname = (char *) malloc (len);
+ if (new_dirname == NULL)
+ return NULL;
+
+ memcpy (new_dirname, dirname, len);
+#endif
+ }
+
+ if (binding->dirname != _nl_default_dirname)
+ free (binding->dirname);
+
+ binding->dirname = new_dirname;
+ }
+ }
+ else
+ {
+ /* We have to create a new binding. */
+ size_t len;
+ struct binding *new_binding =
+ (struct binding *) malloc (sizeof (*new_binding));
+
+ if (new_binding == NULL)
+ return NULL;
+
+#if defined _LIBC || defined HAVE_STRDUP
+ new_binding->domainname = strdup (domainname);
+ if (new_binding->domainname == NULL)
+ return NULL;
+#else
+ len = strlen (domainname) + 1;
+ new_binding->domainname = (char *) malloc (len);
+ if (new_binding->domainname == NULL)
+ return NULL;
+ memcpy (new_binding->domainname, domainname, len);
+#endif
+
+ if (strcmp (dirname, _nl_default_dirname) == 0)
+ new_binding->dirname = (char *) _nl_default_dirname;
+ else
+ {
+#if defined _LIBC || defined HAVE_STRDUP
+ new_binding->dirname = strdup (dirname);
+ if (new_binding->dirname == NULL)
+ return NULL;
+#else
+ len = strlen (dirname) + 1;
+ new_binding->dirname = (char *) malloc (len);
+ if (new_binding->dirname == NULL)
+ return NULL;
+ memcpy (new_binding->dirname, dirname, len);
+#endif
+ }
+
+ /* Now enqueue it. */
+ if (_nl_domain_bindings == NULL
+ || strcmp (domainname, _nl_domain_bindings->domainname) < 0)
+ {
+ new_binding->next = _nl_domain_bindings;
+ _nl_domain_bindings = new_binding;
+ }
+ else
+ {
+ binding = _nl_domain_bindings;
+ while (binding->next != NULL
+ && strcmp (domainname, binding->next->domainname) > 0)
+ binding = binding->next;
+
+ new_binding->next = binding->next;
+ binding->next = new_binding;
+ }
+
+ binding = new_binding;
+ }
+
+ return binding->dirname;
+}
+
+#ifdef _LIBC
+/* Alias for function name in GNU C Library. */
+weak_alias (__bindtextdomain, bindtextdomain);
+#endif
diff --git a/intl/cat-compat.c b/intl/cat-compat.c
new file mode 100644
index 00000000000..867d901b8ff
--- /dev/null
+++ b/intl/cat-compat.c
@@ -0,0 +1,262 @@
+/* Compatibility code for gettext-using-catgets interface.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <string.h>
+#else
+char *getenv ();
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# endif
+#endif
+
+#ifdef HAVE_NL_TYPES_H
+# include <nl_types.h>
+#endif
+
+#include "libgettext.h"
+
+/* @@ end of prolog @@ */
+
+/* XPG3 defines the result of `setlocale (category, NULL)' as:
+ ``Directs `setlocale()' to query `category' and return the current
+ setting of `local'.''
+ However it does not specify the exact format. And even worse: POSIX
+ defines this not at all. So we can use this feature only on selected
+ system (e.g. those using GNU C Library). */
+#ifdef _LIBC
+# define HAVE_LOCALE_NULL
+#endif
+
+/* The catalog descriptor. */
+static nl_catd catalog = (nl_catd) -1;
+
+/* Name of the default catalog. */
+static const char default_catalog_name[] = "messages";
+
+/* Name of currently used catalog. */
+static const char *catalog_name = default_catalog_name;
+
+/* Get ID for given string. If not found return -1. */
+static int msg_to_cat_id PARAMS ((const char *msg));
+
+/* Substitution for systems lacking this function in their C library. */
+#if !_LIBC && !HAVE_STPCPY
+static char *stpcpy PARAMS ((char *dest, const char *src));
+#endif
+
+
+/* Set currently used domain/catalog. */
+char *
+textdomain (domainname)
+ const char *domainname;
+{
+ nl_catd new_catalog;
+ char *new_name;
+ size_t new_name_len;
+ char *lang;
+
+#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES \
+ && defined HAVE_LOCALE_NULL
+ lang = setlocale (LC_MESSAGES, NULL);
+#else
+ lang = getenv ("LC_ALL");
+ if (lang == NULL || lang[0] == '\0')
+ {
+ lang = getenv ("LC_MESSAGES");
+ if (lang == NULL || lang[0] == '\0')
+ lang = getenv ("LANG");
+ }
+#endif
+ if (lang == NULL || lang[0] == '\0')
+ lang = "C";
+
+ /* See whether name of currently used domain is asked. */
+ if (domainname == NULL)
+ return (char *) catalog_name;
+
+ if (domainname[0] == '\0')
+ domainname = default_catalog_name;
+
+ /* Compute length of added path element. */
+ new_name_len = sizeof (LOCALEDIR) - 1 + 1 + strlen (lang)
+ + sizeof ("/LC_MESSAGES/") - 1 + sizeof (PACKAGE) - 1
+ + sizeof (".cat");
+
+ new_name = (char *) malloc (new_name_len);
+ if (new_name == NULL)
+ return NULL;
+
+ strcpy (new_name, PACKAGE);
+ new_catalog = catopen (new_name, 0);
+
+ if (new_catalog == (nl_catd) -1)
+ {
+ /* NLSPATH search didn't work, try absolute path */
+ sprintf (new_name, "%s/%s/LC_MESSAGES/%s.cat", LOCALEDIR, lang,
+ PACKAGE);
+ new_catalog = catopen (new_name, 0);
+
+ if (new_catalog == (nl_catd) -1)
+ {
+ free (new_name);
+ return (char *) catalog_name;
+ }
+ }
+
+ /* Close old catalog. */
+ if (catalog != (nl_catd) -1)
+ catclose (catalog);
+ if (catalog_name != default_catalog_name)
+ free ((char *) catalog_name);
+
+ catalog = new_catalog;
+ catalog_name = new_name;
+
+ return (char *) catalog_name;
+}
+
+char *
+bindtextdomain (domainname, dirname)
+ const char *domainname;
+ const char *dirname;
+{
+#if HAVE_SETENV || HAVE_PUTENV
+ char *old_val, *new_val, *cp;
+ size_t new_val_len;
+
+ /* This does not make much sense here but to be compatible do it. */
+ if (domainname == NULL)
+ return NULL;
+
+ /* Compute length of added path element. If we use setenv we don't need
+ the first byts for NLSPATH=, but why complicate the code for this
+ peanuts. */
+ new_val_len = sizeof ("NLSPATH=") - 1 + strlen (dirname)
+ + sizeof ("/%L/LC_MESSAGES/%N.cat");
+
+ old_val = getenv ("NLSPATH");
+ if (old_val == NULL || old_val[0] == '\0')
+ {
+ old_val = NULL;
+ new_val_len += 1 + sizeof (LOCALEDIR) - 1
+ + sizeof ("/%L/LC_MESSAGES/%N.cat");
+ }
+ else
+ new_val_len += strlen (old_val);
+
+ new_val = (char *) malloc (new_val_len);
+ if (new_val == NULL)
+ return NULL;
+
+# if HAVE_SETENV
+ cp = new_val;
+# else
+ cp = stpcpy (new_val, "NLSPATH=");
+# endif
+
+ cp = stpcpy (cp, dirname);
+ cp = stpcpy (cp, "/%L/LC_MESSAGES/%N.cat:");
+
+ if (old_val == NULL)
+ {
+# if __STDC__
+ stpcpy (cp, LOCALEDIR "/%L/LC_MESSAGES/%N.cat");
+# else
+
+ cp = stpcpy (cp, LOCALEDIR);
+ stpcpy (cp, "/%L/LC_MESSAGES/%N.cat");
+# endif
+ }
+ else
+ stpcpy (cp, old_val);
+
+# if HAVE_SETENV
+ setenv ("NLSPATH", new_val, 1);
+ free (new_val);
+# else
+ putenv (new_val);
+ /* Do *not* free the environment entry we just entered. It is used
+ from now on. */
+# endif
+
+#endif
+
+ return (char *) domainname;
+}
+
+#undef gettext
+char *
+gettext (msg)
+ const char *msg;
+{
+ int msgid;
+
+ if (msg == NULL || catalog == (nl_catd) -1)
+ return (char *) msg;
+
+ /* Get the message from the catalog. We always use set number 1.
+ The message ID is computed by the function `msg_to_cat_id'
+ which works on the table generated by `po-to-tbl'. */
+ msgid = msg_to_cat_id (msg);
+ if (msgid == -1)
+ return (char *) msg;
+
+ return catgets (catalog, 1, msgid, (char *) msg);
+}
+
+/* Look through the table `_msg_tbl' which has `_msg_tbl_length' entries
+ for the one equal to msg. If it is found return the ID. In case when
+ the string is not found return -1. */
+static int
+msg_to_cat_id (msg)
+ const char *msg;
+{
+ int cnt;
+
+ for (cnt = 0; cnt < _msg_tbl_length; ++cnt)
+ if (strcmp (msg, _msg_tbl[cnt]._msg) == 0)
+ return _msg_tbl[cnt]._msg_number;
+
+ return -1;
+}
+
+
+/* @@ begin of epilog @@ */
+
+/* We don't want libintl.a to depend on any other library. So we
+ avoid the non-standard function stpcpy. In GNU C Library this
+ function is available, though. Also allow the symbol HAVE_STPCPY
+ to be defined. */
+#if !_LIBC && !HAVE_STPCPY
+static char *
+stpcpy (dest, src)
+ char *dest;
+ const char *src;
+{
+ while ((*dest++ = *src++) != '\0')
+ /* Do nothing. */ ;
+ return dest - 1;
+}
+#endif
diff --git a/intl/config.in b/intl/config.in
new file mode 100644
index 00000000000..8a9049b80de
--- /dev/null
+++ b/intl/config.in
@@ -0,0 +1,128 @@
+/* config.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if using alloca.c. */
+#undef C_ALLOCA
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+ This function is required for alloca.c support on those systems. */
+#undef CRAY_STACKSEG_END
+
+/* Define if you have alloca, as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+#undef HAVE_ALLOCA_H
+
+/* Define if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#undef off_t
+
+/* Define if you need to in order for stat and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#undef STACK_DIRECTION
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if NLS is requested. */
+#undef ENABLE_NLS
+
+/* Define as 1 if you have catgets and don't want to use GNU gettext. */
+#undef HAVE_CATGETS
+
+/* Define as 1 if you have gettext and don't want to use GNU gettext. */
+#undef HAVE_GETTEXT
+
+/* Define as 1 if you have the stpcpy function. */
+#undef HAVE_STPCPY
+
+/* Define if your locale.h file contains LC_MESSAGES. */
+#undef HAVE_LC_MESSAGES
+
+/* Define if you have the __argz_count function. */
+#undef HAVE___ARGZ_COUNT
+
+/* Define if you have the __argz_next function. */
+#undef HAVE___ARGZ_NEXT
+
+/* Define if you have the __argz_stringify function. */
+#undef HAVE___ARGZ_STRINGIFY
+
+/* Define if you have the dcgettext function. */
+#undef HAVE_DCGETTEXT
+
+/* Define if you have the getcwd function. */
+#undef HAVE_GETCWD
+
+/* Define if you have the getpagesize function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the munmap function. */
+#undef HAVE_MUNMAP
+
+/* Define if you have the putenv function. */
+#undef HAVE_PUTENV
+
+/* Define if you have the setenv function. */
+#undef HAVE_SETENV
+
+/* Define if you have the setlocale function. */
+#undef HAVE_SETLOCALE
+
+/* Define if you have the stpcpy function. */
+#undef HAVE_STPCPY
+
+/* Define if you have the strcasecmp function. */
+#undef HAVE_STRCASECMP
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the <argz.h> header file. */
+#undef HAVE_ARGZ_H
+
+/* Define if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define if you have the <nl_types.h> header file. */
+#undef HAVE_NL_TYPES_H
+
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Define if you have the i library (-li). */
+#undef HAVE_LIBI
diff --git a/intl/configure b/intl/configure
new file mode 100755
index 00000000000..341eea019ae
--- /dev/null
+++ b/intl/configure
@@ -0,0 +1,2950 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.12.1
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --disable-nls do not use Native Language Support"
+ac_help="$ac_help
+ --with-included-gettext use the GNU gettext library included here"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.12.1"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=dgettext.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:562: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:616: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 631 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:637: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 648 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:654: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:677: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:706: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:735: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ ac_prog_rejected=no
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:783: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext <<EOF
+#line 793 "configure"
+#include "confdefs.h"
+main(){return(0);}
+EOF
+if { (eval echo configure:797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:817: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:822: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:831: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:846: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ elif test $ac_cv_prog_cc_g = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-O2"
+ fi
+else
+ GCC=
+ test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:876: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:903: checking for POSIXized ISC" >&5
+if test -d /etc/conf/kconfig.d &&
+ grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+ echo "$ac_t""yes" 1>&6
+ ISC=yes # If later tests want to check for ISC.
+ cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+ if test "$GCC" = yes; then
+ CC="$CC -posix"
+ else
+ CC="$CC -Xp"
+ fi
+else
+ echo "$ac_t""no" 1>&6
+ ISC=
+fi
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:924: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 929 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:937: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 954 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 972 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 993 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:1028: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1033 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1082: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:1103: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat > conftest.$ac_ext <<EOF
+#line 1110 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:1117: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+ inline | yes) ;;
+ no) cat >> confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+ *) cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+echo "configure:1143: checking for off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1148 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+echo "configure:1176: checking for size_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1181 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments. Useless!
+echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
+echo "configure:1211: checking for working alloca.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1216 "configure"
+#include "confdefs.h"
+#include <alloca.h>
+int main() {
+char *p = alloca(2 * sizeof(int));
+; return 0; }
+EOF
+if { (eval echo configure:1223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ ac_cv_header_alloca_h=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_alloca_h=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
+if test $ac_cv_header_alloca_h = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA_H 1
+EOF
+
+fi
+
+echo $ac_n "checking for alloca""... $ac_c" 1>&6
+echo "configure:1244: checking for alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1249 "configure"
+#include "confdefs.h"
+
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+int main() {
+char *p = (char *) alloca(1);
+; return 0; }
+EOF
+if { (eval echo configure:1272: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ ac_cv_func_alloca_works=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_func_alloca_works=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_func_alloca_works" 1>&6
+if test $ac_cv_func_alloca_works = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA 1
+EOF
+
+fi
+
+if test $ac_cv_func_alloca_works = no; then
+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+ # that cause trouble. Some versions do not even contain alloca or
+ # contain a buggy version. If you still want to use their alloca,
+ # use ar to extract alloca.o from them instead of compiling alloca.c.
+ ALLOCA=alloca.o
+ cat >> confdefs.h <<\EOF
+#define C_ALLOCA 1
+EOF
+
+
+echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+echo "configure:1304: checking whether alloca needs Cray hooks" >&5
+if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1309 "configure"
+#include "confdefs.h"
+#if defined(CRAY) && ! defined(CRAY2)
+webecray
+#else
+wenotbecray
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "webecray" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_os_cray=yes
+else
+ rm -rf conftest*
+ ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_os_cray" 1>&6
+if test $ac_cv_os_cray = yes; then
+for ac_func in _getb67 GETB67 getb67; do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1334: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1339 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<EOF
+#define CRAY_STACKSEG_END $ac_func
+EOF
+
+ break
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+done
+fi
+
+echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
+echo "configure:1389: checking stack direction for C alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_c_stack_direction=0
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1397 "configure"
+#include "confdefs.h"
+find_stack_direction ()
+{
+ static char *addr = 0;
+ auto char dummy;
+ if (addr == 0)
+ {
+ addr = &dummy;
+ return find_stack_direction ();
+ }
+ else
+ return (&dummy > addr) ? 1 : -1;
+}
+main ()
+{
+ exit (find_stack_direction() < 0);
+}
+EOF
+if { (eval echo configure:1416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_stack_direction=1
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_stack_direction=-1
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_c_stack_direction" 1>&6
+cat >> confdefs.h <<EOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+EOF
+
+fi
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1441: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1446 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1451: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_func in getpagesize
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1480: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1485 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for working mmap""... $ac_c" 1>&6
+echo "configure:1533: checking for working mmap" >&5
+if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1541 "configure"
+#include "confdefs.h"
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the filesystem buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propogated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+#ifdef __cplusplus
+extern "C" { void *malloc(unsigned); }
+#else
+char *malloc();
+#endif
+
+int
+main()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmap", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file at a fixed address which
+ * already has something else allocated at it. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmap", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ data2 = malloc(2 * pagesize);
+ if (!data2)
+ exit(1);
+ data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ /*
+ * Finally, make sure that changes to the mapped area
+ * do not percolate back to the file as seen by read().
+ * (This is a bug on some variants of i386 svr4.0.)
+ */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit(1);
+ close(fd);
+ unlink("conftestmmap");
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:1681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_MMAP 1
+EOF
+
+fi
+
+
+ for ac_hdr in argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h values.h sys/param.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1709: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1714 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in getcwd munmap putenv setenv setlocale strchr strcasecmp \
+__argz_count __argz_stringify __argz_next
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1749: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1754 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ for ac_func in stpcpy
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1806: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1811 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_STPCPY 1
+EOF
+
+ fi
+
+ if test $ac_cv_header_locale_h = yes; then
+ echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
+echo "configure:1868: checking for LC_MESSAGES" >&5
+if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1873 "configure"
+#include "confdefs.h"
+#include <locale.h>
+int main() {
+return LC_MESSAGES
+; return 0; }
+EOF
+if { (eval echo configure:1880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ am_cv_val_LC_MESSAGES=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ am_cv_val_LC_MESSAGES=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$am_cv_val_LC_MESSAGES" 1>&6
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LC_MESSAGES 1
+EOF
+
+ fi
+ fi
+ echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6
+echo "configure:1901: checking whether NLS is requested" >&5
+ # Check whether --enable-nls or --disable-nls was given.
+if test "${enable_nls+set}" = set; then
+ enableval="$enable_nls"
+ USE_NLS=$enableval
+else
+ USE_NLS=yes
+fi
+
+ echo "$ac_t""$USE_NLS" 1>&6
+
+
+ USE_INCLUDED_LIBINTL=no
+
+ if test "$USE_NLS" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define ENABLE_NLS 1
+EOF
+
+ echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6
+echo "configure:1921: checking whether included gettext is requested" >&5
+ # Check whether --with-included-gettext or --without-included-gettext was given.
+if test "${with_included_gettext+set}" = set; then
+ withval="$with_included_gettext"
+ nls_cv_force_use_gnu_gettext=$withval
+else
+ nls_cv_force_use_gnu_gettext=no
+fi
+
+ echo "$ac_t""$nls_cv_force_use_gnu_gettext" 1>&6
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+ CATOBJEXT=NONE
+
+ ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for libintl.h""... $ac_c" 1>&6
+echo "configure:1940: checking for libintl.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1945 "configure"
+#include "confdefs.h"
+#include <libintl.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1950: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6
+echo "configure:1967: checking for gettext in libc" >&5
+if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1972 "configure"
+#include "confdefs.h"
+#include <libintl.h>
+int main() {
+return (int) gettext ("")
+; return 0; }
+EOF
+if { (eval echo configure:1979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ gt_cv_func_gettext_libc=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ gt_cv_func_gettext_libc=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6
+
+ if test "$gt_cv_func_gettext_libc" != "yes"; then
+ echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
+echo "configure:1995: checking for bindtextdomain in -lintl" >&5
+ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lintl $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2003 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char bindtextdomain();
+
+int main() {
+bindtextdomain()
+; return 0; }
+EOF
+if { (eval echo configure:2014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
+echo "configure:2030: checking for gettext in libintl" >&5
+if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2035 "configure"
+#include "confdefs.h"
+
+int main() {
+return (int) gettext ("")
+; return 0; }
+EOF
+if { (eval echo configure:2042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ gt_cv_func_gettext_libintl=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ gt_cv_func_gettext_libintl=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$gt_cv_func_gettext_libintl" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ fi
+
+ if test "$gt_cv_func_gettext_libc" = "yes" \
+ || test "$gt_cv_func_gettext_libintl" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_GETTEXT 1
+EOF
+
+ # Extract the first word of "msgfmt", so it can be a program name with args.
+set dummy msgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2070: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$MSGFMT" in
+ /*)
+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then
+ ac_cv_path_MSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="no"
+ ;;
+esac
+fi
+MSGFMT="$ac_cv_path_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ if test "$MSGFMT" != "no"; then
+ for ac_func in dcgettext
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2104: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2109 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ # Extract the first word of "gmsgfmt", so it can be a program name with args.
+set dummy gmsgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2159: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GMSGFMT" in
+ /*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GMSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"
+ ;;
+esac
+fi
+GMSGFMT="$ac_cv_path_GMSGFMT"
+if test -n "$GMSGFMT"; then
+ echo "$ac_t""$GMSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "xgettext", so it can be a program name with args.
+set dummy xgettext; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2194: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$XGETTEXT" in
+ /*)
+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then
+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"
+ ;;
+esac
+fi
+XGETTEXT="$ac_cv_path_XGETTEXT"
+if test -n "$XGETTEXT"; then
+ echo "$ac_t""$XGETTEXT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ cat > conftest.$ac_ext <<EOF
+#line 2226 "configure"
+#include "confdefs.h"
+
+int main() {
+extern int _nl_msg_cat_cntr;
+ return _nl_msg_cat_cntr
+; return 0; }
+EOF
+if { (eval echo configure:2234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ CATOBJEXT=.gmo
+ DATADIRNAME=share
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CATOBJEXT=.mo
+ DATADIRNAME=lib
+fi
+rm -f conftest*
+ INSTOBJEXT=.mo
+ fi
+ fi
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+ if test "$CATOBJEXT" = "NONE"; then
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ INTLOBJS="\$(GETTOBJS)"
+ # Extract the first word of "msgfmt", so it can be a program name with args.
+set dummy msgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2266: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$MSGFMT" in
+ /*)
+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then
+ ac_cv_path_MSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="msgfmt"
+ ;;
+esac
+fi
+MSGFMT="$ac_cv_path_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "gmsgfmt", so it can be a program name with args.
+set dummy gmsgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2300: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GMSGFMT" in
+ /*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GMSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"
+ ;;
+esac
+fi
+GMSGFMT="$ac_cv_path_GMSGFMT"
+if test -n "$GMSGFMT"; then
+ echo "$ac_t""$GMSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "xgettext", so it can be a program name with args.
+set dummy xgettext; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2335: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$XGETTEXT" in
+ /*)
+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then
+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"
+ ;;
+esac
+fi
+XGETTEXT="$ac_cv_path_XGETTEXT"
+if test -n "$XGETTEXT"; then
+ echo "$ac_t""$XGETTEXT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+ USE_INCLUDED_LIBINTL=yes
+ CATOBJEXT=.gmo
+ INSTOBJEXT=.mo
+ DATADIRNAME=share
+ INTLDEPS='$(top_builddir)/../intl/libintl.a'
+ INTLLIBS=$INTLDEPS
+ LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ if test "$XGETTEXT" != ":"; then
+ if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
+ : ;
+ else
+ echo "$ac_t""found xgettext programs is not GNU xgettext; ignore it" 1>&6
+ XGETTEXT=":"
+ fi
+ fi
+
+ # We need to process the po/ directory.
+ POSUB=po
+ else
+ DATADIRNAME=share
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ # If this is used in GNU gettext we have to set USE_NLS to `yes'
+ # because some of the sources are only built for this goal.
+ if test "$PACKAGE" = gettext; then
+ USE_NLS=yes
+ USE_INCLUDED_LIBINTL=yes
+ fi
+
+ for lang in $ALL_LINGUAS; do
+ GMOFILES="$GMOFILES $lang.gmo"
+ POFILES="$POFILES $lang.po"
+ done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
+echo "configure:2425: checking for catalogs to be installed" >&5
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ echo "$ac_t""$LINGUAS" 1>&6
+ fi
+
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+
+
+ if test -f $srcdir/po2tbl.sed.in; then
+ if test "$CATOBJEXT" = ".cat"; then
+ ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
+echo "configure:2453: checking for linux/version.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2458 "configure"
+#include "confdefs.h"
+#include <linux/version.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ msgformat=linux
+else
+ echo "$ac_t""no" 1>&6
+msgformat=xopen
+fi
+
+
+ sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
+ fi
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/po2tbl.sed.in > po2tbl.sed
+ fi
+
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+
+
+
+ MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
+
+
+ l=
+
+
+ if test -d $srcdir/po; then
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ fi
+
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set) 2>&1 | grep ac_space` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.12.1"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@CC@%$CC%g
+s%@RANLIB@%$RANLIB%g
+s%@CPP@%$CPP%g
+s%@ALLOCA@%$ALLOCA%g
+s%@USE_NLS@%$USE_NLS%g
+s%@MSGFMT@%$MSGFMT%g
+s%@GMSGFMT@%$GMSGFMT%g
+s%@XGETTEXT@%$XGETTEXT%g
+s%@USE_INCLUDED_LIBINTL@%$USE_INCLUDED_LIBINTL%g
+s%@CATALOGS@%$CATALOGS%g
+s%@CATOBJEXT@%$CATOBJEXT%g
+s%@DATADIRNAME@%$DATADIRNAME%g
+s%@GMOFILES@%$GMOFILES%g
+s%@INSTOBJEXT@%$INSTOBJEXT%g
+s%@INTLDEPS@%$INTLDEPS%g
+s%@INTLLIBS@%$INTLLIBS%g
+s%@INTLOBJS@%$INTLOBJS%g
+s%@POFILES@%$POFILES%g
+s%@POSUB@%$POSUB%g
+s%@INCLUDE_LOCALE_H@%$INCLUDE_LOCALE_H%g
+s%@GT_NO@%$GT_NO%g
+s%@GT_YES@%$GT_YES%g
+s%@MKINSTALLDIRS@%$MKINSTALLDIRS%g
+s%@l@%$l%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h:config.in"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+ac_sources="$nls_cv_header_libgt"
+ac_dests="$nls_cv_header_intl"
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+srcdir=$ac_given_srcdir
+while test -n "$ac_sources"; do
+ set $ac_dests; ac_dest=$1; shift; ac_dests=$*
+ set $ac_sources; ac_source=$1; shift; ac_sources=$*
+
+ echo "linking $srcdir/$ac_source to $ac_dest"
+
+ if test ! -r $srcdir/$ac_source; then
+ { echo "configure: error: $srcdir/$ac_source: File not found" 1>&2; exit 1; }
+ fi
+ rm -f $ac_dest
+
+ # Make relative symlinks.
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dest_dir=`echo $ac_dest|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then
+ # The dest file is in a subdirectory.
+ test ! -d "$ac_dest_dir" && mkdir "$ac_dest_dir"
+ ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dest_dir_suffix.
+ ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dest_dir_suffix= ac_dots=
+ fi
+
+ case "$srcdir" in
+ [/$]*) ac_rel_source="$srcdir/$ac_source" ;;
+ *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;;
+ esac
+
+ # Make a symlink if possible; otherwise try a hard link.
+ if ln -s $ac_rel_source $ac_dest 2>/dev/null ||
+ ln $srcdir/$ac_source $ac_dest; then :
+ else
+ { echo "configure: error: can not link $ac_dest to $srcdir/$ac_source" 1>&2; exit 1; }
+ fi
+done
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/intl/configure.in b/intl/configure.in
new file mode 100644
index 00000000000..4ba9c244efa
--- /dev/null
+++ b/intl/configure.in
@@ -0,0 +1,10 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(dgettext.c)
+AM_CONFIG_HEADER(config.h:config.in)
+
+AM_PROG_INSTALL
+CY_GNU_GETTEXT
+AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
+
+AC_OUTPUT(Makefile)
diff --git a/intl/dcgettext.c b/intl/dcgettext.c
new file mode 100644
index 00000000000..a316bfd1086
--- /dev/null
+++ b/intl/dcgettext.c
@@ -0,0 +1,593 @@
+/* Implementation of the dcgettext(3) function
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+# define HAVE_ALLOCA 1
+#else
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+#ifndef __set_errno
+# define __set_errno(val) errno = (val)
+#endif
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#else
+char *getenv ();
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# else
+void free ();
+# endif
+#endif
+
+#if defined HAVE_STRING_H || defined _LIBC
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+# endif
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+#if !HAVE_STRCHR && !defined _LIBC
+# ifndef strchr
+# define strchr index
+# endif
+#endif
+
+#if defined HAVE_UNISTD_H || defined _LIBC
+# include <unistd.h>
+#endif
+
+#include "gettext.h"
+#include "gettextP.h"
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+#include "hash-string.h"
+
+/* @@ end of prolog @@ */
+
+#ifdef _LIBC
+/* Rename the non ANSI C functions. This is required by the standard
+ because some ANSI C functions will require linking with this object
+ file and the name space must not be polluted. */
+# define getcwd __getcwd
+# define stpcpy __stpcpy
+#else
+# if !defined HAVE_GETCWD
+char *getwd ();
+# define getcwd(buf, max) getwd (buf)
+# else
+char *getcwd ();
+# endif
+# ifndef HAVE_STPCPY
+static char *stpcpy PARAMS ((char *dest, const char *src));
+# endif
+#endif
+
+/* Amount to increase buffer size by in each try. */
+#define PATH_INCR 32
+
+/* The following is from pathmax.h. */
+/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
+ PATH_MAX but might cause redefinition warnings when sys/param.h is
+ later included (as on MORE/BSD 4.3). */
+#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__))
+# include <limits.h>
+#endif
+
+#ifndef _POSIX_PATH_MAX
+# define _POSIX_PATH_MAX 255
+#endif
+
+#if !defined(PATH_MAX) && defined(_PC_PATH_MAX)
+# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))
+#endif
+
+/* Don't include sys/param.h if it already has been. */
+#if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN)
+# include <sys/param.h>
+#endif
+
+#if !defined(PATH_MAX) && defined(MAXPATHLEN)
+# define PATH_MAX MAXPATHLEN
+#endif
+
+#ifndef PATH_MAX
+# define PATH_MAX _POSIX_PATH_MAX
+#endif
+
+/* XPG3 defines the result of `setlocale (category, NULL)' as:
+ ``Directs `setlocale()' to query `category' and return the current
+ setting of `local'.''
+ However it does not specify the exact format. And even worse: POSIX
+ defines this not at all. So we can use this feature only on selected
+ system (e.g. those using GNU C Library). */
+#ifdef _LIBC
+# define HAVE_LOCALE_NULL
+#endif
+
+/* Name of the default domain used for gettext(3) prior any call to
+ textdomain(3). The default value for this is "messages". */
+const char _nl_default_default_domain[] = "messages";
+
+/* Value used as the default domain for gettext(3). */
+const char *_nl_current_default_domain = _nl_default_default_domain;
+
+/* Contains the default location of the message catalogs. */
+const char _nl_default_dirname[] = GNULOCALEDIR;
+
+/* List with bindings of specific domains created by bindtextdomain()
+ calls. */
+struct binding *_nl_domain_bindings;
+
+/* Prototypes for local functions. */
+static char *find_msg PARAMS ((struct loaded_l10nfile *domain_file,
+ const char *msgid));
+static const char *category_to_name PARAMS ((int category));
+static const char *guess_category_value PARAMS ((int category,
+ const char *categoryname));
+
+
+/* For those loosing systems which don't have `alloca' we have to add
+ some additional code emulating it. */
+#ifdef HAVE_ALLOCA
+/* Nothing has to be done. */
+# define ADD_BLOCK(list, address) /* nothing */
+# define FREE_BLOCKS(list) /* nothing */
+#else
+struct block_list
+{
+ void *address;
+ struct block_list *next;
+};
+# define ADD_BLOCK(list, addr) \
+ do { \
+ struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \
+ /* If we cannot get a free block we cannot add the new element to \
+ the list. */ \
+ if (newp != NULL) { \
+ newp->address = (addr); \
+ newp->next = (list); \
+ (list) = newp; \
+ } \
+ } while (0)
+# define FREE_BLOCKS(list) \
+ do { \
+ while (list != NULL) { \
+ struct block_list *old = list; \
+ list = list->next; \
+ free (old); \
+ } \
+ } while (0)
+# undef alloca
+# define alloca(size) (malloc (size))
+#endif /* have alloca */
+
+
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define DCGETTEXT __dcgettext
+#else
+# define DCGETTEXT dcgettext__
+#endif
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
+ locale. */
+char *
+DCGETTEXT (domainname, msgid, category)
+ const char *domainname;
+ const char *msgid;
+ int category;
+{
+#ifndef HAVE_ALLOCA
+ struct block_list *block_list = NULL;
+#endif
+ struct loaded_l10nfile *domain;
+ struct binding *binding;
+ const char *categoryname;
+ const char *categoryvalue;
+ char *dirname, *xdomainname;
+ char *single_locale;
+ char *retval;
+ int saved_errno = errno;
+
+ /* If no real MSGID is given return NULL. */
+ if (msgid == NULL)
+ return NULL;
+
+ /* If DOMAINNAME is NULL, we are interested in the default domain. If
+ CATEGORY is not LC_MESSAGES this might not make much sense but the
+ defintion left this undefined. */
+ if (domainname == NULL)
+ domainname = _nl_current_default_domain;
+
+ /* First find matching binding. */
+ for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
+ {
+ int compare = strcmp (domainname, binding->domainname);
+ if (compare == 0)
+ /* We found it! */
+ break;
+ if (compare < 0)
+ {
+ /* It is not in the list. */
+ binding = NULL;
+ break;
+ }
+ }
+
+ if (binding == NULL)
+ dirname = (char *) _nl_default_dirname;
+ else if (binding->dirname[0] == '/')
+ dirname = binding->dirname;
+ else
+ {
+ /* We have a relative path. Make it absolute now. */
+ size_t dirname_len = strlen (binding->dirname) + 1;
+ size_t path_max;
+ char *ret;
+
+ path_max = (unsigned) PATH_MAX;
+ path_max += 2; /* The getcwd docs say to do this. */
+
+ dirname = (char *) alloca (path_max + dirname_len);
+ ADD_BLOCK (block_list, dirname);
+
+ __set_errno (0);
+ while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE)
+ {
+ path_max += PATH_INCR;
+ dirname = (char *) alloca (path_max + dirname_len);
+ ADD_BLOCK (block_list, dirname);
+ __set_errno (0);
+ }
+
+ if (ret == NULL)
+ {
+ /* We cannot get the current working directory. Don't signal an
+ error but simply return the default string. */
+ FREE_BLOCKS (block_list);
+ __set_errno (saved_errno);
+ return (char *) msgid;
+ }
+
+ stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname);
+ }
+
+ /* Now determine the symbolic name of CATEGORY and its value. */
+ categoryname = category_to_name (category);
+ categoryvalue = guess_category_value (category, categoryname);
+
+ xdomainname = (char *) alloca (strlen (categoryname)
+ + strlen (domainname) + 5);
+ ADD_BLOCK (block_list, xdomainname);
+
+ stpcpy (stpcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
+ domainname),
+ ".mo");
+
+ /* Creating working area. */
+ single_locale = (char *) alloca (strlen (categoryvalue) + 1);
+ ADD_BLOCK (block_list, single_locale);
+
+
+ /* Search for the given string. This is a loop because we perhaps
+ got an ordered list of languages to consider for th translation. */
+ while (1)
+ {
+ /* Make CATEGORYVALUE point to the next element of the list. */
+ while (categoryvalue[0] != '\0' && categoryvalue[0] == ':')
+ ++categoryvalue;
+ if (categoryvalue[0] == '\0')
+ {
+ /* The whole contents of CATEGORYVALUE has been searched but
+ no valid entry has been found. We solve this situation
+ by implicitly appending a "C" entry, i.e. no translation
+ will take place. */
+ single_locale[0] = 'C';
+ single_locale[1] = '\0';
+ }
+ else
+ {
+ char *cp = single_locale;
+ while (categoryvalue[0] != '\0' && categoryvalue[0] != ':')
+ *cp++ = *categoryvalue++;
+ *cp = '\0';
+ }
+
+ /* If the current locale value is C (or POSIX) we don't load a
+ domain. Return the MSGID. */
+ if (strcmp (single_locale, "C") == 0
+ || strcmp (single_locale, "POSIX") == 0)
+ {
+ FREE_BLOCKS (block_list);
+ __set_errno (saved_errno);
+ return (char *) msgid;
+ }
+
+
+ /* Find structure describing the message catalog matching the
+ DOMAINNAME and CATEGORY. */
+ domain = _nl_find_domain (dirname, single_locale, xdomainname);
+
+ if (domain != NULL)
+ {
+ retval = find_msg (domain, msgid);
+
+ if (retval == NULL)
+ {
+ int cnt;
+
+ for (cnt = 0; domain->successor[cnt] != NULL; ++cnt)
+ {
+ retval = find_msg (domain->successor[cnt], msgid);
+
+ if (retval != NULL)
+ break;
+ }
+ }
+
+ if (retval != NULL)
+ {
+ FREE_BLOCKS (block_list);
+ __set_errno (saved_errno);
+ return retval;
+ }
+ }
+ }
+ /* NOTREACHED */
+}
+
+#ifdef _LIBC
+/* Alias for function name in GNU C Library. */
+weak_alias (__dcgettext, dcgettext);
+#endif
+
+
+static char *
+find_msg (domain_file, msgid)
+ struct loaded_l10nfile *domain_file;
+ const char *msgid;
+{
+ size_t top, act, bottom;
+ struct loaded_domain *domain;
+
+ if (domain_file->decided == 0)
+ _nl_load_domain (domain_file);
+
+ if (domain_file->data == NULL)
+ return NULL;
+
+ domain = (struct loaded_domain *) domain_file->data;
+
+ /* Locate the MSGID and its translation. */
+ if (domain->hash_size > 2 && domain->hash_tab != NULL)
+ {
+ /* Use the hashing table. */
+ nls_uint32 len = strlen (msgid);
+ nls_uint32 hash_val = hash_string (msgid);
+ nls_uint32 idx = hash_val % domain->hash_size;
+ nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2));
+ nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]);
+
+ if (nstr == 0)
+ /* Hash table entry is empty. */
+ return NULL;
+
+ if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len
+ && strcmp (msgid,
+ domain->data + W (domain->must_swap,
+ domain->orig_tab[nstr - 1].offset)) == 0)
+ return (char *) domain->data + W (domain->must_swap,
+ domain->trans_tab[nstr - 1].offset);
+
+ while (1)
+ {
+ if (idx >= domain->hash_size - incr)
+ idx -= domain->hash_size - incr;
+ else
+ idx += incr;
+
+ nstr = W (domain->must_swap, domain->hash_tab[idx]);
+ if (nstr == 0)
+ /* Hash table entry is empty. */
+ return NULL;
+
+ if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len
+ && strcmp (msgid,
+ domain->data + W (domain->must_swap,
+ domain->orig_tab[nstr - 1].offset))
+ == 0)
+ return (char *) domain->data
+ + W (domain->must_swap, domain->trans_tab[nstr - 1].offset);
+ }
+ /* NOTREACHED */
+ }
+
+ /* Now we try the default method: binary search in the sorted
+ array of messages. */
+ bottom = 0;
+ top = domain->nstrings;
+ while (bottom < top)
+ {
+ int cmp_val;
+
+ act = (bottom + top) / 2;
+ cmp_val = strcmp (msgid, domain->data
+ + W (domain->must_swap,
+ domain->orig_tab[act].offset));
+ if (cmp_val < 0)
+ top = act;
+ else if (cmp_val > 0)
+ bottom = act + 1;
+ else
+ break;
+ }
+
+ /* If an translation is found return this. */
+ return bottom >= top ? NULL : (char *) domain->data
+ + W (domain->must_swap,
+ domain->trans_tab[act].offset);
+}
+
+
+/* Return string representation of locale CATEGORY. */
+static const char *
+category_to_name (category)
+ int category;
+{
+ const char *retval;
+
+ switch (category)
+ {
+#ifdef LC_COLLATE
+ case LC_COLLATE:
+ retval = "LC_COLLATE";
+ break;
+#endif
+#ifdef LC_CTYPE
+ case LC_CTYPE:
+ retval = "LC_CTYPE";
+ break;
+#endif
+#ifdef LC_MONETARY
+ case LC_MONETARY:
+ retval = "LC_MONETARY";
+ break;
+#endif
+#ifdef LC_NUMERIC
+ case LC_NUMERIC:
+ retval = "LC_NUMERIC";
+ break;
+#endif
+#ifdef LC_TIME
+ case LC_TIME:
+ retval = "LC_TIME";
+ break;
+#endif
+#ifdef LC_MESSAGES
+ case LC_MESSAGES:
+ retval = "LC_MESSAGES";
+ break;
+#endif
+#ifdef LC_RESPONSE
+ case LC_RESPONSE:
+ retval = "LC_RESPONSE";
+ break;
+#endif
+#ifdef LC_ALL
+ case LC_ALL:
+ /* This might not make sense but is perhaps better than any other
+ value. */
+ retval = "LC_ALL";
+ break;
+#endif
+ default:
+ /* If you have a better idea for a default value let me know. */
+ retval = "LC_XXX";
+ }
+
+ return retval;
+}
+
+/* Guess value of current locale from value of the environment variables. */
+static const char *
+guess_category_value (category, categoryname)
+ int category;
+ const char *categoryname;
+{
+ const char *retval;
+
+ /* The highest priority value is the `LANGUAGE' environment
+ variable. This is a GNU extension. */
+ retval = getenv ("LANGUAGE");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+
+ /* `LANGUAGE' is not set. So we have to proceed with the POSIX
+ methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
+ systems this can be done by the `setlocale' function itself. */
+#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
+ return setlocale (category, NULL);
+#else
+ /* Setting of LC_ALL overwrites all other. */
+ retval = getenv ("LC_ALL");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+
+ /* Next comes the name of the desired category. */
+ retval = getenv (categoryname);
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+
+ /* Last possibility is the LANG environment variable. */
+ retval = getenv ("LANG");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+
+ /* We use C as the default domain. POSIX says this is implementation
+ defined. */
+ return "C";
+#endif
+}
+
+/* @@ begin of epilog @@ */
+
+/* We don't want libintl.a to depend on any other library. So we
+ avoid the non-standard function stpcpy. In GNU C Library this
+ function is available, though. Also allow the symbol HAVE_STPCPY
+ to be defined. */
+#if !_LIBC && !HAVE_STPCPY
+static char *
+stpcpy (dest, src)
+ char *dest;
+ const char *src;
+{
+ while ((*dest++ = *src++) != '\0')
+ /* Do nothing. */ ;
+ return dest - 1;
+}
+#endif
diff --git a/intl/dgettext.c b/intl/dgettext.c
new file mode 100644
index 00000000000..2fde6770f79
--- /dev/null
+++ b/intl/dgettext.c
@@ -0,0 +1,59 @@
+/* dgettext.c -- implementation of the dgettext(3) function
+ Copyright (C) 1995 Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined HAVE_LOCALE_H || defined _LIBC
+# include <locale.h>
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+
+/* @@ end of prolog @@ */
+
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define DGETTEXT __dgettext
+# define DCGETTEXT __dcgettext
+#else
+# define DGETTEXT dgettext__
+# define DCGETTEXT dcgettext__
+#endif
+
+/* Look up MSGID in the DOMAINNAME message catalog of the current
+ LC_MESSAGES locale. */
+char *
+DGETTEXT (domainname, msgid)
+ const char *domainname;
+ const char *msgid;
+{
+ return DCGETTEXT (domainname, msgid, LC_MESSAGES);
+}
+
+#ifdef _LIBC
+/* Alias for function name in GNU C Library. */
+weak_alias (__dgettext, dgettext);
+#endif
diff --git a/intl/explodename.c b/intl/explodename.c
new file mode 100644
index 00000000000..37c46e9d7b8
--- /dev/null
+++ b/intl/explodename.c
@@ -0,0 +1,181 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "loadinfo.h"
+
+/* On some strange systems still no definition of NULL is found. Sigh! */
+#ifndef NULL
+# if defined __STDC__ && __STDC__
+# define NULL ((void *) 0)
+# else
+# define NULL 0
+# endif
+#endif
+
+/* @@ end of prolog @@ */
+
+int
+_nl_explode_name (name, language, modifier, territory, codeset,
+ normalized_codeset, special, sponsor, revision)
+ char *name;
+ const char **language;
+ const char **modifier;
+ const char **territory;
+ const char **codeset;
+ const char **normalized_codeset;
+ const char **special;
+ const char **sponsor;
+ const char **revision;
+{
+ enum { undecided, xpg, cen } syntax;
+ char *cp;
+ int mask;
+
+ *modifier = NULL;
+ *territory = NULL;
+ *codeset = NULL;
+ *normalized_codeset = NULL;
+ *special = NULL;
+ *sponsor = NULL;
+ *revision = NULL;
+
+ /* Now we determine the single parts of the locale name. First
+ look for the language. Termination symbols are `_' and `@' if
+ we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
+ mask = 0;
+ syntax = undecided;
+ *language = cp = name;
+ while (cp[0] != '\0' && cp[0] != '_' && cp[0] != '@'
+ && cp[0] != '+' && cp[0] != ',')
+ ++cp;
+
+ if (*language == cp)
+ /* This does not make sense: language has to be specified. Use
+ this entry as it is without exploding. Perhaps it is an alias. */
+ cp = strchr (*language, '\0');
+ else if (cp[0] == '_')
+ {
+ /* Next is the territory. */
+ cp[0] = '\0';
+ *territory = ++cp;
+
+ while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
+ && cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
+ ++cp;
+
+ mask |= TERRITORY;
+
+ if (cp[0] == '.')
+ {
+ /* Next is the codeset. */
+ syntax = xpg;
+ cp[0] = '\0';
+ *codeset = ++cp;
+
+ while (cp[0] != '\0' && cp[0] != '@')
+ ++cp;
+
+ mask |= XPG_CODESET;
+
+ if (*codeset != cp && (*codeset)[0] != '\0')
+ {
+ *normalized_codeset = _nl_normalize_codeset (*codeset,
+ cp - *codeset);
+ if (strcmp (*codeset, *normalized_codeset) == 0)
+ free ((char *) *normalized_codeset);
+ else
+ mask |= XPG_NORM_CODESET;
+ }
+ }
+ }
+
+ if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
+ {
+ /* Next is the modifier. */
+ syntax = cp[0] == '@' ? xpg : cen;
+ cp[0] = '\0';
+ *modifier = ++cp;
+
+ while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
+ && cp[0] != ',' && cp[0] != '_')
+ ++cp;
+
+ mask |= XPG_MODIFIER | CEN_AUDIENCE;
+ }
+
+ if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
+ {
+ syntax = cen;
+
+ if (cp[0] == '+')
+ {
+ /* Next is special application (CEN syntax). */
+ cp[0] = '\0';
+ *special = ++cp;
+
+ while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
+ ++cp;
+
+ mask |= CEN_SPECIAL;
+ }
+
+ if (cp[0] == ',')
+ {
+ /* Next is sponsor (CEN syntax). */
+ cp[0] = '\0';
+ *sponsor = ++cp;
+
+ while (cp[0] != '\0' && cp[0] != '_')
+ ++cp;
+
+ mask |= CEN_SPONSOR;
+ }
+
+ if (cp[0] == '_')
+ {
+ /* Next is revision (CEN syntax). */
+ cp[0] = '\0';
+ *revision = ++cp;
+
+ mask |= CEN_REVISION;
+ }
+ }
+
+ /* For CEN syntax values it might be important to have the
+ separator character in the file name, not for XPG syntax. */
+ if (syntax == xpg)
+ {
+ if (*territory != NULL && (*territory)[0] == '\0')
+ mask &= ~TERRITORY;
+
+ if (*codeset != NULL && (*codeset)[0] == '\0')
+ mask &= ~XPG_CODESET;
+
+ if (*modifier != NULL && (*modifier)[0] == '\0')
+ mask &= ~XPG_MODIFIER;
+ }
+
+ return mask;
+}
diff --git a/intl/finddomain.c b/intl/finddomain.c
new file mode 100644
index 00000000000..ec85d4de4d1
--- /dev/null
+++ b/intl/finddomain.c
@@ -0,0 +1,189 @@
+/* Handle list of needed message catalogs
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#else
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# else
+void free ();
+# endif
+#endif
+
+#if defined HAVE_STRING_H || defined _LIBC
+# include <string.h>
+#else
+# include <strings.h>
+# ifndef memcpy
+# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
+# endif
+#endif
+#if !HAVE_STRCHR && !defined _LIBC
+# ifndef strchr
+# define strchr index
+# endif
+#endif
+
+#if defined HAVE_UNISTD_H || defined _LIBC
+# include <unistd.h>
+#endif
+
+#include "gettext.h"
+#include "gettextP.h"
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+
+/* @@ end of prolog @@ */
+/* List of already loaded domains. */
+static struct loaded_l10nfile *_nl_loaded_domains;
+
+
+/* Return a data structure describing the message catalog described by
+ the DOMAINNAME and CATEGORY parameters with respect to the currently
+ established bindings. */
+struct loaded_l10nfile *
+_nl_find_domain (dirname, locale, domainname)
+ const char *dirname;
+ char *locale;
+ const char *domainname;
+{
+ struct loaded_l10nfile *retval;
+ const char *language;
+ const char *modifier;
+ const char *territory;
+ const char *codeset;
+ const char *normalized_codeset;
+ const char *special;
+ const char *sponsor;
+ const char *revision;
+ const char *alias_value;
+ int mask;
+
+ /* LOCALE can consist of up to four recognized parts for the XPG syntax:
+
+ language[_territory[.codeset]][@modifier]
+
+ and six parts for the CEN syntax:
+
+ language[_territory][+audience][+special][,[sponsor][_revision]]
+
+ Beside the first all of them are allowed to be missing. If the
+ full specified locale is not found, the less specific one are
+ looked for. The various part will be stripped of according to
+ the following order:
+ (1) revision
+ (2) sponsor
+ (3) special
+ (4) codeset
+ (5) normalized codeset
+ (6) territory
+ (7) audience/modifier
+ */
+
+ /* If we have already tested for this locale entry there has to
+ be one data set in the list of loaded domains. */
+ retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
+ strlen (dirname) + 1, 0, locale, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, domainname, 0);
+ if (retval != NULL)
+ {
+ /* We know something about this locale. */
+ int cnt;
+
+ if (retval->decided == 0)
+ _nl_load_domain (retval);
+
+ if (retval->data != NULL)
+ return retval;
+
+ for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
+ {
+ if (retval->successor[cnt]->decided == 0)
+ _nl_load_domain (retval->successor[cnt]);
+
+ if (retval->successor[cnt]->data != NULL)
+ break;
+ }
+ return cnt >= 0 ? retval : NULL;
+ /* NOTREACHED */
+ }
+
+ /* See whether the locale value is an alias. If yes its value
+ *overwrites* the alias name. No test for the original value is
+ done. */
+ alias_value = _nl_expand_alias (locale);
+ if (alias_value != NULL)
+ {
+ size_t len = strlen (alias_value) + 1;
+ locale = (char *) malloc (len);
+ if (locale == NULL)
+ return NULL;
+
+ memcpy (locale, alias_value, len);
+ }
+
+ /* Now we determine the single parts of the locale name. First
+ look for the language. Termination symbols are `_' and `@' if
+ we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
+ mask = _nl_explode_name (locale, &language, &modifier, &territory,
+ &codeset, &normalized_codeset, &special,
+ &sponsor, &revision);
+
+ /* Create all possible locale entries which might be interested in
+ generalization. */
+ retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
+ strlen (dirname) + 1, mask, language, territory,
+ codeset, normalized_codeset, modifier, special,
+ sponsor, revision, domainname, 1);
+ if (retval == NULL)
+ /* This means we are out of core. */
+ return NULL;
+
+ if (retval->decided == 0)
+ _nl_load_domain (retval);
+ if (retval->data == NULL)
+ {
+ int cnt;
+ for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
+ {
+ if (retval->successor[cnt]->decided == 0)
+ _nl_load_domain (retval->successor[cnt]);
+ if (retval->successor[cnt]->data != NULL)
+ break;
+ }
+ }
+
+ /* The room for an alias was dynamically allocated. Free it now. */
+ if (alias_value != NULL)
+ free (locale);
+
+ return retval;
+}
diff --git a/intl/gettext.c b/intl/gettext.c
new file mode 100644
index 00000000000..1336d21e7c9
--- /dev/null
+++ b/intl/gettext.c
@@ -0,0 +1,70 @@
+/* Implementation of gettext(3) function
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef _LIBC
+# define __need_NULL
+# include <stddef.h>
+#else
+# ifdef STDC_HEADERS
+# include <stdlib.h> /* Just for NULL. */
+# else
+# ifdef HAVE_STRING_H
+# include <string.h>
+# else
+# define NULL ((void *) 0)
+# endif
+# endif
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+
+/* @@ end of prolog @@ */
+
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define GETTEXT __gettext
+# define DGETTEXT __dgettext
+#else
+# define GETTEXT gettext__
+# define DGETTEXT dgettext__
+#endif
+
+/* Look up MSGID in the current default message catalog for the current
+ LC_MESSAGES locale. If not found, returns MSGID itself (the default
+ text). */
+char *
+GETTEXT (msgid)
+ const char *msgid;
+{
+ return DGETTEXT (NULL, msgid);
+}
+
+#ifdef _LIBC
+/* Alias for function name in GNU C Library. */
+weak_alias (__gettext, gettext);
+#endif
diff --git a/intl/gettext.h b/intl/gettext.h
new file mode 100644
index 00000000000..6b4b9e3316c
--- /dev/null
+++ b/intl/gettext.h
@@ -0,0 +1,105 @@
+/* Internal header for GNU gettext internationalization functions
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _GETTEXT_H
+#define _GETTEXT_H 1
+
+#include <stdio.h>
+
+#if HAVE_LIMITS_H || _LIBC
+# include <limits.h>
+#endif
+
+/* @@ end of prolog @@ */
+
+/* The magic number of the GNU message catalog format. */
+#define _MAGIC 0x950412de
+#define _MAGIC_SWAPPED 0xde120495
+
+/* Revision number of the currently used .mo (binary) file format. */
+#define MO_REVISION_NUMBER 0
+
+/* The following contortions are an attempt to use the C preprocessor
+ to determine an unsigned integral type that is 32 bits wide. An
+ alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
+ doing that would require that the configure script compile and *run*
+ the resulting executable. Locally running cross-compiled executables
+ is usually not possible. */
+
+#if __STDC__
+# define UINT_MAX_32_BITS 4294967295U
+#else
+# define UINT_MAX_32_BITS 0xFFFFFFFF
+#endif
+
+/* If UINT_MAX isn't defined, assume it's a 32-bit type.
+ This should be valid for all systems GNU cares about because
+ that doesn't include 16-bit systems, and only modern systems
+ (that certainly have <limits.h>) have 64+-bit integral types. */
+
+#ifndef UINT_MAX
+# define UINT_MAX UINT_MAX_32_BITS
+#endif
+
+#if UINT_MAX == UINT_MAX_32_BITS
+typedef unsigned nls_uint32;
+#else
+# if USHRT_MAX == UINT_MAX_32_BITS
+typedef unsigned short nls_uint32;
+# else
+# if ULONG_MAX == UINT_MAX_32_BITS
+typedef unsigned long nls_uint32;
+# else
+ /* The following line is intended to throw an error. Using #error is
+ not portable enough. */
+ "Cannot determine unsigned 32-bit data type."
+# endif
+# endif
+#endif
+
+
+/* Header for binary .mo file format. */
+struct mo_file_header
+{
+ /* The magic number. */
+ nls_uint32 magic;
+ /* The revision number of the file format. */
+ nls_uint32 revision;
+ /* The number of strings pairs. */
+ nls_uint32 nstrings;
+ /* Offset of table with start offsets of original strings. */
+ nls_uint32 orig_tab_offset;
+ /* Offset of table with start offsets of translation strings. */
+ nls_uint32 trans_tab_offset;
+ /* Size of hashing table. */
+ nls_uint32 hash_tab_size;
+ /* Offset of first hashing entry. */
+ nls_uint32 hash_tab_offset;
+};
+
+struct string_desc
+{
+ /* Length of addressed string. */
+ nls_uint32 length;
+ /* Offset of string in file. */
+ nls_uint32 offset;
+};
+
+/* @@ begin of epilog @@ */
+
+#endif /* gettext.h */
diff --git a/intl/gettextP.h b/intl/gettextP.h
new file mode 100644
index 00000000000..bb8d55235ad
--- /dev/null
+++ b/intl/gettextP.h
@@ -0,0 +1,73 @@
+/* Header describing internals of gettext library
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _GETTEXTP_H
+#define _GETTEXTP_H
+
+#include "loadinfo.h"
+
+/* @@ end of prolog @@ */
+
+#ifndef PARAMS
+# if __STDC__
+# define PARAMS(args) args
+# else
+# define PARAMS(args) ()
+# endif
+#endif
+
+#ifndef W
+# define W(flag, data) ((flag) ? SWAP (data) : (data))
+#endif
+
+
+static nls_uint32 SWAP PARAMS ((nls_uint32 i));
+
+static inline nls_uint32
+SWAP (i)
+ nls_uint32 i;
+{
+ return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
+}
+
+
+struct loaded_domain
+{
+ const char *data;
+ int must_swap;
+ nls_uint32 nstrings;
+ struct string_desc *orig_tab;
+ struct string_desc *trans_tab;
+ nls_uint32 hash_size;
+ nls_uint32 *hash_tab;
+};
+
+struct binding
+{
+ struct binding *next;
+ char *domainname;
+ char *dirname;
+};
+
+struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
+ char *__locale,
+ const char *__domainname));
+void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain));
+
+/* @@ begin of epilog @@ */
+
+#endif /* gettextP.h */
diff --git a/intl/hash-string.h b/intl/hash-string.h
new file mode 100644
index 00000000000..e66e8417a97
--- /dev/null
+++ b/intl/hash-string.h
@@ -0,0 +1,63 @@
+/* Implements a string hashing function.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_VALUES_H
+# include <values.h>
+#endif
+
+/* @@ end of prolog @@ */
+
+#ifndef PARAMS
+# if __STDC__
+# define PARAMS(Args) Args
+# else
+# define PARAMS(Args) ()
+# endif
+#endif
+
+/* We assume to have `unsigned long int' value with at least 32 bits. */
+#define HASHWORDBITS 32
+
+
+/* Defines the so called `hashpjw' function by P.J. Weinberger
+ [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
+ 1986, 1987 Bell Telephone Laboratories, Inc.] */
+static unsigned long hash_string PARAMS ((const char *__str_param));
+
+static inline unsigned long
+hash_string (str_param)
+ const char *str_param;
+{
+ unsigned long int hval, g;
+ const char *str = str_param;
+
+ /* Compute the hash value for the given string. */
+ hval = 0;
+ while (*str != '\0')
+ {
+ hval <<= 4;
+ hval += (unsigned long) *str++;
+ g = hval & ((unsigned long) 0xf << (HASHWORDBITS - 4));
+ if (g != 0)
+ {
+ hval ^= g >> (HASHWORDBITS - 8);
+ hval ^= g;
+ }
+ }
+ return hval;
+}
diff --git a/intl/intl-compat.c b/intl/intl-compat.c
new file mode 100644
index 00000000000..503efa0fa9c
--- /dev/null
+++ b/intl/intl-compat.c
@@ -0,0 +1,76 @@
+/* intl-compat.c - Stub functions to call gettext functions from GNU gettext
+ Library.
+ Copyright (C) 1995 Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libgettext.h"
+
+/* @@ end of prolog @@ */
+
+
+#undef gettext
+#undef dgettext
+#undef dcgettext
+#undef textdomain
+#undef bindtextdomain
+
+
+char *
+bindtextdomain (domainname, dirname)
+ const char *domainname;
+ const char *dirname;
+{
+ return bindtextdomain__ (domainname, dirname);
+}
+
+
+char *
+dcgettext (domainname, msgid, category)
+ const char *domainname;
+ const char *msgid;
+ int category;
+{
+ return dcgettext__ (domainname, msgid, category);
+}
+
+
+char *
+dgettext (domainname, msgid)
+ const char *domainname;
+ const char *msgid;
+{
+ return dgettext__ (domainname, msgid);
+}
+
+
+char *
+gettext (msgid)
+ const char *msgid;
+{
+ return gettext__ (msgid);
+}
+
+
+char *
+textdomain (domainname)
+ const char *domainname;
+{
+ return textdomain__ (domainname);
+}
diff --git a/intl/intlh.inst.in b/intl/intlh.inst.in
new file mode 100644
index 00000000000..62d323cd8c1
--- /dev/null
+++ b/intl/intlh.inst.in
@@ -0,0 +1,111 @@
+/* Message catalogs for internationalization.
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _LIBINTL_H
+#define _LIBINTL_H 1
+
+@INCLUDE_LOCALE_H@
+
+/* We define an additional symbol to signal that we use the GNU
+ implementation of gettext. */
+#define __USE_GNU_GETTEXT 1
+
+#ifndef PARAMS
+# if __STDC__
+# define PARAMS(args) args
+# else
+# define PARAMS(args) ()
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Look up MSGID in the current default message catalog for the current
+ LC_MESSAGES locale. If not found, returns MSGID itself (the default
+ text). */
+extern char *gettext PARAMS ((const char *__msgid));
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current
+ LC_MESSAGES locale. */
+extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
+ locale. */
+extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
+ int __category));
+
+
+/* Set the current default message catalog to DOMAINNAME.
+ If DOMAINNAME is null, return the current default.
+ If DOMAINNAME is "", reset to the default of "messages". */
+extern char *textdomain PARAMS ((const char *__domainname));
+
+/* Specify that the DOMAINNAME message catalog will be found
+ in DIRNAME rather than in the system locale data base. */
+extern char *bindtextdomain PARAMS ((const char *__domainname,
+ const char *__dirname));
+
+
+/* Optimized version of the functions above. */
+#if defined __OPTIMIZED
+/* These must be a macro. Inlined functions are useless because the
+ `__builtin_constant_p' predicate in dcgettext would always return
+ false. */
+
+# define gettext(msgid) dgettext ((char *) 0, msgid)
+
+# define dgettext(domainname, msgid) \
+ dcgettext (domainname, msgid, LC_MESSAGES)
+
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+/* This global variable is defined in loadmsgcat.c. We need a sign,
+ whether a new catalog was loaded, which can be associated with all
+ translations. */
+extern int _nl_msg_cat_cntr;
+
+# define dcgettext(domainname, msgid, category) \
+ (__extension__ \
+ ({ \
+ char *__result; \
+ if (__builtin_constant_p (msgid)) \
+ { \
+ static char *__translation__; \
+ static int __catalog_counter__; \
+ if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \
+ { \
+ __translation__ = \
+ (dcgettext) ((domainname), (msgid), (category)); \
+ __catalog_counter__ = _nl_msg_cat_cntr; \
+ } \
+ __result = __translation__; \
+ } \
+ else \
+ __result = (dcgettext) ((domainname), (msgid), (category)); \
+ __result; \
+ }))
+# endif
+#endif /* Optimizing. */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* libintl.h */
diff --git a/intl/l10nflist.c b/intl/l10nflist.c
new file mode 100644
index 00000000000..4e2bc130950
--- /dev/null
+++ b/intl/l10nflist.c
@@ -0,0 +1,409 @@
+/* Handle list of needed message catalogs
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+
+#if defined HAVE_STRING_H || defined _LIBC
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+# endif
+# include <string.h>
+#else
+# include <strings.h>
+# ifndef memcpy
+# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
+# endif
+#endif
+#if !HAVE_STRCHR && !defined _LIBC
+# ifndef strchr
+# define strchr index
+# endif
+#endif
+
+#if defined _LIBC || defined HAVE_ARGZ_H
+# include <argz.h>
+#endif
+#include <ctype.h>
+#include <sys/types.h>
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#endif
+
+#include "loadinfo.h"
+
+/* On some strange systems still no definition of NULL is found. Sigh! */
+#ifndef NULL
+# if defined __STDC__ && __STDC__
+# define NULL ((void *) 0)
+# else
+# define NULL 0
+# endif
+#endif
+
+/* @@ end of prolog @@ */
+
+#ifdef _LIBC
+/* Rename the non ANSI C functions. This is required by the standard
+ because some ANSI C functions will require linking with this object
+ file and the name space must not be polluted. */
+# define stpcpy(dest, src) __stpcpy(dest, src)
+#else
+# ifndef HAVE_STPCPY
+static char *stpcpy PARAMS ((char *dest, const char *src));
+# endif
+#endif
+
+/* Define function which are usually not available. */
+
+#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
+/* Returns the number of strings in ARGZ. */
+static size_t argz_count__ PARAMS ((const char *argz, size_t len));
+
+static size_t
+argz_count__ (argz, len)
+ const char *argz;
+ size_t len;
+{
+ size_t count = 0;
+ while (len > 0)
+ {
+ size_t part_len = strlen (argz);
+ argz += part_len + 1;
+ len -= part_len + 1;
+ count++;
+ }
+ return count;
+}
+# undef __argz_count
+# define __argz_count(argz, len) argz_count__ (argz, len)
+#endif /* !_LIBC && !HAVE___ARGZ_COUNT */
+
+#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
+/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
+ except the last into the character SEP. */
+static void argz_stringify__ PARAMS ((char *argz, size_t len, int sep));
+
+static void
+argz_stringify__ (argz, len, sep)
+ char *argz;
+ size_t len;
+ int sep;
+{
+ while (len > 0)
+ {
+ size_t part_len = strlen (argz);
+ argz += part_len;
+ len -= part_len + 1;
+ if (len > 0)
+ *argz++ = sep;
+ }
+}
+# undef __argz_stringify
+# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
+#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
+
+#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
+static char *argz_next__ PARAMS ((char *argz, size_t argz_len,
+ const char *entry));
+
+static char *
+argz_next__ (argz, argz_len, entry)
+ char *argz;
+ size_t argz_len;
+ const char *entry;
+{
+ if (entry)
+ {
+ if (entry < argz + argz_len)
+ entry = strchr (entry, '\0') + 1;
+
+ return entry >= argz + argz_len ? NULL : (char *) entry;
+ }
+ else
+ if (argz_len > 0)
+ return argz;
+ else
+ return 0;
+}
+# undef __argz_next
+# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
+#endif /* !_LIBC && !HAVE___ARGZ_NEXT */
+
+
+/* Return number of bits set in X. */
+static int pop PARAMS ((int x));
+
+static inline int
+pop (x)
+ int x;
+{
+ /* We assume that no more than 16 bits are used. */
+ x = ((x & ~0x5555) >> 1) + (x & 0x5555);
+ x = ((x & ~0x3333) >> 2) + (x & 0x3333);
+ x = ((x >> 4) + x) & 0x0f0f;
+ x = ((x >> 8) + x) & 0xff;
+
+ return x;
+}
+
+
+struct loaded_l10nfile *
+_nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
+ territory, codeset, normalized_codeset, modifier, special,
+ sponsor, revision, filename, do_allocate)
+ struct loaded_l10nfile **l10nfile_list;
+ const char *dirlist;
+ size_t dirlist_len;
+ int mask;
+ const char *language;
+ const char *territory;
+ const char *codeset;
+ const char *normalized_codeset;
+ const char *modifier;
+ const char *special;
+ const char *sponsor;
+ const char *revision;
+ const char *filename;
+ int do_allocate;
+{
+ char *abs_filename;
+ struct loaded_l10nfile *last = NULL;
+ struct loaded_l10nfile *retval;
+ char *cp;
+ size_t entries;
+ int cnt;
+
+ /* Allocate room for the full file name. */
+ abs_filename = (char *) malloc (dirlist_len
+ + strlen (language)
+ + ((mask & TERRITORY) != 0
+ ? strlen (territory) + 1 : 0)
+ + ((mask & XPG_CODESET) != 0
+ ? strlen (codeset) + 1 : 0)
+ + ((mask & XPG_NORM_CODESET) != 0
+ ? strlen (normalized_codeset) + 1 : 0)
+ + (((mask & XPG_MODIFIER) != 0
+ || (mask & CEN_AUDIENCE) != 0)
+ ? strlen (modifier) + 1 : 0)
+ + ((mask & CEN_SPECIAL) != 0
+ ? strlen (special) + 1 : 0)
+ + (((mask & CEN_SPONSOR) != 0
+ || (mask & CEN_REVISION) != 0)
+ ? (1 + ((mask & CEN_SPONSOR) != 0
+ ? strlen (sponsor) + 1 : 0)
+ + ((mask & CEN_REVISION) != 0
+ ? strlen (revision) + 1 : 0)) : 0)
+ + 1 + strlen (filename) + 1);
+
+ if (abs_filename == NULL)
+ return NULL;
+
+ retval = NULL;
+ last = NULL;
+
+ /* Construct file name. */
+ memcpy (abs_filename, dirlist, dirlist_len);
+ __argz_stringify (abs_filename, dirlist_len, ':');
+ cp = abs_filename + (dirlist_len - 1);
+ *cp++ = '/';
+ cp = stpcpy (cp, language);
+
+ if ((mask & TERRITORY) != 0)
+ {
+ *cp++ = '_';
+ cp = stpcpy (cp, territory);
+ }
+ if ((mask & XPG_CODESET) != 0)
+ {
+ *cp++ = '.';
+ cp = stpcpy (cp, codeset);
+ }
+ if ((mask & XPG_NORM_CODESET) != 0)
+ {
+ *cp++ = '.';
+ cp = stpcpy (cp, normalized_codeset);
+ }
+ if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
+ {
+ /* This component can be part of both syntaces but has different
+ leading characters. For CEN we use `+', else `@'. */
+ *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
+ cp = stpcpy (cp, modifier);
+ }
+ if ((mask & CEN_SPECIAL) != 0)
+ {
+ *cp++ = '+';
+ cp = stpcpy (cp, special);
+ }
+ if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
+ {
+ *cp++ = ',';
+ if ((mask & CEN_SPONSOR) != 0)
+ cp = stpcpy (cp, sponsor);
+ if ((mask & CEN_REVISION) != 0)
+ {
+ *cp++ = '_';
+ cp = stpcpy (cp, revision);
+ }
+ }
+
+ *cp++ = '/';
+ stpcpy (cp, filename);
+
+ /* Look in list of already loaded domains whether it is already
+ available. */
+ last = NULL;
+ for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
+ if (retval->filename != NULL)
+ {
+ int compare = strcmp (retval->filename, abs_filename);
+ if (compare == 0)
+ /* We found it! */
+ break;
+ if (compare < 0)
+ {
+ /* It's not in the list. */
+ retval = NULL;
+ break;
+ }
+
+ last = retval;
+ }
+
+ if (retval != NULL || do_allocate == 0)
+ {
+ free (abs_filename);
+ return retval;
+ }
+
+ retval = (struct loaded_l10nfile *)
+ malloc (sizeof (*retval) + (__argz_count (dirlist, dirlist_len)
+ * (1 << pop (mask))
+ * sizeof (struct loaded_l10nfile *)));
+ if (retval == NULL)
+ return NULL;
+
+ retval->filename = abs_filename;
+ retval->decided = (__argz_count (dirlist, dirlist_len) != 1
+ || ((mask & XPG_CODESET) != 0
+ && (mask & XPG_NORM_CODESET) != 0));
+ retval->data = NULL;
+
+ if (last == NULL)
+ {
+ retval->next = *l10nfile_list;
+ *l10nfile_list = retval;
+ }
+ else
+ {
+ retval->next = last->next;
+ last->next = retval;
+ }
+
+ entries = 0;
+ /* If the DIRLIST is a real list the RETVAL entry corresponds not to
+ a real file. So we have to use the DIRLIST separation mechanism
+ of the inner loop. */
+ cnt = __argz_count (dirlist, dirlist_len) == 1 ? mask - 1 : mask;
+ for (; cnt >= 0; --cnt)
+ if ((cnt & ~mask) == 0
+ && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
+ && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
+ {
+ /* Iterate over all elements of the DIRLIST. */
+ char *dir = NULL;
+
+ while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
+ != NULL)
+ retval->successor[entries++]
+ = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt,
+ language, territory, codeset,
+ normalized_codeset, modifier, special,
+ sponsor, revision, filename, 1);
+ }
+ retval->successor[entries] = NULL;
+
+ return retval;
+}
+
+/* Normalize codeset name. There is no standard for the codeset
+ names. Normalization allows the user to use any of the common
+ names. */
+const char *
+_nl_normalize_codeset (codeset, name_len)
+ const char *codeset;
+ size_t name_len;
+{
+ int len = 0;
+ int only_digit = 1;
+ char *retval;
+ char *wp;
+ size_t cnt;
+
+ for (cnt = 0; cnt < name_len; ++cnt)
+ if (isalnum (codeset[cnt]))
+ {
+ ++len;
+
+ if (isalpha (codeset[cnt]))
+ only_digit = 0;
+ }
+
+ retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
+
+ if (retval != NULL)
+ {
+ if (only_digit)
+ wp = stpcpy (retval, "iso");
+ else
+ wp = retval;
+
+ for (cnt = 0; cnt < name_len; ++cnt)
+ if (isalpha (codeset[cnt]))
+ *wp++ = tolower (codeset[cnt]);
+ else if (isdigit (codeset[cnt]))
+ *wp++ = codeset[cnt];
+
+ *wp = '\0';
+ }
+
+ return (const char *) retval;
+}
+
+
+/* @@ begin of epilog @@ */
+
+/* We don't want libintl.a to depend on any other library. So we
+ avoid the non-standard function stpcpy. In GNU C Library this
+ function is available, though. Also allow the symbol HAVE_STPCPY
+ to be defined. */
+#if !_LIBC && !HAVE_STPCPY
+static char *
+stpcpy (dest, src)
+ char *dest;
+ const char *src;
+{
+ while ((*dest++ = *src++) != '\0')
+ /* Do nothing. */ ;
+ return dest - 1;
+}
+#endif
diff --git a/intl/libgettext.h b/intl/libgettext.h
new file mode 100644
index 00000000000..0d4de4d0ee1
--- /dev/null
+++ b/intl/libgettext.h
@@ -0,0 +1,182 @@
+/* Message catalogs for internationalization.
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Because on some systems (e.g. Solaris) we sometimes have to include
+ the systems libintl.h as well as this file we have more complex
+ include protection above. But the systems header might perhaps also
+ define _LIBINTL_H and therefore we have to protect the definition here. */
+
+#if !defined (_LIBINTL_H) || !defined (_LIBGETTEXT_H)
+#if !defined (_LIBINTL_H)
+# define _LIBINTL_H 1
+#endif
+#define _LIBGETTEXT_H 1
+
+/* We define an additional symbol to signal that we use the GNU
+ implementation of gettext. */
+#define __USE_GNU_GETTEXT 1
+
+#include <sys/types.h>
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* @@ end of prolog @@ */
+
+#ifndef PARAMS
+# if __STDC__
+# define PARAMS(args) args
+# else
+# define PARAMS(args) ()
+# endif
+#endif
+
+#ifndef NULL
+# if !defined __cplusplus || defined __GNUC__
+# define NULL ((void *) 0)
+# else
+# define NULL (0)
+# endif
+#endif
+
+#if !HAVE_LC_MESSAGES
+/* This value determines the behaviour of the gettext() and dgettext()
+ function. But some system does not have this defined. Define it
+ to a default value. */
+# define LC_MESSAGES (-1)
+#endif
+
+
+/* Declarations for gettext-using-catgets interface. Derived from
+ Jim Meyering's libintl.h. */
+struct _msg_ent
+{
+ const char *_msg;
+ int _msg_number;
+};
+
+
+#if HAVE_CATGETS
+/* These two variables are defined in the automatically by po-to-tbl.sed
+ generated file `cat-id-tbl.c'. */
+extern const struct _msg_ent _msg_tbl[];
+extern int _msg_tbl_length;
+#endif
+
+
+/* For automatical extraction of messages sometimes no real
+ translation is needed. Instead the string itself is the result. */
+#define gettext_noop(Str) (Str)
+
+/* Look up MSGID in the current default message catalog for the current
+ LC_MESSAGES locale. If not found, returns MSGID itself (the default
+ text). */
+extern char *gettext PARAMS ((const char *__msgid));
+extern char *gettext__ PARAMS ((const char *__msgid));
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current
+ LC_MESSAGES locale. */
+extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
+extern char *dgettext__ PARAMS ((const char *__domainname,
+ const char *__msgid));
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
+ locale. */
+extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
+ int __category));
+extern char *dcgettext__ PARAMS ((const char *__domainname,
+ const char *__msgid, int __category));
+
+
+/* Set the current default message catalog to DOMAINNAME.
+ If DOMAINNAME is null, return the current default.
+ If DOMAINNAME is "", reset to the default of "messages". */
+extern char *textdomain PARAMS ((const char *__domainname));
+extern char *textdomain__ PARAMS ((const char *__domainname));
+
+/* Specify that the DOMAINNAME message catalog will be found
+ in DIRNAME rather than in the system locale data base. */
+extern char *bindtextdomain PARAMS ((const char *__domainname,
+ const char *__dirname));
+extern char *bindtextdomain__ PARAMS ((const char *__domainname,
+ const char *__dirname));
+
+#if ENABLE_NLS
+
+/* Solaris 2.3 has the gettext function but dcgettext is missing.
+ So we omit this optimization for Solaris 2.3. BTW, Solaris 2.4
+ has dcgettext. */
+# if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT)
+
+# define gettext(Msgid) \
+ dgettext (NULL, Msgid)
+
+# define dgettext(Domainname, Msgid) \
+ dcgettext (Domainname, Msgid, LC_MESSAGES)
+
+# if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7
+/* This global variable is defined in loadmsgcat.c. We need a sign,
+ whether a new catalog was loaded, which can be associated with all
+ translations. */
+extern int _nl_msg_cat_cntr;
+
+# define dcgettext(Domainname, Msgid, Category) \
+ (__extension__ \
+ ({ \
+ char *__result; \
+ if (__builtin_constant_p (Msgid)) \
+ { \
+ static char *__translation__; \
+ static int __catalog_counter__; \
+ if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \
+ { \
+ __translation__ = \
+ dcgettext__ (Domainname, Msgid, Category); \
+ __catalog_counter__ = _nl_msg_cat_cntr; \
+ } \
+ __result = __translation__; \
+ } \
+ else \
+ __result = dcgettext__ (Domainname, Msgid, Category); \
+ __result; \
+ }))
+# endif
+# endif
+
+#else
+
+# define gettext(Msgid) (Msgid)
+# define dgettext(Domainname, Msgid) (Msgid)
+# define dcgettext(Domainname, Msgid, Category) (Msgid)
+# define textdomain(Domainname) while (0) /* nothing */
+# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
+
+#endif
+
+/* @@ begin of epilog @@ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/intl/libintl.glibc b/intl/libintl.glibc
new file mode 100644
index 00000000000..8e5b8f9e694
--- /dev/null
+++ b/intl/libintl.glibc
@@ -0,0 +1,111 @@
+/* libgettext.h -- Message catalogs for internationalization.
+Copyright (C) 1995 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+Contributed by Ulrich Drepper.
+This file is derived from the file libgettext.h in the GNU gettext package.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef _LIBINTL_H
+#define _LIBINTL_H 1
+#include <features.h>
+
+#include <locale.h>
+
+#define __need_NULL
+#include <stddef.h>
+
+/* We define an additional symbol to signal that we use the GNU
+ implementation of gettext. */
+#define __USE_GNU_GETTEXT 1
+
+__BEGIN_DECLS
+
+/* Look up MSGID in the current default message catalog for the current
+ LC_MESSAGES locale. If not found, returns MSGID itself (the default
+ text). */
+extern char *gettext __P ((__const char *__msgid));
+extern char *__gettext __P ((__const char *__msgid));
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current
+ LC_MESSAGES locale. */
+extern char *dgettext __P ((__const char *__domainname,
+ __const char *__msgid));
+extern char *__dgettext __P ((__const char *__domainname,
+ __const char *__msgid));
+
+/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
+ locale. */
+extern char *dcgettext __P ((__const char *__domainname,
+ __const char *__msgid, int __category));
+extern char *__dcgettext __P ((__const char *__domainname,
+ __const char *__msgid, int __category));
+
+
+/* Set the current default message catalog to DOMAINNAME.
+ If DOMAINNAME is null, return the current default.
+ If DOMAINNAME is "", reset to the default of "messages". */
+extern char *textdomain __P ((__const char *__domainname));
+extern char *__textdomain __P ((__const char *__domainname));
+
+/* Specify that the DOMAINNAME message catalog will be found
+ in DIRNAME rather than in the system locale data base. */
+extern char *bindtextdomain __P ((__const char *__domainname,
+ __const char *__dirname));
+extern char *__bindtextdomain __P ((__const char *__domainname,
+ __const char *__dirname));
+
+
+/* Optimized version of the function above. */
+#if defined __OPTIMIZED
+/* These must be a macro. Inlined functions are useless because the
+ `__builtin_constant_p' predicate in dcgettext would always return
+ false. */
+
+# define gettext(msgid) dgettext (NULL, msgid)
+
+# define dgettext(domainname, msgid) \
+ dcgettext (domainname, msgid, LC_MESSAGES)
+
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define dcgettext(domainname, msgid, category) \
+ (__extension__ \
+ ({ \
+ char *result; \
+ if (__builtin_constant_p (msgid)) \
+ { \
+ extern int _nl_msg_cat_cntr; \
+ static char *__translation__; \
+ static int __catalog_counter__; \
+ if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \
+ { \
+ __translation__ = \
+ __dcgettext ((domainname), (msgid), (category)); \
+ __catalog_counter__ = _nl_msg_cat_cntr; \
+ } \
+ result = __translation__; \
+ } \
+ else \
+ result = __dcgettext ((domainname), (msgid), (category)); \
+ result; \
+ }))
+# endif
+#endif /* Optimizing. */
+
+
+__END_DECLS
+
+#endif /* libintl.h */
diff --git a/intl/linux-msg.sed b/intl/linux-msg.sed
new file mode 100644
index 00000000000..5918e720a9a
--- /dev/null
+++ b/intl/linux-msg.sed
@@ -0,0 +1,100 @@
+# po2msg.sed - Convert Uniforum style .po file to Linux style .msg file
+# Copyright (C) 1995 Free Software Foundation, Inc.
+# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# The first directive in the .msg should be the definition of the
+# message set number. We use always set number 1.
+#
+1 {
+ i\
+$set 1 # Automatically created by po2msg.sed
+ h
+ s/.*/0/
+ x
+}
+#
+# Mitch's old catalog format does not allow comments.
+#
+# We copy the original message as a comment into the .msg file.
+#
+/^msgid/ {
+ s/msgid[ ]*"//
+#
+# This does not work now with the new format.
+# /"$/! {
+# s/\\$//
+# s/$/ ... (more lines following)"/
+# }
+ x
+# The following nice solution is by
+# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de>
+ td
+# Increment a decimal number in pattern space.
+# First hide trailing `9' digits.
+ :d
+ s/9\(_*\)$/_\1/
+ td
+# Assure at least one digit is available.
+ s/^\(_*\)$/0\1/
+# Increment the last digit.
+ s/8\(_*\)$/9\1/
+ s/7\(_*\)$/8\1/
+ s/6\(_*\)$/7\1/
+ s/5\(_*\)$/6\1/
+ s/4\(_*\)$/5\1/
+ s/3\(_*\)$/4\1/
+ s/2\(_*\)$/3\1/
+ s/1\(_*\)$/2\1/
+ s/0\(_*\)$/1\1/
+# Convert the hidden `9' digits to `0's.
+ s/_/0/g
+ x
+ G
+ s/\(.*\)"\n\([0-9]*\)/$ #\2 Original Message:(\1)/p
+}
+#
+# The .msg file contains, other then the .po file, only the translations
+# but each given a unique ID. Starting from 1 and incrementing by 1 for
+# each message we assign them to the messages.
+# It is important that the .po file used to generate the cat-id-tbl.c file
+# (with po-to-tbl) is the same as the one used here. (At least the order
+# of declarations must not be changed.)
+#
+/^msgstr/ {
+ s/msgstr[ ]*"\(.*\)"/# \1/
+# Clear substitution flag.
+ tb
+# Append the next line.
+ :b
+ N
+# Look whether second part is continuation line.
+ s/\(.*\n\)"\(.*\)"/\1\2/
+# Yes, then branch.
+ ta
+ P
+ D
+# Note that D includes a jump to the start!!
+# We found a continuation line. But before printing insert '\'.
+ :a
+ s/\(.*\)\(\n.*\)/\1\\\2/
+ P
+# We cannot use D here.
+ s/.*\n\(.*\)/\1/
+ tb
+}
+d
diff --git a/intl/loadinfo.h b/intl/loadinfo.h
new file mode 100644
index 00000000000..c67c2eb2e8e
--- /dev/null
+++ b/intl/loadinfo.h
@@ -0,0 +1,58 @@
+#ifndef PARAMS
+# if __STDC__
+# define PARAMS(args) args
+# else
+# define PARAMS(args) ()
+# endif
+#endif
+
+/* Encoding of locale name parts. */
+#define CEN_REVISION 1
+#define CEN_SPONSOR 2
+#define CEN_SPECIAL 4
+#define XPG_NORM_CODESET 8
+#define XPG_CODESET 16
+#define TERRITORY 32
+#define CEN_AUDIENCE 64
+#define XPG_MODIFIER 128
+
+#define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE)
+#define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER)
+
+
+struct loaded_l10nfile
+{
+ const char *filename;
+ int decided;
+
+ const void *data;
+
+ struct loaded_l10nfile *next;
+ struct loaded_l10nfile *successor[1];
+};
+
+
+extern const char *_nl_normalize_codeset PARAMS ((const char *codeset,
+ size_t name_len));
+
+extern struct loaded_l10nfile *
+_nl_make_l10nflist PARAMS ((struct loaded_l10nfile **l10nfile_list,
+ const char *dirlist, size_t dirlist_len, int mask,
+ const char *language, const char *territory,
+ const char *codeset,
+ const char *normalized_codeset,
+ const char *modifier, const char *special,
+ const char *sponsor, const char *revision,
+ const char *filename, int do_allocate));
+
+
+extern const char *_nl_expand_alias PARAMS ((const char *name));
+
+extern int _nl_explode_name PARAMS ((char *name, const char **language,
+ const char **modifier,
+ const char **territory,
+ const char **codeset,
+ const char **normalized_codeset,
+ const char **special,
+ const char **sponsor,
+ const char **revision));
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
new file mode 100644
index 00000000000..73e90a9190f
--- /dev/null
+++ b/intl/loadmsgcat.c
@@ -0,0 +1,199 @@
+/* Load needed message catalogs
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#endif
+
+#if defined HAVE_UNISTD_H || defined _LIBC
+# include <unistd.h>
+#endif
+
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP) || defined _LIBC
+# include <sys/mman.h>
+#endif
+
+#include "gettext.h"
+#include "gettextP.h"
+
+/* @@ end of prolog @@ */
+
+#ifdef _LIBC
+/* Rename the non ISO C functions. This is required by the standard
+ because some ISO C functions will require linking with this object
+ file and the name space must not be polluted. */
+# define fstat __fstat
+# define open __open
+# define close __close
+# define read __read
+# define mmap __mmap
+# define munmap __munmap
+#endif
+
+/* We need a sign, whether a new catalog was loaded, which can be associated
+ with all translations. This is important if the translations are
+ cached by one of GCC's features. */
+int _nl_msg_cat_cntr = 0;
+
+
+/* Load the message catalogs specified by FILENAME. If it is no valid
+ message catalog do nothing. */
+void
+_nl_load_domain (domain_file)
+ struct loaded_l10nfile *domain_file;
+{
+ int fd;
+ struct stat st;
+ struct mo_file_header *data = (struct mo_file_header *) -1;
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
+ || defined _LIBC
+ int use_mmap = 0;
+#endif
+ struct loaded_domain *domain;
+
+ domain_file->decided = 1;
+ domain_file->data = NULL;
+
+ /* If the record does not represent a valid locale the FILENAME
+ might be NULL. This can happen when according to the given
+ specification the locale file name is different for XPG and CEN
+ syntax. */
+ if (domain_file->filename == NULL)
+ return;
+
+ /* Try to open the addressed file. */
+ fd = open (domain_file->filename, O_RDONLY);
+ if (fd == -1)
+ return;
+
+ /* We must know about the size of the file. */
+ if (fstat (fd, &st) != 0
+ && st.st_size < (off_t) sizeof (struct mo_file_header))
+ {
+ /* Something went wrong. */
+ close (fd);
+ return;
+ }
+
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
+ || defined _LIBC
+ /* Now we are ready to load the file. If mmap() is available we try
+ this first. If not available or it failed we try to load it. */
+ data = (struct mo_file_header *) mmap (NULL, st.st_size, PROT_READ,
+ MAP_PRIVATE, fd, 0);
+
+ if (data != (struct mo_file_header *) -1)
+ {
+ /* mmap() call was successful. */
+ close (fd);
+ use_mmap = 1;
+ }
+#endif
+
+ /* If the data is not yet available (i.e. mmap'ed) we try to load
+ it manually. */
+ if (data == (struct mo_file_header *) -1)
+ {
+ off_t to_read;
+ char *read_ptr;
+
+ data = (struct mo_file_header *) malloc (st.st_size);
+ if (data == NULL)
+ return;
+
+ to_read = st.st_size;
+ read_ptr = (char *) data;
+ do
+ {
+ long int nb = (long int) read (fd, read_ptr, to_read);
+ if (nb == -1)
+ {
+ close (fd);
+ return;
+ }
+
+ read_ptr += nb;
+ to_read -= nb;
+ }
+ while (to_read > 0);
+
+ close (fd);
+ }
+
+ /* Using the magic number we can test whether it really is a message
+ catalog file. */
+ if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED)
+ {
+ /* The magic number is wrong: not a message catalog file. */
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
+ || defined _LIBC
+ if (use_mmap)
+ munmap ((caddr_t) data, st.st_size);
+ else
+#endif
+ free (data);
+ return;
+ }
+
+ domain_file->data
+ = (struct loaded_domain *) malloc (sizeof (struct loaded_domain));
+ if (domain_file->data == NULL)
+ return;
+
+ domain = (struct loaded_domain *) domain_file->data;
+ domain->data = (char *) data;
+ domain->must_swap = data->magic != _MAGIC;
+
+ /* Fill in the information about the available tables. */
+ switch (W (domain->must_swap, data->revision))
+ {
+ case 0:
+ domain->nstrings = W (domain->must_swap, data->nstrings);
+ domain->orig_tab = (struct string_desc *)
+ ((char *) data + W (domain->must_swap, data->orig_tab_offset));
+ domain->trans_tab = (struct string_desc *)
+ ((char *) data + W (domain->must_swap, data->trans_tab_offset));
+ domain->hash_size = W (domain->must_swap, data->hash_tab_size);
+ domain->hash_tab = (nls_uint32 *)
+ ((char *) data + W (domain->must_swap, data->hash_tab_offset));
+ break;
+ default:
+ /* This is an illegal revision. */
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
+ || defined _LIBC
+ if (use_mmap)
+ munmap ((caddr_t) data, st.st_size);
+ else
+#endif
+ free (data);
+ free (domain);
+ domain_file->data = NULL;
+ return;
+ }
+
+ /* Show that one domain is changed. This might make some cached
+ translations invalid. */
+ ++_nl_msg_cat_cntr;
+}
diff --git a/intl/localealias.c b/intl/localealias.c
new file mode 100644
index 00000000000..00d91941b9b
--- /dev/null
+++ b/intl/localealias.c
@@ -0,0 +1,378 @@
+/* Handle aliases for locale names
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+# define HAVE_ALLOCA 1
+#else
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#else
+char *getenv ();
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# else
+void free ();
+# endif
+#endif
+
+#if defined HAVE_STRING_H || defined _LIBC
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+# endif
+# include <string.h>
+#else
+# include <strings.h>
+# ifndef memcpy
+# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
+# endif
+#endif
+#if !HAVE_STRCHR && !defined _LIBC
+# ifndef strchr
+# define strchr index
+# endif
+#endif
+
+#include "gettext.h"
+#include "gettextP.h"
+
+/* @@ end of prolog @@ */
+
+#ifdef _LIBC
+/* Rename the non ANSI C functions. This is required by the standard
+ because some ANSI C functions will require linking with this object
+ file and the name space must not be polluted. */
+# define strcasecmp __strcasecmp
+#endif
+
+
+/* For those loosing systems which don't have `alloca' we have to add
+ some additional code emulating it. */
+#ifdef HAVE_ALLOCA
+/* Nothing has to be done. */
+# define ADD_BLOCK(list, address) /* nothing */
+# define FREE_BLOCKS(list) /* nothing */
+#else
+struct block_list
+{
+ void *address;
+ struct block_list *next;
+};
+# define ADD_BLOCK(list, addr) \
+ do { \
+ struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \
+ /* If we cannot get a free block we cannot add the new element to \
+ the list. */ \
+ if (newp != NULL) { \
+ newp->address = (addr); \
+ newp->next = (list); \
+ (list) = newp; \
+ } \
+ } while (0)
+# define FREE_BLOCKS(list) \
+ do { \
+ while (list != NULL) { \
+ struct block_list *old = list; \
+ list = list->next; \
+ free (old); \
+ } \
+ } while (0)
+# undef alloca
+# define alloca(size) (malloc (size))
+#endif /* have alloca */
+
+
+struct alias_map
+{
+ const char *alias;
+ const char *value;
+};
+
+
+static struct alias_map *map;
+static size_t nmap = 0;
+static size_t maxmap = 0;
+
+
+/* Prototypes for local functions. */
+static size_t read_alias_file PARAMS ((const char *fname, int fname_len));
+static void extend_alias_table PARAMS ((void));
+static int alias_compare PARAMS ((const struct alias_map *map1,
+ const struct alias_map *map2));
+
+
+const char *
+_nl_expand_alias (name)
+ const char *name;
+{
+ static const char *locale_alias_path = LOCALE_ALIAS_PATH;
+ struct alias_map *retval;
+ size_t added;
+
+ do
+ {
+ struct alias_map item;
+
+ item.alias = name;
+
+ if (nmap > 0)
+ retval = (struct alias_map *) bsearch (&item, map, nmap,
+ sizeof (struct alias_map),
+ (int (*) PARAMS ((const void *,
+ const void *))
+ ) alias_compare);
+ else
+ retval = NULL;
+
+ /* We really found an alias. Return the value. */
+ if (retval != NULL)
+ return retval->value;
+
+ /* Perhaps we can find another alias file. */
+ added = 0;
+ while (added == 0 && locale_alias_path[0] != '\0')
+ {
+ const char *start;
+
+ while (locale_alias_path[0] == ':')
+ ++locale_alias_path;
+ start = locale_alias_path;
+
+ while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':')
+ ++locale_alias_path;
+
+ if (start < locale_alias_path)
+ added = read_alias_file (start, locale_alias_path - start);
+ }
+ }
+ while (added != 0);
+
+ return NULL;
+}
+
+
+static size_t
+read_alias_file (fname, fname_len)
+ const char *fname;
+ int fname_len;
+{
+#ifndef HAVE_ALLOCA
+ struct block_list *block_list = NULL;
+#endif
+ FILE *fp;
+ char *full_fname;
+ size_t added;
+ static const char aliasfile[] = "/locale.alias";
+
+ full_fname = (char *) alloca (fname_len + sizeof aliasfile);
+ ADD_BLOCK (block_list, full_fname);
+ memcpy (full_fname, fname, fname_len);
+ memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
+
+ fp = fopen (full_fname, "r");
+ if (fp == NULL)
+ {
+ FREE_BLOCKS (block_list);
+ return 0;
+ }
+
+ added = 0;
+ while (!feof (fp))
+ {
+ /* It is a reasonable approach to use a fix buffer here because
+ a) we are only interested in the first two fields
+ b) these fields must be usable as file names and so must not
+ be that long
+ */
+ char buf[BUFSIZ];
+ char *alias;
+ char *value;
+ char *cp;
+
+ if (fgets (buf, BUFSIZ, fp) == NULL)
+ /* EOF reached. */
+ break;
+
+ cp = buf;
+ /* Ignore leading white space. */
+ while (isspace (cp[0]))
+ ++cp;
+
+ /* A leading '#' signals a comment line. */
+ if (cp[0] != '\0' && cp[0] != '#')
+ {
+ alias = cp++;
+ while (cp[0] != '\0' && !isspace (cp[0]))
+ ++cp;
+ /* Terminate alias name. */
+ if (cp[0] != '\0')
+ *cp++ = '\0';
+
+ /* Now look for the beginning of the value. */
+ while (isspace (cp[0]))
+ ++cp;
+
+ if (cp[0] != '\0')
+ {
+ char *tp;
+ size_t len;
+
+ value = cp++;
+ while (cp[0] != '\0' && !isspace (cp[0]))
+ ++cp;
+ /* Terminate value. */
+ if (cp[0] == '\n')
+ {
+ /* This has to be done to make the following test
+ for the end of line possible. We are looking for
+ the terminating '\n' which do not overwrite here. */
+ *cp++ = '\0';
+ *cp = '\n';
+ }
+ else if (cp[0] != '\0')
+ *cp++ = '\0';
+
+ if (nmap >= maxmap)
+ extend_alias_table ();
+
+ /* We cannot depend on strdup available in the libc. Sigh! */
+ len = strlen (alias) + 1;
+ tp = (char *) malloc (len);
+ if (tp == NULL)
+ {
+ FREE_BLOCKS (block_list);
+ return added;
+ }
+ memcpy (tp, alias, len);
+ map[nmap].alias = tp;
+
+ len = strlen (value) + 1;
+ tp = (char *) malloc (len);
+ if (tp == NULL)
+ {
+ FREE_BLOCKS (block_list);
+ return added;
+ }
+ memcpy (tp, value, len);
+ map[nmap].value = tp;
+
+ ++nmap;
+ ++added;
+ }
+ }
+
+ /* Possibly not the whole line fits into the buffer. Ignore
+ the rest of the line. */
+ while (strchr (cp, '\n') == NULL)
+ {
+ cp = buf;
+ if (fgets (buf, BUFSIZ, fp) == NULL)
+ /* Make sure the inner loop will be left. The outer loop
+ will exit at the `feof' test. */
+ *cp = '\n';
+ }
+ }
+
+ /* Should we test for ferror()? I think we have to silently ignore
+ errors. --drepper */
+ fclose (fp);
+
+ if (added > 0)
+ qsort (map, nmap, sizeof (struct alias_map),
+ (int (*) PARAMS ((const void *, const void *))) alias_compare);
+
+ FREE_BLOCKS (block_list);
+ return added;
+}
+
+
+static void
+extend_alias_table ()
+{
+ size_t new_size;
+ struct alias_map *new_map;
+
+ new_size = maxmap == 0 ? 100 : 2 * maxmap;
+ new_map = (struct alias_map *) malloc (new_size
+ * sizeof (struct alias_map));
+ if (new_map == NULL)
+ /* Simply don't extend: we don't have any more core. */
+ return;
+
+ memcpy (new_map, map, nmap * sizeof (struct alias_map));
+
+ if (maxmap != 0)
+ free (map);
+
+ map = new_map;
+ maxmap = new_size;
+}
+
+
+static int
+alias_compare (map1, map2)
+ const struct alias_map *map1;
+ const struct alias_map *map2;
+{
+#if defined _LIBC || defined HAVE_STRCASECMP
+ return strcasecmp (map1->alias, map2->alias);
+#else
+ const unsigned char *p1 = (const unsigned char *) map1->alias;
+ const unsigned char *p2 = (const unsigned char *) map2->alias;
+ unsigned char c1, c2;
+
+ if (p1 == p2)
+ return 0;
+
+ do
+ {
+ /* I know this seems to be odd but the tolower() function in
+ some systems libc cannot handle nonalpha characters. */
+ c1 = isupper (*p1) ? tolower (*p1) : *p1;
+ c2 = isupper (*p2) ? tolower (*p2) : *p2;
+ if (c1 == '\0')
+ break;
+ ++p1;
+ ++p2;
+ }
+ while (c1 == c2);
+
+ return c1 - c2;
+#endif
+}
diff --git a/intl/po2tbl.sed.in b/intl/po2tbl.sed.in
new file mode 100644
index 00000000000..b3bcca4d730
--- /dev/null
+++ b/intl/po2tbl.sed.in
@@ -0,0 +1,102 @@
+# po2tbl.sed - Convert Uniforum style .po file to lookup table for catgets
+# Copyright (C) 1995 Free Software Foundation, Inc.
+# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+1 {
+ i\
+/* Automatically generated by po2tbl.sed from @PACKAGE NAME@.pot. */\
+\
+#if HAVE_CONFIG_H\
+# include <config.h>\
+#endif\
+\
+#include "libgettext.h"\
+\
+const struct _msg_ent _msg_tbl[] = {
+ h
+ s/.*/0/
+ x
+}
+#
+# Write msgid entries in C array form.
+#
+/^msgid/ {
+ s/msgid[ ]*\(".*"\)/ {\1/
+ tb
+# Append the next line
+ :b
+ N
+# Look whether second part is continuation line.
+ s/\(.*\)"\(\n\)"\(.*"\)/\1\2\3/
+# Yes, then branch.
+ ta
+# Because we assume that the input file correctly formed the line
+# just read cannot be again be a msgid line. So it's safe to ignore
+# it.
+ s/\(.*\)\n.*/\1/
+ bc
+# We found a continuation line. But before printing insert '\'.
+ :a
+ s/\(.*\)\(\n.*\)/\1\\\2/
+ P
+# We cannot use D here.
+ s/.*\n\(.*\)/\1/
+# Some buggy seds do not clear the `successful substitution since last ``t'''
+# flag on `N', so we do a `t' here to clear it.
+ tb
+# Not reached
+ :c
+ x
+# The following nice solution is by
+# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de>
+ td
+# Increment a decimal number in pattern space.
+# First hide trailing `9' digits.
+ :d
+ s/9\(_*\)$/_\1/
+ td
+# Assure at least one digit is available.
+ s/^\(_*\)$/0\1/
+# Increment the last digit.
+ s/8\(_*\)$/9\1/
+ s/7\(_*\)$/8\1/
+ s/6\(_*\)$/7\1/
+ s/5\(_*\)$/6\1/
+ s/4\(_*\)$/5\1/
+ s/3\(_*\)$/4\1/
+ s/2\(_*\)$/3\1/
+ s/1\(_*\)$/2\1/
+ s/0\(_*\)$/1\1/
+# Convert the hidden `9' digits to `0's.
+ s/_/0/g
+ x
+ G
+ s/\(.*\)\n\([0-9]*\)/\1, \2},/
+ s/\(.*\)"$/\1/
+ p
+}
+#
+# Last line.
+#
+$ {
+ i\
+};\
+
+ g
+ s/0*\(.*\)/int _msg_tbl_length = \1;/p
+}
+d
diff --git a/intl/textdomain.c b/intl/textdomain.c
new file mode 100644
index 00000000000..55d93406a8a
--- /dev/null
+++ b/intl/textdomain.c
@@ -0,0 +1,106 @@
+/* Implementation of the textdomain(3) function
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#endif
+
+#if defined STDC_HEADERS || defined HAVE_STRING_H || defined _LIBC
+# include <string.h>
+#else
+# include <strings.h>
+# ifndef memcpy
+# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
+# endif
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+
+/* @@ end of prolog @@ */
+
+/* Name of the default text domain. */
+extern const char _nl_default_default_domain[];
+
+/* Default text domain in which entries for gettext(3) are to be found. */
+extern const char *_nl_current_default_domain;
+
+
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define TEXTDOMAIN __textdomain
+# define strdup(str) __strdup (str)
+#else
+# define TEXTDOMAIN textdomain__
+#endif
+
+/* Set the current default message catalog to DOMAINNAME.
+ If DOMAINNAME is null, return the current default.
+ If DOMAINNAME is "", reset to the default of "messages". */
+char *
+TEXTDOMAIN (domainname)
+ const char *domainname;
+{
+ char *old;
+
+ /* A NULL pointer requests the current setting. */
+ if (domainname == NULL)
+ return (char *) _nl_current_default_domain;
+
+ old = (char *) _nl_current_default_domain;
+
+ /* If domain name is the null string set to default domain "messages". */
+ if (domainname[0] == '\0'
+ || strcmp (domainname, _nl_default_default_domain) == 0)
+ _nl_current_default_domain = _nl_default_default_domain;
+ else
+ {
+ /* If the following malloc fails `_nl_current_default_domain'
+ will be NULL. This value will be returned and so signals we
+ are out of core. */
+#if defined _LIBC || defined HAVE_STRDUP
+ _nl_current_default_domain = strdup (domainname);
+#else
+ size_t len = strlen (domainname) + 1;
+ char *cp = (char *) malloc (len);
+ if (cp != NULL)
+ memcpy (cp, domainname, len);
+ _nl_current_default_domain = cp;
+#endif
+ }
+
+ if (old != _nl_default_default_domain)
+ free (old);
+
+ return (char *) _nl_current_default_domain;
+}
+
+#ifdef _LIBC
+/* Alias for function name in GNU C Library. */
+weak_alias (__textdomain, textdomain);
+#endif
diff --git a/intl/xopen-msg.sed b/intl/xopen-msg.sed
new file mode 100644
index 00000000000..b19c0bbd0ec
--- /dev/null
+++ b/intl/xopen-msg.sed
@@ -0,0 +1,104 @@
+# po2msg.sed - Convert Uniforum style .po file to X/Open style .msg file
+# Copyright (C) 1995 Free Software Foundation, Inc.
+# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# The first directive in the .msg should be the definition of the
+# message set number. We use always set number 1.
+#
+1 {
+ i\
+$set 1 # Automatically created by po2msg.sed
+ h
+ s/.*/0/
+ x
+}
+#
+# We copy all comments into the .msg file. Perhaps they can help.
+#
+/^#/ s/^#[ ]*/$ /p
+#
+# We copy the original message as a comment into the .msg file.
+#
+/^msgid/ {
+# Does not work now
+# /"$/! {
+# s/\\$//
+# s/$/ ... (more lines following)"/
+# }
+ s/^msgid[ ]*"\(.*\)"$/$ Original Message: \1/
+ p
+}
+#
+# The .msg file contains, other then the .po file, only the translations
+# but each given a unique ID. Starting from 1 and incrementing by 1 for
+# each message we assign them to the messages.
+# It is important that the .po file used to generate the cat-id-tbl.c file
+# (with po-to-tbl) is the same as the one used here. (At least the order
+# of declarations must not be changed.)
+#
+/^msgstr/ {
+ s/msgstr[ ]*"\(.*\)"/\1/
+ x
+# The following nice solution is by
+# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de>
+ td
+# Increment a decimal number in pattern space.
+# First hide trailing `9' digits.
+ :d
+ s/9\(_*\)$/_\1/
+ td
+# Assure at least one digit is available.
+ s/^\(_*\)$/0\1/
+# Increment the last digit.
+ s/8\(_*\)$/9\1/
+ s/7\(_*\)$/8\1/
+ s/6\(_*\)$/7\1/
+ s/5\(_*\)$/6\1/
+ s/4\(_*\)$/5\1/
+ s/3\(_*\)$/4\1/
+ s/2\(_*\)$/3\1/
+ s/1\(_*\)$/2\1/
+ s/0\(_*\)$/1\1/
+# Convert the hidden `9' digits to `0's.
+ s/_/0/g
+ x
+# Bring the line in the format `<number> <message>'
+ G
+ s/^[^\n]*$/& /
+ s/\(.*\)\n\([0-9]*\)/\2 \1/
+# Clear flag from last substitution.
+ tb
+# Append the next line.
+ :b
+ N
+# Look whether second part is a continuation line.
+ s/\(.*\n\)"\(.*\)"/\1\2/
+# Yes, then branch.
+ ta
+ P
+ D
+# Note that `D' includes a jump to the start!!
+# We found a continuation line. But before printing insert '\'.
+ :a
+ s/\(.*\)\(\n.*\)/\1\\\2/
+ P
+# We cannot use the sed command `D' here
+ s/.*\n\(.*\)/\1/
+ tb
+}
+d
diff --git a/libiberty/COPYING.LIB b/libiberty/COPYING.LIB
new file mode 100644
index 00000000000..161a3d1d47b
--- /dev/null
+++ b/libiberty/COPYING.LIB
@@ -0,0 +1,482 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
new file mode 100644
index 00000000000..7032febe630
--- /dev/null
+++ b/libiberty/ChangeLog
@@ -0,0 +1,3232 @@
+1999-04-20 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ Fix from Dale Hawkins:
+ * cplus-dem.c (mop_up): Set typevec_size to zero, so it'll be
+ reallocated properly if we use it again.
+
+ * cplus-dem.c (demangle_fund_type): Check for buffer overrun. Be
+ stricter about syntax. Always null-terminate string.
+
+ Fix from Marcus Daniels:
+ * cplus-dem.c (demangle_fund_type): Don't run off the end of the
+ identifier looking for another underscore.
+
+1999-04-11 Richard Henderson <rth@cygnus.com>
+
+ * alloca-conf.h (alloca) [C_ALLOCA]: Don't use Gcc builtin
+ or <alloca.h>.
+ * clock.c (GNU_HZ): New definition.
+ (clock): Use it.
+ * getruntime.c: Likewise.
+
+ * config.table: Use mh-beos.
+ * config/mh-beos: New file.
+
+1999-04-01 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ * cplus-dem.c: Attempt to handle overflows in counts with some
+ semblance of grace.
+ (consume_count): Detect overflows. Return -1 to indicate errors,
+ instead of zero.
+ (demangle_template_value_parm, demangle_template): Handle change
+ to consume_count's return convention.
+
+Thu Apr 8 14:43:28 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * xmalloc.c, pexecute.c: Define __CYGWIN__ when being compiled
+ with old __CYGWIN32__ compiler.
+
+1999-04-02 Mark Mitchell <mark@codesourcery.com>
+
+ * splay-tree.h (splay_tree_compare_pointers): Define.
+
+1999-03-30 Mark Mitchell <mark@codesourcery.com>
+
+ * splay-tree.c (splay_tree_compare_ints): Define.
+
+1999-03-30 Tom Tromey <tromey@cygnus.com>
+
+ * cplus-dem.c (consume_count): If `count' wraps, return 0 and
+ don't advance input pointer.
+ (demangle_class_name): If consume_count didn't find a count, do
+ nothing. Don't bother with `strlen' sanity check; consume_count
+ does it for us.
+
+1999-03-16 Stan Shebs <shebs@andros.cygnus.com>
+
+ From Art Haas <ahaas@neosoft.com>:
+ * cplus-dem.c (demangle_prefix): Don't grab all the '__' strings
+ when doing arm or hp style.
+ (demangle_nested_args): Decr forgetting_types field when done.
+
+Thu Mar 11 01:22:58 1999 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * pexecute.c (__CYGWIN32__): Rename to
+ (__CYGWIN__): this.
+ * xmalloc.c: Likewise.
+
+ Changes to support i386-pc-uwin.
+ * configure.in (*-*-uwin*): Workaround for vfork bug.
+ * configure: Regenerate.
+ * pexecute.c (pexecute): Be like standard Unix.
+ (pwait): Likewise.
+ * xmalloc.c (first_break): Define.
+ (xmalloc_set_program_name): Use.
+ (xmalloc): Use.
+
+Thu Mar 11 01:07:55 1999 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ * config.table: Cleanup and add mh-*pic handling for alpha, arm, powerpc
+
+Sun Feb 28 22:30:44 1999 Geoffrey Noer <noer@cygnus.com>
+
+ * config.table: Check cygwin*, not cygwin32*.
+
+Tue Feb 9 16:39:01 1999 Dave Brolley <brolley@cygnus.com>
+
+ * Makefile.in: Change mkstemp -> mkstemps.
+
+Tue Feb 9 01:12:27 1999 Marc Espie <Marc.Espie@liafa.jussieu.fr>
+
+ * Makefile.in (REQUIRED_OFILES): remove mkstemp.o
+ * configure.in (funcs): Check for and conditionally add mkstemps to
+ the list of functions libiberty will provide.
+ * configure: Rebuilt.
+
+Wed Feb 3 00:01:15 1999 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * clock.c (HZ): Define in terms of (ISO C) CLOCKS_PER_SEC on
+ platforms that don't have HZ.
+ * getruntime.c (HZ): Likewise.
+
+Sat Jan 30 13:28:04 1999 Richard Henderson <rth@cygnus.com>
+
+ * Makefile.in (xstrdup.o): Depend on config.h.
+
+Wed Jan 13 07:26:44 1999 H.J. Lu (hjl@gnu.org)
+
+ * cplus-dem.c (mop_up): Set work->previous_argument to NULL after
+ freeing it.
+
+Wed Jan 13 14:16:36 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed.
+
+Tue Jan 5 15:58:29 1999 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * Makefile.in (CFILES): fix typo, splay-tree.c instead of
+ splay-tree.o.
+
+1999-01-04 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * configure.in: Require autoconf 2.12.1 or higher.
+
+1998-12-30 Michael Meissner <meissner@cygnus.com>
+
+ * random.c (NULL): Don't redefine NULL if it is already defined.
+
+Tue Dec 22 09:43:35 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * argv.c (buildargv): Cast the result of alloca in assignment.
+
+ * choose-temp.c: Include stdlib.h.
+
+ * cplus-dem.c (demangle_arm_pt): Remove unused prototype.
+ (snarf_numeric_literal): Constify first parameter.
+ (code_for_qualifier): Avoid a gcc extension, make the parameter an
+ int, not a char.
+ (demangle_qualifier): Likewise.
+ (demangle_signature): Cast the argument of a ctype function to
+ unsigned char.
+ (arm_pt): Add parens around assignment used as truth value.
+ (demangle_arm_hp_template): Constify variable `args'.
+ (do_hpacc_template_const_value): Cast the argument of a ctype
+ function to unsigned char.
+ (do_hpacc_template_literal): Remove unused variable `i'.
+ (snarf_numeric_literal): Constify parameter `args'.
+ Cast the argument of a ctype function to unsigned char.
+
+ * floatformat.c (floatformat_to_double): Add explicit braces to
+ avoid ambiguous `else'.
+
+ * fnmatch.c (fnmatch): Change type of variables `c', `c1',
+ `cstart' and `cend' to unsigned char. Cast the argument of macro
+ `FOLD', which uses ctype functions, to unsigned char.
+
+ * objalloc.c (free): Add prototype.
+
+Sun Dec 20 16:03:46 1998 Hans-Peter Nilsson <hp@axis.se>
+
+ * Makefile.in (CFILES): Fix typo: splay-tree.c, not splay-tree.o
+
+Fri Dec 18 17:50:18 1998 David Taylor <taylor@texas.cygnus.com>
+
+ * cplus-dem.c (demangle_arm_pt): remove declaration -- function
+ doesn't exist.
+ (do_hpacc_template_literal): remove unused variable `i'.
+
+Fri Dec 18 16:11:43 EST 1998 Andrew MacLeod <amacleod@cygnus.com>
+
+ * cplus-dem.c (demangle_fund_type): Process CV and u codes before
+ bumping the pointer we read from. Also prepend these codes,
+ as we do in other places.
+
+1998-12-18 Nick Clifton <nickc@cygnus.com>
+
+ * cplus-dem.c (demangle_arm_hp_template): Make variable 'args' be
+ 'const char *' in order to match its usage when calling siblings.
+ (snarf_numeric_literal): Make first arg 'const char **' in order
+ to match usage.
+
+Mon Dec 14 09:55:50 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * choose-temp.c: Don't check IN_GCC anymore.
+
+ * floatformat.c (floatformat_from_double): Use `const', not `CONST'.
+ * memchr.c (memchr): Likewise.
+ * memcpy.c (memcpy): Likewise.
+ * memmove.c (memmove): Likewise.
+
+ * mkstemp.c: Don't check IN_GCC anymore.
+ * pexecute.c: Likewise.
+ * splay-tree.c: Likewise.
+
+ * strchr.c (strchr): Use `const', not `CONST'.
+ * strrchr.c (strrchr): Likewise.
+ * strtol.c (strtol): Likewise.
+ * strtoul.c (strtoul): Likewise.
+
+Fri Dec 4 13:51:04 1998 David Taylor <taylor@texas.cygnus.com>
+ Elena Zannoni <ezannoni@cygnus.com>
+ Stan Shebs <shebs@cygnus.com>
+ Edith Epstein <eepstein@cygnus.com>
+ Andres MacLeod <amacleod@cygnus.com>
+ Satish Pai <pai@apollo.hp.com>
+
+ * HP aCC demangling support.
+ * cplus-dem.c
+ (main): Remove default to HP style demangling, set to EDG
+ demangling correctly when -edg specified; set the demangling style
+ when user specifies 'edg'. Set strip_underscore to
+ prepends_underscore, if not HPUXHPPA. Set
+ current_demangling_style to hp_demangling if HPUXHPPA. Set
+ current demangling style correctly if the switch is hp. Read
+ label correctly also in the HP style case.
+ (work_stuff): add temp_start field; add field for volatile member
+ function.
+ (arm_pt): handle ARM_DEMANGLING and EDG_DEMANGLING styles; HP
+ style for this case is the same as ARM.
+ (demangle_args): handle EDG_DEMANGLING style; support HP style.
+ (demangle_arm_hp_template): new function. (It was
+ demangle_arm_pt.); check and set value of temp_start field in
+ multiple places. Also, when ceching for end of template args,
+ check to see if at end of static member of template class.
+ (demangle_class): new local variable : save_class_name_end Don't
+ include template args in string defining class.
+ (demangle_class_name): use demangel_arm_hp_template.
+ (demangle_function_name): handle case where demangling style is
+ HP_DEMANGLING and currently point at an 'X' in the mangled name.
+ Handle EDG_DEMANGLING style. Handle constructor and destructor
+ ops for HP style.
+ (demangle_prefix): handle EDG_DEMANGLING and ARM_DEMANGLING
+ styles. global destructor and constructor for HP style are same
+ as for ARM style. Same for local variables.
+ (demangle_qualified): handle EDG_DEMANGLING style.
+ (demangle_signature): add case for volatile member function. For
+ cases '1' - '9' : initialize the temp_start field to -1 and handle
+ the EDG_DEMANGLING style. for case 'F' : handle EDG_DEMANGLING
+ and AUTO_DEMANGLING styles. If expecting a function and managed
+ to demangle the funct args, then handle the LUCID_DEMANGLING,
+ ARM_DEMANGLING, and EDG_DEMANGLING styles. Add case for local
+ class name after "Lnnn_ in HP style case. HP style too needs to
+ forget types. _nnn is OK for HP style, so don't report failure.
+ (do_hpacc_template_const_value): new function. Handle template's
+ value param for HP/aCC.
+ (do_hpacc_template_literal): new function. Handle a template's
+ literal parameter for HP aCC.
+ (recursively_demangle): new function
+ (snarf_numeric_literal): new function.
+ (usage): add 'edg' to the list of demangling styles; add hp switch
+ to message.
+
+Sat Nov 28 17:25:22 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * pexecute.c: Remove obsolete ifdefed cygwin code.
+
+Fri Nov 27 13:26:06 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * choose-temp.c: Always include libiberty.h. Avoid redundancies.
+ * cplus-dem.c: Likewise. Conform to libiberty.h.
+ * pexecute.c: Likewise.
+ * splay-tree.c: Likewise.
+
+1998-11-25 Mike Stump <mrs@wrs.com>
+
+ * Makefile.in (splay-tree.o): Add config.h dependency.
+
+Mon Nov 23 16:59:49 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * configure.in: Use AC_PREREQ(2.12.1).
+
+1998-11-16 Benjamin Kosnik <bkoz@haight.constant.com>
+
+ * cplus-dem.c (demangle_fund_type): Add demangling for C9x types.
+
+Thu Nov 19 22:15:50 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mpw.c (mpw_access): Add missing parens.
+
+Thu Nov 19 12:59:21 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * configure.in: Call AC_HEADER_SYS_WAIT.
+
+ * pexecute.c: Include sys/wait.h when !IN_GCC.
+
+Thu Nov 19 14:38:20 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * pexecute.c: revert back to checking old Cygwin
+ preprocessor symbol until some time has passed.
+
+Wed Nov 18 08:52:26 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * pexecute.c: Reorganize WIN32 case to accomodate Cygwin
+ since it will now support similar constructs.
+
+Fri Nov 13 19:18:05 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * configure.in: Check for calloc.
+
+ * calloc.c: New file.
+
+ * xmalloc.c (xcalloc): New function.
+
+Fri Nov 13 08:51:46 EST 1998 Andrew MacLeod <amacleod@cygnus.com>
+
+ *cplus-dem.c (demangle_prefix): Use the last "__"
+ in the mangled name when looking for the signature. This allows
+ template names to begin with "__".
+
+1998-11-08 Mark Mitchell <mark@markmitchell.com>
+
+ * cplus-dem.c (type_kind_t): Add tk_reference.
+ (demangle_template_value_parm): Handle it.
+ (do_type): Use it for references, instead of tk_pointer.
+
+ * cplus-dem.c (demangle_template_value_parm): Use cplus_demangle,
+ not internal_cplus_demangle.
+
+Sat Nov 7 16:02:10 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * choose-temp.c: Don't include gansidecl.h.
+ * mkstemp.c: Likewise.
+ * pexecute.c: Likewise.
+
+Mon Nov 2 15:05:33 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: detect cygwin* instead of cygwin32*
+ * configure: regenerate
+
+Mon Nov 2 10:22:01 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * pexecute.c: Check HAVE_CONFIG_H, not IN_GCC, when determining
+ whether to include config.h. Possibly include unistd.h in the
+ !IN_GCC case. Define VFORK_STRING as a printable function call
+ for error messages (either "vfork" or "fork".) If HAVE_VFORK_H is
+ defined, include vfork.h. If VMS is defined, define vfork()
+ appropriately. Remove vfork check on USG, we're using autoconf.
+ (pexecute): Set `errmsg_fmt' to VFORK_STRING instead of checking
+ locally what string to use.
+
+1998-10-26 Mark Mitchell <mark@markmitchell.com>
+
+ * splay-tree.c: Tweak include directives to make sure declarations of
+ xmalloc and free are available.
+
+1998-10-25 Mark Mitchell <mark@markmitchell.com>
+
+ * cplus-dem.c (gnu_special): Fix handling of virtual tables in
+ anonymous namespaces.
+
+1998-10-23 Mark Mitchell <mark@markmitchell.com>
+
+ * cplus-dem.c (work_stuff): Replace const_type and volatile_type
+ with type_quals.
+ (TYPE_UNQUALIFIED): New macro.
+ (TYPE_QUAL_CONST): Likewise.
+ (TYPE_QUAL_VOLATILE): Likewise.
+ (TYPE_QUAL_RESTRICT): Likewise.
+ (code_for_qualifier): New function.
+ (qualifier_string): Likewise.
+ (demangle_qualifier): Likewise.
+ (internal_cplus_demangle): Use them.
+ (demangle_signature): Likewise.
+ (demangle_template_value_parm): Likewise.
+ (do_type): Likewise.
+ (demangle_fund_type)): Likewise.
+
+Thu Oct 22 19:58:43 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * splay-tree.c (splay_tree_foreach_helper): Make definition static
+ to match prototype.
+
+1998-10-21 Mark Mitchell <mark@markmitchell.com>
+
+ * splay-tree.c: New file.
+ * Makefile.in (CFILES): Add it.
+ (REQUIRED_OFILES): Likewise.
+ (splay-tree.o): Add dependencies.
+
+Tue Oct 20 12:29:02 1998 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
+
+ * cplus-dem.c (demangle_qualified): Fix off-by-one when checking
+ range of 'K' index.
+
+Thu Oct 15 18:51:12 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * choose-temp.c: Prototype mkstemps() when IN_GCC.
+
+ * cplus-dem.c (consume_count): Cast argument of ctype macro to
+ `unsigned char'.
+ (cplus_demangle_opname): Cast the result of `strlen' to (int) when
+ comparing against one.
+ (cplus_mangle_opname): Likewise.
+ (demangle_integral_value): Cast argument of ctype macro to
+ `unsigned char'.
+ (demangle_template_value_parm): Likewise.
+ (demangle_template): Initialize variable `bindex'. Cast the
+ result of `strlen' to (int) when comparing against one. Remove
+ unused variable `start_of_value_parm'.
+ (demangle_class_name): Cast the result of `strlen' to (int) when
+ comparing against one.
+ (demangle_prefix): Cast argument of ctype macro to `unsigned char'.
+ (gnu_special): Likewise. Cast the result of `strlen' to (int)
+ when comparing against one.
+ (demangle_qualified): Cast argument of ctype macro to `unsigned char'.
+ (get_count): Likewise.
+ (do_type): Likewise. Cast the result of `strlen' to (int) when
+ comparing against one.
+ (demangle_fund_type): Cast argument of ctype macro to `unsigned char'.
+ (demangle_function_name): Cast the result of `strlen' to (int)
+ when comparing against one.
+
+ * mkstemp.c (mkstemps): Cast variable `len' to (int) when
+ comparing against one.
+
+Tue Oct 13 23:51:51 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mkstemp.c: Check HAVE_SYS_TIME_H before including sys/time.h
+ * configure.in (AC_CHECK_HEADERS): Check for sys/time.h too.
+ * config.in, configure: Rebuilt.
+
+ * getopt.c: Check HAVE_STRINGS_H before including strings.h.
+ * configure.in (AC_CHECK_HEADERS): Check for strings.h too.
+ * config.in, configure: Rebuilt.
+
+Mon Oct 12 19:15:59 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: in comment, call AC_EXEEXT instead of AM_EXEEXT
+
+Sun Oct 11 17:36:06 1998 Michael Tiemann <tiemann@holodeck.cygnus.com>
+
+ * Makefile.in (cplus-dem.o, obstack.o): Depend upon config.h.
+
+Thu Oct 8 23:42:08 1998 Jeffrey A Law (law@cygnus.com)
+
+ * Merge egcs & devo libiberty.
+
+1998-09-08 Martin von Löwis <loewis@informatik.hu-berlin.de>
+
+ * cplus-dem.c (demangle_arm_pt): Demangle anonymous namespaces.
+
+Mon Sep 7 23:29:01 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * mkstemp.c: Include config.h even when not IN_GCC. Wrap header
+ inclusions inside HAVE_*_H macros. Include ansidecl.h when not
+ IN_GCC.
+
+ * vasprintf.c: Include stdarg.h/varargs.h first.
+
+ * vprintf.c: Likewise.
+
+Sat Sep 5 03:24:49 1998 Jeffrey A Law (law@cygnus.com)
+
+ * pexecute.c: Updates from gcc. Copy in gcc has been removed. This
+ is the canonical copy. Define ISSPACE if !IN_GCC.
+ * alloca.c, vfprintf.c, choose-temp.c, mkstemp.c, getopt.c: Similarly.
+ * getopt1.c, obstack.c: Similarly.
+ * Makefile.in: Build mkstemp.o
+
+Tue Sep 1 23:12:47 1998 Christopher Faylor <cgf@cygnus.com>
+
+ * configure.in: Include asprintf in list of functions known not
+ to be in newlib.
+ * configure: Rebuild.
+
+Wed Aug 19 14:05:01 1998 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * cplus-dem.c (work_stuff): Add dllimported.
+ (demangled_prefix): Mark symbols imported from PE DLL.
+ (internal_cplus_demangled): Handle.
+
+1998-08-17 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (do_type): Fix simple array handling. If we fail,
+ stay failed.
+
+Mon Aug 17 10:40:34 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cplus-dem.c: Include config.h if it exists. Also, only
+ prototype malloc/realloc if we can't get stdlib.h.
+
+Sat Aug 15 16:15:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Switch back to checking --with-target-subdir when
+ deciding whether to check for newlib, undoing part of July 15
+ change.
+ * configure: Rebuild.
+
+Thu Aug 13 16:47:38 1998 Mark Mitchell <mark@markmitchell.com>
+
+ * cplus-dem.c (type_kind_t): New type.
+ (demangle_template_value_parm): Add type_kind_t parameter. Rely
+ on this paramter, rather than demangling the type again.
+ (demangle_integral_value): Pass tk_integral.
+ (demangle_template_: Pass the value returned from do_type.
+ (do_type): Return a type_kind_t. Pass tk_integral to
+ demangle_template_value_parm for array bounds.
+ (demangle_fund_type): Likewise.
+
+ Also incorporate from GCC version:
+
+ Tue Jul 21 13:28:19 1998 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (do_type): Use demangle_template_value_parm for arrays.
+
+Thu Aug 13 16:47:38 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cplus-dem.c (demangle_nested_args): Make function definition
+ static to match the prototype.
+
+Tue Jul 28 11:33:09 1998 Mark Mitchell <mark@markmitchell.com>
+
+ * cplus-dem.c (type_kind_t): New type.
+ (demangle_template_value_parm): Add type_kind_t parameter. Rely
+ on this paramter, rather than demangling the type again.
+ (demangle_integral_value): Pass tk_integral.
+ (demangle_template_: Pass the value returned from do_type.
+ (do_type): Return a type_kind_t. Pass tk_integral to
+ demangle_template_value_parm for array bounds.
+ (demangle_fund_type): Likewise.
+
+ Also incorporate from GCC version:
+
+ Tue Jul 21 13:28:19 1998 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (do_type): Use demangle_template_value_parm for arrays.
+
+Mon Jul 27 12:16:08 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (ALLOCA): New variable.
+ ($(TARGETLIB)): Add $(ALLOCA) to library.
+ (needed-list): Add $(ALLOCA).
+ ($(ALLOCA)): Depend upon stamp-picdir.
+
+Sun Jul 19 08:23:17 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cplus-dem.c (demangle_nested_args): Make function definition
+ static to match the prototype.
+
+Wed Jul 15 00:12:58 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Check --with-cross-host rather than
+ --with-target-subdir when deciding whether build uses a cross
+ compiler, and when deciding where to install the library.
+ * configure: Rebuild.
+
+Sun Jul 12 01:27:05 1998 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (demangle_nested_args): Return a value.
+
+Sat Jul 11 16:19:48 1998 Mark Mitchell <mark@markmitchell.com>
+
+ * cplus-dem.c (string): Move definition before work_stuff.
+ (work_stuff): Add volatile_type, forgetting_types,
+ previous_argument, and nrepeats fields.
+ (SCOPE_STRING): New macro.
+ (demangle_template): Add `remember' parameter. Add comment.
+ Register the `B' code type here, if remembering. Tidy. Fix crash
+ on NULL tmpl_argvec. Be consistent with use of tname/trawname.
+ (demangle_nested_args): New function.
+ (internal_cplus_demangle): Handle volatile-qualified member
+ functions.
+ (mop_up): Delete the previous_argument string if present.
+ (demangle_signature): Tidy. Handle volatile-qualified member
+ functions. Handle back-references using the `B' code. Use extra
+ parameter to demangle_template and SCOPE_STRING where appropriate.
+ (demangle_template_value_parm): Fix thinko; 'B' is not an integral
+ code.
+ (demangle_class): Use SCOPE_STRING.
+ (gnu_special): Pass additional argument to demangle_template.
+ Use SCOPE_STRING.
+ (demangle_qualified): Save qualified types for later
+ back-references. Handle constructors and destructors for template
+ types correctly.
+ (do_type): Tidy. Use SCOPE_STRING. Pass extra argument to
+ demangle_template. Use demangled_nested_args. Don't remember
+ qualified types here; that's now done in demangle_qualified.
+ Similarly for templates.
+ (do_arg): Improve commment. Handle 'n' repeat code.
+ (remember_type): Check forgetting_types.
+ (demangle_args): Deal with 'n' repeat codes. Tidy.
+
+Thu Jul 2 16:26:24 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.table: Only use mh-fbsd21 on *-*-freebsd2.2.[012], not on
+ *-*-freebsd2.2.*. From Dmitrij Tejblum <tejblum@arc.hq.cti.ru>.
+
+Mon Jun 15 16:29:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in (setobjs): Correct quoting error in cygwin32 case.
+ From Chris Faylor <cgf@cygnus.com>.
+
+Mon Jun 1 13:47:55 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * obstack.c: Update to latest FSF version.
+
+Mon Jun 1 14:17:36 1998 Mike Stump <mrs@wrs.com>
+
+ * Makefile.in: Add a dependency on stamp-picdir for the
+ objects, so that we can do a parallel build.
+
+Sat May 30 22:17:13 1998 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * configure.in (checkfuncs): Add missing "'".
+
+Fri May 29 12:40:41 1998 Jason Molenda (crash@bugshack.cygnus.com)
+
+ * obstack.c (_obstack_memory_used): Elide this function if we're
+ on a system with GNU libc.
+
+Tue May 26 18:28:43 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (distclean): Remove config.log.
+
+Tue May 26 15:01:52 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makefile.in (distclean): Don't remove alloca-conf.h.
+
+Fri May 22 01:38:07 1998 Hans-Peter Nilsson <hp@axis.se>
+
+ * cplus-dem.c (MBUF_SIZE): Bumped from 512 to 32767.
+
+1998-05-21 Mark Mitchell <mmitchell@usa.net>
+
+ * cplus-dem.c (do_type): Handle volatile qualification.
+
+1998-05-21 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * configure.in: Check for unistd.h as well.
+ * configure: Rebuild.
+ * config.in: Rebuild.
+ * getpagesize.c (GNU_OUR_PAGESIZE): Use sysconf only if _SC_PAGESIZE
+ is defined in unistd.h. Reformat conditional block for easier reading.
+
+ * config.table (shared): Default to no if ${enable_shared}
+ is unset or empty; this logic is used by the toplevel
+ configure scripts, too.
+
+Sat May 16 14:01:26 1998 Jeffrey A Law (law@cygnus.com)
+
+ * config.table: Add line to set enable_shared in the Makefile
+ as needed.
+
+Wed May 13 14:24:38 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cplus-dem.c (squangle_mop_up): Change return type to void.
+ (internal_cplus_demangle): Remove unused parameter `options'.
+ All callers changed.
+ (cplus_demangle_opname): Remove function wide variable `int i' and
+ replace with `size_t i' at each location where it is used.
+ (cplus_mangle_opname): change type of `i' from int to size_t.
+
+Wed May 13 13:39:38 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * alloca-conf.h: Include config.h. Check HAVE_ALLOCA_H rather
+ than sparc or sun.
+ * Makefile.in (argv.o): Depend upon config.h and alloca-conf.h.
+
+Fri May 8 00:23:51 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set libiberty_topdir correctly when srcdir is
+ "." and with_target_subdir is not set.
+ * configure: Rebuild.
+
+Thu May 7 13:01:44 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Add *-*-mingw32* case.
+ * configure: Rebuild.
+
+Wed May 6 11:33:51 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.table: Never use a PIC file for *-*-cygwin32*.
+
+ * Makefile.in (config.status): Depend upon config.table.
+
+ * configure.in: On a cygwin32 host, always compile random, and
+ don't test for sys_siglist, strsignal, or psignal.
+ * configure: Rebuild.
+
+ * clock.c: Check HAVE_SYS_PARAM_H rather than NO_SYS_PARAM_H.
+ * getcwd.c: Likewise.
+ * getpagesize.c: Likewise.
+ * getruntime.c: Likewise.
+
+Tue May 5 18:08:32 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ Use autoconf tests rather than the old dummy.c test:
+ * configure.in: Add AC_ARG_WITH calls for --with-target-subdir and
+ --with-newlib. Add AC_CONFIG_HEADER. Use AC_REPLACE_FUNCS for
+ most functions. Add special cases to handle newlib and VxWorks.
+ Remove target_makefile_frag. Create stamp-h in AC_OUTPUT if
+ CONFIG_HEADERS is set. Only call config-ml.in in AC_OUTPUT if
+ CONFIG_FILES is set; set ac_file before calling it.
+ * config.table (arm-*-riscix*, *-*-cygwin32): Remove.
+ (*-*-hpux*, *-*-hiux*, *-*-irix4*, *-*-solaris2*): Remove.
+ (*-*-sysv4*, *-*-go32, *-*-vxworks5*, *-*-vxworks): Remove
+ (i[3456]-*-mingw32*): Remove.
+ * Makefile.in (ERRORS_CC, CONFIG_H, NEEDED_LIST): Remove.
+ (LIBOBJS): New variable.
+ (HOST_OFILES, DO_ALSO, STAGESTUFF): Remove.
+ (all): Depend upon needed-list. Don't check RULE1.
+ (@target_makefile_frag@): Remove.
+ (COMPILE.c): Include @DEFS@.
+ (HFILES): Add alloca-conf.h.
+ (REQUIRED_OFILES): Remove basename.o.
+ ($(TARGETLIB)): New target.
+ (stamp-needed, lneeded-list, needed.awk, stamp-config): Remove.
+ (lconfig.h, needed2.awk, dummy.o, errors): Remove.
+ (needed-list, config.h): Rewrite.
+ (RULE1, $(RULE1), RULE2, $(RULE2)): Remove.
+ (.always.): Remove.
+ (Makefile): Set CONFIG_FILES and CONFIG_HEADERS.
+ (stamp-h): New target.
+ (atexit.o, clock.o, getcwd.o, getpagesize.o): New targets.
+ (basename.o): Don't depend upon config.h.
+ (getruntime.o): Depend upon config.h.
+ * atexit.c: Include config.h. Check HAVE_ON_EXIT rather than
+ NEED_on_exit.
+ * basename.c: Don't include config.h. Don't check NEED_basename.
+ * clock.c: Include config.h.
+ * getcwd.c: Likewise.
+ * getpagesize.c: Likewise.
+ * getruntime.c: Likewise. Fix checks which set HAVE_GETRUSAGE and
+ HAVE_TIMES.
+ * strerror.c: Change uses of NEED_sys_errlist to
+ HAVE_SYS_ERRLIST. Likewise for NEED_strerror and HAVE_STRERROR.
+ * strsignal.c: Likewise for NEED_sys_siglist and HAVE_SYS_SIGLIST,
+ and for NEED_strsignal and HAVE_STRSIGNAL and for NEED_psignal and
+ HAVE_PSIGNAL.
+ * acconfig.h: New file.
+ * dummy.c: Remove.
+ * functions.def: Remove.
+ * config/mh-cxux7 (HDEFINES): Remove -DHAVE_SYSCONF.
+ * config/mh-windows (HDEFINES): Remove.
+ * config/mh-cygwin32: Remove.
+ * config/mh-go32: Remove.
+ * config/mh-irix4: Remove.
+ * config/mh-riscix: Remove.
+ * config/mh-sysv4: Remove.
+ * config/mt-mingw32: Remove.
+ * config/mt-vxworks5: Remove.
+ * config.in: New file, generated using autoheader.
+ * configure: Rebuild.
+
+Mon May 4 13:00:28 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Rewrite to use autoconf.
+ * configure: Generate using autoconf.
+ * config/mh-a68bsd: Remove.
+ * config/mh-apollo68: Remove.
+ * config/mh-hpbsd: Remove.
+ * config/mh-ncr3000: Remove.
+ * config/mh-sysv: Remove.
+ * config/mh-aix (RANLIB, INSTALL): Don't define.
+ * config/mh-cxux7 (RANLIB, INSTALL): Don't define.
+ * config/mh-irix4 (CC, RANLIB, INSTALL): Don't define.
+ * config/mh-sysv4 (RANLIB, INSTALL): Don't define.
+ * config.table: Change config_shell to CONFIG_SHELL, and use
+ libiberty_topdir to find move-if-change.
+ (m68k-apollo-bsd*, m68k-apollo-sysv*): Remove.
+ (i[3456]86-ncr-sysv4*, *-*-dgux*, hppa*-hp-bsd*): Remove.
+ (*-*-irix*, *-*-m88kbcs*, *-*-sysv*): Remove.
+ * Makefile.in (srcdir): Set to @srcdir@.
+ (VPATH): Likewise.
+ (prefix, exec_prefix, bindir, libdir): Set to autoconf variables.
+ (SHELL, INSTALL, INSTALL_PROGRAM, INSTALL_DATA): Likewise.
+ (CC, CFLAGS, RANLIB)): Likewise.
+ (datadir, man*dir, infodir, includedir, MAKEINFO): Remove.
+ (target_makefile_frag, host_makefile_frag): Add substitutions.
+ (INSTALL_DEST): Set to @INSTALL_DEST@.
+ (Makefile): Depend upon config.status. Don't depend upon
+ $(host_makefile_frag) or $(target_makefile_frag).
+ (config.status): New target.
+
+Sun May 3 17:58:49 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/mt-sunos4: Remove. Should be handled by --with-headers
+ and --with-libraries options at top level.
+ * config.table: Never use mt-sunos4.
+
+ * alloca-conf.h: New file, combining alloca-norm.h and
+ alloca-botch.h.
+ * alloca-norm.h: Remove.
+ * alloca-botch.h: Remove.
+ * configure.in: Set shell variables files and links to empty.
+ * config.table: Don't set shell variable files.
+ * configure.bat: Don't create alloca-conf.h.
+ * makefile.vms: Likewise.
+ * mpw-config.in: Likewise.
+ * vmsbuild.com: Likewise.
+
+Fri May 1 11:41:42 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in ($(HOST_OFILES) $(REQUIRED_OFILES)): Remove old
+ target depending upon config.h.
+ (alloca.o): Add target depending upon config.h
+ (basename.o, choose-temp.o, fnmatch.o): Likewise.
+ (getopt.o, getopt1.o, pexecute.o, strerror.o): Likewise.
+ (strsignal.o, xstrerror.o): Likewise.
+
+Fri May 1 04:26:25 1998 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
+
+ * cplus-dem.c (cplus_demangle_opname): Initialize work.
+
+Mon Apr 27 15:53:30 EDT 1998 Andrew MacLeod <amacleod@cygnus.com>
+
+ * cplus-dem.c (demangle_qualified): Replace missing else.
+
+Sun Apr 26 15:38:50 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * cplus-dem.c (gnu_special): Fix off-by-one bug when checking the
+ length in the name of a virtual table.
+
+Wed Apr 22 10:53:49 EDT 1998 Andrew MacLeod <amacleod@cygnus.com>
+
+ * cplus-dem.c (struct work stuff): Add field for B and K mangle codes.
+ (cplus_demangle_opname): Call mop_up_squangle.
+ (cplus_demangle): Initialize squangle info, then call
+ internal_cplus_demangle. (Most code moved there as well)
+ (internal_cplus_demangle): New function, performs most of what use
+ to be done in cplus_demangle, but is only called with this file.
+ (squangle_mop_up): New function to clean up B and K code data.
+ (mop_up): set pointers to NULL after freeing.
+ (demangle_signature, demangle_template, demangle_class): Add
+ switch elements to handle K and B codes.
+ (demangle_prefix, gnu_special, demangle_qualified): Add
+ code to handle K and B codes.
+ (do_type, demangle_fund_type): Handle B and K codes.
+ (remember_Ktype): New function to store K info.
+ (register_Btype, remember_Btype): New functions for B codes.
+ (forget_B_and_K_types): New function to destroy B and K info.
+
+Fri Apr 10 01:49:10 1998 Jeffrey A Law (law@cygnus.com)
+
+ * COPYING.LIB, choose-temp.c, cplus-dem.c: Sync with egcs & gcc.
+
+Thu Mar 5 09:23:28 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * config.table: Make locating frag files failsafe even for the
+ special case if configuring and building in srcdir.
+
+Mon Feb 23 14:33:15 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * choose-temp.c: Fix handling of sys/file.h to work in libiberty.
+
+Sun Feb 22 18:03:23 1998 Jeffrey A Law (law@cygnus.com)
+
+ * choose-temp.c: Sync with copy in gcc.
+
+Thu Feb 12 16:29:49 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * getopt.c: Update to latest FSF version.
+ * getopt1.c: Likewise.
+
+Tue Feb 10 16:58:33 1998 Stan Shebs <shebs@andros.cygnus.com>
+
+ * cplus-dem.c (gnu_special): Don't get confused by .<digits>
+ strings that are not actually lengths.
+
+Fri Feb 6 01:35:17 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * Makefile.in (FLAGS_TO_PASS): Don't pass PICFLAG.
+ (.c.o): Check value of enable_shared, not PICFLAG.
+ (stamp-picdir): Dito.
+
+Thu Feb 5 18:48:56 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * config/mh-cygwin32: remove vasprintf.o from EXTRA_OFILES
+ since it gets built automatically
+
+Sun Feb 1 02:52:32 1998 Mike Stump <mrs@wrs.com>
+
+ * config.table (vxworks configs): Default to VxWorks 5.x, as that is
+ the currently shipping OS.
+
+Tue Jan 27 16:08:20 1998 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vmsbuild.com [REQUIRE_OFILES]: Synchronized with Makefile.in:
+ Add fnmatch.o and objalloc.o; remove vasprintf.o.
+ [config.h]: Define NEED_strsignal.
+
+Mon Jan 19 12:20:01 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * functions.def: Correct argument types for strerror and
+ strsignal. Reported by Alex Gutman <agutman@emc.com>.
+
+Sun Jan 18 15:57:28 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * vasprintf.c (int_vasprintf): Increase buffer size for float/double
+ values.
+
+Sat Jan 17 22:28:38 1998 Mumit Khan <khan@xraylith.wisc.edu>
+ J.J. VanderHeijden <J.J.vanderHeijden@student.utwente.nl>
+
+ Add mingw32 support.
+ * pexecute.c (pexecute): New function for mingw32. Supports pipes.
+ (pwait): New function for mingw32.
+
+ * config.table (i[3456]86-*-mingw32*): Support for i386-mingw32.
+ * config/mt-mingw32: New file.
+ * xmalloc.c (first_break): Not used for mingw32.
+ (xmalloc_set_program_name): Don't use sbrk on mingw32.
+ (xmalloc): Likewise.
+ (xrealloc): Likewise.
+
+Sat Jan 17 22:28:05 1998 Jeffrey A Law (law@cygnus.com)
+
+ * choose-temp.c: Sync with gcc version.
+
+Tue Jan 13 18:34:39 1998 Jim Wilson <wilson@cygnus.com>
+
+ * Makefile.in (install_to_libdir, install_to_tooldir): Add MULTISUBDIR
+ to all filenames in libdir and tooldir.
+ (distclean): Do MULTICLEAN before deleting Makefile.
+ (stamp-needed, stamp-config): Add MULTISRCTOP to
+ pathname for move-if-change.
+
+Thu Dec 4 17:25:19 1997 Jeffrey A Law (law@cygnus.com)
+
+ * strsignal.c (sys_nsig): Try NSIG and _NSIG.
+
+Wed Nov 19 13:37:06 1997 Michael Meissner <meissner@cygnus.com>
+
+ * alloca-norm.h (alloca, GCC case): Don't redefine alloca if it
+ was already defined previously.
+
+Mon Nov 10 12:48:03 1997 Philippe De Muyter <phdm@macqel.be>
+
+ * Makefile.in (INSTALL): Use ../install-sh, not install.
+
+Tue Oct 28 23:41:15 1997 Judy Goldberg <jodyg@idt.net>
+
+ * Makefile.in (CFILES): Add pexecute.c.
+
+Wed Oct 15 19:13:48 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * asprintf.c: Consistently use either stdarg or varargs.
+
+Tue Oct 14 12:01:00 1997 Mark Mitchell <mmitchell@usa.net>
+
+ * cplus-dem.c (demangle_signature): Don't look for return types on
+ constructors. Handle member template constructors.
+
+Fri Oct 3 17:53:30 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * README: Fix configuration instructions.
+
+Mon Sep 29 12:28:41 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * pexecute.c: Update to current version from /gd/gnu/lib:
+
+ Mon Sep 29 12:27:59 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * pexecute.c: Use spawn if __CYGWIN32__.
+
+ 1997-08-08 Paul Eggert <eggert@twinsun.com>
+
+ * pexecute.c: Include "config.h" first, as per autoconf manual.
+
+ Fri Jun 27 15:20:29 1997 Scott Christley <scottc@net-community.com>
+
+ * pexecute.c (fix_argv): New function.
+ (pexecute): Win32 but not Cygwin32 needs its arguments fixed.
+ Add underscore to cwait function call.
+
+Sun Sep 28 12:00:52 1997 Mark Mitchell <mmitchell@usa.net>
+
+ * cplus-dem.c (demangle_template): Add new parameter. Handle new
+ template-function mangling.
+ (consume_count_with_underscores): New function.
+ (demangle_signature): Handle new name-mangling scheme.
+
+Wed Sep 24 00:31:59 1997 Felix Lee <flee@yin.cygnus.com>
+
+ * asprintf.c: stdarg.h when ALMOST_STDC
+ * config/mh-windows (EXTRA_OFILES): add asprintf.o and
+ strncasecmp.o.
+
+Thu Aug 28 14:27:15 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * vasprintf.c (vasprintf): Allow for _BSD_VA_LIST_.
+
+ * config.table: Add case for FreeBSD 2.1 and 2.2, needs mh-fbsd21.
+
+ * config/mh-fbsd21 (EXTRA_OFILES): Force vasprintf.o
+
+Wed Sep 10 12:43:10 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (demangle_fund_type): Change "complex" to "__complex".
+
+Fri Sep 5 16:34:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * asprintf.c (asprintf): New file.
+ * Makefile.in (CFILES): Add asprintf.c
+ * functions.def: Ditto.
+
+Thu Aug 28 18:53:34 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * argv.c (dupargv): New function, duplicate an argument vector.
+
+Tue Aug 19 20:28:45 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * config/mh-cygwin32: also build random.o
+
+Tue Aug 19 17:10:56 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c: Add 'extern' to prepends_underscore.
+
+Wed Jul 30 11:42:19 1997 Per Bothner <bothner@cygnus.com>
+
+ * cplus-dem.c: Various changes to produce Java output when passed
+ DMGL_JAVA. Thus "::" becomes "." and "JArray<Foo>" becomes "Foo[]".
+ (main): Support --java and -j flags to set DMGL_JAVA.
+
+Tue Jul 22 19:05:23 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
+
+ * config/mh-go32 (CC, AR, RANLIB): Don't define.
+
+Tue Jul 22 17:49:54 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (REQUIRED_OFILES): Add pexecute.o.
+ (pexecute.o): New target.
+
+ * Makefile.in (stamp-needed): New target, replacing needed-list.
+ (needed-list): Just depend upon stamp-needed.
+ (stamp-config): New target, replacing config.h.
+ (config.h): Just depend upon stamp-config.
+ (mostlyclean): Remove stamp-*.
+
+Thu Jun 12 11:00:18 1997 Angela Marie Thomas (angela@cygnus.com)
+
+ * Makefile.in (FLAGS_TO_PASS): pass INSTALL, INSTALL_PROGRAM and
+ INSTALL_DATA for multilibbed installs
+
+Tue Jun 3 13:21:05 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ Tue Dec 10 09:44:57 1996 Paul Eggert <eggert@twinsun.com>
+
+ * choose-temp.c (choose_temp_base): Don't dump core if TMPDIR is empty.
+
+ * choose-temp.c (try): Insist that temp dir be searchable.
+
+ Wed Oct 23 17:36:39 1996 Doug Rupp (rupp@gnat.com)
+
+ * choose-temp.c (choose_temp_base): On VMS, use proper syntax
+ for current directory.
+
+ Sat Feb 15 19:03:48 1997 Geoffrey Noer (noer@cygnus.com)
+
+ * pexecute.c: Remove special cases for cygwin32.
+ (pwait): Remove local definition of `pid'.
+
+ Tue Nov 12 18:26:15 1996 Doug Rupp (rupp@gnat.com)
+
+ * pexecute.c (vfork): Supply new definition for VMS.
+ (pwait): Use waitpid instead of wait for VMS.
+
+Tue May 20 14:02:20 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * cplus-dem.c (do_type): Handle `J'.
+ (demangle_fund_type): Print "complex" for it.
+
+Wed Apr 30 12:15:45 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * configure.in: Don't turn on multilib here.
+
+Mon Apr 28 19:04:31 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * obstack.c: move _obstack_memory_used outside of ifdef. Cannot be
+ elided; needed by gdb and not present in libc.
+
+Thu Apr 24 19:33:47 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (clean): Remove tmpmulti.out.
+
+Tue Apr 22 10:25:15 1997 Fred Fish <fnf@cygnus.com>
+
+ * floatformat.c (floatformat_ieee_double_littlebyte_bigword):
+ Add new floatformat, mainly for ARM doubles.
+
+Mon Apr 14 12:11:16 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.table: Use ${config_shell} with ${moveifchange}. From
+ Thomas Graichen <graichen@rzpd.de>.
+
+Fri Apr 4 03:09:24 1997 Ulrich Drepper <drepper@cygnus.com>
+
+ * configure.in: Enable multilibing by default.
+ Update multilib template to read config-ml.in.
+
+Tue Apr 1 16:26:39 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Add objalloc.
+
+Mon Mar 31 23:57:51 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * cplus-dem.c (demangle_it): Add prototype declaration.
+ (usage, fatal): Likewise.
+
+ * xexit.c (_xexit_cleanup): Add prototype.
+
+ * strerror.c (init_error_tables): Declare.
+
+Fri Mar 28 11:43:20 1997 H.J. Lu <hjl@lucon.org>
+
+ * functions.def: Add DEF of vasprintf, and DEFFUNC of strsignal.
+ * strsignal.c: Only define strsignal if NEED_strsignal.
+ * Makefile.in (REQUIRED_OFILES): Remove vasprintf.o.
+ * configure.in: Add NEED_strsignal to xconfig.h. Add vasprintf.o
+ to xneeded-list.
+ * config/mh-cygwin32 (HDEFINES): Add -DNEED_strsignal.
+ (EXTRA_OFILES): Define to vasprintf.o.
+ * config/mh-windows (HDEFINES): Add -DNEED_strsignal.
+ (EXTRA_OFILES): Add vasprintf.o.
+ * config/mt-vxworks5 (vxconfig.h): Define NEED_strsignal.
+ (vxneeded-list): Add vasprintf.o.
+
+Thu Mar 20 17:02:09 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * objalloc.c: Include <stdio.h>.
+
+Mon Mar 17 19:23:11 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * objalloc.c: New file.
+ * Makefile.in (CFILES): Add objalloc.c
+ (REQUIRED_OFILES): Add objalloc.o.
+ (objalloc.o): New target.
+
+Sat Mar 15 18:49:41 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * obstack.c: Update to current FSF version.
+
+Fri Mar 14 14:18:47 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * cplus-dem.c: Add prototypes for all static functions.
+ (mystrstr): Make static. Make arguments and result const.
+ (cplus_match): Remove; not used.
+
+Tue Mar 11 14:20:31 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * cplus-dem.c (gnu_special): Call demangled_fund_type for other
+ __t* symbols.
+
+Tue Mar 11 15:41:21 1997 H.J. Lu <hjl@lucon.org>
+
+ * spaces.c: Declare malloc and free properly.
+ * strsignal.c (init_signal_tables): Add prototype.
+ * xatexit.c (_xexit_cleanup): Add parameter declarations.
+
+Wed Feb 19 15:43:24 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * Makefile.in (lneeded-list): If alloca.o is needed, xexit.o is
+ also required because of xmalloc.o.
+
+Fri Feb 14 13:43:38 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * strsignal.c: Unconditionally redefine sys_siglist around the
+ inclusion of the system header files.
+
+Thu Feb 13 22:01:04 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Remove 8 bit characters. Update to latest
+ gcc release.
+
+Tue Feb 4 11:52:19 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * strsignal.c: Use NEED_sys_siglist instead of
+ LOSING_SYS_SIGLIST.
+ * config.table: Don't use mh-lynxos.
+ * config/mh-lynxos: Remove.
+
+Thu Jan 16 14:51:03 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * cplus-dem.c: Fix indenting; make identical to the copy
+ in GCC.
+ (do_type, case 'M'): Check for a template as well as a class.
+
+Thu Dec 19 13:51:33 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * config/mt-vxworks5 (vxneeded-list): Remove sigsetmask.o, since
+ vxworks 5.[0-3] all have sigsetmask in them; the one provided by
+ libiberty is incorrect, as well.
+
+Mon Dec 2 15:03:42 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * alloca.c (alloca): When compiled with an ANSI/ISO compiler,
+ alloca takes a size_t argument, not just unsigned.
+
+Mon Nov 18 15:42:08 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c: Note that this file also lives in GCC.
+
+Mon Nov 18 15:19:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * alloca.c: Remove include of libiberty.h for hpux.
+ * argv.c: Replace defs from libiberty.h.
+ * spaces.c: Put back externs from removed from libiberty.h.
+ * vasprintf.c: Remove include of libiberty.h for hpux.
+
+Mon Nov 18 14:08:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * cplus-dem.c: Checking in again; last checkin filed due to sticky tag.
+
+Wed Nov 13 08:22:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * cplus-dem.c: Revert last two commits due to conflicts with
+ hpux system headers.
+
+Wed Nov 13 08:22:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * alloca.c, argv.c, spaces.c, strcasecmp.c, vasprintf.c, vprintf.c:
+ Revert last commit due to conflicts with hpux system headers.
+
+Wed Nov 13 10:36:50 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * cplus-dem.c (x{m,re}alloc): Make declarations compatibile with
+ libiberty.h when compiled with a standard compiler.
+
+Tue Nov 12 16:31:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
+
+ * alloca.c: Include libiberty.h for definition of xmalloc.
+ Don't redefine NULL.
+ * argv.c: Move prototypes to libiberty.h.
+ * cplus-dem.c: Include libiberty.h for definition of xmalloc.
+ Don't redefine NULL.
+ Use casts to eliminate compiler warnings.
+ * spaces.c: Remove prototypes for malloc and free which are
+ already in libibrty.h.
+ * strcasecmp.c: Use casts to eliminate compiler warnings.
+ * vasprintf.c: Include libiberty.h for definition of malloc.
+ Don't redefine NULL.
+ * vprintf.c: Include stdarg.h if __STDC__.
+
+Fri Oct 11 15:42:12 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * config/mh-windows: Add strcasecmp.o to EXTRA_OFILES.
+
+Fri Oct 11 11:16:31 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.c (mpwify_filename): Rewrite to simplify, and to handle
+ upward components correctly.
+
+Tue Oct 8 08:55:34 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * config.table, config/mh-windows: Add support for building under
+ MSVC (the Microsoft build environment).
+
+Mon Oct 7 10:50:27 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * fnmatch.c: Undef const if not __STDC__.
+
+Thu Oct 3 13:46:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * fnmatch.c: New file.
+ * Makefile.in (CFILES): Add fnmatch.c.
+ (REQUIRED_OFILES): Add fnmatch.o.
+ (fnmatch.o): New target.
+
+Wed Sep 18 14:49:13 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (demangle_template): Fix handling of address args.
+ (gnu_special): Handle type_info stuff.
+
+Fri Sep 13 17:52:55 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.c (DebugPI): Make settable from the env var DEBUG_PATHNAMES.
+ (mpwify_filename): Handle "::/" case.
+
+Thu Sep 12 13:30:40 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * config/mh-cygwin32: new file (need -DNEED_basename and
+ -DNEED_sys_siglist for native NT rebuilding)
+ * config.table (*-*-cygwin32): new entry
+ * choose-temp.c: bring in sync with gcc (revert Aug 17 change)
+
+Thu Aug 29 16:48:45 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * config.table (i[345]86-*-*): Recognize i686 for pentium pro.
+
+Tue Aug 27 13:47:58 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * pexecute.c (pexecute) [MPW]: Remove old bogus code that
+ messed with arguments that included a '/', add escape chars
+ to double quotes, remove const decl from arg that Mac
+ compilers don't seem to like.
+
+Sat Aug 17 04:44:27 1996 Geoffrey Noer <noer@cygnus.com>
+
+ * pexecute.c: Update test for win32 (&& ! cygwin32).
+ * choose-temp.c: fix WIN32 preprocessor defines
+
+Thu Aug 15 12:26:48 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Add @DASH_C_FLAG@ and @SEGMENT_FLAG({Default})@
+ to editing of default makefile rule.
+
+Sun Aug 11 21:03:27 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * alloca-norm.h: Include <malloc.h> if _WIN32.
+ * argv.c: Include non-prototyped decls for malloc and string
+ functions if ! _WIN32 or if __GNUC__.
+
+Thu Aug 8 12:42:40 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * config.h-vms: New file.
+ * makefile.vms: Use it.
+
+Wed Aug 7 17:16:12 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * getopt.c (_getopt_internal): If argc is 0, just return (before
+ we reference *argv and segfault).
+
+Mon Aug 5 01:29:08 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * Makefile.in (distclean): Add multilib.out.
+
+Thu Jul 18 17:40:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * alloca-norm.h: Change #ifdef sparc to #if defined (sparc) &&
+ defined (sun). From Andrew Gierth <ANDREWG@microlise.co.uk>.
+
+Mon Jul 1 13:40:44 1996 Ken Raeburn <raeburn@cygnus.com>
+
+ Tue May 28 15:29:03 1996 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vmsbuild.com (REQUIRD_OFILES): Add choose-temp.o and xstrdup.o.
+
+ Thu Jan 25 18:20:04 1996 Pat Rankin <rankin@eql.caltech.edu>
+
+ * vmsbuild.com: Changes to handle DEFFUNC(on_exit).
+ (do_ofiles): Allow nonexistent source file in pass 3.
+ (chk_deffunc): New routine.
+
+Tue Jun 25 19:24:43 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * pexecute.c (PEXECUTE_VERBOSE): Define.
+ (MPW pexecute): Check flags & PEXECUTE_VERBOSE instead of verbose_flag.
+
+Tue Jun 25 23:11:48 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (docdir): Removed.
+
+Tue Jun 25 23:01:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (oldincludedir): Removed.
+
+Tue Jun 25 22:50:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (datadir): Set to $(prefix)/share.
+
+Thu Jun 20 21:17:52 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cplus-dem.c (demangle_arm_pt): Reindent. Avoid endless loop by
+ checking for errors from do_type.
+
+Tue Jun 18 14:36:19 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: New file.
+ * xmalloc.c: If VMS, include <stdlib.h> and <unixlib.h> rather
+ than declaring malloc, realloc, and sbrk.
+
+Mon Jun 10 13:17:17 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * pexecute.c: New file.
+
+Wed Jun 5 16:57:45 1996 Richard Henderson <rth@tamu.edu>
+
+ * xmalloc.c: Declare sbrk.
+
+Sat May 4 05:08:45 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * alloca-norm.h: Add SPARCworks cc compatible __builtin_alloca
+ declaration.
+
+Mon Apr 22 18:41:49 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * xstrerror.c: Include <stdio.h>.
+
+Sun Apr 21 11:55:12 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (CFILES): Add atexit.c.
+
+Sun Apr 21 09:50:09 1996 Stephen L Moshier (moshier@world.std.com)
+
+ * choose-temp.c: Include sys/types.h before sys/file.h for sco3.2v5.
+
+Wed Apr 17 11:17:55 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * choose-temp.c: Don't #include sys/file.h ifdef NO_SYS_FILE_H.
+ #include <stdio.h>
+ * config/mt-vxworks5 (HDEFINES): Define NO_SYS_FILE_H.
+
+Tue Apr 16 11:27:16 1996 Jeffrey A Law (law@cygnus.com)
+
+ * Makefile.in (lneeded-list): If alloca.o is needed, so is xmalloc.o.
+ Reverts Feb 8, 1995 change.
+
+Mon Apr 15 12:53:26 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * choose-temp.c: New file.
+ * Makefile.in (CFILES): Add choose-temp.c.
+ (REQUIRED_OFILES): Add choose-temp.o.
+
+Sat Apr 13 14:19:30 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * floatformat.c (floatformat_to_double): Don't bias exponent when
+ handling zero's, denorms or NaNs.
+
+Thu Apr 11 13:36:56 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * floatformat.c (floatformat_to_double): Fix bugs with handling
+ numbers with fractions < 32 bits.
+
+Mon Apr 8 14:48:34 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.table: Permit --enable-shared to specify a list of
+ directories.
+
+Tue Mar 19 22:02:07 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (demangle_template): Fix for non-mangled pointer
+ arguments.
+
+Fri Mar 8 17:24:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: If srcdir is `.' and with_target_subdir is not
+ `.', then set MULTISRCTOP before calling config-ml.in.
+
+Thu Mar 7 13:37:10 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.c (mpw_open): Add debugging output option.
+
+Wed Mar 6 17:36:03 1996 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cplus-dem.c (demangle_template): Fix for address-of-extern arguments.
+
+Tue Feb 27 12:00:50 1996 Raymond Jou <rjou@mexican.cygnus.com>
+
+ * mpw.c (mpwify_filename): Change 6 to 5 in
+ strncmp (unixname, "/tmp/", 5).
+
+Tue Feb 20 10:55:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cplus-dem.c (demangle_template): Initialize is_bool. Correctly
+ handle 0 as a pointer value parameter.
+
+Mon Feb 5 16:41:44 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (all): Depend upon required-list.
+ (required-list): New target.
+ (clean): Remove required-list.
+
+Wed Jan 31 10:19:41 1996 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * win32.c: Deleted.
+ * config.table (i386-*-win32): Deleted.
+ * config/mh-i386win32: Deleted.
+
+Thu Jan 18 11:34:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * cplus-dem.c (cplus_demangle_opname): Change opname parameter to
+ const char *.
+ (cplus_mangle_opname): Change return type and opname parameter to
+ const char *. Don't cast return value.
+
+Tue Jan 16 12:13:11 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.c: Include Timer.h, in order to get m68k Microseconds trap
+ definition.
+
+Wed Jan 3 13:15:04 1996 Fred Fish <fnf@cygnus.com>
+
+ * obstack.c: Update copyright to 1996.
+ (_obstack_memory_used): Define new function. Called via
+ obstack_memory_used macro.
+
+Thu Dec 28 11:39:40 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * xstrdup.c: New file.
+ * Makefile.in (CFILES): Add xstrdup.c.
+ (REQUIRED_OFILES): Add xstrdup.o.
+ (xstrdup.o): New target.
+
+Mon Dec 11 18:18:52 1995 Mike Stump <mrs@cygnus.com>
+
+ * atexit.c: New stub to provide atexit on systems that have
+ on_exit, like SunOS 4.1.x systems.
+ * functions.def (on_exit, atexit): Ditto.
+
+Mon Dec 11 15:42:14 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw.c (mpw_abort): Remove decl.
+ (mpw_access): Move debugging printf.
+
+Sat Dec 2 01:25:23 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.table: Consistently use ${host} rather than ${xhost} or
+ ${target}.
+ * configure.in: Don't bother to set ${xhost} before calling
+ config.table.
+
+Tue Nov 28 14:16:57 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * Makefile.in (.c.o): Use test instead of the left bracket, to
+ avoid problems with some versions of make.
+
+Tue Nov 28 11:45:17 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Fix INCDIR edit to work with Nov 14 change.
+
+Tue Nov 21 11:26:34 1995 Fred Fish <fnf@rtl.cygnus.com>
+
+ * config/mh-hpux: Remove. It was only used to define EXTRA_OFILES,
+ which was set to just alloca.o, which is now automatically marked
+ as needed by the autoconfiguration process.
+
+Tue Nov 21 14:15:06 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config.table: Check ${with_cross_host} rather than comparing
+ ${host} and ${target}.
+
+Thu Nov 16 14:34:42 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: If with_target_subdir is empty, set xhost to
+ ${host} rather than ${target} before calling config.table.
+
+Tue Nov 14 01:38:30 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (MULTITOP): Deleted.
+ (MULTISRCTOP, MULTIBUILDTOP): New.
+ (FLAGS_TO_PASS): Delete INCDIR.
+ (INCDIR): Add $(MULTISRCTOP).
+ (install_to_libdir): Add $(MULTISUBDIR). Call $(MULTIDO).
+ * configure.in: Delete call to cfg-ml-com.in. Call config-ml.in
+ instead of cfg-ml-pos.in.
+ (cross-compile check): Change to test for with_target_subdir.
+ (EXTRA_LINKS): Delete.
+
+Sun Nov 12 12:13:04 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Add getpagesize.c.o to needed-list.
+ * mpw.c [USE_MW_HEADERS]: Conditionalize compiling of
+ functions that are supplied by Metrowerks libraries.
+ (fstat): Clean up descriptor->pointer conversion code.
+ (InstallConsole, etc): Empty definitions, for when linking
+ with SIOUX.
+
+Sun Nov 5 19:25:27 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * Makefile.in (FLAGS_TO_PASS): Also pass PICFLAGS.
+ (.c.o): Stylistic change.
+
+Thu Nov 2 12:06:29 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * strtol.c, strtoul.c: Don't include <stdlib.h>. From
+ phdm@info.ucl.ac.be (Philippe De Muyter).
+
+Wed Nov 1 11:59:36 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Correct sed call.
+
+Mon Oct 30 13:03:45 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * configure.in: Clean up / simplify for native.
+
+ * configure.in: Merge in stuff from ../xiberty/configure.in.
+ * Makefile.in (CC): Add definition (so it can be overrridden
+ by ../configure).
+
+Tue Oct 24 17:57:27 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Leave strerror.c.o in standard list of functions.
+ * mpw.c (R_OK, ENOENT, EACCESS, ENOSYS): Remove.
+ (link): Remove useless definition with error return.
+ (last_microseconds, warn_if_spin_delay, record_for_spin_delay):
+ Use UnsignedWide type for microsecond counts.
+
+Thu Oct 19 10:52:07 1995 Michael Meissner <meissner@wogglebug.tiac.net>
+
+ * memcmp.c (memcmp): Argument types are const void *, not void
+ *const.
+
+ * strncasecmp.c (strncasecmp): Include ansidecl.h/stdarg.h, not
+ sys/types.h.
+ * strcasecmp.c (strcasecmp): Ditto.
+
+Tue Oct 10 11:03:24 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (BISON): Remove macro.
+
+Tue Sep 26 15:06:46 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * Makefile.in (HFILES): Add default empty definition.
+ * mpw-config.in (config.h): Only update if changed.
+ * mpw-make.in: Remove.
+ * mpw-make.sed: New file, edits Makefile.in into MPW makefile.
+ * mpw.c: Remove semi-clone of strerror code.
+ (sys_nerr, sys_errlist): Define here.
+ (Microseconds): Only define as A-line trap if m68k Mac.
+
+Wed Sep 20 12:53:32 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (maintainer-clean): New synonym for distclean.
+
+Mon Aug 28 19:47:52 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * config.table: For host, generalize rs6000-ibm-aix*
+ to *-ibm-aix* so we also include powerpc.
+
+Tue Aug 22 03:18:05 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Fri Jun 16 18:35:40 1995 Pat Rankin (rankin@eql.caltech.edu)
+
+ * xstrerror.c: New file.
+ * Makefile.in, vmsbuild.com: Compile it.
+
+Mon Jul 31 12:16:32 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ * config.table (i386-*-win32): New.
+
+Fri Jul 21 11:35:52 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * Makefile.in (MULTITOP): New variable.
+ (MULTIDIRS, MULTISUBDIR, MULTIDO, MULTICLEAN): Likewise.
+ (all): Add multilib support.
+ (install_to_tooldir, *clean): Likewise.
+
+Mon Jul 10 11:47:27 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * makefile.dos (OBJS): Add hex.o. From DJ Delorie.
+
+Fri Jun 30 17:28:59 1995 Pat Rankin (rankin@eql.caltech.edu)
+
+ * vmsbuild.com: create "new-lib.olb", build libiberty under that
+ name, and then make it become "liberty.olb" when done, so that an
+ incomplete build attempt never leaves behind something which looks
+ like a complete library.
+
+Thu Jun 29 00:22:02 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * config/mh-i386pe: New file for PE hosts.
+ * config.table: Understand PE hosts.
+
+Wed Jun 28 19:13:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cplus-dem.c: Update from gcc.
+
+ * argv.c, dummy.c: If __STDC__, #include "alloca-conf.h" after
+ <stddef.h>.
+ * alloca-norm.h: If __STDC__, declare alloca with its parameter.
+
+Thu Jun 22 18:57:47 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.in (ALL_CFLAGS): Define NEED_basename.
+ * mpw.c: Only test DebugPI once whenever printing debug info.
+ (mpwify_filename): If filename is /tmp/foo, change it into :_foo,
+ also fix to not write on input filename buffer.
+ (mpw_access): Use stat() instead of open(), works for directories
+ as well as files.
+
+Mon Jun 19 00:33:22 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in: Massage broken shells that require 'else true'.
+
+Sat Jun 17 23:21:58 1995 Fred Fish <fnf@cygnus.com>
+
+ * alloca-norm.h: Declare alloca as type "PTR" to match functions.def.
+ Declare __builtin_alloca in the sparc case, as argv.c did.
+ * argv.c: Replace inline version of alloca-norm.h at start of file with
+ a #include of alloca-conf.h. Precede it with an include of ansidecl.h
+ because alloca-norm.h needs to declare alloca as "PTR".
+
+Mon Jun 12 14:24:26 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * win32.c: New file.
+
+Fri Jun 9 15:16:14 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * dummy.c: #include "alloca-conf.h".
+
+Wed Jun 7 11:46:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in (mostlyclean): Remove stamp-picdir.
+ (clean): Don't.
+
+Mon Jun 5 18:46:06 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * config.table (frags): Use toplevel pic frags.
+
+ * Makefile.in (PICFLAG): New macro.
+ (all): Depend on stamp-picdir.
+ (needed-list): Ditto.
+ (.c.o): Also build pic object.
+ (stamp-picdir): New rule.
+ (mostlyclean): Remove pic.
+ (clean): Remove stamp-picdir.
+
+Fri Mar 24 16:55:48 1995 Pat Rankin (rankin@eql.caltech.edu)
+
+ * vmsbuild.com (config.h): Add `#define NEED_basename'.
+
+Tue May 23 10:12:46 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * clock.c, getopt.c, strtod.c, vsprintf.c: Change from using LGPL
+ to libio-style copyright.
+ * getpagesize.c: Remove FSF copyright.
+
+Sat May 20 12:30:23 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Added improved VMS support from Pat Rankin:
+
+ Fri Mar 17 18:40:36 1995 Pat Rankin (rankin@eql.caltech.edu)
+
+ * vmsbuild.com: new file.
+
+ * getpagesize.c (getpagesize): implement for VMS;
+ * strerror.c (strerror, strerrno, strtoerrno): add rudimentary
+ support for EVMSERR.
+
+Thu May 18 17:01:42 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
+
+ * floatformat.c (floatformat_arm_ext): Define.
+
+Tue May 16 13:30:59 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * basename.c, bcmp.c, getcwd.c, insque.c, rename.c, sigsetmask.c,
+ strerror.c, strsignal.c: Remove FSF copyright.
+ * sigsetmask.c: #include <sys/types.h> - seems to be needed by ISC.
+
+Mon May 15 19:53:17 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * bcopy.c, bzero.c, memcmp.c, memcpy.c, memset.c, strchr.c,
+ strrchr.c, strstr.c, vfork.c: Remove FSF Copyright, because this
+ might contaminate libstdc++ with the LGPL. (OK'd by RMS 11 Oct 94.)
+ * strchr.c, strrchr.c: Add cast to suppress const warning.
+
+Thu May 4 14:36:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cplus-dem.c: Use const instead of CONST. Don't include
+ ansidecl.h directly.
+
+Wed Apr 19 01:30:27 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cplus-dem.c: Don't include libiberty.h. Do declare xmalloc and
+ xrealloc.
+ (-DMAIN): Don't rely on an externally-defined version number;
+ instead, require the version number to be defined as a
+ preprocessor macro. Handle the RS/6000 leading dot. Define
+ xmalloc, xrealloc and fatal. Don't strip a leading underscore
+ if we couldn't demangle the word.
+
+Tue Apr 4 13:03:51 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ (Old mpw.c change descriptions retained for informational value.)
+ * mpw.c (warning_threshold): Default to .4 sec.
+ (overflow_count, current_progress): New globals.
+ (warn_if_spin_delay): Include current progress type,
+ such as program name, in message.
+ (mpw_start_progress): Set current_progress variable from arg.
+ (mpw_end_progress): Report spin delays by power-of-two-size
+ buckets instead of constant-size buckets.
+
+ * mpw.c: Clean up formatting, types, returns, etc.
+ (ENOSYS): Define.
+ (mpw_fread, mpw_fwrite): Define.
+ (sleep): Define correctly.
+
+ * mpw.c: New code to implement cursor spinning support.
+ (umask): New function.
+ (mpw_fopen, mpw_fseek, stat, fstat): Call PROGRESS.
+
+ * mpw.c (mpw_basename, mpw_mixed_basename): New functions, find
+ basenames for MPW and MPW/Unix filenames.
+ (mpw_special_init): New function, calls Macsbug if desired.
+
+ * mpw.c: Add GPL notice.
+ (mpwify_filename): Add more transformations.
+ (mpw_fopen): Call mpwify_filename on file names.
+ (rename): Remove.
+ (chdir, getcwd): Add simple definitions.
+
+ * mpw.c: Random cleanups, remove unused code bits.
+ Added copy of strerror.c for gcc's use.
+ (stat, fstat, _stat): New versions based on Guido van Rossum code.
+
+ * mpw.c (mpw_fseek): Make it work correctly when doing SEEK_CUR.
+
+ * mpw.c (stat): Remove hack definition, get from sys/stat.h.
+ (fork, vfork, etc): Print error messages if called.
+ (getrusage, sbrk, environ, isatty, link, utime, mkdir, rmdir,
+ rename, chown): Define.
+
+ * mpw-config.in: New file, MPW version of configure.in.
+ * mpw-make.in: New file, MPW version of Makefile.in.
+ * mpw.c: New file, MPW compatibility routines.
+
+Fri Mar 24 14:10:30 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * basename.c: Include config.h before checking for NEED_basename.
+
+Thu Mar 23 19:09:54 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * functions.def: Add DEFFUNC for basename.
+
+ * basename.c: Only define basename if NEED_basename.
+
+Thu Mar 16 13:36:05 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * config.table: Fix --enable-shared logic for native builds.
+
+Mon Mar 13 11:05:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cplus-dem.c (demangle_template): Demangle bool literals properly.
+
+Mon Mar 6 23:57:28 1995 Stu Grossman (grossman@cygnus.com)
+
+ * strtol.c strtoul.c: Replace these with less buggy versions from
+ NetBSD. (strtoul in particular couldn't handle base 16.)
+
+Wed Mar 1 15:59:01 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/mt-vxworks5 (HDEFINES): Define NO_SYS_PARAM_H.
+
+ * clock.c: If NO_SYS_PARAM_H is defined, don't include
+ <sys/param.h>.
+ * getcwd.c, getpagesize.c, getruntime.c: Likewise.
+
+Fri Feb 17 15:40:55 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * getruntime.c (get_run_time): Don't assume that CLOCKS_PER_SEC is
+ a number; ANSI appears to permit any expression, including a
+ function call.
+
+ * config.table (*-*-vxworks5*): Use mt-vxworks5 when configuring
+ xiberty.
+ * config/mt-vxworks5: New file.
+
+Thu Feb 9 14:19:45 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * basename.c (basename): Change argument to be const.
+
+Wed Feb 8 18:06:52 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in (lneeded-list): Don't worry about xmalloc.
+
+Sun Jan 15 00:40:36 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * Makefile.in (distclean): Delete xhost-mkfrag.
+
+Thu Jan 12 16:54:18 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in (lneeded-list): If alloca.o is needed, so is xmalloc.o.
+
+Wed Jan 11 22:39:56 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * hex.c: New file.
+ * Makefile.in (REQUIRED_OFILES, CFILES): List it.
+ (hex.o): Add dependencies.
+
+ * cplus-dem.c (demangle_prefix): For GNU style constructor and
+ destructor names, try demangling the remainder of the string.
+
+Wed Dec 28 00:49:15 1994 Ian Lance Taylor <ian@tweedledumb.cygnus.com>
+
+ * vasprintf.c (int_vasprintf): New static function.
+ (vasprintf): Use int_vasprintf. Removes assumption that va_list
+ is assignment compatible.
+
+Sat Nov 5 19:29:12 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * Makefile.in (LIBCFLAGS): New variable.
+ (FLAGS_TO_PASS): Pass it.
+ (.c.o): Use it.
+
+Thu Nov 3 19:09:47 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * getopt.c, getopt1.c: Do compile these functions under Linux,
+ since many native versions are based on glibc but are buggy.
+
+Mon Oct 24 15:16:46 1994 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * vasprintf.c: Make 'format' arg be const, to avoid a mismatch
+ with prototype in GNU libc. Support stdarg.h as well as varargs.h.
+
+Tue Oct 11 17:48:27 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * Makefile.in (REQUIRED_OFILES): Add vasprintf.o.
+ * functions.def: Remove vasprintf.
+
+Wed Sep 14 17:04:55 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * xmalloc.c (first_break): New static variable.
+ (xmalloc_set_program_name): Record sbrk (0) in first_break.
+ (xmalloc): If memory allocation fails, try to report how much
+ memory was allocated by the program up to this point.
+ (xrealloc): Likewise.
+
+Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+ * Makefile.in (ERRORS_CC): New variable, defaulted to $(CC). Use it
+ when linking dummy.
+ * config.table: Add host RISCiX Makefile frag.
+ * config/mh-riscix: New file.
+
+Thu Aug 25 17:29:44 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * Makefile.in (FLAGS_TO_PASS): Define.
+ ($(RULE1)): Use $(FLAGS_TO_PASS).
+
+Wed Aug 24 17:08:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * vasprintf.c: Include <string.h>.
+ (vasprintf): Add casts to void for va_arg to avoid gcc warnings.
+ * xatexit.c: Declare malloc.
+
+Fri Aug 19 15:29:12 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle_args): Fix a bug in previous patch (the
+ one below).
+
+Thu Aug 18 14:37:14 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle args): Handle ARM repeat encoding where
+ the type index is greater than 9.
+
+Wed Aug 17 16:13:49 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle_qualified): accept optional '_' between
+ qualified name. This is baecause the template name may end with
+ numeric and can mixed up with the length of next qualified name.
+
+Wed Aug 3 05:52:14 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
+
+ * config/mt-sunos4: Use our standard location for cross-includes
+ and cross-libs when the target is also a "host" environment (ie no
+ newlib; includes and such don't belong to us). This is specific
+ to the Cygnus Support environment.
+
+Tue Aug 2 15:25:12 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle_template): demangle as xxx<'Q'> not
+ xxx<ch=81>.
+
+Mon Aug 1 17:02:48 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (main): flush stdout to make pipe work.
+
+Sat Jul 16 12:56:32 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * config.table (*-*-cxux7*): Recognize.
+ * floatformat.c (floatformat_m88110_ext) [HARRIS_FLOAT_FORMAT]:
+ Harris-specific float format.
+ * config/mh-cxux7: New file.
+
+Wed Jun 29 00:26:17 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * cplus-dem.c (demangle_template): Make sure that the result of
+ consume_count doesn't index beyond the end of the string.
+
+Mon Jun 20 23:54:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * cplus-dem.c (gnu_special): Handle vtable mangling of gcc-2.4.5 and
+ earlier. Improve test for new vtable mangling. Change output back
+ to `virtual table'.
+
+Mon Jun 20 11:37:30 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * obstack.c: Always compile this code, even if using the GNU
+ library. Avoids problems with relatively recent binary
+ incompatibility.
+
+Thu Jun 16 17:54:01 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * cplus-dem.c: Include libiberty.h.
+ (xmalloc, xrealloc, free): Don't declare.
+ (strstr): Don't declare parameters.
+ (xmalloc, xrealloc): Don't define.
+ (long_options): Add no-strip-underscores.
+ (main): Call xmalloc_set_program_name. Pass n in short options to
+ getopt_long. Handle option 'n' to not strip underscores.
+ (usage): Mention -n and --no-strip-underscores.
+
+Sun Jun 12 01:37:09 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cplus-dem.c (demangle_template): Separate consecutive >'s with a
+ space.
+ (gnu_special): Demangle template and qualified names in a vtable name.
+
+Fri May 27 12:27:52 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ From gas-2.3 and binutils-2.4 net releases:
+
+ Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com)
+
+ * makefile.dos: [new] Makefile for dos/go32
+ * configure.bat: update for latest files
+ * msdos.c: remove some functions now in libc.a
+
+Fri May 20 18:53:32 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * cplus-dem.c (gnu_special): Recognize thunks, as well as
+ the new naming style for vtables (when -fvtable-thunks).
+
+Wed May 18 13:34:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Makefile.in (XTRAFLAGS): Don't define.
+ (.c.o, dummy.o): Don't use XTRAFLAGS.
+ ($(RULE1)): Don't pass XTRAFLAGS down in recursive call.
+
+Fri May 13 16:02:12 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * vasprintf.c: New file.
+ * Makefile.in, functions.def: Add it.
+
+Fri May 13 16:20:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cplus-dem.c (demangle_fund_type): Grok bool.
+
+Fri May 6 14:44:21 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * config.table: Add go32
+ * config/mh-go32: New template.
+
+Fri May 6 11:01:59 1994 D. V. Henkel-Wallace (gumby@rtl.cygnus.com)
+
+ * config.table, config/mt-sunos4: config for when sun4 is cross target.
+
+Mon Apr 11 00:54:33 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+ * getopt.c [not __GNU_LIBRARY__] [__GCC__] [not __STDC__]:
+ Declare strlen to return int. Don't include stddef.h.
+
+Fri Apr 1 00:38:17 1994 Jim Wilson (wilson@mole.gnu.ai.mit.edu)
+
+ * getopt.c: Delete use of IN_GCC to control whether
+ stddef.h or gstddef.h is included.
+
+Thu Apr 14 14:00:56 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle_signature): Fix a bug in template function
+ type numbering.
+
+Wed Apr 13 17:23:03 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle_signature): Fix template function with arm
+ style argument type number, Tn.
+
+Wed Apr 13 17:11:15 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cplus-dem.c (optable): Add new[] and delete[].
+
+Fri Apr 8 11:21:42 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * argv.c (buildargv): Don't produce empty argument just because
+ there is trailing whitespace.
+
+Wed Apr 6 11:42:14 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cplus-dem.c (demangle_template): fix 'Q' qualified name bug.
+ Handle 'p' same as 'P'.
+ * cplus-dem.c (do_type): Handle 'p' same as 'P'.
+
+Sat Mar 26 12:00:13 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * floatformat.c (get_field, put_field): Fix off by one error in
+ little endian case.
+
+Thu Mar 24 10:40:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * floatformat.c (floatformat_from_double): Pass unsigned char *,
+ not char *, to put_field.
+
+Fri Mar 18 12:34:33 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * memmove.c: Re-wrote; placed in public domain.
+
+Wed Mar 16 10:33:07 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * cplus-dem.c (demangle_prefix): If ARM demangling, don't treat
+ __Q* as a constructor.
+
+Mon Mar 14 12:26:02 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * ieee-float.c: Removed; no longer used.
+ * Makefile.in: Changed accordingly.
+
+Mon Mar 7 12:28:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * floatformat.c (get_field): Removed unused local variable i.
+ (put_field): Removed unused local variable i.
+
+Sun Feb 27 21:50:11 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * floatformat.c: New file, intended to replace ieee-float.c.
+ * Makefile.in: Change accordingly.
+
+Thu Feb 24 11:51:12 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * getopt.c: Remove #ifdef GETOPT_COMPAT and #if 0 code.
+ (_getopt_initialize): New function, broken out of _getopt_internal.
+ (_getopt_internal):
+ If long_only and the ARGV-element has the form "-f", where f is
+ a valid short option, don't consider it an abbreviated form of
+ a long option that starts with f. Otherwise there would be no
+ way to give the -f short option.
+
+Thu Feb 10 14:44:16 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+ * getopt.c [not __GNU_LIBRARY__] [__GNUC__] [not IN_GCC]:
+ Test just __STDC__, not emacs.
+
+Wed Feb 9 00:14:00 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+ * getopt.c [not __GNU_LIBRARY__] [__GNUC__] [not IN_GCC]
+ [emacs] [not __STDC__]: Don't include stddef.h. Don't declare strlen.
+
+Fri Dec 24 19:43:00 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
+
+ * getopt.c (_NO_PROTO): Define before config.h is included.
+
+Mon Sep 20 15:59:03 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
+
+ * getopt.c, getopt1.c [emacs || CONFIG_BROKETS]: Include
+ <config.h> only under these, else "config.h".
+
+Thu Aug 12 18:16:49 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
+
+ * getopt.c, getopt1.c [HAVE_CONFIG_H]: Include
+ <config.h> instead of "config.h".
+
+Sun Feb 20 17:17:01 1994 Ian Lance Taylor (ian@lisa.cygnus.com)
+
+ * concat.c: Check ANSI_PROTOTYPES rather than __STDC__ to decide
+ whether to use prototypes or not.
+ * strerror.c (const): Never undefine; let ansidecl.h handle it.
+ * strsignal.c (const): Likewise.
+
+Thu Feb 17 13:27:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * xatexit.c (_xexit_cleanup): Declare as extern; don't initialize.
+ Merging common and initialized variables need not be supported by
+ ANSI C compilers.
+ (xatexit): Initialize _xexit_cleanup if not already set.
+ * xexit.c: Comment fix.
+
+Wed Feb 16 01:15:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * xmalloc.c: Don't declare xexit; it's declared in libiberty.h.
+ (xrealloc): If oldmem is NULL, allocate with malloc, rather than
+ assuming that realloc works correctly.
+
+Tue Feb 15 09:26:16 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * concat.c, ieee-float.c: Replace inclusion of <string.h>
+ with explicit function declarations, as recommended by Ian Taylor.
+
+Sat Feb 12 10:31:11 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * xmalloc.c (xmalloc, xrealloc): Use PTR and size_t throughout.
+ (malloc, realloc): Declare.
+
+Thu Feb 10 17:08:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * argv.c, basename.c: Include ansidecl.h and libiberty.h.
+ * concat.c, fdmatch.c, getruntime.c, spaces.c: Likewise.
+ * strerror.c, strsignal.c, xatexit.c, xexit.c: Likewise.
+ * xmalloc.c: Likewise.
+ * concat.c: Don't declare xmalloc. If __STDC__, use <stdarg.h>
+ macros, not <varargs.h> macros.
+ * spaces.c (spaces): Make return type const. Don't crash if
+ malloc returns NULL.
+ * strerror.c (struct error_info): Make name and msg fields const.
+ (error_names): Make const.
+ (strerrno): Make const.
+ (strtoerrno): Make argument const.
+ * strsignal.c (struct signal_info): Make name and msg fields
+ const.
+ (signal_names, sys_siglist): Make const.
+ (strsignal, strsigno): Make const.
+ (strtosigno): Make argument const.
+ * xatexit.c: Declare parameter types.
+ * xmalloc.c (name): Make const.
+ (xmalloc_set_program_name): Make argument const.
+ * Makefile.in (INCDIR): Define.
+ (.c.o): Use $(INCDIR).
+ (dummy.o): Likewise.
+ (argv.o, basename.o): New targets; depend on libiberty.h.
+ (concat.o, fdmatch.o, getruntime.o, spaces.o): Likewise.
+ (strerror.o, strsignal.o, xatexit.o, xexit.o): Likewise.
+ (xmalloc.o): Likewise.
+ (cplus-dem.o): New target; depend on demangle.h.
+ (getopt.o, getopt1.o): New targets; depend on getopt.h.
+ (ieee-float.o): New target; depend on ieee-float.h.
+ (obstack.o): New target; depend on obstack.h.
+
+Tue Feb 8 05:29:08 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ Handle obstack_chunk_alloc returning NULL. This allows
+ obstacks to be used by libraries, without forcing them
+ to call exit or longjmp.
+ * obstack.c (_obstack_begin, _obstack_begin_1, _obstack_newchunk):
+ If CALL_CHUNKFUN returns NULL, set alloc_failed, else clear it.
+ (_obstack_begin, _obstack_begin_1): Return 1 if successful, 0 if not.
+
+Tue Feb 8 00:32:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * concat.c, ieee-float.c: Include <string.h>.
+
+Sun Feb 6 21:28:46 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * xmalloc.c (xmalloc_set_program_name): New function.
+ (xmalloc, xrealloc): Include the name in the error message, if set.
+
+ * Replace atexit.c with xatexit.c.
+ * Makefile.in (CFILES), functions.def: Change references.
+
+Sat Feb 5 14:02:32 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * getruntime.c (get_run_time): Use getrusage or times if
+ HAVE_GETRUSAGE or HAVE_TIMES are defined.
+
+Fri Feb 4 15:49:38 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * atexit.c: New file.
+ * Makefile.in (CFILES), functions.def: Add it.
+ * xexit.c: New file.
+ * Makefile.in (CFILES, REQUIRED_OFILES): Add it.
+ * xmalloc.c (xmalloc, xrealloc): Call xexit instead of exit.
+ Change request for 0 bytes into request for 1 byte.
+
+Wed Feb 2 11:36:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * xmalloc.c (xmalloc, xrealloc): Print size using %lu, and cast to
+ unsigned long, to avoid warnings.
+
+Fri Jan 28 17:49:06 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * dummy.c: Don't include time.h ever; always define clock_t as
+ "unsigned long". Until gcc/fixincludes ensures that clock_t
+ exists, __STDC__ isn't a sufficient test. And if clock() doesn't
+ exist, clock_t probably doesn't either.
+
+Mon Jan 24 11:52:31 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * clock.c, getruntime.c: New files.
+ * Makefile.in: Add to file lists.
+ * functions.def (clock): Add to list.
+ * dummy.c (time.h): Add if __STDC__.
+ (clock_t): #define as "unsigned long" if not __STDC__.
+
+Tue Jan 11 11:27:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * strtod.c: Declare atof. From edler@jan.ultra.nyu.edu (Jan
+ Edler).
+
+Tue Dec 28 14:17:30 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Makefile.in (errors): Use CFLAGS as well as LDFLAGS when
+ linking.
+
+Fri Dec 17 12:26:07 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c (demangle_arm_pt): New function. Common code
+ for ARM template demangling.
+ * cplus-dem.c (demangle_class_name): Use demangle_arm_pt.
+ * cplus-dem.c (demangle_prefix): Likewise.
+
+Tue Nov 30 15:47:48 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cplus-dem.c (cplus_demangle_opname): Add CONST to please gcc.
+
+Sat Nov 27 11:05:50 1993 Fred Fish (fnf@cygnus.com)
+
+ Merge changes from tom@basil.icce.rug.nl (Tom R.Hageman)
+ * strerror.c, strsignal.c: As a small space optimization, don't
+ include messages when they aren't actually used.
+
+ Merge changes from takefive.co.at!joe (Josef Leherbauer)
+ * cplus-dem.c (demangle_prefix, demangle_function_name,
+ cplus_demangle_opname): Fixes for systems where cplus_marker
+ is something other than '$'.
+
+Fri Nov 26 13:51:11 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * waitpid.c: Simple-minded approcimation to waitpid
+ using vanilla wait.
+ * functions.def, Makefile.in: Update accordingly,
+
+Thu Nov 18 18:01:15 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c(demangle_template): fix bug template instantiation
+ with value of user defined type.
+
+Wed Nov 17 18:30:21 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c(cplus_demangle_opname): add the subject new function
+ to support unified search of operator in class.
+
+Wed Nov 10 09:47:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ gcc -Wall lint:
+ * strtoul.c (strtoul): use "(digit = *s) != '\0'" not just
+ "digit = *s" as condition in while loop.
+
+Tue Nov 9 15:52:22 1993 Mark Eichin (eichin@cygnus.com)
+
+ * Makefile.in: pass SHELL to recursive make
+
+Thu Nov 4 12:09:26 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * vfprintf.c, vprintf.c, vsprintf.c: Make format arg
+ be (const char*), for ANSI (and gcc w/fixproto) consistency.
+
+Thu Nov 4 08:29:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.table: Make *-*-hiux* use mh-hpux.
+
+Fri Oct 22 07:53:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * config.table: Add * to end of all OS names.
+
+Tue Oct 19 17:12:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in (lneeded-list): ensure that object file names are
+ not duplicated, as multiple instances of the same object file in
+ a library causes problems on some machines
+
+Mon Oct 18 21:59:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * strcasecmp.c, strncasecmp.c: Change u_char to unsigned char.
+
+Fri Oct 15 22:17:11 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * strncasecmp.c: new file, implements strncasecmp
+ * strcasecmp.c: new file, implement strcasecmp
+
+ * Makefile.in (CFILES): list these two new source files
+
+ * functions.def: add strcasecmp and strncasecmp entries
+
+Fri Oct 15 14:53:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * strtoul.c (strtoul), strtol.c (strtol): Handle overflow
+ according to ANSI C.
+
+Thu Oct 14 16:34:19 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c: add support of ARM global constructor/destructor,
+ and 'G' for passing record or union in parameter.
+
+Wed Oct 13 13:36:19 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Fix comment to clarify that stuff in REQUIRED_OFILES
+ should not be in functions.def.
+
+Wed Oct 13 13:13:38 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * functions.def: Removed xmalloc. Stuff in REQUIRED_OFILES should
+ not be in functions.def.
+
+Mon Oct 4 18:26:39 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c: change globl constructor/destructor to proper name
+
+Tue Sep 28 18:11:07 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c: fix bug in constructor/destructor
+
+Tue Sep 28 16:20:49 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c: support both old and new _vt$... vtbl mangled names
+
+Fri Sep 24 19:07:16 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cplus-dem.c: Fix demangle_template prototype
+
+Fri Sep 24 17:32:55 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cplus-dem.c: fix template demangling
+ * cplus-dem.c: fix const type demangling
+ * cplus-dem.c: fix constructor/destructor, virtual table,
+ qualifier, global constructor/destructor demangling
+
+Wed Sep 1 23:13:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * strsignal.c, strerror.c: Use fully-bracketed initializer to
+ keep gcc -Wall happy.
+
+Fri Aug 27 10:30:09 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cplus-dem.c (do_type): Add CONSTS to make gcc happy with last
+ patch.
+
+Fri Aug 27 11:24:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ Patch from Paul Flinders:
+ * cplus-dem.c (do_type): Deal with arrays.
+
+Tue Aug 24 14:23:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * cplus-dem.c (demangle_qualified: Deal with GNU format for more
+ than 9 classes.
+
+Wed Aug 18 19:50:29 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * Makefile.in (dummy.o): Redirect to /dev/null to avoid "variable
+ not initialized" warnings under HP/UX
+
+Sun Aug 15 20:42:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * strerror.c: Move include of stdio.h after sys_errlist #define.
+ Also remove NULL definition (stdio.h always defines NULL, so it
+ never did anything but clutter up the code).
+
+Sat Aug 14 14:21:49 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * Makefile.in, functions.def: handle xmalloc.c
+
+ * xmalloc.c: provide xmalloc and xrealloc functions
+
+Thu Aug 12 17:38:57 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * cplus-dem.c: Fix a comment.
+
+Sat Aug 7 13:56:35 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * getopt1.c: Declare const the way getopt.c does.
+
+Fri Aug 6 17:03:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * obstack.c, alloca.c: Update from FSF.
+ * getopt.c, getopt1.c: Update to current FSF version, which
+ doesn't use alloca.
+
+Tue Jul 27 14:03:57 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * Makefile.in (demangle): Add the target with a message saying
+ where demangle went.
+
+Mon Jul 26 15:49:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Remove obsolete `demangle' target.
+
+Thu Jul 22 08:31:01 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * cplus-dem.c (arm_special): Apply patch from arg@lucid.com to
+ avoid infinite loop on vtbl symbols with disambiguating "junk"
+ tacked on the end.
+
+Mon Jul 19 14:10:37 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
+
+ * strsignal.c: work around some systems losing definitions of
+ sys_siglist
+
+ * config/mh-lynxos: this system has a losing definition of
+ sys_siglist
+
+ * config.table: use mh-lynxos for *-*-lynxos
+
+Mon Jul 19 17:08:52 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * config.table: Add support for HPPA BSD hosts.
+
+ * config/mh-hpbsd: New file.
+
+Mon Jul 12 18:00:40 1993 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in (TAGS): make work when srcdir != objdir.
+
+Sun Jun 27 15:35:31 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * cplus-dem.c (main): Add long options, including --help and
+ --version.
+ (usage): New function from code in main.
+
+Tue Jun 22 11:37:38 1993 Per Bothner (bothner@deneb.cygnus.com)
+
+ * config.table: New shell scipt, sourced by both ./configure,in
+ and ../xiberty/configure.in, to avoid maintainance lossages.
+ * configure.in and ../xiberty/configure.in: Use config.table.
+
+ * configure.in: Don't use mh-aix for AIX 3.2, only for 3.1.
+ * configure.in: Map *-*-irix* (except irix4) to mh-sysv.
+ * ../xiberty/configure.in: Update from ./configure.in.
+
+Tue Jun 15 17:05:31 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: remove parentdir support
+
+Wed May 26 12:59:09 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * cplus-dem.c (xrealloc): Match definition with prototype.
+
+Tue May 25 14:27:51 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * cplus-dem.c (demangle_prefix): Demangle cfront
+ local variables as an extension to ARM demangling.
+
+Fri May 21 09:53:57 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * ieee-float.c: Don't require pointers to double to be aligned.
+
+Tue May 18 17:12:10 1993 Fred Fish (fnf@cygnus.com)
+
+ (merge changes from dlong@cse.ucsc.edu)
+ * cplus-dem.c (consume_count): Simplify.
+ * cplus-dem.c (arm_pt, demangle_class_name): New functions.
+ * cplus-dem.c (various): Calls to arm_pt, demangle_class_name.
+
+ * cplus-dem.c (xmalloc, xrealloc, strstr): Make extern decls into
+ full prototypes.
+ * cplus-dem.c (free): Add prototype.
+ * cplus-dem.c (optable): Fully bracketize initializer.
+
+Fri May 14 17:13:05 1993 Per Bothner (bothner@cygnus.com)
+
+ * cplus-dem.c: Whether initial underscores are stripped
+ depends on the external variable prepends_underscore
+ (which is generated by the binutils Makefile).
+
+Fri May 14 07:32:20 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * cplus-dem.c (mop_up, arm_special): Remove some unused variables.
+
+Tue May 4 20:31:59 1993 Fred Fish (fnf@cygnus.com)
+
+ * cplus-dem.c (consume_count): Return zero if arg does not
+ start with digit, and don't consume any input.
+
+Tue May 4 08:10:28 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * Makefile.in (demangle): Use ${srcdir} not $^.
+
+ * strtod.c: New file, needed at least for BSD 4.3.
+
+Sun May 2 11:30:42 1993 Fred Fish (fnf@cygnus.com)
+
+ * strsignal.c (sys_siglist): For ANSI compilations, type is
+ "const char *const". Also remove conditionalization on __STDC__
+ since const is defined away for non-ANSI.
+
+Wed Apr 28 19:29:55 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
+
+ * configure.in: Recognize *-*-hpux.
+ * config/mh-hpux: New file.
+
+Tue Apr 27 15:22:19 1993 Per Bothner (bothner@cygnus.com)
+
+ * tmpnam.c: Added ANSI tmpnam() function.
+ * functions.def, Makefile.in: Update accordingly.
+
+Tue Apr 27 13:38:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * cplus-dem.c (demangle_function_name): Get the demangling of
+ stop__1A right.
+
+Fri Apr 16 23:48:24 1993 Jim Kingdon (kingdon at calvin)
+
+ * cplus-dem.c: Declare strstr return type.
+
+Fri Mar 26 12:01:26 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * strsignal.c: Add some AIX signals.
+
+Thu Mar 25 15:17:23 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in (MAKEOVERRIDES): Define to be empty.
+
+Wed Mar 24 01:59:25 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
+
+ * Makefile.in: add installcheck & dvi targets
+
+Thu Mar 18 14:05:44 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * ieee-float.c: New file, moved from ../gdb (since it is
+ needed by ../opcode/m68k-dis.c).
+
+Tue Mar 2 17:47:31 1993 Fred Fish (fnf@cygnus.com)
+
+ * cplus-dem.c: Replace all references to cfront with ARM.
+
+Fri Feb 26 00:17:07 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * cplus-dem.c: Fix main program (when compiled with -DMAIN)
+ to be more useful as a filter.
+
+Sat Feb 20 21:41:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * Makefile.in (install_to_libdir, install_to_tooldir): Go into the
+ destination directory before running $(RANLIB), in case that
+ program tries to create a file in the current directory as part of
+ its work.
+
+Thu Feb 18 23:00:19 1993 John Gilmore (gnu@cygnus.com)
+
+ * strsignal.c (sys_siglist): Remove yet another *%^&%&$# "const"
+ because BSD 4.4 lacks one. Isn't this fun?
+
+Thu Feb 18 11:24:25 1993 Fred Fish (fnf@cygnus.com)
+
+ * cplus-dem.c (demangle_signature): Set func_done after
+ demangling a template.
+ * cplus-dem.c (demangle_template): Fix several small bugs
+ in demangling GNU style templates.
+ * cplus-dem.c (demangle_prefix): Fix for templates in GNU
+ style constructors.
+ * cplus-dem.c (gnu_special): Fix for templates in GNU style
+ static data members.
+
+Tue Feb 16 17:28:35 1993 Fred Fish (fnf@cygnus.com)
+
+ * cplus-dem.c (demangle_signature): Modify to include type
+ modifiers like static and const in remembered types.
+
+Thu Feb 11 22:20:47 1993 Fred Fish (fnf@cygnus.com)
+
+ * cplus-dem.c (demangled_qualified): Add new parameter that tells
+ whether to prepend or append the qualifiers.
+ * cplus-dem.c (string_prepends): Used now, remove #if 0.
+ * cplus-dem.c (demangle_signature): Call demangle_qualified
+ with prepending.
+ * cplus_dem.c (gnu_special): Recognize static data members that
+ use qualified names.
+ * cplus-dem.c (demangle_qualified): Accumulate qualifiers in a
+ temporary buffer and the prepend or append them to the result,
+ as specified by the new "append" flag.
+ * cplus-dem.c (do_type): Call demangled_qualified with
+ appending.
+
+Mon Dec 28 10:47:19 1992 Ken Raeburn (raeburn@cygnus.com)
+
+ * strsignal.c (signal_table): Now const.
+ (init_signal_tables): Variable eip now points to const.
+
+ * strerror.c (error_table): Now const.
+ (init_error_tables): Variable eip now points to const.
+
+Tue Dec 15 15:36:50 1992 Per Bothner (bothner@cygnus.com)
+
+ * memchr.c (memchr): New (ANSI standard) function.
+ * Makefile.in, functions.def: Added memchr.
+ * Makefile.in (AR_FLAGS): Use rc instad of non-standard cq.
+
+Wed Dec 2 22:49:10 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * getopt.c: remove use of USG around <alloca.h>, which never meant
+ anything anyway
+
+ * config/mh-{aix,apollo68,ncr3000,sysv,sysv4}: removed definitions
+ of USG and USGr4
+
+Thu Nov 19 03:09:33 1992 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cplus-dem.c (demangle_fund_type): Recognize `w', a wide character;
+ it's now a type according to the ANSI X3J16 working paper; output
+ "wchar_t" for it.
+ (demangle_template): Accept `w' as an integral type.
+ (xmalloc, xrealloc): Use `char *', not `PTR'. Cast calls to their
+ counterparts malloc and realloc to `char *'.
+ (main): Exit with a 0 status.
+ * Makefile.in (demangle): Don't expect the user to define
+ DEMANGLE, instead force to be cplus-dem.c. Look in $(srcdir)/../include
+ for demangle.h. Pass it any HDEFINES or XTRAFLAGS.
+
+Wed Nov 18 18:56:20 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (AR_FLAGS): Avoid verbosity.
+ * config/mh-sysv4: Remove AR_FLAGS override, use INSTALL=cp,
+ replace USGr4 with HAVE_SYSCONF.
+ * config/mh-solaris: Remove; mh-sysv4 works now.
+ * getpagesize.c: Replace USGr4 with HAVE_SYSCONF.
+ * configure.in: Simplify host matching table, remove separate
+ solaris config file.
+
+Sun Nov 15 09:35:16 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in (i[34]86-*-solaris2*): Add, use mh-sysv4.
+
+Tue Nov 3 21:27:03 1992 Brendan Kehoe (brendan@cygnus.com)
+
+ * cplus-dem.c (xmalloc, xrealloc): Add decls.
+ (remember_type): Don't cast xmalloc.
+ (string_need): Likewise; don't cast xrealloc either.
+
+Fri Oct 23 08:52:01 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in, functions.defs, rename.c: added simple
+ implementation of rename, since some binutils programs use it.
+
+Thu Oct 15 15:18:22 1992 Per Bothner (bothner@cygnus.com)
+
+ * strsignal.c: Add appropriate 'const' to sys_siglist
+ extern declaration (if __STDC__). (Needed for Linux.)
+ * strsignal.c (strsignal): Add cast to remove const-ness.
+
+Fri Oct 9 03:22:55 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (needed.awk, needed2.awk): Remove erroneous \'s
+ before "'s, diagnosed by BSD 4.4 awk.
+
+Thu Oct 8 15:25:12 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: create config.h and needed-list through $(CONFIG_H)
+ and $(NEEDED_LIST), to give some hooks for xiberty.
+
+Thu Oct 1 23:31:42 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: use cpu-vendor-triple instead of nested cases
+
+Wed Sep 30 11:26:59 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in, argv.c, basename.c, bcmp.c, bcopy.c, bzero.c,
+ concat.c, cplus-dem.c, fdmatch.c, getcwd.c, getopt.c, getopt1.c,
+ getpagesize.c, insque.c, memcmp.c, memcpy.c, memmove.c, memset.c,
+ obstack.c, sigsetmask.c, spaces.c, strchr.c, strerror.c,
+ strrchr.c, strsignal.c, strstr.c, vfork.c, vsprintf.c:
+ Convert from using GPL to LGPL.
+
+Sat Sep 26 04:01:30 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (errors): Leave dummy.o and dummy around so that
+ we can see how the needed list was generated (it's sometimes wrong).
+ (mostlyclean): Remove them.
+
+Mon Sep 21 14:50:42 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * getcwd.c: supply a default if MAXPATHLEN is not defined.
+
+ * config/mh-irix4: set EXTRA_OFILES to alloca.o, from WRS.
+
+Wed Sep 9 12:41:48 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: Use XTRAFLAGS when compiling, so that xiberty works
+ when cross-compiling.
+
+Thu Sep 3 13:29:39 1992 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * cplus-dem.c: (demangle_prefix): reduction in strength of strstr
+ as a time optimization.
+
+ * cplus-dem.c (cplus_demangle): remove strpbrk test. Appears to
+ be more expensive than simply demangling.
+
+ * cplus-dem.c (cplus_match): new function.
+
+Tue Sep 1 15:24:04 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * cplus-dem.c: #include <stdio.h>, to define NULL.
+ Define current_demangling_style.
+
+Sun Aug 30 17:58:19 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * cplus-dem.c: New file, moved from ../gdb.
+ * cplus-dem.c (set_cplus_marker_for_demangling): New exported
+ function, to avoid compiling in target-dependency for CPLUS_MARKER.
+ * cplus-dem.c (cplus_demangle): Allow demangling style option
+ to be passed as a parameter, but using the global variable
+ current_demangling_style as a default.
+ * Makefile.in: Update for cplus-dem.c
+
+Sat Aug 29 10:44:09 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.c: Merge in comment changes from FSF version. Now
+ matches the FSF version exactly.
+
+Fri Aug 28 18:39:08 1992 John Gilmore (gnu@cygnus.com)
+
+ * obstack.c (CALL_FREEFUN): Can't use ?: with void values (at
+ least on losing DECstations!); use if-then-else instead.
+
+Wed Aug 19 14:40:34 1992 Ian Lance Taylor (ian@cygnus.com)
+
+ * Makefile.in: always create installation directories.
+
+Mon Aug 10 17:33:40 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: clean up definition of CFILES, more comments
+
+Sat Aug 8 23:10:59 1992 Fred Fish (fnf@cygnus.com)
+
+ * getopt.c (my_index): Make first arg const to match strchr,
+ which it sometimes is remapped to.
+
+Sat Aug 1 13:48:50 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.c (DEFAULT_ALIGNMENT): Update to match FSF version.
+ * obstack.c (_obstack_begin): Initialize use_extra_arg.
+ * obstack.c (_obstack_begin_1): New, from FSF version.
+
+Mon Jul 20 21:07:58 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.c (CALL_CHECKFUN, CALL_FREEFUN): Use use_extra_arg and
+ extra_arg.
+ * obstack.c (_obstack_begin): Remove area_id and flags arguments
+ (previously added for mmalloc support, interface has changed).
+ Also convert flags usage to use use_extra_arg and maybe_empty_object.
+
+Fri Jul 10 00:41:53 1992 Fred Fish (fnf@cygnus.com)
+
+ * argv.c: Move expandargv inline and eliminate static variables.
+ Rewrite to always allocate in powers of two. Fix to return an
+ argv with a single null string arg if passed a null string.
+
+Fri Jul 3 20:27:29 1992 Fred Fish (fnf@cygnus.com)
+
+ * random.c, sigsetmask.c, strerror.c, strsignal.c: Remove
+ "(void)" casts from function calls where the return value is
+ ignored, in accordance with GNU coding standards.
+
+Mon Jun 29 10:54:19 1992 Fred Fish (fnf at cygnus.com)
+
+ * bcopy.c, strerror.c, strsignal.c: Lint.
+
+Thu Jun 25 09:18:41 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * getopt.c: merge changes from make.
+
+Thu Jun 25 04:43:22 1992 John Gilmore (gnu at cygnus.com)
+
+ * alloca.c: Incorporate fixes from gdb/alloca.c.
+ FIXME: Eventually move gdb's alloca configuration files here,
+ and remove gdb/alloca.c and its Makefile.in support.
+
+Tue Jun 23 21:56:30 1992 Fred Fish (fnf@cygnus.com)
+
+ * dummy.c: Define NOTHING to /*nothing*/, change return type
+ of main to int and return zero.
+ * functions.def: Supply NOTHING as the fourth arg to macros
+ that don't have an explicit arg, to satisfy picky preprocessors.
+
+Wed Jun 17 18:13:58 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in: Clean up *clean rules, as per standards.texi.
+
+Tue Jun 16 16:11:59 1992 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * getopt.c, getopt1.c: merged largely gratuitous, mostly
+ whitespace diffs from other prep distributions.
+
+Mon Jun 15 12:25:46 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install,
+ it is broken on ncr 3000's.
+
+Mon Jun 15 01:03:26 1992 John Gilmore (gnu at cygnus.com)
+
+ * sigsetmask.c: Rewrite. Old one was very confused about its
+ arguments and result. New one can't do much, but at least knows
+ what it can't do, and it's good enough for GDB's use.
+
+Sun Jun 14 15:17:40 1992 Stu Grossman (grossman at cygnus.com)
+
+ * functions.def: Use proper prototype for strtoul.
+
+Fri Jun 12 19:22:40 1992 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Add random.c.
+ * config/mh-*: Use "true" rather than "echo >/dev/null" for ranlib.
+ * configure.in: update solaris2 config.
+
+Wed Jun 10 16:31:29 1992 Fred Fish (fnf@cygnus.com)
+
+ * random.c: Add for random() and srandom().
+ * functions.def: Add random
+
+Tue Jun 9 17:27:18 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/{mh-ncr3000, mh-sysv4}: Add definition for INSTALL
+ using /usr/ucb/install.
+
+Mon Jun 1 13:20:17 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * strerror.c: Kludge to guard against a conflict with
+ possible declaration of sys_errlist in errno.h.
+
+Sun May 31 15:07:47 1992 Mark Eichin (eichin at cygnus.com)
+
+ * configure.in, config/mh-solaris: add solaris2 config support.
+
+Fri May 29 17:23:23 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * sigsetmask.c: #ifdef out sigsetmask if SIG_SETMASK
+ is not defined (should be defined in signal.h, says Posix.).
+
+Mon May 18 17:35:04 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * getopt.c: merged changes from make-3.62.11.
+
+Fri May 8 14:53:07 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * getopt.c: merged changes from bison-1.18.
+
+Tue May 5 11:51:40 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in: Don't have $(EXTRA_OFILES) depend on config.h,
+ since that introduces a circular dependency.
+ ($(EXTRA_OFILES) are used to build config.h.)
+
+ * strtoul.c: Fixes to handle non-decimal bases better.
+
+Wed Apr 22 09:27:51 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/mh-ncr3000: Replace MINUS_G with CFLAGS.
+ * Makefile.dos: Finish MINUS_G eradication.
+ * Makefile.in (CFILES): Add strsignal.c.
+ * Makefile.in (REQUIRED_OFILES): Add strerror.o strsignal.o
+ * Makefile.in (needed-list): Split creation of errors file to
+ separate make target.
+ * Makefile.in (config.h, needed2.awk, errors): New targets.
+ * Makefile.in (clean): Split to multiple lines, add needed2.awk
+ and config.h.
+ * dummy.c (DEFFUNC, DEFVAR): Add defines and undefs.
+ * functions.def (strerror): Remove from optional list.
+ * functions.def (sys_nerr, sys_errlist, sys_siglist): DEFVAR's
+ * functions.def (strerror, psignal): DEFFUNC's
+ * strerror.c: Rewrite from scratch to use sys_errlist only if
+ available, add errno_max(), add strerrno(), add strtoerrno(),
+ add test driver.
+ * strsignal.c: New file, signal equivalent to strerror.c.
+ Uses sys_siglist if available, defines signo_max(), strsignal(),
+ strsigno(), strtosigno(), psignal(), and test driver.
+
+Mon Apr 20 20:49:32 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in: do not print recursion line.
+
+ * Makefile.in: allow CFLAGS to be passed in from command line.
+ Removed MINUS_G. Default CFLAGS to -g.
+
+Mon Apr 20 12:57:46 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * config/mh-aix: New. EXTRA_OFILES lists copysign.o,
+ so libg++ users don't have to be inconvenienced by a
+ libc.a bug (libc.a needs copysign, but doesn't define it!).
+ * configure.in: Use config/mh-aix.
+ * strtoul.c: Handle '-' as required by ANSI.
+ Clean up radix handling.
+ * strstr.c: Fix buggy algorithm.
+ * Makefile.in: Change so that ${EXTRA_OFILES} is
+ appended to needed-list (which is used by libg++).
+
+Fri Apr 10 22:51:41 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in: Recognize new ncr3000 config.
+ * config/mh-ncr3000: New config file.
+
+Wed Apr 1 23:31:43 1992 John Gilmore (gnu at cygnus.com)
+
+ * argv.c, dummy.c: Lint.
+
+Tue Mar 31 18:46:44 1992 Fred Fish (fnf@cygnus.com)
+
+ * config/mh-sysv4: New config file.
+ * configure.in (host_makefile_frag): Set to config/mh-sysv4 for
+ host_os == sysv4.
+ * getpagesize.c: For SVR4, use sysconf(_SC_PAGESIZE) to get
+ pagesize.
+
+Sun Mar 29 12:26:42 1992 John Gilmore (gnu at cygnus.com)
+
+ * getopt.c: Lint.
+
+Fri Mar 27 08:32:55 1992 Fred Fish (fnf@cygnus.com)
+
+ * functions.def (alloca): Fix return type and args to avoid
+ type clash with gcc's builtin alloca.
+
+Tue Mar 24 23:33:42 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * configure.in, config/mh-irix4: irix4 support.
+
+ * Makefile.in, functions.def, alloca.c: added alloca.
+
+Tue Mar 24 17:34:46 1992 Stu Grossman (grossman at cygnus.com)
+
+ * obstack.c (CALL_FREEFUN): Make it compile on DECstations.
+
+Thu Mar 19 13:57:42 1992 Fred Fish (fnf@cygnus.com)
+
+ * argv.c: Fix various external function definitions to be
+ correct in an ANSI compilation environment.
+
+Sat Mar 14 17:28:17 1992 Fred Fish (fnf@cygnus.com)
+
+ * obstack.c: Changes to support calling mmalloc functions,
+ which take an additional argument over malloc functions.
+
+Fri Mar 6 22:01:10 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * added check target.
+
+Thu Feb 27 22:19:39 1992 Per Bothner (bothner@cygnus.com)
+
+ * argv.c: #include alloca-conf.h (needed by AIX).
+
+Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
+
+ * Makefile.in, configure.in: removed traces of namesubdir,
+ -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
+ copyrights to '92, changed some from Cygnus to FSF.
+
+Sat Feb 22 01:09:21 1992 Stu Grossman (grossman at cygnus.com)
+
+ * argv.c: Check in Fred's version which fixes problems with
+ alloca().
+
+Fri Feb 7 21:46:08 1992 Stu Grossman (grossman at cygnus.com)
+
+ * makefile.dos: Remove NUL to keep patch from failing.
+
+Thu Jan 30 22:48:41 1992 Stu Grossman (grossman at cygnus.com)
+
+ * getopt.c (_getopt_internal): Fix usage of enum has_arg.
+
+Mon Jan 20 18:53:23 1992 Stu Grossman (grossman at cygnus.com)
+
+ * getopt.c, getopt1.c, ../include/getopt.h: Get latest versions.
+
+Sat Jan 18 16:53:01 1992 Fred Fish (fnf at cygnus.com)
+
+ * argv.c: New file to build and destroy standard argument
+ vectors from a command string.
+
+ * Makefile.in: Add argv.c and argv.o to appropriate macros.
+
+Fri Dec 20 12:12:57 1991 Fred Fish (fnf at cygnus.com)
+
+ * configure.in: Change svr4 references to sysv4.
+
+ * rindex.c: Declare return type of externally used function
+ strrchr().
+
+Thu Dec 19 18:35:03 1991 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Remove "***" in normal output, since Make produces
+ this on errors, and it's convenient to search for.
+
+Tue Dec 17 23:21:30 1991 Per Bothner (bothner at cygnus.com)
+
+ * memcmp.c, memcpy.c, memmove.c, memset.c, strchr.c, strrchr.c:
+ New ANSI functions. The old non-ANSI functions (such as bcopy)
+ should be avoided.
+ * bcopy.c: Fix to correctly handle overlapping regions.
+ * index.c, rindex.c: Re-write in terms of strchr() and strrchr().
+ * functions.def: Add the new functions.
+ * functions.def: Add 4th parameter to DEF macro,
+ an ansidecl.h-style prototype.
+ * dummy.c: Use expanded DEF macro to create a dummy function
+ call, with correct parameter types. (This avoids some
+ complaints from gcc about predefined builtins.)
+
+ Move the functionality of config/mh-default into Makefile.in.
+ This avoid duplication, and simplifies things slightly.
+ * Makefile.in: Tweak so we don't need config/mh-default.
+ * README: Update.
+ * configure.in: No longer need config/mh-default.
+ * config/mh-default: Deleted.
+ * config/mh-sysv: Remove lines copied from old mh-default.
+
+Tue Dec 17 05:46:46 1991 John Gilmore (gnu at cygnus.com)
+
+ * fdmatch.c (fdmatch): Don't compare st_rdev, which is for
+ 'mknod' device numbers.
+
+Mon Dec 16 12:25:34 1991 Fred Fish (fnf at cygnus.com)
+
+ * fdmatch.c, Makefile.in: Add new function that takes two
+ open file descriptors and returns nonzero if they refer to
+ the same file, zero otherwise. (used in gdb)
+
+Wed Dec 11 17:40:39 1991 Steve Chamberlain (sac at rtl.cygnus.com)
+ From DJ:
+ * msdos.c: stub functions for dos.
+ * makefile.dos, configdj.bat: new.
+ * getopt.c: Don't include alloca-conf.h in a GO32 world.
+
+
+Tue Dec 10 04:14:49 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: infodir belongs in datadir.
+
+Fri Dec 6 23:26:45 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: remove spaces following hyphens because bsd make
+ can't cope. added standards.text support. install using
+ INSTALL_DATA.
+
+ * configure.in: remove commontargets as it is no longer a
+ recognized hook.
+
+Thu Dec 5 22:46:46 1991 K. Richard Pixley (rich at rtl.cygnus.com)
+
+ * Makefile.in: idestdir and ddestdir go away. Added copyrights
+ and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
+ and mandir now keyed off datadir by default.
+
+Fri Nov 22 19:15:29 1991 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: find-needed.awk does not fit in 14 chars.
+
+ * Makefile.in: Suppress error checking when compiling the test
+ program, because Ultrix make/sh aborts there due to a bug.
+
+Fri Nov 22 12:23:17 1991 Per Bothner (bothner at cygnus.com)
+
+ * Makefile.in: Re-did how EXTRA_OFILES is used to be more useful.
+ * README: Explained how the auto-configuration works,
+ and how to add new files and/or configurations.
+
+Fri Nov 22 09:45:23 1991 John Gilmore (gnu at cygnus.com)
+
+ * strtoul.c: Avoid defining ULONG_MAX if already defined;
+ cast a const char * to char * for pedants.
+
+ * getopt.c: Only define "const" after local include files get to,
+ and only if they haven't defined it.
+
+Thu Nov 21 16:58:53 1991 John Gilmore (gnu at cygnus.com)
+
+ * getcwd.c (remove getwd.c): GNU code should call getcwd(). We
+ emulate it with getwd() if available. This avoids callers having
+ to find a MAXPATHLEN or PATH_MAX value from somewhere.
+ * Makefile.in, functions.def: getwd->getcwd.
+ * configure.in: Use generic case for every system.
+ * config/mh-{delta88,mach,rs6000,svr4}: Remove.
+ * config/mh-sysv: Use default handling, just add -DUSG.
+
+Thu Nov 14 10:58:05 1991 Per Bothner (bothner at cygnus.com)
+
+ * Makefile.in, config/mh-default: Re-do make magic
+ so that for the default ("automatic") mode we only
+ compile the files we actually need. Do this using
+ a recursive make: The top-level generates the list
+ of needed files (loosely, the ones missing in libc),
+ and then passes that list to the recursive make.
+ * config/mh-mach: Remove obsolete STRERROR-{C,O} macros.
+
+Tue Nov 12 19:10:57 1991 John Gilmore (gnu at cygnus.com)
+
+ RS/6000 host support (grumble).
+
+ * configure.in: Build alloca-conf.h file from alloca-norm.h
+ (everything else) or alloca-botch.h (rs/6000).
+ * Makefile.in: Include . on the include path.
+ * getopt.c: Use alloca-conf.h.
+ * alloca-norm.h: How to declare alloca on reasonable machines.
+ * alloca-botch.h: How to declare alloca on braindead machines.
+
+Tue Nov 12 09:21:48 1991 Fred Fish (fnf at cygnus.com)
+
+ * concat.c : New file, like concat() in gdb but can take a
+ variable number of arguments rather than fixed at 3 args. For
+ now, client applications must supply an xmalloc(), which is a
+ front end function to malloc() that deals with out-of-memory
+ conditions.
+
+ * Makefile.in: Add concat.c and concat.o to appropriate macros.
+
+Sat Nov 9 13:29:59 1991 Fred Fish (fnf at cygnus.com)
+
+ * config/mh-svr4: Add sigsetmask to list of required functions.
+
+Sun Nov 3 11:57:56 1991 Per Bothner (bothner at cygnus.com)
+
+ * vsprintf.c: New file.
+ * functions.def, Makefile.in: Add vsprintf.
+
+Sun Oct 27 16:31:22 1991 John Gilmore (gnu at cygnus.com)
+
+ * configure.in, config/mh-rs6000: Add rs/6000 host support.
+ * Makefile.in: Compile with debug info.
+
+Fri Oct 25 17:01:12 1991 Per Bothner (bothner at cygnus.com)
+
+ * Makefile.in, configure.in, and new files: dummy.c, functions.def,
+ config/mf-default: Added a default configuration mode,
+ which includes into libiberty.a functions that are "missing" in libc.
+ * strdup.c, vprintf.c, vfprintf.c: New files.
+
+Thu Oct 24 02:29:26 1991 Fred Fish (fnf at cygnus.com)
+
+ * config/hmake-svr4: New file.
+
+ * config/hmake-sysv: Add HOST_CFILES and HOST_OFILES.
+
+ * basename.c, bcmp.c, bcopy.c, bzero.c, getpagesize.c getwd.c,
+ index.c, insque.c, rindex.c, spaces.c, strstr.c, vfork.c: New
+ files containing either portable C versions or emulations using
+ native library calls.
+
+ * strerror.c: Add copyright, internal documentation, etc.
+
+ * strtol.c: Replace hardwired hex constants with some more
+ portable macros. Remove illegal (according to gcc) cast.
+
+ * strtoul.c: Replace hardwired hex constant with more portable
+ macro.
+
+ * Makefile.in: Move TARGETLIB and CFLAGS where makefile fragments
+ can override them. Add new source and object file names to CFILES
+ and OFILES respectively.
+
+ * configure.in: Add support for SVR4 makefile fragments.
+
+Tue Oct 22 19:00:23 1991 Steve Chamberlain (steve at cygnus.com)
+
+ * Makefile.in: Move RANLIB, AR and AR_FLAGS to where they can be
+ over-ridden by config/hmake-*
+ * configure.in: added m88kcvs to sysv list
+
+Fri Oct 4 01:29:08 1991 John Gilmore (gnu at cygnus.com)
+
+ * Makefile.in: Most hosts need strerror, but one or two don't,
+ and they override these definitions in the host-dependent makefile
+ fragment.
+ * config/hmake-mach: The odd man out on strerror -- it's supplied.
+ * strerror.c: New file.
+
+ * strtol.c, strtoul.c: Add strtol to libiberty, since Mach lacks
+ it and bfd uses it.
+ * configure.in, Makefile.in, config/hmake-mach: Only configure
+ strtol & strotoul in on Mach.
+
+Tue Sep 3 06:36:23 1991 John Gilmore (gnu at cygint.cygnus.com)
+
+ * obstack.c: Merge with latest FSF version.
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
new file mode 100644
index 00000000000..b1689ba14fd
--- /dev/null
+++ b/libiberty/Makefile.in
@@ -0,0 +1,247 @@
+#
+# Makefile
+# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+# Free Software Foundation
+#
+# This file is part of the libiberty library.
+# Libiberty is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# Libiberty 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with libiberty; see the file COPYING.LIB. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+# This file was written by K. Richard Pixley <rich@cygnus.com>.
+
+#
+# Makefile for libiberty directory
+#
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+
+SHELL = @SHELL@
+
+# Multilib support variables.
+MULTISRCTOP =
+MULTIBUILDTOP =
+MULTIDIRS =
+MULTISUBDIR =
+MULTIDO = true
+MULTICLEAN = true
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+AR = @AR@
+AR_FLAGS = rc
+
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBCFLAGS = $(CFLAGS)
+RANLIB = @RANLIB@
+
+PICFLAG =
+
+MAKEOVERRIDES =
+
+TARGETLIB = libiberty.a
+
+LIBOBJS = @LIBOBJS@
+ALLOCA = @ALLOCA@
+
+# A configuration can specify extra .o files that should be included,
+# even if they are in libc. (Perhaps the libc version is buggy.)
+EXTRA_OFILES =
+
+# Flags to pass to a recursive make.
+FLAGS_TO_PASS = \
+ "AR=$(AR)" \
+ "AR_FLAGS=$(AR_FLAGS)" \
+ "CC=$(CC)" \
+ "CFLAGS=$(CFLAGS)" \
+ "LIBCFLAGS=$(LIBCFLAGS)" \
+ "EXTRA_OFILES=$(EXTRA_OFILES)" \
+ "HDEFINES=$(HDEFINES)" \
+ "INSTALL=$(INSTALL)" \
+ "INSTALL_DATA=$(INSTALL_DATA)" \
+ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+ "LDFLAGS=$(LDFLAGS)" \
+ "LOADLIBES=$(LOADLIBES)" \
+ "RANLIB=$(RANLIB)" \
+ "SHELL=$(SHELL)"
+
+all: stamp-picdir $(TARGETLIB) needed-list required-list
+ @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
+
+.PHONY: check installcheck
+check installcheck:
+
+@host_makefile_frag@
+
+INCDIR=$(srcdir)/$(MULTISRCTOP)../include
+
+COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES)
+.c.o:
+ test x"$(enable_shared)" != xyes || \
+ $(COMPILE.c) $(PICFLAG) $< -o pic/$@
+ $(COMPILE.c) $<
+
+info install-info clean-info dvi:
+
+# Include files that are in this directory.
+HFILES = alloca-conf.h
+
+# NOTE: If you add new files to the library, add them to this list
+# (alphabetical), and add them to REQUIRED_OFILES or funcs in
+# configure.in.
+CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c \
+ bzero.c choose-temp.c clock.c concat.c cplus-dem.c fdmatch.c \
+ fnmatch.c getcwd.c getopt.c getopt1.c getpagesize.c \
+ getruntime.c floatformat.c hex.c index.c insque.c memchr.c \
+ memcmp.c memcpy.c memmove.c memset.c mkstemps.c objalloc.c obstack.c \
+ pexecute.c random.c rename.c rindex.c sigsetmask.c spaces.c \
+ splay-tree.c strcasecmp.c strncasecmp.c strchr.c strdup.c strerror.c \
+ strrchr.c strsignal.c strstr.c strtod.c strtol.c strtoul.c \
+ tmpnam.c vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c \
+ waitpid.c xatexit.c xexit.c xmalloc.c xstrdup.c xstrerror.c
+
+# These are always included in the library.
+REQUIRED_OFILES = argv.o choose-temp.o concat.o cplus-dem.o \
+ fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o \
+ floatformat.o objalloc.o obstack.o pexecute.o spaces.o \
+ splay-tree.o strerror.o strsignal.o xatexit.o xexit.o xmalloc.o \
+ xstrdup.o xstrerror.o
+
+$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
+ rm -f $(TARGETLIB)
+ $(AR) $(AR_FLAGS) $(TARGETLIB) \
+ $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
+ $(RANLIB) $(TARGETLIB)
+
+INSTALL_DEST = @INSTALL_DEST@
+install: install_to_$(INSTALL_DEST)
+
+install_to_libdir: all
+ $(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n
+ ( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n )
+ mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
+ @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
+
+install_to_tooldir: all
+ $(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n
+ ( cd $(tooldir)/lib$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n )
+ mv -f $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)
+ @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
+
+# needed-list is used by libstdc++.
+needed-list: Makefile
+ f="$(LIBOBJS) $(ALLOCA) $(EXTRA_OFILES)"; \
+ case $$f in \
+ *alloca.o*) f="$$f xmalloc.o xexit.o" ;; \
+ esac; \
+ echo $$f > needed-list
+
+# required-list was used when building a shared bfd/opcodes/libiberty
+# library. I don't know if it used by anything currently.
+required-list: Makefile
+ echo $(REQUIRED_OFILES) > required-list
+
+stamp-picdir:
+ if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \
+ mkdir pic; \
+ else true; fi
+ touch stamp-picdir
+
+.PHONY: all etags tags ls clean stage1 stage2
+
+etags tags: TAGS
+
+TAGS: $(CFILES) $(HFILES)
+ etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done`
+
+# The standalone demangler (c++filt) has been moved to binutils.
+demangle:
+ @echo "The standalone demangler, now named c++filt, is now"
+ @echo "a part of binutils."
+ @false
+
+ls:
+ @echo Makefile $(HFILES) $(CFILES)
+
+# Need to deal with profiled libraries, too.
+
+mostlyclean:
+ rm -rf *.o pic core errs \#* *.E a.out
+ rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-*
+ rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir
+ @$(MULTICLEAN) multi-clean DO=mostlyclean
+clean: mostlyclean
+ rm -f *.a required-list tmpmulti.out
+ @$(MULTICLEAN) multi-clean DO=clean
+distclean: clean
+ @$(MULTICLEAN) multi-clean DO=distclean
+ rm -f *~ Makefile config.status xhost-mkfrag TAGS multilib.out
+ rm -f config.log
+maintainer-clean realclean: distclean
+
+force:
+
+Makefile: $(srcdir)/Makefile.in config.status
+ CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
+
+config.h: stamp-h ; @true
+stamp-h: config.in config.status
+ CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
+
+config.status: $(srcdir)/configure $(srcdir)/config.table
+ $(SHELL) ./config.status --recheck
+
+$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA): stamp-picdir
+
+alloca.o: config.h
+atexit.o: config.h
+argv.o: config.h alloca-conf.h $(INCDIR)/libiberty.h
+basename.o: $(INCDIR)/libiberty.h
+choose-temp.o: config.h
+clock.o: config.h
+concat.o: $(INCDIR)/libiberty.h
+cplus-dem.o: config.h $(INCDIR)/demangle.h
+fdmatch.o: $(INCDIR)/libiberty.h
+fnmatch.o: config.h $(INCDIR)/fnmatch.h
+getcwd.o: config.h
+getopt.o: config.h $(INCDIR)/getopt.h
+getopt1.o: config.h $(INCDIR)/getopt.h
+getpagesize.o: config.h
+getruntime.o: config.h $(INCDIR)/libiberty.h
+hex.o: $(INCDIR)/libiberty.h
+floatformat.o: $(INCDIR)/floatformat.h
+mkstemps.o: config.h
+objalloc.o: $(INCDIR)/objalloc.h
+obstack.o: config.h $(INCDIR)/obstack.h
+pexecute.o: config.h $(INCDIR)/libiberty.h
+spaces.o: $(INCDIR)/libiberty.h
+splay-tree.o: config.h $(INCDIR)/libiberty.h $(INCDIR)/splay-tree.h $(INCDIR)/ansidecl.h
+strerror.o: config.h $(INCDIR)/libiberty.h
+strsignal.o: config.h $(INCDIR)/libiberty.h
+xatexit.o: $(INCDIR)/libiberty.h
+xexit.o: $(INCDIR)/libiberty.h
+xmalloc.o: $(INCDIR)/libiberty.h
+xstrdup.o: config.h $(INCDIR)/libiberty.h
+xstrerror.o: config.h $(INCDIR)/libiberty.h
diff --git a/libiberty/README b/libiberty/README
new file mode 100644
index 00000000000..9f5226a6b1d
--- /dev/null
+++ b/libiberty/README
@@ -0,0 +1,65 @@
+This directory contains the -liberty library of free software.
+It is a collection of subroutines used by various GNU programs.
+Current members include:
+
+ getopt -- get options from command line
+ obstack -- stacks of arbitrarily-sized objects
+ strerror -- error message strings corresponding to errno
+ strtol -- string-to-long conversion
+ strtoul -- string-to-unsigned-long conversion
+
+We expect many of the GNU subroutines that are floating around to
+eventually arrive here.
+
+The library must be configured from the top source directory. Don't
+try to run configure in this directory. Follow the configuration
+instructions in ../README.
+
+Please report bugs and fixes to "bug-gnu-utils@prep.ai.mit.edu". Thank you.
+
+ADDING A NEW FILE
+=================
+
+There are two sets of files: Those that are "required" will be
+included in the library for all configurations, while those
+that are "optional" will be included in the library only if "needed."
+
+To add a new required file, edit Makefile to add the source file
+name to CFILES and the object file to REQUIRED_OFILES.
+
+To add a new optional file, it must provide a single function, and the
+name of the function must be the same as the name of the file.
+
+ * Add the source file name to CFILES.
+
+ * Add the function to name to the funcs shell variable in
+ configure.in.
+
+ * Add the function to the AC_CHECK_FUNCS lists just after the
+ setting of the funcs shell variable. These AC_CHECK_FUNCS calls
+ are never executed; they are there to make autoheader work
+ better.
+
+ * Consider the special cases of building libiberty; as of this
+ writing, the special cases are newlib and VxWorks. If a
+ particular special case provides the function, you do not need
+ to do anything. If it does not provide the function, add the
+ object file to LIBOBJS, and add the function name to the case
+ controlling whether to define HAVE_func.
+
+The optional file you've added (e.g. getcwd.c) should compile and work
+on all hosts where it is needed. It does not have to work or even
+compile on hosts where it is not needed.
+
+ADDING A NEW CONFIGURATION
+==========================
+
+On most hosts you should be able to use the scheme for automatically
+figuring out which files are needed. In that case, you probably
+don't need a special Makefile stub for that configuration.
+
+If the fully automatic scheme doesn't work, you may be able to get
+by with defining EXTRA_OFILES in your Makefile stub. This is
+a list of object file names that should be treated as required
+for this configuration - they will be included in libiberty.a,
+regardless of whatever might be in the C library.
diff --git a/libiberty/acconfig.h b/libiberty/acconfig.h
new file mode 100644
index 00000000000..f7c599df7ac
--- /dev/null
+++ b/libiberty/acconfig.h
@@ -0,0 +1,11 @@
+/* Define if you have the sys_errlist variable. */
+#undef HAVE_SYS_ERRLIST
+
+/* Define if you have the sys_nerr variable. */
+#undef HAVE_SYS_NERR
+
+/* Define if you have the sys_siglist variable. */
+#undef HAVE_SYS_SIGLIST
+
+/* Define if you have the strerror function. */
+#undef HAVE_STRERROR
diff --git a/libiberty/alloca-conf.h b/libiberty/alloca-conf.h
new file mode 100644
index 00000000000..9c3eea396c1
--- /dev/null
+++ b/libiberty/alloca-conf.h
@@ -0,0 +1,24 @@
+#include "config.h"
+
+#if defined(__GNUC__) && !defined(C_ALLOCA)
+# ifndef alloca
+# define alloca __builtin_alloca
+# endif
+#else /* ! defined (__GNUC__) */
+# ifdef _AIX
+ #pragma alloca
+# else
+# if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA)
+# include <alloca.h>
+# else /* ! defined (HAVE_ALLOCA_H) */
+# ifdef __STDC__
+extern PTR alloca (size_t);
+# else /* ! defined (__STDC__) */
+extern PTR alloca ();
+# endif /* ! defined (__STDC__) */
+# endif /* ! defined (HAVE_ALLOCA_H) */
+# ifdef _WIN32
+# include <malloc.h>
+# endif
+# endif /* ! defined (_AIX) */
+#endif /* ! defined (__GNUC__) */
diff --git a/libiberty/alloca.c b/libiberty/alloca.c
new file mode 100644
index 00000000000..0f8a21511db
--- /dev/null
+++ b/libiberty/alloca.c
@@ -0,0 +1,505 @@
+/* alloca.c -- allocate automatically reclaimed memory
+ (Mostly) portable public-domain implementation -- D A Gwyn
+
+ This implementation of the PWB library alloca function,
+ which is used to allocate space off the run-time stack so
+ that it is automatically reclaimed upon procedure exit,
+ was inspired by discussions with J. Q. Johnson of Cornell.
+ J.Otto Tennant <jot@cray.com> contributed the Cray support.
+
+ There are some preprocessor constants that can
+ be defined when compiling for your specific system, for
+ improved efficiency; however, the defaults should be okay.
+
+ The general concept of this implementation is to keep
+ track of all alloca-allocated blocks, and reclaim any
+ that are found to be deeper in the stack than the current
+ invocation. This heuristic does not reclaim storage as
+ soon as it becomes invalid, but it will do so eventually.
+
+ As a special case, alloca(0) reclaims storage without
+ allocating any. It is a good idea to use alloca(0) in
+ your main control loop, etc. to force garbage collection. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef emacs
+#include "blockinput.h"
+#endif
+
+/* If compiling with GCC 2, this file's not needed. Except of course if
+ the C alloca is explicitly requested. */
+#if defined (USE_C_ALLOCA) || !defined (__GNUC__) || __GNUC__ < 2
+
+/* If someone has defined alloca as a macro,
+ there must be some other way alloca is supposed to work. */
+#ifndef alloca
+
+#ifdef emacs
+#ifdef static
+/* actually, only want this if static is defined as ""
+ -- this is for usg, in which emacs must undefine static
+ in order to make unexec workable
+ */
+#ifndef STACK_DIRECTION
+you
+lose
+-- must know STACK_DIRECTION at compile-time
+#endif /* STACK_DIRECTION undefined */
+#endif /* static */
+#endif /* emacs */
+
+/* If your stack is a linked list of frames, you have to
+ provide an "address metric" ADDRESS_FUNCTION macro. */
+
+#if defined (CRAY) && defined (CRAY_STACKSEG_END)
+long i00afunc ();
+#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
+#else
+#define ADDRESS_FUNCTION(arg) &(arg)
+#endif
+
+#if __STDC__
+typedef void *pointer;
+#else
+typedef char *pointer;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* Different portions of Emacs need to call different versions of
+ malloc. The Emacs executable needs alloca to call xmalloc, because
+ ordinary malloc isn't protected from input signals. On the other
+ hand, the utilities in lib-src need alloca to call malloc; some of
+ them are very simple, and don't have an xmalloc routine.
+
+ Non-Emacs programs expect this to call use xmalloc.
+
+ Callers below should use malloc. */
+
+#ifndef emacs
+#define malloc xmalloc
+#endif
+extern pointer malloc ();
+
+/* Define STACK_DIRECTION if you know the direction of stack
+ growth for your system; otherwise it will be automatically
+ deduced at run-time.
+
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+
+#ifndef STACK_DIRECTION
+#define STACK_DIRECTION 0 /* Direction unknown. */
+#endif
+
+#if STACK_DIRECTION != 0
+
+#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
+
+#else /* STACK_DIRECTION == 0; need run-time code. */
+
+static int stack_dir; /* 1 or -1 once known. */
+#define STACK_DIR stack_dir
+
+static void
+find_stack_direction ()
+{
+ static char *addr = NULL; /* Address of first `dummy', once known. */
+ auto char dummy; /* To get stack address. */
+
+ if (addr == NULL)
+ { /* Initial entry. */
+ addr = ADDRESS_FUNCTION (dummy);
+
+ find_stack_direction (); /* Recurse once. */
+ }
+ else
+ {
+ /* Second entry. */
+ if (ADDRESS_FUNCTION (dummy) > addr)
+ stack_dir = 1; /* Stack grew upward. */
+ else
+ stack_dir = -1; /* Stack grew downward. */
+ }
+}
+
+#endif /* STACK_DIRECTION == 0 */
+
+/* An "alloca header" is used to:
+ (a) chain together all alloca'ed blocks;
+ (b) keep track of stack depth.
+
+ It is very important that sizeof(header) agree with malloc
+ alignment chunk size. The following default should work okay. */
+
+#ifndef ALIGN_SIZE
+#define ALIGN_SIZE sizeof(double)
+#endif
+
+typedef union hdr
+{
+ char align[ALIGN_SIZE]; /* To force sizeof(header). */
+ struct
+ {
+ union hdr *next; /* For chaining headers. */
+ char *deep; /* For stack depth measure. */
+ } h;
+} header;
+
+static header *last_alloca_header = NULL; /* -> last alloca header. */
+
+/* Return a pointer to at least SIZE bytes of storage,
+ which will be automatically reclaimed upon exit from
+ the procedure that called alloca. Originally, this space
+ was supposed to be taken from the current stack frame of the
+ caller, but that method cannot be made to work for some
+ implementations of C, for example under Gould's UTX/32. */
+
+pointer
+alloca (size)
+ unsigned size;
+{
+ auto char probe; /* Probes stack depth: */
+ register char *depth = ADDRESS_FUNCTION (probe);
+
+#if STACK_DIRECTION == 0
+ if (STACK_DIR == 0) /* Unknown growth direction. */
+ find_stack_direction ();
+#endif
+
+ /* Reclaim garbage, defined as all alloca'd storage that
+ was allocated from deeper in the stack than currently. */
+
+ {
+ register header *hp; /* Traverses linked list. */
+
+#ifdef emacs
+ BLOCK_INPUT;
+#endif
+
+ for (hp = last_alloca_header; hp != NULL;)
+ if ((STACK_DIR > 0 && hp->h.deep > depth)
+ || (STACK_DIR < 0 && hp->h.deep < depth))
+ {
+ register header *np = hp->h.next;
+
+ free ((pointer) hp); /* Collect garbage. */
+
+ hp = np; /* -> next header. */
+ }
+ else
+ break; /* Rest are not deeper. */
+
+ last_alloca_header = hp; /* -> last valid storage. */
+
+#ifdef emacs
+ UNBLOCK_INPUT;
+#endif
+ }
+
+ if (size == 0)
+ return NULL; /* No allocation required. */
+
+ /* Allocate combined header + user data storage. */
+
+ {
+ register pointer new = malloc (sizeof (header) + size);
+ /* Address of header. */
+
+ if (new == 0)
+ abort();
+
+ ((header *) new)->h.next = last_alloca_header;
+ ((header *) new)->h.deep = depth;
+
+ last_alloca_header = (header *) new;
+
+ /* User storage begins just after header. */
+
+ return (pointer) ((char *) new + sizeof (header));
+ }
+}
+
+#if defined (CRAY) && defined (CRAY_STACKSEG_END)
+
+#ifdef DEBUG_I00AFUNC
+#include <stdio.h>
+#endif
+
+#ifndef CRAY_STACK
+#define CRAY_STACK
+#ifndef CRAY2
+/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
+struct stack_control_header
+ {
+ long shgrow:32; /* Number of times stack has grown. */
+ long shaseg:32; /* Size of increments to stack. */
+ long shhwm:32; /* High water mark of stack. */
+ long shsize:32; /* Current size of stack (all segments). */
+ };
+
+/* The stack segment linkage control information occurs at
+ the high-address end of a stack segment. (The stack
+ grows from low addresses to high addresses.) The initial
+ part of the stack segment linkage control information is
+ 0200 (octal) words. This provides for register storage
+ for the routine which overflows the stack. */
+
+struct stack_segment_linkage
+ {
+ long ss[0200]; /* 0200 overflow words. */
+ long sssize:32; /* Number of words in this segment. */
+ long ssbase:32; /* Offset to stack base. */
+ long:32;
+ long sspseg:32; /* Offset to linkage control of previous
+ segment of stack. */
+ long:32;
+ long sstcpt:32; /* Pointer to task common address block. */
+ long sscsnm; /* Private control structure number for
+ microtasking. */
+ long ssusr1; /* Reserved for user. */
+ long ssusr2; /* Reserved for user. */
+ long sstpid; /* Process ID for pid based multi-tasking. */
+ long ssgvup; /* Pointer to multitasking thread giveup. */
+ long sscray[7]; /* Reserved for Cray Research. */
+ long ssa0;
+ long ssa1;
+ long ssa2;
+ long ssa3;
+ long ssa4;
+ long ssa5;
+ long ssa6;
+ long ssa7;
+ long sss0;
+ long sss1;
+ long sss2;
+ long sss3;
+ long sss4;
+ long sss5;
+ long sss6;
+ long sss7;
+ };
+
+#else /* CRAY2 */
+/* The following structure defines the vector of words
+ returned by the STKSTAT library routine. */
+struct stk_stat
+ {
+ long now; /* Current total stack size. */
+ long maxc; /* Amount of contiguous space which would
+ be required to satisfy the maximum
+ stack demand to date. */
+ long high_water; /* Stack high-water mark. */
+ long overflows; /* Number of stack overflow ($STKOFEN) calls. */
+ long hits; /* Number of internal buffer hits. */
+ long extends; /* Number of block extensions. */
+ long stko_mallocs; /* Block allocations by $STKOFEN. */
+ long underflows; /* Number of stack underflow calls ($STKRETN). */
+ long stko_free; /* Number of deallocations by $STKRETN. */
+ long stkm_free; /* Number of deallocations by $STKMRET. */
+ long segments; /* Current number of stack segments. */
+ long maxs; /* Maximum number of stack segments so far. */
+ long pad_size; /* Stack pad size. */
+ long current_address; /* Current stack segment address. */
+ long current_size; /* Current stack segment size. This
+ number is actually corrupted by STKSTAT to
+ include the fifteen word trailer area. */
+ long initial_address; /* Address of initial segment. */
+ long initial_size; /* Size of initial segment. */
+ };
+
+/* The following structure describes the data structure which trails
+ any stack segment. I think that the description in 'asdef' is
+ out of date. I only describe the parts that I am sure about. */
+
+struct stk_trailer
+ {
+ long this_address; /* Address of this block. */
+ long this_size; /* Size of this block (does not include
+ this trailer). */
+ long unknown2;
+ long unknown3;
+ long link; /* Address of trailer block of previous
+ segment. */
+ long unknown5;
+ long unknown6;
+ long unknown7;
+ long unknown8;
+ long unknown9;
+ long unknown10;
+ long unknown11;
+ long unknown12;
+ long unknown13;
+ long unknown14;
+ };
+
+#endif /* CRAY2 */
+#endif /* not CRAY_STACK */
+
+#ifdef CRAY2
+/* Determine a "stack measure" for an arbitrary ADDRESS.
+ I doubt that "lint" will like this much. */
+
+static long
+i00afunc (long *address)
+{
+ struct stk_stat status;
+ struct stk_trailer *trailer;
+ long *block, size;
+ long result = 0;
+
+ /* We want to iterate through all of the segments. The first
+ step is to get the stack status structure. We could do this
+ more quickly and more directly, perhaps, by referencing the
+ $LM00 common block, but I know that this works. */
+
+ STKSTAT (&status);
+
+ /* Set up the iteration. */
+
+ trailer = (struct stk_trailer *) (status.current_address
+ + status.current_size
+ - 15);
+
+ /* There must be at least one stack segment. Therefore it is
+ a fatal error if "trailer" is null. */
+
+ if (trailer == 0)
+ abort ();
+
+ /* Discard segments that do not contain our argument address. */
+
+ while (trailer != 0)
+ {
+ block = (long *) trailer->this_address;
+ size = trailer->this_size;
+ if (block == 0 || size == 0)
+ abort ();
+ trailer = (struct stk_trailer *) trailer->link;
+ if ((block <= address) && (address < (block + size)))
+ break;
+ }
+
+ /* Set the result to the offset in this segment and add the sizes
+ of all predecessor segments. */
+
+ result = address - block;
+
+ if (trailer == 0)
+ {
+ return result;
+ }
+
+ do
+ {
+ if (trailer->this_size <= 0)
+ abort ();
+ result += trailer->this_size;
+ trailer = (struct stk_trailer *) trailer->link;
+ }
+ while (trailer != 0);
+
+ /* We are done. Note that if you present a bogus address (one
+ not in any segment), you will get a different number back, formed
+ from subtracting the address of the first block. This is probably
+ not what you want. */
+
+ return (result);
+}
+
+#else /* not CRAY2 */
+/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
+ Determine the number of the cell within the stack,
+ given the address of the cell. The purpose of this
+ routine is to linearize, in some sense, stack addresses
+ for alloca. */
+
+static long
+i00afunc (long address)
+{
+ long stkl = 0;
+
+ long size, pseg, this_segment, stack;
+ long result = 0;
+
+ struct stack_segment_linkage *ssptr;
+
+ /* Register B67 contains the address of the end of the
+ current stack segment. If you (as a subprogram) store
+ your registers on the stack and find that you are past
+ the contents of B67, you have overflowed the segment.
+
+ B67 also points to the stack segment linkage control
+ area, which is what we are really interested in. */
+
+ stkl = CRAY_STACKSEG_END ();
+ ssptr = (struct stack_segment_linkage *) stkl;
+
+ /* If one subtracts 'size' from the end of the segment,
+ one has the address of the first word of the segment.
+
+ If this is not the first segment, 'pseg' will be
+ nonzero. */
+
+ pseg = ssptr->sspseg;
+ size = ssptr->sssize;
+
+ this_segment = stkl - size;
+
+ /* It is possible that calling this routine itself caused
+ a stack overflow. Discard stack segments which do not
+ contain the target address. */
+
+ while (!(this_segment <= address && address <= stkl))
+ {
+#ifdef DEBUG_I00AFUNC
+ fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
+#endif
+ if (pseg == 0)
+ break;
+ stkl = stkl - pseg;
+ ssptr = (struct stack_segment_linkage *) stkl;
+ size = ssptr->sssize;
+ pseg = ssptr->sspseg;
+ this_segment = stkl - size;
+ }
+
+ result = address - this_segment;
+
+ /* If you subtract pseg from the current end of the stack,
+ you get the address of the previous stack segment's end.
+ This seems a little convoluted to me, but I'll bet you save
+ a cycle somewhere. */
+
+ while (pseg != 0)
+ {
+#ifdef DEBUG_I00AFUNC
+ fprintf (stderr, "%011o %011o\n", pseg, size);
+#endif
+ stkl = stkl - pseg;
+ ssptr = (struct stack_segment_linkage *) stkl;
+ size = ssptr->sssize;
+ pseg = ssptr->sspseg;
+ result += size;
+ }
+ return (result);
+}
+
+#endif /* not CRAY2 */
+#endif /* CRAY */
+
+#endif /* no alloca */
+#endif /* not GCC version 2 */
diff --git a/libiberty/argv.c b/libiberty/argv.c
new file mode 100644
index 00000000000..85c17e930ee
--- /dev/null
+++ b/libiberty/argv.c
@@ -0,0 +1,390 @@
+/* Create and destroy argument vectors (argv's)
+ Copyright (C) 1992 Free Software Foundation, Inc.
+ Written by Fred Fish @ Cygnus Support
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* Create and destroy argument vectors. An argument vector is simply an
+ array of string pointers, terminated by a NULL pointer. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#ifdef isspace
+#undef isspace
+#endif
+#define isspace(ch) ((ch) == ' ' || (ch) == '\t')
+
+/* Routines imported from standard C runtime libraries. */
+
+#ifdef __STDC__
+
+#include <stddef.h>
+extern void *memcpy (void *s1, const void *s2, size_t n); /* 4.11.2.1 */
+extern size_t strlen (const char *s); /* 4.11.6.3 */
+extern void *malloc (size_t size); /* 4.10.3.3 */
+extern void *realloc (void *ptr, size_t size); /* 4.10.3.4 */
+extern void free (void *ptr); /* 4.10.3.2 */
+extern char *strdup (const char *s); /* Non-ANSI */
+
+#else /* !__STDC__ */
+
+#if !defined _WIN32 || defined __GNUC__
+extern char *memcpy (); /* Copy memory region */
+extern int strlen (); /* Count length of string */
+extern char *malloc (); /* Standard memory allocater */
+extern char *realloc (); /* Standard memory reallocator */
+extern void free (); /* Free malloc'd memory */
+extern char *strdup (); /* Duplicate a string */
+#endif
+
+#endif /* __STDC__ */
+
+#include "alloca-conf.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef EOS
+#define EOS '\0'
+#endif
+
+#define INITIAL_MAXARGC 8 /* Number of args + NULL in initial argv */
+
+
+/*
+
+NAME
+
+ dupargv -- duplicate an argument vector
+
+SYNOPSIS
+
+ char **dupargv (vector)
+ char **vector;
+
+DESCRIPTION
+
+ Duplicate an argument vector. Simply scans through the
+ vector, duplicating each argument until the
+ terminating NULL is found.
+
+RETURNS
+
+ Returns a pointer to the argument vector if
+ successful. Returns NULL if there is insufficient memory to
+ complete building the argument vector.
+
+*/
+
+char **
+dupargv (argv)
+ char **argv;
+{
+ int argc;
+ char **copy;
+
+ if (argv == NULL)
+ return NULL;
+
+ /* the vector */
+ for (argc = 0; argv[argc] != NULL; argc++);
+ copy = (char **) malloc ((argc + 1) * sizeof (char *));
+ if (copy == NULL)
+ return NULL;
+
+ /* the strings */
+ for (argc = 0; argv[argc] != NULL; argc++)
+ {
+ int len = strlen (argv[argc]);
+ copy[argc] = malloc (sizeof (char *) * (len + 1));
+ if (copy[argc] == NULL)
+ {
+ freeargv (copy);
+ return NULL;
+ }
+ strcpy (copy[argc], argv[argc]);
+ }
+ copy[argc] = NULL;
+ return copy;
+}
+
+/*
+
+NAME
+
+ freeargv -- free an argument vector
+
+SYNOPSIS
+
+ void freeargv (vector)
+ char **vector;
+
+DESCRIPTION
+
+ Free an argument vector that was built using buildargv. Simply scans
+ through the vector, freeing the memory for each argument until the
+ terminating NULL is found, and then frees the vector itself.
+
+RETURNS
+
+ No value.
+
+*/
+
+void freeargv (vector)
+char **vector;
+{
+ register char **scan;
+
+ if (vector != NULL)
+ {
+ for (scan = vector; *scan != NULL; scan++)
+ {
+ free (*scan);
+ }
+ free (vector);
+ }
+}
+
+/*
+
+NAME
+
+ buildargv -- build an argument vector from a string
+
+SYNOPSIS
+
+ char **buildargv (sp)
+ char *sp;
+
+DESCRIPTION
+
+ Given a pointer to a string, parse the string extracting fields
+ separated by whitespace and optionally enclosed within either single
+ or double quotes (which are stripped off), and build a vector of
+ pointers to copies of the string for each field. The input string
+ remains unchanged.
+
+ All of the memory for the pointer array and copies of the string
+ is obtained from malloc. All of the memory can be returned to the
+ system with the single function call freeargv, which takes the
+ returned result of buildargv, as it's argument.
+
+ The memory for the argv array is dynamically expanded as necessary.
+
+RETURNS
+
+ Returns a pointer to the argument vector if successful. Returns NULL
+ if the input string pointer is NULL or if there is insufficient
+ memory to complete building the argument vector.
+
+NOTES
+
+ In order to provide a working buffer for extracting arguments into,
+ with appropriate stripping of quotes and translation of backslash
+ sequences, we allocate a working buffer at least as long as the input
+ string. This ensures that we always have enough space in which to
+ work, since the extracted arg is never larger than the input string.
+
+ If the input is a null string (as opposed to a NULL pointer), then
+ buildarg returns an argv that has one arg, a null string.
+
+ Argv is always kept terminated with a NULL arg pointer, so it can
+ be passed to freeargv at any time, or returned, as appropriate.
+*/
+
+char **buildargv (input)
+char *input;
+{
+ char *arg;
+ char *copybuf;
+ int squote = 0;
+ int dquote = 0;
+ int bsquote = 0;
+ int argc = 0;
+ int maxargc = 0;
+ char **argv = NULL;
+ char **nargv;
+
+ if (input != NULL)
+ {
+ copybuf = (char *) alloca (strlen (input) + 1);
+ /* Is a do{}while to always execute the loop once. Always return an
+ argv, even for null strings. See NOTES above, test case below. */
+ do
+ {
+ /* Pick off argv[argc] */
+ while (isspace (*input))
+ {
+ input++;
+ }
+ if ((maxargc == 0) || (argc >= (maxargc - 1)))
+ {
+ /* argv needs initialization, or expansion */
+ if (argv == NULL)
+ {
+ maxargc = INITIAL_MAXARGC;
+ nargv = (char **) malloc (maxargc * sizeof (char *));
+ }
+ else
+ {
+ maxargc *= 2;
+ nargv = (char **) realloc (argv, maxargc * sizeof (char *));
+ }
+ if (nargv == NULL)
+ {
+ if (argv != NULL)
+ {
+ freeargv (argv);
+ argv = NULL;
+ }
+ break;
+ }
+ argv = nargv;
+ argv[argc] = NULL;
+ }
+ /* Begin scanning arg */
+ arg = copybuf;
+ while (*input != EOS)
+ {
+ if (isspace (*input) && !squote && !dquote && !bsquote)
+ {
+ break;
+ }
+ else
+ {
+ if (bsquote)
+ {
+ bsquote = 0;
+ *arg++ = *input;
+ }
+ else if (*input == '\\')
+ {
+ bsquote = 1;
+ }
+ else if (squote)
+ {
+ if (*input == '\'')
+ {
+ squote = 0;
+ }
+ else
+ {
+ *arg++ = *input;
+ }
+ }
+ else if (dquote)
+ {
+ if (*input == '"')
+ {
+ dquote = 0;
+ }
+ else
+ {
+ *arg++ = *input;
+ }
+ }
+ else
+ {
+ if (*input == '\'')
+ {
+ squote = 1;
+ }
+ else if (*input == '"')
+ {
+ dquote = 1;
+ }
+ else
+ {
+ *arg++ = *input;
+ }
+ }
+ input++;
+ }
+ }
+ *arg = EOS;
+ argv[argc] = strdup (copybuf);
+ if (argv[argc] == NULL)
+ {
+ freeargv (argv);
+ argv = NULL;
+ break;
+ }
+ argc++;
+ argv[argc] = NULL;
+
+ while (isspace (*input))
+ {
+ input++;
+ }
+ }
+ while (*input != EOS);
+ }
+ return (argv);
+}
+
+#ifdef MAIN
+
+/* Simple little test driver. */
+
+static char *tests[] =
+{
+ "a simple command line",
+ "arg 'foo' is single quoted",
+ "arg \"bar\" is double quoted",
+ "arg \"foo bar\" has embedded whitespace",
+ "arg 'Jack said \\'hi\\'' has single quotes",
+ "arg 'Jack said \\\"hi\\\"' has double quotes",
+ "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9",
+
+ /* This should be expanded into only one argument. */
+ "trailing-whitespace ",
+
+ "",
+ NULL
+};
+
+main ()
+{
+ char **argv;
+ char **test;
+ char **targs;
+
+ for (test = tests; *test != NULL; test++)
+ {
+ printf ("buildargv(\"%s\")\n", *test);
+ if ((argv = buildargv (*test)) == NULL)
+ {
+ printf ("failed!\n\n");
+ }
+ else
+ {
+ for (targs = argv; *targs != NULL; targs++)
+ {
+ printf ("\t\"%s\"\n", *targs);
+ }
+ printf ("\n");
+ }
+ freeargv (argv);
+ }
+
+}
+
+#endif /* MAIN */
diff --git a/libiberty/asprintf.c b/libiberty/asprintf.c
new file mode 100644
index 00000000000..5aaf3200f0d
--- /dev/null
+++ b/libiberty/asprintf.c
@@ -0,0 +1,57 @@
+/* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ Contributed by Cygnus Solutions.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC)
+#define USE_STDARG
+#endif
+
+#ifdef USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+/* VARARGS */
+#ifdef USE_STDARG
+int
+asprintf (char **buf, const char *fmt, ...)
+#else
+int
+asprintf (buf, fmt, va_alist)
+ char **buf;
+ const char *fmt;
+ va_dcl
+#endif
+{
+ int status;
+ va_list ap;
+#ifdef USE_STDARG
+ va_start (ap, fmt);
+#else
+ va_start (ap);
+#endif
+ status = vasprintf (buf, fmt, ap);
+ va_end (ap);
+ return status;
+}
diff --git a/libiberty/atexit.c b/libiberty/atexit.c
new file mode 100644
index 00000000000..137d985e4cb
--- /dev/null
+++ b/libiberty/atexit.c
@@ -0,0 +1,18 @@
+/* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */
+/* This function is in the public domain. --Mike Stump. */
+
+#include "config.h"
+
+#ifdef HAVE_ON_EXIT
+
+int
+atexit(f)
+ void (*f)();
+{
+ /* If the system doesn't provide a definition for atexit, use on_exit
+ if the system provides that. */
+ on_exit (f, 0);
+ return 0;
+}
+
+#endif
diff --git a/libiberty/basename.c b/libiberty/basename.c
new file mode 100644
index 00000000000..f544c853910
--- /dev/null
+++ b/libiberty/basename.c
@@ -0,0 +1,37 @@
+/* Return the basename of a pathname.
+ This file is in the public domain. */
+
+/*
+NAME
+ basename -- return pointer to last component of a pathname
+
+SYNOPSIS
+ char *basename (const char *name)
+
+DESCRIPTION
+ Given a pointer to a string containing a typical pathname
+ (/usr/src/cmd/ls/ls.c for example), returns a pointer to the
+ last component of the pathname ("ls.c" in this case).
+
+BUGS
+ Presumes a UNIX style path with UNIX style separators.
+*/
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+char *
+basename (name)
+ const char *name;
+{
+ const char *base = name;
+
+ while (*name)
+ {
+ if (*name++ == '/')
+ {
+ base = name;
+ }
+ }
+ return (char *) base;
+}
diff --git a/libiberty/bcmp.c b/libiberty/bcmp.c
new file mode 100644
index 00000000000..11e4417db15
--- /dev/null
+++ b/libiberty/bcmp.c
@@ -0,0 +1,49 @@
+/* bcmp
+ This function is in the public domain. */
+
+/*
+
+NAME
+
+ bcmp -- compare two memory regions
+
+SYNOPSIS
+
+ int bcmp (char *from, char *to, int count)
+
+DESCRIPTION
+
+ Compare two memory regions and return zero if they are identical,
+ non-zero otherwise. If count is zero, return zero.
+
+NOTES
+
+ No guarantee is made about the non-zero returned value. In
+ particular, the results may be signficantly different than
+ strcmp(), where the return value is guaranteed to be less than,
+ equal to, or greater than zero, according to lexicographical
+ sorting of the compared regions.
+
+BUGS
+
+*/
+
+
+int
+bcmp (from, to, count)
+ char *from, *to;
+ int count;
+{
+ int rtnval = 0;
+
+ while (count-- > 0)
+ {
+ if (*from++ != *to++)
+ {
+ rtnval = 1;
+ break;
+ }
+ }
+ return (rtnval);
+}
+
diff --git a/libiberty/bcopy.c b/libiberty/bcopy.c
new file mode 100644
index 00000000000..b655363d879
--- /dev/null
+++ b/libiberty/bcopy.c
@@ -0,0 +1,35 @@
+/* bcopy -- copy memory regions of arbitary length
+
+NAME
+ bcopy -- copy memory regions of arbitrary length
+
+SYNOPSIS
+ void bcopy (char *in, char *out, int length)
+
+DESCRIPTION
+ Copy LENGTH bytes from memory region pointed to by IN to memory
+ region pointed to by OUT.
+
+BUGS
+ Significant speed improvements can be made in some cases by
+ implementing copies of multiple bytes simultaneously, or unrolling
+ the copy loop.
+
+*/
+
+void
+bcopy (src, dest, len)
+ register char *src, *dest;
+ int len;
+{
+ if (dest < src)
+ while (len--)
+ *dest++ = *src++;
+ else
+ {
+ char *lasts = src + (len-1);
+ char *lastd = dest + (len-1);
+ while (len--)
+ *(char *)lastd-- = *(char *)lasts--;
+ }
+}
diff --git a/libiberty/bzero.c b/libiberty/bzero.c
new file mode 100644
index 00000000000..d01644b7f4b
--- /dev/null
+++ b/libiberty/bzero.c
@@ -0,0 +1,31 @@
+/* Portable version of bzero for systems without it.
+ This function is in the public domain. */
+
+/*
+NAME
+ bzero -- zero the contents of a specified memory region
+
+SYNOPSIS
+ void bzero (char *to, int count)
+
+DESCRIPTION
+ Zero COUNT bytes of memory pointed to by TO.
+
+BUGS
+ Significant speed enhancements may be made in some environments
+ by zeroing more than a single byte at a time, or by unrolling the
+ loop.
+
+*/
+
+
+void
+bzero (to, count)
+ char *to;
+ int count;
+{
+ while (count-- > 0)
+ {
+ *to++ = 0;
+ }
+}
diff --git a/libiberty/calloc.c b/libiberty/calloc.c
new file mode 100644
index 00000000000..c8c0a78a7a1
--- /dev/null
+++ b/libiberty/calloc.c
@@ -0,0 +1,26 @@
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#ifdef ANSI_PROTOTYPES
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+/* For systems with larger pointers than ints, this must be declared. */
+PTR malloc PARAMS ((size_t));
+
+PTR
+calloc (nelem, elsize)
+ size_t nelem, elsize;
+{
+ register PTR ptr;
+
+ if (nelem == 0 || elsize == 0)
+ nelem = elsize = 1;
+
+ ptr = malloc (nelem * elsize);
+ if (ptr) bzero (ptr, nelem * elsize);
+
+ return ptr;
+}
diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c
new file mode 100644
index 00000000000..49c73869155
--- /dev/null
+++ b/libiberty/choose-temp.c
@@ -0,0 +1,203 @@
+/* Utility to pick a temporary filename prefix.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If not,
+write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This file exports two functions: choose_temp_base and make_temp_file. */
+
+/* This file lives in at least two places: libiberty and gcc.
+ Don't change one without the other. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h> /* May get P_tmpdir. */
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h> /* May get R_OK, etc. on some systems. */
+#endif
+
+#ifndef R_OK
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#endif
+
+#include "libiberty.h"
+extern int mkstemps ();
+
+#ifndef IN_GCC
+#if defined (__MSDOS__) || defined (_WIN32)
+#define DIR_SEPARATOR '\\'
+#endif
+#endif
+
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+/* On MSDOS, write temp files in current dir
+ because there's no place else we can expect to use. */
+/* ??? Although the current directory is tried as a last resort,
+ this is left in so that on MSDOS it is preferred to /tmp on the
+ off chance that someone requires this, since that was the previous
+ behaviour. */
+#ifdef __MSDOS__
+#ifndef P_tmpdir
+#define P_tmpdir "."
+#endif
+#endif
+
+/* Name of temporary file.
+ mktemp requires 6 trailing X's. */
+#define TEMP_FILE "ccXXXXXX"
+
+/* Subroutine of choose_temp_base.
+ If BASE is non-NULL, return it.
+ Otherwise it checks if DIR is a usable directory.
+ If success, DIR is returned.
+ Otherwise NULL is returned. */
+
+static char *
+try (dir, base)
+ char *dir, *base;
+{
+ if (base != 0)
+ return base;
+ if (dir != 0
+ && access (dir, R_OK | W_OK | X_OK) == 0)
+ return dir;
+ return 0;
+}
+
+/* Return a prefix for temporary file names or NULL if unable to find one.
+ The current directory is chosen if all else fails so the program is
+ exited if a temporary directory can't be found (mktemp fails).
+ The buffer for the result is obtained with xmalloc.
+
+ This function is provided for backwards compatability only. It use
+ is not recommended. */
+
+char *
+choose_temp_base ()
+{
+ char *base = 0;
+ char *temp_filename;
+ int len;
+ static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
+ static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
+
+ base = try (getenv ("TMPDIR"), base);
+ base = try (getenv ("TMP"), base);
+ base = try (getenv ("TEMP"), base);
+
+#ifdef P_tmpdir
+ base = try (P_tmpdir, base);
+#endif
+
+ /* Try /usr/tmp, then /tmp. */
+ base = try (usrtmp, base);
+ base = try (tmp, base);
+
+ /* If all else fails, use the current directory! */
+ if (base == 0)
+ base = ".";
+
+ len = strlen (base);
+ temp_filename = xmalloc (len + 1 /*DIR_SEPARATOR*/
+ + strlen (TEMP_FILE) + 1);
+ strcpy (temp_filename, base);
+
+ if (len != 0
+ && temp_filename[len-1] != '/'
+ && temp_filename[len-1] != DIR_SEPARATOR)
+ temp_filename[len++] = DIR_SEPARATOR;
+ strcpy (temp_filename + len, TEMP_FILE);
+
+ mktemp (temp_filename);
+ if (strlen (temp_filename) == 0)
+ abort ();
+ return temp_filename;
+}
+/* Return a temporary file name (as a string) or NULL if unable to create
+ one. */
+
+char *
+make_temp_file (suffix)
+ char *suffix;
+{
+ char *base = 0;
+ char *temp_filename;
+ int base_len, suffix_len;
+ int fd;
+ static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
+ static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
+
+ base = try (getenv ("TMPDIR"), base);
+ base = try (getenv ("TMP"), base);
+ base = try (getenv ("TEMP"), base);
+
+#ifdef P_tmpdir
+ base = try (P_tmpdir, base);
+#endif
+
+ /* Try /usr/tmp, then /tmp. */
+ base = try (usrtmp, base);
+ base = try (tmp, base);
+
+ /* If all else fails, use the current directory! */
+ if (base == 0)
+ base = ".";
+
+ base_len = strlen (base);
+
+ if (suffix)
+ suffix_len = strlen (suffix);
+ else
+ suffix_len = 0;
+
+ temp_filename = xmalloc (base_len + 1 /*DIR_SEPARATOR*/
+ + strlen (TEMP_FILE)
+ + suffix_len + 1);
+ strcpy (temp_filename, base);
+
+ if (base_len != 0
+ && temp_filename[base_len-1] != '/'
+ && temp_filename[base_len-1] != DIR_SEPARATOR)
+ temp_filename[base_len++] = DIR_SEPARATOR;
+ strcpy (temp_filename + base_len, TEMP_FILE);
+
+ if (suffix)
+ strcat (temp_filename, suffix);
+
+ fd = mkstemps (temp_filename, suffix_len);
+ /* If mkstemps failed, then something bad is happening. Maybe we should
+ issue a message about a possible security attack in progress? */
+ if (fd == -1)
+ abort ();
+ /* Similarly if we can not close the file. */
+ if (close (fd))
+ abort ();
+ return temp_filename;
+}
diff --git a/libiberty/clock.c b/libiberty/clock.c
new file mode 100644
index 00000000000..db2509c17f2
--- /dev/null
+++ b/libiberty/clock.c
@@ -0,0 +1,91 @@
+/* ANSI-compatible clock function.
+ Copyright (C) 1994, 1995, 1999 Free Software Foundation, Inc.
+
+This file is part of the libiberty library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include "config.h"
+
+#ifdef HAVE_GETRUSAGE
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+#ifdef HAVE_TIMES
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <sys/times.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef _SC_CLK_TCK
+#define GNU_HZ sysconf(_SC_CLK_TCK)
+#else
+#ifdef HZ
+#define GNU_HZ HZ
+#else
+#ifdef CLOCKS_PER_SEC
+#define GNU_HZ CLOCKS_PER_SEC
+#endif
+#endif
+#endif
+
+/* FIXME: should be able to declare as clock_t. */
+
+long
+clock ()
+{
+#ifdef HAVE_GETRUSAGE
+ struct rusage rusage;
+
+ getrusage (0, &rusage);
+ return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
+ + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
+#else
+#ifdef HAVE_TIMES
+ struct tms tms;
+
+ times (&tms);
+ return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ);
+#else
+#ifdef VMS
+ struct
+ {
+ int proc_user_time;
+ int proc_system_time;
+ int child_user_time;
+ int child_system_time;
+ } vms_times;
+
+ times (&vms_times);
+ return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
+#else
+ /* A fallback, if nothing else available. */
+ return 0;
+#endif /* VMS */
+#endif /* HAVE_TIMES */
+#endif /* HAVE_GETRUSAGE */
+}
+
diff --git a/libiberty/concat.c b/libiberty/concat.c
new file mode 100644
index 00000000000..5b132c85764
--- /dev/null
+++ b/libiberty/concat.c
@@ -0,0 +1,167 @@
+/* Concatenate variable number of strings.
+ Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+ Written by Fred Fish @ Cygnus Support
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/*
+
+NAME
+
+ concat -- concatenate a variable number of strings
+
+SYNOPSIS
+
+ #include <varargs.h>
+
+ char *concat (s1, s2, s3, ..., NULL)
+
+DESCRIPTION
+
+ Concatenate a variable number of strings and return the result
+ in freshly malloc'd memory.
+
+ Returns NULL if insufficient memory is available. The argument
+ list is terminated by the first NULL pointer encountered. Pointers
+ to empty strings are ignored.
+
+NOTES
+
+ This function uses xmalloc() which is expected to be a front end
+ function to malloc() that deals with low memory situations. In
+ typical use, if malloc() returns NULL then xmalloc() diverts to an
+ error handler routine which never returns, and thus xmalloc will
+ never return a NULL pointer. If the client application wishes to
+ deal with low memory situations itself, it should supply an xmalloc
+ that just directly invokes malloc and blindly returns whatever
+ malloc returns.
+*/
+
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#ifdef __STDC__
+#include <stddef.h>
+extern size_t strlen (const char *s);
+#else
+extern int strlen ();
+#endif
+
+#define NULLP (char *)0
+
+/* VARARGS */
+#ifdef ANSI_PROTOTYPES
+char *
+concat (const char *first, ...)
+#else
+char *
+concat (va_alist)
+ va_dcl
+#endif
+{
+ register int length;
+ register char *newstr;
+ register char *end;
+ register const char *arg;
+ va_list args;
+#ifndef ANSI_PROTOTYPES
+ const char *first;
+#endif
+
+ /* First compute the size of the result and get sufficient memory. */
+
+#ifdef ANSI_PROTOTYPES
+ va_start (args, first);
+#else
+ va_start (args);
+ first = va_arg (args, const char *);
+#endif
+
+ if (first == NULLP)
+ length = 0;
+ else
+ {
+ length = strlen (first);
+ while ((arg = va_arg (args, const char *)) != NULLP)
+ {
+ length += strlen (arg);
+ }
+ }
+ newstr = (char *) xmalloc (length + 1);
+ va_end (args);
+
+ /* Now copy the individual pieces to the result string. */
+
+ if (newstr != NULLP)
+ {
+#ifdef ANSI_PROTOTYPES
+ va_start (args, first);
+#else
+ va_start (args);
+ first = va_arg (args, const char *);
+#endif
+ end = newstr;
+ if (first != NULLP)
+ {
+ arg = first;
+ while (*arg)
+ {
+ *end++ = *arg++;
+ }
+ while ((arg = va_arg (args, const char *)) != NULLP)
+ {
+ while (*arg)
+ {
+ *end++ = *arg++;
+ }
+ }
+ }
+ *end = '\000';
+ va_end (args);
+ }
+
+ return (newstr);
+}
+
+#ifdef MAIN
+
+/* Simple little test driver. */
+
+#include <stdio.h>
+
+int
+main ()
+{
+ printf ("\"\" = \"%s\"\n", concat (NULLP));
+ printf ("\"a\" = \"%s\"\n", concat ("a", NULLP));
+ printf ("\"ab\" = \"%s\"\n", concat ("a", "b", NULLP));
+ printf ("\"abc\" = \"%s\"\n", concat ("a", "b", "c", NULLP));
+ printf ("\"abcd\" = \"%s\"\n", concat ("ab", "cd", NULLP));
+ printf ("\"abcde\" = \"%s\"\n", concat ("ab", "c", "de", NULLP));
+ printf ("\"abcdef\" = \"%s\"\n", concat ("", "a", "", "bcd", "ef", NULLP));
+ return 0;
+}
+
+#endif
diff --git a/libiberty/config.h-vms b/libiberty/config.h-vms
new file mode 100644
index 00000000000..ccac6a2bcc7
--- /dev/null
+++ b/libiberty/config.h-vms
@@ -0,0 +1,13 @@
+#ifndef NEED_strerror
+#define NEED_strerror
+#endif
+#ifndef NEED_basename
+#define NEED_basename
+#endif
+#ifndef NEED_psignal
+#define NEED_psignal
+#endif
+#ifndef NEED_on_exit
+#define NEED_on_exit
+#endif
+
diff --git a/libiberty/config.in b/libiberty/config.in
new file mode 100644
index 00000000000..ba72d865eaf
--- /dev/null
+++ b/libiberty/config.in
@@ -0,0 +1,203 @@
+/* config.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if using alloca.c. */
+#undef C_ALLOCA
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+ This function is required for alloca.c support on those systems. */
+#undef CRAY_STACKSEG_END
+
+/* Define if you have alloca, as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+#undef HAVE_ALLOCA_H
+
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define if you have <vfork.h>. */
+#undef HAVE_VFORK_H
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef pid_t
+
+/* Define if you need to in order for stat and other things to work. */
+#undef _POSIX_SOURCE
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#undef STACK_DIRECTION
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define vfork as fork if vfork does not work. */
+#undef vfork
+
+/* Define if you have the sys_errlist variable. */
+#undef HAVE_SYS_ERRLIST
+
+/* Define if you have the sys_nerr variable. */
+#undef HAVE_SYS_NERR
+
+/* Define if you have the sys_siglist variable. */
+#undef HAVE_SYS_SIGLIST
+
+/* Define if you have the strerror function. */
+#undef HAVE_STRERROR
+
+/* Define if you have the asprintf function. */
+#undef HAVE_ASPRINTF
+
+/* Define if you have the atexit function. */
+#undef HAVE_ATEXIT
+
+/* Define if you have the basename function. */
+#undef HAVE_BASENAME
+
+/* Define if you have the bcmp function. */
+#undef HAVE_BCMP
+
+/* Define if you have the bcopy function. */
+#undef HAVE_BCOPY
+
+/* Define if you have the bzero function. */
+#undef HAVE_BZERO
+
+/* Define if you have the calloc function. */
+#undef HAVE_CALLOC
+
+/* Define if you have the clock function. */
+#undef HAVE_CLOCK
+
+/* Define if you have the getcwd function. */
+#undef HAVE_GETCWD
+
+/* Define if you have the getpagesize function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the getrusage function. */
+#undef HAVE_GETRUSAGE
+
+/* Define if you have the index function. */
+#undef HAVE_INDEX
+
+/* Define if you have the insque function. */
+#undef HAVE_INSQUE
+
+/* Define if you have the memchr function. */
+#undef HAVE_MEMCHR
+
+/* Define if you have the memcmp function. */
+#undef HAVE_MEMCMP
+
+/* Define if you have the memcpy function. */
+#undef HAVE_MEMCPY
+
+/* Define if you have the memmove function. */
+#undef HAVE_MEMMOVE
+
+/* Define if you have the memset function. */
+#undef HAVE_MEMSET
+
+/* Define if you have the on_exit function. */
+#undef HAVE_ON_EXIT
+
+/* Define if you have the psignal function. */
+#undef HAVE_PSIGNAL
+
+/* Define if you have the random function. */
+#undef HAVE_RANDOM
+
+/* Define if you have the rename function. */
+#undef HAVE_RENAME
+
+/* Define if you have the rindex function. */
+#undef HAVE_RINDEX
+
+/* Define if you have the sigsetmask function. */
+#undef HAVE_SIGSETMASK
+
+/* Define if you have the strcasecmp function. */
+#undef HAVE_STRCASECMP
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the strdup function. */
+#undef HAVE_STRDUP
+
+/* Define if you have the strerror function. */
+#undef HAVE_STRERROR
+
+/* Define if you have the strncasecmp function. */
+#undef HAVE_STRNCASECMP
+
+/* Define if you have the strrchr function. */
+#undef HAVE_STRRCHR
+
+/* Define if you have the strsignal function. */
+#undef HAVE_STRSIGNAL
+
+/* Define if you have the strstr function. */
+#undef HAVE_STRSTR
+
+/* Define if you have the strtod function. */
+#undef HAVE_STRTOD
+
+/* Define if you have the strtol function. */
+#undef HAVE_STRTOL
+
+/* Define if you have the strtoul function. */
+#undef HAVE_STRTOUL
+
+/* Define if you have the sysconf function. */
+#undef HAVE_SYSCONF
+
+/* Define if you have the times function. */
+#undef HAVE_TIMES
+
+/* Define if you have the tmpnam function. */
+#undef HAVE_TMPNAM
+
+/* Define if you have the vasprintf function. */
+#undef HAVE_VASPRINTF
+
+/* Define if you have the vfprintf function. */
+#undef HAVE_VFPRINTF
+
+/* Define if you have the vprintf function. */
+#undef HAVE_VPRINTF
+
+/* Define if you have the vsprintf function. */
+#undef HAVE_VSPRINTF
+
+/* Define if you have the waitpid function. */
+#undef HAVE_WAITPID
+
+/* Define if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
diff --git a/libiberty/config.table b/libiberty/config.table
new file mode 100644
index 00000000000..5913b23ad63
--- /dev/null
+++ b/libiberty/config.table
@@ -0,0 +1,60 @@
+case "${host}" in
+ rs6000-ibm-aix3.1 | rs6000-ibm-aix)
+ frag=mh-aix ;;
+ *-*-cxux7*) frag=mh-cxux7 ;;
+ *-*-freebsd2.1.*) frag=mh-fbsd21 ;;
+ *-*-freebsd2.2.[012]) frag=mh-fbsd21 ;;
+ i[345]86-*-windows*) frag=mh-windows ;;
+ *-*-beos*) frag=mh-beos ;;
+esac
+
+frags=$frag
+
+# If they didn't specify --enable-shared, don't generate shared libs.
+case "${enable_shared}" in
+ yes) shared=yes ;;
+ no) shared=no ;;
+ "") shared=no ;;
+ *) shared=yes ;;
+esac
+if [ "${shared}" = "yes" ]; then
+ case "${host}" in
+ *-*-cygwin*) ;;
+ alpha*-*-linux*) frags="${frags} ../../config/mh-elfalphapic" ;;
+ arm*-*-*) frags="${frags} ../../config/mh-armpic" ;;
+ hppa*-*-*) frags="${frags} ../../config/mh-papic" ;;
+ i[3456]86-*-*) frags="${frags} ../../config/mh-x86pic" ;;
+ powerpc*-*-aix*) ;;
+ powerpc*-*-*) frags="${frags} ../../config/mh-ppcpic" ;;
+ *-*-*) frags="${frags} ../../config/mh-${host_cpu}pic" ;;
+ esac
+fi
+
+echo "# Warning: this fragment is automatically generated" > temp-frag
+
+for frag in ${frags}; do
+ case ${frag} in
+ ../* )
+ if [ ${srcdir} = . ]; then
+ [ -n "${with_target_subdir}" ] && frag=../${frag}
+ [ -n "${with_multisrctop}" ] && frag=${with_multisrctop}${frag}
+ fi
+ ;;
+ esac
+ frag=${srcdir}/${xsrcdir}config/$frag
+ if [ -f ${frag} ]; then
+ echo "Appending ${frag} to xhost-mkfrag"
+ echo "# Following fragment copied from ${frag}" >> temp-frag
+ cat ${frag} >> temp-frag
+ fi
+done
+
+# record if we want to build shared libs.
+if [ "${shared}" = "yes" ]; then
+ echo enable_shared = yes >> temp-frag
+else
+ echo enable_shared = no >> temp-frag
+fi
+
+frag=xhost-mkfrag
+${CONFIG_SHELL} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
diff --git a/libiberty/config/mh-aix b/libiberty/config/mh-aix
new file mode 100644
index 00000000000..6b645058fa9
--- /dev/null
+++ b/libiberty/config/mh-aix
@@ -0,0 +1,9 @@
+# This file is only needed by AIX 3.1.
+HDEFINES = -D__IEEE_BIG_ENDIAN
+
+# Most releases of AIX 3.1 include an incorrect internal version of copysign
+# in libc.a for use by some libc public functions including modf. The public
+# version of copysign in libm.a is usable. For the sake of libg++ (which
+# uses modf), we add copysign here. Supposedly, this problem is fixed in AIX
+# 3.1.8 and above, including all releases of AIX 3.2.
+EXTRA_OFILES = copysign.o
diff --git a/libiberty/config/mh-beos b/libiberty/config/mh-beos
new file mode 100644
index 00000000000..9b75e7d3372
--- /dev/null
+++ b/libiberty/config/mh-beos
@@ -0,0 +1,7 @@
+# Host makefile fragment for BeOS
+
+# This is a temporary hack until the wimpy default 64k stack
+# limit in BeOS is either increased or made user settable somehow.
+# This probably won't happen until after the DR9 release.
+
+EXTRA_OFILES = alloca.o
diff --git a/libiberty/config/mh-cxux7 b/libiberty/config/mh-cxux7
new file mode 100644
index 00000000000..a924b0853fc
--- /dev/null
+++ b/libiberty/config/mh-cxux7
@@ -0,0 +1 @@
+HDEFINES = -DHARRIS_FLOAT_FORMAT
diff --git a/libiberty/config/mh-fbsd21 b/libiberty/config/mh-fbsd21
new file mode 100644
index 00000000000..1375a780bef
--- /dev/null
+++ b/libiberty/config/mh-fbsd21
@@ -0,0 +1 @@
+EXTRA_OFILES=vasprintf.o
diff --git a/libiberty/config/mh-windows b/libiberty/config/mh-windows
new file mode 100644
index 00000000000..3ff5f794e9f
--- /dev/null
+++ b/libiberty/config/mh-windows
@@ -0,0 +1 @@
+EXTRA_OFILES=asprintf.o strcasecmp.o strncasecmp.o vasprintf.o
diff --git a/libiberty/configure b/libiberty/configure
new file mode 100755
index 00000000000..98407e7946c
--- /dev/null
+++ b/libiberty/configure
@@ -0,0 +1,2850 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --with-target-subdir=SUBDIR Configuring in a subdirectory"
+ac_help="$ac_help
+ --with-cross-host=HOST Configuring with a cross compiler"
+ac_help="$ac_help
+ --with-newlib Configuring with newlib"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=pexecute.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+# Check whether --with-target-subdir or --without-target-subdir was given.
+if test "${with_target_subdir+set}" = set; then
+ withval="$with_target_subdir"
+ :
+fi
+
+# Check whether --with-cross-host or --without-cross-host was given.
+if test "${with_cross_host+set}" = set; then
+ withval="$with_cross_host"
+ :
+fi
+
+# Check whether --with-newlib or --without-newlib was given.
+if test "${with_newlib+set}" = set; then
+ withval="$with_newlib"
+ :
+fi
+
+
+if test "${srcdir}" = "."; then
+ if test -z "${with_target_subdir}"; then
+ libiberty_topdir="${srcdir}/.."
+ else
+ if test "${with_target_subdir}" != "."; then
+ libiberty_topdir="${srcdir}/${with_multisrctop}../.."
+ else
+ libiberty_topdir="${srcdir}/${with_multisrctop}.."
+ fi
+ fi
+else
+ libiberty_topdir="${srcdir}/.."
+fi
+ac_aux_dir=
+for ac_dir in $libiberty_topdir $srcdir/$libiberty_topdir; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $libiberty_topdir $srcdir/$libiberty_topdir" 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:591: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:614: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+if test $host != $build; then
+ ac_tool_prefix=${host_alias}-
+else
+ ac_tool_prefix=
+fi
+
+# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:640: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
+fi
+fi
+AR="$ac_cv_prog_AR"
+if test -n "$AR"; then
+ echo "$ac_t""$AR" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:672: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_RANLIB"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:704: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ RANLIB=":"
+fi
+fi
+
+
+# FIXME: We temporarily define our own version of AC_PROG_CC. This is
+# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
+# are probably using a cross compiler, which will not be able to fully
+# link an executable. This should really be fixed in autoconf
+# itself.
+
+
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:749: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:779: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:828: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:837: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:852: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ elif test $ac_cv_prog_cc_g = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-O2"
+ fi
+else
+ GCC=
+ test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+
+
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:881: checking for POSIXized ISC" >&5
+if test -d /etc/conf/kconfig.d &&
+ grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+ echo "$ac_t""yes" 1>&6
+ ISC=yes # If later tests want to check for ISC.
+ cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+ if test "$GCC" = yes; then
+ CC="$CC -posix"
+ else
+ CC="$CC -Xp"
+ fi
+else
+ echo "$ac_t""no" 1>&6
+ ISC=
+fi
+
+
+
+
+
+
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:919: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+. ${srcdir}/config.table
+host_makefile_frag=${frag}
+
+
+# It's OK to check for header files. Although the compiler may not be
+# able to link anything, it had better be able to at least compile
+# something.
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:980: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 995 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1001: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 1012 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1018: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1029 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1035: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+for ac_hdr in sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1063: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1068 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
+echo "configure:1100: checking for sys/wait.h that is POSIX.1 compatible" >&5
+if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1105 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+int main() {
+int s;
+wait (&s);
+s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
+; return 0; }
+EOF
+if { (eval echo configure:1121: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_sys_wait_h=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_sys_wait_h=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6
+if test $ac_cv_header_sys_wait_h = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_WAIT_H 1
+EOF
+
+fi
+
+
+# This is the list of functions which libiberty will provide if they
+# are not available on the host.
+
+funcs="asprintf"
+funcs="$funcs atexit"
+funcs="$funcs basename"
+funcs="$funcs bcmp"
+funcs="$funcs bcopy"
+funcs="$funcs bzero"
+funcs="$funcs calloc"
+funcs="$funcs clock"
+funcs="$funcs getcwd"
+funcs="$funcs getpagesize"
+funcs="$funcs index"
+funcs="$funcs insque"
+funcs="$funcs memchr"
+funcs="$funcs memcmp"
+funcs="$funcs memcpy"
+funcs="$funcs memmove"
+funcs="$funcs memset"
+funcs="$funcs mkstemps"
+funcs="$funcs random"
+funcs="$funcs rename"
+funcs="$funcs rindex"
+funcs="$funcs sigsetmask"
+funcs="$funcs strcasecmp"
+funcs="$funcs strchr"
+funcs="$funcs strdup"
+funcs="$funcs strncasecmp"
+funcs="$funcs strrchr"
+funcs="$funcs strstr"
+funcs="$funcs strtod"
+funcs="$funcs strtol"
+funcs="$funcs strtoul"
+funcs="$funcs tmpnam"
+funcs="$funcs vasprintf"
+funcs="$funcs vfprintf"
+funcs="$funcs vprintf"
+funcs="$funcs vsprintf"
+funcs="$funcs waitpid"
+
+# Also in the old function.def file: alloca, vfork, getopt.
+
+vars="sys_errlist sys_nerr sys_siglist"
+
+checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
+
+# These are neither executed nor required, but they help keep
+# autoheader happy without adding a bunch of text to acconfig.h.
+if test "x" = "y"; then
+ for ac_func in asprintf atexit basename bcmp bcopy bzero calloc clock getcwd
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1195: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1200 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in getpagesize index insque mkstemps memchr memcmp memcpy memmove
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1250: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1255 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in memset random rename rindex sigsetmask strcasecmp
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1305: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1310 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in strchr strdup strncasecmp strrchr strstr strtod strtol
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1360: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1365 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1415: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1420 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_ERRLIST 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_NERR 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_SIGLIST 1
+EOF
+
+ for ac_func in getrusage on_exit psignal strerror strsignal sysconf times
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1482: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1487 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+fi
+
+# For each of these functions, if the host does not provide the
+# function we want to put FN.o in LIBOBJS, and if the host does
+# provide the function, we want to define HAVE_FN in config.h. Also,
+# if the host does not provide alloca, we set ALLOCA to alloca.o
+
+setobjs=
+if test -n "${with_target_subdir}"; then
+
+ # We are being configured as a target library. AC_REPLACE_FUNCS
+ # may not work correctly, because the compiler may not be able to
+ # link executables. Note that we may still be being configured
+ # native.
+
+ # If we are being configured for newlib, we know which functions
+ # newlib provide and which ones we will be expected to provide.
+
+ if test "x${with_newlib}" = "xyes"; then
+ ALLOCA="alloca.o"
+ LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
+
+ for f in $funcs; do
+ case "$f" in
+ asprintf | basename | insque | random | strdup | vasprintf)
+ ;;
+ *)
+ n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $n 1
+EOF
+
+ ;;
+ esac
+ done
+
+ # newlib doesnt provide any of the variables in $vars, so we
+ # dont have to check them here.
+
+ # Of the functions in $checkfuncs, newlib only has strerror.
+ cat >> confdefs.h <<\EOF
+#define HAVE_STRERROR 1
+EOF
+
+
+ setobjs=yes
+
+ fi
+fi
+
+if test -z "${setobjs}"; then
+ case "${host}" in
+
+ *-*-vxworks*)
+ # Handle VxWorks configuration specially, since on VxWorks the
+ # libraries are actually on the target board, not in the file
+ # system.
+ LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
+ LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
+ for f in $funcs; do
+ case "$f" in
+ basename | getpagesize | insque | random | strcasecmp)
+ ;;
+ strncasecmp | strdup | vfork | waitpid | vasprintf)
+ ;;
+ *)
+ n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $n 1
+EOF
+
+ ;;
+ esac
+ done
+
+ # VxWorks doesn't provide any of the variables in $vars, so we
+ # don't have to check them here.
+
+ # Of the functions in $checkfuncs, VxWorks only has strerror.
+ cat >> confdefs.h <<\EOF
+#define HAVE_STRERROR 1
+EOF
+
+
+ setobjs=yes
+ ;;
+
+ esac
+fi
+
+if test -z "${setobjs}"; then
+
+ case "${host}" in
+
+ *-*-cygwin*)
+ # The Cygwin library actually uses a couple of files from
+ # libiberty when it is built. If we are building a native
+ # Cygwin, and we run the tests, we will appear to have these
+ # files. However, when we go on to build winsup, we will wind up
+ # with a library which does not have the files, since they should
+ # have come from libiberty.
+
+ # We handle this by removing the functions the winsup library
+ # provides from our shell variables, so that they appear to be
+ # missing.
+
+ funcs="`echo $funcs | sed -e 's/random//'`"
+ LIBOBJS="$LIBOBJS random.o"
+ vars="`echo $vars | sed -e 's/sys_siglist//'`"
+ checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
+ ;;
+
+ *-*-mingw32*)
+ # Under mingw32, sys_nerr and sys_errlist exist, but they are
+ # macros, so the test below won't find them.
+ vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_NERR 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_ERRLIST 1
+EOF
+
+ ;;
+
+ *-*-uwin*)
+ # Under some versions of uwin, vfork is notoriously buggy and the test
+ # can hang configure; on other versions, vfork exists just as a stub.
+ # FIXME: This should be removed once vfork in uwin's runtime is fixed.
+ ac_cv_func_vfork_works=no
+ ;;
+
+ esac
+
+ # We haven't set the list of objects yet. Use the standard autoconf
+ # tests. This will only work if the compiler works.
+ echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:1672: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 1683 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:1688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:1714: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+ for ac_func in $funcs
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1721: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1726 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
+fi
+done
+
+
+ # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments. Useless!
+echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
+echo "configure:1778: checking for working alloca.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1783 "configure"
+#include "confdefs.h"
+#include <alloca.h>
+int main() {
+char *p = alloca(2 * sizeof(int));
+; return 0; }
+EOF
+if { (eval echo configure:1790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_header_alloca_h=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_alloca_h=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
+if test $ac_cv_header_alloca_h = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA_H 1
+EOF
+
+fi
+
+echo $ac_n "checking for alloca""... $ac_c" 1>&6
+echo "configure:1811: checking for alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1816 "configure"
+#include "confdefs.h"
+
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# else
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
+int main() {
+char *p = (char *) alloca(1);
+; return 0; }
+EOF
+if { (eval echo configure:1844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_func_alloca_works=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_func_alloca_works=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_func_alloca_works" 1>&6
+if test $ac_cv_func_alloca_works = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA 1
+EOF
+
+fi
+
+if test $ac_cv_func_alloca_works = no; then
+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+ # that cause trouble. Some versions do not even contain alloca or
+ # contain a buggy version. If you still want to use their alloca,
+ # use ar to extract alloca.o from them instead of compiling alloca.c.
+ ALLOCA=alloca.${ac_objext}
+ cat >> confdefs.h <<\EOF
+#define C_ALLOCA 1
+EOF
+
+
+echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+echo "configure:1876: checking whether alloca needs Cray hooks" >&5
+if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1881 "configure"
+#include "confdefs.h"
+#if defined(CRAY) && ! defined(CRAY2)
+webecray
+#else
+wenotbecray
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "webecray" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_os_cray=yes
+else
+ rm -rf conftest*
+ ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_os_cray" 1>&6
+if test $ac_cv_os_cray = yes; then
+for ac_func in _getb67 GETB67 getb67; do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1906: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1911 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<EOF
+#define CRAY_STACKSEG_END $ac_func
+EOF
+
+ break
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+done
+fi
+
+echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
+echo "configure:1961: checking stack direction for C alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_c_stack_direction=0
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1969 "configure"
+#include "confdefs.h"
+find_stack_direction ()
+{
+ static char *addr = 0;
+ auto char dummy;
+ if (addr == 0)
+ {
+ addr = &dummy;
+ return find_stack_direction ();
+ }
+ else
+ return (&dummy > addr) ? 1 : -1;
+}
+main ()
+{
+ exit (find_stack_direction() < 0);
+}
+EOF
+if { (eval echo configure:1988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_stack_direction=1
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_stack_direction=-1
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_c_stack_direction" 1>&6
+cat >> confdefs.h <<EOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+EOF
+
+fi
+
+ echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:2010: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2015 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 2040 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 2058 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2079 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:2090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for pid_t""... $ac_c" 1>&6
+echo "configure:2114: checking for pid_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2119 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_pid_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_pid_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_pid_t" 1>&6
+if test $ac_cv_type_pid_t = no; then
+ cat >> confdefs.h <<\EOF
+#define pid_t int
+EOF
+
+fi
+
+ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
+echo "configure:2148: checking for vfork.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2153 "configure"
+#include "confdefs.h"
+#include <vfork.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2158: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_VFORK_H 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for working vfork""... $ac_c" 1>&6
+echo "configure:2183: checking for working vfork" >&5
+if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ echo $ac_n "checking for vfork""... $ac_c" 1>&6
+echo "configure:2189: checking for vfork" >&5
+if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2194 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char vfork(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char vfork();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_vfork) || defined (__stub___vfork)
+choke me
+#else
+vfork();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_vfork=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_vfork=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'vfork`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ :
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ac_cv_func_vfork_works=$ac_cv_func_vfork
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2239 "configure"
+#include "confdefs.h"
+/* Thanks to Paul Eggert for this test. */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_VFORK_H
+#include <vfork.h>
+#endif
+/* On some sparc systems, changes by the child to local and incoming
+ argument registers are propagated back to the parent.
+ The compiler is told about this with #include <vfork.h>,
+ but some compilers (e.g. gcc -O) don't grok <vfork.h>.
+ Test for this by using a static variable whose address
+ is put into a register that is clobbered by the vfork. */
+static
+#ifdef __cplusplus
+sparc_address_test (int arg)
+#else
+sparc_address_test (arg) int arg;
+#endif
+{
+ static pid_t child;
+ if (!child) {
+ child = vfork ();
+ if (child < 0) {
+ perror ("vfork");
+ _exit(2);
+ }
+ if (!child) {
+ arg = getpid();
+ write(-1, "", 0);
+ _exit (arg);
+ }
+ }
+}
+main() {
+ pid_t parent = getpid ();
+ pid_t child;
+
+ sparc_address_test ();
+
+ child = vfork ();
+
+ if (child == 0) {
+ /* Here is another test for sparc vfork register problems.
+ This test uses lots of local variables, at least
+ as many local variables as main has allocated so far
+ including compiler temporaries. 4 locals are enough for
+ gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
+ A buggy compiler should reuse the register of parent
+ for one of the local variables, since it will think that
+ parent can't possibly be used any more in this routine.
+ Assigning to the local variable will thus munge parent
+ in the parent process. */
+ pid_t
+ p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
+ p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
+ /* Convince the compiler that p..p7 are live; otherwise, it might
+ use the same hardware register for all 8 local variables. */
+ if (p != p1 || p != p2 || p != p3 || p != p4
+ || p != p5 || p != p6 || p != p7)
+ _exit(1);
+
+ /* On some systems (e.g. IRIX 3.3),
+ vfork doesn't separate parent from child file descriptors.
+ If the child closes a descriptor before it execs or exits,
+ this munges the parent's descriptor as well.
+ Test for this by closing stdout in the child. */
+ _exit(close(fileno(stdout)) != 0);
+ } else {
+ int status;
+ struct stat st;
+
+ while (wait(&status) != child)
+ ;
+ exit(
+ /* Was there some problem with vforking? */
+ child < 0
+
+ /* Did the child fail? (This shouldn't happen.) */
+ || status
+
+ /* Did the vfork/compiler bug occur? */
+ || parent != getpid()
+
+ /* Did the file descriptor bug occur? */
+ || fstat(fileno(stdout), &st) != 0
+ );
+ }
+}
+EOF
+if { (eval echo configure:2334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_vfork_works=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_vfork_works=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_vfork_works" 1>&6
+if test $ac_cv_func_vfork_works = no; then
+ cat >> confdefs.h <<\EOF
+#define vfork fork
+EOF
+
+fi
+
+ if test $ac_cv_func_vfork_works = no; then
+ LIBOBJS="$LIBOBJS vfork.o"
+ fi
+ for v in $vars; do
+ echo $ac_n "checking for $v""... $ac_c" 1>&6
+echo "configure:2361: checking for $v" >&5
+ if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2366 "configure"
+#include "confdefs.h"
+int *p;
+int main() {
+extern int $v; p = &$v;
+; return 0; }
+EOF
+if { (eval echo configure:2373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "libiberty_cv_var_$v=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "libiberty_cv_var_$v=no"
+fi
+rm -f conftest*
+fi
+
+ if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $n 1
+EOF
+
+ else
+ echo "$ac_t""no" 1>&6
+ fi
+ done
+ for ac_func in $checkfuncs
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2399: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2404 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+fi
+
+# Install a library built with a cross compiler in $(tooldir) rather
+# than $(libdir).
+if test -z "${with_cross_host}"; then
+ INSTALL_DEST=libdir
+else
+ INSTALL_DEST=tooldir
+fi
+
+
+# We need multilib support, but only if configuring for the target.
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@AR@%$AR%g
+s%@RANLIB@%$RANLIB%g
+s%@CC@%$CC%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+/@host_makefile_frag@/r $host_makefile_frag
+s%@host_makefile_frag@%%g
+s%@CPP@%$CPP%g
+s%@LIBOBJS@%$LIBOBJS%g
+s%@ALLOCA@%$ALLOCA%g
+s%@INSTALL_DEST@%$INSTALL_DEST%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h:config.in"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+srcdir=${srcdir}
+host=${host}
+target=${target}
+with_target_subdir=${with_target_subdir}
+with_multisubdir=${with_multisubdir}
+ac_configure_args="--enable-multilib ${ac_configure_args}"
+CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+libiberty_topdir=${libiberty_topdir}
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+if test -n "$CONFIG_FILES"; then
+ if test -n "${with_target_subdir}"; then
+ # FIXME: We shouldn't need to set ac_file
+ ac_file=Makefile
+ . ${libiberty_topdir}/config-ml.in
+ fi
+fi
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/libiberty/configure.bat b/libiberty/configure.bat
new file mode 100644
index 00000000000..18881ac2f75
--- /dev/null
+++ b/libiberty/configure.bat
@@ -0,0 +1,14 @@
+@echo off
+if "%1" == "h8/300" goto h8300
+
+echo Configuring libiberty for go32
+copy Makefile.dos Makefile
+echo #define NEED_sys_siglist 1 >> config.h
+echo #define NEED_psignal 1 >> config.h
+goto exit
+
+:h8300
+echo Configuring libiberty for H8/300
+copy Makefile.dos Makefile
+
+:exit
diff --git a/libiberty/configure.in b/libiberty/configure.in
new file mode 100644
index 00000000000..f02f03561e5
--- /dev/null
+++ b/libiberty/configure.in
@@ -0,0 +1,341 @@
+dnl Process this file with autoconf to produce a configure script
+
+AC_PREREQ(2.12.1)
+AC_INIT(pexecute.c)
+
+dnl We use these options to decide which functions to include.
+AC_ARG_WITH(target-subdir,
+[ --with-target-subdir=SUBDIR Configuring in a subdirectory])
+AC_ARG_WITH(cross-host,
+[ --with-cross-host=HOST Configuring with a cross compiler])
+AC_ARG_WITH(newlib,
+[ --with-newlib Configuring with newlib])
+
+if test "${srcdir}" = "."; then
+ if test -z "${with_target_subdir}"; then
+ libiberty_topdir="${srcdir}/.."
+ else
+ if test "${with_target_subdir}" != "."; then
+ libiberty_topdir="${srcdir}/${with_multisrctop}../.."
+ else
+ libiberty_topdir="${srcdir}/${with_multisrctop}.."
+ fi
+ fi
+else
+ libiberty_topdir="${srcdir}/.."
+fi
+AC_CONFIG_AUX_DIR($libiberty_topdir)
+
+AC_CANONICAL_HOST
+
+dnl When we start using automake:
+dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
+
+dnl These must be called before AM_PROG_LIBTOOL, because it may want
+dnl to call AC_CHECK_PROG.
+AC_CHECK_TOOL(AR, ar)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+
+# FIXME: We temporarily define our own version of AC_PROG_CC. This is
+# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
+# are probably using a cross compiler, which will not be able to fully
+# link an executable. This should really be fixed in autoconf
+# itself.
+
+AC_DEFUN(LIB_AC_PROG_CC,
+[AC_BEFORE([$0], [AC_PROG_CPP])dnl
+AC_PROVIDE([AC_PROG_CC])
+AC_CHECK_PROG(CC, gcc, gcc)
+if test -z "$CC"; then
+ AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
+ test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
+fi
+
+AC_PROG_CC_GNU
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+dnl Check whether -g works, even if CFLAGS is set, in case the package
+dnl plays around with CFLAGS (such as to build both debugging and
+dnl normal versions of a library), tasteless as that idea is.
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ AC_PROG_CC_G
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ elif test $ac_cv_prog_cc_g = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-O2"
+ fi
+else
+ GCC=
+ test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+])
+
+LIB_AC_PROG_CC
+
+AC_ISC_POSIX
+
+dnl When we start using libtool:
+dnl Default to a non shared library. This may be overridden by the
+dnl configure option --enable-shared.
+dnl AM_DISABLE_SHARED
+
+dnl When we start using libtool:
+dnl AM_PROG_LIBTOOL
+
+dnl When we start using automake:
+dnl AM_CONFIG_HEADER(config.h:config.in)
+AC_CONFIG_HEADER(config.h:config.in)
+
+dnl When we start using automake:
+dnl AM_MAINTAINER_MODE
+dnl AC_EXEEXT
+
+dnl When we start using automake:
+dnl AM_PROG_INSTALL
+AC_PROG_INSTALL
+
+. ${srcdir}/config.table
+host_makefile_frag=${frag}
+AC_SUBST_FILE(host_makefile_frag)
+
+# It's OK to check for header files. Although the compiler may not be
+# able to link anything, it had better be able to at least compile
+# something.
+AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h)
+AC_HEADER_SYS_WAIT
+
+# This is the list of functions which libiberty will provide if they
+# are not available on the host.
+
+funcs="asprintf"
+funcs="$funcs atexit"
+funcs="$funcs basename"
+funcs="$funcs bcmp"
+funcs="$funcs bcopy"
+funcs="$funcs bzero"
+funcs="$funcs calloc"
+funcs="$funcs clock"
+funcs="$funcs getcwd"
+funcs="$funcs getpagesize"
+funcs="$funcs index"
+funcs="$funcs insque"
+funcs="$funcs memchr"
+funcs="$funcs memcmp"
+funcs="$funcs memcpy"
+funcs="$funcs memmove"
+funcs="$funcs memset"
+funcs="$funcs mkstemps"
+funcs="$funcs random"
+funcs="$funcs rename"
+funcs="$funcs rindex"
+funcs="$funcs sigsetmask"
+funcs="$funcs strcasecmp"
+funcs="$funcs strchr"
+funcs="$funcs strdup"
+funcs="$funcs strncasecmp"
+funcs="$funcs strrchr"
+funcs="$funcs strstr"
+funcs="$funcs strtod"
+funcs="$funcs strtol"
+funcs="$funcs strtoul"
+funcs="$funcs tmpnam"
+funcs="$funcs vasprintf"
+funcs="$funcs vfprintf"
+funcs="$funcs vprintf"
+funcs="$funcs vsprintf"
+funcs="$funcs waitpid"
+
+# Also in the old function.def file: alloca, vfork, getopt.
+
+vars="sys_errlist sys_nerr sys_siglist"
+
+checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
+
+# These are neither executed nor required, but they help keep
+# autoheader happy without adding a bunch of text to acconfig.h.
+if test "x" = "y"; then
+ AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
+ AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
+ AC_CHECK_FUNCS(memset random rename rindex sigsetmask strcasecmp)
+ AC_CHECK_FUNCS(strchr strdup strncasecmp strrchr strstr strtod strtol)
+ AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
+ AC_DEFINE(HAVE_SYS_ERRLIST)
+ AC_DEFINE(HAVE_SYS_NERR)
+ AC_DEFINE(HAVE_SYS_SIGLIST)
+ AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
+fi
+
+# For each of these functions, if the host does not provide the
+# function we want to put FN.o in LIBOBJS, and if the host does
+# provide the function, we want to define HAVE_FN in config.h. Also,
+# if the host does not provide alloca, we set ALLOCA to alloca.o
+
+setobjs=
+if test -n "${with_target_subdir}"; then
+
+ # We are being configured as a target library. AC_REPLACE_FUNCS
+ # may not work correctly, because the compiler may not be able to
+ # link executables. Note that we may still be being configured
+ # native.
+
+ # If we are being configured for newlib, we know which functions
+ # newlib provide and which ones we will be expected to provide.
+
+ if test "x${with_newlib}" = "xyes"; then
+ ALLOCA="alloca.o"
+ LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
+
+ for f in $funcs; do
+ case "$f" in
+ asprintf | basename | insque | random | strdup | vasprintf)
+ ;;
+ *)
+ n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ AC_DEFINE_UNQUOTED($n)
+ ;;
+ esac
+ done
+
+ # newlib doesnt provide any of the variables in $vars, so we
+ # dont have to check them here.
+
+ # Of the functions in $checkfuncs, newlib only has strerror.
+ AC_DEFINE(HAVE_STRERROR)
+
+ setobjs=yes
+
+ fi
+fi
+
+if test -z "${setobjs}"; then
+ case "${host}" in
+
+ *-*-vxworks*)
+ # Handle VxWorks configuration specially, since on VxWorks the
+ # libraries are actually on the target board, not in the file
+ # system.
+ LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
+ LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
+ for f in $funcs; do
+ case "$f" in
+ basename | getpagesize | insque | random | strcasecmp)
+ ;;
+ strncasecmp | strdup | vfork | waitpid | vasprintf)
+ ;;
+ *)
+ n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ AC_DEFINE_UNQUOTED($n)
+ ;;
+ esac
+ done
+
+ # VxWorks doesn't provide any of the variables in $vars, so we
+ # don't have to check them here.
+
+ # Of the functions in $checkfuncs, VxWorks only has strerror.
+ AC_DEFINE(HAVE_STRERROR)
+
+ setobjs=yes
+ ;;
+
+ esac
+fi
+
+if test -z "${setobjs}"; then
+
+ case "${host}" in
+
+ *-*-cygwin*)
+ # The Cygwin library actually uses a couple of files from
+ # libiberty when it is built. If we are building a native
+ # Cygwin, and we run the tests, we will appear to have these
+ # files. However, when we go on to build winsup, we will wind up
+ # with a library which does not have the files, since they should
+ # have come from libiberty.
+
+ # We handle this by removing the functions the winsup library
+ # provides from our shell variables, so that they appear to be
+ # missing.
+
+ funcs="`echo $funcs | sed -e 's/random//'`"
+ LIBOBJS="$LIBOBJS random.o"
+ vars="`echo $vars | sed -e 's/sys_siglist//'`"
+ checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
+ ;;
+
+ *-*-mingw32*)
+ # Under mingw32, sys_nerr and sys_errlist exist, but they are
+ # macros, so the test below won't find them.
+ vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
+ AC_DEFINE(HAVE_SYS_NERR)
+ AC_DEFINE(HAVE_SYS_ERRLIST)
+ ;;
+
+ *-*-uwin*)
+ # Under some versions of uwin, vfork is notoriously buggy and the test
+ # can hang configure; on other versions, vfork exists just as a stub.
+ # FIXME: This should be removed once vfork in uwin's runtime is fixed.
+ ac_cv_func_vfork_works=no
+ ;;
+
+ esac
+
+ # We haven't set the list of objects yet. Use the standard autoconf
+ # tests. This will only work if the compiler works.
+ AC_PROG_CC_WORKS
+ AC_REPLACE_FUNCS($funcs)
+ AC_FUNC_ALLOCA
+ AC_FUNC_VFORK
+ if test $ac_cv_func_vfork_works = no; then
+ LIBOBJS="$LIBOBJS vfork.o"
+ fi
+ for v in $vars; do
+ AC_MSG_CHECKING([for $v])
+ AC_CACHE_VAL(libiberty_cv_var_$v,
+ [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
+ [eval "libiberty_cv_var_$v=yes"],
+ [eval "libiberty_cv_var_$v=no"])])
+ if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ AC_DEFINE_UNQUOTED($n)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ done
+ AC_CHECK_FUNCS($checkfuncs)
+fi
+
+# Install a library built with a cross compiler in $(tooldir) rather
+# than $(libdir).
+if test -z "${with_cross_host}"; then
+ INSTALL_DEST=libdir
+else
+ INSTALL_DEST=tooldir
+fi
+AC_SUBST(INSTALL_DEST)
+
+# We need multilib support, but only if configuring for the target.
+AC_OUTPUT(Makefile,
+[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+if test -n "$CONFIG_FILES"; then
+ if test -n "${with_target_subdir}"; then
+ # FIXME: We shouldn't need to set ac_file
+ ac_file=Makefile
+ . ${libiberty_topdir}/config-ml.in
+ fi
+fi],
+srcdir=${srcdir}
+host=${host}
+target=${target}
+with_target_subdir=${with_target_subdir}
+with_multisubdir=${with_multisubdir}
+ac_configure_args="--enable-multilib ${ac_configure_args}"
+CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+libiberty_topdir=${libiberty_topdir}
+)
diff --git a/libiberty/copysign.c b/libiberty/copysign.c
new file mode 100644
index 00000000000..0b5f8c3d9df
--- /dev/null
+++ b/libiberty/copysign.c
@@ -0,0 +1,140 @@
+#include <ansidecl.h>
+
+#ifdef __IEEE_BIG_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ unsigned int sign : 1;
+ unsigned int exponent: 11;
+ unsigned int fraction0:4;
+ unsigned int fraction1:16;
+ unsigned int fraction2:16;
+ unsigned int fraction3:16;
+
+ } number;
+ struct
+ {
+ unsigned int sign : 1;
+ unsigned int exponent: 11;
+ unsigned int quiet:1;
+ unsigned int function0:3;
+ unsigned int function1:16;
+ unsigned int function2:16;
+ unsigned int function3:16;
+ } nan;
+ struct
+ {
+ unsigned long msw;
+ unsigned long lsw;
+ } parts;
+ long aslong[2];
+} __ieee_double_shape_type;
+
+#endif
+
+#ifdef __IEEE_LITTLE_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+#ifdef __SMALL_BITFIELDS
+ unsigned int fraction3:16;
+ unsigned int fraction2:16;
+ unsigned int fraction1:16;
+ unsigned int fraction0: 4;
+#else
+ unsigned int fraction1:32;
+ unsigned int fraction0:20;
+#endif
+ unsigned int exponent :11;
+ unsigned int sign : 1;
+ } number;
+ struct
+ {
+#ifdef __SMALL_BITFIELDS
+ unsigned int function3:16;
+ unsigned int function2:16;
+ unsigned int function1:16;
+ unsigned int function0:3;
+#else
+ unsigned int function1:32;
+ unsigned int function0:19;
+#endif
+ unsigned int quiet:1;
+ unsigned int exponent: 11;
+ unsigned int sign : 1;
+ } nan;
+ struct
+ {
+ unsigned long lsw;
+ unsigned long msw;
+ } parts;
+
+ long aslong[2];
+
+} __ieee_double_shape_type;
+
+#endif
+
+#ifdef __IEEE_BIG_ENDIAN
+typedef union
+{
+ float value;
+ struct
+ {
+ unsigned int sign : 1;
+ unsigned int exponent: 8;
+ unsigned int fraction0: 7;
+ unsigned int fraction1: 16;
+ } number;
+ struct
+ {
+ unsigned int sign:1;
+ unsigned int exponent:8;
+ unsigned int quiet:1;
+ unsigned int function0:6;
+ unsigned int function1:16;
+ } nan;
+ long p1;
+
+} __ieee_float_shape_type;
+#endif
+
+#ifdef __IEEE_LITTLE_ENDIAN
+typedef union
+{
+ float value;
+ struct
+ {
+ unsigned int fraction0: 7;
+ unsigned int fraction1: 16;
+ unsigned int exponent: 8;
+ unsigned int sign : 1;
+ } number;
+ struct
+ {
+ unsigned int function1:16;
+ unsigned int function0:6;
+ unsigned int quiet:1;
+ unsigned int exponent:8;
+ unsigned int sign:1;
+ } nan;
+ long p1;
+
+} __ieee_float_shape_type;
+#endif
+
+
+double DEFUN(copysign, (x, y), double x AND double y)
+{
+ __ieee_double_shape_type a,b;
+ b.value = y;
+ a.value = x;
+ a.number.sign =b.number.sign;
+ return a.value;
+}
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
new file mode 100644
index 00000000000..4be587a3bca
--- /dev/null
+++ b/libiberty/cplus-dem.c
@@ -0,0 +1,4535 @@
+/* Demangler for GNU C++
+ Copyright 1989, 91, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+ Written by James Clark (jjc@jclark.uucp)
+ Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling
+ Modified by Satish Pai (pai@apollo.hp.com) for HP demangling
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This file exports two functions; cplus_mangle_opname and cplus_demangle.
+
+ This file imports xmalloc and xrealloc, which are like malloc and
+ realloc except that they generate a fatal error if there is no
+ available memory. */
+
+/* This file lives in both GCC and libiberty. When making changes, please
+ try not to break either. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ctype.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#else
+char * malloc ();
+char * realloc ();
+#endif
+
+#include <demangle.h>
+#undef CURRENT_DEMANGLING_STYLE
+#define CURRENT_DEMANGLING_STYLE work->options
+
+#include "libiberty.h"
+
+static const char *mystrstr PARAMS ((const char *, const char *));
+
+static const char *
+mystrstr (s1, s2)
+ const char *s1, *s2;
+{
+ register const char *p = s1;
+ register int len = strlen (s2);
+
+ for (; (p = strchr (p, *s2)) != 0; p++)
+ {
+ if (strncmp (p, s2, len) == 0)
+ {
+ return (p);
+ }
+ }
+ return (0);
+}
+
+/* In order to allow a single demangler executable to demangle strings
+ using various common values of CPLUS_MARKER, as well as any specific
+ one set at compile time, we maintain a string containing all the
+ commonly used ones, and check to see if the marker we are looking for
+ is in that string. CPLUS_MARKER is usually '$' on systems where the
+ assembler can deal with that. Where the assembler can't, it's usually
+ '.' (but on many systems '.' is used for other things). We put the
+ current defined CPLUS_MARKER first (which defaults to '$'), followed
+ by the next most common value, followed by an explicit '$' in case
+ the value of CPLUS_MARKER is not '$'.
+
+ We could avoid this if we could just get g++ to tell us what the actual
+ cplus marker character is as part of the debug information, perhaps by
+ ensuring that it is the character that terminates the gcc<n>_compiled
+ marker symbol (FIXME). */
+
+#if !defined (CPLUS_MARKER)
+#define CPLUS_MARKER '$'
+#endif
+
+enum demangling_styles current_demangling_style = gnu_demangling;
+
+static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' };
+
+static char char_str[2] = { '\000', '\000' };
+
+void
+set_cplus_marker_for_demangling (ch)
+ int ch;
+{
+ cplus_markers[0] = ch;
+}
+
+typedef struct string /* Beware: these aren't required to be */
+{ /* '\0' terminated. */
+ char *b; /* pointer to start of string */
+ char *p; /* pointer after last character */
+ char *e; /* pointer after end of allocated space */
+} string;
+
+/* Stuff that is shared between sub-routines.
+ Using a shared structure allows cplus_demangle to be reentrant. */
+
+struct work_stuff
+{
+ int options;
+ char **typevec;
+ char **ktypevec;
+ char **btypevec;
+ int numk;
+ int numb;
+ int ksize;
+ int bsize;
+ int ntypes;
+ int typevec_size;
+ int constructor;
+ int destructor;
+ int static_type; /* A static member function */
+ int temp_start; /* index in demangled to start of template args */
+ int type_quals; /* The type qualifiers. */
+ int dllimported; /* Symbol imported from a PE DLL */
+ char **tmpl_argvec; /* Template function arguments. */
+ int ntmpl_args; /* The number of template function arguments. */
+ int forgetting_types; /* Nonzero if we are not remembering the types
+ we see. */
+ string* previous_argument; /* The last function argument demangled. */
+ int nrepeats; /* The number of times to repeat the previous
+ argument. */
+};
+
+#define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
+#define PRINT_ARG_TYPES (work -> options & DMGL_PARAMS)
+
+static const struct optable
+{
+ const char *in;
+ const char *out;
+ int flags;
+} optable[] = {
+ {"nw", " new", DMGL_ANSI}, /* new (1.92, ansi) */
+ {"dl", " delete", DMGL_ANSI}, /* new (1.92, ansi) */
+ {"new", " new", 0}, /* old (1.91, and 1.x) */
+ {"delete", " delete", 0}, /* old (1.91, and 1.x) */
+ {"vn", " new []", DMGL_ANSI}, /* GNU, pending ansi */
+ {"vd", " delete []", DMGL_ANSI}, /* GNU, pending ansi */
+ {"as", "=", DMGL_ANSI}, /* ansi */
+ {"ne", "!=", DMGL_ANSI}, /* old, ansi */
+ {"eq", "==", DMGL_ANSI}, /* old, ansi */
+ {"ge", ">=", DMGL_ANSI}, /* old, ansi */
+ {"gt", ">", DMGL_ANSI}, /* old, ansi */
+ {"le", "<=", DMGL_ANSI}, /* old, ansi */
+ {"lt", "<", DMGL_ANSI}, /* old, ansi */
+ {"plus", "+", 0}, /* old */
+ {"pl", "+", DMGL_ANSI}, /* ansi */
+ {"apl", "+=", DMGL_ANSI}, /* ansi */
+ {"minus", "-", 0}, /* old */
+ {"mi", "-", DMGL_ANSI}, /* ansi */
+ {"ami", "-=", DMGL_ANSI}, /* ansi */
+ {"mult", "*", 0}, /* old */
+ {"ml", "*", DMGL_ANSI}, /* ansi */
+ {"amu", "*=", DMGL_ANSI}, /* ansi (ARM/Lucid) */
+ {"aml", "*=", DMGL_ANSI}, /* ansi (GNU/g++) */
+ {"convert", "+", 0}, /* old (unary +) */
+ {"negate", "-", 0}, /* old (unary -) */
+ {"trunc_mod", "%", 0}, /* old */
+ {"md", "%", DMGL_ANSI}, /* ansi */
+ {"amd", "%=", DMGL_ANSI}, /* ansi */
+ {"trunc_div", "/", 0}, /* old */
+ {"dv", "/", DMGL_ANSI}, /* ansi */
+ {"adv", "/=", DMGL_ANSI}, /* ansi */
+ {"truth_andif", "&&", 0}, /* old */
+ {"aa", "&&", DMGL_ANSI}, /* ansi */
+ {"truth_orif", "||", 0}, /* old */
+ {"oo", "||", DMGL_ANSI}, /* ansi */
+ {"truth_not", "!", 0}, /* old */
+ {"nt", "!", DMGL_ANSI}, /* ansi */
+ {"postincrement","++", 0}, /* old */
+ {"pp", "++", DMGL_ANSI}, /* ansi */
+ {"postdecrement","--", 0}, /* old */
+ {"mm", "--", DMGL_ANSI}, /* ansi */
+ {"bit_ior", "|", 0}, /* old */
+ {"or", "|", DMGL_ANSI}, /* ansi */
+ {"aor", "|=", DMGL_ANSI}, /* ansi */
+ {"bit_xor", "^", 0}, /* old */
+ {"er", "^", DMGL_ANSI}, /* ansi */
+ {"aer", "^=", DMGL_ANSI}, /* ansi */
+ {"bit_and", "&", 0}, /* old */
+ {"ad", "&", DMGL_ANSI}, /* ansi */
+ {"aad", "&=", DMGL_ANSI}, /* ansi */
+ {"bit_not", "~", 0}, /* old */
+ {"co", "~", DMGL_ANSI}, /* ansi */
+ {"call", "()", 0}, /* old */
+ {"cl", "()", DMGL_ANSI}, /* ansi */
+ {"alshift", "<<", 0}, /* old */
+ {"ls", "<<", DMGL_ANSI}, /* ansi */
+ {"als", "<<=", DMGL_ANSI}, /* ansi */
+ {"arshift", ">>", 0}, /* old */
+ {"rs", ">>", DMGL_ANSI}, /* ansi */
+ {"ars", ">>=", DMGL_ANSI}, /* ansi */
+ {"component", "->", 0}, /* old */
+ {"pt", "->", DMGL_ANSI}, /* ansi; Lucid C++ form */
+ {"rf", "->", DMGL_ANSI}, /* ansi; ARM/GNU form */
+ {"indirect", "*", 0}, /* old */
+ {"method_call", "->()", 0}, /* old */
+ {"addr", "&", 0}, /* old (unary &) */
+ {"array", "[]", 0}, /* old */
+ {"vc", "[]", DMGL_ANSI}, /* ansi */
+ {"compound", ", ", 0}, /* old */
+ {"cm", ", ", DMGL_ANSI}, /* ansi */
+ {"cond", "?:", 0}, /* old */
+ {"cn", "?:", DMGL_ANSI}, /* pseudo-ansi */
+ {"max", ">?", 0}, /* old */
+ {"mx", ">?", DMGL_ANSI}, /* pseudo-ansi */
+ {"min", "<?", 0}, /* old */
+ {"mn", "<?", DMGL_ANSI}, /* pseudo-ansi */
+ {"nop", "", 0}, /* old (for operator=) */
+ {"rm", "->*", DMGL_ANSI}, /* ansi */
+ {"sz", "sizeof ", DMGL_ANSI} /* pseudo-ansi */
+};
+
+/* These values are used to indicate the various type varieties.
+ They are all non-zero so that they can be used as `success'
+ values. */
+typedef enum type_kind_t
+{
+ tk_none,
+ tk_pointer,
+ tk_reference,
+ tk_integral,
+ tk_bool,
+ tk_char,
+ tk_real
+} type_kind_t;
+
+#define STRING_EMPTY(str) ((str) -> b == (str) -> p)
+#define PREPEND_BLANK(str) {if (!STRING_EMPTY(str)) \
+ string_prepend(str, " ");}
+#define APPEND_BLANK(str) {if (!STRING_EMPTY(str)) \
+ string_append(str, " ");}
+#define LEN_STRING(str) ( (STRING_EMPTY(str))?0:((str)->p - (str)->b))
+
+/* The scope separator appropriate for the language being demangled. */
+
+#define SCOPE_STRING(work) ((work->options & DMGL_JAVA) ? "." : "::")
+
+#define ARM_VTABLE_STRING "__vtbl__" /* Lucid/ARM virtual table prefix */
+#define ARM_VTABLE_STRLEN 8 /* strlen (ARM_VTABLE_STRING) */
+
+/* Prototypes for local functions */
+
+static char *
+mop_up PARAMS ((struct work_stuff *, string *, int));
+
+static void
+squangle_mop_up PARAMS ((struct work_stuff *));
+
+#if 0
+static int
+demangle_method_args PARAMS ((struct work_stuff *, const char **, string *));
+#endif
+
+static char *
+internal_cplus_demangle PARAMS ((struct work_stuff *, const char *));
+
+static int
+demangle_template_template_parm PARAMS ((struct work_stuff *work,
+ const char **, string *));
+
+static int
+demangle_template PARAMS ((struct work_stuff *work, const char **, string *,
+ string *, int, int));
+
+static int
+arm_pt PARAMS ((struct work_stuff *, const char *, int, const char **,
+ const char **));
+
+static int
+demangle_class_name PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+demangle_qualified PARAMS ((struct work_stuff *, const char **, string *,
+ int, int));
+
+static int
+demangle_class PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+demangle_fund_type PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+demangle_signature PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+demangle_prefix PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+gnu_special PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+arm_special PARAMS ((const char **, string *));
+
+static void
+string_need PARAMS ((string *, int));
+
+static void
+string_delete PARAMS ((string *));
+
+static void
+string_init PARAMS ((string *));
+
+static void
+string_clear PARAMS ((string *));
+
+#if 0
+static int
+string_empty PARAMS ((string *));
+#endif
+
+static void
+string_append PARAMS ((string *, const char *));
+
+static void
+string_appends PARAMS ((string *, string *));
+
+static void
+string_appendn PARAMS ((string *, const char *, int));
+
+static void
+string_prepend PARAMS ((string *, const char *));
+
+static void
+string_prependn PARAMS ((string *, const char *, int));
+
+static int
+get_count PARAMS ((const char **, int *));
+
+static int
+consume_count PARAMS ((const char **));
+
+static int
+consume_count_with_underscores PARAMS ((const char**));
+
+static int
+demangle_args PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+demangle_nested_args PARAMS ((struct work_stuff*, const char**, string*));
+
+static int
+do_type PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+do_arg PARAMS ((struct work_stuff *, const char **, string *));
+
+static void
+demangle_function_name PARAMS ((struct work_stuff *, const char **, string *,
+ const char *));
+
+static void
+remember_type PARAMS ((struct work_stuff *, const char *, int));
+
+static void
+remember_Btype PARAMS ((struct work_stuff *, const char *, int, int));
+
+static int
+register_Btype PARAMS ((struct work_stuff *));
+
+static void
+remember_Ktype PARAMS ((struct work_stuff *, const char *, int));
+
+static void
+forget_types PARAMS ((struct work_stuff *));
+
+static void
+forget_B_and_K_types PARAMS ((struct work_stuff *));
+
+static void
+string_prepends PARAMS ((string *, string *));
+
+static int
+demangle_template_value_parm PARAMS ((struct work_stuff*, const char**,
+ string*, type_kind_t));
+
+static int
+do_hpacc_template_const_value PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+do_hpacc_template_literal PARAMS ((struct work_stuff *, const char **, string *));
+
+static int
+snarf_numeric_literal PARAMS ((const char **, string *));
+
+/* There is a TYPE_QUAL value for each type qualifier. They can be
+ combined by bitwise-or to form the complete set of qualifiers for a
+ type. */
+
+#define TYPE_UNQUALIFIED 0x0
+#define TYPE_QUAL_CONST 0x1
+#define TYPE_QUAL_VOLATILE 0x2
+#define TYPE_QUAL_RESTRICT 0x4
+
+static int
+code_for_qualifier PARAMS ((int));
+
+static const char*
+qualifier_string PARAMS ((int));
+
+static const char*
+demangle_qualifier PARAMS ((int));
+
+/* Translate count to integer, consuming tokens in the process.
+ Conversion terminates on the first non-digit character.
+
+ Trying to consume something that isn't a count results in no
+ consumption of input and a return of -1.
+
+ Overflow consumes the rest of the digits, and returns -1. */
+
+static int
+consume_count (type)
+ const char **type;
+{
+ int count = 0;
+
+ if (! isdigit ((unsigned char)**type))
+ return -1;
+
+ while (isdigit ((unsigned char)**type))
+ {
+ count *= 10;
+
+ /* Check for overflow.
+ We assume that count is represented using two's-complement;
+ no power of two is divisible by ten, so if an overflow occurs
+ when multiplying by ten, the result will not be a multiple of
+ ten. */
+ if ((count % 10) != 0)
+ {
+ while (isdigit ((unsigned char) **type))
+ (*type)++;
+ return -1;
+ }
+
+ count += **type - '0';
+ (*type)++;
+ }
+
+ return (count);
+}
+
+
+/* Like consume_count, but for counts that are preceded and followed
+ by '_' if they are greater than 10. Also, -1 is returned for
+ failure, since 0 can be a valid value. */
+
+static int
+consume_count_with_underscores (mangled)
+ const char **mangled;
+{
+ int idx;
+
+ if (**mangled == '_')
+ {
+ (*mangled)++;
+ if (!isdigit ((unsigned char)**mangled))
+ return -1;
+
+ idx = consume_count (mangled);
+ if (**mangled != '_')
+ /* The trailing underscore was missing. */
+ return -1;
+
+ (*mangled)++;
+ }
+ else
+ {
+ if (**mangled < '0' || **mangled > '9')
+ return -1;
+
+ idx = **mangled - '0';
+ (*mangled)++;
+ }
+
+ return idx;
+}
+
+/* C is the code for a type-qualifier. Return the TYPE_QUAL
+ corresponding to this qualifier. */
+
+static int
+code_for_qualifier (c)
+ int c;
+{
+ switch (c)
+ {
+ case 'C':
+ return TYPE_QUAL_CONST;
+
+ case 'V':
+ return TYPE_QUAL_VOLATILE;
+
+ case 'u':
+ return TYPE_QUAL_RESTRICT;
+
+ default:
+ break;
+ }
+
+ /* C was an invalid qualifier. */
+ abort ();
+}
+
+/* Return the string corresponding to the qualifiers given by
+ TYPE_QUALS. */
+
+static const char*
+qualifier_string (type_quals)
+ int type_quals;
+{
+ switch (type_quals)
+ {
+ case TYPE_UNQUALIFIED:
+ return "";
+
+ case TYPE_QUAL_CONST:
+ return "const";
+
+ case TYPE_QUAL_VOLATILE:
+ return "volatile";
+
+ case TYPE_QUAL_RESTRICT:
+ return "__restrict";
+
+ case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE:
+ return "const volatile";
+
+ case TYPE_QUAL_CONST | TYPE_QUAL_RESTRICT:
+ return "const __restrict";
+
+ case TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT:
+ return "volatile __restrict";
+
+ case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT:
+ return "const volatile __restrict";
+
+ default:
+ break;
+ }
+
+ /* TYPE_QUALS was an invalid qualifier set. */
+ abort ();
+}
+
+/* C is the code for a type-qualifier. Return the string
+ corresponding to this qualifier. This function should only be
+ called with a valid qualifier code. */
+
+static const char*
+demangle_qualifier (c)
+ int c;
+{
+ return qualifier_string (code_for_qualifier (c));
+}
+
+int
+cplus_demangle_opname (opname, result, options)
+ const char *opname;
+ char *result;
+ int options;
+{
+ int len, len1, ret;
+ string type;
+ struct work_stuff work[1];
+ const char *tem;
+
+ len = strlen(opname);
+ result[0] = '\0';
+ ret = 0;
+ memset ((char *) work, 0, sizeof (work));
+ work->options = options;
+
+ if (opname[0] == '_' && opname[1] == '_'
+ && opname[2] == 'o' && opname[3] == 'p')
+ {
+ /* ANSI. */
+ /* type conversion operator. */
+ tem = opname + 4;
+ if (do_type (work, &tem, &type))
+ {
+ strcat (result, "operator ");
+ strncat (result, type.b, type.p - type.b);
+ string_delete (&type);
+ ret = 1;
+ }
+ }
+ else if (opname[0] == '_' && opname[1] == '_'
+ && opname[2] >= 'a' && opname[2] <= 'z'
+ && opname[3] >= 'a' && opname[3] <= 'z')
+ {
+ if (opname[4] == '\0')
+ {
+ /* Operator. */
+ size_t i;
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ if (strlen (optable[i].in) == 2
+ && memcmp (optable[i].in, opname + 2, 2) == 0)
+ {
+ strcat (result, "operator");
+ strcat (result, optable[i].out);
+ ret = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (opname[2] == 'a' && opname[5] == '\0')
+ {
+ /* Assignment. */
+ size_t i;
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ if (strlen (optable[i].in) == 3
+ && memcmp (optable[i].in, opname + 2, 3) == 0)
+ {
+ strcat (result, "operator");
+ strcat (result, optable[i].out);
+ ret = 1;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if (len >= 3
+ && opname[0] == 'o'
+ && opname[1] == 'p'
+ && strchr (cplus_markers, opname[2]) != NULL)
+ {
+ /* see if it's an assignment expression */
+ if (len >= 10 /* op$assign_ */
+ && memcmp (opname + 3, "assign_", 7) == 0)
+ {
+ size_t i;
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ len1 = len - 10;
+ if ((int) strlen (optable[i].in) == len1
+ && memcmp (optable[i].in, opname + 10, len1) == 0)
+ {
+ strcat (result, "operator");
+ strcat (result, optable[i].out);
+ strcat (result, "=");
+ ret = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ size_t i;
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ len1 = len - 3;
+ if ((int) strlen (optable[i].in) == len1
+ && memcmp (optable[i].in, opname + 3, len1) == 0)
+ {
+ strcat (result, "operator");
+ strcat (result, optable[i].out);
+ ret = 1;
+ break;
+ }
+ }
+ }
+ }
+ else if (len >= 5 && memcmp (opname, "type", 4) == 0
+ && strchr (cplus_markers, opname[4]) != NULL)
+ {
+ /* type conversion operator */
+ tem = opname + 5;
+ if (do_type (work, &tem, &type))
+ {
+ strcat (result, "operator ");
+ strncat (result, type.b, type.p - type.b);
+ string_delete (&type);
+ ret = 1;
+ }
+ }
+ squangle_mop_up (work);
+ return ret;
+
+}
+/* Takes operator name as e.g. "++" and returns mangled
+ operator name (e.g. "postincrement_expr"), or NULL if not found.
+
+ If OPTIONS & DMGL_ANSI == 1, return the ANSI name;
+ if OPTIONS & DMGL_ANSI == 0, return the old GNU name. */
+
+const char *
+cplus_mangle_opname (opname, options)
+ const char *opname;
+ int options;
+{
+ size_t i;
+ int len;
+
+ len = strlen (opname);
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ if ((int) strlen (optable[i].out) == len
+ && (options & DMGL_ANSI) == (optable[i].flags & DMGL_ANSI)
+ && memcmp (optable[i].out, opname, len) == 0)
+ return optable[i].in;
+ }
+ return (0);
+}
+
+/* char *cplus_demangle (const char *mangled, int options)
+
+ If MANGLED is a mangled function name produced by GNU C++, then
+ a pointer to a malloced string giving a C++ representation
+ of the name will be returned; otherwise NULL will be returned.
+ It is the caller's responsibility to free the string which
+ is returned.
+
+ The OPTIONS arg may contain one or more of the following bits:
+
+ DMGL_ANSI ANSI qualifiers such as `const' and `void' are
+ included.
+ DMGL_PARAMS Function parameters are included.
+
+ For example,
+
+ cplus_demangle ("foo__1Ai", DMGL_PARAMS) => "A::foo(int)"
+ cplus_demangle ("foo__1Ai", DMGL_PARAMS | DMGL_ANSI) => "A::foo(int)"
+ cplus_demangle ("foo__1Ai", 0) => "A::foo"
+
+ cplus_demangle ("foo__1Afe", DMGL_PARAMS) => "A::foo(float,...)"
+ cplus_demangle ("foo__1Afe", DMGL_PARAMS | DMGL_ANSI)=> "A::foo(float,...)"
+ cplus_demangle ("foo__1Afe", 0) => "A::foo"
+
+ Note that any leading underscores, or other such characters prepended by
+ the compilation system, are presumed to have already been stripped from
+ MANGLED. */
+
+char *
+cplus_demangle (mangled, options)
+ const char *mangled;
+ int options;
+{
+ char *ret;
+ struct work_stuff work[1];
+ memset ((char *) work, 0, sizeof (work));
+ work -> options = options;
+ if ((work -> options & DMGL_STYLE_MASK) == 0)
+ work -> options |= (int) current_demangling_style & DMGL_STYLE_MASK;
+
+ ret = internal_cplus_demangle (work, mangled);
+ squangle_mop_up (work);
+ return (ret);
+}
+
+
+/* This function performs most of what cplus_demangle use to do, but
+ to be able to demangle a name with a B, K or n code, we need to
+ have a longer term memory of what types have been seen. The original
+ now intializes and cleans up the squangle code info, while internal
+ calls go directly to this routine to avoid resetting that info. */
+
+static char *
+internal_cplus_demangle (work, mangled)
+ struct work_stuff *work;
+ const char *mangled;
+{
+
+ string decl;
+ int success = 0;
+ char *demangled = NULL;
+ int s1,s2,s3,s4;
+ s1 = work->constructor;
+ s2 = work->destructor;
+ s3 = work->static_type;
+ s4 = work->type_quals;
+ work->constructor = work->destructor = 0;
+ work->type_quals = TYPE_UNQUALIFIED;
+ work->dllimported = 0;
+
+ if ((mangled != NULL) && (*mangled != '\0'))
+ {
+ string_init (&decl);
+
+ /* First check to see if gnu style demangling is active and if the
+ string to be demangled contains a CPLUS_MARKER. If so, attempt to
+ recognize one of the gnu special forms rather than looking for a
+ standard prefix. In particular, don't worry about whether there
+ is a "__" string in the mangled string. Consider "_$_5__foo" for
+ example. */
+
+ if ((AUTO_DEMANGLING || GNU_DEMANGLING))
+ {
+ success = gnu_special (work, &mangled, &decl);
+ }
+ if (!success)
+ {
+ success = demangle_prefix (work, &mangled, &decl);
+ }
+ if (success && (*mangled != '\0'))
+ {
+ success = demangle_signature (work, &mangled, &decl);
+ }
+ if (work->constructor == 2)
+ {
+ string_prepend (&decl, "global constructors keyed to ");
+ work->constructor = 0;
+ }
+ else if (work->destructor == 2)
+ {
+ string_prepend (&decl, "global destructors keyed to ");
+ work->destructor = 0;
+ }
+ else if (work->dllimported == 1)
+ {
+ string_prepend (&decl, "import stub for ");
+ work->dllimported = 0;
+ }
+ demangled = mop_up (work, &decl, success);
+ }
+ work->constructor = s1;
+ work->destructor = s2;
+ work->static_type = s3;
+ work->type_quals = s4;
+ return (demangled);
+}
+
+
+/* Clear out and squangling related storage */
+static void
+squangle_mop_up (work)
+ struct work_stuff *work;
+{
+ /* clean up the B and K type mangling types. */
+ forget_B_and_K_types (work);
+ if (work -> btypevec != NULL)
+ {
+ free ((char *) work -> btypevec);
+ }
+ if (work -> ktypevec != NULL)
+ {
+ free ((char *) work -> ktypevec);
+ }
+}
+
+/* Clear out any mangled storage */
+
+static char *
+mop_up (work, declp, success)
+ struct work_stuff *work;
+ string *declp;
+ int success;
+{
+ char *demangled = NULL;
+
+ /* Discard the remembered types, if any. */
+
+ forget_types (work);
+ if (work -> typevec != NULL)
+ {
+ free ((char *) work -> typevec);
+ work -> typevec = NULL;
+ work -> typevec_size = 0;
+ }
+ if (work->tmpl_argvec)
+ {
+ int i;
+
+ for (i = 0; i < work->ntmpl_args; i++)
+ if (work->tmpl_argvec[i])
+ free ((char*) work->tmpl_argvec[i]);
+
+ free ((char*) work->tmpl_argvec);
+ work->tmpl_argvec = NULL;
+ }
+ if (work->previous_argument)
+ {
+ string_delete (work->previous_argument);
+ free ((char*) work->previous_argument);
+ work->previous_argument = NULL;
+ }
+
+ /* If demangling was successful, ensure that the demangled string is null
+ terminated and return it. Otherwise, free the demangling decl. */
+
+ if (!success)
+ {
+ string_delete (declp);
+ }
+ else
+ {
+ string_appendn (declp, "", 1);
+ demangled = declp -> b;
+ }
+ return (demangled);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ demangle_signature -- demangle the signature part of a mangled name
+
+SYNOPSIS
+
+ static int
+ demangle_signature (struct work_stuff *work, const char **mangled,
+ string *declp);
+
+DESCRIPTION
+
+ Consume and demangle the signature portion of the mangled name.
+
+ DECLP is the string where demangled output is being built. At
+ entry it contains the demangled root name from the mangled name
+ prefix. I.E. either a demangled operator name or the root function
+ name. In some special cases, it may contain nothing.
+
+ *MANGLED points to the current unconsumed location in the mangled
+ name. As tokens are consumed and demangling is performed, the
+ pointer is updated to continuously point at the next token to
+ be consumed.
+
+ Demangling GNU style mangled names is nasty because there is no
+ explicit token that marks the start of the outermost function
+ argument list. */
+
+static int
+demangle_signature (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ int success = 1;
+ int func_done = 0;
+ int expect_func = 0;
+ int expect_return_type = 0;
+ const char *oldmangled = NULL;
+ string trawname;
+ string tname;
+
+ while (success && (**mangled != '\0'))
+ {
+ switch (**mangled)
+ {
+ case 'Q':
+ oldmangled = *mangled;
+ success = demangle_qualified (work, mangled, declp, 1, 0);
+ if (success)
+ remember_type (work, oldmangled, *mangled - oldmangled);
+ if (AUTO_DEMANGLING || GNU_DEMANGLING)
+ expect_func = 1;
+ oldmangled = NULL;
+ break;
+
+ case 'K':
+ oldmangled = *mangled;
+ success = demangle_qualified (work, mangled, declp, 1, 0);
+ if (AUTO_DEMANGLING || GNU_DEMANGLING)
+ {
+ expect_func = 1;
+ }
+ oldmangled = NULL;
+ break;
+
+ case 'S':
+ /* Static member function */
+ if (oldmangled == NULL)
+ {
+ oldmangled = *mangled;
+ }
+ (*mangled)++;
+ work -> static_type = 1;
+ break;
+
+ case 'C':
+ case 'V':
+ case 'u':
+ work->type_quals |= code_for_qualifier (**mangled);
+
+ /* a qualified member function */
+ if (oldmangled == NULL)
+ oldmangled = *mangled;
+ (*mangled)++;
+ break;
+
+ case 'L':
+ /* Local class name follows after "Lnnn_" */
+ if (HP_DEMANGLING)
+ {
+ while (**mangled && (**mangled != '_'))
+ (*mangled)++;
+ if (!**mangled)
+ success = 0;
+ else
+ (*mangled)++;
+ }
+ else
+ success = 0;
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ if (oldmangled == NULL)
+ {
+ oldmangled = *mangled;
+ }
+ work->temp_start = -1; /* uppermost call to demangle_class */
+ success = demangle_class (work, mangled, declp);
+ if (success)
+ {
+ remember_type (work, oldmangled, *mangled - oldmangled);
+ }
+ if (AUTO_DEMANGLING || GNU_DEMANGLING || EDG_DEMANGLING)
+ {
+ /* EDG and others will have the "F", so we let the loop cycle
+ if we are looking at one. */
+ if (**mangled != 'F')
+ expect_func = 1;
+ }
+ oldmangled = NULL;
+ break;
+
+ case 'B':
+ {
+ string s;
+ success = do_type (work, mangled, &s);
+ if (success)
+ {
+ string_append (&s, SCOPE_STRING (work));
+ string_prepends (declp, &s);
+ }
+ oldmangled = NULL;
+ expect_func = 1;
+ }
+ break;
+
+ case 'F':
+ /* Function */
+ /* ARM/HP style demangling includes a specific 'F' character after
+ the class name. For GNU style, it is just implied. So we can
+ safely just consume any 'F' at this point and be compatible
+ with either style. */
+
+ oldmangled = NULL;
+ func_done = 1;
+ (*mangled)++;
+
+ /* For lucid/ARM/HP style we have to forget any types we might
+ have remembered up to this point, since they were not argument
+ types. GNU style considers all types seen as available for
+ back references. See comment in demangle_args() */
+
+ if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)
+ {
+ forget_types (work);
+ }
+ success = demangle_args (work, mangled, declp);
+ /* After picking off the function args, we expect to either
+ find the function return type (preceded by an '_') or the
+ end of the string. */
+ if (success && (AUTO_DEMANGLING || EDG_DEMANGLING) && **mangled == '_')
+ {
+ ++(*mangled);
+ /* At this level, we do not care about the return type. */
+ success = do_type (work, mangled, &tname);
+ string_delete (&tname);
+ }
+
+ break;
+
+ case 't':
+ /* G++ Template */
+ string_init(&trawname);
+ string_init(&tname);
+ if (oldmangled == NULL)
+ {
+ oldmangled = *mangled;
+ }
+ success = demangle_template (work, mangled, &tname,
+ &trawname, 1, 1);
+ if (success)
+ {
+ remember_type (work, oldmangled, *mangled - oldmangled);
+ }
+ string_append (&tname, SCOPE_STRING (work));
+
+ string_prepends(declp, &tname);
+ if (work -> destructor & 1)
+ {
+ string_prepend (&trawname, "~");
+ string_appends (declp, &trawname);
+ work->destructor -= 1;
+ }
+ if ((work->constructor & 1) || (work->destructor & 1))
+ {
+ string_appends (declp, &trawname);
+ work->constructor -= 1;
+ }
+ string_delete(&trawname);
+ string_delete(&tname);
+ oldmangled = NULL;
+ expect_func = 1;
+ break;
+
+ case '_':
+ if (GNU_DEMANGLING && expect_return_type)
+ {
+ /* Read the return type. */
+ string return_type;
+ string_init (&return_type);
+
+ (*mangled)++;
+ success = do_type (work, mangled, &return_type);
+ APPEND_BLANK (&return_type);
+
+ string_prepends (declp, &return_type);
+ string_delete (&return_type);
+ break;
+ }
+ else
+ /* At the outermost level, we cannot have a return type specified,
+ so if we run into another '_' at this point we are dealing with
+ a mangled name that is either bogus, or has been mangled by
+ some algorithm we don't know how to deal with. So just
+ reject the entire demangling. */
+ /* However, "_nnn" is an expected suffix for alternate entry point
+ numbered nnn for a function, with HP aCC, so skip over that
+ without reporting failure. pai/1997-09-04 */
+ if (HP_DEMANGLING)
+ {
+ (*mangled)++;
+ while (**mangled && isdigit ((unsigned char)**mangled))
+ (*mangled)++;
+ }
+ else
+ success = 0;
+ break;
+
+ case 'H':
+ if (GNU_DEMANGLING)
+ {
+ /* A G++ template function. Read the template arguments. */
+ success = demangle_template (work, mangled, declp, 0, 0,
+ 0);
+ if (!(work->constructor & 1))
+ expect_return_type = 1;
+ (*mangled)++;
+ break;
+ }
+ else
+ /* fall through */
+ {;}
+
+ default:
+ if (AUTO_DEMANGLING || GNU_DEMANGLING)
+ {
+ /* Assume we have stumbled onto the first outermost function
+ argument token, and start processing args. */
+ func_done = 1;
+ success = demangle_args (work, mangled, declp);
+ }
+ else
+ {
+ /* Non-GNU demanglers use a specific token to mark the start
+ of the outermost function argument tokens. Typically 'F',
+ for ARM/HP-demangling, for example. So if we find something
+ we are not prepared for, it must be an error. */
+ success = 0;
+ }
+ break;
+ }
+ /*
+ if (AUTO_DEMANGLING || GNU_DEMANGLING)
+ */
+ {
+ if (success && expect_func)
+ {
+ func_done = 1;
+ if (LUCID_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING)
+ {
+ forget_types (work);
+ }
+ success = demangle_args (work, mangled, declp);
+ /* Since template include the mangling of their return types,
+ we must set expect_func to 0 so that we don't try do
+ demangle more arguments the next time we get here. */
+ expect_func = 0;
+ }
+ }
+ }
+ if (success && !func_done)
+ {
+ if (AUTO_DEMANGLING || GNU_DEMANGLING)
+ {
+ /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and
+ bar__3fooi is 'foo::bar(int)'. We get here when we find the
+ first case, and need to ensure that the '(void)' gets added to
+ the current declp. Note that with ARM/HP, the first case
+ represents the name of a static data member 'foo::bar',
+ which is in the current declp, so we leave it alone. */
+ success = demangle_args (work, mangled, declp);
+ }
+ }
+ if (success && PRINT_ARG_TYPES)
+ {
+ if (work->static_type)
+ string_append (declp, " static");
+ if (work->type_quals != TYPE_UNQUALIFIED)
+ {
+ APPEND_BLANK (declp);
+ string_append (declp, qualifier_string (work->type_quals));
+ }
+ }
+
+ return (success);
+}
+
+#if 0
+
+static int
+demangle_method_args (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ int success = 0;
+
+ if (work -> static_type)
+ {
+ string_append (declp, *mangled + 1);
+ *mangled += strlen (*mangled);
+ success = 1;
+ }
+ else
+ {
+ success = demangle_args (work, mangled, declp);
+ }
+ return (success);
+}
+
+#endif
+
+static int
+demangle_template_template_parm (work, mangled, tname)
+ struct work_stuff *work;
+ const char **mangled;
+ string *tname;
+{
+ int i;
+ int r;
+ int need_comma = 0;
+ int success = 1;
+ string temp;
+
+ string_append (tname, "template <");
+ /* get size of template parameter list */
+ if (get_count (mangled, &r))
+ {
+ for (i = 0; i < r; i++)
+ {
+ if (need_comma)
+ {
+ string_append (tname, ", ");
+ }
+
+ /* Z for type parameters */
+ if (**mangled == 'Z')
+ {
+ (*mangled)++;
+ string_append (tname, "class");
+ }
+ /* z for template parameters */
+ else if (**mangled == 'z')
+ {
+ (*mangled)++;
+ success =
+ demangle_template_template_parm (work, mangled, tname);
+ if (!success)
+ {
+ break;
+ }
+ }
+ else
+ {
+ /* temp is initialized in do_type */
+ success = do_type (work, mangled, &temp);
+ if (success)
+ {
+ string_appends (tname, &temp);
+ }
+ string_delete(&temp);
+ if (!success)
+ {
+ break;
+ }
+ }
+ need_comma = 1;
+ }
+
+ }
+ if (tname->p[-1] == '>')
+ string_append (tname, " ");
+ string_append (tname, "> class");
+ return (success);
+}
+
+static int
+demangle_integral_value (work, mangled, s)
+ struct work_stuff *work;
+ const char** mangled;
+ string* s;
+{
+ int success;
+
+ if (**mangled == 'E')
+ {
+ int need_operator = 0;
+
+ success = 1;
+ string_appendn (s, "(", 1);
+ (*mangled)++;
+ while (success && **mangled != 'W' && **mangled != '\0')
+ {
+ if (need_operator)
+ {
+ size_t i;
+ size_t len;
+
+ success = 0;
+
+ len = strlen (*mangled);
+
+ for (i = 0;
+ i < sizeof (optable) / sizeof (optable [0]);
+ ++i)
+ {
+ size_t l = strlen (optable[i].in);
+
+ if (l <= len
+ && memcmp (optable[i].in, *mangled, l) == 0)
+ {
+ string_appendn (s, " ", 1);
+ string_append (s, optable[i].out);
+ string_appendn (s, " ", 1);
+ success = 1;
+ (*mangled) += l;
+ break;
+ }
+ }
+
+ if (!success)
+ break;
+ }
+ else
+ need_operator = 1;
+
+ success = demangle_template_value_parm (work, mangled, s,
+ tk_integral);
+ }
+
+ if (**mangled != 'W')
+ success = 0;
+ else
+ {
+ string_appendn (s, ")", 1);
+ (*mangled)++;
+ }
+ }
+ else if (**mangled == 'Q' || **mangled == 'K')
+ success = demangle_qualified (work, mangled, s, 0, 1);
+ else
+ {
+ success = 0;
+
+ if (**mangled == 'm')
+ {
+ string_appendn (s, "-", 1);
+ (*mangled)++;
+ }
+ while (isdigit ((unsigned char)**mangled))
+ {
+ string_appendn (s, *mangled, 1);
+ (*mangled)++;
+ success = 1;
+ }
+ }
+
+ return success;
+}
+
+static int
+demangle_template_value_parm (work, mangled, s, tk)
+ struct work_stuff *work;
+ const char **mangled;
+ string* s;
+ type_kind_t tk;
+{
+ int success = 1;
+
+ if (**mangled == 'Y')
+ {
+ /* The next argument is a template parameter. */
+ int idx;
+
+ (*mangled)++;
+ idx = consume_count_with_underscores (mangled);
+ if (idx == -1
+ || (work->tmpl_argvec && idx >= work->ntmpl_args)
+ || consume_count_with_underscores (mangled) == -1)
+ return -1;
+ if (work->tmpl_argvec)
+ string_append (s, work->tmpl_argvec[idx]);
+ else
+ {
+ char buf[10];
+ sprintf(buf, "T%d", idx);
+ string_append (s, buf);
+ }
+ }
+ else if (tk == tk_integral)
+ success = demangle_integral_value (work, mangled, s);
+ else if (tk == tk_char)
+ {
+ char tmp[2];
+ int val;
+ if (**mangled == 'm')
+ {
+ string_appendn (s, "-", 1);
+ (*mangled)++;
+ }
+ string_appendn (s, "'", 1);
+ val = consume_count(mangled);
+ if (val <= 0)
+ success = 0;
+ else
+ {
+ tmp[0] = (char)val;
+ tmp[1] = '\0';
+ string_appendn (s, &tmp[0], 1);
+ string_appendn (s, "'", 1);
+ }
+ }
+ else if (tk == tk_bool)
+ {
+ int val = consume_count (mangled);
+ if (val == 0)
+ string_appendn (s, "false", 5);
+ else if (val == 1)
+ string_appendn (s, "true", 4);
+ else
+ success = 0;
+ }
+ else if (tk == tk_real)
+ {
+ if (**mangled == 'm')
+ {
+ string_appendn (s, "-", 1);
+ (*mangled)++;
+ }
+ while (isdigit ((unsigned char)**mangled))
+ {
+ string_appendn (s, *mangled, 1);
+ (*mangled)++;
+ }
+ if (**mangled == '.') /* fraction */
+ {
+ string_appendn (s, ".", 1);
+ (*mangled)++;
+ while (isdigit ((unsigned char)**mangled))
+ {
+ string_appendn (s, *mangled, 1);
+ (*mangled)++;
+ }
+ }
+ if (**mangled == 'e') /* exponent */
+ {
+ string_appendn (s, "e", 1);
+ (*mangled)++;
+ while (isdigit ((unsigned char)**mangled))
+ {
+ string_appendn (s, *mangled, 1);
+ (*mangled)++;
+ }
+ }
+ }
+ else if (tk == tk_pointer || tk == tk_reference)
+ {
+ int symbol_len = consume_count (mangled);
+ if (symbol_len == -1)
+ return -1;
+ if (symbol_len == 0)
+ string_appendn (s, "0", 1);
+ else
+ {
+ char *p = xmalloc (symbol_len + 1), *q;
+ strncpy (p, *mangled, symbol_len);
+ p [symbol_len] = '\0';
+ /* We use cplus_demangle here, rather than
+ internal_cplus_demangle, because the name of the entity
+ mangled here does not make use of any of the squangling
+ or type-code information we have built up thus far; it is
+ mangled independently. */
+ q = cplus_demangle (p, work->options);
+ if (tk == tk_pointer)
+ string_appendn (s, "&", 1);
+ /* FIXME: Pointer-to-member constants should get a
+ qualifying class name here. */
+ if (q)
+ {
+ string_append (s, q);
+ free (q);
+ }
+ else
+ string_append (s, p);
+ free (p);
+ }
+ *mangled += symbol_len;
+ }
+
+ return success;
+}
+
+/* Demangle the template name in MANGLED. The full name of the
+ template (e.g., S<int>) is placed in TNAME. The name without the
+ template parameters (e.g. S) is placed in TRAWNAME if TRAWNAME is
+ non-NULL. If IS_TYPE is nonzero, this template is a type template,
+ not a function template. If both IS_TYPE and REMEMBER are nonzero,
+ the tmeplate is remembered in the list of back-referenceable
+ types. */
+
+static int
+demangle_template (work, mangled, tname, trawname, is_type, remember)
+ struct work_stuff *work;
+ const char **mangled;
+ string *tname;
+ string *trawname;
+ int is_type;
+ int remember;
+{
+ int i;
+ int r;
+ int need_comma = 0;
+ int success = 0;
+ const char *start;
+ int is_java_array = 0;
+ string temp;
+ int bindex = 0;
+
+ (*mangled)++;
+ if (is_type)
+ {
+ if (remember)
+ bindex = register_Btype (work);
+ start = *mangled;
+ /* get template name */
+ if (**mangled == 'z')
+ {
+ int idx;
+ (*mangled)++;
+ (*mangled)++;
+
+ idx = consume_count_with_underscores (mangled);
+ if (idx == -1
+ || (work->tmpl_argvec && idx >= work->ntmpl_args)
+ || consume_count_with_underscores (mangled) == -1)
+ return (0);
+
+ if (work->tmpl_argvec)
+ {
+ string_append (tname, work->tmpl_argvec[idx]);
+ if (trawname)
+ string_append (trawname, work->tmpl_argvec[idx]);
+ }
+ else
+ {
+ char buf[10];
+ sprintf(buf, "T%d", idx);
+ string_append (tname, buf);
+ if (trawname)
+ string_append (trawname, buf);
+ }
+ }
+ else
+ {
+ if ((r = consume_count (mangled)) <= 0
+ || (int) strlen (*mangled) < r)
+ {
+ return (0);
+ }
+ is_java_array = (work -> options & DMGL_JAVA)
+ && strncmp (*mangled, "JArray1Z", 8) == 0;
+ if (! is_java_array)
+ {
+ string_appendn (tname, *mangled, r);
+ }
+ if (trawname)
+ string_appendn (trawname, *mangled, r);
+ *mangled += r;
+ }
+ }
+ if (!is_java_array)
+ string_append (tname, "<");
+ /* get size of template parameter list */
+ if (!get_count (mangled, &r))
+ {
+ return (0);
+ }
+ if (!is_type)
+ {
+ /* Create an array for saving the template argument values. */
+ work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *));
+ work->ntmpl_args = r;
+ for (i = 0; i < r; i++)
+ work->tmpl_argvec[i] = 0;
+ }
+ for (i = 0; i < r; i++)
+ {
+ if (need_comma)
+ {
+ string_append (tname, ", ");
+ }
+ /* Z for type parameters */
+ if (**mangled == 'Z')
+ {
+ (*mangled)++;
+ /* temp is initialized in do_type */
+ success = do_type (work, mangled, &temp);
+ if (success)
+ {
+ string_appends (tname, &temp);
+
+ if (!is_type)
+ {
+ /* Save the template argument. */
+ int len = temp.p - temp.b;
+ work->tmpl_argvec[i] = xmalloc (len + 1);
+ memcpy (work->tmpl_argvec[i], temp.b, len);
+ work->tmpl_argvec[i][len] = '\0';
+ }
+ }
+ string_delete(&temp);
+ if (!success)
+ {
+ break;
+ }
+ }
+ /* z for template parameters */
+ else if (**mangled == 'z')
+ {
+ int r2;
+ (*mangled)++;
+ success = demangle_template_template_parm (work, mangled, tname);
+
+ if (success
+ && (r2 = consume_count (mangled)) > 0
+ && (int) strlen (*mangled) >= r2)
+ {
+ string_append (tname, " ");
+ string_appendn (tname, *mangled, r2);
+ if (!is_type)
+ {
+ /* Save the template argument. */
+ int len = r2;
+ work->tmpl_argvec[i] = xmalloc (len + 1);
+ memcpy (work->tmpl_argvec[i], *mangled, len);
+ work->tmpl_argvec[i][len] = '\0';
+ }
+ *mangled += r2;
+ }
+ if (!success)
+ {
+ break;
+ }
+ }
+ else
+ {
+ string param;
+ string* s;
+
+ /* otherwise, value parameter */
+
+ /* temp is initialized in do_type */
+ success = do_type (work, mangled, &temp);
+ string_delete(&temp);
+ if (!success)
+ break;
+
+ if (!is_type)
+ {
+ s = &param;
+ string_init (s);
+ }
+ else
+ s = tname;
+
+ success = demangle_template_value_parm (work, mangled, s,
+ (type_kind_t) success);
+
+ if (!success)
+ {
+ if (!is_type)
+ string_delete (s);
+ success = 0;
+ break;
+ }
+
+ if (!is_type)
+ {
+ int len = s->p - s->b;
+ work->tmpl_argvec[i] = xmalloc (len + 1);
+ memcpy (work->tmpl_argvec[i], s->b, len);
+ work->tmpl_argvec[i][len] = '\0';
+
+ string_appends (tname, s);
+ string_delete (s);
+ }
+ }
+ need_comma = 1;
+ }
+ if (is_java_array)
+ {
+ string_append (tname, "[]");
+ }
+ else
+ {
+ if (tname->p[-1] == '>')
+ string_append (tname, " ");
+ string_append (tname, ">");
+ }
+
+ if (is_type && remember)
+ remember_Btype (work, tname->b, LEN_STRING (tname), bindex);
+
+ /*
+ if (work -> static_type)
+ {
+ string_append (declp, *mangled + 1);
+ *mangled += strlen (*mangled);
+ success = 1;
+ }
+ else
+ {
+ success = demangle_args (work, mangled, declp);
+ }
+ }
+ */
+ return (success);
+}
+
+static int
+arm_pt (work, mangled, n, anchor, args)
+ struct work_stuff *work;
+ const char *mangled;
+ int n;
+ const char **anchor, **args;
+{
+ /* Check if ARM template with "__pt__" in it ("parameterized type") */
+ /* Allow HP also here, because HP's cfront compiler follows ARM to some extent */
+ if ((ARM_DEMANGLING || HP_DEMANGLING) && (*anchor = mystrstr (mangled, "__pt__")))
+ {
+ int len;
+ *args = *anchor + 6;
+ len = consume_count (args);
+ if (len == -1)
+ return 0;
+ if (*args + len == mangled + n && **args == '_')
+ {
+ ++*args;
+ return 1;
+ }
+ }
+ if (AUTO_DEMANGLING || EDG_DEMANGLING)
+ {
+ if ((*anchor = mystrstr (mangled, "__tm__"))
+ || (*anchor = mystrstr (mangled, "__ps__"))
+ || (*anchor = mystrstr (mangled, "__pt__")))
+ {
+ int len;
+ *args = *anchor + 6;
+ len = consume_count (args);
+ if (len == -1)
+ return 0;
+ if (*args + len == mangled + n && **args == '_')
+ {
+ ++*args;
+ return 1;
+ }
+ }
+ else if ((*anchor = mystrstr (mangled, "__S")))
+ {
+ int len;
+ *args = *anchor + 3;
+ len = consume_count (args);
+ if (len == -1)
+ return 0;
+ if (*args + len == mangled + n && **args == '_')
+ {
+ ++*args;
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static void
+demangle_arm_hp_template (work, mangled, n, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ int n;
+ string *declp;
+{
+ const char *p;
+ const char *args;
+ const char *e = *mangled + n;
+ string arg;
+
+ /* Check for HP aCC template spec: classXt1t2 where t1, t2 are
+ template args */
+ if (HP_DEMANGLING && ((*mangled)[n] == 'X'))
+ {
+ char *start_spec_args = NULL;
+
+ /* First check for and omit template specialization pseudo-arguments,
+ such as in "Spec<#1,#1.*>" */
+ start_spec_args = strchr (*mangled, '<');
+ if (start_spec_args && (start_spec_args - *mangled < n))
+ string_appendn (declp, *mangled, start_spec_args - *mangled);
+ else
+ string_appendn (declp, *mangled, n);
+ (*mangled) += n + 1;
+ string_init (&arg);
+ if (work->temp_start == -1) /* non-recursive call */
+ work->temp_start = declp->p - declp->b;
+ string_append (declp, "<");
+ while (1)
+ {
+ string_clear (&arg);
+ switch (**mangled)
+ {
+ case 'T':
+ /* 'T' signals a type parameter */
+ (*mangled)++;
+ if (!do_type (work, mangled, &arg))
+ goto hpacc_template_args_done;
+ break;
+
+ case 'U':
+ case 'S':
+ /* 'U' or 'S' signals an integral value */
+ if (!do_hpacc_template_const_value (work, mangled, &arg))
+ goto hpacc_template_args_done;
+ break;
+
+ case 'A':
+ /* 'A' signals a named constant expression (literal) */
+ if (!do_hpacc_template_literal (work, mangled, &arg))
+ goto hpacc_template_args_done;
+ break;
+
+ default:
+ /* Today, 1997-09-03, we have only the above types
+ of template parameters */
+ /* FIXME: maybe this should fail and return null */
+ goto hpacc_template_args_done;
+ }
+ string_appends (declp, &arg);
+ /* Check if we're at the end of template args.
+ 0 if at end of static member of template class,
+ _ if done with template args for a function */
+ if ((**mangled == '\000') || (**mangled == '_'))
+ break;
+ else
+ string_append (declp, ",");
+ }
+ hpacc_template_args_done:
+ string_append (declp, ">");
+ string_delete (&arg);
+ if (**mangled == '_')
+ (*mangled)++;
+ return;
+ }
+ /* ARM template? (Also handles HP cfront extensions) */
+ else if (arm_pt (work, *mangled, n, &p, &args))
+ {
+ string type_str;
+
+ string_init (&arg);
+ string_appendn (declp, *mangled, p - *mangled);
+ if (work->temp_start == -1) /* non-recursive call */
+ work->temp_start = declp->p - declp->b;
+ string_append (declp, "<");
+ /* should do error checking here */
+ while (args < e) {
+ string_clear (&arg);
+
+ /* Check for type or literal here */
+ switch (*args)
+ {
+ /* HP cfront extensions to ARM for template args */
+ /* spec: Xt1Lv1 where t1 is a type, v1 is a literal value */
+ /* FIXME: We handle only numeric literals for HP cfront */
+ case 'X':
+ /* A typed constant value follows */
+ args++;
+ if (!do_type (work, &args, &type_str))
+ goto cfront_template_args_done;
+ string_append (&arg, "(");
+ string_appends (&arg, &type_str);
+ string_append (&arg, ")");
+ if (*args != 'L')
+ goto cfront_template_args_done;
+ args++;
+ /* Now snarf a literal value following 'L' */
+ if (!snarf_numeric_literal (&args, &arg))
+ goto cfront_template_args_done;
+ break;
+
+ case 'L':
+ /* Snarf a literal following 'L' */
+ args++;
+ if (!snarf_numeric_literal (&args, &arg))
+ goto cfront_template_args_done;
+ break;
+ default:
+ /* Not handling other HP cfront stuff */
+ if (!do_type (work, &args, &arg))
+ goto cfront_template_args_done;
+ }
+ string_appends (declp, &arg);
+ string_append (declp, ",");
+ }
+ cfront_template_args_done:
+ string_delete (&arg);
+ if (args >= e)
+ --declp->p; /* remove extra comma */
+ string_append (declp, ">");
+ }
+ else if (n>10 && strncmp (*mangled, "_GLOBAL_", 8) == 0
+ && (*mangled)[9] == 'N'
+ && (*mangled)[8] == (*mangled)[10]
+ && strchr (cplus_markers, (*mangled)[8]))
+ {
+ /* A member of the anonymous namespace. */
+ string_append (declp, "{anonymous}");
+ }
+ else
+ {
+ if (work->temp_start == -1) /* non-recursive call only */
+ work->temp_start = 0; /* disable in recursive calls */
+ string_appendn (declp, *mangled, n);
+ }
+ *mangled += n;
+}
+
+/* Extract a class name, possibly a template with arguments, from the
+ mangled string; qualifiers, local class indicators, etc. have
+ already been dealt with */
+
+static int
+demangle_class_name (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ int n;
+ int success = 0;
+
+ n = consume_count (mangled);
+ if (n == -1)
+ return 0;
+ if ((int) strlen (*mangled) >= n)
+ {
+ demangle_arm_hp_template (work, mangled, n, declp);
+ success = 1;
+ }
+
+ return (success);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ demangle_class -- demangle a mangled class sequence
+
+SYNOPSIS
+
+ static int
+ demangle_class (struct work_stuff *work, const char **mangled,
+ strint *declp)
+
+DESCRIPTION
+
+ DECLP points to the buffer into which demangling is being done.
+
+ *MANGLED points to the current token to be demangled. On input,
+ it points to a mangled class (I.E. "3foo", "13verylongclass", etc.)
+ On exit, it points to the next token after the mangled class on
+ success, or the first unconsumed token on failure.
+
+ If the CONSTRUCTOR or DESTRUCTOR flags are set in WORK, then
+ we are demangling a constructor or destructor. In this case
+ we prepend "class::class" or "class::~class" to DECLP.
+
+ Otherwise, we prepend "class::" to the current DECLP.
+
+ Reset the constructor/destructor flags once they have been
+ "consumed". This allows demangle_class to be called later during
+ the same demangling, to do normal class demangling.
+
+ Returns 1 if demangling is successful, 0 otherwise.
+
+*/
+
+static int
+demangle_class (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ int success = 0;
+ int btype;
+ string class_name;
+ char *save_class_name_end = 0;
+
+ string_init (&class_name);
+ btype = register_Btype (work);
+ if (demangle_class_name (work, mangled, &class_name))
+ {
+ save_class_name_end = class_name.p;
+ if ((work->constructor & 1) || (work->destructor & 1))
+ {
+ /* adjust so we don't include template args */
+ if (work->temp_start && (work->temp_start != -1))
+ {
+ class_name.p = class_name.b + work->temp_start;
+ }
+ string_prepends (declp, &class_name);
+ if (work -> destructor & 1)
+ {
+ string_prepend (declp, "~");
+ work -> destructor -= 1;
+ }
+ else
+ {
+ work -> constructor -= 1;
+ }
+ }
+ class_name.p = save_class_name_end;
+ remember_Ktype (work, class_name.b, LEN_STRING(&class_name));
+ remember_Btype (work, class_name.b, LEN_STRING(&class_name), btype);
+ string_prepend (declp, SCOPE_STRING (work));
+ string_prepends (declp, &class_name);
+ success = 1;
+ }
+ string_delete (&class_name);
+ return (success);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ demangle_prefix -- consume the mangled name prefix and find signature
+
+SYNOPSIS
+
+ static int
+ demangle_prefix (struct work_stuff *work, const char **mangled,
+ string *declp);
+
+DESCRIPTION
+
+ Consume and demangle the prefix of the mangled name.
+
+ DECLP points to the string buffer into which demangled output is
+ placed. On entry, the buffer is empty. On exit it contains
+ the root function name, the demangled operator name, or in some
+ special cases either nothing or the completely demangled result.
+
+ MANGLED points to the current pointer into the mangled name. As each
+ token of the mangled name is consumed, it is updated. Upon entry
+ the current mangled name pointer points to the first character of
+ the mangled name. Upon exit, it should point to the first character
+ of the signature if demangling was successful, or to the first
+ unconsumed character if demangling of the prefix was unsuccessful.
+
+ Returns 1 on success, 0 otherwise.
+ */
+
+static int
+demangle_prefix (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ int success = 1;
+ const char *scan;
+ int i;
+
+ if (strlen(*mangled) > 6
+ && (strncmp(*mangled, "_imp__", 6) == 0
+ || strncmp(*mangled, "__imp_", 6) == 0))
+ {
+ /* it's a symbol imported from a PE dynamic library. Check for both
+ new style prefix _imp__ and legacy __imp_ used by older versions
+ of dlltool. */
+ (*mangled) += 6;
+ work->dllimported = 1;
+ }
+ else if (strlen(*mangled) >= 11 && strncmp(*mangled, "_GLOBAL_", 8) == 0)
+ {
+ char *marker = strchr (cplus_markers, (*mangled)[8]);
+ if (marker != NULL && *marker == (*mangled)[10])
+ {
+ if ((*mangled)[9] == 'D')
+ {
+ /* it's a GNU global destructor to be executed at program exit */
+ (*mangled) += 11;
+ work->destructor = 2;
+ if (gnu_special (work, mangled, declp))
+ return success;
+ }
+ else if ((*mangled)[9] == 'I')
+ {
+ /* it's a GNU global constructor to be executed at program init */
+ (*mangled) += 11;
+ work->constructor = 2;
+ if (gnu_special (work, mangled, declp))
+ return success;
+ }
+ }
+ }
+ else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__std__", 7) == 0)
+ {
+ /* it's a ARM global destructor to be executed at program exit */
+ (*mangled) += 7;
+ work->destructor = 2;
+ }
+ else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__sti__", 7) == 0)
+ {
+ /* it's a ARM global constructor to be executed at program initial */
+ (*mangled) += 7;
+ work->constructor = 2;
+ }
+
+ /* This block of code is a reduction in strength time optimization
+ of:
+ scan = mystrstr (*mangled, "__"); */
+
+ {
+ scan = *mangled;
+
+ do {
+ scan = strchr (scan, '_');
+ } while (scan != NULL && *++scan != '_');
+
+ if (scan != NULL) --scan;
+ }
+
+ if (scan != NULL)
+ {
+ /* We found a sequence of two or more '_', ensure that we start at
+ the last pair in the sequence. */
+ i = strspn (scan, "_");
+ if (i > 2)
+ {
+ scan += (i - 2);
+ }
+ }
+
+ if (scan == NULL)
+ {
+ success = 0;
+ }
+ else if (work -> static_type)
+ {
+ if (!isdigit ((unsigned char)scan[0]) && (scan[0] != 't'))
+ {
+ success = 0;
+ }
+ }
+ else if ((scan == *mangled)
+ && (isdigit ((unsigned char)scan[2]) || (scan[2] == 'Q')
+ || (scan[2] == 't') || (scan[2] == 'K') || (scan[2] == 'H')))
+ {
+ /* The ARM says nothing about the mangling of local variables.
+ But cfront mangles local variables by prepending __<nesting_level>
+ to them. As an extension to ARM demangling we handle this case. */
+ if ((LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING)
+ && isdigit ((unsigned char)scan[2]))
+ {
+ *mangled = scan + 2;
+ consume_count (mangled);
+ string_append (declp, *mangled);
+ *mangled += strlen (*mangled);
+ success = 1;
+ }
+ else
+ {
+ /* A GNU style constructor starts with __[0-9Qt]. But cfront uses
+ names like __Q2_3foo3bar for nested type names. So don't accept
+ this style of constructor for cfront demangling. A GNU
+ style member-template constructor starts with 'H'. */
+ if (!(LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING))
+ work -> constructor += 1;
+ *mangled = scan + 2;
+ }
+ }
+ else if (ARM_DEMANGLING && scan[2] == 'p' && scan[3] == 't')
+ {
+ /* Cfront-style parameterized type. Handled later as a signature. */
+ success = 1;
+
+ /* ARM template? */
+ demangle_arm_hp_template (work, mangled, strlen (*mangled), declp);
+ }
+ else if (EDG_DEMANGLING && ((scan[2] == 't' && scan[3] == 'm')
+ || (scan[2] == 'p' && scan[3] == 's')
+ || (scan[2] == 'p' && scan[3] == 't')))
+ {
+ /* EDG-style parameterized type. Handled later as a signature. */
+ success = 1;
+
+ /* EDG template? */
+ demangle_arm_hp_template (work, mangled, strlen (*mangled), declp);
+ }
+ else if ((scan == *mangled) && !isdigit ((unsigned char)scan[2])
+ && (scan[2] != 't'))
+ {
+ /* Mangled name starts with "__". Skip over any leading '_' characters,
+ then find the next "__" that separates the prefix from the signature.
+ */
+ if (!(ARM_DEMANGLING || LUCID_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)
+ || (arm_special (mangled, declp) == 0))
+ {
+ while (*scan == '_')
+ {
+ scan++;
+ }
+ if ((scan = mystrstr (scan, "__")) == NULL || (*(scan + 2) == '\0'))
+ {
+ /* No separator (I.E. "__not_mangled"), or empty signature
+ (I.E. "__not_mangled_either__") */
+ success = 0;
+ }
+ else
+ {
+ const char *tmp;
+
+ /* Look for the LAST occurrence of __, allowing names to
+ have the '__' sequence embedded in them. */
+ if (!(ARM_DEMANGLING || HP_DEMANGLING))
+ {
+ while ((tmp = mystrstr (scan + 2, "__")) != NULL)
+ scan = tmp;
+ }
+ if (*(scan + 2) == '\0')
+ success = 0;
+ else
+ demangle_function_name (work, mangled, declp, scan);
+ }
+ }
+ }
+ else if (*(scan + 2) != '\0')
+ {
+ /* Mangled name does not start with "__" but does have one somewhere
+ in there with non empty stuff after it. Looks like a global
+ function name. */
+ demangle_function_name (work, mangled, declp, scan);
+ }
+ else
+ {
+ /* Doesn't look like a mangled name */
+ success = 0;
+ }
+
+ if (!success && (work->constructor == 2 || work->destructor == 2))
+ {
+ string_append (declp, *mangled);
+ *mangled += strlen (*mangled);
+ success = 1;
+ }
+ return (success);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ gnu_special -- special handling of gnu mangled strings
+
+SYNOPSIS
+
+ static int
+ gnu_special (struct work_stuff *work, const char **mangled,
+ string *declp);
+
+
+DESCRIPTION
+
+ Process some special GNU style mangling forms that don't fit
+ the normal pattern. For example:
+
+ _$_3foo (destructor for class foo)
+ _vt$foo (foo virtual table)
+ _vt$foo$bar (foo::bar virtual table)
+ __vt_foo (foo virtual table, new style with thunks)
+ _3foo$varname (static data member)
+ _Q22rs2tu$vw (static data member)
+ __t6vector1Zii (constructor with template)
+ __thunk_4__$_7ostream (virtual function thunk)
+ */
+
+static int
+gnu_special (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ int n;
+ int success = 1;
+ const char *p;
+
+ if ((*mangled)[0] == '_'
+ && strchr (cplus_markers, (*mangled)[1]) != NULL
+ && (*mangled)[2] == '_')
+ {
+ /* Found a GNU style destructor, get past "_<CPLUS_MARKER>_" */
+ (*mangled) += 3;
+ work -> destructor += 1;
+ }
+ else if ((*mangled)[0] == '_'
+ && (((*mangled)[1] == '_'
+ && (*mangled)[2] == 'v'
+ && (*mangled)[3] == 't'
+ && (*mangled)[4] == '_')
+ || ((*mangled)[1] == 'v'
+ && (*mangled)[2] == 't'
+ && strchr (cplus_markers, (*mangled)[3]) != NULL)))
+ {
+ /* Found a GNU style virtual table, get past "_vt<CPLUS_MARKER>"
+ and create the decl. Note that we consume the entire mangled
+ input string, which means that demangle_signature has no work
+ to do. */
+ if ((*mangled)[2] == 'v')
+ (*mangled) += 5; /* New style, with thunks: "__vt_" */
+ else
+ (*mangled) += 4; /* Old style, no thunks: "_vt<CPLUS_MARKER>" */
+ while (**mangled != '\0')
+ {
+ switch (**mangled)
+ {
+ case 'Q':
+ case 'K':
+ success = demangle_qualified (work, mangled, declp, 0, 1);
+ break;
+ case 't':
+ success = demangle_template (work, mangled, declp, 0, 1,
+ 1);
+ break;
+ default:
+ if (isdigit((unsigned char)*mangled[0]))
+ {
+ n = consume_count(mangled);
+ /* We may be seeing a too-large size, or else a
+ ".<digits>" indicating a static local symbol. In
+ any case, declare victory and move on; *don't* try
+ to use n to allocate. */
+ if (n > (int) strlen (*mangled))
+ {
+ success = 1;
+ break;
+ }
+ }
+ else
+ {
+ n = strcspn (*mangled, cplus_markers);
+ }
+ string_appendn (declp, *mangled, n);
+ (*mangled) += n;
+ }
+
+ p = strpbrk (*mangled, cplus_markers);
+ if (success && ((p == NULL) || (p == *mangled)))
+ {
+ if (p != NULL)
+ {
+ string_append (declp, SCOPE_STRING (work));
+ (*mangled)++;
+ }
+ }
+ else
+ {
+ success = 0;
+ break;
+ }
+ }
+ if (success)
+ string_append (declp, " virtual table");
+ }
+ else if ((*mangled)[0] == '_'
+ && (strchr("0123456789Qt", (*mangled)[1]) != NULL)
+ && (p = strpbrk (*mangled, cplus_markers)) != NULL)
+ {
+ /* static data member, "_3foo$varname" for example */
+ (*mangled)++;
+ switch (**mangled)
+ {
+ case 'Q':
+ case 'K':
+ success = demangle_qualified (work, mangled, declp, 0, 1);
+ break;
+ case 't':
+ success = demangle_template (work, mangled, declp, 0, 1, 1);
+ break;
+ default:
+ n = consume_count (mangled);
+ if (n < 0 || n > strlen (*mangled))
+ {
+ success = 0;
+ break;
+ }
+ string_appendn (declp, *mangled, n);
+ (*mangled) += n;
+ }
+ if (success && (p == *mangled))
+ {
+ /* Consumed everything up to the cplus_marker, append the
+ variable name. */
+ (*mangled)++;
+ string_append (declp, SCOPE_STRING (work));
+ n = strlen (*mangled);
+ string_appendn (declp, *mangled, n);
+ (*mangled) += n;
+ }
+ else
+ {
+ success = 0;
+ }
+ }
+ else if (strncmp (*mangled, "__thunk_", 8) == 0)
+ {
+ int delta;
+
+ (*mangled) += 8;
+ delta = consume_count (mangled);
+ if (delta == -1)
+ success = 0;
+ else
+ {
+ char *method = internal_cplus_demangle (work, ++*mangled);
+
+ if (method)
+ {
+ char buf[50];
+ sprintf (buf, "virtual function thunk (delta:%d) for ", -delta);
+ string_append (declp, buf);
+ string_append (declp, method);
+ free (method);
+ n = strlen (*mangled);
+ (*mangled) += n;
+ }
+ else
+ {
+ success = 0;
+ }
+ }
+ }
+ else if (strncmp (*mangled, "__t", 3) == 0
+ && ((*mangled)[3] == 'i' || (*mangled)[3] == 'f'))
+ {
+ p = (*mangled)[3] == 'i' ? " type_info node" : " type_info function";
+ (*mangled) += 4;
+ switch (**mangled)
+ {
+ case 'Q':
+ case 'K':
+ success = demangle_qualified (work, mangled, declp, 0, 1);
+ break;
+ case 't':
+ success = demangle_template (work, mangled, declp, 0, 1, 1);
+ break;
+ default:
+ success = demangle_fund_type (work, mangled, declp);
+ break;
+ }
+ if (success && **mangled != '\0')
+ success = 0;
+ if (success)
+ string_append (declp, p);
+ }
+ else
+ {
+ success = 0;
+ }
+ return (success);
+}
+
+static void
+recursively_demangle(work, mangled, result, namelength)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+ int namelength;
+{
+ char * recurse = (char *)NULL;
+ char * recurse_dem = (char *)NULL;
+
+ recurse = (char *) xmalloc (namelength + 1);
+ memcpy (recurse, *mangled, namelength);
+ recurse[namelength] = '\000';
+
+ recurse_dem = cplus_demangle (recurse, work->options);
+
+ if (recurse_dem)
+ {
+ string_append (result, recurse_dem);
+ free (recurse_dem);
+ }
+ else
+ {
+ string_appendn (result, *mangled, namelength);
+ }
+ free (recurse);
+ *mangled += namelength;
+}
+
+/*
+
+LOCAL FUNCTION
+
+ arm_special -- special handling of ARM/lucid mangled strings
+
+SYNOPSIS
+
+ static int
+ arm_special (const char **mangled,
+ string *declp);
+
+
+DESCRIPTION
+
+ Process some special ARM style mangling forms that don't fit
+ the normal pattern. For example:
+
+ __vtbl__3foo (foo virtual table)
+ __vtbl__3foo__3bar (bar::foo virtual table)
+
+ */
+
+static int
+arm_special (mangled, declp)
+ const char **mangled;
+ string *declp;
+{
+ int n;
+ int success = 1;
+ const char *scan;
+
+ if (strncmp (*mangled, ARM_VTABLE_STRING, ARM_VTABLE_STRLEN) == 0)
+ {
+ /* Found a ARM style virtual table, get past ARM_VTABLE_STRING
+ and create the decl. Note that we consume the entire mangled
+ input string, which means that demangle_signature has no work
+ to do. */
+ scan = *mangled + ARM_VTABLE_STRLEN;
+ while (*scan != '\0') /* first check it can be demangled */
+ {
+ n = consume_count (&scan);
+ if (n == -1)
+ {
+ return (0); /* no good */
+ }
+ scan += n;
+ if (scan[0] == '_' && scan[1] == '_')
+ {
+ scan += 2;
+ }
+ }
+ (*mangled) += ARM_VTABLE_STRLEN;
+ while (**mangled != '\0')
+ {
+ n = consume_count (mangled);
+ if (n == -1
+ || n > strlen (*mangled))
+ return 0;
+ string_prependn (declp, *mangled, n);
+ (*mangled) += n;
+ if ((*mangled)[0] == '_' && (*mangled)[1] == '_')
+ {
+ string_prepend (declp, "::");
+ (*mangled) += 2;
+ }
+ }
+ string_append (declp, " virtual table");
+ }
+ else
+ {
+ success = 0;
+ }
+ return (success);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ demangle_qualified -- demangle 'Q' qualified name strings
+
+SYNOPSIS
+
+ static int
+ demangle_qualified (struct work_stuff *, const char *mangled,
+ string *result, int isfuncname, int append);
+
+DESCRIPTION
+
+ Demangle a qualified name, such as "Q25Outer5Inner" which is
+ the mangled form of "Outer::Inner". The demangled output is
+ prepended or appended to the result string according to the
+ state of the append flag.
+
+ If isfuncname is nonzero, then the qualified name we are building
+ is going to be used as a member function name, so if it is a
+ constructor or destructor function, append an appropriate
+ constructor or destructor name. I.E. for the above example,
+ the result for use as a constructor is "Outer::Inner::Inner"
+ and the result for use as a destructor is "Outer::Inner::~Inner".
+
+BUGS
+
+ Numeric conversion is ASCII dependent (FIXME).
+
+ */
+
+static int
+demangle_qualified (work, mangled, result, isfuncname, append)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+ int isfuncname;
+ int append;
+{
+ int qualifiers = 0;
+ int success = 1;
+ const char *p;
+ char num[2];
+ string temp;
+ string last_name;
+ int bindex = register_Btype (work);
+
+ /* We only make use of ISFUNCNAME if the entity is a constructor or
+ destructor. */
+ isfuncname = (isfuncname
+ && ((work->constructor & 1) || (work->destructor & 1)));
+
+ string_init (&temp);
+ string_init (&last_name);
+
+ if ((*mangled)[0] == 'K')
+ {
+ /* Squangling qualified name reuse */
+ int idx;
+ (*mangled)++;
+ idx = consume_count_with_underscores (mangled);
+ if (idx == -1 || idx >= work -> numk)
+ success = 0;
+ else
+ string_append (&temp, work -> ktypevec[idx]);
+ }
+ else
+ switch ((*mangled)[1])
+ {
+ case '_':
+ /* GNU mangled name with more than 9 classes. The count is preceded
+ by an underscore (to distinguish it from the <= 9 case) and followed
+ by an underscore. */
+ p = *mangled + 2;
+ qualifiers = atoi (p);
+ if (!isdigit ((unsigned char)*p) || *p == '0')
+ success = 0;
+
+ /* Skip the digits. */
+ while (isdigit ((unsigned char)*p))
+ ++p;
+
+ if (*p != '_')
+ success = 0;
+
+ *mangled = p + 1;
+ break;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ /* The count is in a single digit. */
+ num[0] = (*mangled)[1];
+ num[1] = '\0';
+ qualifiers = atoi (num);
+
+ /* If there is an underscore after the digit, skip it. This is
+ said to be for ARM-qualified names, but the ARM makes no
+ mention of such an underscore. Perhaps cfront uses one. */
+ if ((*mangled)[2] == '_')
+ {
+ (*mangled)++;
+ }
+ (*mangled) += 2;
+ break;
+
+ case '0':
+ default:
+ success = 0;
+ }
+
+ if (!success)
+ return success;
+
+ /* Pick off the names and collect them in the temp buffer in the order
+ in which they are found, separated by '::'. */
+
+ while (qualifiers-- > 0)
+ {
+ int remember_K = 1;
+ string_clear (&last_name);
+
+ if (*mangled[0] == '_')
+ (*mangled)++;
+
+ if (*mangled[0] == 't')
+ {
+ /* Here we always append to TEMP since we will want to use
+ the template name without the template parameters as a
+ constructor or destructor name. The appropriate
+ (parameter-less) value is returned by demangle_template
+ in LAST_NAME. We do not remember the template type here,
+ in order to match the G++ mangling algorithm. */
+ success = demangle_template(work, mangled, &temp,
+ &last_name, 1, 0);
+ if (!success)
+ break;
+ }
+ else if (*mangled[0] == 'K')
+ {
+ int idx;
+ (*mangled)++;
+ idx = consume_count_with_underscores (mangled);
+ if (idx == -1 || idx >= work->numk)
+ success = 0;
+ else
+ string_append (&temp, work->ktypevec[idx]);
+ remember_K = 0;
+
+ if (!success) break;
+ }
+ else
+ {
+ if (EDG_DEMANGLING)
+ {
+ int namelength;
+ /* Now recursively demangle the qualifier
+ * This is necessary to deal with templates in
+ * mangling styles like EDG */
+ namelength = consume_count (mangled);
+ if (namelength == -1)
+ {
+ success = 0;
+ break;
+ }
+ recursively_demangle(work, mangled, &temp, namelength);
+ }
+ else
+ {
+ success = do_type (work, mangled, &last_name);
+ if (!success)
+ break;
+ string_appends (&temp, &last_name);
+ }
+ }
+
+ if (remember_K)
+ remember_Ktype (work, temp.b, LEN_STRING (&temp));
+
+ if (qualifiers > 0)
+ string_append (&temp, SCOPE_STRING (work));
+ }
+
+ remember_Btype (work, temp.b, LEN_STRING (&temp), bindex);
+
+ /* If we are using the result as a function name, we need to append
+ the appropriate '::' separated constructor or destructor name.
+ We do this here because this is the most convenient place, where
+ we already have a pointer to the name and the length of the name. */
+
+ if (isfuncname)
+ {
+ string_append (&temp, SCOPE_STRING (work));
+ if (work -> destructor & 1)
+ string_append (&temp, "~");
+ string_appends (&temp, &last_name);
+ }
+
+ /* Now either prepend the temp buffer to the result, or append it,
+ depending upon the state of the append flag. */
+
+ if (append)
+ string_appends (result, &temp);
+ else
+ {
+ if (!STRING_EMPTY (result))
+ string_append (&temp, SCOPE_STRING (work));
+ string_prepends (result, &temp);
+ }
+
+ string_delete (&last_name);
+ string_delete (&temp);
+ return (success);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ get_count -- convert an ascii count to integer, consuming tokens
+
+SYNOPSIS
+
+ static int
+ get_count (const char **type, int *count)
+
+DESCRIPTION
+
+ Assume that *type points at a count in a mangled name; set
+ *count to its value, and set *type to the next character after
+ the count. There are some weird rules in effect here.
+
+ If *type does not point at a string of digits, return zero.
+
+ If *type points at a string of digits followed by an
+ underscore, set *count to their value as an integer, advance
+ *type to point *after the underscore, and return 1.
+
+ If *type points at a string of digits not followed by an
+ underscore, consume only the first digit. Set *count to its
+ value as an integer, leave *type pointing after that digit,
+ and return 1.
+
+ The excuse for this odd behavior: in the ARM and HP demangling
+ styles, a type can be followed by a repeat count of the form
+ `Nxy', where:
+
+ `x' is a single digit specifying how many additional copies
+ of the type to append to the argument list, and
+
+ `y' is one or more digits, specifying the zero-based index of
+ the first repeated argument in the list. Yes, as you're
+ unmangling the name you can figure this out yourself, but
+ it's there anyway.
+
+ So, for example, in `bar__3fooFPiN51', the first argument is a
+ pointer to an integer (`Pi'), and then the next five arguments
+ are the same (`N5'), and the first repeat is the function's
+ second argument (`1').
+*/
+
+static int
+get_count (type, count)
+ const char **type;
+ int *count;
+{
+ const char *p;
+ int n;
+
+ if (!isdigit ((unsigned char)**type))
+ {
+ return (0);
+ }
+ else
+ {
+ *count = **type - '0';
+ (*type)++;
+ if (isdigit ((unsigned char)**type))
+ {
+ p = *type;
+ n = *count;
+ do
+ {
+ n *= 10;
+ n += *p - '0';
+ p++;
+ }
+ while (isdigit ((unsigned char)*p));
+ if (*p == '_')
+ {
+ *type = p + 1;
+ *count = n;
+ }
+ }
+ }
+ return (1);
+}
+
+/* RESULT will be initialised here; it will be freed on failure. The
+ value returned is really a type_kind_t. */
+
+static int
+do_type (work, mangled, result)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+{
+ int n;
+ int done;
+ int success;
+ string decl;
+ const char *remembered_type;
+ int type_quals;
+ string btype;
+ type_kind_t tk = tk_none;
+
+ string_init (&btype);
+ string_init (&decl);
+ string_init (result);
+
+ done = 0;
+ success = 1;
+ while (success && !done)
+ {
+ int member;
+ switch (**mangled)
+ {
+
+ /* A pointer type */
+ case 'P':
+ case 'p':
+ (*mangled)++;
+ if (! (work -> options & DMGL_JAVA))
+ string_prepend (&decl, "*");
+ if (tk == tk_none)
+ tk = tk_pointer;
+ break;
+
+ /* A reference type */
+ case 'R':
+ (*mangled)++;
+ string_prepend (&decl, "&");
+ if (tk == tk_none)
+ tk = tk_reference;
+ break;
+
+ /* An array */
+ case 'A':
+ {
+ ++(*mangled);
+ if (!STRING_EMPTY (&decl)
+ && (decl.b[0] == '*' || decl.b[0] == '&'))
+ {
+ string_prepend (&decl, "(");
+ string_append (&decl, ")");
+ }
+ string_append (&decl, "[");
+ if (**mangled != '_')
+ success = demangle_template_value_parm (work, mangled, &decl,
+ tk_integral);
+ if (**mangled == '_')
+ ++(*mangled);
+ string_append (&decl, "]");
+ break;
+ }
+
+ /* A back reference to a previously seen type */
+ case 'T':
+ (*mangled)++;
+ if (!get_count (mangled, &n) || n >= work -> ntypes)
+ {
+ success = 0;
+ }
+ else
+ {
+ remembered_type = work -> typevec[n];
+ mangled = &remembered_type;
+ }
+ break;
+
+ /* A function */
+ case 'F':
+ (*mangled)++;
+ if (!STRING_EMPTY (&decl)
+ && (decl.b[0] == '*' || decl.b[0] == '&'))
+ {
+ string_prepend (&decl, "(");
+ string_append (&decl, ")");
+ }
+ /* After picking off the function args, we expect to either find the
+ function return type (preceded by an '_') or the end of the
+ string. */
+ if (!demangle_nested_args (work, mangled, &decl)
+ || (**mangled != '_' && **mangled != '\0'))
+ {
+ success = 0;
+ break;
+ }
+ if (success && (**mangled == '_'))
+ (*mangled)++;
+ break;
+
+ case 'M':
+ case 'O':
+ {
+ type_quals = TYPE_UNQUALIFIED;
+
+ member = **mangled == 'M';
+ (*mangled)++;
+ if (!isdigit ((unsigned char)**mangled) && **mangled != 't')
+ {
+ success = 0;
+ break;
+ }
+
+ string_append (&decl, ")");
+ string_prepend (&decl, SCOPE_STRING (work));
+ if (isdigit ((unsigned char)**mangled))
+ {
+ n = consume_count (mangled);
+ if (n == -1
+ || (int) strlen (*mangled) < n)
+ {
+ success = 0;
+ break;
+ }
+ string_prependn (&decl, *mangled, n);
+ *mangled += n;
+ }
+ else
+ {
+ string temp;
+ string_init (&temp);
+ success = demangle_template (work, mangled, &temp,
+ NULL, 1, 1);
+ if (success)
+ {
+ string_prependn (&decl, temp.b, temp.p - temp.b);
+ string_clear (&temp);
+ }
+ else
+ break;
+ }
+ string_prepend (&decl, "(");
+ if (member)
+ {
+ switch (**mangled)
+ {
+ case 'C':
+ case 'V':
+ case 'u':
+ type_quals |= code_for_qualifier (**mangled);
+ (*mangled)++;
+ break;
+
+ default:
+ break;
+ }
+
+ if (*(*mangled)++ != 'F')
+ {
+ success = 0;
+ break;
+ }
+ }
+ if ((member && !demangle_nested_args (work, mangled, &decl))
+ || **mangled != '_')
+ {
+ success = 0;
+ break;
+ }
+ (*mangled)++;
+ if (! PRINT_ANSI_QUALIFIERS)
+ {
+ break;
+ }
+ if (type_quals != TYPE_UNQUALIFIED)
+ {
+ APPEND_BLANK (&decl);
+ string_append (&decl, qualifier_string (type_quals));
+ }
+ break;
+ }
+ case 'G':
+ (*mangled)++;
+ break;
+
+ case 'C':
+ case 'V':
+ case 'u':
+ if (PRINT_ANSI_QUALIFIERS)
+ {
+ if (!STRING_EMPTY (&decl))
+ string_prepend (&decl, " ");
+
+ string_prepend (&decl, demangle_qualifier (**mangled));
+ }
+ (*mangled)++;
+ break;
+ /*
+ }
+ */
+
+ /* fall through */
+ default:
+ done = 1;
+ break;
+ }
+ }
+
+ if (success) switch (**mangled)
+ {
+ /* A qualified name, such as "Outer::Inner". */
+ case 'Q':
+ case 'K':
+ {
+ success = demangle_qualified (work, mangled, result, 0, 1);
+ break;
+ }
+
+ /* A back reference to a previously seen squangled type */
+ case 'B':
+ (*mangled)++;
+ if (!get_count (mangled, &n) || n >= work -> numb)
+ success = 0;
+ else
+ string_append (result, work->btypevec[n]);
+ break;
+
+ case 'X':
+ case 'Y':
+ /* A template parm. We substitute the corresponding argument. */
+ {
+ int idx;
+
+ (*mangled)++;
+ idx = consume_count_with_underscores (mangled);
+
+ if (idx == -1
+ || (work->tmpl_argvec && idx >= work->ntmpl_args)
+ || consume_count_with_underscores (mangled) == -1)
+ {
+ success = 0;
+ break;
+ }
+
+ if (work->tmpl_argvec)
+ string_append (result, work->tmpl_argvec[idx]);
+ else
+ {
+ char buf[10];
+ sprintf(buf, "T%d", idx);
+ string_append (result, buf);
+ }
+
+ success = 1;
+ }
+ break;
+
+ default:
+ success = demangle_fund_type (work, mangled, result);
+ if (tk == tk_none)
+ tk = (type_kind_t) success;
+ break;
+ }
+
+ if (success)
+ {
+ if (!STRING_EMPTY (&decl))
+ {
+ string_append (result, " ");
+ string_appends (result, &decl);
+ }
+ }
+ else
+ string_delete (result);
+ string_delete (&decl);
+
+ if (success)
+ /* Assume an integral type, if we're not sure. */
+ return (int) ((tk == tk_none) ? tk_integral : tk);
+ else
+ return 0;
+}
+
+/* Given a pointer to a type string that represents a fundamental type
+ argument (int, long, unsigned int, etc) in TYPE, a pointer to the
+ string in which the demangled output is being built in RESULT, and
+ the WORK structure, decode the types and add them to the result.
+
+ For example:
+
+ "Ci" => "const int"
+ "Sl" => "signed long"
+ "CUs" => "const unsigned short"
+
+ The value returned is really a type_kind_t. */
+
+static int
+demangle_fund_type (work, mangled, result)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+{
+ int done = 0;
+ int success = 1;
+ char buf[10];
+ int dec = 0;
+ string btype;
+ type_kind_t tk = tk_integral;
+
+ string_init (&btype);
+
+ /* First pick off any type qualifiers. There can be more than one. */
+
+ while (!done)
+ {
+ switch (**mangled)
+ {
+ case 'C':
+ case 'V':
+ case 'u':
+ if (PRINT_ANSI_QUALIFIERS)
+ {
+ if (!STRING_EMPTY (result))
+ string_prepend (result, " ");
+ string_prepend (result, demangle_qualifier (**mangled));
+ }
+ (*mangled)++;
+ break;
+ case 'U':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "unsigned");
+ break;
+ case 'S': /* signed char only */
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "signed");
+ break;
+ case 'J':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "__complex");
+ break;
+ default:
+ done = 1;
+ break;
+ }
+ }
+
+ /* Now pick off the fundamental type. There can be only one. */
+
+ switch (**mangled)
+ {
+ case '\0':
+ case '_':
+ break;
+ case 'v':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "void");
+ break;
+ case 'x':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "long long");
+ break;
+ case 'l':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "long");
+ break;
+ case 'i':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "int");
+ break;
+ case 's':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "short");
+ break;
+ case 'b':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "bool");
+ tk = tk_bool;
+ break;
+ case 'c':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "char");
+ tk = tk_char;
+ break;
+ case 'w':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "wchar_t");
+ tk = tk_char;
+ break;
+ case 'r':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "long double");
+ tk = tk_real;
+ break;
+ case 'd':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "double");
+ tk = tk_real;
+ break;
+ case 'f':
+ (*mangled)++;
+ APPEND_BLANK (result);
+ string_append (result, "float");
+ tk = tk_real;
+ break;
+ case 'G':
+ (*mangled)++;
+ if (!isdigit ((unsigned char)**mangled))
+ {
+ success = 0;
+ break;
+ }
+ case 'I':
+ ++(*mangled);
+ if (**mangled == '_')
+ {
+ int i;
+ ++(*mangled);
+ for (i = 0;
+ (i < sizeof (buf) - 1 && **mangled && **mangled != '_');
+ ++(*mangled), ++i)
+ buf[i] = **mangled;
+ if (**mangled != '_')
+ {
+ success = 0;
+ break;
+ }
+ buf[i] = '\0';
+ ++(*mangled);
+ }
+ else
+ {
+ strncpy (buf, *mangled, 2);
+ buf[2] = '\0';
+ *mangled += 2;
+ }
+ sscanf (buf, "%x", &dec);
+ sprintf (buf, "int%i_t", dec);
+ APPEND_BLANK (result);
+ string_append (result, buf);
+ break;
+
+ /* fall through */
+ /* An explicit type, such as "6mytype" or "7integer" */
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ int bindex = register_Btype (work);
+ string btype;
+ string_init (&btype);
+ if (demangle_class_name (work, mangled, &btype)) {
+ remember_Btype (work, btype.b, LEN_STRING (&btype), bindex);
+ APPEND_BLANK (result);
+ string_appends (result, &btype);
+ }
+ else
+ success = 0;
+ string_delete (&btype);
+ break;
+ }
+ case 't':
+ {
+ success = demangle_template (work, mangled, &btype, 0, 1, 1);
+ string_appends (result, &btype);
+ break;
+ }
+ default:
+ success = 0;
+ break;
+ }
+
+ return success ? ((int) tk) : 0;
+}
+
+
+/* Handle a template's value parameter for HP aCC (extension from ARM)
+ **mangled points to 'S' or 'U' */
+
+static int
+do_hpacc_template_const_value (work, mangled, result)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+{
+ int unsigned_const;
+
+ if (**mangled != 'U' && **mangled != 'S')
+ return 0;
+
+ unsigned_const = (**mangled == 'U');
+
+ (*mangled)++;
+
+ switch (**mangled)
+ {
+ case 'N':
+ string_append (result, "-");
+ /* fall through */
+ case 'P':
+ (*mangled)++;
+ break;
+ case 'M':
+ /* special case for -2^31 */
+ string_append (result, "-2147483648");
+ (*mangled)++;
+ return 1;
+ default:
+ return 0;
+ }
+
+ /* We have to be looking at an integer now */
+ if (!(isdigit ((unsigned char)**mangled)))
+ return 0;
+
+ /* We only deal with integral values for template
+ parameters -- so it's OK to look only for digits */
+ while (isdigit ((unsigned char)**mangled))
+ {
+ char_str[0] = **mangled;
+ string_append (result, char_str);
+ (*mangled)++;
+ }
+
+ if (unsigned_const)
+ string_append (result, "U");
+
+ /* FIXME? Some day we may have 64-bit (or larger :-) ) constants
+ with L or LL suffixes. pai/1997-09-03 */
+
+ return 1; /* success */
+}
+
+/* Handle a template's literal parameter for HP aCC (extension from ARM)
+ **mangled is pointing to the 'A' */
+
+static int
+do_hpacc_template_literal (work, mangled, result)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+{
+ int literal_len = 0;
+ char * recurse;
+ char * recurse_dem;
+
+ if (**mangled != 'A')
+ return 0;
+
+ (*mangled)++;
+
+ literal_len = consume_count (mangled);
+
+ if (literal_len <= 0)
+ return 0;
+
+ /* Literal parameters are names of arrays, functions, etc. and the
+ canonical representation uses the address operator */
+ string_append (result, "&");
+
+ /* Now recursively demangle the literal name */
+ recurse = (char *) xmalloc (literal_len + 1);
+ memcpy (recurse, *mangled, literal_len);
+ recurse[literal_len] = '\000';
+
+ recurse_dem = cplus_demangle (recurse, work->options);
+
+ if (recurse_dem)
+ {
+ string_append (result, recurse_dem);
+ free (recurse_dem);
+ }
+ else
+ {
+ string_appendn (result, *mangled, literal_len);
+ }
+ (*mangled) += literal_len;
+ free (recurse);
+
+ return 1;
+}
+
+static int
+snarf_numeric_literal (args, arg)
+ const char ** args;
+ string * arg;
+{
+ if (**args == '-')
+ {
+ char_str[0] = '-';
+ string_append (arg, char_str);
+ (*args)++;
+ }
+ else if (**args == '+')
+ (*args)++;
+
+ if (!isdigit ((unsigned char)**args))
+ return 0;
+
+ while (isdigit ((unsigned char)**args))
+ {
+ char_str[0] = **args;
+ string_append (arg, char_str);
+ (*args)++;
+ }
+
+ return 1;
+}
+
+/* Demangle the next argument, given by MANGLED into RESULT, which
+ *should be an uninitialized* string. It will be initialized here,
+ and free'd should anything go wrong. */
+
+static int
+do_arg (work, mangled, result)
+ struct work_stuff *work;
+ const char **mangled;
+ string *result;
+{
+ /* Remember where we started so that we can record the type, for
+ non-squangling type remembering. */
+ const char *start = *mangled;
+
+ string_init (result);
+
+ if (work->nrepeats > 0)
+ {
+ --work->nrepeats;
+
+ if (work->previous_argument == 0)
+ return 0;
+
+ /* We want to reissue the previous type in this argument list. */
+ string_appends (result, work->previous_argument);
+ return 1;
+ }
+
+ if (**mangled == 'n')
+ {
+ /* A squangling-style repeat. */
+ (*mangled)++;
+ work->nrepeats = consume_count(mangled);
+
+ if (work->nrepeats <= 0)
+ /* This was not a repeat count after all. */
+ return 0;
+
+ if (work->nrepeats > 9)
+ {
+ if (**mangled != '_')
+ /* The repeat count should be followed by an '_' in this
+ case. */
+ return 0;
+ else
+ (*mangled)++;
+ }
+
+ /* Now, the repeat is all set up. */
+ return do_arg (work, mangled, result);
+ }
+
+ /* Save the result in WORK->previous_argument so that we can find it
+ if it's repeated. Note that saving START is not good enough: we
+ do not want to add additional types to the back-referenceable
+ type vector when processing a repeated type. */
+ if (work->previous_argument)
+ string_clear (work->previous_argument);
+ else
+ {
+ work->previous_argument = (string*) xmalloc (sizeof (string));
+ string_init (work->previous_argument);
+ }
+
+ if (!do_type (work, mangled, work->previous_argument))
+ return 0;
+
+ string_appends (result, work->previous_argument);
+
+ remember_type (work, start, *mangled - start);
+ return 1;
+}
+
+static void
+remember_type (work, start, len)
+ struct work_stuff *work;
+ const char *start;
+ int len;
+{
+ char *tem;
+
+ if (work->forgetting_types)
+ return;
+
+ if (work -> ntypes >= work -> typevec_size)
+ {
+ if (work -> typevec_size == 0)
+ {
+ work -> typevec_size = 3;
+ work -> typevec
+ = (char **) xmalloc (sizeof (char *) * work -> typevec_size);
+ }
+ else
+ {
+ work -> typevec_size *= 2;
+ work -> typevec
+ = (char **) xrealloc ((char *)work -> typevec,
+ sizeof (char *) * work -> typevec_size);
+ }
+ }
+ tem = xmalloc (len + 1);
+ memcpy (tem, start, len);
+ tem[len] = '\0';
+ work -> typevec[work -> ntypes++] = tem;
+}
+
+
+/* Remember a K type class qualifier. */
+static void
+remember_Ktype (work, start, len)
+ struct work_stuff *work;
+ const char *start;
+ int len;
+{
+ char *tem;
+
+ if (work -> numk >= work -> ksize)
+ {
+ if (work -> ksize == 0)
+ {
+ work -> ksize = 5;
+ work -> ktypevec
+ = (char **) xmalloc (sizeof (char *) * work -> ksize);
+ }
+ else
+ {
+ work -> ksize *= 2;
+ work -> ktypevec
+ = (char **) xrealloc ((char *)work -> ktypevec,
+ sizeof (char *) * work -> ksize);
+ }
+ }
+ tem = xmalloc (len + 1);
+ memcpy (tem, start, len);
+ tem[len] = '\0';
+ work -> ktypevec[work -> numk++] = tem;
+}
+
+/* Register a B code, and get an index for it. B codes are registered
+ as they are seen, rather than as they are completed, so map<temp<char> >
+ registers map<temp<char> > as B0, and temp<char> as B1 */
+
+static int
+register_Btype (work)
+ struct work_stuff *work;
+{
+ int ret;
+
+ if (work -> numb >= work -> bsize)
+ {
+ if (work -> bsize == 0)
+ {
+ work -> bsize = 5;
+ work -> btypevec
+ = (char **) xmalloc (sizeof (char *) * work -> bsize);
+ }
+ else
+ {
+ work -> bsize *= 2;
+ work -> btypevec
+ = (char **) xrealloc ((char *)work -> btypevec,
+ sizeof (char *) * work -> bsize);
+ }
+ }
+ ret = work -> numb++;
+ work -> btypevec[ret] = NULL;
+ return(ret);
+}
+
+/* Store a value into a previously registered B code type. */
+
+static void
+remember_Btype (work, start, len, index)
+ struct work_stuff *work;
+ const char *start;
+ int len, index;
+{
+ char *tem;
+
+ tem = xmalloc (len + 1);
+ memcpy (tem, start, len);
+ tem[len] = '\0';
+ work -> btypevec[index] = tem;
+}
+
+/* Lose all the info related to B and K type codes. */
+static void
+forget_B_and_K_types (work)
+ struct work_stuff *work;
+{
+ int i;
+
+ while (work -> numk > 0)
+ {
+ i = --(work -> numk);
+ if (work -> ktypevec[i] != NULL)
+ {
+ free (work -> ktypevec[i]);
+ work -> ktypevec[i] = NULL;
+ }
+ }
+
+ while (work -> numb > 0)
+ {
+ i = --(work -> numb);
+ if (work -> btypevec[i] != NULL)
+ {
+ free (work -> btypevec[i]);
+ work -> btypevec[i] = NULL;
+ }
+ }
+}
+/* Forget the remembered types, but not the type vector itself. */
+
+static void
+forget_types (work)
+ struct work_stuff *work;
+{
+ int i;
+
+ while (work -> ntypes > 0)
+ {
+ i = --(work -> ntypes);
+ if (work -> typevec[i] != NULL)
+ {
+ free (work -> typevec[i]);
+ work -> typevec[i] = NULL;
+ }
+ }
+}
+
+/* Process the argument list part of the signature, after any class spec
+ has been consumed, as well as the first 'F' character (if any). For
+ example:
+
+ "__als__3fooRT0" => process "RT0"
+ "complexfunc5__FPFPc_PFl_i" => process "PFPc_PFl_i"
+
+ DECLP must be already initialised, usually non-empty. It won't be freed
+ on failure.
+
+ Note that g++ differs significantly from ARM and lucid style mangling
+ with regards to references to previously seen types. For example, given
+ the source fragment:
+
+ class foo {
+ public:
+ foo::foo (int, foo &ia, int, foo &ib, int, foo &ic);
+ };
+
+ foo::foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; }
+ void foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; }
+
+ g++ produces the names:
+
+ __3fooiRT0iT2iT2
+ foo__FiR3fooiT1iT1
+
+ while lcc (and presumably other ARM style compilers as well) produces:
+
+ foo__FiR3fooT1T2T1T2
+ __ct__3fooFiR3fooT1T2T1T2
+
+ Note that g++ bases its type numbers starting at zero and counts all
+ previously seen types, while lucid/ARM bases its type numbers starting
+ at one and only considers types after it has seen the 'F' character
+ indicating the start of the function args. For lucid/ARM style, we
+ account for this difference by discarding any previously seen types when
+ we see the 'F' character, and subtracting one from the type number
+ reference.
+
+ */
+
+static int
+demangle_args (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ string arg;
+ int need_comma = 0;
+ int r;
+ int t;
+ const char *tem;
+ char temptype;
+
+ if (PRINT_ARG_TYPES)
+ {
+ string_append (declp, "(");
+ if (**mangled == '\0')
+ {
+ string_append (declp, "void");
+ }
+ }
+
+ while ((**mangled != '_' && **mangled != '\0' && **mangled != 'e')
+ || work->nrepeats > 0)
+ {
+ if ((**mangled == 'N') || (**mangled == 'T'))
+ {
+ temptype = *(*mangled)++;
+
+ if (temptype == 'N')
+ {
+ if (!get_count (mangled, &r))
+ {
+ return (0);
+ }
+ }
+ else
+ {
+ r = 1;
+ }
+ if ((HP_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) && work -> ntypes >= 10)
+ {
+ /* If we have 10 or more types we might have more than a 1 digit
+ index so we'll have to consume the whole count here. This
+ will lose if the next thing is a type name preceded by a
+ count but it's impossible to demangle that case properly
+ anyway. Eg if we already have 12 types is T12Pc "(..., type1,
+ Pc, ...)" or "(..., type12, char *, ...)" */
+ if ((t = consume_count(mangled)) <= 0)
+ {
+ return (0);
+ }
+ }
+ else
+ {
+ if (!get_count (mangled, &t))
+ {
+ return (0);
+ }
+ }
+ if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)
+ {
+ t--;
+ }
+ /* Validate the type index. Protect against illegal indices from
+ malformed type strings. */
+ if ((t < 0) || (t >= work -> ntypes))
+ {
+ return (0);
+ }
+ while (work->nrepeats > 0 || --r >= 0)
+ {
+ tem = work -> typevec[t];
+ if (need_comma && PRINT_ARG_TYPES)
+ {
+ string_append (declp, ", ");
+ }
+ if (!do_arg (work, &tem, &arg))
+ {
+ return (0);
+ }
+ if (PRINT_ARG_TYPES)
+ {
+ string_appends (declp, &arg);
+ }
+ string_delete (&arg);
+ need_comma = 1;
+ }
+ }
+ else
+ {
+ if (need_comma && PRINT_ARG_TYPES)
+ string_append (declp, ", ");
+ if (!do_arg (work, mangled, &arg))
+ return (0);
+ if (PRINT_ARG_TYPES)
+ string_appends (declp, &arg);
+ string_delete (&arg);
+ need_comma = 1;
+ }
+ }
+
+ if (**mangled == 'e')
+ {
+ (*mangled)++;
+ if (PRINT_ARG_TYPES)
+ {
+ if (need_comma)
+ {
+ string_append (declp, ",");
+ }
+ string_append (declp, "...");
+ }
+ }
+
+ if (PRINT_ARG_TYPES)
+ {
+ string_append (declp, ")");
+ }
+ return (1);
+}
+
+/* Like demangle_args, but for demangling the argument lists of function
+ and method pointers or references, not top-level declarations. */
+
+static int
+demangle_nested_args (work, mangled, declp)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+{
+ string* saved_previous_argument;
+ int result;
+ int saved_nrepeats;
+
+ /* The G++ name-mangling algorithm does not remember types on nested
+ argument lists, unless -fsquangling is used, and in that case the
+ type vector updated by remember_type is not used. So, we turn
+ off remembering of types here. */
+ ++work->forgetting_types;
+
+ /* For the repeat codes used with -fsquangling, we must keep track of
+ the last argument. */
+ saved_previous_argument = work->previous_argument;
+ saved_nrepeats = work->nrepeats;
+ work->previous_argument = 0;
+ work->nrepeats = 0;
+
+ /* Actually demangle the arguments. */
+ result = demangle_args (work, mangled, declp);
+
+ /* Restore the previous_argument field. */
+ if (work->previous_argument)
+ string_delete (work->previous_argument);
+ work->previous_argument = saved_previous_argument;
+ --work->forgetting_types;
+ work->nrepeats = saved_nrepeats;
+
+ return result;
+}
+
+static void
+demangle_function_name (work, mangled, declp, scan)
+ struct work_stuff *work;
+ const char **mangled;
+ string *declp;
+ const char *scan;
+{
+ size_t i;
+ string type;
+ const char *tem;
+
+ string_appendn (declp, (*mangled), scan - (*mangled));
+ string_need (declp, 1);
+ *(declp -> p) = '\0';
+
+ /* Consume the function name, including the "__" separating the name
+ from the signature. We are guaranteed that SCAN points to the
+ separator. */
+
+ (*mangled) = scan + 2;
+ /* We may be looking at an instantiation of a template function:
+ foo__Xt1t2_Ft3t4, where t1, t2, ... are template arguments and a
+ following _F marks the start of the function arguments. Handle
+ the template arguments first. */
+
+ if (HP_DEMANGLING && (**mangled == 'X'))
+ {
+ demangle_arm_hp_template (work, mangled, 0, declp);
+ /* This leaves MANGLED pointing to the 'F' marking func args */
+ }
+
+ if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)
+ {
+
+ /* See if we have an ARM style constructor or destructor operator.
+ If so, then just record it, clear the decl, and return.
+ We can't build the actual constructor/destructor decl until later,
+ when we recover the class name from the signature. */
+
+ if (strcmp (declp -> b, "__ct") == 0)
+ {
+ work -> constructor += 1;
+ string_clear (declp);
+ return;
+ }
+ else if (strcmp (declp -> b, "__dt") == 0)
+ {
+ work -> destructor += 1;
+ string_clear (declp);
+ return;
+ }
+ }
+
+ if (declp->p - declp->b >= 3
+ && declp->b[0] == 'o'
+ && declp->b[1] == 'p'
+ && strchr (cplus_markers, declp->b[2]) != NULL)
+ {
+ /* see if it's an assignment expression */
+ if (declp->p - declp->b >= 10 /* op$assign_ */
+ && memcmp (declp->b + 3, "assign_", 7) == 0)
+ {
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ int len = declp->p - declp->b - 10;
+ if ((int) strlen (optable[i].in) == len
+ && memcmp (optable[i].in, declp->b + 10, len) == 0)
+ {
+ string_clear (declp);
+ string_append (declp, "operator");
+ string_append (declp, optable[i].out);
+ string_append (declp, "=");
+ break;
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ int len = declp->p - declp->b - 3;
+ if ((int) strlen (optable[i].in) == len
+ && memcmp (optable[i].in, declp->b + 3, len) == 0)
+ {
+ string_clear (declp);
+ string_append (declp, "operator");
+ string_append (declp, optable[i].out);
+ break;
+ }
+ }
+ }
+ }
+ else if (declp->p - declp->b >= 5 && memcmp (declp->b, "type", 4) == 0
+ && strchr (cplus_markers, declp->b[4]) != NULL)
+ {
+ /* type conversion operator */
+ tem = declp->b + 5;
+ if (do_type (work, &tem, &type))
+ {
+ string_clear (declp);
+ string_append (declp, "operator ");
+ string_appends (declp, &type);
+ string_delete (&type);
+ }
+ }
+ else if (declp->b[0] == '_' && declp->b[1] == '_'
+ && declp->b[2] == 'o' && declp->b[3] == 'p')
+ {
+ /* ANSI. */
+ /* type conversion operator. */
+ tem = declp->b + 4;
+ if (do_type (work, &tem, &type))
+ {
+ string_clear (declp);
+ string_append (declp, "operator ");
+ string_appends (declp, &type);
+ string_delete (&type);
+ }
+ }
+ else if (declp->b[0] == '_' && declp->b[1] == '_'
+ && declp->b[2] >= 'a' && declp->b[2] <= 'z'
+ && declp->b[3] >= 'a' && declp->b[3] <= 'z')
+ {
+ if (declp->b[4] == '\0')
+ {
+ /* Operator. */
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ if (strlen (optable[i].in) == 2
+ && memcmp (optable[i].in, declp->b + 2, 2) == 0)
+ {
+ string_clear (declp);
+ string_append (declp, "operator");
+ string_append (declp, optable[i].out);
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (declp->b[2] == 'a' && declp->b[5] == '\0')
+ {
+ /* Assignment. */
+ for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
+ {
+ if (strlen (optable[i].in) == 3
+ && memcmp (optable[i].in, declp->b + 2, 3) == 0)
+ {
+ string_clear (declp);
+ string_append (declp, "operator");
+ string_append (declp, optable[i].out);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+/* a mini string-handling package */
+
+static void
+string_need (s, n)
+ string *s;
+ int n;
+{
+ int tem;
+
+ if (s->b == NULL)
+ {
+ if (n < 32)
+ {
+ n = 32;
+ }
+ s->p = s->b = xmalloc (n);
+ s->e = s->b + n;
+ }
+ else if (s->e - s->p < n)
+ {
+ tem = s->p - s->b;
+ n += tem;
+ n *= 2;
+ s->b = xrealloc (s->b, n);
+ s->p = s->b + tem;
+ s->e = s->b + n;
+ }
+}
+
+static void
+string_delete (s)
+ string *s;
+{
+ if (s->b != NULL)
+ {
+ free (s->b);
+ s->b = s->e = s->p = NULL;
+ }
+}
+
+static void
+string_init (s)
+ string *s;
+{
+ s->b = s->p = s->e = NULL;
+}
+
+static void
+string_clear (s)
+ string *s;
+{
+ s->p = s->b;
+}
+
+#if 0
+
+static int
+string_empty (s)
+ string *s;
+{
+ return (s->b == s->p);
+}
+
+#endif
+
+static void
+string_append (p, s)
+ string *p;
+ const char *s;
+{
+ int n;
+ if (s == NULL || *s == '\0')
+ return;
+ n = strlen (s);
+ string_need (p, n);
+ memcpy (p->p, s, n);
+ p->p += n;
+}
+
+static void
+string_appends (p, s)
+ string *p, *s;
+{
+ int n;
+
+ if (s->b != s->p)
+ {
+ n = s->p - s->b;
+ string_need (p, n);
+ memcpy (p->p, s->b, n);
+ p->p += n;
+ }
+}
+
+static void
+string_appendn (p, s, n)
+ string *p;
+ const char *s;
+ int n;
+{
+ if (n != 0)
+ {
+ string_need (p, n);
+ memcpy (p->p, s, n);
+ p->p += n;
+ }
+}
+
+static void
+string_prepend (p, s)
+ string *p;
+ const char *s;
+{
+ if (s != NULL && *s != '\0')
+ {
+ string_prependn (p, s, strlen (s));
+ }
+}
+
+static void
+string_prepends (p, s)
+ string *p, *s;
+{
+ if (s->b != s->p)
+ {
+ string_prependn (p, s->b, s->p - s->b);
+ }
+}
+
+static void
+string_prependn (p, s, n)
+ string *p;
+ const char *s;
+ int n;
+{
+ char *q;
+
+ if (n != 0)
+ {
+ string_need (p, n);
+ for (q = p->p - 1; q >= p->b; q--)
+ {
+ q[n] = q[0];
+ }
+ memcpy (p->b, s, n);
+ p->p += n;
+ }
+}
+
+/* To generate a standalone demangler program for testing purposes,
+ just compile and link this file with -DMAIN and libiberty.a. When
+ run, it demangles each command line arg, or each stdin string, and
+ prints the result on stdout. */
+
+#ifdef MAIN
+
+#include "getopt.h"
+
+static char *program_name;
+static char *program_version = VERSION;
+static int flags = DMGL_PARAMS | DMGL_ANSI;
+
+static void demangle_it PARAMS ((char *));
+static void usage PARAMS ((FILE *, int));
+static void fatal PARAMS ((char *));
+
+static void
+demangle_it (mangled_name)
+ char *mangled_name;
+{
+ char *result;
+
+ result = cplus_demangle (mangled_name, flags);
+ if (result == NULL)
+ {
+ printf ("%s\n", mangled_name);
+ }
+ else
+ {
+ printf ("%s\n", result);
+ free (result);
+ }
+}
+
+static void
+usage (stream, status)
+ FILE *stream;
+ int status;
+{
+ fprintf (stream, "\
+Usage: %s [-_] [-n] [-s {gnu,lucid,arm,hp,edg}] [--strip-underscores]\n\
+ [--no-strip-underscores] [--format={gnu,lucid,arm,hp,edg}]\n\
+ [--help] [--version] [arg...]\n",
+ program_name);
+ exit (status);
+}
+
+#define MBUF_SIZE 32767
+char mbuffer[MBUF_SIZE];
+
+/* Defined in the automatically-generated underscore.c. */
+extern int prepends_underscore;
+
+int strip_underscore = 0;
+
+static struct option long_options[] = {
+ {"strip-underscores", no_argument, 0, '_'},
+ {"format", required_argument, 0, 's'},
+ {"help", no_argument, 0, 'h'},
+ {"java", no_argument, 0, 'j'},
+ {"no-strip-underscores", no_argument, 0, 'n'},
+ {"version", no_argument, 0, 'v'},
+ {0, no_argument, 0, 0}
+};
+
+/* More 'friendly' abort that prints the line and file.
+ config.h can #define abort fancy_abort if you like that sort of thing. */
+
+void
+fancy_abort ()
+{
+ fatal ("Internal gcc abort.");
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *result;
+ int c;
+
+ program_name = argv[0];
+
+ strip_underscore = prepends_underscore;
+
+ while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF)
+ {
+ switch (c)
+ {
+ case '?':
+ usage (stderr, 1);
+ break;
+ case 'h':
+ usage (stdout, 0);
+ case 'n':
+ strip_underscore = 0;
+ break;
+ case 'v':
+ printf ("GNU %s (C++ demangler), version %s\n", program_name, program_version);
+ exit (0);
+ case '_':
+ strip_underscore = 1;
+ break;
+ case 'j':
+ flags |= DMGL_JAVA;
+ break;
+ case 's':
+ if (strcmp (optarg, "gnu") == 0)
+ {
+ current_demangling_style = gnu_demangling;
+ }
+ else if (strcmp (optarg, "lucid") == 0)
+ {
+ current_demangling_style = lucid_demangling;
+ }
+ else if (strcmp (optarg, "arm") == 0)
+ {
+ current_demangling_style = arm_demangling;
+ }
+ else if (strcmp (optarg, "hp") == 0)
+ {
+ current_demangling_style = hp_demangling;
+ }
+ else if (strcmp (optarg, "edg") == 0)
+ {
+ current_demangling_style = edg_demangling;
+ }
+ else
+ {
+ fprintf (stderr, "%s: unknown demangling style `%s'\n",
+ program_name, optarg);
+ exit (1);
+ }
+ break;
+ }
+ }
+
+ if (optind < argc)
+ {
+ for ( ; optind < argc; optind++)
+ {
+ demangle_it (argv[optind]);
+ }
+ }
+ else
+ {
+ for (;;)
+ {
+ int i = 0;
+ c = getchar ();
+ /* Try to read a label. */
+ while (c != EOF && (isalnum(c) || c == '_' || c == '$' || c == '.' ||
+ c == '<' || c == '>' || c == '#' || c == ',' || c == '*' || c == '&' ||
+ c == '[' || c == ']' || c == ':' || c == '(' || c == ')'))
+ /* the ones in the 2nd & 3rd lines were added to handle
+ HP aCC template specialization manglings */
+ {
+ if (i >= MBUF_SIZE-1)
+ break;
+ mbuffer[i++] = c;
+ c = getchar ();
+ }
+ if (i > 0)
+ {
+ int skip_first = 0;
+
+ if (mbuffer[0] == '.')
+ ++skip_first;
+ if (strip_underscore && mbuffer[skip_first] == '_')
+ ++skip_first;
+
+ if (skip_first > i)
+ skip_first = i;
+
+ mbuffer[i] = 0;
+
+ result = cplus_demangle (mbuffer + skip_first, flags);
+ if (result)
+ {
+ if (mbuffer[0] == '.')
+ putc ('.', stdout);
+ fputs (result, stdout);
+ free (result);
+ }
+ else
+ fputs (mbuffer, stdout);
+
+ fflush (stdout);
+ }
+ if (c == EOF)
+ break;
+ putchar (c);
+ }
+ }
+
+ exit (0);
+}
+
+static void
+fatal (str)
+ char *str;
+{
+ fprintf (stderr, "%s: %s\n", program_name, str);
+ exit (1);
+}
+
+PTR
+xmalloc (size)
+ size_t size;
+{
+ register PTR value = (PTR) malloc (size);
+ if (value == 0)
+ fatal ("virtual memory exhausted");
+ return value;
+}
+
+PTR
+xrealloc (ptr, size)
+ PTR ptr;
+ size_t size;
+{
+ register PTR value = (PTR) realloc (ptr, size);
+ if (value == 0)
+ fatal ("virtual memory exhausted");
+ return value;
+}
+#endif /* main */
diff --git a/libiberty/fdmatch.c b/libiberty/fdmatch.c
new file mode 100644
index 00000000000..7af039f5a2b
--- /dev/null
+++ b/libiberty/fdmatch.c
@@ -0,0 +1,73 @@
+/* Compare two open file descriptors to see if they refer to the same file.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/*
+
+NAME
+
+ fdmatch -- see if two file descriptors refer to same file
+
+SYNOPSIS
+
+ int fdmatch (int fd1, int fd2)
+
+DESCRIPTION
+
+ Check to see if two open file descriptors refer to the same file.
+ This is useful, for example, when we have an open file descriptor
+ for an unnamed file, and the name of a file that we believe to
+ correspond to that fd. This can happen when we are exec'd with
+ an already open file (stdout for example) or from the SVR4 /proc
+ calls that return open file descriptors for mapped address spaces.
+ All we have to do is open the file by name and check the two file
+ descriptors for a match, which is done by comparing major&minor
+ device numbers and inode numbers.
+
+BUGS
+
+ (FIXME: does this work for networks?)
+ It works for NFS, which assigns a device number to each mount.
+
+*/
+
+#include "ansidecl.h"
+#include "libiberty.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int fdmatch (fd1, fd2)
+ int fd1;
+ int fd2;
+{
+ struct stat sbuf1;
+ struct stat sbuf2;
+
+ if ((fstat (fd1, &sbuf1) == 0) &&
+ (fstat (fd2, &sbuf2) == 0) &&
+ (sbuf1.st_dev == sbuf2.st_dev) &&
+ (sbuf1.st_ino == sbuf2.st_ino))
+ {
+ return (1);
+ }
+ else
+ {
+ return (0);
+ }
+}
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
new file mode 100644
index 00000000000..c4f21e4ce89
--- /dev/null
+++ b/libiberty/floatformat.c
@@ -0,0 +1,403 @@
+/* IEEE floating point support routines, for GDB, the GNU Debugger.
+ Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "floatformat.h"
+#include <math.h> /* ldexp */
+#ifdef __STDC__
+#include <stddef.h>
+extern void *memcpy (void *s1, const void *s2, size_t n);
+extern void *memset (void *s, int c, size_t n);
+#else
+extern char *memcpy ();
+extern char *memset ();
+#endif
+
+/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
+ going to bother with trying to muck around with whether it is defined in
+ a system header, what we do if not, etc. */
+#define FLOATFORMAT_CHAR_BIT 8
+
+/* floatformats for IEEE single and double, big and little endian. */
+const struct floatformat floatformat_ieee_single_big =
+{
+ floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no
+};
+const struct floatformat floatformat_ieee_single_little =
+{
+ floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no
+};
+const struct floatformat floatformat_ieee_double_big =
+{
+ floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
+};
+const struct floatformat floatformat_ieee_double_little =
+{
+ floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
+};
+
+/* floatformat for IEEE double, little endian byte order, with big endian word
+ ordering, as on the ARM. */
+
+const struct floatformat floatformat_ieee_double_littlebyte_bigword =
+{
+ floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
+};
+
+const struct floatformat floatformat_i387_ext =
+{
+ floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
+ floatformat_intbit_yes
+};
+const struct floatformat floatformat_m68881_ext =
+{
+ /* Note that the bits from 16 to 31 are unused. */
+ floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes
+};
+const struct floatformat floatformat_i960_ext =
+{
+ /* Note that the bits from 0 to 15 are unused. */
+ floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes
+};
+const struct floatformat floatformat_m88110_ext =
+{
+#ifdef HARRIS_FLOAT_FORMAT
+ /* Harris uses raw format 128 bytes long, but the number is just an ieee
+ double, and the last 64 bits are wasted. */
+ floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
+ floatformat_intbit_no
+#else
+ floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
+ floatformat_intbit_yes
+#endif /* HARRIS_FLOAT_FORMAT */
+};
+const struct floatformat floatformat_arm_ext =
+{
+ /* Bits 1 to 16 are unused. */
+ floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes
+};
+
+static unsigned long get_field PARAMS ((unsigned char *,
+ enum floatformat_byteorders,
+ unsigned int,
+ unsigned int,
+ unsigned int));
+
+/* Extract a field which starts at START and is LEN bytes long. DATA and
+ TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
+static unsigned long
+get_field (data, order, total_len, start, len)
+ unsigned char *data;
+ enum floatformat_byteorders order;
+ unsigned int total_len;
+ unsigned int start;
+ unsigned int len;
+{
+ unsigned long result;
+ unsigned int cur_byte;
+ int cur_bitshift;
+
+ /* Start at the least significant part of the field. */
+ cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
+ if (order == floatformat_little)
+ cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
+ cur_bitshift =
+ ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
+ result = *(data + cur_byte) >> (-cur_bitshift);
+ cur_bitshift += FLOATFORMAT_CHAR_BIT;
+ if (order == floatformat_little)
+ ++cur_byte;
+ else
+ --cur_byte;
+
+ /* Move towards the most significant part of the field. */
+ while (cur_bitshift < len)
+ {
+ if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
+ /* This is the last byte; zero out the bits which are not part of
+ this field. */
+ result |=
+ (*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1))
+ << cur_bitshift;
+ else
+ result |= *(data + cur_byte) << cur_bitshift;
+ cur_bitshift += FLOATFORMAT_CHAR_BIT;
+ if (order == floatformat_little)
+ ++cur_byte;
+ else
+ --cur_byte;
+ }
+ return result;
+}
+
+#ifndef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+/* Convert from FMT to a double.
+ FROM is the address of the extended float.
+ Store the double in *TO. */
+
+void
+floatformat_to_double (fmt, from, to)
+ const struct floatformat *fmt;
+ char *from;
+ double *to;
+{
+ unsigned char *ufrom = (unsigned char *)from;
+ double dto;
+ long exponent;
+ unsigned long mant;
+ unsigned int mant_bits, mant_off;
+ int mant_bits_left;
+ int special_exponent; /* It's a NaN, denorm or zero */
+
+ exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ fmt->exp_start, fmt->exp_len);
+ /* Note that if exponent indicates a NaN, we can't really do anything useful
+ (not knowing if the host has NaN's, or how to build one). So it will
+ end up as an infinity or something close; that is OK. */
+
+ mant_bits_left = fmt->man_len;
+ mant_off = fmt->man_start;
+ dto = 0.0;
+
+ special_exponent = exponent == 0 || exponent == fmt->exp_nan;
+
+ /* Don't bias zero's, denorms or NaNs. */
+ if (!special_exponent)
+ exponent -= fmt->exp_bias;
+
+ /* Build the result algebraically. Might go infinite, underflow, etc;
+ who cares. */
+
+ /* If this format uses a hidden bit, explicitly add it in now. Otherwise,
+ increment the exponent by one to account for the integer bit. */
+
+ if (!special_exponent)
+ {
+ if (fmt->intbit == floatformat_intbit_no)
+ dto = ldexp (1.0, exponent);
+ else
+ exponent++;
+ }
+
+ while (mant_bits_left > 0)
+ {
+ mant_bits = min (mant_bits_left, 32);
+
+ mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits);
+
+ dto += ldexp ((double)mant, exponent - mant_bits);
+ exponent -= mant_bits;
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
+
+ /* Negate it if negative. */
+ if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
+ dto = -dto;
+ *to = dto;
+}
+
+static void put_field PARAMS ((unsigned char *, enum floatformat_byteorders,
+ unsigned int,
+ unsigned int,
+ unsigned int,
+ unsigned long));
+
+/* Set a field which starts at START and is LEN bytes long. DATA and
+ TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
+static void
+put_field (data, order, total_len, start, len, stuff_to_put)
+ unsigned char *data;
+ enum floatformat_byteorders order;
+ unsigned int total_len;
+ unsigned int start;
+ unsigned int len;
+ unsigned long stuff_to_put;
+{
+ unsigned int cur_byte;
+ int cur_bitshift;
+
+ /* Start at the least significant part of the field. */
+ cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
+ if (order == floatformat_little)
+ cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
+ cur_bitshift =
+ ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
+ *(data + cur_byte) &=
+ ~(((1 << ((start + len) % FLOATFORMAT_CHAR_BIT)) - 1) << (-cur_bitshift));
+ *(data + cur_byte) |=
+ (stuff_to_put & ((1 << FLOATFORMAT_CHAR_BIT) - 1)) << (-cur_bitshift);
+ cur_bitshift += FLOATFORMAT_CHAR_BIT;
+ if (order == floatformat_little)
+ ++cur_byte;
+ else
+ --cur_byte;
+
+ /* Move towards the most significant part of the field. */
+ while (cur_bitshift < len)
+ {
+ if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
+ {
+ /* This is the last byte. */
+ *(data + cur_byte) &=
+ ~((1 << (len - cur_bitshift)) - 1);
+ *(data + cur_byte) |= (stuff_to_put >> cur_bitshift);
+ }
+ else
+ *(data + cur_byte) = ((stuff_to_put >> cur_bitshift)
+ & ((1 << FLOATFORMAT_CHAR_BIT) - 1));
+ cur_bitshift += FLOATFORMAT_CHAR_BIT;
+ if (order == floatformat_little)
+ ++cur_byte;
+ else
+ --cur_byte;
+ }
+}
+
+/* The converse: convert the double *FROM to an extended float
+ and store where TO points. Neither FROM nor TO have any alignment
+ restrictions. */
+
+void
+floatformat_from_double (fmt, from, to)
+ const struct floatformat *fmt;
+ double *from;
+ char *to;
+{
+ double dfrom;
+ int exponent;
+ double mant;
+ unsigned int mant_bits, mant_off;
+ int mant_bits_left;
+ unsigned char *uto = (unsigned char *)to;
+
+ memcpy (&dfrom, from, sizeof (dfrom));
+ memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
+ if (dfrom == 0)
+ return; /* Result is zero */
+ if (dfrom != dfrom)
+ {
+ /* From is NaN */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, fmt->exp_nan);
+ /* Be sure it's not infinity, but NaN value is irrel */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
+ 32, 1);
+ return;
+ }
+
+ /* If negative, set the sign bit. */
+ if (dfrom < 0)
+ {
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
+ dfrom = -dfrom;
+ }
+
+ /* How to tell an infinity from an ordinary number? FIXME-someday */
+
+ mant = frexp (dfrom, &exponent);
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len,
+ exponent + fmt->exp_bias - 1);
+
+ mant_bits_left = fmt->man_len;
+ mant_off = fmt->man_start;
+ while (mant_bits_left > 0)
+ {
+ unsigned long mant_long;
+ mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
+
+ mant *= 4294967296.0;
+ mant_long = (unsigned long)mant;
+ mant -= mant_long;
+
+ /* If the integer bit is implicit, then we need to discard it.
+ If we are discarding a zero, we should be (but are not) creating
+ a denormalized number which means adjusting the exponent
+ (I think). */
+ if (mant_bits_left == fmt->man_len
+ && fmt->intbit == floatformat_intbit_no)
+ {
+ mant_long &= 0x7fffffff;
+ mant_bits -= 1;
+ }
+ else if (mant_bits < 32)
+ {
+ /* The bits we want are in the most significant MANT_BITS bits of
+ mant_long. Move them to the least significant. */
+ mant_long >>= 32 - mant_bits;
+ }
+
+ put_field (uto, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits, mant_long);
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
+}
+
+
+#ifdef IEEE_DEBUG
+
+/* This is to be run on a host which uses IEEE floating point. */
+
+void
+ieee_test (n)
+ double n;
+{
+ double result;
+ char exten[16];
+
+ floatformat_to_double (&floatformat_ieee_double_big, &n, &result);
+ if (n != result)
+ printf ("Differ(to): %.20g -> %.20g\n", n, result);
+ floatformat_from_double (&floatformat_ieee_double_big, &n, &result);
+ if (n != result)
+ printf ("Differ(from): %.20g -> %.20g\n", n, result);
+
+ floatformat_from_double (&floatformat_m68881_ext, &n, exten);
+ floatformat_to_double (&floatformat_m68881_ext, exten, &result);
+ if (n != result)
+ printf ("Differ(to+from): %.20g -> %.20g\n", n, result);
+
+#if IEEE_DEBUG > 1
+ /* This is to be run on a host which uses 68881 format. */
+ {
+ long double ex = *(long double *)exten;
+ if (ex != n)
+ printf ("Differ(from vs. extended): %.20g\n", n);
+ }
+#endif
+}
+
+int
+main ()
+{
+ ieee_test (0.5);
+ ieee_test (256.0);
+ ieee_test (0.12345);
+ ieee_test (234235.78907234);
+ ieee_test (-512.0);
+ ieee_test (-0.004321);
+ return 0;
+}
+#endif
diff --git a/libiberty/fnmatch.c b/libiberty/fnmatch.c
new file mode 100644
index 00000000000..0a9bfe6152b
--- /dev/null
+++ b/libiberty/fnmatch.c
@@ -0,0 +1,225 @@
+/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, 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, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because it found this file in $srcdir). */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+/* This code to undef const added in libiberty. */
+#ifndef __STDC__
+/* This is a separate conditional since some stdc systems
+ reject `defined (const)'. */
+#ifndef const
+#define const
+#endif
+#endif
+
+#include <errno.h>
+#include <fnmatch.h>
+#include <ctype.h>
+
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
+
+
+#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
+extern int errno;
+#endif
+
+/* Match STRING against the filename pattern PATTERN, returning zero if
+ it matches, nonzero if not. */
+int
+fnmatch (pattern, string, flags)
+ const char *pattern;
+ const char *string;
+ int flags;
+{
+ register const char *p = pattern, *n = string;
+ register unsigned char c;
+
+/* Note that this evalutes C many times. */
+#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
+
+ while ((c = *p++) != '\0')
+ {
+ c = FOLD (c);
+
+ switch (c)
+ {
+ case '?':
+ if (*n == '\0')
+ return FNM_NOMATCH;
+ else if ((flags & FNM_FILE_NAME) && *n == '/')
+ return FNM_NOMATCH;
+ else if ((flags & FNM_PERIOD) && *n == '.' &&
+ (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+ return FNM_NOMATCH;
+ break;
+
+ case '\\':
+ if (!(flags & FNM_NOESCAPE))
+ {
+ c = *p++;
+ c = FOLD (c);
+ }
+ if (FOLD ((unsigned char)*n) != c)
+ return FNM_NOMATCH;
+ break;
+
+ case '*':
+ if ((flags & FNM_PERIOD) && *n == '.' &&
+ (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+ return FNM_NOMATCH;
+
+ for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
+ if (((flags & FNM_FILE_NAME) && *n == '/') ||
+ (c == '?' && *n == '\0'))
+ return FNM_NOMATCH;
+
+ if (c == '\0')
+ return 0;
+
+ {
+ unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
+ c1 = FOLD (c1);
+ for (--p; *n != '\0'; ++n)
+ if ((c == '[' || FOLD ((unsigned char)*n) == c1) &&
+ fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
+ return 0;
+ return FNM_NOMATCH;
+ }
+
+ case '[':
+ {
+ /* Nonzero if the sense of the character class is inverted. */
+ register int not;
+
+ if (*n == '\0')
+ return FNM_NOMATCH;
+
+ if ((flags & FNM_PERIOD) && *n == '.' &&
+ (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+ return FNM_NOMATCH;
+
+ not = (*p == '!' || *p == '^');
+ if (not)
+ ++p;
+
+ c = *p++;
+ for (;;)
+ {
+ register unsigned char cstart = c, cend = c;
+
+ if (!(flags & FNM_NOESCAPE) && c == '\\')
+ cstart = cend = *p++;
+
+ cstart = cend = FOLD (cstart);
+
+ if (c == '\0')
+ /* [ (unterminated) loses. */
+ return FNM_NOMATCH;
+
+ c = *p++;
+ c = FOLD (c);
+
+ if ((flags & FNM_FILE_NAME) && c == '/')
+ /* [/] can never match. */
+ return FNM_NOMATCH;
+
+ if (c == '-' && *p != ']')
+ {
+ cend = *p++;
+ if (!(flags & FNM_NOESCAPE) && cend == '\\')
+ cend = *p++;
+ if (cend == '\0')
+ return FNM_NOMATCH;
+ cend = FOLD (cend);
+
+ c = *p++;
+ }
+
+ if (FOLD ((unsigned char)*n) >= cstart
+ && FOLD ((unsigned char)*n) <= cend)
+ goto matched;
+
+ if (c == ']')
+ break;
+ }
+ if (!not)
+ return FNM_NOMATCH;
+ break;
+
+ matched:;
+ /* Skip the rest of the [...] that already matched. */
+ while (c != ']')
+ {
+ if (c == '\0')
+ /* [... (unterminated) loses. */
+ return FNM_NOMATCH;
+
+ c = *p++;
+ if (!(flags & FNM_NOESCAPE) && c == '\\')
+ /* XXX 1003.2d11 is unclear if this is right. */
+ ++p;
+ }
+ if (not)
+ return FNM_NOMATCH;
+ }
+ break;
+
+ default:
+ if (c != FOLD ((unsigned char)*n))
+ return FNM_NOMATCH;
+ }
+
+ ++n;
+ }
+
+ if (*n == '\0')
+ return 0;
+
+ if ((flags & FNM_LEADING_DIR) && *n == '/')
+ /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
+ return 0;
+
+ return FNM_NOMATCH;
+}
+
+#endif /* _LIBC or not __GNU_LIBRARY__. */
diff --git a/libiberty/getcwd.c b/libiberty/getcwd.c
new file mode 100644
index 00000000000..06d55c04f58
--- /dev/null
+++ b/libiberty/getcwd.c
@@ -0,0 +1,54 @@
+/* Emulate getcwd using getwd.
+ This function is in the public domain. */
+
+/*
+NAME
+ getcwd -- get absolute pathname for current working directory
+
+SYNOPSIS
+ char *getcwd (char pathname[len], len)
+
+DESCRIPTION
+ Copy the absolute pathname for the current working directory into
+ the supplied buffer and return a pointer to the buffer. If the
+ current directory's path doesn't fit in LEN characters, the result
+ is NULL and errno is set.
+
+BUGS
+ Emulated via the getwd() call, which is reasonable for most
+ systems that do not have getcwd().
+
+*/
+
+#include "config.h"
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <errno.h>
+
+extern char *getwd ();
+extern int errno;
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+char *
+getcwd (buf, len)
+ char *buf;
+ int len;
+{
+ char ourbuf[MAXPATHLEN];
+ char *result;
+
+ result = getwd (ourbuf);
+ if (result) {
+ if (strlen (ourbuf) >= len) {
+ errno = ERANGE;
+ return 0;
+ }
+ strcpy (buf, ourbuf);
+ }
+ return buf;
+}
diff --git a/libiberty/getopt.c b/libiberty/getopt.c
new file mode 100644
index 00000000000..c41531e667d
--- /dev/null
+++ b/libiberty/getopt.c
@@ -0,0 +1,1056 @@
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to drepper@gnu.org
+ before changing it!
+
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
+ Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
+ Ditto for AIX 3.2 and <stdlib.h>. */
+#ifndef _NO_PROTO
+# define _NO_PROTO
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if !defined __STDC__ || !__STDC__
+/* This is a separate conditional since some stdc systems
+ reject `defined (const)'. */
+# ifndef const
+# define const
+# endif
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+# define ELIDE_CODE
+# endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+/* Don't include stdlib.h for non-GNU C libraries because some of them
+ contain conflicting prototypes for getopt. */
+# include <stdlib.h>
+# include <unistd.h>
+#endif /* GNU C library. */
+
+#ifdef VMS
+# include <unixlib.h>
+# if HAVE_STRING_H - 0
+# include <string.h>
+# endif
+#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages.
+ When compiling libc, the _ macro is predefined. */
+# ifdef HAVE_LIBINTL_H
+# include <libintl.h>
+# define _(msgid) gettext (msgid)
+# else
+# define _(msgid) (msgid)
+# endif
+#endif
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+ but it behaves differently for the user, since it allows the user
+ to intersperse the options with the other arguments.
+
+ As `getopt' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Setting the environment variable POSIXLY_CORRECT disables permutation.
+ Then the behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg = NULL;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Formerly, initialization of getopt depended on optind==0, which
+ causes problems with re-calling getopt as programs generally don't
+ know that. */
+
+int __getopt_initialized = 0;
+
+/* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+static char *nextchar;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we scan,
+ so that eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written to
+ expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were written
+ to expect options and other ARGV-elements in any order and that care about
+ the ordering of the two. We describe each non-option ARGV-element
+ as if it were the argument of an option with character code 1.
+ Using `-' as the first character of the list of option characters
+ selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
+
+static enum
+{
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+} ordering;
+
+/* Value of POSIXLY_CORRECT environment variable. */
+static char *posixly_correct;
+
+#ifdef __GNU_LIBRARY__
+/* We want to avoid inclusion of string.h with non-GNU libraries
+ because there are many ways it can cause trouble.
+ On some systems, it contains special magic macros that don't work
+ in GCC. */
+# include <string.h>
+# define my_index strchr
+#else
+
+# if HAVE_STRING_H
+# include <string.h>
+# else
+# if HAVE_STRINGS_H
+# include <strings.h>
+# endif
+# endif
+
+/* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+#ifndef getenv
+extern char *getenv ();
+#endif
+
+static char *
+my_index (str, chr)
+ const char *str;
+ int chr;
+{
+ while (*str)
+ {
+ if (*str == chr)
+ return (char *) str;
+ str++;
+ }
+ return 0;
+}
+
+/* If using GCC, we can safely declare strlen this way.
+ If not using GCC, it is ok not to declare it. */
+#ifdef __GNUC__
+/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
+ That was relevant to code that was here before. */
+# if (!defined __STDC__ || !__STDC__) && !defined strlen
+/* gcc with -traditional declares the built-in strlen to return int,
+ and has done so at least since version 2.4.5. -- rms. */
+extern int strlen (const char *);
+# endif /* not __STDC__ */
+#endif /* __GNUC__ */
+
+#endif /* not __GNU_LIBRARY__ */
+
+/* Handle permutation of arguments. */
+
+/* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+static int first_nonopt;
+static int last_nonopt;
+
+#ifdef _LIBC
+/* Bash 2.0 gives us an environment variable containing flags
+ indicating ARGV elements that should not be considered arguments. */
+
+/* Defined in getopt_init.c */
+extern char *__getopt_nonoption_flags;
+
+static int nonoption_flags_max_len;
+static int nonoption_flags_len;
+
+static int original_argc;
+static char *const *original_argv;
+
+/* Make sure the environment variable bash 2.0 puts in the environment
+ is valid for the getopt call we must make sure that the ARGV passed
+ to getopt is that one passed to the process. */
+static void
+__attribute__ ((unused))
+store_args_and_env (int argc, char *const *argv)
+{
+ /* XXX This is no good solution. We should rather copy the args so
+ that we can compare them later. But we must not use malloc(3). */
+ original_argc = argc;
+ original_argv = argv;
+}
+# ifdef text_set_element
+text_set_element (__libc_subinit, store_args_and_env);
+# endif /* text_set_element */
+
+# define SWAP_FLAGS(ch1, ch2) \
+ if (nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
+ }
+#else /* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif /* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+#if defined __STDC__ && __STDC__
+static void exchange (char **);
+#endif
+
+static void
+exchange (argv)
+ char **argv;
+{
+ int bottom = first_nonopt;
+ int middle = last_nonopt;
+ int top = optind;
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+#ifdef _LIBC
+ /* First make sure the handling of the `__getopt_nonoption_flags'
+ string can work normally. Our top argument must be in the range
+ of the string. */
+ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+ {
+ /* We must extend the array. The user plays games with us and
+ presents new arguments. */
+ char *new_str = malloc (top + 1);
+ if (new_str == NULL)
+ nonoption_flags_len = nonoption_flags_max_len = 0;
+ else
+ {
+ memset (__mempcpy (new_str, __getopt_nonoption_flags,
+ nonoption_flags_max_len),
+ '\0', top + 1 - nonoption_flags_max_len);
+ nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
+ }
+#endif
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ first_nonopt += (optind - last_nonopt);
+ last_nonopt = optind;
+}
+
+/* Initialize the internal data when the first call is made. */
+
+#if defined __STDC__ && __STDC__
+static const char *_getopt_initialize (int, char *const *, const char *);
+#endif
+static const char *
+_getopt_initialize (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ first_nonopt = last_nonopt = optind;
+
+ nextchar = NULL;
+
+ posixly_correct = getenv ("POSIXLY_CORRECT");
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (posixly_correct != NULL)
+ ordering = REQUIRE_ORDER;
+ else
+ ordering = PERMUTE;
+
+#ifdef _LIBC
+ if (posixly_correct == NULL
+ && argc == original_argc && argv == original_argv)
+ {
+ if (nonoption_flags_max_len == 0)
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = nonoption_flags_max_len = strlen (orig_str);
+ if (nonoption_flags_max_len < argc)
+ nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ nonoption_flags_max_len = -1;
+ else
+ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+ '\0', nonoption_flags_max_len - len);
+ }
+ }
+ nonoption_flags_len = nonoption_flags_max_len;
+ }
+ else
+ nonoption_flags_len = 0;
+#endif
+
+ return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns -1.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in `optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in `optarg', otherwise `optarg' is set to zero.
+
+ If OPTSTRING starts with `-' or `+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with `--' instead of `-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a `=', or else the in next ARGV-element.
+ When `getopt' finds a long-named option, it returns 0 if that option's
+ `flag' field is nonzero, the value of the option's `val' field
+ if the `flag' field is zero.
+
+ The elements of ARGV aren't really const, because we permute them.
+ But we pretend they're const in the prototype to be compatible
+ with other systems.
+
+ LONGOPTS is a vector of `struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options. */
+
+int
+_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+ const struct option *longopts;
+ int *longind;
+ int long_only;
+{
+ optarg = NULL;
+
+ if (optind == 0 || !__getopt_initialized)
+ {
+ if (optind == 0)
+ optind = 1; /* Don't scan ARGV[0], the program name. */
+ optstring = _getopt_initialize (argc, argv, optstring);
+ __getopt_initialized = 1;
+ }
+
+ /* Test whether ARGV[optind] points to a non-option argument.
+ Either it does not have option syntax, or there is an environment flag
+ from the shell indicating it is not an option. The later information
+ is only used when the used in the GNU libc. */
+#ifdef _LIBC
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
+ || (optind < nonoption_flags_len \
+ && __getopt_nonoption_flags[optind] == '1'))
+#else
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
+#endif
+
+ if (nextchar == NULL || *nextchar == '\0')
+ {
+ /* Advance to the next ARGV-element. */
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (last_nonopt > optind)
+ last_nonopt = optind;
+ if (first_nonopt > optind)
+ first_nonopt = optind;
+
+ if (ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (last_nonopt != optind)
+ first_nonopt = optind;
+
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (optind < argc && NONOPTION_P)
+ optind++;
+ last_nonopt = optind;
+ }
+
+ /* The special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (optind != argc && !strcmp (argv[optind], "--"))
+ {
+ optind++;
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = optind;
+ last_nonopt = argc;
+
+ optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (first_nonopt != last_nonopt)
+ optind = first_nonopt;
+ return -1;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if (NONOPTION_P)
+ {
+ if (ordering == REQUIRE_ORDER)
+ return -1;
+ optarg = argv[optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Skip the initial punctuation. */
+
+ nextchar = (argv[optind] + 1
+ + (longopts != NULL && argv[optind][1] == '-'));
+ }
+
+ /* Decode the current option-ARGV-element. */
+
+ /* Check whether the ARGV-element is a long option.
+
+ If long_only and the ARGV-element has the form "-f", where f is
+ a valid short option, don't consider it an abbreviated form of
+ a long option that starts with f. Otherwise there would be no
+ way to give the -f short option.
+
+ On the other hand, if there's a long option "fubar" and
+ the ARGV-element is "-fu", do consider that an abbreviation of
+ the long option, just like "--fu", and not "-f" with arg "u".
+
+ This distinction seems to be the most useful approach. */
+
+ if (longopts != NULL
+ && (argv[optind][1] == '-'
+ || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar)
+ == (unsigned int) strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ optopt = 0;
+ return '?';
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ optind++;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ {
+ if (argv[optind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ _("%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ _("%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[optind - 1][0], pfound->name);
+
+ nextchar += strlen (nextchar);
+
+ optopt = pfound->val;
+ return '?';
+ }
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (!long_only || argv[optind][1] == '-'
+ || my_index (optstring, *nextchar) == NULL)
+ {
+ if (opterr)
+ {
+ if (argv[optind][1] == '-')
+ /* --option */
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+ else
+ /* +option or -option */
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[optind][0], nextchar);
+ }
+ nextchar = (char *) "";
+ optind++;
+ optopt = 0;
+ return '?';
+ }
+ }
+
+ /* Look at and handle the next short option-character. */
+
+ {
+ char c = *nextchar++;
+ char *temp = my_index (optstring, c);
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*nextchar == '\0')
+ ++optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (opterr)
+ {
+ if (posixly_correct)
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _("%s: illegal option -- %c\n"),
+ argv[0], c);
+ else
+ fprintf (stderr, _("%s: invalid option -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ return '?';
+ }
+ /* Convenience. Treat POSIX -W foo same as long option --foo */
+ if (temp[0] == 'W' && temp[1] == ';')
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
+
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+
+ /* optarg is now the argument, see if it's in the
+ table of longopts. */
+
+ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ return '?';
+ }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+
+ nextchar += strlen (nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ optind++;
+ }
+ else
+ optarg = NULL;
+ nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+ nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+getopt (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ return _getopt_internal (argc, argv, optstring,
+ (const struct option *) 0,
+ (int *) 0,
+ 0);
+}
+
+#endif /* Not ELIDE_CODE. */
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of `getopt'. */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/libiberty/getopt1.c b/libiberty/getopt1.c
new file mode 100644
index 00000000000..ff257374c33
--- /dev/null
+++ b/libiberty/getopt1.c
@@ -0,0 +1,190 @@
+/* getopt_long and getopt_long_only entry points for GNU getopt.
+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
+ Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "getopt.h"
+
+#if !defined __STDC__ || !__STDC__
+/* This is a separate conditional since some stdc systems
+ reject `defined (const)'. */
+#ifndef const
+#define const
+#endif
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+#include <gnu-versions.h>
+#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#define ELIDE_CODE
+#endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+#include <stdlib.h>
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+int
+getopt_long (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+ If an option that starts with '-' (not '--') doesn't match a long option,
+ but does match a short option, it is parsed as a short option
+ instead. */
+
+int
+getopt_long_only (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
+}
+
+
+#endif /* Not ELIDE_CODE. */
+
+#ifdef TEST
+
+#include <stdio.h>
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/libiberty/getpagesize.c b/libiberty/getpagesize.c
new file mode 100644
index 00000000000..564d6c02312
--- /dev/null
+++ b/libiberty/getpagesize.c
@@ -0,0 +1,96 @@
+/* Emulation of getpagesize() for systems that need it. */
+
+/*
+
+NAME
+
+ getpagesize -- return the number of bytes in page of memory
+
+SYNOPSIS
+
+ int getpagesize (void)
+
+DESCRIPTION
+
+ Returns the number of bytes in a page of memory. This is the
+ granularity of many of the system memory management routines.
+ No guarantee is made as to whether or not it is the same as the
+ basic memory management hardware page size.
+
+BUGS
+
+ Is intended as a reasonable replacement for systems where this
+ is not provided as a system call. The value of 4096 may or may
+ not be correct for the systems where it is returned as the default
+ value.
+
+*/
+
+#ifndef VMS
+
+#include "config.h"
+
+#include <sys/types.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#undef GNU_OUR_PAGESIZE
+#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
+#include <unistd.h>
+#ifdef _SC_PAGESIZE
+#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
+#endif
+#endif
+
+#ifndef GNU_OUR_PAGESIZE
+# ifdef PAGESIZE
+# define GNU_OUR_PAGESIZE PAGESIZE
+# else /* no PAGESIZE */
+# ifdef EXEC_PAGESIZE
+# define GNU_OUR_PAGESIZE EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define GNU_OUR_PAGESIZE (NBPG * CLSIZE)
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define GNU_OUR_PAGESIZE NBPC
+# else /* no NBPC */
+# define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */
+# endif /* NBPC */
+# endif /* NBPG */
+# endif /* EXEC_PAGESIZE */
+# endif /* PAGESIZE */
+#endif /* GNU_OUR_PAGESIZE */
+
+int
+getpagesize ()
+{
+ return (GNU_OUR_PAGESIZE);
+}
+
+#else /* VMS */
+
+#if 0 /* older distributions of gcc-vms are missing <syidef.h> */
+#include <syidef.h>
+#endif
+#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */
+#define SYI$_PAGE_SIZE 4452
+#endif
+extern unsigned long lib$getsyi(const unsigned short *,...);
+
+int getpagesize ()
+{
+ long pagsiz = 0L;
+ unsigned short itmcod = SYI$_PAGE_SIZE;
+
+ (void) lib$getsyi (&itmcod, (void *) &pagsiz);
+ if (pagsiz == 0L)
+ pagsiz = 512L; /* VAX default */
+ return (int) pagsiz;
+}
+
+#endif /* VMS */
diff --git a/libiberty/getruntime.c b/libiberty/getruntime.c
new file mode 100644
index 00000000000..6e70773bd94
--- /dev/null
+++ b/libiberty/getruntime.c
@@ -0,0 +1,90 @@
+/* Return time used so far, in microseconds.
+ Copyright (C) 1994, 1999 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+/* There are several ways to get elapsed execution time; unfortunately no
+ single way is available for all host systems, nor are there reliable
+ ways to find out which way is correct for a given host. */
+
+#include <time.h>
+
+#ifdef HAVE_GETRUSAGE
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+#ifdef HAVE_TIMES
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <sys/times.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/* This is a fallback; if wrong, it will likely make obviously wrong
+ results. */
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1
+#endif
+
+#ifdef _SC_CLK_TCK
+#define GNU_HZ sysconf(_SC_CLK_TCK)
+#else
+#ifdef HZ
+#define GNU_HZ HZ
+#else
+#ifdef CLOCKS_PER_SEC
+#define GNU_HZ CLOCKS_PER_SEC
+#endif
+#endif
+#endif
+
+long
+get_run_time ()
+{
+#ifdef HAVE_GETRUSAGE
+ struct rusage rusage;
+
+ getrusage (0, &rusage);
+ return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
+ + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
+#else /* ! HAVE_GETRUSAGE */
+#ifdef HAVE_TIMES
+ struct tms tms;
+
+ times (&tms);
+ return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ);
+#else /* ! HAVE_TIMES */
+ /* Fall back on clock and hope it's correctly implemented. */
+ const long clocks_per_sec = CLOCKS_PER_SEC;
+ if (clocks_per_sec <= 1000000)
+ return clock () * (1000000 / clocks_per_sec);
+ else
+ return clock () / clocks_per_sec;
+#endif /* HAVE_TIMES */
+#endif /* HAVE_GETRUSAGE */
+}
diff --git a/libiberty/hex.c b/libiberty/hex.c
new file mode 100644
index 00000000000..3a2eef03d4c
--- /dev/null
+++ b/libiberty/hex.c
@@ -0,0 +1,33 @@
+/* Hex character manipulation support.
+ Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "libiberty.h"
+
+char _hex_value[_hex_array_size];
+
+void hex_init ()
+{
+ int i;
+ for (i = 0; i < _hex_array_size; i++)
+ _hex_value[i] = _hex_bad;
+ for (i = 0; i < 10; i++)
+ _hex_value['0' + i] = i;
+ for (i = 0; i < 6; i++)
+ _hex_value['a' + i] = _hex_value['A' + i] = 10 + i;
+}
diff --git a/libiberty/index.c b/libiberty/index.c
new file mode 100644
index 00000000000..e5a00f54d94
--- /dev/null
+++ b/libiberty/index.c
@@ -0,0 +1,11 @@
+/* Stub implementation of (obsolete) index(). */
+
+extern char * strchr();
+
+char *
+index (s, c)
+ char *s;
+ int c;
+{
+ return strchr (s, c);
+}
diff --git a/libiberty/insque.c b/libiberty/insque.c
new file mode 100644
index 00000000000..775019f8fff
--- /dev/null
+++ b/libiberty/insque.c
@@ -0,0 +1,50 @@
+/* insque(3C) routines
+ This file is in the public domain. */
+
+/*
+NAME
+ insque, remque -- insert, remove an element from a queue
+
+SYNOPSIS
+ struct qelem {
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char q_data[];
+ };
+
+ void insque (struct qelem *elem, struct qelem *pred)
+
+ void remque (struct qelem *elem)
+
+DESCRIPTION
+ Routines to manipulate queues built from doubly linked lists.
+ The insque routine inserts ELEM in the queue immediately after
+ PRED. The remque routine removes ELEM from its containing queue.
+*/
+
+
+struct qelem {
+ struct qelem *q_forw;
+ struct qelem *q_back;
+};
+
+
+void
+insque (elem, pred)
+ struct qelem *elem;
+ struct qelem *pred;
+{
+ elem -> q_forw = pred -> q_forw;
+ pred -> q_forw -> q_back = elem;
+ elem -> q_back = pred;
+ pred -> q_forw = elem;
+}
+
+
+void
+remque (elem)
+ struct qelem *elem;
+{
+ elem -> q_forw -> q_back = elem -> q_back;
+ elem -> q_back -> q_forw = elem -> q_forw;
+}
diff --git a/libiberty/makefile.dos b/libiberty/makefile.dos
new file mode 100644
index 00000000000..7eba62c3395
--- /dev/null
+++ b/libiberty/makefile.dos
@@ -0,0 +1,29 @@
+CFLAGS=-O2
+
+OBJS = \
+ argv.o \
+ basename.o \
+ concat.o \
+ cplus-dem.o \
+ fdmatch.o \
+ floatformat.o \
+ getopt.o \
+ getopt1.o \
+ getruntime.o \
+ hex.o \
+ msdos.o \
+ obstack.o \
+ spaces.o \
+ strerror.o \
+ strsignal.o \
+ xatexit.o \
+ xexit.o \
+ xmalloc.o \
+ $E
+
+.c.o:
+ gcc -I../include $(CFLAGS) -c $<
+
+libiberty.a : $(OBJS)
+ -rm libiberty.a
+ ar rvs libiberty.a $(OBJS)
diff --git a/libiberty/makefile.vms b/libiberty/makefile.vms
new file mode 100644
index 00000000000..b61b51290da
--- /dev/null
+++ b/libiberty/makefile.vms
@@ -0,0 +1,33 @@
+#
+# Makefile for libiberty under openVMS/Alpha
+#
+# For use with gnu-make for vms
+#
+# Created by Klaus K"ampf, kkaempf@progis.de
+#
+#
+
+OBJS=bcopy.obj,bcmp.obj,getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\
+ getopt1.obj,cplus-dem.obj,strncasecmp.obj,strcasecmp.obj,strdup.obj,\
+ concat.obj,getruntime.obj,getpagesize.obj,alloca.obj,xstrerror.obj,\
+ xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj
+
+ifeq ($(CC),gcc)
+CFLAGS=/include=([],[-.include])
+else
+# assume dec c
+CFLAGS=/noopt/debug/include=([],[-.include])/define=("const=")/warnings=disable=(missingreturn,implicitfunc)
+endif
+
+libiberty.olb: config.h alloca-conf.h $(OBJS)
+ purge
+ lib/create libiberty *.obj
+
+config.h: config.h-vms
+ $(CP) $< $@
+
+clean:
+ $$ purge
+ $(RM) config.h;
+ $(RM) *.obj;
+ $(RM) libiberty.olb;
diff --git a/libiberty/memchr.c b/libiberty/memchr.c
new file mode 100644
index 00000000000..cce30039437
--- /dev/null
+++ b/libiberty/memchr.c
@@ -0,0 +1,60 @@
+/*
+FUNCTION
+ <<memchr>>---find character in memory
+
+INDEX
+ memchr
+
+ANSI_SYNOPSIS
+ #include <string.h>
+ void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
+
+TRAD_SYNOPSIS
+ #include <string.h>
+ void *memchr(<[src]>, <[c]>, <[length]>)
+ void *<[src]>;
+ void *<[c]>;
+ size_t <[length]>;
+
+DESCRIPTION
+ This function searches memory starting at <<*<[src]>>> for the
+ character <[c]>. The search only ends with the first
+ occurrence of <[c]>, or after <[length]> characters; in
+ particular, <<NULL>> does not terminate the search.
+
+RETURNS
+ If the character <[c]> is found within <[length]> characters
+ of <<*<[src]>>>, a pointer to the character is returned. If
+ <[c]> is not found, then <<NULL>> is returned.
+
+PORTABILITY
+<<memchr>> requires no supporting OS subroutines.
+
+QUICKREF
+ memchr ansi pure
+
+*/
+
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+PTR
+memchr (src_void, c, length)
+ register const PTR src_void;
+ int c;
+ size_t length;
+{
+ const unsigned char *src = (const unsigned char *)src_void;
+
+ while (--length >= 0)
+ {
+ if (*src == c)
+ return (PTR)src;
+ src++;
+ }
+ return NULL;
+}
diff --git a/libiberty/memcmp.c b/libiberty/memcmp.c
new file mode 100644
index 00000000000..127ae0c8019
--- /dev/null
+++ b/libiberty/memcmp.c
@@ -0,0 +1,38 @@
+/* memcmp -- compare two memory regions.
+ This function is in the public domain. */
+
+/*
+NAME
+ memcmp -- compare two memory regions
+
+SYNOPSIS
+ int memcmp (const void *from, const void *to, size_t count)
+
+DESCRIPTION
+ Compare two memory regions and return less than,
+ equal to, or greater than zero, according to lexicographical
+ ordering of the compared regions.
+*/
+
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+int
+DEFUN(memcmp, (str1, str2, count),
+ const PTR str1 AND const PTR str2 AND size_t count)
+{
+ register unsigned char *s1 = (unsigned char*)str1;
+ register unsigned char *s2 = (unsigned char*)str2;
+
+ while (count-- > 0)
+ {
+ if (*s1++ != *s2++)
+ return s1[-1] < s2[-1] ? -1 : 1;
+ }
+ return 0;
+}
+
diff --git a/libiberty/memcpy.c b/libiberty/memcpy.c
new file mode 100644
index 00000000000..707a9f57385
--- /dev/null
+++ b/libiberty/memcpy.c
@@ -0,0 +1,28 @@
+/* memcpy (the standard C function)
+ This function is in the public domain. */
+
+/*
+NAME
+ memcpy -- copy memory regions of arbitary length
+
+SYNOPSIS
+ void* memcpy (void *out, const void *in, size_t n);
+
+DESCRIPTION
+ Copy LENGTH bytes from memory region pointed to by IN to memory
+ region pointed to by OUT.
+*/
+
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+PTR
+DEFUN(memcpy, (out, in, length), PTR out AND const PTR in AND size_t length)
+{
+ bcopy(in, out, length);
+ return out;
+}
diff --git a/libiberty/memmove.c b/libiberty/memmove.c
new file mode 100644
index 00000000000..176c326ef2b
--- /dev/null
+++ b/libiberty/memmove.c
@@ -0,0 +1,18 @@
+/* Wrapper to implement ANSI C's memmove using BSD's bcopy. */
+/* This function is in the public domain. --Per Bothner. */
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+PTR
+memmove (s1, s2, n)
+ PTR s1;
+ const PTR s2;
+ size_t n;
+{
+ bcopy (s2, s1, n);
+ return s1;
+}
diff --git a/libiberty/memset.c b/libiberty/memset.c
new file mode 100644
index 00000000000..5f54831e83c
--- /dev/null
+++ b/libiberty/memset.c
@@ -0,0 +1,19 @@
+/* memset
+ This implementation is in the public domain. */
+
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+PTR
+DEFUN(memset, (dest, val, len),
+ PTR dest AND register int val AND register size_t len)
+{
+ register unsigned char *ptr = (unsigned char*)dest;
+ while (len-- > 0)
+ *ptr++ = val;
+ return dest;
+}
diff --git a/libiberty/mkstemps.c b/libiberty/mkstemps.c
new file mode 100644
index 00000000000..16c16a23263
--- /dev/null
+++ b/libiberty/mkstemps.c
@@ -0,0 +1,128 @@
+/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
+ This file is derived from mkstemp.c from the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include "ansidecl.h"
+
+/* We need to provide a type for gcc_uint64_t. */
+#ifdef __GNUC__
+typedef unsigned long long gcc_uint64_t;
+#else
+typedef unsigned long gcc_uint64_t;
+#endif
+
+#ifndef TMP_MAX
+#define TMP_MAX 16384
+#endif
+
+/* Generate a unique temporary file name from TEMPLATE.
+
+ TEMPLATE has the form:
+
+ <path>/ccXXXXXX<suffix>
+
+ SUFFIX_LEN tells us how long <suffix> is (it can be zero length).
+
+ The last six characters of TEMPLATE before <suffix> must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+
+ Returns a file descriptor open on the file for reading and writing. */
+int
+mkstemps (template, suffix_len)
+ char *template;
+ int suffix_len;
+{
+ static const char letters[]
+ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ static gcc_uint64_t value;
+#ifdef HAVE_GETTIMEOFDAY
+ struct timeval tv;
+#endif
+ char *XXXXXX;
+ size_t len;
+ int count;
+
+ len = strlen (template);
+
+ if ((int) len < 6 + suffix_len
+ || strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
+ {
+ return -1;
+ }
+
+ XXXXXX = &template[len - 6 - suffix_len];
+
+#ifdef HAVE_GETTIMEOFDAY
+ /* Get some more or less random data. */
+ gettimeofday (&tv, NULL);
+ value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
+#else
+ value += getpid ();
+#endif
+
+ for (count = 0; count < TMP_MAX; ++count)
+ {
+ gcc_uint64_t v = value;
+ int fd;
+
+ /* Fill in the random bits. */
+ XXXXXX[0] = letters[v % 62];
+ v /= 62;
+ XXXXXX[1] = letters[v % 62];
+ v /= 62;
+ XXXXXX[2] = letters[v % 62];
+ v /= 62;
+ XXXXXX[3] = letters[v % 62];
+ v /= 62;
+ XXXXXX[4] = letters[v % 62];
+ v /= 62;
+ XXXXXX[5] = letters[v % 62];
+
+ fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (fd >= 0)
+ /* The file does not exist. */
+ return fd;
+
+ /* This is a random value. It is only necessary that the next
+ TMP_MAX values generated by adding 7777 to VALUE are different
+ with (module 2^32). */
+ value += 7777;
+ }
+
+ /* We return the null string if we can't find a unique file name. */
+ template[0] = '\0';
+ return -1;
+}
diff --git a/libiberty/mpw-config.in b/libiberty/mpw-config.in
new file mode 100644
index 00000000000..2a21802148d
--- /dev/null
+++ b/libiberty/mpw-config.in
@@ -0,0 +1,7 @@
+# MPW configuration fragment for libiberty.
+
+Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
+
+MoveIfChange "{o}"config.new "{o}"config.h
+
+
diff --git a/libiberty/mpw-make.sed b/libiberty/mpw-make.sed
new file mode 100644
index 00000000000..6f2a5e77b2b
--- /dev/null
+++ b/libiberty/mpw-make.sed
@@ -0,0 +1,51 @@
+# Sed commands to finish translating libiberty's Unix makefile to MPW syntax.
+
+# Comment out a useless thing.
+/^\.always\./s/^/#/
+
+# Replace the auto-generated list with the list of what we know we need.
+s/`cat needed-list`/"{o}"alloca.c.o "{o}"bcopy.c.o "{o}"getpagesize.c.o "{o}"insque.c.o "{o}"mpw.c.o "{o}"strcasecmp.c.o "{o}"strdup.c.o "{o}"strncasecmp.c.o/
+
+# Paste in some desirable definitions.
+# The default rule here completely replaces the tricky stuff in the Unix
+# Makefile.in.
+/^###$/a\
+\
+HDEFINES = -d NEED_sys_siglist -d NEED_sys_errlist -d NEED_basename -d NEED_strcasecmp -d NEED_strncasecmp\
+INCLUDES = -i : -i {INCDIR}: -i {INCDIR}:mpw: -i ::extra-include: -i "{s}"\
+\
+.c.o \\Option-f .c\
+ {CC} @DASH_C_FLAG@ {DepDir}{Default}.c {LIBCFLAGS} {INCLUDES} {HDEFINES} @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o\
+
+# Remove dependency on needed-list, which we don't use.
+/DO_ALSO =/s/needed-list//
+
+/INCDIR=/s/"{srcdir}"{MULTISRCTOP}::/"{topsrcdir}"/
+
+# Whack out the COMPILE.c trickiness.
+/^COMPILE.c /,/^$/d
+
+# Remove the multido trickiness from the "all" target.
+/^all \\Option-f/,/^$/c\
+all \\Option-f {TARGETLIB}\
+
+
+# Remove the RULE1/RULE2 crud.
+/if \[/,/fi/d
+/^RULE1 =/,/RULE2 =/d
+/RULE2/s/RULE2/TARGETLIB/
+
+# Don't want fdmatch ever.
+s/ "{o}"fdmatch.c.o//
+
+# Fix paths to generated files.
+/config.h/s/"{s}"config.h/"{o}"config.h/
+
+# Whack out config rebuild rules.
+/^"{o}"config.h \\Option-f/,/^$/d
+
+
+
+
+
+
diff --git a/libiberty/mpw.c b/libiberty/mpw.c
new file mode 100644
index 00000000000..ca3ae412d25
--- /dev/null
+++ b/libiberty/mpw.c
@@ -0,0 +1,1010 @@
+/* MPW-Unix compatibility library.
+ Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This should only be compiled and linked under MPW. */
+
+#include "mpw.h"
+
+#include <stdlib.h>
+
+#ifndef USE_MW_HEADERS
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+#include <Types.h>
+#include <Files.h>
+
+#include <Timer.h>
+
+/* Initialize to 0 at first, then set to errno_max() later. */
+
+int sys_nerr = 0;
+
+/* Debug flag for pathname hacking. Set this to one and rebuild. */
+
+int DebugPI = -1;
+
+void
+mpwify_filename(char *unixname, char *macname)
+{
+ int i, j;
+
+ /* (should truncate 255 chars from end of name, not beginning) */
+ if (strlen (unixname) > 255)
+ {
+ fprintf (stderr, "Pathname \"%s\" is too long for Macs, truncating\n",
+ unixname);
+ }
+ j = 0;
+ /* If you're going to end up with one or more colons in the middle of a
+ path after an all-Unix relative path is translated, you must add a
+ colon on the front, so that the first component is not thought to be
+ a disk name. */
+ if (unixname[0] != '/' && ! strchr (unixname, ':') && strchr (unixname, '/'))
+ {
+ macname[j++] = ':';
+ }
+ for (i = 0; unixname[i] != '\0' && i < 255; ++i)
+ {
+ if (i == 0 && unixname[i] == '/')
+ {
+ if (strncmp (unixname, "/tmp/", 5) == 0)
+ {
+ /* A temporary name, make a more Mac-flavored tmpname. */
+ /* A better choice would be {Boot}Trash:foo, but
+ that would require being able to identify the
+ boot disk's and trashcan's name. Another option
+ would be to have an env var, so user can point it
+ at a ramdisk. */
+ macname[j++] = ':';
+ macname[j++] = 't';
+ macname[j++] = 'm';
+ macname[j++] = 'p';
+ macname[j++] = '_';
+ i += 4;
+ }
+ else
+ {
+ /* Don't copy the leading slash. */
+ }
+ }
+ else if (unixname[i] == ':' && unixname[i+1] == '/')
+ {
+ macname[j++] = ':';
+ i += 1;
+ }
+ else if (unixname[i] == '.' && unixname[i+1] == '/')
+ {
+ macname[j++] = ':';
+ i += 1;
+ }
+ else if (unixname[i] == '.' && unixname[i+1] == '.' && unixname[i+2] == '/')
+ {
+ macname[j++] = ':';
+ macname[j++] = ':';
+ i += 2;
+ }
+ else if (unixname[i] == '/')
+ {
+ macname[j++] = ':';
+ }
+ else
+ {
+ macname[j++] = unixname[i];
+ }
+ }
+ macname[j] = '\0';
+ /* Allow for getting the debug flag from an env var; quite useful. */
+ if (DebugPI < 0)
+ DebugPI = (*(getenv ("DEBUG_PATHNAMES")) == '1' ? 1 : 0);
+ if (DebugPI)
+ {
+ fprintf (stderr, "# Made \"%s\"\n", unixname);
+ fprintf (stderr, "# into \"%s\"\n", macname);
+ }
+}
+
+/* MPW-flavored basename finder. */
+
+char *
+mpw_basename (name)
+ char *name;
+{
+ char *base = name;
+
+ while (*name)
+ {
+ if (*name++ == ':')
+ {
+ base = name;
+ }
+ }
+ return base;
+}
+
+/* Mixed MPW/Unix basename finder. This can be led astray by
+ filenames with slashes in them and come up with a basename that
+ either corresponds to no file or (worse) to some other file, so
+ should only be tried if other methods of finding a file via a
+ basename have failed. */
+
+char *
+mpw_mixed_basename (name)
+ char *name;
+{
+ char *base = name;
+
+ while (*name)
+ {
+ if (*name == '/' || *name == ':')
+ {
+ base = name + 1;
+ }
+ ++name;
+ }
+ return base;
+}
+
+/* This function is fopen() modified to create files that are type TEXT
+ or 'BIN ', and always of type 'MPS '. */
+
+FILE *
+mpw_fopen (char *name, char *mode)
+{
+#undef fopen
+ int errnum;
+ FILE *fp;
+ char tmpname[256];
+
+ mpwify_filename (name, tmpname);
+ PROGRESS (1);
+ fp = fopen (tmpname, mode);
+ errnum = errno;
+
+ /* If writing, need to set type and creator usefully. */
+ if (strchr (mode, 'w'))
+ {
+ char *pname = (char *) malloc (strlen (tmpname) + 2);
+ OSErr e;
+ struct FInfo fi;
+
+ pname[0] = strlen (tmpname);
+ strcpy (pname+1, tmpname);
+
+ e = GetFInfo ((ConstStr255Param) pname, 0, &fi);
+ /* should do spiffier error handling */
+ if (e != 0)
+ fprintf(stderr, "GetFInfo returns %d\n", e);
+ if (strchr (mode, 'b'))
+ {
+ fi.fdType = (OSType) 'BIN ';
+ }
+ else
+ {
+ fi.fdType = (OSType) 'TEXT';
+ }
+ fi.fdCreator = (OSType) 'MPS ';
+ e = SetFInfo ((ConstStr255Param) pname, 0, &fi);
+ if (e != 0)
+ fprintf(stderr, "SetFInfo returns %d\n", e);
+ free (pname);
+ }
+ if (fp == NULL)
+ errno = errnum;
+ return fp;
+}
+
+/* This is a version of fseek() modified to fill the file with zeros
+ if seeking past the end of it. */
+
+#define ZEROBLKSIZE 4096
+
+char zeros[ZEROBLKSIZE];
+
+int
+mpw_fseek (FILE *fp, int offset, int whence)
+{
+#undef fseek
+ int cursize, numleft;
+
+ PROGRESS (1);
+ if (whence == SEEK_SET)
+ {
+ fseek (fp, 0, SEEK_END);
+ cursize = ftell (fp);
+ if (offset > cursize)
+ {
+ numleft = offset - cursize;
+ while (numleft > ZEROBLKSIZE)
+ {
+ /* This might fail, should check for that. */
+ PROGRESS (1);
+ fwrite (zeros, 1, ZEROBLKSIZE, fp);
+ numleft -= ZEROBLKSIZE;
+ }
+ PROGRESS (1);
+ fwrite (zeros, 1, numleft, fp);
+ fflush (fp);
+ }
+ }
+ return fseek (fp, offset, whence);
+}
+
+int
+mpw_fread (char *ptr, int size, int nitems, FILE *stream)
+{
+#undef fread
+ int rslt;
+
+ PROGRESS (1);
+ rslt = fread (ptr, size, nitems, stream);
+ PROGRESS (1);
+ return rslt;
+}
+
+int
+mpw_fwrite (char *ptr, int size, int nitems, FILE *stream)
+{
+#undef fwrite
+ int rslt;
+
+ PROGRESS (1);
+ rslt = fwrite (ptr, size, nitems, stream);
+ PROGRESS (1);
+ return rslt;
+}
+
+int
+link ()
+{
+ fprintf (stderr, "link not available!\n");
+ mpw_abort ();
+}
+
+int
+fork ()
+{
+ fprintf (stderr, "fork not available!\n");
+ mpw_abort ();
+}
+
+int
+vfork ()
+{
+ fprintf (stderr, "vfork not available!\n");
+ mpw_abort ();
+ return (-1);
+}
+
+int
+pipe (int *fd)
+{
+ fprintf (stderr, "pipe not available!\n");
+ mpw_abort ();
+ return (-1);
+}
+
+#ifndef USE_MW_HEADERS
+int
+execvp (char *file, char **argv)
+{
+ fprintf (stderr, "execvp not available!\n");
+ mpw_abort ();
+ return (-1);
+}
+
+int
+execv (char *path, char **argv)
+{
+ fprintf (stderr, "execv not available!\n");
+ mpw_abort ();
+ return (-1);
+}
+#endif
+
+int
+kill (int pid, int sig)
+{
+ fprintf (stderr, "kill not available!\n");
+ mpw_abort ();
+ return (-1);
+}
+
+int
+wait (int *status)
+{
+ *status = 0;
+ return 0;
+}
+
+#ifndef USE_MW_HEADERS
+int
+sleep (int seconds)
+{
+ unsigned long start_time, now;
+
+ time (&start_time);
+
+ while (1)
+ {
+ PROGRESS (1);
+ time (&now);
+ if (now > start_time + seconds)
+ return 0;
+ }
+}
+#endif
+
+void
+putenv (char *str)
+{
+ /* The GCC driver calls this to do things for collect2, but we
+ don't care about collect2. */
+}
+
+int
+chmod (char *path, int mode)
+{
+ /* Pretend it was all OK. */
+ return 0;
+}
+
+#ifndef USE_MW_HEADERS
+int
+getuid ()
+{
+ /* One value is as good as another... */
+ return 0;
+}
+
+int
+getgid ()
+{
+ /* One value is as good as another... */
+ return 0;
+}
+#endif
+
+/* Instead of coredumping, which is not a normal Mac facility, we
+ drop into Macsbug. If we then "g" from Macsbug, the program will
+ exit cleanly. */
+
+void
+mpw_abort ()
+{
+ /* Make sure no output still buffered up, then zap into MacsBug. */
+ fflush(stdout);
+ fflush(stderr);
+ printf("## Abort! ##\n");
+#ifdef MPW_SADE
+ SysError(8005);
+#else
+ Debugger();
+#endif
+ /* "g" in MacsBug will then cause a regular error exit. */
+ exit (1);
+}
+
+/* Imitation getrusage based on the ANSI clock() function. */
+
+int
+getrusage (int who, struct rusage *rusage)
+{
+ int clk = clock ();
+
+#if 0
+ rusage->ru_utime.tv_sec = clk / CLOCKS_PER_SEC;
+ rusage->ru_utime.tv_usec = ((clk * 1000) / CLOCKS_PER_SEC) * 1000;
+ rusage->ru_stime.tv_sec = 0;
+ rusage->ru_stime.tv_usec = 0;
+#endif
+}
+
+int
+sbrk ()
+{
+ return 0;
+}
+
+#ifndef USE_MW_HEADERS
+int
+isatty (int fd)
+{
+ return 0;
+}
+
+/* This is inherited from Timothy Murray's Posix library. */
+
+#include "utime.h"
+
+int
+utime (char *filename, struct utimbuf *times)
+{
+ CInfoPBRec cipbr;
+ HFileInfo *fpb = (HFileInfo *) &cipbr;
+ DirInfo *dpb = (DirInfo *) &cipbr;
+ unsigned char pname[256];
+ short err;
+
+ strcpy ((char *) pname, filename);
+ c2pstr (pname);
+
+ dpb->ioDrDirID = 0L;
+ fpb->ioNamePtr = pname;
+ fpb->ioVRefNum = 0;
+ fpb->ioFDirIndex = 0;
+ fpb->ioFVersNum = 0;
+ err = PBGetCatInfo (&cipbr, 0);
+ if (err != noErr) {
+ errno = ENOENT;
+ return -1;
+ }
+ dpb->ioDrDirID = 0L;
+ fpb->ioFlMdDat = times->modtime;
+ fpb->ioFlCrDat = times->actime;
+ err = PBSetCatInfo (&cipbr, 0);
+ if (err != noErr) {
+ errno = EACCES;
+ return -1;
+ }
+ return 0;
+}
+
+int
+mkdir (char *path, int mode)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+int
+rmdir ()
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+chown ()
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+char *myenviron[] = {NULL};
+
+char **environ = myenviron;
+
+#ifndef USE_MW_HEADERS
+
+/* Minimal 'stat' emulation: tells directories from files and
+ gives length and mtime.
+
+ Derived from code written by Guido van Rossum, CWI, Amsterdam
+ and placed by him in the public domain. */
+
+extern int __uid, __gid;
+
+int __uid = 0;
+int __gid = 0;
+
+/* Bits in ioFlAttrib: */
+#define LOCKBIT (1<<0) /* File locked */
+#define DIRBIT (1<<4) /* It's a directory */
+
+/* Macified "stat" in which filename is given relative to a directory,
+ specified by long DirID. */
+
+static int
+_stat (char *name, long dirid, struct stat *buf)
+{
+ CInfoPBRec cipbr;
+ HFileInfo *fpb = (HFileInfo*) &cipbr;
+ DirInfo *dpb = (DirInfo*) &cipbr;
+ Str255 pname;
+ short err;
+
+ /* Make a temp copy of the name and pascalize. */
+ strcpy ((char *) pname, name);
+ c2pstr (pname);
+
+ cipbr.dirInfo.ioDrDirID = dirid;
+ cipbr.hFileInfo.ioNamePtr = pname;
+ cipbr.hFileInfo.ioVRefNum = 0;
+ cipbr.hFileInfo.ioFDirIndex = 0;
+ cipbr.hFileInfo.ioFVersNum = 0;
+ err = PBGetCatInfo (&cipbr, 0);
+ if (err != noErr)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+ /* Mac files are readable if they can be accessed at all. */
+ buf->st_mode = 0444;
+ /* Mark unlocked files as writeable. */
+ if (!(fpb->ioFlAttrib & LOCKBIT))
+ buf->st_mode |= 0222;
+ if (fpb->ioFlAttrib & DIRBIT)
+ {
+ /* Mark directories as "executable". */
+ buf->st_mode |= 0111 | S_IFDIR;
+ buf->st_size = dpb->ioDrNmFls;
+ buf->st_rsize = 0;
+ }
+ else
+ {
+ buf->st_mode |= S_IFREG;
+ /* Mark apps as "executable". */
+ if (fpb->ioFlFndrInfo.fdType == 'APPL')
+ buf->st_mode |= 0111;
+ /* Fill in the sizes of data and resource forks. */
+ buf->st_size = fpb->ioFlLgLen;
+ buf->st_rsize = fpb->ioFlRLgLen;
+ }
+ /* Fill in various times. */
+ buf->st_atime = fpb->ioFlCrDat;
+ buf->st_mtime = fpb->ioFlMdDat;
+ buf->st_ctime = fpb->ioFlCrDat;
+ /* Set up an imitation inode number. */
+ buf->st_ino = (unsigned short) fpb->ioDirID;
+ /* Set up an imitation device. */
+ GetVRefNum (buf->st_ino, &buf->st_dev);
+ buf->st_uid = __uid;
+ buf->st_gid = __gid;
+/* buf->st_FlFndrInfo = fpb->ioFlFndrInfo; */
+ return 0;
+}
+
+/* stat() sets up an empty dirid. */
+
+int
+stat (char *path, struct stat *buf)
+{
+ long rslt, errnum;
+ char tmpname[256];
+
+ mpwify_filename (path, tmpname);
+ if (DebugPI)
+ fprintf (stderr, "# stat (%s, %x)", tmpname, buf);
+ PROGRESS (1);
+ rslt = _stat (tmpname, 0L, buf);
+ errnum = errno;
+ if (DebugPI)
+ {
+ fprintf (stderr, " -> %d", rslt);
+ if (rslt != 0)
+ fprintf (stderr, " (errno is %d)", errnum);
+ fprintf (stderr, "\n");
+ fflush (stderr);
+ }
+ if (rslt != 0)
+ errno = errnum;
+ return rslt;
+}
+
+int
+fstat (int fd, struct stat *buf)
+{
+ FCBPBRec fcb;
+ FILE *fp;
+ Str255 pathname;
+ long dirid = 0L, temp;
+ long rslt, errnum;
+ short err;
+
+ if (DebugPI < 0)
+ DebugPI = (*(getenv ("DEBUG_PATHNAMES")) == '1' ? 1 : 0);
+ if (DebugPI)
+ fprintf (stderr, "# fstat (%d, %x)", fd, buf);
+ PROGRESS (1);
+ pathname[0] = 0;
+#ifdef FIOFNAME
+ /* Use an MPW-specific ioctl to get the pathname associated with
+ the file descriptor. */
+ ioctl (fd, FIOFNAME, (long *) pathname);
+#else
+ you lose
+#endif
+ if (DebugPI)
+ fprintf (stderr, " (name is %s)", pathname);
+ dirid = 0L /* fcb.ioFCBParID */ ;
+ rslt = _stat ((char *) pathname, dirid, buf);
+ errnum = errno;
+ if (DebugPI)
+ {
+ fprintf (stderr, " -> %d", rslt);
+ if (rslt != 0)
+ fprintf (stderr, " (errno is %d)", errnum);
+ fprintf (stderr, "\n");
+ fflush (stderr);
+ }
+ if (rslt != 0)
+ errno = errnum;
+ return rslt;
+}
+
+#endif /* n USE_MW_HEADERS */
+
+chdir ()
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+char *
+getcwd (char *buf, int size)
+{
+ if (buf == NULL)
+ buf = (char *) malloc (size);
+ strcpy(buf, ":");
+ return buf;
+}
+
+/* This should probably be more elaborate for MPW. */
+
+char *
+getpwd ()
+{
+ return ":";
+}
+
+int
+mpw_open (char *filename, int arg2, int arg3)
+{
+#undef open
+ int fd, errnum = 0;
+ char tmpname[256];
+
+ mpwify_filename (filename, tmpname);
+ fd = open (tmpname, arg2);
+ errnum = errno;
+
+ if (DebugPI)
+ {
+ fprintf (stderr, "# open (%s, %d, %d)", tmpname, arg2, arg3);
+ fprintf (stderr, " -> %d", fd);
+ if (fd == -1)
+ fprintf (stderr, " (errno is %d)", errnum);
+ fprintf (stderr, "\n");
+ }
+ if (fd == -1)
+ errno = errnum;
+ return fd;
+}
+
+int
+mpw_access (char *filename, unsigned int cmd)
+{
+#undef access
+
+ int rslt, errnum = 0;
+ struct stat st;
+ char tmpname[256];
+
+ mpwify_filename (filename, tmpname);
+ if (cmd & R_OK || cmd & X_OK)
+ {
+ rslt = stat (tmpname, &st);
+ errnum = errno;
+ if (rslt >= 0)
+ {
+ if ((((st.st_mode & 004) == 0) && (cmd & R_OK))
+ || (((st.st_mode & 002) == 0) && (cmd & W_OK))
+ || (((st.st_mode & 001) == 0) && (cmd & X_OK)))
+ {
+ rslt = -1;
+ errnum = EACCES;
+ }
+ }
+ }
+ if (DebugPI)
+ {
+ fprintf (stderr, "# mpw_access (%s, %d)", tmpname, cmd);
+ fprintf (stderr, " -> %d", rslt);
+ if (rslt != 0)
+ fprintf (stderr, " (errno is %d)", errnum);
+ fprintf (stderr, "\n");
+ }
+ if (rslt != 0)
+ errno = errnum;
+ return rslt;
+}
+
+/* The MPW library creat() has no mode argument. */
+
+int
+mpw_creat (char *path, /* mode_t */ int mode)
+{
+#undef creat
+
+#ifdef USE_MW_HEADERS
+ return creat (path, mode);
+#else
+ return creat (path);
+#endif
+}
+
+/* This is a hack to get control in an MPW tool before it crashes the
+ machine. */
+
+mpw_special_init (name)
+ char *name;
+{
+ if (strstr (name, "DEBUG"))
+ DebugStr("\pat beginning of program");
+}
+
+static int current_umask;
+
+int
+umask(int mask)
+{
+ int oldmask = current_umask;
+
+ current_umask = mask;
+ return oldmask;
+}
+
+/* Cursor-spinning stuff that includes metering of spin rate and delays. */
+
+/* Nonzero when cursor spinning has been set up properly. */
+
+int cursor_inited;
+
+/* Nonzero if spin should be measured and excessive delays reported. */
+
+int measure_spin;
+
+/* Nonzero if spin histogram and rate data should be written out. */
+
+int dump_spin_data;
+
+long warning_threshold = 400000;
+
+long bucket_size = 1024;
+
+long bucket_power = 10;
+
+long numbuckets = 300;
+
+int *delay_counts;
+
+int overflow_count;
+
+char *current_progress;
+
+static UnsignedWide last_microseconds;
+
+static char *last_spin_file = "";
+
+static int last_spin_line;
+
+void
+warn_if_spin_delay (char *file, int line)
+{
+ long diff, ix;
+ UnsignedWide now;
+
+ Microseconds(&now);
+
+ diff = now.lo - last_microseconds.lo;
+
+ if (diff > warning_threshold)
+ fprintf (stderr, "# %s: %ld.%06ld sec delay getting from %s:%d to %s:%d\n",
+ (current_progress ? current_progress : ""),
+ diff / 1000000, diff % 1000000,
+ last_spin_file, last_spin_line, file, line);
+ if (dump_spin_data)
+ {
+ if (diff >= 0)
+ {
+ ix = diff >> bucket_power;
+ if (ix >= 0 && ix < numbuckets && delay_counts != NULL)
+ ++delay_counts[ix];
+ else
+ ++overflow_count;
+ }
+ else
+ fprintf (stderr, "raw diff is %ld (?)\n", diff);
+ }
+}
+
+void
+record_for_spin_delay (char *file, int line)
+{
+ Microseconds (&last_microseconds);
+ last_spin_file = file;
+ last_spin_line = line;
+}
+
+void
+mpw_start_progress (char *str, int n, char *file, int line)
+{
+ int i;
+ char *measure, *threshold;
+
+ if (!cursor_inited)
+ {
+ InitCursorCtl (nil);
+ cursor_inited = 1;
+ record_for_spin_delay (file, line);
+ measure = getenv ("MEASURE_SPIN");
+ if (measure != NULL && measure[0] != '\0')
+ {
+ measure_spin = 1;
+ if (strcmp (measure, "all") == 0)
+ dump_spin_data = 1;
+ }
+ threshold = getenv ("SPIN_WARN_THRESHOLD");
+ if (threshold != NULL && threshold[0] != '\0')
+ warning_threshold = atol (threshold);
+ if (dump_spin_data)
+ {
+ if (delay_counts == NULL)
+ delay_counts = (int *) malloc (numbuckets * sizeof (int));
+ for (i = 0; i < numbuckets; ++i)
+ delay_counts[i] = 0;
+ overflow_count = 0;
+ }
+ }
+ current_progress = str;
+
+ sys_nerr = errno_max ();
+
+ mpw_special_init (str);
+}
+
+void
+mpw_progress (int n)
+{
+ SpinCursor (32);
+}
+
+void
+mpw_progress_measured (int n, char *file, int line)
+{
+ if (measure_spin)
+ warn_if_spin_delay (file, line);
+ SpinCursor (32);
+ if (measure_spin)
+ record_for_spin_delay (file, line);
+}
+
+void
+mpw_end_progress (char *str, char *file, int line)
+{
+ long i, delay, count = 0, sum = 0, avgdelay, spinrate;
+ long curpower = 0, curgroup = 0;
+
+ /* Warn if it's been a while since the last spin. */
+ if (measure_spin)
+ warn_if_spin_delay (file, line);
+
+ /* Dump all the nonzero delay counts and an approximation of the delay. */
+ if (dump_spin_data && delay_counts != NULL)
+ {
+ for (i = 0; i < numbuckets; ++i)
+ {
+ delay = (i + 1) * bucket_size;
+ sum += delay_counts[i] * (i + 1);
+ count += delay_counts[i];
+ if (delay <= (1 << curpower))
+ {
+ curgroup += delay_counts[i];
+ }
+ else
+ {
+ if (curgroup > 0)
+ fprintf (stderr,
+ "# %s: %d delays between %ld.%06ld and %ld.%06ld sec\n",
+ (str ? str : ""),
+ curgroup,
+ (1 << curpower) / 1000000,
+ (1 << curpower) % 1000000,
+ (1 << (curpower + 1)) / 1000000,
+ (1 << (curpower + 1)) % 1000000);
+ ++curpower;
+ curgroup = 0;
+ }
+ }
+ if (count > 0)
+ {
+ avgdelay = (sum * bucket_size) / count;
+ spinrate = 1000000 / avgdelay;
+ fprintf (stderr, "# %s: Average spin rate is %d times/sec\n",
+ (str ? str : ""), spinrate);
+ }
+ }
+}
+
+#ifdef PROGRESS_TEST
+
+/* Test program. */
+
+main ()
+{
+ int i, j;
+ double x = 1.0, y = 2.4;
+ long start = Microseconds (), tm; FIXME
+
+ START_PROGRESS ("hi", 0);
+
+ for (i = 0; i < 1000; ++i)
+ {
+ PROGRESS (1);
+
+ for (j = 0; j < (i * 100); ++j)
+ {
+ x += (x * y) / j;
+ }
+ }
+
+ END_PROGRESS ("hi");
+
+ tm = Microseconds () - start;
+
+ printf ("Total time is %d.%d secs\n", tm / 1000000, tm % 1000000);
+}
+
+#endif
+
+#ifdef USE_MW_HEADERS
+/* Empty definitions for Metrowerks' SIOUX console library. */
+
+#ifndef __CONSOLE__
+#include <console.h>
+#endif
+
+short
+InstallConsole(short fd)
+{
+#pragma unused (fd)
+ return 0;
+}
+
+void
+RemoveConsole(void)
+{
+}
+
+long
+WriteCharsToConsole(char *buf, long n)
+{
+#pragma unused (buf, n)
+ return 0;
+}
+
+long ReadCharsFromConsole(char *buf, long n)
+{
+#pragma unused (buf, n)
+ return 0;
+}
+
+extern char *
+__ttyname(long fd)
+{
+ static char *__devicename = "null device";
+
+ if (fd >= 0 && fd <= 2)
+ return (__devicename);
+ return NULL;
+}
+
+#endif
diff --git a/libiberty/msdos.c b/libiberty/msdos.c
new file mode 100644
index 00000000000..923e64d4ede
--- /dev/null
+++ b/libiberty/msdos.c
@@ -0,0 +1,15 @@
+char msg[] = "No vfork available - aborting\n";
+vfork()
+{
+ write(1, msg, sizeof(msg));
+}
+
+sigsetmask()
+{
+ /* no signals support in go32 (yet) */
+}
+
+waitpid()
+{
+ return -1;
+}
diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c
new file mode 100644
index 00000000000..57754a86105
--- /dev/null
+++ b/libiberty/objalloc.c
@@ -0,0 +1,291 @@
+/* objalloc.c -- routines to allocate memory for objects
+ Copyright 1997 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, 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, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "objalloc.h"
+
+/* Get a definition for NULL. */
+#include <stdio.h>
+
+#if VMS
+#include <stdlib.h>
+#include <unixlib.h>
+#else
+
+#ifdef ANSI_PROTOTYPES
+/* Get a definition for size_t. */
+#include <stddef.h>
+#endif
+
+/* For systems with larger pointers than ints, this must be declared. */
+extern PTR malloc PARAMS ((size_t));
+extern void free PARAMS ((PTR));
+#endif
+
+/* These routines allocate space for an object. Freeing allocated
+ space may or may not free all more recently allocated space.
+
+ We handle large and small allocation requests differently. If we
+ don't have enough space in the current block, and the allocation
+ request is for more than 512 bytes, we simply pass it through to
+ malloc. */
+
+/* The objalloc structure is defined in objalloc.h. */
+
+/* This structure appears at the start of each chunk. */
+
+struct objalloc_chunk
+{
+ /* Next chunk. */
+ struct objalloc_chunk *next;
+ /* If this chunk contains large objects, this is the value of
+ current_ptr when this chunk was allocated. If this chunk
+ contains small objects, this is NULL. */
+ char *current_ptr;
+};
+
+/* The aligned size of objalloc_chunk. */
+
+#define CHUNK_HEADER_SIZE \
+ ((sizeof (struct objalloc_chunk) + OBJALLOC_ALIGN - 1) \
+ &~ (OBJALLOC_ALIGN - 1))
+
+/* We ask for this much memory each time we create a chunk which is to
+ hold small objects. */
+
+#define CHUNK_SIZE (4096 - 32)
+
+/* A request for this amount or more is just passed through to malloc. */
+
+#define BIG_REQUEST (512)
+
+/* Create an objalloc structure. */
+
+struct objalloc *
+objalloc_create ()
+{
+ struct objalloc *ret;
+ struct objalloc_chunk *chunk;
+
+ ret = (struct objalloc *) malloc (sizeof *ret);
+ if (ret == NULL)
+ return NULL;
+
+ ret->chunks = (PTR) malloc (CHUNK_SIZE);
+ if (ret->chunks == NULL)
+ {
+ free (ret);
+ return NULL;
+ }
+
+ chunk = (struct objalloc_chunk *) ret->chunks;
+ chunk->next = NULL;
+ chunk->current_ptr = NULL;
+
+ ret->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE;
+ ret->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE;
+
+ return ret;
+}
+
+/* Allocate space from an objalloc structure. */
+
+PTR
+_objalloc_alloc (o, len)
+ struct objalloc *o;
+ unsigned long len;
+{
+ /* We avoid confusion from zero sized objects by always allocating
+ at least 1 byte. */
+ if (len == 0)
+ len = 1;
+
+ len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1);
+
+ if (len <= o->current_space)
+ {
+ o->current_ptr += len;
+ o->current_space -= len;
+ return (PTR) (o->current_ptr - len);
+ }
+
+ if (len >= BIG_REQUEST)
+ {
+ char *ret;
+ struct objalloc_chunk *chunk;
+
+ ret = (char *) malloc (CHUNK_HEADER_SIZE + len);
+ if (ret == NULL)
+ return NULL;
+
+ chunk = (struct objalloc_chunk *) ret;
+ chunk->next = (struct objalloc_chunk *) o->chunks;
+ chunk->current_ptr = o->current_ptr;
+
+ o->chunks = (PTR) chunk;
+
+ return (PTR) (ret + CHUNK_HEADER_SIZE);
+ }
+ else
+ {
+ struct objalloc_chunk *chunk;
+
+ chunk = (struct objalloc_chunk *) malloc (CHUNK_SIZE);
+ if (chunk == NULL)
+ return NULL;
+ chunk->next = (struct objalloc_chunk *) o->chunks;
+ chunk->current_ptr = NULL;
+
+ o->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE;
+ o->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE;
+
+ o->chunks = (PTR) chunk;
+
+ return objalloc_alloc (o, len);
+ }
+}
+
+/* Free an entire objalloc structure. */
+
+void
+objalloc_free (o)
+ struct objalloc *o;
+{
+ struct objalloc_chunk *l;
+
+ l = (struct objalloc_chunk *) o->chunks;
+ while (l != NULL)
+ {
+ struct objalloc_chunk *next;
+
+ next = l->next;
+ free (l);
+ l = next;
+ }
+
+ free (o);
+}
+
+/* Free a block from an objalloc structure. This also frees all more
+ recently allocated blocks. */
+
+void
+objalloc_free_block (o, block)
+ struct objalloc *o;
+ PTR block;
+{
+ struct objalloc_chunk *p, *small;
+ char *b = (char *) block;
+
+ /* First set P to the chunk which contains the block we are freeing,
+ and set Q to the last small object chunk we see before P. */
+ small = NULL;
+ for (p = (struct objalloc_chunk *) o->chunks; p != NULL; p = p->next)
+ {
+ if (p->current_ptr == NULL)
+ {
+ if (b > (char *) p && b < (char *) p + CHUNK_SIZE)
+ break;
+ small = p;
+ }
+ else
+ {
+ if (b == (char *) p + CHUNK_HEADER_SIZE)
+ break;
+ }
+ }
+
+ /* If we can't find the chunk, the caller has made a mistake. */
+ if (p == NULL)
+ abort ();
+
+ if (p->current_ptr == NULL)
+ {
+ struct objalloc_chunk *q;
+ struct objalloc_chunk *first;
+
+ /* The block is in a chunk containing small objects. We can
+ free every chunk through SMALL, because they have certainly
+ been allocated more recently. After SMALL, we will not see
+ any chunks containing small objects; we can free any big
+ chunk if the current_ptr is greater than or equal to B. We
+ can then reset the new current_ptr to B. */
+
+ first = NULL;
+ q = (struct objalloc_chunk *) o->chunks;
+ while (q != p)
+ {
+ struct objalloc_chunk *next;
+
+ next = q->next;
+ if (small != NULL)
+ {
+ if (small == q)
+ small = NULL;
+ free (q);
+ }
+ else if (q->current_ptr > b)
+ free (q);
+ else if (first == NULL)
+ first = q;
+
+ q = next;
+ }
+
+ if (first == NULL)
+ first = p;
+ o->chunks = (PTR) first;
+
+ /* Now start allocating from this small block again. */
+ o->current_ptr = b;
+ o->current_space = ((char *) p + CHUNK_SIZE) - b;
+ }
+ else
+ {
+ struct objalloc_chunk *q;
+ char *current_ptr;
+
+ /* This block is in a large chunk by itself. We can free
+ everything on the list up to and including this block. We
+ then start allocating from the next chunk containing small
+ objects, setting current_ptr from the value stored with the
+ large chunk we are freeing. */
+
+ current_ptr = p->current_ptr;
+ p = p->next;
+
+ q = (struct objalloc_chunk *) o->chunks;
+ while (q != p)
+ {
+ struct objalloc_chunk *next;
+
+ next = q->next;
+ free (q);
+ q = next;
+ }
+
+ o->chunks = (PTR) p;
+
+ while (p->current_ptr != NULL)
+ p = p->next;
+
+ o->current_ptr = current_ptr;
+ o->current_space = ((char *) p + CHUNK_SIZE) - current_ptr;
+ }
+}
diff --git a/libiberty/obstack.c b/libiberty/obstack.c
new file mode 100644
index 00000000000..bc318b37790
--- /dev/null
+++ b/libiberty/obstack.c
@@ -0,0 +1,593 @@
+/* obstack.c - subroutines used implicitly by object stack macros
+ Copyright (C) 1988,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
+
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "obstack.h"
+
+/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
+ incremented whenever callers compiled using an old obstack.h can no
+ longer properly call the functions in this obstack.c. */
+#define OBSTACK_INTERFACE_VERSION 1
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself, and the installed library
+ supports the same library interface we do. This code is part of the GNU
+ C Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object
+ files, it is simpler to just do this in the source for each such file. */
+
+#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
+#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
+#include <gnu-versions.h>
+#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
+#define ELIDE_CODE
+#endif
+#endif
+
+
+#ifndef ELIDE_CODE
+
+
+#if defined (__STDC__) && __STDC__
+#define POINTER void *
+#else
+#define POINTER char *
+#endif
+
+/* Determine default alignment. */
+struct fooalign {char x; double d;};
+#define DEFAULT_ALIGNMENT \
+ ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
+/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
+ But in fact it might be less smart and round addresses to as much as
+ DEFAULT_ROUNDING. So we prepare for it to do that. */
+union fooround {long x; double d;};
+#define DEFAULT_ROUNDING (sizeof (union fooround))
+
+/* When we copy a long block of data, this is the unit to do it with.
+ On some machines, copying successive ints does not work;
+ in such a case, redefine COPYING_UNIT to `long' (if that works)
+ or `char' as a last resort. */
+#ifndef COPYING_UNIT
+#define COPYING_UNIT int
+#endif
+
+
+/* The functions allocating more room by calling `obstack_chunk_alloc'
+ jump to the handler pointed to by `obstack_alloc_failed_handler'.
+ This variable by default points to the internal function
+ `print_and_abort'. */
+#if defined (__STDC__) && __STDC__
+static void print_and_abort (void);
+void (*obstack_alloc_failed_handler) (void) = print_and_abort;
+#else
+static void print_and_abort ();
+void (*obstack_alloc_failed_handler) () = print_and_abort;
+#endif
+
+/* Exit value used when `print_and_abort' is used. */
+#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+int obstack_exit_failure = EXIT_FAILURE;
+
+/* The non-GNU-C macros copy the obstack into this global variable
+ to avoid multiple evaluation. */
+
+struct obstack *_obstack;
+
+/* Define a macro that either calls functions with the traditional malloc/free
+ calling interface, or calls functions with the mmalloc/mfree interface
+ (that adds an extra first argument), based on the state of use_extra_arg.
+ For free, do not use ?:, since some compilers, like the MIPS compilers,
+ do not allow (expr) ? void : void. */
+
+#if defined (__STDC__) && __STDC__
+#define CALL_CHUNKFUN(h, size) \
+ (((h) -> use_extra_arg) \
+ ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
+ : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
+
+#define CALL_FREEFUN(h, old_chunk) \
+ do { \
+ if ((h) -> use_extra_arg) \
+ (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
+ else \
+ (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
+ } while (0)
+#else
+#define CALL_CHUNKFUN(h, size) \
+ (((h) -> use_extra_arg) \
+ ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
+ : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
+
+#define CALL_FREEFUN(h, old_chunk) \
+ do { \
+ if ((h) -> use_extra_arg) \
+ (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
+ else \
+ (*(void (*) ()) (h)->freefun) ((old_chunk)); \
+ } while (0)
+#endif
+
+
+/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
+ Objects start on multiples of ALIGNMENT (0 means use default).
+ CHUNKFUN is the function to use to allocate chunks,
+ and FREEFUN the function to free them.
+
+ Return nonzero if successful, zero if out of memory.
+ To recover from an out of memory error,
+ free up some memory, then call this again. */
+
+int
+_obstack_begin (h, size, alignment, chunkfun, freefun)
+ struct obstack *h;
+ int size;
+ int alignment;
+#if defined (__STDC__) && __STDC__
+ POINTER (*chunkfun) (long);
+ void (*freefun) (void *);
+#else
+ POINTER (*chunkfun) ();
+ void (*freefun) ();
+#endif
+{
+ register struct _obstack_chunk *chunk; /* points to new chunk */
+
+ if (alignment == 0)
+ alignment = (int) DEFAULT_ALIGNMENT;
+ if (size == 0)
+ /* Default size is what GNU malloc can fit in a 4096-byte block. */
+ {
+ /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
+ Use the values for range checking, because if range checking is off,
+ the extra bytes won't be missed terribly, but if range checking is on
+ and we used a larger request, a whole extra 4096 bytes would be
+ allocated.
+
+ These number are irrelevant to the new GNU malloc. I suspect it is
+ less sensitive to the size of the request. */
+ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ + 4 + DEFAULT_ROUNDING - 1)
+ & ~(DEFAULT_ROUNDING - 1));
+ size = 4096 - extra;
+ }
+
+#if defined (__STDC__) && __STDC__
+ h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
+ h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
+#else
+ h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
+ h->freefun = freefun;
+#endif
+ h->chunk_size = size;
+ h->alignment_mask = alignment - 1;
+ h->use_extra_arg = 0;
+
+ chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
+ if (!chunk)
+ (*obstack_alloc_failed_handler) ();
+ h->next_free = h->object_base = chunk->contents;
+ h->chunk_limit = chunk->limit
+ = (char *) chunk + h->chunk_size;
+ chunk->prev = 0;
+ /* The initial chunk now contains no empty object. */
+ h->maybe_empty_object = 0;
+ h->alloc_failed = 0;
+ return 1;
+}
+
+int
+_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
+ struct obstack *h;
+ int size;
+ int alignment;
+#if defined (__STDC__) && __STDC__
+ POINTER (*chunkfun) (POINTER, long);
+ void (*freefun) (POINTER, POINTER);
+#else
+ POINTER (*chunkfun) ();
+ void (*freefun) ();
+#endif
+ POINTER arg;
+{
+ register struct _obstack_chunk *chunk; /* points to new chunk */
+
+ if (alignment == 0)
+ alignment = (int) DEFAULT_ALIGNMENT;
+ if (size == 0)
+ /* Default size is what GNU malloc can fit in a 4096-byte block. */
+ {
+ /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
+ Use the values for range checking, because if range checking is off,
+ the extra bytes won't be missed terribly, but if range checking is on
+ and we used a larger request, a whole extra 4096 bytes would be
+ allocated.
+
+ These number are irrelevant to the new GNU malloc. I suspect it is
+ less sensitive to the size of the request. */
+ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ + 4 + DEFAULT_ROUNDING - 1)
+ & ~(DEFAULT_ROUNDING - 1));
+ size = 4096 - extra;
+ }
+
+#if defined(__STDC__) && __STDC__
+ h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
+ h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
+#else
+ h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
+ h->freefun = freefun;
+#endif
+ h->chunk_size = size;
+ h->alignment_mask = alignment - 1;
+ h->extra_arg = arg;
+ h->use_extra_arg = 1;
+
+ chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
+ if (!chunk)
+ (*obstack_alloc_failed_handler) ();
+ h->next_free = h->object_base = chunk->contents;
+ h->chunk_limit = chunk->limit
+ = (char *) chunk + h->chunk_size;
+ chunk->prev = 0;
+ /* The initial chunk now contains no empty object. */
+ h->maybe_empty_object = 0;
+ h->alloc_failed = 0;
+ return 1;
+}
+
+/* Allocate a new current chunk for the obstack *H
+ on the assumption that LENGTH bytes need to be added
+ to the current object, or a new object of length LENGTH allocated.
+ Copies any partial object from the end of the old chunk
+ to the beginning of the new one. */
+
+void
+_obstack_newchunk (h, length)
+ struct obstack *h;
+ int length;
+{
+ register struct _obstack_chunk *old_chunk = h->chunk;
+ register struct _obstack_chunk *new_chunk;
+ register long new_size;
+ register long obj_size = h->next_free - h->object_base;
+ register long i;
+ long already;
+
+ /* Compute size for new chunk. */
+ new_size = (obj_size + length) + (obj_size >> 3) + 100;
+ if (new_size < h->chunk_size)
+ new_size = h->chunk_size;
+
+ /* Allocate and initialize the new chunk. */
+ new_chunk = CALL_CHUNKFUN (h, new_size);
+ if (!new_chunk)
+ (*obstack_alloc_failed_handler) ();
+ h->chunk = new_chunk;
+ new_chunk->prev = old_chunk;
+ new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
+
+ /* Move the existing object to the new chunk.
+ Word at a time is fast and is safe if the object
+ is sufficiently aligned. */
+ if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
+ {
+ for (i = obj_size / sizeof (COPYING_UNIT) - 1;
+ i >= 0; i--)
+ ((COPYING_UNIT *)new_chunk->contents)[i]
+ = ((COPYING_UNIT *)h->object_base)[i];
+ /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
+ but that can cross a page boundary on a machine
+ which does not do strict alignment for COPYING_UNITS. */
+ already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
+ }
+ else
+ already = 0;
+ /* Copy remaining bytes one by one. */
+ for (i = already; i < obj_size; i++)
+ new_chunk->contents[i] = h->object_base[i];
+
+ /* If the object just copied was the only data in OLD_CHUNK,
+ free that chunk and remove it from the chain.
+ But not if that chunk might contain an empty object. */
+ if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
+ {
+ new_chunk->prev = old_chunk->prev;
+ CALL_FREEFUN (h, old_chunk);
+ }
+
+ h->object_base = new_chunk->contents;
+ h->next_free = h->object_base + obj_size;
+ /* The new chunk certainly contains no empty object yet. */
+ h->maybe_empty_object = 0;
+}
+
+/* Return nonzero if object OBJ has been allocated from obstack H.
+ This is here for debugging.
+ If you use it in a program, you are probably losing. */
+
+#if defined (__STDC__) && __STDC__
+/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
+ obstack.h because it is just for debugging. */
+int _obstack_allocated_p (struct obstack *h, POINTER obj);
+#endif
+
+int
+_obstack_allocated_p (h, obj)
+ struct obstack *h;
+ POINTER obj;
+{
+ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ register struct _obstack_chunk *plp; /* point to previous chunk if any */
+
+ lp = (h)->chunk;
+ /* We use >= rather than > since the object cannot be exactly at
+ the beginning of the chunk but might be an empty object exactly
+ at the end of an adjacent chunk. */
+ while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
+ {
+ plp = lp->prev;
+ lp = plp;
+ }
+ return lp != 0;
+}
+
+/* Free objects in obstack H, including OBJ and everything allocate
+ more recently than OBJ. If OBJ is zero, free everything in H. */
+
+#undef obstack_free
+
+/* This function has two names with identical definitions.
+ This is the first one, called from non-ANSI code. */
+
+void
+_obstack_free (h, obj)
+ struct obstack *h;
+ POINTER obj;
+{
+ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ register struct _obstack_chunk *plp; /* point to previous chunk if any */
+
+ lp = h->chunk;
+ /* We use >= because there cannot be an object at the beginning of a chunk.
+ But there can be an empty object at that address
+ at the end of another chunk. */
+ while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
+ {
+ plp = lp->prev;
+ CALL_FREEFUN (h, lp);
+ lp = plp;
+ /* If we switch chunks, we can't tell whether the new current
+ chunk contains an empty object, so assume that it may. */
+ h->maybe_empty_object = 1;
+ }
+ if (lp)
+ {
+ h->object_base = h->next_free = (char *) (obj);
+ h->chunk_limit = lp->limit;
+ h->chunk = lp;
+ }
+ else if (obj != 0)
+ /* obj is not in any of the chunks! */
+ abort ();
+}
+
+/* This function is used from ANSI code. */
+
+void
+obstack_free (h, obj)
+ struct obstack *h;
+ POINTER obj;
+{
+ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ register struct _obstack_chunk *plp; /* point to previous chunk if any */
+
+ lp = h->chunk;
+ /* We use >= because there cannot be an object at the beginning of a chunk.
+ But there can be an empty object at that address
+ at the end of another chunk. */
+ while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
+ {
+ plp = lp->prev;
+ CALL_FREEFUN (h, lp);
+ lp = plp;
+ /* If we switch chunks, we can't tell whether the new current
+ chunk contains an empty object, so assume that it may. */
+ h->maybe_empty_object = 1;
+ }
+ if (lp)
+ {
+ h->object_base = h->next_free = (char *) (obj);
+ h->chunk_limit = lp->limit;
+ h->chunk = lp;
+ }
+ else if (obj != 0)
+ /* obj is not in any of the chunks! */
+ abort ();
+}
+
+int
+_obstack_memory_used (h)
+ struct obstack *h;
+{
+ register struct _obstack_chunk* lp;
+ register int nbytes = 0;
+
+ for (lp = h->chunk; lp != 0; lp = lp->prev)
+ {
+ nbytes += lp->limit - (char *) lp;
+ }
+ return nbytes;
+}
+
+/* Define the error handler. */
+#ifndef _
+# ifdef HAVE_LIBINTL_H
+# include <libintl.h>
+# ifndef _
+# define _(Str) gettext (Str)
+# endif
+# else
+# define _(Str) (Str)
+# endif
+#endif
+
+static void
+print_and_abort ()
+{
+ fputs (_("memory exhausted\n"), stderr);
+ exit (obstack_exit_failure);
+}
+
+#if 0
+/* These are now turned off because the applications do not use it
+ and it uses bcopy via obstack_grow, which causes trouble on sysV. */
+
+/* Now define the functional versions of the obstack macros.
+ Define them to simply use the corresponding macros to do the job. */
+
+#if defined (__STDC__) && __STDC__
+/* These function definitions do not work with non-ANSI preprocessors;
+ they won't pass through the macro names in parentheses. */
+
+/* The function names appear in parentheses in order to prevent
+ the macro-definitions of the names from being expanded there. */
+
+POINTER (obstack_base) (obstack)
+ struct obstack *obstack;
+{
+ return obstack_base (obstack);
+}
+
+POINTER (obstack_next_free) (obstack)
+ struct obstack *obstack;
+{
+ return obstack_next_free (obstack);
+}
+
+int (obstack_object_size) (obstack)
+ struct obstack *obstack;
+{
+ return obstack_object_size (obstack);
+}
+
+int (obstack_room) (obstack)
+ struct obstack *obstack;
+{
+ return obstack_room (obstack);
+}
+
+int (obstack_make_room) (obstack, length)
+ struct obstack *obstack;
+ int length;
+{
+ return obstack_make_room (obstack, length);
+}
+
+void (obstack_grow) (obstack, pointer, length)
+ struct obstack *obstack;
+ POINTER pointer;
+ int length;
+{
+ obstack_grow (obstack, pointer, length);
+}
+
+void (obstack_grow0) (obstack, pointer, length)
+ struct obstack *obstack;
+ POINTER pointer;
+ int length;
+{
+ obstack_grow0 (obstack, pointer, length);
+}
+
+void (obstack_1grow) (obstack, character)
+ struct obstack *obstack;
+ int character;
+{
+ obstack_1grow (obstack, character);
+}
+
+void (obstack_blank) (obstack, length)
+ struct obstack *obstack;
+ int length;
+{
+ obstack_blank (obstack, length);
+}
+
+void (obstack_1grow_fast) (obstack, character)
+ struct obstack *obstack;
+ int character;
+{
+ obstack_1grow_fast (obstack, character);
+}
+
+void (obstack_blank_fast) (obstack, length)
+ struct obstack *obstack;
+ int length;
+{
+ obstack_blank_fast (obstack, length);
+}
+
+POINTER (obstack_finish) (obstack)
+ struct obstack *obstack;
+{
+ return obstack_finish (obstack);
+}
+
+POINTER (obstack_alloc) (obstack, length)
+ struct obstack *obstack;
+ int length;
+{
+ return obstack_alloc (obstack, length);
+}
+
+POINTER (obstack_copy) (obstack, pointer, length)
+ struct obstack *obstack;
+ POINTER pointer;
+ int length;
+{
+ return obstack_copy (obstack, pointer, length);
+}
+
+POINTER (obstack_copy0) (obstack, pointer, length)
+ struct obstack *obstack;
+ POINTER pointer;
+ int length;
+{
+ return obstack_copy0 (obstack, pointer, length);
+}
+
+#endif /* __STDC__ */
+
+#endif /* 0 */
+
+#endif /* !ELIDE_CODE */
diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c
new file mode 100644
index 00000000000..6da97deee4b
--- /dev/null
+++ b/libiberty/pexecute.c
@@ -0,0 +1,738 @@
+/* Utilities to execute a program in a subprocess (possibly linked by pipes
+ with other subprocesses), and wait for it.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If not,
+write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This file exports two functions: pexecute and pwait. */
+
+/* This file lives in at least two places: libiberty and gcc.
+ Don't change one without the other. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#define ISSPACE (x) isspace(x)
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifdef vfork /* Autoconf may define this to fork for us. */
+# define VFORK_STRING "fork"
+#else
+# define VFORK_STRING "vfork"
+#endif
+#ifdef HAVE_VFORK_H
+#include <vfork.h>
+#endif
+#ifdef VMS
+#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
+ lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
+#endif /* VMS */
+
+#include "libiberty.h"
+
+#if !defined (__CYGWIN__) && defined (__CYGWIN32__)
+#define __CYGWIN__ 1
+#endif
+
+/* stdin file number. */
+#define STDIN_FILE_NO 0
+
+/* stdout file number. */
+#define STDOUT_FILE_NO 1
+
+/* value of `pipe': port index for reading. */
+#define READ_PORT 0
+
+/* value of `pipe': port index for writing. */
+#define WRITE_PORT 1
+
+static char *install_error_msg = "installation problem, cannot exec `%s'";
+
+/* pexecute: execute a program.
+
+ PROGRAM and ARGV are the arguments to execv/execvp.
+
+ THIS_PNAME is name of the calling program (i.e. argv[0]).
+
+ TEMP_BASE is the path name, sans suffix, of a temporary file to use
+ if needed. This is currently only needed for MSDOS ports that don't use
+ GO32 (do any still exist?). Ports that don't need it can pass NULL.
+
+ (FLAGS & PEXECUTE_SEARCH) is non-zero if $PATH should be searched
+ (??? It's not clear that GCC passes this flag correctly).
+ (FLAGS & PEXECUTE_FIRST) is nonzero for the first process in chain.
+ (FLAGS & PEXECUTE_FIRST) is nonzero for the last process in chain.
+ FIRST_LAST could be simplified to only mark the last of a chain of processes
+ but that requires the caller to always mark the last one (and not give up
+ early if some error occurs). It's more robust to require the caller to
+ mark both ends of the chain.
+
+ The result is the pid on systems like Unix where we fork/exec and on systems
+ like WIN32 and OS2 where we use spawn. It is up to the caller to wait for
+ the child.
+
+ The result is the WEXITSTATUS on systems like MSDOS where we spawn and wait
+ for the child here.
+
+ Upon failure, ERRMSG_FMT and ERRMSG_ARG are set to the text of the error
+ message with an optional argument (if not needed, ERRMSG_ARG is set to
+ NULL), and -1 is returned. `errno' is available to the caller to use.
+
+ pwait: cover function for wait.
+
+ PID is the process id of the task to wait for.
+ STATUS is the `status' argument to wait.
+ FLAGS is currently unused (allows future enhancement without breaking
+ upward compatibility). Pass 0 for now.
+
+ The result is the pid of the child reaped,
+ or -1 for failure (errno says why).
+
+ On systems that don't support waiting for a particular child, PID is
+ ignored. On systems like MSDOS that don't really multitask pwait
+ is just a mechanism to provide a consistent interface for the caller.
+
+ pfinish: finish generation of script
+
+ pfinish is necessary for systems like MPW where a script is generated that
+ runs the requested programs.
+*/
+
+#ifdef __MSDOS__
+
+/* MSDOS doesn't multitask, but for the sake of a consistent interface
+ the code behaves like it does. pexecute runs the program, tucks the
+ exit code away, and returns a "pid". pwait must be called to fetch the
+ exit code. */
+
+#include <process.h>
+
+/* For communicating information from pexecute to pwait. */
+static int last_pid = 0;
+static int last_status = 0;
+static int last_reaped = 0;
+
+int
+pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
+ const char *program;
+ char * const *argv;
+ const char *this_pname;
+ const char *temp_base;
+ char **errmsg_fmt, **errmsg_arg;
+ int flags;
+{
+ int rc;
+
+ last_pid++;
+ if (last_pid < 0)
+ last_pid = 1;
+
+ if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
+ abort ();
+
+#ifdef __GO32__
+ /* ??? What are the possible return values from spawnv? */
+ rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv);
+#else
+ char *scmd, *rf;
+ FILE *argfile;
+ int i, el = flags & PEXECUTE_SEARCH ? 4 : 0;
+
+ scmd = (char *) xmalloc (strlen (program) + strlen (temp_base) + 6 + el);
+ rf = scmd + strlen(program) + 2 + el;
+ sprintf (scmd, "%s%s @%s.gp", program,
+ (flags & PEXECUTE_SEARCH ? ".exe" : ""), temp_base);
+ argfile = fopen (rf, "w");
+ if (argfile == 0)
+ {
+ int errno_save = errno;
+ free (scmd);
+ errno = errno_save;
+ *errmsg_fmt = "cannot open `%s.gp'";
+ *errmsg_arg = temp_base;
+ return -1;
+ }
+
+ for (i=1; argv[i]; i++)
+ {
+ char *cp;
+ for (cp = argv[i]; *cp; cp++)
+ {
+ if (*cp == '"' || *cp == '\'' || *cp == '\\' || ISSPACE (*cp))
+ fputc ('\\', argfile);
+ fputc (*cp, argfile);
+ }
+ fputc ('\n', argfile);
+ }
+ fclose (argfile);
+
+ rc = system (scmd);
+
+ {
+ int errno_save = errno;
+ remove (rf);
+ free (scmd);
+ errno = errno_save;
+ }
+#endif
+
+ if (rc == -1)
+ {
+ *errmsg_fmt = install_error_msg;
+ *errmsg_arg = program;
+ return -1;
+ }
+
+ /* Tuck the status away for pwait, and return a "pid". */
+ last_status = rc << 8;
+ return last_pid;
+}
+
+int
+pwait (pid, status, flags)
+ int pid;
+ int *status;
+ int flags;
+{
+ /* On MSDOS each pexecute must be followed by it's associated pwait. */
+ if (pid != last_pid
+ /* Called twice for the same child? */
+ || pid == last_reaped)
+ {
+ /* ??? ECHILD would be a better choice. Can we use it here? */
+ errno = EINVAL;
+ return -1;
+ }
+ /* ??? Here's an opportunity to canonicalize the values in STATUS.
+ Needed? */
+ *status = last_status;
+ last_reaped = last_pid;
+ return last_pid;
+}
+
+#endif /* MSDOS */
+
+#if defined (_WIN32) && ! defined (__UWIN__)
+
+#include <process.h>
+
+#ifdef __CYGWIN__
+
+#define fix_argv(argvec) (argvec)
+
+extern int _spawnv ();
+extern int _spawnvp ();
+
+#else /* ! __CYGWIN__ */
+
+/* This is a kludge to get around the Microsoft C spawn functions' propensity
+ to remove the outermost set of double quotes from all arguments. */
+
+const char * const *
+fix_argv (argvec)
+ char **argvec;
+{
+ int i;
+
+ for (i = 1; argvec[i] != 0; i++)
+ {
+ int len, j;
+ char *temp, *newtemp;
+
+ temp = argvec[i];
+ len = strlen (temp);
+ for (j = 0; j < len; j++)
+ {
+ if (temp[j] == '"')
+ {
+ newtemp = xmalloc (len + 2);
+ strncpy (newtemp, temp, j);
+ newtemp [j] = '\\';
+ strncpy (&newtemp [j+1], &temp [j], len-j);
+ newtemp [len+1] = 0;
+ temp = newtemp;
+ len++;
+ j++;
+ }
+ }
+
+ argvec[i] = temp;
+ }
+
+ return (const char * const *) argvec;
+}
+#endif /* __CYGWIN__ */
+
+#include <io.h>
+#include <fcntl.h>
+#include <signal.h>
+
+/* mingw32 headers may not define the following. */
+
+#ifndef _P_WAIT
+# define _P_WAIT 0
+# define _P_NOWAIT 1
+# define _P_OVERLAY 2
+# define _P_NOWAITO 3
+# define _P_DETACH 4
+
+# define WAIT_CHILD 0
+# define WAIT_GRANDCHILD 1
+#endif
+
+/* Win32 supports pipes */
+int
+pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
+ const char *program;
+ char * const *argv;
+ const char *this_pname;
+ const char *temp_base;
+ char **errmsg_fmt, **errmsg_arg;
+ int flags;
+{
+ int pid;
+ int pdes[2], org_stdin, org_stdout;
+ int input_desc, output_desc;
+ int retries, sleep_interval;
+
+ /* Pipe waiting from last process, to be used as input for the next one.
+ Value is STDIN_FILE_NO if no pipe is waiting
+ (i.e. the next command is the first of a group). */
+ static int last_pipe_input;
+
+ /* If this is the first process, initialize. */
+ if (flags & PEXECUTE_FIRST)
+ last_pipe_input = STDIN_FILE_NO;
+
+ input_desc = last_pipe_input;
+
+ /* If this isn't the last process, make a pipe for its output,
+ and record it as waiting to be the input to the next process. */
+ if (! (flags & PEXECUTE_LAST))
+ {
+ if (_pipe (pdes, 256, O_BINARY) < 0)
+ {
+ *errmsg_fmt = "pipe";
+ *errmsg_arg = NULL;
+ return -1;
+ }
+ output_desc = pdes[WRITE_PORT];
+ last_pipe_input = pdes[READ_PORT];
+ }
+ else
+ {
+ /* Last process. */
+ output_desc = STDOUT_FILE_NO;
+ last_pipe_input = STDIN_FILE_NO;
+ }
+
+ if (input_desc != STDIN_FILE_NO)
+ {
+ org_stdin = dup (STDIN_FILE_NO);
+ dup2 (input_desc, STDIN_FILE_NO);
+ close (input_desc);
+ }
+
+ if (output_desc != STDOUT_FILE_NO)
+ {
+ org_stdout = dup (STDOUT_FILE_NO);
+ dup2 (output_desc, STDOUT_FILE_NO);
+ close (output_desc);
+ }
+
+ pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv)
+ (_P_NOWAIT, program, fix_argv(argv));
+
+ if (input_desc != STDIN_FILE_NO)
+ {
+ dup2 (org_stdin, STDIN_FILE_NO);
+ close (org_stdin);
+ }
+
+ if (output_desc != STDOUT_FILE_NO)
+ {
+ dup2 (org_stdout, STDOUT_FILE_NO);
+ close (org_stdout);
+ }
+
+ if (pid == -1)
+ {
+ *errmsg_fmt = install_error_msg;
+ *errmsg_arg = program;
+ return -1;
+ }
+
+ return pid;
+}
+
+/* MS CRTDLL doesn't return enough information in status to decide if the
+ child exited due to a signal or not, rather it simply returns an
+ integer with the exit code of the child; eg., if the child exited with
+ an abort() call and didn't have a handler for SIGABRT, it simply returns
+ with status = 3. We fix the status code to conform to the usual WIF*
+ macros. Note that WIFSIGNALED will never be true under CRTDLL. */
+
+int
+pwait (pid, status, flags)
+ int pid;
+ int *status;
+ int flags;
+{
+#ifdef __CYGWIN__
+ return wait (status);
+#else
+ int termstat;
+
+ pid = _cwait (&termstat, pid, WAIT_CHILD);
+
+ /* ??? Here's an opportunity to canonicalize the values in STATUS.
+ Needed? */
+
+ /* cwait returns the child process exit code in termstat.
+ A value of 3 indicates that the child caught a signal, but not
+ which one. Since only SIGABRT, SIGFPE and SIGINT do anything, we
+ report SIGABRT. */
+ if (termstat == 3)
+ *status = SIGABRT;
+ else
+ *status = (((termstat) & 0xff) << 8);
+
+ return pid;
+#endif /* __CYGWIN__ */
+}
+
+#endif /* _WIN32 && ! __UWIN__ */
+
+#ifdef OS2
+
+/* ??? Does OS2 have process.h? */
+extern int spawnv ();
+extern int spawnvp ();
+
+int
+pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
+ const char *program;
+ char * const *argv;
+ const char *this_pname;
+ const char *temp_base;
+ char **errmsg_fmt, **errmsg_arg;
+ int flags;
+{
+ int pid;
+
+ if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
+ abort ();
+ /* ??? Presumably 1 == _P_NOWAIT. */
+ pid = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv);
+ if (pid == -1)
+ {
+ *errmsg_fmt = install_error_msg;
+ *errmsg_arg = program;
+ return -1;
+ }
+ return pid;
+}
+
+int
+pwait (pid, status, flags)
+ int pid;
+ int *status;
+ int flags;
+{
+ /* ??? Here's an opportunity to canonicalize the values in STATUS.
+ Needed? */
+ int pid = wait (status);
+ return pid;
+}
+
+#endif /* OS2 */
+
+#ifdef MPW
+
+/* MPW pexecute doesn't actually run anything; instead, it writes out
+ script commands that, when run, will do the actual executing.
+
+ For example, in GCC's case, GCC will write out several script commands:
+
+ cpp ...
+ cc1 ...
+ as ...
+ ld ...
+
+ and then exit. None of the above programs will have run yet. The task
+ that called GCC will then execute the script and cause cpp,etc. to run.
+ The caller must invoke pfinish before calling exit. This adds
+ the finishing touches to the generated script. */
+
+static int first_time = 1;
+
+int
+pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
+ const char *program;
+ char * const *argv;
+ const char *this_pname;
+ const char *temp_base;
+ char **errmsg_fmt, **errmsg_arg;
+ int flags;
+{
+ char tmpprogram[255];
+ char *cp, *tmpname;
+ int i;
+
+ mpwify_filename (program, tmpprogram);
+ if (first_time)
+ {
+ printf ("Set Failed 0\n");
+ first_time = 0;
+ }
+
+ fputs ("If {Failed} == 0\n", stdout);
+ /* If being verbose, output a copy of the command. It should be
+ accurate enough and escaped enough to be "clickable". */
+ if (flags & PEXECUTE_VERBOSE)
+ {
+ fputs ("\tEcho ", stdout);
+ fputc ('\'', stdout);
+ fputs (tmpprogram, stdout);
+ fputc ('\'', stdout);
+ fputc (' ', stdout);
+ for (i=1; argv[i]; i++)
+ {
+ fputc ('\'', stdout);
+ /* See if we have an argument that needs fixing. */
+ if (strchr(argv[i], '/'))
+ {
+ tmpname = (char *) xmalloc (256);
+ mpwify_filename (argv[i], tmpname);
+ argv[i] = tmpname;
+ }
+ for (cp = argv[i]; *cp; cp++)
+ {
+ /* Write an Option-d escape char in front of special chars. */
+ if (strchr("'+", *cp))
+ fputc ('\266', stdout);
+ fputc (*cp, stdout);
+ }
+ fputc ('\'', stdout);
+ fputc (' ', stdout);
+ }
+ fputs ("\n", stdout);
+ }
+ fputs ("\t", stdout);
+ fputs (tmpprogram, stdout);
+ fputc (' ', stdout);
+
+ for (i=1; argv[i]; i++)
+ {
+ /* See if we have an argument that needs fixing. */
+ if (strchr(argv[i], '/'))
+ {
+ tmpname = (char *) xmalloc (256);
+ mpwify_filename (argv[i], tmpname);
+ argv[i] = tmpname;
+ }
+ if (strchr (argv[i], ' '))
+ fputc ('\'', stdout);
+ for (cp = argv[i]; *cp; cp++)
+ {
+ /* Write an Option-d escape char in front of special chars. */
+ if (strchr("'+", *cp))
+ fputc ('\266', stdout);
+ fputc (*cp, stdout);
+ }
+ if (strchr (argv[i], ' '))
+ fputc ('\'', stdout);
+ fputc (' ', stdout);
+ }
+
+ fputs ("\n", stdout);
+
+ /* Output commands that arrange to clean up and exit if a failure occurs.
+ We have to be careful to collect the status from the program that was
+ run, rather than some other script command. Also, we don't exit
+ immediately, since necessary cleanups are at the end of the script. */
+ fputs ("\tSet TmpStatus {Status}\n", stdout);
+ fputs ("\tIf {TmpStatus} != 0\n", stdout);
+ fputs ("\t\tSet Failed {TmpStatus}\n", stdout);
+ fputs ("\tEnd\n", stdout);
+ fputs ("End\n", stdout);
+
+ /* We're just composing a script, can't fail here. */
+ return 0;
+}
+
+int
+pwait (pid, status, flags)
+ int pid;
+ int *status;
+ int flags;
+{
+ *status = 0;
+ return 0;
+}
+
+/* Write out commands that will exit with the correct error code
+ if something in the script failed. */
+
+void
+pfinish ()
+{
+ printf ("\tExit \"{Failed}\"\n");
+}
+
+#endif /* MPW */
+
+/* include for Unix-like environments but not for Dos-like environments */
+#if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \
+ && ! (defined (_WIN32) && ! defined (__UWIN__))
+
+extern int execv ();
+extern int execvp ();
+
+int
+pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
+ const char *program;
+ char * const *argv;
+ const char *this_pname;
+ const char *temp_base;
+ char **errmsg_fmt, **errmsg_arg;
+ int flags;
+{
+ int (*func)() = (flags & PEXECUTE_SEARCH ? execvp : execv);
+ int pid;
+ int pdes[2];
+ int input_desc, output_desc;
+ int retries, sleep_interval;
+ /* Pipe waiting from last process, to be used as input for the next one.
+ Value is STDIN_FILE_NO if no pipe is waiting
+ (i.e. the next command is the first of a group). */
+ static int last_pipe_input;
+
+ /* If this is the first process, initialize. */
+ if (flags & PEXECUTE_FIRST)
+ last_pipe_input = STDIN_FILE_NO;
+
+ input_desc = last_pipe_input;
+
+ /* If this isn't the last process, make a pipe for its output,
+ and record it as waiting to be the input to the next process. */
+ if (! (flags & PEXECUTE_LAST))
+ {
+ if (pipe (pdes) < 0)
+ {
+ *errmsg_fmt = "pipe";
+ *errmsg_arg = NULL;
+ return -1;
+ }
+ output_desc = pdes[WRITE_PORT];
+ last_pipe_input = pdes[READ_PORT];
+ }
+ else
+ {
+ /* Last process. */
+ output_desc = STDOUT_FILE_NO;
+ last_pipe_input = STDIN_FILE_NO;
+ }
+
+ /* Fork a subprocess; wait and retry if it fails. */
+ sleep_interval = 1;
+ for (retries = 0; retries < 4; retries++)
+ {
+ pid = vfork ();
+ if (pid >= 0)
+ break;
+ sleep (sleep_interval);
+ sleep_interval *= 2;
+ }
+
+ switch (pid)
+ {
+ case -1:
+ {
+ *errmsg_fmt = VFORK_STRING;
+ *errmsg_arg = NULL;
+ return -1;
+ }
+
+ case 0: /* child */
+ /* Move the input and output pipes into place, if necessary. */
+ if (input_desc != STDIN_FILE_NO)
+ {
+ close (STDIN_FILE_NO);
+ dup (input_desc);
+ close (input_desc);
+ }
+ if (output_desc != STDOUT_FILE_NO)
+ {
+ close (STDOUT_FILE_NO);
+ dup (output_desc);
+ close (output_desc);
+ }
+
+ /* Close the parent's descs that aren't wanted here. */
+ if (last_pipe_input != STDIN_FILE_NO)
+ close (last_pipe_input);
+
+ /* Exec the program. */
+ (*func) (program, argv);
+
+ /* Note: Calling fprintf and exit here doesn't seem right for vfork. */
+ fprintf (stderr, "%s: ", this_pname);
+ fprintf (stderr, install_error_msg, program);
+ fprintf (stderr, ": %s\n", xstrerror (errno));
+ exit (-1);
+ /* NOTREACHED */
+ return 0;
+
+ default:
+ /* In the parent, after forking.
+ Close the descriptors that we made for this child. */
+ if (input_desc != STDIN_FILE_NO)
+ close (input_desc);
+ if (output_desc != STDOUT_FILE_NO)
+ close (output_desc);
+
+ /* Return child's process number. */
+ return pid;
+ }
+}
+
+int
+pwait (pid, status, flags)
+ int pid;
+ int *status;
+ int flags;
+{
+ /* ??? Here's an opportunity to canonicalize the values in STATUS.
+ Needed? */
+#ifdef VMS
+ pid = waitpid (-1, status, 0);
+#else
+ pid = wait (status);
+#endif
+ return pid;
+}
+
+#endif /* ! __MSDOS__ && ! OS2 && ! MPW && ! (_WIN32 && ! __UWIN__) */
diff --git a/libiberty/random.c b/libiberty/random.c
new file mode 100644
index 00000000000..0a950709fce
--- /dev/null
+++ b/libiberty/random.c
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ * This is derived from the Berkeley source:
+ * @(#)random.c 5.5 (Berkeley) 7/6/88
+ * It was reworked for the GNU C Library by Roland McGrath.
+ */
+
+#include <errno.h>
+
+#if 0
+
+#include <ansidecl.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+#else
+
+#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */
+#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits*/
+
+#ifdef __STDC__
+# define PTR void *
+# ifndef NULL
+# define NULL (void *) 0
+# endif
+#else
+# define PTR char *
+# ifndef NULL
+# define NULL (void *) 0
+# endif
+#endif
+
+#endif
+
+long int random ();
+
+/* An improved random number generation package. In addition to the standard
+ rand()/srand() like interface, this package also has a special state info
+ interface. The initstate() routine is called with a seed, an array of
+ bytes, and a count of how many bytes are being passed in; this array is
+ then initialized to contain information for random number generation with
+ that much state information. Good sizes for the amount of state
+ information are 32, 64, 128, and 256 bytes. The state can be switched by
+ calling the setstate() function with the same array as was initiallized
+ with initstate(). By default, the package runs with 128 bytes of state
+ information and generates far better random numbers than a linear
+ congruential generator. If the amount of state information is less than
+ 32 bytes, a simple linear congruential R.N.G. is used. Internally, the
+ state information is treated as an array of longs; the zeroeth element of
+ the array is the type of R.N.G. being used (small integer); the remainder
+ of the array is the state information for the R.N.G. Thus, 32 bytes of
+ state information will give 7 longs worth of state information, which will
+ allow a degree seven polynomial. (Note: The zeroeth word of state
+ information also has some other information stored in it; see setstate
+ for details). The random number generation technique is a linear feedback
+ shift register approach, employing trinomials (since there are fewer terms
+ to sum up that way). In this approach, the least significant bit of all
+ the numbers in the state table will act as a linear feedback shift register,
+ and will have period 2^deg - 1 (where deg is the degree of the polynomial
+ being used, assuming that the polynomial is irreducible and primitive).
+ The higher order bits will have longer periods, since their values are
+ also influenced by pseudo-random carries out of the lower bits. The
+ total period of the generator is approximately deg*(2**deg - 1); thus
+ doubling the amount of state information has a vast influence on the
+ period of the generator. Note: The deg*(2**deg - 1) is an approximation
+ only good for large deg, when the period of the shift register is the
+ dominant factor. With deg equal to seven, the period is actually much
+ longer than the 7*(2**7 - 1) predicted by this formula. */
+
+
+
+/* For each of the currently supported random number generators, we have a
+ break value on the amount of state information (you need at least thi
+ bytes of state info to support this random number generator), a degree for
+ the polynomial (actually a trinomial) that the R.N.G. is based on, and
+ separation between the two lower order coefficients of the trinomial. */
+
+/* Linear congruential. */
+#define TYPE_0 0
+#define BREAK_0 8
+#define DEG_0 0
+#define SEP_0 0
+
+/* x**7 + x**3 + 1. */
+#define TYPE_1 1
+#define BREAK_1 32
+#define DEG_1 7
+#define SEP_1 3
+
+/* x**15 + x + 1. */
+#define TYPE_2 2
+#define BREAK_2 64
+#define DEG_2 15
+#define SEP_2 1
+
+/* x**31 + x**3 + 1. */
+#define TYPE_3 3
+#define BREAK_3 128
+#define DEG_3 31
+#define SEP_3 3
+
+/* x**63 + x + 1. */
+#define TYPE_4 4
+#define BREAK_4 256
+#define DEG_4 63
+#define SEP_4 1
+
+
+/* Array versions of the above information to make code run faster.
+ Relies on fact that TYPE_i == i. */
+
+#define MAX_TYPES 5 /* Max number of types above. */
+
+static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
+static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
+
+
+
+/* Initially, everything is set up as if from:
+ initstate(1, randtbl, 128);
+ Note that this initialization takes advantage of the fact that srandom
+ advances the front and rear pointers 10*rand_deg times, and hence the
+ rear pointer which starts at 0 will also end up at zero; thus the zeroeth
+ element of the state information, which contains info about the current
+ position of the rear pointer is just
+ (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */
+
+static long int randtbl[DEG_3 + 1] =
+ { TYPE_3,
+ 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342,
+ 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb,
+ 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
+ 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86,
+ 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7,
+ 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
+ 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b,
+ 0xf5ad9d0e, 0x8999220b, 0x27fb47b9
+ };
+
+/* FPTR and RPTR are two pointers into the state info, a front and a rear
+ pointer. These two pointers are always rand_sep places aparts, as they
+ cycle through the state information. (Yes, this does mean we could get
+ away with just one pointer, but the code for random is more efficient
+ this way). The pointers are left positioned as they would be from the call:
+ initstate(1, randtbl, 128);
+ (The position of the rear pointer, rptr, is really 0 (as explained above
+ in the initialization of randtbl) because the state table pointer is set
+ to point to randtbl[1] (as explained below).) */
+
+static long int *fptr = &randtbl[SEP_3 + 1];
+static long int *rptr = &randtbl[1];
+
+
+
+/* The following things are the pointer to the state information table,
+ the type of the current generator, the degree of the current polynomial
+ being used, and the separation between the two pointers.
+ Note that for efficiency of random, we remember the first location of
+ the state information, not the zeroeth. Hence it is valid to access
+ state[-1], which is used to store the type of the R.N.G.
+ Also, we remember the last location, since this is more efficient than
+ indexing every time to find the address of the last element to see if
+ the front and rear pointers have wrapped. */
+
+static long int *state = &randtbl[1];
+
+static int rand_type = TYPE_3;
+static int rand_deg = DEG_3;
+static int rand_sep = SEP_3;
+
+static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])];
+
+/* Initialize the random number generator based on the given seed. If the
+ type is the trivial no-state-information type, just remember the seed.
+ Otherwise, initializes state[] based on the given "seed" via a linear
+ congruential generator. Then, the pointers are set to known locations
+ that are exactly rand_sep places apart. Lastly, it cycles the state
+ information a given number of times to get rid of any initial dependencies
+ introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
+ for default usage relies on values produced by this routine. */
+void
+srandom (x)
+ unsigned int x;
+{
+ state[0] = x;
+ if (rand_type != TYPE_0)
+ {
+ register long int i;
+ for (i = 1; i < rand_deg; ++i)
+ state[i] = (1103515145 * state[i - 1]) + 12345;
+ fptr = &state[rand_sep];
+ rptr = &state[0];
+ for (i = 0; i < 10 * rand_deg; ++i)
+ random();
+ }
+}
+
+/* Initialize the state information in the given array of N bytes for
+ future random number generation. Based on the number of bytes we
+ are given, and the break values for the different R.N.G.'s, we choose
+ the best (largest) one we can and set things up for it. srandom is
+ then called to initialize the state information. Note that on return
+ from srandom, we set state[-1] to be the type multiplexed with the current
+ value of the rear pointer; this is so successive calls to initstate won't
+ lose this information and will be able to restart with setstate.
+ Note: The first thing we do is save the current state, if any, just like
+ setstate so that it doesn't matter when initstate is called.
+ Returns a pointer to the old state. */
+PTR
+initstate (seed, arg_state, n)
+ unsigned int seed;
+ PTR arg_state;
+ unsigned long n;
+{
+ PTR ostate = (PTR) &state[-1];
+
+ if (rand_type == TYPE_0)
+ state[-1] = rand_type;
+ else
+ state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
+ if (n < BREAK_1)
+ {
+ if (n < BREAK_0)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ rand_type = TYPE_0;
+ rand_deg = DEG_0;
+ rand_sep = SEP_0;
+ }
+ else if (n < BREAK_2)
+ {
+ rand_type = TYPE_1;
+ rand_deg = DEG_1;
+ rand_sep = SEP_1;
+ }
+ else if (n < BREAK_3)
+ {
+ rand_type = TYPE_2;
+ rand_deg = DEG_2;
+ rand_sep = SEP_2;
+ }
+ else if (n < BREAK_4)
+ {
+ rand_type = TYPE_3;
+ rand_deg = DEG_3;
+ rand_sep = SEP_3;
+ }
+ else
+ {
+ rand_type = TYPE_4;
+ rand_deg = DEG_4;
+ rand_sep = SEP_4;
+ }
+
+ state = &((long int *) arg_state)[1]; /* First location. */
+ /* Must set END_PTR before srandom. */
+ end_ptr = &state[rand_deg];
+ srandom(seed);
+ if (rand_type == TYPE_0)
+ state[-1] = rand_type;
+ else
+ state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
+
+ return ostate;
+}
+
+/* Restore the state from the given state array.
+ Note: It is important that we also remember the locations of the pointers
+ in the current state information, and restore the locations of the pointers
+ from the old state information. This is done by multiplexing the pointer
+ location into the zeroeth word of the state information. Note that due
+ to the order in which things are done, it is OK to call setstate with the
+ same state as the current state
+ Returns a pointer to the old state information. */
+
+PTR
+setstate (arg_state)
+ PTR arg_state;
+{
+ register long int *new_state = (long int *) arg_state;
+ register int type = new_state[0] % MAX_TYPES;
+ register int rear = new_state[0] / MAX_TYPES;
+ PTR ostate = (PTR) &state[-1];
+
+ if (rand_type == TYPE_0)
+ state[-1] = rand_type;
+ else
+ state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
+
+ switch (type)
+ {
+ case TYPE_0:
+ case TYPE_1:
+ case TYPE_2:
+ case TYPE_3:
+ case TYPE_4:
+ rand_type = type;
+ rand_deg = degrees[type];
+ rand_sep = seps[type];
+ break;
+ default:
+ /* State info munged. */
+ errno = EINVAL;
+ return NULL;
+ }
+
+ state = &new_state[1];
+ if (rand_type != TYPE_0)
+ {
+ rptr = &state[rear];
+ fptr = &state[(rear + rand_sep) % rand_deg];
+ }
+ /* Set end_ptr too. */
+ end_ptr = &state[rand_deg];
+
+ return ostate;
+}
+
+/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
+ same in all ther other cases due to all the global variables that have been
+ set up. The basic operation is to add the number at the rear pointer into
+ the one at the front pointer. Then both pointers are advanced to the next
+ location cyclically in the table. The value returned is the sum generated,
+ reduced to 31 bits by throwing away the "least random" low bit.
+ Note: The code takes advantage of the fact that both the front and
+ rear pointers can't wrap on the same call by not testing the rear
+ pointer if the front one has wrapped. Returns a 31-bit random number. */
+
+long int
+random ()
+{
+ if (rand_type == TYPE_0)
+ {
+ state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX;
+ return state[0];
+ }
+ else
+ {
+ long int i;
+ *fptr += *rptr;
+ /* Chucking least random bit. */
+ i = (*fptr >> 1) & LONG_MAX;
+ ++fptr;
+ if (fptr >= end_ptr)
+ {
+ fptr = state;
+ ++rptr;
+ }
+ else
+ {
+ ++rptr;
+ if (rptr >= end_ptr)
+ rptr = state;
+ }
+ return i;
+ }
+}
diff --git a/libiberty/rename.c b/libiberty/rename.c
new file mode 100644
index 00000000000..ae26e2d0040
--- /dev/null
+++ b/libiberty/rename.c
@@ -0,0 +1,22 @@
+/* rename -- rename a file
+ This function is in the public domain. */
+
+/* Rename a file. */
+
+#include <errno.h>
+
+int
+rename (zfrom, zto)
+ char *zfrom;
+ char *zto;
+{
+ if (link (zfrom, zto) < 0)
+ {
+ if (errno != EEXIST)
+ return -1;
+ if (unlink (zto) < 0
+ || link (zfrom, zto) < 0)
+ return -1;
+ }
+ return unlink (zfrom);
+}
diff --git a/libiberty/rindex.c b/libiberty/rindex.c
new file mode 100644
index 00000000000..061d1269f17
--- /dev/null
+++ b/libiberty/rindex.c
@@ -0,0 +1,11 @@
+/* Stub implementation of (obsolete) rindex(). */
+
+extern char *strrchr ();
+
+char *
+rindex (s, c)
+ char *s;
+ int c;
+{
+ return strrchr (s, c);
+}
diff --git a/libiberty/sigsetmask.c b/libiberty/sigsetmask.c
new file mode 100644
index 00000000000..2a09e6a6c5a
--- /dev/null
+++ b/libiberty/sigsetmask.c
@@ -0,0 +1,30 @@
+/* Version of sigsetmask.c
+ Written by Steve Chamberlain (sac@cygnus.com).
+ Contributed by Cygnus Support.
+ This file is in the public doamin. */
+
+/* Set the current signal mask to the set provided, and return the
+ previous value */
+
+#define _POSIX_SOURCE
+#include <ansidecl.h>
+/* Including <sys/types.h> seems to be needed by ISC. */
+#include <sys/types.h>
+#include <signal.h>
+
+#ifdef SIG_SETMASK
+int
+DEFUN(sigsetmask,(set),
+ int set)
+{
+ sigset_t new;
+ sigset_t old;
+
+ sigemptyset (&new);
+ if (set != 0) {
+ abort(); /* FIXME, we don't know how to translate old mask to new */
+ }
+ sigprocmask(SIG_SETMASK, &new, &old);
+ return 1; /* FIXME, we always return 1 as old value. */
+}
+#endif
diff --git a/libiberty/spaces.c b/libiberty/spaces.c
new file mode 100644
index 00000000000..ea925712e3f
--- /dev/null
+++ b/libiberty/spaces.c
@@ -0,0 +1,78 @@
+/* Allocate memory region filled with spaces.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/*
+
+NAME
+
+ spaces -- return a pointer to a buffer full of spaces
+
+SYNOPSIS
+
+ char *spaces (int count)
+
+DESCRIPTION
+
+ Returns a pointer to a memory region filled with the specified
+ number of spaces and null terminated. The returned pointer is
+ valid until at least the next call.
+
+BUGS
+
+*/
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#if VMS
+#include <stdlib.h>
+#include <unixlib.h>
+#else
+/* For systems with larger pointers than ints, these must be declared. */
+extern PTR malloc PARAMS ((size_t));
+extern void free PARAMS ((PTR));
+#endif
+
+const char *
+spaces (count)
+ int count;
+{
+ register char *t;
+ static char *buf;
+ static int maxsize;
+
+ if (count > maxsize)
+ {
+ if (buf)
+ {
+ free (buf);
+ }
+ buf = malloc (count + 1);
+ if (buf == (char *) 0)
+ return 0;
+ for (t = buf + count ; t != buf ; )
+ {
+ *--t = ' ';
+ }
+ maxsize = count;
+ buf[count] = '\0';
+ }
+ return (const char *) (buf + maxsize - count);
+}
+
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
new file mode 100644
index 00000000000..b6bb5a6a8f0
--- /dev/null
+++ b/libiberty/splay-tree.c
@@ -0,0 +1,368 @@
+/* A splay-tree datatype.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ Contributed by Mark Mitchell (mark@markmitchell.com).
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* For an easily readable description of splay-trees, see:
+
+ Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
+ Algorithms. Harper-Collins, Inc. 1991. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include "libiberty.h"
+#include "splay-tree.h"
+
+static void splay_tree_delete_helper PARAMS((splay_tree,
+ splay_tree_node));
+static void splay_tree_splay PARAMS((splay_tree,
+ splay_tree_key));
+static splay_tree_node splay_tree_splay_helper
+ PARAMS((splay_tree,
+ splay_tree_key,
+ splay_tree_node*,
+ splay_tree_node*,
+ splay_tree_node*));
+static int splay_tree_foreach_helper PARAMS((splay_tree,
+ splay_tree_node,
+ splay_tree_foreach_fn,
+ void*));
+
+/* Deallocate NODE (a member of SP), and all its sub-trees. */
+
+static void
+splay_tree_delete_helper (sp, node)
+ splay_tree sp;
+ splay_tree_node node;
+{
+ if (!node)
+ return;
+
+ splay_tree_delete_helper (sp, node->left);
+ splay_tree_delete_helper (sp, node->right);
+
+ if (sp->delete_key)
+ (*sp->delete_key)(node->key);
+ if (sp->delete_value)
+ (*sp->delete_value)(node->value);
+
+ free ((char*) node);
+}
+
+/* Help splay SP around KEY. PARENT and GRANDPARENT are the parent
+ and grandparent, respectively, of NODE. */
+
+static splay_tree_node
+splay_tree_splay_helper (sp, key, node, parent, grandparent)
+ splay_tree sp;
+ splay_tree_key key;
+ splay_tree_node *node;
+ splay_tree_node *parent;
+ splay_tree_node *grandparent;
+{
+ splay_tree_node *next;
+ splay_tree_node n;
+ int comparison;
+
+ n = *node;
+
+ if (!n)
+ return *parent;
+
+ comparison = (*sp->comp) (key, n->key);
+
+ if (comparison == 0)
+ /* We've found the target. */
+ next = 0;
+ else if (comparison < 0)
+ /* The target is to the left. */
+ next = &n->left;
+ else
+ /* The target is to the right. */
+ next = &n->right;
+
+ if (next)
+ {
+ /* Continue down the tree. */
+ n = splay_tree_splay_helper (sp, key, next, node, parent);
+
+ /* The recursive call will change the place to which NODE
+ points. */
+ if (*node != n)
+ return n;
+ }
+
+ if (!parent)
+ /* NODE is the root. We are done. */
+ return n;
+
+ /* First, handle the case where there is no grandparent (i.e.,
+ *PARENT is the root of the tree.) */
+ if (!grandparent)
+ {
+ if (n == (*parent)->left)
+ {
+ *node = n->right;
+ n->right = *parent;
+ }
+ else
+ {
+ *node = n->left;
+ n->left = *parent;
+ }
+ *parent = n;
+ return n;
+ }
+
+ /* Next handle the cases where both N and *PARENT are left children,
+ or where both are right children. */
+ if (n == (*parent)->left && *parent == (*grandparent)->left)
+ {
+ splay_tree_node p = *parent;
+
+ (*grandparent)->left = p->right;
+ p->right = *grandparent;
+ p->left = n->right;
+ n->right = p;
+ *grandparent = n;
+ return n;
+ }
+ else if (n == (*parent)->right && *parent == (*grandparent)->right)
+ {
+ splay_tree_node p = *parent;
+
+ (*grandparent)->right = p->left;
+ p->left = *grandparent;
+ p->right = n->left;
+ n->left = p;
+ *grandparent = n;
+ return n;
+ }
+
+ /* Finally, deal with the case where N is a left child, but *PARENT
+ is a right child, or vice versa. */
+ if (n == (*parent)->left)
+ {
+ (*parent)->left = n->right;
+ n->right = *parent;
+ (*grandparent)->right = n->left;
+ n->left = *grandparent;
+ *grandparent = n;
+ return n;
+ }
+ else
+ {
+ (*parent)->right = n->left;
+ n->left = *parent;
+ (*grandparent)->left = n->right;
+ n->right = *grandparent;
+ *grandparent = n;
+ return n;
+ }
+}
+
+/* Splay SP around KEY. */
+
+static void
+splay_tree_splay (sp, key)
+ splay_tree sp;
+ splay_tree_key key;
+{
+ if (sp->root == 0)
+ return;
+
+ splay_tree_splay_helper (sp, key, &sp->root,
+ /*grandparent=*/0, /*parent=*/0);
+}
+
+/* Call FN, passing it the DATA, for every node below NODE, all of
+ which are from SP, following an in-order traversal. If FN every
+ returns a non-zero value, the iteration ceases immediately, and the
+ value is returned. Otherwise, this function returns 0. */
+
+static int
+splay_tree_foreach_helper (sp, node, fn, data)
+ splay_tree sp;
+ splay_tree_node node;
+ splay_tree_foreach_fn fn;
+ void* data;
+{
+ int val;
+
+ if (!node)
+ return 0;
+
+ val = splay_tree_foreach_helper (sp, node->left, fn, data);
+ if (val)
+ return val;
+
+ val = (*fn)(node, data);
+ if (val)
+ return val;
+
+ return splay_tree_foreach_helper (sp, node->right, fn, data);
+}
+
+/* Allocate a new splay tree, using COMPARE_FN to compare nodes,
+ DELETE_KEY_FN to deallocate keys, and DELETE_VALUE_FN to deallocate
+ values. */
+
+splay_tree
+splay_tree_new (compare_fn, delete_key_fn, delete_value_fn)
+ splay_tree_compare_fn compare_fn;
+ splay_tree_delete_key_fn delete_key_fn;
+ splay_tree_delete_value_fn delete_value_fn;
+{
+ splay_tree sp = (splay_tree) xmalloc (sizeof (struct splay_tree));
+ sp->root = 0;
+ sp->comp = compare_fn;
+ sp->delete_key = delete_key_fn;
+ sp->delete_value = delete_value_fn;
+
+ return sp;
+}
+
+/* Deallocate SP. */
+
+void
+splay_tree_delete (sp)
+ splay_tree sp;
+{
+ splay_tree_delete_helper (sp, sp->root);
+ free ((char*) sp);
+}
+
+/* Insert a new node (associating KEY with DATA) into SP. If a
+ previous node with the indicated KEY exists, its data is replaced
+ with the new value. */
+
+void
+splay_tree_insert (sp, key, value)
+ splay_tree sp;
+ splay_tree_key key;
+ splay_tree_value value;
+{
+ int comparison;
+
+ splay_tree_splay (sp, key);
+
+ if (sp->root)
+ comparison = (*sp->comp)(sp->root->key, key);
+
+ if (sp->root && comparison == 0)
+ {
+ /* If the root of the tree already has the indicated KEY, just
+ replace the value with VALUE. */
+ if (sp->delete_value)
+ (*sp->delete_value)(sp->root->value);
+ sp->root->value = value;
+ }
+ else
+ {
+ /* Create a new node, and insert it at the root. */
+ splay_tree_node node;
+
+ node = (splay_tree_node) xmalloc (sizeof (struct splay_tree_node));
+ node->key = key;
+ node->value = value;
+
+ if (!sp->root)
+ node->left = node->right = 0;
+ else if (comparison < 0)
+ {
+ node->left = sp->root;
+ node->right = node->left->right;
+ node->left->right = 0;
+ }
+ else
+ {
+ node->right = sp->root;
+ node->left = node->right->left;
+ node->right->left = 0;
+ }
+
+ sp->root = node;
+ }
+}
+
+/* Lookup KEY in SP, returning VALUE if present, and NULL
+ otherwise. */
+
+splay_tree_node
+splay_tree_lookup (sp, key)
+ splay_tree sp;
+ splay_tree_key key;
+{
+ splay_tree_splay (sp, key);
+
+ if (sp->root && (*sp->comp)(sp->root->key, key) == 0)
+ return sp->root;
+ else
+ return 0;
+}
+
+/* Call FN, passing it the DATA, for every node in SP, following an
+ in-order traversal. If FN every returns a non-zero value, the
+ iteration ceases immediately, and the value is returned.
+ Otherwise, this function returns 0. */
+
+int
+splay_tree_foreach (sp, fn, data)
+ splay_tree sp;
+ splay_tree_foreach_fn fn;
+ void *data;
+{
+ return splay_tree_foreach_helper (sp, sp->root, fn, data);
+}
+
+/* Splay-tree comparison function, treating the keys as ints. */
+
+int
+splay_tree_compare_ints (k1, k2)
+ splay_tree_key k1;
+ splay_tree_key k2;
+{
+ if ((int) k1 < (int) k2)
+ return -1;
+ else if ((int) k1 > (int) k2)
+ return 1;
+ else
+ return 0;
+}
+
+/* Splay-tree comparison function, treating the keys as pointers. */
+
+int
+splay_tree_compare_pointers (k1, k2)
+ splay_tree_key k1;
+ splay_tree_key k2;
+{
+ if ((char*) k1 < (char*) k2)
+ return -1;
+ else if ((char*) k1 > (char*) k2)
+ return 1;
+ else
+ return 0;
+}
diff --git a/libiberty/strcasecmp.c b/libiberty/strcasecmp.c
new file mode 100644
index 00000000000..3aa930b696f
--- /dev/null
+++ b/libiberty/strcasecmp.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific written prior permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+/*
+ * This array is designed for mapping upper and lower case letter
+ * together for a case independent comparison. The mappings are
+ * based upon ascii character sequences.
+ */
+typedef unsigned char uc;
+static unsigned char charmap[] = {
+ (uc)'\000',(uc)'\001',(uc)'\002',(uc)'\003',(uc)'\004',(uc)'\005',(uc)'\006',(uc)'\007',
+ (uc)'\010',(uc)'\011',(uc)'\012',(uc)'\013',(uc)'\014',(uc)'\015',(uc)'\016',(uc)'\017',
+ (uc)'\020',(uc)'\021',(uc)'\022',(uc)'\023',(uc)'\024',(uc)'\025',(uc)'\026',(uc)'\027',
+ (uc)'\030',(uc)'\031',(uc)'\032',(uc)'\033',(uc)'\034',(uc)'\035',(uc)'\036',(uc)'\037',
+ (uc)'\040',(uc)'\041',(uc)'\042',(uc)'\043',(uc)'\044',(uc)'\045',(uc)'\046',(uc)'\047',
+ (uc)'\050',(uc)'\051',(uc)'\052',(uc)'\053',(uc)'\054',(uc)'\055',(uc)'\056',(uc)'\057',
+ (uc)'\060',(uc)'\061',(uc)'\062',(uc)'\063',(uc)'\064',(uc)'\065',(uc)'\066',(uc)'\067',
+ (uc)'\070',(uc)'\071',(uc)'\072',(uc)'\073',(uc)'\074',(uc)'\075',(uc)'\076',(uc)'\077',
+ (uc)'\100',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147',
+ (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157',
+ (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167',
+ (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\133',(uc)'\134',(uc)'\135',(uc)'\136',(uc)'\137',
+ (uc)'\140',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147',
+ (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157',
+ (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167',
+ (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\173',(uc)'\174',(uc)'\175',(uc)'\176',(uc)'\177',
+ (uc)'\200',(uc)'\201',(uc)'\202',(uc)'\203',(uc)'\204',(uc)'\205',(uc)'\206',(uc)'\207',
+ (uc)'\210',(uc)'\211',(uc)'\212',(uc)'\213',(uc)'\214',(uc)'\215',(uc)'\216',(uc)'\217',
+ (uc)'\220',(uc)'\221',(uc)'\222',(uc)'\223',(uc)'\224',(uc)'\225',(uc)'\226',(uc)'\227',
+ (uc)'\230',(uc)'\231',(uc)'\232',(uc)'\233',(uc)'\234',(uc)'\235',(uc)'\236',(uc)'\237',
+ (uc)'\240',(uc)'\241',(uc)'\242',(uc)'\243',(uc)'\244',(uc)'\245',(uc)'\246',(uc)'\247',
+ (uc)'\250',(uc)'\251',(uc)'\252',(uc)'\253',(uc)'\254',(uc)'\255',(uc)'\256',(uc)'\257',
+ (uc)'\260',(uc)'\261',(uc)'\262',(uc)'\263',(uc)'\264',(uc)'\265',(uc)'\266',(uc)'\267',
+ (uc)'\270',(uc)'\271',(uc)'\272',(uc)'\273',(uc)'\274',(uc)'\275',(uc)'\276',(uc)'\277',
+ (uc)'\300',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347',
+ (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357',
+ (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367',
+ (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\333',(uc)'\334',(uc)'\335',(uc)'\336',(uc)'\337',
+ (uc)'\340',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347',
+ (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357',
+ (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367',
+ (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\373',(uc)'\374',(uc)'\375',(uc)'\376',(uc)'\377',
+};
+
+int
+strcasecmp(s1, s2)
+ const char *s1, *s2;
+{
+ register unsigned char u1, u2;
+
+ for (;;) {
+ u1 = (unsigned char) *s1++;
+ u2 = (unsigned char) *s2++;
+ if (charmap[u1] != charmap[u2]) {
+ return charmap[u1] - charmap[u2];
+ }
+ if (u1 == '\0') {
+ return 0;
+ }
+ }
+}
+
diff --git a/libiberty/strchr.c b/libiberty/strchr.c
new file mode 100644
index 00000000000..550480f56de
--- /dev/null
+++ b/libiberty/strchr.c
@@ -0,0 +1,34 @@
+/* Portable version of strchr()
+ This function is in the public domain. */
+
+/*
+NAME
+ strchr -- return pointer to first occurance of a character
+
+SYNOPSIS
+ char *strchr (const char *s, int c)
+
+DESCRIPTION
+ Returns a pointer to the first occurance of character C in
+ string S, or a NULL pointer if no occurance is found.
+
+BUGS
+ Behavior when character is the null character is implementation
+ dependent.
+*/
+
+#include <ansidecl.h>
+
+char *
+strchr (s, c)
+ register const char *s;
+ int c;
+{
+ do {
+ if (*s == c)
+ {
+ return (char*)s;
+ }
+ } while (*s++);
+ return (0);
+}
diff --git a/libiberty/strdup.c b/libiberty/strdup.c
new file mode 100644
index 00000000000..1785b34f274
--- /dev/null
+++ b/libiberty/strdup.c
@@ -0,0 +1,10 @@
+char *
+strdup(s)
+ char *s;
+{
+ char *result = (char*)malloc(strlen(s) + 1);
+ if (result == (char*)0)
+ return (char*)0;
+ strcpy(result, s);
+ return result;
+}
diff --git a/libiberty/strerror.c b/libiberty/strerror.c
new file mode 100644
index 00000000000..644cc75462a
--- /dev/null
+++ b/libiberty/strerror.c
@@ -0,0 +1,831 @@
+/* Extended support for using errno values.
+ Written by Fred Fish. fnf@cygnus.com
+ This file is in the public domain. --Per Bothner. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#include "config.h"
+
+#ifdef HAVE_SYS_ERRLIST
+/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
+ might declare sys_errlist in a way that the compiler might consider
+ incompatible with our later declaration, perhaps by using const
+ attributes. So we hide the declaration in errno.h (if any) using a
+ macro. */
+#define sys_errlist sys_errlist__
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef HAVE_SYS_ERRLIST
+#undef sys_errlist
+#endif
+
+/* Routines imported from standard C runtime libraries. */
+
+#ifdef __STDC__
+#include <stddef.h>
+extern void *malloc (size_t size); /* 4.10.3.3 */
+extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
+#else /* !__STDC__ */
+extern char *malloc (); /* Standard memory allocater */
+extern char *memset ();
+#endif /* __STDC__ */
+
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+static void init_error_tables PARAMS ((void));
+
+/* Translation table for errno values. See intro(2) in most UNIX systems
+ Programmers Reference Manuals.
+
+ Note that this table is generally only accessed when it is used at runtime
+ to initialize errno name and message tables that are indexed by errno
+ value.
+
+ Not all of these errnos will exist on all systems. This table is the only
+ thing that should have to be updated as new error numbers are introduced.
+ It's sort of ugly, but at least its portable. */
+
+struct error_info
+{
+ int value; /* The numeric value from <errno.h> */
+ const char *name; /* The equivalent symbolic value */
+#ifndef HAVE_SYS_ERRLIST
+ const char *msg; /* Short message about this value */
+#endif
+};
+
+#ifndef HAVE_SYS_ERRLIST
+# define ENTRY(value, name, msg) {value, name, msg}
+#else
+# define ENTRY(value, name, msg) {value, name}
+#endif
+
+static const struct error_info error_table[] =
+{
+#if defined (EPERM)
+ ENTRY(EPERM, "EPERM", "Not owner"),
+#endif
+#if defined (ENOENT)
+ ENTRY(ENOENT, "ENOENT", "No such file or directory"),
+#endif
+#if defined (ESRCH)
+ ENTRY(ESRCH, "ESRCH", "No such process"),
+#endif
+#if defined (EINTR)
+ ENTRY(EINTR, "EINTR", "Interrupted system call"),
+#endif
+#if defined (EIO)
+ ENTRY(EIO, "EIO", "I/O error"),
+#endif
+#if defined (ENXIO)
+ ENTRY(ENXIO, "ENXIO", "No such device or address"),
+#endif
+#if defined (E2BIG)
+ ENTRY(E2BIG, "E2BIG", "Arg list too long"),
+#endif
+#if defined (ENOEXEC)
+ ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
+#endif
+#if defined (EBADF)
+ ENTRY(EBADF, "EBADF", "Bad file number"),
+#endif
+#if defined (ECHILD)
+ ENTRY(ECHILD, "ECHILD", "No child processes"),
+#endif
+#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */
+ ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
+#endif
+#if defined (EAGAIN)
+ ENTRY(EAGAIN, "EAGAIN", "No more processes"),
+#endif
+#if defined (ENOMEM)
+ ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
+#endif
+#if defined (EACCES)
+ ENTRY(EACCES, "EACCES", "Permission denied"),
+#endif
+#if defined (EFAULT)
+ ENTRY(EFAULT, "EFAULT", "Bad address"),
+#endif
+#if defined (ENOTBLK)
+ ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
+#endif
+#if defined (EBUSY)
+ ENTRY(EBUSY, "EBUSY", "Device busy"),
+#endif
+#if defined (EEXIST)
+ ENTRY(EEXIST, "EEXIST", "File exists"),
+#endif
+#if defined (EXDEV)
+ ENTRY(EXDEV, "EXDEV", "Cross-device link"),
+#endif
+#if defined (ENODEV)
+ ENTRY(ENODEV, "ENODEV", "No such device"),
+#endif
+#if defined (ENOTDIR)
+ ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
+#endif
+#if defined (EISDIR)
+ ENTRY(EISDIR, "EISDIR", "Is a directory"),
+#endif
+#if defined (EINVAL)
+ ENTRY(EINVAL, "EINVAL", "Invalid argument"),
+#endif
+#if defined (ENFILE)
+ ENTRY(ENFILE, "ENFILE", "File table overflow"),
+#endif
+#if defined (EMFILE)
+ ENTRY(EMFILE, "EMFILE", "Too many open files"),
+#endif
+#if defined (ENOTTY)
+ ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
+#endif
+#if defined (ETXTBSY)
+ ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
+#endif
+#if defined (EFBIG)
+ ENTRY(EFBIG, "EFBIG", "File too large"),
+#endif
+#if defined (ENOSPC)
+ ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
+#endif
+#if defined (ESPIPE)
+ ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
+#endif
+#if defined (EROFS)
+ ENTRY(EROFS, "EROFS", "Read-only file system"),
+#endif
+#if defined (EMLINK)
+ ENTRY(EMLINK, "EMLINK", "Too many links"),
+#endif
+#if defined (EPIPE)
+ ENTRY(EPIPE, "EPIPE", "Broken pipe"),
+#endif
+#if defined (EDOM)
+ ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
+#endif
+#if defined (ERANGE)
+ ENTRY(ERANGE, "ERANGE", "Math result not representable"),
+#endif
+#if defined (ENOMSG)
+ ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
+#endif
+#if defined (EIDRM)
+ ENTRY(EIDRM, "EIDRM", "Identifier removed"),
+#endif
+#if defined (ECHRNG)
+ ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
+#endif
+#if defined (EL2NSYNC)
+ ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
+#endif
+#if defined (EL3HLT)
+ ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
+#endif
+#if defined (EL3RST)
+ ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
+#endif
+#if defined (ELNRNG)
+ ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
+#endif
+#if defined (EUNATCH)
+ ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
+#endif
+#if defined (ENOCSI)
+ ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
+#endif
+#if defined (EL2HLT)
+ ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
+#endif
+#if defined (EDEADLK)
+ ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
+#endif
+#if defined (ENOLCK)
+ ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
+#endif
+#if defined (EBADE)
+ ENTRY(EBADE, "EBADE", "Invalid exchange"),
+#endif
+#if defined (EBADR)
+ ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
+#endif
+#if defined (EXFULL)
+ ENTRY(EXFULL, "EXFULL", "Exchange full"),
+#endif
+#if defined (ENOANO)
+ ENTRY(ENOANO, "ENOANO", "No anode"),
+#endif
+#if defined (EBADRQC)
+ ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
+#endif
+#if defined (EBADSLT)
+ ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
+#endif
+#if defined (EDEADLOCK)
+ ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
+#endif
+#if defined (EBFONT)
+ ENTRY(EBFONT, "EBFONT", "Bad font file format"),
+#endif
+#if defined (ENOSTR)
+ ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
+#endif
+#if defined (ENODATA)
+ ENTRY(ENODATA, "ENODATA", "No data available"),
+#endif
+#if defined (ETIME)
+ ENTRY(ETIME, "ETIME", "Timer expired"),
+#endif
+#if defined (ENOSR)
+ ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
+#endif
+#if defined (ENONET)
+ ENTRY(ENONET, "ENONET", "Machine is not on the network"),
+#endif
+#if defined (ENOPKG)
+ ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
+#endif
+#if defined (EREMOTE)
+ ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
+#endif
+#if defined (ENOLINK)
+ ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
+#endif
+#if defined (EADV)
+ ENTRY(EADV, "EADV", "Advertise error"),
+#endif
+#if defined (ESRMNT)
+ ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
+#endif
+#if defined (ECOMM)
+ ENTRY(ECOMM, "ECOMM", "Communication error on send"),
+#endif
+#if defined (EPROTO)
+ ENTRY(EPROTO, "EPROTO", "Protocol error"),
+#endif
+#if defined (EMULTIHOP)
+ ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
+#endif
+#if defined (EDOTDOT)
+ ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
+#endif
+#if defined (EBADMSG)
+ ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
+#endif
+#if defined (ENAMETOOLONG)
+ ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
+#endif
+#if defined (EOVERFLOW)
+ ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
+#endif
+#if defined (ENOTUNIQ)
+ ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
+#endif
+#if defined (EBADFD)
+ ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
+#endif
+#if defined (EREMCHG)
+ ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
+#endif
+#if defined (ELIBACC)
+ ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
+#endif
+#if defined (ELIBBAD)
+ ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
+#endif
+#if defined (ELIBSCN)
+ ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
+#endif
+#if defined (ELIBMAX)
+ ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
+#endif
+#if defined (ELIBEXEC)
+ ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
+#endif
+#if defined (EILSEQ)
+ ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
+#endif
+#if defined (ENOSYS)
+ ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
+#endif
+#if defined (ELOOP)
+ ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
+#endif
+#if defined (ERESTART)
+ ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
+#endif
+#if defined (ESTRPIPE)
+ ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
+#endif
+#if defined (ENOTEMPTY)
+ ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
+#endif
+#if defined (EUSERS)
+ ENTRY(EUSERS, "EUSERS", "Too many users"),
+#endif
+#if defined (ENOTSOCK)
+ ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
+#endif
+#if defined (EDESTADDRREQ)
+ ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
+#endif
+#if defined (EMSGSIZE)
+ ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
+#endif
+#if defined (EPROTOTYPE)
+ ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
+#endif
+#if defined (ENOPROTOOPT)
+ ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
+#endif
+#if defined (EPROTONOSUPPORT)
+ ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
+#endif
+#if defined (ESOCKTNOSUPPORT)
+ ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
+#endif
+#if defined (EOPNOTSUPP)
+ ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
+#endif
+#if defined (EPFNOSUPPORT)
+ ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
+#endif
+#if defined (EAFNOSUPPORT)
+ ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
+#endif
+#if defined (EADDRINUSE)
+ ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
+#endif
+#if defined (EADDRNOTAVAIL)
+ ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
+#endif
+#if defined (ENETDOWN)
+ ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
+#endif
+#if defined (ENETUNREACH)
+ ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
+#endif
+#if defined (ENETRESET)
+ ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
+#endif
+#if defined (ECONNABORTED)
+ ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
+#endif
+#if defined (ECONNRESET)
+ ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
+#endif
+#if defined (ENOBUFS)
+ ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
+#endif
+#if defined (EISCONN)
+ ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
+#endif
+#if defined (ENOTCONN)
+ ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
+#endif
+#if defined (ESHUTDOWN)
+ ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
+#endif
+#if defined (ETOOMANYREFS)
+ ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
+#endif
+#if defined (ETIMEDOUT)
+ ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
+#endif
+#if defined (ECONNREFUSED)
+ ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
+#endif
+#if defined (EHOSTDOWN)
+ ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
+#endif
+#if defined (EHOSTUNREACH)
+ ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
+#endif
+#if defined (EALREADY)
+ ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
+#endif
+#if defined (EINPROGRESS)
+ ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
+#endif
+#if defined (ESTALE)
+ ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
+#endif
+#if defined (EUCLEAN)
+ ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
+#endif
+#if defined (ENOTNAM)
+ ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
+#endif
+#if defined (ENAVAIL)
+ ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
+#endif
+#if defined (EISNAM)
+ ENTRY(EISNAM, "EISNAM", "Is a named type file"),
+#endif
+#if defined (EREMOTEIO)
+ ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
+#endif
+ ENTRY(0, NULL, NULL)
+};
+
+#ifdef EVMSERR
+/* This is not in the table, because the numeric value of EVMSERR (32767)
+ lies outside the range of sys_errlist[]. */
+static struct { int value; const char *name, *msg; }
+ evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" };
+#endif
+
+/* Translation table allocated and initialized at runtime. Indexed by the
+ errno value to find the equivalent symbolic value. */
+
+static const char **error_names;
+static int num_error_names = 0;
+
+/* Translation table allocated and initialized at runtime, if it does not
+ already exist in the host environment. Indexed by the errno value to find
+ the descriptive string.
+
+ We don't export it for use in other modules because even though it has the
+ same name, it differs from other implementations in that it is dynamically
+ initialized rather than statically initialized. */
+
+#ifndef HAVE_SYS_ERRLIST
+
+static int sys_nerr;
+static const char **sys_errlist;
+
+#else
+
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+#endif
+
+
+/*
+
+NAME
+
+ init_error_tables -- initialize the name and message tables
+
+SYNOPSIS
+
+ static void init_error_tables ();
+
+DESCRIPTION
+
+ Using the error_table, which is initialized at compile time, generate
+ the error_names and the sys_errlist (if needed) tables, which are
+ indexed at runtime by a specific errno value.
+
+BUGS
+
+ The initialization of the tables may fail under low memory conditions,
+ in which case we don't do anything particularly useful, but we don't
+ bomb either. Who knows, it might succeed at a later point if we free
+ some memory in the meantime. In any case, the other routines know
+ how to deal with lack of a table after trying to initialize it. This
+ may or may not be considered to be a bug, that we don't specifically
+ warn about this particular failure mode.
+
+*/
+
+static void
+init_error_tables ()
+{
+ const struct error_info *eip;
+ int nbytes;
+
+ /* If we haven't already scanned the error_table once to find the maximum
+ errno value, then go find it now. */
+
+ if (num_error_names == 0)
+ {
+ for (eip = error_table; eip -> name != NULL; eip++)
+ {
+ if (eip -> value >= num_error_names)
+ {
+ num_error_names = eip -> value + 1;
+ }
+ }
+ }
+
+ /* Now attempt to allocate the error_names table, zero it out, and then
+ initialize it from the statically initialized error_table. */
+
+ if (error_names == NULL)
+ {
+ nbytes = num_error_names * sizeof (char *);
+ if ((error_names = (const char **) malloc (nbytes)) != NULL)
+ {
+ memset (error_names, 0, nbytes);
+ for (eip = error_table; eip -> name != NULL; eip++)
+ {
+ error_names[eip -> value] = eip -> name;
+ }
+ }
+ }
+
+#ifndef HAVE_SYS_ERRLIST
+
+ /* Now attempt to allocate the sys_errlist table, zero it out, and then
+ initialize it from the statically initialized error_table. */
+
+ if (sys_errlist == NULL)
+ {
+ nbytes = num_error_names * sizeof (char *);
+ if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
+ {
+ memset (sys_errlist, 0, nbytes);
+ sys_nerr = num_error_names;
+ for (eip = error_table; eip -> name != NULL; eip++)
+ {
+ sys_errlist[eip -> value] = eip -> msg;
+ }
+ }
+ }
+
+#endif
+
+}
+
+/*
+
+NAME
+
+ errno_max -- return the max errno value
+
+SYNOPSIS
+
+ int errno_max ();
+
+DESCRIPTION
+
+ Returns the maximum errno value for which a corresponding symbolic
+ name or message is available. Note that in the case where
+ we use the sys_errlist supplied by the system, it is possible for
+ there to be more symbolic names than messages, or vice versa.
+ In fact, the manual page for perror(3C) explicitly warns that one
+ should check the size of the table (sys_nerr) before indexing it,
+ since new error codes may be added to the system before they are
+ added to the table. Thus sys_nerr might be smaller than value
+ implied by the largest errno value defined in <errno.h>.
+
+ We return the maximum value that can be used to obtain a meaningful
+ symbolic name or message.
+
+*/
+
+int
+errno_max ()
+{
+ int maxsize;
+
+ if (error_names == NULL)
+ {
+ init_error_tables ();
+ }
+ maxsize = MAX (sys_nerr, num_error_names);
+ return (maxsize - 1);
+}
+
+#ifndef HAVE_STRERROR
+
+/*
+
+NAME
+
+ strerror -- map an error number to an error message string
+
+SYNOPSIS
+
+ char *strerror (int errnoval)
+
+DESCRIPTION
+
+ Maps an errno number to an error message string, the contents of
+ which are implementation defined. On systems which have the external
+ variables sys_nerr and sys_errlist, these strings will be the same
+ as the ones used by perror().
+
+ If the supplied error number is within the valid range of indices
+ for the sys_errlist, but no message is available for the particular
+ error number, then returns the string "Error NUM", where NUM is the
+ error number.
+
+ If the supplied error number is not a valid index into sys_errlist,
+ returns NULL.
+
+ The returned string is only guaranteed to be valid only until the
+ next call to strerror.
+
+*/
+
+char *
+strerror (errnoval)
+ int errnoval;
+{
+ char *msg;
+ static char buf[32];
+
+#ifndef HAVE_SYS_ERRLIST
+
+ if (error_names == NULL)
+ {
+ init_error_tables ();
+ }
+
+#endif
+
+ if ((errnoval < 0) || (errnoval >= sys_nerr))
+ {
+#ifdef EVMSERR
+ if (errnoval == evmserr.value)
+ msg = evmserr.msg;
+ else
+#endif
+ /* Out of range, just return NULL */
+ msg = NULL;
+ }
+ else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
+ {
+ /* In range, but no sys_errlist or no entry at this index. */
+ sprintf (buf, "Error %d", errnoval);
+ msg = buf;
+ }
+ else
+ {
+ /* In range, and a valid message. Just return the message. */
+ msg = (char *) sys_errlist[errnoval];
+ }
+
+ return (msg);
+}
+
+#endif /* ! HAVE_STRERROR */
+
+
+/*
+
+NAME
+
+ strerrno -- map an error number to a symbolic name string
+
+SYNOPSIS
+
+ const char *strerrno (int errnoval)
+
+DESCRIPTION
+
+ Given an error number returned from a system call (typically
+ returned in errno), returns a pointer to a string containing the
+ symbolic name of that error number, as found in <errno.h>.
+
+ If the supplied error number is within the valid range of indices
+ for symbolic names, but no name is available for the particular
+ error number, then returns the string "Error NUM", where NUM is
+ the error number.
+
+ If the supplied error number is not within the range of valid
+ indices, then returns NULL.
+
+BUGS
+
+ The contents of the location pointed to are only guaranteed to be
+ valid until the next call to strerrno.
+
+*/
+
+const char *
+strerrno (errnoval)
+ int errnoval;
+{
+ const char *name;
+ static char buf[32];
+
+ if (error_names == NULL)
+ {
+ init_error_tables ();
+ }
+
+ if ((errnoval < 0) || (errnoval >= num_error_names))
+ {
+#ifdef EVMSERR
+ if (errnoval == evmserr.value)
+ name = evmserr.name;
+ else
+#endif
+ /* Out of range, just return NULL */
+ name = NULL;
+ }
+ else if ((error_names == NULL) || (error_names[errnoval] == NULL))
+ {
+ /* In range, but no error_names or no entry at this index. */
+ sprintf (buf, "Error %d", errnoval);
+ name = (const char *) buf;
+ }
+ else
+ {
+ /* In range, and a valid name. Just return the name. */
+ name = error_names[errnoval];
+ }
+
+ return (name);
+}
+
+/*
+
+NAME
+
+ strtoerrno -- map a symbolic errno name to a numeric value
+
+SYNOPSIS
+
+ int strtoerrno (char *name)
+
+DESCRIPTION
+
+ Given the symbolic name of a error number, map it to an errno value.
+ If no translation is found, returns 0.
+
+*/
+
+int
+strtoerrno (name)
+ const char *name;
+{
+ int errnoval = 0;
+
+ if (name != NULL)
+ {
+ if (error_names == NULL)
+ {
+ init_error_tables ();
+ }
+ for (errnoval = 0; errnoval < num_error_names; errnoval++)
+ {
+ if ((error_names[errnoval] != NULL) &&
+ (strcmp (name, error_names[errnoval]) == 0))
+ {
+ break;
+ }
+ }
+ if (errnoval == num_error_names)
+ {
+#ifdef EVMSERR
+ if (strcmp (name, evmserr.name) == 0)
+ errnoval = evmserr.value;
+ else
+#endif
+ errnoval = 0;
+ }
+ }
+ return (errnoval);
+}
+
+
+/* A simple little main that does nothing but print all the errno translations
+ if MAIN is defined and this file is compiled and linked. */
+
+#ifdef MAIN
+
+#include <stdio.h>
+
+int
+main ()
+{
+ int errn;
+ int errnmax;
+ const char *name;
+ char *msg;
+ char *strerror ();
+
+ errnmax = errno_max ();
+ printf ("%d entries in names table.\n", num_error_names);
+ printf ("%d entries in messages table.\n", sys_nerr);
+ printf ("%d is max useful index.\n", errnmax);
+
+ /* Keep printing values until we get to the end of *both* tables, not
+ *either* table. Note that knowing the maximum useful index does *not*
+ relieve us of the responsibility of testing the return pointer for
+ NULL. */
+
+ for (errn = 0; errn <= errnmax; errn++)
+ {
+ name = strerrno (errn);
+ name = (name == NULL) ? "<NULL>" : name;
+ msg = strerror (errn);
+ msg = (msg == NULL) ? "<NULL>" : msg;
+ printf ("%-4d%-18s%s\n", errn, name, msg);
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/libiberty/strncasecmp.c b/libiberty/strncasecmp.c
new file mode 100644
index 00000000000..4485cac7a6a
--- /dev/null
+++ b/libiberty/strncasecmp.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific written prior permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ansidecl.h>
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+/*
+ * This array is designed for mapping upper and lower case letter
+ * together for a case independent comparison. The mappings are
+ * based upon ascii character sequences.
+ */
+static unsigned char charmap[] = {
+ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
+ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
+ '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+ '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+ '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+ '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+ '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+ '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+ '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+ '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+ '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+ '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+ '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+ '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
+ '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+ '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+ '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+ '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
+};
+
+int
+strncasecmp(s1, s2, n)
+ const char *s1, *s2;
+ register size_t n;
+{
+ register unsigned char u1, u2;
+
+ for (; n != 0; --n) {
+ u1 = (unsigned char) *s1++;
+ u2 = (unsigned char) *s2++;
+ if (charmap[u1] != charmap[u2]) {
+ return charmap[u1] - charmap[u2];
+ }
+ if (u1 == '\0') {
+ return 0;
+ }
+ }
+ return 0;
+}
diff --git a/libiberty/strrchr.c b/libiberty/strrchr.c
new file mode 100644
index 00000000000..8c05bcbead8
--- /dev/null
+++ b/libiberty/strrchr.c
@@ -0,0 +1,34 @@
+/* Portable version of strrchr().
+ This function is in the public domain. */
+
+/*
+NAME
+ strrchr -- return pointer to last occurance of a character
+
+SYNOPSIS
+ char *strrchr (const char *s, int c)
+
+DESCRIPTION
+ Returns a pointer to the last occurance of character C in
+ string S, or a NULL pointer if no occurance is found.
+
+BUGS
+ Behavior when character is the null character is implementation
+ dependent.
+*/
+
+#include <ansidecl.h>
+
+char *
+strrchr (s, c)
+ register const char *s;
+ int c;
+{
+ char *rtnval = 0;
+
+ do {
+ if (*s == c)
+ rtnval = (char*) s;
+ } while (*s++);
+ return (rtnval);
+}
diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c
new file mode 100644
index 00000000000..c7bb10c441c
--- /dev/null
+++ b/libiberty/strsignal.c
@@ -0,0 +1,644 @@
+/* Extended support for using signal values.
+ Written by Fred Fish. fnf@cygnus.com
+ This file is in the public domain. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#include "config.h"
+
+/* We need to declare sys_siglist, because even if the system provides
+ it we can't assume that it is declared in <signal.h> (for example,
+ SunOS provides sys_siglist, but it does not declare it in any
+ header file). fHowever, we can't declare sys_siglist portably,
+ because on some systems it is declared with const and on some
+ systems it is declared without const. If we were using autoconf,
+ we could work out the right declaration. Until, then we just
+ ignore any declaration in the system header files, and always
+ declare it ourselves. With luck, this will always work. */
+#define sys_siglist no_such_symbol
+
+#include <stdio.h>
+#include <signal.h>
+
+/* Routines imported from standard C runtime libraries. */
+
+#ifdef __STDC__
+#include <stddef.h>
+extern void *malloc (size_t size); /* 4.10.3.3 */
+extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
+#else /* !__STDC__ */
+extern char *malloc (); /* Standard memory allocater */
+extern char *memset ();
+#endif /* __STDC__ */
+
+/* Undefine the macro we used to hide the definition of sys_siglist
+ found in the system header files. */
+#undef sys_siglist
+
+#ifndef NULL
+# ifdef __STDC__
+# define NULL (void *) 0
+# else
+# define NULL 0
+# endif
+#endif
+
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+static void init_signal_tables PARAMS ((void));
+
+/* Translation table for signal values.
+
+ Note that this table is generally only accessed when it is used at runtime
+ to initialize signal name and message tables that are indexed by signal
+ value.
+
+ Not all of these signals will exist on all systems. This table is the only
+ thing that should have to be updated as new signal numbers are introduced.
+ It's sort of ugly, but at least its portable. */
+
+struct signal_info
+{
+ int value; /* The numeric value from <signal.h> */
+ const char *name; /* The equivalent symbolic value */
+#ifndef HAVE_SYS_SIGLIST
+ const char *msg; /* Short message about this value */
+#endif
+};
+
+#ifndef HAVE_SYS_SIGLIST
+# define ENTRY(value, name, msg) {value, name, msg}
+#else
+# define ENTRY(value, name, msg) {value, name}
+#endif
+
+static const struct signal_info signal_table[] =
+{
+#if defined (SIGHUP)
+ ENTRY(SIGHUP, "SIGHUP", "Hangup"),
+#endif
+#if defined (SIGINT)
+ ENTRY(SIGINT, "SIGINT", "Interrupt"),
+#endif
+#if defined (SIGQUIT)
+ ENTRY(SIGQUIT, "SIGQUIT", "Quit"),
+#endif
+#if defined (SIGILL)
+ ENTRY(SIGILL, "SIGILL", "Illegal instruction"),
+#endif
+#if defined (SIGTRAP)
+ ENTRY(SIGTRAP, "SIGTRAP", "Trace/breakpoint trap"),
+#endif
+/* Put SIGIOT before SIGABRT, so that if SIGIOT==SIGABRT then SIGABRT
+ overrides SIGIOT. SIGABRT is in ANSI and POSIX.1, and SIGIOT isn't. */
+#if defined (SIGIOT)
+ ENTRY(SIGIOT, "SIGIOT", "IOT trap"),
+#endif
+#if defined (SIGABRT)
+ ENTRY(SIGABRT, "SIGABRT", "Aborted"),
+#endif
+#if defined (SIGEMT)
+ ENTRY(SIGEMT, "SIGEMT", "Emulation trap"),
+#endif
+#if defined (SIGFPE)
+ ENTRY(SIGFPE, "SIGFPE", "Arithmetic exception"),
+#endif
+#if defined (SIGKILL)
+ ENTRY(SIGKILL, "SIGKILL", "Killed"),
+#endif
+#if defined (SIGBUS)
+ ENTRY(SIGBUS, "SIGBUS", "Bus error"),
+#endif
+#if defined (SIGSEGV)
+ ENTRY(SIGSEGV, "SIGSEGV", "Segmentation fault"),
+#endif
+#if defined (SIGSYS)
+ ENTRY(SIGSYS, "SIGSYS", "Bad system call"),
+#endif
+#if defined (SIGPIPE)
+ ENTRY(SIGPIPE, "SIGPIPE", "Broken pipe"),
+#endif
+#if defined (SIGALRM)
+ ENTRY(SIGALRM, "SIGALRM", "Alarm clock"),
+#endif
+#if defined (SIGTERM)
+ ENTRY(SIGTERM, "SIGTERM", "Terminated"),
+#endif
+#if defined (SIGUSR1)
+ ENTRY(SIGUSR1, "SIGUSR1", "User defined signal 1"),
+#endif
+#if defined (SIGUSR2)
+ ENTRY(SIGUSR2, "SIGUSR2", "User defined signal 2"),
+#endif
+/* Put SIGCLD before SIGCHLD, so that if SIGCLD==SIGCHLD then SIGCHLD
+ overrides SIGCLD. SIGCHLD is in POXIX.1 */
+#if defined (SIGCLD)
+ ENTRY(SIGCLD, "SIGCLD", "Child status changed"),
+#endif
+#if defined (SIGCHLD)
+ ENTRY(SIGCHLD, "SIGCHLD", "Child status changed"),
+#endif
+#if defined (SIGPWR)
+ ENTRY(SIGPWR, "SIGPWR", "Power fail/restart"),
+#endif
+#if defined (SIGWINCH)
+ ENTRY(SIGWINCH, "SIGWINCH", "Window size changed"),
+#endif
+#if defined (SIGURG)
+ ENTRY(SIGURG, "SIGURG", "Urgent I/O condition"),
+#endif
+#if defined (SIGIO)
+ /* "I/O pending" has also been suggested, but is misleading since the
+ signal only happens when the process has asked for it, not everytime
+ I/O is pending. */
+ ENTRY(SIGIO, "SIGIO", "I/O possible"),
+#endif
+#if defined (SIGPOLL)
+ ENTRY(SIGPOLL, "SIGPOLL", "Pollable event occurred"),
+#endif
+#if defined (SIGSTOP)
+ ENTRY(SIGSTOP, "SIGSTOP", "Stopped (signal)"),
+#endif
+#if defined (SIGTSTP)
+ ENTRY(SIGTSTP, "SIGTSTP", "Stopped (user)"),
+#endif
+#if defined (SIGCONT)
+ ENTRY(SIGCONT, "SIGCONT", "Continued"),
+#endif
+#if defined (SIGTTIN)
+ ENTRY(SIGTTIN, "SIGTTIN", "Stopped (tty input)"),
+#endif
+#if defined (SIGTTOU)
+ ENTRY(SIGTTOU, "SIGTTOU", "Stopped (tty output)"),
+#endif
+#if defined (SIGVTALRM)
+ ENTRY(SIGVTALRM, "SIGVTALRM", "Virtual timer expired"),
+#endif
+#if defined (SIGPROF)
+ ENTRY(SIGPROF, "SIGPROF", "Profiling timer expired"),
+#endif
+#if defined (SIGXCPU)
+ ENTRY(SIGXCPU, "SIGXCPU", "CPU time limit exceeded"),
+#endif
+#if defined (SIGXFSZ)
+ ENTRY(SIGXFSZ, "SIGXFSZ", "File size limit exceeded"),
+#endif
+#if defined (SIGWIND)
+ ENTRY(SIGWIND, "SIGWIND", "SIGWIND"),
+#endif
+#if defined (SIGPHONE)
+ ENTRY(SIGPHONE, "SIGPHONE", "SIGPHONE"),
+#endif
+#if defined (SIGLOST)
+ ENTRY(SIGLOST, "SIGLOST", "Resource lost"),
+#endif
+#if defined (SIGWAITING)
+ ENTRY(SIGWAITING, "SIGWAITING", "Process's LWPs are blocked"),
+#endif
+#if defined (SIGLWP)
+ ENTRY(SIGLWP, "SIGLWP", "Signal LWP"),
+#endif
+#if defined (SIGDANGER)
+ ENTRY(SIGDANGER, "SIGDANGER", "Swap space dangerously low"),
+#endif
+#if defined (SIGGRANT)
+ ENTRY(SIGGRANT, "SIGGRANT", "Monitor mode granted"),
+#endif
+#if defined (SIGRETRACT)
+ ENTRY(SIGRETRACT, "SIGRETRACT", "Need to relinguish monitor mode"),
+#endif
+#if defined (SIGMSG)
+ ENTRY(SIGMSG, "SIGMSG", "Monitor mode data available"),
+#endif
+#if defined (SIGSOUND)
+ ENTRY(SIGSOUND, "SIGSOUND", "Sound completed"),
+#endif
+#if defined (SIGSAK)
+ ENTRY(SIGSAK, "SIGSAK", "Secure attention"),
+#endif
+ ENTRY(0, NULL, NULL)
+};
+
+/* Translation table allocated and initialized at runtime. Indexed by the
+ signal value to find the equivalent symbolic value. */
+
+static const char **signal_names;
+static int num_signal_names = 0;
+
+/* Translation table allocated and initialized at runtime, if it does not
+ already exist in the host environment. Indexed by the signal value to find
+ the descriptive string.
+
+ We don't export it for use in other modules because even though it has the
+ same name, it differs from other implementations in that it is dynamically
+ initialized rather than statically initialized. */
+
+#ifndef HAVE_SYS_SIGLIST
+
+static int sys_nsig;
+static const char **sys_siglist;
+
+#else
+
+#ifdef NSIG
+static int sys_nsig = NSIG;
+#else
+#ifdef _NSIG
+static int sys_nsig = _NSIG;
+#endif
+#endif
+extern const char * const sys_siglist[];
+
+#endif
+
+
+/*
+
+NAME
+
+ init_signal_tables -- initialize the name and message tables
+
+SYNOPSIS
+
+ static void init_signal_tables ();
+
+DESCRIPTION
+
+ Using the signal_table, which is initialized at compile time, generate
+ the signal_names and the sys_siglist (if needed) tables, which are
+ indexed at runtime by a specific signal value.
+
+BUGS
+
+ The initialization of the tables may fail under low memory conditions,
+ in which case we don't do anything particularly useful, but we don't
+ bomb either. Who knows, it might succeed at a later point if we free
+ some memory in the meantime. In any case, the other routines know
+ how to deal with lack of a table after trying to initialize it. This
+ may or may not be considered to be a bug, that we don't specifically
+ warn about this particular failure mode.
+
+*/
+
+static void
+init_signal_tables ()
+{
+ const struct signal_info *eip;
+ int nbytes;
+
+ /* If we haven't already scanned the signal_table once to find the maximum
+ signal value, then go find it now. */
+
+ if (num_signal_names == 0)
+ {
+ for (eip = signal_table; eip -> name != NULL; eip++)
+ {
+ if (eip -> value >= num_signal_names)
+ {
+ num_signal_names = eip -> value + 1;
+ }
+ }
+ }
+
+ /* Now attempt to allocate the signal_names table, zero it out, and then
+ initialize it from the statically initialized signal_table. */
+
+ if (signal_names == NULL)
+ {
+ nbytes = num_signal_names * sizeof (char *);
+ if ((signal_names = (const char **) malloc (nbytes)) != NULL)
+ {
+ memset (signal_names, 0, nbytes);
+ for (eip = signal_table; eip -> name != NULL; eip++)
+ {
+ signal_names[eip -> value] = eip -> name;
+ }
+ }
+ }
+
+#ifndef HAVE_SYS_SIGLIST
+
+ /* Now attempt to allocate the sys_siglist table, zero it out, and then
+ initialize it from the statically initialized signal_table. */
+
+ if (sys_siglist == NULL)
+ {
+ nbytes = num_signal_names * sizeof (char *);
+ if ((sys_siglist = (const char **) malloc (nbytes)) != NULL)
+ {
+ memset (sys_siglist, 0, nbytes);
+ sys_nsig = num_signal_names;
+ for (eip = signal_table; eip -> name != NULL; eip++)
+ {
+ sys_siglist[eip -> value] = eip -> msg;
+ }
+ }
+ }
+
+#endif
+
+}
+
+
+/*
+
+NAME
+
+ signo_max -- return the max signo value
+
+SYNOPSIS
+
+ int signo_max ();
+
+DESCRIPTION
+
+ Returns the maximum signo value for which a corresponding symbolic
+ name or message is available. Note that in the case where
+ we use the sys_siglist supplied by the system, it is possible for
+ there to be more symbolic names than messages, or vice versa.
+ In fact, the manual page for psignal(3b) explicitly warns that one
+ should check the size of the table (NSIG) before indexing it,
+ since new signal codes may be added to the system before they are
+ added to the table. Thus NSIG might be smaller than value
+ implied by the largest signo value defined in <signal.h>.
+
+ We return the maximum value that can be used to obtain a meaningful
+ symbolic name or message.
+
+*/
+
+int
+signo_max ()
+{
+ int maxsize;
+
+ if (signal_names == NULL)
+ {
+ init_signal_tables ();
+ }
+ maxsize = MAX (sys_nsig, num_signal_names);
+ return (maxsize - 1);
+}
+
+
+/*
+
+NAME
+
+ strsignal -- map a signal number to a signal message string
+
+SYNOPSIS
+
+ const char *strsignal (int signo)
+
+DESCRIPTION
+
+ Maps an signal number to an signal message string, the contents of
+ which are implementation defined. On systems which have the external
+ variable sys_siglist, these strings will be the same as the ones used
+ by psignal().
+
+ If the supplied signal number is within the valid range of indices
+ for the sys_siglist, but no message is available for the particular
+ signal number, then returns the string "Signal NUM", where NUM is the
+ signal number.
+
+ If the supplied signal number is not a valid index into sys_siglist,
+ returns NULL.
+
+ The returned string is only guaranteed to be valid only until the
+ next call to strsignal.
+
+*/
+
+#ifndef HAVE_STRSIGNAL
+
+const char *
+strsignal (signo)
+ int signo;
+{
+ const char *msg;
+ static char buf[32];
+
+#ifndef HAVE_SYS_SIGLIST
+
+ if (signal_names == NULL)
+ {
+ init_signal_tables ();
+ }
+
+#endif
+
+ if ((signo < 0) || (signo >= sys_nsig))
+ {
+ /* Out of range, just return NULL */
+ msg = NULL;
+ }
+ else if ((sys_siglist == NULL) || (sys_siglist[signo] == NULL))
+ {
+ /* In range, but no sys_siglist or no entry at this index. */
+ sprintf (buf, "Signal %d", signo);
+ msg = (const char *) buf;
+ }
+ else
+ {
+ /* In range, and a valid message. Just return the message. */
+ msg = (const char *) sys_siglist[signo];
+ }
+
+ return (msg);
+}
+
+#endif /* ! HAVE_STRSIGNAL */
+
+/*
+
+NAME
+
+ strsigno -- map an signal number to a symbolic name string
+
+SYNOPSIS
+
+ const char *strsigno (int signo)
+
+DESCRIPTION
+
+ Given an signal number, returns a pointer to a string containing
+ the symbolic name of that signal number, as found in <signal.h>.
+
+ If the supplied signal number is within the valid range of indices
+ for symbolic names, but no name is available for the particular
+ signal number, then returns the string "Signal NUM", where NUM is
+ the signal number.
+
+ If the supplied signal number is not within the range of valid
+ indices, then returns NULL.
+
+BUGS
+
+ The contents of the location pointed to are only guaranteed to be
+ valid until the next call to strsigno.
+
+*/
+
+const char *
+strsigno (signo)
+ int signo;
+{
+ const char *name;
+ static char buf[32];
+
+ if (signal_names == NULL)
+ {
+ init_signal_tables ();
+ }
+
+ if ((signo < 0) || (signo >= num_signal_names))
+ {
+ /* Out of range, just return NULL */
+ name = NULL;
+ }
+ else if ((signal_names == NULL) || (signal_names[signo] == NULL))
+ {
+ /* In range, but no signal_names or no entry at this index. */
+ sprintf (buf, "Signal %d", signo);
+ name = (const char *) buf;
+ }
+ else
+ {
+ /* In range, and a valid name. Just return the name. */
+ name = signal_names[signo];
+ }
+
+ return (name);
+}
+
+
+/*
+
+NAME
+
+ strtosigno -- map a symbolic signal name to a numeric value
+
+SYNOPSIS
+
+ int strtosigno (char *name)
+
+DESCRIPTION
+
+ Given the symbolic name of a signal, map it to a signal number.
+ If no translation is found, returns 0.
+
+*/
+
+int
+strtosigno (name)
+ const char *name;
+{
+ int signo = 0;
+
+ if (name != NULL)
+ {
+ if (signal_names == NULL)
+ {
+ init_signal_tables ();
+ }
+ for (signo = 0; signo < num_signal_names; signo++)
+ {
+ if ((signal_names[signo] != NULL) &&
+ (strcmp (name, signal_names[signo]) == 0))
+ {
+ break;
+ }
+ }
+ if (signo == num_signal_names)
+ {
+ signo = 0;
+ }
+ }
+ return (signo);
+}
+
+
+/*
+
+NAME
+
+ psignal -- print message about signal to stderr
+
+SYNOPSIS
+
+ void psignal (unsigned signo, char *message);
+
+DESCRIPTION
+
+ Print to the standard error the message, followed by a colon,
+ followed by the description of the signal specified by signo,
+ followed by a newline.
+*/
+
+#ifndef HAVE_PSIGNAL
+
+void
+psignal (signo, message)
+ unsigned signo;
+ char *message;
+{
+ if (signal_names == NULL)
+ {
+ init_signal_tables ();
+ }
+ if ((signo <= 0) || (signo >= sys_nsig))
+ {
+ fprintf (stderr, "%s: unknown signal\n", message);
+ }
+ else
+ {
+ fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]);
+ }
+}
+
+#endif /* ! HAVE_PSIGNAL */
+
+
+/* A simple little main that does nothing but print all the signal translations
+ if MAIN is defined and this file is compiled and linked. */
+
+#ifdef MAIN
+
+#include <stdio.h>
+
+int
+main ()
+{
+ int signo;
+ int maxsigno;
+ const char *name;
+ const char *msg;
+
+ maxsigno = signo_max ();
+ printf ("%d entries in names table.\n", num_signal_names);
+ printf ("%d entries in messages table.\n", sys_nsig);
+ printf ("%d is max useful index.\n", maxsigno);
+
+ /* Keep printing values until we get to the end of *both* tables, not
+ *either* table. Note that knowing the maximum useful index does *not*
+ relieve us of the responsibility of testing the return pointer for
+ NULL. */
+
+ for (signo = 0; signo <= maxsigno; signo++)
+ {
+ name = strsigno (signo);
+ name = (name == NULL) ? "<NULL>" : name;
+ msg = strsignal (signo);
+ msg = (msg == NULL) ? "<NULL>" : msg;
+ printf ("%-4d%-18s%s\n", signo, name, msg);
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/libiberty/strstr.c b/libiberty/strstr.c
new file mode 100644
index 00000000000..fab36e3fb3d
--- /dev/null
+++ b/libiberty/strstr.c
@@ -0,0 +1,51 @@
+/* Simple implementation of strstr for systems without it.
+ This function is in the public domain. */
+
+/*
+
+NAME
+
+ strstr -- locate first occurance of a substring
+
+SYNOPSIS
+
+ #include <string.h>
+
+ char *strstr (char *s1, char *s2)
+
+DESCRIPTION
+
+ Locates the first occurance in the string pointed to by S1 of
+ the string pointed to by S2. Returns a pointer to the substring
+ found, or a NULL pointer if not found. If S2 points to a string
+ with zero length, the function returns S1.
+
+BUGS
+
+*/
+
+
+/* FIXME: The above description is ANSI compiliant. This routine has not
+ been validated to comply with it. -fnf */
+
+char *
+strstr (s1, s2)
+ char *s1, *s2;
+{
+ register char *p = s1;
+ extern char *strchr ();
+ extern int strncmp ();
+#if __GNUC__==2
+ extern __SIZE_TYPE__ strlen ();
+#endif
+ register int len = strlen (s2);
+
+ for (; (p = strchr (p, *s2)) != 0; p++)
+ {
+ if (strncmp (p, s2, len) == 0)
+ {
+ return (p);
+ }
+ }
+ return (0);
+}
diff --git a/libiberty/strtod.c b/libiberty/strtod.c
new file mode 100644
index 00000000000..c86c73de9b3
--- /dev/null
+++ b/libiberty/strtod.c
@@ -0,0 +1,122 @@
+/* Implementation of strtod for systems with atof.
+ Copyright (C) 1991, 1995 Free Software Foundation, Inc.
+
+This file is part of the libiberty library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include <ctype.h>
+
+extern double atof ();
+
+/* Disclaimer: this is currently just used by CHILL in GDB and therefore
+ has not been tested well. It may have been tested for nothing except
+ that it compiles. */
+
+double
+strtod (str, ptr)
+ char *str;
+ char **ptr;
+{
+ char *p;
+
+ if (ptr == (char **)0)
+ return atof (str);
+
+ p = str;
+
+ while (isspace (*p))
+ ++p;
+
+ if (*p == '+' || *p == '-')
+ ++p;
+
+ /* INF or INFINITY. */
+ if ((p[0] == 'i' || p[0] == 'I')
+ && (p[1] == 'n' || p[1] == 'N')
+ && (p[2] == 'f' || p[2] == 'F'))
+ {
+ if ((p[3] == 'i' || p[3] == 'I')
+ && (p[4] == 'n' || p[4] == 'N')
+ && (p[5] == 'i' || p[5] == 'I')
+ && (p[6] == 't' || p[6] == 'T')
+ && (p[7] == 'y' || p[7] == 'Y'))
+ {
+ *ptr = p + 7;
+ return atof (str);
+ }
+ else
+ {
+ *ptr = p + 3;
+ return atof (str);
+ }
+ }
+
+ /* NAN or NAN(foo). */
+ if ((p[0] == 'n' || p[0] == 'N')
+ && (p[1] == 'a' || p[1] == 'A')
+ && (p[2] == 'n' || p[2] == 'N'))
+ {
+ p += 3;
+ if (*p == '(')
+ {
+ ++p;
+ while (*p != '\0' && *p != ')')
+ ++p;
+ if (*p == ')')
+ ++p;
+ }
+ *ptr = p;
+ return atof (str);
+ }
+
+ /* digits, with 0 or 1 periods in it. */
+ if (isdigit (*p) || *p == '.')
+ {
+ int got_dot = 0;
+ while (isdigit (*p) || (!got_dot && *p == '.'))
+ {
+ if (*p == '.')
+ got_dot = 1;
+ ++p;
+ }
+
+ /* Exponent. */
+ if (*p == 'e' || *p == 'E')
+ {
+ int i;
+ i = 1;
+ if (p[i] == '+' || p[i] == '-')
+ ++i;
+ if (isdigit (p[i]))
+ {
+ while (isdigit (p[i]))
+ ++i;
+ *ptr = p + i;
+ return atof (str);
+ }
+ }
+ *ptr = p;
+ return atof (str);
+ }
+ /* Didn't find any digits. Doesn't look like a number. */
+ *ptr = str;
+ return 0.0;
+}
diff --git a/libiberty/strtol.c b/libiberty/strtol.c
new file mode 100644
index 00000000000..37d170660f2
--- /dev/null
+++ b/libiberty/strtol.c
@@ -0,0 +1,143 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+#if 0
+#include <stdlib.h>
+#endif
+#include "ansidecl.h"
+
+/* FIXME: It'd be nice to configure around these, but the include files are too
+ painful. These macros should at least be more portable than hardwired hex
+ constants. */
+
+#ifndef ULONG_MAX
+#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
+#endif
+
+#ifndef LONG_MAX
+#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */
+#endif
+
+/*
+ * Convert a string to a long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long
+strtol(nptr, endptr, base)
+ const char *nptr;
+ char **endptr;
+ register int base;
+{
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutlim = cutoff % (unsigned long)base;
+ cutoff /= (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_MIN : LONG_MAX;
+ errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *) (any ? s - 1 : nptr);
+ return (acc);
+}
diff --git a/libiberty/strtoul.c b/libiberty/strtoul.c
new file mode 100644
index 00000000000..ff6f2d6784d
--- /dev/null
+++ b/libiberty/strtoul.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+#if 0
+#include <stdlib.h>
+#endif
+#include "ansidecl.h"
+
+#ifndef ULONG_MAX
+#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
+#endif
+
+/*
+ * Convert a string to an unsigned long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long
+strtoul(nptr, endptr, base)
+ const char *nptr;
+ char **endptr;
+ register int base;
+{
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+ cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
+ cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = ULONG_MAX;
+ errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *) (any ? s - 1 : nptr);
+ return (acc);
+}
diff --git a/libiberty/tmpnam.c b/libiberty/tmpnam.c
new file mode 100644
index 00000000000..c0614677425
--- /dev/null
+++ b/libiberty/tmpnam.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+
+#ifndef L_tmpnam
+#define L_tmpname 100
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/usr/tmp"
+#endif
+
+static char tmpnam_buffer[L_tmpnam];
+static int tmpnam_counter;
+
+extern int getpid ();
+
+char *
+tmpnam (s)
+ char *s;
+{
+ int pid = getpid ();
+
+ if (s == NULL)
+ s = tmpnam_buffer;
+
+ /* Generate the filename and make sure that there isn't one called
+ it already. */
+
+ while (1)
+ {
+ FILE *f;
+ sprintf (s, "%s/%s%x.%x", P_tmpdir, "t", pid, tmpnam_counter);
+ f = fopen (s, "r");
+ if (f == NULL)
+ break;
+ tmpnam_counter++;
+ fclose (f);
+ }
+
+ return s;
+}
diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c
new file mode 100644
index 00000000000..eeb80e661f7
--- /dev/null
+++ b/libiberty/vasprintf.c
@@ -0,0 +1,172 @@
+/* Like vsprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <ansidecl.h>
+
+#ifdef TEST
+int global_total_width;
+#endif
+
+unsigned long strtoul ();
+char *malloc ();
+
+static int
+int_vasprintf (result, format, args)
+ char **result;
+ const char *format;
+ va_list *args;
+{
+ const char *p = format;
+ /* Add one to make sure that it is never zero, which might cause malloc
+ to return NULL. */
+ int total_width = strlen (format) + 1;
+ va_list ap;
+
+ memcpy ((PTR) &ap, (PTR) args, sizeof (va_list));
+
+ while (*p != '\0')
+ {
+ if (*p++ == '%')
+ {
+ while (strchr ("-+ #0", *p))
+ ++p;
+ if (*p == '*')
+ {
+ ++p;
+ total_width += abs (va_arg (ap, int));
+ }
+ else
+ total_width += strtoul (p, &p, 10);
+ if (*p == '.')
+ {
+ ++p;
+ if (*p == '*')
+ {
+ ++p;
+ total_width += abs (va_arg (ap, int));
+ }
+ else
+ total_width += strtoul (p, &p, 10);
+ }
+ while (strchr ("hlL", *p))
+ ++p;
+ /* Should be big enough for any format specifier except %s and floats. */
+ total_width += 30;
+ switch (*p)
+ {
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ case 'c':
+ (void) va_arg (ap, int);
+ break;
+ case 'f':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ (void) va_arg (ap, double);
+ /* Since an ieee double can have an exponent of 307, we'll
+ make the buffer wide enough to cover the gross case. */
+ total_width += 307;
+ break;
+ case 's':
+ total_width += strlen (va_arg (ap, char *));
+ break;
+ case 'p':
+ case 'n':
+ (void) va_arg (ap, char *);
+ break;
+ }
+ }
+ }
+#ifdef TEST
+ global_total_width = total_width;
+#endif
+ *result = malloc (total_width);
+ if (*result != NULL)
+ return vsprintf (*result, format, *args);
+ else
+ return 0;
+}
+
+int
+vasprintf (result, format, args)
+ char **result;
+ const char *format;
+#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__)
+ _BSD_VA_LIST_ args;
+#else
+ va_list args;
+#endif
+{
+ return int_vasprintf (result, format, &args);
+}
+
+#ifdef TEST
+void
+checkit
+#ifdef __STDC__
+ (const char* format, ...)
+#else
+ (va_alist)
+ va_dcl
+#endif
+{
+ va_list args;
+ char *result;
+
+#ifdef __STDC__
+ va_start (args, format);
+#else
+ char *format;
+ va_start (args);
+ format = va_arg (args, char *);
+#endif
+ vasprintf (&result, format, args);
+ if (strlen (result) < global_total_width)
+ printf ("PASS: ");
+ else
+ printf ("FAIL: ");
+ printf ("%d %s\n", global_total_width, result);
+}
+
+int
+main ()
+{
+ checkit ("%d", 0x12345678);
+ checkit ("%200d", 5);
+ checkit ("%.300d", 6);
+ checkit ("%100.150d", 7);
+ checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+777777777777777777333333333333366666666666622222222222777777777777733333");
+ checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx");
+}
+#endif /* TEST */
diff --git a/libiberty/vfork.c b/libiberty/vfork.c
new file mode 100644
index 00000000000..86c45919f66
--- /dev/null
+++ b/libiberty/vfork.c
@@ -0,0 +1,8 @@
+/* Emulate vfork using just plain fork, for systems without a real vfork.
+ This function is in the public domain. */
+
+int
+vfork ()
+{
+ return (fork ());
+}
diff --git a/libiberty/vfprintf.c b/libiberty/vfprintf.c
new file mode 100644
index 00000000000..db7b2ff4c19
--- /dev/null
+++ b/libiberty/vfprintf.c
@@ -0,0 +1,21 @@
+/* Provide a version vfprintf in terms of _doprnt.
+ By Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ */
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <stdio.h>
+#undef vfprintf
+
+int
+vfprintf (stream, format, ap)
+ FILE * stream;
+ const char * format;
+ va_list ap;
+{
+ return _doprnt (format, ap, stream);
+}
diff --git a/libiberty/vmsbuild.com b/libiberty/vmsbuild.com
new file mode 100644
index 00000000000..4fede380bfd
--- /dev/null
+++ b/libiberty/vmsbuild.com
@@ -0,0 +1,165 @@
+$! libiberty/vmsbuild.com -- build liberty.olb for VMS host, VMS target
+$!
+$ CC = "gcc /noVerbose/Debug/Incl=([],[-.include])"
+$ LIBR = "library /Obj"
+$ LINK = "link"
+$ DELETE= "delete /noConfirm"
+$ SEARCH= "search /Exact"
+$ ECHO = "write sys$output"
+$ ABORT = "exit %x002C"
+$!
+$ LIB_NAME = "liberty.olb" !this is what we're going to construct
+$ WORK_LIB = "new-lib.olb" !used to guard against an incomplete build
+$
+$! manually copied from Makefile.in
+$ REQUIRED_OFILES = "argv.o basename.o choose-temp.o concat.o cplus-dem.o "-
+ + "fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o "-
+ + "floatformat.o objalloc.o obstack.o spaces.o strerror.o strsignal.o "-
+ + "xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o"
+$! anything not caught by link+search of dummy.* should be added here
+$ EXTRA_OFILES = ""
+$!
+$! move to the directory which contains this command procedure
+$ old_dir = f$environ("DEFAULT")
+$ new_dir = f$parse("_._;",f$environ("PROCEDURE")) - "_._;"
+$ set default 'new_dir'
+$
+$ ECHO "Starting libiberty build..."
+$ create config.h
+/* libiberty config.h for VMS */
+#define NEED_sys_siglist
+#define NEED_strsignal
+#define NEED_psignal
+#define NEED_basename
+$ LIBR 'WORK_LIB' /Create
+$
+$! first pass: compile "required" modules
+$ ofiles = REQUIRED_OFILES + " " + EXTRA_OFILES
+$ pass = 1
+$ gosub do_ofiles
+$
+$! second pass: process dummy.c, using the first pass' results
+$ ECHO " now checking run-time library for missing functionality"
+$ if f$search("dummy.obj").nes."" then DELETE dummy.obj;*
+$ define/noLog sys$error _NL: !can't use /User_Mode here due to gcc
+$ define/noLog sys$output _NL: ! driver's use of multiple image activation
+$ on error then continue
+$ 'CC' dummy.c
+$ deassign sys$error !restore, more or less
+$ deassign sys$output
+$ if f$search("dummy.obj").eqs."" then goto pass2_failure1
+$! link dummy.obj, capturing full linker feedback in dummy.map
+$ oldmsg = f$environ("MESSAGE")
+$ set message /Facility/Severity/Identification/Text
+$ define/User sys$output _NL:
+$ define/User sys$error _NL:
+$ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,-
+ gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr
+$ set message 'oldmsg'
+$ if f$search("dummy.map").eqs."" then goto pass2_failure2
+$ DELETE dummy.obj;*
+$ SEARCH dummy.map "%LINK-I-UDFSYM" /Output=dummy.list
+$ DELETE dummy.map;*
+$ ECHO " check completed"
+$! we now have a file with one entry per line of unresolvable symbols
+$ ofiles = ""
+$ if f$trnlnm("IFILE$").nes."" then close/noLog ifile$
+$ open/Read ifile$ dummy.list
+$iloop: read/End=idone ifile$ iline
+$ iline = f$edit(iline,"COMPRESS,TRIM,LOWERCASE")
+$ ofiles = ofiles + " " + f$element(1," ",iline) + ".o"
+$ goto iloop
+$idone: close ifile$
+$ DELETE dummy.list;*
+$ on error then ABORT
+$
+$! third pass: compile "missing" modules collected in pass 2
+$ pass = 3
+$ gosub do_ofiles
+$
+$! finish up
+$ LIBR 'WORK_LIB' /Compress /Output='LIB_NAME' !new-lib.olb -> liberty.olb
+$ DELETE 'WORK_LIB';*
+$
+$! all done
+$ ECHO "Completed libiberty build."
+$ type sys$input:
+
+ You many wish to do
+ $ COPY LIBERTY.OLB GNU_CC:[000000]
+ so that this run-time library resides in the same location as gcc's
+ support library. When building gas, be sure to leave the original
+ copy of liberty.olb here so that gas's build procedure can find it.
+
+$ set default 'old_dir'
+$ exit
+$
+$!
+$! compile each element of the space-delimited list 'ofiles'
+$!
+$do_ofiles:
+$ ofiles = f$edit(ofiles,"COMPRESS,TRIM")
+$ i = 0
+$oloop:
+$ f = f$element(i," ",ofiles)
+$ if f.eqs." " then goto odone
+$ f = f - ".o" !strip dummy suffix
+$ ECHO " ''f'"
+$ skip_f = 0
+$ if pass.eq.3 .and. f$search("''f'.c").eqs."" then gosub chk_deffunc
+$ if .not.skip_f
+$ then
+$ 'CC' 'f'.c
+$ LIBR 'WORK_LIB' 'f'.obj /Insert
+$ DELETE 'f'.obj;*
+$ endif
+$ i = i + 1
+$ goto oloop
+$odone:
+$ return
+$
+$!
+$! check functions.def for a DEFFUNC() entry corresponding to missing file 'f'.c
+$!
+$chk_deffunc:
+$ define/User sys$output _NL:
+$ define/User sys$error _NL:
+$ SEARCH functions.def "DEFFUNC","''f'" /Match=AND
+$ if (($status.and.%x7FFFFFFF) .eq. 1)
+$ then
+$ skip_f = 1
+$ open/Append config_h config.h
+$ write config_h "#define NEED_''f'"
+$ close config_h
+$ endif
+$ return
+$
+$!
+$pass2_failure1:
+$! if we reach here, dummy.c failed to compile and we're really stuck
+$ type sys$input:
+
+ Cannot compile the library contents checker (dummy.c + functions.def),
+ so cannot continue!
+
+$! attempt the compile again, without suppressing diagnostic messages this time
+$ on error then ABORT +0*f$verify(v)
+$ v = f$verify(1)
+$ 'CC' dummy.c
+$ ABORT +0*f$verify(v) !'f$verify(0)'
+$!
+$pass2_failure2:
+$! should never reach here..
+$ type sys$input:
+
+ Cannot link the library contents checker (dummy.obj), so cannot continue!
+
+$! attempt the link again, without suppressing diagnostic messages this time
+$ on error then ABORT +0*f$verify(v)
+$ v = f$verify(1)
+$ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,-
+ gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr
+$ ABORT +0*f$verify(v) !'f$verify(0)'
+$
+$! not reached
+$ exit
diff --git a/libiberty/vprintf.c b/libiberty/vprintf.c
new file mode 100644
index 00000000000..65b425a4d6b
--- /dev/null
+++ b/libiberty/vprintf.c
@@ -0,0 +1,15 @@
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <stdio.h>
+#include <ansidecl.h>
+#undef vprintf
+int
+vprintf (format, ap)
+ const char *format;
+ va_list ap;
+{
+ return vfprintf (stdout, format, ap);
+}
diff --git a/libiberty/vsprintf.c b/libiberty/vsprintf.c
new file mode 100644
index 00000000000..bf0760cf6d3
--- /dev/null
+++ b/libiberty/vsprintf.c
@@ -0,0 +1,55 @@
+/* Simple implementation of vsprintf for systems without it.
+ Highly system-dependent, but should work on most "traditional"
+ implementations of stdio; newer ones should already have vsprintf.
+ Written by Per Bothner of Cygnus Support.
+ Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
+ Copyright (C) 1991, 1995 Free Software Foundation, Inc.
+
+This file is part of the libiberty library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include <varargs.h>
+#include <stdio.h>
+#include <ansidecl.h>
+#undef vsprintf
+
+int
+vsprintf (buf, format, ap)
+ char *buf;
+ const char *format;
+ va_list ap;
+{
+ FILE b;
+ int ret;
+#ifdef VMS
+ b->_flag = _IOWRT|_IOSTRG;
+ b->_ptr = buf;
+ b->_cnt = 12000;
+#else
+ b._flag = _IOWRT|_IOSTRG;
+ b._ptr = buf;
+ b._cnt = 12000;
+#endif
+ ret = _doprnt(format, ap, &b);
+ putc('\0', &b);
+ return ret;
+
+}
diff --git a/libiberty/waitpid.c b/libiberty/waitpid.c
new file mode 100644
index 00000000000..23db0b932d2
--- /dev/null
+++ b/libiberty/waitpid.c
@@ -0,0 +1,11 @@
+int
+waitpid (pid, stat_loc, options)
+ int pid, *stat_loc, options;
+{
+ for (;;)
+ {
+ int wpid = wait(stat_loc);
+ if (wpid == pid || wpid == -1)
+ return wpid;
+ }
+}
diff --git a/libiberty/xatexit.c b/libiberty/xatexit.c
new file mode 100644
index 00000000000..31476c29ddc
--- /dev/null
+++ b/libiberty/xatexit.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+/* Adapted from newlib/libc/stdlib/{,at}exit.[ch].
+ If you use xatexit, you must call xexit instead of exit. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#include <stdio.h>
+
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+/* For systems with larger pointers than ints, this must be declared. */
+PTR malloc PARAMS ((size_t));
+
+static void xatexit_cleanup PARAMS ((void));
+
+/* Pointer to function run by xexit. */
+extern void (*_xexit_cleanup) PARAMS ((void));
+
+#define XATEXIT_SIZE 32
+
+struct xatexit {
+ struct xatexit *next; /* next in list */
+ int ind; /* next index in this table */
+ void (*fns[XATEXIT_SIZE]) PARAMS ((void)); /* the table itself */
+};
+
+/* Allocate one struct statically to guarantee that we can register
+ at least a few handlers. */
+static struct xatexit xatexit_first;
+
+/* Points to head of LIFO stack. */
+static struct xatexit *xatexit_head = &xatexit_first;
+
+/* Register function FN to be run by xexit.
+ Return 0 if successful, -1 if not. */
+
+int
+xatexit (fn)
+ void (*fn) PARAMS ((void));
+{
+ register struct xatexit *p;
+
+ /* Tell xexit to call xatexit_cleanup. */
+ if (!_xexit_cleanup)
+ _xexit_cleanup = xatexit_cleanup;
+
+ p = xatexit_head;
+ if (p->ind >= XATEXIT_SIZE)
+ {
+ if ((p = (struct xatexit *) malloc (sizeof *p)) == NULL)
+ return -1;
+ p->ind = 0;
+ p->next = xatexit_head;
+ xatexit_head = p;
+ }
+ p->fns[p->ind++] = fn;
+ return 0;
+}
+
+/* Call any cleanup functions. */
+
+static void
+xatexit_cleanup ()
+{
+ register struct xatexit *p;
+ register int n;
+
+ for (p = xatexit_head; p; p = p->next)
+ for (n = p->ind; --n >= 0;)
+ (*p->fns[n]) ();
+}
diff --git a/libiberty/xexit.c b/libiberty/xexit.c
new file mode 100644
index 00000000000..431bbe02991
--- /dev/null
+++ b/libiberty/xexit.c
@@ -0,0 +1,36 @@
+/* xexit.c -- Run any exit handlers, then exit.
+ Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If not, write
+to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#include <stdio.h>
+
+/* This variable is set by xatexit if it is called. This way, xmalloc
+ doesn't drag xatexit into the link. */
+void (*_xexit_cleanup) PARAMS ((void));
+
+void
+xexit (code)
+ int code;
+{
+ if (_xexit_cleanup != NULL)
+ (*_xexit_cleanup) ();
+ exit (code);
+}
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
new file mode 100644
index 00000000000..1083790789d
--- /dev/null
+++ b/libiberty/xmalloc.c
@@ -0,0 +1,173 @@
+/* memory allocation routines with error checking.
+ Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#include <stdio.h>
+
+#ifdef __STDC__
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#define ptrdiff_t long
+#endif
+
+#if VMS
+#include <stdlib.h>
+#include <unixlib.h>
+#else
+/* For systems with larger pointers than ints, these must be declared. */
+PTR malloc PARAMS ((size_t));
+PTR realloc PARAMS ((PTR, size_t));
+PTR calloc PARAMS ((size_t, size_t));
+PTR sbrk PARAMS ((ptrdiff_t));
+#endif
+
+/* The program name if set. */
+static const char *name = "";
+
+#if !defined (__CYGWIN__) && defined (__CYGWIN32__)
+#define __CYGWIN__ 1
+#endif
+
+#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (__UWIN__)
+/* The initial sbrk, set when the program name is set. Not used for win32
+ ports other than cygwin32. */
+static char *first_break = NULL;
+#endif /* ! _WIN32 || __CYGWIN __ || __UWIN__ */
+
+void
+xmalloc_set_program_name (s)
+ const char *s;
+{
+ name = s;
+#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (__UWIN__)
+ /* Win32 ports other than cygwin32 don't have brk() */
+ if (first_break == NULL)
+ first_break = (char *) sbrk (0);
+#endif /* ! _WIN32 || __CYGWIN __ || __UWIN__ */
+}
+
+PTR
+xmalloc (size)
+ size_t size;
+{
+ PTR newmem;
+
+ if (size == 0)
+ size = 1;
+ newmem = malloc (size);
+ if (!newmem)
+ {
+#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (__UWIN__)
+ extern char **environ;
+ size_t allocated;
+
+ if (first_break != NULL)
+ allocated = (char *) sbrk (0) - first_break;
+ else
+ allocated = (char *) sbrk (0) - (char *) &environ;
+ fprintf (stderr,
+ "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) size, (unsigned long) allocated);
+#else
+ fprintf (stderr,
+ "\n%s%sCan not allocate %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) size);
+#endif /* ! _WIN32 || __CYGWIN __ || __UWIN__ */
+ xexit (1);
+ }
+ return (newmem);
+}
+
+PTR
+xcalloc (nelem, elsize)
+ size_t nelem, elsize;
+{
+ PTR newmem;
+
+ if (nelem == 0 || elsize == 0)
+ nelem = elsize = 1;
+
+ newmem = calloc (nelem, elsize);
+ if (!newmem)
+ {
+#if ! defined (_WIN32) || defined (__CYGWIN__)
+ extern char **environ;
+ size_t allocated;
+
+ if (first_break != NULL)
+ allocated = (char *) sbrk (0) - first_break;
+ else
+ allocated = (char *) sbrk (0) - (char *) &environ;
+ fprintf (stderr,
+ "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) (nelem * elsize), (unsigned long) allocated);
+#else
+ fprintf (stderr,
+ "\n%s%sCan not allocate %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) (nelem * elsize));
+#endif /* ! _WIN32 || __CYGWIN __ */
+ xexit (1);
+ }
+ return (newmem);
+}
+
+PTR
+xrealloc (oldmem, size)
+ PTR oldmem;
+ size_t size;
+{
+ PTR newmem;
+
+ if (size == 0)
+ size = 1;
+ if (!oldmem)
+ newmem = malloc (size);
+ else
+ newmem = realloc (oldmem, size);
+ if (!newmem)
+ {
+#ifndef __MINGW32__
+ extern char **environ;
+ size_t allocated;
+
+ if (first_break != NULL)
+ allocated = (char *) sbrk (0) - first_break;
+ else
+ allocated = (char *) sbrk (0) - (char *) &environ;
+ fprintf (stderr,
+ "\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) size, (unsigned long) allocated);
+#else
+ fprintf (stderr,
+ "\n%s%sCan not reallocate %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) size);
+#endif /* __MINGW32__ */
+ xexit (1);
+ }
+ return (newmem);
+}
diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c
new file mode 100644
index 00000000000..e16aba08554
--- /dev/null
+++ b/libiberty/xstrdup.c
@@ -0,0 +1,22 @@
+/* xstrdup.c -- Duplicate a string in memory, using xmalloc.
+ This trivial function is in the public domain.
+ Ian Lance Taylor, Cygnus Support, December 1995. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include "ansidecl.h"
+#include "libiberty.h"
+
+char *
+xstrdup (s)
+ const char *s;
+{
+ register size_t len = strlen (s) + 1;
+ register char *ret = xmalloc (len);
+ memcpy (ret, s, len);
+ return ret;
+}
diff --git a/libiberty/xstrerror.c b/libiberty/xstrerror.c
new file mode 100644
index 00000000000..770b653ba80
--- /dev/null
+++ b/libiberty/xstrerror.c
@@ -0,0 +1,56 @@
+/* xstrerror.c -- jacket routine for more robust strerror() usage.
+ Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
+ This code is in the public domain. */
+
+#include <stdio.h>
+
+#include "libiberty.h"
+#include "config.h"
+
+#ifdef VMS
+#include <errno.h>
+#if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
+extern char *strerror PARAMS ((int,...));
+#define DONT_DECLARE_STRERROR
+#endif
+#endif /* VMS */
+
+#ifndef DONT_DECLARE_STRERROR
+extern char *strerror PARAMS ((int));
+#endif
+
+/* If strerror returns NULL, we'll format the number into a static buffer. */
+
+#define ERRSTR_FMT "undocumented error #%d"
+static char xstrerror_buf[sizeof ERRSTR_FMT + 20];
+
+/* Like strerror, but result is never a null pointer. */
+
+char *
+xstrerror (errnum)
+ int errnum;
+{
+ char *errstr;
+#ifdef VMS
+ char *(*vmslib_strerror) PARAMS ((int,...));
+
+ /* Override any possibly-conflicting declaration from system header. */
+ vmslib_strerror = (char *(*) PARAMS ((int,...))) strerror;
+ /* Second argument matters iff first is EVMSERR, but it's simpler to
+ pass it unconditionally. `vaxc$errno' is declared in <errno.h>
+ and maintained by the run-time library in parallel to `errno'.
+ We assume that `errnum' corresponds to the last value assigned to
+ errno by the run-time library, hence vaxc$errno will be relevant. */
+ errstr = (*vmslib_strerror) (errnum, vaxc$errno);
+#else
+ errstr = strerror (errnum);
+#endif
+
+ /* If `errnum' is out of range, result might be NULL. We'll fix that. */
+ if (!errstr)
+ {
+ sprintf (xstrerror_buf, ERRSTR_FMT, errnum);
+ errstr = xstrerror_buf;
+ }
+ return errstr;
+}
diff --git a/ltconfig b/ltconfig
new file mode 100755
index 00000000000..ab304fd3b73
--- /dev/null
+++ b/ltconfig
@@ -0,0 +1,2822 @@
+#! /bin/sh
+
+# ltconfig - Create a system-specific libtool.
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A lot of this script is taken from autoconf-2.10.
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+echo=echo
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit 0
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+ # Yippee, $echo works!
+ :
+else
+ # Restart under the correct shell.
+ exec "$SHELL" "$0" --no-reexec ${1+"$@"}
+fi
+
+# Find the correct PATH separator. Usually this is `:', but
+# DJGPP uses `;' like DOS.
+if test "X${PATH_SEPARATOR+set}" != "Xset"; then
+ UNAME=${UNAME-`uname 2>/dev/null`}
+ case X$UNAME in
+ *-DOS) PATH_SEPARATOR=';' ;;
+ *) PATH_SEPARATOR=':' ;;
+ esac
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi
+
+if test "X${echo_test_string+set}" != "Xset"; then
+ # find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+ echo_test_string="`eval $cmd`" &&
+ (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then
+ break
+ fi
+ done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" != 'X\t' ||
+ test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+ for dir in $PATH /usr/ucb; do
+ if test -f $dir/echo &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+ echo="$dir/echo"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+
+ if test "X$echo" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+ test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ echo='print -r'
+ elif test -f /bin/ksh && test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running ltconfig again with it.
+ ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}"
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"}
+ else
+ # Try using printf.
+ echo='printf "%s\n"'
+ if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+ test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
+ test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+ CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL"
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ echo="$CONFIG_SHELL $0 --fallback-echo"
+ elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
+ test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+ echo="$CONFIG_SHELL $0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+ if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "$0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ echo=echo
+ fi
+ fi
+ fi
+ fi
+fi
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# The name of this program.
+progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'`
+
+# Constants:
+PROGRAM=ltconfig
+PACKAGE=libtool
+VERSION=1.2f
+TIMESTAMP=" (1.385 1999/03/15 17:24:54)"
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5'
+rm="rm -f"
+
+help="Try \`$progname --help' for more information."
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+enable_shared=yes
+# All known linkers require a `.a' archive for static linking.
+enable_static=yes
+enable_fast_install=yes
+enable_dlopen=unknown
+ltmain=
+silent=
+srcdir=
+ac_config_guess=
+ac_config_sub=
+host=
+nonopt=
+ofile="$default_ofile"
+verify_host=yes
+with_gcc=no
+with_gnu_ld=no
+need_locks=yes
+ac_ext=c
+objext=o
+libext=a
+cache_file=
+
+old_AR="$AR"
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+old_CPPFLAGS="$CPPFLAGS"
+old_LD="$LD"
+old_LN_S="$LN_S"
+old_NM="$NM"
+old_RANLIB="$RANLIB"
+old_DLLTOOL="$DLLTOOL"
+old_AS="$AS"
+
+# Parse the command line options.
+args=
+prev=
+for option
+do
+ case "$option" in
+ -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ eval "$prev=\$option"
+ prev=
+ continue
+ fi
+
+ case "$option" in
+ --help) cat <<EOM
+Usage: $progname [OPTION]... [HOST [LTMAIN]]
+
+Generate a system-specific libtool script.
+
+ --debug enable verbose shell tracing
+ --disable-shared do not build shared libraries
+ --disable-static do not build static libraries
+ --disable-fast-install do not optimize for fast installation
+ --enable-dlopen enable dlopen support
+ --enable-dlopen-self enable support for dlopening programs
+ --help display this help and exit
+ --no-verify do not verify that HOST is a valid host type
+-o, --output=FILE specify the output file [default=$default_ofile]
+ --quiet same as \`--silent'
+ --silent do not print informational messages
+ --srcdir=DIR find \`config.guess' in DIR
+ --version output version information and exit
+ --with-gcc assume that the GNU C compiler will be used
+ --with-gnu-ld assume that the C compiler uses the GNU linker
+ --disable-lock disable file locking
+ --cache-file=FILE configure cache file
+
+LTMAIN is the \`ltmain.sh' shell script fragment or \`ltmain.c' program
+that provides basic libtool functionality.
+
+HOST is the canonical host system name [default=guessed].
+EOM
+ exit 0
+ ;;
+
+ --debug)
+ echo "$progname: enabling shell trace mode"
+ set -x
+ ;;
+
+ --disable-shared) enable_shared=no ;;
+
+ --disable-static) enable_static=no ;;
+
+ --disable-fast-install) enable_fast_install=no ;;
+
+ --enable-dlopen) enable_dlopen=yes ;;
+
+ --quiet | --silent) silent=yes ;;
+
+ --srcdir) prev=srcdir ;;
+ --srcdir=*) srcdir="$optarg" ;;
+
+ --no-verify) verify_host=no ;;
+
+ --output | -o) prev=ofile ;;
+ --output=*) ofile="$optarg" ;;
+
+ --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"; exit 0 ;;
+
+ --with-gcc) with_gcc=yes ;;
+ --with-gnu-ld) with_gnu_ld=yes ;;
+
+ --disable-lock) need_locks=no ;;
+
+ --cache-file=*) cache_file="$optarg" ;;
+
+ -*)
+ echo "$progname: unrecognized option \`$option'" 1>&2
+ echo "$help" 1>&2
+ exit 1
+ ;;
+
+ *)
+ if test -z "$ltmain"; then
+ ltmain="$option"
+ elif test -z "$host"; then
+# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1
+# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then
+# echo "$progname: warning \`$option' is not a valid host type" 1>&2
+# fi
+ host="$option"
+ else
+ echo "$progname: too many arguments" 1>&2
+ echo "$help" 1>&2
+ exit 1
+ fi ;;
+ esac
+done
+
+if test -z "$ltmain"; then
+ echo "$progname: you must specify a LTMAIN file" 1>&2
+ echo "$help" 1>&2
+ exit 1
+fi
+
+if test ! -f "$ltmain"; then
+ echo "$progname: \`$ltmain' does not exist" 1>&2
+ echo "$help" 1>&2
+ exit 1
+fi
+
+# Quote any args containing shell metacharacters.
+ltconfig_args=
+for arg
+do
+ case "$arg" in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ltconfig_args="$ltconfig_args '$arg'" ;;
+ *) ltconfig_args="$ltconfig_args $arg" ;;
+ esac
+done
+
+# A relevant subset of AC_INIT.
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 5 compiler messages saved in config.log
+# 6 checking for... messages and results
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>>./config.log
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+
+if test -n "$cache_file" && test -r "$cache_file"; then
+ echo "loading cache $cache_file within ltconfig"
+ . $cache_file
+fi
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+if test -z "$srcdir"; then
+ # Assume the source directory is the same one as the path to LTMAIN.
+ srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'`
+ test "$srcdir" = "$ltmain" && srcdir=.
+fi
+
+trap "$rm conftest*; exit 1" 1 2 15
+if test "$verify_host" = yes; then
+ # Check for config.guess and config.sub.
+ ac_aux_dir=
+ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/config.guess; then
+ ac_aux_dir=$ac_dir
+ break
+ fi
+ done
+ if test -z "$ac_aux_dir"; then
+ echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2
+ echo "$help" 1>&2
+ exit 1
+ fi
+ ac_config_guess=$ac_aux_dir/config.guess
+ ac_config_sub=$ac_aux_dir/config.sub
+
+ # Make sure we can run config.sub.
+ if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then :
+ else
+ echo "$progname: cannot run $ac_config_sub" 1>&2
+ echo "$help" 1>&2
+ exit 1
+ fi
+
+ echo $ac_n "checking host system type""... $ac_c" 1>&6
+
+ host_alias=$host
+ case "$host_alias" in
+ "")
+ if host_alias=`$SHELL $ac_config_guess`; then :
+ else
+ echo "$progname: cannot guess host type; you must specify one" 1>&2
+ echo "$help" 1>&2
+ exit 1
+ fi ;;
+ esac
+ host=`$SHELL $ac_config_sub $host_alias`
+ echo "$ac_t$host" 1>&6
+
+ # Make sure the host verified.
+ test -z "$host" && exit 1
+
+elif test -z "$host"; then
+ echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2
+ echo "$help" 1>&2
+ exit 1
+else
+ host_alias=$host
+fi
+
+# Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+case "$host_os" in
+linux-gnu*) ;;
+linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+esac
+
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+case "$host_os" in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "${COLLECT_NAMES+set}" != set; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR cru $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+# Set a sane default for `AR'.
+test -z "$AR" && AR=ar
+
+# If RANLIB is not set, then run the test.
+if test "${RANLIB+set}" != "set"; then
+ result=no
+
+ echo $ac_n "checking for ranlib... $ac_c" 1>&6
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/ranlib; then
+ RANLIB="ranlib"
+ result="ranlib"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+
+ echo "$ac_t$result" 1>&6
+fi
+
+if test -n "$RANLIB"; then
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+ old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+fi
+
+# Set sane defaults for `DLLTOOL' and `AS', used on cygwin.
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$AS" && AS=as
+
+# Check to see if we are using GCC.
+if test "$with_gcc" != yes || test -z "$CC"; then
+ # If CC is not set, then try to find GCC or a usable CC.
+ if test -z "$CC"; then
+ echo $ac_n "checking for gcc... $ac_c" 1>&6
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+ for dir in $PATH; do
+ IFS="$save_ifs"
+ test -z "$dir" && dir=.
+ if test -f $dir/gcc; then
+ CC="gcc"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+
+ if test -n "$CC"; then
+ echo "$ac_t$CC" 1>&6
+ else
+ echo "$ac_t"no 1>&6
+ fi
+ fi
+
+ # Not "gcc", so try "cc", rejecting "/usr/ucb/cc".
+ if test -z "$CC"; then
+ echo $ac_n "checking for cc... $ac_c" 1>&6
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+ cc_rejected=no
+ for dir in $PATH; do
+ test -z "$dir" && dir=.
+ if test -f $dir/cc; then
+ if test "$dir/cc" = "/usr/ucb/cc"; then
+ cc_rejected=yes
+ continue
+ fi
+ CC="cc"
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if test $cc_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same name, so the bogon will be chosen
+ # first if we set CC to just the name; use the full file name.
+ shift
+ set dummy "$dir/cc" "$@"
+ shift
+ CC="$@"
+ fi
+ fi
+
+ if test -n "$CC"; then
+ echo "$ac_t$CC" 1>&6
+ else
+ echo "$ac_t"no 1>&6
+ fi
+
+ if test -z "$CC"; then
+ echo "$progname: error: no acceptable cc found in \$PATH" 1>&2
+ exit 1
+ fi
+ fi
+
+ # Now see if the compiler is really GCC.
+ with_gcc=no
+ echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6
+ echo "$progname:564: checking whether we are using GNU C" >&5
+
+ $rm conftest.c
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+ if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:572: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ with_gcc=yes
+ fi
+ $rm conftest.c
+ echo "$ac_t$with_gcc" 1>&6
+fi
+
+# Allow CC to be a program name with arguments.
+set dummy $CC
+compiler="$2"
+
+echo $ac_n "checking for object suffix... $ac_c" 1>&6
+$rm conftest*
+echo 'int i = 1;' > conftest.c
+echo "$progname:586: checking for object suffix" >& 5
+if { (eval echo $progname:587: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
+ # Append any warnings to the config.log.
+ cat conftest.err 1>&5
+
+ for ac_file in conftest.*; do
+ case $ac_file in
+ *.c) ;;
+ *) objext=`echo $ac_file | sed -e s/conftest.//` ;;
+ esac
+ done
+else
+ cat conftest.err 1>&5
+ echo "$progname: failed program was:" >&5
+ cat conftest.c >&5
+fi
+$rm conftest*
+echo "$ac_t$objext" 1>&6
+
+echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6
+pic_flag=
+special_shlib_compile_flags=
+wl=
+link_static_flag=
+no_builtin_flag=
+
+if test "$with_gcc" = yes; then
+ wl='-Wl,'
+ link_static_flag='-static'
+
+ case "$host_os" in
+ beos* | irix5* | irix6* | osf3* | osf4*)
+ # PIC is the default for these OSes.
+ ;;
+ aix*)
+ # Below there is a dirty hack to force normal static linking with -ldl
+ # The problem is because libdl dynamically linked with both libc and
+ # libC (AIX C++ library), which obviously doesn't included in libraries
+ # list by gcc. This cause undefined symbols with -static flags.
+ # This hack allows C programs to be linked with "-static -ldl", but
+ # we not sure about C++ programs.
+ link_static_flag="$link_static_flag ${wl}-lC"
+ ;;
+ cygwin* | mingw* | os2*)
+ # We can build DLLs from non-PIC.
+ ;;
+ amigaos*)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ pic_flag='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ *)
+ pic_flag='-fPIC'
+ ;;
+ esac
+else
+ # PORTME Check for PIC flags for the system compiler.
+ case "$host_os" in
+ aix3* | aix4*)
+ # All AIX code is PIC.
+ link_static_flag='-bnso -bI:/lib/syscalls.exp'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ # Is there a better link_static_flag that works with the bundled CC?
+ wl='-Wl,'
+ link_static_flag="${wl}-a ${wl}archive"
+ pic_flag='+Z'
+ ;;
+
+ irix5* | irix6*)
+ wl='-Wl,'
+ link_static_flag='-non_shared'
+ # PIC (with -KPIC) is the default.
+ ;;
+
+ cygwin* | mingw* | os2*)
+ # We can build DLLs from non-PIC.
+ ;;
+
+ osf3* | osf4*)
+ # All OSF/1 code is PIC.
+ wl='-Wl,'
+ link_static_flag='-non_shared'
+ ;;
+
+ sco3.2v5*)
+ pic_flag='-Kpic'
+ link_static_flag='-dn'
+ special_shlib_compile_flags='-belf'
+ ;;
+
+ solaris*)
+ pic_flag='-KPIC'
+ link_static_flag='-Bstatic'
+ wl='-Wl,'
+ ;;
+
+ sunos4*)
+ pic_flag='-PIC'
+ link_static_flag='-Bstatic'
+ wl='-Qoption ld '
+ ;;
+
+ sysv4.2uw2* | sysv4.3* | sysv5*)
+ pic_flag='-KPIC'
+ link_static_flag='-Bstatic'
+ wl='-Wl,'
+ ;;
+
+ uts4*)
+ pic_flag='-pic'
+ link_static_flag='-Bstatic'
+ ;;
+
+ *)
+ can_build_shared=no
+ ;;
+ esac
+fi
+
+if test -n "$pic_flag"; then
+ echo "$ac_t$pic_flag" 1>&6
+
+ # Check to make sure the pic_flag actually works.
+ echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6
+ $rm conftest*
+ echo "int some_variable = 0;" > conftest.c
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $pic_flag -DPIC"
+ echo "$progname:717: checking if $compiler PIC flag $pic_flag works" >&5
+ if { (eval echo $progname:718: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then
+ # Append any warnings to the config.log.
+ cat conftest.err 1>&5
+
+ case "$host_os" in
+ hpux9* | hpux10* | hpux11*)
+ # On HP-UX, both CC and GCC only warn that PIC is supported... then they
+ # create non-PIC objects. So, if there were any warnings, we assume that
+ # PIC is not supported.
+ if test -s conftest.err; then
+ echo "$ac_t"no 1>&6
+ can_build_shared=no
+ pic_flag=
+ else
+ echo "$ac_t"yes 1>&6
+ pic_flag=" $pic_flag"
+ fi
+ ;;
+ *)
+ echo "$ac_t"yes 1>&6
+ pic_flag=" $pic_flag"
+ ;;
+ esac
+ else
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ can_build_shared=no
+ pic_flag=
+ echo "$ac_t"no 1>&6
+ fi
+ CFLAGS="$save_CFLAGS"
+ $rm conftest*
+else
+ echo "$ac_t"none 1>&6
+fi
+
+# Check to see if options -o and -c are simultaneously supported by compiler
+echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6
+$rm conftest*
+echo "int some_variable = 0;" > conftest.c
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -c -o conftest2.o"
+echo "$progname:760: checking if $compiler supports -c -o file.o" >&5
+if { (eval echo $progname:761: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest2.o; then
+
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ echo "$ac_t"no 1>&6
+ compiler_c_o=no
+ else
+ echo "$ac_t"yes 1>&6
+ compiler_c_o=yes
+ fi
+else
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ compiler_c_o=no
+ echo "$ac_t"no 1>&6
+fi
+CFLAGS="$save_CFLAGS"
+$rm conftest*
+
+if test x"$compiler_c_o" = x"yes"; then
+ # Check to see if we can write to a .lo
+ echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6
+ $rm conftest*
+ echo "int some_variable = 0;" > conftest.c
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -c -o conftest.lo"
+ echo "$progname:788: checking if $compiler supports -c -o file.lo" >&5
+if { (eval echo $progname:789: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then
+
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ echo "$ac_t"no 1>&6
+ compiler_o_lo=no
+ else
+ echo "$ac_t"yes 1>&6
+ compiler_o_lo=yes
+ fi
+ else
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ compiler_o_lo=no
+ echo "$ac_t"no 1>&6
+ fi
+ CFLAGS="$save_CFLAGS"
+ $rm conftest*
+else
+ compiler_o_lo=no
+fi
+
+# Check to see if we can do hard links to lock some files if needed
+hard_links="nottested"
+if test "$compiler_c_o" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6
+ hard_links=yes
+ $rm conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$ac_t$hard_links" 1>&6
+ $rm conftest*
+ if test "$hard_links" = no; then
+ echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+if test "$with_gcc" = yes; then
+ # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+ echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6
+ $rm conftest*
+ echo "int some_variable = 0;" > conftest.c
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c"
+ echo "$progname:840: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+ if { (eval echo $progname:841: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then
+
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ echo "$ac_t"no 1>&6
+ compiler_rtti_exceptions=no
+ else
+ echo "$ac_t"yes 1>&6
+ compiler_rtti_exceptions=yes
+ fi
+ else
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ compiler_rtti_exceptions=no
+ echo "$ac_t"no 1>&6
+ fi
+ CFLAGS="$save_CFLAGS"
+ $rm conftest*
+
+ if test "$compiler_rtti_exceptions" = "yes"; then
+ no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
+ else
+ no_builtin_flag=' -fno-builtin'
+ fi
+
+fi
+
+# Check for any special shared library compilation flags.
+if test -n "$special_shlib_compile_flags"; then
+ echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2
+ if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then :
+ else
+ echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2
+ can_build_shared=no
+ fi
+fi
+
+echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6
+$rm conftest*
+echo 'main(){return(0);}' > conftest.c
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $link_static_flag"
+echo "$progname:884: checking if $compiler static flag $link_static_flag works" >&5
+if { (eval echo $progname:885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ echo "$ac_t$link_static_flag" 1>&6
+else
+ echo "$ac_t"none 1>&6
+ link_static_flag=
+fi
+LDFLAGS="$save_LDFLAGS"
+$rm conftest*
+
+if test -z "$LN_S"; then
+ # Check to see if we can use ln -s, or we need hard links.
+ echo $ac_n "checking whether ln -s works... $ac_c" 1>&6
+ $rm conftestdata
+ if ln -s X conftestdata 2>/dev/null; then
+ $rm conftestdata
+ LN_S="ln -s"
+ else
+ LN_S=ln
+ fi
+ if test "$LN_S" = "ln -s"; then
+ echo "$ac_t"yes 1>&6
+ else
+ echo "$ac_t"no 1>&6
+ fi
+fi
+
+# Make sure LD is an absolute path.
+if test -z "$LD"; then
+ ac_prog=ld
+ if test "$with_gcc" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6
+ echo "$progname:917: checking for ld used by GCC" >&5
+ ac_prog=`($CC -print-prog-name=ld) 2>&5`
+ case "$ac_prog" in
+ # Accept absolute paths.
+ /* | [A-Za-z]:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we are not using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+ elif test "$with_gnu_ld" = yes; then
+ echo $ac_n "checking for GNU ld... $ac_c" 1>&6
+ echo "$progname:941: checking for GNU ld" >&5
+ else
+ echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+ echo "$progname:944: checking for non-GNU ld" >&5
+ fi
+
+ if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog"; then
+ LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+ test "$with_gnu_ld" != no && break
+ else
+ test "$with_gnu_ld" != yes && break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ fi
+
+ if test -n "$LD"; then
+ echo "$ac_t$LD" 1>&6
+ else
+ echo "$ac_t"no 1>&6
+ fi
+
+ if test -z "$LD"; then
+ echo "$progname: error: no acceptable ld found in \$PATH" 1>&2
+ exit 1
+ fi
+fi
+
+# Check to see if it really is or is not GNU ld.
+echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6
+# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+ with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+echo "$ac_t$with_gnu_ld" 1>&6
+
+# See if the linker supports building shared libraries.
+echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6
+
+allow_undefined_flag=
+no_undefined_flag=
+need_lib_prefix=unknown
+need_version=unknown
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+archive_cmds=
+archive_expsym_cmds=
+old_archive_from_new_cmds=
+export_dynamic_flag_spec=
+whole_archive_flag_spec=
+thread_safe_flag_spec=
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+hardcode_shlibpath_var=unsupported
+runpath_var=
+always_export_symbols=no
+export_symbols_cmds='$NM $libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
+# include_expsyms should be a list of space-separated symbols to be *always*
+# included in the symbol list
+include_expsyms=
+# exclude_expsyms can be an egrep regular expression of symbols to exclude
+# it will be wrapped by ` (' and `)$', so one must not match beginning or
+# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+# as well as any symbol that contains `d'.
+exclude_expsyms=
+
+case "$host_os" in
+cygwin* | mingw*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$with_gcc" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+
+freebsd2* | sunos4*)
+ exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+ ;;
+
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # See if GNU ld supports shared libraries.
+ case "$host_os" in
+ aix3* | aix4*)
+ # On AIX, the GNU linker is very broken
+ ld_shlibs=no
+ cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+ ;;
+
+ amigaos*)
+ archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw*)
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+
+ # Extract the symbol export list from an `--export-all' def file,
+ # then regenerate the def file from the symbol export list, so that
+ # the compiled dll only exports the symbol export list.
+ export_symbols_cmds='rm -f $objdir/$soname-ltdll.c~
+ sed -e "/^# \/\* ltdll.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
+ (cd $objdir && $CC -c $soname-ltdll.c)~
+ $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs~
+ sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ; *//" < $objdir/$soname-def > $export_symbols'
+
+ archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~
+ _lt_hint=1;
+ for symbol in `cat $export_symbols`; do
+ echo " \$symbol @ \$_lt_hint ; " >> $objdir/$soname-def;
+ _lt_hint=`expr 1 + \$_lt_hint`;
+ done~
+ $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
+ $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
+ $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts'
+
+ old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a'
+ ;;
+
+ *)
+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = yes; then
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${wl}--export-dynamic'
+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case "$host_os" in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$with_gcc" = yes && test -z "$link_static_flag"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+
+ aix4*)
+ allow_undefined_flag=
+ if test "$with_gcc" = yes; then
+ if strings `${CC} -print-prog-name=collect2` | \
+ grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ hardcode_direct=yes
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ fi
+ archive_cmds='$CC -shared ${wl}-bnoentry -o $objdir/$soname $libobjs $deplibs $linkopts'
+ else
+ always_export_symbols=yes
+ archive_expsym_cmds='$CC -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bM:SRE ${wl}-bnoentry'
+ hardcode_direct=yes
+ fi
+ hardcode_minus_L=yes
+ # Though LIBPATH variable hardcodes shlibpath into executable,
+ # it doesn't affect searching for -l* libraries; this confuses
+ # tests in mdemo.
+ hardcode_shlibpath_var=unsupported
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+
+ amigaos*)
+ archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+
+ cygwin* | mingw*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_from_new_cmds='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib /OUT:$oldlib$oldobjs'
+ fix_srcfile_path='`cygpath -w $srcfile`'
+ ;;
+
+ freebsd1*)
+ ld_shlibs=no
+ can_build_shared=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=no # verified on 2.2.6
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd*)
+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ archive_cmds='$rm $objdir/$soname~$LD -b +s +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib'
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10* | hpux11*)
+ archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib $libobjs $deplibs $linkopts'
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ irix5* | irix6*)
+ if test "$with_gcc" = yes; then
+ archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+ else
+ archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -o $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts' # ELF
+ fi
+ hardcode_libdir_flag_spec='${wl}-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ openbsd*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def'
+ old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def'
+ ;;
+
+ osf3* | osf4*)
+ if test "$with_gcc" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -o $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ sco3.2v5*)
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts'
+ hardcode_direct=yes
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z text'
+ # $CC -shared without GNU ld will not create a library from C++
+ # object files and a static libstdc++, better avoid it by now
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sunos4*)
+ # Why do we need -Bstatic? To avoid inter-library dependencies, maybe...
+ if test "$with_gcc" = yes; then
+ # Use -fPIC here because libgcc is multilibbed
+ archive_cmds='$CC -shared ${wl}-Bstatic -fPIC -o $lib $libobjs $deplibs $linkopts'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+ hardcode_direct=no
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=no
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=no
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=no
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ ld_shlibs=no
+ can_build_shared=no
+ ;;
+ esac
+fi
+echo "$ac_t$ld_shlibs" 1>&6
+
+if test -z "$NM"; then
+ echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6
+ case "$NM" in
+ /* | [A-Za-z]:[/\\]*) ;; # Let the user override the test with a path.
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+ for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/nm; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ NM="$ac_dir/nm -B"
+ break
+ elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ NM="$ac_dir/nm -p"
+ break
+ else
+ NM=${NM="$ac_dir/nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$NM" && NM=nm
+ ;;
+ esac
+ echo "$ac_t$NM" 1>&6
+fi
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Define system-specific variables.
+case "$host_os" in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*) # Its linker distinguishes data from code symbols
+ global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+ ;;
+irix*)
+ symcode='[BCDEGRST]'
+ ;;
+solaris*)
+ symcode='[BDT]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+ symcode='[ABCDGISTW]'
+fi
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Write the raw and C identifiers.
+ global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+ $rm conftest*
+ cat > conftest.c <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+ echo "$progname:1447: checking if global_symbol_pipe works" >&5
+ if { (eval echo $progname:1448: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { echo "$progname:1451: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
+
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if egrep ' nm_test_var$' "$nlist" >/dev/null; then
+ if egrep ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<EOF > conftest.c
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+ # Now generate the symbol file.
+ eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c'
+
+ cat <<EOF >> conftest.c
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+ sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
+ cat <<\EOF >> conftest.c
+ {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+ # Now try linking the two files.
+ mv conftest.$objext conftestm.$objext
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="conftestm.$objext"
+ CFLAGS="$CFLAGS$no_builtin_flag"
+ if { (eval echo $progname:1503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ pipe_works=yes
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.c >&5
+ fi
+ LIBS="$save_LIBS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.c >&5
+ fi
+ $rm conftest*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ global_symbol_pipe=
+ fi
+done
+echo "$ac_t$pipe_works" 1>&6
+
+if test -z "$global_symbol_pipe"; then
+ global_symbol_to_cdecl=
+fi
+
+# Check hardcoding attributes.
+echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+ test -n "$runpath_var"; then
+
+ # We can hardcode non-existant directories.
+ if test "$hardcode_direct" != no && \
+ test "$hardcode_minus_L" != no && \
+ test "$hardcode_shlibpath_var" != no; then
+
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+echo "$ac_t$hardcode_action" 1>&6
+
+
+reload_flag=
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6
+# PORTME Some linkers may need a different reload flag.
+reload_flag='-r'
+echo "$ac_t$reload_flag" 1>&6
+test -n "$reload_flag" && reload_flag=" $reload_flag"
+
+# PORTME Fill in your ld.so characteristics
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+file_magic_cmd=
+file_magic_test_file=
+deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [regex]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given egrep regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6
+case "$host_os" in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}.so$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}.so$major'
+ ;;
+
+aix4*)
+ version_type=linux
+ # AIX has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ # We preserve .a as extension for shared libraries though AIX4.2
+ # and later linker supports .so
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a'
+ shlibpath_var=LIBPATH
+ deplibs_check_method=pass_all
+ ;;
+
+amigaos*)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
+ ;;
+
+beos*)
+ library_names_spec='${libname}.so'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi4*)
+ version_type=linux
+ library_names_spec='${libname}.so$major ${libname}.so'
+ soname_spec='${libname}.so'
+ finish_cmds='PATH="$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ deplibs_check_method='file_magic ELF 32-bit LSB shared object'
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=/shlib/libc.so
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw*)
+ version_type=windows
+ if test "$with_gcc" = yes; then
+ library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a'
+ else
+ library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib'
+ fi
+ dynamic_linker='Win32 ld.exe'
+ deplibs_check_method='file_magic file format pei*-i386.*architecture: i386'
+ file_magic_cmd='objdump -f'
+ need_lib_prefix=no
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd*)
+ objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+ version_type=freebsd-$objformat
+ case "$version_type" in
+ freebsd-elf*)
+ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=`echo /usr/lib/libc.so*`
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ deplibs_check_method=unknown
+ library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix'
+ need_version=yes
+ ;;
+ esac
+ finish_cmds='PATH="$PATH:/sbin" OBJFORMAT="'"$objformat"'" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+gnu*)
+ version_type=linux
+ library_names_spec='${libname}${release}.so$versuffix ${libname}.so'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ dynamic_linker="$host_os dld.sl"
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_var=SHLIB_PATH
+ library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl'
+ soname_spec='${libname}${release}.sl$major'
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+irix5*)
+ version_type=irix
+ soname_spec='${libname}${release}.so'
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+ shlibpath_var=LD_LIBRARY_PATH
+ deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" # or should it be pass_all?
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=`echo /lib/libc.so*`
+ shlibpath_overrides_runpath=no
+ ;;
+
+irix6*)
+ version_type=irix
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}.so'
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+ case "$LD" in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ # even though /usr/local/lib is always searched, the man-page says
+ # shared libraries should not be installed there if they use an ABI
+ # different from -32, so we'd better not search for shared libraries
+ # there either
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" # or should it be pass_all?
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux-gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ soname_spec='${libname}${release}.so$major'
+ finish_cmds='PATH="$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+
+ if test -f /lib/ld.so.1; then
+ dynamic_linker='GNU ld.so'
+ else
+ # Only the GNU ld.so supports shared libraries on MkLinux.
+ case "$host_cpu" in
+ powerpc*) dynamic_linker=no ;;
+ *) dynamic_linker='Linux ld.so' ;;
+ esac
+ fi
+ ;;
+
+netbsd*)
+ version_type=sunos
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+ finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so'
+ soname_spec='${libname}${release}.so$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+openbsd*)
+ version_type=sunos
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ need_version=no
+ fi
+ library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+os2*)
+ libname_spec='$name'
+ need_lib_prefix=no
+ library_names_spec='$libname.dll $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4*)
+ version_type=osf
+ soname_spec='${libname}${release}.so'
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+ shlibpath_var=LD_LIBRARY_PATH
+ # deplibs_check_method='pass_all'
+ # Although pass_all appears to work, it copies symbols from static libraries
+ # into shared ones and exports them. So, when a program is linked with two
+ # or more libraries that have got copies of the same symbols, link fails
+ # This was only tested on osf4:
+ deplibs_check_method='file_magic COFF format alpha shared library'
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=/shlib/libc.so
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+sco3.2v5*)
+ version_type=osf
+ soname_spec='${libname}${release}.so$major'
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ soname_spec='${libname}${release}.so$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib"
+ file_magic_cmd=/usr/bin/file
+ file_magic_test_file=/lib/libc.so
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4.2uw2* | sysv4.3* | sysv5*)
+ version_type=linux
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ soname_spec='${libname}${release}.so$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case "$host_vendor" in
+ ncr)
+ deplibs_check_method='pass_all'
+ ;;
+ esac
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ soname_spec='${libname}${release}.so$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ soname_spec='${libname}${release}.so$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$ac_t$dynamic_linker" 1>&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+# Report the final consequences.
+echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6
+
+if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then
+ case "$deplibs_check_method" in
+ "file_magic "*)
+ file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ egrep "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+ fi ;;
+ esac
+fi
+
+echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+aix4*)
+ test "$enable_shared" = yes && enable_static=no
+ ;;
+esac
+
+echo "$ac_t$enable_shared" 1>&6
+
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+
+echo "checking whether to build static libraries... $enable_static" 1>&6
+
+if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+echo $ac_n "checking for objdir... $ac_c" 1>&6
+rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+echo "$ac_t$objdir" 1>&6
+
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then
+ lt_cv_dlopen=no lt_cv_dlopen_libs=
+echo $ac_n "checking for dlopen""... $ac_c" 1>&6
+echo "$progname:1977: checking for dlopen" >&5
+if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1982 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char dlopen(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+dlopen();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_dlopen=yes"
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_dlopen=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ lt_cv_dlopen="dlopen"
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "$progname:2022: checking for dlopen in -ldl" >&5
+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ldl $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2030 "ltconfig"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen();
+
+int main() {
+dlopen()
+; return 0; }
+EOF
+if { (eval echo $progname:2040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
+echo "$progname:2059: checking for dld_link in -ldld" >&5
+ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ldld $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2067 "ltconfig"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dld_link();
+
+int main() {
+dld_link()
+; return 0; }
+EOF
+if { (eval echo $progname:2077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for shl_load""... $ac_c" 1>&6
+echo "$progname:2096: checking for shl_load" >&5
+if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2101 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char shl_load(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+shl_load();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_shl_load=yes"
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_shl_load=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ lt_cv_dlopen="shl_load"
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for LoadLibrary""... $ac_c" 1>&6
+echo "$progname:2141: checking for LoadLibrary" >&5
+if eval "test \"`echo '$''{'ac_cv_func_LoadLibrary'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2146 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char LoadLibrary(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char LoadLibrary();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_LoadLibrary) || defined (__stub___LoadLibrary)
+choke me
+#else
+LoadLibrary();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_LoadLibrary=yes"
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_LoadLibrary=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'LoadLibrary`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ lt_cv_dlopen="LoadLibrary"
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+fi
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ fi
+
+ case "$lt_cv_dlopen" in
+ dlopen)
+for ac_hdr in dlfcn.h; do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "$progname:2210: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2215 "ltconfig"
+#include <$ac_hdr>
+int fnord = 0;
+EOF
+ac_try="$ac_compile conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo $progname:2220: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ if test "x$ac_cv_header_dlfcn_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+ fi
+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
+echo "$progname:2248: checking whether a program can dlopen itself" >&5
+if test "${lt_cv_dlopen_self+set}" = set; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ lt_cv_dlopen_self=cross
+ else
+ cat > conftest.c <<EOF
+#line 2256 "ltconfig"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LTDL_GLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LTDL_GLOBAL DL_GLOBAL
+# else
+# define LTDL_GLOBAL 0
+# endif
+#endif
+
+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LTDL_LAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LTDL_LAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LTDL_LAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LTDL_LAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LTDL_LAZY_OR_NOW DL_NOW
+# else
+# define LTDL_LAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+fnord() { int i=42;}
+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
+ if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
+ if(ptr1 || ptr2) exit(0); } exit(1); }
+
+EOF
+if { (eval echo $progname:2302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ lt_cv_dlopen_self=yes
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ lt_cv_dlopen_self=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$lt_cv_dlopen_self" 1>&6
+
+ if test "$lt_cv_dlopen_self" = yes; then
+ LDFLAGS="$LDFLAGS $link_static_flag"
+ echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
+echo "$progname:2321: checking whether a statically linked program can dlopen itself" >&5
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ lt_cv_dlopen_self_static=cross
+ else
+ cat > conftest.c <<EOF
+#line 2329 "ltconfig"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LTDL_GLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LTDL_GLOBAL DL_GLOBAL
+# else
+# define LTDL_GLOBAL 0
+# endif
+#endif
+
+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LTDL_LAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LTDL_LAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LTDL_LAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LTDL_LAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LTDL_LAZY_OR_NOW DL_NOW
+# else
+# define LTDL_LAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+fnord() { int i=42;}
+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
+ if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
+ if(ptr1 || ptr2) exit(0); } exit(1); }
+
+EOF
+if { (eval echo $progname:2375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ lt_cv_dlopen_self_static=yes
+else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ lt_cv_dlopen_self_static=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6
+fi
+ ;;
+ esac
+
+ case "$lt_cv_dlopen_self" in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case "$lt_cv_dlopen_self_static" in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+# Copy echo and quote the copy, instead of the original, because it is
+# used later.
+ltecho="$echo"
+if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+ ltecho="$CONFIG_SHELL \$0 --fallback-echo"
+fi
+LTSHELL="$SHELL"
+
+LTCONFIG_VERSION="$VERSION"
+
+# Only quote variables if we're using ltmain.sh.
+case "$ltmain" in
+*.sh)
+ # Now quote all the things that may contain metacharacters.
+ for var in ltecho old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \
+ old_LN_S old_DLLTOOL old_AS AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \
+ reload_flag reload_cmds wl \
+ pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \
+ thread_safe_flag_spec whole_archive_flag_spec libname_spec \
+ library_names_spec soname_spec \
+ RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
+ old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \
+ file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \
+ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
+ hardcode_libdir_flag_spec hardcode_libdir_separator \
+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+ compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
+
+ case "$var" in
+ reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
+ old_postinstall_cmds | old_postuninstall_cmds | \
+ export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
+ postinstall_cmds | postuninstall_cmds | \
+ finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+ # Double-quote double-evaled strings.
+ eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+ ;;
+ *)
+ eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+ ;;
+ esac
+ done
+
+ case "$ltecho" in
+ *'\$0 --fallback-echo"')
+ ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+ ;;
+ esac
+
+ trap "$rm \"$ofile\"; exit 1" 1 2 15
+ echo "creating $ofile"
+ $rm "$ofile"
+ cat <<EOF > "$ofile"
+#! $SHELL
+
+# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh.
+#
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="sed -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi
+
+### BEGIN LIBTOOL CONFIG
+EOF
+ cfgfile="$ofile"
+ ;;
+
+*)
+ # Double-quote the variables that need it (for aesthetics).
+ for var in old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \
+ old_LN_S old_DLLTOOL old_AS; do
+ eval "$var=\\\"\$var\\\""
+ done
+
+ # Just create a config file.
+ cfgfile="$ofile.cfg"
+ trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+ echo "creating $cfgfile"
+ $rm "$cfgfile"
+ cat <<EOF > "$cfgfile"
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+EOF
+ ;;
+esac
+
+cat <<EOF >> "$cfgfile"
+# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\
+# LD=$old_LD NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\
+# DLLTOOL="$old_DLLTOOL" AS="$old_AS" \\
+# $0$ltconfig_args
+#
+# Compiler and other test output produced by $progname, useful for
+# debugging $progname, is in ./config.log if it exists.
+
+# The version of $progname that generated this script.
+LTCONFIG_VERSION=$LTCONFIG_VERSION
+
+# Shell to use when invoking shell scripts.
+SHELL=$LTSHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$ltecho
+
+# The archiver.
+AR=$AR
+
+# The default C compiler.
+CC=$CC
+
+# The linker used to build libraries.
+LD=$LD
+
+# Whether we need hard or soft links.
+LN_S=$LN_S
+
+# A BSD-compatible nm program.
+NM=$NM
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$reload_flag
+reload_cmds=$reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$wl
+
+# Object file suffix (normally "o").
+objext="$objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$pic_flag
+
+# Does compiler simultaneously support -c and -o options
+compiler_c_o=$compiler_c_o
+
+# Can we write directly to a .lo ?
+compiler_o_lo=$compiler_o_lo
+
+# Must we lock files when doing compilation ?
+need_locks=$need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$link_static_flag
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$RANLIB
+old_archive_cmds=$old_archive_cmds
+old_postinstall_cmds=$old_postinstall_cmds
+old_postuninstall_cmds=$old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$old_archive_from_new_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$archive_cmds
+archive_expsym_cmds=$archive_expsym_cmds
+postinstall_cmds=$postinstall_cmds
+postuninstall_cmds=$postuninstall_cmds
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic
+file_magic_cmd=$file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$global_symbol_to_cdecl
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required
+always_export_symbols=$always_export_symbols
+
+# The command to extract exported symbols
+export_symbols_cmds=$export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols
+exclude_expsyms=$exclude_expsyms
+
+# Symbols that must always be exported
+include_expsyms=$include_expsyms
+
+EOF
+
+case "$ltmain" in
+*.sh)
+ echo '### END LIBTOOL CONFIG' >> "$ofile"
+ echo >> "$ofile"
+ case "$host_os" in
+ aix3*)
+ cat <<\EOF >> "$ofile"
+
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "${COLLECT_NAMES+set}" != set; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+EOF
+ ;;
+ esac
+
+ # Append the ltmain.sh script.
+ cat "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1)
+
+ chmod +x "$ofile"
+ ;;
+
+*)
+ # Compile the libtool program.
+ echo "FIXME: would compile $ltmain"
+ ;;
+esac
+
+test -n "$cache_file" || exit 0
+
+# AC_CACHE_SAVE
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/ltmain.sh b/ltmain.sh
new file mode 100644
index 00000000000..878787a3c1e
--- /dev/null
+++ b/ltmain.sh
@@ -0,0 +1,3782 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun ltconfig.
+#
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit 0
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+ # Yippee, $echo works!
+ :
+else
+ # Restart under the correct shell, and then maybe $echo will work.
+ exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+# The name of this program.
+progname=`$echo "$0" | sed 's%^.*/%%'`
+modename="$progname"
+
+# Constants.
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.2f
+TIMESTAMP=" (1.33 1999/04/26 16:28:53)"
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+SP2NL='tr \040 \012'
+NL2SP='tr \012 \040'
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+ save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+ save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+if test "$LTCONFIG_VERSION" != "$VERSION"; then
+ echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
+ echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+fi
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ echo "$modename: not configured to build any kind of library" 1>&2
+ echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+lo2o="s/\\.lo\$/.${objext}/"
+
+# Parse our command line options once, thoroughly.
+while test $# -gt 0
+do
+ arg="$1"
+ shift
+
+ case "$arg" in
+ -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case "$prev" in
+ execute_dlfiles)
+ eval "$prev=\"\$$prev \$arg\""
+ ;;
+ *)
+ eval "$prev=\$arg"
+ ;;
+ esac
+
+ prev=
+ prevopt=
+ continue
+ fi
+
+ # Have we seen a non-optional argument yet?
+ case "$arg" in
+ --help)
+ show_help=yes
+ ;;
+
+ --version)
+ echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+ exit 0
+ ;;
+
+ --config)
+ sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
+ exit 0
+ ;;
+
+ --debug)
+ echo "$progname: enabling shell trace mode"
+ set -x
+ ;;
+
+ --dry-run | -n)
+ run=:
+ ;;
+
+ --features)
+ echo "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ echo "enable shared libraries"
+ else
+ echo "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ echo "enable static libraries"
+ else
+ echo "disable static libraries"
+ fi
+ exit 0
+ ;;
+
+ --finish) mode="finish" ;;
+
+ --mode) prevopt="--mode" prev=mode ;;
+ --mode=*) mode="$optarg" ;;
+
+ --quiet | --silent)
+ show=:
+ ;;
+
+ -dlopen)
+ prevopt="-dlopen"
+ prev=execute_dlfiles
+ ;;
+
+ -*)
+ $echo "$modename: unrecognized option \`$arg'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+
+ *)
+ nonopt="$arg"
+ break
+ ;;
+ esac
+done
+
+if test -n "$prevopt"; then
+ $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+fi
+
+if test -z "$show_help"; then
+
+ # Infer the operation mode.
+ if test -z "$mode"; then
+ case "$nonopt" in
+ *cc | *++ | gcc* | *-gcc*)
+ mode=link
+ for arg
+ do
+ case "$arg" in
+ -c)
+ mode=compile
+ break
+ ;;
+ esac
+ done
+ ;;
+ *db | *dbx | *strace | *truss)
+ mode=execute
+ ;;
+ *install*|cp|mv)
+ mode=install
+ ;;
+ *rm)
+ mode=uninstall
+ ;;
+ *)
+ # If we have no mode, but dlfiles were specified, then do execute mode.
+ test -n "$execute_dlfiles" && mode=execute
+
+ # Just use the default operation mode.
+ if test -z "$mode"; then
+ if test -n "$nonopt"; then
+ $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+ else
+ $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+ fi
+ fi
+ ;;
+ esac
+ fi
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$execute_dlfiles" && test "$mode" != execute; then
+ $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$modename --help --mode=$mode' for more information."
+
+ # These modes are in order of execution frequency so that they run quickly.
+ case "$mode" in
+ # libtool compile mode
+ compile)
+ modename="$modename: compile"
+ # Get the compilation command and the source file.
+ base_compile=
+ lastarg=
+ srcfile="$nonopt"
+ suppress_output=
+
+ user_target=no
+ for arg
+ do
+ # Accept any command-line options.
+ case "$arg" in
+ -o)
+ if test "$user_target" != "no"; then
+ $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+ exit 1
+ fi
+ user_target=next
+ ;;
+
+ -static)
+ build_old_libs=yes
+ continue
+ ;;
+ esac
+
+ case "$user_target" in
+ next)
+ # The next one is the -o target name
+ user_target=yes
+ continue
+ ;;
+ yes)
+ # We got the output file
+ user_target=set
+ libobj="$arg"
+ continue
+ ;;
+ esac
+
+ # Accept the current argument as the source file.
+ lastarg="$srcfile"
+ srcfile="$arg"
+
+ # Aesthetically quote the previous argument.
+
+ # Backslashify any backslashes, double quotes, and dollar signs.
+ # These are the only characters that are still specially
+ # interpreted inside of double-quoted scrings.
+ lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+ # Double-quote args containing other shell metacharacters.
+ # Many Bourne shells cannot handle close brackets correctly in scan
+ # sets, so we specify it separately.
+ case "$lastarg" in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ lastarg="\"$lastarg\""
+ ;;
+ esac
+
+ # Add the previous argument to base_compile.
+ if test -z "$base_compile"; then
+ base_compile="$lastarg"
+ else
+ base_compile="$base_compile $lastarg"
+ fi
+ done
+
+ case "$user_target" in
+ set)
+ ;;
+ no)
+ # Get the name of the library object.
+ libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+ ;;
+ *)
+ $echo "$modename: you must specify a target with \`-o'" 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ xform='[cCFSfmso]'
+ case "$libobj" in
+ *.ada) xform=ada ;;
+ *.adb) xform=adb ;;
+ *.ads) xform=ads ;;
+ *.asm) xform=asm ;;
+ *.c++) xform=c++ ;;
+ *.cc) xform=cc ;;
+ *.cpp) xform=cpp ;;
+ *.cxx) xform=cxx ;;
+ *.f90) xform=f90 ;;
+ *.for) xform=for ;;
+ esac
+
+ libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+ case "$libobj" in
+ *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+ *)
+ $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+ exit 1
+ ;;
+ esac
+
+ if test -z "$base_compile"; then
+ $echo "$modename: you must specify a compilation command" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $libobj"
+ else
+ removelist="$libobj"
+ fi
+
+ $run $rm $removelist
+ trap "$run $rm $removelist; exit 1" 1 2 15
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ removelist="$removelist $output_obj $lockfile"
+ trap "$run $rm $removelist; exit 1" 1 2 15
+ else
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until ln "$0" "$lockfile" 2>/dev/null; do
+ $show "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+ echo $srcfile > "$lockfile"
+ fi
+
+ if test -n "$fix_srcfile_path"; then
+ eval srcfile=\"$fix_srcfile_path\"
+ fi
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ # All platforms use -DPIC, to notify preprocessed assembler code.
+ command="$base_compile $pic_flag -DPIC $srcfile"
+ if test "$build_old_libs" = yes; then
+ lo_libobj="$libobj"
+ dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$dir" = "X$libobj"; then
+ dir="$objdir"
+ else
+ dir="$dir/$objdir"
+ fi
+ libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+
+ if test -d "$dir"; then
+ $show "$rm $libobj"
+ $run $rm $libobj
+ else
+ $show "$mkdir $dir"
+ $run $mkdir $dir
+ status=$?
+ if test $status -ne 0 && test ! -d $dir; then
+ exit $status
+ fi
+ fi
+ fi
+ if test "$compiler_o_lo" = yes; then
+ output_obj="$libobj"
+ command="$command -o $output_obj"
+ elif test "$compiler_c_o" = yes; then
+ output_obj="$obj"
+ command="$command -o $output_obj"
+ fi
+
+ $show "$command"
+ if $run eval "$command"; then :
+ else
+ test -n "$output_obj" && $run $rm $removelist
+ exit 1
+ fi
+
+ if test "$need_locks" = warn &&
+ test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+ echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test x"$output_obj" != x"$libobj"; then
+ $show "$mv $output_obj $libobj"
+ if $run $mv $output_obj $libobj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # If we have no pic_flag, then copy the object into place and finish.
+ if test -z "$pic_flag" && test "$build_old_libs" = yes; then
+ # Rename the .lo from within objdir to obj
+ if test -f $obj; then
+ $show $rm $obj
+ $run $rm $obj
+ fi
+
+ $show "$mv $libobj $obj"
+ if $run $mv $libobj $obj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+
+ # Now arrange that obj and lo_libobj become the same file
+ $show "$LN_S $obj $lo_libobj"
+ if $run $LN_S $obj $lo_libobj; then
+ exit 0
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # Allow error messages only from the first compilation.
+ suppress_output=' >/dev/null 2>&1'
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ command="$base_compile $srcfile"
+ if test "$compiler_c_o" = yes; then
+ command="$command -o $obj"
+ output_obj="$obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ command="$command$suppress_output"
+ $show "$command"
+ if $run eval "$command"; then :
+ else
+ $run $rm $removelist
+ exit 1
+ fi
+
+ if test "$need_locks" = warn &&
+ test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+ echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+
+ # Just move the object if needed
+ if test x"$output_obj" != x"$obj"; then
+ $show "$mv $output_obj $obj"
+ if $run $mv $output_obj $obj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we do not
+ # accidentally link it into a program.
+ if test "$build_libtool_libs" != yes; then
+ $show "echo timestamp > $libobj"
+ $run eval "echo timestamp > \$libobj" || exit $?
+ else
+ # Move the .lo from within objdir
+ $show "$mv $libobj $lo_libobj"
+ if $run $mv $libobj $lo_libobj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+ fi
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ $rm "$lockfile"
+ fi
+
+ exit 0
+ ;;
+
+ # libtool link mode
+ link)
+ modename="$modename: link"
+ C_compiler="$CC" # save it, to compile generated C sources
+ # CYGNUS LOCAL: tromey/java
+ # Always respect the CC configured in by ltconfig.
+ # CC="$nonopt"
+ # END CYGNUS LOCAL
+ case "$host" in
+ *-*-cygwin* | *-*-mingw* | *-*-os2*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invokation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+
+ # This is a source program that is used to create dlls on Windows
+ # Don't remove nor modify the starting and closing comments
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+#
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+# __hDllInstance_base = hInst;
+# return TRUE;
+# }
+# /* ltdll.c ends here */
+ # This is a source program that is used to create import libraries
+ # on Windows for dlls which lack them. Don't remove nor modify the
+ # starting and closing comments
+# /* impgen.c starts here */
+# /* Copyright (C) 1999 Free Software Foundation, Inc.
+#
+# This file is part of GNU libtool.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# */
+#
+# #include <stdio.h> /* for printf() */
+# #include <unistd.h> /* for open(), lseek(), read() */
+# #include <fcntl.h> /* for O_RDONLY, O_BINARY */
+# #include <string.h> /* for strdup() */
+#
+# static unsigned int
+# pe_get16 (fd, offset)
+# int fd;
+# int offset;
+# {
+# unsigned char b[2];
+# lseek (fd, offset, SEEK_SET);
+# read (fd, b, 2);
+# return b[0] + (b[1]<<8);
+# }
+#
+# static unsigned int
+# pe_get32 (fd, offset)
+# int fd;
+# int offset;
+# {
+# unsigned char b[4];
+# lseek (fd, offset, SEEK_SET);
+# read (fd, b, 4);
+# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+# }
+#
+# static unsigned int
+# pe_as32 (ptr)
+# void *ptr;
+# {
+# unsigned char *b = ptr;
+# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+# }
+#
+# int
+# main (argc, argv)
+# int argc;
+# char *argv[];
+# {
+# int dll;
+# unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
+# unsigned long export_rva, export_size, nsections, secptr, expptr;
+# unsigned long name_rvas, nexp;
+# unsigned char *expdata, *erva;
+# char *filename, *dll_name;
+#
+# filename = argv[1];
+#
+# dll = open(filename, O_RDONLY|O_BINARY);
+# if (!dll)
+# return 1;
+#
+# dll_name = filename;
+#
+# for (i=0; filename[i]; i++)
+# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':')
+# dll_name = filename + i +1;
+#
+# pe_header_offset = pe_get32 (dll, 0x3c);
+# opthdr_ofs = pe_header_offset + 4 + 20;
+# num_entries = pe_get32 (dll, opthdr_ofs + 92);
+#
+# if (num_entries < 1) /* no exports */
+# return 1;
+#
+# export_rva = pe_get32 (dll, opthdr_ofs + 96);
+# export_size = pe_get32 (dll, opthdr_ofs + 100);
+# nsections = pe_get16 (dll, pe_header_offset + 4 +2);
+# secptr = (pe_header_offset + 4 + 20 +
+# pe_get16 (dll, pe_header_offset + 4 + 16));
+#
+# expptr = 0;
+# for (i = 0; i < nsections; i++)
+# {
+# char sname[8];
+# unsigned long secptr1 = secptr + 40 * i;
+# unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
+# unsigned long vsize = pe_get32 (dll, secptr1 + 16);
+# unsigned long fptr = pe_get32 (dll, secptr1 + 20);
+# lseek(dll, secptr1, SEEK_SET);
+# read(dll, sname, 8);
+# if (vaddr <= export_rva && vaddr+vsize > export_rva)
+# {
+# expptr = fptr + (export_rva - vaddr);
+# if (export_rva + export_size > vaddr + vsize)
+# export_size = vsize - (export_rva - vaddr);
+# break;
+# }
+# }
+#
+# expdata = (unsigned char*)malloc(export_size);
+# lseek (dll, expptr, SEEK_SET);
+# read (dll, expdata, export_size);
+# erva = expdata - export_rva;
+#
+# nexp = pe_as32 (expdata+24);
+# name_rvas = pe_as32 (expdata+32);
+#
+# printf ("EXPORTS\n");
+# for (i = 0; i<nexp; i++)
+# {
+# unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
+# printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
+# }
+#
+# return 0;
+# }
+# /* impgen.c ends here */
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ compile_command="$CC"
+ finalize_command="$CC"
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ linkopts=
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+ else
+ lib_search_path=
+ fi
+ # now prepend the system-specific ones
+ eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ avoid_version=no
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ link_against_libtool_libs=
+ ltlibs=
+ module=no
+ objs=
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case "$arg" in
+ -all-static | -static)
+ if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+ fi
+ build_libtool_libs=no
+ build_old_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test $# -gt 0; do
+ arg="$1"
+ shift
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case "$prev" in
+ output)
+ compile_command="$compile_command @OUTPUT@"
+ finalize_command="$finalize_command @OUTPUT@"
+ ;;
+ esac
+
+ case "$prev" in
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ compile_command="$compile_command @SYMFILE@"
+ finalize_command="$finalize_command @SYMFILE@"
+ preload=yes
+ fi
+ case "$arg" in
+ *.la | *.lo) ;; # We handle these cases below.
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ dlprefiles="$dlprefiles $arg"
+ test "$prev" = dlfiles && dlfiles="$dlfiles $arg"
+ prev=
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ if test ! -f "$arg"; then
+ $echo "$modename: symbol file \`$arg' does not exist"
+ exit 1
+ fi
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ rpath)
+ rpath="$rpath $arg"
+ prev=
+ continue
+ ;;
+ xrpath)
+ xrpath="$xrpath $arg"
+ prev=
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi
+
+ prevarg="$arg"
+
+ case "$arg" in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ compile_command="$compile_command $link_static_flag"
+ finalize_command="$finalize_command $link_static_flag"
+ dlopen_self=$dlopen_self_static
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+ continue
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ if test "$export_dynamic" != yes; then
+ export_dynamic=yes
+ if test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ else
+ arg=
+ fi
+ fi
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ $echo "$modename: cannot have more than one -exported-symbols"
+ exit 1
+ fi
+ if test "$arg" = "-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -L*)
+ dir=`$echo "X$arg" | $Xsed -e 's%^-L\(.*\)$%\1%'`
+ case "$dir" in
+ /* | [A-Za-z]:[/\\]*)
+ # Add the corresponding hardcode_libdir_flag, if it is not identical.
+ ;;
+ *)
+ $echo "$modename: \`-L$dir' cannot specify a relative directory" 1>&2
+ exit 1
+ ;;
+ esac
+ case " $deplibs " in
+ *" $arg "*) ;;
+ *) deplibs="$deplibs $arg";;
+ esac
+ case " $lib_search_path " in
+ *" $dir "*) ;;
+ *) lib_search_path="$lib_search_path $dir";;
+ esac
+ case "$host" in
+ *-*-cygwin* | *-*-mingw* | *-*-os2*)
+ dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
+ case ":$dllsearchpath:" in
+ ::) dllsearchpath="$dllsearchdir";;
+ *":$dllsearchdir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
+ esac
+ ;;
+ esac
+ ;;
+
+ -l*)
+ deplibs="$deplibs $arg"
+ ;;
+
+ -module)
+ if test "$module" != yes; then
+ module=yes
+ if test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ else
+ arg=
+ fi
+ fi
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ xrpath="$xrpath "`$echo "X$arg" | $Xsed -e 's/^-R//'`
+ continue
+ ;;
+
+ -static)
+ # If we have no pic_flag, then this is the same as -all-static.
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ compile_command="$compile_command $link_static_flag"
+ finalize_command="$finalize_command $link_static_flag"
+ dlopen_self=$dlopen_self_static
+ fi
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case "$arg" in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ ;;
+
+ *.o | *.obj | *.a | *.lib)
+ # A standard object.
+ objs="$objs $arg"
+ ;;
+
+ *.lo)
+ # A library object.
+ if test "$prev" = dlfiles; then
+ dlfiles="$dlfiles $arg"
+ if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
+ prev=
+ fi
+ libobjs="$libobjs $arg"
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ dlname=
+ libdir=
+ library_names=
+ old_library=
+
+ # Check to see that this really is a libtool archive.
+ if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variable installed.
+ installed=yes
+
+ # If there is no directory component, then add one.
+ case "$arg" in
+ */* | *\\*) . $arg ;;
+ *) . ./$arg ;;
+ esac
+
+ # Get the name of the library we link against.
+ linklib=
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+
+ if test -z "$linklib"; then
+ $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
+ exit 1
+ fi
+
+ # Find the relevant object directory and library name.
+ name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
+
+ if test "X$installed" = Xyes; then
+ dir="$libdir"
+ else
+ dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$dir" = "X$arg"; then
+ dir="$objdir"
+ else
+ dir="$dir/$objdir"
+ fi
+ fi
+
+ if test -n "$dependency_libs"; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for deplib in $dependency_libs; do
+ case "$deplib" in
+ -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+ case " $rpath $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) xrpath="$xrpath $temp_xrpath";;
+ esac;;
+ -L*) case "$compile_command $temp_deplibs " in
+ *" $deplib "*) ;;
+ *) temp_deplibs="$temp_deplibs $deplib";;
+ esac;;
+ *) temp_deplibs="$temp_deplibs $deplib";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ fi
+
+ if test -z "$libdir"; then
+ # It is a libtool convenience library, so add in its objects.
+ convenience="$convenience $dir/$old_library"
+ old_convenience="$old_convenience $dir/$old_library"
+ deplibs="$deplibs$dependency_libs"
+ compile_command="$compile_command $dir/$old_library$dependency_libs"
+ finalize_command="$finalize_command $dir/$old_library$dependency_libs"
+ continue
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$prev" = dlfiles; then
+ dlfiles="$dlfiles $arg"
+ if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking statically,
+ # we need to preload.
+ prev=dlprefiles
+ else
+ # We should not create a dependency on this library, but we
+ # may need any libraries it requires.
+ compile_command="$compile_command$dependency_libs"
+ finalize_command="$finalize_command$dependency_libs"
+ prev=
+ continue
+ fi
+ fi
+
+ # The library was specified with -dlpreopen.
+ if test "$prev" = dlprefiles; then
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ dlprefiles="$dlprefiles $dir/$old_library"
+ else
+ dlprefiles="$dlprefiles $dir/$linklib"
+ fi
+ prev=
+ fi
+
+ if test "$build_libtool_libs" = yes && test -n "$library_names"; then
+ link_against_libtool_libs="$link_against_libtool_libs $arg"
+ if test -n "$shlibpath_var"; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath " in
+ *" $dir "*) ;;
+ *) temp_rpath="$temp_rpath $dir" ;;
+ esac
+ fi
+
+ # We need an absolute path.
+ case "$dir" in
+ /* | [A-Za-z]:[/\\]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ $echo "$modename: cannot determine absolute directory name of \`$libdir'" 1>&2
+ exit 1
+ fi
+ ;;
+ esac
+
+ # This is the magic to use -rpath.
+ # Skip directories that are in the system default run-time
+ # search path, unless they have been requested with -R.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+
+ lib_linked=yes
+ case "$hardcode_action" in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ compile_command="$compile_command $dir/$linklib"
+ deplibs="$deplibs $dir/$linklib"
+ case "$host" in
+ *-*-cygwin* | *-*-mingw* | *-*-os2*)
+ dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
+ if test -n "$dllsearchpath"; then
+ dllsearchpath="$dllsearchpath:$dllsearchdir"
+ else
+ dllsearchpath="$dllsearchdir"
+ fi
+ ;;
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case "$host" in
+ *-*-sunos*)
+ compile_shlibpath="$compile_shlibpath$dir:"
+ ;;
+ esac
+ case "$compile_command " in
+ *" -L$dir "*) ;;
+ *) compile_command="$compile_command -L$dir";;
+ esac
+ compile_command="$compile_command -l$name"
+ deplibs="$deplibs -L$dir -l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ case ":$compile_shlibpath:" in
+ *":$dir:"*) ;;
+ *) compile_shlibpath="$compile_shlibpath$dir:";;
+ esac
+ compile_command="$compile_command -l$name"
+ deplibs="$deplibs -l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+
+ relink)
+ if test "$hardcode_direct" = yes; then
+ compile_command="$compile_command $absdir/$linklib"
+ deplibs="$deplibs $absdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ case "$compile_command " in
+ *" -L$absdir "*) ;;
+ *) compile_command="$compile_command -L$absdir";;
+ esac
+ compile_command="$compile_command -l$name"
+ deplibs="$deplibs -L$absdir -l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case ":$compile_shlibpath:" in
+ *":$absdir:"*) ;;
+ *) compile_shlibpath="$compile_shlibpath$absdir:";;
+ esac
+ compile_command="$compile_command -l$name"
+ deplibs="$deplibs -l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+
+ *)
+ lib_linked=no
+ ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ $echo "$modename: configuration error: unsupported hardcode properties"
+ exit 1
+ fi
+
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes; then
+ finalize_command="$finalize_command $libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ case "$finalize_command " in
+ *" -L$libdir "*) ;;
+ *) finalize_command="$finalize_command -L$libdir";;
+ esac
+ finalize_command="$finalize_command -l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case ":$finalize_shlibpath:" in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
+ esac
+ finalize_command="$finalize_command -l$name"
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ case "$finalize_command " in
+ *" -L$dir "*) ;;
+ *) finalize_command="$finalize_command -L$libdir";;
+ esac
+ finalize_command="$finalize_command -l$name"
+ fi
+ else
+ # Transform directly to old archives if we don't build new libraries.
+ if test -n "$pic_flag" && test -z "$old_library"; then
+ $echo "$modename: cannot find static library for \`$arg'" 1>&2
+ exit 1
+ fi
+
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_command="$compile_command $dir/$linklib"
+ finalize_command="$finalize_command $dir/$linklib"
+ else
+ case "$compile_command " in
+ *" -L$dir "*) ;;
+ *) compile_command="$compile_command -L$dir";;
+ esac
+ compile_command="$compile_command -l$name"
+ case "$finalize_command " in
+ *" -L$dir "*) ;;
+ *) finalize_command="$finalize_command -L$dir";;
+ esac
+ finalize_command="$finalize_command -l$name"
+ fi
+ fi
+
+ # Add in any libraries that this one depends upon.
+ compile_command="$compile_command$dependency_libs"
+ finalize_command="$finalize_command$dependency_libs"
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case "$arg" in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ ;;
+ esac
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ fi
+ done
+
+ if test -n "$prev"; then
+ $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+ libobjs_save="$libobjs"
+
+ case "$output" in
+ "")
+ $echo "$modename: you must specify an output file" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+
+ *.a | *.lib)
+ if test -n "$link_against_libtool_libs"; then
+ $echo "$modename: error: cannot link libtool libraries into archives" 1>&2
+ exit 1
+ fi
+
+ if test -n "$deplibs"; then
+ $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+ fi
+
+ if test -n "$dlfiles$dlprefiles"; then
+ $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$rpath"; then
+ $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$xrpath"; then
+ $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$export_symbols"; then
+ $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+ fi
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ ;;
+
+ *.la)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case "$outputname" in
+ lib*)
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ if test "$module" = no; then
+ $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ eval libname=\"$libname_spec\"
+ else
+ libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ fi
+ ;;
+ esac
+
+ output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$output_objdir" = "X$output"; then
+ output_objdir="$objdir"
+ else
+ output_objdir="$output_objdir/$objdir"
+ fi
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ if test -n "$objs"; then
+ $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
+ exit 1
+ fi
+
+ # How the heck are we supposed to write a wrapper for a shared library?
+ if test -n "$link_against_libtool_libs"; then
+ $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
+ exit 1
+ fi
+
+ if test -n "$dlfiles$dlprefiles"; then
+ $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
+ fi
+
+ set dummy $rpath
+ if test $# -gt 2; then
+ $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+ fi
+ install_libdir="$2"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ libext=al
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+ dependency_libs="$deplibs"
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+ fi
+ else
+
+ # Parse the version information argument.
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ IFS="$save_ifs"
+
+ if test -n "$8"; then
+ $echo "$modename: too many parameters to \`-version-info'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ current="$2"
+ revision="$3"
+ age="$4"
+
+ # Check that each of the things are valid numbers.
+ case "$current" in
+ 0 | [1-9] | [1-9][0-9]*) ;;
+ *)
+ $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case "$revision" in
+ 0 | [1-9] | [1-9][0-9]*) ;;
+ *)
+ $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case "$age" in
+ 0 | [1-9] | [1-9][0-9]*) ;;
+ *)
+ $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ if test $age -gt $current; then
+ $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case "$version_type" in
+ none) ;;
+
+ irix)
+ major=`expr $current - $age + 1`
+ versuffix="$major.$revision"
+ verstring="sgi$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test $loop != 0; do
+ iface=`expr $revision - $loop`
+ loop=`expr $loop - 1`
+ verstring="sgi$major.$iface:$verstring"
+ done
+ ;;
+
+ linux)
+ major=.`expr $current - $age`
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ major=`expr $current - $age`
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test $loop != 0; do
+ iface=`expr $current - $loop`
+ loop=`expr $loop - 1`
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ verstring="$verstring:${current}.0"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current";
+ ;;
+
+ windows)
+ # Like Linux, but with '-' rather than '.', since we only
+ # want one extension on Windows 95.
+ major=`expr $current - $age`
+ versuffix="-$major-$age-$revision"
+ ;;
+
+ *)
+ $echo "$modename: unknown library version type \`$version_type'" 1>&2
+ echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ verstring="0.0"
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+
+ dependency_libs="$deplibs"
+ case "$host" in
+ *-*-cygwin* | *-*-mingw* | *-*-os2*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *)
+ # Add libc to deplibs on all other systems.
+ deplibs="$deplibs -lc"
+ ;;
+ esac
+ fi
+
+ # Create the output directory, or remove our outputs if we need to.
+ if test -d $output_objdir; then
+ $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
+ $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
+ else
+ $show "$mkdir $output_objdir"
+ $run $mkdir $output_objdir
+ status=$?
+ if test $status -ne 0 && test ! -d $output_objdir; then
+ exit $status
+ fi
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+ fi
+
+ if test "$build_libtool_libs" = yes; then
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case "$deplibs_check_method" in
+ pass_all)
+ newdeplibs=$deplibs
+ ;; # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behaviour.
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $rm conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $rm conftest
+ $C_compiler -o conftest conftest.c $deplibs
+ if test $? -eq 0 ; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ name="`expr $i : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ deplib_matches=`eval \\$echo \"$library_names_spec\"`
+ set dummy $deplib_matches
+ deplib_match=$2
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ echo
+ echo "*** Warning: This library needs some functionality provided by $i."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have."
+ fi
+ else
+ newdeplibs="$newdeplibs $i"
+ fi
+ done
+ else
+ # Error occured in the first compile. Let's try to salvage the situation:
+ # Compile a seperate program for each library.
+ for i in $deplibs; do
+ name="`expr $i : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" ; then
+ $rm conftest
+ $C_compiler -o conftest conftest.c $i
+ # Did it work?
+ if test $? -eq 0 ; then
+ ldd_output=`ldd conftest`
+ libname=`eval \\$echo \"$libname_spec\"`
+ deplib_matches=`eval \\$echo \"$library_names_spec\"`
+ set dummy $deplib_matches
+ deplib_match=$2
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ echo
+ echo "*** Warning: This library needs some functionality provided by $i."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have."
+ fi
+ else
+ droppeddeps=yes
+ echo
+ echo "*** Warning! Library $i is needed by this library but I was not able to"
+ echo "*** make it link in! You will probably need to install it or some"
+ echo "*** library that it depends on before this library will be fully"
+ echo "*** functional. Installing it before continuing would be even better."
+ fi
+ else
+ newdeplibs="$newdeplibs $i"
+ fi
+ done
+ fi
+ deplibs=$newdeplibs
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method
+ file_magic_regex="`expr \"$deplibs_check_method\" : \"$2 \(.*\)\"`"
+ for a_deplib in $deplibs; do
+ name="`expr $a_deplib : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ for i in $lib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potlib" 2>/dev/null \
+ | grep " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+ case "$potliblink" in
+ /*) potlib="$potliblink";;
+ *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" \
+ | sed 10q \
+ | egrep "$file_magic_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ echo
+ echo "*** Warning: This library needs some functionality provided by $a_deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have."
+ fi
+ else
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ fi
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *) newdeplibs=""
+ if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+ -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' |
+ grep . >/dev/null; then
+ echo
+ if test "X$deplibs_check_method" = "Xnone"; then
+ echo "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ echo "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ echo "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ fi
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ echo
+ echo "*** Warning: libtool could not satisfy all declared inter-library"
+ echo "*** dependencies of module $libname. Therefore, libtool will create"
+ echo "*** a static module, that should work as long as the dlopening"
+ echo "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ dlname=
+ library_names=
+ else
+ echo "*** The inter-library dependencies that have been dropped here will be"
+ echo "*** automatically added whenever a program is linked with this library"
+ echo "*** or is declared to -dlopen it."
+ fi
+ fi
+ fi
+
+ # test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ deplibs=$newdeplibs
+ # Done checking deplibs!
+
+ # Get the real and link names of the library.
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ realname="$2"
+ shift; shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ lib="$output_objdir/$realname"
+ for link
+ do
+ linknames="$linknames $link"
+ done
+
+ # Ensure that we have .o objects for linkers which dislike .lo
+ # (e.g. aix) incase we are running --disable-static
+ for obj in $libobjs; do
+ oldobj=`$echo "X$obj" | $Xsed -e "$lo2o"`
+ test -f $oldobj || ${LN_S} $obj $oldobj
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+ if test -n "$whole_archive_flag_spec"; then
+ if test -n "$convenience"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ fi
+ else
+ for xlib in $convenience; do
+ # Extract the objects.
+ xdir="$xlib"x
+ generated="$generated $xdir"
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "mkdir $xdir"
+ $run mkdir "$xdir"
+ status=$?
+ if test $status -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ $show "(cd $xdir && $AR x ../$xlib)"
+ $run eval "(cd \$xdir && $AR x ../\$xlib)" || exit $?
+
+ libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+
+ linkopts="$linkopts $flag"
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ $show "generating symbol list for \`$libname.la'"
+ export_symbols="$objdir/$libname.exp"
+ $run $rm $export_symbols
+ eval cmds=\"$export_symbols_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex"; then
+ $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+ $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+ $run eval '$mv "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+ fi
+
+ # Do each of the archive commands.
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval cmds=\"$archive_expsym_cmds\"
+ else
+ eval cmds=\"$archive_cmds\"
+ fi
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+ $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ *.lo | *.o | *.obj)
+ if test -n "$link_against_libtool_libs"; then
+ $echo "$modename: error: cannot link libtool libraries into objects" 1>&2
+ exit 1
+ fi
+
+ if test -n "$deplibs"; then
+ $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+ fi
+
+ if test -n "$dlfiles$dlprefiles"; then
+ $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$rpath"; then
+ $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$xrpath"; then
+ $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+ fi
+
+ case "$output" in
+ *.lo)
+ if test -n "$objs"; then
+ $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+ exit 1
+ fi
+ libobj="$output"
+ obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $run $rm $obj $libobj
+
+ # Create the old-style object.
+ reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
+
+ output="$obj"
+ eval cmds=\"$reload_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ # Exit if we aren't doing a library object file.
+ test -z "$libobj" && exit 0
+
+ if test "$build_libtool_libs" != yes; then
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ $show "echo timestamp > $libobj"
+ $run eval "echo timestamp > $libobj" || exit $?
+ exit 0
+ fi
+
+ if test -n "$pic_flag"; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs"
+ output="$libobj"
+ eval cmds=\"$reload_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ else
+ # Just create a symlink.
+ $show $rm $libobj
+ $run $rm $libobj
+ $show "$LN_S $obj $libobj"
+ $run $LN_S $obj $libobj || exit $?
+ fi
+
+ exit 0
+ ;;
+
+ # Anything else should be a program.
+ *)
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+ fi
+
+ if test "$preload" = yes; then
+ if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
+ test "$dlopen_self_static" = unknown; then
+ $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+ fi
+ fi
+
+ if test "$dlself" = yes && test "$export_dynamic" = no; then
+ $echo "$modename: error: \`-dlopen self' requires \`-export-dynamic'" 1>&2
+ exit 1
+ fi
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$compile_rpath " in
+ *" $libdir "*) ;;
+ *) compile_rpath="$compile_rpath $libdir" ;;
+ esac
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$output_objdir" = "X$output"; then
+ output_objdir="$objdir"
+ else
+ output_objdir="$output_objdir/$objdir"
+ fi
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ fi
+
+ dlsyms=
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" = yes; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ dlsyms="${outputname}S.c"
+ else
+ $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+ fi
+ fi
+
+ if test -n "$dlsyms"; then
+ case "$dlsyms" in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$objdir/${output}.nm"
+
+ if test -d $objdir; then
+ $show "$rm $nlist ${nlist}S ${nlist}T"
+ $run $rm "$nlist" "${nlist}S" "${nlist}T"
+ else
+ $show "$mkdir $objdir"
+ $run $mkdir $objdir
+ status=$?
+ if test $status -ne 0 && test ! -d $objdir; then
+ exit $status
+ fi
+ fi
+
+ # Parse the name list into a source file.
+ $show "creating $objdir/$dlsyms"
+
+ $echo > "$objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ $show "generating symbol list for \`$output'"
+
+ echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ for arg in $progfiles; do
+ $show "extracting global C symbols from \`$arg'"
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ $run eval '$mv "$nlist"T "$nlist"'
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ $run eval '$mv "$nlist"T "$nlist"'
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$objdir/$output.exp"
+ $run $rm $export_symbols
+ $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ else
+ $run $rm $export_symbols
+ $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$objdir/$output.exp"'
+ $run eval 'grep -f "$objdir/$output.exp" < "$nlist" > "$nlist"T'
+ $run eval 'mv "$nlist"T "$nlist"'
+ fi
+ fi
+
+ for arg in $dlprefiles; do
+ $show "extracting global C symbols from \`$arg'"
+ name=`echo "$arg" | sed -e 's%^.*/%%'`
+ $run eval 'echo ": $name " >> "$nlist"'
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -z "$run"; then
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $mv "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+ :
+ else
+ grep -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+ else
+ echo '/* NONE */' >> "$output_objdir/$dlsyms"
+ fi
+
+ $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+ sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \
+ -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \
+ < "$nlist" >> "$output_objdir/$dlsyms"
+
+ $echo >> "$output_objdir/$dlsyms" "\
+ {0, (lt_ptr_t) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ fi
+
+ pic_flag_for_symtable=
+ case "$host" in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2*|*-*-freebsd3.0*)
+ case "$compile_command " in
+ *" -static "*) ;;
+ *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
+ esac
+ esac
+
+ # Now compile the dynamic symbol file.
+ $show "(cd $objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+ $run eval '(cd $objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+ # Transform the symbol file into the correct name.
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.${objext}%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.${objext}%"`
+ ;;
+ *)
+ $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+ exit 1
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+ fi
+
+ if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
+ # Replace the output file specification.
+ compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ $show "$link_command"
+ $run eval "$link_command"
+ exit $?
+ fi
+
+ if test -n "$shlibpath_var"; then
+ # We should set the shlibpath_var
+ rpath=
+ for dir in $temp_rpath; do
+ case "$dir" in
+ /* | [A-Za-z]:[/\\]*)
+ # Absolute path.
+ rpath="$rpath$dir:"
+ ;;
+ *)
+ # Relative path: add a thisdir entry.
+ rpath="$rpath\$thisdir/$dir:"
+ ;;
+ esac
+ done
+ temp_rpath="$rpath"
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ # AGH! Flame the AIX and HP-UX people for me, will ya?
+ $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+ $echo "$modename: \`$output' will be relinked during installation" 1>&2
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Create the binary in the object directory, then wrap it.
+ if test ! -d $output_objdir; then
+ $show "$mkdir $output_objdir"
+ $run $mkdir $output_objdir
+ status=$?
+ if test $status -ne 0 && test ! -d $objdir; then
+ exit $status
+ fi
+ fi
+
+ # Delete the old output file.
+ $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ $show "$link_command"
+ $run eval "$link_command" || exit $?
+
+ # Now create the wrapper script.
+ $show "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Quote $echo for shipping.
+ if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
+ case "$0" in
+ /* | [A-Za-z]:[/\\]*) qecho="$SHELL $0 --fallback-echo";;
+ *) qecho="$SHELL `pwd`/$0 --fallback-echo";;
+ esac
+ qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+ else
+ qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if our run command is non-null.
+ if test -z "$run"; then
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
+ esac
+ $rm $output
+ trap "$rm $output; exit 1" 1 2 15
+
+ $echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variable:
+ link_against_libtool_libs='$link_against_libtool_libs'
+else
+ # When we are sourced in execute mode, \$file and \$echo are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ echo=\"$qecho\"
+ file=\"\$0\"
+ # Make sure echo works.
+ if test \"X\$1\" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+ # Yippee, \$echo works!
+ :
+ else
+ # Restart under the correct shell, and then maybe \$echo will work.
+ exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+ fi
+ fi\
+"
+ $echo >> $output "\
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ /* | [A-Za-z]:[/\\]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
+ done
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ echo >> $output "\
+ program=lt-'$outputname'
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" || \\
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $mkdir \"\$progdir\"
+ else
+ $rm \"\$progdir/\$file\"
+ fi"
+
+ echo >> $output "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if (cd \"\$thisdir\" && eval \$relink_command); then :
+ else
+ $rm \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $rm \"\$progdir/\$program\";
+ $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $rm \"\$progdir/\$file\"
+ fi"
+ else
+ echo >> $output "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ echo >> $output "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $echo >> $output "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ # fixup the dll searchpath if we need to.
+ if test -n "$dllsearchpath"; then
+ $echo >> $output "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ $echo >> $output "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+"
+ case $host in
+ *-*-cygwin* | *-*-mingw | *-*-os2*)
+ # win32 systems need to use the prog path for dll
+ # lookup to work
+ $echo >> $output "\
+ exec \$progdir\\\\\$program \${1+\"\$@\"}
+"
+ ;;
+ *)
+ $echo >> $output "\
+ # Export the path to the program.
+ PATH=\"\$progdir:\$PATH\"
+ export PATH
+
+ exec \$program \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $echo >> $output "\
+ \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
+ \$echo \"This script is just a wrapper for \$program.\" 1>&2
+ echo \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+ chmod +x $output
+ fi
+ exit 0
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ # Add in members from convenience archives.
+ for xlib in $addlibs; do
+ # Extract the objects.
+ xdir="$xlib"x
+ generated="$generated $xdir"
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "mkdir $xdir"
+ $run mkdir "$xdir"
+ status=$?
+ if test $status -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ $show "(cd $xdir && $AR x ../$xlib)"
+ $run eval "(cd \$xdir && $AR x ../\$xlib)" || exit $?
+
+ oldobjs="$oldobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+ done
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ eval cmds=\"$old_archive_from_new_cmds\"
+ else
+ eval cmds=\"$old_archive_cmds\"
+ fi
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ done
+
+ if test -n "$generated"; then
+ $show "${rm}r$generated"
+ $run ${rm}r$generated
+ fi
+
+ # Now create the libtool archive.
+ case "$output" in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ $show "creating $output"
+
+ if test -n "$xrpath"; then
+ temp_xrpath=
+ for libdir in $xrpath; do
+ temp_xrpath="$temp_xrpath -R$libdir"
+ done
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+
+ # Only create the output if not a dry run.
+ if test -z "$run"; then
+ $echo > $output "\
+# $output - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+
+# The name that we can dlopen(3).
+dlname='$dlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=no
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'\
+"
+
+ $rm "$output_objdir/$outputname"i
+ sed 's/^installed=no$/installed=yes/' \
+ < "$output" > "$output_objdir/$outputname"i || exit 1
+ fi
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+ $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $?
+ ;;
+ esac
+ exit 0
+ ;;
+
+ # libtool install mode
+ install)
+ modename="$modename: install"
+
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then
+ # Aesthetically quote it.
+ arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+ case "$arg" in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$arg "
+ arg="$1"
+ shift
+ else
+ install_prog=
+ arg="$nonopt"
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case "$arg" in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$install_prog$arg"
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ for arg
+ do
+ if test -n "$dest"; then
+ files="$files $dest"
+ dest="$arg"
+ continue
+ fi
+
+ case "$arg" in
+ -d) isdir=yes ;;
+ -f) prev="-f" ;;
+ -g) prev="-g" ;;
+ -m) prev="-m" ;;
+ -o) prev="-o" ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*) ;;
+
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ prev=
+ else
+ dest="$arg"
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case "$arg" in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$install_prog $arg"
+ done
+
+ if test -z "$install_prog"; then
+ $echo "$modename: you must specify an install program" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ if test -n "$prev"; then
+ $echo "$modename: the \`$prev' option requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ $echo "$modename: no file or destination specified" 1>&2
+ else
+ $echo "$modename: you must specify a destination" 1>&2
+ fi
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Strip any trailing slash from the destination.
+ dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$destdir" = "X$dest" && destdir=.
+ destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files
+ if test $# -gt 2; then
+ $echo "$modename: \`$dest' is not a directory" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ fi
+ case "$destdir" in
+ /* | [A-Za-z]:[/\\]*) ;;
+ *)
+ for file in $files; do
+ case "$file" in
+ *.lo) ;;
+ *)
+ $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case "$file" in
+ *.a | *.lib)
+ # Do the static libraries later.
+ staticlibs="$staticlibs $file"
+ ;;
+
+ *.la)
+ # Check to see that this really is a libtool archive.
+ if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ library_names=
+ old_library=
+ # If there is no directory component, then add one.
+ case "$file" in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) current_libdirs="$current_libdirs $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) future_libdirs="$future_libdirs $libdir" ;;
+ esac
+ fi
+
+ dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/"
+ test "X$dir" = "X$file/" && dir=
+ dir="$dir$objdir"
+
+ # See the names of the shared library.
+ set dummy $library_names
+ if test -n "$2"; then
+ realname="$2"
+ shift
+ shift
+
+ # Install the shared library and build the symlinks.
+ $show "$install_prog $dir/$realname $destdir/$realname"
+ $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $?
+ test "X$dlname" = "X$realname" && dlname=
+
+ if test $# -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ for linkname
+ do
+ test "X$dlname" = "X$linkname" && dlname=
+ if test "$linkname" != "$realname"; then
+ $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+ $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+ fi
+ done
+ fi
+
+ if test -n "$dlname"; then
+ # Install the dynamically-loadable library.
+ $show "$install_prog $dir/$dlname $destdir/$dlname"
+ $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $?
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ eval cmds=\"$postinstall_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ # Install the pseudo-library for information purposes.
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ instname="$dir/$name"i
+ if test ! -f "$instname"; then
+ # Just in case it was removed...
+ $show "Creating $instname"
+ $rm "$instname"
+ sed 's/^installed=no$/installed=yes/' "$file" > "$instname"
+ fi
+ $show "$install_prog $instname $destdir/$name"
+ $run eval "$install_prog $instname $destdir/$name" || exit $?
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case "$destfile" in
+ *.lo)
+ staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+ ;;
+ *.o | *.obj)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ if test -n "$destfile"; then
+ $show "$install_prog $file $destfile"
+ $run eval "$install_prog $file $destfile" || exit $?
+ fi
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+ $show "$install_prog $staticobj $staticdest"
+ $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+ fi
+ exit 0
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ destfile="$destdir/$destfile"
+ fi
+
+ # Do a test to see if this is really a libtool program.
+ if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ link_against_libtool_libs=
+ relink_command=
+
+ # If there is no directory component, then add one.
+ case "$file" in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Check the variables that should have been set.
+ if test -z "$link_against_libtool_libs"; then
+ $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
+ exit 1
+ fi
+
+ finalize=yes
+ for lib in $link_against_libtool_libs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ # If there is no directory component, then add one.
+ case "$lib" in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+ fi
+ libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`"
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+ finalize=no
+ fi
+ done
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ if test "$finalize" = yes; then
+ outputname="/tmp/$$-$file"
+ # Replace the output file specification.
+ relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2
+ $show "$relink_command"
+ if $run eval "$relink_command"; then :
+ else
+ $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+ continue
+ fi
+ file="$outputname"
+ else
+ $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2
+ fi
+ else
+ # Install the binary that we compiled earlier.
+ file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ $show "$install_prog$stripme $file $destfile"
+ $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+ test -n "$outputname" && $rm $outputname
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+
+ $show "$install_prog $file $oldlib"
+ $run eval "$install_prog \$file \$oldlib" || exit $?
+
+ # Do each command in the postinstall commands.
+ eval cmds=\"$old_postinstall_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ done
+
+ if test -n "$future_libdirs"; then
+ $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+ fi
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ test -n "$run" && current_libdirs=" -n$current_libdirs"
+ exec $SHELL $0 --finish$current_libdirs
+ exit 1
+ fi
+
+ exit 0
+ ;;
+
+ # libtool finish mode
+ finish)
+ modename="$modename: finish"
+ libdirs="$nonopt"
+ admincmds=
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for dir
+ do
+ libdirs="$libdirs $dir"
+ done
+
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ eval cmds=\"$finish_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || admincmds="$admincmds
+ $cmd"
+ done
+ IFS="$save_ifs"
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $run eval "$cmds" || admincmds="$admincmds
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ test "$show" = : && exit 0
+
+ echo "----------------------------------------------------------------------"
+ echo "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ echo " $libdir"
+ done
+ echo
+ echo "If you ever happen to want to link against installed libraries"
+ echo "in a given directory, LIBDIR, you must either use libtool, and"
+ echo "specify the full pathname of the library, or use \`-LLIBDIR'"
+ echo "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ echo " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ echo " - add LIBDIR to the \`$runpath_var' environment variable"
+ echo " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ echo " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ echo " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ echo
+ echo "See any operating system documentation about shared libraries for"
+ echo "more information, such as the ld(1) and ld.so(8) manual pages."
+ echo "----------------------------------------------------------------------"
+ exit 0
+ ;;
+
+ # libtool execute mode
+ execute)
+ modename="$modename: execute"
+
+ # The first argument is the command name.
+ cmd="$nonopt"
+ if test -z "$cmd"; then
+ $echo "$modename: you must specify a COMMAND" 1>&2
+ $echo "$help"
+ exit 1
+ fi
+
+ # Handle -dlopen flags immediately.
+ for file in $execute_dlfiles; do
+ if test ! -f "$file"; then
+ $echo "$modename: \`$file' is not a file" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ dir=
+ case "$file" in
+ *.la)
+ # Check to see that this really is a libtool archive.
+ if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+
+ # If there is no directory component, then add one.
+ case "$file" in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+
+ if test -f "$dir/$objdir/$dlname"; then
+ dir="$dir/$objdir"
+ else
+ $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+ exit 1
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+ ;;
+
+ *)
+ $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case "$file" in
+ -*) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ # If there is no directory component, then add one.
+ case "$file" in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+ args="$args \"$file\""
+ done
+
+ if test -z "$run"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+
+ # Restore saved enviroment variables
+ if test "${save_LC_ALL+set}" = set; then
+ LC_ALL="$save_LC_ALL"; export LC_ALL
+ fi
+ if test "${save_LANG+set}" = set; then
+ LANG="$save_LANG"; export LANG
+ fi
+
+ # Now actually exec the command.
+ eval "exec \$cmd$args"
+
+ $echo "$modename: cannot exec \$cmd$args"
+ exit 1
+ else
+ # Display what would be done.
+ eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+ $echo "export $shlibpath_var"
+ $echo "$cmd$args"
+ exit 0
+ fi
+ ;;
+
+ # libtool uninstall mode
+ uninstall)
+ modename="$modename: uninstall"
+ rm="$nonopt"
+ files=
+
+ for arg
+ do
+ case "$arg" in
+ -*) rm="$rm $arg" ;;
+ *) files="$files $arg" ;;
+ esac
+ done
+
+ if test -z "$rm"; then
+ $echo "$modename: you must specify an RM program" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ for file in $files; do
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+ rmfiles="$file"
+
+ case "$name" in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ . $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ rmfiles="$rmfiles $dir/$n"
+ test "X$n" = "X$dlname" && dlname=
+ done
+ test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname"
+ test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
+
+ $show "$rm $rmfiles"
+ $run $rm $rmfiles
+
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ eval cmds=\"$postuninstall_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd"
+ done
+ IFS="$save_ifs"
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ eval cmds=\"$old_postuninstall_cmds\"
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd"
+ done
+ IFS="$save_ifs"
+ fi
+
+ # FIXME: should reinstall the best remaining shared library.
+ fi
+ ;;
+
+ *.lo)
+ if test "$build_old_libs" = yes; then
+ oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
+ rmfiles="$rmfiles $dir/$oldobj"
+ fi
+ $show "$rm $rmfiles"
+ $run $rm $rmfiles
+ ;;
+
+ *)
+ $show "$rm $rmfiles"
+ $run $rm $rmfiles
+ ;;
+ esac
+ done
+ exit 0
+ ;;
+
+ "")
+ $echo "$modename: you must specify a MODE" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ ;;
+ esac
+
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+fi # test -z "$show_help"
+
+# We need to display help for each of the modes.
+case "$mode" in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+ --config show all configuration variables
+ --debug enable verbose shell tracing
+-n, --dry-run display commands without modifying any files
+ --features display basic configuration information and exit
+ --finish same as \`--mode=finish'
+ --help display this help message and exit
+ --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
+ --quiet same as \`--silent'
+ --silent don't print informational messages
+ --version print version information
+
+MODE must be one of the following:
+
+ compile compile a source file into a libtool object
+ execute automatically set library path, then run a program
+ finish complete the installation of libtool libraries
+ install install libraries or executables
+ link create a library or an executable
+ uninstall remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE."
+ exit 0
+ ;;
+
+compile)
+ $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -static always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+execute)
+ $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+finish)
+ $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+install)
+ $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+link)
+ $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -static do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+uninstall)
+ $echo
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+*)
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+esac
+
+echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/makeall.bat b/makeall.bat
new file mode 100644
index 00000000000..d2d415f0a49
--- /dev/null
+++ b/makeall.bat
@@ -0,0 +1,16 @@
+@echo off
+chdir libiberty
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\bfd
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\opcodes
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\gprof
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\binutils
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\gas
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..\ld
+make %1 %2 %3 %4 %5 %6 %7 %8 %9
+chdir ..
diff --git a/makefile.vms b/makefile.vms
new file mode 100644
index 00000000000..a9e363403b5
--- /dev/null
+++ b/makefile.vms
@@ -0,0 +1,71 @@
+#
+# makefile for bfd, binutils and gas
+#
+# Created by Klaus K"ampf (kkaempf@rmi.de)
+#
+# You must use Version 3.76 of GNU Make
+#
+#
+
+ifeq ($(ARCH),ALPHA)
+CC = gcc
+GASCC = $(CC)
+else
+CC = cc
+GASCC = gcc
+endif
+
+ifeq ($(CC),cc)
+ CHECK-COMPILER = check_compiler
+else
+ CHECK-COMPILER =
+endif
+
+all: check_cc $(CHECK-COMPILER) [.binutils]makefile.vms
+ $(CD) [.bfd]
+ @gmake "CC=$(CC)"
+ $(CD) [-.opcodes]
+ @gmake "CC=$(CC)"
+ $(CD) [-.libiberty]
+ @gmake "CC=$(CC)"
+ $(CD) [-.binutils]
+ @gmake "CC=$(CC)"
+ $(CD) [-.gas]
+ @gmake "CC=$(GASCC)"
+ $(CD) [-]
+
+check_cc:
+ifeq ($CC,)
+ @$(ECHO) "Please edit MAKEFILE.VMS and select a C Compiler."
+ stop
+endif
+
+check_compiler:
+ @$(ECHO) "Perform a '$$ @setup' before starting make"
+
+[.binutils]makefile.vms:
+ $(CD) [.binutils]
+ $$ @configure
+ $(CD) [-]
+
+install: all
+ $(CD) [.binutils]
+ @gmake "CC=$(CC)" install
+ $(CD) [-]
+ $(CD) [.gas]
+ @gmake "CC=$(GASCC)" install
+ $(CD) [-]
+
+clean:
+ $(CD) [.bfd]
+ @gmake clean
+ $(CD) [-.opcodes]
+ @gmake clean
+ $(CD) [-.libiberty]
+ @gmake clean
+ $(CD) [-.binutils]
+ @gmake clean
+ $(CD) [-.gas]
+ @gmake clean
+ $(CD) [-]
+
diff --git a/missing b/missing
new file mode 100755
index 00000000000..7789652e877
--- /dev/null
+++ b/missing
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing - GNU libit 0.0"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`configure.in'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`configure.in'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`configure.in'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case "$f" in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f y.tab.h ]; then
+ echo >y.tab.h
+ fi
+ if [ ! -f y.tab.c ]; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f lex.yy.c ]; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/mkinstalldirs b/mkinstalldirs
new file mode 100755
index 00000000000..cc8783edce3
--- /dev/null
+++ b/mkinstalldirs
@@ -0,0 +1,36 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Last modified: 1994-03-25
+# Public domain
+
+errstatus=0
+
+for file in ${1+"$@"} ; do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d in ${1+"$@"} ; do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp" 1>&2
+ mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
+ fi
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/move-if-change b/move-if-change
new file mode 100755
index 00000000000..ee1b348beeb
--- /dev/null
+++ b/move-if-change
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Copyright (C) 1996 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if
+test -r $2
+then
+if
+cmp $1 $2 > /dev/null
+then
+echo $2 is unchanged
+rm -f $1
+else
+mv -f $1 $2
+fi
+else
+mv -f $1 $2
+fi
diff --git a/mpw-README b/mpw-README
new file mode 100644
index 00000000000..767140b5b26
--- /dev/null
+++ b/mpw-README
@@ -0,0 +1,376 @@
+This is basic information about the Macintosh(tm) MPW(tm) port of the
+GNU tools. The information below applies to both native and cross
+compilers.
+
+(Please note that there are two versions of this file; "mpw-README"
+is the source form, and "Read Me for MPW" is the distribution form.
+"Read Me for MPW" has 8-bit chars such as \Option-d embedded in it.)
+
+INSTALLING GNU TOOLS
+
+* System Requirements
+
+To use these tools, you will need a Mac with a 68020 or better or else
+any PowerMac, System 7.1 or later, and MPW 3.3 or 3.4. You will *not*
+need any other MPW compiler unless you want to rebuild from sources,
+nor even any include files, unless you are building actual Mac
+applications. For PowerMac native you will need PPCLink, however;
+also the executables are PowerPC-only.
+
+* Automated Installation
+
+The simplest way to install GNU tools is to run the Install script.
+The script will copy things to where you want to keep them, will build
+a UserStartup file with settings corresponding to where things were
+copied, and offer to put that UserStartup file in your MPW folder.
+
+The Install script does not alter anything in the System Folder, and
+it does not take any action without confirmation.
+
+The Install script will be at the top level of the binary
+distribution, or at the top level of the object directory if
+rebuilding from source. (The sources include a file called
+"mpw-install" at the top level, but it is the source to the Install
+script and cannot be run directly.)
+
+* Manual Installation
+
+If you don't want to run the Install script, you can do installation
+manually; this section describes the steps involved.
+
+The GNU tools can go in any directory that is in your {Commands} list.
+We generally put all the tools somewhere like {Boot}Cygnus:latest:bin,
+and then add to a UserStartup file:
+
+ set Commands "{Boot}Cygnus:latest:bin:,{Commands}"
+
+However, the cpp and cc1 programs of GCC are not normally stored here.
+Instead, they will be in a "lib" directory that is alongside "bin",
+and organized by target and version underneath, with names like
+
+ :lib:gcc-lib:<target>:cygnus-<version>:
+
+If you build and install everything yourself according to the build
+instructions below, then you will not have any problems. However, you
+may discover that GCC seems unable to find the right cpp and cc1;
+usually this will be because directory names have changed. (Even
+renaming your hard disk will make this happen.) In such cases, you
+have several choices. One is just to add this directory to
+{Commands}, but then you will not be able to get any other cpp or cc1,
+such as those used by a different target or version. Another way is
+to rename your disk and directories to match the prefix used when the
+tools were compiled. Finally, you can set the variable
+GCC_EXEC_PREFIX to point to the library directory:
+
+ set GCC_EXEC_PREFIX MyDisk:Stuff:lib:gcc-lib:
+ export GCC_EXEC_PREFIX
+
+You may also want to edit MPW's HEXA 128 resource. When GCC is built
+using a native GCC, it is compiled to use a special stack allocator
+function alloca(). While this is very efficient, it means that GCC
+will need considerable stack space to run, especially when compiling
+large programs with optimization turned on. You give MPW more stack
+by editing the HEXA 128 resource of the MPW Shell. A value of "0008
+0000" gives 512K of stack size, which is usually sufficient.
+
+USING GNU TOOLS
+
+* Using Native PowerMac GCC
+
+Using a native PowerMac GCC to produce MPW tools or MacOS applications
+is more complicated than just "gC foo.c", although no more complicated
+than with other Mac compilers.
+
+To build a native PowerMac MPW tool, use this sequence, where hello.c
+is the usual "hello world" program, and genericcfrg.r is the Rez file
+with the code fragment resource:
+
+gC -I{CIncludes} -fno-builtin -Dpascal= -c -g hello.c
+PPCLink hello.o -o hello \Option-d
+ "{PPCLibraries}"StdCRuntime.o \Option-d
+ "{SharedLibraries}"InterfaceLib \Option-d
+ "{SharedLibraries}"StdCLib \Option-d
+ "{PPCLibraries}"PPCToolLibs.o \Option-d
+ "{PPCLibraries}"PPCCRuntime.o \Option-d
+ "{GCCPPCLibraries}"libgcc.xcoff
+rez -d APPNAME='"'hello'"' GenericCFRG.r -o hello
+setfile -t 'MPST' -c 'MPS ' hello
+
+The same sequence works to build a MacOS application, but you set the file
+type to 'APPL' and don't link in PPCToolLibs.o. For further details on
+using MPW to build Mac applications, see the general MPW documentation.
+
+Recent versions of PPCLink have an option to generate the code
+fragment resource and automatically set creator and file type;
+here is what GenericCFRG.r should look like if you have an older
+PPCLink or are using GNU ld:
+
+#include "CodeFragmentTypes.r"
+
+resource 'cfrg' (0) {
+ {
+ kPowerPC,
+ kFullLib,
+ kNoVersionNum,kNoVersionNum,
+ 0,0,
+ kIsApp,kOnDiskFlat,kZeroOffset,kWholeFork,
+ APPNAME // must be defined on Rez command line with -d option
+ }
+};
+
+In general this port of GCC supports the same option syntax and
+behavior as its Unix counterpart. It also has similar compilation
+rules, so it will run the assembler on .s files and so forth.
+
+The GCC manual includes full information on the available options.
+One option that may be especially useful is "-v", which shows you what
+tools and options are being used; unlike most Mac C compilers, GCC
+directs assembly and linking in addition to compilation.
+
+MPW GCC does feature two extensions to the option syntax; '-d macro=name'
+works just as '-Dmacro=name' does in Unix, and '-i directory' works the
+same as '-Idirectory'.
+
+MPW GCC supports the usual Pascal-style strings and alignment pragmas.
+
+To find standard include files you can set the variable GCCIncludes:
+
+ set GCCIncludes MyDisk:MyIncludes:
+ export GCCIncludes
+
+GCCIncludes is similar to MPW's CIncludes or CW's MWCIncludes. In
+order to use MPW's usual include files, just say:
+
+ set GCCIncludes "{CIncludes}"
+ export GCCIncludes
+
+* Using GCC as a Cross-Compiler
+
+If you have a cross-compiler, and you have all of the correct
+target-side crt0 and libraries available, then to compile and link a
+file "foo.c", you can say just
+
+ gC foo.c
+
+The output file will be an MPW binary file named "a.out"; the format
+of the contents will depend on which target is in use, so for instance
+a MIPS-targeting GCC will produce ECOFF or ELF executables.
+
+Note that using MPW include files with a cross-compiler is somewhat
+dangerous.
+
+* Using the Assembler and Friends
+
+The assembler ("as") and linker ("ld") are faithful ports of their
+Unix counterparts. Similarly, the binutils "ar", "cplusfilt", "nm",
+"objcopy", "objdump", "ranlib", "size", "strings", and "strip" are all
+like they are under Unix. (Note that "cplusfilt" is usually called
+"c++filt" under Unix.)
+
+* Using GDB
+
+There are two flavors of GDB. "gdb" is an MPW tool that works very
+much like it does in Unix; put a command into the MPW worksheet and
+type the <enter> key to send it to GDB. While "gdb" is running, you
+cannot do anything else in MPW, although you can switch to other
+Mac applications and use them.
+
+"SiowGDB" is also a Mac application, but it is GDB using the SIOW
+package to provide console emulation. Commands are exactly as for the
+MPW tool, but since this is its own application, you can switch
+between it and MPW.
+
+BUILDING GNU TOOLS
+
+This port of the GNU tools uses a configure script similar to
+that used for GNU tools under Unix, but rewritten for MPW. As with
+Unix configuration, there is an "object" directory that may be
+different from the "source" directory. In the example commands below,
+we will assume that we are currently in the object directory, and that
+the source directory is "{Boot}Cygnus:src:".
+
+* Requirements for Building
+
+In addition to the sources, you will need a set of tools that the
+configure and build scripts assume to be available. These tools
+(and their versions, if relevant) are as follows:
+
+ byacc tool
+ flex (2.3.7) tool (and Flex.skel file)
+ forward-include script
+ MoveIfChange script
+ mpw-touch script
+ mpw-true script
+ NewFolderRecursive script
+ null-command script
+ open-brace script
+ sed (1.13) tool
+ tr-7to8 script
+ true script
+
+The scripts are in the sources, under utils:mpw:. You must arrange to
+get the other tools yourself (they are readily available from the
+"usual" net sites, and are also on many CDROMS). In addition, there
+will usually be a set of these available at ftp.cygnus.com, in pub/mac.
+
+You may put the build tools in your usual Tools or Scripts
+directories, or keep them in a separate directories. We prefer to
+make a directory called "buildtools" and we put this in one of our
+UserStartup files:
+
+ set Commands "{Boot}Cygnus:buildtools:,{Commands}"
+
+Flex uses an environment variable FLEX_SKELETON to locate its skeleton
+file, so you need to do something like this, preferably in a UserStartup:
+
+ Set FLEX_SKELETON "{Boot}"Cygnus:buildtools:Flex.skel
+ Export FLEX_SKELETON
+
+* Configuring
+
+Before you can build anything, you must configure. You do this by
+creating an directory where object files will be stored, setdirectory
+to that directory and do a configure command:
+
+ {Boot}Cygnus:src:mpw-configure --target <name> --cc <compiler> --srcdir {Boot}Cygnus:src: --prefix <whatever>
+
+If the source directory is not in your {Commands} list, then you must
+supply a full pathname to mpw-configure, since mpw-configure invokes
+itself after switching into each subdirectory. Using a relative
+pathname, even something like ':mpw-configure', will therefore not work.
+
+<name> must be a known target. Valid ones include "m68k-apple-macos",
+"powerpc-apple-macos", "i386-unknown-go32", "mips-idt-ecoff", and
+"sh-hitachi-hms". Not all target types are accepted for all of the
+tools yet.
+
+<compiler> must be the name of the compiler to use. It defaults to "mpwc".
+
+ (m68k)
+ mpwc MPW C
+ sc68k Symantec C
+ mwc68k Metrowerks C (Codewarrior)
+ gcc68k GCC
+
+ (powerpc)
+ ppcc PPCC
+ mrc Macintosh on RisC (Mister C, aka(?) Frankenstein)
+ scppc Symantec C
+ mwcppc Metrowerks C (Codewarrior)
+ gccppc GCC
+
+Not all compilers will compile all tools equally well! For m68k Macs,
+MPW C has the best record so far (it has problems, but they can be
+worked around), while for PowerMacs, CodeWarrior is the only compiler
+that has successfully compiled everything into running code.
+
+<prefix> is the path that "gcc" will prepend when looking for tools
+to execute. GCC_EXEC_PREFIX overrides this value, so you need not
+include it if you plan to use GCC_EXEC_PREFIX.
+
+As an example, here is the configure line that you could use to build
+native PowerMac GCC:
+
+"{Boot}"Cygnus:src:mpw-configure --cc mwcppc --target powerpc-apple-macos --srcdir "{Boot}"Cygnus:src: --prefix "{Boot}"GNUTools:
+
+* Building
+
+If you use CodeWarrior, you *must* first set MWCIncludes to
+{CIncludes}. This is because you will be building MPW tools, and
+their standard I/O works by making references to data that is part of
+the MPW Shell, which means that the code must be compiled and linked
+with macros that refer to that data, and those macros are in
+{CIncludes}, not the default {MWCIncludes}. Without this change, you
+will encounter problems compiling libiberty/mpw.c, but tweaking that
+file only masks the real problem, and does not fix it.
+
+The command
+
+ mpw-build
+
+will build everything. Building will take over an hour on a Quadra 800
+or PowerMac 8100/110, longer if the sources are on a shared volume.
+
+You may see some warnings; these are mostly likely benign, typically
+disagreements about declarations of library and system functions.
+
+* Installing
+
+To install the just-built tools, use the command
+
+ mpw-build install
+
+This part of the installation procedure just copies files to the
+location specified at configure time by <prefix>, and, in some cases,
+renames them from temporary internal names to their usual names. This
+install process is *not* the same as what the Install script does;
+Install can copy tools from the installation location chosen at
+configuration time to a user-chosen place, and sets up a UserStartup
+file. Note that while the Install script is optional, the install
+build action performs some tasks would be very hard to replicate
+manually, so you should always do it before using the tools.
+
+* Known Problems With Using Various Compilers to Build
+
+Most versions of MPW C have problems with compiling GNU software.
+
+MPW C 3.2.x has preprocessing bugs that render it incapable of
+compiling the BFD library, so it can't be used at all for building BFD.
+
+MPW C 3.3, 3.3.1, and 3.3.2 will spontaneously claim to have found
+errors in the source code, but in fact the code is perfectly fine. If
+this happens, just set the working directory back to the top-level
+objdir (where the configure command above was performed), and type
+"mpw-build all" again. If it goes on through the supposed error, then
+you got one of the spurious errors. A full build may require a number
+of these restarts.
+
+MPW C 3.3.3 seems to work OK, at least with the aid of a number of
+workarounds that are in the sources (look for #ifdef MPW_C).
+
+Versions of MPW Make earlier than 4.0d2 have exhibited bizarre behavior,
+failure to substitute variables and the like.
+
+Metrowerks CW6 PPC linker (MWLinkPPC) seems to do bad things with memory
+if the "Modern Memory Manager" is turned on (in the Memory control panel),
+but works OK if it is turned off.
+
+Metrowerks CW6 loses bigtime compiling opcodes:ppc-opc.c, which has
+some deeply nested macros. (CW7 is OK.) There is a way to patch the
+file, by substituting constant values. If you need to do this,
+contact shebs@cygnus.com for details.
+
+<Gestalt.h> is missing from {CIncludes} in the MPW version that comes
+with CW7. You can just copy the one in CW7's {MWCIncludes}.
+
+CW8 and later have changes to headers and such that will require changes
+to the source in order to be able to use them to rebuild.
+
+KNOWN BUGS
+
+The declarations for memcpy and memcmp in some versions of header files
+may conflict with GCC's builtin definition. Either use -fno-builtin
+or ignore the warnings.
+
+This is not a bug, but - watch out for cr/nl translation! For instance,
+if config/mpw-mh-mpw is not properly translated because it has been
+copied or updated separately, then everything will almost build, but
+you will get puzzling error messages from make or the compiler.
+
+'/' or ' ' embedded in any device, directory, or file name may or may
+not work.
+
+objcopy -O srec foo.o makes random output filenames.
+
+Mac-x-mips requires -mgas but Unix hosts don't.
+
+GDB will frequently require a '/' on the front of a device name in order
+to recognize it as an absolute rather than a relative pathname.
+
+GDB doesn't seem to use the printer port correctly, although it tries.
+
+The cursor doesn't always spin as much as it should. To get elaborate
+statistics and warnings about spin rates, add this to UserStartup:
+
+ set MEASURE_SPIN all
+ export MEASURE_SPIN
diff --git a/mpw-build.in b/mpw-build.in
new file mode 100644
index 00000000000..86d9530fa3b
--- /dev/null
+++ b/mpw-build.in
@@ -0,0 +1,204 @@
+# Top-level script fragment to build everything for MPW.
+
+Set savedir "`Directory`"
+
+#Set Echo 1
+
+Set ThisScript "{0}"
+
+Set objdir ":"
+
+Set verify 0
+
+Set BuildTarget "none"
+
+# Parse arguments.
+
+Loop
+ Break If {#} == 0
+ If "{BuildTarget}" =~ /none/
+ Set BuildTarget "{1}"
+ Else
+ Echo Only one build target allowed, ignoring "{1}"
+ End If
+ Shift 1
+End Loop
+
+If "{BuildTarget}" =~ /none/
+ Set BuildTarget "all"
+End If
+
+If {verify} == 1
+ Echo "#" Doing "{ThisScript}" "{BuildTarget}" in "`Directory`" ...
+End If
+
+Set ranmake 0
+
+If "`Exists Makefile`" != ""
+ Echo "Set Echo 1" >{BuildTarget}.makeout
+ Make -f Makefile {BuildTarget} >>{BuildTarget}.makeout
+ {BuildTarget}.makeout
+ Delete {BuildTarget}.makeout
+ Set ranmake 1
+End If
+
+If "`Exists Makefile.PPC`" != ""
+ Echo "Set Echo 1" >{BuildTarget}.makeout.ppc
+ Make -f Makefile.PPC {BuildTarget} >>{BuildTarget}.makeout.ppc
+ {BuildTarget}.makeout.ppc
+ Delete {BuildTarget}.makeout.ppc
+ Set ranmake 1
+End If
+
+If {ranmake} == 1
+ Exit
+End If
+
+# Dispatch on various pseudo-targets.
+
+If "{BuildTarget}" =~ /all/
+ Echo Started `Date`
+ "{ThisScript}" all-gcc
+ "{ThisScript}" all-gdb
+ Echo Finished `Date`
+Else If "{BuildTarget}" =~ /all-libiberty/
+ "{ThisScript}" do-libiberty
+Else If "{BuildTarget}" =~ /all-bfd/
+ "{ThisScript}" do-bfd
+Else If "{BuildTarget}" =~ /all-opcodes/
+ "{ThisScript}" do-opcodes
+Else If "{BuildTarget}" =~ /all-byacc/
+ "{ThisScript}" do-byacc
+Else If "{BuildTarget}" =~ /all-flex/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" do-flex
+Else If "{BuildTarget}" =~ /all-binutils/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" all-bfd
+ "{ThisScript}" all-opcodes
+ "{ThisScript}" do-binutils
+Else If "{BuildTarget}" =~ /all-gas/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" all-bfd
+ "{ThisScript}" all-opcodes
+ "{ThisScript}" do-gas
+Else If "{BuildTarget}" =~ /all-gcc/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" all-gas
+ "{ThisScript}" all-binutils
+ "{ThisScript}" all-ld
+ "{ThisScript}" do-gcc
+Else If "{BuildTarget}" =~ /all-gdb/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" all-bfd
+ "{ThisScript}" all-opcodes
+ "{ThisScript}" do-gdb
+Else If "{BuildTarget}" =~ /all-grez/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" all-bfd
+ "{ThisScript}" do-grez
+Else If "{BuildTarget}" =~ /all-ld/
+ "{ThisScript}" all-libiberty
+ "{ThisScript}" all-bfd
+ "{ThisScript}" all-opcodes
+ "{ThisScript}" do-ld
+Else If "{BuildTarget}" =~ /do-byacc/
+ SetDirectory :byacc:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-flex/
+ SetDirectory :flex:
+ ::mpw-build _bootstrap
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-bfd/
+ SetDirectory :bfd:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-libiberty/
+ SetDirectory :libiberty:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-opcodes/
+ SetDirectory :opcodes:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-binutils/
+ SetDirectory :binutils:
+ ::mpw-build stamps
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-gas/
+ SetDirectory :gas:
+ ::mpw-build stamps
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-gcc/
+ SetDirectory :gcc:
+ :mpw-build all
+Else If "{BuildTarget}" =~ /do-gdb/
+ SetDirectory :gdb:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-grez/
+ SetDirectory :grez:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-ld/
+ SetDirectory :ld:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /do-newlib/
+ SetDirectory :newlib:
+ ::mpw-build all
+Else If "{BuildTarget}" =~ /install/
+ "{ThisScript}" install-only-top
+ "{ThisScript}" install-binutils
+ "{ThisScript}" install-gas
+ "{ThisScript}" install-gcc
+ "{ThisScript}" install-ld
+ "{ThisScript}" install-gdb
+Else If "{BuildTarget}" =~ /install-binutils/
+ SetDirectory :binutils:
+ ::mpw-build install
+Else If "{BuildTarget}" =~ /install-gas/
+ SetDirectory :gas:
+ ::mpw-build install
+Else If "{BuildTarget}" =~ /install-gcc/
+ SetDirectory :gcc:
+ :mpw-build install
+Else If "{BuildTarget}" =~ /install-gdb/
+ SetDirectory :gdb:
+ ::mpw-build install
+Else If "{BuildTarget}" =~ /install-grez/
+ SetDirectory :grez:
+ ::mpw-build install
+Else If "{BuildTarget}" =~ /install-ld/
+ SetDirectory :ld:
+ ::mpw-build install
+Else If "{BuildTarget}" =~ /install-only/
+ "{ThisScript}" install-only-top
+ "{ThisScript}" install-only-binutils
+ "{ThisScript}" install-only-gas
+ "{ThisScript}" install-only-gcc
+ "{ThisScript}" install-only-gdb
+ "{ThisScript}" install-only-ld
+Else If "{BuildTarget}" =~ /install-only-binutils/
+ SetDirectory :binutils:
+ ::mpw-build install-only
+Else If "{BuildTarget}" =~ /install-only-gas/
+ SetDirectory :gas:
+ ::mpw-build install-only
+Else If "{BuildTarget}" =~ /install-only-gcc/
+ SetDirectory :gcc:
+ :mpw-build install-only
+Else If "{BuildTarget}" =~ /install-only-gdb/
+ SetDirectory :gdb:
+ ::mpw-build install-only
+Else If "{BuildTarget}" =~ /install-only-grez/
+ SetDirectory :grez:
+ ::mpw-build install-only
+Else If "{BuildTarget}" =~ /install-only-ld/
+ SetDirectory :ld:
+ ::mpw-build install-only
+Else If "{BuildTarget}" =~ /install-only-top/
+ NewFolderRecursive "{prefix}"
+ If "{prefix}" != "`Directory`"
+ Duplicate -y 'Read Me for MPW' "{prefix}"'Read Me for MPW'
+ Duplicate -y Install "{prefix}"Install
+ End If
+Else
+ Echo {BuildTarget} not understood, ignoring
+End If
+
+SetDirectory "{savedir}"
diff --git a/mpw-config.in b/mpw-config.in
new file mode 100644
index 00000000000..8028737a8b6
--- /dev/null
+++ b/mpw-config.in
@@ -0,0 +1,113 @@
+# Configuration fragment for Cygnus source tree.
+
+# Check that we can find all the special tools that we will need.
+# The test for sed is semi-pointless, because it's already been invoked
+# by the calculation of target_cpu in the main configure script, but
+# the test will also show which one is being used.
+
+Set Exit 0
+Echo byacc is `Which byacc`
+Echo flex is `Which flex`
+Echo forward-include is `Which forward-include`
+Echo MoveIfChange is `Which MoveIfChange`
+Echo mpw-touch is `Which mpw-touch`
+Echo mpw-true is `Which mpw-true`
+Echo NewFolderRecursive is `Which NewFolderRecursive`
+Echo null-command is `Which null-command`
+Echo open-brace is `Which open-brace`
+Echo sed is `Which sed`
+Echo 'tr-7to8' is `Which tr-7to8`
+Echo true is `Which true`
+Set Exit 1
+
+Set host_libs "mmalloc libiberty opcodes bfd readline gash tcl tk tclX"
+
+Set host_tools "texinfo byacc flex bison binutils ld gas gcc gdb make patch \Option-d
+ prms send-pr gprof gdbtest tgas etc expect dejagnu sim bash \Option-d
+ m4 autoconf ispell grep diff rcs cvs fileutils shellutils time \Option-d
+ textutils wdiff find emacs emacs19 uudecode hello tar gzip indent \Option-d
+ recode release sed utils guile perl apache inet gawk"
+
+Set target_libs "newlib"
+
+Set target_tools "examples"
+
+# Configure the resource compiler if targeting Macs.
+If {target_os} =~ /macos/ || {target_os} =~ /mpw/
+ Set host_tools "{host_tools} grez"
+End If
+
+Set configdirs "{host_libs} {host_tools} {target_libs} {target_tools}"
+Export configdirs
+
+# Make up a special include directory that tools will share.
+
+If "`Exists "{objdir}"extra-include`" == ""
+ NewFolder "{objdir}"extra-include
+End If
+
+Set edir "{objdir}extra-include:"
+
+forward-include "{srcdir}"include:mpw:sys:file.h "{edir}"'sys/file.h'
+forward-include "{srcdir}"include:mpw:sys:ioctl.h "{edir}"'sys/ioctl.h'
+forward-include "{srcdir}"include:mpw:sys:param.h "{edir}"'sys/param.h'
+forward-include "{srcdir}"include:mpw:sys:resource.h "{edir}"'sys/resource.h'
+forward-include "{srcdir}"include:mpw:sys:stat.h "{edir}"'sys/stat.h'
+forward-include "{srcdir}"include:mpw:sys:time.h "{edir}"'sys/time.h'
+forward-include "{srcdir}"include:mpw:sys:types.h "{edir}"'sys/types.h'
+
+forward-include "{srcroot}"include:aout:aout64.h "{edir}"'aout/aout64.h'
+forward-include "{srcroot}"include:aout:ar.h "{edir}"'aout/ar.h'
+forward-include "{srcroot}"include:aout:ranlib.h "{edir}"'aout/ranlib.h'
+forward-include "{srcroot}"include:aout:reloc.h "{edir}"'aout/reloc.h'
+forward-include "{srcroot}"include:aout:stab.def "{edir}"'aout/stab.def'
+forward-include "{srcroot}"include:aout:stab_gnu.h "{edir}"'aout/stab_gnu.h'
+
+If "`Exists "{srcroot}"include:aout:"{target_cpu}".h`" != ""
+ forward-include "{srcroot}"include:aout:"{target_cpu}".h "{edir}"'aout/'"{target_cpu}"'.h'
+End If
+
+forward-include "{srcroot}"include:coff:ecoff.h "{edir}"'coff/ecoff.h'
+forward-include "{srcroot}"include:coff:internal.h "{edir}"'coff/internal.h'
+forward-include "{srcroot}"include:coff:sym.h "{edir}"'coff/sym.h'
+forward-include "{srcroot}"include:coff:symconst.h "{edir}"'coff/symconst.h'
+
+If "`Exists "{srcroot}"include:coff:"{target_cpu}".h`" != ""
+ forward-include "{srcroot}"include:coff:"{target_cpu}".h "{edir}"'coff/'"{target_cpu}"'.h'
+End If
+If "{target_cpu}" =~ /powerpc/
+ forward-include "{srcroot}"include:coff:rs6000.h "{edir}"'coff/rs6000.h'
+End If
+
+forward-include "{srcroot}"include:elf:common.h "{edir}"'elf/common.h'
+forward-include "{srcroot}"include:elf:dwarf.h "{edir}"'elf/dwarf.h'
+forward-include "{srcroot}"include:elf:dwarf2.h "{edir}"'elf/dwarf2.h'
+forward-include "{srcroot}"include:elf:external.h "{edir}"'elf/external.h'
+forward-include "{srcroot}"include:elf:internal.h "{edir}"'elf/internal.h'
+
+# Believe it or not, GDB needs this for all targets.
+forward-include "{srcroot}"include:elf:mips.h "{edir}"'elf/mips.h'
+
+If "`Exists "{srcroot}"include:elf:"{target_cpu}".h`" != ""
+ forward-include "{srcroot}"include:elf:"{target_cpu}".h "{edir}"'elf/'"{target_cpu}"'.h'
+End If
+If "{target_cpu}" =~ /powerpc/
+ forward-include "{srcroot}"include:elf:ppc.h "{edir}"'elf/ppc.h'
+End If
+
+If "`Exists "{srcroot}"include:opcode:"{target_cpu}".h`" != ""
+ forward-include "{srcroot}"include:opcode:"{target_cpu}".h "{edir}"'opcode/'"{target_cpu}"'.h'
+End If
+If "{target_cpu}" =~ /powerpc/
+ forward-include "{srcroot}"include:opcode:ppc.h "{edir}"'opcode/ppc.h'
+End If
+
+# Add some bfd includes that get mentioned outside the bfd dir.
+
+forward-include "{srcroot}"bfd:libcoff.h "{edir}"'bfd/libcoff.h'
+forward-include "{srcroot}"bfd:libecoff.h "{edir}"'bfd/libecoff.h'
+
+# Translate random files into MPW-only character set.
+
+tr-7to8 "{srcdir}"mpw-README > "{objdir}Read Me for MPW"
+tr-7to8 "{srcdir}"mpw-install > "{objdir}"Install
diff --git a/mpw-configure b/mpw-configure
new file mode 100644
index 00000000000..cf45148ec63
--- /dev/null
+++ b/mpw-configure
@@ -0,0 +1,448 @@
+# Configuration script
+# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+### WARNING
+### This script must NOT use any 8-bit chars!
+### WARNING
+
+# This is an MPW Shell script that sets everything up for compilation,
+# mainly creating directories, and editing copies of files.
+
+Set savedir "`Directory`"
+
+#Set Echo 1
+
+Set ThisScript "{0}"
+
+Set srcroot "--------"
+
+Set srcdir ":"
+
+Set objdir ":"
+
+Set prefix "{MPW}":GNUTools:
+
+Set exec_prefix ""
+
+Set bindir ""
+
+Set host_alias "m68k-apple-mpw"
+
+Set target_alias {host_alias}
+
+Set host_cc "mpwc"
+
+Set with_gnu_ld 0
+
+Set helpoutput 0
+
+Set recurse 1
+
+Set verify 0
+Set verifystr ""
+
+Set enable_options ""
+Set disable_options ""
+
+# Parse arguments.
+
+Loop
+ Break If {#} == 0
+ If "{1}" =~ /--cc/
+ Set host_cc "{2}"
+ Shift 1
+ Else If "{1}" =~ /--bindir/
+ Set bindir "{2}"
+ Shift 1
+ Else If "{1}" =~ /--disable-?+/
+ Set `Echo {1} | sed -e 's/--disable-/enable_/'` no
+ Set disable_options "{disable_options} '{1}'"
+ Else If "{1}" =~ /--enable-?+/
+ Set `Echo {1} | sed -e 's/--enable-/enable_/'` yes
+ Set enable_options "{enable_options} '{1}'"
+ Else If "{1}" =~ /--exec-prefix/
+ Set exec_prefix "{2}"
+ Shift 1
+ Else If "{1}" =~ /--help/
+ Set helpoutput 1
+ Else If "{1}" =~ /--host/
+ Set host_alias "{2}"
+ Shift 1
+ Else If "{1}" =~ /--norecursion/
+ Set recurse 0
+ Else If "{1}" =~ /--prefix/
+ Set prefix "{2}"
+ Shift 1
+ Else If "{1}" =~ /--srcdir/
+ Set srcdir "{2}"
+ Shift 1
+ Else If "{1}" =~ /--srcroot/
+ Set srcroot "{2}"
+ Shift 1
+ Else If "{1}" =~ /--target/
+ Set target_alias "{2}"
+ Shift 1
+ Else If "{1}" =~ /-v/
+ Set verify 1
+ Set verifystr "-v"
+ Else If "{1}" =~ /--with-gnu-ld/
+ Set with_gnu_ld 1
+ Else
+ Echo -n 'mpw-configure: Unrecognized option: "'
+ Echo -n "{1}"
+ Echo '"; use --help for usage.'
+ Exit 1
+ End If
+ Shift 1
+End Loop
+
+If {helpoutput} == 1
+ Echo "Usage: mpw-configure [OPTIONS]"
+ Echo ""
+ Echo "Options: [defaults in brackets]"
+ Echo "--bindir DIR directory for binaries []"
+ Echo "--cc CC use C compiler CC [mpwc]"
+ Echo "--disable-FOO do not include feature FOO"
+ Echo "--enable-FOO include feature FOO"
+ Echo "--exec-prefix DIR install host-dependent files into DIR []"
+ Echo "--help print this message"
+ Echo "--host HOST configure for HOST [m68k-apple-mpw]"
+ Echo "--norecursion configure this directory only [recurse]"
+ Echo "--prefix DIR install into DIR [{MPW}:GNUTools:]"
+ Echo "--srcdir DIR find the sources in DIR [:]"
+ Echo "--srcroot DIR find the toplevel sources in DIR [:]"
+ Echo "--target TARGET configure for TARGET [TARGET=HOST]"
+ Echo "-v verbose"
+ Echo "--with-gnu-ld link using GNU ld [no]"
+ Exit 0
+End If
+
+Set Exit 0
+
+# Default exec_prefix from prefix.
+
+If "{exec_prefix}" == ""
+ Set exec_prefix "{prefix}"
+End If
+
+If "{bindir}" == ""
+ Set bindir "{prefix}"bin:
+End If
+
+# Point to the correct set of tools to use with the chosen compiler.
+
+If "{host_cc}" =~ /mpwc/
+ Set host_alias "m68k-apple-mpw"
+ Set cc_name '{CC_MPW_C}'
+ Set segment_flag '-s '
+ Set ar_name '{AR_LIB}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_LINK}'
+ Set prog_ext_name '{PROG_EXT_68K}'
+ Set extralibs_name '{EXTRALIBS_C}'
+ Set makepef_name '{MAKEPEF_NULL}'
+ Set rez_name '{REZ_68K}'
+Else If "{host_cc}" =~ /sc68k/
+ Set host_alias "m68k-apple-mpw"
+ Set cc_name '{CC_SC}'
+ Set segment_flag '-s '
+ Set ar_name '{AR_LIB}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_LINK}'
+ Set prog_ext_name '{PROG_EXT_68K}'
+ Set extralibs_name '{EXTRALIBS_C}'
+ Set makepef_name '{MAKEPEF_NULL}'
+ Set rez_name '{REZ_68K}'
+Else If "{host_cc}" =~ /mwc68k/
+ Set host_alias "m68k-apple-mpw"
+ Set cc_name '{CC_MWC68K}'
+ Set segment_flag '-s '
+ Set ar_name '{AR_MWLINK68K}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_MWLINK68K}'
+ Set prog_ext_name '{PROG_EXT_68K}'
+ Set extralibs_name '{EXTRALIBS_MWC68K}'
+ Set makepef_name '{MAKEPEF_NULL}'
+ Set rez_name '{REZ_68K}'
+Else If "{host_cc}" =~ /gcc68k/
+ Set host_alias "m68k-apple-mpw"
+ Set cc_name '{CC_68K_GCC}'
+ Set segment_flag '-s '
+ Set ar_name '{AR_68K_AR}'
+ Set ranlib_name '{RANLIB_RANLIB}'
+ Set cc_ld_name '{CC_68K_GCC}'
+ Set prog_ext_name '{PROG_EXT_68K}'
+ Set extralibs_name '{EXTRALIBS_C}'
+ Set makepef_name '{MAKEPEF_NULL}'
+ Set rez_name '{REZ_68K}'
+Else If "{host_cc}" =~ /ppcc/
+ Set host_alias "powerpc-apple-mpw"
+ Set cc_name '{CC_PPCC}'
+ Set segment_flag '-d ___s_e_g___='
+ Set ar_name '{AR_PPCLINK}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_PPCLINK}'
+ Set prog_ext_name '{PROG_EXT_XCOFF}'
+ Set extralibs_name '{EXTRALIBS_PPC}'
+ Set makepef_name '{MAKEPEF_PPC}'
+ Set rez_name '{REZ_PPC}'
+Else If "{host_cc}" =~ /mrc/
+ Set host_alias "powerpc-apple-mpw"
+ Set cc_name '{CC_MRC}'
+ Set segment_flag '-d ___s_e_g___='
+ Set ar_name '{AR_PPCLINK}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_PPCLINK}'
+ Set prog_ext_name '{PROG_EXT_XCOFF}'
+ Set extralibs_name '{EXTRALIBS_PPC}'
+ Set makepef_name '{MAKEPEF_PPC}'
+ Set rez_name '{REZ_PPC}'
+Else If "{host_cc}" =~ /scppc/
+ Set host_alias "powerpc-apple-mpw"
+ Set cc_name '{CC_SC}'
+ Set segment_flag '-d ___s_e_g___='
+ Set ar_name '{AR_PPCLINK}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_PPCLINK}'
+ Set prog_ext_name '{PROG_EXT_XCOFF}'
+ Set extralibs_name '{EXTRALIBS_PPC}'
+ Set makepef_name '{MAKEPEF_PPC}'
+ Set rez_name '{REZ_PPC}'
+Else If "{host_cc}" =~ /mwcppc/
+ Set host_alias "powerpc-apple-mpw"
+ Set cc_name '{CC_MWCPPC}'
+ Set segment_flag '-d ___s_e_g___='
+ Set ar_name '{AR_MWLINKPPC}'
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_MWLINKPPC}'
+ # Misleading, but we don't need a PEF step.
+ Set prog_ext_name '{PROG_EXT_68K}'
+ Set extralibs_name '{EXTRALIBS_MWCPPC}'
+ Set makepef_name '{MAKEPEF_NULL}'
+ Set rez_name '{REZ_PPC}'
+Else If "{host_cc}" =~ /gccppc/
+ Set host_alias "powerpc-apple-mpw"
+ Set cc_name '{CC_PPC_GCC}'
+ Set segment_flag '-d ___s_e_g___='
+ Set ar_name '{AR_PPCLINK}'
+ If {with_gnu_ld} == 1
+ Set ranlib_name '{RANLIB_RANLIB}'
+ Set cc_ld_name '{CC_LD_GLD}'
+ Else
+ Set ranlib_name '{RANLIB_NULL}'
+ Set cc_ld_name '{CC_LD_PPCLINK}'
+ End If
+ Set prog_ext_name '{PROG_EXT_XCOFF}'
+ Set extralibs_name '{EXTRALIBS_PPC}'
+ Set makepef_name '{MAKEPEF_PPC}'
+ Set rez_name '{REZ_PPC}'
+Else
+ Echo "{host_cc}" is not a known MPW compiler type
+End If
+
+Set dash_c_flag ''
+If "{host_cc}" =~ /gcc68k/
+ Set dash_c_flag '-c'
+Else If "{host_cc}" =~ /gccppc/
+ Set dash_c_flag '-c'
+End If
+
+# (should interpret aliases if not in canonical form)
+
+Set host_canonical "{host_alias}"
+
+Set target_canonical "{target_alias}"
+
+Set configdirs ""
+
+If "{srcroot}" =~ /--------/
+ Set srcroot "{srcdir}"
+End If
+If "`Exists "{srcdir}"`" == ""
+ Echo Source directory {srcdir} does not exist!
+ Exit 1
+End If
+If "`Exists "{srcroot}"`" == ""
+ Echo Top-level source directory {srcroot} does not exist!
+ Exit 1
+End If
+
+Set target_cpu "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`"
+Set target_vendor "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`"
+Set target_os "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`"
+
+# Create a file that is guaranteed to be older than any other here.
+
+If "`Exists "{objdir}"_oldest`" == ""
+ mpw-touch _oldest
+End If
+
+# Record this before creating any files, makefiles sometimes mention
+# dependencies on config.status.
+
+Echo "# This directory was configured as follows:" >config.new
+Echo "{ThisScript} --host {host_alias} --target {target_alias} --srcdir {srcdir} --srcroot {srcroot} --prefix {prefix} --cc {host_cc} {verifystr} {enable_options} {disable_options} --norecursion" >>config.new
+MoveIfChange config.new config.status
+
+If "`Exists "{srcdir}"mpw-config.in`" != ""
+ tr-7to8 "{srcdir}"mpw-config.in >"{objdir}"mpw-config.in
+ Execute "{objdir}"mpw-config.in
+End If
+
+# Start Makefile construction by defining all the variables chosen by
+# configuration.
+
+Echo "# This Makefile produced by mpw-configure. Changes may get lost!" > "{objdir}"Makefile.tem
+Echo "srcroot = " {srcroot} >> "{objdir}"Makefile.tem
+Echo "topsrcdir = " {srcroot} >> "{objdir}"Makefile.tem
+Echo "srcdir = " {srcdir} >> "{objdir}"Makefile.tem
+Echo "mpw_prefix = " {prefix} >> "{objdir}"Makefile.tem
+Echo "mpw_exec_prefix = " {exec_prefix} >> "{objdir}"Makefile.tem
+Echo "mpw_bindir = " {bindir} >> "{objdir}"Makefile.tem
+Echo "host_alias = " {host_alias} >> "{objdir}"Makefile.tem
+Echo "target_alias = " {target_alias} >> "{objdir}"Makefile.tem
+Echo "target_cpu = " {target_cpu} >> "{objdir}"Makefile.tem
+Echo "target_vendor = " {target_vendor} >> "{objdir}"Makefile.tem
+Echo "target_os = " {target_os} >> "{objdir}"Makefile.tem
+Echo "target_canonical = " {target_canonical} >> "{objdir}"Makefile.tem
+Echo "host_makefile_frag = " >> "{objdir}"Makefile.tem
+Echo "target_makefile_frag = " >> "{objdir}"Makefile.tem
+Echo "CC = " {cc_name} >> "{objdir}"Makefile.tem
+Echo "AR = " {ar_name} >> "{objdir}"Makefile.tem
+Echo "RANLIB = " {ranlib_name} >> "{objdir}"Makefile.tem
+Echo "CC_LD = " {cc_ld_name} >> "{objdir}"Makefile.tem
+Echo "PROG_EXT = " {prog_ext_name} >> "{objdir}"Makefile.tem
+Echo "EXTRALIBS = " {extralibs_name} >> "{objdir}"Makefile.tem
+Echo "MAKEPEF = " {makepef_name} >> "{objdir}"Makefile.tem
+Echo "REZ = " {rez_name} >> "{objdir}"Makefile.tem
+
+If {host_cc} =~ /gccppc/
+ Echo -n "dq =\Option-d\Option-d\Option-d" > "{objdir}"Makefile.tem0
+ Echo '"' >> "{objdir}"Makefile.tem0
+ tr-7to8 "{objdir}"Makefile.tem0 >>"{objdir}"Makefile.tem
+Else
+ Echo -n "dq ='" >> "{objdir}"Makefile.tem
+ Echo -n '"' >> "{objdir}"Makefile.tem
+ Echo "'" >> "{objdir}"Makefile.tem
+End If
+
+# Append the master set of definitions for the various compilers.
+
+If "`Exists "{srcdir}"config:mpw-mh-mpw`" != ""
+ tr-7to8 "{srcdir}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem
+Else If "`Exists "{srcroot}"config:mpw-mh-mpw`" != ""
+ tr-7to8 "{srcroot}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem
+Else
+ Echo "can't find a host config file!"
+ Exit 0
+End If
+
+# Append anything produced by the directory's mpw-config.in.
+
+If "`Exists "{objdir}"mk.tmp`" != ""
+ Catenate "{objdir}"mk.tmp >>"{objdir}"Makefile.tem
+ # An mpw-config.in might change so as not to create this
+ # anymore, so get rid of it now to be safe.
+ Delete -i -y "{objdir}"mk.tmp
+End If
+
+# If there are sed scripts to edit the Unix Makefile.in, use them; otherwise
+# use an mpw-make.in if present.
+
+If "`Exists "{srcdir}"mpw-make.sed`" != ""
+ If "`Exists "{objdir}"hacked_Makefile.in`" != ""
+ Set MakefileIn "{objdir}"hacked_Makefile.in
+ Else
+ Set MakefileIn "{srcdir}"Makefile.in
+ End If
+ # Find the generic makefile editing script.
+ If "`Exists "{srcroot}"config:mpw:g-mpw-make.sed`" != ""
+ sed -f "{srcroot}"config:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
+ Else If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != ""
+ sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
+ Else If "`Exists "{srcdir}"g-mpw-make.sed`" != ""
+ sed -f "{srcdir}"g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
+ Else
+ Echo Warning: g-mpw-make.sed not found, copying "{MakefileIn}" verbatim...
+ Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1
+ End If
+ sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2
+ sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' -e 's/^exec_prefix = .*$/exec_prefix = {mpw_exec_prefix}/g' -e 's/^bindir = @bindir@/bindir = {mpw_bindir}/g' "{objdir}"Makefile.tem2 >"{objdir}"Makefile.tem3
+ sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}\1/" "{objdir}"Makefile.tem3 >"{objdir}"mpw-make.in
+ tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem
+ If "`Exists "{objdir}"mk.sed`" != ""
+ sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2
+ Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem
+ End If
+ MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile
+ Delete -i -y "{objdir}"Makefile.tem[12]
+ If {verify} == 1
+ Echo Created Makefile in "`Directory`"
+ End If
+Else If "`Exists "{srcdir}"mpw-make.in`" != ""
+ sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' "{srcdir}"mpw-make.in >"{objdir}"Makefile.tem1
+ sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}}\1/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2
+ tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem
+ If "`Exists "{objdir}"mk.sed`" != ""
+ sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2
+ Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem
+ End If
+ MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile
+ Delete -i -y "{objdir}"Makefile.tem[12]
+ If {verify} == 1
+ Echo Created Makefile in "`Directory`"
+ End If
+End If
+
+# Produce a build script if the source is defined.
+
+If "`Exists "{srcdir}"mpw-build.in`" != ""
+ Echo "Set srcroot " {srcroot} > "{objdir}"mpw-build.tem
+ Echo "Set srcdir " {srcdir} >> "{objdir}"mpw-build.tem
+ Echo "Set target_canonical " {target_canonical} >> "{objdir}"mpw-build.tem
+ Echo "Set prefix " {prefix} >> "{objdir}"mpw-build.tem
+ tr-7to8 "{srcdir}"mpw-build.in >>"{objdir}"mpw-build.tem
+ MoveIfChange "{objdir}"mpw-build.tem "{objdir}"mpw-build
+ If {verify} == 1
+ Echo Created mpw-build in "`Directory`"
+ End If
+End If
+
+# Apply ourselves recursively to the list of subdirectories to configure.
+
+If {recurse} == 1
+ For subdir In {configdirs}
+ Set savedir "`Directory`"
+ If "`Exists "{srcdir}{subdir}:"`" == ""
+ If {verify} == 1
+ Echo No "{srcdir}{subdir}:" found, skipping
+ End If
+ Continue
+ End If
+ If {verify} == 1
+ Echo Configuring {subdir}...
+ End If
+ If "`Exists "{objdir}{subdir}:"`" == ""
+ NewFolder "{objdir}{subdir}"
+ End If
+ SetDirectory "{objdir}{subdir}:"
+ "{ThisScript}" --target "{target_canonical}" --srcdir "{srcdir}{subdir}:" --srcroot "{srcroot}" --prefix "{prefix}" --cc "{host_cc}" {verifystr} {enable_options} {disable_options}
+ SetDirectory "{savedir}"
+ End For
+End If
+
+SetDirectory "{savedir}"
diff --git a/mpw-install b/mpw-install
new file mode 100644
index 00000000000..04c5aac2a4f
--- /dev/null
+++ b/mpw-install
@@ -0,0 +1,122 @@
+# GNU Install script for MPW.
+
+Set OldExit "{Exit}"
+Set Exit 0
+
+Set TempUserStartup "{TempFolder}"__temp__UserStartup
+
+Echo '# UserStartup generated by GNU Install script' > "{TempUserStartup}"
+Echo '' >> "{TempUserStartup}"
+
+# (should) Check that disk space is sufficient for installation.
+
+# Assume that the install script is where everything else is.
+
+Set thisdir "`Directory`"
+
+# Copy the binaries to the desired place.
+
+Confirm -t "Copy the binaries to somewhere else?"
+Set TmpStatus {Status}
+If {TmpStatus} == 0
+ Set bindest "`GetFileName -d -m "Where to install the binaries?"`"
+ If {Status} == 0
+ If "`Exists "{thisdir}bin"`" != ""
+ For afile In "{thisdir}"bin:\Option-x
+ Duplicate -y "{afile}" "{bindest}"
+ End For
+ Else
+ Echo "bin directory not found, exiting"
+ Exit 1
+ End If
+ Else
+ Echo "No destination supplied, exiting"
+ Exit 1
+ End If
+Else If {TmpStatus} == 4
+ # Use the existing directory.
+ Set bindest "{thisdir}bin:"
+Else
+ # Cancelled from confirmation, escape altogether.
+ Exit 1
+End If
+
+# Copy the libraries to the desired place.
+
+Confirm -t "Copy the libraries to somewhere else?"
+Set TmpStatus {Status}
+If {TmpStatus} == 0
+ Set libdest "`GetFileName -d -m "Where to install the libraries?"`"
+ If {Status} == 0
+ If "`Exists "{thisdir}lib:"`" != ""
+ For afile In "{thisdir}"lib:\Option-x
+ Duplicate -y "{afile}" "{libdest}"
+ End For
+ Else
+ Echo "lib directory not found, exiting"
+ Exit 1
+ End If
+ Else
+ Echo "No destination supplied, exiting"
+ Exit 1
+ End If
+Else If {TmpStatus} == 4
+ # Use the existing directory.
+ Set libdest "{thisdir}lib:"
+Else
+ # Cancelled from confirmation, escape altogether.
+ Exit 1
+End If
+
+
+# Add the location of the binaries to the command path.
+
+Echo -n 'Set Commands "' >> "{TempUserStartup}"
+Echo -n "{bindest}" >> "{TempUserStartup}"
+Echo ',{Commands}"' >> "{TempUserStartup}"
+Echo '' >> "{TempUserStartup}"
+
+# Set up GCC exec prefix.
+
+Set gcclibdir "{libdest}"gcc-lib:
+
+Echo -n 'Set GCC_EXEC_PREFIX "' >> "{TempUserStartup}"
+Echo -n "{gcclibdir}" >> "{TempUserStartup}"
+Echo '"' >> "{TempUserStartup}"
+Echo "Export GCC_EXEC_PREFIX" >> "{TempUserStartup}"
+Echo '' >> "{TempUserStartup}"
+
+# Set up path to libgcc.xcoff etc.
+
+Echo -n 'Set GCCPPCLibraries "' >> "{TempUserStartup}"
+Echo -n "{libdest}" >> "{TempUserStartup}"
+Echo '"' >> "{TempUserStartup}"
+Echo "Export GCCPPCLibraries" >> "{TempUserStartup}"
+Echo '' >> "{TempUserStartup}"
+
+# Display contents of UserStartup, confirm installation.
+
+Set UserStartupName "UserStartup\Option-8GNU"
+
+Echo "Contents of" {UserStartupName} "will be:"
+Catenate "{TempUserStartup}"
+
+Confirm "Install {UserStartupName} into the MPW folder {MPW} ?"
+If {Status} == 0
+ Duplicate "{TempUserStartup}" "{MPW}{UserStartupName}"
+ Delete -y "{TempUserStartup}"
+Else
+ Echo "{UserStartupName} file not installed"
+End If
+
+# (should) Check HEXA resource, warn if low.
+
+# (should) Check for spaces in pathnames, warn if found.
+
+Echo "Installation was successful."
+Echo ""
+Echo "Be sure to review the usage notes in 'Read Me for MPW' before proceeding!"
+
+# Restore previous settings.
+
+Set Exit "{OldExit}"
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
new file mode 100644
index 00000000000..0e5ea1760cb
--- /dev/null
+++ b/opcodes/ChangeLog
@@ -0,0 +1,5033 @@
+1999-04-26 Tom Tromey <tromey@cygnus.com>
+
+ * aclocal.m4, configure: Updated for new version of libtool.
+
+1999-04-22 Nick Clifton <nickc@cygnus.com>
+
+ * mcore-dis.c (print_insn_mcore): Display locaiton of address pool
+ for LRW instructions.
+
+1999-04-18 Nick Clifton <nickc@cygnus.com>
+
+ * mcore-dis.c (print_insn_mcore): Display location of address pool
+ for JMP instructions.
+ * mcore-opc.h (mcore_table): Add 'nop'.
+
+1999-04-14 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-desc.c,fr30-desc.h,fr30-dis.c,fr30-ibld.c,fr30-opc.c: Rebuild.
+ * m32r-desc.c,m32r-desc.h,m32r-dis.c,m32r-ibld.c,m32r-opc.c: Rebuild.
+
+Mon Apr 12 23:46:17 1999 Jeffrey A Law (law@cygnus.com)
+
+ * hppa-dis.c (print_insn_hppa, case '3'): New case for PA2.0
+ instructions.
+
+1999-04-10 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-desc.c,fr30-desc.h,fr30-ibld.c: Rebuild.
+ * m32r-desc.c,m32r-desc.h,m32r-opinst.c: Rebuild.
+
+1999-04-08 Nick Clifton <nickc@cygnus.com>
+
+ * mcore-dis.c: New file: Disassemble MCore opcodes.
+ * mcore-opc.h: New file: Definitions of MCore opcodes.
+ * Makefile.am: Add Mcore source files.
+ * Makefile.in: Regenerate.
+ * configure.in: Add support for MCore targets.
+ * configure: Regenerate.
+ * disassemble.c: Add support for MCore targets.
+
+1999-04-06 Ian Lance Taylor <ian@zembu.com>
+
+ * opintl.h (LC_MESSAGES): Never define.
+
+1999-04-04 Ian Lance Taylor <ian@zembu.com>
+
+ * i386-dis.c (intel_syntax, open_char, close_char): Make static.
+ (separator_char, scale_char): Likewise.
+ (print_insn_x86): Likewise.
+ (print_insn_i386): Likewise. Add declaration.
+
+1999-03-26 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-dis.c: Rebuild.
+ * m32r-dis.c: Rebuild.
+
+1999-03-23 Ian Lance Taylor <ian@zembu.com>
+
+ * m68k-opc.c: Change compare instructions to use "@s" rather than
+ ";s" when used with an immediate operand.
+
+1999-03-22 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen-opc.c (cgen_set_cpu): Delete.
+ (cgen_lookup_insn): max_insn_size renamed to max_insn_bitsize.
+ * fr30-desc.c,fr30-desc.h,fr30-dis.c,fr30-ibld.c,fr30-opc.c,fr30-opc.h:
+ Rebuild.
+ * m32r-desc.c,m32r-desc.h,m32r-dis.c,m32r-ibld.c,m32r-opc.c,m32r-opc.h:
+ Rebuild.
+ * po/opcodes.pot: Rebuild.
+
+1999-03-16 Martin Hunt <hunt@cygnus.com>
+
+ * d30v-opc.c (mvtsys): Remove FLAG_LKR.
+
+1999-03-11 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen-opc.c (cgen_set_cpu): New arg `isa'. All callers updated.
+ (cgen_operand_lookup_by_name,cgen_operand_lookup_by_num): New fns.
+ (cgen_get_insn_operands): Rewrite test for hardcoded/operand index.
+ * fr30-asm.c,fr30-desc.c,fr30-desc.h,fr30-dis.c,fr30-ibld.c: Rebuild.
+ * m32r-asm.c,m32r-desc.c,m32r-desc.h,m32r-dis.c,m32r-ibld.c: Rebuild.
+ * m32r-opinst.c: Rebuild.
+
+1999-02-25 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen-opc.c (cgen_hw_lookup_by_name): Rewrite.
+ (cgen_hw_lookup_by_num): Rewrite.
+ * fr30-desc.c,fr30-desc.h,fr30-dis.c,fr30-ibld.c,fr30-opc.c: Rebuild.
+ * m32r-desc.c,m32r-desc.h,m32r-dis.c,m32r-ibld.c,m32r-opc.c: Rebuild.
+ * m32r-opinst.c: Rebuild.
+
+Sat Feb 13 14:06:19 1999 Richard Henderson <rth@cygnus.com>
+
+ * alpha-opc.c: Add sqrt+flags patterns. Add EV6 PALcode insns.
+ (insert_jhint): Fix insertion mask.
+ * alpha-dis.c (print_insn_alpha): Disassemble EV6 PALcode insns.
+
+1999-02-10 Doug Evans <devans@casey.cygnus.com>
+
+ * Makefile.in: Rebuild.
+
+1999-02-09 Doug Evans <devans@casey.cygnus.com>
+
+ * i960c-asm.c,i960c-dis.c,i960c-opc.c,i960c-opc.h: Delete.
+ * i960-dis.c (print_insn_i960): Rename from print_insn_i960_orig.
+ * Makefile.am: Remove references to them.
+ (HFILES): Add fr30-desc.h,m32r-desc.h.
+ (CFILES): Add fr30-desc.c,fr30-ibld.c,m32r-desc.c,m32r-ibld.c,
+ m32r-opinst.c.
+ (ALL_MACHINES): Update.
+ * configure.in: Redo handling of cgen_files.
+ (bfd_i960_arch): Delete i960c-*.lo files.
+ * configure: Regenerate.
+ * cgen-asm.c (*): CGEN_OPCODE_DESC renamed to CGEN_CPU_DESC.
+ (hash_insn_array): Rewrite.
+ * cgen-dis.c (*): CGEN_OPCODE_DESC renamed to CGEN_CPU_DESC.
+ (hash_insn_array): Rewrite.
+ * cgen-opc.c (*): CGEN_OPCODE_DESC renamed to CGEN_CPU_DESC.
+ (cgen_lookup_insn,cgen_get_insn_operands): Define here.
+ (cgen_lookup_get_insn_operands): Ditto.
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerate.
+ * m32r-asm.c,m32r-dis.c,m32r-opc.c,m32r-opc.h: Regenerate.
+ * po/POTFILES.in: Rebuild.
+ * po/opcodes.pot: Rebuild.
+
+Fri Feb 5 00:04:24 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: Rebuild dependencies.
+ (HFILES): Add fr30-opc.h.
+ (CFILES): Add fr30-asm.c, fr30-dis.c, fr30-opc.c.
+ * Makefile.in: Rebuild.
+
+ * configure.in: Change AC_PREREQ to 2.13. Remove AM_CYGWIN32.
+ Change AM_EXEEXT to AC_EXEEXT and AM_PROG_INSTALL to
+ AC_PROG_INSTALL.
+ * acconfig.h: Remove.
+ * configure: Rebuild with current autoconf/automake.
+ * aclocal.m4: Likewise.
+ * config.in: Likewise.
+ * Makefile.in: Likewise.
+
+Thu Feb 4 13:48:52 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Correct move (not movew) to status word on 5200.
+
+Mon Feb 1 20:54:36 1999 Catherine Moore <clm@cygnus.com>
+
+ * disassemble.c (disassembler): Handle bfd_mach_i386_i386_intel_syntax.
+ * i386-dis.c (x_mode): Define.
+ (dis386): Remove.
+ (dis386_att): New.
+ (dis386_intel): New.
+ (dis386_twobyte): Remove.
+ (dis386_twobyte_att): New.
+ (dis386_twobyte_intel): New.
+ (print_insn_x86): Use new arrays.
+ (float_mem): Remove.
+ (float_mem_intel): New.
+ (float_mem_att): New.
+ (dofloat): Use new float_mem arrays.
+ (print_insn_i386_att): New.
+ (print_insn_i386_intel): New.
+ (print_insn_i386): Handle bfd_mach_i386_i386_intel_syntax.
+ (putop): Handle intel syntax.
+ (OP_indirE): Handle intel syntax.
+ (OP_E): Handle intel syntax.
+ (OP_I): Handle intel syntax.
+ (OP_sI): Handle intel syntax.
+ (OP_OFF): Handle intel syntax.
+
+
+
+1999-01-27 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-opc.h,fr30-opc.c: Rebuild.
+ * i960c-opc.h,i960c-opc.c: Rebuild.
+ * m32r-opc.c: Rebuild.
+
+Tue Jan 19 18:01:54 1999 David Taylor <taylor@texas.cygnus.com>
+
+ * hppa-dis.c: revert HP merge changes until HP gives us
+ an updated file.
+
+1999-01-19 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c (print_insn_arm): Display ARM syntax for PC relative
+ offsets as well as symbloic address.
+
+Tue Jan 19 10:51:01 1999 David Taylor <taylor@texas.cygnus.com>
+
+ * hppa-dis.c: fix comments and some indentation.
+
+1999-01-12 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-opc.c,i960c-opc.c: Regenerate.
+
+1999-01-11 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-opc.c: Regenerate.
+
+1999-01-06 Doug Evans <devans@casey.cygnus.com>
+
+ * m32r-dis.c: Regenerate.
+
+1999-01-05 Doug Evans <devans@casey.cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.h,fr30-opc.c: Regenerate.
+ * i960c-asm.c,i960c-dis.c,i960c-opc.h,i960c-opc.c: Regenerate.
+ * m32r-asm.c,m32r-dis.c,m32r-opc.h,m32r-opc.c: Regenerate.
+
+1999-01-04 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * configure.in: Require autoconf 2.12.1 or higher.
+
+1998-12-30 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips16-opc.c: Mark branch insns with MIPS16_INSN_BRANCH.
+
+Wed Dec 16 16:17:49 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c: Regenerated.
+
+1998-12-16 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips-dis.c (set_mips_isa_type): Handle bfd_mach_mips4111.
+
+1998-12-15 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c,fr30-opc.h: Regenerated.
+
+1998-12-14 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c,fr30-opc.h: Regenerated.
+
+Thu Dec 10 18:39:46 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c,fr30-opc.h: Regenerated.
+
+Thu Dec 10 12:49:24 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.c: Regenerate.
+
+Tue Dec 8 13:56:18 1998 David Taylor <taylor@texas.cygnus.com>
+
+ * dis-buf.c (generic_strcat_address): reformat to GNU coding
+ conventions. change sprintf call to an sprintf_vma call.
+
+Tue Dec 8 13:12:44 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerated.
+
+Tue Dec 8 10:50:46 1998 David Taylor <taylor@texas.cygnus.com>
+
+ The following changes were made by
+ Elena Zannoni <ezannoni@kwikemart.cygnus.com>,
+ David Taylor <taylor@texas.cygnus.com>, and
+ Edith Epstein <eepstein@sophia.cygnus.com> as part of a project to
+ merge in changes by HP; HP did not create ChangeLog entries.
+
+ * dis-buf.c (generic_strcat_address): new function.
+
+ * hppa-dis.c: Changes to improve hppa disassembly.
+ Changed formatting in : reg_names, fp_reg_names,control_reg,
+ New variables : sign_extension_names, deposit_names, conversion_names
+ float_test_names, compare_cond_names_double, add_cond_names_double,
+ logical_cond_names_double, unit_cond_names_double,
+ branch_push_pop_names, saturation_names, shift_names, mix_names,
+ New Macros : GET_COMPL_O, GET_PUSH_POP,MERGED_REG
+ Move some definitions to libhppa.h: GET_FIELD, GET_BIT
+ (fput_const): renamed as fput_hex_const
+ (print_insn_hppa):
+ - use the macros fputs_filtered and
+ fput_decimal_const whenever possible; calls to sign_extend require
+ 2 params -- add a missing second param of 0.
+ - Some new code ifdefed for LOCAL_ONLY, all related to figuring out
+ architecture version number of current machine. HP folks are
+ trying to handle situation where the target program was compiled
+ for PA 1.x (32-bit), but is running on a PA 2.0 machine and
+ visa versa.
+ - added new cases : 'g', 'B', 'm'
+ - added cases specifically for PA 2.0
+ - changed the following cases : '"', 'n', 'N', 'p', 'Z',
+ - calls to fput_const become calls to fput_hex_const
+
+1998-12-07 James E Wilson <wilson@wilson-pc.cygnus.com>
+
+ * Makefile.am (CFILES): Add i960c-asm, i960c-dis.c, i960c-opc.c.
+ (ALL_MACHINES): Add i960c-asm.lo, i960c-dis.lo, i960-opc.lo.
+ (i960-asm.lo, i960c-dis.lo, i960c-opc.lo): New Makefile rules.
+ * Makefile.in: Rebuilt.
+ * configure.in (bfd_i960_arch): Add i960c-opc.lo, i960-asm.o,
+ i960-dis.c to ta.
+ * i960-dis.c (print_insn_i960): Rename to print_insn_i960_orig.
+ * i960c-asm.c, i960c-dis.c, i960c-opc.c, i960c-opc.h: New files.
+
+Mon Dec 7 14:33:44 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerated.
+
+Sun Dec 6 14:06:48 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c (mips_builtin_opcodes): Add dmfc2 and dmtc2.
+
+ * ppc-opc.c (powerpc_opcodes): Add PowerPC403 GC[X] instructions.
+ From Saitoh Masanobu <msaitoh@spa.is.uec.ac.jp>.
+
+Fri Dec 4 17:45:51 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * fr30-opc.c: Regenerate.
+
+Fri Dec 4 17:08:08 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerated.
+
+Thu Dec 3 14:26:20 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerated.
+
+Thu Dec 3 00:09:17 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerate.
+
+1998-11-30 Doug Evans <devans@casey.cygnus.com>
+
+ * cgen-dis.c (hash_insn_array): CGEN_INSN_VALUE ->
+ CGEN_INSN_BASE_VALUE.
+ * m32r-opc.c,m32r-opc.h,m32r-asm.c,m32r-dis.c: Regenerate.
+ * fr30-opc.c,fr30-opc.h,fr30-asm.c,fr30-dis.c: Regenerate.
+
+Thu Nov 26 11:26:32 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c: Regenerated.
+
+Tue Nov 24 11:20:54 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c: Regenerated.
+
+Mon Nov 23 18:28:48 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c,fr30-opc.h: Regenerated.
+
+1998-11-20 Doug Evans <devans@tobor.to.cygnus.com>
+
+ * fr30-opc.c: Regenerated.
+
+Thu Nov 19 16:02:46 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c: Regenerated.
+ * fr30-opc.h: Regenerated.
+ * fr30-dis.c: Regenerated.
+ * fr30-asm.c: Regenerated.
+
+Thu Nov 19 07:54:15 1998 Doug Evans <devans@charmed.cygnus.com>
+
+ * mips-opc.c (sync.p,sync.l): Swap insn values.
+
+1998-11-19 Doug Evans <devans@tobor.to.cygnus.com>
+
+ * fr30-opc.c: Regenerate.
+
+Wed Nov 18 21:36:37 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c: Regenerated.
+ * fr30-opc.h: Regenerated.
+
+1998-11-18 Doug Evans <devans@casey.cygnus.com>
+
+ * m32r-asm.c,m32r-dis.c,m32r-opc.c: Rebuild.
+ * fr30-asm.c,fr30-dis.c,fr30-opc.c: Rebuild.
+
+Wed Nov 18 11:30:04 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c: Regenerated.
+
+Mon Nov 16 19:21:48 1998 Dave Brolley <brolley@cygnus.com>
+
+ * fr30-opc.c: Regenerated.
+ * fr30-opc.h: Regenerated.
+ * fr30-dis.c: Regenerated.
+ * fr30-asm.c: Regenerated.
+
+Thu Nov 12 19:24:18 1998 Dave Brolley <brolley@cygnus.com>
+
+ * po/opcodes.pot: Regenerated.
+ * fr30-opc.c: Regenerated.
+ * fr30-opc.h: Regenerated.
+ * fr30-dis.c: Regenerated.
+ * fr30-asm.c: Regenerated.
+
+Tue Nov 10 15:26:27 1998 Nick Clifton <nickc@cygnus.com>
+
+ * disassemble.c (disassembler): Add support for FR30 target.
+
+Tue Nov 10 11:00:04 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-dis.c,m32r-opc.c,m32r-opc.h: Rebuild.
+ * fr30-dis.c,fr30-opc.c,fr30-opc.h: Rebuild.
+
+Mon Nov 9 18:22:55 1998 Dave Brolley <brolley@cygnus.com>
+
+ * po/opcodes.pot: Regenerate.
+ * po/POTFILES.in: Regenerate.
+ * fr30-opc.c: Regenerate.
+ * fr30-opc.h: Regenerate.
+
+Fri Nov 6 17:21:38 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-asm.c: Regenerate.
+
+Wed Nov 4 18:46:47 1998 Dave Brolley <brolley@cygnus.com>
+
+ * configure.in: Added case for bfd_fr30_arch.
+ * Makefile.am (CFILES): Added fr30-asm.c, fr30-dis.c, fr30-opc.c.
+ (ALL_MACHINES): Added fr30-asm.lo, fr30-dis.lo, fr30-opc.lo.
+ (CLEANFILES): Added stamp-fr30.
+ (FR30_DEPS): Added.
+ * fr30-asm.c: New file.
+ * fr30-dis.c: New file.
+ * fr30-opc.c: New file.
+ * fr30-opc.h: New file.
+ * po/POTFILES.in: Regenerated
+ * po/opcodes.pot: Regenerated
+
+Mon Nov 2 15:05:33 1998 Geoffrey Noer <noer@cygnus.com>
+
+ * configure.in: detect cygwin* instead of cygwin32*
+ * configure: regenerate
+
+Tue Oct 27 08:58:37 1998 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * mips-opc.c (IS_M): Added.
+
+Mon Oct 19 13:03:19 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * m32r-opc.c,m32r-opc.h,m32r-asm.c,m32r-dis.c: Regenerate.
+
+Fri Oct 9 14:01:56 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * m32r-opc.h,m32r-opc.c: Regenerate.
+
+Sun Oct 4 21:01:44 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c (OP_3DNowSuffix): New static function.
+ (OPSUF): Define.
+ (GRP14): Define.
+ (dis386_twobyte): Add GRP14, femms, and 3DNow entries.
+ (twobyte_has_modrm): Set entries corresponding to GRP14, 3DNow.
+ (insn_codep): New static variable.
+ (print_insn_x86): Init insn_codep after prefixes.
+ (grps): Add GRP14 entries for prefetch, prefetchw.
+ (OP_REG): Reformat.
+
+ From Jeff B Epler <jepler@usgs.gov>
+ * i386-dis.c (Suffix3DNow): New table.
+
+Wed Sep 30 10:17:50 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d10v-opc.c: Treat TRAP as if it were a branch type instruction.
+
+Mon Sep 28 14:35:43 1998 Martin M. Hunt <hunt@cygnus.com>
+
+ * d10v-dis.c (print_operand): If num is nonzero, then
+ add OPERAND_ACC1, not OPERAND_ACC0.
+
+Thu Sep 24 09:20:03 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v-opc.c: Add FLAG_JSR attribute to DBT, REIT, RTD, and TRAP
+ insns.
+
+Tue Sep 22 17:55:14 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v-opc.c: Add use of EITHER_BUT_PREFER_MU execution unit
+ class.
+
+Tue Sep 15 15:14:45 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.h,m32r-opc.c: Add bbpc,bbpsw support.
+
+1998-09-09 Michael Meissner <meissner@cygnus.com>
+
+ * ppc-opc.c (powerpc_opcodes): Add support for PowerPC 750 move
+ to/from SPRs.
+
+Fri Sep 4 19:42:59 1998 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c (print_insn_big_arm): Detect Thumb symbols in elf
+ object files.
+ (print_insn_little_arm): Detect Thumb symbols in elf object
+ files.
+
+Sat Aug 29 22:24:09 1998 Richard Henderson <rth@cygnus.com>
+
+ * alpha-dis.c (print_insn_alpha): Use the machine type to
+ decide which PALcode set to include.
+
+Sun Aug 23 02:16:18 1998 Richard Henderson <rth@cygnus.com>
+
+ * sparc-opc.c (FBRX): Fix typo in ",a,pn %fcc3" case.
+
+Fri Aug 21 16:07:52 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v-opc.c (d30v_opcode_table): Add FLAG_MUL32 to MAC, MACS,
+ MSUB and MSUBS instructions.
+
+Thu Aug 13 16:23:04 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ppc-opc.c (powerpc_operands): Omit parens around additions in
+ operand name macros.
+
+Wed Aug 12 14:00:38 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ From Peter Jeremy <peter.jeremy@auss2.alcatel.com.au>:
+ * m68k-opc.c: Correct mulsl and mulul to use q rather than D, a,
+ +, -, and d for ColdFire.
+
+ From Peter Thiemann <thiemann@informatik.uni-tuebingen.de>:
+ * ppc-opc.c (insert_mbe): Handle wrapping bitmasks.
+ (extract_mbe): Likewise.
+
+Wed Aug 12 11:11:34 1998 Jeffrey A Law (law@cygnus.com)
+
+ * m10300-opc.c: Fix typo in udf20 .. udf25 instruction opcodes.
+
+ * m10300-opc.c: First cut at UDF instructions.
+
+Mon Aug 10 14:08:22 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.c: Regenerate (remove semantic descriptions).
+
+Mon Aug 10 12:51:12 1998 Catherine Moore <clm@cygnus.com>
+
+ * arm-dis.c (print_insn_big_arm): Fix indentation.
+ (print_insn_little_arm): Likewise.
+
+Sun Aug 9 20:17:28 1998 Catherine Moore <clm@cygnus.com>
+
+ * arm-dis.c (print_insn_big_arm): Check for thumb symbol
+ attributes.
+ (print_insn_little_arm): Likewise.
+
+Mon Aug 3 12:43:16 1998 Doug Evans <devans@seba.cygnus.com>
+
+ Move all global state data into opcode table struct, and treat
+ opcode table as something that is "opened/closed".
+ * cgen-asm.c (all fns): New first arg of opcode table descriptor.
+ (cgen_asm_init): Delete.
+ (cgen_set_parse_operand_fn): New function.
+ * cgen-dis.c (all fns): New first arg of opcode table descriptor.
+ (cgen_dis_init): Delete.
+ * cgen-opc.c (all fns): New first arg of opcode table descriptor.
+ (cgen_current_{opcode_table_mach,endian}): Delete.
+ * m32r-asm.c,m32r-dis.c,m32r-opc.c,m32r-opc.h: Regenerate.
+
+Thu Jul 30 21:41:10 1998 Frank Ch. Eigler <fche@cygnus.com>
+
+ * d30v-opc.c (d30v_opcode_table): Add new "LKR" flag to some
+ instructions.
+
+Tue Jul 28 11:00:09 1998 Jeffrey A Law (law@cygnus.com)
+
+ * m10300-opc.c: Add entries for "no_match_operands" field in
+ the opcode table.
+
+Fri Jul 24 11:41:37 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-asm.c,m32r-opc.c: Regenerate (-Wall cleanups).
+
+Tue Jul 21 13:41:07 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * m32r-opc.h,m32r-opc.c,m32r-asm.c,m32r-dis.c: Regenerate.
+
+Mon Jul 13 14:53:59 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c (ckprefix): Handle fwait specially only when it isn't
+ the first prefix.
+ (dofloat): Correct test for fnstsw. Print `fnstsw %ax' rather
+ than `fnstsw %eax'.
+ (OP_J): Remove unnecessary subtraction when 16-bit displacement
+ will be masked later.
+
+Thu Jul 2 17:11:27 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * m32r-opc.h (CGEN_MIN_INSN_SIZE): New #define.
+
+Wed Jul 1 16:11:16 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * m32r-asm.c,m32r-dis.c,m32r-opc.c,m32r-opc.h: Regenerate.
+
+Fri Jun 26 11:08:55 1998 Jeffrey A Law (law@cygnus.com)
+
+ * m10300-dis.c: Only recognize instructions from the currently
+ selected machine.
+ * m10300-opc.c: Add field indicating the particular variant of
+ the mn10300 each instruction is available on.
+
+Fri Jun 26 12:04:21 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: For bfd_vax_arch, build vax-dis.lo.
+ * Makefile.am: Rebuild dependencies.
+ (CFILES): Add vax-dis.c.
+ (ALL_MACHINES): Add vax-dis.lo.
+ * aclocal.m4: Rebuild with current libtool.
+ * configure, Makefile.in: Rebuild.
+
+Fri Jun 26 12:03:20 1998 Klaus Kaempf <kkaempf@progis.de>
+
+ * vax-dis.c: New file, from work by Pauline Middelink
+ <middelin@polyware.iaf.nl>.
+ * disassemble.c (ARCH_vax): Define if ARCH_all.
+ (disassembler): Add case for ARCH_vax.
+ * makefile.vms: Support compilation on vms/vax.
+
+Tue Jun 23 19:42:18 1998 Mark Alexander <marka@cygnus.com>
+
+ * m10200-dis.c (print_insn_mn10200): Fix various non-portabilities
+ related to sign extension and the size of ints.
+
+Tue Jun 23 10:59:26 1998 Jeffrey A Law (law@cygnus.com)
+
+ * m10300-opc.c: Support one operand "asr", "lsr" and "asl"
+ instructions. Support (sp) addressing mode by expanding it into
+ (0,sp).
+
+Sat Jun 20 14:46:20 1998 Frank Ch. Eigler <fche@cygnus.com>
+
+ * mips-dis.c (_print_insn_mips): Fix argument interchange typo.
+
+Fri Jun 19 09:16:42 1998 Mark Alexander <marka@cygnus.com>
+
+ * m10200-dis.c (print_insn_mn10200): Recognize 'break' pseudo-op.
+
+1998-06-18 Ulrich Drepper <drepper@cygnus.com>
+
+ * i386-dis.c: Add support for fxsave, fxrstor, sysenter and
+ sysexit.
+
+Thu Jun 18 10:22:24 1998 John Metzler <jmetzler@cygnus.com>
+
+ * mips-dis.c (print_insn_little_mips): Previously, instruction
+ printing references the symbol table to determine whether the
+ instruction resides in a block regular instructions or mips16
+ instructions. However, when the disassembler gets used in other
+ environments where the symbol table is not present, we no longer
+ rely in the symbol table, rather, use the low bit of the
+ instructions address to guess. There should be no change for usage
+ of the disassembler in host based programs, gdb, objdump.
+ (print_insn_big_mips): ditto.
+ (print_insn_mips): ditto
+
+Wed Jun 17 21:19:01 1998 Mark Alexander <marka@cygnus.com>
+
+ * m10200-dis.c (print_insn_mn10200): Don't bomb on unknown opcodes.
+
+Wed Jun 17 17:49:23 1998 Jeffrey A Law (law@cygnus.com)
+
+ * m10300-opc.c (mn10300_opcodes): Change opcode for "syscall".
+
+Tue Jun 16 13:10:51 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c (index16): Add '%' to register names. Use ','
+ instead of '+'.
+
+Sat Jun 13 11:33:55 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c: Don't print opcode suffix when we can figure out the
+ size (and gas can!) by register operands, or from the default
+ size.
+ (putop): Handle 'A', 'B', 'L', 'P', 'Q', 'R' macros. Rename 'C'
+ macro to 'E'.
+ (dis386, dis386_twobyte, grps): Use new suffix macros.
+ (dis386): Correct imul Ib to imul sIb. Change jnl to jge to be
+ consistent. Add suffix for call, jmp, lcall, ljmp, iret. Reverse
+ order of cmps operands to agree with Intel docs. Correct operand
+ of aad and aam (Ib -> sIb). Change ud2b from 0fb8 to 0fb9 to
+ agree with Intel docs.
+ (print_insn_x86): Print orphan fwait before other prefixes.
+ Return correct byte count for orphan fwait with prefixes. Don't
+ print `bound' operands in reverse order.
+ (ckprefix): Stop accumulating prefixes if we get fwait.
+ (OP_DIR): Print `$' before Ap operands of ljmp, lcall.
+
+Fri Jun 12 13:40:38 1998 Tom Tromey <tromey@cygnus.com>
+
+ * po/Make-in (all-yes): If maintainer mode, depend on .pot file.
+ ($(PACKAGE).pot): Unconditionally depend on POTFILES.
+
+Fri Jun 12 11:04:06 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ Fix problems when bfd_vma is wider than long.
+ * i386-dis.c: Make op_address and start_pc unsigned.
+ (set_op): Make parameter unsigned.
+ (print_insn_x86): Cast to bfd_vma when passing a value to
+ print_address_func.
+ * ns32k-dis.c (CORE_ADDR): Don't define.
+ (print_insn_ns32k): Change type of addr to bfd_vma. Use
+ bfd_scan_vma to read back address.
+ (print_insn_arg): Change type of addr to bfd_vma. Use sprintf_vma
+ to format it.
+ * m68k-dis.c (COERCE32): Cast to bfd_signed_vma to avoid overflow.
+ (NEXTULONG): New definition.
+ (print_insn_m68k): Avoid overflow when computing third argument of
+ print_insn_arg.
+ (print_insn_arg): Use NEXTULONG to fetch 32 bit address values.
+ Use disp instead of val to store offset values.
+ (print_indexed): Use base_disp instead of word to store base
+ displacement, to avoid overflow.
+ * m10300-dis.c (disassemble): Cast value to long when computing
+ pc-relative address, to get correct sign extension.
+
+Wed Jun 10 15:58:37 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.c: Regenerate.
+
+Tue Jun 9 14:27:57 1998 Nick Clifton <nickc@cygnus.com>
+
+ * arm-opc.h (thumb_opcodes): Display 'add rx, rY, #0' insns as
+ 'mov rX, rY'. Patch courtesy of Tony Thompson <Tony.Thompson@arm.com>
+
+Mon Jun 8 18:17:21 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v-opc.c: Remove FALG_MUL32 attribyte from MULX2H insn.
+
+Fri Jun 5 23:47:55 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c: Combine aflag and dflag into sizeflag. Change OP_*
+ functions to void.
+ (OP_DSreg): Rename from OP_DSSI.
+ (OP_ESreg): Rename from OP_ESDI.
+ (Xb, Xv, Yb, Yv): Use index reg code, not b_mode or v_mode.
+ (DSBX): Define.
+ (append_seg): Rename from append_prefix.
+ (ptr_reg): New function.
+ (dis386): Add S suffix to pushf, popf, ret, lret, enter, leave.
+ Add DSBX for xlat.
+ (PREFIX_ADDR): Rename from PREFIX_ADR.
+ (float_reg): Add non-broken opcodes for people who don't want
+ UNIXWARE_COMPAT.
+
+Fri Jun 5 19:15:04 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-opc.c (tstb, tstw, tstl): Don't allow pcrel on
+ 68000/68008/68010.
+
+Wed Jun 3 18:56:22 1998 H.J. Lu <hjl@gnu.org>
+
+ * i386-dis.c (dis386): Change 0x60 to "pushaS", 0x61 to "popaS".
+
+Tue Jun 2 15:06:46 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * ppc-opc.c (powerpc_macros): Support shifts and rotates of size
+ 0; produce error message for shifts of size 32 (or 64 for 64-bit
+ shifts), because the hardware doesn't support them.
+
+Wed May 27 15:29:13 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v-opc.c: Add new operand: Ra3. Change SHORT_B3, SHORT_B3b,
+ LONG_2, LONG_2b formats to use this new operand.
+
+Tue May 26 20:47:48 1998 Stan Cox <scox@cygnus.com>
+
+ * sparc-dis.c (compute_arch_mask): Added bfd_mach_sparc_sparclite_le.
+
+Tue May 26 20:45:33 1998 Mark Alexander <marka@cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): big endian instruction / little
+ endian data support.
+
+Tue May 26 16:14:39 1998 Nick Clifton <nickc@cygnus.com>
+
+ * d30v-opc.c (d30v_format_table): Change definition of SHORT_B3
+ and SHORT_B3b formats to use Rb instead of Ra.
+
+ Add FLAG_MUL16 to MUL2XH opcode.
+
+ Add FLAG_ADDSUBppp to SRC and SATHp opcodes to implement extension
+ to existing 1.1.1 parallelisation prohibition procedure.
+
+Fri May 22 16:00:00 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-asm.c,m32r-dis.c: Regenerate.
+
+Tue May 19 17:36:08 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_mips16_insn_arg): Handle type ']' correctly
+ with a shift count of 0.
+
+Fri May 15 14:58:31 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-opc.c (cgen_hw_lookup_by_name): Renamed from cgen_hw_lookup.
+ (cgen_hw_lookup_by_num): New function.
+
+Wed May 13 17:03:59 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-asm.c: Regenerate (handle uppercase HIGH/SHIGH/LOW/SDA).
+
+Wed May 13 14:34:31 1998 Mark Alexander <marka@cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): Always fetch instructions
+ as big-endian on SPARClite.
+
+Tue May 12 11:46:31 1998 Richard Henderson <rth@cygnus.com>
+
+ * d30v-opc.c (pre_defined_register): Remove alias for r0.
+
+Sun May 10 22:37:22 1998 Jeffrey A Law (law@cygnus.com)
+
+ * po/Make-in (install-info): New target.
+
+Thu May 7 17:15:59 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in (WIN32LIBADD): Add -lintl on cygwin32.
+ * configure: Rebuild.
+
+Thu May 7 12:49:46 1998 Frank Ch. Eigler <fche@cygnus.com>
+
+ * mips-opc.c (teq,tge,tgeu,tlt,tltu,tne): Added three-operand
+ variety of ISA2 instructions to set bottom ten bits of trap code.
+
+Thu May 7 11:54:25 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (config.status): Add explicit target so that
+ config.status depends upon bfd/configure.in.
+ * Makefile.in: Rebuild.
+
+Thu May 7 09:33:02 1998 Frank Ch. Eigler <fche@cygnus.com>
+
+ * mips-opc.c (break, sdbbp): Added two-operand variety of ISA1
+ instructions to set bottom ten bits of break code.
+ * mips-dis.c (print_insn_arg): Implement 'q' operand format used
+ for above optional argument.
+
+Wed May 6 15:30:06 1998 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Run dec c with /nodebug.
+
+Mon May 4 10:19:57 1998 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am: Regenerated dependencies with mkdep.
+
+ * opintl.h (_): Define as dgettext.
+
+Tue Apr 28 14:12:12 1998 Nick Clifton <nickc@cygnus.com>
+
+ * cgen-asm.c: Internationalised.
+ * m32r-asm.c: Internationalised.
+ * m32r-dis.c: Internationalised.
+ * m32r-opc.c: Internationalised.
+
+ * aclocal.m4: Regenerated.
+ * configure: Regenerated.
+ * Makefile.am (POTFILES): Remove inclusion of BFD_H.
+ * Makefile.in: Rebuild.
+ * po/POTFILES.in: Rebuilt using rule in Makefile.in.
+ * po/opcodes.pot: Rebuilt after changing POTFILES.in.
+
+Tue Apr 28 13:13:13 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_ISC_POSIX near start. Move CY_GNU_GETTEXT
+ after AC_PROG_CC.
+ * aclocal.m4, configure: Rebuild with current tools.
+
+Mon Apr 27 14:31:00 1998 Nick Clifton <nickc@cygnus.com>
+
+ * opintl.h: New file - contains internationalisation macros used
+ by source files in this directory.
+ * po/: New subdirectory - contains internationalisation files.
+ * po/Make-in: New file - Makefile constructor.
+ * po/POTFILES.in: New file - list of files in opcodes directory
+ that should be scan for internationalisation macros.
+ * po/opcodes.pot: New file - list of internationisation strings
+ found in files mentioned in po/POTFILES.in.
+ * Makefile.am: Add rule to build po/POTFILES.in. Add SUBDIRS
+ entry. Add intl directory to include paths.
+ * acconfig.h: Add ENABLE_NLS, HAVE_CATGETS, HAVE_GETEXT,
+ HAVE_STRCPY, HAVE_LC_MESSAGES
+ * configure.in: Add rule to build Makefile in po subdirectory.
+ * Makefile.in: Rebuilt.
+ * aclocal.m4: Rebuilt.
+ * config.in: Rebuilt.
+ * configure: Rebuilt.
+ * alpha-opc.c: Internationalised.
+ * arc-dis.c: Internationalised.
+ * arc-opc.c: Internationalised.
+ * arm-dis.c: Internationalised.
+ * cgen-asm.c: Internationalised.
+ * d30v-dis.c: Internationalised.
+ * dis-buf.c: Internationalised.
+ * h8300-dis.c: Internationalised.
+ * h8500-dis.c: Internationalised.
+ * i386-dis.c: Internationalised.
+ * m10200-dis.c: Internationalised.
+ * m10300-dis.c: Internationalised.
+ * m68k-dis.c: Internationalised.
+ * m88k-dis.c: Internationalised.
+ * mips-dis.c: Internationalised.
+ * ns32k-dis.c: Internationalised.
+ * opintl.h: Internationalised.
+ * ppc-opc.c: Internationalised.
+ * sparc-dis.c: Internationalised.
+ * v850-dis.c: Internationalised.
+ * v850-opc.c: Internationalised.
+
+Mon Apr 27 10:33:56 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-asm.c (cgen_current_opcode_table): Renamed from ..._data.
+ (asm_hash_table_entries): New variable.
+ (cgen_asm_init): Free asm_hash_table_entries.
+ (hash_insn_array,hash_insn_list): New functions.
+ (build_asm_hash_table): Use them. Hash macro insns as well.
+ (cgen_asm_lookup_insn): Update.
+ * cgen_dis.c (cgen_current_opcode_table): Renamed from ..._data.
+ (dis_hash_table_entries): New variable.
+ (cgen_dis_init): Free dis_hash_table_entries.
+ (hash_insn_array,hash_insn_list): New functions.
+ (build_dis_hash_table): Use them. Hash macro insns as well.
+ (cgen_dis_lookup_insn): Update.
+ * cgen-opc.c (cgen_current_opcode_table): Renamed from ..._data.
+ (cgen_set_cpu,cgen_hw_lookup,cgen_insn_count): Update.
+ (cgen_macro_insn_count): New function.
+ * m32r-opc.h,m32r-opc.c,m32r-asm.c,m32r-dis.c: Regenerate.
+
+Fri Apr 24 16:07:57 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c (OP_DSSI): Print segment override.
+
+Mon Apr 13 16:59:39 1998 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c (print_insn_arm): Add "_all" extension to 'C'
+ operator.
+
+Mon Apr 13 16:50:27 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (libopcodes_la_LIBADD): Add @WIN32LIBADD@.
+ (libopcodes_la_LDFLAGS): Add @WIN32LDFLAGS@.
+ * configure.in: Define and substitute WIN32LDFLAGS and
+ WIN32LIBADD.
+ * aclocal.m4: Rebuild with new libtool.
+ * configure, Makefile.in: Rebuild.
+
+Fri Apr 10 18:14:31 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.c: Regenerate.
+
+Sun Apr 5 16:04:39 1998 H.J. Lu <hjl@gnu.org>
+
+ * Makefile.am (stamp-lib): Check that .libs/libopcodes.a exists
+ before trying to copy it.
+ * Makefile.in: Rebuild.
+
+Thu Apr 2 17:25:49 1998 Nick Clifton <nickc@cygnus.com>
+
+ * m32r-opc.c: Use signed immediate values for CMPUI instruction.
+
+Wed Apr 1 16:20:27 1998 Ian Dall <Ian.Dall@dsto.defence.gov.au>
+
+ * ns32k-dis.c (bit_extract_simple): New function to extract bits
+ from an arbitrary valid buffer instead of fetching them on demand
+ using fetch_data().
+ (invalid_float): use bit_extract_simple() instead of bit_extract().
+
+Tue Mar 31 11:09:08 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ From H.J. Lu <hjl@gnu.org>:
+ * i386-dis.c (dis386): Change 0x8c and 0x8e to movS, and change Ew
+ to Ev for both.
+
+Mon Mar 30 17:32:03 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Branched binutils 2.9.
+
+Mon Mar 30 15:18:00 1998 Ken Raeburn <raeburn@cygnus.com>
+
+ * d30v-dis.c (print_insn_d30v): Don't use uninitialized "num" when
+ disassembling last 4 bytes of a section.
+
+Fri Mar 27 18:08:13 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ Fix some gcc -Wall warnings:
+ * arc-dis.c (print_insn): Add casts to avoid warnings.
+ * cgen-opc.c (cgen_keyword_lookup_name): Likewise.
+ * d10v-dis.c (dis_long, dis_2_short): Likewise.
+ * m10200-dis.c (disassemble): Likewise.
+ * m10300-dis.c (disassemble): Likewise.
+ * ns32k-dis.c (print_insn_ns32k): Likewise.
+ * ppc-opc.c (insert_ral, insert_ram): Likewise.
+ * cgen-dis.c (build_dis_hash_table): Remove used local variables.
+ * cgen-opc.c (cgen_keyword_search_next): Likewise.
+ * d10v-dis.c (dis_long, dis_2_short): Likewise.
+ * d30v-dis.c (print_insn_d30v, lookup_opcode): Likewise.
+ * ns32k-dis.c (bit_extract, print_insn_ns32k): Likewise.
+ * tic80-dis.c (print_one_instruction): Likewise.
+ * w65-dis.c (print_operand): Likewise.
+ * z8k-dis.c (fetch_data): Likewise.
+ * a29k-dis.c: Add return type for find_byte_func_type.
+ * arc-opc.c: Include <stdio.h>. Remove declarations of
+ insert_multshift and extract_multshift.
+ * d30v-dis.c (lookup_opcode): Parenthesize assignments in
+ conditionals.
+ (extract_value): Fully parenthesize expression.
+ * h8500-dis.c (print_insn_h8500): Initialize local variables.
+ * h8500-opc.h (h8500_table): Fully bracket initializer.
+ * w65-opc.h (optable): Likewise.
+ * i386-dis.c (print_insn_x86): Declare aflag and flag parameters.
+ * i386-dis.c (OP_E): Initialize local variables.
+ * m10200-dis.c (print_insn_mn10200): Likewise.
+ * mips-dis.c (print_insn_mips16): Likewise.
+ * sh-dis.c (print_insn_shx): Likewise.
+ * v850-dis.c (print_insn_v850): Likewise.
+ * ns32k-dis.c (print_insn_arg): Declare.
+ (get_displacement, invalid_float): Declare.
+ (list_search, sign_extend, flip_bytes): Declare return type.
+ (get_displacement): Likewise.
+ (print_insn_arg): Likewise. Make d int. Fix sprintf format
+ string.
+ (print_insn_ns32k): Make i unsigned.
+ (invalid_float): Make static. Declare type of val.
+ * tic30-dis.c (print_par_insn): Make i size_t. Don't check strlen
+ on each for iteration.
+ * tic30-dis.c (get_indirect_operand): Likewise.
+ * z8k-dis.c (print_insn_z8001): Declare return type.
+ (print_insn_z8002): Likewise.
+ (unparse_instr): Fix sprintf format strings.
+
+Fri Mar 27 00:05:23 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mips-opc.c: Add "sync.l" and "sync.p".
+
+Wed Mar 25 14:32:48 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-dis.c (print_insn_m68k): Use info->mach to select the
+ default m68k variant to recognize.
+
+ * i960-dis.c (pinsn): Change type of first argument to bfd_vma.
+ (ctrl, cobr, mem, ea): Likewise.
+ (print_addr): Likewise. Remove cast.
+ (ea): Cast argument of print_addr to bfd_vma.
+
+ * cgen-asm.c (cgen_parse_signed_integer): Fix type of local
+ variable value.
+ (cgen_parse_unsigned_integer): Likewise.
+ (cgen_parse_address): Likewise.
+
+Wed Mar 25 14:31:31 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * i960-dis.c (ctrl): Add full braces to structure initialization.
+ (cobr, mem, reg): Likewise.
+ (ea): Correct parenthesization in expression.
+
+ * cgen-asm.c: Include <ctype.h>.
+ (build_asm_hash_table): Remove unused local variable i.
+ (cgen_parse_keyword): Add casts to avoid warnings.
+
+ * arm-dis.c (print_insn_big_arm): Only call coffsymbol for a COFF
+ symbol. Fix indentation.
+ (print_insn_little_arm): Likewise.
+
+Fri Mar 20 18:55:18 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use AM_DISABLE_SHARED.
+ * aclocal.m4, configure: Rebuild with libtool 1.2.
+
+Thu Mar 19 15:46:53 1998 Nick Clifton <nickc@cygnus.com>
+
+ These patches are courtesy of Jonathan Walton and Tony Thompson
+ (athompso@cambridge.arm.com).
+
+ * arm-dis.c (print_insn_thumb): Ignore bottom two bits of PC
+ relative addresses.
+
+ * arm-opc.h (thumb_opcodes): Annotate PC relative addresses with
+ both the offset and the label closest to the destination.
+
+Sat Mar 14 23:47:14 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * m32r-opc.h: Regenerate.
+
+Wed Mar 4 12:08:14 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.h,m32r-opc.c,m32r-asm.c,m32r-dis.c: Regenerate.
+
+Sat Feb 28 16:02:34 1998 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c (print_insn_big_arm, print_insn_little_arm): Do not
+ assume that info->symbols is non-empty.
+
+Sat Feb 28 12:19:05 1998 Richard Henderson <rth@cygnus.com>
+
+ * alpha-opc.c (cvtqs) There is no such thing.
+ (cvttq): Missing most of the /*d variants.
+
+Thu Feb 26 15:53:09 1998 Michael Meissner <meissner@cygnus.com>
+
+ * d30v-opc.c (d30v_opcode_table): Indicate which instructions are
+ delayed branches or jumps.
+
+Tue Feb 24 10:46:44 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * arm-dis.c (print_insn_{big,little}_arm): info->symbol changed
+ to *info->symbols.
+ * mips-dis.c (print_insn_{big,little}_mips): Likewise.
+ * tic30-dis.c (print_branch): Likewise.
+
+Tue Feb 24 11:06:18 1998 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c (print_insn_big_arm, print_insn_little_arm): Remove
+ saved_symbol code as it is no longer needed.
+
+Mon Feb 23 13:16:17 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-asm.c: Include symcat.h.
+ * cgen-dis.c,cgen-opc.c: Ditto.
+ * m32r-asm.c,m32r-dis.c,m32r-opc.h,m32r-opc.c: Regenerate.
+
+Mon Feb 23 10:34:58 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mips-dis.c (print_insn_arg): Do not prefix 'P' arguments with '$'.
+
+Thu Feb 19 16:51:13 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.[ch]: Regenerate.
+
+Tue Feb 17 17:14:50 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-asm.c (cgen_parse_{signed,unsigned}_integer): Delete min,max
+ arguments. Don't perform validation here.
+ * m32r-asm.c,m32r-dis.c,m32r-opc.c: Regenerate.
+
+Fri Feb 13 14:26:06 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.c: Regenerate.
+
+Fri Feb 13 14:53:02 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am (AUTOMAKE_OPTIONS): Define.
+ * configure, Makefile.in, aclocal.m4: Rebuild with automake 1.2e.
+
+Fri Feb 13 10:21:09 1998 Mark Alexander <marka@cygnus.com>
+
+ * m10300-dis.c (print_insn_mn10300): Recognize break instruction.
+
+Fri Feb 13 13:12:14 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Get the version number from BFD.
+ * configure: Rebuild.
+
+ From H.J. Lu <hjl@gnu.org>:
+ * Makefile.am (libopcodes_la_LDFLAGS): Define.
+ * Makefile.in: Rebuild.
+
+Fri Feb 13 09:50:32 1998 Nick Clifton <nickc@cygnus.com>
+
+ * m32r-opc.c: Regenerate.
+ * m32r-opc.h: Regenerate.
+
+Thu Feb 12 11:01:40 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.c: Regenerate.
+
+Thu Feb 12 03:41:00 1998 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ Fix rac to accept only a0:
+ * d10v-opc.c (d10v_predefined_registers, d10v_operands, d10v_opcodes):
+ Split OPERAND_ACC into OPERAND_ACC0 and OPERAND_ACC1.
+ Introduce OPERAND_GPR.
+ * d10v-dis.c (print_operand): Likewise.
+
+Wed Feb 11 18:58:34 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-opc.c (cgen_set_cpu): Delete init of hw list `next' chain.
+ (cgen_hw_lookup): Make result const.
+ * m32r-opc.h, m32r-opc.c, m32r-asm.c, m32r-dis.c: Regenerate.
+
+Sat Feb 7 15:30:27 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure, aclocal.m4: Rebuild with new libtool.
+
+Thu Feb 5 17:56:10 1998 Michael Meissner <meissner@cygnus.com>
+
+ * d30v-opc.c (repeat{,i} instructions): Repeat/repeati
+ instructions use a PC relative branch, not absolute.
+
+Wed Feb 4 19:17:37 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set libtool_enable_shared rather than
+ libtool_shared. Remove diversion hack.
+ * configure, Makefile.in, aclocal.m4: Rebuild with new libtool.
+
+Tue Feb 3 17:19:40 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-opc.c (cgen_set_cpu): Initialize hardware table.
+ * m32r-opc.h, m32r-opc.c, m32r-asm.c, m32r-dis.c: Regenerate.
+
+Mon Feb 2 19:22:15 1998 Steve Haworth <steve@pm.cse.rmit.EDU.AU>
+
+ * tic30-dis.c: New file.
+ * disassemble.c (disassembler): Add bfd_arch_tic30 case.
+ * configure.in: Handle bfd_tic30_arch.
+ * Makefile.am: Rebuild dependencies.
+ (CFILES): Add tic30-dis.c
+ (ALL_MACHINES): Add tic30-dis.lo.
+ * configure, Makefile.in: Rebuild.
+
+Thu Jan 29 13:02:56 1998 Doug Evans <devans@canuck.cygnus.com>
+
+ * m32r-opc.h (HAVE_CPU_M32R): Define.
+
+Wed Jan 28 09:55:03 1998 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (insertion routines): If both alignment and size is
+ wrong then report this.
+
+Tue Jan 27 21:52:59 1998 Jeffrey A Law (law@cygnus.com)
+
+ * mips-dis.c (_print_insn_mips): Set target_processor as appropriate.
+ Only recognize instructions for the current target_processor.
+
+Thu Jan 22 16:20:17 1998 Fred Fish <fnf@cygnus.com>
+
+ * d10v-dis.c (PC_MASK): Correct value.
+ (print_operand): If there's a reloc, don't calculate the
+ address because they could be in different sections.
+
+Fri Jan 16 15:29:11 1998 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ * mips-opc.c (mips_builtin_opcodes): Move 4010's "addciu"
+ instruction after the 4650's "mul" instruction; nobody's using the
+ 4010 these days. If object files someday indicate which processor
+ variant they're intended for, we can do a better job at this.
+
+Mon Jan 12 14:43:54 1998 Doug Evans <devans@seba.cygnus.com>
+
+ * cgen-asm.c (build_asm_hash_table): Traverse compiled in table using
+ table provided entry size. Use CGEN_INSN_MNEMONIC.
+ (cgen_parse_keyword): Rewrite.
+ * cgen-dis.c (build_dis_hash_table): Traverse compiled in table using
+ table provided entry size. Use CGEN_INSN_MASK_BITSIZE.
+ * cgen-opc.c: Clean up pass over `struct foo' usage.
+ (cgen_keyword_lookup_value): Handle "" entry.
+ (cgen_keyword_add): Likewise.
+
+Mon Dec 22 12:37:06 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Add FP_D to s.d instruction flags.
+
+Wed Dec 17 11:38:29 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-opc.c (halt, pulse): Enable them on the 68060.
+
+Tue Dec 16 15:22:53 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_opcodes): Revert change that put the 32 bit
+ PC relative offset forms before the 15 bit forms. An assembler command
+ line option now chooses the default.
+
+Tue Dec 16 15:22:51 1997 Michael Meissner <meissner@cygnus.com>
+
+ * d30v-opc.c (d30v_opcode_table): Set new flags bits
+ FLAG_{2WORD,MUL{16,32},ADDSUBppp}, in appropriate instructions.
+
+1997-12-15 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * configure: Only build libopcodes shared if --enable-shared's value
+ was `yes', or was set to `*opcodes*'.
+ * aclocal.m4: Likewise.
+ * NOTE: this really needs to be fixed in libtool/libtool.m4, the
+ original source of this bit of code. It's not clear what the best fix
+ would be, though.
+
+Fri Dec 12 11:57:04 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (OFF_SL_PC, OFF_SL_BR): Minor formatting change.
+ (tic80_opcodes): Reorder table entries to put the 32 bit PC relative
+ offset forms before the 15 bit forms, to default to the long forms.
+
+Fri Dec 12 01:32:30 1997 Richard Henderson <rth@cygnus.com>
+
+ * alpha-opc.c (cvttq/*u*): Remove, as that suffix is invalid.
+
+Wed Dec 10 17:42:35 1997 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c (print_insn_little_arm): Prevent examination of stored
+ symbol if none is present.
+ (print_insn_big_arm): Prevent examination of stored symbol if
+ none is present.
+
+Thu Oct 23 21:13:37 1997 Fred Fish <fnf@cygnus.com>
+
+ * d10v-opc.c (d10v_opcodes): Correct entry for RTE.
+
+Mon Dec 8 11:21:07 1997 Nick Clifton <nickc@cygnus.com>
+
+ * disassemble.c: Remove disasm_symaddr() function.
+
+ * arm-dis.c: Use info->symbol instead of info->flags to determine
+ if disassmbly should be in Thumb or Arm mode.
+
+Tue Dec 2 09:54:27 1997 Nick Clifton <nickc@cygnus.com>
+
+ * arm-dis.c: Add support for disassembling Thumb opcodes.
+ (print_insn_thumb): New function.
+
+ * disassemble.c (disasm_symaddr): New function.
+
+ * arm-opc.h: Display nop pseudo ops alongside equivalent disassembly.
+ (thumb_opcodes): Table of Thumb opcodes.
+
+Mon Dec 1 12:25:57 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-opc.c (btst): Change Dd@s to Dd;b.
+
+ * m68k-dis.c (print_insn_arg): Recognize 'm', 'n', 'o', 'p', 'q',
+ and 'v' as operand types.
+
+Mon Dec 1 11:56:50 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Add argument for lpstop. From Olivier Carmona
+ <olivier.carmona@di.epfl.ch>.
+ * m68k-dis.c (print_insn_m68k): Handle special case of lpstop,
+ which has a two word opcode with a one word argument.
+
+Sun Nov 23 22:25:21 1997 Michael Meissner <meissner@cygnus.com>
+
+ * d30v-opc.c (d30v_opcode_table, case cmpu): Immediate field is
+ unsigned, not signed.
+ (d30v_format_table): Add SHORT_CMPU cases for cmpu.
+
+Tue Nov 18 23:10:03 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * d10v-dis.c (print_operand):
+ Split OPERAND_FLAG into OPERAND_FFLAG and OPERAND_CFLAG.
+
+Tue Nov 18 18:45:14 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ * d10v-opc.c (OPERAND_FLAG): Split into:
+ (OPERAND_FFLAG, OPERAND_CFLAG) .
+ (FSRC): Split into:
+ (FFSRC, CFSRC).
+
+Thu Nov 13 11:05:33 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c: Move the INSN_MACRO ISA value to the membership
+ field for all INSN_MACRO's.
+ * mips16-opc.c: same
+
+Wed Nov 12 10:16:57 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c (sync,cache): These are 3900 insns.
+
+Tue Nov 11 23:53:41 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
+
+ sh-opc.h (sh_table): Remove ftst/nan.
+
+Tue Oct 28 17:59:32 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ * mips-opc.c (ffc, ffs): Fix mask.
+
+Tue Oct 28 16:34:54 1997 Michael Meissner <meissner@cygnus.com>
+
+ * d30v-opc.c (pre_defined_registers): Add eit_vb, int_s, and int_m
+ control registers.
+
+Mon Oct 27 22:34:03 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ * mips-opc.c: Fix bug in mask for "not" pseudo-instruction.
+ (WR_HILO, RD_HILO, MOD_HILO): New macros.
+
+Mon Oct 27 22:34:03 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ * mips-opc.c: Fix bug in mask for "not" pseudo-instruction.
+ (WR_HILO, RD_HILO, MOD_HILO): New macros.
+
+Thu Oct 23 14:57:58 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (disassemble): Replace // with /* ... */
+
+Wed Oct 22 17:33:21 1997 Richard Henderson <rth@cygnus.com>
+
+ * sparc-opc.c: Add wr & rd for v9a asr's.
+ * sparc-dis.c (print_insn_sparc): Recognize '_' and '/' for v9a asr's.
+ (v9a_asr_reg_names): New variable.
+ Patch from David Miller <davem@vger.rutgers.edu>.
+
+Wed Oct 22 17:18:02 1997 Richard Henderson <rth@cygnus.com>
+
+ * sparc-opc.c (v9notv9a): New insn type.
+ (IMPDEP): Move to the end to not conflict with edge8 et al.
+ Patch from David Miller <davem@vger.rutgers.edu>.
+
+Fri Oct 17 13:18:53 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c (bnezl,beqzl): Mark these as also tx39.
+
+Thu Oct 16 11:55:20 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c: Note that 'jalx' is (probably incorrectly) marked I1.
+
+Tue Oct 14 16:10:31 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (disassemble): Use new symbol_at_address_func() field
+ of disassemble_info structure to determine if an overlay address
+ has a matching symbol in low memory.
+
+ * dis-buf.c (generic_symbol_at_address): New (dummy) function for
+ new symbol_at_address_func field in disassemble_info structure.
+
+Fri Oct 10 16:44:52 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (extract_d22): Use signed arithmatic.
+
+Tue Oct 7 23:40:43 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c: Three op mult is not an ISA insn.
+
+Tue Oct 7 23:37:21 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c: Fix formatting.
+
+Fri Oct 3 17:26:54 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386-dis.c (OP_E): Explicitly sign extend 8 bit values, rather
+ than assuming that char is signed. Explicitly sign extend 16 bit
+ values, rather than assuming that short is 16 bits.
+ (OP_sI, OP_J, OP_DIR): Likewise.
+
+Thu Oct 2 13:36:45 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (v850_sreg_names): Use symbolic names for higher
+ system registers.
+
+Wed Oct 1 16:58:54 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c: Fix typo in comment.
+
+ * v850-dis.c (disassemble): Add test of processor type when
+ determining opcodes.
+
+Wed Oct 1 14:10:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use a diversion to set enable_shared before the
+ arguments are parsed.
+ * configure: Rebuild.
+
+Thu Sep 25 13:04:59 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c (TBL1): Use ! rather than `.
+ * m68k-dis.c (print_insn_arg): Remove ` operand specifier.
+
+Wed Sep 24 11:29:35 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Correct bchg, bclr, bset, and btst on ColdFire.
+
+ * m68k-opc.c: Accept tst{b,w,l} with immediate operands on cpu32.
+
+ * m68k-opc.c: Correct movew of an immediate operand to %sr or %ccr
+ for mcf5200.
+
+ * configure.in: Call AC_CHECK_TOOL before AM_PROG_LIBTOOL.
+ * aclocal.m4: Rebuild with new libtool.
+ * configure: Rebuild.
+
+Fri Sep 19 11:45:49 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * v850-opc.c ("cmov"): Order reg param r1, r2 not r2, r2.
+
+Thu Sep 18 11:21:43 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparclet_cpreg_table): Add %ccsr2, %cccrr, %ccrstr.
+
+Tue Sep 16 15:18:20 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (v850_opcodes): Further rearrangements.
+
+Tue Sep 16 16:12:11 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ * d30v-opc.c (rot2h, sra2h, srl2h insns): Revert last change.
+
+Tue Sep 16 09:48:50 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (v850_opcodes): Fields reordered to allow assembler
+ parser to work.
+
+Tue Sep 16 10:01:00 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c: Added tx39 insns sdbbp, rfe, and deret.
+
+Mon Sep 15 18:31:52 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c: Initialise processors field of v850_opcode structure.
+
+Wed Aug 27 21:42:39 1997 Ken Raeburn <raeburn@cygnus.com>
+
+ Merge changes from Martin Hunt:
+
+ * d30v-opc.c: Change mvfacc to accept 6-bit unsigned values.
+
+ * d30v-opc.c (pre_defined_registers): Add control registers from 0-63.
+ (d30v_opcode_tabel): Add dbt, rtd, srah, and srlh instructions. Fix
+ rot2h, sra2h, and srl2h to use new SHORT_A5S format.
+
+ * d30v-dis.c (print_insn): Fix disassembly of SHORT_D2 opcodes.
+
+ * d30v-dis.c (print_insn): First operand of d*i (delayed
+ branch) instructions is relative.
+
+ * d30v-opc.c (d30v_opcode_table): Change form for repeati.
+ (d30v_operand_table): Add IMM6S3 type.
+ (d30v_format_table): Change SHORT_D2. Add LONG_Db.
+
+ * d30v-dis.c: Fix bug with ".s" and ".l" extensions
+ and cmp instructions.
+
+ * d30v-opc.c: Correct entries for repeat*, and sat*.
+ Make IMM5 unsigned. Create IMM6U and IMM12S3U operand
+ types. Correct several formats.
+
+ * d30v-opc.c: (pre_defined_registers): Add dpsw and dpc.
+
+ * d30v-opc.c (pre_defined_registers): Change control registers.
+
+ * d30v-opc.c (d30v_format_table): Correct SHORT_C1 and
+ SHORT_C2. Manual was incorrect.
+
+ * d30v-dis.c (lookup_opcode): Return value now indicates
+ if an opcode has a short and a long form. Used for deciding
+ to append a ".s" or ".l".
+ (print_insn): Append a ".s" to an instruction if it is
+ the short form and ".l" if it is a long form. Do not append
+ anything if the instruction has only one possible size.
+
+ * d30v-opc.c: Change mulx2h to require an even register.
+ New form: SHORT_A2; a SHORT_A form that needs an even
+ register as the first operand.
+
+ * d30v-dis.c (print_insn_d30v): Fix problem where the last
+ instruction was not being disassembled if there were an odd
+ number of instructions.
+
+ * d30v-opc.c (SHORT_M2, LONG_M2): Two new forms.
+
+Fri Sep 12 11:43:54 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (disassemble): Improved display of register lists.
+
+Thu Sep 11 17:35:10 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Fix assembler args to
+ fzeros, fones, fsrc1, fsrc1s, fsrc2s, fnot1, fnot1s, fnot2s,
+ fors, fnors, fands, fnands, fxors, fxnors, fornot1s, fornot2s,
+ fandnot1s, fandnot2s.
+
+Tue Sep 9 10:03:49 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Fix op3 field for fcmpq/fcmpeq.
+
+Mon Sep 8 14:06:59 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen-asm.c (cgen_parse_address): New argument resultp.
+ All callers updated.
+ * m32r-asm.c (parse_h_hi16): Right shift numbers by 16.
+
+Tue Sep 2 18:39:08 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-dis.c (disassemble): PC relative instructions are
+ relative to the next instruction, not the current instruction.
+
+Tue Sep 2 15:41:55 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (disassemble): Only signed extend values that are not
+ returned by extract functions.
+ Remove use of V850_OPERAND_ADJUST_SHORT_MEMORY flag.
+
+Tue Sep 2 15:39:40 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c: Update comments. Remove use of
+ V850_OPERAND_ADJUST_SHORT_MEMORY. Fix several operand patterns.
+
+Tue Aug 26 09:42:28 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (MOVHI): Immediate parameter is unsigned.
+
+Mon Aug 25 15:58:07 1997 Christopher Provenzano <proven@cygnus.com>
+
+ * configure: Rebuilt with latest devo autoconf for NT support.
+
+Fri Aug 22 10:35:15 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (disassemble): Use curly brace syntax for register
+ lists.
+
+ * v850-opc.c (v850_opcodes[]): Add NOT_R0 flag to decect cases
+ where r0 is being used as a destination register.
+
+Thu Aug 21 11:09:09 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (v850_opcodes[]): Move divh opcodes next to each other.
+
+Tue Aug 19 10:59:59 1997 Richard Henderson <rth@cygnus.com>
+
+ * alpha-opc.c (alpha_opcodes): Fix hw_rei_stall mungage.
+
+Mon Aug 18 11:10:03 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-opc.c (v850_opcodes[]): Remove use of flag field.
+ * v850-opc.c (v850_opcodes[]): Add support for reversed short load
+ opcodes..
+
+Mon Aug 18 11:08:25 1997 Nick Clifton <nickc@cygnus.com>
+
+ * configure (cgen_files): Add support for v850e target.
+ * configure.in (cgen_files): Add support for v850e target.
+
+Mon Aug 18 11:08:25 1997 Nick Clifton <nickc@cygnus.com>
+
+ * configure (cgen_files): Add support for v850ea target.
+ * configure.in (cgen_files): Add support for v850ea target.
+
+Fri Aug 15 05:17:48 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * configure.in (bfd_arc_arch): Add.
+ * configure: Rebuild.
+ * Makefile.am (ALL_MACHINES): Add arc-dis.lo, arc-opc.lo.
+ * Makefile.in: Rebuild.
+ * arc-dis.c, arc-opc.c: New files.
+ * disassemble.c (ARCH_all): Define ARCH_arc.
+ (disassembler): Add ARC support.
+
+Wed Aug 13 18:52:11 1997 Nick Clifton <nickc@cygnus.com>
+
+ * v850-dis.c (disassemble): Add support for v850EA instructions.
+
+ * v850-opc.c (insert_i5div, extract_i5div): New Functions.
+ (v850_opcodes): Add v850EA instructions.
+
+ * v850-dis.c (disassemble): Add support for v850E instructions.
+
+ * v850-opc.c (insert_d5_4, extract_d5_4, insert_d16_16,
+ extract_d16_16, insert_i9, extract_i9, insert_u9, extract_u9,
+ insert_spe, extract_spe): New Functions.
+ (v850_opcodes): Add v850E instructions.
+
+ * v850-opc.c: Reorganised and re-layed out to improve readability
+ and portability.
+
+Tue Aug 5 23:09:31 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Rebuild with autoconf 2.12.1.
+
+Mon Aug 4 12:02:16 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * aclocal.m4, configure: Rebuild with new automake patches.
+
+Fri Aug 1 13:02:04 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set enable_shared before AM_PROG_LIBTOOL.
+ * acinclude.m4: Just include acinclude.m4 from BFD.
+ * aclocal.m4, configure: Rebuild.
+
+Thu Jul 31 21:44:42 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.am: New file, based on old Makefile.in.
+ * acconfig.h: New file.
+ * acinclude.m4: New file.
+ * stamp-h.in: New file.
+ * configure.in: Call AM_INIT_AUTOMAKE and AM_PROG_LIBTOOL.
+ Removed shared library handling; now handled by libtool. Replace
+ AC_CONFIG_HEADER with AM_CONFIG_HEADER. Call AM_MAINTAINER_MODE,
+ AM_CYGWIN32, and AM_EXEEXT. Replace AC_PROG_INSTALL with
+ AM_PROG_INSTALL. Change all .o files to .lo. Remove stamp-h
+ handling in AC_OUTPUT.
+ * dep-in.sed: Change .o to .lo.
+ * Makefile.in: Now built with automake.
+ * aclocal.m4: Now built with aclocal.
+ * config.in, configure: Rebuild.
+
+Mon Jul 28 21:52:24 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mips-opc.c: Fix typo/thinko in "eret" instruction.
+
+Thu Jul 24 13:03:26 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Fix spelling on fpaddX, fpsubX insns.
+ Make array const.
+ * sparc-dis.c (sorted_opcodes): New static local.
+ (struct opcode_hash): `opcode' is pointer to const element.
+ (build_hash): First arg is now table of sorted pointers.
+ (print_insn_sparc): Sort opcodes by sorting table of pointers.
+ (compare_opcodes): Update.
+
+Tue Jul 15 12:05:23 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen-opc.c: #include <ctype.h>.
+ (hash_keyword_name): New arg `case_sensitive_p'. Callers updated.
+ Handle case insensitive hashing.
+ (hash_keyword_value): Change type of `value' to unsigned int.
+
+Thu Jul 10 12:56:10 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mips-opc.c (mips_builtin_opcodes): If an insn uses single
+ precision FP, mark it as such. Likewise for double precision
+ FP. Mark ISA1 insns. Consolidate duplicate opcodes where
+ possible.
+
+Wed Jun 25 15:25:57 1997 Felix Lee <flee@cirdan.cygnus.com>
+
+ * ppc-opc.c (extract_nsi): make unsigned expression signed before
+ negating it.
+ (UNUSED): remove one level of parens, so MSVC doesn't choke on
+ nesting depth when all the macros are expanded.
+
+Tue Jun 17 17:02:17 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc-opc.c: The fcmp v9a instructions take an integer register
+ as a destination, not a floating point register. From Christian
+ Kuehnke <Christian.Kuehnke@arbi.Informatik.Uni-Oldenburg.DE>.
+
+Mon Jun 16 14:13:18 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-dis.c (print_insn_arg): Print case 7.2 using %pc@()
+ syntax. From Roman Hodek
+ <rnhodek@faui22c.informatik.uni-erlangen.de>.
+
+ * i386-dis.c (twobyte_has_modrm): Fix pand.
+
+Mon Jun 16 14:08:38 1997 Michael Taylor <mbt@mit.edu>
+
+ * i386-dis.c (dis386_twobyte): Fix pand and pandn.
+
+Tue Jun 10 11:26:47 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
+
+ * arm-dis.c: Add prototypes for arm_decode_shift and
+ print_insn_arm.
+
+Mon Jun 2 11:39:04 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c: Add r3900 insns.
+
+Tue May 27 15:55:44 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sh-dis.c (print_insn_shx): Change relmask to bfd_vma. Don't
+ print delay slot instructions on the same line. When using a PC
+ relative load, add a comment with the value being loaded if it can
+ be obtained.
+
+Tue May 27 11:02:08 1997 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c (dis386[], dis386_twobyte[]): change pushl/popl
+ to pushS/popS for segment regs and byte constant so that
+ pushw/popw printed when in 16 bit data mode.
+
+ * i386-dis.c (dis386[]): change cwtl, cltd to cWtS, cStd to
+ print cbtw, cwtd in 16 bit data mode.
+ * i386-dis.c (putop): extra case W to support above.
+
+ * i386-dis.c (print_insn_x86): print addr32 prefix when given
+ address size prefix in 16 bit address mode.
+
+Fri May 23 16:47:23 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sh-dis.c: Reindent. Rename local variable fprintf to
+ fprintf_fn.
+
+Thu May 22 14:06:02 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * m32r-opc.c (m32r_cgen_insn_table, cmpui): Undo patch of May 2.
+
+Tue May 20 11:26:27 1997 Gavin Koch <gavin@cygnus.com>
+
+ * mips-opc.c (mips_builtin_opcodes): Moved INSN_ISA field into new
+ field membership.
+ * mips16-opc.c (mip16_opcodes): same.
+
+Mon May 12 15:10:53 1997 Jim Wilson <wilson@cygnus.com>
+
+ * m68k-opc.c (moveb): Change $d to %d.
+
+Mon May 5 14:28:41 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386-dis.c: (dis386_twobyte): Add MMX instructions.
+ (twobyte_has_modrm): Likewise.
+ (grps): Likewise.
+ (OP_MMX, OP_EM, OP_MS): New static functions.
+
+ * i386-dis.c: Revert patch of April 4. The output now matches
+ what gcc generates.
+
+Fri May 2 12:48:37 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * m32r-opc.c (m32r_cgen_insn_table, cmpui): Use $uimm16 instead
+ of $simm16.
+
+Thu May 1 15:34:15 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * m32r-opc.h (CGEN_ARCH): Renamed from CGEN_CPU.
+
+Tue Apr 15 12:40:08 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (install): Depend upon installdirs.
+ (installdirs): New target.
+
+Mon Apr 14 12:13:51 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ From Thomas Graichen <graichen@rzpd.de>:
+ * configure.in: Use ${CONFIG_SHELL} when running $ac_config_sub.
+ * configure: Rebuild.
+
+Sun Apr 13 17:50:41 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen-*.c, m32r-*.c: #include sysdep.h instead of config.h.
+ Delete string{,s}.h support.
+
+Thu Apr 10 14:44:56 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen-asm.c (cgen_parse_operand_fn): New global.
+ (cgen_parse_{{,un}signed_integer,address}): Update call to
+ cgen_parse_operand_fn.
+ (cgen_init_parse_operand): New function.
+ * m32r-asm.c (parse_insn_normal): cgen_init_parse_operand renamed
+ from cgen_asm_init_parse.
+ (m32r_cgen_assemble_insn): New operand `errmsg'.
+ Delete call to as_bad, return error message to caller.
+ (m32r_cgen_asm_hash_keywords): #if 0 out.
+
+Wed Apr 9 12:05:25 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-dis.c (print_insn_arg) [case 'd']: Print as address register,
+ not data register.
+ [case 'J']: Fix typo in register name.
+
+Mon Apr 7 16:48:22 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Substitute SHLIB_LIBS.
+ * configure: Rebuild.
+ * Makefile.in (SHLIB_LIBS): New variable.
+ ($(SHLIB)): Use $(SHLIB_LIBS).
+
+Mon Apr 7 11:45:44 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * cgen-dis.c (build_dis_hash_table): Fix xmalloc size computation.
+
+ * cgen-opc.c (hash_keyword_name): Improve algorithm.
+
+ * disassemble.c (disassembler): Handle m32r.
+
+Fri Apr 4 12:29:38 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * m32r-asm.c, m32r-dis.c, m32r-opc.c, m32r-opc.h: New files.
+ * cgen-asm.c, cgen-dis.c, cgen-opc.c: New files.
+ * Makefile.in (CFILES): Add them.
+ (ALL_MACHINES): Add them.
+ (dependencies): Regenerate.
+ * configure.in (cgen_files): New variable.
+ (bfd_m32r_arch): Add entry.
+ * configure: Regenerate.
+
+Fri Apr 4 14:04:16 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Correct file names for bfd_mn10[23]00_arch.
+ * configure: Rebuild.
+
+ * Makefile.in: Rebuild dependencies.
+
+ * d10v-dis.c: Include "ansidecl.h" before "opcode/d10v.h".
+
+ * i386-dis.c (float_reg): Swap fsubrp and fsubp. Swap fdivrp and
+ fdivp.
+
+Thu Apr 3 13:22:45 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Branched binutils 2.8.
+
+Wed Apr 2 12:23:53 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m10200-dis.c: Rename from mn10200-dis.c.
+ * m10200-opc.c: Rename from mn10200-opc.c.
+ * m10300-dis.c: Rename from mn10300-dis.c
+ * m10300-opc.c: Rename from mn10300-opc.c.
+ * Makefile.in: Update accordingly.
+
+ * mips16-opc.c: Add mul and dmul macros.
+
+Tue Apr 1 16:27:45 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Update CFLAGS, add clean target.
+
+Fri Mar 28 12:10:09 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Add "wait". From Ralf Baechle
+ <ralf@gnu.ai.mit.edu>.
+
+ * configure.in: Add stdlib.h to AC_CHECK_HEADERS list.
+ * configure, config.in: Rebuild.
+ * sysdep.h: Include <stdlib.h> if it exists.
+ * sparc-dis.c: Include <stdio.h> and "sysdep.h". Don't include
+ <string.h>.
+ * Makefile.in: Rebuild dependencies.
+
+Thu Mar 27 14:24:43 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ppc-opc.c: Add PPC 403 instructions and extended opcodes. From
+ Andrew Bray <andy@madhouse.demon.co.uk>.
+
+ * mips-opc.c: Add cast when setting mips_opcodes.
+
+Tue Mar 25 23:04:00 1997 Stu Grossman (grossman@critters.cygnus.com)
+
+ * v850-dis.c (disassemble): Fix sign extension problem.
+ * v850-opc.c (extract_d*): Fix sign extension problems to make
+ disassembly calculate branch offsets correctly.
+
+Mon Mar 24 13:22:13 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sh-opc.h: Add bf/s and bt/s as synonyms for bf.s and bt.s.
+
+ * mips-opc.c: Add dctr and dctw.
+
+Sun Mar 23 18:08:10 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d30v-dis.c (print_insn): Change the way signed constants
+ are displayed.
+
+Fri Mar 21 14:37:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (BFD_H): New variable.
+ (HFILES): New variable.
+ (CFILES): Add all C files.
+ (.dep, .dep1, dep.sed, dep, dep-in): New targets.
+ Delete old dependencies, and build new ones.
+ * dep-in.sed: New file.
+
+Thu Mar 20 19:03:30 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * m68k-opc.c (m68k_opcode_aliases): Added blo and blo{s,b,w,l}.
+
+Tue Mar 18 14:17:03 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c: Change "trap" to "syscall".
+ * mn10300-opc.c: Add new "syscall" instruction.
+
+Mon Mar 17 08:48:03 1997 J.T. Conklin <jtc@beauty.cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Provide correct entries for mulsl and
+ mulul insns on the coldfire.
+
+Sat Mar 15 17:13:05 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * arm-dis.c (print_insn_arm): Don't print instruction bytes.
+ (print_insn_big_arm): Set bytes_per_chunk and display_endian.
+ (print_insn_little_arm): Likewise.
+
+Fri Mar 14 15:08:59 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ Based on patches from H.J. Lu <hjl@lucon.org>:
+ * i386-dis.c (fetch_data): Add prototype.
+ * m68k-dis.c (fetch_data): Add prototype.
+ (dummy_print_address): Add prototype. Make static.
+ * ppc-opc.c (valid_bo): Add prototype.
+ * sparc-dis.c (build_hash_table): Add prototype.
+ (is_delayed_branch, compute_arch_mask): Add prototypes.
+ (print_insn_sparc): Make several local variables const.
+ (compare_opcodes): Change arguments to const PTR. Add prototype.
+ * sparc-opc.c (arg): Change name field to be const.
+ (lookup_name, lookup_value): Add prototypes. Change table and
+ name parameters to be const.
+ (sparc_encode_asi): Change name parameter to be const.
+ (sparc_encode_membar, sparc_encode_prefetch): Likewise.
+ (sparc_encode_sparclet_cpreg): Likewise.
+ (sparc_decode_asi): Change return type to be const.
+ (sparc_decode_membar, sparc_decode_prefetch): Likewise.
+ (sparc_decode_sparclet_cpreg): Likewise.
+
+Fri Mar 7 10:51:49 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in ($(SHLINK)): Just use ln -s, not ln -sf, since
+ Solaris doesn't like the combined options, and the -f is
+ unnecessary.
+ (stamp-tshlink, install): Likewise.
+
+Thu Mar 6 16:51:11 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (IMM16_PCREL, SD8N_PCREL, D16_SHIFT): Mark these
+ as relaxable.
+
+Tue Mar 4 06:10:36 1997 J.T. Conklin <jtc@cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Fix last change for the mc68010.
+
+Mon Mar 3 07:45:20 1997 J.T. Conklin <jtc@cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Added entries for the tst insns on
+ the mc68000.
+
+Thu Feb 27 14:04:32 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * m68k-opc.c (m68k_opcodes): Added swbegl pseudo-instruction.
+
+Thu Feb 27 11:36:41 1997 Michael Meissner <meissner@cygnus.com>
+
+ * tic80-dis.c (print_insn_tic80): Set info->bytes_per_line to 8.
+
+Wed Feb 26 15:34:48 1997 Michael Meissner <meissner@cygnus.com>
+
+ * tic80-opc.c (tic80_predefined_symbols): Define r25 properly.
+
+Wed Feb 26 13:38:30 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-dis.c (NEXTSINGLE, NEXTDOUBLE, NEXTEXTEND): Use
+ floatformat_to_double to make portable.
+ (print_insn_arg): Use NEXTEXTEND macro when extracting extended
+ precision float.
+
+Mon Feb 24 19:26:12 1997 Dawn Perchik <dawn@cygnus.com>
+
+ * mips-opc.c: Initialize mips_opcodes to mips_builtin_opcodes,
+ and bfd_mips_num_opcodes to bfd_mips_num_builtin_opcodes.
+
+Mon Feb 24 15:19:01 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-dis.c, d10v-opc.c: Change pre_defined_registers to
+ d10v_predefined_registers and reg_name_cnt to d10v_reg_name_cnt.
+
+Mon Feb 24 14:33:26 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (LSI_SCALED): Renamed from this ...
+ (OFF_SL_BR_SCALED): ... to this, and added the flag
+ TIC80_OPERAND_BASEREL to the flags word.
+ (tic80_opcodes): Replace all occurances of LSI_SCALED with
+ OFF_SL_BR_SCALED.
+
+Sat Feb 22 21:25:00 1997 Dawn Perchik <dawn@cygnus.com>
+
+ * mips-opc.c: Add macros for cop0, cop1 cop2 and cop3.
+ Change mips_opcodes from const array to a pointer,
+ and change bfd_mips_num_opcodes from const int to int,
+ so that we can increase the size of the mips opcodes table
+ dynamically.
+
+Sat Feb 22 21:03:47 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_predefined_symbols): Revert change to
+ store BITNUM values in the table in one's complement form
+ to match behavior when assembler is given a raw numeric
+ value for a BITNUM operand.
+ * tic80-dis.c (print_operand_bitnum): Ditto.
+
+Fri Feb 21 16:31:18 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d30v-opc.c: Removed references to FLAG_X.
+
+Wed Feb 19 14:51:20 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in: Add dependencies on ../bfd/bfd.h as required.
+
+Tue Feb 18 17:43:43 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * Makefile.in: Added d30v object files.
+ * configure: (bfd_d30v_arch) Rebuilt.
+ * configure.in: (bfd_d30v_arch) Added new case.
+ * d30v-dis.c: New file.
+ * d30v-opc.c: New file.
+ * disassemble.c (disassembler) Add entry for d30v.
+
+Tue Feb 18 16:32:08 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_predefined_symbols): Add symbolic
+ representations for the floating point BITNUM values.
+
+Fri Feb 14 12:14:05 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_predefined_symbols): Store BITNUM values
+ in the table in one's complement form, as they appear in the
+ actual instruction.
+ (tic80_symbol_to_value): Use macros to access predefined
+ symbol fields.
+ (tic80_value_to_symbol): Ditto.
+ (tic80_next_predefined_symbol): New function.
+ * tic80-dis.c (print_operand_bitnum): Remove code that did
+ one's complement for BITNUM values.
+
+Thu Feb 13 21:56:51 1997 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Remove 8 bit characters. Update to latest
+ gcc release.
+
+Thu Feb 13 20:41:22 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * m68k-opc.c (m68k_opcodes): Add swbeg pseudo-instruction.
+
+Thu Feb 13 16:30:02 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c (IMM16_PCREL): This is a signed operand.
+ (IMM24_PCREL): Likewise.
+
+Thu Feb 13 13:28:43 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_mips16_insn_arg): Use memaddr - 2 as the base
+ address for an extended PC relative instruction that is not a
+ branch.
+
+Wed Feb 12 12:27:40 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-dis.c (print_insn_m68k): Set bytes_per_chunk and
+ bytes_per_line.
+
+Tue Feb 11 16:36:31 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_operands): Fix typo '+' -> '|'.
+ (tic80_opcodes): Sort entries so that long immediate forms
+ come after short immediate forms, making it easier for
+ assembler to select the right one for a given operand.
+
+Tue Feb 11 15:26:47 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (_print_insn_mips): Set bytes_per_chunk and
+ display_endian.
+ (print_insn_mips16): Likewise.
+
+Mon Feb 10 10:12:41 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_symbol_to_value): Changed to accept
+ a symbol class that restricts translation to just that
+ class (general register, condition code, etc).
+
+Thu Feb 6 17:34:09 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_operands): Add REG_0_E, REG_22_E,
+ and REG_DEST_E for register operands that have to be
+ an even numbered register. Add REG_FPA for operands that
+ are one of the floating point accumulator registers.
+ Add TIC80_OPERAND_MASK to flags for ENDMASK operand.
+ (tic80_opcodes): Change entries that need even numbered
+ register operands to use the new operand table entries.
+ Add "or" entries that are identical to "or.tt" entries.
+
+Wed Feb 5 11:12:44 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips16-opc.c: Add new cases of exit instruction for
+ disassembler.
+ * mips-dis.c (print_mips16_insn_arg): Display floating point
+ registers in operands of exit instruction. Print `$' before
+ register names in operands of entry and exit instructions.
+
+Thu Jan 30 14:09:03 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_predefined_symbols): Table of name/value
+ pairs for all predefined symbols recognized by the assembler.
+ Also used by the disassembling routines.
+ (tic80_symbol_to_value): New function.
+ (tic80_value_to_symbol): New function.
+ * tic80-dis.c (print_operand_control_register,
+ print_operand_condition_code, print_operand_bitnum):
+ Remove private tables and use tic80_value_to_symbol function.
+
+Thu Jan 30 11:30:45 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-dis.c (print_operand): Change address printing
+ to correctly handle PC wrapping. Fixes PR11490.
+
+Wed Jan 29 09:39:17 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c (mn10200_operands): Make 8 and 16 bit pc-relative
+ branches relaxable.
+
+Tue Jan 28 15:57:34 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_insn_mips16): Set insn_info information.
+ (print_mips16_insn_arg): Likewise.
+
+ * mips-dis.c (print_insn_mips16): Better handling of an extend
+ opcode followed by an instruction which can not be extended.
+
+Fri Jan 24 12:08:21 1997 J.T. Conklin <jtc@cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Changed operand specifier for the
+ coldfire moveb instruction to not allow an address register as
+ destination. Although the documentation does not indicate that
+ this is invalid, experiments uncovered unexpected behavior.
+ Added a comment explaining the situation. Thanks to Andreas
+ Schwab for pointing this out to me.
+
+Wed Jan 22 20:13:51 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_opcodes): Expand comment to note that the
+ entries are presorted so that entries with the same mnemonic are
+ adjacent to each other in the table. Sort the entries for each
+ instruction so that this is true.
+
+Mon Jan 20 12:48:57 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-dis.c: Include <libiberty.h>.
+ (print_insn_m68k): Sort the opcode table on the most significant
+ nibble of the opcode.
+
+Sat Jan 18 15:15:05 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-dis.c (tic80_opcodes): Add "wrcr", "vmpy", "vrnd",
+ "vsub", "vst", "xnor", and "xor" instructions.
+ (V_a1): Renamed from V_a, msb of accumulator reg number.
+ (V_a0): Add macro, lsb of accumulator reg number.
+
+Fri Jan 17 18:24:31 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-dis.c (print_insn_tic80): Broke excessively long
+ function up into several smaller ones and arranged for
+ the instruction printing function to be callable recursively
+ to print vector instructions that have both a load and a
+ math instruction packed into a single opcode.
+ * tic80-opc.c (tic80_opcodes): Expand comment for vld opcode
+ to explain why it comes after the other vector opcodes.
+
+Fri Jan 17 16:19:15 1997 J.T. Conklin <jtc@beauty.cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): add b, w, or l specifier to coldfire
+ move insns to handle immediate operands.
+
+Thu Jan 17 16:19:00 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-opc.c (m68k_opcodes): Delete duplicate entry for "cmpil".
+ fix operand mask in the "moveml" entries for the coldfire.
+
+Thu Jan 16 20:54:40 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (V_a, V_m, V_S, V_Z, V_p, OP_V, MASK_V):
+ New macros for building vector instruction opcodes.
+ (tic80_opcodes): Remove all uses of FMT_SI, FMT_REG, and
+ FMT_LI, which were unused. The field is now a flags field.
+ Remove some opcodes that are possible, but illegal, such
+ as long immediate instructions with doubles for immediate
+ values. Add "vadd" and "vld" instructions.
+
+Wed Jan 15 18:59:51 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (tic80_operands): Reorder some table entries to make
+ the order more logical. Move the shift alias instructions ("rotl",
+ "shl", "ins", "rotr", "extu", "exts", "srl", and "sra" to be
+ interspersed with the regular sr.x and sl.x instructions. Add
+ and test new instruction opcodes for "sl", "sli", "sr", "sri", "st",
+ "sub", "subu", "swcr", and "trap".
+
+Tue Jan 14 19:42:50 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-opc.c (OFF_SS_PC): Renamed from OFF_SS.
+ (OFF_SL_PC): Renamed from OFF_SL.
+ (OFF_SS_BR): New operand type for base relative operand.
+ (OFF_SL_BR): New operand type for base relative operand.
+ (REG_BASE): New operand type for base register operand.
+ (tic80_opcodes): Add and test "fmpy", "frndm", "frndn", "frndp",
+ "frndz", "fsqrt", "fsub", "illop0", "illopF", "ins", "jsr",
+ "ld", "ld.u", "lmo", "or", "rdcr", "rmo", "rotl", and "rotr"
+ instructions.
+ * tic80-dis.c (print_insn_tic80): Print opcode name with fixed width
+ 10 char field, padded with spaces on rhs, rather than a string
+ followed by a tab. Use renamed TIC80_OPERAND_PCREL flag bit rather
+ than old TIC80_OPERAND_RELATIVE. Add support for new
+ TIC80_OPERAND_BASEREL flag bit.
+
+Mon Jan 13 15:58:56 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-dis.c (print_insn_tic80): Print floating point operands
+ as floats.
+ * tic80-opc.c (SPFI): Add single precision floating point
+ immediate operand type.
+ (ROTATE): Add rotate operand type for shifts.
+ (ENDMASK): Add for shifts.
+ (n): Macro for the 'n' bit.
+ (i): Macro for the 'i' bit.
+ (PD): Macro for the 'PD' field.
+ (P2): Macro for the 'P2' field.
+ (P1): Macro for the 'P1' field.
+ (tic80_opcodes): Add entries for "exts", "extu", "fadd",
+ "fcmp", and "fdiv".
+
+Mon Jan 6 15:06:55 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-dis.c (disassemble): Mask off unwanted bits after
+ adding in current address for pc-relative operands.
+
+Mon Jan 6 10:56:25 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-dis.c (R_SCALED): Add macro to test for ":s" modifier bit.
+ (print_insn_tic80): If R_SCALED then print ":s" modifier for operand.
+ * tic80-opc.c (REG0, REG22, REG27, SSOFF, LSOFF): Names
+ changed to REG_0, REG_22, REG_DEST, OFF_SS, OFF_SL respectively.
+ (SICR, LICR, REGM_SI, REGM_LI): Names changed to CR_SI, CR_LI,
+ REG_BASE_M_SI, REG_BASE_M_LI respectively.
+ (REG_SCALED, LSI_SCALED): New operand types.
+ (E): New macro for 'E' bit at bit 27.
+ (tic80_opcodes): Add and test dld, dld.u, dst, estop, and etrap
+ opcodes, including the various size flavors (b,h,w,d) for
+ the direct load and store instructions.
+
+Sun Jan 5 12:18:14 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-dis.c (M_SI, M_LI): Add macros to test for ":m" modifier bit
+ in an instruction.
+ * tic80-dis.c (print_insn_tic80): Change comma and paren handling.
+ Use M_SI and M_LI macros to check for ":m" modifier for GPR operands.
+ * tic80-opc.c (tic80_operands): Add REGM_SI and REGM_LI operands.
+ (F, M_REG, M_LI, M_SI, SZ_REG, SZ_LI, SZ_SI, D, S): New bit-twiddlers.
+ (MASK_LI_M, MASK_SI_M, MASK_REG_M): Remove and replace in opcode
+ masks with "MASK_* & ~M_*" to get the M bit reset.
+ (tic80_opcodes): Add bsr, bsr.a, cmnd, cmp, dcachec, and dcachef.
+
+Sat Jan 4 19:05:05 1997 Fred Fish <fnf@cygnus.com>
+
+ * tic80-dis.c (print_insn_tic80): Print TIC80_OPERAND_RELATIVE
+ correctly. Add support for printing TIC80_OPERAND_BITNUM and
+ TIC80_OPERAND_CC, and TIC80_OPERAND_CR operands in symbolic
+ form.
+ * tic80-opc.c (tic80_operands): Add SSOFF, LSOFF, BITNUM,
+ CC, SICR, and LICR table entries.
+ (tic80_opcodes): Add and test "nop", "br", "bbo", "bbz",
+ "bcnd", and "brcr" opcodes.
+
+Fri Jan 3 18:32:11 1997 Fred Fish <fnf@cygnus.com>
+
+ * ppc-opc.c (powerpc_operands): Make comment match the
+ actual fields (no shift field).
+ * sparc-opc.c (sparc_opcodes): Document why this cannot be "const".
+ * tic80-dis.c (print_insn_tic80): Replace abort stub with a
+ partial implementation, work in progress.
+ * tic80-opc.c (tic80_operands): Begin construction operands table.
+ (tic80_opcodes): Continue populating opcodes table and start
+ filling in the operand indices.
+ (tic80_num_opcodes): Add this.
+
+Fri Jan 3 12:13:52 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Add #B case for moveq.
+
+Thu Jan 2 12:14:29 1997 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-dis.c (disassemble): Make sure all variables are initialized
+ before they are used.
+
+Tue Dec 31 12:20:38 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_opcodes): Put curly-braces around operands
+ for "breakpoint" instruction.
+
+Tue Dec 31 15:38:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (ALL_CFLAGS): Add -D_GNU_SOURCE.
+ (dep): Use ALL_CFLAGS rather than CFLAGS.
+
+Tue Dec 31 15:09:16 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * v850-opc.c (D8_{6,7}): Set V850_OPERAND_ADJUST_SHORT_MEMORY
+ flag.
+
+Mon Dec 30 17:02:11 1996 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (m68k-opc.o, alpha-opc.o): Remove dis-asm.h dependency.
+ (tic80-dis.o, tic80-opc.o): Add rules per comment in Makefile.in.
+
+Mon Dec 30 11:38:01 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips16-opc.c: Add "abs".
+
+Sun Dec 29 10:58:22 1996 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (ALL_MACHINES): Add tic80-dis.o and tic80-opc.o.
+ * disassemble.c (ARCH_tic80): Define if ARCH_all is defined.
+ (disassembler): Add bfd_arch_tic80 support to set disassemble
+ to print_insn_tic80.
+ * tic80-dis.c (print_insn_tic80): Add stub.
+
+Fri Dec 27 22:30:57 1996 Fred Fish <fnf@cygnus.com>
+
+ * configure.in (arch in $selarchs): Add bfd_tic80_arch entry.
+ * configure: Regenerate with autoconf.
+ * tic80-dis.c: Add file.
+ * tic80-opc.c: Add file.
+
+Fri Dec 20 14:30:19 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (pre_defined_registers): Add cr[0-15], dpc, dpsw, link.
+
+Mon Dec 16 13:00:15 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c (mn10200_operands): Add SIMM16N.
+ (mn10200_opcodes): Use it for some logicals and btst insns.
+ Add "break" and "trap" instructions.
+
+ * mn10300-opc.c (mn10300_opcodes): Add "break" instruction.
+
+ * mn10200-opc.c: Add pseudo-ops for "mov (an),am" and "mov an,(am)".
+
+Sat Dec 14 22:36:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_mips16_insn_arg): The base address of a PC
+ relative load or add now depends upon whether the instruction is
+ in a delay slot.
+
+Wed Dec 11 09:23:46 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-dis.c: Finish writing disassembler.
+ * mn10200-opc.c (mn10200_opcodes): Fix mask for "mov imm8,dn".
+ Fix mask for "jmp (an)".
+
+ * mn10300-dis.c (disassemble, print_insn_mn10300): Corrently
+ handle endianness issues for mn10300.
+
+ * mn10200-opc.c (mn10200_opcodes): Fix operands for "movb dm,(an)".
+
+Tue Dec 10 12:08:05 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c (mn10200_opcodes): "mov imm8,d0" is a format 2
+ instruction. Fix opcode field for "movb (imm24),dn".
+
+ * mn10200-opc.c (mn10200_operands): Fix insertion position
+ for DI operand.
+
+Mon Dec 9 16:42:43 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c: Create mn10200 opcode table.
+ * mn10200-dis.c: Flesh out mn10200 disassembler. Not ready,
+ but moving along nicely.
+
+Sun Dec 8 04:28:31 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * Makefile.in (ALL_MACHINES): Add mips16-opc.o.
+
+Fri Dec 6 16:47:40 1996 J.T. Conklin <jtc@rhino.cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Revert change to use < and >
+ specifiers for fmovem* instructions.
+
+Fri Dec 6 14:48:09 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-dis.c (disassemble): Remove '$' register prefixing.
+
+Fri Dec 6 17:34:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips16-opc.c: Change opcode for entry/exit to avoid conflicting
+ with dsrl.
+
+Fri Dec 6 14:48:09 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c: Add some comments explaining the various
+ operands and such.
+
+ * mn10300-dis.c (disassemble): Fix minor gcc -Wall warnings.
+
+Thu Dec 5 12:09:48 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * m68k-dis.c (print_insn_arg): Handle new < and > operand
+ specifiers.
+
+ * m68k-opc.c (m68k_opcodes): Simplify table by using < and >
+ operand specifiers in fmovm* instructions.
+
+Wed Dec 4 14:52:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ppc-opc.c (insert_li): Give an error if the offset has the two
+ least significant bits set.
+
+Wed Nov 27 13:09:01 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_insn_mips16): Separate the instruction from
+ the arguments with a tab, not a space.
+
+Tue Nov 26 13:24:17 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-dis.c (disasemble): Finish conversion to '$' as
+ register prefix.
+
+ * mn10300-opc.c (mn10300_opcodes): Fix mask field for
+ mov am,(imm32,sp).
+
+Tue Nov 26 10:53:21 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Rebuild with autoconf 2.12.
+
+ Add support for mips16 (16 bit MIPS implementation):
+ * mips16-opc.c: New file.
+ * mips-dis.c: Include "elf-bfd.h" and "elf/mips.h".
+ (mips16_reg_names): New static array.
+ (print_insn_big_mips): Use print_insn_mips16 in 16 bit mode or
+ after seeing a 16 bit symbol.
+ (print_insn_little_mips): Likewise.
+ (print_insn_mips16): New static function.
+ (print_mips16_insn_arg): New static function.
+ * mips-opc.c: Add jalx instruction.
+ * Makefile.in (mips16-opc.o): New target.
+ * configure.in: Use mips16-opc.o for bfd_mips_arch.
+ * configure: Rebuild.
+
+Mon Nov 25 16:15:17 1996 J.T. Conklin <jtc@cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Simplify table by using < and >
+ operand specifiers in *save, *restore and movem* instructions.
+
+ * m68k-opc.c (m68k_opcodes): Fix move and movem instructions for
+ the coldfire.
+
+ * m68k-opc.c (m68k_opcodes): The coldfire (mcf5200) can only use
+ register operands for immediate arithmetic, not, neg, negx, and
+ set according to condition instructions.
+
+ * m68k-opc.c (m68k_opcodes): Consistantly Use "s" as the storage
+ specifier of the effective-address operand in immediate forms of
+ arithmetic instructions. The specifier for the immediate operand
+ notes how and where the constant will be stored.
+
+Mon Nov 25 11:17:01 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_opcodes): Remove redundant "lcc"
+ opcode.
+
+ * mn10300-dis.c (disassemble): Use '$' instead of '%' for
+ register prefix.
+
+ * mn10300-dis.c (disassemble): Prefix registers with '%'.
+
+Wed Nov 20 10:37:13 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-dis.c (disassemble): Handle register lists.
+
+ * mn10300-opc.c: Fix handling of register list operand for
+ "call", "ret", and "rets" instructions.
+
+ * mn10300-dis.c (disassemble): Print PC-relative and memory
+ addresses symbolically if possible.
+ * mn10300-opc.c: Distinguish between absolute memory addresses,
+ pc-relative offsets & random immediates.
+
+ * mn10300-dis.c (print_insn_mn10300): Fix fetch of last byte
+ in 7 byte insns.
+ (disassemble): Handle SPLIT and EXTENDED operands.
+
+Tue Nov 19 13:33:01 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-dis.c: Rough cut at printing some operands.
+
+ * mn10300-dis.c: Start working on disassembler support.
+ * mn10300-opc.c (mn10300_opcodes): Fix masks on several insns.
+
+ * mn10300-opc.c (mn10300_operands): Add "REGS" for a register
+ list.
+ (mn10300_opcodes): Use REGS for register list in "movm" instructions.
+
+Mon Nov 18 15:20:35 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * d10v-opc.c (d10v_opcodes): Add3 sets the carry.
+
+Fri Nov 15 13:43:19 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_opcodes): Demand parens around
+ register argument is calls and jmp instructions.
+
+Thu Nov 7 00:26:05 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_opcodes): Use DN01 for putx and
+ getx operand. Fix opcode for mulqu imm,dn.
+
+Wed Nov 6 13:42:32 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_operands): Hijack "bits" field
+ in MN10300_OPERAND_SPLIT operands for how many bits
+ appear in the basic insn word. Add IMM32_HIGH24,
+ IMM32_HIGH24_LOWSHIFT8, IMM8E_SHIFT8.
+ (mn10300_opcodes): Use new operands as needed.
+
+ * mn10300-opc.c (mn10300_operands): Add IMM32_LOWSHIFT8
+ for bset, bclr, btst instructions.
+ (mn10300_opcodes): Use new IMM32_LOWSHIFT8 as needed.
+
+ * mn10300-opc.c (mn10300_operands): Remove many redundant
+ operands. Update opcode table as appropriate.
+ (IMM32): Add MN10300_OPERAND_SPLIT flag.
+ (mn10300_opcodes): Fix single bit error in mov imm32,dn insn.
+
+Tue Nov 5 13:26:58 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_operands): Add DN2, DM2, AN2, AM2
+ operands (for indexed load/stores). Fix bitpos for DI
+ operand. Add SN8N_SHIFT8, IMM8_SHIFT8, and D16_SHIFT for the
+ few instructions that insert immediates/displacements in the
+ middle of the instruction. Add IMM8E for 8 bit immediate in
+ the extended part of an instruction.
+ (mn10300_operands): Use new opcodes as appropriate.
+
+Tue Nov 5 10:30:51 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (d10v_opcodes): Declare the trap instruction
+ sequential so the assembler never parallelizes it with
+ other instructions.
+
+Mon Nov 4 12:50:40 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_operands): Add DN01 and AN01 for
+ a data/address register that appears in register field 0
+ and register field 1.
+ (mn10300_opcodes): Use DN01 and AN01 for mov/cmp imm8,DN/AN
+
+Fri Nov 1 10:29:11 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha-dis.c (print_insn_alpha): Use new NOPAL mask for
+ standard disassembly.
+
+ * alpha-opc.c (alpha_operands): Rearrange flags slot.
+ (alpha_opcodes): Add new BWX, CIX, and MAX instructions.
+ Recategorize PALcode instructions.
+
+Wed Oct 30 16:46:58 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_opcodes): Add relaxing "jbr".
+
+Tue Oct 29 16:30:28 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (_print_insn_mips): Don't print a trailing tab if
+ there are no operand types.
+
+Tue Oct 29 12:22:21 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (D9_RELAX): Renamed from D9, all references
+ changed.
+ (v850_operands): Make sure D22 immediately follows D9_RELAX.
+
+Fri Oct 25 12:12:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386-dis.c (print_insn_x86): Set info->bytes_per_line to 5.
+
+Thu Oct 24 17:53:52 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (insert_d8_6): Fix operand insertion for sld.w
+ and sst.w instructions.
+
+ * v850-opc.c (v850_opcodes): Add "jCC" instructions (aliases for
+ "bCC"instructions).
+
+Thu Oct 24 17:21:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (_print_insn_mips): Use a tab between the instruction
+ and the arguments.
+
+Tue Oct 22 23:32:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ppc-opc.c (PPCPWR2): Define.
+ (powerpc_opcodes): Use PPCPWR2 for fsqrt, rather than duplicating
+ it.
+
+Fri Oct 11 16:03:49 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_opcodes): Fix typo in opcode
+ field for movhu instruction.
+
+ * v850-dis.c (disassemble): For V850_OPERAND_SIGNED operands,
+ cast value to "long" not "signed long" to keep hpux10
+ compiler quiet.
+
+Thu Oct 10 10:25:58 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_opcodes): Fix typo in opcode field
+ for mov (abs16),DN.
+
+ * mn10300-opc.c (FMT*): Remove definitions.
+
+ * mn10300-opc.c (mn10300_opcodes): Fix destination register
+ for shift-by-register opcodes.
+
+ * mn10300-opc.c (mn10300_operands): Break DN, DM, AN, AM
+ into [AD][MN][01] for encoding the position of the register
+ in the opcode.
+
+Wed Oct 9 11:19:26 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_opcodes): Add "extended" instructions,
+ "putx", "getx", "mulq", "mulqu", "sat16", "sat24", "bsch".
+
+Tue Oct 8 11:55:35 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (mn10300_operands): Remove "REGS" operand.
+ Fix various typos. Add "PAREN" operand.
+ (MEM, MEM2): Define.
+ (mn10300_opcodes): Surround all memory addresses with "PAREN"
+ operands. Fix several typos.
+
+ * mn10300-opc.c (mn10300_opcodes): Fix typos in yesterday's
+ changes.
+
+Mon Oct 7 16:48:45 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10300-opc.c (FMT_XX): Renumber starting at one.
+ (mn10300_operands): Rough cut. Enough to parse "mov" instructions
+ at this time.
+ (mn10300_opcodes): Break opcode format out into its own field.
+ Update many operand fields to deal with signed vs unsigned
+ issues. Fix one or two typos in the "mov" instruction
+ opcode, mask and/or operand fields.
+
+Mon Oct 7 11:39:49 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-opc.c (plusha): Prefer encoding for m68040up, in case
+ m68851 wasn't reset.
+
+Thu Oct 3 17:17:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mn10300-opc.c (mn10300_opcodes): Add opcode & masks for
+ all opcodes. Very rough cut at operands for all opcodes.
+
+ * mn10300-opc.c (mn10300_opcodes): Start fleshing out the
+ opcode table.
+
+Thu Oct 3 10:06:07 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10200-opc.c, mn10300-opc.c: New files.
+ * mn10200-dis.c, mn10300-dis.c: New files.
+ * mn10x00-opc.c, mn10x00-dis.c: Deleted.
+ * disassemble.c: Break mn10x00 support into 10200 and 10300
+ support.
+ * configure.in: Likewise.
+ * configure: Rebuilt.
+
+Thu Oct 3 15:59:12 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (MOSTLYCLEAN): Move config.log to distclean.
+
+Wed Oct 2 23:28:42 1996 Jeffrey A Law (law@cygnus.com)
+
+ * mn10x00-opc.c, mn10x00-dis.c: New files for Matsushita
+ MN10x00 processors.
+ * disassemble (ARCH_mn10x00): Define.
+ (disassembler): Handle bfd_arch_mn10x00.
+ * configure.in: Recognize bfd_mn10x00_arch.
+ * configure: Rebuilt.
+
+Tue Oct 1 10:49:11 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386-dis.c (op_rtn): Change to be a pointer. Adjust uses
+ accordingly. Don't declare functions using op_rtn.
+
+Fri Sep 27 18:28:59 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * v850-dis.c (disassemble): Add memaddr argument. Re-arrange
+ params to be more standard.
+ * (disassemble): Print absolute addresses and symbolic names for
+ branch and jump targets.
+ * v850-opc.c (v850_operand): Add displacement flag to 9 and 22
+ bit operands.
+ * (v850_opcodes): Add breakpoint insn.
+
+Mon Sep 23 12:32:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Move the fmovemx data register cases before the
+ other cases, so that they get recognized before the data register
+ does gets treated as a degenerate register list.
+
+Tue Sep 17 12:06:51 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Add a case for "div" and "divu" with two registers
+ and a destination of $0.
+
+Tue Sep 10 16:12:39 1996 Fred Fish <fnf@rtl.cygnus.com>
+
+ * mips-dis.c (print_insn_arg): Add prototype.
+ (_print_insn_mips): Ditto.
+
+Mon Sep 9 14:26:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_insn_arg): Print condition code registers as
+ $fccN.
+
+Tue Sep 3 12:09:46 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Add setuw, setsw, setx.
+
+Tue Sep 3 12:05:25 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-dis.c (disassemble): Make static. Provide prototype.
+
+Sun Sep 1 22:30:40 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (insert_d9, insert_d22): Fix boundary case
+ in range checks.
+
+Sat Aug 31 01:27:26 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-dis.c (disassemble): Handle insertion of ',', '[' and
+ ']' characters into the output stream.
+ * v850-opc.c (v850_opcodes: Remove size field from all opcodes.
+ Add "memop" field to all opcodes (for the disassembler).
+ Reorder opcodes so that "nop" comes before "mov" and "jr"
+ comes before "jarl".
+
+ * v850-dis.c (print_insn_v850): Fix typo in last change.
+
+ * v850-dis.c (print_insn_v850): Properly handle disassembling
+ a two byte insn at the end of a memory region when the memory
+ region's size is only two byte aligned.
+
+ * v850-dis.c (v850_cc_names): Fix stupid thinkos.
+
+ * v850-dis.c (v850_reg_names): Define.
+ (v850_sreg_names, v850_cc_names): Likewise.
+ (disassemble): Very rough cut at printing operands (unformatted).
+
+ * v850-opc.c (BOP_MASK): Fix.
+ (v850_opcodes): Fix mask for jarl and jr.
+
+ * v850-dis.c: New file. Skeleton for disassembler support.
+ * Makefile.in Remove v850 references, they're not needed here.
+ * configure.in: Add v850-dis.o when building v850 toolchains.
+ * configure: Rebuilt.
+ * disassemble.c (disassembler): Call v850 disassembler.
+
+ * v850-opc.c (insert_d8_7, extract_d8_7): New functions.
+ (insert_d8_6, extract_d8_6): New functions.
+ (v850_operands): Rename D7S to D7; operand for D7 is unsigned.
+ Rename D8 to D8_7, use {insert,extract}_d8_7 routines.
+ Add D8_6.
+ (IF4A, IF4B): Use "D7" instead of "D7S".
+ (IF4C, IF4D): Use "D8_7" instead of "D8".
+ (IF4E, IF4F): New. Use "D8_6".
+ (v850_opcodes): Use IF4A/IF4B for sld.b/sst.b. Use IF4C/IF4D for
+ sld.h/sst.h. Use IF4E/IF4F for sld.w/sst.w.
+
+ * v850-opc.c (insert_d16_15, extract_d16_15): New functions.
+ (v850_operands): Change D16 to D16_15, use special insert/extract
+ routines. New new D16 that uses the generic insert/extract code.
+ (IF7A, IF7B): Use D16_15.
+ (IF7C, IF7D): New. Use D16.
+ (v850_opcodes): Use IF7C and IF7D for ld.b and st.b.
+
+ * v850-opc.c (insert_d9, insert_d22): Slightly improve error
+ message. Issue an error if the branch offset is odd.
+
+ * v850-opc.c: Add notes about needing special insert/extract
+ for all the load/store insns, except "ld.b" and "st.b".
+
+ * v850-opc.c (insert_d22, extract_d22): New functions.
+ (v850_operands): Use insert_d22 and extract_d22 for
+ D22 operands.
+ (insert_d9): Fix range check.
+
+Fri Aug 30 18:01:02 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * v850-opc.c (v850_operands): Add V850_OPERAND_SIGNED flag
+ and set bits field to D9 and D22 operands.
+
+Thu Aug 29 11:10:46 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_operands): Define SR2 operand.
+ (v850_opcodes): "ldsr" uses R1,SR2.
+
+ * v850-opc.c (v850_opcodes): Fix opcode specs for
+ sld.w, sst.b, sst.h, sst.w, and nop.
+
+Wed Aug 28 15:55:43 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_opcodes): Add null opcode to mark the
+ end of the opcode table.
+
+Mon Aug 26 13:35:53 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (pre_defined_registers): Added register pairs,
+ "r0-r1", "r2-r3", etc.
+
+Fri Aug 23 00:27:01 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_operands): Make I16 be a signed operand.
+ Create I16U for an unsigned 16bit mmediate operand.
+ (v850_opcodes): Use I16U for "ori", "andi" and "xori".
+
+ * v850-opc.c (v850_operands): Define EP operand.
+ (IF4A, IF4B, IF4C, IF4D): Use EP.
+
+ * v850-opc.c (v850_opcodes): Fix opcode numbers for "mov"
+ with immediate operand, "movhi". Tweak "ldsr".
+
+ * v850-opc.c (v850_opcodes): Get ld.[bhw] and st.[bhw]
+ correct. Get sld.[bhw] and sst.[bhw] closer.
+
+ * v850-opc.c (v850_operands): "not" is a two byte insn
+
+ * v850-opc.c (v850_opcodes): Correct bit pattern for setf.
+
+ * v850-opc.c (v850_operands): D16 inserts at offset 16!
+
+ * v850-opc.c (two): Get order of words correct.
+
+ * v850-opc.c (v850_operands): I16 inserts at offset 16!
+
+ * v850-opc.c (v850_operands): Add "SR1" and "SR2" for system
+ register source and destination operands.
+ (v850_opcodes): Use SR1 and SR2 for "ldsr" and "stsr".
+
+ * v850-opc.c (v850_opcodes): Fix thinko in "jmp" opcode. Fix
+ same thinko in "trap" opcode.
+
+ * v850-opc.c (v850_opcodes): Add initializer for size field
+ on all opcodes.
+
+ * v850-opc.c (v850_operands): D6 -> DS7. References changed.
+ Add D8 for 8-bit unsigned field in short load/store insns.
+ (IF4A, IF4D): These both need two registers.
+ (IF4C, IF4D): Define. Use 8-bit unsigned field.
+ (v850_opcodes): For "sld.h", "sld.w", "sst.h", "sst.w", use
+ IF4C & IF4D. For "trap" use I5U, not I5. Add IF1 operand
+ for "ldsr" and "stsr".
+ * v850-opc.c (v850_operands): 3-bit immediate for bit insns
+ is unsigned.
+
+ * v850-opc.c (v850_opcodes): Correct short store half (sst.h) and
+ short store word (sst.w).
+
+Thu Aug 22 16:57:27 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * v850-opc.c (v850_operands): Added insert and extract fields,
+ pointers to functions that handle unusual operand encodings.
+
+Thu Aug 22 01:05:24 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_opcodes): Enable "trap".
+
+ * v850-opc.c (v850_opcodes): Fix order of displacement
+ and register for "set1", "clr1", "not1", and "tst1".
+
+Wed Aug 21 18:46:26 1996 Jeffrey A Law (law@cygnus.com)
+
+ * v850-opc.c (v850_operands): Add "B3" support.
+ (v850_opcodes): Fix and enable "set1", "clr1", "not1"
+ and "tst1".
+
+ * v850-opc.c (v850_opcodes): "jmp" has only an R1 operand.
+
+ * v850-opc.c: Close unterminated comment.
+
+Wed Aug 21 17:31:26 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * v850-opc.c (v850_operands): Add flags field.
+ (v850_opcodes): add move opcodes.
+
+Tue Aug 20 14:41:03 1996 J.T. Conklin <jtc@hippo.cygnus.com>
+
+ * Makefile.in (ALL_MACHINES): Add v850-opc.o.
+ * configure: (bfd_v850v_arch) Add new case.
+ * configure.in: (bfd_v850_arch) Add new case.
+ * v850-opc.c: New file.
+
+Mon Aug 19 15:21:38 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): Handle little endian sparcs.
+
+Thu Aug 15 13:14:43 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c: Add additional information to the opcode
+ table to help determinine which instructions can be done
+ in parallel.
+
+Thu Aug 15 13:11:13 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Update editing of include pathnames to be
+ more general.
+
+Thu Aug 15 16:28:41 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * arm-opc.h: Added "bx" instruction definition.
+
+Wed Aug 14 17:00:04 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha-opc.c (EV4EXTHWINDEX): Field width should be 8 not 5.
+
+Mon Aug 12 14:30:37 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (d10v_opcodes): Minor fixes to addi and bl.l.
+
+Fri Aug 9 13:21:59 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (d10v_opcodes): Correct 'mv' unit entry to EITHER.
+
+Thu Aug 8 12:43:52 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: Update for alpha-opc changes.
+
+Wed Aug 7 11:55:10 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386-dis.c (print_insn_i386): Actually return the correct value.
+ (ONE, OP_ONE): #ifdef out; not used.
+
+Fri Aug 2 17:47:03 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (d10v_opcodes): Added 2 accumulator sub instructions.
+ Changed subi operand type to treat 0 as 16.
+
+Wed Jul 31 16:21:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Add cpushl for the mcf5200. From Ken Rose
+ <rose@netcom.com>.
+
+Wed Jul 31 14:39:27 1996 James G. Smith <jsmith@cygnus.co.uk>
+
+ * arm-opc.h: (arm_opcodes): Added halfword and sign-extension
+ memory transfer instructions. Add new format string entries %h and %s.
+ * arm-dis.c: (print_insn_arm): Provide decoding of the new
+ formats %h and %s.
+
+Fri Jul 26 11:45:04 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c (d10v_operands): Added UNUM4S; a 4-bit accumulator shift.
+ (d10v_opcodes): Modified accumulator shift instructions to use UNUM4S.
+
+Fri Jul 26 14:01:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * alpha-dis.c (print_insn_alpha_osf): Remove.
+ (print_insn_alpha_vms): Remove.
+ (print_insn_alpha): Make globally visible. Chose the register
+ names based on info->flavour.
+ * disassemble.c: Always return print_insn_alpha for the alpha.
+
+Thu Jul 25 15:24:17 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-dis.c (dis_long): Handle unknown opcodes.
+
+Thu Jul 25 12:08:09 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-opc.c: Changes to support signed and unsigned numbers.
+ All instructions with the same name that have long and short forms
+ now end in ".l" or ".s". Divs added.
+ * d10v-dis.c: Changes to support signed and unsigned numbers.
+
+Tue Jul 23 11:02:53 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * d10v-dis.c: Change all functions to use info->print_address_func.
+
+Mon Jul 22 15:38:53 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-opc.c (m68k_opcodes): Make opcode masks for the ColdFire
+ move ccr/sr insns more strict so that the disassembler only
+ selects them when the addressing mode is data register.
+
+Mon Jul 22 11:25:24 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+ * d10v-opc.c (pre_defined_registers): Declare.
+ * d10v-dis.c (print_operand): Now uses pre_defined_registers
+ to pick a better name for the registers.
+
+Mon Jul 22 13:47:23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc-opc.c: Fix opcode values for fpack16, and fpackfix. Fix
+ operands for fexpand and fpmerge. From Christian Kuehnke
+ <Christian.Kuehnke@arbi.informatik.uni-oldenburg.de>.
+
+Mon Jul 22 13:17:06 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha-dis.c (print_insn_alpha): No longer the user-visible
+ print routine. Take new regnames and cpumask arguments.
+ Kill the environment variable nonsense.
+ (print_insn_alpha_osf): New function. Do OSF/1 style regnames.
+ (print_insn_alpha_vms): New function. Do VMS style regnames.
+ * disassemble.c (disassembler): Test bfd flavour to pick
+ between OSF and VMS routines. Default to OSF.
+
+Thu Jul 18 17:19:34 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_SUBST (INSTALL_SHLIB).
+ * configure: Rebuild.
+ * Makefile.in (install): Use @INSTALL_SHLIB@.
+
+Wed Jul 17 14:39:05 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
+
+ * configure: (bfd_d10v_arch) Add new case.
+ * configure.in: (bfd_d10v_arch) Add new case.
+ * d10v-dis.c: New file.
+ * d10v-opc.c: New file.
+ * disassemble.c (disassembler) Add entry for d10v.
+
+Wed Jul 17 10:12:05 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Fix bugs in coldfire insns relating
+ to bcc, trapfl, subxl, and wddata discovered by Andreas Schwab.
+
+Mon Jul 15 16:59:55 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * i386-dis.c: Get rid of print_insn_i8086. Use info.mach to
+ distinguish between variants of the instruction set.
+ * sparc-dis.c: Get rid of print_insn_sparclite. Use info.mach to
+ distinguish between variants of the instruction set.
+
+Fri Jul 12 10:12:01 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * i386-dis.c (print_insn_i8086): New routine to disassemble using
+ the 8086 instruction set.
+ * i386-dis.c: General cleanups. Make most things static. Add
+ prototypes. Get rid of static variables aflags and dflags. Pass
+ them as args (to almost everything).
+
+Thu Jul 11 11:58:44 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300-dis.c (bfd_h8_disassemble): Handle macregs in ldmac insns.
+
+ * h8300-dis.c (bfd_h8_disassemble): Handle "ldm.l" and "stm.l".
+
+ * h8300-dis.c (bfd_h8_disassemble): "abs" is implicitly two
+ if the next arg is marked with SRC_IN_DST. Gross.
+
+ * h8300-dis.c (bfd_h8_disassemble): Print "exr" when
+ we're looking for and find EXR.
+
+ * h8300-dis.c (bfd_h8_disassemble): We don't have a match
+ if we're looking for KBIT and we don't find it.
+
+ * h8300-dis.c (bfd_h8_disassemble): Mask off unwanted bits
+ for L_3 and L_2.
+
+ * h8300-dis.c (bfd_h8_disassemble): Don't set plen for
+ 3bit immediate operands.
+
+Tue Jul 9 10:55:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Released binutils 2.7.
+
+ * alpha-opc.c: Add new case of "mov". From Klaus Kaempf
+ <kkaempf@progis.ac-net.de>.
+
+Thu Jul 4 11:42:51 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * alpha-opc.c: Correct second case of "mov" to use OPRL.
+
+Wed Jul 3 16:03:47 1996 Stu Grossman (grossman@critters.cygnus.com)
+
+ * sparc-dis.c (print_insn_sparclite): New routine to print
+ sparclite instructions.
+
+Wed Jul 3 14:21:18 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Add coldfire support.
+
+Fri Jun 28 15:53:51 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (asi_table): Add #ASI_N, #ASI_N_L, #ASI_NUCLEUS,
+ #ASI_NUCLEUS_LITTLE. Rename #ASI_AS_IF_USER_{PRIMARY,SECONDARY}_L
+ to #ASI_AS_IF_USER_{PRIMARY,SECONDARY}_LITTLE.
+
+Tue Jun 25 22:58:31 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
+
+ * Makefile.in (bindir, libdir, datadir, mandir, infodir, includedir):
+ Use autoconf-set values.
+ (docdir, oldincludedir): Removed.
+ * configure.in (AC_PREREQ): autoconf 2.5 or higher.
+
+Fri Jun 21 13:53:36 1996 Richard Henderson <rth@tamu.edu>
+
+ * alpha-opc.c: New file.
+ * alpha-opc.h: Remove.
+ * alpha-dis.c: Complete rewrite to use new opcode table.
+ * configure.in: For bfd_alpha_arch, use alpha-opc.o.
+ * configure: Rebuild with autoconf 2.10.
+ * Makefile.in (ALL_MACHINES): Add alpha-opc.o.
+ (alpha-dis.o): Depend upon $(INCDIR)/opcode/alpha.h, not
+ alpha-opc.h.
+ (alpha-opc.o): New target.
+
+Wed Jun 19 15:55:12 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): Remove unused local variable i.
+ Set imm_added_to_rs1 even if the source and destination register
+ are not the same.
+
+ * sparc-opc.c: Add some two operand forms of the wr instruction.
+
+Tue Jun 18 15:58:27 1996 Jeffrey A. Law <law@rtl.cygnus.com>
+
+ * h8300-dis.c (bfd_h8_disassemble): Rename "hmode" argument
+ to just "mode".
+
+ * disassemble.c (disassembler): Handle H8/S.
+ * h8300-dis.c (print_insn_h8300s): New function for H8/S.
+
+Tue Jun 18 18:06:50 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc-opc.c: Add beq/teq as aliases for be/te.
+
+ * ppc-opc.c: Fix fcmpo opcode. From Sergei Steshenko
+ <sergei@msil.sps.mot.com>.
+
+Tue Jun 18 15:08:54 1996 Klaus Kaempf <kkaempf@progis.de>
+
+ * makefile.vms: New file.
+
+ * alpha-dis.c (print_insn_alpha): Print lda ra,lit(rz) as mov.
+
+Mon Jun 10 18:50:38 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * h8300-dis.c (bfd_h8_disassemble): Always print ABS8MEM with :8,
+ regardless of plen.
+
+Tue Jun 4 09:15:53 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * i386-dis.c (OP_OFF): Call append_prefix.
+
+Thu May 23 15:18:23 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (instruction encoding macros): Add explicit casts to
+ unsigned long to silence a warning from the Solaris PowerPC
+ compiler.
+
+Thu Apr 25 19:33:32 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Add ultrasparc vis extensions.
+
+Mon Apr 22 17:12:35 1996 Doug Evans <dje@blues.cygnus.com>
+
+ * sparc-dis.c (X_IMM,X_SIMM): New macros.
+ (X_IMM13): Delete.
+ (print_insn_sparc): Merge cases i,I,j together. New cases X,Y.
+ * sparc-opc.c (sparc_opcodes): Use X for 5 bit shift constants,
+ Y for 6 bit shift constants. Rewrite entries for crdcxt, cwrcxt,
+ cpush, cpusha, cpull sparclet insns.
+
+Wed Apr 17 14:20:22 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-dis.c (compute_arch_mask): Replace ANSI style def with K&R.
+
+Thu Apr 11 17:30:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sparc-opc.c: Set F_FBR on floating point branch instructions.
+ Set F_FLOAT on other floating point instructions.
+
+Mon Apr 8 17:02:48 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (PPC860): Macro for 860/821 specific instructions and
+ registers.
+ (powerpc_opcodes): Add 860/821 specific SPRs.
+
+Mon Apr 8 14:00:44 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Permit --enable-shared to specify a list of
+ directories. Set and substitute BFD_PICLIST.
+ * configure: Rebuild.
+ * Makefile.in (BFD_PICLIST): Rename from BFD_LIST. Change all
+ uses. Set to @BFD_PICLIST@.
+
+Fri Apr 5 17:12:27 1996 Jeffrey A Law (law@cygnus.com)
+
+ * h8300-dis.c (bfd_h8_disassemble): Use "bit" for L_3 immediates,
+ not "abs", which may be needed for the absolute in something
+ like btst #0,@10:8. Print L_3 immediates separately from other
+ immediates. Change ABSMOV reference to ABS8MEM.
+
+Wed Apr 3 10:40:45 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-dis.c (opcodes_initialized): Move inside print_insn_sparc.
+ (current_arch_mask): New static global.
+ (compute_arch_mask): New static function.
+ (print_insn_sparc): Delete sparc_v9_p. New static local
+ current_mach. Resort opcode table if current_mach changes.
+ Generalize "insn not supported" test.
+ (compare_opcodes): Prefer supported opcodes to nonsupported ones.
+ Delete test for v9/!v9.
+ * sparc-opc.c (MASK_*): Use SPARC_OPCODE_ARCH_MASK.
+ (v6notlet): Define.
+ (brfc): Split into CBR and FBR for coprocessor/fp branches.
+ (brfcx): Renamed to FBRX.
+ (condfc): Renamed to CONDFC. Pass v6notlet to CBR (standard
+ coprocessor mnemonics are not supported on the sparclet).
+ (condf): Renamed to CONDF.
+ (SLCBCC2): Delete F_ALIAS flag.
+
+Sat Mar 30 21:45:59 1996 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): rd must be 0 for
+ mov foo,{%y,%psr,%wim,%tbr}. Support mov foo,%asrX.
+
+Fri Mar 29 13:02:40 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (config.status): Depend upon BFD VERSION file, so
+ that the shared library version number is set correctly.
+
+Tue Mar 26 15:47:14 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Use AC_CHECK_TOOL to find ar and ranlib. From
+ Miles Bader <miles@gnu.ai.mit.edu>.
+ * configure: Rebuild.
+
+Sat Mar 16 13:04:07 1996 Fred Fish <fnf@cygnus.com>
+
+ * z8kgen.c (internal, gas): Call xmalloc rather than unchecked
+ malloc.
+
+Tue Mar 12 12:14:10 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Rebuild with autoconf 2.8.
+
+Thu Mar 7 15:11:10 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): Handle 'O' operand char like 'r'.
+ * sparc-opc.c (sparc_opcodes): Use 'O' operand char for `neg reg'.
+
+Tue Mar 5 15:51:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Don't set SHLIB or SHLINK to an empty string,
+ since they appear as targets in Makefile.in.
+ * configure: Rebuild.
+
+Mon Feb 26 13:03:40 1996 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-make.sed: Edit out shared library support bits.
+
+Tue Feb 20 20:48:28 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-opc.c (v8,v6notv9): Add MASK_SPARCLET.
+ (sparc_opcode_archs): Add MASK_V8 to sparclet entry.
+ (sparc_opcodes): Add sparclet insns.
+ (sparclet_cpreg_table): New static local.
+ (sparc_{encode,decode}_sparclet_cpreg): New functions.
+ * sparc-dis.c (print_insn_sparc): Handle sparclet cpregs.
+
+Tue Feb 20 11:02:44 1996 Alan Modra <alan@mullet.Levels.UniSA.Edu.Au>
+
+ * i386-dis.c (index16): New static variable.
+ (putop): Print jecxz for 32 bit case, jcxz for 16 bit, not the
+ other way around.
+ (OP_indirE): Return result of OP_E.
+ (OP_E): Check for 16 bit addressing mode, and disassemble
+ correctly. Optimised 32 bit case a little. Don't print
+ "(base,index,scale)" when sib specifies only an offset.
+
+Mon Feb 19 12:32:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Set and substitute SHLIB_DEP.
+ * configure: Rebuild.
+ * Makefile.in (SHLIB_DEP): New variable.
+ (LIBIBERTY_LISTS, BFD_LIST): New variables.
+ (stamp-piclist): Depend upon LIBIBERTY_LISTS and BFD_LIST. If
+ COMMON_SHLIB, add them to piclist with appropriate modifications.
+ ($(SHLIB)): Depend upon $(SHLIB_DEP). Don't check COMMON_SHLIB
+ here: just use piclist.
+
+Mon Feb 19 02:03:50 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-dis.c (MASK_V9,V9_ONLY_P,V9_P): Define.
+ (print_insn_sparc): Rewrite v9/not-v9 tests.
+ (compare_opcodes): Likewise.
+ * sparc-opc.c (MASK_<ARCH>): Define.
+ (v6,v7,v8,sparclite,v9,v9a): Redefine.
+ (sparclet,v6notv9): Define.
+ (sparc_opcode_archs): Delete member `conflicts'. Add `supported'.
+ (sparc_opcodes): Delete F_NOTV9, use v6notv9 instead.
+
+Thu Feb 15 14:45:05 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_PROG_CC before configure.host.
+ * configure: Rebuild.
+
+ * Makefile.in (SONAME): Remove leading ../bfd/ from $(SHLIB).
+
+Wed Feb 14 19:01:27 1996 Alan Modra <alan@spri.levels.unisa.edu.au>
+
+ * i386-dis.c (onebyte_has_modrm): New static array.
+ (twobyte_has_modrm): New static array.
+ (print_insn_i386): Only fetch the mod/reg/rm byte if it is needed.
+
+Tue Feb 13 15:15:01 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in ($(SHLINK)): Check ts against $(SHLIB), not
+ $(SHLINK).
+
+Mon Feb 12 16:26:06 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (PPC): Undef, so default defination on Windows NT
+ doesn't conflict.
+
+Wed Feb 7 13:59:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): The bkpt instruction is supported on
+ m68010up, not just m68020up | cpu32.
+
+ * Makefile.in (SONAME): New variable.
+ ($(SHLINK)): Make a link to the transformed name, as well.
+ (stamp-tshlink): New target.
+ (install): Skip stamp-tshlink during install.
+
+Tue Feb 6 12:28:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_ARG_PROGRAM.
+ * configure: Rebuild.
+ * Makefile.in (program_transform_name): New variable.
+ (install): Transform library name before installing it.
+
+Mon Feb 5 16:14:42 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i960-dis.c (mem): Add HX dcinva instruction.
+
+ Support for building as a shared library, based on patches from
+ Alan Modra <alan@spri.levels.unisa.edu.au>:
+ * configure.in: Add AC_ARG_ENABLE for shared and commonbfdlib.
+ New substitutions: ALLLIBS, PICFLAG, SHLIB, SHLIB_CC,
+ SHLIB_CFLAGS, COMMON_SHLIB, SHLINK.
+ * configure: Rebuild.
+ * Makefile.in (ALLLIBS): New variable.
+ (PICFLAG, SHLIB, SHLIB_CC, SHLIB_CFLAGS): New variables.
+ (COMMON_SHLIB, SHLINK): New variables.
+ (.c.o): If PICFLAG is set, compile twice, once PIC, once normal.
+ (STAGESTUFF): Remove variable.
+ (all): Depend upon $(ALLLIBS) rather than $(TARGETLIB).
+ (stamp-piclist, piclist): New targets.
+ ($(SHLIB), $(SHLINK)): New targets.
+ ($(OFILES)): Depend upon stamp-picdir.
+ (disassemble.o): Build twice if PICFLAG is set.
+ (MOSTLYCLEAN): Add pic/*.o.
+ (clean): Remove $(SHLIB), $(SHLINK), piclist, and stamp-piclist.
+ (distclean): Remove pic and stamp-picdir.
+ (install): Install shared libraries.
+ (stamp-picdir): New target.
+
+Fri Feb 2 17:15:25 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): Delete DISASM_RAW_INSN support.
+ Print unknown instruction as "unknown", rather than in hex.
+
+Tue Jan 30 14:06:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * dis-buf.c: Include "sysdep.h" before "dis-asm.h".
+
+Thu Jan 25 20:24:07 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-opc.c (sparc_opcode_archs): Mark v8/sparclite as conflicting.
+
+Thu Jan 25 11:56:49 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * i386-dis.c (print_insn_i386): Only fetch the mod/reg/rm byte
+ when necessary. From Ulrich Drepper
+ <drepper@myware.rz.uni-karlsruhe.de>.
+
+Thu Jan 25 03:39:10 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): NUMOPCODES replaced with
+ sparc_num_opcodes. Update architecture enum values.
+ * sparc-opc.c (sparc_opcode_archs): Replaces architecture_pname.
+ (sparc_opcode_lookup_arch): New function.
+ (sparc_num_opcodes): Renamed from bfd_sparc_num_opcodes.
+ (sparc_opcodes): Add v9a shutdown insn.
+
+Mon Jan 22 08:29:59 1996 Doug Evans <dje@charmed.cygnus.com>
+
+ * sparc-dis.c (print_insn_sparc): Renamed from print_insn.
+ If DISASM_RAW_INSN, print insn in hex. Handle v9a as opcode
+ architecture.
+ (print_insn_sparc64): Deleted.
+ * disassemble.c (disassembler, case bfd_arch_sparc): Always use
+ print_insn_sparc.
+
+ * sparc-opc.c (architecture_pname): Add v9a.
+
+Fri Jan 12 14:35:58 1996 David Mosberger-Tang <davidm@AZStarNet.com>
+
+ * alpha-opc.h (alpha_insn_set): VAX floating point opcode was
+ incorrectly defined as 0x16 when it should be 0x15.
+ (FLOAT_FORMAT_MASK): function code is 11 bits, not just 7 bits!
+ (alpha_insn_set): added cvtst and cvttq float ops. Also added
+ excb (exception barrier) which is defined in the Alpha
+ Architecture Handbook version 2.
+ * alpha-dis.c (print_insn_alpha): Fixed special-case decoding for
+ OPERATE_FORMAT_CODE type instructions. The bug caused mulq to be
+ disassembled as or, for example.
+
+Wed Jan 10 12:37:22 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-dis.c (print_insn_arg): Print cases 'i' and 'u' in hex.
+ (_print_insn_mips): Change i from int to unsigned int.
+
+Thu Jan 4 17:21:10 1996 David Edelsohn <edelsohn@mhpcc.edu>
+
+ * ppc-opc.c (powerpc_opcodes): tlbi POWER opcode form different
+ from tlbie PowerPC opcode. Add PPC603 tlbld and tlbli.
+
+Thu Dec 28 13:29:19 1995 John Hassey <hassey@rtp.dg.com>
+
+ * i386-dis.c: Added Pentium Pro instructions.
+
+Tue Dec 19 22:56:35 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (fsqrt{,.}): Duplicate for PowerPC in addition to
+ being for Power2.
+
+Fri Dec 15 14:14:15 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * sh-opc.h (sh_nibble_type): Added REG_B.
+ (sh_arg_type): Added A_REG_B.
+ (sh_table): Added pref and bank reg versions of ldc, ldc.l, stc
+ and stc.l opcodes.
+ * sh-dis.c (print_insn_shx): Added cases for REG_B and A_REG_B.
+
+Fri Dec 15 16:44:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * disassemble.c (disassembler): Use new bfd_big_endian macro.
+
+Tue Dec 12 12:22:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (distclean): Remove stamp-h. From Ronald
+ F. Guilmette <rfg@monkeys.com>.
+
+Tue Dec 5 13:42:44 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ From David Mosberger-Tang <davidm@azstarnet.com>:
+ * alpha-dis.c (print_insn_alpha): fixed decoding of cpys
+ instruction.
+
+Mon Dec 4 12:29:05 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * sh-opc.h (sh_arg_type): Added A_SSR and A_SPC.
+ (sh_table): Added many SH3 opcodes.
+ * sh-dis.c (print_insn_shx): Added cases for A_SSR and A_SPC.
+
+Fri Dec 1 07:42:18 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (subfc., subfco): Mark this PPCCOM, not PPC.
+ (subco,subco.): Mark this PPC, not PPCCOM.
+
+Mon Nov 27 13:09:52 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Rebuild with autoconf 2.7.
+
+Tue Nov 21 18:28:06 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure: Rebuild with autoconf 2.6.
+
+Wed Nov 15 19:02:53 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * configure.in: Sort list of architectures. Accept but do nothing
+ for alliant, convex, pyramid, romp, and tahoe.
+
+Wed Nov 8 20:18:59 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * a29k-dis.c (print_special): Change num to unsigned int.
+
+Wed Nov 8 20:10:35 1995 Eric Freudenthal <freudenthal@nyu.edu>
+
+ * a29k-dis.c (print_insn): Cast insn24 to unsigned long when
+ shifting it.
+
+Tue Nov 7 15:21:06 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Call AC_CHECK_PROG to find and cache AR.
+ * configure: Rebuilt.
+
+Mon Nov 6 17:39:47 1995 Harry Dolan <dolan@ssd.intel.com>
+
+ * configure.in: Add case for bfd_i860_arch.
+ * configure: Rebuild.
+
+Fri Nov 3 12:45:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c (m68k_opcodes): Correct fmoveml operands.
+ * m68k-dis.c (NEXTSINGLE): Change i to unsigned int.
+ (NEXTDOUBLE): Likewise.
+ (print_insn_m68k): Don't match fmoveml if there is more than one
+ register in the list.
+ (print_insn_arg): Handle a place of '8' for a type of 'L'.
+
+Thu Nov 2 23:06:33 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Use #W rather than #w.
+ * m68k-dis.c (print_insn_arg): Handle new 'W' place.
+
+Wed Nov 1 13:30:24 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c (m68k_opcode_aliases): Add dbfw as an alias for dbf,
+ and likewise for all the dbxx opcodes.
+
+Mon Oct 30 20:50:40 1995 Fred Fish <fnf@cygnus.com>
+
+ * arc-dis.c: Include elf-bfd.h rather than libelf.h.
+
+Mon Oct 23 11:11:34 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
+
+ * mips-opc.c: Added shorthand (V1) for INSN_4100 manifest. Added
+ the VR4100 specific instructions to the mips_opcodes structure.
+
+Thu Oct 19 11:05:23 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in, mpw-make.sed: Remove ugly workaround for
+ ugly Metrowerks bug in CW6, is fixed in CW7.
+
+Mon Oct 16 12:59:01 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (whole file): Add flags for common/any support.
+
+Tue Oct 10 11:06:07 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (BISON): Remove macro.
+ (FLAGS_TO_PASS): Remove BISON.
+
+Fri Oct 6 16:26:45 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k-dis.c (print_insn_m68k): Recognize all two-word
+ instructions that take no args by looking at the match mask.
+ (print_insn_arg): Always print "%" before register names.
+ [case 'c']: Use "nc" for the no-cache case, as recognized by gas.
+ [case '_']: Don't print "@#" before address.
+ [case 'J']: Use "%s" as format string, not register name.
+ [case 'B']: Treat place == 'C' like 'l' and 'L'.
+
+Thu Oct 5 22:16:20 1995 Ken Raeburn <raeburn@cygnus.com>
+
+ * i386-dis.c: Describe cmpxchg8b operand, and spell the opcode
+ name correctly.
+
+Tue Oct 3 08:30:20 1995 steve chamberlain <sac@slash.cygnus.com>
+
+ From David Mosberger-Tang <davidm@azstarnet.com>
+
+ * alpha-opc.h (MEMORY_FUNCTION_FORMAT_MASK): added.
+ (alpha_insn_set): added definitions for VAX floating point
+ instructions (Unix compilers don't generate these, but handcoded
+ assembly might still use them).
+
+ * alpha-dis.c (print_insn_alpha): added support for disassembling
+ the miscellaneous instructions in the Alpha instruction set.
+
+Tue Sep 26 18:47:20 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Add m68k-opc.c.o to BFD_MACHINES for m68k,
+ no longer create sysdep.h, sed ppc-opc.c to work around a
+ serious Metrowerks C bug.
+ * mpw-make.in: Remove.
+ * mpw-make.sed: New file, used by mpw-configure to edit
+ Makefile.in into an MPW makefile.
+
+Wed Sep 20 12:55:28 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (maintainer-clean): New synonym for realclean.
+
+Tue Sep 19 15:28:36 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: Split pmove patterns which use 'P' into patterns
+ which use '0', '1', and '2' instead. Specify the proper size for
+ a pmove immediate operand. Correct the pmovefd patterns to be
+ moves to a register, not from a register.
+ * m68k-dis.c (print_insn_arg): Replace 'P' with '0', '1', '2'.
+
+Thu Sep 14 11:58:22 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Mark all insns that reference
+ %psr, %wim, %tbr as F_NOTV9.
+
+Fri Sep 8 01:07:38 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (Makefile): Just rebuild Makefile when running
+ config.status.
+ (config.h, stamp-h): New targets.
+ * configure.in: Call AC_CONFIG_HEADER and AC_CANONICAL_SYSTEM
+ earlier. Don't bother to call AC_ARG_PROGRAM. Touch stamp-h when
+ rebuilding config.h.
+ * configure: Rebuild.
+
+ * mips-opc.c: Change unaligned loads and stores with "t,A"
+ operands to use "t,A(b)".
+
+Thu Sep 7 19:02:46 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-dis.c (print_insn_shx): Add F_FR0 support.
+
+Thu Sep 7 19:02:46 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-dis.c (print_insn_shx): Change loop over op->arg[n] to iterate
+ until 3 instead of until 2.
+
+Wed Sep 6 21:21:33 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * Makefile.in (ALL_CFLAGS): Define.
+ (.c.o, disassemble.o): Use $(ALL_CFLAGS).
+ (MOSTLYCLEAN): Add config.log.
+ (distclean): Don't remove config.log.
+ * configure.in: Substitute HDEFINES.
+ * configure: Rebuild.
+
+Wed Sep 6 15:08:09 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-opc.h (sh_arg_type): Add F_FR0.
+ (sh_table, case fmac): Add F_FR0 as first argument.
+
+Wed Sep 6 15:08:09 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-opc.h (sh_opcode_info): Increase arg array size to 4.
+
+Tue Sep 5 18:28:10 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-dis.c: Remove all references to NO_V9.
+
+Tue Sep 5 20:03:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * aclocal.m4: Just include ../bfd/aclocal.m4.
+ * configure: Rebuild.
+
+Tue Sep 5 16:09:59 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-dis.c (X_DISP19): Define.
+ (print_insn, case 'G'): Use it.
+ (print_insn, case 'L'): Sign extend displacement.
+
+Mon Sep 4 14:28:46 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * configure.in: Run ../bfd/configure.host before AC_PROG_CC.
+ Subsitute CFLAGS and AR. Call AC_PROG_INSTALL. Don't substitute
+ host_makefile_frag or frags.
+ * aclocal.m4: New file.
+ * configure: Rebuild.
+ * Makefile.in (INSTALL): Set to @INSTALL@.
+ (INSTALL_PROGRAM): Set to @INSTALL_PROGRAM@.
+ (INSTALL_DATA): Set to @INSTALL_DATA@.
+ (AR): Set to @AR@.
+ (AR_FLAGS): Set to rc rather than qc.
+ (CC): Define as @CC@.
+ (CFLAGS): Set to @CFLAGS@.
+ (@host_makefile_frag@): Remove.
+ (config.status): Remove dependency upon @frags@.
+
+ * configure.in: ../bfd/config.bfd now just sets shell variables.
+ Use them rather than looking through target Makefile fragments.
+ * configure: Rebuild.
+
+Thu Aug 31 12:35:32 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-opc.h (ftrc): Change FPUL_N to FPUL_M.
+
+Wed Aug 30 13:52:28 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sparc_opcodes): Delete duplicate wr %y insn.
+ Add clrx, iprefetch, signx, clruw, cas, casl, casx, casxl synthetic
+ sparc64 insns.
+
+ * sparc-opc.c (sparc_opcodes): Fix prefetcha insn.
+ (lookup_{name,value}): New functions.
+ (prefetch_table): New static local.
+ (sparc_{encode,decode}_prefetch): New functions.
+ * sparc-dis.c (print_insn): Handle '*' arg (prefetch function).
+
+Wed Aug 30 11:11:58 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-opc.h: Add blank lines to improve readabililty of sh3e
+ instructions.
+
+Wed Aug 30 11:09:38 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-dis.c: Correct comment on first line of file.
+
+Tue Aug 29 15:37:18 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * disassemble.c (disassembler): Handle bfd_mach_sparc64.
+
+ * sparc-opc.c (asi, membar): New static locals.
+ (sparc_{encode,decode}_{asi,membar}): New functions.
+ (sparc_opcodes, membar insn): Fix.
+ * sparc-dis.c (print_insn): Call sparc_decode_asi.
+ Support decoding of membar masks.
+ (X_MEMBAR): Define.
+
+Sat Aug 26 21:22:48 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c (m68k_opcode_aliases): Add br, brs, brb, brw, brl.
+
+Mon Aug 21 17:33:36 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c (m68k_opcode_aliases): Add bhib as an alias for bhis,
+ and likewise for the other branches. Add bhs as an alias for bcc,
+ and likewise for the size variants. Add dbhs as an alias for
+ dbcc.
+
+Fri Aug 11 13:40:24 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * sh-opc.h (FP sts instructions): Update to match reality.
+
+Mon Aug 7 16:12:58 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-dis.c: (fpcr_names): Add % before all register names.
+ (reg_names): Likewise.
+ (print_insn_arg): Don't explicitly print % before register names.
+ Add % before register names in static array names. In case 'r',
+ print data registers as `@(Dn)', not `Dn@'. When printing a
+ memory address, don't print @# before it.
+ (print_indexed): Change base_disp and outer_disp from int to
+ bfd_vma. Print using MIT syntax, not mutant invalid Motorola
+ syntax. Sign extend 8 byte displacement correctly.
+ (print_base): Print using MIT syntax. Print zpc when appropriate.
+ Change parameter disp from int to bfd_vma.
+
+ * m68k-opc.c (m68k_opcode_aliases): Add jsrl and jsrs as aliases
+ for jsr.
+
+Mon Aug 7 02:21:40 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * sh-dis.c (print_insn_shx): Handle new operand types F_REG_N,
+ F_REG_M, FPSCR_M, FPSCR_N, FPUL_M and FPUL_N.
+ * sh-opc.h (sh_arg_type): Add new operand types.
+ (sh_table): Add new opcodes from SH3E Floating Point ISA.
+
+Sat Aug 5 16:50:14 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (distclean): Remove generated file config.h.
+
+Sat Aug 5 16:50:14 1995 Fred Fish <fnf@cygnus.com>
+
+ * Makefile.in (distclean): Remove generated file config.h.
+
+Wed Aug 2 18:33:40 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * m68k-opc.c: New file, holding tables from include/opcode/m68k.h.
+ Clean up tables.
+ * m68k-dis.c: Remove BREAK_UP_BIG_DECL stuff.
+ (opcode): Remove.
+ (print_insn_m68k): Change d to be const. Use m68k_numopcodes
+ rather than numopcodes. Use m68k_opcodes rather than removed
+ opcode function. Don't check F_ALIAS.
+ (print_insn_arg): Change first parameter to be const char *.
+ * Makefile.in (ALL_MACHINES): Add m68k-opc.o.
+ (m68k-opc.o): New target.
+ * configure.in: Build m68k-opc.o for bfd_m68k_arch.
+ * configure: Rebuild.
+
+Wed Aug 2 08:23:38 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-dis.c (HASH_SIZE, HASH_INSN): Define.
+ (opcode_bits, opcode_hash_table): New variables.
+ (opcodes_initialized): Renamed from opcodes_sorted.
+ (build_hash_table): New function.
+ (is_delayed_branch): Use hash table.
+ (print_insn): Renamed from print_insn_sparc, made static.
+ Build and use hash table. If !sparc64, ignore sparc64 insns,
+ and vice-versa if sparc64.
+ (print_insn_sparc, print_insn_sparc64): New functions.
+ (compare_opcodes): Move sparc64 opcodes to end.
+ Print commutative insns with constant second.
+ * sparc-opc.c (all non-v9 insns): Use flag F_NOTV9 instead of F_ALIAS.
+
+Tue Aug 1 00:12:49 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * sh-dis.c (print_insn_shx): Remove unused local dslot. Use
+ print_address_func for A_BDISP12 and A_BDISP8. Correct test which
+ avoids printing a delay slot in a delay slot.
+ * sh-opc.h (sh_table): Fully bracket last entry.
+
+Mon Jul 31 12:04:47 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * sparc-opc.c (sllx, srax, srlx): Fix disassembly.
+
+Wed Jul 12 00:59:34 1995 Ken Raeburn <raeburn@kr-pc.cygnus.com>
+
+ * configure.in: Get host_makefile_frag from ${srcdir}.
+
+ * configure.in: Autoconfiscated. Check for string[s].h. Create
+ config.h from config.in. Don't set up sysdep.h link.
+ * sysdep.h: New file.
+ * configure, config.in: New files, generated from configure.in.
+ * Makefile.in: Updated to be processed autoconf-style.
+ (distclean): Keep sysdep.h. Remove config.log and config.cache.
+ (Makefile): Depend on config.status.
+ (config.status): New rule.
+ * configure.bat: Update Makefile substitutions.
+
+Tue Jul 11 14:23:37 1995 Jeff Spiegel <jeffs@lsil.com>
+
+ * mips-opc.c (L1): Define.
+ (mips_opcodes): Add R4010 instructions: flushi, flushd, flushid,
+ addciu, madd, maddu, ffc, ffs, msub, msubu, selsi, selsr, waiti,
+ and wb.
+
+Tue Jul 11 11:49:49 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c (mips_opcodes): For the move pseudo-op, prefer daddu
+ if ISA 3 and addu otherwise, replacing or, since some MIPS chips
+ have multiple add units but only a single logical unit.
+
+ * ppc-opc.c (powerpc_operands): Change CR to use a bitsize of 3,
+ shifted by 18, without any insertion or extraction function.
+ (insert_cr, extract_cr): Remove.
+
+Wed Jun 21 20:05:39 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * m68k-dis.c (print_insn_arg, print_indexed): Print "%" before
+ register names.
+
+Thu Jun 15 17:23:31 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * mpw-config.in: Add sh and i386 configs, remove sparc config.
+ * sh-opc.h: Add copyright.
+
+Mon Jun 5 03:30:43 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
+
+ * Makefile.in (crunch-m68k): Delete extra target accidentally
+ checked in a while ago.
+
+Wed May 24 16:22:13 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * sh-opc.h (sh_table): Add SH3 support.
+
+Wed May 24 14:16:08 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * sh-opc.h: Added bsrf and braf.
+
+Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
+
+ * arm-opc.h (arm_opcodes): Add 64-bit multiply patterns. Delete
+ bogus [ls]fm{ea,fd} patterns.
+
+ * arm-opc.h (arm_opcodes): Correct typos in stm, ldm, std, and ldc.
+ * arm-dis.c (print_insn_arm): Make GIVEN a parameter, don't try and
+ initialize it from memory. Make function static.
+ (print_insn_{big,little}_arm): New functions.
+ * disassemble.c (disassembler, case bfd_arch_arm): Disassemble for
+ the correct endianness.
+
+Mon Apr 24 14:18:05 1995 Jason Molenda (crash@phydeaux.cygnus.com>
+
+ * sh-opc.h (sh_nibble_type, sh_arg_type): remove trailing , from
+ enum list.
+
+Wed Apr 19 14:07:03 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * m68k-dis.c (opcode): Finish change made by Kung Hsu on April
+ 17th, so that it builds again using GCC as the compiler.
+
+Tue Apr 18 12:14:51 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * mips-dis.c (print_insn_little_mips): Cast return value from
+ bfd_getl32 from bfd_vma to unsigned long, because _print_insn_mips
+ expects an unsigned long, and that might be fewer words of
+ argument storage (e.g., if bfd_vma is long long on a 32-bit
+ machine).
+ (print_insn_big_mips): Likewise with bfd_getb32 value.
+ (_print_insn_mips): Now static.
+
+Mon Apr 17 12:23:28 1995 Kung Hsu <kung@rtl.cygnus.com>
+
+ * m68k-dis.c: Take out #define BREAK_UP_BIG_DECL kludge, because
+ gcc memory hog problem with initializer is fixed.
+
+Mon Apr 10 15:55:01 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ Merge in support for Mac MPW as a host.
+ (Old change descriptions retained for informational value.)
+
+ * mpw-config.in (archname): Compute from the config.
+ (BFD_MACHINES, ARCHDEFS): Put into mk.tmp.
+
+ * mpw-config.in (target_arch): Compute from canonical target.
+ (m68k, mips, powerpc, sparc): Add architectures.
+ * mpw-make.in (disassemble.c.o): Add.
+ (ALL_CFLAGS): Remove special flags (-mc68020 -mc68881 -model far).
+
+ * mpw-config.in (BFD_MACHINES): Set to a default value.
+ * mpw-make.in (BFD_MACHINES): Remove wired-in value.
+
+ * mpw-make.in (CSEARCH): Add extra-include to search path.
+
+ * mpw-config.in (varargs.h): Don't create.
+ (sysdep.h): Create using forward-include.
+ * mpw-make.in (CSEARCH): Add include/mpw to search path.
+
+ * mpw-config.in: New file, MPW version of configure.in.
+ * mpw-make.in: New file, MPW version of Makefile.in.
+
+Fri Mar 31 14:23:38 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * alpha-dis.c (print_insn_alpha): Put empty statement after
+ default label.
+
+Tue Mar 21 10:51:40 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppa-dis.c (sign_extend): Delete, redundant with libhppa.h version.
+ (low_sign_extend): Likewise.
+ (get_field): Delete unused function.
+ (set_field, deposit_14, deposit_21): Likewise.
+
+Fri Mar 17 15:55:53 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * i386-dis.c: Support for more pentium opcodes. From Guy Harris
+ (guy@netapp.com).
+
+Tue Mar 14 00:52:57 1995 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ Sat Feb 11 17:22:41 1995 Klaus Kaempf (kkaempf@didymus.rmi.de)
+
+ * alpha-opc.h (OSF_ASMCODE): define
+ print pal-code names as defined in App C of the
+ Alpha Architecture Reference Manual
+
+ * alpha-dis.c: cleaned up output
+ print stylized code forms as defined in App A.4.3 of the
+ Alpha Architecture Reference Manual
+
+Wed Mar 8 15:21:14 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Add new mips4 instructions. Don't set INSN_RFE for
+ `rfe'.
+ * mips-dis.c (print_insn_arg): Handle new argument types 'h', 'R',
+ 'N', and 'M'.
+
+Wed Mar 8 02:54:05 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * m68k-dis.c (opcode): New function. Returns address of opcode
+ table entry given index, even if the opcode table was split to
+ work around gcc bugs.
+ (print_insn_m68k): Call opcode instead of referencing m68k_opcodes
+ directly.
+ (BREAK_UP_BIG_DECL): Make secondary array static and const.
+ (reg_names): Now const.
+ (print_insn_arg): Arrays cacheFieldName and names now const.
+ (print_indexed): Array scales now const.
+
+Tue Mar 7 16:41:21 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ppc-opc.c: Sort recently added instructions by minor opcode
+ number within major opcode number.
+
+Mon Mar 6 10:04:36 1995 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppa-dis.c: Include libhppa.h.
+
+Fri Feb 24 19:15:36 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Change dli to use M_DLI, and add dla.
+
+Mon Feb 20 23:54:38 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * Makefile.in (ALL_MACHINES): Add w65-dis.o.
+
+Thu Feb 16 17:34:41 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Add r4650 mul instruction.
+
+Wed Feb 15 15:45:20 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * mips-opc.c: Add uld and usd macros for unaligned double load and
+ store.
+
+Tue Feb 14 13:17:37 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * ppc-opc.c (powerpc_opcodes): Add 403GA opcodes rfci, dccci,
+ mfdcr, mtdcr, icbt, iccci.
+
+Thu Feb 9 12:28:13 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * i960-dis.c (struct tabent, struct sparse_tabent): Change the
+ signed char fields to shorts, more portable.
+
+Wed Feb 8 17:29:29 1995 Stan Shebs <shebs@andros.cygnus.com>
+
+ * i960-dis.c (struct tabent, struct sparse_tabent): Declare the
+ char fields as signed chars, since they may have negative values.
+
+Mon Feb 6 10:52:06 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * i386-dis.c (dis386_twobyte): Add cpuid, From Charles Hannum
+ (mycroft@netbsd.org).
+
+Mon Jan 30 12:38:00 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ From "Logg, Ed" <elogg@ea.com>:
+ * ppc-opc.c (extract_bdm): Correct parenthezisation.
+ * ppc-dis.c (print_insn_powerpc): Print .long before unrecognized
+ value.
+
+Thu Jan 26 18:32:08 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ppc-opc.c: Changes based on patch from David Edelsohn
+ <edelsohn@mhpcc.edu>.
+ (powerpc_operands): Add operands SPRBAT and SPRG. Split TBR out of
+ SPR.
+ (FXM_MASK): Define.
+ (insert_tbr): New static function.
+ (extract_tbr): New static function.
+ (XFXFXM_MASK, XFXM): Define.
+ (XSPRBAT_MASK, XSPRG_MASK): Define.
+ (powerpc_opcodes): Add instructions to access special registers by
+ name. Add mtcr and mftbu.
+
+Tue Jan 17 10:56:43 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * mips-opc.c (P3): Define.
+ (mips_opcodes): Add mad and madu.
+
+Sun Jan 15 16:32:59 1995 Steve Chamberlain <sac@splat>
+
+ * configure.in: Add W65 support.
+ * disassemble.c: Likewise.
+ * w65-opc.h, w65-dis.c: New files.
+
+Wed Dec 28 22:15:33 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * h8300-dis.c (bfd_h8_disassemble): Add support for 2 bit
+ immediates.
+
+Tue Dec 20 11:25:12 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * mips-opc.c: Add dli as a synonym for li.
+
+Thu Dec 8 18:23:31 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * alpha-dis.c (print_insn_alpha): Handle call_pal instruction, and
+ print something for reserved opcode values, even if it won't
+ assemble again.
+
+ * mips-dis.c (_print_insn_mips): When initializing, shift right
+ and mask, to avoid sign extension problems on the Alpha.
+
+ * m68k-dis.c (print_insn_arg, case 'J'): Handle buscr and pcr
+ control registers.
+
+Wed Nov 23 22:34:51 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * sh-opc.h (mov.l gbr): Get direction right.
+ * sh-dis.c (print_insn_shx): New function.
+ (print_insn_shl, print_insn_sh): Call print_insn_shx to
+ print opcodes with right byte order.
+
+Thu Nov 3 19:32:22 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * ns32k-dis.c (struct ns32k_option): Renamed from struct option,
+ to avoid conflicts with getopt.
+
+Mon Oct 31 18:48:10 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * hppa-dis.c (print_insn_hppa): Read the instruction using
+ bfd_getb32, so that it works on a little endian or 64 bit host.
+ Remove unused local variable op.
+
+Tue Oct 25 17:07:57 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * mips-opc.c: Use or instead of addu for pseudo-op move, since
+ addu does not work correctly if -mips3.
+
+Wed Oct 19 13:40:16 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * a29k-dis.c (print_special): Add special register names defined
+ on 29030, 29040 and 29050.
+ (print_insn): Handle new operand type 'I'.
+
+Wed Oct 12 11:59:55 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * Makefile.in (INSTALL): Use top level install.sh script.
+
+Wed Oct 5 19:16:29 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * sparc-dis.c: Rewrite to use bitfields, rather than a union, so
+ that it works on a little endian host.
+
+Tue Oct 4 12:14:21 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * configure.in: Use ${config_shell} when running config.bfd.
+
+Wed Sep 21 18:49:12 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * mips-opc.c (mips_opcodes): "dabs" is only available with -mips3.
+
+Thu Sep 15 16:30:22 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * a29k-dis.c (print_insn): Print the opcode.
+
+Wed Sep 14 17:52:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * mips-opc.c (mips_opcodes): Set WR_t for sc and scd.
+
+Sun Sep 11 22:32:17 1994 Jeff Law (law@snake.cs.utah.edu)
+
+ * hppa-dis.c (reg_names): Use r26-r23 for arg0-arg3.
+
+Tue Sep 6 11:37:12 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * mips-opc.c: Set INSN_STORE_MEMORY flag for all instructions
+ which store a value into memory.
+
+Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+ * configure.in, Makefile.in, disassemble.c: Add support for the ARM.
+ * arm-dis.c, arm-opc.h: New files.
+
+Fri Aug 5 14:00:05 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * Makefile.in (ns32k-dis.o): Add dependency.
+ * ns32k-dis.c (print_insn_arg): Declare initialized local as
+ string, not as array of chars.
+
+Thu Jul 28 18:14:16 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * sparc-dis.c (print_insn_sparc): Handle new operand type 'x'.
+
+ * sparc-opc.c: Added sparclite extended FP operations, and
+ versions of v9 impdep* instructions permitting specification of
+ the OPF field.
+
+Tue Jul 26 16:36:03 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * i960-dis.c (reg_names): Now const.
+ (struct sparse_tabent): New type, copied from array type in mem
+ function.
+ (ctrl): Local static array ctrl_tab now const.
+ (cobr): Local static array cobr_tab now const.
+ (mem): Local variables reg1, reg2, reg3 now point to const. Local
+ static variable mem_tab no longer explicitly initialized. Changed
+ mem_init to const array of struct sparse_tabent.
+ (reg): Local static variable reg_tab no longer explicitly
+ initialized. Changed reg_init to const array of struct
+ sparse_tabent.
+ (ea): Local static array scale_tab now const.
+
+ * i960-dis.c (reg): Added i960JX instructions to reg_init table.
+ (REG_MAX): Updated.
+
+Tue Jul 19 21:00:00 1994 DJ Delorie (dj@ctron.com)
+
+ * configure.bat: the disassember needs to be enabled for
+ "objdump -d" to work in djgpp.
+
+Wed Jul 13 18:01:58 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * ns32k-dis.c: Deleted all code in "#ifdef GDB".
+ (invalid_float): Enabled general version, doesn't require running
+ on ns32k host. Changed to take char* argument, and test for
+ explicitly specified sizes, instead of using sizeof() on host CPU
+ types.
+ (INVALID_FLOAT): Cast first argument.
+ (opt_u, opt_U, opt_O, opt_C, opt_S, list_P532, list_M532,
+ list_P032, list_M032): Now const.
+ (optlist, list_search): Made appropriate arguments now point to
+ const.
+ (print_insn_arg): Changed static array of one-character-string
+ pointers into a static const array of characters; fixed sprintf
+ statement accordingly.
+
+Sun Jul 10 00:27:47 1994 Ian Dall (dall@hfrd.dsto.gov.au)
+
+ * opcodes/ns32k-dis.c: Semi-new file. Had apparently been dropped
+ from distribution. A ns32k-dis.c from a previous distribution has
+ been brought up to date and supports the new interface.
+
+ * disassemble.c: define ARCH_ns32k and add case bfd_arch_ns32k.
+
+ * configure.in: add bfd_ns32k_arch target support.
+
+ * Makefile.in: add ns32k-dis.o to ALL_MACHINES.
+ Add ns32k-dis.c to CFILES. Add dependencies for ns32k-dis.o.
+
+Wed Jun 29 22:10:37 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * h8300-dis.c (bfd_h8_disassemble): Get 16bit branch
+ disassembly right.
+
+Tue Jun 28 13:22:06 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * h8300-dis.c, mips-dis.c: Don't use true and false.
+
+Thu Jun 23 12:53:19 1994 David J. Mackenzie (djm@rtl.cygnus.com)
+
+ * configure.in: Change --with-targets to --enable-targets.
+
+Wed Jun 22 13:38:32 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * mips-dis.c (_print_insn_mips): Build a static hash table mapping
+ opcodes to the first instruction with that opcode, to speed
+ disassembly of large files. From ralphc@pyramid.com (Ralph
+ Campbell).
+
+Tue Jun 7 12:49:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Makefile.in (mostlyclean): Fix typo (was mostyclean).
+
+Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com)
+
+ * configure.bat: update to latest makefile.in
+
+Sat May 7 17:13:21 1994 Steve Chamberlain (sac@cygnus.com)
+
+ * a29k-dis.c (print_insn): Print 'x' type operand in hex.
+ * h8300-dis.c (bfd_h8_disassemble): Print 16bit rels correctly.
+ * sh-dis.c (print_insn_sh): Don't recur endlessly if delay
+ slot insn is in a delay slot.
+ * z8k-opc.h: (resflg): Fix patterns.
+ * h8500-opc.h Fix CR insn patterns.
+
+Fri May 6 14:34:46 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c (powerpc_opcodes): Put PowerPC versions of "cmp" and
+ "cmpl" before POWER versions, so that gas -many uses them.
+
+Thu Apr 28 18:32:36 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * disassemble.c: New file.
+ * Makefile.in (OFILES): Add disassemble.o.
+ (disassemble.o): Provide dependencies; compile with $(ARCHDEFS).
+ * configure.in: Define ARCHDEFS in Makefile. Code taken from
+ binutils/configure.in.
+
+ * m68k-dis.c (print_insn_m68k): If F_ALIAS flag is set, skip the
+ opcode being examined.
+
+Thu Apr 21 17:08:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c (powerpc_operands): Added RAL, RAM and RAS.
+ (insert_ral, insert_ram, insert_ras): New functions.
+ (powerpc_opcodes): Use RAL for load with update, RAM for lmw, and
+ RAS for store with update.
+
+Sat Apr 16 23:41:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c (powerpc_opcodes): Correct fcir. From David Edelsohn
+ (edelsohn@npac.syr.edu).
+
+Wed Apr 6 17:11:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c (mips_opcodes): Correct operands of "nor" with an
+ immediate argument.
+
+Mon Apr 4 16:30:46 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * sparc-opc.c (sparc_opcodes): Fix "rd %fprs,%l0".
+
+Mon Apr 4 13:22:00 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c (powerpc_operands): The signedp field has been
+ removed, so don't initialize it. Set the PPC_OPERAND_SIGNED flag
+ instead. Add new operand SISIGNOPT.
+ (powerpc_opcodes): For lis, liu, addis, and cau use SISIGNOPT.
+ Based on patch from David Edelsohn (edelsohn@npac.syr.edu).
+ * ppc-dis.c (print_insn_powerpc): Check PPC_OPERAND_SIGNED rather
+ than signedp field.
+
+Wed Mar 30 00:31:49 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * i386-dis.c (struct private): Renamed to dis_private. `private'
+ is a reserved word for dynix cc.
+
+Mon Mar 28 13:00:15 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Change error message to refer to bfd/config.bfd
+ rather than bfd/configure.in.
+
+Mon Mar 28 12:28:30 1994 David Edelsohn (edelsohn@npac.syr.edu)
+
+ * ppc-opc.c: Define POWER2 as short alias flag.
+ (powerpc_opcodes): Add POWER/2 opcodes lfq*, stfq*, fcir[z], and
+ fsqrt.
+
+Wed Mar 23 12:23:05 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * i960-dis.c (print_insn_i960): Don't read a second word for
+ opcodes 0, 1, 2 and 3.
+
+Wed Mar 16 15:37:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in: Don't build m68881-ext.o for bfd_m68k_arch.
+
+Mon Mar 14 14:53:50 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m68881-ext.c: Removed; no longer used.
+ * Makefile.in: Changed accordingly.
+
+ * m68k-dis.c (ext_format_68881): Don't declare.
+ (print_insn_m68k): If an instruction uses place 'i', it uses at
+ least four fixed bytes.
+ (print_insn_arg): Don't bump p by 2 for case 'I', place 'i'. For
+ extended float, convert to double using floatformat_to_double, not
+ ieee_extended_to_double, and fetch the data before converting it.
+
+Tue Mar 8 18:12:25 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: It's sqrt.s, not sqrt.w. From
+ davidj@ICSI.Berkeley.EDU (David Johnson).
+
+Tue Feb 8 16:55:27 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c (powerpc_opcodes): The POWER uses bdn[l][a] where the
+ PowerPC uses bdnz[l][a].
+
+Tue Feb 8 00:32:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * dis-buf.c, i386-dis.c: Include sysdep.h.
+
+Mon Feb 7 19:22:23 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * configure.in (bfd_powerpc_arch): Use ppc-dis.o and ppc-opc.o.
+
+ * ppc-opc.c (powerpc_opcodes): Mark POWER instructions supported
+ by Motorola PowerPC 601 with PPC_OPCODE_601.
+ * ppc-dis.c (print_insn_big_powerpc, print_insn_little_powerpc):
+ Disassemble Motorola PowerPC 601 instructions as well as normal
+ PowerPC instructions.
+
+Sun Feb 6 07:45:17 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * i960-dis.c (reg, mem): Just use a static array instead of
+ calling xmalloc.
+
+Sat Feb 5 00:04:02 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * hppa-dis.c (print_insn_hppa): For '?' and '@' only adjust the
+ condition name index if this is for a negated condition.
+
+ * hppa-dis.c (print_insn_hppa): No space before 'H' operand.
+ Floating point format for 'H' operand is backwards from normal
+ case (0 == double, 1 == single). For '4', '6', '7', '9', and '8'
+ operands (fmpyadd and fmpysub), handle bizarre register
+ translation correctly for single precision format.
+
+ * hppa-dis.c (print_insn_hppa): Do not emit a space after 'F'
+ or 'I' operands if the next format specifier is 'M' (fcmp
+ condition completer).
+
+Feb 4 23:38:03 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c (powerpc_operands): New operand type MBE to handle a
+ single number giving a bitmask for the MB and ME fields of an M
+ form instruction. Change NB to accept 32, and turn it into 0;
+ also turn 0 into 32 when disassembling. Seperated SH from NB.
+ (insert_mbe, extract_mbe): New functions.
+ (insert_nb, extract_nb): New functions.
+ (SC_MASK): Mask out SA and LK bits.
+ (powerpc_opcodes): Change "cal" to use RT, D, RA rather than RT,
+ RA, SI. Change "liu" and "cau" to use UI rather than SI. Mark
+ "bctr" and "bctrl" as accepted by POWER. Change "rlwimi",
+ "rlimi", "rlwimi.", "rlimi.", "rlwinm", "rlinm", "rlwinm.",
+ "rlinm.", "rlmi", "rlmi.", "rlwnm", "rlnm", "rlwnm.", "rlnm." to
+ use MBE rather than MB. Add "mfmq" and "mtmq" POWER instructions.
+ (powerpc_macros): Define table of macro definitions.
+ (powerpc_num_macros): Define.
+
+ * ppc-dis.c (print_insn_powerpc): Don't skip optional operands
+ if PPC_OPERAND_NEXT is set.
+
+Sat Jan 22 23:10:07 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * i960-dis.c (print_insn_i960): Make buffer bfd_byte instead of
+ char. Retrieve contents using bfd_getl32 instead of shifting.
+
+Fri Jan 21 19:01:39 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * ppc-opc.c: New file. Opcode table for PowerPC, including
+ opcodes for POWER (RS/6000).
+ * ppc-dis.c: New file. PowerPC and Power (RS/6000) disassembler.
+ * Makefile.in (ALL_MACHINES): Add ppc-dis.o and ppc-opc.o.
+ (CFILES): Add ppc-dis.c.
+ (ppc-dis.o, ppc-opc.o): New targets.
+ * configure.in: Build ppc-dis.o and ppc-opc.o for bfd_rs6000_arch.
+
+Mon Jan 17 20:05:49 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * hppa-dis.c (print_insn_hppa): Handle 'N' in assembler template.
+ No space before 'u', 'f', or 'N'.
+
+Sun Jan 16 14:20:16 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * i386-dis.c (print_insn_i386): Add FIXME comment regarding reading
+ farther than we should.
+
+ * i386-dis.c (dis386): Use Yb and Yv for scasb and scasS.
+
+Thu Jan 6 12:38:05 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * sparc-dis.c m68k-dis.c alpha-dis.c a29k-dis.c: Fix comments.
+
+Wed Jan 5 11:56:21 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * i960-dis.c (print_insn_i960): Only read word2 if the instruction
+ needs it, to prevent reading past the end of a section.
+
+Wed Nov 17 17:20:12 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.h: Use macro for j instruction, to support SVR4 PIC.
+ Removed t,A case for la; always use t,A(b) case.
+
+Mon Nov 8 12:37:36 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ From Ted Lemen <mellon@pepper.ncd.com>
+ * mips-dis.c (print_insn_arg): Handle 'k'.
+ * mips-opc.c: Make cache use k, not t.
+
+Sun Nov 7 23:52:34 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * alpha-opc.h, alpha-dis.c (print_insn_alpha): Add
+ FLOAT_MEMORY_FORMAT_CODE, FLOAT_BRANCH_FORMAT_CODE, correct
+ FLOAT_FORMAT_CODE to put out floating point register names.
+
+Mon Nov 1 18:17:51 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Use macros for jal variants, to support SVR4 PIC.
+
+Thu Oct 28 17:42:23 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * a29k-dis.c (print_insn): Use 0x%08x, not 0x%8x.
+
+Wed Oct 27 11:48:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c (dsll, dsra, dsrl): Added '>' cases for shift counts
+ larger than 32. Moved dsxx32 variants first for disassembler.
+
+Mon Oct 25 11:33:14 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * z8kgen.c, z8k-opc.h: Add full lda information.
+
+Tue Oct 19 12:39:25 1993 Jeffrey A Law (law@cs.utah.edu)
+
+ * hppa-dis.c (print_insn_hppa): Do not emit a space after
+ movb instructions. Any necessary space will be emitted by
+ the code to handle nullification completers.
+
+Wed Oct 13 16:19:07 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Moved l.d down so that it disassembles as ldc1.
+
+Fri Oct 8 02:34:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * alpha-opc.h: Add ldl_l, fix typo for ldq_u.
+ * alpha-dis.c (print_insn_alpha): Add code for PAL_FORMAT_CODE.
+
+Tue Oct 5 17:47:53 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Correct lwu opcode value (book had it wrong).
+
+Thu Sep 30 11:26:18 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * z8k-dis.c (FETCH_DATA): get just the right amount of data.
+ (unpack_instr): Cope with ARG_IMM4M1 type instructions.
+
+Wed Sep 29 16:24:49 1993 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * m88k-dis.c (m88kdis): comment change. Remove space after
+ printing mnemonic.
+ (printop): handle new arg types DEC and XREG for m88110.
+
+Tue Sep 28 19:20:16 1993 Jeffrey A Law (law@snake.cs.utah.edu)
+
+ * hppa-dis.c (print_insn_hppa): Handle 'z' operand
+ type for absolute branch addresses. Delete special
+ "ble" and "be" code in 'W' operand code.
+
+Fri Sep 24 14:08:33 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Set hazard information correctly for branch
+ likely instructions.
+
+Fri Sep 17 04:41:17 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * alpha-dis.c (print_insn_alpha), alpha-opc.h: Fix bugs, use
+ info->fprintf_func for printing and info->print_address_func for
+ address output.
+
+Wed Sep 15 12:12:07 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Set INSN_TRAP for tXX instructions.
+
+Thu Sep 9 10:11:27 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: From davidj@ICSI.Berkeley.EDU (David Johnson):
+ Corrected second case of "b" for disassembler.
+
+Tue Sep 7 14:25:15 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-dis.c, m88k-dis.c: Don't include libbfd.h. Changed calls
+ to BFD swapping routines to correspond to BFD name changes.
+
+Thu Sep 2 10:35:25 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Change div machine instruction to be z,s,t rather
+ than s,t. Change div macro to be d,v,t rather than d,s,t.
+ Likewise for divu, ddiv, ddivu. Added z,s,t case for drem, dremu,
+ rem and remu which generates only the corresponding div
+ instruction. This is for compatibility with the MIPS assembler,
+ which only generates the simple machine instruction when an
+ explicit destination of $0 is used.
+ * mips-dis.c (print_insn_arg): Handle 'z' (always register zero).
+
+Thu Aug 26 17:41:44 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: From davidj@ICSI.Berkeley.EDU (David Johnson): Set
+ WR_31 hazard for bal, bgezal, bltzal.
+
+Thu Aug 26 17:20:02 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * hppa-dis.c (print_insn_hppa): Use print function
+ from within the disassemble_info, not fprintf_filtered.
+
+Wed Aug 25 13:51:40 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hppa-dis.c (print_insn_hppa): Handle '|' like '>'. (From Jeff
+ Law, law@cs.utah.edu.)
+
+Mon Aug 23 12:44:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c ("absu"): Removed.
+ ("dabs"): Added.
+
+Fri Aug 20 10:52:52 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Added r6000 and r4000 instructions and macros.
+ Changed hazard information to distinguish between memory load
+ delays and coprocessor load delays.
+
+Wed Aug 18 15:39:23 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: li.d uses "T,L", not "S,F". Added li.s.
+
+Tue Aug 17 09:44:42 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * configure.in: Don't pass cpu to config.bfd.
+
+Tue Aug 17 12:23:52 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m88k-dis.c (m88kdis): Make class unsigned.
+
+Thu Aug 12 15:08:18 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * alpha-dis.c (print_insn_alpha): One branch format case was
+ missing the instruction name.
+
+Wed Aug 11 19:29:39 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * Makefile.in (ALL_MACHINES): Renamed from DIS_LIBS.
+ Add the arch-specific auxiliary files.
+ (OFILES): Remove the arch-specific auxiliary files
+ and use BFD_MACHINES instead of DIS_LIBS.
+ * configure.in: Set BFD_MACHINES based on --with-targets option.
+
+Thu Aug 12 12:04:53 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: Added lwc1 E,A(b) to go with lwc1 T,A(b). Similarly
+ for swc1.
+
+Sun Aug 8 15:09:30 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * sparc-opc.c: Change CONST to const to deal with gcc
+ -Dconst=__const -traditional.
+
+Fri Aug 6 10:58:55 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-opc.c: From davidj@ICSI.Berkeley.EDU (David Johnson): Took
+ coprocessor instructions out of #if 0, and made them use new
+ argument type "C".
+
+Thu Aug 5 17:11:06 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * sparc-dis.c: Include ansidecl.h before opcodes/sparc.h.
+
+Fri Jul 30 18:48:15 1993 John Gilmore (gnu@cygnus.com)
+
+ * sparc-opc.c: Add F_JSR, F_UNBR, or F_CONDBR flags to each branch
+ instruction, for use by the disassembler.
+
+ * sparc-dis.c (SEX): Add sign extension macro. Replace many
+ hand-coded sign extensions that depended on 32-bit host ints.
+ FIXME, we still depend on big-endian host bitfield ordering.
+ (sparc_print_insn): Set the insn_info_valid field, and the
+ other fields that describe the instruction being printed.
+
+Tue Jul 27 17:04:58 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * sparc-opc.c (call): Accept all 6 addressing modes valid for
+ `jmp' instead of just one of them.
+
+Wed Jul 21 11:43:32 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * hppa-dis.c: Move floating registers from reg_names to fp_reg_names.
+ (fput_fp_reg_r): Renamed from fput_reg_r.
+ (fput_fp_reg): New function.
+ (print_insn_hppa): Use fput_fp_reg{,_r} where appropriate.
+
+ * hppa-dis.c (print_insn_hppa, cases 'a', 'd'): Print space afterwards.
+
+ * hppa-dis.c (print_insn_hppa, case 'd'): Use GET_COND not GET_FIELD.
+
+Mon Jul 19 13:52:21 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * hppa-dis.c (print_insn_hppa): Use extract_5r_store for 'r'.
+
+ * hppa-dis.c (print_insn_hppa, case '>'): If next character is 'n',
+ don't output a space.
+
+ * hppa-dis.c (float_format_names): 10 is undefined, and 11 is quad.
+
+Sun Jul 18 16:30:02 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
+
+ * mips-opc.c: New file, containing opcode table from
+ ../include/opcode/mips.h.
+ * Makefile.in: Add it.
+
+Thu Jul 15 12:37:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * m88k-dis.c: New file, moved in from gdb and changed to use the
+ new dis-asm.h disassembler interface.
+ * Makefile.in (DIS_LIBS): Added m88k-dis.o.
+ (m88k-dis.o): New target.
+
+Tue Jul 13 10:04:16 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips-dis.c (print_insn_arg, _print_insn_mips): Made pointer to
+ argument string const char * to correspond to opcode/mips.h.
+
+Tue Jul 6 15:18:37 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * mips-dis.c: Updated to account for name changes in new version
+ of opcode/mips.h.
+ * Makefile.in: Added header file dependencies.
+
+Sat Jul 3 23:47:56 1993 Doug Evans (dje@canuck.cygnus.com)
+
+ * h8300-dis.c (bfd_h8_disassemble): Correct fetching of instruction.
+
+Thu Jul 1 12:23:38 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * m68k-dis.c (NEXTWORD, NEXTLONG): Use ((x) ^ 0x8000) - 0x8000 to sign
+ extend, rather than shifts.
+
+Sun Jun 20 20:56:56 1993 Ken Raeburn (raeburn@poseidon.cygnus.com)
+
+ * Makefile.in: Undo 15 June change.
+
+Fri Jun 18 14:15:15 1993 Per Bothner (bothner@deneb.cygnus.com)
+
+ * m68k-dis.c (print_insn_arg): Change return value to byte count
+ or error code.
+ * m68k-dis.c: Re-write to detect invalid operands before
+ printing anything, so we can handle this the same way we
+ handle invalid opcodes.
+
+Thu Jun 17 15:01:36 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * sh-dis.c, sh-opc.h: Understand some more opcodes.
+
+Wed Jun 16 13:48:05 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * hppa-dis.c: Include <ansidecl.h> and sysdep.h before other
+ header files.
+
+Tue Jun 15 21:45:26 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * sparc-dis.c: Don't declare qsort, since sysdep.h might.
+
+ * configure.in: Do make sysdep.h link.
+ * Makefile.in: Search ../include. Don't search ../bfd.
+
+Tue Jun 15 13:36:10 1993 Stu Grossman (grossman@cygnus.com)
+
+ Changes from Jeff Law, law@cs.utah.edu:
+ * hppa-dis.c: Fix typo. 'a' and 'd' were reversed.
+ Do not print a space before the completers specified by
+ 'a' and 'd'.
+
+Fri Jun 11 18:40:21 1993 Ken Raeburn (raeburn@cygnus.com)
+
+ * mips-dis.c: No longer need to bomb out if HOST_64_BIT is
+ defined, since gdb has been fixed.
+
+ Changes from Jeff Law, law@cs.utah.edu:
+ * hppa-dis.c (print_insn_hppa): Last argument to fput_reg,
+ fput_reg_r, fput_creg, fput_const, and fputs_filtered should
+ be a *disassemble_info, not a *FILE.
+ * hppa-dis.c: Support 'd', '!', and 'a'.
+ * hppa-dis.c: Support 's' to extract a 2 bit space register.
+ * hppa-dis.c: Delete cases which are no longer needed.
+
+Fri Jun 11 07:53:48 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * m68k-dis.c (print_insn_{m68k,arg}): Add MMU codes.
+
+Tue Jun 8 12:25:01 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
+
+ * h8300-dis.c: New file, removed from bfd/cpu-h8300.c, with
+ H8/300-H opcodes.
+
+Mon Jun 7 12:58:49 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in (CSEARCH): Add -I../bfd for sysdep.h and bfd.h.
+ * configure.in: No longer need to configure to get sysdep.h.
+
+Thu Jun 3 15:56:49 1993 Stu Grossman (grossman@cygnus.com)
+
+ * Patches from Jeffrey Law <law@cs.utah.edu>.
+ * hppa-dis.c: Support 'I', 'J', and 'K' in output
+ templates for 1.1 FP computational instructions.
+
+Tue May 25 13:05:48 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * h8500-dis.c (print_insn_h8500): Address argument is type
+ bfd_vma.
+ * z8k-dis.c (print_insn_z8k, print_insn_z8001, print_insn_z8002):
+ Ditto.
+
+ * h8500-opc.h (addr_class_type): No comma at end of enumerator.
+ * sh-opc.h (sh_nibble_type, sh_arg_type): Ditto.
+
+ * sparc-dis.c (compare_opcodes): Move static declaration to
+ top-level.
+
+Fri May 21 14:17:37 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * sparc-dis.c (print_insn_sparc): Implement 'n' argument for unimp
+ instruction, remove unimp hack from 'l' argument.
+
+Wed May 19 15:35:54 1993 Stu Grossman (grossman@cygnus.com)
+
+ * z8k-dis.c (fetch_data): Use unsigned char to make ancient gcc's
+ happy.
+
+Fri May 14 15:22:46 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * Based on patches from davidj@ICSI.Berkeley.EDU (David Johnson):
+ * mips-dis.c (print_insn_arg): Handle 'C' for general coprocessor
+ instructions.
+
+Fri May 14 00:09:14 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hppa-dis.c: Include dis-asm.h before sysdep.h. Changed some
+ arrays of string pointers to 2-d arrays of chars, to save
+ space.
+
+Thu May 6 20:51:17 1993 Fred Fish (fnf@cygnus.com)
+
+ * a29k-dis.c, alpha-dis.c, i960-dis.c, sparc-dis.c, z8k-dis.c:
+ Cast second arg to read_memory_func to "bfd_byte *", as necessary.
+
+Tue May 4 20:31:10 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * hppa-dis.c: New file from Utah, adapted to new disassembler
+ calling interface.
+ * Makefile.in: Include it.
+
+Mon Apr 26 18:17:42 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * sh-dis.c, sh-opc.h: New files.
+
+Fri Apr 23 18:51:22 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * alpha-dis.c, alpha-opc.h: New files.
+
+Tue Apr 6 12:54:08 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * mips-dis.c: Sign extend 'j' and 'b' arguments, delta is a signed
+ value.
+
+Mon Apr 5 17:37:37 1993 John Gilmore (gnu@cygnus.com)
+
+ * sparc-dis.c: Make "ta" the default trap instruction, "t" the alias.
+
+Fri Apr 2 07:24:27 1993 Ian Lance Taylor (ian@cygnus.com)
+
+ * a29k-dis.c, sparc-dis.c, sparc-opc.c: Use CONST rather than
+ const.
+
+Thu Apr 1 11:20:43 1993 Jim Kingdon (kingdon@cygnus.com)
+
+ * sparc-dis.c: Use fprintf_func a few places where I forgot,
+ and double percent signs a few places.
+
+ * a29k-dis.c, i960-dis.c: New, merged from gdb and binutils.
+
+ * i386-dis.c, m68k-dis.c, mips-dis.c, sparc-dis.c:
+ Use info->print_address_func not print_address.
+
+ * dis-buf.c (generic_print_address): New function.
+
+Wed Mar 31 10:07:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * Makefile.in: Add sparc-dis.c.
+ sparc-dis.c: New file, merges binutils and gdb versions as follows:
+ From GDB:
+ Add `add' instruction to the set that get checked
+ for a preceding `sethi' in order to print an absolute address.
+ * (print_insn): Disassembly prefers real instructions.
+ (is_delayed_branch): Speed up.
+ * sparc-opcode.h: Add ALIAS bit to aliases. Fix up opcode tables.
+ Still missing some float ops, and needs testing.
+ * sparc-pinsn.c (print_insn): Eliminate 'set' test, subsumed by
+ F_ALIAS. Use printf, not fprintf, when not passing a file
+ pointer...
+ (compare_opcodes): Check that identical instructions have
+ identical opcodes, complain otherwise.
+ From binutils:
+ * New 'm' arg.
+ * Include reg_names.
+ From neither:
+ Use dis-asm.h/read_memory_func interface.
+
+Wed Mar 31 20:49:06 1993 K. Richard Pixley (rich@rtl.cygnus.com)
+
+ * h8500-dis.c, i386-dis.c, m68k-dis.c, z8k-dis.c (fetch_data):
+ deliberately return non-zero to setjmp from longjmp. Otherwise
+ this code fails to compile.
+
+Wed Mar 31 17:04:31 1993 Stu Grossman (grossman@cygnus.com)
+
+ * m68k-dis.c: Fix prototype for fetch_arg().
+
+Wed Mar 31 10:07:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * dis-buf.c: New file, for new read_memory_func interface.
+ Makefile.in (OFILES): Include it.
+ m68k-dis.c, i386-dis.c, h8500-dis.c, mips-dis.c, z8k-dis.c:
+ Use new read_memory_func interface.
+
+Mon Mar 29 14:02:17 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * h8500-dis.c (print_insn_h8500): Get sign of fp offsets right.
+ * h8500-opc.h: Fix couple of opcodes.
+
+Wed Mar 24 02:03:36 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
+
+ * Makefile.in: add dvi & installcheck targets
+
+Mon Mar 22 18:55:04 1993 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in: Update for h8500-dis.c.
+
+Fri Mar 19 14:27:17 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * h8500-dis.c, h8500-opc.h: New files
+
+Thu Mar 18 14:12:37 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * mips-dis.c, z8k-dis.c: Converted to use interface defined in
+ ../include/dis-asm.h.
+ * m68k-dis.c: New file (merge of ../binutils/m68k-pinsn.c
+ and ../gdb/m68k-pinsn.c).
+ * i386-dis.c: New file (merge of ../binutils/i386-pinsn.c
+ and ../gdb/i386-pinsn.c).
+ * m68881-ext.c: New file. Moved definition of
+ ext_format ext_format_68881 from ../gdb/m68k-tdep.c.
+ * Makefile.in: Adjust for new files.
+ * i386-dis.c: Patches from John Hassey (hassey@dg-rtp.dg.com).
+ * m68k-dis.c: Recognize '9' placement code, so (say) pflush
+ can be dis-assembled.
+
+Wed Feb 17 09:19:47 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * mips-dis.c (print_insn_arg): Now returns void.
+
+Mon Jan 11 16:09:16 1993 Fred Fish (fnf@cygnus.com)
+
+ * mips-dis.c (ansidecl.h): Include for benefit of sysdep.h
+ files that use the macros.
+
+Thu Jan 7 13:15:17 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * mips-dis.c: New file, from gdb/mips-pinsn.c.
+ * Makefile.in (DIS_LIBS): Added mips-dis.o.
+ (CFILES): Added mips-dis.c.
+
+Thu Jan 7 07:36:33 1993 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * z8k-dis.c (print_insn_z8001, print_insn_z8002): new routines
+ * z8kgen.c, z8k-opc.h: fix sizes of some shifts.
+
+Tue Dec 22 15:42:44 1992 Per Bothner (bothner@rtl.cygnus.com)
+
+ * Makefile.in: Improve *clean rules.
+ * configure.in: Allow a default host.
+
+Tue Nov 17 19:53:54 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * Makefile.in: also use -I$(srcdir)/../bfd, since some sysdep
+ files include other sysdep files
+
+Thu Nov 12 16:10:37 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * z8k-dis.c z8k-opc.h z8kgen.c: checkpoint
+
+Fri Oct 9 04:56:05 1992 John Gilmore (gnu@cygnus.com)
+
+ * configure.in: For host support, use ../bfd/configure.host
+ so it stays in sync with the ../bfd/hosts database.
+
+Thu Oct 1 23:38:54 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
+
+ * configure.in: use cpu-vendor-os triple instead of nested cases
+
+Wed Sep 30 16:09:20 1992 Michael Werner (mtw@cygnus.com)
+
+ * z8k-dis.c (unparse_instr): fix bug where opcode returned was
+ *always* the wrong one.
+
+Wed Sep 30 07:42:17 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * z8kgen.c: added copyright info
+
+Tue Sep 29 12:20:21 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * z8k-dis.c (unparse_instr): prettier tabs
+ * z8kgen.c -> z8k-opc.h: bug fixes in tables
+
+Fri Sep 25 12:50:32 1992 Stu Grossman (grossman at cygnus.com)
+
+ * configure.in: Add ncr* configuration.
+ * z8k-dis.c (struct instr_data_s): Make instr_asmsrc char to make
+ picayune ANSI compilers happy.
+
+Sep 20 08:50:55 1992 Fred Fish (fnf@cygnus.com)
+
+ * configure.in (i386): Make i386 and i486 synonymous for now.
+ * configure.in (i[34]86-*-sysv4): Add my_host definition.
+
+Fri Sep 18 17:01:23 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (install): Fix typo.
+
+Fri Sep 18 02:04:24 1992 John Gilmore (gnu@cygnus.com)
+
+ * Makefile.in (make): Remove obsolete crud.
+ (sparc-opc.o): Avoid Sun Make VPATH bug.
+
+Tue Sep 8 17:29:27 1992 K. Richard Pixley (rich@sendai.cygnus.com)
+
+ * Makefile.in: since there are no SUBDIRS, remove rule and
+ references of subdir_do.
+
+Tue Sep 8 17:02:58 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
+
+ * Makefile.in (install): Get the library name right here too.
+ Don't install bfd.h, since it's unrelated to this library. No
+ subdirs to recurse into, either.
+ (CFILES): The source file has a .c suffix, not .o.
+
+ * sparc-opc.c: New file, moved from BFD.
+ * Makefile.in (OFILES): Build it.
+
+Thu Sep 3 16:59:20 1992 Michael Werner (mtw@cygnus.com)
+
+ * z8k-dis.c: fixed forward refferences of some declarations.
+
+Mon Aug 31 16:09:45 1992 Michael Werner (mtw@cygnus.com)
+
+ * Makefile.in: get the name of the library right
+
+Mon Aug 31 13:47:35 1992 Steve Chamberlain (sac@thepub.cygnus.com)
+
+ * z8k-dis.c: knows how to disassemble z8k stuff
+ * z8k-opc.h: new file full of z8000 opcodes
+
+
+Local Variables:
+version-control: never
+End:
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
new file mode 100644
index 00000000000..d997298d1d4
--- /dev/null
+++ b/opcodes/Makefile.am
@@ -0,0 +1,348 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+SUBDIRS = po
+
+INCDIR = $(srcdir)/../include
+BFDDIR = $(srcdir)/../bfd
+DEP = mkdep
+
+lib_LTLIBRARIES = libopcodes.la
+
+# This is where bfd.h lives.
+BFD_H = ../bfd/bfd.h
+
+# Header files.
+HFILES = \
+ arm-opc.h \
+ fr30-desc.h fr30-opc.h \
+ h8500-opc.h \
+ m32r-desc.h m32r-opc.h \
+ mcore-opc.h \
+ sh-opc.h \
+ sysdep.h \
+ w65-opc.h \
+ z8k-opc.h
+
+# C source files that correspond to .o's.
+CFILES = \
+ a29k-dis.c \
+ alpha-dis.c \
+ alpha-opc.c \
+ arm-dis.c \
+ cgen-asm.c \
+ cgen-dis.c \
+ cgen-opc.c \
+ d10v-dis.c \
+ d10v-opc.c \
+ d30v-dis.c \
+ d30v-opc.c \
+ dis-buf.c \
+ disassemble.c \
+ fr30-asm.c \
+ fr30-desc.c \
+ fr30-dis.c \
+ fr30-ibld.c \
+ fr30-opc.c \
+ h8300-dis.c \
+ h8500-dis.c \
+ hppa-dis.c \
+ i386-dis.c \
+ i960-dis.c \
+ m32r-asm.c \
+ m32r-desc.c \
+ m32r-dis.c \
+ m32r-ibld.c \
+ m32r-opc.c \
+ m32r-opinst.c \
+ m68k-dis.c \
+ m68k-opc.c \
+ m88k-dis.c \
+ mcore-dis.c \
+ mips-dis.c \
+ mips-opc.c \
+ mips16-opc.c \
+ m10200-dis.c \
+ m10200-opc.c \
+ m10300-dis.c \
+ m10300-opc.c \
+ ns32k-dis.c \
+ ppc-dis.c \
+ ppc-opc.c \
+ sh-dis.c \
+ sparc-dis.c \
+ sparc-opc.c \
+ tic30-dis.c \
+ tic80-dis.c \
+ tic80-opc.c \
+ vax-dis.c \
+ w65-dis.c \
+ z8k-dis.c \
+ z8kgen.c
+
+ALL_MACHINES = \
+ a29k-dis.lo \
+ alpha-dis.lo \
+ alpha-opc.lo \
+ arc-dis.lo \
+ arc-opc.lo \
+ arm-dis.lo \
+ cgen-asm.lo \
+ cgen-dis.lo \
+ cgen-opc.lo \
+ d10v-dis.lo \
+ d10v-opc.lo \
+ d30v-dis.lo \
+ d30v-opc.lo \
+ fr30-asm.lo \
+ fr30-desc.lo \
+ fr30-dis.lo \
+ fr30-ibld.lo \
+ fr30-opc.lo \
+ h8300-dis.lo \
+ h8500-dis.lo \
+ hppa-dis.lo \
+ i386-dis.lo \
+ i960-dis.lo \
+ m32r-asm.lo \
+ m32r-desc.lo \
+ m32r-dis.lo \
+ m32r-ibld.lo \
+ m32r-opc.lo \
+ m32r-opinst.lo \
+ m68k-dis.lo \
+ m68k-opc.lo \
+ m88k-dis.lo \
+ m10200-dis.lo \
+ m10200-opc.lo \
+ m10300-dis.lo \
+ m10300-opc.lo \
+ mcore-dis.lo \
+ mips-dis.lo \
+ mips-opc.lo \
+ mips16-opc.lo \
+ ppc-dis.lo \
+ ppc-opc.lo \
+ ns32k-dis.lo \
+ sh-dis.lo \
+ sparc-dis.lo \
+ sparc-opc.lo \
+ tic30-dis.lo \
+ tic80-dis.lo \
+ tic80-opc.lo \
+ v850-dis.lo \
+ v850-opc.lo \
+ vax-dis.lo \
+ w65-dis.lo \
+ z8k-dis.lo
+
+OFILES = @BFD_MACHINES@
+
+INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl
+
+disassemble.lo: disassemble.c $(INCDIR)/dis-asm.h
+ $(LIBTOOL) --mode=compile $(COMPILE) -c @archdefs@ $(srcdir)/disassemble.c
+
+libopcodes_la_SOURCES = dis-buf.c disassemble.c
+libopcodes_la_DEPENDENCIES = $(OFILES)
+libopcodes_la_LIBADD = $(OFILES) @WIN32LIBADD@
+libopcodes_la_LDFLAGS = -release $(VERSION) @WIN32LDFLAGS@
+
+# libtool will build .libs/libopcodes.a. We create libopcodes.a in
+# the build directory so that we don't have to convert all the
+# programs that use libopcodes.a simultaneously. This is a hack which
+# should be removed if everything else starts using libtool. FIXME.
+
+noinst_LIBRARIES = libopcodes.a
+
+stamp-lib: libopcodes.la
+ if [ -f .libs/libopcodes.a ]; then \
+ cp .libs/libopcodes.a libopcodes.tmp; \
+ $(SHELL) $(srcdir)/../move-if-change libopcodes.tmp libopcodes.a; \
+ else true; fi
+ touch stamp-lib
+
+libopcodes.a: stamp-lib ; @true
+
+POTFILES = $(HFILES) $(CFILES)
+po/POTFILES.in: @MAINT@ Makefile
+ for file in $(POTFILES); do echo $$file; done | sort > tmp \
+ && mv tmp $(srcdir)/po/POTFILES.in
+
+# We should reconfigure whenever bfd/configure.in changes, because
+# that's where the version number comes from.
+config.status: $(srcdir)/configure $(srcdir)/../bfd/configure.in
+ $(SHELL) ./config.status --recheck
+
+CLEANFILES = \
+ libopcodes.a stamp-lib dep.sed .dep .dep1
+
+
+
+# The start marker is written this way to pass through automake unscathed.
+
+
+
+
+# This dependency stuff is copied from BFD.
+
+.dep: dep.sed $(CFILES) $(HFILES) config.h
+ rm -f .dep1
+ $(MAKE) DEP=$(DEP) .dep1
+ sed -f dep.sed < .dep1 > .dep
+
+.dep1: $(CFILES)
+ rm -f .dep2 .dep2a
+ echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2
+ echo > .dep2a
+ $(DEP) -f .dep2a $(INCLUDES) $(CFLAGS) $?
+ sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2
+ rm -f .dep2a
+ $(srcdir)/../move-if-change .dep2 .dep1
+
+dep.sed: dep-in.sed config.status
+ sed <$(srcdir)/dep-in.sed >dep.sed \
+ -e 's!@BFD_H@!$(BFD_H)!' \
+ -e 's!@INCDIR@!$(INCDIR)!' \
+ -e 's!@BFDDIR@!$(BFDDIR)!' \
+ -e 's!@SRCDIR@!$(srcdir)!'
+
+dep: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
+ cat .dep >> tmp-Makefile
+ $(srcdir)/../move-if-change tmp-Makefile Makefile
+
+dep-in: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
+ cat .dep >> tmp-Makefile.in
+ $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
+
+dep-am: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am
+ cat .dep >> tmp-Makefile.am
+ $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am
+
+.PHONY: dep dep-in dep-am
+
+# What appears below is generated by a hacked mkdep using gcc -MM.
+
+# DO NOT DELETE THIS LINE -- mkdep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+a29k-dis.lo: a29k-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/opcode/a29k.h
+alpha-dis.lo: alpha-dis.c $(INCDIR)/ansidecl.h sysdep.h \
+ config.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/opcode/alpha.h
+alpha-opc.lo: alpha-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/alpha.h \
+ $(BFD_H) opintl.h
+arm-dis.lo: arm-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h arm-opc.h $(INCDIR)/coff/internal.h \
+ $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h opintl.h $(BFDDIR)/elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h
+cgen-asm.lo: cgen-asm.c sysdep.h config.h $(INCDIR)/libiberty.h \
+ $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h \
+ opintl.h
+cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/libiberty.h \
+ $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h
+cgen-opc.lo: cgen-opc.c sysdep.h config.h $(INCDIR)/libiberty.h \
+ $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h
+d10v-dis.lo: d10v-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/d10v.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+d10v-opc.lo: d10v-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/d10v.h
+d30v-dis.lo: d30v-dis.c $(INCDIR)/opcode/d30v.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h opintl.h
+d30v-opc.lo: d30v-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/d30v.h
+dis-buf.lo: dis-buf.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) opintl.h
+disassemble.lo: disassemble.c $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+fr30-asm.lo: fr30-asm.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-desc.lo: fr30-desc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-dis.lo: fr30-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-ibld.lo: fr30-ibld.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-opc.lo: fr30-opc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h
+h8300-dis.lo: h8300-dis.c $(INCDIR)/opcode/h8300.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/ansidecl.h opintl.h
+h8500-dis.lo: h8500-dis.c h8500-opc.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h opintl.h
+hppa-dis.lo: hppa-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(BFDDIR)/libhppa.h $(INCDIR)/opcode/hppa.h
+i386-dis.lo: i386-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h sysdep.h config.h opintl.h
+i960-dis.lo: i960-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h
+m32r-asm.lo: m32r-asm.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-desc.lo: m32r-desc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-dis.lo: m32r-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-ibld.lo: m32r-ibld.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-opc.lo: m32r-opc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h
+m32r-opinst.lo: m32r-opinst.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h
+m68k-dis.lo: m68k-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/floatformat.h opintl.h \
+ $(INCDIR)/opcode/m68k.h
+m68k-opc.lo: m68k-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/m68k.h
+m88k-dis.lo: m88k-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/opcode/m88k.h opintl.h
+mcore-dis.lo: mcore-dis.c mcore-opc.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+mips-dis.lo: mips-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/opcode/mips.h opintl.h $(BFDDIR)/elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h
+mips-opc.lo: mips-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mips.h
+mips16-opc.lo: mips16-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mips.h
+m10200-dis.lo: m10200-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10200.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) opintl.h
+m10200-opc.lo: m10200-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10200.h
+m10300-dis.lo: m10300-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10300.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) opintl.h
+m10300-opc.lo: m10300-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10300.h
+ns32k-dis.lo: ns32k-dis.c $(BFD_H) $(INCDIR)/ansidecl.h \
+ sysdep.h config.h $(INCDIR)/dis-asm.h $(INCDIR)/opcode/ns32k.h \
+ opintl.h
+ppc-dis.lo: ppc-dis.c $(INCDIR)/ansidecl.h sysdep.h \
+ config.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/opcode/ppc.h
+ppc-opc.lo: ppc-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/ppc.h \
+ opintl.h
+sh-dis.lo: sh-dis.c sh-opc.h $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h
+sparc-dis.lo: sparc-dis.c $(INCDIR)/ansidecl.h sysdep.h \
+ config.h $(INCDIR)/opcode/sparc.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/libiberty.h opintl.h
+sparc-opc.lo: sparc-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/sparc.h
+tic30-dis.lo: tic30-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic30.h
+tic80-dis.lo: tic80-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic80.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+tic80-opc.lo: tic80-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic80.h
+vax-dis.lo: vax-dis.c $(INCDIR)/opcode/vax.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h
+w65-dis.lo: w65-dis.c w65-opc.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h
+z8k-dis.lo: z8k-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) z8k-opc.h
+z8kgen.lo: z8kgen.c sysdep.h config.h
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
new file mode 100644
index 00000000000..ed8f64f9cd5
--- /dev/null
+++ b/opcodes/Makefile.in
@@ -0,0 +1,858 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = .
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+AR = @AR@
+AS = @AS@
+BFD_MACHINES = @BFD_MACHINES@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+DATADIRNAME = @DATADIRNAME@
+DLLTOOL = @DLLTOOL@
+EXEEXT = @EXEEXT@
+EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GT_NO = @GT_NO@
+GT_YES = @GT_YES@
+HDEFINES = @HDEFINES@
+INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
+INSTOBJEXT = @INSTOBJEXT@
+INTLDEPS = @INTLDEPS@
+INTLLIBS = @INTLLIBS@
+INTLOBJS = @INTLOBJS@
+LD = @LD@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+NM = @NM@
+PACKAGE = @PACKAGE@
+POFILES = @POFILES@
+POSUB = @POSUB@
+RANLIB = @RANLIB@
+USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
+USE_NLS = @USE_NLS@
+USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
+VERSION = @VERSION@
+WIN32LDFLAGS = @WIN32LDFLAGS@
+WIN32LIBADD = @WIN32LIBADD@
+archdefs = @archdefs@
+cgen = @cgen@
+cgendir = @cgendir@
+l = @l@
+
+AUTOMAKE_OPTIONS = cygnus
+
+SUBDIRS = po
+
+INCDIR = $(srcdir)/../include
+BFDDIR = $(srcdir)/../bfd
+DEP = mkdep
+
+lib_LTLIBRARIES = libopcodes.la
+
+# This is where bfd.h lives.
+BFD_H = ../bfd/bfd.h
+
+# Header files.
+HFILES = \
+ arm-opc.h \
+ fr30-desc.h fr30-opc.h \
+ h8500-opc.h \
+ m32r-desc.h m32r-opc.h \
+ mcore-opc.h \
+ sh-opc.h \
+ sysdep.h \
+ w65-opc.h \
+ z8k-opc.h
+
+
+# C source files that correspond to .o's.
+CFILES = \
+ a29k-dis.c \
+ alpha-dis.c \
+ alpha-opc.c \
+ arm-dis.c \
+ cgen-asm.c \
+ cgen-dis.c \
+ cgen-opc.c \
+ d10v-dis.c \
+ d10v-opc.c \
+ d30v-dis.c \
+ d30v-opc.c \
+ dis-buf.c \
+ disassemble.c \
+ fr30-asm.c \
+ fr30-desc.c \
+ fr30-dis.c \
+ fr30-ibld.c \
+ fr30-opc.c \
+ h8300-dis.c \
+ h8500-dis.c \
+ hppa-dis.c \
+ i386-dis.c \
+ i960-dis.c \
+ m32r-asm.c \
+ m32r-desc.c \
+ m32r-dis.c \
+ m32r-ibld.c \
+ m32r-opc.c \
+ m32r-opinst.c \
+ m68k-dis.c \
+ m68k-opc.c \
+ m88k-dis.c \
+ mcore-dis.c \
+ mips-dis.c \
+ mips-opc.c \
+ mips16-opc.c \
+ m10200-dis.c \
+ m10200-opc.c \
+ m10300-dis.c \
+ m10300-opc.c \
+ ns32k-dis.c \
+ ppc-dis.c \
+ ppc-opc.c \
+ sh-dis.c \
+ sparc-dis.c \
+ sparc-opc.c \
+ tic30-dis.c \
+ tic80-dis.c \
+ tic80-opc.c \
+ vax-dis.c \
+ w65-dis.c \
+ z8k-dis.c \
+ z8kgen.c
+
+
+ALL_MACHINES = \
+ a29k-dis.lo \
+ alpha-dis.lo \
+ alpha-opc.lo \
+ arc-dis.lo \
+ arc-opc.lo \
+ arm-dis.lo \
+ cgen-asm.lo \
+ cgen-dis.lo \
+ cgen-opc.lo \
+ d10v-dis.lo \
+ d10v-opc.lo \
+ d30v-dis.lo \
+ d30v-opc.lo \
+ fr30-asm.lo \
+ fr30-desc.lo \
+ fr30-dis.lo \
+ fr30-ibld.lo \
+ fr30-opc.lo \
+ h8300-dis.lo \
+ h8500-dis.lo \
+ hppa-dis.lo \
+ i386-dis.lo \
+ i960-dis.lo \
+ m32r-asm.lo \
+ m32r-desc.lo \
+ m32r-dis.lo \
+ m32r-ibld.lo \
+ m32r-opc.lo \
+ m32r-opinst.lo \
+ m68k-dis.lo \
+ m68k-opc.lo \
+ m88k-dis.lo \
+ m10200-dis.lo \
+ m10200-opc.lo \
+ m10300-dis.lo \
+ m10300-opc.lo \
+ mcore-dis.lo \
+ mips-dis.lo \
+ mips-opc.lo \
+ mips16-opc.lo \
+ ppc-dis.lo \
+ ppc-opc.lo \
+ ns32k-dis.lo \
+ sh-dis.lo \
+ sparc-dis.lo \
+ sparc-opc.lo \
+ tic30-dis.lo \
+ tic80-dis.lo \
+ tic80-opc.lo \
+ v850-dis.lo \
+ v850-opc.lo \
+ vax-dis.lo \
+ w65-dis.lo \
+ z8k-dis.lo
+
+
+OFILES = @BFD_MACHINES@
+
+INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl
+
+libopcodes_la_SOURCES = dis-buf.c disassemble.c
+libopcodes_la_DEPENDENCIES = $(OFILES)
+libopcodes_la_LIBADD = $(OFILES) @WIN32LIBADD@
+libopcodes_la_LDFLAGS = -release $(VERSION) @WIN32LDFLAGS@
+
+# libtool will build .libs/libopcodes.a. We create libopcodes.a in
+# the build directory so that we don't have to convert all the
+# programs that use libopcodes.a simultaneously. This is a hack which
+# should be removed if everything else starts using libtool. FIXME.
+
+noinst_LIBRARIES = libopcodes.a
+
+POTFILES = $(HFILES) $(CFILES)
+
+CLEANFILES = \
+ libopcodes.a stamp-lib dep.sed .dep .dep1
+
+
+
+
+# The start marker is written this way to pass through automake unscathed.
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I.
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libopcodes_a_LIBADD =
+libopcodes_a_SOURCES = libopcodes.a.c
+libopcodes_a_OBJECTS = libopcodes.a.o
+LTLIBRARIES = $(lib_LTLIBRARIES)
+
+libopcodes_la_OBJECTS = dis-buf.lo disassemble.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = ./stamp-h.in ChangeLog Makefile.am Makefile.in \
+acinclude.m4 aclocal.m4 config.in configure configure.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+SOURCES = libopcodes.a.c $(libopcodes_la_SOURCES)
+OBJECTS = libopcodes.a.o $(libopcodes_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4
+ cd $(srcdir) && $(ACLOCAL)
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+ cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h
+ @if test ! -f $@; then \
+ rm -f stamp-h; \
+ $(MAKE) stamp-h; \
+ else :; fi
+stamp-h: $(srcdir)/config.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \
+ $(SHELL) ./config.status
+ @echo timestamp > stamp-h 2> /dev/null
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h.in
+ @if test ! -f $@; then \
+ rm -f $(srcdir)/stamp-h.in; \
+ $(MAKE) $(srcdir)/stamp-h.in; \
+ else :; fi
+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOHEADER)
+ @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+ -rm -f config.h
+
+maintainer-clean-hdr:
+
+mostlyclean-noinstLIBRARIES:
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+distclean-noinstLIBRARIES:
+
+maintainer-clean-noinstLIBRARIES:
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.c.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+mostlyclean-libLTLIBRARIES:
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+
+distclean-libLTLIBRARIES:
+
+maintainer-clean-libLTLIBRARIES:
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+libopcodes.la: $(libopcodes_la_OBJECTS) $(libopcodes_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libopcodes_la_LDFLAGS) $(libopcodes_la_OBJECTS) $(libopcodes_la_LIBADD) $(LIBS)
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+
+@SET_MAKE@
+
+all-recursive install-data-recursive install-exec-recursive \
+installdirs-recursive install-recursive uninstall-recursive install-info-recursive \
+check-recursive installcheck-recursive info-recursive dvi-recursive:
+ @set fnord $(MAKEFLAGS); amf=$$2; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+ @set fnord $(MAKEFLAGS); amf=$$2; \
+ dot_seen=no; \
+ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
+ rev="$$subdir $$rev"; \
+ test "$$subdir" = "." && dot_seen=yes; \
+ done; \
+ test "$$dot_seen" = "no" && rev=". $$rev"; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)config.in$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.in $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ -rm -rf $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+ mkdir $(distdir)/=build
+ mkdir $(distdir)/=inst
+ dc_install_base=`cd $(distdir)/=inst && pwd`; \
+ cd $(distdir)/=build \
+ && ../configure --srcdir=.. --prefix=$$dc_install_base \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) dist
+ -rm -rf $(distdir)
+ @banner="$(distdir).tar.gz is ready for distribution"; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"
+dist: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+dist-all: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+distdir: $(DISTFILES)
+ -rm -rf $(distdir)
+ mkdir $(distdir)
+ -chmod 777 $(distdir)
+ @for file in $(DISTFILES); do \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ cp -pr $$/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+ for subdir in $(SUBDIRS); do \
+ if test "$$subdir" = .; then :; else \
+ test -d $(distdir)/$$subdir \
+ || mkdir $(distdir)/$$subdir \
+ || exit 1; \
+ chmod 777 $(distdir)/$$subdir; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
+ || exit 1; \
+ fi; \
+ done
+info-am:
+info: info-recursive
+dvi-am:
+dvi: dvi-recursive
+check-am:
+check: check-recursive
+installcheck-am:
+installcheck: installcheck-recursive
+install-info-am:
+install-info: install-info-recursive
+all-recursive-am: config.h
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+install-exec-am: install-libLTLIBRARIES
+install-exec: install-exec-recursive
+
+install-data-am:
+install-data: install-data-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-recursive
+uninstall-am: uninstall-libLTLIBRARIES
+uninstall: uninstall-recursive
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) config.h
+all-redirect: all-recursive-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs: installdirs-recursive
+installdirs-am:
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-hdr mostlyclean-noinstLIBRARIES \
+ mostlyclean-compile mostlyclean-libtool \
+ mostlyclean-libLTLIBRARIES mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-recursive
+
+clean-am: clean-hdr clean-noinstLIBRARIES clean-compile clean-libtool \
+ clean-libLTLIBRARIES clean-tags clean-generic \
+ mostlyclean-am
+
+clean: clean-recursive
+
+distclean-am: distclean-hdr distclean-noinstLIBRARIES distclean-compile \
+ distclean-libtool distclean-libLTLIBRARIES \
+ distclean-tags distclean-generic clean-am
+ -rm -f libtool
+
+distclean: distclean-recursive
+ -rm -f config.status
+
+maintainer-clean-am: maintainer-clean-hdr \
+ maintainer-clean-noinstLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-libLTLIBRARIES maintainer-clean-tags \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f config.status
+
+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
+mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
+clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool mostlyclean-libLTLIBRARIES \
+distclean-libLTLIBRARIES clean-libLTLIBRARIES \
+maintainer-clean-libLTLIBRARIES uninstall-libLTLIBRARIES \
+install-libLTLIBRARIES install-data-recursive uninstall-data-recursive \
+install-exec-recursive uninstall-exec-recursive installdirs-recursive \
+uninstalldirs-recursive all-recursive check-recursive \
+installcheck-recursive info-recursive dvi-recursive \
+mostlyclean-recursive distclean-recursive clean-recursive \
+maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-info-am \
+install-info all-recursive-am install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs-am installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+disassemble.lo: disassemble.c $(INCDIR)/dis-asm.h
+ $(LIBTOOL) --mode=compile $(COMPILE) -c @archdefs@ $(srcdir)/disassemble.c
+
+stamp-lib: libopcodes.la
+ if [ -f .libs/libopcodes.a ]; then \
+ cp .libs/libopcodes.a libopcodes.tmp; \
+ $(SHELL) $(srcdir)/../move-if-change libopcodes.tmp libopcodes.a; \
+ else true; fi
+ touch stamp-lib
+
+libopcodes.a: stamp-lib ; @true
+po/POTFILES.in: @MAINT@ Makefile
+ for file in $(POTFILES); do echo $$file; done | sort > tmp \
+ && mv tmp $(srcdir)/po/POTFILES.in
+
+# We should reconfigure whenever bfd/configure.in changes, because
+# that's where the version number comes from.
+config.status: $(srcdir)/configure $(srcdir)/../bfd/configure.in
+ $(SHELL) ./config.status --recheck
+
+
+
+
+# This dependency stuff is copied from BFD.
+
+.dep: dep.sed $(CFILES) $(HFILES) config.h
+ rm -f .dep1
+ $(MAKE) DEP=$(DEP) .dep1
+ sed -f dep.sed < .dep1 > .dep
+
+.dep1: $(CFILES)
+ rm -f .dep2 .dep2a
+ echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2
+ echo > .dep2a
+ $(DEP) -f .dep2a $(INCLUDES) $(CFLAGS) $?
+ sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2
+ rm -f .dep2a
+ $(srcdir)/../move-if-change .dep2 .dep1
+
+dep.sed: dep-in.sed config.status
+ sed <$(srcdir)/dep-in.sed >dep.sed \
+ -e 's!@BFD_H@!$(BFD_H)!' \
+ -e 's!@INCDIR@!$(INCDIR)!' \
+ -e 's!@BFDDIR@!$(BFDDIR)!' \
+ -e 's!@SRCDIR@!$(srcdir)!'
+
+dep: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
+ cat .dep >> tmp-Makefile
+ $(srcdir)/../move-if-change tmp-Makefile Makefile
+
+dep-in: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
+ cat .dep >> tmp-Makefile.in
+ $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
+
+dep-am: .dep
+ sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am
+ cat .dep >> tmp-Makefile.am
+ $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am
+
+.PHONY: dep dep-in dep-am
+
+# What appears below is generated by a hacked mkdep using gcc -MM.
+
+# DO NOT DELETE THIS LINE -- mkdep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+a29k-dis.lo: a29k-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/opcode/a29k.h
+alpha-dis.lo: alpha-dis.c $(INCDIR)/ansidecl.h sysdep.h \
+ config.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/opcode/alpha.h
+alpha-opc.lo: alpha-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/alpha.h \
+ $(BFD_H) opintl.h
+arm-dis.lo: arm-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h arm-opc.h $(INCDIR)/coff/internal.h \
+ $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h opintl.h $(BFDDIR)/elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h
+cgen-asm.lo: cgen-asm.c sysdep.h config.h $(INCDIR)/libiberty.h \
+ $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h \
+ opintl.h
+cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/libiberty.h \
+ $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h
+cgen-opc.lo: cgen-opc.c sysdep.h config.h $(INCDIR)/libiberty.h \
+ $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h
+d10v-dis.lo: d10v-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/d10v.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+d10v-opc.lo: d10v-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/d10v.h
+d30v-dis.lo: d30v-dis.c $(INCDIR)/opcode/d30v.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h opintl.h
+d30v-opc.lo: d30v-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/d30v.h
+dis-buf.lo: dis-buf.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) opintl.h
+disassemble.lo: disassemble.c $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+fr30-asm.lo: fr30-asm.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-desc.lo: fr30-desc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-dis.lo: fr30-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-ibld.lo: fr30-ibld.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h opintl.h
+fr30-opc.lo: fr30-opc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h fr30-desc.h $(INCDIR)/opcode/cgen.h \
+ fr30-opc.h
+h8300-dis.lo: h8300-dis.c $(INCDIR)/opcode/h8300.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/ansidecl.h opintl.h
+h8500-dis.lo: h8500-dis.c h8500-opc.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h opintl.h
+hppa-dis.lo: hppa-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(BFDDIR)/libhppa.h $(INCDIR)/opcode/hppa.h
+i386-dis.lo: i386-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h sysdep.h config.h opintl.h
+i960-dis.lo: i960-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h
+m32r-asm.lo: m32r-asm.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-desc.lo: m32r-desc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-dis.lo: m32r-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-ibld.lo: m32r-ibld.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h opintl.h
+m32r-opc.lo: m32r-opc.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h
+m32r-opinst.lo: m32r-opinst.c sysdep.h config.h $(BFD_H) \
+ $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
+ m32r-opc.h
+m68k-dis.lo: m68k-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/floatformat.h opintl.h \
+ $(INCDIR)/opcode/m68k.h
+m68k-opc.lo: m68k-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/m68k.h
+m88k-dis.lo: m88k-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/opcode/m88k.h opintl.h
+mcore-dis.lo: mcore-dis.c mcore-opc.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+mips-dis.lo: mips-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/opcode/mips.h opintl.h $(BFDDIR)/elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h
+mips-opc.lo: mips-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mips.h
+mips16-opc.lo: mips16-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mips.h
+m10200-dis.lo: m10200-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10200.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) opintl.h
+m10200-opc.lo: m10200-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10200.h
+m10300-dis.lo: m10300-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10300.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) opintl.h
+m10300-opc.lo: m10300-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/mn10300.h
+ns32k-dis.lo: ns32k-dis.c $(BFD_H) $(INCDIR)/ansidecl.h \
+ sysdep.h config.h $(INCDIR)/dis-asm.h $(INCDIR)/opcode/ns32k.h \
+ opintl.h
+ppc-dis.lo: ppc-dis.c $(INCDIR)/ansidecl.h sysdep.h \
+ config.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/opcode/ppc.h
+ppc-opc.lo: ppc-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/ppc.h \
+ opintl.h
+sh-dis.lo: sh-dis.c sh-opc.h $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h
+sparc-dis.lo: sparc-dis.c $(INCDIR)/ansidecl.h sysdep.h \
+ config.h $(INCDIR)/opcode/sparc.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/libiberty.h opintl.h
+sparc-opc.lo: sparc-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/sparc.h
+tic30-dis.lo: tic30-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+ $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic30.h
+tic80-dis.lo: tic80-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic80.h \
+ $(INCDIR)/dis-asm.h $(BFD_H)
+tic80-opc.lo: tic80-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic80.h
+vax-dis.lo: vax-dis.c $(INCDIR)/opcode/vax.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h
+w65-dis.lo: w65-dis.c w65-opc.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h
+z8k-dis.lo: z8k-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) z8k-opc.h
+z8kgen.lo: z8kgen.c sysdep.h config.h
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/opcodes/a29k-dis.c b/opcodes/a29k-dis.c
new file mode 100644
index 00000000000..72959c975d9
--- /dev/null
+++ b/opcodes/a29k-dis.c
@@ -0,0 +1,353 @@
+/* Instruction printing code for the AMD 29000
+ Copyright (C) 1990, 93, 94, 95, 1998 Free Software Foundation, Inc.
+ Contributed by Cygnus Support. Written by Jim Kingdon.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "dis-asm.h"
+#include "opcode/a29k.h"
+
+/* Print a symbolic representation of a general-purpose
+ register number NUM on STREAM.
+ NUM is a number as found in the instruction, not as found in
+ debugging symbols; it must be in the range 0-255. */
+static void
+print_general (num, info)
+ int num;
+ struct disassemble_info *info;
+{
+ if (num < 128)
+ (*info->fprintf_func) (info->stream, "gr%d", num);
+ else
+ (*info->fprintf_func) (info->stream, "lr%d", num - 128);
+}
+
+/* Like print_general but a special-purpose register.
+
+ The mnemonics used by the AMD assembler are not quite the same
+ as the ones in the User's Manual. We use the ones that the
+ assembler uses. */
+static void
+print_special (num, info)
+ unsigned int num;
+ struct disassemble_info *info;
+{
+ /* Register names of registers 0-SPEC0_NUM-1. */
+ static char *spec0_names[] = {
+ "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr",
+ "pc0", "pc1", "pc2", "mmu", "lru", "rsn", "rma0", "rmc0", "rma1", "rmc1",
+ "spc0", "spc1", "spc2", "iba0", "ibc0", "iba1", "ibc1", "dba", "dbc",
+ "cir", "cdr"
+ };
+#define SPEC0_NUM ((sizeof spec0_names) / (sizeof spec0_names[0]))
+
+ /* Register names of registers 128-128+SPEC128_NUM-1. */
+ static char *spec128_names[] = {
+ "ipc", "ipa", "ipb", "q", "alu", "bp", "fc", "cr"
+ };
+#define SPEC128_NUM ((sizeof spec128_names) / (sizeof spec128_names[0]))
+
+ /* Register names of registers 160-160+SPEC160_NUM-1. */
+ static char *spec160_names[] = {
+ "fpe", "inte", "fps", "sr163", "exop"
+ };
+#define SPEC160_NUM ((sizeof spec160_names) / (sizeof spec160_names[0]))
+
+ if (num < SPEC0_NUM)
+ (*info->fprintf_func) (info->stream, spec0_names[num]);
+ else if (num >= 128 && num < 128 + SPEC128_NUM)
+ (*info->fprintf_func) (info->stream, spec128_names[num-128]);
+ else if (num >= 160 && num < 160 + SPEC160_NUM)
+ (*info->fprintf_func) (info->stream, spec160_names[num-160]);
+ else
+ (*info->fprintf_func) (info->stream, "sr%d", num);
+}
+
+/* Is an instruction with OPCODE a delayed branch? */
+static int
+is_delayed_branch (opcode)
+ int opcode;
+{
+ return (opcode == 0xa8 || opcode == 0xa9 || opcode == 0xa0 || opcode == 0xa1
+ || opcode == 0xa4 || opcode == 0xa5
+ || opcode == 0xb4 || opcode == 0xb5
+ || opcode == 0xc4 || opcode == 0xc0
+ || opcode == 0xac || opcode == 0xad
+ || opcode == 0xcc);
+}
+
+/* Now find the four bytes of INSN and put them in *INSN{0,8,16,24}. */
+static void
+find_bytes_big (insn, insn0, insn8, insn16, insn24)
+ char *insn;
+ unsigned char *insn0;
+ unsigned char *insn8;
+ unsigned char *insn16;
+ unsigned char *insn24;
+{
+ *insn24 = insn[0];
+ *insn16 = insn[1];
+ *insn8 = insn[2];
+ *insn0 = insn[3];
+}
+
+static void
+find_bytes_little (insn, insn0, insn8, insn16, insn24)
+ char *insn;
+ unsigned char *insn0;
+ unsigned char *insn8;
+ unsigned char *insn16;
+ unsigned char *insn24;
+{
+ *insn24 = insn[3];
+ *insn16 = insn[2];
+ *insn8 = insn[1];
+ *insn0 = insn[0];
+}
+
+typedef void (*find_byte_func_type)
+ PARAMS ((char *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *));
+
+/* Print one instruction from MEMADDR on INFO->STREAM.
+ Return the size of the instruction (always 4 on a29k). */
+
+static int
+print_insn (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ /* The raw instruction. */
+ char insn[4];
+
+ /* The four bytes of the instruction. */
+ unsigned char insn24, insn16, insn8, insn0;
+
+ find_byte_func_type find_byte_func = (find_byte_func_type)info->private_data;
+
+ struct a29k_opcode CONST * opcode;
+
+ {
+ int status =
+ (*info->read_memory_func) (memaddr, (bfd_byte *) &insn[0], 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ }
+
+ (*find_byte_func) (insn, &insn0, &insn8, &insn16, &insn24);
+
+ printf ("%02x%02x%02x%02x ", insn24, insn16, insn8, insn0);
+
+ /* Handle the nop (aseq 0x40,gr1,gr1) specially */
+ if ((insn24==0x70) && (insn16==0x40) && (insn8==0x01) && (insn0==0x01)) {
+ (*info->fprintf_func) (info->stream,"nop");
+ return 4;
+ }
+
+ /* The opcode is always in insn24. */
+ for (opcode = &a29k_opcodes[0];
+ opcode < &a29k_opcodes[num_opcodes];
+ ++opcode)
+ {
+ if (((unsigned long) insn24 << 24) == opcode->opcode)
+ {
+ char *s;
+
+ (*info->fprintf_func) (info->stream, "%s ", opcode->name);
+ for (s = opcode->args; *s != '\0'; ++s)
+ {
+ switch (*s)
+ {
+ case 'a':
+ print_general (insn8, info);
+ break;
+
+ case 'b':
+ print_general (insn0, info);
+ break;
+
+ case 'c':
+ print_general (insn16, info);
+ break;
+
+ case 'i':
+ (*info->fprintf_func) (info->stream, "%d", insn0);
+ break;
+
+ case 'x':
+ (*info->fprintf_func) (info->stream, "0x%x", (insn16 << 8) + insn0);
+ break;
+
+ case 'h':
+ /* This used to be %x for binutils. */
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (insn16 << 24) + (insn0 << 16));
+ break;
+
+ case 'X':
+ (*info->fprintf_func) (info->stream, "%d",
+ ((insn16 << 8) + insn0) | 0xffff0000);
+ break;
+
+ case 'P':
+ /* This output looks just like absolute addressing, but
+ maybe that's OK (it's what the GDB m68k and EBMON
+ a29k disassemblers do). */
+ /* All the shifting is to sign-extend it. p*/
+ (*info->print_address_func)
+ (memaddr +
+ (((int)((insn16 << 10) + (insn0 << 2)) << 14) >> 14),
+ info);
+ break;
+
+ case 'A':
+ (*info->print_address_func)
+ ((insn16 << 10) + (insn0 << 2), info);
+ break;
+
+ case 'e':
+ (*info->fprintf_func) (info->stream, "%d", insn16 >> 7);
+ break;
+
+ case 'n':
+ (*info->fprintf_func) (info->stream, "0x%x", insn16 & 0x7f);
+ break;
+
+ case 'v':
+ (*info->fprintf_func) (info->stream, "0x%x", insn16);
+ break;
+
+ case 's':
+ print_special (insn8, info);
+ break;
+
+ case 'u':
+ (*info->fprintf_func) (info->stream, "%d", insn0 >> 7);
+ break;
+
+ case 'r':
+ (*info->fprintf_func) (info->stream, "%d", (insn0 >> 4) & 7);
+ break;
+
+ case 'I':
+ if ((insn16 & 3) != 0)
+ (*info->fprintf_func) (info->stream, "%d", insn16 & 3);
+ break;
+
+ case 'd':
+ (*info->fprintf_func) (info->stream, "%d", (insn0 >> 2) & 3);
+ break;
+
+ case 'f':
+ (*info->fprintf_func) (info->stream, "%d", insn0 & 3);
+ break;
+
+ case 'F':
+ (*info->fprintf_func) (info->stream, "%d", (insn16 >> 2) & 15);
+ break;
+
+ case 'C':
+ (*info->fprintf_func) (info->stream, "%d", insn16 & 3);
+ break;
+
+ default:
+ (*info->fprintf_func) (info->stream, "%c", *s);
+ }
+ }
+
+ /* Now we look for a const,consth pair of instructions,
+ in which case we try to print the symbolic address. */
+ if (insn24 == 2) /* consth */
+ {
+ int errcode;
+ char prev_insn[4];
+ unsigned char prev_insn0, prev_insn8, prev_insn16, prev_insn24;
+
+ errcode = (*info->read_memory_func) (memaddr - 4,
+ (bfd_byte *) &prev_insn[0],
+ 4,
+ info);
+ if (errcode == 0)
+ {
+ /* If it is a delayed branch, we need to look at the
+ instruction before the delayed brach to handle
+ things like
+
+ const _foo
+ call _printf
+ consth _foo
+ */
+ (*find_byte_func) (prev_insn, &prev_insn0, &prev_insn8,
+ &prev_insn16, &prev_insn24);
+ if (is_delayed_branch (prev_insn24))
+ {
+ errcode = (*info->read_memory_func)
+ (memaddr - 8, (bfd_byte *) &prev_insn[0], 4, info);
+ (*find_byte_func) (prev_insn, &prev_insn0, &prev_insn8,
+ &prev_insn16, &prev_insn24);
+ }
+ }
+
+ /* If there was a problem reading memory, then assume
+ the previous instruction was not const. */
+ if (errcode == 0)
+ {
+ /* Is it const to the same register? */
+ if (prev_insn24 == 3
+ && prev_insn8 == insn8)
+ {
+ (*info->fprintf_func) (info->stream, "\t; ");
+ (*info->print_address_func)
+ (((insn16 << 24) + (insn0 << 16)
+ + (prev_insn16 << 8) + (prev_insn0)),
+ info);
+ }
+ }
+ }
+
+ return 4;
+ }
+ }
+ /* This used to be %8x for binutils. */
+ (*info->fprintf_func)
+ (info->stream, ".word 0x%08x",
+ (insn24 << 24) + (insn16 << 16) + (insn8 << 8) + insn0);
+ return 4;
+}
+
+/* Disassemble an big-endian a29k instruction. */
+int
+print_insn_big_a29k (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ info->private_data = (PTR) find_bytes_big;
+ return print_insn (memaddr, info);
+}
+
+/* Disassemble a little-endian a29k instruction. */
+int
+print_insn_little_a29k (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ info->private_data = (PTR) find_bytes_little;
+ return print_insn (memaddr, info);
+}
diff --git a/opcodes/acinclude.m4 b/opcodes/acinclude.m4
new file mode 100644
index 00000000000..71b09b9f6ac
--- /dev/null
+++ b/opcodes/acinclude.m4
@@ -0,0 +1 @@
+sinclude(../bfd/acinclude.m4)
diff --git a/opcodes/aclocal.m4 b/opcodes/aclocal.m4
new file mode 100644
index 00000000000..308711dfa4e
--- /dev/null
+++ b/opcodes/aclocal.m4
@@ -0,0 +1,1111 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+sinclude(../bfd/acinclude.m4)
+
+# Do all the work for Automake. This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "[$]*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "[$]*" != "X $srcdir/configure conftestfile" \
+ && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "[$]2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+ $1=$2
+ AC_MSG_RESULT(found)
+else
+ $1="$3/missing $2"
+ AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
+
+# serial 35 AC_PROG_LIBTOOL
+AC_DEFUN(AC_PROG_LIBTOOL,
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+
+# Save cache, so that ltconfig can load it
+AC_CACHE_SAVE
+
+# Actually configure libtool. ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
+DLLTOOL="$DLLTOOL" AS="$AS" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+|| AC_MSG_ERROR([libtool configure failed])
+
+# Reload cache, that may have been modified by ltconfig
+AC_CACHE_LOAD
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+])
+
+AC_DEFUN(AC_LIBTOOL_SETUP,
+[AC_PREREQ(2.13)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_RANLIB])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([AC_SYS_NM_PARSE])dnl
+AC_REQUIRE([AC_SYS_SYMBOL_UNDERSCORE])dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+dnl
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$lt_dlopen" = yes && libtool_flags="$libtool_flags --enable-dlopen"
+test "$silent" = yes && libtool_flags="$libtool_flags --silent"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$host" in
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+ [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+
+*-*-cygwin*)
+ AC_SYS_LIBTOOL_CYGWIN
+ ;;
+
+esac
+
+# enable the --disable-libtool-lock switch
+
+AC_ARG_ENABLE(libtool-lock,
+[ --disable-libtool-lock force libtool not to do file locking],
+need_locks=$enableval,
+need_locks=yes)
+
+if test x"$need_locks" = xno; then
+ libtool_flags="$libtool_flags --disable-lock"
+fi
+])
+
+# AC_LIBTOOL_DLOPEN - check for dlopen support
+AC_DEFUN(AC_LIBTOOL_DLOPEN, [lt_dlopen=yes])
+
+# AC_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AC_ENABLE_SHARED[(DEFAULT)]
+# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
+# `yes'.
+AC_DEFUN(AC_ENABLE_SHARED,
+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac],
+enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN(AC_DISABLE_SHARED,
+[AC_ENABLE_SHARED(no)])
+
+# AC_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AC_ENABLE_STATIC[(DEFAULT)]
+# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
+# `yes'.
+AC_DEFUN(AC_ENABLE_STATIC,
+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac],
+enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
+])
+
+# AC_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN(AC_DISABLE_STATIC,
+[AC_ENABLE_STATIC(no)])
+
+
+# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
+# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
+# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
+# `yes'.
+AC_DEFUN(AC_ENABLE_FAST_INSTALL,
+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(fast-install,
+changequote(<<, >>)dnl
+<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac],
+enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
+])
+
+# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
+AC_DEFUN(AC_DISABLE_FAST_INSTALL,
+[AC_ENABLE_FAST_INSTALL(no)])
+
+
+# AC_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN(AC_PROG_LD,
+[AC_ARG_WITH(gnu-ld,
+[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by GCC])
+ ac_prog=`($CC -print-prog-name=ld) 2>&5`
+ case "$ac_prog" in
+ # Accept absolute paths.
+changequote(,)dnl
+ /* | [A-Za-z]:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+changequote([,])dnl
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(ac_cv_path_LD,
+[if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog"; then
+ ac_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+ test "$with_gnu_ld" != no && break
+ else
+ test "$with_gnu_ld" != yes && break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_SUBST(LD)
+AC_PROG_LD_GNU
+])
+
+AC_DEFUN(AC_PROG_LD_GNU,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+ ac_cv_prog_gnu_ld=yes
+else
+ ac_cv_prog_gnu_ld=no
+fi])
+])
+
+# AC_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN(AC_PROG_NM,
+[AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(ac_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ ac_cv_path_NM="$NM"
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/nm; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -B"
+ break
+ elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -p"
+ break
+ else
+ ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi])
+NM="$ac_cv_path_NM"
+AC_MSG_RESULT([$NM])
+AC_SUBST(NM)
+])
+
+# AC_SYS_NM_PARSE - Check for command to grab the raw symbol name followed
+# by C symbol name from nm.
+AC_DEFUN(AC_SYS_NM_PARSE,
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output])
+AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
+[# These are sane defaults that work on at least a few old systems.
+# {They come from Ultrix. What could be older than Ultrix?!! ;)}
+
+changequote(,)dnl
+# Character class describing NM global symbol codes.
+ac_symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+ac_symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+ac_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Define system-specific variables.
+case "$host_os" in
+aix*)
+ ac_symcode='[BCDT]'
+ ;;
+cygwin* | mingw*)
+ ac_symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ ac_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+ ;;
+irix*)
+ ac_symcode='[BCDEGRST]'
+ ;;
+solaris*)
+ ac_symcode='[BDT]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+ ac_symcode='[ABCDGISTW]'
+fi
+changequote([,])dnl
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+ ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($ac_symcode\)[ ][ ]*\($ac_symprfx\)$ac_sympat$/$ac_symxfrm/p'"
+
+ # Check to see that the pipe works correctly.
+ ac_pipe_works=no
+ rm -f conftest.$ac_ext
+ cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func;return 0;}
+EOF
+
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ ac_nlist=conftest.nm
+
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
+
+ # Try sorting and uniquifying the output.
+ if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
+ mv -f "$ac_nlist"T "$ac_nlist"
+ else
+ rm -f "$ac_nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
+ if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
+ cat <<EOF > conftest.c
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+ # Now generate the symbol file.
+ eval "$ac_global_symbol_to_cdecl"' < "$ac_nlist" >> conftest.c'
+
+ cat <<EOF >> conftest.c
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr_t address;
+}
+changequote(,)dnl
+lt_preloaded_symbols[] =
+changequote([,])dnl
+{
+EOF
+ sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
+ cat <<\EOF >> conftest.c
+ {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftestm.$ac_objext
+ ac_save_LIBS="$LIBS"
+ ac_save_CFLAGS="$CFLAGS"
+ LIBS="conftestm.$ac_objext"
+ CFLAGS="$CFLAGS$no_builtin_flag"
+ if AC_TRY_EVAL(ac_link) && test -s conftest; then
+ ac_pipe_works=yes
+ else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat conftest.c >&AC_FD_CC
+ fi
+ LIBS="$ac_save_LIBS"
+ CFLAGS="$ac_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
+ fi
+ else
+ echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
+ fi
+ else
+ echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
+ fi
+ else
+ echo "$progname: failed program was:" >&AC_FD_CC
+ cat conftest.c >&AC_FD_CC
+ fi
+ rm -rf conftest*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$ac_pipe_works" = yes; then
+ if test x"$ac_symprfx" = x"_"; then
+ ac_cv_sys_symbol_underscore=yes
+ else
+ ac_cv_sys_symbol_underscore=no
+ fi
+ break
+ else
+ ac_cv_sys_global_symbol_pipe=
+ fi
+done
+])
+
+ac_result=yes
+if test -z "$ac_cv_sys_global_symbol_pipe"; then
+ ac_result=no
+fi
+AC_MSG_RESULT($ac_result)
+])
+
+# AC_SYS_LIBTOOL_CYGWIN - find tools needed on cygwin
+AC_DEFUN(AC_SYS_LIBTOOL_CYGWIN,
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+AC_CHECK_TOOL(AS, as, false)
+])
+
+# AC_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
+# with an underscore?
+AC_DEFUN(AC_SYS_SYMBOL_UNDERSCORE,
+[AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([AC_SYS_NM_PARSE])dnl
+AC_MSG_CHECKING([for _ prefix in compiled symbols])
+AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
+[ac_cv_sys_symbol_underscore=no
+cat > conftest.$ac_ext <<EOF
+void nm_test_func(){}
+int main(){nm_test_func;return 0;}
+EOF
+if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ ac_nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
+ # See whether the symbols have a leading underscore.
+ if egrep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
+ ac_cv_sys_symbol_underscore=yes
+ else
+ if egrep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
+ :
+ else
+ echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
+ fi
+ fi
+ else
+ echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
+ fi
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat conftest.c >&AC_FD_CC
+fi
+rm -rf conftest*
+])
+AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
+USE_SYMBOL_UNDERSCORE=${ac_cv_sys_symbol_underscore=no}
+AC_SUBST(USE_SYMBOL_UNDERSCORE)dnl
+])
+
+# AC_CHECK_LIBM - check for math library
+AC_DEFUN(AC_CHECK_LIBM, [
+AC_CHECK_LIB(mw, _mwvalidcheckl)
+AC_CHECK_LIB(m, cos)
+])
+
+# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl convenience library, adds --enable-ltdl-convenience to
+# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
+# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
+# to be `${top_builddir}/libltdl'. Make sure you start DIR with
+# '${top_builddir}/' (note the single quotes!) if your package is not
+# flat, and, if you're not using automake, define top_builddir as
+# appropriate in the Makefiles.
+AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [
+ case "$enable_ltdl_convenience" in
+ no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+ "") enable_ltdl_convenience=yes
+ ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+ esac
+ LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
+])
+
+# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl installable library, and adds --enable-ltdl-install to
+# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
+# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
+# to be `${top_builddir}/libltdl'. Make sure you start DIR with
+# '${top_builddir}/' (note the single quotes!) if your package is not
+# flat, and, if you're not using automake, define top_builddir as
+# appropriate in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [
+ AC_CHECK_LIB(ltdl, main, LIBLTDL="-lltdl", [
+ case "$enable_ltdl_install" in
+ no) AC_MSG_WARN([libltdl not installed, but installation disabled]) ;;
+ "") enable_ltdl_install=yes
+ ac_configure_args="$ac_configure_args --enable-ltdl-install" ;;
+ esac
+ ])
+ if test x"$enable_ltdl_install" != x"no"; then
+ LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
+ fi
+])
+
+dnl old names
+AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
+AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
+AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
+AC_DEFUN(AM_SYS_NM_PARSE, [indir([AC_SYS_NM_PARSE])])dnl
+AC_DEFUN(AM_SYS_SYMBOL_UNDERSCORE, [indir([AC_SYS_SYMBOL_UNDERSCORE])])dnl
+AC_DEFUN(AM_SYS_LIBTOOL_CYGWIN, [indir([AC_SYS_LIBTOOL_CYGWIN])])dnl
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated. We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+ case " <<$>>CONFIG_HEADERS " in
+ *" <<$>>am_file "*<<)>>
+ echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+ ;;
+ esac
+ am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+
+# Add --enable-maintainer-mode option to configure.
+# From Jim Meyering
+
+# serial 1
+
+AC_DEFUN(AM_MAINTAINER_MODE,
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+ dnl maintainer-mode is disabled by default
+ AC_ARG_ENABLE(maintainer-mode,
+[ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer],
+ USE_MAINTAINER_MODE=$enableval,
+ USE_MAINTAINER_MODE=no)
+ AC_MSG_RESULT($USE_MAINTAINER_MODE)
+ AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
+ MAINT=$MAINTAINER_MODE_TRUE
+ AC_SUBST(MAINT)dnl
+]
+)
+
+# Define a conditional.
+
+AC_DEFUN(AM_CONDITIONAL,
+[AC_SUBST($1_TRUE)
+AC_SUBST($1_FALSE)
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi])
+
+# This file is derived from `gettext.m4'. The difference is that the
+# included macros assume Cygnus-style source and build trees.
+
+# Macro to add for using GNU gettext.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 3
+
+AC_DEFUN(CY_WITH_NLS,
+ [AC_MSG_CHECKING([whether NLS is requested])
+ dnl Default is enabled NLS
+ AC_ARG_ENABLE(nls,
+ [ --disable-nls do not use Native Language Support],
+ USE_NLS=$enableval, USE_NLS=yes)
+ AC_MSG_RESULT($USE_NLS)
+ AC_SUBST(USE_NLS)
+
+ USE_INCLUDED_LIBINTL=no
+
+ dnl If we use NLS figure out what method
+ if test "$USE_NLS" = "yes"; then
+ AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested])
+ AC_MSG_CHECKING([whether included gettext is requested])
+ AC_ARG_WITH(included-gettext,
+ [ --with-included-gettext use the GNU gettext library included here],
+ nls_cv_force_use_gnu_gettext=$withval,
+ nls_cv_force_use_gnu_gettext=no)
+ AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ dnl User does not insist on using GNU NLS library. Figure out what
+ dnl to use. If gettext or catgets are available (in this order) we
+ dnl use this. Else we have to fall back to GNU NLS library.
+ dnl catgets is only used if permitted by option --with-catgets.
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+ CATOBJEXT=NONE
+
+ AC_CHECK_HEADER(libintl.h,
+ [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
+ [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
+ gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
+
+ if test "$gt_cv_func_gettext_libc" != "yes"; then
+ AC_CHECK_LIB(intl, bindtextdomain,
+ [AC_CACHE_CHECK([for gettext in libintl],
+ gt_cv_func_gettext_libintl,
+ [AC_TRY_LINK([], [return (int) gettext ("")],
+ gt_cv_func_gettext_libintl=yes,
+ gt_cv_func_gettext_libintl=no)])])
+ fi
+
+ if test "$gt_cv_func_gettext_libc" = "yes" \
+ || test "$gt_cv_func_gettext_libintl" = "yes"; then
+ AC_DEFINE(HAVE_GETTEXT, 1,
+ [Define as 1 if you have gettext and don't want to use GNU gettext.])
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
+ if test "$MSGFMT" != "no"; then
+ AC_CHECK_FUNCS(dcgettext)
+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+ AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
+ return _nl_msg_cat_cntr],
+ [CATOBJEXT=.gmo
+ DATADIRNAME=share],
+ [CATOBJEXT=.mo
+ DATADIRNAME=lib])
+ INSTOBJEXT=.mo
+ fi
+ fi
+ ])
+
+ dnl In the standard gettext, we would now check for catgets.
+ dnl However, we never want to use catgets for our releases.
+
+ if test "$CATOBJEXT" = "NONE"; then
+ dnl Neither gettext nor catgets in included in the C library.
+ dnl Fall back on GNU gettext library.
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions used to generate GNU NLS library.
+ INTLOBJS="\$(GETTOBJS)"
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+ AC_SUBST(MSGFMT)
+ USE_INCLUDED_LIBINTL=yes
+ CATOBJEXT=.gmo
+ INSTOBJEXT=.mo
+ DATADIRNAME=share
+ INTLDEPS='$(top_builddir)/../intl/libintl.a'
+ INTLLIBS=$INTLDEPS
+ LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ dnl Test whether we really found GNU xgettext.
+ if test "$XGETTEXT" != ":"; then
+ dnl If it is no GNU xgettext we define it as : so that the
+ dnl Makefiles still can work.
+ if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
+ : ;
+ else
+ AC_MSG_RESULT(
+ [found xgettext programs is not GNU xgettext; ignore it])
+ XGETTEXT=":"
+ fi
+ fi
+
+ # We need to process the po/ directory.
+ POSUB=po
+ else
+ DATADIRNAME=share
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ # If this is used in GNU gettext we have to set USE_NLS to `yes'
+ # because some of the sources are only built for this goal.
+ if test "$PACKAGE" = gettext; then
+ USE_NLS=yes
+ USE_INCLUDED_LIBINTL=yes
+ fi
+
+ dnl These rules are solely for the distribution goal. While doing this
+ dnl we only have to keep exactly one list of the available catalogs
+ dnl in configure.in.
+ for lang in $ALL_LINGUAS; do
+ GMOFILES="$GMOFILES $lang.gmo"
+ POFILES="$POFILES $lang.po"
+ done
+
+ dnl Make all variables we use known to autoconf.
+ AC_SUBST(USE_INCLUDED_LIBINTL)
+ AC_SUBST(CATALOGS)
+ AC_SUBST(CATOBJEXT)
+ AC_SUBST(DATADIRNAME)
+ AC_SUBST(GMOFILES)
+ AC_SUBST(INSTOBJEXT)
+ AC_SUBST(INTLDEPS)
+ AC_SUBST(INTLLIBS)
+ AC_SUBST(INTLOBJS)
+ AC_SUBST(POFILES)
+ AC_SUBST(POSUB)
+ ])
+
+AC_DEFUN(CY_GNU_GETTEXT,
+ [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_PROG_RANLIB])dnl
+ AC_REQUIRE([AC_ISC_POSIX])dnl
+ AC_REQUIRE([AC_HEADER_STDC])dnl
+ AC_REQUIRE([AC_C_CONST])dnl
+ AC_REQUIRE([AC_C_INLINE])dnl
+ AC_REQUIRE([AC_TYPE_OFF_T])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+ AC_REQUIRE([AC_FUNC_MMAP])dnl
+
+ AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h values.h sys/param.h])
+ AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
+__argz_count __argz_stringify __argz_next])
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ AC_CHECK_FUNCS(stpcpy)
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function])
+ fi
+
+ AM_LC_MESSAGES
+ CY_WITH_NLS
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ AC_MSG_CHECKING(for catalogs to be installed)
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ AC_MSG_RESULT($LINGUAS)
+ fi
+
+ dnl Construct list of names of catalog files to be constructed.
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ dnl The reference to <locale.h> in the installed <libintl.h> file
+ dnl must be resolved because we cannot expect the users of this
+ dnl to define HAVE_LOCALE_H.
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+ AC_SUBST(INCLUDE_LOCALE_H)
+
+ dnl Determine which catalog format we have (if any is needed)
+ dnl For now we know about two different formats:
+ dnl Linux libc-5 and the normal X/Open format
+ if test -f $srcdir/po2tbl.sed.in; then
+ if test "$CATOBJEXT" = ".cat"; then
+ AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
+
+ dnl Transform the SED scripts while copying because some dumb SEDs
+ dnl cannot handle comments.
+ sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
+ fi
+ dnl po2tbl.sed is always needed.
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/po2tbl.sed.in > po2tbl.sed
+ fi
+
+ dnl In the intl/Makefile.in we have a special dependency which makes
+ dnl only sense for gettext. We comment this out for non-gettext
+ dnl packages.
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+ AC_SUBST(GT_NO)
+ AC_SUBST(GT_YES)
+
+ MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
+ AC_SUBST(MKINSTALLDIRS)
+
+ dnl *** For now the libtool support in intl/Makefile is not for real.
+ l=
+ AC_SUBST(l)
+
+ dnl Generate list of files to be processed by xgettext which will
+ dnl be included in po/Makefile. But only do this if the po directory
+ dnl exists in srcdir.
+ if test -d $srcdir/po; then
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ fi
+ ])
+
+# Search path for a program which passes the given test.
+# Ulrich Drepper <drepper@cygnus.com>, 1996.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
+dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
+AC_DEFUN(AM_PATH_PROG_WITH_TEST,
+[# Extract the first word of "$2", so it can be a program name with args.
+set dummy $2; ac_word=[$]2
+AC_MSG_CHECKING([for $ac_word])
+AC_CACHE_VAL(ac_cv_path_$1,
+[case "[$]$1" in
+ /*)
+ ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in ifelse([$5], , $PATH, [$5]); do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if [$3]; then
+ ac_cv_path_$1="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+dnl If no 4th arg is given, leave the cache variable unset,
+dnl so AC_PATH_PROGS will keep looking.
+ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
+])dnl
+ ;;
+esac])dnl
+$1="$ac_cv_path_$1"
+if test -n "[$]$1"; then
+ AC_MSG_RESULT([$]$1)
+else
+ AC_MSG_RESULT(no)
+fi
+AC_SUBST($1)dnl
+])
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+AC_DEFUN(AM_LC_MESSAGES,
+ [if test $ac_cv_header_locale_h = yes; then
+ AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
+ [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+ am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ AC_DEFINE(HAVE_LC_MESSAGES, 1,
+ [Define if your locale.h file contains LC_MESSAGES.])
+ fi
+ fi])
+
diff --git a/opcodes/alpha-dis.c b/opcodes/alpha-dis.c
new file mode 100644
index 00000000000..db55799ee68
--- /dev/null
+++ b/opcodes/alpha-dis.c
@@ -0,0 +1,213 @@
+/* alpha-dis.c -- Disassemble Alpha AXP instructions
+ Copyright 1996, 1999 Free Software Foundation, Inc.
+ Contributed by Richard Henderson <rth@tamu.edu>,
+ patterned after the PPC opcode handling written by Ian Lance Taylor.
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+2, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "ansidecl.h"
+#include "sysdep.h"
+#include "dis-asm.h"
+#include "opcode/alpha.h"
+
+/* OSF register names. */
+
+static const char * const osf_regnames[64] =
+{
+ "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
+ "t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp",
+ "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
+ "t10", "t11", "ra", "t12", "at", "gp", "sp", "zero",
+ "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7",
+ "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15",
+ "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",
+ "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31"
+};
+
+/* VMS register names. */
+
+static const char * const vms_regnames[64] =
+{
+ "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
+ "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15",
+ "R16", "R17", "R18", "R19", "R20", "R21", "R22", "R23",
+ "R24", "AI", "RA", "PV", "AT", "FP", "SP", "RZ",
+ "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7",
+ "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15",
+ "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23",
+ "F24", "F25", "F26", "F27", "F28", "F29", "F30", "FZ"
+};
+
+/* Disassemble Alpha instructions. */
+
+int
+print_insn_alpha (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ static const struct alpha_opcode *opcode_index[AXP_NOPS+1];
+ const char * const * regnames;
+ const struct alpha_opcode *opcode, *opcode_end;
+ const unsigned char *opindex;
+ unsigned insn, op, isa_mask;
+ int need_comma;
+
+ /* Initialize the majorop table the first time through */
+ if (!opcode_index[0])
+ {
+ opcode = alpha_opcodes;
+ opcode_end = opcode + alpha_num_opcodes;
+
+ for (op = 0; op < AXP_NOPS; ++op)
+ {
+ opcode_index[op] = opcode;
+ while (opcode < opcode_end && op == AXP_OP (opcode->opcode))
+ ++opcode;
+ }
+ opcode_index[op] = opcode;
+ }
+
+ if (info->flavour == bfd_target_evax_flavour)
+ regnames = vms_regnames;
+ else
+ regnames = osf_regnames;
+
+ isa_mask = AXP_OPCODE_NOPAL;
+ switch (info->mach)
+ {
+ case bfd_mach_alpha_ev4:
+ isa_mask |= AXP_OPCODE_EV4;
+ break;
+ case bfd_mach_alpha_ev5:
+ isa_mask |= AXP_OPCODE_EV5;
+ break;
+ case bfd_mach_alpha_ev6:
+ isa_mask |= AXP_OPCODE_EV6;
+ break;
+ }
+
+ /* Read the insn into a host word */
+ {
+ bfd_byte buffer[4];
+ int status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getl32 (buffer);
+ }
+
+ /* Get the major opcode of the instruction. */
+ op = AXP_OP (insn);
+
+ /* Find the first match in the opcode table. */
+ opcode_end = opcode_index[op+1];
+ for (opcode = opcode_index[op]; opcode < opcode_end; ++opcode)
+ {
+ if ((insn & opcode->mask) != opcode->opcode)
+ continue;
+
+ if (!(opcode->flags & isa_mask))
+ continue;
+
+ /* Make two passes over the operands. First see if any of them
+ have extraction functions, and, if they do, make sure the
+ instruction is valid. */
+ {
+ int invalid = 0;
+ for (opindex = opcode->operands; *opindex != 0; opindex++)
+ {
+ const struct alpha_operand *operand = alpha_operands + *opindex;
+ if (operand->extract)
+ (*operand->extract) (insn, &invalid);
+ }
+ if (invalid)
+ continue;
+ }
+
+ /* The instruction is valid. */
+ goto found;
+ }
+
+ /* No instruction found */
+ (*info->fprintf_func) (info->stream, ".long %#08x", insn);
+
+ return 4;
+
+found:
+ (*info->fprintf_func) (info->stream, "%s", opcode->name);
+ if (opcode->operands[0] != 0)
+ (*info->fprintf_func) (info->stream, "\t");
+
+ /* Now extract and print the operands. */
+ need_comma = 0;
+ for (opindex = opcode->operands; *opindex != 0; opindex++)
+ {
+ const struct alpha_operand *operand = alpha_operands + *opindex;
+ int value;
+
+ /* Operands that are marked FAKE are simply ignored. We
+ already made sure that the extract function considered
+ the instruction to be valid. */
+ if ((operand->flags & AXP_OPERAND_FAKE) != 0)
+ continue;
+
+ /* Extract the value from the instruction. */
+ if (operand->extract)
+ value = (*operand->extract) (insn, (int *) NULL);
+ else
+ {
+ value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
+ if (operand->flags & AXP_OPERAND_SIGNED)
+ {
+ int signbit = 1 << (operand->bits - 1);
+ value = (value ^ signbit) - signbit;
+ }
+ }
+
+ if (need_comma &&
+ ((operand->flags & (AXP_OPERAND_PARENS|AXP_OPERAND_COMMA))
+ != AXP_OPERAND_PARENS))
+ {
+ (*info->fprintf_func) (info->stream, ",");
+ }
+ if (operand->flags & AXP_OPERAND_PARENS)
+ (*info->fprintf_func) (info->stream, "(");
+
+ /* Print the operand as directed by the flags. */
+ if (operand->flags & AXP_OPERAND_IR)
+ (*info->fprintf_func) (info->stream, "%s", regnames[value]);
+ else if (operand->flags & AXP_OPERAND_FPR)
+ (*info->fprintf_func) (info->stream, "%s", regnames[value+32]);
+ else if (operand->flags & AXP_OPERAND_RELATIVE)
+ (*info->print_address_func) (memaddr + 4 + value, info);
+ else if (operand->flags & AXP_OPERAND_SIGNED)
+ (*info->fprintf_func) (info->stream, "%d", value);
+ else
+ (*info->fprintf_func) (info->stream, "%#x", value);
+
+ if (operand->flags & AXP_OPERAND_PARENS)
+ (*info->fprintf_func) (info->stream, ")");
+ need_comma = 1;
+ }
+
+ return 4;
+}
diff --git a/opcodes/alpha-opc.c b/opcodes/alpha-opc.c
new file mode 100644
index 00000000000..cceaf798715
--- /dev/null
+++ b/opcodes/alpha-opc.c
@@ -0,0 +1,1546 @@
+/* alpha-opc.c -- Alpha AXP opcode list
+ Copyright (c) 1996, 1998, 1999 Free Software Foundation, Inc.
+ Contributed by Richard Henderson <rth@cygnus.com>,
+ patterned after the PPC opcode handling written by Ian Lance Taylor.
+
+ This file is part of GDB, GAS, and the GNU binutils.
+
+ GDB, GAS, and the GNU binutils are free software; you can redistribute
+ them and/or modify them under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either version
+ 2, or (at your option) any later version.
+
+ GDB, GAS, and the GNU binutils are distributed in the hope that they
+ 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 file; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/alpha.h"
+#include "bfd.h"
+#include "opintl.h"
+
+/* This file holds the Alpha AXP opcode table. The opcode table includes
+ almost all of the extended instruction mnemonics. This permits the
+ disassembler to use them, and simplifies the assembler logic, at the
+ cost of increasing the table size. The table is strictly constant
+ data, so the compiler should be able to put it in the .text section.
+
+ This file also holds the operand table. All knowledge about inserting
+ operands into instructions and vice-versa is kept in this file.
+
+ The information for the base instruction set was compiled from the
+ _Alpha Architecture Handbook_, Digital Order Number EC-QD2KB-TE,
+ version 2.
+
+ The information for the post-ev5 architecture extensions BWX, CIX and
+ MAX came from version 3 of this same document, which is also available
+ on-line at http://ftp.digital.com/pub/Digital/info/semiconductor
+ /literature/alphahb2.pdf
+
+ The information for the EV4 PALcode instructions was compiled from
+ _DECchip 21064 and DECchip 21064A Alpha AXP Microprocessors Hardware
+ Reference Manual_, Digital Order Number EC-Q9ZUA-TE, preliminary
+ revision dated June 1994.
+
+ The information for the EV5 PALcode instructions was compiled from
+ _Alpha 21164 Microprocessor Hardware Reference Manual_, Digital
+ Order Number EC-QAEQB-TE, preliminary revision dated April 1995. */
+
+/* Local insertion and extraction functions */
+
+static unsigned insert_rba PARAMS((unsigned, int, const char **));
+static unsigned insert_rca PARAMS((unsigned, int, const char **));
+static unsigned insert_za PARAMS((unsigned, int, const char **));
+static unsigned insert_zb PARAMS((unsigned, int, const char **));
+static unsigned insert_zc PARAMS((unsigned, int, const char **));
+static unsigned insert_bdisp PARAMS((unsigned, int, const char **));
+static unsigned insert_jhint PARAMS((unsigned, int, const char **));
+static unsigned insert_ev6hwjhint PARAMS((unsigned, int, const char **));
+
+static int extract_rba PARAMS((unsigned, int *));
+static int extract_rca PARAMS((unsigned, int *));
+static int extract_za PARAMS((unsigned, int *));
+static int extract_zb PARAMS((unsigned, int *));
+static int extract_zc PARAMS((unsigned, int *));
+static int extract_bdisp PARAMS((unsigned, int *));
+static int extract_jhint PARAMS((unsigned, int *));
+static int extract_ev6hwjhint PARAMS((unsigned, int *));
+
+
+/* The operands table */
+
+const struct alpha_operand alpha_operands[] =
+{
+ /* The fields are bits, shift, insert, extract, flags */
+ /* The zero index is used to indicate end-of-list */
+#define UNUSED 0
+ { 0, 0, 0, 0, 0 },
+
+ /* The plain integer register fields */
+#define RA (UNUSED + 1)
+ { 5, 21, 0, AXP_OPERAND_IR, 0, 0 },
+#define RB (RA + 1)
+ { 5, 16, 0, AXP_OPERAND_IR, 0, 0 },
+#define RC (RB + 1)
+ { 5, 0, 0, AXP_OPERAND_IR, 0, 0 },
+
+ /* The plain fp register fields */
+#define FA (RC + 1)
+ { 5, 21, 0, AXP_OPERAND_FPR, 0, 0 },
+#define FB (FA + 1)
+ { 5, 16, 0, AXP_OPERAND_FPR, 0, 0 },
+#define FC (FB + 1)
+ { 5, 0, 0, AXP_OPERAND_FPR, 0, 0 },
+
+ /* The integer registers when they are ZERO */
+#define ZA (FC + 1)
+ { 5, 21, 0, AXP_OPERAND_FAKE, insert_za, extract_za },
+#define ZB (ZA + 1)
+ { 5, 16, 0, AXP_OPERAND_FAKE, insert_zb, extract_zb },
+#define ZC (ZB + 1)
+ { 5, 0, 0, AXP_OPERAND_FAKE, insert_zc, extract_zc },
+
+ /* The RB field when it needs parentheses */
+#define PRB (ZC + 1)
+ { 5, 16, 0, AXP_OPERAND_IR|AXP_OPERAND_PARENS, 0, 0 },
+
+ /* The RB field when it needs parentheses _and_ a preceding comma */
+#define CPRB (PRB + 1)
+ { 5, 16, 0,
+ AXP_OPERAND_IR|AXP_OPERAND_PARENS|AXP_OPERAND_COMMA, 0, 0 },
+
+ /* The RB field when it must be the same as the RA field */
+#define RBA (CPRB + 1)
+ { 5, 16, 0, AXP_OPERAND_FAKE, insert_rba, extract_rba },
+
+ /* The RC field when it must be the same as the RB field */
+#define RCA (RBA + 1)
+ { 5, 0, 0, AXP_OPERAND_FAKE, insert_rca, extract_rca },
+
+ /* The RC field when it can *default* to RA */
+#define DRC1 (RCA + 1)
+ { 5, 0, 0,
+ AXP_OPERAND_IR|AXP_OPERAND_DEFAULT_FIRST, 0, 0 },
+
+ /* The RC field when it can *default* to RB */
+#define DRC2 (DRC1 + 1)
+ { 5, 0, 0,
+ AXP_OPERAND_IR|AXP_OPERAND_DEFAULT_SECOND, 0, 0 },
+
+ /* The FC field when it can *default* to RA */
+#define DFC1 (DRC2 + 1)
+ { 5, 0, 0,
+ AXP_OPERAND_FPR|AXP_OPERAND_DEFAULT_FIRST, 0, 0 },
+
+ /* The FC field when it can *default* to RB */
+#define DFC2 (DFC1 + 1)
+ { 5, 0, 0,
+ AXP_OPERAND_FPR|AXP_OPERAND_DEFAULT_SECOND, 0, 0 },
+
+ /* The unsigned 8-bit literal of Operate format insns */
+#define LIT (DFC2 + 1)
+ { 8, 13, -LIT, AXP_OPERAND_UNSIGNED, 0, 0 },
+
+ /* The signed 16-bit displacement of Memory format insns. From here
+ we can't tell what relocation should be used, so don't use a default. */
+#define MDISP (LIT + 1)
+ { 16, 0, -MDISP, AXP_OPERAND_SIGNED, 0, 0 },
+
+ /* The signed "23-bit" aligned displacement of Branch format insns */
+#define BDISP (MDISP + 1)
+ { 21, 0, BFD_RELOC_23_PCREL_S2,
+ AXP_OPERAND_RELATIVE, insert_bdisp, extract_bdisp },
+
+ /* The 26-bit PALcode function */
+#define PALFN (BDISP + 1)
+ { 26, 0, -PALFN, AXP_OPERAND_UNSIGNED, 0, 0 },
+
+ /* The optional signed "16-bit" aligned displacement of the JMP/JSR hint */
+#define JMPHINT (PALFN + 1)
+ { 14, 0, BFD_RELOC_ALPHA_HINT,
+ AXP_OPERAND_RELATIVE|AXP_OPERAND_DEFAULT_ZERO|AXP_OPERAND_NOOVERFLOW,
+ insert_jhint, extract_jhint },
+
+ /* The optional hint to RET/JSR_COROUTINE */
+#define RETHINT (JMPHINT + 1)
+ { 14, 0, -RETHINT,
+ AXP_OPERAND_UNSIGNED|AXP_OPERAND_DEFAULT_ZERO, 0, 0 },
+
+ /* The 12-bit displacement for the ev[46] hw_{ld,st} (pal1b/pal1f) insns */
+#define EV4HWDISP (RETHINT + 1)
+#define EV6HWDISP (EV4HWDISP)
+ { 12, 0, -EV4HWDISP, AXP_OPERAND_SIGNED, 0, 0 },
+
+ /* The 5-bit index for the ev4 hw_m[ft]pr (pal19/pal1d) insns */
+#define EV4HWINDEX (EV4HWDISP + 1)
+ { 5, 0, -EV4HWINDEX, AXP_OPERAND_UNSIGNED, 0, 0 },
+
+ /* The 8-bit index for the oddly unqualified hw_m[tf]pr insns
+ that occur in DEC PALcode. */
+#define EV4EXTHWINDEX (EV4HWINDEX + 1)
+ { 8, 0, -EV4EXTHWINDEX, AXP_OPERAND_UNSIGNED, 0, 0 },
+
+ /* The 10-bit displacement for the ev5 hw_{ld,st} (pal1b/pal1f) insns */
+#define EV5HWDISP (EV4EXTHWINDEX + 1)
+ { 10, 0, -EV5HWDISP, AXP_OPERAND_SIGNED, 0, 0 },
+
+ /* The 16-bit index for the ev5 hw_m[ft]pr (pal19/pal1d) insns */
+#define EV5HWINDEX (EV5HWDISP + 1)
+ { 16, 0, -EV5HWINDEX, AXP_OPERAND_UNSIGNED, 0, 0 },
+
+ /* The 16-bit combined index/scoreboard mask for the ev6
+ hw_m[ft]pr (pal19/pal1d) insns */
+#define EV6HWINDEX (EV5HWINDEX + 1)
+ { 16, 0, -EV6HWINDEX, AXP_OPERAND_UNSIGNED, 0, 0 },
+
+ /* The 13-bit branch hint for the ev6 hw_jmp/jsr (pal1e) insn */
+#define EV6HWJMPHINT (EV6HWINDEX+ 1)
+ { 8, 0, -EV6HWJMPHINT,
+ AXP_OPERAND_RELATIVE|AXP_OPERAND_DEFAULT_ZERO|AXP_OPERAND_NOOVERFLOW,
+ insert_ev6hwjhint, extract_ev6hwjhint }
+};
+
+const int alpha_num_operands = sizeof(alpha_operands)/sizeof(*alpha_operands);
+
+/* The RB field when it is the same as the RA field in the same insn.
+ This operand is marked fake. The insertion function just copies
+ the RA field into the RB field, and the extraction function just
+ checks that the fields are the same. */
+
+/*ARGSUSED*/
+static unsigned
+insert_rba(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ return insn | (((insn >> 21) & 0x1f) << 16);
+}
+
+static int
+extract_rba(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))
+ *invalid = 1;
+ return 0;
+}
+
+
+/* The same for the RC field */
+
+/*ARGSUSED*/
+static unsigned
+insert_rca(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ return insn | ((insn >> 21) & 0x1f);
+}
+
+static int
+extract_rca(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn >> 21) & 0x1f) != (insn & 0x1f))
+ *invalid = 1;
+ return 0;
+}
+
+
+/* Fake arguments in which the registers must be set to ZERO */
+
+/*ARGSUSED*/
+static unsigned
+insert_za(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ return insn | (31 << 21);
+}
+
+static int
+extract_za(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL && ((insn >> 21) & 0x1f) != 31)
+ *invalid = 1;
+ return 0;
+}
+
+/*ARGSUSED*/
+static unsigned
+insert_zb(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ return insn | (31 << 16);
+}
+
+static int
+extract_zb(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL && ((insn >> 16) & 0x1f) != 31)
+ *invalid = 1;
+ return 0;
+}
+
+/*ARGSUSED*/
+static unsigned
+insert_zc(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ return insn | 31;
+}
+
+static int
+extract_zc(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL && (insn & 0x1f) != 31)
+ *invalid = 1;
+ return 0;
+}
+
+
+/* The displacement field of a Branch format insn. */
+
+static unsigned
+insert_bdisp(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ if (errmsg != (const char **)NULL && (value & 3))
+ *errmsg = _("branch operand unaligned");
+ return insn | ((value / 4) & 0x1FFFFF);
+}
+
+/*ARGSUSED*/
+static int
+extract_bdisp(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ return 4 * (((insn & 0x1FFFFF) ^ 0x100000) - 0x100000);
+}
+
+
+/* The hint field of a JMP/JSR insn. */
+
+static unsigned
+insert_jhint(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ if (errmsg != (const char **)NULL && (value & 3))
+ *errmsg = _("jump hint unaligned");
+ return insn | ((value / 4) & 0x3FFF);
+}
+
+/*ARGSUSED*/
+static int
+extract_jhint(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ return 4 * (((insn & 0x3FFF) ^ 0x2000) - 0x2000);
+}
+
+/* The hint field of an EV6 HW_JMP/JSR insn. */
+
+static unsigned
+insert_ev6hwjhint(insn, value, errmsg)
+ unsigned insn;
+ int value;
+ const char **errmsg;
+{
+ if (errmsg != (const char **)NULL && (value & 3))
+ *errmsg = _("jump hint unaligned");
+ return insn | ((value / 4) & 0x1FFF);
+}
+
+/*ARGSUSED*/
+static int
+extract_ev6hwjhint(insn, invalid)
+ unsigned insn;
+ int *invalid;
+{
+ return 4 * (((insn & 0x1FFF) ^ 0x1000) - 0x1000);
+}
+
+
+/* Macros used to form opcodes */
+
+/* The main opcode */
+#define OP(x) (((x) & 0x3F) << 26)
+#define OP_MASK 0xFC000000
+
+/* Branch format instructions */
+#define BRA_(oo) OP(oo)
+#define BRA_MASK OP_MASK
+#define BRA(oo) BRA_(oo), BRA_MASK
+
+/* Floating point format instructions */
+#define FP_(oo,fff) (OP(oo) | (((fff) & 0x7FF) << 5))
+#define FP_MASK (OP_MASK | 0xFFE0)
+#define FP(oo,fff) FP_(oo,fff), FP_MASK
+
+/* Memory format instructions */
+#define MEM_(oo) OP(oo)
+#define MEM_MASK OP_MASK
+#define MEM(oo) MEM_(oo), MEM_MASK
+
+/* Memory/Func Code format instructions */
+#define MFC_(oo,ffff) (OP(oo) | ((ffff) & 0xFFFF))
+#define MFC_MASK (OP_MASK | 0xFFFF)
+#define MFC(oo,ffff) MFC_(oo,ffff), MFC_MASK
+
+/* Memory/Branch format instructions */
+#define MBR_(oo,h) (OP(oo) | (((h) & 3) << 14))
+#define MBR_MASK (OP_MASK | 0xC000)
+#define MBR(oo,h) MBR_(oo,h), MBR_MASK
+
+/* Operate format instructions. The OPRL variant specifies a
+ literal second argument. */
+#define OPR_(oo,ff) (OP(oo) | (((ff) & 0x7F) << 5))
+#define OPRL_(oo,ff) (OPR_((oo),(ff)) | 0x1000)
+#define OPR_MASK (OP_MASK | 0x1FE0)
+#define OPR(oo,ff) OPR_(oo,ff), OPR_MASK
+#define OPRL(oo,ff) OPRL_(oo,ff), OPR_MASK
+
+/* Generic PALcode format instructions */
+#define PCD_(oo) OP(oo)
+#define PCD_MASK OP_MASK
+#define PCD(oo) PCD_(oo), PCD_MASK
+
+/* Specific PALcode instructions */
+#define SPCD_(oo,ffff) (OP(oo) | ((ffff) & 0x3FFFFFF))
+#define SPCD_MASK 0xFFFFFFFF
+#define SPCD(oo,ffff) SPCD_(oo,ffff), SPCD_MASK
+
+/* Hardware memory (hw_{ld,st}) instructions */
+#define EV4HWMEM_(oo,f) (OP(oo) | (((f) & 0xF) << 12))
+#define EV4HWMEM_MASK (OP_MASK | 0xF000)
+#define EV4HWMEM(oo,f) EV4HWMEM_(oo,f), EV4HWMEM_MASK
+
+#define EV5HWMEM_(oo,f) (OP(oo) | (((f) & 0x3F) << 10))
+#define EV5HWMEM_MASK (OP_MASK | 0xF800)
+#define EV5HWMEM(oo,f) EV5HWMEM_(oo,f), EV5HWMEM_MASK
+
+#define EV6HWMEM_(oo,f) (OP(oo) | (((f) & 0xF) << 12))
+#define EV6HWMEM_MASK (OP_MASK | 0xF000)
+#define EV6HWMEM(oo,f) EV6HWMEM_(oo,f), EV6HWMEM_MASK
+
+#define EV6HWMBR_(oo,h) (OP(oo) | (((h) & 7) << 13))
+#define EV6HWMBR_MASK (OP_MASK | 0xE000)
+#define EV6HWMBR(oo,h) EV6HWMBR_(oo,h), EV6HWMBR_MASK
+
+/* Abbreviations for instruction subsets. */
+#define BASE AXP_OPCODE_BASE
+#define EV4 AXP_OPCODE_EV4
+#define EV5 AXP_OPCODE_EV5
+#define EV6 AXP_OPCODE_EV6
+#define BWX AXP_OPCODE_BWX
+#define CIX AXP_OPCODE_CIX
+#define MAX AXP_OPCODE_MAX
+
+/* Common combinations of arguments */
+#define ARG_NONE { 0 }
+#define ARG_BRA { RA, BDISP }
+#define ARG_FBRA { FA, BDISP }
+#define ARG_FP { FA, FB, DFC1 }
+#define ARG_FPZ1 { ZA, FB, DFC1 }
+#define ARG_MEM { RA, MDISP, PRB }
+#define ARG_FMEM { FA, MDISP, PRB }
+#define ARG_OPR { RA, RB, DRC1 }
+#define ARG_OPRL { RA, LIT, DRC1 }
+#define ARG_OPRZ1 { ZA, RB, DRC1 }
+#define ARG_OPRLZ1 { ZA, LIT, RC }
+#define ARG_PCD { PALFN }
+#define ARG_EV4HWMEM { RA, EV4HWDISP, PRB }
+#define ARG_EV4HWMPR { RA, RBA, EV4HWINDEX }
+#define ARG_EV5HWMEM { RA, EV5HWDISP, PRB }
+#define ARG_EV6HWMEM { RA, EV6HWDISP, PRB }
+
+/* The opcode table.
+
+ The format of the opcode table is:
+
+ NAME OPCODE MASK { OPERANDS }
+
+ NAME is the name of the instruction.
+
+ OPCODE is the instruction opcode.
+
+ MASK is the opcode mask; this is used to tell the disassembler
+ which bits in the actual opcode must match OPCODE.
+
+ OPERANDS is the list of operands.
+
+ The preceding macros merge the text of the OPCODE and MASK fields.
+
+ The disassembler reads the table in order and prints the first
+ instruction which matches, so this table is sorted to put more
+ specific instructions before more general instructions.
+
+ Otherwise, it is sorted by major opcode and minor function code.
+
+ There are three classes of not-really-instructions in this table:
+
+ ALIAS is another name for another instruction. Some of
+ these come from the Architecture Handbook, some
+ come from the original gas opcode tables. In all
+ cases, the functionality of the opcode is unchanged.
+
+ PSEUDO a stylized code form endorsed by Chapter A.4 of the
+ Architecture Handbook.
+
+ EXTRA a stylized code form found in the original gas tables.
+
+ And two annotations:
+
+ EV56 BUT opcodes that are officially introduced as of the ev56,
+ but with defined results on previous implementations.
+
+ EV56 UNA opcodes that were introduced as of the ev56 with
+ presumably undefined results on previous implementations
+ that were not assigned to a particular extension.
+*/
+
+const struct alpha_opcode alpha_opcodes[] = {
+ { "halt", SPCD(0x00,0x0000), BASE, ARG_NONE },
+ { "draina", SPCD(0x00,0x0002), BASE, ARG_NONE },
+ { "bpt", SPCD(0x00,0x0080), BASE, ARG_NONE },
+ { "callsys", SPCD(0x00,0x0083), BASE, ARG_NONE },
+ { "chmk", SPCD(0x00,0x0083), BASE, ARG_NONE },
+ { "imb", SPCD(0x00,0x0086), BASE, ARG_NONE },
+ { "call_pal", PCD(0x00), BASE, ARG_PCD },
+ { "pal", PCD(0x00), BASE, ARG_PCD }, /* alias */
+
+ { "lda", MEM(0x08), BASE, ARG_MEM },
+ { "ldah", MEM(0x09), BASE, ARG_MEM },
+ { "ldbu", MEM(0x0A), BWX, ARG_MEM },
+ { "unop", MEM(0x0B), BASE, { ZA } }, /* pseudo */
+ { "ldq_u", MEM(0x0B), BASE, ARG_MEM },
+ { "ldwu", MEM(0x0C), BWX, ARG_MEM },
+ { "stw", MEM(0x0D), BWX, ARG_MEM },
+ { "stb", MEM(0x0E), BWX, ARG_MEM },
+ { "stq_u", MEM(0x0F), BASE, ARG_MEM },
+
+ { "sextl", OPR(0x10,0x00), BASE, ARG_OPRZ1 }, /* pseudo */
+ { "sextl", OPRL(0x10,0x00), BASE, ARG_OPRLZ1 }, /* pseudo */
+ { "addl", OPR(0x10,0x00), BASE, ARG_OPR },
+ { "addl", OPRL(0x10,0x00), BASE, ARG_OPRL },
+ { "s4addl", OPR(0x10,0x02), BASE, ARG_OPR },
+ { "s4addl", OPRL(0x10,0x02), BASE, ARG_OPRL },
+ { "negl", OPR(0x10,0x09), BASE, ARG_OPRZ1 }, /* pseudo */
+ { "negl", OPRL(0x10,0x09), BASE, ARG_OPRLZ1 }, /* pseudo */
+ { "subl", OPR(0x10,0x09), BASE, ARG_OPR },
+ { "subl", OPRL(0x10,0x09), BASE, ARG_OPRL },
+ { "s4subl", OPR(0x10,0x0B), BASE, ARG_OPR },
+ { "s4subl", OPRL(0x10,0x0B), BASE, ARG_OPRL },
+ { "cmpbge", OPR(0x10,0x0F), BASE, ARG_OPR },
+ { "cmpbge", OPRL(0x10,0x0F), BASE, ARG_OPRL },
+ { "s8addl", OPR(0x10,0x12), BASE, ARG_OPR },
+ { "s8addl", OPRL(0x10,0x12), BASE, ARG_OPRL },
+ { "s8subl", OPR(0x10,0x1B), BASE, ARG_OPR },
+ { "s8subl", OPRL(0x10,0x1B), BASE, ARG_OPRL },
+ { "cmpult", OPR(0x10,0x1D), BASE, ARG_OPR },
+ { "cmpult", OPRL(0x10,0x1D), BASE, ARG_OPRL },
+ { "addq", OPR(0x10,0x20), BASE, ARG_OPR },
+ { "addq", OPRL(0x10,0x20), BASE, ARG_OPRL },
+ { "s4addq", OPR(0x10,0x22), BASE, ARG_OPR },
+ { "s4addq", OPRL(0x10,0x22), BASE, ARG_OPRL },
+ { "negq", OPR(0x10,0x29), BASE, ARG_OPRZ1 }, /* pseudo */
+ { "negq", OPRL(0x10,0x29), BASE, ARG_OPRLZ1 }, /* pseudo */
+ { "subq", OPR(0x10,0x29), BASE, ARG_OPR },
+ { "subq", OPRL(0x10,0x29), BASE, ARG_OPRL },
+ { "s4subq", OPR(0x10,0x2B), BASE, ARG_OPR },
+ { "s4subq", OPRL(0x10,0x2B), BASE, ARG_OPRL },
+ { "cmpeq", OPR(0x10,0x2D), BASE, ARG_OPR },
+ { "cmpeq", OPRL(0x10,0x2D), BASE, ARG_OPRL },
+ { "s8addq", OPR(0x10,0x32), BASE, ARG_OPR },
+ { "s8addq", OPRL(0x10,0x32), BASE, ARG_OPRL },
+ { "s8subq", OPR(0x10,0x3B), BASE, ARG_OPR },
+ { "s8subq", OPRL(0x10,0x3B), BASE, ARG_OPRL },
+ { "cmpule", OPR(0x10,0x3D), BASE, ARG_OPR },
+ { "cmpule", OPRL(0x10,0x3D), BASE, ARG_OPRL },
+ { "addl/v", OPR(0x10,0x40), BASE, ARG_OPR },
+ { "addl/v", OPRL(0x10,0x40), BASE, ARG_OPRL },
+ { "negl/v", OPR(0x10,0x49), BASE, ARG_OPRZ1 }, /* pseudo */
+ { "negl/v", OPRL(0x10,0x49), BASE, ARG_OPRLZ1 }, /* pseudo */
+ { "subl/v", OPR(0x10,0x49), BASE, ARG_OPR },
+ { "subl/v", OPRL(0x10,0x49), BASE, ARG_OPRL },
+ { "cmplt", OPR(0x10,0x4D), BASE, ARG_OPR },
+ { "cmplt", OPRL(0x10,0x4D), BASE, ARG_OPRL },
+ { "addq/v", OPR(0x10,0x60), BASE, ARG_OPR },
+ { "addq/v", OPRL(0x10,0x60), BASE, ARG_OPRL },
+ { "negq/v", OPR(0x10,0x69), BASE, ARG_OPRZ1 }, /* pseudo */
+ { "negq/v", OPRL(0x10,0x69), BASE, ARG_OPRLZ1 }, /* pseudo */
+ { "subq/v", OPR(0x10,0x69), BASE, ARG_OPR },
+ { "subq/v", OPRL(0x10,0x69), BASE, ARG_OPRL },
+ { "cmple", OPR(0x10,0x6D), BASE, ARG_OPR },
+ { "cmple", OPRL(0x10,0x6D), BASE, ARG_OPRL },
+
+ { "and", OPR(0x11,0x00), BASE, ARG_OPR },
+ { "and", OPRL(0x11,0x00), BASE, ARG_OPRL },
+ { "andnot", OPR(0x11,0x08), BASE, ARG_OPR }, /* alias */
+ { "andnot", OPRL(0x11,0x08), BASE, ARG_OPRL }, /* alias */
+ { "bic", OPR(0x11,0x08), BASE, ARG_OPR },
+ { "bic", OPRL(0x11,0x08), BASE, ARG_OPRL },
+ { "cmovlbs", OPR(0x11,0x14), BASE, ARG_OPR },
+ { "cmovlbs", OPRL(0x11,0x14), BASE, ARG_OPRL },
+ { "cmovlbc", OPR(0x11,0x16), BASE, ARG_OPR },
+ { "cmovlbc", OPRL(0x11,0x16), BASE, ARG_OPRL },
+ { "nop", OPR(0x11,0x20), BASE, { ZA, ZB, ZC } }, /* pseudo */
+ { "clr", OPR(0x11,0x20), BASE, { ZA, ZB, RC } }, /* pseudo */
+ { "mov", OPR(0x11,0x20), BASE, { ZA, RB, RC } }, /* pseudo */
+ { "mov", OPR(0x11,0x20), BASE, { RA, RBA, RC } }, /* pseudo */
+ { "mov", OPRL(0x11,0x20), BASE, { ZA, LIT, RC } }, /* pseudo */
+ { "or", OPR(0x11,0x20), BASE, ARG_OPR }, /* alias */
+ { "or", OPRL(0x11,0x20), BASE, ARG_OPRL }, /* alias */
+ { "bis", OPR(0x11,0x20), BASE, ARG_OPR },
+ { "bis", OPRL(0x11,0x20), BASE, ARG_OPRL },
+ { "cmoveq", OPR(0x11,0x24), BASE, ARG_OPR },
+ { "cmoveq", OPRL(0x11,0x24), BASE, ARG_OPRL },
+ { "cmovne", OPR(0x11,0x26), BASE, ARG_OPR },
+ { "cmovne", OPRL(0x11,0x26), BASE, ARG_OPRL },
+ { "not", OPR(0x11,0x28), BASE, ARG_OPRZ1 }, /* pseudo */
+ { "not", OPRL(0x11,0x28), BASE, ARG_OPRLZ1 }, /* pseudo */
+ { "ornot", OPR(0x11,0x28), BASE, ARG_OPR },
+ { "ornot", OPRL(0x11,0x28), BASE, ARG_OPRL },
+ { "xor", OPR(0x11,0x40), BASE, ARG_OPR },
+ { "xor", OPRL(0x11,0x40), BASE, ARG_OPRL },
+ { "cmovlt", OPR(0x11,0x44), BASE, ARG_OPR },
+ { "cmovlt", OPRL(0x11,0x44), BASE, ARG_OPRL },
+ { "cmovge", OPR(0x11,0x46), BASE, ARG_OPR },
+ { "cmovge", OPRL(0x11,0x46), BASE, ARG_OPRL },
+ { "eqv", OPR(0x11,0x48), BASE, ARG_OPR },
+ { "eqv", OPRL(0x11,0x48), BASE, ARG_OPRL },
+ { "xornot", OPR(0x11,0x48), BASE, ARG_OPR }, /* alias */
+ { "xornot", OPRL(0x11,0x48), BASE, ARG_OPRL }, /* alias */
+ { "amask", OPR(0x11,0x61), BASE, ARG_OPRZ1 }, /* ev56 but */
+ { "amask", OPRL(0x11,0x61), BASE, ARG_OPRLZ1 }, /* ev56 but */
+ { "cmovle", OPR(0x11,0x64), BASE, ARG_OPR },
+ { "cmovle", OPRL(0x11,0x64), BASE, ARG_OPRL },
+ { "cmovgt", OPR(0x11,0x66), BASE, ARG_OPR },
+ { "cmovgt", OPRL(0x11,0x66), BASE, ARG_OPRL },
+ { "implver", OPRL_(0x11,0x6C)|(31<<21)|(1<<13),
+ 0xFFFFFFE0, BASE, { RC } }, /* ev56 but */
+
+ { "mskbl", OPR(0x12,0x02), BASE, ARG_OPR },
+ { "mskbl", OPRL(0x12,0x02), BASE, ARG_OPRL },
+ { "extbl", OPR(0x12,0x06), BASE, ARG_OPR },
+ { "extbl", OPRL(0x12,0x06), BASE, ARG_OPRL },
+ { "insbl", OPR(0x12,0x0B), BASE, ARG_OPR },
+ { "insbl", OPRL(0x12,0x0B), BASE, ARG_OPRL },
+ { "mskwl", OPR(0x12,0x12), BASE, ARG_OPR },
+ { "mskwl", OPRL(0x12,0x12), BASE, ARG_OPRL },
+ { "extwl", OPR(0x12,0x16), BASE, ARG_OPR },
+ { "extwl", OPRL(0x12,0x16), BASE, ARG_OPRL },
+ { "inswl", OPR(0x12,0x1B), BASE, ARG_OPR },
+ { "inswl", OPRL(0x12,0x1B), BASE, ARG_OPRL },
+ { "mskll", OPR(0x12,0x22), BASE, ARG_OPR },
+ { "mskll", OPRL(0x12,0x22), BASE, ARG_OPRL },
+ { "extll", OPR(0x12,0x26), BASE, ARG_OPR },
+ { "extll", OPRL(0x12,0x26), BASE, ARG_OPRL },
+ { "insll", OPR(0x12,0x2B), BASE, ARG_OPR },
+ { "insll", OPRL(0x12,0x2B), BASE, ARG_OPRL },
+ { "zap", OPR(0x12,0x30), BASE, ARG_OPR },
+ { "zap", OPRL(0x12,0x30), BASE, ARG_OPRL },
+ { "zapnot", OPR(0x12,0x31), BASE, ARG_OPR },
+ { "zapnot", OPRL(0x12,0x31), BASE, ARG_OPRL },
+ { "mskql", OPR(0x12,0x32), BASE, ARG_OPR },
+ { "mskql", OPRL(0x12,0x32), BASE, ARG_OPRL },
+ { "srl", OPR(0x12,0x34), BASE, ARG_OPR },
+ { "srl", OPRL(0x12,0x34), BASE, ARG_OPRL },
+ { "extql", OPR(0x12,0x36), BASE, ARG_OPR },
+ { "extql", OPRL(0x12,0x36), BASE, ARG_OPRL },
+ { "sll", OPR(0x12,0x39), BASE, ARG_OPR },
+ { "sll", OPRL(0x12,0x39), BASE, ARG_OPRL },
+ { "insql", OPR(0x12,0x3B), BASE, ARG_OPR },
+ { "insql", OPRL(0x12,0x3B), BASE, ARG_OPRL },
+ { "sra", OPR(0x12,0x3C), BASE, ARG_OPR },
+ { "sra", OPRL(0x12,0x3C), BASE, ARG_OPRL },
+ { "mskwh", OPR(0x12,0x52), BASE, ARG_OPR },
+ { "mskwh", OPRL(0x12,0x52), BASE, ARG_OPRL },
+ { "inswh", OPR(0x12,0x57), BASE, ARG_OPR },
+ { "inswh", OPRL(0x12,0x57), BASE, ARG_OPRL },
+ { "extwh", OPR(0x12,0x5A), BASE, ARG_OPR },
+ { "extwh", OPRL(0x12,0x5A), BASE, ARG_OPRL },
+ { "msklh", OPR(0x12,0x62), BASE, ARG_OPR },
+ { "msklh", OPRL(0x12,0x62), BASE, ARG_OPRL },
+ { "inslh", OPR(0x12,0x67), BASE, ARG_OPR },
+ { "inslh", OPRL(0x12,0x67), BASE, ARG_OPRL },
+ { "extlh", OPR(0x12,0x6A), BASE, ARG_OPR },
+ { "extlh", OPRL(0x12,0x6A), BASE, ARG_OPRL },
+ { "mskqh", OPR(0x12,0x72), BASE, ARG_OPR },
+ { "mskqh", OPRL(0x12,0x72), BASE, ARG_OPRL },
+ { "insqh", OPR(0x12,0x77), BASE, ARG_OPR },
+ { "insqh", OPRL(0x12,0x77), BASE, ARG_OPRL },
+ { "extqh", OPR(0x12,0x7A), BASE, ARG_OPR },
+ { "extqh", OPRL(0x12,0x7A), BASE, ARG_OPRL },
+
+ { "mull", OPR(0x13,0x00), BASE, ARG_OPR },
+ { "mull", OPRL(0x13,0x00), BASE, ARG_OPRL },
+ { "mulq", OPR(0x13,0x20), BASE, ARG_OPR },
+ { "mulq", OPRL(0x13,0x20), BASE, ARG_OPRL },
+ { "umulh", OPR(0x13,0x30), BASE, ARG_OPR },
+ { "umulh", OPRL(0x13,0x30), BASE, ARG_OPRL },
+ { "mull/v", OPR(0x13,0x40), BASE, ARG_OPR },
+ { "mull/v", OPRL(0x13,0x40), BASE, ARG_OPRL },
+ { "mulq/v", OPR(0x13,0x60), BASE, ARG_OPR },
+ { "mulq/v", OPRL(0x13,0x60), BASE, ARG_OPRL },
+
+ { "itofs", FP(0x14,0x004), CIX, { RA, ZB, FC } },
+ { "sqrtf/c", FP(0x14,0x00A), CIX, ARG_FPZ1 },
+ { "sqrts/c", FP(0x14,0x00B), CIX, ARG_FPZ1 },
+ { "itoff", FP(0x14,0x014), CIX, { RA, ZB, FC } },
+ { "itoft", FP(0x14,0x024), CIX, { RA, ZB, FC } },
+ { "sqrtg/c", FP(0x14,0x02A), CIX, ARG_FPZ1 },
+ { "sqrtt/c", FP(0x14,0x02B), CIX, ARG_FPZ1 },
+ { "sqrts/m", FP(0x14,0x04B), CIX, ARG_FPZ1 },
+ { "sqrtt/m", FP(0x14,0x06B), CIX, ARG_FPZ1 },
+ { "sqrtf", FP(0x14,0x08A), CIX, ARG_FPZ1 },
+ { "sqrts", FP(0x14,0x08B), CIX, ARG_FPZ1 },
+ { "sqrtg", FP(0x14,0x0AA), CIX, ARG_FPZ1 },
+ { "sqrtt", FP(0x14,0x0AB), CIX, ARG_FPZ1 },
+ { "sqrts/d", FP(0x14,0x0CB), CIX, ARG_FPZ1 },
+ { "sqrtt/d", FP(0x14,0x0EB), CIX, ARG_FPZ1 },
+ { "sqrtf/uc", FP(0x14,0x10A), CIX, ARG_FPZ1 },
+ { "sqrts/uc", FP(0x14,0x10B), CIX, ARG_FPZ1 },
+ { "sqrtg/uc", FP(0x14,0x12A), CIX, ARG_FPZ1 },
+ { "sqrtt/uc", FP(0x14,0x12B), CIX, ARG_FPZ1 },
+ { "sqrts/um", FP(0x14,0x14B), CIX, ARG_FPZ1 },
+ { "sqrtt/um", FP(0x14,0x16B), CIX, ARG_FPZ1 },
+ { "sqrtf/u", FP(0x14,0x18A), CIX, ARG_FPZ1 },
+ { "sqrts/u", FP(0x14,0x18B), CIX, ARG_FPZ1 },
+ { "sqrtg/u", FP(0x14,0x1AA), CIX, ARG_FPZ1 },
+ { "sqrtt/u", FP(0x14,0x1AB), CIX, ARG_FPZ1 },
+ { "sqrts/ud", FP(0x14,0x1CB), CIX, ARG_FPZ1 },
+ { "sqrtt/ud", FP(0x14,0x1EB), CIX, ARG_FPZ1 },
+ { "sqrtf/sc", FP(0x14,0x40A), CIX, ARG_FPZ1 },
+ { "sqrtg/sc", FP(0x14,0x42A), CIX, ARG_FPZ1 },
+ { "sqrtf/s", FP(0x14,0x48A), CIX, ARG_FPZ1 },
+ { "sqrtg/s", FP(0x14,0x4AA), CIX, ARG_FPZ1 },
+ { "sqrtf/suc", FP(0x14,0x50A), CIX, ARG_FPZ1 },
+ { "sqrts/suc", FP(0x14,0x50B), CIX, ARG_FPZ1 },
+ { "sqrtg/suc", FP(0x14,0x52A), CIX, ARG_FPZ1 },
+ { "sqrtt/suc", FP(0x14,0x52B), CIX, ARG_FPZ1 },
+ { "sqrts/sum", FP(0x14,0x54B), CIX, ARG_FPZ1 },
+ { "sqrtt/sum", FP(0x14,0x56B), CIX, ARG_FPZ1 },
+ { "sqrtf/su", FP(0x14,0x58A), CIX, ARG_FPZ1 },
+ { "sqrts/su", FP(0x14,0x58B), CIX, ARG_FPZ1 },
+ { "sqrtg/su", FP(0x14,0x5AA), CIX, ARG_FPZ1 },
+ { "sqrtt/su", FP(0x14,0x5AB), CIX, ARG_FPZ1 },
+ { "sqrts/sud", FP(0x14,0x5CB), CIX, ARG_FPZ1 },
+ { "sqrtt/sud", FP(0x14,0x5EB), CIX, ARG_FPZ1 },
+ { "sqrts/suic", FP(0x14,0x70B), CIX, ARG_FPZ1 },
+ { "sqrtt/suic", FP(0x14,0x72B), CIX, ARG_FPZ1 },
+ { "sqrts/suim", FP(0x14,0x74B), CIX, ARG_FPZ1 },
+ { "sqrtt/suim", FP(0x14,0x76B), CIX, ARG_FPZ1 },
+ { "sqrts/sui", FP(0x14,0x78B), CIX, ARG_FPZ1 },
+ { "sqrtt/sui", FP(0x14,0x7AB), CIX, ARG_FPZ1 },
+ { "sqrts/suid", FP(0x14,0x7CB), CIX, ARG_FPZ1 },
+ { "sqrtt/suid", FP(0x14,0x7EB), CIX, ARG_FPZ1 },
+
+ { "addf/c", FP(0x15,0x000), BASE, ARG_FP },
+ { "subf/c", FP(0x15,0x001), BASE, ARG_FP },
+ { "mulf/c", FP(0x15,0x002), BASE, ARG_FP },
+ { "divf/c", FP(0x15,0x003), BASE, ARG_FP },
+ { "cvtdg/c", FP(0x15,0x01E), BASE, ARG_FPZ1 },
+ { "addg/c", FP(0x15,0x020), BASE, ARG_FP },
+ { "subg/c", FP(0x15,0x021), BASE, ARG_FP },
+ { "mulg/c", FP(0x15,0x022), BASE, ARG_FP },
+ { "divg/c", FP(0x15,0x023), BASE, ARG_FP },
+ { "cvtgf/c", FP(0x15,0x02C), BASE, ARG_FPZ1 },
+ { "cvtgd/c", FP(0x15,0x02D), BASE, ARG_FPZ1 },
+ { "cvtgq/c", FP(0x15,0x02F), BASE, ARG_FPZ1 },
+ { "cvtqf/c", FP(0x15,0x03C), BASE, ARG_FPZ1 },
+ { "cvtqg/c", FP(0x15,0x03E), BASE, ARG_FPZ1 },
+ { "addf", FP(0x15,0x080), BASE, ARG_FP },
+ { "negf", FP(0x15,0x081), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subf", FP(0x15,0x081), BASE, ARG_FP },
+ { "mulf", FP(0x15,0x082), BASE, ARG_FP },
+ { "divf", FP(0x15,0x083), BASE, ARG_FP },
+ { "cvtdg", FP(0x15,0x09E), BASE, ARG_FPZ1 },
+ { "addg", FP(0x15,0x0A0), BASE, ARG_FP },
+ { "negg", FP(0x15,0x0A1), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subg", FP(0x15,0x0A1), BASE, ARG_FP },
+ { "mulg", FP(0x15,0x0A2), BASE, ARG_FP },
+ { "divg", FP(0x15,0x0A3), BASE, ARG_FP },
+ { "cmpgeq", FP(0x15,0x0A5), BASE, ARG_FP },
+ { "cmpglt", FP(0x15,0x0A6), BASE, ARG_FP },
+ { "cmpgle", FP(0x15,0x0A7), BASE, ARG_FP },
+ { "cvtgf", FP(0x15,0x0AC), BASE, ARG_FPZ1 },
+ { "cvtgd", FP(0x15,0x0AD), BASE, ARG_FPZ1 },
+ { "cvtgq", FP(0x15,0x0AF), BASE, ARG_FPZ1 },
+ { "cvtqf", FP(0x15,0x0BC), BASE, ARG_FPZ1 },
+ { "cvtqg", FP(0x15,0x0BE), BASE, ARG_FPZ1 },
+ { "addf/uc", FP(0x15,0x100), BASE, ARG_FP },
+ { "subf/uc", FP(0x15,0x101), BASE, ARG_FP },
+ { "mulf/uc", FP(0x15,0x102), BASE, ARG_FP },
+ { "divf/uc", FP(0x15,0x103), BASE, ARG_FP },
+ { "cvtdg/uc", FP(0x15,0x11E), BASE, ARG_FPZ1 },
+ { "addg/uc", FP(0x15,0x120), BASE, ARG_FP },
+ { "subg/uc", FP(0x15,0x121), BASE, ARG_FP },
+ { "mulg/uc", FP(0x15,0x122), BASE, ARG_FP },
+ { "divg/uc", FP(0x15,0x123), BASE, ARG_FP },
+ { "cvtgf/uc", FP(0x15,0x12C), BASE, ARG_FPZ1 },
+ { "cvtgd/uc", FP(0x15,0x12D), BASE, ARG_FPZ1 },
+ { "cvtgq/vc", FP(0x15,0x12F), BASE, ARG_FPZ1 },
+ { "addf/u", FP(0x15,0x180), BASE, ARG_FP },
+ { "subf/u", FP(0x15,0x181), BASE, ARG_FP },
+ { "mulf/u", FP(0x15,0x182), BASE, ARG_FP },
+ { "divf/u", FP(0x15,0x183), BASE, ARG_FP },
+ { "cvtdg/u", FP(0x15,0x19E), BASE, ARG_FPZ1 },
+ { "addg/u", FP(0x15,0x1A0), BASE, ARG_FP },
+ { "subg/u", FP(0x15,0x1A1), BASE, ARG_FP },
+ { "mulg/u", FP(0x15,0x1A2), BASE, ARG_FP },
+ { "divg/u", FP(0x15,0x1A3), BASE, ARG_FP },
+ { "cvtgf/u", FP(0x15,0x1AC), BASE, ARG_FPZ1 },
+ { "cvtgd/u", FP(0x15,0x1AD), BASE, ARG_FPZ1 },
+ { "cvtgq/v", FP(0x15,0x1AF), BASE, ARG_FPZ1 },
+ { "addf/sc", FP(0x15,0x400), BASE, ARG_FP },
+ { "subf/sc", FP(0x15,0x401), BASE, ARG_FP },
+ { "mulf/sc", FP(0x15,0x402), BASE, ARG_FP },
+ { "divf/sc", FP(0x15,0x403), BASE, ARG_FP },
+ { "cvtdg/sc", FP(0x15,0x41E), BASE, ARG_FPZ1 },
+ { "addg/sc", FP(0x15,0x420), BASE, ARG_FP },
+ { "subg/sc", FP(0x15,0x421), BASE, ARG_FP },
+ { "mulg/sc", FP(0x15,0x422), BASE, ARG_FP },
+ { "divg/sc", FP(0x15,0x423), BASE, ARG_FP },
+ { "cvtgf/sc", FP(0x15,0x42C), BASE, ARG_FPZ1 },
+ { "cvtgd/sc", FP(0x15,0x42D), BASE, ARG_FPZ1 },
+ { "cvtgq/sc", FP(0x15,0x42F), BASE, ARG_FPZ1 },
+ { "addf/s", FP(0x15,0x480), BASE, ARG_FP },
+ { "negf/s", FP(0x15,0x481), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subf/s", FP(0x15,0x481), BASE, ARG_FP },
+ { "mulf/s", FP(0x15,0x482), BASE, ARG_FP },
+ { "divf/s", FP(0x15,0x483), BASE, ARG_FP },
+ { "cvtdg/s", FP(0x15,0x49E), BASE, ARG_FPZ1 },
+ { "addg/s", FP(0x15,0x4A0), BASE, ARG_FP },
+ { "negg/s", FP(0x15,0x4A1), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subg/s", FP(0x15,0x4A1), BASE, ARG_FP },
+ { "mulg/s", FP(0x15,0x4A2), BASE, ARG_FP },
+ { "divg/s", FP(0x15,0x4A3), BASE, ARG_FP },
+ { "cmpgeq/s", FP(0x15,0x4A5), BASE, ARG_FP },
+ { "cmpglt/s", FP(0x15,0x4A6), BASE, ARG_FP },
+ { "cmpgle/s", FP(0x15,0x4A7), BASE, ARG_FP },
+ { "cvtgf/s", FP(0x15,0x4AC), BASE, ARG_FPZ1 },
+ { "cvtgd/s", FP(0x15,0x4AD), BASE, ARG_FPZ1 },
+ { "cvtgq/s", FP(0x15,0x4AF), BASE, ARG_FPZ1 },
+ { "addf/suc", FP(0x15,0x500), BASE, ARG_FP },
+ { "subf/suc", FP(0x15,0x501), BASE, ARG_FP },
+ { "mulf/suc", FP(0x15,0x502), BASE, ARG_FP },
+ { "divf/suc", FP(0x15,0x503), BASE, ARG_FP },
+ { "cvtdg/suc", FP(0x15,0x51E), BASE, ARG_FPZ1 },
+ { "addg/suc", FP(0x15,0x520), BASE, ARG_FP },
+ { "subg/suc", FP(0x15,0x521), BASE, ARG_FP },
+ { "mulg/suc", FP(0x15,0x522), BASE, ARG_FP },
+ { "divg/suc", FP(0x15,0x523), BASE, ARG_FP },
+ { "cvtgf/suc", FP(0x15,0x52C), BASE, ARG_FPZ1 },
+ { "cvtgd/suc", FP(0x15,0x52D), BASE, ARG_FPZ1 },
+ { "cvtgq/svc", FP(0x15,0x52F), BASE, ARG_FPZ1 },
+ { "addf/su", FP(0x15,0x580), BASE, ARG_FP },
+ { "subf/su", FP(0x15,0x581), BASE, ARG_FP },
+ { "mulf/su", FP(0x15,0x582), BASE, ARG_FP },
+ { "divf/su", FP(0x15,0x583), BASE, ARG_FP },
+ { "cvtdg/su", FP(0x15,0x59E), BASE, ARG_FPZ1 },
+ { "addg/su", FP(0x15,0x5A0), BASE, ARG_FP },
+ { "subg/su", FP(0x15,0x5A1), BASE, ARG_FP },
+ { "mulg/su", FP(0x15,0x5A2), BASE, ARG_FP },
+ { "divg/su", FP(0x15,0x5A3), BASE, ARG_FP },
+ { "cvtgf/su", FP(0x15,0x5AC), BASE, ARG_FPZ1 },
+ { "cvtgd/su", FP(0x15,0x5AD), BASE, ARG_FPZ1 },
+ { "cvtgq/sv", FP(0x15,0x5AF), BASE, ARG_FPZ1 },
+
+ { "adds/c", FP(0x16,0x000), BASE, ARG_FP },
+ { "subs/c", FP(0x16,0x001), BASE, ARG_FP },
+ { "muls/c", FP(0x16,0x002), BASE, ARG_FP },
+ { "divs/c", FP(0x16,0x003), BASE, ARG_FP },
+ { "addt/c", FP(0x16,0x020), BASE, ARG_FP },
+ { "subt/c", FP(0x16,0x021), BASE, ARG_FP },
+ { "mult/c", FP(0x16,0x022), BASE, ARG_FP },
+ { "divt/c", FP(0x16,0x023), BASE, ARG_FP },
+ { "cvtts/c", FP(0x16,0x02C), BASE, ARG_FPZ1 },
+ { "cvttq/c", FP(0x16,0x02F), BASE, ARG_FPZ1 },
+ { "cvtqs/c", FP(0x16,0x03C), BASE, ARG_FPZ1 },
+ { "cvtqt/c", FP(0x16,0x03E), BASE, ARG_FPZ1 },
+ { "adds/m", FP(0x16,0x040), BASE, ARG_FP },
+ { "subs/m", FP(0x16,0x041), BASE, ARG_FP },
+ { "muls/m", FP(0x16,0x042), BASE, ARG_FP },
+ { "divs/m", FP(0x16,0x043), BASE, ARG_FP },
+ { "addt/m", FP(0x16,0x060), BASE, ARG_FP },
+ { "subt/m", FP(0x16,0x061), BASE, ARG_FP },
+ { "mult/m", FP(0x16,0x062), BASE, ARG_FP },
+ { "divt/m", FP(0x16,0x063), BASE, ARG_FP },
+ { "cvtts/m", FP(0x16,0x06C), BASE, ARG_FPZ1 },
+ { "cvttq/m", FP(0x16,0x06F), BASE, ARG_FPZ1 },
+ { "cvtqs/m", FP(0x16,0x07C), BASE, ARG_FPZ1 },
+ { "cvtqt/m", FP(0x16,0x07E), BASE, ARG_FPZ1 },
+ { "adds", FP(0x16,0x080), BASE, ARG_FP },
+ { "negs", FP(0x16,0x081), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subs", FP(0x16,0x081), BASE, ARG_FP },
+ { "muls", FP(0x16,0x082), BASE, ARG_FP },
+ { "divs", FP(0x16,0x083), BASE, ARG_FP },
+ { "addt", FP(0x16,0x0A0), BASE, ARG_FP },
+ { "negt", FP(0x16,0x0A1), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subt", FP(0x16,0x0A1), BASE, ARG_FP },
+ { "mult", FP(0x16,0x0A2), BASE, ARG_FP },
+ { "divt", FP(0x16,0x0A3), BASE, ARG_FP },
+ { "cmptun", FP(0x16,0x0A4), BASE, ARG_FP },
+ { "cmpteq", FP(0x16,0x0A5), BASE, ARG_FP },
+ { "cmptlt", FP(0x16,0x0A6), BASE, ARG_FP },
+ { "cmptle", FP(0x16,0x0A7), BASE, ARG_FP },
+ { "cvtts", FP(0x16,0x0AC), BASE, ARG_FPZ1 },
+ { "cvttq", FP(0x16,0x0AF), BASE, ARG_FPZ1 },
+ { "cvtqs", FP(0x16,0x0BC), BASE, ARG_FPZ1 },
+ { "cvtqt", FP(0x16,0x0BE), BASE, ARG_FPZ1 },
+ { "adds/d", FP(0x16,0x0C0), BASE, ARG_FP },
+ { "subs/d", FP(0x16,0x0C1), BASE, ARG_FP },
+ { "muls/d", FP(0x16,0x0C2), BASE, ARG_FP },
+ { "divs/d", FP(0x16,0x0C3), BASE, ARG_FP },
+ { "addt/d", FP(0x16,0x0E0), BASE, ARG_FP },
+ { "subt/d", FP(0x16,0x0E1), BASE, ARG_FP },
+ { "mult/d", FP(0x16,0x0E2), BASE, ARG_FP },
+ { "divt/d", FP(0x16,0x0E3), BASE, ARG_FP },
+ { "cvtts/d", FP(0x16,0x0EC), BASE, ARG_FPZ1 },
+ { "cvttq/d", FP(0x16,0x0EF), BASE, ARG_FPZ1 },
+ { "cvtqs/d", FP(0x16,0x0FC), BASE, ARG_FPZ1 },
+ { "cvtqt/d", FP(0x16,0x0FE), BASE, ARG_FPZ1 },
+ { "adds/uc", FP(0x16,0x100), BASE, ARG_FP },
+ { "subs/uc", FP(0x16,0x101), BASE, ARG_FP },
+ { "muls/uc", FP(0x16,0x102), BASE, ARG_FP },
+ { "divs/uc", FP(0x16,0x103), BASE, ARG_FP },
+ { "addt/uc", FP(0x16,0x120), BASE, ARG_FP },
+ { "subt/uc", FP(0x16,0x121), BASE, ARG_FP },
+ { "mult/uc", FP(0x16,0x122), BASE, ARG_FP },
+ { "divt/uc", FP(0x16,0x123), BASE, ARG_FP },
+ { "cvtts/uc", FP(0x16,0x12C), BASE, ARG_FPZ1 },
+ { "cvttq/vc", FP(0x16,0x12F), BASE, ARG_FPZ1 },
+ { "adds/um", FP(0x16,0x140), BASE, ARG_FP },
+ { "subs/um", FP(0x16,0x141), BASE, ARG_FP },
+ { "muls/um", FP(0x16,0x142), BASE, ARG_FP },
+ { "divs/um", FP(0x16,0x143), BASE, ARG_FP },
+ { "addt/um", FP(0x16,0x160), BASE, ARG_FP },
+ { "subt/um", FP(0x16,0x161), BASE, ARG_FP },
+ { "mult/um", FP(0x16,0x162), BASE, ARG_FP },
+ { "divt/um", FP(0x16,0x163), BASE, ARG_FP },
+ { "cvtts/um", FP(0x16,0x16C), BASE, ARG_FPZ1 },
+ { "cvttq/vm", FP(0x16,0x16F), BASE, ARG_FPZ1 },
+ { "adds/u", FP(0x16,0x180), BASE, ARG_FP },
+ { "subs/u", FP(0x16,0x181), BASE, ARG_FP },
+ { "muls/u", FP(0x16,0x182), BASE, ARG_FP },
+ { "divs/u", FP(0x16,0x183), BASE, ARG_FP },
+ { "addt/u", FP(0x16,0x1A0), BASE, ARG_FP },
+ { "subt/u", FP(0x16,0x1A1), BASE, ARG_FP },
+ { "mult/u", FP(0x16,0x1A2), BASE, ARG_FP },
+ { "divt/u", FP(0x16,0x1A3), BASE, ARG_FP },
+ { "cvtts/u", FP(0x16,0x1AC), BASE, ARG_FPZ1 },
+ { "cvttq/v", FP(0x16,0x1AF), BASE, ARG_FPZ1 },
+ { "adds/ud", FP(0x16,0x1C0), BASE, ARG_FP },
+ { "subs/ud", FP(0x16,0x1C1), BASE, ARG_FP },
+ { "muls/ud", FP(0x16,0x1C2), BASE, ARG_FP },
+ { "divs/ud", FP(0x16,0x1C3), BASE, ARG_FP },
+ { "addt/ud", FP(0x16,0x1E0), BASE, ARG_FP },
+ { "subt/ud", FP(0x16,0x1E1), BASE, ARG_FP },
+ { "mult/ud", FP(0x16,0x1E2), BASE, ARG_FP },
+ { "divt/ud", FP(0x16,0x1E3), BASE, ARG_FP },
+ { "cvtts/ud", FP(0x16,0x1EC), BASE, ARG_FPZ1 },
+ { "cvttq/vd", FP(0x16,0x1EF), BASE, ARG_FPZ1 },
+ { "cvtst", FP(0x16,0x2AC), BASE, ARG_FPZ1 },
+ { "adds/suc", FP(0x16,0x500), BASE, ARG_FP },
+ { "subs/suc", FP(0x16,0x501), BASE, ARG_FP },
+ { "muls/suc", FP(0x16,0x502), BASE, ARG_FP },
+ { "divs/suc", FP(0x16,0x503), BASE, ARG_FP },
+ { "addt/suc", FP(0x16,0x520), BASE, ARG_FP },
+ { "subt/suc", FP(0x16,0x521), BASE, ARG_FP },
+ { "mult/suc", FP(0x16,0x522), BASE, ARG_FP },
+ { "divt/suc", FP(0x16,0x523), BASE, ARG_FP },
+ { "cvtts/suc", FP(0x16,0x52C), BASE, ARG_FPZ1 },
+ { "cvttq/svc", FP(0x16,0x52F), BASE, ARG_FPZ1 },
+ { "adds/sum", FP(0x16,0x540), BASE, ARG_FP },
+ { "subs/sum", FP(0x16,0x541), BASE, ARG_FP },
+ { "muls/sum", FP(0x16,0x542), BASE, ARG_FP },
+ { "divs/sum", FP(0x16,0x543), BASE, ARG_FP },
+ { "addt/sum", FP(0x16,0x560), BASE, ARG_FP },
+ { "subt/sum", FP(0x16,0x561), BASE, ARG_FP },
+ { "mult/sum", FP(0x16,0x562), BASE, ARG_FP },
+ { "divt/sum", FP(0x16,0x563), BASE, ARG_FP },
+ { "cvtts/sum", FP(0x16,0x56C), BASE, ARG_FPZ1 },
+ { "cvttq/svm", FP(0x16,0x56F), BASE, ARG_FPZ1 },
+ { "adds/su", FP(0x16,0x580), BASE, ARG_FP },
+ { "negs/su", FP(0x16,0x581), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subs/su", FP(0x16,0x581), BASE, ARG_FP },
+ { "muls/su", FP(0x16,0x582), BASE, ARG_FP },
+ { "divs/su", FP(0x16,0x583), BASE, ARG_FP },
+ { "addt/su", FP(0x16,0x5A0), BASE, ARG_FP },
+ { "negt/su", FP(0x16,0x5A1), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subt/su", FP(0x16,0x5A1), BASE, ARG_FP },
+ { "mult/su", FP(0x16,0x5A2), BASE, ARG_FP },
+ { "divt/su", FP(0x16,0x5A3), BASE, ARG_FP },
+ { "cmptun/su", FP(0x16,0x5A4), BASE, ARG_FP },
+ { "cmpteq/su", FP(0x16,0x5A5), BASE, ARG_FP },
+ { "cmptlt/su", FP(0x16,0x5A6), BASE, ARG_FP },
+ { "cmptle/su", FP(0x16,0x5A7), BASE, ARG_FP },
+ { "cvtts/su", FP(0x16,0x5AC), BASE, ARG_FPZ1 },
+ { "cvttq/sv", FP(0x16,0x5AF), BASE, ARG_FPZ1 },
+ { "adds/sud", FP(0x16,0x5C0), BASE, ARG_FP },
+ { "subs/sud", FP(0x16,0x5C1), BASE, ARG_FP },
+ { "muls/sud", FP(0x16,0x5C2), BASE, ARG_FP },
+ { "divs/sud", FP(0x16,0x5C3), BASE, ARG_FP },
+ { "addt/sud", FP(0x16,0x5E0), BASE, ARG_FP },
+ { "subt/sud", FP(0x16,0x5E1), BASE, ARG_FP },
+ { "mult/sud", FP(0x16,0x5E2), BASE, ARG_FP },
+ { "divt/sud", FP(0x16,0x5E3), BASE, ARG_FP },
+ { "cvtts/sud", FP(0x16,0x5EC), BASE, ARG_FPZ1 },
+ { "cvttq/svd", FP(0x16,0x5EF), BASE, ARG_FPZ1 },
+ { "cvtst/s", FP(0x16,0x6AC), BASE, ARG_FPZ1 },
+ { "adds/suic", FP(0x16,0x700), BASE, ARG_FP },
+ { "subs/suic", FP(0x16,0x701), BASE, ARG_FP },
+ { "muls/suic", FP(0x16,0x702), BASE, ARG_FP },
+ { "divs/suic", FP(0x16,0x703), BASE, ARG_FP },
+ { "addt/suic", FP(0x16,0x720), BASE, ARG_FP },
+ { "subt/suic", FP(0x16,0x721), BASE, ARG_FP },
+ { "mult/suic", FP(0x16,0x722), BASE, ARG_FP },
+ { "divt/suic", FP(0x16,0x723), BASE, ARG_FP },
+ { "cvtts/suic", FP(0x16,0x72C), BASE, ARG_FPZ1 },
+ { "cvttq/svic", FP(0x16,0x72F), BASE, ARG_FPZ1 },
+ { "cvtqs/suic", FP(0x16,0x73C), BASE, ARG_FPZ1 },
+ { "cvtqt/suic", FP(0x16,0x73E), BASE, ARG_FPZ1 },
+ { "adds/suim", FP(0x16,0x740), BASE, ARG_FP },
+ { "subs/suim", FP(0x16,0x741), BASE, ARG_FP },
+ { "muls/suim", FP(0x16,0x742), BASE, ARG_FP },
+ { "divs/suim", FP(0x16,0x743), BASE, ARG_FP },
+ { "addt/suim", FP(0x16,0x760), BASE, ARG_FP },
+ { "subt/suim", FP(0x16,0x761), BASE, ARG_FP },
+ { "mult/suim", FP(0x16,0x762), BASE, ARG_FP },
+ { "divt/suim", FP(0x16,0x763), BASE, ARG_FP },
+ { "cvtts/suim", FP(0x16,0x76C), BASE, ARG_FPZ1 },
+ { "cvttq/svim", FP(0x16,0x76F), BASE, ARG_FPZ1 },
+ { "cvtqs/suim", FP(0x16,0x77C), BASE, ARG_FPZ1 },
+ { "cvtqt/suim", FP(0x16,0x77E), BASE, ARG_FPZ1 },
+ { "adds/sui", FP(0x16,0x780), BASE, ARG_FP },
+ { "negs/sui", FP(0x16,0x781), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subs/sui", FP(0x16,0x781), BASE, ARG_FP },
+ { "muls/sui", FP(0x16,0x782), BASE, ARG_FP },
+ { "divs/sui", FP(0x16,0x783), BASE, ARG_FP },
+ { "addt/sui", FP(0x16,0x7A0), BASE, ARG_FP },
+ { "negt/sui", FP(0x16,0x7A1), BASE, ARG_FPZ1 }, /* pseudo */
+ { "subt/sui", FP(0x16,0x7A1), BASE, ARG_FP },
+ { "mult/sui", FP(0x16,0x7A2), BASE, ARG_FP },
+ { "divt/sui", FP(0x16,0x7A3), BASE, ARG_FP },
+ { "cvtts/sui", FP(0x16,0x7AC), BASE, ARG_FPZ1 },
+ { "cvttq/svi", FP(0x16,0x7AF), BASE, ARG_FPZ1 },
+ { "cvtqs/sui", FP(0x16,0x7BC), BASE, ARG_FPZ1 },
+ { "cvtqt/sui", FP(0x16,0x7BE), BASE, ARG_FPZ1 },
+ { "adds/suid", FP(0x16,0x7C0), BASE, ARG_FP },
+ { "subs/suid", FP(0x16,0x7C1), BASE, ARG_FP },
+ { "muls/suid", FP(0x16,0x7C2), BASE, ARG_FP },
+ { "divs/suid", FP(0x16,0x7C3), BASE, ARG_FP },
+ { "addt/suid", FP(0x16,0x7E0), BASE, ARG_FP },
+ { "subt/suid", FP(0x16,0x7E1), BASE, ARG_FP },
+ { "mult/suid", FP(0x16,0x7E2), BASE, ARG_FP },
+ { "divt/suid", FP(0x16,0x7E3), BASE, ARG_FP },
+ { "cvtts/suid", FP(0x16,0x7EC), BASE, ARG_FPZ1 },
+ { "cvttq/svid", FP(0x16,0x7EF), BASE, ARG_FPZ1 },
+ { "cvtqs/suid", FP(0x16,0x7FC), BASE, ARG_FPZ1 },
+ { "cvtqt/suid", FP(0x16,0x7FE), BASE, ARG_FPZ1 },
+
+ { "cvtlq", FP(0x17,0x010), BASE, ARG_FPZ1 },
+ { "fnop", FP(0x17,0x020), BASE, { ZA, ZB, ZC } }, /* pseudo */
+ { "fclr", FP(0x17,0x020), BASE, { ZA, ZB, FC } }, /* pseudo */
+ { "fabs", FP(0x17,0x020), BASE, ARG_FPZ1 }, /* pseudo */
+ { "fmov", FP(0x17,0x020), BASE, { FA, RBA, FC } }, /* pseudo */
+ { "cpys", FP(0x17,0x020), BASE, ARG_FP },
+ { "fneg", FP(0x17,0x021), BASE, { FA, RBA, FC } }, /* pseudo */
+ { "cpysn", FP(0x17,0x021), BASE, ARG_FP },
+ { "cpyse", FP(0x17,0x022), BASE, ARG_FP },
+ { "mt_fpcr", FP(0x17,0x024), BASE, { FA, RBA, RCA } },
+ { "mf_fpcr", FP(0x17,0x025), BASE, { FA, RBA, RCA } },
+ { "fcmoveq", FP(0x17,0x02A), BASE, ARG_FP },
+ { "fcmovne", FP(0x17,0x02B), BASE, ARG_FP },
+ { "fcmovlt", FP(0x17,0x02C), BASE, ARG_FP },
+ { "fcmovge", FP(0x17,0x02D), BASE, ARG_FP },
+ { "fcmovle", FP(0x17,0x02E), BASE, ARG_FP },
+ { "fcmovgt", FP(0x17,0x02F), BASE, ARG_FP },
+ { "cvtql", FP(0x17,0x030), BASE, ARG_FPZ1 },
+ { "cvtql/v", FP(0x17,0x130), BASE, ARG_FPZ1 },
+ { "cvtql/sv", FP(0x17,0x530), BASE, ARG_FPZ1 },
+
+ { "trapb", MFC(0x18,0x0000), BASE, ARG_NONE },
+ { "draint", MFC(0x18,0x0000), BASE, ARG_NONE }, /* alias */
+ { "excb", MFC(0x18,0x0400), BASE, ARG_NONE },
+ { "mb", MFC(0x18,0x4000), BASE, ARG_NONE },
+ { "wmb", MFC(0x18,0x4400), BASE, ARG_NONE },
+ { "fetch", MFC(0x18,0x8000), BASE, { PRB } },
+ { "fetch_m", MFC(0x18,0xA000), BASE, { PRB } },
+ { "rpcc", MFC(0x18,0xC000), BASE, { RA } },
+ { "rc", MFC(0x18,0xE000), BASE, { RA } },
+ { "ecb", MFC(0x18,0xE800), BASE, { PRB } }, /* ev56 una */
+ { "rs", MFC(0x18,0xF000), BASE, { RA } },
+ { "wh64", MFC(0x18,0xF800), BASE, { PRB } }, /* ev56 una */
+
+ { "hw_mfpr", OPR(0x19,0x00), EV4, { RA, RBA, EV4EXTHWINDEX } },
+ { "hw_mfpr", OP(0x19), OP_MASK, EV5, { RA, RBA, EV5HWINDEX } },
+ { "hw_mfpr", OP(0x19), OP_MASK, EV6, { RA, ZB, EV6HWINDEX } },
+ { "hw_mfpr/i", OPR(0x19,0x01), EV4, ARG_EV4HWMPR },
+ { "hw_mfpr/a", OPR(0x19,0x02), EV4, ARG_EV4HWMPR },
+ { "hw_mfpr/ai", OPR(0x19,0x03), EV4, ARG_EV4HWMPR },
+ { "hw_mfpr/p", OPR(0x19,0x04), EV4, ARG_EV4HWMPR },
+ { "hw_mfpr/pi", OPR(0x19,0x05), EV4, ARG_EV4HWMPR },
+ { "hw_mfpr/pa", OPR(0x19,0x06), EV4, ARG_EV4HWMPR },
+ { "hw_mfpr/pai", OPR(0x19,0x07), EV4, ARG_EV4HWMPR },
+ { "pal19", PCD(0x19), BASE, ARG_PCD },
+
+ { "jmp", MBR(0x1A,0), BASE, { RA, CPRB, JMPHINT } },
+ { "jsr", MBR(0x1A,1), BASE, { RA, CPRB, JMPHINT } },
+ { "ret", MBR(0x1A,2), BASE, { RA, CPRB, RETHINT } },
+ { "jcr", MBR(0x1A,3), BASE, { RA, CPRB, RETHINT } }, /* alias */
+ { "jsr_coroutine", MBR(0x1A,3), BASE, { RA, CPRB, RETHINT } },
+
+ { "hw_ldl", EV4HWMEM(0x1B,0x0), EV4, ARG_EV4HWMEM },
+ { "hw_ldl", EV5HWMEM(0x1B,0x00), EV5, ARG_EV5HWMEM },
+ { "hw_ldl", EV6HWMEM(0x1B,0x8), EV6, ARG_EV6HWMEM },
+ { "hw_ldl/a", EV4HWMEM(0x1B,0x4), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/a", EV5HWMEM(0x1B,0x10), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/a", EV6HWMEM(0x1B,0xC), EV6, ARG_EV6HWMEM },
+ { "hw_ldl/al", EV5HWMEM(0x1B,0x11), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/ar", EV4HWMEM(0x1B,0x6), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/av", EV5HWMEM(0x1B,0x12), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/avl", EV5HWMEM(0x1B,0x13), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/aw", EV5HWMEM(0x1B,0x18), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/awl", EV5HWMEM(0x1B,0x19), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/awv", EV5HWMEM(0x1B,0x1a), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/awvl", EV5HWMEM(0x1B,0x1b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/l", EV5HWMEM(0x1B,0x01), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/p", EV4HWMEM(0x1B,0x8), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/p", EV5HWMEM(0x1B,0x20), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/p", EV6HWMEM(0x1B,0x0), EV6, ARG_EV6HWMEM },
+ { "hw_ldl/pa", EV4HWMEM(0x1B,0xC), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/pa", EV5HWMEM(0x1B,0x30), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pal", EV5HWMEM(0x1B,0x31), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/par", EV4HWMEM(0x1B,0xE), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/pav", EV5HWMEM(0x1B,0x32), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pavl", EV5HWMEM(0x1B,0x33), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/paw", EV5HWMEM(0x1B,0x38), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pawl", EV5HWMEM(0x1B,0x39), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pawv", EV5HWMEM(0x1B,0x3a), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pawvl", EV5HWMEM(0x1B,0x3b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pl", EV5HWMEM(0x1B,0x21), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pr", EV4HWMEM(0x1B,0xA), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/pv", EV5HWMEM(0x1B,0x22), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pvl", EV5HWMEM(0x1B,0x23), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pw", EV5HWMEM(0x1B,0x28), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pwl", EV5HWMEM(0x1B,0x29), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pwv", EV5HWMEM(0x1B,0x2a), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/pwvl", EV5HWMEM(0x1B,0x2b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/r", EV4HWMEM(0x1B,0x2), EV4, ARG_EV4HWMEM },
+ { "hw_ldl/v", EV5HWMEM(0x1B,0x02), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/v", EV6HWMEM(0x1B,0x4), EV6, ARG_EV6HWMEM },
+ { "hw_ldl/vl", EV5HWMEM(0x1B,0x03), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/w", EV5HWMEM(0x1B,0x08), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/w", EV6HWMEM(0x1B,0xA), EV6, ARG_EV6HWMEM },
+ { "hw_ldl/wa", EV6HWMEM(0x1B,0xE), EV6, ARG_EV6HWMEM },
+ { "hw_ldl/wl", EV5HWMEM(0x1B,0x09), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/wv", EV5HWMEM(0x1B,0x0a), EV5, ARG_EV5HWMEM },
+ { "hw_ldl/wvl", EV5HWMEM(0x1B,0x0b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l", EV5HWMEM(0x1B,0x01), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/a", EV5HWMEM(0x1B,0x11), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/av", EV5HWMEM(0x1B,0x13), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/aw", EV5HWMEM(0x1B,0x19), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/awv", EV5HWMEM(0x1B,0x1b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/p", EV5HWMEM(0x1B,0x21), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/p", EV6HWMEM(0x1B,0x2), EV6, ARG_EV6HWMEM },
+ { "hw_ldl_l/pa", EV5HWMEM(0x1B,0x31), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/pav", EV5HWMEM(0x1B,0x33), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/paw", EV5HWMEM(0x1B,0x39), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/pawv", EV5HWMEM(0x1B,0x3b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/pv", EV5HWMEM(0x1B,0x23), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/pw", EV5HWMEM(0x1B,0x29), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/pwv", EV5HWMEM(0x1B,0x2b), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/v", EV5HWMEM(0x1B,0x03), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/w", EV5HWMEM(0x1B,0x09), EV5, ARG_EV5HWMEM },
+ { "hw_ldl_l/wv", EV5HWMEM(0x1B,0x0b), EV5, ARG_EV5HWMEM },
+ { "hw_ldq", EV4HWMEM(0x1B,0x1), EV4, ARG_EV4HWMEM },
+ { "hw_ldq", EV5HWMEM(0x1B,0x04), EV5, ARG_EV5HWMEM },
+ { "hw_ldq", EV6HWMEM(0x1B,0x9), EV6, ARG_EV6HWMEM },
+ { "hw_ldq/a", EV4HWMEM(0x1B,0x5), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/a", EV5HWMEM(0x1B,0x14), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/a", EV6HWMEM(0x1B,0xD), EV6, ARG_EV6HWMEM },
+ { "hw_ldq/al", EV5HWMEM(0x1B,0x15), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/ar", EV4HWMEM(0x1B,0x7), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/av", EV5HWMEM(0x1B,0x16), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/avl", EV5HWMEM(0x1B,0x17), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/aw", EV5HWMEM(0x1B,0x1c), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/awl", EV5HWMEM(0x1B,0x1d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/awv", EV5HWMEM(0x1B,0x1e), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/awvl", EV5HWMEM(0x1B,0x1f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/l", EV5HWMEM(0x1B,0x05), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/p", EV4HWMEM(0x1B,0x9), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/p", EV5HWMEM(0x1B,0x24), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/p", EV6HWMEM(0x1B,0x1), EV6, ARG_EV6HWMEM },
+ { "hw_ldq/pa", EV4HWMEM(0x1B,0xD), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/pa", EV5HWMEM(0x1B,0x34), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pal", EV5HWMEM(0x1B,0x35), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/par", EV4HWMEM(0x1B,0xF), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/pav", EV5HWMEM(0x1B,0x36), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pavl", EV5HWMEM(0x1B,0x37), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/paw", EV5HWMEM(0x1B,0x3c), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pawl", EV5HWMEM(0x1B,0x3d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pawv", EV5HWMEM(0x1B,0x3e), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pawvl", EV5HWMEM(0x1B,0x3f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pl", EV5HWMEM(0x1B,0x25), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pr", EV4HWMEM(0x1B,0xB), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/pv", EV5HWMEM(0x1B,0x26), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pvl", EV5HWMEM(0x1B,0x27), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pw", EV5HWMEM(0x1B,0x2c), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pwl", EV5HWMEM(0x1B,0x2d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pwv", EV5HWMEM(0x1B,0x2e), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/pwvl", EV5HWMEM(0x1B,0x2f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/r", EV4HWMEM(0x1B,0x3), EV4, ARG_EV4HWMEM },
+ { "hw_ldq/v", EV5HWMEM(0x1B,0x06), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/v", EV6HWMEM(0x1B,0x5), EV6, ARG_EV6HWMEM },
+ { "hw_ldq/vl", EV5HWMEM(0x1B,0x07), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/w", EV5HWMEM(0x1B,0x0c), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/w", EV6HWMEM(0x1B,0xB), EV6, ARG_EV6HWMEM },
+ { "hw_ldq/wa", EV6HWMEM(0x1B,0xF), EV6, ARG_EV6HWMEM },
+ { "hw_ldq/wl", EV5HWMEM(0x1B,0x0d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/wv", EV5HWMEM(0x1B,0x0e), EV5, ARG_EV5HWMEM },
+ { "hw_ldq/wvl", EV5HWMEM(0x1B,0x0f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l", EV5HWMEM(0x1B,0x05), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/a", EV5HWMEM(0x1B,0x15), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/av", EV5HWMEM(0x1B,0x17), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/aw", EV5HWMEM(0x1B,0x1d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/awv", EV5HWMEM(0x1B,0x1f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/p", EV5HWMEM(0x1B,0x25), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/p", EV6HWMEM(0x1B,0x3), EV6, ARG_EV6HWMEM },
+ { "hw_ldq_l/pa", EV5HWMEM(0x1B,0x35), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/pav", EV5HWMEM(0x1B,0x37), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/paw", EV5HWMEM(0x1B,0x3d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/pawv", EV5HWMEM(0x1B,0x3f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/pv", EV5HWMEM(0x1B,0x27), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/pw", EV5HWMEM(0x1B,0x2d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/pwv", EV5HWMEM(0x1B,0x2f), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/v", EV5HWMEM(0x1B,0x07), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/w", EV5HWMEM(0x1B,0x0d), EV5, ARG_EV5HWMEM },
+ { "hw_ldq_l/wv", EV5HWMEM(0x1B,0x0f), EV5, ARG_EV5HWMEM },
+ { "hw_ld", EV4HWMEM(0x1B,0x0), EV4, ARG_EV4HWMEM },
+ { "hw_ld", EV5HWMEM(0x1B,0x00), EV5, ARG_EV5HWMEM },
+ { "hw_ld/a", EV4HWMEM(0x1B,0x4), EV4, ARG_EV4HWMEM },
+ { "hw_ld/a", EV5HWMEM(0x1B,0x10), EV5, ARG_EV5HWMEM },
+ { "hw_ld/al", EV5HWMEM(0x1B,0x11), EV5, ARG_EV5HWMEM },
+ { "hw_ld/aq", EV4HWMEM(0x1B,0x5), EV4, ARG_EV4HWMEM },
+ { "hw_ld/aq", EV5HWMEM(0x1B,0x14), EV5, ARG_EV5HWMEM },
+ { "hw_ld/aql", EV5HWMEM(0x1B,0x15), EV5, ARG_EV5HWMEM },
+ { "hw_ld/aqv", EV5HWMEM(0x1B,0x16), EV5, ARG_EV5HWMEM },
+ { "hw_ld/aqvl", EV5HWMEM(0x1B,0x17), EV5, ARG_EV5HWMEM },
+ { "hw_ld/ar", EV4HWMEM(0x1B,0x6), EV4, ARG_EV4HWMEM },
+ { "hw_ld/arq", EV4HWMEM(0x1B,0x7), EV4, ARG_EV4HWMEM },
+ { "hw_ld/av", EV5HWMEM(0x1B,0x12), EV5, ARG_EV5HWMEM },
+ { "hw_ld/avl", EV5HWMEM(0x1B,0x13), EV5, ARG_EV5HWMEM },
+ { "hw_ld/aw", EV5HWMEM(0x1B,0x18), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awl", EV5HWMEM(0x1B,0x19), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awq", EV5HWMEM(0x1B,0x1c), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awql", EV5HWMEM(0x1B,0x1d), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awqv", EV5HWMEM(0x1B,0x1e), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awqvl", EV5HWMEM(0x1B,0x1f), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awv", EV5HWMEM(0x1B,0x1a), EV5, ARG_EV5HWMEM },
+ { "hw_ld/awvl", EV5HWMEM(0x1B,0x1b), EV5, ARG_EV5HWMEM },
+ { "hw_ld/l", EV5HWMEM(0x1B,0x01), EV5, ARG_EV5HWMEM },
+ { "hw_ld/p", EV4HWMEM(0x1B,0x8), EV4, ARG_EV4HWMEM },
+ { "hw_ld/p", EV5HWMEM(0x1B,0x20), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pa", EV4HWMEM(0x1B,0xC), EV4, ARG_EV4HWMEM },
+ { "hw_ld/pa", EV5HWMEM(0x1B,0x30), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pal", EV5HWMEM(0x1B,0x31), EV5, ARG_EV5HWMEM },
+ { "hw_ld/paq", EV4HWMEM(0x1B,0xD), EV4, ARG_EV4HWMEM },
+ { "hw_ld/paq", EV5HWMEM(0x1B,0x34), EV5, ARG_EV5HWMEM },
+ { "hw_ld/paql", EV5HWMEM(0x1B,0x35), EV5, ARG_EV5HWMEM },
+ { "hw_ld/paqv", EV5HWMEM(0x1B,0x36), EV5, ARG_EV5HWMEM },
+ { "hw_ld/paqvl", EV5HWMEM(0x1B,0x37), EV5, ARG_EV5HWMEM },
+ { "hw_ld/par", EV4HWMEM(0x1B,0xE), EV4, ARG_EV4HWMEM },
+ { "hw_ld/parq", EV4HWMEM(0x1B,0xF), EV4, ARG_EV4HWMEM },
+ { "hw_ld/pav", EV5HWMEM(0x1B,0x32), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pavl", EV5HWMEM(0x1B,0x33), EV5, ARG_EV5HWMEM },
+ { "hw_ld/paw", EV5HWMEM(0x1B,0x38), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawl", EV5HWMEM(0x1B,0x39), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawq", EV5HWMEM(0x1B,0x3c), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawql", EV5HWMEM(0x1B,0x3d), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawqv", EV5HWMEM(0x1B,0x3e), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawqvl", EV5HWMEM(0x1B,0x3f), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawv", EV5HWMEM(0x1B,0x3a), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pawvl", EV5HWMEM(0x1B,0x3b), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pl", EV5HWMEM(0x1B,0x21), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pq", EV4HWMEM(0x1B,0x9), EV4, ARG_EV4HWMEM },
+ { "hw_ld/pq", EV5HWMEM(0x1B,0x24), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pql", EV5HWMEM(0x1B,0x25), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pqv", EV5HWMEM(0x1B,0x26), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pqvl", EV5HWMEM(0x1B,0x27), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pr", EV4HWMEM(0x1B,0xA), EV4, ARG_EV4HWMEM },
+ { "hw_ld/prq", EV4HWMEM(0x1B,0xB), EV4, ARG_EV4HWMEM },
+ { "hw_ld/pv", EV5HWMEM(0x1B,0x22), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pvl", EV5HWMEM(0x1B,0x23), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pw", EV5HWMEM(0x1B,0x28), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwl", EV5HWMEM(0x1B,0x29), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwq", EV5HWMEM(0x1B,0x2c), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwql", EV5HWMEM(0x1B,0x2d), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwqv", EV5HWMEM(0x1B,0x2e), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwqvl", EV5HWMEM(0x1B,0x2f), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwv", EV5HWMEM(0x1B,0x2a), EV5, ARG_EV5HWMEM },
+ { "hw_ld/pwvl", EV5HWMEM(0x1B,0x2b), EV5, ARG_EV5HWMEM },
+ { "hw_ld/q", EV4HWMEM(0x1B,0x1), EV4, ARG_EV4HWMEM },
+ { "hw_ld/q", EV5HWMEM(0x1B,0x04), EV5, ARG_EV5HWMEM },
+ { "hw_ld/ql", EV5HWMEM(0x1B,0x05), EV5, ARG_EV5HWMEM },
+ { "hw_ld/qv", EV5HWMEM(0x1B,0x06), EV5, ARG_EV5HWMEM },
+ { "hw_ld/qvl", EV5HWMEM(0x1B,0x07), EV5, ARG_EV5HWMEM },
+ { "hw_ld/r", EV4HWMEM(0x1B,0x2), EV4, ARG_EV4HWMEM },
+ { "hw_ld/rq", EV4HWMEM(0x1B,0x3), EV4, ARG_EV4HWMEM },
+ { "hw_ld/v", EV5HWMEM(0x1B,0x02), EV5, ARG_EV5HWMEM },
+ { "hw_ld/vl", EV5HWMEM(0x1B,0x03), EV5, ARG_EV5HWMEM },
+ { "hw_ld/w", EV5HWMEM(0x1B,0x08), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wl", EV5HWMEM(0x1B,0x09), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wq", EV5HWMEM(0x1B,0x0c), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wql", EV5HWMEM(0x1B,0x0d), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wqv", EV5HWMEM(0x1B,0x0e), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wqvl", EV5HWMEM(0x1B,0x0f), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wv", EV5HWMEM(0x1B,0x0a), EV5, ARG_EV5HWMEM },
+ { "hw_ld/wvl", EV5HWMEM(0x1B,0x0b), EV5, ARG_EV5HWMEM },
+ { "pal1b", PCD(0x1B), BASE, ARG_PCD },
+
+ { "sextb", OPR(0x1C, 0x00), BWX, ARG_OPRZ1 },
+ { "sextw", OPR(0x1C, 0x01), BWX, ARG_OPRZ1 },
+ { "ctpop", OPR(0x1C, 0x30), CIX, ARG_OPRZ1 },
+ { "perr", OPR(0x1C, 0x31), MAX, ARG_OPR },
+ { "ctlz", OPR(0x1C, 0x32), CIX, ARG_OPRZ1 },
+ { "cttz", OPR(0x1C, 0x33), CIX, ARG_OPRZ1 },
+ { "unpkbw", OPR(0x1C, 0x34), MAX, ARG_OPRZ1 },
+ { "unpkbl", OPR(0x1C, 0x35), MAX, ARG_OPRZ1 },
+ { "pkwb", OPR(0x1C, 0x36), MAX, ARG_OPRZ1 },
+ { "pklb", OPR(0x1C, 0x37), MAX, ARG_OPRZ1 },
+ { "minsb8", OPR(0x1C, 0x38), MAX, ARG_OPR },
+ { "minsb8", OPRL(0x1C, 0x38), MAX, ARG_OPRL },
+ { "minsw4", OPR(0x1C, 0x39), MAX, ARG_OPR },
+ { "minsw4", OPRL(0x1C, 0x39), MAX, ARG_OPRL },
+ { "minub8", OPR(0x1C, 0x3A), MAX, ARG_OPR },
+ { "minub8", OPRL(0x1C, 0x3A), MAX, ARG_OPRL },
+ { "minuw4", OPR(0x1C, 0x3B), MAX, ARG_OPR },
+ { "minuw4", OPRL(0x1C, 0x3B), MAX, ARG_OPRL },
+ { "maxub8", OPR(0x1C, 0x3C), MAX, ARG_OPR },
+ { "maxub8", OPRL(0x1C, 0x3C), MAX, ARG_OPRL },
+ { "maxuw4", OPR(0x1C, 0x3D), MAX, ARG_OPR },
+ { "maxuw4", OPRL(0x1C, 0x3D), MAX, ARG_OPRL },
+ { "maxsb8", OPR(0x1C, 0x3E), MAX, ARG_OPR },
+ { "maxsb8", OPRL(0x1C, 0x3E), MAX, ARG_OPRL },
+ { "maxsw4", OPR(0x1C, 0x3F), MAX, ARG_OPR },
+ { "maxsw4", OPRL(0x1C, 0x3F), MAX, ARG_OPRL },
+ { "ftoit", FP(0x1C, 0x70), CIX, { FA, ZB, RC } },
+ { "ftois", FP(0x1C, 0x78), CIX, { FA, ZB, RC } },
+
+ { "hw_mtpr", OPR(0x1D,0x00), EV4, { RA, RBA, EV4EXTHWINDEX } },
+ { "hw_mtpr", OP(0x1D), OP_MASK, EV5, { RA, RBA, EV5HWINDEX } },
+ { "hw_mtpr", OP(0x1D), OP_MASK, EV6, { ZA, RB, EV6HWINDEX } },
+ { "hw_mtpr/i", OPR(0x1D,0x01), EV4, ARG_EV4HWMPR },
+ { "hw_mtpr/a", OPR(0x1D,0x02), EV4, ARG_EV4HWMPR },
+ { "hw_mtpr/ai", OPR(0x1D,0x03), EV4, ARG_EV4HWMPR },
+ { "hw_mtpr/p", OPR(0x1D,0x04), EV4, ARG_EV4HWMPR },
+ { "hw_mtpr/pi", OPR(0x1D,0x05), EV4, ARG_EV4HWMPR },
+ { "hw_mtpr/pa", OPR(0x1D,0x06), EV4, ARG_EV4HWMPR },
+ { "hw_mtpr/pai", OPR(0x1D,0x07), EV4, ARG_EV4HWMPR },
+ { "pal1d", PCD(0x1D), BASE, ARG_PCD },
+
+ { "hw_rei", SPCD(0x1E,0x3FF8000), EV4|EV5, ARG_NONE },
+ { "hw_rei_stall", SPCD(0x1E,0x3FFC000), EV5, ARG_NONE },
+ { "hw_jmp", EV6HWMBR(0x1E,0x0), EV6, { ZA, PRB, EV6HWJMPHINT } },
+ { "hw_jsr", EV6HWMBR(0x1E,0x2), EV6, { ZA, PRB, EV6HWJMPHINT } },
+ { "hw_ret", EV6HWMBR(0x1E,0x4), EV6, { ZA, PRB } },
+ { "hw_jcr", EV6HWMBR(0x1E,0x6), EV6, { ZA, PRB } },
+ { "hw_coroutine", EV6HWMBR(0x1E,0x6), EV6, { ZA, PRB } }, /* alias */
+ { "hw_jmp/stall", EV6HWMBR(0x1E,0x1), EV6, { ZA, PRB, EV6HWJMPHINT } },
+ { "hw_jsr/stall", EV6HWMBR(0x1E,0x3), EV6, { ZA, PRB, EV6HWJMPHINT } },
+ { "hw_ret/stall", EV6HWMBR(0x1E,0x5), EV6, { ZA, PRB } },
+ { "hw_jcr/stall", EV6HWMBR(0x1E,0x7), EV6, { ZA, PRB } },
+ { "hw_coroutine/stall", EV6HWMBR(0x1E,0x7), EV6, { ZA, PRB } }, /* alias */
+ { "pal1e", PCD(0x1E), BASE, ARG_PCD },
+
+ { "hw_stl", EV4HWMEM(0x1F,0x0), EV4, ARG_EV4HWMEM },
+ { "hw_stl", EV5HWMEM(0x1F,0x00), EV5, ARG_EV5HWMEM },
+ { "hw_stl", EV6HWMEM(0x1F,0x4), EV6, ARG_EV6HWMEM }, /* ??? 8 */
+ { "hw_stl/a", EV4HWMEM(0x1F,0x4), EV4, ARG_EV4HWMEM },
+ { "hw_stl/a", EV5HWMEM(0x1F,0x10), EV5, ARG_EV5HWMEM },
+ { "hw_stl/a", EV6HWMEM(0x1F,0xC), EV6, ARG_EV6HWMEM },
+ { "hw_stl/ac", EV5HWMEM(0x1F,0x11), EV5, ARG_EV5HWMEM },
+ { "hw_stl/ar", EV4HWMEM(0x1F,0x6), EV4, ARG_EV4HWMEM },
+ { "hw_stl/av", EV5HWMEM(0x1F,0x12), EV5, ARG_EV5HWMEM },
+ { "hw_stl/avc", EV5HWMEM(0x1F,0x13), EV5, ARG_EV5HWMEM },
+ { "hw_stl/c", EV5HWMEM(0x1F,0x01), EV5, ARG_EV5HWMEM },
+ { "hw_stl/p", EV4HWMEM(0x1F,0x8), EV4, ARG_EV4HWMEM },
+ { "hw_stl/p", EV5HWMEM(0x1F,0x20), EV5, ARG_EV5HWMEM },
+ { "hw_stl/p", EV6HWMEM(0x1F,0x0), EV6, ARG_EV6HWMEM },
+ { "hw_stl/pa", EV4HWMEM(0x1F,0xC), EV4, ARG_EV4HWMEM },
+ { "hw_stl/pa", EV5HWMEM(0x1F,0x30), EV5, ARG_EV5HWMEM },
+ { "hw_stl/pac", EV5HWMEM(0x1F,0x31), EV5, ARG_EV5HWMEM },
+ { "hw_stl/pav", EV5HWMEM(0x1F,0x32), EV5, ARG_EV5HWMEM },
+ { "hw_stl/pavc", EV5HWMEM(0x1F,0x33), EV5, ARG_EV5HWMEM },
+ { "hw_stl/pc", EV5HWMEM(0x1F,0x21), EV5, ARG_EV5HWMEM },
+ { "hw_stl/pr", EV4HWMEM(0x1F,0xA), EV4, ARG_EV4HWMEM },
+ { "hw_stl/pv", EV5HWMEM(0x1F,0x22), EV5, ARG_EV5HWMEM },
+ { "hw_stl/pvc", EV5HWMEM(0x1F,0x23), EV5, ARG_EV5HWMEM },
+ { "hw_stl/r", EV4HWMEM(0x1F,0x2), EV4, ARG_EV4HWMEM },
+ { "hw_stl/v", EV5HWMEM(0x1F,0x02), EV5, ARG_EV5HWMEM },
+ { "hw_stl/vc", EV5HWMEM(0x1F,0x03), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c", EV5HWMEM(0x1F,0x01), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/a", EV5HWMEM(0x1F,0x11), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/av", EV5HWMEM(0x1F,0x13), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/p", EV5HWMEM(0x1F,0x21), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/p", EV6HWMEM(0x1F,0x2), EV6, ARG_EV6HWMEM },
+ { "hw_stl_c/pa", EV5HWMEM(0x1F,0x31), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/pav", EV5HWMEM(0x1F,0x33), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/pv", EV5HWMEM(0x1F,0x23), EV5, ARG_EV5HWMEM },
+ { "hw_stl_c/v", EV5HWMEM(0x1F,0x03), EV5, ARG_EV5HWMEM },
+ { "hw_stq", EV4HWMEM(0x1F,0x1), EV4, ARG_EV4HWMEM },
+ { "hw_stq", EV5HWMEM(0x1F,0x04), EV5, ARG_EV5HWMEM },
+ { "hw_stq", EV6HWMEM(0x1F,0x5), EV6, ARG_EV6HWMEM }, /* ??? 9 */
+ { "hw_stq/a", EV4HWMEM(0x1F,0x5), EV4, ARG_EV4HWMEM },
+ { "hw_stq/a", EV5HWMEM(0x1F,0x14), EV5, ARG_EV5HWMEM },
+ { "hw_stq/a", EV6HWMEM(0x1F,0xD), EV6, ARG_EV6HWMEM },
+ { "hw_stq/ac", EV5HWMEM(0x1F,0x15), EV5, ARG_EV5HWMEM },
+ { "hw_stq/ar", EV4HWMEM(0x1F,0x7), EV4, ARG_EV4HWMEM },
+ { "hw_stq/av", EV5HWMEM(0x1F,0x16), EV5, ARG_EV5HWMEM },
+ { "hw_stq/avc", EV5HWMEM(0x1F,0x17), EV5, ARG_EV5HWMEM },
+ { "hw_stq/c", EV5HWMEM(0x1F,0x05), EV5, ARG_EV5HWMEM },
+ { "hw_stq/p", EV4HWMEM(0x1F,0x9), EV4, ARG_EV4HWMEM },
+ { "hw_stq/p", EV5HWMEM(0x1F,0x24), EV5, ARG_EV5HWMEM },
+ { "hw_stq/p", EV6HWMEM(0x1F,0x1), EV6, ARG_EV6HWMEM },
+ { "hw_stq/pa", EV4HWMEM(0x1F,0xD), EV4, ARG_EV4HWMEM },
+ { "hw_stq/pa", EV5HWMEM(0x1F,0x34), EV5, ARG_EV5HWMEM },
+ { "hw_stq/pac", EV5HWMEM(0x1F,0x35), EV5, ARG_EV5HWMEM },
+ { "hw_stq/par", EV4HWMEM(0x1F,0xE), EV4, ARG_EV4HWMEM },
+ { "hw_stq/par", EV4HWMEM(0x1F,0xF), EV4, ARG_EV4HWMEM },
+ { "hw_stq/pav", EV5HWMEM(0x1F,0x36), EV5, ARG_EV5HWMEM },
+ { "hw_stq/pavc", EV5HWMEM(0x1F,0x37), EV5, ARG_EV5HWMEM },
+ { "hw_stq/pc", EV5HWMEM(0x1F,0x25), EV5, ARG_EV5HWMEM },
+ { "hw_stq/pr", EV4HWMEM(0x1F,0xB), EV4, ARG_EV4HWMEM },
+ { "hw_stq/pv", EV5HWMEM(0x1F,0x26), EV5, ARG_EV5HWMEM },
+ { "hw_stq/pvc", EV5HWMEM(0x1F,0x27), EV5, ARG_EV5HWMEM },
+ { "hw_stq/r", EV4HWMEM(0x1F,0x3), EV4, ARG_EV4HWMEM },
+ { "hw_stq/v", EV5HWMEM(0x1F,0x06), EV5, ARG_EV5HWMEM },
+ { "hw_stq/vc", EV5HWMEM(0x1F,0x07), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c", EV5HWMEM(0x1F,0x05), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/a", EV5HWMEM(0x1F,0x15), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/av", EV5HWMEM(0x1F,0x17), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/p", EV5HWMEM(0x1F,0x25), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/p", EV6HWMEM(0x1F,0x3), EV6, ARG_EV6HWMEM },
+ { "hw_stq_c/pa", EV5HWMEM(0x1F,0x35), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/pav", EV5HWMEM(0x1F,0x37), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/pv", EV5HWMEM(0x1F,0x27), EV5, ARG_EV5HWMEM },
+ { "hw_stq_c/v", EV5HWMEM(0x1F,0x07), EV5, ARG_EV5HWMEM },
+ { "hw_st", EV4HWMEM(0x1F,0x0), EV4, ARG_EV4HWMEM },
+ { "hw_st", EV5HWMEM(0x1F,0x00), EV5, ARG_EV5HWMEM },
+ { "hw_st/a", EV4HWMEM(0x1F,0x4), EV4, ARG_EV4HWMEM },
+ { "hw_st/a", EV5HWMEM(0x1F,0x10), EV5, ARG_EV5HWMEM },
+ { "hw_st/ac", EV5HWMEM(0x1F,0x11), EV5, ARG_EV5HWMEM },
+ { "hw_st/aq", EV4HWMEM(0x1F,0x5), EV4, ARG_EV4HWMEM },
+ { "hw_st/aq", EV5HWMEM(0x1F,0x14), EV5, ARG_EV5HWMEM },
+ { "hw_st/aqc", EV5HWMEM(0x1F,0x15), EV5, ARG_EV5HWMEM },
+ { "hw_st/aqv", EV5HWMEM(0x1F,0x16), EV5, ARG_EV5HWMEM },
+ { "hw_st/aqvc", EV5HWMEM(0x1F,0x17), EV5, ARG_EV5HWMEM },
+ { "hw_st/ar", EV4HWMEM(0x1F,0x6), EV4, ARG_EV4HWMEM },
+ { "hw_st/arq", EV4HWMEM(0x1F,0x7), EV4, ARG_EV4HWMEM },
+ { "hw_st/av", EV5HWMEM(0x1F,0x12), EV5, ARG_EV5HWMEM },
+ { "hw_st/avc", EV5HWMEM(0x1F,0x13), EV5, ARG_EV5HWMEM },
+ { "hw_st/c", EV5HWMEM(0x1F,0x01), EV5, ARG_EV5HWMEM },
+ { "hw_st/p", EV4HWMEM(0x1F,0x8), EV4, ARG_EV4HWMEM },
+ { "hw_st/p", EV5HWMEM(0x1F,0x20), EV5, ARG_EV5HWMEM },
+ { "hw_st/pa", EV4HWMEM(0x1F,0xC), EV4, ARG_EV4HWMEM },
+ { "hw_st/pa", EV5HWMEM(0x1F,0x30), EV5, ARG_EV5HWMEM },
+ { "hw_st/pac", EV5HWMEM(0x1F,0x31), EV5, ARG_EV5HWMEM },
+ { "hw_st/paq", EV4HWMEM(0x1F,0xD), EV4, ARG_EV4HWMEM },
+ { "hw_st/paq", EV5HWMEM(0x1F,0x34), EV5, ARG_EV5HWMEM },
+ { "hw_st/paqc", EV5HWMEM(0x1F,0x35), EV5, ARG_EV5HWMEM },
+ { "hw_st/paqv", EV5HWMEM(0x1F,0x36), EV5, ARG_EV5HWMEM },
+ { "hw_st/paqvc", EV5HWMEM(0x1F,0x37), EV5, ARG_EV5HWMEM },
+ { "hw_st/par", EV4HWMEM(0x1F,0xE), EV4, ARG_EV4HWMEM },
+ { "hw_st/parq", EV4HWMEM(0x1F,0xF), EV4, ARG_EV4HWMEM },
+ { "hw_st/pav", EV5HWMEM(0x1F,0x32), EV5, ARG_EV5HWMEM },
+ { "hw_st/pavc", EV5HWMEM(0x1F,0x33), EV5, ARG_EV5HWMEM },
+ { "hw_st/pc", EV5HWMEM(0x1F,0x21), EV5, ARG_EV5HWMEM },
+ { "hw_st/pq", EV4HWMEM(0x1F,0x9), EV4, ARG_EV4HWMEM },
+ { "hw_st/pq", EV5HWMEM(0x1F,0x24), EV5, ARG_EV5HWMEM },
+ { "hw_st/pqc", EV5HWMEM(0x1F,0x25), EV5, ARG_EV5HWMEM },
+ { "hw_st/pqv", EV5HWMEM(0x1F,0x26), EV5, ARG_EV5HWMEM },
+ { "hw_st/pqvc", EV5HWMEM(0x1F,0x27), EV5, ARG_EV5HWMEM },
+ { "hw_st/pr", EV4HWMEM(0x1F,0xA), EV4, ARG_EV4HWMEM },
+ { "hw_st/prq", EV4HWMEM(0x1F,0xB), EV4, ARG_EV4HWMEM },
+ { "hw_st/pv", EV5HWMEM(0x1F,0x22), EV5, ARG_EV5HWMEM },
+ { "hw_st/pvc", EV5HWMEM(0x1F,0x23), EV5, ARG_EV5HWMEM },
+ { "hw_st/q", EV4HWMEM(0x1F,0x1), EV4, ARG_EV4HWMEM },
+ { "hw_st/q", EV5HWMEM(0x1F,0x04), EV5, ARG_EV5HWMEM },
+ { "hw_st/qc", EV5HWMEM(0x1F,0x05), EV5, ARG_EV5HWMEM },
+ { "hw_st/qv", EV5HWMEM(0x1F,0x06), EV5, ARG_EV5HWMEM },
+ { "hw_st/qvc", EV5HWMEM(0x1F,0x07), EV5, ARG_EV5HWMEM },
+ { "hw_st/r", EV4HWMEM(0x1F,0x2), EV4, ARG_EV4HWMEM },
+ { "hw_st/v", EV5HWMEM(0x1F,0x02), EV5, ARG_EV5HWMEM },
+ { "hw_st/vc", EV5HWMEM(0x1F,0x03), EV5, ARG_EV5HWMEM },
+ { "pal1f", PCD(0x1F), BASE, ARG_PCD },
+
+ { "ldf", MEM(0x20), BASE, ARG_FMEM },
+ { "ldg", MEM(0x21), BASE, ARG_FMEM },
+ { "lds", MEM(0x22), BASE, ARG_FMEM },
+ { "ldt", MEM(0x23), BASE, ARG_FMEM },
+ { "stf", MEM(0x24), BASE, ARG_FMEM },
+ { "stg", MEM(0x25), BASE, ARG_FMEM },
+ { "sts", MEM(0x26), BASE, ARG_FMEM },
+ { "stt", MEM(0x27), BASE, ARG_FMEM },
+
+ { "ldl", MEM(0x28), BASE, ARG_MEM },
+ { "ldq", MEM(0x29), BASE, ARG_MEM },
+ { "ldl_l", MEM(0x2A), BASE, ARG_MEM },
+ { "ldq_l", MEM(0x2B), BASE, ARG_MEM },
+ { "stl", MEM(0x2C), BASE, ARG_MEM },
+ { "stq", MEM(0x2D), BASE, ARG_MEM },
+ { "stl_c", MEM(0x2E), BASE, ARG_MEM },
+ { "stq_c", MEM(0x2F), BASE, ARG_MEM },
+
+ { "br", BRA(0x30), BASE, { ZA, BDISP } }, /* pseudo */
+ { "br", BRA(0x30), BASE, ARG_BRA },
+ { "fbeq", BRA(0x31), BASE, ARG_FBRA },
+ { "fblt", BRA(0x32), BASE, ARG_FBRA },
+ { "fble", BRA(0x33), BASE, ARG_FBRA },
+ { "bsr", BRA(0x34), BASE, ARG_BRA },
+ { "fbne", BRA(0x35), BASE, ARG_FBRA },
+ { "fbge", BRA(0x36), BASE, ARG_FBRA },
+ { "fbgt", BRA(0x37), BASE, ARG_FBRA },
+ { "blbc", BRA(0x38), BASE, ARG_BRA },
+ { "beq", BRA(0x39), BASE, ARG_BRA },
+ { "blt", BRA(0x3A), BASE, ARG_BRA },
+ { "ble", BRA(0x3B), BASE, ARG_BRA },
+ { "blbs", BRA(0x3C), BASE, ARG_BRA },
+ { "bne", BRA(0x3D), BASE, ARG_BRA },
+ { "bge", BRA(0x3E), BASE, ARG_BRA },
+ { "bgt", BRA(0x3F), BASE, ARG_BRA },
+};
+
+const int alpha_num_opcodes = sizeof(alpha_opcodes)/sizeof(*alpha_opcodes);
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
new file mode 100644
index 00000000000..802b07b9521
--- /dev/null
+++ b/opcodes/arc-dis.c
@@ -0,0 +1,267 @@
+/* Instruction printing code for the ARC.
+ Copyright (C) 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
+ Contributed by Doug Evans (dje@cygnus.com).
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "dis-asm.h"
+#include "opcode/arc.h"
+#include "elf-bfd.h"
+#include "elf/arc.h"
+#include "opintl.h"
+
+static int print_insn_arc_base_little PARAMS ((bfd_vma, disassemble_info *));
+static int print_insn_arc_base_big PARAMS ((bfd_vma, disassemble_info *));
+
+static int print_insn PARAMS ((bfd_vma, disassemble_info *, int, int));
+
+/* Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction (4 or 8 for the ARC). */
+
+static int
+print_insn (pc, info, mach, big_p)
+ bfd_vma pc;
+ disassemble_info *info;
+ int mach;
+ int big_p;
+{
+ const struct arc_opcode *opcode;
+ bfd_byte buffer[4];
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+ int status;
+ /* First element is insn, second element is limm (if present). */
+ arc_insn insn[2];
+ int got_limm_p = 0;
+ static int initialized = 0;
+ static int current_mach = 0;
+
+ if (!initialized || mach != current_mach)
+ {
+ initialized = 1;
+ current_mach = arc_get_opcode_mach (mach, big_p);
+ arc_opcode_init_tables (current_mach);
+ }
+
+ status = (*info->read_memory_func) (pc, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+ if (big_p)
+ insn[0] = bfd_getb32 (buffer);
+ else
+ insn[0] = bfd_getl32 (buffer);
+
+ (*func) (stream, "%08lx\t", insn[0]);
+
+ /* The instructions are stored in lists hashed by the insn code
+ (though we needn't care how they're hashed). */
+
+ opcode = arc_opcode_lookup_dis (insn[0]);
+ for ( ; opcode != NULL; opcode = ARC_OPCODE_NEXT_DIS (opcode))
+ {
+ char *syn;
+ int mods,invalid;
+ long value;
+ const struct arc_operand *operand;
+ const struct arc_operand_value *opval;
+
+ /* Basic bit mask must be correct. */
+ if ((insn[0] & opcode->mask) != opcode->value)
+ continue;
+
+ /* Supported by this cpu? */
+ if (! arc_opcode_supported (opcode))
+ continue;
+
+ /* Make two passes over the operands. First see if any of them
+ have extraction functions, and, if they do, make sure the
+ instruction is valid. */
+
+ arc_opcode_init_extract ();
+ invalid = 0;
+
+ /* ??? Granted, this is slower than the `ppc' way. Maybe when this is
+ done it'll be clear what the right way to do this is. */
+ /* Instructions like "add.f r0,r1,1" are tricky because the ".f" gets
+ printed first, but we don't know how to print it until we've processed
+ the regs. Since we're scanning all the args before printing the insn
+ anyways, it's actually quite easy. */
+
+ for (syn = opcode->syntax; *syn; ++syn)
+ {
+ int c;
+
+ if (*syn != '%' || *++syn == '%')
+ continue;
+ mods = 0;
+ c = *syn;
+ while (ARC_MOD_P (arc_operands[arc_operand_map[c]].flags))
+ {
+ mods |= arc_operands[arc_operand_map[c]].flags & ARC_MOD_BITS;
+ ++syn;
+ c = *syn;
+ }
+ operand = arc_operands + arc_operand_map[c];
+ if (operand->extract)
+ (*operand->extract) (insn, operand, mods,
+ (const struct arc_operand_value **) NULL,
+ &invalid);
+ }
+ if (invalid)
+ continue;
+
+ /* The instruction is valid. */
+
+ /* If we have an insn with a limm, fetch it now. Scanning the insns
+ twice lets us do this. */
+ if (arc_opcode_limm_p (NULL))
+ {
+ status = (*info->read_memory_func) (pc + 4, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+ if (big_p)
+ insn[1] = bfd_getb32 (buffer);
+ else
+ insn[1] = bfd_getl32 (buffer);
+ got_limm_p = 1;
+ }
+
+ for (syn = opcode->syntax; *syn; ++syn)
+ {
+ int c;
+
+ if (*syn != '%' || *++syn == '%')
+ {
+ (*func) (stream, "%c", *syn);
+ continue;
+ }
+
+ /* We have an operand. Fetch any special modifiers. */
+ mods = 0;
+ c = *syn;
+ while (ARC_MOD_P (arc_operands[arc_operand_map[c]].flags))
+ {
+ mods |= arc_operands[arc_operand_map[c]].flags & ARC_MOD_BITS;
+ ++syn;
+ c = *syn;
+ }
+ operand = arc_operands + arc_operand_map[c];
+
+ /* Extract the value from the instruction. */
+ opval = NULL;
+ if (operand->extract)
+ {
+ value = (*operand->extract) (insn, operand, mods,
+ &opval, (int *) NULL);
+ }
+ else
+ {
+ value = (insn[0] >> operand->shift) & ((1 << operand->bits) - 1);
+ if ((operand->flags & ARC_OPERAND_SIGNED)
+ && (value & (1 << (operand->bits - 1))))
+ value -= 1 << operand->bits;
+
+ /* If this is a suffix operand, set `opval'. */
+ if (operand->flags & ARC_OPERAND_SUFFIX)
+ opval = arc_opcode_lookup_suffix (operand, value);
+ }
+
+ /* Print the operand as directed by the flags. */
+ if (operand->flags & ARC_OPERAND_FAKE)
+ ; /* nothing to do (??? at least not yet) */
+ else if (operand->flags & ARC_OPERAND_SUFFIX)
+ {
+ /* Default suffixes aren't printed. Fortunately, they all have
+ zero values. Also, zero values for boolean suffixes are
+ represented by the absence of text. */
+
+ if (value != 0)
+ {
+ /* ??? OPVAL should have a value. If it doesn't just cope
+ as we want disassembly to be reasonably robust.
+ Also remember that several condition code values (16-31)
+ aren't defined yet. For these cases just print the
+ number suitably decorated. */
+ if (opval)
+ (*func) (stream, "%s%s",
+ mods & ARC_MOD_DOT ? "." : "",
+ opval->name);
+ else
+ (*func) (stream, "%s%c%d",
+ mods & ARC_MOD_DOT ? "." : "",
+ operand->fmt, value);
+ }
+ }
+ else if (operand->flags & ARC_OPERAND_RELATIVE_BRANCH)
+ (*info->print_address_func) (pc + 4 + value, info);
+ /* ??? Not all cases of this are currently caught. */
+ else if (operand->flags & ARC_OPERAND_ABSOLUTE_BRANCH)
+ (*info->print_address_func) ((bfd_vma) value & 0xffffffff, info);
+ else if (operand->flags & ARC_OPERAND_ADDRESS)
+ (*info->print_address_func) ((bfd_vma) value & 0xffffffff, info);
+ else if (opval)
+ /* Note that this case catches both normal and auxiliary regs. */
+ (*func) (stream, "%s", opval->name);
+ else
+ (*func) (stream, "%ld", value);
+ }
+
+ /* We have found and printed an instruction; return. */
+ return got_limm_p ? 8 : 4;
+ }
+
+ (*func) (stream, _("*unknown*"));
+ return 4;
+}
+
+/* Given MACH, one of bfd_mach_arc_xxx, return the print_insn function to use.
+ This does things a non-standard way (the "standard" way would be to copy
+ this code into disassemble.c). Since there are more than a couple of
+ variants, hiding all this crud here seems cleaner. */
+
+disassembler_ftype
+arc_get_disassembler (mach, big_p)
+ int mach;
+ int big_p;
+{
+ switch (mach)
+ {
+ case bfd_mach_arc_base:
+ return big_p ? print_insn_arc_base_big : print_insn_arc_base_little;
+ }
+ return print_insn_arc_base_little;
+}
+
+static int
+print_insn_arc_base_little (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ return print_insn (pc, info, bfd_mach_arc_base, 0);
+}
+
+static int
+print_insn_arc_base_big (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ return print_insn (pc, info, bfd_mach_arc_base, 1);
+}
diff --git a/opcodes/arc-opc.c b/opcodes/arc-opc.c
new file mode 100644
index 00000000000..0f8f6895965
--- /dev/null
+++ b/opcodes/arc-opc.c
@@ -0,0 +1,1131 @@
+/* Opcode table for the ARC.
+ Copyright (c) 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
+ Contributed by Doug Evans (dje@cygnus.com).
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/arc.h"
+#include "opintl.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define INSERT_FN(fn) \
+static arc_insn fn PARAMS ((arc_insn, const struct arc_operand *, \
+ int, const struct arc_operand_value *, long, \
+ const char **))
+#define EXTRACT_FN(fn) \
+static long fn PARAMS ((arc_insn *, const struct arc_operand *, \
+ int, const struct arc_operand_value **, int *))
+
+INSERT_FN (insert_reg);
+INSERT_FN (insert_shimmfinish);
+INSERT_FN (insert_limmfinish);
+INSERT_FN (insert_shimmoffset);
+INSERT_FN (insert_shimmzero);
+INSERT_FN (insert_flag);
+INSERT_FN (insert_flagfinish);
+INSERT_FN (insert_cond);
+INSERT_FN (insert_forcelimm);
+INSERT_FN (insert_reladdr);
+INSERT_FN (insert_absaddr);
+INSERT_FN (insert_unopmacro);
+
+EXTRACT_FN (extract_reg);
+EXTRACT_FN (extract_flag);
+EXTRACT_FN (extract_cond);
+EXTRACT_FN (extract_reladdr);
+EXTRACT_FN (extract_unopmacro);
+
+/* Various types of ARC operands, including insn suffixes. */
+
+/* Insn format values:
+
+ 'a' REGA register A field
+ 'b' REGB register B field
+ 'c' REGC register C field
+ 'S' SHIMMFINISH finish inserting a shimm value
+ 'L' LIMMFINISH finish inserting a limm value
+ 'd' SHIMMOFFSET shimm offset in ld,st insns
+ '0' SHIMMZERO 0 shimm value in ld,st insns
+ 'f' FLAG F flag
+ 'F' FLAGFINISH finish inserting the F flag
+ 'G' FLAGINSN insert F flag in "flag" insn
+ 'n' DELAY N field (nullify field)
+ 'q' COND condition code field
+ 'Q' FORCELIMM set `cond_p' to 1 to ensure a constant is a limm
+ 'B' BRANCH branch address (22 bit pc relative)
+ 'J' JUMP jump address (26 bit absolute)
+ 'z' SIZE1 size field in ld a,[b,c]
+ 'Z' SIZE10 size field in ld a,[b,shimm]
+ 'y' SIZE22 size field in st c,[b,shimm]
+ 'x' SIGN0 sign extend field ld a,[b,c]
+ 'X' SIGN9 sign extend field ld a,[b,shimm]
+ 'w' ADDRESS3 write-back field in ld a,[b,c]
+ 'W' ADDRESS12 write-back field in ld a,[b,shimm]
+ 'v' ADDRESS24 write-back field in st c,[b,shimm]
+ 'e' CACHEBYPASS5 cache bypass in ld a,[b,c]
+ 'E' CACHEBYPASS14 cache bypass in ld a,[b,shimm]
+ 'D' CACHEBYPASS26 cache bypass in st c,[b,shimm]
+ 'U' UNOPMACRO fake operand to copy REGB to REGC for unop macros
+
+ The following modifiers may appear between the % and char (eg: %.f):
+
+ '.' MODDOT '.' prefix must be present
+ 'r' REG generic register value, for register table
+ 'A' AUXREG auxiliary register in lr a,[b], sr c,[b]
+
+ Fields are:
+
+ CHAR BITS SHIFT FLAGS INSERT_FN EXTRACT_FN
+*/
+
+const struct arc_operand arc_operands[] =
+{
+/* place holder (??? not sure if needed) */
+#define UNUSED 0
+ { 0 },
+
+/* register A or shimm/limm indicator */
+#define REGA (UNUSED + 1)
+ { 'a', 6, ARC_SHIFT_REGA, ARC_OPERAND_SIGNED, insert_reg, extract_reg },
+
+/* register B or shimm/limm indicator */
+#define REGB (REGA + 1)
+ { 'b', 6, ARC_SHIFT_REGB, ARC_OPERAND_SIGNED, insert_reg, extract_reg },
+
+/* register C or shimm/limm indicator */
+#define REGC (REGB + 1)
+ { 'c', 6, ARC_SHIFT_REGC, ARC_OPERAND_SIGNED, insert_reg, extract_reg },
+
+/* fake operand used to insert shimm value into most instructions */
+#define SHIMMFINISH (REGC + 1)
+ { 'S', 9, 0, ARC_OPERAND_SIGNED + ARC_OPERAND_FAKE, insert_shimmfinish, 0 },
+
+/* fake operand used to insert limm value into most instructions. */
+#define LIMMFINISH (SHIMMFINISH + 1)
+ { 'L', 32, 32, ARC_OPERAND_ADDRESS + ARC_OPERAND_LIMM + ARC_OPERAND_FAKE, insert_limmfinish, 0 },
+
+/* shimm operand when there is no reg indicator (ld,st) */
+#define SHIMMOFFSET (LIMMFINISH + 1)
+ { 'd', 9, 0, ARC_OPERAND_SIGNED, insert_shimmoffset, 0 },
+
+/* 0 shimm operand for ld,st insns */
+#define SHIMMZERO (SHIMMOFFSET + 1)
+ { '0', 9, 0, ARC_OPERAND_FAKE, insert_shimmzero, 0 },
+
+/* flag update bit (insertion is defered until we know how) */
+#define FLAG (SHIMMZERO + 1)
+ { 'f', 1, 8, ARC_OPERAND_SUFFIX, insert_flag, extract_flag },
+
+/* fake utility operand to finish 'f' suffix handling */
+#define FLAGFINISH (FLAG + 1)
+ { 'F', 1, 8, ARC_OPERAND_FAKE, insert_flagfinish, 0 },
+
+/* fake utility operand to set the 'f' flag for the "flag" insn */
+#define FLAGINSN (FLAGFINISH + 1)
+ { 'G', 1, 8, ARC_OPERAND_FAKE, insert_flag, 0 },
+
+/* branch delay types */
+#define DELAY (FLAGINSN + 1)
+ { 'n', 2, 5, ARC_OPERAND_SUFFIX },
+
+/* conditions */
+#define COND (DELAY + 1)
+ { 'q', 5, 0, ARC_OPERAND_SUFFIX, insert_cond, extract_cond },
+
+/* set `cond_p' to 1 to ensure a constant is treated as a limm */
+#define FORCELIMM (COND + 1)
+ { 'Q', 0, 0, ARC_OPERAND_FAKE, insert_forcelimm },
+
+/* branch address; b, bl, and lp insns */
+#define BRANCH (FORCELIMM + 1)
+ { 'B', 20, 7, ARC_OPERAND_RELATIVE_BRANCH + ARC_OPERAND_SIGNED, insert_reladdr, extract_reladdr },
+
+/* jump address; j insn (this is basically the same as 'L' except that the
+ value is right shifted by 2) */
+#define JUMP (BRANCH + 1)
+ { 'J', 24, 32, ARC_OPERAND_ABSOLUTE_BRANCH + ARC_OPERAND_LIMM + ARC_OPERAND_FAKE, insert_absaddr },
+
+/* size field, stored in bit 1,2 */
+#define SIZE1 (JUMP + 1)
+ { 'z', 2, 1, ARC_OPERAND_SUFFIX },
+
+/* size field, stored in bit 10,11 */
+#define SIZE10 (SIZE1 + 1)
+ { 'Z', 2, 10, ARC_OPERAND_SUFFIX, },
+
+/* size field, stored in bit 22,23 */
+#define SIZE22 (SIZE10 + 1)
+ { 'y', 2, 22, ARC_OPERAND_SUFFIX, },
+
+/* sign extend field, stored in bit 0 */
+#define SIGN0 (SIZE22 + 1)
+ { 'x', 1, 0, ARC_OPERAND_SUFFIX },
+
+/* sign extend field, stored in bit 9 */
+#define SIGN9 (SIGN0 + 1)
+ { 'X', 1, 9, ARC_OPERAND_SUFFIX },
+
+/* address write back, stored in bit 3 */
+#define ADDRESS3 (SIGN9 + 1)
+ { 'w', 1, 3, ARC_OPERAND_SUFFIX },
+
+/* address write back, stored in bit 12 */
+#define ADDRESS12 (ADDRESS3 + 1)
+ { 'W', 1, 12, ARC_OPERAND_SUFFIX },
+
+/* address write back, stored in bit 24 */
+#define ADDRESS24 (ADDRESS12 + 1)
+ { 'v', 1, 24, ARC_OPERAND_SUFFIX },
+
+/* cache bypass, stored in bit 5 */
+#define CACHEBYPASS5 (ADDRESS24 + 1)
+ { 'e', 1, 5, ARC_OPERAND_SUFFIX },
+
+/* cache bypass, stored in bit 14 */
+#define CACHEBYPASS14 (CACHEBYPASS5 + 1)
+ { 'E', 1, 14, ARC_OPERAND_SUFFIX },
+
+/* cache bypass, stored in bit 26 */
+#define CACHEBYPASS26 (CACHEBYPASS14 + 1)
+ { 'D', 1, 26, ARC_OPERAND_SUFFIX },
+
+/* unop macro, used to copy REGB to REGC */
+#define UNOPMACRO (CACHEBYPASS26 + 1)
+ { 'U', 6, ARC_SHIFT_REGC, ARC_OPERAND_FAKE, insert_unopmacro, extract_unopmacro },
+
+/* '.' modifier ('.' required). */
+#define MODDOT (UNOPMACRO + 1)
+ { '.', 1, 0, ARC_MOD_DOT },
+
+/* Dummy 'r' modifier for the register table.
+ It's called a "dummy" because there's no point in inserting an 'r' into all
+ the %a/%b/%c occurrences in the insn table. */
+#define REG (MODDOT + 1)
+ { 'r', 6, 0, ARC_MOD_REG },
+
+/* Known auxiliary register modifier (stored in shimm field). */
+#define AUXREG (REG + 1)
+ { 'A', 9, 0, ARC_MOD_AUXREG },
+
+/* end of list place holder */
+ { 0 }
+};
+
+/* Given a format letter, yields the index into `arc_operands'.
+ eg: arc_operand_map['a'] = REGA. */
+unsigned char arc_operand_map[256];
+
+#define I(x) (((x) & 31) << 27)
+#define A(x) (((x) & ARC_MASK_REG) << ARC_SHIFT_REGA)
+#define B(x) (((x) & ARC_MASK_REG) << ARC_SHIFT_REGB)
+#define C(x) (((x) & ARC_MASK_REG) << ARC_SHIFT_REGC)
+#define R(x,b,m) (((x) & (m)) << (b)) /* value X, mask M, at bit B */
+
+/* ARC instructions.
+
+ Longer versions of insns must appear before shorter ones (if gas sees
+ "lsr r2,r3,1" when it's parsing "lsr %a,%b" it will think the ",1" is
+ junk). This isn't necessary for `ld' because of the trailing ']'.
+
+ Instructions that are really macros based on other insns must appear
+ before the real insn so they're chosen when disassembling. Eg: The `mov'
+ insn is really the `and' insn.
+
+ This table is best viewed on a wide screen (161 columns). I'd prefer to
+ keep it this way. The rest of the file, however, should be viewable on an
+ 80 column terminal. */
+
+/* ??? This table also includes macros: asl, lsl, and mov. The ppc port has
+ a more general facility for dealing with macros which could be used if
+ we need to. */
+
+/* This table can't be `const' because members `next_asm' and `next_dis' are
+ computed at run-time. We could split this into two, but that doesn't seem
+ worth it. */
+
+struct arc_opcode arc_opcodes[] = {
+
+ /* Macros appear first. */
+ /* "mov" is really an "and". */
+ { "mov%.q%.f %a,%b%F%S%L%U", I(-1), I(12) },
+ /* "asl" is really an "add". */
+ { "asl%.q%.f %a,%b%F%S%L%U", I(-1), I(8) },
+ /* "lsl" is really an "add". */
+ { "lsl%.q%.f %a,%b%F%S%L%U", I(-1), I(8) },
+ /* "nop" is really an "xor". */
+ { "nop", 0xffffffff, 0x7fffffff },
+ /* "rlc" is really an "adc". */
+ { "rlc%.q%.f %a,%b%F%S%L%U", I(-1), I(9) },
+
+ /* The rest of these needn't be sorted, but it helps to find them if they are. */
+ { "adc%.q%.f %a,%b,%c%F%S%L", I(-1), I(9) },
+ { "add%.q%.f %a,%b,%c%F%S%L", I(-1), I(8) },
+ { "and%.q%.f %a,%b,%c%F%S%L", I(-1), I(12) },
+ { "asr%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(1) },
+ { "bic%.q%.f %a,%b,%c%F%S%L", I(-1), I(14) },
+ { "b%q%.n %B", I(-1), I(4), ARC_OPCODE_COND_BRANCH },
+ { "bl%q%.n %B", I(-1), I(5), ARC_OPCODE_COND_BRANCH },
+ { "extb%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(7) },
+ { "extw%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(8) },
+ { "flag%.q %b%G%S%L", I(-1)+A(-1)+C(-1), I(3)+A(ARC_REG_SHIMM_UPDATE)+C(0) },
+ /* %Q: force cond_p=1 --> no shimm values */
+ /* ??? This insn allows an optional flags spec. */
+ { "j%q%Q%.n%.f %b%J", I(-1)+A(-1)+C(-1)+R(-1,7,1), I(7)+A(0)+C(0)+R(0,7,1) },
+ /* Put opcode 1 ld insns first so shimm gets prefered over limm. */
+ /* "[%b]" is before "[%b,%d]" so 0 offsets don't get printed. */
+ { "ld%Z%.X%.W%.E %0%a,[%b]%L", I(-1)+R(-1,13,1)+R(-1,0,511), I(1)+R(0,13,1)+R(0,0,511) },
+ { "ld%Z%.X%.W%.E %a,[%b,%d]%S%L", I(-1)+R(-1,13,1), I(1)+R(0,13,1) },
+ { "ld%z%.x%.w%.e%Q %a,[%b,%c]%L", I(-1)+R(-1,4,1)+R(-1,6,7), I(0)+R(0,4,1)+R(0,6,7) },
+ { "lp%q%.n %B", I(-1), I(6), },
+ { "lr %a,[%Ab]%S%L", I(-1)+C(-1), I(1)+C(0x10) },
+ { "lsr%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(2) },
+ { "or%.q%.f %a,%b,%c%F%S%L", I(-1), I(13) },
+ { "ror%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(3) },
+ { "rrc%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(4) },
+ { "sbc%.q%.f %a,%b,%c%F%S%L", I(-1), I(11) },
+ { "sexb%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(5) },
+ { "sexw%.q%.f %a,%b%F%S%L", I(-1)+C(-1), I(3)+C(6) },
+ { "sr %c,[%Ab]%S%L", I(-1)+A(-1), I(2)+A(0x10) },
+ /* "[%b]" is before "[%b,%d]" so 0 offsets don't get printed. */
+ { "st%y%.v%.D%Q %0%c,[%b]%L", I(-1)+R(-1,25,1)+R(-1,21,1)+R(-1,0,511), I(2)+R(0,25,1)+R(0,21,1)+R(0,0,511) },
+ { "st%y%.v%.D %c,[%b,%d]%S%L", I(-1)+R(-1,25,1)+R(-1,21,1), I(2)+R(0,25,1)+R(0,21,1) },
+ { "sub%.q%.f %a,%b,%c%F%S%L", I(-1), I(10) },
+ { "xor%.q%.f %a,%b,%c%F%S%L", I(-1), I(15) }
+};
+const int arc_opcodes_count = sizeof (arc_opcodes) / sizeof (arc_opcodes[0]);
+
+const struct arc_operand_value arc_reg_names[] =
+{
+ /* Sort this so that the first 61 entries are sequential.
+ IE: For each i (i<61), arc_reg_names[i].value == i. */
+
+ { "r0", 0, REG }, { "r1", 1, REG }, { "r2", 2, REG }, { "r3", 3, REG },
+ { "r4", 4, REG }, { "r5", 5, REG }, { "r6", 6, REG }, { "r7", 7, REG },
+ { "r8", 8, REG }, { "r9", 9, REG }, { "r10", 10, REG }, { "r11", 11, REG },
+ { "r12", 12, REG }, { "r13", 13, REG }, { "r14", 14, REG }, { "r15", 15, REG },
+ { "r16", 16, REG }, { "r17", 17, REG }, { "r18", 18, REG }, { "r19", 19, REG },
+ { "r20", 20, REG }, { "r21", 21, REG }, { "r22", 22, REG }, { "r23", 23, REG },
+ { "r24", 24, REG }, { "r25", 25, REG }, { "r26", 26, REG }, { "fp", 27, REG },
+ { "sp", 28, REG }, { "ilink1", 29, REG }, { "ilink2", 30, REG }, { "blink", 31, REG },
+ { "r32", 32, REG }, { "r33", 33, REG }, { "r34", 34, REG }, { "r35", 35, REG },
+ { "r36", 36, REG }, { "r37", 37, REG }, { "r38", 38, REG }, { "r39", 39, REG },
+ { "r40", 40, REG }, { "r41", 41, REG }, { "r42", 42, REG }, { "r43", 43, REG },
+ { "r44", 44, REG }, { "r45", 45, REG }, { "r46", 46, REG }, { "r47", 47, REG },
+ { "r48", 48, REG }, { "r49", 49, REG }, { "r50", 50, REG }, { "r51", 51, REG },
+ { "r52", 52, REG }, { "r53", 53, REG }, { "r54", 54, REG }, { "r55", 55, REG },
+ { "r56", 56, REG }, { "r57", 57, REG }, { "r58", 58, REG }, { "r59", 59, REG },
+ { "lp_count", 60, REG },
+
+ /* I'd prefer to output these as "fp" and "sp" by default, but we still need
+ to recognize the canonical values. */
+ { "r27", 27, REG }, { "r28", 28, REG },
+
+ /* Someone may wish to refer to these in this way, and it's probably a
+ good idea to reserve them as such anyway. */
+ { "r29", 29, REG }, { "r30", 30, REG }, { "r31", 31, REG }, { "r60", 60, REG },
+
+ /* Standard auxiliary registers. */
+ { "status", 0, AUXREG },
+ { "semaphore", 1, AUXREG },
+ { "lp_start", 2, AUXREG },
+ { "lp_end", 3, AUXREG },
+ { "identity", 4, AUXREG },
+ { "debug", 5, AUXREG },
+};
+const int arc_reg_names_count = sizeof (arc_reg_names) / sizeof (arc_reg_names[0]);
+
+/* The suffix table.
+ Operands with the same name must be stored together. */
+
+const struct arc_operand_value arc_suffixes[] =
+{
+ /* Entry 0 is special, default values aren't printed by the disassembler. */
+ { "", 0, -1 },
+ { "al", 0, COND },
+ { "ra", 0, COND },
+ { "eq", 1, COND },
+ { "z", 1, COND },
+ { "ne", 2, COND },
+ { "nz", 2, COND },
+ { "p", 3, COND },
+ { "pl", 3, COND },
+ { "n", 4, COND },
+ { "mi", 4, COND },
+ { "c", 5, COND },
+ { "cs", 5, COND },
+ { "lo", 5, COND },
+ { "nc", 6, COND },
+ { "cc", 6, COND },
+ { "hs", 6, COND },
+ { "v", 7, COND },
+ { "vs", 7, COND },
+ { "nv", 8, COND },
+ { "vc", 8, COND },
+ { "gt", 9, COND },
+ { "ge", 10, COND },
+ { "lt", 11, COND },
+ { "le", 12, COND },
+ { "hi", 13, COND },
+ { "ls", 14, COND },
+ { "pnz", 15, COND },
+ { "f", 1, FLAG },
+ { "nd", ARC_DELAY_NONE, DELAY },
+ { "d", ARC_DELAY_NORMAL, DELAY },
+ { "jd", ARC_DELAY_JUMP, DELAY },
+/*{ "b", 7, SIZEEXT },*/
+/*{ "b", 5, SIZESEX },*/
+ { "b", 1, SIZE1 },
+ { "b", 1, SIZE10 },
+ { "b", 1, SIZE22 },
+/*{ "w", 8, SIZEEXT },*/
+/*{ "w", 6, SIZESEX },*/
+ { "w", 2, SIZE1 },
+ { "w", 2, SIZE10 },
+ { "w", 2, SIZE22 },
+ { "x", 1, SIGN0 },
+ { "x", 1, SIGN9 },
+ { "a", 1, ADDRESS3 },
+ { "a", 1, ADDRESS12 },
+ { "a", 1, ADDRESS24 },
+ { "di", 1, CACHEBYPASS5 },
+ { "di", 1, CACHEBYPASS14 },
+ { "di", 1, CACHEBYPASS26 },
+};
+const int arc_suffixes_count = sizeof (arc_suffixes) / sizeof (arc_suffixes[0]);
+
+/* Indexed by first letter of opcode. Points to chain of opcodes with same
+ first letter. */
+static struct arc_opcode *opcode_map[26 + 1];
+
+/* Indexed by insn code. Points to chain of opcodes with same insn code. */
+static struct arc_opcode *icode_map[32];
+
+/* Configuration flags. */
+
+/* Various ARC_HAVE_XXX bits. */
+static int cpu_type;
+
+/* Translate a bfd_mach_arc_xxx value to a ARC_MACH_XXX value. */
+
+int
+arc_get_opcode_mach (bfd_mach, big_p)
+ int bfd_mach, big_p;
+{
+ static int mach_type_map[] =
+ {
+ ARC_MACH_BASE
+ };
+
+ return mach_type_map[bfd_mach] | (big_p ? ARC_MACH_BIG : 0);
+}
+
+/* Initialize any tables that need it.
+ Must be called once at start up (or when first needed).
+
+ FLAGS is a set of bits that say what version of the cpu we have,
+ and in particular at least (one of) ARC_MACH_XXX. */
+
+void
+arc_opcode_init_tables (flags)
+ int flags;
+{
+ static int init_p = 0;
+
+ cpu_type = flags;
+
+ /* We may be intentionally called more than once (for example gdb will call
+ us each time the user switches cpu). These tables only need to be init'd
+ once though. */
+ /* ??? We can remove the need for arc_opcode_supported by taking it into
+ account here, but I'm not sure I want to do that yet (if ever). */
+ if (!init_p)
+ {
+ register int i,n;
+
+ memset (arc_operand_map, 0, sizeof (arc_operand_map));
+ n = sizeof (arc_operands) / sizeof (arc_operands[0]);
+ for (i = 0; i < n; ++i)
+ arc_operand_map[arc_operands[i].fmt] = i;
+
+ memset (opcode_map, 0, sizeof (opcode_map));
+ memset (icode_map, 0, sizeof (icode_map));
+ /* Scan the table backwards so macros appear at the front. */
+ for (i = arc_opcodes_count - 1; i >= 0; --i)
+ {
+ int opcode_hash = ARC_HASH_OPCODE (arc_opcodes[i].syntax);
+ int icode_hash = ARC_HASH_ICODE (arc_opcodes[i].value);
+
+ arc_opcodes[i].next_asm = opcode_map[opcode_hash];
+ opcode_map[opcode_hash] = &arc_opcodes[i];
+
+ arc_opcodes[i].next_dis = icode_map[icode_hash];
+ icode_map[icode_hash] = &arc_opcodes[i];
+ }
+
+ init_p = 1;
+ }
+}
+
+/* Return non-zero if OPCODE is supported on the specified cpu.
+ Cpu selection is made when calling `arc_opcode_init_tables'. */
+
+int
+arc_opcode_supported (opcode)
+ const struct arc_opcode *opcode;
+{
+ if (ARC_OPCODE_CPU (opcode->flags) == 0)
+ return 1;
+ if (ARC_OPCODE_CPU (opcode->flags) & ARC_HAVE_CPU (cpu_type))
+ return 1;
+ return 0;
+}
+
+/* Return non-zero if OPVAL is supported on the specified cpu.
+ Cpu selection is made when calling `arc_opcode_init_tables'. */
+
+int
+arc_opval_supported (opval)
+ const struct arc_operand_value *opval;
+{
+ if (ARC_OPVAL_CPU (opval->flags) == 0)
+ return 1;
+ if (ARC_OPVAL_CPU (opval->flags) & ARC_HAVE_CPU (cpu_type))
+ return 1;
+ return 0;
+}
+
+/* Return the first insn in the chain for assembling INSN. */
+
+const struct arc_opcode *
+arc_opcode_lookup_asm (insn)
+ const char *insn;
+{
+ return opcode_map[ARC_HASH_OPCODE (insn)];
+}
+
+/* Return the first insn in the chain for disassembling INSN. */
+
+const struct arc_opcode *
+arc_opcode_lookup_dis (insn)
+ unsigned int insn;
+{
+ return icode_map[ARC_HASH_ICODE (insn)];
+}
+
+/* Nonzero if we've seen an 'f' suffix (in certain insns). */
+static int flag_p;
+
+/* Nonzero if we've finished processing the 'f' suffix. */
+static int flagshimm_handled_p;
+
+/* Nonzero if we've seen a 'q' suffix (condition code). */
+static int cond_p;
+
+/* Nonzero if we've inserted a shimm. */
+static int shimm_p;
+
+/* The value of the shimm we inserted (each insn only gets one but it can
+ appear multiple times. */
+static int shimm;
+
+/* Nonzero if we've inserted a limm (during assembly) or seen a limm
+ (during disassembly). */
+static int limm_p;
+
+/* The value of the limm we inserted. Each insn only gets one but it can
+ appear multiple times. */
+static long limm;
+
+/* Insertion functions. */
+
+/* Called by the assembler before parsing an instruction. */
+
+void
+arc_opcode_init_insert ()
+{
+ flag_p = 0;
+ flagshimm_handled_p = 0;
+ cond_p = 0;
+ shimm_p = 0;
+ limm_p = 0;
+}
+
+/* Called by the assembler to see if the insn has a limm operand.
+ Also called by the disassembler to see if the insn contains a limm. */
+
+int
+arc_opcode_limm_p (limmp)
+ long *limmp;
+{
+ if (limmp)
+ *limmp = limm;
+ return limm_p;
+}
+
+/* Insert a value into a register field.
+ If REG is NULL, then this is actually a constant.
+
+ We must also handle auxiliary registers for lr/sr insns. */
+
+static arc_insn
+insert_reg (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ static char buf[100];
+
+ if (reg == NULL)
+ {
+ /* We have a constant that also requires a value stored in a register
+ field. Handle these by updating the register field and saving the
+ value for later handling by either %S (shimm) or %L (limm). */
+
+ /* Try to use a shimm value before a limm one. */
+ if (ARC_SHIMM_CONST_P (value)
+ /* If we've seen a conditional suffix we have to use a limm. */
+ && !cond_p
+ /* If we already have a shimm value that is different than ours
+ we have to use a limm. */
+ && (!shimm_p || shimm == value))
+ {
+ int marker = flag_p ? ARC_REG_SHIMM_UPDATE : ARC_REG_SHIMM;
+ flagshimm_handled_p = 1;
+ shimm_p = 1;
+ shimm = value;
+ insn |= marker << operand->shift;
+ /* insn |= value & 511; - done later */
+ }
+ /* We have to use a limm. If we've already seen one they must match. */
+ else if (!limm_p || limm == value)
+ {
+ limm_p = 1;
+ limm = value;
+ insn |= ARC_REG_LIMM << operand->shift;
+ /* The constant is stored later. */
+ }
+ else
+ {
+ *errmsg = _("unable to fit different valued constants into instruction");
+ }
+ }
+ else
+ {
+ /* We have to handle both normal and auxiliary registers. */
+
+ if (reg->type == AUXREG)
+ {
+ if (!(mods & ARC_MOD_AUXREG))
+ *errmsg = _("auxiliary register not allowed here");
+ else
+ {
+ insn |= ARC_REG_SHIMM << operand->shift;
+ insn |= reg->value << arc_operands[reg->type].shift;
+ }
+ }
+ else
+ {
+ /* We should never get an invalid register number here. */
+ if ((unsigned int) reg->value > 60)
+ {
+ /* xgettext:c-format */
+ sprintf (buf, _("invalid register number `%d'"), reg->value);
+ *errmsg = buf;
+ }
+ else
+ insn |= reg->value << operand->shift;
+ }
+ }
+
+ return insn;
+}
+
+/* Called when we see an 'f' flag. */
+
+static arc_insn
+insert_flag (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ /* We can't store anything in the insn until we've parsed the registers.
+ Just record the fact that we've got this flag. `insert_reg' will use it
+ to store the correct value (ARC_REG_SHIMM_UPDATE or bit 0x100). */
+ flag_p = 1;
+
+ return insn;
+}
+
+/* Called after completely building an insn to ensure the 'f' flag gets set
+ properly. This is needed because we don't know how to set this flag until
+ we've parsed the registers. */
+
+static arc_insn
+insert_flagfinish (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ if (flag_p && !flagshimm_handled_p)
+ {
+ if (shimm_p)
+ abort ();
+ flagshimm_handled_p = 1;
+ insn |= (1 << operand->shift);
+ }
+ return insn;
+}
+
+/* Called when we see a conditional flag (eg: .eq). */
+
+static arc_insn
+insert_cond (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ cond_p = 1;
+ insn |= (value & ((1 << operand->bits) - 1)) << operand->shift;
+ return insn;
+}
+
+/* Used in the "j" instruction to prevent constants from being interpreted as
+ shimm values (which the jump insn doesn't accept). This can also be used
+ to force the use of limm values in other situations (eg: ld r0,[foo] uses
+ this).
+ ??? The mechanism is sound. Access to it is a bit klunky right now. */
+
+static arc_insn
+insert_forcelimm (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ cond_p = 1;
+ return insn;
+}
+
+/* Used in ld/st insns to handle the shimm offset field. */
+
+static arc_insn
+insert_shimmoffset (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ long minval, maxval;
+ static char buf[100];
+
+ if (reg != NULL)
+ {
+ *errmsg = "register appears where shimm value expected";
+ }
+ else
+ {
+ /* This is *way* more general than necessary, but maybe some day it'll
+ be useful. */
+ if (operand->flags & ARC_OPERAND_SIGNED)
+ {
+ minval = -(1 << (operand->bits - 1));
+ maxval = (1 << (operand->bits - 1)) - 1;
+ }
+ else
+ {
+ minval = 0;
+ maxval = (1 << operand->bits) - 1;
+ }
+ if (value < minval || value > maxval)
+ {
+ /* xgettext:c-format */
+ sprintf (buf, _("value won't fit in range %ld - %ld"),
+ minval, maxval);
+ *errmsg = buf;
+ }
+ else
+ insn |= (value & ((1 << operand->bits) - 1)) << operand->shift;
+ }
+ return insn;
+}
+
+/* Used in ld/st insns when the shimm offset is 0. */
+
+static arc_insn
+insert_shimmzero (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ shimm_p = 1;
+ shimm = 0;
+ return insn;
+}
+
+/* Called at the end of processing normal insns (eg: add) to insert a shimm
+ value (if present) into the insn. */
+
+static arc_insn
+insert_shimmfinish (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ if (shimm_p)
+ insn |= (shimm & ((1 << operand->bits) - 1)) << operand->shift;
+ return insn;
+}
+
+/* Called at the end of processing normal insns (eg: add) to insert a limm
+ value (if present) into the insn.
+
+ Note that this function is only intended to handle instructions (with 4 byte
+ immediate operands). It is not intended to handle data. */
+
+/* ??? Actually, there's nothing for us to do as we can't call frag_more, the
+ caller must do that. The extract fns take a pointer to two words. The
+ insert fns could be converted and then we could do something useful, but
+ then the reloc handlers would have to know to work on the second word of
+ a 2 word quantity. That's too much so we don't handle them. */
+
+static arc_insn
+insert_limmfinish (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ if (limm_p)
+ ; /* nothing to do, gas does it */
+ return insn;
+}
+
+/* Called at the end of unary operand macros to copy the B field to C. */
+
+static arc_insn
+insert_unopmacro (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ insn |= ((insn >> ARC_SHIFT_REGB) & ARC_MASK_REG) << operand->shift;
+ return insn;
+}
+
+/* Insert a relative address for a branch insn (b, bl, or lp). */
+
+static arc_insn
+insert_reladdr (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ if (value & 3)
+ *errmsg = _("branch address not on 4 byte boundary");
+ insn |= ((value >> 2) & ((1 << operand->bits) - 1)) << operand->shift;
+ return insn;
+}
+
+/* Insert a limm value as a 26 bit address right shifted 2 into the insn.
+
+ Note that this function is only intended to handle instructions (with 4 byte
+ immediate operands). It is not intended to handle data. */
+
+/* ??? Actually, there's nothing for us to do as we can't call frag_more, the
+ caller must do that. The extract fns take a pointer to two words. The
+ insert fns could be converted and then we could do something useful, but
+ then the reloc handlers would have to know to work on the second word of
+ a 2 word quantity. That's too much so we don't handle them. */
+
+static arc_insn
+insert_absaddr (insn, operand, mods, reg, value, errmsg)
+ arc_insn insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value *reg;
+ long value;
+ const char **errmsg;
+{
+ if (limm_p)
+ ; /* nothing to do */
+ return insn;
+}
+
+/* Extraction functions.
+
+ The suffix extraction functions' return value is redundant since it can be
+ obtained from (*OPVAL)->value. However, the boolean suffixes don't have
+ a suffix table entry for the "false" case, so values of zero must be
+ obtained from the return value (*OPVAL == NULL). */
+
+static const struct arc_operand_value *lookup_register (int type, long regno);
+
+/* Called by the disassembler before printing an instruction. */
+
+void
+arc_opcode_init_extract ()
+{
+ flag_p = 0;
+ flagshimm_handled_p = 0;
+ shimm_p = 0;
+ limm_p = 0;
+}
+
+/* As we're extracting registers, keep an eye out for the 'f' indicator
+ (ARC_REG_SHIMM_UPDATE). If we find a register (not a constant marker,
+ like ARC_REG_SHIMM), set OPVAL so our caller will know this is a register.
+
+ We must also handle auxiliary registers for lr/sr insns. They are just
+ constants with special names. */
+
+static long
+extract_reg (insn, operand, mods, opval, invalid)
+ arc_insn *insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value **opval;
+ int *invalid;
+{
+ int regno;
+ long value;
+
+ /* Get the register number. */
+ regno = (insn[0] >> operand->shift) & ((1 << operand->bits) - 1);
+
+ /* Is it a constant marker? */
+ if (regno == ARC_REG_SHIMM)
+ {
+ value = insn[0] & 511;
+ if ((operand->flags & ARC_OPERAND_SIGNED)
+ && (value & 256))
+ value -= 512;
+ flagshimm_handled_p = 1;
+ }
+ else if (regno == ARC_REG_SHIMM_UPDATE)
+ {
+ value = insn[0] & 511;
+ if ((operand->flags & ARC_OPERAND_SIGNED)
+ && (value & 256))
+ value -= 512;
+ flag_p = 1;
+ flagshimm_handled_p = 1;
+ }
+ else if (regno == ARC_REG_LIMM)
+ {
+ value = insn[1];
+ limm_p = 1;
+ }
+ /* It's a register, set OPVAL (that's the only way we distinguish registers
+ from constants here). */
+ else
+ {
+ const struct arc_operand_value *reg = lookup_register (REG, regno);
+
+ if (reg == NULL)
+ abort ();
+ if (opval != NULL)
+ *opval = reg;
+ value = regno;
+ }
+
+ /* If this field takes an auxiliary register, see if it's a known one. */
+ if ((mods & ARC_MOD_AUXREG)
+ && ARC_REG_CONSTANT_P (regno))
+ {
+ const struct arc_operand_value *reg = lookup_register (AUXREG, value);
+
+ /* This is really a constant, but tell the caller it has a special
+ name. */
+ if (reg != NULL && opval != NULL)
+ *opval = reg;
+ }
+
+ return value;
+}
+
+/* Return the value of the "flag update" field for shimm insns.
+ This value is actually stored in the register field. */
+
+static long
+extract_flag (insn, operand, mods, opval, invalid)
+ arc_insn *insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value **opval;
+ int *invalid;
+{
+ int f;
+ const struct arc_operand_value *val;
+
+ if (flagshimm_handled_p)
+ f = flag_p != 0;
+ else
+ f = (insn[0] & (1 << operand->shift)) != 0;
+
+ /* There is no text for zero values. */
+ if (f == 0)
+ return 0;
+
+ val = arc_opcode_lookup_suffix (operand, 1);
+ if (opval != NULL && val != NULL)
+ *opval = val;
+ return val->value;
+}
+
+/* Extract the condition code (if it exists).
+ If we've seen a shimm value in this insn (meaning that the insn can't have
+ a condition code field), then we don't store anything in OPVAL and return
+ zero. */
+
+static long
+extract_cond (insn, operand, mods, opval, invalid)
+ arc_insn *insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value **opval;
+ int *invalid;
+{
+ long cond;
+ const struct arc_operand_value *val;
+
+ if (flagshimm_handled_p)
+ return 0;
+
+ cond = (insn[0] >> operand->shift) & ((1 << operand->bits) - 1);
+ val = arc_opcode_lookup_suffix (operand, cond);
+
+ /* Ignore NULL values of `val'. Several condition code values are
+ reserved for extensions. */
+ if (opval != NULL && val != NULL)
+ *opval = val;
+ return cond;
+}
+
+/* Extract a branch address.
+ We return the value as a real address (not right shifted by 2). */
+
+static long
+extract_reladdr (insn, operand, mods, opval, invalid)
+ arc_insn *insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value **opval;
+ int *invalid;
+{
+ long addr;
+
+ addr = (insn[0] >> operand->shift) & ((1 << operand->bits) - 1);
+ if ((operand->flags & ARC_OPERAND_SIGNED)
+ && (addr & (1 << (operand->bits - 1))))
+ addr -= 1 << operand->bits;
+
+ return addr << 2;
+}
+
+/* The only thing this does is set the `invalid' flag if B != C.
+ This is needed because the "mov" macro appears before it's real insn "and"
+ and we don't want the disassembler to confuse them. */
+
+static long
+extract_unopmacro (insn, operand, mods, opval, invalid)
+ arc_insn *insn;
+ const struct arc_operand *operand;
+ int mods;
+ const struct arc_operand_value **opval;
+ int *invalid;
+{
+ /* This misses the case where B == ARC_REG_SHIMM_UPDATE &&
+ C == ARC_REG_SHIMM (or vice versa). No big deal. Those insns will get
+ printed as "and"s. */
+ if (((insn[0] >> ARC_SHIFT_REGB) & ARC_MASK_REG)
+ != ((insn[0] >> ARC_SHIFT_REGC) & ARC_MASK_REG))
+ if (invalid != NULL)
+ *invalid = 1;
+
+ return 0;
+}
+
+/* Utility for the extraction functions to return the index into
+ `arc_suffixes'. */
+
+const struct arc_operand_value *
+arc_opcode_lookup_suffix (type, value)
+ const struct arc_operand *type;
+ int value;
+{
+ register const struct arc_operand_value *v,*end;
+
+ /* ??? This is a little slow and can be speeded up. */
+
+ for (v = arc_suffixes, end = arc_suffixes + arc_suffixes_count; v < end; ++v)
+ if (type == &arc_operands[v->type]
+ && value == v->value)
+ return v;
+ return 0;
+}
+
+static const struct arc_operand_value *
+lookup_register (type, regno)
+ int type;
+ long regno;
+{
+ register const struct arc_operand_value *r,*end;
+
+ if (type == REG)
+ return &arc_reg_names[regno];
+
+ /* ??? This is a little slow and can be speeded up. */
+
+ for (r = arc_reg_names, end = arc_reg_names + arc_reg_names_count;
+ r < end; ++r)
+ if (type == r->type && regno == r->value)
+ return r;
+ return 0;
+}
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
new file mode 100644
index 00000000000..4aabf7286bc
--- /dev/null
+++ b/opcodes/arm-dis.c
@@ -0,0 +1,887 @@
+/* Instruction printing code for the ARM
+ Copyright (C) 1994, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+ Modification by James G. Smith (jsmith@cygnus.co.uk)
+
+This file is part of libopcodes.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "dis-asm.h"
+#define DEFINE_TABLE
+#include "arm-opc.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+#include "opintl.h"
+
+/* FIXME: This shouldn't be done here */
+#include "elf-bfd.h"
+#include "elf/internal.h"
+#include "elf/arm.h"
+
+static char *arm_conditional[] =
+{"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc",
+ "hi", "ls", "ge", "lt", "gt", "le", "", "nv"};
+
+static char *arm_regnames[] =
+{"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc"};
+
+static char *arm_fp_const[] =
+{"0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0"};
+
+static char *arm_shift[] =
+{"lsl", "lsr", "asr", "ror"};
+
+static int print_insn_arm PARAMS ((bfd_vma, struct disassemble_info *,
+ long));
+
+static void
+arm_decode_shift (given, func, stream)
+ long given;
+ fprintf_ftype func;
+ void *stream;
+{
+ func (stream, "%s", arm_regnames[given & 0xf]);
+ if ((given & 0xff0) != 0)
+ {
+ if ((given & 0x10) == 0)
+ {
+ int amount = (given & 0xf80) >> 7;
+ int shift = (given & 0x60) >> 5;
+ if (amount == 0)
+ {
+ if (shift == 3)
+ {
+ func (stream, ", rrx");
+ return;
+ }
+ amount = 32;
+ }
+ func (stream, ", %s #%d", arm_shift[shift], amount);
+ }
+ else
+ func (stream, ", %s %s", arm_shift[(given & 0x60) >> 5],
+ arm_regnames[(given & 0xf00) >> 8]);
+ }
+}
+
+/* Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction (always 4 on ARM). */
+
+static int
+print_insn_arm (pc, info, given)
+ bfd_vma pc;
+ struct disassemble_info *info;
+ long given;
+{
+ struct arm_opcode * insn;
+ void * stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ for (insn = arm_opcodes; insn->assembler; insn++)
+ {
+ if ((given & insn->mask) == insn->value)
+ {
+ char * c;
+
+ for (c = insn->assembler; *c; c++)
+ {
+ if (*c == '%')
+ {
+ switch (*++c)
+ {
+ case '%':
+ func (stream, "%%");
+ break;
+
+ case 'a':
+ if (((given & 0x000f0000) == 0x000f0000)
+ && ((given & 0x02000000) == 0))
+ {
+ int offset = given & 0xfff;
+
+ func (stream, "[pc");
+
+ if (given & 0x01000000)
+ {
+ if ((given & 0x00800000) == 0)
+ offset = - offset;
+
+ /* pre-indexed */
+ func (stream, ", #%x]", offset);
+
+ offset += pc + 8;
+
+ /* Cope with the possibility of write-back being used.
+ Probably a very dangerous thing for the programmer
+ to do, but who are we to argue ? */
+ if (given & 0x00200000)
+ func (stream, "!");
+ }
+ else
+ {
+ /* post indexed */
+ func (stream, "], #%x", offset);
+
+ offset = pc + 8; /* ie ignore the offset */
+ }
+
+ func (stream, "\t; ");
+ info->print_address_func (offset, info);
+ }
+ else
+ {
+ func (stream, "[%s",
+ arm_regnames[(given >> 16) & 0xf]);
+ if ((given & 0x01000000) != 0)
+ {
+ if ((given & 0x02000000) == 0)
+ {
+ int offset = given & 0xfff;
+ if (offset)
+ func (stream, ", %s#%d",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""), offset);
+ }
+ else
+ {
+ func (stream, ", %s",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""));
+ arm_decode_shift (given, func, stream);
+ }
+
+ func (stream, "]%s",
+ ((given & 0x00200000) != 0) ? "!" : "");
+ }
+ else
+ {
+ if ((given & 0x02000000) == 0)
+ {
+ int offset = given & 0xfff;
+ if (offset)
+ func (stream, "], %s#%d",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""), offset);
+ else
+ func (stream, "]");
+ }
+ else
+ {
+ func (stream, "], %s",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""));
+ arm_decode_shift (given, func, stream);
+ }
+ }
+ }
+ break;
+
+ case 's':
+ if ((given & 0x004f0000) == 0x004f0000)
+ {
+ /* PC relative with immediate offset */
+ int offset = ((given & 0xf00) >> 4) | (given & 0xf);
+ if ((given & 0x00800000) == 0)
+ offset = -offset;
+ (*info->print_address_func)
+ (offset + pc + 8, info);
+ }
+ else
+ {
+ func (stream, "[%s",
+ arm_regnames[(given >> 16) & 0xf]);
+ if ((given & 0x01000000) != 0)
+ {
+ /* pre-indexed */
+ if ((given & 0x00400000) == 0x00400000)
+ {
+ /* immediate */
+ int offset = ((given & 0xf00) >> 4) | (given & 0xf);
+ if (offset)
+ func (stream, ", %s#%d",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""), offset);
+ }
+ else
+ {
+ /* register */
+ func (stream, ", %s%s",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""),
+ arm_regnames[given & 0xf]);
+ }
+
+ func (stream, "]%s",
+ ((given & 0x00200000) != 0) ? "!" : "");
+ }
+ else
+ {
+ /* post-indexed */
+ if ((given & 0x00400000) == 0x00400000)
+ {
+ /* immediate */
+ int offset = ((given & 0xf00) >> 4) | (given & 0xf);
+ if (offset)
+ func (stream, "], %s#%d",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""), offset);
+ else
+ func (stream, "]");
+ }
+ else
+ {
+ /* register */
+ func (stream, "], %s%s",
+ (((given & 0x00800000) == 0)
+ ? "-" : ""),
+ arm_regnames[given & 0xf]);
+ }
+ }
+ }
+ break;
+
+ case 'b':
+ (*info->print_address_func)
+ (BDISP (given) * 4 + pc + 8, info);
+ break;
+
+ case 'c':
+ func (stream, "%s",
+ arm_conditional [(given >> 28) & 0xf]);
+ break;
+
+ case 'm':
+ {
+ int started = 0;
+ int reg;
+
+ func (stream, "{");
+ for (reg = 0; reg < 16; reg++)
+ if ((given & (1 << reg)) != 0)
+ {
+ if (started)
+ func (stream, ", ");
+ started = 1;
+ func (stream, "%s", arm_regnames[reg]);
+ }
+ func (stream, "}");
+ }
+ break;
+
+ case 'o':
+ if ((given & 0x02000000) != 0)
+ {
+ int rotate = (given & 0xf00) >> 7;
+ int immed = (given & 0xff);
+ func (stream, "#%d",
+ ((immed << (32 - rotate))
+ | (immed >> rotate)) & 0xffffffff);
+ }
+ else
+ arm_decode_shift (given, func, stream);
+ break;
+
+ case 'p':
+ if ((given & 0x0000f000) == 0x0000f000)
+ func (stream, "p");
+ break;
+
+ case 't':
+ if ((given & 0x01200000) == 0x00200000)
+ func (stream, "t");
+ break;
+
+ case 'h':
+ if ((given & 0x00000020) == 0x00000020)
+ func (stream, "h");
+ else
+ func (stream, "b");
+ break;
+
+ case 'A':
+ func (stream, "[%s", arm_regnames [(given >> 16) & 0xf]);
+ if ((given & 0x01000000) != 0)
+ {
+ int offset = given & 0xff;
+ if (offset)
+ func (stream, ", %s#%d]%s",
+ ((given & 0x00800000) == 0 ? "-" : ""),
+ offset * 4,
+ ((given & 0x00200000) != 0 ? "!" : ""));
+ else
+ func (stream, "]");
+ }
+ else
+ {
+ int offset = given & 0xff;
+ if (offset)
+ func (stream, "], %s#%d",
+ ((given & 0x00800000) == 0 ? "-" : ""),
+ offset * 4);
+ else
+ func (stream, "]");
+ }
+ break;
+
+ case 'C':
+ switch (given & 0x00090000)
+ {
+ default:
+ func (stream, "_???");
+ break;
+ case 0x90000:
+ func (stream, "_all");
+ break;
+ case 0x10000:
+ func (stream, "_ctl");
+ break;
+ case 0x80000:
+ func (stream, "_flg");
+ break;
+ }
+ break;
+
+ case 'F':
+ switch (given & 0x00408000)
+ {
+ case 0:
+ func (stream, "4");
+ break;
+ case 0x8000:
+ func (stream, "1");
+ break;
+ case 0x00400000:
+ func (stream, "2");
+ break;
+ default:
+ func (stream, "3");
+ }
+ break;
+
+ case 'P':
+ switch (given & 0x00080080)
+ {
+ case 0:
+ func (stream, "s");
+ break;
+ case 0x80:
+ func (stream, "d");
+ break;
+ case 0x00080000:
+ func (stream, "e");
+ break;
+ default:
+ func (stream, _("<illegal precision>"));
+ break;
+ }
+ break;
+ case 'Q':
+ switch (given & 0x00408000)
+ {
+ case 0:
+ func (stream, "s");
+ break;
+ case 0x8000:
+ func (stream, "d");
+ break;
+ case 0x00400000:
+ func (stream, "e");
+ break;
+ default:
+ func (stream, "p");
+ break;
+ }
+ break;
+ case 'R':
+ switch (given & 0x60)
+ {
+ case 0:
+ break;
+ case 0x20:
+ func (stream, "p");
+ break;
+ case 0x40:
+ func (stream, "m");
+ break;
+ default:
+ func (stream, "z");
+ break;
+ }
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ int bitstart = *c++ - '0';
+ int bitend = 0;
+ while (*c >= '0' && *c <= '9')
+ bitstart = (bitstart * 10) + *c++ - '0';
+
+ switch (*c)
+ {
+ case '-':
+ c++;
+ while (*c >= '0' && *c <= '9')
+ bitend = (bitend * 10) + *c++ - '0';
+ if (!bitend)
+ abort ();
+ switch (*c)
+ {
+ case 'r':
+ {
+ long reg;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ func (stream, "%s", arm_regnames[reg]);
+ }
+ break;
+ case 'd':
+ {
+ long reg;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ func (stream, "%d", reg);
+ }
+ break;
+ case 'x':
+ {
+ long reg;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ func (stream, "0x%08x", reg);
+ }
+ break;
+ case 'f':
+ {
+ long reg;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ if (reg > 7)
+ func (stream, "#%s",
+ arm_fp_const[reg & 7]);
+ else
+ func (stream, "f%d", reg);
+ }
+ break;
+ default:
+ abort ();
+ }
+ break;
+ case '`':
+ c++;
+ if ((given & (1 << bitstart)) == 0)
+ func (stream, "%c", *c);
+ break;
+ case '\'':
+ c++;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c);
+ break;
+ case '?':
+ ++c;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c++);
+ else
+ func (stream, "%c", *++c);
+ break;
+ default:
+ abort ();
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+ }
+ else
+ func (stream, "%c", *c);
+ }
+ return 4;
+ }
+ }
+ abort ();
+}
+
+/* Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction. */
+
+static int
+print_insn_thumb (pc, info, given)
+ bfd_vma pc;
+ struct disassemble_info *info;
+ long given;
+{
+ struct thumb_opcode *insn;
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ for (insn = thumb_opcodes; insn->assembler; insn++)
+ {
+ if ((given & insn->mask) == insn->value)
+ {
+ char *c = insn->assembler;
+
+ /* Special processing for Thumb 2 instruction BL sequence: */
+ if (!*c) /* check for empty (not NULL) assembler string */
+ {
+ info->bytes_per_chunk = 4;
+ info->bytes_per_line = 4;
+
+ func (stream, "%04x\tbl\t", given & 0xffff);
+ (*info->print_address_func)
+ (BDISP23 (given) * 2 + pc + 4, info);
+ return 4;
+ }
+ else
+ {
+ info->bytes_per_chunk = 2;
+ info->bytes_per_line = 4;
+
+ given &= 0xffff;
+ func (stream, "%04x\t", given);
+ for (; *c; c++)
+ {
+ if (*c == '%')
+ {
+ int domaskpc = 0;
+ int domasklr = 0;
+ switch (*++c)
+ {
+ case '%':
+ func (stream, "%%");
+ break;
+
+ case 'S':
+ {
+ long reg;
+ reg = (given >> 3) & 0x7;
+ if (given & (1 << 6))
+ reg += 8;
+ func (stream, "%s", arm_regnames[reg]);
+ }
+ break;
+
+ case 'D':
+ {
+ long reg;
+ reg = given & 0x7;
+ if (given & (1 << 7))
+ reg += 8;
+ func (stream, "%s", arm_regnames[reg]);
+ }
+ break;
+
+ case 'T':
+ func (stream, "%s",
+ arm_conditional [(given >> 8) & 0xf]);
+ break;
+
+ case 'N':
+ if (given & (1 << 8))
+ domasklr = 1;
+ /* fall through */
+ case 'O':
+ if (*c == 'O' && (given & (1 << 8)))
+ domaskpc = 1;
+ /* fall through */
+ case 'M':
+ {
+ int started = 0;
+ int reg;
+ func (stream, "{");
+ /* It would be nice if we could spot
+ ranges, and generate the rS-rE format: */
+ for (reg = 0; (reg < 8); reg++)
+ if ((given & (1 << reg)) != 0)
+ {
+ if (started)
+ func (stream, ", ");
+ started = 1;
+ func (stream, "%s", arm_regnames[reg]);
+ }
+
+ if (domasklr)
+ {
+ if (started)
+ func (stream, ", ");
+ started = 1;
+ func (stream, "lr");
+ }
+
+ if (domaskpc)
+ {
+ if (started)
+ func (stream, ", ");
+ func (stream, "pc");
+ }
+
+ func (stream, "}");
+ }
+ break;
+
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ int bitstart = *c++ - '0';
+ int bitend = 0;
+ while (*c >= '0' && *c <= '9')
+ bitstart = (bitstart * 10) + *c++ - '0';
+
+ switch (*c)
+ {
+ case '-':
+ {
+ long reg;
+ c++;
+ while (*c >= '0' && *c <= '9')
+ bitend = (bitend * 10) + *c++ - '0';
+ if (!bitend)
+ abort ();
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ switch (*c)
+ {
+ case 'r':
+ func (stream, "%s", arm_regnames[reg]);
+ break;
+
+ case 'd':
+ func (stream, "%d", reg);
+ break;
+
+ case 'H':
+ func (stream, "%d", reg << 1);
+ break;
+
+ case 'W':
+ func (stream, "%d", reg << 2);
+ break;
+
+ case 'a':
+ /* PC-relative address -- the bottom two
+ bits of the address are dropped before
+ the calculation. */
+ info->print_address_func
+ (((pc + 4) & ~3) + (reg << 2), info);
+ break;
+
+ case 'x':
+ func (stream, "0x%04x", reg);
+ break;
+
+ case 'I':
+ reg = ((reg ^ (1 << bitend)) - (1 << bitend));
+ func (stream, "%d", reg);
+ break;
+
+ case 'B':
+ reg = ((reg ^ (1 << bitend)) - (1 << bitend));
+ (*info->print_address_func)
+ (reg * 2 + pc + 4, info);
+ break;
+
+ default:
+ abort();
+ }
+ }
+ break;
+
+ case '\'':
+ c++;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c);
+ break;
+
+ case '?':
+ ++c;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c++);
+ else
+ func (stream, "%c", *++c);
+ break;
+
+ default:
+ abort();
+ }
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+ else
+ func (stream, "%c", *c);
+ }
+ }
+ return 2;
+ }
+ }
+
+ /* no match */
+ abort ();
+}
+
+/* NOTE: There are no checks in these routines that the relevant number of data bytes exist */
+
+int
+print_insn_big_arm (pc, info)
+ bfd_vma pc;
+ struct disassemble_info *info;
+{
+ unsigned char b[4];
+ long given;
+ int status;
+ coff_symbol_type *cs;
+ elf_symbol_type *es;
+ int is_thumb;
+
+ is_thumb = false;
+ if (info->symbols != NULL)
+ {
+ if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour)
+ {
+ cs = coffsymbol (*info->symbols);
+ is_thumb = (cs->native->u.syment.n_sclass == C_THUMBEXT
+ || cs->native->u.syment.n_sclass == C_THUMBSTAT
+ || cs->native->u.syment.n_sclass == C_THUMBLABEL
+ || cs->native->u.syment.n_sclass == C_THUMBEXTFUNC
+ || cs->native->u.syment.n_sclass == C_THUMBSTATFUNC);
+
+ }
+ else if (bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour)
+ {
+ es = *(elf_symbol_type **)(info->symbols);
+ is_thumb = ELF_ST_TYPE (es->internal_elf_sym.st_info) ==
+ STT_ARM_TFUNC;
+ }
+ }
+
+ info->bytes_per_chunk = 4;
+ info->display_endian = BFD_ENDIAN_BIG;
+
+ /* Always fetch word aligned values. */
+
+ status = (*info->read_memory_func) (pc & ~ 0x3, (bfd_byte *) &b[0], 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+
+ if (is_thumb)
+ {
+ if (pc & 0x2)
+ {
+ given = (b[2] << 8) | b[3];
+
+ status = info->read_memory_func ((pc + 4) & ~ 0x3, (bfd_byte *) b, 4, info);
+ if (status != 0)
+ {
+ info->memory_error_func (status, pc + 4, info);
+ return -1;
+ }
+
+ given |= (b[0] << 24) | (b[1] << 16);
+ }
+ else
+ {
+ given = (b[0] << 8) | b[1] | (b[2] << 24) | (b[3] << 16);
+ }
+ }
+ else
+ {
+ given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
+ }
+
+ if (is_thumb)
+ {
+ status = print_insn_thumb (pc, info, given);
+ }
+ else
+ {
+ status = print_insn_arm (pc, info, given);
+ }
+
+ return status;
+}
+
+int
+print_insn_little_arm (pc, info)
+ bfd_vma pc;
+ struct disassemble_info * info;
+{
+ unsigned char b[4];
+ long given;
+ int status;
+ coff_symbol_type *cs;
+ elf_symbol_type *es;
+ int is_thumb;
+
+ is_thumb = false;
+ if (info->symbols != NULL)
+ {
+ if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour)
+ {
+ cs = coffsymbol (*info->symbols);
+ is_thumb = (cs->native->u.syment.n_sclass == C_THUMBEXT
+ || cs->native->u.syment.n_sclass == C_THUMBSTAT
+ || cs->native->u.syment.n_sclass == C_THUMBLABEL
+ || cs->native->u.syment.n_sclass == C_THUMBEXTFUNC
+ || cs->native->u.syment.n_sclass == C_THUMBSTATFUNC);
+
+ }
+ else if (bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour)
+ {
+ es = *(elf_symbol_type **)(info->symbols);
+ is_thumb = ELF_ST_TYPE (es->internal_elf_sym.st_info) ==
+ STT_ARM_TFUNC;
+ }
+ }
+
+ info->bytes_per_chunk = 4;
+ info->display_endian = BFD_ENDIAN_LITTLE;
+
+ status = (*info->read_memory_func) (pc, (bfd_byte *) &b[0], 4, info);
+ if (status != 0 && is_thumb)
+ {
+ info->bytes_per_chunk = 2;
+
+ status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
+ b[3] = b[2] = 0;
+ }
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+
+ given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
+
+ if (is_thumb)
+ {
+ status = print_insn_thumb (pc, info, given);
+ }
+ else
+ {
+ status = print_insn_arm (pc, info, given);
+ }
+
+ return status;
+}
diff --git a/opcodes/arm-opc.h b/opcodes/arm-opc.h
new file mode 100644
index 00000000000..f49298fb0cd
--- /dev/null
+++ b/opcodes/arm-opc.h
@@ -0,0 +1,281 @@
+/* Opcode table for the ARM.
+
+ Copyright 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+struct arm_opcode {
+ unsigned long value, mask; /* recognise instruction if (op&mask)==value */
+ char *assembler; /* how to disassemble this instruction */
+};
+
+struct thumb_opcode
+{
+ unsigned short value, mask; /* recognise instruction if (op&mask)==value */
+ char * assembler; /* how to disassemble this instruction */
+};
+
+/* format of the assembler string :
+
+ %% %
+ %<bitfield>d print the bitfield in decimal
+ %<bitfield>x print the bitfield in hex
+ %<bitfield>r print as an ARM register
+ %<bitfield>f print a floating point constant if >7 else a
+ floating point register
+ %c print condition code (always bits 28-31)
+ %P print floating point precision in arithmetic insn
+ %Q print floating point precision in ldf/stf insn
+ %R print floating point rounding mode
+ %<bitnum>'c print specified char iff bit is one
+ %<bitnum>`c print specified char iff bit is zero
+ %<bitnum>?ab print a if bit is one else print b
+ %p print 'p' iff bits 12-15 are 15
+ %t print 't' iff bit 21 set and bit 24 clear
+ %h print 'h' iff bit 5 set, else print 'b'
+ %o print operand2 (immediate or register + shift)
+ %a print address for ldr/str instruction
+ %s print address for ldr/str halfword/signextend instruction
+ %b print branch destination
+ %A print address for ldc/stc/ldf/stf instruction
+ %m print register mask for ldm/stm instruction
+ %C print the PSR sub type.
+ %F print the COUNT field of a LFM/SFM instruction.
+Thumb specific format options:
+ %D print Thumb register (bits 0..2 as high number if bit 7 set)
+ %S print Thumb register (bits 3..5 as high number if bit 6 set)
+ %<bitfield>I print bitfield as a signed decimal
+ (top bit of range being the sign bit)
+ %M print Thumb register mask
+ %N print Thumb register mask (with LR)
+ %O print Thumb register mask (with PC)
+ %T print Thumb condition code (always bits 8-11)
+ %<bitfield>B print Thumb branch destination (signed displacement)
+ %<bitfield>W print (bitfield * 4) as a decimal
+ %<bitfield>H print (bitfield * 2) as a decimal
+ %<bitfield>a print (bitfield * 4) as a pc-rel offset + decoded symbol
+*/
+
+/* Note: There is a partial ordering in this table - it must be searched from
+ the top to obtain a correct match. */
+
+static struct arm_opcode arm_opcodes[] = {
+ /* ARM instructions */
+ {0xe1a00000, 0xffffffff, "nop\t\t\t(mov r0,r0)"},
+ {0x012FFF10, 0x0ffffff0, "bx%c\t%0-3r"},
+ {0x00000090, 0x0fe000f0, "mul%c%20's\t%16-19r, %0-3r, %8-11r"},
+ {0x00200090, 0x0fe000f0, "mla%c%20's\t%16-19r, %0-3r, %8-11r, %12-15r"},
+ {0x01000090, 0x0fb00ff0, "swp%c%22'b\t%12-15r, %0-3r, [%16-19r]"},
+ {0x00800090, 0x0fa000f0, "%22?sumull%c%20's\t%12-15r, %16-19r, %0-3r, %8-11r"},
+ {0x00a00090, 0x0fa000f0, "%22?sumlal%c%20's\t%12-15r, %16-19r, %0-3r, %8-11r"},
+ {0x00000090, 0x0e100090, "str%c%6's%h\t%12-15r, %s"},
+ {0x00100090, 0x0e100090, "ldr%c%6's%h\t%12-15r, %s"},
+ {0x00000000, 0x0de00000, "and%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00200000, 0x0de00000, "eor%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00400000, 0x0de00000, "sub%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00600000, 0x0de00000, "rsb%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00800000, 0x0de00000, "add%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00a00000, 0x0de00000, "adc%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00c00000, 0x0de00000, "sbc%c%20's\t%12-15r, %16-19r, %o"},
+ {0x00e00000, 0x0de00000, "rsc%c%20's\t%12-15r, %16-19r, %o"},
+ {0x0120f000, 0x0db6f000, "msr%c\t%22?scpsr%C, %o"},
+ {0x010f0000, 0x0fbf0fff, "mrs%c\t%12-15r, %22?scpsr"},
+ {0x01000000, 0x0de00000, "tst%c%p\t%16-19r, %o"},
+ {0x01200000, 0x0de00000, "teq%c%p\t%16-19r, %o"},
+ {0x01400000, 0x0de00000, "cmp%c%p\t%16-19r, %o"},
+ {0x01600000, 0x0de00000, "cmn%c%p\t%16-19r, %o"},
+ {0x01800000, 0x0de00000, "orr%c%20's\t%12-15r, %16-19r, %o"},
+ {0x01a00000, 0x0de00000, "mov%c%20's\t%12-15r, %o"},
+ {0x01c00000, 0x0de00000, "bic%c%20's\t%12-15r, %16-19r, %o"},
+ {0x01e00000, 0x0de00000, "mvn%c%20's\t%12-15r, %o"},
+ {0x04000000, 0x0e100000, "str%c%22'b%t\t%12-15r, %a"},
+ {0x06000000, 0x0e100ff0, "str%c%22'b%t\t%12-15r, %a"},
+ {0x04000000, 0x0c100010, "str%c%22'b%t\t%12-15r, %a"},
+ {0x06000010, 0x0e000010, "undefined"},
+ {0x04100000, 0x0c100000, "ldr%c%22'b%t\t%12-15r, %a"},
+ {0x08000000, 0x0e100000, "stm%c%23?id%24?ba\t%16-19r%21'!, %m%22'^"},
+ {0x08100000, 0x0e100000, "ldm%c%23?id%24?ba\t%16-19r%21'!, %m%22'^"},
+ {0x0a000000, 0x0e000000, "b%24'l%c\t%b"},
+ {0x0f000000, 0x0f000000, "swi%c\t%0-23x"},
+
+ /* Floating point coprocessor instructions */
+ {0x0e000100, 0x0ff08f10, "adf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e100100, 0x0ff08f10, "muf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e200100, 0x0ff08f10, "suf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e300100, 0x0ff08f10, "rsf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e400100, 0x0ff08f10, "dvf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e500100, 0x0ff08f10, "rdf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e600100, 0x0ff08f10, "pow%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e700100, 0x0ff08f10, "rpw%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e800100, 0x0ff08f10, "rmf%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e900100, 0x0ff08f10, "fml%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0ea00100, 0x0ff08f10, "fdv%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0eb00100, 0x0ff08f10, "frd%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0ec00100, 0x0ff08f10, "pol%c%P%R\t%12-14f, %16-18f, %0-3f"},
+ {0x0e008100, 0x0ff08f10, "mvf%c%P%R\t%12-14f, %0-3f"},
+ {0x0e108100, 0x0ff08f10, "mnf%c%P%R\t%12-14f, %0-3f"},
+ {0x0e208100, 0x0ff08f10, "abs%c%P%R\t%12-14f, %0-3f"},
+ {0x0e308100, 0x0ff08f10, "rnd%c%P%R\t%12-14f, %0-3f"},
+ {0x0e408100, 0x0ff08f10, "sqt%c%P%R\t%12-14f, %0-3f"},
+ {0x0e508100, 0x0ff08f10, "log%c%P%R\t%12-14f, %0-3f"},
+ {0x0e608100, 0x0ff08f10, "lgn%c%P%R\t%12-14f, %0-3f"},
+ {0x0e708100, 0x0ff08f10, "exp%c%P%R\t%12-14f, %0-3f"},
+ {0x0e808100, 0x0ff08f10, "sin%c%P%R\t%12-14f, %0-3f"},
+ {0x0e908100, 0x0ff08f10, "cos%c%P%R\t%12-14f, %0-3f"},
+ {0x0ea08100, 0x0ff08f10, "tan%c%P%R\t%12-14f, %0-3f"},
+ {0x0eb08100, 0x0ff08f10, "asn%c%P%R\t%12-14f, %0-3f"},
+ {0x0ec08100, 0x0ff08f10, "acs%c%P%R\t%12-14f, %0-3f"},
+ {0x0ed08100, 0x0ff08f10, "atn%c%P%R\t%12-14f, %0-3f"},
+ {0x0ee08100, 0x0ff08f10, "urd%c%P%R\t%12-14f, %0-3f"},
+ {0x0ef08100, 0x0ff08f10, "nrm%c%P%R\t%12-14f, %0-3f"},
+ {0x0e000110, 0x0ff00f1f, "flt%c%P%R\t%16-18f, %12-15r"},
+ {0x0e100110, 0x0fff0f98, "fix%c%R\t%12-15r, %0-2f"},
+ {0x0e200110, 0x0fff0fff, "wfs%c\t%12-15r"},
+ {0x0e300110, 0x0fff0fff, "rfs%c\t%12-15r"},
+ {0x0e400110, 0x0fff0fff, "wfc%c\t%12-15r"},
+ {0x0e500110, 0x0fff0fff, "rfc%c\t%12-15r"},
+ {0x0e90f110, 0x0ff8fff0, "cmf%c\t%16-18f, %0-3f"},
+ {0x0eb0f110, 0x0ff8fff0, "cnf%c\t%16-18f, %0-3f"},
+ {0x0ed0f110, 0x0ff8fff0, "cmfe%c\t%16-18f, %0-3f"},
+ {0x0ef0f110, 0x0ff8fff0, "cnfe%c\t%16-18f, %0-3f"},
+ {0x0c000100, 0x0e100f00, "stf%c%Q\t%12-14f, %A"},
+ {0x0c100100, 0x0e100f00, "ldf%c%Q\t%12-14f, %A"},
+ {0x0c000200, 0x0e100f00, "sfm%c\t%12-14f, %F, %A"},
+ {0x0c100200, 0x0e100f00, "lfm%c\t%12-14f, %F, %A"},
+
+ /* Generic coprocessor instructions */
+ {0x0e000000, 0x0f000010, "cdp%c\t%8-11d, %20-23d, cr%12-15d, cr%16-19d, cr%0-3d, {%5-7d}"},
+ {0x0e100010, 0x0f100010, "mrc%c\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"},
+ {0x0e000010, 0x0f100010, "mcr%c\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"},
+ {0x0c000000, 0x0e100000, "stc%c%22'l\t%8-11d, cr%12-15d, %A"},
+ {0x0c100000, 0x0e100000, "ldc%c%22'l\t%8-11d, cr%12-15d, %A"},
+ /* the rest */
+ {0x00000000, 0x00000000, "undefined instruction %0-31x"},
+ {0x00000000, 0x00000000, 0}
+};
+
+#define BDISP(x) ((((x) & 0xffffff) ^ 0x800000) - 0x800000) /* 26 bit */
+
+static struct thumb_opcode thumb_opcodes[] =
+{
+ /* Thumb instructions */
+ {0x46C0, 0xFFFF, "nop\t\t\t(mov r8,r8)"}, /* format 5 instructions do not update the PSR */
+ {0x1C00, 0xFFC0, "mov\t%0-2r, %3-5r\t\t(add %0-2r, %3-5r, #%6-8d)"},
+ /* format 4 */
+ {0x4000, 0xFFC0, "and\t%0-2r, %3-5r"},
+ {0x4040, 0xFFC0, "eor\t%0-2r, %3-5r"},
+ {0x4080, 0xFFC0, "lsl\t%0-2r, %3-5r"},
+ {0x40C0, 0xFFC0, "lsr\t%0-2r, %3-5r"},
+ {0x4100, 0xFFC0, "asr\t%0-2r, %3-5r"},
+ {0x4140, 0xFFC0, "adc\t%0-2r, %3-5r"},
+ {0x4180, 0xFFC0, "sbc\t%0-2r, %3-5r"},
+ {0x41C0, 0xFFC0, "ror\t%0-2r, %3-5r"},
+ {0x4200, 0xFFC0, "tst\t%0-2r, %3-5r"},
+ {0x4240, 0xFFC0, "neg\t%0-2r, %3-5r"},
+ {0x4280, 0xFFC0, "cmp\t%0-2r, %3-5r"},
+ {0x42C0, 0xFFC0, "cmn\t%0-2r, %3-5r"},
+ {0x4300, 0xFFC0, "orr\t%0-2r, %3-5r"},
+ {0x4340, 0xFFC0, "mul\t%0-2r, %3-5r"},
+ {0x4380, 0xFFC0, "bic\t%0-2r, %3-5r"},
+ {0x43C0, 0xFFC0, "mvn\t%0-2r, %3-5r"},
+ /* format 13 */
+ {0xB000, 0xFF80, "add\tsp, #%0-6W"},
+ {0xB080, 0xFF80, "sub\tsp, #%0-6W"},
+ /* format 5 */
+ {0x4700, 0xFF80, "bx\t%S"},
+ {0x4400, 0xFF00, "add\t%D, %S"},
+ {0x4500, 0xFF00, "cmp\t%D, %S"},
+ {0x4600, 0xFF00, "mov\t%D, %S"},
+ /* format 14 */
+ {0xB400, 0xFE00, "push\t%N"},
+ {0xBC00, 0xFE00, "pop\t%O"},
+ /* format 2 */
+ {0x1800, 0xFE00, "add\t%0-2r, %3-5r, %6-8r"},
+ {0x1A00, 0xFE00, "sub\t%0-2r, %3-5r, %6-8r"},
+ {0x1C00, 0xFE00, "add\t%0-2r, %3-5r, #%6-8d"},
+ {0x1E00, 0xFE00, "sub\t%0-2r, %3-5r, #%6-8d"},
+ /* format 8 */
+ {0x5200, 0xFE00, "strh\t%0-2r, [%3-5r, %6-8r]"},
+ {0x5A00, 0xFE00, "ldrh\t%0-2r, [%3-5r, %6-8r]"},
+ {0x5600, 0xF600, "lds%11?hb\t%0-2r, [%3-5r, %6-8r]"},
+ /* format 7 */
+ {0x5000, 0xFA00, "str%10'b\t%0-2r, [%3-5r, %6-8r]"},
+ {0x5800, 0xFA00, "ldr%10'b\t%0-2r, [%3-5r, %6-8r]"},
+ /* format 1 */
+ {0x0000, 0xF800, "lsl\t%0-2r, %3-5r, #%6-10d"},
+ {0x0800, 0xF800, "lsr\t%0-2r, %3-5r, #%6-10d"},
+ {0x1000, 0xF800, "asr\t%0-2r, %3-5r, #%6-10d"},
+ /* format 3 */
+ {0x2000, 0xF800, "mov\t%8-10r, #%0-7d"},
+ {0x2800, 0xF800, "cmp\t%8-10r, #%0-7d"},
+ {0x3000, 0xF800, "add\t%8-10r, #%0-7d"},
+ {0x3800, 0xF800, "sub\t%8-10r, #%0-7d"},
+ /* format 6 */
+ {0x4800, 0xF800, "ldr\t%8-10r, [pc, #%0-7W]\t(%0-7a)"}, /* TODO: Disassemble PC relative "LDR rD,=<symbolic>" */
+ /* format 9 */
+ {0x6000, 0xF800, "str\t%0-2r, [%3-5r, #%6-10W]"},
+ {0x6800, 0xF800, "ldr\t%0-2r, [%3-5r, #%6-10W]"},
+ {0x7000, 0xF800, "strb\t%0-2r, [%3-5r, #%6-10d]"},
+ {0x7800, 0xF800, "ldrb\t%0-2r, [%3-5r, #%6-10d]"},
+ /* format 10 */
+ {0x8000, 0xF800, "strh\t%0-2r, [%3-5r, #%6-10H]"},
+ {0x8800, 0xF800, "ldrh\t%0-2r, [%3-5r, #%6-10H]"},
+ /* format 11 */
+ {0x9000, 0xF800, "str\t%8-10r, [sp, #%0-7W]"},
+ {0x9800, 0xF800, "ldr\t%8-10r, [sp, #%0-7W]"},
+ /* format 12 */
+ {0xA000, 0xF800, "add\t%8-10r, pc, #%0-7W\t(adr %8-10r,%0-7a)"},
+ {0xA800, 0xF800, "add\t%8-10r, sp, #%0-7W"},
+ /* format 15 */
+ {0xC000, 0xF800, "stmia\t%8-10r!,%M"},
+ {0xC800, 0xF800, "ldmia\t%8-10r!,%M"},
+ /* format 18 */
+ {0xE000, 0xF800, "b\t%0-10B"},
+ {0xE800, 0xF800, "undefined"},
+ /* format 19 */
+ {0xF000, 0xF800, ""}, /* special processing required in disassembler */
+ {0xF800, 0xF800, "second half of BL instruction %0-15x"},
+ /* format 16 */
+ {0xD000, 0xFF00, "beq\t%0-7B"},
+ {0xD100, 0xFF00, "bne\t%0-7B"},
+ {0xD200, 0xFF00, "bcs\t%0-7B"},
+ {0xD300, 0xFF00, "bcc\t%0-7B"},
+ {0xD400, 0xFF00, "bmi\t%0-7B"},
+ {0xD500, 0xFF00, "bpl\t%0-7B"},
+ {0xD600, 0xFF00, "bvs\t%0-7B"},
+ {0xD700, 0xFF00, "bvc\t%0-7B"},
+ {0xD800, 0xFF00, "bhi\t%0-7B"},
+ {0xD900, 0xFF00, "bls\t%0-7B"},
+ {0xDA00, 0xFF00, "bge\t%0-7B"},
+ {0xDB00, 0xFF00, "blt\t%0-7B"},
+ {0xDC00, 0xFF00, "bgt\t%0-7B"},
+ {0xDD00, 0xFF00, "ble\t%0-7B"},
+ /* format 17 */
+ {0xDE00, 0xFF00, "undefined"},
+ {0xDF00, 0xFF00, "swi\t%0-7d"},
+ /* format 9 */
+ {0x6000, 0xF800, "str\t%0-2r, [%3-5r, #%6-10W]"},
+ {0x6800, 0xF800, "ldr\t%0-2r, [%3-5r, #%6-10W]"},
+ {0x7000, 0xF800, "strb\t%0-2r, [%3-5r, #%6-10d]"},
+ {0x7800, 0xF800, "ldrb\t%0-2r, [%3-5r, #%6-10d]"},
+ /* the rest */
+ {0x0000, 0x0000, "undefined instruction %0-15x"},
+ {0x0000, 0x0000, 0}
+};
+
+#define BDISP23(x) ((((((x) & 0x07ff) << 11) | (((x) & 0x07ff0000) >> 16)) \
+ ^ 0x200000) - 0x200000) /* 23bit */
+
diff --git a/opcodes/cgen-asm.c b/opcodes/cgen-asm.c
new file mode 100644
index 00000000000..4ed69363a9d
--- /dev/null
+++ b/opcodes/cgen-asm.c
@@ -0,0 +1,359 @@
+/* CGEN generic assembler support code.
+
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "sysdep.h"
+#include <stdio.h>
+#include <ctype.h>
+#include "ansidecl.h"
+#include "libiberty.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "opcode/cgen.h"
+#include "opintl.h"
+
+/* Set the cgen_parse_operand_fn callback. */
+
+void
+cgen_set_parse_operand_fn (cd, fn)
+ CGEN_CPU_DESC cd;
+ cgen_parse_operand_fn fn;
+{
+ cd->parse_operand_fn = fn;
+}
+
+/* Called whenever starting to parse an insn. */
+
+void
+cgen_init_parse_operand (cd)
+ CGEN_CPU_DESC cd;
+{
+ /* This tells the callback to re-initialize. */
+ (void) (* cd->parse_operand_fn)
+ (cd, CGEN_PARSE_OPERAND_INIT, NULL, 0, 0, NULL, NULL);
+}
+
+/* Subroutine of build_asm_hash_table to add INSNS to the hash table.
+
+ COUNT is the number of elements in INSNS.
+ ENTSIZE is sizeof (CGEN_IBASE) for the target.
+ ??? No longer used but leave in for now.
+ HTABLE points to the hash table.
+ HENTBUF is a pointer to sufficiently large buffer of hash entries.
+ The result is a pointer to the next entry to use.
+
+ The table is scanned backwards as additions are made to the front of the
+ list and we want earlier ones to be prefered. */
+
+static CGEN_INSN_LIST *
+hash_insn_array (cd, insns, count, entsize, htable, hentbuf)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insns;
+ int count;
+ int entsize;
+ CGEN_INSN_LIST **htable;
+ CGEN_INSN_LIST *hentbuf;
+{
+ int i;
+
+ for (i = count - 1; i >= 0; --i, ++hentbuf)
+ {
+ unsigned int hash;
+ const CGEN_INSN *insn = &insns[i];
+
+ if (! (* cd->asm_hash_p) (insn))
+ continue;
+ hash = (* cd->asm_hash) (CGEN_INSN_MNEMONIC (insn));
+ hentbuf->next = htable[hash];
+ hentbuf->insn = insn;
+ htable[hash] = hentbuf;
+ }
+
+ return hentbuf;
+}
+
+/* Subroutine of build_asm_hash_table to add INSNS to the hash table.
+ This function is identical to hash_insn_array except the insns are
+ in a list. */
+
+static CGEN_INSN_LIST *
+hash_insn_list (cd, insns, htable, hentbuf)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN_LIST *insns;
+ CGEN_INSN_LIST **htable;
+ CGEN_INSN_LIST *hentbuf;
+{
+ const CGEN_INSN_LIST *ilist;
+
+ for (ilist = insns; ilist != NULL; ilist = ilist->next, ++ hentbuf)
+ {
+ unsigned int hash;
+
+ if (! (* cd->asm_hash_p) (ilist->insn))
+ continue;
+ hash = (* cd->asm_hash) (CGEN_INSN_MNEMONIC (ilist->insn));
+ hentbuf->next = htable[hash];
+ hentbuf->insn = ilist->insn;
+ htable[hash] = hentbuf;
+ }
+
+ return hentbuf;
+}
+
+/* Build the assembler instruction hash table. */
+
+static void
+build_asm_hash_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ int count = cgen_insn_count (cd) + cgen_macro_insn_count (cd);
+ CGEN_INSN_TABLE *insn_table = &cd->insn_table;
+ CGEN_INSN_TABLE *macro_insn_table = &cd->macro_insn_table;
+ unsigned int hash_size = cd->asm_hash_size;
+ CGEN_INSN_LIST *hash_entry_buf;
+ CGEN_INSN_LIST **asm_hash_table;
+ CGEN_INSN_LIST *asm_hash_table_entries;
+
+ /* The space allocated for the hash table consists of two parts:
+ the hash table and the hash lists. */
+
+ asm_hash_table = (CGEN_INSN_LIST **)
+ xmalloc (hash_size * sizeof (CGEN_INSN_LIST *));
+ memset (asm_hash_table, 0, hash_size * sizeof (CGEN_INSN_LIST *));
+ asm_hash_table_entries = hash_entry_buf = (CGEN_INSN_LIST *)
+ xmalloc (count * sizeof (CGEN_INSN_LIST));
+
+ /* Add compiled in insns.
+ Don't include the first one as it is a reserved entry. */
+ /* ??? It was the end of all hash chains, and also the special
+ "invalid insn" marker. May be able to do it differently now. */
+
+ hash_entry_buf = hash_insn_array (cd,
+ insn_table->init_entries + 1,
+ insn_table->num_init_entries - 1,
+ insn_table->entry_size,
+ asm_hash_table, hash_entry_buf);
+
+ /* Add compiled in macro-insns. */
+
+ hash_entry_buf = hash_insn_array (cd, macro_insn_table->init_entries,
+ macro_insn_table->num_init_entries,
+ macro_insn_table->entry_size,
+ asm_hash_table, hash_entry_buf);
+
+ /* Add runtime added insns.
+ Later added insns will be prefered over earlier ones. */
+
+ hash_entry_buf = hash_insn_list (cd, insn_table->new_entries,
+ asm_hash_table, hash_entry_buf);
+
+ /* Add runtime added macro-insns. */
+
+ hash_insn_list (cd, macro_insn_table->new_entries,
+ asm_hash_table, hash_entry_buf);
+
+ cd->asm_hash_table = asm_hash_table;
+ cd->asm_hash_table_entries = asm_hash_table_entries;
+}
+
+/* Return the first entry in the hash list for INSN. */
+
+CGEN_INSN_LIST *
+cgen_asm_lookup_insn (cd, insn)
+ CGEN_CPU_DESC cd;
+ const char *insn;
+{
+ unsigned int hash;
+
+ if (cd->asm_hash_table == NULL)
+ build_asm_hash_table (cd);
+
+ hash = (* cd->asm_hash) (insn);
+ return cd->asm_hash_table[hash];
+}
+
+/* Keyword parser.
+ The result is NULL upon success or an error message.
+ If successful, *STRP is updated to point passed the keyword.
+
+ ??? At present we have a static notion of how to pick out a keyword.
+ Later we can allow a target to customize this if necessary [say by
+ recording something in the keyword table]. */
+
+const char *
+cgen_parse_keyword (cd, strp, keyword_table, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ CGEN_KEYWORD *keyword_table;
+ long *valuep;
+{
+ const CGEN_KEYWORD_ENTRY *ke;
+ char buf[256];
+ const char *p,*start;
+
+ p = start = *strp;
+
+ /* Allow any first character.
+ Note that this allows recognizing ",a" for the annul flag in sparc
+ even though "," is subsequently not a valid keyword char. */
+ if (*p)
+ ++p;
+
+ /* Now allow letters, digits, and _. */
+ while (((p - start) < (int) sizeof (buf))
+ && (isalnum ((unsigned char) *p) || *p == '_'))
+ ++p;
+
+ if (p - start >= (int) sizeof (buf))
+ return _("unrecognized keyword/register name");
+
+ memcpy (buf, start, p - start);
+ buf[p - start] = 0;
+
+ ke = cgen_keyword_lookup_name (keyword_table, buf);
+
+ if (ke != NULL)
+ {
+ *valuep = ke->value;
+ /* Don't advance pointer if we recognized the null keyword. */
+ if (ke->name[0] != 0)
+ *strp = p;
+ return NULL;
+ }
+
+ return "unrecognized keyword/register name";
+}
+
+/* Parse a small signed integer parser.
+ ??? VALUEP is not a bfd_vma * on purpose, though this is confusing.
+ Note that if the caller expects a bfd_vma result, it should call
+ cgen_parse_address. */
+
+const char *
+cgen_parse_signed_integer (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ long *valuep;
+{
+ bfd_vma value;
+ enum cgen_parse_operand_result result;
+ const char *errmsg;
+
+ errmsg = (* cd->parse_operand_fn)
+ (cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
+ &result, &value);
+ /* FIXME: Examine `result'. */
+ if (!errmsg)
+ *valuep = value;
+ return errmsg;
+}
+
+/* Parse a small unsigned integer parser.
+ ??? VALUEP is not a bfd_vma * on purpose, though this is confusing.
+ Note that if the caller expects a bfd_vma result, it should call
+ cgen_parse_address. */
+
+const char *
+cgen_parse_unsigned_integer (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ bfd_vma value;
+ enum cgen_parse_operand_result result;
+ const char *errmsg;
+
+ errmsg = (* cd->parse_operand_fn)
+ (cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
+ &result, &value);
+ /* FIXME: Examine `result'. */
+ if (!errmsg)
+ *valuep = value;
+ return errmsg;
+}
+
+/* Address parser. */
+
+const char *
+cgen_parse_address (cd, strp, opindex, opinfo, resultp, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ int opinfo;
+ enum cgen_parse_operand_result *resultp;
+ bfd_vma *valuep;
+{
+ bfd_vma value;
+ enum cgen_parse_operand_result result_type;
+ const char *errmsg;
+
+ errmsg = (* cd->parse_operand_fn)
+ (cd, CGEN_PARSE_OPERAND_ADDRESS, strp, opindex, opinfo,
+ &result_type, &value);
+ /* FIXME: Examine `result'. */
+ if (!errmsg)
+ {
+ if (resultp != NULL)
+ *resultp = result_type;
+ *valuep = value;
+ }
+ return errmsg;
+}
+
+/* Signed integer validation routine. */
+
+const char *
+cgen_validate_signed_integer (value, min, max)
+ long value, min, max;
+{
+ if (value < min || value > max)
+ {
+ static char buf[100];
+
+ /* xgettext:c-format */
+ sprintf (buf, _("operand out of range (%ld not between %ld and %ld)"),
+ value, min, max);
+ return buf;
+ }
+
+ return NULL;
+}
+
+/* Unsigned integer validation routine.
+ Supplying `min' here may seem unnecessary, but we also want to handle
+ cases where min != 0 (and max > LONG_MAX). */
+
+const char *
+cgen_validate_unsigned_integer (value, min, max)
+ unsigned long value, min, max;
+{
+ if (value < min || value > max)
+ {
+ static char buf[100];
+
+ /* xgettext:c-format */
+ sprintf (buf, _("operand out of range (%lu not between %lu and %lu)"),
+ value, min, max);
+ return buf;
+ }
+
+ return NULL;
+}
diff --git a/opcodes/cgen-dis.c b/opcodes/cgen-dis.c
new file mode 100644
index 00000000000..78b1cd90ed9
--- /dev/null
+++ b/opcodes/cgen-dis.c
@@ -0,0 +1,226 @@
+/* CGEN generic disassembler support code.
+
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "sysdep.h"
+#include <stdio.h>
+#include "ansidecl.h"
+#include "libiberty.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "opcode/cgen.h"
+
+/* Subroutine of build_dis_hash_table to add INSNS to the hash table.
+
+ COUNT is the number of elements in INSNS.
+ ENTSIZE is sizeof (CGEN_IBASE) for the target.
+ ??? No longer used but leave in for now.
+ HTABLE points to the hash table.
+ HENTBUF is a pointer to sufficiently large buffer of hash entries.
+ The result is a pointer to the next entry to use.
+
+ The table is scanned backwards as additions are made to the front of the
+ list and we want earlier ones to be prefered. */
+
+static CGEN_INSN_LIST *
+hash_insn_array (cd, insns, count, entsize, htable, hentbuf)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN * insns;
+ int count;
+ int entsize;
+ CGEN_INSN_LIST ** htable;
+ CGEN_INSN_LIST * hentbuf;
+{
+ int big_p = CGEN_CPU_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+ int i;
+
+ for (i = count - 1; i >= 0; --i, ++hentbuf)
+ {
+ unsigned int hash;
+ char buf [4];
+ unsigned long value;
+ const CGEN_INSN *insn = &insns[i];
+
+ if (! (* cd->dis_hash_p) (insn))
+ continue;
+
+ /* We don't know whether the target uses the buffer or the base insn
+ to hash on, so set both up. */
+
+ value = CGEN_INSN_BASE_VALUE (insn);
+ switch (CGEN_INSN_MASK_BITSIZE (insn))
+ {
+ case 8:
+ buf[0] = value;
+ break;
+ case 16:
+ if (big_p)
+ bfd_putb16 ((bfd_vma) value, buf);
+ else
+ bfd_putl16 ((bfd_vma) value, buf);
+ break;
+ case 32:
+ if (big_p)
+ bfd_putb32 ((bfd_vma) value, buf);
+ else
+ bfd_putl32 ((bfd_vma) value, buf);
+ break;
+ default:
+ abort ();
+ }
+
+ hash = (* cd->dis_hash) (buf, value);
+ hentbuf->next = htable[hash];
+ hentbuf->insn = insn;
+ htable[hash] = hentbuf;
+ }
+
+ return hentbuf;
+}
+
+/* Subroutine of build_dis_hash_table to add INSNS to the hash table.
+ This function is identical to hash_insn_array except the insns are
+ in a list. */
+
+static CGEN_INSN_LIST *
+hash_insn_list (cd, insns, htable, hentbuf)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN_LIST *insns;
+ CGEN_INSN_LIST **htable;
+ CGEN_INSN_LIST *hentbuf;
+{
+ int big_p = CGEN_CPU_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+ const CGEN_INSN_LIST *ilist;
+
+ for (ilist = insns; ilist != NULL; ilist = ilist->next, ++ hentbuf)
+ {
+ unsigned int hash;
+ char buf[4];
+ unsigned long value;
+
+ if (! (* cd->dis_hash_p) (ilist->insn))
+ continue;
+
+ /* We don't know whether the target uses the buffer or the base insn
+ to hash on, so set both up. */
+
+ value = CGEN_INSN_BASE_VALUE (ilist->insn);
+ switch (CGEN_INSN_MASK_BITSIZE (ilist->insn))
+ {
+ case 8:
+ buf[0] = value;
+ break;
+ case 16:
+ if (big_p)
+ bfd_putb16 ((bfd_vma) value, buf);
+ else
+ bfd_putl16 ((bfd_vma) value, buf);
+ break;
+ case 32:
+ if (big_p)
+ bfd_putb32 ((bfd_vma) value, buf);
+ else
+ bfd_putl32 ((bfd_vma) value, buf);
+ break;
+ default:
+ abort ();
+ }
+
+ hash = (* cd->dis_hash) (buf, value);
+ hentbuf->next = htable [hash];
+ hentbuf->insn = ilist->insn;
+ htable [hash] = hentbuf;
+ }
+
+ return hentbuf;
+}
+
+/* Build the disassembler instruction hash table. */
+
+static void
+build_dis_hash_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ int count = cgen_insn_count (cd) + cgen_macro_insn_count (cd);
+ CGEN_INSN_TABLE *insn_table = & cd->insn_table;
+ CGEN_INSN_TABLE *macro_insn_table = & cd->macro_insn_table;
+ unsigned int hash_size = cd->dis_hash_size;
+ CGEN_INSN_LIST *hash_entry_buf;
+ CGEN_INSN_LIST **dis_hash_table;
+ CGEN_INSN_LIST *dis_hash_table_entries;
+
+ /* The space allocated for the hash table consists of two parts:
+ the hash table and the hash lists. */
+
+ dis_hash_table = (CGEN_INSN_LIST **)
+ xmalloc (hash_size * sizeof (CGEN_INSN_LIST *));
+ memset (dis_hash_table, 0, hash_size * sizeof (CGEN_INSN_LIST *));
+ dis_hash_table_entries = hash_entry_buf = (CGEN_INSN_LIST *)
+ xmalloc (count * sizeof (CGEN_INSN_LIST));
+
+ /* Add compiled in insns.
+ Don't include the first one as it is a reserved entry. */
+ /* ??? It was the end of all hash chains, and also the special
+ "invalid insn" marker. May be able to do it differently now. */
+
+ hash_entry_buf = hash_insn_array (cd,
+ insn_table->init_entries + 1,
+ insn_table->num_init_entries - 1,
+ insn_table->entry_size,
+ dis_hash_table, hash_entry_buf);
+
+ /* Add compiled in macro-insns. */
+
+ hash_entry_buf = hash_insn_array (cd, macro_insn_table->init_entries,
+ macro_insn_table->num_init_entries,
+ macro_insn_table->entry_size,
+ dis_hash_table, hash_entry_buf);
+
+ /* Add runtime added insns.
+ Later added insns will be prefered over earlier ones. */
+
+ hash_entry_buf = hash_insn_list (cd, insn_table->new_entries,
+ dis_hash_table, hash_entry_buf);
+
+ /* Add runtime added macro-insns. */
+
+ hash_insn_list (cd, macro_insn_table->new_entries,
+ dis_hash_table, hash_entry_buf);
+
+ cd->dis_hash_table = dis_hash_table;
+ cd->dis_hash_table_entries = dis_hash_table_entries;
+}
+
+/* Return the first entry in the hash list for INSN. */
+
+CGEN_INSN_LIST *
+cgen_dis_lookup_insn (cd, buf, value)
+ CGEN_CPU_DESC cd;
+ const char * buf;
+ CGEN_INSN_INT value;
+{
+ unsigned int hash;
+
+ if (cd->dis_hash_table == NULL)
+ build_dis_hash_table (cd);
+
+ hash = (* cd->dis_hash) (buf, value);
+
+ return cd->dis_hash_table[hash];
+}
diff --git a/opcodes/cgen-opc.c b/opcodes/cgen-opc.c
new file mode 100644
index 00000000000..56840a6a6f9
--- /dev/null
+++ b/opcodes/cgen-opc.c
@@ -0,0 +1,597 @@
+/* CGEN generic opcode support.
+
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include "ansidecl.h"
+#include "libiberty.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "opcode/cgen.h"
+
+static unsigned int hash_keyword_name
+ PARAMS ((const CGEN_KEYWORD *, const char *, int));
+static unsigned int hash_keyword_value
+ PARAMS ((const CGEN_KEYWORD *, unsigned int));
+static void build_keyword_hash_tables
+ PARAMS ((CGEN_KEYWORD *));
+
+/* Return number of hash table entries to use for N elements. */
+#define KEYWORD_HASH_SIZE(n) ((n) <= 31 ? 17 : 31)
+
+/* Look up *NAMEP in the keyword table KT.
+ The result is the keyword entry or NULL if not found. */
+
+const CGEN_KEYWORD_ENTRY *
+cgen_keyword_lookup_name (kt, name)
+ CGEN_KEYWORD *kt;
+ const char *name;
+{
+ const CGEN_KEYWORD_ENTRY *ke;
+ const char *p,*n;
+
+ if (kt->name_hash_table == NULL)
+ build_keyword_hash_tables (kt);
+
+ ke = kt->name_hash_table[hash_keyword_name (kt, name, 0)];
+
+ /* We do case insensitive comparisons.
+ If that ever becomes a problem, add an attribute that denotes
+ "do case sensitive comparisons". */
+
+ while (ke != NULL)
+ {
+ n = name;
+ p = ke->name;
+
+ while (*p
+ && (*p == *n
+ || (isalpha ((unsigned char) *p)
+ && (tolower ((unsigned char) *p)
+ == tolower ((unsigned char) *n)))))
+ ++n, ++p;
+
+ if (!*p && !*n)
+ return ke;
+
+ ke = ke->next_name;
+ }
+
+ if (kt->null_entry)
+ return kt->null_entry;
+ return NULL;
+}
+
+/* Look up VALUE in the keyword table KT.
+ The result is the keyword entry or NULL if not found. */
+
+const CGEN_KEYWORD_ENTRY *
+cgen_keyword_lookup_value (kt, value)
+ CGEN_KEYWORD *kt;
+ int value;
+{
+ const CGEN_KEYWORD_ENTRY *ke;
+
+ if (kt->name_hash_table == NULL)
+ build_keyword_hash_tables (kt);
+
+ ke = kt->value_hash_table[hash_keyword_value (kt, value)];
+
+ while (ke != NULL)
+ {
+ if (value == ke->value)
+ return ke;
+ ke = ke->next_value;
+ }
+
+ return NULL;
+}
+
+/* Add an entry to a keyword table. */
+
+void
+cgen_keyword_add (kt, ke)
+ CGEN_KEYWORD *kt;
+ CGEN_KEYWORD_ENTRY *ke;
+{
+ unsigned int hash;
+
+ if (kt->name_hash_table == NULL)
+ build_keyword_hash_tables (kt);
+
+ hash = hash_keyword_name (kt, ke->name, 0);
+ ke->next_name = kt->name_hash_table[hash];
+ kt->name_hash_table[hash] = ke;
+
+ hash = hash_keyword_value (kt, ke->value);
+ ke->next_value = kt->value_hash_table[hash];
+ kt->value_hash_table[hash] = ke;
+
+ if (ke->name[0] == 0)
+ kt->null_entry = ke;
+}
+
+/* FIXME: Need function to return count of keywords. */
+
+/* Initialize a keyword table search.
+ SPEC is a specification of what to search for.
+ A value of NULL means to find every keyword.
+ Currently NULL is the only acceptable value [further specification
+ deferred].
+ The result is an opaque data item used to record the search status.
+ It is passed to each call to cgen_keyword_search_next. */
+
+CGEN_KEYWORD_SEARCH
+cgen_keyword_search_init (kt, spec)
+ CGEN_KEYWORD *kt;
+ const char *spec;
+{
+ CGEN_KEYWORD_SEARCH search;
+
+ /* FIXME: Need to specify format of PARAMS. */
+ if (spec != NULL)
+ abort ();
+
+ if (kt->name_hash_table == NULL)
+ build_keyword_hash_tables (kt);
+
+ search.table = kt;
+ search.spec = spec;
+ search.current_hash = 0;
+ search.current_entry = NULL;
+ return search;
+}
+
+/* Return the next keyword specified by SEARCH.
+ The result is the next entry or NULL if there are no more. */
+
+const CGEN_KEYWORD_ENTRY *
+cgen_keyword_search_next (search)
+ CGEN_KEYWORD_SEARCH *search;
+{
+ /* Has search finished? */
+ if (search->current_hash == search->table->hash_table_size)
+ return NULL;
+
+ /* Search in progress? */
+ if (search->current_entry != NULL
+ /* Anything left on this hash chain? */
+ && search->current_entry->next_name != NULL)
+ {
+ search->current_entry = search->current_entry->next_name;
+ return search->current_entry;
+ }
+
+ /* Move to next hash chain [unless we haven't started yet]. */
+ if (search->current_entry != NULL)
+ ++search->current_hash;
+
+ while (search->current_hash < search->table->hash_table_size)
+ {
+ search->current_entry = search->table->name_hash_table[search->current_hash];
+ if (search->current_entry != NULL)
+ return search->current_entry;
+ ++search->current_hash;
+ }
+
+ return NULL;
+}
+
+/* Return first entry in hash chain for NAME.
+ If CASE_SENSITIVE_P is non-zero, return a case sensitive hash. */
+
+static unsigned int
+hash_keyword_name (kt, name, case_sensitive_p)
+ const CGEN_KEYWORD *kt;
+ const char *name;
+ int case_sensitive_p;
+{
+ unsigned int hash;
+
+ if (case_sensitive_p)
+ for (hash = 0; *name; ++name)
+ hash = (hash * 97) + (unsigned char) *name;
+ else
+ for (hash = 0; *name; ++name)
+ hash = (hash * 97) + (unsigned char) tolower (*name);
+ return hash % kt->hash_table_size;
+}
+
+/* Return first entry in hash chain for VALUE. */
+
+static unsigned int
+hash_keyword_value (kt, value)
+ const CGEN_KEYWORD *kt;
+ unsigned int value;
+{
+ return value % kt->hash_table_size;
+}
+
+/* Build a keyword table's hash tables.
+ We probably needn't build the value hash table for the assembler when
+ we're using the disassembler, but we keep things simple. */
+
+static void
+build_keyword_hash_tables (kt)
+ CGEN_KEYWORD *kt;
+{
+ int i;
+ /* Use the number of compiled in entries as an estimate for the
+ typical sized table [not too many added at runtime]. */
+ unsigned int size = KEYWORD_HASH_SIZE (kt->num_init_entries);
+
+ kt->hash_table_size = size;
+ kt->name_hash_table = (CGEN_KEYWORD_ENTRY **)
+ xmalloc (size * sizeof (CGEN_KEYWORD_ENTRY *));
+ memset (kt->name_hash_table, 0, size * sizeof (CGEN_KEYWORD_ENTRY *));
+ kt->value_hash_table = (CGEN_KEYWORD_ENTRY **)
+ xmalloc (size * sizeof (CGEN_KEYWORD_ENTRY *));
+ memset (kt->value_hash_table, 0, size * sizeof (CGEN_KEYWORD_ENTRY *));
+
+ /* The table is scanned backwards as we want keywords appearing earlier to
+ be prefered over later ones. */
+ for (i = kt->num_init_entries - 1; i >= 0; --i)
+ cgen_keyword_add (kt, &kt->init_entries[i]);
+}
+
+/* Hardware support. */
+
+/* Lookup a hardware element by its name.
+ Returns NULL if NAME is not supported by the currently selected
+ mach/isa. */
+
+const CGEN_HW_ENTRY *
+cgen_hw_lookup_by_name (cd, name)
+ CGEN_CPU_DESC cd;
+ const char *name;
+{
+ int i;
+ const CGEN_HW_ENTRY **hw = cd->hw_table.entries;
+
+ for (i = 0; i < cd->hw_table.num_entries; ++i)
+ if (hw[i] && strcmp (name, hw[i]->name) == 0)
+ return hw[i];
+
+ return NULL;
+}
+
+/* Lookup a hardware element by its number.
+ Hardware elements are enumerated, however it may be possible to add some
+ at runtime, thus HWNUM is not an enum type but rather an int.
+ Returns NULL if HWNUM is not supported by the currently selected mach. */
+
+const CGEN_HW_ENTRY *
+cgen_hw_lookup_by_num (cd, hwnum)
+ CGEN_CPU_DESC cd;
+ int hwnum;
+{
+ int i;
+ const CGEN_HW_ENTRY **hw = cd->hw_table.entries;
+
+ /* ??? This can be speeded up. */
+ for (i = 0; i < cd->hw_table.num_entries; ++i)
+ if (hw[i] && hwnum == hw[i]->type)
+ return hw[i];
+
+ return NULL;
+}
+
+/* Operand support. */
+
+/* Lookup an operand by its name.
+ Returns NULL if NAME is not supported by the currently selected
+ mach/isa. */
+
+const CGEN_OPERAND *
+cgen_operand_lookup_by_name (cd, name)
+ CGEN_CPU_DESC cd;
+ const char *name;
+{
+ int i;
+ const CGEN_OPERAND **op = cd->operand_table.entries;
+
+ for (i = 0; i < cd->operand_table.num_entries; ++i)
+ if (op[i] && strcmp (name, op[i]->name) == 0)
+ return op[i];
+
+ return NULL;
+}
+
+/* Lookup an operand by its number.
+ Operands are enumerated, however it may be possible to add some
+ at runtime, thus OPNUM is not an enum type but rather an int.
+ Returns NULL if OPNUM is not supported by the currently selected
+ mach/isa. */
+
+const CGEN_OPERAND *
+cgen_operand_lookup_by_num (cd, opnum)
+ CGEN_CPU_DESC cd;
+ int opnum;
+{
+ return cd->operand_table.entries[opnum];
+}
+
+/* Instruction support. */
+
+/* Return number of instructions. This includes any added at runtime. */
+
+int
+cgen_insn_count (cd)
+ CGEN_CPU_DESC cd;
+{
+ int count = cd->insn_table.num_init_entries;
+ CGEN_INSN_LIST *rt_insns = cd->insn_table.new_entries;
+
+ for ( ; rt_insns != NULL; rt_insns = rt_insns->next)
+ ++count;
+
+ return count;
+}
+
+/* Return number of macro-instructions.
+ This includes any added at runtime. */
+
+int
+cgen_macro_insn_count (cd)
+ CGEN_CPU_DESC cd;
+{
+ int count = cd->macro_insn_table.num_init_entries;
+ CGEN_INSN_LIST *rt_insns = cd->macro_insn_table.new_entries;
+
+ for ( ; rt_insns != NULL; rt_insns = rt_insns->next)
+ ++count;
+
+ return count;
+}
+
+/* Cover function to read and properly byteswap an insn value. */
+
+CGEN_INSN_INT
+cgen_get_insn_value (cd, buf, length)
+ CGEN_CPU_DESC cd;
+ unsigned char *buf;
+ int length;
+{
+ CGEN_INSN_INT value;
+
+ switch (length)
+ {
+ case 8:
+ value = *buf;
+ break;
+ case 16:
+ if (cd->insn_endian == CGEN_ENDIAN_BIG)
+ value = bfd_getb16 (buf);
+ else
+ value = bfd_getl16 (buf);
+ break;
+ case 32:
+ if (cd->insn_endian == CGEN_ENDIAN_BIG)
+ value = bfd_getb32 (buf);
+ else
+ value = bfd_getl32 (buf);
+ break;
+ default:
+ abort ();
+ }
+
+ return value;
+}
+
+/* Cover function to store an insn value properly byteswapped. */
+
+void
+cgen_put_insn_value (cd, buf, length, value)
+ CGEN_CPU_DESC cd;
+ unsigned char *buf;
+ int length;
+ CGEN_INSN_INT value;
+{
+ switch (length)
+ {
+ case 8:
+ buf[0] = value;
+ break;
+ case 16:
+ if (cd->insn_endian == CGEN_ENDIAN_BIG)
+ bfd_putb16 (value, buf);
+ else
+ bfd_putl16 (value, buf);
+ break;
+ case 32:
+ if (cd->insn_endian == CGEN_ENDIAN_BIG)
+ bfd_putb32 (value, buf);
+ else
+ bfd_putl32 (value, buf);
+ break;
+ default:
+ abort ();
+ }
+}
+
+/* Look up instruction INSN_*_VALUE and extract its fields.
+ INSN_INT_VALUE is used if CGEN_INT_INSN_P.
+ Otherwise INSN_BYTES_VALUE is used.
+ INSN, if non-null, is the insn table entry.
+ Otherwise INSN_*_VALUE is examined to compute it.
+ LENGTH is the bit length of INSN_*_VALUE if known, otherwise 0.
+ 0 is only valid if `insn == NULL && ! CGEN_INT_INSN_P'.
+ If INSN != NULL, LENGTH must be valid.
+ ALIAS_P is non-zero if alias insns are to be included in the search.
+
+ The result is a pointer to the insn table entry, or NULL if the instruction
+ wasn't recognized. */
+
+/* ??? Will need to be revisited for VLIW architectures. */
+
+const CGEN_INSN *
+cgen_lookup_insn (cd, insn, insn_int_value, insn_bytes_value, length, fields,
+ alias_p)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ CGEN_INSN_INT insn_int_value;
+ /* ??? CGEN_INSN_BYTES would be a nice type name to use here. */
+ unsigned char *insn_bytes_value;
+ int length;
+ CGEN_FIELDS *fields;
+ int alias_p;
+{
+ unsigned char *buf;
+ CGEN_INSN_INT base_insn;
+ CGEN_EXTRACT_INFO ex_info;
+ CGEN_EXTRACT_INFO *info;
+
+ if (cd->int_insn_p)
+ {
+ info = NULL;
+ buf = (unsigned char *) alloca (cd->max_insn_bitsize / 8);
+ cgen_put_insn_value (cd, buf, length, insn_int_value);
+ base_insn = insn_int_value;
+ }
+ else
+ {
+ info = &ex_info;
+ ex_info.dis_info = NULL;
+ ex_info.insn_bytes = insn_bytes_value;
+ ex_info.valid = -1;
+ buf = insn_bytes_value;
+ base_insn = cgen_get_insn_value (cd, buf, length);
+ }
+
+ if (!insn)
+ {
+ const CGEN_INSN_LIST *insn_list;
+
+ /* The instructions are stored in hash lists.
+ Pick the first one and keep trying until we find the right one. */
+
+ insn_list = cgen_dis_lookup_insn (cd, buf, base_insn);
+ while (insn_list != NULL)
+ {
+ insn = insn_list->insn;
+
+ if (alias_p
+ /* FIXME: Ensure ALIAS attribute always has same index. */
+ || ! CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_ALIAS))
+ {
+ /* Basic bit mask must be correct. */
+ /* ??? May wish to allow target to defer this check until the
+ extract handler. */
+ if ((base_insn & CGEN_INSN_BASE_MASK (insn))
+ == CGEN_INSN_BASE_VALUE (insn))
+ {
+ /* ??? 0 is passed for `pc' */
+ int elength = CGEN_EXTRACT_FN (cd, insn)
+ (cd, insn, info, base_insn, fields, (bfd_vma) 0);
+ if (elength > 0)
+ {
+ /* sanity check */
+ if (length != 0 && length != elength)
+ abort ();
+ return insn;
+ }
+ }
+ }
+
+ insn_list = insn_list->next;
+ }
+ }
+ else
+ {
+ /* Sanity check: can't pass an alias insn if ! alias_p. */
+ if (! alias_p
+ && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_ALIAS))
+ abort ();
+ /* Sanity check: length must be correct. */
+ if (length != CGEN_INSN_BITSIZE (insn))
+ abort ();
+
+ /* ??? 0 is passed for `pc' */
+ length = CGEN_EXTRACT_FN (cd, insn)
+ (cd, insn, info, base_insn, fields, (bfd_vma) 0);
+ /* Sanity check: must succeed.
+ Could relax this later if it ever proves useful. */
+ if (length == 0)
+ abort ();
+ return insn;
+ }
+
+ return NULL;
+}
+
+/* Fill in the operand instances used by INSN whose operands are FIELDS.
+ INDICES is a pointer to a buffer of MAX_OPERAND_INSTANCES ints to be filled
+ in. */
+
+void
+cgen_get_insn_operands (cd, insn, fields, indices)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ const CGEN_FIELDS *fields;
+ int *indices;
+{
+ const CGEN_OPINST *opinst;
+ int i;
+
+ if (insn->opinst == NULL)
+ abort ();
+ for (i = 0, opinst = insn->opinst; opinst->type != CGEN_OPINST_END; ++i, ++opinst)
+ {
+ enum cgen_operand_type op_type = opinst->op_type;
+ if (op_type == CGEN_OPERAND_NIL)
+ indices[i] = opinst->index;
+ else
+ indices[i] = (*cd->get_int_operand) (cd, op_type, fields);
+ }
+}
+
+/* Cover function to cgen_get_insn_operands when either INSN or FIELDS
+ isn't known.
+ The INSN, INSN_*_VALUE, and LENGTH arguments are passed to
+ cgen_lookup_insn unchanged.
+ INSN_INT_VALUE is used if CGEN_INT_INSN_P.
+ Otherwise INSN_BYTES_VALUE is used.
+
+ The result is the insn table entry or NULL if the instruction wasn't
+ recognized. */
+
+const CGEN_INSN *
+cgen_lookup_get_insn_operands (cd, insn, insn_int_value, insn_bytes_value,
+ length, indices, fields)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ CGEN_INSN_INT insn_int_value;
+ /* ??? CGEN_INSN_BYTES would be a nice type name to use here. */
+ unsigned char *insn_bytes_value;
+ int length;
+ int *indices;
+ CGEN_FIELDS *fields;
+{
+ /* Pass non-zero for ALIAS_P only if INSN != NULL.
+ If INSN == NULL, we want a real insn. */
+ insn = cgen_lookup_insn (cd, insn, insn_int_value, insn_bytes_value,
+ length, fields, insn != NULL);
+ if (! insn)
+ return NULL;
+
+ cgen_get_insn_operands (cd, insn, fields, indices);
+ return insn;
+}
diff --git a/opcodes/config.in b/opcodes/config.in
new file mode 100644
index 00000000000..c60a32101ae
--- /dev/null
+++ b/opcodes/config.in
@@ -0,0 +1,135 @@
+/* config.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if using alloca.c. */
+#undef C_ALLOCA
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+ This function is required for alloca.c support on those systems. */
+#undef CRAY_STACKSEG_END
+
+/* Define if you have alloca, as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+#undef HAVE_ALLOCA_H
+
+/* Define if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#undef off_t
+
+/* Define if you need to in order for stat and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#undef STACK_DIRECTION
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if you have the __argz_count function. */
+#undef HAVE___ARGZ_COUNT
+
+/* Define if you have the __argz_next function. */
+#undef HAVE___ARGZ_NEXT
+
+/* Define if you have the __argz_stringify function. */
+#undef HAVE___ARGZ_STRINGIFY
+
+/* Define if you have the dcgettext function. */
+#undef HAVE_DCGETTEXT
+
+/* Define if you have the getcwd function. */
+#undef HAVE_GETCWD
+
+/* Define if you have the getpagesize function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the munmap function. */
+#undef HAVE_MUNMAP
+
+/* Define if you have the putenv function. */
+#undef HAVE_PUTENV
+
+/* Define if you have the setenv function. */
+#undef HAVE_SETENV
+
+/* Define if you have the setlocale function. */
+#undef HAVE_SETLOCALE
+
+/* Define if you have the stpcpy function. */
+#undef HAVE_STPCPY
+
+/* Define if you have the strcasecmp function. */
+#undef HAVE_STRCASECMP
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the <argz.h> header file. */
+#undef HAVE_ARGZ_H
+
+/* Define if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define if you have the <nl_types.h> header file. */
+#undef HAVE_NL_TYPES_H
+
+/* Define if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+
+/* Define if you have the stpcpy function */
+#undef HAVE_STPCPY
+
+/* Define if your locale.h file contains LC_MESSAGES. */
+#undef HAVE_LC_MESSAGES
+
+/* Define to 1 if NLS is requested */
+#undef ENABLE_NLS
+
+/* Define as 1 if you have gettext and don't want to use GNU gettext. */
+#undef HAVE_GETTEXT
+
diff --git a/opcodes/configure b/opcodes/configure
new file mode 100755
index 00000000000..71cff129f61
--- /dev/null
+++ b/opcodes/configure
@@ -0,0 +1,4754 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --enable-shared[=PKGS] build shared libraries [default=no]"
+ac_help="$ac_help
+ --enable-static[=PKGS] build static libraries [default=yes]"
+ac_help="$ac_help
+ --enable-fast-install[=PKGS] optimize for fast installation [default=yes]"
+ac_help="$ac_help
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]"
+ac_help="$ac_help
+ --disable-libtool-lock force libtool not to do file locking"
+ac_help="$ac_help
+ --enable-targets alternative target configurations"
+ac_help="$ac_help
+ --enable-commonbfdlib build shared BFD/opcodes/libiberty library"
+ac_help="$ac_help
+ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer"
+ac_help="$ac_help
+ --disable-nls do not use Native Language Support"
+ac_help="$ac_help
+ --with-included-gettext use the GNU gettext library included here"
+ac_help="$ac_help
+ --enable-cgen-maint[=dir] build cgen generated files"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=z8k-dis.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+# same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:596: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+echo "configure:617: checking target system type" >&5
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+ case $nonopt in
+ NONE) target_alias=$host_alias ;;
+ *) target_alias=$nonopt ;;
+ esac ;;
+esac
+
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:635: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:660: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:690: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:741: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:773: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 784 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:815: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:820: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:829: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:848: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:880: checking for POSIXized ISC" >&5
+if test -d /etc/conf/kconfig.d &&
+ grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+ echo "$ac_t""yes" 1>&6
+ ISC=yes # If later tests want to check for ISC.
+ cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+ if test "$GCC" = yes; then
+ CC="$CC -posix"
+ else
+ CC="$CC -Xp"
+ fi
+else
+ echo "$ac_t""no" 1>&6
+ ISC=
+fi
+
+
+# We currently only use the version number for the name of any shared
+# library. For user convenience, we always use the same version
+# number that BFD is using.
+BFD_VERSION=`grep INIT_AUTOMAKE ${srcdir}/../bfd/configure.in | sed -n -e 's/[ ]//g' -e 's/^.*,\(.*\)).*$/\1/p'`
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:918: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
+echo "configure:971: checking whether build environment is sane" >&5
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "$*" != "X $srcdir/configure conftestfile" \
+ && test "$*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { echo "configure: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" 1>&2; exit 1; }
+ fi
+
+ test "$2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ { echo "configure: error: newly created file is older than distributed files!
+Check your system clock" 1>&2; exit 1; }
+fi
+rm -f conftest*
+echo "$ac_t""yes" 1>&6
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:1028: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+PACKAGE=opcodes
+
+VERSION=${BFD_VERSION}
+
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
+fi
+cat >> confdefs.h <<EOF
+#define PACKAGE "$PACKAGE"
+EOF
+
+cat >> confdefs.h <<EOF
+#define VERSION "$VERSION"
+EOF
+
+
+
+missing_dir=`cd $ac_aux_dir && pwd`
+echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
+echo "configure:1074: checking for working aclocal" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+ ACLOCAL=aclocal
+ echo "$ac_t""found" 1>&6
+else
+ ACLOCAL="$missing_dir/missing aclocal"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
+echo "configure:1087: checking for working autoconf" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoconf --version) < /dev/null > /dev/null 2>&1; then
+ AUTOCONF=autoconf
+ echo "$ac_t""found" 1>&6
+else
+ AUTOCONF="$missing_dir/missing autoconf"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working automake""... $ac_c" 1>&6
+echo "configure:1100: checking for working automake" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (automake --version) < /dev/null > /dev/null 2>&1; then
+ AUTOMAKE=automake
+ echo "$ac_t""found" 1>&6
+else
+ AUTOMAKE="$missing_dir/missing automake"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
+echo "configure:1113: checking for working autoheader" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoheader --version) < /dev/null > /dev/null 2>&1; then
+ AUTOHEADER=autoheader
+ echo "$ac_t""found" 1>&6
+else
+ AUTOHEADER="$missing_dir/missing autoheader"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
+echo "configure:1126: checking for working makeinfo" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
+ MAKEINFO=makeinfo
+ echo "$ac_t""found" 1>&6
+else
+ MAKEINFO="$missing_dir/missing makeinfo"
+ echo "$ac_t""missing" 1>&6
+fi
+
+
+
+if test $host != $build; then
+ ac_tool_prefix=${host_alias}-
+else
+ ac_tool_prefix=
+fi
+
+# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1149: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
+fi
+fi
+AR="$ac_cv_prog_AR"
+if test -n "$AR"; then
+ echo "$ac_t""$AR" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1181: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_RANLIB"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1213: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ RANLIB=":"
+fi
+fi
+
+
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+ enableval="$enable_shared"
+ p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac
+else
+ enable_shared=no
+fi
+
+
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+ enableval="$enable_static"
+ p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac
+else
+ enable_static=yes
+fi
+
+# Check whether --enable-fast-install or --disable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+ enableval="$enable_fast_install"
+ p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+ for pkg in $enableval; do
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac
+else
+ enable_fast_install=yes
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1319: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
+echo "configure:1358: checking for ld used by GCC" >&5
+ ac_prog=`($CC -print-prog-name=ld) 2>&5`
+ case "$ac_prog" in
+ # Accept absolute paths.
+ /* | [A-Za-z]:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+echo "configure:1382: checking for GNU ld" >&5
+else
+ echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+echo "configure:1385: checking for non-GNU ld" >&5
+fi
+if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog"; then
+ ac_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+ test "$with_gnu_ld" != no && break
+ else
+ test "$with_gnu_ld" != yes && break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+ echo "$ac_t""$LD" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
+
+echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
+echo "configure:1421: checking if the linker ($LD) is GNU ld" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+ ac_cv_prog_gnu_ld=yes
+else
+ ac_cv_prog_gnu_ld=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
+
+
+echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+echo "configure:1437: checking for BSD-compatible nm" >&5
+if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$NM"; then
+ # Let the user override the test.
+ ac_cv_path_NM="$NM"
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/nm; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -B"
+ break
+ elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+ ac_cv_path_NM="$ac_dir/nm -p"
+ break
+ else
+ ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi
+fi
+
+NM="$ac_cv_path_NM"
+echo "$ac_t""$NM" 1>&6
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6
+echo "configure:1475: checking command to parse $NM output" >&5
+if eval "test \"`echo '$''{'ac_cv_sys_global_symbol_pipe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # These are sane defaults that work on at least a few old systems.
+# {They come from Ultrix. What could be older than Ultrix?!! ;)}
+
+# Character class describing NM global symbol codes.
+ac_symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+ac_symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+ac_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Define system-specific variables.
+case "$host_os" in
+aix*)
+ ac_symcode='[BCDT]'
+ ;;
+cygwin* | mingw*)
+ ac_symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ ac_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+ ;;
+irix*)
+ ac_symcode='[BCDEGRST]'
+ ;;
+solaris*)
+ ac_symcode='[BDT]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+ ac_symcode='[ABCDGISTW]'
+fi
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+ ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* \($ac_symcode\) *\($ac_symprfx\)$ac_sympat$/$ac_symxfrm/p'"
+
+ # Check to see that the pipe works correctly.
+ ac_pipe_works=no
+ rm -f conftest.$ac_ext
+ cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func;return 0;}
+EOF
+
+ if { (eval echo configure:1538: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ # Now try to grab the symbols.
+ ac_nlist=conftest.nm
+
+ if { (eval echo configure:1542: \"$NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) 2>&5; } && test -s "$ac_nlist"; then
+
+ # Try sorting and uniquifying the output.
+ if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
+ mv -f "$ac_nlist"T "$ac_nlist"
+ else
+ rm -f "$ac_nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
+ if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
+ cat <<EOF > conftest.c
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+ # Now generate the symbol file.
+ eval "$ac_global_symbol_to_cdecl"' < "$ac_nlist" >> conftest.c'
+
+ cat <<EOF >> conftest.c
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+ sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
+ cat <<\EOF >> conftest.c
+ {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftestm.$ac_objext
+ ac_save_LIBS="$LIBS"
+ ac_save_CFLAGS="$CFLAGS"
+ LIBS="conftestm.$ac_objext"
+ CFLAGS="$CFLAGS$no_builtin_flag"
+ if { (eval echo configure:1594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ ac_pipe_works=yes
+ else
+ echo "configure: failed program was:" >&5
+ cat conftest.c >&5
+ fi
+ LIBS="$ac_save_LIBS"
+ CFLAGS="$ac_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $ac_nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $ac_nlist" >&5
+ fi
+ else
+ echo "cannot run $ac_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.c >&5
+ fi
+ rm -rf conftest*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$ac_pipe_works" = yes; then
+ if test x"$ac_symprfx" = x"_"; then
+ ac_cv_sys_symbol_underscore=yes
+ else
+ ac_cv_sys_symbol_underscore=no
+ fi
+ break
+ else
+ ac_cv_sys_global_symbol_pipe=
+ fi
+done
+
+fi
+
+
+ac_result=yes
+if test -z "$ac_cv_sys_global_symbol_pipe"; then
+ ac_result=no
+fi
+echo "$ac_t""$ac_result" 1>&6
+
+echo $ac_n "checking for _ prefix in compiled symbols""... $ac_c" 1>&6
+echo "configure:1640: checking for _ prefix in compiled symbols" >&5
+if eval "test \"`echo '$''{'ac_cv_sys_symbol_underscore'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_sys_symbol_underscore=no
+cat > conftest.$ac_ext <<EOF
+void nm_test_func(){}
+int main(){nm_test_func;return 0;}
+EOF
+if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ # Now try to grab the symbols.
+ ac_nlist=conftest.nm
+ if { (eval echo configure:1652: \"$NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) 2>&5; } && test -s "$ac_nlist"; then
+ # See whether the symbols have a leading underscore.
+ if egrep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
+ ac_cv_sys_symbol_underscore=yes
+ else
+ if egrep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
+ :
+ else
+ echo "configure: cannot find nm_test_func in $ac_nlist" >&5
+ fi
+ fi
+ else
+ echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&5
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.c >&5
+fi
+rm -rf conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_sys_symbol_underscore" 1>&6
+USE_SYMBOL_UNDERSCORE=${ac_cv_sys_symbol_underscore=no}
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1678: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$lt_dlopen" = yes && libtool_flags="$libtool_flags --enable-dlopen"
+test "$silent" = yes && libtool_flags="$libtool_flags --silent"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$host" in
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '#line 1714 "configure"' > conftest.$ac_ext
+ if { (eval echo configure:1715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
+echo "configure:1736: checking whether the C compiler needs -belf" >&5
+if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1741 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ lt_cv_cc_needs_belf=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ lt_cv_cc_needs_belf=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+
+*-*-cygwin*)
+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1771: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+DLLTOOL="$ac_cv_prog_DLLTOOL"
+if test -n "$DLLTOOL"; then
+ echo "$ac_t""$DLLTOOL" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_DLLTOOL"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1803: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_DLLTOOL="dlltool"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_DLLTOOL" && ac_cv_prog_DLLTOOL="false"
+fi
+fi
+DLLTOOL="$ac_cv_prog_DLLTOOL"
+if test -n "$DLLTOOL"; then
+ echo "$ac_t""$DLLTOOL" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ DLLTOOL="false"
+fi
+fi
+
+# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1838: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AS"; then
+ ac_cv_prog_AS="$AS" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AS="${ac_tool_prefix}as"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+AS="$ac_cv_prog_AS"
+if test -n "$AS"; then
+ echo "$ac_t""$AS" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_AS"; then
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "as", so it can be a program name with args.
+set dummy as; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1870: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AS"; then
+ ac_cv_prog_AS="$AS" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AS="as"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_AS" && ac_cv_prog_AS="false"
+fi
+fi
+AS="$ac_cv_prog_AS"
+if test -n "$AS"; then
+ echo "$ac_t""$AS" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ AS="false"
+fi
+fi
+
+
+ ;;
+
+esac
+
+# enable the --disable-libtool-lock switch
+
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+ enableval="$enable_libtool_lock"
+ need_locks=$enableval
+else
+ need_locks=yes
+fi
+
+
+if test x"$need_locks" = xno; then
+ libtool_flags="$libtool_flags --disable-lock"
+fi
+
+
+# Save cache, so that ltconfig can load it
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+
+# Actually configure libtool. ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
+DLLTOOL="$DLLTOOL" AS="$AS" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
+
+# Reload cache, that may have been modified by ltconfig
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+
+
+# Check whether --enable-targets or --disable-targets was given.
+if test "${enable_targets+set}" = set; then
+ enableval="$enable_targets"
+ case "${enableval}" in
+ yes | "") { echo "configure: error: enable-targets option must specify target names or 'all'" 1>&2; exit 1; }
+ ;;
+ no) enable_targets= ;;
+ *) enable_targets=$enableval ;;
+esac
+fi
+# Check whether --enable-commonbfdlib or --disable-commonbfdlib was given.
+if test "${enable_commonbfdlib+set}" = set; then
+ enableval="$enable_commonbfdlib"
+ case "${enableval}" in
+ yes) commonbfdlib=true ;;
+ no) commonbfdlib=false ;;
+ *) { echo "configure: error: bad value ${enableval} for opcodes commonbfdlib option" 1>&2; exit 1; } ;;
+esac
+fi
+
+
+
+
+
+if test -z "$target" ; then
+ { echo "configure: error: Unrecognized target system type; please check config.sub." 1>&2; exit 1; }
+fi
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+
+echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
+echo "configure:2049: checking whether to enable maintainer-specific portions of Makefiles" >&5
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ USE_MAINTAINER_MODE=$enableval
+else
+ USE_MAINTAINER_MODE=no
+fi
+
+ echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6
+
+
+if test $USE_MAINTAINER_MODE = yes; then
+ MAINTAINER_MODE_TRUE=
+ MAINTAINER_MODE_FALSE='#'
+else
+ MAINTAINER_MODE_TRUE='#'
+ MAINTAINER_MODE_FALSE=
+fi
+ MAINT=$MAINTAINER_MODE_TRUE
+
+
+echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
+echo "configure:2072: checking for Cygwin environment" >&5
+if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2077 "configure"
+#include "confdefs.h"
+
+int main() {
+
+#ifndef __CYGWIN__
+#define __CYGWIN__ __CYGWIN32__
+#endif
+return __CYGWIN__;
+; return 0; }
+EOF
+if { (eval echo configure:2088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_cygwin=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_cygwin=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_cygwin" 1>&6
+CYGWIN=
+test "$ac_cv_cygwin" = yes && CYGWIN=yes
+echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
+echo "configure:2105: checking for mingw32 environment" >&5
+if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2110 "configure"
+#include "confdefs.h"
+
+int main() {
+return __MINGW32__;
+; return 0; }
+EOF
+if { (eval echo configure:2117: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_mingw32=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_mingw32=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_mingw32" 1>&6
+MINGW32=
+test "$ac_cv_mingw32" = yes && MINGW32=yes
+
+
+echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
+echo "configure:2136: checking for executable suffix" >&5
+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
+ ac_cv_exeext=.exe
+else
+ rm -f conftest*
+ echo 'int main () { return 0; }' > conftest.$ac_ext
+ ac_cv_exeext=
+ if { (eval echo configure:2146: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+ for file in conftest.*; do
+ case $file in
+ *.c | *.o | *.obj | *.ilk | *.pdb) ;;
+ *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+ esac
+ done
+ else
+ { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ rm -f conftest*
+ test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
+fi
+fi
+
+EXEEXT=""
+test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
+echo "$ac_t""${ac_cv_exeext}" 1>&6
+ac_exeext=$EXEEXT
+
+
+# host-specific stuff:
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2172: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2202: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2253: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:2285: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 2296 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:2301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:2327: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:2332: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:2360: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+
+ALL_LINGUAS=
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:2394: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 2409 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2415: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 2426 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 2443 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2449: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:2474: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2479 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2487: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 2504 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 2522 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2543 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:2554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:2578: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2583 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:2632: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:2653: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat > conftest.$ac_ext <<EOF
+#line 2660 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:2667: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+ inline | yes) ;;
+ no) cat >> confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+ *) cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+echo "configure:2693: checking for off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2698 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+echo "configure:2726: checking for size_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2731 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments. Useless!
+echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
+echo "configure:2761: checking for working alloca.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2766 "configure"
+#include "confdefs.h"
+#include <alloca.h>
+int main() {
+char *p = alloca(2 * sizeof(int));
+; return 0; }
+EOF
+if { (eval echo configure:2773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_header_alloca_h=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_alloca_h=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
+if test $ac_cv_header_alloca_h = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA_H 1
+EOF
+
+fi
+
+echo $ac_n "checking for alloca""... $ac_c" 1>&6
+echo "configure:2794: checking for alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2799 "configure"
+#include "confdefs.h"
+
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# else
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
+int main() {
+char *p = (char *) alloca(1);
+; return 0; }
+EOF
+if { (eval echo configure:2827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_func_alloca_works=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_func_alloca_works=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_func_alloca_works" 1>&6
+if test $ac_cv_func_alloca_works = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ALLOCA 1
+EOF
+
+fi
+
+if test $ac_cv_func_alloca_works = no; then
+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+ # that cause trouble. Some versions do not even contain alloca or
+ # contain a buggy version. If you still want to use their alloca,
+ # use ar to extract alloca.o from them instead of compiling alloca.c.
+ ALLOCA=alloca.${ac_objext}
+ cat >> confdefs.h <<\EOF
+#define C_ALLOCA 1
+EOF
+
+
+echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+echo "configure:2859: checking whether alloca needs Cray hooks" >&5
+if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2864 "configure"
+#include "confdefs.h"
+#if defined(CRAY) && ! defined(CRAY2)
+webecray
+#else
+wenotbecray
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "webecray" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_os_cray=yes
+else
+ rm -rf conftest*
+ ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_os_cray" 1>&6
+if test $ac_cv_os_cray = yes; then
+for ac_func in _getb67 GETB67 getb67; do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2889: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2894 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<EOF
+#define CRAY_STACKSEG_END $ac_func
+EOF
+
+ break
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+done
+fi
+
+echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
+echo "configure:2944: checking stack direction for C alloca" >&5
+if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_c_stack_direction=0
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2952 "configure"
+#include "confdefs.h"
+find_stack_direction ()
+{
+ static char *addr = 0;
+ auto char dummy;
+ if (addr == 0)
+ {
+ addr = &dummy;
+ return find_stack_direction ();
+ }
+ else
+ return (&dummy > addr) ? 1 : -1;
+}
+main ()
+{
+ exit (find_stack_direction() < 0);
+}
+EOF
+if { (eval echo configure:2971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_stack_direction=1
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_stack_direction=-1
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_c_stack_direction" 1>&6
+cat >> confdefs.h <<EOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+EOF
+
+fi
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2996: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3001 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_func in getpagesize
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3035: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3040 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3063: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for working mmap""... $ac_c" 1>&6
+echo "configure:3088: checking for working mmap" >&5
+if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3096 "configure"
+#include "confdefs.h"
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the filesystem buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propogated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+#ifdef __cplusplus
+extern "C" { void *malloc(unsigned); }
+#else
+char *malloc();
+#endif
+
+int
+main()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmap", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file at a fixed address which
+ * already has something else allocated at it. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmap", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ data2 = malloc(2 * pagesize);
+ if (!data2)
+ exit(1);
+ data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ /*
+ * Finally, make sure that changes to the mapped area
+ * do not percolate back to the file as seen by read().
+ * (This is a bug on some variants of i386 svr4.0.)
+ */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit(1);
+ close(fd);
+ unlink("conftestmmap");
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:3236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_MMAP 1
+EOF
+
+fi
+
+
+ for ac_hdr in argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h values.h sys/param.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3264: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3269 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3274: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ for ac_func in getcwd munmap putenv setenv setlocale strchr strcasecmp \
+__argz_count __argz_stringify __argz_next
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3304: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3309 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ for ac_func in stpcpy
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3361: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3366 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_STPCPY 1
+EOF
+
+ fi
+
+ if test $ac_cv_header_locale_h = yes; then
+ echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
+echo "configure:3423: checking for LC_MESSAGES" >&5
+if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3428 "configure"
+#include "confdefs.h"
+#include <locale.h>
+int main() {
+return LC_MESSAGES
+; return 0; }
+EOF
+if { (eval echo configure:3435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ am_cv_val_LC_MESSAGES=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ am_cv_val_LC_MESSAGES=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$am_cv_val_LC_MESSAGES" 1>&6
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LC_MESSAGES 1
+EOF
+
+ fi
+ fi
+ echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6
+echo "configure:3456: checking whether NLS is requested" >&5
+ # Check whether --enable-nls or --disable-nls was given.
+if test "${enable_nls+set}" = set; then
+ enableval="$enable_nls"
+ USE_NLS=$enableval
+else
+ USE_NLS=yes
+fi
+
+ echo "$ac_t""$USE_NLS" 1>&6
+
+
+ USE_INCLUDED_LIBINTL=no
+
+ if test "$USE_NLS" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define ENABLE_NLS 1
+EOF
+
+ echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6
+echo "configure:3476: checking whether included gettext is requested" >&5
+ # Check whether --with-included-gettext or --without-included-gettext was given.
+if test "${with_included_gettext+set}" = set; then
+ withval="$with_included_gettext"
+ nls_cv_force_use_gnu_gettext=$withval
+else
+ nls_cv_force_use_gnu_gettext=no
+fi
+
+ echo "$ac_t""$nls_cv_force_use_gnu_gettext" 1>&6
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+ CATOBJEXT=NONE
+
+ ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for libintl.h""... $ac_c" 1>&6
+echo "configure:3495: checking for libintl.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3500 "configure"
+#include "confdefs.h"
+#include <libintl.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3505: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6
+echo "configure:3522: checking for gettext in libc" >&5
+if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3527 "configure"
+#include "confdefs.h"
+#include <libintl.h>
+int main() {
+return (int) gettext ("")
+; return 0; }
+EOF
+if { (eval echo configure:3534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ gt_cv_func_gettext_libc=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ gt_cv_func_gettext_libc=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6
+
+ if test "$gt_cv_func_gettext_libc" != "yes"; then
+ echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
+echo "configure:3550: checking for bindtextdomain in -lintl" >&5
+ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lintl $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3558 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char bindtextdomain();
+
+int main() {
+bindtextdomain()
+; return 0; }
+EOF
+if { (eval echo configure:3569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
+echo "configure:3585: checking for gettext in libintl" >&5
+if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3590 "configure"
+#include "confdefs.h"
+
+int main() {
+return (int) gettext ("")
+; return 0; }
+EOF
+if { (eval echo configure:3597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ gt_cv_func_gettext_libintl=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ gt_cv_func_gettext_libintl=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$gt_cv_func_gettext_libintl" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ fi
+
+ if test "$gt_cv_func_gettext_libc" = "yes" \
+ || test "$gt_cv_func_gettext_libintl" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_GETTEXT 1
+EOF
+
+ # Extract the first word of "msgfmt", so it can be a program name with args.
+set dummy msgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3625: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$MSGFMT" in
+ /*)
+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then
+ ac_cv_path_MSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="no"
+ ;;
+esac
+fi
+MSGFMT="$ac_cv_path_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ if test "$MSGFMT" != "no"; then
+ for ac_func in dcgettext
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3659: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3664 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ # Extract the first word of "gmsgfmt", so it can be a program name with args.
+set dummy gmsgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3714: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GMSGFMT" in
+ /*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GMSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"
+ ;;
+esac
+fi
+GMSGFMT="$ac_cv_path_GMSGFMT"
+if test -n "$GMSGFMT"; then
+ echo "$ac_t""$GMSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "xgettext", so it can be a program name with args.
+set dummy xgettext; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3750: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$XGETTEXT" in
+ /*)
+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then
+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"
+ ;;
+esac
+fi
+XGETTEXT="$ac_cv_path_XGETTEXT"
+if test -n "$XGETTEXT"; then
+ echo "$ac_t""$XGETTEXT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ cat > conftest.$ac_ext <<EOF
+#line 3782 "configure"
+#include "confdefs.h"
+
+int main() {
+extern int _nl_msg_cat_cntr;
+ return _nl_msg_cat_cntr
+; return 0; }
+EOF
+if { (eval echo configure:3790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ CATOBJEXT=.gmo
+ DATADIRNAME=share
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CATOBJEXT=.mo
+ DATADIRNAME=lib
+fi
+rm -f conftest*
+ INSTOBJEXT=.mo
+ fi
+ fi
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+ if test "$CATOBJEXT" = "NONE"; then
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ INTLOBJS="\$(GETTOBJS)"
+ # Extract the first word of "msgfmt", so it can be a program name with args.
+set dummy msgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3822: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$MSGFMT" in
+ /*)
+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then
+ ac_cv_path_MSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="msgfmt"
+ ;;
+esac
+fi
+MSGFMT="$ac_cv_path_MSGFMT"
+if test -n "$MSGFMT"; then
+ echo "$ac_t""$MSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "gmsgfmt", so it can be a program name with args.
+set dummy gmsgfmt; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3856: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GMSGFMT" in
+ /*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GMSGFMT="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"
+ ;;
+esac
+fi
+GMSGFMT="$ac_cv_path_GMSGFMT"
+if test -n "$GMSGFMT"; then
+ echo "$ac_t""$GMSGFMT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ # Extract the first word of "xgettext", so it can be a program name with args.
+set dummy xgettext; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3892: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$XGETTEXT" in
+ /*)
+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then
+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word"
+ break
+ fi
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"
+ ;;
+esac
+fi
+XGETTEXT="$ac_cv_path_XGETTEXT"
+if test -n "$XGETTEXT"; then
+ echo "$ac_t""$XGETTEXT" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+ USE_INCLUDED_LIBINTL=yes
+ CATOBJEXT=.gmo
+ INSTOBJEXT=.mo
+ DATADIRNAME=share
+ INTLDEPS='$(top_builddir)/../intl/libintl.a'
+ INTLLIBS=$INTLDEPS
+ LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ if test "$XGETTEXT" != ":"; then
+ if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
+ : ;
+ else
+ echo "$ac_t""found xgettext programs is not GNU xgettext; ignore it" 1>&6
+ XGETTEXT=":"
+ fi
+ fi
+
+ # We need to process the po/ directory.
+ POSUB=po
+ else
+ DATADIRNAME=share
+ nls_cv_header_intl=libintl.h
+ nls_cv_header_libgt=libgettext.h
+ fi
+
+ # If this is used in GNU gettext we have to set USE_NLS to `yes'
+ # because some of the sources are only built for this goal.
+ if test "$PACKAGE" = gettext; then
+ USE_NLS=yes
+ USE_INCLUDED_LIBINTL=yes
+ fi
+
+ for lang in $ALL_LINGUAS; do
+ GMOFILES="$GMOFILES $lang.gmo"
+ POFILES="$POFILES $lang.po"
+ done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
+echo "configure:3982: checking for catalogs to be installed" >&5
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ echo "$ac_t""$LINGUAS" 1>&6
+ fi
+
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+
+
+ if test -f $srcdir/po2tbl.sed.in; then
+ if test "$CATOBJEXT" = ".cat"; then
+ ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
+echo "configure:4010: checking for linux/version.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4015 "configure"
+#include "confdefs.h"
+#include <linux/version.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:4020: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ msgformat=linux
+else
+ echo "$ac_t""no" 1>&6
+msgformat=xopen
+fi
+
+
+ sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
+ fi
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/po2tbl.sed.in > po2tbl.sed
+ fi
+
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+
+
+
+ MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
+
+
+ l=
+
+
+ if test -d $srcdir/po; then
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ fi
+
+
+. ${srcdir}/../bfd/configure.host
+
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:4097: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+for ac_hdr in string.h strings.h stdlib.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:4154: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4159 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:4164: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+
+using_cgen=no
+
+# Horrible hacks to build DLLs on Windows.
+WIN32LDFLAGS=
+WIN32LIBADD=
+case "${host}" in
+*-*-cygwin*)
+ if test "$enable_shared" = "yes"; then
+ WIN32LDFLAGS="-no-undefined"
+ WIN32LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
+ fi
+ ;;
+esac
+
+
+
+# target-specific stuff:
+
+# Canonicalize the secondary target names.
+if test -n "$enable_targets" ; then
+ for targ in `echo $enable_targets | sed 's/,/ /g'`
+ do
+ result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null`
+ if test -n "$result" ; then
+ canon_targets="$canon_targets $result"
+ else
+ # Allow targets that config.sub doesn't recognize, like "all".
+ canon_targets="$canon_targets $targ"
+ fi
+ done
+fi
+
+all_targets=false
+selarchs=
+for targ in $target $canon_targets
+do
+ if test "x$targ" = "xall" ; then
+ all_targets=true
+ else
+ . $srcdir/../bfd/config.bfd
+ selarchs="$selarchs $targ_archs"
+ fi
+done
+
+# Utility var, documents generic cgen support files.
+
+cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo"
+
+# We don't do any links based on the target system, just makefile config.
+
+if test x${all_targets} = xfalse ; then
+
+ # Target architecture .o files.
+ ta=
+
+ for arch in $selarchs
+ do
+ ad=`echo $arch | sed -e s/bfd_//g -e s/_arch//g`
+ archdefs="$archdefs -DARCH_$ad"
+ case "$arch" in
+ bfd_a29k_arch) ta="$ta a29k-dis.lo" ;;
+ bfd_alliant_arch) ;;
+ bfd_alpha_arch) ta="$ta alpha-dis.lo alpha-opc.lo" ;;
+ bfd_arc_arch) ta="$ta arc-dis.lo arc-opc.lo" ;;
+ bfd_arm_arch) ta="$ta arm-dis.lo" ;;
+ bfd_convex_arch) ;;
+ bfd_d10v_arch) ta="$ta d10v-dis.lo d10v-opc.lo" ;;
+ bfd_d30v_arch) ta="$ta d30v-dis.lo d30v-opc.lo" ;;
+ bfd_fr30_arch) ta="$ta fr30-asm.lo fr30-desc.lo fr30-dis.lo fr30-ibld.lo fr30-opc.lo" using_cgen=yes ;;
+ bfd_h8300_arch) ta="$ta h8300-dis.lo" ;;
+ bfd_h8500_arch) ta="$ta h8500-dis.lo" ;;
+ bfd_hppa_arch) ta="$ta hppa-dis.lo" ;;
+ bfd_i386_arch) ta="$ta i386-dis.lo" ;;
+ bfd_i860_arch) ;;
+ bfd_i960_arch) ta="$ta i960-dis.lo" ;;
+ bfd_m32r_arch) ta="$ta m32r-asm.lo m32r-desc.lo m32r-dis.lo m32r-ibld.lo m32r-opc.lo m32r-opinst.lo" using_cgen=yes ;;
+ bfd_m68k_arch) ta="$ta m68k-dis.lo m68k-opc.lo" ;;
+ bfd_m88k_arch) ta="$ta m88k-dis.lo" ;;
+ bfd_mcore_arch) ta="$ta mcore-dis.lo" ;;
+ bfd_mips_arch) ta="$ta mips-dis.lo mips-opc.lo mips16-opc.lo" ;;
+ bfd_mn10200_arch) ta="$ta m10200-dis.lo m10200-opc.lo" ;;
+ bfd_mn10300_arch) ta="$ta m10300-dis.lo m10300-opc.lo" ;;
+ bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;;
+ bfd_powerpc_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
+ bfd_pyramid_arch) ;;
+ bfd_romp_arch) ;;
+ bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
+ bfd_sh_arch) ta="$ta sh-dis.lo" ;;
+ bfd_sparc_arch) ta="$ta sparc-dis.lo sparc-opc.lo" ;;
+ bfd_tahoe_arch) ;;
+ bfd_tic30_arch) ta="$ta tic30-dis.lo" ;;
+ bfd_tic80_arch) ta="$ta tic80-dis.lo tic80-opc.lo" ;;
+ bfd_v850_arch) ta="$ta v850-opc.lo v850-dis.lo" ;;
+ bfd_v850e_arch) ta="$ta v850-opc.lo v850-dis.lo" ;;
+ bfd_v850ea_arch) ta="$ta v850-opc.lo v850-dis.lo" ;;
+ bfd_vax_arch) ta="$ta vax-dis.lo" ;;
+ bfd_w65_arch) ta="$ta w65-dis.lo" ;;
+ bfd_we32k_arch) ;;
+ bfd_z8k_arch) ta="$ta z8k-dis.lo" ;;
+
+ "") ;;
+ *) { echo "configure: error: *** unknown target architecture $arch" 1>&2; exit 1; } ;;
+ esac
+ done
+
+ if test $using_cgen = yes ; then
+ ta="$ta $cgen_files"
+ fi
+
+ # Weed out duplicate .o files.
+ f=""
+ for i in $ta ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+ done
+ ta="$f"
+
+ # And duplicate -D flags.
+ f=""
+ for i in $archdefs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+ done
+ archdefs="$f"
+
+ BFD_MACHINES="$ta"
+
+else # all_targets is true
+ archdefs=-DARCH_all
+ BFD_MACHINES='$(ALL_MACHINES)'
+fi
+
+
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile po/Makefile.in:po/Make-in config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@CC@%$CC%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@PACKAGE@%$PACKAGE%g
+s%@VERSION@%$VERSION%g
+s%@ACLOCAL@%$ACLOCAL%g
+s%@AUTOCONF@%$AUTOCONF%g
+s%@AUTOMAKE@%$AUTOMAKE%g
+s%@AUTOHEADER@%$AUTOHEADER%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@AR@%$AR%g
+s%@RANLIB@%$RANLIB%g
+s%@LD@%$LD%g
+s%@NM@%$NM%g
+s%@USE_SYMBOL_UNDERSCORE@%$USE_SYMBOL_UNDERSCORE%g
+s%@LN_S@%$LN_S%g
+s%@DLLTOOL@%$DLLTOOL%g
+s%@AS@%$AS%g
+s%@LIBTOOL@%$LIBTOOL%g
+s%@MAINTAINER_MODE_TRUE@%$MAINTAINER_MODE_TRUE%g
+s%@MAINTAINER_MODE_FALSE@%$MAINTAINER_MODE_FALSE%g
+s%@MAINT@%$MAINT%g
+s%@EXEEXT@%$EXEEXT%g
+s%@CPP@%$CPP%g
+s%@ALLOCA@%$ALLOCA%g
+s%@USE_NLS@%$USE_NLS%g
+s%@MSGFMT@%$MSGFMT%g
+s%@GMSGFMT@%$GMSGFMT%g
+s%@XGETTEXT@%$XGETTEXT%g
+s%@USE_INCLUDED_LIBINTL@%$USE_INCLUDED_LIBINTL%g
+s%@CATALOGS@%$CATALOGS%g
+s%@CATOBJEXT@%$CATOBJEXT%g
+s%@DATADIRNAME@%$DATADIRNAME%g
+s%@GMOFILES@%$GMOFILES%g
+s%@INSTOBJEXT@%$INSTOBJEXT%g
+s%@INTLDEPS@%$INTLDEPS%g
+s%@INTLLIBS@%$INTLLIBS%g
+s%@INTLOBJS@%$INTLOBJS%g
+s%@POFILES@%$POFILES%g
+s%@POSUB@%$POSUB%g
+s%@INCLUDE_LOCALE_H@%$INCLUDE_LOCALE_H%g
+s%@GT_NO@%$GT_NO%g
+s%@GT_YES@%$GT_YES%g
+s%@MKINSTALLDIRS@%$MKINSTALLDIRS%g
+s%@l@%$l%g
+s%@HDEFINES@%$HDEFINES%g
+s%@CGEN_MAINT_TRUE@%$CGEN_MAINT_TRUE%g
+s%@CGEN_MAINT_FALSE@%$CGEN_MAINT_FALSE%g
+s%@cgendir@%$cgendir%g
+s%@cgen@%$cgen%g
+s%@WIN32LDFLAGS@%$WIN32LDFLAGS%g
+s%@WIN32LIBADD@%$WIN32LIBADD%g
+s%@archdefs@%$archdefs%g
+s%@BFD_MACHINES@%$BFD_MACHINES%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile po/Makefile.in:po/Make-in"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h:config.in"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+sed -e '/POTFILES =/r po/POTFILES' po/Makefile.in > po/Makefile
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/opcodes/configure.bat b/opcodes/configure.bat
new file mode 100644
index 00000000000..5f2c6d11c23
--- /dev/null
+++ b/opcodes/configure.bat
@@ -0,0 +1,24 @@
+@echo off
+echo Configuring opcodes for go32
+rem This batch file assumes a unix-type "sed" program
+
+echo # Makefile generated by "configure.bat"> Makefile
+
+if exist config.sed del config.sed
+
+echo "/\.o[ ]*:/ s/config.status// ">> config.sed
+echo "s/CC = cc/CC = gcc/ ">> config.sed
+echo "s/@BFD_MACHINES@/i386-dis.o/ ">> config.sed
+echo "s/@archdefs@/-DARCH_i386/ ">> config.sed
+echo "s/@frags@// ">> config.sed
+echo "s/@srcdir@// ">> config.sed
+echo "s!@prefix@!/usr/local! ">> config.sed
+echo "s!@exec_prefix@!/usr/local! ">> config.sed
+echo "s/@RANLIB@/ranlib/ ">> config.sed
+
+echo "s/^[ ]*rm/ -rm/ ">> config.sed
+
+sed -e "s/^\"//" -e "s/\"$//" -e "s/[ ]*$//" config.sed > config2.sed
+sed -f config2.sed Makefile.in >> Makefile
+del config.sed
+del config2.sed
diff --git a/opcodes/configure.in b/opcodes/configure.in
new file mode 100644
index 00000000000..c2785804b22
--- /dev/null
+++ b/opcodes/configure.in
@@ -0,0 +1,211 @@
+dnl Process this file with autoconf to produce a configure script.
+dnl
+
+AC_PREREQ(2.13)
+AC_INIT(z8k-dis.c)
+
+AC_CANONICAL_SYSTEM
+AC_ISC_POSIX
+
+# We currently only use the version number for the name of any shared
+# library. For user convenience, we always use the same version
+# number that BFD is using.
+changequote(,)dnl
+BFD_VERSION=`grep INIT_AUTOMAKE ${srcdir}/../bfd/configure.in | sed -n -e 's/[ ]//g' -e 's/^.*,\(.*\)).*$/\1/p'`
+changequote([,])dnl
+
+AM_INIT_AUTOMAKE(opcodes, ${BFD_VERSION})
+
+dnl These must be called before AM_PROG_LIBTOOL, because it may want
+dnl to call AC_CHECK_PROG.
+AC_CHECK_TOOL(AR, ar)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+
+dnl Default to a non shared library. This may be overridden by the
+dnl configure option --enable-shared.
+AM_DISABLE_SHARED
+
+AM_PROG_LIBTOOL
+
+AC_ARG_ENABLE(targets,
+[ --enable-targets alternative target configurations],
+[case "${enableval}" in
+ yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
+ ;;
+ no) enable_targets= ;;
+ *) enable_targets=$enableval ;;
+esac])dnl
+AC_ARG_ENABLE(commonbfdlib,
+[ --enable-commonbfdlib build shared BFD/opcodes/libiberty library],
+[case "${enableval}" in
+ yes) commonbfdlib=true ;;
+ no) commonbfdlib=false ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for opcodes commonbfdlib option]) ;;
+esac])dnl
+
+AM_CONFIG_HEADER(config.h:config.in)
+
+if test -z "$target" ; then
+ AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
+fi
+AC_ARG_PROGRAM
+
+AM_MAINTAINER_MODE
+AC_EXEEXT
+
+# host-specific stuff:
+
+AC_PROG_CC
+
+ALL_LINGUAS=
+CY_GNU_GETTEXT
+
+. ${srcdir}/../bfd/configure.host
+
+AC_SUBST(HDEFINES)
+AC_PROG_INSTALL
+
+AC_CHECK_HEADERS(string.h strings.h stdlib.h)
+
+
+using_cgen=no
+
+# Horrible hacks to build DLLs on Windows.
+WIN32LDFLAGS=
+WIN32LIBADD=
+case "${host}" in
+*-*-cygwin*)
+ if test "$enable_shared" = "yes"; then
+ WIN32LDFLAGS="-no-undefined"
+ WIN32LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
+ fi
+ ;;
+esac
+AC_SUBST(WIN32LDFLAGS)
+AC_SUBST(WIN32LIBADD)
+
+# target-specific stuff:
+
+# Canonicalize the secondary target names.
+if test -n "$enable_targets" ; then
+ for targ in `echo $enable_targets | sed 's/,/ /g'`
+ do
+ result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null`
+ if test -n "$result" ; then
+ canon_targets="$canon_targets $result"
+ else
+ # Allow targets that config.sub doesn't recognize, like "all".
+ canon_targets="$canon_targets $targ"
+ fi
+ done
+fi
+
+all_targets=false
+selarchs=
+for targ in $target $canon_targets
+do
+ if test "x$targ" = "xall" ; then
+ all_targets=true
+ else
+ . $srcdir/../bfd/config.bfd
+ selarchs="$selarchs $targ_archs"
+ fi
+done
+
+# Utility var, documents generic cgen support files.
+
+cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo"
+
+# We don't do any links based on the target system, just makefile config.
+
+if test x${all_targets} = xfalse ; then
+
+ # Target architecture .o files.
+ ta=
+
+ for arch in $selarchs
+ do
+ ad=`echo $arch | sed -e s/bfd_//g -e s/_arch//g`
+ archdefs="$archdefs -DARCH_$ad"
+ case "$arch" in
+ bfd_a29k_arch) ta="$ta a29k-dis.lo" ;;
+ bfd_alliant_arch) ;;
+ bfd_alpha_arch) ta="$ta alpha-dis.lo alpha-opc.lo" ;;
+ bfd_arc_arch) ta="$ta arc-dis.lo arc-opc.lo" ;;
+ bfd_arm_arch) ta="$ta arm-dis.lo" ;;
+ bfd_convex_arch) ;;
+ bfd_d10v_arch) ta="$ta d10v-dis.lo d10v-opc.lo" ;;
+ bfd_d30v_arch) ta="$ta d30v-dis.lo d30v-opc.lo" ;;
+ bfd_fr30_arch) ta="$ta fr30-asm.lo fr30-desc.lo fr30-dis.lo fr30-ibld.lo fr30-opc.lo" using_cgen=yes ;;
+ bfd_h8300_arch) ta="$ta h8300-dis.lo" ;;
+ bfd_h8500_arch) ta="$ta h8500-dis.lo" ;;
+ bfd_hppa_arch) ta="$ta hppa-dis.lo" ;;
+ bfd_i386_arch) ta="$ta i386-dis.lo" ;;
+ bfd_i860_arch) ;;
+ bfd_i960_arch) ta="$ta i960-dis.lo" ;;
+ bfd_m32r_arch) ta="$ta m32r-asm.lo m32r-desc.lo m32r-dis.lo m32r-ibld.lo m32r-opc.lo m32r-opinst.lo" using_cgen=yes ;;
+ bfd_m68k_arch) ta="$ta m68k-dis.lo m68k-opc.lo" ;;
+ bfd_m88k_arch) ta="$ta m88k-dis.lo" ;;
+ bfd_mcore_arch) ta="$ta mcore-dis.lo" ;;
+ bfd_mips_arch) ta="$ta mips-dis.lo mips-opc.lo mips16-opc.lo" ;;
+ bfd_mn10200_arch) ta="$ta m10200-dis.lo m10200-opc.lo" ;;
+ bfd_mn10300_arch) ta="$ta m10300-dis.lo m10300-opc.lo" ;;
+ bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;;
+ bfd_powerpc_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
+ bfd_pyramid_arch) ;;
+ bfd_romp_arch) ;;
+ bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
+ bfd_sh_arch) ta="$ta sh-dis.lo" ;;
+ bfd_sparc_arch) ta="$ta sparc-dis.lo sparc-opc.lo" ;;
+ bfd_tahoe_arch) ;;
+ bfd_tic30_arch) ta="$ta tic30-dis.lo" ;;
+ bfd_tic80_arch) ta="$ta tic80-dis.lo tic80-opc.lo" ;;
+ bfd_v850_arch) ta="$ta v850-opc.lo v850-dis.lo" ;;
+ bfd_v850e_arch) ta="$ta v850-opc.lo v850-dis.lo" ;;
+ bfd_v850ea_arch) ta="$ta v850-opc.lo v850-dis.lo" ;;
+ bfd_vax_arch) ta="$ta vax-dis.lo" ;;
+ bfd_w65_arch) ta="$ta w65-dis.lo" ;;
+ bfd_we32k_arch) ;;
+ bfd_z8k_arch) ta="$ta z8k-dis.lo" ;;
+
+ "") ;;
+ *) AC_MSG_ERROR(*** unknown target architecture $arch) ;;
+ esac
+ done
+
+ if test $using_cgen = yes ; then
+ ta="$ta $cgen_files"
+ fi
+
+ # Weed out duplicate .o files.
+ f=""
+ for i in $ta ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+ done
+ ta="$f"
+
+ # And duplicate -D flags.
+ f=""
+ for i in $archdefs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+ done
+ archdefs="$f"
+
+ BFD_MACHINES="$ta"
+
+else # all_targets is true
+ archdefs=-DARCH_all
+ BFD_MACHINES='$(ALL_MACHINES)'
+fi
+
+AC_SUBST(archdefs)
+AC_SUBST(BFD_MACHINES)
+
+AC_OUTPUT(Makefile po/Makefile.in:po/Make-in,
+[sed -e '/POTFILES =/r po/POTFILES' po/Makefile.in > po/Makefile])
diff --git a/opcodes/d10v-dis.c b/opcodes/d10v-dis.c
new file mode 100644
index 00000000000..fb1a7d30dd2
--- /dev/null
+++ b/opcodes/d10v-dis.c
@@ -0,0 +1,301 @@
+/* Disassemble D10V instructions.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include <stdio.h>
+
+#include "ansidecl.h"
+#include "opcode/d10v.h"
+#include "dis-asm.h"
+
+/* the PC wraps at 18 bits, except for the segment number */
+/* so use this mask to keep the parts we want */
+#define PC_MASK 0x0303FFFF
+
+static void dis_2_short PARAMS ((unsigned long insn, bfd_vma memaddr,
+ struct disassemble_info *info, int order));
+static void dis_long PARAMS ((unsigned long insn, bfd_vma memaddr,
+ struct disassemble_info *info));
+
+int
+print_insn_d10v (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int status;
+ bfd_byte buffer[4];
+ unsigned long insn;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb32 (buffer);
+
+ status = insn & FM11;
+ switch (status) {
+ case 0:
+ dis_2_short (insn, memaddr, info, 2);
+ break;
+ case FM01:
+ dis_2_short (insn, memaddr, info, 0);
+ break;
+ case FM10:
+ dis_2_short (insn, memaddr, info, 1);
+ break;
+ case FM11:
+ dis_long (insn, memaddr, info);
+ break;
+ }
+ return 4;
+}
+
+static void
+print_operand (oper, insn, op, memaddr, info)
+ struct d10v_operand *oper;
+ unsigned long insn;
+ struct d10v_opcode *op;
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int num, shift;
+
+ if (oper->flags == OPERAND_ATMINUS)
+ {
+ (*info->fprintf_func) (info->stream, "@-");
+ return;
+ }
+ if (oper->flags == OPERAND_MINUS)
+ {
+ (*info->fprintf_func) (info->stream, "-");
+ return;
+ }
+ if (oper->flags == OPERAND_PLUS)
+ {
+ (*info->fprintf_func) (info->stream, "+");
+ return;
+ }
+ if (oper->flags == OPERAND_ATSIGN)
+ {
+ (*info->fprintf_func) (info->stream, "@");
+ return;
+ }
+ if (oper->flags == OPERAND_ATPAR)
+ {
+ (*info->fprintf_func) (info->stream, "@(");
+ return;
+ }
+
+ shift = oper->shift;
+
+ /* the LONG_L format shifts registers over by 15 */
+ if (op->format == LONG_L && (oper->flags & OPERAND_REG))
+ shift += 15;
+
+ num = (insn >> shift) & (0x7FFFFFFF >> (31 - oper->bits));
+
+ if (oper->flags & OPERAND_REG)
+ {
+ int i;
+ int match=0;
+ num += (oper->flags
+ & (OPERAND_GPR|OPERAND_FFLAG|OPERAND_CFLAG|OPERAND_CONTROL));
+ if (oper->flags & (OPERAND_ACC0|OPERAND_ACC1))
+ num += num ? OPERAND_ACC1 : OPERAND_ACC0;
+ for (i = 0; i < d10v_reg_name_cnt(); i++)
+ {
+ if (num == d10v_predefined_registers[i].value)
+ {
+ if (d10v_predefined_registers[i].pname)
+ (*info->fprintf_func) (info->stream, "%s",d10v_predefined_registers[i].pname);
+ else
+ (*info->fprintf_func) (info->stream, "%s",d10v_predefined_registers[i].name);
+ match=1;
+ break;
+ }
+ }
+ if (match == 0)
+ {
+ /* this would only get executed if a register was not in the
+ register table */
+ if (oper->flags & (OPERAND_ACC0|OPERAND_ACC1))
+ (*info->fprintf_func) (info->stream, "a");
+ else if (oper->flags & OPERAND_CONTROL)
+ (*info->fprintf_func) (info->stream, "cr");
+ else if(oper->flags & OPERAND_REG)
+ (*info->fprintf_func) (info->stream, "r");
+ (*info->fprintf_func) (info->stream, "%d",num);
+ }
+ }
+ else
+ {
+ /* addresses are right-shifted by 2 */
+ if (oper->flags & OPERAND_ADDR)
+ {
+ long max;
+ int neg=0;
+ max = (1 << (oper->bits - 1));
+ if (num & max)
+ {
+ num = -num & ((1 << oper->bits)-1);
+ neg = 1;
+ }
+ num = num<<2;
+ if (info->flags & INSN_HAS_RELOC)
+ (*info->print_address_func) (num & PC_MASK, info);
+ else
+ {
+ if (neg)
+ (*info->print_address_func) ((memaddr - num) & PC_MASK, info);
+ else
+ (*info->print_address_func) ((memaddr + num) & PC_MASK, info);
+ }
+ }
+ else
+ {
+ if (oper->flags & OPERAND_SIGNED)
+ {
+ int max = (1 << (oper->bits - 1));
+ if (num & max)
+ {
+ num = -num & ((1 << oper->bits)-1);
+ (*info->fprintf_func) (info->stream, "-");
+ }
+ }
+ (*info->fprintf_func) (info->stream, "0x%x",num);
+ }
+ }
+}
+
+
+static void
+dis_long (insn, memaddr, info)
+ unsigned long insn;
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int i;
+ char buf[32];
+ struct d10v_opcode *op = (struct d10v_opcode *)d10v_opcodes;
+ struct d10v_operand *oper;
+ int need_paren = 0;
+ int match = 0;
+
+ while (op->name)
+ {
+ if ((op->format & LONG_OPCODE) && ((op->mask & insn) == op->opcode))
+ {
+ match = 1;
+ (*info->fprintf_func) (info->stream, "%s\t", op->name);
+ for ( i=0; op->operands[i]; i++)
+ {
+ oper = (struct d10v_operand *)&d10v_operands[op->operands[i]];
+ if (oper->flags == OPERAND_ATPAR)
+ need_paren = 1;
+ print_operand (oper, insn, op, memaddr, info);
+ if (op->operands[i+1] && oper->bits &&
+ d10v_operands[op->operands[i+1]].flags != OPERAND_PLUS &&
+ d10v_operands[op->operands[i+1]].flags != OPERAND_MINUS)
+ (*info->fprintf_func) (info->stream, ", ");
+ }
+ break;
+ }
+ op++;
+ }
+
+ if (!match)
+ (*info->fprintf_func) (info->stream, ".long\t0x%08x",insn);
+
+ if (need_paren)
+ (*info->fprintf_func) (info->stream, ")");
+}
+
+static void
+dis_2_short (insn, memaddr, info, order)
+ unsigned long insn;
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+ int order;
+{
+ int i,j;
+ char astr[2][32];
+ unsigned int ins[2];
+ struct d10v_opcode *op;
+ char buf[32];
+ int match, num_match=0;
+ struct d10v_operand *oper;
+ int need_paren = 0;
+
+ ins[0] = (insn & 0x3FFFFFFF) >> 15;
+ ins[1] = insn & 0x00007FFF;
+
+ for(j=0;j<2;j++)
+ {
+ op = (struct d10v_opcode *)d10v_opcodes;
+ match=0;
+ while (op->name)
+ {
+ if ((op->format & SHORT_OPCODE) && ((op->mask & ins[j]) == op->opcode))
+ {
+ (*info->fprintf_func) (info->stream, "%s\t",op->name);
+ for (i=0; op->operands[i]; i++)
+ {
+ oper = (struct d10v_operand *)&d10v_operands[op->operands[i]];
+ if (oper->flags == OPERAND_ATPAR)
+ need_paren = 1;
+ print_operand (oper, ins[j], op, memaddr, info);
+ if (op->operands[i+1] && oper->bits &&
+ d10v_operands[op->operands[i+1]].flags != OPERAND_PLUS &&
+ d10v_operands[op->operands[i+1]].flags != OPERAND_MINUS)
+ (*info->fprintf_func) (info->stream, ", ");
+ }
+ match = 1;
+ num_match++;
+ break;
+ }
+ op++;
+ }
+ if (!match)
+ (*info->fprintf_func) (info->stream, "unknown");
+
+ switch (order)
+ {
+ case 0:
+ (*info->fprintf_func) (info->stream, "\t->\t");
+ order = -1;
+ break;
+ case 1:
+ (*info->fprintf_func) (info->stream, "\t<-\t");
+ order = -1;
+ break;
+ case 2:
+ (*info->fprintf_func) (info->stream, "\t||\t");
+ order = -1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (num_match == 0)
+ (*info->fprintf_func) (info->stream, ".long\t0x%08x",insn);
+
+ if (need_paren)
+ (*info->fprintf_func) (info->stream, ")");
+}
diff --git a/opcodes/d10v-opc.c b/opcodes/d10v-opc.c
new file mode 100644
index 00000000000..a8a02d03871
--- /dev/null
+++ b/opcodes/d10v-opc.c
@@ -0,0 +1,334 @@
+/* d10v-opc.c -- D10V opcode list
+ Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+ Written by Martin Hunt, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+2, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/d10v.h"
+
+
+/* The table is sorted. Suitable for searching by a binary search. */
+const struct pd_reg d10v_predefined_registers[] =
+{
+ { "a0", NULL, OPERAND_ACC0+0 },
+ { "a1", NULL, OPERAND_ACC1+1 },
+ { "bpc", NULL, OPERAND_CONTROL+3 },
+ { "bpsw", NULL, OPERAND_CONTROL+1 },
+ { "c", NULL, OPERAND_CFLAG+3 },
+ { "cr0", "psw", OPERAND_CONTROL },
+ { "cr1", "bpsw", OPERAND_CONTROL+1 },
+ { "cr10", "mod_s", OPERAND_CONTROL+10 },
+ { "cr11", "mod_e", OPERAND_CONTROL+11 },
+ { "cr12", NULL, OPERAND_CONTROL+12 },
+ { "cr13", NULL, OPERAND_CONTROL+13 },
+ { "cr14", "iba", OPERAND_CONTROL+14 },
+ { "cr15", NULL, OPERAND_CONTROL+15 },
+ { "cr2", "pc", OPERAND_CONTROL+2 },
+ { "cr3", "bpc", OPERAND_CONTROL+3 },
+ { "cr4", "dpsw", OPERAND_CONTROL+4 },
+ { "cr5", "dpc", OPERAND_CONTROL+5 },
+ { "cr6", NULL, OPERAND_CONTROL+6 },
+ { "cr7", "rpt_c", OPERAND_CONTROL+7 },
+ { "cr8", "rpt_s", OPERAND_CONTROL+8 },
+ { "cr9", "rpt_e", OPERAND_CONTROL+9 },
+ { "dpc", NULL, OPERAND_CONTROL+5 },
+ { "dpsw", NULL, OPERAND_CONTROL+4 },
+ { "f0", NULL, OPERAND_FFLAG+0 },
+ { "f1", NULL, OPERAND_FFLAG+1 },
+ { "iba", NULL, OPERAND_CONTROL+14 },
+ { "link", "r13", OPERAND_GPR+13 },
+ { "mod_e", NULL, OPERAND_CONTROL+11 },
+ { "mod_s", NULL, OPERAND_CONTROL+10 },
+ { "pc", NULL, OPERAND_CONTROL+2 },
+ { "psw", NULL, OPERAND_CONTROL+0 },
+ { "r0", NULL, OPERAND_GPR+0 },
+ { "r0-r1", NULL, OPERAND_GPR+0},
+ { "r1", NULL, OPERAND_GPR+1 },
+ { "r1", NULL, OPERAND_GPR+1 },
+ { "r10", NULL, OPERAND_GPR+10 },
+ { "r10-r11", NULL, OPERAND_GPR+10 },
+ { "r11", NULL, OPERAND_GPR+11 },
+ { "r12", NULL, OPERAND_GPR+12 },
+ { "r12-r13", NULL, OPERAND_GPR+12 },
+ { "r13", NULL, OPERAND_GPR+13 },
+ { "r14", NULL, OPERAND_GPR+14 },
+ { "r14-r15", NULL, OPERAND_GPR+14 },
+ { "r15", "sp", OPERAND_GPR+15 },
+ { "r2", NULL, OPERAND_GPR+2 },
+ { "r2-r3", NULL, OPERAND_GPR+2 },
+ { "r3", NULL, OPERAND_GPR+3 },
+ { "r4", NULL, OPERAND_GPR+4 },
+ { "r4-r5", NULL, OPERAND_GPR+4 },
+ { "r5", NULL, OPERAND_GPR+5 },
+ { "r6", NULL, OPERAND_GPR+6 },
+ { "r6-r7", NULL, OPERAND_GPR+6 },
+ { "r7", NULL, OPERAND_GPR+7 },
+ { "r8", NULL, OPERAND_GPR+8 },
+ { "r8-r9", NULL, OPERAND_GPR+8 },
+ { "r9", NULL, OPERAND_GPR+9 },
+ { "rpt_c", NULL, OPERAND_CONTROL+7 },
+ { "rpt_e", NULL, OPERAND_CONTROL+9 },
+ { "rpt_s", NULL, OPERAND_CONTROL+8 },
+ { "sp", NULL, OPERAND_GPR+15 },
+};
+
+int
+d10v_reg_name_cnt()
+{
+ return (sizeof(d10v_predefined_registers) / sizeof(struct pd_reg));
+}
+
+const struct d10v_operand d10v_operands[] =
+{
+#define UNUSED (0)
+ { 0, 0, 0 },
+#define RSRC (UNUSED + 1)
+ { 4, 1, OPERAND_GPR|OPERAND_REG },
+#define RDST (RSRC + 1)
+ { 4, 5, OPERAND_DEST|OPERAND_GPR|OPERAND_REG },
+#define ASRC (RDST + 1)
+ { 1, 4, OPERAND_ACC0|OPERAND_ACC1|OPERAND_REG },
+#define ASRC0ONLY (ASRC + 1)
+ { 1, 4, OPERAND_ACC0|OPERAND_REG },
+#define ADST (ASRC0ONLY + 1)
+ { 1, 8, OPERAND_DEST|OPERAND_ACC0|OPERAND_ACC1|OPERAND_REG },
+#define RSRCE (ADST + 1)
+ { 4, 1, OPERAND_EVEN|OPERAND_GPR|OPERAND_REG },
+#define RDSTE (RSRCE + 1)
+ { 4, 5, OPERAND_EVEN|OPERAND_DEST|OPERAND_GPR|OPERAND_REG },
+#define NUM16 (RDSTE + 1)
+ { 16, 0, OPERAND_NUM|OPERAND_SIGNED },
+#define NUM3 (NUM16 + 1) /* rac, rachi */
+ { 3, 1, OPERAND_NUM|OPERAND_SIGNED },
+#define NUM4 (NUM3 + 1)
+ { 4, 1, OPERAND_NUM|OPERAND_SIGNED },
+#define UNUM4 (NUM4 + 1)
+ { 4, 1, OPERAND_NUM },
+#define UNUM4S (UNUM4 + 1) /* addi, slli, srai, srli, subi */
+ { 4, 1, OPERAND_NUM|OPERAND_SHIFT },
+#define UNUM8 (UNUM4S + 1) /* repi */
+ { 8, 16, OPERAND_NUM },
+#define UNUM16 (UNUM8 + 1) /* cmpui */
+ { 16, 0, OPERAND_NUM },
+#define ANUM16 (UNUM16 + 1)
+ { 16, 0, OPERAND_ADDR|OPERAND_SIGNED },
+#define ANUM8 (ANUM16 + 1)
+ { 8, 0, OPERAND_ADDR|OPERAND_SIGNED },
+#define ASRC2 (ANUM8 + 1)
+ { 1, 8, OPERAND_ACC0|OPERAND_ACC1|OPERAND_REG },
+#define RSRC2 (ASRC2 + 1)
+ { 4, 5, OPERAND_GPR|OPERAND_REG },
+#define RSRC2E (RSRC2 + 1)
+ { 4, 5, OPERAND_GPR|OPERAND_REG|OPERAND_EVEN },
+#define ASRC0 (RSRC2E + 1)
+ { 1, 0, OPERAND_ACC0|OPERAND_ACC1|OPERAND_REG },
+#define ADST0 (ASRC0 + 1)
+ { 1, 0, OPERAND_ACC0|OPERAND_ACC1|OPERAND_REG|OPERAND_DEST },
+#define FFSRC (ADST0 + 1)
+ { 2, 1, OPERAND_REG | OPERAND_FFLAG },
+#define CFSRC (FFSRC + 1)
+ { 2, 1, OPERAND_REG | OPERAND_CFLAG },
+#define FDST (CFSRC + 1)
+ { 1, 5, OPERAND_REG | OPERAND_FFLAG | OPERAND_DEST},
+#define ATSIGN (FDST + 1)
+ { 0, 0, OPERAND_ATSIGN},
+#define ATPAR (ATSIGN + 1) /* "@(" */
+ { 0, 0, OPERAND_ATPAR},
+#define PLUS (ATPAR + 1) /* postincrement */
+ { 0, 0, OPERAND_PLUS},
+#define MINUS (PLUS + 1) /* postdecrement */
+ { 0, 0, OPERAND_MINUS},
+#define ATMINUS (MINUS + 1) /* predecrement */
+ { 0, 0, OPERAND_ATMINUS},
+#define CSRC (ATMINUS + 1) /* control register */
+ { 4, 1, OPERAND_REG|OPERAND_CONTROL},
+#define CDST (CSRC + 1) /* control register */
+ { 4, 5, OPERAND_REG|OPERAND_CONTROL|OPERAND_DEST},
+};
+
+const struct d10v_opcode d10v_opcodes[] = {
+ { "abs", SHORT_2, 1, EITHER, PAR|WF0, 0x4607, 0x7e1f, { RDST } },
+ { "abs", SHORT_2, 1, IU, PAR|WF0, 0x5607, 0x7eff, { ADST } },
+ { "add", SHORT_2, 1, EITHER, PAR|WCAR, 0x0200, 0x7e01, { RDST, RSRC } },
+ { "add", SHORT_2, 1, IU, PAR, 0x1201, 0x7ee3, { ADST, RSRCE } },
+ { "add", SHORT_2, 1, IU, PAR, 0x1203, 0x7eef, { ADST, ASRC } },
+ { "add2w", SHORT_2, 2, IU, PAR|WCAR, 0x1200, 0x7e23, { RDSTE, RSRCE } },
+ { "add3", LONG_L, 1, MU, SEQ|WCAR, 0x1000000, 0x3f000000, { RDST, RSRC, NUM16 } },
+ { "addac3", LONG_R, 1, IU, SEQ, 0x17000200, 0x3ffffe22, { RDSTE, RSRCE, ASRC0 } },
+ { "addac3", LONG_R, 1, IU, SEQ, 0x17000202, 0x3ffffe2e, { RDSTE, ASRC, ASRC0 } },
+ { "addac3s", LONG_R, 1, IU, SEQ, 0x17001200, 0x3ffffe22, { RDSTE, RSRCE, ASRC0 } },
+ { "addac3s", LONG_R, 1, IU, SEQ, 0x17001202, 0x3ffffe2e, { RDSTE, ASRC, ASRC0 } },
+ { "addi", SHORT_2, 1, EITHER, PAR|WCAR, 0x201, 0x7e01, { RDST, UNUM4S } },
+ { "and", SHORT_2, 1, EITHER, PAR, 0xc00, 0x7e01, { RDST, RSRC } },
+ { "and3", LONG_L, 1, MU, SEQ, 0x6000000, 0x3f000000, { RDST, RSRC, NUM16 } },
+ { "bclri", SHORT_2, 1, IU, PAR, 0xc01, 0x7e01, { RDST, UNUM4 } },
+ { "bl", OPCODE_FAKE, 0, 0, 0, 0, 0, { 0, 8, 16, 0 } },
+ { "bl.s", SHORT_B, 3, MU, BRANCH_LINK|PAR, 0x4900, 0x7f00, { ANUM8 } },
+ { "bl.l", LONG_B, 3, MU, BRANCH_LINK|SEQ, 0x24800000, 0x3fff0000, { ANUM16 } },
+ { "bnoti", SHORT_2, 1, IU, PAR, 0xa01, 0x7e01, { RDST, UNUM4 } },
+ { "bra", OPCODE_FAKE, 0, 0, 0, 0, 0, { 0, 8, 16, 0 } },
+ { "bra.s", SHORT_B, 3, MU, BRANCH|PAR, 0x4800, 0x7f00, { ANUM8 } },
+ { "bra.l", LONG_B, 3, MU, BRANCH|SEQ, 0x24000000, 0x3fff0000, { ANUM16 } },
+ { "brf0f", OPCODE_FAKE, 0, 0, 0, 0, 0, { 0, 8, 16, 0 } },
+ { "brf0f.s", SHORT_B, 3, MU, BRANCH|PAR|RF0, 0x4a00, 0x7f00, { ANUM8 } },
+ { "brf0f.l", LONG_B, 3, MU, SEQ, 0x25000000, 0x3fff0000, { ANUM16 } },
+ { "brf0t", OPCODE_FAKE, 0, 0, 0, 0, 0, { 0, 8, 16, 0 } },
+ { "brf0t.s", SHORT_B, 3, MU, BRANCH|PAR|RF0, 0x4b00, 0x7f00, { ANUM8 } },
+ { "brf0t.l", LONG_B, 3, MU, SEQ, 0x25800000, 0x3fff0000, { ANUM16 } },
+ { "bseti", SHORT_2, 1, IU, PAR, 0x801, 0x7e01, { RDST, UNUM4 } },
+ { "btsti", SHORT_2, 1, IU, PAR|WF0, 0xe01, 0x7e01, { RDST, UNUM4 } },
+ { "clrac", SHORT_2, 1, IU, PAR, 0x5601, 0x7eff, { ADST } },
+ { "cmp", SHORT_2, 1, EITHER, PAR|WF0, 0x600, 0x7e01, { RSRC2, RSRC } },
+ { "cmp", SHORT_2, 1, IU, PAR|WF0, 0x1603, 0x7eef, { ASRC2, ASRC } },
+ { "cmpeq", SHORT_2, 1, EITHER, PAR|WF0, 0x400, 0x7e01, { RSRC2, RSRC } },
+ { "cmpeq", SHORT_2, 1, IU, PAR|WF0, 0x1403, 0x7eef, { ASRC2, ASRC } },
+ { "cmpeqi", OPCODE_FAKE, 0, 0, 0, 0, 0, { 1, 4, 16, 0 } },
+ { "cmpeqi.s", SHORT_2, 1, EITHER, PAR|WF0, 0x401, 0x7e01, { RSRC2, NUM4 } },
+ { "cmpeqi.l", LONG_L, 1, MU, SEQ, 0x2000000, 0x3f0f0000, { RSRC2, NUM16 } },
+ { "cmpi", OPCODE_FAKE, 0, 0, 0, 0, 0, { 1, 4, 16, 0 } },
+ { "cmpi.s", SHORT_2, 1, EITHER, PAR|WF0, 0x601, 0x7e01, { RSRC2, NUM4 } },
+ { "cmpi.l", LONG_L, 1, MU, SEQ, 0x3000000, 0x3f0f0000, { RSRC2, NUM16 } },
+ { "cmpu", SHORT_2, 1, EITHER, PAR|WF0, 0x4600, 0x7e01, { RSRC2, RSRC } },
+ { "cmpui", LONG_L, 1, MU, SEQ, 0x23000000, 0x3f0f0000, { RSRC2, UNUM16 } },
+ { "cpfg", SHORT_2, 1, MU, PAR, 0x4e09, 0x7fd9, { FDST, FFSRC } },
+ { "cpfg", SHORT_2, 1, MU, PAR, 0x4e09, 0x7fd9, { FDST, CFSRC } },
+ { "dbt", SHORT_2, 5, MU, PAR, 0x5f20, 0x7fff, { 0 } },
+ { "divs", LONG_L, 1, BOTH, SEQ, 0x14002800, 0x3f10fe21, { RDSTE, RSRC } },
+ { "exef0f", SHORT_2, 1, EITHER, PARONLY, 0x4e04, 0x7fff, { 0 } },
+ { "exef0t", SHORT_2, 1, EITHER, PARONLY, 0x4e24, 0x7fff, { 0 } },
+ { "exef1f", SHORT_2, 1, EITHER, PARONLY, 0x4e40, 0x7fff, { 0 } },
+ { "exef1t", SHORT_2, 1, EITHER, PARONLY, 0x4e42, 0x7fff, { 0 } },
+ { "exefaf", SHORT_2, 1, EITHER, PARONLY, 0x4e00, 0x7fff, { 0 } },
+ { "exefat", SHORT_2, 1, EITHER, PARONLY, 0x4e02, 0x7fff, { 0 } },
+ { "exetaf", SHORT_2, 1, EITHER, PARONLY, 0x4e20, 0x7fff, { 0 } },
+ { "exetat", SHORT_2, 1, EITHER, PARONLY, 0x4e22, 0x7fff, { 0 } },
+ { "exp", LONG_R, 1, IU, SEQ, 0x15002a00, 0x3ffffe03, { RDST, RSRCE } },
+ { "exp", LONG_R, 1, IU, SEQ, 0x15002a02, 0x3ffffe0f, { RDST, ASRC } },
+ { "jl", SHORT_2, 3, MU, BRANCH_LINK|PAR, 0x4d00, 0x7fe1, { RSRC } },
+ { "jmp", SHORT_2, 3, MU, BRANCH|PAR, 0x4c00, 0x7fe1, { RSRC } },
+ { "ld", LONG_L, 1, MU, SEQ, 0x30000000, 0x3f000000, { RDST, ATPAR, NUM16, RSRC } },
+ { "ld", SHORT_2, 1, MU, PAR|RMEM, 0x6401, 0x7e01, { RDST, ATSIGN, RSRC, MINUS } },
+ { "ld", SHORT_2, 1, MU, PAR|RMEM, 0x6001, 0x7e01, { RDST, ATSIGN, RSRC, PLUS } },
+ { "ld", SHORT_2, 1, MU, PAR|RMEM, 0x6000, 0x7e01, { RDST, ATSIGN, RSRC } },
+ { "ld2w", LONG_L, 1, MU, SEQ, 0x31000000, 0x3f100000, { RDSTE, ATPAR, NUM16, RSRC } },
+ { "ld2w", SHORT_2, 1, MU, PAR|RMEM, 0x6601, 0x7e21, { RDSTE, ATSIGN, RSRC, MINUS } },
+ { "ld2w", SHORT_2, 1, MU, PAR|RMEM, 0x6201, 0x7e21, { RDSTE, ATSIGN, RSRC, PLUS } },
+ { "ld2w", SHORT_2, 1, MU, PAR|RMEM, 0x6200, 0x7e21, { RDSTE, ATSIGN, RSRC } },
+ { "ldb", LONG_L, 1, MU, SEQ, 0x38000000, 0x3f000000, { RDST, ATPAR, NUM16, RSRC } },
+ { "ldb", SHORT_2, 1, MU, PAR|RMEM, 0x7000, 0x7e01, { RDST, ATSIGN, RSRC } },
+ { "ldi", OPCODE_FAKE, 0, 0, 0, 0, 0, { 1, 4, 16, 0 } },
+ { "ldi.s", SHORT_2, 1, EITHER, PAR|RMEM, 0x4001, 0x7e01 , { RDST, NUM4 } },
+ { "ldi.l", LONG_L, 1, MU, SEQ, 0x20000000, 0x3f0f0000, { RDST, NUM16 } },
+ { "ldub", LONG_L, 1, MU, SEQ, 0x39000000, 0x3f000000, { RDST, ATPAR, NUM16, RSRC } },
+ { "ldub", SHORT_2, 1, MU, PAR|RMEM, 0x7200, 0x7e01, { RDST, ATSIGN, RSRC } },
+ { "mac", SHORT_2, 1, IU, PAR, 0x2a00, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "macsu", SHORT_2, 1, IU, PAR, 0x1a00, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "macu", SHORT_2, 1, IU, PAR, 0x3a00, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "max", SHORT_2, 1, IU, PAR|WF0, 0x2600, 0x7e01, { RDST, RSRC } },
+ { "max", SHORT_2, 1, IU, PAR|WF0, 0x3600, 0x7ee3, { ADST, RSRCE } },
+ { "max", SHORT_2, 1, IU, PAR|WF0, 0x3602, 0x7eef, { ADST, ASRC } },
+ { "min", SHORT_2, 1, IU, PAR|WF0, 0x2601, 0x7e01 , { RDST, RSRC } },
+ { "min", SHORT_2, 1, IU, PAR|WF0, 0x3601, 0x7ee3 , { ADST, RSRCE } },
+ { "min", SHORT_2, 1, IU, PAR|WF0, 0x3603, 0x7eef, { ADST, ASRC } },
+ { "msb", SHORT_2, 1, IU, PAR, 0x2800, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "msbsu", SHORT_2, 1, IU, PAR, 0x1800, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "msbu", SHORT_2, 1, IU, PAR, 0x3800, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "mul", SHORT_2, 1, IU, PAR, 0x2e00, 0x7e01 , { RDST, RSRC } },
+ { "mulx", SHORT_2, 1, IU, PAR, 0x2c00, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "mulxsu", SHORT_2, 1, IU, PAR, 0x1c00, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "mulxu", SHORT_2, 1, IU, PAR, 0x3c00, 0x7e00, { ADST0, RSRC2, RSRC } },
+ { "mv", SHORT_2, 1, EITHER, PAR, 0x4000, 0x7e01, { RDST, RSRC } },
+ { "mv2w", SHORT_2, 1, IU, PAR, 0x5000, 0x7e23, { RDSTE, RSRCE } },
+ { "mv2wfac", SHORT_2, 1, IU, PAR, 0x3e00, 0x7e2f, { RDSTE, ASRC } },
+ { "mv2wtac", SHORT_2, 1, IU, PAR, 0x3e01, 0x7ee3, { RSRCE, ADST } },
+ { "mvac", SHORT_2, 1, IU, PAR, 0x3e03, 0x7eef, { ADST, ASRC } },
+ { "mvb", SHORT_2, 1, IU, PAR, 0x5400, 0x7e01, { RDST, RSRC } },
+ { "mvf0f", SHORT_2, 1, EITHER, PAR|RF0, 0x4400, 0x7e01, { RDST, RSRC } },
+ { "mvf0t", SHORT_2, 1, EITHER, PAR|RF0, 0x4401, 0x7e01, { RDST, RSRC } },
+ { "mvfacg", SHORT_2, 1, IU, PAR, 0x1e04, 0x7e0f, { RDST, ASRC } },
+ { "mvfachi", SHORT_2, 1, IU, PAR, 0x1e00, 0x7e0f, { RDST, ASRC } },
+ { "mvfaclo", SHORT_2, 1, IU, PAR, 0x1e02, 0x7e0f, { RDST, ASRC } },
+ { "mvfc", SHORT_2, 1, MU, PAR, 0x5200, 0x7e01, { RDST, CSRC } },
+ { "mvtacg", SHORT_2, 1, IU, PAR, 0x1e41, 0x7ee1, { RSRC, ADST } },
+ { "mvtachi", SHORT_2, 1, IU, PAR, 0x1e01, 0x7ee1, { RSRC, ADST } },
+ { "mvtaclo", SHORT_2, 1, IU, PAR, 0x1e21, 0x7ee1, { RSRC, ADST } },
+ { "mvtc", SHORT_2, 1, MU, PAR, 0x5600, 0x7e01, { RSRC, CDST } },
+ { "mvub", SHORT_2, 1, IU, PAR, 0x5401, 0x7e01, { RDST, RSRC } },
+ { "neg", SHORT_2, 1, EITHER, PAR, 0x4605, 0x7e1f, { RDST } },
+ { "neg", SHORT_2, 1, IU, PAR, 0x5605, 0x7eff, { ADST } },
+ { "nop", SHORT_2, 1, EITHER, PAR, 0x5e00, 0x7fff, { 0 } },
+ { "not", SHORT_2, 1, EITHER, PAR, 0x4603, 0x7e1f, { RDST } },
+ { "or", SHORT_2, 1, EITHER, PAR, 0x800, 0x7e01, { RDST, RSRC } },
+ { "or3", LONG_L, 1, MU, SEQ, 0x4000000, 0x3f000000, { RDST, RSRC, NUM16 } },
+ { "rac", SHORT_2, 1, IU, PAR|WF0, 0x5201, 0x7e21, { RDSTE, ASRC0ONLY, NUM3 } },
+ { "rachi", SHORT_2, 1, IU, PAR|WF0, 0x4201, 0x7e01, { RDST, ASRC, NUM3 } },
+ { "rep", LONG_L, 2, MU, SEQ, 0x27000000, 0x3ff00000, { RSRC, ANUM16 } },
+ { "repi", LONG_L, 2, MU, SEQ, 0x2f000000, 0x3f000000, { UNUM8, ANUM16 } },
+ { "rtd", SHORT_2, 3, MU, PAR, 0x5f60, 0x7fff, { 0 } },
+ { "rte", SHORT_2, 3, MU, PAR, 0x5f40, 0x7fff, { 0 } },
+ { "sadd", SHORT_2, 1, IU, PAR, 0x1223, 0x7eef, { ADST, ASRC } },
+ { "setf0f", SHORT_2, 1, MU, PAR|RF0, 0x4611, 0x7e1f, { RDST } },
+ { "setf0t", SHORT_2, 1, MU, PAR|RF0, 0x4613, 0x7e1f, { RDST } },
+ { "sleep", SHORT_2, 1, MU, PAR, 0x5fc0, 0x7fff, { 0 } },
+ { "sll", SHORT_2, 1, IU, PAR, 0x2200, 0x7e01, { RDST, RSRC } },
+ { "sll", SHORT_2, 1, IU, PAR, 0x3200, 0x7ee1, { ADST, RSRC } },
+ { "slli", SHORT_2, 1, IU, PAR, 0x2201, 0x7e01, { RDST, UNUM4 } },
+ { "slli", SHORT_2, 1, IU, PAR, 0x3201, 0x7ee1, { ADST, UNUM4S } },
+ { "slx", SHORT_2, 1, IU, PAR|RF0, 0x460b, 0x7e1f, { RDST } },
+ { "sra", SHORT_2, 1, IU, PAR, 0x2400, 0x7e01, { RDST, RSRC } },
+ { "sra", SHORT_2, 1, IU, PAR, 0x3400, 0x7ee1, { ADST, RSRC } },
+ { "srai", SHORT_2, 1, IU, PAR, 0x2401, 0x7e01, { RDST, UNUM4 } },
+ { "srai", SHORT_2, 1, IU, PAR, 0x3401, 0x7ee1, { ADST, UNUM4S } },
+ { "srl", SHORT_2, 1, IU, PAR, 0x2000, 0x7e01, { RDST, RSRC } },
+ { "srl", SHORT_2, 1, IU, PAR, 0x3000, 0x7ee1, { ADST, RSRC } },
+ { "srli", SHORT_2, 1, IU, PAR, 0x2001, 0x7e01, { RDST, UNUM4 } },
+ { "srli", SHORT_2, 1, IU, PAR, 0x3001, 0x7ee1, { ADST, UNUM4S } },
+ { "srx", SHORT_2, 1, IU, PAR|RF0, 0x4609, 0x7e1f, { RDST } },
+ { "st", LONG_L, 1, MU, SEQ, 0x34000000, 0x3f000000, { RSRC2, ATPAR, NUM16, RSRC } },
+ { "st", SHORT_2, 1, MU, PAR|WMEM, 0x6800, 0x7e01, { RSRC2, ATSIGN, RSRC } },
+ { "st", SHORT_2, 1, MU, PAR|WMEM, 0x6c1f, 0x7e1f, { RSRC2, ATMINUS, RSRC } },
+ { "st", SHORT_2, 1, MU, PAR|WMEM, 0x6801, 0x7e01, { RSRC2, ATSIGN, RSRC, PLUS } },
+ { "st", SHORT_2, 1, MU, PAR|WMEM, 0x6c01, 0x7e01, { RSRC2, ATSIGN, RSRC, MINUS } },
+ { "st2w", LONG_L, 1, MU, SEQ, 0x35000000, 0x3f100000, { RSRC2E, ATPAR, NUM16, RSRC } },
+ { "st2w", SHORT_2, 1, MU, PAR|WMEM, 0x6a00, 0x7e21, { RSRC2E, ATSIGN, RSRC } },
+ { "st2w", SHORT_2, 1, MU, PAR|WMEM, 0x6e1f, 0x7e3f, { RSRC2E, ATMINUS, RSRC } },
+ { "st2w", SHORT_2, 1, MU, PAR|WMEM, 0x6a01, 0x7e21, { RSRC2E, ATSIGN, RSRC, PLUS } },
+ { "st2w", SHORT_2, 1, MU, PAR|WMEM, 0x6e01, 0x7e21, { RSRC2E, ATSIGN, RSRC, MINUS } },
+ { "stb", LONG_L, 1, MU, SEQ, 0x3c000000, 0x3f000000, { RSRC2, ATPAR, NUM16, RSRC } },
+ { "stb", SHORT_2, 1, MU, PAR|WMEM, 0x7800, 0x7e01, { RSRC2, ATSIGN, RSRC } },
+ { "stop", SHORT_2, 1, MU, PAR, 0x5fe0, 0x7fff, { 0 } },
+ { "sub", SHORT_2, 1, EITHER, PAR|WCAR, 0x0, 0x7e01, { RDST, RSRC } },
+ { "sub", SHORT_2, 1, IU, PAR, 0x1001, 0x7ee3, { ADST, RSRC } },
+ { "sub", SHORT_2, 1, IU, PAR, 0x1003, 0x7eef, { ADST, ASRC } },
+ { "sub2w", SHORT_2, 1, IU, PAR|WCAR, 0x1000, 0x7e23, { RDSTE, RSRCE } },
+ { "subac3", LONG_R, 1, IU, SEQ, 0x17000000, 0x3ffffe22, { RDSTE, RSRCE, ASRC0 } },
+ { "subac3", LONG_R, 1, IU, SEQ, 0x17000002, 0x3ffffe2e, { RDSTE, ASRC, ASRC0 } },
+ { "subac3s", LONG_R, 1, IU, SEQ, 0x17001000, 0x3ffffe22, { RDSTE, RSRCE, ASRC0 } },
+ { "subac3s", LONG_R, 1, IU, SEQ, 0x17001002, 0x3ffffe2e, { RDSTE, ASRC, ASRC0 } },
+ { "subi", SHORT_2, 1, EITHER, PAR, 0x1, 0x7e01, { RDST, UNUM4S } },
+ { "trap", SHORT_2, 5, MU, BRANCH_LINK|PAR, 0x5f00, 0x7fe1, { UNUM4 } },
+ { "tst0i", LONG_L, 1, MU, SEQ, 0x7000000, 0x3f0f0000, { RSRC2, NUM16 } },
+ { "tst1i", LONG_L, 1, MU, SEQ, 0xf000000, 0x3f0f0000, { RSRC2, NUM16 } },
+ { "wait", SHORT_2, 1, MU, PAR, 0x5f80, 0x7fff, { 0 } },
+ { "xor", SHORT_2, 1, EITHER, PAR, 0xa00, 0x7e01, { RDST, RSRC } },
+ { "xor3", LONG_L, 1, MU, SEQ, 0x5000000, 0x3f000000, { RDST, RSRC, NUM16 } },
+ { 0, 0, 0, 0, 0, 0, 0, { 0 } },
+};
+
+
diff --git a/opcodes/d30v-dis.c b/opcodes/d30v-dis.c
new file mode 100644
index 00000000000..9358b753235
--- /dev/null
+++ b/opcodes/d30v-dis.c
@@ -0,0 +1,399 @@
+/* Disassemble D30V instructions.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include "opcode/d30v.h"
+#include "dis-asm.h"
+#include "opintl.h"
+
+#define PC_MASK 0xFFFFFFFF
+
+static int lookup_opcode PARAMS (( struct d30v_insn *insn, long num, int is_long ));
+static void print_insn PARAMS (( struct disassemble_info *info, bfd_vma memaddr, long long num,
+ struct d30v_insn *insn, int is_long, int show_ext ));
+static int extract_value PARAMS (( long long num, struct d30v_operand *oper, int is_long ));
+
+int
+print_insn_d30v (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int status, result;
+ bfd_byte buffer[12];
+ unsigned long in1,in2;
+ struct d30v_insn insn;
+ long long num;
+
+ insn.form = (struct d30v_format *)NULL;
+
+ info->bytes_per_line = 8;
+ info->bytes_per_chunk = 4;
+ info->display_endian = BFD_ENDIAN_BIG;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ in1 = bfd_getb32 (buffer);
+
+ status = (*info->read_memory_func) (memaddr+4, buffer, 4, info);
+ if (status != 0)
+ {
+ info->bytes_per_line = 8;
+ if (!(result = lookup_opcode(&insn, in1, 0)))
+ (*info->fprintf_func) (info->stream, ".long\t0x%x",in1);
+ else
+ print_insn(info, memaddr, (long long) in1, &insn, 0, result);
+ return 4;
+ }
+ in2 = bfd_getb32 (buffer);
+
+ if (in1 & in2 & FM01)
+ {
+ /* LONG instruction */
+ if (!(result = lookup_opcode(&insn, in1, 1)))
+ {
+ (*info->fprintf_func) (info->stream, ".long\t0x%x,0x%x",in1,in2);
+ return 8;
+ }
+ num = (long long)in1 << 32 | in2;
+ print_insn(info, memaddr, num, &insn, 1, result);
+ }
+ else
+ {
+ num = in1;
+ if (!(result = lookup_opcode(&insn, in1, 0)))
+ (*info->fprintf_func) (info->stream, ".long\t0x%x",in1);
+ else
+ print_insn(info, memaddr, num, &insn, 0, result);
+
+ switch ( ((in1>>31)<<1) | (in2>>31) )
+ {
+ case 0:
+ (*info->fprintf_func) (info->stream, "\t||\t");
+ break;
+ case 1:
+ (*info->fprintf_func) (info->stream, "\t->\t");
+ break;
+ case 2:
+ (*info->fprintf_func) (info->stream, "\t<-\t");
+ default:
+ break;
+ }
+
+ insn.form = (struct d30v_format *)NULL;
+ num = in2;
+ if (!(result = lookup_opcode(&insn, in2, 0)))
+ (*info->fprintf_func) (info->stream, ".long\t0x%x",in2);
+ else
+ print_insn(info, memaddr, num, &insn, 0, result);
+
+ }
+ return 8;
+}
+
+
+/* returns 0 if lookup fails */
+/* 1 if found and only one form */
+/* 2 if found and there are short and long forms */
+static int
+lookup_opcode (insn, num, is_long)
+ struct d30v_insn *insn;
+ long num;
+ int is_long;
+{
+ int i=0, index;
+ struct d30v_format *f;
+ struct d30v_opcode *op = (struct d30v_opcode *)d30v_opcode_table;
+ int op1 = (num >> 25) & 0x7;
+ int op2 = (num >> 20) & 0x1f;
+ int mod = (num >> 18) & 0x3;
+
+ /* find the opcode */
+ do {
+ if ((op->op1 == op1) && (op->op2 == op2))
+ break;
+ op++;
+ } while (op->name);
+
+ if (!op || !op->name)
+ return 0;
+
+ while (op->op1 == op1 && op->op2 == op2)
+ {
+ /* scan through all the formats for the opcode */
+ index = op->format[i++];
+ do
+ {
+ f = (struct d30v_format *)&d30v_format_table[index];
+ while (f->form == index)
+ {
+ if ((!is_long || f->form >= LONG) && (f->modifier == mod))
+ {
+ insn->form = f;
+ break;
+ }
+ f++;
+ }
+ if (insn->form)
+ break;
+ } while ((index = op->format[i++]) != 0);
+ if (insn->form)
+ break;
+ op++;
+ i=0;
+ }
+ if (insn->form == NULL)
+ return 0;
+
+ insn->op = op;
+ insn->ecc = (num >> 28) & 0x7;
+ if (op->format[1])
+ return 2;
+ else
+ return 1;
+}
+
+
+static void
+print_insn ( info, memaddr, num, insn, is_long, show_ext )
+ struct disassemble_info *info;
+ bfd_vma memaddr;
+ long long num;
+ struct d30v_insn *insn;
+ int is_long;
+ int show_ext;
+{
+ int val, opnum, need_comma=0;
+ struct d30v_operand *oper;
+ int i, match, opind=0, need_paren=0, found_control=0;
+
+ (*info->fprintf_func) (info->stream, "%s",insn->op->name);
+
+ /* check for CMP or CMPU */
+ if (d30v_operand_table[insn->form->operands[0]].flags & OPERAND_NAME)
+ {
+ opind++;
+ val = extract_value(num,(struct d30v_operand *)&d30v_operand_table[insn->form->operands[0]],is_long);
+ (*info->fprintf_func) (info->stream, "%s",d30v_cc_names[val]);
+ }
+
+ /* add in ".s" or ".l" */
+ if (show_ext == 2)
+ {
+ if (is_long)
+ (*info->fprintf_func) (info->stream, ".l");
+ else
+ (*info->fprintf_func) (info->stream, ".s");
+ }
+
+ if (insn->ecc)
+ (*info->fprintf_func) (info->stream, "/%s",d30v_ecc_names[insn->ecc]);
+
+ (*info->fprintf_func) (info->stream, "\t");
+
+ while ((opnum = insn->form->operands[opind++]) != 0)
+ {
+ int bits;
+ oper = (struct d30v_operand *)&d30v_operand_table[opnum];
+ bits = oper->bits;
+ if (oper->flags & OPERAND_SHIFT)
+ bits += 3;
+
+ if (need_comma && oper->flags != OPERAND_PLUS && oper->flags != OPERAND_MINUS)
+ {
+ need_comma=0;
+ (*info->fprintf_func) (info->stream, ", ");
+ }
+
+ if (oper->flags == OPERAND_ATMINUS)
+ {
+ (*info->fprintf_func) (info->stream, "@-");
+ continue;
+ }
+ if (oper->flags == OPERAND_MINUS)
+ {
+ (*info->fprintf_func) (info->stream, "-");
+ continue;
+ }
+ if (oper->flags == OPERAND_PLUS)
+ {
+ (*info->fprintf_func) (info->stream, "+");
+ continue;
+ }
+ if (oper->flags == OPERAND_ATSIGN)
+ {
+ (*info->fprintf_func) (info->stream, "@");
+ continue;
+ }
+ if (oper->flags == OPERAND_ATPAR)
+ {
+ (*info->fprintf_func) (info->stream, "@(");
+ need_paren = 1;
+ continue;
+ }
+
+ if (oper->flags == OPERAND_SPECIAL)
+ continue;
+
+ val = extract_value(num, oper, is_long);
+
+ if (oper->flags & OPERAND_REG)
+ {
+ match = 0;
+ if (oper->flags & OPERAND_CONTROL)
+ {
+ struct d30v_operand *oper3 =
+ (struct d30v_operand *)&d30v_operand_table[insn->form->operands[2]];
+ int id = extract_value (num, oper3, is_long );
+ found_control = 1;
+ switch ( id )
+ {
+ case 0:
+ val |= OPERAND_CONTROL;
+ break;
+ case 1:
+ case 2:
+ val = OPERAND_CONTROL + MAX_CONTROL_REG + id;
+ break;
+ case 3:
+ val |= OPERAND_FLAG;
+ break;
+ default:
+ fprintf(stderr,"illegal id (%d)\n",id);
+ }
+ }
+ else if (oper->flags & OPERAND_ACC)
+ val |= OPERAND_ACC;
+ else if (oper->flags & OPERAND_FLAG)
+ val |= OPERAND_FLAG;
+ for (i=0;i<reg_name_cnt();i++)
+ {
+ if (val == pre_defined_registers[i].value)
+ {
+ if (pre_defined_registers[i].pname)
+ (*info->fprintf_func)
+ (info->stream, "%s",pre_defined_registers[i].pname);
+ else
+ (*info->fprintf_func)
+ (info->stream, "%s",pre_defined_registers[i].name);
+ match=1;
+ break;
+ }
+ }
+ if (match==0)
+ {
+ /* this would only get executed if a register was not in the
+ register table */
+ (*info->fprintf_func)
+ (info->stream, _("<unknown register %d>"), val & 0x3F);
+ }
+ }
+ else if (insn->op->reloc_flag == RELOC_PCREL ||
+ (opind == 1 && (insn->form->form == SHORT_D2 || insn->form->form == LONG_D)))
+ {
+ long max;
+ int neg=0;
+ max = (1 << (bits - 1));
+ if (val & max)
+ {
+ if (bits == 32)
+ val = -val;
+ else
+ val = -val & ((1 << bits)-1);
+ neg = 1;
+ }
+ if (opind == 1 && (insn->form->form == SHORT_D2 || insn->form->form == LONG_D))
+ {
+ (*info->fprintf_func) (info->stream, "%x",val);
+ }
+ else {
+ if (neg)
+ {
+ (*info->fprintf_func) (info->stream, "-%x\t(",val);
+ (*info->print_address_func) ((memaddr - val) & PC_MASK, info);
+ (*info->fprintf_func) (info->stream, ")");
+ }
+ else
+ {
+ (*info->fprintf_func) (info->stream, "%x\t(",val);
+ (*info->print_address_func) ((memaddr + val) & PC_MASK, info);
+ (*info->fprintf_func) (info->stream, ")");
+ }
+ }
+ }
+ else if (insn->op->reloc_flag == RELOC_ABS)
+ {
+ (*info->print_address_func) (val, info);
+ }
+ else
+ {
+ if (oper->flags & OPERAND_SIGNED)
+ {
+ int max = (1 << (bits - 1));
+ if (val & max)
+ {
+ val = -val;
+ if (bits < 32)
+ val &= ((1 << bits) - 1);
+ (*info->fprintf_func) (info->stream, "-");
+ }
+ }
+ (*info->fprintf_func) (info->stream, "0x%x",val);
+ }
+ /* if there is another operand, then write a comma and space */
+ if (insn->form->operands[opind] && !(found_control && opind == 2))
+ need_comma = 1;
+ }
+ if (need_paren)
+ (*info->fprintf_func) (info->stream, ")");
+}
+
+
+
+static int
+extract_value (num, oper, is_long)
+ long long num;
+ struct d30v_operand *oper;
+ int is_long;
+{
+ int val;
+ int shift = 12 - oper->position;
+ int mask = (0xFFFFFFFF >> (32 - oper->bits));
+
+ if (is_long)
+ {
+ if (oper->bits == 32)
+ {
+ /* piece together 32-bit constant */
+ val = ((num & 0x3FFFF)
+ | ((num & 0xFF00000) >> 2)
+ | ((num & 0x3F00000000LL) >> 6));
+ }
+ else
+ val = (num >> (32 + shift)) & mask;
+ }
+ else
+ val = (num >> shift) & mask;
+
+ if (oper->flags & OPERAND_SHIFT)
+ val <<= 3;
+
+ return val;
+}
diff --git a/opcodes/d30v-opc.c b/opcodes/d30v-opc.c
new file mode 100644
index 00000000000..2265e7cf81f
--- /dev/null
+++ b/opcodes/d30v-opc.c
@@ -0,0 +1,500 @@
+/* d30v-opc.c -- D30V opcode list
+ Copyright 1997, 1998 Free Software Foundation, Inc.
+ Written by Martin Hunt, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+2, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/d30v.h"
+
+
+/* This table is sorted. */
+/* If you add anything, it MUST be in alphabetical order */
+/* The first field is the name the assembler uses when looking */
+/* up orcodes. The second field is the name the disassembler will use. */
+/* This allows the assembler to assemble references to r63 (for example) */
+/* or "sp". The disassembler will always use the preferred form (sp) */
+const struct pd_reg pre_defined_registers[] =
+{
+ { "a0", NULL, OPERAND_ACC+0 },
+ { "a1", NULL, OPERAND_ACC+1 },
+ { "bpc", NULL, OPERAND_CONTROL+3 },
+ { "bpsw", NULL, OPERAND_CONTROL+1 },
+ { "c", "c", OPERAND_FLAG+7 },
+ { "cr0", "psw", OPERAND_CONTROL },
+ { "cr1", "bpsw", OPERAND_CONTROL+1 },
+ { "cr10", "mod_s", OPERAND_CONTROL+10 },
+ { "cr11", "mod_e", OPERAND_CONTROL+11 },
+ { "cr12", NULL, OPERAND_CONTROL+12 },
+ { "cr13", NULL, OPERAND_CONTROL+13 },
+ { "cr14", "iba", OPERAND_CONTROL+14 },
+ { "cr15", "eit_vb", OPERAND_CONTROL+15 },
+ { "cr16", "int_s", OPERAND_CONTROL+16 },
+ { "cr17", "int_m", OPERAND_CONTROL+17 },
+ { "cr18", NULL, OPERAND_CONTROL+18 },
+ { "cr19", NULL, OPERAND_CONTROL+19 },
+ { "cr2", "pc", OPERAND_CONTROL+2 },
+ { "cr20", NULL, OPERAND_CONTROL+20 },
+ { "cr21", NULL, OPERAND_CONTROL+21 },
+ { "cr22", NULL, OPERAND_CONTROL+22 },
+ { "cr23", NULL, OPERAND_CONTROL+23 },
+ { "cr24", NULL, OPERAND_CONTROL+24 },
+ { "cr25", NULL, OPERAND_CONTROL+25 },
+ { "cr26", NULL, OPERAND_CONTROL+26 },
+ { "cr27", NULL, OPERAND_CONTROL+27 },
+ { "cr28", NULL, OPERAND_CONTROL+28 },
+ { "cr29", NULL, OPERAND_CONTROL+29 },
+ { "cr3", "bpc", OPERAND_CONTROL+3 },
+ { "cr30", NULL, OPERAND_CONTROL+30 },
+ { "cr31", NULL, OPERAND_CONTROL+31 },
+ { "cr32", NULL, OPERAND_CONTROL+32 },
+ { "cr33", NULL, OPERAND_CONTROL+33 },
+ { "cr34", NULL, OPERAND_CONTROL+34 },
+ { "cr35", NULL, OPERAND_CONTROL+35 },
+ { "cr36", NULL, OPERAND_CONTROL+36 },
+ { "cr37", NULL, OPERAND_CONTROL+37 },
+ { "cr38", NULL, OPERAND_CONTROL+38 },
+ { "cr39", NULL, OPERAND_CONTROL+39 },
+ { "cr4", "dpsw", OPERAND_CONTROL+4 },
+ { "cr40", NULL, OPERAND_CONTROL+40 },
+ { "cr41", NULL, OPERAND_CONTROL+41 },
+ { "cr42", NULL, OPERAND_CONTROL+42 },
+ { "cr43", NULL, OPERAND_CONTROL+43 },
+ { "cr44", NULL, OPERAND_CONTROL+44 },
+ { "cr45", NULL, OPERAND_CONTROL+45 },
+ { "cr46", NULL, OPERAND_CONTROL+46 },
+ { "cr47", NULL, OPERAND_CONTROL+47 },
+ { "cr48", NULL, OPERAND_CONTROL+48 },
+ { "cr49", NULL, OPERAND_CONTROL+49 },
+ { "cr5","dpc", OPERAND_CONTROL+5 },
+ { "cr50", NULL, OPERAND_CONTROL+50 },
+ { "cr51", NULL, OPERAND_CONTROL+51 },
+ { "cr52", NULL, OPERAND_CONTROL+52 },
+ { "cr53", NULL, OPERAND_CONTROL+53 },
+ { "cr54", NULL, OPERAND_CONTROL+54 },
+ { "cr55", NULL, OPERAND_CONTROL+55 },
+ { "cr56", NULL, OPERAND_CONTROL+56 },
+ { "cr57", NULL, OPERAND_CONTROL+57 },
+ { "cr58", NULL, OPERAND_CONTROL+58 },
+ { "cr59", NULL, OPERAND_CONTROL+59 },
+ { "cr6", NULL, OPERAND_CONTROL+6 },
+ { "cr60", NULL, OPERAND_CONTROL+60 },
+ { "cr61", NULL, OPERAND_CONTROL+61 },
+ { "cr62", NULL, OPERAND_CONTROL+62 },
+ { "cr63", NULL, OPERAND_CONTROL+63 },
+ { "cr7", "rpt_c", OPERAND_CONTROL+7 },
+ { "cr8", "rpt_s", OPERAND_CONTROL+8 },
+ { "cr9", "rpt_e", OPERAND_CONTROL+9 },
+ { "dpc", NULL, OPERAND_CONTROL+5 },
+ { "dpsw", NULL, OPERAND_CONTROL+4 },
+ { "eit_vb", NULL, OPERAND_CONTROL+15 },
+ { "f0", NULL, OPERAND_FLAG+0 },
+ { "f1", NULL, OPERAND_FLAG+1 },
+ { "f2", NULL, OPERAND_FLAG+2 },
+ { "f3", NULL, OPERAND_FLAG+3 },
+ { "f4", "s", OPERAND_FLAG+4 },
+ { "f5", "v", OPERAND_FLAG+5 },
+ { "f6", "va", OPERAND_FLAG+6 },
+ { "f7", "c", OPERAND_FLAG+7 },
+ { "iba", NULL, OPERAND_CONTROL+14 },
+ { "int_m", NULL, OPERAND_CONTROL+17 },
+ { "int_s", NULL, OPERAND_CONTROL+16 },
+ { "link", "r62", 62 },
+ { "mod_e", NULL, OPERAND_CONTROL+11 },
+ { "mod_s", NULL, OPERAND_CONTROL+10 },
+ { "pc", NULL, OPERAND_CONTROL+2 },
+ { "psw", NULL, OPERAND_CONTROL },
+ { "pswh", NULL, OPERAND_CONTROL+MAX_CONTROL_REG+2 },
+ { "pswl", NULL, OPERAND_CONTROL+MAX_CONTROL_REG+1 },
+ { "r0", NULL, 0 },
+ { "r1", NULL, 1 },
+ { "r10", NULL, 10 },
+ { "r11", NULL, 11 },
+ { "r12", NULL, 12 },
+ { "r13", NULL, 13 },
+ { "r14", NULL, 14 },
+ { "r15", NULL, 15 },
+ { "r16", NULL, 16 },
+ { "r17", NULL, 17 },
+ { "r18", NULL, 18 },
+ { "r19", NULL, 19 },
+ { "r2", NULL, 2 },
+ { "r20", NULL, 20 },
+ { "r21", NULL, 21 },
+ { "r22", NULL, 22 },
+ { "r23", NULL, 23 },
+ { "r24", NULL, 24 },
+ { "r25", NULL, 25 },
+ { "r26", NULL, 26 },
+ { "r27", NULL, 27 },
+ { "r28", NULL, 28 },
+ { "r29", NULL, 29 },
+ { "r3", NULL, 3 },
+ { "r30", NULL, 30 },
+ { "r31", NULL, 31 },
+ { "r32", NULL, 32 },
+ { "r33", NULL, 33 },
+ { "r34", NULL, 34 },
+ { "r35", NULL, 35 },
+ { "r36", NULL, 36 },
+ { "r37", NULL, 37 },
+ { "r38", NULL, 38 },
+ { "r39", NULL, 39 },
+ { "r4", NULL, 4 },
+ { "r40", NULL, 40 },
+ { "r41", NULL, 41 },
+ { "r42", NULL, 42 },
+ { "r43", NULL, 43 },
+ { "r44", NULL, 44 },
+ { "r45", NULL, 45 },
+ { "r46", NULL, 46 },
+ { "r47", NULL, 47 },
+ { "r48", NULL, 48 },
+ { "r49", NULL, 49 },
+ { "r5", NULL, 5 },
+ { "r50", NULL, 50 },
+ { "r51", NULL, 51 },
+ { "r52", NULL, 52 },
+ { "r53", NULL, 53 },
+ { "r54", NULL, 54 },
+ { "r55", NULL, 55 },
+ { "r56", NULL, 56 },
+ { "r57", NULL, 57 },
+ { "r58", NULL, 58 },
+ { "r59", NULL, 59 },
+ { "r6", NULL, 6 },
+ { "r60", NULL, 60 },
+ { "r61", NULL, 61 },
+ { "r62", "link", 62 },
+ { "r63", "sp", 63 },
+ { "r7", NULL, 7 },
+ { "r8", NULL, 8 },
+ { "r9", NULL, 9 },
+ { "rpt_c", NULL, OPERAND_CONTROL+7 },
+ { "rpt_e", NULL, OPERAND_CONTROL+9 },
+ { "rpt_s", NULL, OPERAND_CONTROL+8 },
+ { "s", NULL, OPERAND_FLAG+4 },
+ { "sp", NULL, 63 },
+ { "v", NULL, OPERAND_FLAG+5 },
+ { "va", NULL, OPERAND_FLAG+6 },
+};
+
+int
+reg_name_cnt()
+{
+ return (sizeof(pre_defined_registers) / sizeof(struct pd_reg));
+}
+
+/* OPCODE TABLE */
+/* The format of this table is defined in opcode/d30v.h */
+const struct d30v_opcode d30v_opcode_table[] = {
+ { "abs", IALU1, 0x8, { SHORT_U }, EITHER, 0, 0, 0 },
+ { "add", IALU1, 0x0, { SHORT_A, LONG}, EITHER, 0, FLAG_CVVA, 0 },
+ { "add2h", IALU1, 0x1, { SHORT_A, LONG}, EITHER, 0, 0, 0 },
+ { "addc", IALU1, 0x4, { SHORT_A, LONG }, EITHER, FLAG_C, FLAG_CVVA, 0 },
+ { "addhlll", IALU1, 0x10, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhllh", IALU1, 0x11, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhlhl", IALU1, 0x12, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhlhh", IALU1, 0x13, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhhll", IALU1, 0x14, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhhlh", IALU1, 0x15, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhhhl", IALU1, 0x16, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "addhhhh", IALU1, 0x17, { SHORT_A, LONG }, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "adds", IALU1, 0x6, { SHORT_A, LONG }, EITHER, 0, FLAG_CVVA, 0 },
+ { "adds2h", IALU1, 0x7, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "and", LOGIC, 0x18, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "andfg", LOGIC, 0x8, { SHORT_F }, EITHER, 0, 0, 0 },
+ { "avg", IALU1, 0xa, { SHORT_A, LONG}, EITHER, 0, 0, 0 },
+ { "avg2h", IALU1, 0xb, { SHORT_A, LONG}, EITHER, 0, 0, 0 },
+ { "bclr", LOGIC, 0x3, { SHORT_A }, EITHER_BUT_PREFER_MU, 0, 0, 0 },
+ { "bnot", LOGIC, 0x1, { SHORT_A }, EITHER_BUT_PREFER_MU, 0, 0, 0 },
+ { "bra", BRA, 0, { SHORT_B1, SHORT_B2, LONG_U }, MU, FLAG_JMP, 0, RELOC_PCREL },
+ { "bratnz", BRA, 0x4, { SHORT_B3b, LONG_2b }, MU, FLAG_JMP, 0, RELOC_PCREL },
+ { "bratzr", BRA, 0x4, { SHORT_B3, LONG_2 }, MU, FLAG_JMP, 0, RELOC_PCREL },
+ { "bset", LOGIC, 0x2, { SHORT_A }, EITHER_BUT_PREFER_MU, 0, 0, 0 },
+ { "bsr", BRA, 0x2, { SHORT_B1, SHORT_B2, LONG_U }, MU, FLAG_JSR, 0, RELOC_PCREL },
+ { "bsrtnz", BRA, 0x6, { SHORT_B3b, LONG_2b }, MU, FLAG_JSR, 0, RELOC_PCREL },
+ { "bsrtzr", BRA, 0x6, { SHORT_B3, LONG_2 }, MU, FLAG_JSR, 0, RELOC_PCREL },
+ { "btst", LOGIC, 0, { SHORT_AF }, EITHER_BUT_PREFER_MU, 0, 0, 0 },
+ { "cmp", LOGIC, 0xC, { SHORT_CMP, LONG_CMP }, EITHER, 0, 0, 0 },
+ { "cmpu", LOGIC, 0xD, { SHORT_CMPU, LONG_CMP }, EITHER, 0, 0, 0 },
+ { "dbra", BRA, 0x10, { SHORT_B3, LONG_2 }, MU, FLAG_JMP | FLAG_DELAY, FLAG_RP, RELOC_PCREL },
+ { "dbrai", BRA, 0x14, { SHORT_D2, LONG_D }, MU, FLAG_JMP | FLAG_DELAY, FLAG_RP, RELOC_PCREL },
+ { "dbsr", BRA, 0x12, { SHORT_B3, LONG_2 }, MU, FLAG_JSR | FLAG_DELAY, FLAG_RP, RELOC_PCREL },
+ { "dbsri", BRA, 0x16, { SHORT_D2, LONG_D }, MU, FLAG_JSR | FLAG_DELAY, FLAG_RP, RELOC_PCREL },
+ { "dbt", BRA, 0xb, { SHORT_NONE }, MU, FLAG_JSR, FLAG_LKR, 0 },
+ { "djmp", BRA, 0x11, { SHORT_B3, LONG_2 }, MU, FLAG_JMP | FLAG_DELAY, FLAG_RP, RELOC_ABS },
+ { "djmpi", BRA, 0x15, { SHORT_D2, LONG_D }, MU, FLAG_JMP | FLAG_DELAY, FLAG_RP, RELOC_ABS },
+ { "djsr", BRA, 0x13, { SHORT_B3, LONG_2 }, MU, FLAG_JSR | FLAG_DELAY, FLAG_RP, RELOC_ABS },
+ { "djsri", BRA, 0x17, { SHORT_D2, LONG_D }, MU, FLAG_JSR | FLAG_DELAY, FLAG_RP, RELOC_ABS },
+ { "jmp", BRA, 0x1, { SHORT_B1, SHORT_B2, LONG_U }, MU, FLAG_JMP, 0, RELOC_ABS },
+ { "jmptnz", BRA, 0x5, { SHORT_B3b, LONG_2b }, MU, FLAG_JMP, 0, RELOC_ABS },
+ { "jmptzr", BRA, 0x5, { SHORT_B3, LONG_2 }, MU, FLAG_JMP, 0, RELOC_ABS },
+ { "joinll", IALU1, 0xC, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "joinlh", IALU1, 0xD, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "joinhl", IALU1, 0xE, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "joinhh", IALU1, 0xF, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "jsr", BRA, 0x3, { SHORT_B1, SHORT_B2, LONG_U }, MU, FLAG_JSR, 0, RELOC_ABS },
+ { "jsrtnz", BRA, 0x7, { SHORT_B3b, LONG_2b }, MU, FLAG_JSR, 0, RELOC_ABS },
+ { "jsrtzr", BRA, 0x7, { SHORT_B3, LONG_2 }, MU, FLAG_JSR, 0, RELOC_ABS },
+ { "ld2h", IMEM, 0x3, { SHORT_M2, LONG_M2 }, MU, FLAG_MEM, 0, 0 },
+ { "ld2w", IMEM, 0x6, { SHORT_M2, LONG_M2 }, MU, FLAG_MEM | FLAG_2WORD, 0, 0 },
+ { "ld4bh", IMEM, 0x5, { SHORT_M2, LONG_M2 }, MU, FLAG_MEM | FLAG_2WORD, 0, 0 },
+ { "ld4bhu", IMEM, 0xd, { SHORT_M2, LONG_M2 }, MU, FLAG_MEM, 0, 0 },
+ { "ldb", IMEM, 0, { SHORT_M, LONG_M }, MU, FLAG_MEM, 0, 0 },
+ { "ldbu", IMEM, 0x9, { SHORT_M, LONG_M }, MU, FLAG_MEM, 0, 0 },
+ { "ldh", IMEM, 0x2, { SHORT_M, LONG_M }, MU, FLAG_MEM, 0, 0 },
+ { "ldhh", IMEM, 0x1, { SHORT_M, LONG_M }, MU, FLAG_MEM, 0, 0 },
+ { "ldhu", IMEM, 0xa, { SHORT_M, LONG_M }, MU, FLAG_MEM, 0, 0 },
+ { "ldw", IMEM, 0x4, { SHORT_M, LONG_M }, MU, FLAG_MEM, 0, 0 },
+ { "mac0", IALU2, 0x14, { SHORT_A }, IU, FLAG_MUL32, 0, 0 },
+ { "mac1", IALU2, 0x14, { SHORT_A1 }, IU, FLAG_MUL32, 0, 0 },
+ { "macs0", IALU2, 0x15, { SHORT_A }, IU, FLAG_MUL32, 0, 0 },
+ { "macs1", IALU2, 0x15, { SHORT_A1 }, IU, FLAG_MUL32, 0, 0 },
+ { "moddec", IMEM, 0x7, { SHORT_MODDEC }, MU, 0, 0, 0 },
+ { "modinc", IMEM, 0x7, { SHORT_MODINC }, MU, 0, 0, 0 },
+ { "msub0", IALU2, 0x16, { SHORT_A }, IU, FLAG_MUL32, 0, 0 },
+ { "msub1", IALU2, 0x16, { SHORT_A1 }, IU, FLAG_MUL32, 0, 0 },
+ { "msubs0", IALU2, 0x17, { SHORT_A }, IU, FLAG_MUL32, 0, 0 },
+ { "msubs1", IALU2, 0x17, { SHORT_A1 }, IU, FLAG_MUL32, 0, 0 },
+ { "mul", IALU2, 0x10, { SHORT_A }, IU, FLAG_MUL32, 0, 0 },
+ { "mul2h", IALU2, 0, { SHORT_A }, IU, FLAG_MUL16, 0, 0 },
+ { "mulhxll", IALU2, 0x4, { SHORT_A }, IU, FLAG_MUL16, 0, 0 },
+ { "mulhxlh", IALU2, 0x5, { SHORT_A }, IU, FLAG_MUL16, 0, 0 },
+ { "mulhxhl", IALU2, 0x6, { SHORT_A }, IU, FLAG_MUL16, 0, 0 },
+ { "mulhxhh", IALU2, 0x7, { SHORT_A }, IU, FLAG_MUL16, 0, 0 },
+ { "mulx", IALU2, 0x18, { SHORT_AA }, IU, FLAG_MUL32, 0, 0 },
+ { "mulx2h", IALU2, 0x1, { SHORT_A2 }, IU, FLAG_MUL16, 0, 0 },
+ { "mulxs", IALU2, 0x19, { SHORT_AA }, IU, FLAG_MUL32, 0, 0 },
+ { "mvfacc", IALU2, 0x1f, { SHORT_RA }, IU, 0, 0, 0 },
+ { "mvfsys", BRA, 0x1e, { SHORT_C1 }, MU, FLAG_ALL, FLAG_ALL, 0 },
+ { "mvtacc", IALU2, 0xf, { SHORT_AA }, IU, 0, 0, 0 },
+ { "mvtsys", BRA, 0xe, { SHORT_C2 }, MU, FLAG_ALL, FLAG_ALL, 0 },
+ { "nop", BRA, 0xF, { SHORT_NONE }, EITHER, 0, 0, 0 },
+ { "not", LOGIC, 0x19, { SHORT_U }, EITHER, 0, 0, 0 },
+ { "notfg", LOGIC, 0x9, { SHORT_UF }, EITHER, 0, 0, 0 },
+ { "or", LOGIC, 0x1a, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "orfg", LOGIC, 0xa, { SHORT_F }, EITHER, 0, 0, 0 },
+ { "reit", BRA, 0x8, { SHORT_NONE }, MU, FLAG_SM | FLAG_JMP, FLAG_SM | FLAG_LKR, 0 },
+ { "repeat", BRA, 0x18, { SHORT_D1, LONG_2 }, MU, FLAG_RP, FLAG_RP, RELOC_PCREL },
+ { "repeati", BRA, 0x1a, { SHORT_D2B, LONG_Db }, MU, FLAG_RP, FLAG_RP, RELOC_PCREL },
+ { "rot", LOGIC, 0x14, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "rot2h", LOGIC, 0x15, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "rtd", BRA, 0xa, { SHORT_NONE }, MU, FLAG_JMP, FLAG_LKR, 0 },
+ { "sat", IALU2, 0x8, { SHORT_A5 }, IU, 0, 0, 0 },
+ { "sat2h", IALU2, 0x9, { SHORT_A5 }, IU, 0, 0, 0 },
+ { "sathl", IALU2, 0x1c, { SHORT_A5 }, IU, FLAG_ADDSUBppp, 0, 0 },
+ { "sathh", IALU2, 0x1d, { SHORT_A5 }, IU, FLAG_ADDSUBppp, 0, 0 },
+ { "satz", IALU2, 0xa, { SHORT_A5 }, IU, 0, 0, 0 },
+ { "satz2h", IALU2, 0xb, { SHORT_A5 }, IU, 0, 0, 0 },
+ { "sra", LOGIC, 0x10, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "sra2h", LOGIC, 0x11, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "srahh", LOGIC, 0x5, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "srahl", LOGIC, 0x4, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "src", LOGIC, 0x16, { SHORT_A }, EITHER, FLAG_ADDSUBppp, 0, 0 },
+ { "srl", LOGIC, 0x12, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "srl2h", LOGIC, 0x13, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "srlhh", LOGIC, 0x7, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "srlhl", LOGIC, 0x6, { SHORT_A }, EITHER, 0, 0, 0 },
+ { "st2h", IMEM, 0x13, { SHORT_M2, LONG_M2 }, MU, 0, FLAG_MEM, 0 },
+ { "st2w", IMEM, 0x16, { SHORT_M2, LONG_M2 }, MU, 0, FLAG_MEM | FLAG_2WORD, 0 },
+ { "st4hb", IMEM, 0x15, { SHORT_M2, LONG_M2 }, MU, 0, FLAG_MEM | FLAG_2WORD, 0 },
+ { "stb", IMEM, 0x10, { SHORT_M, LONG_M }, MU, 0, FLAG_MEM, 0 },
+ { "sth", IMEM, 0x12, { SHORT_M, LONG_M }, MU, 0, FLAG_MEM, 0 },
+ { "sthh", IMEM, 0x11, { SHORT_M, LONG_M }, MU, 0, FLAG_MEM, 0 },
+ { "stw", IMEM, 0x14, { SHORT_M, LONG_M }, MU, 0, FLAG_MEM, 0 },
+ { "sub", IALU1, 0x2, { SHORT_A, LONG}, EITHER, 0, FLAG_CVVA, 0 },
+ { "sub2h", IALU1, 0x3, { SHORT_A, LONG}, EITHER, 0, 0, 0 },
+ { "subb", IALU1, 0x5, { SHORT_A, LONG}, EITHER, FLAG_C, FLAG_CVVA, 0 },
+ { "subhlll", IALU1, 0x18, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhllh", IALU1, 0x19, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhlhl", IALU1, 0x1a, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhlhh", IALU1, 0x1b, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhhll", IALU1, 0x1c, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhhlh", IALU1, 0x1d, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhhhl", IALU1, 0x1e, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "subhhhh", IALU1, 0x1f, { SHORT_A, LONG}, EITHER, FLAG_ADDSUBppp, FLAG_CVVA, 0 },
+ { "trap", BRA, 0x9, { SHORT_B1, SHORT_T}, MU, FLAG_JSR, FLAG_SM | FLAG_LKR, 0 },
+ { "xor", LOGIC, 0x1b, { SHORT_A, LONG }, EITHER, 0, 0, 0 },
+ { "xorfg", LOGIC, 0xb, { SHORT_F }, EITHER, 0, 0, 0 },
+ { NULL, 0, 0, { 0 }, 0, 0, 0, 0 },
+};
+
+
+/* now define the operand types */
+/* format is length, bits, position, flags */
+const struct d30v_operand d30v_operand_table[] =
+{
+#define UNUSED (0)
+ { 0, 0, 0, 0 },
+#define Ra (UNUSED + 1)
+ { 6, 6, 0, OPERAND_REG|OPERAND_DEST },
+#define Ra2 (Ra + 1)
+ { 6, 6, 0, OPERAND_REG|OPERAND_DEST|OPERAND_2REG },
+#define Ra3 (Ra2 + 1)
+ { 6, 6, 0, OPERAND_REG },
+#define Rb (Ra3 + 1)
+ { 6, 6, 6, OPERAND_REG },
+#define Rc (Rb + 1)
+ { 6, 6, 12, OPERAND_REG },
+#define Aa (Rc + 1)
+ { 6, 1, 0, OPERAND_ACC|OPERAND_REG|OPERAND_DEST },
+#define Ab (Aa + 1)
+ { 6, 1, 6, OPERAND_ACC|OPERAND_REG },
+#define IMM5 (Ab + 1)
+ { 6, 5, 12, OPERAND_NUM },
+#define IMM5U (IMM5 + 1)
+ { 6, 5, 12, OPERAND_NUM|OPERAND_SIGNED },
+#define IMM5S3 (IMM5U + 1)
+ { 6, 5, 12, OPERAND_NUM|OPERAND_SIGNED },
+#define IMM6 (IMM5S3 + 1)
+ { 6, 6, 12, OPERAND_NUM|OPERAND_SIGNED },
+#define IMM6U (IMM6 + 1)
+ { 6, 6, 0, OPERAND_NUM },
+#define IMM6U2 (IMM6U + 1)
+ { 6, 6, 12, OPERAND_NUM },
+#define IMM6S3 (IMM6U2 + 1)
+ { 6, 6, 0, OPERAND_NUM|OPERAND_SHIFT },
+#define IMM12S3 (IMM6S3 + 1)
+ { 12, 12, 12, OPERAND_NUM|OPERAND_SIGNED|OPERAND_SHIFT },
+#define IMM12S3U (IMM12S3 + 1)
+ { 12, 12, 12, OPERAND_NUM|OPERAND_SHIFT },
+#define IMM18S3 (IMM12S3U + 1)
+ { 18, 18, 12, OPERAND_NUM|OPERAND_SIGNED|OPERAND_SHIFT },
+#define IMM32 (IMM18S3 + 1)
+ { 32, 32, 0, OPERAND_NUM },
+#define Fa (IMM32 + 1)
+ { 6, 3, 0, OPERAND_REG | OPERAND_FLAG | OPERAND_DEST },
+#define Fb (Fa + 1)
+ { 6, 3, 6, OPERAND_REG | OPERAND_FLAG },
+#define Fc (Fb + 1)
+ { 6, 3, 12, OPERAND_REG | OPERAND_FLAG },
+#define ATSIGN (Fc + 1)
+ { 0, 0, 0, OPERAND_ATSIGN},
+#define ATPAR (ATSIGN + 1) /* "@(" */
+ { 0, 0, 0, OPERAND_ATPAR},
+#define PLUS (ATPAR + 1) /* postincrement */
+ { 0, 0, 0, OPERAND_PLUS},
+#define MINUS (PLUS + 1) /* postdecrement */
+ { 0, 0, 0, OPERAND_MINUS},
+#define ATMINUS (MINUS + 1) /* predecrement */
+ { 0, 0, 0, OPERAND_ATMINUS},
+#define Ca (ATMINUS + 1) /* control register */
+ { 6, 6, 0, OPERAND_REG|OPERAND_CONTROL|OPERAND_DEST},
+#define Cb (Ca + 1) /* control register */
+ { 6, 6, 6, OPERAND_REG|OPERAND_CONTROL},
+#define CC (Cb + 1) /* condition code (CMPcc and CMPUcc) */
+ { 3, 3, -3, OPERAND_NAME},
+#define Fa2 (CC + 1) /* flag register (CMPcc and CMPUcc) */
+ { 3, 3, 0, OPERAND_REG|OPERAND_FLAG|OPERAND_DEST},
+#define Fake (Fa2 + 1) /* place holder for "id" field in mvfsys and mvtsys */
+ { 6, 2, 12, OPERAND_SPECIAL},
+};
+
+/* now we need to define the instruction formats */
+const struct d30v_format d30v_format_table[] =
+{
+ { 0, 0, { 0 } },
+ { SHORT_M, 0, { Ra, ATPAR, Rb, Rc } }, /* Ra,@(Rb,Rc) */
+ { SHORT_M, 1, { Ra, ATPAR, Rb, PLUS, Rc } }, /* Ra,@(Rb+,Rc) */
+ { SHORT_M, 2, { Ra, ATPAR, Rb, IMM6 } }, /* Ra,@(Rb,imm6) */
+ { SHORT_M, 3, { Ra, ATPAR, Rb, MINUS, Rc } }, /* Ra,@(Rb-,Rc) */
+ { SHORT_M2, 0, { Ra2, ATPAR, Rb, Rc } }, /* Ra,@(Rb,Rc) */
+ { SHORT_M2, 1, { Ra2, ATPAR, Rb, PLUS, Rc } }, /* Ra,@(Rb+,Rc) */
+ { SHORT_M2, 2, { Ra2, ATPAR, Rb, IMM6 } }, /* Ra,@(Rb,imm6) */
+ { SHORT_M2, 3, { Ra2, ATPAR, Rb, MINUS, Rc } }, /* Ra,@(Rb-,Rc) */
+ { SHORT_A, 0, { Ra, Rb, Rc } }, /* Ra,Rb,Rc */
+ { SHORT_A, 2, { Ra, Rb, IMM6 } }, /* Ra,Rb,imm6 */
+ { SHORT_B1, 0, { Rc } }, /* Rc */
+ { SHORT_B2, 2, { IMM18S3 } }, /* imm18 */
+ { SHORT_B3, 0, { Ra3, Rc } }, /* Ra,Rc */
+ { SHORT_B3, 2, { Ra3, IMM12S3 } }, /* Ra,imm12 */
+ { SHORT_B3b, 1, { Ra3, Rc } }, /* Ra,Rc */
+ { SHORT_B3b, 3, { Ra3, IMM12S3 } }, /* Ra,imm12 */
+ { SHORT_D1, 0, { Ra, Rc } }, /* Ra,Rc */
+ { SHORT_D1, 2, { Ra, IMM12S3 } }, /* Ra,imm12s3 */
+ { SHORT_D2, 0, { IMM6S3, Rc } }, /* imm6s3,Rc */
+ { SHORT_D2, 2, { IMM6S3, IMM12S3 } }, /* imm6s3,imm12s3 */
+ { SHORT_D2B, 0, { IMM6U, Rc } }, /* imm6u,Rc */
+ { SHORT_D2B, 2, { IMM6U, IMM12S3U } }, /* imm6u,imm12s3u */
+ { SHORT_U, 0, { Ra, Rb } }, /* Ra,Rb */
+ { SHORT_U, 2, { Ra, IMM12S3 } }, /* Ra,imm12 (repeat) */
+ { SHORT_F, 0, { Fa, Fb, Fc } }, /* Fa,Fb,Fc (orfg, xorfg) */
+ { SHORT_F, 2, { Fa, Fb, IMM6 } }, /* Fa,Fb,imm6 */
+ { SHORT_AF, 0, { Fa, Rb, Rc } }, /* Fa,Rb,Rc */
+ { SHORT_AF, 2, { Fa, Rb, IMM6 } }, /* Fa,Rb,imm6 */
+ { SHORT_T, 2, { IMM5 } }, /* imm5s3 (trap) */
+ { SHORT_A5, 0, { Ra, Rb, Rc } }, /* Ra,Rb,Rc */
+ { SHORT_A5, 2, { Ra, Rb, IMM5 } }, /* Ra,Rb,imm5 (sat*) */
+ { SHORT_CMP, 0, { CC, Fa2, Rb, Rc} }, /* CC Fa2,Rb,Rc */
+ { SHORT_CMP, 2, { CC, Fa2, Rb, IMM6} }, /* CC Fa2,Rb,imm6 */
+ { SHORT_CMPU, 0, { CC, Fa2, Rb, Rc} }, /* CC Fa2,Rb,Rc */
+ { SHORT_CMPU, 2, { CC, Fa2, Rb, IMM6U2} }, /* CC Fa2,Rb,imm6 */
+ { SHORT_A1, 1, { Ra, Rb, Rc } }, /* Ra,Rb,Rc for MAC where a=1 */
+ { SHORT_A1, 3, { Ra, Rb, IMM6 } }, /* Ra,Rb,imm6 for MAC where a=1 */
+ { SHORT_AA, 0, { Aa, Rb, Rc } }, /* Aa,Rb,Rc */
+ { SHORT_AA, 2, { Aa, Rb, IMM6 } }, /* Aa,Rb,imm6 */
+ { SHORT_RA, 0, { Ra, Ab, Rc } }, /* Ra,Ab,Rc */
+ { SHORT_RA, 2, { Ra, Ab, IMM6U2 } }, /* Ra,Ab,imm6u */
+ { SHORT_MODINC, 1, { Rb, IMM5 } }, /* Rb,imm5 (modinc) */
+ { SHORT_MODDEC, 3, { Rb, IMM5 } }, /* Rb,imm5 (moddec) */
+ { SHORT_C1, 0, { Ra, Cb, Fake } }, /* Ra,Cb (mvfsys) */
+ { SHORT_C2, 0, { Ca, Rb, Fake } }, /* Ca,Rb (mvtsys) */
+ { SHORT_UF, 0, { Fa, Fb } }, /* Fa,Fb (notfg) */
+ { SHORT_A2, 0, { Ra2, Rb, Rc } }, /* Ra2,Rb,Rc */
+ { SHORT_A2, 2, { Ra2, Rb, IMM6 } }, /* Ra2,Rb,imm6 */
+ { SHORT_A5S, 0, { Ra, Rb, Rc } }, /* Ra,Rb,Rc */
+ { SHORT_A5S, 2, { Ra, Rb, IMM5U } }, /* Ra,Rb,imm5u (shifts) */
+ { SHORT_NONE, 0, { 0 } }, /* no operands (nop, reit) */
+ { LONG, 2, { Ra, Rb, IMM32 } }, /* Ra,Rb,imm32 */
+ { LONG_U, 2, { IMM32 } }, /* imm32 */
+ { LONG_AF, 2, { Fa, Rb, IMM32 } }, /* Fa,Rb,imm32 */
+ { LONG_CMP, 2, { CC, Fa2, Rb, IMM32} }, /* CC Fa2,Rb,imm32 */
+ { LONG_M, 2, { Ra, ATPAR, Rb, IMM32 } }, /* Ra,@(Rb,imm32) */
+ { LONG_M2, 2, { Ra2, ATPAR, Rb, IMM32 } }, /* Ra,@(Rb,imm32) */
+ { LONG_2, 2, { Ra3, IMM32 } }, /* Ra,imm32 */
+ { LONG_2b, 3, { Ra3, IMM32 } }, /* Ra,imm32 */
+ { LONG_D, 2, { IMM6S3, IMM32 } }, /* imm6s3,imm32 */
+ { LONG_Db, 2, { IMM6U, IMM32 } }, /* imm6,imm32 */
+ { 0, 0, { 0 } },
+};
+
+const char *d30v_ecc_names[] =
+{
+ "al",
+ "tx",
+ "fx",
+ "xt",
+ "xf",
+ "tt",
+ "tf",
+ "res"
+};
+
+const char *d30v_cc_names[] =
+{
+ "eq",
+ "ne",
+ "gt",
+ "ge",
+ "lt",
+ "le",
+ "ps",
+ "ng",
+ NULL
+};
diff --git a/opcodes/dep-in.sed b/opcodes/dep-in.sed
new file mode 100644
index 00000000000..c30dee56391
--- /dev/null
+++ b/opcodes/dep-in.sed
@@ -0,0 +1,20 @@
+:loop
+/\\$/N
+s/\\\n */ /g
+t loop
+
+s!\.o:!.lo:!
+s! @BFD_H@! $(BFD_H)!g
+s!@INCDIR@!$(INCDIR)!g
+s!@BFDDIR@!$(BFDDIR)!g
+s!@SRCDIR@/!!g
+
+s/\\\n */ /g
+
+s/ *$//
+s/ */ /g
+s/ *:/:/g
+/:$/d
+
+s/\(.\{50\}[^ ]*\) /\1 \\\
+ /g
diff --git a/opcodes/dis-buf.c b/opcodes/dis-buf.c
new file mode 100644
index 00000000000..d76be2ec872
--- /dev/null
+++ b/opcodes/dis-buf.c
@@ -0,0 +1,104 @@
+/* Disassemble from a buffer, for GNU.
+ Copyright (C) 1993, 1994, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "sysdep.h"
+#include "dis-asm.h"
+#include <errno.h>
+#include "opintl.h"
+
+/* Get LENGTH bytes from info's buffer, at target address memaddr.
+ Transfer them to myaddr. */
+int
+buffer_read_memory (memaddr, myaddr, length, info)
+ bfd_vma memaddr;
+ bfd_byte *myaddr;
+ int length;
+ struct disassemble_info *info;
+{
+ if (memaddr < info->buffer_vma
+ || memaddr + length > info->buffer_vma + info->buffer_length)
+ /* Out of bounds. Use EIO because GDB uses it. */
+ return EIO;
+ memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
+ return 0;
+}
+
+/* Print an error message. We can assume that this is in response to
+ an error return from buffer_read_memory. */
+void
+perror_memory (status, memaddr, info)
+ int status;
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ if (status != EIO)
+ /* Can't happen. */
+ info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
+ else
+ /* Actually, address between memaddr and memaddr + len was
+ out of bounds. */
+ info->fprintf_func (info->stream,
+ _("Address 0x%x is out of bounds.\n"), memaddr);
+}
+
+/* This could be in a separate file, to save miniscule amounts of space
+ in statically linked executables. */
+
+/* Just print the address is hex. This is included for completeness even
+ though both GDB and objdump provide their own (to print symbolic
+ addresses). */
+
+void
+generic_print_address (addr, info)
+ bfd_vma addr;
+ struct disassemble_info *info;
+{
+ (*info->fprintf_func) (info->stream, "0x%x", addr);
+}
+
+/* Just concatenate the address as hex. This is included for
+ completeness even though both GDB and objdump provide their own (to
+ print symbolic addresses). */
+
+void
+generic_strcat_address (addr, buf, len)
+ bfd_vma addr;
+ char *buf;
+ int len;
+{
+ if (buf != (char *)NULL && len > 0)
+ {
+ char tmpBuf[30];
+
+ sprintf_vma (tmpBuf, addr);
+ if ((strlen (buf) + strlen (tmpBuf)) <= len)
+ strcat (buf, tmpBuf);
+ else
+ strncat (buf, tmpBuf, (len - strlen(buf)));
+ }
+ return;
+}
+
+/* Just return the given address. */
+
+int
+generic_symbol_at_address (addr, info)
+ bfd_vma addr;
+ struct disassemble_info * info;
+{
+ return 1;
+}
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
new file mode 100644
index 00000000000..4898b42458d
--- /dev/null
+++ b/opcodes/disassemble.c
@@ -0,0 +1,248 @@
+/* Select disassembly routine for specified architecture.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "dis-asm.h"
+
+#ifdef ARCH_all
+#define ARCH_a29k
+#define ARCH_alpha
+#define ARCH_arc
+#define ARCH_arm
+#define ARCH_d10v
+#define ARCH_d30v
+#define ARCH_h8300
+#define ARCH_h8500
+#define ARCH_hppa
+#define ARCH_i386
+#define ARCH_i960
+#define ARCH_fr30
+#define ARCH_m32r
+#define ARCH_m68k
+#define ARCH_m88k
+#define ARCH_mcore
+#define ARCH_mips
+#define ARCH_mn10200
+#define ARCH_mn10300
+#define ARCH_ns32k
+#define ARCH_powerpc
+#define ARCH_rs6000
+#define ARCH_sh
+#define ARCH_sparc
+#define ARCH_tic30
+#define ARCH_tic80
+#define ARCH_v850
+#define ARCH_vax
+#define ARCH_w65
+#define ARCH_z8k
+#endif
+
+
+disassembler_ftype
+disassembler (abfd)
+ bfd *abfd;
+{
+ enum bfd_architecture a = bfd_get_arch (abfd);
+ disassembler_ftype disassemble;
+
+ switch (a)
+ {
+ /* If you add a case to this table, also add it to the
+ ARCH_all definition right above this function. */
+#ifdef ARCH_a29k
+ case bfd_arch_a29k:
+ /* As far as I know we only handle big-endian 29k objects. */
+ disassemble = print_insn_big_a29k;
+ break;
+#endif
+#ifdef ARCH_alpha
+ case bfd_arch_alpha:
+ disassemble = print_insn_alpha;
+ break;
+#endif
+#ifdef ARCH_arc
+ case bfd_arch_arc:
+ {
+ disassemble = arc_get_disassembler (bfd_get_mach (abfd),
+ bfd_big_endian (abfd));
+ break;
+ }
+#endif
+#ifdef ARCH_arm
+ case bfd_arch_arm:
+ if (bfd_big_endian (abfd))
+ disassemble = print_insn_big_arm;
+ else
+ disassemble = print_insn_little_arm;
+ break;
+#endif
+#ifdef ARCH_d10v
+ case bfd_arch_d10v:
+ disassemble = print_insn_d10v;
+ break;
+#endif
+#ifdef ARCH_d30v
+ case bfd_arch_d30v:
+ disassemble = print_insn_d30v;
+ break;
+#endif
+#ifdef ARCH_h8300
+ case bfd_arch_h8300:
+ if (bfd_get_mach(abfd) == bfd_mach_h8300h)
+ disassemble = print_insn_h8300h;
+ else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
+ disassemble = print_insn_h8300s;
+ else
+ disassemble = print_insn_h8300;
+ break;
+#endif
+#ifdef ARCH_h8500
+ case bfd_arch_h8500:
+ disassemble = print_insn_h8500;
+ break;
+#endif
+#ifdef ARCH_hppa
+ case bfd_arch_hppa:
+ disassemble = print_insn_hppa;
+ break;
+#endif
+#ifdef ARCH_i386
+ case bfd_arch_i386:
+ if (bfd_get_mach (abfd) == bfd_mach_i386_i386_intel_syntax)
+ disassemble = print_insn_i386_intel;
+ else
+ disassemble = print_insn_i386_att;
+ break;
+#endif
+#ifdef ARCH_i960
+ case bfd_arch_i960:
+ disassemble = print_insn_i960;
+ break;
+#endif
+#ifdef ARCH_fr30
+ case bfd_arch_fr30:
+ disassemble = print_insn_fr30;
+ break;
+#endif
+#ifdef ARCH_m32r
+ case bfd_arch_m32r:
+ disassemble = print_insn_m32r;
+ break;
+#endif
+#ifdef ARCH_m68k
+ case bfd_arch_m68k:
+ disassemble = print_insn_m68k;
+ break;
+#endif
+#ifdef ARCH_m88k
+ case bfd_arch_m88k:
+ disassemble = print_insn_m88k;
+ break;
+#endif
+#ifdef ARCH_ns32k
+ case bfd_arch_ns32k:
+ disassemble = print_insn_ns32k;
+ break;
+#endif
+#ifdef ARCH_mcore
+ case bfd_arch_mcore:
+ disassemble = print_insn_mcore;
+ break;
+#endif
+#ifdef ARCH_mips
+ case bfd_arch_mips:
+ if (bfd_big_endian (abfd))
+ disassemble = print_insn_big_mips;
+ else
+ disassemble = print_insn_little_mips;
+ break;
+#endif
+#ifdef ARCH_mn10200
+ case bfd_arch_mn10200:
+ disassemble = print_insn_mn10200;
+ break;
+#endif
+#ifdef ARCH_mn10300
+ case bfd_arch_mn10300:
+ disassemble = print_insn_mn10300;
+ break;
+#endif
+#ifdef ARCH_powerpc
+ case bfd_arch_powerpc:
+ if (bfd_big_endian (abfd))
+ disassemble = print_insn_big_powerpc;
+ else
+ disassemble = print_insn_little_powerpc;
+ break;
+#endif
+#ifdef ARCH_rs6000
+ case bfd_arch_rs6000:
+ disassemble = print_insn_rs6000;
+ break;
+#endif
+#ifdef ARCH_sh
+ case bfd_arch_sh:
+ if (bfd_big_endian (abfd))
+ disassemble = print_insn_sh;
+ else
+ disassemble = print_insn_shl;
+ break;
+#endif
+#ifdef ARCH_sparc
+ case bfd_arch_sparc:
+ disassemble = print_insn_sparc;
+ break;
+#endif
+#ifdef ARCH_tic30
+ case bfd_arch_tic30:
+ disassemble = print_insn_tic30;
+ break;
+#endif
+#ifdef ARCH_tic80
+ case bfd_arch_tic80:
+ disassemble = print_insn_tic80;
+ break;
+#endif
+#ifdef ARCH_v850
+ case bfd_arch_v850:
+ disassemble = print_insn_v850;
+ break;
+#endif
+#ifdef ARCH_w65
+ case bfd_arch_w65:
+ disassemble = print_insn_w65;
+ break;
+#endif
+#ifdef ARCH_z8k
+ case bfd_arch_z8k:
+ if (bfd_get_mach(abfd) == bfd_mach_z8001)
+ disassemble = print_insn_z8001;
+ else
+ disassemble = print_insn_z8002;
+ break;
+#endif
+#ifdef ARCH_vax
+ case bfd_arch_vax:
+ disassemble = print_insn_vax;
+ break;
+#endif
+ default:
+ return 0;
+ }
+ return disassemble;
+}
+
diff --git a/opcodes/fr30-asm.c b/opcodes/fr30-asm.c
new file mode 100644
index 00000000000..5f5ccdc0b80
--- /dev/null
+++ b/opcodes/fr30-asm.c
@@ -0,0 +1,560 @@
+/* Assembler interface for targets using CGEN. -*- C -*-
+ CGEN: Cpu tools GENerator
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+- the resultant file is machine generated, cgen-asm.in isn't
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ??? Eventually more and more of this stuff can go to cpu-independent files.
+ Keep that in mind. */
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "fr30-desc.h"
+#include "fr30-opc.h"
+#include "opintl.h"
+
+#undef min
+#define min(a,b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a,b) ((a) > (b) ? (a) : (b))
+
+static const char * parse_insn_normal
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *));
+
+/* -- assembler routines inserted here */
+
+/* -- asm.c */
+/* Handle register lists for LDMx and STMx */
+
+static int
+parse_register_number (strp)
+ const char **strp;
+{
+ int regno;
+ if (**strp < '0' || **strp > '9')
+ return -1; /* error */
+ regno = **strp - '0';
+ ++*strp;
+
+ if (**strp >= '0' && **strp <= '9')
+ {
+ regno = regno * 10 + (**strp - '0');
+ ++*strp;
+ }
+
+ return regno;
+}
+
+static const char *
+parse_register_list (cd, strp, opindex, valuep, high_low, load_store)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+ int high_low; /* 0 == high, 1 == low */
+ int load_store; /* 0 == load, 1 == store */
+{
+ int regno;
+ *valuep = 0;
+ while (**strp && **strp != ')')
+ {
+ if (**strp != 'R' && **strp != 'r')
+ break;
+ ++*strp;
+
+ regno = parse_register_number (strp);
+ if (regno == -1)
+ return "Register number is not valid";
+ if (regno > 7 && !high_low)
+ return "Register must be between r0 and r7";
+ if (regno < 8 && high_low)
+ return "Register must be between r8 and r15";
+
+ if (high_low)
+ regno -= 8;
+
+ if (load_store) /* mask is reversed for store */
+ *valuep |= 0x80 >> regno;
+ else
+ *valuep |= 1 << regno;
+
+ if (**strp == ',')
+ {
+ if (*(*strp + 1) == ')')
+ break;
+ ++*strp;
+ }
+ }
+
+ if (!*strp || **strp != ')')
+ return "Register list is not valid";
+
+ return NULL;
+}
+
+static const char *
+parse_low_register_list_ld (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ return parse_register_list (cd, strp, opindex, valuep, 0/*low*/, 0/*load*/);
+}
+
+static const char *
+parse_hi_register_list_ld (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ return parse_register_list (cd, strp, opindex, valuep, 1/*high*/, 0/*load*/);
+}
+
+static const char *
+parse_low_register_list_st (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ return parse_register_list (cd, strp, opindex, valuep, 0/*low*/, 1/*store*/);
+}
+
+static const char *
+parse_hi_register_list_st (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ return parse_register_list (cd, strp, opindex, valuep, 1/*high*/, 1/*store*/);
+}
+
+/* -- */
+
+/* Main entry point for operand parsing.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `parse_insn_normal', but keeping it
+ separate makes clear the interface between `parse_insn_normal' and each of
+ the handlers.
+*/
+
+const char *
+fr30_cgen_parse_operand (cd, opindex, strp, fields)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ const char ** strp;
+ CGEN_FIELDS * fields;
+{
+ const char * errmsg;
+
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_cr_names, & fields->f_CRi);
+ break;
+ case FR30_OPERAND_CRJ :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_cr_names, & fields->f_CRj);
+ break;
+ case FR30_OPERAND_R13 :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r13, & fields->f_nil);
+ break;
+ case FR30_OPERAND_R14 :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r14, & fields->f_nil);
+ break;
+ case FR30_OPERAND_R15 :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r15, & fields->f_nil);
+ break;
+ case FR30_OPERAND_RI :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_gr_names, & fields->f_Ri);
+ break;
+ case FR30_OPERAND_RIC :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_gr_names, & fields->f_Ric);
+ break;
+ case FR30_OPERAND_RJ :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_gr_names, & fields->f_Rj);
+ break;
+ case FR30_OPERAND_RJC :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_gr_names, & fields->f_Rjc);
+ break;
+ case FR30_OPERAND_RS1 :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_dr_names, & fields->f_Rs1);
+ break;
+ case FR30_OPERAND_RS2 :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_dr_names, & fields->f_Rs2);
+ break;
+ case FR30_OPERAND_CC :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_CC, &fields->f_cc);
+ break;
+ case FR30_OPERAND_CCC :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_CCC, &fields->f_ccc);
+ break;
+ case FR30_OPERAND_DIR10 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_DIR10, &fields->f_dir10);
+ break;
+ case FR30_OPERAND_DIR8 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_DIR8, &fields->f_dir8);
+ break;
+ case FR30_OPERAND_DIR9 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_DIR9, &fields->f_dir9);
+ break;
+ case FR30_OPERAND_DISP10 :
+ errmsg = cgen_parse_signed_integer (cd, strp, FR30_OPERAND_DISP10, &fields->f_disp10);
+ break;
+ case FR30_OPERAND_DISP8 :
+ errmsg = cgen_parse_signed_integer (cd, strp, FR30_OPERAND_DISP8, &fields->f_disp8);
+ break;
+ case FR30_OPERAND_DISP9 :
+ errmsg = cgen_parse_signed_integer (cd, strp, FR30_OPERAND_DISP9, &fields->f_disp9);
+ break;
+ case FR30_OPERAND_I20 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_I20, &fields->f_i20);
+ break;
+ case FR30_OPERAND_I32 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_I32, &fields->f_i32);
+ break;
+ case FR30_OPERAND_I8 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_I8, &fields->f_i8);
+ break;
+ case FR30_OPERAND_LABEL12 :
+ {
+ bfd_vma value;
+ errmsg = cgen_parse_address (cd, strp, FR30_OPERAND_LABEL12, 0, NULL, & value);
+ fields->f_rel12 = value;
+ }
+ break;
+ case FR30_OPERAND_LABEL9 :
+ {
+ bfd_vma value;
+ errmsg = cgen_parse_address (cd, strp, FR30_OPERAND_LABEL9, 0, NULL, & value);
+ fields->f_rel9 = value;
+ }
+ break;
+ case FR30_OPERAND_M4 :
+ errmsg = cgen_parse_signed_integer (cd, strp, FR30_OPERAND_M4, &fields->f_m4);
+ break;
+ case FR30_OPERAND_PS :
+ errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_ps, & fields->f_nil);
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ errmsg = parse_hi_register_list_ld (cd, strp, FR30_OPERAND_REGLIST_HI_LD, &fields->f_reglist_hi_ld);
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ errmsg = parse_hi_register_list_st (cd, strp, FR30_OPERAND_REGLIST_HI_ST, &fields->f_reglist_hi_st);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ errmsg = parse_low_register_list_ld (cd, strp, FR30_OPERAND_REGLIST_LOW_LD, &fields->f_reglist_low_ld);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ errmsg = parse_low_register_list_st (cd, strp, FR30_OPERAND_REGLIST_LOW_ST, &fields->f_reglist_low_st);
+ break;
+ case FR30_OPERAND_S10 :
+ errmsg = cgen_parse_signed_integer (cd, strp, FR30_OPERAND_S10, &fields->f_s10);
+ break;
+ case FR30_OPERAND_U10 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_U10, &fields->f_u10);
+ break;
+ case FR30_OPERAND_U4 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_U4, &fields->f_u4);
+ break;
+ case FR30_OPERAND_U4C :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_U4C, &fields->f_u4c);
+ break;
+ case FR30_OPERAND_U8 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_U8, &fields->f_u8);
+ break;
+ case FR30_OPERAND_UDISP6 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, FR30_OPERAND_UDISP6, &fields->f_udisp6);
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
+ abort ();
+ }
+
+ return errmsg;
+}
+
+cgen_parse_fn * const fr30_cgen_parse_handlers[] =
+{
+ parse_insn_normal,
+};
+
+void
+fr30_cgen_init_asm (cd)
+ CGEN_CPU_DESC cd;
+{
+ fr30_cgen_init_opcode_table (cd);
+ fr30_cgen_init_ibld_table (cd);
+ cd->parse_handlers = & fr30_cgen_parse_handlers[0];
+ cd->parse_operand = fr30_cgen_parse_operand;
+}
+
+
+/* Default insn parser.
+
+ The syntax string is scanned and operands are parsed and stored in FIELDS.
+ Relocs are queued as we go via other callbacks.
+
+ ??? Note that this is currently an all-or-nothing parser. If we fail to
+ parse the instruction, we return 0 and the caller will start over from
+ the beginning. Backtracking will be necessary in parsing subexpressions,
+ but that can be handled there. Not handling backtracking here may get
+ expensive in the case of the m68k. Deal with later.
+
+ Returns NULL for success, an error message for failure.
+*/
+
+static const char *
+parse_insn_normal (cd, insn, strp, fields)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ const char **strp;
+ CGEN_FIELDS *fields;
+{
+ /* ??? Runtime added insns not handled yet. */
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ const char *str = *strp;
+ const char *errmsg;
+ const char *p;
+ const unsigned char * syn;
+#ifdef CGEN_MNEMONIC_OPERANDS
+ /* FIXME: wip */
+ int past_opcode_p;
+#endif
+
+ /* For now we assume the mnemonic is first (there are no leading operands).
+ We can parse it without needing to set up operand parsing.
+ GAS's input scrubber will ensure mnemonics are lowercase, but we may
+ not be called from GAS. */
+ p = CGEN_INSN_MNEMONIC (insn);
+ while (*p && tolower (*p) == tolower (*str))
+ ++p, ++str;
+
+ if (* p || (* str && !isspace (* str)))
+ return _("unrecognized instruction");
+
+ CGEN_INIT_PARSE (cd);
+ cgen_init_parse_operand (cd);
+#ifdef CGEN_MNEMONIC_OPERANDS
+ past_opcode_p = 0;
+#endif
+
+ /* We don't check for (*str != '\0') here because we want to parse
+ any trailing fake arguments in the syntax string. */
+ syn = CGEN_SYNTAX_STRING (syntax);
+
+ /* Mnemonics come first for now, ensure valid string. */
+ if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
+ abort ();
+
+ ++syn;
+
+ while (* syn != 0)
+ {
+ /* Non operand chars must match exactly. */
+ if (CGEN_SYNTAX_CHAR_P (* syn))
+ {
+ if (*str == CGEN_SYNTAX_CHAR (* syn))
+ {
+#ifdef CGEN_MNEMONIC_OPERANDS
+ if (* syn == ' ')
+ past_opcode_p = 1;
+#endif
+ ++ syn;
+ ++ str;
+ }
+ else
+ {
+ /* Syntax char didn't match. Can't be this insn. */
+ /* FIXME: would like to return something like
+ "expected char `c'" */
+ return _("syntax error");
+ }
+ continue;
+ }
+
+ /* We have an operand of some sort. */
+ errmsg = fr30_cgen_parse_operand (cd, CGEN_SYNTAX_FIELD (*syn),
+ &str, fields);
+ if (errmsg)
+ return errmsg;
+
+ /* Done with this operand, continue with next one. */
+ ++ syn;
+ }
+
+ /* If we're at the end of the syntax string, we're done. */
+ if (* syn == '\0')
+ {
+ /* FIXME: For the moment we assume a valid `str' can only contain
+ blanks now. IE: We needn't try again with a longer version of
+ the insn and it is assumed that longer versions of insns appear
+ before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
+ while (isspace (* str))
+ ++ str;
+
+ if (* str != '\0')
+ return _("junk at end of line"); /* FIXME: would like to include `str' */
+
+ return NULL;
+ }
+
+ /* We couldn't parse it. */
+ return _("unrecognized instruction");
+}
+
+/* Main entry point.
+ This routine is called for each instruction to be assembled.
+ STR points to the insn to be assembled.
+ We assume all necessary tables have been initialized.
+ The assembled instruction, less any fixups, is stored in BUF.
+ Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
+ still needs to be converted to target byte order, otherwise BUF is an array
+ of bytes in target byte order.
+ The result is a pointer to the insn's entry in the opcode table,
+ or NULL if an error occured (an error message will have already been
+ printed).
+
+ Note that when processing (non-alias) macro-insns,
+ this function recurses.
+
+ ??? It's possible to make this cpu-independent.
+ One would have to deal with a few minor things.
+ At this point in time doing so would be more of a curiosity than useful
+ [for example this file isn't _that_ big], but keeping the possibility in
+ mind helps keep the design clean. */
+
+const CGEN_INSN *
+fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg)
+ CGEN_CPU_DESC cd;
+ const char *str;
+ CGEN_FIELDS *fields;
+ CGEN_INSN_BYTES_PTR buf;
+ char **errmsg;
+{
+ const char *start;
+ CGEN_INSN_LIST *ilist;
+
+ /* Skip leading white space. */
+ while (isspace (* str))
+ ++ str;
+
+ /* The instructions are stored in hashed lists.
+ Get the first in the list. */
+ ilist = CGEN_ASM_LOOKUP_INSN (cd, str);
+
+ /* Keep looking until we find a match. */
+
+ start = str;
+ for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist))
+ {
+ const CGEN_INSN *insn = ilist->insn;
+
+#if 0 /* not needed as unsupported opcodes shouldn't be in the hash lists */
+ /* Is this insn supported by the selected cpu? */
+ if (! fr30_cgen_insn_supported (cd, insn))
+ continue;
+#endif
+
+ /* If the RELAX attribute is set, this is an insn that shouldn't be
+ chosen immediately. Instead, it is used during assembler/linker
+ relaxation if possible. */
+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAX) != 0)
+ continue;
+
+ str = start;
+
+ /* Allow parse/insert handlers to obtain length of insn. */
+ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
+
+ if (! CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields))
+ {
+ /* ??? 0 is passed for `pc' */
+ if (CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, (bfd_vma) 0)
+ != NULL)
+ continue;
+ /* It is up to the caller to actually output the insn and any
+ queued relocs. */
+ return insn;
+ }
+
+ /* Try the next entry. */
+ }
+
+ /* FIXME: We can return a better error message than this.
+ Need to track why it failed and pick the right one. */
+ {
+ static char errbuf[100];
+ if (strlen (start) > 50)
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s...'"), start);
+ else
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s'"), start);
+
+ *errmsg = errbuf;
+ return NULL;
+ }
+}
+
+#if 0 /* This calls back to GAS which we can't do without care. */
+
+/* Record each member of OPVALS in the assembler's symbol table.
+ This lets GAS parse registers for us.
+ ??? Interesting idea but not currently used. */
+
+/* Record each member of OPVALS in the assembler's symbol table.
+ FIXME: Not currently used. */
+
+void
+fr30_cgen_asm_hash_keywords (cd, opvals)
+ CGEN_CPU_DESC cd;
+ CGEN_KEYWORD *opvals;
+{
+ CGEN_KEYWORD_SEARCH search = cgen_keyword_search_init (opvals, NULL);
+ const CGEN_KEYWORD_ENTRY * ke;
+
+ while ((ke = cgen_keyword_search_next (& search)) != NULL)
+ {
+#if 0 /* Unnecessary, should be done in the search routine. */
+ if (! fr30_cgen_opval_supported (ke))
+ continue;
+#endif
+ cgen_asm_record_register (cd, ke->name, ke->value);
+ }
+}
+
+#endif /* 0 */
diff --git a/opcodes/fr30-desc.c b/opcodes/fr30-desc.c
new file mode 100644
index 00000000000..810f04b9dcc
--- /dev/null
+++ b/opcodes/fr30-desc.c
@@ -0,0 +1,1643 @@
+/* CPU data for fr30.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "fr30-desc.h"
+#include "fr30-opc.h"
+#include "opintl.h"
+
+/* Attributes. */
+
+static const CGEN_ATTR_ENTRY bool_attr[] =
+{
+ { "#f", 0 },
+ { "#t", 1 },
+ { 0, 0 }
+};
+
+static const CGEN_ATTR_ENTRY MACH_attr[] =
+{
+ { "base", MACH_BASE },
+ { "fr30", MACH_FR30 },
+ { "max", MACH_MAX },
+ { 0, 0 }
+};
+
+static const CGEN_ATTR_ENTRY ISA_attr[] =
+{
+ { "fr30", ISA_FR30 },
+ { "max", ISA_MAX },
+ { 0, 0 }
+};
+
+const CGEN_ATTR_TABLE fr30_cgen_ifield_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "RESERVED", &bool_attr[0], &bool_attr[0] },
+ { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
+ { "SIGNED", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+const CGEN_ATTR_TABLE fr30_cgen_hardware_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "PC", &bool_attr[0], &bool_attr[0] },
+ { "PROFILE", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+const CGEN_ATTR_TABLE fr30_cgen_operand_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
+ { "SIGNED", &bool_attr[0], &bool_attr[0] },
+ { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
+ { "RELAX", &bool_attr[0], &bool_attr[0] },
+ { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
+ { "HASH-PREFIX", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+const CGEN_ATTR_TABLE fr30_cgen_insn_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "ALIAS", &bool_attr[0], &bool_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
+ { "COND-CTI", &bool_attr[0], &bool_attr[0] },
+ { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
+ { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
+ { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
+ { "RELAX", &bool_attr[0], &bool_attr[0] },
+ { "NO-DIS", &bool_attr[0], &bool_attr[0] },
+ { "PBB", &bool_attr[0], &bool_attr[0] },
+ { "NOT-IN-DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+/* Instruction set variants. */
+
+static const CGEN_ISA fr30_cgen_isa_table[] = {
+ { "fr30", 16, 16, 16, 48, },
+ { 0 }
+};
+
+/* Machine variants. */
+
+static const CGEN_MACH fr30_cgen_mach_table[] = {
+ { "fr30", "fr30", MACH_FR30 },
+ { 0 }
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_gr_names_entries[] =
+{
+ { "r0", 0 },
+ { "r1", 1 },
+ { "r2", 2 },
+ { "r3", 3 },
+ { "r4", 4 },
+ { "r5", 5 },
+ { "r6", 6 },
+ { "r7", 7 },
+ { "r8", 8 },
+ { "r9", 9 },
+ { "r10", 10 },
+ { "r11", 11 },
+ { "r12", 12 },
+ { "r13", 13 },
+ { "r14", 14 },
+ { "r15", 15 },
+ { "ac", 13 },
+ { "fp", 14 },
+ { "sp", 15 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_gr_names =
+{
+ & fr30_cgen_opval_gr_names_entries[0],
+ 19
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_cr_names_entries[] =
+{
+ { "cr0", 0 },
+ { "cr1", 1 },
+ { "cr2", 2 },
+ { "cr3", 3 },
+ { "cr4", 4 },
+ { "cr5", 5 },
+ { "cr6", 6 },
+ { "cr7", 7 },
+ { "cr8", 8 },
+ { "cr9", 9 },
+ { "cr10", 10 },
+ { "cr11", 11 },
+ { "cr12", 12 },
+ { "cr13", 13 },
+ { "cr14", 14 },
+ { "cr15", 15 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_cr_names =
+{
+ & fr30_cgen_opval_cr_names_entries[0],
+ 16
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_dr_names_entries[] =
+{
+ { "tbr", 0 },
+ { "rp", 1 },
+ { "ssp", 2 },
+ { "usp", 3 },
+ { "mdh", 4 },
+ { "mdl", 5 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_dr_names =
+{
+ & fr30_cgen_opval_dr_names_entries[0],
+ 6
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_h_ps_entries[] =
+{
+ { "ps", 0 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_h_ps =
+{
+ & fr30_cgen_opval_h_ps_entries[0],
+ 1
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_h_r13_entries[] =
+{
+ { "r13", 0 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_h_r13 =
+{
+ & fr30_cgen_opval_h_r13_entries[0],
+ 1
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_h_r14_entries[] =
+{
+ { "r14", 0 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_h_r14 =
+{
+ & fr30_cgen_opval_h_r14_entries[0],
+ 1
+};
+
+static CGEN_KEYWORD_ENTRY fr30_cgen_opval_h_r15_entries[] =
+{
+ { "r15", 0 }
+};
+
+CGEN_KEYWORD fr30_cgen_opval_h_r15 =
+{
+ & fr30_cgen_opval_h_r15_entries[0],
+ 1
+};
+
+
+
+/* The hardware table. */
+
+#define A(a) (1 << CONCAT2 (CGEN_HW_,a))
+
+const CGEN_HW_ENTRY fr30_cgen_hw_table[] =
+{
+ { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PROFILE)|A(PC), { (1<<MACH_BASE) } } },
+ { "h-gr", HW_H_GR, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_gr_names, { 0|A(CACHE_ADDR)|A(PROFILE), { (1<<MACH_BASE) } } },
+ { "h-cr", HW_H_CR, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_cr_names, { 0, { (1<<MACH_BASE) } } },
+ { "h-dr", HW_H_DR, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_dr_names, { 0, { (1<<MACH_BASE) } } },
+ { "h-ps", HW_H_PS, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_h_ps, { 0, { (1<<MACH_BASE) } } },
+ { "h-r13", HW_H_R13, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_h_r13, { 0, { (1<<MACH_BASE) } } },
+ { "h-r14", HW_H_R14, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_h_r14, { 0, { (1<<MACH_BASE) } } },
+ { "h-r15", HW_H_R15, CGEN_ASM_KEYWORD, (PTR) & fr30_cgen_opval_h_r15, { 0, { (1<<MACH_BASE) } } },
+ { "h-nbit", HW_H_NBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-zbit", HW_H_ZBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-vbit", HW_H_VBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-cbit", HW_H_CBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-ibit", HW_H_IBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-sbit", HW_H_SBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-tbit", HW_H_TBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-d0bit", HW_H_D0BIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-d1bit", HW_H_D1BIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-ccr", HW_H_CCR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-scr", HW_H_SCR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-ilm", HW_H_ILM, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { 0 }
+};
+
+#undef A
+
+/* The instruction field table. */
+
+#define A(a) (1 << CONCAT2 (CGEN_IFLD_,a))
+
+const CGEN_IFLD fr30_cgen_ifld_table[] =
+{
+ { FR30_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_OP1, "f-op1", 0, 16, 0, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_OP2, "f-op2", 0, 16, 4, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_OP3, "f-op3", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_OP4, "f-op4", 0, 16, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_OP5, "f-op5", 0, 16, 4, 1, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_CC, "f-cc", 0, 16, 4, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_CCC, "f-ccc", 16, 16, 0, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_RJ, "f-Rj", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_RI, "f-Ri", 0, 16, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_RS1, "f-Rs1", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_RS2, "f-Rs2", 0, 16, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_RJC, "f-Rjc", 16, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_RIC, "f-Ric", 16, 16, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_CRJ, "f-CRj", 16, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_CRI, "f-CRi", 16, 16, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_U4, "f-u4", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_U4C, "f-u4c", 0, 16, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_I4, "f-i4", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_M4, "f-m4", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_U8, "f-u8", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_I8, "f-i8", 0, 16, 4, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_I20_4, "f-i20-4", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_I20_16, "f-i20-16", 16, 16, 0, 16, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_I32, "f-i32", 16, 32, 0, 32, { 0|A(SIGN_OPT), { (1<<MACH_BASE) } } },
+ { FR30_F_UDISP6, "f-udisp6", 0, 16, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_DISP8, "f-disp8", 0, 16, 4, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_DISP9, "f-disp9", 0, 16, 4, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_DISP10, "f-disp10", 0, 16, 4, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_S10, "f-s10", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_U10, "f-u10", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_REL9, "f-rel9", 0, 16, 8, 8, { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+ { FR30_F_DIR8, "f-dir8", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_DIR9, "f-dir9", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_DIR10, "f-dir10", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_REL12, "f-rel12", 0, 16, 5, 11, { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+ { FR30_F_REGLIST_HI_ST, "f-reglist_hi_st", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_REGLIST_LOW_ST, "f-reglist_low_st", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_REGLIST_HI_LD, "f-reglist_hi_ld", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { FR30_F_REGLIST_LOW_LD, "f-reglist_low_ld", 0, 16, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { 0 }
+};
+
+#undef A
+
+/* The operand table. */
+
+#define A(a) (1 << CONCAT2 (CGEN_OPERAND_,a))
+#define OPERAND(op) CONCAT2 (FR30_OPERAND_,op)
+
+const CGEN_OPERAND fr30_cgen_operand_table[] =
+{
+/* pc: program counter */
+ { "pc", FR30_OPERAND_PC, HW_H_PC, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* Ri: destination register */
+ { "Ri", FR30_OPERAND_RI, HW_H_GR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* Rj: source register */
+ { "Rj", FR30_OPERAND_RJ, HW_H_GR, 8, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* Ric: target register coproc insn */
+ { "Ric", FR30_OPERAND_RIC, HW_H_GR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* Rjc: source register coproc insn */
+ { "Rjc", FR30_OPERAND_RJC, HW_H_GR, 8, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* CRi: coprocessor register */
+ { "CRi", FR30_OPERAND_CRI, HW_H_CR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* CRj: coprocessor register */
+ { "CRj", FR30_OPERAND_CRJ, HW_H_CR, 8, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* Rs1: dedicated register */
+ { "Rs1", FR30_OPERAND_RS1, HW_H_DR, 8, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* Rs2: dedicated register */
+ { "Rs2", FR30_OPERAND_RS2, HW_H_DR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* R13: General Register 13 */
+ { "R13", FR30_OPERAND_R13, HW_H_R13, 0, 0,
+ { 0, { (1<<MACH_BASE) } } },
+/* R14: General Register 14 */
+ { "R14", FR30_OPERAND_R14, HW_H_R14, 0, 0,
+ { 0, { (1<<MACH_BASE) } } },
+/* R15: General Register 15 */
+ { "R15", FR30_OPERAND_R15, HW_H_R15, 0, 0,
+ { 0, { (1<<MACH_BASE) } } },
+/* ps: Program Status register */
+ { "ps", FR30_OPERAND_PS, HW_H_PS, 0, 0,
+ { 0, { (1<<MACH_BASE) } } },
+/* u4: 4 bit unsigned immediate */
+ { "u4", FR30_OPERAND_U4, HW_H_UINT, 8, 4,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* u4c: 4 bit unsigned immediate */
+ { "u4c", FR30_OPERAND_U4C, HW_H_UINT, 12, 4,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* u8: 8 bit unsigned immediate */
+ { "u8", FR30_OPERAND_U8, HW_H_UINT, 8, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* i8: 8 bit unsigned immediate */
+ { "i8", FR30_OPERAND_I8, HW_H_UINT, 4, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* udisp6: 6 bit unsigned immediate */
+ { "udisp6", FR30_OPERAND_UDISP6, HW_H_UINT, 8, 4,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* disp8: 8 bit signed immediate */
+ { "disp8", FR30_OPERAND_DISP8, HW_H_SINT, 4, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* disp9: 9 bit signed immediate */
+ { "disp9", FR30_OPERAND_DISP9, HW_H_SINT, 4, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* disp10: 10 bit signed immediate */
+ { "disp10", FR30_OPERAND_DISP10, HW_H_SINT, 4, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* s10: 10 bit signed immediate */
+ { "s10", FR30_OPERAND_S10, HW_H_SINT, 8, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* u10: 10 bit unsigned immediate */
+ { "u10", FR30_OPERAND_U10, HW_H_UINT, 8, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* i32: 32 bit immediate */
+ { "i32", FR30_OPERAND_I32, HW_H_UINT, 0, 32,
+ { 0|A(HASH_PREFIX)|A(SIGN_OPT), { (1<<MACH_BASE) } } },
+/* m4: 4 bit negative immediate */
+ { "m4", FR30_OPERAND_M4, HW_H_SINT, 8, 4,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* i20: 20 bit immediate */
+ { "i20", FR30_OPERAND_I20, HW_H_UINT, 0, 20,
+ { 0|A(HASH_PREFIX)|A(VIRTUAL), { (1<<MACH_BASE) } } },
+/* dir8: 8 bit direct address */
+ { "dir8", FR30_OPERAND_DIR8, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* dir9: 9 bit direct address */
+ { "dir9", FR30_OPERAND_DIR9, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* dir10: 10 bit direct address */
+ { "dir10", FR30_OPERAND_DIR10, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* label9: 9 bit pc relative address */
+ { "label9", FR30_OPERAND_LABEL9, HW_H_IADDR, 8, 8,
+ { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+/* label12: 12 bit pc relative address */
+ { "label12", FR30_OPERAND_LABEL12, HW_H_IADDR, 5, 11,
+ { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+/* reglist_low_ld: 8 bit low register mask for ldm */
+ { "reglist_low_ld", FR30_OPERAND_REGLIST_LOW_LD, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* reglist_hi_ld: 8 bit high register mask for ldm */
+ { "reglist_hi_ld", FR30_OPERAND_REGLIST_HI_LD, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* reglist_low_st: 8 bit low register mask for stm */
+ { "reglist_low_st", FR30_OPERAND_REGLIST_LOW_ST, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* reglist_hi_st: 8 bit high register mask for stm */
+ { "reglist_hi_st", FR30_OPERAND_REGLIST_HI_ST, HW_H_UINT, 8, 8,
+ { 0, { (1<<MACH_BASE) } } },
+/* cc: condition codes */
+ { "cc", FR30_OPERAND_CC, HW_H_UINT, 4, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* ccc: coprocessor calc */
+ { "ccc", FR30_OPERAND_CCC, HW_H_UINT, 0, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* nbit: negative bit */
+ { "nbit", FR30_OPERAND_NBIT, HW_H_NBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* vbit: overflow bit */
+ { "vbit", FR30_OPERAND_VBIT, HW_H_VBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* zbit: zero bit */
+ { "zbit", FR30_OPERAND_ZBIT, HW_H_ZBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* cbit: carry bit */
+ { "cbit", FR30_OPERAND_CBIT, HW_H_CBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* ibit: interrupt bit */
+ { "ibit", FR30_OPERAND_IBIT, HW_H_IBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* sbit: stack bit */
+ { "sbit", FR30_OPERAND_SBIT, HW_H_SBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* tbit: trace trap bit */
+ { "tbit", FR30_OPERAND_TBIT, HW_H_TBIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* d0bit: division 0 bit */
+ { "d0bit", FR30_OPERAND_D0BIT, HW_H_D0BIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* d1bit: division 1 bit */
+ { "d1bit", FR30_OPERAND_D1BIT, HW_H_D1BIT, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* ccr: condition code bits */
+ { "ccr", FR30_OPERAND_CCR, HW_H_CCR, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* scr: system condition bits */
+ { "scr", FR30_OPERAND_SCR, HW_H_SCR, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* ilm: interrupt level mask */
+ { "ilm", FR30_OPERAND_ILM, HW_H_ILM, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+ { 0 }
+};
+
+#undef A
+
+#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+
+/* The instruction table. */
+
+static const CGEN_IBASE fr30_cgen_insn_table[MAX_INSNS] =
+{
+ /* Special null first entry.
+ A `num' value of zero is thus invalid.
+ Also, the special `invalid' insn resides here. */
+ { 0, 0, 0 },
+/* add $Rj,$Ri */
+ {
+ FR30_INSN_ADD, "add", "add", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* add $u4,$Ri */
+ {
+ FR30_INSN_ADDI, "addi", "add", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* add2 $m4,$Ri */
+ {
+ FR30_INSN_ADD2, "add2", "add2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addc $Rj,$Ri */
+ {
+ FR30_INSN_ADDC, "addc", "addc", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addn $Rj,$Ri */
+ {
+ FR30_INSN_ADDN, "addn", "addn", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addn $u4,$Ri */
+ {
+ FR30_INSN_ADDNI, "addni", "addn", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addn2 $m4,$Ri */
+ {
+ FR30_INSN_ADDN2, "addn2", "addn2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sub $Rj,$Ri */
+ {
+ FR30_INSN_SUB, "sub", "sub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* subc $Rj,$Ri */
+ {
+ FR30_INSN_SUBC, "subc", "subc", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* subn $Rj,$Ri */
+ {
+ FR30_INSN_SUBN, "subn", "subn", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* cmp $Rj,$Ri */
+ {
+ FR30_INSN_CMP, "cmp", "cmp", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* cmp $u4,$Ri */
+ {
+ FR30_INSN_CMPI, "cmpi", "cmp", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* cmp2 $m4,$Ri */
+ {
+ FR30_INSN_CMP2, "cmp2", "cmp2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* and $Rj,$Ri */
+ {
+ FR30_INSN_AND, "and", "and", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* or $Rj,$Ri */
+ {
+ FR30_INSN_OR, "or", "or", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* eor $Rj,$Ri */
+ {
+ FR30_INSN_EOR, "eor", "eor", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* and $Rj,@$Ri */
+ {
+ FR30_INSN_ANDM, "andm", "and", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* andh $Rj,@$Ri */
+ {
+ FR30_INSN_ANDH, "andh", "andh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* andb $Rj,@$Ri */
+ {
+ FR30_INSN_ANDB, "andb", "andb", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* or $Rj,@$Ri */
+ {
+ FR30_INSN_ORM, "orm", "or", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* orh $Rj,@$Ri */
+ {
+ FR30_INSN_ORH, "orh", "orh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* orb $Rj,@$Ri */
+ {
+ FR30_INSN_ORB, "orb", "orb", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* eor $Rj,@$Ri */
+ {
+ FR30_INSN_EORM, "eorm", "eor", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* eorh $Rj,@$Ri */
+ {
+ FR30_INSN_EORH, "eorh", "eorh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* eorb $Rj,@$Ri */
+ {
+ FR30_INSN_EORB, "eorb", "eorb", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bandl $u4,@$Ri */
+ {
+ FR30_INSN_BANDL, "bandl", "bandl", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* borl $u4,@$Ri */
+ {
+ FR30_INSN_BORL, "borl", "borl", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* beorl $u4,@$Ri */
+ {
+ FR30_INSN_BEORL, "beorl", "beorl", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bandh $u4,@$Ri */
+ {
+ FR30_INSN_BANDH, "bandh", "bandh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* borh $u4,@$Ri */
+ {
+ FR30_INSN_BORH, "borh", "borh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* beorh $u4,@$Ri */
+ {
+ FR30_INSN_BEORH, "beorh", "beorh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* btstl $u4,@$Ri */
+ {
+ FR30_INSN_BTSTL, "btstl", "btstl", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* btsth $u4,@$Ri */
+ {
+ FR30_INSN_BTSTH, "btsth", "btsth", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* mul $Rj,$Ri */
+ {
+ FR30_INSN_MUL, "mul", "mul", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* mulu $Rj,$Ri */
+ {
+ FR30_INSN_MULU, "mulu", "mulu", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* mulh $Rj,$Ri */
+ {
+ FR30_INSN_MULH, "mulh", "mulh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* muluh $Rj,$Ri */
+ {
+ FR30_INSN_MULUH, "muluh", "muluh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* div0s $Ri */
+ {
+ FR30_INSN_DIV0S, "div0s", "div0s", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* div0u $Ri */
+ {
+ FR30_INSN_DIV0U, "div0u", "div0u", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* div1 $Ri */
+ {
+ FR30_INSN_DIV1, "div1", "div1", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* div2 $Ri */
+ {
+ FR30_INSN_DIV2, "div2", "div2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* div3 */
+ {
+ FR30_INSN_DIV3, "div3", "div3", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* div4s */
+ {
+ FR30_INSN_DIV4S, "div4s", "div4s", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lsl $Rj,$Ri */
+ {
+ FR30_INSN_LSL, "lsl", "lsl", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lsl $u4,$Ri */
+ {
+ FR30_INSN_LSLI, "lsli", "lsl", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lsl2 $u4,$Ri */
+ {
+ FR30_INSN_LSL2, "lsl2", "lsl2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lsr $Rj,$Ri */
+ {
+ FR30_INSN_LSR, "lsr", "lsr", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lsr $u4,$Ri */
+ {
+ FR30_INSN_LSRI, "lsri", "lsr", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lsr2 $u4,$Ri */
+ {
+ FR30_INSN_LSR2, "lsr2", "lsr2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* asr $Rj,$Ri */
+ {
+ FR30_INSN_ASR, "asr", "asr", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* asr $u4,$Ri */
+ {
+ FR30_INSN_ASRI, "asri", "asr", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* asr2 $u4,$Ri */
+ {
+ FR30_INSN_ASR2, "asr2", "asr2", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldi:8 $i8,$Ri */
+ {
+ FR30_INSN_LDI8, "ldi8", "ldi:8", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldi:20 $i20,$Ri */
+ {
+ FR30_INSN_LDI20, "ldi20", "ldi:20", 32,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* ldi:32 $i32,$Ri */
+ {
+ FR30_INSN_LDI32, "ldi32", "ldi:32", 48,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* ld @$Rj,$Ri */
+ {
+ FR30_INSN_LD, "ld", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lduh @$Rj,$Ri */
+ {
+ FR30_INSN_LDUH, "lduh", "lduh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldub @$Rj,$Ri */
+ {
+ FR30_INSN_LDUB, "ldub", "ldub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld @($R13,$Rj),$Ri */
+ {
+ FR30_INSN_LDR13, "ldr13", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lduh @($R13,$Rj),$Ri */
+ {
+ FR30_INSN_LDR13UH, "ldr13uh", "lduh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldub @($R13,$Rj),$Ri */
+ {
+ FR30_INSN_LDR13UB, "ldr13ub", "ldub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld @($R14,$disp10),$Ri */
+ {
+ FR30_INSN_LDR14, "ldr14", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lduh @($R14,$disp9),$Ri */
+ {
+ FR30_INSN_LDR14UH, "ldr14uh", "lduh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldub @($R14,$disp8),$Ri */
+ {
+ FR30_INSN_LDR14UB, "ldr14ub", "ldub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld @($R15,$udisp6),$Ri */
+ {
+ FR30_INSN_LDR15, "ldr15", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld @$R15+,$Ri */
+ {
+ FR30_INSN_LDR15GR, "ldr15gr", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld @$R15+,$Rs2 */
+ {
+ FR30_INSN_LDR15DR, "ldr15dr", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld @$R15+,$ps */
+ {
+ FR30_INSN_LDR15PS, "ldr15ps", "ld", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* st $Ri,@$Rj */
+ {
+ FR30_INSN_ST, "st", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sth $Ri,@$Rj */
+ {
+ FR30_INSN_STH, "sth", "sth", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stb $Ri,@$Rj */
+ {
+ FR30_INSN_STB, "stb", "stb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $Ri,@($R13,$Rj) */
+ {
+ FR30_INSN_STR13, "str13", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sth $Ri,@($R13,$Rj) */
+ {
+ FR30_INSN_STR13H, "str13h", "sth", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stb $Ri,@($R13,$Rj) */
+ {
+ FR30_INSN_STR13B, "str13b", "stb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $Ri,@($R14,$disp10) */
+ {
+ FR30_INSN_STR14, "str14", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sth $Ri,@($R14,$disp9) */
+ {
+ FR30_INSN_STR14H, "str14h", "sth", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stb $Ri,@($R14,$disp8) */
+ {
+ FR30_INSN_STR14B, "str14b", "stb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $Ri,@($R15,$udisp6) */
+ {
+ FR30_INSN_STR15, "str15", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $Ri,@-$R15 */
+ {
+ FR30_INSN_STR15GR, "str15gr", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $Rs2,@-$R15 */
+ {
+ FR30_INSN_STR15DR, "str15dr", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $ps,@-$R15 */
+ {
+ FR30_INSN_STR15PS, "str15ps", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mov $Rj,$Ri */
+ {
+ FR30_INSN_MOV, "mov", "mov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mov $Rs1,$Ri */
+ {
+ FR30_INSN_MOVDR, "movdr", "mov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mov $ps,$Ri */
+ {
+ FR30_INSN_MOVPS, "movps", "mov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mov $Ri,$Rs1 */
+ {
+ FR30_INSN_MOV2DR, "mov2dr", "mov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mov $Ri,$ps */
+ {
+ FR30_INSN_MOV2PS, "mov2ps", "mov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* jmp @$Ri */
+ {
+ FR30_INSN_JMP, "jmp", "jmp", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* jmp:d @$Ri */
+ {
+ FR30_INSN_JMPD, "jmpd", "jmp:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* call @$Ri */
+ {
+ FR30_INSN_CALLR, "callr", "call", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* call:d @$Ri */
+ {
+ FR30_INSN_CALLRD, "callrd", "call:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* call $label12 */
+ {
+ FR30_INSN_CALL, "call", "call", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* call:d $label12 */
+ {
+ FR30_INSN_CALLD, "calld", "call:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* ret */
+ {
+ FR30_INSN_RET, "ret", "ret", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* ret:d */
+ {
+ FR30_INSN_RET_D, "ret:d", "ret:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* int $u8 */
+ {
+ FR30_INSN_INT, "int", "int", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* inte */
+ {
+ FR30_INSN_INTE, "inte", "inte", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* reti */
+ {
+ FR30_INSN_RETI, "reti", "reti", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bra:d $label9 */
+ {
+ FR30_INSN_BRAD, "brad", "bra:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bra $label9 */
+ {
+ FR30_INSN_BRA, "bra", "bra", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bno:d $label9 */
+ {
+ FR30_INSN_BNOD, "bnod", "bno:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bno $label9 */
+ {
+ FR30_INSN_BNO, "bno", "bno", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* beq:d $label9 */
+ {
+ FR30_INSN_BEQD, "beqd", "beq:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* beq $label9 */
+ {
+ FR30_INSN_BEQ, "beq", "beq", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bne:d $label9 */
+ {
+ FR30_INSN_BNED, "bned", "bne:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bne $label9 */
+ {
+ FR30_INSN_BNE, "bne", "bne", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bc:d $label9 */
+ {
+ FR30_INSN_BCD, "bcd", "bc:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bc $label9 */
+ {
+ FR30_INSN_BC, "bc", "bc", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bnc:d $label9 */
+ {
+ FR30_INSN_BNCD, "bncd", "bnc:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bnc $label9 */
+ {
+ FR30_INSN_BNC, "bnc", "bnc", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bn:d $label9 */
+ {
+ FR30_INSN_BND, "bnd", "bn:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bn $label9 */
+ {
+ FR30_INSN_BN, "bn", "bn", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bp:d $label9 */
+ {
+ FR30_INSN_BPD, "bpd", "bp:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bp $label9 */
+ {
+ FR30_INSN_BP, "bp", "bp", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bv:d $label9 */
+ {
+ FR30_INSN_BVD, "bvd", "bv:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bv $label9 */
+ {
+ FR30_INSN_BV, "bv", "bv", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bnv:d $label9 */
+ {
+ FR30_INSN_BNVD, "bnvd", "bnv:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bnv $label9 */
+ {
+ FR30_INSN_BNV, "bnv", "bnv", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* blt:d $label9 */
+ {
+ FR30_INSN_BLTD, "bltd", "blt:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* blt $label9 */
+ {
+ FR30_INSN_BLT, "blt", "blt", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bge:d $label9 */
+ {
+ FR30_INSN_BGED, "bged", "bge:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bge $label9 */
+ {
+ FR30_INSN_BGE, "bge", "bge", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* ble:d $label9 */
+ {
+ FR30_INSN_BLED, "bled", "ble:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* ble $label9 */
+ {
+ FR30_INSN_BLE, "ble", "ble", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bgt:d $label9 */
+ {
+ FR30_INSN_BGTD, "bgtd", "bgt:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bgt $label9 */
+ {
+ FR30_INSN_BGT, "bgt", "bgt", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bls:d $label9 */
+ {
+ FR30_INSN_BLSD, "blsd", "bls:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bls $label9 */
+ {
+ FR30_INSN_BLS, "bls", "bls", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bhi:d $label9 */
+ {
+ FR30_INSN_BHID, "bhid", "bhi:d", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* bhi $label9 */
+ {
+ FR30_INSN_BHI, "bhi", "bhi", 16,
+ { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* dmov $R13,@$dir10 */
+ {
+ FR30_INSN_DMOVR13, "dmovr13", "dmov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* dmovh $R13,@$dir9 */
+ {
+ FR30_INSN_DMOVR13H, "dmovr13h", "dmovh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* dmovb $R13,@$dir8 */
+ {
+ FR30_INSN_DMOVR13B, "dmovr13b", "dmovb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* dmov @$R13+,@$dir10 */
+ {
+ FR30_INSN_DMOVR13PI, "dmovr13pi", "dmov", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmovh @$R13+,@$dir9 */
+ {
+ FR30_INSN_DMOVR13PIH, "dmovr13pih", "dmovh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmovb @$R13+,@$dir8 */
+ {
+ FR30_INSN_DMOVR13PIB, "dmovr13pib", "dmovb", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmov @$R15+,@$dir10 */
+ {
+ FR30_INSN_DMOVR15PI, "dmovr15pi", "dmov", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmov @$dir10,$R13 */
+ {
+ FR30_INSN_DMOV2R13, "dmov2r13", "dmov", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* dmovh @$dir9,$R13 */
+ {
+ FR30_INSN_DMOV2R13H, "dmov2r13h", "dmovh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* dmovb @$dir8,$R13 */
+ {
+ FR30_INSN_DMOV2R13B, "dmov2r13b", "dmovb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* dmov @$dir10,@$R13+ */
+ {
+ FR30_INSN_DMOV2R13PI, "dmov2r13pi", "dmov", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmovh @$dir9,@$R13+ */
+ {
+ FR30_INSN_DMOV2R13PIH, "dmov2r13pih", "dmovh", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmovb @$dir8,@$R13+ */
+ {
+ FR30_INSN_DMOV2R13PIB, "dmov2r13pib", "dmovb", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* dmov @$dir10,@-$R15 */
+ {
+ FR30_INSN_DMOV2R15PD, "dmov2r15pd", "dmov", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* ldres @$Ri+,$u4 */
+ {
+ FR30_INSN_LDRES, "ldres", "ldres", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stres $u4,@$Ri+ */
+ {
+ FR30_INSN_STRES, "stres", "stres", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* copop $u4c,$ccc,$CRj,$CRi */
+ {
+ FR30_INSN_COPOP, "copop", "copop", 32,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* copld $u4c,$ccc,$Rjc,$CRi */
+ {
+ FR30_INSN_COPLD, "copld", "copld", 32,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* copst $u4c,$ccc,$CRj,$Ric */
+ {
+ FR30_INSN_COPST, "copst", "copst", 32,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* copsv $u4c,$ccc,$CRj,$Ric */
+ {
+ FR30_INSN_COPSV, "copsv", "copsv", 32,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* nop */
+ {
+ FR30_INSN_NOP, "nop", "nop", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* andccr $u8 */
+ {
+ FR30_INSN_ANDCCR, "andccr", "andccr", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* orccr $u8 */
+ {
+ FR30_INSN_ORCCR, "orccr", "orccr", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stilm $u8 */
+ {
+ FR30_INSN_STILM, "stilm", "stilm", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addsp $s10 */
+ {
+ FR30_INSN_ADDSP, "addsp", "addsp", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* extsb $Ri */
+ {
+ FR30_INSN_EXTSB, "extsb", "extsb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* extub $Ri */
+ {
+ FR30_INSN_EXTUB, "extub", "extub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* extsh $Ri */
+ {
+ FR30_INSN_EXTSH, "extsh", "extsh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* extuh $Ri */
+ {
+ FR30_INSN_EXTUH, "extuh", "extuh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldm0 ($reglist_low_ld) */
+ {
+ FR30_INSN_LDM0, "ldm0", "ldm0", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* ldm1 ($reglist_hi_ld) */
+ {
+ FR30_INSN_LDM1, "ldm1", "ldm1", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* stm0 ($reglist_low_st) */
+ {
+ FR30_INSN_STM0, "stm0", "stm0", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* stm1 ($reglist_hi_st) */
+ {
+ FR30_INSN_STM1, "stm1", "stm1", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* enter $u10 */
+ {
+ FR30_INSN_ENTER, "enter", "enter", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+/* leave */
+ {
+ FR30_INSN_LEAVE, "leave", "leave", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* xchb @$Rj,$Ri */
+ {
+ FR30_INSN_XCHB, "xchb", "xchb", 16,
+ { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
+ },
+};
+
+#undef A
+#undef MNEM
+#undef OP
+
+/* Initialize anything needed to be done once, before any cpu_open call. */
+
+static void
+init_tables ()
+{
+}
+
+/* Subroutine of fr30_cgen_cpu_open to look up a mach via its bfd name. */
+
+static const CGEN_MACH *
+lookup_mach_via_bfd_name (table, name)
+ const CGEN_MACH *table;
+ const char *name;
+{
+ while (table->name)
+ {
+ if (strcmp (name, table->bfd_name) == 0)
+ return table;
+ ++table;
+ }
+ abort ();
+}
+
+/* Subroutine of fr30_cgen_cpu_open to build the hardware table. */
+
+static void
+build_hw_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i;
+ int machs = cd->machs;
+ const CGEN_HW_ENTRY *init = & fr30_cgen_hw_table[0];
+ /* MAX_HW is only an upper bound on the number of selected entries.
+ However each entry is indexed by it's enum so there can be holes in
+ the table. */
+ const CGEN_HW_ENTRY **selected =
+ (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
+
+ cd->hw_table.init_entries = init;
+ cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
+ memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
+ /* ??? For now we just use machs to determine which ones we want. */
+ for (i = 0; init[i].name != NULL; ++i)
+ if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
+ & machs)
+ selected[init[i].type] = &init[i];
+ cd->hw_table.entries = selected;
+ cd->hw_table.num_entries = MAX_HW;
+}
+
+/* Subroutine of fr30_cgen_cpu_open to build the hardware table. */
+
+static void
+build_ifield_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ cd->ifld_table = & fr30_cgen_ifld_table[0];
+}
+
+/* Subroutine of fr30_cgen_cpu_open to build the hardware table. */
+
+static void
+build_operand_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i;
+ int machs = cd->machs;
+ const CGEN_OPERAND *init = & fr30_cgen_operand_table[0];
+ /* MAX_OPERANDS is only an upper bound on the number of selected entries.
+ However each entry is indexed by it's enum so there can be holes in
+ the table. */
+ const CGEN_OPERAND **selected =
+ (const CGEN_OPERAND **) xmalloc (MAX_OPERANDS * sizeof (CGEN_OPERAND *));
+
+ cd->operand_table.init_entries = init;
+ cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
+ memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
+ /* ??? For now we just use mach to determine which ones we want. */
+ for (i = 0; init[i].name != NULL; ++i)
+ if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
+ & machs)
+ selected[init[i].type] = &init[i];
+ cd->operand_table.entries = selected;
+ cd->operand_table.num_entries = MAX_OPERANDS;
+}
+
+/* Subroutine of fr30_cgen_cpu_open to build the hardware table.
+ ??? This could leave out insns not supported by the specified mach/isa,
+ but that would cause errors like "foo only supported by bar" to become
+ "unknown insn", so for now we include all insns and require the app to
+ do the checking later.
+ ??? On the other hand, parsing of such insns may require their hardware or
+ operand elements to be in the table [which they mightn't be]. */
+
+static void
+build_insn_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i;
+ const CGEN_IBASE *ib = & fr30_cgen_insn_table[0];
+ CGEN_INSN *insns = (CGEN_INSN *) xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
+
+ memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
+ for (i = 0; i < MAX_INSNS; ++i)
+ insns[i].base = &ib[i];
+ cd->insn_table.init_entries = insns;
+ cd->insn_table.entry_size = sizeof (CGEN_IBASE);
+ cd->insn_table.num_init_entries = MAX_INSNS;
+}
+
+/* Subroutine of fr30_cgen_cpu_open to rebuild the tables. */
+
+static void
+fr30_cgen_rebuild_tables (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i,n_isas,n_machs;
+ unsigned int isas = cd->isas;
+ unsigned int machs = cd->machs;
+
+ cd->int_insn_p = CGEN_INT_INSN_P;
+
+ /* Data derived from the isa spec. */
+#define UNSET (CGEN_SIZE_UNKNOWN + 1)
+ cd->default_insn_bitsize = UNSET;
+ cd->base_insn_bitsize = UNSET;
+ cd->min_insn_bitsize = 65535; /* some ridiculously big number */
+ cd->max_insn_bitsize = 0;
+ for (i = 0; i < MAX_ISAS; ++i)
+ if (((1 << i) & isas) != 0)
+ {
+ const CGEN_ISA *isa = & fr30_cgen_isa_table[i];
+
+ /* Default insn sizes of all selected isas must be equal or we set
+ the result to 0, meaning "unknown". */
+ if (cd->default_insn_bitsize == UNSET)
+ cd->default_insn_bitsize = isa->default_insn_bitsize;
+ else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
+ ; /* this is ok */
+ else
+ cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
+
+ /* Base insn sizes of all selected isas must be equal or we set
+ the result to 0, meaning "unknown". */
+ if (cd->base_insn_bitsize == UNSET)
+ cd->base_insn_bitsize = isa->base_insn_bitsize;
+ else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
+ ; /* this is ok */
+ else
+ cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
+
+ /* Set min,max insn sizes. */
+ if (isa->min_insn_bitsize < cd->min_insn_bitsize)
+ cd->min_insn_bitsize = isa->min_insn_bitsize;
+ if (isa->max_insn_bitsize > cd->max_insn_bitsize)
+ cd->max_insn_bitsize = isa->max_insn_bitsize;
+
+ ++n_isas;
+ }
+
+ /* Data derived from the mach spec. */
+ for (i = 0; i < MAX_MACHS; ++i)
+ if (((1 << i) & machs) != 0)
+ {
+ const CGEN_MACH *mach = & fr30_cgen_mach_table[i];
+
+ ++n_machs;
+ }
+
+ /* Determine which hw elements are used by MACH. */
+ build_hw_table (cd);
+
+ /* Build the ifield table. */
+ build_ifield_table (cd);
+
+ /* Determine which operands are used by MACH/ISA. */
+ build_operand_table (cd);
+
+ /* Build the instruction table. */
+ build_insn_table (cd);
+}
+
+/* Initialize a cpu table and return a descriptor.
+ It's much like opening a file, and must be the first function called.
+ The arguments are a set of (type/value) pairs, terminated with
+ CGEN_CPU_OPEN_END.
+
+ Currently supported values:
+ CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr
+ CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr
+ CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
+ CGEN_CPU_OPEN_ENDIAN: specify endian choice
+ CGEN_CPU_OPEN_END: terminates arguments
+
+ ??? Simultaneous multiple isas might not make sense, but it's not (yet)
+ precluded.
+
+ ??? We only support ISO C stdargs here, not K&R.
+ Laziness, plus experiment to see if anything requires K&R - eventually
+ K&R will no longer be supported - e.g. GDB is currently trying this. */
+
+CGEN_CPU_DESC
+fr30_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
+{
+ CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
+ static int init_p;
+ unsigned int isas = 0; /* 0 = "unspecified" */
+ unsigned int machs = 0; /* 0 = "unspecified" */
+ enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
+ va_list ap;
+
+ if (! init_p)
+ {
+ init_tables ();
+ init_p = 1;
+ }
+
+ memset (cd, 0, sizeof (*cd));
+
+ va_start (ap, arg_type);
+ while (arg_type != CGEN_CPU_OPEN_END)
+ {
+ switch (arg_type)
+ {
+ case CGEN_CPU_OPEN_ISAS :
+ isas = va_arg (ap, unsigned int);
+ break;
+ case CGEN_CPU_OPEN_MACHS :
+ machs = va_arg (ap, unsigned int);
+ break;
+ case CGEN_CPU_OPEN_BFDMACH :
+ {
+ const char *name = va_arg (ap, const char *);
+ const CGEN_MACH *mach =
+ lookup_mach_via_bfd_name (fr30_cgen_mach_table, name);
+
+ machs |= mach->num << 1;
+ break;
+ }
+ case CGEN_CPU_OPEN_ENDIAN :
+ endian = va_arg (ap, enum cgen_endian);
+ break;
+ default :
+ fprintf (stderr, "fr30_cgen_cpu_open: unsupported argument `%d'\n",
+ arg_type);
+ abort (); /* ??? return NULL? */
+ }
+ arg_type = va_arg (ap, enum cgen_cpu_open_arg);
+ }
+ va_end (ap);
+
+ /* mach unspecified means "all" */
+ if (machs == 0)
+ machs = (1 << MAX_MACHS) - 1;
+ /* base mach is always selected */
+ machs |= 1;
+ /* isa unspecified means "all" */
+ if (isas == 0)
+ isas = (1 << MAX_ISAS) - 1;
+ if (endian == CGEN_ENDIAN_UNKNOWN)
+ {
+ /* ??? If target has only one, could have a default. */
+ fprintf (stderr, "fr30_cgen_cpu_open: no endianness specified\n");
+ abort ();
+ }
+
+ cd->isas = isas;
+ cd->machs = machs;
+ cd->endian = endian;
+ /* FIXME: for the sparc case we can determine insn-endianness statically.
+ The worry here is where both data and insn endian can be independently
+ chosen, in which case this function will need another argument.
+ Actually, will want to allow for more arguments in the future anyway. */
+ cd->insn_endian = endian;
+
+ /* Table (re)builder. */
+ cd->rebuild_tables = fr30_cgen_rebuild_tables;
+ fr30_cgen_rebuild_tables (cd);
+
+ return (CGEN_CPU_DESC) cd;
+}
+
+/* Cover fn to fr30_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
+ MACH_NAME is the bfd name of the mach. */
+
+CGEN_CPU_DESC
+fr30_cgen_cpu_open_1 (mach_name, endian)
+ const char *mach_name;
+ enum cgen_endian endian;
+{
+ return fr30_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
+ CGEN_CPU_OPEN_ENDIAN, endian,
+ CGEN_CPU_OPEN_END);
+}
+
+/* Close a cpu table.
+ ??? This can live in a machine independent file, but there's currently
+ no place to put this file (there's no libcgen). libopcodes is the wrong
+ place as some simulator ports use this but they don't use libopcodes. */
+
+void
+fr30_cgen_cpu_close (cd)
+ CGEN_CPU_DESC cd;
+{
+ if (cd->insn_table.init_entries)
+ free ((CGEN_INSN *) cd->insn_table.init_entries);
+ if (cd->hw_table.entries)
+ free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
+ free (cd);
+}
+
diff --git a/opcodes/fr30-desc.h b/opcodes/fr30-desc.h
new file mode 100644
index 00000000000..0289156bca3
--- /dev/null
+++ b/opcodes/fr30-desc.h
@@ -0,0 +1,266 @@
+/* CPU data header for fr30.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef FR30_CPU_H
+#define FR30_CPU_H
+
+#define CGEN_ARCH fr30
+
+/* Given symbol S, return fr30_cgen_<S>. */
+#define CGEN_SYM(s) CONCAT3 (fr30,_cgen_,s)
+
+/* Selected cpu families. */
+#define HAVE_CPU_FR30BF
+
+#define CGEN_INSN_LSB0_P 0
+
+/* Maximum size of any insn (in bytes). */
+#define CGEN_MAX_INSN_SIZE 6
+
+#define CGEN_INT_INSN_P 0
+
+/* FIXME: Need to compute CGEN_MAX_SYNTAX_BYTES. */
+
+/* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands.
+ e.g. In "b,a foo" the ",a" is an operand. If mnemonics have operands
+ we can't hash on everything up to the space. */
+#define CGEN_MNEMONIC_OPERANDS
+/* Maximum number of operands any insn or macro-insn has. */
+#define CGEN_MAX_INSN_OPERANDS 16
+
+/* Maximum number of fields in an instruction. */
+#define CGEN_MAX_IFMT_OPERANDS 7
+
+/* Enums. */
+
+/* Enum declaration for insn op1 enums. */
+typedef enum insn_op1 {
+ OP1_0, OP1_1, OP1_2, OP1_3
+ , OP1_4, OP1_5, OP1_6, OP1_7
+ , OP1_8, OP1_9, OP1_A, OP1_B
+ , OP1_C, OP1_D, OP1_E, OP1_F
+} INSN_OP1;
+
+/* Enum declaration for insn op2 enums. */
+typedef enum insn_op2 {
+ OP2_0, OP2_1, OP2_2, OP2_3
+ , OP2_4, OP2_5, OP2_6, OP2_7
+ , OP2_8, OP2_9, OP2_A, OP2_B
+ , OP2_C, OP2_D, OP2_E, OP2_F
+} INSN_OP2;
+
+/* Enum declaration for insn op3 enums. */
+typedef enum insn_op3 {
+ OP3_0, OP3_1, OP3_2, OP3_3
+ , OP3_4, OP3_5, OP3_6, OP3_7
+ , OP3_8, OP3_9, OP3_A, OP3_B
+ , OP3_C, OP3_D, OP3_E, OP3_F
+} INSN_OP3;
+
+/* Enum declaration for insn op4 enums. */
+typedef enum insn_op4 {
+ OP4_0
+} INSN_OP4;
+
+/* Enum declaration for insn op5 enums. */
+typedef enum insn_op5 {
+ OP5_0, OP5_1
+} INSN_OP5;
+
+/* Enum declaration for insn cc enums. */
+typedef enum insn_cc {
+ CC_RA, CC_NO, CC_EQ, CC_NE
+ , CC_C, CC_NC, CC_N, CC_P
+ , CC_V, CC_NV, CC_LT, CC_GE
+ , CC_LE, CC_GT, CC_LS, CC_HI
+} INSN_CC;
+
+/* Enum declaration for . */
+typedef enum gr_names {
+ H_GR_R0 = 0, H_GR_R1 = 1, H_GR_R2 = 2, H_GR_R3 = 3
+ , H_GR_R4 = 4, H_GR_R5 = 5, H_GR_R6 = 6, H_GR_R7 = 7
+ , H_GR_R8 = 8, H_GR_R9 = 9, H_GR_R10 = 10, H_GR_R11 = 11
+ , H_GR_R12 = 12, H_GR_R13 = 13, H_GR_R14 = 14, H_GR_R15 = 15
+ , H_GR_AC = 13, H_GR_FP = 14, H_GR_SP = 15
+} GR_NAMES;
+
+/* Enum declaration for . */
+typedef enum cr_names {
+ H_CR_CR0, H_CR_CR1, H_CR_CR2, H_CR_CR3
+ , H_CR_CR4, H_CR_CR5, H_CR_CR6, H_CR_CR7
+ , H_CR_CR8, H_CR_CR9, H_CR_CR10, H_CR_CR11
+ , H_CR_CR12, H_CR_CR13, H_CR_CR14, H_CR_CR15
+} CR_NAMES;
+
+/* Enum declaration for . */
+typedef enum dr_names {
+ H_DR_TBR, H_DR_RP, H_DR_SSP, H_DR_USP
+ , H_DR_MDH, H_DR_MDL
+} DR_NAMES;
+
+/* Attributes. */
+
+/* Enum declaration for machine type selection. */
+typedef enum mach_attr {
+ MACH_BASE, MACH_FR30, MACH_MAX
+} MACH_ATTR;
+
+/* Enum declaration for instruction set selection. */
+typedef enum isa_attr {
+ ISA_FR30, ISA_MAX
+} ISA_ATTR;
+
+/* Number of architecture variants. */
+#define MAX_ISAS 1
+#define MAX_MACHS ((int) MACH_MAX)
+
+/* Ifield support. */
+
+extern const struct cgen_ifld fr30_cgen_ifld_table[];
+
+/* Ifield attribute indices. */
+
+/* Enum declaration for cgen_ifld attrs. */
+typedef enum cgen_ifld_attr {
+ CGEN_IFLD_VIRTUAL, CGEN_IFLD_PCREL_ADDR, CGEN_IFLD_ABS_ADDR, CGEN_IFLD_RESERVED
+ , CGEN_IFLD_SIGN_OPT, CGEN_IFLD_SIGNED, CGEN_IFLD_END_BOOLS, CGEN_IFLD_START_NBOOLS = 31
+ , CGEN_IFLD_MACH, CGEN_IFLD_END_NBOOLS
+} CGEN_IFLD_ATTR;
+
+/* Number of non-boolean elements in cgen_ifld_attr. */
+#define CGEN_IFLD_NBOOL_ATTRS (CGEN_IFLD_END_NBOOLS - CGEN_IFLD_START_NBOOLS - 1)
+
+/* Enum declaration for fr30 ifield types. */
+typedef enum ifield_type {
+ FR30_F_NIL, FR30_F_OP1, FR30_F_OP2, FR30_F_OP3
+ , FR30_F_OP4, FR30_F_OP5, FR30_F_CC, FR30_F_CCC
+ , FR30_F_RJ, FR30_F_RI, FR30_F_RS1, FR30_F_RS2
+ , FR30_F_RJC, FR30_F_RIC, FR30_F_CRJ, FR30_F_CRI
+ , FR30_F_U4, FR30_F_U4C, FR30_F_I4, FR30_F_M4
+ , FR30_F_U8, FR30_F_I8, FR30_F_I20_4, FR30_F_I20_16
+ , FR30_F_I20, FR30_F_I32, FR30_F_UDISP6, FR30_F_DISP8
+ , FR30_F_DISP9, FR30_F_DISP10, FR30_F_S10, FR30_F_U10
+ , FR30_F_REL9, FR30_F_DIR8, FR30_F_DIR9, FR30_F_DIR10
+ , FR30_F_REL12, FR30_F_REGLIST_HI_ST, FR30_F_REGLIST_LOW_ST, FR30_F_REGLIST_HI_LD
+ , FR30_F_REGLIST_LOW_LD, FR30_F_MAX
+} IFIELD_TYPE;
+
+#define MAX_IFLD ((int) FR30_F_MAX)
+
+/* Hardware attribute indices. */
+
+/* Enum declaration for cgen_hw attrs. */
+typedef enum cgen_hw_attr {
+ CGEN_HW_VIRTUAL, CGEN_HW_CACHE_ADDR, CGEN_HW_PC, CGEN_HW_PROFILE
+ , CGEN_HW_END_BOOLS, CGEN_HW_START_NBOOLS = 31, CGEN_HW_MACH, CGEN_HW_END_NBOOLS
+} CGEN_HW_ATTR;
+
+/* Number of non-boolean elements in cgen_hw_attr. */
+#define CGEN_HW_NBOOL_ATTRS (CGEN_HW_END_NBOOLS - CGEN_HW_START_NBOOLS - 1)
+
+/* Enum declaration for fr30 hardware types. */
+typedef enum cgen_hw_type {
+ HW_H_MEMORY, HW_H_SINT, HW_H_UINT, HW_H_ADDR
+ , HW_H_IADDR, HW_H_PC, HW_H_GR, HW_H_CR
+ , HW_H_DR, HW_H_PS, HW_H_R13, HW_H_R14
+ , HW_H_R15, HW_H_NBIT, HW_H_ZBIT, HW_H_VBIT
+ , HW_H_CBIT, HW_H_IBIT, HW_H_SBIT, HW_H_TBIT
+ , HW_H_D0BIT, HW_H_D1BIT, HW_H_CCR, HW_H_SCR
+ , HW_H_ILM, HW_MAX
+} CGEN_HW_TYPE;
+
+#define MAX_HW ((int) HW_MAX)
+
+/* Operand attribute indices. */
+
+/* Enum declaration for cgen_operand attrs. */
+typedef enum cgen_operand_attr {
+ CGEN_OPERAND_VIRTUAL, CGEN_OPERAND_PCREL_ADDR, CGEN_OPERAND_ABS_ADDR, CGEN_OPERAND_SIGN_OPT
+ , CGEN_OPERAND_SIGNED, CGEN_OPERAND_NEGATIVE, CGEN_OPERAND_RELAX, CGEN_OPERAND_SEM_ONLY
+ , CGEN_OPERAND_HASH_PREFIX, CGEN_OPERAND_END_BOOLS, CGEN_OPERAND_START_NBOOLS = 31, CGEN_OPERAND_MACH
+ , CGEN_OPERAND_END_NBOOLS
+} CGEN_OPERAND_ATTR;
+
+/* Number of non-boolean elements in cgen_operand_attr. */
+#define CGEN_OPERAND_NBOOL_ATTRS (CGEN_OPERAND_END_NBOOLS - CGEN_OPERAND_START_NBOOLS - 1)
+
+/* Enum declaration for fr30 operand types. */
+typedef enum cgen_operand_type {
+ FR30_OPERAND_PC, FR30_OPERAND_RI, FR30_OPERAND_RJ, FR30_OPERAND_RIC
+ , FR30_OPERAND_RJC, FR30_OPERAND_CRI, FR30_OPERAND_CRJ, FR30_OPERAND_RS1
+ , FR30_OPERAND_RS2, FR30_OPERAND_R13, FR30_OPERAND_R14, FR30_OPERAND_R15
+ , FR30_OPERAND_PS, FR30_OPERAND_U4, FR30_OPERAND_U4C, FR30_OPERAND_U8
+ , FR30_OPERAND_I8, FR30_OPERAND_UDISP6, FR30_OPERAND_DISP8, FR30_OPERAND_DISP9
+ , FR30_OPERAND_DISP10, FR30_OPERAND_S10, FR30_OPERAND_U10, FR30_OPERAND_I32
+ , FR30_OPERAND_M4, FR30_OPERAND_I20, FR30_OPERAND_DIR8, FR30_OPERAND_DIR9
+ , FR30_OPERAND_DIR10, FR30_OPERAND_LABEL9, FR30_OPERAND_LABEL12, FR30_OPERAND_REGLIST_LOW_LD
+ , FR30_OPERAND_REGLIST_HI_LD, FR30_OPERAND_REGLIST_LOW_ST, FR30_OPERAND_REGLIST_HI_ST, FR30_OPERAND_CC
+ , FR30_OPERAND_CCC, FR30_OPERAND_NBIT, FR30_OPERAND_VBIT, FR30_OPERAND_ZBIT
+ , FR30_OPERAND_CBIT, FR30_OPERAND_IBIT, FR30_OPERAND_SBIT, FR30_OPERAND_TBIT
+ , FR30_OPERAND_D0BIT, FR30_OPERAND_D1BIT, FR30_OPERAND_CCR, FR30_OPERAND_SCR
+ , FR30_OPERAND_ILM, FR30_OPERAND_MAX
+} CGEN_OPERAND_TYPE;
+
+/* Number of operands types. */
+#define MAX_OPERANDS ((int) FR30_OPERAND_MAX)
+
+/* Maximum number of operands referenced by any insn. */
+#define MAX_OPERAND_INSTANCES 8
+
+/* Insn attribute indices. */
+
+/* Enum declaration for cgen_insn attrs. */
+typedef enum cgen_insn_attr {
+ CGEN_INSN_ALIAS, CGEN_INSN_VIRTUAL, CGEN_INSN_UNCOND_CTI, CGEN_INSN_COND_CTI
+ , CGEN_INSN_SKIP_CTI, CGEN_INSN_DELAY_SLOT, CGEN_INSN_RELAXABLE, CGEN_INSN_RELAX
+ , CGEN_INSN_NO_DIS, CGEN_INSN_PBB, CGEN_INSN_NOT_IN_DELAY_SLOT, CGEN_INSN_END_BOOLS
+ , CGEN_INSN_START_NBOOLS = 31, CGEN_INSN_MACH, CGEN_INSN_END_NBOOLS
+} CGEN_INSN_ATTR;
+
+/* Number of non-boolean elements in cgen_insn_attr. */
+#define CGEN_INSN_NBOOL_ATTRS (CGEN_INSN_END_NBOOLS - CGEN_INSN_START_NBOOLS - 1)
+
+/* cgen.h uses things we just defined. */
+#include "opcode/cgen.h"
+
+/* Attributes. */
+extern const CGEN_ATTR_TABLE fr30_cgen_hardware_attr_table[];
+extern const CGEN_ATTR_TABLE fr30_cgen_ifield_attr_table[];
+extern const CGEN_ATTR_TABLE fr30_cgen_operand_attr_table[];
+extern const CGEN_ATTR_TABLE fr30_cgen_insn_attr_table[];
+
+/* Hardware decls. */
+
+extern CGEN_KEYWORD fr30_cgen_opval_gr_names;
+extern CGEN_KEYWORD fr30_cgen_opval_cr_names;
+extern CGEN_KEYWORD fr30_cgen_opval_dr_names;
+extern CGEN_KEYWORD fr30_cgen_opval_h_ps;
+extern CGEN_KEYWORD fr30_cgen_opval_h_r13;
+extern CGEN_KEYWORD fr30_cgen_opval_h_r14;
+extern CGEN_KEYWORD fr30_cgen_opval_h_r15;
+
+
+
+
+#endif /* FR30_CPU_H */
diff --git a/opcodes/fr30-dis.c b/opcodes/fr30-dis.c
new file mode 100644
index 00000000000..0d7c18c766d
--- /dev/null
+++ b/opcodes/fr30-dis.c
@@ -0,0 +1,630 @@
+/* Disassembler interface for targets using CGEN. -*- C -*-
+ CGEN: Cpu tools GENerator
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+- the resultant file is machine generated, cgen-dis.in isn't
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ??? Eventually more and more of this stuff can go to cpu-independent files.
+ Keep that in mind. */
+
+#include "sysdep.h"
+#include <stdio.h>
+#include "ansidecl.h"
+#include "dis-asm.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "fr30-desc.h"
+#include "fr30-opc.h"
+#include "opintl.h"
+
+/* Default text to print if an instruction isn't recognized. */
+#define UNKNOWN_INSN_MSG _("*unknown*")
+
+static void print_normal
+ PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned int, bfd_vma, int));
+static void print_address
+ PARAMS ((CGEN_CPU_DESC, PTR, bfd_vma, unsigned int, bfd_vma, int));
+static void print_keyword
+ PARAMS ((CGEN_CPU_DESC, PTR, CGEN_KEYWORD *, long, unsigned int));
+static void print_insn_normal
+ PARAMS ((CGEN_CPU_DESC, PTR, const CGEN_INSN *, CGEN_FIELDS *,
+ bfd_vma, int));
+static int print_insn PARAMS ((CGEN_CPU_DESC, bfd_vma,
+ disassemble_info *, char *, int));
+static int default_print_insn
+ PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *));
+
+/* -- disassembler routines inserted here */
+
+/* -- dis.c */
+
+static void
+print_register_list (dis_info, value, offset, load_store)
+ PTR dis_info;
+ long value;
+ long offset;
+ int load_store; /* 0 == load, 1 == store */
+{
+ disassemble_info *info = dis_info;
+ int mask;
+ int index = 0;
+ char* comma = "";
+
+ if (load_store)
+ mask = 0x80;
+ else
+ mask = 1;
+
+ if (value & mask)
+ {
+ (*info->fprintf_func) (info->stream, "r%i", index + offset);
+ comma = ",";
+ }
+
+ for (index = 1; index <= 7; ++index)
+ {
+ if (load_store)
+ mask >>= 1;
+ else
+ mask <<= 1;
+
+ if (value & mask)
+ {
+ (*info->fprintf_func) (info->stream, "%sr%i", comma, index + offset);
+ comma = ",";
+ }
+ }
+}
+
+static void
+print_hi_register_list_ld (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ print_register_list (dis_info, value, 8, 0/*load*/);
+}
+
+static void
+print_low_register_list_ld (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ print_register_list (dis_info, value, 0, 0/*load*/);
+}
+
+static void
+print_hi_register_list_st (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ print_register_list (dis_info, value, 8, 1/*store*/);
+}
+
+static void
+print_low_register_list_st (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ print_register_list (dis_info, value, 0, 1/*store*/);
+}
+
+static void
+print_m4 (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+ (*info->fprintf_func) (info->stream, "%ld", value);
+}
+/* -- */
+
+/* Main entry point for printing operands.
+ XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
+ of dis-asm.h on cgen.h.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `print_insn_normal', but keeping it
+ separate makes clear the interface between `print_insn_normal' and each of
+ the handlers.
+*/
+
+void
+fr30_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ PTR xinfo;
+ CGEN_FIELDS *fields;
+ void const *attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) xinfo;
+
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ print_keyword (cd, info, & fr30_cgen_opval_cr_names, fields->f_CRi, 0);
+ break;
+ case FR30_OPERAND_CRJ :
+ print_keyword (cd, info, & fr30_cgen_opval_cr_names, fields->f_CRj, 0);
+ break;
+ case FR30_OPERAND_R13 :
+ print_keyword (cd, info, & fr30_cgen_opval_h_r13, fields->f_nil, 0);
+ break;
+ case FR30_OPERAND_R14 :
+ print_keyword (cd, info, & fr30_cgen_opval_h_r14, fields->f_nil, 0);
+ break;
+ case FR30_OPERAND_R15 :
+ print_keyword (cd, info, & fr30_cgen_opval_h_r15, fields->f_nil, 0);
+ break;
+ case FR30_OPERAND_RI :
+ print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Ri, 0);
+ break;
+ case FR30_OPERAND_RIC :
+ print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Ric, 0);
+ break;
+ case FR30_OPERAND_RJ :
+ print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Rj, 0);
+ break;
+ case FR30_OPERAND_RJC :
+ print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Rjc, 0);
+ break;
+ case FR30_OPERAND_RS1 :
+ print_keyword (cd, info, & fr30_cgen_opval_dr_names, fields->f_Rs1, 0);
+ break;
+ case FR30_OPERAND_RS2 :
+ print_keyword (cd, info, & fr30_cgen_opval_dr_names, fields->f_Rs2, 0);
+ break;
+ case FR30_OPERAND_CC :
+ print_normal (cd, info, fields->f_cc, 0, pc, length);
+ break;
+ case FR30_OPERAND_CCC :
+ print_normal (cd, info, fields->f_ccc, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_DIR10 :
+ print_normal (cd, info, fields->f_dir10, 0, pc, length);
+ break;
+ case FR30_OPERAND_DIR8 :
+ print_normal (cd, info, fields->f_dir8, 0, pc, length);
+ break;
+ case FR30_OPERAND_DIR9 :
+ print_normal (cd, info, fields->f_dir9, 0, pc, length);
+ break;
+ case FR30_OPERAND_DISP10 :
+ print_normal (cd, info, fields->f_disp10, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_DISP8 :
+ print_normal (cd, info, fields->f_disp8, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_DISP9 :
+ print_normal (cd, info, fields->f_disp9, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_I20 :
+ print_normal (cd, info, fields->f_i20, 0|(1<<CGEN_OPERAND_HASH_PREFIX)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
+ break;
+ case FR30_OPERAND_I32 :
+ print_normal (cd, info, fields->f_i32, 0|(1<<CGEN_OPERAND_HASH_PREFIX)|(1<<CGEN_OPERAND_SIGN_OPT), pc, length);
+ break;
+ case FR30_OPERAND_I8 :
+ print_normal (cd, info, fields->f_i8, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_LABEL12 :
+ print_address (cd, info, fields->f_rel12, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
+ break;
+ case FR30_OPERAND_LABEL9 :
+ print_address (cd, info, fields->f_rel9, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
+ break;
+ case FR30_OPERAND_M4 :
+ print_m4 (cd, info, fields->f_m4, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_PS :
+ print_keyword (cd, info, & fr30_cgen_opval_h_ps, fields->f_nil, 0);
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ print_hi_register_list_ld (cd, info, fields->f_reglist_hi_ld, 0, pc, length);
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ print_hi_register_list_st (cd, info, fields->f_reglist_hi_st, 0, pc, length);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ print_low_register_list_ld (cd, info, fields->f_reglist_low_ld, 0, pc, length);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ print_low_register_list_st (cd, info, fields->f_reglist_low_st, 0, pc, length);
+ break;
+ case FR30_OPERAND_S10 :
+ print_normal (cd, info, fields->f_s10, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_U10 :
+ print_normal (cd, info, fields->f_u10, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_U4 :
+ print_normal (cd, info, fields->f_u4, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_U4C :
+ print_normal (cd, info, fields->f_u4c, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_U8 :
+ print_normal (cd, info, fields->f_u8, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case FR30_OPERAND_UDISP6 :
+ print_normal (cd, info, fields->f_udisp6, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
+ opindex);
+ abort ();
+ }
+}
+
+cgen_print_fn * const fr30_cgen_print_handlers[] =
+{
+ print_insn_normal,
+};
+
+
+void
+fr30_cgen_init_dis (cd)
+ CGEN_CPU_DESC cd;
+{
+ fr30_cgen_init_opcode_table (cd);
+ fr30_cgen_init_ibld_table (cd);
+ cd->print_handlers = & fr30_cgen_print_handlers[0];
+ cd->print_operand = fr30_cgen_print_operand;
+}
+
+
+/* Default print handler. */
+
+static void
+print_normal (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+
+#ifdef CGEN_PRINT_NORMAL
+ CGEN_PRINT_NORMAL (cd, info, value, attrs, pc, length);
+#endif
+
+ /* Print the operand as directed by the attributes. */
+ if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
+ ; /* nothing to do */
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
+ (*info->fprintf_func) (info->stream, "%ld", value);
+ else
+ (*info->fprintf_func) (info->stream, "0x%lx", value);
+}
+
+/* Default address handler. */
+
+static void
+print_address (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ bfd_vma value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+
+#ifdef CGEN_PRINT_ADDRESS
+ CGEN_PRINT_ADDRESS (cd, info, value, attrs, pc, length);
+#endif
+
+ /* Print the operand as directed by the attributes. */
+ if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
+ ; /* nothing to do */
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
+ (*info->print_address_func) (value, info);
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
+ (*info->print_address_func) (value, info);
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
+ (*info->fprintf_func) (info->stream, "%ld", (long) value);
+ else
+ (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
+}
+
+/* Keyword print handler. */
+
+static void
+print_keyword (cd, dis_info, keyword_table, value, attrs)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ CGEN_KEYWORD *keyword_table;
+ long value;
+ unsigned int attrs;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+ const CGEN_KEYWORD_ENTRY *ke;
+
+ ke = cgen_keyword_lookup_value (keyword_table, value);
+ if (ke != NULL)
+ (*info->fprintf_func) (info->stream, "%s", ke->name);
+ else
+ (*info->fprintf_func) (info->stream, "???");
+}
+
+/* Default insn printer.
+
+ DIS_INFO is defined as `PTR' so the disassembler needn't know anything
+ about disassemble_info. */
+
+static void
+print_insn_normal (cd, dis_info, insn, fields, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ const CGEN_INSN *insn;
+ CGEN_FIELDS *fields;
+ bfd_vma pc;
+ int length;
+{
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ disassemble_info *info = (disassemble_info *) dis_info;
+ const unsigned char *syn;
+
+ CGEN_INIT_PRINT (cd);
+
+ for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
+ {
+ if (CGEN_SYNTAX_MNEMONIC_P (*syn))
+ {
+ (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
+ continue;
+ }
+ if (CGEN_SYNTAX_CHAR_P (*syn))
+ {
+ (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
+ continue;
+ }
+
+ /* We have an operand. */
+ fr30_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
+ fields, CGEN_INSN_ATTRS (insn), pc, length);
+ }
+}
+
+/* Utility to print an insn.
+ BUF is the base part of the insn, target byte order, BUFLEN bytes long.
+ The result is the size of the insn in bytes or zero for an unknown insn
+ or -1 if an error occurs fetching data (memory_error_func will have
+ been called). */
+
+static int
+print_insn (cd, pc, info, buf, buflen)
+ CGEN_CPU_DESC cd;
+ bfd_vma pc;
+ disassemble_info *info;
+ char *buf;
+ int buflen;
+{
+ unsigned long insn_value;
+ const CGEN_INSN_LIST *insn_list;
+ CGEN_EXTRACT_INFO ex_info;
+
+ ex_info.dis_info = info;
+ ex_info.valid = (1 << (cd->base_insn_bitsize / 8)) - 1;
+ ex_info.insn_bytes = buf;
+
+ switch (buflen)
+ {
+ case 1:
+ insn_value = buf[0];
+ break;
+ case 2:
+ insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf);
+ break;
+ case 4:
+ insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf);
+ break;
+ default:
+ abort ();
+ }
+
+ /* The instructions are stored in hash lists.
+ Pick the first one and keep trying until we find the right one. */
+
+ insn_list = CGEN_DIS_LOOKUP_INSN (cd, buf, insn_value);
+ while (insn_list != NULL)
+ {
+ const CGEN_INSN *insn = insn_list->insn;
+ CGEN_FIELDS fields;
+ int length;
+
+#if 0 /* not needed as insn shouldn't be in hash lists if not supported */
+ /* Supported by this cpu? */
+ if (! fr30_cgen_insn_supported (cd, insn))
+ continue;
+#endif
+
+ /* Basic bit mask must be correct. */
+ /* ??? May wish to allow target to defer this check until the extract
+ handler. */
+ if ((insn_value & CGEN_INSN_BASE_MASK (insn))
+ == CGEN_INSN_BASE_VALUE (insn))
+ {
+ /* Printing is handled in two passes. The first pass parses the
+ machine insn and extracts the fields. The second pass prints
+ them. */
+
+ length = CGEN_EXTRACT_FN (cd, insn)
+ (cd, insn, &ex_info, insn_value, &fields, pc);
+ /* length < 0 -> error */
+ if (length < 0)
+ return length;
+ if (length > 0)
+ {
+ CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
+ /* length is in bits, result is in bytes */
+ return length / 8;
+ }
+ }
+
+ insn_list = CGEN_DIS_NEXT_INSN (insn_list);
+ }
+
+ return 0;
+}
+
+/* Default value for CGEN_PRINT_INSN.
+ The result is the size of the insn in bytes or zero for an unknown insn
+ or -1 if an error occured fetching bytes. */
+
+#ifndef CGEN_PRINT_INSN
+#define CGEN_PRINT_INSN default_print_insn
+#endif
+
+static int
+default_print_insn (cd, pc, info)
+ CGEN_CPU_DESC cd;
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ char buf[CGEN_MAX_INSN_SIZE];
+ int status;
+
+ /* Read the base part of the insn. */
+
+ status = (*info->read_memory_func) (pc, buf, cd->base_insn_bitsize / 8, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+
+ return print_insn (cd, pc, info, buf, cd->base_insn_bitsize / 8);
+}
+
+/* Main entry point.
+ Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction (in bytes). */
+
+int
+print_insn_fr30 (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ static CGEN_CPU_DESC cd = 0;
+ static prev_isa,prev_mach,prev_endian;
+ int length;
+ int isa,mach;
+ int endian = (info->endian == BFD_ENDIAN_BIG
+ ? CGEN_ENDIAN_BIG
+ : CGEN_ENDIAN_LITTLE);
+ enum bfd_architecture arch;
+
+ /* ??? gdb will set mach but leave the architecture as "unknown" */
+#ifndef CGEN_BFD_ARCH
+#define CGEN_BFD_ARCH bfd_arch_fr30
+#endif
+ arch = info->arch;
+ if (arch == bfd_arch_unknown)
+ arch = CGEN_BFD_ARCH;
+
+ /* There's no standard way to compute the isa number (e.g. for arm thumb)
+ so we leave it to the target. */
+#ifdef CGEN_COMPUTE_ISA
+ isa = CGEN_COMPUTE_ISA (info);
+#else
+ isa = 0;
+#endif
+
+ mach = info->mach;
+
+ /* If we've switched cpu's, close the current table and open a new one. */
+ if (cd
+ && (isa != prev_isa
+ || mach != prev_mach
+ || endian != prev_endian))
+ {
+ fr30_cgen_cpu_close (cd);
+ cd = 0;
+ }
+
+ /* If we haven't initialized yet, initialize the opcode table. */
+ if (! cd)
+ {
+ const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
+ const char *mach_name;
+
+ if (!arch_type)
+ abort ();
+ mach_name = arch_type->printable_name;
+
+ prev_isa = isa;
+ prev_mach = mach;
+ prev_endian = endian;
+ cd = fr30_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
+ CGEN_CPU_OPEN_BFDMACH, mach_name,
+ CGEN_CPU_OPEN_ENDIAN, prev_endian,
+ CGEN_CPU_OPEN_END);
+ if (!cd)
+ abort ();
+ fr30_cgen_init_dis (cd);
+ }
+
+ /* We try to have as much common code as possible.
+ But at this point some targets need to take over. */
+ /* ??? Some targets may need a hook elsewhere. Try to avoid this,
+ but if not possible try to move this hook elsewhere rather than
+ have two hooks. */
+ length = CGEN_PRINT_INSN (cd, pc, info);
+ if (length > 0)
+ return length;
+ if (length < 0)
+ return -1;
+
+ (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
+ return cd->default_insn_bitsize / 8;
+}
diff --git a/opcodes/fr30-ibld.c b/opcodes/fr30-ibld.c
new file mode 100644
index 00000000000..386613d41c7
--- /dev/null
+++ b/opcodes/fr30-ibld.c
@@ -0,0 +1,1506 @@
+/* Instruction building/extraction support for fr30. -*- C -*-
+
+THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
+- the resultant file is machine generated, cgen-ibld.in isn't
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ??? Eventually more and more of this stuff can go to cpu-independent files.
+ Keep that in mind. */
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include "ansidecl.h"
+#include "dis-asm.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "fr30-desc.h"
+#include "fr30-opc.h"
+#include "opintl.h"
+
+#undef min
+#define min(a,b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a,b) ((a) > (b) ? (a) : (b))
+
+/* Used by the ifield rtx function. */
+#define FLD(f) (fields->f)
+
+static const char * insert_normal
+ PARAMS ((CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
+ unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR));
+static const char * insert_insn_normal
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *,
+ CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma));
+
+static int extract_normal
+ PARAMS ((CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
+ unsigned int, unsigned int, unsigned int, unsigned int,
+ unsigned int, unsigned int, bfd_vma, long *));
+static int extract_insn_normal
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
+ CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma));
+
+/* Operand insertion. */
+
+#if ! CGEN_INT_INSN_P
+
+/* Subroutine of insert_normal. */
+
+static CGEN_INLINE void
+insert_1 (cd, value, start, length, word_length, bufp)
+ CGEN_CPU_DESC cd;
+ unsigned long value;
+ int start,length,word_length;
+ unsigned char *bufp;
+{
+ unsigned long x,mask;
+ int shift;
+ int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+
+ switch (word_length)
+ {
+ case 8:
+ x = *bufp;
+ break;
+ case 16:
+ if (big_p)
+ x = bfd_getb16 (bufp);
+ else
+ x = bfd_getl16 (bufp);
+ break;
+ case 24:
+ /* ??? This may need reworking as these cases don't necessarily
+ want the first byte and the last two bytes handled like this. */
+ if (big_p)
+ x = (bufp[0] << 16) | bfd_getb16 (bufp + 1);
+ else
+ x = bfd_getl16 (bufp) | (bufp[2] << 16);
+ break;
+ case 32:
+ if (big_p)
+ x = bfd_getb32 (bufp);
+ else
+ x = bfd_getl32 (bufp);
+ break;
+ default :
+ abort ();
+ }
+
+ /* Written this way to avoid undefined behaviour. */
+ mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ if (CGEN_INSN_LSB0_P)
+ shift = (start + 1) - length;
+ else
+ shift = (word_length - (start + length));
+ x = (x & ~(mask << shift)) | ((value & mask) << shift);
+
+ switch (word_length)
+ {
+ case 8:
+ *bufp = x;
+ break;
+ case 16:
+ if (big_p)
+ bfd_putb16 (x, bufp);
+ else
+ bfd_putl16 (x, bufp);
+ break;
+ case 24:
+ /* ??? This may need reworking as these cases don't necessarily
+ want the first byte and the last two bytes handled like this. */
+ if (big_p)
+ {
+ bufp[0] = x >> 16;
+ bfd_putb16 (x, bufp + 1);
+ }
+ else
+ {
+ bfd_putl16 (x, bufp);
+ bufp[2] = x >> 16;
+ }
+ break;
+ case 32:
+ if (big_p)
+ bfd_putb32 (x, bufp);
+ else
+ bfd_putl32 (x, bufp);
+ break;
+ default :
+ abort ();
+ }
+}
+
+#endif /* ! CGEN_INT_INSN_P */
+
+/* Default insertion routine.
+
+ ATTRS is a mask of the boolean attributes.
+ WORD_OFFSET is the offset in bits from the start of the insn of the value.
+ WORD_LENGTH is the length of the word in bits in which the value resides.
+ START is the starting bit number in the word, architecture origin.
+ LENGTH is the length of VALUE in bits.
+ TOTAL_LENGTH is the total length of the insn in bits.
+
+ The result is an error message or NULL if success. */
+
+/* ??? This duplicates functionality with bfd's howto table and
+ bfd_install_relocation. */
+/* ??? This doesn't handle bfd_vma's. Create another function when
+ necessary. */
+
+static const char *
+insert_normal (cd, value, attrs, word_offset, start, length, word_length,
+ total_length, buffer)
+ CGEN_CPU_DESC cd;
+ long value;
+ unsigned int attrs;
+ unsigned int word_offset, start, length, word_length, total_length;
+ CGEN_INSN_BYTES_PTR buffer;
+{
+ static char errbuf[100];
+ /* Written this way to avoid undefined behaviour. */
+ unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+
+ /* If LENGTH is zero, this operand doesn't contribute to the value. */
+ if (length == 0)
+ return NULL;
+
+ if (CGEN_INT_INSN_P
+ && word_offset != 0)
+ abort ();
+
+ if (word_length > 32)
+ abort ();
+
+ /* For architectures with insns smaller than the base-insn-bitsize,
+ word_length may be too big. */
+ if (cd->min_insn_bitsize < cd->base_insn_bitsize)
+ {
+ if (word_offset == 0
+ && word_length > total_length)
+ word_length = total_length;
+ }
+
+ /* Ensure VALUE will fit. */
+ if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
+ {
+ unsigned long maxval = mask;
+ if ((unsigned long) value > maxval)
+ {
+ /* xgettext:c-format */
+ sprintf (errbuf,
+ _("operand out of range (%lu not between 0 and %lu)"),
+ value, maxval);
+ return errbuf;
+ }
+ }
+ else
+ {
+ long minval = - (1L << (length - 1));
+ long maxval = (1L << (length - 1)) - 1;
+ if (value < minval || value > maxval)
+ {
+ sprintf
+ /* xgettext:c-format */
+ (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
+ value, minval, maxval);
+ return errbuf;
+ }
+ }
+
+#if CGEN_INT_INSN_P
+
+ {
+ int shift;
+
+ if (CGEN_INSN_LSB0_P)
+ shift = (start + 1) - length;
+ else
+ shift = word_length - (start + length);
+ *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
+ }
+
+#else /* ! CGEN_INT_INSN_P */
+
+ {
+ unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
+
+ insert_1 (cd, value, start, length, word_length, bufp);
+ }
+
+#endif /* ! CGEN_INT_INSN_P */
+
+ return NULL;
+}
+
+/* Default insn builder (insert handler).
+ The instruction is recorded in CGEN_INT_INSN_P byte order
+ (meaning that if CGEN_INT_INSN_P BUFFER is an int * and thus the value is
+ recorded in host byte order, otherwise BUFFER is an array of bytes and the
+ value is recorded in target byte order).
+ The result is an error message or NULL if success. */
+
+static const char *
+insert_insn_normal (cd, insn, fields, buffer, pc)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN * insn;
+ CGEN_FIELDS * fields;
+ CGEN_INSN_BYTES_PTR buffer;
+ bfd_vma pc;
+{
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ unsigned long value;
+ const unsigned char * syn;
+
+ CGEN_INIT_INSERT (cd);
+ value = CGEN_INSN_BASE_VALUE (insn);
+
+ /* If we're recording insns as numbers (rather than a string of bytes),
+ target byte order handling is deferred until later. */
+
+#if CGEN_INT_INSN_P
+
+ *buffer = value;
+
+#else
+
+ cgen_put_insn_value (cd, buffer, min (cd->base_insn_bitsize,
+ CGEN_FIELDS_BITSIZE (fields)),
+ value);
+
+#endif /* ! CGEN_INT_INSN_P */
+
+ /* ??? It would be better to scan the format's fields.
+ Still need to be able to insert a value based on the operand though;
+ e.g. storing a branch displacement that got resolved later.
+ Needs more thought first. */
+
+ for (syn = CGEN_SYNTAX_STRING (syntax); * syn != '\0'; ++ syn)
+ {
+ const char *errmsg;
+
+ if (CGEN_SYNTAX_CHAR_P (* syn))
+ continue;
+
+ errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
+ fields, buffer, pc);
+ if (errmsg)
+ return errmsg;
+ }
+
+ return NULL;
+}
+
+/* Operand extraction. */
+
+#if ! CGEN_INT_INSN_P
+
+/* Subroutine of extract_normal.
+ Ensure sufficient bytes are cached in EX_INFO.
+ OFFSET is the offset in bytes from the start of the insn of the value.
+ BYTES is the length of the needed value.
+ Returns 1 for success, 0 for failure. */
+
+static CGEN_INLINE int
+fill_cache (cd, ex_info, offset, bytes, pc)
+ CGEN_CPU_DESC cd;
+ CGEN_EXTRACT_INFO *ex_info;
+ int offset, bytes;
+ bfd_vma pc;
+{
+ /* It's doubtful that the middle part has already been fetched so
+ we don't optimize that case. kiss. */
+ int mask;
+ disassemble_info *info = (disassemble_info *) ex_info->dis_info;
+
+ /* First do a quick check. */
+ mask = (1 << bytes) - 1;
+ if (((ex_info->valid >> offset) & mask) == mask)
+ return 1;
+
+ /* Search for the first byte we need to read. */
+ for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
+ if (! (mask & ex_info->valid))
+ break;
+
+ if (bytes)
+ {
+ int status;
+
+ pc += offset;
+ status = (*info->read_memory_func)
+ (pc, ex_info->insn_bytes + offset, bytes, info);
+
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return 0;
+ }
+
+ ex_info->valid |= ((1 << bytes) - 1) << offset;
+ }
+
+ return 1;
+}
+
+/* Subroutine of extract_normal. */
+
+static CGEN_INLINE long
+extract_1 (cd, ex_info, start, length, word_length, bufp, pc)
+ CGEN_CPU_DESC cd;
+ CGEN_EXTRACT_INFO *ex_info;
+ int start,length,word_length;
+ unsigned char *bufp;
+ bfd_vma pc;
+{
+ unsigned long x,mask;
+ int shift;
+ int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+
+ switch (word_length)
+ {
+ case 8:
+ x = *bufp;
+ break;
+ case 16:
+ if (big_p)
+ x = bfd_getb16 (bufp);
+ else
+ x = bfd_getl16 (bufp);
+ break;
+ case 24:
+ /* ??? This may need reworking as these cases don't necessarily
+ want the first byte and the last two bytes handled like this. */
+ if (big_p)
+ x = (bufp[0] << 16) | bfd_getb16 (bufp + 1);
+ else
+ x = bfd_getl16 (bufp) | (bufp[2] << 16);
+ break;
+ case 32:
+ if (big_p)
+ x = bfd_getb32 (bufp);
+ else
+ x = bfd_getl32 (bufp);
+ break;
+ default :
+ abort ();
+ }
+
+ /* Written this way to avoid undefined behaviour. */
+ mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ if (CGEN_INSN_LSB0_P)
+ shift = (start + 1) - length;
+ else
+ shift = (word_length - (start + length));
+ return (x >> shift) & mask;
+}
+
+#endif /* ! CGEN_INT_INSN_P */
+
+/* Default extraction routine.
+
+ INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
+ or sometimes less for cases like the m32r where the base insn size is 32
+ but some insns are 16 bits.
+ ATTRS is a mask of the boolean attributes. We only need `SIGNED',
+ but for generality we take a bitmask of all of them.
+ WORD_OFFSET is the offset in bits from the start of the insn of the value.
+ WORD_LENGTH is the length of the word in bits in which the value resides.
+ START is the starting bit number in the word, architecture origin.
+ LENGTH is the length of VALUE in bits.
+ TOTAL_LENGTH is the total length of the insn in bits.
+
+ Returns 1 for success, 0 for failure. */
+
+/* ??? The return code isn't properly used. wip. */
+
+/* ??? This doesn't handle bfd_vma's. Create another function when
+ necessary. */
+
+static int
+extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length,
+ word_length, total_length, pc, valuep)
+ CGEN_CPU_DESC cd;
+ CGEN_EXTRACT_INFO *ex_info;
+ CGEN_INSN_INT insn_value;
+ unsigned int attrs;
+ unsigned int word_offset, start, length, word_length, total_length;
+ bfd_vma pc;
+ long *valuep;
+{
+ CGEN_INSN_INT value;
+
+ /* If LENGTH is zero, this operand doesn't contribute to the value
+ so give it a standard value of zero. */
+ if (length == 0)
+ {
+ *valuep = 0;
+ return 1;
+ }
+
+ if (CGEN_INT_INSN_P
+ && word_offset != 0)
+ abort ();
+
+ if (word_length > 32)
+ abort ();
+
+ /* For architectures with insns smaller than the insn-base-bitsize,
+ word_length may be too big. */
+ if (cd->min_insn_bitsize < cd->base_insn_bitsize)
+ {
+ if (word_offset == 0
+ && word_length > total_length)
+ word_length = total_length;
+ }
+
+ /* Does the value reside in INSN_VALUE? */
+
+ if (word_offset == 0)
+ {
+ /* Written this way to avoid undefined behaviour. */
+ CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+
+ if (CGEN_INSN_LSB0_P)
+ value = insn_value >> ((start + 1) - length);
+ else
+ value = insn_value >> (word_length - (start + length));
+ value &= mask;
+ /* sign extend? */
+ if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
+ && (value & (1L << (length - 1))))
+ value |= ~mask;
+ }
+
+#if ! CGEN_INT_INSN_P
+
+ else
+ {
+ unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
+
+ if (word_length > 32)
+ abort ();
+
+ if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
+ return 0;
+
+ value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
+ }
+
+#endif /* ! CGEN_INT_INSN_P */
+
+ *valuep = value;
+
+ return 1;
+}
+
+/* Default insn extractor.
+
+ INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
+ The extracted fields are stored in FIELDS.
+ EX_INFO is used to handle reading variable length insns.
+ Return the length of the insn in bits, or 0 if no match,
+ or -1 if an error occurs fetching data (memory_error_func will have
+ been called). */
+
+static int
+extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ CGEN_EXTRACT_INFO *ex_info;
+ CGEN_INSN_INT insn_value;
+ CGEN_FIELDS *fields;
+ bfd_vma pc;
+{
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ const unsigned char *syn;
+
+ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
+
+ CGEN_INIT_EXTRACT (cd);
+
+ for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
+ {
+ int length;
+
+ if (CGEN_SYNTAX_CHAR_P (*syn))
+ continue;
+
+ length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
+ ex_info, insn_value, fields, pc);
+ if (length <= 0)
+ return length;
+ }
+
+ /* We recognized and successfully extracted this insn. */
+ return CGEN_INSN_BITSIZE (insn);
+}
+
+/* machine generated code added here */
+
+/* Main entry point for operand insertion.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `parse_insn_normal', but keeping it
+ separate makes clear the interface between `parse_insn_normal' and each of
+ the handlers. It's also needed by GAS to insert operands that couldn't be
+ resolved during parsing.
+*/
+
+const char *
+fr30_cgen_insert_operand (cd, opindex, fields, buffer, pc)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_FIELDS * fields;
+ CGEN_INSN_BYTES_PTR buffer;
+ bfd_vma pc;
+{
+ const char * errmsg;
+ unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
+
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ errmsg = insert_normal (cd, fields->f_CRi, 0, 16, 12, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_CRJ :
+ errmsg = insert_normal (cd, fields->f_CRj, 0, 16, 8, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_R13 :
+ errmsg = insert_normal (cd, fields->f_nil, 0, 0, 0, 0, 0, total_length, buffer);
+ break;
+ case FR30_OPERAND_R14 :
+ errmsg = insert_normal (cd, fields->f_nil, 0, 0, 0, 0, 0, total_length, buffer);
+ break;
+ case FR30_OPERAND_R15 :
+ errmsg = insert_normal (cd, fields->f_nil, 0, 0, 0, 0, 0, total_length, buffer);
+ break;
+ case FR30_OPERAND_RI :
+ errmsg = insert_normal (cd, fields->f_Ri, 0, 0, 12, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_RIC :
+ errmsg = insert_normal (cd, fields->f_Ric, 0, 16, 12, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_RJ :
+ errmsg = insert_normal (cd, fields->f_Rj, 0, 0, 8, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_RJC :
+ errmsg = insert_normal (cd, fields->f_Rjc, 0, 16, 8, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_RS1 :
+ errmsg = insert_normal (cd, fields->f_Rs1, 0, 0, 8, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_RS2 :
+ errmsg = insert_normal (cd, fields->f_Rs2, 0, 0, 12, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_CC :
+ errmsg = insert_normal (cd, fields->f_cc, 0, 0, 4, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_CCC :
+ errmsg = insert_normal (cd, fields->f_ccc, 0, 16, 0, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_DIR10 :
+ {
+ long value = fields->f_dir10;
+ value = ((unsigned int) (value) >> (2));
+ errmsg = insert_normal (cd, value, 0, 0, 8, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_DIR8 :
+ errmsg = insert_normal (cd, fields->f_dir8, 0, 0, 8, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_DIR9 :
+ {
+ long value = fields->f_dir9;
+ value = ((unsigned int) (value) >> (1));
+ errmsg = insert_normal (cd, value, 0, 0, 8, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_DISP10 :
+ {
+ long value = fields->f_disp10;
+ value = ((int) (value) >> (2));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_DISP8 :
+ errmsg = insert_normal (cd, fields->f_disp8, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_DISP9 :
+ {
+ long value = fields->f_disp9;
+ value = ((int) (value) >> (1));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_I20 :
+ {
+{
+ FLD (f_i20_4) = ((unsigned int) (FLD (f_i20)) >> (16));
+ FLD (f_i20_16) = ((FLD (f_i20)) & (65535));
+}
+ errmsg = insert_normal (cd, fields->f_i20_4, 0, 0, 8, 4, 16, total_length, buffer);
+ if (errmsg)
+ break;
+ errmsg = insert_normal (cd, fields->f_i20_16, 0, 16, 0, 16, 16, total_length, buffer);
+ if (errmsg)
+ break;
+ }
+ break;
+ case FR30_OPERAND_I32 :
+ errmsg = insert_normal (cd, fields->f_i32, 0|(1<<CGEN_IFLD_SIGN_OPT), 16, 0, 32, 32, total_length, buffer);
+ break;
+ case FR30_OPERAND_I8 :
+ errmsg = insert_normal (cd, fields->f_i8, 0, 0, 4, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_LABEL12 :
+ {
+ long value = fields->f_rel12;
+ value = ((int) (((value) - (((pc) + (2))))) >> (1));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 11, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_LABEL9 :
+ {
+ long value = fields->f_rel9;
+ value = ((int) (((value) - (((pc) + (2))))) >> (1));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_M4 :
+ {
+ long value = fields->f_m4;
+ value = ((value) & (15));
+ errmsg = insert_normal (cd, value, 0, 0, 8, 4, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_PS :
+ errmsg = insert_normal (cd, fields->f_nil, 0, 0, 0, 0, 0, total_length, buffer);
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ errmsg = insert_normal (cd, fields->f_reglist_hi_ld, 0, 0, 8, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ errmsg = insert_normal (cd, fields->f_reglist_hi_st, 0, 0, 8, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ errmsg = insert_normal (cd, fields->f_reglist_low_ld, 0, 0, 8, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ errmsg = insert_normal (cd, fields->f_reglist_low_st, 0, 0, 8, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_S10 :
+ {
+ long value = fields->f_s10;
+ value = ((int) (value) >> (2));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_U10 :
+ {
+ long value = fields->f_u10;
+ value = ((unsigned int) (value) >> (2));
+ errmsg = insert_normal (cd, value, 0, 0, 8, 8, 16, total_length, buffer);
+ }
+ break;
+ case FR30_OPERAND_U4 :
+ errmsg = insert_normal (cd, fields->f_u4, 0, 0, 8, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_U4C :
+ errmsg = insert_normal (cd, fields->f_u4c, 0, 0, 12, 4, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_U8 :
+ errmsg = insert_normal (cd, fields->f_u8, 0, 0, 8, 8, 16, total_length, buffer);
+ break;
+ case FR30_OPERAND_UDISP6 :
+ {
+ long value = fields->f_udisp6;
+ value = ((unsigned int) (value) >> (2));
+ errmsg = insert_normal (cd, value, 0, 0, 8, 4, 16, total_length, buffer);
+ }
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
+ opindex);
+ abort ();
+ }
+
+ return errmsg;
+}
+
+/* Main entry point for operand extraction.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `print_insn_normal', but keeping it
+ separate makes clear the interface between `print_insn_normal' and each of
+ the handlers.
+*/
+
+int
+fr30_cgen_extract_operand (cd, opindex, ex_info, insn_value, fields, pc)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_EXTRACT_INFO *ex_info;
+ CGEN_INSN_INT insn_value;
+ CGEN_FIELDS * fields;
+ bfd_vma pc;
+{
+ int length;
+ unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
+
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ length = extract_normal (cd, ex_info, insn_value, 0, 16, 12, 4, 16, total_length, pc, & fields->f_CRi);
+ break;
+ case FR30_OPERAND_CRJ :
+ length = extract_normal (cd, ex_info, insn_value, 0, 16, 8, 4, 16, total_length, pc, & fields->f_CRj);
+ break;
+ case FR30_OPERAND_R13 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 0, total_length, pc, & fields->f_nil);
+ break;
+ case FR30_OPERAND_R14 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 0, total_length, pc, & fields->f_nil);
+ break;
+ case FR30_OPERAND_R15 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 0, total_length, pc, & fields->f_nil);
+ break;
+ case FR30_OPERAND_RI :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 16, total_length, pc, & fields->f_Ri);
+ break;
+ case FR30_OPERAND_RIC :
+ length = extract_normal (cd, ex_info, insn_value, 0, 16, 12, 4, 16, total_length, pc, & fields->f_Ric);
+ break;
+ case FR30_OPERAND_RJ :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & fields->f_Rj);
+ break;
+ case FR30_OPERAND_RJC :
+ length = extract_normal (cd, ex_info, insn_value, 0, 16, 8, 4, 16, total_length, pc, & fields->f_Rjc);
+ break;
+ case FR30_OPERAND_RS1 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & fields->f_Rs1);
+ break;
+ case FR30_OPERAND_RS2 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 16, total_length, pc, & fields->f_Rs2);
+ break;
+ case FR30_OPERAND_CC :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 16, total_length, pc, & fields->f_cc);
+ break;
+ case FR30_OPERAND_CCC :
+ length = extract_normal (cd, ex_info, insn_value, 0, 16, 0, 8, 16, total_length, pc, & fields->f_ccc);
+ break;
+ case FR30_OPERAND_DIR10 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & value);
+ value = ((value) << (2));
+ fields->f_dir10 = value;
+ }
+ break;
+ case FR30_OPERAND_DIR8 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & fields->f_dir8);
+ break;
+ case FR30_OPERAND_DIR9 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & value);
+ value = ((value) << (1));
+ fields->f_dir9 = value;
+ }
+ break;
+ case FR30_OPERAND_DISP10 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, pc, & value);
+ value = ((value) << (2));
+ fields->f_disp10 = value;
+ }
+ break;
+ case FR30_OPERAND_DISP8 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, pc, & fields->f_disp8);
+ break;
+ case FR30_OPERAND_DISP9 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, pc, & value);
+ value = ((value) << (1));
+ fields->f_disp9 = value;
+ }
+ break;
+ case FR30_OPERAND_I20 :
+ {
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & fields->f_i20_4);
+ length = extract_normal (cd, ex_info, insn_value, 0, 16, 0, 16, 16, total_length, pc, & fields->f_i20_16);
+{
+ FLD (f_i20) = ((((FLD (f_i20_4)) << (16))) | (FLD (f_i20_16)));
+}
+ }
+ break;
+ case FR30_OPERAND_I32 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGN_OPT), 16, 0, 32, 32, total_length, pc, & fields->f_i32);
+ break;
+ case FR30_OPERAND_I8 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 16, total_length, pc, & fields->f_i8);
+ break;
+ case FR30_OPERAND_LABEL12 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 11, 16, total_length, pc, & value);
+ value = ((((value) << (1))) + (((pc) + (2))));
+ fields->f_rel12 = value;
+ }
+ break;
+ case FR30_OPERAND_LABEL9 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 16, total_length, pc, & value);
+ value = ((((value) << (1))) + (((pc) + (2))));
+ fields->f_rel9 = value;
+ }
+ break;
+ case FR30_OPERAND_M4 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & value);
+ value = ((value) | (((-1) << (4))));
+ fields->f_m4 = value;
+ }
+ break;
+ case FR30_OPERAND_PS :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 0, total_length, pc, & fields->f_nil);
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & fields->f_reglist_hi_ld);
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & fields->f_reglist_hi_st);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & fields->f_reglist_low_ld);
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & fields->f_reglist_low_st);
+ break;
+ case FR30_OPERAND_S10 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 16, total_length, pc, & value);
+ value = ((value) << (2));
+ fields->f_s10 = value;
+ }
+ break;
+ case FR30_OPERAND_U10 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & value);
+ value = ((value) << (2));
+ fields->f_u10 = value;
+ }
+ break;
+ case FR30_OPERAND_U4 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & fields->f_u4);
+ break;
+ case FR30_OPERAND_U4C :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 16, total_length, pc, & fields->f_u4c);
+ break;
+ case FR30_OPERAND_U8 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 16, total_length, pc, & fields->f_u8);
+ break;
+ case FR30_OPERAND_UDISP6 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & value);
+ value = ((value) << (2));
+ fields->f_udisp6 = value;
+ }
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
+ opindex);
+ abort ();
+ }
+
+ return length;
+}
+
+cgen_insert_fn * const fr30_cgen_insert_handlers[] =
+{
+ insert_insn_normal,
+};
+
+cgen_extract_fn * const fr30_cgen_extract_handlers[] =
+{
+ extract_insn_normal,
+};
+
+/* Getting values from cgen_fields is handled by a collection of functions.
+ They are distinguished by the type of the VALUE argument they return.
+ TODO: floating point, inlining support, remove cases where result type
+ not appropriate. */
+
+int
+fr30_cgen_get_int_operand (cd, opindex, fields)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ const CGEN_FIELDS * fields;
+{
+ int value;
+
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ value = fields->f_CRi;
+ break;
+ case FR30_OPERAND_CRJ :
+ value = fields->f_CRj;
+ break;
+ case FR30_OPERAND_R13 :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_R14 :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_R15 :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_RI :
+ value = fields->f_Ri;
+ break;
+ case FR30_OPERAND_RIC :
+ value = fields->f_Ric;
+ break;
+ case FR30_OPERAND_RJ :
+ value = fields->f_Rj;
+ break;
+ case FR30_OPERAND_RJC :
+ value = fields->f_Rjc;
+ break;
+ case FR30_OPERAND_RS1 :
+ value = fields->f_Rs1;
+ break;
+ case FR30_OPERAND_RS2 :
+ value = fields->f_Rs2;
+ break;
+ case FR30_OPERAND_CC :
+ value = fields->f_cc;
+ break;
+ case FR30_OPERAND_CCC :
+ value = fields->f_ccc;
+ break;
+ case FR30_OPERAND_DIR10 :
+ value = fields->f_dir10;
+ break;
+ case FR30_OPERAND_DIR8 :
+ value = fields->f_dir8;
+ break;
+ case FR30_OPERAND_DIR9 :
+ value = fields->f_dir9;
+ break;
+ case FR30_OPERAND_DISP10 :
+ value = fields->f_disp10;
+ break;
+ case FR30_OPERAND_DISP8 :
+ value = fields->f_disp8;
+ break;
+ case FR30_OPERAND_DISP9 :
+ value = fields->f_disp9;
+ break;
+ case FR30_OPERAND_I20 :
+ value = fields->f_i20;
+ break;
+ case FR30_OPERAND_I32 :
+ value = fields->f_i32;
+ break;
+ case FR30_OPERAND_I8 :
+ value = fields->f_i8;
+ break;
+ case FR30_OPERAND_LABEL12 :
+ value = fields->f_rel12;
+ break;
+ case FR30_OPERAND_LABEL9 :
+ value = fields->f_rel9;
+ break;
+ case FR30_OPERAND_M4 :
+ value = fields->f_m4;
+ break;
+ case FR30_OPERAND_PS :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ value = fields->f_reglist_hi_ld;
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ value = fields->f_reglist_hi_st;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ value = fields->f_reglist_low_ld;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ value = fields->f_reglist_low_st;
+ break;
+ case FR30_OPERAND_S10 :
+ value = fields->f_s10;
+ break;
+ case FR30_OPERAND_U10 :
+ value = fields->f_u10;
+ break;
+ case FR30_OPERAND_U4 :
+ value = fields->f_u4;
+ break;
+ case FR30_OPERAND_U4C :
+ value = fields->f_u4c;
+ break;
+ case FR30_OPERAND_U8 :
+ value = fields->f_u8;
+ break;
+ case FR30_OPERAND_UDISP6 :
+ value = fields->f_udisp6;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
+ opindex);
+ abort ();
+ }
+
+ return value;
+}
+
+bfd_vma
+fr30_cgen_get_vma_operand (cd, opindex, fields)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ const CGEN_FIELDS * fields;
+{
+ bfd_vma value;
+
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ value = fields->f_CRi;
+ break;
+ case FR30_OPERAND_CRJ :
+ value = fields->f_CRj;
+ break;
+ case FR30_OPERAND_R13 :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_R14 :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_R15 :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_RI :
+ value = fields->f_Ri;
+ break;
+ case FR30_OPERAND_RIC :
+ value = fields->f_Ric;
+ break;
+ case FR30_OPERAND_RJ :
+ value = fields->f_Rj;
+ break;
+ case FR30_OPERAND_RJC :
+ value = fields->f_Rjc;
+ break;
+ case FR30_OPERAND_RS1 :
+ value = fields->f_Rs1;
+ break;
+ case FR30_OPERAND_RS2 :
+ value = fields->f_Rs2;
+ break;
+ case FR30_OPERAND_CC :
+ value = fields->f_cc;
+ break;
+ case FR30_OPERAND_CCC :
+ value = fields->f_ccc;
+ break;
+ case FR30_OPERAND_DIR10 :
+ value = fields->f_dir10;
+ break;
+ case FR30_OPERAND_DIR8 :
+ value = fields->f_dir8;
+ break;
+ case FR30_OPERAND_DIR9 :
+ value = fields->f_dir9;
+ break;
+ case FR30_OPERAND_DISP10 :
+ value = fields->f_disp10;
+ break;
+ case FR30_OPERAND_DISP8 :
+ value = fields->f_disp8;
+ break;
+ case FR30_OPERAND_DISP9 :
+ value = fields->f_disp9;
+ break;
+ case FR30_OPERAND_I20 :
+ value = fields->f_i20;
+ break;
+ case FR30_OPERAND_I32 :
+ value = fields->f_i32;
+ break;
+ case FR30_OPERAND_I8 :
+ value = fields->f_i8;
+ break;
+ case FR30_OPERAND_LABEL12 :
+ value = fields->f_rel12;
+ break;
+ case FR30_OPERAND_LABEL9 :
+ value = fields->f_rel9;
+ break;
+ case FR30_OPERAND_M4 :
+ value = fields->f_m4;
+ break;
+ case FR30_OPERAND_PS :
+ value = fields->f_nil;
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ value = fields->f_reglist_hi_ld;
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ value = fields->f_reglist_hi_st;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ value = fields->f_reglist_low_ld;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ value = fields->f_reglist_low_st;
+ break;
+ case FR30_OPERAND_S10 :
+ value = fields->f_s10;
+ break;
+ case FR30_OPERAND_U10 :
+ value = fields->f_u10;
+ break;
+ case FR30_OPERAND_U4 :
+ value = fields->f_u4;
+ break;
+ case FR30_OPERAND_U4C :
+ value = fields->f_u4c;
+ break;
+ case FR30_OPERAND_U8 :
+ value = fields->f_u8;
+ break;
+ case FR30_OPERAND_UDISP6 :
+ value = fields->f_udisp6;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
+ opindex);
+ abort ();
+ }
+
+ return value;
+}
+
+/* Stuffing values in cgen_fields is handled by a collection of functions.
+ They are distinguished by the type of the VALUE argument they accept.
+ TODO: floating point, inlining support, remove cases where argument type
+ not appropriate. */
+
+void
+fr30_cgen_set_int_operand (cd, opindex, fields, value)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_FIELDS * fields;
+ int value;
+{
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ fields->f_CRi = value;
+ break;
+ case FR30_OPERAND_CRJ :
+ fields->f_CRj = value;
+ break;
+ case FR30_OPERAND_R13 :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_R14 :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_R15 :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_RI :
+ fields->f_Ri = value;
+ break;
+ case FR30_OPERAND_RIC :
+ fields->f_Ric = value;
+ break;
+ case FR30_OPERAND_RJ :
+ fields->f_Rj = value;
+ break;
+ case FR30_OPERAND_RJC :
+ fields->f_Rjc = value;
+ break;
+ case FR30_OPERAND_RS1 :
+ fields->f_Rs1 = value;
+ break;
+ case FR30_OPERAND_RS2 :
+ fields->f_Rs2 = value;
+ break;
+ case FR30_OPERAND_CC :
+ fields->f_cc = value;
+ break;
+ case FR30_OPERAND_CCC :
+ fields->f_ccc = value;
+ break;
+ case FR30_OPERAND_DIR10 :
+ fields->f_dir10 = value;
+ break;
+ case FR30_OPERAND_DIR8 :
+ fields->f_dir8 = value;
+ break;
+ case FR30_OPERAND_DIR9 :
+ fields->f_dir9 = value;
+ break;
+ case FR30_OPERAND_DISP10 :
+ fields->f_disp10 = value;
+ break;
+ case FR30_OPERAND_DISP8 :
+ fields->f_disp8 = value;
+ break;
+ case FR30_OPERAND_DISP9 :
+ fields->f_disp9 = value;
+ break;
+ case FR30_OPERAND_I20 :
+ fields->f_i20 = value;
+ break;
+ case FR30_OPERAND_I32 :
+ fields->f_i32 = value;
+ break;
+ case FR30_OPERAND_I8 :
+ fields->f_i8 = value;
+ break;
+ case FR30_OPERAND_LABEL12 :
+ fields->f_rel12 = value;
+ break;
+ case FR30_OPERAND_LABEL9 :
+ fields->f_rel9 = value;
+ break;
+ case FR30_OPERAND_M4 :
+ fields->f_m4 = value;
+ break;
+ case FR30_OPERAND_PS :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ fields->f_reglist_hi_ld = value;
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ fields->f_reglist_hi_st = value;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ fields->f_reglist_low_ld = value;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ fields->f_reglist_low_st = value;
+ break;
+ case FR30_OPERAND_S10 :
+ fields->f_s10 = value;
+ break;
+ case FR30_OPERAND_U10 :
+ fields->f_u10 = value;
+ break;
+ case FR30_OPERAND_U4 :
+ fields->f_u4 = value;
+ break;
+ case FR30_OPERAND_U4C :
+ fields->f_u4c = value;
+ break;
+ case FR30_OPERAND_U8 :
+ fields->f_u8 = value;
+ break;
+ case FR30_OPERAND_UDISP6 :
+ fields->f_udisp6 = value;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
+ opindex);
+ abort ();
+ }
+}
+
+void
+fr30_cgen_set_vma_operand (cd, opindex, fields, value)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_FIELDS * fields;
+ bfd_vma value;
+{
+ switch (opindex)
+ {
+ case FR30_OPERAND_CRI :
+ fields->f_CRi = value;
+ break;
+ case FR30_OPERAND_CRJ :
+ fields->f_CRj = value;
+ break;
+ case FR30_OPERAND_R13 :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_R14 :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_R15 :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_RI :
+ fields->f_Ri = value;
+ break;
+ case FR30_OPERAND_RIC :
+ fields->f_Ric = value;
+ break;
+ case FR30_OPERAND_RJ :
+ fields->f_Rj = value;
+ break;
+ case FR30_OPERAND_RJC :
+ fields->f_Rjc = value;
+ break;
+ case FR30_OPERAND_RS1 :
+ fields->f_Rs1 = value;
+ break;
+ case FR30_OPERAND_RS2 :
+ fields->f_Rs2 = value;
+ break;
+ case FR30_OPERAND_CC :
+ fields->f_cc = value;
+ break;
+ case FR30_OPERAND_CCC :
+ fields->f_ccc = value;
+ break;
+ case FR30_OPERAND_DIR10 :
+ fields->f_dir10 = value;
+ break;
+ case FR30_OPERAND_DIR8 :
+ fields->f_dir8 = value;
+ break;
+ case FR30_OPERAND_DIR9 :
+ fields->f_dir9 = value;
+ break;
+ case FR30_OPERAND_DISP10 :
+ fields->f_disp10 = value;
+ break;
+ case FR30_OPERAND_DISP8 :
+ fields->f_disp8 = value;
+ break;
+ case FR30_OPERAND_DISP9 :
+ fields->f_disp9 = value;
+ break;
+ case FR30_OPERAND_I20 :
+ fields->f_i20 = value;
+ break;
+ case FR30_OPERAND_I32 :
+ fields->f_i32 = value;
+ break;
+ case FR30_OPERAND_I8 :
+ fields->f_i8 = value;
+ break;
+ case FR30_OPERAND_LABEL12 :
+ fields->f_rel12 = value;
+ break;
+ case FR30_OPERAND_LABEL9 :
+ fields->f_rel9 = value;
+ break;
+ case FR30_OPERAND_M4 :
+ fields->f_m4 = value;
+ break;
+ case FR30_OPERAND_PS :
+ fields->f_nil = value;
+ break;
+ case FR30_OPERAND_REGLIST_HI_LD :
+ fields->f_reglist_hi_ld = value;
+ break;
+ case FR30_OPERAND_REGLIST_HI_ST :
+ fields->f_reglist_hi_st = value;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_LD :
+ fields->f_reglist_low_ld = value;
+ break;
+ case FR30_OPERAND_REGLIST_LOW_ST :
+ fields->f_reglist_low_st = value;
+ break;
+ case FR30_OPERAND_S10 :
+ fields->f_s10 = value;
+ break;
+ case FR30_OPERAND_U10 :
+ fields->f_u10 = value;
+ break;
+ case FR30_OPERAND_U4 :
+ fields->f_u4 = value;
+ break;
+ case FR30_OPERAND_U4C :
+ fields->f_u4c = value;
+ break;
+ case FR30_OPERAND_U8 :
+ fields->f_u8 = value;
+ break;
+ case FR30_OPERAND_UDISP6 :
+ fields->f_udisp6 = value;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
+ opindex);
+ abort ();
+ }
+}
+
+/* Function to call before using the instruction builder tables. */
+
+void
+fr30_cgen_init_ibld_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ cd->insert_handlers = & fr30_cgen_insert_handlers[0];
+ cd->extract_handlers = & fr30_cgen_extract_handlers[0];
+
+ cd->insert_operand = fr30_cgen_insert_operand;
+ cd->extract_operand = fr30_cgen_extract_operand;
+
+ cd->get_int_operand = fr30_cgen_get_int_operand;
+ cd->set_int_operand = fr30_cgen_set_int_operand;
+ cd->get_vma_operand = fr30_cgen_get_vma_operand;
+ cd->set_vma_operand = fr30_cgen_set_vma_operand;
+}
diff --git a/opcodes/fr30-opc.c b/opcodes/fr30-opc.c
new file mode 100644
index 00000000000..302100dfc64
--- /dev/null
+++ b/opcodes/fr30-opc.c
@@ -0,0 +1,1368 @@
+/* Instruction opcode table for fr30.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "sysdep.h"
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "fr30-desc.h"
+#include "fr30-opc.h"
+
+/* The hash functions are recorded here to help keep assembler code out of
+ the disassembler and vice versa. */
+
+static int asm_hash_insn_p PARAMS ((const CGEN_INSN *));
+static unsigned int asm_hash_insn PARAMS ((const char *));
+static int dis_hash_insn_p PARAMS ((const CGEN_INSN *));
+static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT));
+
+/* Instruction formats. */
+
+#define F(f) & fr30_cgen_ifld_table[CONCAT2 (FR30_,f)]
+
+static const CGEN_IFMT ifmt_empty = {
+ 0, 0, 0x0, { 0 }
+};
+
+static const CGEN_IFMT ifmt_add = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_RJ), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_addi = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_U4), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_add2 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_M4), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_div0s = {
+ 16, 16, 0xfff0, { F (F_OP1), F (F_OP2), F (F_OP3), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_div3 = {
+ 16, 16, 0xffff, { F (F_OP1), F (F_OP2), F (F_OP3), F (F_OP4), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi8 = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_I8), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi20 = {
+ 16, 32, 0xff00, { F (F_OP1), F (F_I20), F (F_OP2), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi32 = {
+ 16, 48, 0xfff0, { F (F_OP1), F (F_I32), F (F_OP2), F (F_OP3), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldr14 = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_DISP10), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldr14uh = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_DISP9), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldr14ub = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_DISP8), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldr15 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_UDISP6), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldr15dr = {
+ 16, 16, 0xfff0, { F (F_OP1), F (F_OP2), F (F_OP3), F (F_RS2), 0 }
+};
+
+static const CGEN_IFMT ifmt_movdr = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_RS1), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_call = {
+ 16, 16, 0xf800, { F (F_OP1), F (F_OP5), F (F_REL12), 0 }
+};
+
+static const CGEN_IFMT ifmt_int = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_U8), 0 }
+};
+
+static const CGEN_IFMT ifmt_brad = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_CC), F (F_REL9), 0 }
+};
+
+static const CGEN_IFMT ifmt_dmovr13 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_DIR10), 0 }
+};
+
+static const CGEN_IFMT ifmt_dmovr13h = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_DIR9), 0 }
+};
+
+static const CGEN_IFMT ifmt_dmovr13b = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_DIR8), 0 }
+};
+
+static const CGEN_IFMT ifmt_copop = {
+ 16, 32, 0xfff0, { F (F_OP1), F (F_CCC), F (F_OP2), F (F_OP3), F (F_CRJ), F (F_U4C), F (F_CRI), 0 }
+};
+
+static const CGEN_IFMT ifmt_copld = {
+ 16, 32, 0xfff0, { F (F_OP1), F (F_CCC), F (F_OP2), F (F_OP3), F (F_RJC), F (F_U4C), F (F_CRI), 0 }
+};
+
+static const CGEN_IFMT ifmt_copst = {
+ 16, 32, 0xfff0, { F (F_OP1), F (F_CCC), F (F_OP2), F (F_OP3), F (F_CRJ), F (F_U4C), F (F_RIC), 0 }
+};
+
+static const CGEN_IFMT ifmt_addsp = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_S10), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldm0 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_REGLIST_LOW_LD), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldm1 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_REGLIST_HI_LD), 0 }
+};
+
+static const CGEN_IFMT ifmt_stm0 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_REGLIST_LOW_ST), 0 }
+};
+
+static const CGEN_IFMT ifmt_stm1 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_REGLIST_HI_ST), 0 }
+};
+
+static const CGEN_IFMT ifmt_enter = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_OP2), F (F_U10), 0 }
+};
+
+#undef F
+
+#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
+#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
+#define OPERAND(op) CONCAT2 (FR30_OPERAND_,op)
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+
+/* The instruction table. */
+
+static const CGEN_OPCODE fr30_cgen_insn_opcode_table[MAX_INSNS] =
+{
+ /* Special null first entry.
+ A `num' value of zero is thus invalid.
+ Also, the special `invalid' insn resides here. */
+ { { 0 } },
+/* add $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xa600 }
+ },
+/* add $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xa400 }
+ },
+/* add2 $m4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (M4), ',', OP (RI), 0 } },
+ & ifmt_add2, { 0xa500 }
+ },
+/* addc $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xa700 }
+ },
+/* addn $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xa200 }
+ },
+/* addn $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xa000 }
+ },
+/* addn2 $m4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (M4), ',', OP (RI), 0 } },
+ & ifmt_add2, { 0xa100 }
+ },
+/* sub $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xac00 }
+ },
+/* subc $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xad00 }
+ },
+/* subn $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xae00 }
+ },
+/* cmp $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xaa00 }
+ },
+/* cmp $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xa800 }
+ },
+/* cmp2 $m4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (M4), ',', OP (RI), 0 } },
+ & ifmt_add2, { 0xa900 }
+ },
+/* and $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x8200 }
+ },
+/* or $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x9200 }
+ },
+/* eor $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x9a00 }
+ },
+/* and $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x8400 }
+ },
+/* andh $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x8500 }
+ },
+/* andb $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x8600 }
+ },
+/* or $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x9400 }
+ },
+/* orh $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x9500 }
+ },
+/* orb $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x9600 }
+ },
+/* eor $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x9c00 }
+ },
+/* eorh $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x9d00 }
+ },
+/* eorb $Rj,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', '@', OP (RI), 0 } },
+ & ifmt_add, { 0x9e00 }
+ },
+/* bandl $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x8000 }
+ },
+/* borl $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x9000 }
+ },
+/* beorl $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x9800 }
+ },
+/* bandh $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x8100 }
+ },
+/* borh $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x9100 }
+ },
+/* beorh $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x9900 }
+ },
+/* btstl $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x8800 }
+ },
+/* btsth $u4,@$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), 0 } },
+ & ifmt_addi, { 0x8900 }
+ },
+/* mul $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xaf00 }
+ },
+/* mulu $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xab00 }
+ },
+/* mulh $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xbf00 }
+ },
+/* muluh $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xbb00 }
+ },
+/* div0s $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9740 }
+ },
+/* div0u $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9750 }
+ },
+/* div1 $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9760 }
+ },
+/* div2 $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9770 }
+ },
+/* div3 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9f60 }
+ },
+/* div4s */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9f70 }
+ },
+/* lsl $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xb600 }
+ },
+/* lsl $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xb400 }
+ },
+/* lsl2 $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xb500 }
+ },
+/* lsr $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xb200 }
+ },
+/* lsr $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xb000 }
+ },
+/* lsr2 $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xb100 }
+ },
+/* asr $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0xba00 }
+ },
+/* asr $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xb800 }
+ },
+/* asr2 $u4,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', OP (RI), 0 } },
+ & ifmt_addi, { 0xb900 }
+ },
+/* ldi:8 $i8,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (I8), ',', OP (RI), 0 } },
+ & ifmt_ldi8, { 0xc000 }
+ },
+/* ldi:20 $i20,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (I20), ',', OP (RI), 0 } },
+ & ifmt_ldi20, { 0x9b00 }
+ },
+/* ldi:32 $i32,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (I32), ',', OP (RI), 0 } },
+ & ifmt_ldi32, { 0x9f80 }
+ },
+/* ld @$Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x400 }
+ },
+/* lduh @$Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x500 }
+ },
+/* ldub @$Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x600 }
+ },
+/* ld @($R13,$Rj),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R13), ',', OP (RJ), ')', ',', OP (RI), 0 } },
+ & ifmt_add, { 0x0 }
+ },
+/* lduh @($R13,$Rj),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R13), ',', OP (RJ), ')', ',', OP (RI), 0 } },
+ & ifmt_add, { 0x100 }
+ },
+/* ldub @($R13,$Rj),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R13), ',', OP (RJ), ')', ',', OP (RI), 0 } },
+ & ifmt_add, { 0x200 }
+ },
+/* ld @($R14,$disp10),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R14), ',', OP (DISP10), ')', ',', OP (RI), 0 } },
+ & ifmt_ldr14, { 0x2000 }
+ },
+/* lduh @($R14,$disp9),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R14), ',', OP (DISP9), ')', ',', OP (RI), 0 } },
+ & ifmt_ldr14uh, { 0x4000 }
+ },
+/* ldub @($R14,$disp8),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R14), ',', OP (DISP8), ')', ',', OP (RI), 0 } },
+ & ifmt_ldr14ub, { 0x6000 }
+ },
+/* ld @($R15,$udisp6),$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', '(', OP (R15), ',', OP (UDISP6), ')', ',', OP (RI), 0 } },
+ & ifmt_ldr15, { 0x300 }
+ },
+/* ld @$R15+,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R15), '+', ',', OP (RI), 0 } },
+ & ifmt_div0s, { 0x700 }
+ },
+/* ld @$R15+,$Rs2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R15), '+', ',', OP (RS2), 0 } },
+ & ifmt_ldr15dr, { 0x780 }
+ },
+/* ld @$R15+,$ps */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R15), '+', ',', OP (PS), 0 } },
+ & ifmt_div3, { 0x790 }
+ },
+/* st $Ri,@$Rj */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', OP (RJ), 0 } },
+ & ifmt_add, { 0x1400 }
+ },
+/* sth $Ri,@$Rj */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', OP (RJ), 0 } },
+ & ifmt_add, { 0x1500 }
+ },
+/* stb $Ri,@$Rj */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', OP (RJ), 0 } },
+ & ifmt_add, { 0x1600 }
+ },
+/* st $Ri,@($R13,$Rj) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R13), ',', OP (RJ), ')', 0 } },
+ & ifmt_add, { 0x1000 }
+ },
+/* sth $Ri,@($R13,$Rj) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R13), ',', OP (RJ), ')', 0 } },
+ & ifmt_add, { 0x1100 }
+ },
+/* stb $Ri,@($R13,$Rj) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R13), ',', OP (RJ), ')', 0 } },
+ & ifmt_add, { 0x1200 }
+ },
+/* st $Ri,@($R14,$disp10) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R14), ',', OP (DISP10), ')', 0 } },
+ & ifmt_ldr14, { 0x3000 }
+ },
+/* sth $Ri,@($R14,$disp9) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R14), ',', OP (DISP9), ')', 0 } },
+ & ifmt_ldr14uh, { 0x5000 }
+ },
+/* stb $Ri,@($R14,$disp8) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R14), ',', OP (DISP8), ')', 0 } },
+ & ifmt_ldr14ub, { 0x7000 }
+ },
+/* st $Ri,@($R15,$udisp6) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '(', OP (R15), ',', OP (UDISP6), ')', 0 } },
+ & ifmt_ldr15, { 0x1300 }
+ },
+/* st $Ri,@-$R15 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', '@', '-', OP (R15), 0 } },
+ & ifmt_div0s, { 0x1700 }
+ },
+/* st $Rs2,@-$R15 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RS2), ',', '@', '-', OP (R15), 0 } },
+ & ifmt_ldr15dr, { 0x1780 }
+ },
+/* st $ps,@-$R15 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (PS), ',', '@', '-', OP (R15), 0 } },
+ & ifmt_div3, { 0x1790 }
+ },
+/* mov $Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x8b00 }
+ },
+/* mov $Rs1,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RS1), ',', OP (RI), 0 } },
+ & ifmt_movdr, { 0xb700 }
+ },
+/* mov $ps,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (PS), ',', OP (RI), 0 } },
+ & ifmt_div0s, { 0x1710 }
+ },
+/* mov $Ri,$Rs1 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', OP (RS1), 0 } },
+ & ifmt_movdr, { 0xb300 }
+ },
+/* mov $Ri,$ps */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), ',', OP (PS), 0 } },
+ & ifmt_div0s, { 0x710 }
+ },
+/* jmp @$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9700 }
+ },
+/* jmp:d @$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9f00 }
+ },
+/* call @$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9710 }
+ },
+/* call:d @$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9f10 }
+ },
+/* call $label12 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL12), 0 } },
+ & ifmt_call, { 0xd000 }
+ },
+/* call:d $label12 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL12), 0 } },
+ & ifmt_call, { 0xd800 }
+ },
+/* ret */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9720 }
+ },
+/* ret:d */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9f20 }
+ },
+/* int $u8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U8), 0 } },
+ & ifmt_int, { 0x1f00 }
+ },
+/* inte */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9f30 }
+ },
+/* reti */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9730 }
+ },
+/* bra:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf000 }
+ },
+/* bra $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe000 }
+ },
+/* bno:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf100 }
+ },
+/* bno $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe100 }
+ },
+/* beq:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf200 }
+ },
+/* beq $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe200 }
+ },
+/* bne:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf300 }
+ },
+/* bne $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe300 }
+ },
+/* bc:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf400 }
+ },
+/* bc $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe400 }
+ },
+/* bnc:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf500 }
+ },
+/* bnc $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe500 }
+ },
+/* bn:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf600 }
+ },
+/* bn $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe600 }
+ },
+/* bp:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf700 }
+ },
+/* bp $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe700 }
+ },
+/* bv:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf800 }
+ },
+/* bv $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe800 }
+ },
+/* bnv:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xf900 }
+ },
+/* bnv $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xe900 }
+ },
+/* blt:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xfa00 }
+ },
+/* blt $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xea00 }
+ },
+/* bge:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xfb00 }
+ },
+/* bge $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xeb00 }
+ },
+/* ble:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xfc00 }
+ },
+/* ble $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xec00 }
+ },
+/* bgt:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xfd00 }
+ },
+/* bgt $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xed00 }
+ },
+/* bls:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xfe00 }
+ },
+/* bls $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xee00 }
+ },
+/* bhi:d $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xff00 }
+ },
+/* bhi $label9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (LABEL9), 0 } },
+ & ifmt_brad, { 0xef00 }
+ },
+/* dmov $R13,@$dir10 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (R13), ',', '@', OP (DIR10), 0 } },
+ & ifmt_dmovr13, { 0x1800 }
+ },
+/* dmovh $R13,@$dir9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (R13), ',', '@', OP (DIR9), 0 } },
+ & ifmt_dmovr13h, { 0x1900 }
+ },
+/* dmovb $R13,@$dir8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (R13), ',', '@', OP (DIR8), 0 } },
+ & ifmt_dmovr13b, { 0x1a00 }
+ },
+/* dmov @$R13+,@$dir10 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R13), '+', ',', '@', OP (DIR10), 0 } },
+ & ifmt_dmovr13, { 0x1c00 }
+ },
+/* dmovh @$R13+,@$dir9 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R13), '+', ',', '@', OP (DIR9), 0 } },
+ & ifmt_dmovr13h, { 0x1d00 }
+ },
+/* dmovb @$R13+,@$dir8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R13), '+', ',', '@', OP (DIR8), 0 } },
+ & ifmt_dmovr13b, { 0x1e00 }
+ },
+/* dmov @$R15+,@$dir10 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (R15), '+', ',', '@', OP (DIR10), 0 } },
+ & ifmt_dmovr13, { 0x1b00 }
+ },
+/* dmov @$dir10,$R13 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR10), ',', OP (R13), 0 } },
+ & ifmt_dmovr13, { 0x800 }
+ },
+/* dmovh @$dir9,$R13 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR9), ',', OP (R13), 0 } },
+ & ifmt_dmovr13h, { 0x900 }
+ },
+/* dmovb @$dir8,$R13 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR8), ',', OP (R13), 0 } },
+ & ifmt_dmovr13b, { 0xa00 }
+ },
+/* dmov @$dir10,@$R13+ */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR10), ',', '@', OP (R13), '+', 0 } },
+ & ifmt_dmovr13, { 0xc00 }
+ },
+/* dmovh @$dir9,@$R13+ */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR9), ',', '@', OP (R13), '+', 0 } },
+ & ifmt_dmovr13h, { 0xd00 }
+ },
+/* dmovb @$dir8,@$R13+ */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR8), ',', '@', OP (R13), '+', 0 } },
+ & ifmt_dmovr13b, { 0xe00 }
+ },
+/* dmov @$dir10,@-$R15 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (DIR10), ',', '@', '-', OP (R15), 0 } },
+ & ifmt_dmovr13, { 0xb00 }
+ },
+/* ldres @$Ri+,$u4 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RI), '+', ',', OP (U4), 0 } },
+ & ifmt_addi, { 0xbc00 }
+ },
+/* stres $u4,@$Ri+ */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4), ',', '@', OP (RI), '+', 0 } },
+ & ifmt_addi, { 0xbd00 }
+ },
+/* copop $u4c,$ccc,$CRj,$CRi */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4C), ',', OP (CCC), ',', OP (CRJ), ',', OP (CRI), 0 } },
+ & ifmt_copop, { 0x9fc0 }
+ },
+/* copld $u4c,$ccc,$Rjc,$CRi */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4C), ',', OP (CCC), ',', OP (RJC), ',', OP (CRI), 0 } },
+ & ifmt_copld, { 0x9fd0 }
+ },
+/* copst $u4c,$ccc,$CRj,$Ric */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4C), ',', OP (CCC), ',', OP (CRJ), ',', OP (RIC), 0 } },
+ & ifmt_copst, { 0x9fe0 }
+ },
+/* copsv $u4c,$ccc,$CRj,$Ric */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U4C), ',', OP (CCC), ',', OP (CRJ), ',', OP (RIC), 0 } },
+ & ifmt_copst, { 0x9ff0 }
+ },
+/* nop */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9fa0 }
+ },
+/* andccr $u8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U8), 0 } },
+ & ifmt_int, { 0x8300 }
+ },
+/* orccr $u8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U8), 0 } },
+ & ifmt_int, { 0x9300 }
+ },
+/* stilm $u8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U8), 0 } },
+ & ifmt_int, { 0x8700 }
+ },
+/* addsp $s10 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (S10), 0 } },
+ & ifmt_addsp, { 0xa300 }
+ },
+/* extsb $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9780 }
+ },
+/* extub $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x9790 }
+ },
+/* extsh $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x97a0 }
+ },
+/* extuh $Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (RI), 0 } },
+ & ifmt_div0s, { 0x97b0 }
+ },
+/* ldm0 ($reglist_low_ld) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '(', OP (REGLIST_LOW_LD), ')', 0 } },
+ & ifmt_ldm0, { 0x8c00 }
+ },
+/* ldm1 ($reglist_hi_ld) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '(', OP (REGLIST_HI_LD), ')', 0 } },
+ & ifmt_ldm1, { 0x8d00 }
+ },
+/* stm0 ($reglist_low_st) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '(', OP (REGLIST_LOW_ST), ')', 0 } },
+ & ifmt_stm0, { 0x8e00 }
+ },
+/* stm1 ($reglist_hi_st) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '(', OP (REGLIST_HI_ST), ')', 0 } },
+ & ifmt_stm1, { 0x8f00 }
+ },
+/* enter $u10 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (U10), 0 } },
+ & ifmt_enter, { 0xf00 }
+ },
+/* leave */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_div3, { 0x9f90 }
+ },
+/* xchb @$Rj,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', '@', OP (RJ), ',', OP (RI), 0 } },
+ & ifmt_add, { 0x8a00 }
+ },
+};
+
+#undef A
+#undef MNEM
+#undef OPERAND
+#undef OP
+
+/* Formats for ALIAS macro-insns. */
+
+#define F(f) & fr30_cgen_ifld_table[CONCAT2 (FR30_,f)]
+
+static const CGEN_IFMT ifmt_ldi8m = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_I8), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi20m = {
+ 16, 32, 0xff00, { F (F_OP1), F (F_I20), F (F_OP2), F (F_RI), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi32m = {
+ 16, 48, 0xfff0, { F (F_OP1), F (F_I32), F (F_OP2), F (F_OP3), F (F_RI), 0 }
+};
+
+#undef F
+
+/* Each non-simple macro entry points to an array of expansion possibilities. */
+
+#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
+#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
+#define OPERAND(op) CONCAT2 (FR30_OPERAND_,op)
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+
+/* The macro instruction table. */
+
+static const CGEN_IBASE fr30_cgen_macro_insn_table[] =
+{
+/* ldi8 $i8,$Ri */
+ {
+ -1, "ldi8m", "ldi8", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldi20 $i20,$Ri */
+ {
+ -1, "ldi20m", "ldi20", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldi32 $i32,$Ri */
+ {
+ -1, "ldi32m", "ldi32", 48,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+};
+
+/* The macro instruction opcode table. */
+
+static const CGEN_OPCODE fr30_cgen_macro_insn_opcode_table[] =
+{
+/* ldi8 $i8,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (I8), ',', OP (RI), 0 } },
+ & ifmt_ldi8m, { 0xc000 }
+ },
+/* ldi20 $i20,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (I20), ',', OP (RI), 0 } },
+ & ifmt_ldi20m, { 0x9b00 }
+ },
+/* ldi32 $i32,$Ri */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (I32), ',', OP (RI), 0 } },
+ & ifmt_ldi32m, { 0x9f80 }
+ },
+};
+
+#undef A
+#undef MNEM
+#undef OPERAND
+#undef OP
+
+#ifndef CGEN_ASM_HASH_P
+#define CGEN_ASM_HASH_P(insn) 1
+#endif
+
+#ifndef CGEN_DIS_HASH_P
+#define CGEN_DIS_HASH_P(insn) 1
+#endif
+
+/* Return non-zero if INSN is to be added to the hash table.
+ Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */
+
+static int
+asm_hash_insn_p (insn)
+ const CGEN_INSN *insn;
+{
+ return CGEN_ASM_HASH_P (insn);
+}
+
+static int
+dis_hash_insn_p (insn)
+ const CGEN_INSN *insn;
+{
+ /* If building the hash table and the NO-DIS attribute is present,
+ ignore. */
+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
+ return 0;
+ return CGEN_DIS_HASH_P (insn);
+}
+
+#ifndef CGEN_ASM_HASH
+#define CGEN_ASM_HASH_SIZE 127
+#ifdef CGEN_MNEMONIC_OPERANDS
+#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
+#else
+#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
+#endif
+#endif
+
+/* It doesn't make much sense to provide a default here,
+ but while this is under development we do.
+ BUFFER is a pointer to the bytes of the insn, target order.
+ VALUE is the first base_insn_bitsize bits as an int in host order. */
+
+#ifndef CGEN_DIS_HASH
+#define CGEN_DIS_HASH_SIZE 256
+#define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
+#endif
+
+/* The result is the hash value of the insn.
+ Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */
+
+static unsigned int
+asm_hash_insn (mnem)
+ const char * mnem;
+{
+ return CGEN_ASM_HASH (mnem);
+}
+
+/* BUF is a pointer to the bytes of the insn, target order.
+ VALUE is the first base_insn_bitsize bits as an int in host order. */
+
+static unsigned int
+dis_hash_insn (buf, value)
+ const char * buf;
+ CGEN_INSN_INT value;
+{
+ return CGEN_DIS_HASH (buf, value);
+}
+
+/* Set the recorded length of the insn in the CGEN_FIELDS struct. */
+
+static void
+set_fields_bitsize (fields, size)
+ CGEN_FIELDS *fields;
+ int size;
+{
+ CGEN_FIELDS_BITSIZE (fields) = size;
+}
+
+/* Function to call before using the operand instance table.
+ This plugs the opcode entries and macro instructions into the cpu table. */
+
+void
+fr30_cgen_init_opcode_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ int i;
+ int num_macros = (sizeof (fr30_cgen_macro_insn_table) /
+ sizeof (fr30_cgen_macro_insn_table[0]));
+ const CGEN_IBASE *ib = & fr30_cgen_macro_insn_table[0];
+ const CGEN_OPCODE *oc = & fr30_cgen_macro_insn_opcode_table[0];
+ CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN));
+ memset (insns, 0, num_macros * sizeof (CGEN_INSN));
+ for (i = 0; i < num_macros; ++i)
+ {
+ insns[i].base = &ib[i];
+ insns[i].opcode = &oc[i];
+ }
+ cd->macro_insn_table.init_entries = insns;
+ cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
+ cd->macro_insn_table.num_init_entries = num_macros;
+
+ oc = & fr30_cgen_insn_opcode_table[0];
+ insns = (CGEN_INSN *) cd->insn_table.init_entries;
+ for (i = 0; i < MAX_INSNS; ++i)
+ insns[i].opcode = &oc[i];
+
+ cd->sizeof_fields = sizeof (CGEN_FIELDS);
+ cd->set_fields_bitsize = set_fields_bitsize;
+
+ cd->asm_hash_p = asm_hash_insn_p;
+ cd->asm_hash = asm_hash_insn;
+ cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
+
+ cd->dis_hash_p = dis_hash_insn_p;
+ cd->dis_hash = dis_hash_insn;
+ cd->dis_hash_size = CGEN_DIS_HASH_SIZE;
+}
diff --git a/opcodes/fr30-opc.h b/opcodes/fr30-opc.h
new file mode 100644
index 00000000000..d387ed55e99
--- /dev/null
+++ b/opcodes/fr30-opc.h
@@ -0,0 +1,150 @@
+/* Instruction opcode header for fr30.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef FR30_OPC_H
+#define FR30_OPC_H
+
+/* -- opc.h */
+
+/* ??? This can be improved upon. */
+#undef CGEN_DIS_HASH_SIZE
+#define CGEN_DIS_HASH_SIZE 16
+#undef CGEN_DIS_HASH
+#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 4)
+
+/* -- */
+/* Enum declaration for fr30 instruction types. */
+typedef enum cgen_insn_type {
+ FR30_INSN_INVALID, FR30_INSN_ADD, FR30_INSN_ADDI, FR30_INSN_ADD2
+ , FR30_INSN_ADDC, FR30_INSN_ADDN, FR30_INSN_ADDNI, FR30_INSN_ADDN2
+ , FR30_INSN_SUB, FR30_INSN_SUBC, FR30_INSN_SUBN, FR30_INSN_CMP
+ , FR30_INSN_CMPI, FR30_INSN_CMP2, FR30_INSN_AND, FR30_INSN_OR
+ , FR30_INSN_EOR, FR30_INSN_ANDM, FR30_INSN_ANDH, FR30_INSN_ANDB
+ , FR30_INSN_ORM, FR30_INSN_ORH, FR30_INSN_ORB, FR30_INSN_EORM
+ , FR30_INSN_EORH, FR30_INSN_EORB, FR30_INSN_BANDL, FR30_INSN_BORL
+ , FR30_INSN_BEORL, FR30_INSN_BANDH, FR30_INSN_BORH, FR30_INSN_BEORH
+ , FR30_INSN_BTSTL, FR30_INSN_BTSTH, FR30_INSN_MUL, FR30_INSN_MULU
+ , FR30_INSN_MULH, FR30_INSN_MULUH, FR30_INSN_DIV0S, FR30_INSN_DIV0U
+ , FR30_INSN_DIV1, FR30_INSN_DIV2, FR30_INSN_DIV3, FR30_INSN_DIV4S
+ , FR30_INSN_LSL, FR30_INSN_LSLI, FR30_INSN_LSL2, FR30_INSN_LSR
+ , FR30_INSN_LSRI, FR30_INSN_LSR2, FR30_INSN_ASR, FR30_INSN_ASRI
+ , FR30_INSN_ASR2, FR30_INSN_LDI8, FR30_INSN_LDI20, FR30_INSN_LDI32
+ , FR30_INSN_LD, FR30_INSN_LDUH, FR30_INSN_LDUB, FR30_INSN_LDR13
+ , FR30_INSN_LDR13UH, FR30_INSN_LDR13UB, FR30_INSN_LDR14, FR30_INSN_LDR14UH
+ , FR30_INSN_LDR14UB, FR30_INSN_LDR15, FR30_INSN_LDR15GR, FR30_INSN_LDR15DR
+ , FR30_INSN_LDR15PS, FR30_INSN_ST, FR30_INSN_STH, FR30_INSN_STB
+ , FR30_INSN_STR13, FR30_INSN_STR13H, FR30_INSN_STR13B, FR30_INSN_STR14
+ , FR30_INSN_STR14H, FR30_INSN_STR14B, FR30_INSN_STR15, FR30_INSN_STR15GR
+ , FR30_INSN_STR15DR, FR30_INSN_STR15PS, FR30_INSN_MOV, FR30_INSN_MOVDR
+ , FR30_INSN_MOVPS, FR30_INSN_MOV2DR, FR30_INSN_MOV2PS, FR30_INSN_JMP
+ , FR30_INSN_JMPD, FR30_INSN_CALLR, FR30_INSN_CALLRD, FR30_INSN_CALL
+ , FR30_INSN_CALLD, FR30_INSN_RET, FR30_INSN_RET_D, FR30_INSN_INT
+ , FR30_INSN_INTE, FR30_INSN_RETI, FR30_INSN_BRAD, FR30_INSN_BRA
+ , FR30_INSN_BNOD, FR30_INSN_BNO, FR30_INSN_BEQD, FR30_INSN_BEQ
+ , FR30_INSN_BNED, FR30_INSN_BNE, FR30_INSN_BCD, FR30_INSN_BC
+ , FR30_INSN_BNCD, FR30_INSN_BNC, FR30_INSN_BND, FR30_INSN_BN
+ , FR30_INSN_BPD, FR30_INSN_BP, FR30_INSN_BVD, FR30_INSN_BV
+ , FR30_INSN_BNVD, FR30_INSN_BNV, FR30_INSN_BLTD, FR30_INSN_BLT
+ , FR30_INSN_BGED, FR30_INSN_BGE, FR30_INSN_BLED, FR30_INSN_BLE
+ , FR30_INSN_BGTD, FR30_INSN_BGT, FR30_INSN_BLSD, FR30_INSN_BLS
+ , FR30_INSN_BHID, FR30_INSN_BHI, FR30_INSN_DMOVR13, FR30_INSN_DMOVR13H
+ , FR30_INSN_DMOVR13B, FR30_INSN_DMOVR13PI, FR30_INSN_DMOVR13PIH, FR30_INSN_DMOVR13PIB
+ , FR30_INSN_DMOVR15PI, FR30_INSN_DMOV2R13, FR30_INSN_DMOV2R13H, FR30_INSN_DMOV2R13B
+ , FR30_INSN_DMOV2R13PI, FR30_INSN_DMOV2R13PIH, FR30_INSN_DMOV2R13PIB, FR30_INSN_DMOV2R15PD
+ , FR30_INSN_LDRES, FR30_INSN_STRES, FR30_INSN_COPOP, FR30_INSN_COPLD
+ , FR30_INSN_COPST, FR30_INSN_COPSV, FR30_INSN_NOP, FR30_INSN_ANDCCR
+ , FR30_INSN_ORCCR, FR30_INSN_STILM, FR30_INSN_ADDSP, FR30_INSN_EXTSB
+ , FR30_INSN_EXTUB, FR30_INSN_EXTSH, FR30_INSN_EXTUH, FR30_INSN_LDM0
+ , FR30_INSN_LDM1, FR30_INSN_STM0, FR30_INSN_STM1, FR30_INSN_ENTER
+ , FR30_INSN_LEAVE, FR30_INSN_XCHB, FR30_INSN_MAX
+} CGEN_INSN_TYPE;
+
+/* Index of `invalid' insn place holder. */
+#define CGEN_INSN_INVALID FR30_INSN_INVALID
+
+/* Total number of insns in table. */
+#define MAX_INSNS ((int) FR30_INSN_MAX)
+
+/* This struct records data prior to insertion or after extraction. */
+struct cgen_fields
+{
+ int length;
+ long f_nil;
+ long f_op1;
+ long f_op2;
+ long f_op3;
+ long f_op4;
+ long f_op5;
+ long f_cc;
+ long f_ccc;
+ long f_Rj;
+ long f_Ri;
+ long f_Rs1;
+ long f_Rs2;
+ long f_Rjc;
+ long f_Ric;
+ long f_CRj;
+ long f_CRi;
+ long f_u4;
+ long f_u4c;
+ long f_i4;
+ long f_m4;
+ long f_u8;
+ long f_i8;
+ long f_i20_4;
+ long f_i20_16;
+ long f_i20;
+ long f_i32;
+ long f_udisp6;
+ long f_disp8;
+ long f_disp9;
+ long f_disp10;
+ long f_s10;
+ long f_u10;
+ long f_rel9;
+ long f_dir8;
+ long f_dir9;
+ long f_dir10;
+ long f_rel12;
+ long f_reglist_hi_st;
+ long f_reglist_low_st;
+ long f_reglist_hi_ld;
+ long f_reglist_low_ld;
+};
+
+#define CGEN_INIT_PARSE(od) \
+{\
+}
+#define CGEN_INIT_INSERT(od) \
+{\
+}
+#define CGEN_INIT_EXTRACT(od) \
+{\
+}
+#define CGEN_INIT_PRINT(od) \
+{\
+}
+
+
+#endif /* FR30_OPC_H */
diff --git a/opcodes/h8300-dis.c b/opcodes/h8300-dis.c
new file mode 100644
index 00000000000..57753a98d54
--- /dev/null
+++ b/opcodes/h8300-dis.c
@@ -0,0 +1,457 @@
+/* Disassemble h8300 instructions.
+ Copyright (C) 1993, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define DEFINE_TABLE
+
+#define h8_opcodes h8ops
+#include "opcode/h8300.h"
+#include "dis-asm.h"
+#include "opintl.h"
+
+
+/* Run through the opcodes and sort them into order to make them easy
+ to disassemble
+ */
+static void
+bfd_h8_disassemble_init ()
+{
+ unsigned int i;
+
+
+ struct h8_opcode *p;
+
+ for (p = h8_opcodes; p->name; p++)
+ {
+ int n1 = 0;
+ int n2 = 0;
+
+ if ((int) p->data.nib[0] < 16)
+ {
+ n1 = (int) p->data.nib[0];
+ }
+ else
+ n1 = 0;
+ if ((int) p->data.nib[1] < 16)
+ {
+ n2 = (int) p->data.nib[1];
+ }
+ else
+ n2 = 0;
+
+ /* Just make sure there are an even number of nibbles in it, and
+ that the count is the same s the length */
+ for (i = 0; p->data.nib[i] != E; i++)
+ /*EMPTY*/ ;
+ if (i & 1)
+ abort ();
+ p->length = i / 2;
+ }
+
+}
+
+
+unsigned int
+bfd_h8_disassemble (addr, info, mode)
+ bfd_vma addr;
+ disassemble_info *info;
+ int mode;
+{
+ /* Find the first entry in the table for this opcode */
+ static CONST char *regnames[] =
+ {
+ "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
+ "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l"};
+
+ static CONST char *wregnames[] =
+ {
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7"
+ };
+
+ static CONST char *lregnames[] =
+ {
+ "er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7",
+ "er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7"
+ }
+ ;
+
+ int rs = 0;
+ int rd = 0;
+ int rdisp = 0;
+ int abs = 0;
+ int bit = 0;
+ int plen = 0;
+ static boolean init = 0;
+ struct h8_opcode *q = h8_opcodes;
+ char CONST **pregnames = mode != 0 ? lregnames : wregnames;
+ int status;
+ int l;
+
+ unsigned char data[20];
+ void *stream = info->stream;
+ fprintf_ftype fprintf = info->fprintf_func;
+
+ if (!init)
+ {
+ bfd_h8_disassemble_init ();
+ init = 1;
+ }
+
+ status = info->read_memory_func(addr, data, 2, info);
+ if (status != 0)
+ {
+ info->memory_error_func(status, addr, info);
+ return -1;
+ }
+ for (l = 2; status == 0 && l < 10; l+=2)
+ {
+ status = info->read_memory_func(addr+l, data+l, 2, info);
+ }
+
+
+
+ /* Find the exact opcode/arg combo */
+ while (q->name)
+ {
+ op_type *nib;
+ unsigned int len = 0;
+
+ nib = q->data.nib;
+
+ while (1)
+ {
+ op_type looking_for = *nib;
+ int thisnib = data[len >> 1];
+
+ thisnib = (len & 1) ? (thisnib & 0xf) : ((thisnib >> 4) & 0xf);
+
+ if (looking_for < 16 && looking_for >=0)
+ {
+
+ if (looking_for != thisnib)
+ goto fail;
+ }
+
+ else
+ {
+
+ if ((int) looking_for & (int) B31)
+ {
+ if (! (((int) thisnib & 0x8) != 0))
+ goto fail;
+ looking_for = (op_type) ((int) looking_for & ~(int) B31);
+ }
+ if ((int) looking_for & (int) B30)
+ {
+ if (!(((int) thisnib & 0x8) == 0))
+ goto fail;
+ looking_for = (op_type) ((int) looking_for & ~(int) B30);
+ }
+
+ if (looking_for & DBIT)
+ {
+ if ((looking_for & 5) != (thisnib &5)) goto fail;
+ abs = (thisnib & 0x8) ? 2 : 1;
+ }
+
+ else if (looking_for & (REG | IND|INC|DEC))
+ {
+ if (looking_for & SRC)
+ {
+ rs = thisnib;
+ }
+ else
+ {
+ rd = thisnib;
+ }
+ }
+ else if (looking_for & L_16)
+ {
+ abs = (data[len >> 1]) * 256 + data[(len + 2) >> 1];
+ plen = 16;
+
+ }
+ else if(looking_for & ABSJMP)
+ {
+ abs =
+ (data[1] << 16)
+ | (data[2] << 8)
+ | (data[3]);
+ }
+ else if(looking_for & MEMIND)
+ {
+ abs = data[1];
+ }
+ else if (looking_for & L_32)
+ {
+ int i = len >> 1;
+ abs = (data[i] << 24)
+ | (data[i + 1] << 16)
+ | (data[i + 2] << 8)
+ | (data[i+ 3]);
+
+ plen =32;
+
+ }
+ else if (looking_for & L_24)
+ {
+ int i = len >> 1;
+ abs = (data[i] << 16) | (data[i + 1] << 8)| (data[i+2]);
+ plen =24;
+ }
+ else if (looking_for & IGNORE)
+ {
+
+ }
+ else if (looking_for & DISPREG)
+ {
+ rdisp = thisnib;
+ }
+ else if (looking_for & KBIT)
+ {
+ switch (thisnib)
+ {
+ case 9:
+ abs = 4;
+ break;
+ case 8:
+ abs = 2;
+ break;
+ case 0:
+ abs = 1;
+ break;
+ default:
+ goto fail;
+ }
+ }
+ else if (looking_for & L_8)
+ {
+ plen = 8;
+ abs = data[len >> 1];
+ }
+ else if (looking_for & L_3)
+ {
+ bit = thisnib & 0x7;
+ }
+ else if (looking_for & L_2)
+ {
+ plen = 2;
+ abs = thisnib & 0x3;
+ }
+ else if (looking_for & MACREG)
+ {
+ abs = (thisnib == 3);
+ }
+ else if (looking_for == E)
+ {
+
+ {
+ int i;
+
+ for (i = 0; i < q->length; i++)
+ {
+ fprintf (stream, "%02x ", data[i]);
+ }
+ for (; i < 6; i++)
+ {
+ fprintf (stream, " ");
+ }
+ }
+ fprintf (stream, "%s\t", q->name);
+
+ /* Gross. Disgusting. */
+ if (strcmp (q->name, "ldm.l") == 0)
+ {
+ int count, high;
+
+ count = (data[1] >> 4) & 0x3;
+ high = data[3] & 0x7;
+
+ fprintf (stream, "@sp+,er%d-er%d", high - count, high);
+ return q->length;
+ }
+
+ if (strcmp (q->name, "stm.l") == 0)
+ {
+ int count, low;
+
+ count = (data[1] >> 4) & 0x3;
+ low = data[3] & 0x7;
+
+ fprintf (stream, "er%d-er%d,@-sp", low, low + count);
+ return q->length;
+ }
+
+ /* Fill in the args */
+ {
+ op_type *args = q->args.nib;
+ int hadone = 0;
+
+
+ while (*args != E)
+ {
+ int x = *args;
+ if (hadone)
+ fprintf (stream, ",");
+
+
+ if (x & L_3)
+ {
+ fprintf (stream, "#0x%x", (unsigned) bit);
+ }
+ else if (x & (IMM|KBIT|DBIT))
+ {
+ /* Bletch. For shal #2,er0 and friends. */
+ if (*(args+1) & SRC_IN_DST)
+ abs = 2;
+
+ fprintf (stream, "#0x%x", (unsigned) abs);
+ }
+ else if (x & REG)
+ {
+ int rn = (x & DST) ? rd : rs;
+ switch (x & SIZE)
+ {
+ case L_8:
+ fprintf (stream, "%s", regnames[rn]);
+ break;
+ case L_16:
+ fprintf (stream, "%s", wregnames[rn]);
+ break;
+ case L_P:
+ case L_32:
+ fprintf (stream, "%s", lregnames[rn]);
+ break;
+
+ }
+ }
+ else if (x & MACREG)
+ {
+ fprintf (stream, "mac%c", abs ? 'l' : 'h');
+ }
+ else if (x & INC)
+ {
+ fprintf (stream, "@%s+", pregnames[rs]);
+ }
+ else if (x & DEC)
+ {
+ fprintf (stream, "@-%s", pregnames[rd]);
+ }
+
+ else if (x & IND)
+ {
+ int rn = (x & DST) ? rd : rs;
+ fprintf (stream, "@%s", pregnames[rn]);
+ }
+
+ else if (x & ABS8MEM)
+ {
+ fprintf (stream, "@0x%x:8", (unsigned) abs);
+ }
+
+ else if (x & (ABS|ABSJMP))
+ {
+ fprintf (stream, "@0x%x:%d", (unsigned) abs, plen);
+ }
+
+ else if (x & MEMIND)
+ {
+ fprintf (stream, "@@%d (%x)", abs, abs);
+ }
+
+ else if (x & PCREL)
+ {
+ if (x & L_16)
+ {
+ abs +=2;
+ fprintf (stream, ".%s%d (%x)", (short) abs > 0 ? "+" : "", (short) abs,
+ addr + (short) abs + 2);
+ }
+ else {
+ fprintf (stream, ".%s%d (%x)", (char) abs > 0 ? "+" : "", (char) abs,
+ addr + (char) abs + 2);
+ }
+ }
+ else if (x & DISP)
+ {
+ fprintf (stream, "@(0x%x:%d,%s)", abs,plen, pregnames[rdisp]);
+ }
+
+ else if (x & CCR)
+ {
+ fprintf (stream, "ccr");
+ }
+ else if (x & EXR)
+ {
+ fprintf (stream, "exr");
+ }
+ else
+ /* xgettext:c-format */
+ fprintf (stream, _("Hmmmm %x"), x);
+ hadone = 1;
+ args++;
+ }
+ }
+ return q->length;
+ }
+
+
+ else
+ {
+ /* xgettext:c-format */
+ fprintf (stream, _("Don't understand %x \n"), looking_for);
+ }
+ }
+
+ len++;
+ nib++;
+ }
+
+ fail:
+ q++;
+ }
+
+ /* Fell of the end */
+ fprintf (stream, "%02x %02x .word\tH'%x,H'%x",
+ data[0], data[1],
+ data[0], data[1]);
+ return 2;
+}
+
+int
+print_insn_h8300 (addr, info)
+bfd_vma addr;
+disassemble_info *info;
+{
+ return bfd_h8_disassemble (addr, info , 0);
+}
+
+int
+print_insn_h8300h (addr, info)
+bfd_vma addr;
+disassemble_info *info;
+{
+ return bfd_h8_disassemble (addr, info , 1);
+}
+
+int
+print_insn_h8300s (addr, info)
+bfd_vma addr;
+disassemble_info *info;
+{
+ return bfd_h8_disassemble (addr, info , 2);
+}
diff --git a/opcodes/h8500-dis.c b/opcodes/h8500-dis.c
new file mode 100644
index 00000000000..16858c98fa6
--- /dev/null
+++ b/opcodes/h8500-dis.c
@@ -0,0 +1,347 @@
+/* Disassemble h8500 instructions.
+ Copyright (C) 1993, 94, 95, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+
+#define DISASSEMBLER_TABLE
+#define DEFINE_TABLE
+
+#include "h8500-opc.h"
+#include "dis-asm.h"
+#include "opintl.h"
+
+/* Maximum length of an instruction. */
+#define MAXLEN 8
+
+#include <setjmp.h>
+
+struct private
+{
+ /* Points to first byte not fetched. */
+ bfd_byte *max_fetched;
+ bfd_byte the_buffer[MAXLEN];
+ bfd_vma insn_start;
+ jmp_buf bailout;
+};
+
+/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
+ to ADDR (exclusive) are valid. Returns 1 for success, longjmps
+ on error. */
+#define FETCH_DATA(info, addr) \
+ ((addr) <= ((struct private *)(info->private_data))->max_fetched \
+ ? 1 : fetch_data ((info), (addr)))
+
+static int
+fetch_data (info, addr)
+ struct disassemble_info *info;
+ bfd_byte *addr;
+{
+ int status;
+ struct private *priv = (struct private *) info->private_data;
+ bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
+
+ status = (*info->read_memory_func) (start,
+ priv->max_fetched,
+ addr - priv->max_fetched,
+ info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, start, info);
+ longjmp (priv->bailout, 1);
+ }
+ else
+ priv->max_fetched = addr;
+ return 1;
+}
+
+static char *crname[] =
+{"sr", "ccr", "*", "br", "ep", "dp", "*", "tp"};
+
+int
+print_insn_h8500 (addr, info)
+ bfd_vma addr;
+ disassemble_info *info;
+{
+ h8500_opcode_info *opcode;
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ struct private priv;
+ bfd_byte *buffer = priv.the_buffer;
+
+ info->private_data = (PTR) & priv;
+ priv.max_fetched = priv.the_buffer;
+ priv.insn_start = addr;
+ if (setjmp (priv.bailout) != 0)
+ /* Error return. */
+ return -1;
+
+if (0) {
+ static int one;
+ if (!one )
+ {
+ one = 1;
+ for (opcode = h8500_table; opcode->name; opcode++)
+ {
+ if ((opcode->bytes[0].contents & 0x8) == 0)
+ printf("%s\n", opcode->name);
+ }
+ }
+ }
+
+
+ /* Run down the table to find the one which matches */
+ for (opcode = h8500_table; opcode->name; opcode++)
+ {
+ int byte;
+ int rn = 0;
+ int rd = 0;
+ int rs = 0;
+ int disp = 0;
+ int abs = 0;
+ int imm = 0;
+ int pcrel = 0;
+ int qim = 0;
+ int i;
+ int cr = 0;
+ for (byte = 0; byte < opcode->length; byte++)
+ {
+ FETCH_DATA (info, buffer + byte + 1);
+ if ((buffer[byte] & opcode->bytes[byte].mask)
+ != (opcode->bytes[byte].contents))
+ {
+ goto next;
+ }
+ else
+ {
+ /* extract any info parts */
+ switch (opcode->bytes[byte].insert)
+ {
+ case 0:
+ case FP:
+ break;
+ default:
+ /* xgettext:c-format */
+ func (stream, _("can't cope with insert %d\n"),
+ opcode->bytes[byte].insert);
+ break;
+ case RN:
+ rn = buffer[byte] & 0x7;
+ break;
+ case RS:
+ rs = buffer[byte] & 0x7;
+ break;
+ case CRB:
+ cr = buffer[byte] & 0x7;
+ if (cr == 0)
+ goto next;
+ break;
+ case CRW:
+ cr = buffer[byte] & 0x7;
+ if (cr != 0)
+ goto next;
+ break;
+ case DISP16:
+ FETCH_DATA (info, buffer + byte + 2);
+ disp = (buffer[byte] << 8) | (buffer[byte + 1]);
+ break;
+ case FPIND_D8:
+ case DISP8:
+ disp = ((char) (buffer[byte]));
+ break;
+ case RD:
+ case RDIND:
+ rd = buffer[byte] & 0x7;
+ break;
+ case ABS24:
+ FETCH_DATA (info, buffer + byte + 3);
+ abs =
+ (buffer[byte] << 16)
+ | (buffer[byte + 1] << 8)
+ | (buffer[byte + 2]);
+ break;
+ case ABS16:
+ FETCH_DATA (info, buffer + byte + 2);
+ abs = (buffer[byte] << 8) | (buffer[byte + 1]);
+ break;
+ case ABS8:
+ abs = (buffer[byte]);
+ break;
+ case IMM16:
+ FETCH_DATA (info, buffer + byte + 2);
+ imm = (buffer[byte] << 8) | (buffer[byte + 1]);
+ break;
+ case IMM4:
+ imm = (buffer[byte]) & 0xf;
+ break;
+ case IMM8:
+ case RLIST:
+ imm = (buffer[byte]);
+ break;
+ case PCREL16:
+ FETCH_DATA (info, buffer + byte + 2);
+ pcrel = (buffer[byte] << 8) | (buffer[byte + 1]);
+ break;
+ case PCREL8:
+ pcrel = (buffer[byte]);
+ break;
+ case QIM:
+ switch (buffer[byte] & 0x7)
+ {
+ case 0:
+ qim = 1;
+ break;
+ case 1:
+ qim = 2;
+ break;
+ case 4:
+ qim = -1;
+ break;
+ case 5:
+ qim = -2;
+ break;
+ }
+ break;
+
+ }
+ }
+ }
+ /* We get here when all the masks have passed so we can output the
+ operands*/
+ FETCH_DATA (info, buffer + opcode->length);
+ for (i = 0; i < opcode->length; i++)
+ {
+ (func) (stream, "%02x ", buffer[i]);
+ }
+ for (; i < 6; i++)
+ {
+ (func) (stream, " ");
+ }
+ (func) (stream, "%s\t", opcode->name);
+ for (i = 0; i < opcode->nargs; i++)
+ {
+ if (i)
+ (func) (stream, ",");
+ switch (opcode->arg_type[i])
+ {
+ case FP:
+ func (stream, "fp");
+ break;
+ case RNIND_D16:
+ func (stream, "@(0x%x:16,r%d)", disp, rn);
+ break;
+ case RNIND_D8:
+ func (stream, "@(0x%x:8 (%d),r%d)", disp & 0xff, disp, rn);
+ break;
+ case RDIND_D16:
+ func (stream, "@(0x%x:16,r%d)", disp, rd);
+ break;
+ case RDIND_D8:
+ func (stream, "@(0x%x:8 (%d), r%d)", disp & 0xff, disp, rd);
+ break;
+ case FPIND_D8:
+ func (stream, "@(0x%x:8 (%d), fp)", disp & 0xff, disp, rn);
+ break;
+ case CRB:
+ case CRW:
+ func (stream, "%s", crname[cr]);
+ break;
+ case RN:
+ func (stream, "r%d", rn);
+ break;
+ case RD:
+ func (stream, "r%d", rd);
+ break;
+ case RS:
+ func (stream, "r%d", rs);
+ break;
+ case RNDEC:
+ func (stream, "@-r%d", rn);
+ break;
+ case RNINC:
+ func (stream, "@r%d+", rn);
+ break;
+ case RNIND:
+ func (stream, "@r%d", rn);
+ break;
+ case RDIND:
+ func (stream, "@r%d", rd);
+ break;
+ case SPINC:
+ func (stream, "@sp+");
+ break;
+ case SPDEC:
+ func (stream, "@-sp");
+ break;
+ case ABS24:
+ func (stream, "@0x%0x:24", abs);
+ break;
+ case ABS16:
+ func (stream, "@0x%0x:16", abs & 0xffff);
+ break;
+ case ABS8:
+ func (stream, "@0x%0x:8", abs & 0xff);
+ break;
+ case IMM16:
+ func (stream, "#0x%0x:16", imm & 0xffff);
+ break;
+ case RLIST:
+ {
+ int i;
+ int nc = 0;
+ func (stream, "(");
+ for (i = 0; i < 8; i++)
+ {
+ if (imm & (1 << i))
+ {
+ func (stream, "r%d", i);
+ if (nc)
+ func (stream, ",");
+ nc = 1;
+ }
+ }
+ func (stream, ")");
+ }
+ break;
+ case IMM8:
+ func (stream, "#0x%0x:8", imm & 0xff);
+ break;
+ case PCREL16:
+ func (stream, "0x%0x:16", (pcrel + addr + opcode->length) & 0xffff);
+ break;
+ case PCREL8:
+ func (stream, "#0x%0x:8",
+ ((char) pcrel + addr + opcode->length) & 0xffff);
+ break;
+ case QIM:
+ func (stream, "#%d:q", qim);
+ break;
+ case IMM4:
+ func (stream, "#%d:4", imm);
+ break;
+ }
+ }
+ return opcode->length;
+ next:;
+ }
+
+ /* Couldn't understand anything */
+ /* xgettext:c-format */
+ func (stream, _("%02x\t\t*unknown*"), buffer[0]);
+ return 1;
+
+}
diff --git a/opcodes/h8500-opc.h b/opcodes/h8500-opc.h
new file mode 100644
index 00000000000..d4949af34d0
--- /dev/null
+++ b/opcodes/h8500-opc.h
@@ -0,0 +1,3836 @@
+typedef enum
+{
+ GR0,GR1,GR2,GR3,GR4,GR5,GR6,GR7,
+ GPR0, GPR1, GPR2, GPR3, GPR4, GPR5, GPR6, GPR7,
+ GCCR, GPC,
+ GSEGC, GSEGD, GSEGE, GSEGT,GLAST
+} gdbreg_type;
+#define O_XORC 1
+#define O_XOR 2
+#define O_XCH 3
+#define O_UNLK 4
+#define O_TST 5
+#define O_TRAPA 6
+#define O_TRAP_VS 7
+#define O_TAS 8
+#define O_SWAP 9
+#define O_SUBX 10
+#define O_SUBS 11
+#define O_SUB 12
+#define O_STM 13
+#define O_STC 14
+#define O_SLEEP 15
+#define O_SHLR 16
+#define O_SHLL 17
+#define O_SHAR 18
+#define O_SHAL 19
+#define O_SCB_NE 20
+#define O_SCB_F 21
+#define O_SCB_EQ 22
+#define O_RTS 23
+#define O_RTD 24
+#define O_ROTXR 25
+#define O_ROTXL 26
+#define O_ROTR 27
+#define O_ROTL 28
+#define O_PRTS 29
+#define O_PRTD 30
+#define O_PJSR 31
+#define O_PJMP 32
+#define O_ORC 33
+#define O_OR 34
+#define O_NOT 35
+#define O_NOP 36
+#define O_NEG 37
+#define O_MULXU 38
+#define O_MOVTPE 39
+#define O_MOVFPE 40
+#define O_MOV 41
+#define O_LINK 42
+#define O_LDM 43
+#define O_LDC 44
+#define O_JSR 45
+#define O_JMP 46
+#define O_EXTU 47
+#define O_EXTS 48
+#define O_DSUB 49
+#define O_DIVXU 50
+#define O_DADD 51
+#define O_CMP 52
+#define O_CLR 53
+#define O_BVS 54
+#define O_BVC 55
+#define O_BTST 56
+#define O_BT 57
+#define O_BSR 58
+#define O_BSET 59
+#define O_BRN 60
+#define O_BRA 61
+#define O_BPT 62
+#define O_BPL 63
+#define O_BNOT 64
+#define O_BNE 65
+#define O_BMI 66
+#define O_BLT 67
+#define O_BLS 68
+#define O_BLO 69
+#define O_BLE 70
+#define O_BHS 71
+#define O_BHI 72
+#define O_BGT 73
+#define O_BGE 74
+#define O_BF 75
+#define O_BEQ 76
+#define O_BCS 77
+#define O_BCLR 78
+#define O_BCC 79
+#define O_ANDC 80
+#define O_AND 81
+#define O_ADDX 82
+#define O_ADDS 83
+#define O_ADD 84
+#define O_BYTE 128
+#define O_WORD 0x000
+#define O_UNSZ 0x000
+#define FPIND_D8 10
+#define RDIND_D16 11
+#define RDIND_D8 12
+#define SPDEC 13
+#define RDIND 14
+#define RN 15
+#define RNIND_D8 16
+#define RNIND_D16 17
+#define RNDEC 18
+#define RNINC 19
+#define RNIND 20
+#define SPINC 21
+#define ABS16 22
+#define ABS24 23
+#define PCREL16 24
+#define PCREL8 25
+#define ABS8 26
+#define CRB 27
+#define CR 28
+#define CRW 29
+#define DISP16 30
+#define DISP8 31
+#define FP 32
+#define IMM16 33
+#define IMM4 34
+#define IMM8 35
+#define RLIST 36
+#define QIM 37
+#define RD 38
+#define RS 39
+#define SP 40
+typedef enum { AC_BAD, AC_EI, AC_RI, AC_D, AC_,AC_ERR, AC_X,AC_B, AC_EE,AC_RR,AC_IE,
+ AC_RE,AC_E, AC_I, AC_ER,AC_IRR, AC_IR, AC_RER, AC_ERE,AC_EIE } addr_class_type;
+typedef struct {
+ short int idx;
+ char flags,src1,src2,dst;
+ unsigned char flavor;
+ char *name;
+ int nargs;
+ int arg_type[2];
+ int length;
+ struct { unsigned char contents;unsigned char mask; char insert; } bytes[6];
+} h8500_opcode_info;
+h8500_opcode_info h8500_table[]
+#ifdef ASSEMBLER_TABLE
+#ifdef DEFINE_TABLE
+={
+/*
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },
+ {0x00,0x00,ABS16 },
+ {0x00,0x00, },
+ {0x07,0xff, },
+ {0x00,0x00,IMM16 },{0x00,0x00, }}},*/
+
+{1,'s','E','C','C',O_XORC|O_WORD,"xorc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x68,0xf8,CRW }}},
+{2,'s','E','C','C',O_XORC|O_BYTE,"xorc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x68,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{5,'m','E','D','D',O_XOR|O_UNSZ,"xor",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{6,'-','X','!','!',O_XCH|O_WORD,"xch.w",2,{RS,RD},2, {{0xa8,0xf8,RS },{0x90,0xf8,RD }}},
+{7,'-','X','!','!',O_XCH|O_UNSZ,"xch",2,{RS,RD},2, {{0xa8,0xf8,RS },{0x90,0xf8,RD }}},
+{8,'-','B','!','!',O_UNLK|O_UNSZ,"unlk",1,{FP,0},1, {{0x0f,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{RN,0},2, {{0xa8,0xf8,RN },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x16,0xff, }}},
+{11,'a','E','!','!',O_TST|O_UNSZ,"tst",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x16,0xff, }}},
+{12,'-','I','!','!',O_TRAPA|O_UNSZ,"trapa",1,{IMM4,0},2, {{0x08,0xff, },{0x10,0xf0,IMM4 }}},
+{13,'-','B','!','!',O_TRAP_VS|O_UNSZ,"trap/vs",0,{0,0},1, {{0x09,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x17,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{RN,0},2, {{0xa0,0xf8,RN },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x17,0xff, }}},
+{15,'s','E','!','E',O_TAS|O_UNSZ,"tas",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x17,0xff, }}},
+{16,'m','D','!','D',O_SWAP|O_BYTE,"swap.b",1,{RD,0},2, {{0xa0,0xf8,RD },{0x10,0xff, }}},
+{17,'m','D','!','D',O_SWAP|O_UNSZ,"swap",1,{RD,0},2, {{0xa0,0xf8,RD },{0x10,0xff, }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{20,'a','E','D','D',O_SUBX|O_UNSZ,"subx",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{23,'-','E','D','D',O_SUBS|O_UNSZ,"subs",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{26,'a','E','D','D',O_SUB|O_UNSZ,"sub",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{27,'-','I','!','E',O_STM|O_UNSZ,"stm",2,{RLIST,SPDEC},2, {{0x12,0xff, },{0x00,0x00,RLIST }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,RN},2, {{0xa8,0xf8,RN },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,RNDEC},2, {{0xb8,0xf8,RN },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,RNINC},2, {{0xc8,0xf8,RN },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,RNIND},2, {{0xd8,0xf8,RN },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x98,0xf8,CRW }}},
+{28,'s','C','!','E',O_STC|O_WORD,"stc.w",2,{CRW,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x98,0xf8,CRW }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RN},2, {{0xa0,0xf8,RN },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNDEC},2, {{0xb0,0xf8,RN },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNINC},2, {{0xc0,0xf8,RN },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNIND},2, {{0xd0,0xf8,RN },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x98,0xf8,CRB }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,RN},2, {{0xa8,0xf8,RN },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,RN},2, {{0xa0,0xf8,RN },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,RNDEC},2, {{0xb0,0xf8,RN },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,RNIND},2, {{0xd8,0xf8,RN },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,RNINC},2, {{0xc8,0xf8,RN },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,RNDEC},2, {{0xb8,0xf8,RN },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,RNIND},2, {{0xd0,0xf8,RN },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,RNINC},2, {{0xc0,0xf8,RN },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRW,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x98,0xf8,CRW }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x98,0xf8,CRB }}},
+{30,'s','C','!','E',O_STC|O_UNSZ,"stc",2,{CRB,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x98,0xf8,CRB }}},
+{31,'-','!','!','!',O_SLEEP|O_UNSZ,"sleep",0,{0,0},1, {{0x1a,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1b,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1b,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1b,0xff, }}},
+{34,'h','E','!','E',O_SHLR|O_UNSZ,"shlr",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1b,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1a,0xff, }}},
+{37,'h','E','!','E',O_SHLL|O_UNSZ,"shll",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1a,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{RN,0},2, {{0xa8,0xf8,RN },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x19,0xff, }}},
+{40,'h','E','!','E',O_SHAR|O_UNSZ,"shar",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x19,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{RN,0},2, {{0xa8,0xf8,RN },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x18,0xff, }}},
+{43,'h','E','!','E',O_SHAL|O_UNSZ,"shal",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x18,0xff, }}},
+{44,'-','B','S','S',O_SCB_NE|O_UNSZ,"scb/ne",2,{RS,PCREL8},3, {{0x06,0xff, },{0xb8,0xf8,RS },{0x00,0x00,PCREL8 }}},
+{45,'-','B','S','S',O_SCB_F|O_UNSZ,"scb/f",2,{RS,PCREL8},3, {{0x01,0xff, },{0xb8,0xf8,RS },{0x00,0x00,PCREL8 }}},
+{46,'-','B','S','S',O_SCB_EQ|O_UNSZ,"scb/eq",2,{RS,PCREL8},3, {{0x07,0xff, },{0xb8,0xf8,RS },{0x00,0x00,PCREL8 }}},
+{47,'-','B','!','!',O_RTS|O_UNSZ,"rts",0,{0,0},1, {{0x19,0xff, }}},
+{48,'-','B','!','!',O_RTD|O_UNSZ,"rtd",1,{IMM8,0},2, {{0x14,0xff, },{0x00,0x00,IMM8 }}},
+{48,'-','B','!','!',O_RTD|O_UNSZ,"rtd",1,{IMM16,0},3, {{0x14,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1f,0xff, }}},
+{51,'h','E','!','E',O_ROTXR|O_UNSZ,"rotxr",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1f,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1e,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1e,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1e,0xff, }}},
+{54,'h','E','!','E',O_ROTXL|O_UNSZ,"rotxl",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1e,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1d,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1d,0xff, }}},
+{57,'h','E','!','E',O_ROTR|O_UNSZ,"rotr",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1d,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1c,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1c,0xff, }}},
+{60,'h','E','!','E',O_ROTL|O_UNSZ,"rotl",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1c,0xff, }}},
+{61,'-','B','!','!',O_PRTS|O_UNSZ,"prts",0,{0,0},2, {{0x11,0xff, },{0x19,0xff, }}},
+{62,'-','B','!','!',O_PRTD|O_UNSZ,"prtd",1,{IMM8,0},3, {{0x11,0xff, },{0x14,0xff, },{0x00,0x00,IMM8 }}},
+{62,'-','B','!','!',O_PRTD|O_UNSZ,"prtd",1,{IMM16,0},4, {{0x11,0xff, },{0x1c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{63,'-','J','!','!',O_PJSR|O_UNSZ,"pjsr",1,{RDIND,0},2, {{0x11,0xff, },{0xc8,0xf8,RDIND }}},
+{63,'-','J','!','!',O_PJSR|O_UNSZ,"pjsr",1,{ABS24,0},4, {{0x03,0xff, },{0x00,0x00,ABS24 },{0x00,0x00, },{0x00,0x00, }}},
+{64,'-','J','!','!',O_PJMP|O_UNSZ,"pjmp",1,{RDIND,0},2, {{0x11,0xff, },{0xc0,0xf8,RDIND }}},
+{64,'-','J','!','!',O_PJMP|O_UNSZ,"pjmp",1,{ABS24,0},4, {{0x13,0xff, },{0x00,0x00,ABS24 },{0x00,0x00, },{0x00,0x00, }}},
+{65,'s','I','C','C',O_ORC|O_WORD,"orc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x48,0xf8,CRW }}},
+{66,'s','I','C','C',O_ORC|O_BYTE,"orc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x48,0xf8,CRB }}},
+{67,'s','I','C','C',O_ORC|O_UNSZ,"orc",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x48,0xf8,CRB }}},
+{67,'s','I','C','C',O_ORC|O_UNSZ,"orc",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x48,0xf8,CRW }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{70,'m','E','D','D',O_OR|O_UNSZ,"or",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x15,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x15,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{RN,0},2, {{0xa8,0xf8,RN },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x15,0xff, }}},
+{73,'m','E','!','E',O_NOT|O_UNSZ,"not",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x15,0xff, }}},
+{74,'-','!','!','!',O_NOP|O_UNSZ,"nop",0,{0,0},1, {{0x00,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x14,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x14,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{RN,0},2, {{0xa8,0xf8,RN },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x14,0xff, }}},
+{77,'a','E','!','E',O_NEG|O_UNSZ,"neg",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x14,0xff, }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{80,'p','E','D','D',O_MULXU|O_UNSZ,"mulxu",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RN},3, {{0xa0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNDEC},3, {{0xb0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNINC},3, {{0xc0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNIND},3, {{0xd0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,RN},3, {{0xa0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,RNDEC},3, {{0xb0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,RNIND},3, {{0xd0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,RNINC},3, {{0xc0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x00,0xff, },{0x90,0xf8,RS }}},
+{82,'-','S','!','E',O_MOVTPE|O_UNSZ,"movtpe",2,{RS,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x00,0xff, },{0x90,0xf8,RS }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RN,RD},3, {{0xa0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNINC,RD},3, {{0xc0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNIND,RD},3, {{0xd0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNDEC,RD},3, {{0xb0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{IMM8,RD},4, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{ABS8,RD},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNIND_D8,RD},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{ABS16,RD},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNIND_D16,RD},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{RN,RD},3, {{0xa0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{RNINC,RD},3, {{0xc0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{RNIND,RD},3, {{0xd0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{RNDEC,RD},3, {{0xb0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{IMM8,RD},4, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{ABS8,RD},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{RNIND_D8,RD},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{ABS16,RD},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x00,0xff, },{0x80,0xf8,RD }}},
+{84,'-','E','!','D',O_MOVFPE|O_UNSZ,"movfpe",2,{RNIND_D16,RD},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x00,0xff, },{0x80,0xf8,RD }}},
+{85,'m','S','!','E',O_MOV|O_WORD,"mov:s.w",2,{RS,ABS8},2, {{0x78,0xf8,RS },{0x00,0x00,ABS8 }}},
+{86,'m','S','!','E',O_MOV|O_BYTE,"mov:s.b",2,{RS,ABS8},2, {{0x70,0xf8,RS },{0x00,0x00,ABS8 }}},
+{87,'m','S','!','E',O_MOV|O_UNSZ,"mov:s",2,{RS,ABS8},2, {{0x78,0xf8,RS },{0x00,0x00,ABS8 }}},
+{88,'m','E','!','D',O_MOV|O_WORD,"mov:l.w",2,{ABS8,RD},2, {{0x68,0xf8,RD },{0x00,0x00,ABS8 }}},
+{89,'m','E','!','D',O_MOV|O_BYTE,"mov:l.b",2,{ABS8,RD},2, {{0x60,0xf8,RD },{0x00,0x00,ABS8 }}},
+{90,'m','E','!','D',O_MOV|O_UNSZ,"mov:l",2,{ABS8,RD},2, {{0x68,0xf8,RD },{0x00,0x00,ABS8 }}},
+{91,'m','I','!','D',O_MOV|O_WORD,"mov:i.w",2,{IMM16,RD},3, {{0x58,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{92,'m','I','!','D',O_MOV|O_UNSZ,"mov:i", 2,{IMM16,RD},3, {{0x58,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x90,0xf8,RS }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x90,0xf8,RS }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x90,0xf8,RS }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x80,0xf8,RD }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x80,0xf8,RD }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNIND_D8},5,{{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNIND_D16},6,{{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x90,0xf8,RS }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x90,0xf8,RS }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x90,0xf8,RS }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x80,0xf8,RD }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNIND},3, {{0xd0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNINC},3, {{0xc0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNDEC},3, {{0xb0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x90,0xf8,RS }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x80,0xf8,RD }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x90,0xf8,RS }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x80,0xf8,RD }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x90,0xf8,RS }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x80,0xf8,RD }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x80,0xf8,RD }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,RNIND},3, {{0xd8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,RNDEC},3, {{0xb8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,RNINC},3, {{0xc8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,RNIND_D8},4, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,ABS8},4, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{95,'m','S','!','E',O_MOV|O_UNSZ,"mov:g",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{95,'m','E','!','D',O_MOV|O_UNSZ,"mov:g",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,ABS16},5, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM8,RNIND_D16},5, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{95,'m','I','!','E',O_MOV|O_UNSZ,"mov:g",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{96,'m','S','!','E',O_MOV|O_WORD,"mov:f.w",2,{RS,FPIND_D8},2, {{0x98,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{96,'m','E','!','D',O_MOV|O_WORD,"mov:f.w",2,{FPIND_D8,RD},2, {{0x88,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{97,'m','S','!','E',O_MOV|O_BYTE,"mov:f.b",2,{RS,FPIND_D8},2, {{0x90,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{97,'m','E','!','D',O_MOV|O_BYTE,"mov:f.b",2,{FPIND_D8,RD},2, {{0x80,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{98,'m','S','!','E',O_MOV|O_UNSZ,"mov:f",2,{RS,FPIND_D8},2, {{0x98,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{98,'m','E','!','D',O_MOV|O_UNSZ,"mov:f",2,{FPIND_D8,RD},2, {{0x88,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{99,'m','I','!','D',O_MOV|O_BYTE,"mov:e.b",2,{IMM8,RD},2, {{0x50,0xf8,RD },{0x00,0x00,IMM8 }}},
+{100,'m','I','!','D',O_MOV|O_UNSZ,"mov:e",2,{IMM8,RD},2, {{0x50,0xf8,RD },{0x00,0x00,IMM8 }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,FPIND_D8},2, {{0x98,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,ABS8},2, {{0x78,0xf8,RS },{0x00,0x00,ABS8 }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{ABS8,RD},2, {{0x68,0xf8,RD },{0x00,0x00,ABS8 }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x90,0xf8,RS }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x90,0xf8,RS }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x90,0xf8,RS }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x80,0xf8,RD }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{FPIND_D8,RD},2, {{0x88,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x80,0xf8,RD }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x80,0xf8,RD }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x80,0xf8,RD }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{101,'m','I','!','D',O_MOV|O_WORD,"mov.w",2,{IMM16,RD},3, {{0x58,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{101,'m','S','!','E',O_MOV|O_WORD,"mov.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{101,'m','E','!','D',O_MOV|O_WORD,"mov.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{101,'m','I','!','E',O_MOV|O_WORD,"mov.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{FPIND_D8,RD},2, {{0x80,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,ABS8},2, {{0x70,0xf8,RS },{0x00,0x00,ABS8 }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x80,0xf8,RD }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x90,0xf8,RS }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x90,0xf8,RS }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x90,0xf8,RS }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x80,0xf8,RD }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,FPIND_D8},2, {{0x90,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x80,0xf8,RD }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x80,0xf8,RD }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{ABS8,RD},2, {{0x60,0xf8,RD },{0x00,0x00,ABS8 }}},
+{102,'m','I','!','D',O_MOV|O_BYTE,"mov.b",2,{IMM8,RD},2, {{0x50,0xf8,RD },{0x00,0x00,IMM8 }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x80,0xf8,RD }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,RNIND},3, {{0xd0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,RNINC},3, {{0xc0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,RNDEC},3, {{0xb0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{102,'m','S','!','E',O_MOV|O_BYTE,"mov.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{102,'m','E','!','D',O_MOV|O_BYTE,"mov.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{102,'m','I','!','E',O_MOV|O_BYTE,"mov.b",2,{IMM8,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{ABS8,RD},2, {{0x68,0xf8,RD },{0x00,0x00,ABS8 }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,ABS8},2, {{0x78,0xf8,RS },{0x00,0x00,ABS8 }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x80,0xf8,RD }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x90,0xf8,RS }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x90,0xf8,RS }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x90,0xf8,RS }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x80,0xf8,RD }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,FPIND_D8},2, {{0x98,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x80,0xf8,RD }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{FPIND_D8,RD},2, {{0x88,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+/*{103,'m','I','!','D',O_MOV|O_UNSZ,"mov",2,{IMM8,RD},2, {{0x58,0xf8,RD },{0x00,0x00,IMM8 }}},*/
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x80,0xf8,RD }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,RNIND},3, {{0xd8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,RNINC},3, {{0xc8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,RNDEC},3, {{0xb8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{103,'m','I','!','D',O_MOV|O_UNSZ,"mov",2,{IMM16,RD},3, {{0x58,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,ABS8},4, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','S','!','E',O_MOV|O_UNSZ,"mov",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,RNIND_D8},4, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{103,'m','E','!','D',O_MOV|O_UNSZ,"mov",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,ABS16},5, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM8,RNIND_D16},5, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{103,'m','I','!','E',O_MOV|O_UNSZ,"mov",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{104,'-','S','I','!',O_LINK|O_UNSZ,"link",2,{FP,IMM8},2, {{0x17,0xff, },{0x00,0x00,IMM8 }}},
+{104,'-','S','I','!',O_LINK|O_UNSZ,"link",2,{FP,IMM16},3, {{0x1f,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{105,'-','E','!','C',O_LDM|O_UNSZ,"ldm",2,{SPINC,RLIST},2, {{0x02,0xff, },{0x00,0x00,RLIST }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{RN,CRW},2, {{0xa8,0xf8,RN },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{RNIND,CRW},2, {{0xd8,0xf8,RN },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{RNINC,CRW},2, {{0xc8,0xf8,RN },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{RNDEC,CRW},2, {{0xb8,0xf8,RN },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{ABS8,CRW},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{RNIND_D8,CRW},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{ABS16,CRW},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{RNIND_D16,CRW},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RN,CRB},2, {{0xa0,0xf8,RN },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNDEC,CRB},2, {{0xb0,0xf8,RN },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNINC,CRB},2, {{0xc0,0xf8,RN },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNIND,CRB},2, {{0xd0,0xf8,RN },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{ABS8,CRB},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNIND_D8,CRB},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{ABS16,CRB},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNIND_D16,CRB},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RN,CRW},2, {{0xa8,0xf8,RN },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RN,CRB},2, {{0xa0,0xf8,RN },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNINC,CRW},2, {{0xc8,0xf8,RN },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNIND,CRB},2, {{0xd0,0xf8,RN },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNDEC,CRW},2, {{0xb8,0xf8,RN },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNIND,CRW},2, {{0xd8,0xf8,RN },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNDEC,CRB},2, {{0xb0,0xf8,RN },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNINC,CRB},2, {{0xc0,0xf8,RN },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{ABS8,CRW},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{ABS8,CRB},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNIND_D8,CRW},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNIND_D8,CRB},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{ABS16,CRB},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x88,0xf8,CRB }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{ABS16,CRW},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNIND_D16,CRW},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{108,'s','E','!','C',O_LDC|O_UNSZ,"ldc",2,{RNIND_D16,CRB},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x88,0xf8,CRB }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{RDIND,0},2, {{0x11,0xff, },{0xd8,0xf8,RD }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{ABS16,0},3, {{0x18,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{RDIND_D8,0},3, {{0x11,0xff, },{0xe8,0xf8,RDIND_D8 },{0x00,0x00, }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{RDIND_D16,0},4, {{0x11,0xff, },{0xf8,0xf8,RDIND_D16 },{0x00,0x00, },{0x00,0x00, }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{RDIND,0},2, {{0x11,0xff, },{0xd0,0xf8,RD }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{ABS16,0},3, {{0x10,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{RDIND_D8,0},3, {{0x11,0xff, },{0xe0,0xf8,RDIND_D8 },{0x00,0x00, }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{RDIND_D16,0},4, {{0x11,0xff, },{0xf0,0xf8,RDIND_D16 },{0x00,0x00, },{0x00,0x00, }}},
+{111,'s','D','!','D',O_EXTU|O_BYTE,"extu.b",1,{RD,0},2, {{0xa0,0xf8,RD },{0x12,0xff, }}},
+{112,'s','D','!','D',O_EXTU|O_UNSZ,"extu",1,{RD,0},2, {{0xa0,0xf8,RD },{0x12,0xff, }}},
+{113,'s','D','!','D',O_EXTS|O_BYTE,"exts.b",1,{RD,0},2, {{0xa0,0xf8,RD },{0x11,0xff, }}},
+{114,'s','D','!','D',O_EXTS|O_UNSZ,"exts",1,{RD,0},2, {{0xa0,0xf8,RD },{0x11,0xff, }}},
+{115,'s','D','!','!',O_DSUB|O_UNSZ,"dsub",2,{RS,RD},3, {{0xa0,0xf8,RS },{0x00,0xff, },{0xb0,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{118,'s','E','D','D',O_DIVXU|O_UNSZ,"divxu",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{119,'s','D','!','!',O_DADD|O_UNSZ,"dadd",2,{RS,RD},3, {{0xa0,0xf8,RS },{0x00,0xff, },{0xa0,0xf8,RD }}},
+{120,'a','D','I','!',O_CMP|O_WORD,"cmp:i.w",2,{IMM16,RD},3, {{0x48,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{121,'a','D','I','!',O_CMP|O_UNSZ,"cmp:i",2,{IMM16,RD},3, {{0x48,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RN},4, {{0xa8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNIND_D8},5,{{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RN},3, {{0xa0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNIND},3, {{0xd0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNINC},3, {{0xc0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNDEC},3, {{0xb0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RN},4, {{0xa8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{124,'a','D','E','!',O_CMP|O_UNSZ,"cmp:g",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,RNIND_D16},6,{{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{124,'a','E','I','!',O_CMP|O_UNSZ,"cmp:g",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{125,'a','D','I','!',O_CMP|O_BYTE,"cmp:e.b",2,{IMM8,RD},2, {{0x40,0xf8,RD },{0x00,0x00,IMM8 }}},
+{126,'a','D','I','!',O_CMP|O_UNSZ,"cmp:e",2,{IMM8,RD},2, {{0x48,0xf8,RD },{0x00,0x00,IMM8 }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x70,0xf8,RD }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x70,0xf8,RD }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x70,0xf8,RD }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x70,0xf8,RD }}},
+{127,'a','D','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RD},3, {{0x48,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{127,'a','D','E','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RN},4, {{0xa8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,RNIND_D16},6,{{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{127,'a','E','I','!',O_CMP|O_WORD,"cmp.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x70,0xf8,RD }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x70,0xf8,RD }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x70,0xf8,RD }}},
+{128,'a','D','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RD},2, {{0x40,0xf8,RD },{0x00,0x00,IMM8 }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x70,0xf8,RD }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RN},3, {{0xa0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RNIND},3, {{0xd0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RNINC},3, {{0xc0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RNDEC},3, {{0xb0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x70,0xf8,RD }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','D','E','!',O_CMP|O_BYTE,"cmp.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{128,'a','E','I','!',O_CMP|O_BYTE,"cmp.b",2,{IMM8,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x70,0xf8,RD }}},
+{129,'a','D','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM8,RD},2, {{0x48,0xf8,RD },{0x00,0x00,IMM8 }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x70,0xf8,RD }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x70,0xf8,RD }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x70,0xf8,RD }}},
+{129,'a','D','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RD},3, {{0x48,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RN},4, {{0xa8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{129,'a','D','E','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{129,'a','E','I','!',O_CMP|O_UNSZ,"cmp",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{RN,0},2, {{0xa8,0xf8,RN },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x13,0xff, }}},
+{132,'c','!','!','E',O_CLR|O_UNSZ,"clr",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x13,0xff, }}},
+{133,'-','B','!','!',O_BVS|O_WORD,"bvs.w",1,{PCREL16,0},3, {{0x39,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{134,'-','B','!','!',O_BVS|O_BYTE,"bvs.b",1,{PCREL8,0},2, {{0x29,0xff, },{0x00,0x00,PCREL8 }}},
+{135,'-','B','!','!',O_BVS|O_UNSZ,"bvs",1,{PCREL8,0},2, {{0x29,0xff, },{0x00,0x00,PCREL8 }}},
+{135,'-','B','!','!',O_BVS|O_UNSZ,"bvs",1,{PCREL16,0},3, {{0x39,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{136,'-','B','!','!',O_BVC|O_WORD,"bvc.w",1,{PCREL16,0},3, {{0x38,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{137,'-','B','!','!',O_BVC|O_BYTE,"bvc.b",1,{PCREL8,0},2, {{0x28,0xff, },{0x00,0x00,PCREL8 }}},
+{138,'-','B','!','!',O_BVC|O_UNSZ,"bvc",1,{PCREL8,0},2, {{0x28,0xff, },{0x00,0x00,PCREL8 }}},
+{138,'-','B','!','!',O_BVC|O_UNSZ,"bvc",1,{PCREL16,0},3, {{0x38,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x78,0xf8,RS }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x78,0xf8,RS }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x78,0xf8,RS }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x78,0xf8,RS }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x78,0xf8,RS }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x78,0xf8,RS }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x78,0xf8,RS }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x78,0xf8,RS }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{141,'b','E','S','E',O_BTST|O_UNSZ,"btst",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{141,'b','E','I','E',O_BTST|O_UNSZ,"btst",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{142,'-','B','!','!',O_BT|O_WORD,"bt.w",1,{PCREL16,0},3, {{0x30,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{143,'-','B','!','!',O_BT|O_BYTE,"bt.b",1,{PCREL8,0},2, {{0x20,0xff, },{0x00,0x00,PCREL8 }}},
+{144,'-','B','!','!',O_BT|O_UNSZ,"bt",1,{PCREL8,0},2, {{0x20,0xff, },{0x00,0x00,PCREL8 }}},
+{144,'-','B','!','!',O_BT|O_UNSZ,"bt",1,{PCREL16,0},3, {{0x30,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{145,'-','B','!','!',O_BSR|O_WORD,"bsr.w",1,{PCREL16,0},3, {{0x1e,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{146,'-','B','!','!',O_BSR|O_BYTE,"bsr.b",1,{PCREL8,0},2, {{0x0e,0xff, },{0x00,0x00,PCREL8 }}},
+{147,'-','B','!','!',O_BSR|O_UNSZ,"bsr",1,{PCREL8,0},2, {{0x0e,0xff, },{0x00,0x00,PCREL8 }}},
+{147,'-','B','!','!',O_BSR|O_UNSZ,"bsr",1,{PCREL16,0},3, {{0x1e,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x48,0xf8,RS }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x48,0xf8,RS }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x48,0xf8,RS }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x48,0xf8,RS }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x48,0xf8,RS }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x48,0xf8,RS }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x48,0xf8,RS }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x48,0xf8,RS }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x48,0xf8,RS }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x48,0xf8,RS }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{150,'b','E','S','E',O_BSET|O_UNSZ,"bset",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{150,'b','E','I','E',O_BSET|O_UNSZ,"bset",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{151,'-','B','!','!',O_BRN|O_WORD,"brn.w",1,{PCREL16,0},3, {{0x31,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{152,'-','B','!','!',O_BRN|O_BYTE,"brn.b",1,{PCREL8,0},2, {{0x21,0xff, },{0x00,0x00,PCREL8 }}},
+{153,'-','B','!','!',O_BRN|O_UNSZ,"brn",1,{PCREL8,0},2, {{0x21,0xff, },{0x00,0x00,PCREL8 }}},
+{153,'-','B','!','!',O_BRN|O_UNSZ,"brn",1,{PCREL16,0},3, {{0x31,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{154,'-','B','!','!',O_BRA|O_WORD,"bra.w",1,{PCREL16,0},3, {{0x30,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{155,'-','B','!','!',O_BRA|O_BYTE,"bra.b",1,{PCREL8,0},2, {{0x20,0xff, },{0x00,0x00,PCREL8 }}},
+{156,'-','B','!','!',O_BRA|O_UNSZ,"bra",1,{PCREL8,0},2, {{0x20,0xff, },{0x00,0x00,PCREL8 }}},
+{156,'-','B','!','!',O_BRA|O_UNSZ,"bra",1,{PCREL16,0},3, {{0x30,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{157,'-','!','!','!',O_BPT|O_UNSZ,"bpt",0,{0,0},1, {{0x0b,0xff, }}},
+{158,'-','B','!','!',O_BPL|O_WORD,"bpl.w",1,{PCREL16,0},3, {{0x3a,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{159,'-','B','!','!',O_BPL|O_BYTE,"bpl.b",1,{PCREL8,0},2, {{0x2a,0xff, },{0x00,0x00,PCREL8 }}},
+{160,'-','B','!','!',O_BPL|O_UNSZ,"bpl",1,{PCREL8,0},2, {{0x2a,0xff, },{0x00,0x00,PCREL8 }}},
+{160,'-','B','!','!',O_BPL|O_UNSZ,"bpl",1,{PCREL16,0},3, {{0x3a,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x68,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x68,0xf8,RS }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x68,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x68,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x68,0xf8,RS }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x68,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x68,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x68,0xf8,RS }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x68,0xf8,RS }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x68,0xf8,RS }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x68,0xf8,RS }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x68,0xf8,RS }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x68,0xf8,RS }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{163,'b','E','S','E',O_BNOT|O_UNSZ,"bnot",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{163,'b','E','I','E',O_BNOT|O_UNSZ,"bnot",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{164,'-','B','!','!',O_BNE|O_WORD,"bne.w",1,{PCREL16,0},3, {{0x36,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{165,'-','B','!','!',O_BNE|O_BYTE,"bne.b",1,{PCREL8,0},2, {{0x26,0xff, },{0x00,0x00,PCREL8 }}},
+{166,'-','B','!','!',O_BNE|O_UNSZ,"bne",1,{PCREL8,0},2, {{0x26,0xff, },{0x00,0x00,PCREL8 }}},
+{166,'-','B','!','!',O_BNE|O_UNSZ,"bne",1,{PCREL16,0},3, {{0x36,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{167,'-','B','!','!',O_BMI|O_WORD,"bmi.w",1,{PCREL16,0},3, {{0x3b,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{168,'-','B','!','!',O_BMI|O_BYTE,"bmi.b",1,{PCREL8,0},2, {{0x2b,0xff, },{0x00,0x00,PCREL8 }}},
+{169,'-','B','!','!',O_BMI|O_UNSZ,"bmi",1,{PCREL8,0},2, {{0x2b,0xff, },{0x00,0x00,PCREL8 }}},
+{169,'-','B','!','!',O_BMI|O_UNSZ,"bmi",1,{PCREL16,0},3, {{0x3b,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{170,'-','B','!','!',O_BLT|O_WORD,"blt.w",1,{PCREL16,0},3, {{0x3d,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{171,'-','B','!','!',O_BLT|O_BYTE,"blt.b",1,{PCREL8,0},2, {{0x2d,0xff, },{0x00,0x00,PCREL8 }}},
+{172,'-','B','!','!',O_BLT|O_UNSZ,"blt",1,{PCREL8,0},2, {{0x2d,0xff, },{0x00,0x00,PCREL8 }}},
+{172,'-','B','!','!',O_BLT|O_UNSZ,"blt",1,{PCREL16,0},3, {{0x3d,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{173,'-','B','!','!',O_BLS|O_WORD,"bls.w",1,{PCREL16,0},3, {{0x33,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{174,'-','B','!','!',O_BLS|O_BYTE,"bls.b",1,{PCREL8,0},2, {{0x23,0xff, },{0x00,0x00,PCREL8 }}},
+{175,'-','B','!','!',O_BLS|O_UNSZ,"bls",1,{PCREL8,0},2, {{0x23,0xff, },{0x00,0x00,PCREL8 }}},
+{175,'-','B','!','!',O_BLS|O_UNSZ,"bls",1,{PCREL16,0},3, {{0x33,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{176,'-','B','!','!',O_BLO|O_WORD,"blo.w",1,{PCREL16,0},3, {{0x35,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{177,'-','B','!','!',O_BLO|O_BYTE,"blo.b",1,{PCREL8,0},2, {{0x25,0xff, },{0x00,0x00,PCREL8 }}},
+{178,'-','B','!','!',O_BLO|O_UNSZ,"blo",1,{PCREL8,0},2, {{0x25,0xff, },{0x00,0x00,PCREL8 }}},
+{178,'-','B','!','!',O_BLO|O_UNSZ,"blo",1,{PCREL16,0},3, {{0x35,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{179,'-','B','!','!',O_BLE|O_WORD,"ble.w",1,{PCREL16,0},3, {{0x3f,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{180,'-','B','!','!',O_BLE|O_BYTE,"ble.b",1,{PCREL8,0},2, {{0x2f,0xff, },{0x00,0x00,PCREL8 }}},
+{181,'-','B','!','!',O_BLE|O_UNSZ,"ble",1,{PCREL8,0},2, {{0x2f,0xff, },{0x00,0x00,PCREL8 }}},
+{181,'-','B','!','!',O_BLE|O_UNSZ,"ble",1,{PCREL16,0},3, {{0x3f,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{182,'-','B','!','!',O_BHS|O_WORD,"bhs.w",1,{PCREL16,0},3, {{0x34,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{183,'-','B','!','!',O_BHS|O_BYTE,"bhs.b",1,{PCREL8,0},2, {{0x24,0xff, },{0x00,0x00,PCREL8 }}},
+{184,'-','B','!','!',O_BHS|O_UNSZ,"bhs",1,{PCREL8,0},2, {{0x24,0xff, },{0x00,0x00,PCREL8 }}},
+{184,'-','B','!','!',O_BHS|O_UNSZ,"bhs",1,{PCREL16,0},3, {{0x34,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{185,'-','B','!','!',O_BHI|O_WORD,"bhi.w",1,{PCREL16,0},3, {{0x32,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{186,'-','B','!','!',O_BHI|O_BYTE,"bhi.b",1,{PCREL8,0},2, {{0x22,0xff, },{0x00,0x00,PCREL8 }}},
+{187,'-','B','!','!',O_BHI|O_UNSZ,"bhi",1,{PCREL8,0},2, {{0x22,0xff, },{0x00,0x00,PCREL8 }}},
+{187,'-','B','!','!',O_BHI|O_UNSZ,"bhi",1,{PCREL16,0},3, {{0x32,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{188,'-','B','!','!',O_BGT|O_WORD,"bgt.w",1,{PCREL16,0},3, {{0x3e,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{189,'-','B','!','!',O_BGT|O_BYTE,"bgt.b",1,{PCREL8,0},2, {{0x2e,0xff, },{0x00,0x00,PCREL8 }}},
+{190,'-','B','!','!',O_BGT|O_UNSZ,"bgt",1,{PCREL8,0},2, {{0x2e,0xff, },{0x00,0x00,PCREL8 }}},
+{190,'-','B','!','!',O_BGT|O_UNSZ,"bgt",1,{PCREL16,0},3, {{0x3e,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{191,'-','B','!','!',O_BGE|O_WORD,"bge.w",1,{PCREL16,0},3, {{0x3c,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{192,'-','B','!','!',O_BGE|O_BYTE,"bge.b",1,{PCREL8,0},2, {{0x2c,0xff, },{0x00,0x00,PCREL8 }}},
+{193,'-','B','!','!',O_BGE|O_UNSZ,"bge",1,{PCREL8,0},2, {{0x2c,0xff, },{0x00,0x00,PCREL8 }}},
+{193,'-','B','!','!',O_BGE|O_UNSZ,"bge",1,{PCREL16,0},3, {{0x3c,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{194,'-','B','!','!',O_BF|O_WORD,"bf.w",1,{PCREL16,0},3, {{0x31,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{195,'-','B','!','!',O_BF|O_BYTE,"bf.b",1,{PCREL8,0},2, {{0x21,0xff, },{0x00,0x00,PCREL8 }}},
+{196,'-','B','!','!',O_BF|O_UNSZ,"bf",1,{PCREL8,0},2, {{0x21,0xff, },{0x00,0x00,PCREL8 }}},
+{196,'-','B','!','!',O_BF|O_UNSZ,"bf",1,{PCREL16,0},3, {{0x31,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{197,'-','B','!','!',O_BEQ|O_WORD,"beq.w",1,{PCREL16,0},3, {{0x37,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{198,'-','B','!','!',O_BEQ|O_BYTE,"beq.b",1,{PCREL8,0},2, {{0x27,0xff, },{0x00,0x00,PCREL8 }}},
+{199,'-','B','!','!',O_BEQ|O_UNSZ,"beq",1,{PCREL8,0},2, {{0x27,0xff, },{0x00,0x00,PCREL8 }}},
+{199,'-','B','!','!',O_BEQ|O_UNSZ,"beq",1,{PCREL16,0},3, {{0x37,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{200,'-','B','!','!',O_BCS|O_WORD,"bcs.w",1,{PCREL16,0},3, {{0x35,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{201,'-','B','!','!',O_BCS|O_BYTE,"bcs.b",1,{PCREL8,0},2, {{0x25,0xff, },{0x00,0x00,PCREL8 }}},
+{202,'-','B','!','!',O_BCS|O_UNSZ,"bcs",1,{PCREL8,0},2, {{0x25,0xff, },{0x00,0x00,PCREL8 }}},
+{202,'-','B','!','!',O_BCS|O_UNSZ,"bcs",1,{PCREL16,0},3, {{0x35,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x58,0xf8,RS }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x58,0xf8,RS }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x58,0xf8,RS }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x58,0xf8,RS }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x58,0xf8,RS }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x58,0xf8,RS }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x58,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x58,0xf8,RS }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x58,0xf8,RS }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x58,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x58,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x58,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x58,0xf8,RS }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x58,0xf8,RS }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x58,0xf8,RS }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x58,0xf8,RS }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x58,0xf8,RS }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x58,0xf8,RS }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{205,'b','E','S','E',O_BCLR|O_UNSZ,"bclr",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{205,'b','E','I','E',O_BCLR|O_UNSZ,"bclr",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{206,'-','B','!','!',O_BCC|O_WORD,"bcc.w",1,{PCREL16,0},3, {{0x34,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{207,'-','B','!','!',O_BCC|O_BYTE,"bcc.b",1,{PCREL8,0},2, {{0x24,0xff, },{0x00,0x00,PCREL8 }}},
+{208,'-','B','!','!',O_BCC|O_UNSZ,"bcc",1,{PCREL8,0},2, {{0x24,0xff, },{0x00,0x00,PCREL8 }}},
+{208,'-','B','!','!',O_BCC|O_UNSZ,"bcc",1,{PCREL16,0},3, {{0x34,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{209,'s','I','S','S',O_ANDC|O_WORD,"andc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x58,0xf8,CRW }}},
+{210,'s','I','S','S',O_ANDC|O_BYTE,"andc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x58,0xf8,CRB }}},
+{211,'s','I','S','S',O_ANDC|O_UNSZ,"andc",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x58,0xf8,CRB }}},
+{211,'s','I','S','S',O_ANDC|O_UNSZ,"andc",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x58,0xf8,CRW }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{214,'m','E','D','D',O_AND|O_UNSZ,"and",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{217,'a','E','D','D',O_ADDX|O_UNSZ,"addx",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{220,'-','E','D','D',O_ADDS|O_UNSZ,"adds",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RN},2, {{0xa8,0xf8,RN },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNINC},2, {{0xc8,0xf8,RN },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNDEC},2, {{0xb8,0xf8,RN },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNIND},2, {{0xd8,0xf8,RN },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RN},2, {{0xa0,0xf8,RN },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNINC},2, {{0xc0,0xf8,RN },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNDEC},2, {{0xb0,0xf8,RN },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNIND},2, {{0xd0,0xf8,RN },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,RN},2, {{0xa8,0xf8,RN },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,RNDEC},2, {{0xb8,0xf8,RN },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,RNINC},2, {{0xc8,0xf8,RN },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,RNIND},2, {{0xd8,0xf8,RN },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{223,'a','I','E','E',O_ADD|O_UNSZ,"add:q",2,{QIM,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{226,'a','E','D','D',O_ADD|O_UNSZ,"add:g",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x20,0xf8,RD }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,RN},2, {{0xa8,0xf8,RN },{0x08,0xf8,QIM }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,RNIND},2, {{0xd8,0xf8,RN },{0x08,0xf8,QIM }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x20,0xf8,RD }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,RNDEC},2, {{0xb8,0xf8,RN },{0x08,0xf8,QIM }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,RNINC},2, {{0xc8,0xf8,RN },{0x08,0xf8,QIM }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x20,0xf8,RD }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x20,0xf8,RD }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{227,'a','I','E','E',O_ADD|O_WORD,"add.w",2,{QIM,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{227,'a','E','D','D',O_ADD|O_WORD,"add.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x20,0xf8,RD }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,RN},2, {{0xa0,0xf8,RN },{0x08,0xf8,QIM }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,RNINC},2, {{0xc0,0xf8,RN },{0x08,0xf8,QIM }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x20,0xf8,RD }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,RNIND},2, {{0xd0,0xf8,RN },{0x08,0xf8,QIM }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x20,0xf8,RD }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,RNDEC},2, {{0xb0,0xf8,RN },{0x08,0xf8,QIM }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x20,0xf8,RD }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x20,0xf8,RD }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{228,'a','I','E','E',O_ADD|O_BYTE,"add.b",2,{QIM,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{228,'a','E','D','D',O_ADD|O_BYTE,"add.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x20,0xf8,RD }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,RN},2, {{0xa8,0xf8,RN },{0x08,0xf8,QIM }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,RNDEC},2, {{0xb8,0xf8,RN },{0x08,0xf8,QIM }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x20,0xf8,RD }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,RNIND},2, {{0xd8,0xf8,RN },{0x08,0xf8,QIM }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,RNINC},2, {{0xc8,0xf8,RN },{0x08,0xf8,QIM }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x20,0xf8,RD }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x20,0xf8,RD }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{229,'a','I','E','E',O_ADD|O_UNSZ,"add",2,{QIM,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{229,'a','E','D','D',O_ADD|O_UNSZ,"add",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+0,0,0}
+#endif
+;
+#endif
+#ifdef DISASSEMBLER_TABLE
+#ifdef DEFINE_TABLE
+={
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RN},2, {{0xa0,0xf8,RN },{0x98,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNDEC},2, {{0xb0,0xf8,RN },{0x98,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNINC},2, {{0xc0,0xf8,RN },{0x98,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x60,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNIND},2, {{0xd0,0xf8,RN },{0x98,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x60,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x30,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x98,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x60,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x98,0xf8,CRB }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x30,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x16,0xff, }}},
+{6,'-','X','!','!',O_XCH|O_WORD,"xch.w",2,{RS,RD},2, {{0xa8,0xf8,RS },{0x90,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x16,0xff, }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x30,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x16,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x30,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x16,0xff, }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x30,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x16,0xff, }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x16,0xff, }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x30,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x16,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x30,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x16,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x30,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x16,0xff, }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x16,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{16,'m','D','!','D',O_SWAP|O_WORD,"swap.b",1,{RD,0},2, {{0xa0,0xf8,RD },{0x10,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x17,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x30,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xb0,0xf8,RD }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x17,0xff, }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xb0,0xf8,RD }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x17,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x30,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x38,0xf8,RD }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x17,0xff, }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xb0,0xf8,RD }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x17,0xff, }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x17,0xff, }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x38,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xb0,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x38,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xb0,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x38,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x38,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xb0,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x38,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xb0,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xb0,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x38,0xf8,RD }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x38,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xb0,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x16,0xff, }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x30,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x38,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x60,0xf8,RD }}},
+{2,'s','E','C','C',O_XORC|O_BYTE,"xorc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x68,0xf8,CRB }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xb0,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x16,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x17,0xff, }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x30,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x38,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x98,0xf8,CRB }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xb0,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x16,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x17,0xff, }}},
+{12,'-','I','!','!',O_TRAPA|O_UNSZ,"trapa",1,{IMM4,0},2, {{0x08,0xff, },{0x10,0xf0,IMM4 }}},
+{13,'-','B','!','!',O_TRAP_VS|O_UNSZ,"trap/vs",0,{0,0},1, {{0x09,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{1,'s','E','C','C',O_XORC|O_WORD,"xorc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x68,0xf8,CRW }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x16,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x30,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x38,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x60,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xb0,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x16,0xff, }}},
+{8,'-','B','!','!',O_UNLK|O_UNSZ,"unlk",1,{FP,0},1, {{0x0f,0xff, }}},
+{25,'a','E','D','D',O_SUB|O_BYTE,"sub.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{22,'-','E','D','D',O_SUBS|O_BYTE,"subs.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{4,'m','E','D','D',O_XOR|O_BYTE,"xor.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{29,'s','C','!','E',O_STC|O_BYTE,"stc.b",2,{CRB,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x98,0xf8,CRB }}},
+{27,'-','I','!','E',O_STM|O_UNSZ,"stm",2,{RLIST,SPDEC},2, {{0x12,0xff, },{0x00,0x00,RLIST }}},
+{19,'a','E','D','D',O_SUBX|O_BYTE,"subx.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{10,'a','E','!','!',O_TST|O_BYTE,"tst.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x16,0xff, }}},
+{14,'s','E','!','E',O_TAS|O_BYTE,"tas.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x17,0xff, }}},
+{24,'a','E','D','D',O_SUB|O_WORD,"sub.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x30,0xf8,RD }}},
+{21,'-','E','D','D',O_SUBS|O_WORD,"subs.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x38,0xf8,RD }}},
+{3,'m','E','D','D',O_XOR|O_WORD,"xor.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x60,0xf8,RD }}},
+{18,'a','E','D','D',O_SUBX|O_WORD,"subx.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb0,0xf8,RD }}},
+{9,'a','E','!','!',O_TST|O_WORD,"tst.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x16,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1b,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1b,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1b,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1b,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x19,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1b,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x19,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1b,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1b,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1b,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1b,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1b,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1a,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1a,0xff, }}},
+{36,'h','E','!','E',O_SHLL|O_BYTE,"shll.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1a,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1b,0xff, }}},
+{35,'h','E','!','E',O_SHLL|O_WORD,"shll.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1a,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1b,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1b,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x19,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1b,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x19,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x19,0xff, }}},
+{33,'h','E','!','E',O_SHLR|O_BYTE,"shlr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1b,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1b,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1b,0xff, }}},
+{39,'h','E','!','E',O_SHAR|O_BYTE,"shar.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x19,0xff, }}},
+{31,'-','!','!','!',O_SLEEP|O_UNSZ,"sleep",0,{0,0},1, {{0x1a,0xff, }}},
+{38,'h','E','!','E',O_SHAR|O_WORD,"shar.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x19,0xff, }}},
+{32,'h','E','!','E',O_SHLR|O_WORD,"shlr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1b,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x18,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1e,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x18,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x18,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x18,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1e,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x18,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1e,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x18,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1e,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x18,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1e,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x18,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1f,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1e,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1f,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1e,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1f,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1e,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1f,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1e,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1f,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1e,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1f,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1e,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1f,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1e,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1f,0xff, }}},
+{45,'-','B','S','S',O_SCB_F|O_UNSZ,"scb/f",2,{RS,PCREL8},3, {{0x01,0xff, },{0xb8,0xf8,RS },{0x00,0x00,PCREL8 }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1e,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1f,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1f,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1f,0xff, }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x18,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1e,0xff, }}},
+{44,'-','B','S','S',O_SCB_NE|O_UNSZ,"scb/ne",2,{RS,PCREL8},3, {{0x06,0xff, },{0xb8,0xf8,RS },{0x00,0x00,PCREL8 }}},
+{46,'-','B','S','S',O_SCB_EQ|O_UNSZ,"scb/eq",2,{RS,PCREL8},3, {{0x07,0xff, },{0xb8,0xf8,RS },{0x00,0x00,PCREL8 }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x18,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1e,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x18,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1e,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1f,0xff, }}},
+{48,'-','B','!','!',O_RTD|O_UNSZ,"rtd",1,{IMM16,0},3, {{0x14,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{48,'-','B','!','!',O_RTD|O_UNSZ,"rtd",1,{IMM8,0},2, {{0x14,0xff, },{0x00,0x00,IMM8 }}},
+{42,'h','E','!','E',O_SHAL|O_BYTE,"shal.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x18,0xff, }}},
+{53,'h','E','!','E',O_ROTXL|O_BYTE,"rotxl.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1e,0xff, }}},
+{50,'h','E','!','E',O_ROTXR|O_BYTE,"rotxr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1f,0xff, }}},
+{47,'-','B','!','!',O_RTS|O_UNSZ,"rts",0,{0,0},1, {{0x19,0xff, }}},
+{41,'h','E','!','E',O_SHAL|O_WORD,"shal.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x18,0xff, }}},
+{52,'h','E','!','E',O_ROTXL|O_WORD,"rotxl.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1e,0xff, }}},
+{49,'h','E','!','E',O_ROTXR|O_WORD,"rotxr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1f,0xff, }}},
+{99,'m','I','!','D',O_MOV|O_BYTE,"mov:e.b",2,{IMM8,RD},2, {{0x50,0xf8,RD },{0x00,0x00,IMM8 }}},
+{97,'m','E','!','D',O_MOV|O_BYTE,"mov:f.b",2,{FPIND_D8,RD},2, {{0x80,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{96,'m','E','!','D',O_MOV|O_WORD,"mov:f.w",2,{FPIND_D8,RD},2, {{0x88,0xf8,RD },{0x00,0x00,FPIND_D8 }}},
+{97,'m','S','!','E',O_MOV|O_BYTE,"mov:f.b",2,{RS,FPIND_D8},2, {{0x90,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{96,'m','S','!','E',O_MOV|O_WORD,"mov:f.w",2,{RS,FPIND_D8},2, {{0x98,0xf8,RS },{0x00,0x00,FPIND_D8 }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x80,0xf8,RD }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1d,0xff, }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x90,0xf8,RS }}},
+{91,'m','I','!','D',O_MOV|O_WORD,"mov:i.w",2,{IMM16,RD},3, {{0x58,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{89,'m','E','!','D',O_MOV|O_BYTE,"mov:l.b",2,{ABS8,RD},2, {{0x60,0xf8,RD },{0x00,0x00,ABS8 }}},
+{88,'m','E','!','D',O_MOV|O_WORD,"mov:l.w",2,{ABS8,RD},2, {{0x68,0xf8,RD },{0x00,0x00,ABS8 }}},
+{86,'m','S','!','E',O_MOV|O_BYTE,"mov:s.b",2,{RS,ABS8},2, {{0x70,0xf8,RS },{0x00,0x00,ABS8 }}},
+{85,'m','S','!','E',O_MOV|O_WORD,"mov:s.w",2,{RS,ABS8},2, {{0x78,0xf8,RS },{0x00,0x00,ABS8 }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RN,RD},3, {{0xa0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1d,0xff, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNDEC,RD},3, {{0xb0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xa8,0xf8,RD }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RN},3, {{0xa0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x1c,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x40,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xa8,0xf8,RD }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x15,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x1c,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x40,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xa8,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x15,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x40,0xf8,RD }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNDEC},3, {{0xb0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1c,0xff, }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x14,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x40,0xf8,RD }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1c,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x15,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x40,0xf8,RD }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x15,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1d,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x15,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x40,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x15,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1d,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x40,0xf8,RD }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x15,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1c,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x40,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x15,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1d,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x40,0xf8,RD }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x15,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1c,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x40,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x15,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1d,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x15,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1c,0xff, }}},
+{63,'-','J','!','!',O_PJSR|O_UNSZ,"pjsr",1,{ABS24,0},4, {{0x03,0xff, },{0x00,0x00,ABS24 },{0x00,0x00, },{0x00,0x00, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x40,0xf8,RD }}},
+{66,'s','I','C','C',O_ORC|O_BYTE,"orc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x48,0xf8,CRB }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x14,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1c,0xff, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x40,0xf8,RD }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x15,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1c,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x15,0xff, }}},
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x14,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x15,0xff, }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{74,'-','!','!','!',O_NOP|O_UNSZ,"nop",0,{0,0},1, {{0x00,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1c,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{65,'s','I','C','C',O_ORC|O_WORD,"orc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x48,0xf8,CRW }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x15,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1c,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x40,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x14,0xff, }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x15,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1d,0xff, }}},
+{64,'-','J','!','!',O_PJMP|O_UNSZ,"pjmp",1,{RDIND,0},2, {{0x11,0xff, },{0xc0,0xf8,RDIND }}},
+{63,'-','J','!','!',O_PJSR|O_UNSZ,"pjsr",1,{RDIND,0},2, {{0x11,0xff, },{0xc8,0xf8,RDIND }}},
+{62,'-','B','!','!',O_PRTD|O_UNSZ,"prtd",1,{IMM8,0},3, {{0x11,0xff, },{0x14,0xff, },{0x00,0x00,IMM8 }}},
+{61,'-','B','!','!',O_PRTS|O_UNSZ,"prts",0,{0,0},2, {{0x11,0xff, },{0x19,0xff, }}},
+{62,'-','B','!','!',O_PRTD|O_UNSZ,"prtd",1,{IMM16,0},4, {{0x11,0xff, },{0x1c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{64,'-','J','!','!',O_PJMP|O_UNSZ,"pjmp",1,{ABS24,0},4, {{0x13,0xff, },{0x00,0x00,ABS24 },{0x00,0x00, },{0x00,0x00, }}},
+{69,'m','E','D','D',O_OR|O_BYTE,"or.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xa8,0xf8,RD }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x1c,0xff, }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xa8,0xf8,RD }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x1c,0xff, }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xa8,0xf8,RD }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xa8,0xf8,RD }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x1c,0xff, }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{79,'p','E','D','D',O_MULXU|O_BYTE,"mulxu.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNINC},3, {{0xc0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x1c,0xff, }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNIND},3, {{0xd0,0xf8,RN },{0x00,0xff, },{0x90,0xf8,RS }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x1c,0xff, }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x00,0xff, },{0x90,0xf8,RS }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x00,0xff, },{0x90,0xf8,RS }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x00,0xff, },{0x90,0xf8,RS }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNIND,RD},3, {{0xd0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNINC,RD},3, {{0xc0,0xf8,RN },{0x00,0xff, },{0x80,0xf8,RD }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1d,0xff, }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNIND_D8,RD},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{RNIND_D16,RD},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{IMM8,RD},4, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{ABS8,RD},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x00,0xff, },{0x80,0xf8,RD }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x1d,0xff, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x80,0xf8,RD }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x80,0xf8,RD }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x1d,0xff, }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x90,0xf8,RS }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x90,0xf8,RS }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x90,0xf8,RS }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x1d,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x1d,0xff, }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNDEC},3, {{0xb0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,RNDEC},4, {{0xb8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x90,0xf8,RS }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNINC},3, {{0xc0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,RNINC},4, {{0xc8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x90,0xf8,RS }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RNIND},3, {{0xd0,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,RNIND},4, {{0xd8,0xf8,RN },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x90,0xf8,RS }}},
+
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x1d,0xff, }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x80,0xf8,RD }}},
+{94,'m','E','!','D',O_MOV|O_BYTE,"mov:g.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{94,'m','S','!','E',O_MOV|O_BYTE,"mov:g.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x90,0xf8,RS }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x1d,0xff, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x80,0xf8,RD }}},
+{83,'-','E','!','D',O_MOVFPE|O_BYTE,"movfpe.b",2,{ABS16,RD},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x00,0xff, },{0x80,0xf8,RD }}},
+{81,'-','S','!','E',O_MOVTPE|O_BYTE,"movtpe.b",2,{RS,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x00,0xff, },{0x90,0xf8,RS }}},
+{94,'m','I','!','E',O_MOV|O_BYTE,"mov:g.b",2,{IMM8,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x07,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+
+{93,'m','I','!','E',O_MOV|O_WORD,"mov:g.w",2,{IMM8,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x06,0xff, },{0x00,0x00,IMM8 },{0x00,0x00, }}},
+
+{76,'a','E','!','E',O_NEG|O_BYTE,"neg.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x14,0xff, }}},
+{56,'h','E','!','E',O_ROTR|O_BYTE,"rotr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1d,0xff, }}},
+{93,'m','E','!','D',O_MOV|O_WORD,"mov:g.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x80,0xf8,RD }}},
+{93,'m','S','!','E',O_MOV|O_WORD,"mov:g.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x90,0xf8,RS }}},
+{78,'p','E','D','D',O_MULXU|O_WORD,"mulxu.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa8,0xf8,RD }}},
+{75,'a','E','!','E',O_NEG|O_WORD,"neg.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x14,0xff, }}},
+{55,'h','E','!','E',O_ROTR|O_WORD,"rotr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1d,0xff, }}},
+{72,'m','E','!','E',O_NOT|O_BYTE,"not.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x15,0xff, }}},
+{68,'m','E','D','D',O_OR|O_WORD,"or.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x40,0xf8,RD }}},
+{71,'m','E','!','E',O_NOT|O_WORD,"not.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x15,0xff, }}},
+{58,'h','E','!','E',O_ROTL|O_WORD,"rotl.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1c,0xff, }}},
+{59,'h','E','!','E',O_ROTL|O_BYTE,"rotl.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x1c,0xff, }}},
+{125,'a','D','I','!',O_CMP|O_BYTE,"cmp:e.b",2,{IMM8,RD},2, {{0x40,0xf8,RD },{0x00,0x00,IMM8 }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RN},3, {{0xa0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x70,0xf8,RD }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RN},4, {{0xa8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RN,CRB},2, {{0xa0,0xf8,RN },{0x88,0xf8,CRB }}},
+{120,'a','D','I','!',O_CMP|O_WORD,"cmp:i.w",2,{IMM16,RD},3, {{0x48,0xf8,RD },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xb8,0xf8,RD }}},
+{119,'s','D','!','!',O_DADD|O_UNSZ,"dadd",2,{RS,RD},3, {{0xa0,0xf8,RS },{0x00,0xff, },{0xa0,0xf8,RD }}},
+{115,'s','D','!','!',O_DSUB|O_UNSZ,"dsub",2,{RS,RD},3, {{0xa0,0xf8,RS },{0x00,0xff, },{0xb0,0xf8,RD }}},
+{113,'s','D','!','D',O_EXTS|O_BYTE,"exts.b",1,{RD,0},2, {{0xa0,0xf8,RD },{0x11,0xff, }}},
+{111,'s','D','!','D',O_EXTU|O_BYTE,"extu.b",1,{RD,0},2, {{0xa0,0xf8,RD },{0x12,0xff, }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xb8,0xf8,RD }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNIND_D8,CRB},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x88,0xf8,CRB }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNIND_D16,CRB},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x88,0xf8,CRB }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{ABS16,0},3, {{0x10,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{RDIND,0},2, {{0x11,0xff, },{0xd0,0xf8,RD }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{RDIND,0},2, {{0x11,0xff, },{0xd8,0xf8,RD }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{RDIND_D8,0},3, {{0x11,0xff, },{0xe0,0xf8,RDIND_D8 },{0x00,0x00, }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{RDIND_D8,0},3, {{0x11,0xff, },{0xe8,0xf8,RDIND_D8 },{0x00,0x00, }}},
+{110,'-','B','!','!',O_JMP|O_UNSZ,"jmp",1,{RDIND_D16,0},4, {{0x11,0xff, },{0xf0,0xf8,RDIND_D16 },{0x00,0x00, },{0x00,0x00, }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{RDIND_D16,0},4, {{0x11,0xff, },{0xf8,0xf8,RDIND_D16 },{0x00,0x00, },{0x00,0x00, }}},
+{109,'-','B','!','!',O_JSR|O_UNSZ,"jsr",1,{ABS16,0},3, {{0x18,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{ABS16,CRB},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x88,0xf8,CRB }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xb8,0xf8,RD }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNINC,CRB},2, {{0xc0,0xf8,RN },{0x88,0xf8,CRB }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xb8,0xf8,RD }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNIND,CRB},2, {{0xd0,0xf8,RN },{0x88,0xf8,CRB }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x88,0xf8,CRB }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{117,'s','E','D','D',O_DIVXU|O_BYTE,"divxu.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xb8,0xf8,RD }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{ABS8,CRB},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x88,0xf8,CRB }}},
+{116,'s','E','D','D',O_DIVXU|O_WORD,"divxu.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xb8,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x70,0xf8,RD }}},
+{107,'s','E','!','C',O_LDC|O_BYTE,"ldc.b",2,{RNDEC,CRB},2, {{0xb0,0xf8,RN },{0x88,0xf8,CRB }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNDEC},3, {{0xb0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNDEC},4, {{0xb8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNINC},3, {{0xc0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNINC},4, {{0xc8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNIND},3, {{0xd0,0xf8,RN },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNIND},4, {{0xd8,0xf8,RN },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNIND_D8},4, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNIND_D8},5, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RNIND_D16},5, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RNIND_D16},6, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{105,'-','E','!','C',O_LDM|O_UNSZ,"ldm",2,{SPINC,RLIST},2, {{0x02,0xff, },{0x00,0x00,RLIST }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,ABS8},4, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,ABS8},5, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{106,'s','E','!','C',O_LDC|O_WORD,"ldc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x88,0xf8,CRW }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x70,0xf8,RD }}},
+{123,'a','D','E','!',O_CMP|O_BYTE,"cmp:g.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{123,'a','E','I','!',O_CMP|O_BYTE,"cmp:g.b",2,{IMM8,ABS16},5, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x04,0xff, },{0x00,0x00,IMM8 }}},
+{122,'a','E','I','!',O_CMP|O_WORD,"cmp:g.w",2,{IMM16,ABS16},6, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x05,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{122,'a','D','E','!',O_CMP|O_WORD,"cmp:g.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x70,0xf8,RD }}},
+{104,'-','S','I','!',O_LINK|O_UNSZ,"link",2,{FP,IMM16},3, {{0x1f,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, }}},
+{104,'-','S','I','!',O_LINK|O_UNSZ,"link",2,{FP,IMM8},2, {{0x17,0xff, },{0x00,0x00,IMM8 }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x48,0xf8,RS }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x78,0xf8,RS }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RN,0},2, {{0xa0,0xf8,RN },{0x13,0xff, }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNDEC,0},2, {{0xb0,0xf8,RN },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNINC,0},2, {{0xc0,0xf8,RN },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNIND,0},2, {{0xd0,0xf8,RN },{0x13,0xff, }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x78,0xf8,RS }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNIND_D8,0},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x13,0xff, }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{RNIND_D16,0},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x13,0xff, }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNIND_D16,0},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{IMM8,0},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x13,0xff, }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{ABS8,0},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x13,0xff, }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x78,0xf8,RS }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x78,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNDEC,0},2, {{0xb8,0xf8,RN },{0x13,0xff, }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x78,0xf8,RS }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x78,0xf8,RS }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x78,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNIND_D8,0},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x13,0xff, }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{IMM16,0},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x13,0xff, }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x78,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{ABS8,0},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x13,0xff, }}},
+{140,'b','E','I','E',O_BTST|O_BYTE,"btst.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{140,'b','E','S','E',O_BTST|O_BYTE,"btst.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{131,'c','!','!','E',O_CLR|O_BYTE,"clr.b",1,{ABS16,0},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x13,0xff, }}},
+{139,'b','E','I','E',O_BTST|O_WORD,"btst.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xf0,0xf0,IMM4 }}},
+{139,'b','E','S','E',O_BTST|O_WORD,"btst.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x78,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{ABS16,0},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x13,0xff, }}},
+{137,'-','B','!','!',O_BVC|O_BYTE,"bvc.b",1,{PCREL8,0},2, {{0x28,0xff, },{0x00,0x00,PCREL8 }}},
+{134,'-','B','!','!',O_BVS|O_BYTE,"bvs.b",1,{PCREL8,0},2, {{0x29,0xff, },{0x00,0x00,PCREL8 }}},
+{136,'-','B','!','!',O_BVC|O_WORD,"bvc.w",1,{PCREL16,0},3, {{0x38,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{133,'-','B','!','!',O_BVS|O_WORD,"bvs.w",1,{PCREL16,0},3, {{0x39,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x48,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RN,0},2, {{0xa8,0xf8,RN },{0x13,0xff, }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x48,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNINC,0},2, {{0xc8,0xf8,RN },{0x13,0xff, }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x48,0xf8,RS }}},
+{130,'c','!','!','E',O_CLR|O_WORD,"clr.w",1,{RNIND,0},2, {{0xd8,0xf8,RN },{0x13,0xff, }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x48,0xf8,RS }}},
+{146,'-','B','!','!',O_BSR|O_BYTE,"bsr.b",1,{PCREL8,0},2, {{0x0e,0xff, },{0x00,0x00,PCREL8 }}},
+{149,'b','E','I','E',O_BSET|O_BYTE,"bset.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{149,'b','E','S','E',O_BSET|O_BYTE,"bset.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{148,'b','E','I','E',O_BSET|O_WORD,"bset.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xc0,0xf0,IMM4 }}},
+{148,'b','E','S','E',O_BSET|O_WORD,"bset.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x48,0xf8,RS }}},
+{145,'-','B','!','!',O_BSR|O_WORD,"bsr.w",1,{PCREL16,0},3, {{0x1e,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RN},2, {{0xa0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RN},2, {{0xa0,0xf8,RN },{0x08,0xf8,QIM }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x28,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x20,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0x50,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x58,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RN},2, {{0xa0,0xf8,RN },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RN,RD},2, {{0xa0,0xf8,RN },{0xa0,0xf8,RD }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RN},2, {{0xa8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RN},2, {{0xa8,0xf8,RN },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x58,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RN},2, {{0xa8,0xf8,RN },{0x68,0xf8,RS }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RN,RD},2, {{0xa8,0xf8,RN },{0xa0,0xf8,RD }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNDEC},2, {{0xb0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNDEC},2, {{0xb0,0xf8,RN },{0x08,0xf8,QIM }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x20,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0x50,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x58,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNDEC},2, {{0xb0,0xf8,RN },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNDEC,RD},2, {{0xb0,0xf8,RN },{0xa0,0xf8,RD }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNDEC},2, {{0xb8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNDEC},2, {{0xb8,0xf8,RN },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x58,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNDEC},2, {{0xb8,0xf8,RN },{0x68,0xf8,RS }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNDEC,RD},2, {{0xb8,0xf8,RN },{0xa0,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x20,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x50,0xf8,RD }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNINC},2, {{0xc0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0x28,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x58,0xf8,RS }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNINC},2, {{0xc0,0xf8,RN },{0x08,0xf8,QIM }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNINC},2, {{0xc0,0xf8,RN },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNINC,RD},2, {{0xc0,0xf8,RN },{0xa0,0xf8,RD }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNINC},2, {{0xc8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0xa0,0xf8,RD }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x68,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNIND},2, {{0xd0,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x28,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNINC},2, {{0xc8,0xf8,RN },{0x58,0xf8,RS }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNINC,RD},2, {{0xc8,0xf8,RN },{0x50,0xf8,RD }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNINC},2, {{0xc8,0xf8,RN },{0x08,0xf8,QIM }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNIND},2, {{0xd0,0xf8,RN },{0x08,0xf8,QIM }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x20,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0x50,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x58,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNIND},2, {{0xd0,0xf8,RN },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNIND,RD},2, {{0xd0,0xf8,RN },{0xa0,0xf8,RD }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xd0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNIND},2, {{0xd8,0xf8,RN },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNIND},2, {{0xd8,0xf8,RN },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x58,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNIND},2, {{0xd8,0xf8,RN },{0x68,0xf8,RS }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNIND,RD},2, {{0xd8,0xf8,RN },{0xa0,0xf8,RD }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xd0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xe0,0xf0,IMM4 }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x50,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x58,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNIND_D8},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNIND_D8,RD},3, {{0xe0,0xf8,RN },{0x00,0x00,DISP8 },{0xa0,0xf8,RD }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xd0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x58,0xf8,RS }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNIND_D8},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNIND_D8,RD},3, {{0xe8,0xf8,RN },{0x00,0x00,DISP8 },{0xa0,0xf8,RD }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{RNIND_D16,RD},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,RNIND_D16},4, {{0xf0,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,RNIND_D16},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{RNIND_D16,RD},4, {{0xf8,0xf8,RN },{0x00,0x00,DISP16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x20,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x50,0xf8,RD }}},
+{210,'s','I','S','S',O_ANDC|O_BYTE,"andc.b",2,{IMM8,CRB},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0x58,0xf8,CRB }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{IMM8,RD},3, {{0x04,0xff, },{0x00,0x00,IMM8 },{0xa0,0xf8,RD }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xd0,0xf0,IMM4 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xe0,0xf0,IMM4 }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x50,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x58,0xf8,RS }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,ABS8},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0x68,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{ABS8,RD},3, {{0x05,0xff, },{0x00,0x00,ABS8 },{0xa0,0xf8,RD }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{209,'s','I','S','S',O_ANDC|O_WORD,"andc.w",2,{IMM16,CRW},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0x58,0xf8,CRW }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{IMM16,RD},4, {{0x0c,0xff, },{0x00,0x00,IMM16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x20,0xf8,RD }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x28,0xf8,RD }}},
+{157,'-','!','!','!',O_BPT|O_UNSZ,"bpt",0,{0,0},1, {{0x0b,0xff, }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xd0,0xf0,IMM4 }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x58,0xf8,RS }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,ABS8},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0x68,0xf8,RS }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{ABS8,RD},3, {{0x0d,0xff, },{0x00,0x00,ABS8 },{0xa0,0xf8,RD }}},
+{204,'b','E','I','E',O_BCLR|O_BYTE,"bclr.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{225,'a','E','D','D',O_ADD|O_BYTE,"add:g.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{219,'-','E','D','D',O_ADDS|O_BYTE,"adds.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{213,'m','E','D','D',O_AND|O_BYTE,"and.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{204,'b','E','S','E',O_BCLR|O_BYTE,"bclr.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{216,'a','E','D','D',O_ADDX|O_BYTE,"addx.b",2,{ABS16,RD},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{203,'b','E','I','E',O_BCLR|O_WORD,"bclr.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xd0,0xf0,IMM4 }}},
+{218,'-','E','D','D',O_ADDS|O_WORD,"adds.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x28,0xf8,RD }}},
+{212,'m','E','D','D',O_AND|O_WORD,"and.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x50,0xf8,RD }}},
+{203,'b','E','S','E',O_BCLR|O_WORD,"bclr.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x58,0xf8,RS }}},
+{215,'a','E','D','D',O_ADDX|O_WORD,"addx.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xa0,0xf8,RD }}},
+{155,'-','B','!','!',O_BRA|O_BYTE,"bra.b",1,{PCREL8,0},2, {{0x20,0xff, },{0x00,0x00,PCREL8 }}},
+{162,'b','E','I','E',O_BNOT|O_BYTE,"bnot.b",2,{IMM4,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{222,'a','I','E','E',O_ADD|O_BYTE,"add:q.b",2,{QIM,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{162,'b','E','S','E',O_BNOT|O_BYTE,"bnot.b",2,{RS,ABS16},4, {{0x15,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{161,'b','E','I','E',O_BNOT|O_WORD,"bnot.w",2,{IMM4,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0xe0,0xf0,IMM4 }}},
+{221,'a','I','E','E',O_ADD|O_WORD,"add:q.w",2,{QIM,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x08,0xf8,QIM }}},
+{224,'a','E','D','D',O_ADD|O_WORD,"add:g.w",2,{ABS16,RD},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x20,0xf8,RD }}},
+{161,'b','E','S','E',O_BNOT|O_WORD,"bnot.w",2,{RS,ABS16},4, {{0x1d,0xff, },{0x00,0x00,ABS16 },{0x00,0x00, },{0x68,0xf8,RS }}},
+{152,'-','B','!','!',O_BRN|O_BYTE,"brn.b",1,{PCREL8,0},2, {{0x21,0xff, },{0x00,0x00,PCREL8 }}},
+{186,'-','B','!','!',O_BHI|O_BYTE,"bhi.b",1,{PCREL8,0},2, {{0x22,0xff, },{0x00,0x00,PCREL8 }}},
+{174,'-','B','!','!',O_BLS|O_BYTE,"bls.b",1,{PCREL8,0},2, {{0x23,0xff, },{0x00,0x00,PCREL8 }}},
+{207,'-','B','!','!',O_BCC|O_BYTE,"bcc.b",1,{PCREL8,0},2, {{0x24,0xff, },{0x00,0x00,PCREL8 }}},
+{201,'-','B','!','!',O_BCS|O_BYTE,"bcs.b",1,{PCREL8,0},2, {{0x25,0xff, },{0x00,0x00,PCREL8 }}},
+{165,'-','B','!','!',O_BNE|O_BYTE,"bne.b",1,{PCREL8,0},2, {{0x26,0xff, },{0x00,0x00,PCREL8 }}},
+{198,'-','B','!','!',O_BEQ|O_BYTE,"beq.b",1,{PCREL8,0},2, {{0x27,0xff, },{0x00,0x00,PCREL8 }}},
+{159,'-','B','!','!',O_BPL|O_BYTE,"bpl.b",1,{PCREL8,0},2, {{0x2a,0xff, },{0x00,0x00,PCREL8 }}},
+{168,'-','B','!','!',O_BMI|O_BYTE,"bmi.b",1,{PCREL8,0},2, {{0x2b,0xff, },{0x00,0x00,PCREL8 }}},
+{192,'-','B','!','!',O_BGE|O_BYTE,"bge.b",1,{PCREL8,0},2, {{0x2c,0xff, },{0x00,0x00,PCREL8 }}},
+{171,'-','B','!','!',O_BLT|O_BYTE,"blt.b",1,{PCREL8,0},2, {{0x2d,0xff, },{0x00,0x00,PCREL8 }}},
+{189,'-','B','!','!',O_BGT|O_BYTE,"bgt.b",1,{PCREL8,0},2, {{0x2e,0xff, },{0x00,0x00,PCREL8 }}},
+{180,'-','B','!','!',O_BLE|O_BYTE,"ble.b",1,{PCREL8,0},2, {{0x2f,0xff, },{0x00,0x00,PCREL8 }}},
+{154,'-','B','!','!',O_BRA|O_WORD,"bra.w",1,{PCREL16,0},3, {{0x30,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{151,'-','B','!','!',O_BRN|O_WORD,"brn.w",1,{PCREL16,0},3, {{0x31,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{185,'-','B','!','!',O_BHI|O_WORD,"bhi.w",1,{PCREL16,0},3, {{0x32,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{173,'-','B','!','!',O_BLS|O_WORD,"bls.w",1,{PCREL16,0},3, {{0x33,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{206,'-','B','!','!',O_BCC|O_WORD,"bcc.w",1,{PCREL16,0},3, {{0x34,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{200,'-','B','!','!',O_BCS|O_WORD,"bcs.w",1,{PCREL16,0},3, {{0x35,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{164,'-','B','!','!',O_BNE|O_WORD,"bne.w",1,{PCREL16,0},3, {{0x36,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{197,'-','B','!','!',O_BEQ|O_WORD,"beq.w",1,{PCREL16,0},3, {{0x37,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{158,'-','B','!','!',O_BPL|O_WORD,"bpl.w",1,{PCREL16,0},3, {{0x3a,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{167,'-','B','!','!',O_BMI|O_WORD,"bmi.w",1,{PCREL16,0},3, {{0x3b,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{191,'-','B','!','!',O_BGE|O_WORD,"bge.w",1,{PCREL16,0},3, {{0x3c,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{170,'-','B','!','!',O_BLT|O_WORD,"blt.w",1,{PCREL16,0},3, {{0x3d,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{188,'-','B','!','!',O_BGT|O_WORD,"bgt.w",1,{PCREL16,0},3, {{0x3e,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+{179,'-','B','!','!',O_BLE|O_WORD,"ble.w",1,{PCREL16,0},3, {{0x3f,0xff, },{0x00,0x00,PCREL16 },{0x00,0x00, }}},
+/*
+RN,RD 'm','E','D','D'
+CRB,RN 's','C','!','E'
+RN,RD 'm','E','D','D'
+RNDEC,RD 'm','E','D','D'
+CRB,RNDEC 's','C','!','E'
+RNDEC,RD 'm','E','D','D'
+RNINC,RD 'm','E','D','D'
+CRB,RNINC 's','C','!','E'
+RNINC,RD 'm','E','D','D'
+RNIND,RD 'm','E','D','D'
+CRB,RNIND 's','C','!','E'
+RNIND,RD 'm','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+RNIND_D8,RD 'm','E','D','D'
+CRB,RNIND_D8 's','C','!','E'
+RNIND_D8,RD 'm','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+CRB,RNIND_D16 's','C','!','E'
+RNIND_D16,RD 'm','E','D','D'
+RN,RD 'm','E','D','D'
+RNDEC,RD 'm','E','D','D'
+RNIND,RD 'm','E','D','D'
+RNINC,RD 'm','E','D','D'
+RNIND_D8,RD 'm','E','D','D'
+ABS8,RD 'm','E','D','D'
+IMM16,RD 'm','E','D','D'
+ABS16,RD 'm','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+RN,RD 'a','E','D','D'
+RS,RD '-','X','!','!'
+RN,0 'a','E','!','!'
+RS,RD '-','X','!','!'
+RN,0 'a','E','!','!'
+RNDEC,RD 'a','E','D','D'
+RNDEC,0 'a','E','!','!'
+RNDEC,RD 'a','E','D','D'
+RNDEC,0 'a','E','!','!'
+RNINC,RD 'a','E','D','D'
+RNINC,0 'a','E','!','!'
+RNINC,0 'a','E','!','!'
+RNIND,RD 'a','E','D','D'
+RNIND,0 'a','E','!','!'
+RNIND,RD 'a','E','D','D'
+RNIND,0 'a','E','!','!'
+RNIND_D8,0 'a','E','!','!'
+RNIND_D8,RD 'a','E','D','D'
+RNIND_D8,0 'a','E','!','!'
+RNIND_D16,0 'a','E','!','!'
+RNIND_D16,RD 'a','E','D','D'
+RN,0 'a','E','!','!'
+RNIND,0 'a','E','!','!'
+RNDEC,0 'a','E','!','!'
+RNINC,0 'a','E','!','!'
+ABS8,0 'a','E','!','!'
+RNIND_D8,0 'a','E','!','!'
+RD,0 'm','D','!','D'
+ABS16,0 'a','E','!','!'
+RNIND_D16,0 'a','E','!','!'
+RN,0 's','E','!','E'
+RN,RD 'a','E','D','D'
+RN,RD 'a','E','D','D'
+RNDEC,0 's','E','!','E'
+RNDEC,RD 'a','E','D','D'
+RNINC,0 's','E','!','E'
+RNINC,RD 'a','E','D','D'
+RNIND,RD '-','E','D','D'
+RNIND,0 's','E','!','E'
+RNIND,RD 'a','E','D','D'
+RNIND_D8,0 's','E','!','E'
+RN,0 's','E','!','E'
+RNIND,0 's','E','!','E'
+RNINC,0 's','E','!','E'
+RNDEC,0 's','E','!','E'
+IMM8,0 's','E','!','E'
+ABS8,0 's','E','!','E'
+RNIND_D8,0 's','E','!','E'
+ABS16,0 's','E','!','E'
+RNIND_D16,0 's','E','!','E'
+RNIND_D8,RD '-','E','D','D'
+RD,0 'm','D','!','D'
+RNIND_D16,RD '-','E','D','D'
+RNIND_D16,0 's','E','!','E'
+IMM16,0 'a','E','!','!'
+RN,RD '-','E','D','D'
+RN,RD 'a','E','D','D'
+RN,RD '-','E','D','D'
+RNDEC,RD '-','E','D','D'
+RNDEC,RD 'a','E','D','D'
+RNDEC,RD '-','E','D','D'
+RNINC,RD '-','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNINC,RD '-','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNIND,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+RNIND_D8,RD '-','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RNIND_D16,RD '-','E','D','D'
+RN,RD 'a','E','D','D'
+RNDEC,RD 'a','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNIND,RD 'a','E','D','D'
+ABS8,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+IMM16,RD 'a','E','D','D'
+ABS16,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RNIND,RD '-','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RNIND_D16,0 'a','E','!','!'
+IMM8,RD 'a','E','D','D'
+IMM8,RD '-','E','D','D'
+IMM8,RD 'm','E','D','D'
+IMM8,CRB 's','E','C','C'
+IMM8,RD 'a','E','D','D'
+IMM8,0 'a','E','!','!'
+IMM8,0 's','E','!','E'
+ABS8,RD 'a','E','D','D'
+ABS8,RD '-','E','D','D'
+ABS8,RD 'm','E','D','D'
+CRB,ABS8 's','C','!','E'
+ABS8,RD 'a','E','D','D'
+ABS8,0 'a','E','!','!'
+ABS8,0 's','E','!','E'
+RN,RD '-','E','D','D'
+RNDEC,RD '-','E','D','D'
+RNIND,RD '-','E','D','D'
+RNINC,RD '-','E','D','D'
+ABS8,RD '-','E','D','D'
+RNIND_D8,RD '-','E','D','D'
+ABS16,RD '-','E','D','D'
+IMM16,RD '-','E','D','D'
+RNIND_D16,RD '-','E','D','D'
+IMM4,0 '-','I','!','!'
+0,0 '-','B','!','!'
+IMM16,RD 'a','E','D','D'
+IMM16,RD '-','E','D','D'
+IMM16,RD 'm','E','D','D'
+IMM16,CRW 's','E','C','C'
+IMM16,RD 'a','E','D','D'
+IMM16,0 'a','E','!','!'
+ABS8,RD 'a','E','D','D'
+ABS8,RD '-','E','D','D'
+ABS8,RD 'm','E','D','D'
+ABS8,RD 'a','E','D','D'
+ABS8,0 'a','E','!','!'
+FP,0 '-','B','!','!'
+ABS16,RD 'a','E','D','D'
+ABS16,RD '-','E','D','D'
+ABS16,RD 'm','E','D','D'
+CRB,ABS16 's','C','!','E'
+RN,RD 'a','E','D','D'
+RNIND,RD 'a','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNDEC,RD 'a','E','D','D'
+ABS8,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+IMM16,RD 'a','E','D','D'
+ABS16,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RLIST,SPDEC '-','I','!','E'
+CRW,RN 's','C','!','E'
+CRW,RNDEC 's','C','!','E'
+CRW,RNINC 's','C','!','E'
+CRW,RNIND 's','C','!','E'
+CRW,ABS8 's','C','!','E'
+CRW,RNIND_D8 's','C','!','E'
+CRW,ABS16 's','C','!','E'
+CRW,RNIND_D16 's','C','!','E'
+ABS16,RD 'a','E','D','D'
+ABS16,0 'a','E','!','!'
+ABS16,0 's','E','!','E'
+ABS16,RD 'a','E','D','D'
+ABS16,RD '-','E','D','D'
+ABS16,RD 'm','E','D','D'
+ABS16,RD 'a','E','D','D'
+ABS16,0 'a','E','!','!'
+CRW,RN 's','C','!','E'
+RNIND,0 'h','E','!','E'
+CRB,RNDEC 's','C','!','E'
+CRW,RNIND 's','C','!','E'
+CRW,RNINC 's','C','!','E'
+CRW,RNDEC 's','C','!','E'
+CRB,RNIND 's','C','!','E'
+CRB,RNINC 's','C','!','E'
+CRW,RNIND_D8 's','C','!','E'
+CRB,ABS8 's','C','!','E'
+CRB,RNIND_D8 's','C','!','E'
+CRW,ABS8 's','C','!','E'
+CRW,RNIND_D16 's','C','!','E'
+RNIND,0 'h','E','!','E'
+CRB,ABS16 's','C','!','E'
+CRB,RNIND_D16 's','C','!','E'
+RN,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+CRW,ABS16 's','C','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+CRB,RN 's','C','!','E'
+RN,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+IMM8,0 'h','E','!','E'
+IMM8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+IMM8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+0,0 '-','!','!','!'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+IMM8,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RS,PCREL8 '-','B','S','S'
+IMM8,0 'h','E','!','E'
+IMM8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RS,PCREL8 '-','B','S','S'
+RS,PCREL8 '-','B','S','S'
+IMM16,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+IMM16,0 '-','B','!','!'
+IMM8,0 '-','B','!','!'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+0,0 '-','B','!','!'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+IMM8,RD 'm','I','!','D'
+ABS16,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+FPIND_D8,RD 'm','E','!','D'
+FPIND_D8,RD 'm','E','!','D'
+RS,FPIND_D8 'm','S','!','E'
+RS,FPIND_D8 'm','S','!','E'
+RN,RD 'm','E','!','D'
+RN,0 'h','E','!','E'
+RS,RNDEC 'm','S','!','E'
+RNIND_D8,0 'h','E','!','E'
+IMM16,RD 'm','I','!','D'
+ABS8,RD 'm','E','!','D'
+ABS8,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+RS,ABS8 'm','S','!','E'
+RN,RD '-','E','!','D'
+RN,0 'h','E','!','E'
+RN,RD 'm','E','!','D'
+RNDEC,RD 'm','E','!','D'
+RNDEC,RD '-','E','!','D'
+RN,0 'h','E','!','E'
+RNDEC,RD 'p','E','D','D'
+RNIND,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RS,RN '-','S','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RN,RD 'm','E','D','D'
+RN,RD 'p','E','D','D'
+RN,0 'a','E','!','E'
+RN,0 'm','E','!','E'
+RN,0 'h','E','!','E'
+RN,RD 'm','E','D','D'
+RN,RD 'p','E','D','D'
+RN,0 'a','E','!','E'
+RN,0 'm','E','!','E'
+RNDEC,RD 'm','E','D','D'
+RS,RNDEC '-','S','!','E'
+RNDEC,0 'h','E','!','E'
+RNDEC,0 'a','E','!','E'
+RNINC,RD 'm','E','D','D'
+RNINC,0 'h','E','!','E'
+RN,0 'h','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNIND,0 'h','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS16,0 'h','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+RNDEC,0 'a','E','!','E'
+RNDEC,0 'm','E','!','E'
+RNDEC,RD 'm','E','D','D'
+RNDEC,0 'm','E','!','E'
+RNDEC,0 'h','E','!','E'
+RNINC,0 'a','E','!','E'
+RNINC,0 'm','E','!','E'
+RNINC,RD 'm','E','D','D'
+RNINC,0 'a','E','!','E'
+IMM8,CRB 's','I','C','C'
+IMM16,CRW 's','I','C','C'
+RNINC,0 'm','E','!','E'
+RNINC,0 'h','E','!','E'
+RNIND,RD 'm','E','D','D'
+RNIND,0 'a','E','!','E'
+RNIND,0 'm','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND,RD 'm','E','D','D'
+RNIND,0 'a','E','!','E'
+RNIND,0 'm','E','!','E'
+RNIND,0 'h','E','!','E'
+RNIND_D8,RD 'm','E','D','D'
+RNIND_D8,0 'a','E','!','E'
+RNIND_D8,0 'm','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D8,RD 'm','E','D','D'
+RNIND_D8,0 'a','E','!','E'
+RNIND_D8,0 'm','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D16,RD 'm','E','D','D'
+RNIND,RD 'm','E','D','D'
+RNDEC,RD 'm','E','D','D'
+RNINC,RD 'm','E','D','D'
+ABS8,RD 'm','E','D','D'
+RNIND_D8,RD 'm','E','D','D'
+ABS16,RD 'm','E','D','D'
+IMM16,RD 'm','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+RNIND_D16,0 'a','E','!','E'
+RNIND_D16,0 'm','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+ABS24,0 '-','J','!','!'
+IMM8,RD 'm','E','D','D'
+IMM8,CRB 's','I','C','C'
+IMM8,0 'a','E','!','E'
+IMM8,0 'h','E','!','E'
+ABS8,RD 'm','E','D','D'
+RN,RD 'm','E','D','D'
+RNIND_D16,RD 'm','E','!','D'
+RNIND_D16,0 'a','E','!','E'
+RNIND_D16,0 'm','E','!','E'
+RNIND_D16,0 'h','E','!','E'
+IMM8,0 'm','E','!','E'
+ABS8,0 'a','E','!','E'
+ABS8,0 'm','E','!','E'
+RN,0 'm','E','!','E'
+RNIND,0 'm','E','!','E'
+RNDEC,0 'm','E','!','E'
+RNINC,0 'm','E','!','E'
+ABS8,0 'm','E','!','E'
+RNIND_D8,0 'm','E','!','E'
+ABS16,0 'm','E','!','E'
+IMM16,0 'm','E','!','E'
+RNIND_D16,0 'm','E','!','E'
+IMM8,RNIND_D16 'm','I','!','E'
+0,0 '-','!','!','!'
+ABS8,0 'h','E','!','E'
+IMM16,RD 'm','E','D','D'
+IMM16,CRW 's','I','C','C'
+IMM16,0 'a','E','!','E'
+IMM16,0 'm','E','!','E'
+IMM16,0 'h','E','!','E'
+ABS8,RD 'm','E','D','D'
+ABS8,0 'a','E','!','E'
+ABS8,0 'm','E','!','E'
+ABS8,0 'h','E','!','E'
+RDIND,0 '-','J','!','!'
+RDIND,0 '-','J','!','!'
+IMM8,0 '-','B','!','!'
+0,0 '-','B','!','!'
+IMM16,0 '-','B','!','!'
+ABS24,0 '-','J','!','!'
+ABS16,RD 'm','E','D','D'
+RN,0 'a','E','!','E'
+RNDEC,0 'a','E','!','E'
+RNINC,0 'a','E','!','E'
+RNIND,0 'a','E','!','E'
+ABS8,0 'a','E','!','E'
+RNIND_D8,0 'a','E','!','E'
+ABS16,0 'a','E','!','E'
+IMM16,0 'a','E','!','E'
+RNIND_D16,0 'a','E','!','E'
+RNDEC,RD 'p','E','D','D'
+RNDEC,0 'h','E','!','E'
+RNINC,RD 'p','E','D','D'
+RNINC,RD 'p','E','D','D'
+RNIND,RD 'p','E','D','D'
+RNIND,RD 'p','E','D','D'
+RNIND_D8,RD 'p','E','D','D'
+RNIND_D8,RD 'p','E','D','D'
+RNIND_D8,0 'h','E','!','E'
+RNIND_D16,RD 'p','E','D','D'
+RNIND_D16,RD 'p','E','D','D'
+IMM8,RD 'p','E','D','D'
+ABS8,RD 'p','E','D','D'
+IMM16,RD 'p','E','D','D'
+ABS8,RD 'p','E','D','D'
+ABS8,0 'h','E','!','E'
+RS,ABS16 'm','S','!','E'
+ABS16,RD 'p','E','D','D'
+RN,RD 'p','E','D','D'
+RNIND,RD 'p','E','D','D'
+RNDEC,RD 'p','E','D','D'
+RNINC,RD 'p','E','D','D'
+RNIND_D8,RD 'p','E','D','D'
+ABS8,RD 'p','E','D','D'
+IMM16,RD 'p','E','D','D'
+ABS16,RD 'p','E','D','D'
+RNIND_D16,RD 'p','E','D','D'
+RS,RNINC '-','S','!','E'
+RNINC,0 'h','E','!','E'
+RS,RNIND '-','S','!','E'
+RNIND,0 'h','E','!','E'
+RS,RNIND_D8 '-','S','!','E'
+RS,RNIND_D16 'm','S','!','E'
+RS,RNIND_D16 '-','S','!','E'
+RS,ABS8 '-','S','!','E'
+RS,RN '-','S','!','E'
+RS,RNDEC '-','S','!','E'
+RS,RNIND '-','S','!','E'
+RS,RNINC '-','S','!','E'
+RS,ABS8 '-','S','!','E'
+RNIND,RD '-','E','!','D'
+RS,ABS16 '-','S','!','E'
+RS,RNIND_D16 '-','S','!','E'
+RNINC,RD '-','E','!','D'
+RNIND_D16,0 'h','E','!','E'
+ABS16,RD 'm','E','!','D'
+RS,RNIND_D8 '-','S','!','E'
+RNIND_D8,RD '-','E','!','D'
+IMM8,RNIND_D8 'm','I','!','E'
+RNIND_D16,RD '-','E','!','D'
+IMM8,RD '-','E','!','D'
+ABS8,RD '-','E','!','D'
+RN,RD '-','E','!','D'
+RNINC,0 'h','E','!','E'
+RNIND,RD '-','E','!','D'
+RNDEC,RD '-','E','!','D'
+IMM8,RD '-','E','!','D'
+ABS8,RD '-','E','!','D'
+RNIND_D8,RD '-','E','!','D'
+ABS16,RD '-','E','!','D'
+RNIND_D16,RD '-','E','!','D'
+RNIND,0 'h','E','!','E'
+RNIND_D8,0 'h','E','!','E'
+RS,ABS8 'm','S','!','E'
+RNDEC,RD 'm','E','!','D'
+RNINC,RD 'm','E','!','D'
+ABS8,RD 'm','E','!','D'
+RNDEC,0 'h','E','!','E'
+IMM16,RD 'm','I','!','D'
+RS,RNDEC 'm','S','!','E'
+RS,RNINC 'm','S','!','E'
+RNIND,RD 'm','E','!','D'
+RS,RNIND 'm','S','!','E'
+RNIND_D8,RD 'm','E','!','D'
+RS,RNIND_D8 'm','S','!','E'
+IMM8,0 'h','E','!','E'
+ABS8,0 'h','E','!','E'
+RS,ABS8 'm','S','!','E'
+RNINC,RD '-','E','!','D'
+IMM8,RNDEC 'm','I','!','E'
+IMM16,RNDEC 'm','I','!','E'
+RNINC,RD 'm','E','!','D'
+RS,RNINC 'm','S','!','E'
+IMM8,RNINC 'm','I','!','E'
+IMM16,RNINC 'm','I','!','E'
+RNIND,RD 'm','E','!','D'
+RS,RNIND 'm','S','!','E'
+IMM8,RNIND 'm','I','!','E'
+IMM16,RNIND 'm','I','!','E'
+RNIND_D8,RD 'm','E','!','D'
+RS,RNIND_D8 'm','S','!','E'
+IMM16,RNIND_D8 'm','I','!','E'
+IMM16,RNIND_D16 'm','I','!','E'
+RNIND_D16,RD 'm','E','!','D'
+RS,RNIND_D16 'm','S','!','E'
+RNIND_D16,0 'h','E','!','E'
+IMM8,RD 'm','E','!','D'
+ABS8,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+IMM8,ABS8 'm','I','!','E'
+IMM16,ABS8 'm','I','!','E'
+IMM16,RD 'm','E','!','D'
+IMM16,0 'h','E','!','E'
+ABS8,RD 'm','E','!','D'
+ABS16,RD '-','E','!','D'
+RS,ABS16 '-','S','!','E'
+IMM8,ABS16 'm','I','!','E'
+IMM16,ABS16 'm','I','!','E'
+ABS16,0 'a','E','!','E'
+ABS16,0 'h','E','!','E'
+ABS16,RD 'm','E','!','D'
+RS,ABS16 'm','S','!','E'
+ABS16,RD 'p','E','D','D'
+ABS16,0 'a','E','!','E'
+ABS16,0 'h','E','!','E'
+RS,RNINC 'm','S','!','E'
+RN,RD 'm','E','!','D'
+RS,RNIND 'm','S','!','E'
+RNIND,RD 'm','E','!','D'
+RS,RNDEC 'm','S','!','E'
+RNINC,RD 'm','E','!','D'
+RNDEC,RD 'm','E','!','D'
+RS,RNIND_D8 'm','S','!','E'
+RS,ABS8 'm','S','!','E'
+RNIND_D8,RD 'm','E','!','D'
+IMM8,RNIND 'm','I','!','E'
+ABS8,RD 'm','E','!','D'
+IMM8,RNDEC 'm','I','!','E'
+IMM8,RNINC 'm','I','!','E'
+IMM8,RNIND_D8 'm','I','!','E'
+IMM8,ABS8 'm','I','!','E'
+RS,RNIND_D16 'm','S','!','E'
+IMM16,RD 'm','E','!','D'
+IMM16,RNIND 'm','I','!','E'
+IMM16,RNINC 'm','I','!','E'
+IMM16,RNDEC 'm','I','!','E'
+RS,ABS16 'm','S','!','E'
+RNIND_D16,RD 'm','E','!','D'
+ABS16,RD 'm','E','!','D'
+IMM16,RNIND_D8 'm','I','!','E'
+IMM8,ABS16 'm','I','!','E'
+IMM16,ABS8 'm','I','!','E'
+IMM8,RNIND_D16 'm','I','!','E'
+IMM16,ABS16 'm','I','!','E'
+IMM16,RNIND_D16 'm','I','!','E'
+ABS16,0 'm','E','!','E'
+ABS16,RD 'm','E','D','D'
+ABS16,0 'm','E','!','E'
+ABS16,0 'h','E','!','E'
+RS,FPIND_D8 'm','S','!','E'
+FPIND_D8,RD 'm','E','!','D'
+ABS16,0 'h','E','!','E'
+IMM8,RD 'm','I','!','D'
+RS,FPIND_D8 'm','S','!','E'
+RS,ABS8 'm','S','!','E'
+ABS8,RD 'm','E','!','D'
+RS,RNIND 'm','S','!','E'
+RS,RNINC 'm','S','!','E'
+RS,RNDEC 'm','S','!','E'
+RNIND,RD 'm','E','!','D'
+FPIND_D8,RD 'm','E','!','D'
+RNINC,RD 'm','E','!','D'
+RN,RD 'm','E','!','D'
+RNDEC,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+RNIND_D8,RD 'm','E','!','D'
+RS,RNIND_D8 'm','S','!','E'
+IMM16,RD 'm','I','!','D'
+ABS8,RD 'm','E','!','D'
+IMM16,RNINC 'm','I','!','E'
+IMM16,RNDEC 'm','I','!','E'
+IMM16,RNIND 'm','I','!','E'
+RS,RNIND_D16 'm','S','!','E'
+RS,ABS16 'm','S','!','E'
+ABS16,RD 'm','E','!','D'
+IMM16,RD 'm','E','!','D'
+RNIND_D16,RD 'm','E','!','D'
+IMM16,RNIND_D8 'm','I','!','E'
+IMM16,ABS8 'm','I','!','E'
+IMM16,RNIND_D16 'm','I','!','E'
+IMM16,ABS16 'm','I','!','E'
+FPIND_D8,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+RNINC,RD 'm','E','!','D'
+RS,RNIND 'm','S','!','E'
+RS,RNINC 'm','S','!','E'
+RS,RNDEC 'm','S','!','E'
+RNDEC,RD 'm','E','!','D'
+RS,FPIND_D8 'm','S','!','E'
+RNIND,RD 'm','E','!','D'
+RN,RD 'm','E','!','D'
+ABS8,RD 'm','E','!','D'
+IMM8,RD 'm','I','!','D'
+IMM8,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+IMM8,RNIND 'm','I','!','E'
+IMM8,RNINC 'm','I','!','E'
+IMM8,RNDEC 'm','I','!','E'
+RNIND_D8,RD 'm','E','!','D'
+ABS8,RD 'm','E','!','D'
+RS,RNIND_D8 'm','S','!','E'
+IMM8,RNIND_D8 'm','I','!','E'
+ABS16,RD 'm','E','!','D'
+IMM8,ABS8 'm','I','!','E'
+RS,ABS16 'm','S','!','E'
+RS,RNIND_D16 'm','S','!','E'
+RNIND_D16,RD 'm','E','!','D'
+IMM8,ABS16 'm','I','!','E'
+IMM8,RNIND_D16 'm','I','!','E'
+ABS8,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+RNIND,RD 'm','E','!','D'
+RS,RNIND 'm','S','!','E'
+RS,RNINC 'm','S','!','E'
+RS,RNDEC 'm','S','!','E'
+RN,RD 'm','E','!','D'
+RS,FPIND_D8 'm','S','!','E'
+RNINC,RD 'm','E','!','D'
+FPIND_D8,RD 'm','E','!','D'
+IMM8,RD 'm','I','!','D'
+RNDEC,RD 'm','E','!','D'
+RS,RNIND_D8 'm','S','!','E'
+IMM8,RNIND 'm','I','!','E'
+IMM8,RNINC 'm','I','!','E'
+IMM8,RNDEC 'm','I','!','E'
+RNIND_D8,RD 'm','E','!','D'
+RS,ABS8 'm','S','!','E'
+ABS8,RD 'm','E','!','D'
+IMM16,RD 'm','I','!','D'
+IMM8,ABS8 'm','I','!','E'
+RS,RNIND_D16 'm','S','!','E'
+IMM16,RNIND 'm','I','!','E'
+IMM16,RNINC 'm','I','!','E'
+IMM16,RNDEC 'm','I','!','E'
+RS,ABS16 'm','S','!','E'
+IMM16,RD 'm','E','!','D'
+IMM8,RNIND_D8 'm','I','!','E'
+RNIND_D16,RD 'm','E','!','D'
+ABS16,RD 'm','E','!','D'
+IMM16,RNIND_D8 'm','I','!','E'
+IMM8,ABS16 'm','I','!','E'
+IMM16,ABS8 'm','I','!','E'
+IMM8,RNIND_D16 'm','I','!','E'
+IMM16,ABS16 'm','I','!','E'
+IMM16,RNIND_D16 'm','I','!','E'
+IMM8,RD 'a','D','I','!'
+RN,RD 'a','D','E','!'
+IMM8,RN 'a','E','I','!'
+RN,CRW 's','E','!','C'
+RNIND,CRW 's','E','!','C'
+RNINC,CRW 's','E','!','C'
+RNDEC,CRW 's','E','!','C'
+RN,RD 'a','D','E','!'
+RNIND_D8,CRW 's','E','!','C'
+IMM16,RN 'a','E','I','!'
+ABS16,CRW 's','E','!','C'
+RNIND_D16,CRW 's','E','!','C'
+RN,CRB 's','E','!','C'
+ABS8,CRW 's','E','!','C'
+IMM16,RD 'a','D','I','!'
+RN,RD 's','E','D','D'
+RS,RD 's','D','!','!'
+RS,RD 's','D','!','!'
+RD,0 's','D','!','D'
+RD,0 's','D','!','D'
+RN,RD 's','E','D','D'
+RNIND_D8,CRB 's','E','!','C'
+RN,CRB 's','E','!','C'
+RNINC,CRW 's','E','!','C'
+RNIND,CRB 's','E','!','C'
+RNDEC,CRW 's','E','!','C'
+RNIND,CRW 's','E','!','C'
+RNDEC,CRB 's','E','!','C'
+RNINC,CRB 's','E','!','C'
+ABS8,CRW 's','E','!','C'
+ABS8,CRB 's','E','!','C'
+IMM8,CRB 's','E','!','C'
+RNIND_D8,CRW 's','E','!','C'
+RNIND_D8,CRB 's','E','!','C'
+ABS16,CRB 's','E','!','C'
+ABS16,CRW 's','E','!','C'
+IMM16,CRW 's','E','!','C'
+RNIND_D16,CRW 's','E','!','C'
+RNIND_D16,CRB 's','E','!','C'
+RNIND_D16,CRB 's','E','!','C'
+ABS16,0 '-','B','!','!'
+RDIND,0 '-','B','!','!'
+RDIND,0 '-','B','!','!'
+RDIND_D8,0 '-','B','!','!'
+RDIND_D8,0 '-','B','!','!'
+RDIND_D16,0 '-','B','!','!'
+RDIND_D16,0 '-','B','!','!'
+ABS16,0 '-','B','!','!'
+RD,0 's','D','!','D'
+ABS16,CRB 's','E','!','C'
+RD,0 's','D','!','D'
+RN,CRW 's','E','!','C'
+RNDEC,RD 's','E','D','D'
+RNDEC,RD 's','E','D','D'
+RNINC,CRB 's','E','!','C'
+RNINC,RD 's','E','D','D'
+RNINC,RD 's','E','D','D'
+RNIND,CRB 's','E','!','C'
+RNIND,RD 's','E','D','D'
+RNIND,RD 's','E','D','D'
+RNIND_D8,RD 's','E','D','D'
+RNIND_D8,RD 's','E','D','D'
+RNIND_D16,RD 's','E','D','D'
+RNIND_D16,RD 's','E','D','D'
+IMM8,CRB 's','E','!','C'
+IMM8,RD 's','E','D','D'
+ABS8,RD 's','E','D','D'
+IMM16,RD 's','E','D','D'
+ABS16,RD 's','E','D','D'
+ABS16,RD 's','E','D','D'
+RN,RD 's','E','D','D'
+RNINC,RD 's','E','D','D'
+RNDEC,RD 's','E','D','D'
+RNIND,RD 's','E','D','D'
+ABS8,RD 's','E','D','D'
+RNIND_D8,RD 's','E','D','D'
+IMM16,RD 's','E','D','D'
+ABS16,RD 's','E','D','D'
+RNIND_D16,RD 's','E','D','D'
+ABS8,CRB 's','E','!','C'
+ABS8,RD 's','E','D','D'
+IMM16,RD 'a','D','I','!'
+RNDEC,RD 'a','D','E','!'
+RNDEC,CRB 's','E','!','C'
+IMM8,RNDEC 'a','E','I','!'
+IMM16,RNDEC 'a','E','I','!'
+RNDEC,RD 'a','D','E','!'
+RNINC,RD 'a','D','E','!'
+IMM8,RNINC 'a','E','I','!'
+IMM16,RNINC 'a','E','I','!'
+RNINC,RD 'a','D','E','!'
+RNIND,RD 'a','D','E','!'
+IMM8,RNIND 'a','E','I','!'
+IMM16,RNIND 'a','E','I','!'
+RNIND,RD 'a','D','E','!'
+RNIND_D8,RD 'a','D','E','!'
+IMM8,RNIND_D8 'a','E','I','!'
+IMM16,RNIND_D8 'a','E','I','!'
+RNIND_D8,RD 'a','D','E','!'
+RNIND_D16,RD 'a','D','E','!'
+IMM8,RNIND_D16 'a','E','I','!'
+IMM16,RNIND_D16 'a','E','I','!'
+RNIND_D16,RD 'a','D','E','!'
+SPINC,RLIST '-','E','!','C'
+IMM8,RD 'a','D','E','!'
+ABS8,RD 'a','D','E','!'
+IMM8,ABS8 'a','E','I','!'
+IMM16,ABS8 'a','E','I','!'
+IMM16,RD 'a','D','E','!'
+IMM16,CRW 's','E','!','C'
+ABS8,RD 'a','D','E','!'
+ABS16,RD 'a','D','E','!'
+IMM8,ABS16 'a','E','I','!'
+IMM16,ABS16 'a','E','I','!'
+ABS16,RD 'a','D','E','!'
+FP,IMM16 '-','S','I','!'
+RN,RD 'a','D','E','!'
+RNIND,RD 'a','D','E','!'
+RNINC,RD 'a','D','E','!'
+RNDEC,RD 'a','D','E','!'
+RNIND_D8,RD 'a','D','E','!'
+ABS8,RD 'a','D','E','!'
+IMM16,RNINC 'a','E','I','!'
+IMM16,RNIND 'a','E','I','!'
+IMM16,RN 'a','E','I','!'
+IMM16,RNDEC 'a','E','I','!'
+IMM16,RD 'a','D','E','!'
+ABS16,RD 'a','D','E','!'
+RNIND_D16,RD 'a','D','E','!'
+IMM16,RNIND_D8 'a','E','I','!'
+IMM16,ABS8 'a','E','I','!'
+IMM16,RNIND_D16 'a','E','I','!'
+IMM16,ABS16 'a','E','I','!'
+FP,IMM8 '-','S','I','!'
+IMM8,RD 'a','D','I','!'
+RN,RD 'a','D','E','!'
+RNDEC,RD 'a','D','E','!'
+RNINC,RD 'a','D','E','!'
+RNIND,RD 'a','D','E','!'
+IMM16,RD 'a','D','I','!'
+RNIND_D8,RD 'a','D','E','!'
+ABS8,RD 'a','D','E','!'
+IMM16,RNINC 'a','E','I','!'
+IMM16,RNDEC 'a','E','I','!'
+IMM16,RNIND 'a','E','I','!'
+RNIND_D16,RD 'a','D','E','!'
+ABS16,RD 'a','D','E','!'
+IMM16,RD 'a','D','E','!'
+IMM16,RN 'a','E','I','!'
+IMM16,RNIND_D8 'a','E','I','!'
+IMM16,ABS8 'a','E','I','!'
+IMM16,RNIND_D16 'a','E','I','!'
+IMM16,ABS16 'a','E','I','!'
+RN,RD 'a','D','E','!'
+RNDEC,RD 'a','D','E','!'
+RNINC,RD 'a','D','E','!'
+IMM8,RD 'a','D','I','!'
+RNIND,RD 'a','D','E','!'
+IMM8,RN 'a','E','I','!'
+IMM8,RNIND 'a','E','I','!'
+IMM8,RNINC 'a','E','I','!'
+IMM8,RNDEC 'a','E','I','!'
+ABS8,RD 'a','D','E','!'
+RNIND_D8,RD 'a','D','E','!'
+IMM8,RD 'a','D','E','!'
+IMM8,ABS8 'a','E','I','!'
+ABS16,RD 'a','D','E','!'
+IMM8,RNIND_D8 'a','E','I','!'
+RNIND_D16,RD 'a','D','E','!'
+IMM8,ABS16 'a','E','I','!'
+IMM8,RNIND_D16 'a','E','I','!'
+RN,RD 'a','D','E','!'
+IMM8,RD 'a','D','I','!'
+RNINC,RD 'a','D','E','!'
+RNIND,RD 'a','D','E','!'
+RNDEC,RD 'a','D','E','!'
+IMM16,RD 'a','D','I','!'
+RNIND_D8,RD 'a','D','E','!'
+ABS8,RD 'a','D','E','!'
+IMM16,RN 'a','E','I','!'
+IMM16,RNDEC 'a','E','I','!'
+IMM16,RNIND 'a','E','I','!'
+RNIND_D16,RD 'a','D','E','!'
+IMM16,RNINC 'a','E','I','!'
+ABS16,RD 'a','D','E','!'
+IMM16,RD 'a','D','E','!'
+IMM16,ABS8 'a','E','I','!'
+IMM16,RNIND_D8 'a','E','I','!'
+IMM16,ABS16 'a','E','I','!'
+IMM16,RNIND_D16 'a','E','I','!'
+IMM4,RN 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+RS,RN 'b','E','S','E'
+RS,RN 'b','E','S','E'
+RN,0 'c','!','!','E'
+IMM4,RN 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+RNDEC,0 'c','!','!','E'
+RNINC,0 'c','!','!','E'
+RNIND,0 'c','!','!','E'
+RS,RNIND 'b','E','S','E'
+RNIND_D8,0 'c','!','!','E'
+IMM4,RNIND_D16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+RNIND_D16,0 'c','!','!','E'
+RNIND_D16,0 'c','!','!','E'
+IMM8,0 'c','!','!','E'
+ABS8,0 'c','!','!','E'
+RN,0 'c','!','!','E'
+RNIND,0 'c','!','!','E'
+RNINC,0 'c','!','!','E'
+RNDEC,0 'c','!','!','E'
+ABS8,0 'c','!','!','E'
+RNIND_D8,0 'c','!','!','E'
+IMM16,0 'c','!','!','E'
+ABS16,0 'c','!','!','E'
+RNIND_D16,0 'c','!','!','E'
+IMM4,ABS8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RS,RN 'b','E','S','E'
+IMM4,RNDEC 'b','E','I','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RS,RNDEC 'b','E','S','E'
+IMM4,RNDEC 'b','E','I','E'
+RS,RNDEC 'b','E','S','E'
+RNDEC,0 'c','!','!','E'
+IMM4,RNINC 'b','E','I','E'
+RS,RNINC 'b','E','S','E'
+IMM4,RNINC 'b','E','I','E'
+RS,RNINC 'b','E','S','E'
+IMM4,RNIND 'b','E','I','E'
+RS,RNIND 'b','E','S','E'
+IMM4,RNIND 'b','E','I','E'
+IMM4,RNIND_D8 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,RNIND_D8 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+RNIND_D8,0 'c','!','!','E'
+IMM4,RNIND_D16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+IMM16,0 'c','!','!','E'
+IMM4,ABS8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+ABS8,0 'c','!','!','E'
+IMM4,ABS16 'b','E','I','E'
+RS,ABS16 'b','E','S','E'
+ABS16,0 'c','!','!','E'
+IMM4,ABS16 'b','E','I','E'
+RS,ABS16 'b','E','S','E'
+ABS16,0 'c','!','!','E'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RS,RN 'b','E','S','E'
+IMM4,RNDEC 'b','E','I','E'
+IMM4,RNIND 'b','E','I','E'
+RS,RNIND 'b','E','S','E'
+RS,RNINC 'b','E','S','E'
+RS,RNDEC 'b','E','S','E'
+IMM4,RN 'b','E','I','E'
+IMM4,RNINC 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,ABS8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+IMM4,RNIND_D8 'b','E','I','E'
+IMM4,ABS16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+RS,ABS16 'b','E','S','E'
+IMM4,RNDEC 'b','E','I','E'
+PCREL16,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+IMM4,RNIND_D16 'b','E','I','E'
+RS,RNDEC 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RS,RN 'b','E','S','E'
+RN,0 'c','!','!','E'
+IMM4,RNDEC 'b','E','I','E'
+RS,RNDEC 'b','E','S','E'
+IMM4,RNINC 'b','E','I','E'
+RS,RNINC 'b','E','S','E'
+IMM4,RNINC 'b','E','I','E'
+RS,RNINC 'b','E','S','E'
+RNINC,0 'c','!','!','E'
+IMM4,RNIND 'b','E','I','E'
+RS,RNIND 'b','E','S','E'
+IMM4,RNIND 'b','E','I','E'
+RS,RNIND 'b','E','S','E'
+RNIND,0 'c','!','!','E'
+IMM4,RNIND_D8 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,RNIND_D8 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+IMM4,ABS8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+IMM4,ABS8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+IMM4,ABS16 'b','E','I','E'
+RS,ABS16 'b','E','S','E'
+IMM4,ABS16 'b','E','I','E'
+RS,ABS16 'b','E','S','E'
+PCREL16,0 '-','B','!','!'
+RS,RN 'b','E','S','E'
+IMM4,RN 'b','E','I','E'
+IMM4,RNIND 'b','E','I','E'
+RS,RNIND 'b','E','S','E'
+RS,RNINC 'b','E','S','E'
+RS,RNDEC 'b','E','S','E'
+IMM4,RNINC 'b','E','I','E'
+IMM4,RNDEC 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,RNIND_D8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+IMM4,ABS8 'b','E','I','E'
+IMM4,ABS16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+RS,ABS16 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+QIM,RN 'a','I','E','E'
+RN,RD '-','E','D','D'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RN,RD 'a','E','D','D'
+RN,RD 'm','E','D','D'
+RS,RN 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RS,RN 'b','E','S','E'
+RN,RD 'a','E','D','D'
+IMM4,RN 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+QIM,RN 'a','I','E','E'
+RN,RD 'a','E','D','D'
+RN,RD '-','E','D','D'
+RN,RD 'm','E','D','D'
+RS,RN 'b','E','S','E'
+RS,RN 'b','E','S','E'
+RN,RD 'a','E','D','D'
+IMM4,RNDEC 'b','E','I','E'
+IMM4,RNDEC 'b','E','I','E'
+QIM,RNDEC 'a','I','E','E'
+RNDEC,RD 'a','E','D','D'
+RNDEC,RD '-','E','D','D'
+RNDEC,RD 'm','E','D','D'
+RS,RNDEC 'b','E','S','E'
+RS,RNDEC 'b','E','S','E'
+RNDEC,RD 'a','E','D','D'
+IMM4,RNDEC 'b','E','I','E'
+IMM4,RNDEC 'b','E','I','E'
+QIM,RNDEC 'a','I','E','E'
+RNDEC,RD 'a','E','D','D'
+RNDEC,RD '-','E','D','D'
+RNDEC,RD 'm','E','D','D'
+RS,RNDEC 'b','E','S','E'
+RS,RNDEC 'b','E','S','E'
+RNDEC,RD 'a','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNINC,RD 'm','E','D','D'
+IMM4,RNINC 'b','E','I','E'
+RS,RN 'b','E','S','E'
+RS,RNIND 'b','E','S','E'
+IMM4,RNIND 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+RS,RNINC 'b','E','S','E'
+RS,RNDEC 'b','E','S','E'
+IMM4,RNDEC 'b','E','I','E'
+IMM4,RNINC 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+IMM4,ABS8 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,RNIND_D8 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+IMM4,ABS16 'b','E','I','E'
+RS,ABS16 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+IMM4,RNINC 'b','E','I','E'
+IMM4,RNINC 'b','E','I','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RNINC,RD '-','E','D','D'
+RS,RNINC 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+QIM,RNINC 'a','I','E','E'
+RS,RNINC 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RNINC,RD 'a','E','D','D'
+IMM4,RNINC 'b','E','I','E'
+RNINC,RD 'a','E','D','D'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RS,RNINC 'b','E','S','E'
+IMM4,RNIND 'b','E','I','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+IMM4,RNIND 'b','E','I','E'
+PCREL8,0 '-','B','!','!'
+RNINC,RD 'a','E','D','D'
+PCREL16,0 '-','B','!','!'
+RNINC,RD '-','E','D','D'
+RS,RNINC 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RNINC,RD 'm','E','D','D'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+QIM,RNINC 'a','I','E','E'
+QIM,RNIND 'a','I','E','E'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RNIND,RD 'a','E','D','D'
+RNIND,RD '-','E','D','D'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RNIND,RD 'm','E','D','D'
+RS,RNIND 'b','E','S','E'
+RS,RNIND 'b','E','S','E'
+RNIND,RD 'a','E','D','D'
+IMM4,RNIND 'b','E','I','E'
+IMM4,RNIND 'b','E','I','E'
+QIM,RNIND 'a','I','E','E'
+RNIND,RD 'a','E','D','D'
+RNIND,RD '-','E','D','D'
+RNIND,RD 'm','E','D','D'
+RS,RNIND 'b','E','S','E'
+RS,RNIND 'b','E','S','E'
+RNIND,RD 'a','E','D','D'
+IMM4,RNIND_D8 'b','E','I','E'
+IMM4,RNIND_D8 'b','E','I','E'
+QIM,RNIND_D8 'a','I','E','E'
+RNIND_D8,RD 'a','E','D','D'
+RNIND_D8,RD '-','E','D','D'
+RNIND_D8,RD 'm','E','D','D'
+RS,RNIND_D8 'b','E','S','E'
+RS,RNIND_D8 'b','E','S','E'
+RNIND_D8,RD 'a','E','D','D'
+IMM4,RNIND_D8 'b','E','I','E'
+IMM4,RNIND_D8 'b','E','I','E'
+QIM,RNIND_D8 'a','I','E','E'
+RNIND_D8,RD 'a','E','D','D'
+RNIND_D8,RD '-','E','D','D'
+RNIND_D8,RD 'm','E','D','D'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+QIM,RNIND_D16 'a','I','E','E'
+RS,RNIND_D16 'b','E','S','E'
+RS,RN 'b','E','S','E'
+IMM4,RNDEC 'b','E','I','E'
+IMM4,RNINC 'b','E','I','E'
+RS,RNIND 'b','E','S','E'
+RS,RNINC 'b','E','S','E'
+RS,RNDEC 'b','E','S','E'
+IMM4,RNIND 'b','E','I','E'
+IMM4,RN 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+IMM4,ABS8 'b','E','I','E'
+RS,ABS8 'b','E','S','E'
+IMM4,RNIND_D8 'b','E','I','E'
+IMM4,ABS16 'b','E','I','E'
+RS,RNIND_D16 'b','E','S','E'
+RS,ABS16 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+RS,RNIND_D8 'b','E','S','E'
+RNIND_D16,RD 'a','E','D','D'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RNIND_D16,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+IMM8,CRB 's','I','S','S'
+IMM16,CRW 's','I','S','S'
+RNIND_D8,RD 'a','E','D','D'
+IMM4,RNIND_D16 'b','E','I','E'
+RNIND_D16,RD '-','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+RS,RNIND_D16 'b','E','S','E'
+IMM4,RNIND_D16 'b','E','I','E'
+IMM4,RNIND_D16 'b','E','I','E'
+QIM,RNIND_D16 'a','I','E','E'
+RNIND_D16,RD '-','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+RS,RNIND_D16 'b','E','S','E'
+RS,RNIND_D16 'b','E','S','E'
+RNIND_D16,RD 'a','E','D','D'
+IMM8,RD 'a','E','D','D'
+IMM8,RD '-','E','D','D'
+IMM8,RD 'm','E','D','D'
+IMM8,CRB 's','I','S','S'
+IMM8,RD 'a','E','D','D'
+RN,RD 'm','E','D','D'
+RNDEC,RD 'm','E','D','D'
+RNINC,RD 'm','E','D','D'
+RNIND,RD 'm','E','D','D'
+ABS8,RD 'm','E','D','D'
+RNIND_D8,RD 'm','E','D','D'
+IMM16,RD 'm','E','D','D'
+ABS16,RD 'm','E','D','D'
+RNIND_D16,RD 'm','E','D','D'
+IMM4,ABS8 'b','E','I','E'
+IMM4,ABS8 'b','E','I','E'
+QIM,ABS8 'a','I','E','E'
+ABS8,RD 'a','E','D','D'
+ABS8,RD '-','E','D','D'
+ABS8,RD 'm','E','D','D'
+RS,ABS8 'b','E','S','E'
+RS,ABS8 'b','E','S','E'
+ABS8,RD 'a','E','D','D'
+IMM16,RD 'a','E','D','D'
+IMM16,RD '-','E','D','D'
+IMM16,RD 'm','E','D','D'
+IMM16,CRW 's','I','S','S'
+IMM16,RD 'a','E','D','D'
+IMM4,ABS8 'b','E','I','E'
+QIM,ABS8 'a','I','E','E'
+ABS8,RD 'a','E','D','D'
+ABS8,RD '-','E','D','D'
+RN,RD 'a','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNIND,RD 'a','E','D','D'
+RNDEC,RD 'a','E','D','D'
+ABS8,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+ABS16,RD 'a','E','D','D'
+IMM16,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+0,0 '-','!','!','!'
+IMM4,ABS8 'b','E','I','E'
+ABS8,RD 'm','E','D','D'
+RS,ABS8 'b','E','S','E'
+RS,ABS8 'b','E','S','E'
+ABS8,RD 'a','E','D','D'
+IMM4,ABS16 'b','E','I','E'
+ABS16,RD 'a','E','D','D'
+ABS16,RD '-','E','D','D'
+ABS16,RD 'm','E','D','D'
+RS,ABS16 'b','E','S','E'
+ABS16,RD 'a','E','D','D'
+IMM4,ABS16 'b','E','I','E'
+ABS16,RD '-','E','D','D'
+ABS16,RD 'm','E','D','D'
+RS,ABS16 'b','E','S','E'
+ABS16,RD 'a','E','D','D'
+PCREL8,0 '-','B','!','!'
+RN,RD '-','E','D','D'
+RNIND,RD '-','E','D','D'
+RNINC,RD '-','E','D','D'
+RNDEC,RD '-','E','D','D'
+ABS8,RD '-','E','D','D'
+RNIND_D8,RD '-','E','D','D'
+ABS16,RD '-','E','D','D'
+IMM16,RD '-','E','D','D'
+RNIND_D16,RD '-','E','D','D'
+IMM4,ABS16 'b','E','I','E'
+QIM,ABS16 'a','I','E','E'
+RS,ABS16 'b','E','S','E'
+IMM4,ABS16 'b','E','I','E'
+QIM,ABS16 'a','I','E','E'
+ABS16,RD 'a','E','D','D'
+RS,ABS16 'b','E','S','E'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+QIM,RN 'a','I','E','E'
+QIM,RNDEC 'a','I','E','E'
+QIM,RNINC 'a','I','E','E'
+QIM,RNIND 'a','I','E','E'
+QIM,ABS8 'a','I','E','E'
+QIM,RNIND_D8 'a','I','E','E'
+QIM,ABS16 'a','I','E','E'
+QIM,RNIND_D16 'a','I','E','E'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL8,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+PCREL16,0 '-','B','!','!'
+RN,RD 'a','E','D','D'
+RNDEC,RD 'a','E','D','D'
+RNINC,RD 'a','E','D','D'
+RNIND,RD 'a','E','D','D'
+ABS8,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+ABS16,RD 'a','E','D','D'
+IMM16,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RN,RD 'a','E','D','D'
+QIM,RN 'a','I','E','E'
+QIM,RNIND 'a','I','E','E'
+RNDEC,RD 'a','E','D','D'
+QIM,RNDEC 'a','I','E','E'
+QIM,RNINC 'a','I','E','E'
+RNIND,RD 'a','E','D','D'
+RNINC,RD 'a','E','D','D'
+QIM,ABS8 'a','I','E','E'
+QIM,RNIND_D8 'a','I','E','E'
+ABS8,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+ABS16,RD 'a','E','D','D'
+QIM,RNIND_D16 'a','I','E','E'
+IMM16,RD 'a','E','D','D'
+QIM,ABS16 'a','I','E','E'
+RNIND_D16,RD 'a','E','D','D'
+RN,RD 'a','E','D','D'
+QIM,RN 'a','I','E','E'
+QIM,RNINC 'a','I','E','E'
+RNDEC,RD 'a','E','D','D'
+QIM,RNIND 'a','I','E','E'
+RNINC,RD 'a','E','D','D'
+QIM,RNDEC 'a','I','E','E'
+RNIND,RD 'a','E','D','D'
+QIM,RNIND_D8 'a','I','E','E'
+IMM8,RD 'a','E','D','D'
+QIM,ABS8 'a','I','E','E'
+ABS8,RD 'a','E','D','D'
+RNIND_D8,RD 'a','E','D','D'
+QIM,RNIND_D16 'a','I','E','E'
+QIM,ABS16 'a','I','E','E'
+ABS16,RD 'a','E','D','D'
+RNIND_D16,RD 'a','E','D','D'
+RN,RD 'a','E','D','D'
+QIM,RN 'a','I','E','E'
+QIM,RNDEC 'a','I','E','E'
+RNDEC,RD 'a','E','D','D'
+QIM,RNIND 'a','I','E','E'
+QIM,RNINC 'a','I','E','E'
+RNINC,RD 'a','E','D','D'
+RNIND,RD 'a','E','D','D'
+QIM,ABS8 'a','I','E','E'
+QIM,RNIND_D8 'a','I','E','E'
+RNIND_D8,RD 'a','E','D','D'
+ABS8,RD 'a','E','D','D'
+ABS16,RD 'a','E','D','D'
+QIM,RNIND_D16 'a','I','E','E'
+IMM16,RD 'a','E','D','D'
+QIM,ABS16 'a','I','E','E'
+RNIND_D16,RD 'a','E','D','D'
+*/
+{0,0,0}}
+#endif
+;
+#endif
diff --git a/opcodes/hppa-dis.c b/opcodes/hppa-dis.c
new file mode 100644
index 00000000000..dc45d5ee4ba
--- /dev/null
+++ b/opcodes/hppa-dis.c
@@ -0,0 +1,631 @@
+/* Disassembler for the PA-RISC. Somewhat derived from sparc-pinsn.c.
+ Copyright 1989, 1990, 1992, 1993 Free Software Foundation, Inc.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <ansidecl.h>
+#include "sysdep.h"
+#include "dis-asm.h"
+#include "libhppa.h"
+#include "opcode/hppa.h"
+
+/* Integer register names, indexed by the numbers which appear in the
+ opcodes. */
+static const char *const reg_names[] =
+ {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
+ "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
+ "r20", "r21", "r22", "r23", "r24", "r25", "r26", "dp", "ret0", "ret1",
+ "sp", "r31"};
+
+/* Floating point register names, indexed by the numbers which appear in the
+ opcodes. */
+static const char *const fp_reg_names[] =
+ {"fpsr", "fpe2", "fpe4", "fpe6",
+ "fr4", "fr5", "fr6", "fr7", "fr8",
+ "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
+ "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23",
+ "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"};
+
+typedef unsigned int CORE_ADDR;
+
+/* Get at various relevent fields of an instruction word. */
+
+#define MASK_5 0x1f
+#define MASK_11 0x7ff
+#define MASK_14 0x3fff
+#define MASK_21 0x1fffff
+
+/* This macro gets bit fields using HP's numbering (MSB = 0) */
+
+#define GET_FIELD(X, FROM, TO) \
+ ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
+
+/* Some of these have been converted to 2-d arrays because they
+ consume less storage this way. If the maintenance becomes a
+ problem, convert them back to const 1-d pointer arrays. */
+static const char control_reg[][6] = {
+ "rctr", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
+ "pidr1", "pidr2", "ccr", "sar", "pidr3", "pidr4",
+ "iva", "eiem", "itmr", "pcsq", "pcoq", "iir", "isr",
+ "ior", "ipsw", "eirr", "tr0", "tr1", "tr2", "tr3",
+ "tr4", "tr5", "tr6", "tr7"
+};
+
+static const char compare_cond_names[][5] = {
+ "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv",
+ ",od", ",tr", ",<>", ",>=", ",>", ",>>=",
+ ",>>", ",nsv", ",ev"
+};
+static const char add_cond_names[][5] = {
+ "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv",
+ ",od", ",tr", ",<>", ",>=", ",>", ",uv",
+ ",vnz", ",nsv", ",ev"
+};
+static const char *const logical_cond_names[] = {
+ "", ",=", ",<", ",<=", 0, 0, 0, ",od",
+ ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
+static const char *const unit_cond_names[] = {
+ "", 0, ",sbz", ",shz", ",sdc", 0, ",sbc", ",shc",
+ ",tr", 0, ",nbz", ",nhz", ",ndc", 0, ",nbc", ",nhc"
+};
+static const char shift_cond_names[][4] = {
+ "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"
+};
+static const char index_compl_names[][4] = {"", ",m", ",s", ",sm"};
+static const char short_ldst_compl_names[][4] = {"", ",ma", "", ",mb"};
+static const char *const short_bytes_compl_names[] = {
+ "", ",b,m", ",e", ",e,m"
+};
+static const char *const float_format_names[] = {",sgl", ",dbl", "", ",quad"};
+static const char float_comp_names[][8] =
+{
+ ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
+ ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
+ ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
+ ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
+};
+
+/* For a bunch of different instructions form an index into a
+ completer name table. */
+#define GET_COMPL(insn) (GET_FIELD (insn, 26, 26) | \
+ GET_FIELD (insn, 18, 18) << 1)
+
+#define GET_COND(insn) (GET_FIELD ((insn), 16, 18) + \
+ (GET_FIELD ((insn), 19, 19) ? 8 : 0))
+
+/* Utility function to print registers. Put these first, so gcc's function
+ inlining can do its stuff. */
+
+#define fputs_filtered(STR,F) (*info->fprintf_func) (info->stream, "%s", STR)
+
+static void
+fput_reg (reg, info)
+ unsigned reg;
+ disassemble_info *info;
+{
+ (*info->fprintf_func) (info->stream, reg ? reg_names[reg] : "r0");
+}
+
+static void
+fput_fp_reg (reg, info)
+ unsigned reg;
+ disassemble_info *info;
+{
+ (*info->fprintf_func) (info->stream, reg ? fp_reg_names[reg] : "fr0");
+}
+
+static void
+fput_fp_reg_r (reg, info)
+ unsigned reg;
+ disassemble_info *info;
+{
+ /* Special case floating point exception registers. */
+ if (reg < 4)
+ (*info->fprintf_func) (info->stream, "fpe%d", reg * 2 + 1);
+ else
+ (*info->fprintf_func) (info->stream, "%sR", reg ? fp_reg_names[reg]
+ : "fr0");
+}
+
+static void
+fput_creg (reg, info)
+ unsigned reg;
+ disassemble_info *info;
+{
+ (*info->fprintf_func) (info->stream, control_reg[reg]);
+}
+
+/* print constants with sign */
+
+static void
+fput_const (num, info)
+ unsigned num;
+ disassemble_info *info;
+{
+ if ((int)num < 0)
+ (*info->fprintf_func) (info->stream, "-%x", -(int)num);
+ else
+ (*info->fprintf_func) (info->stream, "%x", num);
+}
+
+/* Routines to extract various sized constants out of hppa
+ instructions. */
+
+/* extract a 3-bit space register number from a be, ble, mtsp or mfsp */
+static int
+extract_3 (word)
+ unsigned word;
+{
+ return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17);
+}
+
+static int
+extract_5_load (word)
+ unsigned word;
+{
+ return low_sign_extend (word >> 16 & MASK_5, 5);
+}
+
+/* extract the immediate field from a st{bhw}s instruction */
+static int
+extract_5_store (word)
+ unsigned word;
+{
+ return low_sign_extend (word & MASK_5, 5);
+}
+
+/* extract the immediate field from a break instruction */
+static unsigned
+extract_5r_store (word)
+ unsigned word;
+{
+ return (word & MASK_5);
+}
+
+/* extract the immediate field from a {sr}sm instruction */
+static unsigned
+extract_5R_store (word)
+ unsigned word;
+{
+ return (word >> 16 & MASK_5);
+}
+
+/* extract the immediate field from a bb instruction */
+static unsigned
+extract_5Q_store (word)
+ unsigned word;
+{
+ return (word >> 21 & MASK_5);
+}
+
+/* extract an 11 bit immediate field */
+static int
+extract_11 (word)
+ unsigned word;
+{
+ return low_sign_extend (word & MASK_11, 11);
+}
+
+/* extract a 14 bit immediate field */
+static int
+extract_14 (word)
+ unsigned word;
+{
+ return low_sign_extend (word & MASK_14, 14);
+}
+
+/* extract a 21 bit constant */
+
+static int
+extract_21 (word)
+ unsigned word;
+{
+ int val;
+
+ word &= MASK_21;
+ word <<= 11;
+ val = GET_FIELD (word, 20, 20);
+ val <<= 11;
+ val |= GET_FIELD (word, 9, 19);
+ val <<= 2;
+ val |= GET_FIELD (word, 5, 6);
+ val <<= 5;
+ val |= GET_FIELD (word, 0, 4);
+ val <<= 2;
+ val |= GET_FIELD (word, 7, 8);
+ return sign_extend (val, 21) << 11;
+}
+
+/* extract a 12 bit constant from branch instructions */
+
+static int
+extract_12 (word)
+ unsigned word;
+{
+ return sign_extend (GET_FIELD (word, 19, 28) |
+ GET_FIELD (word, 29, 29) << 10 |
+ (word & 0x1) << 11, 12) << 2;
+}
+
+/* extract a 17 bit constant from branch instructions, returning the
+ 19 bit signed value. */
+
+static int
+extract_17 (word)
+ unsigned word;
+{
+ return sign_extend (GET_FIELD (word, 19, 28) |
+ GET_FIELD (word, 29, 29) << 10 |
+ GET_FIELD (word, 11, 15) << 11 |
+ (word & 0x1) << 16, 17) << 2;
+}
+
+/* Print one instruction. */
+int
+print_insn_hppa (memaddr, info)
+ bfd_vma memaddr;
+ disassemble_info *info;
+{
+ bfd_byte buffer[4];
+ unsigned int insn, i;
+
+ {
+ int status =
+ (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ }
+
+ insn = bfd_getb32 (buffer);
+
+ for (i = 0; i < NUMOPCODES; ++i)
+ {
+ const struct pa_opcode *opcode = &pa_opcodes[i];
+ if ((insn & opcode->mask) == opcode->match)
+ {
+ register const char *s;
+
+ (*info->fprintf_func) (info->stream, "%s", opcode->name);
+
+ if (!strchr ("cfCY<?!@-+&U>~nHNZFIMadu|", opcode->args[0]))
+ (*info->fprintf_func) (info->stream, " ");
+ for (s = opcode->args; *s != '\0'; ++s)
+ {
+ switch (*s)
+ {
+ case 'x':
+ fput_reg (GET_FIELD (insn, 11, 15), info);
+ break;
+ case 'X':
+ if (GET_FIELD (insn, 25, 25))
+ fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
+ else
+ fput_fp_reg (GET_FIELD (insn, 11, 15), info);
+ break;
+ case 'b':
+ fput_reg (GET_FIELD (insn, 6, 10), info);
+ break;
+ case '^':
+ fput_creg (GET_FIELD (insn, 6, 10), info);
+ break;
+ case 'E':
+ if (GET_FIELD (insn, 25, 25))
+ fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
+ else
+ fput_fp_reg (GET_FIELD (insn, 6, 10), info);
+ break;
+ case 't':
+ fput_reg (GET_FIELD (insn, 27, 31), info);
+ break;
+ case 'v':
+ if (GET_FIELD (insn, 25, 25))
+ fput_fp_reg_r (GET_FIELD (insn, 27, 31), info);
+ else
+ fput_fp_reg (GET_FIELD (insn, 27, 31), info);
+ break;
+ case 'y':
+ fput_fp_reg (GET_FIELD (insn, 27, 31), info);
+ break;
+ case '4':
+ {
+ int reg = GET_FIELD (insn, 6, 10);
+
+ reg |= (GET_FIELD (insn, 26, 26) << 4);
+ fput_fp_reg (reg, info);
+ break;
+ }
+ case '6':
+ {
+ int reg = GET_FIELD (insn, 11, 15);
+
+ reg |= (GET_FIELD (insn, 26, 26) << 4);
+ fput_fp_reg (reg, info);
+ break;
+ }
+ case '7':
+ {
+ int reg = GET_FIELD (insn, 27, 31);
+
+ reg |= (GET_FIELD (insn, 26, 26) << 4);
+ fput_fp_reg (reg, info);
+ break;
+ }
+ case '8':
+ {
+ int reg = GET_FIELD (insn, 16, 20);
+
+ reg |= (GET_FIELD (insn, 26, 26) << 4);
+ fput_fp_reg (reg, info);
+ break;
+ }
+ case '9':
+ {
+ int reg = GET_FIELD (insn, 21, 25);
+
+ reg |= (GET_FIELD (insn, 26, 26) << 4);
+ fput_fp_reg (reg, info);
+ break;
+ }
+ case '5':
+ fput_const (extract_5_load (insn), info);
+ break;
+ case 's':
+ (*info->fprintf_func) (info->stream,
+ "sr%d", GET_FIELD (insn, 16, 17));
+ break;
+ case 'S':
+ (*info->fprintf_func) (info->stream, "sr%d", extract_3 (insn));
+ break;
+ case 'c':
+ (*info->fprintf_func) (info->stream, "%s ",
+ index_compl_names[GET_COMPL (insn)]);
+ break;
+ case 'C':
+ (*info->fprintf_func) (info->stream, "%s ",
+ short_ldst_compl_names[GET_COMPL (insn)]);
+ break;
+ case 'Y':
+ (*info->fprintf_func) (info->stream, "%s ",
+ short_bytes_compl_names[GET_COMPL (insn)]);
+ break;
+ /* these four conditions are for the set of instructions
+ which distinguish true/false conditions by opcode rather
+ than by the 'f' bit (sigh): comb, comib, addb, addib */
+ case '<':
+ fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)],
+ info);
+ break;
+ case '?':
+ fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
+ + GET_FIELD (insn, 4, 4) * 8], info);
+ break;
+ case '@':
+ fputs_filtered (add_cond_names[GET_FIELD (insn, 16, 18)
+ + GET_FIELD (insn, 4, 4) * 8], info);
+ break;
+ case 'a':
+ (*info->fprintf_func) (info->stream, "%s ",
+ compare_cond_names[GET_COND (insn)]);
+ break;
+ case 'd':
+ (*info->fprintf_func) (info->stream, "%s ",
+ add_cond_names[GET_COND (insn)]);
+ break;
+ case '!':
+ (*info->fprintf_func) (info->stream, "%s",
+ add_cond_names[GET_FIELD (insn, 16, 18)]);
+ break;
+
+ case '&':
+ (*info->fprintf_func) (info->stream, "%s ",
+ logical_cond_names[GET_COND (insn)]);
+ break;
+ case 'U':
+ (*info->fprintf_func) (info->stream, "%s ",
+ unit_cond_names[GET_COND (insn)]);
+ break;
+ case '|':
+ case '>':
+ case '~':
+ (*info->fprintf_func)
+ (info->stream, "%s",
+ shift_cond_names[GET_FIELD (insn, 16, 18)]);
+
+ /* If the next character in args is 'n', it will handle
+ putting out the space. */
+ if (s[1] != 'n')
+ (*info->fprintf_func) (info->stream, " ");
+ break;
+ case 'V':
+ fput_const (extract_5_store (insn), info);
+ break;
+ case 'r':
+ fput_const (extract_5r_store (insn), info);
+ break;
+ case 'R':
+ fput_const (extract_5R_store (insn), info);
+ break;
+ case 'Q':
+ fput_const (extract_5Q_store (insn), info);
+ break;
+ case 'i':
+ fput_const (extract_11 (insn), info);
+ break;
+ case 'j':
+ fput_const (extract_14 (insn), info);
+ break;
+ case 'k':
+ fput_const (extract_21 (insn), info);
+ break;
+ case 'n':
+ if (insn & 0x2)
+ (*info->fprintf_func) (info->stream, ",n ");
+ else
+ (*info->fprintf_func) (info->stream, " ");
+ break;
+ case 'N':
+ if ((insn & 0x20) && s[1])
+ (*info->fprintf_func) (info->stream, ",n ");
+ else if (insn & 0x20)
+ (*info->fprintf_func) (info->stream, ",n");
+ else if (s[1])
+ (*info->fprintf_func) (info->stream, " ");
+ break;
+ case 'w':
+ (*info->print_address_func) (memaddr + 8 + extract_12 (insn),
+ info);
+ break;
+ case 'W':
+ /* 17 bit PC-relative branch. */
+ (*info->print_address_func) ((memaddr + 8
+ + extract_17 (insn)),
+ info);
+ break;
+ case 'z':
+ /* 17 bit displacement. This is an offset from a register
+ so it gets disasssembled as just a number, not any sort
+ of address. */
+ fput_const (extract_17 (insn), info);
+ break;
+ case 'p':
+ (*info->fprintf_func) (info->stream, "%d",
+ 31 - GET_FIELD (insn, 22, 26));
+ break;
+ case 'P':
+ (*info->fprintf_func) (info->stream, "%d",
+ GET_FIELD (insn, 22, 26));
+ break;
+ case 'T':
+ (*info->fprintf_func) (info->stream, "%d",
+ 32 - GET_FIELD (insn, 27, 31));
+ break;
+ case 'A':
+ fput_const (GET_FIELD (insn, 6, 18), info);
+ break;
+ case 'Z':
+ if (GET_FIELD (insn, 26, 26))
+ (*info->fprintf_func) (info->stream, ",m ");
+ else
+ (*info->fprintf_func) (info->stream, " ");
+ break;
+ case 'D':
+ fput_const (GET_FIELD (insn, 6, 31), info);
+ break;
+ case 'f':
+ (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
+ break;
+ case 'O':
+ fput_const ((GET_FIELD (insn, 6,20) << 5 |
+ GET_FIELD (insn, 27, 31)), info);
+ break;
+ case 'o':
+ fput_const (GET_FIELD (insn, 6, 20), info);
+ break;
+ case '3':
+ {
+ int reg = GET_FIELD (insn, 21, 22);
+ reg |= GET_FIELD (insn, 16, 18) << 2;
+ if (GET_FIELD (insn, 23, 23) != 0)
+ fput_fp_reg_r (reg, info);
+ else
+ fput_fp_reg (reg, info);
+ break;
+ }
+
+ case '2':
+ fput_const ((GET_FIELD (insn, 6, 22) << 5 |
+ GET_FIELD (insn, 27, 31)), info);
+ break;
+ case '1':
+ fput_const ((GET_FIELD (insn, 11, 20) << 5 |
+ GET_FIELD (insn, 27, 31)), info);
+ break;
+ case '0':
+ fput_const ((GET_FIELD (insn, 16, 20) << 5 |
+ GET_FIELD (insn, 27, 31)), info);
+ break;
+ case 'u':
+ (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
+ break;
+ case 'F':
+ /* if no destination completer and not before a completer
+ for fcmp, need a space here */
+ if (GET_FIELD (insn, 21, 22) == 1 || s[1] == 'M')
+ fputs_filtered (float_format_names[GET_FIELD (insn, 19, 20)],
+ info);
+ else
+ (*info->fprintf_func) (info->stream, "%s ",
+ float_format_names[GET_FIELD
+ (insn, 19, 20)]);
+ break;
+ case 'G':
+ (*info->fprintf_func) (info->stream, "%s ",
+ float_format_names[GET_FIELD (insn,
+ 17, 18)]);
+ break;
+ case 'H':
+ if (GET_FIELD (insn, 26, 26) == 1)
+ (*info->fprintf_func) (info->stream, "%s ",
+ float_format_names[0]);
+ else
+ (*info->fprintf_func) (info->stream, "%s ",
+ float_format_names[1]);
+ break;
+ case 'I':
+ /* if no destination completer and not before a completer
+ for fcmp, need a space here */
+ if (GET_FIELD (insn, 21, 22) == 1 || s[1] == 'M')
+ fputs_filtered (float_format_names[GET_FIELD (insn, 20, 20)],
+ info);
+ else
+ (*info->fprintf_func) (info->stream, "%s ",
+ float_format_names[GET_FIELD
+ (insn, 20, 20)]);
+ break;
+ case 'J':
+ if (GET_FIELD (insn, 24, 24))
+ fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
+ else
+ fput_fp_reg (GET_FIELD (insn, 6, 10), info);
+
+ break;
+ case 'K':
+ if (GET_FIELD (insn, 19, 19))
+ fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
+ else
+ fput_fp_reg (GET_FIELD (insn, 11, 15), info);
+ break;
+ case 'M':
+ (*info->fprintf_func) (info->stream, "%s ",
+ float_comp_names[GET_FIELD
+ (insn, 27, 31)]);
+ break;
+ default:
+ (*info->fprintf_func) (info->stream, "%c", *s);
+ break;
+ }
+ }
+ return sizeof(insn);
+ }
+ }
+ (*info->fprintf_func) (info->stream, "#%8x", insn);
+ return sizeof(insn);
+}
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
new file mode 100644
index 00000000000..19144cb9fc5
--- /dev/null
+++ b/opcodes/i386-dis.c
@@ -0,0 +1,3268 @@
+/* Print i386 instructions for GDB, the GNU debugger.
+ Copyright (C) 1988, 89, 91, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+ * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
+ * July 1988
+ * modified by John Hassey (hassey@dg-rtp.dg.com)
+ */
+
+/*
+ * The main tables describing the instructions is essentially a copy
+ * of the "Opcode Map" chapter (Appendix A) of the Intel 80386
+ * Programmers Manual. Usually, there is a capital letter, followed
+ * by a small letter. The capital letter tell the addressing mode,
+ * and the small letter tells about the operand size. Refer to
+ * the Intel manual for details.
+ */
+
+#include "dis-asm.h"
+#include "sysdep.h"
+#include "opintl.h"
+
+#define MAXLEN 20
+
+#include <setjmp.h>
+
+#ifndef UNIXWARE_COMPAT
+/* Set non-zero for broken, compatible instructions. Set to zero for
+ non-broken opcodes. */
+#define UNIXWARE_COMPAT 1
+#endif
+
+
+static int fetch_data PARAMS ((struct disassemble_info *, bfd_byte *));
+
+struct dis_private
+{
+ /* Points to first byte not fetched. */
+ bfd_byte *max_fetched;
+ bfd_byte the_buffer[MAXLEN];
+ bfd_vma insn_start;
+ jmp_buf bailout;
+};
+
+/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
+ to ADDR (exclusive) are valid. Returns 1 for success, longjmps
+ on error. */
+#define FETCH_DATA(info, addr) \
+ ((addr) <= ((struct dis_private *)(info->private_data))->max_fetched \
+ ? 1 : fetch_data ((info), (addr)))
+
+static int
+fetch_data (info, addr)
+ struct disassemble_info *info;
+ bfd_byte *addr;
+{
+ int status;
+ struct dis_private *priv = (struct dis_private *)info->private_data;
+ bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
+
+ status = (*info->read_memory_func) (start,
+ priv->max_fetched,
+ addr - priv->max_fetched,
+ info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, start, info);
+ longjmp (priv->bailout, 1);
+ }
+ else
+ priv->max_fetched = addr;
+ return 1;
+}
+
+#define Eb OP_E, b_mode
+#define indirEb OP_indirE, b_mode
+#define Gb OP_G, b_mode
+#define Ev OP_E, v_mode
+#define indirEv OP_indirE, v_mode
+#define Ew OP_E, w_mode
+#define Ma OP_E, v_mode
+#define M OP_E, 0
+#define Mp OP_E, 0 /* ? */
+#define Gv OP_G, v_mode
+#define Gw OP_G, w_mode
+#define Rw OP_rm, w_mode
+#define Rd OP_rm, d_mode
+#define Ib OP_I, b_mode
+#define sIb OP_sI, b_mode /* sign extened byte */
+#define Iv OP_I, v_mode
+#define Iw OP_I, w_mode
+#define Jb OP_J, b_mode
+#define Jv OP_J, v_mode
+#if 0
+#define ONE OP_ONE, 0
+#endif
+#define Cd OP_C, d_mode
+#define Dd OP_D, d_mode
+#define Td OP_T, d_mode
+
+#define eAX OP_REG, eAX_reg
+#define eBX OP_REG, eBX_reg
+#define eCX OP_REG, eCX_reg
+#define eDX OP_REG, eDX_reg
+#define eSP OP_REG, eSP_reg
+#define eBP OP_REG, eBP_reg
+#define eSI OP_REG, eSI_reg
+#define eDI OP_REG, eDI_reg
+#define AL OP_REG, al_reg
+#define CL OP_REG, cl_reg
+#define DL OP_REG, dl_reg
+#define BL OP_REG, bl_reg
+#define AH OP_REG, ah_reg
+#define CH OP_REG, ch_reg
+#define DH OP_REG, dh_reg
+#define BH OP_REG, bh_reg
+#define AX OP_REG, ax_reg
+#define DX OP_REG, dx_reg
+#define indirDX OP_REG, indir_dx_reg
+
+#define Sw OP_SEG, w_mode
+#define Ap OP_DIR, lptr
+#define Av OP_DIR, v_mode
+#define Ob OP_OFF, b_mode
+#define Ov OP_OFF, v_mode
+#define Xb OP_DSreg, eSI_reg
+#define Xv OP_DSreg, eSI_reg
+#define Yb OP_ESreg, eDI_reg
+#define Yv OP_ESreg, eDI_reg
+#define DSBX OP_DSreg, eBX_reg
+
+#define es OP_REG, es_reg
+#define ss OP_REG, ss_reg
+#define cs OP_REG, cs_reg
+#define ds OP_REG, ds_reg
+#define fs OP_REG, fs_reg
+#define gs OP_REG, gs_reg
+
+#define MX OP_MMX, 0
+#define EM OP_EM, v_mode
+#define MS OP_MS, b_mode
+#define OPSUF OP_3DNowSuffix, 0
+
+/* bits in sizeflag */
+#if 0 /* leave undefined until someone adds the extra flag to objdump */
+#define SUFFIX_ALWAYS 4
+#endif
+#define AFLAG 2
+#define DFLAG 1
+
+typedef void (*op_rtn) PARAMS ((int bytemode, int sizeflag ));
+
+static void OP_E PARAMS ((int, int));
+static void OP_G PARAMS ((int, int));
+static void OP_I PARAMS ((int, int));
+static void OP_indirE PARAMS ((int, int));
+static void OP_sI PARAMS ((int, int));
+static void OP_REG PARAMS ((int, int));
+static void OP_J PARAMS ((int, int));
+static void OP_DIR PARAMS ((int, int));
+static void OP_OFF PARAMS ((int, int));
+static void OP_ESreg PARAMS ((int, int));
+static void OP_DSreg PARAMS ((int, int));
+static void OP_SEG PARAMS ((int, int));
+static void OP_C PARAMS ((int, int));
+static void OP_D PARAMS ((int, int));
+static void OP_T PARAMS ((int, int));
+static void OP_rm PARAMS ((int, int));
+static void OP_ST PARAMS ((int, int));
+static void OP_STi PARAMS ((int, int));
+#if 0
+static void OP_ONE PARAMS ((int, int));
+#endif
+static void OP_MMX PARAMS ((int, int));
+static void OP_EM PARAMS ((int, int));
+static void OP_MS PARAMS ((int, int));
+static void OP_3DNowSuffix PARAMS ((int, int));
+
+static void append_seg PARAMS ((void));
+static void set_op PARAMS ((unsigned int op));
+static void putop PARAMS ((char *template, int sizeflag));
+static void dofloat PARAMS ((int sizeflag));
+static int get16 PARAMS ((void));
+static int get32 PARAMS ((void));
+static void ckprefix PARAMS ((void));
+static void ptr_reg PARAMS ((int, int));
+
+#define b_mode 1
+#define v_mode 2
+#define w_mode 3
+#define d_mode 4
+#define x_mode 5
+
+#define es_reg 100
+#define cs_reg 101
+#define ss_reg 102
+#define ds_reg 103
+#define fs_reg 104
+#define gs_reg 105
+#define eAX_reg 107
+#define eCX_reg 108
+#define eDX_reg 109
+#define eBX_reg 110
+#define eSP_reg 111
+#define eBP_reg 112
+#define eSI_reg 113
+#define eDI_reg 114
+
+#define lptr 115
+
+#define al_reg 116
+#define cl_reg 117
+#define dl_reg 118
+#define bl_reg 119
+#define ah_reg 120
+#define ch_reg 121
+#define dh_reg 122
+#define bh_reg 123
+
+#define ax_reg 124
+#define cx_reg 125
+#define dx_reg 126
+#define bx_reg 127
+#define sp_reg 128
+#define bp_reg 129
+#define si_reg 130
+#define di_reg 131
+
+#define indir_dx_reg 150
+
+#define GRP1b NULL, NULL, 0
+#define GRP1S NULL, NULL, 1
+#define GRP1Ss NULL, NULL, 2
+#define GRP2b NULL, NULL, 3
+#define GRP2S NULL, NULL, 4
+#define GRP2b_one NULL, NULL, 5
+#define GRP2S_one NULL, NULL, 6
+#define GRP2b_cl NULL, NULL, 7
+#define GRP2S_cl NULL, NULL, 8
+#define GRP3b NULL, NULL, 9
+#define GRP3S NULL, NULL, 10
+#define GRP4 NULL, NULL, 11
+#define GRP5 NULL, NULL, 12
+#define GRP6 NULL, NULL, 13
+#define GRP7 NULL, NULL, 14
+#define GRP8 NULL, NULL, 15
+#define GRP9 NULL, NULL, 16
+#define GRP10 NULL, NULL, 17
+#define GRP11 NULL, NULL, 18
+#define GRP12 NULL, NULL, 19
+#define GRP13 NULL, NULL, 20
+#define GRP14 NULL, NULL, 21
+
+#define FLOATCODE 50
+#define FLOAT NULL, NULL, FLOATCODE
+
+struct dis386 {
+ char *name;
+ op_rtn op1;
+ int bytemode1;
+ op_rtn op2;
+ int bytemode2;
+ op_rtn op3;
+ int bytemode3;
+};
+
+/* Upper case letters in the instruction names here are macros.
+ 'A' => print 'b' if no register operands or suffix_always is true
+ 'B' => print 'b' if suffix_always is true
+ 'E' => print 'e' if 32-bit form of jcxz
+ 'L' => print 'l' if suffix_always is true
+ 'N' => print 'n' if instruction has no wait "prefix"
+ 'P' => print 'w' or 'l' if instruction has an operand size prefix,
+ or suffix_always is true
+ 'Q' => print 'w' or 'l' if no register operands or suffix_always is true
+ 'R' => print 'w' or 'l'
+ 'S' => print 'w' or 'l' if suffix_always is true
+ 'W' => print 'b' or 'w'
+*/
+
+static struct dis386 dis386_att[] = {
+ /* 00 */
+ { "addB", Eb, Gb },
+ { "addS", Ev, Gv },
+ { "addB", Gb, Eb },
+ { "addS", Gv, Ev },
+ { "addB", AL, Ib },
+ { "addS", eAX, Iv },
+ { "pushP", es },
+ { "popP", es },
+ /* 08 */
+ { "orB", Eb, Gb },
+ { "orS", Ev, Gv },
+ { "orB", Gb, Eb },
+ { "orS", Gv, Ev },
+ { "orB", AL, Ib },
+ { "orS", eAX, Iv },
+ { "pushP", cs },
+ { "(bad)" }, /* 0x0f extended opcode escape */
+ /* 10 */
+ { "adcB", Eb, Gb },
+ { "adcS", Ev, Gv },
+ { "adcB", Gb, Eb },
+ { "adcS", Gv, Ev },
+ { "adcB", AL, Ib },
+ { "adcS", eAX, Iv },
+ { "pushP", ss },
+ { "popP", ss },
+ /* 18 */
+ { "sbbB", Eb, Gb },
+ { "sbbS", Ev, Gv },
+ { "sbbB", Gb, Eb },
+ { "sbbS", Gv, Ev },
+ { "sbbB", AL, Ib },
+ { "sbbS", eAX, Iv },
+ { "pushP", ds },
+ { "popP", ds },
+ /* 20 */
+ { "andB", Eb, Gb },
+ { "andS", Ev, Gv },
+ { "andB", Gb, Eb },
+ { "andS", Gv, Ev },
+ { "andB", AL, Ib },
+ { "andS", eAX, Iv },
+ { "(bad)" }, /* SEG ES prefix */
+ { "daa" },
+ /* 28 */
+ { "subB", Eb, Gb },
+ { "subS", Ev, Gv },
+ { "subB", Gb, Eb },
+ { "subS", Gv, Ev },
+ { "subB", AL, Ib },
+ { "subS", eAX, Iv },
+ { "(bad)" }, /* SEG CS prefix */
+ { "das" },
+ /* 30 */
+ { "xorB", Eb, Gb },
+ { "xorS", Ev, Gv },
+ { "xorB", Gb, Eb },
+ { "xorS", Gv, Ev },
+ { "xorB", AL, Ib },
+ { "xorS", eAX, Iv },
+ { "(bad)" }, /* SEG SS prefix */
+ { "aaa" },
+ /* 38 */
+ { "cmpB", Eb, Gb },
+ { "cmpS", Ev, Gv },
+ { "cmpB", Gb, Eb },
+ { "cmpS", Gv, Ev },
+ { "cmpB", AL, Ib },
+ { "cmpS", eAX, Iv },
+ { "(bad)" }, /* SEG DS prefix */
+ { "aas" },
+ /* 40 */
+ { "incS", eAX },
+ { "incS", eCX },
+ { "incS", eDX },
+ { "incS", eBX },
+ { "incS", eSP },
+ { "incS", eBP },
+ { "incS", eSI },
+ { "incS", eDI },
+ /* 48 */
+ { "decS", eAX },
+ { "decS", eCX },
+ { "decS", eDX },
+ { "decS", eBX },
+ { "decS", eSP },
+ { "decS", eBP },
+ { "decS", eSI },
+ { "decS", eDI },
+ /* 50 */
+ { "pushS", eAX },
+ { "pushS", eCX },
+ { "pushS", eDX },
+ { "pushS", eBX },
+ { "pushS", eSP },
+ { "pushS", eBP },
+ { "pushS", eSI },
+ { "pushS", eDI },
+ /* 58 */
+ { "popS", eAX },
+ { "popS", eCX },
+ { "popS", eDX },
+ { "popS", eBX },
+ { "popS", eSP },
+ { "popS", eBP },
+ { "popS", eSI },
+ { "popS", eDI },
+ /* 60 */
+ { "pushaP" },
+ { "popaP" },
+ { "boundS", Gv, Ma },
+ { "arpl", Ew, Gw },
+ { "(bad)" }, /* seg fs */
+ { "(bad)" }, /* seg gs */
+ { "(bad)" }, /* op size prefix */
+ { "(bad)" }, /* adr size prefix */
+ /* 68 */
+ { "pushP", Iv }, /* 386 book wrong */
+ { "imulS", Gv, Ev, Iv },
+ { "pushP", sIb }, /* push of byte really pushes 2 or 4 bytes */
+ { "imulS", Gv, Ev, sIb },
+ { "insb", Yb, indirDX },
+ { "insR", Yv, indirDX },
+ { "outsb", indirDX, Xb },
+ { "outsR", indirDX, Xv },
+ /* 70 */
+ { "jo", Jb },
+ { "jno", Jb },
+ { "jb", Jb },
+ { "jae", Jb },
+ { "je", Jb },
+ { "jne", Jb },
+ { "jbe", Jb },
+ { "ja", Jb },
+ /* 78 */
+ { "js", Jb },
+ { "jns", Jb },
+ { "jp", Jb },
+ { "jnp", Jb },
+ { "jl", Jb },
+ { "jge", Jb },
+ { "jle", Jb },
+ { "jg", Jb },
+ /* 80 */
+ { GRP1b },
+ { GRP1S },
+ { "(bad)" },
+ { GRP1Ss },
+ { "testB", Eb, Gb },
+ { "testS", Ev, Gv },
+ { "xchgB", Eb, Gb },
+ { "xchgS", Ev, Gv },
+ /* 88 */
+ { "movB", Eb, Gb },
+ { "movS", Ev, Gv },
+ { "movB", Gb, Eb },
+ { "movS", Gv, Ev },
+ { "movQ", Ev, Sw },
+ { "leaS", Gv, M },
+ { "movQ", Sw, Ev },
+ { "popQ", Ev },
+ /* 90 */
+ { "nop" },
+ { "xchgS", eCX, eAX },
+ { "xchgS", eDX, eAX },
+ { "xchgS", eBX, eAX },
+ { "xchgS", eSP, eAX },
+ { "xchgS", eBP, eAX },
+ { "xchgS", eSI, eAX },
+ { "xchgS", eDI, eAX },
+ /* 98 */
+ { "cWtR" },
+ { "cRtd" },
+ { "lcallP", Ap },
+ { "(bad)" }, /* fwait */
+ { "pushfP" },
+ { "popfP" },
+ { "sahf" },
+ { "lahf" },
+ /* a0 */
+ { "movB", AL, Ob },
+ { "movS", eAX, Ov },
+ { "movB", Ob, AL },
+ { "movS", Ov, eAX },
+ { "movsb", Yb, Xb },
+ { "movsR", Yv, Xv },
+ { "cmpsb", Xb, Yb },
+ { "cmpsR", Xv, Yv },
+ /* a8 */
+ { "testB", AL, Ib },
+ { "testS", eAX, Iv },
+ { "stosB", Yb, AL },
+ { "stosS", Yv, eAX },
+ { "lodsB", AL, Xb },
+ { "lodsS", eAX, Xv },
+ { "scasB", AL, Yb },
+ { "scasS", eAX, Yv },
+ /* b0 */
+ { "movB", AL, Ib },
+ { "movB", CL, Ib },
+ { "movB", DL, Ib },
+ { "movB", BL, Ib },
+ { "movB", AH, Ib },
+ { "movB", CH, Ib },
+ { "movB", DH, Ib },
+ { "movB", BH, Ib },
+ /* b8 */
+ { "movS", eAX, Iv },
+ { "movS", eCX, Iv },
+ { "movS", eDX, Iv },
+ { "movS", eBX, Iv },
+ { "movS", eSP, Iv },
+ { "movS", eBP, Iv },
+ { "movS", eSI, Iv },
+ { "movS", eDI, Iv },
+ /* c0 */
+ { GRP2b },
+ { GRP2S },
+ { "retP", Iw },
+ { "retP" },
+ { "lesS", Gv, Mp },
+ { "ldsS", Gv, Mp },
+ { "movA", Eb, Ib },
+ { "movQ", Ev, Iv },
+ /* c8 */
+ { "enterP", Iw, Ib },
+ { "leaveP" },
+ { "lretP", Iw },
+ { "lretP" },
+ { "int3" },
+ { "int", Ib },
+ { "into" },
+ { "iretP" },
+ /* d0 */
+ { GRP2b_one },
+ { GRP2S_one },
+ { GRP2b_cl },
+ { GRP2S_cl },
+ { "aam", sIb },
+ { "aad", sIb },
+ { "(bad)" },
+ { "xlat", DSBX },
+ /* d8 */
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ /* e0 */
+ { "loopne", Jb },
+ { "loope", Jb },
+ { "loop", Jb },
+ { "jEcxz", Jb },
+ { "inB", AL, Ib },
+ { "inS", eAX, Ib },
+ { "outB", Ib, AL },
+ { "outS", Ib, eAX },
+ /* e8 */
+ { "callP", Av },
+ { "jmpP", Jv },
+ { "ljmpP", Ap },
+ { "jmp", Jb },
+ { "inB", AL, indirDX },
+ { "inS", eAX, indirDX },
+ { "outB", indirDX, AL },
+ { "outS", indirDX, eAX },
+ /* f0 */
+ { "(bad)" }, /* lock prefix */
+ { "(bad)" },
+ { "(bad)" }, /* repne */
+ { "(bad)" }, /* repz */
+ { "hlt" },
+ { "cmc" },
+ { GRP3b },
+ { GRP3S },
+ /* f8 */
+ { "clc" },
+ { "stc" },
+ { "cli" },
+ { "sti" },
+ { "cld" },
+ { "std" },
+ { GRP4 },
+ { GRP5 },
+};
+
+static struct dis386 dis386_intel[] = {
+ /* 00 */
+ { "addB", Eb, Gb },
+ { "addS", Ev, Gv },
+ { "addB", Gb, Eb },
+ { "addS", Gv, Ev },
+ { "addB", AL, Ib },
+ { "addS", eAX, Iv },
+ { "pushP", es },
+ { "popP", es },
+ /* 08 */
+ { "orB", Eb, Gb },
+ { "orS", Ev, Gv },
+ { "orB", Gb, Eb },
+ { "orS", Gv, Ev },
+ { "orB", AL, Ib },
+ { "orS", eAX, Iv },
+ { "pushP", cs },
+ { "(bad)" }, /* 0x0f extended opcode escape */
+ /* 10 */
+ { "adcB", Eb, Gb },
+ { "adcS", Ev, Gv },
+ { "adcB", Gb, Eb },
+ { "adcS", Gv, Ev },
+ { "adcB", AL, Ib },
+ { "adcS", eAX, Iv },
+ { "pushP", ss },
+ { "popP", ss },
+ /* 18 */
+ { "sbbB", Eb, Gb },
+ { "sbbS", Ev, Gv },
+ { "sbbB", Gb, Eb },
+ { "sbbS", Gv, Ev },
+ { "sbbB", AL, Ib },
+ { "sbbS", eAX, Iv },
+ { "pushP", ds },
+ { "popP", ds },
+ /* 20 */
+ { "andB", Eb, Gb },
+ { "andS", Ev, Gv },
+ { "andB", Gb, Eb },
+ { "andS", Gv, Ev },
+ { "andB", AL, Ib },
+ { "andS", eAX, Iv },
+ { "(bad)" }, /* SEG ES prefix */
+ { "daa" },
+ /* 28 */
+ { "subB", Eb, Gb },
+ { "subS", Ev, Gv },
+ { "subB", Gb, Eb },
+ { "subS", Gv, Ev },
+ { "subB", AL, Ib },
+ { "subS", eAX, Iv },
+ { "(bad)" }, /* SEG CS prefix */
+ { "das" },
+ /* 30 */
+ { "xorB", Eb, Gb },
+ { "xorS", Ev, Gv },
+ { "xorB", Gb, Eb },
+ { "xorS", Gv, Ev },
+ { "xorB", AL, Ib },
+ { "xorS", eAX, Iv },
+ { "(bad)" }, /* SEG SS prefix */
+ { "aaa" },
+ /* 38 */
+ { "cmpB", Eb, Gb },
+ { "cmpS", Ev, Gv },
+ { "cmpB", Gb, Eb },
+ { "cmpS", Gv, Ev },
+ { "cmpB", AL, Ib },
+ { "cmpS", eAX, Iv },
+ { "(bad)" }, /* SEG DS prefix */
+ { "aas" },
+ /* 40 */
+ { "incS", eAX },
+ { "incS", eCX },
+ { "incS", eDX },
+ { "incS", eBX },
+ { "incS", eSP },
+ { "incS", eBP },
+ { "incS", eSI },
+ { "incS", eDI },
+ /* 48 */
+ { "decS", eAX },
+ { "decS", eCX },
+ { "decS", eDX },
+ { "decS", eBX },
+ { "decS", eSP },
+ { "decS", eBP },
+ { "decS", eSI },
+ { "decS", eDI },
+ /* 50 */
+ { "pushS", eAX },
+ { "pushS", eCX },
+ { "pushS", eDX },
+ { "pushS", eBX },
+ { "pushS", eSP },
+ { "pushS", eBP },
+ { "pushS", eSI },
+ { "pushS", eDI },
+ /* 58 */
+ { "popS", eAX },
+ { "popS", eCX },
+ { "popS", eDX },
+ { "popS", eBX },
+ { "popS", eSP },
+ { "popS", eBP },
+ { "popS", eSI },
+ { "popS", eDI },
+ /* 60 */
+ { "pushaP" },
+ { "popaP" },
+ { "boundS", Gv, Ma },
+ { "arpl", Ew, Gw },
+ { "(bad)" }, /* seg fs */
+ { "(bad)" }, /* seg gs */
+ { "(bad)" }, /* op size prefix */
+ { "(bad)" }, /* adr size prefix */
+ /* 68 */
+ { "pushP", Iv }, /* 386 book wrong */
+ { "imulS", Gv, Ev, Iv },
+ { "pushP", sIb }, /* push of byte really pushes 2 or 4 bytes */
+ { "imulS", Gv, Ev, sIb },
+ { "insb", Yb, indirDX },
+ { "insR", Yv, indirDX },
+ { "outsb", indirDX, Xb },
+ { "outsR", indirDX, Xv },
+ /* 70 */
+ { "jo", Jb },
+ { "jno", Jb },
+ { "jb", Jb },
+ { "jae", Jb },
+ { "je", Jb },
+ { "jne", Jb },
+ { "jbe", Jb },
+ { "ja", Jb },
+ /* 78 */
+ { "js", Jb },
+ { "jns", Jb },
+ { "jp", Jb },
+ { "jnp", Jb },
+ { "jl", Jb },
+ { "jge", Jb },
+ { "jle", Jb },
+ { "jg", Jb },
+ /* 80 */
+ { GRP1b },
+ { GRP1S },
+ { "(bad)" },
+ { GRP1Ss },
+ { "testB", Eb, Gb },
+ { "testS", Ev, Gv },
+ { "xchgB", Eb, Gb },
+ { "xchgS", Ev, Gv },
+ /* 88 */
+ { "movB", Eb, Gb },
+ { "movS", Ev, Gv },
+ { "movB", Gb, Eb },
+ { "movS", Gv, Ev },
+ { "movQ", Ev, Sw },
+ { "leaS", Gv, M },
+ { "movQ", Sw, Ev },
+ { "popQ", Ev },
+ /* 90 */
+ { "nop" },
+ { "xchgS", eCX, eAX },
+ { "xchgS", eDX, eAX },
+ { "xchgS", eBX, eAX },
+ { "xchgS", eSP, eAX },
+ { "xchgS", eBP, eAX },
+ { "xchgS", eSI, eAX },
+ { "xchgS", eDI, eAX },
+ /* 98 */
+ { "cWtR" },
+ { "cRtd" },
+ { "lcallP", Ap },
+ { "(bad)" }, /* fwait */
+ { "pushfP" },
+ { "popfP" },
+ { "sahf" },
+ { "lahf" },
+ /* a0 */
+ { "movB", AL, Ob },
+ { "movS", eAX, Ov },
+ { "movB", Ob, AL },
+ { "movS", Ov, eAX },
+ { "movsb", Yb, Xb },
+ { "movsR", Yv, Xv },
+ { "cmpsb", Xb, Yb },
+ { "cmpsR", Xv, Yv },
+ /* a8 */
+ { "testB", AL, Ib },
+ { "testS", eAX, Iv },
+ { "stosB", Yb, AL },
+ { "stosS", Yv, eAX },
+ { "lodsB", AL, Xb },
+ { "lodsS", eAX, Xv },
+ { "scasB", AL, Yb },
+ { "scasS", eAX, Yv },
+ /* b0 */
+ { "movB", AL, Ib },
+ { "movB", CL, Ib },
+ { "movB", DL, Ib },
+ { "movB", BL, Ib },
+ { "movB", AH, Ib },
+ { "movB", CH, Ib },
+ { "movB", DH, Ib },
+ { "movB", BH, Ib },
+ /* b8 */
+ { "movS", eAX, Iv },
+ { "movS", eCX, Iv },
+ { "movS", eDX, Iv },
+ { "movS", eBX, Iv },
+ { "movS", eSP, Iv },
+ { "movS", eBP, Iv },
+ { "movS", eSI, Iv },
+ { "movS", eDI, Iv },
+ /* c0 */
+ { GRP2b },
+ { GRP2S },
+ { "retP", Iw },
+ { "retP" },
+ { "lesS", Gv, Mp },
+ { "ldsS", Gv, Mp },
+ { "movA", Eb, Ib },
+ { "movQ", Ev, Iv },
+ /* c8 */
+ { "enterP", Iw, Ib },
+ { "leaveP" },
+ { "lretP", Iw },
+ { "lretP" },
+ { "int3" },
+ { "int", Ib },
+ { "into" },
+ { "iretP" },
+ /* d0 */
+ { GRP2b_one },
+ { GRP2S_one },
+ { GRP2b_cl },
+ { GRP2S_cl },
+ { "aam", sIb },
+ { "aad", sIb },
+ { "(bad)" },
+ { "xlat", DSBX },
+ /* d8 */
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ { FLOAT },
+ /* e0 */
+ { "loopne", Jb },
+ { "loope", Jb },
+ { "loop", Jb },
+ { "jEcxz", Jb },
+ { "inB", AL, Ib },
+ { "inS", eAX, Ib },
+ { "outB", Ib, AL },
+ { "outS", Ib, eAX },
+ /* e8 */
+ { "callP", Av },
+ { "jmpP", Jv },
+ { "ljmpP", Ap },
+ { "jmp", Jb },
+ { "inB", AL, indirDX },
+ { "inS", eAX, indirDX },
+ { "outB", indirDX, AL },
+ { "outS", indirDX, eAX },
+ /* f0 */
+ { "(bad)" }, /* lock prefix */
+ { "(bad)" },
+ { "(bad)" }, /* repne */
+ { "(bad)" }, /* repz */
+ { "hlt" },
+ { "cmc" },
+ { GRP3b },
+ { GRP3S },
+ /* f8 */
+ { "clc" },
+ { "stc" },
+ { "cli" },
+ { "sti" },
+ { "cld" },
+ { "std" },
+ { GRP4 },
+ { GRP5 },
+};
+
+static struct dis386 dis386_twobyte_att[] = {
+ /* 00 */
+ { GRP6 },
+ { GRP7 },
+ { "larS", Gv, Ew },
+ { "lslS", Gv, Ew },
+ { "(bad)" },
+ { "(bad)" },
+ { "clts" },
+ { "(bad)" },
+ /* 08 */
+ { "invd" },
+ { "wbinvd" },
+ { "(bad)" },
+ { "ud2a" },
+ { "(bad)" },
+ { GRP14 },
+ { "femms" },
+ { "", MX, EM, OPSUF }, /* See OP_3DNowSuffix */
+ /* 10 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 18 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 20 */
+ /* these are all backward in appendix A of the intel book */
+ { "movL", Rd, Cd },
+ { "movL", Rd, Dd },
+ { "movL", Cd, Rd },
+ { "movL", Dd, Rd },
+ { "movL", Rd, Td },
+ { "(bad)" },
+ { "movL", Td, Rd },
+ { "(bad)" },
+ /* 28 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 30 */
+ { "wrmsr" }, { "rdtsc" }, { "rdmsr" }, { "rdpmc" },
+ { "sysenter" }, { "sysexit" }, { "(bad)" }, { "(bad)" },
+ /* 38 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 40 */
+ { "cmovo", Gv,Ev }, { "cmovno", Gv,Ev }, { "cmovb", Gv,Ev }, { "cmovae", Gv,Ev },
+ { "cmove", Gv,Ev }, { "cmovne", Gv,Ev }, { "cmovbe", Gv,Ev }, { "cmova", Gv,Ev },
+ /* 48 */
+ { "cmovs", Gv,Ev }, { "cmovns", Gv,Ev }, { "cmovp", Gv,Ev }, { "cmovnp", Gv,Ev },
+ { "cmovl", Gv,Ev }, { "cmovge", Gv,Ev }, { "cmovle", Gv,Ev }, { "cmovg", Gv,Ev },
+ /* 50 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 58 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 60 */
+ { "punpcklbw", MX, EM },
+ { "punpcklwd", MX, EM },
+ { "punpckldq", MX, EM },
+ { "packsswb", MX, EM },
+ { "pcmpgtb", MX, EM },
+ { "pcmpgtw", MX, EM },
+ { "pcmpgtd", MX, EM },
+ { "packuswb", MX, EM },
+ /* 68 */
+ { "punpckhbw", MX, EM },
+ { "punpckhwd", MX, EM },
+ { "punpckhdq", MX, EM },
+ { "packssdw", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ { "movd", MX, Ev },
+ { "movq", MX, EM },
+ /* 70 */
+ { "(bad)" },
+ { GRP10 },
+ { GRP11 },
+ { GRP12 },
+ { "pcmpeqb", MX, EM },
+ { "pcmpeqw", MX, EM },
+ { "pcmpeqd", MX, EM },
+ { "emms" },
+ /* 78 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" },
+ { "movd", Ev, MX },
+ { "movq", EM, MX },
+ /* 80 */
+ { "jo", Jv },
+ { "jno", Jv },
+ { "jb", Jv },
+ { "jae", Jv },
+ { "je", Jv },
+ { "jne", Jv },
+ { "jbe", Jv },
+ { "ja", Jv },
+ /* 88 */
+ { "js", Jv },
+ { "jns", Jv },
+ { "jp", Jv },
+ { "jnp", Jv },
+ { "jl", Jv },
+ { "jge", Jv },
+ { "jle", Jv },
+ { "jg", Jv },
+ /* 90 */
+ { "seto", Eb },
+ { "setno", Eb },
+ { "setb", Eb },
+ { "setae", Eb },
+ { "sete", Eb },
+ { "setne", Eb },
+ { "setbe", Eb },
+ { "seta", Eb },
+ /* 98 */
+ { "sets", Eb },
+ { "setns", Eb },
+ { "setp", Eb },
+ { "setnp", Eb },
+ { "setl", Eb },
+ { "setge", Eb },
+ { "setle", Eb },
+ { "setg", Eb },
+ /* a0 */
+ { "pushP", fs },
+ { "popP", fs },
+ { "cpuid" },
+ { "btS", Ev, Gv },
+ { "shldS", Ev, Gv, Ib },
+ { "shldS", Ev, Gv, CL },
+ { "(bad)" },
+ { "(bad)" },
+ /* a8 */
+ { "pushP", gs },
+ { "popP", gs },
+ { "rsm" },
+ { "btsS", Ev, Gv },
+ { "shrdS", Ev, Gv, Ib },
+ { "shrdS", Ev, Gv, CL },
+ { GRP13 },
+ { "imulS", Gv, Ev },
+ /* b0 */
+ { "cmpxchgB", Eb, Gb },
+ { "cmpxchgS", Ev, Gv },
+ { "lssS", Gv, Mp }, /* 386 lists only Mp */
+ { "btrS", Ev, Gv },
+ { "lfsS", Gv, Mp }, /* 386 lists only Mp */
+ { "lgsS", Gv, Mp }, /* 386 lists only Mp */
+ { "movzbR", Gv, Eb },
+ { "movzwR", Gv, Ew }, /* yes, there really is movzww ! */
+ /* b8 */
+ { "(bad)" },
+ { "ud2b" },
+ { GRP8 },
+ { "btcS", Ev, Gv },
+ { "bsfS", Gv, Ev },
+ { "bsrS", Gv, Ev },
+ { "movsbR", Gv, Eb },
+ { "movswR", Gv, Ew }, /* yes, there really is movsww ! */
+ /* c0 */
+ { "xaddB", Eb, Gb },
+ { "xaddS", Ev, Gv },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { GRP9 },
+ /* c8 */
+ { "bswap", eAX }, /* bswap doesn't support 16 bit regs */
+ { "bswap", eCX },
+ { "bswap", eDX },
+ { "bswap", eBX },
+ { "bswap", eSP },
+ { "bswap", eBP },
+ { "bswap", eSI },
+ { "bswap", eDI },
+ /* d0 */
+ { "(bad)" },
+ { "psrlw", MX, EM },
+ { "psrld", MX, EM },
+ { "psrlq", MX, EM },
+ { "(bad)" },
+ { "pmullw", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ /* d8 */
+ { "psubusb", MX, EM },
+ { "psubusw", MX, EM },
+ { "(bad)" },
+ { "pand", MX, EM },
+ { "paddusb", MX, EM },
+ { "paddusw", MX, EM },
+ { "(bad)" },
+ { "pandn", MX, EM },
+ /* e0 */
+ { "(bad)" },
+ { "psraw", MX, EM },
+ { "psrad", MX, EM },
+ { "(bad)" },
+ { "(bad)" },
+ { "pmulhw", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ /* e8 */
+ { "psubsb", MX, EM },
+ { "psubsw", MX, EM },
+ { "(bad)" },
+ { "por", MX, EM },
+ { "paddsb", MX, EM },
+ { "paddsw", MX, EM },
+ { "(bad)" },
+ { "pxor", MX, EM },
+ /* f0 */
+ { "(bad)" },
+ { "psllw", MX, EM },
+ { "pslld", MX, EM },
+ { "psllq", MX, EM },
+ { "(bad)" },
+ { "pmaddwd", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ /* f8 */
+ { "psubb", MX, EM },
+ { "psubw", MX, EM },
+ { "psubd", MX, EM },
+ { "(bad)" },
+ { "paddb", MX, EM },
+ { "paddw", MX, EM },
+ { "paddd", MX, EM },
+ { "(bad)" }
+};
+
+static struct dis386 dis386_twobyte_intel[] = {
+ /* 00 */
+ { GRP6 },
+ { GRP7 },
+ { "larS", Gv, Ew },
+ { "lslS", Gv, Ew },
+ { "(bad)" },
+ { "(bad)" },
+ { "clts" },
+ { "(bad)" },
+ /* 08 */
+ { "invd" },
+ { "wbinvd" },
+ { "(bad)" },
+ { "ud2a" },
+ { "(bad)" },
+ { GRP14 },
+ { "femms" },
+ { "", MX, EM, OPSUF }, /* See OP_3DNowSuffix */
+ /* 10 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 18 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 20 */
+ /* these are all backward in appendix A of the intel book */
+ { "movL", Rd, Cd },
+ { "movL", Rd, Dd },
+ { "movL", Cd, Rd },
+ { "movL", Dd, Rd },
+ { "movL", Rd, Td },
+ { "(bad)" },
+ { "movL", Td, Rd },
+ { "(bad)" },
+ /* 28 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 30 */
+ { "wrmsr" }, { "rdtsc" }, { "rdmsr" }, { "rdpmc" },
+ { "sysenter" }, { "sysexit" }, { "(bad)" }, { "(bad)" },
+ /* 38 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 40 */
+ { "cmovo", Gv,Ev }, { "cmovno", Gv,Ev }, { "cmovb", Gv,Ev }, { "cmovae", Gv,Ev },
+ { "cmove", Gv,Ev }, { "cmovne", Gv,Ev }, { "cmovbe", Gv,Ev }, { "cmova", Gv,Ev },
+ /* 48 */
+ { "cmovs", Gv,Ev }, { "cmovns", Gv,Ev }, { "cmovp", Gv,Ev }, { "cmovnp", Gv,Ev },
+ { "cmovl", Gv,Ev }, { "cmovge", Gv,Ev }, { "cmovle", Gv,Ev }, { "cmovg", Gv,Ev },
+ /* 50 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 58 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ /* 60 */
+ { "punpcklbw", MX, EM },
+ { "punpcklwd", MX, EM },
+ { "punpckldq", MX, EM },
+ { "packsswb", MX, EM },
+ { "pcmpgtb", MX, EM },
+ { "pcmpgtw", MX, EM },
+ { "pcmpgtd", MX, EM },
+ { "packuswb", MX, EM },
+ /* 68 */
+ { "punpckhbw", MX, EM },
+ { "punpckhwd", MX, EM },
+ { "punpckhdq", MX, EM },
+ { "packssdw", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ { "movd", MX, Ev },
+ { "movq", MX, EM },
+ /* 70 */
+ { "(bad)" },
+ { GRP10 },
+ { GRP11 },
+ { GRP12 },
+ { "pcmpeqb", MX, EM },
+ { "pcmpeqw", MX, EM },
+ { "pcmpeqd", MX, EM },
+ { "emms" },
+ /* 78 */
+ { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
+ { "(bad)" }, { "(bad)" },
+ { "movd", Ev, MX },
+ { "movq", EM, MX },
+ /* 80 */
+ { "jo", Jv },
+ { "jno", Jv },
+ { "jb", Jv },
+ { "jae", Jv },
+ { "je", Jv },
+ { "jne", Jv },
+ { "jbe", Jv },
+ { "ja", Jv },
+ /* 88 */
+ { "js", Jv },
+ { "jns", Jv },
+ { "jp", Jv },
+ { "jnp", Jv },
+ { "jl", Jv },
+ { "jge", Jv },
+ { "jle", Jv },
+ { "jg", Jv },
+ /* 90 */
+ { "seto", Eb },
+ { "setno", Eb },
+ { "setb", Eb },
+ { "setae", Eb },
+ { "sete", Eb },
+ { "setne", Eb },
+ { "setbe", Eb },
+ { "seta", Eb },
+ /* 98 */
+ { "sets", Eb },
+ { "setns", Eb },
+ { "setp", Eb },
+ { "setnp", Eb },
+ { "setl", Eb },
+ { "setge", Eb },
+ { "setle", Eb },
+ { "setg", Eb },
+ /* a0 */
+ { "pushP", fs },
+ { "popP", fs },
+ { "cpuid" },
+ { "btS", Ev, Gv },
+ { "shldS", Ev, Gv, Ib },
+ { "shldS", Ev, Gv, CL },
+ { "(bad)" },
+ { "(bad)" },
+ /* a8 */
+ { "pushP", gs },
+ { "popP", gs },
+ { "rsm" },
+ { "btsS", Ev, Gv },
+ { "shrdS", Ev, Gv, Ib },
+ { "shrdS", Ev, Gv, CL },
+ { GRP13 },
+ { "imulS", Gv, Ev },
+ /* b0 */
+ { "cmpxchgB", Eb, Gb },
+ { "cmpxchgS", Ev, Gv },
+ { "lssS", Gv, Mp }, /* 386 lists only Mp */
+ { "btrS", Ev, Gv },
+ { "lfsS", Gv, Mp }, /* 386 lists only Mp */
+ { "lgsS", Gv, Mp }, /* 386 lists only Mp */
+ { "movzx", Gv, Eb },
+ { "movzx", Gv, Ew },
+ /* b8 */
+ { "(bad)" },
+ { "ud2b" },
+ { GRP8 },
+ { "btcS", Ev, Gv },
+ { "bsfS", Gv, Ev },
+ { "bsrS", Gv, Ev },
+ { "movsx", Gv, Eb },
+ { "movsx", Gv, Ew },
+ /* c0 */
+ { "xaddB", Eb, Gb },
+ { "xaddS", Ev, Gv },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { GRP9 },
+ /* c8 */
+ { "bswap", eAX }, /* bswap doesn't support 16 bit regs */
+ { "bswap", eCX },
+ { "bswap", eDX },
+ { "bswap", eBX },
+ { "bswap", eSP },
+ { "bswap", eBP },
+ { "bswap", eSI },
+ { "bswap", eDI },
+ /* d0 */
+ { "(bad)" },
+ { "psrlw", MX, EM },
+ { "psrld", MX, EM },
+ { "psrlq", MX, EM },
+ { "(bad)" },
+ { "pmullw", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ /* d8 */
+ { "psubusb", MX, EM },
+ { "psubusw", MX, EM },
+ { "(bad)" },
+ { "pand", MX, EM },
+ { "paddusb", MX, EM },
+ { "paddusw", MX, EM },
+ { "(bad)" },
+ { "pandn", MX, EM },
+ /* e0 */
+ { "(bad)" },
+ { "psraw", MX, EM },
+ { "psrad", MX, EM },
+ { "(bad)" },
+ { "(bad)" },
+ { "pmulhw", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ /* e8 */
+ { "psubsb", MX, EM },
+ { "psubsw", MX, EM },
+ { "(bad)" },
+ { "por", MX, EM },
+ { "paddsb", MX, EM },
+ { "paddsw", MX, EM },
+ { "(bad)" },
+ { "pxor", MX, EM },
+ /* f0 */
+ { "(bad)" },
+ { "psllw", MX, EM },
+ { "pslld", MX, EM },
+ { "psllq", MX, EM },
+ { "(bad)" },
+ { "pmaddwd", MX, EM },
+ { "(bad)" }, { "(bad)" },
+ /* f8 */
+ { "psubb", MX, EM },
+ { "psubw", MX, EM },
+ { "psubd", MX, EM },
+ { "(bad)" },
+ { "paddb", MX, EM },
+ { "paddw", MX, EM },
+ { "paddd", MX, EM },
+ { "(bad)" }
+};
+
+static const unsigned char onebyte_has_modrm[256] = {
+ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,
+ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,
+ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,
+ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,
+ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1
+};
+
+static const unsigned char twobyte_has_modrm[256] = {
+ /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
+ /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
+ /* 20 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* 2f */
+ /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
+ /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
+ /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
+ /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1, /* 6f */
+ /* 70 */ 0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1, /* 7f */
+ /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
+ /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
+ /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
+ /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
+ /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
+ /* d0 */ 0,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1, /* df */
+ /* e0 */ 0,1,1,0,0,1,0,0,1,1,0,1,1,1,0,1, /* ef */
+ /* f0 */ 0,1,1,1,0,1,0,0,1,1,1,0,1,1,1,0 /* ff */
+};
+
+static char obuf[100];
+static char *obufp;
+static char scratchbuf[100];
+static unsigned char *start_codep;
+static unsigned char *insn_codep;
+static unsigned char *codep;
+static disassemble_info *the_info;
+static int mod;
+static int rm;
+static int reg;
+static void oappend PARAMS ((char *s));
+
+static char *names32[]={
+ "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi",
+};
+static char *names16[] = {
+ "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di",
+};
+static char *names8[] = {
+ "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh",
+};
+static char *names_seg[] = {
+ "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
+};
+static char *index16[] = {
+ "%bx,%si","%bx,%di","%bp,%si","%bp,%di","%si","%di","%bp","%bx"
+};
+
+static struct dis386 grps[][8] = {
+ /* GRP1b */
+ {
+ { "addA", Eb, Ib },
+ { "orA", Eb, Ib },
+ { "adcA", Eb, Ib },
+ { "sbbA", Eb, Ib },
+ { "andA", Eb, Ib },
+ { "subA", Eb, Ib },
+ { "xorA", Eb, Ib },
+ { "cmpA", Eb, Ib }
+ },
+ /* GRP1S */
+ {
+ { "addQ", Ev, Iv },
+ { "orQ", Ev, Iv },
+ { "adcQ", Ev, Iv },
+ { "sbbQ", Ev, Iv },
+ { "andQ", Ev, Iv },
+ { "subQ", Ev, Iv },
+ { "xorQ", Ev, Iv },
+ { "cmpQ", Ev, Iv }
+ },
+ /* GRP1Ss */
+ {
+ { "addQ", Ev, sIb },
+ { "orQ", Ev, sIb },
+ { "adcQ", Ev, sIb },
+ { "sbbQ", Ev, sIb },
+ { "andQ", Ev, sIb },
+ { "subQ", Ev, sIb },
+ { "xorQ", Ev, sIb },
+ { "cmpQ", Ev, sIb }
+ },
+ /* GRP2b */
+ {
+ { "rolA", Eb, Ib },
+ { "rorA", Eb, Ib },
+ { "rclA", Eb, Ib },
+ { "rcrA", Eb, Ib },
+ { "shlA", Eb, Ib },
+ { "shrA", Eb, Ib },
+ { "(bad)" },
+ { "sarA", Eb, Ib },
+ },
+ /* GRP2S */
+ {
+ { "rolQ", Ev, Ib },
+ { "rorQ", Ev, Ib },
+ { "rclQ", Ev, Ib },
+ { "rcrQ", Ev, Ib },
+ { "shlQ", Ev, Ib },
+ { "shrQ", Ev, Ib },
+ { "(bad)" },
+ { "sarQ", Ev, Ib },
+ },
+ /* GRP2b_one */
+ {
+ { "rolA", Eb },
+ { "rorA", Eb },
+ { "rclA", Eb },
+ { "rcrA", Eb },
+ { "shlA", Eb },
+ { "shrA", Eb },
+ { "(bad)" },
+ { "sarA", Eb },
+ },
+ /* GRP2S_one */
+ {
+ { "rolQ", Ev },
+ { "rorQ", Ev },
+ { "rclQ", Ev },
+ { "rcrQ", Ev },
+ { "shlQ", Ev },
+ { "shrQ", Ev },
+ { "(bad)" },
+ { "sarQ", Ev },
+ },
+ /* GRP2b_cl */
+ {
+ { "rolA", Eb, CL },
+ { "rorA", Eb, CL },
+ { "rclA", Eb, CL },
+ { "rcrA", Eb, CL },
+ { "shlA", Eb, CL },
+ { "shrA", Eb, CL },
+ { "(bad)" },
+ { "sarA", Eb, CL },
+ },
+ /* GRP2S_cl */
+ {
+ { "rolQ", Ev, CL },
+ { "rorQ", Ev, CL },
+ { "rclQ", Ev, CL },
+ { "rcrQ", Ev, CL },
+ { "shlQ", Ev, CL },
+ { "shrQ", Ev, CL },
+ { "(bad)" },
+ { "sarQ", Ev, CL }
+ },
+ /* GRP3b */
+ {
+ { "testA", Eb, Ib },
+ { "(bad)", Eb },
+ { "notA", Eb },
+ { "negA", Eb },
+ { "mulB", AL, Eb },
+ { "imulB", AL, Eb },
+ { "divB", AL, Eb },
+ { "idivB", AL, Eb }
+ },
+ /* GRP3S */
+ {
+ { "testQ", Ev, Iv },
+ { "(bad)" },
+ { "notQ", Ev },
+ { "negQ", Ev },
+ { "mulS", eAX, Ev },
+ { "imulS", eAX, Ev },
+ { "divS", eAX, Ev },
+ { "idivS", eAX, Ev },
+ },
+ /* GRP4 */
+ {
+ { "incA", Eb },
+ { "decA", Eb },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ },
+ /* GRP5 */
+ {
+ { "incQ", Ev },
+ { "decQ", Ev },
+ { "callP", indirEv },
+ { "callP", indirEv },
+ { "jmpP", indirEv },
+ { "ljmpP", indirEv },
+ { "pushQ", Ev },
+ { "(bad)" },
+ },
+ /* GRP6 */
+ {
+ { "sldt", Ew },
+ { "str", Ew },
+ { "lldt", Ew },
+ { "ltr", Ew },
+ { "verr", Ew },
+ { "verw", Ew },
+ { "(bad)" },
+ { "(bad)" }
+ },
+ /* GRP7 */
+ {
+ { "sgdt", Ew },
+ { "sidt", Ew },
+ { "lgdt", Ew },
+ { "lidt", Ew },
+ { "smsw", Ew },
+ { "(bad)" },
+ { "lmsw", Ew },
+ { "invlpg", Ew },
+ },
+ /* GRP8 */
+ {
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "btQ", Ev, Ib },
+ { "btsQ", Ev, Ib },
+ { "btrQ", Ev, Ib },
+ { "btcQ", Ev, Ib },
+ },
+ /* GRP9 */
+ {
+ { "(bad)" },
+ { "cmpxchg8b", Ev },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ },
+ /* GRP10 */
+ {
+ { "(bad)" },
+ { "(bad)" },
+ { "psrlw", MS, Ib },
+ { "(bad)" },
+ { "psraw", MS, Ib },
+ { "(bad)" },
+ { "psllw", MS, Ib },
+ { "(bad)" },
+ },
+ /* GRP11 */
+ {
+ { "(bad)" },
+ { "(bad)" },
+ { "psrld", MS, Ib },
+ { "(bad)" },
+ { "psrad", MS, Ib },
+ { "(bad)" },
+ { "pslld", MS, Ib },
+ { "(bad)" },
+ },
+ /* GRP12 */
+ {
+ { "(bad)" },
+ { "(bad)" },
+ { "psrlq", MS, Ib },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "psllq", MS, Ib },
+ { "(bad)" },
+ },
+ /* GRP13 */
+ {
+ { "fxsave", Ev },
+ { "fxrstor", Ev },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ },
+ /* GRP14 */
+ {
+ { "prefetch", Eb },
+ { "prefetchw", Eb },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ }
+
+};
+
+#define PREFIX_REPZ 1
+#define PREFIX_REPNZ 2
+#define PREFIX_LOCK 4
+#define PREFIX_CS 8
+#define PREFIX_SS 0x10
+#define PREFIX_DS 0x20
+#define PREFIX_ES 0x40
+#define PREFIX_FS 0x80
+#define PREFIX_GS 0x100
+#define PREFIX_DATA 0x200
+#define PREFIX_ADDR 0x400
+#define PREFIX_FWAIT 0x800
+
+static int prefixes;
+
+static void
+ckprefix ()
+{
+ prefixes = 0;
+ while (1)
+ {
+ FETCH_DATA (the_info, codep + 1);
+ switch (*codep)
+ {
+ case 0xf3:
+ prefixes |= PREFIX_REPZ;
+ break;
+ case 0xf2:
+ prefixes |= PREFIX_REPNZ;
+ break;
+ case 0xf0:
+ prefixes |= PREFIX_LOCK;
+ break;
+ case 0x2e:
+ prefixes |= PREFIX_CS;
+ break;
+ case 0x36:
+ prefixes |= PREFIX_SS;
+ break;
+ case 0x3e:
+ prefixes |= PREFIX_DS;
+ break;
+ case 0x26:
+ prefixes |= PREFIX_ES;
+ break;
+ case 0x64:
+ prefixes |= PREFIX_FS;
+ break;
+ case 0x65:
+ prefixes |= PREFIX_GS;
+ break;
+ case 0x66:
+ prefixes |= PREFIX_DATA;
+ break;
+ case 0x67:
+ prefixes |= PREFIX_ADDR;
+ break;
+ case 0x9b:
+ /* fwait is really an instruction. If there are prefixes
+ before the fwait, they belong to the fwait, *not* to the
+ following instruction. */
+ if (prefixes)
+ {
+ prefixes |= PREFIX_FWAIT;
+ codep++;
+ return;
+ }
+ prefixes = PREFIX_FWAIT;
+ break;
+ default:
+ return;
+ }
+ codep++;
+ }
+}
+
+static char op1out[100], op2out[100], op3out[100];
+static int op_ad, op_index[3];
+static unsigned int op_address[3];
+static unsigned int start_pc;
+
+
+/*
+ * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
+ * (see topic "Redundant prefixes" in the "Differences from 8086"
+ * section of the "Virtual 8086 Mode" chapter.)
+ * 'pc' should be the address of this instruction, it will
+ * be used to print the target address if this is a relative jump or call
+ * The function returns the length of this instruction in bytes.
+ */
+
+static int print_insn_x86
+ PARAMS ((bfd_vma pc, disassemble_info *info, int sizeflag));
+static int print_insn_i386
+ PARAMS ((bfd_vma pc, disassemble_info *info));
+
+static char intel_syntax;
+static char open_char;
+static char close_char;
+static char separator_char;
+static char scale_char;
+
+int
+print_insn_i386_att (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ intel_syntax = 0;
+ open_char = '(';
+ close_char = ')';
+ separator_char = ',';
+ scale_char = ',';
+
+ return print_insn_i386 (pc, info);
+}
+
+int
+print_insn_i386_intel (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ intel_syntax = 1;
+ open_char = '[';
+ close_char = ']';
+ separator_char = '+';
+ scale_char = '*';
+
+ return print_insn_i386 (pc, info);
+}
+
+static int
+print_insn_i386 (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ int flags;
+ if (info->mach == bfd_mach_i386_i386
+ || info->mach == bfd_mach_i386_i386_intel_syntax)
+ flags = AFLAG|DFLAG;
+ else if (info->mach == bfd_mach_i386_i8086)
+ flags = 0;
+ else
+ abort ();
+ return print_insn_x86 (pc, info, flags);
+}
+
+static int
+print_insn_x86 (pc, info, sizeflag)
+ bfd_vma pc;
+ disassemble_info *info;
+ int sizeflag;
+{
+ struct dis386 *dp;
+ int i;
+ int two_source_ops;
+ char *first, *second, *third;
+ int needcomma;
+ unsigned char need_modrm;
+
+ struct dis_private priv;
+ bfd_byte *inbuf = priv.the_buffer;
+
+ /* The output looks better if we put 5 bytes on a line, since that
+ puts long word instructions on a single line. */
+ info->bytes_per_line = 5;
+
+ info->private_data = (PTR) &priv;
+ priv.max_fetched = priv.the_buffer;
+ priv.insn_start = pc;
+ if (setjmp (priv.bailout) != 0)
+ /* Error return. */
+ return -1;
+
+ obuf[0] = 0;
+ op1out[0] = 0;
+ op2out[0] = 0;
+ op3out[0] = 0;
+
+ op_index[0] = op_index[1] = op_index[2] = -1;
+
+ the_info = info;
+ start_pc = pc;
+ start_codep = inbuf;
+ codep = inbuf;
+
+ ckprefix ();
+
+ insn_codep = codep;
+
+ FETCH_DATA (info, codep + 1);
+ two_source_ops = (*codep == 0x62) || (*codep == 0xc8);
+
+ obufp = obuf;
+
+ if ((prefixes & PREFIX_FWAIT)
+ && ((*codep < 0xd8) || (*codep > 0xdf)))
+ {
+ /* fwait not followed by floating point instruction. */
+ (*info->fprintf_func) (info->stream, "fwait");
+ /* There may be other prefixes. Skip any before the fwait. */
+ return codep - inbuf;
+ }
+
+ if (prefixes & PREFIX_REPZ)
+ oappend ("repz ");
+ if (prefixes & PREFIX_REPNZ)
+ oappend ("repnz ");
+ if (prefixes & PREFIX_LOCK)
+ oappend ("lock ");
+
+ if (prefixes & PREFIX_DATA)
+ sizeflag ^= DFLAG;
+
+ if (prefixes & PREFIX_ADDR)
+ {
+ sizeflag ^= AFLAG;
+ if (sizeflag & AFLAG)
+ oappend ("addr32 ");
+ else
+ oappend ("addr16 ");
+ }
+
+ if (*codep == 0x0f)
+ {
+ FETCH_DATA (info, codep + 2);
+ if (intel_syntax)
+ dp = &dis386_twobyte_intel[*++codep];
+ else
+ dp = &dis386_twobyte_att[*++codep];
+ need_modrm = twobyte_has_modrm[*codep];
+ }
+ else
+ {
+ if (intel_syntax)
+ dp = &dis386_intel[*codep];
+ else
+ dp = &dis386_att[*codep];
+ need_modrm = onebyte_has_modrm[*codep];
+ }
+ codep++;
+
+ if (need_modrm)
+ {
+ FETCH_DATA (info, codep + 1);
+ mod = (*codep >> 6) & 3;
+ reg = (*codep >> 3) & 7;
+ rm = *codep & 7;
+ }
+
+ if (dp->name == NULL && dp->bytemode1 == FLOATCODE)
+ {
+ dofloat (sizeflag);
+ }
+ else
+ {
+ if (dp->name == NULL)
+ dp = &grps[dp->bytemode1][reg];
+
+ putop (dp->name, sizeflag);
+
+ obufp = op1out;
+ op_ad = 2;
+ if (dp->op1)
+ (*dp->op1)(dp->bytemode1, sizeflag);
+
+ obufp = op2out;
+ op_ad = 1;
+ if (dp->op2)
+ (*dp->op2)(dp->bytemode2, sizeflag);
+
+ obufp = op3out;
+ op_ad = 0;
+ if (dp->op3)
+ (*dp->op3)(dp->bytemode3, sizeflag);
+ }
+
+ obufp = obuf + strlen (obuf);
+ for (i = strlen (obuf); i < 6; i++)
+ oappend (" ");
+ oappend (" ");
+ (*info->fprintf_func) (info->stream, "%s", obuf);
+
+ /* The enter and bound instructions are printed with operands in the same
+ order as the intel book; everything else is printed in reverse order. */
+ if (intel_syntax || two_source_ops)
+ {
+ first = op1out;
+ second = op2out;
+ third = op3out;
+ op_ad = op_index[0];
+ op_index[0] = op_index[2];
+ op_index[2] = op_ad;
+ }
+ else
+ {
+ first = op3out;
+ second = op2out;
+ third = op1out;
+ }
+ needcomma = 0;
+ if (*first)
+ {
+ if (op_index[0] != -1)
+ (*info->print_address_func) ((bfd_vma) op_address[op_index[0]], info);
+ else
+ (*info->fprintf_func) (info->stream, "%s", first);
+ needcomma = 1;
+ }
+ if (*second)
+ {
+ if (needcomma)
+ (*info->fprintf_func) (info->stream, ",");
+ if (op_index[1] != -1)
+ (*info->print_address_func) ((bfd_vma) op_address[op_index[1]], info);
+ else
+ (*info->fprintf_func) (info->stream, "%s", second);
+ needcomma = 1;
+ }
+ if (*third)
+ {
+ if (needcomma)
+ (*info->fprintf_func) (info->stream, ",");
+ if (op_index[2] != -1)
+ (*info->print_address_func) ((bfd_vma) op_address[op_index[2]], info);
+ else
+ (*info->fprintf_func) (info->stream, "%s", third);
+ }
+ return codep - inbuf;
+}
+
+static char *float_mem_att[] = {
+ /* d8 */
+ "fadds",
+ "fmuls",
+ "fcoms",
+ "fcomps",
+ "fsubs",
+ "fsubrs",
+ "fdivs",
+ "fdivrs",
+ /* d9 */
+ "flds",
+ "(bad)",
+ "fsts",
+ "fstps",
+ "fldenv",
+ "fldcw",
+ "fNstenv",
+ "fNstcw",
+ /* da */
+ "fiaddl",
+ "fimull",
+ "ficoml",
+ "ficompl",
+ "fisubl",
+ "fisubrl",
+ "fidivl",
+ "fidivrl",
+ /* db */
+ "fildl",
+ "(bad)",
+ "fistl",
+ "fistpl",
+ "(bad)",
+ "fldt",
+ "(bad)",
+ "fstpt",
+ /* dc */
+ "faddl",
+ "fmull",
+ "fcoml",
+ "fcompl",
+ "fsubl",
+ "fsubrl",
+ "fdivl",
+ "fdivrl",
+ /* dd */
+ "fldl",
+ "(bad)",
+ "fstl",
+ "fstpl",
+ "frstor",
+ "(bad)",
+ "fNsave",
+ "fNstsw",
+ /* de */
+ "fiadd",
+ "fimul",
+ "ficom",
+ "ficomp",
+ "fisub",
+ "fisubr",
+ "fidiv",
+ "fidivr",
+ /* df */
+ "fild",
+ "(bad)",
+ "fist",
+ "fistp",
+ "fbld",
+ "fildll",
+ "fbstp",
+ "fistpll",
+};
+
+static char *float_mem_intel[] = {
+ /* d8 */
+ "fadd",
+ "fmul",
+ "fcom",
+ "fcomp",
+ "fsub",
+ "fsubr",
+ "fdiv",
+ "fdivr",
+ /* d9 */
+ "fld",
+ "(bad)",
+ "fst",
+ "fstp",
+ "fldenv",
+ "fldcw",
+ "fNstenv",
+ "fNstcw",
+ /* da */
+ "fiadd",
+ "fimul",
+ "ficom",
+ "ficomp",
+ "fisub",
+ "fisubr",
+ "fidiv",
+ "fidivr",
+ /* db */
+ "fild",
+ "(bad)",
+ "fist",
+ "fistp",
+ "(bad)",
+ "fld",
+ "(bad)",
+ "fstp",
+ /* dc */
+ "fadd",
+ "fmul",
+ "fcom",
+ "fcomp",
+ "fsub",
+ "fsubr",
+ "fdiv",
+ "fdivr",
+ /* dd */
+ "fld",
+ "(bad)",
+ "fst",
+ "fstp",
+ "frstor",
+ "(bad)",
+ "fNsave",
+ "fNstsw",
+ /* de */
+ "fiadd",
+ "fimul",
+ "ficom",
+ "ficomp",
+ "fisub",
+ "fisubr",
+ "fidiv",
+ "fidivr",
+ /* df */
+ "fild",
+ "(bad)",
+ "fist",
+ "fistp",
+ "fbld",
+ "fild",
+ "fbstp",
+ "fistpll",
+};
+
+#define ST OP_ST, 0
+#define STi OP_STi, 0
+
+#define FGRPd9_2 NULL, NULL, 0
+#define FGRPd9_4 NULL, NULL, 1
+#define FGRPd9_5 NULL, NULL, 2
+#define FGRPd9_6 NULL, NULL, 3
+#define FGRPd9_7 NULL, NULL, 4
+#define FGRPda_5 NULL, NULL, 5
+#define FGRPdb_4 NULL, NULL, 6
+#define FGRPde_3 NULL, NULL, 7
+#define FGRPdf_4 NULL, NULL, 8
+
+static struct dis386 float_reg[][8] = {
+ /* d8 */
+ {
+ { "fadd", ST, STi },
+ { "fmul", ST, STi },
+ { "fcom", STi },
+ { "fcomp", STi },
+ { "fsub", ST, STi },
+ { "fsubr", ST, STi },
+ { "fdiv", ST, STi },
+ { "fdivr", ST, STi },
+ },
+ /* d9 */
+ {
+ { "fld", STi },
+ { "fxch", STi },
+ { FGRPd9_2 },
+ { "(bad)" },
+ { FGRPd9_4 },
+ { FGRPd9_5 },
+ { FGRPd9_6 },
+ { FGRPd9_7 },
+ },
+ /* da */
+ {
+ { "fcmovb", ST, STi },
+ { "fcmove", ST, STi },
+ { "fcmovbe",ST, STi },
+ { "fcmovu", ST, STi },
+ { "(bad)" },
+ { FGRPda_5 },
+ { "(bad)" },
+ { "(bad)" },
+ },
+ /* db */
+ {
+ { "fcmovnb",ST, STi },
+ { "fcmovne",ST, STi },
+ { "fcmovnbe",ST, STi },
+ { "fcmovnu",ST, STi },
+ { FGRPdb_4 },
+ { "fucomi", ST, STi },
+ { "fcomi", ST, STi },
+ { "(bad)" },
+ },
+ /* dc */
+ {
+ { "fadd", STi, ST },
+ { "fmul", STi, ST },
+ { "(bad)" },
+ { "(bad)" },
+#if UNIXWARE_COMPAT
+ { "fsub", STi, ST },
+ { "fsubr", STi, ST },
+ { "fdiv", STi, ST },
+ { "fdivr", STi, ST },
+#else
+ { "fsubr", STi, ST },
+ { "fsub", STi, ST },
+ { "fdivr", STi, ST },
+ { "fdiv", STi, ST },
+#endif
+ },
+ /* dd */
+ {
+ { "ffree", STi },
+ { "(bad)" },
+ { "fst", STi },
+ { "fstp", STi },
+ { "fucom", STi },
+ { "fucomp", STi },
+ { "(bad)" },
+ { "(bad)" },
+ },
+ /* de */
+ {
+ { "faddp", STi, ST },
+ { "fmulp", STi, ST },
+ { "(bad)" },
+ { FGRPde_3 },
+#if UNIXWARE_COMPAT
+ { "fsubp", STi, ST },
+ { "fsubrp", STi, ST },
+ { "fdivp", STi, ST },
+ { "fdivrp", STi, ST },
+#else
+ { "fsubrp", STi, ST },
+ { "fsubp", STi, ST },
+ { "fdivrp", STi, ST },
+ { "fdivp", STi, ST },
+#endif
+ },
+ /* df */
+ {
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { "(bad)" },
+ { FGRPdf_4 },
+ { "fucomip",ST, STi },
+ { "fcomip", ST, STi },
+ { "(bad)" },
+ },
+};
+
+
+static char *fgrps[][8] = {
+ /* d9_2 0 */
+ {
+ "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
+ },
+
+ /* d9_4 1 */
+ {
+ "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
+ },
+
+ /* d9_5 2 */
+ {
+ "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
+ },
+
+ /* d9_6 3 */
+ {
+ "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
+ },
+
+ /* d9_7 4 */
+ {
+ "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
+ },
+
+ /* da_5 5 */
+ {
+ "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
+ },
+
+ /* db_4 6 */
+ {
+ "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
+ "fNsetpm(287 only)","(bad)","(bad)","(bad)",
+ },
+
+ /* de_3 7 */
+ {
+ "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
+ },
+
+ /* df_4 8 */
+ {
+ "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
+ },
+};
+
+static void
+dofloat (sizeflag)
+ int sizeflag;
+{
+ struct dis386 *dp;
+ unsigned char floatop;
+
+ floatop = codep[-1];
+
+ if (mod != 3)
+ {
+ if (intel_syntax)
+ putop (float_mem_intel[(floatop - 0xd8 ) * 8 + reg], sizeflag);
+ else
+ putop (float_mem_att[(floatop - 0xd8 ) * 8 + reg], sizeflag);
+ obufp = op1out;
+ if (floatop == 0xdb)
+ OP_E (x_mode, sizeflag);
+ else if (floatop == 0xdd)
+ OP_E (d_mode, sizeflag);
+ else
+ OP_E (v_mode, sizeflag);
+ return;
+ }
+ codep++;
+
+ dp = &float_reg[floatop - 0xd8][reg];
+ if (dp->name == NULL)
+ {
+ putop (fgrps[dp->bytemode1][rm], sizeflag);
+
+ /* instruction fnstsw is only one with strange arg */
+ if (floatop == 0xdf && codep[-1] == 0xe0)
+ strcpy (op1out, names16[0]);
+ }
+ else
+ {
+ putop (dp->name, sizeflag);
+
+ obufp = op1out;
+ if (dp->op1)
+ (*dp->op1)(dp->bytemode1, sizeflag);
+ obufp = op2out;
+ if (dp->op2)
+ (*dp->op2)(dp->bytemode2, sizeflag);
+ }
+}
+
+/* ARGSUSED */
+static void
+OP_ST (ignore, sizeflag)
+ int ignore;
+ int sizeflag;
+{
+ oappend ("%st");
+}
+
+/* ARGSUSED */
+static void
+OP_STi (ignore, sizeflag)
+ int ignore;
+ int sizeflag;
+{
+ sprintf (scratchbuf, "%%st(%d)", rm);
+ oappend (scratchbuf);
+}
+
+
+/* capital letters in template are macros */
+static void
+putop (template, sizeflag)
+ char *template;
+ int sizeflag;
+{
+ char *p;
+
+ for (p = template; *p; p++)
+ {
+ switch (*p)
+ {
+ default:
+ *obufp++ = *p;
+ break;
+ case 'A':
+ if (intel_syntax)
+ break;
+ if (mod != 3
+#ifdef SUFFIX_ALWAYS
+ || (sizeflag & SUFFIX_ALWAYS)
+#endif
+ )
+ *obufp++ = 'b';
+ break;
+ case 'B':
+ if (intel_syntax)
+ break;
+#ifdef SUFFIX_ALWAYS
+ if (sizeflag & SUFFIX_ALWAYS)
+ *obufp++ = 'b';
+#endif
+ break;
+ case 'E': /* For jcxz/jecxz */
+ if (sizeflag & AFLAG)
+ *obufp++ = 'e';
+ break;
+ case 'L':
+ if (intel_syntax)
+ break;
+#ifdef SUFFIX_ALWAYS
+ if (sizeflag & SUFFIX_ALWAYS)
+ *obufp++ = 'l';
+#endif
+ break;
+ case 'N':
+ if ((prefixes & PREFIX_FWAIT) == 0)
+ *obufp++ = 'n';
+ break;
+ case 'P':
+ if (intel_syntax)
+ break;
+ if ((prefixes & PREFIX_DATA)
+#ifdef SUFFIX_ALWAYS
+ || (sizeflag & SUFFIX_ALWAYS)
+#endif
+ )
+ {
+ if (sizeflag & DFLAG)
+ *obufp++ = 'l';
+ else
+ *obufp++ = 'w';
+ }
+ break;
+ case 'Q':
+ if (intel_syntax)
+ break;
+ if (mod != 3
+#ifdef SUFFIX_ALWAYS
+ || (sizeflag & SUFFIX_ALWAYS)
+#endif
+ )
+ {
+ if (sizeflag & DFLAG)
+ *obufp++ = 'l';
+ else
+ *obufp++ = 'w';
+ }
+ break;
+ case 'R':
+ if (intel_syntax)
+ break;
+ if (sizeflag & DFLAG)
+ *obufp++ = 'l';
+ else
+ *obufp++ = 'w';
+ break;
+ case 'S':
+ if (intel_syntax)
+ break;
+#ifdef SUFFIX_ALWAYS
+ if (sizeflag & SUFFIX_ALWAYS)
+ {
+ if (sizeflag & DFLAG)
+ *obufp++ = 'l';
+ else
+ *obufp++ = 'w';
+ }
+#endif
+ break;
+ case 'W':
+ if (intel_syntax)
+ break;
+ /* operand size flag for cwtl, cbtw */
+ if (sizeflag & DFLAG)
+ *obufp++ = 'w';
+ else
+ *obufp++ = 'b';
+ break;
+ }
+ }
+ *obufp = 0;
+}
+
+static void
+oappend (s)
+ char *s;
+{
+ strcpy (obufp, s);
+ obufp += strlen (s);
+}
+
+static void
+append_seg ()
+{
+ if (prefixes & PREFIX_CS)
+ oappend ("%cs:");
+ if (prefixes & PREFIX_DS)
+ oappend ("%ds:");
+ if (prefixes & PREFIX_SS)
+ oappend ("%ss:");
+ if (prefixes & PREFIX_ES)
+ oappend ("%es:");
+ if (prefixes & PREFIX_FS)
+ oappend ("%fs:");
+ if (prefixes & PREFIX_GS)
+ oappend ("%gs:");
+}
+
+static void
+OP_indirE (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ if (!intel_syntax)
+ oappend ("*");
+ OP_E (bytemode, sizeflag);
+}
+
+static void
+OP_E (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ int disp;
+
+ /* skip mod/rm byte */
+ codep++;
+
+ if (mod == 3)
+ {
+ switch (bytemode)
+ {
+ case b_mode:
+ oappend (names8[rm]);
+ break;
+ case w_mode:
+ oappend (names16[rm]);
+ break;
+ case v_mode:
+ if (sizeflag & DFLAG)
+ oappend (names32[rm]);
+ else
+ oappend (names16[rm]);
+ break;
+ default:
+ oappend ("<bad dis table>");
+ break;
+ }
+ return;
+ }
+
+ disp = 0;
+ append_seg ();
+
+ if (sizeflag & AFLAG) /* 32 bit address mode */
+ {
+ int havesib;
+ int havebase;
+ int base;
+ int index = 0;
+ int scale = 0;
+
+ havesib = 0;
+ havebase = 1;
+ base = rm;
+
+ if (base == 4)
+ {
+ havesib = 1;
+ FETCH_DATA (the_info, codep + 1);
+ scale = (*codep >> 6) & 3;
+ index = (*codep >> 3) & 7;
+ base = *codep & 7;
+ codep++;
+ }
+
+ switch (mod)
+ {
+ case 0:
+ if (base == 5)
+ {
+ havebase = 0;
+ disp = get32 ();
+ }
+ break;
+ case 1:
+ FETCH_DATA (the_info, codep + 1);
+ disp = *codep++;
+ if ((disp & 0x80) != 0)
+ disp -= 0x100;
+ break;
+ case 2:
+ disp = get32 ();
+ break;
+ }
+
+ if (!intel_syntax)
+ if (mod != 0 || base == 5)
+ {
+ sprintf (scratchbuf, "0x%x", disp);
+ oappend (scratchbuf);
+ }
+
+ if (havebase || (havesib && (index != 4 || scale != 0)))
+ {
+ if (intel_syntax)
+ {
+ switch (bytemode)
+ {
+ case b_mode:
+ oappend("BYTE PTR ");
+ break;
+ case w_mode:
+ oappend("WORD PTR ");
+ break;
+ case v_mode:
+ oappend("DWORD PTR ");
+ break;
+ case d_mode:
+ oappend("QWORD PTR ");
+ break;
+ case x_mode:
+ oappend("XWORD PTR ");
+ break;
+ default:
+ break;
+ }
+ }
+ *obufp++ = open_char;
+ *obufp = '\0';
+ if (havebase)
+ oappend (names32[base]);
+ if (havesib)
+ {
+ if (index != 4)
+ {
+ if (intel_syntax)
+ {
+ if (havebase)
+ {
+ *obufp++ = separator_char;
+ *obufp = '\0';
+ }
+ sprintf (scratchbuf, "%s", names32[index]);
+ }
+ else
+ sprintf (scratchbuf, ",%s", names32[index]);
+ oappend (scratchbuf);
+ }
+ if (!intel_syntax
+ || (intel_syntax
+ && bytemode != b_mode
+ && bytemode != w_mode
+ && bytemode != v_mode))
+ {
+ *obufp++ = scale_char;
+ *obufp = '\0';
+ sprintf (scratchbuf, "%d", 1 << scale);
+ oappend (scratchbuf);
+ }
+ }
+ if (intel_syntax)
+ if (mod != 0 || base == 5)
+ {
+ /* Don't print zero displacements */
+ if (disp > 0)
+ {
+ sprintf (scratchbuf, "+%d", disp);
+ oappend (scratchbuf);
+ }
+ else if (disp < 0)
+ {
+ sprintf (scratchbuf, "%d", disp);
+ oappend (scratchbuf);
+ }
+ }
+
+ *obufp++ = close_char;
+ *obufp = '\0';
+ }
+ else if (intel_syntax)
+ {
+ if (mod != 0 || base == 5)
+ {
+ if (prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
+ | PREFIX_ES | PREFIX_FS | PREFIX_GS))
+ ;
+ else
+ {
+ oappend (names_seg[3]);
+ oappend (":");
+ }
+ sprintf (scratchbuf, "0x%x", disp);
+ oappend (scratchbuf);
+ }
+ }
+ }
+ else
+ { /* 16 bit address mode */
+ switch (mod)
+ {
+ case 0:
+ if (rm == 6)
+ {
+ disp = get16 ();
+ if ((disp & 0x8000) != 0)
+ disp -= 0x10000;
+ }
+ break;
+ case 1:
+ FETCH_DATA (the_info, codep + 1);
+ disp = *codep++;
+ if ((disp & 0x80) != 0)
+ disp -= 0x100;
+ break;
+ case 2:
+ disp = get16 ();
+ if ((disp & 0x8000) != 0)
+ disp -= 0x10000;
+ break;
+ }
+
+ if (!intel_syntax)
+ if (mod != 0 || rm == 6)
+ {
+ sprintf (scratchbuf, "%d", disp);
+ oappend (scratchbuf);
+ }
+
+ if (mod != 0 || rm != 6)
+ {
+ *obufp++ = open_char;
+ *obufp = '\0';
+ oappend (index16[rm]);
+ *obufp++ = close_char;
+ *obufp = '\0';
+ }
+ }
+}
+
+#define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
+
+static void
+OP_G (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ switch (bytemode)
+ {
+ case b_mode:
+ oappend (names8[reg]);
+ break;
+ case w_mode:
+ oappend (names16[reg]);
+ break;
+ case d_mode:
+ oappend (names32[reg]);
+ break;
+ case v_mode:
+ if (sizeflag & DFLAG)
+ oappend (names32[reg]);
+ else
+ oappend (names16[reg]);
+ break;
+ default:
+ oappend (INTERNAL_DISASSEMBLER_ERROR);
+ break;
+ }
+}
+
+static int
+get32 ()
+{
+ int x = 0;
+
+ FETCH_DATA (the_info, codep + 4);
+ x = *codep++ & 0xff;
+ x |= (*codep++ & 0xff) << 8;
+ x |= (*codep++ & 0xff) << 16;
+ x |= (*codep++ & 0xff) << 24;
+ return x;
+}
+
+static int
+get16 ()
+{
+ int x = 0;
+
+ FETCH_DATA (the_info, codep + 2);
+ x = *codep++ & 0xff;
+ x |= (*codep++ & 0xff) << 8;
+ return x;
+}
+
+static void
+set_op (op)
+ unsigned int op;
+{
+ op_index[op_ad] = op_ad;
+ op_address[op_ad] = op;
+}
+
+static void
+OP_REG (code, sizeflag)
+ int code;
+ int sizeflag;
+{
+ char *s;
+
+ switch (code)
+ {
+ case indir_dx_reg:
+ s = "(%dx)";
+ break;
+ case ax_reg: case cx_reg: case dx_reg: case bx_reg:
+ case sp_reg: case bp_reg: case si_reg: case di_reg:
+ s = names16[code - ax_reg];
+ break;
+ case es_reg: case ss_reg: case cs_reg:
+ case ds_reg: case fs_reg: case gs_reg:
+ s = names_seg[code - es_reg];
+ break;
+ case al_reg: case ah_reg: case cl_reg: case ch_reg:
+ case dl_reg: case dh_reg: case bl_reg: case bh_reg:
+ s = names8[code - al_reg];
+ break;
+ case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
+ case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
+ if (sizeflag & DFLAG)
+ s = names32[code - eAX_reg];
+ else
+ s = names16[code - eAX_reg];
+ break;
+ default:
+ s = INTERNAL_DISASSEMBLER_ERROR;
+ break;
+ }
+ oappend (s);
+}
+
+static void
+OP_I (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ int op;
+
+ switch (bytemode)
+ {
+ case b_mode:
+ FETCH_DATA (the_info, codep + 1);
+ op = *codep++ & 0xff;
+ break;
+ case v_mode:
+ if (sizeflag & DFLAG)
+ op = get32 ();
+ else
+ op = get16 ();
+ break;
+ case w_mode:
+ op = get16 ();
+ break;
+ default:
+ oappend (INTERNAL_DISASSEMBLER_ERROR);
+ return;
+ }
+
+ if (intel_syntax)
+ sprintf (scratchbuf, "0x%x", op);
+ else
+ sprintf (scratchbuf, "$0x%x", op);
+ oappend (scratchbuf);
+ scratchbuf[0] = '\0';
+}
+
+static void
+OP_sI (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ int op;
+
+ switch (bytemode)
+ {
+ case b_mode:
+ FETCH_DATA (the_info, codep + 1);
+ op = *codep++;
+ if ((op & 0x80) != 0)
+ op -= 0x100;
+ break;
+ case v_mode:
+ if (sizeflag & DFLAG)
+ op = get32 ();
+ else
+ {
+ op = get16();
+ if ((op & 0x8000) != 0)
+ op -= 0x10000;
+ }
+ break;
+ case w_mode:
+ op = get16 ();
+ if ((op & 0x8000) != 0)
+ op -= 0x10000;
+ break;
+ default:
+ oappend (INTERNAL_DISASSEMBLER_ERROR);
+ return;
+ }
+ if (intel_syntax)
+ sprintf (scratchbuf, "%d", op);
+ else
+ sprintf (scratchbuf, "$0x%x", op);
+ oappend (scratchbuf);
+}
+
+static void
+OP_J (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ int disp;
+ int mask = -1;
+
+ switch (bytemode)
+ {
+ case b_mode:
+ FETCH_DATA (the_info, codep + 1);
+ disp = *codep++;
+ if ((disp & 0x80) != 0)
+ disp -= 0x100;
+ break;
+ case v_mode:
+ if (sizeflag & DFLAG)
+ disp = get32 ();
+ else
+ {
+ disp = get16 ();
+ /* for some reason, a data16 prefix on a jump instruction
+ means that the pc is masked to 16 bits after the
+ displacement is added! */
+ mask = 0xffff;
+ }
+ break;
+ default:
+ oappend (INTERNAL_DISASSEMBLER_ERROR);
+ return;
+ }
+ disp = (start_pc + codep - start_codep + disp) & mask;
+ set_op (disp);
+ sprintf (scratchbuf, "0x%x", disp);
+ oappend (scratchbuf);
+}
+
+/* ARGSUSED */
+static void
+OP_SEG (dummy, sizeflag)
+ int dummy;
+ int sizeflag;
+{
+ static char *sreg[] = {
+ "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
+ };
+
+ oappend (sreg[reg]);
+}
+
+static void
+OP_DIR (size, sizeflag)
+ int size;
+ int sizeflag;
+{
+ int seg, offset;
+
+ switch (size)
+ {
+ case lptr:
+ if (sizeflag & DFLAG)
+ {
+ offset = get32 ();
+ seg = get16 ();
+ }
+ else
+ {
+ offset = get16 ();
+ seg = get16 ();
+ }
+ sprintf (scratchbuf, "$0x%x,$0x%x", seg, offset);
+ oappend (scratchbuf);
+ break;
+ case v_mode:
+ if (sizeflag & DFLAG)
+ offset = get32 ();
+ else
+ {
+ offset = get16 ();
+ if ((offset & 0x8000) != 0)
+ offset -= 0x10000;
+ }
+
+ offset = start_pc + codep - start_codep + offset;
+ set_op (offset);
+ sprintf (scratchbuf, "0x%x", offset);
+ oappend (scratchbuf);
+ break;
+ default:
+ oappend (INTERNAL_DISASSEMBLER_ERROR);
+ break;
+ }
+}
+
+/* ARGSUSED */
+static void
+OP_OFF (ignore, sizeflag)
+ int ignore;
+ int sizeflag;
+{
+ int off;
+
+ append_seg ();
+
+ if (sizeflag & AFLAG)
+ off = get32 ();
+ else
+ off = get16 ();
+
+ if (intel_syntax)
+ {
+ if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
+ | PREFIX_ES | PREFIX_FS | PREFIX_GS)))
+ {
+ oappend (names_seg[3]);
+ oappend (":");
+ }
+ }
+ sprintf (scratchbuf, "0x%x", off);
+ oappend (scratchbuf);
+}
+
+static void
+ptr_reg (code, sizeflag)
+ int code;
+ int sizeflag;
+{
+ char *s;
+ oappend ("(");
+ if (sizeflag & AFLAG)
+ s = names32[code - eAX_reg];
+ else
+ s = names16[code - eAX_reg];
+ oappend (s);
+ oappend (")");
+}
+
+static void
+OP_ESreg (code, sizeflag)
+ int code;
+ int sizeflag;
+{
+ oappend ("%es:");
+ ptr_reg (code, sizeflag);
+}
+
+static void
+OP_DSreg (code, sizeflag)
+ int code;
+ int sizeflag;
+{
+ if ((prefixes
+ & (PREFIX_CS
+ | PREFIX_DS
+ | PREFIX_SS
+ | PREFIX_ES
+ | PREFIX_FS
+ | PREFIX_GS)) == 0)
+ prefixes |= PREFIX_DS;
+ append_seg();
+ ptr_reg (code, sizeflag);
+}
+
+#if 0
+/* Not used. */
+
+/* ARGSUSED */
+static void
+OP_ONE (dummy, sizeflag)
+ int dummy;
+ int sizeflag;
+{
+ oappend ("1");
+}
+
+#endif
+
+/* ARGSUSED */
+static void
+OP_C (dummy, sizeflag)
+ int dummy;
+ int sizeflag;
+{
+ codep++; /* skip mod/rm */
+ sprintf (scratchbuf, "%%cr%d", reg);
+ oappend (scratchbuf);
+}
+
+/* ARGSUSED */
+static void
+OP_D (dummy, sizeflag)
+ int dummy;
+ int sizeflag;
+{
+ codep++; /* skip mod/rm */
+ sprintf (scratchbuf, "%%db%d", reg);
+ oappend (scratchbuf);
+}
+
+/* ARGSUSED */
+static void
+OP_T (dummy, sizeflag)
+ int dummy;
+ int sizeflag;
+{
+ codep++; /* skip mod/rm */
+ sprintf (scratchbuf, "%%tr%d", reg);
+ oappend (scratchbuf);
+}
+
+static void
+OP_rm (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ switch (bytemode)
+ {
+ case d_mode:
+ oappend (names32[rm]);
+ break;
+ case w_mode:
+ oappend (names16[rm]);
+ break;
+ }
+}
+
+static void
+OP_MMX (ignore, sizeflag)
+ int ignore;
+ int sizeflag;
+{
+ sprintf (scratchbuf, "%%mm%d", reg);
+ oappend (scratchbuf);
+}
+
+static void
+OP_EM (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ if (mod != 3)
+ {
+ OP_E (bytemode, sizeflag);
+ return;
+ }
+
+ codep++;
+ sprintf (scratchbuf, "%%mm%d", rm);
+ oappend (scratchbuf);
+}
+
+static void
+OP_MS (ignore, sizeflag)
+ int ignore;
+ int sizeflag;
+{
+ ++codep;
+ sprintf (scratchbuf, "%%mm%d", rm);
+ oappend (scratchbuf);
+}
+
+static const char *Suffix3DNow[] = {
+/* 00 */ NULL, NULL, NULL, NULL,
+/* 04 */ NULL, NULL, NULL, NULL,
+/* 08 */ NULL, NULL, NULL, NULL,
+/* 0C */ NULL, "pi2fd", NULL, NULL,
+/* 10 */ NULL, NULL, NULL, NULL,
+/* 14 */ NULL, NULL, NULL, NULL,
+/* 18 */ NULL, NULL, NULL, NULL,
+/* 1C */ NULL, "pf2id", NULL, NULL,
+/* 20 */ NULL, NULL, NULL, NULL,
+/* 24 */ NULL, NULL, NULL, NULL,
+/* 28 */ NULL, NULL, NULL, NULL,
+/* 2C */ NULL, NULL, NULL, NULL,
+/* 30 */ NULL, NULL, NULL, NULL,
+/* 34 */ NULL, NULL, NULL, NULL,
+/* 38 */ NULL, NULL, NULL, NULL,
+/* 3C */ NULL, NULL, NULL, NULL,
+/* 40 */ NULL, NULL, NULL, NULL,
+/* 44 */ NULL, NULL, NULL, NULL,
+/* 48 */ NULL, NULL, NULL, NULL,
+/* 4C */ NULL, NULL, NULL, NULL,
+/* 50 */ NULL, NULL, NULL, NULL,
+/* 54 */ NULL, NULL, NULL, NULL,
+/* 58 */ NULL, NULL, NULL, NULL,
+/* 5C */ NULL, NULL, NULL, NULL,
+/* 60 */ NULL, NULL, NULL, NULL,
+/* 64 */ NULL, NULL, NULL, NULL,
+/* 68 */ NULL, NULL, NULL, NULL,
+/* 6C */ NULL, NULL, NULL, NULL,
+/* 70 */ NULL, NULL, NULL, NULL,
+/* 74 */ NULL, NULL, NULL, NULL,
+/* 78 */ NULL, NULL, NULL, NULL,
+/* 7C */ NULL, NULL, NULL, NULL,
+/* 80 */ NULL, NULL, NULL, NULL,
+/* 84 */ NULL, NULL, NULL, NULL,
+/* 88 */ NULL, NULL, NULL, NULL,
+/* 8C */ NULL, NULL, NULL, NULL,
+/* 90 */ "pfcmpge", NULL, NULL, NULL,
+/* 94 */ "pfmin", NULL, "pfrcp", "pfrsqrt",
+/* 98 */ NULL, NULL, "pfsub", NULL,
+/* 9C */ NULL, NULL, "pfadd", NULL,
+/* A0 */ "pfcmpgt", NULL, NULL, NULL,
+/* A4 */ "pfmax", NULL, "pfrcpit1", "pfrsqit1",
+/* A8 */ NULL, NULL, "pfsubr", NULL,
+/* AC */ NULL, NULL, "pfacc", NULL,
+/* B0 */ "pfcmpeq", NULL, NULL, NULL,
+/* B4 */ "pfmul", NULL, "pfrcpit2", "pfmulhrw",
+/* B8 */ NULL, NULL, NULL, NULL,
+/* BC */ NULL, NULL, NULL, "pavgusb",
+/* C0 */ NULL, NULL, NULL, NULL,
+/* C4 */ NULL, NULL, NULL, NULL,
+/* C8 */ NULL, NULL, NULL, NULL,
+/* CC */ NULL, NULL, NULL, NULL,
+/* D0 */ NULL, NULL, NULL, NULL,
+/* D4 */ NULL, NULL, NULL, NULL,
+/* D8 */ NULL, NULL, NULL, NULL,
+/* DC */ NULL, NULL, NULL, NULL,
+/* E0 */ NULL, NULL, NULL, NULL,
+/* E4 */ NULL, NULL, NULL, NULL,
+/* E8 */ NULL, NULL, NULL, NULL,
+/* EC */ NULL, NULL, NULL, NULL,
+/* F0 */ NULL, NULL, NULL, NULL,
+/* F4 */ NULL, NULL, NULL, NULL,
+/* F8 */ NULL, NULL, NULL, NULL,
+/* FC */ NULL, NULL, NULL, NULL,
+};
+
+static void
+OP_3DNowSuffix (bytemode, sizeflag)
+ int bytemode;
+ int sizeflag;
+{
+ const char *mnemonic;
+
+ FETCH_DATA (the_info, codep + 1);
+ /* AMD 3DNow! instructions are specified by an opcode suffix in the
+ place where an 8-bit immediate would normally go. ie. the last
+ byte of the instruction. */
+ mnemonic = Suffix3DNow[*codep++];
+ if (mnemonic)
+ strcat (obuf, mnemonic);
+ else
+ {
+ /* Since a variable sized modrm/sib chunk is between the start
+ of the opcode (0x0f0f) and the opcode suffix, we need to do
+ all the modrm processing first, and don't know until now that
+ we have a bad opcode. This necessitates some cleaning up. */
+ op1out[0] = 0;
+ op2out[0] = 0;
+ codep = insn_codep + 1;
+ strcat (obuf, "(bad)");
+ }
+}
diff --git a/opcodes/i960-dis.c b/opcodes/i960-dis.c
new file mode 100644
index 00000000000..c0bd84837aa
--- /dev/null
+++ b/opcodes/i960-dis.c
@@ -0,0 +1,914 @@
+/* Disassemble i80960 instructions.
+ Copyright (C) 1990, 91, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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; see the file COPYING. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include "dis-asm.h"
+
+static const char *const reg_names[] = {
+/* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7",
+/* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+/* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
+/* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp",
+/* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3"
+};
+
+
+static FILE *stream; /* Output goes here */
+static struct disassemble_info *info;
+static void print_addr();
+static void ctrl();
+static void cobr();
+static void reg();
+static int mem();
+static void ea();
+static void dstop();
+static void regop();
+static void invalid();
+static int pinsn();
+static void put_abs();
+
+
+/* Print the i960 instruction at address 'memaddr' in debugged memory,
+ on INFO->STREAM. Returns length of the instruction, in bytes. */
+
+int
+print_insn_i960 (memaddr, info_arg)
+ bfd_vma memaddr;
+ struct disassemble_info *info_arg;
+{
+ unsigned int word1, word2 = 0xdeadbeef;
+ bfd_byte buffer[8];
+ int status;
+
+ info = info_arg;
+ stream = info->stream;
+
+ /* Read word1. Only read word2 if the instruction
+ needs it, to prevent reading past the end of a section. */
+
+ status = (*info->read_memory_func) (memaddr, (bfd_byte *) buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ word1 = bfd_getl32 (buffer);
+
+ /* Divide instruction set into classes based on high 4 bits of opcode. */
+ switch ( (word1 >> 28) & 0xf )
+ {
+ default:
+ break;
+ case 0x8:
+ case 0x9:
+ case 0xa:
+ case 0xb:
+ case 0xc:
+ /* Read word2. */
+ status = (*info->read_memory_func)
+ (memaddr + 4, (bfd_byte *) (buffer + 4), 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ word2 = bfd_getl32 (buffer + 4);
+ break;
+ }
+
+ return pinsn( memaddr, word1, word2 );
+}
+
+#define IN_GDB
+
+/*****************************************************************************
+ * All code below this point should be identical with that of
+ * the disassembler in gdmp960.
+
+ A noble sentiment, but at least in cosmetic ways (info->fprintf_func), it
+ just ain't so. -kingdon, 31 Mar 93
+ *****************************************************************************/
+
+struct tabent {
+ char *name;
+ short numops;
+};
+
+struct sparse_tabent {
+ int opcode;
+ char *name;
+ short numops;
+};
+
+static int
+pinsn( memaddr, word1, word2 )
+ bfd_vma memaddr;
+ unsigned long word1, word2;
+{
+ int instr_len;
+
+ instr_len = 4;
+ put_abs( word1, word2 );
+
+ /* Divide instruction set into classes based on high 4 bits of opcode*/
+ switch ( (word1 >> 28) & 0xf ){
+ case 0x0:
+ case 0x1:
+ ctrl( memaddr, word1, word2 );
+ break;
+ case 0x2:
+ case 0x3:
+ cobr( memaddr, word1, word2 );
+ break;
+ case 0x5:
+ case 0x6:
+ case 0x7:
+ reg( word1 );
+ break;
+ case 0x8:
+ case 0x9:
+ case 0xa:
+ case 0xb:
+ case 0xc:
+ instr_len = mem( memaddr, word1, word2, 0 );
+ break;
+ default:
+ /* invalid instruction, print as data word */
+ invalid( word1 );
+ break;
+ }
+ return instr_len;
+}
+
+/****************************************/
+/* CTRL format */
+/****************************************/
+static void
+ctrl( memaddr, word1, word2 )
+ bfd_vma memaddr;
+ unsigned long word1, word2;
+{
+ int i;
+ static const struct tabent ctrl_tab[] = {
+ { NULL, 0, }, /* 0x00 */
+ { NULL, 0, }, /* 0x01 */
+ { NULL, 0, }, /* 0x02 */
+ { NULL, 0, }, /* 0x03 */
+ { NULL, 0, }, /* 0x04 */
+ { NULL, 0, }, /* 0x05 */
+ { NULL, 0, }, /* 0x06 */
+ { NULL, 0, }, /* 0x07 */
+ { "b", 1, }, /* 0x08 */
+ { "call", 1, }, /* 0x09 */
+ { "ret", 0, }, /* 0x0a */
+ { "bal", 1, }, /* 0x0b */
+ { NULL, 0, }, /* 0x0c */
+ { NULL, 0, }, /* 0x0d */
+ { NULL, 0, }, /* 0x0e */
+ { NULL, 0, }, /* 0x0f */
+ { "bno", 1, }, /* 0x10 */
+ { "bg", 1, }, /* 0x11 */
+ { "be", 1, }, /* 0x12 */
+ { "bge", 1, }, /* 0x13 */
+ { "bl", 1, }, /* 0x14 */
+ { "bne", 1, }, /* 0x15 */
+ { "ble", 1, }, /* 0x16 */
+ { "bo", 1, }, /* 0x17 */
+ { "faultno", 0, }, /* 0x18 */
+ { "faultg", 0, }, /* 0x19 */
+ { "faulte", 0, }, /* 0x1a */
+ { "faultge", 0, }, /* 0x1b */
+ { "faultl", 0, }, /* 0x1c */
+ { "faultne", 0, }, /* 0x1d */
+ { "faultle", 0, }, /* 0x1e */
+ { "faulto", 0, }, /* 0x1f */
+ };
+
+ i = (word1 >> 24) & 0xff;
+ if ( (ctrl_tab[i].name == NULL) || ((word1 & 1) != 0) ){
+ invalid( word1 );
+ return;
+ }
+
+ (*info->fprintf_func) ( stream, ctrl_tab[i].name );
+ if ( word1 & 2 ){ /* Predicts branch not taken */
+ (*info->fprintf_func) ( stream, ".f" );
+ }
+
+ if ( ctrl_tab[i].numops == 1 ){
+ /* EXTRACT DISPLACEMENT AND CONVERT TO ADDRESS */
+ word1 &= 0x00ffffff;
+ if ( word1 & 0x00800000 ){ /* Sign bit is set */
+ word1 |= (-1 & ~0xffffff); /* Sign extend */
+ }
+ (*info->fprintf_func)( stream, "\t" );
+ print_addr( word1 + memaddr );
+ }
+}
+
+/****************************************/
+/* COBR format */
+/****************************************/
+static void
+cobr( memaddr, word1, word2 )
+ bfd_vma memaddr;
+ unsigned long word1, word2;
+{
+ int src1;
+ int src2;
+ int i;
+
+ static const struct tabent cobr_tab[] = {
+ { "testno", 1, }, /* 0x20 */
+ { "testg", 1, }, /* 0x21 */
+ { "teste", 1, }, /* 0x22 */
+ { "testge", 1, }, /* 0x23 */
+ { "testl", 1, }, /* 0x24 */
+ { "testne", 1, }, /* 0x25 */
+ { "testle", 1, }, /* 0x26 */
+ { "testo", 1, }, /* 0x27 */
+ { NULL, 0, }, /* 0x28 */
+ { NULL, 0, }, /* 0x29 */
+ { NULL, 0, }, /* 0x2a */
+ { NULL, 0, }, /* 0x2b */
+ { NULL, 0, }, /* 0x2c */
+ { NULL, 0, }, /* 0x2d */
+ { NULL, 0, }, /* 0x2e */
+ { NULL, 0, }, /* 0x2f */
+ { "bbc", 3, }, /* 0x30 */
+ { "cmpobg", 3, }, /* 0x31 */
+ { "cmpobe", 3, }, /* 0x32 */
+ { "cmpobge", 3, }, /* 0x33 */
+ { "cmpobl", 3, }, /* 0x34 */
+ { "cmpobne", 3, }, /* 0x35 */
+ { "cmpoble", 3, }, /* 0x36 */
+ { "bbs", 3, }, /* 0x37 */
+ { "cmpibno", 3, }, /* 0x38 */
+ { "cmpibg", 3, }, /* 0x39 */
+ { "cmpibe", 3, }, /* 0x3a */
+ { "cmpibge", 3, }, /* 0x3b */
+ { "cmpibl", 3, }, /* 0x3c */
+ { "cmpibne", 3, }, /* 0x3d */
+ { "cmpible", 3, }, /* 0x3e */
+ { "cmpibo", 3, }, /* 0x3f */
+ };
+
+ i = ((word1 >> 24) & 0xff) - 0x20;
+ if ( cobr_tab[i].name == NULL ){
+ invalid( word1 );
+ return;
+ }
+
+ (*info->fprintf_func) ( stream, cobr_tab[i].name );
+ if ( word1 & 2 ){ /* Predicts branch not taken */
+ (*info->fprintf_func) ( stream, ".f" );
+ }
+ (*info->fprintf_func)( stream, "\t" );
+
+ src1 = (word1 >> 19) & 0x1f;
+ src2 = (word1 >> 14) & 0x1f;
+
+ if ( word1 & 0x02000 ){ /* M1 is 1 */
+ (*info->fprintf_func)( stream, "%d", src1 );
+ } else { /* M1 is 0 */
+ (*info->fprintf_func)( stream, reg_names[src1] );
+ }
+
+ if ( cobr_tab[i].numops > 1 ){
+ if ( word1 & 1 ){ /* S2 is 1 */
+ (*info->fprintf_func)( stream, ",sf%d,", src2 );
+ } else { /* S1 is 0 */
+ (*info->fprintf_func)( stream, ",%s,", reg_names[src2] );
+ }
+
+ /* Extract displacement and convert to address
+ */
+ word1 &= 0x00001ffc;
+ if ( word1 & 0x00001000 ){ /* Negative displacement */
+ word1 |= (-1 & ~0x1fff); /* Sign extend */
+ }
+ print_addr( memaddr + word1 );
+ }
+}
+
+/****************************************/
+/* MEM format */
+/****************************************/
+static int /* returns instruction length: 4 or 8 */
+mem( memaddr, word1, word2, noprint )
+ bfd_vma memaddr;
+ unsigned long word1, word2;
+ int noprint; /* If TRUE, return instruction length, but
+ * don't output any text.
+ */
+{
+ int i, j;
+ int len;
+ int mode;
+ int offset;
+ const char *reg1, *reg2, *reg3;
+
+ /* This lookup table is too sparse to make it worth typing in, but not
+ so large as to make a sparse array necessary. We create the table
+ at runtime. */
+
+ /*
+ * NOTE: In this table, the meaning of 'numops' is:
+ * 1: single operand
+ * 2: 2 operands, load instruction
+ * -2: 2 operands, store instruction
+ */
+ static struct tabent *mem_tab;
+/* Opcodes of 0x8X, 9X, aX, bX, and cX must be in the table. */
+#define MEM_MIN 0x80
+#define MEM_MAX 0xcf
+#define MEM_SIZ ( * sizeof(struct tabent))
+
+ static const struct sparse_tabent mem_init[] = {
+ { 0x80, "ldob", 2 },
+ { 0x82, "stob", -2 },
+ { 0x84, "bx", 1 },
+ { 0x85, "balx", 2 },
+ { 0x86, "callx", 1 },
+ { 0x88, "ldos", 2 },
+ { 0x8a, "stos", -2 },
+ { 0x8c, "lda", 2 },
+ { 0x90, "ld", 2 },
+ { 0x92, "st", -2 },
+ { 0x98, "ldl", 2 },
+ { 0x9a, "stl", -2 },
+ { 0xa0, "ldt", 2 },
+ { 0xa2, "stt", -2 },
+ { 0xac, "dcinva", 1 },
+ { 0xb0, "ldq", 2 },
+ { 0xb2, "stq", -2 },
+ { 0xc0, "ldib", 2 },
+ { 0xc2, "stib", -2 },
+ { 0xc8, "ldis", 2 },
+ { 0xca, "stis", -2 },
+ { 0, NULL, 0 }
+ };
+ static struct tabent mem_tab_buf[MEM_MAX - MEM_MIN + 1];
+
+ if ( mem_tab == NULL ){
+ mem_tab = mem_tab_buf;
+ for ( i = 0; mem_init[i].opcode != 0; i++ ){
+ j = mem_init[i].opcode - MEM_MIN;
+ mem_tab[j].name = mem_init[i].name;
+ mem_tab[j].numops = mem_init[i].numops;
+ }
+ }
+
+ i = ((word1 >> 24) & 0xff) - MEM_MIN;
+ mode = (word1 >> 10) & 0xf;
+
+ if ( (mem_tab[i].name != NULL) /* Valid instruction */
+ && ((mode == 5) || (mode >=12)) ){ /* With 32-bit displacement */
+ len = 8;
+ } else {
+ len = 4;
+ }
+
+ if ( noprint ){
+ return len;
+ }
+
+ if ( (mem_tab[i].name == NULL) || (mode == 6) ){
+ invalid( word1 );
+ return len;
+ }
+
+ (*info->fprintf_func)( stream, "%s\t", mem_tab[i].name );
+
+ reg1 = reg_names[ (word1 >> 19) & 0x1f ]; /* MEMB only */
+ reg2 = reg_names[ (word1 >> 14) & 0x1f ];
+ reg3 = reg_names[ word1 & 0x1f ]; /* MEMB only */
+ offset = word1 & 0xfff; /* MEMA only */
+
+ switch ( mem_tab[i].numops ){
+
+ case 2: /* LOAD INSTRUCTION */
+ if ( mode & 4 ){ /* MEMB FORMAT */
+ ea( memaddr, mode, reg2, reg3, word1, word2 );
+ (*info->fprintf_func)( stream, ",%s", reg1 );
+ } else { /* MEMA FORMAT */
+ (*info->fprintf_func)( stream, "0x%x", (unsigned) offset );
+ if (mode & 8) {
+ (*info->fprintf_func)( stream, "(%s)", reg2 );
+ }
+ (*info->fprintf_func)( stream, ",%s", reg1 );
+ }
+ break;
+
+ case -2: /* STORE INSTRUCTION */
+ if ( mode & 4 ){ /* MEMB FORMAT */
+ (*info->fprintf_func)( stream, "%s,", reg1 );
+ ea( memaddr, mode, reg2, reg3, word1, word2 );
+ } else { /* MEMA FORMAT */
+ (*info->fprintf_func)( stream, "%s,0x%x", reg1, (unsigned) offset );
+ if (mode & 8) {
+ (*info->fprintf_func)( stream, "(%s)", reg2 );
+ }
+ }
+ break;
+
+ case 1: /* BX/CALLX INSTRUCTION */
+ if ( mode & 4 ){ /* MEMB FORMAT */
+ ea( memaddr, mode, reg2, reg3, word1, word2 );
+ } else { /* MEMA FORMAT */
+ (*info->fprintf_func)( stream, "0x%x", (unsigned) offset );
+ if (mode & 8) {
+ (*info->fprintf_func)( stream, "(%s)", reg2 );
+ }
+ }
+ break;
+ }
+
+ return len;
+}
+
+/****************************************/
+/* REG format */
+/****************************************/
+static void
+reg( word1 )
+ unsigned long word1;
+{
+ int i, j;
+ int opcode;
+ int fp;
+ int m1, m2, m3;
+ int s1, s2;
+ int src, src2, dst;
+ char *mnemp;
+
+ /* This lookup table is too sparse to make it worth typing in, but not
+ so large as to make a sparse array necessary. We create the table
+ at runtime. */
+
+ /*
+ * NOTE: In this table, the meaning of 'numops' is:
+ * 1: single operand, which is NOT a destination.
+ * -1: single operand, which IS a destination.
+ * 2: 2 operands, the 2nd of which is NOT a destination.
+ * -2: 2 operands, the 2nd of which IS a destination.
+ * 3: 3 operands
+ *
+ * If an opcode mnemonic begins with "F", it is a floating-point
+ * opcode (the "F" is not printed).
+ */
+
+ static struct tabent *reg_tab;
+ static const struct sparse_tabent reg_init[] = {
+#define REG_MIN 0x580
+ { 0x580, "notbit", 3 },
+ { 0x581, "and", 3 },
+ { 0x582, "andnot", 3 },
+ { 0x583, "setbit", 3 },
+ { 0x584, "notand", 3 },
+ { 0x586, "xor", 3 },
+ { 0x587, "or", 3 },
+ { 0x588, "nor", 3 },
+ { 0x589, "xnor", 3 },
+ { 0x58a, "not", -2 },
+ { 0x58b, "ornot", 3 },
+ { 0x58c, "clrbit", 3 },
+ { 0x58d, "notor", 3 },
+ { 0x58e, "nand", 3 },
+ { 0x58f, "alterbit", 3 },
+ { 0x590, "addo", 3 },
+ { 0x591, "addi", 3 },
+ { 0x592, "subo", 3 },
+ { 0x593, "subi", 3 },
+ { 0x594, "cmpob", 2 },
+ { 0x595, "cmpib", 2 },
+ { 0x596, "cmpos", 2 },
+ { 0x597, "cmpis", 2 },
+ { 0x598, "shro", 3 },
+ { 0x59a, "shrdi", 3 },
+ { 0x59b, "shri", 3 },
+ { 0x59c, "shlo", 3 },
+ { 0x59d, "rotate", 3 },
+ { 0x59e, "shli", 3 },
+ { 0x5a0, "cmpo", 2 },
+ { 0x5a1, "cmpi", 2 },
+ { 0x5a2, "concmpo", 2 },
+ { 0x5a3, "concmpi", 2 },
+ { 0x5a4, "cmpinco", 3 },
+ { 0x5a5, "cmpinci", 3 },
+ { 0x5a6, "cmpdeco", 3 },
+ { 0x5a7, "cmpdeci", 3 },
+ { 0x5ac, "scanbyte", 2 },
+ { 0x5ad, "bswap", -2 },
+ { 0x5ae, "chkbit", 2 },
+ { 0x5b0, "addc", 3 },
+ { 0x5b2, "subc", 3 },
+ { 0x5b4, "intdis", 0 },
+ { 0x5b5, "inten", 0 },
+ { 0x5cc, "mov", -2 },
+ { 0x5d8, "eshro", 3 },
+ { 0x5dc, "movl", -2 },
+ { 0x5ec, "movt", -2 },
+ { 0x5fc, "movq", -2 },
+ { 0x600, "synmov", 2 },
+ { 0x601, "synmovl", 2 },
+ { 0x602, "synmovq", 2 },
+ { 0x603, "cmpstr", 3 },
+ { 0x604, "movqstr", 3 },
+ { 0x605, "movstr", 3 },
+ { 0x610, "atmod", 3 },
+ { 0x612, "atadd", 3 },
+ { 0x613, "inspacc", -2 },
+ { 0x614, "ldphy", -2 },
+ { 0x615, "synld", -2 },
+ { 0x617, "fill", 3 },
+ { 0x630, "sdma", 3 },
+ { 0x631, "udma", 0 },
+ { 0x640, "spanbit", -2 },
+ { 0x641, "scanbit", -2 },
+ { 0x642, "daddc", 3 },
+ { 0x643, "dsubc", 3 },
+ { 0x644, "dmovt", -2 },
+ { 0x645, "modac", 3 },
+ { 0x646, "condrec", -2 },
+ { 0x650, "modify", 3 },
+ { 0x651, "extract", 3 },
+ { 0x654, "modtc", 3 },
+ { 0x655, "modpc", 3 },
+ { 0x656, "receive", -2 },
+ { 0x658, "intctl", -2 },
+ { 0x659, "sysctl", 3 },
+ { 0x65b, "icctl", 3 },
+ { 0x65c, "dcctl", 3 },
+ { 0x65d, "halt", 0 },
+ { 0x660, "calls", 1 },
+ { 0x662, "send", 3 },
+ { 0x663, "sendserv", 1 },
+ { 0x664, "resumprcs", 1 },
+ { 0x665, "schedprcs", 1 },
+ { 0x666, "saveprcs", 0 },
+ { 0x668, "condwait", 1 },
+ { 0x669, "wait", 1 },
+ { 0x66a, "signal", 1 },
+ { 0x66b, "mark", 0 },
+ { 0x66c, "fmark", 0 },
+ { 0x66d, "flushreg", 0 },
+ { 0x66f, "syncf", 0 },
+ { 0x670, "emul", 3 },
+ { 0x671, "ediv", 3 },
+ { 0x673, "ldtime", -1 },
+ { 0x674, "Fcvtir", -2 },
+ { 0x675, "Fcvtilr", -2 },
+ { 0x676, "Fscalerl", 3 },
+ { 0x677, "Fscaler", 3 },
+ { 0x680, "Fatanr", 3 },
+ { 0x681, "Flogepr", 3 },
+ { 0x682, "Flogr", 3 },
+ { 0x683, "Fremr", 3 },
+ { 0x684, "Fcmpor", 2 },
+ { 0x685, "Fcmpr", 2 },
+ { 0x688, "Fsqrtr", -2 },
+ { 0x689, "Fexpr", -2 },
+ { 0x68a, "Flogbnr", -2 },
+ { 0x68b, "Froundr", -2 },
+ { 0x68c, "Fsinr", -2 },
+ { 0x68d, "Fcosr", -2 },
+ { 0x68e, "Ftanr", -2 },
+ { 0x68f, "Fclassr", 1 },
+ { 0x690, "Fatanrl", 3 },
+ { 0x691, "Flogeprl", 3 },
+ { 0x692, "Flogrl", 3 },
+ { 0x693, "Fremrl", 3 },
+ { 0x694, "Fcmporl", 2 },
+ { 0x695, "Fcmprl", 2 },
+ { 0x698, "Fsqrtrl", -2 },
+ { 0x699, "Fexprl", -2 },
+ { 0x69a, "Flogbnrl", -2 },
+ { 0x69b, "Froundrl", -2 },
+ { 0x69c, "Fsinrl", -2 },
+ { 0x69d, "Fcosrl", -2 },
+ { 0x69e, "Ftanrl", -2 },
+ { 0x69f, "Fclassrl", 1 },
+ { 0x6c0, "Fcvtri", -2 },
+ { 0x6c1, "Fcvtril", -2 },
+ { 0x6c2, "Fcvtzri", -2 },
+ { 0x6c3, "Fcvtzril", -2 },
+ { 0x6c9, "Fmovr", -2 },
+ { 0x6d9, "Fmovrl", -2 },
+ { 0x6e1, "Fmovre", -2 },
+ { 0x6e2, "Fcpysre", 3 },
+ { 0x6e3, "Fcpyrsre", 3 },
+ { 0x701, "mulo", 3 },
+ { 0x708, "remo", 3 },
+ { 0x70b, "divo", 3 },
+ { 0x741, "muli", 3 },
+ { 0x748, "remi", 3 },
+ { 0x749, "modi", 3 },
+ { 0x74b, "divi", 3 },
+ { 0x780, "addono", 3 },
+ { 0x781, "addino", 3 },
+ { 0x782, "subono", 3 },
+ { 0x783, "subino", 3 },
+ { 0x784, "selno", 3 },
+ { 0x78b, "Fdivr", 3 },
+ { 0x78c, "Fmulr", 3 },
+ { 0x78d, "Fsubr", 3 },
+ { 0x78f, "Faddr", 3 },
+ { 0x790, "addog", 3 },
+ { 0x791, "addig", 3 },
+ { 0x792, "subog", 3 },
+ { 0x793, "subig", 3 },
+ { 0x794, "selg", 3 },
+ { 0x79b, "Fdivrl", 3 },
+ { 0x79c, "Fmulrl", 3 },
+ { 0x79d, "Fsubrl", 3 },
+ { 0x79f, "Faddrl", 3 },
+ { 0x7a0, "addoe", 3 },
+ { 0x7a1, "addie", 3 },
+ { 0x7a2, "suboe", 3 },
+ { 0x7a3, "subie", 3 },
+ { 0x7a4, "sele", 3 },
+ { 0x7b0, "addoge", 3 },
+ { 0x7b1, "addige", 3 },
+ { 0x7b2, "suboge", 3 },
+ { 0x7b3, "subige", 3 },
+ { 0x7b4, "selge", 3 },
+ { 0x7c0, "addol", 3 },
+ { 0x7c1, "addil", 3 },
+ { 0x7c2, "subol", 3 },
+ { 0x7c3, "subil", 3 },
+ { 0x7c4, "sell", 3 },
+ { 0x7d0, "addone", 3 },
+ { 0x7d1, "addine", 3 },
+ { 0x7d2, "subone", 3 },
+ { 0x7d3, "subine", 3 },
+ { 0x7d4, "selne", 3 },
+ { 0x7e0, "addole", 3 },
+ { 0x7e1, "addile", 3 },
+ { 0x7e2, "subole", 3 },
+ { 0x7e3, "subile", 3 },
+ { 0x7e4, "selle", 3 },
+ { 0x7f0, "addoo", 3 },
+ { 0x7f1, "addio", 3 },
+ { 0x7f2, "suboo", 3 },
+ { 0x7f3, "subio", 3 },
+ { 0x7f4, "selo", 3 },
+#define REG_MAX 0x7f4
+ { 0, NULL, 0 }
+ };
+ static struct tabent reg_tab_buf[REG_MAX - REG_MIN + 1];
+
+ if ( reg_tab == NULL ){
+ reg_tab = reg_tab_buf;
+ for ( i = 0; reg_init[i].opcode != 0; i++ ){
+ j = reg_init[i].opcode - REG_MIN;
+ reg_tab[j].name = reg_init[i].name;
+ reg_tab[j].numops = reg_init[i].numops;
+ }
+ }
+
+ opcode = ((word1 >> 20) & 0xff0) | ((word1 >> 7) & 0xf);
+ i = opcode - REG_MIN;
+
+ if ( (opcode<REG_MIN) || (opcode>REG_MAX) || (reg_tab[i].name==NULL) ){
+ invalid( word1 );
+ return;
+ }
+
+ mnemp = reg_tab[i].name;
+ if ( *mnemp == 'F' ){
+ fp = 1;
+ mnemp++;
+ } else {
+ fp = 0;
+ }
+
+ (*info->fprintf_func)( stream, mnemp );
+
+ s1 = (word1 >> 5) & 1;
+ s2 = (word1 >> 6) & 1;
+ m1 = (word1 >> 11) & 1;
+ m2 = (word1 >> 12) & 1;
+ m3 = (word1 >> 13) & 1;
+ src = word1 & 0x1f;
+ src2 = (word1 >> 14) & 0x1f;
+ dst = (word1 >> 19) & 0x1f;
+
+ if ( reg_tab[i].numops != 0 ){
+ (*info->fprintf_func)( stream, "\t" );
+
+ switch ( reg_tab[i].numops ){
+ case 1:
+ regop( m1, s1, src, fp );
+ break;
+ case -1:
+ dstop( m3, dst, fp );
+ break;
+ case 2:
+ regop( m1, s1, src, fp );
+ (*info->fprintf_func)( stream, "," );
+ regop( m2, s2, src2, fp );
+ break;
+ case -2:
+ regop( m1, s1, src, fp );
+ (*info->fprintf_func)( stream, "," );
+ dstop( m3, dst, fp );
+ break;
+ case 3:
+ regop( m1, s1, src, fp );
+ (*info->fprintf_func)( stream, "," );
+ regop( m2, s2, src2, fp );
+ (*info->fprintf_func)( stream, "," );
+ dstop( m3, dst, fp );
+ break;
+ }
+ }
+}
+
+
+/*
+ * Print out effective address for memb instructions.
+ */
+static void
+ea( memaddr, mode, reg2, reg3, word1, word2 )
+ bfd_vma memaddr;
+ int mode;
+ char *reg2, *reg3;
+ int word1;
+ unsigned int word2;
+{
+ int scale;
+ static const int scale_tab[] = { 1, 2, 4, 8, 16 };
+
+ scale = (word1 >> 7) & 0x07;
+ if ( (scale > 4) || (((word1 >> 5) & 0x03) != 0) ){
+ invalid( word1 );
+ return;
+ }
+ scale = scale_tab[scale];
+
+ switch (mode) {
+ case 4: /* (reg) */
+ (*info->fprintf_func)( stream, "(%s)", reg2 );
+ break;
+ case 5: /* displ+8(ip) */
+ print_addr( word2+8+memaddr );
+ break;
+ case 7: /* (reg)[index*scale] */
+ if (scale == 1) {
+ (*info->fprintf_func)( stream, "(%s)[%s]", reg2, reg3 );
+ } else {
+ (*info->fprintf_func)( stream, "(%s)[%s*%d]",reg2,reg3,scale);
+ }
+ break;
+ case 12: /* displacement */
+ print_addr( (bfd_vma)word2 );
+ break;
+ case 13: /* displ(reg) */
+ print_addr( (bfd_vma)word2 );
+ (*info->fprintf_func)( stream, "(%s)", reg2 );
+ break;
+ case 14: /* displ[index*scale] */
+ print_addr( (bfd_vma)word2 );
+ if (scale == 1) {
+ (*info->fprintf_func)( stream, "[%s]", reg3 );
+ } else {
+ (*info->fprintf_func)( stream, "[%s*%d]", reg3, scale );
+ }
+ break;
+ case 15: /* displ(reg)[index*scale] */
+ print_addr( (bfd_vma)word2 );
+ if (scale == 1) {
+ (*info->fprintf_func)( stream, "(%s)[%s]", reg2, reg3 );
+ } else {
+ (*info->fprintf_func)( stream, "(%s)[%s*%d]",reg2,reg3,scale );
+ }
+ break;
+ default:
+ invalid( word1 );
+ return;
+ }
+}
+
+
+/************************************************/
+/* Register Instruction Operand */
+/************************************************/
+static void
+regop( mode, spec, reg, fp )
+ int mode, spec, reg, fp;
+{
+ if ( fp ){ /* FLOATING POINT INSTRUCTION */
+ if ( mode == 1 ){ /* FP operand */
+ switch ( reg ){
+ case 0: (*info->fprintf_func)( stream, "fp0" );
+ break;
+ case 1: (*info->fprintf_func)( stream, "fp1" );
+ break;
+ case 2: (*info->fprintf_func)( stream, "fp2" );
+ break;
+ case 3: (*info->fprintf_func)( stream, "fp3" );
+ break;
+ case 16: (*info->fprintf_func)( stream, "0f0.0" );
+ break;
+ case 22: (*info->fprintf_func)( stream, "0f1.0" );
+ break;
+ default: (*info->fprintf_func)( stream, "?" );
+ break;
+ }
+ } else { /* Non-FP register */
+ (*info->fprintf_func)( stream, reg_names[reg] );
+ }
+ } else { /* NOT FLOATING POINT */
+ if ( mode == 1 ){ /* Literal */
+ (*info->fprintf_func)( stream, "%d", reg );
+ } else { /* Register */
+ if ( spec == 0 ){
+ (*info->fprintf_func)( stream, reg_names[reg] );
+ } else {
+ (*info->fprintf_func)( stream, "sf%d", reg );
+ }
+ }
+ }
+}
+
+/************************************************/
+/* Register Instruction Destination Operand */
+/************************************************/
+static void
+dstop( mode, reg, fp )
+ int mode, reg, fp;
+{
+ /* 'dst' operand can't be a literal. On non-FP instructions, register
+ * mode is assumed and "m3" acts as if were "s3"; on FP-instructions,
+ * sf registers are not allowed so m3 acts normally.
+ */
+ if ( fp ){
+ regop( mode, 0, reg, fp );
+ } else {
+ regop( 0, mode, reg, fp );
+ }
+}
+
+
+static void
+invalid( word1 )
+ int word1;
+{
+ (*info->fprintf_func)( stream, ".word\t0x%08x", (unsigned) word1 );
+}
+
+static void
+print_addr(a)
+bfd_vma a;
+{
+ (*info->print_address_func) (a, info);
+}
+
+static void
+put_abs( word1, word2 )
+ unsigned long word1, word2;
+{
+#ifdef IN_GDB
+ return;
+#else
+ int len;
+
+ switch ( (word1 >> 28) & 0xf ){
+ case 0x8:
+ case 0x9:
+ case 0xa:
+ case 0xb:
+ case 0xc:
+ /* MEM format instruction */
+ len = mem( 0, word1, word2, 1 );
+ break;
+ default:
+ len = 4;
+ break;
+ }
+
+ if ( len == 8 ){
+ (*info->fprintf_func)( stream, "%08x %08x\t", word1, word2 );
+ } else {
+ (*info->fprintf_func)( stream, "%08x \t", word1 );
+ }
+;
+
+#endif
+}
diff --git a/opcodes/m10200-dis.c b/opcodes/m10200-dis.c
new file mode 100644
index 00000000000..022c7e3410b
--- /dev/null
+++ b/opcodes/m10200-dis.c
@@ -0,0 +1,341 @@
+/* Disassemble MN10200 instructions.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include <stdio.h>
+
+#include "ansidecl.h"
+#include "opcode/mn10200.h"
+#include "dis-asm.h"
+#include "opintl.h"
+
+static void disassemble PARAMS ((bfd_vma, struct disassemble_info *,
+ unsigned long insn, unsigned long,
+ unsigned int));
+
+int
+print_insn_mn10200 (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int status;
+ bfd_byte buffer[4];
+ unsigned long insn;
+ unsigned long extension = 0;
+ unsigned int consume;
+
+ /* First figure out how big the opcode is. */
+ status = (*info->read_memory_func) (memaddr, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ insn = *(unsigned char *) buffer;
+
+ /* These are one byte insns. */
+ if ((insn & 0xf0) == 0x00
+ || (insn & 0xf0) == 0x10
+ || (insn & 0xf0) == 0x20
+ || (insn & 0xf0) == 0x30
+ || ((insn & 0xf0) == 0x80
+ && (insn & 0x0c) >> 2 != (insn & 0x03))
+ || (insn & 0xf0) == 0x90
+ || (insn & 0xf0) == 0xa0
+ || (insn & 0xf0) == 0xb0
+ || (insn & 0xff) == 0xeb
+ || (insn & 0xff) == 0xf6
+ || (insn & 0xff) == 0xfe
+ || (insn & 0xff) == 0xff)
+ {
+ extension = 0;
+ consume = 1;
+ }
+
+ /* These are two byte insns. */
+ else if ((insn & 0xf0) == 0x40
+ || (insn & 0xf0) == 0x50
+ || (insn & 0xf0) == 0x60
+ || (insn & 0xf0) == 0x70
+ || (insn & 0xf0) == 0x80
+ || (insn & 0xfc) == 0xd0
+ || (insn & 0xfc) == 0xd4
+ || (insn & 0xfc) == 0xd8
+ || (insn & 0xfc) == 0xe0
+ || (insn & 0xfc) == 0xe4
+ || (insn & 0xff) == 0xe8
+ || (insn & 0xff) == 0xe9
+ || (insn & 0xff) == 0xea
+ || (insn & 0xff) == 0xf0
+ || (insn & 0xff) == 0xf1
+ || (insn & 0xff) == 0xf2
+ || (insn & 0xff) == 0xf3)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb16 (buffer);
+ consume = 2;
+ }
+
+ /* These are three byte insns with a 16bit operand in little
+ endian form. */
+ else if ((insn & 0xf0) == 0xc0
+ || (insn & 0xfc) == 0xdc
+ || (insn & 0xfc) == 0xec
+ || (insn & 0xff) == 0xf8
+ || (insn & 0xff) == 0xf9
+ || (insn & 0xff) == 0xfa
+ || (insn & 0xff) == 0xfb
+ || (insn & 0xff) == 0xfc
+ || (insn & 0xff) == 0xfd)
+ {
+ status = (*info->read_memory_func) (memaddr + 1, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn <<= 16;
+ insn |= bfd_getl16 (buffer);
+ extension = 0;
+ consume = 3;
+ }
+ /* These are three byte insns too, but we don't have to mess with
+ endianness stuff. */
+ else if ((insn & 0xff) == 0xf5)
+ {
+ status = (*info->read_memory_func) (memaddr + 1, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn <<= 16;
+ insn |= bfd_getb16 (buffer);
+ extension = 0;
+ consume = 3;
+ }
+
+ /* These are four byte insns. */
+ else if ((insn & 0xff) == 0xf7)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb16 (buffer);
+ insn <<= 16;
+ status = (*info->read_memory_func) (memaddr + 2, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn |= bfd_getl16 (buffer);
+ extension = 0;
+ consume = 4;
+ }
+
+ /* These are five byte insns. */
+ else if ((insn & 0xff) == 0xf4)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb16 (buffer);
+ insn <<= 16;
+
+ status = (*info->read_memory_func) (memaddr + 4, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn |= (*(unsigned char *)buffer << 8) & 0xff00;
+
+ status = (*info->read_memory_func) (memaddr + 3, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn |= (*(unsigned char *)buffer) & 0xff;
+
+ status = (*info->read_memory_func) (memaddr + 2, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ extension = (*(unsigned char *)buffer) & 0xff;
+ consume = 5;
+ }
+ else
+ {
+ (*info->fprintf_func) (info->stream, _("unknown\t0x%02x"), insn);
+ return 1;
+ }
+
+ disassemble (memaddr, info, insn, extension, consume);
+
+ return consume;
+}
+
+static void
+disassemble (memaddr, info, insn, extension, size)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+ unsigned long insn;
+ unsigned long extension;
+ unsigned int size;
+{
+ struct mn10200_opcode *op = (struct mn10200_opcode *)mn10200_opcodes;
+ const struct mn10200_operand *operand;
+ int match = 0;
+
+ /* Find the opcode. */
+ while (op->name)
+ {
+ int mysize, extra_shift;
+
+ if (op->format == FMT_1)
+ mysize = 1;
+ else if (op->format == FMT_2
+ || op->format == FMT_4)
+ mysize = 2;
+ else if (op->format == FMT_3
+ || op->format == FMT_5)
+ mysize = 3;
+ else if (op->format == FMT_6)
+ mysize = 4;
+ else if (op->format == FMT_7)
+ mysize = 5;
+ else
+ abort ();
+
+ if (op->format == FMT_2 || op->format == FMT_5)
+ extra_shift = 8;
+ else if (op->format == FMT_3
+ || op->format == FMT_6
+ || op->format == FMT_7)
+ extra_shift = 16;
+ else
+ extra_shift = 0;
+
+ if ((op->mask & insn) == op->opcode
+ && size == (unsigned int) mysize)
+ {
+ const unsigned char *opindex_ptr;
+ unsigned int nocomma;
+ int paren = 0;
+
+ match = 1;
+ (*info->fprintf_func) (info->stream, "%s\t", op->name);
+
+ /* Now print the operands. */
+ for (opindex_ptr = op->operands, nocomma = 1;
+ *opindex_ptr != 0;
+ opindex_ptr++)
+ {
+ unsigned long value;
+
+ operand = &mn10200_operands[*opindex_ptr];
+
+ if ((operand->flags & MN10200_OPERAND_EXTENDED) != 0)
+ {
+ value = (insn & 0xffff) << 8;
+ value |= extension;
+ }
+ else
+ {
+ value = ((insn >> (operand->shift))
+ & ((1L << operand->bits) - 1L));
+ }
+
+ if ((operand->flags & MN10200_OPERAND_SIGNED) != 0)
+ value = ((long)(value << (32 - operand->bits))
+ >> (32 - operand->bits));
+
+ if (!nocomma
+ && (!paren
+ || ((operand->flags & MN10200_OPERAND_PAREN) == 0)))
+ (*info->fprintf_func) (info->stream, ",");
+
+ nocomma = 0;
+
+ if ((operand->flags & MN10200_OPERAND_DREG) != 0)
+ {
+ value = ((insn >> (operand->shift + extra_shift))
+ & ((1 << operand->bits) - 1));
+ (*info->fprintf_func) (info->stream, "d%d", value);
+ }
+
+ else if ((operand->flags & MN10200_OPERAND_AREG) != 0)
+ {
+ value = ((insn >> (operand->shift + extra_shift))
+ & ((1 << operand->bits) - 1));
+ (*info->fprintf_func) (info->stream, "a%d", value);
+ }
+
+ else if ((operand->flags & MN10200_OPERAND_PSW) != 0)
+ (*info->fprintf_func) (info->stream, "psw");
+
+ else if ((operand->flags & MN10200_OPERAND_MDR) != 0)
+ (*info->fprintf_func) (info->stream, "mdr");
+
+ else if ((operand->flags & MN10200_OPERAND_PAREN) != 0)
+ {
+ if (paren)
+ (*info->fprintf_func) (info->stream, ")");
+ else
+ {
+ (*info->fprintf_func) (info->stream, "(");
+ nocomma = 1;
+ }
+ paren = !paren;
+ }
+
+ else if ((operand->flags & MN10200_OPERAND_PCREL) != 0)
+ (*info->print_address_func) ((value + memaddr + mysize) & 0xffffff, info);
+
+ else if ((operand->flags & MN10200_OPERAND_MEMADDR) != 0)
+ (*info->print_address_func) (value, info);
+
+ else
+ (*info->fprintf_func) (info->stream, "%ld", value);
+ }
+ /* All done. */
+ break;
+ }
+ op++;
+ }
+
+ if (!match)
+ {
+ (*info->fprintf_func) (info->stream, _("unknown\t0x%04lx"), insn);
+ }
+}
diff --git a/opcodes/m10200-opc.c b/opcodes/m10200-opc.c
new file mode 100644
index 00000000000..2f70b9081ae
--- /dev/null
+++ b/opcodes/m10200-opc.c
@@ -0,0 +1,360 @@
+/* Assemble Matsushita MN10200 instructions.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "opcode/mn10200.h"
+
+
+const struct mn10200_operand mn10200_operands[] = {
+#define UNUSED 0
+ {0, 0, 0},
+
+/* dn register in the first register operand position. */
+#define DN0 (UNUSED+1)
+ {2, 0, MN10200_OPERAND_DREG},
+
+/* dn register in the second register operand position. */
+#define DN1 (DN0+1)
+ {2, 2, MN10200_OPERAND_DREG},
+
+/* dm register in the first register operand position. */
+#define DM0 (DN1+1)
+ {2, 0, MN10200_OPERAND_DREG},
+
+/* dm register in the second register operand position. */
+#define DM1 (DM0+1)
+ {2, 2, MN10200_OPERAND_DREG},
+
+/* an register in the first register operand position. */
+#define AN0 (DM1+1)
+ {2, 0, MN10200_OPERAND_AREG},
+
+/* an register in the second register operand position. */
+#define AN1 (AN0+1)
+ {2, 2, MN10200_OPERAND_AREG},
+
+/* am register in the first register operand position. */
+#define AM0 (AN1+1)
+ {2, 0, MN10200_OPERAND_AREG},
+
+/* am register in the second register operand position. */
+#define AM1 (AM0+1)
+ {2, 2, MN10200_OPERAND_AREG},
+
+/* 8 bit unsigned immediate which may promote to a 16bit
+ unsigned immediate. */
+#define IMM8 (AM1+1)
+ {8, 0, MN10200_OPERAND_PROMOTE},
+
+/* 16 bit unsigned immediate which may promote to a 32bit
+ unsigned immediate. */
+#define IMM16 (IMM8+1)
+ {16, 0, MN10200_OPERAND_PROMOTE},
+
+/* 16 bit pc-relative immediate which may promote to a 16bit
+ pc-relative immediate. */
+#define IMM16_PCREL (IMM16+1)
+ {16, 0, MN10200_OPERAND_PCREL | MN10200_OPERAND_RELAX | MN10200_OPERAND_SIGNED},
+
+/* 16bit unsigned dispacement in a memory operation which
+ may promote to a 32bit displacement. */
+#define IMM16_MEM (IMM16_PCREL+1)
+ {16, 0, MN10200_OPERAND_PROMOTE | MN10200_OPERAND_MEMADDR},
+
+/* 24 immediate, low 16 bits in the main instruction
+ word, 8 in the extension word. */
+
+#define IMM24 (IMM16_MEM+1)
+ {24, 0, MN10200_OPERAND_EXTENDED},
+
+/* 32bit pc-relative offset. */
+#define IMM24_PCREL (IMM24+1)
+ {24, 0, MN10200_OPERAND_EXTENDED | MN10200_OPERAND_PCREL | MN10200_OPERAND_SIGNED},
+
+/* 32bit memory offset. */
+#define IMM24_MEM (IMM24_PCREL+1)
+ {24, 0, MN10200_OPERAND_EXTENDED | MN10200_OPERAND_MEMADDR},
+
+/* Processor status word. */
+#define PSW (IMM24_MEM+1)
+ {0, 0, MN10200_OPERAND_PSW},
+
+/* MDR register. */
+#define MDR (PSW+1)
+ {0, 0, MN10200_OPERAND_MDR},
+
+/* Index register. */
+#define DI (MDR+1)
+ {2, 4, MN10200_OPERAND_DREG},
+
+/* 8 bit signed displacement, may promote to 16bit signed dispacement. */
+#define SD8 (DI+1)
+ {8, 0, MN10200_OPERAND_SIGNED | MN10200_OPERAND_PROMOTE},
+
+/* 16 bit signed displacement, may promote to 32bit dispacement. */
+#define SD16 (SD8+1)
+ {16, 0, MN10200_OPERAND_SIGNED | MN10200_OPERAND_PROMOTE},
+
+/* 8 bit pc-relative displacement. */
+#define SD8N_PCREL (SD16+1)
+ {8, 0, MN10200_OPERAND_SIGNED | MN10200_OPERAND_PCREL | MN10200_OPERAND_RELAX},
+
+/* 8 bit signed immediate which may promote to 16bit signed immediate. */
+#define SIMM8 (SD8N_PCREL+1)
+ {8, 0, MN10200_OPERAND_SIGNED | MN10200_OPERAND_PROMOTE},
+
+/* 16 bit signed immediate which may promote to 32bit immediate. */
+#define SIMM16 (SIMM8+1)
+ {16, 0, MN10200_OPERAND_SIGNED | MN10200_OPERAND_PROMOTE},
+
+/* 16 bit signed immediate which may not promote. */
+#define SIMM16N (SIMM16+1)
+ {16, 0, MN10200_OPERAND_SIGNED | MN10200_OPERAND_NOCHECK},
+
+/* Either an open paren or close paren. */
+#define PAREN (SIMM16N+1)
+ {0, 0, MN10200_OPERAND_PAREN},
+
+/* dn register that appears in the first and second register positions. */
+#define DN01 (PAREN+1)
+ {2, 0, MN10200_OPERAND_DREG | MN10200_OPERAND_REPEATED},
+
+/* an register that appears in the first and second register positions. */
+#define AN01 (DN01+1)
+ {2, 0, MN10200_OPERAND_AREG | MN10200_OPERAND_REPEATED},
+} ;
+
+#define MEM(ADDR) PAREN, ADDR, PAREN
+#define MEM2(ADDR1,ADDR2) PAREN, ADDR1, ADDR2, PAREN
+
+/* The opcode table.
+
+ The format of the opcode table is:
+
+ NAME OPCODE MASK { OPERANDS }
+
+ NAME is the name of the instruction.
+ OPCODE is the instruction opcode.
+ MASK is the opcode mask; this is used to tell the disassembler
+ which bits in the actual opcode must match OPCODE.
+ OPERANDS is the list of operands.
+
+ The disassembler reads the table in order and prints the first
+ instruction which matches, so this table is sorted to put more
+ specific instructions before more general instructions. It is also
+ sorted by major opcode. */
+
+const struct mn10200_opcode mn10200_opcodes[] = {
+{ "mov", 0x8000, 0xf000, FMT_2, {SIMM8, DN01}},
+{ "mov", 0x80, 0xf0, FMT_1, {DN1, DM0}},
+{ "mov", 0xf230, 0xfff0, FMT_4, {DM1, AN0}},
+{ "mov", 0xf2f0, 0xfff0, FMT_4, {AN1, DM0}},
+{ "mov", 0xf270, 0xfff0, FMT_4, {AN1, AM0}},
+{ "mov", 0xf3f0, 0xfffc, FMT_4, {PSW, DN0}},
+{ "mov", 0xf3d0, 0xfff3, FMT_4, {DN1, PSW}},
+{ "mov", 0xf3e0, 0xfffc, FMT_4, {MDR, DN0}},
+{ "mov", 0xf3c0, 0xfff3, FMT_4, {DN1, MDR}},
+{ "mov", 0x20, 0xf0, FMT_1, {MEM(AN1), DM0}},
+{ "mov", 0x6000, 0xf000, FMT_2, {MEM2(SD8, AN1), DM0}},
+{ "mov", 0xf7c00000, 0xfff00000, FMT_6, {MEM2(SD16, AN1), DM0}},
+{ "mov", 0xf4800000, 0xfff00000, FMT_7, {MEM2(IMM24,AN1), DM0}},
+{ "mov", 0xf140, 0xffc0, FMT_4, {MEM2(DI, AN1), DM0}},
+{ "mov", 0xc80000, 0xfc0000, FMT_3, {MEM(IMM16_MEM), DN0}},
+{ "mov", 0xf4c00000, 0xfffc0000, FMT_7, {MEM(IMM24_MEM), DN0}},
+{ "mov", 0x7000, 0xf000, FMT_2, {MEM2(SD8,AN1), AM0}},
+{ "mov", 0x7000, 0xf000, FMT_2, {MEM(AN1), AM0}},
+{ "mov", 0xf7b00000, 0xfff00000, FMT_6, {MEM2(SD16, AN1), AM0}},
+{ "mov", 0xf4f00000, 0xfff00000, FMT_7, {MEM2(IMM24,AN1), AM0}},
+{ "mov", 0xf100, 0xffc0, FMT_4, {MEM2(DI, AN1), AM0}},
+{ "mov", 0xf7300000, 0xfffc0000, FMT_6, {MEM(IMM16_MEM), AN0}},
+{ "mov", 0xf4d00000, 0xfffc0000, FMT_7, {MEM(IMM24_MEM), AN0}},
+{ "mov", 0x00, 0xf0, FMT_1, {DM0, MEM(AN1)}},
+{ "mov", 0x4000, 0xf000, FMT_2, {DM0, MEM2(SD8, AN1)}},
+{ "mov", 0xf7800000, 0xfff00000, FMT_6, {DM0, MEM2(SD16, AN1)}},
+{ "mov", 0xf4000000, 0xfff00000, FMT_7, {DM0, MEM2(IMM24, AN1)}},
+{ "mov", 0xf1c0, 0xffc0, FMT_4, {DM0, MEM2(DI, AN1)}},
+{ "mov", 0xc00000, 0xfc0000, FMT_3, {DN0, MEM(IMM16_MEM)}},
+{ "mov", 0xf4400000, 0xfffc0000, FMT_7, {DN0, MEM(IMM24_MEM)}},
+{ "mov", 0x5000, 0xf000, FMT_2, {AM0, MEM2(SD8, AN1)}},
+{ "mov", 0x5000, 0xf000, FMT_2, {AM0, MEM(AN1)}},
+{ "mov", 0xf7a00000, 0xfff00000, FMT_6, {AM0, MEM2(SD16, AN1)}},
+{ "mov", 0xf4100000, 0xfff00000, FMT_7, {AM0, MEM2(IMM24,AN1)}},
+{ "mov", 0xf180, 0xffc0, FMT_4, {AM0, MEM2(DI, AN1)}},
+{ "mov", 0xf7200000, 0xfffc0000, FMT_6, {AN0, MEM(IMM16_MEM)}},
+{ "mov", 0xf4500000, 0xfffc0000, FMT_7, {AN0, MEM(IMM24_MEM)}},
+{ "mov", 0xf80000, 0xfc0000, FMT_3, {SIMM16, DN0}},
+{ "mov", 0xf4700000, 0xfffc0000, FMT_7, {IMM24, DN0}},
+{ "mov", 0xdc0000, 0xfc0000, FMT_3, {IMM16, AN0}},
+{ "mov", 0xf4740000, 0xfffc0000, FMT_7, {IMM24, AN0}},
+
+{ "movx", 0xf57000, 0xfff000, FMT_5, {MEM2(SD8, AN1), DM0}},
+{ "movx", 0xf7700000, 0xfff00000, FMT_6, {MEM2(SD16, AN1), DM0}},
+{ "movx", 0xf4b00000, 0xfff00000, FMT_7, {MEM2(IMM24,AN1), DM0}},
+{ "movx", 0xf55000, 0xfff000, FMT_5, {DM0, MEM2(SD8, AN1)}},
+{ "movx", 0xf7600000, 0xfff00000, FMT_6, {DM0, MEM2(SD16, AN1)}},
+{ "movx", 0xf4300000, 0xfff00000, FMT_7, {DM0, MEM2(IMM24, AN1)}},
+
+{ "movb", 0xf52000, 0xfff000, FMT_5, {MEM2(SD8, AN1), DM0}},
+{ "movb", 0xf7d00000, 0xfff00000, FMT_6, {MEM2(SD16, AN1), DM0}},
+{ "movb", 0xf4a00000, 0xfff00000, FMT_7, {MEM2(IMM24,AN1), DM0}},
+{ "movb", 0xf040, 0xffc0, FMT_4, {MEM2(DI, AN1), DM0}},
+{ "movb", 0xf4c40000, 0xfffc0000, FMT_7, {MEM(IMM24_MEM), DN0}},
+{ "movb", 0x10, 0xf0, FMT_1, {DM0, MEM(AN1)}},
+{ "movb", 0xf51000, 0xfff000, FMT_5, {DM0, MEM2(SD8, AN1)}},
+{ "movb", 0xf7900000, 0xfff00000, FMT_6, {DM0, MEM2(SD16, AN1)}},
+{ "movb", 0xf4200000, 0xfff00000, FMT_7, {DM0, MEM2(IMM24, AN1)}},
+{ "movb", 0xf0c0, 0xffc0, FMT_4, {DM0, MEM2(DI, AN1)}},
+{ "movb", 0xc40000, 0xfc0000, FMT_3, {DN0, MEM(IMM16_MEM)}},
+{ "movb", 0xf4440000, 0xfffc0000, FMT_7, {DN0, MEM(IMM24_MEM)}},
+
+{ "movbu", 0x30, 0xf0, FMT_1, {MEM(AN1), DM0}},
+{ "movbu", 0xf53000, 0xfff000, FMT_5, {MEM2(SD8, AN1), DM0}},
+{ "movbu", 0xf7500000, 0xfff00000, FMT_6, {MEM2(SD16, AN1), DM0}},
+{ "movbu", 0xf4900000, 0xfff00000, FMT_7, {MEM2(IMM24,AN1), DM0}},
+{ "movbu", 0xf080, 0xffc0, FMT_4, {MEM2(DI, AN1), DM0}},
+{ "movbu", 0xcc0000, 0xfc0000, FMT_3, {MEM(IMM16_MEM), DN0}},
+{ "movbu", 0xf4c80000, 0xfffc0000, FMT_7, {MEM(IMM24_MEM), DN0}},
+
+{ "ext", 0xf3c1, 0xfff3, FMT_4, {DN1}},
+{ "extx", 0xb0, 0xfc, FMT_1, {DN0}},
+{ "extxu", 0xb4, 0xfc, FMT_1, {DN0}},
+{ "extxb", 0xb8, 0xfc, FMT_1, {DN0}},
+{ "extxbu", 0xbc, 0xfc, FMT_1, {DN0}},
+
+{ "add", 0x90, 0xf0, FMT_1, {DN1, DM0}},
+{ "add", 0xf200, 0xfff0, FMT_4, {DM1, AN0}},
+{ "add", 0xf2c0, 0xfff0, FMT_4, {AN1, DM0}},
+{ "add", 0xf240, 0xfff0, FMT_4, {AN1, AM0}},
+{ "add", 0xd400, 0xfc00, FMT_2, {SIMM8, DN0}},
+{ "add", 0xf7180000, 0xfffc0000, FMT_6, {SIMM16, DN0}},
+{ "add", 0xf4600000, 0xfffc0000, FMT_7, {IMM24, DN0}},
+{ "add", 0xd000, 0xfc00, FMT_2, {SIMM8, AN0}},
+{ "add", 0xf7080000, 0xfffc0000, FMT_6, {SIMM16, AN0}},
+{ "add", 0xf4640000, 0xfffc0000, FMT_7, {IMM24, AN0}},
+{ "addc", 0xf280, 0xfff0, FMT_4, {DN1, DM0}},
+{ "addnf", 0xf50c00, 0xfffc00, FMT_5, {SIMM8, AN0}},
+
+{ "sub", 0xa0, 0xf0, FMT_1, {DN1, DM0}},
+{ "sub", 0xf210, 0xfff0, FMT_4, {DN1, AN0}},
+{ "sub", 0xf2d0, 0xfff0, FMT_4, {AN1, DM0}},
+{ "sub", 0xf250, 0xfff0, FMT_4, {AN1, AM0}},
+{ "sub", 0xf71c0000, 0xfffc0000, FMT_6, {IMM16, DN0}},
+{ "sub", 0xf4680000, 0xfffc0000, FMT_7, {IMM24, DN0}},
+{ "sub", 0xf70c0000, 0xfffc0000, FMT_6, {IMM16, AN0}},
+{ "sub", 0xf46c0000, 0xfffc0000, FMT_7, {IMM24, AN0}},
+{ "subc", 0xf290, 0xfff0, FMT_4, {DN1, DM0}},
+
+{ "mul", 0xf340, 0xfff0, FMT_4, {DN1, DM0}},
+{ "mulu", 0xf350, 0xfff0, FMT_4, {DN1, DM0}},
+
+{ "divu", 0xf360, 0xfff0, FMT_4, {DN1, DM0}},
+
+{ "cmp", 0xf390, 0xfff0, FMT_4, {DN1, DM0}},
+{ "cmp", 0xf220, 0xfff0, FMT_4, {DM1, AN0}},
+{ "cmp", 0xf2e0, 0xfff0, FMT_4, {AN1, DM0}},
+{ "cmp", 0xf260, 0xfff0, FMT_4, {AN1, AM0}},
+{ "cmp", 0xd800, 0xfc00, FMT_2, {SIMM8, DN0}},
+{ "cmp", 0xf7480000, 0xfffc0000, FMT_6, {SIMM16, DN0}},
+{ "cmp", 0xf4780000, 0xfffc0000, FMT_7, {IMM24, DN0}},
+{ "cmp", 0xec0000, 0xfc0000, FMT_3, {IMM16, AN0}},
+{ "cmp", 0xf47c0000, 0xfffc0000, FMT_7, {IMM24, AN0}},
+
+{ "and", 0xf300, 0xfff0, FMT_4, {DN1, DM0}},
+{ "and", 0xf50000, 0xfffc00, FMT_5, {IMM8, DN0}},
+{ "and", 0xf7000000, 0xfffc0000, FMT_6, {SIMM16N, DN0}},
+{ "and", 0xf7100000, 0xffff0000, FMT_6, {SIMM16N, PSW}},
+{ "or", 0xf310, 0xfff0, FMT_4, {DN1, DM0}},
+{ "or", 0xf50800, 0xfffc00, FMT_5, {IMM8, DN0}},
+{ "or", 0xf7400000, 0xfffc0000, FMT_6, {SIMM16N, DN0}},
+{ "or", 0xf7140000, 0xffff0000, FMT_6, {SIMM16N, PSW}},
+{ "xor", 0xf320, 0xfff0, FMT_4, {DN1, DM0}},
+{ "xor", 0xf74c0000, 0xfffc0000, FMT_6, {SIMM16N, DN0}},
+{ "not", 0xf3e4, 0xfffc, FMT_4, {DN0}},
+
+{ "asr", 0xf338, 0xfffc, FMT_4, {DN0}},
+{ "lsr", 0xf33c, 0xfffc, FMT_4, {DN0}},
+{ "ror", 0xf334, 0xfffc, FMT_4, {DN0}},
+{ "rol", 0xf330, 0xfffc, FMT_4, {DN0}},
+
+{ "btst", 0xf50400, 0xfffc00, FMT_5, {IMM8, DN0}},
+{ "btst", 0xf7040000, 0xfffc0000, FMT_6, {SIMM16N, DN0}},
+{ "bset", 0xf020, 0xfff0, FMT_4, {DM0, MEM(AN1)}},
+{ "bclr", 0xf030, 0xfff0, FMT_4, {DM0, MEM(AN1)}},
+
+{ "beq", 0xe800, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bne", 0xe900, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "blt", 0xe000, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "ble", 0xe300, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bge", 0xe200, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bgt", 0xe100, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bcs", 0xe400, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bls", 0xe700, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bcc", 0xe600, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bhi", 0xe500, 0xff00, FMT_2, {SD8N_PCREL}},
+{ "bvc", 0xf5fc00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bvs", 0xf5fd00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bnc", 0xf5fe00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bns", 0xf5ff00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bra", 0xea00, 0xff00, FMT_2, {SD8N_PCREL}},
+
+{ "beqx", 0xf5e800, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bnex", 0xf5e900, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bltx", 0xf5e000, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "blex", 0xf5e300, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bgex", 0xf5e200, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bgtx", 0xf5e100, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bcsx", 0xf5e400, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "blsx", 0xf5e700, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bccx", 0xf5e600, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bhix", 0xf5e500, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bvcx", 0xf5ec00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bvsx", 0xf5ed00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bncx", 0xf5ee00, 0xffff00, FMT_5, {SD8N_PCREL}},
+{ "bnsx", 0xf5ef00, 0xffff00, FMT_5, {SD8N_PCREL}},
+
+{ "jmp", 0xfc0000, 0xff0000, FMT_3, {IMM16_PCREL}},
+{ "jmp", 0xf4e00000, 0xffff0000, FMT_7, {IMM24_PCREL}},
+{ "jmp", 0xf000, 0xfff3, FMT_4, {PAREN,AN1,PAREN}},
+{ "jsr", 0xfd0000, 0xff0000, FMT_3, {IMM16_PCREL}},
+{ "jsr", 0xf4e10000, 0xffff0000, FMT_7, {IMM24_PCREL}},
+{ "jsr", 0xf001, 0xfff3, FMT_4, {PAREN,AN1,PAREN}},
+
+{ "nop", 0xf6, 0xff, FMT_1, {UNUSED}},
+
+{ "rts", 0xfe, 0xff, FMT_1, {UNUSED}},
+{ "rti", 0xeb, 0xff, FMT_1, {UNUSED}},
+
+/* Extension. We need some instruction to trigger "emulated syscalls"
+ for our simulator. */
+{ "syscall", 0xf010, 0xffff, FMT_4, {UNUSED}},
+
+/* Extension. When talking to the simulator, gdb requires some instruction
+ that will trigger a "breakpoint" (really just an instruction that isn't
+ otherwise used by the tools. This instruction must be the same size
+ as the smallest instruction on the target machine. In the case of the
+ mn10x00 the "break" instruction must be one byte. 0xff is available on
+ both mn10x00 architectures. */
+{ "break", 0xff, 0xff, FMT_1, {UNUSED}},
+
+{ 0, 0, 0, 0, {0}},
+
+} ;
+
+const int mn10200_num_opcodes =
+ sizeof (mn10200_opcodes) / sizeof (mn10200_opcodes[0]);
+
+
diff --git a/opcodes/m10300-dis.c b/opcodes/m10300-dis.c
new file mode 100644
index 00000000000..415bffce37d
--- /dev/null
+++ b/opcodes/m10300-dis.c
@@ -0,0 +1,548 @@
+/* Disassemble MN10300 instructions.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include <stdio.h>
+
+#include "ansidecl.h"
+#include "opcode/mn10300.h"
+#include "dis-asm.h"
+#include "opintl.h"
+
+static void disassemble PARAMS ((bfd_vma, struct disassemble_info *,
+ unsigned long insn, unsigned int));
+
+int
+print_insn_mn10300 (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int status;
+ bfd_byte buffer[4];
+ unsigned long insn;
+ unsigned int consume;
+
+ /* First figure out how big the opcode is. */
+ status = (*info->read_memory_func) (memaddr, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = *(unsigned char *) buffer;
+
+ /* These are one byte insns. */
+ if ((insn & 0xf3) == 0x00
+ || (insn & 0xf0) == 0x10
+ || (insn & 0xfc) == 0x3c
+ || (insn & 0xf3) == 0x41
+ || (insn & 0xf3) == 0x40
+ || (insn & 0xfc) == 0x50
+ || (insn & 0xfc) == 0x54
+ || (insn & 0xf0) == 0x60
+ || (insn & 0xf0) == 0x70
+ || ((insn & 0xf0) == 0x80
+ && (insn & 0x0c) >> 2 != (insn & 0x03))
+ || ((insn & 0xf0) == 0x90
+ && (insn & 0x0c) >> 2 != (insn & 0x03))
+ || ((insn & 0xf0) == 0xa0
+ && (insn & 0x0c) >> 2 != (insn & 0x03))
+ || ((insn & 0xf0) == 0xb0
+ && (insn & 0x0c) >> 2 != (insn & 0x03))
+ || (insn & 0xff) == 0xcb
+ || (insn & 0xfc) == 0xd0
+ || (insn & 0xfc) == 0xd4
+ || (insn & 0xfc) == 0xd8
+ || (insn & 0xf0) == 0xe0
+ || (insn & 0xff) == 0xff)
+ {
+ consume = 1;
+ }
+
+ /* These are two byte insns. */
+ else if ((insn & 0xf0) == 0x80
+ || (insn & 0xf0) == 0x90
+ || (insn & 0xf0) == 0xa0
+ || (insn & 0xf0) == 0xb0
+ || (insn & 0xfc) == 0x20
+ || (insn & 0xfc) == 0x28
+ || (insn & 0xf3) == 0x43
+ || (insn & 0xf3) == 0x42
+ || (insn & 0xfc) == 0x58
+ || (insn & 0xfc) == 0x5c
+ || ((insn & 0xf0) == 0xc0
+ && (insn & 0xff) != 0xcb
+ && (insn & 0xff) != 0xcc
+ && (insn & 0xff) != 0xcd)
+ || (insn & 0xff) == 0xf0
+ || (insn & 0xff) == 0xf1
+ || (insn & 0xff) == 0xf2
+ || (insn & 0xff) == 0xf3
+ || (insn & 0xff) == 0xf4
+ || (insn & 0xff) == 0xf5
+ || (insn & 0xff) == 0xf6)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb16 (buffer);
+ consume = 2;
+ }
+
+ /* These are three byte insns. */
+ else if ((insn & 0xff) == 0xf8
+ || (insn & 0xff) == 0xcc
+ || (insn & 0xff) == 0xf9
+ || (insn & 0xf3) == 0x01
+ || (insn & 0xf3) == 0x02
+ || (insn & 0xf3) == 0x03
+ || (insn & 0xfc) == 0x24
+ || (insn & 0xfc) == 0x2c
+ || (insn & 0xfc) == 0x30
+ || (insn & 0xfc) == 0x34
+ || (insn & 0xfc) == 0x38
+ || (insn & 0xff) == 0xde
+ || (insn & 0xff) == 0xdf
+ || (insn & 0xff) == 0xcc)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb16 (buffer);
+ insn <<= 8;
+ status = (*info->read_memory_func) (memaddr + 2, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn |= *(unsigned char *)buffer;
+ consume = 3;
+ }
+
+ /* These are four byte insns. */
+ else if ((insn & 0xff) == 0xfa
+ || (insn & 0xff) == 0xfb)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb32 (buffer);
+ consume = 4;
+ }
+
+ /* These are five byte insns. */
+ else if ((insn & 0xff) == 0xcd
+ || (insn & 0xff) == 0xdc)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ insn = bfd_getb32 (buffer);
+ consume = 5;
+ }
+
+ /* These are six byte insns. */
+ else if ((insn & 0xff) == 0xfd
+ || (insn & 0xff) == 0xfc)
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ insn = bfd_getb32 (buffer);
+ consume = 6;
+ }
+
+ /* Else its a seven byte insns (in theory). */
+ else
+ {
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ insn = bfd_getb32 (buffer);
+ consume = 7;
+ }
+
+ disassemble (memaddr, info, insn, consume);
+
+ return consume;
+}
+
+static void
+disassemble (memaddr, info, insn, size)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+ unsigned long insn;
+ unsigned int size;
+{
+ struct mn10300_opcode *op = (struct mn10300_opcode *)mn10300_opcodes;
+ const struct mn10300_operand *operand;
+ bfd_byte buffer[4];
+ unsigned long extension = 0;
+ int status, match = 0;
+
+ /* Find the opcode. */
+ while (op->name)
+ {
+ int mysize, extra_shift;
+
+ if (op->format == FMT_S0)
+ mysize = 1;
+ else if (op->format == FMT_S1
+ || op->format == FMT_D0)
+ mysize = 2;
+ else if (op->format == FMT_S2
+ || op->format == FMT_D1)
+ mysize = 3;
+ else if (op->format == FMT_S4)
+ mysize = 5;
+ else if (op->format == FMT_D2)
+ mysize = 4;
+ else if (op->format == FMT_D4)
+ mysize = 6;
+ else
+ mysize = 7;
+
+ if ((op->mask & insn) == op->opcode
+ && size == (unsigned int) mysize
+ && (op->machine == 0
+ || op->machine == info->mach))
+ {
+ const unsigned char *opindex_ptr;
+ unsigned int nocomma;
+ int paren = 0;
+
+ if (op->format == FMT_D1 || op->format == FMT_S1)
+ extra_shift = 8;
+ else if (op->format == FMT_D2 || op->format == FMT_D4
+ || op->format == FMT_S2 || op->format == FMT_S4
+ || op->format == FMT_S6 || op->format == FMT_D5)
+ extra_shift = 16;
+ else
+ extra_shift = 0;
+
+ if (size == 1 || size == 2)
+ {
+ extension = 0;
+ }
+ else if (size == 3
+ && (op->format == FMT_D1
+ || op->opcode == 0xdf0000
+ || op->opcode == 0xde0000))
+ {
+ extension = 0;
+ }
+ else if (size == 3)
+ {
+ insn &= 0xff0000;
+ status = (*info->read_memory_func) (memaddr + 1, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+
+ insn |= bfd_getl16 (buffer);
+ extension = 0;
+ }
+ else if (size == 4
+ && (op->opcode == 0xfaf80000
+ || op->opcode == 0xfaf00000
+ || op->opcode == 0xfaf40000))
+ {
+ extension = 0;
+ }
+ else if (size == 4)
+ {
+ insn &= 0xffff0000;
+ status = (*info->read_memory_func) (memaddr + 2, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+
+ insn |= bfd_getl16 (buffer);
+ extension = 0;
+ }
+ else if (size == 5 && op->opcode == 0xdc000000)
+ {
+ unsigned long temp = 0;
+ status = (*info->read_memory_func) (memaddr + 1, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ temp |= bfd_getl32 (buffer);
+
+ insn &= 0xff000000;
+ insn |= (temp & 0xffffff00) >> 8;
+ extension = temp & 0xff;
+ }
+ else if (size == 5)
+ {
+ unsigned long temp = 0;
+ status = (*info->read_memory_func) (memaddr + 1, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ temp |= bfd_getl16 (buffer);
+
+ insn &= 0xff0000ff;
+ insn |= temp << 8;
+
+ status = (*info->read_memory_func) (memaddr + 4, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ extension = *(unsigned char *)buffer;
+ }
+ else if (size == 6)
+ {
+ unsigned long temp = 0;
+ status = (*info->read_memory_func) (memaddr + 2, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ temp |= bfd_getl32 (buffer);
+
+ insn &= 0xffff0000;
+ insn |= (temp >> 16) & 0xffff;
+ extension = temp & 0xffff;
+ }
+ else if (size == 7 && op->opcode == 0xdd000000)
+ {
+ unsigned long temp = 0;
+ status = (*info->read_memory_func) (memaddr + 1, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ temp |= bfd_getl32 (buffer);
+
+ insn &= 0xff000000;
+ insn |= (temp >> 8) & 0xffffff;
+ extension = (temp & 0xff) << 16;
+
+ status = (*info->read_memory_func) (memaddr + 5, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ extension |= bfd_getb16 (buffer);
+ }
+ else if (size == 7)
+ {
+ unsigned long temp = 0;
+ status = (*info->read_memory_func) (memaddr + 2, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ temp |= bfd_getl32 (buffer);
+
+ insn &= 0xffff0000;
+ insn |= (temp >> 16) & 0xffff;
+ extension = (temp & 0xffff) << 8;
+
+ status = (*info->read_memory_func) (memaddr + 6, buffer, 1, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return;
+ }
+ extension |= *(unsigned char *)buffer;
+ }
+
+ match = 1;
+ (*info->fprintf_func) (info->stream, "%s\t", op->name);
+
+ /* Now print the operands. */
+ for (opindex_ptr = op->operands, nocomma = 1;
+ *opindex_ptr != 0;
+ opindex_ptr++)
+ {
+ unsigned long value;
+
+ operand = &mn10300_operands[*opindex_ptr];
+
+
+ if ((operand->flags & MN10300_OPERAND_SPLIT) != 0)
+ {
+ unsigned long temp;
+ value = insn & ((1 << operand->bits) - 1);
+ value <<= (32 - operand->bits);
+ temp = extension >> operand->shift;
+ temp &= ((1 << (32 - operand->bits)) - 1);
+ value |= temp;
+ }
+ else if ((operand->flags & MN10300_OPERAND_EXTENDED) != 0)
+ {
+ value = ((extension >> (operand->shift))
+ & ((1 << operand->bits) - 1));
+ }
+ else
+ {
+ value = ((insn >> (operand->shift))
+ & ((1 << operand->bits) - 1));
+ }
+
+ if ((operand->flags & MN10300_OPERAND_SIGNED) != 0
+ )
+ value = ((long)(value << (32 - operand->bits))
+ >> (32 - operand->bits));
+
+ if (!nocomma
+ && (!paren
+ || ((operand->flags & MN10300_OPERAND_PAREN) == 0)))
+ (*info->fprintf_func) (info->stream, ",");
+
+ nocomma = 0;
+
+ if ((operand->flags & MN10300_OPERAND_DREG) != 0)
+ {
+ value = ((insn >> (operand->shift + extra_shift))
+ & ((1 << operand->bits) - 1));
+ (*info->fprintf_func) (info->stream, "d%d", value);
+ }
+
+ else if ((operand->flags & MN10300_OPERAND_AREG) != 0)
+ {
+ value = ((insn >> (operand->shift + extra_shift))
+ & ((1 << operand->bits) - 1));
+ (*info->fprintf_func) (info->stream, "a%d", value);
+ }
+
+ else if ((operand->flags & MN10300_OPERAND_SP) != 0)
+ (*info->fprintf_func) (info->stream, "sp");
+
+ else if ((operand->flags & MN10300_OPERAND_PSW) != 0)
+ (*info->fprintf_func) (info->stream, "psw");
+
+ else if ((operand->flags & MN10300_OPERAND_MDR) != 0)
+ (*info->fprintf_func) (info->stream, "mdr");
+
+
+ else if ((operand->flags & MN10300_OPERAND_PAREN) != 0)
+ {
+ if (paren)
+ (*info->fprintf_func) (info->stream, ")");
+ else
+ {
+ (*info->fprintf_func) (info->stream, "(");
+ nocomma = 1;
+ }
+ paren = !paren;
+ }
+
+ else if ((operand->flags & MN10300_OPERAND_PCREL) != 0)
+ (*info->print_address_func) ((long) value + memaddr, info);
+
+ else if ((operand->flags & MN10300_OPERAND_MEMADDR) != 0)
+ (*info->print_address_func) (value, info);
+
+ else if ((operand->flags & MN10300_OPERAND_REG_LIST) != 0)
+ {
+ int comma = 0;
+
+ (*info->fprintf_func) (info->stream, "[");
+ if (value & 0x80)
+ {
+ (*info->fprintf_func) (info->stream, "d2");
+ comma = 1;
+ }
+
+ if (value & 0x40)
+ {
+ if (comma)
+ (*info->fprintf_func) (info->stream, ",");
+ (*info->fprintf_func) (info->stream, "d3");
+ comma = 1;
+ }
+
+ if (value & 0x20)
+ {
+ if (comma)
+ (*info->fprintf_func) (info->stream, ",");
+ (*info->fprintf_func) (info->stream, "a2");
+ comma = 1;
+ }
+
+ if (value & 0x10)
+ {
+ if (comma)
+ (*info->fprintf_func) (info->stream, ",");
+ (*info->fprintf_func) (info->stream, "a3");
+ comma = 1;
+ }
+
+ if (value & 0x08)
+ {
+ if (comma)
+ (*info->fprintf_func) (info->stream, ",");
+ (*info->fprintf_func) (info->stream, "other");
+ comma = 1;
+ }
+
+ (*info->fprintf_func) (info->stream, "]");
+ }
+
+ else
+ (*info->fprintf_func) (info->stream, "%d", value);
+ }
+ /* All done. */
+ break;
+ }
+ op++;
+ }
+
+ if (!match)
+ {
+ /* xgettext:c-format */
+ (*info->fprintf_func) (info->stream, _("unknown\t0x%04x"), insn);
+ }
+}
diff --git a/opcodes/m10300-opc.c b/opcodes/m10300-opc.c
new file mode 100644
index 00000000000..8d0c0f3f8a1
--- /dev/null
+++ b/opcodes/m10300-opc.c
@@ -0,0 +1,683 @@
+/* Assemble Matsushita MN10300 instructions.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file is formatted at > 80 columns. Attempting to read it on a
+ screeen with less than 80 columns will be difficult. */
+#include "ansidecl.h"
+#include "opcode/mn10300.h"
+
+
+const struct mn10300_operand mn10300_operands[] = {
+#define UNUSED 0
+ {0, 0, 0},
+
+/* dn register in the first register operand position. */
+#define DN0 (UNUSED+1)
+ {2, 0, MN10300_OPERAND_DREG},
+
+/* dn register in the second register operand position. */
+#define DN1 (DN0+1)
+ {2, 2, MN10300_OPERAND_DREG},
+
+/* dn register in the third register operand position. */
+#define DN2 (DN1+1)
+ {2, 4, MN10300_OPERAND_DREG},
+
+/* dm register in the first register operand position. */
+#define DM0 (DN2+1)
+ {2, 0, MN10300_OPERAND_DREG},
+
+/* dm register in the second register operand position. */
+#define DM1 (DM0+1)
+ {2, 2, MN10300_OPERAND_DREG},
+
+/* dm register in the third register operand position. */
+#define DM2 (DM1+1)
+ {2, 4, MN10300_OPERAND_DREG},
+
+/* an register in the first register operand position. */
+#define AN0 (DM2+1)
+ {2, 0, MN10300_OPERAND_AREG},
+
+/* an register in the second register operand position. */
+#define AN1 (AN0+1)
+ {2, 2, MN10300_OPERAND_AREG},
+
+/* an register in the third register operand position. */
+#define AN2 (AN1+1)
+ {2, 4, MN10300_OPERAND_AREG},
+
+/* am register in the first register operand position. */
+#define AM0 (AN2+1)
+ {2, 0, MN10300_OPERAND_AREG},
+
+/* am register in the second register operand position. */
+#define AM1 (AM0+1)
+ {2, 2, MN10300_OPERAND_AREG},
+
+/* am register in the third register operand position. */
+#define AM2 (AM1+1)
+ {2, 4, MN10300_OPERAND_AREG},
+
+/* 8 bit unsigned immediate which may promote to a 16bit
+ unsigned immediate. */
+#define IMM8 (AM2+1)
+ {8, 0, MN10300_OPERAND_PROMOTE},
+
+/* 16 bit unsigned immediate which may promote to a 32bit
+ unsigned immediate. */
+#define IMM16 (IMM8+1)
+ {16, 0, MN10300_OPERAND_PROMOTE},
+
+/* 16 bit pc-relative immediate which may promote to a 16bit
+ pc-relative immediate. */
+#define IMM16_PCREL (IMM16+1)
+ {16, 0, MN10300_OPERAND_PCREL | MN10300_OPERAND_RELAX | MN10300_OPERAND_SIGNED},
+
+/* 16bit unsigned dispacement in a memory operation which
+ may promote to a 32bit displacement. */
+#define IMM16_MEM (IMM16_PCREL+1)
+ {16, 0, MN10300_OPERAND_PROMOTE | MN10300_OPERAND_MEMADDR},
+
+/* 32bit immediate, high 16 bits in the main instruction
+ word, 16bits in the extension word.
+
+ The "bits" field indicates how many bits are in the
+ main instruction word for MN10300_OPERAND_SPLIT! */
+#define IMM32 (IMM16_MEM+1)
+ {16, 0, MN10300_OPERAND_SPLIT},
+
+/* 32bit pc-relative offset. */
+#define IMM32_PCREL (IMM32+1)
+ {16, 0, MN10300_OPERAND_SPLIT | MN10300_OPERAND_PCREL},
+
+/* 32bit memory offset. */
+#define IMM32_MEM (IMM32_PCREL+1)
+ {16, 0, MN10300_OPERAND_SPLIT | MN10300_OPERAND_MEMADDR},
+
+/* 32bit immediate, high 16 bits in the main instruction
+ word, 16bits in the extension word, low 16bits are left
+ shifted 8 places.
+
+ The "bits" field indicates how many bits are in the
+ main instruction word for MN10300_OPERAND_SPLIT! */
+#define IMM32_LOWSHIFT8 (IMM32_MEM+1)
+ {16, 8, MN10300_OPERAND_SPLIT | MN10300_OPERAND_MEMADDR},
+
+/* 32bit immediate, high 24 bits in the main instruction
+ word, 8 in the extension word.
+
+ The "bits" field indicates how many bits are in the
+ main instruction word for MN10300_OPERAND_SPLIT! */
+#define IMM32_HIGH24 (IMM32_LOWSHIFT8+1)
+ {24, 0, MN10300_OPERAND_SPLIT | MN10300_OPERAND_PCREL},
+
+/* 32bit immediate, high 24 bits in the main instruction
+ word, 8 in the extension word, low 8 bits are left
+ shifted 16 places.
+
+ The "bits" field indicates how many bits are in the
+ main instruction word for MN10300_OPERAND_SPLIT! */
+#define IMM32_HIGH24_LOWSHIFT16 (IMM32_HIGH24+1)
+ {24, 16, MN10300_OPERAND_SPLIT | MN10300_OPERAND_PCREL},
+
+/* Stack pointer. */
+#define SP (IMM32_HIGH24_LOWSHIFT16+1)
+ {8, 0, MN10300_OPERAND_SP},
+
+/* Processor status word. */
+#define PSW (SP+1)
+ {0, 0, MN10300_OPERAND_PSW},
+
+/* MDR register. */
+#define MDR (PSW+1)
+ {0, 0, MN10300_OPERAND_MDR},
+
+/* Index register. */
+#define DI (MDR+1)
+ {2, 2, MN10300_OPERAND_DREG},
+
+/* 8 bit signed displacement, may promote to 16bit signed dispacement. */
+#define SD8 (DI+1)
+ {8, 0, MN10300_OPERAND_SIGNED | MN10300_OPERAND_PROMOTE},
+
+/* 16 bit signed displacement, may promote to 32bit dispacement. */
+#define SD16 (SD8+1)
+ {16, 0, MN10300_OPERAND_SIGNED | MN10300_OPERAND_PROMOTE},
+
+/* 8 bit signed displacement that can not promote. */
+#define SD8N (SD16+1)
+ {8, 0, MN10300_OPERAND_SIGNED},
+
+/* 8 bit pc-relative displacement. */
+#define SD8N_PCREL (SD8N+1)
+ {8, 0, MN10300_OPERAND_SIGNED | MN10300_OPERAND_PCREL | MN10300_OPERAND_RELAX},
+
+/* 8 bit signed displacement shifted left 8 bits in the instruction. */
+#define SD8N_SHIFT8 (SD8N_PCREL+1)
+ {8, 8, MN10300_OPERAND_SIGNED},
+
+/* 8 bit signed immediate which may promote to 16bit signed immediate. */
+#define SIMM8 (SD8N_SHIFT8+1)
+ {8, 0, MN10300_OPERAND_SIGNED | MN10300_OPERAND_PROMOTE},
+
+/* 16 bit signed immediate which may promote to 32bit immediate. */
+#define SIMM16 (SIMM8+1)
+ {16, 0, MN10300_OPERAND_SIGNED | MN10300_OPERAND_PROMOTE},
+
+/* Either an open paren or close paren. */
+#define PAREN (SIMM16+1)
+ {0, 0, MN10300_OPERAND_PAREN},
+
+/* dn register that appears in the first and second register positions. */
+#define DN01 (PAREN+1)
+ {2, 0, MN10300_OPERAND_DREG | MN10300_OPERAND_REPEATED},
+
+/* an register that appears in the first and second register positions. */
+#define AN01 (DN01+1)
+ {2, 0, MN10300_OPERAND_AREG | MN10300_OPERAND_REPEATED},
+
+/* 16bit pc-relative displacement which may promote to 32bit pc-relative
+ displacement. */
+#define D16_SHIFT (AN01+1)
+ {16, 8, MN10300_OPERAND_PCREL | MN10300_OPERAND_RELAX | MN10300_OPERAND_SIGNED},
+
+/* 8 bit immediate found in the extension word. */
+#define IMM8E (D16_SHIFT+1)
+ {8, 0, MN10300_OPERAND_EXTENDED},
+
+/* Register list found in the extension word shifted 8 bits left. */
+#define REGSE_SHIFT8 (IMM8E+1)
+ {8, 8, MN10300_OPERAND_EXTENDED | MN10300_OPERAND_REG_LIST},
+
+/* Register list shifted 8 bits left. */
+#define REGS_SHIFT8 (REGSE_SHIFT8 + 1)
+ {8, 8, MN10300_OPERAND_REG_LIST},
+
+/* Reigster list. */
+#define REGS (REGS_SHIFT8+1)
+ {8, 0, MN10300_OPERAND_REG_LIST},
+
+
+} ;
+
+#define MEM(ADDR) PAREN, ADDR, PAREN
+#define MEMINC(ADDR) PAREN, ADDR, PLUS, PAREN
+#define MEMINC2(ADDR,INC) PAREN, ADDR, PLUS, INC, PAREN
+#define MEM2(ADDR1,ADDR2) PAREN, ADDR1, ADDR2, PAREN
+
+/* The opcode table.
+
+ The format of the opcode table is:
+
+ NAME OPCODE MASK MATCH_MASK, FORMAT, PROCESSOR { OPERANDS }
+
+ NAME is the name of the instruction.
+ OPCODE is the instruction opcode.
+ MASK is the opcode mask; this is used to tell the disassembler
+ which bits in the actual opcode must match OPCODE.
+ OPERANDS is the list of operands.
+
+ The disassembler reads the table in order and prints the first
+ instruction which matches, so this table is sorted to put more
+ specific instructions before more general instructions. It is also
+ sorted by major opcode. */
+
+const struct mn10300_opcode mn10300_opcodes[] = {
+{ "mov", 0x8000, 0xf000, 0, FMT_S1, 0, {SIMM8, DN01}},
+{ "mov", 0x80, 0xf0, 0x3, FMT_S0, 0, {DM1, DN0}},
+{ "mov", 0xf1e0, 0xfff0, 0, FMT_D0, 0, {DM1, AN0}},
+{ "mov", 0xf1d0, 0xfff0, 0, FMT_D0, 0, {AM1, DN0}},
+{ "mov", 0x9000, 0xf000, 0, FMT_S1, 0, {IMM8, AN01}},
+{ "mov", 0x90, 0xf0, 0x3, FMT_S0, 0, {AM1, AN0}},
+{ "mov", 0x3c, 0xfc, 0, FMT_S0, 0, {SP, AN0}},
+{ "mov", 0xf2f0, 0xfff3, 0, FMT_D0, 0, {AM1, SP}},
+{ "mov", 0xf2e4, 0xfffc, 0, FMT_D0, 0, {PSW, DN0}},
+{ "mov", 0xf2f3, 0xfff3, 0, FMT_D0, 0, {DM1, PSW}},
+{ "mov", 0xf2e0, 0xfffc, 0, FMT_D0, 0, {MDR, DN0}},
+{ "mov", 0xf2f2, 0xfff3, 0, FMT_D0, 0, {DM1, MDR}},
+{ "mov", 0x70, 0xf0, 0, FMT_S0, 0, {MEM(AM0), DN1}},
+{ "mov", 0x5800, 0xfcff, 0, FMT_S1, 0, {MEM(SP), DN0}},
+{ "mov", 0x300000, 0xfc0000, 0, FMT_S2, 0, {MEM(IMM16_MEM), DN0}},
+{ "mov", 0xf000, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), AN1}},
+{ "mov", 0x5c00, 0xfcff, 0, FMT_S1, 0, {MEM(SP), AN0}},
+{ "mov", 0xfaa00000, 0xfffc0000, 0, FMT_D2, 0, {MEM(IMM16_MEM), AN0}},
+{ "mov", 0x60, 0xf0, 0, FMT_S0, 0, {DM1, MEM(AN0)}},
+{ "mov", 0x4200, 0xf3ff, 0, FMT_S1, 0, {DM1, MEM(SP)}},
+{ "mov", 0x010000, 0xf30000, 0, FMT_S2, 0, {DM1, MEM(IMM16_MEM)}},
+{ "mov", 0xf010, 0xfff0, 0, FMT_D0, 0, {AM1, MEM(AN0)}},
+{ "mov", 0x4300, 0xf3ff, 0, FMT_S1, 0, {AM1, MEM(SP)}},
+{ "mov", 0xfa800000, 0xfff30000, 0, FMT_D2, 0, {AM1, MEM(IMM16_MEM)}},
+{ "mov", 0x5c00, 0xfc00, 0, FMT_S1, 0, {MEM2(IMM8, SP), AN0}},
+{ "mov", 0xf80000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}},
+{ "mov", 0xfa000000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}},
+{ "mov", 0x5800, 0xfc00, 0, FMT_S1, 0, {MEM2(IMM8, SP), DN0}},
+{ "mov", 0xfab40000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}},
+{ "mov", 0xf300, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), DN2}},
+{ "mov", 0xf82000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8,AM0), AN1}},
+{ "mov", 0xfa200000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), AN1}},
+{ "mov", 0xfab00000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), AN0}},
+{ "mov", 0xf380, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), AN2}},
+{ "mov", 0x4300, 0xf300, 0, FMT_S1, 0, {AM1, MEM2(IMM8, SP)}},
+{ "mov", 0xf81000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}},
+{ "mov", 0xfa100000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}},
+{ "mov", 0x4200, 0xf300, 0, FMT_S1, 0, {DM1, MEM2(IMM8, SP)}},
+{ "mov", 0xfa910000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}},
+{ "mov", 0xf340, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}},
+{ "mov", 0xf83000, 0xfff000, 0, FMT_D1, 0, {AM1, MEM2(SD8, AN0)}},
+{ "mov", 0xfa300000, 0xfff00000, 0, FMT_D2, 0, {AM1, MEM2(SD16, AN0)}},
+{ "mov", 0xfa900000, 0xfff30000, 0, FMT_D2, 0, {AM1, MEM2(IMM16, SP)}},
+{ "mov", 0xf3c0, 0xffc0, 0, FMT_D0, 0, {AM2, MEM2(DI, AN0)}},
+
+/* These must come after most of the other move instructions to avoid matching
+ a symbolic name with IMMxx operands. Ugh. */
+{ "mov", 0x2c0000, 0xfc0000, 0, FMT_S2, 0, {SIMM16, DN0}},
+{ "mov", 0xfccc0000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "mov", 0x240000, 0xfc0000, 0, FMT_S2, 0, {IMM16, AN0}},
+{ "mov", 0xfcdc0000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, AN0}},
+{ "mov", 0xfca40000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}},
+{ "mov", 0xfca00000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), AN0}},
+{ "mov", 0xfc810000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}},
+{ "mov", 0xfc800000, 0xfff30000, 0, FMT_D4, 0, {AM1, MEM(IMM32_MEM)}},
+{ "mov", 0xfc000000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}},
+{ "mov", 0xfcb40000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}},
+{ "mov", 0xfc200000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), AN1}},
+{ "mov", 0xfcb00000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), AN0}},
+{ "mov", 0xfc100000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}},
+{ "mov", 0xfc910000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}},
+{ "mov", 0xfc300000, 0xfff00000, 0, FMT_D4, 0, {AM1, MEM2(IMM32,AN0)}},
+{ "mov", 0xfc900000, 0xfff30000, 0, FMT_D4, 0, {AM1, MEM2(IMM32, SP)}},
+/* These non-promoting variants need to come after all the other memory
+ moves. */
+{ "mov", 0xf8f000, 0xfffc00, 0, FMT_D1, AM30, {MEM2(SD8N, AM0), SP}},
+{ "mov", 0xf8f400, 0xfffc00, 0, FMT_D1, AM30, {SP, MEM2(SD8N, AN0)}},
+
+
+
+{ "movbu", 0xf040, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), DN1}},
+{ "movbu", 0xf84000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}},
+{ "movbu", 0xfa400000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}},
+{ "movbu", 0xf8b800, 0xfffcff, 0, FMT_D1, 0, {MEM(SP), DN0}},
+{ "movbu", 0xf8b800, 0xfffc00, 0, FMT_D1, 0, {MEM2(IMM8, SP), DN0}},
+{ "movbu", 0xfab80000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}},
+{ "movbu", 0xf400, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), DN2}},
+{ "movbu", 0x340000, 0xfc0000, 0, FMT_S2, 0, {MEM(IMM16_MEM), DN0}},
+{ "movbu", 0xf050, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}},
+{ "movbu", 0xf85000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}},
+{ "movbu", 0xfa500000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}},
+{ "movbu", 0xf89200, 0xfff3ff, 0, FMT_D1, 0, {DM1, MEM(SP)}},
+{ "movbu", 0xf89200, 0xfff300, 0, FMT_D1, 0, {DM1, MEM2(IMM8, SP)}},
+{ "movbu", 0xfa920000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}},
+{ "movbu", 0xf440, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}},
+{ "movbu", 0x020000, 0xf30000, 0, FMT_S2, 0, {DM1, MEM(IMM16_MEM)}},
+{ "movbu", 0xfc400000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}},
+{ "movbu", 0xfcb80000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}},
+{ "movbu", 0xfca80000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}},
+{ "movbu", 0xfc500000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}},
+{ "movbu", 0xfc920000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}},
+{ "movbu", 0xfc820000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}},
+
+{ "movhu", 0xf060, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), DN1}},
+{ "movhu", 0xf86000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}},
+{ "movhu", 0xfa600000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}},
+{ "movhu", 0xf8bc00, 0xfffcff, 0, FMT_D1, 0, {MEM(SP), DN0}},
+{ "movhu", 0xf8bc00, 0xfffc00, 0, FMT_D1, 0, {MEM2(IMM8, SP), DN0}},
+{ "movhu", 0xfabc0000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}},
+{ "movhu", 0xf480, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), DN2}},
+{ "movhu", 0x380000, 0xfc0000, 0, FMT_S2, 0, {MEM(IMM16_MEM), DN0}},
+{ "movhu", 0xf070, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}},
+{ "movhu", 0xf87000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}},
+{ "movhu", 0xfa700000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}},
+{ "movhu", 0xf89300, 0xfff3ff, 0, FMT_D1, 0, {DM1, MEM(SP)}},
+{ "movhu", 0xf89300, 0xfff300, 0, FMT_D1, 0, {DM1, MEM2(IMM8, SP)}},
+{ "movhu", 0xfa930000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}},
+{ "movhu", 0xf4c0, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}},
+{ "movhu", 0x030000, 0xf30000, 0, FMT_S2, 0, {DM1, MEM(IMM16_MEM)}},
+{ "movhu", 0xfc600000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}},
+{ "movhu", 0xfcbc0000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}},
+{ "movhu", 0xfcac0000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}},
+{ "movhu", 0xfc700000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}},
+{ "movhu", 0xfc930000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}},
+{ "movhu", 0xfc830000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}},
+
+{ "ext", 0xf2d0, 0xfffc, 0, FMT_D0, 0, {DN0}},
+
+{ "extb", 0x10, 0xfc, 0, FMT_S0, 0, {DN0}},
+
+{ "extbu", 0x14, 0xfc, 0, FMT_S0, 0, {DN0}},
+
+{ "exth", 0x18, 0xfc, 0, FMT_S0, 0, {DN0}},
+
+{ "exthu", 0x1c, 0xfc, 0, FMT_S0, 0, {DN0}},
+
+{ "movm", 0xce00, 0xff00, 0, FMT_S1, 0, {MEM(SP), REGS}},
+{ "movm", 0xcf00, 0xff00, 0, FMT_S1, 0, {REGS, MEM(SP)}},
+
+{ "clr", 0x00, 0xf3, 0, FMT_S0, 0, {DN1}},
+
+{ "add", 0xe0, 0xf0, 0, FMT_S0, 0, {DM1, DN0}},
+{ "add", 0xf160, 0xfff0, 0, FMT_D0, 0, {DM1, AN0}},
+{ "add", 0xf150, 0xfff0, 0, FMT_D0, 0, {AM1, DN0}},
+{ "add", 0xf170, 0xfff0, 0, FMT_D0, 0, {AM1, AN0}},
+{ "add", 0x2800, 0xfc00, 0, FMT_S1, 0, {SIMM8, DN0}},
+{ "add", 0xfac00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "add", 0x2000, 0xfc00, 0, FMT_S1, 0, {SIMM8, AN0}},
+{ "add", 0xfad00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, AN0}},
+{ "add", 0xf8fe00, 0xffff00, 0, FMT_D1, 0, {SIMM8, SP}},
+{ "add", 0xfafe0000, 0xffff0000, 0, FMT_D2, 0, {SIMM16, SP}},
+{ "add", 0xfcc00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "add", 0xfcd00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, AN0}},
+{ "add", 0xfcfe0000, 0xffff0000, 0, FMT_D4, 0, {IMM32, SP}},
+
+{ "addc", 0xf140, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+
+{ "sub", 0xf100, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "sub", 0xf120, 0xfff0, 0, FMT_D0, 0, {DM1, AN0}},
+{ "sub", 0xf110, 0xfff0, 0, FMT_D0, 0, {AM1, DN0}},
+{ "sub", 0xf130, 0xfff0, 0, FMT_D0, 0, {AM1, AN0}},
+{ "sub", 0xfcc40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "sub", 0xfcd40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, AN0}},
+
+{ "subc", 0xf180, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+
+{ "mul", 0xf240, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+
+{ "mulu", 0xf250, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+
+{ "div", 0xf260, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+
+{ "divu", 0xf270, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+
+{ "inc", 0x40, 0xf3, 0, FMT_S0, 0, {DN1}},
+{ "inc", 0x41, 0xf3, 0, FMT_S0, 0, {AN1}},
+
+{ "inc4", 0x50, 0xfc, 0, FMT_S0, 0, {AN0}},
+
+{ "cmp", 0xa000, 0xf000, 0, FMT_S1, 0, {SIMM8, DN01}},
+{ "cmp", 0xa0, 0xf0, 0x3, FMT_S0, 0, {DM1, DN0}},
+{ "cmp", 0xf1a0, 0xfff0, 0, FMT_D0, 0, {DM1, AN0}},
+{ "cmp", 0xf190, 0xfff0, 0, FMT_D0, 0, {AM1, DN0}},
+{ "cmp", 0xb000, 0xf000, 0, FMT_S1, 0, {IMM8, AN01}},
+{ "cmp", 0xb0, 0xf0, 0x3, FMT_S0, 0, {AM1, AN0}},
+{ "cmp", 0xfac80000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "cmp", 0xfad80000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, AN0}},
+{ "cmp", 0xfcc80000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "cmp", 0xfcd80000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, AN0}},
+
+{ "and", 0xf200, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "and", 0xf8e000, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "and", 0xfae00000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "and", 0xfafc0000, 0xffff0000, 0, FMT_D2, 0, {IMM16, PSW}},
+{ "and", 0xfce00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+
+{ "or", 0xf210, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "or", 0xf8e400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "or", 0xfae40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "or", 0xfafd0000, 0xffff0000, 0, FMT_D2, 0, {IMM16, PSW}},
+{ "or", 0xfce40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+
+{ "xor", 0xf220, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "xor", 0xfae80000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "xor", 0xfce80000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+
+{ "not", 0xf230, 0xfffc, 0, FMT_D0, 0, {DN0}},
+
+{ "btst", 0xf8ec00, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "btst", 0xfaec0000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "btst", 0xfcec0000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "btst", 0xfe020000, 0xffff0000, 0, FMT_D5, 0, {IMM8E, MEM(IMM32_LOWSHIFT8)}},
+{ "btst", 0xfaf80000, 0xfffc0000, 0, FMT_D2, 0, {IMM8, MEM2(SD8N_SHIFT8, AN0)}},
+
+{ "bset", 0xf080, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}},
+{ "bset", 0xfe000000, 0xffff0000, 0, FMT_D5, 0, {IMM8E, MEM(IMM32_LOWSHIFT8)}},
+{ "bset", 0xfaf00000, 0xfffc0000, 0, FMT_D2, 0, {IMM8, MEM2(SD8N_SHIFT8, AN0)}},
+
+{ "bclr", 0xf090, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}},
+{ "bclr", 0xfe010000, 0xffff0000, 0, FMT_D5, 0, {IMM8E, MEM(IMM32_LOWSHIFT8)}},
+{ "bclr", 0xfaf40000, 0xfffc0000, 0, FMT_D2, 0, {IMM8, MEM2(SD8N_SHIFT8,AN0)}},
+
+{ "asr", 0xf2b0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "asr", 0xf8c800, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "asr", 0xf8c801, 0xfffcff, 0, FMT_D1, 0, {DN0}},
+
+{ "lsr", 0xf2a0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "lsr", 0xf8c400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "lsr", 0xf8c401, 0xfffcff, 0, FMT_D1, 0, {DN0}},
+
+{ "asl", 0xf290, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "asl", 0xf8c000, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "asl", 0xf8c001, 0xfffcff, 0, FMT_D1, 0, {DN0}},
+
+{ "asl2", 0x54, 0xfc, 0, FMT_S0, 0, {DN0}},
+
+{ "ror", 0xf284, 0xfffc, 0, FMT_D0, 0, {DN0}},
+
+{ "rol", 0xf280, 0xfffc, 0, FMT_D0, 0, {DN0}},
+
+{ "beq", 0xc800, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bne", 0xc900, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bgt", 0xc100, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bge", 0xc200, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "ble", 0xc300, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "blt", 0xc000, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bhi", 0xc500, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bcc", 0xc600, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bls", 0xc700, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bcs", 0xc400, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+{ "bvc", 0xf8e800, 0xffff00, 0, FMT_D1, 0, {SD8N_PCREL}},
+{ "bvs", 0xf8e900, 0xffff00, 0, FMT_D1, 0, {SD8N_PCREL}},
+{ "bnc", 0xf8ea00, 0xffff00, 0, FMT_D1, 0, {SD8N_PCREL}},
+{ "bns", 0xf8eb00, 0xffff00, 0, FMT_D1, 0, {SD8N_PCREL}},
+{ "bra", 0xca00, 0xff00, 0, FMT_S1, 0, {SD8N_PCREL}},
+
+{ "leq", 0xd8, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lne", 0xd9, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lgt", 0xd1, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lge", 0xd2, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lle", 0xd3, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "llt", 0xd0, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lhi", 0xd5, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lcc", 0xd6, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lls", 0xd7, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lcs", 0xd4, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "lra", 0xda, 0xff, 0, FMT_S0, 0, {UNUSED}},
+{ "setlb", 0xdb, 0xff, 0, FMT_S0, 0, {UNUSED}},
+
+{ "jmp", 0xf0f4, 0xfffc, 0, FMT_D0, 0, {PAREN,AN0,PAREN}},
+{ "jmp", 0xcc0000, 0xff0000, 0, FMT_S2, 0, {IMM16_PCREL}},
+{ "jmp", 0xdc000000, 0xff000000, 0, FMT_S4, 0, {IMM32_HIGH24}},
+{ "call", 0xcd000000, 0xff000000, 0, FMT_S4, 0, {D16_SHIFT,REGS,IMM8E}},
+{ "call", 0xdd000000, 0xff000000, 0, FMT_S6, 0, {IMM32_HIGH24_LOWSHIFT16, REGSE_SHIFT8,IMM8E}},
+{ "calls", 0xf0f0, 0xfffc, 0, FMT_D0, 0, {PAREN,AN0,PAREN}},
+{ "calls", 0xfaff0000, 0xffff0000, 0, FMT_D2, 0, {IMM16_PCREL}},
+{ "calls", 0xfcff0000, 0xffff0000, 0, FMT_D4, 0, {IMM32_PCREL}},
+
+{ "ret", 0xdf0000, 0xff0000, 0, FMT_S2, 0, {REGS_SHIFT8, IMM8}},
+{ "retf", 0xde0000, 0xff0000, 0, FMT_S2, 0, {REGS_SHIFT8, IMM8}},
+{ "rets", 0xf0fc, 0xffff, 0, FMT_D0, 0, {UNUSED}},
+{ "rti", 0xf0fd, 0xffff, 0, FMT_D0, 0, {UNUSED}},
+{ "trap", 0xf0fe, 0xffff, 0, FMT_D0, 0, {UNUSED}},
+{ "rtm", 0xf0ff, 0xffff, 0, FMT_D0, 0, {UNUSED}},
+{ "nop", 0xcb, 0xff, 0, FMT_S0, 0, {UNUSED}},
+
+/* UDF instructions. */
+{ "udf00", 0xf600, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf00", 0xf90000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf00", 0xfb000000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf00", 0xfd000000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf01", 0xf610, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf01", 0xf91000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf01", 0xfb100000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf01", 0xfd100000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf02", 0xf620, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf02", 0xf92000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf02", 0xfb200000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf02", 0xfd200000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf03", 0xf630, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf03", 0xf93000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf03", 0xfb300000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf03", 0xfd300000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf04", 0xf640, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf04", 0xf94000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf04", 0xfb400000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf04", 0xfd400000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf05", 0xf650, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf05", 0xf95000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf05", 0xfb500000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf05", 0xfd500000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf06", 0xf660, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf06", 0xf96000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf06", 0xfb600000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf06", 0xfd600000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf07", 0xf670, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf07", 0xf97000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf07", 0xfb700000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf07", 0xfd700000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf08", 0xf680, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf08", 0xf98000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf08", 0xfb800000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf08", 0xfd800000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf09", 0xf690, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf09", 0xf99000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf09", 0xfb900000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf09", 0xfd900000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf10", 0xf6a0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf10", 0xf9a000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf10", 0xfba00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf10", 0xfda00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf11", 0xf6b0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf11", 0xf9b000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf11", 0xfbb00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf11", 0xfdb00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf12", 0xf6c0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf12", 0xf9c000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf12", 0xfbc00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf12", 0xfdc00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf13", 0xf6d0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf13", 0xf9d000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf13", 0xfbd00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf13", 0xfdd00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf14", 0xf6e0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf14", 0xf9e000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf14", 0xfbe00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf14", 0xfde00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf15", 0xf6f0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf15", 0xf9f000, 0xfffc00, 0, FMT_D1, 0, {SIMM8, DN0}},
+{ "udf15", 0xfbf00000, 0xfffc0000, 0, FMT_D2, 0, {SIMM16, DN0}},
+{ "udf15", 0xfdf00000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udf20", 0xf500, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf21", 0xf510, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf22", 0xf520, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf23", 0xf530, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf24", 0xf540, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf25", 0xf550, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf26", 0xf560, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf27", 0xf570, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf28", 0xf580, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf29", 0xf590, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf30", 0xf5a0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf31", 0xf5b0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf32", 0xf5c0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf33", 0xf5d0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf34", 0xf5e0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udf35", 0xf5f0, 0xfff0, 0, FMT_D0, 0, {DM1, DN0}},
+{ "udfu00", 0xf90400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu00", 0xfb040000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu00", 0xfd040000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu01", 0xf91400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu01", 0xfb140000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu01", 0xfd140000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu02", 0xf92400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu02", 0xfb240000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu02", 0xfd240000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu03", 0xf93400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu03", 0xfb340000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu03", 0xfd340000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu04", 0xf94400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu04", 0xfb440000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu04", 0xfd440000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu05", 0xf95400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu05", 0xfb540000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu05", 0xfd540000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu06", 0xf96400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu06", 0xfb640000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu06", 0xfd640000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu07", 0xf97400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu07", 0xfb740000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu07", 0xfd740000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu08", 0xf98400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu08", 0xfb840000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu08", 0xfd840000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu09", 0xf99400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu09", 0xfb940000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu09", 0xfd940000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu10", 0xf9a400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu10", 0xfba40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu10", 0xfda40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu11", 0xf9b400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu11", 0xfbb40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu11", 0xfdb40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu12", 0xf9c400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu12", 0xfbc40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu12", 0xfdc40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu13", 0xf9d400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu13", 0xfbd40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu13", 0xfdd40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu14", 0xf9e400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu14", 0xfbe40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu14", 0xfde40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+{ "udfu15", 0xf9f400, 0xfffc00, 0, FMT_D1, 0, {IMM8, DN0}},
+{ "udfu15", 0xfbf40000, 0xfffc0000, 0, FMT_D2, 0, {IMM16, DN0}},
+{ "udfu15", 0xfdf40000, 0xfffc0000, 0, FMT_D4, 0, {IMM32, DN0}},
+
+{ "putx", 0xf500, 0xfff0, 0, FMT_D0, AM30, {DN01}},
+{ "getx", 0xf6f0, 0xfff0, 0, FMT_D0, AM30, {DN01}},
+{ "mulq", 0xf600, 0xfff0, 0, FMT_D0, AM30, {DM1, DN0}},
+{ "mulq", 0xf90000, 0xfffc00, 0, FMT_D1, AM30, {SIMM8, DN0}},
+{ "mulq", 0xfb000000, 0xfffc0000, 0, FMT_D2, AM30, {SIMM16, DN0}},
+{ "mulq", 0xfd000000, 0xfffc0000, 0, FMT_D4, AM30, {IMM32, DN0}},
+{ "mulqu", 0xf610, 0xfff0, 0, FMT_D0, AM30, {DM1, DN0}},
+{ "mulqu", 0xf91400, 0xfffc00, 0, FMT_D1, AM30, {SIMM8, DN0}},
+{ "mulqu", 0xfb140000, 0xfffc0000, 0, FMT_D2, AM30, {SIMM16, DN0}},
+{ "mulqu", 0xfd140000, 0xfffc0000, 0, FMT_D4, AM30, {IMM32, DN0}},
+{ "sat16", 0xf640, 0xfff0, 0, FMT_D0, AM30, {DM1, DN0}},
+
+{ "sat24", 0xf650, 0xfff0, 0, FMT_D0, AM30, {DM1, DN0}},
+
+{ "bsch", 0xf670, 0xfff0, 0, FMT_D0, AM30, {DM1, DN0}},
+
+/* Extension. We need some instruction to trigger "emulated syscalls"
+ for our simulator. */
+{ "syscall", 0xf0c0, 0xffff, 0, FMT_D0, 0, {UNUSED}},
+
+/* Extension. When talking to the simulator, gdb requires some instruction
+ that will trigger a "breakpoint" (really just an instruction that isn't
+ otherwise used by the tools. This instruction must be the same size
+ as the smallest instruction on the target machine. In the case of the
+ mn10x00 the "break" instruction must be one byte. 0xff is available on
+ both mn10x00 architectures. */
+{ "break", 0xff, 0xff, 0, FMT_S0, 0, {UNUSED}},
+
+
+{ 0, 0, 0, 0, 0, 0, {0}},
+
+} ;
+
+const int mn10300_num_opcodes =
+ sizeof (mn10300_opcodes) / sizeof (mn10300_opcodes[0]);
+
+
diff --git a/opcodes/m32r-asm.c b/opcodes/m32r-asm.c
new file mode 100644
index 00000000000..378cd73e9c4
--- /dev/null
+++ b/opcodes/m32r-asm.c
@@ -0,0 +1,556 @@
+/* Assembler interface for targets using CGEN. -*- C -*-
+ CGEN: Cpu tools GENerator
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+- the resultant file is machine generated, cgen-asm.in isn't
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ??? Eventually more and more of this stuff can go to cpu-independent files.
+ Keep that in mind. */
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "m32r-desc.h"
+#include "m32r-opc.h"
+#include "opintl.h"
+
+#undef min
+#define min(a,b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a,b) ((a) > (b) ? (a) : (b))
+
+static const char * parse_insn_normal
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *));
+
+/* -- assembler routines inserted here */
+
+/* -- asm.c */
+
+/* Handle '#' prefixes (i.e. skip over them). */
+
+static const char *
+parse_hash (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ if (**strp == '#')
+ ++*strp;
+ return NULL;
+}
+
+/* Handle shigh(), high(). */
+
+static const char *
+parse_hi16 (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ const char *errmsg;
+ enum cgen_parse_operand_result result_type;
+ bfd_vma value;
+
+ if (**strp == '#')
+ ++*strp;
+
+ if (strncasecmp (*strp, "high(", 5) == 0)
+ {
+ *strp += 5;
+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_HI16_ULO,
+ &result_type, &value);
+ if (**strp != ')')
+ return "missing `)'";
+ ++*strp;
+ if (errmsg == NULL
+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+ value >>= 16;
+ *valuep = value;
+ return errmsg;
+ }
+ else if (strncasecmp (*strp, "shigh(", 6) == 0)
+ {
+ *strp += 6;
+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_HI16_SLO,
+ &result_type, &value);
+ if (**strp != ')')
+ return "missing `)'";
+ ++*strp;
+ if (errmsg == NULL
+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+ value = (value >> 16) + (value & 0x8000 ? 1 : 0);
+ *valuep = value;
+ return errmsg;
+ }
+
+ return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
+}
+
+/* Handle low() in a signed context. Also handle sda().
+ The signedness of the value doesn't matter to low(), but this also
+ handles the case where low() isn't present. */
+
+static const char *
+parse_slo16 (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ long *valuep;
+{
+ const char *errmsg;
+ enum cgen_parse_operand_result result_type;
+ bfd_vma value;
+
+ if (**strp == '#')
+ ++*strp;
+
+ if (strncasecmp (*strp, "low(", 4) == 0)
+ {
+ *strp += 4;
+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_LO16,
+ &result_type, &value);
+ if (**strp != ')')
+ return "missing `)'";
+ ++*strp;
+ if (errmsg == NULL
+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+ value &= 0xffff;
+ *valuep = value;
+ return errmsg;
+ }
+
+ if (strncasecmp (*strp, "sda(", 4) == 0)
+ {
+ *strp += 4;
+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_SDA16,
+ NULL, &value);
+ if (**strp != ')')
+ return "missing `)'";
+ ++*strp;
+ *valuep = value;
+ return errmsg;
+ }
+
+ return cgen_parse_signed_integer (cd, strp, opindex, valuep);
+}
+
+/* Handle low() in an unsigned context.
+ The signedness of the value doesn't matter to low(), but this also
+ handles the case where low() isn't present. */
+
+static const char *
+parse_ulo16 (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ const char *errmsg;
+ enum cgen_parse_operand_result result_type;
+ bfd_vma value;
+
+ if (**strp == '#')
+ ++*strp;
+
+ if (strncasecmp (*strp, "low(", 4) == 0)
+ {
+ *strp += 4;
+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_LO16,
+ &result_type, &value);
+ if (**strp != ')')
+ return "missing `)'";
+ ++*strp;
+ if (errmsg == NULL
+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+ value &= 0xffff;
+ *valuep = value;
+ return errmsg;
+ }
+
+ return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
+}
+
+/* -- */
+
+/* Main entry point for operand parsing.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `parse_insn_normal', but keeping it
+ separate makes clear the interface between `parse_insn_normal' and each of
+ the handlers.
+*/
+
+const char *
+m32r_cgen_parse_operand (cd, opindex, strp, fields)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ const char ** strp;
+ CGEN_FIELDS * fields;
+{
+ const char * errmsg;
+
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_cr_names, & fields->f_r1);
+ break;
+ case M32R_OPERAND_DISP16 :
+ {
+ bfd_vma value;
+ errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_DISP16, 0, NULL, & value);
+ fields->f_disp16 = value;
+ }
+ break;
+ case M32R_OPERAND_DISP24 :
+ {
+ bfd_vma value;
+ errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_DISP24, 0, NULL, & value);
+ fields->f_disp24 = value;
+ }
+ break;
+ case M32R_OPERAND_DISP8 :
+ {
+ bfd_vma value;
+ errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_DISP8, 0, NULL, & value);
+ fields->f_disp8 = value;
+ }
+ break;
+ case M32R_OPERAND_DR :
+ errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r1);
+ break;
+ case M32R_OPERAND_HASH :
+ errmsg = parse_hash (cd, strp, M32R_OPERAND_HASH, &fields->f_nil);
+ break;
+ case M32R_OPERAND_HI16 :
+ errmsg = parse_hi16 (cd, strp, M32R_OPERAND_HI16, &fields->f_hi16);
+ break;
+ case M32R_OPERAND_SCR :
+ errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_cr_names, & fields->f_r2);
+ break;
+ case M32R_OPERAND_SIMM16 :
+ errmsg = cgen_parse_signed_integer (cd, strp, M32R_OPERAND_SIMM16, &fields->f_simm16);
+ break;
+ case M32R_OPERAND_SIMM8 :
+ errmsg = cgen_parse_signed_integer (cd, strp, M32R_OPERAND_SIMM8, &fields->f_simm8);
+ break;
+ case M32R_OPERAND_SLO16 :
+ errmsg = parse_slo16 (cd, strp, M32R_OPERAND_SLO16, &fields->f_simm16);
+ break;
+ case M32R_OPERAND_SR :
+ errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r2);
+ break;
+ case M32R_OPERAND_SRC1 :
+ errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r1);
+ break;
+ case M32R_OPERAND_SRC2 :
+ errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r2);
+ break;
+ case M32R_OPERAND_UIMM16 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, M32R_OPERAND_UIMM16, &fields->f_uimm16);
+ break;
+ case M32R_OPERAND_UIMM24 :
+ {
+ bfd_vma value;
+ errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_UIMM24, 0, NULL, & value);
+ fields->f_uimm24 = value;
+ }
+ break;
+ case M32R_OPERAND_UIMM4 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, M32R_OPERAND_UIMM4, &fields->f_uimm4);
+ break;
+ case M32R_OPERAND_UIMM5 :
+ errmsg = cgen_parse_unsigned_integer (cd, strp, M32R_OPERAND_UIMM5, &fields->f_uimm5);
+ break;
+ case M32R_OPERAND_ULO16 :
+ errmsg = parse_ulo16 (cd, strp, M32R_OPERAND_ULO16, &fields->f_uimm16);
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
+ abort ();
+ }
+
+ return errmsg;
+}
+
+cgen_parse_fn * const m32r_cgen_parse_handlers[] =
+{
+ parse_insn_normal,
+};
+
+void
+m32r_cgen_init_asm (cd)
+ CGEN_CPU_DESC cd;
+{
+ m32r_cgen_init_opcode_table (cd);
+ m32r_cgen_init_ibld_table (cd);
+ cd->parse_handlers = & m32r_cgen_parse_handlers[0];
+ cd->parse_operand = m32r_cgen_parse_operand;
+}
+
+
+/* Default insn parser.
+
+ The syntax string is scanned and operands are parsed and stored in FIELDS.
+ Relocs are queued as we go via other callbacks.
+
+ ??? Note that this is currently an all-or-nothing parser. If we fail to
+ parse the instruction, we return 0 and the caller will start over from
+ the beginning. Backtracking will be necessary in parsing subexpressions,
+ but that can be handled there. Not handling backtracking here may get
+ expensive in the case of the m68k. Deal with later.
+
+ Returns NULL for success, an error message for failure.
+*/
+
+static const char *
+parse_insn_normal (cd, insn, strp, fields)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ const char **strp;
+ CGEN_FIELDS *fields;
+{
+ /* ??? Runtime added insns not handled yet. */
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ const char *str = *strp;
+ const char *errmsg;
+ const char *p;
+ const unsigned char * syn;
+#ifdef CGEN_MNEMONIC_OPERANDS
+ /* FIXME: wip */
+ int past_opcode_p;
+#endif
+
+ /* For now we assume the mnemonic is first (there are no leading operands).
+ We can parse it without needing to set up operand parsing.
+ GAS's input scrubber will ensure mnemonics are lowercase, but we may
+ not be called from GAS. */
+ p = CGEN_INSN_MNEMONIC (insn);
+ while (*p && tolower (*p) == tolower (*str))
+ ++p, ++str;
+
+ if (* p || (* str && !isspace (* str)))
+ return _("unrecognized instruction");
+
+ CGEN_INIT_PARSE (cd);
+ cgen_init_parse_operand (cd);
+#ifdef CGEN_MNEMONIC_OPERANDS
+ past_opcode_p = 0;
+#endif
+
+ /* We don't check for (*str != '\0') here because we want to parse
+ any trailing fake arguments in the syntax string. */
+ syn = CGEN_SYNTAX_STRING (syntax);
+
+ /* Mnemonics come first for now, ensure valid string. */
+ if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
+ abort ();
+
+ ++syn;
+
+ while (* syn != 0)
+ {
+ /* Non operand chars must match exactly. */
+ if (CGEN_SYNTAX_CHAR_P (* syn))
+ {
+ if (*str == CGEN_SYNTAX_CHAR (* syn))
+ {
+#ifdef CGEN_MNEMONIC_OPERANDS
+ if (* syn == ' ')
+ past_opcode_p = 1;
+#endif
+ ++ syn;
+ ++ str;
+ }
+ else
+ {
+ /* Syntax char didn't match. Can't be this insn. */
+ /* FIXME: would like to return something like
+ "expected char `c'" */
+ return _("syntax error");
+ }
+ continue;
+ }
+
+ /* We have an operand of some sort. */
+ errmsg = m32r_cgen_parse_operand (cd, CGEN_SYNTAX_FIELD (*syn),
+ &str, fields);
+ if (errmsg)
+ return errmsg;
+
+ /* Done with this operand, continue with next one. */
+ ++ syn;
+ }
+
+ /* If we're at the end of the syntax string, we're done. */
+ if (* syn == '\0')
+ {
+ /* FIXME: For the moment we assume a valid `str' can only contain
+ blanks now. IE: We needn't try again with a longer version of
+ the insn and it is assumed that longer versions of insns appear
+ before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
+ while (isspace (* str))
+ ++ str;
+
+ if (* str != '\0')
+ return _("junk at end of line"); /* FIXME: would like to include `str' */
+
+ return NULL;
+ }
+
+ /* We couldn't parse it. */
+ return _("unrecognized instruction");
+}
+
+/* Main entry point.
+ This routine is called for each instruction to be assembled.
+ STR points to the insn to be assembled.
+ We assume all necessary tables have been initialized.
+ The assembled instruction, less any fixups, is stored in BUF.
+ Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
+ still needs to be converted to target byte order, otherwise BUF is an array
+ of bytes in target byte order.
+ The result is a pointer to the insn's entry in the opcode table,
+ or NULL if an error occured (an error message will have already been
+ printed).
+
+ Note that when processing (non-alias) macro-insns,
+ this function recurses.
+
+ ??? It's possible to make this cpu-independent.
+ One would have to deal with a few minor things.
+ At this point in time doing so would be more of a curiosity than useful
+ [for example this file isn't _that_ big], but keeping the possibility in
+ mind helps keep the design clean. */
+
+const CGEN_INSN *
+m32r_cgen_assemble_insn (cd, str, fields, buf, errmsg)
+ CGEN_CPU_DESC cd;
+ const char *str;
+ CGEN_FIELDS *fields;
+ CGEN_INSN_BYTES_PTR buf;
+ char **errmsg;
+{
+ const char *start;
+ CGEN_INSN_LIST *ilist;
+
+ /* Skip leading white space. */
+ while (isspace (* str))
+ ++ str;
+
+ /* The instructions are stored in hashed lists.
+ Get the first in the list. */
+ ilist = CGEN_ASM_LOOKUP_INSN (cd, str);
+
+ /* Keep looking until we find a match. */
+
+ start = str;
+ for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist))
+ {
+ const CGEN_INSN *insn = ilist->insn;
+
+#if 0 /* not needed as unsupported opcodes shouldn't be in the hash lists */
+ /* Is this insn supported by the selected cpu? */
+ if (! m32r_cgen_insn_supported (cd, insn))
+ continue;
+#endif
+
+ /* If the RELAX attribute is set, this is an insn that shouldn't be
+ chosen immediately. Instead, it is used during assembler/linker
+ relaxation if possible. */
+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAX) != 0)
+ continue;
+
+ str = start;
+
+ /* Allow parse/insert handlers to obtain length of insn. */
+ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
+
+ if (! CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields))
+ {
+ /* ??? 0 is passed for `pc' */
+ if (CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, (bfd_vma) 0)
+ != NULL)
+ continue;
+ /* It is up to the caller to actually output the insn and any
+ queued relocs. */
+ return insn;
+ }
+
+ /* Try the next entry. */
+ }
+
+ /* FIXME: We can return a better error message than this.
+ Need to track why it failed and pick the right one. */
+ {
+ static char errbuf[100];
+ if (strlen (start) > 50)
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s...'"), start);
+ else
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s'"), start);
+
+ *errmsg = errbuf;
+ return NULL;
+ }
+}
+
+#if 0 /* This calls back to GAS which we can't do without care. */
+
+/* Record each member of OPVALS in the assembler's symbol table.
+ This lets GAS parse registers for us.
+ ??? Interesting idea but not currently used. */
+
+/* Record each member of OPVALS in the assembler's symbol table.
+ FIXME: Not currently used. */
+
+void
+m32r_cgen_asm_hash_keywords (cd, opvals)
+ CGEN_CPU_DESC cd;
+ CGEN_KEYWORD *opvals;
+{
+ CGEN_KEYWORD_SEARCH search = cgen_keyword_search_init (opvals, NULL);
+ const CGEN_KEYWORD_ENTRY * ke;
+
+ while ((ke = cgen_keyword_search_next (& search)) != NULL)
+ {
+#if 0 /* Unnecessary, should be done in the search routine. */
+ if (! m32r_cgen_opval_supported (ke))
+ continue;
+#endif
+ cgen_asm_record_register (cd, ke->name, ke->value);
+ }
+}
+
+#endif /* 0 */
diff --git a/opcodes/m32r-desc.c b/opcodes/m32r-desc.c
new file mode 100644
index 00000000000..9cb5462502e
--- /dev/null
+++ b/opcodes/m32r-desc.c
@@ -0,0 +1,1150 @@
+/* CPU data for m32r.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "m32r-desc.h"
+#include "m32r-opc.h"
+#include "opintl.h"
+
+/* Attributes. */
+
+static const CGEN_ATTR_ENTRY bool_attr[] =
+{
+ { "#f", 0 },
+ { "#t", 1 },
+ { 0, 0 }
+};
+
+static const CGEN_ATTR_ENTRY MACH_attr[] =
+{
+ { "base", MACH_BASE },
+ { "m32r", MACH_M32R },
+ { "max", MACH_MAX },
+ { 0, 0 }
+};
+
+static const CGEN_ATTR_ENTRY ISA_attr[] =
+{
+ { "m32r", ISA_M32R },
+ { "max", ISA_MAX },
+ { 0, 0 }
+};
+
+const CGEN_ATTR_TABLE m32r_cgen_ifield_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "RESERVED", &bool_attr[0], &bool_attr[0] },
+ { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
+ { "SIGNED", &bool_attr[0], &bool_attr[0] },
+ { "RELOC", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+const CGEN_ATTR_TABLE m32r_cgen_hardware_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "PC", &bool_attr[0], &bool_attr[0] },
+ { "PROFILE", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+const CGEN_ATTR_TABLE m32r_cgen_operand_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
+ { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
+ { "SIGNED", &bool_attr[0], &bool_attr[0] },
+ { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
+ { "RELAX", &bool_attr[0], &bool_attr[0] },
+ { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
+ { "RELOC", &bool_attr[0], &bool_attr[0] },
+ { "HASH-PREFIX", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+const CGEN_ATTR_TABLE m32r_cgen_insn_attr_table[] =
+{
+ { "MACH", & MACH_attr[0] },
+ { "ALIAS", &bool_attr[0], &bool_attr[0] },
+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
+ { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
+ { "COND-CTI", &bool_attr[0], &bool_attr[0] },
+ { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
+ { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
+ { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
+ { "RELAX", &bool_attr[0], &bool_attr[0] },
+ { "NO-DIS", &bool_attr[0], &bool_attr[0] },
+ { "PBB", &bool_attr[0], &bool_attr[0] },
+ { "FILL-SLOT", &bool_attr[0], &bool_attr[0] },
+ { 0, 0, 0 }
+};
+
+/* Instruction set variants. */
+
+static const CGEN_ISA m32r_cgen_isa_table[] = {
+ { "m32r", 32, 32, 16, 32, },
+ { 0 }
+};
+
+/* Machine variants. */
+
+static const CGEN_MACH m32r_cgen_mach_table[] = {
+ { "m32r", "m32r", MACH_M32R },
+ { 0 }
+};
+
+static CGEN_KEYWORD_ENTRY m32r_cgen_opval_gr_names_entries[] =
+{
+ { "fp", 13 },
+ { "lr", 14 },
+ { "sp", 15 },
+ { "r0", 0 },
+ { "r1", 1 },
+ { "r2", 2 },
+ { "r3", 3 },
+ { "r4", 4 },
+ { "r5", 5 },
+ { "r6", 6 },
+ { "r7", 7 },
+ { "r8", 8 },
+ { "r9", 9 },
+ { "r10", 10 },
+ { "r11", 11 },
+ { "r12", 12 },
+ { "r13", 13 },
+ { "r14", 14 },
+ { "r15", 15 }
+};
+
+CGEN_KEYWORD m32r_cgen_opval_gr_names =
+{
+ & m32r_cgen_opval_gr_names_entries[0],
+ 19
+};
+
+static CGEN_KEYWORD_ENTRY m32r_cgen_opval_cr_names_entries[] =
+{
+ { "psw", 0 },
+ { "cbr", 1 },
+ { "spi", 2 },
+ { "spu", 3 },
+ { "bpc", 6 },
+ { "bbpsw", 8 },
+ { "bbpc", 14 },
+ { "cr0", 0 },
+ { "cr1", 1 },
+ { "cr2", 2 },
+ { "cr3", 3 },
+ { "cr4", 4 },
+ { "cr5", 5 },
+ { "cr6", 6 },
+ { "cr7", 7 },
+ { "cr8", 8 },
+ { "cr9", 9 },
+ { "cr10", 10 },
+ { "cr11", 11 },
+ { "cr12", 12 },
+ { "cr13", 13 },
+ { "cr14", 14 },
+ { "cr15", 15 }
+};
+
+CGEN_KEYWORD m32r_cgen_opval_cr_names =
+{
+ & m32r_cgen_opval_cr_names_entries[0],
+ 23
+};
+
+
+
+/* The hardware table. */
+
+#define A(a) (1 << CONCAT2 (CGEN_HW_,a))
+
+const CGEN_HW_ENTRY m32r_cgen_hw_table[] =
+{
+ { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PROFILE)|A(PC), { (1<<MACH_BASE) } } },
+ { "h-hi16", HW_H_HI16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-slo16", HW_H_SLO16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-ulo16", HW_H_ULO16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-gr", HW_H_GR, CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_gr_names, { 0|A(CACHE_ADDR)|A(PROFILE), { (1<<MACH_BASE) } } },
+ { "h-cr", HW_H_CR, CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_cr_names, { 0, { (1<<MACH_BASE) } } },
+ { "h-accum", HW_H_ACCUM, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-cond", HW_H_COND, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-psw", HW_H_PSW, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-bpsw", HW_H_BPSW, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-bbpsw", HW_H_BBPSW, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { "h-lock", HW_H_LOCK, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
+ { 0 }
+};
+
+#undef A
+
+/* The instruction field table. */
+
+#define A(a) (1 << CONCAT2 (CGEN_IFLD_,a))
+
+const CGEN_IFLD m32r_cgen_ifld_table[] =
+{
+ { M32R_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_OP1, "f-op1", 0, 32, 0, 4, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_OP2, "f-op2", 0, 32, 8, 4, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_COND, "f-cond", 0, 32, 4, 4, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_R1, "f-r1", 0, 32, 4, 4, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_R2, "f-r2", 0, 32, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_SIMM8, "f-simm8", 0, 32, 8, 8, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_SIMM16, "f-simm16", 0, 32, 16, 16, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_SHIFT_OP2, "f-shift-op2", 0, 32, 8, 3, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_UIMM4, "f-uimm4", 0, 32, 12, 4, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_UIMM5, "f-uimm5", 0, 32, 11, 5, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_UIMM16, "f-uimm16", 0, 32, 16, 16, { 0, { (1<<MACH_BASE) } } },
+ { M32R_F_UIMM24, "f-uimm24", 0, 32, 8, 24, { 0|A(RELOC)|A(ABS_ADDR), { (1<<MACH_BASE) } } },
+ { M32R_F_HI16, "f-hi16", 0, 32, 16, 16, { 0|A(SIGN_OPT), { (1<<MACH_BASE) } } },
+ { M32R_F_DISP8, "f-disp8", 0, 32, 8, 8, { 0|A(RELOC)|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+ { M32R_F_DISP16, "f-disp16", 0, 32, 16, 16, { 0|A(RELOC)|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+ { M32R_F_DISP24, "f-disp24", 0, 32, 8, 24, { 0|A(RELOC)|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+ { 0 }
+};
+
+#undef A
+
+/* The operand table. */
+
+#define A(a) (1 << CONCAT2 (CGEN_OPERAND_,a))
+#define OPERAND(op) CONCAT2 (M32R_OPERAND_,op)
+
+const CGEN_OPERAND m32r_cgen_operand_table[] =
+{
+/* pc: program counter */
+ { "pc", M32R_OPERAND_PC, HW_H_PC, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* sr: source register */
+ { "sr", M32R_OPERAND_SR, HW_H_GR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* dr: destination register */
+ { "dr", M32R_OPERAND_DR, HW_H_GR, 4, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* src1: source register 1 */
+ { "src1", M32R_OPERAND_SRC1, HW_H_GR, 4, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* src2: source register 2 */
+ { "src2", M32R_OPERAND_SRC2, HW_H_GR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* scr: source control register */
+ { "scr", M32R_OPERAND_SCR, HW_H_CR, 12, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* dcr: destination control register */
+ { "dcr", M32R_OPERAND_DCR, HW_H_CR, 4, 4,
+ { 0, { (1<<MACH_BASE) } } },
+/* simm8: 8 bit signed immediate */
+ { "simm8", M32R_OPERAND_SIMM8, HW_H_SINT, 8, 8,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* simm16: 16 bit signed immediate */
+ { "simm16", M32R_OPERAND_SIMM16, HW_H_SINT, 16, 16,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* uimm4: 4 bit trap number */
+ { "uimm4", M32R_OPERAND_UIMM4, HW_H_UINT, 12, 4,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* uimm5: 5 bit shift count */
+ { "uimm5", M32R_OPERAND_UIMM5, HW_H_UINT, 11, 5,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* uimm16: 16 bit unsigned immediate */
+ { "uimm16", M32R_OPERAND_UIMM16, HW_H_UINT, 16, 16,
+ { 0|A(HASH_PREFIX), { (1<<MACH_BASE) } } },
+/* hash: # prefix */
+ { "hash", M32R_OPERAND_HASH, HW_H_SINT, 0, 0,
+ { 0, { (1<<MACH_BASE) } } },
+/* hi16: high 16 bit immediate, sign optional */
+ { "hi16", M32R_OPERAND_HI16, HW_H_HI16, 16, 16,
+ { 0|A(SIGN_OPT), { (1<<MACH_BASE) } } },
+/* slo16: 16 bit signed immediate, for low() */
+ { "slo16", M32R_OPERAND_SLO16, HW_H_SLO16, 16, 16,
+ { 0, { (1<<MACH_BASE) } } },
+/* ulo16: 16 bit unsigned immediate, for low() */
+ { "ulo16", M32R_OPERAND_ULO16, HW_H_ULO16, 16, 16,
+ { 0, { (1<<MACH_BASE) } } },
+/* uimm24: 24 bit address */
+ { "uimm24", M32R_OPERAND_UIMM24, HW_H_ADDR, 8, 24,
+ { 0|A(HASH_PREFIX)|A(RELOC)|A(ABS_ADDR), { (1<<MACH_BASE) } } },
+/* disp8: 8 bit displacement */
+ { "disp8", M32R_OPERAND_DISP8, HW_H_IADDR, 8, 8,
+ { 0|A(RELAX)|A(RELOC)|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+/* disp16: 16 bit displacement */
+ { "disp16", M32R_OPERAND_DISP16, HW_H_IADDR, 16, 16,
+ { 0|A(RELOC)|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+/* disp24: 24 bit displacement */
+ { "disp24", M32R_OPERAND_DISP24, HW_H_IADDR, 8, 24,
+ { 0|A(RELAX)|A(RELOC)|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
+/* condbit: condition bit */
+ { "condbit", M32R_OPERAND_CONDBIT, HW_H_COND, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+/* accum: accumulator */
+ { "accum", M32R_OPERAND_ACCUM, HW_H_ACCUM, 0, 0,
+ { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
+ { 0 }
+};
+
+#undef A
+
+#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+
+/* The instruction table. */
+
+static const CGEN_IBASE m32r_cgen_insn_table[MAX_INSNS] =
+{
+ /* Special null first entry.
+ A `num' value of zero is thus invalid.
+ Also, the special `invalid' insn resides here. */
+ { 0, 0, 0 },
+/* add $dr,$sr */
+ {
+ M32R_INSN_ADD, "add", "add", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* add3 $dr,$sr,$hash$slo16 */
+ {
+ M32R_INSN_ADD3, "add3", "add3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* and $dr,$sr */
+ {
+ M32R_INSN_AND, "and", "and", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* and3 $dr,$sr,$uimm16 */
+ {
+ M32R_INSN_AND3, "and3", "and3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* or $dr,$sr */
+ {
+ M32R_INSN_OR, "or", "or", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* or3 $dr,$sr,$hash$ulo16 */
+ {
+ M32R_INSN_OR3, "or3", "or3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* xor $dr,$sr */
+ {
+ M32R_INSN_XOR, "xor", "xor", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* xor3 $dr,$sr,$uimm16 */
+ {
+ M32R_INSN_XOR3, "xor3", "xor3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addi $dr,$simm8 */
+ {
+ M32R_INSN_ADDI, "addi", "addi", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addv $dr,$sr */
+ {
+ M32R_INSN_ADDV, "addv", "addv", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addv3 $dr,$sr,$simm16 */
+ {
+ M32R_INSN_ADDV3, "addv3", "addv3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* addx $dr,$sr */
+ {
+ M32R_INSN_ADDX, "addx", "addx", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* bc.s $disp8 */
+ {
+ M32R_INSN_BC8, "bc8", "bc.s", 16,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bc.l $disp24 */
+ {
+ M32R_INSN_BC24, "bc24", "bc.l", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* beq $src1,$src2,$disp16 */
+ {
+ M32R_INSN_BEQ, "beq", "beq", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* beqz $src2,$disp16 */
+ {
+ M32R_INSN_BEQZ, "beqz", "beqz", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bgez $src2,$disp16 */
+ {
+ M32R_INSN_BGEZ, "bgez", "bgez", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bgtz $src2,$disp16 */
+ {
+ M32R_INSN_BGTZ, "bgtz", "bgtz", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* blez $src2,$disp16 */
+ {
+ M32R_INSN_BLEZ, "blez", "blez", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bltz $src2,$disp16 */
+ {
+ M32R_INSN_BLTZ, "bltz", "bltz", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bnez $src2,$disp16 */
+ {
+ M32R_INSN_BNEZ, "bnez", "bnez", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bl.s $disp8 */
+ {
+ M32R_INSN_BL8, "bl8", "bl.s", 16,
+ { 0|A(FILL_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bl.l $disp24 */
+ {
+ M32R_INSN_BL24, "bl24", "bl.l", 32,
+ { 0|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bnc.s $disp8 */
+ {
+ M32R_INSN_BNC8, "bnc8", "bnc.s", 16,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bnc.l $disp24 */
+ {
+ M32R_INSN_BNC24, "bnc24", "bnc.l", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bne $src1,$src2,$disp16 */
+ {
+ M32R_INSN_BNE, "bne", "bne", 32,
+ { 0|A(COND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bra.s $disp8 */
+ {
+ M32R_INSN_BRA8, "bra8", "bra.s", 16,
+ { 0|A(FILL_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* bra.l $disp24 */
+ {
+ M32R_INSN_BRA24, "bra24", "bra.l", 32,
+ { 0|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* cmp $src1,$src2 */
+ {
+ M32R_INSN_CMP, "cmp", "cmp", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* cmpi $src2,$simm16 */
+ {
+ M32R_INSN_CMPI, "cmpi", "cmpi", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* cmpu $src1,$src2 */
+ {
+ M32R_INSN_CMPU, "cmpu", "cmpu", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* cmpui $src2,$simm16 */
+ {
+ M32R_INSN_CMPUI, "cmpui", "cmpui", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* div $dr,$sr */
+ {
+ M32R_INSN_DIV, "div", "div", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* divu $dr,$sr */
+ {
+ M32R_INSN_DIVU, "divu", "divu", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* rem $dr,$sr */
+ {
+ M32R_INSN_REM, "rem", "rem", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* remu $dr,$sr */
+ {
+ M32R_INSN_REMU, "remu", "remu", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* jl $sr */
+ {
+ M32R_INSN_JL, "jl", "jl", 16,
+ { 0|A(FILL_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* jmp $sr */
+ {
+ M32R_INSN_JMP, "jmp", "jmp", 16,
+ { 0|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* ld $dr,@$sr */
+ {
+ M32R_INSN_LD, "ld", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld $dr,@($slo16,$sr) */
+ {
+ M32R_INSN_LD_D, "ld-d", "ld", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldb $dr,@$sr */
+ {
+ M32R_INSN_LDB, "ldb", "ldb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldb $dr,@($slo16,$sr) */
+ {
+ M32R_INSN_LDB_D, "ldb-d", "ldb", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldh $dr,@$sr */
+ {
+ M32R_INSN_LDH, "ldh", "ldh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldh $dr,@($slo16,$sr) */
+ {
+ M32R_INSN_LDH_D, "ldh-d", "ldh", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldub $dr,@$sr */
+ {
+ M32R_INSN_LDUB, "ldub", "ldub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldub $dr,@($slo16,$sr) */
+ {
+ M32R_INSN_LDUB_D, "ldub-d", "ldub", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lduh $dr,@$sr */
+ {
+ M32R_INSN_LDUH, "lduh", "lduh", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lduh $dr,@($slo16,$sr) */
+ {
+ M32R_INSN_LDUH_D, "lduh-d", "lduh", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld $dr,@$sr+ */
+ {
+ M32R_INSN_LD_PLUS, "ld-plus", "ld", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ld24 $dr,$uimm24 */
+ {
+ M32R_INSN_LD24, "ld24", "ld24", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldi8 $dr,$simm8 */
+ {
+ M32R_INSN_LDI8, "ldi8", "ldi8", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* ldi16 $dr,$hash$slo16 */
+ {
+ M32R_INSN_LDI16, "ldi16", "ldi16", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* lock $dr,@$sr */
+ {
+ M32R_INSN_LOCK, "lock", "lock", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* machi $src1,$src2 */
+ {
+ M32R_INSN_MACHI, "machi", "machi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* maclo $src1,$src2 */
+ {
+ M32R_INSN_MACLO, "maclo", "maclo", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* macwhi $src1,$src2 */
+ {
+ M32R_INSN_MACWHI, "macwhi", "macwhi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* macwlo $src1,$src2 */
+ {
+ M32R_INSN_MACWLO, "macwlo", "macwlo", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mul $dr,$sr */
+ {
+ M32R_INSN_MUL, "mul", "mul", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mulhi $src1,$src2 */
+ {
+ M32R_INSN_MULHI, "mulhi", "mulhi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mullo $src1,$src2 */
+ {
+ M32R_INSN_MULLO, "mullo", "mullo", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mulwhi $src1,$src2 */
+ {
+ M32R_INSN_MULWHI, "mulwhi", "mulwhi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mulwlo $src1,$src2 */
+ {
+ M32R_INSN_MULWLO, "mulwlo", "mulwlo", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mv $dr,$sr */
+ {
+ M32R_INSN_MV, "mv", "mv", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mvfachi $dr */
+ {
+ M32R_INSN_MVFACHI, "mvfachi", "mvfachi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mvfaclo $dr */
+ {
+ M32R_INSN_MVFACLO, "mvfaclo", "mvfaclo", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mvfacmi $dr */
+ {
+ M32R_INSN_MVFACMI, "mvfacmi", "mvfacmi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mvfc $dr,$scr */
+ {
+ M32R_INSN_MVFC, "mvfc", "mvfc", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* mvtachi $src1 */
+ {
+ M32R_INSN_MVTACHI, "mvtachi", "mvtachi", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mvtaclo $src1 */
+ {
+ M32R_INSN_MVTACLO, "mvtaclo", "mvtaclo", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* mvtc $sr,$dcr */
+ {
+ M32R_INSN_MVTC, "mvtc", "mvtc", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* neg $dr,$sr */
+ {
+ M32R_INSN_NEG, "neg", "neg", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* nop */
+ {
+ M32R_INSN_NOP, "nop", "nop", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* not $dr,$sr */
+ {
+ M32R_INSN_NOT, "not", "not", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* rac */
+ {
+ M32R_INSN_RAC, "rac", "rac", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* rach */
+ {
+ M32R_INSN_RACH, "rach", "rach", 16,
+ { 0, { (1<<MACH_M32R) } }
+ },
+/* rte */
+ {
+ M32R_INSN_RTE, "rte", "rte", 16,
+ { 0|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* seth $dr,$hash$hi16 */
+ {
+ M32R_INSN_SETH, "seth", "seth", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sll $dr,$sr */
+ {
+ M32R_INSN_SLL, "sll", "sll", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sll3 $dr,$sr,$simm16 */
+ {
+ M32R_INSN_SLL3, "sll3", "sll3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* slli $dr,$uimm5 */
+ {
+ M32R_INSN_SLLI, "slli", "slli", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sra $dr,$sr */
+ {
+ M32R_INSN_SRA, "sra", "sra", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sra3 $dr,$sr,$simm16 */
+ {
+ M32R_INSN_SRA3, "sra3", "sra3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* srai $dr,$uimm5 */
+ {
+ M32R_INSN_SRAI, "srai", "srai", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* srl $dr,$sr */
+ {
+ M32R_INSN_SRL, "srl", "srl", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* srl3 $dr,$sr,$simm16 */
+ {
+ M32R_INSN_SRL3, "srl3", "srl3", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* srli $dr,$uimm5 */
+ {
+ M32R_INSN_SRLI, "srli", "srli", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $src1,@$src2 */
+ {
+ M32R_INSN_ST, "st", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $src1,@($slo16,$src2) */
+ {
+ M32R_INSN_ST_D, "st-d", "st", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stb $src1,@$src2 */
+ {
+ M32R_INSN_STB, "stb", "stb", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* stb $src1,@($slo16,$src2) */
+ {
+ M32R_INSN_STB_D, "stb-d", "stb", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sth $src1,@$src2 */
+ {
+ M32R_INSN_STH, "sth", "sth", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sth $src1,@($slo16,$src2) */
+ {
+ M32R_INSN_STH_D, "sth-d", "sth", 32,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $src1,@+$src2 */
+ {
+ M32R_INSN_ST_PLUS, "st-plus", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* st $src1,@-$src2 */
+ {
+ M32R_INSN_ST_MINUS, "st-minus", "st", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* sub $dr,$sr */
+ {
+ M32R_INSN_SUB, "sub", "sub", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* subv $dr,$sr */
+ {
+ M32R_INSN_SUBV, "subv", "subv", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* subx $dr,$sr */
+ {
+ M32R_INSN_SUBX, "subx", "subx", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+/* trap $uimm4 */
+ {
+ M32R_INSN_TRAP, "trap", "trap", 16,
+ { 0|A(FILL_SLOT)|A(UNCOND_CTI), { (1<<MACH_BASE) } }
+ },
+/* unlock $src1,@$src2 */
+ {
+ M32R_INSN_UNLOCK, "unlock", "unlock", 16,
+ { 0, { (1<<MACH_BASE) } }
+ },
+};
+
+#undef A
+#undef MNEM
+#undef OP
+
+/* Initialize anything needed to be done once, before any cpu_open call. */
+
+static void
+init_tables ()
+{
+}
+
+/* Subroutine of m32r_cgen_cpu_open to look up a mach via its bfd name. */
+
+static const CGEN_MACH *
+lookup_mach_via_bfd_name (table, name)
+ const CGEN_MACH *table;
+ const char *name;
+{
+ while (table->name)
+ {
+ if (strcmp (name, table->bfd_name) == 0)
+ return table;
+ ++table;
+ }
+ abort ();
+}
+
+/* Subroutine of m32r_cgen_cpu_open to build the hardware table. */
+
+static void
+build_hw_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i;
+ int machs = cd->machs;
+ const CGEN_HW_ENTRY *init = & m32r_cgen_hw_table[0];
+ /* MAX_HW is only an upper bound on the number of selected entries.
+ However each entry is indexed by it's enum so there can be holes in
+ the table. */
+ const CGEN_HW_ENTRY **selected =
+ (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
+
+ cd->hw_table.init_entries = init;
+ cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
+ memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
+ /* ??? For now we just use machs to determine which ones we want. */
+ for (i = 0; init[i].name != NULL; ++i)
+ if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
+ & machs)
+ selected[init[i].type] = &init[i];
+ cd->hw_table.entries = selected;
+ cd->hw_table.num_entries = MAX_HW;
+}
+
+/* Subroutine of m32r_cgen_cpu_open to build the hardware table. */
+
+static void
+build_ifield_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ cd->ifld_table = & m32r_cgen_ifld_table[0];
+}
+
+/* Subroutine of m32r_cgen_cpu_open to build the hardware table. */
+
+static void
+build_operand_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i;
+ int machs = cd->machs;
+ const CGEN_OPERAND *init = & m32r_cgen_operand_table[0];
+ /* MAX_OPERANDS is only an upper bound on the number of selected entries.
+ However each entry is indexed by it's enum so there can be holes in
+ the table. */
+ const CGEN_OPERAND **selected =
+ (const CGEN_OPERAND **) xmalloc (MAX_OPERANDS * sizeof (CGEN_OPERAND *));
+
+ cd->operand_table.init_entries = init;
+ cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
+ memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
+ /* ??? For now we just use mach to determine which ones we want. */
+ for (i = 0; init[i].name != NULL; ++i)
+ if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
+ & machs)
+ selected[init[i].type] = &init[i];
+ cd->operand_table.entries = selected;
+ cd->operand_table.num_entries = MAX_OPERANDS;
+}
+
+/* Subroutine of m32r_cgen_cpu_open to build the hardware table.
+ ??? This could leave out insns not supported by the specified mach/isa,
+ but that would cause errors like "foo only supported by bar" to become
+ "unknown insn", so for now we include all insns and require the app to
+ do the checking later.
+ ??? On the other hand, parsing of such insns may require their hardware or
+ operand elements to be in the table [which they mightn't be]. */
+
+static void
+build_insn_table (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i;
+ const CGEN_IBASE *ib = & m32r_cgen_insn_table[0];
+ CGEN_INSN *insns = (CGEN_INSN *) xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
+
+ memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
+ for (i = 0; i < MAX_INSNS; ++i)
+ insns[i].base = &ib[i];
+ cd->insn_table.init_entries = insns;
+ cd->insn_table.entry_size = sizeof (CGEN_IBASE);
+ cd->insn_table.num_init_entries = MAX_INSNS;
+}
+
+/* Subroutine of m32r_cgen_cpu_open to rebuild the tables. */
+
+static void
+m32r_cgen_rebuild_tables (cd)
+ CGEN_CPU_TABLE *cd;
+{
+ int i,n_isas,n_machs;
+ unsigned int isas = cd->isas;
+ unsigned int machs = cd->machs;
+
+ cd->int_insn_p = CGEN_INT_INSN_P;
+
+ /* Data derived from the isa spec. */
+#define UNSET (CGEN_SIZE_UNKNOWN + 1)
+ cd->default_insn_bitsize = UNSET;
+ cd->base_insn_bitsize = UNSET;
+ cd->min_insn_bitsize = 65535; /* some ridiculously big number */
+ cd->max_insn_bitsize = 0;
+ for (i = 0; i < MAX_ISAS; ++i)
+ if (((1 << i) & isas) != 0)
+ {
+ const CGEN_ISA *isa = & m32r_cgen_isa_table[i];
+
+ /* Default insn sizes of all selected isas must be equal or we set
+ the result to 0, meaning "unknown". */
+ if (cd->default_insn_bitsize == UNSET)
+ cd->default_insn_bitsize = isa->default_insn_bitsize;
+ else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
+ ; /* this is ok */
+ else
+ cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
+
+ /* Base insn sizes of all selected isas must be equal or we set
+ the result to 0, meaning "unknown". */
+ if (cd->base_insn_bitsize == UNSET)
+ cd->base_insn_bitsize = isa->base_insn_bitsize;
+ else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
+ ; /* this is ok */
+ else
+ cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
+
+ /* Set min,max insn sizes. */
+ if (isa->min_insn_bitsize < cd->min_insn_bitsize)
+ cd->min_insn_bitsize = isa->min_insn_bitsize;
+ if (isa->max_insn_bitsize > cd->max_insn_bitsize)
+ cd->max_insn_bitsize = isa->max_insn_bitsize;
+
+ ++n_isas;
+ }
+
+ /* Data derived from the mach spec. */
+ for (i = 0; i < MAX_MACHS; ++i)
+ if (((1 << i) & machs) != 0)
+ {
+ const CGEN_MACH *mach = & m32r_cgen_mach_table[i];
+
+ ++n_machs;
+ }
+
+ /* Determine which hw elements are used by MACH. */
+ build_hw_table (cd);
+
+ /* Build the ifield table. */
+ build_ifield_table (cd);
+
+ /* Determine which operands are used by MACH/ISA. */
+ build_operand_table (cd);
+
+ /* Build the instruction table. */
+ build_insn_table (cd);
+}
+
+/* Initialize a cpu table and return a descriptor.
+ It's much like opening a file, and must be the first function called.
+ The arguments are a set of (type/value) pairs, terminated with
+ CGEN_CPU_OPEN_END.
+
+ Currently supported values:
+ CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr
+ CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr
+ CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
+ CGEN_CPU_OPEN_ENDIAN: specify endian choice
+ CGEN_CPU_OPEN_END: terminates arguments
+
+ ??? Simultaneous multiple isas might not make sense, but it's not (yet)
+ precluded.
+
+ ??? We only support ISO C stdargs here, not K&R.
+ Laziness, plus experiment to see if anything requires K&R - eventually
+ K&R will no longer be supported - e.g. GDB is currently trying this. */
+
+CGEN_CPU_DESC
+m32r_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
+{
+ CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
+ static int init_p;
+ unsigned int isas = 0; /* 0 = "unspecified" */
+ unsigned int machs = 0; /* 0 = "unspecified" */
+ enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
+ va_list ap;
+
+ if (! init_p)
+ {
+ init_tables ();
+ init_p = 1;
+ }
+
+ memset (cd, 0, sizeof (*cd));
+
+ va_start (ap, arg_type);
+ while (arg_type != CGEN_CPU_OPEN_END)
+ {
+ switch (arg_type)
+ {
+ case CGEN_CPU_OPEN_ISAS :
+ isas = va_arg (ap, unsigned int);
+ break;
+ case CGEN_CPU_OPEN_MACHS :
+ machs = va_arg (ap, unsigned int);
+ break;
+ case CGEN_CPU_OPEN_BFDMACH :
+ {
+ const char *name = va_arg (ap, const char *);
+ const CGEN_MACH *mach =
+ lookup_mach_via_bfd_name (m32r_cgen_mach_table, name);
+
+ machs |= mach->num << 1;
+ break;
+ }
+ case CGEN_CPU_OPEN_ENDIAN :
+ endian = va_arg (ap, enum cgen_endian);
+ break;
+ default :
+ fprintf (stderr, "m32r_cgen_cpu_open: unsupported argument `%d'\n",
+ arg_type);
+ abort (); /* ??? return NULL? */
+ }
+ arg_type = va_arg (ap, enum cgen_cpu_open_arg);
+ }
+ va_end (ap);
+
+ /* mach unspecified means "all" */
+ if (machs == 0)
+ machs = (1 << MAX_MACHS) - 1;
+ /* base mach is always selected */
+ machs |= 1;
+ /* isa unspecified means "all" */
+ if (isas == 0)
+ isas = (1 << MAX_ISAS) - 1;
+ if (endian == CGEN_ENDIAN_UNKNOWN)
+ {
+ /* ??? If target has only one, could have a default. */
+ fprintf (stderr, "m32r_cgen_cpu_open: no endianness specified\n");
+ abort ();
+ }
+
+ cd->isas = isas;
+ cd->machs = machs;
+ cd->endian = endian;
+ /* FIXME: for the sparc case we can determine insn-endianness statically.
+ The worry here is where both data and insn endian can be independently
+ chosen, in which case this function will need another argument.
+ Actually, will want to allow for more arguments in the future anyway. */
+ cd->insn_endian = endian;
+
+ /* Table (re)builder. */
+ cd->rebuild_tables = m32r_cgen_rebuild_tables;
+ m32r_cgen_rebuild_tables (cd);
+
+ return (CGEN_CPU_DESC) cd;
+}
+
+/* Cover fn to m32r_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
+ MACH_NAME is the bfd name of the mach. */
+
+CGEN_CPU_DESC
+m32r_cgen_cpu_open_1 (mach_name, endian)
+ const char *mach_name;
+ enum cgen_endian endian;
+{
+ return m32r_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
+ CGEN_CPU_OPEN_ENDIAN, endian,
+ CGEN_CPU_OPEN_END);
+}
+
+/* Close a cpu table.
+ ??? This can live in a machine independent file, but there's currently
+ no place to put this file (there's no libcgen). libopcodes is the wrong
+ place as some simulator ports use this but they don't use libopcodes. */
+
+void
+m32r_cgen_cpu_close (cd)
+ CGEN_CPU_DESC cd;
+{
+ if (cd->insn_table.init_entries)
+ free ((CGEN_INSN *) cd->insn_table.init_entries);
+ if (cd->hw_table.entries)
+ free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
+ free (cd);
+}
+
diff --git a/opcodes/m32r-desc.h b/opcodes/m32r-desc.h
new file mode 100644
index 00000000000..6a3636cd55c
--- /dev/null
+++ b/opcodes/m32r-desc.h
@@ -0,0 +1,219 @@
+/* CPU data header for m32r.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef M32R_CPU_H
+#define M32R_CPU_H
+
+#define CGEN_ARCH m32r
+
+/* Given symbol S, return m32r_cgen_<S>. */
+#define CGEN_SYM(s) CONCAT3 (m32r,_cgen_,s)
+
+/* Selected cpu families. */
+#define HAVE_CPU_M32RBF
+
+#define CGEN_INSN_LSB0_P 0
+
+/* Maximum size of any insn (in bytes). */
+#define CGEN_MAX_INSN_SIZE 4
+
+#define CGEN_INT_INSN_P 1
+
+/* FIXME: Need to compute CGEN_MAX_SYNTAX_BYTES. */
+
+/* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands.
+ e.g. In "b,a foo" the ",a" is an operand. If mnemonics have operands
+ we can't hash on everything up to the space. */
+#define CGEN_MNEMONIC_OPERANDS
+/* Maximum number of operands any insn or macro-insn has. */
+#define CGEN_MAX_INSN_OPERANDS 16
+
+/* Maximum number of fields in an instruction. */
+#define CGEN_MAX_IFMT_OPERANDS 7
+
+/* Enums. */
+
+/* Enum declaration for insn format enums. */
+typedef enum insn_op1 {
+ OP1_0, OP1_1, OP1_2, OP1_3
+ , OP1_4, OP1_5, OP1_6, OP1_7
+ , OP1_8, OP1_9, OP1_10, OP1_11
+ , OP1_12, OP1_13, OP1_14, OP1_15
+} INSN_OP1;
+
+/* Enum declaration for op2 enums. */
+typedef enum insn_op2 {
+ OP2_0, OP2_1, OP2_2, OP2_3
+ , OP2_4, OP2_5, OP2_6, OP2_7
+ , OP2_8, OP2_9, OP2_10, OP2_11
+ , OP2_12, OP2_13, OP2_14, OP2_15
+} INSN_OP2;
+
+/* Enum declaration for . */
+typedef enum gr_names {
+ H_GR_FP = 13, H_GR_LR = 14, H_GR_SP = 15, H_GR_R0 = 0
+ , H_GR_R1 = 1, H_GR_R2 = 2, H_GR_R3 = 3, H_GR_R4 = 4
+ , H_GR_R5 = 5, H_GR_R6 = 6, H_GR_R7 = 7, H_GR_R8 = 8
+ , H_GR_R9 = 9, H_GR_R10 = 10, H_GR_R11 = 11, H_GR_R12 = 12
+ , H_GR_R13 = 13, H_GR_R14 = 14, H_GR_R15 = 15
+} GR_NAMES;
+
+/* Enum declaration for . */
+typedef enum cr_names {
+ H_CR_PSW = 0, H_CR_CBR = 1, H_CR_SPI = 2, H_CR_SPU = 3
+ , H_CR_BPC = 6, H_CR_BBPSW = 8, H_CR_BBPC = 14, H_CR_CR0 = 0
+ , H_CR_CR1 = 1, H_CR_CR2 = 2, H_CR_CR3 = 3, H_CR_CR4 = 4
+ , H_CR_CR5 = 5, H_CR_CR6 = 6, H_CR_CR7 = 7, H_CR_CR8 = 8
+ , H_CR_CR9 = 9, H_CR_CR10 = 10, H_CR_CR11 = 11, H_CR_CR12 = 12
+ , H_CR_CR13 = 13, H_CR_CR14 = 14, H_CR_CR15 = 15
+} CR_NAMES;
+
+/* Attributes. */
+
+/* Enum declaration for machine type selection. */
+typedef enum mach_attr {
+ MACH_BASE, MACH_M32R
+ , MACH_MAX
+} MACH_ATTR;
+
+/* Enum declaration for instruction set selection. */
+typedef enum isa_attr {
+ ISA_M32R, ISA_MAX
+} ISA_ATTR;
+
+/* Number of architecture variants. */
+#define MAX_ISAS 1
+#define MAX_MACHS ((int) MACH_MAX)
+
+/* Ifield support. */
+
+extern const struct cgen_ifld m32r_cgen_ifld_table[];
+
+/* Ifield attribute indices. */
+
+/* Enum declaration for cgen_ifld attrs. */
+typedef enum cgen_ifld_attr {
+ CGEN_IFLD_VIRTUAL, CGEN_IFLD_PCREL_ADDR, CGEN_IFLD_ABS_ADDR, CGEN_IFLD_RESERVED
+ , CGEN_IFLD_SIGN_OPT, CGEN_IFLD_SIGNED, CGEN_IFLD_RELOC, CGEN_IFLD_END_BOOLS
+ , CGEN_IFLD_START_NBOOLS = 31, CGEN_IFLD_MACH, CGEN_IFLD_END_NBOOLS
+} CGEN_IFLD_ATTR;
+
+/* Number of non-boolean elements in cgen_ifld_attr. */
+#define CGEN_IFLD_NBOOL_ATTRS (CGEN_IFLD_END_NBOOLS - CGEN_IFLD_START_NBOOLS - 1)
+
+/* Enum declaration for m32r ifield types. */
+typedef enum ifield_type {
+ M32R_F_NIL, M32R_F_OP1, M32R_F_OP2, M32R_F_COND
+ , M32R_F_R1, M32R_F_R2, M32R_F_SIMM8, M32R_F_SIMM16
+ , M32R_F_SHIFT_OP2, M32R_F_UIMM4, M32R_F_UIMM5, M32R_F_UIMM16
+ , M32R_F_UIMM24, M32R_F_HI16, M32R_F_DISP8, M32R_F_DISP16
+ , M32R_F_DISP24
+ , M32R_F_MAX
+} IFIELD_TYPE;
+
+#define MAX_IFLD ((int) M32R_F_MAX)
+
+/* Hardware attribute indices. */
+
+/* Enum declaration for cgen_hw attrs. */
+typedef enum cgen_hw_attr {
+ CGEN_HW_VIRTUAL, CGEN_HW_CACHE_ADDR, CGEN_HW_PC, CGEN_HW_PROFILE
+ , CGEN_HW_END_BOOLS, CGEN_HW_START_NBOOLS = 31, CGEN_HW_MACH, CGEN_HW_END_NBOOLS
+} CGEN_HW_ATTR;
+
+/* Number of non-boolean elements in cgen_hw_attr. */
+#define CGEN_HW_NBOOL_ATTRS (CGEN_HW_END_NBOOLS - CGEN_HW_START_NBOOLS - 1)
+
+/* Enum declaration for m32r hardware types. */
+typedef enum cgen_hw_type {
+ HW_H_MEMORY, HW_H_SINT, HW_H_UINT, HW_H_ADDR
+ , HW_H_IADDR, HW_H_PC, HW_H_HI16, HW_H_SLO16
+ , HW_H_ULO16, HW_H_GR, HW_H_CR, HW_H_ACCUM
+ , HW_H_COND, HW_H_PSW, HW_H_BPSW, HW_H_BBPSW
+ , HW_H_LOCK, HW_MAX
+} CGEN_HW_TYPE;
+
+#define MAX_HW ((int) HW_MAX)
+
+/* Operand attribute indices. */
+
+/* Enum declaration for cgen_operand attrs. */
+typedef enum cgen_operand_attr {
+ CGEN_OPERAND_VIRTUAL, CGEN_OPERAND_PCREL_ADDR, CGEN_OPERAND_ABS_ADDR, CGEN_OPERAND_SIGN_OPT
+ , CGEN_OPERAND_SIGNED, CGEN_OPERAND_NEGATIVE, CGEN_OPERAND_RELAX, CGEN_OPERAND_SEM_ONLY
+ , CGEN_OPERAND_RELOC, CGEN_OPERAND_HASH_PREFIX, CGEN_OPERAND_END_BOOLS, CGEN_OPERAND_START_NBOOLS = 31
+ , CGEN_OPERAND_MACH, CGEN_OPERAND_END_NBOOLS
+} CGEN_OPERAND_ATTR;
+
+/* Number of non-boolean elements in cgen_operand_attr. */
+#define CGEN_OPERAND_NBOOL_ATTRS (CGEN_OPERAND_END_NBOOLS - CGEN_OPERAND_START_NBOOLS - 1)
+
+/* Enum declaration for m32r operand types. */
+typedef enum cgen_operand_type {
+ M32R_OPERAND_PC, M32R_OPERAND_SR, M32R_OPERAND_DR, M32R_OPERAND_SRC1
+ , M32R_OPERAND_SRC2, M32R_OPERAND_SCR, M32R_OPERAND_DCR, M32R_OPERAND_SIMM8
+ , M32R_OPERAND_SIMM16, M32R_OPERAND_UIMM4, M32R_OPERAND_UIMM5, M32R_OPERAND_UIMM16
+ , M32R_OPERAND_HASH, M32R_OPERAND_HI16, M32R_OPERAND_SLO16, M32R_OPERAND_ULO16
+ , M32R_OPERAND_UIMM24, M32R_OPERAND_DISP8, M32R_OPERAND_DISP16, M32R_OPERAND_DISP24
+ , M32R_OPERAND_CONDBIT, M32R_OPERAND_ACCUM, M32R_OPERAND_MAX
+} CGEN_OPERAND_TYPE;
+
+/* Number of operands types. */
+#define MAX_OPERANDS ((int) M32R_OPERAND_MAX)
+
+/* Maximum number of operands referenced by any insn. */
+#define MAX_OPERAND_INSTANCES 11
+
+/* Insn attribute indices. */
+
+/* Enum declaration for cgen_insn attrs. */
+typedef enum cgen_insn_attr {
+ CGEN_INSN_ALIAS, CGEN_INSN_VIRTUAL, CGEN_INSN_UNCOND_CTI, CGEN_INSN_COND_CTI
+ , CGEN_INSN_SKIP_CTI, CGEN_INSN_DELAY_SLOT, CGEN_INSN_RELAXABLE, CGEN_INSN_RELAX
+ , CGEN_INSN_NO_DIS, CGEN_INSN_PBB, CGEN_INSN_FILL_SLOT, CGEN_INSN_SPECIAL
+ , CGEN_INSN_END_BOOLS, CGEN_INSN_START_NBOOLS = 31, CGEN_INSN_MACH, CGEN_INSN_PIPE
+ , CGEN_INSN_END_NBOOLS
+} CGEN_INSN_ATTR;
+
+/* Number of non-boolean elements in cgen_insn_attr. */
+#define CGEN_INSN_NBOOL_ATTRS (CGEN_INSN_END_NBOOLS - CGEN_INSN_START_NBOOLS - 1)
+
+/* cgen.h uses things we just defined. */
+#include "opcode/cgen.h"
+
+/* Attributes. */
+extern const CGEN_ATTR_TABLE m32r_cgen_hardware_attr_table[];
+extern const CGEN_ATTR_TABLE m32r_cgen_ifield_attr_table[];
+extern const CGEN_ATTR_TABLE m32r_cgen_operand_attr_table[];
+extern const CGEN_ATTR_TABLE m32r_cgen_insn_attr_table[];
+
+/* Hardware decls. */
+
+extern CGEN_KEYWORD m32r_cgen_opval_gr_names;
+extern CGEN_KEYWORD m32r_cgen_opval_cr_names;
+
+
+
+
+#endif /* M32R_CPU_H */
diff --git a/opcodes/m32r-dis.c b/opcodes/m32r-dis.c
new file mode 100644
index 00000000000..48c591a6941
--- /dev/null
+++ b/opcodes/m32r-dis.c
@@ -0,0 +1,557 @@
+/* Disassembler interface for targets using CGEN. -*- C -*-
+ CGEN: Cpu tools GENerator
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+- the resultant file is machine generated, cgen-dis.in isn't
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ??? Eventually more and more of this stuff can go to cpu-independent files.
+ Keep that in mind. */
+
+#include "sysdep.h"
+#include <stdio.h>
+#include "ansidecl.h"
+#include "dis-asm.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "m32r-desc.h"
+#include "m32r-opc.h"
+#include "opintl.h"
+
+/* Default text to print if an instruction isn't recognized. */
+#define UNKNOWN_INSN_MSG _("*unknown*")
+
+static void print_normal
+ PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned int, bfd_vma, int));
+static void print_address
+ PARAMS ((CGEN_CPU_DESC, PTR, bfd_vma, unsigned int, bfd_vma, int));
+static void print_keyword
+ PARAMS ((CGEN_CPU_DESC, PTR, CGEN_KEYWORD *, long, unsigned int));
+static void print_insn_normal
+ PARAMS ((CGEN_CPU_DESC, PTR, const CGEN_INSN *, CGEN_FIELDS *,
+ bfd_vma, int));
+static int print_insn PARAMS ((CGEN_CPU_DESC, bfd_vma,
+ disassemble_info *, char *, int));
+static int default_print_insn
+ PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *));
+
+/* -- disassembler routines inserted here */
+
+/* -- dis.c */
+
+/* Immediate values are prefixed with '#'. */
+
+#define CGEN_PRINT_NORMAL(cd, info, value, attrs, pc, length) \
+do { \
+ if (CGEN_BOOL_ATTR ((attrs), CGEN_OPERAND_HASH_PREFIX)) \
+ (*info->fprintf_func) (info->stream, "#"); \
+} while (0)
+
+/* Handle '#' prefixes as operands. */
+
+static void
+print_hash (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+ (*info->fprintf_func) (info->stream, "#");
+}
+
+#undef CGEN_PRINT_INSN
+#define CGEN_PRINT_INSN my_print_insn
+
+static int
+my_print_insn (cd, pc, info)
+ CGEN_CPU_DESC cd;
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ char buffer[CGEN_MAX_INSN_SIZE];
+ char *buf = buffer;
+ int status;
+ int buflen = (pc & 3) == 0 ? 4 : 2;
+
+ /* Read the base part of the insn. */
+
+ status = (*info->read_memory_func) (pc, buf, buflen, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+
+ /* 32 bit insn? */
+ if ((pc & 3) == 0 && (buf[0] & 0x80) != 0)
+ return print_insn (cd, pc, info, buf, buflen);
+
+ /* Print the first insn. */
+ if ((pc & 3) == 0)
+ {
+ if (print_insn (cd, pc, info, buf, 2) == 0)
+ (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
+ buf += 2;
+ }
+
+ if (buf[0] & 0x80)
+ {
+ /* Parallel. */
+ (*info->fprintf_func) (info->stream, " || ");
+ buf[0] &= 0x7f;
+ }
+ else
+ (*info->fprintf_func) (info->stream, " -> ");
+
+ /* The "& 3" is to pass a consistent address.
+ Parallel insns arguably both begin on the word boundary.
+ Also, branch insns are calculated relative to the word boundary. */
+ if (print_insn (cd, pc & ~ (bfd_vma) 3, info, buf, 2) == 0)
+ (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
+
+ return (pc & 3) ? 2 : 4;
+}
+
+/* -- */
+
+/* Main entry point for printing operands.
+ XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
+ of dis-asm.h on cgen.h.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `print_insn_normal', but keeping it
+ separate makes clear the interface between `print_insn_normal' and each of
+ the handlers.
+*/
+
+void
+m32r_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ PTR xinfo;
+ CGEN_FIELDS *fields;
+ void const *attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) xinfo;
+
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ print_keyword (cd, info, & m32r_cgen_opval_cr_names, fields->f_r1, 0);
+ break;
+ case M32R_OPERAND_DISP16 :
+ print_address (cd, info, fields->f_disp16, 0|(1<<CGEN_OPERAND_RELOC)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
+ break;
+ case M32R_OPERAND_DISP24 :
+ print_address (cd, info, fields->f_disp24, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_RELOC)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
+ break;
+ case M32R_OPERAND_DISP8 :
+ print_address (cd, info, fields->f_disp8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_RELOC)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
+ break;
+ case M32R_OPERAND_DR :
+ print_keyword (cd, info, & m32r_cgen_opval_gr_names, fields->f_r1, 0);
+ break;
+ case M32R_OPERAND_HASH :
+ print_hash (cd, info, fields->f_nil, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
+ break;
+ case M32R_OPERAND_HI16 :
+ print_normal (cd, info, fields->f_hi16, 0|(1<<CGEN_OPERAND_SIGN_OPT), pc, length);
+ break;
+ case M32R_OPERAND_SCR :
+ print_keyword (cd, info, & m32r_cgen_opval_cr_names, fields->f_r2, 0);
+ break;
+ case M32R_OPERAND_SIMM16 :
+ print_normal (cd, info, fields->f_simm16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case M32R_OPERAND_SIMM8 :
+ print_normal (cd, info, fields->f_simm8, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case M32R_OPERAND_SLO16 :
+ print_normal (cd, info, fields->f_simm16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
+ break;
+ case M32R_OPERAND_SR :
+ print_keyword (cd, info, & m32r_cgen_opval_gr_names, fields->f_r2, 0);
+ break;
+ case M32R_OPERAND_SRC1 :
+ print_keyword (cd, info, & m32r_cgen_opval_gr_names, fields->f_r1, 0);
+ break;
+ case M32R_OPERAND_SRC2 :
+ print_keyword (cd, info, & m32r_cgen_opval_gr_names, fields->f_r2, 0);
+ break;
+ case M32R_OPERAND_UIMM16 :
+ print_normal (cd, info, fields->f_uimm16, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case M32R_OPERAND_UIMM24 :
+ print_address (cd, info, fields->f_uimm24, 0|(1<<CGEN_OPERAND_HASH_PREFIX)|(1<<CGEN_OPERAND_RELOC)|(1<<CGEN_OPERAND_ABS_ADDR), pc, length);
+ break;
+ case M32R_OPERAND_UIMM4 :
+ print_normal (cd, info, fields->f_uimm4, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case M32R_OPERAND_UIMM5 :
+ print_normal (cd, info, fields->f_uimm5, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
+ break;
+ case M32R_OPERAND_ULO16 :
+ print_normal (cd, info, fields->f_uimm16, 0, pc, length);
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
+ opindex);
+ abort ();
+ }
+}
+
+cgen_print_fn * const m32r_cgen_print_handlers[] =
+{
+ print_insn_normal,
+};
+
+
+void
+m32r_cgen_init_dis (cd)
+ CGEN_CPU_DESC cd;
+{
+ m32r_cgen_init_opcode_table (cd);
+ m32r_cgen_init_ibld_table (cd);
+ cd->print_handlers = & m32r_cgen_print_handlers[0];
+ cd->print_operand = m32r_cgen_print_operand;
+}
+
+
+/* Default print handler. */
+
+static void
+print_normal (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ long value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+
+#ifdef CGEN_PRINT_NORMAL
+ CGEN_PRINT_NORMAL (cd, info, value, attrs, pc, length);
+#endif
+
+ /* Print the operand as directed by the attributes. */
+ if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
+ ; /* nothing to do */
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
+ (*info->fprintf_func) (info->stream, "%ld", value);
+ else
+ (*info->fprintf_func) (info->stream, "0x%lx", value);
+}
+
+/* Default address handler. */
+
+static void
+print_address (cd, dis_info, value, attrs, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ bfd_vma value;
+ unsigned int attrs;
+ bfd_vma pc;
+ int length;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+
+#ifdef CGEN_PRINT_ADDRESS
+ CGEN_PRINT_ADDRESS (cd, info, value, attrs, pc, length);
+#endif
+
+ /* Print the operand as directed by the attributes. */
+ if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
+ ; /* nothing to do */
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
+ (*info->print_address_func) (value, info);
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
+ (*info->print_address_func) (value, info);
+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
+ (*info->fprintf_func) (info->stream, "%ld", (long) value);
+ else
+ (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
+}
+
+/* Keyword print handler. */
+
+static void
+print_keyword (cd, dis_info, keyword_table, value, attrs)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ CGEN_KEYWORD *keyword_table;
+ long value;
+ unsigned int attrs;
+{
+ disassemble_info *info = (disassemble_info *) dis_info;
+ const CGEN_KEYWORD_ENTRY *ke;
+
+ ke = cgen_keyword_lookup_value (keyword_table, value);
+ if (ke != NULL)
+ (*info->fprintf_func) (info->stream, "%s", ke->name);
+ else
+ (*info->fprintf_func) (info->stream, "???");
+}
+
+/* Default insn printer.
+
+ DIS_INFO is defined as `PTR' so the disassembler needn't know anything
+ about disassemble_info. */
+
+static void
+print_insn_normal (cd, dis_info, insn, fields, pc, length)
+ CGEN_CPU_DESC cd;
+ PTR dis_info;
+ const CGEN_INSN *insn;
+ CGEN_FIELDS *fields;
+ bfd_vma pc;
+ int length;
+{
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ disassemble_info *info = (disassemble_info *) dis_info;
+ const unsigned char *syn;
+
+ CGEN_INIT_PRINT (cd);
+
+ for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
+ {
+ if (CGEN_SYNTAX_MNEMONIC_P (*syn))
+ {
+ (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
+ continue;
+ }
+ if (CGEN_SYNTAX_CHAR_P (*syn))
+ {
+ (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
+ continue;
+ }
+
+ /* We have an operand. */
+ m32r_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
+ fields, CGEN_INSN_ATTRS (insn), pc, length);
+ }
+}
+
+/* Utility to print an insn.
+ BUF is the base part of the insn, target byte order, BUFLEN bytes long.
+ The result is the size of the insn in bytes or zero for an unknown insn
+ or -1 if an error occurs fetching data (memory_error_func will have
+ been called). */
+
+static int
+print_insn (cd, pc, info, buf, buflen)
+ CGEN_CPU_DESC cd;
+ bfd_vma pc;
+ disassemble_info *info;
+ char *buf;
+ int buflen;
+{
+ unsigned long insn_value;
+ const CGEN_INSN_LIST *insn_list;
+ CGEN_EXTRACT_INFO ex_info;
+
+ ex_info.dis_info = info;
+ ex_info.valid = (1 << (cd->base_insn_bitsize / 8)) - 1;
+ ex_info.insn_bytes = buf;
+
+ switch (buflen)
+ {
+ case 1:
+ insn_value = buf[0];
+ break;
+ case 2:
+ insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf);
+ break;
+ case 4:
+ insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf);
+ break;
+ default:
+ abort ();
+ }
+
+ /* The instructions are stored in hash lists.
+ Pick the first one and keep trying until we find the right one. */
+
+ insn_list = CGEN_DIS_LOOKUP_INSN (cd, buf, insn_value);
+ while (insn_list != NULL)
+ {
+ const CGEN_INSN *insn = insn_list->insn;
+ CGEN_FIELDS fields;
+ int length;
+
+#if 0 /* not needed as insn shouldn't be in hash lists if not supported */
+ /* Supported by this cpu? */
+ if (! m32r_cgen_insn_supported (cd, insn))
+ continue;
+#endif
+
+ /* Basic bit mask must be correct. */
+ /* ??? May wish to allow target to defer this check until the extract
+ handler. */
+ if ((insn_value & CGEN_INSN_BASE_MASK (insn))
+ == CGEN_INSN_BASE_VALUE (insn))
+ {
+ /* Printing is handled in two passes. The first pass parses the
+ machine insn and extracts the fields. The second pass prints
+ them. */
+
+ length = CGEN_EXTRACT_FN (cd, insn)
+ (cd, insn, &ex_info, insn_value, &fields, pc);
+ /* length < 0 -> error */
+ if (length < 0)
+ return length;
+ if (length > 0)
+ {
+ CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
+ /* length is in bits, result is in bytes */
+ return length / 8;
+ }
+ }
+
+ insn_list = CGEN_DIS_NEXT_INSN (insn_list);
+ }
+
+ return 0;
+}
+
+/* Default value for CGEN_PRINT_INSN.
+ The result is the size of the insn in bytes or zero for an unknown insn
+ or -1 if an error occured fetching bytes. */
+
+#ifndef CGEN_PRINT_INSN
+#define CGEN_PRINT_INSN default_print_insn
+#endif
+
+static int
+default_print_insn (cd, pc, info)
+ CGEN_CPU_DESC cd;
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ char buf[CGEN_MAX_INSN_SIZE];
+ int status;
+
+ /* Read the base part of the insn. */
+
+ status = (*info->read_memory_func) (pc, buf, cd->base_insn_bitsize / 8, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
+
+ return print_insn (cd, pc, info, buf, cd->base_insn_bitsize / 8);
+}
+
+/* Main entry point.
+ Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction (in bytes). */
+
+int
+print_insn_m32r (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ static CGEN_CPU_DESC cd = 0;
+ static prev_isa,prev_mach,prev_endian;
+ int length;
+ int isa,mach;
+ int endian = (info->endian == BFD_ENDIAN_BIG
+ ? CGEN_ENDIAN_BIG
+ : CGEN_ENDIAN_LITTLE);
+ enum bfd_architecture arch;
+
+ /* ??? gdb will set mach but leave the architecture as "unknown" */
+#ifndef CGEN_BFD_ARCH
+#define CGEN_BFD_ARCH bfd_arch_m32r
+#endif
+ arch = info->arch;
+ if (arch == bfd_arch_unknown)
+ arch = CGEN_BFD_ARCH;
+
+ /* There's no standard way to compute the isa number (e.g. for arm thumb)
+ so we leave it to the target. */
+#ifdef CGEN_COMPUTE_ISA
+ isa = CGEN_COMPUTE_ISA (info);
+#else
+ isa = 0;
+#endif
+
+ mach = info->mach;
+
+ /* If we've switched cpu's, close the current table and open a new one. */
+ if (cd
+ && (isa != prev_isa
+ || mach != prev_mach
+ || endian != prev_endian))
+ {
+ m32r_cgen_cpu_close (cd);
+ cd = 0;
+ }
+
+ /* If we haven't initialized yet, initialize the opcode table. */
+ if (! cd)
+ {
+ const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
+ const char *mach_name;
+
+ if (!arch_type)
+ abort ();
+ mach_name = arch_type->printable_name;
+
+ prev_isa = isa;
+ prev_mach = mach;
+ prev_endian = endian;
+ cd = m32r_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
+ CGEN_CPU_OPEN_BFDMACH, mach_name,
+ CGEN_CPU_OPEN_ENDIAN, prev_endian,
+ CGEN_CPU_OPEN_END);
+ if (!cd)
+ abort ();
+ m32r_cgen_init_dis (cd);
+ }
+
+ /* We try to have as much common code as possible.
+ But at this point some targets need to take over. */
+ /* ??? Some targets may need a hook elsewhere. Try to avoid this,
+ but if not possible try to move this hook elsewhere rather than
+ have two hooks. */
+ length = CGEN_PRINT_INSN (cd, pc, info);
+ if (length > 0)
+ return length;
+ if (length < 0)
+ return -1;
+
+ (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
+ return cd->default_insn_bitsize / 8;
+}
diff --git a/opcodes/m32r-ibld.c b/opcodes/m32r-ibld.c
new file mode 100644
index 00000000000..fa15d7e4514
--- /dev/null
+++ b/opcodes/m32r-ibld.c
@@ -0,0 +1,1120 @@
+/* Instruction building/extraction support for m32r. -*- C -*-
+
+THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
+- the resultant file is machine generated, cgen-ibld.in isn't
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* ??? Eventually more and more of this stuff can go to cpu-independent files.
+ Keep that in mind. */
+
+#include "sysdep.h"
+#include <ctype.h>
+#include <stdio.h>
+#include "ansidecl.h"
+#include "dis-asm.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "m32r-desc.h"
+#include "m32r-opc.h"
+#include "opintl.h"
+
+#undef min
+#define min(a,b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a,b) ((a) > (b) ? (a) : (b))
+
+/* Used by the ifield rtx function. */
+#define FLD(f) (fields->f)
+
+static const char * insert_normal
+ PARAMS ((CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
+ unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR));
+static const char * insert_insn_normal
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *,
+ CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma));
+
+static int extract_normal
+ PARAMS ((CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
+ unsigned int, unsigned int, unsigned int, unsigned int,
+ unsigned int, unsigned int, bfd_vma, long *));
+static int extract_insn_normal
+ PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
+ CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma));
+
+/* Operand insertion. */
+
+#if ! CGEN_INT_INSN_P
+
+/* Subroutine of insert_normal. */
+
+static CGEN_INLINE void
+insert_1 (cd, value, start, length, word_length, bufp)
+ CGEN_CPU_DESC cd;
+ unsigned long value;
+ int start,length,word_length;
+ unsigned char *bufp;
+{
+ unsigned long x,mask;
+ int shift;
+ int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+
+ switch (word_length)
+ {
+ case 8:
+ x = *bufp;
+ break;
+ case 16:
+ if (big_p)
+ x = bfd_getb16 (bufp);
+ else
+ x = bfd_getl16 (bufp);
+ break;
+ case 24:
+ /* ??? This may need reworking as these cases don't necessarily
+ want the first byte and the last two bytes handled like this. */
+ if (big_p)
+ x = (bufp[0] << 16) | bfd_getb16 (bufp + 1);
+ else
+ x = bfd_getl16 (bufp) | (bufp[2] << 16);
+ break;
+ case 32:
+ if (big_p)
+ x = bfd_getb32 (bufp);
+ else
+ x = bfd_getl32 (bufp);
+ break;
+ default :
+ abort ();
+ }
+
+ /* Written this way to avoid undefined behaviour. */
+ mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ if (CGEN_INSN_LSB0_P)
+ shift = (start + 1) - length;
+ else
+ shift = (word_length - (start + length));
+ x = (x & ~(mask << shift)) | ((value & mask) << shift);
+
+ switch (word_length)
+ {
+ case 8:
+ *bufp = x;
+ break;
+ case 16:
+ if (big_p)
+ bfd_putb16 (x, bufp);
+ else
+ bfd_putl16 (x, bufp);
+ break;
+ case 24:
+ /* ??? This may need reworking as these cases don't necessarily
+ want the first byte and the last two bytes handled like this. */
+ if (big_p)
+ {
+ bufp[0] = x >> 16;
+ bfd_putb16 (x, bufp + 1);
+ }
+ else
+ {
+ bfd_putl16 (x, bufp);
+ bufp[2] = x >> 16;
+ }
+ break;
+ case 32:
+ if (big_p)
+ bfd_putb32 (x, bufp);
+ else
+ bfd_putl32 (x, bufp);
+ break;
+ default :
+ abort ();
+ }
+}
+
+#endif /* ! CGEN_INT_INSN_P */
+
+/* Default insertion routine.
+
+ ATTRS is a mask of the boolean attributes.
+ WORD_OFFSET is the offset in bits from the start of the insn of the value.
+ WORD_LENGTH is the length of the word in bits in which the value resides.
+ START is the starting bit number in the word, architecture origin.
+ LENGTH is the length of VALUE in bits.
+ TOTAL_LENGTH is the total length of the insn in bits.
+
+ The result is an error message or NULL if success. */
+
+/* ??? This duplicates functionality with bfd's howto table and
+ bfd_install_relocation. */
+/* ??? This doesn't handle bfd_vma's. Create another function when
+ necessary. */
+
+static const char *
+insert_normal (cd, value, attrs, word_offset, start, length, word_length,
+ total_length, buffer)
+ CGEN_CPU_DESC cd;
+ long value;
+ unsigned int attrs;
+ unsigned int word_offset, start, length, word_length, total_length;
+ CGEN_INSN_BYTES_PTR buffer;
+{
+ static char errbuf[100];
+ /* Written this way to avoid undefined behaviour. */
+ unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+
+ /* If LENGTH is zero, this operand doesn't contribute to the value. */
+ if (length == 0)
+ return NULL;
+
+ if (CGEN_INT_INSN_P
+ && word_offset != 0)
+ abort ();
+
+ if (word_length > 32)
+ abort ();
+
+ /* For architectures with insns smaller than the base-insn-bitsize,
+ word_length may be too big. */
+ if (cd->min_insn_bitsize < cd->base_insn_bitsize)
+ {
+ if (word_offset == 0
+ && word_length > total_length)
+ word_length = total_length;
+ }
+
+ /* Ensure VALUE will fit. */
+ if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
+ {
+ unsigned long maxval = mask;
+ if ((unsigned long) value > maxval)
+ {
+ /* xgettext:c-format */
+ sprintf (errbuf,
+ _("operand out of range (%lu not between 0 and %lu)"),
+ value, maxval);
+ return errbuf;
+ }
+ }
+ else
+ {
+ long minval = - (1L << (length - 1));
+ long maxval = (1L << (length - 1)) - 1;
+ if (value < minval || value > maxval)
+ {
+ sprintf
+ /* xgettext:c-format */
+ (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
+ value, minval, maxval);
+ return errbuf;
+ }
+ }
+
+#if CGEN_INT_INSN_P
+
+ {
+ int shift;
+
+ if (CGEN_INSN_LSB0_P)
+ shift = (start + 1) - length;
+ else
+ shift = word_length - (start + length);
+ *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
+ }
+
+#else /* ! CGEN_INT_INSN_P */
+
+ {
+ unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
+
+ insert_1 (cd, value, start, length, word_length, bufp);
+ }
+
+#endif /* ! CGEN_INT_INSN_P */
+
+ return NULL;
+}
+
+/* Default insn builder (insert handler).
+ The instruction is recorded in CGEN_INT_INSN_P byte order
+ (meaning that if CGEN_INT_INSN_P BUFFER is an int * and thus the value is
+ recorded in host byte order, otherwise BUFFER is an array of bytes and the
+ value is recorded in target byte order).
+ The result is an error message or NULL if success. */
+
+static const char *
+insert_insn_normal (cd, insn, fields, buffer, pc)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN * insn;
+ CGEN_FIELDS * fields;
+ CGEN_INSN_BYTES_PTR buffer;
+ bfd_vma pc;
+{
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ unsigned long value;
+ const unsigned char * syn;
+
+ CGEN_INIT_INSERT (cd);
+ value = CGEN_INSN_BASE_VALUE (insn);
+
+ /* If we're recording insns as numbers (rather than a string of bytes),
+ target byte order handling is deferred until later. */
+
+#if CGEN_INT_INSN_P
+
+ *buffer = value;
+
+#else
+
+ cgen_put_insn_value (cd, buffer, min (cd->base_insn_bitsize,
+ CGEN_FIELDS_BITSIZE (fields)),
+ value);
+
+#endif /* ! CGEN_INT_INSN_P */
+
+ /* ??? It would be better to scan the format's fields.
+ Still need to be able to insert a value based on the operand though;
+ e.g. storing a branch displacement that got resolved later.
+ Needs more thought first. */
+
+ for (syn = CGEN_SYNTAX_STRING (syntax); * syn != '\0'; ++ syn)
+ {
+ const char *errmsg;
+
+ if (CGEN_SYNTAX_CHAR_P (* syn))
+ continue;
+
+ errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
+ fields, buffer, pc);
+ if (errmsg)
+ return errmsg;
+ }
+
+ return NULL;
+}
+
+/* Operand extraction. */
+
+#if ! CGEN_INT_INSN_P
+
+/* Subroutine of extract_normal.
+ Ensure sufficient bytes are cached in EX_INFO.
+ OFFSET is the offset in bytes from the start of the insn of the value.
+ BYTES is the length of the needed value.
+ Returns 1 for success, 0 for failure. */
+
+static CGEN_INLINE int
+fill_cache (cd, ex_info, offset, bytes, pc)
+ CGEN_CPU_DESC cd;
+ CGEN_EXTRACT_INFO *ex_info;
+ int offset, bytes;
+ bfd_vma pc;
+{
+ /* It's doubtful that the middle part has already been fetched so
+ we don't optimize that case. kiss. */
+ int mask;
+ disassemble_info *info = (disassemble_info *) ex_info->dis_info;
+
+ /* First do a quick check. */
+ mask = (1 << bytes) - 1;
+ if (((ex_info->valid >> offset) & mask) == mask)
+ return 1;
+
+ /* Search for the first byte we need to read. */
+ for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
+ if (! (mask & ex_info->valid))
+ break;
+
+ if (bytes)
+ {
+ int status;
+
+ pc += offset;
+ status = (*info->read_memory_func)
+ (pc, ex_info->insn_bytes + offset, bytes, info);
+
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return 0;
+ }
+
+ ex_info->valid |= ((1 << bytes) - 1) << offset;
+ }
+
+ return 1;
+}
+
+/* Subroutine of extract_normal. */
+
+static CGEN_INLINE long
+extract_1 (cd, ex_info, start, length, word_length, bufp, pc)
+ CGEN_CPU_DESC cd;
+ CGEN_EXTRACT_INFO *ex_info;
+ int start,length,word_length;
+ unsigned char *bufp;
+ bfd_vma pc;
+{
+ unsigned long x,mask;
+ int shift;
+ int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+
+ switch (word_length)
+ {
+ case 8:
+ x = *bufp;
+ break;
+ case 16:
+ if (big_p)
+ x = bfd_getb16 (bufp);
+ else
+ x = bfd_getl16 (bufp);
+ break;
+ case 24:
+ /* ??? This may need reworking as these cases don't necessarily
+ want the first byte and the last two bytes handled like this. */
+ if (big_p)
+ x = (bufp[0] << 16) | bfd_getb16 (bufp + 1);
+ else
+ x = bfd_getl16 (bufp) | (bufp[2] << 16);
+ break;
+ case 32:
+ if (big_p)
+ x = bfd_getb32 (bufp);
+ else
+ x = bfd_getl32 (bufp);
+ break;
+ default :
+ abort ();
+ }
+
+ /* Written this way to avoid undefined behaviour. */
+ mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ if (CGEN_INSN_LSB0_P)
+ shift = (start + 1) - length;
+ else
+ shift = (word_length - (start + length));
+ return (x >> shift) & mask;
+}
+
+#endif /* ! CGEN_INT_INSN_P */
+
+/* Default extraction routine.
+
+ INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
+ or sometimes less for cases like the m32r where the base insn size is 32
+ but some insns are 16 bits.
+ ATTRS is a mask of the boolean attributes. We only need `SIGNED',
+ but for generality we take a bitmask of all of them.
+ WORD_OFFSET is the offset in bits from the start of the insn of the value.
+ WORD_LENGTH is the length of the word in bits in which the value resides.
+ START is the starting bit number in the word, architecture origin.
+ LENGTH is the length of VALUE in bits.
+ TOTAL_LENGTH is the total length of the insn in bits.
+
+ Returns 1 for success, 0 for failure. */
+
+/* ??? The return code isn't properly used. wip. */
+
+/* ??? This doesn't handle bfd_vma's. Create another function when
+ necessary. */
+
+static int
+extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length,
+ word_length, total_length, pc, valuep)
+ CGEN_CPU_DESC cd;
+ CGEN_EXTRACT_INFO *ex_info;
+ CGEN_INSN_INT insn_value;
+ unsigned int attrs;
+ unsigned int word_offset, start, length, word_length, total_length;
+ bfd_vma pc;
+ long *valuep;
+{
+ CGEN_INSN_INT value;
+
+ /* If LENGTH is zero, this operand doesn't contribute to the value
+ so give it a standard value of zero. */
+ if (length == 0)
+ {
+ *valuep = 0;
+ return 1;
+ }
+
+ if (CGEN_INT_INSN_P
+ && word_offset != 0)
+ abort ();
+
+ if (word_length > 32)
+ abort ();
+
+ /* For architectures with insns smaller than the insn-base-bitsize,
+ word_length may be too big. */
+ if (cd->min_insn_bitsize < cd->base_insn_bitsize)
+ {
+ if (word_offset == 0
+ && word_length > total_length)
+ word_length = total_length;
+ }
+
+ /* Does the value reside in INSN_VALUE? */
+
+ if (word_offset == 0)
+ {
+ /* Written this way to avoid undefined behaviour. */
+ CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+
+ if (CGEN_INSN_LSB0_P)
+ value = insn_value >> ((start + 1) - length);
+ else
+ value = insn_value >> (word_length - (start + length));
+ value &= mask;
+ /* sign extend? */
+ if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
+ && (value & (1L << (length - 1))))
+ value |= ~mask;
+ }
+
+#if ! CGEN_INT_INSN_P
+
+ else
+ {
+ unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
+
+ if (word_length > 32)
+ abort ();
+
+ if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
+ return 0;
+
+ value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
+ }
+
+#endif /* ! CGEN_INT_INSN_P */
+
+ *valuep = value;
+
+ return 1;
+}
+
+/* Default insn extractor.
+
+ INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
+ The extracted fields are stored in FIELDS.
+ EX_INFO is used to handle reading variable length insns.
+ Return the length of the insn in bits, or 0 if no match,
+ or -1 if an error occurs fetching data (memory_error_func will have
+ been called). */
+
+static int
+extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc)
+ CGEN_CPU_DESC cd;
+ const CGEN_INSN *insn;
+ CGEN_EXTRACT_INFO *ex_info;
+ CGEN_INSN_INT insn_value;
+ CGEN_FIELDS *fields;
+ bfd_vma pc;
+{
+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
+ const unsigned char *syn;
+
+ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
+
+ CGEN_INIT_EXTRACT (cd);
+
+ for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
+ {
+ int length;
+
+ if (CGEN_SYNTAX_CHAR_P (*syn))
+ continue;
+
+ length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
+ ex_info, insn_value, fields, pc);
+ if (length <= 0)
+ return length;
+ }
+
+ /* We recognized and successfully extracted this insn. */
+ return CGEN_INSN_BITSIZE (insn);
+}
+
+/* machine generated code added here */
+
+/* Main entry point for operand insertion.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `parse_insn_normal', but keeping it
+ separate makes clear the interface between `parse_insn_normal' and each of
+ the handlers. It's also needed by GAS to insert operands that couldn't be
+ resolved during parsing.
+*/
+
+const char *
+m32r_cgen_insert_operand (cd, opindex, fields, buffer, pc)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_FIELDS * fields;
+ CGEN_INSN_BYTES_PTR buffer;
+ bfd_vma pc;
+{
+ const char * errmsg;
+ unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
+
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 4, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_DISP16 :
+ {
+ long value = fields->f_disp16;
+ value = ((int) (((value) - (pc))) >> (2));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, buffer);
+ }
+ break;
+ case M32R_OPERAND_DISP24 :
+ {
+ long value = fields->f_disp24;
+ value = ((int) (((value) - (pc))) >> (2));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 24, 32, total_length, buffer);
+ }
+ break;
+ case M32R_OPERAND_DISP8 :
+ {
+ long value = fields->f_disp8;
+ value = ((int) (((value) - (((pc) & (-4))))) >> (2));
+ errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 32, total_length, buffer);
+ }
+ break;
+ case M32R_OPERAND_DR :
+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 4, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_HASH :
+ errmsg = insert_normal (cd, fields->f_nil, 0, 0, 0, 0, 0, total_length, buffer);
+ break;
+ case M32R_OPERAND_HI16 :
+ errmsg = insert_normal (cd, fields->f_hi16, 0|(1<<CGEN_IFLD_SIGN_OPT), 0, 16, 16, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SCR :
+ errmsg = insert_normal (cd, fields->f_r2, 0, 0, 12, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SIMM16 :
+ errmsg = insert_normal (cd, fields->f_simm16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SIMM8 :
+ errmsg = insert_normal (cd, fields->f_simm8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SLO16 :
+ errmsg = insert_normal (cd, fields->f_simm16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SR :
+ errmsg = insert_normal (cd, fields->f_r2, 0, 0, 12, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SRC1 :
+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 4, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_SRC2 :
+ errmsg = insert_normal (cd, fields->f_r2, 0, 0, 12, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_UIMM16 :
+ errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 16, 16, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_UIMM24 :
+ errmsg = insert_normal (cd, fields->f_uimm24, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 8, 24, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_UIMM4 :
+ errmsg = insert_normal (cd, fields->f_uimm4, 0, 0, 12, 4, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_UIMM5 :
+ errmsg = insert_normal (cd, fields->f_uimm5, 0, 0, 11, 5, 32, total_length, buffer);
+ break;
+ case M32R_OPERAND_ULO16 :
+ errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 16, 16, 32, total_length, buffer);
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
+ opindex);
+ abort ();
+ }
+
+ return errmsg;
+}
+
+/* Main entry point for operand extraction.
+
+ This function is basically just a big switch statement. Earlier versions
+ used tables to look up the function to use, but
+ - if the table contains both assembler and disassembler functions then
+ the disassembler contains much of the assembler and vice-versa,
+ - there's a lot of inlining possibilities as things grow,
+ - using a switch statement avoids the function call overhead.
+
+ This function could be moved into `print_insn_normal', but keeping it
+ separate makes clear the interface between `print_insn_normal' and each of
+ the handlers.
+*/
+
+int
+m32r_cgen_extract_operand (cd, opindex, ex_info, insn_value, fields, pc)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_EXTRACT_INFO *ex_info;
+ CGEN_INSN_INT insn_value;
+ CGEN_FIELDS * fields;
+ bfd_vma pc;
+{
+ int length;
+ unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
+
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_r1);
+ break;
+ case M32R_OPERAND_DISP16 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, pc, & value);
+ value = ((((value) << (2))) + (pc));
+ fields->f_disp16 = value;
+ }
+ break;
+ case M32R_OPERAND_DISP24 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 24, 32, total_length, pc, & value);
+ value = ((((value) << (2))) + (pc));
+ fields->f_disp24 = value;
+ }
+ break;
+ case M32R_OPERAND_DISP8 :
+ {
+ long value;
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 32, total_length, pc, & value);
+ value = ((((value) << (2))) + (((pc) & (-4))));
+ fields->f_disp8 = value;
+ }
+ break;
+ case M32R_OPERAND_DR :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_r1);
+ break;
+ case M32R_OPERAND_HASH :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 0, total_length, pc, & fields->f_nil);
+ break;
+ case M32R_OPERAND_HI16 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGN_OPT), 0, 16, 16, 32, total_length, pc, & fields->f_hi16);
+ break;
+ case M32R_OPERAND_SCR :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_r2);
+ break;
+ case M32R_OPERAND_SIMM16 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_simm16);
+ break;
+ case M32R_OPERAND_SIMM8 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, pc, & fields->f_simm8);
+ break;
+ case M32R_OPERAND_SLO16 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_simm16);
+ break;
+ case M32R_OPERAND_SR :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_r2);
+ break;
+ case M32R_OPERAND_SRC1 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_r1);
+ break;
+ case M32R_OPERAND_SRC2 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_r2);
+ break;
+ case M32R_OPERAND_UIMM16 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_uimm16);
+ break;
+ case M32R_OPERAND_UIMM24 :
+ length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 8, 24, 32, total_length, pc, & fields->f_uimm24);
+ break;
+ case M32R_OPERAND_UIMM4 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_uimm4);
+ break;
+ case M32R_OPERAND_UIMM5 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 5, 32, total_length, pc, & fields->f_uimm5);
+ break;
+ case M32R_OPERAND_ULO16 :
+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_uimm16);
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
+ opindex);
+ abort ();
+ }
+
+ return length;
+}
+
+cgen_insert_fn * const m32r_cgen_insert_handlers[] =
+{
+ insert_insn_normal,
+};
+
+cgen_extract_fn * const m32r_cgen_extract_handlers[] =
+{
+ extract_insn_normal,
+};
+
+/* Getting values from cgen_fields is handled by a collection of functions.
+ They are distinguished by the type of the VALUE argument they return.
+ TODO: floating point, inlining support, remove cases where result type
+ not appropriate. */
+
+int
+m32r_cgen_get_int_operand (cd, opindex, fields)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ const CGEN_FIELDS * fields;
+{
+ int value;
+
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ value = fields->f_r1;
+ break;
+ case M32R_OPERAND_DISP16 :
+ value = fields->f_disp16;
+ break;
+ case M32R_OPERAND_DISP24 :
+ value = fields->f_disp24;
+ break;
+ case M32R_OPERAND_DISP8 :
+ value = fields->f_disp8;
+ break;
+ case M32R_OPERAND_DR :
+ value = fields->f_r1;
+ break;
+ case M32R_OPERAND_HASH :
+ value = fields->f_nil;
+ break;
+ case M32R_OPERAND_HI16 :
+ value = fields->f_hi16;
+ break;
+ case M32R_OPERAND_SCR :
+ value = fields->f_r2;
+ break;
+ case M32R_OPERAND_SIMM16 :
+ value = fields->f_simm16;
+ break;
+ case M32R_OPERAND_SIMM8 :
+ value = fields->f_simm8;
+ break;
+ case M32R_OPERAND_SLO16 :
+ value = fields->f_simm16;
+ break;
+ case M32R_OPERAND_SR :
+ value = fields->f_r2;
+ break;
+ case M32R_OPERAND_SRC1 :
+ value = fields->f_r1;
+ break;
+ case M32R_OPERAND_SRC2 :
+ value = fields->f_r2;
+ break;
+ case M32R_OPERAND_UIMM16 :
+ value = fields->f_uimm16;
+ break;
+ case M32R_OPERAND_UIMM24 :
+ value = fields->f_uimm24;
+ break;
+ case M32R_OPERAND_UIMM4 :
+ value = fields->f_uimm4;
+ break;
+ case M32R_OPERAND_UIMM5 :
+ value = fields->f_uimm5;
+ break;
+ case M32R_OPERAND_ULO16 :
+ value = fields->f_uimm16;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
+ opindex);
+ abort ();
+ }
+
+ return value;
+}
+
+bfd_vma
+m32r_cgen_get_vma_operand (cd, opindex, fields)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ const CGEN_FIELDS * fields;
+{
+ bfd_vma value;
+
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ value = fields->f_r1;
+ break;
+ case M32R_OPERAND_DISP16 :
+ value = fields->f_disp16;
+ break;
+ case M32R_OPERAND_DISP24 :
+ value = fields->f_disp24;
+ break;
+ case M32R_OPERAND_DISP8 :
+ value = fields->f_disp8;
+ break;
+ case M32R_OPERAND_DR :
+ value = fields->f_r1;
+ break;
+ case M32R_OPERAND_HASH :
+ value = fields->f_nil;
+ break;
+ case M32R_OPERAND_HI16 :
+ value = fields->f_hi16;
+ break;
+ case M32R_OPERAND_SCR :
+ value = fields->f_r2;
+ break;
+ case M32R_OPERAND_SIMM16 :
+ value = fields->f_simm16;
+ break;
+ case M32R_OPERAND_SIMM8 :
+ value = fields->f_simm8;
+ break;
+ case M32R_OPERAND_SLO16 :
+ value = fields->f_simm16;
+ break;
+ case M32R_OPERAND_SR :
+ value = fields->f_r2;
+ break;
+ case M32R_OPERAND_SRC1 :
+ value = fields->f_r1;
+ break;
+ case M32R_OPERAND_SRC2 :
+ value = fields->f_r2;
+ break;
+ case M32R_OPERAND_UIMM16 :
+ value = fields->f_uimm16;
+ break;
+ case M32R_OPERAND_UIMM24 :
+ value = fields->f_uimm24;
+ break;
+ case M32R_OPERAND_UIMM4 :
+ value = fields->f_uimm4;
+ break;
+ case M32R_OPERAND_UIMM5 :
+ value = fields->f_uimm5;
+ break;
+ case M32R_OPERAND_ULO16 :
+ value = fields->f_uimm16;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
+ opindex);
+ abort ();
+ }
+
+ return value;
+}
+
+/* Stuffing values in cgen_fields is handled by a collection of functions.
+ They are distinguished by the type of the VALUE argument they accept.
+ TODO: floating point, inlining support, remove cases where argument type
+ not appropriate. */
+
+void
+m32r_cgen_set_int_operand (cd, opindex, fields, value)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_FIELDS * fields;
+ int value;
+{
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ fields->f_r1 = value;
+ break;
+ case M32R_OPERAND_DISP16 :
+ fields->f_disp16 = value;
+ break;
+ case M32R_OPERAND_DISP24 :
+ fields->f_disp24 = value;
+ break;
+ case M32R_OPERAND_DISP8 :
+ fields->f_disp8 = value;
+ break;
+ case M32R_OPERAND_DR :
+ fields->f_r1 = value;
+ break;
+ case M32R_OPERAND_HASH :
+ fields->f_nil = value;
+ break;
+ case M32R_OPERAND_HI16 :
+ fields->f_hi16 = value;
+ break;
+ case M32R_OPERAND_SCR :
+ fields->f_r2 = value;
+ break;
+ case M32R_OPERAND_SIMM16 :
+ fields->f_simm16 = value;
+ break;
+ case M32R_OPERAND_SIMM8 :
+ fields->f_simm8 = value;
+ break;
+ case M32R_OPERAND_SLO16 :
+ fields->f_simm16 = value;
+ break;
+ case M32R_OPERAND_SR :
+ fields->f_r2 = value;
+ break;
+ case M32R_OPERAND_SRC1 :
+ fields->f_r1 = value;
+ break;
+ case M32R_OPERAND_SRC2 :
+ fields->f_r2 = value;
+ break;
+ case M32R_OPERAND_UIMM16 :
+ fields->f_uimm16 = value;
+ break;
+ case M32R_OPERAND_UIMM24 :
+ fields->f_uimm24 = value;
+ break;
+ case M32R_OPERAND_UIMM4 :
+ fields->f_uimm4 = value;
+ break;
+ case M32R_OPERAND_UIMM5 :
+ fields->f_uimm5 = value;
+ break;
+ case M32R_OPERAND_ULO16 :
+ fields->f_uimm16 = value;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
+ opindex);
+ abort ();
+ }
+}
+
+void
+m32r_cgen_set_vma_operand (cd, opindex, fields, value)
+ CGEN_CPU_DESC cd;
+ int opindex;
+ CGEN_FIELDS * fields;
+ bfd_vma value;
+{
+ switch (opindex)
+ {
+ case M32R_OPERAND_DCR :
+ fields->f_r1 = value;
+ break;
+ case M32R_OPERAND_DISP16 :
+ fields->f_disp16 = value;
+ break;
+ case M32R_OPERAND_DISP24 :
+ fields->f_disp24 = value;
+ break;
+ case M32R_OPERAND_DISP8 :
+ fields->f_disp8 = value;
+ break;
+ case M32R_OPERAND_DR :
+ fields->f_r1 = value;
+ break;
+ case M32R_OPERAND_HASH :
+ fields->f_nil = value;
+ break;
+ case M32R_OPERAND_HI16 :
+ fields->f_hi16 = value;
+ break;
+ case M32R_OPERAND_SCR :
+ fields->f_r2 = value;
+ break;
+ case M32R_OPERAND_SIMM16 :
+ fields->f_simm16 = value;
+ break;
+ case M32R_OPERAND_SIMM8 :
+ fields->f_simm8 = value;
+ break;
+ case M32R_OPERAND_SLO16 :
+ fields->f_simm16 = value;
+ break;
+ case M32R_OPERAND_SR :
+ fields->f_r2 = value;
+ break;
+ case M32R_OPERAND_SRC1 :
+ fields->f_r1 = value;
+ break;
+ case M32R_OPERAND_SRC2 :
+ fields->f_r2 = value;
+ break;
+ case M32R_OPERAND_UIMM16 :
+ fields->f_uimm16 = value;
+ break;
+ case M32R_OPERAND_UIMM24 :
+ fields->f_uimm24 = value;
+ break;
+ case M32R_OPERAND_UIMM4 :
+ fields->f_uimm4 = value;
+ break;
+ case M32R_OPERAND_UIMM5 :
+ fields->f_uimm5 = value;
+ break;
+ case M32R_OPERAND_ULO16 :
+ fields->f_uimm16 = value;
+ break;
+
+ default :
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
+ opindex);
+ abort ();
+ }
+}
+
+/* Function to call before using the instruction builder tables. */
+
+void
+m32r_cgen_init_ibld_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ cd->insert_handlers = & m32r_cgen_insert_handlers[0];
+ cd->extract_handlers = & m32r_cgen_extract_handlers[0];
+
+ cd->insert_operand = m32r_cgen_insert_operand;
+ cd->extract_operand = m32r_cgen_extract_operand;
+
+ cd->get_int_operand = m32r_cgen_get_int_operand;
+ cd->set_int_operand = m32r_cgen_set_int_operand;
+ cd->get_vma_operand = m32r_cgen_get_vma_operand;
+ cd->set_vma_operand = m32r_cgen_set_vma_operand;
+}
diff --git a/opcodes/m32r-opc.c b/opcodes/m32r-opc.c
new file mode 100644
index 00000000000..43edf9ae1f7
--- /dev/null
+++ b/opcodes/m32r-opc.c
@@ -0,0 +1,1331 @@
+/* Instruction opcode table for m32r.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "sysdep.h"
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "m32r-desc.h"
+#include "m32r-opc.h"
+
+/* The hash functions are recorded here to help keep assembler code out of
+ the disassembler and vice versa. */
+
+static int asm_hash_insn_p PARAMS ((const CGEN_INSN *));
+static unsigned int asm_hash_insn PARAMS ((const char *));
+static int dis_hash_insn_p PARAMS ((const CGEN_INSN *));
+static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT));
+
+/* Instruction formats. */
+
+#define F(f) & m32r_cgen_ifld_table[CONCAT2 (M32R_,f)]
+
+static const CGEN_IFMT ifmt_empty = {
+ 0, 0, 0x0, { 0 }
+};
+
+static const CGEN_IFMT ifmt_add = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_add3 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_and3 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_UIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_or3 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_UIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_addi = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_R1), F (F_SIMM8), 0 }
+};
+
+static const CGEN_IFMT ifmt_addv3 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_bc8 = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
+};
+
+static const CGEN_IFMT ifmt_bc24 = {
+ 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
+};
+
+static const CGEN_IFMT ifmt_beq = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_DISP16), 0 }
+};
+
+static const CGEN_IFMT ifmt_beqz = {
+ 32, 32, 0xfff00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_DISP16), 0 }
+};
+
+static const CGEN_IFMT ifmt_cmp = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_cmpi = {
+ 32, 32, 0xfff00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_div = {
+ 32, 32, 0xf0f0ffff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_jl = {
+ 16, 16, 0xfff0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_ld24 = {
+ 32, 32, 0xf0000000, { F (F_OP1), F (F_R1), F (F_UIMM24), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi16 = {
+ 32, 32, 0xf0ff0000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_mvfachi = {
+ 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_mvfc = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_mvtachi = {
+ 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_mvtc = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_nop = {
+ 16, 16, 0xffff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_seth = {
+ 32, 32, 0xf0ff0000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_HI16), 0 }
+};
+
+static const CGEN_IFMT ifmt_slli = {
+ 16, 16, 0xf0e0, { F (F_OP1), F (F_R1), F (F_SHIFT_OP2), F (F_UIMM5), 0 }
+};
+
+static const CGEN_IFMT ifmt_st_d = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_trap = {
+ 16, 16, 0xfff0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_UIMM4), 0 }
+};
+
+#undef F
+
+#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
+#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
+#define OPERAND(op) CONCAT2 (M32R_OPERAND_,op)
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+
+/* The instruction table. */
+
+static const CGEN_OPCODE m32r_cgen_insn_opcode_table[MAX_INSNS] =
+{
+ /* Special null first entry.
+ A `num' value of zero is thus invalid.
+ Also, the special `invalid' insn resides here. */
+ { { 0 } },
+/* add $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0xa0 }
+ },
+/* add3 $dr,$sr,$hash$slo16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (HASH), OP (SLO16), 0 } },
+ & ifmt_add3, { 0x80a00000 }
+ },
+/* and $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0xc0 }
+ },
+/* and3 $dr,$sr,$uimm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (UIMM16), 0 } },
+ & ifmt_and3, { 0x80c00000 }
+ },
+/* or $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0xe0 }
+ },
+/* or3 $dr,$sr,$hash$ulo16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (HASH), OP (ULO16), 0 } },
+ & ifmt_or3, { 0x80e00000 }
+ },
+/* xor $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0xd0 }
+ },
+/* xor3 $dr,$sr,$uimm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (UIMM16), 0 } },
+ & ifmt_and3, { 0x80d00000 }
+ },
+/* addi $dr,$simm8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SIMM8), 0 } },
+ & ifmt_addi, { 0x4000 }
+ },
+/* addv $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x80 }
+ },
+/* addv3 $dr,$sr,$simm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
+ & ifmt_addv3, { 0x80800000 }
+ },
+/* addx $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x90 }
+ },
+/* bc.s $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bc8, { 0x7c00 }
+ },
+/* bc.l $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bc24, { 0xfc000000 }
+ },
+/* beq $src1,$src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beq, { 0xb0000000 }
+ },
+/* beqz $src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beqz, { 0xb0800000 }
+ },
+/* bgez $src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beqz, { 0xb0b00000 }
+ },
+/* bgtz $src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beqz, { 0xb0d00000 }
+ },
+/* blez $src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beqz, { 0xb0c00000 }
+ },
+/* bltz $src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beqz, { 0xb0a00000 }
+ },
+/* bnez $src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beqz, { 0xb0900000 }
+ },
+/* bl.s $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bc8, { 0x7e00 }
+ },
+/* bl.l $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bc24, { 0xfe000000 }
+ },
+/* bnc.s $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bc8, { 0x7d00 }
+ },
+/* bnc.l $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bc24, { 0xfd000000 }
+ },
+/* bne $src1,$src2,$disp16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), ',', OP (DISP16), 0 } },
+ & ifmt_beq, { 0xb0100000 }
+ },
+/* bra.s $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bc8, { 0x7f00 }
+ },
+/* bra.l $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bc24, { 0xff000000 }
+ },
+/* cmp $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x40 }
+ },
+/* cmpi $src2,$simm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (SIMM16), 0 } },
+ & ifmt_cmpi, { 0x80400000 }
+ },
+/* cmpu $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x50 }
+ },
+/* cmpui $src2,$simm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC2), ',', OP (SIMM16), 0 } },
+ & ifmt_cmpi, { 0x80500000 }
+ },
+/* div $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_div, { 0x90000000 }
+ },
+/* divu $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_div, { 0x90100000 }
+ },
+/* rem $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_div, { 0x90200000 }
+ },
+/* remu $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_div, { 0x90300000 }
+ },
+/* jl $sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SR), 0 } },
+ & ifmt_jl, { 0x1ec0 }
+ },
+/* jmp $sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SR), 0 } },
+ & ifmt_jl, { 0x1fc0 }
+ },
+/* ld $dr,@$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
+ & ifmt_add, { 0x20c0 }
+ },
+/* ld $dr,@($slo16,$sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
+ & ifmt_add3, { 0xa0c00000 }
+ },
+/* ldb $dr,@$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
+ & ifmt_add, { 0x2080 }
+ },
+/* ldb $dr,@($slo16,$sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
+ & ifmt_add3, { 0xa0800000 }
+ },
+/* ldh $dr,@$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
+ & ifmt_add, { 0x20a0 }
+ },
+/* ldh $dr,@($slo16,$sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
+ & ifmt_add3, { 0xa0a00000 }
+ },
+/* ldub $dr,@$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
+ & ifmt_add, { 0x2090 }
+ },
+/* ldub $dr,@($slo16,$sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
+ & ifmt_add3, { 0xa0900000 }
+ },
+/* lduh $dr,@$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
+ & ifmt_add, { 0x20b0 }
+ },
+/* lduh $dr,@($slo16,$sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
+ & ifmt_add3, { 0xa0b00000 }
+ },
+/* ld $dr,@$sr+ */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), '+', 0 } },
+ & ifmt_add, { 0x20e0 }
+ },
+/* ld24 $dr,$uimm24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (UIMM24), 0 } },
+ & ifmt_ld24, { 0xe0000000 }
+ },
+/* ldi8 $dr,$simm8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SIMM8), 0 } },
+ & ifmt_addi, { 0x6000 }
+ },
+/* ldi16 $dr,$hash$slo16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (HASH), OP (SLO16), 0 } },
+ & ifmt_ldi16, { 0x90f00000 }
+ },
+/* lock $dr,@$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
+ & ifmt_add, { 0x20d0 }
+ },
+/* machi $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3040 }
+ },
+/* maclo $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3050 }
+ },
+/* macwhi $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3060 }
+ },
+/* macwlo $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3070 }
+ },
+/* mul $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x1060 }
+ },
+/* mulhi $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3000 }
+ },
+/* mullo $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3010 }
+ },
+/* mulwhi $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3020 }
+ },
+/* mulwlo $src1,$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x3030 }
+ },
+/* mv $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x1080 }
+ },
+/* mvfachi $dr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), 0 } },
+ & ifmt_mvfachi, { 0x50f0 }
+ },
+/* mvfaclo $dr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), 0 } },
+ & ifmt_mvfachi, { 0x50f1 }
+ },
+/* mvfacmi $dr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), 0 } },
+ & ifmt_mvfachi, { 0x50f2 }
+ },
+/* mvfc $dr,$scr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SCR), 0 } },
+ & ifmt_mvfc, { 0x1090 }
+ },
+/* mvtachi $src1 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), 0 } },
+ & ifmt_mvtachi, { 0x5070 }
+ },
+/* mvtaclo $src1 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), 0 } },
+ & ifmt_mvtachi, { 0x5071 }
+ },
+/* mvtc $sr,$dcr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SR), ',', OP (DCR), 0 } },
+ & ifmt_mvtc, { 0x10a0 }
+ },
+/* neg $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x30 }
+ },
+/* nop */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_nop, { 0x7000 }
+ },
+/* not $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0xb0 }
+ },
+/* rac */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_nop, { 0x5090 }
+ },
+/* rach */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_nop, { 0x5080 }
+ },
+/* rte */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, 0 } },
+ & ifmt_nop, { 0x10d6 }
+ },
+/* seth $dr,$hash$hi16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (HASH), OP (HI16), 0 } },
+ & ifmt_seth, { 0xd0c00000 }
+ },
+/* sll $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x1040 }
+ },
+/* sll3 $dr,$sr,$simm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
+ & ifmt_addv3, { 0x90c00000 }
+ },
+/* slli $dr,$uimm5 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (UIMM5), 0 } },
+ & ifmt_slli, { 0x5040 }
+ },
+/* sra $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x1020 }
+ },
+/* sra3 $dr,$sr,$simm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
+ & ifmt_addv3, { 0x90a00000 }
+ },
+/* srai $dr,$uimm5 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (UIMM5), 0 } },
+ & ifmt_slli, { 0x5020 }
+ },
+/* srl $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x1000 }
+ },
+/* srl3 $dr,$sr,$simm16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
+ & ifmt_addv3, { 0x90800000 }
+ },
+/* srli $dr,$uimm5 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (UIMM5), 0 } },
+ & ifmt_slli, { 0x5000 }
+ },
+/* st $src1,@$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x2040 }
+ },
+/* st $src1,@($slo16,$src2) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SLO16), ',', OP (SRC2), ')', 0 } },
+ & ifmt_st_d, { 0xa0400000 }
+ },
+/* stb $src1,@$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x2000 }
+ },
+/* stb $src1,@($slo16,$src2) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SLO16), ',', OP (SRC2), ')', 0 } },
+ & ifmt_st_d, { 0xa0000000 }
+ },
+/* sth $src1,@$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x2020 }
+ },
+/* sth $src1,@($slo16,$src2) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SLO16), ',', OP (SRC2), ')', 0 } },
+ & ifmt_st_d, { 0xa0200000 }
+ },
+/* st $src1,@+$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '+', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x2060 }
+ },
+/* st $src1,@-$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '-', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x2070 }
+ },
+/* sub $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x20 }
+ },
+/* subv $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x0 }
+ },
+/* subx $dr,$sr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
+ & ifmt_add, { 0x10 }
+ },
+/* trap $uimm4 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (UIMM4), 0 } },
+ & ifmt_trap, { 0x10f0 }
+ },
+/* unlock $src1,@$src2 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
+ & ifmt_cmp, { 0x2050 }
+ },
+};
+
+#undef A
+#undef MNEM
+#undef OPERAND
+#undef OP
+
+/* Formats for ALIAS macro-insns. */
+
+#define F(f) & m32r_cgen_ifld_table[CONCAT2 (M32R_,f)]
+
+static const CGEN_IFMT ifmt_bc8r = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
+};
+
+static const CGEN_IFMT ifmt_bc24r = {
+ 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
+};
+
+static const CGEN_IFMT ifmt_bl8r = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
+};
+
+static const CGEN_IFMT ifmt_bl24r = {
+ 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
+};
+
+static const CGEN_IFMT ifmt_bnc8r = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
+};
+
+static const CGEN_IFMT ifmt_bnc24r = {
+ 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
+};
+
+static const CGEN_IFMT ifmt_bra8r = {
+ 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
+};
+
+static const CGEN_IFMT ifmt_bra24r = {
+ 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
+};
+
+static const CGEN_IFMT ifmt_ld_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_ld_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldb_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldb_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldh_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldh_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldub_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldub_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_lduh_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_lduh_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_pop = {
+ 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi8a = {
+ 16, 16, 0xf000, { F (F_OP1), F (F_R1), F (F_SIMM8), 0 }
+};
+
+static const CGEN_IFMT ifmt_ldi16a = {
+ 32, 32, 0xf0ff0000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_st_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_st_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_stb_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_stb_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_sth_2 = {
+ 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+static const CGEN_IFMT ifmt_sth_d2 = {
+ 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
+};
+
+static const CGEN_IFMT ifmt_push = {
+ 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
+};
+
+#undef F
+
+/* Each non-simple macro entry points to an array of expansion possibilities. */
+
+#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
+#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
+#define OPERAND(op) CONCAT2 (M32R_OPERAND_,op)
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+
+/* The macro instruction table. */
+
+static const CGEN_IBASE m32r_cgen_macro_insn_table[] =
+{
+/* bc $disp8 */
+ {
+ -1, "bc8r", "bc", 16,
+ { 0|A(RELAXABLE)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bc $disp24 */
+ {
+ -1, "bc24r", "bc", 32,
+ { 0|A(RELAX)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bl $disp8 */
+ {
+ -1, "bl8r", "bl", 16,
+ { 0|A(RELAXABLE)|A(FILL_SLOT)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bl $disp24 */
+ {
+ -1, "bl24r", "bl", 32,
+ { 0|A(RELAX)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bnc $disp8 */
+ {
+ -1, "bnc8r", "bnc", 16,
+ { 0|A(RELAXABLE)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bnc $disp24 */
+ {
+ -1, "bnc24r", "bnc", 32,
+ { 0|A(RELAX)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bra $disp8 */
+ {
+ -1, "bra8r", "bra", 16,
+ { 0|A(RELAXABLE)|A(FILL_SLOT)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* bra $disp24 */
+ {
+ -1, "bra24r", "bra", 32,
+ { 0|A(RELAX)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ld $dr,@($sr) */
+ {
+ -1, "ld-2", "ld", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ld $dr,@($sr,$slo16) */
+ {
+ -1, "ld-d2", "ld", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldb $dr,@($sr) */
+ {
+ -1, "ldb-2", "ldb", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldb $dr,@($sr,$slo16) */
+ {
+ -1, "ldb-d2", "ldb", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldh $dr,@($sr) */
+ {
+ -1, "ldh-2", "ldh", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldh $dr,@($sr,$slo16) */
+ {
+ -1, "ldh-d2", "ldh", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldub $dr,@($sr) */
+ {
+ -1, "ldub-2", "ldub", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldub $dr,@($sr,$slo16) */
+ {
+ -1, "ldub-d2", "ldub", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* lduh $dr,@($sr) */
+ {
+ -1, "lduh-2", "lduh", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* lduh $dr,@($sr,$slo16) */
+ {
+ -1, "lduh-d2", "lduh", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* pop $dr */
+ {
+ -1, "pop", "pop", 16,
+ { 0|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldi $dr,$simm8 */
+ {
+ -1, "ldi8a", "ldi", 16,
+ { 0|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* ldi $dr,$hash$slo16 */
+ {
+ -1, "ldi16a", "ldi", 32,
+ { 0|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* st $src1,@($src2) */
+ {
+ -1, "st-2", "st", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* st $src1,@($src2,$slo16) */
+ {
+ -1, "st-d2", "st", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* stb $src1,@($src2) */
+ {
+ -1, "stb-2", "stb", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* stb $src1,@($src2,$slo16) */
+ {
+ -1, "stb-d2", "stb", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* sth $src1,@($src2) */
+ {
+ -1, "sth-2", "sth", 16,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* sth $src1,@($src2,$slo16) */
+ {
+ -1, "sth-d2", "sth", 32,
+ { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+/* push $src1 */
+ {
+ -1, "push", "push", 16,
+ { 0|A(ALIAS), { (1<<MACH_BASE) } }
+ },
+};
+
+/* The macro instruction opcode table. */
+
+static const CGEN_OPCODE m32r_cgen_macro_insn_opcode_table[] =
+{
+/* bc $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bc8r, { 0x7c00 }
+ },
+/* bc $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bc24r, { 0xfc000000 }
+ },
+/* bl $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bl8r, { 0x7e00 }
+ },
+/* bl $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bl24r, { 0xfe000000 }
+ },
+/* bnc $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bnc8r, { 0x7d00 }
+ },
+/* bnc $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bnc24r, { 0xfd000000 }
+ },
+/* bra $disp8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP8), 0 } },
+ & ifmt_bra8r, { 0x7f00 }
+ },
+/* bra $disp24 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DISP24), 0 } },
+ & ifmt_bra24r, { 0xff000000 }
+ },
+/* ld $dr,@($sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
+ & ifmt_ld_2, { 0x20c0 }
+ },
+/* ld $dr,@($sr,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
+ & ifmt_ld_d2, { 0xa0c00000 }
+ },
+/* ldb $dr,@($sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
+ & ifmt_ldb_2, { 0x2080 }
+ },
+/* ldb $dr,@($sr,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
+ & ifmt_ldb_d2, { 0xa0800000 }
+ },
+/* ldh $dr,@($sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
+ & ifmt_ldh_2, { 0x20a0 }
+ },
+/* ldh $dr,@($sr,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
+ & ifmt_ldh_d2, { 0xa0a00000 }
+ },
+/* ldub $dr,@($sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
+ & ifmt_ldub_2, { 0x2090 }
+ },
+/* ldub $dr,@($sr,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
+ & ifmt_ldub_d2, { 0xa0900000 }
+ },
+/* lduh $dr,@($sr) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
+ & ifmt_lduh_2, { 0x20b0 }
+ },
+/* lduh $dr,@($sr,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
+ & ifmt_lduh_d2, { 0xa0b00000 }
+ },
+/* pop $dr */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), 0 } },
+ & ifmt_pop, { 0x20ef }
+ },
+/* ldi $dr,$simm8 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (SIMM8), 0 } },
+ & ifmt_ldi8a, { 0x6000 }
+ },
+/* ldi $dr,$hash$slo16 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (DR), ',', OP (HASH), OP (SLO16), 0 } },
+ & ifmt_ldi16a, { 0x90f00000 }
+ },
+/* st $src1,@($src2) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ')', 0 } },
+ & ifmt_st_2, { 0x2040 }
+ },
+/* st $src1,@($src2,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ',', OP (SLO16), ')', 0 } },
+ & ifmt_st_d2, { 0xa0400000 }
+ },
+/* stb $src1,@($src2) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ')', 0 } },
+ & ifmt_stb_2, { 0x2000 }
+ },
+/* stb $src1,@($src2,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ',', OP (SLO16), ')', 0 } },
+ & ifmt_stb_d2, { 0xa0000000 }
+ },
+/* sth $src1,@($src2) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ')', 0 } },
+ & ifmt_sth_2, { 0x2020 }
+ },
+/* sth $src1,@($src2,$slo16) */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ',', OP (SLO16), ')', 0 } },
+ & ifmt_sth_d2, { 0xa0200000 }
+ },
+/* push $src1 */
+ {
+ { 0, 0, 0, 0 },
+ { { MNEM, ' ', OP (SRC1), 0 } },
+ & ifmt_push, { 0x207f }
+ },
+};
+
+#undef A
+#undef MNEM
+#undef OPERAND
+#undef OP
+
+#ifndef CGEN_ASM_HASH_P
+#define CGEN_ASM_HASH_P(insn) 1
+#endif
+
+#ifndef CGEN_DIS_HASH_P
+#define CGEN_DIS_HASH_P(insn) 1
+#endif
+
+/* Return non-zero if INSN is to be added to the hash table.
+ Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */
+
+static int
+asm_hash_insn_p (insn)
+ const CGEN_INSN *insn;
+{
+ return CGEN_ASM_HASH_P (insn);
+}
+
+static int
+dis_hash_insn_p (insn)
+ const CGEN_INSN *insn;
+{
+ /* If building the hash table and the NO-DIS attribute is present,
+ ignore. */
+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
+ return 0;
+ return CGEN_DIS_HASH_P (insn);
+}
+
+#ifndef CGEN_ASM_HASH
+#define CGEN_ASM_HASH_SIZE 127
+#ifdef CGEN_MNEMONIC_OPERANDS
+#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
+#else
+#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
+#endif
+#endif
+
+/* It doesn't make much sense to provide a default here,
+ but while this is under development we do.
+ BUFFER is a pointer to the bytes of the insn, target order.
+ VALUE is the first base_insn_bitsize bits as an int in host order. */
+
+#ifndef CGEN_DIS_HASH
+#define CGEN_DIS_HASH_SIZE 256
+#define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
+#endif
+
+/* The result is the hash value of the insn.
+ Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */
+
+static unsigned int
+asm_hash_insn (mnem)
+ const char * mnem;
+{
+ return CGEN_ASM_HASH (mnem);
+}
+
+/* BUF is a pointer to the bytes of the insn, target order.
+ VALUE is the first base_insn_bitsize bits as an int in host order. */
+
+static unsigned int
+dis_hash_insn (buf, value)
+ const char * buf;
+ CGEN_INSN_INT value;
+{
+ return CGEN_DIS_HASH (buf, value);
+}
+
+/* Set the recorded length of the insn in the CGEN_FIELDS struct. */
+
+static void
+set_fields_bitsize (fields, size)
+ CGEN_FIELDS *fields;
+ int size;
+{
+ CGEN_FIELDS_BITSIZE (fields) = size;
+}
+
+/* Function to call before using the operand instance table.
+ This plugs the opcode entries and macro instructions into the cpu table. */
+
+void
+m32r_cgen_init_opcode_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ int i;
+ int num_macros = (sizeof (m32r_cgen_macro_insn_table) /
+ sizeof (m32r_cgen_macro_insn_table[0]));
+ const CGEN_IBASE *ib = & m32r_cgen_macro_insn_table[0];
+ const CGEN_OPCODE *oc = & m32r_cgen_macro_insn_opcode_table[0];
+ CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN));
+ memset (insns, 0, num_macros * sizeof (CGEN_INSN));
+ for (i = 0; i < num_macros; ++i)
+ {
+ insns[i].base = &ib[i];
+ insns[i].opcode = &oc[i];
+ }
+ cd->macro_insn_table.init_entries = insns;
+ cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
+ cd->macro_insn_table.num_init_entries = num_macros;
+
+ oc = & m32r_cgen_insn_opcode_table[0];
+ insns = (CGEN_INSN *) cd->insn_table.init_entries;
+ for (i = 0; i < MAX_INSNS; ++i)
+ insns[i].opcode = &oc[i];
+
+ cd->sizeof_fields = sizeof (CGEN_FIELDS);
+ cd->set_fields_bitsize = set_fields_bitsize;
+
+ cd->asm_hash_p = asm_hash_insn_p;
+ cd->asm_hash = asm_hash_insn;
+ cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
+
+ cd->dis_hash_p = dis_hash_insn_p;
+ cd->dis_hash = dis_hash_insn;
+ cd->dis_hash_size = CGEN_DIS_HASH_SIZE;
+}
diff --git a/opcodes/m32r-opc.h b/opcodes/m32r-opc.h
new file mode 100644
index 00000000000..6c57daa8f9c
--- /dev/null
+++ b/opcodes/m32r-opc.h
@@ -0,0 +1,126 @@
+/* Instruction opcode header for m32r.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef M32R_OPC_H
+#define M32R_OPC_H
+
+/* -- opc.h */
+
+#undef CGEN_DIS_HASH_SIZE
+#define CGEN_DIS_HASH_SIZE 256
+#undef CGEN_DIS_HASH
+#define X(b) (((unsigned char *) (b))[0] & 0xf0)
+#define CGEN_DIS_HASH(buffer, value) \
+(X (buffer) | \
+ (X (buffer) == 0x40 || X (buffer) == 0xe0 || X (buffer) == 0x60 || X (buffer) == 0x50 ? 0 \
+ : X (buffer) == 0x70 || X (buffer) == 0xf0 ? (((unsigned char *) (buffer))[0] & 0xf) \
+ : X (buffer) == 0x30 ? ((((unsigned char *) (buffer))[1] & 0x70) >> 4) \
+ : ((((unsigned char *) (buffer))[1] & 0xf0) >> 4)))
+
+/* -- */
+/* Enum declaration for m32r instruction types. */
+typedef enum cgen_insn_type {
+ M32R_INSN_INVALID, M32R_INSN_ADD, M32R_INSN_ADD3, M32R_INSN_AND
+ , M32R_INSN_AND3, M32R_INSN_OR, M32R_INSN_OR3, M32R_INSN_XOR
+ , M32R_INSN_XOR3, M32R_INSN_ADDI, M32R_INSN_ADDV, M32R_INSN_ADDV3
+ , M32R_INSN_ADDX, M32R_INSN_BC8, M32R_INSN_BC24, M32R_INSN_BEQ
+ , M32R_INSN_BEQZ, M32R_INSN_BGEZ, M32R_INSN_BGTZ, M32R_INSN_BLEZ
+ , M32R_INSN_BLTZ, M32R_INSN_BNEZ, M32R_INSN_BL8, M32R_INSN_BL24
+ , M32R_INSN_BNC8, M32R_INSN_BNC24, M32R_INSN_BNE, M32R_INSN_BRA8
+ , M32R_INSN_BRA24
+ , M32R_INSN_CMP, M32R_INSN_CMPI, M32R_INSN_CMPU, M32R_INSN_CMPUI
+ , M32R_INSN_DIV, M32R_INSN_DIVU, M32R_INSN_REM, M32R_INSN_REMU
+ , M32R_INSN_JL, M32R_INSN_JMP, M32R_INSN_LD, M32R_INSN_LD_D
+ , M32R_INSN_LDB, M32R_INSN_LDB_D, M32R_INSN_LDH, M32R_INSN_LDH_D
+ , M32R_INSN_LDUB, M32R_INSN_LDUB_D, M32R_INSN_LDUH, M32R_INSN_LDUH_D
+ , M32R_INSN_LD_PLUS, M32R_INSN_LD24, M32R_INSN_LDI8, M32R_INSN_LDI16
+ , M32R_INSN_LOCK, M32R_INSN_MACHI
+ , M32R_INSN_MACLO
+ , M32R_INSN_MACWHI
+ , M32R_INSN_MACWLO
+ , M32R_INSN_MUL, M32R_INSN_MULHI
+ , M32R_INSN_MULLO
+ , M32R_INSN_MULWHI
+ , M32R_INSN_MULWLO
+ , M32R_INSN_MV, M32R_INSN_MVFACHI
+ , M32R_INSN_MVFACLO
+ , M32R_INSN_MVFACMI
+ , M32R_INSN_MVFC, M32R_INSN_MVTACHI
+ , M32R_INSN_MVTACLO
+ , M32R_INSN_MVTC, M32R_INSN_NEG, M32R_INSN_NOP, M32R_INSN_NOT
+ , M32R_INSN_RAC
+ , M32R_INSN_RACH
+ , M32R_INSN_RTE, M32R_INSN_SETH, M32R_INSN_SLL, M32R_INSN_SLL3
+ , M32R_INSN_SLLI, M32R_INSN_SRA, M32R_INSN_SRA3, M32R_INSN_SRAI
+ , M32R_INSN_SRL, M32R_INSN_SRL3, M32R_INSN_SRLI, M32R_INSN_ST
+ , M32R_INSN_ST_D, M32R_INSN_STB, M32R_INSN_STB_D, M32R_INSN_STH
+ , M32R_INSN_STH_D, M32R_INSN_ST_PLUS, M32R_INSN_ST_MINUS, M32R_INSN_SUB
+ , M32R_INSN_SUBV, M32R_INSN_SUBX, M32R_INSN_TRAP, M32R_INSN_UNLOCK
+ , M32R_INSN_MAX
+} CGEN_INSN_TYPE;
+
+/* Index of `invalid' insn place holder. */
+#define CGEN_INSN_INVALID M32R_INSN_INVALID
+
+/* Total number of insns in table. */
+#define MAX_INSNS ((int) M32R_INSN_MAX)
+
+/* This struct records data prior to insertion or after extraction. */
+struct cgen_fields
+{
+ int length;
+ long f_nil;
+ long f_op1;
+ long f_op2;
+ long f_cond;
+ long f_r1;
+ long f_r2;
+ long f_simm8;
+ long f_simm16;
+ long f_shift_op2;
+ long f_uimm4;
+ long f_uimm5;
+ long f_uimm16;
+ long f_uimm24;
+ long f_hi16;
+ long f_disp8;
+ long f_disp16;
+ long f_disp24;
+};
+
+#define CGEN_INIT_PARSE(od) \
+{\
+}
+#define CGEN_INIT_INSERT(od) \
+{\
+}
+#define CGEN_INIT_EXTRACT(od) \
+{\
+}
+#define CGEN_INIT_PRINT(od) \
+{\
+}
+
+
+#endif /* M32R_OPC_H */
diff --git a/opcodes/m32r-opinst.c b/opcodes/m32r-opinst.c
new file mode 100644
index 00000000000..7f3a49f8b97
--- /dev/null
+++ b/opcodes/m32r-opinst.c
@@ -0,0 +1,562 @@
+/* Semantic operand instances for m32r.
+
+THIS FILE IS MACHINE GENERATED WITH CGEN.
+
+Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of the GNU Binutils and/or GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "sysdep.h"
+#include "ansidecl.h"
+#include "bfd.h"
+#include "symcat.h"
+#include "m32r-desc.h"
+#include "m32r-opc.h"
+
+/* Operand references. */
+
+#define INPUT CGEN_OPINST_INPUT
+#define OUTPUT CGEN_OPINST_OUTPUT
+#define END CGEN_OPINST_END
+#define COND_REF CGEN_OPINST_COND_REF
+#define OP_ENT(op) CONCAT2 (M32R_OPERAND_,op)
+
+static const CGEN_OPINST fmt_empty_ops[] = {
+ { END }
+};
+
+static const CGEN_OPINST fmt_add_ops[] = {
+ { INPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_add3_ops[] = {
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_and3_ops[] = {
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { INPUT, "uimm16", HW_H_UINT, CGEN_MODE_UINT, OP_ENT (UIMM16), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_or3_ops[] = {
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { INPUT, "ulo16", HW_H_ULO16, CGEN_MODE_UINT, OP_ENT (ULO16), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_addi_ops[] = {
+ { INPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { INPUT, "simm8", HW_H_SINT, CGEN_MODE_INT, OP_ENT (SIMM8), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_addv_ops[] = {
+ { INPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_addv3_ops[] = {
+ { INPUT, "simm16", HW_H_SINT, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_addx_ops[] = {
+ { INPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { INPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_bc8_ops[] = {
+ { INPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { INPUT, "disp8", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP8), 0, COND_REF },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, COND_REF },
+ { END }
+};
+
+static const CGEN_OPINST fmt_bc24_ops[] = {
+ { INPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { INPUT, "disp24", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP24), 0, COND_REF },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, COND_REF },
+ { END }
+};
+
+static const CGEN_OPINST fmt_beq_ops[] = {
+ { INPUT, "disp16", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP16), 0, COND_REF },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, COND_REF },
+ { END }
+};
+
+static const CGEN_OPINST fmt_beqz_ops[] = {
+ { INPUT, "disp16", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP16), 0, COND_REF },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, COND_REF },
+ { END }
+};
+
+static const CGEN_OPINST fmt_bl8_ops[] = {
+ { INPUT, "disp8", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP8), 0, 0 },
+ { INPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { OUTPUT, "h_gr_14", HW_H_GR, CGEN_MODE_SI, 0, 14, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_bl24_ops[] = {
+ { INPUT, "disp24", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP24), 0, 0 },
+ { INPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { OUTPUT, "h_gr_14", HW_H_GR, CGEN_MODE_SI, 0, 14, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_bra8_ops[] = {
+ { INPUT, "disp8", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP8), 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_bra24_ops[] = {
+ { INPUT, "disp24", HW_H_IADDR, CGEN_MODE_USI, OP_ENT (DISP24), 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_cmp_ops[] = {
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_cmpi_ops[] = {
+ { INPUT, "simm16", HW_H_SINT, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "condbit", HW_H_COND, CGEN_MODE_BI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_div_ops[] = {
+ { INPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, COND_REF },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, COND_REF },
+ { END }
+};
+
+static const CGEN_OPINST fmt_jl_ops[] = {
+ { INPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "h_gr_14", HW_H_GR, CGEN_MODE_SI, 0, 14, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_jmp_ops[] = {
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ld_ops[] = {
+ { INPUT, "h_memory_sr", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_USI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ld_d_ops[] = {
+ { INPUT, "h_memory_add__VM_sr_slo16", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ldb_ops[] = {
+ { INPUT, "h_memory_sr", HW_H_MEMORY, CGEN_MODE_QI, 0, 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_USI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ldb_d_ops[] = {
+ { INPUT, "h_memory_add__VM_sr_slo16", HW_H_MEMORY, CGEN_MODE_QI, 0, 0, 0 },
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ldh_ops[] = {
+ { INPUT, "h_memory_sr", HW_H_MEMORY, CGEN_MODE_HI, 0, 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_USI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ldh_d_ops[] = {
+ { INPUT, "h_memory_add__VM_sr_slo16", HW_H_MEMORY, CGEN_MODE_HI, 0, 0, 0 },
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ld_plus_ops[] = {
+ { INPUT, "h_memory_sr", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_USI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { OUTPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ld24_ops[] = {
+ { INPUT, "uimm24", HW_H_ADDR, CGEN_MODE_USI, OP_ENT (UIMM24), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ldi8_ops[] = {
+ { INPUT, "simm8", HW_H_SINT, CGEN_MODE_INT, OP_ENT (SIMM8), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_ldi16_ops[] = {
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_lock_ops[] = {
+ { INPUT, "h_memory_sr", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_USI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { OUTPUT, "h_lock", HW_H_LOCK, CGEN_MODE_BI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_machi_ops[] = {
+ { INPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_mulhi_ops[] = {
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_mv_ops[] = {
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_mvfachi_ops[] = {
+ { INPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_mvfc_ops[] = {
+ { INPUT, "scr", HW_H_CR, CGEN_MODE_USI, OP_ENT (SCR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_mvtachi_ops[] = {
+ { INPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { OUTPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_mvtc_ops[] = {
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dcr", HW_H_CR, CGEN_MODE_USI, OP_ENT (DCR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_nop_ops[] = {
+ { END }
+};
+
+static const CGEN_OPINST fmt_rac_ops[] = {
+ { INPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { OUTPUT, "accum", HW_H_ACCUM, CGEN_MODE_DI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_rte_ops[] = {
+ { INPUT, "h_bbpsw", HW_H_BBPSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { INPUT, "h_bpsw", HW_H_BPSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { INPUT, "h_cr_14", HW_H_CR, CGEN_MODE_USI, 0, 14, 0 },
+ { INPUT, "h_cr_6", HW_H_CR, CGEN_MODE_USI, 0, 6, 0 },
+ { OUTPUT, "h_bpsw", HW_H_BPSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { OUTPUT, "h_cr_6", HW_H_CR, CGEN_MODE_USI, 0, 6, 0 },
+ { OUTPUT, "h_psw", HW_H_PSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_seth_ops[] = {
+ { INPUT, "hi16", HW_H_HI16, CGEN_MODE_SI, OP_ENT (HI16), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_sll3_ops[] = {
+ { INPUT, "simm16", HW_H_SINT, CGEN_MODE_SI, OP_ENT (SIMM16), 0, 0 },
+ { INPUT, "sr", HW_H_GR, CGEN_MODE_SI, OP_ENT (SR), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_slli_ops[] = {
+ { INPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { INPUT, "uimm5", HW_H_UINT, CGEN_MODE_INT, OP_ENT (UIMM5), 0, 0 },
+ { OUTPUT, "dr", HW_H_GR, CGEN_MODE_SI, OP_ENT (DR), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_st_ops[] = {
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_USI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_src2", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_st_d_ops[] = {
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_add__VM_src2_slo16", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_stb_ops[] = {
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_QI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_USI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_src2", HW_H_MEMORY, CGEN_MODE_QI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_stb_d_ops[] = {
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_QI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_add__VM_src2_slo16", HW_H_MEMORY, CGEN_MODE_QI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_sth_ops[] = {
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_HI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_USI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_src2", HW_H_MEMORY, CGEN_MODE_HI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_sth_d_ops[] = {
+ { INPUT, "slo16", HW_H_SLO16, CGEN_MODE_INT, OP_ENT (SLO16), 0, 0 },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_HI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_add__VM_src2_slo16", HW_H_MEMORY, CGEN_MODE_HI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_st_plus_ops[] = {
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, 0 },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { OUTPUT, "h_memory_new_src2", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 },
+ { OUTPUT, "src2", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC2), 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_trap_ops[] = {
+ { INPUT, "h_bpsw", HW_H_BPSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { INPUT, "h_cr_6", HW_H_CR, CGEN_MODE_USI, 0, 6, 0 },
+ { INPUT, "h_psw", HW_H_PSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { INPUT, "pc", HW_H_PC, CGEN_MODE_USI, 0, 0, 0 },
+ { INPUT, "uimm4", HW_H_UINT, CGEN_MODE_UINT, OP_ENT (UIMM4), 0, 0 },
+ { OUTPUT, "h_bbpsw", HW_H_BBPSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { OUTPUT, "h_bpsw", HW_H_BPSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { OUTPUT, "h_cr_14", HW_H_CR, CGEN_MODE_USI, 0, 14, 0 },
+ { OUTPUT, "h_cr_6", HW_H_CR, CGEN_MODE_USI, 0, 6, 0 },
+ { OUTPUT, "h_psw", HW_H_PSW, CGEN_MODE_UQI, 0, 0, 0 },
+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_SI, 0, 0, 0 },
+ { END }
+};
+
+static const CGEN_OPINST fmt_unlock_ops[] = {
+ { INPUT, "h_lock", HW_H_LOCK, CGEN_MODE_BI, 0, 0, 0 },
+ { INPUT, "src1", HW_H_GR, CGEN_MODE_SI, OP_ENT (SRC1), 0, COND_REF },
+ { INPUT, "src2", HW_H_GR, CGEN_MODE_USI, OP_ENT (SRC2), 0, COND_REF },
+ { OUTPUT, "h_lock", HW_H_LOCK, CGEN_MODE_BI, 0, 0, 0 },
+ { OUTPUT, "h_memory_src2", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, COND_REF },
+ { END }
+};
+
+#undef INPUT
+#undef OUTPUT
+#undef END
+#undef COND_REF
+#undef OP_ENT
+
+/* Operand instance lookup table. */
+
+static const CGEN_OPINST *m32r_cgen_opinst_table[MAX_INSNS] = {
+ 0,
+ & fmt_add_ops[0],
+ & fmt_add3_ops[0],
+ & fmt_add_ops[0],
+ & fmt_and3_ops[0],
+ & fmt_add_ops[0],
+ & fmt_or3_ops[0],
+ & fmt_add_ops[0],
+ & fmt_and3_ops[0],
+ & fmt_addi_ops[0],
+ & fmt_addv_ops[0],
+ & fmt_addv3_ops[0],
+ & fmt_addx_ops[0],
+ & fmt_bc8_ops[0],
+ & fmt_bc24_ops[0],
+ & fmt_beq_ops[0],
+ & fmt_beqz_ops[0],
+ & fmt_beqz_ops[0],
+ & fmt_beqz_ops[0],
+ & fmt_beqz_ops[0],
+ & fmt_beqz_ops[0],
+ & fmt_beqz_ops[0],
+ & fmt_bl8_ops[0],
+ & fmt_bl24_ops[0],
+ & fmt_bc8_ops[0],
+ & fmt_bc24_ops[0],
+ & fmt_beq_ops[0],
+ & fmt_bra8_ops[0],
+ & fmt_bra24_ops[0],
+ & fmt_cmp_ops[0],
+ & fmt_cmpi_ops[0],
+ & fmt_cmp_ops[0],
+ & fmt_cmpi_ops[0],
+ & fmt_div_ops[0],
+ & fmt_div_ops[0],
+ & fmt_div_ops[0],
+ & fmt_div_ops[0],
+ & fmt_jl_ops[0],
+ & fmt_jmp_ops[0],
+ & fmt_ld_ops[0],
+ & fmt_ld_d_ops[0],
+ & fmt_ldb_ops[0],
+ & fmt_ldb_d_ops[0],
+ & fmt_ldh_ops[0],
+ & fmt_ldh_d_ops[0],
+ & fmt_ldb_ops[0],
+ & fmt_ldb_d_ops[0],
+ & fmt_ldh_ops[0],
+ & fmt_ldh_d_ops[0],
+ & fmt_ld_plus_ops[0],
+ & fmt_ld24_ops[0],
+ & fmt_ldi8_ops[0],
+ & fmt_ldi16_ops[0],
+ & fmt_lock_ops[0],
+ & fmt_machi_ops[0],
+ & fmt_machi_ops[0],
+ & fmt_machi_ops[0],
+ & fmt_machi_ops[0],
+ & fmt_add_ops[0],
+ & fmt_mulhi_ops[0],
+ & fmt_mulhi_ops[0],
+ & fmt_mulhi_ops[0],
+ & fmt_mulhi_ops[0],
+ & fmt_mv_ops[0],
+ & fmt_mvfachi_ops[0],
+ & fmt_mvfachi_ops[0],
+ & fmt_mvfachi_ops[0],
+ & fmt_mvfc_ops[0],
+ & fmt_mvtachi_ops[0],
+ & fmt_mvtachi_ops[0],
+ & fmt_mvtc_ops[0],
+ & fmt_mv_ops[0],
+ & fmt_nop_ops[0],
+ & fmt_mv_ops[0],
+ & fmt_rac_ops[0],
+ & fmt_rac_ops[0],
+ & fmt_rte_ops[0],
+ & fmt_seth_ops[0],
+ & fmt_add_ops[0],
+ & fmt_sll3_ops[0],
+ & fmt_slli_ops[0],
+ & fmt_add_ops[0],
+ & fmt_sll3_ops[0],
+ & fmt_slli_ops[0],
+ & fmt_add_ops[0],
+ & fmt_sll3_ops[0],
+ & fmt_slli_ops[0],
+ & fmt_st_ops[0],
+ & fmt_st_d_ops[0],
+ & fmt_stb_ops[0],
+ & fmt_stb_d_ops[0],
+ & fmt_sth_ops[0],
+ & fmt_sth_d_ops[0],
+ & fmt_st_plus_ops[0],
+ & fmt_st_plus_ops[0],
+ & fmt_add_ops[0],
+ & fmt_addv_ops[0],
+ & fmt_addx_ops[0],
+ & fmt_trap_ops[0],
+ & fmt_unlock_ops[0],
+};
+
+/* Function to call before using the operand instance table. */
+
+void
+m32r_cgen_init_opinst_table (cd)
+ CGEN_CPU_DESC cd;
+{
+ int i;
+ const CGEN_OPINST **oi = & m32r_cgen_opinst_table[0];
+ CGEN_INSN *insns = (CGEN_INSN *) cd->insn_table.init_entries;
+ for (i = 0; i < MAX_INSNS; ++i)
+ insns[i].opinst = oi[i];
+}
diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c
new file mode 100644
index 00000000000..a316c211a82
--- /dev/null
+++ b/opcodes/m68k-dis.c
@@ -0,0 +1,1243 @@
+/* Print Motorola 68k instructions.
+ Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "dis-asm.h"
+#include "floatformat.h"
+#include <libiberty.h>
+#include "opintl.h"
+
+#include "opcode/m68k.h"
+
+/* Local function prototypes */
+
+static int
+fetch_data PARAMS ((struct disassemble_info *, bfd_byte *));
+
+static void
+dummy_print_address PARAMS ((bfd_vma, struct disassemble_info *));
+
+static int
+fetch_arg PARAMS ((unsigned char *, int, int, disassemble_info *));
+
+static void
+print_base PARAMS ((int, bfd_vma, disassemble_info*));
+
+static unsigned char *
+print_indexed PARAMS ((int, unsigned char *, bfd_vma, disassemble_info *));
+
+static int
+print_insn_arg PARAMS ((const char *, unsigned char *, unsigned char *,
+ bfd_vma, disassemble_info *));
+
+CONST char * CONST fpcr_names[] = {
+ "", "%fpiar", "%fpsr", "%fpiar/%fpsr", "%fpcr",
+ "%fpiar/%fpcr", "%fpsr/%fpcr", "%fpiar/%fpsr/%fpcr"};
+
+static char *const reg_names[] = {
+ "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
+ "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp",
+ "%ps", "%pc"};
+
+/* Sign-extend an (unsigned char). */
+#if __STDC__ == 1
+#define COERCE_SIGNED_CHAR(ch) ((signed char)(ch))
+#else
+#define COERCE_SIGNED_CHAR(ch) ((int)(((ch) ^ 0x80) & 0xFF) - 128)
+#endif
+
+/* Get a 1 byte signed integer. */
+#define NEXTBYTE(p) (p += 2, FETCH_DATA (info, p), COERCE_SIGNED_CHAR(p[-1]))
+
+/* Get a 2 byte signed integer. */
+#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
+#define NEXTWORD(p) \
+ (p += 2, FETCH_DATA (info, p), \
+ COERCE16 ((p[-2] << 8) + p[-1]))
+
+/* Get a 4 byte signed integer. */
+#define COERCE32(x) ((bfd_signed_vma) ((x) ^ 0x80000000) - 0x80000000)
+#define NEXTLONG(p) \
+ (p += 4, FETCH_DATA (info, p), \
+ (COERCE32 ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1])))
+
+/* Get a 4 byte unsigned integer. */
+#define NEXTULONG(p) \
+ (p += 4, FETCH_DATA (info, p), \
+ (unsigned int) ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]))
+
+/* Get a single precision float. */
+#define NEXTSINGLE(val, p) \
+ (p += 4, FETCH_DATA (info, p), \
+ floatformat_to_double (&floatformat_ieee_single_big, (char *) p - 4, &val))
+
+/* Get a double precision float. */
+#define NEXTDOUBLE(val, p) \
+ (p += 8, FETCH_DATA (info, p), \
+ floatformat_to_double (&floatformat_ieee_double_big, (char *) p - 8, &val))
+
+/* Get an extended precision float. */
+#define NEXTEXTEND(val, p) \
+ (p += 12, FETCH_DATA (info, p), \
+ floatformat_to_double (&floatformat_m68881_ext, (char *) p - 12, &val))
+
+/* Need a function to convert from packed to double
+ precision. Actually, it's easier to print a
+ packed number than a double anyway, so maybe
+ there should be a special case to handle this... */
+#define NEXTPACKED(p) \
+ (p += 12, FETCH_DATA (info, p), 0.0)
+
+
+/* Maximum length of an instruction. */
+#define MAXLEN 22
+
+#include <setjmp.h>
+
+struct private
+{
+ /* Points to first byte not fetched. */
+ bfd_byte *max_fetched;
+ bfd_byte the_buffer[MAXLEN];
+ bfd_vma insn_start;
+ jmp_buf bailout;
+};
+
+/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
+ to ADDR (exclusive) are valid. Returns 1 for success, longjmps
+ on error. */
+#define FETCH_DATA(info, addr) \
+ ((addr) <= ((struct private *)(info->private_data))->max_fetched \
+ ? 1 : fetch_data ((info), (addr)))
+
+static int
+fetch_data (info, addr)
+ struct disassemble_info *info;
+ bfd_byte *addr;
+{
+ int status;
+ struct private *priv = (struct private *)info->private_data;
+ bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
+
+ status = (*info->read_memory_func) (start,
+ priv->max_fetched,
+ addr - priv->max_fetched,
+ info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, start, info);
+ longjmp (priv->bailout, 1);
+ }
+ else
+ priv->max_fetched = addr;
+ return 1;
+}
+
+/* This function is used to print to the bit-bucket. */
+static int
+#ifdef __STDC__
+dummy_printer (FILE * file, const char * format, ...)
+#else
+dummy_printer (file) FILE *file;
+#endif
+ { return 0; }
+
+static void
+dummy_print_address (vma, info)
+ bfd_vma vma;
+ struct disassemble_info *info;
+{
+}
+
+/* Print the m68k instruction at address MEMADDR in debugged memory,
+ on INFO->STREAM. Returns length of the instruction, in bytes. */
+
+int
+print_insn_m68k (memaddr, info)
+ bfd_vma memaddr;
+ disassemble_info *info;
+{
+ register int i;
+ register unsigned char *p;
+ unsigned char *save_p;
+ register const char *d;
+ register unsigned long bestmask;
+ const struct m68k_opcode *best = 0;
+ unsigned int arch_mask;
+ struct private priv;
+ bfd_byte *buffer = priv.the_buffer;
+ fprintf_ftype save_printer = info->fprintf_func;
+ void (*save_print_address) PARAMS((bfd_vma, struct disassemble_info*))
+ = info->print_address_func;
+ int major_opcode;
+ static int numopcodes[16];
+ static const struct m68k_opcode **opcodes[16];
+
+ if (!opcodes[0])
+ {
+ /* Speed up the matching by sorting the opcode table on the upper
+ four bits of the opcode. */
+ const struct m68k_opcode **opc_pointer[16];
+
+ /* First count how many opcodes are in each of the sixteen buckets. */
+ for (i = 0; i < m68k_numopcodes; i++)
+ numopcodes[(m68k_opcodes[i].opcode >> 28) & 15]++;
+
+ /* Then create a sorted table of pointers that point into the
+ unsorted table. */
+ opc_pointer[0] = ((const struct m68k_opcode **)
+ xmalloc (sizeof (struct m68k_opcode *)
+ * m68k_numopcodes));
+ opcodes[0] = opc_pointer[0];
+ for (i = 1; i < 16; i++)
+ {
+ opc_pointer[i] = opc_pointer[i - 1] + numopcodes[i - 1];
+ opcodes[i] = opc_pointer[i];
+ }
+
+ for (i = 0; i < m68k_numopcodes; i++)
+ *opc_pointer[(m68k_opcodes[i].opcode >> 28) & 15]++ = &m68k_opcodes[i];
+
+ }
+
+ info->private_data = (PTR) &priv;
+ /* Tell objdump to use two bytes per chunk and six bytes per line for
+ displaying raw data. */
+ info->bytes_per_chunk = 2;
+ info->bytes_per_line = 6;
+ info->display_endian = BFD_ENDIAN_BIG;
+ priv.max_fetched = priv.the_buffer;
+ priv.insn_start = memaddr;
+ if (setjmp (priv.bailout) != 0)
+ /* Error return. */
+ return -1;
+
+ switch (info->mach)
+ {
+ default:
+ case 0:
+ arch_mask = (unsigned int) -1;
+ break;
+ case bfd_mach_m68000:
+ arch_mask = m68000;
+ break;
+ case bfd_mach_m68008:
+ arch_mask = m68008;
+ break;
+ case bfd_mach_m68010:
+ arch_mask = m68010;
+ break;
+ case bfd_mach_m68020:
+ arch_mask = m68020;
+ break;
+ case bfd_mach_m68030:
+ arch_mask = m68030;
+ break;
+ case bfd_mach_m68040:
+ arch_mask = m68040;
+ break;
+ case bfd_mach_m68060:
+ arch_mask = m68060;
+ break;
+ }
+
+ arch_mask |= m68881 | m68851;
+
+ bestmask = 0;
+ FETCH_DATA (info, buffer + 2);
+ major_opcode = (buffer[0] >> 4) & 15;
+ for (i = 0; i < numopcodes[major_opcode]; i++)
+ {
+ const struct m68k_opcode *opc = opcodes[major_opcode][i];
+ unsigned long opcode = opc->opcode;
+ unsigned long match = opc->match;
+
+ if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
+ && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
+ /* Only fetch the next two bytes if we need to. */
+ && (((0xffff & match) == 0)
+ ||
+ (FETCH_DATA (info, buffer + 4)
+ && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
+ && ((0xff & buffer[3] & match) == (0xff & opcode)))
+ )
+ && (opc->arch & arch_mask) != 0)
+ {
+ /* Don't use for printout the variants of divul and divsl
+ that have the same register number in two places.
+ The more general variants will match instead. */
+ for (d = opc->args; *d; d += 2)
+ if (d[1] == 'D')
+ break;
+
+ /* Don't use for printout the variants of most floating
+ point coprocessor instructions which use the same
+ register number in two places, as above. */
+ if (*d == '\0')
+ for (d = opc->args; *d; d += 2)
+ if (d[1] == 't')
+ break;
+
+ /* Don't match fmovel with more than one register; wait for
+ fmoveml. */
+ if (*d == '\0')
+ {
+ for (d = opc->args; *d; d += 2)
+ {
+ if (d[0] == 's' && d[1] == '8')
+ {
+ int val;
+
+ val = fetch_arg (buffer, d[1], 3, info);
+ if ((val & (val - 1)) != 0)
+ break;
+ }
+ }
+ }
+
+ if (*d == '\0' && match > bestmask)
+ {
+ best = opc;
+ bestmask = match;
+ }
+ }
+ }
+
+ if (best == 0)
+ goto invalid;
+
+ /* Point at first word of argument data,
+ and at descriptor for first argument. */
+ p = buffer + 2;
+
+ /* Figure out how long the fixed-size portion of the instruction is.
+ The only place this is stored in the opcode table is
+ in the arguments--look for arguments which specify fields in the 2nd
+ or 3rd words of the instruction. */
+ for (d = best->args; *d; d += 2)
+ {
+ /* I don't think it is necessary to be checking d[0] here; I suspect
+ all this could be moved to the case statement below. */
+ if (d[0] == '#')
+ {
+ if (d[1] == 'l' && p - buffer < 6)
+ p = buffer + 6;
+ else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8' )
+ p = buffer + 4;
+ }
+ if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
+ p = buffer + 4;
+ switch (d[1])
+ {
+ case '1':
+ case '2':
+ case '3':
+ case '7':
+ case '8':
+ case '9':
+ case 'i':
+ if (p - buffer < 4)
+ p = buffer + 4;
+ break;
+ case '4':
+ case '5':
+ case '6':
+ if (p - buffer < 6)
+ p = buffer + 6;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* pflusha is an exceptions. It takes no arguments but is two words
+ long. Recognize it by looking at the lower 16 bits of the mask. */
+ if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
+ p = buffer + 4;
+
+ /* lpstop is another exception. It takes a one word argument but is
+ three words long. */
+ if (p - buffer < 6
+ && (best->match & 0xffff) == 0xffff
+ && best->args[0] == '#'
+ && best->args[1] == 'w')
+ {
+ /* Copy the one word argument into the usual location for a one
+ word argument, to simplify printing it. We can get away with
+ this because we know exactly what the second word is, and we
+ aren't going to print anything based on it. */
+ p = buffer + 6;
+ FETCH_DATA (info, p);
+ buffer[2] = buffer[4];
+ buffer[3] = buffer[5];
+ }
+
+ FETCH_DATA (info, p);
+
+ d = best->args;
+
+ /* We can the operands twice. The first time we don't print anything,
+ but look for errors. */
+
+ save_p = p;
+ info->print_address_func = dummy_print_address;
+ info->fprintf_func = (fprintf_ftype)dummy_printer;
+ for ( ; *d; d += 2)
+ {
+ int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
+ if (eaten >= 0)
+ p += eaten;
+ else if (eaten == -1)
+ goto invalid;
+ else
+ {
+ (*info->fprintf_func)(info->stream,
+ /* xgettext:c-format */
+ _("<internal error in opcode table: %s %s>\n"),
+ best->name,
+ best->args);
+ goto invalid;
+ }
+
+ }
+ p = save_p;
+ info->fprintf_func = save_printer;
+ info->print_address_func = save_print_address;
+
+ d = best->args;
+
+ (*info->fprintf_func) (info->stream, "%s", best->name);
+
+ if (*d)
+ (*info->fprintf_func) (info->stream, " ");
+
+ while (*d)
+ {
+ p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
+ d += 2;
+ if (*d && *(d - 2) != 'I' && *d != 'k')
+ (*info->fprintf_func) (info->stream, ",");
+ }
+ return p - buffer;
+
+ invalid:
+ /* Handle undefined instructions. */
+ info->fprintf_func = save_printer;
+ info->print_address_func = save_print_address;
+ (*info->fprintf_func) (info->stream, "0%o",
+ (buffer[0] << 8) + buffer[1]);
+ return 2;
+}
+
+/* Returns number of bytes "eaten" by the operand, or
+ return -1 if an invalid operand was found, or -2 if
+ an opcode tabe error was found. */
+
+static int
+print_insn_arg (d, buffer, p0, addr, info)
+ const char *d;
+ unsigned char *buffer;
+ unsigned char *p0;
+ bfd_vma addr; /* PC for this arg to be relative to */
+ disassemble_info *info;
+{
+ register int val = 0;
+ register int place = d[1];
+ register unsigned char *p = p0;
+ int regno;
+ register CONST char *regname;
+ register unsigned char *p1;
+ double flval;
+ int flt_p;
+ bfd_signed_vma disp;
+ unsigned int uval;
+
+ switch (*d)
+ {
+ case 'c': /* cache identifier */
+ {
+ static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
+ val = fetch_arg (buffer, place, 2, info);
+ (*info->fprintf_func) (info->stream, cacheFieldName[val]);
+ break;
+ }
+
+ case 'a': /* address register indirect only. Cf. case '+'. */
+ {
+ (*info->fprintf_func)
+ (info->stream,
+ "%s@",
+ reg_names [fetch_arg (buffer, place, 3, info) + 8]);
+ break;
+ }
+
+ case '_': /* 32-bit absolute address for move16. */
+ {
+ uval = NEXTULONG (p);
+ (*info->print_address_func) (uval, info);
+ break;
+ }
+
+ case 'C':
+ (*info->fprintf_func) (info->stream, "%%ccr");
+ break;
+
+ case 'S':
+ (*info->fprintf_func) (info->stream, "%%sr");
+ break;
+
+ case 'U':
+ (*info->fprintf_func) (info->stream, "%%usp");
+ break;
+
+ case 'J':
+ {
+ static const struct { char *name; int value; } names[]
+ = {{"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
+ {"%tc", 0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
+ {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
+ {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
+ {"%msp", 0x803}, {"%isp", 0x804},
+
+ /* Should we be calling this psr like we do in case 'Y'? */
+ {"%mmusr",0x805},
+
+ {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808}};
+
+ val = fetch_arg (buffer, place, 12, info);
+ for (regno = sizeof names / sizeof names[0] - 1; regno >= 0; regno--)
+ if (names[regno].value == val)
+ {
+ (*info->fprintf_func) (info->stream, "%s", names[regno].name);
+ break;
+ }
+ if (regno < 0)
+ (*info->fprintf_func) (info->stream, "%d", val);
+ }
+ break;
+
+ case 'Q':
+ val = fetch_arg (buffer, place, 3, info);
+ /* 0 means 8, except for the bkpt instruction... */
+ if (val == 0 && d[1] != 's')
+ val = 8;
+ (*info->fprintf_func) (info->stream, "#%d", val);
+ break;
+
+ case 'M':
+ val = fetch_arg (buffer, place, 8, info);
+ if (val & 0x80)
+ val = val - 0x100;
+ (*info->fprintf_func) (info->stream, "#%d", val);
+ break;
+
+ case 'T':
+ val = fetch_arg (buffer, place, 4, info);
+ (*info->fprintf_func) (info->stream, "#%d", val);
+ break;
+
+ case 'D':
+ (*info->fprintf_func) (info->stream, "%s",
+ reg_names[fetch_arg (buffer, place, 3, info)]);
+ break;
+
+ case 'A':
+ (*info->fprintf_func)
+ (info->stream, "%s",
+ reg_names[fetch_arg (buffer, place, 3, info) + 010]);
+ break;
+
+ case 'R':
+ (*info->fprintf_func)
+ (info->stream, "%s",
+ reg_names[fetch_arg (buffer, place, 4, info)]);
+ break;
+
+ case 'r':
+ regno = fetch_arg (buffer, place, 4, info);
+ if (regno > 7)
+ (*info->fprintf_func) (info->stream, "%s@", reg_names[regno]);
+ else
+ (*info->fprintf_func) (info->stream, "@(%s)", reg_names[regno]);
+ break;
+
+ case 'F':
+ (*info->fprintf_func)
+ (info->stream, "%%fp%d",
+ fetch_arg (buffer, place, 3, info));
+ break;
+
+ case 'O':
+ val = fetch_arg (buffer, place, 6, info);
+ if (val & 0x20)
+ (*info->fprintf_func) (info->stream, "%s", reg_names [val & 7]);
+ else
+ (*info->fprintf_func) (info->stream, "%d", val);
+ break;
+
+ case '+':
+ (*info->fprintf_func)
+ (info->stream, "%s@+",
+ reg_names[fetch_arg (buffer, place, 3, info) + 8]);
+ break;
+
+ case '-':
+ (*info->fprintf_func)
+ (info->stream, "%s@-",
+ reg_names[fetch_arg (buffer, place, 3, info) + 8]);
+ break;
+
+ case 'k':
+ if (place == 'k')
+ (*info->fprintf_func)
+ (info->stream, "{%s}",
+ reg_names[fetch_arg (buffer, place, 3, info)]);
+ else if (place == 'C')
+ {
+ val = fetch_arg (buffer, place, 7, info);
+ if ( val > 63 ) /* This is a signed constant. */
+ val -= 128;
+ (*info->fprintf_func) (info->stream, "{#%d}", val);
+ }
+ else
+ return -2;
+ break;
+
+ case '#':
+ case '^':
+ p1 = buffer + (*d == '#' ? 2 : 4);
+ if (place == 's')
+ val = fetch_arg (buffer, place, 4, info);
+ else if (place == 'C')
+ val = fetch_arg (buffer, place, 7, info);
+ else if (place == '8')
+ val = fetch_arg (buffer, place, 3, info);
+ else if (place == '3')
+ val = fetch_arg (buffer, place, 8, info);
+ else if (place == 'b')
+ val = NEXTBYTE (p1);
+ else if (place == 'w' || place == 'W')
+ val = NEXTWORD (p1);
+ else if (place == 'l')
+ val = NEXTLONG (p1);
+ else
+ return -2;
+ (*info->fprintf_func) (info->stream, "#%d", val);
+ break;
+
+ case 'B':
+ if (place == 'b')
+ disp = NEXTBYTE (p);
+ else if (place == 'B')
+ disp = COERCE_SIGNED_CHAR(buffer[1]);
+ else if (place == 'w' || place == 'W')
+ disp = NEXTWORD (p);
+ else if (place == 'l' || place == 'L' || place == 'C')
+ disp = NEXTLONG (p);
+ else if (place == 'g')
+ {
+ disp = NEXTBYTE (buffer);
+ if (disp == 0)
+ disp = NEXTWORD (p);
+ else if (disp == -1)
+ disp = NEXTLONG (p);
+ }
+ else if (place == 'c')
+ {
+ if (buffer[1] & 0x40) /* If bit six is one, long offset */
+ disp = NEXTLONG (p);
+ else
+ disp = NEXTWORD (p);
+ }
+ else
+ return -2;
+
+ (*info->print_address_func) (addr + disp, info);
+ break;
+
+ case 'd':
+ val = NEXTWORD (p);
+ (*info->fprintf_func)
+ (info->stream, "%s@(%d)",
+ reg_names[fetch_arg (buffer, place, 3, info) + 8], val);
+ break;
+
+ case 's':
+ (*info->fprintf_func) (info->stream, "%s",
+ fpcr_names[fetch_arg (buffer, place, 3, info)]);
+ break;
+
+ case 'I':
+ /* Get coprocessor ID... */
+ val = fetch_arg (buffer, 'd', 3, info);
+
+ if (val != 1) /* Unusual coprocessor ID? */
+ (*info->fprintf_func) (info->stream, "(cpid=%d) ", val);
+ break;
+
+ case '*':
+ case '~':
+ case '%':
+ case ';':
+ case '@':
+ case '!':
+ case '$':
+ case '?':
+ case '/':
+ case '&':
+ case '|':
+ case '<':
+ case '>':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'v':
+
+ if (place == 'd')
+ {
+ val = fetch_arg (buffer, 'x', 6, info);
+ val = ((val & 7) << 3) + ((val >> 3) & 7);
+ }
+ else
+ val = fetch_arg (buffer, 's', 6, info);
+
+ /* Get register number assuming address register. */
+ regno = (val & 7) + 8;
+ regname = reg_names[regno];
+ switch (val >> 3)
+ {
+ case 0:
+ (*info->fprintf_func) (info->stream, "%s", reg_names[val]);
+ break;
+
+ case 1:
+ (*info->fprintf_func) (info->stream, "%s", regname);
+ break;
+
+ case 2:
+ (*info->fprintf_func) (info->stream, "%s@", regname);
+ break;
+
+ case 3:
+ (*info->fprintf_func) (info->stream, "%s@+", regname);
+ break;
+
+ case 4:
+ (*info->fprintf_func) (info->stream, "%s@-", regname);
+ break;
+
+ case 5:
+ val = NEXTWORD (p);
+ (*info->fprintf_func) (info->stream, "%s@(%d)", regname, val);
+ break;
+
+ case 6:
+ p = print_indexed (regno, p, addr, info);
+ break;
+
+ case 7:
+ switch (val & 7)
+ {
+ case 0:
+ val = NEXTWORD (p);
+ (*info->print_address_func) (val, info);
+ break;
+
+ case 1:
+ uval = NEXTULONG (p);
+ (*info->print_address_func) (uval, info);
+ break;
+
+ case 2:
+ val = NEXTWORD (p);
+ (*info->fprintf_func) (info->stream, "%%pc@(");
+ (*info->print_address_func) (addr + val, info);
+ (*info->fprintf_func) (info->stream, ")");
+ break;
+
+ case 3:
+ p = print_indexed (-1, p, addr, info);
+ break;
+
+ case 4:
+ flt_p = 1; /* Assume it's a float... */
+ switch( place )
+ {
+ case 'b':
+ val = NEXTBYTE (p);
+ flt_p = 0;
+ break;
+
+ case 'w':
+ val = NEXTWORD (p);
+ flt_p = 0;
+ break;
+
+ case 'l':
+ val = NEXTLONG (p);
+ flt_p = 0;
+ break;
+
+ case 'f':
+ NEXTSINGLE(flval, p);
+ break;
+
+ case 'F':
+ NEXTDOUBLE(flval, p);
+ break;
+
+ case 'x':
+ NEXTEXTEND(flval, p);
+ break;
+
+ case 'p':
+ flval = NEXTPACKED(p);
+ break;
+
+ default:
+ return -1;
+ }
+ if ( flt_p ) /* Print a float? */
+ (*info->fprintf_func) (info->stream, "#%g", flval);
+ else
+ (*info->fprintf_func) (info->stream, "#%d", val);
+ break;
+
+ default:
+ return -1;
+ }
+ }
+ break;
+
+ case 'L':
+ case 'l':
+ if (place == 'w')
+ {
+ char doneany;
+ p1 = buffer + 2;
+ val = NEXTWORD (p1);
+ /* Move the pointer ahead if this point is farther ahead
+ than the last. */
+ p = p1 > p ? p1 : p;
+ if (val == 0)
+ {
+ (*info->fprintf_func) (info->stream, "#0");
+ break;
+ }
+ if (*d == 'l')
+ {
+ register int newval = 0;
+ for (regno = 0; regno < 16; ++regno)
+ if (val & (0x8000 >> regno))
+ newval |= 1 << regno;
+ val = newval;
+ }
+ val &= 0xffff;
+ doneany = 0;
+ for (regno = 0; regno < 16; ++regno)
+ if (val & (1 << regno))
+ {
+ int first_regno;
+ if (doneany)
+ (*info->fprintf_func) (info->stream, "/");
+ doneany = 1;
+ (*info->fprintf_func) (info->stream, "%s", reg_names[regno]);
+ first_regno = regno;
+ while (val & (1 << (regno + 1)))
+ ++regno;
+ if (regno > first_regno)
+ (*info->fprintf_func) (info->stream, "-%s",
+ reg_names[regno]);
+ }
+ }
+ else if (place == '3')
+ {
+ /* `fmovem' insn. */
+ char doneany;
+ val = fetch_arg (buffer, place, 8, info);
+ if (val == 0)
+ {
+ (*info->fprintf_func) (info->stream, "#0");
+ break;
+ }
+ if (*d == 'l')
+ {
+ register int newval = 0;
+ for (regno = 0; regno < 8; ++regno)
+ if (val & (0x80 >> regno))
+ newval |= 1 << regno;
+ val = newval;
+ }
+ val &= 0xff;
+ doneany = 0;
+ for (regno = 0; regno < 8; ++regno)
+ if (val & (1 << regno))
+ {
+ int first_regno;
+ if (doneany)
+ (*info->fprintf_func) (info->stream, "/");
+ doneany = 1;
+ (*info->fprintf_func) (info->stream, "%%fp%d", regno);
+ first_regno = regno;
+ while (val & (1 << (regno + 1)))
+ ++regno;
+ if (regno > first_regno)
+ (*info->fprintf_func) (info->stream, "-%%fp%d", regno);
+ }
+ }
+ else if (place == '8')
+ {
+ /* fmoveml for FP status registers */
+ (*info->fprintf_func) (info->stream, "%s",
+ fpcr_names[fetch_arg (buffer, place, 3,
+ info)]);
+ }
+ else
+ return -2;
+ break;
+
+ case 'X':
+ place = '8';
+ case 'Y':
+ case 'Z':
+ case 'W':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ {
+ int val = fetch_arg (buffer, place, 5, info);
+ char *name = 0;
+ switch (val)
+ {
+ case 2: name = "%tt0"; break;
+ case 3: name = "%tt1"; break;
+ case 0x10: name = "%tc"; break;
+ case 0x11: name = "%drp"; break;
+ case 0x12: name = "%srp"; break;
+ case 0x13: name = "%crp"; break;
+ case 0x14: name = "%cal"; break;
+ case 0x15: name = "%val"; break;
+ case 0x16: name = "%scc"; break;
+ case 0x17: name = "%ac"; break;
+ case 0x18: name = "%psr"; break;
+ case 0x19: name = "%pcsr"; break;
+ case 0x1c:
+ case 0x1d:
+ {
+ int break_reg = ((buffer[3] >> 2) & 7);
+ (*info->fprintf_func)
+ (info->stream, val == 0x1c ? "%%bad%d" : "%%bac%d",
+ break_reg);
+ }
+ break;
+ default:
+ (*info->fprintf_func) (info->stream, "<mmu register %d>", val);
+ }
+ if (name)
+ (*info->fprintf_func) (info->stream, "%s", name);
+ }
+ break;
+
+ case 'f':
+ {
+ int fc = fetch_arg (buffer, place, 5, info);
+ if (fc == 1)
+ (*info->fprintf_func) (info->stream, "%%dfc");
+ else if (fc == 0)
+ (*info->fprintf_func) (info->stream, "%%sfc");
+ else
+ /* xgettext:c-format */
+ (*info->fprintf_func) (info->stream, _("<function code %d>"), fc);
+ }
+ break;
+
+ case 'V':
+ (*info->fprintf_func) (info->stream, "%%val");
+ break;
+
+ case 't':
+ {
+ int level = fetch_arg (buffer, place, 3, info);
+ (*info->fprintf_func) (info->stream, "%d", level);
+ }
+ break;
+
+ default:
+ return -2;
+ }
+
+ return p - p0;
+}
+
+/* Fetch BITS bits from a position in the instruction specified by CODE.
+ CODE is a "place to put an argument", or 'x' for a destination
+ that is a general address (mode and register).
+ BUFFER contains the instruction. */
+
+static int
+fetch_arg (buffer, code, bits, info)
+ unsigned char *buffer;
+ int code;
+ int bits;
+ disassemble_info *info;
+{
+ register int val = 0;
+ switch (code)
+ {
+ case 's':
+ val = buffer[1];
+ break;
+
+ case 'd': /* Destination, for register or quick. */
+ val = (buffer[0] << 8) + buffer[1];
+ val >>= 9;
+ break;
+
+ case 'x': /* Destination, for general arg */
+ val = (buffer[0] << 8) + buffer[1];
+ val >>= 6;
+ break;
+
+ case 'k':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[3] >> 4);
+ break;
+
+ case 'C':
+ FETCH_DATA (info, buffer + 3);
+ val = buffer[3];
+ break;
+
+ case '1':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[2] << 8) + buffer[3];
+ val >>= 12;
+ break;
+
+ case '2':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[2] << 8) + buffer[3];
+ val >>= 6;
+ break;
+
+ case '3':
+ case 'j':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[2] << 8) + buffer[3];
+ break;
+
+ case '4':
+ FETCH_DATA (info, buffer + 5);
+ val = (buffer[4] << 8) + buffer[5];
+ val >>= 12;
+ break;
+
+ case '5':
+ FETCH_DATA (info, buffer + 5);
+ val = (buffer[4] << 8) + buffer[5];
+ val >>= 6;
+ break;
+
+ case '6':
+ FETCH_DATA (info, buffer + 5);
+ val = (buffer[4] << 8) + buffer[5];
+ break;
+
+ case '7':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[2] << 8) + buffer[3];
+ val >>= 7;
+ break;
+
+ case '8':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[2] << 8) + buffer[3];
+ val >>= 10;
+ break;
+
+ case '9':
+ FETCH_DATA (info, buffer + 3);
+ val = (buffer[2] << 8) + buffer[3];
+ val >>= 5;
+ break;
+
+ case 'e':
+ val = (buffer[1] >> 6);
+ break;
+
+ default:
+ abort ();
+ }
+
+ switch (bits)
+ {
+ case 2:
+ return val & 3;
+ case 3:
+ return val & 7;
+ case 4:
+ return val & 017;
+ case 5:
+ return val & 037;
+ case 6:
+ return val & 077;
+ case 7:
+ return val & 0177;
+ case 8:
+ return val & 0377;
+ case 12:
+ return val & 07777;
+ default:
+ abort ();
+ }
+}
+
+/* Print an indexed argument. The base register is BASEREG (-1 for pc).
+ P points to extension word, in buffer.
+ ADDR is the nominal core address of that extension word. */
+
+static unsigned char *
+print_indexed (basereg, p, addr, info)
+ int basereg;
+ unsigned char *p;
+ bfd_vma addr;
+ disassemble_info *info;
+{
+ register int word;
+ static char *const scales[] = {"", ":2", ":4", ":8"};
+ bfd_vma base_disp;
+ bfd_vma outer_disp;
+ char buf[40];
+ char vmabuf[50];
+
+ word = NEXTWORD (p);
+
+ /* Generate the text for the index register.
+ Where this will be output is not yet determined. */
+ sprintf (buf, "%s:%c%s",
+ reg_names[(word >> 12) & 0xf],
+ (word & 0x800) ? 'l' : 'w',
+ scales[(word >> 9) & 3]);
+
+ /* Handle the 68000 style of indexing. */
+
+ if ((word & 0x100) == 0)
+ {
+ base_disp = word & 0xff;
+ if ((base_disp & 0x80) != 0)
+ base_disp -= 0x100;
+ if (basereg == -1)
+ base_disp += addr;
+ print_base (basereg, base_disp, info);
+ (*info->fprintf_func) (info->stream, ",%s)", buf);
+ return p;
+ }
+
+ /* Handle the generalized kind. */
+ /* First, compute the displacement to add to the base register. */
+
+ if (word & 0200)
+ {
+ if (basereg == -1)
+ basereg = -3;
+ else
+ basereg = -2;
+ }
+ if (word & 0100)
+ buf[0] = '\0';
+ base_disp = 0;
+ switch ((word >> 4) & 3)
+ {
+ case 2:
+ base_disp = NEXTWORD (p);
+ break;
+ case 3:
+ base_disp = NEXTLONG (p);
+ }
+ if (basereg == -1)
+ base_disp += addr;
+
+ /* Handle single-level case (not indirect) */
+
+ if ((word & 7) == 0)
+ {
+ print_base (basereg, base_disp, info);
+ if (buf[0] != '\0')
+ (*info->fprintf_func) (info->stream, ",%s", buf);
+ (*info->fprintf_func) (info->stream, ")");
+ return p;
+ }
+
+ /* Two level. Compute displacement to add after indirection. */
+
+ outer_disp = 0;
+ switch (word & 3)
+ {
+ case 2:
+ outer_disp = NEXTWORD (p);
+ break;
+ case 3:
+ outer_disp = NEXTLONG (p);
+ }
+
+ print_base (basereg, base_disp, info);
+ if ((word & 4) == 0 && buf[0] != '\0')
+ {
+ (*info->fprintf_func) (info->stream, ",%s", buf);
+ buf[0] = '\0';
+ }
+ sprintf_vma (vmabuf, outer_disp);
+ (*info->fprintf_func) (info->stream, ")@(%s", vmabuf);
+ if (buf[0] != '\0')
+ (*info->fprintf_func) (info->stream, ",%s", buf);
+ (*info->fprintf_func) (info->stream, ")");
+
+ return p;
+}
+
+/* Print a base register REGNO and displacement DISP, on INFO->STREAM.
+ REGNO = -1 for pc, -2 for none (suppressed). */
+
+static void
+print_base (regno, disp, info)
+ int regno;
+ bfd_vma disp;
+ disassemble_info *info;
+{
+ if (regno == -1)
+ {
+ (*info->fprintf_func) (info->stream, "%%pc@(");
+ (*info->print_address_func) (disp, info);
+ }
+ else
+ {
+ char buf[50];
+
+ if (regno == -2)
+ (*info->fprintf_func) (info->stream, "@(");
+ else if (regno == -3)
+ (*info->fprintf_func) (info->stream, "%%zpc@(");
+ else
+ (*info->fprintf_func) (info->stream, "%s@(", reg_names[regno]);
+
+ sprintf_vma (buf, disp);
+ (*info->fprintf_func) (info->stream, "%s", buf);
+ }
+}
diff --git a/opcodes/m68k-opc.c b/opcodes/m68k-opc.c
new file mode 100644
index 00000000000..15e1b8dd626
--- /dev/null
+++ b/opcodes/m68k-opc.c
@@ -0,0 +1,2090 @@
+/* Opcode table for m680[012346]0/m6888[12]/m68851/mcf5200.
+ Copyright 1989, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation.
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "opcode/m68k.h"
+
+#define one(x) ((unsigned int) (x) << 16)
+#define two(x, y) (((unsigned int) (x) << 16) + (y))
+
+/* The assembler requires that all instances of the same mnemonic must
+ be consecutive. If they aren't, the assembler will bomb at
+ runtime. */
+
+const struct m68k_opcode m68k_opcodes[] =
+{
+{"abcd", one(0140400), one(0170770), "DsDd", m68000up },
+{"abcd", one(0140410), one(0170770), "-s-d", m68000up },
+
+{"addaw", one(0150300), one(0170700), "*wAd", m68000up },
+{"addal", one(0150700), one(0170700), "*lAd", m68000up | mcf5200 },
+
+{"addib", one(0003000), one(0177700), "#b$s", m68000up },
+{"addiw", one(0003100), one(0177700), "#w$s", m68000up },
+{"addil", one(0003200), one(0177700), "#l$s", m68000up },
+{"addil", one(0003200), one(0177700), "#lDs", mcf5200 },
+
+{"addqb", one(0050000), one(0170700), "Qd$b", m68000up },
+{"addqw", one(0050100), one(0170700), "Qd%w", m68000up },
+{"addql", one(0050200), one(0170700), "Qd%l", m68000up | mcf5200 },
+
+/* The add opcode can generate the adda, addi, and addq instructions. */
+{"addb", one(0050000), one(0170700), "Qd$b", m68000up },
+{"addb", one(0003000), one(0177700), "#b$s", m68000up },
+{"addb", one(0150000), one(0170700), ";bDd", m68000up },
+{"addb", one(0150400), one(0170700), "Dd~b", m68000up },
+{"addw", one(0050100), one(0170700), "Qd%w", m68000up },
+{"addw", one(0150300), one(0170700), "*wAd", m68000up },
+{"addw", one(0003100), one(0177700), "#w$s", m68000up },
+{"addw", one(0150100), one(0170700), "*wDd", m68000up },
+{"addw", one(0150500), one(0170700), "Dd~w", m68000up },
+{"addl", one(0050200), one(0170700), "Qd%l", m68000up | mcf5200 },
+{"addl", one(0003200), one(0177700), "#l$s", m68000up },
+{"addl", one(0003200), one(0177700), "#lDs", mcf5200 },
+{"addl", one(0150700), one(0170700), "*lAd", m68000up | mcf5200 },
+{"addl", one(0150200), one(0170700), "*lDd", m68000up | mcf5200 },
+{"addl", one(0150600), one(0170700), "Dd~l", m68000up | mcf5200 },
+
+{"addxb", one(0150400), one(0170770), "DsDd", m68000up },
+{"addxb", one(0150410), one(0170770), "-s-d", m68000up },
+{"addxw", one(0150500), one(0170770), "DsDd", m68000up },
+{"addxw", one(0150510), one(0170770), "-s-d", m68000up },
+{"addxl", one(0150600), one(0170770), "DsDd", m68000up | mcf5200 },
+{"addxl", one(0150610), one(0170770), "-s-d", m68000up },
+
+{"andib", one(0001000), one(0177700), "#b$s", m68000up },
+{"andib", one(0001074), one(0177777), "#bCs", m68000up },
+{"andiw", one(0001100), one(0177700), "#w$s", m68000up },
+{"andiw", one(0001174), one(0177777), "#wSs", m68000up },
+{"andil", one(0001200), one(0177700), "#l$s", m68000up },
+{"andil", one(0001200), one(0177700), "#lDs", mcf5200 },
+{"andi", one(0001100), one(0177700), "#w$s", m68000up },
+{"andi", one(0001074), one(0177777), "#bCs", m68000up },
+{"andi", one(0001174), one(0177777), "#wSs", m68000up },
+
+/* The and opcode can generate the andi instruction. */
+{"andb", one(0001000), one(0177700), "#b$s", m68000up },
+{"andb", one(0001074), one(0177777), "#bCs", m68000up },
+{"andb", one(0140000), one(0170700), ";bDd", m68000up },
+{"andb", one(0140400), one(0170700), "Dd~b", m68000up },
+{"andw", one(0001100), one(0177700), "#w$s", m68000up },
+{"andw", one(0001174), one(0177777), "#wSs", m68000up },
+{"andw", one(0140100), one(0170700), ";wDd", m68000up },
+{"andw", one(0140500), one(0170700), "Dd~w", m68000up },
+{"andl", one(0001200), one(0177700), "#l$s", m68000up },
+{"andl", one(0001200), one(0177700), "#lDs", mcf5200 },
+{"andl", one(0140200), one(0170700), ";lDd", m68000up | mcf5200 },
+{"andl", one(0140600), one(0170700), "Dd~l", m68000up | mcf5200 },
+{"and", one(0001100), one(0177700), "#w$w", m68000up },
+{"and", one(0001074), one(0177777), "#bCs", m68000up },
+{"and", one(0001174), one(0177777), "#wSs", m68000up },
+{"and", one(0140100), one(0170700), ";wDd", m68000up },
+{"and", one(0140500), one(0170700), "Dd~w", m68000up },
+
+{"aslb", one(0160400), one(0170770), "QdDs", m68000up },
+{"aslb", one(0160440), one(0170770), "DdDs", m68000up },
+{"aslw", one(0160500), one(0170770), "QdDs", m68000up },
+{"aslw", one(0160540), one(0170770), "DdDs", m68000up },
+{"aslw", one(0160700), one(0177700), "~s", m68000up },
+{"asll", one(0160600), one(0170770), "QdDs", m68000up | mcf5200 },
+{"asll", one(0160640), one(0170770), "DdDs", m68000up | mcf5200 },
+
+{"asrb", one(0160000), one(0170770), "QdDs", m68000up },
+{"asrb", one(0160040), one(0170770), "DdDs", m68000up },
+{"asrw", one(0160100), one(0170770), "QdDs", m68000up },
+{"asrw", one(0160140), one(0170770), "DdDs", m68000up },
+{"asrw", one(0160300), one(0177700), "~s", m68000up },
+{"asrl", one(0160200), one(0170770), "QdDs", m68000up | mcf5200 },
+{"asrl", one(0160240), one(0170770), "DdDs", m68000up | mcf5200 },
+
+{"bhiw", one(0061000), one(0177777), "BW", m68000up | mcf5200 },
+{"blsw", one(0061400), one(0177777), "BW", m68000up | mcf5200 },
+{"bccw", one(0062000), one(0177777), "BW", m68000up | mcf5200 },
+{"bcsw", one(0062400), one(0177777), "BW", m68000up | mcf5200 },
+{"bnew", one(0063000), one(0177777), "BW", m68000up | mcf5200 },
+{"beqw", one(0063400), one(0177777), "BW", m68000up | mcf5200 },
+{"bvcw", one(0064000), one(0177777), "BW", m68000up | mcf5200 },
+{"bvsw", one(0064400), one(0177777), "BW", m68000up | mcf5200 },
+{"bplw", one(0065000), one(0177777), "BW", m68000up | mcf5200 },
+{"bmiw", one(0065400), one(0177777), "BW", m68000up | mcf5200 },
+{"bgew", one(0066000), one(0177777), "BW", m68000up | mcf5200 },
+{"bltw", one(0066400), one(0177777), "BW", m68000up | mcf5200 },
+{"bgtw", one(0067000), one(0177777), "BW", m68000up | mcf5200 },
+{"blew", one(0067400), one(0177777), "BW", m68000up | mcf5200 },
+
+{"bhil", one(0061377), one(0177777), "BL", m68020up | cpu32 },
+{"blsl", one(0061777), one(0177777), "BL", m68020up | cpu32 },
+{"bccl", one(0062377), one(0177777), "BL", m68020up | cpu32 },
+{"bcsl", one(0062777), one(0177777), "BL", m68020up | cpu32 },
+{"bnel", one(0063377), one(0177777), "BL", m68020up | cpu32 },
+{"beql", one(0063777), one(0177777), "BL", m68020up | cpu32 },
+{"bvcl", one(0064377), one(0177777), "BL", m68020up | cpu32 },
+{"bvsl", one(0064777), one(0177777), "BL", m68020up | cpu32 },
+{"bpll", one(0065377), one(0177777), "BL", m68020up | cpu32 },
+{"bmil", one(0065777), one(0177777), "BL", m68020up | cpu32 },
+{"bgel", one(0066377), one(0177777), "BL", m68020up | cpu32 },
+{"bltl", one(0066777), one(0177777), "BL", m68020up | cpu32 },
+{"bgtl", one(0067377), one(0177777), "BL", m68020up | cpu32 },
+{"blel", one(0067777), one(0177777), "BL", m68020up | cpu32 },
+
+{"bhis", one(0061000), one(0177400), "BB", m68000up | mcf5200 },
+{"blss", one(0061400), one(0177400), "BB", m68000up | mcf5200 },
+{"bccs", one(0062000), one(0177400), "BB", m68000up | mcf5200 },
+{"bcss", one(0062400), one(0177400), "BB", m68000up | mcf5200 },
+{"bnes", one(0063000), one(0177400), "BB", m68000up | mcf5200 },
+{"beqs", one(0063400), one(0177400), "BB", m68000up | mcf5200 },
+{"bvcs", one(0064000), one(0177400), "BB", m68000up | mcf5200 },
+{"bvss", one(0064400), one(0177400), "BB", m68000up | mcf5200 },
+{"bpls", one(0065000), one(0177400), "BB", m68000up | mcf5200 },
+{"bmis", one(0065400), one(0177400), "BB", m68000up | mcf5200 },
+{"bges", one(0066000), one(0177400), "BB", m68000up | mcf5200 },
+{"blts", one(0066400), one(0177400), "BB", m68000up | mcf5200 },
+{"bgts", one(0067000), one(0177400), "BB", m68000up | mcf5200 },
+{"bles", one(0067400), one(0177400), "BB", m68000up | mcf5200 },
+
+{"jhi", one(0061000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jls", one(0061400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jcc", one(0062000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jcs", one(0062400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jne", one(0063000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jeq", one(0063400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jvc", one(0064000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jvs", one(0064400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jpl", one(0065000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jmi", one(0065400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jge", one(0066000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jlt", one(0066400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jgt", one(0067000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jle", one(0067400), one(0177400), "Bg", m68000up | mcf5200 },
+
+{"bchg", one(0000500), one(0170700), "Dd$s", m68000up | mcf5200 },
+{"bchg", one(0004100), one(0177700), "#b$s", m68000up },
+{"bchg", one(0004100), one(0177700), "#bqs", mcf5200 },
+
+{"bclr", one(0000600), one(0170700), "Dd$s", m68000up },
+{"bclr", one(0000600), one(0170700), "Ddvs", mcf5200 },
+{"bclr", one(0004200), one(0177700), "#b$s", m68000up },
+{"bclr", one(0004200), one(0177700), "#bqs", mcf5200 },
+
+{"bfchg", two(0165300, 0), two(0177700, 0170000), "?sO2O3", m68020up },
+{"bfclr", two(0166300, 0), two(0177700, 0170000), "?sO2O3", m68020up },
+{"bfexts", two(0165700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up },
+{"bfextu", two(0164700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up },
+{"bfffo", two(0166700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up },
+{"bfins", two(0167700, 0), two(0177700, 0100000), "D1?sO2O3", m68020up },
+{"bfset", two(0167300, 0), two(0177700, 0170000), "?sO2O3", m68020up },
+{"bftst", two(0164300, 0), two(0177700, 0170000), "/sO2O3", m68020up },
+
+{"bgnd", one(0045372), one(0177777), "", cpu32 },
+
+{"bkpt", one(0044110), one(0177770), "ts", m68010up },
+
+{"braw", one(0060000), one(0177777), "BW", m68000up | mcf5200 },
+{"bral", one(0060377), one(0177777), "BL", m68020up | cpu32 },
+{"bras", one(0060000), one(0177400), "BB", m68000up | mcf5200 },
+
+{"bset", one(0000700), one(0170700), "Dd$s", m68000up },
+{"bset", one(0000700), one(0170700), "Ddvs", mcf5200 },
+{"bset", one(0004300), one(0177700), "#b$s", m68000up },
+{"bset", one(0004300), one(0177700), "#bqs", mcf5200 },
+
+{"bsrw", one(0060400), one(0177777), "BW", m68000up | mcf5200 },
+{"bsrl", one(0060777), one(0177777), "BL", m68020up | cpu32 },
+{"bsrs", one(0060400), one(0177400), "BB", m68000up | mcf5200 },
+
+{"btst", one(0000400), one(0170700), "Dd;b", m68000up | mcf5200 },
+{"btst", one(0004000), one(0177700), "#b@s", m68000up },
+{"btst", one(0004000), one(0177700), "#bqs", mcf5200 },
+
+{"callm", one(0003300), one(0177700), "#b!s", m68020 },
+
+{"cas2w", two(0006374,0), two(0177777,0007070), "D3D6D2D5r1r4", m68020up },
+{"cas2w", two(0006374,0), two(0177777,0007070), "D3D6D2D5R1R4", m68020up },
+{"cas2l", two(0007374,0), two(0177777,0007070), "D3D6D2D5r1r4", m68020up },
+{"cas2l", two(0007374,0), two(0177777,0007070), "D3D6D2D5R1R4", m68020up },
+
+{"casb", two(0005300, 0), two(0177700, 0177070), "D3D2~s", m68020up },
+{"casw", two(0006300, 0), two(0177700, 0177070), "D3D2~s", m68020up },
+{"casl", two(0007300, 0), two(0177700, 0177070), "D3D2~s", m68020up },
+
+{"chk2b", two(0000300,0004000), two(0177700,07777), "!sR1", m68020up | cpu32 },
+{"chk2w", two(0001300,0004000), two(0177700,07777), "!sR1", m68020up | cpu32 },
+{"chk2l", two(0002300,0004000), two(0177700,07777), "!sR1", m68020up | cpu32 },
+
+{"chkl", one(0040400), one(0170700), ";lDd", m68000up },
+{"chkw", one(0040600), one(0170700), ";wDd", m68000up },
+
+#define SCOPE_LINE (0x1 << 3)
+#define SCOPE_PAGE (0x2 << 3)
+#define SCOPE_ALL (0x3 << 3)
+
+{"cinva", one(0xf400|SCOPE_ALL), one(0xff38), "ce", m68040up },
+{"cinvl", one(0xf400|SCOPE_LINE), one(0xff38), "ceas", m68040up },
+{"cinvp", one(0xf400|SCOPE_PAGE), one(0xff38), "ceas", m68040up },
+
+{"cpusha", one(0xf420|SCOPE_ALL), one(0xff38), "ce", m68040up },
+{"cpushl", one(0xf420|SCOPE_LINE), one(0xff38), "ceas", m68040up },
+{"cpushl", one(0x04e8), one(0xfff8), "as", mcf5200 },
+{"cpushp", one(0xf420|SCOPE_PAGE), one(0xff38), "ceas", m68040up },
+
+#undef SCOPE_LINE
+#undef SCOPE_PAGE
+#undef SCOPE_ALL
+
+{"clrb", one(0041000), one(0177700), "$s", m68000up | mcf5200 },
+{"clrw", one(0041100), one(0177700), "$s", m68000up | mcf5200 },
+{"clrl", one(0041200), one(0177700), "$s", m68000up | mcf5200 },
+
+{"cmp2b", two(0000300,0), two(0177700,07777), "!sR1", m68020up | cpu32 },
+{"cmp2w", two(0001300,0), two(0177700,07777), "!sR1", m68020up | cpu32 },
+{"cmp2l", two(0002300,0), two(0177700,07777), "!sR1", m68020up | cpu32 },
+
+{"cmpaw", one(0130300), one(0170700), "*wAd", m68000up },
+{"cmpal", one(0130700), one(0170700), "*lAd", m68000up | mcf5200 },
+
+{"cmpib", one(0006000), one(0177700), "#b@s", m68000up },
+{"cmpiw", one(0006100), one(0177700), "#w@s", m68000up },
+{"cmpil", one(0006200), one(0177700), "#l@s", m68000up },
+{"cmpil", one(0006200), one(0177700), "#lDs", mcf5200 },
+
+{"cmpmb", one(0130410), one(0170770), "+s+d", m68000up },
+{"cmpmw", one(0130510), one(0170770), "+s+d", m68000up },
+{"cmpml", one(0130610), one(0170770), "+s+d", m68000up },
+
+/* The cmp opcode can generate the cmpa, cmpm, and cmpi instructions. */
+{"cmpb", one(0006000), one(0177700), "#b@s", m68000up },
+{"cmpb", one(0130410), one(0170770), "+s+d", m68000up },
+{"cmpb", one(0130000), one(0170700), ";bDd", m68000up },
+{"cmpw", one(0130300), one(0170700), "*wAd", m68000up },
+{"cmpw", one(0006100), one(0177700), "#w@s", m68000up },
+{"cmpw", one(0130510), one(0170770), "+s+d", m68000up },
+{"cmpw", one(0130100), one(0170700), "*wDd", m68000up },
+{"cmpl", one(0130700), one(0170700), "*lAd", m68000up | mcf5200 },
+{"cmpl", one(0006200), one(0177700), "#l@s", m68000up },
+{"cmpl", one(0006200), one(0177700), "#lDs", mcf5200 },
+{"cmpl", one(0130610), one(0170770), "+s+d", m68000up },
+{"cmpl", one(0130200), one(0170700), "*lDd", m68000up | mcf5200 },
+
+{"dbcc", one(0052310), one(0177770), "DsBw", m68000up },
+{"dbcs", one(0052710), one(0177770), "DsBw", m68000up },
+{"dbeq", one(0053710), one(0177770), "DsBw", m68000up },
+{"dbf", one(0050710), one(0177770), "DsBw", m68000up },
+{"dbge", one(0056310), one(0177770), "DsBw", m68000up },
+{"dbgt", one(0057310), one(0177770), "DsBw", m68000up },
+{"dbhi", one(0051310), one(0177770), "DsBw", m68000up },
+{"dble", one(0057710), one(0177770), "DsBw", m68000up },
+{"dbls", one(0051710), one(0177770), "DsBw", m68000up },
+{"dblt", one(0056710), one(0177770), "DsBw", m68000up },
+{"dbmi", one(0055710), one(0177770), "DsBw", m68000up },
+{"dbne", one(0053310), one(0177770), "DsBw", m68000up },
+{"dbpl", one(0055310), one(0177770), "DsBw", m68000up },
+{"dbt", one(0050310), one(0177770), "DsBw", m68000up },
+{"dbvc", one(0054310), one(0177770), "DsBw", m68000up },
+{"dbvs", one(0054710), one(0177770), "DsBw", m68000up },
+
+{"divsw", one(0100700), one(0170700), ";wDd", m68000up },
+
+{"divsl", two(0046100,0006000),two(0177700,0107770),";lD3D1", m68020up|cpu32 },
+{"divsl", two(0046100,0004000),two(0177700,0107770),";lDD", m68020up|cpu32 },
+
+{"divsll", two(0046100,0004000),two(0177700,0107770),";lD3D1",m68020up|cpu32 },
+{"divsll", two(0046100,0004000),two(0177700,0107770),";lDD", m68020up|cpu32 },
+
+{"divuw", one(0100300), one(0170700), ";wDd", m68000up },
+
+{"divul", two(0046100,0002000),two(0177700,0107770),";lD3D1", m68020up|cpu32 },
+{"divul", two(0046100,0000000),two(0177700,0107770),";lDD", m68020up|cpu32 },
+
+{"divull", two(0046100,0000000),two(0177700,0107770),";lD3D1",m68020up|cpu32 },
+{"divull", two(0046100,0000000),two(0177700,0107770),";lDD", m68020up|cpu32 },
+
+{"eorib", one(0005000), one(0177700), "#b$s", m68000up },
+{"eorib", one(0005074), one(0177777), "#bCs", m68000up },
+{"eoriw", one(0005100), one(0177700), "#w$s", m68000up },
+{"eoriw", one(0005174), one(0177777), "#wSs", m68000up },
+{"eoril", one(0005200), one(0177700), "#l$s", m68000up },
+{"eoril", one(0005200), one(0177700), "#lDs", mcf5200 },
+{"eori", one(0005074), one(0177777), "#bCs", m68000up },
+{"eori", one(0005174), one(0177777), "#wSs", m68000up },
+{"eori", one(0005100), one(0177700), "#w$s", m68000up },
+
+/* The eor opcode can generate the eori instruction. */
+{"eorb", one(0005000), one(0177700), "#b$s", m68000up },
+{"eorb", one(0005074), one(0177777), "#bCs", m68000up },
+{"eorb", one(0130400), one(0170700), "Dd$s", m68000up },
+{"eorw", one(0005100), one(0177700), "#w$s", m68000up },
+{"eorw", one(0005174), one(0177777), "#wSs", m68000up },
+{"eorw", one(0130500), one(0170700), "Dd$s", m68000up },
+{"eorl", one(0005200), one(0177700), "#l$s", m68000up },
+{"eorl", one(0005200), one(0177700), "#lDs", mcf5200 },
+{"eorl", one(0130600), one(0170700), "Dd$s", m68000up | mcf5200 },
+{"eor", one(0005074), one(0177777), "#bCs", m68000up },
+{"eor", one(0005174), one(0177777), "#wSs", m68000up },
+{"eor", one(0005100), one(0177700), "#w$s", m68000up },
+{"eor", one(0130500), one(0170700), "Dd$s", m68000up },
+
+{"exg", one(0140500), one(0170770), "DdDs", m68000up },
+{"exg", one(0140510), one(0170770), "AdAs", m68000up },
+{"exg", one(0140610), one(0170770), "DdAs", m68000up },
+{"exg", one(0140610), one(0170770), "AsDd", m68000up },
+
+{"extw", one(0044200), one(0177770), "Ds", m68000up|mcf5200 },
+{"extl", one(0044300), one(0177770), "Ds", m68000up|mcf5200 },
+{"extbl", one(0044700), one(0177770), "Ds", m68020up|cpu32|mcf5200 },
+
+/* float stuff starts here */
+
+{"fabsb", two(0xF000, 0x5818), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fabsd", two(0xF000, 0x5418), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fabsl", two(0xF000, 0x4018), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fabsp", two(0xF000, 0x4C18), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fabss", two(0xF000, 0x4418), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fabsw", two(0xF000, 0x5018), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fabsx", two(0xF000, 0x4818), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fsabsb", two(0xF000, 0x5858), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fsabsd", two(0xF000, 0x5458), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fsabsl", two(0xF000, 0x4058), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fsabsp", two(0xF000, 0x4C58), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fsabss", two(0xF000, 0x4458), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fsabsw", two(0xF000, 0x5058), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fsabsx", two(0xF000, 0x0058), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fsabsx", two(0xF000, 0x4858), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fsabsx", two(0xF000, 0x0058), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"fdabsb", two(0xF000, 0x585c), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up},
+{"fdabsd", two(0xF000, 0x545c), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up},
+{"fdabsl", two(0xF000, 0x405c), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up},
+{"fdabsp", two(0xF000, 0x4C5c), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up},
+{"fdabss", two(0xF000, 0x445c), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up},
+{"fdabsw", two(0xF000, 0x505c), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up},
+{"fdabsx", two(0xF000, 0x005c), two(0xF1C0, 0xE07F), "IiF8F7", m68040up},
+{"fdabsx", two(0xF000, 0x485c), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up},
+{"fdabsx", two(0xF000, 0x005c), two(0xF1C0, 0xE07F), "IiFt", m68040up},
+
+{"facosb", two(0xF000, 0x581C), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"facosd", two(0xF000, 0x541C), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"facosl", two(0xF000, 0x401C), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"facosp", two(0xF000, 0x4C1C), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"facoss", two(0xF000, 0x441C), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"facosw", two(0xF000, 0x501C), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"facosx", two(0xF000, 0x481C), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"faddb", two(0xF000, 0x5822), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"faddd", two(0xF000, 0x5422), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"faddl", two(0xF000, 0x4022), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"faddp", two(0xF000, 0x4C22), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fadds", two(0xF000, 0x4422), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"faddw", two(0xF000, 0x5022), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"faddx", two(0xF000, 0x4822), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+{"fsaddb", two(0xF000, 0x5862), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fsaddd", two(0xF000, 0x5462), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fsaddl", two(0xF000, 0x4062), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fsaddp", two(0xF000, 0x4C62), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fsadds", two(0xF000, 0x4462), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fsaddw", two(0xF000, 0x5062), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fsaddx", two(0xF000, 0x0062), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fsaddx", two(0xF000, 0x4862), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+
+{"fdaddb", two(0xF000, 0x5866), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fdaddd", two(0xF000, 0x5466), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fdaddl", two(0xF000, 0x4066), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fdaddp", two(0xF000, 0x4C66), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fdadds", two(0xF000, 0x4466), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fdaddw", two(0xF000, 0x5066), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fdaddx", two(0xF000, 0x0066), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fdaddx", two(0xF000, 0x4866), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+
+{"fasinb", two(0xF000, 0x580C), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fasind", two(0xF000, 0x540C), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fasinl", two(0xF000, 0x400C), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fasinp", two(0xF000, 0x4C0C), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fasins", two(0xF000, 0x440C), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fasinw", two(0xF000, 0x500C), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fasinx", two(0xF000, 0x480C), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fatanb", two(0xF000, 0x580A), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fatand", two(0xF000, 0x540A), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fatanl", two(0xF000, 0x400A), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fatanp", two(0xF000, 0x4C0A), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fatans", two(0xF000, 0x440A), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fatanw", two(0xF000, 0x500A), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fatanx", two(0xF000, 0x480A), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fatanhb", two(0xF000, 0x580D), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fatanhd", two(0xF000, 0x540D), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fatanhl", two(0xF000, 0x400D), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fatanhp", two(0xF000, 0x4C0D), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fatanhs", two(0xF000, 0x440D), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fatanhw", two(0xF000, 0x500D), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fatanhx", two(0xF000, 0x480D), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fbeq", one(0xF081), one(0xF1FF), "IdBW", mfloat },
+{"fbf", one(0xF080), one(0xF1FF), "IdBW", mfloat },
+{"fbge", one(0xF093), one(0xF1FF), "IdBW", mfloat },
+{"fbgl", one(0xF096), one(0xF1FF), "IdBW", mfloat },
+{"fbgle", one(0xF097), one(0xF1FF), "IdBW", mfloat },
+{"fbgt", one(0xF092), one(0xF1FF), "IdBW", mfloat },
+{"fble", one(0xF095), one(0xF1FF), "IdBW", mfloat },
+{"fblt", one(0xF094), one(0xF1FF), "IdBW", mfloat },
+{"fbne", one(0xF08E), one(0xF1FF), "IdBW", mfloat },
+{"fbnge", one(0xF09C), one(0xF1FF), "IdBW", mfloat },
+{"fbngl", one(0xF099), one(0xF1FF), "IdBW", mfloat },
+{"fbngle", one(0xF098), one(0xF1FF), "IdBW", mfloat },
+{"fbngt", one(0xF09D), one(0xF1FF), "IdBW", mfloat },
+{"fbnle", one(0xF09A), one(0xF1FF), "IdBW", mfloat },
+{"fbnlt", one(0xF09B), one(0xF1FF), "IdBW", mfloat },
+{"fboge", one(0xF083), one(0xF1FF), "IdBW", mfloat },
+{"fbogl", one(0xF086), one(0xF1FF), "IdBW", mfloat },
+{"fbogt", one(0xF082), one(0xF1FF), "IdBW", mfloat },
+{"fbole", one(0xF085), one(0xF1FF), "IdBW", mfloat },
+{"fbolt", one(0xF084), one(0xF1FF), "IdBW", mfloat },
+{"fbor", one(0xF087), one(0xF1FF), "IdBW", mfloat },
+{"fbseq", one(0xF091), one(0xF1FF), "IdBW", mfloat },
+{"fbsf", one(0xF090), one(0xF1FF), "IdBW", mfloat },
+{"fbsne", one(0xF09E), one(0xF1FF), "IdBW", mfloat },
+{"fbst", one(0xF09F), one(0xF1FF), "IdBW", mfloat },
+{"fbt", one(0xF08F), one(0xF1FF), "IdBW", mfloat },
+{"fbueq", one(0xF089), one(0xF1FF), "IdBW", mfloat },
+{"fbuge", one(0xF08B), one(0xF1FF), "IdBW", mfloat },
+{"fbugt", one(0xF08A), one(0xF1FF), "IdBW", mfloat },
+{"fbule", one(0xF08D), one(0xF1FF), "IdBW", mfloat },
+{"fbult", one(0xF08C), one(0xF1FF), "IdBW", mfloat },
+{"fbun", one(0xF088), one(0xF1FF), "IdBW", mfloat },
+
+{"fbeql", one(0xF0C1), one(0xF1FF), "IdBC", mfloat },
+{"fbfl", one(0xF0C0), one(0xF1FF), "IdBC", mfloat },
+{"fbgel", one(0xF0D3), one(0xF1FF), "IdBC", mfloat },
+{"fbgll", one(0xF0D6), one(0xF1FF), "IdBC", mfloat },
+{"fbglel", one(0xF0D7), one(0xF1FF), "IdBC", mfloat },
+{"fbgtl", one(0xF0D2), one(0xF1FF), "IdBC", mfloat },
+{"fblel", one(0xF0D5), one(0xF1FF), "IdBC", mfloat },
+{"fbltl", one(0xF0D4), one(0xF1FF), "IdBC", mfloat },
+{"fbnel", one(0xF0CE), one(0xF1FF), "IdBC", mfloat },
+{"fbngel", one(0xF0DC), one(0xF1FF), "IdBC", mfloat },
+{"fbngll", one(0xF0D9), one(0xF1FF), "IdBC", mfloat },
+{"fbnglel", one(0xF0D8), one(0xF1FF), "IdBC", mfloat },
+{"fbngtl", one(0xF0DD), one(0xF1FF), "IdBC", mfloat },
+{"fbnlel", one(0xF0DA), one(0xF1FF), "IdBC", mfloat },
+{"fbnltl", one(0xF0DB), one(0xF1FF), "IdBC", mfloat },
+{"fbogel", one(0xF0C3), one(0xF1FF), "IdBC", mfloat },
+{"fbogll", one(0xF0C6), one(0xF1FF), "IdBC", mfloat },
+{"fbogtl", one(0xF0C2), one(0xF1FF), "IdBC", mfloat },
+{"fbolel", one(0xF0C5), one(0xF1FF), "IdBC", mfloat },
+{"fboltl", one(0xF0C4), one(0xF1FF), "IdBC", mfloat },
+{"fborl", one(0xF0C7), one(0xF1FF), "IdBC", mfloat },
+{"fbseql", one(0xF0D1), one(0xF1FF), "IdBC", mfloat },
+{"fbsfl", one(0xF0D0), one(0xF1FF), "IdBC", mfloat },
+{"fbsnel", one(0xF0DE), one(0xF1FF), "IdBC", mfloat },
+{"fbstl", one(0xF0DF), one(0xF1FF), "IdBC", mfloat },
+{"fbtl", one(0xF0CF), one(0xF1FF), "IdBC", mfloat },
+{"fbueql", one(0xF0C9), one(0xF1FF), "IdBC", mfloat },
+{"fbugel", one(0xF0CB), one(0xF1FF), "IdBC", mfloat },
+{"fbugtl", one(0xF0CA), one(0xF1FF), "IdBC", mfloat },
+{"fbulel", one(0xF0CD), one(0xF1FF), "IdBC", mfloat },
+{"fbultl", one(0xF0CC), one(0xF1FF), "IdBC", mfloat },
+{"fbunl", one(0xF0C8), one(0xF1FF), "IdBC", mfloat },
+
+{"fjeq", one(0xF081), one(0xF1BF), "IdBc", mfloat },
+{"fjf", one(0xF080), one(0xF1BF), "IdBc", mfloat },
+{"fjge", one(0xF093), one(0xF1BF), "IdBc", mfloat },
+{"fjgl", one(0xF096), one(0xF1BF), "IdBc", mfloat },
+{"fjgle", one(0xF097), one(0xF1BF), "IdBc", mfloat },
+{"fjgt", one(0xF092), one(0xF1BF), "IdBc", mfloat },
+{"fjle", one(0xF095), one(0xF1BF), "IdBc", mfloat },
+{"fjlt", one(0xF094), one(0xF1BF), "IdBc", mfloat },
+{"fjne", one(0xF08E), one(0xF1BF), "IdBc", mfloat },
+{"fjnge", one(0xF09C), one(0xF1BF), "IdBc", mfloat },
+{"fjngl", one(0xF099), one(0xF1BF), "IdBc", mfloat },
+{"fjngle", one(0xF098), one(0xF1BF), "IdBc", mfloat },
+{"fjngt", one(0xF09D), one(0xF1BF), "IdBc", mfloat },
+{"fjnle", one(0xF09A), one(0xF1BF), "IdBc", mfloat },
+{"fjnlt", one(0xF09B), one(0xF1BF), "IdBc", mfloat },
+{"fjoge", one(0xF083), one(0xF1BF), "IdBc", mfloat },
+{"fjogl", one(0xF086), one(0xF1BF), "IdBc", mfloat },
+{"fjogt", one(0xF082), one(0xF1BF), "IdBc", mfloat },
+{"fjole", one(0xF085), one(0xF1BF), "IdBc", mfloat },
+{"fjolt", one(0xF084), one(0xF1BF), "IdBc", mfloat },
+{"fjor", one(0xF087), one(0xF1BF), "IdBc", mfloat },
+{"fjseq", one(0xF091), one(0xF1BF), "IdBc", mfloat },
+{"fjsf", one(0xF090), one(0xF1BF), "IdBc", mfloat },
+{"fjsne", one(0xF09E), one(0xF1BF), "IdBc", mfloat },
+{"fjst", one(0xF09F), one(0xF1BF), "IdBc", mfloat },
+{"fjt", one(0xF08F), one(0xF1BF), "IdBc", mfloat },
+{"fjueq", one(0xF089), one(0xF1BF), "IdBc", mfloat },
+{"fjuge", one(0xF08B), one(0xF1BF), "IdBc", mfloat },
+{"fjugt", one(0xF08A), one(0xF1BF), "IdBc", mfloat },
+{"fjule", one(0xF08D), one(0xF1BF), "IdBc", mfloat },
+{"fjult", one(0xF08C), one(0xF1BF), "IdBc", mfloat },
+{"fjun", one(0xF088), one(0xF1BF), "IdBc", mfloat },
+
+{"fcmpb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fcmpd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fcmpl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fcmpp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fcmps", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fcmpw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fcmpx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+{"fcosb", two(0xF000, 0x581D), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fcosd", two(0xF000, 0x541D), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fcosl", two(0xF000, 0x401D), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fcosp", two(0xF000, 0x4C1D), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fcoss", two(0xF000, 0x441D), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fcosw", two(0xF000, 0x501D), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fcosx", two(0xF000, 0x481D), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fcoshb", two(0xF000, 0x5819), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fcoshd", two(0xF000, 0x5419), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fcoshl", two(0xF000, 0x4019), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fcoshp", two(0xF000, 0x4C19), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fcoshs", two(0xF000, 0x4419), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fcoshw", two(0xF000, 0x5019), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fcoshx", two(0xF000, 0x4819), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fdbeq", two(0xF048, 0x0001), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbf", two(0xF048, 0x0000), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbge", two(0xF048, 0x0013), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbgl", two(0xF048, 0x0016), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbgle", two(0xF048, 0x0017), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbgt", two(0xF048, 0x0012), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdble", two(0xF048, 0x0015), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdblt", two(0xF048, 0x0014), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbne", two(0xF048, 0x000E), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbnge", two(0xF048, 0x001C), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbngl", two(0xF048, 0x0019), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbngle", two(0xF048, 0x0018), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbngt", two(0xF048, 0x001D), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbnle", two(0xF048, 0x001A), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbnlt", two(0xF048, 0x001B), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdboge", two(0xF048, 0x0003), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbogl", two(0xF048, 0x0006), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbogt", two(0xF048, 0x0002), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbole", two(0xF048, 0x0005), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbolt", two(0xF048, 0x0004), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbor", two(0xF048, 0x0007), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbseq", two(0xF048, 0x0011), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbsf", two(0xF048, 0x0010), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbsne", two(0xF048, 0x001E), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbst", two(0xF048, 0x001F), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbt", two(0xF048, 0x000F), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbueq", two(0xF048, 0x0009), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbuge", two(0xF048, 0x000B), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbugt", two(0xF048, 0x000A), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbule", two(0xF048, 0x000D), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbult", two(0xF048, 0x000C), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+{"fdbun", two(0xF048, 0x0008), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
+
+{"fdivb", two(0xF000, 0x5820), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fdivd", two(0xF000, 0x5420), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fdivl", two(0xF000, 0x4020), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fdivp", two(0xF000, 0x4C20), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fdivs", two(0xF000, 0x4420), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fdivw", two(0xF000, 0x5020), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fdivx", two(0xF000, 0x4820), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+{"fsdivb", two(0xF000, 0x5860), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fsdivd", two(0xF000, 0x5460), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fsdivl", two(0xF000, 0x4060), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fsdivp", two(0xF000, 0x4C60), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fsdivs", two(0xF000, 0x4460), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fsdivw", two(0xF000, 0x5060), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fsdivx", two(0xF000, 0x0060), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fsdivx", two(0xF000, 0x4860), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+
+{"fddivb", two(0xF000, 0x5864), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fddivd", two(0xF000, 0x5464), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fddivl", two(0xF000, 0x4064), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fddivp", two(0xF000, 0x4C64), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fddivs", two(0xF000, 0x4464), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fddivw", two(0xF000, 0x5064), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fddivx", two(0xF000, 0x0064), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fddivx", two(0xF000, 0x4864), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+
+{"fetoxb", two(0xF000, 0x5810), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fetoxd", two(0xF000, 0x5410), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fetoxl", two(0xF000, 0x4010), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fetoxp", two(0xF000, 0x4C10), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fetoxs", two(0xF000, 0x4410), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fetoxw", two(0xF000, 0x5010), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fetoxx", two(0xF000, 0x4810), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fetoxm1b", two(0xF000, 0x5808), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fetoxm1d", two(0xF000, 0x5408), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fetoxm1l", two(0xF000, 0x4008), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fetoxm1p", two(0xF000, 0x4C08), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fetoxm1s", two(0xF000, 0x4408), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fetoxm1w", two(0xF000, 0x5008), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fetoxm1x", two(0xF000, 0x4808), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fgetexpb", two(0xF000, 0x581E), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fgetexpd", two(0xF000, 0x541E), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fgetexpl", two(0xF000, 0x401E), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fgetexpp", two(0xF000, 0x4C1E), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fgetexps", two(0xF000, 0x441E), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fgetexpw", two(0xF000, 0x501E), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fgetexpx", two(0xF000, 0x481E), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fgetmanb", two(0xF000, 0x581F), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fgetmand", two(0xF000, 0x541F), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fgetmanl", two(0xF000, 0x401F), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fgetmanp", two(0xF000, 0x4C1F), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fgetmans", two(0xF000, 0x441F), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fgetmanw", two(0xF000, 0x501F), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fgetmanx", two(0xF000, 0x481F), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fintb", two(0xF000, 0x5801), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fintd", two(0xF000, 0x5401), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fintl", two(0xF000, 0x4001), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fintp", two(0xF000, 0x4C01), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fints", two(0xF000, 0x4401), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fintw", two(0xF000, 0x5001), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fintx", two(0xF000, 0x4801), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fintrzb", two(0xF000, 0x5803), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fintrzd", two(0xF000, 0x5403), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fintrzl", two(0xF000, 0x4003), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fintrzp", two(0xF000, 0x4C03), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fintrzs", two(0xF000, 0x4403), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fintrzw", two(0xF000, 0x5003), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fintrzx", two(0xF000, 0x4803), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"flog10b", two(0xF000, 0x5815), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"flog10d", two(0xF000, 0x5415), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"flog10l", two(0xF000, 0x4015), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"flog10p", two(0xF000, 0x4C15), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"flog10s", two(0xF000, 0x4415), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"flog10w", two(0xF000, 0x5015), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"flog10x", two(0xF000, 0x4815), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"flog2b", two(0xF000, 0x5816), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"flog2d", two(0xF000, 0x5416), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"flog2l", two(0xF000, 0x4016), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"flog2p", two(0xF000, 0x4C16), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"flog2s", two(0xF000, 0x4416), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"flog2w", two(0xF000, 0x5016), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"flog2x", two(0xF000, 0x4816), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"flognb", two(0xF000, 0x5814), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"flognd", two(0xF000, 0x5414), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"flognl", two(0xF000, 0x4014), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"flognp", two(0xF000, 0x4C14), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"flogns", two(0xF000, 0x4414), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"flognw", two(0xF000, 0x5014), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"flognx", two(0xF000, 0x4814), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"flognp1b", two(0xF000, 0x5806), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"flognp1d", two(0xF000, 0x5406), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"flognp1l", two(0xF000, 0x4006), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"flognp1p", two(0xF000, 0x4C06), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"flognp1s", two(0xF000, 0x4406), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"flognp1w", two(0xF000, 0x5006), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"flognp1x", two(0xF000, 0x4806), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fmodb", two(0xF000, 0x5821), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fmodd", two(0xF000, 0x5421), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fmodl", two(0xF000, 0x4021), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fmodp", two(0xF000, 0x4C21), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fmods", two(0xF000, 0x4421), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fmodw", two(0xF000, 0x5021), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fmodx", two(0xF000, 0x4821), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+{"fmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fmoveb", two(0xF000, 0x7800), two(0xF1C0, 0xFC7F), "IiF7$b", mfloat },
+{"fmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fmoved", two(0xF000, 0x7400), two(0xF1C0, 0xFC7F), "IiF7~F", mfloat },
+{"fmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fmovel", two(0xF000, 0x6000), two(0xF1C0, 0xFC7F), "IiF7$l", mfloat },
+/* FIXME: the next two variants should not permit moving an address
+ register to anything but the floating point instruction register. */
+{"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8%s", mfloat },
+{"fmovel", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ls8", mfloat },
+{"fmovep", two(0xF000, 0x4C00), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fmovep", two(0xF000, 0x6C00), two(0xF1C0, 0xFC00), "IiF7~pkC", mfloat },
+{"fmovep", two(0xF000, 0x7C00), two(0xF1C0, 0xFC0F), "IiF7~pDk", mfloat },
+{"fmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fmoves", two(0xF000, 0x6400), two(0xF1C0, 0xFC7F), "IiF7$f", mfloat },
+{"fmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fmovew", two(0xF000, 0x7000), two(0xF1C0, 0xFC7F), "IiF7$w", mfloat },
+{"fmovex", two(0xF000, 0x0000), two(0xF1FF, 0xE07F), "IiF8F7", mfloat },
+{"fmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fmovex", two(0xF000, 0x6800), two(0xF1C0, 0xFC7F), "IiF7~x", mfloat },
+
+{"fsmoveb", two(0xF000, 0x5840), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fsmoved", two(0xF000, 0x5440), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fsmovel", two(0xF000, 0x4040), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fsmoves", two(0xF000, 0x4440), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fsmovew", two(0xF000, 0x5040), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fsmovex", two(0xF000, 0x0040), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fsmovex", two(0xF000, 0x4840), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fsmovep", two(0xF000, 0x4C40), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+
+{"fdmoveb", two(0xF000, 0x5844), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fdmoved", two(0xF000, 0x5444), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fdmovel", two(0xF000, 0x4044), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fdmoves", two(0xF000, 0x4444), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fdmovew", two(0xF000, 0x5044), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fdmovex", two(0xF000, 0x0044), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fdmovex", two(0xF000, 0x4844), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fdmovep", two(0xF000, 0x4C44), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+
+{"fmovecrx", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7", mfloat },
+
+{"fmovemx", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s", mfloat },
+{"fmovemx", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s", mfloat },
+{"fmovemx", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk", mfloat },
+{"fmovemx", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk", mfloat },
+{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s", mfloat },
+{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s", mfloat },
+{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3", mfloat },
+{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3", mfloat },
+{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s", mfloat },
+{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s", mfloat },
+{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3", mfloat },
+{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3", mfloat },
+
+{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8%s", mfloat },
+{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8~s", mfloat },
+/* FIXME: In the next instruction, we should only permit %dn if the
+ target is a single register. We should only permit %an if the
+ target is a single %fpiar. */
+{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*lL8", mfloat },
+
+{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s", mfloat },
+{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s", mfloat },
+{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3", mfloat },
+{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3", mfloat },
+{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s", mfloat },
+{"fmovem", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s", mfloat },
+{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s", mfloat },
+{"fmovem", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s", mfloat },
+{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3", mfloat },
+{"fmovem", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk", mfloat },
+{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3", mfloat },
+{"fmovem", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk", mfloat },
+{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8%s", mfloat },
+{"fmovem", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8", mfloat },
+{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8~s", mfloat },
+{"fmovem", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8", mfloat },
+
+{"fmulb", two(0xF000, 0x5823), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fmuld", two(0xF000, 0x5423), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fmull", two(0xF000, 0x4023), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fmulp", two(0xF000, 0x4C23), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fmuls", two(0xF000, 0x4423), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fmulw", two(0xF000, 0x5023), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fmulx", two(0xF000, 0x4823), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+{"fsmulb", two(0xF000, 0x5863), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fsmuld", two(0xF000, 0x5463), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fsmull", two(0xF000, 0x4063), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fsmulp", two(0xF000, 0x4C63), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fsmuls", two(0xF000, 0x4463), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fsmulw", two(0xF000, 0x5063), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fsmulx", two(0xF000, 0x0063), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fsmulx", two(0xF000, 0x4863), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+
+{"fdmulb", two(0xF000, 0x5867), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fdmuld", two(0xF000, 0x5467), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fdmull", two(0xF000, 0x4067), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fdmulp", two(0xF000, 0x4C67), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fdmuls", two(0xF000, 0x4467), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fdmulw", two(0xF000, 0x5067), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fdmulx", two(0xF000, 0x0067), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fdmulx", two(0xF000, 0x4867), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+
+{"fnegb", two(0xF000, 0x581A), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fnegd", two(0xF000, 0x541A), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fnegl", two(0xF000, 0x401A), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fnegp", two(0xF000, 0x4C1A), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fnegs", two(0xF000, 0x441A), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fnegw", two(0xF000, 0x501A), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fnegx", two(0xF000, 0x481A), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fsnegb", two(0xF000, 0x585A), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fsnegd", two(0xF000, 0x545A), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fsnegl", two(0xF000, 0x405A), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fsnegp", two(0xF000, 0x4C5A), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fsnegs", two(0xF000, 0x445A), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fsnegw", two(0xF000, 0x505A), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fsnegx", two(0xF000, 0x005A), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fsnegx", two(0xF000, 0x485A), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fsnegx", two(0xF000, 0x005A), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"fdnegb", two(0xF000, 0x585E), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fdnegd", two(0xF000, 0x545E), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fdnegl", two(0xF000, 0x405E), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fdnegp", two(0xF000, 0x4C5E), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fdnegs", two(0xF000, 0x445E), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fdnegw", two(0xF000, 0x505E), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fdnegx", two(0xF000, 0x005E), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fdnegx", two(0xF000, 0x485E), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fdnegx", two(0xF000, 0x005E), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"fnop", two(0xF280, 0x0000), two(0xFFFF, 0xFFFF), "Ii", mfloat },
+
+{"fremb", two(0xF000, 0x5825), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fremd", two(0xF000, 0x5425), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"freml", two(0xF000, 0x4025), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fremp", two(0xF000, 0x4C25), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"frems", two(0xF000, 0x4425), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fremw", two(0xF000, 0x5025), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fremx", two(0xF000, 0x4825), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+{"frestore", one(0xF140), one(0xF1C0), "Id<s", mfloat },
+
+{"fsave", one(0xF100), one(0xF1C0), "Id>s", mfloat },
+
+{"fscaleb", two(0xF000, 0x5826), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fscaled", two(0xF000, 0x5426), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fscalel", two(0xF000, 0x4026), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fscalep", two(0xF000, 0x4C26), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fscales", two(0xF000, 0x4426), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fscalew", two(0xF000, 0x5026), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fscalex", two(0xF000, 0x4826), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+
+/* $ is necessary to prevent the assembler from using PC-relative.
+ If @ were used, "label: fseq label" could produce "ftrapeq",
+ because "label" became "pc@label". */
+{"fseq", two(0xF040, 0x0001), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsf", two(0xF040, 0x0000), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsge", two(0xF040, 0x0013), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsgl", two(0xF040, 0x0016), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsgle", two(0xF040, 0x0017), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsgt", two(0xF040, 0x0012), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsle", two(0xF040, 0x0015), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fslt", two(0xF040, 0x0014), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsne", two(0xF040, 0x000E), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsnge", two(0xF040, 0x001C), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsngl", two(0xF040, 0x0019), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsngle", two(0xF040, 0x0018), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsngt", two(0xF040, 0x001D), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsnle", two(0xF040, 0x001A), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsnlt", two(0xF040, 0x001B), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsoge", two(0xF040, 0x0003), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsogl", two(0xF040, 0x0006), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsogt", two(0xF040, 0x0002), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsole", two(0xF040, 0x0005), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsolt", two(0xF040, 0x0004), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsor", two(0xF040, 0x0007), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsseq", two(0xF040, 0x0011), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fssf", two(0xF040, 0x0010), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fssne", two(0xF040, 0x001E), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsst", two(0xF040, 0x001F), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fst", two(0xF040, 0x000F), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsueq", two(0xF040, 0x0009), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsuge", two(0xF040, 0x000B), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsugt", two(0xF040, 0x000A), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsule", two(0xF040, 0x000D), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsult", two(0xF040, 0x000C), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+{"fsun", two(0xF040, 0x0008), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
+
+{"fsgldivb", two(0xF000, 0x5824), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fsgldivd", two(0xF000, 0x5424), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fsgldivl", two(0xF000, 0x4024), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fsgldivp", two(0xF000, 0x4C24), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fsgldivs", two(0xF000, 0x4424), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fsgldivw", two(0xF000, 0x5024), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fsgldivx", two(0xF000, 0x4824), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fsglmulb", two(0xF000, 0x5827), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fsglmuld", two(0xF000, 0x5427), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fsglmull", two(0xF000, 0x4027), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fsglmulp", two(0xF000, 0x4C27), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fsglmuls", two(0xF000, 0x4427), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fsglmulw", two(0xF000, 0x5027), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fsglmulx", two(0xF000, 0x4827), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fsinb", two(0xF000, 0x580E), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fsind", two(0xF000, 0x540E), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fsinl", two(0xF000, 0x400E), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fsinp", two(0xF000, 0x4C0E), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fsins", two(0xF000, 0x440E), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fsinw", two(0xF000, 0x500E), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fsinx", two(0xF000, 0x480E), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fsincosb", two(0xF000, 0x5830), two(0xF1C0, 0xFC78), "Ii;bF3F7", mfloat },
+{"fsincosd", two(0xF000, 0x5430), two(0xF1C0, 0xFC78), "Ii;FF3F7", mfloat },
+{"fsincosl", two(0xF000, 0x4030), two(0xF1C0, 0xFC78), "Ii;lF3F7", mfloat },
+{"fsincosp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC78), "Ii;pF3F7", mfloat },
+{"fsincoss", two(0xF000, 0x4430), two(0xF1C0, 0xFC78), "Ii;fF3F7", mfloat },
+{"fsincosw", two(0xF000, 0x5030), two(0xF1C0, 0xFC78), "Ii;wF3F7", mfloat },
+{"fsincosx", two(0xF000, 0x0030), two(0xF1C0, 0xE078), "IiF8F3F7", mfloat },
+{"fsincosx", two(0xF000, 0x4830), two(0xF1C0, 0xFC78), "Ii;xF3F7", mfloat },
+
+{"fsinhb", two(0xF000, 0x5802), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fsinhd", two(0xF000, 0x5402), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fsinhl", two(0xF000, 0x4002), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fsinhp", two(0xF000, 0x4C02), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fsinhs", two(0xF000, 0x4402), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fsinhw", two(0xF000, 0x5002), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fsinhx", two(0xF000, 0x4802), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fsqrtb", two(0xF000, 0x5804), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fsqrtd", two(0xF000, 0x5404), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fsqrtl", two(0xF000, 0x4004), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fsqrtp", two(0xF000, 0x4C04), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fsqrts", two(0xF000, 0x4404), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fsqrtw", two(0xF000, 0x5004), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fsqrtx", two(0xF000, 0x4804), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fssqrtb", two(0xF000, 0x5841), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fssqrtd", two(0xF000, 0x5441), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fssqrtl", two(0xF000, 0x4041), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fssqrtp", two(0xF000, 0x4C41), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fssqrts", two(0xF000, 0x4441), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fssqrtw", two(0xF000, 0x5041), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fssqrtx", two(0xF000, 0x0041), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fssqrtx", two(0xF000, 0x4841), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fssqrtx", two(0xF000, 0x0041), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"fdsqrtb", two(0xF000, 0x5845), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fdsqrtd", two(0xF000, 0x5445), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fdsqrtl", two(0xF000, 0x4045), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fdsqrtp", two(0xF000, 0x4C45), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fdsqrts", two(0xF000, 0x4445), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fdsqrtw", two(0xF000, 0x5045), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fdsqrtx", two(0xF000, 0x0045), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fdsqrtx", two(0xF000, 0x4845), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fdsqrtx", two(0xF000, 0x0045), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"fsubb", two(0xF000, 0x5828), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"fsubd", two(0xF000, 0x5428), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"fsubl", two(0xF000, 0x4028), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"fsubp", two(0xF000, 0x4C28), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"fsubs", two(0xF000, 0x4428), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"fsubw", two(0xF000, 0x5028), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"fsubx", two(0xF000, 0x4828), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"fssubb", two(0xF000, 0x5868), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fssubd", two(0xF000, 0x5468), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fssubl", two(0xF000, 0x4068), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fssubp", two(0xF000, 0x4C68), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fssubs", two(0xF000, 0x4468), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fssubw", two(0xF000, 0x5068), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fssubx", two(0xF000, 0x0068), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fssubx", two(0xF000, 0x4868), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fssubx", two(0xF000, 0x0068), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"fdsubb", two(0xF000, 0x586c), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040up },
+{"fdsubd", two(0xF000, 0x546c), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040up },
+{"fdsubl", two(0xF000, 0x406c), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040up },
+{"fdsubp", two(0xF000, 0x4C6c), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040up },
+{"fdsubs", two(0xF000, 0x446c), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040up },
+{"fdsubw", two(0xF000, 0x506c), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040up },
+{"fdsubx", two(0xF000, 0x006c), two(0xF1C0, 0xE07F), "IiF8F7", m68040up },
+{"fdsubx", two(0xF000, 0x486c), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040up },
+{"fdsubx", two(0xF000, 0x006c), two(0xF1C0, 0xE07F), "IiFt", m68040up },
+
+{"ftanb", two(0xF000, 0x580F), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"ftand", two(0xF000, 0x540F), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"ftanl", two(0xF000, 0x400F), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"ftanp", two(0xF000, 0x4C0F), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"ftans", two(0xF000, 0x440F), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"ftanw", two(0xF000, 0x500F), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"ftanx", two(0xF000, 0x480F), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"ftanhb", two(0xF000, 0x5809), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"ftanhd", two(0xF000, 0x5409), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"ftanhl", two(0xF000, 0x4009), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"ftanhp", two(0xF000, 0x4C09), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"ftanhs", two(0xF000, 0x4409), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"ftanhw", two(0xF000, 0x5009), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"ftanhx", two(0xF000, 0x4809), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"ftentoxb", two(0xF000, 0x5812), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"ftentoxd", two(0xF000, 0x5412), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"ftentoxl", two(0xF000, 0x4012), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"ftentoxp", two(0xF000, 0x4C12), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"ftentoxs", two(0xF000, 0x4412), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"ftentoxw", two(0xF000, 0x5012), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"ftentoxx", two(0xF000, 0x4812), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"ftrapeq", two(0xF07C, 0x0001), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapf", two(0xF07C, 0x0000), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapge", two(0xF07C, 0x0013), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapgl", two(0xF07C, 0x0016), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapgle", two(0xF07C, 0x0017), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapgt", two(0xF07C, 0x0012), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftraple", two(0xF07C, 0x0015), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftraplt", two(0xF07C, 0x0014), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapne", two(0xF07C, 0x000E), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapnge", two(0xF07C, 0x001C), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapngl", two(0xF07C, 0x0019), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapngle", two(0xF07C, 0x0018), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapngt", two(0xF07C, 0x001D), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapnle", two(0xF07C, 0x001A), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapnlt", two(0xF07C, 0x001B), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapoge", two(0xF07C, 0x0003), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapogl", two(0xF07C, 0x0006), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapogt", two(0xF07C, 0x0002), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapole", two(0xF07C, 0x0005), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapolt", two(0xF07C, 0x0004), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapor", two(0xF07C, 0x0007), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapseq", two(0xF07C, 0x0011), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapsf", two(0xF07C, 0x0010), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapsne", two(0xF07C, 0x001E), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapst", two(0xF07C, 0x001F), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapt", two(0xF07C, 0x000F), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapueq", two(0xF07C, 0x0009), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapuge", two(0xF07C, 0x000B), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapugt", two(0xF07C, 0x000A), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapule", two(0xF07C, 0x000D), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapult", two(0xF07C, 0x000C), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+{"ftrapun", two(0xF07C, 0x0008), two(0xF1FF, 0xFFFF), "Ii", mfloat },
+
+{"ftrapeqw", two(0xF07A, 0x0001), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapfw", two(0xF07A, 0x0000), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapgew", two(0xF07A, 0x0013), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapglw", two(0xF07A, 0x0016), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapglew", two(0xF07A, 0x0017), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapgtw", two(0xF07A, 0x0012), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftraplew", two(0xF07A, 0x0015), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapltw", two(0xF07A, 0x0014), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapnew", two(0xF07A, 0x000E), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapngew", two(0xF07A, 0x001C), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapnglw", two(0xF07A, 0x0019), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapnglew", two(0xF07A, 0x0018), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapngtw", two(0xF07A, 0x001D), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapnlew", two(0xF07A, 0x001A), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapnltw", two(0xF07A, 0x001B), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapogew", two(0xF07A, 0x0003), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapoglw", two(0xF07A, 0x0006), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapogtw", two(0xF07A, 0x0002), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapolew", two(0xF07A, 0x0005), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapoltw", two(0xF07A, 0x0004), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftraporw", two(0xF07A, 0x0007), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapseqw", two(0xF07A, 0x0011), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapsfw", two(0xF07A, 0x0010), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapsnew", two(0xF07A, 0x001E), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapstw", two(0xF07A, 0x001F), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftraptw", two(0xF07A, 0x000F), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapueqw", two(0xF07A, 0x0009), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapugew", two(0xF07A, 0x000B), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapugtw", two(0xF07A, 0x000A), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapulew", two(0xF07A, 0x000D), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapultw", two(0xF07A, 0x000C), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+{"ftrapunw", two(0xF07A, 0x0008), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
+
+{"ftrapeql", two(0xF07B, 0x0001), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapfl", two(0xF07B, 0x0000), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapgel", two(0xF07B, 0x0013), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapgll", two(0xF07B, 0x0016), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapglel", two(0xF07B, 0x0017), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapgtl", two(0xF07B, 0x0012), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftraplel", two(0xF07B, 0x0015), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapltl", two(0xF07B, 0x0014), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapnel", two(0xF07B, 0x000E), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapngel", two(0xF07B, 0x001C), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapngll", two(0xF07B, 0x0019), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapnglel", two(0xF07B, 0x0018), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapngtl", two(0xF07B, 0x001D), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapnlel", two(0xF07B, 0x001A), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapnltl", two(0xF07B, 0x001B), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapogel", two(0xF07B, 0x0003), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapogll", two(0xF07B, 0x0006), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapogtl", two(0xF07B, 0x0002), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapolel", two(0xF07B, 0x0005), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapoltl", two(0xF07B, 0x0004), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftraporl", two(0xF07B, 0x0007), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapseql", two(0xF07B, 0x0011), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapsfl", two(0xF07B, 0x0010), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapsnel", two(0xF07B, 0x001E), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapstl", two(0xF07B, 0x001F), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftraptl", two(0xF07B, 0x000F), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapueql", two(0xF07B, 0x0009), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapugel", two(0xF07B, 0x000B), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapugtl", two(0xF07B, 0x000A), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapulel", two(0xF07B, 0x000D), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapultl", two(0xF07B, 0x000C), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+{"ftrapunl", two(0xF07B, 0x0008), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
+
+{"ftstb", two(0xF000, 0x583A), two(0xF1C0, 0xFC7F), "Ii;b", mfloat },
+{"ftstd", two(0xF000, 0x543A), two(0xF1C0, 0xFC7F), "Ii;F", mfloat },
+{"ftstl", two(0xF000, 0x403A), two(0xF1C0, 0xFC7F), "Ii;l", mfloat },
+{"ftstp", two(0xF000, 0x4C3A), two(0xF1C0, 0xFC7F), "Ii;p", mfloat },
+{"ftsts", two(0xF000, 0x443A), two(0xF1C0, 0xFC7F), "Ii;f", mfloat },
+{"ftstw", two(0xF000, 0x503A), two(0xF1C0, 0xFC7F), "Ii;w", mfloat },
+{"ftstx", two(0xF000, 0x003A), two(0xF1C0, 0xE07F), "IiF8", mfloat },
+{"ftstx", two(0xF000, 0x483A), two(0xF1C0, 0xFC7F), "Ii;x", mfloat },
+
+{"ftwotoxb", two(0xF000, 0x5811), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
+{"ftwotoxd", two(0xF000, 0x5411), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
+{"ftwotoxl", two(0xF000, 0x4011), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
+{"ftwotoxp", two(0xF000, 0x4C11), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
+{"ftwotoxs", two(0xF000, 0x4411), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
+{"ftwotoxw", two(0xF000, 0x5011), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
+{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
+{"ftwotoxx", two(0xF000, 0x4811), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
+{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiFt", mfloat },
+
+{"halt", one(0045310), one(0177777), "", m68060 | mcf5200 },
+
+{"illegal", one(0045374), one(0177777), "", m68000up },
+
+{"jmp", one(0047300), one(0177700), "!s", m68000up | mcf5200 },
+
+{"jra", one(0060000), one(0177400), "Bg", m68000up | mcf5200 },
+{"jra", one(0047300), one(0177700), "!s", m68000up | mcf5200 },
+
+{"jsr", one(0047200), one(0177700), "!s", m68000up | mcf5200 },
+
+{"jbsr", one(0060400), one(0177400), "Bg", m68000up | mcf5200 },
+{"jbsr", one(0047200), one(0177700), "!s", m68000up | mcf5200 },
+
+{"lea", one(0040700), one(0170700), "!sAd", m68000up | mcf5200 },
+
+{"lpstop", two(0174000,0000700),two(0177777,0177777),"#w", cpu32|m68060 },
+
+{"linkw", one(0047120), one(0177770), "As#w", m68000up | mcf5200 },
+{"linkl", one(0044010), one(0177770), "As#l", m68020up | cpu32 },
+{"link", one(0047120), one(0177770), "As#W", m68000up | mcf5200 },
+{"link", one(0044010), one(0177770), "As#l", m68020up | cpu32 },
+
+{"lslb", one(0160410), one(0170770), "QdDs", m68000up },
+{"lslb", one(0160450), one(0170770), "DdDs", m68000up },
+{"lslw", one(0160510), one(0170770), "QdDs", m68000up },
+{"lslw", one(0160550), one(0170770), "DdDs", m68000up },
+{"lslw", one(0161700), one(0177700), "~s", m68000up },
+{"lsll", one(0160610), one(0170770), "QdDs", m68000up | mcf5200 },
+{"lsll", one(0160650), one(0170770), "DdDs", m68000up | mcf5200 },
+
+{"lsrb", one(0160010), one(0170770), "QdDs", m68000up },
+{"lsrb", one(0160050), one(0170770), "DdDs", m68000up },
+{"lsrw", one(0160110), one(0170770), "QdDs", m68000up },
+{"lsrw", one(0160150), one(0170770), "DdDs", m68000up },
+{"lsrw", one(0161300), one(0177700), "~s", m68000up },
+{"lsrl", one(0160210), one(0170770), "QdDs", m68000up | mcf5200 },
+{"lsrl", one(0160250), one(0170770), "DdDs", m68000up | mcf5200 },
+
+/* NOTE: The mcf5200 family programmer's reference manual does not
+ indicate the byte form of the movea instruction is invalid (as it
+ is on 68000 family cpus). However, experiments on the 5202 yeild
+ unexpected results. The value is copied, but it is not sign extended
+ (as is done with movea.w) and the top three bytes in the address
+ register are not disturbed. I don't know if this is the intended
+ behavior --- it could be a hole in instruction decoding (Motorola
+ decided not to trap all invalid instructions for performance reasons)
+ --- but I suspect that it is not.
+
+ I reported this to Motorola ISD Technical Communications Support,
+ which replied that other coldfire assemblers reject movea.b. For
+ this reason I've decided to not allow moveab.
+
+ jtc@cygnus.com - 97/01/24
+ */
+
+{"moveal", one(0020100), one(0170700), "*lAd", m68000up | mcf5200 },
+{"moveaw", one(0030100), one(0170700), "*wAd", m68000up | mcf5200 },
+
+{"movec", one(0047173), one(0177777), "R1Jj", m68010up | mcf5200 },
+{"movec", one(0047173), one(0177777), "R1#j", m68010up | mcf5200 },
+{"movec", one(0047172), one(0177777), "JjR1", m68010up },
+{"movec", one(0047172), one(0177777), "#jR1", m68010up },
+
+{"movemw", one(0044200), one(0177700), "Lw&s", m68000up },
+{"movemw", one(0044240), one(0177770), "lw-s", m68000up },
+{"movemw", one(0044200), one(0177700), "#w>s", m68000up },
+{"movemw", one(0046200), one(0177700), "<sLw", m68000up },
+{"movemw", one(0046200), one(0177700), "<s#w", m68000up },
+{"moveml", one(0044300), one(0177700), "Lw&s", m68000up },
+{"moveml", one(0044340), one(0177770), "lw-s", m68000up },
+{"moveml", one(0044300), one(0177700), "#w>s", m68000up },
+{"moveml", one(0046300), one(0177700), "<sLw", m68000up },
+{"moveml", one(0046300), one(0177700), "<s#w", m68000up },
+/* FIXME: need specifier for mode 2 and 5 to simplify below insn patterns */
+{"moveml", one(0044320), one(0177770), "Lwas", mcf5200 },
+{"moveml", one(0044320), one(0177770), "#was", mcf5200 },
+{"moveml", one(0044350), one(0177770), "Lwds", mcf5200 },
+{"moveml", one(0044350), one(0177770), "#wds", mcf5200 },
+{"moveml", one(0046320), one(0177770), "asLw", mcf5200 },
+{"moveml", one(0046320), one(0177770), "as#w", mcf5200 },
+{"moveml", one(0046350), one(0177770), "dsLw", mcf5200 },
+{"moveml", one(0046350), one(0177770), "ds#w", mcf5200 },
+
+{"movepw", one(0000410), one(0170770), "dsDd", m68000up },
+{"movepw", one(0000610), one(0170770), "Ddds", m68000up },
+{"movepl", one(0000510), one(0170770), "dsDd", m68000up },
+{"movepl", one(0000710), one(0170770), "Ddds", m68000up },
+
+{"moveq", one(0070000), one(0170400), "MsDd", m68000up | mcf5200 },
+{"moveq", one(0070000), one(0170400), "#BDd", m68000up | mcf5200 },
+
+/* The move opcode can generate the movea and moveq instructions. */
+{"moveb", one(0010000), one(0170000), ";b$d", m68000up },
+{"moveb", one(0010000), one(0170000), "ms%d", mcf5200 },
+{"moveb", one(0010000), one(0170000), "nspd", mcf5200 },
+{"moveb", one(0010000), one(0170000), "obmd", mcf5200 },
+
+{"movew", one(0030000), one(0170000), "*w%d", m68000up },
+{"movew", one(0030000), one(0170000), "ms%d", mcf5200 },
+{"movew", one(0030000), one(0170000), "nspd", mcf5200 },
+{"movew", one(0030000), one(0170000), "owmd", mcf5200 },
+{"movew", one(0040300), one(0177700), "Ss$s", m68000up },
+{"movew", one(0040300), one(0177770), "SsDs", mcf5200 },
+{"movew", one(0041300), one(0177700), "Cs$s", m68010up },
+{"movew", one(0041300), one(0177770), "CsDs", mcf5200 },
+{"movew", one(0042300), one(0177700), ";wCd", m68000up },
+{"movew", one(0042300), one(0177700), "DsCd", mcf5200 },
+{"movew", one(0042374), one(0177777), "#wCd", mcf5200 },
+{"movew", one(0043300), one(0177700), ";wSd", m68000up },
+{"movew", one(0043300), one(0177700), "DsSd", mcf5200 },
+{"movew", one(0043374), one(0177777), "#wSd", mcf5200 },
+
+{"movel", one(0070000), one(0170400), "MsDd", m68000up | mcf5200 },
+{"movel", one(0020000), one(0170000), "*l%d", m68000up },
+{"movel", one(0020000), one(0170000), "ms%d", mcf5200 },
+{"movel", one(0020000), one(0170000), "nspd", mcf5200 },
+{"movel", one(0020000), one(0170000), "olmd", mcf5200 },
+{"movel", one(0047140), one(0177770), "AsUd", m68000up },
+{"movel", one(0047150), one(0177770), "UdAs", m68000up },
+
+{"move", one(0030000), one(0170000), "*w%d", m68000up },
+{"move", one(0030000), one(0170000), "ms%d", mcf5200 },
+{"move", one(0030000), one(0170000), "nspd", mcf5200 },
+{"move", one(0030000), one(0170000), "owmd", mcf5200 },
+{"move", one(0040300), one(0177700), "Ss$s", m68000up },
+{"move", one(0040300), one(0177770), "SsDs", mcf5200 },
+{"move", one(0041300), one(0177700), "Cs$s", m68010up },
+{"move", one(0041300), one(0177770), "CsDs", mcf5200 },
+{"move", one(0042300), one(0177700), ";wCd", m68000up },
+{"move", one(0042300), one(0177700), "DsCd", mcf5200 },
+{"move", one(0042374), one(0177777), "#wCd", mcf5200 },
+{"move", one(0043300), one(0177700), ";wSd", m68000up },
+{"move", one(0043300), one(0177700), "DsSd", mcf5200 },
+{"move", one(0043374), one(0177777), "#wSd", mcf5200 },
+
+{"move", one(0047140), one(0177770), "AsUd", m68000up },
+{"move", one(0047150), one(0177770), "UdAs", m68000up },
+
+{"movesb", two(0007000, 0), two(0177700, 07777), "~sR1", m68010up },
+{"movesb", two(0007000, 04000), two(0177700, 07777), "R1~s", m68010up },
+{"movesw", two(0007100, 0), two(0177700, 07777), "~sR1", m68010up },
+{"movesw", two(0007100, 04000), two(0177700, 07777), "R1~s", m68010up },
+{"movesl", two(0007200, 0), two(0177700, 07777), "~sR1", m68010up },
+{"movesl", two(0007200, 04000), two(0177700, 07777), "R1~s", m68010up },
+
+{"move16", two(0xf620, 0x8000), two(0xfff8, 0x8fff), "+s+1", m68040up },
+{"move16", one(0xf600), one(0xfff8), "+s_L", m68040up },
+{"move16", one(0xf608), one(0xfff8), "_L+s", m68040up },
+{"move16", one(0xf610), one(0xfff8), "as_L", m68040up },
+{"move16", one(0xf618), one(0xfff8), "_Las", m68040up },
+
+{"mulsw", one(0140700), one(0170700), ";wDd", m68000up|mcf5200 },
+{"mulsl", two(0046000,004000), two(0177700,0107770), ";lD1", m68020up|cpu32 },
+{"mulsl", two(0046000,004000), two(0177700,0107770), "qsD1", mcf5200 },
+{"mulsl", two(0046000,006000), two(0177700,0107770), ";lD3D1",m68020up|cpu32 },
+
+{"muluw", one(0140300), one(0170700), ";wDd", m68000up|mcf5200 },
+{"mulul", two(0046000,000000), two(0177700,0107770), ";lD1", m68020up|cpu32 },
+{"mulul", two(0046000,000000), two(0177700,0107770), "qsD1", mcf5200 },
+{"mulul", two(0046000,002000), two(0177700,0107770), ";lD3D1",m68020up|cpu32 },
+
+{"nbcd", one(0044000), one(0177700), "$s", m68000up },
+
+{"negb", one(0042000), one(0177700), "$s", m68000up },
+{"negw", one(0042100), one(0177700), "$s", m68000up },
+{"negl", one(0042200), one(0177700), "$s", m68000up },
+{"negl", one(0042200), one(0177700), "Ds", mcf5200},
+
+{"negxb", one(0040000), one(0177700), "$s", m68000up },
+{"negxw", one(0040100), one(0177700), "$s", m68000up },
+{"negxl", one(0040200), one(0177700), "$s", m68000up },
+{"negxl", one(0040200), one(0177700), "Ds", mcf5200},
+
+{"nop", one(0047161), one(0177777), "", m68000up | mcf5200},
+
+{"notb", one(0043000), one(0177700), "$s", m68000up },
+{"notw", one(0043100), one(0177700), "$s", m68000up },
+{"notl", one(0043200), one(0177700), "$s", m68000up },
+{"notl", one(0043200), one(0177700), "Ds", mcf5200},
+
+{"orib", one(0000000), one(0177700), "#b$s", m68000up },
+{"orib", one(0000074), one(0177777), "#bCs", m68000up },
+{"oriw", one(0000100), one(0177700), "#w$s", m68000up },
+{"oriw", one(0000174), one(0177777), "#wSs", m68000up },
+{"oril", one(0000200), one(0177700), "#l$s", m68000up },
+{"oril", one(0000200), one(0177700), "#lDs", mcf5200 },
+{"ori", one(0000074), one(0177777), "#bCs", m68000up },
+{"ori", one(0000100), one(0177700), "#w$s", m68000up },
+{"ori", one(0000174), one(0177777), "#wSs", m68000up },
+
+/* The or opcode can generate the ori instruction. */
+{"orb", one(0000000), one(0177700), "#b$s", m68000up },
+{"orb", one(0000074), one(0177777), "#bCs", m68000up },
+{"orb", one(0100000), one(0170700), ";bDd", m68000up },
+{"orb", one(0100400), one(0170700), "Dd~s", m68000up },
+{"orw", one(0000100), one(0177700), "#w$s", m68000up },
+{"orw", one(0000174), one(0177777), "#wSs", m68000up },
+{"orw", one(0100100), one(0170700), ";wDd", m68000up },
+{"orw", one(0100500), one(0170700), "Dd~s", m68000up },
+{"orl", one(0000200), one(0177700), "#l$s", m68000up },
+{"orl", one(0000200), one(0177700), "#lDs", mcf5200 },
+{"orl", one(0100200), one(0170700), ";lDd", m68000up | mcf5200 },
+{"orl", one(0100600), one(0170700), "Dd~s", m68000up | mcf5200 },
+{"or", one(0000074), one(0177777), "#bCs", m68000up },
+{"or", one(0000100), one(0177700), "#w$s", m68000up },
+{"or", one(0000174), one(0177777), "#wSs", m68000up },
+{"or", one(0100100), one(0170700), ";wDd", m68000up },
+{"or", one(0100500), one(0170700), "Dd~s", m68000up },
+
+{"pack", one(0100500), one(0170770), "DsDd#w", m68020up },
+{"pack", one(0100510), one(0170770), "-s-d#w", m68020up },
+
+{"pbac", one(0xf087), one(0xffbf), "Bc", m68851 },
+{"pbacw", one(0xf087), one(0xffff), "BW", m68851 },
+{"pbas", one(0xf086), one(0xffbf), "Bc", m68851 },
+{"pbasw", one(0xf086), one(0xffff), "BW", m68851 },
+{"pbbc", one(0xf081), one(0xffbf), "Bc", m68851 },
+{"pbbcw", one(0xf081), one(0xffff), "BW", m68851 },
+{"pbbs", one(0xf080), one(0xffbf), "Bc", m68851 },
+{"pbbsw", one(0xf080), one(0xffff), "BW", m68851 },
+{"pbcc", one(0xf08f), one(0xffbf), "Bc", m68851 },
+{"pbccw", one(0xf08f), one(0xffff), "BW", m68851 },
+{"pbcs", one(0xf08e), one(0xffbf), "Bc", m68851 },
+{"pbcsw", one(0xf08e), one(0xffff), "BW", m68851 },
+{"pbgc", one(0xf08d), one(0xffbf), "Bc", m68851 },
+{"pbgcw", one(0xf08d), one(0xffff), "BW", m68851 },
+{"pbgs", one(0xf08c), one(0xffbf), "Bc", m68851 },
+{"pbgsw", one(0xf08c), one(0xffff), "BW", m68851 },
+{"pbic", one(0xf08b), one(0xffbf), "Bc", m68851 },
+{"pbicw", one(0xf08b), one(0xffff), "BW", m68851 },
+{"pbis", one(0xf08a), one(0xffbf), "Bc", m68851 },
+{"pbisw", one(0xf08a), one(0xffff), "BW", m68851 },
+{"pblc", one(0xf083), one(0xffbf), "Bc", m68851 },
+{"pblcw", one(0xf083), one(0xffff), "BW", m68851 },
+{"pbls", one(0xf082), one(0xffbf), "Bc", m68851 },
+{"pblsw", one(0xf082), one(0xffff), "BW", m68851 },
+{"pbsc", one(0xf085), one(0xffbf), "Bc", m68851 },
+{"pbscw", one(0xf085), one(0xffff), "BW", m68851 },
+{"pbss", one(0xf084), one(0xffbf), "Bc", m68851 },
+{"pbssw", one(0xf084), one(0xffff), "BW", m68851 },
+{"pbwc", one(0xf089), one(0xffbf), "Bc", m68851 },
+{"pbwcw", one(0xf089), one(0xffff), "BW", m68851 },
+{"pbws", one(0xf088), one(0xffbf), "Bc", m68851 },
+{"pbwsw", one(0xf088), one(0xffff), "BW", m68851 },
+
+{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw", m68851 },
+{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw", m68851 },
+
+{"pea", one(0044100), one(0177700), "!s", m68000up|mcf5200 },
+
+{"pflusha", one(0xf518), one(0xfff8), "", m68040up },
+{"pflusha", two(0xf000,0x2400), two(0xffff,0xffff), "", m68030 | m68851 },
+
+{"pflush", two(0xf000,0x3010), two(0xffc0,0xfe10), "T3T9", m68030|m68851 },
+{"pflush", two(0xf000,0x3810), two(0xffc0,0xfe10), "T3T9&s", m68030|m68851 },
+{"pflush", two(0xf000,0x3008), two(0xffc0,0xfe18), "D3T9", m68030|m68851 },
+{"pflush", two(0xf000,0x3808), two(0xffc0,0xfe18), "D3T9&s", m68030|m68851 },
+{"pflush", two(0xf000,0x3000), two(0xffc0,0xfe1e), "f3T9", m68030|m68851 },
+{"pflush", two(0xf000,0x3800), two(0xffc0,0xfe1e), "f3T9&s", m68030|m68851 },
+{"pflush", one(0xf508), one(0xfff8), "as", m68040up },
+{"pflush", one(0xf508), one(0xfff8), "As", m68040up },
+
+{"pflushan", one(0xf510), one(0xfff8), "", m68040up },
+{"pflushn", one(0xf500), one(0xfff8), "as", m68040up },
+{"pflushn", one(0xf500), one(0xfff8), "As", m68040up },
+
+{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s", m68851 },
+
+{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9", m68851 },
+{"pflushs", two(0xf000, 0x3c10), two(0xfff8, 0xfe10), "T3T9&s", m68851 },
+{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9", m68851 },
+{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s", m68851 },
+{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9", m68851 },
+{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s", m68851 },
+
+{"ploadr", two(0xf000,0x2210), two(0xffc0,0xfff0), "T3&s", m68030|m68851 },
+{"ploadr", two(0xf000,0x2208), two(0xffc0,0xfff8), "D3&s", m68030|m68851 },
+{"ploadr", two(0xf000,0x2200), two(0xffc0,0xfffe), "f3&s", m68030|m68851 },
+{"ploadw", two(0xf000,0x2010), two(0xffc0,0xfff0), "T3&s", m68030|m68851 },
+{"ploadw", two(0xf000,0x2008), two(0xffc0,0xfff8), "D3&s", m68030|m68851 },
+{"ploadw", two(0xf000,0x2000), two(0xffc0,0xfffe), "f3&s", m68030|m68851 },
+
+{"plpar", one(0xf5c8), one(0xfff8), "as", m68060 },
+{"plpaw", one(0xf588), one(0xfff8), "as", m68060 },
+
+{"pmove", two(0xf000,0x4000), two(0xffc0,0xffff), "*l08", m68030|m68851 },
+{"pmove", two(0xf000,0x5c00), two(0xffc0,0xffff), "*w18", m68851 },
+{"pmove", two(0xf000,0x4000), two(0xffc0,0xe3ff), "*b28", m68851 },
+{"pmove", two(0xf000,0x4200), two(0xffc0,0xffff), "08%s", m68030|m68851 },
+{"pmove", two(0xf000,0x5e00), two(0xffc0,0xffff), "18%s", m68851 },
+{"pmove", two(0xf000,0x4200), two(0xffc0,0xe3ff), "28%s", m68851 },
+{"pmove", two(0xf000,0x4000), two(0xffc0,0xe3ff), "|sW8", m68030|m68851 },
+{"pmove", two(0xf000,0x4200), two(0xffc0,0xe3ff), "W8~s", m68030|m68851 },
+{"pmove", two(0xf000,0x6200), two(0xffc0,0xe3e3), "*wX3", m68851 },
+{"pmove", two(0xf000,0x6000), two(0xffc0,0xe3e3), "X3%s", m68851 },
+{"pmove", two(0xf000,0x6000), two(0xffc0,0xffff), "*wY8", m68030|m68851 },
+{"pmove", two(0xf000,0x6200), two(0xffc0,0xffff), "Y8%s", m68030|m68851 },
+{"pmove", two(0xf000,0x6600), two(0xffc0,0xffff), "Z8%s", m68851 },
+{"pmove", two(0xf000,0x0800), two(0xffc0,0xfbff), "*l38", m68030 },
+{"pmove", two(0xf000,0x0a00), two(0xffc0,0xfbff), "38%s", m68030 },
+
+{"pmovefd", two(0xf000, 0x4100), two(0xffc0, 0xe3ff), "*l08", m68030 },
+{"pmovefd", two(0xf000, 0x4100), two(0xffc0, 0xe3ff), "|sW8", m68030 },
+{"pmovefd", two(0xf000, 0x0900), two(0xffc0, 0xfbff), "*l38", m68030 },
+
+{"prestore", one(0xf140), one(0xffc0), "<s", m68851 },
+
+{"psave", one(0xf100), one(0xffc0), ">s", m68851 },
+
+{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "$s", m68851 },
+{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "$s", m68851 },
+{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "$s", m68851 },
+{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "$s", m68851 },
+{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "$s", m68851 },
+{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "$s", m68851 },
+{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "$s", m68851 },
+{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "$s", m68851 },
+{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "$s", m68851 },
+{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "$s", m68851 },
+{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "$s", m68851 },
+{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "$s", m68851 },
+{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "$s", m68851 },
+{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "$s", m68851 },
+{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "$s", m68851 },
+{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "$s", m68851 },
+
+{"ptestr", two(0xf000,0x8210), two(0xffc0, 0xe3f0), "T3&st8", m68030|m68851 },
+{"ptestr", two(0xf000,0x8310), two(0xffc0,0xe310), "T3&st8A9", m68030|m68851 },
+{"ptestr", two(0xf000,0x8208), two(0xffc0,0xe3f8), "D3&st8", m68030|m68851 },
+{"ptestr", two(0xf000,0x8308), two(0xffc0,0xe318), "D3&st8A9", m68030|m68851 },
+{"ptestr", two(0xf000,0x8200), two(0xffc0,0xe3fe), "f3&st8", m68030|m68851 },
+{"ptestr", two(0xf000,0x8300), two(0xffc0,0xe31e), "f3&st8A9", m68030|m68851 },
+{"ptestr", one(0xf568), one(0xfff8), "as", m68040 },
+
+{"ptestw", two(0xf000,0x8010), two(0xffc0,0xe3f0), "T3&st8", m68030|m68851 },
+{"ptestw", two(0xf000,0x8110), two(0xffc0,0xe310), "T3&st8A9", m68030|m68851 },
+{"ptestw", two(0xf000,0x8008), two(0xffc0,0xe3f8), "D3&st8", m68030|m68851 },
+{"ptestw", two(0xf000,0x8108), two(0xffc0,0xe318), "D3&st8A9", m68030|m68851 },
+{"ptestw", two(0xf000,0x8000), two(0xffc0,0xe3fe), "f3&st8", m68030|m68851 },
+{"ptestw", two(0xf000,0x8100), two(0xffc0,0xe31e), "f3&st8A9", m68030|m68851 },
+{"ptestw", one(0xf548), one(0xfff8), "as", m68040 },
+
+{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), "", m68851 },
+
+{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w", m68851 },
+{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l", m68851 },
+{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), "", m68851 },
+
+{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w", m68851 },
+{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), "", m68851 },
+
+{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w", m68851 },
+{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l", m68851 },
+{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), "", m68851 },
+
+{"pulse", one(0045314), one(0177777), "", m68060 | mcf5200 },
+
+{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s", m68851 },
+{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s", m68851 },
+
+
+{"reset", one(0047160), one(0177777), "", m68000up },
+
+{"rolb", one(0160430), one(0170770), "QdDs", m68000up },
+{"rolb", one(0160470), one(0170770), "DdDs", m68000up },
+{"rolw", one(0160530), one(0170770), "QdDs", m68000up },
+{"rolw", one(0160570), one(0170770), "DdDs", m68000up },
+{"rolw", one(0163700), one(0177700), "~s", m68000up },
+{"roll", one(0160630), one(0170770), "QdDs", m68000up },
+{"roll", one(0160670), one(0170770), "DdDs", m68000up },
+
+{"rorb", one(0160030), one(0170770), "QdDs", m68000up },
+{"rorb", one(0160070), one(0170770), "DdDs", m68000up },
+{"rorw", one(0160130), one(0170770), "QdDs", m68000up },
+{"rorw", one(0160170), one(0170770), "DdDs", m68000up },
+{"rorw", one(0163300), one(0177700), "~s", m68000up },
+{"rorl", one(0160230), one(0170770), "QdDs", m68000up },
+{"rorl", one(0160270), one(0170770), "DdDs", m68000up },
+
+{"roxlb", one(0160420), one(0170770), "QdDs", m68000up },
+{"roxlb", one(0160460), one(0170770), "DdDs", m68000up },
+{"roxlw", one(0160520), one(0170770), "QdDs", m68000up },
+{"roxlw", one(0160560), one(0170770), "DdDs", m68000up },
+{"roxlw", one(0162700), one(0177700), "~s", m68000up },
+{"roxll", one(0160620), one(0170770), "QdDs", m68000up },
+{"roxll", one(0160660), one(0170770), "DdDs", m68000up },
+
+{"roxrb", one(0160020), one(0170770), "QdDs", m68000up },
+{"roxrb", one(0160060), one(0170770), "DdDs", m68000up },
+{"roxrw", one(0160120), one(0170770), "QdDs", m68000up },
+{"roxrw", one(0160160), one(0170770), "DdDs", m68000up },
+{"roxrw", one(0162300), one(0177700), "~s", m68000up },
+{"roxrl", one(0160220), one(0170770), "QdDs", m68000up },
+{"roxrl", one(0160260), one(0170770), "DdDs", m68000up },
+
+{"rtd", one(0047164), one(0177777), "#w", m68010up },
+
+{"rte", one(0047163), one(0177777), "", m68000up|mcf5200 },
+
+{"rtm", one(0003300), one(0177760), "Rs", m68020 },
+
+{"rtr", one(0047167), one(0177777), "", m68000up },
+
+{"rts", one(0047165), one(0177777), "", m68000up|mcf5200 },
+
+{"sbcd", one(0100400), one(0170770), "DsDd", m68000up },
+{"sbcd", one(0100410), one(0170770), "-s-d", m68000up },
+
+
+{"scc", one(0052300), one(0177700), "$s", m68000up },
+{"scc", one(0052300), one(0177700), "Ds", mcf5200 },
+{"scs", one(0052700), one(0177700), "$s", m68000up },
+{"scs", one(0052700), one(0177700), "Ds", mcf5200 },
+{"seq", one(0053700), one(0177700), "$s", m68000up },
+{"seq", one(0053700), one(0177700), "Ds", mcf5200 },
+{"sf", one(0050700), one(0177700), "$s", m68000up },
+{"sf", one(0050700), one(0177700), "Ds", mcf5200 },
+{"sge", one(0056300), one(0177700), "$s", m68000up },
+{"sge", one(0056300), one(0177700), "Ds", mcf5200 },
+{"sgt", one(0057300), one(0177700), "$s", m68000up },
+{"sgt", one(0057300), one(0177700), "Ds", mcf5200 },
+{"shi", one(0051300), one(0177700), "$s", m68000up },
+{"shi", one(0051300), one(0177700), "Ds", mcf5200 },
+{"sle", one(0057700), one(0177700), "$s", m68000up },
+{"sle", one(0057700), one(0177700), "Ds", mcf5200 },
+{"sls", one(0051700), one(0177700), "$s", m68000up },
+{"sls", one(0051700), one(0177700), "Ds", mcf5200 },
+{"slt", one(0056700), one(0177700), "$s", m68000up },
+{"slt", one(0056700), one(0177700), "Ds", mcf5200 },
+{"smi", one(0055700), one(0177700), "$s", m68000up },
+{"smi", one(0055700), one(0177700), "Ds", mcf5200 },
+{"sne", one(0053300), one(0177700), "$s", m68000up },
+{"sne", one(0053300), one(0177700), "Ds", mcf5200 },
+{"spl", one(0055300), one(0177700), "$s", m68000up },
+{"spl", one(0055300), one(0177700), "Ds", mcf5200 },
+{"st", one(0050300), one(0177700), "$s", m68000up },
+{"st", one(0050300), one(0177700), "Ds", mcf5200 },
+{"svc", one(0054300), one(0177700), "$s", m68000up },
+{"svc", one(0054300), one(0177700), "Ds", mcf5200 },
+{"svs", one(0054700), one(0177700), "$s", m68000up },
+{"svs", one(0054700), one(0177700), "Ds", mcf5200 },
+
+{"stop", one(0047162), one(0177777), "#w", m68000up | mcf5200 },
+
+{"subal", one(0110700), one(0170700), "*lAd", m68000up | mcf5200 },
+{"subaw", one(0110300), one(0170700), "*wAd", m68000up },
+
+{"subib", one(0002000), one(0177700), "#b$s", m68000up },
+{"subiw", one(0002100), one(0177700), "#w$s", m68000up },
+{"subil", one(0002200), one(0177700), "#l$s", m68000up },
+{"subil", one(0002200), one(0177700), "#lDs", mcf5200 },
+
+{"subqb", one(0050400), one(0170700), "Qd%s", m68000up },
+{"subqw", one(0050500), one(0170700), "Qd%s", m68000up },
+{"subql", one(0050600), one(0170700), "Qd%s", m68000up | mcf5200 },
+
+/* The sub opcode can generate the suba, subi, and subq instructions. */
+{"subb", one(0050400), one(0170700), "Qd%s", m68000up },
+{"subb", one(0002000), one(0177700), "#b$s", m68000up },
+{"subb", one(0110000), one(0170700), ";bDd", m68000up },
+{"subb", one(0110400), one(0170700), "Dd~s", m68000up },
+{"subw", one(0050500), one(0170700), "Qd%s", m68000up },
+{"subw", one(0002100), one(0177700), "#w$s", m68000up },
+{"subw", one(0110300), one(0170700), "*wAd", m68000up },
+{"subw", one(0110100), one(0170700), "*wDd", m68000up },
+{"subw", one(0110500), one(0170700), "Dd~s", m68000up },
+{"subl", one(0050600), one(0170700), "Qd%s", m68000up | mcf5200 },
+{"subl", one(0002200), one(0177700), "#l$s", m68000up },
+{"subl", one(0002200), one(0177700), "#lDs", mcf5200 },
+{"subl", one(0110700), one(0170700), "*lAd", m68000up | mcf5200 },
+{"subl", one(0110200), one(0170700), "*lDd", m68000up | mcf5200 },
+{"subl", one(0110600), one(0170700), "Dd~s", m68000up | mcf5200 },
+
+{"subxb", one(0110400), one(0170770), "DsDd", m68000up },
+{"subxb", one(0110410), one(0170770), "-s-d", m68000up },
+{"subxw", one(0110500), one(0170770), "DsDd", m68000up },
+{"subxw", one(0110510), one(0170770), "-s-d", m68000up },
+{"subxl", one(0110600), one(0170770), "DsDd", m68000up | mcf5200 },
+{"subxl", one(0110610), one(0170770), "-s-d", m68000up },
+
+{"swap", one(0044100), one(0177770), "Ds", m68000up | mcf5200 },
+
+/* swbeg and swbegl are magic constants used on sysV68. The compiler
+ generates them before a switch table. They tell the debugger and
+ disassembler that a switch table follows. The parameter is the
+ number of elements in the table. swbeg means that the entries in
+ the table are word (2 byte) sized, and swbegl means that the
+ entries in the table are longword (4 byte) sized. */
+{"swbeg", one(0045374), one(0177777), "#w", m68000up | mcf5200 },
+{"swbegl", one(0045375), one(0177777), "#l", m68000up | mcf5200 },
+
+{"tas", one(0045300), one(0177700), "$s", m68000up },
+
+#define TBL1(name,signed,round,size) \
+ {name, two(0174000, (signed<<11)|(!round<<10)|(size<<6)|0000400), \
+ two(0177700,0107777), "!sD1", cpu32 }, \
+ {name, two(0174000, (signed<<11)|(!round<<10)|(size<<6)), \
+ two(0177770,0107770), "DsD3D1", cpu32 }
+#define TBL(name1, name2, name3, s, r) \
+ TBL1(name1, s, r, 0), TBL1(name2, s, r, 1), TBL1(name3, s, r, 2)
+TBL("tblsb", "tblsw", "tblsl", 1, 1),
+TBL("tblsnb", "tblsnw", "tblsnl", 1, 0),
+TBL("tblub", "tbluw", "tblul", 0, 1),
+TBL("tblunb", "tblunw", "tblunl", 0, 0),
+
+{"trap", one(0047100), one(0177760), "Ts", m68000up | mcf5200 },
+
+{"trapcc", one(0052374), one(0177777), "", m68020up | cpu32 },
+{"trapcs", one(0052774), one(0177777), "", m68020up | cpu32 },
+{"trapeq", one(0053774), one(0177777), "", m68020up | cpu32 },
+{"trapf", one(0050774), one(0177777), "", m68020up | cpu32 | mcf5200 },
+{"trapge", one(0056374), one(0177777), "", m68020up | cpu32 },
+{"trapgt", one(0057374), one(0177777), "", m68020up | cpu32 },
+{"traphi", one(0051374), one(0177777), "", m68020up | cpu32 },
+{"traple", one(0057774), one(0177777), "", m68020up | cpu32 },
+{"trapls", one(0051774), one(0177777), "", m68020up | cpu32 },
+{"traplt", one(0056774), one(0177777), "", m68020up | cpu32 },
+{"trapmi", one(0055774), one(0177777), "", m68020up | cpu32 },
+{"trapne", one(0053374), one(0177777), "", m68020up | cpu32 },
+{"trappl", one(0055374), one(0177777), "", m68020up | cpu32 },
+{"trapt", one(0050374), one(0177777), "", m68020up | cpu32 },
+{"trapvc", one(0054374), one(0177777), "", m68020up | cpu32 },
+{"trapvs", one(0054774), one(0177777), "", m68020up | cpu32 },
+
+{"trapccw", one(0052372), one(0177777), "#w", m68020up|cpu32 },
+{"trapcsw", one(0052772), one(0177777), "#w", m68020up|cpu32 },
+{"trapeqw", one(0053772), one(0177777), "#w", m68020up|cpu32 },
+{"trapfw", one(0050772), one(0177777), "#w", m68020up|cpu32|mcf5200},
+{"trapgew", one(0056372), one(0177777), "#w", m68020up|cpu32 },
+{"trapgtw", one(0057372), one(0177777), "#w", m68020up|cpu32 },
+{"traphiw", one(0051372), one(0177777), "#w", m68020up|cpu32 },
+{"traplew", one(0057772), one(0177777), "#w", m68020up|cpu32 },
+{"traplsw", one(0051772), one(0177777), "#w", m68020up|cpu32 },
+{"trapltw", one(0056772), one(0177777), "#w", m68020up|cpu32 },
+{"trapmiw", one(0055772), one(0177777), "#w", m68020up|cpu32 },
+{"trapnew", one(0053372), one(0177777), "#w", m68020up|cpu32 },
+{"trapplw", one(0055372), one(0177777), "#w", m68020up|cpu32 },
+{"traptw", one(0050372), one(0177777), "#w", m68020up|cpu32 },
+{"trapvcw", one(0054372), one(0177777), "#w", m68020up|cpu32 },
+{"trapvsw", one(0054772), one(0177777), "#w", m68020up|cpu32 },
+
+{"trapccl", one(0052373), one(0177777), "#l", m68020up|cpu32 },
+{"trapcsl", one(0052773), one(0177777), "#l", m68020up|cpu32 },
+{"trapeql", one(0053773), one(0177777), "#l", m68020up|cpu32 },
+{"trapfl", one(0050773), one(0177777), "#l", m68020up|cpu32|mcf5200},
+{"trapgel", one(0056373), one(0177777), "#l", m68020up|cpu32 },
+{"trapgtl", one(0057373), one(0177777), "#l", m68020up|cpu32 },
+{"traphil", one(0051373), one(0177777), "#l", m68020up|cpu32 },
+{"traplel", one(0057773), one(0177777), "#l", m68020up|cpu32 },
+{"traplsl", one(0051773), one(0177777), "#l", m68020up|cpu32 },
+{"trapltl", one(0056773), one(0177777), "#l", m68020up|cpu32 },
+{"trapmil", one(0055773), one(0177777), "#l", m68020up|cpu32 },
+{"trapnel", one(0053373), one(0177777), "#l", m68020up|cpu32 },
+{"trappll", one(0055373), one(0177777), "#l", m68020up|cpu32 },
+{"traptl", one(0050373), one(0177777), "#l", m68020up|cpu32 },
+{"trapvcl", one(0054373), one(0177777), "#l", m68020up|cpu32 },
+{"trapvsl", one(0054773), one(0177777), "#l", m68020up|cpu32 },
+
+{"trapv", one(0047166), one(0177777), "", m68000up },
+
+{"tstb", one(0045000), one(0177700), ";b", m68020up|cpu32|mcf5200 },
+{"tstb", one(0045000), one(0177700), "$b", m68000up },
+{"tstw", one(0045100), one(0177700), "*w", m68020up|cpu32|mcf5200 },
+{"tstw", one(0045100), one(0177700), "$w", m68000up },
+{"tstl", one(0045200), one(0177700), "*l", m68020up|cpu32|mcf5200 },
+{"tstl", one(0045200), one(0177700), "$l", m68000up },
+
+{"unlk", one(0047130), one(0177770), "As", m68000up | mcf5200 },
+
+{"unpk", one(0100600), one(0170770), "DsDd#w", m68020up },
+{"unpk", one(0100610), one(0170770), "-s-d#w", m68020up },
+
+{"wddatab", one(0172000), one(0177700), "~s", mcf5200 },
+{"wddataw", one(0172100), one(0177700), "~s", mcf5200 },
+{"wddatal", one(0172200), one(0177700), "~s", mcf5200 },
+
+};
+
+const int m68k_numopcodes = sizeof m68k_opcodes / sizeof m68k_opcodes[0];
+
+/* These aliases used to be in the above table, each one duplicating
+ all of the entries for its primary exactly. This table was
+ constructed by mechanical processing of the opcode table, with a
+ small number of tweaks done by hand. There are probably a lot more
+ aliases above that could be moved down here, except for very minor
+ differences. */
+
+const struct m68k_opcode_alias m68k_opcode_aliases[] =
+{
+ { "add", "addw", },
+ { "adda", "addaw", },
+ { "addi", "addiw", },
+ { "addq", "addqw", },
+ { "addx", "addxw", },
+ { "asl", "aslw", },
+ { "asr", "asrw", },
+ { "bhi", "bhiw", },
+ { "bls", "blsw", },
+ { "bcc", "bccw", },
+ { "bcs", "bcsw", },
+ { "bne", "bnew", },
+ { "beq", "beqw", },
+ { "bvc", "bvcw", },
+ { "bvs", "bvsw", },
+ { "bpl", "bplw", },
+ { "bmi", "bmiw", },
+ { "bge", "bgew", },
+ { "blt", "bltw", },
+ { "bgt", "bgtw", },
+ { "ble", "blew", },
+ { "bra", "braw", },
+ { "bsr", "bsrw", },
+ { "bhib", "bhis", },
+ { "blsb", "blss", },
+ { "bccb", "bccs", },
+ { "bcsb", "bcss", },
+ { "bneb", "bnes", },
+ { "beqb", "beqs", },
+ { "bvcb", "bvcs", },
+ { "bvsb", "bvss", },
+ { "bplb", "bpls", },
+ { "bmib", "bmis", },
+ { "bgeb", "bges", },
+ { "bltb", "blts", },
+ { "bgtb", "bgts", },
+ { "bleb", "bles", },
+ { "brab", "bras", },
+ { "bsrb", "bsrs", },
+ { "bhs", "bccw" },
+ { "bhss", "bccs" },
+ { "bhsb", "bccs" },
+ { "bhsw", "bccw" },
+ { "bhsl", "bccl" },
+ { "blo", "bcsw" },
+ { "blos", "bcss" },
+ { "blob", "bcss" },
+ { "blow", "bcsw" },
+ { "blol", "bcsl" },
+ { "br", "braw", },
+ { "brs", "bras", },
+ { "brb", "bras", },
+ { "brw", "braw", },
+ { "brl", "bral", },
+ { "jfnlt", "bcc", }, /* apparently a sun alias */
+ { "jfngt", "ble", }, /* apparently a sun alias */
+ { "jfeq", "beqs", }, /* apparently a sun alias */
+ { "bchgb", "bchg", },
+ { "bchgl", "bchg", },
+ { "bclrb", "bclr", },
+ { "bclrl", "bclr", },
+ { "bsetb", "bset", },
+ { "bsetl", "bset", },
+ { "btstb", "btst", },
+ { "btstl", "btst", },
+ { "cas2", "cas2w", },
+ { "cas", "casw", },
+ { "chk2", "chk2w", },
+ { "chk", "chkw", },
+ { "clr", "clrw", },
+ { "cmp2", "cmp2w", },
+ { "cmpa", "cmpaw", },
+ { "cmpi", "cmpiw", },
+ { "cmpm", "cmpmw", },
+ { "cmp", "cmpw", },
+ { "dbccw", "dbcc", },
+ { "dbcsw", "dbcs", },
+ { "dbeqw", "dbeq", },
+ { "dbfw", "dbf", },
+ { "dbgew", "dbge", },
+ { "dbgtw", "dbgt", },
+ { "dbhiw", "dbhi", },
+ { "dblew", "dble", },
+ { "dblsw", "dbls", },
+ { "dbltw", "dblt", },
+ { "dbmiw", "dbmi", },
+ { "dbnew", "dbne", },
+ { "dbplw", "dbpl", },
+ { "dbtw", "dbt", },
+ { "dbvcw", "dbvc", },
+ { "dbvsw", "dbvs", },
+ { "dbhs", "dbcc", },
+ { "dbhsw", "dbcc", },
+ { "dbra", "dbf", },
+ { "dbraw", "dbf", },
+ { "tdivsl", "divsl", },
+ { "divs", "divsw", },
+ { "divu", "divuw", },
+ { "ext", "extw", },
+ { "extbw", "extw", },
+ { "extwl", "extl", },
+ { "fbneq", "fbne", },
+ { "fbsneq", "fbsne", },
+ { "fdbneq", "fdbne", },
+ { "fdbsneq", "fdbsne", },
+ { "fmovecr", "fmovecrx", },
+ { "fmovm", "fmovem", },
+ { "fsneq", "fsne", },
+ { "fssneq", "fssne", },
+ { "ftrapneq", "ftrapne", },
+ { "ftrapsneq", "ftrapsne", },
+ { "fjneq", "fjne", },
+ { "fjsneq", "fjsne", },
+ { "jmpl", "jmp", },
+ { "jmps", "jmp", },
+ { "jsrl", "jsr", },
+ { "jsrs", "jsr", },
+ { "leal", "lea", },
+ { "lsl", "lslw", },
+ { "lsr", "lsrw", },
+ { "movea", "moveaw", },
+ { "movem", "movemw", },
+ { "movml", "moveml", },
+ { "movmw", "movemw", },
+ { "movm", "movemw", },
+ { "movep", "movepw", },
+ { "movpw", "movepw", },
+ { "moves", "movesw" },
+ { "muls", "mulsw", },
+ { "mulu", "muluw", },
+ { "nbcdb", "nbcd" },
+ { "neg", "negw", },
+ { "negx", "negxw", },
+ { "not", "notw", },
+ { "peal", "pea", },
+ { "rol", "rolw", },
+ { "ror", "rorw", },
+ { "roxl", "roxlw", },
+ { "roxr", "roxrw", },
+ { "sbcdb", "sbcd", },
+ { "sccb", "scc", },
+ { "scsb", "scs", },
+ { "seqb", "seq", },
+ { "sfb", "sf", },
+ { "sgeb", "sge", },
+ { "sgtb", "sgt", },
+ { "shib", "shi", },
+ { "sleb", "sle", },
+ { "slsb", "sls", },
+ { "sltb", "slt", },
+ { "smib", "smi", },
+ { "sneb", "sne", },
+ { "splb", "spl", },
+ { "stb", "st", },
+ { "svcb", "svc", },
+ { "svsb", "svs", },
+ { "sfge", "sge", },
+ { "sfgt", "sgt", },
+ { "sfle", "sle", },
+ { "sflt", "slt", },
+ { "sfneq", "sne", },
+ { "suba", "subaw", },
+ { "subi", "subiw", },
+ { "subq", "subqw", },
+ { "sub", "subw", },
+ { "subx", "subxw", },
+ { "swapw", "swap", },
+ { "tasb", "tas", },
+ { "tpcc", "trapcc", },
+ { "tcc", "trapcc", },
+ { "tst", "tstw", },
+ { "jbra", "jra", },
+ { "jbhi", "jhi", },
+ { "jbls", "jls", },
+ { "jbcc", "jcc", },
+ { "jbcs", "jcs", },
+ { "jbne", "jne", },
+ { "jbeq", "jeq", },
+ { "jbvc", "jvc", },
+ { "jbvs", "jvs", },
+ { "jbpl", "jpl", },
+ { "jbmi", "jmi", },
+ { "jbge", "jge", },
+ { "jblt", "jlt", },
+ { "jbgt", "jgt", },
+ { "jble", "jle", },
+ { "movql", "moveq", },
+ { "moveql", "moveq", },
+ { "movl", "movel", },
+ { "movq", "moveq", },
+ { "moval", "moveal", },
+ { "movaw", "moveaw", },
+ { "movb", "moveb", },
+ { "movc", "movec", },
+ { "movecl", "movec", },
+ { "movpl", "movepl", },
+ { "movw", "movew", },
+ { "movsb", "movesb", },
+ { "movsl", "movesl", },
+ { "movsw", "movesw", },
+
+ { "tdivul", "divul", }, /* for m68k-svr4 */
+ { "fmovb", "fmoveb", },
+ { "fsmovb", "fsmoveb", },
+ { "fdmovb", "fdmoveb", },
+ { "fmovd", "fmoved", },
+ { "fsmovd", "fsmoved", },
+ { "fmovl", "fmovel", },
+ { "fsmovl", "fsmovel", },
+ { "fdmovl", "fdmovel", },
+ { "fmovp", "fmovep", },
+ { "fsmovp", "fsmovep", },
+ { "fdmovp", "fdmovep", },
+ { "fmovs", "fmoves", },
+ { "fsmovs", "fsmoves", },
+ { "fdmovs", "fdmoves", },
+ { "fmovw", "fmovew", },
+ { "fsmovw", "fsmovew", },
+ { "fdmovw", "fdmovew", },
+ { "fmovx", "fmovex", },
+ { "fsmovx", "fsmovex", },
+ { "fdmovx", "fdmovex", },
+ { "fmovcr", "fmovecr", },
+ { "fmovcrx", "fmovecrx", },
+ { "ftestb", "ftstb", },
+ { "ftestd", "ftstd", },
+ { "ftestl", "ftstl", },
+ { "ftestp", "ftstp", },
+ { "ftests", "ftsts", },
+ { "ftestw", "ftstw", },
+ { "ftestx", "ftstx", },
+};
+
+const int m68k_numaliases =
+ sizeof m68k_opcode_aliases / sizeof m68k_opcode_aliases[0];
diff --git a/opcodes/m88k-dis.c b/opcodes/m88k-dis.c
new file mode 100644
index 00000000000..8af6b87929b
--- /dev/null
+++ b/opcodes/m88k-dis.c
@@ -0,0 +1,330 @@
+/* Print instructions for the Motorola 88000, for GDB and GNU Binutils.
+ Copyright (c) 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1998
+ Free Software Foundation, Inc.
+ Contributed by Data General Corporation, November 1989.
+ Partially derived from an earlier printcmd.c.
+
+This file is part of GDB and the GNU Binutils.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "dis-asm.h"
+#include "opcode/m88k.h"
+#include "opintl.h"
+
+INSTAB *hashtable[HASHVAL] = {0};
+
+static int
+m88kdis PARAMS ((bfd_vma, unsigned long, struct disassemble_info *));
+
+static void
+printop PARAMS ((struct disassemble_info *, OPSPEC *,
+ unsigned long, bfd_vma, int));
+
+static void
+init_disasm PARAMS ((void));
+
+static void
+install PARAMS ((INSTAB *instptr));
+
+/*
+* Disassemble an M88000 Instruction
+*
+*
+* This module decodes the instruction at memaddr.
+*
+* Revision History
+*
+* Revision 1.0 11/08/85 Creation date by Motorola
+* 05/11/89 R. Trawick adapted to GDB interface.
+* 07/12/93 Ian Lance Taylor updated to
+* binutils interface.
+*/
+
+int
+print_insn_m88k (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ bfd_byte buffer[4];
+ int status;
+
+ /* Instruction addresses may have low two bits set. Clear them. */
+ memaddr &=~ (bfd_vma) 3;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ return m88kdis (memaddr, bfd_getb32 (buffer), info);
+}
+
+/*
+ * disassemble the instruction in 'instruction'.
+ * 'pc' should be the address of this instruction, it will
+ * be used to print the target address if this is a relative jump or call
+ * the disassembled instruction is written to 'info'.
+ * The function returns the length of this instruction in bytes.
+ */
+
+static int
+m88kdis (pc, instruction, info)
+ bfd_vma pc;
+ unsigned long instruction;
+ struct disassemble_info *info;
+{
+ static int ihashtab_initialized = 0;
+ unsigned int opcode;
+ INSTAB *entry_ptr;
+ int opmask;
+ unsigned int class;
+
+ if (! ihashtab_initialized)
+ init_disasm ();
+
+ /* create the appropriate mask to isolate the opcode */
+ opmask = DEFMASK;
+ class = instruction & DEFMASK;
+ if ((class >= SFU0) && (class <= SFU7))
+ {
+ if (instruction < SFU1)
+ opmask = CTRLMASK;
+ else
+ opmask = SFUMASK;
+ }
+ else if (class == RRR)
+ opmask = RRRMASK;
+ else if (class == RRI10)
+ opmask = RRI10MASK;
+
+ /* isolate the opcode */
+ opcode = instruction & opmask;
+
+ /* search the hash table with the isolated opcode */
+ for (entry_ptr = hashtable[opcode % HASHVAL];
+ (entry_ptr != NULL) && (entry_ptr->opcode != opcode);
+ entry_ptr = entry_ptr->next)
+ ;
+
+ if (entry_ptr == NULL)
+ (*info->fprintf_func) (info->stream, "word\t%08x", instruction);
+ else
+ {
+ (*info->fprintf_func) (info->stream, "%s", entry_ptr->mnemonic);
+ printop (info, &(entry_ptr->op1), instruction, pc, 1);
+ printop (info, &(entry_ptr->op2), instruction, pc, 0);
+ printop (info, &(entry_ptr->op3), instruction, pc, 0);
+ }
+
+ return 4;
+}
+
+/*
+* Decode an Operand of an Instruction
+*
+* Functional Description
+*
+* This module formats and writes an operand of an instruction to info
+* based on the operand specification. When the first flag is set this
+* is the first operand of an instruction. Undefined operand types
+* cause a <dis error> message.
+*
+* Parameters
+* disassemble_info where the operand may be printed
+* OPSPEC *opptr Pointer to an operand specification
+* UINT inst Instruction from which operand is extracted
+* UINT pc PC of instruction; used for pc-relative disp.
+* int first Flag which if nonzero indicates the first
+* operand of an instruction
+*
+* Output
+*
+* The operand specified is extracted from the instruction and is
+* written to buf in the format specified. The operand is preceded
+* by a comma if it is not the first operand of an instruction and it
+* is not a register indirect form. Registers are preceded by 'r' and
+* hex values by '0x'.
+*
+* Revision History
+*
+* Revision 1.0 11/08/85 Creation date
+*/
+
+static void
+printop (info, opptr, inst, pc, first)
+ struct disassemble_info *info;
+ OPSPEC *opptr;
+ unsigned long inst;
+ bfd_vma pc;
+ int first;
+{
+ int extracted_field;
+ char *cond_mask_sym;
+
+ if (opptr->width == 0)
+ return;
+
+ if (! first)
+ {
+ switch (opptr->type)
+ {
+ case REGSC:
+ case CONT:
+ break;
+ default:
+ (*info->fprintf_func) (info->stream, ",");
+ break;
+ }
+ }
+
+ switch (opptr->type)
+ {
+ case CRREG:
+ (*info->fprintf_func) (info->stream, "cr%d",
+ UEXT (inst, opptr->offset, opptr->width));
+ break;
+
+ case FCRREG:
+ (*info->fprintf_func) (info->stream, "fcr%d",
+ UEXT (inst, opptr->offset, opptr->width));
+ break;
+
+ case REGSC:
+ (*info->fprintf_func) (info->stream, "[r%d]",
+ UEXT (inst, opptr->offset, opptr->width));
+ break;
+
+ case REG:
+ (*info->fprintf_func) (info->stream, "r%d",
+ UEXT (inst, opptr->offset, opptr->width));
+ break;
+
+ case XREG:
+ (*info->fprintf_func) (info->stream, "x%d",
+ UEXT (inst, opptr->offset, opptr->width));
+ break;
+
+ case HEX:
+ extracted_field = UEXT (inst, opptr->offset, opptr->width);
+ if (extracted_field == 0)
+ (*info->fprintf_func) (info->stream, "0");
+ else
+ (*info->fprintf_func) (info->stream, "0x%02x", extracted_field);
+ break;
+
+ case DEC:
+ extracted_field = UEXT (inst, opptr->offset, opptr->width);
+ (*info->fprintf_func) (info->stream, "%d", extracted_field);
+ break;
+
+ case CONDMASK:
+ extracted_field = UEXT (inst, opptr->offset, opptr->width);
+ switch (extracted_field & 0x0f)
+ {
+ case 0x1: cond_mask_sym = "gt0"; break;
+ case 0x2: cond_mask_sym = "eq0"; break;
+ case 0x3: cond_mask_sym = "ge0"; break;
+ case 0xc: cond_mask_sym = "lt0"; break;
+ case 0xd: cond_mask_sym = "ne0"; break;
+ case 0xe: cond_mask_sym = "le0"; break;
+ default: cond_mask_sym = NULL; break;
+ }
+ if (cond_mask_sym != NULL)
+ (*info->fprintf_func) (info->stream, "%s", cond_mask_sym);
+ else
+ (*info->fprintf_func) (info->stream, "%x", extracted_field);
+ break;
+
+ case PCREL:
+ (*info->print_address_func)
+ (pc + (4 * (SEXT (inst, opptr->offset, opptr->width))),
+ info);
+ break;
+
+ case CONT:
+ (*info->fprintf_func) (info->stream, "%d,r%d",
+ UEXT (inst, opptr->offset, 5),
+ UEXT (inst, (opptr->offset) + 5, 5));
+ break;
+
+ case BF:
+ (*info->fprintf_func) (info->stream, "%d<%d>",
+ UEXT (inst, (opptr->offset) + 5, 5),
+ UEXT (inst, opptr->offset, 5));
+ break;
+
+ default:
+ /* xgettext:c-format */
+ (*info->fprintf_func) (info->stream, _("# <dis error: %08x>"), inst);
+ }
+}
+
+/*
+* Initialize the Disassembler Instruction Table
+*
+* Initialize the hash table and instruction table for the disassembler.
+* This should be called once before the first call to disasm().
+*
+* Parameters
+*
+* Output
+*
+* If the debug option is selected, certain statistics about the hashing
+* distribution are written to stdout.
+*
+* Revision History
+*
+* Revision 1.0 11/08/85 Creation date
+*/
+
+static void
+init_disasm ()
+{
+ int i, size;
+
+ for (i = 0; i < HASHVAL; i++)
+ hashtable[i] = NULL;
+
+ size = sizeof (instructions) / sizeof (INSTAB);
+ for (i = 0; i < size; i++)
+ install (&instructions[i]);
+}
+
+/*
+* Insert an instruction into the disassembler table by hashing the
+* opcode and inserting it into the linked list for that hash value.
+*
+* Parameters
+*
+* INSTAB *instptr Pointer to the entry in the instruction table
+* to be installed
+*
+* Revision 1.0 11/08/85 Creation date
+* 05/11/89 R. TRAWICK ADAPTED FROM MOTOROLA
+*/
+
+static void
+install (instptr)
+ INSTAB *instptr;
+{
+ unsigned int i;
+
+ i = (instptr->opcode) % HASHVAL;
+ instptr->next = hashtable[i];
+ hashtable[i] = instptr;
+}
diff --git a/opcodes/makefile.vms b/opcodes/makefile.vms
new file mode 100644
index 00000000000..fc8704831e0
--- /dev/null
+++ b/opcodes/makefile.vms
@@ -0,0 +1,42 @@
+#
+# Makefile for libopcodes under openVMS VAX and Alpha
+#
+# For use with gnu-make for vms
+#
+# Created by Klaus K"ampf, kkaempf@progis.de
+#
+#
+ifeq ($(ARCH),alpha)
+OBJS=alpha-dis.obj,alpha-opc.obj,dis-buf.obj,disassemble.obj
+FORMAT=OBJ_EVAX
+ARCHDEF="ARCH_alpha"
+else
+OBJS=vax-dis.obj,dis-buf.obj,disassemble.obj
+FORMAT=OBJ_VAX
+ARCHDEF="ARCH_vax"
+endif
+
+ifeq ($(CC),gcc)
+DEFS=/define=($(FORMAT))
+CFLAGS=/include=([],[-.include],[-.bfd])$(DEFS)
+else
+DEFS=/define=($(FORMAT),"const=")
+CFLAGS=/noopt/debug/include=([],[-.include],[-.bfd])$(DEFS)\
+/warnings=disable=(missingreturn,implicitfunc,longextern)
+endif
+
+libopcodes.olb: sysdep.h $(OBJS)
+ purge
+ lib/create libopcodes *.obj
+
+disassemble.obj: disassemble.c
+ $(CC)$(CFLAGS)/define=($(ARCHDEF)) $<
+
+sysdep.h: [-.bfd.hosts]$(ARCH)vms.h
+ $(CP) $< $@
+
+clean:
+ $$ purge
+ $(RM) *.obj;
+ $(RM) sysdep.h;
+ $(RM) libopcodes.olb;
diff --git a/opcodes/mcore-dis.c b/opcodes/mcore-dis.c
new file mode 100644
index 00000000000..42c1793b6d7
--- /dev/null
+++ b/opcodes/mcore-dis.c
@@ -0,0 +1,250 @@
+/* Disassemble Motorolla M*Core instructions.
+ Copyright (C) 1993, 1999 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+#define STATIC_TABLE
+#define DEFINE_TABLE
+
+#include "mcore-opc.h"
+#include "dis-asm.h"
+
+/* Mask for each mcore_opclass: */
+static const unsigned short imsk[] =
+{
+ /* O0 */ 0xFFFF,
+ /* OT */ 0xFFFC,
+ /* O1 */ 0xFFF0,
+ /* OC */ 0xFFE0,
+ /* O2 */ 0xFF00,
+ /* X1 */ 0xFFF0,
+ /* OI */ 0xFE00,
+ /* OB */ 0xFE00,
+
+ /* OMa */ 0xFFF0,
+ /* SI */ 0xFE00,
+ /* I7 */ 0xF800,
+ /* LS */ 0xF000,
+ /* BR */ 0xF800,
+ /* BL */ 0xFF00,
+ /* LR */ 0xF000,
+ /* LJ */ 0xFF00,
+
+ /* RM */ 0xFFF0,
+ /* RQ */ 0xFFF0,
+ /* JSR */ 0xFFF0,
+ /* JMP */ 0xFFF0,
+ /* OBRa*/ 0xFFF0,
+ /* OBRb*/ 0xFF80,
+ /* OBRc*/ 0xFF00,
+ /* OBR2*/ 0xFE00,
+
+ /* O1R1*/ 0xFFF0,
+ /* OMb */ 0xFF80,
+ /* OMc */ 0xFF00,
+ /* SIa */ 0xFE00,
+
+
+ /* JC */ 0, /* JC,JU,JL don't appear in object */
+ /* JU */ 0,
+ /* JL */ 0,
+ /* RSI */ 0,
+ /* DO21*/ 0,
+ /* OB2 */ 0 /* OB2 won't appear in object. */
+};
+
+static const char * grname[] =
+{
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
+};
+
+static const char X[] = "??";
+
+static const char * crname[] =
+{
+ "psr", "vbr", "epsr", "fpsr", "epc", "fpc", "ss0", "ss1",
+ "ss2", "ss3", "ss4", "gcr", "gsr", X, X, X,
+ X, X, X, X, X, X, X, X,
+ X, X, X, X, X, X, X, X
+};
+
+static const unsigned isiz[] = { 2, 0, 1, 0 };
+
+int
+print_insn_mcore (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info * info;
+{
+ unsigned char ibytes[4];
+ fprintf_ftype fprintf = info->fprintf_func;
+ void * stream = info->stream;
+ unsigned short inst;
+ mcore_opcode_info * op;
+ int status;
+
+ status = info->read_memory_func (memaddr, ibytes, 2, info);
+
+ if (status != 0)
+ {
+ info->memory_error_func (status, memaddr, info);
+ return -1;
+ }
+
+ inst = (ibytes[0] << 8) | ibytes[1];
+
+ /* Just a linear search of the table. */
+ for (op = mcore_table; op->name != 0; op ++)
+ {
+ if (op->inst == (inst & imsk[op->opclass]))
+ break;
+ }
+
+ if (op->name == 0)
+ fprintf (stream, ".word 0x%04x", inst);
+ else
+ {
+ const char * name = grname[inst & 0x0F];
+
+ fprintf (stream, "%s", op->name);
+
+ switch (op->opclass)
+ {
+ case O0: break;
+ case OT: fprintf (stream, "\t%d", inst & 0x3); break;
+ case O1:
+ case JMP:
+ case JSR: fprintf (stream, "\t%s", name); break;
+ case OC: fprintf (stream, "\t%s, %s", name, crname[(inst >> 4) & 0x1F]); break;
+ case O1R1: fprintf (stream, "\t%s, r1", name); break;
+ case O2: fprintf (stream, "\t%s, %s", name, grname[(inst >> 4) & 0xF]); break;
+ case X1: fprintf (stream, "\tr1, %s", name); break;
+ case OI: fprintf (stream, "\t%s, %d", name, ((inst >> 4) & 0x1F) + 1); break;
+ case RM: fprintf (stream, "\t%s-r15, (r0)", name); break;
+ case RQ: fprintf (stream, "\tr4-r7, (%s)", name); break;
+ case OB:
+ case OBRa:
+ case OBRb:
+ case OBRc:
+ case SI:
+ case SIa:
+ case OMa:
+ case OMb:
+ case OMc: fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x1F); break;
+ case I7: fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x7F); break;
+ case LS: fprintf (stream, "\t%s, (%s, %d)", grname[(inst >> 8) & 0xF],
+ name, ((inst >> 4) & 0xF) << isiz[(inst >> 13) & 3]);
+ break;
+
+ case BR:
+ {
+ long val = inst & 0x3FF;
+
+ if (inst & 0x400)
+ val |= 0xFFFFFC00;
+
+ fprintf (stream, "\t0x%x", memaddr + 2 + (val<<1));
+
+ if (strcmp (op->name, "bsr") == 0)
+ {
+ /* for bsr, we'll try to get a symbol for the target */
+ val = memaddr + 2 + (val << 1);
+
+ if (info->print_address_func && val != 0)
+ {
+ fprintf (stream, "\t// ");
+ info->print_address_func (val, info);
+ }
+ }
+ }
+ break;
+
+ case BL:
+ {
+ long val;
+ val = (inst & 0x000F);
+ fprintf (stream, "\t%s, 0x%x",
+ grname[(inst >> 4) & 0xF], memaddr - (val << 1));
+ }
+ break;
+
+ case LR:
+ {
+ unsigned long val;
+
+ val = (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC;
+
+ status = info->read_memory_func (val, ibytes, 4, info);
+ if (status != 0)
+ {
+ info->memory_error_func (status, memaddr, info);
+ return -1;
+ }
+
+ val = (ibytes[0] << 24) | (ibytes[1] << 16)
+ | (ibytes[2] << 8) | (ibytes[3]);
+
+ /* Removed [] around literal value to match ABI syntax 12/95. */
+ fprintf (stream, "\t%s, 0x%X", grname[(inst >> 8) & 0xF], val);
+
+ if (val == 0)
+ fprintf (stream, "\t// from address pool at 0x%x",
+ (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
+ }
+ break;
+
+ case LJ:
+ {
+ unsigned long val;
+
+ val = (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC;
+
+ status = info->read_memory_func (val, ibytes, 4, info);
+ if (status != 0)
+ {
+ info->memory_error_func (status, memaddr, info);
+ return -1;
+ }
+
+ val = (ibytes[0] << 24) | (ibytes[1] << 16)
+ | (ibytes[2] << 8) | (ibytes[3]);
+
+ /* Removed [] around literal value to match ABI syntax 12/95. */
+ fprintf (stream, "\t0x%X", val);
+ /* For jmpi/jsri, we'll try to get a symbol for the target. */
+ if (info->print_address_func && val != 0)
+ {
+ fprintf (stream, "\t// ");
+ info->print_address_func (val, info);
+ }
+ else
+ {
+ fprintf (stream, "\t// from address pool at 0x%x",
+ (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
+ }
+ }
+ break;
+
+ default:
+ /* if the disassembler lags the instruction set */
+ fprintf (stream, "\tundecoded operands, inst is 0x%04x", inst);
+ break;
+ }
+ }
+
+ /* Say how many bytes we consumed? */
+ return 2;
+}
diff --git a/opcodes/mcore-opc.h b/opcodes/mcore-opc.h
new file mode 100644
index 00000000000..606ba846efd
--- /dev/null
+++ b/opcodes/mcore-opc.h
@@ -0,0 +1,202 @@
+/* Assembler instructions for Motorolla's Mcore processor
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+
+typedef enum
+{
+ O0, OT, O1, OC, O2, X1, OI, OB,
+ OMa, SI, I7, LS, BR, BL, LR, LJ,
+ RM, RQ, JSR, JMP, OBRa, OBRb, OBRc, OBR2,
+ O1R1, OMb, OMc, SIa,
+ JC, JU, JL, RSI, DO21, OB2
+}
+mcore_opclass;
+
+typedef struct inst
+{
+ char * name;
+ mcore_opclass opclass;
+ unsigned char transfer;
+ unsigned short inst;
+}
+mcore_opcode_info;
+
+#ifdef DEFINE_TABLE
+mcore_opcode_info mcore_table[] =
+{
+ { "bkpt", O0, 0, 0x0000 },
+ { "sync", O0, 0, 0x0001 },
+ { "rte", O0, 1, 0x0002 },
+ { "rfe", O0, 1, 0x0002 },
+ { "rfi", O0, 1, 0x0003 },
+ { "stop", O0, 0, 0x0004 },
+ { "wait", O0, 0, 0x0005 },
+ { "doze", O0, 0, 0x0006 },
+ { "trap", OT, 0, 0x0008 },
+/* SPACE: 0x000C - 0x000F */
+/* SPACE: 0x0010 - 0x001F */
+ { "mvc", O1, 0, 0x0020 },
+ { "mvcv", O1, 0, 0x0030 },
+ { "ldq", RQ, 0, 0x0040 },
+ { "stq", RQ, 0, 0x0050 },
+ { "ldm", RM, 0, 0x0060 },
+ { "stm", RM, 0, 0x0070 },
+ { "dect", O1, 0, 0x0080 },
+ { "decf", O1, 0, 0x0090 },
+ { "inct", O1, 0, 0x00A0 },
+ { "incf", O1, 0, 0x00B0 },
+ { "jmp", JMP, 2, 0x00C0 },
+#define MCORE_INST_JMP 0x00C0
+ { "jsr", JSR, 0, 0x00D0 },
+#define MCORE_INST_JSR 0x00E0
+ { "ff1", O1, 0, 0x00E0 },
+ { "brev", O1, 0, 0x00F0 },
+ { "xtrb3", X1, 0, 0x0100 },
+ { "xtrb2", X1, 0, 0x0110 },
+ { "xtrb1", X1, 0, 0x0120 },
+ { "xtrb0", X1, 0, 0x0130 },
+ { "zextb", O1, 0, 0x0140 },
+ { "sextb", O1, 0, 0x0150 },
+ { "zexth", O1, 0, 0x0160 },
+ { "sexth", O1, 0, 0x0170 },
+ { "declt", O1, 0, 0x0180 },
+ { "tstnbz", O1, 0, 0x0190 },
+ { "decgt", O1, 0, 0x01A0 },
+ { "decne", O1, 0, 0x01B0 },
+ { "clrt", O1, 0, 0x01C0 },
+ { "clrf", O1, 0, 0x01D0 },
+ { "abs", O1, 0, 0x01E0 },
+ { "not", O1, 0, 0x01F0 },
+ { "movt", O2, 0, 0x0200 },
+ { "mult", O2, 0, 0x0300 },
+ { "loopt", BL, 0, 0x0400 },
+ { "subu", O2, 0, 0x0500 },
+ { "sub", O2, 0, 0x0500 }, /* Official alias. */
+ { "addc", O2, 0, 0x0600 },
+ { "subc", O2, 0, 0x0700 },
+/* SPACE: 0x0800-0x08ff for a diadic operation */
+/* SPACE: 0x0900-0x09ff for a diadic operation */
+ { "movf", O2, 0, 0x0A00 },
+ { "lsr", O2, 0, 0x0B00 },
+ { "cmphs", O2, 0, 0x0C00 },
+ { "cmplt", O2, 0, 0x0D00 },
+ { "tst", O2, 0, 0x0E00 },
+ { "cmpne", O2, 0, 0x0F00 },
+ { "mfcr", OC, 0, 0x1000 },
+ { "mov", O2, 0, 0x1200 },
+ { "bgenr", O2, 0, 0x1300 },
+ { "rsub", O2, 0, 0x1400 },
+ { "ixw", O2, 0, 0x1500 },
+ { "and", O2, 0, 0x1600 },
+ { "xor", O2, 0, 0x1700 },
+ { "mtcr", OC, 0, 0x1800 },
+ { "asr", O2, 0, 0x1A00 },
+ { "lsl", O2, 0, 0x1B00 },
+ { "addu", O2, 0, 0x1C00 },
+ { "ixh", O2, 0, 0x1D00 },
+ { "or", O2, 0, 0x1E00 },
+ { "andn", O2, 0, 0x1F00 },
+ { "addi", OI, 0, 0x2000 },
+#define MCORE_INST_ADDI 0x2000
+ { "cmplti", OI, 0, 0x2200 },
+ { "subi", OI, 0, 0x2400 },
+/* SPACE: 0x2600-0x27ff open for a register+immediate operation */
+ { "rsubi", OB, 0, 0x2800 },
+ { "cmpnei", OB, 0, 0x2A00 },
+ { "bmaski", OMa, 0, 0x2C00 },
+ { "divu", O1R1, 0, 0x2C10 },
+/* SPACE: 0x2c20 - 0x2c7f */
+ { "bmaski", OMb, 0, 0x2C80 },
+ { "bmaski", OMc, 0, 0x2D00 },
+ { "andi", OB, 0, 0x2E00 },
+ { "bclri", OB, 0, 0x3000 },
+/* SPACE: 0x3200 - 0x320f */
+ { "divs", O1R1, 0, 0x3210 },
+/* SPACE: 0x3220 - 0x326f */
+ { "bgeni", OBRa, 0, 0x3270 },
+ { "bgeni", OBRb, 0, 0x3280 },
+ { "bgeni", OBRc, 0, 0x3300 },
+ { "bseti", OB, 0, 0x3400 },
+ { "btsti", OB, 0, 0x3600 },
+ { "xsr", O1, 0, 0x3800 },
+ { "rotli", SIa, 0, 0x3800 },
+ { "asrc", O1, 0, 0x3A00 },
+ { "asri", SIa, 0, 0x3A00 },
+ { "lslc", O1, 0, 0x3C00 },
+ { "lsli", SIa, 0, 0x3C00 },
+ { "lsrc", O1, 0, 0x3E00 },
+ { "lsri", SIa, 0, 0x3E00 },
+/* SPACE: 0x4000 - 0x5fff */
+ { "movi", I7, 0, 0x6000 },
+#define MCORE_INST_BMASKI_ALT 0x6000
+#define MCORE_INST_BGENI_ALT 0x6000
+/* SPACE: 0x6900 - 0x6FFF */
+ { "jmpi", LJ, 1, 0x7000 },
+ { "jsri", LJ, 0, 0x7F00 },
+#define MCORE_INST_JMPI 0x7000
+ { "lrw", LR, 0, 0x7000 },
+#define MCORE_INST_JSRI 0x7F00
+ { "ld", LS, 0, 0x8000 },
+ { "ldw", LS, 0, 0x8000 },
+ { "ld.w", LS, 0, 0x8000 },
+ { "st", LS, 0, 0x9000 },
+ { "stw", LS, 0, 0x9000 },
+ { "st.w", LS, 0, 0x9000 },
+ { "ldb", LS, 0, 0xA000 },
+ { "ld.b", LS, 0, 0xA000 },
+ { "stb", LS, 0, 0xB000 },
+ { "st.b", LS, 0, 0xB000 },
+ { "ldh", LS, 0, 0xC000 },
+ { "ld.h", LS, 0, 0xC000 },
+ { "sth", LS, 0, 0xD000 },
+ { "st.h", LS, 0, 0xD000 },
+ { "bt", BR, 0, 0xE000 },
+ { "bf", BR, 0, 0xE800 },
+ { "br", BR, 1, 0xF000 },
+#define MCORE_INST_BR 0xF000
+ { "bsr", BR, 0, 0xF800 },
+#define MCORE_INST_BSR 0xF800
+
+/* The following are relaxable branches */
+ { "jbt", JC, 0, 0xE000 },
+ { "jbf", JC, 0, 0xE800 },
+ { "jbr", JU, 1, 0xF000 },
+ { "jbsr", JL, 0, 0xF800 },
+
+/* The following are aliases for other instructions */
+ { "rts", O0, 2, 0x00CF }, /* jmp r15 */
+ { "rolc", DO21, 0, 0x0600 }, /* addc rd,rd */
+ { "rotlc", DO21, 0, 0x0600 }, /* addc rd,rd */
+ { "setc", O0, 0, 0x0C00 }, /* cmphs r0,r0 */
+ { "clrc", O0, 0, 0x0F00 }, /* cmpne r0,r0 */
+ { "tstle", O1, 0, 0x2200 }, /* cmplti rd,1 */
+ { "cmplei", OB, 0, 0x2200 }, /* cmplei rd,X -> cmplti rd,X+1 */
+ { "neg", O1, 0, 0x2800 }, /* rsubi rd,0 */
+ { "tstne", O1, 0, 0x2A00 }, /* cmpnei rd,0 */
+ { "tstlt", O1, 0, 0x37F0 }, /* btsti rx,31 */
+ { "mclri", OB2, 0, 0x3000 }, /* bclri rx,log2(imm) */
+ { "mgeni", OBR2, 0, 0x3200 }, /* bgeni rx,log2(imm) */
+ { "mseti", OB2, 0, 0x3400 }, /* bseti rx,log2(imm) */
+ { "mtsti", OB2, 0, 0x3600 }, /* btsti rx,log2(imm) */
+ { "rori", RSI, 0, 0x3800 },
+ { "rotri", RSI, 0, 0x3800 },
+ { "nop", O0, 0, 0x1200 }, /* mov r0, r0 */
+ { 0, 0, 0, 0 }
+};
+#endif
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
new file mode 100644
index 00000000000..1e3577cec32
--- /dev/null
+++ b/opcodes/mips-dis.c
@@ -0,0 +1,1068 @@
+/* Print mips instructions for GDB, the GNU debugger, or for objdump.
+ Copyright (c) 1989, 91-97, 1998 Free Software Foundation, Inc.
+ Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp).
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <ansidecl.h>
+#include "sysdep.h"
+#include "dis-asm.h"
+#include "opcode/mips.h"
+#include "opintl.h"
+
+/* FIXME: These are needed to figure out if the code is mips16 or
+ not. The low bit of the address is often a good indicator. No
+ symbol table is available when this code runs out in an embedded
+ system as when it is used for disassembler support in a monitor. */
+
+#if !defined(EMBEDDED_ENV)
+#define SYMTAB_AVAILABLE 1
+#include "elf-bfd.h"
+#include "elf/mips.h"
+#endif
+
+static int print_insn_mips16 PARAMS ((bfd_vma, struct disassemble_info *));
+static void print_mips16_insn_arg
+ PARAMS ((int, const struct mips_opcode *, int, boolean, int, bfd_vma,
+ struct disassemble_info *));
+
+/* Mips instructions are never longer than this many bytes. */
+#define MAXLEN 4
+
+static void print_insn_arg PARAMS ((const char *, unsigned long, bfd_vma,
+ struct disassemble_info *));
+static int _print_insn_mips PARAMS ((bfd_vma, unsigned long int,
+ struct disassemble_info *));
+
+
+/* FIXME: This should be shared with gdb somehow. */
+#define REGISTER_NAMES \
+ { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", \
+ "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", \
+ "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \
+ "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", \
+ "sr", "lo", "hi", "bad", "cause","pc", \
+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
+ "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",\
+ "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",\
+ "fsr", "fir", "fp", "inx", "rand", "tlblo","ctxt", "tlbhi",\
+ "epc", "prid"\
+ }
+
+static CONST char * CONST reg_names[] = REGISTER_NAMES;
+
+/* The mips16 register names. */
+static const char * const mips16_reg_names[] =
+{
+ "s0", "s1", "v0", "v1", "a0", "a1", "a2", "a3"
+};
+
+/* subroutine */
+static void
+print_insn_arg (d, l, pc, info)
+ const char *d;
+ register unsigned long int l;
+ bfd_vma pc;
+ struct disassemble_info *info;
+{
+ int delta;
+
+ switch (*d)
+ {
+ case ',':
+ case '(':
+ case ')':
+ (*info->fprintf_func) (info->stream, "%c", *d);
+ break;
+
+ case 's':
+ case 'b':
+ case 'r':
+ case 'v':
+ (*info->fprintf_func) (info->stream, "$%s",
+ reg_names[(l >> OP_SH_RS) & OP_MASK_RS]);
+ break;
+
+ case 't':
+ case 'w':
+ (*info->fprintf_func) (info->stream, "$%s",
+ reg_names[(l >> OP_SH_RT) & OP_MASK_RT]);
+ break;
+
+ case 'i':
+ case 'u':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (l >> OP_SH_IMMEDIATE) & OP_MASK_IMMEDIATE);
+ break;
+
+ case 'j': /* same as i, but sign-extended */
+ case 'o':
+ delta = (l >> OP_SH_DELTA) & OP_MASK_DELTA;
+ if (delta & 0x8000)
+ delta |= ~0xffff;
+ (*info->fprintf_func) (info->stream, "%d",
+ delta);
+ break;
+
+ case 'h':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (unsigned int) ((l >> OP_SH_PREFX)
+ & OP_MASK_PREFX));
+ break;
+
+ case 'k':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (unsigned int) ((l >> OP_SH_CACHE)
+ & OP_MASK_CACHE));
+ break;
+
+ case 'a':
+ (*info->print_address_func)
+ (((pc & 0xF0000000) | (((l >> OP_SH_TARGET) & OP_MASK_TARGET) << 2)),
+ info);
+ break;
+
+ case 'p':
+ /* sign extend the displacement */
+ delta = (l >> OP_SH_DELTA) & OP_MASK_DELTA;
+ if (delta & 0x8000)
+ delta |= ~0xffff;
+ (*info->print_address_func)
+ ((delta << 2) + pc + 4,
+ info);
+ break;
+
+ case 'd':
+ (*info->fprintf_func) (info->stream, "$%s",
+ reg_names[(l >> OP_SH_RD) & OP_MASK_RD]);
+ break;
+
+ case 'z':
+ (*info->fprintf_func) (info->stream, "$%s", reg_names[0]);
+ break;
+
+ case '<':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (l >> OP_SH_SHAMT) & OP_MASK_SHAMT);
+ break;
+
+ case 'c':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (l >> OP_SH_CODE) & OP_MASK_CODE);
+ break;
+
+
+ case 'q':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (l >> OP_SH_CODE2) & OP_MASK_CODE2);
+ break;
+
+ case 'C':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (l >> OP_SH_COPZ) & OP_MASK_COPZ);
+ break;
+
+ case 'B':
+ (*info->fprintf_func) (info->stream, "0x%x",
+ (l >> OP_SH_SYSCALL) & OP_MASK_SYSCALL);
+ break;
+
+ case 'S':
+ case 'V':
+ (*info->fprintf_func) (info->stream, "$f%d",
+ (l >> OP_SH_FS) & OP_MASK_FS);
+ break;
+
+
+ case 'T':
+ case 'W':
+ (*info->fprintf_func) (info->stream, "$f%d",
+ (l >> OP_SH_FT) & OP_MASK_FT);
+ break;
+
+ case 'D':
+ (*info->fprintf_func) (info->stream, "$f%d",
+ (l >> OP_SH_FD) & OP_MASK_FD);
+ break;
+
+ case 'R':
+ (*info->fprintf_func) (info->stream, "$f%d",
+ (l >> OP_SH_FR) & OP_MASK_FR);
+ break;
+
+ case 'E':
+ (*info->fprintf_func) (info->stream, "$%d",
+ (l >> OP_SH_RT) & OP_MASK_RT);
+ break;
+
+ case 'G':
+ (*info->fprintf_func) (info->stream, "$%d",
+ (l >> OP_SH_RD) & OP_MASK_RD);
+ break;
+
+ case 'N':
+ (*info->fprintf_func) (info->stream, "$fcc%d",
+ (l >> OP_SH_BCC) & OP_MASK_BCC);
+ break;
+
+ case 'M':
+ (*info->fprintf_func) (info->stream, "$fcc%d",
+ (l >> OP_SH_CCC) & OP_MASK_CCC);
+ break;
+
+ case 'P':
+ (*info->fprintf_func) (info->stream, "%d",
+ (l >> OP_SH_PERFREG) & OP_MASK_PERFREG);
+ break;
+
+
+ default:
+ /* xgettext:c-format */
+ (*info->fprintf_func) (info->stream,
+ _("# internal error, undefined modifier(%c)"),
+ *d);
+ break;
+ }
+}
+
+#if SYMTAB_AVAILABLE
+
+/* Figure out the MIPS ISA and CPU based on the machine number.
+ FIXME: What does this have to do with SYMTAB_AVAILABLE? */
+
+static void
+set_mips_isa_type (mach, isa, cputype)
+ int mach;
+ int *isa;
+ int *cputype;
+{
+ int target_processor = 0;
+ int mips_isa = 0;
+
+ switch (mach)
+ {
+ case bfd_mach_mips3000:
+ target_processor = 3000;
+ mips_isa = 1;
+ break;
+ case bfd_mach_mips3900:
+ target_processor = 3900;
+ mips_isa = 1;
+ break;
+ case bfd_mach_mips4000:
+ target_processor = 4000;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips4010:
+ target_processor = 4010;
+ mips_isa = 2;
+ break;
+ case bfd_mach_mips4100:
+ target_processor = 4100;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips4111:
+ target_processor = 4100;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips4300:
+ target_processor = 4300;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips4400:
+ target_processor = 4400;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips4600:
+ target_processor = 4600;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips4650:
+ target_processor = 4650;
+ mips_isa = 3;
+ break;
+ case bfd_mach_mips5000:
+ target_processor = 5000;
+ mips_isa = 4;
+ break;
+ case bfd_mach_mips6000:
+ target_processor = 6000;
+ mips_isa = 2;
+ break;
+ case bfd_mach_mips8000:
+ target_processor = 8000;
+ mips_isa = 4;
+ break;
+ case bfd_mach_mips10000:
+ target_processor = 10000;
+ mips_isa = 4;
+ break;
+ case bfd_mach_mips16:
+ target_processor = 16;
+ mips_isa = 3;
+ break;
+ default:
+ target_processor = 3000;
+ mips_isa = 3;
+ break;
+
+ }
+
+ *isa = mips_isa;
+ *cputype = target_processor;
+}
+
+#endif /* SYMTAB_AVAILABLE */
+
+/* Print the mips instruction at address MEMADDR in debugged memory,
+ on using INFO. Returns length of the instruction, in bytes, which is
+ always 4. BIGENDIAN must be 1 if this is big-endian code, 0 if
+ this is little-endian code. */
+
+static int
+_print_insn_mips (memaddr, word, info)
+ bfd_vma memaddr;
+ unsigned long int word;
+ struct disassemble_info *info;
+{
+ register const struct mips_opcode *op;
+ int target_processor, mips_isa;
+ static boolean init = 0;
+ static const struct mips_opcode *mips_hash[OP_MASK_OP + 1];
+
+ /* Build a hash table to shorten the search time. */
+ if (! init)
+ {
+ unsigned int i;
+
+ for (i = 0; i <= OP_MASK_OP; i++)
+ {
+ for (op = mips_opcodes; op < &mips_opcodes[NUMOPCODES]; op++)
+ {
+ if (op->pinfo == INSN_MACRO)
+ continue;
+ if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP))
+ {
+ mips_hash[i] = op;
+ break;
+ }
+ }
+ }
+
+ init = 1;
+ }
+
+#if ! SYMTAB_AVAILABLE
+ /* This is running out on a target machine, not in a host tool.
+ FIXME: Where does mips_target_info come from? */
+ target_processor = mips_target_info.processor;
+ mips_isa = mips_target_info.isa;
+#else
+ set_mips_isa_type (info->mach, &mips_isa, &target_processor);
+#endif
+
+ info->bytes_per_chunk = 4;
+ info->display_endian = info->endian;
+
+ op = mips_hash[(word >> OP_SH_OP) & OP_MASK_OP];
+ if (op != NULL)
+ {
+ for (; op < &mips_opcodes[NUMOPCODES]; op++)
+ {
+ if (op->pinfo != INSN_MACRO && (word & op->mask) == op->match)
+ {
+ register const char *d;
+ int insn_isa;
+
+ if ((op->membership & INSN_ISA) == INSN_ISA1)
+ insn_isa = 1;
+ else if ((op->membership & INSN_ISA) == INSN_ISA2)
+ insn_isa = 2;
+ else if ((op->membership & INSN_ISA) == INSN_ISA3)
+ insn_isa = 3;
+ else if ((op->membership & INSN_ISA) == INSN_ISA4)
+ insn_isa = 4;
+ else
+ insn_isa = 15;
+
+ if (insn_isa > mips_isa
+ && (target_processor == 4650
+ && op->membership & INSN_4650) == 0
+ && (target_processor == 4010
+ && op->membership & INSN_4010) == 0
+ && (target_processor == 4100
+ && op->membership & INSN_4100) == 0
+ && (target_processor == 3900
+ && op->membership & INSN_3900) == 0)
+ continue;
+
+ (*info->fprintf_func) (info->stream, "%s", op->name);
+
+ d = op->args;
+ if (d != NULL && *d != '\0')
+ {
+ (*info->fprintf_func) (info->stream, "\t");
+ for (; *d != '\0'; d++)
+ print_insn_arg (d, word, memaddr, info);
+ }
+
+ return 4;
+ }
+ }
+ }
+
+ /* Handle undefined instructions. */
+ (*info->fprintf_func) (info->stream, "0x%x", word);
+ return 4;
+}
+
+
+/* In an environment where we do not know the symbol type of the
+ instruction we are forced to assume that the low order bit of the
+ instructions' address may mark it as a mips16 instruction. If we
+ are single stepping, or the pc is within the disassembled function,
+ this works. Otherwise, we need a clue. Sometimes. */
+
+int
+print_insn_big_mips (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ bfd_byte buffer[4];
+ int status;
+
+#if 1
+ /* FIXME: If odd address, this is CLEARLY a mips 16 instruction. */
+ /* Only a few tools will work this way. */
+ if (memaddr & 0x01)
+ return print_insn_mips16 (memaddr, info);
+#endif
+
+#if SYMTAB_AVAILABLE
+ if (info->mach == 16
+ || (info->flavour == bfd_target_elf_flavour
+ && info->symbols != NULL
+ && ((*(elf_symbol_type **) info->symbols)->internal_elf_sym.st_other
+ == STO_MIPS16)))
+ return print_insn_mips16 (memaddr, info);
+#endif
+
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status == 0)
+ return _print_insn_mips (memaddr, (unsigned long) bfd_getb32 (buffer),
+ info);
+ else
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+}
+
+int
+print_insn_little_mips (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ bfd_byte buffer[4];
+ int status;
+
+
+#if 1
+ if (memaddr & 0x01)
+ return print_insn_mips16 (memaddr, info);
+#endif
+
+#if SYMTAB_AVAILABLE
+ if (info->mach == 16
+ || (info->flavour == bfd_target_elf_flavour
+ && info->symbols != NULL
+ && ((*(elf_symbol_type **) info->symbols)->internal_elf_sym.st_other
+ == STO_MIPS16)))
+ return print_insn_mips16 (memaddr, info);
+#endif
+
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status == 0)
+ return _print_insn_mips (memaddr, (unsigned long) bfd_getl32 (buffer),
+ info);
+ else
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+}
+
+/* Disassemble mips16 instructions. */
+
+static int
+print_insn_mips16 (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int status;
+ bfd_byte buffer[2];
+ int length;
+ int insn;
+ boolean use_extend;
+ int extend = 0;
+ const struct mips_opcode *op, *opend;
+
+ info->bytes_per_chunk = 2;
+ info->display_endian = info->endian;
+
+ info->insn_info_valid = 1;
+ info->branch_delay_insns = 0;
+ info->data_size = 0;
+ info->insn_type = dis_nonbranch;
+ info->target = 0;
+ info->target2 = 0;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ length = 2;
+
+ if (info->endian == BFD_ENDIAN_BIG)
+ insn = bfd_getb16 (buffer);
+ else
+ insn = bfd_getl16 (buffer);
+
+ /* Handle the extend opcode specially. */
+ use_extend = false;
+ if ((insn & 0xf800) == 0xf000)
+ {
+ use_extend = true;
+ extend = insn & 0x7ff;
+
+ memaddr += 2;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 2, info);
+ if (status != 0)
+ {
+ (*info->fprintf_func) (info->stream, "extend 0x%x",
+ (unsigned int) extend);
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ if (info->endian == BFD_ENDIAN_BIG)
+ insn = bfd_getb16 (buffer);
+ else
+ insn = bfd_getl16 (buffer);
+
+ /* Check for an extend opcode followed by an extend opcode. */
+ if ((insn & 0xf800) == 0xf000)
+ {
+ (*info->fprintf_func) (info->stream, "extend 0x%x",
+ (unsigned int) extend);
+ info->insn_type = dis_noninsn;
+ return length;
+ }
+
+ length += 2;
+ }
+
+ /* FIXME: Should probably use a hash table on the major opcode here. */
+
+ opend = mips16_opcodes + bfd_mips16_num_opcodes;
+ for (op = mips16_opcodes; op < opend; op++)
+ {
+ if (op->pinfo != INSN_MACRO && (insn & op->mask) == op->match)
+ {
+ const char *s;
+
+ if (strchr (op->args, 'a') != NULL)
+ {
+ if (use_extend)
+ {
+ (*info->fprintf_func) (info->stream, "extend 0x%x",
+ (unsigned int) extend);
+ info->insn_type = dis_noninsn;
+ return length - 2;
+ }
+
+ use_extend = false;
+
+ memaddr += 2;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 2,
+ info);
+ if (status == 0)
+ {
+ use_extend = true;
+ if (info->endian == BFD_ENDIAN_BIG)
+ extend = bfd_getb16 (buffer);
+ else
+ extend = bfd_getl16 (buffer);
+ length += 2;
+ }
+ }
+
+ (*info->fprintf_func) (info->stream, "%s", op->name);
+ if (op->args[0] != '\0')
+ (*info->fprintf_func) (info->stream, "\t");
+
+ for (s = op->args; *s != '\0'; s++)
+ {
+ if (*s == ','
+ && s[1] == 'w'
+ && (((insn >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX)
+ == ((insn >> MIPS16OP_SH_RY) & MIPS16OP_MASK_RY)))
+ {
+ /* Skip the register and the comma. */
+ ++s;
+ continue;
+ }
+ if (*s == ','
+ && s[1] == 'v'
+ && (((insn >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ)
+ == ((insn >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX)))
+ {
+ /* Skip the register and the comma. */
+ ++s;
+ continue;
+ }
+ print_mips16_insn_arg (*s, op, insn, use_extend, extend, memaddr,
+ info);
+ }
+
+ if ((op->pinfo & INSN_UNCOND_BRANCH_DELAY) != 0)
+ {
+ info->branch_delay_insns = 1;
+ if (info->insn_type != dis_jsr)
+ info->insn_type = dis_branch;
+ }
+
+ return length;
+ }
+ }
+
+ if (use_extend)
+ (*info->fprintf_func) (info->stream, "0x%x", extend | 0xf000);
+ (*info->fprintf_func) (info->stream, "0x%x", insn);
+ info->insn_type = dis_noninsn;
+
+ return length;
+}
+
+/* Disassemble an operand for a mips16 instruction. */
+
+static void
+print_mips16_insn_arg (type, op, l, use_extend, extend, memaddr, info)
+ int type;
+ const struct mips_opcode *op;
+ int l;
+ boolean use_extend;
+ int extend;
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ switch (type)
+ {
+ case ',':
+ case '(':
+ case ')':
+ (*info->fprintf_func) (info->stream, "%c", type);
+ break;
+
+ case 'y':
+ case 'w':
+ (*info->fprintf_func) (info->stream, "$%s",
+ mips16_reg_names[((l >> MIPS16OP_SH_RY)
+ & MIPS16OP_MASK_RY)]);
+ break;
+
+ case 'x':
+ case 'v':
+ (*info->fprintf_func) (info->stream, "$%s",
+ mips16_reg_names[((l >> MIPS16OP_SH_RX)
+ & MIPS16OP_MASK_RX)]);
+ break;
+
+ case 'z':
+ (*info->fprintf_func) (info->stream, "$%s",
+ mips16_reg_names[((l >> MIPS16OP_SH_RZ)
+ & MIPS16OP_MASK_RZ)]);
+ break;
+
+ case 'Z':
+ (*info->fprintf_func) (info->stream, "$%s",
+ mips16_reg_names[((l >> MIPS16OP_SH_MOVE32Z)
+ & MIPS16OP_MASK_MOVE32Z)]);
+ break;
+
+ case '0':
+ (*info->fprintf_func) (info->stream, "$%s", reg_names[0]);
+ break;
+
+ case 'S':
+ (*info->fprintf_func) (info->stream, "$%s", reg_names[29]);
+ break;
+
+ case 'P':
+ (*info->fprintf_func) (info->stream, "$pc");
+ break;
+
+ case 'R':
+ (*info->fprintf_func) (info->stream, "$%s", reg_names[31]);
+ break;
+
+ case 'X':
+ (*info->fprintf_func) (info->stream, "$%s",
+ reg_names[((l >> MIPS16OP_SH_REGR32)
+ & MIPS16OP_MASK_REGR32)]);
+ break;
+
+ case 'Y':
+ (*info->fprintf_func) (info->stream, "$%s",
+ reg_names[MIPS16OP_EXTRACT_REG32R (l)]);
+ break;
+
+ case '<':
+ case '>':
+ case '[':
+ case ']':
+ case '4':
+ case '5':
+ case 'H':
+ case 'W':
+ case 'D':
+ case 'j':
+ case '6':
+ case '8':
+ case 'V':
+ case 'C':
+ case 'U':
+ case 'k':
+ case 'K':
+ case 'p':
+ case 'q':
+ case 'A':
+ case 'B':
+ case 'E':
+ {
+ int immed, nbits, shift, signedp, extbits, pcrel, extu, branch;
+
+ shift = 0;
+ signedp = 0;
+ extbits = 16;
+ pcrel = 0;
+ extu = 0;
+ branch = 0;
+ switch (type)
+ {
+ case '<':
+ nbits = 3;
+ immed = (l >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ;
+ extbits = 5;
+ extu = 1;
+ break;
+ case '>':
+ nbits = 3;
+ immed = (l >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX;
+ extbits = 5;
+ extu = 1;
+ break;
+ case '[':
+ nbits = 3;
+ immed = (l >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ;
+ extbits = 6;
+ extu = 1;
+ break;
+ case ']':
+ nbits = 3;
+ immed = (l >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX;
+ extbits = 6;
+ extu = 1;
+ break;
+ case '4':
+ nbits = 4;
+ immed = (l >> MIPS16OP_SH_IMM4) & MIPS16OP_MASK_IMM4;
+ signedp = 1;
+ extbits = 15;
+ break;
+ case '5':
+ nbits = 5;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ info->insn_type = dis_dref;
+ info->data_size = 1;
+ break;
+ case 'H':
+ nbits = 5;
+ shift = 1;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ info->insn_type = dis_dref;
+ info->data_size = 2;
+ break;
+ case 'W':
+ nbits = 5;
+ shift = 2;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ if ((op->pinfo & MIPS16_INSN_READ_PC) == 0
+ && (op->pinfo & MIPS16_INSN_READ_SP) == 0)
+ {
+ info->insn_type = dis_dref;
+ info->data_size = 4;
+ }
+ break;
+ case 'D':
+ nbits = 5;
+ shift = 3;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ info->insn_type = dis_dref;
+ info->data_size = 8;
+ break;
+ case 'j':
+ nbits = 5;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ signedp = 1;
+ break;
+ case '6':
+ nbits = 6;
+ immed = (l >> MIPS16OP_SH_IMM6) & MIPS16OP_MASK_IMM6;
+ break;
+ case '8':
+ nbits = 8;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ break;
+ case 'V':
+ nbits = 8;
+ shift = 2;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ /* FIXME: This might be lw, or it might be addiu to $sp or
+ $pc. We assume it's load. */
+ info->insn_type = dis_dref;
+ info->data_size = 4;
+ break;
+ case 'C':
+ nbits = 8;
+ shift = 3;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ info->insn_type = dis_dref;
+ info->data_size = 8;
+ break;
+ case 'U':
+ nbits = 8;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ extu = 1;
+ break;
+ case 'k':
+ nbits = 8;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ signedp = 1;
+ break;
+ case 'K':
+ nbits = 8;
+ shift = 3;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ signedp = 1;
+ break;
+ case 'p':
+ nbits = 8;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ signedp = 1;
+ pcrel = 1;
+ branch = 1;
+ info->insn_type = dis_condbranch;
+ break;
+ case 'q':
+ nbits = 11;
+ immed = (l >> MIPS16OP_SH_IMM11) & MIPS16OP_MASK_IMM11;
+ signedp = 1;
+ pcrel = 1;
+ branch = 1;
+ info->insn_type = dis_branch;
+ break;
+ case 'A':
+ nbits = 8;
+ shift = 2;
+ immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8;
+ pcrel = 1;
+ /* FIXME: This can be lw or la. We assume it is lw. */
+ info->insn_type = dis_dref;
+ info->data_size = 4;
+ break;
+ case 'B':
+ nbits = 5;
+ shift = 3;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ pcrel = 1;
+ info->insn_type = dis_dref;
+ info->data_size = 8;
+ break;
+ case 'E':
+ nbits = 5;
+ shift = 2;
+ immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5;
+ pcrel = 1;
+ break;
+ default:
+ abort ();
+ }
+
+ if (! use_extend)
+ {
+ if (signedp && immed >= (1 << (nbits - 1)))
+ immed -= 1 << nbits;
+ immed <<= shift;
+ if ((type == '<' || type == '>' || type == '[' || type == ']')
+ && immed == 0)
+ immed = 8;
+ }
+ else
+ {
+ if (extbits == 16)
+ immed |= ((extend & 0x1f) << 11) | (extend & 0x7e0);
+ else if (extbits == 15)
+ immed |= ((extend & 0xf) << 11) | (extend & 0x7f0);
+ else
+ immed = ((extend >> 6) & 0x1f) | (extend & 0x20);
+ immed &= (1 << extbits) - 1;
+ if (! extu && immed >= (1 << (extbits - 1)))
+ immed -= 1 << extbits;
+ }
+
+ if (! pcrel)
+ (*info->fprintf_func) (info->stream, "%d", immed);
+ else
+ {
+ bfd_vma baseaddr;
+ bfd_vma val;
+
+ if (branch)
+ {
+ immed *= 2;
+ baseaddr = memaddr + 2;
+ }
+ else if (use_extend)
+ baseaddr = memaddr - 2;
+ else
+ {
+ int status;
+ bfd_byte buffer[2];
+
+ baseaddr = memaddr;
+
+ /* If this instruction is in the delay slot of a jr
+ instruction, the base address is the address of the
+ jr instruction. If it is in the delay slot of jalr
+ instruction, the base address is the address of the
+ jalr instruction. This test is unreliable: we have
+ no way of knowing whether the previous word is
+ instruction or data. */
+ status = (*info->read_memory_func) (memaddr - 4, buffer, 2,
+ info);
+ if (status == 0
+ && (((info->endian == BFD_ENDIAN_BIG
+ ? bfd_getb16 (buffer)
+ : bfd_getl16 (buffer))
+ & 0xf800) == 0x1800))
+ baseaddr = memaddr - 4;
+ else
+ {
+ status = (*info->read_memory_func) (memaddr - 2, buffer,
+ 2, info);
+ if (status == 0
+ && (((info->endian == BFD_ENDIAN_BIG
+ ? bfd_getb16 (buffer)
+ : bfd_getl16 (buffer))
+ & 0xf81f) == 0xe800))
+ baseaddr = memaddr - 2;
+ }
+ }
+ val = (baseaddr & ~ ((1 << shift) - 1)) + immed;
+ (*info->print_address_func) (val, info);
+ info->target = val;
+ }
+ }
+ break;
+
+ case 'a':
+ if (! use_extend)
+ extend = 0;
+ l = ((l & 0x1f) << 23) | ((l & 0x3e0) << 13) | (extend << 2);
+ (*info->print_address_func) ((memaddr & 0xf0000000) | l, info);
+ info->insn_type = dis_jsr;
+ info->target = (memaddr & 0xf0000000) | l;
+ info->branch_delay_insns = 1;
+ break;
+
+ case 'l':
+ case 'L':
+ {
+ int need_comma, amask, smask;
+
+ need_comma = 0;
+
+ l = (l >> MIPS16OP_SH_IMM6) & MIPS16OP_MASK_IMM6;
+
+ amask = (l >> 3) & 7;
+
+ if (amask > 0 && amask < 5)
+ {
+ (*info->fprintf_func) (info->stream, "$%s", reg_names[4]);
+ if (amask > 1)
+ (*info->fprintf_func) (info->stream, "-$%s",
+ reg_names[amask + 3]);
+ need_comma = 1;
+ }
+
+ smask = (l >> 1) & 3;
+ if (smask == 3)
+ {
+ (*info->fprintf_func) (info->stream, "%s??",
+ need_comma ? "," : "");
+ need_comma = 1;
+ }
+ else if (smask > 0)
+ {
+ (*info->fprintf_func) (info->stream, "%s$%s",
+ need_comma ? "," : "",
+ reg_names[16]);
+ if (smask > 1)
+ (*info->fprintf_func) (info->stream, "-$%s",
+ reg_names[smask + 15]);
+ need_comma = 1;
+ }
+
+ if (l & 1)
+ {
+ (*info->fprintf_func) (info->stream, "%s$%s",
+ need_comma ? "," : "",
+ reg_names[31]);
+ need_comma = 1;
+ }
+
+ if (amask == 5 || amask == 6)
+ {
+ (*info->fprintf_func) (info->stream, "%s$f0",
+ need_comma ? "," : "");
+ if (amask == 6)
+ (*info->fprintf_func) (info->stream, "-$f1");
+ }
+ }
+ break;
+
+ default:
+ abort ();
+ }
+}
diff --git a/opcodes/mips-opc.c b/opcodes/mips-opc.c
new file mode 100644
index 00000000000..b8646193863
--- /dev/null
+++ b/opcodes/mips-opc.c
@@ -0,0 +1,772 @@
+/* mips.h. Mips opcode list for GDB, the GNU debugger.
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Contributed by Ralph Campbell and OSF
+ Commented and modified by Ian Lance Taylor, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/mips.h"
+
+/* Short hand so the lines aren't too long. */
+
+#define LDD INSN_LOAD_MEMORY_DELAY
+#define LCD INSN_LOAD_COPROC_DELAY
+#define UBD INSN_UNCOND_BRANCH_DELAY
+#define CBD INSN_COND_BRANCH_DELAY
+#define COD INSN_COPROC_MOVE_DELAY
+#define CLD INSN_COPROC_MEMORY_DELAY
+#define CBL INSN_COND_BRANCH_LIKELY
+#define TRAP INSN_TRAP
+#define SM INSN_STORE_MEMORY
+
+#define WR_d INSN_WRITE_GPR_D
+#define WR_t INSN_WRITE_GPR_T
+#define WR_31 INSN_WRITE_GPR_31
+#define WR_D INSN_WRITE_FPR_D
+#define WR_T INSN_WRITE_FPR_T
+#define WR_S INSN_WRITE_FPR_S
+#define RD_s INSN_READ_GPR_S
+#define RD_b INSN_READ_GPR_S
+#define RD_t INSN_READ_GPR_T
+#define RD_S INSN_READ_FPR_S
+#define RD_T INSN_READ_FPR_T
+#define RD_R INSN_READ_FPR_R
+#define WR_CC INSN_WRITE_COND_CODE
+#define RD_CC INSN_READ_COND_CODE
+#define RD_C0 INSN_COP
+#define RD_C1 INSN_COP
+#define RD_C2 INSN_COP
+#define RD_C3 INSN_COP
+#define WR_C0 INSN_COP
+#define WR_C1 INSN_COP
+#define WR_C2 INSN_COP
+#define WR_C3 INSN_COP
+
+#define WR_HI INSN_WRITE_HI
+#define RD_HI INSN_READ_HI
+#define MOD_HI WR_HI|RD_HI
+
+#define WR_LO INSN_WRITE_LO
+#define RD_LO INSN_READ_LO
+#define MOD_LO WR_LO|RD_LO
+
+#define WR_HILO WR_HI|WR_LO
+#define RD_HILO RD_HI|RD_LO
+#define MOD_HILO WR_HILO|RD_HILO
+
+#define IS_M INSN_MULT
+
+#define I1 INSN_ISA1
+#define I2 INSN_ISA2
+#define I3 INSN_ISA3
+#define I4 INSN_ISA4
+#define P3 INSN_4650
+#define L1 INSN_4010
+#define V1 INSN_4100
+#define T3 INSN_3900
+
+#define G1 (T3 \
+ )
+
+#define G2 (T3 \
+ )
+
+#define G3 (I4 \
+ )
+
+/* The order of overloaded instructions matters. Label arguments and
+ register arguments look the same. Instructions that can have either
+ for arguments must apear in the correct order in this table for the
+ assembler to pick the right one. In other words, entries with
+ immediate operands must apear after the same instruction with
+ registers.
+
+ Many instructions are short hand for other instructions (i.e., The
+ jal <register> instruction is short for jalr <register>). */
+
+const struct mips_opcode mips_builtin_opcodes[] = {
+/* These instructions appear first so that the disassembler will find
+ them first. The assemblers uses a hash table based on the
+ instruction name anyhow. */
+/* name, args, mask, match, pinfo */
+{"nop", "", 0x00000000, 0xffffffff, 0, I1 },
+{"li", "t,j", 0x24000000, 0xffe00000, WR_t, I1 }, /* addiu */
+{"li", "t,i", 0x34000000, 0xffe00000, WR_t, I1 }, /* ori */
+{"li", "t,I", 0, (int) M_LI, INSN_MACRO, I1 },
+{"move", "d,s", 0x0000002d, 0xfc1f07ff, WR_d|RD_s, I3 },/* daddu */
+{"move", "d,s", 0x00000021, 0xfc1f07ff, WR_d|RD_s, I1 },/* addu */
+{"move", "d,s", 0x00000025, 0xfc1f07ff, WR_d|RD_s, I1 },/* or */
+{"b", "p", 0x10000000, 0xffff0000, UBD, I1 },/* beq 0,0 */
+{"b", "p", 0x04010000, 0xffff0000, UBD, I1 },/* bgez 0 */
+{"bal", "p", 0x04110000, 0xffff0000, UBD|WR_31, I1 },/* bgezal 0*/
+
+{"abs", "d,v", 0, (int) M_ABS, INSN_MACRO, I1 },
+{"abs.s", "D,V", 0x46000005, 0xffff003f, WR_D|RD_S|FP_S, I1 },
+{"abs.d", "D,V", 0x46200005, 0xffff003f, WR_D|RD_S|FP_D, I1 },
+{"add", "d,v,t", 0x00000020, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"add", "t,r,I", 0, (int) M_ADD_I, INSN_MACRO, I1 },
+{"add.s", "D,V,T", 0x46000000, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, I1},
+{"add.d", "D,V,T", 0x46200000, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, I1},
+{"addi", "t,r,j", 0x20000000, 0xfc000000, WR_t|RD_s, I1 },
+{"addiu", "t,r,j", 0x24000000, 0xfc000000, WR_t|RD_s, I1 },
+{"addu", "d,v,t", 0x00000021, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"addu", "t,r,I", 0, (int) M_ADDU_I, INSN_MACRO, I1 },
+{"and", "d,v,t", 0x00000024, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"and", "t,r,I", 0, (int) M_AND_I, INSN_MACRO, I1 },
+{"andi", "t,r,i", 0x30000000, 0xfc000000, WR_t|RD_s, I1 },
+/* b is at the top of the table. */
+/* bal is at the top of the table. */
+{"bc0f", "p", 0x41000000, 0xffff0000, CBD|RD_CC, I1 },
+{"bc0fl", "p", 0x41020000, 0xffff0000, CBL|RD_CC, I2|T3 },
+{"bc1f", "p", 0x45000000, 0xffff0000, CBD|RD_CC|FP_S, I1 },
+{"bc1f", "N,p", 0x45000000, 0xffe30000, CBD|RD_CC|FP_S, I4 },
+{"bc1fl", "p", 0x45020000, 0xffff0000, CBL|RD_CC|FP_S, I2|T3 },
+{"bc1fl", "N,p", 0x45020000, 0xffe30000, CBL|RD_CC|FP_S, I4 },
+{"bc2f", "p", 0x49000000, 0xffff0000, CBD|RD_CC, I1 },
+{"bc2fl", "p", 0x49020000, 0xffff0000, CBL|RD_CC, I2|T3 },
+{"bc3f", "p", 0x4d000000, 0xffff0000, CBD|RD_CC, I1 },
+{"bc3fl", "p", 0x4d020000, 0xffff0000, CBL|RD_CC, I2|T3 },
+{"bc0t", "p", 0x41010000, 0xffff0000, CBD|RD_CC, I1 },
+{"bc0tl", "p", 0x41030000, 0xffff0000, CBL|RD_CC, I2|T3 },
+{"bc1t", "p", 0x45010000, 0xffff0000, CBD|RD_CC|FP_S, I1 },
+{"bc1t", "N,p", 0x45010000, 0xffe30000, CBD|RD_CC|FP_S, I4 },
+{"bc1tl", "p", 0x45030000, 0xffff0000, CBL|RD_CC|FP_S, I2|T3 },
+{"bc1tl", "N,p", 0x45030000, 0xffe30000, CBL|RD_CC|FP_S, I4 },
+{"bc2t", "p", 0x49010000, 0xffff0000, CBD|RD_CC, I1 },
+{"bc2tl", "p", 0x49030000, 0xffff0000, CBL|RD_CC, I2|T3 },
+{"bc3t", "p", 0x4d010000, 0xffff0000, CBD|RD_CC, I1 },
+{"bc3tl", "p", 0x4d030000, 0xffff0000, CBL|RD_CC, I2|T3 },
+{"beqz", "s,p", 0x10000000, 0xfc1f0000, CBD|RD_s, I1 },
+{"beqzl", "s,p", 0x50000000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"beq", "s,t,p", 0x10000000, 0xfc000000, CBD|RD_s|RD_t, I1 },
+{"beq", "s,I,p", 0, (int) M_BEQ_I, INSN_MACRO, I1 },
+{"beql", "s,t,p", 0x50000000, 0xfc000000, CBL|RD_s|RD_t, I2|T3 },
+{"beql", "s,I,p", 0, (int) M_BEQL_I, INSN_MACRO, I2 },
+{"bge", "s,t,p", 0, (int) M_BGE, INSN_MACRO, I1 },
+{"bge", "s,I,p", 0, (int) M_BGE_I, INSN_MACRO, I1 },
+{"bgel", "s,t,p", 0, (int) M_BGEL, INSN_MACRO, I2 },
+{"bgel", "s,I,p", 0, (int) M_BGEL_I, INSN_MACRO, I2 },
+{"bgeu", "s,t,p", 0, (int) M_BGEU, INSN_MACRO, I1 },
+{"bgeu", "s,I,p", 0, (int) M_BGEU_I, INSN_MACRO, I1 },
+{"bgeul", "s,t,p", 0, (int) M_BGEUL, INSN_MACRO, I2 },
+{"bgeul", "s,I,p", 0, (int) M_BGEUL_I, INSN_MACRO, I2 },
+{"bgez", "s,p", 0x04010000, 0xfc1f0000, CBD|RD_s, I1 },
+{"bgezl", "s,p", 0x04030000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"bgezal", "s,p", 0x04110000, 0xfc1f0000, CBD|RD_s|WR_31, I1 },
+{"bgezall", "s,p", 0x04130000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"bgt", "s,t,p", 0, (int) M_BGT, INSN_MACRO, I1 },
+{"bgt", "s,I,p", 0, (int) M_BGT_I, INSN_MACRO, I1 },
+{"bgtl", "s,t,p", 0, (int) M_BGTL, INSN_MACRO, I2 },
+{"bgtl", "s,I,p", 0, (int) M_BGTL_I, INSN_MACRO, I2 },
+{"bgtu", "s,t,p", 0, (int) M_BGTU, INSN_MACRO, I1 },
+{"bgtu", "s,I,p", 0, (int) M_BGTU_I, INSN_MACRO, I1 },
+{"bgtul", "s,t,p", 0, (int) M_BGTUL, INSN_MACRO, I2 },
+{"bgtul", "s,I,p", 0, (int) M_BGTUL_I, INSN_MACRO, I2 },
+{"bgtz", "s,p", 0x1c000000, 0xfc1f0000, CBD|RD_s, I1 },
+{"bgtzl", "s,p", 0x5c000000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"ble", "s,t,p", 0, (int) M_BLE, INSN_MACRO, I1 },
+{"ble", "s,I,p", 0, (int) M_BLE_I, INSN_MACRO, I1 },
+{"blel", "s,t,p", 0, (int) M_BLEL, INSN_MACRO, I2 },
+{"blel", "s,I,p", 0, (int) M_BLEL_I, INSN_MACRO, I2 },
+{"bleu", "s,t,p", 0, (int) M_BLEU, INSN_MACRO, I1 },
+{"bleu", "s,I,p", 0, (int) M_BLEU_I, INSN_MACRO, I1 },
+{"bleul", "s,t,p", 0, (int) M_BLEUL, INSN_MACRO, I2 },
+{"bleul", "s,I,p", 0, (int) M_BLEUL_I, INSN_MACRO, I2 },
+{"blez", "s,p", 0x18000000, 0xfc1f0000, CBD|RD_s, I1 },
+{"blezl", "s,p", 0x58000000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"blt", "s,t,p", 0, (int) M_BLT, INSN_MACRO, I1 },
+{"blt", "s,I,p", 0, (int) M_BLT_I, INSN_MACRO, I1 },
+{"bltl", "s,t,p", 0, (int) M_BLTL, INSN_MACRO, I2 },
+{"bltl", "s,I,p", 0, (int) M_BLTL_I, INSN_MACRO, I2 },
+{"bltu", "s,t,p", 0, (int) M_BLTU, INSN_MACRO, I1 },
+{"bltu", "s,I,p", 0, (int) M_BLTU_I, INSN_MACRO, I1 },
+{"bltul", "s,t,p", 0, (int) M_BLTUL, INSN_MACRO, I2 },
+{"bltul", "s,I,p", 0, (int) M_BLTUL_I, INSN_MACRO, I2 },
+{"bltz", "s,p", 0x04000000, 0xfc1f0000, CBD|RD_s, I1 },
+{"bltzl", "s,p", 0x04020000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"bltzal", "s,p", 0x04100000, 0xfc1f0000, CBD|RD_s|WR_31, I1 },
+{"bltzall", "s,p", 0x04120000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"bnez", "s,p", 0x14000000, 0xfc1f0000, CBD|RD_s, I1 },
+{"bnezl", "s,p", 0x54000000, 0xfc1f0000, CBL|RD_s, I2|T3 },
+{"bne", "s,t,p", 0x14000000, 0xfc000000, CBD|RD_s|RD_t, I1 },
+{"bne", "s,I,p", 0, (int) M_BNE_I, INSN_MACRO, I1 },
+{"bnel", "s,t,p", 0x54000000, 0xfc000000, CBL|RD_s|RD_t, I2|T3 },
+{"bnel", "s,I,p", 0, (int) M_BNEL_I, INSN_MACRO, I2 },
+{"break", "", 0x0000000d, 0xffffffff, TRAP, I1 },
+{"break", "c", 0x0000000d, 0xfc00ffff, TRAP, I1 },
+{"break", "c,q", 0x0000000d, 0xfc00003f, TRAP, I1 },
+{"c.f.d", "S,T", 0x46200030, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.f.d", "M,S,T", 0x46200030, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.f.s", "S,T", 0x46000030, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.f.s", "M,S,T", 0x46000030, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.un.d", "S,T", 0x46200031, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.un.d", "M,S,T", 0x46200031, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.un.s", "S,T", 0x46000031, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.un.s", "M,S,T", 0x46000031, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.eq.d", "S,T", 0x46200032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.eq.d", "M,S,T", 0x46200032, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.eq.s", "S,T", 0x46000032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.eq.s", "M,S,T", 0x46000032, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ueq.d", "S,T", 0x46200033, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ueq.d", "M,S,T", 0x46200033, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ueq.s", "S,T", 0x46000033, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ueq.s", "M,S,T", 0x46000033, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.olt.d", "S,T", 0x46200034, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.olt.d", "M,S,T", 0x46200034, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.olt.s", "S,T", 0x46000034, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.olt.s", "M,S,T", 0x46000034, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ult.d", "S,T", 0x46200035, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ult.d", "M,S,T", 0x46200035, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ult.s", "S,T", 0x46000035, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ult.s", "M,S,T", 0x46000035, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ole.d", "S,T", 0x46200036, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ole.d", "M,S,T", 0x46200036, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ole.s", "S,T", 0x46000036, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ole.s", "M,S,T", 0x46000036, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ule.d", "S,T", 0x46200037, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ule.d", "M,S,T", 0x46200037, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ule.s", "S,T", 0x46000037, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ule.s", "M,S,T", 0x46000037, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.sf.d", "S,T", 0x46200038, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.sf.d", "M,S,T", 0x46200038, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.sf.s", "S,T", 0x46000038, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.sf.s", "M,S,T", 0x46000038, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ngle.d","S,T", 0x46200039, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ngle.d","M,S,T", 0x46200039, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ngle.s","S,T", 0x46000039, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ngle.s","M,S,T", 0x46000039, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.seq.d", "S,T", 0x4620003a, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.seq.d", "M,S,T", 0x4620003a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.seq.s", "S,T", 0x4600003a, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.seq.s", "M,S,T", 0x4600003a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ngl.d", "S,T", 0x4620003b, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ngl.d", "M,S,T", 0x4620003b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ngl.s", "S,T", 0x4600003b, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ngl.s", "M,S,T", 0x4600003b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.lt.d", "S,T", 0x4620003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.lt.d", "M,S,T", 0x4620003c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.lt.s", "S,T", 0x4600003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.lt.s", "M,S,T", 0x4600003c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.nge.d", "S,T", 0x4620003d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.nge.d", "M,S,T", 0x4620003d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.nge.s", "S,T", 0x4600003d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.nge.s", "M,S,T", 0x4600003d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.le.d", "S,T", 0x4620003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.le.d", "M,S,T", 0x4620003e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.le.s", "S,T", 0x4600003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.le.s", "M,S,T", 0x4600003e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"c.ngt.d", "S,T", 0x4620003f, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, I1 },
+{"c.ngt.d", "M,S,T", 0x4620003f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, I4 },
+{"c.ngt.s", "S,T", 0x4600003f, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, I1 },
+{"c.ngt.s", "M,S,T", 0x4600003f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, I4 },
+{"cache", "k,o(b)", 0xbc000000, 0xfc000000, RD_b, I3|T3 },
+{"ceil.l.d", "D,S", 0x4620000a, 0xffff003f, WR_D|RD_S|FP_D, I3 },
+{"ceil.l.s", "D,S", 0x4600000a, 0xffff003f, WR_D|RD_S|FP_S, I3 },
+{"ceil.w.d", "D,S", 0x4620000e, 0xffff003f, WR_D|RD_S|FP_D, I2 },
+{"ceil.w.s", "D,S", 0x4600000e, 0xffff003f, WR_D|RD_S|FP_S, I2 },
+{"cfc0", "t,G", 0x40400000, 0xffe007ff, LCD|WR_t|RD_C0, I1 },
+{"cfc1", "t,G", 0x44400000, 0xffe007ff, LCD|WR_t|RD_C1|FP_S, I1 },
+{"cfc1", "t,S", 0x44400000, 0xffe007ff, LCD|WR_t|RD_C1|FP_S, I1 },
+{"cfc2", "t,G", 0x48400000, 0xffe007ff, LCD|WR_t|RD_C2, I1 },
+{"cfc3", "t,G", 0x4c400000, 0xffe007ff, LCD|WR_t|RD_C3, I1 },
+{"ctc0", "t,G", 0x40c00000, 0xffe007ff, COD|RD_t|WR_CC, I1 },
+{"ctc1", "t,G", 0x44c00000, 0xffe007ff, COD|RD_t|WR_CC|FP_S, I1 },
+{"ctc1", "t,S", 0x44c00000, 0xffe007ff, COD|RD_t|WR_CC|FP_S, I1 },
+{"ctc2", "t,G", 0x48c00000, 0xffe007ff, COD|RD_t|WR_CC, I1 },
+{"ctc3", "t,G", 0x4cc00000, 0xffe007ff, COD|RD_t|WR_CC, I1 },
+{"cvt.d.l", "D,S", 0x46a00021, 0xffff003f, WR_D|RD_S|FP_D, I3 },
+{"cvt.d.s", "D,S", 0x46000021, 0xffff003f, WR_D|RD_S|FP_D|FP_S, I1 },
+{"cvt.d.w", "D,S", 0x46800021, 0xffff003f, WR_D|RD_S|FP_D, I1 },
+{"cvt.l.d", "D,S", 0x46200025, 0xffff003f, WR_D|RD_S|FP_D, I3 },
+{"cvt.l.s", "D,S", 0x46000025, 0xffff003f, WR_D|RD_S|FP_S, I3 },
+{"cvt.s.l", "D,S", 0x46a00020, 0xffff003f, WR_D|RD_S|FP_S, I3 },
+{"cvt.s.d", "D,S", 0x46200020, 0xffff003f, WR_D|RD_S|FP_S|FP_D, I1 },
+{"cvt.s.w", "D,S", 0x46800020, 0xffff003f, WR_D|RD_S|FP_S, I1 },
+{"cvt.w.d", "D,S", 0x46200024, 0xffff003f, WR_D|RD_S|FP_D, I1 },
+{"cvt.w.s", "D,S", 0x46000024, 0xffff003f, WR_D|RD_S|FP_S, I1 },
+{"dabs", "d,v", 0, (int) M_DABS, INSN_MACRO, I3 },
+{"dadd", "d,v,t", 0x0000002c, 0xfc0007ff, WR_d|RD_s|RD_t, I3 },
+{"dadd", "t,r,I", 0, (int) M_DADD_I, INSN_MACRO, I3 },
+{"daddi", "t,r,j", 0x60000000, 0xfc000000, WR_t|RD_s, I3 },
+{"daddiu", "t,r,j", 0x64000000, 0xfc000000, WR_t|RD_s, I3 },
+{"daddu", "d,v,t", 0x0000002d, 0xfc0007ff, WR_d|RD_s|RD_t, I3 },
+{"daddu", "t,r,I", 0, (int) M_DADDU_I, INSN_MACRO, I3 },
+/* dctr and dctw are used on the r5000. */
+{"dctr", "o(b)", 0xbc050000, 0xfc1f0000, RD_b, I3 },
+{"dctw", "o(b)", 0xbc090000, 0xfc1f0000, RD_b, I3 },
+{"deret", "", 0x4200001f, 0xffffffff, 0, G2 },
+/* For ddiv, see the comments about div. */
+{"ddiv", "z,s,t", 0x0000001e, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I3 },
+{"ddiv", "d,v,t", 0, (int) M_DDIV_3, INSN_MACRO, I3 },
+{"ddiv", "d,v,I", 0, (int) M_DDIV_3I, INSN_MACRO, I3 },
+/* For ddivu, see the comments about div. */
+{"ddivu", "z,s,t", 0x0000001f, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I3 },
+{"ddivu", "d,v,t", 0, (int) M_DDIVU_3, INSN_MACRO, I3 },
+{"ddivu", "d,v,I", 0, (int) M_DDIVU_3I, INSN_MACRO, I3 },
+/* The MIPS assembler treats the div opcode with two operands as
+ though the first operand appeared twice (the first operand is both
+ a source and a destination). To get the div machine instruction,
+ you must use an explicit destination of $0. */
+{"div", "z,s,t", 0x0000001a, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I1 },
+{"div", "z,t", 0x0000001a, 0xffe0ffff, RD_s|RD_t|WR_HI|WR_LO, I1 },
+{"div", "d,v,t", 0, (int) M_DIV_3, INSN_MACRO, I1 },
+{"div", "d,v,I", 0, (int) M_DIV_3I, INSN_MACRO, I1 },
+{"div.d", "D,V,T", 0x46200003, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, I1 },
+{"div.s", "D,V,T", 0x46000003, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, I1 },
+/* For divu, see the comments about div. */
+{"divu", "z,s,t", 0x0000001b, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I1 },
+{"divu", "z,t", 0x0000001b, 0xffe0ffff, RD_s|RD_t|WR_HI|WR_LO, I1 },
+{"divu", "d,v,t", 0, (int) M_DIVU_3, INSN_MACRO, I1 },
+{"divu", "d,v,I", 0, (int) M_DIVU_3I, INSN_MACRO, I1 },
+{"dla", "t,A(b)", 0, (int) M_DLA_AB, INSN_MACRO, I3 },
+{"dli", "t,j", 0x24000000, 0xffe00000, WR_t, I3 }, /* addiu */
+{"dli", "t,i", 0x34000000, 0xffe00000, WR_t, I3 }, /* ori */
+{"dli", "t,I", 0, (int) M_DLI, INSN_MACRO, I3 },
+
+{"dmadd16", "s,t", 0x00000029, 0xfc00ffff, RD_s|RD_t|WR_LO|RD_LO, V1 },
+{"dmfc0", "t,G", 0x40200000, 0xffe007ff, LCD|WR_t|RD_C0, I3 },
+{"dmtc0", "t,G", 0x40a00000, 0xffe007ff, COD|RD_t|WR_C0|WR_CC, I3 },
+{"dmfc1", "t,S", 0x44200000, 0xffe007ff, LCD|WR_t|RD_S|FP_S, I3 },
+{"dmtc1", "t,S", 0x44a00000, 0xffe007ff, COD|RD_t|WR_S|FP_S, I3 },
+{"dmfc2", "t,S", 0x48200000, 0xffe007ff, LCD|WR_t|RD_S|FP_S, I3 },
+{"dmtc2", "t,S", 0x48a00000, 0xffe007ff, COD|RD_t|WR_S|FP_S, I3 },
+{"dmul", "d,v,t", 0, (int) M_DMUL, INSN_MACRO, I3 },
+{"dmul", "d,v,I", 0, (int) M_DMUL_I, INSN_MACRO, I3 },
+{"dmulo", "d,v,t", 0, (int) M_DMULO, INSN_MACRO, I3 },
+{"dmulo", "d,v,I", 0, (int) M_DMULO_I, INSN_MACRO, I3 },
+{"dmulou", "d,v,t", 0, (int) M_DMULOU, INSN_MACRO, I3 },
+{"dmulou", "d,v,I", 0, (int) M_DMULOU_I, INSN_MACRO, I3 },
+{"dmult", "s,t", 0x0000001c, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I3},
+{"dmultu", "s,t", 0x0000001d, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I3},
+{"dneg", "d,w", 0x0000002e, 0xffe007ff, WR_d|RD_t, I3 }, /* dsub 0 */
+{"dnegu", "d,w", 0x0000002f, 0xffe007ff, WR_d|RD_t, I3 }, /* dsubu 0*/
+{"drem", "z,s,t", 0x0000001e, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I3 },
+{"drem", "d,v,t", 3, (int) M_DREM_3, INSN_MACRO, I3 },
+{"drem", "d,v,I", 3, (int) M_DREM_3I, INSN_MACRO, I3 },
+{"dremu", "z,s,t", 0x0000001f, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I3 },
+{"dremu", "d,v,t", 3, (int) M_DREMU_3, INSN_MACRO, I3 },
+{"dremu", "d,v,I", 3, (int) M_DREMU_3I, INSN_MACRO, I3 },
+{"dsllv", "d,t,s", 0x00000014, 0xfc0007ff, WR_d|RD_t|RD_s, I3 },
+{"dsll32", "d,w,<", 0x0000003c, 0xffe0003f, WR_d|RD_t, I3 },
+{"dsll", "d,w,s", 0x00000014, 0xfc0007ff, WR_d|RD_t|RD_s, I3 }, /* dsllv */
+{"dsll", "d,w,>", 0x0000003c, 0xffe0003f, WR_d|RD_t, I3 }, /* dsll32 */
+{"dsll", "d,w,<", 0x00000038, 0xffe0003f, WR_d|RD_t, I3 },
+{"dsrav", "d,t,s", 0x00000017, 0xfc0007ff, WR_d|RD_t|RD_s, I3 },
+{"dsra32", "d,w,<", 0x0000003f, 0xffe0003f, WR_d|RD_t, I3 },
+{"dsra", "d,w,s", 0x00000017, 0xfc0007ff, WR_d|RD_t|RD_s, I3 }, /* dsrav */
+{"dsra", "d,w,>", 0x0000003f, 0xffe0003f, WR_d|RD_t, I3 }, /* dsra32 */
+{"dsra", "d,w,<", 0x0000003b, 0xffe0003f, WR_d|RD_t, I3 },
+{"dsrlv", "d,t,s", 0x00000016, 0xfc0007ff, WR_d|RD_t|RD_s, I3 },
+{"dsrl32", "d,w,<", 0x0000003e, 0xffe0003f, WR_d|RD_t, I3 },
+{"dsrl", "d,w,s", 0x00000016, 0xfc0007ff, WR_d|RD_t|RD_s, I3 }, /* dsrlv */
+{"dsrl", "d,w,>", 0x0000003e, 0xffe0003f, WR_d|RD_t, I3 }, /* dsrl32 */
+{"dsrl", "d,w,<", 0x0000003a, 0xffe0003f, WR_d|RD_t, I3 },
+{"dsub", "d,v,t", 0x0000002e, 0xfc0007ff, WR_d|RD_s|RD_t, I3 },
+{"dsub", "d,v,I", 0, (int) M_DSUB_I, INSN_MACRO, I3 },
+{"dsubu", "d,v,t", 0x0000002f, 0xfc0007ff, WR_d|RD_s|RD_t, I3 },
+{"dsubu", "d,v,I", 0, (int) M_DSUBU_I, INSN_MACRO, I3 },
+{"eret", "", 0x42000018, 0xffffffff, 0, I3 },
+{"floor.l.d", "D,S", 0x4620000b, 0xffff003f, WR_D|RD_S|FP_D, I3 },
+{"floor.l.s", "D,S", 0x4600000b, 0xffff003f, WR_D|RD_S|FP_S, I3 },
+{"floor.w.d", "D,S", 0x4620000f, 0xffff003f, WR_D|RD_S|FP_D, I2 },
+{"floor.w.s", "D,S", 0x4600000f, 0xffff003f, WR_D|RD_S|FP_S, I2 },
+{"flushi", "", 0xbc010000, 0xffffffff, 0, L1 },
+{"flushd", "", 0xbc020000, 0xffffffff, 0, L1 },
+{"flushid", "", 0xbc030000, 0xffffffff, 0, L1 },
+{"hibernate","", 0x42000023, 0xffffffff, 0, V1 },
+{"jr", "s", 0x00000008, 0xfc1fffff, UBD|RD_s, I1 },
+{"j", "s", 0x00000008, 0xfc1fffff, UBD|RD_s, I1 }, /* jr */
+/* SVR4 PIC code requires special handling for j, so it must be a
+ macro. */
+{"j", "a", 0, (int) M_J_A, INSN_MACRO, I1 },
+/* This form of j is used by the disassembler and internally by the
+ assembler, but will never match user input (because the line above
+ will match first). */
+{"j", "a", 0x08000000, 0xfc000000, UBD, I1 },
+{"jalr", "s", 0x0000f809, 0xfc1fffff, UBD|RD_s|WR_d, I1 },
+{"jalr", "d,s", 0x00000009, 0xfc1f07ff, UBD|RD_s|WR_d, I1 },
+/* SVR4 PIC code requires special handling for jal, so it must be a
+ macro. */
+{"jal", "d,s", 0, (int) M_JAL_2, INSN_MACRO, I1 },
+{"jal", "s", 0, (int) M_JAL_1, INSN_MACRO, I1 },
+{"jal", "a", 0, (int) M_JAL_A, INSN_MACRO, I1 },
+/* This form of jal is used by the disassembler and internally by the
+ assembler, but will never match user input (because the line above
+ will match first). */
+{"jal", "a", 0x0c000000, 0xfc000000, UBD|WR_31, I1 },
+ /* jalx really should only be avaliable if mips16 is available,
+ but for now make it I1. */
+{"jalx", "a", 0x74000000, 0xfc000000, UBD|WR_31, I1 },
+{"la", "t,A(b)", 0, (int) M_LA_AB, INSN_MACRO, I1 },
+{"lb", "t,o(b)", 0x80000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lb", "t,A(b)", 0, (int) M_LB_AB, INSN_MACRO, I1 },
+{"lbu", "t,o(b)", 0x90000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lbu", "t,A(b)", 0, (int) M_LBU_AB, INSN_MACRO, I1 },
+{"ld", "t,o(b)", 0xdc000000, 0xfc000000, WR_t|RD_b, I3 },
+{"ld", "t,o(b)", 0, (int) M_LD_OB, INSN_MACRO, I1 },
+{"ld", "t,A(b)", 0, (int) M_LD_AB, INSN_MACRO, I1 },
+{"ldc1", "T,o(b)", 0xd4000000, 0xfc000000, CLD|RD_b|WR_T|FP_D, I2 },
+{"ldc1", "E,o(b)", 0xd4000000, 0xfc000000, CLD|RD_b|WR_T|FP_D, I2 },
+{"ldc1", "T,A(b)", 0, (int) M_LDC1_AB, INSN_MACRO, I2 },
+{"ldc1", "E,A(b)", 0, (int) M_LDC1_AB, INSN_MACRO, I2 },
+{"l.d", "T,o(b)", 0xd4000000, 0xfc000000, CLD|RD_b|WR_T|FP_D, I2 }, /* ldc1 */
+{"l.d", "T,o(b)", 0, (int) M_L_DOB, INSN_MACRO, I1 },
+{"l.d", "T,A(b)", 0, (int) M_L_DAB, INSN_MACRO, I1 },
+{"ldc2", "E,o(b)", 0xd8000000, 0xfc000000, CLD|RD_b|WR_CC, I2 },
+{"ldc2", "E,A(b)", 0, (int) M_LDC2_AB, INSN_MACRO, I2 },
+{"ldc3", "E,o(b)", 0xdc000000, 0xfc000000, CLD|RD_b|WR_CC, I2 },
+{"ldc3", "E,A(b)", 0, (int) M_LDC3_AB, INSN_MACRO, I2 },
+{"ldl", "t,o(b)", 0x68000000, 0xfc000000, LDD|WR_t|RD_b, I3 },
+{"ldl", "t,A(b)", 0, (int) M_LDL_AB, INSN_MACRO, I3 },
+{"ldr", "t,o(b)", 0x6c000000, 0xfc000000, LDD|WR_t|RD_b, I3 },
+{"ldr", "t,A(b)", 0, (int) M_LDR_AB, INSN_MACRO, I3 },
+{"ldxc1", "D,t(b)", 0x4c000001, 0xfc00f83f, LDD|WR_D|RD_t|RD_b, I4 },
+{"lh", "t,o(b)", 0x84000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lh", "t,A(b)", 0, (int) M_LH_AB, INSN_MACRO, I1 },
+{"lhu", "t,o(b)", 0x94000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lhu", "t,A(b)", 0, (int) M_LHU_AB, INSN_MACRO, I1 },
+/* li is at the start of the table. */
+{"li.d", "t,F", 0, (int) M_LI_D, INSN_MACRO, I1 },
+{"li.d", "T,L", 0, (int) M_LI_DD, INSN_MACRO, I1 },
+{"li.s", "t,f", 0, (int) M_LI_S, INSN_MACRO, I1 },
+{"li.s", "T,l", 0, (int) M_LI_SS, INSN_MACRO, I1 },
+{"ll", "t,o(b)", 0xc0000000, 0xfc000000, LDD|RD_b|WR_t, I2 },
+{"ll", "t,A(b)", 0, (int) M_LL_AB, INSN_MACRO, I2 },
+{"lld", "t,o(b)", 0xd0000000, 0xfc000000, LDD|RD_b|WR_t, I3 },
+{"lld", "t,A(b)", 0, (int) M_LLD_AB, INSN_MACRO, I3 },
+{"lui", "t,u", 0x3c000000, 0xffe00000, WR_t, I1 },
+{"lw", "t,o(b)", 0x8c000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lw", "t,A(b)", 0, (int) M_LW_AB, INSN_MACRO, I1 },
+{"lwc0", "E,o(b)", 0xc0000000, 0xfc000000, CLD|RD_b|WR_CC, I1 },
+{"lwc0", "E,A(b)", 0, (int) M_LWC0_AB, INSN_MACRO, I1 },
+{"lwc1", "T,o(b)", 0xc4000000, 0xfc000000, CLD|RD_b|WR_T|FP_S, I1 },
+{"lwc1", "E,o(b)", 0xc4000000, 0xfc000000, CLD|RD_b|WR_T|FP_S, I1 },
+{"lwc1", "T,A(b)", 0, (int) M_LWC1_AB, INSN_MACRO, I1 },
+{"lwc1", "E,A(b)", 0, (int) M_LWC1_AB, INSN_MACRO, I1 },
+{"l.s", "T,o(b)", 0xc4000000, 0xfc000000, CLD|RD_b|WR_T|FP_S, I1 }, /* lwc1 */
+{"l.s", "T,A(b)", 0, (int) M_LWC1_AB, INSN_MACRO, I1 },
+{"lwc2", "E,o(b)", 0xc8000000, 0xfc000000, CLD|RD_b|WR_CC, I1 },
+{"lwc2", "E,A(b)", 0, (int) M_LWC2_AB, INSN_MACRO, I1 },
+{"lwc3", "E,o(b)", 0xcc000000, 0xfc000000, CLD|RD_b|WR_CC, I1 },
+{"lwc3", "E,A(b)", 0, (int) M_LWC3_AB, INSN_MACRO, I1 },
+{"lwl", "t,o(b)", 0x88000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lwl", "t,A(b)", 0, (int) M_LWL_AB, INSN_MACRO, I1 },
+{"lcache", "t,o(b)", 0x88000000, 0xfc000000, LDD|RD_b|WR_t, I2 }, /* same */
+{"lcache", "t,A(b)", 0, (int) M_LWL_AB, INSN_MACRO, I2 }, /* as lwl */
+{"lwr", "t,o(b)", 0x98000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
+{"lwr", "t,A(b)", 0, (int) M_LWR_AB, INSN_MACRO, I1 },
+{"flush", "t,o(b)", 0x98000000, 0xfc000000, LDD|RD_b|WR_t, I2 }, /* same */
+{"flush", "t,A(b)", 0, (int) M_LWR_AB, INSN_MACRO, I2 }, /* as lwr */
+{"lwu", "t,o(b)", 0x9c000000, 0xfc000000, LDD|RD_b|WR_t, I3 },
+{"lwu", "t,A(b)", 0, (int) M_LWU_AB, INSN_MACRO, I3 },
+{"lwxc1", "D,t(b)", 0x4c000000, 0xfc00f83f, LDD|WR_D|RD_t|RD_b, I4 },
+
+
+{"mad", "s,t", 0x70000000, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|RD_HI|RD_LO, P3 },
+{"madu", "s,t", 0x70000001, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|RD_HI|RD_LO, P3 },
+{"madd.d", "D,R,S,T", 0x4c000021, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, I4 },
+{"madd.s", "D,R,S,T", 0x4c000020, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, I4 },
+{"madd", "s,t", 0x0000001c, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, L1 },
+{"madd", "s,t", 0x70000000, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|IS_M, G1 },
+{"madd", "d,s,t", 0x70000000, 0xfc0007ff, RD_s|RD_t|WR_HI|WR_LO|WR_d|IS_M, G1 },
+{"maddu", "s,t", 0x0000001d, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, L1 },
+{"maddu", "s,t", 0x70000001, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|IS_M, G1},
+{"maddu", "d,s,t", 0x70000001, 0xfc0007ff, RD_s|RD_t|WR_HI|WR_LO|WR_d|IS_M, G1},
+{"madd16", "s,t", 0x00000028, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|RD_HI|RD_LO, V1 },
+{"mfc0", "t,G", 0x40000000, 0xffe007ff, LCD|WR_t|RD_C0, I1 },
+{"mfc1", "t,S", 0x44000000, 0xffe007ff, LCD|WR_t|RD_S|FP_S, I1 },
+{"mfc1", "t,G", 0x44000000, 0xffe007ff, LCD|WR_t|RD_S|FP_S, I1 },
+{"mfc2", "t,G", 0x48000000, 0xffe007ff, LCD|WR_t|RD_C2, I1 },
+{"mfc3", "t,G", 0x4c000000, 0xffe007ff, LCD|WR_t|RD_C3, I1 },
+{"mfhi", "d", 0x00000010, 0xffff07ff, WR_d|RD_HI, I1 },
+{"mflo", "d", 0x00000012, 0xffff07ff, WR_d|RD_LO, I1 },
+{"mov.d", "D,S", 0x46200006, 0xffff003f, WR_D|RD_S|FP_D, I1 },
+{"mov.s", "D,S", 0x46000006, 0xffff003f, WR_D|RD_S|FP_S, I1 },
+{"movf", "d,s,N", 0x00000001, 0xfc0307ff, WR_d|RD_s|RD_CC|FP_D|FP_S, I4 },
+{"movf.d", "D,S,N", 0x46200011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, I4 },
+{"movf.s", "D,S,N", 0x46000011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_S, I4 },
+{"movn", "d,v,t", 0x0000000b, 0xfc0007ff, WR_d|RD_s|RD_t, I4 },
+{"ffc", "d,v", 0x0000000b, 0xfc1f07ff, WR_d|RD_s,L1 },
+{"movn.d", "D,S,t", 0x46200013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, I4 },
+{"movn.s", "D,S,t", 0x46000013, 0xffe0003f, WR_D|RD_S|RD_t|FP_S, I4 },
+{"movt", "d,s,N", 0x00010001, 0xfc0307ff, WR_d|RD_s|RD_CC, I4 },
+{"movt.d", "D,S,N", 0x46210011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, I4 },
+{"movt.s", "D,S,N", 0x46010011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_S, I4 },
+{"movz", "d,v,t", 0x0000000a, 0xfc0007ff, WR_d|RD_s|RD_t, I4 },
+{"ffs", "d,v", 0x0000000a, 0xfc1f07ff, WR_d|RD_s,L1 },
+{"movz.d", "D,S,t", 0x46200012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, I4 },
+{"movz.s", "D,S,t", 0x46000012, 0xffe0003f, WR_D|RD_S|RD_t|FP_S, I4 },
+/* move is at the top of the table. */
+{"msub.d", "D,R,S,T", 0x4c000029, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, I4 },
+{"msub.s", "D,R,S,T", 0x4c000028, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, I4 },
+{"msub", "s,t", 0x0000001e, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO,L1 },
+{"msubu", "s,t", 0x0000001f, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO,L1 },
+{"mtc0", "t,G", 0x40800000, 0xffe007ff, COD|RD_t|WR_C0|WR_CC, I1 },
+{"mtc1", "t,S", 0x44800000, 0xffe007ff, COD|RD_t|WR_S|FP_S, I1 },
+{"mtc1", "t,G", 0x44800000, 0xffe007ff, COD|RD_t|WR_S|FP_S, I1 },
+{"mtc2", "t,G", 0x48800000, 0xffe007ff, COD|RD_t|WR_C2|WR_CC, I1 },
+{"mtc3", "t,G", 0x4c800000, 0xffe007ff, COD|RD_t|WR_C3|WR_CC, I1 },
+{"mthi", "s", 0x00000011, 0xfc1fffff, RD_s|WR_HI, I1 },
+{"mtlo", "s", 0x00000013, 0xfc1fffff, RD_s|WR_LO, I1 },
+{"mul.d", "D,V,T", 0x46200002, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, I1 },
+{"mul.s", "D,V,T", 0x46000002, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, I1 },
+{"mul", "d,v,t", 0x70000002, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HI|WR_LO,P3},
+{"mul", "d,v,t", 0, (int) M_MUL, INSN_MACRO, I1 },
+{"mul", "d,v,I", 0, (int) M_MUL_I, INSN_MACRO, I1 },
+{"mulo", "d,v,t", 0, (int) M_MULO, INSN_MACRO, I1 },
+{"mulo", "d,v,I", 0, (int) M_MULO_I, INSN_MACRO, I1 },
+{"mulou", "d,v,t", 0, (int) M_MULOU, INSN_MACRO, I1 },
+{"mulou", "d,v,I", 0, (int) M_MULOU_I, INSN_MACRO, I1 },
+{"mult", "s,t", 0x00000018, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|IS_M, I1},
+{"mult", "d,s,t", 0x00000018, 0xfc0007ff, RD_s|RD_t|WR_HI|WR_LO|WR_d|IS_M, G1},
+{"multu", "s,t", 0x00000019, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO|IS_M, I1},
+{"multu", "d,s,t", 0x00000019, 0xfc0007ff, RD_s|RD_t|WR_HI|WR_LO|WR_d|IS_M, G1},
+{"neg", "d,w", 0x00000022, 0xffe007ff, WR_d|RD_t, I1 }, /* sub 0 */
+{"negu", "d,w", 0x00000023, 0xffe007ff, WR_d|RD_t, I1 }, /* subu 0 */
+{"neg.d", "D,V", 0x46200007, 0xffff003f, WR_D|RD_S|FP_D, I1 },
+{"neg.s", "D,V", 0x46000007, 0xffff003f, WR_D|RD_S|FP_S, I1 },
+{"nmadd.d", "D,R,S,T", 0x4c000031, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, I4 },
+{"nmadd.s", "D,R,S,T", 0x4c000030, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, I4 },
+{"nmsub.d", "D,R,S,T", 0x4c000039, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, I4 },
+{"nmsub.s", "D,R,S,T", 0x4c000038, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, I4 },
+/* nop is at the start of the table. */
+{"nor", "d,v,t", 0x00000027, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"nor", "t,r,I", 0, (int) M_NOR_I, INSN_MACRO, I1 },
+{"not", "d,v", 0x00000027, 0xfc1f07ff, WR_d|RD_s|RD_t, I1 },/*nor d,s,0*/
+{"or", "d,v,t", 0x00000025, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"or", "t,r,I", 0, (int) M_OR_I, INSN_MACRO, I1 },
+{"ori", "t,r,i", 0x34000000, 0xfc000000, WR_t|RD_s, I1 },
+
+
+{"pref", "k,o(b)", 0xcc000000, 0xfc000000, RD_b, G3 },
+{"prefx", "h,t(b)", 0x4c00000f, 0xfc0007ff, RD_b|RD_t, I4 },
+
+
+{"recip.d", "D,S", 0x46200015, 0xffff003f, WR_D|RD_S|FP_D, I4 },
+{"recip.s", "D,S", 0x46000015, 0xffff003f, WR_D|RD_S|FP_S, I4 },
+{"rem", "z,s,t", 0x0000001a, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I1 },
+{"rem", "d,v,t", 0, (int) M_REM_3, INSN_MACRO, I1 },
+{"rem", "d,v,I", 0, (int) M_REM_3I, INSN_MACRO, I1 },
+{"remu", "z,s,t", 0x0000001b, 0xfc00ffff, RD_s|RD_t|WR_HI|WR_LO, I1 },
+{"remu", "d,v,t", 0, (int) M_REMU_3, INSN_MACRO, I1 },
+{"remu", "d,v,I", 0, (int) M_REMU_3I, INSN_MACRO, I1 },
+{"rfe", "", 0x42000010, 0xffffffff, 0, I1|T3 },
+{"rol", "d,v,t", 0, (int) M_ROL, INSN_MACRO, I1 },
+{"rol", "d,v,I", 0, (int) M_ROL_I, INSN_MACRO, I1 },
+{"ror", "d,v,t", 0, (int) M_ROR, INSN_MACRO, I1 },
+{"ror", "d,v,I", 0, (int) M_ROR_I, INSN_MACRO, I1 },
+{"round.l.d", "D,S", 0x46200008, 0xffff003f, WR_D|RD_S|FP_D, I3 },
+{"round.l.s", "D,S", 0x46000008, 0xffff003f, WR_D|RD_S|FP_S, I3 },
+{"round.w.d", "D,S", 0x4620000c, 0xffff003f, WR_D|RD_S|FP_D, I2 },
+{"round.w.s", "D,S", 0x4600000c, 0xffff003f, WR_D|RD_S|FP_S, I2 },
+{"rsqrt.d", "D,S", 0x46200016, 0xffff003f, WR_D|RD_S|FP_D, I4 },
+{"rsqrt.s", "D,S", 0x46000016, 0xffff003f, WR_D|RD_S|FP_S, I4 },
+{"sb", "t,o(b)", 0xa0000000, 0xfc000000, SM|RD_t|RD_b, I1 },
+{"sb", "t,A(b)", 0, (int) M_SB_AB, INSN_MACRO, I1 },
+{"sc", "t,o(b)", 0xe0000000, 0xfc000000, SM|RD_t|WR_t|RD_b, I2 },
+{"sc", "t,A(b)", 0, (int) M_SC_AB, INSN_MACRO, I2 },
+{"scd", "t,o(b)", 0xf0000000, 0xfc000000, SM|RD_t|WR_t|RD_b, I3 },
+{"scd", "t,A(b)", 0, (int) M_SCD_AB, INSN_MACRO, I3 },
+{"sd", "t,o(b)", 0xfc000000, 0xfc000000, SM|RD_t|RD_b, I3 },
+{"sd", "t,o(b)", 0, (int) M_SD_OB, INSN_MACRO, I1 },
+{"sd", "t,A(b)", 0, (int) M_SD_AB, INSN_MACRO, I1 },
+{"sdbbp", "", 0x0000000e, 0xffffffff, TRAP, G2 },
+{"sdbbp", "c", 0x0000000e, 0xfc00ffff, TRAP, G2 },
+{"sdbbp", "c,q", 0x0000000e, 0xfc00003f, TRAP, G2 },
+{"sdc1", "T,o(b)", 0xf4000000, 0xfc000000, SM|RD_T|RD_b|FP_D, I2 },
+{"sdc1", "E,o(b)", 0xf4000000, 0xfc000000, SM|RD_T|RD_b|FP_D, I2 },
+{"sdc1", "T,A(b)", 0, (int) M_SDC1_AB, INSN_MACRO, I2 },
+{"sdc1", "E,A(b)", 0, (int) M_SDC1_AB, INSN_MACRO, I2 },
+{"sdc2", "E,o(b)", 0xf8000000, 0xfc000000, SM|RD_C2|RD_b, I2 },
+{"sdc2", "E,A(b)", 0, (int) M_SDC2_AB, INSN_MACRO, I2 },
+{"sdc3", "E,o(b)", 0xfc000000, 0xfc000000, SM|RD_C3|RD_b, I2 },
+{"sdc3", "E,A(b)", 0, (int) M_SDC3_AB, INSN_MACRO, I2 },
+{"s.d", "T,o(b)", 0xf4000000, 0xfc000000, SM|RD_T|RD_b|FP_D, I2 },
+{"s.d", "T,o(b)", 0, (int) M_S_DOB, INSN_MACRO, I1 },
+{"s.d", "T,A(b)", 0, (int) M_S_DAB, INSN_MACRO, I1 },
+{"sdl", "t,o(b)", 0xb0000000, 0xfc000000, SM|RD_t|RD_b, I3 },
+{"sdl", "t,A(b)", 0, (int) M_SDL_AB, INSN_MACRO, I3 },
+{"sdr", "t,o(b)", 0xb4000000, 0xfc000000, SM|RD_t|RD_b, I3 },
+{"sdr", "t,A(b)", 0, (int) M_SDR_AB, INSN_MACRO, I3 },
+{"sdxc1", "S,t(b)", 0x4c000009, 0xfc0007ff, SM|RD_S|RD_t|RD_b, I4 },
+{"selsl", "d,v,t", 0x00000005, 0xfc0007ff, WR_d|RD_s|RD_t,L1 },
+{"selsr", "d,v,t", 0x00000001, 0xfc0007ff, WR_d|RD_s|RD_t,L1 },
+{"seq", "d,v,t", 0, (int) M_SEQ, INSN_MACRO, I1 },
+{"seq", "d,v,I", 0, (int) M_SEQ_I, INSN_MACRO, I1 },
+{"sge", "d,v,t", 0, (int) M_SGE, INSN_MACRO, I1 },
+{"sge", "d,v,I", 0, (int) M_SGE_I, INSN_MACRO, I1 },
+{"sgeu", "d,v,t", 0, (int) M_SGEU, INSN_MACRO, I1 },
+{"sgeu", "d,v,I", 0, (int) M_SGEU_I, INSN_MACRO, I1 },
+{"sgt", "d,v,t", 0, (int) M_SGT, INSN_MACRO, I1 },
+{"sgt", "d,v,I", 0, (int) M_SGT_I, INSN_MACRO, I1 },
+{"sgtu", "d,v,t", 0, (int) M_SGTU, INSN_MACRO, I1 },
+{"sgtu", "d,v,I", 0, (int) M_SGTU_I, INSN_MACRO, I1 },
+{"sh", "t,o(b)", 0xa4000000, 0xfc000000, SM|RD_t|RD_b, I1 },
+{"sh", "t,A(b)", 0, (int) M_SH_AB, INSN_MACRO, I1 },
+{"sle", "d,v,t", 0, (int) M_SLE, INSN_MACRO, I1 },
+{"sle", "d,v,I", 0, (int) M_SLE_I, INSN_MACRO, I1 },
+{"sleu", "d,v,t", 0, (int) M_SLEU, INSN_MACRO, I1 },
+{"sleu", "d,v,I", 0, (int) M_SLEU_I, INSN_MACRO, I1 },
+{"sllv", "d,t,s", 0x00000004, 0xfc0007ff, WR_d|RD_t|RD_s, I1 },
+{"sll", "d,w,s", 0x00000004, 0xfc0007ff, WR_d|RD_t|RD_s, I1 }, /* sllv */
+{"sll", "d,w,<", 0x00000000, 0xffe0003f, WR_d|RD_t, I1 },
+{"slt", "d,v,t", 0x0000002a, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"slt", "d,v,I", 0, (int) M_SLT_I, INSN_MACRO, I1 },
+{"slti", "t,r,j", 0x28000000, 0xfc000000, WR_t|RD_s, I1 },
+{"sltiu", "t,r,j", 0x2c000000, 0xfc000000, WR_t|RD_s, I1 },
+{"sltu", "d,v,t", 0x0000002b, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"sltu", "d,v,I", 0, (int) M_SLTU_I, INSN_MACRO, I1 },
+{"sne", "d,v,t", 0, (int) M_SNE, INSN_MACRO, I1 },
+{"sne", "d,v,I", 0, (int) M_SNE_I, INSN_MACRO, I1 },
+{"sqrt.d", "D,S", 0x46200004, 0xffff003f, WR_D|RD_S|FP_D, I2 },
+{"sqrt.s", "D,S", 0x46000004, 0xffff003f, WR_D|RD_S|FP_S, I2 },
+{"srav", "d,t,s", 0x00000007, 0xfc0007ff, WR_d|RD_t|RD_s, I1 },
+{"sra", "d,w,s", 0x00000007, 0xfc0007ff, WR_d|RD_t|RD_s, I1 }, /* srav */
+{"sra", "d,w,<", 0x00000003, 0xffe0003f, WR_d|RD_t, I1 },
+{"srlv", "d,t,s", 0x00000006, 0xfc0007ff, WR_d|RD_t|RD_s, I1 },
+{"srl", "d,w,s", 0x00000006, 0xfc0007ff, WR_d|RD_t|RD_s, I1 }, /* srlv */
+{"srl", "d,w,<", 0x00000002, 0xffe0003f, WR_d|RD_t, I1 },
+{"standby", "", 0x42000021, 0xffffffff, 0, V1 },
+{"sub", "d,v,t", 0x00000022, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"sub", "d,v,I", 0, (int) M_SUB_I, INSN_MACRO, I1 },
+{"sub.d", "D,V,T", 0x46200001, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, I1 },
+{"sub.s", "D,V,T", 0x46000001, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, I1 },
+{"subu", "d,v,t", 0x00000023, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"subu", "d,v,I", 0, (int) M_SUBU_I, INSN_MACRO, I1 },
+{"suspend", "", 0x42000022, 0xffffffff, 0, V1 },
+{"sw", "t,o(b)", 0xac000000, 0xfc000000, SM|RD_t|RD_b, I1 },
+{"sw", "t,A(b)", 0, (int) M_SW_AB, INSN_MACRO, I1 },
+{"swc0", "E,o(b)", 0xe0000000, 0xfc000000, SM|RD_C0|RD_b, I1 },
+{"swc0", "E,A(b)", 0, (int) M_SWC0_AB, INSN_MACRO, I1 },
+{"swc1", "T,o(b)", 0xe4000000, 0xfc000000, SM|RD_T|RD_b|FP_S, I1 },
+{"swc1", "E,o(b)", 0xe4000000, 0xfc000000, SM|RD_T|RD_b|FP_S, I1 },
+{"swc1", "T,A(b)", 0, (int) M_SWC1_AB, INSN_MACRO, I1 },
+{"swc1", "E,A(b)", 0, (int) M_SWC1_AB, INSN_MACRO, I1 },
+{"s.s", "T,o(b)", 0xe4000000, 0xfc000000, SM|RD_T|RD_b|FP_S, I1 }, /* swc1 */
+{"s.s", "T,A(b)", 0, (int) M_SWC1_AB, INSN_MACRO, I1 },
+{"swc2", "E,o(b)", 0xe8000000, 0xfc000000, SM|RD_C2|RD_b, I1 },
+{"swc2", "E,A(b)", 0, (int) M_SWC2_AB, INSN_MACRO, I1 },
+{"swc3", "E,o(b)", 0xec000000, 0xfc000000, SM|RD_C3|RD_b, I1 },
+{"swc3", "E,A(b)", 0, (int) M_SWC3_AB, INSN_MACRO, I1 },
+{"swl", "t,o(b)", 0xa8000000, 0xfc000000, SM|RD_t|RD_b, I1 },
+{"swl", "t,A(b)", 0, (int) M_SWL_AB, INSN_MACRO, I1 },
+{"scache", "t,o(b)", 0xa8000000, 0xfc000000, RD_t|RD_b, I2 }, /* same */
+{"scache", "t,A(b)", 0, (int) M_SWL_AB, INSN_MACRO, I2 }, /* as swl */
+{"swr", "t,o(b)", 0xb8000000, 0xfc000000, SM|RD_t|RD_b, I1 },
+{"swr", "t,A(b)", 0, (int) M_SWR_AB, INSN_MACRO, I1 },
+{"invalidate", "t,o(b)",0xb8000000, 0xfc000000, RD_t|RD_b, I2 }, /* same */
+{"invalidate", "t,A(b)",0, (int) M_SWR_AB, INSN_MACRO, I2 }, /* as swr */
+{"swxc1", "S,t(b)", 0x4c000008, 0xfc0007ff, SM|RD_S|RD_t|RD_b, I4 },
+{"sync", "", 0x0000000f, 0xffffffff, INSN_SYNC, I2|G1 },
+{"sync.p", "", 0x0000040f, 0xffffffff, INSN_SYNC, I2 },
+{"sync.l", "", 0x0000000f, 0xffffffff, INSN_SYNC, I2 },
+{"syscall", "", 0x0000000c, 0xffffffff, TRAP, I1 },
+{"syscall", "B", 0x0000000c, 0xfc00003f, TRAP, I1 },
+{"teqi", "s,j", 0x040c0000, 0xfc1f0000, RD_s|TRAP, I2 },
+{"teq", "s,t", 0x00000034, 0xfc00ffff, RD_s|RD_t|TRAP, I2 },
+{"teq", "s,t,q", 0x00000034, 0xfc00003f, RD_s|RD_t|TRAP, I2 },
+{"teq", "s,j", 0x040c0000, 0xfc1f0000, RD_s|TRAP, I2 }, /* teqi */
+{"teq", "s,I", 0, (int) M_TEQ_I, INSN_MACRO, I2 },
+{"tgei", "s,j", 0x04080000, 0xfc1f0000, RD_s|TRAP, I2 },
+{"tge", "s,t", 0x00000030, 0xfc00ffff, RD_s|RD_t|TRAP, I2 },
+{"tge", "s,t,q", 0x00000030, 0xfc00003f, RD_s|RD_t|TRAP, I2 },
+{"tge", "s,j", 0x04080000, 0xfc1f0000, RD_s|TRAP, I2 }, /* tgei */
+{"tge", "s,I", 0, (int) M_TGE_I, INSN_MACRO, I2 },
+{"tgeiu", "s,j", 0x04090000, 0xfc1f0000, RD_s|TRAP, I2 },
+{"tgeu", "s,t", 0x00000031, 0xfc00ffff, RD_s|RD_t|TRAP, I2 },
+{"tgeu", "s,t,q", 0x00000031, 0xfc00003f, RD_s|RD_t|TRAP, I2 },
+{"tgeu", "s,j", 0x04090000, 0xfc1f0000, RD_s|TRAP, I2 }, /* tgeiu */
+{"tgeu", "s,I", 0, (int) M_TGEU_I, INSN_MACRO, I2 },
+{"tlbp", "", 0x42000008, 0xffffffff, INSN_TLB, I1 },
+{"tlbr", "", 0x42000001, 0xffffffff, INSN_TLB, I1 },
+{"tlbwi", "", 0x42000002, 0xffffffff, INSN_TLB, I1 },
+{"tlbwr", "", 0x42000006, 0xffffffff, INSN_TLB, I1 },
+{"tlti", "s,j", 0x040a0000, 0xfc1f0000, RD_s|TRAP, I2 },
+{"tlt", "s,t", 0x00000032, 0xfc00ffff, RD_s|RD_t|TRAP, I2 },
+{"tlt", "s,t,q", 0x00000032, 0xfc00003f, RD_s|RD_t|TRAP, I2 },
+{"tlt", "s,j", 0x040a0000, 0xfc1f0000, RD_s|TRAP, I2 }, /* tlti */
+{"tlt", "s,I", 0, (int) M_TLT_I, INSN_MACRO, I2 },
+{"tltiu", "s,j", 0x040b0000, 0xfc1f0000, RD_s|TRAP, I2 },
+{"tltu", "s,t", 0x00000033, 0xfc00ffff, RD_s|RD_t|TRAP, I2 },
+{"tltu", "s,t,q", 0x00000033, 0xfc00003f, RD_s|RD_t|TRAP, I2 },
+{"tltu", "s,j", 0x040b0000, 0xfc1f0000, RD_s|TRAP, I2 }, /* tltiu */
+{"tltu", "s,I", 0, (int) M_TLTU_I, INSN_MACRO, I2 },
+{"tnei", "s,j", 0x040e0000, 0xfc1f0000, RD_s|TRAP, I2 },
+{"tne", "s,t", 0x00000036, 0xfc00ffff, RD_s|RD_t|TRAP, I2 },
+{"tne", "s,t,q", 0x00000036, 0xfc00003f, RD_s|RD_t|TRAP, I2 },
+{"tne", "s,j", 0x040e0000, 0xfc1f0000, RD_s|TRAP, I2 }, /* tnei */
+{"tne", "s,I", 0, (int) M_TNE_I, INSN_MACRO, I2 },
+{"trunc.l.d", "D,S", 0x46200009, 0xffff003f, WR_D|RD_S|FP_D, I3 },
+{"trunc.l.s", "D,S", 0x46000009, 0xffff003f, WR_D|RD_S|FP_S, I3 },
+{"trunc.w.d", "D,S", 0x4620000d, 0xffff003f, WR_D|RD_S|FP_D, I2 },
+{"trunc.w.d", "D,S,x", 0x4620000d, 0xffff003f, WR_D|RD_S|FP_D, I2 },
+{"trunc.w.d", "D,S,t", 0, (int) M_TRUNCWD, INSN_MACRO, I1 },
+{"trunc.w.s", "D,S", 0x4600000d, 0xffff003f, WR_D|RD_S|FP_S, I2 },
+{"trunc.w.s", "D,S,x", 0x4600000d, 0xffff003f, WR_D|RD_S|FP_S, I2 },
+{"trunc.w.s", "D,S,t", 0, (int) M_TRUNCWS, INSN_MACRO, I1 },
+{"uld", "t,o(b)", 0, (int) M_ULD, INSN_MACRO, I3 },
+{"uld", "t,A(b)", 0, (int) M_ULD_A, INSN_MACRO, I3 },
+{"ulh", "t,o(b)", 0, (int) M_ULH, INSN_MACRO, I1 },
+{"ulh", "t,A(b)", 0, (int) M_ULH_A, INSN_MACRO, I1 },
+{"ulhu", "t,o(b)", 0, (int) M_ULHU, INSN_MACRO, I1 },
+{"ulhu", "t,A(b)", 0, (int) M_ULHU_A, INSN_MACRO, I1 },
+{"ulw", "t,o(b)", 0, (int) M_ULW, INSN_MACRO, I1 },
+{"ulw", "t,A(b)", 0, (int) M_ULW_A, INSN_MACRO, I1 },
+{"usd", "t,o(b)", 0, (int) M_USD, INSN_MACRO, I3 },
+{"usd", "t,A(b)", 0, (int) M_USD_A, INSN_MACRO, I3 },
+{"ush", "t,o(b)", 0, (int) M_USH, INSN_MACRO, I1 },
+{"ush", "t,A(b)", 0, (int) M_USH_A, INSN_MACRO, I1 },
+{"usw", "t,o(b)", 0, (int) M_USW, INSN_MACRO, I1 },
+{"usw", "t,A(b)", 0, (int) M_USW_A, INSN_MACRO, I1 },
+{"xor", "d,v,t", 0x00000026, 0xfc0007ff, WR_d|RD_s|RD_t, I1 },
+{"xor", "t,r,I", 0, (int) M_XOR_I, INSN_MACRO, I1 },
+{"xori", "t,r,i", 0x38000000, 0xfc000000, WR_t|RD_s, I1 },
+{"wait", "", 0x42000020, 0xffffffff, TRAP, I3 },
+{"waiti", "", 0x42000020, 0xffffffff, TRAP, L1 },
+{"wb", "o(b)", 0xbc040000, 0xfc1f0000, SM|RD_b, L1 },
+/* No hazard protection on coprocessor instructions--they shouldn't
+ change the state of the processor and if they do it's up to the
+ user to put in nops as necessary. These are at the end so that the
+ disasembler recognizes more specific versions first. */
+{"c0", "C", 0x42000000, 0xfe000000, 0, I1 },
+{"c1", "C", 0x46000000, 0xfe000000, 0, I1 },
+{"c2", "C", 0x4a000000, 0xfe000000, 0, I1 },
+{"c3", "C", 0x4e000000, 0xfe000000, 0, I1 },
+{"cop0", "C", 0, (int) M_COP0, INSN_MACRO, I1 },
+{"cop1", "C", 0, (int) M_COP1, INSN_MACRO, I1 },
+{"cop2", "C", 0, (int) M_COP2, INSN_MACRO, I1 },
+{"cop3", "C", 0, (int) M_COP3, INSN_MACRO, I1 },
+
+ /* Conflicts with the 4650's "mul" instruction. Nobody's using the
+ 4010 any more, so move this insn out of the way. If the object
+ format gave us more info, we could do this right. */
+{"addciu", "t,r,j", 0x70000000, 0xfc000000, WR_t|RD_s,L1 },
+};
+
+#define MIPS_NUM_OPCODES \
+ ((sizeof mips_builtin_opcodes) / (sizeof (mips_builtin_opcodes[0])))
+const int bfd_mips_num_builtin_opcodes = MIPS_NUM_OPCODES;
+
+/* const removed from the following to allow for dynamic extensions to the
+ * built-in instruction set. */
+struct mips_opcode *mips_opcodes =
+ (struct mips_opcode *) mips_builtin_opcodes;
+int bfd_mips_num_opcodes = MIPS_NUM_OPCODES;
+#undef MIPS_NUM_OPCODES
+
diff --git a/opcodes/mips16-opc.c b/opcodes/mips16-opc.c
new file mode 100644
index 00000000000..dad2dbb2e5a
--- /dev/null
+++ b/opcodes/mips16-opc.c
@@ -0,0 +1,226 @@
+/* mips16-opc.c. Mips16 opcode table.
+ Copyright 1996, 1997 Free Software Foundation, Inc.
+ Contributed by Ian Lance Taylor, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/mips.h"
+
+/* This is the opcodes table for the mips16 processor. The format of
+ this table is intentionally identical to the one in mips-opc.c.
+ However, the special letters that appear in the argument string are
+ different, and the table uses some different flags. */
+
+/* Use some short hand macros to keep down the length of the lines in
+ the opcodes table. */
+
+#define UBD INSN_UNCOND_BRANCH_DELAY
+#define BR MIPS16_INSN_BRANCH
+
+#define WR_x MIPS16_INSN_WRITE_X
+#define WR_y MIPS16_INSN_WRITE_Y
+#define WR_z MIPS16_INSN_WRITE_Z
+#define WR_T MIPS16_INSN_WRITE_T
+#define WR_SP MIPS16_INSN_WRITE_SP
+#define WR_31 MIPS16_INSN_WRITE_31
+#define WR_Y MIPS16_INSN_WRITE_GPR_Y
+
+#define RD_x MIPS16_INSN_READ_X
+#define RD_y MIPS16_INSN_READ_Y
+#define RD_Z MIPS16_INSN_READ_Z
+#define RD_T MIPS16_INSN_READ_T
+#define RD_SP MIPS16_INSN_READ_SP
+#define RD_31 MIPS16_INSN_READ_31
+#define RD_PC MIPS16_INSN_READ_PC
+#define RD_X MIPS16_INSN_READ_GPR_X
+
+#define WR_HI INSN_WRITE_HI
+#define WR_LO INSN_WRITE_LO
+#define RD_HI INSN_READ_HI
+#define RD_LO INSN_READ_LO
+
+#define TRAP INSN_TRAP
+
+#define I3 INSN_ISA3
+
+#define T3 INSN_3900
+
+const struct mips_opcode mips16_opcodes[] = {
+{"nop", "", 0x6500, 0xffff, RD_Z }, /* move $0,$Z */
+{"la", "x,A", 0x0800, 0xf800, WR_x|RD_PC },
+{"abs", "x,w", 0, (int) M_ABS, INSN_MACRO },
+{"addiu", "y,x,4", 0x4000, 0xf810, WR_y|RD_x },
+{"addiu", "x,k", 0x4800, 0xf800, WR_x|RD_x },
+{"addiu", "S,K", 0x6300, 0xff00, WR_SP|RD_SP },
+{"addiu", "S,S,K", 0x6300, 0xff00, WR_SP|RD_SP },
+{"addiu", "x,P,V", 0x0800, 0xf800, WR_x|RD_PC },
+{"addiu", "x,S,V", 0x0000, 0xf800, WR_x|RD_SP },
+{"addu", "z,v,y", 0xe001, 0xf803, WR_z|RD_x|RD_y },
+{"addu", "y,x,4", 0x4000, 0xf810, WR_y|RD_x },
+{"addu", "x,k", 0x4800, 0xf800, WR_x|RD_x },
+{"addu", "S,K", 0x6300, 0xff00, WR_SP|RD_SP },
+{"addu", "S,S,K", 0x6300, 0xff00, WR_SP|RD_SP },
+{"addu", "x,P,V", 0x0800, 0xf800, WR_x|RD_PC },
+{"addu", "x,S,V", 0x0000, 0xf800, WR_x|RD_SP },
+{"and", "x,y", 0xe80c, 0xf81f, WR_x|RD_x|RD_y },
+{"b", "q", 0x1000, 0xf800, BR},
+{"beq", "x,y,p", 0, (int) M_BEQ, INSN_MACRO },
+{"beq", "x,U,p", 0, (int) M_BEQ_I, INSN_MACRO },
+{"beqz", "x,p", 0x2000, 0xf800, BR|RD_x },
+{"bge", "x,y,p", 0, (int) M_BGE, INSN_MACRO },
+{"bge", "x,8,p", 0, (int) M_BGE_I, INSN_MACRO },
+{"bgeu", "x,y,p", 0, (int) M_BGEU, INSN_MACRO },
+{"bgeu", "x,8,p", 0, (int) M_BGEU_I, INSN_MACRO },
+{"bgt", "x,y,p", 0, (int) M_BGT, INSN_MACRO },
+{"bgt", "x,8,p", 0, (int) M_BGT_I, INSN_MACRO },
+{"bgtu", "x,y,p", 0, (int) M_BGTU, INSN_MACRO },
+{"bgtu", "x,8,p", 0, (int) M_BGTU_I, INSN_MACRO },
+{"ble", "x,y,p", 0, (int) M_BLE, INSN_MACRO },
+{"ble", "x,8,p", 0, (int) M_BLE_I, INSN_MACRO },
+{"bleu", "x,y,p", 0, (int) M_BLEU, INSN_MACRO },
+{"bleu", "x,8,p", 0, (int) M_BLEU_I, INSN_MACRO },
+{"blt", "x,y,p", 0, (int) M_BLT, INSN_MACRO },
+{"blt", "x,8,p", 0, (int) M_BLT_I, INSN_MACRO },
+{"bltu", "x,y,p", 0, (int) M_BLTU, INSN_MACRO },
+{"bltu", "x,8,p", 0, (int) M_BLTU_I, INSN_MACRO },
+{"bne", "x,y,p", 0, (int) M_BNE, INSN_MACRO },
+{"bne", "x,U,p", 0, (int) M_BNE_I, INSN_MACRO },
+{"bnez", "x,p", 0x2800, 0xf800, BR|RD_x },
+{"break", "6", 0xe805, 0xf81f, TRAP },
+{"bteqz", "p", 0x6000, 0xff00, BR|RD_T },
+{"btnez", "p", 0x6100, 0xff00, BR|RD_T },
+{"cmpi", "x,U", 0x7000, 0xf800, WR_T|RD_x },
+{"cmp", "x,y", 0xe80a, 0xf81f, WR_T|RD_x|RD_y },
+{"cmp", "x,U", 0x7000, 0xf800, WR_T|RD_x },
+{"dla", "y,E", 0xfe00, 0xff00, WR_y|RD_PC, I3 },
+{"daddiu", "y,x,4", 0x4010, 0xf810, WR_y|RD_x, I3 },
+{"daddiu", "y,j", 0xfd00, 0xff00, WR_y|RD_y, I3 },
+{"daddiu", "S,K", 0xfb00, 0xff00, WR_SP|RD_SP, I3 },
+{"daddiu", "S,S,K", 0xfb00, 0xff00, WR_SP|RD_SP, I3 },
+{"daddiu", "y,P,W", 0xfe00, 0xff00, WR_y|RD_PC, I3 },
+{"daddiu", "y,S,W", 0xff00, 0xff00, WR_y|RD_SP, I3 },
+{"daddu", "z,v,y", 0xe000, 0xf803, WR_z|RD_x|RD_y, I3 },
+{"daddu", "y,x,4", 0x4010, 0xf810, WR_y|RD_x, I3 },
+{"daddu", "y,j", 0xfd00, 0xff00, WR_y|RD_y, I3 },
+{"daddu", "S,K", 0xfb00, 0xff00, WR_SP|RD_SP, I3 },
+{"daddu", "S,S,K", 0xfb00, 0xff00, WR_SP|RD_SP, I3 },
+{"daddu", "y,P,W", 0xfe00, 0xff00, WR_y|RD_PC, I3 },
+{"daddu", "y,S,W", 0xff00, 0xff00, WR_y|RD_SP, I3 },
+{"ddiv", "0,x,y", 0xe81e, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, I3 },
+{"ddiv", "z,v,y", 0, (int) M_DDIV_3, INSN_MACRO },
+{"ddivu", "0,x,y", 0xe81f, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, I3 },
+{"ddivu", "z,v,y", 0, (int) M_DDIVU_3, INSN_MACRO },
+{"div", "0,x,y", 0xe81a, 0xf81f, RD_x|RD_y|WR_HI|WR_LO },
+{"div", "z,v,y", 0, (int) M_DIV_3, INSN_MACRO },
+{"divu", "0,x,y", 0xe81b, 0xf81f, RD_x|RD_y|WR_HI|WR_LO },
+{"divu", "z,v,y", 0, (int) M_DIVU_3, INSN_MACRO },
+{"dmul", "z,v,y", 0, (int) M_DMUL, INSN_MACRO, I3 },
+{"dmult", "x,y", 0xe81c, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, I3 },
+{"dmultu", "x,y", 0xe81d, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, I3 },
+{"drem", "0,x,y", 0xe81e, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, I3 },
+{"drem", "z,v,y", 0, (int) M_DREM_3, INSN_MACRO },
+{"dremu", "0,x,y", 0xe81f, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, I3 },
+{"dremu", "z,v,y", 0, (int) M_DREMU_3, INSN_MACRO },
+{"dsllv", "y,x", 0xe814, 0xf81f, WR_y|RD_y|RD_x, I3 },
+{"dsll", "x,w,[", 0x3001, 0xf803, WR_x|RD_y, I3 },
+{"dsll", "y,x", 0xe814, 0xf81f, WR_y|RD_y|RD_x, I3 },
+{"dsrav", "y,x", 0xe817, 0xf81f, WR_y|RD_y|RD_x, I3 },
+{"dsra", "y,]", 0xe813, 0xf81f, WR_y|RD_y, I3 },
+{"dsra", "y,x", 0xe817, 0xf81f, WR_y|RD_y|RD_x, I3 },
+{"dsrlv", "y,x", 0xe816, 0xf81f, WR_y|RD_y|RD_x, I3 },
+{"dsrl", "y,]", 0xe808, 0xf81f, WR_y|RD_y, I3 },
+{"dsrl", "y,x", 0xe816, 0xf81f, WR_y|RD_y|RD_x, I3 },
+{"dsubu", "z,v,y", 0xe002, 0xf803, WR_z|RD_x|RD_y, I3 },
+{"dsubu", "y,x,4", 0, (int) M_DSUBU_I, INSN_MACRO },
+{"dsubu", "y,j", 0, (int) M_DSUBU_I_2, INSN_MACRO },
+{"exit", "L", 0xed09, 0xff1f, TRAP },
+{"exit", "L", 0xee09, 0xff1f, TRAP },
+{"exit", "L", 0xef09, 0xff1f, TRAP },
+{"entry", "l", 0xe809, 0xf81f, TRAP },
+{"extend", "e", 0xf000, 0xf800, 0 },
+{"jalr", "x", 0xe840, 0xf8ff, UBD|WR_31|RD_x },
+{"jalr", "R,x", 0xe840, 0xf8ff, UBD|WR_31|RD_x },
+{"jal", "x", 0xe840, 0xf8ff, UBD|WR_31|RD_x },
+{"jal", "R,x", 0xe840, 0xf8ff, UBD|WR_31|RD_x },
+{"jal", "a", 0x1800, 0xfc00, UBD|WR_31 },
+{"jalx", "a", 0x1c00, 0xfc00, UBD|WR_31 },
+{"jr", "x", 0xe800, 0xf8ff, UBD|RD_x },
+{"jr", "R", 0xe820, 0xffff, UBD|RD_31 },
+{"j", "x", 0xe800, 0xf8ff, UBD|RD_x },
+{"j", "R", 0xe820, 0xffff, UBD|RD_31 },
+{"lb", "y,5(x)", 0x8000, 0xf800, WR_y|RD_x },
+{"lbu", "y,5(x)", 0xa000, 0xf800, WR_y|RD_x },
+{"ld", "y,D(x)", 0x3800, 0xf800, WR_y|RD_x, I3 },
+{"ld", "y,B", 0xfc00, 0xff00, WR_y|RD_PC, I3 },
+{"ld", "y,D(P)", 0xfc00, 0xff00, WR_y|RD_PC, I3 },
+{"ld", "y,D(S)", 0xf800, 0xff00, WR_y|RD_SP, I3 },
+{"lh", "y,H(x)", 0x8800, 0xf800, WR_y|RD_x },
+{"lhu", "y,H(x)", 0xa800, 0xf800, WR_y|RD_x },
+{"li", "x,U", 0x6800, 0xf800, WR_x },
+{"lw", "y,W(x)", 0x9800, 0xf800, WR_y|RD_x },
+{"lw", "x,A", 0xb000, 0xf800, WR_x|RD_PC },
+{"lw", "x,V(P)", 0xb000, 0xf800, WR_x|RD_PC },
+{"lw", "x,V(S)", 0x9000, 0xf800, WR_x|RD_SP },
+{"lwu", "y,W(x)", 0xb800, 0xf800, WR_y|RD_x, I3 },
+{"mfhi", "x", 0xe810, 0xf8ff, WR_x|RD_HI },
+{"mflo", "x", 0xe812, 0xf8ff, WR_x|RD_LO },
+{"move", "y,X", 0x6700, 0xff00, WR_y|RD_X },
+{"move", "Y,Z", 0x6500, 0xff00, WR_Y|RD_Z },
+{"mul", "z,v,y", 0, (int) M_MUL, INSN_MACRO },
+{"mult", "x,y", 0xe818, 0xf81f, RD_x|RD_y|WR_HI|WR_LO },
+{"multu", "x,y", 0xe819, 0xf81f, RD_x|RD_y|WR_HI|WR_LO },
+{"neg", "x,w", 0xe80b, 0xf81f, WR_x|RD_y },
+{"not", "x,w", 0xe80f, 0xf81f, WR_x|RD_y },
+{"or", "x,y", 0xe80d, 0xf81f, WR_x|RD_x|RD_y },
+{"rem", "0,x,y", 0xe81a, 0xf81f, RD_x|RD_y|WR_HI|WR_LO },
+{"rem", "z,v,y", 0, (int) M_REM_3, INSN_MACRO },
+{"remu", "0,x,y", 0xe81b, 0xf81f, RD_x|RD_y|WR_HI|WR_LO },
+{"remu", "z,v,y", 0, (int) M_REMU_3, INSN_MACRO },
+{"sb", "y,5(x)", 0xc000, 0xf800, RD_y|RD_x },
+{"sd", "y,D(x)", 0x7800, 0xf800, RD_y|RD_x, I3 },
+{"sd", "y,D(S)", 0xf900, 0xff00, RD_y|RD_PC, I3 },
+{"sd", "R,C(S)", 0xfa00, 0xff00, RD_31|RD_PC },
+{"sh", "y,H(x)", 0xc800, 0xf800, RD_y|RD_x },
+{"sllv", "y,x", 0xe804, 0xf81f, WR_y|RD_y|RD_x },
+{"sll", "x,w,<", 0x3000, 0xf803, WR_x|RD_y },
+{"sll", "y,x", 0xe804, 0xf81f, WR_y|RD_y|RD_x },
+{"slti", "x,8", 0x5000, 0xf800, WR_T|RD_x },
+{"slt", "x,y", 0xe802, 0xf81f, WR_T|RD_x|RD_y },
+{"slt", "x,8", 0x5000, 0xf800, WR_T|RD_x },
+{"sltiu", "x,8", 0x5800, 0xf800, WR_T|RD_x },
+{"sltu", "x,y", 0xe803, 0xf81f, WR_T|RD_x|RD_y },
+{"sltu", "x,8", 0x5800, 0xf800, WR_T|RD_x },
+{"srav", "y,x", 0xe807, 0xf81f, WR_y|RD_y|RD_x },
+{"sra", "x,w,<", 0x3003, 0xf803, WR_x|RD_y },
+{"sra", "y,x", 0xe807, 0xf81f, WR_y|RD_y|RD_x },
+{"srlv", "y,x", 0xe806, 0xf81f, WR_y|RD_y|RD_x },
+{"srl", "x,w,<", 0x3002, 0xf803, WR_x|RD_y },
+{"srl", "y,x", 0xe806, 0xf81f, WR_y|RD_y|RD_x },
+{"subu", "z,v,y", 0xe003, 0xf803, WR_z|RD_x|RD_y },
+{"subu", "y,x,4", 0, (int) M_SUBU_I, INSN_MACRO },
+{"subu", "x,k", 0, (int) M_SUBU_I_2, INSN_MACRO },
+{"sw", "y,W(x)", 0xd800, 0xf800, RD_y|RD_x },
+{"sw", "x,V(S)", 0xd000, 0xf800, RD_x|RD_SP },
+{"sw", "R,V(S)", 0x6200, 0xff00, RD_31|RD_SP },
+{"xor", "x,y", 0xe80e, 0xf81f, WR_x|RD_x|RD_y },
+};
+
+const int bfd_mips16_num_opcodes =
+ ((sizeof mips16_opcodes) / (sizeof (mips16_opcodes[0])));
diff --git a/opcodes/mpw-config.in b/opcodes/mpw-config.in
new file mode 100644
index 00000000000..ff9be9d72f4
--- /dev/null
+++ b/opcodes/mpw-config.in
@@ -0,0 +1,27 @@
+# Configuration fragment for opcodes.
+
+Set target_arch `echo {target_canonical} | sed -e 's/-.*-.*//'`
+
+Set archname ARCH_{target_arch}
+
+If "{target_arch}" =~ /m68k/
+ Set BFD_MACHINES '"{o}"m68k-dis.c.o "{o}"m68k-opc.c.o'
+Else If "{target_arch}" =~ /powerpc/
+ Set BFD_MACHINES '"{o}"ppc-dis.c.o "{o}"ppc-opc.c.o'
+Else If "{target_arch}" =~ /i386/
+ Set BFD_MACHINES '"{o}"i386-dis.c.o'
+Else If "{target_arch}" =~ /mips/
+ Set BFD_MACHINES '"{o}"mips-dis.c.o "{o}"mips-opc.c.o'
+Else If "{target_arch}" =~ /sh/
+ Set BFD_MACHINES '"{o}"sh-dis.c.o'
+End If
+
+Echo '# Start from mpw-config.in' > "{o}"mk.tmp
+Echo "BFD_MACHINES = " {BFD_MACHINES} >> "{o}"mk.tmp
+Echo "ARCHDEFS = -d" {archname} >> "{o}"mk.tmp
+Echo '# End from mpw-config.in' >> "{o}"mk.tmp
+
+Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
+Echo '#include "mpw.h"' >> "{o}"config.new
+
+MoveIfChange "{o}"config.new "{o}"config.h
diff --git a/opcodes/mpw-make.sed b/opcodes/mpw-make.sed
new file mode 100644
index 00000000000..ee604862de6
--- /dev/null
+++ b/opcodes/mpw-make.sed
@@ -0,0 +1,25 @@
+# Sed commands to finish translating the opcodes Makefile.in into MPW syntax.
+
+# Empty HDEFINES.
+/HDEFINES/s/@HDEFINES@//
+
+# Fix pathnames to include directories.
+/^INCDIR = /s/^INCDIR = .*$/INCDIR = "{topsrcdir}"include/
+/^CSEARCH = /s/$/ -i "{INCDIR}":mpw: -i ::extra-include:/
+
+/BFD_MACHINES/s/@BFD_MACHINES@/{BFD_MACHINES}/
+/archdefs/s/@archdefs@/{ARCHDEFS}/
+
+# No PIC foolery in this environment.
+/@ALLLIBS@/s/@ALLLIBS@/{TARGETLIB}/
+/@PICLIST@/s/@PICLIST@//
+/@PICFLAG@/s/@PICFLAG@//
+/^{OFILES} \\Option-f stamp-picdir/,/^$/d
+
+# Remove the pic trickery from the default build rule.
+/^\.c\.o \\Option-f /,/End If/c\
+.c.o \\Option-f .c
+
+# Remove pic trickery from other rules - aimed at the rule
+# for disassemble.o in particular.
+/-n "{PICFLAG}"/,/End If/d
diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c
new file mode 100644
index 00000000000..050266be849
--- /dev/null
+++ b/opcodes/ns32k-dis.c
@@ -0,0 +1,894 @@
+/* Print National Semiconductor 32000 instructions.
+ Copyright (c) 1986, 88, 91, 92, 94, 95, 1998 Free Software Foundation, Inc.
+
+This file is part of opcodes library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "dis-asm.h"
+#if !defined(const) && !defined(__STDC__)
+#define const
+#endif
+#include "opcode/ns32k.h"
+#include "opintl.h"
+
+static disassemble_info *dis_info;
+
+/*
+ * Hacks to get it to compile <= READ THESE AS FIXES NEEDED
+ */
+#define INVALID_FLOAT(val, size) invalid_float((char *)val, size)
+
+static int print_insn_arg
+ PARAMS ((int, int, int *, char *, bfd_vma, char *, int));
+static int get_displacement PARAMS ((char *, int *));
+static int invalid_float PARAMS ((char *, int));
+
+static long read_memory_integer(addr, nr)
+ unsigned char *addr;
+ int nr;
+{
+ long val;
+ int i;
+ for (val = 0, i = nr - 1; i >= 0; i--) {
+ val = (val << 8);
+ val |= (0xff & *(addr + i));
+ }
+ return val;
+}
+
+/* 32000 instructions are never longer than this. */
+#define MAXLEN 62
+
+
+#include <setjmp.h>
+
+struct private
+{
+ /* Points to first byte not fetched. */
+ bfd_byte *max_fetched;
+ bfd_byte the_buffer[MAXLEN];
+ bfd_vma insn_start;
+ jmp_buf bailout;
+};
+
+
+/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
+ to ADDR (exclusive) are valid. Returns 1 for success, longjmps
+ on error. */
+#define FETCH_DATA(info, addr) \
+ ((addr) <= ((struct private *)(info->private_data))->max_fetched \
+ ? 1 : fetch_data ((info), (addr)))
+
+static int
+fetch_data (info, addr)
+ struct disassemble_info *info;
+ bfd_byte *addr;
+{
+ int status;
+ struct private *priv = (struct private *)info->private_data;
+ bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
+
+ status = (*info->read_memory_func) (start,
+ priv->max_fetched,
+ addr - priv->max_fetched,
+ info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, start, info);
+ longjmp (priv->bailout, 1);
+ }
+ else
+ priv->max_fetched = addr;
+ return 1;
+}
+/* Number of elements in the opcode table. */
+#define NOPCODES (sizeof ns32k_opcodes / sizeof ns32k_opcodes[0])
+
+#define NEXT_IS_ADDR '|'
+
+
+struct ns32k_option {
+ char *pattern; /* the option itself */
+ unsigned long value; /* binary value of the option */
+ unsigned long match; /* these bits must match */
+};
+
+
+static const struct ns32k_option opt_u[]= /* restore, exit */
+{
+ { "r0", 0x80, 0x80 },
+ { "r1", 0x40, 0x40 },
+ { "r2", 0x20, 0x20 },
+ { "r3", 0x10, 0x10 },
+ { "r4", 0x08, 0x08 },
+ { "r5", 0x04, 0x04 },
+ { "r6", 0x02, 0x02 },
+ { "r7", 0x01, 0x01 },
+ { 0 , 0x00, 0x00 }
+};
+
+static const struct ns32k_option opt_U[]= /* save, enter */
+{
+ { "r0", 0x01, 0x01 },
+ { "r1", 0x02, 0x02 },
+ { "r2", 0x04, 0x04 },
+ { "r3", 0x08, 0x08 },
+ { "r4", 0x10, 0x10 },
+ { "r5", 0x20, 0x20 },
+ { "r6", 0x40, 0x40 },
+ { "r7", 0x80, 0x80 },
+ { 0 , 0x00, 0x00 }
+};
+
+static const struct ns32k_option opt_O[]= /* setcfg */
+{
+ { "c", 0x8, 0x8 },
+ { "m", 0x4, 0x4 },
+ { "f", 0x2, 0x2 },
+ { "i", 0x1, 0x1 },
+ { 0 , 0x0, 0x0 }
+};
+
+static const struct ns32k_option opt_C[]= /* cinv */
+{
+ { "a", 0x4, 0x4 },
+ { "i", 0x2, 0x2 },
+ { "d", 0x1, 0x1 },
+ { 0 , 0x0, 0x0 }
+};
+
+static const struct ns32k_option opt_S[]= /* string inst */
+{
+ { "b", 0x1, 0x1 },
+ { "u", 0x6, 0x6 },
+ { "w", 0x2, 0x2 },
+ { 0 , 0x0, 0x0 }
+};
+
+static const struct ns32k_option list_P532[]= /* lpr spr */
+{
+ { "us", 0x0, 0xf },
+ { "dcr", 0x1, 0xf },
+ { "bpc", 0x2, 0xf },
+ { "dsr", 0x3, 0xf },
+ { "car", 0x4, 0xf },
+ { "fp", 0x8, 0xf },
+ { "sp", 0x9, 0xf },
+ { "sb", 0xa, 0xf },
+ { "usp", 0xb, 0xf },
+ { "cfg", 0xc, 0xf },
+ { "psr", 0xd, 0xf },
+ { "intbase", 0xe, 0xf },
+ { "mod", 0xf, 0xf },
+ { 0 , 0x00, 0xf }
+};
+
+static const struct ns32k_option list_M532[]= /* lmr smr */
+{
+ { "mcr", 0x9, 0xf },
+ { "msr", 0xa, 0xf },
+ { "tear", 0xb, 0xf },
+ { "ptb0", 0xc, 0xf },
+ { "ptb1", 0xd, 0xf },
+ { "ivar0", 0xe, 0xf },
+ { "ivar1", 0xf, 0xf },
+ { 0 , 0x0, 0xf }
+};
+
+static const struct ns32k_option list_P032[]= /* lpr spr */
+{
+ { "upsr", 0x0, 0xf },
+ { "fp", 0x8, 0xf },
+ { "sp", 0x9, 0xf },
+ { "sb", 0xa, 0xf },
+ { "psr", 0xb, 0xf },
+ { "intbase", 0xe, 0xf },
+ { "mod", 0xf, 0xf },
+ { 0 , 0x0, 0xf }
+};
+
+static const struct ns32k_option list_M032[]= /* lmr smr */
+{
+ { "bpr0", 0x0, 0xf },
+ { "bpr1", 0x1, 0xf },
+ { "pf0", 0x4, 0xf },
+ { "pf1", 0x5, 0xf },
+ { "sc", 0x8, 0xf },
+ { "msr", 0xa, 0xf },
+ { "bcnt", 0xb, 0xf },
+ { "ptb0", 0xc, 0xf },
+ { "ptb1", 0xd, 0xf },
+ { "eia", 0xf, 0xf },
+ { 0 , 0x0, 0xf }
+};
+
+
+/*
+ * figure out which options are present
+ */
+static void
+optlist(options, optionP, result)
+ int options;
+ const struct ns32k_option *optionP;
+ char *result;
+{
+ if (options == 0) {
+ sprintf(result, "[]");
+ return;
+ }
+ sprintf(result, "[");
+
+ for (; (options != 0) && optionP->pattern; optionP++) {
+ if ((options & optionP->match) == optionP->value) {
+ /* we found a match, update result and options */
+ strcat(result, optionP->pattern);
+ options &= ~optionP->value;
+ if (options != 0) /* more options to come */
+ strcat(result, ",");
+ }
+ }
+ if (options != 0)
+ strcat(result, "undefined");
+
+ strcat(result, "]");
+}
+
+static void
+list_search (reg_value, optionP, result)
+ int reg_value;
+ const struct ns32k_option *optionP;
+ char *result;
+{
+ for (; optionP->pattern; optionP++) {
+ if ((reg_value & optionP->match) == optionP->value) {
+ sprintf(result, "%s", optionP->pattern);
+ return;
+ }
+ }
+ sprintf(result, "undefined");
+}
+
+/*
+ * extract "count" bits starting "offset" bits
+ * into buffer
+ */
+
+static int
+bit_extract (buffer, offset, count)
+ bfd_byte *buffer;
+ int offset;
+ int count;
+{
+ int result;
+ int bit;
+
+ buffer += offset >> 3;
+ offset &= 7;
+ bit = 1;
+ result = 0;
+ while (count--)
+ {
+ FETCH_DATA(dis_info, buffer + 1);
+ if ((*buffer & (1 << offset)))
+ result |= bit;
+ if (++offset == 8)
+ {
+ offset = 0;
+ buffer++;
+ }
+ bit <<= 1;
+ }
+ return result;
+}
+
+/* Like bit extract but the buffer is valid and doen't need to be
+ * fetched
+ */
+static int
+bit_extract_simple (buffer, offset, count)
+ bfd_byte *buffer;
+ int offset;
+ int count;
+{
+ int result;
+ int mask;
+ int bit;
+
+ buffer += offset >> 3;
+ offset &= 7;
+ bit = 1;
+ result = 0;
+ while (count--)
+ {
+ if ((*buffer & (1 << offset)))
+ result |= bit;
+ if (++offset == 8)
+ {
+ offset = 0;
+ buffer++;
+ }
+ bit <<= 1;
+ }
+ return result;
+}
+
+static void
+bit_copy (buffer, offset, count, to)
+ char *buffer;
+ int offset;
+ int count;
+ char *to;
+{
+ for(; count > 8; count -= 8, to++, offset += 8)
+ *to = bit_extract (buffer, offset, 8);
+ *to = bit_extract (buffer, offset, count);
+}
+
+
+static int
+sign_extend (value, bits)
+ int value, bits;
+{
+ value = value & ((1 << bits) - 1);
+ return (value & (1 << (bits-1))
+ ? value | (~((1 << bits) - 1))
+ : value);
+}
+
+static void
+flip_bytes (ptr, count)
+ char *ptr;
+ int count;
+{
+ char tmp;
+
+ while (count > 0)
+ {
+ tmp = ptr[0];
+ ptr[0] = ptr[count-1];
+ ptr[count-1] = tmp;
+ ptr++;
+ count -= 2;
+ }
+}
+
+/* Given a character C, does it represent a general addressing mode? */
+#define Is_gen(c) \
+ ((c) == 'F' || (c) == 'L' || (c) == 'B' \
+ || (c) == 'W' || (c) == 'D' || (c) == 'A' || (c) == 'I' || (c) == 'Z')
+
+/* Adressing modes. */
+#define Adrmod_index_byte 0x1c
+#define Adrmod_index_word 0x1d
+#define Adrmod_index_doubleword 0x1e
+#define Adrmod_index_quadword 0x1f
+
+/* Is MODE an indexed addressing mode? */
+#define Adrmod_is_index(mode) \
+ (mode == Adrmod_index_byte \
+ || mode == Adrmod_index_word \
+ || mode == Adrmod_index_doubleword \
+ || mode == Adrmod_index_quadword)
+
+
+/* Print the 32000 instruction at address MEMADDR in debugged memory,
+ on STREAM. Returns length of the instruction, in bytes. */
+
+int
+print_insn_ns32k (memaddr, info)
+ bfd_vma memaddr;
+ disassemble_info *info;
+{
+ register unsigned int i;
+ register char *d;
+ unsigned short first_word;
+ int ioffset; /* bits into instruction */
+ int aoffset; /* bits into arguments */
+ char arg_bufs[MAX_ARGS+1][ARG_LEN];
+ int argnum;
+ int maxarg;
+ struct private priv;
+ bfd_byte *buffer = priv.the_buffer;
+ dis_info = info;
+
+ info->private_data = (PTR) &priv;
+ priv.max_fetched = priv.the_buffer;
+ priv.insn_start = memaddr;
+ if (setjmp (priv.bailout) != 0)
+ /* Error return. */
+ return -1;
+
+ /* Look for 8bit opcodes first. Other wise, fetching two bytes could take
+ * us over the end of accessible data unnecessarilly
+ */
+ FETCH_DATA(info, buffer + 1);
+ for (i = 0; i < NOPCODES; i++)
+ if (ns32k_opcodes[i].opcode_id_size <= 8
+ && ((buffer[0]
+ & (((unsigned long) 1 << ns32k_opcodes[i].opcode_id_size) - 1))
+ == ns32k_opcodes[i].opcode_seed))
+ break;
+ if (i == NOPCODES) {
+ /* Maybe it is 9 to 16 bits big */
+ FETCH_DATA(info, buffer + 2);
+ first_word = read_memory_integer(buffer, 2);
+
+ for (i = 0; i < NOPCODES; i++)
+ if ((first_word
+ & (((unsigned long) 1 << ns32k_opcodes[i].opcode_id_size) - 1))
+ == ns32k_opcodes[i].opcode_seed)
+ break;
+
+ /* Handle undefined instructions. */
+ if (i == NOPCODES)
+ {
+ (*dis_info->fprintf_func)(dis_info->stream, "0%o", buffer[0]);
+ return 1;
+ }
+ }
+
+ (*dis_info->fprintf_func)(dis_info->stream, "%s", ns32k_opcodes[i].name);
+
+ ioffset = ns32k_opcodes[i].opcode_size;
+ aoffset = ns32k_opcodes[i].opcode_size;
+ d = ns32k_opcodes[i].operands;
+
+ if (*d)
+ {
+ /* Offset in bits of the first thing beyond each index byte.
+ Element 0 is for operand A and element 1 is for operand B.
+ The rest are irrelevant, but we put them here so we don't
+ index outside the array. */
+ int index_offset[MAX_ARGS];
+
+ /* 0 for operand A, 1 for operand B, greater for other args. */
+ int whicharg = 0;
+
+ (*dis_info->fprintf_func)(dis_info->stream, "\t");
+
+ maxarg = 0;
+
+ /* First we have to find and keep track of the index bytes,
+ if we are using scaled indexed addressing mode, since the index
+ bytes occur right after the basic instruction, not as part
+ of the addressing extension. */
+ if (Is_gen(d[1]))
+ {
+ int addr_mode = bit_extract (buffer, ioffset - 5, 5);
+
+ if (Adrmod_is_index (addr_mode))
+ {
+ aoffset += 8;
+ index_offset[0] = aoffset;
+ }
+ }
+ if (d[2] && Is_gen(d[3]))
+ {
+ int addr_mode = bit_extract (buffer, ioffset - 10, 5);
+
+ if (Adrmod_is_index (addr_mode))
+ {
+ aoffset += 8;
+ index_offset[1] = aoffset;
+ }
+ }
+
+ while (*d)
+ {
+ argnum = *d - '1';
+ d++;
+ if (argnum > maxarg && argnum < MAX_ARGS)
+ maxarg = argnum;
+ ioffset = print_insn_arg (*d, ioffset, &aoffset, buffer,
+ memaddr, arg_bufs[argnum],
+ index_offset[whicharg]);
+ d++;
+ whicharg++;
+ }
+ for (argnum = 0; argnum <= maxarg; argnum++)
+ {
+ bfd_vma addr;
+ char *ch;
+ for (ch = arg_bufs[argnum]; *ch;)
+ {
+ if (*ch == NEXT_IS_ADDR)
+ {
+ ++ch;
+ addr = bfd_scan_vma (ch, NULL, 16);
+ (*dis_info->print_address_func) (addr, dis_info);
+ while (*ch && *ch != NEXT_IS_ADDR)
+ ++ch;
+ if (*ch)
+ ++ch;
+ }
+ else
+ (*dis_info->fprintf_func)(dis_info->stream, "%c", *ch++);
+ }
+ if (argnum < maxarg)
+ (*dis_info->fprintf_func)(dis_info->stream, ", ");
+ }
+ }
+ return aoffset / 8;
+}
+
+/* Print an instruction operand of category given by d. IOFFSET is
+ the bit position below which small (<1 byte) parts of the operand can
+ be found (usually in the basic instruction, but for indexed
+ addressing it can be in the index byte). AOFFSETP is a pointer to the
+ bit position of the addressing extension. BUFFER contains the
+ instruction. ADDR is where BUFFER was read from. Put the disassembled
+ version of the operand in RESULT. INDEX_OFFSET is the bit position
+ of the index byte (it contains garbage if this operand is not a
+ general operand using scaled indexed addressing mode). */
+
+static int
+print_insn_arg (d, ioffset, aoffsetp, buffer, addr, result, index_offset)
+ int d;
+ int ioffset, *aoffsetp;
+ char *buffer;
+ bfd_vma addr;
+ char *result;
+ int index_offset;
+{
+ int addr_mode;
+ float Fvalue;
+ double Lvalue;
+ int Ivalue;
+ int disp1, disp2;
+ int index;
+ int size;
+
+ switch (d)
+ {
+ case 'f':
+ /* a "gen" operand but 5 bits from the end of instruction */
+ ioffset -= 5;
+ case 'Z':
+ case 'F':
+ case 'L':
+ case 'I':
+ case 'B':
+ case 'W':
+ case 'D':
+ case 'A':
+ addr_mode = bit_extract (buffer, ioffset-5, 5);
+ ioffset -= 5;
+ switch (addr_mode)
+ {
+ case 0x0: case 0x1: case 0x2: case 0x3:
+ case 0x4: case 0x5: case 0x6: case 0x7:
+ /* register mode R0 -- R7 */
+ switch (d)
+ {
+ case 'F':
+ case 'L':
+ case 'Z':
+ sprintf (result, "f%d", addr_mode);
+ break;
+ default:
+ sprintf (result, "r%d", addr_mode);
+ }
+ break;
+ case 0x8: case 0x9: case 0xa: case 0xb:
+ case 0xc: case 0xd: case 0xe: case 0xf:
+ /* Register relative disp(R0 -- R7) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "%d(r%d)", disp1, addr_mode & 7);
+ break;
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ /* Memory relative disp2(disp1(FP, SP, SB)) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ disp2 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "%d(%d(%s))", disp2, disp1,
+ addr_mode==0x10?"fp":addr_mode==0x11?"sp":"sb");
+ break;
+ case 0x13:
+ /* reserved */
+ sprintf (result, "reserved");
+ break;
+ case 0x14:
+ /* Immediate */
+ switch (d)
+ {
+ case 'I': case 'Z': case 'A':
+ /* I and Z are output operands and can`t be immediate
+ * A is an address and we can`t have the address of
+ * an immediate either. We don't know how much to increase
+ * aoffsetp by since whatever generated this is broken
+ * anyway!
+ */
+ sprintf (result, _("$<undefined>"));
+ break;
+ case 'B':
+ Ivalue = bit_extract (buffer, *aoffsetp, 8);
+ Ivalue = sign_extend (Ivalue, 8);
+ *aoffsetp += 8;
+ sprintf (result, "$%d", Ivalue);
+ break;
+ case 'W':
+ Ivalue = bit_extract (buffer, *aoffsetp, 16);
+ flip_bytes (&Ivalue, 2);
+ *aoffsetp += 16;
+ Ivalue = sign_extend (Ivalue, 16);
+ sprintf (result, "$%d", Ivalue);
+ break;
+ case 'D':
+ Ivalue = bit_extract (buffer, *aoffsetp, 32);
+ flip_bytes (&Ivalue, 4);
+ *aoffsetp += 32;
+ sprintf (result, "$%d", Ivalue);
+ break;
+ case 'F':
+ bit_copy (buffer, *aoffsetp, 32, (char *) &Fvalue);
+ flip_bytes (&Fvalue, 4);
+ *aoffsetp += 32;
+ if (INVALID_FLOAT (&Fvalue, 4))
+ sprintf (result, "<<invalid float 0x%.8x>>", *(int *) &Fvalue);
+ else /* assume host has ieee float */
+ sprintf (result, "$%g", Fvalue);
+ break;
+ case 'L':
+ bit_copy (buffer, *aoffsetp, 64, (char *) &Lvalue);
+ flip_bytes (&Lvalue, 8);
+ *aoffsetp += 64;
+ if (INVALID_FLOAT (&Lvalue, 8))
+ sprintf (result, "<<invalid long 0x%.8x%.8x>>",
+ *(((int *) &Lvalue) + 1), *(int *) &Lvalue);
+ else /* assume host has ieee float */
+ sprintf (result, "$%g", Lvalue);
+ break;
+ }
+ break;
+ case 0x15:
+ /* Absolute @disp */
+ disp1 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "@|%d|", disp1);
+ break;
+ case 0x16:
+ /* External EXT(disp1) + disp2 (Mod table stuff) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ disp2 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "EXT(%d) + %d", disp1, disp2);
+ break;
+ case 0x17:
+ /* Top of stack tos */
+ sprintf (result, "tos");
+ break;
+ case 0x18:
+ /* Memory space disp(FP) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "%d(fp)", disp1);
+ break;
+ case 0x19:
+ /* Memory space disp(SP) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "%d(sp)", disp1);
+ break;
+ case 0x1a:
+ /* Memory space disp(SB) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ sprintf (result, "%d(sb)", disp1);
+ break;
+ case 0x1b:
+ /* Memory space disp(PC) */
+ disp1 = get_displacement (buffer, aoffsetp);
+ *result++ = NEXT_IS_ADDR;
+ sprintf_vma (result, addr + disp1);
+ result += strlen (result);
+ *result++ = NEXT_IS_ADDR;
+ *result = '\0';
+ break;
+ case 0x1c:
+ case 0x1d:
+ case 0x1e:
+ case 0x1f:
+ /* Scaled index basemode[R0 -- R7:B,W,D,Q] */
+ index = bit_extract (buffer, index_offset - 8, 3);
+ print_insn_arg (d, index_offset, aoffsetp, buffer, addr,
+ result, 0);
+ {
+ static const char *ind = "bwdq";
+ char *off;
+
+ off = result + strlen (result);
+ sprintf (off, "[r%d:%c]", index,
+ ind[addr_mode & 3]);
+ }
+ break;
+ }
+ break;
+ case 'H':
+ case 'q':
+ Ivalue = bit_extract (buffer, ioffset-4, 4);
+ Ivalue = sign_extend (Ivalue, 4);
+ sprintf (result, "%d", Ivalue);
+ ioffset -= 4;
+ break;
+ case 'r':
+ Ivalue = bit_extract (buffer, ioffset-3, 3);
+ sprintf (result, "r%d", Ivalue&7);
+ ioffset -= 3;
+ break;
+ case 'd':
+ sprintf (result, "%d", get_displacement (buffer, aoffsetp));
+ break;
+ case 'b':
+ Ivalue = get_displacement (buffer, aoffsetp);
+ /*
+ * Warning!! HACK ALERT!
+ * Operand type 'b' is only used by the cmp{b,w,d} and
+ * movm{b,w,d} instructions; we need to know whether
+ * it's a `b' or `w' or `d' instruction; and for both
+ * cmpm and movm it's stored at the same place so we
+ * just grab two bits of the opcode and look at it...
+ *
+ */
+ size = bit_extract(buffer, ioffset-6, 2);
+ if (size == 0) /* 00 => b */
+ size = 1;
+ else if (size == 1) /* 01 => w */
+ size = 2;
+ else
+ size = 4; /* 11 => d */
+
+ sprintf (result, "%d", (Ivalue / size) + 1);
+ break;
+ case 'p':
+ *result++ = NEXT_IS_ADDR;
+ sprintf_vma (result, addr + get_displacement (buffer, aoffsetp));
+ result += strlen (result);
+ *result++ = NEXT_IS_ADDR;
+ *result = '\0';
+ break;
+ case 'i':
+ Ivalue = bit_extract (buffer, *aoffsetp, 8);
+ *aoffsetp += 8;
+ sprintf (result, "0x%x", Ivalue);
+ break;
+ case 'u':
+ Ivalue = bit_extract (buffer, *aoffsetp, 8);
+ optlist(Ivalue, opt_u, result);
+ *aoffsetp += 8;
+ break;
+ case 'U':
+ Ivalue = bit_extract(buffer, *aoffsetp, 8);
+ optlist(Ivalue, opt_U, result);
+ *aoffsetp += 8;
+ break;
+ case 'O':
+ Ivalue = bit_extract(buffer, ioffset-9, 9);
+ optlist(Ivalue, opt_O, result);
+ ioffset -= 9;
+ break;
+ case 'C':
+ Ivalue = bit_extract(buffer, ioffset-4, 4);
+ optlist(Ivalue, opt_C, result);
+ ioffset -= 4;
+ break;
+ case 'S':
+ Ivalue = bit_extract(buffer, ioffset - 8, 8);
+ optlist(Ivalue, opt_S, result);
+ ioffset -= 8;
+ break;
+ case 'M':
+ Ivalue = bit_extract(buffer, ioffset-4, 4);
+ list_search(Ivalue, 0 ? list_M032 : list_M532, result);
+ ioffset -= 4;
+ break;
+ case 'P':
+ Ivalue = bit_extract(buffer, ioffset-4, 4);
+ list_search(Ivalue, 0 ? list_P032 : list_P532, result);
+ ioffset -= 4;
+ break;
+ case 'g':
+ Ivalue = bit_extract(buffer, *aoffsetp, 3);
+ sprintf(result, "%d", Ivalue);
+ *aoffsetp += 3;
+ break;
+ case 'G':
+ Ivalue = bit_extract(buffer, *aoffsetp, 5);
+ sprintf(result, "%d", Ivalue + 1);
+ *aoffsetp += 5;
+ break;
+ }
+ return ioffset;
+}
+
+static int
+get_displacement (buffer, aoffsetp)
+ char *buffer;
+ int *aoffsetp;
+{
+ int Ivalue;
+ short Ivalue2;
+
+ Ivalue = bit_extract (buffer, *aoffsetp, 8);
+ switch (Ivalue & 0xc0)
+ {
+ case 0x00:
+ case 0x40:
+ Ivalue = sign_extend (Ivalue, 7);
+ *aoffsetp += 8;
+ break;
+ case 0x80:
+ Ivalue2 = bit_extract (buffer, *aoffsetp, 16);
+ flip_bytes (&Ivalue2, 2);
+ Ivalue = sign_extend (Ivalue2, 14);
+ *aoffsetp += 16;
+ break;
+ case 0xc0:
+ Ivalue = bit_extract (buffer, *aoffsetp, 32);
+ flip_bytes (&Ivalue, 4);
+ Ivalue = sign_extend (Ivalue, 30);
+ *aoffsetp += 32;
+ break;
+ }
+ return Ivalue;
+}
+
+
+#if 1 /* a version that should work on ns32k f's&d's on any machine */
+static int
+invalid_float (p, len)
+ register char *p;
+ register int len;
+{
+ register int val;
+
+ if ( len == 4 )
+ val = (bit_extract_simple(p, 23, 8)/*exponent*/ == 0xff
+ || (bit_extract_simple(p, 23, 8)/*exponent*/ == 0 &&
+ bit_extract_simple(p, 0, 23)/*mantisa*/ != 0));
+ else if ( len == 8 )
+ val = (bit_extract_simple(p, 52, 11)/*exponent*/ == 0x7ff
+ || (bit_extract_simple(p, 52, 11)/*exponent*/ == 0
+ && (bit_extract_simple(p, 0, 32)/*low mantisa*/ != 0
+ || bit_extract_simple(p, 32, 20)/*high mantisa*/ != 0)));
+ else
+ val = 1;
+ return (val);
+}
+#else
+
+/* assumes the bytes have been swapped to local order */
+typedef union { double d;
+ float f;
+ struct { unsigned m:23, e:8, :1;} sf;
+ struct { unsigned lm; unsigned m:20, e:11, :1;} sd;
+ } float_type_u;
+
+static int
+invalid_float (p, len)
+ register float_type_u *p;
+ register int len;
+{
+ register int val;
+ if ( len == sizeof (float) )
+ val = (p->sf.e == 0xff
+ || (p->sf.e == 0 && p->sf.m != 0));
+ else if ( len == sizeof (double) )
+ val = (p->sd.e == 0x7ff
+ || (p->sd.e == 0 && (p->sd.m != 0 || p->sd.lm != 0)));
+ else
+ val = 1;
+ return (val);
+}
+#endif
diff --git a/opcodes/opintl.h b/opcodes/opintl.h
new file mode 100644
index 00000000000..a5901604081
--- /dev/null
+++ b/opcodes/opintl.h
@@ -0,0 +1,30 @@
+/* opintl.h - opcodes specific header for gettext code.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ Written by Tom Tromey <tromey@cygnus.com>
+
+ This file is part of the opcodes library used by GAS and the GNU binutils.
+
+ You should have received a copy of the GNU General Public License
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# define _(String) dgettext (PACKAGE, String)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+/* Stubs that do something close enough. */
+# define textdomain(String) (String)
+# define gettext(String) (String)
+# define dgettext(Domain,Message) (Message)
+# define dcgettext(Domain,Message,Type) (Message)
+# define bindtextdomain(Domain,Directory) (Domain)
+# define _(String) (String)
+# define N_(String) (String)
+#endif
diff --git a/opcodes/po/Make-in b/opcodes/po/Make-in
new file mode 100644
index 00000000000..0552db1feef
--- /dev/null
+++ b/opcodes/po/Make-in
@@ -0,0 +1,251 @@
+# Makefile for program source directory in GNU NLS utilities package.
+# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+#
+# This file file be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SHELL = /bin/sh
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+datadir = $(prefix)/@DATADIRNAME@
+localedir = $(datadir)/locale
+gnulocaledir = $(prefix)/share/locale
+gettextsrcdir = $(prefix)/share/gettext/po
+subdir = po
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+
+CC = @CC@
+GENCAT = @GENCAT@
+GMSGFMT = PATH=../src:$$PATH @GMSGFMT@
+MSGFMT = @MSGFMT@
+XGETTEXT = PATH=../src:$$PATH @XGETTEXT@
+MSGMERGE = PATH=../src:$$PATH msgmerge
+
+DEFS = @DEFS@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+
+INCLUDES = -I.. -I$(top_srcdir)/intl
+
+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
+
+SOURCES = cat-id-tbl.c
+POFILES = @POFILES@
+GMOFILES = @GMOFILES@
+DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
+stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
+
+POTFILES = \
+
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+INSTOBJEXT = @INSTOBJEXT@
+
+.SUFFIXES:
+.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
+
+.c.o:
+ $(COMPILE) $<
+
+.po.pox:
+ $(MAKE) $(PACKAGE).pot
+ $(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
+
+.po.mo:
+ $(MSGFMT) -o $@ $<
+
+.po.gmo:
+ file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
+ && rm -f $$file && $(GMSGFMT) -o $$file $<
+
+.po.cat:
+ sed -f ../intl/po2msg.sed < $< > $*.msg \
+ && rm -f $@ && $(GENCAT) $@ $*.msg
+
+
+all: all-@USE_NLS@
+
+all-yes: $(CATALOGS) @MAINT@ $(PACKAGE).pot
+all-no:
+
+$(srcdir)/$(PACKAGE).pot: $(POTFILES)
+ $(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(top_srcdir) \
+ --add-comments --keyword=_ --keyword=N_ \
+ --files-from=$(srcdir)/POTFILES.in
+ rm -f $(srcdir)/$(PACKAGE).pot
+ mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot
+
+$(srcdir)/cat-id-tbl.c: stamp-cat-id; @:
+$(srcdir)/stamp-cat-id: $(PACKAGE).pot
+ rm -f cat-id-tbl.tmp
+ sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
+ | sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
+ if cmp -s cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; then \
+ rm cat-id-tbl.tmp; \
+ else \
+ echo cat-id-tbl.c changed; \
+ rm -f $(srcdir)/cat-id-tbl.c; \
+ mv cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; \
+ fi
+ cd $(srcdir) && rm -f stamp-cat-id && echo timestamp > stamp-cat-id
+
+
+install: install-exec install-data
+install-exec:
+install-info:
+install-data: install-data-@USE_NLS@
+install-data-no: all
+install-data-yes: all
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $(datadir); \
+ else \
+ $(top_srcdir)/mkinstalldirs $(datadir); \
+ fi
+ @catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ case "$$cat" in \
+ *.gmo) destdir=$(gnulocaledir);; \
+ *) destdir=$(localedir);; \
+ esac; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ dir=$$destdir/$$lang/LC_MESSAGES; \
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $$dir; \
+ else \
+ $(top_srcdir)/mkinstalldirs $$dir; \
+ fi; \
+ if test -r $$cat; then \
+ $(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
+ echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \
+ else \
+ $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
+ echo "installing $(srcdir)/$$cat as" \
+ "$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
+ fi; \
+ if test -r $$cat.m; then \
+ $(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
+ echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
+ else \
+ if test -r $(srcdir)/$$cat.m ; then \
+ $(INSTALL_DATA) $(srcdir)/$$cat.m \
+ $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
+ echo "installing $(srcdir)/$$cat as" \
+ "$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
+ else \
+ true; \
+ fi; \
+ fi; \
+ done
+ if test "$(PACKAGE)" = "gettext"; then \
+ if test -r $(MKINSTALLDIRS); then \
+ $(MKINSTALLDIRS) $(gettextsrcdir); \
+ else \
+ $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
+ fi; \
+ $(INSTALL_DATA) $(srcdir)/Makefile.in.in \
+ $(gettextsrcdir)/Makefile.in.in; \
+ else \
+ : ; \
+ fi
+
+# Define this as empty until I found a useful application.
+installcheck:
+
+uninstall:
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
+ rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
+ rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
+ rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
+ done
+ rm -f $(gettextsrcdir)/po-Makefile.in.in
+
+check: all
+
+cat-id-tbl.o: ../intl/libgettext.h
+
+dvi info tags TAGS ID:
+
+mostlyclean:
+ rm -f core core.* *.pox $(PACKAGE).po *.old.po cat-id-tbl.tmp
+ rm -fr *.o
+
+clean: mostlyclean
+
+distclean: clean
+ rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
+
+maintainer-clean: distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+ rm -f $(GMOFILES)
+
+distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
+dist distdir: update-po $(DISTFILES)
+ dists="$(DISTFILES)"; \
+ for file in $$dists; do \
+ ln $(srcdir)/$$file $(distdir) 2> /dev/null \
+ || cp -p $(srcdir)/$$file $(distdir); \
+ done
+
+update-po: Makefile
+ $(MAKE) $(PACKAGE).pot
+ PATH=`pwd`/../src:$$PATH; \
+ cd $(srcdir); \
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+ mv $$lang.po $$lang.old.po; \
+ echo "$$lang:"; \
+ if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \
+ rm -f $$lang.old.po; \
+ else \
+ echo "msgmerge for $$cat failed!"; \
+ rm -f $$lang.po; \
+ mv $$lang.old.po $$lang.po; \
+ fi; \
+ done
+
+POTFILES: POTFILES.in
+ ( if test 'x$(srcdir)' != 'x.'; then \
+ posrcprefix='$(top_srcdir)/'; \
+ else \
+ posrcprefix="../"; \
+ fi; \
+ rm -f $@-t $@ \
+ && (sed -e '/^#/d' -e '/^[ ]*$$/d' \
+ -e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
+ | sed -e '$$s/\\$$//') > $@-t \
+ && chmod a-w $@-t \
+ && mv $@-t $@ )
+
+POTFILES.in: @MAINT@ ../Makefile
+ cd .. && $(MAKE) po/POTFILES.in
+
+Makefile: Make-in ../config.status POTFILES
+ cd .. \
+ && CONFIG_FILES=$(subdir)/Makefile.in:$(subdir)/Make-in \
+ CONFIG_HEADERS= $(SHELL) ./config.status
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/opcodes/po/POTFILES.in b/opcodes/po/POTFILES.in
new file mode 100644
index 00000000000..f072ccaeb9e
--- /dev/null
+++ b/opcodes/po/POTFILES.in
@@ -0,0 +1,69 @@
+a29k-dis.c
+alpha-dis.c
+alpha-opc.c
+arc-dis.c
+arc-opc.c
+arm-dis.c
+arm-opc.h
+cgen-asm.c
+cgen-dis.c
+cgen-opc.c
+d10v-dis.c
+d10v-opc.c
+d30v-dis.c
+d30v-opc.c
+dis-buf.c
+disassemble.c
+fr30-asm.c
+fr30-desc.c
+fr30-desc.h
+fr30-dis.c
+fr30-ibld.c
+fr30-opc.c
+fr30-opc.h
+h8300-dis.c
+h8500-dis.c
+h8500-opc.h
+hppa-dis.c
+i386-dis.c
+i960-dis.c
+m10200-dis.c
+m10200-opc.c
+m10300-dis.c
+m10300-opc.c
+m32r-asm.c
+m32r-desc.c
+m32r-desc.h
+m32r-dis.c
+m32r-ibld.c
+m32r-opc.c
+m32r-opc.h
+m32r-opinst.c
+m68k-dis.c
+m68k-opc.c
+m88k-dis.c
+mcore-dis.c
+mcore-opc.h
+mips-dis.c
+mips-opc.c
+mips16-opc.c
+ns32k-dis.c
+opintl.h
+ppc-dis.c
+ppc-opc.c
+sh-dis.c
+sh-opc.h
+sparc-dis.c
+sparc-opc.c
+sysdep.h
+tic30-dis.c
+tic80-dis.c
+tic80-opc.c
+v850-dis.c
+v850-opc.c
+vax-dis.c
+w65-dis.c
+w65-opc.h
+z8k-dis.c
+z8k-opc.h
+z8kgen.c
diff --git a/opcodes/po/opcodes.pot b/opcodes/po/opcodes.pot
new file mode 100644
index 00000000000..f7e3f0f47f9
--- /dev/null
+++ b/opcodes/po/opcodes.pot
@@ -0,0 +1,242 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 1999-04-18 19:01-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: ENCODING\n"
+
+#: alpha-opc.c:335
+msgid "branch operand unaligned"
+msgstr ""
+
+#: alpha-opc.c:358 alpha-opc.c:380
+msgid "jump hint unaligned"
+msgstr ""
+
+#: arm-dis.c:388
+msgid "<illegal precision>"
+msgstr ""
+
+#: cgen-asm.c:224
+msgid "unrecognized keyword/register name"
+msgstr ""
+
+#: cgen-asm.c:332 fr30-ibld.c:223 m32r-ibld.c:223
+#, c-format
+msgid "operand out of range (%ld not between %ld and %ld)"
+msgstr ""
+
+#: cgen-asm.c:353
+#, c-format
+msgid "operand out of range (%lu not between %lu and %lu)"
+msgstr ""
+
+#: d30v-dis.c:305
+#, c-format
+msgid "<unknown register %d>"
+msgstr ""
+
+#. Can't happen.
+#: dis-buf.c:50
+#, c-format
+msgid "Unknown error %d\n"
+msgstr ""
+
+#: dis-buf.c:55
+#, c-format
+msgid "Address 0x%x is out of bounds.\n"
+msgstr ""
+
+#: fr30-asm.c:303 m32r-asm.c:319
+#, c-format
+msgid "Unrecognized field %d while parsing.\n"
+msgstr ""
+
+#. We couldn't parse it.
+#: fr30-asm.c:367 fr30-asm.c:436 m32r-asm.c:383 m32r-asm.c:452
+msgid "unrecognized instruction"
+msgstr ""
+
+#. Syntax char didn't match. Can't be this insn.
+#. FIXME: would like to return something like
+#. "expected char `c'"
+#: fr30-asm.c:404 m32r-asm.c:420
+msgid "syntax error"
+msgstr ""
+
+#: fr30-asm.c:430 m32r-asm.c:446
+msgid "junk at end of line"
+msgstr ""
+
+#: fr30-asm.c:523 m32r-asm.c:539
+#, c-format
+msgid "bad instruction `%.50s...'"
+msgstr ""
+
+#: fr30-asm.c:526 m32r-asm.c:542
+#, c-format
+msgid "bad instruction `%.50s'"
+msgstr ""
+
+#: fr30-dis.c:300 m32r-dis.c:247
+#, c-format
+msgid "Unrecognized field %d while printing insn.\n"
+msgstr ""
+
+#: fr30-ibld.c:210 m32r-ibld.c:210
+#, c-format
+msgid "operand out of range (%lu not between 0 and %lu)"
+msgstr ""
+
+#: fr30-ibld.c:749 m32r-ibld.c:683
+#, c-format
+msgid "Unrecognized field %d while building insn.\n"
+msgstr ""
+
+#: fr30-ibld.c:952 m32r-ibld.c:819
+#, c-format
+msgid "Unrecognized field %d while decoding insn.\n"
+msgstr ""
+
+#: fr30-ibld.c:1096 m32r-ibld.c:932
+#, c-format
+msgid "Unrecognized field %d while getting int operand.\n"
+msgstr ""
+
+#: fr30-ibld.c:1225 m32r-ibld.c:1030
+#, c-format
+msgid "Unrecognized field %d while getting vma operand.\n"
+msgstr ""
+
+#: fr30-ibld.c:1358 m32r-ibld.c:1132
+#, c-format
+msgid "Unrecognized field %d while setting int operand.\n"
+msgstr ""
+
+#: fr30-ibld.c:1484 m32r-ibld.c:1227
+#, c-format
+msgid "Unrecognized field %d while setting vma operand.\n"
+msgstr ""
+
+#: h8300-dis.c:404
+#, c-format
+msgid "Hmmmm %x"
+msgstr ""
+
+#: h8300-dis.c:416
+#, c-format
+msgid "Don't understand %x \n"
+msgstr ""
+
+#: h8500-dis.c:139
+#, c-format
+msgid "can't cope with insert %d\n"
+msgstr ""
+
+#. Couldn't understand anything
+#: h8500-dis.c:344
+#, c-format
+msgid "%02x\t\t*unknown*"
+msgstr ""
+
+#: m10200-dis.c:199
+#, c-format
+msgid "unknown\t0x%02x"
+msgstr ""
+
+#: m10200-dis.c:339
+#, c-format
+msgid "unknown\t0x%04lx"
+msgstr ""
+
+#: m10300-dis.c:706
+#, c-format
+msgid "unknown\t0x%04x"
+msgstr ""
+
+#: m68k-dis.c:410
+#, c-format
+msgid "<internal error in opcode table: %s %s>\n"
+msgstr ""
+
+#: m68k-dis.c:967
+#, c-format
+msgid "<function code %d>"
+msgstr ""
+
+#: m88k-dis.c:273
+#, c-format
+msgid "# <dis error: %08x>"
+msgstr ""
+
+#: mips-dis.c:373
+#, c-format
+msgid "# internal error, undefined modifier(%c)"
+msgstr ""
+
+#. I and Z are output operands and can`t be immediate
+#. * A is an address and we can`t have the address of
+#. * an immediate either. We don't know how much to increase
+#. * aoffsetp by since whatever generated this is broken
+#. * anyway!
+#.
+#: ns32k-dis.c:618
+msgid "$<undefined>"
+msgstr ""
+
+#: ppc-opc.c:586 ppc-opc.c:617
+msgid "invalid conditional option"
+msgstr ""
+
+#: ppc-opc.c:619
+msgid "attempt to set y bit when using + or - modifier"
+msgstr ""
+
+#: ppc-opc.c:674
+msgid "ignoring least significant bits in branch offset"
+msgstr ""
+
+#: ppc-opc.c:709 ppc-opc.c:746
+msgid "illegal bitmask"
+msgstr ""
+
+#: ppc-opc.c:815
+msgid "value out of range"
+msgstr ""
+
+#: ppc-opc.c:889
+msgid "index register in load range"
+msgstr ""
+
+#: ppc-opc.c:904
+msgid "invalid register operand when updating"
+msgstr ""
+
+#. Mark as non-valid instruction
+#: sparc-dis.c:739
+msgid "unknown"
+msgstr ""
+
+#: sparc-dis.c:811
+#, c-format
+msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
+msgstr ""
+
+#: sparc-dis.c:822
+#, c-format
+msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
+msgstr ""
+
+#: sparc-dis.c:871
+#, c-format
+msgid "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"
+msgstr ""
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
new file mode 100644
index 00000000000..70716ea2471
--- /dev/null
+++ b/opcodes/ppc-dis.c
@@ -0,0 +1,238 @@
+/* ppc-dis.c -- Disassemble PowerPC instructions
+ Copyright 1994 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+2, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "sysdep.h"
+#include "dis-asm.h"
+#include "opcode/ppc.h"
+
+/* This file provides several disassembler functions, all of which use
+ the disassembler interface defined in dis-asm.h. Several functions
+ are provided because this file handles disassembly for the PowerPC
+ in both big and little endian mode and also for the POWER (RS/6000)
+ chip. */
+
+static int print_insn_powerpc PARAMS ((bfd_vma, struct disassemble_info *,
+ int bigendian, int dialect));
+
+/* Print a big endian PowerPC instruction. For convenience, also
+ disassemble instructions supported by the Motorola PowerPC 601. */
+
+int
+print_insn_big_powerpc (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ return print_insn_powerpc (memaddr, info, 1,
+ PPC_OPCODE_PPC | PPC_OPCODE_601);
+}
+
+/* Print a little endian PowerPC instruction. For convenience, also
+ disassemble instructions supported by the Motorola PowerPC 601. */
+
+int
+print_insn_little_powerpc (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ return print_insn_powerpc (memaddr, info, 0,
+ PPC_OPCODE_PPC | PPC_OPCODE_601);
+}
+
+/* Print a POWER (RS/6000) instruction. */
+
+int
+print_insn_rs6000 (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ return print_insn_powerpc (memaddr, info, 1, PPC_OPCODE_POWER);
+}
+
+/* Print a PowerPC or POWER instruction. */
+
+static int
+print_insn_powerpc (memaddr, info, bigendian, dialect)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+ int bigendian;
+ int dialect;
+{
+ bfd_byte buffer[4];
+ int status;
+ unsigned long insn;
+ const struct powerpc_opcode *opcode;
+ const struct powerpc_opcode *opcode_end;
+ unsigned long op;
+
+ status = (*info->read_memory_func) (memaddr, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+
+ if (bigendian)
+ insn = bfd_getb32 (buffer);
+ else
+ insn = bfd_getl32 (buffer);
+
+ /* Get the major opcode of the instruction. */
+ op = PPC_OP (insn);
+
+ /* Find the first match in the opcode table. We could speed this up
+ a bit by doing a binary search on the major opcode. */
+ opcode_end = powerpc_opcodes + powerpc_num_opcodes;
+ for (opcode = powerpc_opcodes; opcode < opcode_end; opcode++)
+ {
+ unsigned long table_op;
+ const unsigned char *opindex;
+ const struct powerpc_operand *operand;
+ int invalid;
+ int need_comma;
+ int need_paren;
+
+ table_op = PPC_OP (opcode->opcode);
+ if (op < table_op)
+ break;
+ if (op > table_op)
+ continue;
+
+ if ((insn & opcode->mask) != opcode->opcode
+ || (opcode->flags & dialect) == 0)
+ continue;
+
+ /* Make two passes over the operands. First see if any of them
+ have extraction functions, and, if they do, make sure the
+ instruction is valid. */
+ invalid = 0;
+ for (opindex = opcode->operands; *opindex != 0; opindex++)
+ {
+ operand = powerpc_operands + *opindex;
+ if (operand->extract)
+ (*operand->extract) (insn, &invalid);
+ }
+ if (invalid)
+ continue;
+
+ /* The instruction is valid. */
+ (*info->fprintf_func) (info->stream, "%s", opcode->name);
+ if (opcode->operands[0] != 0)
+ (*info->fprintf_func) (info->stream, "\t");
+
+ /* Now extract and print the operands. */
+ need_comma = 0;
+ need_paren = 0;
+ for (opindex = opcode->operands; *opindex != 0; opindex++)
+ {
+ long value;
+
+ operand = powerpc_operands + *opindex;
+
+ /* Operands that are marked FAKE are simply ignored. We
+ already made sure that the extract function considered
+ the instruction to be valid. */
+ if ((operand->flags & PPC_OPERAND_FAKE) != 0)
+ continue;
+
+ /* Extract the value from the instruction. */
+ if (operand->extract)
+ value = (*operand->extract) (insn, (int *) NULL);
+ else
+ {
+ value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
+ if ((operand->flags & PPC_OPERAND_SIGNED) != 0
+ && (value & (1 << (operand->bits - 1))) != 0)
+ value -= 1 << operand->bits;
+ }
+
+ /* If the operand is optional, and the value is zero, don't
+ print anything. */
+ if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
+ && (operand->flags & PPC_OPERAND_NEXT) == 0
+ && value == 0)
+ continue;
+
+ if (need_comma)
+ {
+ (*info->fprintf_func) (info->stream, ",");
+ need_comma = 0;
+ }
+
+ /* Print the operand as directed by the flags. */
+ if ((operand->flags & PPC_OPERAND_GPR) != 0)
+ (*info->fprintf_func) (info->stream, "r%ld", value);
+ else if ((operand->flags & PPC_OPERAND_FPR) != 0)
+ (*info->fprintf_func) (info->stream, "f%ld", value);
+ else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0)
+ (*info->print_address_func) (memaddr + value, info);
+ else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
+ (*info->print_address_func) ((bfd_vma) value & 0xffffffff, info);
+ else if ((operand->flags & PPC_OPERAND_CR) == 0
+ || (dialect & PPC_OPCODE_PPC) == 0)
+ (*info->fprintf_func) (info->stream, "%ld", value);
+ else
+ {
+ if (operand->bits == 3)
+ (*info->fprintf_func) (info->stream, "cr%d", value);
+ else
+ {
+ static const char *cbnames[4] = { "lt", "gt", "eq", "so" };
+ int cr;
+ int cc;
+
+ cr = value >> 2;
+ if (cr != 0)
+ (*info->fprintf_func) (info->stream, "4*cr%d", cr);
+ cc = value & 3;
+ if (cc != 0)
+ {
+ if (cr != 0)
+ (*info->fprintf_func) (info->stream, "+");
+ (*info->fprintf_func) (info->stream, "%s", cbnames[cc]);
+ }
+ }
+ }
+
+ if (need_paren)
+ {
+ (*info->fprintf_func) (info->stream, ")");
+ need_paren = 0;
+ }
+
+ if ((operand->flags & PPC_OPERAND_PARENS) == 0)
+ need_comma = 1;
+ else
+ {
+ (*info->fprintf_func) (info->stream, "(");
+ need_paren = 1;
+ }
+ }
+
+ /* We have found and printed an instruction; return. */
+ return 4;
+ }
+
+ /* We could not find a match. */
+ (*info->fprintf_func) (info->stream, ".long 0x%lx", insn);
+
+ return 4;
+}
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
new file mode 100644
index 00000000000..59218805da8
--- /dev/null
+++ b/opcodes/ppc-opc.c
@@ -0,0 +1,3124 @@
+/* ppc-opc.c -- PowerPC opcode list
+ Copyright (c) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Support
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+2, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/ppc.h"
+#include "opintl.h"
+
+/* This file holds the PowerPC opcode table. The opcode table
+ includes almost all of the extended instruction mnemonics. This
+ permits the disassembler to use them, and simplifies the assembler
+ logic, at the cost of increasing the table size. The table is
+ strictly constant data, so the compiler should be able to put it in
+ the .text section.
+
+ This file also holds the operand table. All knowledge about
+ inserting operands into instructions and vice-versa is kept in this
+ file. */
+
+/* Local insertion and extraction functions. */
+
+static unsigned long insert_bat PARAMS ((unsigned long, long, const char **));
+static long extract_bat PARAMS ((unsigned long, int *));
+static unsigned long insert_bba PARAMS ((unsigned long, long, const char **));
+static long extract_bba PARAMS ((unsigned long, int *));
+static unsigned long insert_bd PARAMS ((unsigned long, long, const char **));
+static long extract_bd PARAMS ((unsigned long, int *));
+static unsigned long insert_bdm PARAMS ((unsigned long, long, const char **));
+static long extract_bdm PARAMS ((unsigned long, int *));
+static unsigned long insert_bdp PARAMS ((unsigned long, long, const char **));
+static long extract_bdp PARAMS ((unsigned long, int *));
+static int valid_bo PARAMS ((long));
+static unsigned long insert_bo PARAMS ((unsigned long, long, const char **));
+static long extract_bo PARAMS ((unsigned long, int *));
+static unsigned long insert_boe PARAMS ((unsigned long, long, const char **));
+static long extract_boe PARAMS ((unsigned long, int *));
+static unsigned long insert_ds PARAMS ((unsigned long, long, const char **));
+static long extract_ds PARAMS ((unsigned long, int *));
+static unsigned long insert_li PARAMS ((unsigned long, long, const char **));
+static long extract_li PARAMS ((unsigned long, int *));
+static unsigned long insert_mbe PARAMS ((unsigned long, long, const char **));
+static long extract_mbe PARAMS ((unsigned long, int *));
+static unsigned long insert_mb6 PARAMS ((unsigned long, long, const char **));
+static long extract_mb6 PARAMS ((unsigned long, int *));
+static unsigned long insert_nb PARAMS ((unsigned long, long, const char **));
+static long extract_nb PARAMS ((unsigned long, int *));
+static unsigned long insert_nsi PARAMS ((unsigned long, long, const char **));
+static long extract_nsi PARAMS ((unsigned long, int *));
+static unsigned long insert_ral PARAMS ((unsigned long, long, const char **));
+static unsigned long insert_ram PARAMS ((unsigned long, long, const char **));
+static unsigned long insert_ras PARAMS ((unsigned long, long, const char **));
+static unsigned long insert_rbs PARAMS ((unsigned long, long, const char **));
+static long extract_rbs PARAMS ((unsigned long, int *));
+static unsigned long insert_sh6 PARAMS ((unsigned long, long, const char **));
+static long extract_sh6 PARAMS ((unsigned long, int *));
+static unsigned long insert_spr PARAMS ((unsigned long, long, const char **));
+static long extract_spr PARAMS ((unsigned long, int *));
+static unsigned long insert_tbr PARAMS ((unsigned long, long, const char **));
+static long extract_tbr PARAMS ((unsigned long, int *));
+
+/* The operands table.
+
+ The fields are bits, shift, insert, extract, flags.
+
+ We used to put parens around the various additions, like the one
+ for BA just below. However, that caused trouble with feeble
+ compilers with a limit on depth of a parenthesized expression, like
+ (reportedly) the compiler in Microsoft Developer Studio 5. So we
+ omit the parens, since the macros are never used in a context where
+ the addition will be ambiguous. */
+
+const struct powerpc_operand powerpc_operands[] =
+{
+ /* The zero index is used to indicate the end of the list of
+ operands. */
+#define UNUSED 0
+ { 0, 0, 0, 0, 0 },
+
+ /* The BA field in an XL form instruction. */
+#define BA UNUSED + 1
+#define BA_MASK (0x1f << 16)
+ { 5, 16, 0, 0, PPC_OPERAND_CR },
+
+ /* The BA field in an XL form instruction when it must be the same
+ as the BT field in the same instruction. */
+#define BAT BA + 1
+ { 5, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE },
+
+ /* The BB field in an XL form instruction. */
+#define BB BAT + 1
+#define BB_MASK (0x1f << 11)
+ { 5, 11, 0, 0, PPC_OPERAND_CR },
+
+ /* The BB field in an XL form instruction when it must be the same
+ as the BA field in the same instruction. */
+#define BBA BB + 1
+ { 5, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE },
+
+ /* The BD field in a B form instruction. The lower two bits are
+ forced to zero. */
+#define BD BBA + 1
+ { 16, 0, insert_bd, extract_bd, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
+
+ /* The BD field in a B form instruction when absolute addressing is
+ used. */
+#define BDA BD + 1
+ { 16, 0, insert_bd, extract_bd, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
+
+ /* The BD field in a B form instruction when the - modifier is used.
+ This sets the y bit of the BO field appropriately. */
+#define BDM BDA + 1
+ { 16, 0, insert_bdm, extract_bdm,
+ PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
+
+ /* The BD field in a B form instruction when the - modifier is used
+ and absolute address is used. */
+#define BDMA BDM + 1
+ { 16, 0, insert_bdm, extract_bdm,
+ PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
+
+ /* The BD field in a B form instruction when the + modifier is used.
+ This sets the y bit of the BO field appropriately. */
+#define BDP BDMA + 1
+ { 16, 0, insert_bdp, extract_bdp,
+ PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
+
+ /* The BD field in a B form instruction when the + modifier is used
+ and absolute addressing is used. */
+#define BDPA BDP + 1
+ { 16, 0, insert_bdp, extract_bdp,
+ PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
+
+ /* The BF field in an X or XL form instruction. */
+#define BF BDPA + 1
+ { 3, 23, 0, 0, PPC_OPERAND_CR },
+
+ /* An optional BF field. This is used for comparison instructions,
+ in which an omitted BF field is taken as zero. */
+#define OBF BF + 1
+ { 3, 23, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
+
+ /* The BFA field in an X or XL form instruction. */
+#define BFA OBF + 1
+ { 3, 18, 0, 0, PPC_OPERAND_CR },
+
+ /* The BI field in a B form or XL form instruction. */
+#define BI BFA + 1
+#define BI_MASK (0x1f << 16)
+ { 5, 16, 0, 0, PPC_OPERAND_CR },
+
+ /* The BO field in a B form instruction. Certain values are
+ illegal. */
+#define BO BI + 1
+#define BO_MASK (0x1f << 21)
+ { 5, 21, insert_bo, extract_bo, 0 },
+
+ /* The BO field in a B form instruction when the + or - modifier is
+ used. This is like the BO field, but it must be even. */
+#define BOE BO + 1
+ { 5, 21, insert_boe, extract_boe, 0 },
+
+ /* The BT field in an X or XL form instruction. */
+#define BT BOE + 1
+ { 5, 21, 0, 0, PPC_OPERAND_CR },
+
+ /* The condition register number portion of the BI field in a B form
+ or XL form instruction. This is used for the extended
+ conditional branch mnemonics, which set the lower two bits of the
+ BI field. This field is optional. */
+#define CR BT + 1
+ { 3, 18, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
+
+ /* The D field in a D form instruction. This is a displacement off
+ a register, and implies that the next operand is a register in
+ parentheses. */
+#define D CR + 1
+ { 16, 0, 0, 0, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
+
+ /* The DS field in a DS form instruction. This is like D, but the
+ lower two bits are forced to zero. */
+#define DS D + 1
+ { 16, 0, insert_ds, extract_ds, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
+
+ /* The E field in a wrteei instruction. */
+#define E DS + 1
+ { 1, 15, 0, 0, 0 },
+
+ /* The FL1 field in a POWER SC form instruction. */
+#define FL1 E + 1
+ { 4, 12, 0, 0, 0 },
+
+ /* The FL2 field in a POWER SC form instruction. */
+#define FL2 FL1 + 1
+ { 3, 2, 0, 0, 0 },
+
+ /* The FLM field in an XFL form instruction. */
+#define FLM FL2 + 1
+ { 8, 17, 0, 0, 0 },
+
+ /* The FRA field in an X or A form instruction. */
+#define FRA FLM + 1
+#define FRA_MASK (0x1f << 16)
+ { 5, 16, 0, 0, PPC_OPERAND_FPR },
+
+ /* The FRB field in an X or A form instruction. */
+#define FRB FRA + 1
+#define FRB_MASK (0x1f << 11)
+ { 5, 11, 0, 0, PPC_OPERAND_FPR },
+
+ /* The FRC field in an A form instruction. */
+#define FRC FRB + 1
+#define FRC_MASK (0x1f << 6)
+ { 5, 6, 0, 0, PPC_OPERAND_FPR },
+
+ /* The FRS field in an X form instruction or the FRT field in a D, X
+ or A form instruction. */
+#define FRS FRC + 1
+#define FRT FRS
+ { 5, 21, 0, 0, PPC_OPERAND_FPR },
+
+ /* The FXM field in an XFX instruction. */
+#define FXM FRS + 1
+#define FXM_MASK (0xff << 12)
+ { 8, 12, 0, 0, 0 },
+
+ /* The L field in a D or X form instruction. */
+#define L FXM + 1
+ { 1, 21, 0, 0, PPC_OPERAND_OPTIONAL },
+
+ /* The LEV field in a POWER SC form instruction. */
+#define LEV L + 1
+ { 7, 5, 0, 0, 0 },
+
+ /* The LI field in an I form instruction. The lower two bits are
+ forced to zero. */
+#define LI LEV + 1
+ { 26, 0, insert_li, extract_li, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
+
+ /* The LI field in an I form instruction when used as an absolute
+ address. */
+#define LIA LI + 1
+ { 26, 0, insert_li, extract_li, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
+
+ /* The MB field in an M form instruction. */
+#define MB LIA + 1
+#define MB_MASK (0x1f << 6)
+ { 5, 6, 0, 0, 0 },
+
+ /* The ME field in an M form instruction. */
+#define ME MB + 1
+#define ME_MASK (0x1f << 1)
+ { 5, 1, 0, 0, 0 },
+
+ /* The MB and ME fields in an M form instruction expressed a single
+ operand which is a bitmask indicating which bits to select. This
+ is a two operand form using PPC_OPERAND_NEXT. See the
+ description in opcode/ppc.h for what this means. */
+#define MBE ME + 1
+ { 5, 6, 0, 0, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT },
+ { 32, 0, insert_mbe, extract_mbe, 0 },
+
+ /* The MB or ME field in an MD or MDS form instruction. The high
+ bit is wrapped to the low end. */
+#define MB6 MBE + 2
+#define ME6 MB6
+#define MB6_MASK (0x3f << 5)
+ { 6, 5, insert_mb6, extract_mb6, 0 },
+
+ /* The NB field in an X form instruction. The value 32 is stored as
+ 0. */
+#define NB MB6 + 1
+ { 6, 11, insert_nb, extract_nb, 0 },
+
+ /* The NSI field in a D form instruction. This is the same as the
+ SI field, only negated. */
+#define NSI NB + 1
+ { 16, 0, insert_nsi, extract_nsi,
+ PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED },
+
+ /* The RA field in an D, DS, X, XO, M, or MDS form instruction. */
+#define RA NSI + 1
+#define RA_MASK (0x1f << 16)
+ { 5, 16, 0, 0, PPC_OPERAND_GPR },
+
+ /* The RA field in a D or X form instruction which is an updating
+ load, which means that the RA field may not be zero and may not
+ equal the RT field. */
+#define RAL RA + 1
+ { 5, 16, insert_ral, 0, PPC_OPERAND_GPR },
+
+ /* The RA field in an lmw instruction, which has special value
+ restrictions. */
+#define RAM RAL + 1
+ { 5, 16, insert_ram, 0, PPC_OPERAND_GPR },
+
+ /* The RA field in a D or X form instruction which is an updating
+ store or an updating floating point load, which means that the RA
+ field may not be zero. */
+#define RAS RAM + 1
+ { 5, 16, insert_ras, 0, PPC_OPERAND_GPR },
+
+ /* The RB field in an X, XO, M, or MDS form instruction. */
+#define RB RAS + 1
+#define RB_MASK (0x1f << 11)
+ { 5, 11, 0, 0, PPC_OPERAND_GPR },
+
+ /* The RB field in an X form instruction when it must be the same as
+ the RS field in the instruction. This is used for extended
+ mnemonics like mr. */
+#define RBS RB + 1
+ { 5, 1, insert_rbs, extract_rbs, PPC_OPERAND_FAKE },
+
+ /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form
+ instruction or the RT field in a D, DS, X, XFX or XO form
+ instruction. */
+#define RS RBS + 1
+#define RT RS
+#define RT_MASK (0x1f << 21)
+ { 5, 21, 0, 0, PPC_OPERAND_GPR },
+
+ /* The SH field in an X or M form instruction. */
+#define SH RS + 1
+#define SH_MASK (0x1f << 11)
+ { 5, 11, 0, 0, 0 },
+
+ /* The SH field in an MD form instruction. This is split. */
+#define SH6 SH + 1
+#define SH6_MASK ((0x1f << 11) | (1 << 1))
+ { 6, 1, insert_sh6, extract_sh6, 0 },
+
+ /* The SI field in a D form instruction. */
+#define SI SH6 + 1
+ { 16, 0, 0, 0, PPC_OPERAND_SIGNED },
+
+ /* The SI field in a D form instruction when we accept a wide range
+ of positive values. */
+#define SISIGNOPT SI + 1
+ { 16, 0, 0, 0, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
+
+ /* The SPR field in an XFX form instruction. This is flipped--the
+ lower 5 bits are stored in the upper 5 and vice- versa. */
+#define SPR SISIGNOPT + 1
+#define SPR_MASK (0x3ff << 11)
+ { 10, 11, insert_spr, extract_spr, 0 },
+
+ /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */
+#define SPRBAT SPR + 1
+#define SPRBAT_MASK (0x3 << 17)
+ { 2, 17, 0, 0, 0 },
+
+ /* The SPRG register number in an XFX form m[ft]sprg instruction. */
+#define SPRG SPRBAT + 1
+#define SPRG_MASK (0x3 << 16)
+ { 2, 16, 0, 0, 0 },
+
+ /* The SR field in an X form instruction. */
+#define SR SPRG + 1
+ { 4, 16, 0, 0, 0 },
+
+ /* The SV field in a POWER SC form instruction. */
+#define SV SR + 1
+ { 14, 2, 0, 0, 0 },
+
+ /* The TBR field in an XFX form instruction. This is like the SPR
+ field, but it is optional. */
+#define TBR SV + 1
+ { 10, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL },
+
+ /* The TO field in a D or X form instruction. */
+#define TO TBR + 1
+#define TO_MASK (0x1f << 21)
+ { 5, 21, 0, 0, 0 },
+
+ /* The U field in an X form instruction. */
+#define U TO + 1
+ { 4, 12, 0, 0, 0 },
+
+ /* The UI field in a D form instruction. */
+#define UI U + 1
+ { 16, 0, 0, 0, 0 },
+};
+
+/* The functions used to insert and extract complicated operands. */
+
+/* The BA field in an XL form instruction when it must be the same as
+ the BT field in the same instruction. This operand is marked FAKE.
+ The insertion function just copies the BT field into the BA field,
+ and the extraction function just checks that the fields are the
+ same. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_bat (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | (((insn >> 21) & 0x1f) << 16);
+}
+
+static long
+extract_bat (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))
+ *invalid = 1;
+ return 0;
+}
+
+/* The BB field in an XL form instruction when it must be the same as
+ the BA field in the same instruction. This operand is marked FAKE.
+ The insertion function just copies the BA field into the BB field,
+ and the extraction function just checks that the fields are the
+ same. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_bba (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | (((insn >> 16) & 0x1f) << 11);
+}
+
+static long
+extract_bba (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
+ *invalid = 1;
+ return 0;
+}
+
+/* The BD field in a B form instruction. The lower two bits are
+ forced to zero. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_bd (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | (value & 0xfffc);
+}
+
+/*ARGSUSED*/
+static long
+extract_bd (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if ((insn & 0x8000) != 0)
+ return (insn & 0xfffc) - 0x10000;
+ else
+ return insn & 0xfffc;
+}
+
+/* The BD field in a B form instruction when the - modifier is used.
+ This modifier means that the branch is not expected to be taken.
+ We must set the y bit of the BO field to 1 if the offset is
+ negative. When extracting, we require that the y bit be 1 and that
+ the offset be positive, since if the y bit is 0 we just want to
+ print the normal form of the instruction. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_bdm (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if ((value & 0x8000) != 0)
+ insn |= 1 << 21;
+ return insn | (value & 0xfffc);
+}
+
+static long
+extract_bdm (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn & (1 << 21)) == 0
+ || (insn & (1 << 15)) == 0))
+ *invalid = 1;
+ if ((insn & 0x8000) != 0)
+ return (insn & 0xfffc) - 0x10000;
+ else
+ return insn & 0xfffc;
+}
+
+/* The BD field in a B form instruction when the + modifier is used.
+ This is like BDM, above, except that the branch is expected to be
+ taken. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_bdp (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if ((value & 0x8000) == 0)
+ insn |= 1 << 21;
+ return insn | (value & 0xfffc);
+}
+
+static long
+extract_bdp (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn & (1 << 21)) == 0
+ || (insn & (1 << 15)) != 0))
+ *invalid = 1;
+ if ((insn & 0x8000) != 0)
+ return (insn & 0xfffc) - 0x10000;
+ else
+ return insn & 0xfffc;
+}
+
+/* Check for legal values of a BO field. */
+
+static int
+valid_bo (value)
+ long value;
+{
+ /* Certain encodings have bits that are required to be zero. These
+ are (z must be zero, y may be anything):
+ 001zy
+ 011zy
+ 1z00y
+ 1z01y
+ 1z1zz
+ */
+ switch (value & 0x14)
+ {
+ default:
+ case 0:
+ return 1;
+ case 0x4:
+ return (value & 0x2) == 0;
+ case 0x10:
+ return (value & 0x8) == 0;
+ case 0x14:
+ return value == 0x14;
+ }
+}
+
+/* The BO field in a B form instruction. Warn about attempts to set
+ the field to an illegal value. */
+
+static unsigned long
+insert_bo (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if (errmsg != (const char **) NULL
+ && ! valid_bo (value))
+ *errmsg = _("invalid conditional option");
+ return insn | ((value & 0x1f) << 21);
+}
+
+static long
+extract_bo (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ long value;
+
+ value = (insn >> 21) & 0x1f;
+ if (invalid != (int *) NULL
+ && ! valid_bo (value))
+ *invalid = 1;
+ return value;
+}
+
+/* The BO field in a B form instruction when the + or - modifier is
+ used. This is like the BO field, but it must be even. When
+ extracting it, we force it to be even. */
+
+static unsigned long
+insert_boe (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if (errmsg != (const char **) NULL)
+ {
+ if (! valid_bo (value))
+ *errmsg = _("invalid conditional option");
+ else if ((value & 1) != 0)
+ *errmsg = _("attempt to set y bit when using + or - modifier");
+ }
+ return insn | ((value & 0x1f) << 21);
+}
+
+static long
+extract_boe (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ long value;
+
+ value = (insn >> 21) & 0x1f;
+ if (invalid != (int *) NULL
+ && ! valid_bo (value))
+ *invalid = 1;
+ return value & 0x1e;
+}
+
+/* The DS field in a DS form instruction. This is like D, but the
+ lower two bits are forced to zero. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_ds (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | (value & 0xfffc);
+}
+
+/*ARGSUSED*/
+static long
+extract_ds (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if ((insn & 0x8000) != 0)
+ return (insn & 0xfffc) - 0x10000;
+ else
+ return insn & 0xfffc;
+}
+
+/* The LI field in an I form instruction. The lower two bits are
+ forced to zero. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_li (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if ((value & 3) != 0 && errmsg != (const char **) NULL)
+ *errmsg = _("ignoring least significant bits in branch offset");
+ return insn | (value & 0x3fffffc);
+}
+
+/*ARGSUSED*/
+static long
+extract_li (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if ((insn & 0x2000000) != 0)
+ return (insn & 0x3fffffc) - 0x4000000;
+ else
+ return insn & 0x3fffffc;
+}
+
+/* The MB and ME fields in an M form instruction expressed as a single
+ operand which is itself a bitmask. The extraction function always
+ marks it as invalid, since we never want to recognize an
+ instruction which uses a field of this type. */
+
+static unsigned long
+insert_mbe (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ unsigned long uval, mask;
+ int mb, me, mx, count, last;
+
+ uval = value;
+
+ if (uval == 0)
+ {
+ if (errmsg != (const char **) NULL)
+ *errmsg = _("illegal bitmask");
+ return insn;
+ }
+
+ mb = 0;
+ me = 32;
+ if ((uval & 1) != 0)
+ last = 1;
+ else
+ last = 0;
+ count = 0;
+
+ /* mb: location of last 0->1 transition */
+ /* me: location of last 1->0 transition */
+ /* count: # transitions */
+
+ for (mx = 0, mask = 1 << 31; mx < 32; ++mx, mask >>= 1)
+ {
+ if ((uval & mask) && !last)
+ {
+ ++count;
+ mb = mx;
+ last = 1;
+ }
+ else if (!(uval & mask) && last)
+ {
+ ++count;
+ me = mx;
+ last = 0;
+ }
+ }
+ if (me == 0)
+ me = 32;
+
+ if (count != 2 && (count != 0 || ! last))
+ {
+ if (errmsg != (const char **) NULL)
+ *errmsg = _("illegal bitmask");
+ }
+
+ return insn | (mb << 6) | ((me - 1) << 1);
+}
+
+static long
+extract_mbe (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ long ret;
+ int mb, me;
+ int i;
+
+ if (invalid != (int *) NULL)
+ *invalid = 1;
+
+ mb = (insn >> 6) & 0x1f;
+ me = (insn >> 1) & 0x1f;
+ if (mb < me + 1)
+ {
+ ret = 0;
+ for (i = mb; i <= me; i++)
+ ret |= (long) 1 << (31 - i);
+ }
+ else if (mb == me + 1)
+ ret = ~0;
+ else /* (mb > me + 1) */
+ {
+ ret = ~ (long) 0;
+ for (i = me + 1; i < mb; i++)
+ ret &= ~ ((long) 1 << (31 - i));
+ }
+ return ret;
+}
+
+/* The MB or ME field in an MD or MDS form instruction. The high bit
+ is wrapped to the low end. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_mb6 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | ((value & 0x1f) << 6) | (value & 0x20);
+}
+
+/*ARGSUSED*/
+static long
+extract_mb6 (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ return ((insn >> 6) & 0x1f) | (insn & 0x20);
+}
+
+/* The NB field in an X form instruction. The value 32 is stored as
+ 0. */
+
+static unsigned long
+insert_nb (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if (value < 0 || value > 32)
+ *errmsg = _("value out of range");
+ if (value == 32)
+ value = 0;
+ return insn | ((value & 0x1f) << 11);
+}
+
+/*ARGSUSED*/
+static long
+extract_nb (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ long ret;
+
+ ret = (insn >> 11) & 0x1f;
+ if (ret == 0)
+ ret = 32;
+ return ret;
+}
+
+/* The NSI field in a D form instruction. This is the same as the SI
+ field, only negated. The extraction function always marks it as
+ invalid, since we never want to recognize an instruction which uses
+ a field of this type. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_nsi (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | ((- value) & 0xffff);
+}
+
+static long
+extract_nsi (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL)
+ *invalid = 1;
+ if ((insn & 0x8000) != 0)
+ return - ((long)(insn & 0xffff) - 0x10000);
+ else
+ return - (long)(insn & 0xffff);
+}
+
+/* The RA field in a D or X form instruction which is an updating
+ load, which means that the RA field may not be zero and may not
+ equal the RT field. */
+
+static unsigned long
+insert_ral (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if (value == 0
+ || (unsigned long) value == ((insn >> 21) & 0x1f))
+ *errmsg = "invalid register operand when updating";
+ return insn | ((value & 0x1f) << 16);
+}
+
+/* The RA field in an lmw instruction, which has special value
+ restrictions. */
+
+static unsigned long
+insert_ram (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if ((unsigned long) value >= ((insn >> 21) & 0x1f))
+ *errmsg = _("index register in load range");
+ return insn | ((value & 0x1f) << 16);
+}
+
+/* The RA field in a D or X form instruction which is an updating
+ store or an updating floating point load, which means that the RA
+ field may not be zero. */
+
+static unsigned long
+insert_ras (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if (value == 0)
+ *errmsg = _("invalid register operand when updating");
+ return insn | ((value & 0x1f) << 16);
+}
+
+/* The RB field in an X form instruction when it must be the same as
+ the RS field in the instruction. This is used for extended
+ mnemonics like mr. This operand is marked FAKE. The insertion
+ function just copies the BT field into the BA field, and the
+ extraction function just checks that the fields are the same. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_rbs (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | (((insn >> 21) & 0x1f) << 11);
+}
+
+static long
+extract_rbs (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ if (invalid != (int *) NULL
+ && ((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f))
+ *invalid = 1;
+ return 0;
+}
+
+/* The SH field in an MD form instruction. This is split. */
+
+/*ARGSUSED*/
+static unsigned long
+insert_sh6 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);
+}
+
+/*ARGSUSED*/
+static long
+extract_sh6 (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ return ((insn >> 11) & 0x1f) | ((insn << 4) & 0x20);
+}
+
+/* The SPR field in an XFX form instruction. This is flipped--the
+ lower 5 bits are stored in the upper 5 and vice- versa. */
+
+static unsigned long
+insert_spr (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
+}
+
+static long
+extract_spr (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
+}
+
+/* The TBR field in an XFX instruction. This is just like SPR, but it
+ is optional. When TBR is omitted, it must be inserted as 268 (the
+ magic number of the TB register). These functions treat 0
+ (indicating an omitted optional operand) as 268. This means that
+ ``mftb 4,0'' is not handled correctly. This does not matter very
+ much, since the architecture manual does not define mftb as
+ accepting any values other than 268 or 269. */
+
+#define TB (268)
+
+static unsigned long
+insert_tbr (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char **errmsg;
+{
+ if (value == 0)
+ value = TB;
+ return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
+}
+
+static long
+extract_tbr (insn, invalid)
+ unsigned long insn;
+ int *invalid;
+{
+ long ret;
+
+ ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
+ if (ret == TB)
+ ret = 0;
+ return ret;
+}
+
+/* Macros used to form opcodes. */
+
+/* The main opcode. */
+#define OP(x) ((((unsigned long)(x)) & 0x3f) << 26)
+#define OP_MASK OP (0x3f)
+
+/* The main opcode combined with a trap code in the TO field of a D
+ form instruction. Used for extended mnemonics for the trap
+ instructions. */
+#define OPTO(x,to) (OP (x) | ((((unsigned long)(to)) & 0x1f) << 21))
+#define OPTO_MASK (OP_MASK | TO_MASK)
+
+/* The main opcode combined with a comparison size bit in the L field
+ of a D form or X form instruction. Used for extended mnemonics for
+ the comparison instructions. */
+#define OPL(x,l) (OP (x) | ((((unsigned long)(l)) & 1) << 21))
+#define OPL_MASK OPL (0x3f,1)
+
+/* An A form instruction. */
+#define A(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1) | (((unsigned long)(rc)) & 1))
+#define A_MASK A (0x3f, 0x1f, 1)
+
+/* An A_MASK with the FRB field fixed. */
+#define AFRB_MASK (A_MASK | FRB_MASK)
+
+/* An A_MASK with the FRC field fixed. */
+#define AFRC_MASK (A_MASK | FRC_MASK)
+
+/* An A_MASK with the FRA and FRC fields fixed. */
+#define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK)
+
+/* A B form instruction. */
+#define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1))
+#define B_MASK B (0x3f, 1, 1)
+
+/* A B form instruction setting the BO field. */
+#define BBO(op, bo, aa, lk) (B ((op), (aa), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21))
+#define BBO_MASK BBO (0x3f, 0x1f, 1, 1)
+
+/* A BBO_MASK with the y bit of the BO field removed. This permits
+ matching a conditional branch regardless of the setting of the y
+ bit. */
+#define Y_MASK (((unsigned long)1) << 21)
+#define BBOY_MASK (BBO_MASK &~ Y_MASK)
+
+/* A B form instruction setting the BO field and the condition bits of
+ the BI field. */
+#define BBOCB(op, bo, cb, aa, lk) \
+ (BBO ((op), (bo), (aa), (lk)) | ((((unsigned long)(cb)) & 0x3) << 16))
+#define BBOCB_MASK BBOCB (0x3f, 0x1f, 0x3, 1, 1)
+
+/* A BBOCB_MASK with the y bit of the BO field removed. */
+#define BBOYCB_MASK (BBOCB_MASK &~ Y_MASK)
+
+/* A BBOYCB_MASK in which the BI field is fixed. */
+#define BBOYBI_MASK (BBOYCB_MASK | BI_MASK)
+
+/* The main opcode mask with the RA field clear. */
+#define DRA_MASK (OP_MASK | RA_MASK)
+
+/* A DS form instruction. */
+#define DSO(op, xop) (OP (op) | ((xop) & 0x3))
+#define DS_MASK DSO (0x3f, 3)
+
+/* An M form instruction. */
+#define M(op, rc) (OP (op) | ((rc) & 1))
+#define M_MASK M (0x3f, 1)
+
+/* An M form instruction with the ME field specified. */
+#define MME(op, me, rc) (M ((op), (rc)) | ((((unsigned long)(me)) & 0x1f) << 1))
+
+/* An M_MASK with the MB and ME fields fixed. */
+#define MMBME_MASK (M_MASK | MB_MASK | ME_MASK)
+
+/* An M_MASK with the SH and ME fields fixed. */
+#define MSHME_MASK (M_MASK | SH_MASK | ME_MASK)
+
+/* An MD form instruction. */
+#define MD(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x7) << 2) | ((rc) & 1))
+#define MD_MASK MD (0x3f, 0x7, 1)
+
+/* An MD_MASK with the MB field fixed. */
+#define MDMB_MASK (MD_MASK | MB6_MASK)
+
+/* An MD_MASK with the SH field fixed. */
+#define MDSH_MASK (MD_MASK | SH6_MASK)
+
+/* An MDS form instruction. */
+#define MDS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0xf) << 1) | ((rc) & 1))
+#define MDS_MASK MDS (0x3f, 0xf, 1)
+
+/* An MDS_MASK with the MB field fixed. */
+#define MDSMB_MASK (MDS_MASK | MB6_MASK)
+
+/* An SC form instruction. */
+#define SC(op, sa, lk) (OP (op) | ((((unsigned long)(sa)) & 1) << 1) | ((lk) & 1))
+#define SC_MASK (OP_MASK | (((unsigned long)0x3ff) << 16) | (((unsigned long)1) << 1) | 1)
+
+/* An X form instruction. */
+#define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
+
+/* An X form instruction with the RC bit specified. */
+#define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1))
+
+/* The mask for an X form instruction. */
+#define X_MASK XRC (0x3f, 0x3ff, 1)
+
+/* An X_MASK with the RA field fixed. */
+#define XRA_MASK (X_MASK | RA_MASK)
+
+/* An X_MASK with the RB field fixed. */
+#define XRB_MASK (X_MASK | RB_MASK)
+
+/* An X_MASK with the RT field fixed. */
+#define XRT_MASK (X_MASK | RT_MASK)
+
+/* An X_MASK with the RA and RB fields fixed. */
+#define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
+
+/* An X_MASK with the RT and RA fields fixed. */
+#define XRTRA_MASK (X_MASK | RT_MASK | RA_MASK)
+
+/* An X form comparison instruction. */
+#define XCMPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21))
+
+/* The mask for an X form comparison instruction. */
+#define XCMP_MASK (X_MASK | (((unsigned long)1) << 22))
+
+/* The mask for an X form comparison instruction with the L field
+ fixed. */
+#define XCMPL_MASK (XCMP_MASK | (((unsigned long)1) << 21))
+
+/* An X form trap instruction with the TO field specified. */
+#define XTO(op, xop, to) (X ((op), (xop)) | ((((unsigned long)(to)) & 0x1f) << 21))
+#define XTO_MASK (X_MASK | TO_MASK)
+
+/* An XFL form instruction. */
+#define XFL(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1))
+#define XFL_MASK (XFL (0x3f, 0x3ff, 1) | (((unsigned long)1) << 25) | (((unsigned long)1) << 16))
+
+/* An XL form instruction with the LK field set to 0. */
+#define XL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
+
+/* An XL form instruction which uses the LK field. */
+#define XLLK(op, xop, lk) (XL ((op), (xop)) | ((lk) & 1))
+
+/* The mask for an XL form instruction. */
+#define XL_MASK XLLK (0x3f, 0x3ff, 1)
+
+/* An XL form instruction which explicitly sets the BO field. */
+#define XLO(op, bo, xop, lk) \
+ (XLLK ((op), (xop), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21))
+#define XLO_MASK (XL_MASK | BO_MASK)
+
+/* An XL form instruction which explicitly sets the y bit of the BO
+ field. */
+#define XLYLK(op, xop, y, lk) (XLLK ((op), (xop), (lk)) | ((((unsigned long)(y)) & 1) << 21))
+#define XLYLK_MASK (XL_MASK | Y_MASK)
+
+/* An XL form instruction which sets the BO field and the condition
+ bits of the BI field. */
+#define XLOCB(op, bo, cb, xop, lk) \
+ (XLO ((op), (bo), (xop), (lk)) | ((((unsigned long)(cb)) & 3) << 16))
+#define XLOCB_MASK XLOCB (0x3f, 0x1f, 0x3, 0x3ff, 1)
+
+/* An XL_MASK or XLYLK_MASK or XLOCB_MASK with the BB field fixed. */
+#define XLBB_MASK (XL_MASK | BB_MASK)
+#define XLYBB_MASK (XLYLK_MASK | BB_MASK)
+#define XLBOCBBB_MASK (XLOCB_MASK | BB_MASK)
+
+/* An XL_MASK with the BO and BB fields fixed. */
+#define XLBOBB_MASK (XL_MASK | BO_MASK | BB_MASK)
+
+/* An XL_MASK with the BO, BI and BB fields fixed. */
+#define XLBOBIBB_MASK (XL_MASK | BO_MASK | BI_MASK | BB_MASK)
+
+/* An XO form instruction. */
+#define XO(op, xop, oe, rc) \
+ (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1) | ((((unsigned long)(oe)) & 1) << 10) | (((unsigned long)(rc)) & 1))
+#define XO_MASK XO (0x3f, 0x1ff, 1, 1)
+
+/* An XO_MASK with the RB field fixed. */
+#define XORB_MASK (XO_MASK | RB_MASK)
+
+/* An XS form instruction. */
+#define XS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 2) | (((unsigned long)(rc)) & 1))
+#define XS_MASK XS (0x3f, 0x1ff, 1)
+
+/* A mask for the FXM version of an XFX form instruction. */
+#define XFXFXM_MASK (X_MASK | (((unsigned long)1) << 20) | (((unsigned long)1) << 11))
+
+/* An XFX form instruction with the FXM field filled in. */
+#define XFXM(op, xop, fxm) \
+ (X ((op), (xop)) | ((((unsigned long)(fxm)) & 0xff) << 12))
+
+/* An XFX form instruction with the SPR field filled in. */
+#define XSPR(op, xop, spr) \
+ (X ((op), (xop)) | ((((unsigned long)(spr)) & 0x1f) << 16) | ((((unsigned long)(spr)) & 0x3e0) << 6))
+#define XSPR_MASK (X_MASK | SPR_MASK)
+
+/* An XFX form instruction with the SPR field filled in except for the
+ SPRBAT field. */
+#define XSPRBAT_MASK (XSPR_MASK &~ SPRBAT_MASK)
+
+/* An XFX form instruction with the SPR field filled in except for the
+ SPRG field. */
+#define XSPRG_MASK (XSPR_MASK &~ SPRG_MASK)
+
+/* An X form instruction with everything filled in except the E field. */
+#define XE_MASK (0xffff7fff)
+
+/* The BO encodings used in extended conditional branch mnemonics. */
+#define BODNZF (0x0)
+#define BODNZFP (0x1)
+#define BODZF (0x2)
+#define BODZFP (0x3)
+#define BOF (0x4)
+#define BOFP (0x5)
+#define BODNZT (0x8)
+#define BODNZTP (0x9)
+#define BODZT (0xa)
+#define BODZTP (0xb)
+#define BOT (0xc)
+#define BOTP (0xd)
+#define BODNZ (0x10)
+#define BODNZP (0x11)
+#define BODZ (0x12)
+#define BODZP (0x13)
+#define BOU (0x14)
+
+/* The BI condition bit encodings used in extended conditional branch
+ mnemonics. */
+#define CBLT (0)
+#define CBGT (1)
+#define CBEQ (2)
+#define CBSO (3)
+
+/* The TO encodings used in extended trap mnemonics. */
+#define TOLGT (0x1)
+#define TOLLT (0x2)
+#define TOEQ (0x4)
+#define TOLGE (0x5)
+#define TOLNL (0x5)
+#define TOLLE (0x6)
+#define TOLNG (0x6)
+#define TOGT (0x8)
+#define TOGE (0xc)
+#define TONL (0xc)
+#define TOLT (0x10)
+#define TOLE (0x14)
+#define TONG (0x14)
+#define TONE (0x18)
+#define TOU (0x1f)
+
+/* Smaller names for the flags so each entry in the opcodes table will
+ fit on a single line. */
+#undef PPC
+#define PPC PPC_OPCODE_PPC | PPC_OPCODE_ANY
+#define PPCCOM PPC_OPCODE_PPC | PPC_OPCODE_COMMON | PPC_OPCODE_ANY
+#define PPC32 PPC_OPCODE_PPC | PPC_OPCODE_32 | PPC_OPCODE_ANY
+#define PPC64 PPC_OPCODE_PPC | PPC_OPCODE_64 | PPC_OPCODE_ANY
+#define PPCONLY PPC_OPCODE_PPC
+#define PPC403 PPC
+#define PPC750 PPC
+#define PPC860 PPC
+#define POWER PPC_OPCODE_POWER | PPC_OPCODE_ANY
+#define POWER2 PPC_OPCODE_POWER | PPC_OPCODE_POWER2 | PPC_OPCODE_ANY
+#define PPCPWR2 PPC_OPCODE_PPC | PPC_OPCODE_POWER | PPC_OPCODE_POWER2 | PPC_OPCODE_ANY
+#define POWER32 PPC_OPCODE_POWER | PPC_OPCODE_ANY | PPC_OPCODE_32
+#define COM PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON | PPC_OPCODE_ANY
+#define COM32 PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON | PPC_OPCODE_ANY | PPC_OPCODE_32
+#define M601 PPC_OPCODE_POWER | PPC_OPCODE_601 | PPC_OPCODE_ANY
+#define PWRCOM PPC_OPCODE_POWER | PPC_OPCODE_601 | PPC_OPCODE_COMMON | PPC_OPCODE_ANY
+#define MFDEC1 PPC_OPCODE_POWER
+#define MFDEC2 PPC_OPCODE_PPC | PPC_OPCODE_601
+
+/* The opcode table.
+
+ The format of the opcode table is:
+
+ NAME OPCODE MASK FLAGS { OPERANDS }
+
+ NAME is the name of the instruction.
+ OPCODE is the instruction opcode.
+ MASK is the opcode mask; this is used to tell the disassembler
+ which bits in the actual opcode must match OPCODE.
+ FLAGS are flags indicated what processors support the instruction.
+ OPERANDS is the list of operands.
+
+ The disassembler reads the table in order and prints the first
+ instruction which matches, so this table is sorted to put more
+ specific instructions before more general instructions. It is also
+ sorted by major opcode. */
+
+const struct powerpc_opcode powerpc_opcodes[] = {
+{ "tdlgti", OPTO(2,TOLGT), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdllti", OPTO(2,TOLLT), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdeqi", OPTO(2,TOEQ), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdlgei", OPTO(2,TOLGE), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdlnli", OPTO(2,TOLNL), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdllei", OPTO(2,TOLLE), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdlngi", OPTO(2,TOLNG), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdgti", OPTO(2,TOGT), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdgei", OPTO(2,TOGE), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdnli", OPTO(2,TONL), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdlti", OPTO(2,TOLT), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdlei", OPTO(2,TOLE), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdngi", OPTO(2,TONG), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdnei", OPTO(2,TONE), OPTO_MASK, PPC64, { RA, SI } },
+{ "tdi", OP(2), OP_MASK, PPC64, { TO, RA, SI } },
+
+{ "twlgti", OPTO(3,TOLGT), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tlgti", OPTO(3,TOLGT), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twllti", OPTO(3,TOLLT), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tllti", OPTO(3,TOLLT), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "tweqi", OPTO(3,TOEQ), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "teqi", OPTO(3,TOEQ), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twlgei", OPTO(3,TOLGE), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tlgei", OPTO(3,TOLGE), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twlnli", OPTO(3,TOLNL), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tlnli", OPTO(3,TOLNL), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twllei", OPTO(3,TOLLE), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tllei", OPTO(3,TOLLE), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twlngi", OPTO(3,TOLNG), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tlngi", OPTO(3,TOLNG), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twgti", OPTO(3,TOGT), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tgti", OPTO(3,TOGT), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twgei", OPTO(3,TOGE), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tgei", OPTO(3,TOGE), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twnli", OPTO(3,TONL), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tnli", OPTO(3,TONL), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twlti", OPTO(3,TOLT), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tlti", OPTO(3,TOLT), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twlei", OPTO(3,TOLE), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tlei", OPTO(3,TOLE), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twngi", OPTO(3,TONG), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tngi", OPTO(3,TONG), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twnei", OPTO(3,TONE), OPTO_MASK, PPCCOM, { RA, SI } },
+{ "tnei", OPTO(3,TONE), OPTO_MASK, PWRCOM, { RA, SI } },
+{ "twi", OP(3), OP_MASK, PPCCOM, { TO, RA, SI } },
+{ "ti", OP(3), OP_MASK, PWRCOM, { TO, RA, SI } },
+
+{ "mulli", OP(7), OP_MASK, PPCCOM, { RT, RA, SI } },
+{ "muli", OP(7), OP_MASK, PWRCOM, { RT, RA, SI } },
+
+{ "subfic", OP(8), OP_MASK, PPCCOM, { RT, RA, SI } },
+{ "sfi", OP(8), OP_MASK, PWRCOM, { RT, RA, SI } },
+
+{ "dozi", OP(9), OP_MASK, M601, { RT, RA, SI } },
+
+{ "cmplwi", OPL(10,0), OPL_MASK, PPCCOM, { OBF, RA, UI } },
+{ "cmpldi", OPL(10,1), OPL_MASK, PPC64, { OBF, RA, UI } },
+{ "cmpli", OP(10), OP_MASK, PPCONLY, { BF, L, RA, UI } },
+{ "cmpli", OP(10), OP_MASK, PWRCOM, { BF, RA, UI } },
+
+{ "cmpwi", OPL(11,0), OPL_MASK, PPCCOM, { OBF, RA, SI } },
+{ "cmpdi", OPL(11,1), OPL_MASK, PPC64, { OBF, RA, SI } },
+{ "cmpi", OP(11), OP_MASK, PPCONLY, { BF, L, RA, SI } },
+{ "cmpi", OP(11), OP_MASK, PWRCOM, { BF, RA, SI } },
+
+{ "addic", OP(12), OP_MASK, PPCCOM, { RT, RA, SI } },
+{ "ai", OP(12), OP_MASK, PWRCOM, { RT, RA, SI } },
+{ "subic", OP(12), OP_MASK, PPCCOM, { RT, RA, NSI } },
+
+{ "addic.", OP(13), OP_MASK, PPCCOM, { RT, RA, SI } },
+{ "ai.", OP(13), OP_MASK, PWRCOM, { RT, RA, SI } },
+{ "subic.", OP(13), OP_MASK, PPCCOM, { RT, RA, NSI } },
+
+{ "li", OP(14), DRA_MASK, PPCCOM, { RT, SI } },
+{ "lil", OP(14), DRA_MASK, PWRCOM, { RT, SI } },
+{ "addi", OP(14), OP_MASK, PPCCOM, { RT, RA, SI } },
+{ "cal", OP(14), OP_MASK, PWRCOM, { RT, D, RA } },
+{ "subi", OP(14), OP_MASK, PPCCOM, { RT, RA, NSI } },
+{ "la", OP(14), OP_MASK, PPCCOM, { RT, D, RA } },
+
+{ "lis", OP(15), DRA_MASK, PPCCOM, { RT, SISIGNOPT } },
+{ "liu", OP(15), DRA_MASK, PWRCOM, { RT, SISIGNOPT } },
+{ "addis", OP(15), OP_MASK, PPCCOM, { RT,RA,SISIGNOPT } },
+{ "cau", OP(15), OP_MASK, PWRCOM, { RT,RA,SISIGNOPT } },
+{ "subis", OP(15), OP_MASK, PPCCOM, { RT, RA, NSI } },
+
+{ "bdnz-", BBO(16,BODNZ,0,0), BBOYBI_MASK, PPC, { BDM } },
+{ "bdnz+", BBO(16,BODNZ,0,0), BBOYBI_MASK, PPC, { BDP } },
+{ "bdnz", BBO(16,BODNZ,0,0), BBOYBI_MASK, PPCCOM, { BD } },
+{ "bdn", BBO(16,BODNZ,0,0), BBOYBI_MASK, PWRCOM, { BD } },
+{ "bdnzl-", BBO(16,BODNZ,0,1), BBOYBI_MASK, PPC, { BDM } },
+{ "bdnzl+", BBO(16,BODNZ,0,1), BBOYBI_MASK, PPC, { BDP } },
+{ "bdnzl", BBO(16,BODNZ,0,1), BBOYBI_MASK, PPCCOM, { BD } },
+{ "bdnl", BBO(16,BODNZ,0,1), BBOYBI_MASK, PWRCOM, { BD } },
+{ "bdnza-", BBO(16,BODNZ,1,0), BBOYBI_MASK, PPC, { BDMA } },
+{ "bdnza+", BBO(16,BODNZ,1,0), BBOYBI_MASK, PPC, { BDPA } },
+{ "bdnza", BBO(16,BODNZ,1,0), BBOYBI_MASK, PPCCOM, { BDA } },
+{ "bdna", BBO(16,BODNZ,1,0), BBOYBI_MASK, PWRCOM, { BDA } },
+{ "bdnzla-", BBO(16,BODNZ,1,1), BBOYBI_MASK, PPC, { BDMA } },
+{ "bdnzla+", BBO(16,BODNZ,1,1), BBOYBI_MASK, PPC, { BDPA } },
+{ "bdnzla", BBO(16,BODNZ,1,1), BBOYBI_MASK, PPCCOM, { BDA } },
+{ "bdnla", BBO(16,BODNZ,1,1), BBOYBI_MASK, PWRCOM, { BDA } },
+{ "bdz-", BBO(16,BODZ,0,0), BBOYBI_MASK, PPC, { BDM } },
+{ "bdz+", BBO(16,BODZ,0,0), BBOYBI_MASK, PPC, { BDP } },
+{ "bdz", BBO(16,BODZ,0,0), BBOYBI_MASK, COM, { BD } },
+{ "bdzl-", BBO(16,BODZ,0,1), BBOYBI_MASK, PPC, { BDM } },
+{ "bdzl+", BBO(16,BODZ,0,1), BBOYBI_MASK, PPC, { BDP } },
+{ "bdzl", BBO(16,BODZ,0,1), BBOYBI_MASK, COM, { BD } },
+{ "bdza-", BBO(16,BODZ,1,0), BBOYBI_MASK, PPC, { BDMA } },
+{ "bdza+", BBO(16,BODZ,1,0), BBOYBI_MASK, PPC, { BDPA } },
+{ "bdza", BBO(16,BODZ,1,0), BBOYBI_MASK, COM, { BDA } },
+{ "bdzla-", BBO(16,BODZ,1,1), BBOYBI_MASK, PPC, { BDMA } },
+{ "bdzla+", BBO(16,BODZ,1,1), BBOYBI_MASK, PPC, { BDPA } },
+{ "bdzla", BBO(16,BODZ,1,1), BBOYBI_MASK, COM, { BDA } },
+{ "blt-", BBOCB(16,BOT,CBLT,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "blt+", BBOCB(16,BOT,CBLT,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "blt", BBOCB(16,BOT,CBLT,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bltl-", BBOCB(16,BOT,CBLT,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bltl+", BBOCB(16,BOT,CBLT,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bltl", BBOCB(16,BOT,CBLT,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "blta-", BBOCB(16,BOT,CBLT,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "blta+", BBOCB(16,BOT,CBLT,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "blta", BBOCB(16,BOT,CBLT,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bltla-", BBOCB(16,BOT,CBLT,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bltla+", BBOCB(16,BOT,CBLT,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bltla", BBOCB(16,BOT,CBLT,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bgt-", BBOCB(16,BOT,CBGT,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bgt+", BBOCB(16,BOT,CBGT,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bgt", BBOCB(16,BOT,CBGT,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bgtl-", BBOCB(16,BOT,CBGT,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bgtl+", BBOCB(16,BOT,CBGT,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bgtl", BBOCB(16,BOT,CBGT,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bgta-", BBOCB(16,BOT,CBGT,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bgta+", BBOCB(16,BOT,CBGT,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bgta", BBOCB(16,BOT,CBGT,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bgtla-", BBOCB(16,BOT,CBGT,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bgtla+", BBOCB(16,BOT,CBGT,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bgtla", BBOCB(16,BOT,CBGT,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "beq-", BBOCB(16,BOT,CBEQ,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "beq+", BBOCB(16,BOT,CBEQ,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "beq", BBOCB(16,BOT,CBEQ,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "beql-", BBOCB(16,BOT,CBEQ,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "beql+", BBOCB(16,BOT,CBEQ,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "beql", BBOCB(16,BOT,CBEQ,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "beqa-", BBOCB(16,BOT,CBEQ,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "beqa+", BBOCB(16,BOT,CBEQ,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "beqa", BBOCB(16,BOT,CBEQ,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "beqla-", BBOCB(16,BOT,CBEQ,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "beqla+", BBOCB(16,BOT,CBEQ,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "beqla", BBOCB(16,BOT,CBEQ,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bso-", BBOCB(16,BOT,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bso+", BBOCB(16,BOT,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bso", BBOCB(16,BOT,CBSO,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bsol-", BBOCB(16,BOT,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bsol+", BBOCB(16,BOT,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bsol", BBOCB(16,BOT,CBSO,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bsoa-", BBOCB(16,BOT,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bsoa+", BBOCB(16,BOT,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bsoa", BBOCB(16,BOT,CBSO,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bsola-", BBOCB(16,BOT,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bsola+", BBOCB(16,BOT,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bsola", BBOCB(16,BOT,CBSO,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bun-", BBOCB(16,BOT,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bun+", BBOCB(16,BOT,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bun", BBOCB(16,BOT,CBSO,0,0), BBOYCB_MASK, PPCCOM, { CR, BD } },
+{ "bunl-", BBOCB(16,BOT,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bunl+", BBOCB(16,BOT,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bunl", BBOCB(16,BOT,CBSO,0,1), BBOYCB_MASK, PPCCOM, { CR, BD } },
+{ "buna-", BBOCB(16,BOT,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "buna+", BBOCB(16,BOT,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "buna", BBOCB(16,BOT,CBSO,1,0), BBOYCB_MASK, PPCCOM, { CR, BDA } },
+{ "bunla-", BBOCB(16,BOT,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bunla+", BBOCB(16,BOT,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bunla", BBOCB(16,BOT,CBSO,1,1), BBOYCB_MASK, PPCCOM, { CR, BDA } },
+{ "bge-", BBOCB(16,BOF,CBLT,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bge+", BBOCB(16,BOF,CBLT,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bge", BBOCB(16,BOF,CBLT,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bgel-", BBOCB(16,BOF,CBLT,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bgel+", BBOCB(16,BOF,CBLT,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bgel", BBOCB(16,BOF,CBLT,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bgea-", BBOCB(16,BOF,CBLT,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bgea+", BBOCB(16,BOF,CBLT,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bgea", BBOCB(16,BOF,CBLT,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bgela-", BBOCB(16,BOF,CBLT,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bgela+", BBOCB(16,BOF,CBLT,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bgela", BBOCB(16,BOF,CBLT,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bnl-", BBOCB(16,BOF,CBLT,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bnl+", BBOCB(16,BOF,CBLT,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bnl", BBOCB(16,BOF,CBLT,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnll-", BBOCB(16,BOF,CBLT,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bnll+", BBOCB(16,BOF,CBLT,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bnll", BBOCB(16,BOF,CBLT,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnla-", BBOCB(16,BOF,CBLT,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnla+", BBOCB(16,BOF,CBLT,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnla", BBOCB(16,BOF,CBLT,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bnlla-", BBOCB(16,BOF,CBLT,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnlla+", BBOCB(16,BOF,CBLT,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnlla", BBOCB(16,BOF,CBLT,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "ble-", BBOCB(16,BOF,CBGT,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "ble+", BBOCB(16,BOF,CBGT,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "ble", BBOCB(16,BOF,CBGT,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "blel-", BBOCB(16,BOF,CBGT,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "blel+", BBOCB(16,BOF,CBGT,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "blel", BBOCB(16,BOF,CBGT,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "blea-", BBOCB(16,BOF,CBGT,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "blea+", BBOCB(16,BOF,CBGT,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "blea", BBOCB(16,BOF,CBGT,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "blela-", BBOCB(16,BOF,CBGT,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "blela+", BBOCB(16,BOF,CBGT,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "blela", BBOCB(16,BOF,CBGT,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bng-", BBOCB(16,BOF,CBGT,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bng+", BBOCB(16,BOF,CBGT,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bng", BBOCB(16,BOF,CBGT,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bngl-", BBOCB(16,BOF,CBGT,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bngl+", BBOCB(16,BOF,CBGT,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bngl", BBOCB(16,BOF,CBGT,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnga-", BBOCB(16,BOF,CBGT,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnga+", BBOCB(16,BOF,CBGT,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnga", BBOCB(16,BOF,CBGT,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bngla-", BBOCB(16,BOF,CBGT,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bngla+", BBOCB(16,BOF,CBGT,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bngla", BBOCB(16,BOF,CBGT,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bne-", BBOCB(16,BOF,CBEQ,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bne+", BBOCB(16,BOF,CBEQ,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bne", BBOCB(16,BOF,CBEQ,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnel-", BBOCB(16,BOF,CBEQ,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bnel+", BBOCB(16,BOF,CBEQ,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bnel", BBOCB(16,BOF,CBEQ,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnea-", BBOCB(16,BOF,CBEQ,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnea+", BBOCB(16,BOF,CBEQ,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnea", BBOCB(16,BOF,CBEQ,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bnela-", BBOCB(16,BOF,CBEQ,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnela+", BBOCB(16,BOF,CBEQ,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnela", BBOCB(16,BOF,CBEQ,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bns-", BBOCB(16,BOF,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bns+", BBOCB(16,BOF,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bns", BBOCB(16,BOF,CBSO,0,0), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnsl-", BBOCB(16,BOF,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bnsl+", BBOCB(16,BOF,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bnsl", BBOCB(16,BOF,CBSO,0,1), BBOYCB_MASK, COM, { CR, BD } },
+{ "bnsa-", BBOCB(16,BOF,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnsa+", BBOCB(16,BOF,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnsa", BBOCB(16,BOF,CBSO,1,0), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bnsla-", BBOCB(16,BOF,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnsla+", BBOCB(16,BOF,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnsla", BBOCB(16,BOF,CBSO,1,1), BBOYCB_MASK, COM, { CR, BDA } },
+{ "bnu-", BBOCB(16,BOF,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bnu+", BBOCB(16,BOF,CBSO,0,0), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bnu", BBOCB(16,BOF,CBSO,0,0), BBOYCB_MASK, PPCCOM, { CR, BD } },
+{ "bnul-", BBOCB(16,BOF,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDM } },
+{ "bnul+", BBOCB(16,BOF,CBSO,0,1), BBOYCB_MASK, PPC, { CR, BDP } },
+{ "bnul", BBOCB(16,BOF,CBSO,0,1), BBOYCB_MASK, PPCCOM, { CR, BD } },
+{ "bnua-", BBOCB(16,BOF,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnua+", BBOCB(16,BOF,CBSO,1,0), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnua", BBOCB(16,BOF,CBSO,1,0), BBOYCB_MASK, PPCCOM, { CR, BDA } },
+{ "bnula-", BBOCB(16,BOF,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDMA } },
+{ "bnula+", BBOCB(16,BOF,CBSO,1,1), BBOYCB_MASK, PPC, { CR, BDPA } },
+{ "bnula", BBOCB(16,BOF,CBSO,1,1), BBOYCB_MASK, PPCCOM, { CR, BDA } },
+{ "bdnzt-", BBO(16,BODNZT,0,0), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdnzt+", BBO(16,BODNZT,0,0), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdnzt", BBO(16,BODNZT,0,0), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdnztl-", BBO(16,BODNZT,0,1), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdnztl+", BBO(16,BODNZT,0,1), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdnztl", BBO(16,BODNZT,0,1), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdnzta-", BBO(16,BODNZT,1,0), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdnzta+", BBO(16,BODNZT,1,0), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdnzta", BBO(16,BODNZT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bdnztla-",BBO(16,BODNZT,1,1), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdnztla+",BBO(16,BODNZT,1,1), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdnztla", BBO(16,BODNZT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bdnzf-", BBO(16,BODNZF,0,0), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdnzf+", BBO(16,BODNZF,0,0), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdnzf", BBO(16,BODNZF,0,0), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdnzfl-", BBO(16,BODNZF,0,1), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdnzfl+", BBO(16,BODNZF,0,1), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdnzfl", BBO(16,BODNZF,0,1), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdnzfa-", BBO(16,BODNZF,1,0), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdnzfa+", BBO(16,BODNZF,1,0), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdnzfa", BBO(16,BODNZF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bdnzfla-",BBO(16,BODNZF,1,1), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdnzfla+",BBO(16,BODNZF,1,1), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdnzfla", BBO(16,BODNZF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bt-", BBO(16,BOT,0,0), BBOY_MASK, PPC, { BI, BDM } },
+{ "bt+", BBO(16,BOT,0,0), BBOY_MASK, PPC, { BI, BDP } },
+{ "bt", BBO(16,BOT,0,0), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bbt", BBO(16,BOT,0,0), BBOY_MASK, PWRCOM, { BI, BD } },
+{ "btl-", BBO(16,BOT,0,1), BBOY_MASK, PPC, { BI, BDM } },
+{ "btl+", BBO(16,BOT,0,1), BBOY_MASK, PPC, { BI, BDP } },
+{ "btl", BBO(16,BOT,0,1), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bbtl", BBO(16,BOT,0,1), BBOY_MASK, PWRCOM, { BI, BD } },
+{ "bta-", BBO(16,BOT,1,0), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bta+", BBO(16,BOT,1,0), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bta", BBO(16,BOT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bbta", BBO(16,BOT,1,0), BBOY_MASK, PWRCOM, { BI, BDA } },
+{ "btla-", BBO(16,BOT,1,1), BBOY_MASK, PPC, { BI, BDMA } },
+{ "btla+", BBO(16,BOT,1,1), BBOY_MASK, PPC, { BI, BDPA } },
+{ "btla", BBO(16,BOT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bbtla", BBO(16,BOT,1,1), BBOY_MASK, PWRCOM, { BI, BDA } },
+{ "bf-", BBO(16,BOF,0,0), BBOY_MASK, PPC, { BI, BDM } },
+{ "bf+", BBO(16,BOF,0,0), BBOY_MASK, PPC, { BI, BDP } },
+{ "bf", BBO(16,BOF,0,0), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bbf", BBO(16,BOF,0,0), BBOY_MASK, PWRCOM, { BI, BD } },
+{ "bfl-", BBO(16,BOF,0,1), BBOY_MASK, PPC, { BI, BDM } },
+{ "bfl+", BBO(16,BOF,0,1), BBOY_MASK, PPC, { BI, BDP } },
+{ "bfl", BBO(16,BOF,0,1), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bbfl", BBO(16,BOF,0,1), BBOY_MASK, PWRCOM, { BI, BD } },
+{ "bfa-", BBO(16,BOF,1,0), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bfa+", BBO(16,BOF,1,0), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bfa", BBO(16,BOF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bbfa", BBO(16,BOF,1,0), BBOY_MASK, PWRCOM, { BI, BDA } },
+{ "bfla-", BBO(16,BOF,1,1), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bfla+", BBO(16,BOF,1,1), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bfla", BBO(16,BOF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bbfla", BBO(16,BOF,1,1), BBOY_MASK, PWRCOM, { BI, BDA } },
+{ "bdzt-", BBO(16,BODZT,0,0), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdzt+", BBO(16,BODZT,0,0), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdzt", BBO(16,BODZT,0,0), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdztl-", BBO(16,BODZT,0,1), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdztl+", BBO(16,BODZT,0,1), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdztl", BBO(16,BODZT,0,1), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdzta-", BBO(16,BODZT,1,0), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdzta+", BBO(16,BODZT,1,0), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdzta", BBO(16,BODZT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bdztla-", BBO(16,BODZT,1,1), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdztla+", BBO(16,BODZT,1,1), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdztla", BBO(16,BODZT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bdzf-", BBO(16,BODZF,0,0), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdzf+", BBO(16,BODZF,0,0), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdzf", BBO(16,BODZF,0,0), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdzfl-", BBO(16,BODZF,0,1), BBOY_MASK, PPC, { BI, BDM } },
+{ "bdzfl+", BBO(16,BODZF,0,1), BBOY_MASK, PPC, { BI, BDP } },
+{ "bdzfl", BBO(16,BODZF,0,1), BBOY_MASK, PPCCOM, { BI, BD } },
+{ "bdzfa-", BBO(16,BODZF,1,0), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdzfa+", BBO(16,BODZF,1,0), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdzfa", BBO(16,BODZF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bdzfla-", BBO(16,BODZF,1,1), BBOY_MASK, PPC, { BI, BDMA } },
+{ "bdzfla+", BBO(16,BODZF,1,1), BBOY_MASK, PPC, { BI, BDPA } },
+{ "bdzfla", BBO(16,BODZF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } },
+{ "bc-", B(16,0,0), B_MASK, PPC, { BOE, BI, BDM } },
+{ "bc+", B(16,0,0), B_MASK, PPC, { BOE, BI, BDP } },
+{ "bc", B(16,0,0), B_MASK, COM, { BO, BI, BD } },
+{ "bcl-", B(16,0,1), B_MASK, PPC, { BOE, BI, BDM } },
+{ "bcl+", B(16,0,1), B_MASK, PPC, { BOE, BI, BDP } },
+{ "bcl", B(16,0,1), B_MASK, COM, { BO, BI, BD } },
+{ "bca-", B(16,1,0), B_MASK, PPC, { BOE, BI, BDMA } },
+{ "bca+", B(16,1,0), B_MASK, PPC, { BOE, BI, BDPA } },
+{ "bca", B(16,1,0), B_MASK, COM, { BO, BI, BDA } },
+{ "bcla-", B(16,1,1), B_MASK, PPC, { BOE, BI, BDMA } },
+{ "bcla+", B(16,1,1), B_MASK, PPC, { BOE, BI, BDPA } },
+{ "bcla", B(16,1,1), B_MASK, COM, { BO, BI, BDA } },
+
+{ "sc", SC(17,1,0), 0xffffffff, PPC, { 0 } },
+{ "svc", SC(17,0,0), SC_MASK, POWER, { LEV, FL1, FL2 } },
+{ "svcl", SC(17,0,1), SC_MASK, POWER, { LEV, FL1, FL2 } },
+{ "svca", SC(17,1,0), SC_MASK, PWRCOM, { SV } },
+{ "svcla", SC(17,1,1), SC_MASK, POWER, { SV } },
+
+{ "b", B(18,0,0), B_MASK, COM, { LI } },
+{ "bl", B(18,0,1), B_MASK, COM, { LI } },
+{ "ba", B(18,1,0), B_MASK, COM, { LIA } },
+{ "bla", B(18,1,1), B_MASK, COM, { LIA } },
+
+{ "mcrf", XL(19,0), XLBB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } },
+
+{ "blr", XLO(19,BOU,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } },
+{ "br", XLO(19,BOU,16,0), XLBOBIBB_MASK, PWRCOM, { 0 } },
+{ "blrl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } },
+{ "brl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PWRCOM, { 0 } },
+{ "bdnzlr", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } },
+{ "bdnzlr-", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdnzlr+", XLO(19,BODNZP,16,0), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdnzlrl", XLO(19,BODNZ,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } },
+{ "bdnzlrl-",XLO(19,BODNZ,16,1), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdnzlrl+",XLO(19,BODNZP,16,1), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdzlr", XLO(19,BODZ,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } },
+{ "bdzlr-", XLO(19,BODZ,16,0), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdzlr+", XLO(19,BODZP,16,0), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdzlrl", XLO(19,BODZ,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } },
+{ "bdzlrl-", XLO(19,BODZ,16,1), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bdzlrl+", XLO(19,BODZP,16,1), XLBOBIBB_MASK, PPC, { 0 } },
+{ "bltlr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bltlr-", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltlr+", XLOCB(19,BOTP,CBLT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bltlrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bltlrl-", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltlrl+", XLOCB(19,BOTP,CBLT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bgtlr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgtlr-", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtlr+", XLOCB(19,BOTP,CBGT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bgtlrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgtlrl-", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtlrl+", XLOCB(19,BOTP,CBGT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "beqlr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "beqlr-", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqlr+", XLOCB(19,BOTP,CBEQ,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "beqlrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "beqlrl-", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqlrl+", XLOCB(19,BOTP,CBEQ,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bsolr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bsolr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsolr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsor", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bsolrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bsolrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsolrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsorl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bunlr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bunlr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunlr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunlrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bunlrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunlrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgelr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgelr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgelr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bger", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bgelrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgelrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgelrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgerl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnllr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnllr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnllr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnlr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnllrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnllrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnllrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnlrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "blelr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "blelr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "blelr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bler", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "blelrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "blelrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "blelrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "blerl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnglr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnglr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnglr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bngr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnglrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnglrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnglrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bngrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnelr", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnelr-", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnelr+", XLOCB(19,BOFP,CBEQ,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bner", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnelrl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnelrl-", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnelrl+", XLOCB(19,BOFP,CBEQ,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnerl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnslr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnslr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnslr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnsr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnslrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnslrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnslrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnsrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, { CR } },
+{ "bnulr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnulr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnulr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnulrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnulrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnulrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "btlr", XLO(19,BOT,16,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "btlr-", XLO(19,BOT,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "btlr+", XLO(19,BOTP,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bbtr", XLO(19,BOT,16,0), XLBOBB_MASK, PWRCOM, { BI } },
+{ "btlrl", XLO(19,BOT,16,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "btlrl-", XLO(19,BOT,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "btlrl+", XLO(19,BOTP,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bbtrl", XLO(19,BOT,16,1), XLBOBB_MASK, PWRCOM, { BI } },
+{ "bflr", XLO(19,BOF,16,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bflr-", XLO(19,BOF,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bflr+", XLO(19,BOFP,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bbfr", XLO(19,BOF,16,0), XLBOBB_MASK, PWRCOM, { BI } },
+{ "bflrl", XLO(19,BOF,16,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bflrl-", XLO(19,BOF,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bflrl+", XLO(19,BOFP,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bbfrl", XLO(19,BOF,16,1), XLBOBB_MASK, PWRCOM, { BI } },
+{ "bdnztlr", XLO(19,BODNZT,16,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdnztlr-",XLO(19,BODNZT,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdnztlr+",XLO(19,BODNZTP,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdnztlrl",XLO(19,BODNZT,16,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdnztlrl-",XLO(19,BODNZT,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdnztlrl+",XLO(19,BODNZTP,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdnzflr", XLO(19,BODNZF,16,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdnzflr-",XLO(19,BODNZF,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdnzflr+",XLO(19,BODNZFP,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdnzflrl",XLO(19,BODNZF,16,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdnzflrl-",XLO(19,BODNZF,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdnzflrl+",XLO(19,BODNZFP,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdztlr", XLO(19,BODZT,16,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdztlr-", XLO(19,BODZT,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdztlr+", XLO(19,BODZTP,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdztlrl", XLO(19,BODZT,16,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdztlrl-",XLO(19,BODZT,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdztlrl+",XLO(19,BODZTP,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdzflr", XLO(19,BODZF,16,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdzflr-", XLO(19,BODZF,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdzflr+", XLO(19,BODZFP,16,0), XLBOBB_MASK, PPC, { BI } },
+{ "bdzflrl", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bdzflrl-",XLO(19,BODZF,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bdzflrl+",XLO(19,BODZFP,16,1), XLBOBB_MASK, PPC, { BI } },
+{ "bclr", XLLK(19,16,0), XLYBB_MASK, PPCCOM, { BO, BI } },
+{ "bclrl", XLLK(19,16,1), XLYBB_MASK, PPCCOM, { BO, BI } },
+{ "bclr+", XLYLK(19,16,1,0), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bclrl+", XLYLK(19,16,1,1), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bclr-", XLYLK(19,16,0,0), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bclrl-", XLYLK(19,16,0,1), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bcr", XLLK(19,16,0), XLBB_MASK, PWRCOM, { BO, BI } },
+{ "bcrl", XLLK(19,16,1), XLBB_MASK, PWRCOM, { BO, BI } },
+
+{ "crnot", XL(19,33), XL_MASK, PPCCOM, { BT, BA, BBA } },
+{ "crnor", XL(19,33), XL_MASK, COM, { BT, BA, BB } },
+
+{ "rfi", XL(19,50), 0xffffffff, COM, { 0 } },
+{ "rfci", XL(19,51), 0xffffffff, PPC, { 0 } },
+
+{ "rfsvc", XL(19,82), 0xffffffff, POWER, { 0 } },
+
+{ "crandc", XL(19,129), XL_MASK, COM, { BT, BA, BB } },
+
+{ "isync", XL(19,150), 0xffffffff, PPCCOM, { 0 } },
+{ "ics", XL(19,150), 0xffffffff, PWRCOM, { 0 } },
+
+{ "crclr", XL(19,193), XL_MASK, PPCCOM, { BT, BAT, BBA } },
+{ "crxor", XL(19,193), XL_MASK, COM, { BT, BA, BB } },
+
+{ "crnand", XL(19,225), XL_MASK, COM, { BT, BA, BB } },
+
+{ "crand", XL(19,257), XL_MASK, COM, { BT, BA, BB } },
+
+{ "crset", XL(19,289), XL_MASK, PPCCOM, { BT, BAT, BBA } },
+{ "creqv", XL(19,289), XL_MASK, COM, { BT, BA, BB } },
+
+{ "crorc", XL(19,417), XL_MASK, COM, { BT, BA, BB } },
+
+{ "crmove", XL(19,449), XL_MASK, PPCCOM, { BT, BA, BBA } },
+{ "cror", XL(19,449), XL_MASK, COM, { BT, BA, BB } },
+
+{ "bctr", XLO(19,BOU,528,0), XLBOBIBB_MASK, COM, { 0 } },
+{ "bctrl", XLO(19,BOU,528,1), XLBOBIBB_MASK, COM, { 0 } },
+{ "bltctr", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bltctr-", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltctr+", XLOCB(19,BOTP,CBLT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltctrl", XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bltctrl-",XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bltctrl+",XLOCB(19,BOTP,CBLT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtctr", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgtctr-", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtctr+", XLOCB(19,BOTP,CBGT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtctrl", XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgtctrl-",XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgtctrl+",XLOCB(19,BOTP,CBGT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqctr", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "beqctr-", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqctr+", XLOCB(19,BOTP,CBEQ,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqctrl", XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "beqctrl-",XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "beqctrl+",XLOCB(19,BOTP,CBEQ,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsoctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bsoctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsoctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsoctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bsoctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bsoctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bunctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bunctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bunctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgectr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgectr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgectr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgectrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bgectrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bgectrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnlctr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnlctr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnlctr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnlctrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnlctrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnlctrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "blectr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "blectr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "blectr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "blectrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "blectrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "blectrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bngctr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bngctr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bngctr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bngctrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bngctrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bngctrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnectr", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnectr-", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnectr+", XLOCB(19,BOFP,CBEQ,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnectrl", XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnectrl-",XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnectrl+",XLOCB(19,BOFP,CBEQ,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnsctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnsctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnsctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnsctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnsctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnsctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnuctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnuctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnuctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnuctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } },
+{ "bnuctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "bnuctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, PPC, { CR } },
+{ "btctr", XLO(19,BOT,528,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "btctr-", XLO(19,BOT,528,0), XLBOBB_MASK, PPC, { BI } },
+{ "btctr+", XLO(19,BOTP,528,0), XLBOBB_MASK, PPC, { BI } },
+{ "btctrl", XLO(19,BOT,528,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "btctrl-", XLO(19,BOT,528,1), XLBOBB_MASK, PPC, { BI } },
+{ "btctrl+", XLO(19,BOTP,528,1), XLBOBB_MASK, PPC, { BI } },
+{ "bfctr", XLO(19,BOF,528,0), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bfctr-", XLO(19,BOF,528,0), XLBOBB_MASK, PPC, { BI } },
+{ "bfctr+", XLO(19,BOFP,528,0), XLBOBB_MASK, PPC, { BI } },
+{ "bfctrl", XLO(19,BOF,528,1), XLBOBB_MASK, PPCCOM, { BI } },
+{ "bfctrl-", XLO(19,BOF,528,1), XLBOBB_MASK, PPC, { BI } },
+{ "bfctrl+", XLO(19,BOFP,528,1), XLBOBB_MASK, PPC, { BI } },
+{ "bcctr", XLLK(19,528,0), XLYBB_MASK, PPCCOM, { BO, BI } },
+{ "bcctr-", XLYLK(19,528,0,0), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bcctr+", XLYLK(19,528,1,0), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bcctrl", XLLK(19,528,1), XLYBB_MASK, PPCCOM, { BO, BI } },
+{ "bcctrl-", XLYLK(19,528,0,1), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bcctrl+", XLYLK(19,528,1,1), XLYBB_MASK, PPC, { BOE, BI } },
+{ "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } },
+{ "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } },
+
+{ "rlwimi", M(20,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } },
+{ "rlimi", M(20,0), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } },
+
+{ "rlwimi.", M(20,1), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } },
+{ "rlimi.", M(20,1), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } },
+
+{ "rotlwi", MME(21,31,0), MMBME_MASK, PPCCOM, { RA, RS, SH } },
+{ "clrlwi", MME(21,31,0), MSHME_MASK, PPCCOM, { RA, RS, MB } },
+{ "rlwinm", M(21,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } },
+{ "rlinm", M(21,0), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } },
+{ "rotlwi.", MME(21,31,1), MMBME_MASK, PPCCOM, { RA,RS,SH } },
+{ "clrlwi.", MME(21,31,1), MSHME_MASK, PPCCOM, { RA, RS, MB } },
+{ "rlwinm.", M(21,1), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } },
+{ "rlinm.", M(21,1), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } },
+
+{ "rlmi", M(22,0), M_MASK, M601, { RA,RS,RB,MBE,ME } },
+{ "rlmi.", M(22,1), M_MASK, M601, { RA,RS,RB,MBE,ME } },
+
+{ "rotlw", MME(23,31,0), MMBME_MASK, PPCCOM, { RA, RS, RB } },
+{ "rlwnm", M(23,0), M_MASK, PPCCOM, { RA,RS,RB,MBE,ME } },
+{ "rlnm", M(23,0), M_MASK, PWRCOM, { RA,RS,RB,MBE,ME } },
+{ "rotlw.", MME(23,31,1), MMBME_MASK, PPCCOM, { RA, RS, RB } },
+{ "rlwnm.", M(23,1), M_MASK, PPCCOM, { RA,RS,RB,MBE,ME } },
+{ "rlnm.", M(23,1), M_MASK, PWRCOM, { RA,RS,RB,MBE,ME } },
+
+{ "nop", OP(24), 0xffffffff, PPCCOM, { 0 } },
+{ "ori", OP(24), OP_MASK, PPCCOM, { RA, RS, UI } },
+{ "oril", OP(24), OP_MASK, PWRCOM, { RA, RS, UI } },
+
+{ "oris", OP(25), OP_MASK, PPCCOM, { RA, RS, UI } },
+{ "oriu", OP(25), OP_MASK, PWRCOM, { RA, RS, UI } },
+
+{ "xori", OP(26), OP_MASK, PPCCOM, { RA, RS, UI } },
+{ "xoril", OP(26), OP_MASK, PWRCOM, { RA, RS, UI } },
+
+{ "xoris", OP(27), OP_MASK, PPCCOM, { RA, RS, UI } },
+{ "xoriu", OP(27), OP_MASK, PWRCOM, { RA, RS, UI } },
+
+{ "andi.", OP(28), OP_MASK, PPCCOM, { RA, RS, UI } },
+{ "andil.", OP(28), OP_MASK, PWRCOM, { RA, RS, UI } },
+
+{ "andis.", OP(29), OP_MASK, PPCCOM, { RA, RS, UI } },
+{ "andiu.", OP(29), OP_MASK, PWRCOM, { RA, RS, UI } },
+
+{ "rotldi", MD(30,0,0), MDMB_MASK, PPC64, { RA, RS, SH6 } },
+{ "clrldi", MD(30,0,0), MDSH_MASK, PPC64, { RA, RS, MB6 } },
+{ "rldicl", MD(30,0,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } },
+{ "rotldi.", MD(30,0,1), MDMB_MASK, PPC64, { RA, RS, SH6 } },
+{ "clrldi.", MD(30,0,1), MDSH_MASK, PPC64, { RA, RS, MB6 } },
+{ "rldicl.", MD(30,0,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } },
+
+{ "rldicr", MD(30,1,0), MD_MASK, PPC64, { RA, RS, SH6, ME6 } },
+{ "rldicr.", MD(30,1,1), MD_MASK, PPC64, { RA, RS, SH6, ME6 } },
+
+{ "rldic", MD(30,2,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } },
+{ "rldic.", MD(30,2,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } },
+
+{ "rldimi", MD(30,3,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } },
+{ "rldimi.", MD(30,3,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } },
+
+{ "rotld", MDS(30,8,0), MDSMB_MASK, PPC64, { RA, RS, RB } },
+{ "rldcl", MDS(30,8,0), MDS_MASK, PPC64, { RA, RS, RB, MB6 } },
+{ "rotld.", MDS(30,8,1), MDSMB_MASK, PPC64, { RA, RS, RB } },
+{ "rldcl.", MDS(30,8,1), MDS_MASK, PPC64, { RA, RS, RB, MB6 } },
+
+{ "rldcr", MDS(30,9,0), MDS_MASK, PPC64, { RA, RS, RB, ME6 } },
+{ "rldcr.", MDS(30,9,1), MDS_MASK, PPC64, { RA, RS, RB, ME6 } },
+
+{ "cmpw", XCMPL(31,0,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } },
+{ "cmpd", XCMPL(31,0,1), XCMPL_MASK, PPC64, { OBF, RA, RB } },
+{ "cmp", X(31,0), XCMP_MASK, PPCONLY, { BF, L, RA, RB } },
+{ "cmp", X(31,0), XCMPL_MASK, PWRCOM, { BF, RA, RB } },
+
+{ "twlgt", XTO(31,4,TOLGT), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tlgt", XTO(31,4,TOLGT), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twllt", XTO(31,4,TOLLT), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tllt", XTO(31,4,TOLLT), XTO_MASK, PWRCOM, { RA, RB } },
+{ "tweq", XTO(31,4,TOEQ), XTO_MASK, PPCCOM, { RA, RB } },
+{ "teq", XTO(31,4,TOEQ), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twlge", XTO(31,4,TOLGE), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tlge", XTO(31,4,TOLGE), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twlnl", XTO(31,4,TOLNL), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tlnl", XTO(31,4,TOLNL), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twlle", XTO(31,4,TOLLE), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tlle", XTO(31,4,TOLLE), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twlng", XTO(31,4,TOLNG), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tlng", XTO(31,4,TOLNG), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twgt", XTO(31,4,TOGT), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tgt", XTO(31,4,TOGT), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twge", XTO(31,4,TOGE), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tge", XTO(31,4,TOGE), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twnl", XTO(31,4,TONL), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tnl", XTO(31,4,TONL), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twlt", XTO(31,4,TOLT), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tlt", XTO(31,4,TOLT), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twle", XTO(31,4,TOLE), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tle", XTO(31,4,TOLE), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twng", XTO(31,4,TONG), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tng", XTO(31,4,TONG), XTO_MASK, PWRCOM, { RA, RB } },
+{ "twne", XTO(31,4,TONE), XTO_MASK, PPCCOM, { RA, RB } },
+{ "tne", XTO(31,4,TONE), XTO_MASK, PWRCOM, { RA, RB } },
+{ "trap", XTO(31,4,TOU), 0xffffffff, PPCCOM, { 0 } },
+{ "tw", X(31,4), X_MASK, PPCCOM, { TO, RA, RB } },
+{ "t", X(31,4), X_MASK, PWRCOM, { TO, RA, RB } },
+
+{ "subfc", XO(31,8,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sf", XO(31,8,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subc", XO(31,8,0,0), XO_MASK, PPC, { RT, RB, RA } },
+{ "subfc.", XO(31,8,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sf.", XO(31,8,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subc.", XO(31,8,0,1), XO_MASK, PPCCOM, { RT, RB, RA } },
+{ "subfco", XO(31,8,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sfo", XO(31,8,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subco", XO(31,8,1,0), XO_MASK, PPC, { RT, RB, RA } },
+{ "subfco.", XO(31,8,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sfo.", XO(31,8,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subco.", XO(31,8,1,1), XO_MASK, PPC, { RT, RB, RA } },
+
+{ "mulhdu", XO(31,9,0,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "mulhdu.", XO(31,9,0,1), XO_MASK, PPC64, { RT, RA, RB } },
+
+{ "addc", XO(31,10,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "a", XO(31,10,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addc.", XO(31,10,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "a.", XO(31,10,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addco", XO(31,10,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "ao", XO(31,10,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addco.", XO(31,10,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "ao.", XO(31,10,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "mulhwu", XO(31,11,0,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "mulhwu.", XO(31,11,0,1), XO_MASK, PPC, { RT, RA, RB } },
+
+{ "mfcr", X(31,19), XRARB_MASK, COM, { RT } },
+
+{ "lwarx", X(31,20), X_MASK, PPC, { RT, RA, RB } },
+
+{ "ldx", X(31,21), X_MASK, PPC64, { RT, RA, RB } },
+
+{ "lwzx", X(31,23), X_MASK, PPCCOM, { RT, RA, RB } },
+{ "lx", X(31,23), X_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "slw", XRC(31,24,0), X_MASK, PPCCOM, { RA, RS, RB } },
+{ "sl", XRC(31,24,0), X_MASK, PWRCOM, { RA, RS, RB } },
+{ "slw.", XRC(31,24,1), X_MASK, PPCCOM, { RA, RS, RB } },
+{ "sl.", XRC(31,24,1), X_MASK, PWRCOM, { RA, RS, RB } },
+
+{ "cntlzw", XRC(31,26,0), XRB_MASK, PPCCOM, { RA, RS } },
+{ "cntlz", XRC(31,26,0), XRB_MASK, PWRCOM, { RA, RS } },
+{ "cntlzw.", XRC(31,26,1), XRB_MASK, PPCCOM, { RA, RS } },
+{ "cntlz.", XRC(31,26,1), XRB_MASK, PWRCOM, { RA, RS } },
+
+{ "sld", XRC(31,27,0), X_MASK, PPC64, { RA, RS, RB } },
+{ "sld.", XRC(31,27,1), X_MASK, PPC64, { RA, RS, RB } },
+
+{ "and", XRC(31,28,0), X_MASK, COM, { RA, RS, RB } },
+{ "and.", XRC(31,28,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "maskg", XRC(31,29,0), X_MASK, M601, { RA, RS, RB } },
+{ "maskg.", XRC(31,29,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "cmplw", XCMPL(31,32,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } },
+{ "cmpld", XCMPL(31,32,1), XCMPL_MASK, PPC64, { OBF, RA, RB } },
+{ "cmpl", X(31,32), XCMP_MASK, PPCONLY, { BF, L, RA, RB } },
+{ "cmpl", X(31,32), XCMPL_MASK, PWRCOM, { BF, RA, RB } },
+
+{ "subf", XO(31,40,0,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "sub", XO(31,40,0,0), XO_MASK, PPC, { RT, RB, RA } },
+{ "subf.", XO(31,40,0,1), XO_MASK, PPC, { RT, RA, RB } },
+{ "sub.", XO(31,40,0,1), XO_MASK, PPC, { RT, RB, RA } },
+{ "subfo", XO(31,40,1,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "subo", XO(31,40,1,0), XO_MASK, PPC, { RT, RB, RA } },
+{ "subfo.", XO(31,40,1,1), XO_MASK, PPC, { RT, RA, RB } },
+{ "subo.", XO(31,40,1,1), XO_MASK, PPC, { RT, RB, RA } },
+
+{ "ldux", X(31,53), X_MASK, PPC64, { RT, RAL, RB } },
+
+{ "dcbst", X(31,54), XRT_MASK, PPC, { RA, RB } },
+
+{ "lwzux", X(31,55), X_MASK, PPCCOM, { RT, RAL, RB } },
+{ "lux", X(31,55), X_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "cntlzd", XRC(31,58,0), XRB_MASK, PPC64, { RA, RS } },
+{ "cntlzd.", XRC(31,58,1), XRB_MASK, PPC64, { RA, RS } },
+
+{ "andc", XRC(31,60,0), X_MASK, COM, { RA, RS, RB } },
+{ "andc.", XRC(31,60,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "tdlgt", XTO(31,68,TOLGT), XTO_MASK, PPC64, { RA, RB } },
+{ "tdllt", XTO(31,68,TOLLT), XTO_MASK, PPC64, { RA, RB } },
+{ "tdeq", XTO(31,68,TOEQ), XTO_MASK, PPC64, { RA, RB } },
+{ "tdlge", XTO(31,68,TOLGE), XTO_MASK, PPC64, { RA, RB } },
+{ "tdlnl", XTO(31,68,TOLNL), XTO_MASK, PPC64, { RA, RB } },
+{ "tdlle", XTO(31,68,TOLLE), XTO_MASK, PPC64, { RA, RB } },
+{ "tdlng", XTO(31,68,TOLNG), XTO_MASK, PPC64, { RA, RB } },
+{ "tdgt", XTO(31,68,TOGT), XTO_MASK, PPC64, { RA, RB } },
+{ "tdge", XTO(31,68,TOGE), XTO_MASK, PPC64, { RA, RB } },
+{ "tdnl", XTO(31,68,TONL), XTO_MASK, PPC64, { RA, RB } },
+{ "tdlt", XTO(31,68,TOLT), XTO_MASK, PPC64, { RA, RB } },
+{ "tdle", XTO(31,68,TOLE), XTO_MASK, PPC64, { RA, RB } },
+{ "tdng", XTO(31,68,TONG), XTO_MASK, PPC64, { RA, RB } },
+{ "tdne", XTO(31,68,TONE), XTO_MASK, PPC64, { RA, RB } },
+{ "td", X(31,68), X_MASK, PPC64, { TO, RA, RB } },
+
+{ "mulhd", XO(31,73,0,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "mulhd.", XO(31,73,0,1), XO_MASK, PPC64, { RT, RA, RB } },
+
+{ "mulhw", XO(31,75,0,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "mulhw.", XO(31,75,0,1), XO_MASK, PPC, { RT, RA, RB } },
+
+{ "mfmsr", X(31,83), XRARB_MASK, COM, { RT } },
+
+{ "ldarx", X(31,84), X_MASK, PPC64, { RT, RA, RB } },
+
+{ "dcbf", X(31,86), XRT_MASK, PPC, { RA, RB } },
+
+{ "lbzx", X(31,87), X_MASK, COM, { RT, RA, RB } },
+
+{ "neg", XO(31,104,0,0), XORB_MASK, COM, { RT, RA } },
+{ "neg.", XO(31,104,0,1), XORB_MASK, COM, { RT, RA } },
+{ "nego", XO(31,104,1,0), XORB_MASK, COM, { RT, RA } },
+{ "nego.", XO(31,104,1,1), XORB_MASK, COM, { RT, RA } },
+
+{ "mul", XO(31,107,0,0), XO_MASK, M601, { RT, RA, RB } },
+{ "mul.", XO(31,107,0,1), XO_MASK, M601, { RT, RA, RB } },
+{ "mulo", XO(31,107,1,0), XO_MASK, M601, { RT, RA, RB } },
+{ "mulo.", XO(31,107,1,1), XO_MASK, M601, { RT, RA, RB } },
+
+{ "clf", X(31,118), XRB_MASK, POWER, { RT, RA } },
+
+{ "lbzux", X(31,119), X_MASK, COM, { RT, RAL, RB } },
+
+{ "not", XRC(31,124,0), X_MASK, COM, { RA, RS, RBS } },
+{ "nor", XRC(31,124,0), X_MASK, COM, { RA, RS, RB } },
+{ "not.", XRC(31,124,1), X_MASK, COM, { RA, RS, RBS } },
+{ "nor.", XRC(31,124,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "wrtee", X(31,131), XRARB_MASK, PPC403, { RS } },
+
+{ "subfe", XO(31,136,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sfe", XO(31,136,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subfe.", XO(31,136,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sfe.", XO(31,136,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subfeo", XO(31,136,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sfeo", XO(31,136,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "subfeo.", XO(31,136,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "sfeo.", XO(31,136,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "adde", XO(31,138,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "ae", XO(31,138,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "adde.", XO(31,138,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "ae.", XO(31,138,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addeo", XO(31,138,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "aeo", XO(31,138,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addeo.", XO(31,138,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "aeo.", XO(31,138,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "mtcr", XFXM(31,144,0xff), XFXFXM_MASK|FXM_MASK, COM, { RS }},
+{ "mtcrf", X(31,144), XFXFXM_MASK, COM, { FXM, RS } },
+
+{ "mtmsr", X(31,146), XRARB_MASK, COM, { RS } },
+
+{ "stdx", X(31,149), X_MASK, PPC64, { RS, RA, RB } },
+
+{ "stwcx.", XRC(31,150,1), X_MASK, PPC, { RS, RA, RB } },
+
+{ "stwx", X(31,151), X_MASK, PPCCOM, { RS, RA, RB } },
+{ "stx", X(31,151), X_MASK, PWRCOM, { RS, RA, RB } },
+
+{ "slq", XRC(31,152,0), X_MASK, M601, { RA, RS, RB } },
+{ "slq.", XRC(31,152,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "sle", XRC(31,153,0), X_MASK, M601, { RA, RS, RB } },
+{ "sle.", XRC(31,153,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "wrteei", X(31,163), XE_MASK, PPC403, { E } },
+
+{ "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } },
+
+{ "stwux", X(31,183), X_MASK, PPCCOM, { RS, RAS, RB } },
+{ "stux", X(31,183), X_MASK, PWRCOM, { RS, RA, RB } },
+
+{ "sliq", XRC(31,184,0), X_MASK, M601, { RA, RS, SH } },
+{ "sliq.", XRC(31,184,1), X_MASK, M601, { RA, RS, SH } },
+
+{ "subfze", XO(31,200,0,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfze", XO(31,200,0,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "subfze.", XO(31,200,0,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfze.", XO(31,200,0,1), XORB_MASK, PWRCOM, { RT, RA } },
+{ "subfzeo", XO(31,200,1,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfzeo", XO(31,200,1,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "subfzeo.",XO(31,200,1,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfzeo.", XO(31,200,1,1), XORB_MASK, PWRCOM, { RT, RA } },
+
+{ "addze", XO(31,202,0,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "aze", XO(31,202,0,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "addze.", XO(31,202,0,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "aze.", XO(31,202,0,1), XORB_MASK, PWRCOM, { RT, RA } },
+{ "addzeo", XO(31,202,1,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "azeo", XO(31,202,1,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "addzeo.", XO(31,202,1,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "azeo.", XO(31,202,1,1), XORB_MASK, PWRCOM, { RT, RA } },
+
+{ "mtsr", X(31,210), XRB_MASK|(1<<20), COM32, { SR, RS } },
+
+{ "stdcx.", XRC(31,214,1), X_MASK, PPC64, { RS, RA, RB } },
+
+{ "stbx", X(31,215), X_MASK, COM, { RS, RA, RB } },
+
+{ "sllq", XRC(31,216,0), X_MASK, M601, { RA, RS, RB } },
+{ "sllq.", XRC(31,216,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "sleq", XRC(31,217,0), X_MASK, M601, { RA, RS, RB } },
+{ "sleq.", XRC(31,217,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "subfme", XO(31,232,0,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfme", XO(31,232,0,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "subfme.", XO(31,232,0,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfme.", XO(31,232,0,1), XORB_MASK, PWRCOM, { RT, RA } },
+{ "subfmeo", XO(31,232,1,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfmeo", XO(31,232,1,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "subfmeo.",XO(31,232,1,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "sfmeo.", XO(31,232,1,1), XORB_MASK, PWRCOM, { RT, RA } },
+
+{ "mulld", XO(31,233,0,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "mulld.", XO(31,233,0,1), XO_MASK, PPC64, { RT, RA, RB } },
+{ "mulldo", XO(31,233,1,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "mulldo.", XO(31,233,1,1), XO_MASK, PPC64, { RT, RA, RB } },
+
+{ "addme", XO(31,234,0,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "ame", XO(31,234,0,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "addme.", XO(31,234,0,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "ame.", XO(31,234,0,1), XORB_MASK, PWRCOM, { RT, RA } },
+{ "addmeo", XO(31,234,1,0), XORB_MASK, PPCCOM, { RT, RA } },
+{ "ameo", XO(31,234,1,0), XORB_MASK, PWRCOM, { RT, RA } },
+{ "addmeo.", XO(31,234,1,1), XORB_MASK, PPCCOM, { RT, RA } },
+{ "ameo.", XO(31,234,1,1), XORB_MASK, PWRCOM, { RT, RA } },
+
+{ "mullw", XO(31,235,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "muls", XO(31,235,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "mullw.", XO(31,235,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "muls.", XO(31,235,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "mullwo", XO(31,235,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "mulso", XO(31,235,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "mullwo.", XO(31,235,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "mulso.", XO(31,235,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "mtsrin", X(31,242), XRA_MASK, PPC32, { RS, RB } },
+{ "mtsri", X(31,242), XRA_MASK, POWER32, { RS, RB } },
+
+{ "dcbtst", X(31,246), XRT_MASK, PPC, { RA, RB } },
+
+{ "stbux", X(31,247), X_MASK, COM, { RS, RAS, RB } },
+
+{ "slliq", XRC(31,248,0), X_MASK, M601, { RA, RS, SH } },
+{ "slliq.", XRC(31,248,1), X_MASK, M601, { RA, RS, SH } },
+
+{ "doz", XO(31,264,0,0), XO_MASK, M601, { RT, RA, RB } },
+{ "doz.", XO(31,264,0,1), XO_MASK, M601, { RT, RA, RB } },
+{ "dozo", XO(31,264,1,0), XO_MASK, M601, { RT, RA, RB } },
+{ "dozo.", XO(31,264,1,1), XO_MASK, M601, { RT, RA, RB } },
+
+{ "add", XO(31,266,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "cax", XO(31,266,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "add.", XO(31,266,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "cax.", XO(31,266,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addo", XO(31,266,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "caxo", XO(31,266,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
+{ "addo.", XO(31,266,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
+{ "caxo.", XO(31,266,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "lscbx", XRC(31,277,0), X_MASK, M601, { RT, RA, RB } },
+{ "lscbx.", XRC(31,277,1), X_MASK, M601, { RT, RA, RB } },
+
+{ "dcbt", X(31,278), XRT_MASK, PPC, { RA, RB } },
+
+{ "lhzx", X(31,279), X_MASK, COM, { RT, RA, RB } },
+
+{ "icbt", X(31,262), XRT_MASK, PPC, { RA, RB } },
+
+{ "eqv", XRC(31,284,0), X_MASK, COM, { RA, RS, RB } },
+{ "eqv.", XRC(31,284,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "tlbie", X(31,306), XRTRA_MASK, PPC, { RB } },
+{ "tlbi", X(31,306), XRT_MASK, POWER, { RA, RB } },
+
+{ "eciwx", X(31,310), X_MASK, PPC, { RT, RA, RB } },
+
+{ "lhzux", X(31,311), X_MASK, COM, { RT, RAL, RB } },
+
+{ "xor", XRC(31,316,0), X_MASK, COM, { RA, RS, RB } },
+{ "xor.", XRC(31,316,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "mfexisr", XSPR(31,323,64), XSPR_MASK, PPC403, { RT } },
+{ "mfexier", XSPR(31,323,66), XSPR_MASK, PPC403, { RT } },
+{ "mfbr0", XSPR(31,323,128), XSPR_MASK, PPC403, { RT } },
+{ "mfbr1", XSPR(31,323,129), XSPR_MASK, PPC403, { RT } },
+{ "mfbr2", XSPR(31,323,130), XSPR_MASK, PPC403, { RT } },
+{ "mfbr3", XSPR(31,323,131), XSPR_MASK, PPC403, { RT } },
+{ "mfbr4", XSPR(31,323,132), XSPR_MASK, PPC403, { RT } },
+{ "mfbr5", XSPR(31,323,133), XSPR_MASK, PPC403, { RT } },
+{ "mfbr6", XSPR(31,323,134), XSPR_MASK, PPC403, { RT } },
+{ "mfbr7", XSPR(31,323,135), XSPR_MASK, PPC403, { RT } },
+{ "mfbear", XSPR(31,323,144), XSPR_MASK, PPC403, { RT } },
+{ "mfbesr", XSPR(31,323,145), XSPR_MASK, PPC403, { RT } },
+{ "mfiocr", XSPR(31,323,160), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacr0", XSPR(31,323,192), XSPR_MASK, PPC403, { RT } },
+{ "mfdmact0", XSPR(31,323,193), XSPR_MASK, PPC403, { RT } },
+{ "mfdmada0", XSPR(31,323,194), XSPR_MASK, PPC403, { RT } },
+{ "mfdmasa0", XSPR(31,323,195), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacc0", XSPR(31,323,196), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacr1", XSPR(31,323,200), XSPR_MASK, PPC403, { RT } },
+{ "mfdmact1", XSPR(31,323,201), XSPR_MASK, PPC403, { RT } },
+{ "mfdmada1", XSPR(31,323,202), XSPR_MASK, PPC403, { RT } },
+{ "mfdmasa1", XSPR(31,323,203), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacc1", XSPR(31,323,204), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacr2", XSPR(31,323,208), XSPR_MASK, PPC403, { RT } },
+{ "mfdmact2", XSPR(31,323,209), XSPR_MASK, PPC403, { RT } },
+{ "mfdmada2", XSPR(31,323,210), XSPR_MASK, PPC403, { RT } },
+{ "mfdmasa2", XSPR(31,323,211), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacc2", XSPR(31,323,212), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacr3", XSPR(31,323,216), XSPR_MASK, PPC403, { RT } },
+{ "mfdmact3", XSPR(31,323,217), XSPR_MASK, PPC403, { RT } },
+{ "mfdmada3", XSPR(31,323,218), XSPR_MASK, PPC403, { RT } },
+{ "mfdmasa3", XSPR(31,323,219), XSPR_MASK, PPC403, { RT } },
+{ "mfdmacc3", XSPR(31,323,220), XSPR_MASK, PPC403, { RT } },
+{ "mfdmasr", XSPR(31,323,224), XSPR_MASK, PPC403, { RT } },
+{ "mfdcr", X(31,323), X_MASK, PPC, { RT, SPR } },
+
+{ "div", XO(31,331,0,0), XO_MASK, M601, { RT, RA, RB } },
+{ "div.", XO(31,331,0,1), XO_MASK, M601, { RT, RA, RB } },
+{ "divo", XO(31,331,1,0), XO_MASK, M601, { RT, RA, RB } },
+{ "divo.", XO(31,331,1,1), XO_MASK, M601, { RT, RA, RB } },
+
+{ "mfmq", XSPR(31,339,0), XSPR_MASK, M601, { RT } },
+{ "mfxer", XSPR(31,339,1), XSPR_MASK, COM, { RT } },
+{ "mfrtcu", XSPR(31,339,4), XSPR_MASK, COM, { RT } },
+{ "mfrtcl", XSPR(31,339,5), XSPR_MASK, COM, { RT } },
+{ "mfdec", XSPR(31,339,6), XSPR_MASK, MFDEC1, { RT } },
+{ "mflr", XSPR(31,339,8), XSPR_MASK, COM, { RT } },
+{ "mfctr", XSPR(31,339,9), XSPR_MASK, COM, { RT } },
+{ "mftid", XSPR(31,339,17), XSPR_MASK, POWER, { RT } },
+{ "mfdsisr", XSPR(31,339,18), XSPR_MASK, COM, { RT } },
+{ "mfdar", XSPR(31,339,19), XSPR_MASK, COM, { RT } },
+{ "mfdec", XSPR(31,339,22), XSPR_MASK, MFDEC2, { RT } },
+{ "mfsdr0", XSPR(31,339,24), XSPR_MASK, POWER, { RT } },
+{ "mfsdr1", XSPR(31,339,25), XSPR_MASK, COM, { RT } },
+{ "mfsrr0", XSPR(31,339,26), XSPR_MASK, COM, { RT } },
+{ "mfsrr1", XSPR(31,339,27), XSPR_MASK, COM, { RT } },
+{ "mfcmpa", XSPR(31,339,144), XSPR_MASK, PPC860, { RT } },
+{ "mfcmpb", XSPR(31,339,145), XSPR_MASK, PPC860, { RT } },
+{ "mfcmpc", XSPR(31,339,146), XSPR_MASK, PPC860, { RT } },
+{ "mfcmpd", XSPR(31,339,147), XSPR_MASK, PPC860, { RT } },
+{ "mficr", XSPR(31,339,148), XSPR_MASK, PPC860, { RT } },
+{ "mfder", XSPR(31,339,149), XSPR_MASK, PPC860, { RT } },
+{ "mfcounta", XSPR(31,339,150), XSPR_MASK, PPC860, { RT } },
+{ "mfcountb", XSPR(31,339,151), XSPR_MASK, PPC860, { RT } },
+{ "mfcmpe", XSPR(31,339,152), XSPR_MASK, PPC860, { RT } },
+{ "mfcmpf", XSPR(31,339,153), XSPR_MASK, PPC860, { RT } },
+{ "mfcmpg", XSPR(31,339,154), XSPR_MASK, PPC860, { RT } },
+{ "mfcmph", XSPR(31,339,155), XSPR_MASK, PPC860, { RT } },
+{ "mflctrl1", XSPR(31,339,156), XSPR_MASK, PPC860, { RT } },
+{ "mflctrl2", XSPR(31,339,157), XSPR_MASK, PPC860, { RT } },
+{ "mfictrl", XSPR(31,339,158), XSPR_MASK, PPC860, { RT } },
+{ "mfbar", XSPR(31,339,159), XSPR_MASK, PPC860, { RT } },
+{ "mfsprg", XSPR(31,339,272), XSPRG_MASK, PPC, { RT, SPRG } },
+{ "mfsprg0", XSPR(31,339,272), XSPR_MASK, PPC, { RT } },
+{ "mfsprg1", XSPR(31,339,273), XSPR_MASK, PPC, { RT } },
+{ "mfsprg2", XSPR(31,339,274), XSPR_MASK, PPC, { RT } },
+{ "mfsprg3", XSPR(31,339,275), XSPR_MASK, PPC, { RT } },
+{ "mfasr", XSPR(31,339,280), XSPR_MASK, PPC64, { RT } },
+{ "mfear", XSPR(31,339,282), XSPR_MASK, PPC, { RT } },
+{ "mfpvr", XSPR(31,339,287), XSPR_MASK, PPC, { RT } },
+{ "mfibatu", XSPR(31,339,528), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
+{ "mfibatl", XSPR(31,339,529), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
+{ "mfdbatu", XSPR(31,339,536), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
+{ "mfdbatl", XSPR(31,339,537), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
+{ "mfic_cst", XSPR(31,339,560), XSPR_MASK, PPC860, { RT } },
+{ "mfic_adr", XSPR(31,339,561), XSPR_MASK, PPC860, { RT } },
+{ "mfic_dat", XSPR(31,339,562), XSPR_MASK, PPC860, { RT } },
+{ "mfdc_cst", XSPR(31,339,568), XSPR_MASK, PPC860, { RT } },
+{ "mfdc_adr", XSPR(31,339,569), XSPR_MASK, PPC860, { RT } },
+{ "mfdc_dat", XSPR(31,339,570), XSPR_MASK, PPC860, { RT } },
+{ "mfdpdr", XSPR(31,339,630), XSPR_MASK, PPC860, { RT } },
+{ "mfdpir", XSPR(31,339,631), XSPR_MASK, PPC860, { RT } },
+{ "mfimmr", XSPR(31,339,638), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_ctr", XSPR(31,339,784), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_ap", XSPR(31,339,786), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_epn", XSPR(31,339,787), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_twc", XSPR(31,339,789), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_rpn", XSPR(31,339,790), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_ctr", XSPR(31,339,792), XSPR_MASK, PPC860, { RT } },
+{ "mfm_casid",XSPR(31,339,793), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_ap", XSPR(31,339,794), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_epn", XSPR(31,339,795), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_twb", XSPR(31,339,796), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_twc", XSPR(31,339,797), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_rpn", XSPR(31,339,798), XSPR_MASK, PPC860, { RT } },
+{ "mfm_tw", XSPR(31,339,799), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_dbcam",XSPR(31,339,816), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_dbram0",XSPR(31,339,817), XSPR_MASK, PPC860, { RT } },
+{ "mfmi_dbram1",XSPR(31,339,818), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_dbcam", XSPR(31,339,824), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_dbram0",XSPR(31,339,825), XSPR_MASK, PPC860, { RT } },
+{ "mfmd_dbram1",XSPR(31,339,826), XSPR_MASK, PPC860, { RT } },
+{ "mfzpr", XSPR(31,339,944), XSPR_MASK, PPC403, { RT } },
+{ "mfpid", XSPR(31,339,945), XSPR_MASK, PPC403, { RT } },
+{ "mficdbdr",XSPR(31,339,979), XSPR_MASK, PPC403, { RT } },
+{ "mfummcr0", XSPR(31,339,936), XSPR_MASK, PPC750, { RT } },
+{ "mfupmc1", XSPR(31,339,937), XSPR_MASK, PPC750, { RT } },
+{ "mfupmc2", XSPR(31,339,938), XSPR_MASK, PPC750, { RT } },
+{ "mfusia", XSPR(31,339,939), XSPR_MASK, PPC750, { RT } },
+{ "mfummcr1", XSPR(31,339,940), XSPR_MASK, PPC750, { RT } },
+{ "mfupmc3", XSPR(31,339,941), XSPR_MASK, PPC750, { RT } },
+{ "mfupmc4", XSPR(31,339,942), XSPR_MASK, PPC750, { RT } },
+{ "mfmmcr0", XSPR(31,339,952), XSPR_MASK, PPC750, { RT } },
+{ "mfpmc1", XSPR(31,339,953), XSPR_MASK, PPC750, { RT } },
+{ "mfpmc2", XSPR(31,339,954), XSPR_MASK, PPC750, { RT } },
+{ "mfsia", XSPR(31,339,955), XSPR_MASK, PPC750, { RT } },
+{ "mfmmcr1", XSPR(31,339,956), XSPR_MASK, PPC750, { RT } },
+{ "mfpmc3", XSPR(31,339,957), XSPR_MASK, PPC750, { RT } },
+{ "mfpmc4", XSPR(31,339,958), XSPR_MASK, PPC750, { RT } },
+{ "mfesr", XSPR(31,339,980), XSPR_MASK, PPC403, { RT } },
+{ "mfdear", XSPR(31,339,981), XSPR_MASK, PPC403, { RT } },
+{ "mfevpr", XSPR(31,339,982), XSPR_MASK, PPC403, { RT } },
+{ "mfcdbcr", XSPR(31,339,983), XSPR_MASK, PPC403, { RT } },
+{ "mftsr", XSPR(31,339,984), XSPR_MASK, PPC403, { RT } },
+{ "mftcr", XSPR(31,339,986), XSPR_MASK, PPC403, { RT } },
+{ "mfpit", XSPR(31,339,987), XSPR_MASK, PPC403, { RT } },
+{ "mftbhi", XSPR(31,339,988), XSPR_MASK, PPC403, { RT } },
+{ "mftblo", XSPR(31,339,989), XSPR_MASK, PPC403, { RT } },
+{ "mfsrr2", XSPR(31,339,990), XSPR_MASK, PPC403, { RT } },
+{ "mfsrr3", XSPR(31,339,991), XSPR_MASK, PPC403, { RT } },
+{ "mfdbsr", XSPR(31,339,1008), XSPR_MASK, PPC403, { RT } },
+{ "mfiac1", XSPR(31,339,1012), XSPR_MASK, PPC403, { RT } },
+{ "mfiac2", XSPR(31,339,1013), XSPR_MASK, PPC403, { RT } },
+{ "mfdac1", XSPR(31,339,1014), XSPR_MASK, PPC403, { RT } },
+{ "mfdac2", XSPR(31,339,1015), XSPR_MASK, PPC403, { RT } },
+{ "mfdccr", XSPR(31,339,1018), XSPR_MASK, PPC403, { RT } },
+{ "mficcr", XSPR(31,339,1019), XSPR_MASK, PPC403, { RT } },
+{ "mfpbl1", XSPR(31,339,1020), XSPR_MASK, PPC403, { RT } },
+{ "mfpbu1", XSPR(31,339,1021), XSPR_MASK, PPC403, { RT } },
+{ "mfpbl2", XSPR(31,339,1022), XSPR_MASK, PPC403, { RT } },
+{ "mfpbu2", XSPR(31,339,1023), XSPR_MASK, PPC403, { RT } },
+{ "mfl2cr", XSPR(31,339,1017), XSPR_MASK, PPC750, { RT } },
+{ "mfictc", XSPR(31,339,1019), XSPR_MASK, PPC750, { RT } },
+{ "mfthrm1", XSPR(31,339,1020), XSPR_MASK, PPC750, { RT } },
+{ "mfthrm2", XSPR(31,339,1021), XSPR_MASK, PPC750, { RT } },
+{ "mfthrm3", XSPR(31,339,1022), XSPR_MASK, PPC750, { RT } },
+{ "mfspr", X(31,339), X_MASK, COM, { RT, SPR } },
+
+{ "lwax", X(31,341), X_MASK, PPC64, { RT, RA, RB } },
+
+{ "lhax", X(31,343), X_MASK, COM, { RT, RA, RB } },
+
+{ "dccci", X(31,454), XRT_MASK, PPC, { RA, RB } },
+
+{ "abs", XO(31,360,0,0), XORB_MASK, M601, { RT, RA } },
+{ "abs.", XO(31,360,0,1), XORB_MASK, M601, { RT, RA } },
+{ "abso", XO(31,360,1,0), XORB_MASK, M601, { RT, RA } },
+{ "abso.", XO(31,360,1,1), XORB_MASK, M601, { RT, RA } },
+
+{ "divs", XO(31,363,0,0), XO_MASK, M601, { RT, RA, RB } },
+{ "divs.", XO(31,363,0,1), XO_MASK, M601, { RT, RA, RB } },
+{ "divso", XO(31,363,1,0), XO_MASK, M601, { RT, RA, RB } },
+{ "divso.", XO(31,363,1,1), XO_MASK, M601, { RT, RA, RB } },
+
+{ "tlbia", X(31,370), 0xffffffff, PPC, { 0 } },
+
+{ "mftbu", XSPR(31,371,269), XSPR_MASK, PPC, { RT } },
+{ "mftb", X(31,371), X_MASK, PPC, { RT, TBR } },
+
+{ "lwaux", X(31,373), X_MASK, PPC64, { RT, RAL, RB } },
+
+{ "lhaux", X(31,375), X_MASK, COM, { RT, RAL, RB } },
+
+{ "sthx", X(31,407), X_MASK, COM, { RS, RA, RB } },
+
+{ "lfqx", X(31,791), X_MASK, POWER2, { FRT, RA, RB } },
+
+{ "lfqux", X(31,823), X_MASK, POWER2, { FRT, RA, RB } },
+
+{ "stfqx", X(31,919), X_MASK, POWER2, { FRS, RA, RB } },
+
+{ "stfqux", X(31,951), X_MASK, POWER2, { FRS, RA, RB } },
+
+{ "orc", XRC(31,412,0), X_MASK, COM, { RA, RS, RB } },
+{ "orc.", XRC(31,412,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "sradi", XS(31,413,0), XS_MASK, PPC64, { RA, RS, SH6 } },
+{ "sradi.", XS(31,413,1), XS_MASK, PPC64, { RA, RS, SH6 } },
+
+{ "slbie", X(31,434), XRTRA_MASK, PPC64, { RB } },
+
+{ "ecowx", X(31,438), X_MASK, PPC, { RT, RA, RB } },
+
+{ "sthux", X(31,439), X_MASK, COM, { RS, RAS, RB } },
+
+{ "mr", XRC(31,444,0), X_MASK, COM, { RA, RS, RBS } },
+{ "or", XRC(31,444,0), X_MASK, COM, { RA, RS, RB } },
+{ "mr.", XRC(31,444,1), X_MASK, COM, { RA, RS, RBS } },
+{ "or.", XRC(31,444,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "mtexisr", XSPR(31,451,64), XSPR_MASK, PPC403, { RT } },
+{ "mtexier", XSPR(31,451,66), XSPR_MASK, PPC403, { RT } },
+{ "mtbr0", XSPR(31,451,128), XSPR_MASK, PPC403, { RT } },
+{ "mtbr1", XSPR(31,451,129), XSPR_MASK, PPC403, { RT } },
+{ "mtbr2", XSPR(31,451,130), XSPR_MASK, PPC403, { RT } },
+{ "mtbr3", XSPR(31,451,131), XSPR_MASK, PPC403, { RT } },
+{ "mtbr4", XSPR(31,451,132), XSPR_MASK, PPC403, { RT } },
+{ "mtbr5", XSPR(31,451,133), XSPR_MASK, PPC403, { RT } },
+{ "mtbr6", XSPR(31,451,134), XSPR_MASK, PPC403, { RT } },
+{ "mtbr7", XSPR(31,451,135), XSPR_MASK, PPC403, { RT } },
+{ "mtbear", XSPR(31,451,144), XSPR_MASK, PPC403, { RT } },
+{ "mtbesr", XSPR(31,451,145), XSPR_MASK, PPC403, { RT } },
+{ "mtiocr", XSPR(31,451,160), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacr0", XSPR(31,451,192), XSPR_MASK, PPC403, { RT } },
+{ "mtdmact0", XSPR(31,451,193), XSPR_MASK, PPC403, { RT } },
+{ "mtdmada0", XSPR(31,451,194), XSPR_MASK, PPC403, { RT } },
+{ "mtdmasa0", XSPR(31,451,195), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacc0", XSPR(31,451,196), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacr1", XSPR(31,451,200), XSPR_MASK, PPC403, { RT } },
+{ "mtdmact1", XSPR(31,451,201), XSPR_MASK, PPC403, { RT } },
+{ "mtdmada1", XSPR(31,451,202), XSPR_MASK, PPC403, { RT } },
+{ "mtdmasa1", XSPR(31,451,203), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacc1", XSPR(31,451,204), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacr2", XSPR(31,451,208), XSPR_MASK, PPC403, { RT } },
+{ "mtdmact2", XSPR(31,451,209), XSPR_MASK, PPC403, { RT } },
+{ "mtdmada2", XSPR(31,451,210), XSPR_MASK, PPC403, { RT } },
+{ "mtdmasa2", XSPR(31,451,211), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacc2", XSPR(31,451,212), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacr3", XSPR(31,451,216), XSPR_MASK, PPC403, { RT } },
+{ "mtdmact3", XSPR(31,451,217), XSPR_MASK, PPC403, { RT } },
+{ "mtdmada3", XSPR(31,451,218), XSPR_MASK, PPC403, { RT } },
+{ "mtdmasa3", XSPR(31,451,219), XSPR_MASK, PPC403, { RT } },
+{ "mtdmacc3", XSPR(31,451,220), XSPR_MASK, PPC403, { RT } },
+{ "mtdmasr", XSPR(31,451,224), XSPR_MASK, PPC403, { RT } },
+{ "mtummcr0", XSPR(31,451,936), XSPR_MASK, PPC750, { RT } },
+{ "mtupmc1", XSPR(31,451,937), XSPR_MASK, PPC750, { RT } },
+{ "mtupmc2", XSPR(31,451,938), XSPR_MASK, PPC750, { RT } },
+{ "mtusia", XSPR(31,451,939), XSPR_MASK, PPC750, { RT } },
+{ "mtummcr1", XSPR(31,451,940), XSPR_MASK, PPC750, { RT } },
+{ "mtupmc3", XSPR(31,451,941), XSPR_MASK, PPC750, { RT } },
+{ "mtupmc4", XSPR(31,451,942), XSPR_MASK, PPC750, { RT } },
+{ "mtmmcr0", XSPR(31,451,952), XSPR_MASK, PPC750, { RT } },
+{ "mtpmc1", XSPR(31,451,953), XSPR_MASK, PPC750, { RT } },
+{ "mtpmc2", XSPR(31,451,954), XSPR_MASK, PPC750, { RT } },
+{ "mtsia", XSPR(31,451,955), XSPR_MASK, PPC750, { RT } },
+{ "mtmmcr1", XSPR(31,451,956), XSPR_MASK, PPC750, { RT } },
+{ "mtpmc3", XSPR(31,451,957), XSPR_MASK, PPC750, { RT } },
+{ "mtpmc4", XSPR(31,451,958), XSPR_MASK, PPC750, { RT } },
+{ "mtl2cr", XSPR(31,451,1017), XSPR_MASK, PPC750, { RT } },
+{ "mtictc", XSPR(31,451,1019), XSPR_MASK, PPC750, { RT } },
+{ "mtthrm1", XSPR(31,451,1020), XSPR_MASK, PPC750, { RT } },
+{ "mtthrm2", XSPR(31,451,1021), XSPR_MASK, PPC750, { RT } },
+{ "mtthrm3", XSPR(31,451,1022), XSPR_MASK, PPC750, { RT } },
+{ "mtdcr", X(31,451), X_MASK, PPC, { SPR, RS } },
+
+{ "divdu", XO(31,457,0,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "divdu.", XO(31,457,0,1), XO_MASK, PPC64, { RT, RA, RB } },
+{ "divduo", XO(31,457,1,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "divduo.", XO(31,457,1,1), XO_MASK, PPC64, { RT, RA, RB } },
+
+{ "divwu", XO(31,459,0,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "divwu.", XO(31,459,0,1), XO_MASK, PPC, { RT, RA, RB } },
+{ "divwuo", XO(31,459,1,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "divwuo.", XO(31,459,1,1), XO_MASK, PPC, { RT, RA, RB } },
+
+{ "mtmq", XSPR(31,467,0), XSPR_MASK, M601, { RS } },
+{ "mtxer", XSPR(31,467,1), XSPR_MASK, COM, { RS } },
+{ "mtlr", XSPR(31,467,8), XSPR_MASK, COM, { RS } },
+{ "mtctr", XSPR(31,467,9), XSPR_MASK, COM, { RS } },
+{ "mttid", XSPR(31,467,17), XSPR_MASK, POWER, { RS } },
+{ "mtdsisr", XSPR(31,467,18), XSPR_MASK, COM, { RS } },
+{ "mtdar", XSPR(31,467,19), XSPR_MASK, COM, { RS } },
+{ "mtrtcu", XSPR(31,467,20), XSPR_MASK, COM, { RS } },
+{ "mtrtcl", XSPR(31,467,21), XSPR_MASK, COM, { RS } },
+{ "mtdec", XSPR(31,467,22), XSPR_MASK, COM, { RS } },
+{ "mtsdr0", XSPR(31,467,24), XSPR_MASK, POWER, { RS } },
+{ "mtsdr1", XSPR(31,467,25), XSPR_MASK, COM, { RS } },
+{ "mtsrr0", XSPR(31,467,26), XSPR_MASK, COM, { RS } },
+{ "mtsrr1", XSPR(31,467,27), XSPR_MASK, COM, { RS } },
+{ "mtcmpa", XSPR(31,467,144), XSPR_MASK, PPC860, { RT } },
+{ "mtcmpb", XSPR(31,467,145), XSPR_MASK, PPC860, { RT } },
+{ "mtcmpc", XSPR(31,467,146), XSPR_MASK, PPC860, { RT } },
+{ "mtcmpd", XSPR(31,467,147), XSPR_MASK, PPC860, { RT } },
+{ "mticr", XSPR(31,467,148), XSPR_MASK, PPC860, { RT } },
+{ "mtder", XSPR(31,467,149), XSPR_MASK, PPC860, { RT } },
+{ "mtcounta", XSPR(31,467,150), XSPR_MASK, PPC860, { RT } },
+{ "mtcountb", XSPR(31,467,151), XSPR_MASK, PPC860, { RT } },
+{ "mtcmpe", XSPR(31,467,152), XSPR_MASK, PPC860, { RT } },
+{ "mtcmpf", XSPR(31,467,153), XSPR_MASK, PPC860, { RT } },
+{ "mtcmpg", XSPR(31,467,154), XSPR_MASK, PPC860, { RT } },
+{ "mtcmph", XSPR(31,467,155), XSPR_MASK, PPC860, { RT } },
+{ "mtlctrl1", XSPR(31,467,156), XSPR_MASK, PPC860, { RT } },
+{ "mtlctrl2", XSPR(31,467,157), XSPR_MASK, PPC860, { RT } },
+{ "mtictrl", XSPR(31,467,158), XSPR_MASK, PPC860, { RT } },
+{ "mtbar", XSPR(31,467,159), XSPR_MASK, PPC860, { RT } },
+{ "mtsprg", XSPR(31,467,272), XSPRG_MASK, PPC, { SPRG, RS } },
+{ "mtsprg0", XSPR(31,467,272), XSPR_MASK, PPC, { RT } },
+{ "mtsprg1", XSPR(31,467,273), XSPR_MASK, PPC, { RT } },
+{ "mtsprg2", XSPR(31,467,274), XSPR_MASK, PPC, { RT } },
+{ "mtsprg3", XSPR(31,467,275), XSPR_MASK, PPC, { RT } },
+{ "mtasr", XSPR(31,467,280), XSPR_MASK, PPC64, { RS } },
+{ "mtear", XSPR(31,467,282), XSPR_MASK, PPC, { RS } },
+{ "mttbl", XSPR(31,467,284), XSPR_MASK, PPC, { RS } },
+{ "mttbu", XSPR(31,467,285), XSPR_MASK, PPC, { RS } },
+{ "mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
+{ "mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
+{ "mtdbatu", XSPR(31,467,536), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
+{ "mtdbatl", XSPR(31,467,537), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
+{ "mtzpr", XSPR(31,467,944), XSPR_MASK, PPC403, { RT } },
+{ "mtpid", XSPR(31,467,945), XSPR_MASK, PPC403, { RT } },
+{ "mticdbdr",XSPR(31,467,979), XSPR_MASK, PPC403, { RT } },
+{ "mtesr", XSPR(31,467,980), XSPR_MASK, PPC403, { RT } },
+{ "mtevpr", XSPR(31,467,982), XSPR_MASK, PPC403, { RT } },
+{ "mtcdbcr", XSPR(31,467,983), XSPR_MASK, PPC403, { RT } },
+{ "mttsr", XSPR(31,467,984), XSPR_MASK, PPC403, { RT } },
+{ "mttcr", XSPR(31,467,986), XSPR_MASK, PPC403, { RT } },
+{ "mtpit", XSPR(31,467,987), XSPR_MASK, PPC403, { RT } },
+{ "mttbhi", XSPR(31,467,988), XSPR_MASK, PPC403, { RT } },
+{ "mttblo", XSPR(31,467,989), XSPR_MASK, PPC403, { RT } },
+{ "mtsrr2", XSPR(31,467,990), XSPR_MASK, PPC403, { RT } },
+{ "mtsrr3", XSPR(31,467,991), XSPR_MASK, PPC403, { RT } },
+{ "mtdbsr", XSPR(31,467,1008), XSPR_MASK, PPC403, { RT } },
+{ "mtiac1", XSPR(31,467,1012), XSPR_MASK, PPC403, { RT } },
+{ "mtiac2", XSPR(31,467,1013), XSPR_MASK, PPC403, { RT } },
+{ "mtdac1", XSPR(31,467,1014), XSPR_MASK, PPC403, { RT } },
+{ "mtdac2", XSPR(31,467,1015), XSPR_MASK, PPC403, { RT } },
+{ "mtdccr", XSPR(31,467,1018), XSPR_MASK, PPC403, { RT } },
+{ "mticcr", XSPR(31,467,1019), XSPR_MASK, PPC403, { RT } },
+{ "mtpbl1", XSPR(31,467,1020), XSPR_MASK, PPC403, { RT } },
+{ "mtpbu1", XSPR(31,467,1021), XSPR_MASK, PPC403, { RT } },
+{ "mtpbl2", XSPR(31,467,1022), XSPR_MASK, PPC403, { RT } },
+{ "mtpbu2", XSPR(31,467,1023), XSPR_MASK, PPC403, { RT } },
+{ "mtspr", X(31,467), X_MASK, COM, { SPR, RS } },
+
+{ "dcbi", X(31,470), XRT_MASK, PPC, { RA, RB } },
+
+{ "nand", XRC(31,476,0), X_MASK, COM, { RA, RS, RB } },
+{ "nand.", XRC(31,476,1), X_MASK, COM, { RA, RS, RB } },
+
+{ "dcread", X(31,486), XRT_MASK, PPC403, { RA, RB } },
+
+{ "nabs", XO(31,488,0,0), XORB_MASK, M601, { RT, RA } },
+{ "nabs.", XO(31,488,0,1), XORB_MASK, M601, { RT, RA } },
+{ "nabso", XO(31,488,1,0), XORB_MASK, M601, { RT, RA } },
+{ "nabso.", XO(31,488,1,1), XORB_MASK, M601, { RT, RA } },
+
+{ "divd", XO(31,489,0,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "divd.", XO(31,489,0,1), XO_MASK, PPC64, { RT, RA, RB } },
+{ "divdo", XO(31,489,1,0), XO_MASK, PPC64, { RT, RA, RB } },
+{ "divdo.", XO(31,489,1,1), XO_MASK, PPC64, { RT, RA, RB } },
+
+{ "divw", XO(31,491,0,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "divw.", XO(31,491,0,1), XO_MASK, PPC, { RT, RA, RB } },
+{ "divwo", XO(31,491,1,0), XO_MASK, PPC, { RT, RA, RB } },
+{ "divwo.", XO(31,491,1,1), XO_MASK, PPC, { RT, RA, RB } },
+
+{ "slbia", X(31,498), 0xffffffff, PPC64, { 0 } },
+
+{ "cli", X(31,502), XRB_MASK, POWER, { RT, RA } },
+
+{ "mcrxr", X(31,512), XRARB_MASK|(3<<21), COM, { BF } },
+
+{ "clcs", X(31,531), XRB_MASK, M601, { RT, RA } },
+
+{ "lswx", X(31,533), X_MASK, PPCCOM, { RT, RA, RB } },
+{ "lsx", X(31,533), X_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "lwbrx", X(31,534), X_MASK, PPCCOM, { RT, RA, RB } },
+{ "lbrx", X(31,534), X_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "lfsx", X(31,535), X_MASK, COM, { FRT, RA, RB } },
+
+{ "srw", XRC(31,536,0), X_MASK, PPCCOM, { RA, RS, RB } },
+{ "sr", XRC(31,536,0), X_MASK, PWRCOM, { RA, RS, RB } },
+{ "srw.", XRC(31,536,1), X_MASK, PPCCOM, { RA, RS, RB } },
+{ "sr.", XRC(31,536,1), X_MASK, PWRCOM, { RA, RS, RB } },
+
+{ "rrib", XRC(31,537,0), X_MASK, M601, { RA, RS, RB } },
+{ "rrib.", XRC(31,537,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "srd", XRC(31,539,0), X_MASK, PPC64, { RA, RS, RB } },
+{ "srd.", XRC(31,539,1), X_MASK, PPC64, { RA, RS, RB } },
+
+{ "maskir", XRC(31,541,0), X_MASK, M601, { RA, RS, RB } },
+{ "maskir.", XRC(31,541,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "tlbsync", X(31,566), 0xffffffff, PPC, { 0 } },
+
+{ "lfsux", X(31,567), X_MASK, COM, { FRT, RAS, RB } },
+
+{ "mfsr", X(31,595), XRB_MASK|(1<<20), COM32, { RT, SR } },
+
+{ "lswi", X(31,597), X_MASK, PPCCOM, { RT, RA, NB } },
+{ "lsi", X(31,597), X_MASK, PWRCOM, { RT, RA, NB } },
+
+{ "sync", X(31,598), 0xffffffff, PPCCOM, { 0 } },
+{ "dcs", X(31,598), 0xffffffff, PWRCOM, { 0 } },
+
+{ "lfdx", X(31,599), X_MASK, COM, { FRT, RA, RB } },
+
+{ "mfsri", X(31,627), X_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "dclst", X(31,630), XRB_MASK, PWRCOM, { RS, RA } },
+
+{ "lfdux", X(31,631), X_MASK, COM, { FRT, RAS, RB } },
+
+{ "mfsrin", X(31,659), XRA_MASK, PPC32, { RT, RB } },
+
+{ "stswx", X(31,661), X_MASK, PPCCOM, { RS, RA, RB } },
+{ "stsx", X(31,661), X_MASK, PWRCOM, { RS, RA, RB } },
+
+{ "stwbrx", X(31,662), X_MASK, PPCCOM, { RS, RA, RB } },
+{ "stbrx", X(31,662), X_MASK, PWRCOM, { RS, RA, RB } },
+
+{ "stfsx", X(31,663), X_MASK, COM, { FRS, RA, RB } },
+
+{ "srq", XRC(31,664,0), X_MASK, M601, { RA, RS, RB } },
+{ "srq.", XRC(31,664,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "sre", XRC(31,665,0), X_MASK, M601, { RA, RS, RB } },
+{ "sre.", XRC(31,665,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "stfsux", X(31,695), X_MASK, COM, { FRS, RAS, RB } },
+
+{ "sriq", XRC(31,696,0), X_MASK, M601, { RA, RS, SH } },
+{ "sriq.", XRC(31,696,1), X_MASK, M601, { RA, RS, SH } },
+
+{ "stswi", X(31,725), X_MASK, PPCCOM, { RS, RA, NB } },
+{ "stsi", X(31,725), X_MASK, PWRCOM, { RS, RA, NB } },
+
+{ "stfdx", X(31,727), X_MASK, COM, { FRS, RA, RB } },
+
+{ "srlq", XRC(31,728,0), X_MASK, M601, { RA, RS, RB } },
+{ "srlq.", XRC(31,728,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "sreq", XRC(31,729,0), X_MASK, M601, { RA, RS, RB } },
+{ "sreq.", XRC(31,729,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "stfdux", X(31,759), X_MASK, COM, { FRS, RAS, RB } },
+
+{ "srliq", XRC(31,760,0), X_MASK, M601, { RA, RS, SH } },
+{ "srliq.", XRC(31,760,1), X_MASK, M601, { RA, RS, SH } },
+
+{ "lhbrx", X(31,790), X_MASK, COM, { RT, RA, RB } },
+
+{ "sraw", XRC(31,792,0), X_MASK, PPCCOM, { RA, RS, RB } },
+{ "sra", XRC(31,792,0), X_MASK, PWRCOM, { RA, RS, RB } },
+{ "sraw.", XRC(31,792,1), X_MASK, PPCCOM, { RA, RS, RB } },
+{ "sra.", XRC(31,792,1), X_MASK, PWRCOM, { RA, RS, RB } },
+
+{ "srad", XRC(31,794,0), X_MASK, PPC64, { RA, RS, RB } },
+{ "srad.", XRC(31,794,1), X_MASK, PPC64, { RA, RS, RB } },
+
+{ "rac", X(31,818), X_MASK, PWRCOM, { RT, RA, RB } },
+
+{ "srawi", XRC(31,824,0), X_MASK, PPCCOM, { RA, RS, SH } },
+{ "srai", XRC(31,824,0), X_MASK, PWRCOM, { RA, RS, SH } },
+{ "srawi.", XRC(31,824,1), X_MASK, PPCCOM, { RA, RS, SH } },
+{ "srai.", XRC(31,824,1), X_MASK, PWRCOM, { RA, RS, SH } },
+
+{ "eieio", X(31,854), 0xffffffff, PPC, { 0 } },
+
+{ "tlbsx", XRC(31,914,0), X_MASK, PPC403, { RT, RA, RB } },
+{ "tlbsx.", XRC(31,914,1), X_MASK, PPC403, { RT, RA, RB } },
+
+{ "sthbrx", X(31,918), X_MASK, COM, { RS, RA, RB } },
+
+{ "sraq", XRC(31,920,0), X_MASK, M601, { RA, RS, RB } },
+{ "sraq.", XRC(31,920,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "srea", XRC(31,921,0), X_MASK, M601, { RA, RS, RB } },
+{ "srea.", XRC(31,921,1), X_MASK, M601, { RA, RS, RB } },
+
+{ "extsh", XRC(31,922,0), XRB_MASK, PPCCOM, { RA, RS } },
+{ "exts", XRC(31,922,0), XRB_MASK, PWRCOM, { RA, RS } },
+{ "extsh.", XRC(31,922,1), XRB_MASK, PPCCOM, { RA, RS } },
+{ "exts.", XRC(31,922,1), XRB_MASK, PWRCOM, { RA, RS } },
+
+{ "tlbre", X(31,946), X_MASK, PPC403, { RT, RA, SH } },
+
+{ "sraiq", XRC(31,952,0), X_MASK, M601, { RA, RS, SH } },
+{ "sraiq.", XRC(31,952,1), X_MASK, M601, { RA, RS, SH } },
+
+{ "extsb", XRC(31,954,0), XRB_MASK, PPC, { RA, RS} },
+{ "extsb.", XRC(31,954,1), XRB_MASK, PPC, { RA, RS} },
+
+{ "iccci", X(31,966), XRT_MASK, PPC, { RA, RB } },
+
+{ "tlbld", X(31,978), XRTRA_MASK, PPC, { RB } },
+{ "tlbwe", X(31,978), X_MASK, PPC403, { RS, RA, SH } },
+
+{ "icbi", X(31,982), XRT_MASK, PPC, { RA, RB } },
+
+{ "stfiwx", X(31,983), X_MASK, PPC, { FRS, RA, RB } },
+
+{ "extsw", XRC(31,986,0), XRB_MASK, PPC, { RA, RS } },
+{ "extsw.", XRC(31,986,1), XRB_MASK, PPC, { RA, RS } },
+
+{ "icread", X(31,998), XRT_MASK, PPC403, { RA, RB } },
+
+{ "tlbli", X(31,1010), XRTRA_MASK, PPC, { RB } },
+
+{ "dcbz", X(31,1014), XRT_MASK, PPC, { RA, RB } },
+{ "dclz", X(31,1014), XRT_MASK, PPC, { RA, RB } },
+
+{ "lwz", OP(32), OP_MASK, PPCCOM, { RT, D, RA } },
+{ "l", OP(32), OP_MASK, PWRCOM, { RT, D, RA } },
+
+{ "lwzu", OP(33), OP_MASK, PPCCOM, { RT, D, RAL } },
+{ "lu", OP(33), OP_MASK, PWRCOM, { RT, D, RA } },
+
+{ "lbz", OP(34), OP_MASK, COM, { RT, D, RA } },
+
+{ "lbzu", OP(35), OP_MASK, COM, { RT, D, RAL } },
+
+{ "stw", OP(36), OP_MASK, PPCCOM, { RS, D, RA } },
+{ "st", OP(36), OP_MASK, PWRCOM, { RS, D, RA } },
+
+{ "stwu", OP(37), OP_MASK, PPCCOM, { RS, D, RAS } },
+{ "stu", OP(37), OP_MASK, PWRCOM, { RS, D, RA } },
+
+{ "stb", OP(38), OP_MASK, COM, { RS, D, RA } },
+
+{ "stbu", OP(39), OP_MASK, COM, { RS, D, RAS } },
+
+{ "lhz", OP(40), OP_MASK, COM, { RT, D, RA } },
+
+{ "lhzu", OP(41), OP_MASK, COM, { RT, D, RAL } },
+
+{ "lha", OP(42), OP_MASK, COM, { RT, D, RA } },
+
+{ "lhau", OP(43), OP_MASK, COM, { RT, D, RAL } },
+
+{ "sth", OP(44), OP_MASK, COM, { RS, D, RA } },
+
+{ "sthu", OP(45), OP_MASK, COM, { RS, D, RAS } },
+
+{ "lmw", OP(46), OP_MASK, PPCCOM, { RT, D, RAM } },
+{ "lm", OP(46), OP_MASK, PWRCOM, { RT, D, RA } },
+
+{ "stmw", OP(47), OP_MASK, PPCCOM, { RS, D, RA } },
+{ "stm", OP(47), OP_MASK, PWRCOM, { RS, D, RA } },
+
+{ "lfs", OP(48), OP_MASK, COM, { FRT, D, RA } },
+
+{ "lfsu", OP(49), OP_MASK, COM, { FRT, D, RAS } },
+
+{ "lfd", OP(50), OP_MASK, COM, { FRT, D, RA } },
+
+{ "lfdu", OP(51), OP_MASK, COM, { FRT, D, RAS } },
+
+{ "stfs", OP(52), OP_MASK, COM, { FRS, D, RA } },
+
+{ "stfsu", OP(53), OP_MASK, COM, { FRS, D, RAS } },
+
+{ "stfd", OP(54), OP_MASK, COM, { FRS, D, RA } },
+
+{ "stfdu", OP(55), OP_MASK, COM, { FRS, D, RAS } },
+
+{ "lfq", OP(56), OP_MASK, POWER2, { FRT, D, RA } },
+
+{ "lfqu", OP(57), OP_MASK, POWER2, { FRT, D, RA } },
+
+{ "ld", DSO(58,0), DS_MASK, PPC64, { RT, DS, RA } },
+
+{ "ldu", DSO(58,1), DS_MASK, PPC64, { RT, DS, RAL } },
+
+{ "lwa", DSO(58,2), DS_MASK, PPC64, { RT, DS, RA } },
+
+{ "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } },
+{ "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } },
+
+{ "fsubs", A(59,20,0), AFRC_MASK, PPC, { FRT, FRA, FRB } },
+{ "fsubs.", A(59,20,1), AFRC_MASK, PPC, { FRT, FRA, FRB } },
+
+{ "fadds", A(59,21,0), AFRC_MASK, PPC, { FRT, FRA, FRB } },
+{ "fadds.", A(59,21,1), AFRC_MASK, PPC, { FRT, FRA, FRB } },
+
+{ "fsqrts", A(59,22,0), AFRAFRC_MASK, PPC, { FRT, FRB } },
+{ "fsqrts.", A(59,22,1), AFRAFRC_MASK, PPC, { FRT, FRB } },
+
+{ "fres", A(59,24,0), AFRAFRC_MASK, PPC, { FRT, FRB } },
+{ "fres.", A(59,24,1), AFRAFRC_MASK, PPC, { FRT, FRB } },
+
+{ "fmuls", A(59,25,0), AFRB_MASK, PPC, { FRT, FRA, FRC } },
+{ "fmuls.", A(59,25,1), AFRB_MASK, PPC, { FRT, FRA, FRC } },
+
+{ "fmsubs", A(59,28,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+{ "fmsubs.", A(59,28,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+
+{ "fmadds", A(59,29,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+{ "fmadds.", A(59,29,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+
+{ "fnmsubs", A(59,30,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+{ "fnmsubs.",A(59,30,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+
+{ "fnmadds", A(59,31,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+{ "fnmadds.",A(59,31,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+
+{ "stfq", OP(60), OP_MASK, POWER2, { FRS, D, RA } },
+
+{ "stfqu", OP(61), OP_MASK, POWER2, { FRS, D, RA } },
+
+{ "std", DSO(62,0), DS_MASK, PPC64, { RS, DS, RA } },
+
+{ "stdu", DSO(62,1), DS_MASK, PPC64, { RS, DS, RAS } },
+
+{ "fcmpu", X(63,0), X_MASK|(3<<21), COM, { BF, FRA, FRB } },
+
+{ "frsp", XRC(63,12,0), XRA_MASK, COM, { FRT, FRB } },
+{ "frsp.", XRC(63,12,1), XRA_MASK, COM, { FRT, FRB } },
+
+{ "fctiw", XRC(63,14,0), XRA_MASK, PPCCOM, { FRT, FRB } },
+{ "fcir", XRC(63,14,0), XRA_MASK, POWER2, { FRT, FRB } },
+{ "fctiw.", XRC(63,14,1), XRA_MASK, PPCCOM, { FRT, FRB } },
+{ "fcir.", XRC(63,14,1), XRA_MASK, POWER2, { FRT, FRB } },
+
+{ "fctiwz", XRC(63,15,0), XRA_MASK, PPCCOM, { FRT, FRB } },
+{ "fcirz", XRC(63,15,0), XRA_MASK, POWER2, { FRT, FRB } },
+{ "fctiwz.", XRC(63,15,1), XRA_MASK, PPCCOM, { FRT, FRB } },
+{ "fcirz.", XRC(63,15,1), XRA_MASK, POWER2, { FRT, FRB } },
+
+{ "fdiv", A(63,18,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
+{ "fd", A(63,18,0), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
+{ "fdiv.", A(63,18,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
+{ "fd.", A(63,18,1), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
+
+{ "fsub", A(63,20,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
+{ "fs", A(63,20,0), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
+{ "fsub.", A(63,20,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
+{ "fs.", A(63,20,1), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
+
+{ "fadd", A(63,21,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
+{ "fa", A(63,21,0), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
+{ "fadd.", A(63,21,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
+{ "fa.", A(63,21,1), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
+
+{ "fsqrt", A(63,22,0), AFRAFRC_MASK, PPCPWR2, { FRT, FRB } },
+{ "fsqrt.", A(63,22,1), AFRAFRC_MASK, PPCPWR2, { FRT, FRB } },
+
+{ "fsel", A(63,23,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+{ "fsel.", A(63,23,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
+
+{ "fmul", A(63,25,0), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } },
+{ "fm", A(63,25,0), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } },
+{ "fmul.", A(63,25,1), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } },
+{ "fm.", A(63,25,1), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } },
+
+{ "frsqrte", A(63,26,0), AFRAFRC_MASK, PPC, { FRT, FRB } },
+{ "frsqrte.",A(63,26,1), AFRAFRC_MASK, PPC, { FRT, FRB } },
+
+{ "fmsub", A(63,28,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fms", A(63,28,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+{ "fmsub.", A(63,28,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fms.", A(63,28,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+
+{ "fmadd", A(63,29,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fma", A(63,29,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+{ "fmadd.", A(63,29,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fma.", A(63,29,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+
+{ "fnmsub", A(63,30,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fnms", A(63,30,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+{ "fnmsub.", A(63,30,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fnms.", A(63,30,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+
+{ "fnmadd", A(63,31,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fnma", A(63,31,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+{ "fnmadd.", A(63,31,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
+{ "fnma.", A(63,31,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
+
+{ "fcmpo", X(63,32), X_MASK|(3<<21), COM, { BF, FRA, FRB } },
+
+{ "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } },
+{ "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } },
+
+{ "fneg", XRC(63,40,0), XRA_MASK, COM, { FRT, FRB } },
+{ "fneg.", XRC(63,40,1), XRA_MASK, COM, { FRT, FRB } },
+
+{ "mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } },
+
+{ "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } },
+{ "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } },
+
+{ "fmr", XRC(63,72,0), XRA_MASK, COM, { FRT, FRB } },
+{ "fmr.", XRC(63,72,1), XRA_MASK, COM, { FRT, FRB } },
+
+{ "mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } },
+{ "mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } },
+
+{ "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } },
+{ "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } },
+
+{ "fabs", XRC(63,264,0), XRA_MASK, COM, { FRT, FRB } },
+{ "fabs.", XRC(63,264,1), XRA_MASK, COM, { FRT, FRB } },
+
+{ "mffs", XRC(63,583,0), XRARB_MASK, COM, { FRT } },
+{ "mffs.", XRC(63,583,1), XRARB_MASK, COM, { FRT } },
+
+{ "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB } },
+{ "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB } },
+
+{ "fctid", XRC(63,814,0), XRA_MASK, PPC64, { FRT, FRB } },
+{ "fctid.", XRC(63,814,1), XRA_MASK, PPC64, { FRT, FRB } },
+
+{ "fctidz", XRC(63,815,0), XRA_MASK, PPC64, { FRT, FRB } },
+{ "fctidz.", XRC(63,815,1), XRA_MASK, PPC64, { FRT, FRB } },
+
+{ "fcfid", XRC(63,846,0), XRA_MASK, PPC64, { FRT, FRB } },
+{ "fcfid.", XRC(63,846,1), XRA_MASK, PPC64, { FRT, FRB } },
+
+};
+
+const int powerpc_num_opcodes =
+ sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]);
+
+/* The macro table. This is only used by the assembler. */
+
+/* The expressions of the form (-x ! 31) & (x | 31) have the value 0
+ when x=0; 32-x when x is between 1 and 31; are negative if x is
+ negative; and are 32 or more otherwise. This is what you want
+ when, for instance, you are emulating a right shift by a
+ rotate-left-and-mask, because the underlying instructions support
+ shifts of size 0 but not shifts of size 32. By comparison, when
+ extracting x bits from some word you want to use just 32-x, because
+ the underlying instructions don't support extracting 0 bits but do
+ support extracting the whole word (32 bits in this case). */
+
+const struct powerpc_macro powerpc_macros[] = {
+{ "extldi", 4, PPC64, "rldicr %0,%1,%3,(%2)-1" },
+{ "extldi.", 4, PPC64, "rldicr. %0,%1,%3,(%2)-1" },
+{ "extrdi", 4, PPC64, "rldicl %0,%1,(%2)+(%3),64-(%2)" },
+{ "extrdi.", 4, PPC64, "rldicl. %0,%1,(%2)+(%3),64-(%2)" },
+{ "insrdi", 4, PPC64, "rldimi %0,%1,64-((%2)+(%3)),%3" },
+{ "insrdi.", 4, PPC64, "rldimi. %0,%1,64-((%2)+(%3)),%3" },
+{ "rotrdi", 3, PPC64, "rldicl %0,%1,(-(%2)!63)&((%2)|63),0" },
+{ "rotrdi.", 3, PPC64, "rldicl. %0,%1,(-(%2)!63)&((%2)|63),0" },
+{ "sldi", 3, PPC64, "rldicr %0,%1,%2,63-(%2)" },
+{ "sldi.", 3, PPC64, "rldicr. %0,%1,%2,63-(%2)" },
+{ "srdi", 3, PPC64, "rldicl %0,%1,(-(%2)!63)&((%2)|63),%2" },
+{ "srdi.", 3, PPC64, "rldicl. %0,%1,(-(%2)!63)&((%2)|63),%2" },
+{ "clrrdi", 3, PPC64, "rldicr %0,%1,0,63-(%2)" },
+{ "clrrdi.", 3, PPC64, "rldicr. %0,%1,0,63-(%2)" },
+{ "clrlsldi",4, PPC64, "rldic %0,%1,%3,(%2)-(%3)" },
+{ "clrlsldi.",4, PPC64, "rldic. %0,%1,%3,(%2)-(%3)" },
+
+{ "extlwi", 4, PPCCOM, "rlwinm %0,%1,%3,0,(%2)-1" },
+{ "extlwi.", 4, PPCCOM, "rlwinm. %0,%1,%3,0,(%2)-1" },
+{ "extrwi", 4, PPCCOM, "rlwinm %0,%1,(%2)+(%3),32-(%2),31" },
+{ "extrwi.", 4, PPCCOM, "rlwinm. %0,%1,(%2)+(%3),32-(%2),31" },
+{ "inslwi", 4, PPCCOM, "rlwimi %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1" },
+{ "inslwi.", 4, PPCCOM, "rlwimi. %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1"},
+{ "insrwi", 4, PPCCOM, "rlwimi %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1" },
+{ "insrwi.", 4, PPCCOM, "rlwimi. %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1"},
+{ "rotrwi", 3, PPCCOM, "rlwinm %0,%1,(-(%2)!31)&((%2)|31),0,31" },
+{ "rotrwi.", 3, PPCCOM, "rlwinm. %0,%1,(-(%2)!31)&((%2)|31),0,31" },
+{ "slwi", 3, PPCCOM, "rlwinm %0,%1,%2,0,31-(%2)" },
+{ "sli", 3, PWRCOM, "rlinm %0,%1,%2,0,31-(%2)" },
+{ "slwi.", 3, PPCCOM, "rlwinm. %0,%1,%2,0,31-(%2)" },
+{ "sli.", 3, PWRCOM, "rlinm. %0,%1,%2,0,31-(%2)" },
+{ "srwi", 3, PPCCOM, "rlwinm %0,%1,(-(%2)!31)&((%2)|31),%2,31" },
+{ "sri", 3, PWRCOM, "rlinm %0,%1,(-(%2)!31)&((%2)|31),%2,31" },
+{ "srwi.", 3, PPCCOM, "rlwinm. %0,%1,(-(%2)!31)&((%2)|31),%2,31" },
+{ "sri.", 3, PWRCOM, "rlinm. %0,%1,(-(%2)!31)&((%2)|31),%2,31" },
+{ "clrrwi", 3, PPCCOM, "rlwinm %0,%1,0,0,31-(%2)" },
+{ "clrrwi.", 3, PPCCOM, "rlwinm. %0,%1,0,0,31-(%2)" },
+{ "clrlslwi",4, PPCCOM, "rlwinm %0,%1,%3,(%2)-(%3),31-(%3)" },
+{ "clrlslwi.",4, PPCCOM, "rlwinm. %0,%1,%3,(%2)-(%3),31-(%3)" },
+
+};
+
+const int powerpc_num_macros =
+ sizeof (powerpc_macros) / sizeof (powerpc_macros[0]);
diff --git a/opcodes/sh-dis.c b/opcodes/sh-dis.c
new file mode 100644
index 00000000000..2ebfdb6d368
--- /dev/null
+++ b/opcodes/sh-dis.c
@@ -0,0 +1,387 @@
+/* Disassemble SH instructions.
+ Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#define STATIC_TABLE
+#define DEFINE_TABLE
+
+#include "sh-opc.h"
+#include "dis-asm.h"
+
+#define LITTLE_BIT 2
+
+static int
+print_insn_shx (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ fprintf_ftype fprintf_fn = info->fprintf_func;
+ void *stream = info->stream;
+ unsigned char insn[2];
+ unsigned char nibs[4];
+ int status;
+ bfd_vma relmask = ~ (bfd_vma) 0;
+ sh_opcode_info *op;
+
+ status = info->read_memory_func (memaddr, insn, 2, info);
+
+ if (status != 0)
+ {
+ info->memory_error_func (status, memaddr, info);
+ return -1;
+ }
+
+ if (info->flags & LITTLE_BIT)
+ {
+ nibs[0] = (insn[1] >> 4) & 0xf;
+ nibs[1] = insn[1] & 0xf;
+
+ nibs[2] = (insn[0] >> 4) & 0xf;
+ nibs[3] = insn[0] & 0xf;
+ }
+ else
+ {
+ nibs[0] = (insn[0] >> 4) & 0xf;
+ nibs[1] = insn[0] & 0xf;
+
+ nibs[2] = (insn[1] >> 4) & 0xf;
+ nibs[3] = insn[1] & 0xf;
+ }
+
+ for (op = sh_table; op->name; op++)
+ {
+ int n;
+ int imm = 0;
+ int rn = 0;
+ int rm = 0;
+ int rb = 0;
+ int disp_pc;
+ bfd_vma disp_pc_addr = 0;
+
+ for (n = 0; n < 4; n++)
+ {
+ int i = op->nibbles[n];
+
+ if (i < 16)
+ {
+ if (nibs[n] == i)
+ continue;
+ goto fail;
+ }
+ switch (i)
+ {
+ case BRANCH_8:
+ imm = (nibs[2] << 4) | (nibs[3]);
+ if (imm & 0x80)
+ imm |= ~0xff;
+ imm = ((char)imm) * 2 + 4 ;
+ goto ok;
+ case BRANCH_12:
+ imm = ((nibs[1]) << 8) | (nibs[2] << 4) | (nibs[3]);
+ if (imm & 0x800)
+ imm |= ~0xfff;
+ imm = imm * 2 + 4;
+ goto ok;
+ case IMM_4:
+ imm = nibs[3];
+ goto ok;
+ case IMM_4BY2:
+ imm = nibs[3] <<1;
+ goto ok;
+ case IMM_4BY4:
+ imm = nibs[3] <<2;
+ goto ok;
+ case IMM_8:
+ imm = (nibs[2] << 4) | nibs[3];
+ goto ok;
+ case PCRELIMM_8BY2:
+ imm = ((nibs[2] << 4) | nibs[3]) <<1;
+ relmask = ~ (bfd_vma) 1;
+ goto ok;
+ case PCRELIMM_8BY4:
+ imm = ((nibs[2] << 4) | nibs[3]) <<2;
+ relmask = ~ (bfd_vma) 3;
+ goto ok;
+ case IMM_8BY2:
+ imm = ((nibs[2] << 4) | nibs[3]) <<1;
+ goto ok;
+ case IMM_8BY4:
+ imm = ((nibs[2] << 4) | nibs[3]) <<2;
+ goto ok;
+ case DISP_8:
+ imm = (nibs[2] << 4) | (nibs[3]);
+ goto ok;
+ case DISP_4:
+ imm = nibs[3];
+ goto ok;
+ case REG_N:
+ rn = nibs[n];
+ break;
+ case REG_M:
+ rm = nibs[n];
+ break;
+ case REG_NM:
+ rn = (nibs[n] & 0xc) >> 2;
+ rm = (nibs[n] & 0x3);
+ break;
+ case REG_B:
+ rb = nibs[n] & 0x07;
+ break;
+ default:
+ abort();
+ }
+ }
+
+ ok:
+ fprintf_fn (stream,"%s\t", op->name);
+ disp_pc = 0;
+ for (n = 0; n < 3 && op->arg[n] != A_END; n++)
+ {
+ if (n && op->arg[1] != A_END)
+ fprintf_fn (stream, ",");
+ switch (op->arg[n])
+ {
+ case A_IMM:
+ fprintf_fn (stream, "#%d", (char)(imm));
+ break;
+ case A_R0:
+ fprintf_fn (stream, "r0");
+ break;
+ case A_REG_N:
+ fprintf_fn (stream, "r%d", rn);
+ break;
+ case A_INC_N:
+ fprintf_fn (stream, "@r%d+", rn);
+ break;
+ case A_DEC_N:
+ fprintf_fn (stream, "@-r%d", rn);
+ break;
+ case A_IND_N:
+ fprintf_fn (stream, "@r%d", rn);
+ break;
+ case A_DISP_REG_N:
+ fprintf_fn (stream, "@(%d,r%d)", imm, rn);
+ break;
+ case A_REG_M:
+ fprintf_fn (stream, "r%d", rm);
+ break;
+ case A_INC_M:
+ fprintf_fn (stream, "@r%d+", rm);
+ break;
+ case A_DEC_M:
+ fprintf_fn (stream, "@-r%d", rm);
+ break;
+ case A_IND_M:
+ fprintf_fn (stream, "@r%d", rm);
+ break;
+ case A_DISP_REG_M:
+ fprintf_fn (stream, "@(%d,r%d)", imm, rm);
+ break;
+ case A_REG_B:
+ fprintf_fn (stream, "r%d_bank", rb);
+ break;
+ case A_DISP_PC:
+ disp_pc = 1;
+ disp_pc_addr = imm + 4 + (memaddr & relmask);
+ (*info->print_address_func) (disp_pc_addr, info);
+ break;
+ case A_IND_R0_REG_N:
+ fprintf_fn (stream, "@(r0,r%d)", rn);
+ break;
+ case A_IND_R0_REG_M:
+ fprintf_fn (stream, "@(r0,r%d)", rm);
+ break;
+ case A_DISP_GBR:
+ fprintf_fn (stream, "@(%d,gbr)",imm);
+ break;
+ case A_R0_GBR:
+ fprintf_fn (stream, "@(r0,gbr)");
+ break;
+ case A_BDISP12:
+ case A_BDISP8:
+ (*info->print_address_func) (imm + memaddr, info);
+ break;
+ case A_SR:
+ fprintf_fn (stream, "sr");
+ break;
+ case A_GBR:
+ fprintf_fn (stream, "gbr");
+ break;
+ case A_VBR:
+ fprintf_fn (stream, "vbr");
+ break;
+ case A_SSR:
+ fprintf_fn (stream, "ssr");
+ break;
+ case A_SPC:
+ fprintf_fn (stream, "spc");
+ break;
+ case A_MACH:
+ fprintf_fn (stream, "mach");
+ break;
+ case A_MACL:
+ fprintf_fn (stream ,"macl");
+ break;
+ case A_PR:
+ fprintf_fn (stream, "pr");
+ break;
+ case A_SGR:
+ fprintf_fn (stream, "sgr");
+ break;
+ case A_DBR:
+ fprintf_fn (stream, "dbr");
+ break;
+ case FD_REG_N:
+ if (0)
+ goto d_reg_n;
+ case F_REG_N:
+ fprintf_fn (stream, "fr%d", rn);
+ break;
+ case F_REG_M:
+ fprintf_fn (stream, "fr%d", rm);
+ break;
+ case DX_REG_N:
+ if (rn & 1)
+ {
+ fprintf_fn (stream, "xd%d", rn & ~1);
+ break;
+ }
+ d_reg_n:
+ case D_REG_N:
+ fprintf_fn (stream, "dr%d", rn);
+ break;
+ case DX_REG_M:
+ if (rm & 1)
+ {
+ fprintf_fn (stream, "xd%d", rm & ~1);
+ break;
+ }
+ case D_REG_M:
+ fprintf_fn (stream, "dr%d", rm);
+ break;
+ case FPSCR_M:
+ case FPSCR_N:
+ fprintf_fn (stream, "fpscr");
+ break;
+ case FPUL_M:
+ case FPUL_N:
+ fprintf_fn (stream, "fpul");
+ break;
+ case F_FR0:
+ fprintf_fn (stream, "fr0");
+ break;
+ case V_REG_N:
+ fprintf_fn (stream, "fv%d", rn*4);
+ break;
+ case V_REG_M:
+ fprintf_fn (stream, "fv%d", rm*4);
+ break;
+ case XMTRX_M4:
+ fprintf_fn (stream, "xmtrx");
+ break;
+ default:
+ abort();
+ }
+ }
+
+#if 0
+ /* This code prints instructions in delay slots on the same line
+ as the instruction which needs the delay slots. This can be
+ confusing, since other disassembler don't work this way, and
+ it means that the instructions are not all in a line. So I
+ disabled it. Ian. */
+ if (!(info->flags & 1)
+ && (op->name[0] == 'j'
+ || (op->name[0] == 'b'
+ && (op->name[1] == 'r'
+ || op->name[1] == 's'))
+ || (op->name[0] == 'r' && op->name[1] == 't')
+ || (op->name[0] == 'b' && op->name[2] == '.')))
+ {
+ info->flags |= 1;
+ fprintf_fn (stream, "\t(slot ");
+ print_insn_shx (memaddr + 2, info);
+ info->flags &= ~1;
+ fprintf_fn (stream, ")");
+ return 4;
+ }
+#endif
+
+ if (disp_pc && strcmp (op->name, "mova") != 0)
+ {
+ int size;
+ bfd_byte bytes[4];
+
+ if (relmask == ~ (bfd_vma) 1)
+ size = 2;
+ else
+ size = 4;
+ status = info->read_memory_func (disp_pc_addr, bytes, size, info);
+ if (status == 0)
+ {
+ unsigned int val;
+
+ if (size == 2)
+ {
+ if ((info->flags & LITTLE_BIT) != 0)
+ val = bfd_getl16 (bytes);
+ else
+ val = bfd_getb16 (bytes);
+ }
+ else
+ {
+ if ((info->flags & LITTLE_BIT) != 0)
+ val = bfd_getl32 (bytes);
+ else
+ val = bfd_getb32 (bytes);
+ }
+ fprintf_fn (stream, "\t! 0x%x", val);
+ }
+ }
+
+ return 2;
+ fail:
+ ;
+
+ }
+ fprintf_fn (stream, ".word 0x%x%x%x%x", nibs[0], nibs[1], nibs[2], nibs[3]);
+ return 2;
+}
+
+int
+print_insn_shl (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int r;
+
+ info->flags = LITTLE_BIT;
+ r = print_insn_shx (memaddr, info);
+ return r;
+}
+
+int
+print_insn_sh (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ int r;
+
+ info->flags = 0;
+ r = print_insn_shx (memaddr, info);
+ return r;
+}
diff --git a/opcodes/sh-opc.h b/opcodes/sh-opc.h
new file mode 100644
index 00000000000..dc1aae5cbb1
--- /dev/null
+++ b/opcodes/sh-opc.h
@@ -0,0 +1,573 @@
+/* Definitions for SH opcodes.
+ Copyright (C) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+typedef enum {
+ HEX_0,
+ HEX_1,
+ HEX_2,
+ HEX_3,
+ HEX_4,
+ HEX_5,
+ HEX_6,
+ HEX_7,
+ HEX_8,
+ HEX_9,
+ HEX_A,
+ HEX_B,
+ HEX_C,
+ HEX_D,
+ HEX_E,
+ HEX_F,
+ REG_N,
+ REG_M,
+ REG_NM,
+ REG_B,
+ BRANCH_12,
+ BRANCH_8,
+ DISP_8,
+ DISP_4,
+ IMM_4,
+ IMM_4BY2,
+ IMM_4BY4,
+ PCRELIMM_8BY2,
+ PCRELIMM_8BY4,
+ IMM_8,
+ IMM_8BY2,
+ IMM_8BY4
+} sh_nibble_type;
+
+typedef enum {
+ A_END,
+ A_BDISP12,
+ A_BDISP8,
+ A_DEC_M,
+ A_DEC_N,
+ A_DISP_GBR,
+ A_DISP_PC,
+ A_DISP_REG_M,
+ A_DISP_REG_N,
+ A_GBR,
+ A_IMM,
+ A_INC_M,
+ A_INC_N,
+ A_IND_M,
+ A_IND_N,
+ A_IND_R0_REG_M,
+ A_IND_R0_REG_N,
+ A_MACH,
+ A_MACL,
+ A_PR,
+ A_R0,
+ A_R0_GBR,
+ A_REG_M,
+ A_REG_N,
+ A_REG_B,
+ A_SR,
+ A_VBR,
+ A_SSR,
+ A_SPC,
+ A_SGR,
+ A_DBR,
+ F_REG_N,
+ F_REG_M,
+ D_REG_N,
+ D_REG_M,
+ X_REG_N, /* Only used for argument parsing */
+ X_REG_M, /* Only used for argument parsing */
+ DX_REG_N,
+ DX_REG_M,
+ V_REG_N,
+ V_REG_M,
+ FD_REG_N,
+ XMTRX_M4,
+ F_FR0,
+ FPUL_N,
+ FPUL_M,
+ FPSCR_N,
+ FPSCR_M
+} sh_arg_type;
+
+typedef struct {
+ char *name;
+ sh_arg_type arg[4];
+ sh_nibble_type nibbles[4];
+} sh_opcode_info;
+
+#ifdef DEFINE_TABLE
+
+sh_opcode_info sh_table[] = {
+
+/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM_8}},
+
+/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}},
+
+/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}},
+
+/* 0011nnnnmmmm1111 addv <REG_M>,<REG_N>*/{"addv",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_F}},
+
+/* 11001001i8*1.... and #<imm>,R0 */{"and",{A_IMM,A_R0},{HEX_C,HEX_9,IMM_8}},
+
+/* 0010nnnnmmmm1001 and <REG_M>,<REG_N> */{"and",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_9}},
+
+/* 11001101i8*1.... and.b #<imm>,@(R0,GBR)*/{"and.b",{A_IMM,A_R0_GBR},{HEX_C,HEX_D,IMM_8}},
+
+/* 1010i12......... bra <bdisp12> */{"bra",{A_BDISP12},{HEX_A,BRANCH_12}},
+
+/* 1011i12......... bsr <bdisp12> */{"bsr",{A_BDISP12},{HEX_B,BRANCH_12}},
+
+/* 10001001i8p1.... bt <bdisp8> */{"bt",{A_BDISP8},{HEX_8,HEX_9,BRANCH_8}},
+
+/* 10001011i8p1.... bf <bdisp8> */{"bf",{A_BDISP8},{HEX_8,HEX_B,BRANCH_8}},
+
+/* 10001101i8p1.... bt.s <bdisp8> */{"bt.s",{A_BDISP8},{HEX_8,HEX_D,BRANCH_8}},
+
+/* 10001101i8p1.... bt/s <bdisp8> */{"bt/s",{A_BDISP8},{HEX_8,HEX_D,BRANCH_8}},
+
+/* 10001111i8p1.... bf.s <bdisp8> */{"bf.s",{A_BDISP8},{HEX_8,HEX_F,BRANCH_8}},
+
+/* 10001111i8p1.... bf/s <bdisp8> */{"bf/s",{A_BDISP8},{HEX_8,HEX_F,BRANCH_8}},
+
+/* 0000000000101000 clrmac */{"clrmac",{0},{HEX_0,HEX_0,HEX_2,HEX_8}},
+
+/* 0000000001001000 clrs */{"clrs",{0},{HEX_0,HEX_0,HEX_4,HEX_8}},
+
+/* 0000000000001000 clrt */{"clrt",{0},{HEX_0,HEX_0,HEX_0,HEX_8}},
+
+/* 10001000i8*1.... cmp/eq #<imm>,R0 */{"cmp/eq",{A_IMM,A_R0},{HEX_8,HEX_8,IMM_8}},
+
+/* 0011nnnnmmmm0000 cmp/eq <REG_M>,<REG_N>*/{"cmp/eq",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_0}},
+
+/* 0011nnnnmmmm0011 cmp/ge <REG_M>,<REG_N>*/{"cmp/ge",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_3}},
+
+/* 0011nnnnmmmm0111 cmp/gt <REG_M>,<REG_N>*/{"cmp/gt",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_7}},
+
+/* 0011nnnnmmmm0110 cmp/hi <REG_M>,<REG_N>*/{"cmp/hi",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_6}},
+
+/* 0011nnnnmmmm0010 cmp/hs <REG_M>,<REG_N>*/{"cmp/hs",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_2}},
+
+/* 0100nnnn00010101 cmp/pl <REG_N> */{"cmp/pl",{A_REG_N},{HEX_4,REG_N,HEX_1,HEX_5}},
+
+/* 0100nnnn00010001 cmp/pz <REG_N> */{"cmp/pz",{A_REG_N},{HEX_4,REG_N,HEX_1,HEX_1}},
+
+/* 0010nnnnmmmm1100 cmp/str <REG_M>,<REG_N>*/{"cmp/str",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_C}},
+
+/* 0010nnnnmmmm0111 div0s <REG_M>,<REG_N>*/{"div0s",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_7}},
+
+/* 0000000000011001 div0u */{"div0u",{0},{HEX_0,HEX_0,HEX_1,HEX_9}},
+
+/* 0011nnnnmmmm0100 div1 <REG_M>,<REG_N>*/{"div1",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_4}},
+
+/* 0110nnnnmmmm1110 exts.b <REG_M>,<REG_N>*/{"exts.b",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_E}},
+
+/* 0110nnnnmmmm1111 exts.w <REG_M>,<REG_N>*/{"exts.w",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_F}},
+
+/* 0110nnnnmmmm1100 extu.b <REG_M>,<REG_N>*/{"extu.b",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_C}},
+
+/* 0110nnnnmmmm1101 extu.w <REG_M>,<REG_N>*/{"extu.w",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_D}},
+
+/* 0100nnnn00101011 jmp @<REG_N> */{"jmp",{A_IND_N},{HEX_4,REG_N,HEX_2,HEX_B}},
+
+/* 0100nnnn00001011 jsr @<REG_N> */{"jsr",{A_IND_N},{HEX_4,REG_N,HEX_0,HEX_B}},
+
+/* 0100nnnn00001110 ldc <REG_N>,SR */{"ldc",{A_REG_N,A_SR},{HEX_4,REG_N,HEX_0,HEX_E}},
+
+/* 0100nnnn00011110 ldc <REG_N>,GBR */{"ldc",{A_REG_N,A_GBR},{HEX_4,REG_N,HEX_1,HEX_E}},
+
+/* 0100nnnn00101110 ldc <REG_N>,VBR */{"ldc",{A_REG_N,A_VBR},{HEX_4,REG_N,HEX_2,HEX_E}},
+
+/* 0100nnnn00111110 ldc <REG_N>,SSR */{"ldc",{A_REG_N,A_SSR},{HEX_4,REG_N,HEX_3,HEX_E}},
+
+/* 0100nnnn01001110 ldc <REG_N>,SPC */{"ldc",{A_REG_N,A_SPC},{HEX_4,REG_N,HEX_4,HEX_E}},
+
+/* 0100nnnn01111110 ldc <REG_N>,DBR */{"ldc",{A_REG_N,A_DBR},{HEX_4,REG_N,HEX_7,HEX_E}},
+
+/* 0100nnnn1xxx1110 ldc <REG_N>,Rn_BANK */{"ldc",{A_REG_N,A_REG_B},{HEX_4,REG_N,REG_B,HEX_E}},
+
+/* 0100nnnn00000111 ldc.l @<REG_N>+,SR */{"ldc.l",{A_INC_N,A_SR},{HEX_4,REG_N,HEX_0,HEX_7}},
+
+/* 0100nnnn00010111 ldc.l @<REG_N>+,GBR */{"ldc.l",{A_INC_N,A_GBR},{HEX_4,REG_N,HEX_1,HEX_7}},
+
+/* 0100nnnn00100111 ldc.l @<REG_N>+,VBR */{"ldc.l",{A_INC_N,A_VBR},{HEX_4,REG_N,HEX_2,HEX_7}},
+
+/* 0100nnnn00110111 ldc.l @<REG_N>+,SSR */{"ldc.l",{A_INC_N,A_SSR},{HEX_4,REG_N,HEX_3,HEX_7}},
+
+/* 0100nnnn01000111 ldc.l @<REG_N>+,SPC */{"ldc.l",{A_INC_N,A_SPC},{HEX_4,REG_N,HEX_4,HEX_7}},
+
+/* 0100nnnn01110111 ldc.l @<REG_N>+,DBR */{"ldc.l",{A_INC_N,A_DBR},{HEX_4,REG_N,HEX_7,HEX_7}},
+
+/* 0100nnnn1xxx0111 ldc.l <REG_N>,Rn_BANK */{"ldc.l",{A_INC_N,A_REG_B},{HEX_4,REG_N,REG_B,HEX_7}},
+
+/* 0100nnnn00001010 lds <REG_N>,MACH */{"lds",{A_REG_N,A_MACH},{HEX_4,REG_N,HEX_0,HEX_A}},
+
+/* 0100nnnn00011010 lds <REG_N>,MACL */{"lds",{A_REG_N,A_MACL},{HEX_4,REG_N,HEX_1,HEX_A}},
+
+/* 0100nnnn00101010 lds <REG_N>,PR */{"lds",{A_REG_N,A_PR},{HEX_4,REG_N,HEX_2,HEX_A}},
+
+/* 0100nnnn01011010 lds <REG_N>,FPUL */{"lds",{A_REG_M,FPUL_N},{HEX_4,REG_M,HEX_5,HEX_A}},
+
+/* 0100nnnn01101010 lds <REG_M>,FPSCR */{"lds",{A_REG_M,FPSCR_N},{HEX_4,REG_M,HEX_6,HEX_A}},
+
+/* 0100nnnn00000110 lds.l @<REG_N>+,MACH*/{"lds.l",{A_INC_N,A_MACH},{HEX_4,REG_N,HEX_0,HEX_6}},
+
+/* 0100nnnn00010110 lds.l @<REG_N>+,MACL*/{"lds.l",{A_INC_N,A_MACL},{HEX_4,REG_N,HEX_1,HEX_6}},
+
+/* 0100nnnn00100110 lds.l @<REG_N>+,PR */{"lds.l",{A_INC_N,A_PR},{HEX_4,REG_N,HEX_2,HEX_6}},
+
+/* 0100nnnn01010110 lds.l @<REG_M>+,FPUL*/{"lds.l",{A_INC_M,FPUL_N},{HEX_4,REG_M,HEX_5,HEX_6}},
+
+/* 0100nnnn01100110 lds.l @<REG_M>+,FPSCR*/{"lds.l",{A_INC_M,FPSCR_N},{HEX_4,REG_M,HEX_6,HEX_6}},
+
+/* 0000000000111000 ldtlb */{"ldtlb",{0},{HEX_0,HEX_0,HEX_3,HEX_8}},
+
+/* 0100nnnnmmmm1111 mac.w @<REG_M>+,@<REG_N>+*/{"mac.w",{A_INC_M,A_INC_N},{HEX_4,REG_N,REG_M,HEX_F}},
+
+/* 1110nnnni8*1.... mov #<imm>,<REG_N> */{"mov",{A_IMM,A_REG_N},{HEX_E,REG_N,IMM_8}},
+
+/* 0110nnnnmmmm0011 mov <REG_M>,<REG_N> */{"mov",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_3}},
+
+/* 0000nnnnmmmm0100 mov.b <REG_M>,@(R0,<REG_N>)*/{"mov.b",{ A_REG_M,A_IND_R0_REG_N},{HEX_0,REG_N,REG_M,HEX_4}},
+
+/* 0010nnnnmmmm0100 mov.b <REG_M>,@-<REG_N>*/{"mov.b",{ A_REG_M,A_DEC_N},{HEX_2,REG_N,REG_M,HEX_4}},
+
+/* 0010nnnnmmmm0000 mov.b <REG_M>,@<REG_N>*/{"mov.b",{ A_REG_M,A_IND_N},{HEX_2,REG_N,REG_M,HEX_0}},
+
+/* 10000100mmmmi4*1 mov.b @(<disp>,<REG_M>),R0*/{"mov.b",{A_DISP_REG_M,A_R0},{HEX_8,HEX_4,REG_M,IMM_4}},
+
+/* 11000100i8*1.... mov.b @(<disp>,GBR),R0*/{"mov.b",{A_DISP_GBR,A_R0},{HEX_C,HEX_4,IMM_8}},
+
+/* 0000nnnnmmmm1100 mov.b @(R0,<REG_M>),<REG_N>*/{"mov.b",{A_IND_R0_REG_M,A_REG_N},{HEX_0,REG_N,REG_M,HEX_C}},
+
+/* 0110nnnnmmmm0100 mov.b @<REG_M>+,<REG_N>*/{"mov.b",{A_INC_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_4}},
+
+/* 0110nnnnmmmm0000 mov.b @<REG_M>,<REG_N>*/{"mov.b",{A_IND_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_0}},
+
+/* 10000000mmmmi4*1 mov.b R0,@(<disp>,<REG_M>)*/{"mov.b",{A_R0,A_DISP_REG_M},{HEX_8,HEX_0,REG_M,IMM_4}},
+
+/* 11000000i8*1.... mov.b R0,@(<disp>,GBR)*/{"mov.b",{A_R0,A_DISP_GBR},{HEX_C,HEX_0,IMM_8}},
+
+/* 0001nnnnmmmmi4*4 mov.l <REG_M>,@(<disp>,<REG_N>)*/{"mov.l",{ A_REG_M,A_DISP_REG_N},{HEX_1,REG_N,REG_M,IMM_4BY4}},
+
+/* 0000nnnnmmmm0110 mov.l <REG_M>,@(R0,<REG_N>)*/{"mov.l",{ A_REG_M,A_IND_R0_REG_N},{HEX_0,REG_N,REG_M,HEX_6}},
+
+/* 0010nnnnmmmm0110 mov.l <REG_M>,@-<REG_N>*/{"mov.l",{ A_REG_M,A_DEC_N},{HEX_2,REG_N,REG_M,HEX_6}},
+
+/* 0010nnnnmmmm0010 mov.l <REG_M>,@<REG_N>*/{"mov.l",{ A_REG_M,A_IND_N},{HEX_2,REG_N,REG_M,HEX_2}},
+
+/* 0101nnnnmmmmi4*4 mov.l @(<disp>,<REG_M>),<REG_N>*/{"mov.l",{A_DISP_REG_M,A_REG_N},{HEX_5,REG_N,REG_M,IMM_4BY4}},
+
+/* 11000110i8*4.... mov.l @(<disp>,GBR),R0*/{"mov.l",{A_DISP_GBR,A_R0},{HEX_C,HEX_6,IMM_8BY4}},
+
+/* 1101nnnni8p4.... mov.l @(<disp>,PC),<REG_N>*/{"mov.l",{A_DISP_PC,A_REG_N},{HEX_D,REG_N,PCRELIMM_8BY4}},
+
+/* 0000nnnnmmmm1110 mov.l @(R0,<REG_M>),<REG_N>*/{"mov.l",{A_IND_R0_REG_M,A_REG_N},{HEX_0,REG_N,REG_M,HEX_E}},
+
+/* 0110nnnnmmmm0110 mov.l @<REG_M>+,<REG_N>*/{"mov.l",{A_INC_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_6}},
+
+/* 0110nnnnmmmm0010 mov.l @<REG_M>,<REG_N>*/{"mov.l",{A_IND_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_2}},
+
+/* 11000010i8*4.... mov.l R0,@(<disp>,GBR)*/{"mov.l",{A_R0,A_DISP_GBR},{HEX_C,HEX_2,IMM_8BY4}},
+
+/* 0000nnnnmmmm0101 mov.w <REG_M>,@(R0,<REG_N>)*/{"mov.w",{ A_REG_M,A_IND_R0_REG_N},{HEX_0,REG_N,REG_M,HEX_5}},
+
+/* 0010nnnnmmmm0101 mov.w <REG_M>,@-<REG_N>*/{"mov.w",{ A_REG_M,A_DEC_N},{HEX_2,REG_N,REG_M,HEX_5}},
+
+/* 0010nnnnmmmm0001 mov.w <REG_M>,@<REG_N>*/{"mov.w",{ A_REG_M,A_IND_N},{HEX_2,REG_N,REG_M,HEX_1}},
+
+/* 10000101mmmmi4*2 mov.w @(<disp>,<REG_M>),R0*/{"mov.w",{A_DISP_REG_M,A_R0},{HEX_8,HEX_5,REG_M,IMM_4BY2}},
+
+/* 11000101i8*2.... mov.w @(<disp>,GBR),R0*/{"mov.w",{A_DISP_GBR,A_R0},{HEX_C,HEX_5,IMM_8BY2}},
+
+/* 1001nnnni8p2.... mov.w @(<disp>,PC),<REG_N>*/{"mov.w",{A_DISP_PC,A_REG_N},{HEX_9,REG_N,PCRELIMM_8BY2}},
+
+/* 0000nnnnmmmm1101 mov.w @(R0,<REG_M>),<REG_N>*/{"mov.w",{A_IND_R0_REG_M,A_REG_N},{HEX_0,REG_N,REG_M,HEX_D}},
+
+/* 0110nnnnmmmm0101 mov.w @<REG_M>+,<REG_N>*/{"mov.w",{A_INC_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_5}},
+
+/* 0110nnnnmmmm0001 mov.w @<REG_M>,<REG_N>*/{"mov.w",{A_IND_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_1}},
+
+/* 10000001mmmmi4*2 mov.w R0,@(<disp>,<REG_M>)*/{"mov.w",{A_R0,A_DISP_REG_M},{HEX_8,HEX_1,REG_M,IMM_4BY2}},
+
+/* 11000001i8*2.... mov.w R0,@(<disp>,GBR)*/{"mov.w",{A_R0,A_DISP_GBR},{HEX_C,HEX_1,IMM_8BY2}},
+
+/* 11000111i8p4.... mova @(<disp>,PC),R0*/{"mova",{A_DISP_PC,A_R0},{HEX_C,HEX_7,PCRELIMM_8BY4}},
+/* 0000nnnn11000011 movca.l R0,@<REG_N> */{"movca.l",{A_R0,A_IND_N},{HEX_0,REG_N,HEX_C,HEX_3}},
+
+
+/* 0000nnnn00101001 movt <REG_N> */{"movt",{A_REG_N},{HEX_0,REG_N,HEX_2,HEX_9}},
+
+/* 0010nnnnmmmm1111 muls <REG_M>,<REG_N>*/{"muls",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_F}},
+
+/* 0000nnnnmmmm0111 mul.l <REG_M>,<REG_N>*/{"mul.l",{ A_REG_M,A_REG_N},{HEX_0,REG_N,REG_M,HEX_7}},
+
+/* 0010nnnnmmmm1110 mulu <REG_M>,<REG_N>*/{"mulu",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_E}},
+
+/* 0110nnnnmmmm1011 neg <REG_M>,<REG_N> */{"neg",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_B}},
+
+/* 0110nnnnmmmm1010 negc <REG_M>,<REG_N>*/{"negc",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_A}},
+
+/* 0000000000001001 nop */{"nop",{0},{HEX_0,HEX_0,HEX_0,HEX_9}},
+
+/* 0110nnnnmmmm0111 not <REG_M>,<REG_N> */{"not",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_7}},
+/* 0000nnnn10010011 ocbi @<REG_N> */{"ocbi",{A_IND_N},{HEX_0,REG_N,HEX_9,HEX_3}},
+
+/* 0000nnnn10100011 ocbp @<REG_N> */{"ocbp",{A_IND_N},{HEX_0,REG_N,HEX_A,HEX_3}},
+
+/* 0000nnnn10110011 ocbwb @<REG_N> */{"ocbwb",{A_IND_N},{HEX_0,REG_N,HEX_B,HEX_3}},
+
+
+/* 11001011i8*1.... or #<imm>,R0 */{"or",{A_IMM,A_R0},{HEX_C,HEX_B,IMM_8}},
+
+/* 0010nnnnmmmm1011 or <REG_M>,<REG_N> */{"or",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_B}},
+
+/* 11001111i8*1.... or.b #<imm>,@(R0,GBR)*/{"or.b",{A_IMM,A_R0_GBR},{HEX_C,HEX_F,IMM_8}},
+
+/* 0000nnnn10000011 pref @<REG_N> */{"pref",{A_IND_N},{HEX_0,REG_N,HEX_8,HEX_3}},
+
+/* 0100nnnn00100100 rotcl <REG_N> */{"rotcl",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_4}},
+
+/* 0100nnnn00100101 rotcr <REG_N> */{"rotcr",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_5}},
+
+/* 0100nnnn00000100 rotl <REG_N> */{"rotl",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_4}},
+
+/* 0100nnnn00000101 rotr <REG_N> */{"rotr",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_5}},
+
+/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}},
+
+/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}},
+
+/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}},
+/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}},
+
+/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}},
+
+/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}},
+
+/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}},
+
+/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}},
+
+/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}},
+
+/* 0100nnnn00101000 shll16 <REG_N> */{"shll16",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_8}},
+
+/* 0100nnnn00001000 shll2 <REG_N> */{"shll2",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_8}},
+
+/* 0100nnnn00011000 shll8 <REG_N> */{"shll8",{A_REG_N},{HEX_4,REG_N,HEX_1,HEX_8}},
+
+/* 0100nnnn00000001 shlr <REG_N> */{"shlr",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_1}},
+
+/* 0100nnnn00101001 shlr16 <REG_N> */{"shlr16",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_9}},
+
+/* 0100nnnn00001001 shlr2 <REG_N> */{"shlr2",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_9}},
+
+/* 0100nnnn00011001 shlr8 <REG_N> */{"shlr8",{A_REG_N},{HEX_4,REG_N,HEX_1,HEX_9}},
+
+/* 0000000000011011 sleep */{"sleep",{0},{HEX_0,HEX_0,HEX_1,HEX_B}},
+
+/* 0000nnnn00000010 stc SR,<REG_N> */{"stc",{A_SR,A_REG_N},{HEX_0,REG_N,HEX_0,HEX_2}},
+
+/* 0000nnnn00010010 stc GBR,<REG_N> */{"stc",{A_GBR,A_REG_N},{HEX_0,REG_N,HEX_1,HEX_2}},
+
+/* 0000nnnn00100010 stc VBR,<REG_N> */{"stc",{A_VBR,A_REG_N},{HEX_0,REG_N,HEX_2,HEX_2}},
+
+/* 0000nnnn00110010 stc SSR,<REG_N> */{"stc",{A_SSR,A_REG_N},{HEX_0,REG_N,HEX_3,HEX_2}},
+
+/* 0000nnnn01000010 stc SPC,<REG_N> */{"stc",{A_SPC,A_REG_N},{HEX_0,REG_N,HEX_4,HEX_2}},
+
+/* 0000nnnn01100010 stc SGR,<REG_N> */{"stc",{A_SGR,A_REG_N},{HEX_0,REG_N,HEX_6,HEX_2}},
+
+/* 0000nnnn01110010 stc DBR,<REG_N> */{"stc",{A_DBR,A_REG_N},{HEX_0,REG_N,HEX_7,HEX_2}},
+
+/* 0000nnnn1xxx0012 stc Rn_BANK,<REG_N> */{"stc",{A_REG_B,A_REG_N},{HEX_0,REG_N,REG_B,HEX_2}},
+
+/* 0100nnnn00000011 stc.l SR,@-<REG_N> */{"stc.l",{A_SR,A_DEC_N},{HEX_4,REG_N,HEX_0,HEX_3}},
+
+/* 0100nnnn00010011 stc.l GBR,@-<REG_N> */{"stc.l",{A_GBR,A_DEC_N},{HEX_4,REG_N,HEX_1,HEX_3}},
+
+/* 0100nnnn00100011 stc.l VBR,@-<REG_N> */{"stc.l",{A_VBR,A_DEC_N},{HEX_4,REG_N,HEX_2,HEX_3}},
+
+/* 0100nnnn00110011 stc.l SSR,@-<REG_N> */{"stc.l",{A_SSR,A_DEC_N},{HEX_4,REG_N,HEX_3,HEX_3}},
+
+/* 0100nnnn01000011 stc.l SPC,@-<REG_N> */{"stc.l",{A_SPC,A_DEC_N},{HEX_4,REG_N,HEX_4,HEX_3}},
+
+/* 0100nnnn01100011 stc.l SGR,@-<REG_N> */{"stc.l",{A_SGR,A_DEC_N},{HEX_4,REG_N,HEX_6,HEX_3}},
+
+/* 0100nnnn01110011 stc.l DBR,@-<REG_N> */{"stc.l",{A_DBR,A_DEC_N},{HEX_4,REG_N,HEX_7,HEX_3}},
+
+/* 0100nnnn1xxx0012 stc.l Rn_BANK,@-<REG_N> */{"stc.l",{A_REG_B,A_DEC_N},{HEX_4,REG_N,REG_B,HEX_3}},
+
+/* 0000nnnn00001010 sts MACH,<REG_N> */{"sts",{A_MACH,A_REG_N},{HEX_0,REG_N,HEX_0,HEX_A}},
+
+/* 0000nnnn00011010 sts MACL,<REG_N> */{"sts",{A_MACL,A_REG_N},{HEX_0,REG_N,HEX_1,HEX_A}},
+
+/* 0000nnnn00101010 sts PR,<REG_N> */{"sts",{A_PR,A_REG_N},{HEX_0,REG_N,HEX_2,HEX_A}},
+
+/* 0000nnnn01011010 sts FPUL,<REG_N> */{"sts",{FPUL_M,A_REG_N},{HEX_0,REG_N,HEX_5,HEX_A}},
+
+/* 0000nnnn01101010 sts FPSCR,<REG_N> */{"sts",{FPSCR_M,A_REG_N},{HEX_0,REG_N,HEX_6,HEX_A}},
+
+/* 0100nnnn00000010 sts.l MACH,@-<REG_N>*/{"sts.l",{A_MACH,A_DEC_N},{HEX_4,REG_N,HEX_0,HEX_2}},
+
+/* 0100nnnn00010010 sts.l MACL,@-<REG_N>*/{"sts.l",{A_MACL,A_DEC_N},{HEX_4,REG_N,HEX_1,HEX_2}},
+
+/* 0100nnnn00100010 sts.l PR,@-<REG_N> */{"sts.l",{A_PR,A_DEC_N},{HEX_4,REG_N,HEX_2,HEX_2}},
+
+/* 0100nnnn01010010 sts.l FPUL,@-<REG_N>*/{"sts.l",{FPUL_M,A_DEC_N},{HEX_4,REG_N,HEX_5,HEX_2}},
+
+/* 0100nnnn01100010 sts.l FPSCR,@-<REG_N>*/{"sts.l",{FPSCR_M,A_DEC_N},{HEX_4,REG_N,HEX_6,HEX_2}},
+
+/* 0011nnnnmmmm1000 sub <REG_M>,<REG_N> */{"sub",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_8}},
+
+/* 0011nnnnmmmm1010 subc <REG_M>,<REG_N>*/{"subc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_A}},
+
+/* 0011nnnnmmmm1011 subv <REG_M>,<REG_N>*/{"subv",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_B}},
+
+/* 0110nnnnmmmm1000 swap.b <REG_M>,<REG_N>*/{"swap.b",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_8}},
+
+/* 0110nnnnmmmm1001 swap.w <REG_M>,<REG_N>*/{"swap.w",{ A_REG_M,A_REG_N},{HEX_6,REG_N,REG_M,HEX_9}},
+
+/* 0100nnnn00011011 tas.b @<REG_N> */{"tas.b",{A_IND_N},{HEX_4,REG_N,HEX_1,HEX_B}},
+
+/* 11000011i8*1.... trapa #<imm> */{"trapa",{A_IMM},{HEX_C,HEX_3,IMM_8}},
+
+/* 11001000i8*1.... tst #<imm>,R0 */{"tst",{A_IMM,A_R0},{HEX_C,HEX_8,IMM_8}},
+
+/* 0010nnnnmmmm1000 tst <REG_M>,<REG_N> */{"tst",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_8}},
+
+/* 11001100i8*1.... tst.b #<imm>,@(R0,GBR)*/{"tst.b",{A_IMM,A_R0_GBR},{HEX_C,HEX_C,IMM_8}},
+
+/* 11001010i8*1.... xor #<imm>,R0 */{"xor",{A_IMM,A_R0},{HEX_C,HEX_A,IMM_8}},
+
+/* 0010nnnnmmmm1010 xor <REG_M>,<REG_N> */{"xor",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_A}},
+
+/* 11001110i8*1.... xor.b #<imm>,@(R0,GBR)*/{"xor.b",{A_IMM,A_R0_GBR},{HEX_C,HEX_E,IMM_8}},
+
+/* 0010nnnnmmmm1101 xtrct <REG_M>,<REG_N>*/{"xtrct",{ A_REG_M,A_REG_N},{HEX_2,REG_N,REG_M,HEX_D}},
+
+/* 0000nnnnmmmm0111 mul.l <REG_M>,<REG_N>*/{"mul.l",{ A_REG_M,A_REG_N},{HEX_0,REG_N,REG_M,HEX_7}},
+
+/* 0100nnnn00010000 dt <REG_N> */{"dt",{A_REG_N},{HEX_4,REG_N,HEX_1,HEX_0}},
+
+/* 0011nnnnmmmm1101 dmuls.l <REG_M>,<REG_N>*/{"dmuls.l",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_D}},
+
+/* 0011nnnnmmmm0101 dmulu.l <REG_M>,<REG_N>*/{"dmulu.l",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_5}},
+
+/* 0000nnnnmmmm1111 mac.l @<REG_M>+,@<REG_N>+*/{"mac.l",{A_INC_M,A_INC_N},{HEX_0,REG_N,REG_M,HEX_F}},
+
+/* 0000nnnn00100011 braf <REG_N> */{"braf",{A_REG_N},{HEX_0,REG_N,HEX_2,HEX_3}},
+
+/* 0000nnnn00000011 bsrf <REG_N> */{"bsrf",{A_REG_N},{HEX_0,REG_N,HEX_0,HEX_3}},
+
+/* 1111nnnn01011101 fabs <F_REG_N> */{"fabs",{FD_REG_N},{HEX_F,REG_N,HEX_5,HEX_D}},
+
+/* 1111nnnnmmmm0000 fadd <F_REG_M>,<F_REG_N>*/{"fadd",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_0}},
+/* 1111nnn0mmm00000 fadd <D_REG_M>,<D_REG_N>*/{"fadd",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_0}},
+
+/* 1111nnnnmmmm0100 fcmp/eq <F_REG_M>,<F_REG_N>*/{"fcmp/eq",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_4}},
+/* 1111nnn0mmm00100 fcmp/eq <D_REG_M>,<D_REG_N>*/{"fcmp/eq",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_4}},
+
+/* 1111nnnnmmmm0101 fcmp/gt <F_REG_M>,<F_REG_N>*/{"fcmp/gt",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_5}},
+/* 1111nnn0mmm00101 fcmp/gt <D_REG_M>,<D_REG_N>*/{"fcmp/gt",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_5}},
+
+/* 1111nnn010111101 fcnvds <D_REG_N>,FPUL*/{"fcnvds",{D_REG_N,FPUL_M},{HEX_F,REG_N,HEX_B,HEX_D}},
+
+/* 1111nnn010101101 fcnvsd FPUL,<D_REG_N>*/{"fcnvsd",{FPUL_M,D_REG_N},{HEX_F,REG_N,HEX_A,HEX_D}},
+
+/* 1111nnnnmmmm0011 fdiv <F_REG_M>,<F_REG_N>*/{"fdiv",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_3}},
+/* 1111nnn0mmm00011 fdiv <D_REG_M>,<D_REG_N>*/{"fdiv",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_3}},
+
+/* 1111nnmm11101101 fipr <V_REG_M>,<V_REG_N>*/{"fipr",{V_REG_M,V_REG_N},{HEX_F,REG_NM,HEX_E,HEX_D}},
+
+/* 1111nnnn10001101 fldi0 <F_REG_N> */{"fldi0",{F_REG_N},{HEX_F,REG_N,HEX_8,HEX_D}},
+
+/* 1111nnnn10011101 fldi1 <F_REG_N> */{"fldi1",{F_REG_N},{HEX_F,REG_N,HEX_9,HEX_D}},
+
+/* 1111nnnn00011101 flds <F_REG_N>,FPUL*/{"flds",{F_REG_N,FPUL_M},{HEX_F,REG_N,HEX_1,HEX_D}},
+
+/* 1111nnnn00101101 float FPUL,<FD_REG_N>*/{"float",{FPUL_M,FD_REG_N},{HEX_F,REG_N,HEX_2,HEX_D}},
+
+/* 1111nnnnmmmm1110 fmac FR0,<F_REG_M>,<F_REG_N>*/{"fmac",{F_FR0,F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_E}},
+
+/* 1111nnnnmmmm1100 fmov <F_REG_M>,<F_REG_N>*/{"fmov",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_C}},
+/* 1111nnnnmmmm1100 fmov <DX_REG_M>,<DX_REG_N>*/{"fmov",{DX_REG_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_C}},
+
+/* 1111nnnnmmmm1000 fmov @<REG_M>,<F_REG_N>*/{"fmov",{A_IND_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_8}},
+/* 1111nnnnmmmm1000 fmov @<REG_M>,<DX_REG_N>*/{"fmov",{A_IND_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_8}},
+
+/* 1111nnnnmmmm1010 fmov <F_REG_M>,@<REG_N>*/{"fmov",{F_REG_M,A_IND_N},{HEX_F,REG_N,REG_M,HEX_A}},
+/* 1111nnnnmmmm1010 fmov <DX_REG_M>,@<REG_N>*/{"fmov",{DX_REG_M,A_IND_N},{HEX_F,REG_N,REG_M,HEX_A}},
+
+/* 1111nnnnmmmm1001 fmov @<REG_M>+,<F_REG_N>*/{"fmov",{A_INC_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_9}},
+/* 1111nnnnmmmm1001 fmov @<REG_M>+,<DX_REG_N>*/{"fmov",{A_INC_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_9}},
+
+/* 1111nnnnmmmm1011 fmov <F_REG_M>,@-<REG_N>*/{"fmov",{F_REG_M,A_DEC_N},{HEX_F,REG_N,REG_M,HEX_B}},
+/* 1111nnnnmmmm1011 fmov <DX_REG_M>,@-<REG_N>*/{"fmov",{DX_REG_M,A_DEC_N},{HEX_F,REG_N,REG_M,HEX_B}},
+
+/* 1111nnnnmmmm0110 fmov @(R0,<REG_M>),<F_REG_N>*/{"fmov",{A_IND_R0_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_6}},
+/* 1111nnnnmmmm0110 fmov @(R0,<REG_M>),<DX_REG_N>*/{"fmov",{A_IND_R0_REG_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_6}},
+
+/* 1111nnnnmmmm0111 fmov <F_REG_M>,@(R0,<REG_N>)*/{"fmov",{F_REG_M,A_IND_R0_REG_N},{HEX_F,REG_N,REG_M,HEX_7}},
+/* 1111nnnnmmmm0111 fmov <DX_REG_M>,@(R0,<REG_N>)*/{"fmov",{DX_REG_M,A_IND_R0_REG_N},{HEX_F,REG_N,REG_M,HEX_7}},
+
+/* 1111nnnnmmmm1000 fmov.d @<REG_M>,<DX_REG_N>*/{"fmov.d",{A_IND_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_8}},
+
+/* 1111nnnnmmmm1010 fmov.d <DX_REG_M>,@<REG_N>*/{"fmov.d",{DX_REG_M,A_IND_N},{HEX_F,REG_N,REG_M,HEX_A}},
+
+/* 1111nnnnmmmm1001 fmov.d @<REG_M>+,<DX_REG_N>*/{"fmov.d",{A_INC_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_9}},
+
+/* 1111nnnnmmmm1011 fmov.d <DX_REG_M>,@-<REG_N>*/{"fmov.d",{DX_REG_M,A_DEC_N},{HEX_F,REG_N,REG_M,HEX_B}},
+
+/* 1111nnnnmmmm0110 fmov.d @(R0,<REG_M>),<DX_REG_N>*/{"fmov.d",{A_IND_R0_REG_M,DX_REG_N},{HEX_F,REG_N,REG_M,HEX_6}},
+
+/* 1111nnnnmmmm0111 fmov.d <DX_REG_M>,@(R0,<REG_N>)*/{"fmov.d",{DX_REG_M,A_IND_R0_REG_N},{HEX_F,REG_N,REG_M,HEX_7}},
+
+/* 1111nnnnmmmm1000 fmov.s @<REG_M>,<F_REG_N>*/{"fmov.s",{A_IND_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_8}},
+
+/* 1111nnnnmmmm1010 fmov.s <F_REG_M>,@<REG_N>*/{"fmov.s",{F_REG_M,A_IND_N},{HEX_F,REG_N,REG_M,HEX_A}},
+
+/* 1111nnnnmmmm1001 fmov.s @<REG_M>+,<F_REG_N>*/{"fmov.s",{A_INC_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_9}},
+
+/* 1111nnnnmmmm1011 fmov.s <F_REG_M>,@-<REG_N>*/{"fmov.s",{F_REG_M,A_DEC_N},{HEX_F,REG_N,REG_M,HEX_B}},
+
+/* 1111nnnnmmmm0110 fmov.s @(R0,<REG_M>),<F_REG_N>*/{"fmov.s",{A_IND_R0_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_6}},
+
+/* 1111nnnnmmmm0111 fmov.s <F_REG_M>,@(R0,<REG_N>)*/{"fmov.s",{F_REG_M,A_IND_R0_REG_N},{HEX_F,REG_N,REG_M,HEX_7}},
+
+/* 1111nnnnmmmm0010 fmul <F_REG_M>,<F_REG_N>*/{"fmul",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_2}},
+/* 1111nnn0mmm00010 fmul <D_REG_M>,<D_REG_N>*/{"fmul",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_2}},
+
+/* 1111nnnn01001101 fneg <FD_REG_N> */{"fneg",{FD_REG_N},{HEX_F,REG_N,HEX_4,HEX_D}},
+
+/* 1111101111111101 frchg */{"frchg",{0},{HEX_F,HEX_B,HEX_F,HEX_D}},
+
+/* 1111001111111101 fschg */{"fschg",{0},{HEX_F,HEX_3,HEX_F,HEX_D}},
+
+/* 1111nnnn01101101 fsqrt <FD_REG_N> */{"fsqrt",{FD_REG_N},{HEX_F,REG_N,HEX_6,HEX_D}},
+
+/* 1111nnnn00001101 fsts FPUL,<F_REG_N>*/{"fsts",{FPUL_M,F_REG_N},{HEX_F,REG_N,HEX_0,HEX_D}},
+
+/* 1111nnnnmmmm0001 fsub <F_REG_M>,<F_REG_N>*/{"fsub",{F_REG_M,F_REG_N},{HEX_F,REG_N,REG_M,HEX_1}},
+/* 1111nnn0mmm00001 fsub <D_REG_M>,<D_REG_N>*/{"fsub",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_1}},
+
+/* 1111nnnn00111101 ftrc <FD_REG_N>,FPUL*/{"ftrc",{FD_REG_N,FPUL_M},{HEX_F,REG_N,HEX_3,HEX_D}},
+
+/* 1111nn0111111101 ftrv XMTRX_M4,<V_REG_n>*/{"ftrv",{XMTRX_M4,V_REG_N},{HEX_F,REG_NM,HEX_F,HEX_D}},
+
+{ 0 }
+};
+
+#endif
diff --git a/opcodes/sparc-dis.c b/opcodes/sparc-dis.c
new file mode 100644
index 00000000000..0975b280e28
--- /dev/null
+++ b/opcodes/sparc-dis.c
@@ -0,0 +1,969 @@
+/* Print SPARC instructions.
+ Copyright (C) 1989, 91-97, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+
+#include "ansidecl.h"
+#include "sysdep.h"
+#include "opcode/sparc.h"
+#include "dis-asm.h"
+#include "libiberty.h"
+#include "opintl.h"
+
+/* Bitmask of v9 architectures. */
+#define MASK_V9 ((1 << SPARC_OPCODE_ARCH_V9) \
+ | (1 << SPARC_OPCODE_ARCH_V9A))
+/* 1 if INSN is for v9 only. */
+#define V9_ONLY_P(insn) (! ((insn)->architecture & ~MASK_V9))
+/* 1 if INSN is for v9. */
+#define V9_P(insn) (((insn)->architecture & MASK_V9) != 0)
+
+/* The sorted opcode table. */
+static const struct sparc_opcode **sorted_opcodes;
+
+/* For faster lookup, after insns are sorted they are hashed. */
+/* ??? I think there is room for even more improvement. */
+
+#define HASH_SIZE 256
+/* It is important that we only look at insn code bits as that is how the
+ opcode table is hashed. OPCODE_BITS is a table of valid bits for each
+ of the main types (0,1,2,3). */
+static int opcode_bits[4] = { 0x01c00000, 0x0, 0x01f80000, 0x01f80000 };
+#define HASH_INSN(INSN) \
+ ((((INSN) >> 24) & 0xc0) | (((INSN) & opcode_bits[((INSN) >> 30) & 3]) >> 19))
+struct opcode_hash {
+ struct opcode_hash *next;
+ const struct sparc_opcode *opcode;
+};
+static struct opcode_hash *opcode_hash_table[HASH_SIZE];
+
+static void build_hash_table
+ PARAMS ((const struct sparc_opcode **, struct opcode_hash **, int));
+static int is_delayed_branch PARAMS ((unsigned long));
+static int compare_opcodes PARAMS ((const PTR, const PTR));
+static int compute_arch_mask PARAMS ((unsigned long));
+
+/* Sign-extend a value which is N bits long. */
+#define SEX(value, bits) \
+ ((((int)(value)) << ((8 * sizeof (int)) - bits)) \
+ >> ((8 * sizeof (int)) - bits) )
+
+static char *reg_names[] =
+{ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
+ "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
+ "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
+ "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7",
+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
+ "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
+ "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
+ "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
+ "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
+ "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47",
+ "f48", "f49", "f50", "f51", "f52", "f53", "f54", "f55",
+ "f56", "f57", "f58", "f59", "f60", "f61", "f62", "f63",
+/* psr, wim, tbr, fpsr, cpsr are v8 only. */
+ "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr"
+};
+
+#define freg_names (&reg_names[4 * 8])
+
+/* These are ordered according to there register number in
+ rdpr and wrpr insns. */
+static char *v9_priv_reg_names[] =
+{
+ "tpc", "tnpc", "tstate", "tt", "tick", "tba", "pstate", "tl",
+ "pil", "cwp", "cansave", "canrestore", "cleanwin", "otherwin",
+ "wstate", "fq"
+ /* "ver" - special cased */
+};
+
+/* These are ordered according to there register number in
+ rd and wr insns (-16). */
+static char *v9a_asr_reg_names[] =
+{
+ "pcr", "pic", "dcr", "gsr", "set_softint", "clear_softint",
+ "softint", "tick_cmpr"
+};
+
+/* Macros used to extract instruction fields. Not all fields have
+ macros defined here, only those which are actually used. */
+
+#define X_RD(i) (((i) >> 25) & 0x1f)
+#define X_RS1(i) (((i) >> 14) & 0x1f)
+#define X_LDST_I(i) (((i) >> 13) & 1)
+#define X_ASI(i) (((i) >> 5) & 0xff)
+#define X_RS2(i) (((i) >> 0) & 0x1f)
+#define X_IMM(i,n) (((i) >> 0) & ((1 << (n)) - 1))
+#define X_SIMM(i,n) SEX (X_IMM ((i), (n)), (n))
+#define X_DISP22(i) (((i) >> 0) & 0x3fffff)
+#define X_IMM22(i) X_DISP22 (i)
+#define X_DISP30(i) (((i) >> 0) & 0x3fffffff)
+
+/* These are for v9. */
+#define X_DISP16(i) (((((i) >> 20) & 3) << 14) | (((i) >> 0) & 0x3fff))
+#define X_DISP19(i) (((i) >> 0) & 0x7ffff)
+#define X_MEMBAR(i) ((i) & 0x7f)
+
+/* Here is the union which was used to extract instruction fields
+ before the shift and mask macros were written.
+
+ union sparc_insn
+ {
+ unsigned long int code;
+ struct
+ {
+ unsigned int anop:2;
+ #define op ldst.anop
+ unsigned int anrd:5;
+ #define rd ldst.anrd
+ unsigned int op3:6;
+ unsigned int anrs1:5;
+ #define rs1 ldst.anrs1
+ unsigned int i:1;
+ unsigned int anasi:8;
+ #define asi ldst.anasi
+ unsigned int anrs2:5;
+ #define rs2 ldst.anrs2
+ #define shcnt rs2
+ } ldst;
+ struct
+ {
+ unsigned int anop:2, anrd:5, op3:6, anrs1:5, i:1;
+ unsigned int IMM13:13;
+ #define imm13 IMM13.IMM13
+ } IMM13;
+ struct
+ {
+ unsigned int anop:2;
+ unsigned int a:1;
+ unsigned int cond:4;
+ unsigned int op2:3;
+ unsigned int DISP22:22;
+ #define disp22 branch.DISP22
+ #define imm22 disp22
+ } branch;
+ struct
+ {
+ unsigned int anop:2;
+ unsigned int a:1;
+ unsigned int z:1;
+ unsigned int rcond:3;
+ unsigned int op2:3;
+ unsigned int DISP16HI:2;
+ unsigned int p:1;
+ unsigned int _rs1:5;
+ unsigned int DISP16LO:14;
+ } branch16;
+ struct
+ {
+ unsigned int anop:2;
+ unsigned int adisp30:30;
+ #define disp30 call.adisp30
+ } call;
+ };
+
+ */
+
+/* Nonzero if INSN is the opcode for a delayed branch. */
+static int
+is_delayed_branch (insn)
+ unsigned long insn;
+{
+ struct opcode_hash *op;
+
+ for (op = opcode_hash_table[HASH_INSN (insn)]; op; op = op->next)
+ {
+ CONST struct sparc_opcode *opcode = op->opcode;
+ if ((opcode->match & insn) == opcode->match
+ && (opcode->lose & insn) == 0)
+ return (opcode->flags & F_DELAYED);
+ }
+ return 0;
+}
+
+/* extern void qsort (); */
+
+/* Records current mask of SPARC_OPCODE_ARCH_FOO values, used to pass value
+ to compare_opcodes. */
+static unsigned int current_arch_mask;
+
+/* Print one instruction from MEMADDR on INFO->STREAM.
+
+ We suffix the instruction with a comment that gives the absolute
+ address involved, as well as its symbolic form, if the instruction
+ is preceded by a findable `sethi' and it either adds an immediate
+ displacement to that register, or it is an `add' or `or' instruction
+ on that register. */
+
+int
+print_insn_sparc (memaddr, info)
+ bfd_vma memaddr;
+ disassemble_info *info;
+{
+ FILE *stream = info->stream;
+ bfd_byte buffer[4];
+ unsigned long insn;
+ register struct opcode_hash *op;
+ /* Nonzero of opcode table has been initialized. */
+ static int opcodes_initialized = 0;
+ /* bfd mach number of last call. */
+ static unsigned long current_mach = 0;
+ bfd_vma (*getword) PARAMS ((const unsigned char *));
+
+ if (!opcodes_initialized
+ || info->mach != current_mach)
+ {
+ int i;
+
+ current_arch_mask = compute_arch_mask (info->mach);
+
+ if (!opcodes_initialized)
+ sorted_opcodes = (const struct sparc_opcode **)
+ xmalloc (sparc_num_opcodes * sizeof (struct sparc_opcode *));
+ /* Reset the sorted table so we can resort it. */
+ for (i = 0; i < sparc_num_opcodes; ++i)
+ sorted_opcodes[i] = &sparc_opcodes[i];
+ qsort ((char *) sorted_opcodes, sparc_num_opcodes,
+ sizeof (sorted_opcodes[0]), compare_opcodes);
+
+ build_hash_table (sorted_opcodes, opcode_hash_table, sparc_num_opcodes);
+ current_mach = info->mach;
+ opcodes_initialized = 1;
+ }
+
+ {
+ int status =
+ (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
+ }
+ }
+
+ /* On SPARClite variants such as DANlite (sparc86x), instructions
+ are always big-endian even when the machine is in little-endian mode. */
+ if (info->endian == BFD_ENDIAN_BIG || info->mach == bfd_mach_sparc_sparclite)
+ getword = bfd_getb32;
+ else
+ getword = bfd_getl32;
+
+ insn = getword (buffer);
+
+ info->insn_info_valid = 1; /* We do return this info */
+ info->insn_type = dis_nonbranch; /* Assume non branch insn */
+ info->branch_delay_insns = 0; /* Assume no delay */
+ info->target = 0; /* Assume no target known */
+
+ for (op = opcode_hash_table[HASH_INSN (insn)]; op; op = op->next)
+ {
+ CONST struct sparc_opcode *opcode = op->opcode;
+
+ /* If the insn isn't supported by the current architecture, skip it. */
+ if (! (opcode->architecture & current_arch_mask))
+ continue;
+
+ if ((opcode->match & insn) == opcode->match
+ && (opcode->lose & insn) == 0)
+ {
+ /* Nonzero means that we have found an instruction which has
+ the effect of adding or or'ing the imm13 field to rs1. */
+ int imm_added_to_rs1 = 0;
+
+ /* Nonzero means that we have found a plus sign in the args
+ field of the opcode table. */
+ int found_plus = 0;
+
+ /* Nonzero means we have an annulled branch. */
+ int is_annulled = 0;
+
+ /* Do we have an `add' or `or' instruction combining an
+ immediate with rs1? */
+ if (opcode->match == 0x80102000 || opcode->match == 0x80002000)
+ /* (or) (add) */
+ imm_added_to_rs1 = 1;
+
+ if (X_RS1 (insn) != X_RD (insn)
+ && strchr (opcode->args, 'r') != 0)
+ /* Can't do simple format if source and dest are different. */
+ continue;
+ if (X_RS2 (insn) != X_RD (insn)
+ && strchr (opcode->args, 'O') != 0)
+ /* Can't do simple format if source and dest are different. */
+ continue;
+
+ (*info->fprintf_func) (stream, opcode->name);
+
+ {
+ register CONST char *s;
+
+ if (opcode->args[0] != ',')
+ (*info->fprintf_func) (stream, " ");
+ for (s = opcode->args; *s != '\0'; ++s)
+ {
+ while (*s == ',')
+ {
+ (*info->fprintf_func) (stream, ",");
+ ++s;
+ switch (*s) {
+ case 'a':
+ (*info->fprintf_func) (stream, "a");
+ is_annulled = 1;
+ ++s;
+ continue;
+ case 'N':
+ (*info->fprintf_func) (stream, "pn");
+ ++s;
+ continue;
+
+ case 'T':
+ (*info->fprintf_func) (stream, "pt");
+ ++s;
+ continue;
+
+ default:
+ break;
+ } /* switch on arg */
+ } /* while there are comma started args */
+
+ (*info->fprintf_func) (stream, " ");
+
+ switch (*s)
+ {
+ case '+':
+ found_plus = 1;
+
+ /* note fall-through */
+ default:
+ (*info->fprintf_func) (stream, "%c", *s);
+ break;
+
+ case '#':
+ (*info->fprintf_func) (stream, "0");
+ break;
+
+#define reg(n) (*info->fprintf_func) (stream, "%%%s", reg_names[n])
+ case '1':
+ case 'r':
+ reg (X_RS1 (insn));
+ break;
+
+ case '2':
+ case 'O':
+ reg (X_RS2 (insn));
+ break;
+
+ case 'd':
+ reg (X_RD (insn));
+ break;
+#undef reg
+
+#define freg(n) (*info->fprintf_func) (stream, "%%%s", freg_names[n])
+#define fregx(n) (*info->fprintf_func) (stream, "%%%s", freg_names[((n) & ~1) | (((n) & 1) << 5)])
+ case 'e':
+ freg (X_RS1 (insn));
+ break;
+ case 'v': /* double/even */
+ case 'V': /* quad/multiple of 4 */
+ fregx (X_RS1 (insn));
+ break;
+
+ case 'f':
+ freg (X_RS2 (insn));
+ break;
+ case 'B': /* double/even */
+ case 'R': /* quad/multiple of 4 */
+ fregx (X_RS2 (insn));
+ break;
+
+ case 'g':
+ freg (X_RD (insn));
+ break;
+ case 'H': /* double/even */
+ case 'J': /* quad/multiple of 4 */
+ fregx (X_RD (insn));
+ break;
+#undef freg
+#undef fregx
+
+#define creg(n) (*info->fprintf_func) (stream, "%%c%u", (unsigned int) (n))
+ case 'b':
+ creg (X_RS1 (insn));
+ break;
+
+ case 'c':
+ creg (X_RS2 (insn));
+ break;
+
+ case 'D':
+ creg (X_RD (insn));
+ break;
+#undef creg
+
+ case 'h':
+ (*info->fprintf_func) (stream, "%%hi(%#x)",
+ (0xFFFFFFFF
+ & ((int) X_IMM22 (insn) << 10)));
+ break;
+
+ case 'i': /* 13 bit immediate */
+ case 'I': /* 11 bit immediate */
+ case 'j': /* 10 bit immediate */
+ {
+ int imm;
+
+ if (*s == 'i')
+ imm = X_SIMM (insn, 13);
+ else if (*s == 'I')
+ imm = X_SIMM (insn, 11);
+ else
+ imm = X_SIMM (insn, 10);
+
+ /* Check to see whether we have a 1+i, and take
+ note of that fact.
+
+ Note: because of the way we sort the table,
+ we will be matching 1+i rather than i+1,
+ so it is OK to assume that i is after +,
+ not before it. */
+ if (found_plus)
+ imm_added_to_rs1 = 1;
+
+ if (imm <= 9)
+ (*info->fprintf_func) (stream, "%d", imm);
+ else
+ (*info->fprintf_func) (stream, "%#x", imm);
+ }
+ break;
+
+ case 'X': /* 5 bit unsigned immediate */
+ case 'Y': /* 6 bit unsigned immediate */
+ {
+ int imm = X_IMM (insn, *s == 'X' ? 5 : 6);
+
+ if (imm <= 9)
+ (info->fprintf_func) (stream, "%d", imm);
+ else
+ (info->fprintf_func) (stream, "%#x", (unsigned) imm);
+ }
+ break;
+
+ case 'K':
+ {
+ int mask = X_MEMBAR (insn);
+ int bit = 0x40, printed_one = 0;
+ const char *name;
+
+ if (mask == 0)
+ (info->fprintf_func) (stream, "0");
+ else
+ while (bit)
+ {
+ if (mask & bit)
+ {
+ if (printed_one)
+ (info->fprintf_func) (stream, "|");
+ name = sparc_decode_membar (bit);
+ (info->fprintf_func) (stream, "%s", name);
+ printed_one = 1;
+ }
+ bit >>= 1;
+ }
+ break;
+ }
+
+ case 'k':
+ info->target = memaddr + SEX (X_DISP16 (insn), 16) * 4;
+ (*info->print_address_func) (info->target, info);
+ break;
+
+ case 'G':
+ info->target = memaddr + SEX (X_DISP19 (insn), 19) * 4;
+ (*info->print_address_func) (info->target, info);
+ break;
+
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ (*info->fprintf_func) (stream, "%%fcc%c", *s - '6' + '0');
+ break;
+
+ case 'z':
+ (*info->fprintf_func) (stream, "%%icc");
+ break;
+
+ case 'Z':
+ (*info->fprintf_func) (stream, "%%xcc");
+ break;
+
+ case 'E':
+ (*info->fprintf_func) (stream, "%%ccr");
+ break;
+
+ case 's':
+ (*info->fprintf_func) (stream, "%%fprs");
+ break;
+
+ case 'o':
+ (*info->fprintf_func) (stream, "%%asi");
+ break;
+
+ case 'W':
+ (*info->fprintf_func) (stream, "%%tick");
+ break;
+
+ case 'P':
+ (*info->fprintf_func) (stream, "%%pc");
+ break;
+
+ case '?':
+ if (X_RS1 (insn) == 31)
+ (*info->fprintf_func) (stream, "%%ver");
+ else if ((unsigned) X_RS1 (insn) < 16)
+ (*info->fprintf_func) (stream, "%%%s",
+ v9_priv_reg_names[X_RS1 (insn)]);
+ else
+ (*info->fprintf_func) (stream, "%%reserved");
+ break;
+
+ case '!':
+ if ((unsigned) X_RD (insn) < 15)
+ (*info->fprintf_func) (stream, "%%%s",
+ v9_priv_reg_names[X_RD (insn)]);
+ else
+ (*info->fprintf_func) (stream, "%%reserved");
+ break;
+
+ case '/':
+ if (X_RS1 (insn) < 16 || X_RS1 (insn) > 23)
+ (*info->fprintf_func) (stream, "%%reserved");
+ else
+ (*info->fprintf_func) (stream, "%%%s",
+ v9a_asr_reg_names[X_RS1 (insn)-16]);
+ break;
+
+ case '_':
+ if (X_RD (insn) < 16 || X_RD (insn) > 23)
+ (*info->fprintf_func) (stream, "%%reserved");
+ else
+ (*info->fprintf_func) (stream, "%%%s",
+ v9a_asr_reg_names[X_RD (insn)-16]);
+ break;
+
+ case '*':
+ {
+ const char *name = sparc_decode_prefetch (X_RD (insn));
+
+ if (name)
+ (*info->fprintf_func) (stream, "%s", name);
+ else
+ (*info->fprintf_func) (stream, "%d", X_RD (insn));
+ break;
+ }
+
+ case 'M':
+ (*info->fprintf_func) (stream, "%%asr%d", X_RS1 (insn));
+ break;
+
+ case 'm':
+ (*info->fprintf_func) (stream, "%%asr%d", X_RD (insn));
+ break;
+
+ case 'L':
+ info->target = memaddr + SEX (X_DISP30 (insn), 30) * 4;
+ (*info->print_address_func) (info->target, info);
+ break;
+
+ case 'n':
+ (*info->fprintf_func)
+ (stream, "%#x", SEX (X_DISP22 (insn), 22));
+ break;
+
+ case 'l':
+ info->target = memaddr + SEX (X_DISP22 (insn), 22) * 4;
+ (*info->print_address_func) (info->target, info);
+ break;
+
+ case 'A':
+ {
+ const char *name = sparc_decode_asi (X_ASI (insn));
+
+ if (name)
+ (*info->fprintf_func) (stream, "%s", name);
+ else
+ (*info->fprintf_func) (stream, "(%d)", X_ASI (insn));
+ break;
+ }
+
+ case 'C':
+ (*info->fprintf_func) (stream, "%%csr");
+ break;
+
+ case 'F':
+ (*info->fprintf_func) (stream, "%%fsr");
+ break;
+
+ case 'p':
+ (*info->fprintf_func) (stream, "%%psr");
+ break;
+
+ case 'q':
+ (*info->fprintf_func) (stream, "%%fq");
+ break;
+
+ case 'Q':
+ (*info->fprintf_func) (stream, "%%cq");
+ break;
+
+ case 't':
+ (*info->fprintf_func) (stream, "%%tbr");
+ break;
+
+ case 'w':
+ (*info->fprintf_func) (stream, "%%wim");
+ break;
+
+ case 'x':
+ (*info->fprintf_func) (stream, "%d",
+ ((X_LDST_I (insn) << 8)
+ + X_ASI (insn)));
+ break;
+
+ case 'y':
+ (*info->fprintf_func) (stream, "%%y");
+ break;
+
+ case 'u':
+ case 'U':
+ {
+ int val = *s == 'U' ? X_RS1 (insn) : X_RD (insn);
+ const char *name = sparc_decode_sparclet_cpreg (val);
+
+ if (name)
+ (*info->fprintf_func) (stream, "%s", name);
+ else
+ (*info->fprintf_func) (stream, "%%cpreg(%d)", val);
+ break;
+ }
+ }
+ }
+ }
+
+ /* If we are adding or or'ing something to rs1, then
+ check to see whether the previous instruction was
+ a sethi to the same register as in the sethi.
+ If so, attempt to print the result of the add or
+ or (in this context add and or do the same thing)
+ and its symbolic value. */
+ if (imm_added_to_rs1)
+ {
+ unsigned long prev_insn;
+ int errcode;
+
+ errcode =
+ (*info->read_memory_func)
+ (memaddr - 4, buffer, sizeof (buffer), info);
+ prev_insn = getword (buffer);
+
+ if (errcode == 0)
+ {
+ /* If it is a delayed branch, we need to look at the
+ instruction before the delayed branch. This handles
+ sequences such as
+
+ sethi %o1, %hi(_foo), %o1
+ call _printf
+ or %o1, %lo(_foo), %o1
+ */
+
+ if (is_delayed_branch (prev_insn))
+ {
+ errcode = (*info->read_memory_func)
+ (memaddr - 8, buffer, sizeof (buffer), info);
+ prev_insn = getword (buffer);
+ }
+ }
+
+ /* If there was a problem reading memory, then assume
+ the previous instruction was not sethi. */
+ if (errcode == 0)
+ {
+ /* Is it sethi to the same register? */
+ if ((prev_insn & 0xc1c00000) == 0x01000000
+ && X_RD (prev_insn) == X_RS1 (insn))
+ {
+ (*info->fprintf_func) (stream, "\t! ");
+ info->target =
+ (0xFFFFFFFF & (int) X_IMM22 (prev_insn) << 10)
+ | X_SIMM (insn, 13);
+ (*info->print_address_func) (info->target, info);
+ info->insn_type = dis_dref;
+ info->data_size = 4; /* FIXME!!! */
+ }
+ }
+ }
+
+ if (opcode->flags & (F_UNBR|F_CONDBR|F_JSR))
+ {
+ /* FIXME -- check is_annulled flag */
+ if (opcode->flags & F_UNBR)
+ info->insn_type = dis_branch;
+ if (opcode->flags & F_CONDBR)
+ info->insn_type = dis_condbranch;
+ if (opcode->flags & F_JSR)
+ info->insn_type = dis_jsr;
+ if (opcode->flags & F_DELAYED)
+ info->branch_delay_insns = 1;
+ }
+
+ return sizeof (buffer);
+ }
+ }
+
+ info->insn_type = dis_noninsn; /* Mark as non-valid instruction */
+ (*info->fprintf_func) (stream, _("unknown"));
+ return sizeof (buffer);
+}
+
+/* Given BFD mach number, return a mask of SPARC_OPCODE_ARCH_FOO values. */
+
+static int
+compute_arch_mask (mach)
+ unsigned long mach;
+{
+ switch (mach)
+ {
+ case 0 :
+ case bfd_mach_sparc :
+ return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8);
+ case bfd_mach_sparc_sparclet :
+ return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLET);
+ case bfd_mach_sparc_sparclite :
+ case bfd_mach_sparc_sparclite_le :
+ /* sparclites insns are recognized by default (because that's how
+ they've always been treated, for better or worse). Kludge this by
+ indicating generic v8 is also selected. */
+ return (SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLITE)
+ | SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8));
+ case bfd_mach_sparc_v8plus :
+ case bfd_mach_sparc_v9 :
+ return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9);
+ case bfd_mach_sparc_v8plusa :
+ case bfd_mach_sparc_v9a :
+ return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9A);
+ }
+ abort ();
+}
+
+/* Compare opcodes A and B. */
+
+static int
+compare_opcodes (a, b)
+ const PTR a;
+ const PTR b;
+{
+ struct sparc_opcode *op0 = * (struct sparc_opcode **) a;
+ struct sparc_opcode *op1 = * (struct sparc_opcode **) b;
+ unsigned long int match0 = op0->match, match1 = op1->match;
+ unsigned long int lose0 = op0->lose, lose1 = op1->lose;
+ register unsigned int i;
+
+ /* If one (and only one) insn isn't supported by the current architecture,
+ prefer the one that is. If neither are supported, but they're both for
+ the same architecture, continue processing. Otherwise (both unsupported
+ and for different architectures), prefer lower numbered arch's (fudged
+ by comparing the bitmasks). */
+ if (op0->architecture & current_arch_mask)
+ {
+ if (! (op1->architecture & current_arch_mask))
+ return -1;
+ }
+ else
+ {
+ if (op1->architecture & current_arch_mask)
+ return 1;
+ else if (op0->architecture != op1->architecture)
+ return op0->architecture - op1->architecture;
+ }
+
+ /* If a bit is set in both match and lose, there is something
+ wrong with the opcode table. */
+ if (match0 & lose0)
+ {
+ fprintf
+ (stderr,
+ /* xgettext:c-format */
+ _("Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"),
+ op0->name, match0, lose0);
+ op0->lose &= ~op0->match;
+ lose0 = op0->lose;
+ }
+
+ if (match1 & lose1)
+ {
+ fprintf
+ (stderr,
+ /* xgettext:c-format */
+ _("Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"),
+ op1->name, match1, lose1);
+ op1->lose &= ~op1->match;
+ lose1 = op1->lose;
+ }
+
+ /* Because the bits that are variable in one opcode are constant in
+ another, it is important to order the opcodes in the right order. */
+ for (i = 0; i < 32; ++i)
+ {
+ unsigned long int x = 1 << i;
+ int x0 = (match0 & x) != 0;
+ int x1 = (match1 & x) != 0;
+
+ if (x0 != x1)
+ return x1 - x0;
+ }
+
+ for (i = 0; i < 32; ++i)
+ {
+ unsigned long int x = 1 << i;
+ int x0 = (lose0 & x) != 0;
+ int x1 = (lose1 & x) != 0;
+
+ if (x0 != x1)
+ return x1 - x0;
+ }
+
+ /* They are functionally equal. So as long as the opcode table is
+ valid, we can put whichever one first we want, on aesthetic grounds. */
+
+ /* Our first aesthetic ground is that aliases defer to real insns. */
+ {
+ int alias_diff = (op0->flags & F_ALIAS) - (op1->flags & F_ALIAS);
+ if (alias_diff != 0)
+ /* Put the one that isn't an alias first. */
+ return alias_diff;
+ }
+
+ /* Except for aliases, two "identical" instructions had
+ better have the same opcode. This is a sanity check on the table. */
+ i = strcmp (op0->name, op1->name);
+ if (i)
+ {
+ if (op0->flags & F_ALIAS) /* If they're both aliases, be arbitrary. */
+ return i;
+ else
+ fprintf (stderr,
+ /* xgettext:c-format */
+ _("Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"),
+ op0->name, op1->name);
+ }
+
+ /* Fewer arguments are preferred. */
+ {
+ int length_diff = strlen (op0->args) - strlen (op1->args);
+ if (length_diff != 0)
+ /* Put the one with fewer arguments first. */
+ return length_diff;
+ }
+
+ /* Put 1+i before i+1. */
+ {
+ char *p0 = (char *) strchr (op0->args, '+');
+ char *p1 = (char *) strchr (op1->args, '+');
+
+ if (p0 && p1)
+ {
+ /* There is a plus in both operands. Note that a plus
+ sign cannot be the first character in args,
+ so the following [-1]'s are valid. */
+ if (p0[-1] == 'i' && p1[1] == 'i')
+ /* op0 is i+1 and op1 is 1+i, so op1 goes first. */
+ return 1;
+ if (p0[1] == 'i' && p1[-1] == 'i')
+ /* op0 is 1+i and op1 is i+1, so op0 goes first. */
+ return -1;
+ }
+ }
+
+ /* Put 1,i before i,1. */
+ {
+ int i0 = strncmp (op0->args, "i,1", 3) == 0;
+ int i1 = strncmp (op1->args, "i,1", 3) == 0;
+
+ if (i0 ^ i1)
+ return i0 - i1;
+ }
+
+ /* They are, as far as we can tell, identical.
+ Since qsort may have rearranged the table partially, there is
+ no way to tell which one was first in the opcode table as
+ written, so just say there are equal. */
+ /* ??? This is no longer true now that we sort a vector of pointers,
+ not the table itself. */
+ return 0;
+}
+
+/* Build a hash table from the opcode table.
+ OPCODE_TABLE is a sorted list of pointers into the opcode table. */
+
+static void
+build_hash_table (opcode_table, hash_table, num_opcodes)
+ const struct sparc_opcode **opcode_table;
+ struct opcode_hash **hash_table;
+ int num_opcodes;
+{
+ register int i;
+ int hash_count[HASH_SIZE];
+ static struct opcode_hash *hash_buf = NULL;
+
+ /* Start at the end of the table and work backwards so that each
+ chain is sorted. */
+
+ memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
+ memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
+ if (hash_buf != NULL)
+ free (hash_buf);
+ hash_buf = (struct opcode_hash *) xmalloc (sizeof (struct opcode_hash) * num_opcodes);
+ for (i = num_opcodes - 1; i >= 0; --i)
+ {
+ register int hash = HASH_INSN (opcode_table[i]->match);
+ register struct opcode_hash *h = &hash_buf[i];
+ h->next = hash_table[hash];
+ h->opcode = opcode_table[i];
+ hash_table[hash] = h;
+ ++hash_count[hash];
+ }
+
+#if 0 /* for debugging */
+ {
+ int min_count = num_opcodes, max_count = 0;
+ int total;
+
+ for (i = 0; i < HASH_SIZE; ++i)
+ {
+ if (hash_count[i] < min_count)
+ min_count = hash_count[i];
+ if (hash_count[i] > max_count)
+ max_count = hash_count[i];
+ total += hash_count[i];
+ }
+
+ printf ("Opcode hash table stats: min %d, max %d, ave %f\n",
+ min_count, max_count, (double) total / HASH_SIZE);
+ }
+#endif
+}
diff --git a/opcodes/sparc-opc.c b/opcodes/sparc-opc.c
new file mode 100644
index 00000000000..b50b39b4ba9
--- /dev/null
+++ b/opcodes/sparc-opc.c
@@ -0,0 +1,1920 @@
+/* Table of opcodes for the sparc.
+ Copyright (C) 1989, 91, 92, 93, 94, 95, 96, 97, 1998
+ Free Software Foundation, Inc.
+
+This file is part of the BFD library.
+
+BFD is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+BFD 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 software; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* FIXME-someday: perhaps the ,a's and such should be embedded in the
+ instruction's name rather than the args. This would make gas faster, pinsn
+ slower, but would mess up some macros a bit. xoxorich. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/sparc.h"
+
+/* Some defines to make life easy. */
+#define MASK_V6 SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V6)
+#define MASK_V7 SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V7)
+#define MASK_V8 SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8)
+#define MASK_SPARCLET SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLET)
+#define MASK_SPARCLITE SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLITE)
+#define MASK_V9 SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9)
+#define MASK_V9A SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9A)
+
+/* Bit masks of architectures supporting the insn. */
+
+#define v6 (MASK_V6 | MASK_V7 | MASK_V8 | MASK_SPARCLET \
+ | MASK_SPARCLITE | MASK_V9 | MASK_V9A)
+/* v6 insns not supported on the sparclet */
+#define v6notlet (MASK_V6 | MASK_V7 | MASK_V8 \
+ | MASK_SPARCLITE | MASK_V9 | MASK_V9A)
+#define v7 (MASK_V7 | MASK_V8 | MASK_SPARCLET \
+ | MASK_SPARCLITE | MASK_V9 | MASK_V9A)
+/* Although not all insns are implemented in hardware, sparclite is defined
+ to be a superset of v8. Unimplemented insns trap and are then theoretically
+ implemented in software.
+ It's not clear that the same is true for sparclet, although the docs
+ suggest it is. Rather than complicating things, the sparclet assembler
+ recognizes all v8 insns. */
+#define v8 (MASK_V8 | MASK_SPARCLET | MASK_SPARCLITE | MASK_V9 | MASK_V9A)
+#define sparclet (MASK_SPARCLET)
+#define sparclite (MASK_SPARCLITE)
+#define v9 (MASK_V9 | MASK_V9A)
+#define v9a (MASK_V9A)
+/* v6 insns not supported by v9 */
+#define v6notv9 (MASK_V6 | MASK_V7 | MASK_V8 \
+ | MASK_SPARCLET | MASK_SPARCLITE)
+/* v9a instructions which would appear to be aliases to v9's impdep's
+ otherwise */
+#define v9notv9a (MASK_V9)
+
+/* Table of opcode architectures.
+ The order is defined in opcode/sparc.h. */
+
+const struct sparc_opcode_arch sparc_opcode_archs[] = {
+ { "v6", MASK_V6 },
+ { "v7", MASK_V6 | MASK_V7 },
+ { "v8", MASK_V6 | MASK_V7 | MASK_V8 },
+ { "sparclet", MASK_V6 | MASK_V7 | MASK_V8 | MASK_SPARCLET },
+ { "sparclite", MASK_V6 | MASK_V7 | MASK_V8 | MASK_SPARCLITE },
+ /* ??? Don't some v8 priviledged insns conflict with v9? */
+ { "v9", MASK_V6 | MASK_V7 | MASK_V8 | MASK_V9 },
+ /* v9 with ultrasparc additions */
+ { "v9a", MASK_V6 | MASK_V7 | MASK_V8 | MASK_V9 | MASK_V9A },
+ { NULL, 0 }
+};
+
+/* Given NAME, return it's architecture entry. */
+
+enum sparc_opcode_arch_val
+sparc_opcode_lookup_arch (name)
+ const char *name;
+{
+ const struct sparc_opcode_arch *p;
+
+ for (p = &sparc_opcode_archs[0]; p->name; ++p)
+ {
+ if (strcmp (name, p->name) == 0)
+ return (enum sparc_opcode_arch_val) (p - &sparc_opcode_archs[0]);
+ }
+
+ return SPARC_OPCODE_ARCH_BAD;
+}
+
+/* Branch condition field. */
+#define COND(x) (((x)&0xf)<<25)
+
+/* v9: Move (MOVcc and FMOVcc) condition field. */
+#define MCOND(x,i_or_f) ((((i_or_f)&1)<<18)|(((x)>>11)&(0xf<<14))) /* v9 */
+
+/* v9: Move register (MOVRcc and FMOVRcc) condition field. */
+#define RCOND(x) (((x)&0x7)<<10) /* v9 */
+
+#define CONDA (COND(0x8))
+#define CONDCC (COND(0xd))
+#define CONDCS (COND(0x5))
+#define CONDE (COND(0x1))
+#define CONDG (COND(0xa))
+#define CONDGE (COND(0xb))
+#define CONDGU (COND(0xc))
+#define CONDL (COND(0x3))
+#define CONDLE (COND(0x2))
+#define CONDLEU (COND(0x4))
+#define CONDN (COND(0x0))
+#define CONDNE (COND(0x9))
+#define CONDNEG (COND(0x6))
+#define CONDPOS (COND(0xe))
+#define CONDVC (COND(0xf))
+#define CONDVS (COND(0x7))
+
+#define CONDNZ CONDNE
+#define CONDZ CONDE
+#define CONDGEU CONDCC
+#define CONDLU CONDCS
+
+#define FCONDA (COND(0x8))
+#define FCONDE (COND(0x9))
+#define FCONDG (COND(0x6))
+#define FCONDGE (COND(0xb))
+#define FCONDL (COND(0x4))
+#define FCONDLE (COND(0xd))
+#define FCONDLG (COND(0x2))
+#define FCONDN (COND(0x0))
+#define FCONDNE (COND(0x1))
+#define FCONDO (COND(0xf))
+#define FCONDU (COND(0x7))
+#define FCONDUE (COND(0xa))
+#define FCONDUG (COND(0x5))
+#define FCONDUGE (COND(0xc))
+#define FCONDUL (COND(0x3))
+#define FCONDULE (COND(0xe))
+
+#define FCONDNZ FCONDNE
+#define FCONDZ FCONDE
+
+#define ICC (0) /* v9 */
+#define XCC (1<<12) /* v9 */
+#define FCC(x) (((x)&0x3)<<11) /* v9 */
+#define FBFCC(x) (((x)&0x3)<<20) /* v9 */
+
+/* The order of the opcodes in the table is significant:
+
+ * The assembler requires that all instances of the same mnemonic must
+ be consecutive. If they aren't, the assembler will bomb at runtime.
+
+ * The disassembler should not care about the order of the opcodes.
+
+*/
+
+/* Entries for commutative arithmetic operations. */
+/* ??? More entries can make use of this. */
+#define COMMUTEOP(opcode, op3, arch_mask) \
+{ opcode, F3(2, op3, 0), F3(~2, ~op3, ~0)|ASI(~0), "1,2,d", 0, arch_mask }, \
+{ opcode, F3(2, op3, 1), F3(~2, ~op3, ~1), "1,i,d", 0, arch_mask }, \
+{ opcode, F3(2, op3, 1), F3(~2, ~op3, ~1), "i,1,d", 0, arch_mask }
+
+const struct sparc_opcode sparc_opcodes[] = {
+
+{ "ld", F3(3, 0x00, 0), F3(~3, ~0x00, ~0), "[1+2],d", 0, v6 },
+{ "ld", F3(3, 0x00, 0), F3(~3, ~0x00, ~0)|RS2_G0, "[1],d", 0, v6 }, /* ld [rs1+%g0],d */
+{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[1+i],d", 0, v6 },
+{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[i+1],d", 0, v6 },
+{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ld [rs1+0],d */
+{ "ld", F3(3, 0x20, 0), F3(~3, ~0x20, ~0), "[1+2],g", 0, v6 },
+{ "ld", F3(3, 0x20, 0), F3(~3, ~0x20, ~0)|RS2_G0, "[1],g", 0, v6 }, /* ld [rs1+%g0],d */
+{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[1+i],g", 0, v6 },
+{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[i+1],g", 0, v6 },
+{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|RS1_G0, "[i],g", 0, v6 },
+{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|SIMM13(~0), "[1],g", 0, v6 }, /* ld [rs1+0],d */
+
+{ "ld", F3(3, 0x21, 0), F3(~3, ~0x21, ~0)|RD(~0), "[1+2],F", 0, v6 },
+{ "ld", F3(3, 0x21, 0), F3(~3, ~0x21, ~0)|RS2_G0|RD(~0),"[1],F", 0, v6 }, /* ld [rs1+%g0],d */
+{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RD(~0), "[1+i],F", 0, v6 },
+{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RD(~0), "[i+1],F", 0, v6 },
+{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RS1_G0|RD(~0),"[i],F", 0, v6 },
+{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|SIMM13(~0)|RD(~0),"[1],F", 0, v6 }, /* ld [rs1+0],d */
+
+{ "ld", F3(3, 0x30, 0), F3(~3, ~0x30, ~0), "[1+2],D", 0, v6notv9 },
+{ "ld", F3(3, 0x30, 0), F3(~3, ~0x30, ~0)|RS2_G0, "[1],D", 0, v6notv9 }, /* ld [rs1+%g0],d */
+{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[1+i],D", 0, v6notv9 },
+{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[i+1],D", 0, v6notv9 },
+{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|RS1_G0, "[i],D", 0, v6notv9 },
+{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|SIMM13(~0), "[1],D", 0, v6notv9 }, /* ld [rs1+0],d */
+{ "ld", F3(3, 0x31, 0), F3(~3, ~0x31, ~0), "[1+2],C", 0, v6notv9 },
+{ "ld", F3(3, 0x31, 0), F3(~3, ~0x31, ~0)|RS2_G0, "[1],C", 0, v6notv9 }, /* ld [rs1+%g0],d */
+{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[1+i],C", 0, v6notv9 },
+{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[i+1],C", 0, v6notv9 },
+{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|RS1_G0, "[i],C", 0, v6notv9 },
+{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|SIMM13(~0), "[1],C", 0, v6notv9 }, /* ld [rs1+0],d */
+
+/* The v9 LDUW is the same as the old 'ld' opcode, it is not the same as the
+ 'ld' pseudo-op in v9. */
+{ "lduw", F3(3, 0x00, 0), F3(~3, ~0x00, ~0), "[1+2],d", F_ALIAS, v9 },
+{ "lduw", F3(3, 0x00, 0), F3(~3, ~0x00, ~0)|RS2_G0, "[1],d", F_ALIAS, v9 }, /* ld [rs1+%g0],d */
+{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[1+i],d", F_ALIAS, v9 },
+{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[i+1],d", F_ALIAS, v9 },
+{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|RS1_G0, "[i],d", F_ALIAS, v9 },
+{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|SIMM13(~0), "[1],d", F_ALIAS, v9 }, /* ld [rs1+0],d */
+
+{ "ldd", F3(3, 0x03, 0), F3(~3, ~0x03, ~0)|ASI(~0), "[1+2],d", 0, v6 },
+{ "ldd", F3(3, 0x03, 0), F3(~3, ~0x03, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldd [rs1+%g0],d */
+{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1), "[1+i],d", 0, v6 },
+{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1), "[i+1],d", 0, v6 },
+{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldd [rs1+0],d */
+{ "ldd", F3(3, 0x23, 0), F3(~3, ~0x23, ~0)|ASI(~0), "[1+2],H", 0, v6 },
+{ "ldd", F3(3, 0x23, 0), F3(~3, ~0x23, ~0)|ASI_RS2(~0), "[1],H", 0, v6 }, /* ldd [rs1+%g0],d */
+{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1), "[1+i],H", 0, v6 },
+{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1), "[i+1],H", 0, v6 },
+{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1)|RS1_G0, "[i],H", 0, v6 },
+{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1)|SIMM13(~0), "[1],H", 0, v6 }, /* ldd [rs1+0],d */
+
+{ "ldd", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|ASI(~0), "[1+2],D", 0, v6notv9 },
+{ "ldd", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|ASI_RS2(~0), "[1],D", 0, v6notv9 }, /* ldd [rs1+%g0],d */
+{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[1+i],D", 0, v6notv9 },
+{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[i+1],D", 0, v6notv9 },
+{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|RS1_G0, "[i],D", 0, v6notv9 },
+{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|SIMM13(~0), "[1],D", 0, v6notv9 }, /* ldd [rs1+0],d */
+
+{ "ldq", F3(3, 0x22, 0), F3(~3, ~0x22, ~0)|ASI(~0), "[1+2],J", 0, v9 },
+{ "ldq", F3(3, 0x22, 0), F3(~3, ~0x22, ~0)|ASI_RS2(~0), "[1],J", 0, v9 }, /* ldd [rs1+%g0],d */
+{ "ldq", F3(3, 0x22, 1), F3(~3, ~0x22, ~1), "[1+i],J", 0, v9 },
+{ "ldq", F3(3, 0x22, 1), F3(~3, ~0x22, ~1), "[i+1],J", 0, v9 },
+{ "ldq", F3(3, 0x22, 1), F3(~3, ~0x22, ~1)|RS1_G0, "[i],J", 0, v9 },
+{ "ldq", F3(3, 0x22, 1), F3(~3, ~0x22, ~1)|SIMM13(~0), "[1],J", 0, v9 }, /* ldd [rs1+0],d */
+
+{ "ldsb", F3(3, 0x09, 0), F3(~3, ~0x09, ~0)|ASI(~0), "[1+2],d", 0, v6 },
+{ "ldsb", F3(3, 0x09, 0), F3(~3, ~0x09, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldsb [rs1+%g0],d */
+{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1), "[1+i],d", 0, v6 },
+{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1), "[i+1],d", 0, v6 },
+{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldsb [rs1+0],d */
+
+{ "ldsh", F3(3, 0x0a, 0), F3(~3, ~0x0a, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldsh [rs1+%g0],d */
+{ "ldsh", F3(3, 0x0a, 0), F3(~3, ~0x0a, ~0)|ASI(~0), "[1+2],d", 0, v6 },
+{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1), "[1+i],d", 0, v6 },
+{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1), "[i+1],d", 0, v6 },
+{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldsh [rs1+0],d */
+
+{ "ldstub", F3(3, 0x0d, 0), F3(~3, ~0x0d, ~0)|ASI(~0), "[1+2],d", 0, v6 },
+{ "ldstub", F3(3, 0x0d, 0), F3(~3, ~0x0d, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldstub [rs1+%g0],d */
+{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1), "[1+i],d", 0, v6 },
+{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1), "[i+1],d", 0, v6 },
+{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldstub [rs1+0],d */
+
+{ "ldsw", F3(3, 0x08, 0), F3(~3, ~0x08, ~0)|ASI(~0), "[1+2],d", 0, v9 },
+{ "ldsw", F3(3, 0x08, 0), F3(~3, ~0x08, ~0)|ASI_RS2(~0), "[1],d", 0, v9 }, /* ldsw [rs1+%g0],d */
+{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1), "[1+i],d", 0, v9 },
+{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1), "[i+1],d", 0, v9 },
+{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1)|RS1_G0, "[i],d", 0, v9 },
+{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1)|SIMM13(~0), "[1],d", 0, v9 }, /* ldsw [rs1+0],d */
+
+{ "ldub", F3(3, 0x01, 0), F3(~3, ~0x01, ~0)|ASI(~0), "[1+2],d", 0, v6 },
+{ "ldub", F3(3, 0x01, 0), F3(~3, ~0x01, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldub [rs1+%g0],d */
+{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1), "[1+i],d", 0, v6 },
+{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1), "[i+1],d", 0, v6 },
+{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldub [rs1+0],d */
+
+{ "lduh", F3(3, 0x02, 0), F3(~3, ~0x02, ~0)|ASI(~0), "[1+2],d", 0, v6 },
+{ "lduh", F3(3, 0x02, 0), F3(~3, ~0x02, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* lduh [rs1+%g0],d */
+{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1), "[1+i],d", 0, v6 },
+{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1), "[i+1],d", 0, v6 },
+{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1)|RS1_G0, "[i],d", 0, v6 },
+{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* lduh [rs1+0],d */
+
+{ "ldx", F3(3, 0x0b, 0), F3(~3, ~0x0b, ~0)|ASI(~0), "[1+2],d", 0, v9 },
+{ "ldx", F3(3, 0x0b, 0), F3(~3, ~0x0b, ~0)|ASI_RS2(~0), "[1],d", 0, v9 }, /* ldx [rs1+%g0],d */
+{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1), "[1+i],d", 0, v9 },
+{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1), "[i+1],d", 0, v9 },
+{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1)|RS1_G0, "[i],d", 0, v9 },
+{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1)|SIMM13(~0), "[1],d", 0, v9 }, /* ldx [rs1+0],d */
+
+{ "ldx", F3(3, 0x21, 0)|RD(1), F3(~3, ~0x21, ~0)|RD(~1), "[1+2],F", 0, v9 },
+{ "ldx", F3(3, 0x21, 0)|RD(1), F3(~3, ~0x21, ~0)|RS2_G0|RD(~1), "[1],F", 0, v9 }, /* ld [rs1+%g0],d */
+{ "ldx", F3(3, 0x21, 1)|RD(1), F3(~3, ~0x21, ~1)|RD(~1), "[1+i],F", 0, v9 },
+{ "ldx", F3(3, 0x21, 1)|RD(1), F3(~3, ~0x21, ~1)|RD(~1), "[i+1],F", 0, v9 },
+{ "ldx", F3(3, 0x21, 1)|RD(1), F3(~3, ~0x21, ~1)|RS1_G0|RD(~1), "[i],F", 0, v9 },
+{ "ldx", F3(3, 0x21, 1)|RD(1), F3(~3, ~0x21, ~1)|SIMM13(~0)|RD(~1),"[1],F", 0, v9 }, /* ld [rs1+0],d */
+
+{ "lda", F3(3, 0x10, 0), F3(~3, ~0x10, ~0), "[1+2]A,d", 0, v6 },
+{ "lda", F3(3, 0x10, 0), F3(~3, ~0x10, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lda [rs1+%g0],d */
+{ "lda", F3(3, 0x10, 1), F3(~3, ~0x10, ~1), "[1+i]o,d", 0, v9 },
+{ "lda", F3(3, 0x10, 1), F3(~3, ~0x10, ~1), "[i+1]o,d", 0, v9 },
+{ "lda", F3(3, 0x10, 1), F3(~3, ~0x10, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "lda", F3(3, 0x10, 1), F3(~3, ~0x10, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+{ "lda", F3(3, 0x30, 0), F3(~3, ~0x30, ~0), "[1+2]A,g", 0, v9 },
+{ "lda", F3(3, 0x30, 0), F3(~3, ~0x30, ~0)|RS2_G0, "[1]A,g", 0, v9 }, /* lda [rs1+%g0],d */
+{ "lda", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[1+i]o,g", 0, v9 },
+{ "lda", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[i+1]o,g", 0, v9 },
+{ "lda", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|RS1_G0, "[i]o,g", 0, v9 },
+{ "lda", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|SIMM13(~0), "[1]o,g", 0, v9 }, /* ld [rs1+0],d */
+
+{ "ldda", F3(3, 0x13, 0), F3(~3, ~0x13, ~0), "[1+2]A,d", 0, v6 },
+{ "ldda", F3(3, 0x13, 0), F3(~3, ~0x13, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldda [rs1+%g0],d */
+{ "ldda", F3(3, 0x13, 1), F3(~3, ~0x13, ~1), "[1+i]o,d", 0, v9 },
+{ "ldda", F3(3, 0x13, 1), F3(~3, ~0x13, ~1), "[i+1]o,d", 0, v9 },
+{ "ldda", F3(3, 0x13, 1), F3(~3, ~0x13, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "ldda", F3(3, 0x13, 1), F3(~3, ~0x13, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "ldda", F3(3, 0x33, 0), F3(~3, ~0x33, ~0), "[1+2]A,H", 0, v9 },
+{ "ldda", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|RS2_G0, "[1]A,H", 0, v9 }, /* ldda [rs1+%g0],d */
+{ "ldda", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[1+i]o,H", 0, v9 },
+{ "ldda", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[i+1]o,H", 0, v9 },
+{ "ldda", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|RS1_G0, "[i]o,H", 0, v9 },
+{ "ldda", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|SIMM13(~0), "[1]o,H", 0, v9 }, /* ld [rs1+0],d */
+
+{ "ldqa", F3(3, 0x32, 0), F3(~3, ~0x32, ~0), "[1+2]A,J", 0, v9 },
+{ "ldqa", F3(3, 0x32, 0), F3(~3, ~0x32, ~0)|RS2_G0, "[1]A,J", 0, v9 }, /* ldd [rs1+%g0],d */
+{ "ldqa", F3(3, 0x32, 1), F3(~3, ~0x32, ~1), "[1+i]o,J", 0, v9 },
+{ "ldqa", F3(3, 0x32, 1), F3(~3, ~0x32, ~1), "[i+1]o,J", 0, v9 },
+{ "ldqa", F3(3, 0x32, 1), F3(~3, ~0x32, ~1)|RS1_G0, "[i]o,J", 0, v9 },
+{ "ldqa", F3(3, 0x32, 1), F3(~3, ~0x32, ~1)|SIMM13(~0), "[1]o,J", 0, v9 }, /* ldd [rs1+0],d */
+
+{ "ldsba", F3(3, 0x19, 0), F3(~3, ~0x19, ~0), "[1+2]A,d", 0, v6 },
+{ "ldsba", F3(3, 0x19, 0), F3(~3, ~0x19, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldsba [rs1+%g0],d */
+{ "ldsba", F3(3, 0x19, 1), F3(~3, ~0x19, ~1), "[1+i]o,d", 0, v9 },
+{ "ldsba", F3(3, 0x19, 1), F3(~3, ~0x19, ~1), "[i+1]o,d", 0, v9 },
+{ "ldsba", F3(3, 0x19, 1), F3(~3, ~0x19, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "ldsba", F3(3, 0x19, 1), F3(~3, ~0x19, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "ldsha", F3(3, 0x1a, 0), F3(~3, ~0x1a, ~0), "[1+2]A,d", 0, v6 },
+{ "ldsha", F3(3, 0x1a, 0), F3(~3, ~0x1a, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldsha [rs1+%g0],d */
+{ "ldsha", F3(3, 0x1a, 1), F3(~3, ~0x1a, ~1), "[1+i]o,d", 0, v9 },
+{ "ldsha", F3(3, 0x1a, 1), F3(~3, ~0x1a, ~1), "[i+1]o,d", 0, v9 },
+{ "ldsha", F3(3, 0x1a, 1), F3(~3, ~0x1a, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "ldsha", F3(3, 0x1a, 1), F3(~3, ~0x1a, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "ldstuba", F3(3, 0x1d, 0), F3(~3, ~0x1d, ~0), "[1+2]A,d", 0, v6 },
+{ "ldstuba", F3(3, 0x1d, 0), F3(~3, ~0x1d, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldstuba [rs1+%g0],d */
+{ "ldstuba", F3(3, 0x1d, 1), F3(~3, ~0x1d, ~1), "[1+i]o,d", 0, v9 },
+{ "ldstuba", F3(3, 0x1d, 1), F3(~3, ~0x1d, ~1), "[i+1]o,d", 0, v9 },
+{ "ldstuba", F3(3, 0x1d, 1), F3(~3, ~0x1d, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "ldstuba", F3(3, 0x1d, 1), F3(~3, ~0x1d, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "ldswa", F3(3, 0x18, 0), F3(~3, ~0x18, ~0), "[1+2]A,d", 0, v9 },
+{ "ldswa", F3(3, 0x18, 0), F3(~3, ~0x18, ~0)|RS2_G0, "[1]A,d", 0, v9 }, /* lda [rs1+%g0],d */
+{ "ldswa", F3(3, 0x18, 1), F3(~3, ~0x18, ~1), "[1+i]o,d", 0, v9 },
+{ "ldswa", F3(3, 0x18, 1), F3(~3, ~0x18, ~1), "[i+1]o,d", 0, v9 },
+{ "ldswa", F3(3, 0x18, 1), F3(~3, ~0x18, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "ldswa", F3(3, 0x18, 1), F3(~3, ~0x18, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "lduba", F3(3, 0x11, 0), F3(~3, ~0x11, ~0), "[1+2]A,d", 0, v6 },
+{ "lduba", F3(3, 0x11, 0), F3(~3, ~0x11, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lduba [rs1+%g0],d */
+{ "lduba", F3(3, 0x11, 1), F3(~3, ~0x11, ~1), "[1+i]o,d", 0, v9 },
+{ "lduba", F3(3, 0x11, 1), F3(~3, ~0x11, ~1), "[i+1]o,d", 0, v9 },
+{ "lduba", F3(3, 0x11, 1), F3(~3, ~0x11, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "lduba", F3(3, 0x11, 1), F3(~3, ~0x11, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "lduha", F3(3, 0x12, 0), F3(~3, ~0x12, ~0), "[1+2]A,d", 0, v6 },
+{ "lduha", F3(3, 0x12, 0), F3(~3, ~0x12, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lduha [rs1+%g0],d */
+{ "lduha", F3(3, 0x12, 1), F3(~3, ~0x12, ~1), "[1+i]o,d", 0, v9 },
+{ "lduha", F3(3, 0x12, 1), F3(~3, ~0x12, ~1), "[i+1]o,d", 0, v9 },
+{ "lduha", F3(3, 0x12, 1), F3(~3, ~0x12, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "lduha", F3(3, 0x12, 1), F3(~3, ~0x12, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "lduwa", F3(3, 0x10, 0), F3(~3, ~0x10, ~0), "[1+2]A,d", F_ALIAS, v9 }, /* lduwa === lda */
+{ "lduwa", F3(3, 0x10, 0), F3(~3, ~0x10, ~0)|RS2_G0, "[1]A,d", F_ALIAS, v9 }, /* lda [rs1+%g0],d */
+{ "lduwa", F3(3, 0x10, 1), F3(~3, ~0x10, ~1), "[1+i]o,d", F_ALIAS, v9 },
+{ "lduwa", F3(3, 0x10, 1), F3(~3, ~0x10, ~1), "[i+1]o,d", F_ALIAS, v9 },
+{ "lduwa", F3(3, 0x10, 1), F3(~3, ~0x10, ~1)|RS1_G0, "[i]o,d", F_ALIAS, v9 },
+{ "lduwa", F3(3, 0x10, 1), F3(~3, ~0x10, ~1)|SIMM13(~0), "[1]o,d", F_ALIAS, v9 }, /* ld [rs1+0],d */
+
+{ "ldxa", F3(3, 0x1b, 0), F3(~3, ~0x1b, ~0), "[1+2]A,d", 0, v9 }, /* lduwa === lda */
+{ "ldxa", F3(3, 0x1b, 0), F3(~3, ~0x1b, ~0)|RS2_G0, "[1]A,d", 0, v9 }, /* lda [rs1+%g0],d */
+{ "ldxa", F3(3, 0x1b, 1), F3(~3, ~0x1b, ~1), "[1+i]o,d", 0, v9 },
+{ "ldxa", F3(3, 0x1b, 1), F3(~3, ~0x1b, ~1), "[i+1]o,d", 0, v9 },
+{ "ldxa", F3(3, 0x1b, 1), F3(~3, ~0x1b, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "ldxa", F3(3, 0x1b, 1), F3(~3, ~0x1b, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* ld [rs1+0],d */
+
+{ "st", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
+{ "st", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* st d,[rs1+%g0] */
+{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", 0, v6 },
+{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", 0, v6 },
+{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", 0, v6 },
+{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* st d,[rs1+0] */
+{ "st", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI(~0), "g,[1+2]", 0, v6 },
+{ "st", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI_RS2(~0), "g,[1]", 0, v6 }, /* st d[rs1+%g0] */
+{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[1+i]", 0, v6 },
+{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[i+1]", 0, v6 },
+{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|RS1_G0, "g,[i]", 0, v6 },
+{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|SIMM13(~0), "g,[1]", 0, v6 }, /* st d,[rs1+0] */
+
+{ "st", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI(~0), "D,[1+2]", 0, v6notv9 },
+{ "st", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI_RS2(~0), "D,[1]", 0, v6notv9 }, /* st d,[rs1+%g0] */
+{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[1+i]", 0, v6notv9 },
+{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[i+1]", 0, v6notv9 },
+{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "D,[i]", 0, v6notv9 },
+{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "D,[1]", 0, v6notv9 }, /* st d,[rs1+0] */
+{ "st", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI(~0), "C,[1+2]", 0, v6notv9 },
+{ "st", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI_RS2(~0), "C,[1]", 0, v6notv9 }, /* st d,[rs1+%g0] */
+{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[1+i]", 0, v6notv9 },
+{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[i+1]", 0, v6notv9 },
+{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|RS1_G0, "C,[i]", 0, v6notv9 },
+{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|SIMM13(~0), "C,[1]", 0, v6notv9 }, /* st d,[rs1+0] */
+
+{ "st", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI(~0), "F,[1+2]", 0, v6 },
+{ "st", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", 0, v6 }, /* st d,[rs1+%g0] */
+{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[1+i]", 0, v6 },
+{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[i+1]", 0, v6 },
+{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|RS1_G0, "F,[i]", 0, v6 },
+{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|SIMM13(~0), "F,[1]", 0, v6 }, /* st d,[rs1+0] */
+
+{ "stw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 },
+{ "stw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */
+{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", F_ALIAS, v9 },
+{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", F_ALIAS, v9 },
+{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 },
+{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */
+
+{ "sta", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", 0, v6 },
+{ "sta", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* sta d,[rs1+%g0] */
+{ "sta", F3(3, 0x14, 1), F3(~3, ~0x14, ~1), "d,[1+i]o", 0, v9 },
+{ "sta", F3(3, 0x14, 1), F3(~3, ~0x14, ~1), "d,[i+1]o", 0, v9 },
+{ "sta", F3(3, 0x14, 1), F3(~3, ~0x14, ~1)|RS1_G0, "d,[i]o", 0, v9 },
+{ "sta", F3(3, 0x14, 1), F3(~3, ~0x14, ~1)|SIMM13(~0), "d,[1]o", 0, v9 }, /* st d,[rs1+0] */
+
+{ "sta", F3(3, 0x34, 0), F3(~3, ~0x34, ~0), "g,[1+2]A", 0, v9 },
+{ "sta", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|RS2(~0), "g,[1]A", 0, v9 }, /* sta d,[rs1+%g0] */
+{ "sta", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "g,[1+i]o", 0, v9 },
+{ "sta", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "g,[i+1]o", 0, v9 },
+{ "sta", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "g,[i]o", 0, v9 },
+{ "sta", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "g,[1]o", 0, v9 }, /* st d,[rs1+0] */
+
+{ "stwa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", F_ALIAS, v9 },
+{ "stwa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* sta d,[rs1+%g0] */
+{ "stwa", F3(3, 0x14, 1), F3(~3, ~0x14, ~1), "d,[1+i]o", F_ALIAS, v9 },
+{ "stwa", F3(3, 0x14, 1), F3(~3, ~0x14, ~1), "d,[i+1]o", F_ALIAS, v9 },
+{ "stwa", F3(3, 0x14, 1), F3(~3, ~0x14, ~1)|RS1_G0, "d,[i]o", F_ALIAS, v9 },
+{ "stwa", F3(3, 0x14, 1), F3(~3, ~0x14, ~1)|SIMM13(~0), "d,[1]o", F_ALIAS, v9 }, /* st d,[rs1+0] */
+
+{ "stb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
+{ "stb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* stb d,[rs1+%g0] */
+{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[1+i]", 0, v6 },
+{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[i+1]", 0, v6 },
+{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RS1_G0, "d,[i]", 0, v6 },
+{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* stb d,[rs1+0] */
+
+{ "stba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0), "d,[1+2]A", 0, v6 },
+{ "stba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stba d,[rs1+%g0] */
+{ "stba", F3(3, 0x15, 1), F3(~3, ~0x15, ~1), "d,[1+i]o", 0, v9 },
+{ "stba", F3(3, 0x15, 1), F3(~3, ~0x15, ~1), "d,[i+1]o", 0, v9 },
+{ "stba", F3(3, 0x15, 1), F3(~3, ~0x15, ~1)|RS1_G0, "d,[i]o", 0, v9 },
+{ "stba", F3(3, 0x15, 1), F3(~3, ~0x15, ~1)|SIMM13(~0), "d,[1]o", 0, v9 }, /* stb d,[rs1+0] */
+
+{ "std", F3(3, 0x07, 0), F3(~3, ~0x07, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
+{ "std", F3(3, 0x07, 0), F3(~3, ~0x07, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* std d,[rs1+%g0] */
+{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1), "d,[1+i]", 0, v6 },
+{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1), "d,[i+1]", 0, v6 },
+{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1)|RS1_G0, "d,[i]", 0, v6 },
+{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* std d,[rs1+0] */
+
+{ "std", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI(~0), "q,[1+2]", 0, v6notv9 },
+{ "std", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI_RS2(~0), "q,[1]", 0, v6notv9 }, /* std d,[rs1+%g0] */
+{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "q,[1+i]", 0, v6notv9 },
+{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "q,[i+1]", 0, v6notv9 },
+{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|RS1_G0, "q,[i]", 0, v6notv9 },
+{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|SIMM13(~0), "q,[1]", 0, v6notv9 }, /* std d,[rs1+0] */
+{ "std", F3(3, 0x27, 0), F3(~3, ~0x27, ~0)|ASI(~0), "H,[1+2]", 0, v6 },
+{ "std", F3(3, 0x27, 0), F3(~3, ~0x27, ~0)|ASI_RS2(~0), "H,[1]", 0, v6 }, /* std d,[rs1+%g0] */
+{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1), "H,[1+i]", 0, v6 },
+{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1), "H,[i+1]", 0, v6 },
+{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1)|RS1_G0, "H,[i]", 0, v6 },
+{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1)|SIMM13(~0), "H,[1]", 0, v6 }, /* std d,[rs1+0] */
+
+{ "std", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI(~0), "Q,[1+2]", 0, v6notv9 },
+{ "std", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI_RS2(~0), "Q,[1]", 0, v6notv9 }, /* std d,[rs1+%g0] */
+{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "Q,[1+i]", 0, v6notv9 },
+{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "Q,[i+1]", 0, v6notv9 },
+{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|RS1_G0, "Q,[i]", 0, v6notv9 },
+{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|SIMM13(~0), "Q,[1]", 0, v6notv9 }, /* std d,[rs1+0] */
+{ "std", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|ASI(~0), "D,[1+2]", 0, v6notv9 },
+{ "std", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|ASI_RS2(~0), "D,[1]", 0, v6notv9 }, /* std d,[rs1+%g0] */
+{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "D,[1+i]", 0, v6notv9 },
+{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "D,[i+1]", 0, v6notv9 },
+{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|RS1_G0, "D,[i]", 0, v6notv9 },
+{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|SIMM13(~0), "D,[1]", 0, v6notv9 }, /* std d,[rs1+0] */
+
+{ "stda", F3(3, 0x17, 0), F3(~3, ~0x17, ~0), "d,[1+2]A", 0, v6 },
+{ "stda", F3(3, 0x17, 0), F3(~3, ~0x17, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stda d,[rs1+%g0] */
+{ "stda", F3(3, 0x17, 1), F3(~3, ~0x17, ~1), "d,[1+i]o", 0, v9 },
+{ "stda", F3(3, 0x17, 1), F3(~3, ~0x17, ~1), "d,[i+1]o", 0, v9 },
+{ "stda", F3(3, 0x17, 1), F3(~3, ~0x17, ~1)|RS1_G0, "d,[i]o", 0, v9 },
+{ "stda", F3(3, 0x17, 1), F3(~3, ~0x17, ~1)|SIMM13(~0), "d,[1]o", 0, v9 }, /* std d,[rs1+0] */
+{ "stda", F3(3, 0x37, 0), F3(~3, ~0x37, ~0), "H,[1+2]A", 0, v9 },
+{ "stda", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|RS2(~0), "H,[1]A", 0, v9 }, /* stda d,[rs1+%g0] */
+{ "stda", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "H,[1+i]o", 0, v9 },
+{ "stda", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "H,[i+1]o", 0, v9 },
+{ "stda", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|RS1_G0, "H,[i]o", 0, v9 },
+{ "stda", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|SIMM13(~0), "H,[1]o", 0, v9 }, /* std d,[rs1+0] */
+
+{ "sth", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
+{ "sth", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* sth d,[rs1+%g0] */
+{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[1+i]", 0, v6 },
+{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[i+1]", 0, v6 },
+{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RS1_G0, "d,[i]", 0, v6 },
+{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* sth d,[rs1+0] */
+
+{ "stha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0), "d,[1+2]A", 0, v6 },
+{ "stha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stha ,[rs1+%g0] */
+{ "stha", F3(3, 0x16, 1), F3(~3, ~0x16, ~1), "d,[1+i]o", 0, v9 },
+{ "stha", F3(3, 0x16, 1), F3(~3, ~0x16, ~1), "d,[i+1]o", 0, v9 },
+{ "stha", F3(3, 0x16, 1), F3(~3, ~0x16, ~1)|RS1_G0, "d,[i]o", 0, v9 },
+{ "stha", F3(3, 0x16, 1), F3(~3, ~0x16, ~1)|SIMM13(~0), "d,[1]o", 0, v9 }, /* sth d,[rs1+0] */
+
+{ "stx", F3(3, 0x0e, 0), F3(~3, ~0x0e, ~0)|ASI(~0), "d,[1+2]", 0, v9 },
+{ "stx", F3(3, 0x0e, 0), F3(~3, ~0x0e, ~0)|ASI_RS2(~0), "d,[1]", 0, v9 }, /* stx d,[rs1+%g0] */
+{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1), "d,[1+i]", 0, v9 },
+{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1), "d,[i+1]", 0, v9 },
+{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|RS1_G0, "d,[i]", 0, v9 },
+{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|SIMM13(~0), "d,[1]", 0, v9 }, /* stx d,[rs1+0] */
+
+{ "stx", F3(3, 0x25, 0)|RD(1), F3(~3, ~0x25, ~0)|ASI(~0)|RD(~1), "F,[1+2]", 0, v9 },
+{ "stx", F3(3, 0x25, 0)|RD(1), F3(~3, ~0x25, ~0)|ASI_RS2(~0)|RD(~1),"F,[1]", 0, v9 }, /* stx d,[rs1+%g0] */
+{ "stx", F3(3, 0x25, 1)|RD(1), F3(~3, ~0x25, ~1)|RD(~1), "F,[1+i]", 0, v9 },
+{ "stx", F3(3, 0x25, 1)|RD(1), F3(~3, ~0x25, ~1)|RD(~1), "F,[i+1]", 0, v9 },
+{ "stx", F3(3, 0x25, 1)|RD(1), F3(~3, ~0x25, ~1)|RS1_G0|RD(~1), "F,[i]", 0, v9 },
+{ "stx", F3(3, 0x25, 1)|RD(1), F3(~3, ~0x25, ~1)|SIMM13(~0)|RD(~1),"F,[1]", 0, v9 }, /* stx d,[rs1+0] */
+
+{ "stxa", F3(3, 0x1e, 0), F3(~3, ~0x1e, ~0), "d,[1+2]A", 0, v9 },
+{ "stxa", F3(3, 0x1e, 0), F3(~3, ~0x1e, ~0)|RS2(~0), "d,[1]A", 0, v9 }, /* stxa d,[rs1+%g0] */
+{ "stxa", F3(3, 0x1e, 1), F3(~3, ~0x1e, ~1), "d,[1+i]o", 0, v9 },
+{ "stxa", F3(3, 0x1e, 1), F3(~3, ~0x1e, ~1), "d,[i+1]o", 0, v9 },
+{ "stxa", F3(3, 0x1e, 1), F3(~3, ~0x1e, ~1)|RS1_G0, "d,[i]o", 0, v9 },
+{ "stxa", F3(3, 0x1e, 1), F3(~3, ~0x1e, ~1)|SIMM13(~0), "d,[1]o", 0, v9 }, /* stx d,[rs1+0] */
+
+{ "stq", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI(~0), "J,[1+2]", 0, v9 },
+{ "stq", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI_RS2(~0), "J,[1]", 0, v9 }, /* stq [rs1+%g0] */
+{ "stq", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "J,[1+i]", 0, v9 },
+{ "stq", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "J,[i+1]", 0, v9 },
+{ "stq", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|RS1_G0, "J,[i]", 0, v9 },
+{ "stq", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|SIMM13(~0), "J,[1]", 0, v9 }, /* stq [rs1+0] */
+
+{ "stqa", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI(~0), "J,[1+2]A", 0, v9 },
+{ "stqa", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI_RS2(~0), "J,[1]A", 0, v9 }, /* stqa [rs1+%g0] */
+{ "stqa", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "J,[1+i]o", 0, v9 },
+{ "stqa", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "J,[i+1]o", 0, v9 },
+{ "stqa", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|RS1_G0, "J,[i]o", 0, v9 },
+{ "stqa", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|SIMM13(~0), "J,[1]o", 0, v9 }, /* stqa [rs1+0] */
+
+{ "swap", F3(3, 0x0f, 0), F3(~3, ~0x0f, ~0)|ASI(~0), "[1+2],d", 0, v7 },
+{ "swap", F3(3, 0x0f, 0), F3(~3, ~0x0f, ~0)|ASI_RS2(~0), "[1],d", 0, v7 }, /* swap [rs1+%g0],d */
+{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1), "[1+i],d", 0, v7 },
+{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1), "[i+1],d", 0, v7 },
+{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1)|RS1_G0, "[i],d", 0, v7 },
+{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1)|SIMM13(~0), "[1],d", 0, v7 }, /* swap [rs1+0],d */
+
+{ "swapa", F3(3, 0x1f, 0), F3(~3, ~0x1f, ~0), "[1+2]A,d", 0, v7 },
+{ "swapa", F3(3, 0x1f, 0), F3(~3, ~0x1f, ~0)|RS2(~0), "[1]A,d", 0, v7 }, /* swapa [rs1+%g0],d */
+{ "swapa", F3(3, 0x1f, 1), F3(~3, ~0x1f, ~1), "[1+i]o,d", 0, v9 },
+{ "swapa", F3(3, 0x1f, 1), F3(~3, ~0x1f, ~1), "[i+1]o,d", 0, v9 },
+{ "swapa", F3(3, 0x1f, 1), F3(~3, ~0x1f, ~1)|RS1_G0, "[i]o,d", 0, v9 },
+{ "swapa", F3(3, 0x1f, 1), F3(~3, ~0x1f, ~1)|SIMM13(~0), "[1]o,d", 0, v9 }, /* swap [rs1+0],d */
+
+{ "restore", F3(2, 0x3d, 0), F3(~2, ~0x3d, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "restore", F3(2, 0x3d, 0), F3(~2, ~0x3d, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "", 0, v6 }, /* restore %g0,%g0,%g0 */
+{ "restore", F3(2, 0x3d, 1), F3(~2, ~0x3d, ~1), "1,i,d", 0, v6 },
+{ "restore", F3(2, 0x3d, 1), F3(~2, ~0x3d, ~1)|RD_G0|RS1_G0|SIMM13(~0), "", 0, v6 }, /* restore %g0,0,%g0 */
+
+{ "rett", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|RD_G0|ASI(~0), "1+2", F_UNBR|F_DELAYED, v6 }, /* rett rs1+rs2 */
+{ "rett", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|RD_G0|ASI_RS2(~0), "1", F_UNBR|F_DELAYED, v6 }, /* rett rs1,%g0 */
+{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0, "1+i", F_UNBR|F_DELAYED, v6 }, /* rett rs1+X */
+{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0, "i+1", F_UNBR|F_DELAYED, v6 }, /* rett X+rs1 */
+{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|RS1_G0, "i", F_UNBR|F_DELAYED, v6 }, /* rett X+rs1 */
+{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|RS1_G0, "i", F_UNBR|F_DELAYED, v6 }, /* rett X */
+{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|SIMM13(~0), "1", F_UNBR|F_DELAYED, v6 }, /* rett rs1+0 */
+
+{ "save", F3(2, 0x3c, 0), F3(~2, ~0x3c, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "save", F3(2, 0x3c, 1), F3(~2, ~0x3c, ~1), "1,i,d", 0, v6 },
+{ "save", 0x81e00000, ~0x81e00000, "", F_ALIAS, v6 },
+
+{ "ret", F3(2, 0x38, 1)|RS1(0x1f)|SIMM13(8), F3(~2, ~0x38, ~1)|SIMM13(~8), "", F_UNBR|F_DELAYED, v6 }, /* jmpl %i7+8,%g0 */
+{ "retl", F3(2, 0x38, 1)|RS1(0x0f)|SIMM13(8), F3(~2, ~0x38, ~1)|RS1(~0x0f)|SIMM13(~8), "", F_UNBR|F_DELAYED, v6 }, /* jmpl %o7+8,%g0 */
+
+{ "jmpl", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|ASI(~0), "1+2,d", F_JSR|F_DELAYED, v6 },
+{ "jmpl", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|ASI_RS2(~0), "1,d", F_JSR|F_DELAYED, v6 }, /* jmpl rs1+%g0,d */
+{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|SIMM13(~0), "1,d", F_JSR|F_DELAYED, v6 }, /* jmpl rs1+0,d */
+{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RS1_G0, "i,d", F_JSR|F_DELAYED, v6 }, /* jmpl %g0+i,d */
+{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1), "1+i,d", F_JSR|F_DELAYED, v6 },
+{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1), "i+1,d", F_JSR|F_DELAYED, v6 },
+
+{ "done", F3(2, 0x3e, 0)|RD(0), F3(~2, ~0x3e, ~0)|RD(~0)|RS1_G0|SIMM13(~0), "", 0, v9 },
+{ "retry", F3(2, 0x3e, 0)|RD(1), F3(~2, ~0x3e, ~0)|RD(~1)|RS1_G0|SIMM13(~0), "", 0, v9 },
+{ "saved", F3(2, 0x31, 0)|RD(0), F3(~2, ~0x31, ~0)|RD(~0)|RS1_G0|SIMM13(~0), "", 0, v9 },
+{ "restored", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|RS1_G0|SIMM13(~0), "", 0, v9 },
+{ "sir", F3(2, 0x30, 1)|RD(0xf), F3(~2, ~0x30, ~1)|RD(~0xf)|RS1_G0, "i", 0, v9 },
+
+{ "flush", F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI(~0), "1+2", 0, v8 },
+{ "flush", F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI_RS2(~0), "1", 0, v8 }, /* flush rs1+%g0 */
+{ "flush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|SIMM13(~0), "1", 0, v8 }, /* flush rs1+0 */
+{ "flush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|RS1_G0, "i", 0, v8 }, /* flush %g0+i */
+{ "flush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "1+i", 0, v8 },
+{ "flush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "i+1", 0, v8 },
+
+/* IFLUSH was renamed to FLUSH in v8. */
+{ "iflush", F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI(~0), "1+2", F_ALIAS, v6 },
+{ "iflush", F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI_RS2(~0), "1", F_ALIAS, v6 }, /* flush rs1+%g0 */
+{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|SIMM13(~0), "1", F_ALIAS, v6 }, /* flush rs1+0 */
+{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|RS1_G0, "i", F_ALIAS, v6 },
+{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "1+i", F_ALIAS, v6 },
+{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "i+1", F_ALIAS, v6 },
+
+{ "return", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|ASI(~0), "1+2", 0, v9 },
+{ "return", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|ASI_RS2(~0), "1", 0, v9 }, /* return rs1+%g0 */
+{ "return", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|SIMM13(~0), "1", 0, v9 }, /* return rs1+0 */
+{ "return", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RS1_G0, "i", 0, v9 }, /* return %g0+i */
+{ "return", F3(2, 0x39, 1), F3(~2, ~0x39, ~1), "1+i", 0, v9 },
+{ "return", F3(2, 0x39, 1), F3(~2, ~0x39, ~1), "i+1", 0, v9 },
+
+{ "flushw", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "", 0, v9 },
+
+{ "membar", F3(2, 0x28, 1)|RS1(0xf), F3(~2, ~0x28, ~1)|RD_G0|RS1(~0xf)|SIMM13(~127), "K", 0, v9 },
+{ "stbar", F3(2, 0x28, 0)|RS1(0xf), F3(~2, ~0x28, ~0)|RD_G0|RS1(~0xf)|SIMM13(~0), "", 0, v8 },
+
+{ "prefetch", F3(3, 0x2d, 0), F3(~3, ~0x2d, ~0), "[1+2],*", 0, v9 },
+{ "prefetch", F3(3, 0x2d, 0), F3(~3, ~0x2d, ~0)|RS2_G0, "[1],*", 0, v9 }, /* prefetch [rs1+%g0],prefetch_fcn */
+{ "prefetch", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1), "[1+i],*", 0, v9 },
+{ "prefetch", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1), "[i+1],*", 0, v9 },
+{ "prefetch", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1)|RS1_G0, "[i],*", 0, v9 },
+{ "prefetch", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1)|SIMM13(~0), "[1],*", 0, v9 }, /* prefetch [rs1+0],prefetch_fcn */
+{ "prefetcha", F3(3, 0x3d, 0), F3(~3, ~0x3d, ~0), "[1+2]A,*", 0, v9 },
+{ "prefetcha", F3(3, 0x3d, 0), F3(~3, ~0x3d, ~0)|RS2_G0, "[1]A,*", 0, v9 }, /* prefetcha [rs1+%g0],prefetch_fcn */
+{ "prefetcha", F3(3, 0x3d, 1), F3(~3, ~0x3d, ~1), "[1+i]o,*", 0, v9 },
+{ "prefetcha", F3(3, 0x3d, 1), F3(~3, ~0x3d, ~1), "[i+1]o,*", 0, v9 },
+{ "prefetcha", F3(3, 0x3d, 1), F3(~3, ~0x3d, ~1)|RS1_G0, "[i]o,*", 0, v9 },
+{ "prefetcha", F3(3, 0x3d, 1), F3(~3, ~0x3d, ~1)|SIMM13(~0), "[1]o,*", 0, v9 }, /* prefetcha [rs1+0],d */
+
+{ "sll", F3(2, 0x25, 0), F3(~2, ~0x25, ~0)|(1<<12)|(0x7f<<5), "1,2,d", 0, v6 },
+{ "sll", F3(2, 0x25, 1), F3(~2, ~0x25, ~1)|(1<<12)|(0x7f<<5), "1,X,d", 0, v6 },
+{ "sra", F3(2, 0x27, 0), F3(~2, ~0x27, ~0)|(1<<12)|(0x7f<<5), "1,2,d", 0, v6 },
+{ "sra", F3(2, 0x27, 1), F3(~2, ~0x27, ~1)|(1<<12)|(0x7f<<5), "1,X,d", 0, v6 },
+{ "srl", F3(2, 0x26, 0), F3(~2, ~0x26, ~0)|(1<<12)|(0x7f<<5), "1,2,d", 0, v6 },
+{ "srl", F3(2, 0x26, 1), F3(~2, ~0x26, ~1)|(1<<12)|(0x7f<<5), "1,X,d", 0, v6 },
+
+{ "sllx", F3(2, 0x25, 0)|(1<<12), F3(~2, ~0x25, ~0)|(0x7f<<5), "1,2,d", 0, v9 },
+{ "sllx", F3(2, 0x25, 1)|(1<<12), F3(~2, ~0x25, ~1)|(0x3f<<6), "1,Y,d", 0, v9 },
+{ "srax", F3(2, 0x27, 0)|(1<<12), F3(~2, ~0x27, ~0)|(0x7f<<5), "1,2,d", 0, v9 },
+{ "srax", F3(2, 0x27, 1)|(1<<12), F3(~2, ~0x27, ~1)|(0x3f<<6), "1,Y,d", 0, v9 },
+{ "srlx", F3(2, 0x26, 0)|(1<<12), F3(~2, ~0x26, ~0)|(0x7f<<5), "1,2,d", 0, v9 },
+{ "srlx", F3(2, 0x26, 1)|(1<<12), F3(~2, ~0x26, ~1)|(0x3f<<6), "1,Y,d", 0, v9 },
+
+{ "mulscc", F3(2, 0x24, 0), F3(~2, ~0x24, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "mulscc", F3(2, 0x24, 1), F3(~2, ~0x24, ~1), "1,i,d", 0, v6 },
+
+{ "divscc", F3(2, 0x1d, 0), F3(~2, ~0x1d, ~0)|ASI(~0), "1,2,d", 0, sparclite },
+{ "divscc", F3(2, 0x1d, 1), F3(~2, ~0x1d, ~1), "1,i,d", 0, sparclite },
+
+{ "scan", F3(2, 0x2c, 0), F3(~2, ~0x2c, ~0)|ASI(~0), "1,2,d", 0, sparclet|sparclite },
+{ "scan", F3(2, 0x2c, 1), F3(~2, ~0x2c, ~1), "1,i,d", 0, sparclet|sparclite },
+
+{ "popc", F3(2, 0x2e, 0), F3(~2, ~0x2e, ~0)|RS2_G0|ASI(~0),"2,d", 0, v9 },
+{ "popc", F3(2, 0x2e, 1), F3(~2, ~0x2e, ~1)|RS2_G0, "i,d", 0, v9 },
+
+{ "clr", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "d", F_ALIAS, v6 }, /* or %g0,%g0,d */
+{ "clr", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|RS1_G0|SIMM13(~0), "d", F_ALIAS, v6 }, /* or %g0,0,d */
+{ "clr", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 },
+{ "clr", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* st %g0,[rs1+%g0] */
+{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 },
+{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 },
+{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 },
+{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0|SIMM13(~0), "[1]", F_ALIAS, v6 }, /* st %g0,[rs1+0] */
+
+{ "clrb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 },
+{ "clrb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* stb %g0,[rs1+%g0] */
+{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 },
+{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 },
+{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 },
+{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0|SIMM13(~0), "[1]", F_ALIAS, v6 }, /* stb %g0,[rs1+0] */
+
+{ "clrh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 },
+{ "clrh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* sth %g0,[rs1+%g0] */
+{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 },
+{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 },
+{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 },
+{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0|SIMM13(~0), "[1]", F_ALIAS, v6 }, /* sth %g0,[rs1+0] */
+
+{ "clrx", F3(3, 0x0e, 0), F3(~3, ~0x0e, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v9 },
+{ "clrx", F3(3, 0x0e, 0), F3(~3, ~0x0e, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v9 }, /* stx %g0,[rs1+%g0] */
+{ "clrx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|RD_G0, "[1+i]", F_ALIAS, v9 },
+{ "clrx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|RD_G0, "[i+1]", F_ALIAS, v9 },
+{ "clrx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v9 },
+{ "clrx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|RD_G0|SIMM13(~0), "[1]", F_ALIAS, v9 }, /* stx %g0,[rs1+0] */
+
+{ "orcc", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "orcc", F3(2, 0x12, 1), F3(~2, ~0x12, ~1), "1,i,d", 0, v6 },
+{ "orcc", F3(2, 0x12, 1), F3(~2, ~0x12, ~1), "i,1,d", 0, v6 },
+
+/* This is not a commutative instruction. */
+{ "orncc", F3(2, 0x16, 0), F3(~2, ~0x16, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "orncc", F3(2, 0x16, 1), F3(~2, ~0x16, ~1), "1,i,d", 0, v6 },
+
+/* This is not a commutative instruction. */
+{ "orn", F3(2, 0x06, 0), F3(~2, ~0x06, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "orn", F3(2, 0x06, 1), F3(~2, ~0x06, ~1), "1,i,d", 0, v6 },
+
+{ "tst", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|RD_G0|ASI_RS2(~0), "1", 0, v6 }, /* orcc rs1, %g0, %g0 */
+{ "tst", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|RD_G0|RS1_G0|ASI(~0), "2", 0, v6 }, /* orcc %g0, rs2, %g0 */
+{ "tst", F3(2, 0x12, 1), F3(~2, ~0x12, ~1)|RD_G0|SIMM13(~0), "1", 0, v6 }, /* orcc rs1, 0, %g0 */
+
+{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI(~0), "1,2,m", 0, v8 }, /* wr r,r,%asrX */
+{ "wr", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "1,i,m", 0, v8 }, /* wr r,i,%asrX */
+{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI_RS2(~0), "1,m", F_ALIAS, v8 }, /* wr rs1,%g0,%asrX */
+{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI(~0), "1,2,y", 0, v6 }, /* wr r,r,%y */
+{ "wr", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "1,i,y", 0, v6 }, /* wr r,i,%y */
+{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI_RS2(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,%g0,%y */
+{ "wr", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI(~0), "1,2,p", 0, v6notv9 }, /* wr r,r,%psr */
+{ "wr", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "1,i,p", 0, v6notv9 }, /* wr r,i,%psr */
+{ "wr", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI_RS2(~0), "1,p", F_ALIAS, v6notv9 }, /* wr rs1,%g0,%psr */
+{ "wr", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI(~0), "1,2,w", 0, v6notv9 }, /* wr r,r,%wim */
+{ "wr", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "1,i,w", 0, v6notv9 }, /* wr r,i,%wim */
+{ "wr", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI_RS2(~0), "1,w", F_ALIAS, v6notv9 }, /* wr rs1,%g0,%wim */
+{ "wr", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI(~0), "1,2,t", 0, v6notv9 }, /* wr r,r,%tbr */
+{ "wr", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "1,i,t", 0, v6notv9 }, /* wr r,i,%tbr */
+{ "wr", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI_RS2(~0), "1,t", F_ALIAS, v6notv9 }, /* wr rs1,%g0,%tbr */
+
+{ "wr", F3(2, 0x30, 0)|RD(2), F3(~2, ~0x30, ~0)|RD(~2)|ASI(~0), "1,2,E", 0, v9 }, /* wr r,r,%ccr */
+{ "wr", F3(2, 0x30, 1)|RD(2), F3(~2, ~0x30, ~1)|RD(~2), "1,i,E", 0, v9 }, /* wr r,i,%ccr */
+{ "wr", F3(2, 0x30, 0)|RD(3), F3(~2, ~0x30, ~0)|RD(~3)|ASI(~0), "1,2,o", 0, v9 }, /* wr r,r,%asi */
+{ "wr", F3(2, 0x30, 1)|RD(3), F3(~2, ~0x30, ~1)|RD(~3), "1,i,o", 0, v9 }, /* wr r,i,%asi */
+{ "wr", F3(2, 0x30, 0)|RD(6), F3(~2, ~0x30, ~0)|RD(~6)|ASI(~0), "1,2,s", 0, v9 }, /* wr r,r,%fprs */
+{ "wr", F3(2, 0x30, 1)|RD(6), F3(~2, ~0x30, ~1)|RD(~6), "1,i,s", 0, v9 }, /* wr r,i,%fprs */
+
+{ "wr", F3(2, 0x30, 0)|RD(16), F3(~2, ~0x30, ~0)|RD(~16)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%pcr */
+{ "wr", F3(2, 0x30, 1)|RD(16), F3(~2, ~0x30, ~1)|RD(~16), "1,i,_", 0, v9a }, /* wr r,i,%pcr */
+{ "wr", F3(2, 0x30, 0)|RD(17), F3(~2, ~0x30, ~0)|RD(~17)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%pic */
+{ "wr", F3(2, 0x30, 1)|RD(17), F3(~2, ~0x30, ~1)|RD(~17), "1,i,_", 0, v9a }, /* wr r,i,%pic */
+{ "wr", F3(2, 0x30, 0)|RD(18), F3(~2, ~0x30, ~0)|RD(~18)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%dcr */
+{ "wr", F3(2, 0x30, 1)|RD(18), F3(~2, ~0x30, ~1)|RD(~18), "1,i,_", 0, v9a }, /* wr r,i,%dcr */
+{ "wr", F3(2, 0x30, 0)|RD(19), F3(~2, ~0x30, ~0)|RD(~19)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%gsr */
+{ "wr", F3(2, 0x30, 1)|RD(19), F3(~2, ~0x30, ~1)|RD(~19), "1,i,_", 0, v9a }, /* wr r,i,%gsr */
+{ "wr", F3(2, 0x30, 0)|RD(20), F3(~2, ~0x30, ~0)|RD(~20)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%set_softint */
+{ "wr", F3(2, 0x30, 1)|RD(20), F3(~2, ~0x30, ~1)|RD(~20), "1,i,_", 0, v9a }, /* wr r,i,%set_softint */
+{ "wr", F3(2, 0x30, 0)|RD(21), F3(~2, ~0x30, ~0)|RD(~21)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%clear_softint */
+{ "wr", F3(2, 0x30, 1)|RD(21), F3(~2, ~0x30, ~1)|RD(~21), "1,i,_", 0, v9a }, /* wr r,i,%clear_softint */
+{ "wr", F3(2, 0x30, 0)|RD(22), F3(~2, ~0x30, ~0)|RD(~22)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%softint */
+{ "wr", F3(2, 0x30, 1)|RD(22), F3(~2, ~0x30, ~1)|RD(~22), "1,i,_", 0, v9a }, /* wr r,i,%softint */
+{ "wr", F3(2, 0x30, 0)|RD(23), F3(~2, ~0x30, ~0)|RD(~23)|ASI(~0), "1,2,_", 0, v9a }, /* wr r,r,%tick_cmpr */
+{ "wr", F3(2, 0x30, 1)|RD(23), F3(~2, ~0x30, ~1)|RD(~23), "1,i,_", 0, v9a }, /* wr r,i,%tick_cmpr */
+
+{ "rd", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|SIMM13(~0), "M,d", 0, v8 }, /* rd %asrX,r */
+{ "rd", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|RS1_G0|SIMM13(~0), "y,d", 0, v6 }, /* rd %y,r */
+{ "rd", F3(2, 0x29, 0), F3(~2, ~0x29, ~0)|RS1_G0|SIMM13(~0), "p,d", 0, v6notv9 }, /* rd %psr,r */
+{ "rd", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|RS1_G0|SIMM13(~0), "w,d", 0, v6notv9 }, /* rd %wim,r */
+{ "rd", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RS1_G0|SIMM13(~0), "t,d", 0, v6notv9 }, /* rd %tbr,r */
+
+{ "rd", F3(2, 0x28, 0)|RS1(2), F3(~2, ~0x28, ~0)|RS1(~2)|SIMM13(~0), "E,d", 0, v9 }, /* rd %ccr,r */
+{ "rd", F3(2, 0x28, 0)|RS1(3), F3(~2, ~0x28, ~0)|RS1(~3)|SIMM13(~0), "o,d", 0, v9 }, /* rd %asi,r */
+{ "rd", F3(2, 0x28, 0)|RS1(4), F3(~2, ~0x28, ~0)|RS1(~4)|SIMM13(~0), "W,d", 0, v9 }, /* rd %tick,r */
+{ "rd", F3(2, 0x28, 0)|RS1(5), F3(~2, ~0x28, ~0)|RS1(~5)|SIMM13(~0), "P,d", 0, v9 }, /* rd %pc,r */
+{ "rd", F3(2, 0x28, 0)|RS1(6), F3(~2, ~0x28, ~0)|RS1(~6)|SIMM13(~0), "s,d", 0, v9 }, /* rd %fprs,r */
+
+{ "rd", F3(2, 0x28, 0)|RS1(16), F3(~2, ~0x28, ~0)|RS1(~16)|SIMM13(~0), "/,d", 0, v9a }, /* rd %pcr,r */
+{ "rd", F3(2, 0x28, 0)|RS1(17), F3(~2, ~0x28, ~0)|RS1(~17)|SIMM13(~0), "/,d", 0, v9a }, /* rd %pic,r */
+{ "rd", F3(2, 0x28, 0)|RS1(18), F3(~2, ~0x28, ~0)|RS1(~18)|SIMM13(~0), "/,d", 0, v9a }, /* rd %dcr,r */
+{ "rd", F3(2, 0x28, 0)|RS1(19), F3(~2, ~0x28, ~0)|RS1(~19)|SIMM13(~0), "/,d", 0, v9a }, /* rd %gsr,r */
+{ "rd", F3(2, 0x28, 0)|RS1(22), F3(~2, ~0x28, ~0)|RS1(~22)|SIMM13(~0), "/,d", 0, v9a }, /* rd %softint,r */
+{ "rd", F3(2, 0x28, 0)|RS1(23), F3(~2, ~0x28, ~0)|RS1(~23)|SIMM13(~0), "/,d", 0, v9a }, /* rd %tick_cmpr,r */
+
+{ "rdpr", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|SIMM13(~0), "?,d", 0, v9 }, /* rdpr %priv,r */
+{ "wrpr", F3(2, 0x32, 0), F3(~2, ~0x32, ~0), "1,2,!", 0, v9 }, /* wrpr r1,r2,%priv */
+{ "wrpr", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|SIMM13(~0), "1,!", 0, v9 }, /* wrpr r1,%priv */
+{ "wrpr", F3(2, 0x32, 1), F3(~2, ~0x32, ~1), "1,i,!", 0, v9 }, /* wrpr r1,i,%priv */
+{ "wrpr", F3(2, 0x32, 1), F3(~2, ~0x32, ~1), "i,1,!", F_ALIAS, v9 }, /* wrpr i,r1,%priv */
+{ "wrpr", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RS1(~0), "i,!", 0, v9 }, /* wrpr i,%priv */
+
+/* ??? This group seems wrong. A three operand move? */
+{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI(~0), "1,2,m", F_ALIAS, v8 }, /* wr r,r,%asrX */
+{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "1,i,m", F_ALIAS, v8 }, /* wr r,i,%asrX */
+{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI(~0), "1,2,y", F_ALIAS, v6 }, /* wr r,r,%y */
+{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "1,i,y", F_ALIAS, v6 }, /* wr r,i,%y */
+{ "mov", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI(~0), "1,2,p", F_ALIAS, v6notv9 }, /* wr r,r,%psr */
+{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "1,i,p", F_ALIAS, v6notv9 }, /* wr r,i,%psr */
+{ "mov", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI(~0), "1,2,w", F_ALIAS, v6notv9 }, /* wr r,r,%wim */
+{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "1,i,w", F_ALIAS, v6notv9 }, /* wr r,i,%wim */
+{ "mov", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI(~0), "1,2,t", F_ALIAS, v6notv9 }, /* wr r,r,%tbr */
+{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "1,i,t", F_ALIAS, v6notv9 }, /* wr r,i,%tbr */
+
+{ "mov", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|SIMM13(~0), "M,d", F_ALIAS, v8 }, /* rd %asr1,r */
+{ "mov", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|RS1_G0|SIMM13(~0), "y,d", F_ALIAS, v6 }, /* rd %y,r */
+{ "mov", F3(2, 0x29, 0), F3(~2, ~0x29, ~0)|RS1_G0|SIMM13(~0), "p,d", F_ALIAS, v6notv9 }, /* rd %psr,r */
+{ "mov", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|RS1_G0|SIMM13(~0), "w,d", F_ALIAS, v6notv9 }, /* rd %wim,r */
+{ "mov", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RS1_G0|SIMM13(~0), "t,d", F_ALIAS, v6notv9 }, /* rd %tbr,r */
+
+{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI_RS2(~0), "1,m", F_ALIAS, v8 }, /* wr rs1,%g0,%asrX */
+{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "i,m", F_ALIAS, v8 }, /* wr %g0,i,%asrX */
+{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|SIMM13(~0), "1,m", F_ALIAS, v8 }, /* wr rs1,0,%asrX */
+{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI_RS2(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,%g0,%y */
+{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "i,y", F_ALIAS, v6 }, /* wr %g0,i,%y */
+{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0|SIMM13(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,0,%y */
+{ "mov", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI_RS2(~0), "1,p", F_ALIAS, v6notv9 }, /* wr rs1,%g0,%psr */
+{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "i,p", F_ALIAS, v6notv9 }, /* wr %g0,i,%psr */
+{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0|SIMM13(~0), "1,p", F_ALIAS, v6notv9 }, /* wr rs1,0,%psr */
+{ "mov", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI_RS2(~0), "1,w", F_ALIAS, v6notv9 }, /* wr rs1,%g0,%wim */
+{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "i,w", F_ALIAS, v6notv9 }, /* wr %g0,i,%wim */
+{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0|SIMM13(~0), "1,w", F_ALIAS, v6notv9 }, /* wr rs1,0,%wim */
+{ "mov", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI_RS2(~0), "1,t", F_ALIAS, v6notv9 }, /* wr rs1,%g0,%tbr */
+{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "i,t", F_ALIAS, v6notv9 }, /* wr %g0,i,%tbr */
+{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0|SIMM13(~0), "1,t", F_ALIAS, v6notv9 }, /* wr rs1,0,%tbr */
+
+{ "mov", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|RS1_G0|ASI(~0), "2,d", 0, v6 }, /* or %g0,rs2,d */
+{ "mov", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|RS1_G0, "i,d", 0, v6 }, /* or %g0,i,d */
+{ "mov", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI_RS2(~0), "1,d", 0, v6 }, /* or rs1,%g0,d */
+{ "mov", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|SIMM13(~0), "1,d", 0, v6 }, /* or rs1,0,d */
+
+{ "or", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "or", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "1,i,d", 0, v6 },
+{ "or", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "i,1,d", 0, v6 },
+
+{ "bset", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* or rd,rs2,rd */
+{ "bset", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "i,r", F_ALIAS, v6 }, /* or rd,i,rd */
+
+/* This is not a commutative instruction. */
+{ "andn", F3(2, 0x05, 0), F3(~2, ~0x05, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "andn", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "1,i,d", 0, v6 },
+
+/* This is not a commutative instruction. */
+{ "andncc", F3(2, 0x15, 0), F3(~2, ~0x15, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "andncc", F3(2, 0x15, 1), F3(~2, ~0x15, ~1), "1,i,d", 0, v6 },
+
+{ "bclr", F3(2, 0x05, 0), F3(~2, ~0x05, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* andn rd,rs2,rd */
+{ "bclr", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "i,r", F_ALIAS, v6 }, /* andn rd,i,rd */
+
+{ "cmp", F3(2, 0x14, 0), F3(~2, ~0x14, ~0)|RD_G0|ASI(~0), "1,2", 0, v6 }, /* subcc rs1,rs2,%g0 */
+{ "cmp", F3(2, 0x14, 1), F3(~2, ~0x14, ~1)|RD_G0, "1,i", 0, v6 }, /* subcc rs1,i,%g0 */
+
+{ "sub", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "sub", F3(2, 0x04, 1), F3(~2, ~0x04, ~1), "1,i,d", 0, v6 },
+
+{ "subcc", F3(2, 0x14, 0), F3(~2, ~0x14, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "subcc", F3(2, 0x14, 1), F3(~2, ~0x14, ~1), "1,i,d", 0, v6 },
+
+{ "subx", F3(2, 0x0c, 0), F3(~2, ~0x0c, ~0)|ASI(~0), "1,2,d", 0, v6notv9 },
+{ "subx", F3(2, 0x0c, 1), F3(~2, ~0x0c, ~1), "1,i,d", 0, v6notv9 },
+{ "subc", F3(2, 0x0c, 0), F3(~2, ~0x0c, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "subc", F3(2, 0x0c, 1), F3(~2, ~0x0c, ~1), "1,i,d", 0, v9 },
+
+{ "subxcc", F3(2, 0x1c, 0), F3(~2, ~0x1c, ~0)|ASI(~0), "1,2,d", 0, v6notv9 },
+{ "subxcc", F3(2, 0x1c, 1), F3(~2, ~0x1c, ~1), "1,i,d", 0, v6notv9 },
+{ "subccc", F3(2, 0x1c, 0), F3(~2, ~0x1c, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "subccc", F3(2, 0x1c, 1), F3(~2, ~0x1c, ~1), "1,i,d", 0, v9 },
+
+{ "and", F3(2, 0x01, 0), F3(~2, ~0x01, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "and", F3(2, 0x01, 1), F3(~2, ~0x01, ~1), "1,i,d", 0, v6 },
+{ "and", F3(2, 0x01, 1), F3(~2, ~0x01, ~1), "i,1,d", 0, v6 },
+
+{ "andcc", F3(2, 0x11, 0), F3(~2, ~0x11, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "andcc", F3(2, 0x11, 1), F3(~2, ~0x11, ~1), "1,i,d", 0, v6 },
+{ "andcc", F3(2, 0x11, 1), F3(~2, ~0x11, ~1), "i,1,d", 0, v6 },
+
+{ "dec", F3(2, 0x04, 1)|SIMM13(0x1), F3(~2, ~0x04, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* sub rd,1,rd */
+{ "dec", F3(2, 0x04, 1), F3(~2, ~0x04, ~1), "i,r", F_ALIAS, v8 }, /* sub rd,imm,rd */
+{ "deccc", F3(2, 0x14, 1)|SIMM13(0x1), F3(~2, ~0x14, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* subcc rd,1,rd */
+{ "deccc", F3(2, 0x14, 1), F3(~2, ~0x14, ~1), "i,r", F_ALIAS, v8 }, /* subcc rd,imm,rd */
+{ "inc", F3(2, 0x00, 1)|SIMM13(0x1), F3(~2, ~0x00, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* add rd,1,rd */
+{ "inc", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "i,r", F_ALIAS, v8 }, /* add rd,imm,rd */
+{ "inccc", F3(2, 0x10, 1)|SIMM13(0x1), F3(~2, ~0x10, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* addcc rd,1,rd */
+{ "inccc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "i,r", F_ALIAS, v8 }, /* addcc rd,imm,rd */
+
+{ "btst", F3(2, 0x11, 0), F3(~2, ~0x11, ~0)|RD_G0|ASI(~0), "1,2", F_ALIAS, v6 }, /* andcc rs1,rs2,%g0 */
+{ "btst", F3(2, 0x11, 1), F3(~2, ~0x11, ~1)|RD_G0, "i,1", F_ALIAS, v6 }, /* andcc rs1,i,%g0 */
+
+{ "neg", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|RS1_G0|ASI(~0), "2,d", F_ALIAS, v6 }, /* sub %g0,rs2,rd */
+{ "neg", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|RS1_G0|ASI(~0), "O", F_ALIAS, v6 }, /* sub %g0,rd,rd */
+
+{ "add", F3(2, 0x00, 0), F3(~2, ~0x00, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "add", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "1,i,d", 0, v6 },
+{ "add", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "i,1,d", 0, v6 },
+{ "addcc", F3(2, 0x10, 0), F3(~2, ~0x10, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "addcc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "1,i,d", 0, v6 },
+{ "addcc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "i,1,d", 0, v6 },
+
+{ "addx", F3(2, 0x08, 0), F3(~2, ~0x08, ~0)|ASI(~0), "1,2,d", 0, v6notv9 },
+{ "addx", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "1,i,d", 0, v6notv9 },
+{ "addx", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "i,1,d", 0, v6notv9 },
+{ "addc", F3(2, 0x08, 0), F3(~2, ~0x08, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "addc", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "1,i,d", 0, v9 },
+{ "addc", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "i,1,d", 0, v9 },
+
+{ "addxcc", F3(2, 0x18, 0), F3(~2, ~0x18, ~0)|ASI(~0), "1,2,d", 0, v6notv9 },
+{ "addxcc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "1,i,d", 0, v6notv9 },
+{ "addxcc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "i,1,d", 0, v6notv9 },
+{ "addccc", F3(2, 0x18, 0), F3(~2, ~0x18, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "addccc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "1,i,d", 0, v9 },
+{ "addccc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "i,1,d", 0, v9 },
+
+{ "smul", F3(2, 0x0b, 0), F3(~2, ~0x0b, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "smul", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "1,i,d", 0, v8 },
+{ "smul", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "i,1,d", 0, v8 },
+{ "smulcc", F3(2, 0x1b, 0), F3(~2, ~0x1b, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "smulcc", F3(2, 0x1b, 1), F3(~2, ~0x1b, ~1), "1,i,d", 0, v8 },
+{ "smulcc", F3(2, 0x1b, 1), F3(~2, ~0x1b, ~1), "i,1,d", 0, v8 },
+{ "umul", F3(2, 0x0a, 0), F3(~2, ~0x0a, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "umul", F3(2, 0x0a, 1), F3(~2, ~0x0a, ~1), "1,i,d", 0, v8 },
+{ "umul", F3(2, 0x0a, 1), F3(~2, ~0x0a, ~1), "i,1,d", 0, v8 },
+{ "umulcc", F3(2, 0x1a, 0), F3(~2, ~0x1a, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "umulcc", F3(2, 0x1a, 1), F3(~2, ~0x1a, ~1), "1,i,d", 0, v8 },
+{ "umulcc", F3(2, 0x1a, 1), F3(~2, ~0x1a, ~1), "i,1,d", 0, v8 },
+{ "sdiv", F3(2, 0x0f, 0), F3(~2, ~0x0f, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "sdiv", F3(2, 0x0f, 1), F3(~2, ~0x0f, ~1), "1,i,d", 0, v8 },
+{ "sdiv", F3(2, 0x0f, 1), F3(~2, ~0x0f, ~1), "i,1,d", 0, v8 },
+{ "sdivcc", F3(2, 0x1f, 0), F3(~2, ~0x1f, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "sdivcc", F3(2, 0x1f, 1), F3(~2, ~0x1f, ~1), "1,i,d", 0, v8 },
+{ "sdivcc", F3(2, 0x1f, 1), F3(~2, ~0x1f, ~1), "i,1,d", 0, v8 },
+{ "udiv", F3(2, 0x0e, 0), F3(~2, ~0x0e, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "udiv", F3(2, 0x0e, 1), F3(~2, ~0x0e, ~1), "1,i,d", 0, v8 },
+{ "udiv", F3(2, 0x0e, 1), F3(~2, ~0x0e, ~1), "i,1,d", 0, v8 },
+{ "udivcc", F3(2, 0x1e, 0), F3(~2, ~0x1e, ~0)|ASI(~0), "1,2,d", 0, v8 },
+{ "udivcc", F3(2, 0x1e, 1), F3(~2, ~0x1e, ~1), "1,i,d", 0, v8 },
+{ "udivcc", F3(2, 0x1e, 1), F3(~2, ~0x1e, ~1), "i,1,d", 0, v8 },
+
+{ "mulx", F3(2, 0x09, 0), F3(~2, ~0x09, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "mulx", F3(2, 0x09, 1), F3(~2, ~0x09, ~1), "1,i,d", 0, v9 },
+{ "sdivx", F3(2, 0x2d, 0), F3(~2, ~0x2d, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "sdivx", F3(2, 0x2d, 1), F3(~2, ~0x2d, ~1), "1,i,d", 0, v9 },
+{ "udivx", F3(2, 0x0d, 0), F3(~2, ~0x0d, ~0)|ASI(~0), "1,2,d", 0, v9 },
+{ "udivx", F3(2, 0x0d, 1), F3(~2, ~0x0d, ~1), "1,i,d", 0, v9 },
+
+{ "call", F1(0x1), F1(~0x1), "L", F_JSR|F_DELAYED, v6 },
+{ "call", F1(0x1), F1(~0x1), "L,#", F_JSR|F_DELAYED, v6 },
+
+{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI(~0), "1+2", F_JSR|F_DELAYED, v6 }, /* jmpl rs1+rs2,%o7 */
+{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI(~0), "1+2,#", F_JSR|F_DELAYED, v6 },
+{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI_RS2(~0), "1", F_JSR|F_DELAYED, v6 }, /* jmpl rs1+%g0,%o7 */
+{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI_RS2(~0), "1,#", F_JSR|F_DELAYED, v6 },
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf), "1+i", F_JSR|F_DELAYED, v6 }, /* jmpl rs1+i,%o7 */
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf), "1+i,#", F_JSR|F_DELAYED, v6 },
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf), "i+1", F_JSR|F_DELAYED, v6 }, /* jmpl i+rs1,%o7 */
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf), "i+1,#", F_JSR|F_DELAYED, v6 },
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf)|RS1_G0, "i", F_JSR|F_DELAYED, v6 }, /* jmpl %g0+i,%o7 */
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf)|RS1_G0, "i,#", F_JSR|F_DELAYED, v6 },
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf)|SIMM13(~0), "1", F_JSR|F_DELAYED, v6 }, /* jmpl rs1+0,%o7 */
+{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf)|SIMM13(~0), "1,#", F_JSR|F_DELAYED, v6 },
+
+
+/* Conditional instructions.
+
+ Because this part of the table was such a mess earlier, I have
+ macrofied it so that all the branches and traps are generated from
+ a single-line description of each condition value. John Gilmore. */
+
+/* Define branches -- one annulled, one without, etc. */
+#define br(opcode, mask, lose, flags) \
+ { opcode, (mask)|ANNUL, (lose), ",a l", (flags), v6 }, \
+ { opcode, (mask) , (lose)|ANNUL, "l", (flags), v6 }
+
+#define brx(opcode, mask, lose, flags) /* v9 */ \
+ { opcode, (mask)|(2<<20)|BPRED, ANNUL|(lose), "Z,G", (flags), v9 }, \
+ { opcode, (mask)|(2<<20)|BPRED, ANNUL|(lose), ",T Z,G", (flags), v9 }, \
+ { opcode, (mask)|(2<<20)|BPRED|ANNUL, (lose), ",a Z,G", (flags), v9 }, \
+ { opcode, (mask)|(2<<20)|BPRED|ANNUL, (lose), ",a,T Z,G", (flags), v9 }, \
+ { opcode, (mask)|(2<<20), ANNUL|BPRED|(lose), ",N Z,G", (flags), v9 }, \
+ { opcode, (mask)|(2<<20)|ANNUL, BPRED|(lose), ",a,N Z,G", (flags), v9 }, \
+ { opcode, (mask)|BPRED, ANNUL|(lose)|(2<<20), "z,G", (flags), v9 }, \
+ { opcode, (mask)|BPRED, ANNUL|(lose)|(2<<20), ",T z,G", (flags), v9 }, \
+ { opcode, (mask)|BPRED|ANNUL, (lose)|(2<<20), ",a z,G", (flags), v9 }, \
+ { opcode, (mask)|BPRED|ANNUL, (lose)|(2<<20), ",a,T z,G", (flags), v9 }, \
+ { opcode, (mask), ANNUL|BPRED|(lose)|(2<<20), ",N z,G", (flags), v9 }, \
+ { opcode, (mask)|ANNUL, BPRED|(lose)|(2<<20), ",a,N z,G", (flags), v9 }
+
+/* Define four traps: reg+reg, reg + immediate, immediate alone, reg alone. */
+#define tr(opcode, mask, lose, flags) \
+ { opcode, (mask)|(2<<11)|IMMED, (lose)|RS1_G0, "Z,i", (flags), v9 }, /* %g0 + imm */ \
+ { opcode, (mask)|(2<<11)|IMMED, (lose), "Z,1+i", (flags), v9 }, /* rs1 + imm */ \
+ { opcode, (mask)|(2<<11), IMMED|(lose), "Z,1+2", (flags), v9 }, /* rs1 + rs2 */ \
+ { opcode, (mask)|(2<<11), IMMED|(lose)|RS2_G0, "Z,1", (flags), v9 }, /* rs1 + %g0 */ \
+ { opcode, (mask)|IMMED, (lose)|RS1_G0, "z,i", (flags)|F_ALIAS, v9 }, /* %g0 + imm */ \
+ { opcode, (mask)|IMMED, (lose), "z,1+i", (flags)|F_ALIAS, v9 }, /* rs1 + imm */ \
+ { opcode, (mask), IMMED|(lose), "z,1+2", (flags)|F_ALIAS, v9 }, /* rs1 + rs2 */ \
+ { opcode, (mask), IMMED|(lose)|RS2_G0, "z,1", (flags)|F_ALIAS, v9 }, /* rs1 + %g0 */ \
+ { opcode, (mask)|IMMED, (lose)|RS1_G0, "i", (flags), v6 }, /* %g0 + imm */ \
+ { opcode, (mask)|IMMED, (lose), "1+i", (flags), v6 }, /* rs1 + imm */ \
+ { opcode, (mask), IMMED|(lose), "1+2", (flags), v6 }, /* rs1 + rs2 */ \
+ { opcode, (mask), IMMED|(lose)|RS2_G0, "1", (flags), v6 } /* rs1 + %g0 */
+
+/* v9: We must put `brx' before `br', to ensure that we never match something
+ v9: against an expression unless it is an expression. Otherwise, we end
+ v9: up with undefined symbol tables entries, because they get added, but
+ v9: are not deleted if the pattern fails to match. */
+
+/* Define both branches and traps based on condition mask */
+#define cond(bop, top, mask, flags) \
+ brx(bop, F2(0, 1)|(mask), F2(~0, ~1)|((~mask)&COND(~0)), F_DELAYED|(flags)), /* v9 */ \
+ br(bop, F2(0, 2)|(mask), F2(~0, ~2)|((~mask)&COND(~0)), F_DELAYED|(flags)), \
+ tr(top, F3(2, 0x3a, 0)|(mask), F3(~2, ~0x3a, 0)|((~mask)&COND(~0)), ((flags) & ~(F_UNBR|F_CONDBR)))
+
+/* Define all the conditions, all the branches, all the traps. */
+
+/* Standard branch, trap mnemonics */
+cond ("b", "ta", CONDA, F_UNBR),
+/* Alternative form (just for assembly, not for disassembly) */
+cond ("ba", "t", CONDA, F_UNBR|F_ALIAS),
+
+cond ("bcc", "tcc", CONDCC, F_CONDBR),
+cond ("bcs", "tcs", CONDCS, F_CONDBR),
+cond ("be", "te", CONDE, F_CONDBR),
+cond ("beq", "teq", CONDE, F_CONDBR|F_ALIAS),
+cond ("bg", "tg", CONDG, F_CONDBR),
+cond ("bgt", "tgt", CONDG, F_CONDBR|F_ALIAS),
+cond ("bge", "tge", CONDGE, F_CONDBR),
+cond ("bgeu", "tgeu", CONDGEU, F_CONDBR|F_ALIAS), /* for cc */
+cond ("bgu", "tgu", CONDGU, F_CONDBR),
+cond ("bl", "tl", CONDL, F_CONDBR),
+cond ("blt", "tlt", CONDL, F_CONDBR|F_ALIAS),
+cond ("ble", "tle", CONDLE, F_CONDBR),
+cond ("bleu", "tleu", CONDLEU, F_CONDBR),
+cond ("blu", "tlu", CONDLU, F_CONDBR|F_ALIAS), /* for cs */
+cond ("bn", "tn", CONDN, F_CONDBR),
+cond ("bne", "tne", CONDNE, F_CONDBR),
+cond ("bneg", "tneg", CONDNEG, F_CONDBR),
+cond ("bnz", "tnz", CONDNZ, F_CONDBR|F_ALIAS), /* for ne */
+cond ("bpos", "tpos", CONDPOS, F_CONDBR),
+cond ("bvc", "tvc", CONDVC, F_CONDBR),
+cond ("bvs", "tvs", CONDVS, F_CONDBR),
+cond ("bz", "tz", CONDZ, F_CONDBR|F_ALIAS), /* for e */
+
+#undef cond
+#undef br
+#undef brr /* v9 */
+#undef tr
+
+#define brr(opcode, mask, lose, flags) /* v9 */ \
+ { opcode, (mask)|BPRED, ANNUL|(lose), "1,k", F_DELAYED|(flags), v9 }, \
+ { opcode, (mask)|BPRED, ANNUL|(lose), ",T 1,k", F_DELAYED|(flags), v9 }, \
+ { opcode, (mask)|BPRED|ANNUL, (lose), ",a 1,k", F_DELAYED|(flags), v9 }, \
+ { opcode, (mask)|BPRED|ANNUL, (lose), ",a,T 1,k", F_DELAYED|(flags), v9 }, \
+ { opcode, (mask), ANNUL|BPRED|(lose), ",N 1,k", F_DELAYED|(flags), v9 }, \
+ { opcode, (mask)|ANNUL, BPRED|(lose), ",a,N 1,k", F_DELAYED|(flags), v9 }
+
+#define condr(bop, mask, flags) /* v9 */ \
+ brr(bop, F2(0, 3)|COND(mask), F2(~0, ~3)|COND(~(mask)), (flags)) /* v9 */
+
+/* v9 */ condr("brnz", 0x5, F_CONDBR),
+/* v9 */ condr("brz", 0x1, F_CONDBR),
+/* v9 */ condr("brgez", 0x7, F_CONDBR),
+/* v9 */ condr("brlz", 0x3, F_CONDBR),
+/* v9 */ condr("brlez", 0x2, F_CONDBR),
+/* v9 */ condr("brgz", 0x6, F_CONDBR),
+
+#undef condr /* v9 */
+#undef brr /* v9 */
+
+#define movr(opcode, mask, flags) /* v9 */ \
+ { opcode, F3(2, 0x2f, 0)|RCOND(mask), F3(~2, ~0x2f, ~0)|RCOND(~(mask)), "1,2,d", (flags), v9 }, \
+ { opcode, F3(2, 0x2f, 1)|RCOND(mask), F3(~2, ~0x2f, ~1)|RCOND(~(mask)), "1,j,d", (flags), v9 }
+
+#define fmrrs(opcode, mask, lose, flags) /* v9 */ \
+ { opcode, (mask), (lose), "1,f,g", (flags) | F_FLOAT, v9 }
+#define fmrrd(opcode, mask, lose, flags) /* v9 */ \
+ { opcode, (mask), (lose), "1,B,H", (flags) | F_FLOAT, v9 }
+#define fmrrq(opcode, mask, lose, flags) /* v9 */ \
+ { opcode, (mask), (lose), "1,R,J", (flags) | F_FLOAT, v9 }
+
+#define fmovrs(mop, mask, flags) /* v9 */ \
+ fmrrs(mop, F3(2, 0x35, 0)|OPF_LOW5(5)|RCOND(mask), F3(~2, ~0x35, 0)|OPF_LOW5(~5)|RCOND(~(mask)), (flags)) /* v9 */
+#define fmovrd(mop, mask, flags) /* v9 */ \
+ fmrrd(mop, F3(2, 0x35, 0)|OPF_LOW5(6)|RCOND(mask), F3(~2, ~0x35, 0)|OPF_LOW5(~6)|RCOND(~(mask)), (flags)) /* v9 */
+#define fmovrq(mop, mask, flags) /* v9 */ \
+ fmrrq(mop, F3(2, 0x35, 0)|OPF_LOW5(7)|RCOND(mask), F3(~2, ~0x35, 0)|OPF_LOW5(~7)|RCOND(~(mask)), (flags)) /* v9 */
+
+/* v9 */ movr("movrne", 0x5, 0),
+/* v9 */ movr("movre", 0x1, 0),
+/* v9 */ movr("movrgez", 0x7, 0),
+/* v9 */ movr("movrlz", 0x3, 0),
+/* v9 */ movr("movrlez", 0x2, 0),
+/* v9 */ movr("movrgz", 0x6, 0),
+/* v9 */ movr("movrnz", 0x5, F_ALIAS),
+/* v9 */ movr("movrz", 0x1, F_ALIAS),
+
+/* v9 */ fmovrs("fmovrsne", 0x5, 0),
+/* v9 */ fmovrs("fmovrse", 0x1, 0),
+/* v9 */ fmovrs("fmovrsgez", 0x7, 0),
+/* v9 */ fmovrs("fmovrslz", 0x3, 0),
+/* v9 */ fmovrs("fmovrslez", 0x2, 0),
+/* v9 */ fmovrs("fmovrsgz", 0x6, 0),
+/* v9 */ fmovrs("fmovrsnz", 0x5, F_ALIAS),
+/* v9 */ fmovrs("fmovrsz", 0x1, F_ALIAS),
+
+/* v9 */ fmovrd("fmovrdne", 0x5, 0),
+/* v9 */ fmovrd("fmovrde", 0x1, 0),
+/* v9 */ fmovrd("fmovrdgez", 0x7, 0),
+/* v9 */ fmovrd("fmovrdlz", 0x3, 0),
+/* v9 */ fmovrd("fmovrdlez", 0x2, 0),
+/* v9 */ fmovrd("fmovrdgz", 0x6, 0),
+/* v9 */ fmovrd("fmovrdnz", 0x5, F_ALIAS),
+/* v9 */ fmovrd("fmovrdz", 0x1, F_ALIAS),
+
+/* v9 */ fmovrq("fmovrqne", 0x5, 0),
+/* v9 */ fmovrq("fmovrqe", 0x1, 0),
+/* v9 */ fmovrq("fmovrqgez", 0x7, 0),
+/* v9 */ fmovrq("fmovrqlz", 0x3, 0),
+/* v9 */ fmovrq("fmovrqlez", 0x2, 0),
+/* v9 */ fmovrq("fmovrqgz", 0x6, 0),
+/* v9 */ fmovrq("fmovrqnz", 0x5, F_ALIAS),
+/* v9 */ fmovrq("fmovrqz", 0x1, F_ALIAS),
+
+#undef movr /* v9 */
+#undef fmovr /* v9 */
+#undef fmrr /* v9 */
+
+#define movicc(opcode, cond, flags) /* v9 */ \
+ { opcode, F3(2, 0x2c, 0)|MCOND(cond,1)|ICC, F3(~2, ~0x2c, ~0)|MCOND(~cond,~1)|XCC|(1<<11), "z,2,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 1)|MCOND(cond,1)|ICC, F3(~2, ~0x2c, ~1)|MCOND(~cond,~1)|XCC|(1<<11), "z,I,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 0)|MCOND(cond,1)|XCC, F3(~2, ~0x2c, ~0)|MCOND(~cond,~1)|(1<<11), "Z,2,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 1)|MCOND(cond,1)|XCC, F3(~2, ~0x2c, ~1)|MCOND(~cond,~1)|(1<<11), "Z,I,d", flags, v9 }
+
+#define movfcc(opcode, fcond, flags) /* v9 */ \
+ { opcode, F3(2, 0x2c, 0)|FCC(0)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~0)|F3(~2, ~0x2c, ~0), "6,2,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 1)|FCC(0)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~0)|F3(~2, ~0x2c, ~1), "6,I,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 0)|FCC(1)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~1)|F3(~2, ~0x2c, ~0), "7,2,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 1)|FCC(1)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~1)|F3(~2, ~0x2c, ~1), "7,I,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 0)|FCC(2)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~2)|F3(~2, ~0x2c, ~0), "8,2,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 1)|FCC(2)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~2)|F3(~2, ~0x2c, ~1), "8,I,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 0)|FCC(3)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~3)|F3(~2, ~0x2c, ~0), "9,2,d", flags, v9 }, \
+ { opcode, F3(2, 0x2c, 1)|FCC(3)|MCOND(fcond,0), MCOND(~fcond,~0)|FCC(~3)|F3(~2, ~0x2c, ~1), "9,I,d", flags, v9 }
+
+#define movcc(opcode, cond, fcond, flags) /* v9 */ \
+ movfcc (opcode, fcond, flags), /* v9 */ \
+ movicc (opcode, cond, flags) /* v9 */
+
+/* v9 */ movcc ("mova", CONDA, FCONDA, 0),
+/* v9 */ movicc ("movcc", CONDCC, 0),
+/* v9 */ movicc ("movgeu", CONDGEU, F_ALIAS),
+/* v9 */ movicc ("movcs", CONDCS, 0),
+/* v9 */ movicc ("movlu", CONDLU, F_ALIAS),
+/* v9 */ movcc ("move", CONDE, FCONDE, 0),
+/* v9 */ movcc ("movg", CONDG, FCONDG, 0),
+/* v9 */ movcc ("movge", CONDGE, FCONDGE, 0),
+/* v9 */ movicc ("movgu", CONDGU, 0),
+/* v9 */ movcc ("movl", CONDL, FCONDL, 0),
+/* v9 */ movcc ("movle", CONDLE, FCONDLE, 0),
+/* v9 */ movicc ("movleu", CONDLEU, 0),
+/* v9 */ movfcc ("movlg", FCONDLG, 0),
+/* v9 */ movcc ("movn", CONDN, FCONDN, 0),
+/* v9 */ movcc ("movne", CONDNE, FCONDNE, 0),
+/* v9 */ movicc ("movneg", CONDNEG, 0),
+/* v9 */ movcc ("movnz", CONDNZ, FCONDNZ, F_ALIAS),
+/* v9 */ movfcc ("movo", FCONDO, 0),
+/* v9 */ movicc ("movpos", CONDPOS, 0),
+/* v9 */ movfcc ("movu", FCONDU, 0),
+/* v9 */ movfcc ("movue", FCONDUE, 0),
+/* v9 */ movfcc ("movug", FCONDUG, 0),
+/* v9 */ movfcc ("movuge", FCONDUGE, 0),
+/* v9 */ movfcc ("movul", FCONDUL, 0),
+/* v9 */ movfcc ("movule", FCONDULE, 0),
+/* v9 */ movicc ("movvc", CONDVC, 0),
+/* v9 */ movicc ("movvs", CONDVS, 0),
+/* v9 */ movcc ("movz", CONDZ, FCONDZ, F_ALIAS),
+
+#undef movicc /* v9 */
+#undef movfcc /* v9 */
+#undef movcc /* v9 */
+
+#define FM_SF 1 /* v9 - values for fpsize */
+#define FM_DF 2 /* v9 */
+#define FM_QF 3 /* v9 */
+
+#define fmovicc(opcode, fpsize, cond, flags) /* v9 */ \
+{ opcode, F3F(2, 0x35, 0x100+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x100+fpsize))|MCOND(~cond,~0), "z,f,g", flags, v9 }, \
+{ opcode, F3F(2, 0x35, 0x180+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x180+fpsize))|MCOND(~cond,~0), "Z,f,g", flags, v9 }
+
+#define fmovfcc(opcode, fpsize, fcond, flags) /* v9 */ \
+{ opcode, F3F(2, 0x35, 0x000+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x000+fpsize))|MCOND(~fcond,~0), "6,f,g", flags, v9 }, \
+{ opcode, F3F(2, 0x35, 0x040+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x040+fpsize))|MCOND(~fcond,~0), "7,f,g", flags, v9 }, \
+{ opcode, F3F(2, 0x35, 0x080+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x080+fpsize))|MCOND(~fcond,~0), "8,f,g", flags, v9 }, \
+{ opcode, F3F(2, 0x35, 0x0c0+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x0c0+fpsize))|MCOND(~fcond,~0), "9,f,g", flags, v9 }
+
+/* FIXME: use fmovicc/fmovfcc? */ /* v9 */
+#define fmovcc(opcode, fpsize, cond, fcond, flags) /* v9 */ \
+{ opcode, F3F(2, 0x35, 0x100+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x100+fpsize))|MCOND(~cond,~0), "z,f,g", flags | F_FLOAT, v9 }, \
+{ opcode, F3F(2, 0x35, 0x000+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x000+fpsize))|MCOND(~fcond,~0), "6,f,g", flags | F_FLOAT, v9 }, \
+{ opcode, F3F(2, 0x35, 0x180+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x180+fpsize))|MCOND(~cond,~0), "Z,f,g", flags | F_FLOAT, v9 }, \
+{ opcode, F3F(2, 0x35, 0x040+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x040+fpsize))|MCOND(~fcond,~0), "7,f,g", flags | F_FLOAT, v9 }, \
+{ opcode, F3F(2, 0x35, 0x080+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x080+fpsize))|MCOND(~fcond,~0), "8,f,g", flags | F_FLOAT, v9 }, \
+{ opcode, F3F(2, 0x35, 0x0c0+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x0c0+fpsize))|MCOND(~fcond,~0), "9,f,g", flags | F_FLOAT, v9 }
+
+/* v9 */ fmovcc ("fmovda", FM_DF, CONDA, FCONDA, 0),
+/* v9 */ fmovcc ("fmovqa", FM_QF, CONDA, FCONDA, 0),
+/* v9 */ fmovcc ("fmovsa", FM_SF, CONDA, FCONDA, 0),
+/* v9 */ fmovicc ("fmovdcc", FM_DF, CONDCC, 0),
+/* v9 */ fmovicc ("fmovqcc", FM_QF, CONDCC, 0),
+/* v9 */ fmovicc ("fmovscc", FM_SF, CONDCC, 0),
+/* v9 */ fmovicc ("fmovdcs", FM_DF, CONDCS, 0),
+/* v9 */ fmovicc ("fmovqcs", FM_QF, CONDCS, 0),
+/* v9 */ fmovicc ("fmovscs", FM_SF, CONDCS, 0),
+/* v9 */ fmovcc ("fmovde", FM_DF, CONDE, FCONDE, 0),
+/* v9 */ fmovcc ("fmovqe", FM_QF, CONDE, FCONDE, 0),
+/* v9 */ fmovcc ("fmovse", FM_SF, CONDE, FCONDE, 0),
+/* v9 */ fmovcc ("fmovdg", FM_DF, CONDG, FCONDG, 0),
+/* v9 */ fmovcc ("fmovqg", FM_QF, CONDG, FCONDG, 0),
+/* v9 */ fmovcc ("fmovsg", FM_SF, CONDG, FCONDG, 0),
+/* v9 */ fmovcc ("fmovdge", FM_DF, CONDGE, FCONDGE, 0),
+/* v9 */ fmovcc ("fmovqge", FM_QF, CONDGE, FCONDGE, 0),
+/* v9 */ fmovcc ("fmovsge", FM_SF, CONDGE, FCONDGE, 0),
+/* v9 */ fmovicc ("fmovdgeu", FM_DF, CONDGEU, F_ALIAS),
+/* v9 */ fmovicc ("fmovqgeu", FM_QF, CONDGEU, F_ALIAS),
+/* v9 */ fmovicc ("fmovsgeu", FM_SF, CONDGEU, F_ALIAS),
+/* v9 */ fmovicc ("fmovdgu", FM_DF, CONDGU, 0),
+/* v9 */ fmovicc ("fmovqgu", FM_QF, CONDGU, 0),
+/* v9 */ fmovicc ("fmovsgu", FM_SF, CONDGU, 0),
+/* v9 */ fmovcc ("fmovdl", FM_DF, CONDL, FCONDL, 0),
+/* v9 */ fmovcc ("fmovql", FM_QF, CONDL, FCONDL, 0),
+/* v9 */ fmovcc ("fmovsl", FM_SF, CONDL, FCONDL, 0),
+/* v9 */ fmovcc ("fmovdle", FM_DF, CONDLE, FCONDLE, 0),
+/* v9 */ fmovcc ("fmovqle", FM_QF, CONDLE, FCONDLE, 0),
+/* v9 */ fmovcc ("fmovsle", FM_SF, CONDLE, FCONDLE, 0),
+/* v9 */ fmovicc ("fmovdleu", FM_DF, CONDLEU, 0),
+/* v9 */ fmovicc ("fmovqleu", FM_QF, CONDLEU, 0),
+/* v9 */ fmovicc ("fmovsleu", FM_SF, CONDLEU, 0),
+/* v9 */ fmovfcc ("fmovdlg", FM_DF, FCONDLG, 0),
+/* v9 */ fmovfcc ("fmovqlg", FM_QF, FCONDLG, 0),
+/* v9 */ fmovfcc ("fmovslg", FM_SF, FCONDLG, 0),
+/* v9 */ fmovicc ("fmovdlu", FM_DF, CONDLU, F_ALIAS),
+/* v9 */ fmovicc ("fmovqlu", FM_QF, CONDLU, F_ALIAS),
+/* v9 */ fmovicc ("fmovslu", FM_SF, CONDLU, F_ALIAS),
+/* v9 */ fmovcc ("fmovdn", FM_DF, CONDN, FCONDN, 0),
+/* v9 */ fmovcc ("fmovqn", FM_QF, CONDN, FCONDN, 0),
+/* v9 */ fmovcc ("fmovsn", FM_SF, CONDN, FCONDN, 0),
+/* v9 */ fmovcc ("fmovdne", FM_DF, CONDNE, FCONDNE, 0),
+/* v9 */ fmovcc ("fmovqne", FM_QF, CONDNE, FCONDNE, 0),
+/* v9 */ fmovcc ("fmovsne", FM_SF, CONDNE, FCONDNE, 0),
+/* v9 */ fmovicc ("fmovdneg", FM_DF, CONDNEG, 0),
+/* v9 */ fmovicc ("fmovqneg", FM_QF, CONDNEG, 0),
+/* v9 */ fmovicc ("fmovsneg", FM_SF, CONDNEG, 0),
+/* v9 */ fmovcc ("fmovdnz", FM_DF, CONDNZ, FCONDNZ, F_ALIAS),
+/* v9 */ fmovcc ("fmovqnz", FM_QF, CONDNZ, FCONDNZ, F_ALIAS),
+/* v9 */ fmovcc ("fmovsnz", FM_SF, CONDNZ, FCONDNZ, F_ALIAS),
+/* v9 */ fmovfcc ("fmovdo", FM_DF, FCONDO, 0),
+/* v9 */ fmovfcc ("fmovqo", FM_QF, FCONDO, 0),
+/* v9 */ fmovfcc ("fmovso", FM_SF, FCONDO, 0),
+/* v9 */ fmovicc ("fmovdpos", FM_DF, CONDPOS, 0),
+/* v9 */ fmovicc ("fmovqpos", FM_QF, CONDPOS, 0),
+/* v9 */ fmovicc ("fmovspos", FM_SF, CONDPOS, 0),
+/* v9 */ fmovfcc ("fmovdu", FM_DF, FCONDU, 0),
+/* v9 */ fmovfcc ("fmovqu", FM_QF, FCONDU, 0),
+/* v9 */ fmovfcc ("fmovsu", FM_SF, FCONDU, 0),
+/* v9 */ fmovfcc ("fmovdue", FM_DF, FCONDUE, 0),
+/* v9 */ fmovfcc ("fmovque", FM_QF, FCONDUE, 0),
+/* v9 */ fmovfcc ("fmovsue", FM_SF, FCONDUE, 0),
+/* v9 */ fmovfcc ("fmovdug", FM_DF, FCONDUG, 0),
+/* v9 */ fmovfcc ("fmovqug", FM_QF, FCONDUG, 0),
+/* v9 */ fmovfcc ("fmovsug", FM_SF, FCONDUG, 0),
+/* v9 */ fmovfcc ("fmovduge", FM_DF, FCONDUGE, 0),
+/* v9 */ fmovfcc ("fmovquge", FM_QF, FCONDUGE, 0),
+/* v9 */ fmovfcc ("fmovsuge", FM_SF, FCONDUGE, 0),
+/* v9 */ fmovfcc ("fmovdul", FM_DF, FCONDUL, 0),
+/* v9 */ fmovfcc ("fmovqul", FM_QF, FCONDUL, 0),
+/* v9 */ fmovfcc ("fmovsul", FM_SF, FCONDUL, 0),
+/* v9 */ fmovfcc ("fmovdule", FM_DF, FCONDULE, 0),
+/* v9 */ fmovfcc ("fmovqule", FM_QF, FCONDULE, 0),
+/* v9 */ fmovfcc ("fmovsule", FM_SF, FCONDULE, 0),
+/* v9 */ fmovicc ("fmovdvc", FM_DF, CONDVC, 0),
+/* v9 */ fmovicc ("fmovqvc", FM_QF, CONDVC, 0),
+/* v9 */ fmovicc ("fmovsvc", FM_SF, CONDVC, 0),
+/* v9 */ fmovicc ("fmovdvs", FM_DF, CONDVS, 0),
+/* v9 */ fmovicc ("fmovqvs", FM_QF, CONDVS, 0),
+/* v9 */ fmovicc ("fmovsvs", FM_SF, CONDVS, 0),
+/* v9 */ fmovcc ("fmovdz", FM_DF, CONDZ, FCONDZ, F_ALIAS),
+/* v9 */ fmovcc ("fmovqz", FM_QF, CONDZ, FCONDZ, F_ALIAS),
+/* v9 */ fmovcc ("fmovsz", FM_SF, CONDZ, FCONDZ, F_ALIAS),
+
+#undef fmovicc /* v9 */
+#undef fmovfcc /* v9 */
+#undef fmovcc /* v9 */
+#undef FM_DF /* v9 */
+#undef FM_QF /* v9 */
+#undef FM_SF /* v9 */
+
+/* Coprocessor branches. */
+#define CBR(opcode, mask, lose, flags, arch) \
+ { opcode, (mask), ANNUL|(lose), "l", flags|F_DELAYED, arch }, \
+ { opcode, (mask)|ANNUL, (lose), ",a l", flags|F_DELAYED, arch }
+
+/* Floating point branches. */
+#define FBR(opcode, mask, lose, flags) \
+ { opcode, (mask), ANNUL|(lose), "l", flags|F_DELAYED|F_FBR, v6 }, \
+ { opcode, (mask)|ANNUL, (lose), ",a l", flags|F_DELAYED|F_FBR, v6 }
+
+/* V9 extended floating point branches. */
+#define FBRX(opcode, mask, lose, flags) /* v9 */ \
+ { opcode, FBFCC(0)|(mask)|BPRED, ANNUL|FBFCC(~0)|(lose), "6,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(0)|(mask)|BPRED, ANNUL|FBFCC(~0)|(lose), ",T 6,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(0)|(mask)|BPRED|ANNUL, FBFCC(~0)|(lose), ",a 6,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(0)|(mask)|BPRED|ANNUL, FBFCC(~0)|(lose), ",a,T 6,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(0)|(mask), ANNUL|BPRED|FBFCC(~0)|(lose), ",N 6,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(0)|(mask)|ANNUL, BPRED|FBFCC(~0)|(lose), ",a,N 6,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(1)|(mask)|BPRED, ANNUL|FBFCC(~1)|(lose), "7,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(1)|(mask)|BPRED, ANNUL|FBFCC(~1)|(lose), ",T 7,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(1)|(mask)|BPRED|ANNUL, FBFCC(~1)|(lose), ",a 7,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(1)|(mask)|BPRED|ANNUL, FBFCC(~1)|(lose), ",a,T 7,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(1)|(mask), ANNUL|BPRED|FBFCC(~1)|(lose), ",N 7,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(1)|(mask)|ANNUL, BPRED|FBFCC(~1)|(lose), ",a,N 7,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(2)|(mask)|BPRED, ANNUL|FBFCC(~2)|(lose), "8,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(2)|(mask)|BPRED, ANNUL|FBFCC(~2)|(lose), ",T 8,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(2)|(mask)|BPRED|ANNUL, FBFCC(~2)|(lose), ",a 8,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(2)|(mask)|BPRED|ANNUL, FBFCC(~2)|(lose), ",a,T 8,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(2)|(mask), ANNUL|BPRED|FBFCC(~2)|(lose), ",N 8,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(2)|(mask)|ANNUL, BPRED|FBFCC(~2)|(lose), ",a,N 8,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(3)|(mask)|BPRED, ANNUL|FBFCC(~3)|(lose), "9,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(3)|(mask)|BPRED, ANNUL|FBFCC(~3)|(lose), ",T 9,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(3)|(mask)|BPRED|ANNUL, FBFCC(~3)|(lose), ",a 9,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(3)|(mask)|BPRED|ANNUL, FBFCC(~3)|(lose), ",a,T 9,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(3)|(mask), ANNUL|BPRED|FBFCC(~3)|(lose), ",N 9,G", flags|F_DELAYED|F_FBR, v9 }, \
+ { opcode, FBFCC(3)|(mask)|ANNUL, BPRED|FBFCC(~3)|(lose), ",a,N 9,G", flags|F_DELAYED|F_FBR, v9 }
+
+/* v9: We must put `FBRX' before `FBR', to ensure that we never match
+ v9: something against an expression unless it is an expression. Otherwise,
+ v9: we end up with undefined symbol tables entries, because they get added,
+ v9: but are not deleted if the pattern fails to match. */
+
+#define CONDFC(fop, cop, mask, flags) \
+ FBRX(fop, F2(0, 5)|COND(mask), F2(~0, ~5)|COND(~(mask)), flags), /* v9 */ \
+ FBR(fop, F2(0, 6)|COND(mask), F2(~0, ~6)|COND(~(mask)), flags), \
+ CBR(cop, F2(0, 7)|COND(mask), F2(~0, ~7)|COND(~(mask)), flags, v6notlet)
+
+#define CONDFCL(fop, cop, mask, flags) \
+ FBRX(fop, F2(0, 5)|COND(mask), F2(~0, ~5)|COND(~(mask)), flags), /* v9 */ \
+ FBR(fop, F2(0, 6)|COND(mask), F2(~0, ~6)|COND(~(mask)), flags), \
+ CBR(cop, F2(0, 7)|COND(mask), F2(~0, ~7)|COND(~(mask)), flags, v6)
+
+#define CONDF(fop, mask, flags) \
+ FBRX(fop, F2(0, 5)|COND(mask), F2(~0, ~5)|COND(~(mask)), flags), /* v9 */ \
+ FBR(fop, F2(0, 6)|COND(mask), F2(~0, ~6)|COND(~(mask)), flags)
+
+CONDFC ("fb", "cb", 0x8, 0),
+CONDFCL ("fba", "cba", 0x8, F_ALIAS),
+CONDFC ("fbe", "cb0", 0x9, 0),
+CONDF ("fbz", 0x9, F_ALIAS),
+CONDFC ("fbg", "cb2", 0x6, 0),
+CONDFC ("fbge", "cb02", 0xb, 0),
+CONDFC ("fbl", "cb1", 0x4, 0),
+CONDFC ("fble", "cb01", 0xd, 0),
+CONDFC ("fblg", "cb12", 0x2, 0),
+CONDFCL ("fbn", "cbn", 0x0, 0),
+CONDFC ("fbne", "cb123", 0x1, 0),
+CONDF ("fbnz", 0x1, F_ALIAS),
+CONDFC ("fbo", "cb012", 0xf, 0),
+CONDFC ("fbu", "cb3", 0x7, 0),
+CONDFC ("fbue", "cb03", 0xa, 0),
+CONDFC ("fbug", "cb23", 0x5, 0),
+CONDFC ("fbuge", "cb023", 0xc, 0),
+CONDFC ("fbul", "cb13", 0x3, 0),
+CONDFC ("fbule", "cb013", 0xe, 0),
+
+#undef CONDFC
+#undef CONDFCL
+#undef CONDF
+#undef CBR
+#undef FBR
+#undef FBRX /* v9 */
+
+{ "jmp", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|RD_G0|ASI(~0), "1+2", F_UNBR|F_DELAYED, v6 }, /* jmpl rs1+rs2,%g0 */
+{ "jmp", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|RD_G0|ASI_RS2(~0), "1", F_UNBR|F_DELAYED, v6 }, /* jmpl rs1+%g0,%g0 */
+{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0, "1+i", F_UNBR|F_DELAYED, v6 }, /* jmpl rs1+i,%g0 */
+{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0, "i+1", F_UNBR|F_DELAYED, v6 }, /* jmpl i+rs1,%g0 */
+{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0|RS1_G0, "i", F_UNBR|F_DELAYED, v6 }, /* jmpl %g0+i,%g0 */
+{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0|SIMM13(~0), "1", F_UNBR|F_DELAYED, v6 }, /* jmpl rs1+0,%g0 */
+
+{ "nop", F2(0, 4), 0xfeffffff, "", 0, v6 }, /* sethi 0, %g0 */
+
+{ "set", F2(0x0, 0x4), F2(~0x0, ~0x4), "Sh,d", F_ALIAS, v6 },
+{ "setuw", F2(0x0, 0x4), F2(~0x0, ~0x4), "Sh,d", F_ALIAS, v9 },
+{ "setsw", F2(0x0, 0x4), F2(~0x0, ~0x4), "Sh,d", F_ALIAS, v9 },
+{ "setx", F2(0x0, 0x4), F2(~0x0, ~0x4), "S0,1,d", F_ALIAS, v9 },
+
+{ "sethi", F2(0x0, 0x4), F2(~0x0, ~0x4), "h,d", 0, v6 },
+
+{ "taddcc", F3(2, 0x20, 0), F3(~2, ~0x20, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "taddcc", F3(2, 0x20, 1), F3(~2, ~0x20, ~1), "1,i,d", 0, v6 },
+{ "taddcc", F3(2, 0x20, 1), F3(~2, ~0x20, ~1), "i,1,d", 0, v6 },
+{ "taddcctv", F3(2, 0x22, 0), F3(~2, ~0x22, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "taddcctv", F3(2, 0x22, 1), F3(~2, ~0x22, ~1), "1,i,d", 0, v6 },
+{ "taddcctv", F3(2, 0x22, 1), F3(~2, ~0x22, ~1), "i,1,d", 0, v6 },
+
+{ "tsubcc", F3(2, 0x21, 0), F3(~2, ~0x21, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "tsubcc", F3(2, 0x21, 1), F3(~2, ~0x21, ~1), "1,i,d", 0, v6 },
+{ "tsubcctv", F3(2, 0x23, 0), F3(~2, ~0x23, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "tsubcctv", F3(2, 0x23, 1), F3(~2, ~0x23, ~1), "1,i,d", 0, v6 },
+
+{ "unimp", F2(0x0, 0x0), 0xffc00000, "n", 0, v6notv9 },
+{ "illtrap", F2(0, 0), F2(~0, ~0)|RD_G0, "n", 0, v9 },
+
+/* This *is* a commutative instruction. */
+{ "xnor", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "xnor", F3(2, 0x07, 1), F3(~2, ~0x07, ~1), "1,i,d", 0, v6 },
+{ "xnor", F3(2, 0x07, 1), F3(~2, ~0x07, ~1), "i,1,d", 0, v6 },
+/* This *is* a commutative instruction. */
+{ "xnorcc", F3(2, 0x17, 0), F3(~2, ~0x17, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "xnorcc", F3(2, 0x17, 1), F3(~2, ~0x17, ~1), "1,i,d", 0, v6 },
+{ "xnorcc", F3(2, 0x17, 1), F3(~2, ~0x17, ~1), "i,1,d", 0, v6 },
+{ "xor", F3(2, 0x03, 0), F3(~2, ~0x03, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "xor", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "1,i,d", 0, v6 },
+{ "xor", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "i,1,d", 0, v6 },
+{ "xorcc", F3(2, 0x13, 0), F3(~2, ~0x13, ~0)|ASI(~0), "1,2,d", 0, v6 },
+{ "xorcc", F3(2, 0x13, 1), F3(~2, ~0x13, ~1), "1,i,d", 0, v6 },
+{ "xorcc", F3(2, 0x13, 1), F3(~2, ~0x13, ~1), "i,1,d", 0, v6 },
+
+{ "not", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "1,d", F_ALIAS, v6 }, /* xnor rs1,%0,rd */
+{ "not", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "r", F_ALIAS, v6 }, /* xnor rd,%0,rd */
+
+{ "btog", F3(2, 0x03, 0), F3(~2, ~0x03, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* xor rd,rs2,rd */
+{ "btog", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "i,r", F_ALIAS, v6 }, /* xor rd,i,rd */
+
+/* FPop1 and FPop2 are not instructions. Don't accept them. */
+
+{ "fdtoi", F3F(2, 0x34, 0x0d2), F3F(~2, ~0x34, ~0x0d2)|RS1_G0, "B,g", F_FLOAT, v6 },
+{ "fstoi", F3F(2, 0x34, 0x0d1), F3F(~2, ~0x34, ~0x0d1)|RS1_G0, "f,g", F_FLOAT, v6 },
+{ "fqtoi", F3F(2, 0x34, 0x0d3), F3F(~2, ~0x34, ~0x0d3)|RS1_G0, "R,g", F_FLOAT, v8 },
+
+{ "fdtox", F3F(2, 0x34, 0x082), F3F(~2, ~0x34, ~0x082)|RS1_G0, "B,g", F_FLOAT, v9 },
+{ "fstox", F3F(2, 0x34, 0x081), F3F(~2, ~0x34, ~0x081)|RS1_G0, "f,g", F_FLOAT, v9 },
+{ "fqtox", F3F(2, 0x34, 0x083), F3F(~2, ~0x34, ~0x083)|RS1_G0, "R,g", F_FLOAT, v9 },
+
+{ "fitod", F3F(2, 0x34, 0x0c8), F3F(~2, ~0x34, ~0x0c8)|RS1_G0, "f,H", F_FLOAT, v6 },
+{ "fitos", F3F(2, 0x34, 0x0c4), F3F(~2, ~0x34, ~0x0c4)|RS1_G0, "f,g", F_FLOAT, v6 },
+{ "fitoq", F3F(2, 0x34, 0x0cc), F3F(~2, ~0x34, ~0x0cc)|RS1_G0, "f,J", F_FLOAT, v8 },
+
+{ "fxtod", F3F(2, 0x34, 0x088), F3F(~2, ~0x34, ~0x088)|RS1_G0, "f,H", F_FLOAT, v9 },
+{ "fxtos", F3F(2, 0x34, 0x084), F3F(~2, ~0x34, ~0x084)|RS1_G0, "f,g", F_FLOAT, v9 },
+{ "fxtoq", F3F(2, 0x34, 0x08c), F3F(~2, ~0x34, ~0x08c)|RS1_G0, "f,J", F_FLOAT, v9 },
+
+{ "fdtoq", F3F(2, 0x34, 0x0ce), F3F(~2, ~0x34, ~0x0ce)|RS1_G0, "B,J", F_FLOAT, v8 },
+{ "fdtos", F3F(2, 0x34, 0x0c6), F3F(~2, ~0x34, ~0x0c6)|RS1_G0, "B,g", F_FLOAT, v6 },
+{ "fqtod", F3F(2, 0x34, 0x0cb), F3F(~2, ~0x34, ~0x0cb)|RS1_G0, "R,H", F_FLOAT, v8 },
+{ "fqtos", F3F(2, 0x34, 0x0c7), F3F(~2, ~0x34, ~0x0c7)|RS1_G0, "R,g", F_FLOAT, v8 },
+{ "fstod", F3F(2, 0x34, 0x0c9), F3F(~2, ~0x34, ~0x0c9)|RS1_G0, "f,H", F_FLOAT, v6 },
+{ "fstoq", F3F(2, 0x34, 0x0cd), F3F(~2, ~0x34, ~0x0cd)|RS1_G0, "f,J", F_FLOAT, v8 },
+
+{ "fdivd", F3F(2, 0x34, 0x04e), F3F(~2, ~0x34, ~0x04e), "v,B,H", F_FLOAT, v6 },
+{ "fdivq", F3F(2, 0x34, 0x04f), F3F(~2, ~0x34, ~0x04f), "V,R,J", F_FLOAT, v8 },
+{ "fdivs", F3F(2, 0x34, 0x04d), F3F(~2, ~0x34, ~0x04d), "e,f,g", F_FLOAT, v6 },
+{ "fmuld", F3F(2, 0x34, 0x04a), F3F(~2, ~0x34, ~0x04a), "v,B,H", F_FLOAT, v6 },
+{ "fmulq", F3F(2, 0x34, 0x04b), F3F(~2, ~0x34, ~0x04b), "V,R,J", F_FLOAT, v8 },
+{ "fmuls", F3F(2, 0x34, 0x049), F3F(~2, ~0x34, ~0x049), "e,f,g", F_FLOAT, v6 },
+
+{ "fdmulq", F3F(2, 0x34, 0x06e), F3F(~2, ~0x34, ~0x06e), "v,B,J", F_FLOAT, v8 },
+{ "fsmuld", F3F(2, 0x34, 0x069), F3F(~2, ~0x34, ~0x069), "e,f,H", F_FLOAT, v8 },
+
+{ "fsqrtd", F3F(2, 0x34, 0x02a), F3F(~2, ~0x34, ~0x02a)|RS1_G0, "B,H", F_FLOAT, v7 },
+{ "fsqrtq", F3F(2, 0x34, 0x02b), F3F(~2, ~0x34, ~0x02b)|RS1_G0, "R,J", F_FLOAT, v8 },
+{ "fsqrts", F3F(2, 0x34, 0x029), F3F(~2, ~0x34, ~0x029)|RS1_G0, "f,g", F_FLOAT, v7 },
+
+{ "fabsd", F3F(2, 0x34, 0x00a), F3F(~2, ~0x34, ~0x00a)|RS1_G0, "B,H", F_FLOAT, v9 },
+{ "fabsq", F3F(2, 0x34, 0x00b), F3F(~2, ~0x34, ~0x00b)|RS1_G0, "R,J", F_FLOAT, v9 },
+{ "fabss", F3F(2, 0x34, 0x009), F3F(~2, ~0x34, ~0x009)|RS1_G0, "f,g", F_FLOAT, v6 },
+{ "fmovd", F3F(2, 0x34, 0x002), F3F(~2, ~0x34, ~0x002)|RS1_G0, "B,H", F_FLOAT, v9 },
+{ "fmovq", F3F(2, 0x34, 0x003), F3F(~2, ~0x34, ~0x003)|RS1_G0, "R,J", F_FLOAT, v9 },
+{ "fmovs", F3F(2, 0x34, 0x001), F3F(~2, ~0x34, ~0x001)|RS1_G0, "f,g", F_FLOAT, v6 },
+{ "fnegd", F3F(2, 0x34, 0x006), F3F(~2, ~0x34, ~0x006)|RS1_G0, "B,H", F_FLOAT, v9 },
+{ "fnegq", F3F(2, 0x34, 0x007), F3F(~2, ~0x34, ~0x007)|RS1_G0, "R,J", F_FLOAT, v9 },
+{ "fnegs", F3F(2, 0x34, 0x005), F3F(~2, ~0x34, ~0x005)|RS1_G0, "f,g", F_FLOAT, v6 },
+
+{ "faddd", F3F(2, 0x34, 0x042), F3F(~2, ~0x34, ~0x042), "v,B,H", F_FLOAT, v6 },
+{ "faddq", F3F(2, 0x34, 0x043), F3F(~2, ~0x34, ~0x043), "V,R,J", F_FLOAT, v8 },
+{ "fadds", F3F(2, 0x34, 0x041), F3F(~2, ~0x34, ~0x041), "e,f,g", F_FLOAT, v6 },
+{ "fsubd", F3F(2, 0x34, 0x046), F3F(~2, ~0x34, ~0x046), "v,B,H", F_FLOAT, v6 },
+{ "fsubq", F3F(2, 0x34, 0x047), F3F(~2, ~0x34, ~0x047), "V,R,J", F_FLOAT, v8 },
+{ "fsubs", F3F(2, 0x34, 0x045), F3F(~2, ~0x34, ~0x045), "e,f,g", F_FLOAT, v6 },
+
+#define CMPFCC(x) (((x)&0x3)<<25)
+
+{ "fcmpd", F3F(2, 0x35, 0x052), F3F(~2, ~0x35, ~0x052)|RD_G0, "v,B", F_FLOAT, v6 },
+{ "fcmpd", CMPFCC(0)|F3F(2, 0x35, 0x052), CMPFCC(~0)|F3F(~2, ~0x35, ~0x052), "6,v,B", F_FLOAT, v9 },
+{ "fcmpd", CMPFCC(1)|F3F(2, 0x35, 0x052), CMPFCC(~1)|F3F(~2, ~0x35, ~0x052), "7,v,B", F_FLOAT, v9 },
+{ "fcmpd", CMPFCC(2)|F3F(2, 0x35, 0x052), CMPFCC(~2)|F3F(~2, ~0x35, ~0x052), "8,v,B", F_FLOAT, v9 },
+{ "fcmpd", CMPFCC(3)|F3F(2, 0x35, 0x052), CMPFCC(~3)|F3F(~2, ~0x35, ~0x052), "9,v,B", F_FLOAT, v9 },
+{ "fcmped", F3F(2, 0x35, 0x056), F3F(~2, ~0x35, ~0x056)|RD_G0, "v,B", F_FLOAT, v6 },
+{ "fcmped", CMPFCC(0)|F3F(2, 0x35, 0x056), CMPFCC(~0)|F3F(~2, ~0x35, ~0x056), "6,v,B", F_FLOAT, v9 },
+{ "fcmped", CMPFCC(1)|F3F(2, 0x35, 0x056), CMPFCC(~1)|F3F(~2, ~0x35, ~0x056), "7,v,B", F_FLOAT, v9 },
+{ "fcmped", CMPFCC(2)|F3F(2, 0x35, 0x056), CMPFCC(~2)|F3F(~2, ~0x35, ~0x056), "8,v,B", F_FLOAT, v9 },
+{ "fcmped", CMPFCC(3)|F3F(2, 0x35, 0x056), CMPFCC(~3)|F3F(~2, ~0x35, ~0x056), "9,v,B", F_FLOAT, v9 },
+{ "fcmpq", F3F(2, 0x35, 0x053), F3F(~2, ~0x35, ~0x053)|RD_G0, "V,R", F_FLOAT, v8 },
+{ "fcmpq", CMPFCC(0)|F3F(2, 0x35, 0x053), CMPFCC(~0)|F3F(~2, ~0x35, ~0x053), "6,V,R", F_FLOAT, v9 },
+{ "fcmpq", CMPFCC(1)|F3F(2, 0x35, 0x053), CMPFCC(~1)|F3F(~2, ~0x35, ~0x053), "7,V,R", F_FLOAT, v9 },
+{ "fcmpq", CMPFCC(2)|F3F(2, 0x35, 0x053), CMPFCC(~2)|F3F(~2, ~0x35, ~0x053), "8,V,R", F_FLOAT, v9 },
+{ "fcmpq", CMPFCC(3)|F3F(2, 0x35, 0x053), CMPFCC(~3)|F3F(~2, ~0x35, ~0x053), "9,V,R", F_FLOAT, v9 },
+{ "fcmpeq", F3F(2, 0x35, 0x057), F3F(~2, ~0x35, ~0x057)|RD_G0, "V,R", F_FLOAT, v8 },
+{ "fcmpeq", CMPFCC(0)|F3F(2, 0x35, 0x057), CMPFCC(~0)|F3F(~2, ~0x35, ~0x057), "6,V,R", F_FLOAT, v9 },
+{ "fcmpeq", CMPFCC(1)|F3F(2, 0x35, 0x057), CMPFCC(~1)|F3F(~2, ~0x35, ~0x057), "7,V,R", F_FLOAT, v9 },
+{ "fcmpeq", CMPFCC(2)|F3F(2, 0x35, 0x057), CMPFCC(~2)|F3F(~2, ~0x35, ~0x057), "8,V,R", F_FLOAT, v9 },
+{ "fcmpeq", CMPFCC(3)|F3F(2, 0x35, 0x057), CMPFCC(~3)|F3F(~2, ~0x35, ~0x057), "9,V,R", F_FLOAT, v9 },
+{ "fcmps", F3F(2, 0x35, 0x051), F3F(~2, ~0x35, ~0x051)|RD_G0, "e,f", F_FLOAT, v6 },
+{ "fcmps", CMPFCC(0)|F3F(2, 0x35, 0x051), CMPFCC(~0)|F3F(~2, ~0x35, ~0x051), "6,e,f", F_FLOAT, v9 },
+{ "fcmps", CMPFCC(1)|F3F(2, 0x35, 0x051), CMPFCC(~1)|F3F(~2, ~0x35, ~0x051), "7,e,f", F_FLOAT, v9 },
+{ "fcmps", CMPFCC(2)|F3F(2, 0x35, 0x051), CMPFCC(~2)|F3F(~2, ~0x35, ~0x051), "8,e,f", F_FLOAT, v9 },
+{ "fcmps", CMPFCC(3)|F3F(2, 0x35, 0x051), CMPFCC(~3)|F3F(~2, ~0x35, ~0x051), "9,e,f", F_FLOAT, v9 },
+{ "fcmpes", F3F(2, 0x35, 0x055), F3F(~2, ~0x35, ~0x055)|RD_G0, "e,f", F_FLOAT, v6 },
+{ "fcmpes", CMPFCC(0)|F3F(2, 0x35, 0x055), CMPFCC(~0)|F3F(~2, ~0x35, ~0x055), "6,e,f", F_FLOAT, v9 },
+{ "fcmpes", CMPFCC(1)|F3F(2, 0x35, 0x055), CMPFCC(~1)|F3F(~2, ~0x35, ~0x055), "7,e,f", F_FLOAT, v9 },
+{ "fcmpes", CMPFCC(2)|F3F(2, 0x35, 0x055), CMPFCC(~2)|F3F(~2, ~0x35, ~0x055), "8,e,f", F_FLOAT, v9 },
+{ "fcmpes", CMPFCC(3)|F3F(2, 0x35, 0x055), CMPFCC(~3)|F3F(~2, ~0x35, ~0x055), "9,e,f", F_FLOAT, v9 },
+
+/* These Extended FPop (FIFO) instructions are new in the Fujitsu
+ MB86934, replacing the CPop instructions from v6 and later
+ processors. */
+
+#define EFPOP1_2(name, op, args) { name, F3F(2, 0x36, op), F3F(~2, ~0x36, ~op)|RS1_G0, args, 0, sparclite }
+#define EFPOP1_3(name, op, args) { name, F3F(2, 0x36, op), F3F(~2, ~0x36, ~op), args, 0, sparclite }
+#define EFPOP2_2(name, op, args) { name, F3F(2, 0x37, op), F3F(~2, ~0x37, ~op)|RD_G0, args, 0, sparclite }
+
+EFPOP1_2 ("efitod", 0x0c8, "f,H"),
+EFPOP1_2 ("efitos", 0x0c4, "f,g"),
+EFPOP1_2 ("efdtoi", 0x0d2, "B,g"),
+EFPOP1_2 ("efstoi", 0x0d1, "f,g"),
+EFPOP1_2 ("efstod", 0x0c9, "f,H"),
+EFPOP1_2 ("efdtos", 0x0c6, "B,g"),
+EFPOP1_2 ("efmovs", 0x001, "f,g"),
+EFPOP1_2 ("efnegs", 0x005, "f,g"),
+EFPOP1_2 ("efabss", 0x009, "f,g"),
+EFPOP1_2 ("efsqrtd", 0x02a, "B,H"),
+EFPOP1_2 ("efsqrts", 0x029, "f,g"),
+EFPOP1_3 ("efaddd", 0x042, "v,B,H"),
+EFPOP1_3 ("efadds", 0x041, "e,f,g"),
+EFPOP1_3 ("efsubd", 0x046, "v,B,H"),
+EFPOP1_3 ("efsubs", 0x045, "e,f,g"),
+EFPOP1_3 ("efdivd", 0x04e, "v,B,H"),
+EFPOP1_3 ("efdivs", 0x04d, "e,f,g"),
+EFPOP1_3 ("efmuld", 0x04a, "v,B,H"),
+EFPOP1_3 ("efmuls", 0x049, "e,f,g"),
+EFPOP1_3 ("efsmuld", 0x069, "e,f,H"),
+EFPOP2_2 ("efcmpd", 0x052, "v,B"),
+EFPOP2_2 ("efcmped", 0x056, "v,B"),
+EFPOP2_2 ("efcmps", 0x051, "e,f"),
+EFPOP2_2 ("efcmpes", 0x055, "e,f"),
+
+#undef EFPOP1_2
+#undef EFPOP1_3
+#undef EFPOP2_2
+
+/* These are marked F_ALIAS, so that they won't conflict with sparclite insns
+ present. Otherwise, the F_ALIAS flag is ignored. */
+{ "cpop1", F3(2, 0x36, 0), F3(~2, ~0x36, ~1), "[1+2],d", F_ALIAS, v6notv9 },
+{ "cpop2", F3(2, 0x37, 0), F3(~2, ~0x37, ~1), "[1+2],d", F_ALIAS, v6notv9 },
+
+/* sparclet specific insns */
+
+COMMUTEOP ("umac", 0x3e, sparclet),
+COMMUTEOP ("smac", 0x3f, sparclet),
+COMMUTEOP ("umacd", 0x2e, sparclet),
+COMMUTEOP ("smacd", 0x2f, sparclet),
+COMMUTEOP ("umuld", 0x09, sparclet),
+COMMUTEOP ("smuld", 0x0d, sparclet),
+
+{ "shuffle", F3(2, 0x2d, 0), F3(~2, ~0x2d, ~0)|ASI(~0), "1,2,d", 0, sparclet },
+{ "shuffle", F3(2, 0x2d, 1), F3(~2, ~0x2d, ~1), "1,i,d", 0, sparclet },
+
+/* The manual isn't completely accurate on these insns. The `rs2' field is
+ treated as being 6 bits to account for 6 bit immediates to cpush. It is
+ assumed that it is intended that bit 5 is 0 when rs2 contains a reg. */
+#define BIT5 (1<<5)
+{ "crdcxt", F3(2, 0x36, 0)|SLCPOP(4), F3(~2, ~0x36, ~0)|SLCPOP(~4)|BIT5|RS2(~0), "U,d", 0, sparclet },
+{ "cwrcxt", F3(2, 0x36, 0)|SLCPOP(3), F3(~2, ~0x36, ~0)|SLCPOP(~3)|BIT5|RS2(~0), "1,u", 0, sparclet },
+{ "cpush", F3(2, 0x36, 0)|SLCPOP(0), F3(~2, ~0x36, ~0)|SLCPOP(~0)|BIT5|RD(~0), "1,2", 0, sparclet },
+{ "cpush", F3(2, 0x36, 1)|SLCPOP(0), F3(~2, ~0x36, ~1)|SLCPOP(~0)|RD(~0), "1,Y", 0, sparclet },
+{ "cpusha", F3(2, 0x36, 0)|SLCPOP(1), F3(~2, ~0x36, ~0)|SLCPOP(~1)|BIT5|RD(~0), "1,2", 0, sparclet },
+{ "cpusha", F3(2, 0x36, 1)|SLCPOP(1), F3(~2, ~0x36, ~1)|SLCPOP(~1)|RD(~0), "1,Y", 0, sparclet },
+{ "cpull", F3(2, 0x36, 0)|SLCPOP(2), F3(~2, ~0x36, ~0)|SLCPOP(~2)|BIT5|RS1(~0)|RS2(~0), "d", 0, sparclet },
+#undef BIT5
+
+/* sparclet coprocessor branch insns */
+#define SLCBCC2(opcode, mask, lose) \
+ { opcode, (mask), ANNUL|(lose), "l", F_DELAYED|F_CONDBR, sparclet }, \
+ { opcode, (mask)|ANNUL, (lose), ",a l", F_DELAYED|F_CONDBR, sparclet }
+#define SLCBCC(opcode, mask) \
+ SLCBCC2(opcode, F2(0, 7)|COND(mask), F2(~0, ~7)|COND(~(mask)))
+
+/* cbn,cba can't be defined here because they're defined elsewhere and GAS
+ requires all mnemonics of the same name to be consecutive. */
+/*SLCBCC("cbn", 0), - already defined */
+SLCBCC("cbe", 1),
+SLCBCC("cbf", 2),
+SLCBCC("cbef", 3),
+SLCBCC("cbr", 4),
+SLCBCC("cber", 5),
+SLCBCC("cbfr", 6),
+SLCBCC("cbefr", 7),
+/*SLCBCC("cba", 8), - already defined */
+SLCBCC("cbne", 9),
+SLCBCC("cbnf", 10),
+SLCBCC("cbnef", 11),
+SLCBCC("cbnr", 12),
+SLCBCC("cbner", 13),
+SLCBCC("cbnfr", 14),
+SLCBCC("cbnefr", 15),
+
+#undef SLCBCC2
+#undef SLCBCC
+
+{ "casa", F3(3, 0x3c, 0), F3(~3, ~0x3c, ~0), "[1]A,2,d", 0, v9 },
+{ "casa", F3(3, 0x3c, 1), F3(~3, ~0x3c, ~1), "[1]o,2,d", 0, v9 },
+{ "casxa", F3(3, 0x3e, 0), F3(~3, ~0x3e, ~0), "[1]A,2,d", 0, v9 },
+{ "casxa", F3(3, 0x3e, 1), F3(~3, ~0x3e, ~1), "[1]o,2,d", 0, v9 },
+
+/* v9 synthetic insns */
+/* FIXME: still missing "signx d", and "clruw d". Can't be done here. */
+{ "iprefetch", F2(0, 1)|(2<<20)|BPRED, F2(~0, ~1)|(1<<20)|ANNUL|COND(~0), "G", 0, v9 }, /* bn,a,pt %xcc,label */
+{ "signx", F3(2, 0x27, 0), F3(~2, ~0x27, ~0)|(1<<12)|ASI(~0)|RS2_G0, "1,d", F_ALIAS, v9 }, /* sra rs1,%g0,rd */
+{ "clruw", F3(2, 0x26, 0), F3(~2, ~0x26, ~0)|(1<<12)|ASI(~0)|RS2_G0, "1,d", F_ALIAS, v9 }, /* srl rs1,%g0,rd */
+{ "cas", F3(3, 0x3c, 0)|ASI(0x80), F3(~3, ~0x3c, ~0)|ASI(~0x80), "[1],2,d", F_ALIAS, v9 }, /* casa [rs1]ASI_P,rs2,rd */
+{ "casl", F3(3, 0x3c, 0)|ASI(0x88), F3(~3, ~0x3c, ~0)|ASI(~0x88), "[1],2,d", F_ALIAS, v9 }, /* casa [rs1]ASI_P_L,rs2,rd */
+{ "casx", F3(3, 0x3e, 0)|ASI(0x80), F3(~3, ~0x3e, ~0)|ASI(~0x80), "[1],2,d", F_ALIAS, v9 }, /* casxa [rs1]ASI_P,rs2,rd */
+{ "casxl", F3(3, 0x3e, 0)|ASI(0x88), F3(~3, ~0x3e, ~0)|ASI(~0x88), "[1],2,d", F_ALIAS, v9 }, /* casxa [rs1]ASI_P_L,rs2,rd */
+
+/* Ultrasparc extensions */
+{ "shutdown", F3F(2, 0x36, 0x080), F3F(~2, ~0x36, ~0x080)|RD_G0|RS1_G0|RS2_G0, "", 0, v9a },
+
+/* FIXME: Do we want to mark these as F_FLOAT, or something similar? */
+{ "fpadd16", F3F(2, 0x36, 0x050), F3F(~2, ~0x36, ~0x050), "v,B,H", 0, v9a },
+{ "fpadd16s", F3F(2, 0x36, 0x051), F3F(~2, ~0x36, ~0x051), "e,f,g", 0, v9a },
+{ "fpadd32", F3F(2, 0x36, 0x052), F3F(~2, ~0x36, ~0x052), "v,B,H", 0, v9a },
+{ "fpadd32s", F3F(2, 0x36, 0x053), F3F(~2, ~0x36, ~0x053), "e,f,g", 0, v9a },
+{ "fpsub16", F3F(2, 0x36, 0x054), F3F(~2, ~0x36, ~0x054), "v,B,H", 0, v9a },
+{ "fpsub16s", F3F(2, 0x36, 0x055), F3F(~2, ~0x36, ~0x055), "e,f,g", 0, v9a },
+{ "fpsub32", F3F(2, 0x36, 0x056), F3F(~2, ~0x36, ~0x056), "v,B,H", 0, v9a },
+{ "fpsub32s", F3F(2, 0x36, 0x057), F3F(~2, ~0x36, ~0x057), "e,f,g", 0, v9a },
+
+{ "fpack32", F3F(2, 0x36, 0x03a), F3F(~2, ~0x36, ~0x03a), "v,B,H", 0, v9a },
+{ "fpack16", F3F(2, 0x36, 0x03b), F3F(~2, ~0x36, ~0x03b)|RS1_G0, "B,g", 0, v9a },
+{ "fpackfix", F3F(2, 0x36, 0x03d), F3F(~2, ~0x36, ~0x03d)|RS1_G0, "B,g", 0, v9a },
+{ "fexpand", F3F(2, 0x36, 0x04d), F3F(~2, ~0x36, ~0x04d)|RS1_G0, "f,H", 0, v9a },
+{ "fpmerge", F3F(2, 0x36, 0x04b), F3F(~2, ~0x36, ~0x04b), "e,f,H", 0, v9a },
+
+/* Note that the mixing of 32/64 bit regs is intentional. */
+{ "fmul8x16", F3F(2, 0x36, 0x031), F3F(~2, ~0x36, ~0x031), "e,B,H", 0, v9a },
+{ "fmul8x16au", F3F(2, 0x36, 0x033), F3F(~2, ~0x36, ~0x033), "e,f,H", 0, v9a },
+{ "fmul8x16al", F3F(2, 0x36, 0x035), F3F(~2, ~0x36, ~0x035), "e,f,H", 0, v9a },
+{ "fmul8sux16", F3F(2, 0x36, 0x036), F3F(~2, ~0x36, ~0x036), "v,B,H", 0, v9a },
+{ "fmul8ulx16", F3F(2, 0x36, 0x037), F3F(~2, ~0x36, ~0x037), "v,B,H", 0, v9a },
+{ "fmuld8sux16", F3F(2, 0x36, 0x038), F3F(~2, ~0x36, ~0x038), "e,f,H", 0, v9a },
+{ "fmuld8ulx16", F3F(2, 0x36, 0x039), F3F(~2, ~0x36, ~0x039), "e,f,H", 0, v9a },
+
+{ "alignaddr", F3F(2, 0x36, 0x018), F3F(~2, ~0x36, ~0x018), "1,2,d", 0, v9a },
+{ "alignaddrl", F3F(2, 0x36, 0x01a), F3F(~2, ~0x36, ~0x01a), "1,2,d", 0, v9a },
+{ "faligndata", F3F(2, 0x36, 0x048), F3F(~2, ~0x36, ~0x048), "v,B,H", 0, v9a },
+
+{ "fzero", F3F(2, 0x36, 0x060), F3F(~2, ~0x36, ~0x060), "H", 0, v9a },
+{ "fzeros", F3F(2, 0x36, 0x061), F3F(~2, ~0x36, ~0x061), "g", 0, v9a },
+{ "fone", F3F(2, 0x36, 0x07e), F3F(~2, ~0x36, ~0x07e), "H", 0, v9a },
+{ "fones", F3F(2, 0x36, 0x07f), F3F(~2, ~0x36, ~0x07f), "g", 0, v9a },
+{ "fsrc1", F3F(2, 0x36, 0x074), F3F(~2, ~0x36, ~0x074), "v,H", 0, v9a },
+{ "fsrc1s", F3F(2, 0x36, 0x075), F3F(~2, ~0x36, ~0x075), "e,g", 0, v9a },
+{ "fsrc2", F3F(2, 0x36, 0x078), F3F(~2, ~0x36, ~0x078), "B,H", 0, v9a },
+{ "fsrc2s", F3F(2, 0x36, 0x079), F3F(~2, ~0x36, ~0x079), "f,g", 0, v9a },
+{ "fnot1", F3F(2, 0x36, 0x06a), F3F(~2, ~0x36, ~0x06a), "v,H", 0, v9a },
+{ "fnot1s", F3F(2, 0x36, 0x06b), F3F(~2, ~0x36, ~0x06b), "e,g", 0, v9a },
+{ "fnot2", F3F(2, 0x36, 0x066), F3F(~2, ~0x36, ~0x066), "B,H", 0, v9a },
+{ "fnot2s", F3F(2, 0x36, 0x067), F3F(~2, ~0x36, ~0x067), "f,g", 0, v9a },
+{ "for", F3F(2, 0x36, 0x07c), F3F(~2, ~0x36, ~0x07c), "v,B,H", 0, v9a },
+{ "fors", F3F(2, 0x36, 0x07d), F3F(~2, ~0x36, ~0x07d), "e,f,g", 0, v9a },
+{ "fnor", F3F(2, 0x36, 0x062), F3F(~2, ~0x36, ~0x062), "v,B,H", 0, v9a },
+{ "fnors", F3F(2, 0x36, 0x063), F3F(~2, ~0x36, ~0x063), "e,f,g", 0, v9a },
+{ "fand", F3F(2, 0x36, 0x070), F3F(~2, ~0x36, ~0x070), "v,B,H", 0, v9a },
+{ "fands", F3F(2, 0x36, 0x071), F3F(~2, ~0x36, ~0x071), "e,f,g", 0, v9a },
+{ "fnand", F3F(2, 0x36, 0x06e), F3F(~2, ~0x36, ~0x06e), "v,B,H", 0, v9a },
+{ "fnands", F3F(2, 0x36, 0x06f), F3F(~2, ~0x36, ~0x06f), "e,f,g", 0, v9a },
+{ "fxor", F3F(2, 0x36, 0x06c), F3F(~2, ~0x36, ~0x06c), "v,B,H", 0, v9a },
+{ "fxors", F3F(2, 0x36, 0x06d), F3F(~2, ~0x36, ~0x06d), "e,f,g", 0, v9a },
+{ "fxnor", F3F(2, 0x36, 0x072), F3F(~2, ~0x36, ~0x072), "v,B,H", 0, v9a },
+{ "fxnors", F3F(2, 0x36, 0x073), F3F(~2, ~0x36, ~0x073), "e,f,g", 0, v9a },
+{ "fornot1", F3F(2, 0x36, 0x07a), F3F(~2, ~0x36, ~0x07a), "v,B,H", 0, v9a },
+{ "fornot1s", F3F(2, 0x36, 0x07b), F3F(~2, ~0x36, ~0x07b), "e,f,g", 0, v9a },
+{ "fornot2", F3F(2, 0x36, 0x076), F3F(~2, ~0x36, ~0x076), "v,B,H", 0, v9a },
+{ "fornot2s", F3F(2, 0x36, 0x077), F3F(~2, ~0x36, ~0x077), "e,f,g", 0, v9a },
+{ "fandnot1", F3F(2, 0x36, 0x068), F3F(~2, ~0x36, ~0x068), "v,B,H", 0, v9a },
+{ "fandnot1s", F3F(2, 0x36, 0x069), F3F(~2, ~0x36, ~0x069), "e,f,g", 0, v9a },
+{ "fandnot2", F3F(2, 0x36, 0x064), F3F(~2, ~0x36, ~0x064), "v,B,H", 0, v9a },
+{ "fandnot2s", F3F(2, 0x36, 0x065), F3F(~2, ~0x36, ~0x065), "e,f,g", 0, v9a },
+
+{ "fcmpgt16", F3F(2, 0x36, 0x028), F3F(~2, ~0x36, ~0x028), "v,B,d", 0, v9a },
+{ "fcmpgt32", F3F(2, 0x36, 0x02c), F3F(~2, ~0x36, ~0x02c), "v,B,d", 0, v9a },
+{ "fcmple16", F3F(2, 0x36, 0x020), F3F(~2, ~0x36, ~0x020), "v,B,d", 0, v9a },
+{ "fcmple32", F3F(2, 0x36, 0x024), F3F(~2, ~0x36, ~0x024), "v,B,d", 0, v9a },
+{ "fcmpne16", F3F(2, 0x36, 0x022), F3F(~2, ~0x36, ~0x022), "v,B,d", 0, v9a },
+{ "fcmpne32", F3F(2, 0x36, 0x026), F3F(~2, ~0x36, ~0x026), "v,B,d", 0, v9a },
+{ "fcmpeq16", F3F(2, 0x36, 0x02a), F3F(~2, ~0x36, ~0x02a), "v,B,d", 0, v9a },
+{ "fcmpeq32", F3F(2, 0x36, 0x02e), F3F(~2, ~0x36, ~0x02e), "v,B,d", 0, v9a },
+
+{ "edge8", F3F(2, 0x36, 0x000), F3F(~2, ~0x36, ~0x000), "1,2,d", 0, v9a },
+{ "edge8l", F3F(2, 0x36, 0x002), F3F(~2, ~0x36, ~0x002), "1,2,d", 0, v9a },
+{ "edge16", F3F(2, 0x36, 0x004), F3F(~2, ~0x36, ~0x004), "1,2,d", 0, v9a },
+{ "edge16l", F3F(2, 0x36, 0x006), F3F(~2, ~0x36, ~0x006), "1,2,d", 0, v9a },
+{ "edge32", F3F(2, 0x36, 0x008), F3F(~2, ~0x36, ~0x008), "1,2,d", 0, v9a },
+{ "edge32l", F3F(2, 0x36, 0x00a), F3F(~2, ~0x36, ~0x00a), "1,2,d", 0, v9a },
+
+{ "pdist", F3F(2, 0x36, 0x03e), F3F(~2, ~0x36, ~0x03e), "v,B,H", 0, v9a },
+
+{ "array8", F3F(2, 0x36, 0x010), F3F(~2, ~0x36, ~0x010), "1,2,d", 0, v9a },
+{ "array16", F3F(2, 0x36, 0x012), F3F(~2, ~0x36, ~0x012), "1,2,d", 0, v9a },
+{ "array32", F3F(2, 0x36, 0x014), F3F(~2, ~0x36, ~0x014), "1,2,d", 0, v9a },
+
+/* More v9 specific insns, these need to come last so they do not clash
+ with v9a instructions such as "edge8" which looks like impdep1. */
+
+#define IMPDEP(name, code) \
+{ name, F3(2, code, 0), F3(~2, ~code, ~0)|ASI(~0), "1,2,d", 0, v9notv9a }, \
+{ name, F3(2, code, 1), F3(~2, ~code, ~1), "1,i,d", 0, v9notv9a }, \
+{ name, F3(2, code, 0), F3(~2, ~code, ~0), "x,1,2,d", 0, v9notv9a }, \
+{ name, F3(2, code, 0), F3(~2, ~code, ~0), "x,e,f,g", 0, v9notv9a }
+
+IMPDEP ("impdep1", 0x36),
+IMPDEP ("impdep2", 0x37),
+
+#undef IMPDEP
+
+};
+
+const int sparc_num_opcodes = ((sizeof sparc_opcodes)/(sizeof sparc_opcodes[0]));
+
+/* Utilities for argument parsing. */
+
+typedef struct
+{
+ int value;
+ const char *name;
+} arg;
+
+/* Look up NAME in TABLE. */
+
+static int lookup_name PARAMS ((const arg *, const char *));
+static const char *lookup_value PARAMS ((const arg *, int));
+
+static int
+lookup_name (table, name)
+ const arg *table;
+ const char *name;
+{
+ const arg *p;
+
+ for (p = table; p->name; ++p)
+ if (strcmp (name, p->name) == 0)
+ return p->value;
+
+ return -1;
+}
+
+/* Look up VALUE in TABLE. */
+
+static const char *
+lookup_value (table, value)
+ const arg *table;
+ int value;
+{
+ const arg *p;
+
+ for (p = table; p->name; ++p)
+ if (value == p->value)
+ return p->name;
+
+ return (char *) 0;
+}
+
+/* Handle ASI's. */
+
+static arg asi_table[] =
+{
+ /* These are in the v9 architecture manual. */
+ /* The shorter versions appear first, they're here because Sun's as has them.
+ Sun's as uses #ASI_P_L instead of #ASI_PL (which appears in the
+ UltraSPARC architecture manual). */
+ { 0x04, "#ASI_N" },
+ { 0x0c, "#ASI_N_L" },
+ { 0x10, "#ASI_AIUP" },
+ { 0x11, "#ASI_AIUS" },
+ { 0x18, "#ASI_AIUP_L" },
+ { 0x19, "#ASI_AIUS_L" },
+ { 0x80, "#ASI_P" },
+ { 0x81, "#ASI_S" },
+ { 0x82, "#ASI_PNF" },
+ { 0x83, "#ASI_SNF" },
+ { 0x88, "#ASI_P_L" },
+ { 0x89, "#ASI_S_L" },
+ { 0x8a, "#ASI_PNF_L" },
+ { 0x8b, "#ASI_SNF_L" },
+ { 0x04, "#ASI_NUCLEUS" },
+ { 0x0c, "#ASI_NUCLEUS_LITTLE" },
+ { 0x10, "#ASI_AS_IF_USER_PRIMARY" },
+ { 0x11, "#ASI_AS_IF_USER_SECONDARY" },
+ { 0x18, "#ASI_AS_IF_USER_PRIMARY_LITTLE" },
+ { 0x19, "#ASI_AS_IF_USER_SECONDARY_LITTLE" },
+ { 0x80, "#ASI_PRIMARY" },
+ { 0x81, "#ASI_SECONDARY" },
+ { 0x82, "#ASI_PRIMARY_NOFAULT" },
+ { 0x83, "#ASI_SECONDARY_NOFAULT" },
+ { 0x88, "#ASI_PRIMARY_LITTLE" },
+ { 0x89, "#ASI_SECONDARY_LITTLE" },
+ { 0x8a, "#ASI_PRIMARY_NOFAULT_LITTLE" },
+ { 0x8b, "#ASI_SECONDARY_NOFAULT_LITTLE" },
+ /* These are UltraSPARC extensions. */
+ /* FIXME: There are dozens of them. Not sure we want them all.
+ Most are for kernel building but some are for vis type stuff. */
+ { 0, 0 }
+};
+
+/* Return the value for ASI NAME, or -1 if not found. */
+
+int
+sparc_encode_asi (name)
+ const char *name;
+{
+ return lookup_name (asi_table, name);
+}
+
+/* Return the name for ASI value VALUE or NULL if not found. */
+
+const char *
+sparc_decode_asi (value)
+ int value;
+{
+ return lookup_value (asi_table, value);
+}
+
+/* Handle membar masks. */
+
+static arg membar_table[] =
+{
+ { 0x40, "#Sync" },
+ { 0x20, "#MemIssue" },
+ { 0x10, "#Lookaside" },
+ { 0x08, "#StoreStore" },
+ { 0x04, "#LoadStore" },
+ { 0x02, "#StoreLoad" },
+ { 0x01, "#LoadLoad" },
+ { 0, 0 }
+};
+
+/* Return the value for membar arg NAME, or -1 if not found. */
+
+int
+sparc_encode_membar (name)
+ const char *name;
+{
+ return lookup_name (membar_table, name);
+}
+
+/* Return the name for membar value VALUE or NULL if not found. */
+
+const char *
+sparc_decode_membar (value)
+ int value;
+{
+ return lookup_value (membar_table, value);
+}
+
+/* Handle prefetch args. */
+
+static arg prefetch_table[] =
+{
+ { 0, "#n_reads" },
+ { 1, "#one_read" },
+ { 2, "#n_writes" },
+ { 3, "#one_write" },
+ { 4, "#page" },
+ { 0, 0 }
+};
+
+/* Return the value for prefetch arg NAME, or -1 if not found. */
+
+int
+sparc_encode_prefetch (name)
+ const char *name;
+{
+ return lookup_name (prefetch_table, name);
+}
+
+/* Return the name for prefetch value VALUE or NULL if not found. */
+
+const char *
+sparc_decode_prefetch (value)
+ int value;
+{
+ return lookup_value (prefetch_table, value);
+}
+
+/* Handle sparclet coprocessor registers. */
+
+static arg sparclet_cpreg_table[] =
+{
+ { 0, "%ccsr" },
+ { 1, "%ccfr" },
+ { 2, "%cccrcr" },
+ { 3, "%ccpr" },
+ { 4, "%ccsr2" },
+ { 5, "%cccrr" },
+ { 6, "%ccrstr" },
+ { 0, 0 }
+};
+
+/* Return the value for sparclet cpreg arg NAME, or -1 if not found. */
+
+int
+sparc_encode_sparclet_cpreg (name)
+ const char *name;
+{
+ return lookup_name (sparclet_cpreg_table, name);
+}
+
+/* Return the name for sparclet cpreg value VALUE or NULL if not found. */
+
+const char *
+sparc_decode_sparclet_cpreg (value)
+ int value;
+{
+ return lookup_value (sparclet_cpreg_table, value);
+}
diff --git a/opcodes/stamp-h.in b/opcodes/stamp-h.in
new file mode 100644
index 00000000000..9788f70238c
--- /dev/null
+++ b/opcodes/stamp-h.in
@@ -0,0 +1 @@
+timestamp
diff --git a/opcodes/sysdep.h b/opcodes/sysdep.h
new file mode 100644
index 00000000000..bb23e5fcf5d
--- /dev/null
+++ b/opcodes/sysdep.h
@@ -0,0 +1,42 @@
+/* Random host-dependent support code.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ Written by Ken Raeburn.
+
+This file is part of libopcodes, the opcodes library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Do system-dependent stuff, mainly driven by autoconf-detected info.
+
+ Well, some generic common stuff is done here too, like including
+ ansidecl.h. That's because the .h files in bfd/hosts files I'm
+ trying to replace often did that. If it can be dropped from this
+ file (check in a non-ANSI environment!), it should be. */
+
+#include "config.h"
+
+#include <ansidecl.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
diff --git a/opcodes/tic30-dis.c b/opcodes/tic30-dis.c
new file mode 100644
index 00000000000..105145778b3
--- /dev/null
+++ b/opcodes/tic30-dis.c
@@ -0,0 +1,711 @@
+/* Disassembly routines for TMS320C30 architecture
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <errno.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include "dis-asm.h"
+#include "opcode/tic30.h"
+
+#define NORMAL_INSN 1
+#define PARALLEL_INSN 2
+
+/* Gets the type of instruction based on the top 2 or 3 bits of the
+ instruction word. */
+#define GET_TYPE(insn) (insn & 0x80000000 ? insn & 0xC0000000 : insn & 0xE0000000)
+
+/* Instruction types. */
+#define TWO_OPERAND_1 0x00000000
+#define TWO_OPERAND_2 0x40000000
+#define THREE_OPERAND 0x20000000
+#define PAR_STORE 0xC0000000
+#define MUL_ADDS 0x80000000
+#define BRANCHES 0x60000000
+
+/* Specific instruction id bits. */
+#define NORMAL_IDEN 0x1F800000
+#define PAR_STORE_IDEN 0x3E000000
+#define MUL_ADD_IDEN 0x2C000000
+#define BR_IMM_IDEN 0x1F000000
+#define BR_COND_IDEN 0x1C3F0000
+
+/* Addressing modes. */
+#define AM_REGISTER 0x00000000
+#define AM_DIRECT 0x00200000
+#define AM_INDIRECT 0x00400000
+#define AM_IMM 0x00600000
+
+#define P_FIELD 0x03000000
+
+#define REG_AR0 0x08
+#define LDP_INSN 0x08700000
+
+/* TMS320C30 program counter for current instruction. */
+static unsigned int _pc;
+
+struct instruction
+ {
+ int type;
+ template *tm;
+ partemplate *ptm;
+ };
+
+int get_tic30_instruction PARAMS ((unsigned long, struct instruction *));
+int print_two_operand
+ PARAMS ((disassemble_info *, unsigned long, struct instruction *));
+int print_three_operand
+ PARAMS ((disassemble_info *, unsigned long, struct instruction *));
+int print_par_insn
+ PARAMS ((disassemble_info *, unsigned long, struct instruction *));
+int print_branch
+ PARAMS ((disassemble_info *, unsigned long, struct instruction *));
+int get_indirect_operand PARAMS ((unsigned short, int, char *));
+int get_register_operand PARAMS ((unsigned char, char *));
+int cnvt_tmsfloat_ieee PARAMS ((unsigned long, int, float *));
+
+int
+print_insn_tic30 (pc, info)
+ bfd_vma pc;
+ disassemble_info *info;
+{
+ unsigned long insn_word;
+ struct instruction insn =
+ {0, NULL, NULL};
+ bfd_vma bufaddr = pc - info->buffer_vma;
+ /* Obtain the current instruction word from the buffer. */
+ insn_word = (*(info->buffer + bufaddr) << 24) | (*(info->buffer + bufaddr + 1) << 16) |
+ (*(info->buffer + bufaddr + 2) << 8) | *(info->buffer + bufaddr + 3);
+ _pc = pc / 4;
+ /* Get the instruction refered to by the current instruction word
+ and print it out based on its type. */
+ if (!get_tic30_instruction (insn_word, &insn))
+ return -1;
+ switch (GET_TYPE (insn_word))
+ {
+ case TWO_OPERAND_1:
+ case TWO_OPERAND_2:
+ if (!print_two_operand (info, insn_word, &insn))
+ return -1;
+ break;
+ case THREE_OPERAND:
+ if (!print_three_operand (info, insn_word, &insn))
+ return -1;
+ break;
+ case PAR_STORE:
+ case MUL_ADDS:
+ if (!print_par_insn (info, insn_word, &insn))
+ return -1;
+ break;
+ case BRANCHES:
+ if (!print_branch (info, insn_word, &insn))
+ return -1;
+ break;
+ }
+ return 4;
+}
+
+int
+get_tic30_instruction (insn_word, insn)
+ unsigned long insn_word;
+ struct instruction *insn;
+{
+ switch (GET_TYPE (insn_word))
+ {
+ case TWO_OPERAND_1:
+ case TWO_OPERAND_2:
+ case THREE_OPERAND:
+ insn->type = NORMAL_INSN;
+ {
+ template *current_optab = (template *) tic30_optab;
+ for (; current_optab < tic30_optab_end; current_optab++)
+ {
+ if (GET_TYPE (current_optab->base_opcode) == GET_TYPE (insn_word))
+ {
+ if (current_optab->operands == 0)
+ {
+ if (current_optab->base_opcode == insn_word)
+ {
+ insn->tm = current_optab;
+ break;
+ }
+ }
+ else if ((current_optab->base_opcode & NORMAL_IDEN) == (insn_word & NORMAL_IDEN))
+ {
+ insn->tm = current_optab;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case PAR_STORE:
+ insn->type = PARALLEL_INSN;
+ {
+ partemplate *current_optab = (partemplate *) tic30_paroptab;
+ for (; current_optab < tic30_paroptab_end; current_optab++)
+ {
+ if (GET_TYPE (current_optab->base_opcode) == GET_TYPE (insn_word))
+ {
+ if ((current_optab->base_opcode & PAR_STORE_IDEN) == (insn_word & PAR_STORE_IDEN))
+ {
+ insn->ptm = current_optab;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case MUL_ADDS:
+ insn->type = PARALLEL_INSN;
+ {
+ partemplate *current_optab = (partemplate *) tic30_paroptab;
+ for (; current_optab < tic30_paroptab_end; current_optab++)
+ {
+ if (GET_TYPE (current_optab->base_opcode) == GET_TYPE (insn_word))
+ {
+ if ((current_optab->base_opcode & MUL_ADD_IDEN) == (insn_word & MUL_ADD_IDEN))
+ {
+ insn->ptm = current_optab;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case BRANCHES:
+ insn->type = NORMAL_INSN;
+ {
+ template *current_optab = (template *) tic30_optab;
+ for (; current_optab < tic30_optab_end; current_optab++)
+ {
+ if (GET_TYPE (current_optab->base_opcode) == GET_TYPE (insn_word))
+ {
+ if (current_optab->operand_types[0] & Imm24)
+ {
+ if ((current_optab->base_opcode & BR_IMM_IDEN) == (insn_word & BR_IMM_IDEN))
+ {
+ insn->tm = current_optab;
+ break;
+ }
+ }
+ else if (current_optab->operands > 0)
+ {
+ if ((current_optab->base_opcode & BR_COND_IDEN) == (insn_word & BR_COND_IDEN))
+ {
+ insn->tm = current_optab;
+ break;
+ }
+ }
+ else
+ {
+ if ((current_optab->base_opcode & (BR_COND_IDEN | 0x00800000)) == (insn_word & (BR_COND_IDEN | 0x00800000)))
+ {
+ insn->tm = current_optab;
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+int
+print_two_operand (info, insn_word, insn)
+ disassemble_info *info;
+ unsigned long insn_word;
+ struct instruction *insn;
+{
+ char name[12];
+ char operand[2][13] =
+ {
+ {0},
+ {0}};
+ float f_number;
+
+ if (insn->tm == NULL)
+ return 0;
+ strcpy (name, insn->tm->name);
+ if (insn->tm->opcode_modifier == AddressMode)
+ {
+ int src_op, dest_op;
+ /* Determine whether instruction is a store or a normal instruction. */
+ if ((insn->tm->operand_types[1] & (Direct | Indirect)) == (Direct | Indirect))
+ {
+ src_op = 1;
+ dest_op = 0;
+ }
+ else
+ {
+ src_op = 0;
+ dest_op = 1;
+ }
+ /* Get the destination register. */
+ if (insn->tm->operands == 2)
+ get_register_operand ((insn_word & 0x001F0000) >> 16, operand[dest_op]);
+ /* Get the source operand based on addressing mode. */
+ switch (insn_word & AddressMode)
+ {
+ case AM_REGISTER:
+ /* Check for the NOP instruction before getting the operand. */
+ if ((insn->tm->operand_types[0] & NotReq) == 0)
+ get_register_operand ((insn_word & 0x0000001F), operand[src_op]);
+ break;
+ case AM_DIRECT:
+ sprintf (operand[src_op], "@0x%lX", (insn_word & 0x0000FFFF));
+ break;
+ case AM_INDIRECT:
+ get_indirect_operand ((insn_word & 0x0000FFFF), 2, operand[src_op]);
+ break;
+ case AM_IMM:
+ /* Get the value of the immediate operand based on variable type. */
+ switch (insn->tm->imm_arg_type)
+ {
+ case Imm_Float:
+ cnvt_tmsfloat_ieee ((insn_word & 0x0000FFFF), 2, &f_number);
+ sprintf (operand[src_op], "%2.2f", f_number);
+ break;
+ case Imm_SInt:
+ sprintf (operand[src_op], "%d", (short) (insn_word & 0x0000FFFF));
+ break;
+ case Imm_UInt:
+ sprintf (operand[src_op], "%lu", (insn_word & 0x0000FFFF));
+ break;
+ default:
+ return 0;
+ }
+ /* Handle special case for LDP instruction. */
+ if ((insn_word & 0xFFFFFF00) == LDP_INSN)
+ {
+ strcpy (name, "ldp");
+ sprintf (operand[0], "0x%06lX", (insn_word & 0x000000FF) << 16);
+ operand[1][0] = '\0';
+ }
+ }
+ }
+ /* Handle case for stack and rotate instructions. */
+ else if (insn->tm->operands == 1)
+ {
+ if (insn->tm->opcode_modifier == StackOp)
+ {
+ get_register_operand ((insn_word & 0x001F0000) >> 16, operand[0]);
+ }
+ }
+ /* Output instruction to stream. */
+ info->fprintf_func (info->stream, " %s %s%c%s", name,
+ operand[0][0] ? operand[0] : "",
+ operand[1][0] ? ',' : ' ',
+ operand[1][0] ? operand[1] : "");
+ return 1;
+}
+
+int
+print_three_operand (info, insn_word, insn)
+ disassemble_info *info;
+ unsigned long insn_word;
+ struct instruction *insn;
+{
+ char operand[3][13] =
+ {
+ {0},
+ {0},
+ {0}};
+
+ if (insn->tm == NULL)
+ return 0;
+ switch (insn_word & AddressMode)
+ {
+ case AM_REGISTER:
+ get_register_operand ((insn_word & 0x000000FF), operand[0]);
+ get_register_operand ((insn_word & 0x0000FF00) >> 8, operand[1]);
+ break;
+ case AM_DIRECT:
+ get_register_operand ((insn_word & 0x000000FF), operand[0]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1]);
+ break;
+ case AM_INDIRECT:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0]);
+ get_register_operand ((insn_word & 0x0000FF00) >> 8, operand[1]);
+ break;
+ case AM_IMM:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1]);
+ break;
+ default:
+ return 0;
+ }
+ if (insn->tm->operands == 3)
+ get_register_operand ((insn_word & 0x001F0000) >> 16, operand[2]);
+ info->fprintf_func (info->stream, " %s %s,%s%c%s", insn->tm->name,
+ operand[0], operand[1],
+ operand[2][0] ? ',' : ' ',
+ operand[2][0] ? operand[2] : "");
+ return 1;
+}
+
+int
+print_par_insn (info, insn_word, insn)
+ disassemble_info *info;
+ unsigned long insn_word;
+ struct instruction *insn;
+{
+ size_t i, len;
+ char *name1, *name2;
+ char operand[2][3][13] =
+ {
+ {
+ {0},
+ {0},
+ {0}},
+ {
+ {0},
+ {0},
+ {0}}};
+
+ if (insn->ptm == NULL)
+ return 0;
+ /* Parse out the names of each of the parallel instructions from the
+ q_insn1_insn2 format. */
+ name1 = (char *) strdup (insn->ptm->name + 2);
+ name2 = "";
+ len = strlen (name1);
+ for (i = 0; i < len; i++)
+ {
+ if (name1[i] == '_')
+ {
+ name2 = &name1[i + 1];
+ name1[i] = '\0';
+ break;
+ }
+ }
+ /* Get the operands of the instruction based on the operand order. */
+ switch (insn->ptm->oporder)
+ {
+ case OO_4op1:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0][0]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1][1]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][0]);
+ get_register_operand ((insn_word >> 22) & 0x07, operand[0][1]);
+ break;
+ case OO_4op2:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0][0]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1][0]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[1][1]);
+ get_register_operand ((insn_word >> 22) & 0x07, operand[0][1]);
+ break;
+ case OO_4op3:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0][1]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1][1]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][0]);
+ get_register_operand ((insn_word >> 22) & 0x07, operand[0][0]);
+ break;
+ case OO_5op1:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0][0]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1][1]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][0]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[0][1]);
+ get_register_operand ((insn_word >> 22) & 0x07, operand[0][2]);
+ break;
+ case OO_5op2:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0][1]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1][1]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][0]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[0][0]);
+ get_register_operand ((insn_word >> 22) & 0x07, operand[0][2]);
+ break;
+ case OO_PField:
+ if (insn_word & 0x00800000)
+ get_register_operand (0x01, operand[0][2]);
+ else
+ get_register_operand (0x00, operand[0][2]);
+ if (insn_word & 0x00400000)
+ get_register_operand (0x03, operand[1][2]);
+ else
+ get_register_operand (0x02, operand[1][2]);
+ switch (insn_word & P_FIELD)
+ {
+ case 0x00000000:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[0][1]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[0][0]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][1]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[1][0]);
+ break;
+ case 0x01000000:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[1][0]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[0][0]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][1]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[0][1]);
+ break;
+ case 0x02000000:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[1][1]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[1][0]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[0][1]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[0][0]);
+ break;
+ case 0x03000000:
+ get_indirect_operand ((insn_word & 0x000000FF), 1, operand[1][1]);
+ get_indirect_operand ((insn_word & 0x0000FF00) >> 8, 1, operand[0][0]);
+ get_register_operand ((insn_word >> 16) & 0x07, operand[1][0]);
+ get_register_operand ((insn_word >> 19) & 0x07, operand[0][1]);
+ break;
+ }
+ break;
+ default:
+ return 0;
+ }
+ info->fprintf_func (info->stream, " %s %s,%s%c%s", name1,
+ operand[0][0], operand[0][1],
+ operand[0][2][0] ? ',' : ' ',
+ operand[0][2][0] ? operand[0][2] : "");
+ info->fprintf_func (info->stream, "\n\t\t\t|| %s %s,%s%c%s", name2,
+ operand[1][0], operand[1][1],
+ operand[1][2][0] ? ',' : ' ',
+ operand[1][2][0] ? operand[1][2] : "");
+ free (name1);
+ return 1;
+}
+
+int
+print_branch (info, insn_word, insn)
+ disassemble_info *info;
+ unsigned long insn_word;
+ struct instruction *insn;
+{
+ char operand[2][13] =
+ {
+ {0},
+ {0}};
+ unsigned long address;
+ int print_label = 0;
+
+ if (insn->tm == NULL)
+ return 0;
+ /* Get the operands for 24-bit immediate jumps. */
+ if (insn->tm->operand_types[0] & Imm24)
+ {
+ address = insn_word & 0x00FFFFFF;
+ sprintf (operand[0], "0x%lX", address);
+ print_label = 1;
+ }
+ /* Get the operand for the trap instruction. */
+ else if (insn->tm->operand_types[0] & IVector)
+ {
+ address = insn_word & 0x0000001F;
+ sprintf (operand[0], "0x%lX", address);
+ }
+ else
+ {
+ address = insn_word & 0x0000FFFF;
+ /* Get the operands for the DB instructions. */
+ if (insn->tm->operands == 2)
+ {
+ get_register_operand (((insn_word & 0x01C00000) >> 22) + REG_AR0, operand[0]);
+ if (insn_word & PCRel)
+ {
+ sprintf (operand[1], "%d", (short) address);
+ print_label = 1;
+ }
+ else
+ get_register_operand (insn_word & 0x0000001F, operand[1]);
+ }
+ /* Get the operands for the standard branches. */
+ else if (insn->tm->operands == 1)
+ {
+ if (insn_word & PCRel)
+ {
+ address = (short) address;
+ sprintf (operand[0], "%ld", address);
+ print_label = 1;
+ }
+ else
+ get_register_operand (insn_word & 0x0000001F, operand[0]);
+ }
+ }
+ info->fprintf_func (info->stream, " %s %s%c%s", insn->tm->name,
+ operand[0][0] ? operand[0] : "",
+ operand[1][0] ? ',' : ' ',
+ operand[1][0] ? operand[1] : "");
+ /* Print destination of branch in relation to current symbol. */
+ if (print_label && info->symbols)
+ {
+ asymbol *sym = *info->symbols;
+
+ if ((insn->tm->opcode_modifier == PCRel) && (insn_word & PCRel))
+ {
+ address = (_pc + 1 + (short) address) - ((sym->section->vma + sym->value) / 4);
+ /* Check for delayed instruction, if so adjust destination. */
+ if (insn_word & 0x00200000)
+ address += 2;
+ }
+ else
+ {
+ address -= ((sym->section->vma + sym->value) / 4);
+ }
+ if (address == 0)
+ info->fprintf_func (info->stream, " <%s>", sym->name);
+ else
+ info->fprintf_func (info->stream, " <%s %c %d>", sym->name,
+ ((short) address < 0) ? '-' : '+',
+ abs (address));
+ }
+ return 1;
+}
+
+int
+get_indirect_operand (fragment, size, buffer)
+ unsigned short fragment;
+ int size;
+ char *buffer;
+{
+ unsigned char mod;
+ unsigned arnum;
+ unsigned char disp;
+
+ if (buffer == NULL)
+ return 0;
+ /* Determine which bits identify the sections of the indirect operand based on the
+ size in bytes. */
+ switch (size)
+ {
+ case 1:
+ mod = (fragment & 0x00F8) >> 3;
+ arnum = (fragment & 0x0007);
+ disp = 0;
+ break;
+ case 2:
+ mod = (fragment & 0xF800) >> 11;
+ arnum = (fragment & 0x0700) >> 8;
+ disp = (fragment & 0x00FF);
+ break;
+ default:
+ return 0;
+ }
+ {
+ const ind_addr_type *current_ind = tic30_indaddr_tab;
+ for (; current_ind < tic30_indaddrtab_end; current_ind++)
+ {
+ if (current_ind->modfield == mod)
+ {
+ if (current_ind->displacement == IMPLIED_DISP && size == 2)
+ {
+ continue;
+ }
+ else
+ {
+ size_t i, len;
+ int bufcnt;
+
+ len = strlen (current_ind->syntax);
+ for (i = 0, bufcnt = 0; i < len; i++, bufcnt++)
+ {
+ buffer[bufcnt] = current_ind->syntax[i];
+ if (buffer[bufcnt - 1] == 'a' && buffer[bufcnt] == 'r')
+ buffer[++bufcnt] = arnum + '0';
+ if (buffer[bufcnt] == '(' && current_ind->displacement == DISP_REQUIRED)
+ {
+ sprintf (&buffer[bufcnt + 1], "%u", disp);
+ bufcnt += strlen (&buffer[bufcnt + 1]);
+ }
+ }
+ buffer[bufcnt + 1] = '\0';
+ break;
+ }
+ }
+ }
+ }
+ return 1;
+}
+
+int
+get_register_operand (fragment, buffer)
+ unsigned char fragment;
+ char *buffer;
+{
+ const reg *current_reg = tic30_regtab;
+
+ if (buffer == NULL)
+ return 0;
+ for (; current_reg < tic30_regtab_end; current_reg++)
+ {
+ if ((fragment & 0x1F) == current_reg->opcode)
+ {
+ strcpy (buffer, current_reg->name);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+cnvt_tmsfloat_ieee (tmsfloat, size, ieeefloat)
+ unsigned long tmsfloat;
+ int size;
+ float *ieeefloat;
+{
+ unsigned long exp, sign, mant;
+
+ if (size == 2)
+ {
+ if ((tmsfloat & 0x0000F000) == 0x00008000)
+ tmsfloat = 0x80000000;
+ else
+ {
+ tmsfloat <<= 16;
+ tmsfloat = (long) tmsfloat >> 4;
+ }
+ }
+ exp = tmsfloat & 0xFF000000;
+ if (exp == 0x80000000)
+ {
+ *ieeefloat = 0.0;
+ return 1;
+ }
+ exp += 0x7F000000;
+ sign = (tmsfloat & 0x00800000) << 8;
+ mant = tmsfloat & 0x007FFFFF;
+ if (exp == 0xFF000000)
+ {
+ if (mant == 0)
+ *ieeefloat = ERANGE;
+ if (sign == 0)
+ *ieeefloat = 1.0 / 0.0;
+ else
+ *ieeefloat = -1.0 / 0.0;
+ return 1;
+ }
+ exp >>= 1;
+ if (sign)
+ {
+ mant = (~mant) & 0x007FFFFF;
+ mant += 1;
+ exp += mant & 0x00800000;
+ exp &= 0x7F800000;
+ mant &= 0x007FFFFF;
+ }
+ if (tmsfloat == 0x80000000)
+ sign = mant = exp = 0;
+ tmsfloat = sign | exp | mant;
+ *ieeefloat = *((float *) &tmsfloat);
+ return 1;
+}
diff --git a/opcodes/tic80-dis.c b/opcodes/tic80-dis.c
new file mode 100644
index 00000000000..726bc12e881
--- /dev/null
+++ b/opcodes/tic80-dis.c
@@ -0,0 +1,397 @@
+/* Print TI TMS320C80 (MVP) instructions
+ Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+
+#include "ansidecl.h"
+#include "opcode/tic80.h"
+#include "dis-asm.h"
+
+static int length;
+
+static void print_operand_bitnum PARAMS ((struct disassemble_info *, long));
+static void print_operand_condition_code PARAMS ((struct disassemble_info *, long));
+static void print_operand_control_register PARAMS ((struct disassemble_info *, long));
+static void print_operand_float PARAMS ((struct disassemble_info *, long));
+static void print_operand_integer PARAMS ((struct disassemble_info *, long));
+static void print_operand PARAMS ((struct disassemble_info *, long, unsigned long,
+ const struct tic80_operand *, bfd_vma));
+static int print_one_instruction PARAMS ((struct disassemble_info *, bfd_vma,
+ unsigned long, const struct tic80_opcode *));
+static int print_instruction PARAMS ((struct disassemble_info *, bfd_vma, unsigned long,
+ const struct tic80_opcode *));
+static int fill_instruction PARAMS ((struct disassemble_info *, bfd_vma,
+ unsigned long *));
+
+
+/* Print an integer operand. Try to be somewhat smart about the
+ format by assuming that small positive or negative integers are
+ probably loop increment values, structure offsets, or similar
+ values that are more meaningful printed as signed decimal values.
+ Larger numbers are probably better printed as hex values. */
+
+static void
+print_operand_integer (info, value)
+ struct disassemble_info *info;
+ long value;
+{
+ if ((value > 9999 || value < -9999))
+ {
+ (*info -> fprintf_func) (info -> stream, "%#lx", value);
+ }
+ else
+ {
+ (*info -> fprintf_func) (info -> stream, "%ld", value);
+ }
+}
+
+
+/* FIXME: depends upon sizeof (long) == sizeof (float) and
+ also upon host floating point format matching target
+ floating point format. */
+
+static void
+print_operand_float (info, value)
+ struct disassemble_info *info;
+ long value;
+{
+ union { float f; long l; } fval;
+
+ fval.l = value;
+ (*info -> fprintf_func) (info -> stream, "%g", fval.f);
+}
+
+
+static void
+print_operand_control_register (info, value)
+ struct disassemble_info *info;
+ long value;
+{
+ const char *tmp;
+
+ tmp = tic80_value_to_symbol (value, TIC80_OPERAND_CR);
+ if (tmp != NULL)
+ {
+ (*info -> fprintf_func) (info -> stream, "%s", tmp);
+ }
+ else
+ {
+ (*info -> fprintf_func) (info -> stream, "%#lx", value);
+ }
+}
+
+
+static void
+print_operand_condition_code (info, value)
+ struct disassemble_info *info;
+ long value;
+{
+ const char *tmp;
+
+ tmp = tic80_value_to_symbol (value, TIC80_OPERAND_CC);
+ if (tmp != NULL)
+ {
+ (*info -> fprintf_func) (info -> stream, "%s", tmp);
+ }
+ else
+ {
+ (*info -> fprintf_func) (info -> stream, "%ld", value);
+ }
+}
+
+
+static void
+print_operand_bitnum (info, value)
+ struct disassemble_info *info;
+ long value;
+{
+ int bitnum;
+ const char *tmp;
+
+ bitnum = ~value & 0x1F;
+ tmp = tic80_value_to_symbol (bitnum, TIC80_OPERAND_BITNUM);
+ if (tmp != NULL)
+ {
+ (*info -> fprintf_func) (info -> stream, "%s", tmp);
+ }
+ else
+ {
+ (*info -> fprintf_func) (info -> stream, "%ld", bitnum);
+ }
+}
+
+
+/* Print the operand as directed by the flags. */
+
+#define M_SI(insn,op) ((((op) -> flags & TIC80_OPERAND_M_SI) != 0) && ((insn) & (1 << 17)))
+#define M_LI(insn,op) ((((op) -> flags & TIC80_OPERAND_M_LI) != 0) && ((insn) & (1 << 15)))
+#define R_SCALED(insn,op) ((((op) -> flags & TIC80_OPERAND_SCALED) != 0) && ((insn) & (1 << 11)))
+
+static void
+print_operand (info, value, insn, operand, memaddr)
+ struct disassemble_info *info;
+ long value;
+ unsigned long insn;
+ const struct tic80_operand *operand;
+ bfd_vma memaddr;
+{
+ if ((operand -> flags & TIC80_OPERAND_GPR) != 0)
+ {
+ (*info -> fprintf_func) (info -> stream, "r%ld", value);
+ if (M_SI (insn, operand) || M_LI (insn, operand))
+ {
+ (*info -> fprintf_func) (info -> stream, ":m");
+ }
+ }
+ else if ((operand -> flags & TIC80_OPERAND_FPA) != 0)
+ {
+ (*info -> fprintf_func) (info -> stream, "a%ld", value);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_PCREL) != 0)
+ {
+ (*info -> print_address_func) (memaddr + 4 * value, info);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_BASEREL) != 0)
+ {
+ (*info -> print_address_func) (value, info);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_BITNUM) != 0)
+ {
+ print_operand_bitnum (info, value);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_CC) != 0)
+ {
+ print_operand_condition_code (info, value);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_CR) != 0)
+ {
+ print_operand_control_register (info, value);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_FLOAT) != 0)
+ {
+ print_operand_float (info, value);
+ }
+ else if ((operand -> flags & TIC80_OPERAND_BITFIELD))
+ {
+ (*info -> fprintf_func) (info -> stream, "%#lx", value);
+ }
+ else
+ {
+ print_operand_integer (info, value);
+ }
+
+ /* If this is a scaled operand, then print the modifier */
+
+ if (R_SCALED (insn, operand))
+ {
+ (*info -> fprintf_func) (info -> stream, ":s");
+ }
+}
+
+
+/* We have chosen an opcode table entry */
+
+static int
+print_one_instruction (info, memaddr, insn, opcode)
+ struct disassemble_info *info;
+ bfd_vma memaddr;
+ unsigned long insn;
+ const struct tic80_opcode *opcode;
+{
+ const struct tic80_operand *operand;
+ long value;
+ int status;
+ const unsigned char *opindex;
+ int close_paren;
+
+ (*info -> fprintf_func) (info -> stream, "%-10s", opcode -> name);
+
+ for (opindex = opcode -> operands; *opindex != 0; opindex++)
+ {
+ operand = tic80_operands + *opindex;
+
+ /* Extract the value from the instruction. */
+ if (operand -> extract)
+ {
+ value = (*operand -> extract) (insn, (int *) NULL);
+ }
+ else if (operand -> bits == 32)
+ {
+ status = fill_instruction (info, memaddr, (unsigned long *) &value);
+ if (status == -1)
+ {
+ return (status);
+ }
+ }
+ else
+ {
+ value = (insn >> operand -> shift) & ((1 << operand -> bits) - 1);
+ if ((operand -> flags & TIC80_OPERAND_SIGNED) != 0
+ && (value & (1 << (operand -> bits - 1))) != 0)
+ {
+ value -= 1 << operand -> bits;
+ }
+ }
+
+ /* If this operand is enclosed in parenthesis, then print
+ the open paren, otherwise just print the regular comma
+ separator, except for the first operand. */
+
+ if ((operand -> flags & TIC80_OPERAND_PARENS) == 0)
+ {
+ close_paren = 0;
+ if (opindex != opcode -> operands)
+ {
+ (*info -> fprintf_func) (info -> stream, ",");
+ }
+ }
+ else
+ {
+ close_paren = 1;
+ (*info -> fprintf_func) (info -> stream, "(");
+ }
+
+ print_operand (info, value, insn, operand, memaddr);
+
+ /* If we printed an open paren before printing this operand, close
+ it now. The flag gets reset on each loop. */
+
+ if (close_paren)
+ {
+ (*info -> fprintf_func) (info -> stream, ")");
+ }
+ }
+ return (length);
+}
+
+
+
+/* There are no specific bits that tell us for certain whether a vector
+ instruction opcode contains one or two instructions. However since
+ a destination register of r0 is illegal, we can check for nonzero
+ values in both destination register fields. Only opcodes that have
+ two valid instructions will have non-zero in both */
+
+#define TWO_INSN(insn) ((((insn) & (0x1F << 27)) != 0) && (((insn) & (0x1F << 22)) != 0))
+
+static int
+print_instruction (info, memaddr, insn, vec_opcode)
+ struct disassemble_info *info;
+ bfd_vma memaddr;
+ unsigned long insn;
+ const struct tic80_opcode *vec_opcode;
+{
+ const struct tic80_opcode *opcode;
+ const struct tic80_opcode *opcode_end;
+
+ /* Find the first opcode match in the opcodes table. For vector
+ opcodes (vec_opcode != NULL) find the first match that is not the
+ previously found match. FIXME: there should be faster ways to
+ search (hash table or binary search), but don't worry too much
+ about it until other TIc80 support is finished. */
+
+ opcode_end = tic80_opcodes + tic80_num_opcodes;
+ for (opcode = tic80_opcodes; opcode < opcode_end; opcode++)
+ {
+ if ((insn & opcode -> mask) == opcode -> opcode &&
+ opcode != vec_opcode)
+ {
+ break;
+ }
+ }
+
+ if (opcode == opcode_end)
+ {
+ /* No match found, just print the bits as a .word directive */
+ (*info -> fprintf_func) (info -> stream, ".word %#08lx", insn);
+ }
+ else
+ {
+ /* Match found, decode the instruction. */
+ length = print_one_instruction (info, memaddr, insn, opcode);
+ if (opcode -> flags & TIC80_VECTOR && vec_opcode == NULL && TWO_INSN (insn))
+ {
+ /* There is another instruction to print from the same opcode.
+ Print the separator and then find and print the other
+ instruction. */
+ (*info -> fprintf_func) (info -> stream, " || ");
+ length = print_instruction (info, memaddr, insn, opcode);
+ }
+ }
+ return (length);
+}
+
+/* Get the next 32 bit word from the instruction stream and convert it
+ into internal format in the unsigned long INSN, for which we are
+ passed the address. Return 0 on success, -1 on error. */
+
+static int
+fill_instruction (info, memaddr, insnp)
+ struct disassemble_info *info;
+ bfd_vma memaddr;
+ unsigned long *insnp;
+{
+ bfd_byte buffer[4];
+ int status;
+
+ /* Get the bits for the next 32 bit word and put in buffer */
+
+ status = (*info -> read_memory_func) (memaddr + length, buffer, 4, info);
+ if (status != 0)
+ {
+ (*info -> memory_error_func) (status, memaddr, info);
+ return (-1);
+ }
+
+ /* Read was successful, so increment count of bytes read and convert
+ the bits into internal format. */
+
+ length += 4;
+ if (info -> endian == BFD_ENDIAN_LITTLE)
+ {
+ *insnp = bfd_getl32 (buffer);
+ }
+ else if (info -> endian == BFD_ENDIAN_BIG)
+ {
+ *insnp = bfd_getb32 (buffer);
+ }
+ else
+ {
+ /* FIXME: Should probably just default to one or the other */
+ abort ();
+ }
+ return (0);
+}
+
+
+int
+print_insn_tic80 (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+ unsigned long insn;
+ int status;
+
+ length = 0;
+ info->bytes_per_line = 8;
+ status = fill_instruction (info, memaddr, &insn);
+ if (status != -1)
+ {
+ status = print_instruction (info, memaddr, insn, NULL);
+ }
+ return (status);
+}
diff --git a/opcodes/tic80-opc.c b/opcodes/tic80-opc.c
new file mode 100644
index 00000000000..425c308ba64
--- /dev/null
+++ b/opcodes/tic80-opc.c
@@ -0,0 +1,1216 @@
+/* Opcode table for TI TMS320C80 (MVP).
+ Copyright 1996, 1999 Free Software Foundation, Inc.
+
+This file is part of GDB, GAS, and the GNU binutils.
+
+GDB, GAS, and the GNU binutils are free software; you can redistribute
+them and/or modify them under the terms of the GNU General Public
+License as published by the Free Software Foundation; either version
+1, or (at your option) any later version.
+
+GDB, GAS, and the GNU binutils are distributed in the hope that they
+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 file; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include <stdio.h>
+#include "ansidecl.h"
+#include "opcode/tic80.h"
+
+/* This file holds various tables for the TMS320C80 (MVP).
+
+ The opcode table is strictly constant data, so the compiler should
+ be able to put it in the .text section.
+
+ This file also holds the operand table. All knowledge about
+ inserting operands into instructions and vice-versa is kept in this
+ file.
+
+ The predefined register table maps from register names to register
+ values. */
+
+
+/* Table of predefined symbol names, such as general purpose registers,
+ floating point registers, condition codes, control registers, and bit
+ numbers.
+
+ The table is sorted case independently by name so that it is suitable for
+ searching via a binary search using a case independent comparison
+ function.
+
+ Note that the type of the symbol is stored in the upper bits of the value
+ field, which allows the value and type to be passed around as a unit in a
+ single int. The types have to be masked off before using the numeric
+ value as a number.
+*/
+
+const struct predefined_symbol tic80_predefined_symbols[] =
+{
+ { "a0", TIC80_OPERAND_FPA | 0 },
+ { "a1", TIC80_OPERAND_FPA | 1 },
+ { "alw.b", TIC80_OPERAND_CC | 7 },
+ { "alw.h", TIC80_OPERAND_CC | 15 },
+ { "alw.w", TIC80_OPERAND_CC | 23 },
+ { "ANASTAT", TIC80_OPERAND_CR | 0x34 },
+ { "BRK1", TIC80_OPERAND_CR | 0x39 },
+ { "BRK2", TIC80_OPERAND_CR | 0x3A },
+ { "CONFIG", TIC80_OPERAND_CR | 2 },
+ { "DLRU", TIC80_OPERAND_CR | 0x500 },
+ { "DTAG0", TIC80_OPERAND_CR | 0x400 },
+ { "DTAG1", TIC80_OPERAND_CR | 0x401 },
+ { "DTAG10", TIC80_OPERAND_CR | 0x40A },
+ { "DTAG11", TIC80_OPERAND_CR | 0x40B },
+ { "DTAG12", TIC80_OPERAND_CR | 0x40C },
+ { "DTAG13", TIC80_OPERAND_CR | 0x40D },
+ { "DTAG14", TIC80_OPERAND_CR | 0x40E },
+ { "DTAG15", TIC80_OPERAND_CR | 0x40F },
+ { "DTAG2", TIC80_OPERAND_CR | 0x402 },
+ { "DTAG3", TIC80_OPERAND_CR | 0x403 },
+ { "DTAG4", TIC80_OPERAND_CR | 0x404 },
+ { "DTAG5", TIC80_OPERAND_CR | 0x405 },
+ { "DTAG6", TIC80_OPERAND_CR | 0x406 },
+ { "DTAG7", TIC80_OPERAND_CR | 0x407 },
+ { "DTAG8", TIC80_OPERAND_CR | 0x408 },
+ { "DTAG9", TIC80_OPERAND_CR | 0x409 },
+ { "ECOMCNTL", TIC80_OPERAND_CR | 0x33 },
+ { "EIP", TIC80_OPERAND_CR | 1 },
+ { "EPC", TIC80_OPERAND_CR | 0 },
+ { "eq.b", TIC80_OPERAND_BITNUM | 0 },
+ { "eq.f", TIC80_OPERAND_BITNUM | 20 },
+ { "eq.h", TIC80_OPERAND_BITNUM | 10 },
+ { "eq.w", TIC80_OPERAND_BITNUM | 20 },
+ { "eq0.b", TIC80_OPERAND_CC | 2 },
+ { "eq0.h", TIC80_OPERAND_CC | 10 },
+ { "eq0.w", TIC80_OPERAND_CC | 18 },
+ { "FLTADR", TIC80_OPERAND_CR | 0x11 },
+ { "FLTDTH", TIC80_OPERAND_CR | 0x14 },
+ { "FLTDTL", TIC80_OPERAND_CR | 0x13 },
+ { "FLTOP", TIC80_OPERAND_CR | 0x10 },
+ { "FLTTAG", TIC80_OPERAND_CR | 0x12 },
+ { "FPST", TIC80_OPERAND_CR | 8 },
+ { "ge.b", TIC80_OPERAND_BITNUM | 5 },
+ { "ge.f", TIC80_OPERAND_BITNUM | 25 },
+ { "ge.h", TIC80_OPERAND_BITNUM | 15 },
+ { "ge.w", TIC80_OPERAND_BITNUM | 25 },
+ { "ge0.b", TIC80_OPERAND_CC | 3 },
+ { "ge0.h", TIC80_OPERAND_CC | 11 },
+ { "ge0.w", TIC80_OPERAND_CC | 19 },
+ { "gt.b", TIC80_OPERAND_BITNUM | 2 },
+ { "gt.f", TIC80_OPERAND_BITNUM | 22 },
+ { "gt.h", TIC80_OPERAND_BITNUM | 12 },
+ { "gt.w", TIC80_OPERAND_BITNUM | 22 },
+ { "gt0.b", TIC80_OPERAND_CC | 1 },
+ { "gt0.h", TIC80_OPERAND_CC | 9 },
+ { "gt0.w", TIC80_OPERAND_CC | 17 },
+ { "hi.b", TIC80_OPERAND_BITNUM | 6 },
+ { "hi.h", TIC80_OPERAND_BITNUM | 16 },
+ { "hi.w", TIC80_OPERAND_BITNUM | 26 },
+ { "hs.b", TIC80_OPERAND_BITNUM | 9 },
+ { "hs.h", TIC80_OPERAND_BITNUM | 19 },
+ { "hs.w", TIC80_OPERAND_BITNUM | 29 },
+ { "ib.f", TIC80_OPERAND_BITNUM | 28 },
+ { "IE", TIC80_OPERAND_CR | 6 },
+ { "ILRU", TIC80_OPERAND_CR | 0x300 },
+ { "in.f", TIC80_OPERAND_BITNUM | 27 },
+ { "IN0P", TIC80_OPERAND_CR | 0x4000 },
+ { "IN1P", TIC80_OPERAND_CR | 0x4001 },
+ { "INTPEN", TIC80_OPERAND_CR | 4 },
+ { "ITAG0", TIC80_OPERAND_CR | 0x200 },
+ { "ITAG1", TIC80_OPERAND_CR | 0x201 },
+ { "ITAG10", TIC80_OPERAND_CR | 0x20A },
+ { "ITAG11", TIC80_OPERAND_CR | 0x20B },
+ { "ITAG12", TIC80_OPERAND_CR | 0x20C },
+ { "ITAG13", TIC80_OPERAND_CR | 0x20D },
+ { "ITAG14", TIC80_OPERAND_CR | 0x20E },
+ { "ITAG15", TIC80_OPERAND_CR | 0x20F },
+ { "ITAG2", TIC80_OPERAND_CR | 0x202 },
+ { "ITAG3", TIC80_OPERAND_CR | 0x203 },
+ { "ITAG4", TIC80_OPERAND_CR | 0x204 },
+ { "ITAG5", TIC80_OPERAND_CR | 0x205 },
+ { "ITAG6", TIC80_OPERAND_CR | 0x206 },
+ { "ITAG7", TIC80_OPERAND_CR | 0x207 },
+ { "ITAG8", TIC80_OPERAND_CR | 0x208 },
+ { "ITAG9", TIC80_OPERAND_CR | 0x209 },
+ { "le.b", TIC80_OPERAND_BITNUM | 3 },
+ { "le.f", TIC80_OPERAND_BITNUM | 23 },
+ { "le.h", TIC80_OPERAND_BITNUM | 13 },
+ { "le.w", TIC80_OPERAND_BITNUM | 23 },
+ { "le0.b", TIC80_OPERAND_CC | 6 },
+ { "le0.h", TIC80_OPERAND_CC | 14 },
+ { "le0.w", TIC80_OPERAND_CC | 22 },
+ { "lo.b", TIC80_OPERAND_BITNUM | 8 },
+ { "lo.h", TIC80_OPERAND_BITNUM | 18 },
+ { "lo.w", TIC80_OPERAND_BITNUM | 28 },
+ { "ls.b", TIC80_OPERAND_BITNUM | 7 },
+ { "ls.h", TIC80_OPERAND_BITNUM | 17 },
+ { "ls.w", TIC80_OPERAND_BITNUM | 27 },
+ { "lt.b", TIC80_OPERAND_BITNUM | 4 },
+ { "lt.f", TIC80_OPERAND_BITNUM | 24 },
+ { "lt.h", TIC80_OPERAND_BITNUM | 14 },
+ { "lt.w", TIC80_OPERAND_BITNUM | 24 },
+ { "lt0.b", TIC80_OPERAND_CC | 4 },
+ { "lt0.h", TIC80_OPERAND_CC | 12 },
+ { "lt0.w", TIC80_OPERAND_CC | 20 },
+ { "MIP", TIC80_OPERAND_CR | 0x31 },
+ { "MPC", TIC80_OPERAND_CR | 0x30 },
+ { "ne.b", TIC80_OPERAND_BITNUM | 1 },
+ { "ne.f", TIC80_OPERAND_BITNUM | 21 },
+ { "ne.h", TIC80_OPERAND_BITNUM | 11 },
+ { "ne.w", TIC80_OPERAND_BITNUM | 21 },
+ { "ne0.b", TIC80_OPERAND_CC | 5 },
+ { "ne0.h", TIC80_OPERAND_CC | 13 },
+ { "ne0.w", TIC80_OPERAND_CC | 21 },
+ { "nev.b", TIC80_OPERAND_CC | 0 },
+ { "nev.h", TIC80_OPERAND_CC | 8 },
+ { "nev.w", TIC80_OPERAND_CC | 16 },
+ { "ob.f", TIC80_OPERAND_BITNUM | 29 },
+ { "or.f", TIC80_OPERAND_BITNUM | 31 },
+ { "ou.f", TIC80_OPERAND_BITNUM | 26 },
+ { "OUTP", TIC80_OPERAND_CR | 0x4002 },
+ { "PKTREQ", TIC80_OPERAND_CR | 0xD },
+ { "PPERROR", TIC80_OPERAND_CR | 0xA },
+ { "r0", TIC80_OPERAND_GPR | 0 },
+ { "r1", TIC80_OPERAND_GPR | 1 },
+ { "r10", TIC80_OPERAND_GPR | 10 },
+ { "r11", TIC80_OPERAND_GPR | 11 },
+ { "r12", TIC80_OPERAND_GPR | 12 },
+ { "r13", TIC80_OPERAND_GPR | 13 },
+ { "r14", TIC80_OPERAND_GPR | 14 },
+ { "r15", TIC80_OPERAND_GPR | 15 },
+ { "r16", TIC80_OPERAND_GPR | 16 },
+ { "r17", TIC80_OPERAND_GPR | 17 },
+ { "r18", TIC80_OPERAND_GPR | 18 },
+ { "r19", TIC80_OPERAND_GPR | 19 },
+ { "r2", TIC80_OPERAND_GPR | 2 },
+ { "r20", TIC80_OPERAND_GPR | 20 },
+ { "r21", TIC80_OPERAND_GPR | 21 },
+ { "r22", TIC80_OPERAND_GPR | 22 },
+ { "r23", TIC80_OPERAND_GPR | 23 },
+ { "r24", TIC80_OPERAND_GPR | 24 },
+ { "r25", TIC80_OPERAND_GPR | 25 },
+ { "r26", TIC80_OPERAND_GPR | 26 },
+ { "r27", TIC80_OPERAND_GPR | 27 },
+ { "r28", TIC80_OPERAND_GPR | 28 },
+ { "r29", TIC80_OPERAND_GPR | 29 },
+ { "r3", TIC80_OPERAND_GPR | 3 },
+ { "r30", TIC80_OPERAND_GPR | 30 },
+ { "r31", TIC80_OPERAND_GPR | 31 },
+ { "r4", TIC80_OPERAND_GPR | 4 },
+ { "r5", TIC80_OPERAND_GPR | 5 },
+ { "r6", TIC80_OPERAND_GPR | 6 },
+ { "r7", TIC80_OPERAND_GPR | 7 },
+ { "r8", TIC80_OPERAND_GPR | 8 },
+ { "r9", TIC80_OPERAND_GPR | 9 },
+ { "SYSSTK", TIC80_OPERAND_CR | 0x20 },
+ { "SYSTMP", TIC80_OPERAND_CR | 0x21 },
+ { "TCOUNT", TIC80_OPERAND_CR | 0xE },
+ { "TSCALE", TIC80_OPERAND_CR | 0xF },
+ { "uo.f", TIC80_OPERAND_BITNUM | 30 },
+};
+
+const int tic80_num_predefined_symbols = sizeof (tic80_predefined_symbols) / sizeof (struct predefined_symbol);
+
+/* This function takes a predefined symbol name in NAME, symbol class
+ in CLASS, and translates it to a numeric value, which it returns.
+
+ If CLASS is zero, any symbol that matches NAME is translated. If
+ CLASS is non-zero, then only a symbol that has class CLASS is
+ matched.
+
+ If no translation is possible, it returns -1, a value not used by
+ any predefined symbol. Note that the predefined symbol array is
+ presorted case independently by name.
+
+ This function is implemented with the assumption that there are no
+ duplicate names in the predefined symbol array, which happens to be
+ true at the moment.
+
+ */
+
+int
+tic80_symbol_to_value (name, class)
+ char *name;
+ int class;
+{
+ const struct predefined_symbol *pdsp;
+ int low = 0;
+ int middle;
+ int high = tic80_num_predefined_symbols - 1;
+ int cmp;
+ int rtnval = -1;
+
+ while (low <= high)
+ {
+ middle = (low + high) / 2;
+ cmp = strcasecmp (name, tic80_predefined_symbols[middle].name);
+ if (cmp < 0)
+ {
+ high = middle - 1;
+ }
+ else if (cmp > 0)
+ {
+ low = middle + 1;
+ }
+ else
+ {
+ pdsp = &tic80_predefined_symbols[middle];
+ if ((class == 0) || (class & PDS_VALUE (pdsp)))
+ {
+ rtnval = PDS_VALUE (pdsp);
+ }
+ /* For now we assume that there are no duplicate names */
+ break;
+ }
+ }
+ return (rtnval);
+}
+
+/* This function takes a value VAL and finds a matching predefined
+ symbol that is in the operand class specified by CLASS. If CLASS
+ is zero, the first matching symbol is returned. */
+
+const char *
+tic80_value_to_symbol (val, class)
+ int val;
+ int class;
+{
+ const struct predefined_symbol *pdsp;
+ int ival;
+ char *name;
+
+ name = NULL;
+ for (pdsp = tic80_predefined_symbols;
+ pdsp < tic80_predefined_symbols + tic80_num_predefined_symbols;
+ pdsp++)
+ {
+ ival = PDS_VALUE (pdsp) & ~TIC80_OPERAND_MASK;
+ if (ival == val)
+ {
+ if ((class == 0) || (class & PDS_VALUE (pdsp)))
+ {
+ /* Found the desired match */
+ name = PDS_NAME (pdsp);
+ break;
+ }
+ }
+ }
+ return (name);
+}
+
+/* This function returns a pointer to the next symbol in the predefined
+ symbol table after PDSP, or NULL if PDSP points to the last symbol. If
+ PDSP is NULL, it returns the first symbol in the table. Thus it can be
+ used to walk through the table by first calling it with NULL and then
+ calling it with each value it returned on the previous call, until it
+ returns NULL. */
+
+const struct predefined_symbol *
+tic80_next_predefined_symbol (pdsp)
+ const struct predefined_symbol *pdsp;
+{
+ if (pdsp == NULL)
+ {
+ pdsp = tic80_predefined_symbols;
+ }
+ else if (pdsp >= tic80_predefined_symbols &&
+ pdsp < tic80_predefined_symbols + tic80_num_predefined_symbols - 1)
+ {
+ pdsp++;
+ }
+ else
+ {
+ pdsp = NULL;
+ }
+ return (pdsp);
+}
+
+
+
+/* The operands table. The fields are:
+
+ bits, shift, insertion function, extraction function, flags
+ */
+
+const struct tic80_operand tic80_operands[] =
+{
+
+ /* The zero index is used to indicate the end of the list of operands. */
+
+#define UNUSED (0)
+ { 0, 0, 0, 0, 0 },
+
+ /* Short signed immediate value in bits 14-0. */
+
+#define SSI (UNUSED + 1)
+ { 15, 0, NULL, NULL, TIC80_OPERAND_SIGNED },
+
+ /* Short unsigned immediate value in bits 14-0 */
+
+#define SUI (SSI + 1)
+ { 15, 0, NULL, NULL, 0 },
+
+ /* Short unsigned bitfield in bits 14-0. We distinguish this
+ from a regular unsigned immediate value only for the convenience
+ of the disassembler and the user. */
+
+#define SUBF (SUI + 1)
+ { 15, 0, NULL, NULL, TIC80_OPERAND_BITFIELD },
+
+ /* Long signed immediate in following 32 bit word */
+
+#define LSI (SUBF + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_SIGNED },
+
+ /* Long unsigned immediate in following 32 bit word */
+
+#define LUI (LSI + 1)
+ { 32, 0, NULL, NULL, 0 },
+
+ /* Long unsigned bitfield in following 32 bit word. We distinguish
+ this from a regular unsigned immediate value only for the
+ convenience of the disassembler and the user. */
+
+#define LUBF (LUI + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_BITFIELD },
+
+ /* Single precision floating point immediate in following 32 bit
+ word. */
+
+#define SPFI (LUBF + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_FLOAT },
+
+ /* Register in bits 4-0 */
+
+#define REG_0 (SPFI + 1)
+ { 5, 0, NULL, NULL, TIC80_OPERAND_GPR },
+
+ /* Even register in bits 4-0 */
+
+#define REG_0_E (REG_0 + 1)
+ { 5, 0, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_EVEN },
+
+ /* Register in bits 26-22 */
+
+#define REG_22 (REG_0_E + 1)
+ { 5, 22, NULL, NULL, TIC80_OPERAND_GPR },
+
+ /* Even register in bits 26-22 */
+
+#define REG_22_E (REG_22 + 1)
+ { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_EVEN },
+
+ /* Register in bits 31-27 */
+
+#define REG_DEST (REG_22_E + 1)
+ { 5, 27, NULL, NULL, TIC80_OPERAND_GPR },
+
+ /* Even register in bits 31-27 */
+
+#define REG_DEST_E (REG_DEST + 1)
+ { 5, 27, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_EVEN },
+
+ /* Floating point accumulator register (a0-a3) specified by bit 16 (MSB)
+ and bit 11 (LSB) */
+ /* FIXME! Needs to use functions to insert and extract the register
+ number in bits 16 and 11. */
+
+#define REG_FPA (REG_DEST_E + 1)
+ { 0, 0, NULL, NULL, TIC80_OPERAND_FPA },
+
+ /* Short signed PC word offset in bits 14-0 */
+
+#define OFF_SS_PC (REG_FPA + 1)
+ { 15, 0, NULL, NULL, TIC80_OPERAND_PCREL | TIC80_OPERAND_SIGNED },
+
+ /* Long signed PC word offset in following 32 bit word */
+
+#define OFF_SL_PC (OFF_SS_PC + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_PCREL | TIC80_OPERAND_SIGNED },
+
+ /* Short signed base relative byte offset in bits 14-0 */
+
+#define OFF_SS_BR (OFF_SL_PC + 1)
+ { 15, 0, NULL, NULL, TIC80_OPERAND_BASEREL | TIC80_OPERAND_SIGNED },
+
+ /* Long signed base relative byte offset in following 32 bit word */
+
+#define OFF_SL_BR (OFF_SS_BR + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_BASEREL | TIC80_OPERAND_SIGNED },
+
+ /* Long signed base relative byte offset in following 32 bit word
+ with optional ":s" modifier flag in bit 11 */
+
+#define OFF_SL_BR_SCALED (OFF_SL_BR + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_BASEREL | TIC80_OPERAND_SIGNED | TIC80_OPERAND_SCALED },
+
+ /* BITNUM in bits 31-27 */
+
+#define BITNUM (OFF_SL_BR_SCALED + 1)
+ { 5, 27, NULL, NULL, TIC80_OPERAND_BITNUM },
+
+ /* Condition code in bits 31-27 */
+
+#define CC (BITNUM + 1)
+ { 5, 27, NULL, NULL, TIC80_OPERAND_CC },
+
+ /* Control register number in bits 14-0 */
+
+#define CR_SI (CC + 1)
+ { 15, 0, NULL, NULL, TIC80_OPERAND_CR },
+
+ /* Control register number in next 32 bit word */
+
+#define CR_LI (CR_SI + 1)
+ { 32, 0, NULL, NULL, TIC80_OPERAND_CR },
+
+ /* A base register in bits 26-22, enclosed in parens */
+
+#define REG_BASE (CR_LI + 1)
+ { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_PARENS },
+
+ /* A base register in bits 26-22, enclosed in parens, with optional ":m"
+ flag in bit 17 (short immediate instructions only) */
+
+#define REG_BASE_M_SI (REG_BASE + 1)
+ { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_PARENS | TIC80_OPERAND_M_SI },
+
+ /* A base register in bits 26-22, enclosed in parens, with optional ":m"
+ flag in bit 15 (long immediate and register instructions only) */
+
+#define REG_BASE_M_LI (REG_BASE_M_SI + 1)
+ { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_PARENS | TIC80_OPERAND_M_LI },
+
+ /* Scaled register in bits 4-0, with optional ":s" modifier flag in bit 11 */
+
+#define REG_SCALED (REG_BASE_M_LI + 1)
+ { 5, 0, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_SCALED },
+
+ /* Unsigned immediate in bits 4-0, used only for shift instructions */
+
+#define ROTATE (REG_SCALED + 1)
+ { 5, 0, NULL, NULL, 0 },
+
+ /* Unsigned immediate in bits 9-5, used only for shift instructions */
+#define ENDMASK (ROTATE + 1)
+ { 5, 5, NULL, NULL, TIC80_OPERAND_ENDMASK },
+
+};
+
+const int tic80_num_operands = sizeof (tic80_operands)/sizeof(*tic80_operands);
+
+
+/* Macros used to generate entries for the opcodes table. */
+
+#define FIXME 0
+
+/* Short-Immediate Format Instructions - basic opcode */
+#define OP_SI(x) (((x) & 0x7F) << 15)
+#define MASK_SI OP_SI(0x7F)
+
+/* Long-Immediate Format Instructions - basic opcode */
+#define OP_LI(x) (((x) & 0x3FF) << 12)
+#define MASK_LI OP_LI(0x3FF)
+
+/* Register Format Instructions - basic opcode */
+#define OP_REG(x) OP_LI(x) /* For readability */
+#define MASK_REG MASK_LI /* For readability */
+
+/* The 'n' bit at bit 10 */
+#define n(x) ((x) << 10)
+
+/* The 'i' bit at bit 11 */
+#define i(x) ((x) << 11)
+
+/* The 'F' bit at bit 27 */
+#define F(x) ((x) << 27)
+
+/* The 'E' bit at bit 27 */
+#define E(x) ((x) << 27)
+
+/* The 'M' bit at bit 15 in register and long immediate opcodes */
+#define M_REG(x) ((x) << 15)
+#define M_LI(x) ((x) << 15)
+
+/* The 'M' bit at bit 17 in short immediate opcodes */
+#define M_SI(x) ((x) << 17)
+
+/* The 'SZ' field at bits 14-13 in register and long immediate opcodes */
+#define SZ_REG(x) ((x) << 13)
+#define SZ_LI(x) ((x) << 13)
+
+/* The 'SZ' field at bits 16-15 in short immediate opcodes */
+#define SZ_SI(x) ((x) << 15)
+
+/* The 'D' (direct external memory access) bit at bit 10 in long immediate
+ and register opcodes. */
+#define D(x) ((x) << 10)
+
+/* The 'S' (scale offset by data size) bit at bit 11 in long immediate
+ and register opcodes. */
+#define S(x) ((x) << 11)
+
+/* The 'PD' field at bits 10-9 in floating point instructions */
+#define PD(x) ((x) << 9)
+
+/* The 'P2' field at bits 8-7 in floating point instructions */
+#define P2(x) ((x) << 7)
+
+/* The 'P1' field at bits 6-5 in floating point instructions */
+#define P1(x) ((x) << 5)
+
+/* The 'a' field at bit 16 in vector instructions */
+#define V_a1(x) ((x) << 16)
+
+/* The 'a' field at bit 11 in vector instructions */
+#define V_a0(x) ((x) << 11)
+
+/* The 'm' field at bit 10 in vector instructions */
+#define V_m(x) ((x) << 10)
+
+/* The 'S' field at bit 9 in vector instructions */
+#define V_S(x) ((x) << 9)
+
+/* The 'Z' field at bit 8 in vector instructions */
+#define V_Z(x) ((x) << 8)
+
+/* The 'p' field at bit 6 in vector instructions */
+#define V_p(x) ((x) << 6)
+
+/* The opcode field at bits 21-17 for vector instructions */
+#define OP_V(x) ((x) << 17)
+#define MASK_V OP_V(0x1F)
+
+
+/* The opcode table. Formatted for better readability on a wide screen. Also, all
+ entries with the same mnemonic are sorted so that they are adjacent in the table,
+ allowing the use of a hash table to locate the first of a sequence of opcodes that have
+ a particular name. The short immediate forms also come before the long immediate forms
+ so that the assembler will pick the "best fit" for the size of the operand, except for
+ the case of the PC relative forms, where the long forms come first and are the default
+ forms. */
+
+const struct tic80_opcode tic80_opcodes[] = {
+
+ /* The "nop" instruction is really "rdcr 0,r0". We put it first so that this
+ specific bit pattern will get disassembled as a nop rather than an rdcr. The
+ mask of all ones ensures that this will happen. */
+
+ {"nop", OP_SI(0x4), ~0, 0, {0} },
+
+ /* The "br" instruction is really "bbz target,r0,31". We put it first so that
+ this specific bit pattern will get disassembled as a br rather than bbz. */
+
+ {"br", OP_SI(0x48), 0xFFFF8000, 0, {OFF_SS_PC} },
+ {"br", OP_LI(0x391), 0xFFFFF000, 0, {OFF_SL_PC} },
+ {"br", OP_REG(0x390), 0xFFFFF000, 0, {REG_0} },
+ {"br.a", OP_SI(0x49), 0xFFFF8000, 0, {OFF_SS_PC} },
+ {"br.a", OP_LI(0x393), 0xFFFFF000, 0, {OFF_SL_PC} },
+ {"br.a", OP_REG(0x392), 0xFFFFF000, 0, {REG_0} },
+
+ /* Signed integer ADD */
+
+ {"add", OP_SI(0x58), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
+ {"add", OP_LI(0x3B1), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
+ {"add", OP_REG(0x3B0), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Unsigned integer ADD */
+
+ {"addu", OP_SI(0x59), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
+ {"addu", OP_LI(0x3B3), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
+ {"addu", OP_REG(0x3B2), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Bitwise AND */
+
+ {"and", OP_SI(0x11), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"and", OP_LI(0x323), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"and", OP_REG(0x322), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+ {"and.tt", OP_SI(0x11), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"and.tt", OP_LI(0x323), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"and.tt", OP_REG(0x322), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Bitwise AND with ones complement of both sources */
+
+ {"and.ff", OP_SI(0x18), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"and.ff", OP_LI(0x331), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"and.ff", OP_REG(0x330), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Bitwise AND with ones complement of source 1 */
+
+ {"and.ft", OP_SI(0x14), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"and.ft", OP_LI(0x329), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"and.ft", OP_REG(0x328), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Bitwise AND with ones complement of source 2 */
+
+ {"and.tf", OP_SI(0x12), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"and.tf", OP_LI(0x325), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"and.tf", OP_REG(0x324), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Branch Bit One - nonannulled */
+
+ {"bbo", OP_SI(0x4A), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
+ {"bbo", OP_LI(0x395), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
+ {"bbo", OP_REG(0x394), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
+
+ /* Branch Bit One - annulled */
+
+ {"bbo.a", OP_SI(0x4B), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
+ {"bbo.a", OP_LI(0x397), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
+ {"bbo.a", OP_REG(0x396), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
+
+ /* Branch Bit Zero - nonannulled */
+
+ {"bbz", OP_SI(0x48), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
+ {"bbz", OP_LI(0x391), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
+ {"bbz", OP_REG(0x390), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
+
+ /* Branch Bit Zero - annulled */
+
+ {"bbz.a", OP_SI(0x49), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
+ {"bbz.a", OP_LI(0x393), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
+ {"bbz.a", OP_REG(0x392), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
+
+ /* Branch Conditional - nonannulled */
+
+ {"bcnd", OP_SI(0x4C), MASK_SI, 0, {OFF_SS_PC, REG_22, CC} },
+ {"bcnd", OP_LI(0x399), MASK_LI, 0, {OFF_SL_PC, REG_22, CC} },
+ {"bcnd", OP_REG(0x398), MASK_REG, 0, {REG_0, REG_22, CC} },
+
+ /* Branch Conditional - annulled */
+
+ {"bcnd.a", OP_SI(0x4D), MASK_SI, 0, {OFF_SS_PC, REG_22, CC} },
+ {"bcnd.a", OP_LI(0x39B), MASK_LI, 0, {OFF_SL_PC, REG_22, CC} },
+ {"bcnd.a", OP_REG(0x39A), MASK_REG, 0, {REG_0, REG_22, CC} },
+
+ /* Branch Control Register */
+
+ {"brcr", OP_SI(0x6), MASK_SI, 0, {CR_SI} },
+ {"brcr", OP_LI(0x30D), MASK_LI, 0, {CR_LI} },
+ {"brcr", OP_REG(0x30C), MASK_REG, 0, {REG_0} },
+
+ /* Branch and save return - nonannulled */
+
+ {"bsr", OP_SI(0x40), MASK_SI, 0, {OFF_SS_PC, REG_DEST} },
+ {"bsr", OP_LI(0x381), MASK_LI, 0, {OFF_SL_PC, REG_DEST} },
+ {"bsr", OP_REG(0x380), MASK_REG, 0, {REG_0, REG_DEST} },
+
+ /* Branch and save return - annulled */
+
+ {"bsr.a", OP_SI(0x41), MASK_SI, 0, {OFF_SS_PC, REG_DEST} },
+ {"bsr.a", OP_LI(0x383), MASK_LI, 0, {OFF_SL_PC, REG_DEST} },
+ {"bsr.a", OP_REG(0x382), MASK_REG, 0, {REG_0, REG_DEST} },
+
+ /* Send command */
+
+ {"cmnd", OP_SI(0x2), MASK_SI, 0, {SUI} },
+ {"cmnd", OP_LI(0x305), MASK_LI, 0, {LUI} },
+ {"cmnd", OP_REG(0x304), MASK_REG, 0, {REG_0} },
+
+ /* Integer compare */
+
+ {"cmp", OP_SI(0x50), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
+ {"cmp", OP_LI(0x3A1), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
+ {"cmp", OP_REG(0x3A0), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Flush data cache subblock - don't clear subblock preset flag */
+
+ {"dcachec", OP_SI(0x38), F(1) | (MASK_SI & ~M_SI(1)), 0, {SSI, REG_BASE_M_SI} },
+ {"dcachec", OP_LI(0x371), F(1) | (MASK_LI & ~M_LI(1)) | S(1) | D(1), 0, {LSI, REG_BASE_M_LI} },
+ {"dcachec", OP_REG(0x370), F(1) | (MASK_REG & ~M_REG(1)) | S(1) | D(1), 0, {REG_0, REG_BASE_M_LI} },
+
+ /* Flush data cache subblock - clear subblock preset flag */
+
+ {"dcachef", OP_SI(0x38) | F(1), F(1) | (MASK_SI & ~M_SI(1)), 0, {SSI, REG_BASE_M_SI} },
+ {"dcachef", OP_LI(0x371) | F(1), F(1) | (MASK_LI & ~M_LI(1)) | S(1) | D(1), 0, {LSI, REG_BASE_M_LI} },
+ {"dcachef", OP_REG(0x370) | F(1), F(1) | (MASK_REG & ~M_REG(1)) | S(1) | D(1), 0, {REG_0, REG_BASE_M_LI} },
+
+ /* Direct load signed data into register */
+
+ {"dld", OP_LI(0x345) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld", OP_REG(0x344) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.b", OP_LI(0x341) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.b", OP_REG(0x340) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.d", OP_LI(0x347) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"dld.d", OP_REG(0x346) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"dld.h", OP_LI(0x343) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.h", OP_REG(0x342) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+
+ /* Direct load unsigned data into register */
+
+ {"dld.ub", OP_LI(0x351) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.ub", OP_REG(0x350) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.uh", OP_LI(0x353) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dld.uh", OP_REG(0x352) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+
+ /* Direct store data into memory */
+
+ {"dst", OP_LI(0x365) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dst", OP_REG(0x364) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dst.b", OP_LI(0x361) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dst.b", OP_REG(0x360) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dst.d", OP_LI(0x367) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"dst.d", OP_REG(0x366) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"dst.h", OP_LI(0x363) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"dst.h", OP_REG(0x362) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+
+ /* Emulation stop */
+
+ {"estop", OP_LI(0x3FC), MASK_LI, 0, {0} },
+
+ /* Emulation trap */
+
+ {"etrap", OP_SI(0x1) | E(1), MASK_SI | E(1), 0, {SUI} },
+ {"etrap", OP_LI(0x303) | E(1), MASK_LI | E(1), 0, {LUI} },
+ {"etrap", OP_REG(0x302) | E(1), MASK_REG | E(1), 0, {REG_0} },
+
+ /* Floating-point addition */
+
+ {"fadd.ddd", OP_REG(0x3E0) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
+ {"fadd.dsd", OP_REG(0x3E0) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
+ {"fadd.sdd", OP_LI(0x3E1) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
+ {"fadd.sdd", OP_REG(0x3E0) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
+ {"fadd.ssd", OP_LI(0x3E1) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
+ {"fadd.ssd", OP_REG(0x3E0) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
+ {"fadd.sss", OP_LI(0x3E1) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
+ {"fadd.sss", OP_REG(0x3E0) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Floating point compare */
+
+ {"fcmp.dd", OP_REG(0x3EA) | PD(0) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST} },
+ {"fcmp.ds", OP_REG(0x3EA) | PD(0) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST} },
+ {"fcmp.sd", OP_LI(0x3EB) | PD(0) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST} },
+ {"fcmp.sd", OP_REG(0x3EA) | PD(0) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST} },
+ {"fcmp.ss", OP_LI(0x3EB) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
+ {"fcmp.ss", OP_REG(0x3EA) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Floating point divide */
+
+ {"fdiv.ddd", OP_REG(0x3E6) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
+ {"fdiv.dsd", OP_REG(0x3E6) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
+ {"fdiv.sdd", OP_LI(0x3E7) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
+ {"fdiv.sdd", OP_REG(0x3E6) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
+ {"fdiv.ssd", OP_LI(0x3E7) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
+ {"fdiv.ssd", OP_REG(0x3E6) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
+ {"fdiv.sss", OP_LI(0x3E7) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
+ {"fdiv.sss", OP_REG(0x3E6) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Floating point multiply */
+
+ {"fmpy.ddd", OP_REG(0x3E4) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
+ {"fmpy.dsd", OP_REG(0x3E4) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
+ {"fmpy.iii", OP_LI(0x3E5) | PD(2) | P2(2) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_22, REG_DEST} },
+ {"fmpy.iii", OP_REG(0x3E4) | PD(2) | P2(2) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+ {"fmpy.sdd", OP_LI(0x3E5) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
+ {"fmpy.sdd", OP_REG(0x3E4) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
+ {"fmpy.ssd", OP_LI(0x3E5) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
+ {"fmpy.ssd", OP_REG(0x3E4) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
+ {"fmpy.sss", OP_LI(0x3E5) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
+ {"fmpy.sss", OP_REG(0x3E4) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+ {"fmpy.uuu", OP_LI(0x3E5) | PD(3) | P2(3) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LUI, REG_22, REG_DEST} },
+ {"fmpy.uuu", OP_REG(0x3E4) | PD(3) | P2(3) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Convert/Round to Minus Infinity */
+
+ {"frndm.dd", OP_REG(0x3E8) | PD(1) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
+ {"frndm.di", OP_REG(0x3E8) | PD(2) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndm.ds", OP_REG(0x3E8) | PD(0) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndm.du", OP_REG(0x3E8) | PD(3) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndm.id", OP_LI(0x3E9) | PD(1) | P2(3) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndm.id", OP_REG(0x3E8) | PD(1) | P2(3) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndm.is", OP_LI(0x3E9) | PD(0) | P2(3) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndm.is", OP_REG(0x3E8) | PD(0) | P2(3) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndm.sd", OP_LI(0x3E9) | PD(1) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
+ {"frndm.sd", OP_REG(0x3E8) | PD(1) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndm.si", OP_LI(0x3E9) | PD(2) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndm.si", OP_REG(0x3E8) | PD(2) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndm.ss", OP_LI(0x3E9) | PD(0) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndm.ss", OP_REG(0x3E8) | PD(0) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndm.su", OP_LI(0x3E9) | PD(3) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndm.su", OP_REG(0x3E8) | PD(3) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndm.ud", OP_LI(0x3E9) | PD(1) | P2(3) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndm.ud", OP_REG(0x3E8) | PD(1) | P2(3) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndm.us", OP_LI(0x3E9) | PD(0) | P2(3) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndm.us", OP_REG(0x3E8) | PD(0) | P2(3) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+
+ /* Convert/Round to Nearest */
+
+ {"frndn.dd", OP_REG(0x3E8) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
+ {"frndn.di", OP_REG(0x3E8) | PD(2) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndn.ds", OP_REG(0x3E8) | PD(0) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndn.du", OP_REG(0x3E8) | PD(3) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndn.id", OP_LI(0x3E9) | PD(1) | P2(0) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndn.id", OP_REG(0x3E8) | PD(1) | P2(0) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndn.is", OP_LI(0x3E9) | PD(0) | P2(0) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndn.is", OP_REG(0x3E8) | PD(0) | P2(0) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndn.sd", OP_LI(0x3E9) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
+ {"frndn.sd", OP_REG(0x3E8) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndn.si", OP_LI(0x3E9) | PD(2) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndn.si", OP_REG(0x3E8) | PD(2) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndn.ss", OP_LI(0x3E9) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndn.ss", OP_REG(0x3E8) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndn.su", OP_LI(0x3E9) | PD(3) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndn.su", OP_REG(0x3E8) | PD(3) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndn.ud", OP_LI(0x3E9) | PD(1) | P2(0) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndn.ud", OP_REG(0x3E8) | PD(1) | P2(0) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndn.us", OP_LI(0x3E9) | PD(0) | P2(0) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndn.us", OP_REG(0x3E8) | PD(0) | P2(0) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+
+ /* Convert/Round to Positive Infinity */
+
+ {"frndp.dd", OP_REG(0x3E8) | PD(1) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
+ {"frndp.di", OP_REG(0x3E8) | PD(2) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndp.ds", OP_REG(0x3E8) | PD(0) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndp.du", OP_REG(0x3E8) | PD(3) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndp.id", OP_LI(0x3E9) | PD(1) | P2(2) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndp.id", OP_REG(0x3E8) | PD(1) | P2(2) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndp.is", OP_LI(0x3E9) | PD(0) | P2(2) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndp.is", OP_REG(0x3E8) | PD(0) | P2(2) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndp.sd", OP_LI(0x3E9) | PD(1) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
+ {"frndp.sd", OP_REG(0x3E8) | PD(1) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndp.si", OP_LI(0x3E9) | PD(2) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndp.si", OP_REG(0x3E8) | PD(2) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndp.ss", OP_LI(0x3E9) | PD(0) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndp.ss", OP_REG(0x3E8) | PD(0) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndp.su", OP_LI(0x3E9) | PD(3) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndp.su", OP_REG(0x3E8) | PD(3) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndp.ud", OP_LI(0x3E9) | PD(1) | P2(2) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndp.ud", OP_REG(0x3E8) | PD(1) | P2(2) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndp.us", OP_LI(0x3E9) | PD(0) | P2(2) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndp.us", OP_REG(0x3E8) | PD(0) | P2(2) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+
+ /* Convert/Round to Zero */
+
+ {"frndz.dd", OP_REG(0x3E8) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
+ {"frndz.di", OP_REG(0x3E8) | PD(2) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndz.ds", OP_REG(0x3E8) | PD(0) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndz.du", OP_REG(0x3E8) | PD(3) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
+ {"frndz.id", OP_LI(0x3E9) | PD(1) | P2(1) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndz.id", OP_REG(0x3E8) | PD(1) | P2(1) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndz.is", OP_LI(0x3E9) | PD(0) | P2(1) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndz.is", OP_REG(0x3E8) | PD(0) | P2(1) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndz.sd", OP_LI(0x3E9) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
+ {"frndz.sd", OP_REG(0x3E8) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndz.si", OP_LI(0x3E9) | PD(2) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndz.si", OP_REG(0x3E8) | PD(2) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndz.ss", OP_LI(0x3E9) | PD(0) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndz.ss", OP_REG(0x3E8) | PD(0) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndz.su", OP_LI(0x3E9) | PD(3) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"frndz.su", OP_REG(0x3E8) | PD(3) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+ {"frndz.ud", OP_LI(0x3E9) | PD(1) | P2(1) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
+ {"frndz.ud", OP_REG(0x3E8) | PD(1) | P2(1) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"frndz.us", OP_LI(0x3E9) | PD(0) | P2(1) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
+ {"frndz.us", OP_REG(0x3E8) | PD(0) | P2(1) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+
+ /* Floating point square root */
+
+ {"fsqrt.dd", OP_REG(0x3EE) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
+ {"fsqrt.sd", OP_LI(0x3EF) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
+ {"fsqrt.sd", OP_REG(0x3EE) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
+ {"fsqrt.ss", OP_LI(0x3EF) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
+ {"fsqrt.ss", OP_REG(0x3EE) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
+
+ /* Floating point subtraction */
+
+ { "fsub.ddd", OP_REG(0x3E2) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
+ { "fsub.dsd", OP_REG(0x3E2) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
+ { "fsub.sdd", OP_LI(0x3E3) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
+ { "fsub.sdd", OP_REG(0x3E2) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
+ { "fsub.ssd", OP_LI(0x3E3) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
+ { "fsub.ssd", OP_REG(0x3E2) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
+ { "fsub.sss", OP_LI(0x3E3) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
+ { "fsub.sss", OP_REG(0x3E2) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Illegal instructions */
+
+ {"illop0", OP_SI(0x0), MASK_SI, 0, {0} },
+ {"illopF", 0x1FF << 13, 0x1FF << 13, 0, {0} },
+
+ /* Jump and save return */
+
+ {"jsr", OP_SI(0x44), MASK_SI, 0, {OFF_SS_BR, REG_BASE, REG_DEST} },
+ {"jsr", OP_LI(0x389), MASK_LI, 0, {OFF_SL_BR, REG_BASE, REG_DEST} },
+ {"jsr", OP_REG(0x388), MASK_REG, 0, {REG_0, REG_BASE, REG_DEST} },
+ {"jsr.a", OP_SI(0x45), MASK_SI, 0, {OFF_SS_BR, REG_BASE, REG_DEST} },
+ {"jsr.a", OP_LI(0x38B), MASK_LI, 0, {OFF_SL_BR, REG_BASE, REG_DEST} },
+ {"jsr.a", OP_REG(0x38A), MASK_REG, 0, {REG_0, REG_BASE, REG_DEST} },
+
+ /* Load Signed Data Into Register */
+
+ {"ld", OP_SI(0x22), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"ld", OP_LI(0x345) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld", OP_REG(0x344) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.b", OP_SI(0x20), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"ld.b", OP_LI(0x341) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.b", OP_REG(0x340) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.d", OP_SI(0x23), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST_E} },
+ {"ld.d", OP_LI(0x347) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"ld.d", OP_REG(0x346) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"ld.h", OP_SI(0x21), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"ld.h", OP_LI(0x343) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.h", OP_REG(0x342) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+
+ /* Load Unsigned Data Into Register */
+
+ {"ld.ub", OP_SI(0x28), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"ld.ub", OP_LI(0x351) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.ub", OP_REG(0x350) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.uh", OP_SI(0x29), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"ld.uh", OP_LI(0x353) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"ld.uh", OP_REG(0x352) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+
+ /* Leftmost one */
+
+ {"lmo", OP_LI(0x3F0), MASK_LI, 0, {REG_22, REG_DEST} },
+
+ /* Bitwise logical OR. Note that "or.tt" and "or" are the same instructions. */
+
+ {"or.ff", OP_SI(0x1E), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
+ {"or.ff", OP_LI(0x33D), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
+ {"or.ff", OP_REG(0x33C), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+ {"or.ft", OP_SI(0x1D), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
+ {"or.ft", OP_LI(0x33B), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
+ {"or.ft", OP_REG(0x33A), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+ {"or.tf", OP_SI(0x1B), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
+ {"or.tf", OP_LI(0x337), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
+ {"or.tf", OP_REG(0x336), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+ {"or.tt", OP_SI(0x17), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
+ {"or.tt", OP_LI(0x32F), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
+ {"or.tt", OP_REG(0x32E), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+ {"or", OP_SI(0x17), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
+ {"or", OP_LI(0x32F), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
+ {"or", OP_REG(0x32E), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Read Control Register */
+
+ {"rdcr", OP_SI(0x4), MASK_SI | (0x1F << 22), 0, {CR_SI, REG_DEST} },
+ {"rdcr", OP_LI(0x309), MASK_LI | (0x1F << 22), 0, {CR_LI, REG_DEST} },
+ {"rdcr", OP_REG(0x308), MASK_REG | (0x1F << 22), 0, {REG_0, REG_DEST} },
+
+ /* Rightmost one */
+
+ {"rmo", OP_LI(0x3F2), MASK_LI, 0, {REG_22, REG_DEST} },
+
+ /* Shift Register Left - note that rotl, shl, and ins are all alternate names for one of the shift instructions.
+ They appear prior to their sl equivalent so that they will be diassembled as the alternate name. */
+
+
+ {"ins", OP_REG(0x31E) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"ins", OP_SI(0xF) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"rotl", OP_REG(0x310) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"rotl", OP_SI(0x8) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"shl", OP_REG(0x31C) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"shl", OP_SI(0xE) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.dm", OP_REG(0x312) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.dm", OP_SI(0x9) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.ds", OP_REG(0x314) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.ds", OP_SI(0xA) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.dz", OP_REG(0x310) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.dz", OP_SI(0x8) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.em", OP_REG(0x318) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.em", OP_SI(0xC) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.es", OP_REG(0x31A) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.es", OP_SI(0xD) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.ez", OP_REG(0x316) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.ez", OP_SI(0xB) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.im", OP_REG(0x31E) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.im", OP_SI(0xF) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sl.iz", OP_REG(0x31C) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sl.iz", OP_SI(0xE) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+
+ /* Shift Register Left With Inverted Endmask */
+
+ {"sli.dm", OP_REG(0x312) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.dm", OP_SI(0x9) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.ds", OP_REG(0x314) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.ds", OP_SI(0xA) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.dz", OP_REG(0x310) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.dz", OP_SI(0x8) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.em", OP_REG(0x318) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.em", OP_SI(0xC) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.es", OP_REG(0x31A) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.es", OP_SI(0xD) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.ez", OP_REG(0x316) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.ez", OP_SI(0xB) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.im", OP_REG(0x31E) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.im", OP_SI(0xF) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sli.iz", OP_REG(0x31C) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sli.iz", OP_SI(0xE) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+
+ /* Shift Register Right - note that exts, extu, rotr, sra, and srl are all alternate names for one of the shift instructions.
+ They appear prior to their sr equivalent so that they will be diassembled as the alternate name. */
+
+ {"exts", OP_REG(0x314) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"exts", OP_SI(0xA) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"extu", OP_REG(0x310) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"extu", OP_SI(0x8) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"rotr", OP_REG(0x310) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"rotr", OP_SI(0x8) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sra", OP_REG(0x31A) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sra", OP_SI(0xD) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"srl", OP_REG(0x316) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"srl", OP_SI(0xB) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.dm", OP_REG(0x312) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.dm", OP_SI(0x9) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.ds", OP_REG(0x314) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.ds", OP_SI(0xA) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.dz", OP_REG(0x310) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.dz", OP_SI(0x8) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.em", OP_REG(0x318) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.em", OP_SI(0xC) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.es", OP_REG(0x31A) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.es", OP_SI(0xD) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.ez", OP_REG(0x316) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.ez", OP_SI(0xB) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.im", OP_REG(0x31E) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.im", OP_SI(0xF) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sr.iz", OP_REG(0x31C) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sr.iz", OP_SI(0xE) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+
+ /* Shift Register Right With Inverted Endmask */
+
+ {"sri.dm", OP_REG(0x312) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.dm", OP_SI(0x9) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.ds", OP_REG(0x314) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.ds", OP_SI(0xA) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.dz", OP_REG(0x310) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.dz", OP_SI(0x8) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.em", OP_REG(0x318) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.em", OP_SI(0xC) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.es", OP_REG(0x31A) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.es", OP_SI(0xD) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.ez", OP_REG(0x316) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.ez", OP_SI(0xB) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.im", OP_REG(0x31E) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.im", OP_SI(0xF) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+ {"sri.iz", OP_REG(0x31C) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
+ {"sri.iz", OP_SI(0xE) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
+
+ /* Store Data into Memory */
+
+ {"st", OP_SI(0x32), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"st", OP_LI(0x365) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"st", OP_REG(0x364) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"st.b", OP_SI(0x30), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"st.b", OP_LI(0x361) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"st.b", OP_REG(0x360) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"st.d", OP_SI(0x33), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST_E} },
+ {"st.d", OP_LI(0x367) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"st.d", OP_REG(0x366) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
+ {"st.h", OP_SI(0x31), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
+ {"st.h", OP_LI(0x363) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
+ {"st.h", OP_REG(0x362) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
+
+ /* Signed Integer Subtract */
+
+ {"sub", OP_SI(0x5A), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
+ {"sub", OP_LI(0x3B5), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
+ {"sub", OP_REG(0x3B4), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Unsigned Integer Subtract */
+
+ {"subu", OP_SI(0x5B), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
+ {"subu", OP_LI(0x3B7), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
+ {"subu", OP_REG(0x3B6), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Write Control Register
+ Is a special form of the "swcr" instruction so comes before it in the table. */
+
+ {"wrcr", OP_SI(0x5), MASK_SI | (0x1F << 27), 0, {CR_SI, REG_22} },
+ {"wrcr", OP_LI(0x30B), MASK_LI | (0x1F << 27), 0, {CR_LI, REG_22} },
+ {"wrcr", OP_REG(0x30A), MASK_REG | (0x1F << 27), 0, {REG_0, REG_22} },
+
+ /* Swap Control Register */
+
+ {"swcr", OP_SI(0x5), MASK_SI, 0, {CR_SI, REG_22, REG_DEST} },
+ {"swcr", OP_LI(0x30B), MASK_LI, 0, {CR_LI, REG_22, REG_DEST} },
+ {"swcr", OP_REG(0x30A), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ /* Trap */
+
+ {"trap", OP_SI(0x1) | E(0), MASK_SI | E(1), 0, {SUI} },
+ {"trap", OP_LI(0x303) | E(0), MASK_LI | E(1), 0, {LUI} },
+ {"trap", OP_REG(0x302) | E(0), MASK_REG | E(1), 0, {REG_0} },
+
+ /* Vector Floating-Point Add */
+
+ {"vadd.dd", OP_REG(0x3C0) | P2(1) | P1(1), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0_E, REG_22_E, REG_22_E} },
+ {"vadd.sd", OP_LI(0x3C1) | P2(1) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22_E, REG_22_E} },
+ {"vadd.sd", OP_REG(0x3C0) | P2(1) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E, REG_22_E} },
+ {"vadd.ss", OP_LI(0x3C1) | P2(0) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22, REG_22} },
+ {"vadd.ss", OP_REG(0x3C0) | P2(0) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22, REG_22} },
+
+ /* Vector Floating-Point Multiply and Add to Accumulator FIXME! This is not yet fully implemented.
+ From the documentation there appears to be no way to tell the difference between the opcodes for
+ instructions that have register destinations and instructions that have accumulator destinations.
+ Further investigation is necessary. Since this isn't critical to getting a TIC80 toolchain up
+ and running, it is defered until later. */
+
+ /* Vector Floating-Point Multiply
+ Note: If r0 is in the destination reg, then this is a "vector nop" instruction. */
+
+ {"vmpy.dd", OP_REG(0x3C4) | P2(1) | P1(1), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {REG_0_E, REG_22_E, REG_22_E} },
+ {"vmpy.sd", OP_LI(0x3C5) | P2(1) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {SPFI, REG_22_E, REG_22_E} },
+ {"vmpy.sd", OP_REG(0x3C4) | P2(1) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {REG_0, REG_22_E, REG_22_E} },
+ {"vmpy.ss", OP_LI(0x3C5) | P2(0) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {SPFI, REG_22, REG_22} },
+ {"vmpy.ss", OP_REG(0x3C4) | P2(0) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {REG_0, REG_22, REG_22} },
+
+ /* Vector Floating-Point Multiply and Subtract from Accumulator
+ FIXME: See note above for vmac instruction */
+
+ /* Vector Floating-Point Subtract Accumulator From Source
+ FIXME: See note above for vmac instruction */
+
+ /* Vector Round With Floating-Point Input
+ FIXME: See note above for vmac instruction */
+
+ /* Vector Round with Integer Input */
+
+ {"vrnd.id", OP_LI (0x3CB) | P2(1) | P1(0), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LSI, REG_22_E}},
+ {"vrnd.id", OP_REG (0x3CA) | P2(1) | P1(0), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E}},
+ {"vrnd.is", OP_LI (0x3CB) | P2(0) | P1(0), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LSI, REG_22}},
+ {"vrnd.is", OP_REG (0x3CA) | P2(0) | P1(0), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22}},
+ {"vrnd.ud", OP_LI (0x3CB) | P2(1) | P1(1), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LUI, REG_22_E}},
+ {"vrnd.ud", OP_REG (0x3CA) | P2(1) | P1(1), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E}},
+ {"vrnd.us", OP_LI (0x3CB) | P2(0) | P1(1), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LUI, REG_22}},
+ {"vrnd.us", OP_REG (0x3CA) | P2(0) | P1(1), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22}},
+
+ /* Vector Floating-Point Subtract */
+
+ {"vsub.dd", OP_REG(0x3C2) | P2(1) | P1(1), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0_E, REG_22_E, REG_22_E} },
+ {"vsub.sd", OP_LI(0x3C3) | P2(1) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22_E, REG_22_E} },
+ {"vsub.sd", OP_REG(0x3C2) | P2(1) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E, REG_22_E} },
+ {"vsub.ss", OP_LI(0x3C3) | P2(0) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22, REG_22} },
+ {"vsub.ss", OP_REG(0x3C2) | P2(0) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22, REG_22} },
+
+ /* Vector Load Data Into Register - Note that the vector load/store instructions come after the other
+ vector instructions so that the disassembler will always print the load/store instruction second for
+ vector instructions that have two instructions in the same opcode. */
+
+ {"vld0.d", OP_V(0x1E) | V_m(1) | V_S(1) | V_p(0), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST_E} },
+ {"vld0.s", OP_V(0x1E) | V_m(1) | V_S(0) | V_p(0), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST} },
+ {"vld1.d", OP_V(0x1E) | V_m(1) | V_S(1) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST_E} },
+ {"vld1.s", OP_V(0x1E) | V_m(1) | V_S(0) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST} },
+
+ /* Vector Store Data Into Memory - Note that the vector load/store instructions come after the other
+ vector instructions so that the disassembler will always print the load/store instruction second for
+ vector instructions that have two instructions in the same opcode. */
+
+ {"vst.d", OP_V(0x1E) | V_m(0) | V_S(1) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST_E} },
+ {"vst.s", OP_V(0x1E) | V_m(0) | V_S(0) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST} },
+
+ {"xnor", OP_SI(0x19), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"xnor", OP_LI(0x333), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"xnor", OP_REG(0x332), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+ {"xor", OP_SI(0x16), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
+ {"xor", OP_LI(0x32D), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
+ {"xor", OP_REG(0x32C), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
+
+};
+
+const int tic80_num_opcodes = sizeof (tic80_opcodes) / sizeof (tic80_opcodes[0]);
diff --git a/opcodes/v850-dis.c b/opcodes/v850-dis.c
new file mode 100644
index 00000000000..610625b6a19
--- /dev/null
+++ b/opcodes/v850-dis.c
@@ -0,0 +1,381 @@
+/* Disassemble V850 instructions.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+#include <stdio.h>
+
+#include "ansidecl.h"
+#include "opcode/v850.h"
+#include "dis-asm.h"
+#include "opintl.h"
+
+static const char *const v850_reg_names[] =
+{ "r0", "r1", "r2", "sp", "gp", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
+ "r24", "r25", "r26", "r27", "r28", "r29", "ep", "lp" };
+
+static const char *const v850_sreg_names[] =
+{ "eipc", "eipsw", "fepc", "fepsw", "ecr", "psw", "sr6", "sr7",
+ "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15",
+ "ctpc", "ctpsw", "dbpc", "dbpsw", "ctbp", "sr21", "sr22", "sr23",
+ "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31",
+ "sr16", "sr17", "sr18", "sr19", "sr20", "sr21", "sr22", "sr23",
+ "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31" };
+
+static const char *const v850_cc_names[] =
+{ "v", "c/l", "z", "nh", "s/n", "t", "lt", "le",
+ "nv", "nc/nl", "nz", "h", "ns/p", "sa", "ge", "gt" };
+
+static int
+disassemble (memaddr, info, insn)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+ unsigned long insn;
+{
+ struct v850_opcode * op = (struct v850_opcode *)v850_opcodes;
+ const struct v850_operand * operand;
+ int match = 0;
+ int short_op = ((insn & 0x0600) != 0x0600);
+ int bytes_read;
+ int target_processor;
+
+ /* Special case: 32 bit MOV */
+ if ((insn & 0xffe0) == 0x0620)
+ short_op = true;
+
+ bytes_read = short_op ? 2 : 4;
+
+ /* If this is a two byte insn, then mask off the high bits. */
+ if (short_op)
+ insn &= 0xffff;
+
+ switch (info->mach)
+ {
+ case 0:
+ default:
+ target_processor = PROCESSOR_V850;
+ break;
+
+ case bfd_mach_v850e:
+ target_processor = PROCESSOR_V850E;
+ break;
+
+ case bfd_mach_v850ea:
+ target_processor = PROCESSOR_V850EA;
+ break;
+ }
+
+ /* Find the opcode. */
+ while (op->name)
+ {
+ if ((op->mask & insn) == op->opcode
+ && (op->processors & target_processor))
+ {
+ const unsigned char * opindex_ptr;
+ unsigned int opnum;
+ unsigned int memop;
+
+ match = 1;
+ (*info->fprintf_func) (info->stream, "%s\t", op->name);
+/*fprintf (stderr, "match: mask: %x insn: %x, opcode: %x, name: %s\n", op->mask, insn, op->opcode, op->name );*/
+
+ memop = op->memop;
+ /* Now print the operands.
+
+ MEMOP is the operand number at which a memory
+ address specification starts, or zero if this
+ instruction has no memory addresses.
+
+ A memory address is always two arguments.
+
+ This information allows us to determine when to
+ insert commas into the output stream as well as
+ when to insert disp[reg] expressions onto the
+ output stream. */
+
+ for (opindex_ptr = op->operands, opnum = 1;
+ *opindex_ptr != 0;
+ opindex_ptr++, opnum++)
+ {
+ long value;
+ int flag;
+ int status;
+ bfd_byte buffer[ 4 ];
+
+ operand = &v850_operands[*opindex_ptr];
+
+ if (operand->extract)
+ value = (operand->extract) (insn, 0);
+ else
+ {
+ if (operand->bits == -1)
+ value = (insn & operand->shift);
+ else
+ value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
+
+ if (operand->flags & V850_OPERAND_SIGNED)
+ value = ((long)(value << (32 - operand->bits))
+ >> (32 - operand->bits));
+ }
+
+ /* The first operand is always output without any
+ special handling.
+
+ For the following arguments:
+
+ If memop && opnum == memop + 1, then we need '[' since
+ we're about to output the register used in a memory
+ reference.
+
+ If memop && opnum == memop + 2, then we need ']' since
+ we just finished the register in a memory reference. We
+ also need a ',' before this operand.
+
+ Else we just need a comma.
+
+ We may need to output a trailing ']' if the last operand
+ in an instruction is the register for a memory address.
+
+ The exception (and there's always an exception) is the
+ "jmp" insn which needs square brackets around it's only
+ register argument. */
+
+ if (memop && opnum == memop + 1) info->fprintf_func (info->stream, "[");
+ else if (memop && opnum == memop + 2) info->fprintf_func (info->stream, "],");
+ else if (memop == 1 && opnum == 1
+ && (operand->flags & V850_OPERAND_REG))
+ info->fprintf_func (info->stream, "[");
+ else if (opnum > 1) info->fprintf_func (info->stream, ", ");
+
+ /* extract the flags, ignorng ones which do not effect disassembly output. */
+ flag = operand->flags;
+ flag &= ~ V850_OPERAND_SIGNED;
+ flag &= ~ V850_OPERAND_RELAX;
+ flag &= - flag;
+
+ switch (flag)
+ {
+ case V850_OPERAND_REG: info->fprintf_func (info->stream, "%s", v850_reg_names[value]); break;
+ case V850_OPERAND_SRG: info->fprintf_func (info->stream, "%s", v850_sreg_names[value]); break;
+ case V850_OPERAND_CC: info->fprintf_func (info->stream, "%s", v850_cc_names[value]); break;
+ case V850_OPERAND_EP: info->fprintf_func (info->stream, "ep"); break;
+ default: info->fprintf_func (info->stream, "%d", value); break;
+ case V850_OPERAND_DISP:
+ {
+ bfd_vma addr = value + memaddr;
+
+ /* On the v850 the top 8 bits of an address are used by an overlay manager.
+ Thus it may happen that when we are looking for a symbol to match
+ against an address with some of its top bits set, the search fails to
+ turn up an exact match. In this case we try to find an exact match
+ against a symbol in the lower address space, and if we find one, we
+ use that address. We only do this for JARL instructions however, as
+ we do not want to misinterpret branch instructions. */
+ if (operand->bits == 22)
+ {
+ if ( ! info->symbol_at_address_func (addr, info)
+ && ((addr & 0xFF000000) != 0)
+ && info->symbol_at_address_func (addr & 0x00FFFFFF, info))
+ {
+ addr &= 0x00FFFFFF;
+ }
+ }
+ info->print_address_func (addr, info);
+ break;
+ }
+
+ case V850E_PUSH_POP:
+ {
+ static int list12_regs[32] = { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24 };
+ static int list18_h_regs[32] = { 19, 18, 17, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 30, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24 };
+ static int list18_l_regs[32] = { 3, 2, 1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 14, 15, 13, 12, 7, 6, 5, 4, 11, 10, 9, 8 };
+ int * regs;
+ int i;
+ unsigned long int mask = 0;
+ int pc = false;
+ int sr = false;
+
+
+ switch (operand->shift)
+ {
+ case 0xffe00001: regs = list12_regs; break;
+ case 0xfff8000f: regs = list18_h_regs; break;
+ case 0xfff8001f: regs = list18_l_regs; value &= ~0x10; break; /* Do not include magic bit */
+ default:
+ /* xgettext:c-format */
+ fprintf (stderr, _("unknown operand shift: %x\n"), operand->shift );
+ abort();
+ }
+
+ for (i = 0; i < 32; i++)
+ {
+ if (value & (1 << i))
+ {
+ switch (regs[ i ])
+ {
+ default: mask |= (1 << regs[ i ]); break;
+ /* xgettext:c-format */
+ case 0: fprintf (stderr, _("unknown pop reg: %d\n"), i ); abort();
+ case -1: pc = true; break;
+ case -2: sr = true; break;
+ }
+ }
+ }
+
+ info->fprintf_func (info->stream, "{");
+
+ if (mask || pc || sr)
+ {
+ if (mask)
+ {
+ unsigned int bit;
+ int shown_one = false;
+
+ for (bit = 0; bit < 32; bit++)
+ if (mask & (1 << bit))
+ {
+ unsigned long int first = bit;
+ unsigned long int last;
+
+ if (shown_one)
+ info->fprintf_func (info->stream, ", ");
+ else
+ shown_one = true;
+
+ info->fprintf_func (info->stream, v850_reg_names[first]);
+
+ for (bit++; bit < 32; bit++)
+ if ((mask & (1 << bit)) == 0)
+ break;
+
+ last = bit;
+
+ if (last > first + 1)
+ {
+ info->fprintf_func (info->stream, " - %s", v850_reg_names[ last - 1 ]);
+ }
+ }
+ }
+
+ if (pc)
+ info->fprintf_func (info->stream, "%sPC", mask ? ", " : "");
+ if (sr)
+ info->fprintf_func (info->stream, "%sSR", (mask || pc) ? ", " : "");
+ }
+
+ info->fprintf_func (info->stream, "}");
+ }
+ break;
+
+ case V850E_IMMEDIATE16:
+ status = info->read_memory_func (memaddr + bytes_read, buffer, 2, info);
+ if (status == 0)
+ {
+ bytes_read += 2;
+ value = bfd_getl16 (buffer);
+
+ /* If this is a DISPOSE instruction with ff set to 0x10, then shift value up by 16. */
+ if ((insn & 0x001fffc0) == 0x00130780)
+ value <<= 16;
+
+ info->fprintf_func (info->stream, "0x%x", value);
+ }
+ else
+ {
+ info->memory_error_func (status, memaddr + bytes_read, info);
+ }
+ break;
+
+ case V850E_IMMEDIATE32:
+ status = info->read_memory_func (memaddr + bytes_read, buffer, 4, info);
+ if (status == 0)
+ {
+ bytes_read += 4;
+ value = bfd_getl32 (buffer);
+ info->fprintf_func (info->stream, "0x%lx", value);
+ }
+ else
+ {
+ info->memory_error_func (status, memaddr + bytes_read, info);
+ }
+ break;
+ }
+
+ /* Handle jmp correctly. */
+ if (memop == 1 && opnum == 1
+ && ((operand->flags & V850_OPERAND_REG) != 0))
+ (*info->fprintf_func) (info->stream, "]");
+ }
+
+ /* Close any square bracket we left open. */
+ if (memop && opnum == memop + 2)
+ (*info->fprintf_func) (info->stream, "]");
+
+ /* All done. */
+ break;
+ }
+ op++;
+ }
+
+ if (!match)
+ {
+ if (short_op)
+ info->fprintf_func (info->stream, ".short\t0x%04x", insn);
+ else
+ info->fprintf_func (info->stream, ".long\t0x%08x", insn);
+ }
+
+ return bytes_read;
+}
+
+int
+print_insn_v850 (memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info * info;
+{
+ int status;
+ bfd_byte buffer[ 4 ];
+ unsigned long insn = 0;
+
+ /* First figure out how big the opcode is. */
+
+ status = info->read_memory_func (memaddr, buffer, 2, info);
+ if (status == 0)
+ {
+ insn = bfd_getl16 (buffer);
+
+ if ( (insn & 0x0600) == 0x0600
+ && (insn & 0xffe0) != 0x0620)
+ {
+ /* If this is a 4 byte insn, read 4 bytes of stuff. */
+ status = info->read_memory_func (memaddr, buffer, 4, info);
+
+ if (status == 0)
+ insn = bfd_getl32 (buffer);
+ }
+ }
+
+ if (status != 0)
+ {
+ info->memory_error_func (status, memaddr, info);
+ return -1;
+ }
+
+ /* Make sure we tell our caller how many bytes we consumed. */
+ return disassemble (memaddr, info, insn);
+}
diff --git a/opcodes/v850-opc.c b/opcodes/v850-opc.c
new file mode 100644
index 00000000000..d34857efa10
--- /dev/null
+++ b/opcodes/v850-opc.c
@@ -0,0 +1,786 @@
+/* Assemble V850 instructions.
+ Copyright (C) 1996 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "ansidecl.h"
+#include "opcode/v850.h"
+#include <stdio.h>
+#include "opintl.h"
+
+/* regular opcode */
+#define OP(x) ((x & 0x3f) << 5)
+#define OP_MASK OP (0x3f)
+
+/* conditional branch opcode */
+#define BOP(x) ((0x0b << 7) | (x & 0x0f))
+#define BOP_MASK ((0x0f << 7) | 0x0f)
+
+/* one-word opcodes */
+#define one(x) ((unsigned int) (x))
+
+/* two-word opcodes */
+#define two(x,y) ((unsigned int) (x) | ((unsigned int) (y) << 16))
+
+
+
+/* The functions used to insert and extract complicated operands. */
+
+/* Note: There is a conspiracy between these functions and
+ v850_insert_operand() in gas/config/tc-v850.c. Error messages
+ containing the string 'out of range' will be ignored unless a
+ specific command line option is given to GAS. */
+
+static const char * not_valid = N_ ("displacement value is not in range and is not aligned");
+static const char * out_of_range = N_ ("displacement value is out of range");
+static const char * not_aligned = N_ ("displacement value is not aligned");
+
+static const char * immediate_out_of_range = N_ ("immediate value is out of range");
+
+static unsigned long
+insert_d9 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char ** errmsg;
+{
+ if (value > 0xff || value < -0x100)
+ {
+ if ((value % 2) != 0)
+ * errmsg = _("branch value not in range and to odd offset");
+ else
+ * errmsg = _("branch value out of range");
+ }
+ else if ((value % 2) != 0)
+ * errmsg = _("branch to odd offset");
+
+ return (insn | ((value & 0x1f0) << 7) | ((value & 0x0e) << 3));
+}
+
+static unsigned long
+extract_d9 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ unsigned long ret = ((insn & 0xf800) >> 7) | ((insn & 0x0070) >> 3);
+
+ if ((insn & 0x8000) != 0)
+ ret -= 0x0200;
+
+ return ret;
+}
+
+static unsigned long
+insert_d22 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char ** errmsg;
+{
+ if (value > 0x1fffff || value < -0x200000)
+ {
+ if ((value % 2) != 0)
+ * errmsg = _("branch value not in range and to an odd offset");
+ else
+ * errmsg = _("branch value out of range");
+ }
+ else if ((value % 2) != 0)
+ * errmsg = _("branch to odd offset");
+
+ return (insn | ((value & 0xfffe) << 16) | ((value & 0x3f0000) >> 16));
+}
+
+static unsigned long
+extract_d22 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ signed long ret = ((insn & 0xfffe0000) >> 16) | ((insn & 0x3f) << 16);
+
+ return (unsigned long) ((ret << 10) >> 10);
+}
+
+static unsigned long
+insert_d16_15 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char ** errmsg;
+{
+ if (value > 0x7fff || value < -0x8000)
+ {
+ if ((value % 2) != 0)
+ * errmsg = _(not_valid);
+ else
+ * errmsg = _(out_of_range);
+ }
+ else if ((value % 2) != 0)
+ * errmsg = _(not_aligned);
+
+ return insn | ((value & 0xfffe) << 16);
+}
+
+static unsigned long
+extract_d16_15 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ signed long ret = (insn & 0xfffe0000);
+
+ return ret >> 16;
+}
+
+static unsigned long
+insert_d8_7 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char ** errmsg;
+{
+ if (value > 0xff || value < 0)
+ {
+ if ((value % 2) != 0)
+ * errmsg = _(not_valid);
+ else
+ * errmsg = _(out_of_range);
+ }
+ else if ((value % 2) != 0)
+ * errmsg = _(not_aligned);
+
+ value >>= 1;
+
+ return (insn | (value & 0x7f));
+}
+
+static unsigned long
+extract_d8_7 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ unsigned long ret = (insn & 0x7f);
+
+ return ret << 1;
+}
+
+static unsigned long
+insert_d8_6 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char ** errmsg;
+{
+ if (value > 0xff || value < 0)
+ {
+ if ((value % 4) != 0)
+ *errmsg = _(not_valid);
+ else
+ * errmsg = _(out_of_range);
+ }
+ else if ((value % 4) != 0)
+ * errmsg = _(not_aligned);
+
+ value >>= 1;
+
+ return (insn | (value & 0x7e));
+}
+
+static unsigned long
+extract_d8_6 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ unsigned long ret = (insn & 0x7e);
+
+ return ret << 1;
+}
+
+static unsigned long
+insert_d5_4 (insn, value, errmsg)
+ unsigned long insn;
+ long value;
+ const char ** errmsg;
+{
+ if (value > 0x1f || value < 0)
+ {
+ if (value & 1)
+ * errmsg = _(not_valid);
+ else
+ *errmsg = _(out_of_range);
+ }
+ else if (value & 1)
+ * errmsg = _(not_aligned);
+
+ value >>= 1;
+
+ return (insn | (value & 0x0f));
+}
+
+static unsigned long
+extract_d5_4 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ unsigned long ret = (insn & 0x0f);
+
+ return ret << 1;
+}
+
+static unsigned long
+insert_d16_16 (insn, value, errmsg)
+ unsigned long insn;
+ signed long value;
+ const char ** errmsg;
+{
+ if (value > 0x7fff || value < -0x8000)
+ * errmsg = _(out_of_range);
+
+ return (insn | ((value & 0xfffe) << 16) | ((value & 1) << 5));
+}
+
+static unsigned long
+extract_d16_16 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ signed long ret = insn & 0xfffe0000;
+
+ ret >>= 16;
+
+ ret |= ((insn & 0x20) >> 5);
+
+ return ret;
+}
+
+static unsigned long
+insert_i9 (insn, value, errmsg)
+ unsigned long insn;
+ signed long value;
+ const char ** errmsg;
+{
+ if (value > 0xff || value < -0x100)
+ * errmsg = _(immediate_out_of_range);
+
+ return insn | ((value & 0x1e0) << 13) | (value & 0x1f);
+}
+
+static unsigned long
+extract_i9 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ signed long ret = insn & 0x003c0000;
+
+ ret <<= 10;
+ ret >>= 23;
+
+ ret |= (insn & 0x1f);
+
+ return ret;
+}
+
+static unsigned long
+insert_u9 (insn, value, errmsg)
+ unsigned long insn;
+ unsigned long value;
+ const char ** errmsg;
+{
+ if (value > 0x1ff)
+ * errmsg = _(immediate_out_of_range);
+
+ return insn | ((value & 0x1e0) << 13) | (value & 0x1f);
+}
+
+static unsigned long
+extract_u9 (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ unsigned long ret = insn & 0x003c0000;
+
+ ret >>= 13;
+
+ ret |= (insn & 0x1f);
+
+ return ret;
+}
+
+static unsigned long
+insert_spe (insn, value, errmsg)
+ unsigned long insn;
+ unsigned long value;
+ const char ** errmsg;
+{
+ if (value != 3)
+ * errmsg = _("invalid register for stack adjustment");
+
+ return insn & (~ 0x180000);
+}
+
+static unsigned long
+extract_spe (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ return 3;
+}
+
+static unsigned long
+insert_i5div (insn, value, errmsg)
+ unsigned long insn;
+ unsigned long value;
+ const char ** errmsg;
+{
+ if (value > 0x1ff)
+ {
+ if (value & 1)
+ * errmsg = _("immediate value not in range and not even");
+ else
+ * errmsg = _(immediate_out_of_range);
+ }
+ else if (value & 1)
+ * errmsg = _("immediate value must be even");
+
+ value = 32 - value;
+
+ return insn | ((value & 0x1e) << 17);
+}
+
+static unsigned long
+extract_i5div (insn, invalid)
+ unsigned long insn;
+ int * invalid;
+{
+ unsigned long ret = insn & 0x3c0000;
+
+ ret >>= 17;
+
+ ret = 32 - ret;
+
+ return ret;
+}
+
+
+/* Warning: code in gas/config/tc-v850.c examines the contents of this array.
+ If you change any of the values here, be sure to look for side effects in
+ that code. */
+const struct v850_operand v850_operands[] =
+{
+#define UNUSED 0
+ { 0, 0, NULL, NULL, 0 },
+
+/* The R1 field in a format 1, 6, 7, or 9 insn. */
+#define R1 (UNUSED + 1)
+ { 5, 0, NULL, NULL, V850_OPERAND_REG },
+
+/* As above, but register 0 is not allowed. */
+#define R1_NOTR0 (R1 + 1)
+ { 5, 0, NULL, NULL, V850_OPERAND_REG | V850_NOT_R0 },
+
+/* The R2 field in a format 1, 2, 4, 5, 6, 7, 9 insn. */
+#define R2 (R1_NOTR0 + 1)
+ { 5, 11, NULL, NULL, V850_OPERAND_REG },
+
+/* As above, but register 0 is not allowed. */
+#define R2_NOTR0 (R2 + 1)
+ { 5, 11, NULL, NULL, V850_OPERAND_REG | V850_NOT_R0 },
+
+/* The imm5 field in a format 2 insn. */
+#define I5 (R2_NOTR0 + 1)
+ { 5, 0, NULL, NULL, V850_OPERAND_SIGNED },
+
+/* The unsigned imm5 field in a format 2 insn. */
+#define I5U (I5 + 1)
+ { 5, 0, NULL, NULL, 0 },
+
+/* The imm16 field in a format 6 insn. */
+#define I16 (I5U + 1)
+ { 16, 16, NULL, NULL, V850_OPERAND_SIGNED },
+
+/* The signed disp7 field in a format 4 insn. */
+#define D7 (I16 + 1)
+ { 7, 0, NULL, NULL, 0},
+
+/* The disp16 field in a format 6 insn. */
+#define D16_15 (D7 + 1)
+ { 15, 17, insert_d16_15, extract_d16_15, V850_OPERAND_SIGNED },
+
+/* The 3 bit immediate field in format 8 insn. */
+#define B3 (D16_15 + 1)
+ { 3, 11, NULL, NULL, 0 },
+
+/* The 4 bit condition code in a setf instruction */
+#define CCCC (B3 + 1)
+ { 4, 0, NULL, NULL, V850_OPERAND_CC },
+
+/* The unsigned DISP8 field in a format 4 insn. */
+#define D8_7 (CCCC + 1)
+ { 7, 0, insert_d8_7, extract_d8_7, 0 },
+
+/* The unsigned DISP8 field in a format 4 insn. */
+#define D8_6 (D8_7 + 1)
+ { 6, 1, insert_d8_6, extract_d8_6, 0 },
+
+/* System register operands. */
+#define SR1 (D8_6 + 1)
+ { 5, 0, NULL, NULL, V850_OPERAND_SRG },
+
+/* EP Register. */
+#define EP (SR1 + 1)
+ { 0, 0, NULL, NULL, V850_OPERAND_EP },
+
+/* The imm16 field (unsigned) in a format 6 insn. */
+#define I16U (EP + 1)
+ { 16, 16, NULL, NULL, 0},
+
+/* The R2 field as a system register. */
+#define SR2 (I16U + 1)
+ { 5, 11, NULL, NULL, V850_OPERAND_SRG },
+
+/* The disp16 field in a format 8 insn. */
+#define D16 (SR2 + 1)
+ { 16, 16, NULL, NULL, V850_OPERAND_SIGNED },
+
+/* The DISP9 field in a format 3 insn, relaxable. */
+#define D9_RELAX (D16 + 1)
+ { 9, 0, insert_d9, extract_d9, V850_OPERAND_RELAX | V850_OPERAND_SIGNED | V850_OPERAND_DISP },
+
+/* The DISP22 field in a format 4 insn, relaxable.
+ This _must_ follow D9_RELAX; the assembler assumes that the longer
+ version immediately follows the shorter version for relaxing. */
+#define D22 (D9_RELAX + 1)
+ { 22, 0, insert_d22, extract_d22, V850_OPERAND_SIGNED | V850_OPERAND_DISP },
+
+/* The signed disp4 field in a format 4 insn. */
+#define D4 (D22 + 1)
+ { 4, 0, NULL, NULL, 0},
+
+/* The unsigned disp5 field in a format 4 insn. */
+#define D5_4 (D4 + 1)
+ { 4, 0, insert_d5_4, extract_d5_4, 0 },
+
+/* The disp16 field in an format 7 unsigned byte load insn. */
+#define D16_16 (D5_4 + 1)
+ { -1, 0xfffe0020, insert_d16_16, extract_d16_16, 0 },
+
+/* Third register in conditional moves. */
+#define R3 (D16_16 + 1)
+ { 5, 27, NULL, NULL, V850_OPERAND_REG },
+
+/* Condition code in conditional moves. */
+#define MOVCC (R3 + 1)
+ { 4, 17, NULL, NULL, V850_OPERAND_CC },
+
+/* The imm9 field in a multiply word. */
+#define I9 (MOVCC + 1)
+ { 9, 0, insert_i9, extract_i9, V850_OPERAND_SIGNED },
+
+/* The unsigned imm9 field in a multiply word. */
+#define U9 (I9 + 1)
+ { 9, 0, insert_u9, extract_u9, 0 },
+
+/* A list of registers in a prepare/dispose instruction. */
+#define LIST12 (U9 + 1)
+ { -1, 0xffe00001, NULL, NULL, V850E_PUSH_POP },
+
+/* The IMM6 field in a call instruction. */
+#define I6 (LIST12 + 1)
+ { 6, 0, NULL, NULL, 0 },
+
+/* The 16 bit immediate following a 32 bit instruction. */
+#define IMM16 (I6 + 1)
+ { 16, 16, NULL, NULL, V850_OPERAND_SIGNED | V850E_IMMEDIATE16 },
+
+/* The 32 bit immediate following a 32 bit instruction. */
+#define IMM32 (IMM16 + 1)
+ { 0, 0, NULL, NULL, V850E_IMMEDIATE32 },
+
+/* The imm5 field in a push/pop instruction. */
+#define IMM5 (IMM32 + 1)
+ { 5, 1, NULL, NULL, 0 },
+
+/* Reg2 in dispose instruction. */
+#define R2DISPOSE (IMM5 + 1)
+ { 5, 16, NULL, NULL, V850_OPERAND_REG | V850_NOT_R0 },
+
+/* Stack pointer in prepare instruction. */
+#define SP (R2DISPOSE + 1)
+ { 2, 19, insert_spe, extract_spe, V850_OPERAND_REG },
+
+/* The IMM5 field in a divide N step instruction. */
+#define I5DIV (SP + 1)
+ { 9, 0, insert_i5div, extract_i5div, V850_OPERAND_SIGNED },
+
+ /* The list of registers in a PUSHMH/POPMH instruction. */
+#define LIST18_H (I5DIV + 1)
+ { -1, 0xfff8000f, NULL, NULL, V850E_PUSH_POP },
+
+ /* The list of registers in a PUSHML/POPML instruction. */
+#define LIST18_L (LIST18_H + 1)
+ { -1, 0xfff8001f, NULL, NULL, V850E_PUSH_POP }, /* The setting of the 4th bit is a flag to disassmble() in v850-dis.c */
+} ;
+
+
+/* reg-reg instruction format (Format I) */
+#define IF1 {R1, R2}
+
+/* imm-reg instruction format (Format II) */
+#define IF2 {I5, R2}
+
+/* conditional branch instruction format (Format III) */
+#define IF3 {D9_RELAX}
+
+/* 3 operand instruction (Format VI) */
+#define IF6 {I16, R1, R2}
+
+/* 3 operand instruction (Format VI) */
+#define IF6U {I16U, R1, R2}
+
+
+
+/* The opcode table.
+
+ The format of the opcode table is:
+
+ NAME OPCODE MASK { OPERANDS } MEMOP PROCESSOR
+
+ NAME is the name of the instruction.
+ OPCODE is the instruction opcode.
+ MASK is the opcode mask; this is used to tell the disassembler
+ which bits in the actual opcode must match OPCODE.
+ OPERANDS is the list of operands.
+ MEMOP specifies which operand (if any) is a memory operand.
+ PROCESSORS specifies which CPU(s) support the opcode.
+
+ The disassembler reads the table in order and prints the first
+ instruction which matches, so this table is sorted to put more
+ specific instructions before more general instructions. It is also
+ sorted by major opcode.
+
+ The table is also sorted by name. This is used by the assembler.
+ When parsing an instruction the assembler finds the first occurance
+ of the name of the instruciton in this table and then attempts to
+ match the instruction's arguments with description of the operands
+ associated with the entry it has just found in this table. If the
+ match fails the assembler looks at the next entry in this table.
+ If that entry has the same name as the previous entry, then it
+ tries to match the instruction against that entry and so on. This
+ is how the assembler copes with multiple, different formats of the
+ same instruction. */
+
+const struct v850_opcode v850_opcodes[] =
+{
+{ "breakpoint", 0xffff, 0xffff, {UNUSED}, 0, PROCESSOR_ALL },
+
+{ "jmp", one (0x0060), one (0xffe0), {R1}, 1, PROCESSOR_ALL },
+
+/* load/store instructions */
+{ "sld.bu", one (0x0300), one (0x0780), {D7, EP, R2_NOTR0}, 1, PROCESSOR_V850EA },
+{ "sld.bu", one (0x0060), one (0x07f0), {D4, EP, R2_NOTR0}, 1, PROCESSOR_V850E },
+
+{ "sld.hu", one (0x0400), one (0x0780), {D8_7, EP, R2_NOTR0}, 1, PROCESSOR_V850EA },
+{ "sld.hu", one (0x0070), one (0x07f0), {D5_4, EP, R2_NOTR0}, 1, PROCESSOR_V850E },
+
+{ "sld.b", one (0x0060), one (0x07f0), {D4, EP, R2}, 1, PROCESSOR_V850EA },
+{ "sld.b", one (0x0300), one (0x0780), {D7, EP, R2}, 1, PROCESSOR_V850E },
+{ "sld.b", one (0x0300), one (0x0780), {D7, EP, R2}, 1, PROCESSOR_V850 },
+
+{ "sld.h", one (0x0070), one (0x07f0), {D5_4, EP, R2}, 1, PROCESSOR_V850EA },
+{ "sld.h", one (0x0400), one (0x0780), {D8_7, EP, R2}, 1, PROCESSOR_V850E },
+{ "sld.h", one (0x0400), one (0x0780), {D8_7, EP, R2}, 1, PROCESSOR_V850 },
+{ "sld.w", one (0x0500), one (0x0781), {D8_6, EP, R2}, 1, PROCESSOR_ALL },
+{ "sst.b", one (0x0380), one (0x0780), {R2, D7, EP}, 2, PROCESSOR_ALL },
+{ "sst.h", one (0x0480), one (0x0780), {R2, D8_7, EP}, 2, PROCESSOR_ALL },
+{ "sst.w", one (0x0501), one (0x0781), {R2, D8_6, EP}, 2, PROCESSOR_ALL },
+
+{ "pushml", two (0x07e0, 0x0001), two (0xfff0, 0x0007), {LIST18_L}, 0, PROCESSOR_V850EA },
+{ "pushmh", two (0x07e0, 0x0003), two (0xfff0, 0x0007), {LIST18_H}, 0, PROCESSOR_V850EA },
+{ "popml", two (0x07f0, 0x0001), two (0xfff0, 0x0007), {LIST18_L}, 0, PROCESSOR_V850EA },
+{ "popmh", two (0x07f0, 0x0003), two (0xfff0, 0x0007), {LIST18_H}, 0, PROCESSOR_V850EA },
+{ "prepare", two (0x0780, 0x0003), two (0xffc0, 0x001f), {LIST12, IMM5, SP}, 0, PROCESSOR_NOT_V850 },
+{ "prepare", two (0x0780, 0x000b), two (0xffc0, 0x001f), {LIST12, IMM5, IMM16}, 0, PROCESSOR_NOT_V850 },
+{ "prepare", two (0x0780, 0x0013), two (0xffc0, 0x001f), {LIST12, IMM5, IMM16}, 0, PROCESSOR_NOT_V850 },
+{ "prepare", two (0x0780, 0x001b), two (0xffc0, 0x001f), {LIST12, IMM5, IMM32}, 0, PROCESSOR_NOT_V850 },
+{ "prepare", two (0x0780, 0x0001), two (0xffc0, 0x001f), {LIST12, IMM5}, 0, PROCESSOR_NOT_V850 },
+{ "dispose", one (0x0640), one (0xffc0), {IMM5, LIST12, R2DISPOSE},0, PROCESSOR_NOT_V850 },
+{ "dispose", two (0x0640, 0x0000), two (0xffc0, 0x001f), {IMM5, LIST12}, 0, PROCESSOR_NOT_V850 },
+
+{ "ld.b", two (0x0700, 0x0000), two (0x07e0, 0x0000), {D16, R1, R2}, 1, PROCESSOR_ALL },
+{ "ld.h", two (0x0720, 0x0000), two (0x07e0, 0x0001), {D16_15, R1, R2}, 1, PROCESSOR_ALL },
+{ "ld.w", two (0x0720, 0x0001), two (0x07e0, 0x0001), {D16_15, R1, R2}, 1, PROCESSOR_ALL },
+{ "ld.bu", two (0x0780, 0x0001), two (0x07c0, 0x0001), {D16_16, R1, R2_NOTR0}, 1, PROCESSOR_NOT_V850 },
+{ "ld.hu", two (0x07e0, 0x0001), two (0x07e0, 0x0001), {D16_15, R1, R2_NOTR0}, 1, PROCESSOR_NOT_V850 },
+{ "st.b", two (0x0740, 0x0000), two (0x07e0, 0x0000), {R2, D16, R1}, 2, PROCESSOR_ALL },
+{ "st.h", two (0x0760, 0x0000), two (0x07e0, 0x0001), {R2, D16_15, R1}, 2, PROCESSOR_ALL },
+{ "st.w", two (0x0760, 0x0001), two (0x07e0, 0x0001), {R2, D16_15, R1}, 2, PROCESSOR_ALL },
+
+/* byte swap/extend instructions */
+{ "zxb", one (0x0080), one (0xffe0), {R1_NOTR0}, 0, PROCESSOR_NOT_V850 },
+{ "zxh", one (0x00c0), one (0xffe0), {R1_NOTR0}, 0, PROCESSOR_NOT_V850 },
+{ "sxb", one (0x00a0), one (0xffe0), {R1_NOTR0}, 0, PROCESSOR_NOT_V850 },
+{ "sxh", one (0x00e0), one (0xffe0), {R1_NOTR0}, 0, PROCESSOR_NOT_V850 },
+{ "bsh", two (0x07e0, 0x0342), two (0x07ff, 0x07ff), {R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "bsw", two (0x07e0, 0x0340), two (0x07ff, 0x07ff), {R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "hsw", two (0x07e0, 0x0344), two (0x07ff, 0x07ff), {R2, R3}, 0, PROCESSOR_NOT_V850 },
+
+/* jump table instructions */
+{ "switch", one (0x0040), one (0xffe0), {R1}, 1, PROCESSOR_NOT_V850 },
+{ "callt", one (0x0200), one (0xffc0), {I6}, 0, PROCESSOR_NOT_V850 },
+{ "ctret", two (0x07e0, 0x0144), two (0xffff, 0xffff), {0}, 0, PROCESSOR_NOT_V850 },
+
+/* arithmetic operation instructions */
+{ "setf", two (0x07e0, 0x0000), two (0x07f0, 0xffff), {CCCC, R2}, 0, PROCESSOR_ALL },
+{ "cmov", two (0x07e0, 0x0320), two (0x07e0, 0x07e1), {MOVCC, R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "cmov", two (0x07e0, 0x0300), two (0x07e0, 0x07e1), {MOVCC, I5, R2, R3}, 0, PROCESSOR_NOT_V850 },
+
+{ "mul", two (0x07e0, 0x0220), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "mul", two (0x07e0, 0x0240), two (0x07e0, 0x07c3), {I9, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "mulu", two (0x07e0, 0x0222), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "mulu", two (0x07e0, 0x0242), two (0x07e0, 0x07c3), {U9, R2, R3}, 0, PROCESSOR_NOT_V850 },
+
+{ "div", two (0x07e0, 0x02c0), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "divu", two (0x07e0, 0x02c2), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "divhu", two (0x07e0, 0x0282), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "divh", two (0x07e0, 0x0280), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, PROCESSOR_NOT_V850 },
+{ "divh", OP (0x02), OP_MASK, {R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+
+{ "divhn", two (0x07e0, 0x0280), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "divhun", two (0x07e0, 0x0282), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "divn", two (0x07e0, 0x02c0), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "divun", two (0x07e0, 0x02c2), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "sdivhn", two (0x07e0, 0x0180), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "sdivhun", two (0x07e0, 0x0182), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "sdivn", two (0x07e0, 0x01c0), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+{ "sdivun", two (0x07e0, 0x01c2), two (0x07e0, 0x07c3), {I5DIV, R1, R2, R3}, 0, PROCESSOR_V850EA },
+
+{ "nop", one (0x00), one (0xffff), {0}, 0, PROCESSOR_ALL },
+{ "mov", OP (0x10), OP_MASK, {I5, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "mov", one (0x0620), one (0xffe0), {IMM32, R1_NOTR0}, 0, PROCESSOR_NOT_V850 },
+{ "mov", OP (0x00), OP_MASK, {R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "movea", OP (0x31), OP_MASK, {I16, R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "movhi", OP (0x32), OP_MASK, {I16U, R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "add", OP (0x0e), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "add", OP (0x12), OP_MASK, IF2, 0, PROCESSOR_ALL },
+{ "addi", OP (0x30), OP_MASK, IF6, 0, PROCESSOR_ALL },
+{ "sub", OP (0x0d), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "subr", OP (0x0c), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "mulh", OP (0x17), OP_MASK, {I5, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "mulh", OP (0x07), OP_MASK, {R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "mulhi", OP (0x37), OP_MASK, {I16, R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "cmp", OP (0x0f), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "cmp", OP (0x13), OP_MASK, IF2, 0, PROCESSOR_ALL },
+
+/* saturated operation instructions */
+{ "satadd", OP (0x11), OP_MASK, {I5, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "satadd", OP (0x06), OP_MASK, {R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "satsub", OP (0x05), OP_MASK, {R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "satsubi", OP (0x33), OP_MASK, {I16, R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+{ "satsubr", OP (0x04), OP_MASK, {R1, R2_NOTR0}, 0, PROCESSOR_ALL },
+
+/* logical operation instructions */
+{ "tst", OP (0x0b), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "or", OP (0x08), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "ori", OP (0x34), OP_MASK, IF6U, 0, PROCESSOR_ALL },
+{ "and", OP (0x0a), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "andi", OP (0x36), OP_MASK, IF6U, 0, PROCESSOR_ALL },
+{ "xor", OP (0x09), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "xori", OP (0x35), OP_MASK, IF6U, 0, PROCESSOR_ALL },
+{ "not", OP (0x01), OP_MASK, IF1, 0, PROCESSOR_ALL },
+{ "sar", OP (0x15), OP_MASK, {I5U, R2}, 0, PROCESSOR_ALL },
+{ "sar", two (0x07e0, 0x00a0), two (0x07e0, 0xffff), {R1, R2}, 0, PROCESSOR_ALL },
+{ "shl", OP (0x16), OP_MASK, {I5U, R2}, 0, PROCESSOR_ALL },
+{ "shl", two (0x07e0, 0x00c0), two (0x07e0, 0xffff), {R1, R2}, 0, PROCESSOR_ALL },
+{ "shr", OP (0x14), OP_MASK, {I5U, R2}, 0, PROCESSOR_ALL },
+{ "shr", two (0x07e0, 0x0080), two (0x07e0, 0xffff), {R1, R2}, 0, PROCESSOR_ALL },
+{ "sasf", two (0x07e0, 0x0200), two (0x07f0, 0xffff), {CCCC, R2}, 0, PROCESSOR_NOT_V850 },
+
+/* branch instructions */
+ /* signed integer */
+{ "bgt", BOP (0xf), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bge", BOP (0xe), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "blt", BOP (0x6), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "ble", BOP (0x7), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+ /* unsigned integer */
+{ "bh", BOP (0xb), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bnh", BOP (0x3), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bl", BOP (0x1), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bnl", BOP (0x9), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+ /* common */
+{ "be", BOP (0x2), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bne", BOP (0xa), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+ /* others */
+{ "bv", BOP (0x0), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bnv", BOP (0x8), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bn", BOP (0x4), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bp", BOP (0xc), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bc", BOP (0x1), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bnc", BOP (0x9), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bz", BOP (0x2), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bnz", BOP (0xa), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "br", BOP (0x5), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "bsa", BOP (0xd), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+
+/* Branch macros.
+
+ We use the short form in the opcode/mask fields. The assembler
+ will twiddle bits as necessary if the long form is needed. */
+
+ /* signed integer */
+{ "jgt", BOP (0xf), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jge", BOP (0xe), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jlt", BOP (0x6), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jle", BOP (0x7), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+ /* unsigned integer */
+{ "jh", BOP (0xb), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jnh", BOP (0x3), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jl", BOP (0x1), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jnl", BOP (0x9), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+ /* common */
+{ "je", BOP (0x2), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jne", BOP (0xa), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+ /* others */
+{ "jv", BOP (0x0), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jnv", BOP (0x8), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jn", BOP (0x4), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jp", BOP (0xc), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jc", BOP (0x1), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jnc", BOP (0x9), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jz", BOP (0x2), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jnz", BOP (0xa), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jsa", BOP (0xd), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+{ "jbr", BOP (0x5), BOP_MASK, IF3, 0, PROCESSOR_ALL },
+
+{ "jr", one (0x0780), two (0xffc0, 0x0001), {D22}, 0, PROCESSOR_ALL },
+{ "jarl", one (0x0780), two (0x07c0, 0x0001), {D22, R2}, 0, PROCESSOR_ALL},
+
+/* bit manipulation instructions */
+{ "set1", two (0x07c0, 0x0000), two (0xc7e0, 0x0000), {B3, D16, R1}, 2, PROCESSOR_ALL },
+{ "set1", two (0x07e0, 0x00e0), two (0x07e0, 0xffff), {R2, R1}, 2, PROCESSOR_NOT_V850 },
+{ "not1", two (0x47c0, 0x0000), two (0xc7e0, 0x0000), {B3, D16, R1}, 2, PROCESSOR_ALL },
+{ "not1", two (0x07e0, 0x00e2), two (0x07e0, 0xffff), {R2, R1}, 2, PROCESSOR_NOT_V850 },
+{ "clr1", two (0x87c0, 0x0000), two (0xc7e0, 0x0000), {B3, D16, R1}, 2, PROCESSOR_ALL },
+{ "clr1", two (0x07e0, 0x00e4), two (0x07e0, 0xffff), {R2, R1}, 2, PROCESSOR_NOT_V850 },
+{ "tst1", two (0xc7c0, 0x0000), two (0xc7e0, 0x0000), {B3, D16, R1}, 2, PROCESSOR_ALL },
+{ "tst1", two (0x07e0, 0x00e6), two (0x07e0, 0xffff), {R2, R1}, 2, PROCESSOR_NOT_V850 },
+
+/* special instructions */
+{ "di", two (0x07e0, 0x0160), two (0xffff, 0xffff), {0}, 0, PROCESSOR_ALL },
+{ "ei", two (0x87e0, 0x0160), two (0xffff, 0xffff), {0}, 0, PROCESSOR_ALL },
+{ "halt", two (0x07e0, 0x0120), two (0xffff, 0xffff), {0}, 0, PROCESSOR_ALL },
+{ "reti", two (0x07e0, 0x0140), two (0xffff, 0xffff), {0}, 0, PROCESSOR_ALL },
+{ "trap", two (0x07e0, 0x0100), two (0xffe0, 0xffff), {I5U}, 0, PROCESSOR_ALL },
+{ "ldsr", two (0x07e0, 0x0020), two (0x07e0, 0xffff), {R1, SR2}, 0, PROCESSOR_ALL },
+{ "stsr", two (0x07e0, 0x0040), two (0x07e0, 0xffff), {SR1, R2}, 0, PROCESSOR_ALL },
+{ 0, 0, 0, {0}, 0, 0 },
+
+} ;
+
+const int v850_num_opcodes =
+ sizeof (v850_opcodes) / sizeof (v850_opcodes[0]);
+
diff --git a/opcodes/vax-dis.c b/opcodes/vax-dis.c
new file mode 100644
index 00000000000..54b59f30d40
--- /dev/null
+++ b/opcodes/vax-dis.c
@@ -0,0 +1,299 @@
+/* Print VAX instructions.
+ Copyright (C) 1995, 1998 Free Software Foundation, Inc.
+ Contributed by Pauline Middelink <middelin@polyware.iaf.nl>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "opcode/vax.h"
+#include "dis-asm.h"
+
+/* Local function prototypes */
+static int
+print_insn_arg PARAMS ((const char *, unsigned char *, bfd_vma,
+ disassemble_info *));
+
+static int
+print_insn_mode PARAMS ((int, unsigned char *, bfd_vma, disassemble_info *));
+
+static char *reg_names[] =
+{
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc"
+};
+
+/* Sign-extend an (unsigned char). */
+#if __STDC__ == 1
+#define COERCE_SIGNED_CHAR(ch) ((signed char)(ch))
+#else
+#define COERCE_SIGNED_CHAR(ch) ((int)(((ch) ^ 0x80) & 0xFF) - 128)
+#endif
+
+/* Get a 1 byte signed integer. */
+#define NEXTBYTE(p) \
+ (p += 1, FETCH_DATA (info, p), \
+ COERCE_SIGNED_CHAR(p[-1]))
+
+/* Get a 2 byte signed integer. */
+#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
+#define NEXTWORD(p) \
+ (p += 2, FETCH_DATA (info, p), \
+ COERCE16 ((p[-1] << 8) + p[-2]))
+
+/* Get a 4 byte signed integer. */
+#define COERCE32(x) ((int) (((x) ^ 0x80000000) - 0x80000000))
+#define NEXTLONG(p) \
+ (p += 4, FETCH_DATA (info, p), \
+ (COERCE32 ((((((p[-1] << 8) + p[-2]) << 8) + p[-3]) << 8) + p[-4])))
+
+/* Maximum length of an instruction. */
+#define MAXLEN 25
+
+#include <setjmp.h>
+
+struct private
+{
+ /* Points to first byte not fetched. */
+ bfd_byte *max_fetched;
+ bfd_byte the_buffer[MAXLEN];
+ bfd_vma insn_start;
+ jmp_buf bailout;
+};
+
+/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
+ to ADDR (exclusive) are valid. Returns 1 for success, longjmps
+ on error. */
+#define FETCH_DATA(info, addr) \
+ ((addr) <= ((struct private *)(info->private_data))->max_fetched \
+ ? 1 : fetch_data ((info), (addr)))
+
+static int
+fetch_data (info, addr)
+ struct disassemble_info *info;
+ bfd_byte *addr;
+{
+ int status;
+ struct private *priv = (struct private *) info->private_data;
+ bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
+
+ status = (*info->read_memory_func) (start,
+ priv->max_fetched,
+ addr - priv->max_fetched,
+ info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, start, info);
+ longjmp (priv->bailout, 1);
+ }
+ else
+ priv->max_fetched = addr;
+
+ return 1;
+}
+
+/* Print the vax instruction at address MEMADDR in debugged memory,
+ on INFO->STREAM. Returns length of the instruction, in bytes. */
+
+int
+print_insn_vax (memaddr, info)
+ bfd_vma memaddr;
+ disassemble_info *info;
+{
+ const struct vot *votp;
+ const char *argp = NULL;
+ unsigned char *arg;
+ struct private priv;
+ bfd_byte *buffer = priv.the_buffer;
+
+ info->private_data = (PTR) &priv;
+ priv.max_fetched = priv.the_buffer;
+ priv.insn_start = memaddr;
+ if (setjmp (priv.bailout) != 0)
+ {
+ /* Error return. */
+ return -1;
+ }
+
+ FETCH_DATA (info, buffer + 2);
+ for (votp = &votstrs[0]; votp->name[0]; votp++)
+ {
+ register vax_opcodeT opcode = votp->detail.code;
+
+ /* 2 byte codes match 2 buffer pos. */
+ if ((bfd_byte) opcode == buffer[0]
+ && (opcode >> 8 == 0 || opcode >> 8 == buffer[1]))
+ {
+ argp = votp->detail.args;
+ break;
+ }
+ }
+ if (argp == NULL)
+ {
+ /* Handle undefined instructions. */
+ (*info->fprintf_func) (info->stream, ".word 0x%x",
+ (buffer[0] << 8) + buffer[1]);
+ return 2;
+ }
+
+ /* Point at first byte of argument data, and at descriptor for first
+ argument. */
+ arg = buffer + ((votp->detail.code >> 8) ? 2 : 1);
+
+ /* Make sure we have it in mem */
+ FETCH_DATA (info, arg);
+
+ (*info->fprintf_func) (info->stream, "%s", votp->name);
+ if (*argp)
+ (*info->fprintf_func) (info->stream, " ");
+
+ while (*argp)
+ {
+ arg += print_insn_arg (argp, arg, memaddr + arg - buffer, info);
+ argp += 2;
+ if (*argp)
+ (*info->fprintf_func) (info->stream, ",");
+ }
+
+ return arg - buffer;
+}
+
+/* Returns number of bytes "eaten" by the operand, or return -1 if an
+ invalid operand was found, or -2 if an opcode tabel error was
+ found. */
+
+static int
+print_insn_arg (d, p0, addr, info)
+ const char *d;
+ unsigned char *p0;
+ bfd_vma addr; /* PC for this arg to be relative to */
+ disassemble_info *info;
+{
+ int arg_len;
+
+ /* check validity of addressing length */
+ switch (d[1])
+ {
+ case 'b' : arg_len = 1; break;
+ case 'd' : arg_len = 8; break;
+ case 'f' : arg_len = 4; break;
+ case 'g' : arg_len = 8; break;
+ case 'h' : arg_len = 16; break;
+ case 'l' : arg_len = 4; break;
+ case 'o' : arg_len = 16; break;
+ case 'w' : arg_len = 2; break;
+ case 'q' : arg_len = 8; break;
+ default : abort();
+ }
+
+ /* branches have no mode byte */
+ if (d[0] == 'b')
+ {
+ unsigned char *p = p0;
+
+ if (arg_len == 1)
+ (*info->print_address_func) (addr + 1 + NEXTBYTE (p), info);
+ else
+ (*info->print_address_func) (addr + 2 + NEXTWORD (p), info);
+
+ return p - p0;
+ }
+
+ return print_insn_mode (arg_len, p0, addr, info);
+}
+
+static int
+print_insn_mode (size, p0, addr, info)
+ int size;
+ unsigned char *p0;
+ bfd_vma addr; /* PC for this arg to be relative to */
+ disassemble_info *info;
+{
+ unsigned char *p = p0;
+ unsigned char mode, reg;
+
+ /* fetch and interpret mode byte */
+ mode = (unsigned char) NEXTBYTE (p);
+ reg = mode & 0xF;
+ switch (mode & 0xF0)
+ {
+ case 0x00:
+ case 0x10:
+ case 0x20:
+ case 0x30: /* literal mode $number */
+ (*info->fprintf_func) (info->stream, "$0x%x", mode);
+ break;
+ case 0x40: /* index: base-addr[Rn] */
+ p += print_insn_mode (size, p0 + 1, addr + 1, info);
+ (*info->fprintf_func) (info->stream, "[%s]", reg_names[reg]);
+ break;
+ case 0x50: /* register: Rn */
+ (*info->fprintf_func) (info->stream, "%s", reg_names[reg]);
+ break;
+ case 0x60: /* register deferred: (Rn) */
+ (*info->fprintf_func) (info->stream, "(%s)", reg_names[reg]);
+ break;
+ case 0x70: /* autodecrement: -(Rn) */
+ (*info->fprintf_func) (info->stream, "-(%s)", reg_names[reg]);
+ break;
+ case 0x80: /* autoincrement: (Rn)+ */
+ if (reg == 0xF)
+ { /* immediate? */
+ int i;
+
+ FETCH_DATA (info, p + size);
+ (*info->fprintf_func) (info->stream, "$0x");
+ for (i = 0; i < size; i++)
+ (*info->fprintf_func) (info->stream, "%02x", p[size - i - 1]);
+ p += size;
+ }
+ else
+ (*info->fprintf_func) (info->stream, "(%s)+", reg_names[reg]);
+ break;
+ case 0x90: /* autoincrement deferred: @(Rn)+ */
+ if (reg == 0xF)
+ (*info->fprintf_func) (info->stream, "*0x%x", NEXTLONG (p));
+ else
+ (*info->fprintf_func) (info->stream, "@(%s)+", reg_names[reg]);
+ break;
+ case 0xB0: /* displacement byte deferred: *displ(Rn) */
+ (*info->fprintf_func) (info->stream, "*");
+ case 0xA0: /* displacement byte: displ(Rn) */
+ if (reg == 0xF)
+ (*info->print_address_func) (addr + 2 + NEXTBYTE (p), info);
+ else
+ (*info->fprintf_func) (info->stream, "0x%x(%s)", NEXTBYTE (p),
+ reg_names[reg]);
+ break;
+ case 0xD0: /* displacement word deferred: *displ(Rn) */
+ (*info->fprintf_func) (info->stream, "*");
+ case 0xC0: /* displacement word: displ(Rn) */
+ if (reg == 0xF)
+ (*info->print_address_func) (addr + 3 + NEXTWORD (p), info);
+ else
+ (*info->fprintf_func) (info->stream, "0x%x(%s)", NEXTWORD (p),
+ reg_names[reg]);
+ break;
+ case 0xF0: /* displacement long deferred: *displ(Rn) */
+ (*info->fprintf_func) (info->stream, "*");
+ case 0xE0: /* displacement long: displ(Rn) */
+ if (reg == 0xF)
+ (*info->print_address_func) (addr + 5 + NEXTLONG (p), info);
+ else
+ (*info->fprintf_func) (info->stream, "0x%x(%s)", NEXTLONG (p),
+ reg_names[reg]);
+ break;
+ }
+
+ return p - p0;
+}
diff --git a/opcodes/w65-dis.c b/opcodes/w65-dis.c
new file mode 100644
index 00000000000..a12e896de67
--- /dev/null
+++ b/opcodes/w65-dis.c
@@ -0,0 +1,118 @@
+/* Disassemble WDC 65816 instructions.
+ Copyright (C) 1995, 1998 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#define STATIC_TABLE
+#define DEFINE_TABLE
+
+#include "w65-opc.h"
+#include "dis-asm.h"
+
+static fprintf_ftype fpr;
+static void *stream;
+static struct disassemble_info *local_info;
+#if 0
+static char *lname[] = {"r0","r1","r2","r3","r4","r5","r6","r7","s0"};
+
+static char *findname (val)
+ unsigned int val;
+{
+ if (val >= 0x10 && val <= 0x20)
+ return lname[(val - 0x10) / 2];
+ return 0;
+}
+#endif
+static void
+print_operand (lookup, format, args)
+ int lookup;
+ char *format;
+ unsigned int *args;
+{
+ int val;
+ int c;
+
+ while (*format)
+ {
+ switch ( c = *format++)
+ {
+ case '$':
+ val = args[(*format++) - '0'];
+ if (lookup)
+ {
+#if 0
+ name = findname(val);
+ if (name)
+ fpr(stream, "%s", name);
+ else
+#endif
+ local_info->print_address_func (val, local_info);
+ }
+ else
+ fpr (stream, "0x%x", val);
+
+ break;
+ default:
+ fpr(stream,"%c", c);
+ break;
+ }
+ }
+}
+int
+print_insn_w65(memaddr, info)
+ bfd_vma memaddr;
+ struct disassemble_info *info;
+{
+
+
+ int status = 0;
+ unsigned char insn[4];
+ register struct opinfo *op;
+ int i;
+ int X =0;
+ int M = 0;
+ int args[2];
+stream = info->stream;
+ fpr = info->fprintf_func;
+local_info = info;
+ for (i = 0; i <4 && status == 0; i++)
+ {
+ status = info->read_memory_func(memaddr+i, insn + i, 1, info);
+ }
+
+
+ for (op = optable; op->val != insn[0]; op++)
+ ;
+
+ fpr(stream,"%s", op->name);
+
+ /* Prepare all the posible operand values */
+ {
+ int size = 1;
+ int asR_W65_ABS8 = insn[1];
+ int asR_W65_ABS16 = (insn[2] << 8) + asR_W65_ABS8;
+ int asR_W65_ABS24 = (insn[3] << 16) + asR_W65_ABS16;
+ int asR_W65_PCR8 = ((char)(asR_W65_ABS8)) + memaddr + 2;
+ int asR_W65_PCR16 = ((short)(asR_W65_ABS16)) + memaddr + 3;
+
+ switch (op->amode) {
+ DISASM();
+ }
+
+ return size;
+ }
+
+}
diff --git a/opcodes/w65-opc.h b/opcodes/w65-opc.h
new file mode 100644
index 00000000000..9dc3535c787
--- /dev/null
+++ b/opcodes/w65-opc.h
@@ -0,0 +1,548 @@
+ /* WDC 65816 Assembler opcode table */
+ /* (generated by the program sim/w65/gencode -a) */
+#define ADDR_IMMTOA 1 /* #a */
+#define ADDR_IMMCOP 2 /* #c */
+#define ADDR_IMMTOI 3 /* #i */
+#define ADDR_ACC 4 /* A */
+#define ADDR_PC_REL 5 /* r */
+#define ADDR_PC_REL_LONG 6 /* rl */
+#define ADDR_IMPLIED 7 /* i */
+#define ADDR_STACK 8 /* s */
+#define ADDR_DIR 9 /* d */
+#define ADDR_DIR_IDX_X 10 /* d,x */
+#define ADDR_DIR_IDX_Y 11 /* d,y */
+#define ADDR_DIR_IND 12 /* (d) */
+#define ADDR_DIR_IDX_IND_X 13 /* (d,x) */
+#define ADDR_DIR_IND_IDX_Y 14 /* (d),y */
+#define ADDR_DIR_IND_LONG 15 /* [d] */
+#define ADDR_DIR_IND_IDX_Y_LONG 16 /* [d],y */
+#define ADDR_ABS 17 /* a */
+#define ADDR_ABS_IDX_X 18 /* a,x */
+#define ADDR_ABS_IDX_Y 19 /* a,y */
+#define ADDR_ABS_LONG 20 /* al */
+#define ADDR_ABS_IND_LONG 21 /* [a] */
+#define ADDR_ABS_LONG_IDX_X 22 /* al,x */
+#define ADDR_STACK_REL 23 /* d,s */
+#define ADDR_STACK_REL_INDX_IDX 24 /* (d,s),y */
+#define ADDR_ABS_IND 25 /* (a) */
+#define ADDR_ABS_IND_IDX 26 /* (a,x) */
+#define ADDR_BLOCK_MOVE 27 /* xyz */
+struct opinfo {
+ int val;
+ int code;
+ char *name;
+ int amode;
+};
+struct opinfo optable[257]={
+#define O_adc 1
+#define O_and 2
+#define O_asl 3
+#define O_bcc 4
+#define O_bcs 5
+#define O_beq 6
+#define O_bit 7
+#define O_bmi 8
+#define O_bne 9
+#define O_bpl 10
+#define O_bra 11
+#define O_brk 12
+#define O_brl 13
+#define O_bvc 14
+#define O_bvs 15
+#define O_clc 16
+#define O_cld 17
+#define O_cli 18
+#define O_clv 19
+#define O_cmp 20
+#define O_cop 21
+#define O_cpx 22
+#define O_cpy 23
+#define O_dec 24
+#define O_dex 25
+#define O_dey 26
+#define O_eor 27
+#define O_inc 28
+#define O_inx 29
+#define O_iny 30
+#define O_jmp 31
+#define O_jsr 32
+#define O_lda 33
+#define O_ldx 34
+#define O_ldy 35
+#define O_lsr 36
+#define O_mvn 37
+#define O_mvp 38
+#define O_nop 39
+#define O_ora 40
+#define O_pea 41
+#define O_pei 42
+#define O_per 43
+#define O_pha 44
+#define O_phb 45
+#define O_phd 46
+#define O_phk 47
+#define O_php 48
+#define O_phx 49
+#define O_phy 50
+#define O_pla 51
+#define O_plb 52
+#define O_pld 53
+#define O_plp 54
+#define O_plx 55
+#define O_ply 56
+#define O_rep 57
+#define O_rol 58
+#define O_ror 59
+#define O_rti 60
+#define O_rtl 61
+#define O_rts 62
+#define O_sbc 63
+#define O_sec 64
+#define O_sed 65
+#define O_sei 66
+#define O_sep 67
+#define O_sta 68
+#define O_stp 69
+#define O_stx 70
+#define O_sty 71
+#define O_stz 72
+#define O_tax 73
+#define O_tay 74
+#define O_tcd 75
+#define O_tcs 76
+#define O_tdc 77
+#define O_trb 78
+#define O_tsb 79
+#define O_tsc 80
+#define O_tsx 81
+#define O_txa 82
+#define O_txs 83
+#define O_txy 84
+#define O_tya 85
+#define O_tyx 86
+#define O_wai 87
+#define O_wdm 88
+#define O_xba 89
+#define O_xce 90
+#ifdef DEFINE_TABLE
+ {0x69, O_adc, "adc", ADDR_IMMTOA},
+ {0x72, O_adc, "adc", ADDR_DIR_IND},
+ {0x71, O_adc, "adc", ADDR_DIR_IND_IDX_Y},
+ {0x73, O_adc, "adc", ADDR_STACK_REL_INDX_IDX},
+ {0x61, O_adc, "adc", ADDR_DIR_IDX_IND_X},
+ {0x67, O_adc, "adc", ADDR_DIR_IND_LONG},
+ {0x77, O_adc, "adc", ADDR_DIR_IND_IDX_Y_LONG},
+ {0x6D, O_adc, "adc", ADDR_ABS},
+ {0x7D, O_adc, "adc", ADDR_ABS_IDX_X},
+ {0x79, O_adc, "adc", ADDR_ABS_IDX_Y},
+ {0x6F, O_adc, "adc", ADDR_ABS_LONG},
+ {0x7F, O_adc, "adc", ADDR_ABS_LONG_IDX_X},
+ {0x65, O_adc, "adc", ADDR_DIR},
+ {0x63, O_adc, "adc", ADDR_STACK_REL},
+ {0x75, O_adc, "adc", ADDR_DIR_IDX_X},
+ {0x29, O_and, "and", ADDR_IMMTOA},
+ {0x32, O_and, "and", ADDR_DIR_IND},
+ {0x31, O_and, "and", ADDR_DIR_IND_IDX_Y},
+ {0x33, O_and, "and", ADDR_STACK_REL_INDX_IDX},
+ {0x21, O_and, "and", ADDR_DIR_IDX_IND_X},
+ {0x27, O_and, "and", ADDR_DIR_IND_LONG},
+ {0x37, O_and, "and", ADDR_DIR_IND_IDX_Y_LONG},
+ {0x2D, O_and, "and", ADDR_ABS},
+ {0x3D, O_and, "and", ADDR_ABS_IDX_X},
+ {0x39, O_and, "and", ADDR_ABS_IDX_Y},
+ {0x2F, O_and, "and", ADDR_ABS_LONG},
+ {0x3F, O_and, "and", ADDR_ABS_LONG_IDX_X},
+ {0x25, O_and, "and", ADDR_DIR},
+ {0x23, O_and, "and", ADDR_STACK_REL},
+ {0x35, O_and, "and", ADDR_DIR_IDX_X},
+ {0x0A, O_asl, "asl", ADDR_ACC},
+ {0x0E, O_asl, "asl", ADDR_ABS},
+ {0x1E, O_asl, "asl", ADDR_ABS_IDX_X},
+ {0x06, O_asl, "asl", ADDR_DIR},
+ {0x16, O_asl, "asl", ADDR_DIR_IDX_X},
+ {0x90, O_bcc, "bcc", ADDR_PC_REL},
+ {0xB0, O_bcs, "bcs", ADDR_PC_REL},
+ {0xF0, O_beq, "beq", ADDR_PC_REL},
+ {0x89, O_bit, "bit", ADDR_IMMTOA},
+ {0x24, O_bit, "bit", ADDR_DIR_IND},
+ {0x34, O_bit, "bit", ADDR_DIR_IDX_IND_X},
+ {0x2C, O_bit, "bit", ADDR_ABS},
+ {0x3C, O_bit, "bit", ADDR_ABS_IDX_X},
+ {0x30, O_bmi, "bmi", ADDR_PC_REL},
+ {0xD0, O_bne, "bne", ADDR_PC_REL},
+ {0x10, O_bpl, "bpl", ADDR_PC_REL},
+ {0x80, O_bra, "bra", ADDR_PC_REL},
+ {0x00, O_brk, "brk", ADDR_STACK},
+ {0x82, O_brl, "brl", ADDR_PC_REL_LONG},
+ {0x50, O_bvc, "bvc", ADDR_PC_REL},
+ {0x70, O_bvs, "bvs", ADDR_PC_REL},
+ {0x18, O_clc, "clc", ADDR_IMPLIED},
+ {0xD8, O_cld, "cld", ADDR_IMPLIED},
+ {0x58, O_cli, "cli", ADDR_IMPLIED},
+ {0xB8, O_clv, "clv", ADDR_IMPLIED},
+ {0xC9, O_cmp, "cmp", ADDR_IMMTOA},
+ {0xD2, O_cmp, "cmp", ADDR_DIR_IND},
+ {0xD1, O_cmp, "cmp", ADDR_DIR_IND_IDX_Y},
+ {0xD3, O_cmp, "cmp", ADDR_STACK_REL_INDX_IDX},
+ {0xC1, O_cmp, "cmp", ADDR_DIR_IDX_IND_X},
+ {0xC7, O_cmp, "cmp", ADDR_DIR_IND_LONG},
+ {0xD7, O_cmp, "cmp", ADDR_DIR_IND_IDX_Y_LONG},
+ {0xCD, O_cmp, "cmp", ADDR_ABS},
+ {0xDD, O_cmp, "cmp", ADDR_ABS_IDX_X},
+ {0xD9, O_cmp, "cmp", ADDR_ABS_IDX_Y},
+ {0xCF, O_cmp, "cmp", ADDR_ABS_LONG},
+ {0xDF, O_cmp, "cmp", ADDR_ABS_LONG_IDX_X},
+ {0xC5, O_cmp, "cmp", ADDR_DIR},
+ {0xC3, O_cmp, "cmp", ADDR_STACK_REL},
+ {0xD5, O_cmp, "cmp", ADDR_DIR_IDX_X},
+ {0x02, O_cop, "cop", ADDR_IMMCOP},
+ {0xE0, O_cpx, "cpx", ADDR_IMMTOI},
+ {0xEC, O_cpx, "cpx", ADDR_ABS},
+ {0xE4, O_cpx, "cpx", ADDR_DIR},
+ {0xC0, O_cpy, "cpy", ADDR_IMMTOI},
+ {0xCC, O_cpy, "cpy", ADDR_ABS},
+ {0xC4, O_cpy, "cpy", ADDR_DIR},
+ {0x3A, O_dec, "dec", ADDR_ACC},
+ {0xCE, O_dec, "dec", ADDR_ABS},
+ {0xDE, O_dec, "dec", ADDR_ABS_IDX_X},
+ {0xC6, O_dec, "dec", ADDR_DIR},
+ {0xD6, O_dec, "dec", ADDR_DIR_IDX_X},
+ {0xCA, O_dex, "dex", ADDR_IMPLIED},
+ {0x88, O_dey, "dey", ADDR_IMPLIED},
+ {0x49, O_eor, "eor", ADDR_IMMTOA},
+ {0x52, O_eor, "eor", ADDR_DIR_IND},
+ {0x51, O_eor, "eor", ADDR_DIR_IND_IDX_Y},
+ {0x53, O_eor, "eor", ADDR_STACK_REL_INDX_IDX},
+ {0x41, O_eor, "eor", ADDR_DIR_IDX_IND_X},
+ {0x47, O_eor, "eor", ADDR_DIR_IND_LONG},
+ {0x57, O_eor, "eor", ADDR_DIR_IND_IDX_Y_LONG},
+ {0x4D, O_eor, "eor", ADDR_ABS},
+ {0x5D, O_eor, "eor", ADDR_ABS_IDX_X},
+ {0x59, O_eor, "eor", ADDR_ABS_IDX_Y},
+ {0x4F, O_eor, "eor", ADDR_ABS_LONG},
+ {0x5F, O_eor, "eor", ADDR_ABS_LONG_IDX_X},
+ {0x45, O_eor, "eor", ADDR_DIR},
+ {0x43, O_eor, "eor", ADDR_STACK_REL},
+ {0x55, O_eor, "eor", ADDR_DIR_IDX_X},
+ {0x1A, O_inc, "inc", ADDR_ACC},
+ {0xEE, O_inc, "inc", ADDR_ABS},
+ {0xFE, O_inc, "inc", ADDR_ABS_IDX_X},
+ {0xE6, O_inc, "inc", ADDR_DIR},
+ {0xF6, O_inc, "inc", ADDR_DIR_IDX_X},
+ {0xE8, O_inx, "inx", ADDR_IMPLIED},
+ {0xC8, O_iny, "iny", ADDR_IMPLIED},
+ {0x6C, O_jmp, "jmp", ADDR_ABS_IND},
+ {0x7C, O_jmp, "jmp", ADDR_ABS_IND_IDX},
+ {0xDC, O_jmp, "jmp", ADDR_ABS_IND_LONG},
+ {0x4C, O_jmp, "jmp", ADDR_ABS},
+ {0x5C, O_jmp, "jmp", ADDR_ABS_LONG},
+ {0xFC, O_jsr, "jsr", ADDR_ABS_IND_IDX},
+ {0x20, O_jsr, "jsr", ADDR_ABS},
+ {0x22, O_jsr, "jsr", ADDR_ABS_LONG},
+ {0xA9, O_lda, "lda", ADDR_IMMTOA},
+ {0xB2, O_lda, "lda", ADDR_DIR_IND},
+ {0xB1, O_lda, "lda", ADDR_DIR_IND_IDX_Y},
+ {0xB3, O_lda, "lda", ADDR_STACK_REL_INDX_IDX},
+ {0xA1, O_lda, "lda", ADDR_DIR_IDX_IND_X},
+ {0xA7, O_lda, "lda", ADDR_DIR_IND_LONG},
+ {0xB7, O_lda, "lda", ADDR_DIR_IND_IDX_Y_LONG},
+ {0xAD, O_lda, "lda", ADDR_ABS},
+ {0xBD, O_lda, "lda", ADDR_ABS_IDX_X},
+ {0xB9, O_lda, "lda", ADDR_ABS_IDX_Y},
+ {0xAF, O_lda, "lda", ADDR_ABS_LONG},
+ {0xBF, O_lda, "lda", ADDR_ABS_LONG_IDX_X},
+ {0xA5, O_lda, "lda", ADDR_DIR},
+ {0xA3, O_lda, "lda", ADDR_STACK_REL},
+ {0xB5, O_lda, "lda", ADDR_DIR_IDX_X},
+ {0xA2, O_ldx, "ldx", ADDR_IMMTOI},
+ {0xAE, O_ldx, "ldx", ADDR_ABS},
+ {0xBE, O_ldx, "ldx", ADDR_ABS_IDX_Y},
+ {0xA6, O_ldx, "ldx", ADDR_DIR},
+ {0xB6, O_ldx, "ldx", ADDR_DIR_IDX_Y},
+ {0xA0, O_ldy, "ldy", ADDR_IMMTOI},
+ {0xAC, O_ldy, "ldy", ADDR_ABS},
+ {0xBC, O_ldy, "ldy", ADDR_ABS_IDX_X},
+ {0xA4, O_ldy, "ldy", ADDR_DIR},
+ {0xB4, O_ldy, "ldy", ADDR_DIR_IDX_X},
+ {0x4A, O_lsr, "lsr", ADDR_ACC},
+ {0x4E, O_lsr, "lsr", ADDR_ABS},
+ {0x5E, O_lsr, "lsr", ADDR_ABS_IDX_X},
+ {0x46, O_lsr, "lsr", ADDR_DIR},
+ {0x56, O_lsr, "lsr", ADDR_DIR_IDX_X},
+ {0x54, O_mvn, "mvn", ADDR_BLOCK_MOVE},
+ {0x44, O_mvp, "mvp", ADDR_BLOCK_MOVE},
+ {0xEA, O_nop, "nop", ADDR_IMPLIED},
+ {0x09, O_ora, "ora", ADDR_IMMTOA},
+ {0x12, O_ora, "ora", ADDR_DIR_IND},
+ {0x11, O_ora, "ora", ADDR_DIR_IND_IDX_Y},
+ {0x13, O_ora, "ora", ADDR_STACK_REL_INDX_IDX},
+ {0x01, O_ora, "ora", ADDR_DIR_IDX_IND_X},
+ {0x07, O_ora, "ora", ADDR_DIR_IND_LONG},
+ {0x17, O_ora, "ora", ADDR_DIR_IND_IDX_Y_LONG},
+ {0x0D, O_ora, "ora", ADDR_ABS},
+ {0x1D, O_ora, "ora", ADDR_ABS_IDX_X},
+ {0x19, O_ora, "ora", ADDR_ABS_IDX_Y},
+ {0x0F, O_ora, "ora", ADDR_ABS_LONG},
+ {0x1F, O_ora, "ora", ADDR_ABS_LONG_IDX_X},
+ {0x05, O_ora, "ora", ADDR_DIR},
+ {0x03, O_ora, "ora", ADDR_STACK_REL},
+ {0x15, O_ora, "ora", ADDR_DIR_IDX_X},
+ {0xF4, O_pea, "pea", ADDR_ABS},
+ {0xD4, O_pei, "pei", ADDR_DIR},
+ {0x62, O_per, "per", ADDR_PC_REL_LONG},
+ {0x48, O_pha, "pha", ADDR_STACK},
+ {0x8B, O_phb, "phb", ADDR_STACK},
+ {0x0B, O_phd, "phd", ADDR_STACK},
+ {0x4B, O_phk, "phk", ADDR_STACK},
+ {0x08, O_php, "php", ADDR_STACK},
+ {0xDA, O_phx, "phx", ADDR_STACK},
+ {0x5A, O_phy, "phy", ADDR_STACK},
+ {0x68, O_pla, "pla", ADDR_STACK},
+ {0xAB, O_plb, "plb", ADDR_STACK},
+ {0x2B, O_pld, "pld", ADDR_STACK},
+ {0x28, O_plp, "plp", ADDR_STACK},
+ {0xFA, O_plx, "plx", ADDR_STACK},
+ {0x7A, O_ply, "ply", ADDR_STACK},
+ {0xC2, O_rep, "rep", ADDR_IMMCOP},
+ {0x2A, O_rol, "rol", ADDR_ACC},
+ {0x2E, O_rol, "rol", ADDR_ABS},
+ {0x3E, O_rol, "rol", ADDR_ABS_IDX_X},
+ {0x26, O_rol, "rol", ADDR_DIR},
+ {0x36, O_rol, "rol", ADDR_DIR_IDX_X},
+ {0x6A, O_ror, "ror", ADDR_ACC},
+ {0x6E, O_ror, "ror", ADDR_ABS},
+ {0x7E, O_ror, "ror", ADDR_ABS_IDX_X},
+ {0x66, O_ror, "ror", ADDR_DIR},
+ {0x76, O_ror, "ror", ADDR_DIR_IDX_X},
+ {0x40, O_rti, "rti", ADDR_STACK},
+ {0x6B, O_rtl, "rtl", ADDR_STACK},
+ {0x60, O_rts, "rts", ADDR_STACK},
+ {0xE9, O_sbc, "sbc", ADDR_IMMTOA},
+ {0xF2, O_sbc, "sbc", ADDR_DIR_IND},
+ {0xF1, O_sbc, "sbc", ADDR_DIR_IND_IDX_Y},
+ {0xF3, O_sbc, "sbc", ADDR_STACK_REL_INDX_IDX},
+ {0xE1, O_sbc, "sbc", ADDR_DIR_IDX_IND_X},
+ {0xE7, O_sbc, "sbc", ADDR_DIR_IND_LONG},
+ {0xF7, O_sbc, "sbc", ADDR_DIR_IND_IDX_Y_LONG},
+ {0xED, O_sbc, "sbc", ADDR_ABS},
+ {0xFD, O_sbc, "sbc", ADDR_ABS_IDX_X},
+ {0xF9, O_sbc, "sbc", ADDR_ABS_IDX_Y},
+ {0xEF, O_sbc, "sbc", ADDR_ABS_LONG},
+ {0xFF, O_sbc, "sbc", ADDR_ABS_LONG_IDX_X},
+ {0xE5, O_sbc, "sbc", ADDR_DIR},
+ {0xE3, O_sbc, "sbc", ADDR_STACK_REL},
+ {0xF5, O_sbc, "sbc", ADDR_DIR_IDX_X},
+ {0x38, O_sec, "sec", ADDR_IMPLIED},
+ {0xF8, O_sed, "sed", ADDR_IMPLIED},
+ {0x78, O_sei, "sei", ADDR_IMPLIED},
+ {0xE2, O_sep, "sep", ADDR_IMMCOP},
+ {0x92, O_sta, "sta", ADDR_DIR_IND},
+ {0x91, O_sta, "sta", ADDR_DIR_IND_IDX_Y},
+ {0x93, O_sta, "sta", ADDR_STACK_REL_INDX_IDX},
+ {0x81, O_sta, "sta", ADDR_DIR_IDX_IND_X},
+ {0x87, O_sta, "sta", ADDR_DIR_IND_LONG},
+ {0x97, O_sta, "sta", ADDR_DIR_IND_IDX_Y_LONG},
+ {0x8D, O_sta, "sta", ADDR_ABS},
+ {0x9D, O_sta, "sta", ADDR_ABS_IDX_X},
+ {0x99, O_sta, "sta", ADDR_ABS_IDX_Y},
+ {0x8F, O_sta, "sta", ADDR_ABS_LONG},
+ {0x9F, O_sta, "sta", ADDR_ABS_LONG_IDX_X},
+ {0x85, O_sta, "sta", ADDR_DIR},
+ {0x83, O_sta, "sta", ADDR_STACK_REL},
+ {0x95, O_sta, "sta", ADDR_DIR_IDX_X},
+ {0xDB, O_stp, "stp", ADDR_IMPLIED},
+ {0x8E, O_stx, "stx", ADDR_ABS},
+ {0x86, O_stx, "stx", ADDR_DIR},
+ {0x96, O_stx, "stx", ADDR_DIR_IDX_X},
+ {0x8C, O_sty, "sty", ADDR_ABS},
+ {0x84, O_sty, "sty", ADDR_DIR},
+ {0x94, O_sty, "sty", ADDR_DIR_IDX_X},
+ {0x9C, O_stz, "stz", ADDR_ABS},
+ {0x9E, O_stz, "stz", ADDR_ABS_IDX_X},
+ {0x64, O_stz, "stz", ADDR_DIR},
+ {0x74, O_stz, "stz", ADDR_DIR_IDX_X},
+ {0xAA, O_tax, "tax", ADDR_IMPLIED},
+ {0xA8, O_tay, "tay", ADDR_IMPLIED},
+ {0x5B, O_tcd, "tcd", ADDR_IMPLIED},
+ {0x1B, O_tcs, "tcs", ADDR_IMPLIED},
+ {0x7B, O_tdc, "tdc", ADDR_IMPLIED},
+ {0x1C, O_trb, "trb", ADDR_ABS},
+ {0x14, O_trb, "trb", ADDR_DIR},
+ {0x0C, O_tsb, "tsb", ADDR_ABS},
+ {0x04, O_tsb, "tsb", ADDR_DIR},
+ {0x3B, O_tsc, "tsc", ADDR_IMPLIED},
+ {0xBA, O_tsx, "tsx", ADDR_IMPLIED},
+ {0x8A, O_txa, "txa", ADDR_IMPLIED},
+ {0x9A, O_txs, "txs", ADDR_IMPLIED},
+ {0x9B, O_txy, "txy", ADDR_IMPLIED},
+ {0x98, O_tya, "tya", ADDR_IMPLIED},
+ {0xBB, O_tyx, "tyx", ADDR_IMPLIED},
+ {0xCB, O_wai, "wai", ADDR_IMPLIED},
+ {0x42, O_wdm, "wdm", ADDR_IMPLIED},
+ {0xEB, O_xba, "xba", ADDR_IMPLIED},
+ {0xFB, O_xce, "xce", ADDR_IMPLIED},
+ { 0 }
+};
+#endif
+#define DISASM()\
+ case ADDR_IMMTOA:\
+ args[0] = M==0 ? asR_W65_ABS16 : asR_W65_ABS8;\
+ print_operand (0, " #$0", args);\
+ size += M==0 ? 2:1;\
+ break;\
+ case ADDR_IMMCOP:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (0, " #$0", args);\
+ size += 1;\
+ break;\
+ case ADDR_IMMTOI:\
+ args[0] = X==0 ? asR_W65_ABS16 : asR_W65_ABS8;\
+ print_operand (0, " #$0", args);\
+ size += X==0 ? 2:1;\
+ break;\
+ case ADDR_ACC:\
+ print_operand (0, " a", 0);\
+ size += 0;\
+ break;\
+ case ADDR_PC_REL:\
+ args[0] = asR_W65_PCR8;\
+ print_operand (0, " $0", args);\
+ size += 1;\
+ break;\
+ case ADDR_PC_REL_LONG:\
+ args[0] = asR_W65_PCR16;\
+ print_operand (0, " $0", args);\
+ size += 2;\
+ break;\
+ case ADDR_IMPLIED:\
+ size += 0;\
+ break;\
+ case ADDR_STACK:\
+ size += 0;\
+ break;\
+ case ADDR_DIR:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " <$0", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IDX_X:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " <$0,x", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IDX_Y:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " <$0,y", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IND:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " (<$0)", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IDX_IND_X:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " (<$0,x)", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IND_IDX_Y:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " (<$0),y", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IND_LONG:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " [$0]", args);\
+ size += 1;\
+ break;\
+ case ADDR_DIR_IND_IDX_Y_LONG:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (1, " [$0],y", args);\
+ size += 1;\
+ break;\
+ case ADDR_ABS:\
+ args[0] = asR_W65_ABS16;\
+ print_operand (1, " !$0", args);\
+ size += 2;\
+ break;\
+ case ADDR_ABS_IDX_X:\
+ args[0] = asR_W65_ABS16;\
+ print_operand (1, " !$0,x", args);\
+ size += 2;\
+ break;\
+ case ADDR_ABS_IDX_Y:\
+ args[0] = asR_W65_ABS16;\
+ print_operand (1, " !$0,y", args);\
+ size += 2;\
+ break;\
+ case ADDR_ABS_LONG:\
+ args[0] = asR_W65_ABS24;\
+ print_operand (1, " >$0", args);\
+ size += 3;\
+ break;\
+ case ADDR_ABS_IND_LONG:\
+ args[0] = asR_W65_ABS16;\
+ print_operand (1, " [>$0]", args);\
+ size += 2;\
+ break;\
+ case ADDR_ABS_LONG_IDX_X:\
+ args[0] = asR_W65_ABS24;\
+ print_operand (1, " >$0,x", args);\
+ size += 3;\
+ break;\
+ case ADDR_STACK_REL:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (0, " $0,s", args);\
+ size += 1;\
+ break;\
+ case ADDR_STACK_REL_INDX_IDX:\
+ args[0] = asR_W65_ABS8;\
+ print_operand (0, " ($0,s),y", args);\
+ size += 1;\
+ break;\
+ case ADDR_ABS_IND:\
+ args[0] = asR_W65_ABS16;\
+ print_operand (1, " ($0)", args);\
+ size += 2;\
+ break;\
+ case ADDR_ABS_IND_IDX:\
+ args[0] = asR_W65_ABS16;\
+ print_operand (1, " ($0,x)", args);\
+ size += 2;\
+ break;\
+ case ADDR_BLOCK_MOVE:\
+ args[0] = (asR_W65_ABS16 >>8) &0xff;\
+ args[1] = ( asR_W65_ABS16 & 0xff);\
+ print_operand (0," $0,$1",args);\
+ size += 2;\
+ break;\
+
+#define GETINFO(size,type,pcrel)\
+ case ADDR_IMMTOA: size = M==0 ? 2:1;type=M==0 ? R_W65_ABS16 : R_W65_ABS8;pcrel=0;break;\
+ case ADDR_IMMCOP: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_IMMTOI: size = X==0 ? 2:1;type=X==0 ? R_W65_ABS16 : R_W65_ABS8;pcrel=0;break;\
+ case ADDR_ACC: size = 0;type=-1;pcrel=0;break;\
+ case ADDR_PC_REL: size = 1;type=R_W65_PCR8;pcrel=0;break;\
+ case ADDR_PC_REL_LONG: size = 2;type=R_W65_PCR16;pcrel=0;break;\
+ case ADDR_IMPLIED: size = 0;type=-1;pcrel=0;break;\
+ case ADDR_STACK: size = 0;type=-1;pcrel=0;break;\
+ case ADDR_DIR: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IDX_X: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IDX_Y: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IND: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IDX_IND_X: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IND_IDX_Y: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IND_LONG: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_DIR_IND_IDX_Y_LONG: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_ABS: size = 2;type=R_W65_ABS16;pcrel=0;break;\
+ case ADDR_ABS_IDX_X: size = 2;type=R_W65_ABS16;pcrel=0;break;\
+ case ADDR_ABS_IDX_Y: size = 2;type=R_W65_ABS16;pcrel=0;break;\
+ case ADDR_ABS_LONG: size = 3;type=R_W65_ABS24;pcrel=0;break;\
+ case ADDR_ABS_IND_LONG: size = 2;type=R_W65_ABS16;pcrel=0;break;\
+ case ADDR_ABS_LONG_IDX_X: size = 3;type=R_W65_ABS24;pcrel=0;break;\
+ case ADDR_STACK_REL: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_STACK_REL_INDX_IDX: size = 1;type=R_W65_ABS8;pcrel=0;break;\
+ case ADDR_ABS_IND: size = 2;type=R_W65_ABS16;pcrel=0;break;\
+ case ADDR_ABS_IND_IDX: size = 2;type=R_W65_ABS16;pcrel=0;break;\
+ case ADDR_BLOCK_MOVE: size = 2;type=-1;pcrel=0;break;\
+
diff --git a/opcodes/z8k-dis.c b/opcodes/z8k-dis.c
new file mode 100644
index 00000000000..7123622a291
--- /dev/null
+++ b/opcodes/z8k-dis.c
@@ -0,0 +1,574 @@
+/* Disassemble z8000 code.
+ Copyright 1992, 1993, 1995, 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Binutils.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <ansidecl.h>
+#include "sysdep.h"
+#include "dis-asm.h"
+
+#define DEFINE_TABLE
+#include "z8k-opc.h"
+
+
+#include <setjmp.h>
+
+
+typedef struct
+{
+ /* These are all indexed by nibble number (i.e only every other entry
+ of bytes is used, and every 4th entry of words). */
+ unsigned char nibbles[24];
+ unsigned char bytes[24];
+ unsigned short words[24];
+
+ /* Nibble number of first word not yet fetched. */
+ int max_fetched;
+ bfd_vma insn_start;
+ jmp_buf bailout;
+
+ long tabl_index;
+ char instr_asmsrc[80];
+ unsigned long arg_reg[0x0f];
+ unsigned long immediate;
+ unsigned long displacement;
+ unsigned long address;
+ unsigned long cond_code;
+ unsigned long ctrl_code;
+ unsigned long flags;
+ unsigned long interrupts;
+}
+instr_data_s;
+
+/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
+ to ADDR (exclusive) are valid. Returns 1 for success, longjmps
+ on error. */
+#define FETCH_DATA(info, nibble) \
+ ((nibble) < ((instr_data_s *)(info->private_data))->max_fetched \
+ ? 1 : fetch_data ((info), (nibble)))
+
+static int
+fetch_data (info, nibble)
+ struct disassemble_info *info;
+ int nibble;
+{
+ unsigned char mybuf[20];
+ int status;
+ instr_data_s *priv = (instr_data_s *)info->private_data;
+
+ if ((nibble % 4) != 0)
+ abort ();
+
+ status = (*info->read_memory_func) (priv->insn_start,
+ (bfd_byte *) mybuf,
+ nibble / 2,
+ info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, priv->insn_start, info);
+ longjmp (priv->bailout, 1);
+ }
+
+ {
+ int i;
+ unsigned char *p = mybuf ;
+
+ for (i = 0; i < nibble;)
+ {
+ priv->words[i] = (p[0] << 8) | p[1];
+
+ priv->bytes[i] = *p;
+ priv->nibbles[i++] = *p >> 4;
+ priv->nibbles[i++] = *p &0xf;
+
+ ++p;
+ priv->bytes[i] = *p;
+ priv->nibbles[i++] = *p >> 4;
+ priv->nibbles[i++] = *p & 0xf;
+
+ ++p;
+ }
+ }
+ priv->max_fetched = nibble;
+ return 1;
+}
+
+static char *codes[16] =
+{
+ "f",
+ "lt",
+ "le",
+ "ule",
+ "ov/pe",
+ "mi",
+ "eq",
+ "c/ult",
+ "t",
+ "ge",
+ "gt",
+ "ugt",
+ "nov/po",
+ "pl",
+ "ne",
+ "nc/uge"
+};
+
+int z8k_lookup_instr PARAMS ((unsigned char*, disassemble_info *));
+static void output_instr
+ PARAMS ((instr_data_s *, unsigned long, disassemble_info *));
+static void unpack_instr PARAMS ((instr_data_s *, int, disassemble_info *));
+static void unparse_instr PARAMS ((instr_data_s *));
+
+static int
+print_insn_z8k (addr, info, is_segmented)
+ bfd_vma addr;
+ disassemble_info *info;
+ int is_segmented;
+{
+ instr_data_s instr_data;
+
+ info->private_data = (PTR) &instr_data;
+ instr_data.max_fetched = 0;
+ instr_data.insn_start = addr;
+ if (setjmp (instr_data.bailout) != 0)
+ /* Error return. */
+ return -1;
+
+ instr_data.tabl_index = z8k_lookup_instr (instr_data.nibbles, info);
+ if (instr_data.tabl_index > 0)
+ {
+ unpack_instr (&instr_data, is_segmented, info);
+ unparse_instr (&instr_data);
+ output_instr (&instr_data, addr, info);
+ return z8k_table[instr_data.tabl_index].length;
+ }
+ else
+ {
+ FETCH_DATA (info, 4);
+ (*info->fprintf_func) (info->stream, ".word %02x%02x",
+ instr_data.bytes[0], instr_data.bytes[2]);
+ return 2;
+ }
+}
+
+int
+print_insn_z8001 (addr, info)
+ bfd_vma addr;
+ disassemble_info *info;
+{
+ return print_insn_z8k (addr, info, 1);
+}
+
+int
+print_insn_z8002 (addr, info)
+ bfd_vma addr;
+ disassemble_info *info;
+{
+ return print_insn_z8k (addr, info, 0);
+}
+
+int
+z8k_lookup_instr (nibbles, info)
+ unsigned char *nibbles;
+ disassemble_info *info;
+{
+
+ int nibl_index, tabl_index;
+ int nibl_matched;
+ unsigned short instr_nibl;
+ unsigned short tabl_datum, datum_class, datum_value;
+
+ nibl_matched = 0;
+ tabl_index = 0;
+ while (!nibl_matched && z8k_table[tabl_index].name)
+ {
+ nibl_matched = 1;
+ for (nibl_index = 0; nibl_index < z8k_table[tabl_index].length * 2 && nibl_matched; nibl_index++)
+ {
+ if ((nibl_index % 4) == 0)
+ /* Fetch one word at a time. */
+ FETCH_DATA (info, nibl_index + 4);
+ instr_nibl = nibbles[nibl_index];
+
+ tabl_datum = z8k_table[tabl_index].byte_info[nibl_index];
+ datum_class = tabl_datum & CLASS_MASK;
+ datum_value = ~CLASS_MASK & tabl_datum;
+
+ switch (datum_class)
+ {
+ case CLASS_BIT:
+ if (datum_value != instr_nibl)
+ nibl_matched = 0;
+ break;
+ case CLASS_00II:
+ if (!((~instr_nibl) & 0x4))
+ nibl_matched = 0;
+ break;
+ case CLASS_01II:
+ if (!(instr_nibl & 0x4))
+ nibl_matched = 0;
+ break;
+ case CLASS_0CCC:
+ if (!((~instr_nibl) & 0x8))
+ nibl_matched = 0;
+ break;
+ case CLASS_1CCC:
+ if (!(instr_nibl & 0x8))
+ nibl_matched = 0;
+ break;
+ case CLASS_0DISP7:
+ if (!((~instr_nibl) & 0x8))
+ nibl_matched = 0;
+ nibl_index += 1;
+ break;
+ case CLASS_1DISP7:
+ if (!(instr_nibl & 0x8))
+ nibl_matched = 0;
+ nibl_index += 1;
+ break;
+ case CLASS_REGN0:
+ if (instr_nibl == 0)
+ nibl_matched = 0;
+ break;
+ case CLASS_BIT_1OR2:
+ if ((instr_nibl | 0x2) != (datum_value | 0x2))
+ nibl_matched = 0;
+ break;
+ default:
+ break;
+ }
+ }
+ if (nibl_matched)
+ {
+ return tabl_index;
+ }
+
+ tabl_index++;
+ }
+ return -1;
+
+}
+
+static void
+output_instr (instr_data, addr, info)
+ instr_data_s *instr_data;
+ unsigned long addr;
+ disassemble_info *info;
+{
+ int loop, loop_limit;
+ char tmp_str[20];
+ char out_str[100];
+
+ strcpy (out_str, "\t");
+
+ loop_limit = z8k_table[instr_data->tabl_index].length * 2;
+ FETCH_DATA (info, loop_limit);
+ for (loop = 0; loop < loop_limit; loop++)
+ {
+ sprintf (tmp_str, "%x", instr_data->nibbles[loop]);
+ strcat (out_str, tmp_str);
+ }
+
+ while (loop++ < 8)
+ {
+ strcat (out_str, " ");
+ }
+
+ strcat (out_str, instr_data->instr_asmsrc);
+
+ (*info->fprintf_func) (info->stream, "%s", out_str);
+}
+
+static void
+unpack_instr (instr_data, is_segmented, info)
+ instr_data_s *instr_data;
+ int is_segmented;
+ disassemble_info *info;
+{
+ int nibl_count, loop;
+ unsigned short instr_nibl, instr_byte, instr_word;
+ long instr_long;
+ unsigned short tabl_datum, datum_class, datum_value;
+
+ nibl_count = 0;
+ loop = 0;
+ while (z8k_table[instr_data->tabl_index].byte_info[loop] != 0)
+ {
+ FETCH_DATA (info, nibl_count + 4 - (nibl_count % 4));
+ instr_nibl = instr_data->nibbles[nibl_count];
+ instr_byte = instr_data->bytes[nibl_count];
+ instr_word = instr_data->words[nibl_count];
+
+ tabl_datum = z8k_table[instr_data->tabl_index].byte_info[loop];
+ datum_class = tabl_datum & CLASS_MASK;
+ datum_value = tabl_datum & ~CLASS_MASK;
+
+ switch (datum_class)
+ {
+ case CLASS_X:
+ instr_data->address = instr_nibl;
+ break;
+ case CLASS_BA:
+ instr_data->displacement = instr_nibl;
+ break;
+ case CLASS_BX:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_DISP:
+ switch (datum_value)
+ {
+ case ARG_DISP16:
+ instr_data->displacement = instr_word;
+ nibl_count += 3;
+ break;
+ case ARG_DISP12:
+ instr_data->displacement = instr_word & 0x0fff;
+ nibl_count += 2;
+ break;
+ default:
+ break;
+ }
+ break;
+ case CLASS_IMM:
+ switch (datum_value)
+ {
+ case ARG_IMM4:
+ instr_data->immediate = instr_nibl;
+ break;
+ case ARG_NIM8:
+ instr_data->immediate = (-instr_byte);
+ nibl_count += 1;
+ break;
+ case ARG_IMM8:
+ instr_data->immediate = instr_byte;
+ nibl_count += 1;
+ break;
+ case ARG_IMM16:
+ instr_data->immediate = instr_word;
+ nibl_count += 3;
+ break;
+ case ARG_IMM32:
+ FETCH_DATA (info, nibl_count + 8);
+ instr_long = (instr_data->words[nibl_count] << 16)
+ | (instr_data->words[nibl_count + 4]);
+ instr_data->immediate = instr_long;
+ nibl_count += 7;
+ break;
+ case ARG_IMMN:
+ instr_data->immediate = instr_nibl - 1;
+ break;
+ case ARG_IMM4M1:
+ instr_data->immediate = instr_nibl + 1;
+ break;
+ case ARG_IMM_1:
+ instr_data->immediate = 1;
+ break;
+ case ARG_IMM_2:
+ instr_data->immediate = 2;
+ break;
+ case ARG_IMM2:
+ instr_data->immediate = instr_nibl & 0x3;
+ break;
+ default:
+ break;
+ }
+ break;
+ case CLASS_CC:
+ instr_data->cond_code = instr_nibl;
+ break;
+ case CLASS_CTRL:
+ instr_data->ctrl_code = instr_nibl;
+ break;
+ case CLASS_DA:
+ case CLASS_ADDRESS:
+ if (is_segmented)
+ {
+ if (instr_nibl & 0x8)
+ {
+ FETCH_DATA (info, nibl_count + 8);
+ instr_long = (instr_data->words[nibl_count] << 16)
+ | (instr_data->words[nibl_count + 4]);
+ instr_data->address = ((instr_word & 0x7f00) << 8) +
+ (instr_long & 0xffff);
+ nibl_count += 7;
+ }
+ else
+ {
+ instr_data->address = ((instr_word & 0x7f00) << 8) +
+ (instr_word & 0x00ff);
+ nibl_count += 3;
+ }
+ }
+ else
+ {
+ instr_data->address = instr_word;
+ nibl_count += 3;
+ }
+ break;
+ case CLASS_0CCC:
+ instr_data->cond_code = instr_nibl & 0x7;
+ break;
+ case CLASS_1CCC:
+ instr_data->cond_code = instr_nibl & 0x7;
+ break;
+ case CLASS_0DISP7:
+ instr_data->displacement = instr_byte & 0x7f;
+ nibl_count += 1;
+ break;
+ case CLASS_1DISP7:
+ instr_data->displacement = instr_byte & 0x7f;
+ nibl_count += 1;
+ break;
+ case CLASS_01II:
+ instr_data->interrupts = instr_nibl & 0x3;
+ break;
+ case CLASS_00II:
+ instr_data->interrupts = instr_nibl & 0x3;
+ break;
+ case CLASS_BIT:
+ /* do nothing */
+ break;
+ case CLASS_IR:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_FLAGS:
+ instr_data->flags = instr_nibl;
+ break;
+ case CLASS_REG:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_REG_BYTE:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_REG_WORD:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_REG_QUAD:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_REG_LONG:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ case CLASS_REGN0:
+ instr_data->arg_reg[datum_value] = instr_nibl;
+ break;
+ default:
+ break;
+ }
+
+ loop += 1;
+ nibl_count += 1;
+ }
+}
+
+static void
+unparse_instr (instr_data)
+ instr_data_s *instr_data;
+{
+ unsigned short tabl_datum, datum_class, datum_value;
+ int loop, loop_limit;
+ char out_str[80], tmp_str[25];
+
+ sprintf (out_str, "\t%s\t", z8k_table[instr_data->tabl_index].name);
+
+ loop_limit = z8k_table[instr_data->tabl_index].noperands;
+ for (loop = 0; loop < loop_limit; loop++)
+ {
+ if (loop)
+ strcat (out_str, ",");
+
+ tabl_datum = z8k_table[instr_data->tabl_index].arg_info[loop];
+ datum_class = tabl_datum & CLASS_MASK;
+ datum_value = tabl_datum & ~CLASS_MASK;
+
+ switch (datum_class)
+ {
+ case CLASS_X:
+ sprintf (tmp_str, "0x%0lx(R%ld)", instr_data->address,
+ instr_data->arg_reg[datum_value]);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_BA:
+ sprintf (tmp_str, "r%ld(#%lx)", instr_data->arg_reg[datum_value],
+ instr_data->immediate);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_BX:
+ sprintf (tmp_str, "r%ld(R%ld)", instr_data->arg_reg[datum_value],
+ instr_data->arg_reg[ARG_RX]);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_DISP:
+ sprintf (tmp_str, "#0x%0lx", instr_data->displacement);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_IMM:
+ sprintf (tmp_str, "#0x%0lx", instr_data->immediate);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_CC:
+ sprintf (tmp_str, "%s", codes[instr_data->cond_code]);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_CTRL:
+ sprintf (tmp_str, "0x%0lx", instr_data->ctrl_code);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_DA:
+ case CLASS_ADDRESS:
+ sprintf (tmp_str, "#0x%0lx", instr_data->address);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_IR:
+ sprintf (tmp_str, "@R%ld", instr_data->arg_reg[datum_value]);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_FLAGS:
+ sprintf (tmp_str, "0x%0lx", instr_data->flags);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_REG_BYTE:
+ if (instr_data->arg_reg[datum_value] >= 0x8)
+ {
+ sprintf (tmp_str, "rl%ld",
+ instr_data->arg_reg[datum_value] - 0x8);
+ }
+ else
+ {
+ sprintf (tmp_str, "rh%ld", instr_data->arg_reg[datum_value]);
+ }
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_REG_WORD:
+ sprintf (tmp_str, "r%ld", instr_data->arg_reg[datum_value]);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_REG_QUAD:
+ sprintf (tmp_str, "rq%ld", instr_data->arg_reg[datum_value]);
+ strcat (out_str, tmp_str);
+ break;
+ case CLASS_REG_LONG:
+ sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]);
+ strcat (out_str, tmp_str);
+ break;
+ default:
+ break;
+ }
+ }
+
+ strcpy (instr_data->instr_asmsrc, out_str);
+}
diff --git a/opcodes/z8k-opc.h b/opcodes/z8k-opc.h
new file mode 100644
index 00000000000..379a3a3c647
--- /dev/null
+++ b/opcodes/z8k-opc.h
@@ -0,0 +1,4438 @@
+ /* THIS FILE IS AUTOMAGICALLY GENERATED, DON'T EDIT IT */
+#define ARG_MASK 0x0f
+#define ARG_SRC 0x01
+#define ARG_DST 0x02
+#define ARG_RS 0x01
+#define ARG_RD 0x02
+#define ARG_RA 0x03
+#define ARG_RB 0x04
+#define ARG_RR 0x05
+#define ARG_RX 0x06
+#define ARG_IMM4 0x01
+#define ARG_IMM8 0x02
+#define ARG_IMM16 0x03
+#define ARG_IMM32 0x04
+#define ARG_IMMN 0x05
+#define ARG_IMMNMINUS1 0x05
+#define ARG_IMM_1 0x06
+#define ARG_IMM_2 0x07
+#define ARG_DISP16 0x08
+#define ARG_NIM8 0x09
+#define ARG_IMM2 0x0a
+#define ARG_IMM1OR2 0x0b
+#define ARG_DISP12 0x0b
+#define ARG_DISP8 0x0c
+#define ARG_IMM4M1 0x0d
+#define CLASS_MASK 0x1fff0
+#define CLASS_X 0x10
+#define CLASS_BA 0x20
+#define CLASS_DA 0x30
+#define CLASS_BX 0x40
+#define CLASS_DISP 0x50
+#define CLASS_IMM 0x60
+#define CLASS_CC 0x70
+#define CLASS_CTRL 0x80
+#define CLASS_ADDRESS 0xd0
+#define CLASS_0CCC 0xe0
+#define CLASS_1CCC 0xf0
+#define CLASS_0DISP7 0x100
+#define CLASS_1DISP7 0x200
+#define CLASS_01II 0x300
+#define CLASS_00II 0x400
+#define CLASS_BIT 0x500
+#define CLASS_FLAGS 0x600
+#define CLASS_IR 0x700
+#define CLASS_DISP8 0x800
+#define CLASS_BIT_1OR2 0x900
+#define CLASS_REG 0x7000
+#define CLASS_REG_BYTE 0x2000
+#define CLASS_REG_WORD 0x3000
+#define CLASS_REG_QUAD 0x4000
+#define CLASS_REG_LONG 0x5000
+#define CLASS_REGN0 0x8000
+#define CLASS_PR 0x10000
+#define OPC_adc 0
+#define OPC_adcb 1
+#define OPC_add 2
+#define OPC_addb 3
+#define OPC_addl 4
+#define OPC_and 5
+#define OPC_andb 6
+#define OPC_bit 7
+#define OPC_bitb 8
+#define OPC_call 9
+#define OPC_calr 10
+#define OPC_clr 11
+#define OPC_clrb 12
+#define OPC_com 13
+#define OPC_comb 14
+#define OPC_comflg 15
+#define OPC_cp 16
+#define OPC_cpb 17
+#define OPC_cpd 18
+#define OPC_cpdb 19
+#define OPC_cpdr 20
+#define OPC_cpdrb 21
+#define OPC_cpi 22
+#define OPC_cpib 23
+#define OPC_cpir 24
+#define OPC_cpirb 25
+#define OPC_cpl 26
+#define OPC_cpsd 27
+#define OPC_cpsdb 28
+#define OPC_cpsdr 29
+#define OPC_cpsdrb 30
+#define OPC_cpsi 31
+#define OPC_cpsib 32
+#define OPC_cpsir 33
+#define OPC_cpsirb 34
+#define OPC_dab 35
+#define OPC_dbjnz 36
+#define OPC_dec 37
+#define OPC_decb 38
+#define OPC_di 39
+#define OPC_div 40
+#define OPC_divl 41
+#define OPC_djnz 42
+#define OPC_ei 43
+#define OPC_ex 44
+#define OPC_exb 45
+#define OPC_exts 46
+#define OPC_extsb 47
+#define OPC_extsl 48
+#define OPC_halt 49
+#define OPC_in 50
+#define OPC_inb 51
+#define OPC_inc 52
+#define OPC_incb 53
+#define OPC_ind 54
+#define OPC_indb 55
+#define OPC_inib 56
+#define OPC_inibr 57
+#define OPC_iret 58
+#define OPC_jp 59
+#define OPC_jr 60
+#define OPC_ld 61
+#define OPC_lda 62
+#define OPC_ldar 63
+#define OPC_ldb 64
+#define OPC_ldctl 65
+#define OPC_ldir 66
+#define OPC_ldirb 67
+#define OPC_ldk 68
+#define OPC_ldl 69
+#define OPC_ldm 70
+#define OPC_ldps 71
+#define OPC_ldr 72
+#define OPC_ldrb 73
+#define OPC_ldrl 74
+#define OPC_mbit 75
+#define OPC_mreq 76
+#define OPC_mres 77
+#define OPC_mset 78
+#define OPC_mult 79
+#define OPC_multl 80
+#define OPC_neg 81
+#define OPC_negb 82
+#define OPC_nop 83
+#define OPC_or 84
+#define OPC_orb 85
+#define OPC_out 86
+#define OPC_outb 87
+#define OPC_outd 88
+#define OPC_outdb 89
+#define OPC_outib 90
+#define OPC_outibr 91
+#define OPC_pop 92
+#define OPC_popl 93
+#define OPC_push 94
+#define OPC_pushl 95
+#define OPC_res 96
+#define OPC_resb 97
+#define OPC_resflg 98
+#define OPC_ret 99
+#define OPC_rl 100
+#define OPC_rlb 101
+#define OPC_rlc 102
+#define OPC_rlcb 103
+#define OPC_rldb 104
+#define OPC_rr 105
+#define OPC_rrb 106
+#define OPC_rrc 107
+#define OPC_rrcb 108
+#define OPC_rrdb 109
+#define OPC_sbc 110
+#define OPC_sbcb 111
+#define OPC_sda 112
+#define OPC_sdab 113
+#define OPC_sdal 114
+#define OPC_sdl 115
+#define OPC_sdlb 116
+#define OPC_sdll 117
+#define OPC_set 118
+#define OPC_setb 119
+#define OPC_setflg 120
+#define OPC_sinb 121
+#define OPC_sind 122
+#define OPC_sindb 123
+#define OPC_sinib 124
+#define OPC_sinibr 125
+#define OPC_sla 126
+#define OPC_slab 127
+#define OPC_slal 128
+#define OPC_sll 129
+#define OPC_sllb 130
+#define OPC_slll 131
+#define OPC_sout 132
+#define OPC_soutb 133
+#define OPC_soutd 134
+#define OPC_soutdb 135
+#define OPC_soutib 136
+#define OPC_soutibr 137
+#define OPC_sra 138
+#define OPC_srab 139
+#define OPC_sral 140
+#define OPC_srl 141
+#define OPC_srlb 142
+#define OPC_srll 143
+#define OPC_sub 144
+#define OPC_subb 145
+#define OPC_subl 146
+#define OPC_tcc 147
+#define OPC_tccb 148
+#define OPC_test 149
+#define OPC_testb 150
+#define OPC_testl 151
+#define OPC_trdb 152
+#define OPC_trdrb 153
+#define OPC_trib 154
+#define OPC_trirb 155
+#define OPC_trtdrb 156
+#define OPC_trtib 157
+#define OPC_trtirb 158
+#define OPC_trtdb 159
+#define OPC_tset 160
+#define OPC_tsetb 161
+#define OPC_xor 162
+#define OPC_xorb 163
+#define OPC_ldd 164
+#define OPC_lddb 165
+#define OPC_lddr 166
+#define OPC_lddrb 167
+#define OPC_ldi 168
+#define OPC_ldib 169
+#define OPC_sc 170
+#define OPC_bpt 171
+#define OPC_ext0e 172
+#define OPC_ext0f 172
+#define OPC_ext8e 172
+#define OPC_ext8f 172
+#define OPC_rsvd36 172
+#define OPC_rsvd38 172
+#define OPC_rsvd78 172
+#define OPC_rsvd7e 172
+#define OPC_rsvd9d 172
+#define OPC_rsvd9f 172
+#define OPC_rsvdb9 172
+#define OPC_rsvdbf 172
+#define OPC_outi 173
+typedef struct {
+#ifdef NICENAMES
+char *nicename;
+int type;
+int cycles;
+int flags;
+#endif
+char *name;
+unsigned char opcode;
+void (*func)();
+unsigned int arg_info[4];
+unsigned int byte_info[10];
+int noperands;
+int length;
+int idx;
+} opcode_entry_type;
+#ifdef DEFINE_TABLE
+opcode_entry_type z8k_table[] = {
+
+
+/* 1011 0101 ssss dddd *** adc rd,rs */
+{
+#ifdef NICENAMES
+"adc rd,rs",16,5,
+0x3c,
+#endif
+"adc",OPC_adc,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+5,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,0},
+
+
+/* 1011 0100 ssss dddd *** adcb rbd,rbs */
+{
+#ifdef NICENAMES
+"adcb rbd,rbs",8,5,
+0x3f,
+#endif
+"adcb",OPC_adcb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+4,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,1},
+
+
+/* 0000 0001 ssN0 dddd *** add rd,@rs */
+{
+#ifdef NICENAMES
+"add rd,@rs",16,7,
+0x3c,
+#endif
+"add",OPC_add,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+1,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,2},
+
+
+/* 0100 0001 0000 dddd address_src *** add rd,address_src */
+{
+#ifdef NICENAMES
+"add rd,address_src",16,9,
+0x3c,
+#endif
+"add",OPC_add,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,3},
+
+
+/* 0100 0001 ssN0 dddd address_src *** add rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"add rd,address_src(rs)",16,10,
+0x3c,
+#endif
+"add",OPC_add,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+1,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,4},
+
+
+/* 0000 0001 0000 dddd imm16 *** add rd,imm16 */
+{
+#ifdef NICENAMES
+"add rd,imm16",16,7,
+0x3c,
+#endif
+"add",OPC_add,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,5},
+
+
+/* 1000 0001 ssss dddd *** add rd,rs */
+{
+#ifdef NICENAMES
+"add rd,rs",16,4,
+0x3c,
+#endif
+"add",OPC_add,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+1,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,6},
+
+
+/* 0000 0000 ssN0 dddd *** addb rbd,@rs */
+{
+#ifdef NICENAMES
+"addb rbd,@rs",8,7,
+0x3f,
+#endif
+"addb",OPC_addb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,7},
+
+
+/* 0100 0000 0000 dddd address_src *** addb rbd,address_src */
+{
+#ifdef NICENAMES
+"addb rbd,address_src",8,9,
+0x3f,
+#endif
+"addb",OPC_addb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,8},
+
+
+/* 0100 0000 ssN0 dddd address_src *** addb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"addb rbd,address_src(rs)",8,10,
+0x3f,
+#endif
+"addb",OPC_addb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,9},
+
+
+/* 0000 0000 0000 dddd imm8 imm8 *** addb rbd,imm8 */
+{
+#ifdef NICENAMES
+"addb rbd,imm8",8,7,
+0x3f,
+#endif
+"addb",OPC_addb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,10},
+
+
+/* 1000 0000 ssss dddd *** addb rbd,rbs */
+{
+#ifdef NICENAMES
+"addb rbd,rbs",8,4,
+0x3f,
+#endif
+"addb",OPC_addb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,11},
+
+
+/* 0001 0110 ssN0 dddd *** addl rrd,@rs */
+{
+#ifdef NICENAMES
+"addl rrd,@rs",32,14,
+0x3c,
+#endif
+"addl",OPC_addl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+6,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,12},
+
+
+/* 0101 0110 0000 dddd address_src *** addl rrd,address_src */
+{
+#ifdef NICENAMES
+"addl rrd,address_src",32,15,
+0x3c,
+#endif
+"addl",OPC_addl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,13},
+
+
+/* 0101 0110 ssN0 dddd address_src *** addl rrd,address_src(rs) */
+{
+#ifdef NICENAMES
+"addl rrd,address_src(rs)",32,16,
+0x3c,
+#endif
+"addl",OPC_addl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+6,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,14},
+
+
+/* 0001 0110 0000 dddd imm32 *** addl rrd,imm32 */
+{
+#ifdef NICENAMES
+"addl rrd,imm32",32,14,
+0x3c,
+#endif
+"addl",OPC_addl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM32),},
+ {CLASS_BIT+1,CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM32),0,0,0,0,},2,6,15},
+
+
+/* 1001 0110 ssss dddd *** addl rrd,rrs */
+{
+#ifdef NICENAMES
+"addl rrd,rrs",32,8,
+0x3c,
+#endif
+"addl",OPC_addl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+6,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,16},
+
+
+/* 0000 0111 ssN0 dddd *** and rd,@rs */
+{
+#ifdef NICENAMES
+"and rd,@rs",16,7,
+0x18,
+#endif
+"and",OPC_and,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+7,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,17},
+
+
+/* 0100 0111 0000 dddd address_src *** and rd,address_src */
+{
+#ifdef NICENAMES
+"and rd,address_src",16,9,
+0x18,
+#endif
+"and",OPC_and,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+7,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,18},
+
+
+/* 0100 0111 ssN0 dddd address_src *** and rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"and rd,address_src(rs)",16,10,
+0x18,
+#endif
+"and",OPC_and,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+7,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,19},
+
+
+/* 0000 0111 0000 dddd imm16 *** and rd,imm16 */
+{
+#ifdef NICENAMES
+"and rd,imm16",16,7,
+0x18,
+#endif
+"and",OPC_and,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+7,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,20},
+
+
+/* 1000 0111 ssss dddd *** and rd,rs */
+{
+#ifdef NICENAMES
+"and rd,rs",16,4,
+0x18,
+#endif
+"and",OPC_and,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+7,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,21},
+
+
+/* 0000 0110 ssN0 dddd *** andb rbd,@rs */
+{
+#ifdef NICENAMES
+"andb rbd,@rs",8,7,
+0x1c,
+#endif
+"andb",OPC_andb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+6,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,22},
+
+
+/* 0100 0110 0000 dddd address_src *** andb rbd,address_src */
+{
+#ifdef NICENAMES
+"andb rbd,address_src",8,9,
+0x1c,
+#endif
+"andb",OPC_andb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,23},
+
+
+/* 0100 0110 ssN0 dddd address_src *** andb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"andb rbd,address_src(rs)",8,10,
+0x1c,
+#endif
+"andb",OPC_andb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+6,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,24},
+
+
+/* 0000 0110 0000 dddd imm8 imm8 *** andb rbd,imm8 */
+{
+#ifdef NICENAMES
+"andb rbd,imm8",8,7,
+0x1c,
+#endif
+"andb",OPC_andb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,25},
+
+
+/* 1000 0110 ssss dddd *** andb rbd,rbs */
+{
+#ifdef NICENAMES
+"andb rbd,rbs",8,4,
+0x1c,
+#endif
+"andb",OPC_andb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+6,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,26},
+
+
+/* 0010 0111 ddN0 imm4 *** bit @rd,imm4 */
+{
+#ifdef NICENAMES
+"bit @rd,imm4",16,8,
+0x10,
+#endif
+"bit",OPC_bit,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+2,CLASS_BIT+7,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,27},
+
+
+/* 0110 0111 ddN0 imm4 address_dst *** bit address_dst(rd),imm4 */
+{
+#ifdef NICENAMES
+"bit address_dst(rd),imm4",16,11,
+0x10,
+#endif
+"bit",OPC_bit,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+7,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,28},
+
+
+/* 0110 0111 0000 imm4 address_dst *** bit address_dst,imm4 */
+{
+#ifdef NICENAMES
+"bit address_dst,imm4",16,10,
+0x10,
+#endif
+"bit",OPC_bit,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+7,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,29},
+
+
+/* 1010 0111 dddd imm4 *** bit rd,imm4 */
+{
+#ifdef NICENAMES
+"bit rd,imm4",16,4,
+0x10,
+#endif
+"bit",OPC_bit,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xa,CLASS_BIT+7,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,30},
+
+
+/* 0010 0111 0000 ssss 0000 dddd 0000 0000 *** bit rd,rs */
+{
+#ifdef NICENAMES
+"bit rd,rs",16,10,
+0x10,
+#endif
+"bit",OPC_bit,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+7,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,31},
+
+
+/* 0010 0110 ddN0 imm4 *** bitb @rd,imm4 */
+{
+#ifdef NICENAMES
+"bitb @rd,imm4",8,8,
+0x10,
+#endif
+"bitb",OPC_bitb,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+2,CLASS_BIT+6,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,32},
+
+
+/* 0110 0110 ddN0 imm4 address_dst *** bitb address_dst(rd),imm4 */
+{
+#ifdef NICENAMES
+"bitb address_dst(rd),imm4",8,11,
+0x10,
+#endif
+"bitb",OPC_bitb,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+6,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,33},
+
+
+/* 0110 0110 0000 imm4 address_dst *** bitb address_dst,imm4 */
+{
+#ifdef NICENAMES
+"bitb address_dst,imm4",8,10,
+0x10,
+#endif
+"bitb",OPC_bitb,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+6,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,34},
+
+
+/* 1010 0110 dddd imm4 *** bitb rbd,imm4 */
+{
+#ifdef NICENAMES
+"bitb rbd,imm4",8,4,
+0x10,
+#endif
+"bitb",OPC_bitb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xa,CLASS_BIT+6,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,35},
+
+
+/* 0010 0110 0000 ssss 0000 dddd 0000 0000 *** bitb rbd,rs */
+{
+#ifdef NICENAMES
+"bitb rbd,rs",8,10,
+0x10,
+#endif
+"bitb",OPC_bitb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,36},
+
+
+/* 0011 0110 0000 0000 *** bpt */
+{
+#ifdef NICENAMES
+"bpt",8,2,
+0x00,
+#endif
+"bpt",OPC_bpt,0,{0},
+ {CLASS_BIT+3,CLASS_BIT+6,CLASS_BIT+0,CLASS_BIT+0,0,0,0,0,0,},0,2,37},
+
+
+/* 0001 1111 ddN0 0000 *** call @rd */
+{
+#ifdef NICENAMES
+"call @rd",32,10,
+0x00,
+#endif
+"call",OPC_call,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+1,CLASS_BIT+0xf,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,38},
+
+
+/* 0101 1111 0000 0000 address_dst *** call address_dst */
+{
+#ifdef NICENAMES
+"call address_dst",32,12,
+0x00,
+#endif
+"call",OPC_call,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+5,CLASS_BIT+0xf,CLASS_BIT+0,CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,39},
+
+
+/* 0101 1111 ddN0 0000 address_dst *** call address_dst(rd) */
+{
+#ifdef NICENAMES
+"call address_dst(rd)",32,13,
+0x00,
+#endif
+"call",OPC_call,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+5,CLASS_BIT+0xf,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,40},
+
+
+/* 1101 disp12 *** calr disp12 */
+{
+#ifdef NICENAMES
+"calr disp12",16,10,
+0x00,
+#endif
+"calr",OPC_calr,0,{CLASS_DISP,},
+ {CLASS_BIT+0xd,CLASS_DISP+(ARG_DISP12),0,0,0,0,0,0,0,},1,2,41},
+
+
+/* 0000 1101 ddN0 1000 *** clr @rd */
+{
+#ifdef NICENAMES
+"clr @rd",16,8,
+0x00,
+#endif
+"clr",OPC_clr,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,0,0,0,0,},1,2,42},
+
+
+/* 0100 1101 0000 1000 address_dst *** clr address_dst */
+{
+#ifdef NICENAMES
+"clr address_dst",16,11,
+0x00,
+#endif
+"clr",OPC_clr,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+8,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,43},
+
+
+/* 0100 1101 ddN0 1000 address_dst *** clr address_dst(rd) */
+{
+#ifdef NICENAMES
+"clr address_dst(rd)",16,12,
+0x00,
+#endif
+"clr",OPC_clr,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,44},
+
+
+/* 1000 1101 dddd 1000 *** clr rd */
+{
+#ifdef NICENAMES
+"clr rd",16,7,
+0x00,
+#endif
+"clr",OPC_clr,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_BIT+8,0,0,0,0,0,},1,2,45},
+
+
+/* 0000 1100 ddN0 1000 *** clrb @rd */
+{
+#ifdef NICENAMES
+"clrb @rd",8,8,
+0x00,
+#endif
+"clrb",OPC_clrb,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,0,0,0,0,},1,2,46},
+
+
+/* 0100 1100 0000 1000 address_dst *** clrb address_dst */
+{
+#ifdef NICENAMES
+"clrb address_dst",8,11,
+0x00,
+#endif
+"clrb",OPC_clrb,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+8,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,47},
+
+
+/* 0100 1100 ddN0 1000 address_dst *** clrb address_dst(rd) */
+{
+#ifdef NICENAMES
+"clrb address_dst(rd)",8,12,
+0x00,
+#endif
+"clrb",OPC_clrb,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,48},
+
+
+/* 1000 1100 dddd 1000 *** clrb rbd */
+{
+#ifdef NICENAMES
+"clrb rbd",8,7,
+0x00,
+#endif
+"clrb",OPC_clrb,0,{CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_BIT+8,0,0,0,0,0,},1,2,49},
+
+
+/* 0000 1101 ddN0 0000 *** com @rd */
+{
+#ifdef NICENAMES
+"com @rd",16,12,
+0x18,
+#endif
+"com",OPC_com,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,50},
+
+
+/* 0100 1101 0000 0000 address_dst *** com address_dst */
+{
+#ifdef NICENAMES
+"com address_dst",16,15,
+0x18,
+#endif
+"com",OPC_com,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,51},
+
+
+/* 0100 1101 ddN0 0000 address_dst *** com address_dst(rd) */
+{
+#ifdef NICENAMES
+"com address_dst(rd)",16,16,
+0x18,
+#endif
+"com",OPC_com,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,52},
+
+
+/* 1000 1101 dddd 0000 *** com rd */
+{
+#ifdef NICENAMES
+"com rd",16,7,
+0x18,
+#endif
+"com",OPC_com,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,53},
+
+
+/* 0000 1100 ddN0 0000 *** comb @rd */
+{
+#ifdef NICENAMES
+"comb @rd",8,12,
+0x1c,
+#endif
+"comb",OPC_comb,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,54},
+
+
+/* 0100 1100 0000 0000 address_dst *** comb address_dst */
+{
+#ifdef NICENAMES
+"comb address_dst",8,15,
+0x1c,
+#endif
+"comb",OPC_comb,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,55},
+
+
+/* 0100 1100 ddN0 0000 address_dst *** comb address_dst(rd) */
+{
+#ifdef NICENAMES
+"comb address_dst(rd)",8,16,
+0x1c,
+#endif
+"comb",OPC_comb,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,56},
+
+
+/* 1000 1100 dddd 0000 *** comb rbd */
+{
+#ifdef NICENAMES
+"comb rbd",8,7,
+0x1c,
+#endif
+"comb",OPC_comb,0,{CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,57},
+
+
+/* 1000 1101 flags 0101 *** comflg flags */
+{
+#ifdef NICENAMES
+"comflg flags",16,7,
+0x3c,
+#endif
+"comflg",OPC_comflg,0,{CLASS_FLAGS,},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_FLAGS,CLASS_BIT+5,0,0,0,0,0,},1,2,58},
+
+
+/* 0000 1101 ddN0 0001 imm16 *** cp @rd,imm16 */
+{
+#ifdef NICENAMES
+"cp @rd,imm16",16,11,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_IR+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+1,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,59},
+
+
+/* 0100 1101 ddN0 0001 address_dst imm16 *** cp address_dst(rd),imm16 */
+{
+#ifdef NICENAMES
+"cp address_dst(rd),imm16",16,15,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_X+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+1,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM16),0,0,0,},2,6,60},
+
+
+/* 0100 1101 0000 0001 address_dst imm16 *** cp address_dst,imm16 */
+{
+#ifdef NICENAMES
+"cp address_dst,imm16",16,14,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_DA+(ARG_DST),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+1,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM16),0,0,0,},2,6,61},
+
+
+/* 0000 1011 ssN0 dddd *** cp rd,@rs */
+{
+#ifdef NICENAMES
+"cp rd,@rs",16,7,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,62},
+
+
+/* 0100 1011 0000 dddd address_src *** cp rd,address_src */
+{
+#ifdef NICENAMES
+"cp rd,address_src",16,9,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,63},
+
+
+/* 0100 1011 ssN0 dddd address_src *** cp rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"cp rd,address_src(rs)",16,10,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,64},
+
+
+/* 0000 1011 0000 dddd imm16 *** cp rd,imm16 */
+{
+#ifdef NICENAMES
+"cp rd,imm16",16,7,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,65},
+
+
+/* 1000 1011 ssss dddd *** cp rd,rs */
+{
+#ifdef NICENAMES
+"cp rd,rs",16,4,
+0x3c,
+#endif
+"cp",OPC_cp,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+0xb,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,66},
+
+
+/* 0000 1100 ddN0 0001 imm8 imm8 *** cpb @rd,imm8 */
+{
+#ifdef NICENAMES
+"cpb @rd,imm8",8,11,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_IR+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+1,CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,67},
+
+
+/* 0100 1100 ddN0 0001 address_dst imm8 imm8 *** cpb address_dst(rd),imm8 */
+{
+#ifdef NICENAMES
+"cpb address_dst(rd),imm8",8,15,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_X+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+1,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,},2,6,68},
+
+
+/* 0100 1100 0000 0001 address_dst imm8 imm8 *** cpb address_dst,imm8 */
+{
+#ifdef NICENAMES
+"cpb address_dst,imm8",8,14,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_DA+(ARG_DST),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+1,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,},2,6,69},
+
+
+/* 0000 1010 ssN0 dddd *** cpb rbd,@rs */
+{
+#ifdef NICENAMES
+"cpb rbd,@rs",8,7,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,70},
+
+
+/* 0100 1010 0000 dddd address_src *** cpb rbd,address_src */
+{
+#ifdef NICENAMES
+"cpb rbd,address_src",8,9,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,71},
+
+
+/* 0100 1010 ssN0 dddd address_src *** cpb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"cpb rbd,address_src(rs)",8,10,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,72},
+
+
+/* 0000 1010 0000 dddd imm8 imm8 *** cpb rbd,imm8 */
+{
+#ifdef NICENAMES
+"cpb rbd,imm8",8,7,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,73},
+
+
+/* 1000 1010 ssss dddd *** cpb rbd,rbs */
+{
+#ifdef NICENAMES
+"cpb rbd,rbs",8,4,
+0x3c,
+#endif
+"cpb",OPC_cpb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+0xa,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,74},
+
+
+/* 1011 1011 ssN0 1000 0000 rrrr dddd cccc *** cpd rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpd rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpd",OPC_cpd,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,75},
+
+
+/* 1011 1010 ssN0 1000 0000 rrrr dddd cccc *** cpdb rbd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpdb rbd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpdb",OPC_cpdb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,76},
+
+
+/* 1011 1011 ssN0 1100 0000 rrrr dddd cccc *** cpdr rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpdr rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpdr",OPC_cpdr,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xc,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,77},
+
+
+/* 1011 1010 ssN0 1100 0000 rrrr dddd cccc *** cpdrb rbd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpdrb rbd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpdrb",OPC_cpdrb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xc,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,78},
+
+
+/* 1011 1011 ssN0 0000 0000 rrrr dddd cccc *** cpi rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpi rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpi",OPC_cpi,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,79},
+
+
+/* 1011 1010 ssN0 0000 0000 rrrr dddd cccc *** cpib rbd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpib rbd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpib",OPC_cpib,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,80},
+
+
+/* 1011 1011 ssN0 0100 0000 rrrr dddd cccc *** cpir rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpir rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpir",OPC_cpir,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,81},
+
+
+/* 1011 1010 ssN0 0100 0000 rrrr dddd cccc *** cpirb rbd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpirb rbd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpirb",OPC_cpirb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REG+(ARG_RD),CLASS_CC,0,},4,4,82},
+
+
+/* 0001 0000 ssN0 dddd *** cpl rrd,@rs */
+{
+#ifdef NICENAMES
+"cpl rrd,@rs",32,14,
+0x3c,
+#endif
+"cpl",OPC_cpl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,83},
+
+
+/* 0101 0000 0000 dddd address_src *** cpl rrd,address_src */
+{
+#ifdef NICENAMES
+"cpl rrd,address_src",32,15,
+0x3c,
+#endif
+"cpl",OPC_cpl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,84},
+
+
+/* 0101 0000 ssN0 dddd address_src *** cpl rrd,address_src(rs) */
+{
+#ifdef NICENAMES
+"cpl rrd,address_src(rs)",32,16,
+0x3c,
+#endif
+"cpl",OPC_cpl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,85},
+
+
+/* 0001 0000 0000 dddd imm32 *** cpl rrd,imm32 */
+{
+#ifdef NICENAMES
+"cpl rrd,imm32",32,14,
+0x3c,
+#endif
+"cpl",OPC_cpl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM32),},
+ {CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM32),0,0,0,0,},2,6,86},
+
+
+/* 1001 0000 ssss dddd *** cpl rrd,rrs */
+{
+#ifdef NICENAMES
+"cpl rrd,rrs",32,8,
+0x3c,
+#endif
+"cpl",OPC_cpl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,87},
+
+
+/* 1011 1011 ssN0 1010 0000 rrrr ddN0 cccc *** cpsd @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsd @rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpsd",OPC_cpsd,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,88},
+
+
+/* 1011 1010 ssN0 1010 0000 rrrr ddN0 cccc *** cpsdb @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsdb @rd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpsdb",OPC_cpsdb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,89},
+
+
+/* 1011 1011 ssN0 1110 0000 rrrr ddN0 cccc *** cpsdr @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsdr @rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpsdr",OPC_cpsdr,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xe,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,90},
+
+
+/* 1011 1010 ssN0 1110 0000 rrrr ddN0 cccc *** cpsdrb @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsdrb @rd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpsdrb",OPC_cpsdrb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xe,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,91},
+
+
+/* 1011 1011 ssN0 0010 0000 rrrr ddN0 cccc *** cpsi @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsi @rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpsi",OPC_cpsi,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,92},
+
+
+/* 1011 1010 ssN0 0010 0000 rrrr ddN0 cccc *** cpsib @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsib @rd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpsib",OPC_cpsib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,93},
+
+
+/* 1011 1011 ssN0 0110 0000 rrrr ddN0 cccc *** cpsir @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsir @rd,@rs,rr,cc",16,11,
+0x3c,
+#endif
+"cpsir",OPC_cpsir,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,94},
+
+
+/* 1011 1010 ssN0 0110 0000 rrrr ddN0 cccc *** cpsirb @rd,@rs,rr,cc */
+{
+#ifdef NICENAMES
+"cpsirb @rd,@rs,rr,cc",8,11,
+0x3c,
+#endif
+"cpsirb",OPC_cpsirb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),CLASS_CC,},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_CC,0,},4,4,95},
+
+
+/* 1011 0000 dddd 0000 *** dab rbd */
+{
+#ifdef NICENAMES
+"dab rbd",8,5,
+0x38,
+#endif
+"dab",OPC_dab,0,{CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,96},
+
+
+/* 1111 dddd 0disp7 *** dbjnz rbd,disp7 */
+{
+#ifdef NICENAMES
+"dbjnz rbd,disp7",16,11,
+0x00,
+#endif
+"dbjnz",OPC_dbjnz,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DISP,},
+ {CLASS_BIT+0xf,CLASS_REG+(ARG_RD),CLASS_0DISP7,0,0,0,0,0,0,},2,2,97},
+
+
+/* 0010 1011 ddN0 imm4m1 *** dec @rd,imm4m1 */
+{
+#ifdef NICENAMES
+"dec @rd,imm4m1",16,11,
+0x1c,
+#endif
+"dec",OPC_dec,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+2,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,98},
+
+
+/* 0110 1011 ddN0 imm4m1 address_dst *** dec address_dst(rd),imm4m1 */
+{
+#ifdef NICENAMES
+"dec address_dst(rd),imm4m1",16,14,
+0x1c,
+#endif
+"dec",OPC_dec,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,99},
+
+
+/* 0110 1011 0000 imm4m1 address_dst *** dec address_dst,imm4m1 */
+{
+#ifdef NICENAMES
+"dec address_dst,imm4m1",16,13,
+0x1c,
+#endif
+"dec",OPC_dec,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,100},
+
+
+/* 1010 1011 dddd imm4m1 *** dec rd,imm4m1 */
+{
+#ifdef NICENAMES
+"dec rd,imm4m1",16,4,
+0x1c,
+#endif
+"dec",OPC_dec,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+0xa,CLASS_BIT+0xb,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,101},
+
+
+/* 0010 1010 ddN0 imm4m1 *** decb @rd,imm4m1 */
+{
+#ifdef NICENAMES
+"decb @rd,imm4m1",8,11,
+0x1c,
+#endif
+"decb",OPC_decb,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+2,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,102},
+
+
+/* 0110 1010 ddN0 imm4m1 address_dst *** decb address_dst(rd),imm4m1 */
+{
+#ifdef NICENAMES
+"decb address_dst(rd),imm4m1",8,14,
+0x1c,
+#endif
+"decb",OPC_decb,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,103},
+
+
+/* 0110 1010 0000 imm4m1 address_dst *** decb address_dst,imm4m1 */
+{
+#ifdef NICENAMES
+"decb address_dst,imm4m1",8,13,
+0x1c,
+#endif
+"decb",OPC_decb,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+0xa,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,104},
+
+
+/* 1010 1010 dddd imm4m1 *** decb rbd,imm4m1 */
+{
+#ifdef NICENAMES
+"decb rbd,imm4m1",8,4,
+0x1c,
+#endif
+"decb",OPC_decb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+0xa,CLASS_BIT+0xa,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,105},
+
+
+/* 0111 1100 0000 00ii *** di i2 */
+{
+#ifdef NICENAMES
+"di i2",16,7,
+0x00,
+#endif
+"di",OPC_di,0,{CLASS_IMM+(ARG_IMM2),},
+ {CLASS_BIT+7,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_00II,0,0,0,0,0,},1,2,106},
+
+
+/* 0001 1011 ssN0 dddd *** div rrd,@rs */
+{
+#ifdef NICENAMES
+"div rrd,@rs",16,107,
+0x3c,
+#endif
+"div",OPC_div,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,107},
+
+
+/* 0101 1011 0000 dddd address_src *** div rrd,address_src */
+{
+#ifdef NICENAMES
+"div rrd,address_src",16,107,
+0x3c,
+#endif
+"div",OPC_div,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,108},
+
+
+/* 0101 1011 ssN0 dddd address_src *** div rrd,address_src(rs) */
+{
+#ifdef NICENAMES
+"div rrd,address_src(rs)",16,107,
+0x3c,
+#endif
+"div",OPC_div,0,{CLASS_REG_LONG+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,109},
+
+
+/* 0001 1011 0000 dddd imm16 *** div rrd,imm16 */
+{
+#ifdef NICENAMES
+"div rrd,imm16",16,107,
+0x3c,
+#endif
+"div",OPC_div,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+1,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,110},
+
+
+/* 1001 1011 ssss dddd *** div rrd,rs */
+{
+#ifdef NICENAMES
+"div rrd,rs",16,107,
+0x3c,
+#endif
+"div",OPC_div,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+0xb,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,111},
+
+
+/* 0001 1010 ssN0 dddd *** divl rqd,@rs */
+{
+#ifdef NICENAMES
+"divl rqd,@rs",32,744,
+0x3c,
+#endif
+"divl",OPC_divl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,112},
+
+
+/* 0101 1010 0000 dddd address_src *** divl rqd,address_src */
+{
+#ifdef NICENAMES
+"divl rqd,address_src",32,745,
+0x3c,
+#endif
+"divl",OPC_divl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,113},
+
+
+/* 0101 1010 ssN0 dddd address_src *** divl rqd,address_src(rs) */
+{
+#ifdef NICENAMES
+"divl rqd,address_src(rs)",32,746,
+0x3c,
+#endif
+"divl",OPC_divl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,114},
+
+
+/* 0001 1010 0000 dddd imm32 *** divl rqd,imm32 */
+{
+#ifdef NICENAMES
+"divl rqd,imm32",32,744,
+0x3c,
+#endif
+"divl",OPC_divl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_IMM+(ARG_IMM32),},
+ {CLASS_BIT+1,CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM32),0,0,0,0,},2,6,115},
+
+
+/* 1001 1010 ssss dddd *** divl rqd,rrs */
+{
+#ifdef NICENAMES
+"divl rqd,rrs",32,744,
+0x3c,
+#endif
+"divl",OPC_divl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+0xa,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,116},
+
+
+/* 1111 dddd 1disp7 *** djnz rd,disp7 */
+{
+#ifdef NICENAMES
+"djnz rd,disp7",16,11,
+0x00,
+#endif
+"djnz",OPC_djnz,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DISP,},
+ {CLASS_BIT+0xf,CLASS_REG+(ARG_RD),CLASS_1DISP7,0,0,0,0,0,0,},2,2,117},
+
+
+/* 0111 1100 0000 01ii *** ei i2 */
+{
+#ifdef NICENAMES
+"ei i2",16,7,
+0x00,
+#endif
+"ei",OPC_ei,0,{CLASS_IMM+(ARG_IMM2),},
+ {CLASS_BIT+7,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_01II,0,0,0,0,0,},1,2,118},
+
+
+/* 0010 1101 ssN0 dddd *** ex rd,@rs */
+{
+#ifdef NICENAMES
+"ex rd,@rs",16,12,
+0x00,
+#endif
+"ex",OPC_ex,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,119},
+
+
+/* 0110 1101 0000 dddd address_src *** ex rd,address_src */
+{
+#ifdef NICENAMES
+"ex rd,address_src",16,15,
+0x00,
+#endif
+"ex",OPC_ex,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+6,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,120},
+
+
+/* 0110 1101 ssN0 dddd address_src *** ex rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"ex rd,address_src(rs)",16,16,
+0x00,
+#endif
+"ex",OPC_ex,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,121},
+
+
+/* 1010 1101 ssss dddd *** ex rd,rs */
+{
+#ifdef NICENAMES
+"ex rd,rs",16,6,
+0x00,
+#endif
+"ex",OPC_ex,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xa,CLASS_BIT+0xd,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,122},
+
+
+/* 0010 1100 ssN0 dddd *** exb rbd,@rs */
+{
+#ifdef NICENAMES
+"exb rbd,@rs",8,12,
+0x00,
+#endif
+"exb",OPC_exb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,123},
+
+
+/* 0110 1100 0000 dddd address_src *** exb rbd,address_src */
+{
+#ifdef NICENAMES
+"exb rbd,address_src",8,15,
+0x00,
+#endif
+"exb",OPC_exb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+6,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,124},
+
+
+/* 0110 1100 ssN0 dddd address_src *** exb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"exb rbd,address_src(rs)",8,16,
+0x00,
+#endif
+"exb",OPC_exb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,125},
+
+
+/* 1010 1100 ssss dddd *** exb rbd,rbs */
+{
+#ifdef NICENAMES
+"exb rbd,rbs",8,6,
+0x00,
+#endif
+"exb",OPC_exb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+0xa,CLASS_BIT+0xc,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,126},
+
+
+/* 0000 1110 imm8 *** ext0e imm8 */
+{
+#ifdef NICENAMES
+"ext0e imm8",8,10,
+0x00,
+#endif
+"ext0e",OPC_ext0e,0,{CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+0xe,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},1,2,127},
+
+
+/* 0000 1111 imm8 *** ext0f imm8 */
+{
+#ifdef NICENAMES
+"ext0f imm8",8,10,
+0x00,
+#endif
+"ext0f",OPC_ext0f,0,{CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+0xf,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},1,2,128},
+
+
+/* 1000 1110 imm8 *** ext8e imm8 */
+{
+#ifdef NICENAMES
+"ext8e imm8",8,10,
+0x00,
+#endif
+"ext8e",OPC_ext8e,0,{CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+8,CLASS_BIT+0xe,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},1,2,129},
+
+
+/* 1000 1111 imm8 *** ext8f imm8 */
+{
+#ifdef NICENAMES
+"ext8f imm8",8,10,
+0x00,
+#endif
+"ext8f",OPC_ext8f,0,{CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+8,CLASS_BIT+0xf,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},1,2,130},
+
+
+/* 1011 0001 dddd 1010 *** exts rrd */
+{
+#ifdef NICENAMES
+"exts rrd",16,11,
+0x00,
+#endif
+"exts",OPC_exts,0,{CLASS_REG_LONG+(ARG_RD),},
+ {CLASS_BIT+0xb,CLASS_BIT+1,CLASS_REG+(ARG_RD),CLASS_BIT+0xa,0,0,0,0,0,},1,2,131},
+
+
+/* 1011 0001 dddd 0000 *** extsb rd */
+{
+#ifdef NICENAMES
+"extsb rd",8,11,
+0x00,
+#endif
+"extsb",OPC_extsb,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+0xb,CLASS_BIT+1,CLASS_REG+(ARG_RD),CLASS_BIT+0,0,0,0,0,0,},1,2,132},
+
+
+/* 1011 0001 dddd 0111 *** extsl rqd */
+{
+#ifdef NICENAMES
+"extsl rqd",32,11,
+0x00,
+#endif
+"extsl",OPC_extsl,0,{CLASS_REG_QUAD+(ARG_RD),},
+ {CLASS_BIT+0xb,CLASS_BIT+1,CLASS_REG+(ARG_RD),CLASS_BIT+7,0,0,0,0,0,},1,2,133},
+
+
+/* 0111 1010 0000 0000 *** halt */
+{
+#ifdef NICENAMES
+"halt",16,8,
+0x00,
+#endif
+"halt",OPC_halt,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+0xa,CLASS_BIT+0,CLASS_BIT+0,0,0,0,0,0,},0,2,134},
+
+
+/* 0011 1101 ssN0 dddd *** in rd,@rs */
+{
+#ifdef NICENAMES
+"in rd,@rs",16,10,
+0x00,
+#endif
+"in",OPC_in,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,135},
+
+
+/* 0011 1101 dddd 0100 imm16 *** in rd,imm16 */
+{
+#ifdef NICENAMES
+"in rd,imm16",16,12,
+0x00,
+#endif
+"in",OPC_in,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+3,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_BIT+4,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,136},
+
+
+/* 0011 1100 ssN0 dddd *** inb rbd,@rs */
+{
+#ifdef NICENAMES
+"inb rbd,@rs",8,12,
+0x00,
+#endif
+"inb",OPC_inb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,137},
+
+
+/* 0011 1010 dddd 0100 imm16 *** inb rbd,imm16 */
+{
+#ifdef NICENAMES
+"inb rbd,imm16",8,10,
+0x00,
+#endif
+"inb",OPC_inb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REG+(ARG_RD),CLASS_BIT+4,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,138},
+
+
+/* 0010 1001 ddN0 imm4m1 *** inc @rd,imm4m1 */
+{
+#ifdef NICENAMES
+"inc @rd,imm4m1",16,11,
+0x1c,
+#endif
+"inc",OPC_inc,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+2,CLASS_BIT+9,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,139},
+
+
+/* 0110 1001 ddN0 imm4m1 address_dst *** inc address_dst(rd),imm4m1 */
+{
+#ifdef NICENAMES
+"inc address_dst(rd),imm4m1",16,14,
+0x1c,
+#endif
+"inc",OPC_inc,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+9,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,140},
+
+
+/* 0110 1001 0000 imm4m1 address_dst *** inc address_dst,imm4m1 */
+{
+#ifdef NICENAMES
+"inc address_dst,imm4m1",16,13,
+0x1c,
+#endif
+"inc",OPC_inc,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+9,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,141},
+
+
+/* 1010 1001 dddd imm4m1 *** inc rd,imm4m1 */
+{
+#ifdef NICENAMES
+"inc rd,imm4m1",16,4,
+0x1c,
+#endif
+"inc",OPC_inc,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+0xa,CLASS_BIT+9,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,142},
+
+
+/* 0010 1000 ddN0 imm4m1 *** incb @rd,imm4m1 */
+{
+#ifdef NICENAMES
+"incb @rd,imm4m1",8,11,
+0x1c,
+#endif
+"incb",OPC_incb,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+2,CLASS_BIT+8,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,143},
+
+
+/* 0110 1000 ddN0 imm4m1 address_dst *** incb address_dst(rd),imm4m1 */
+{
+#ifdef NICENAMES
+"incb address_dst(rd),imm4m1",8,14,
+0x1c,
+#endif
+"incb",OPC_incb,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+8,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,144},
+
+
+/* 0110 1000 0000 imm4m1 address_dst *** incb address_dst,imm4m1 */
+{
+#ifdef NICENAMES
+"incb address_dst,imm4m1",8,13,
+0x1c,
+#endif
+"incb",OPC_incb,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+6,CLASS_BIT+8,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,145},
+
+
+/* 1010 1000 dddd imm4m1 *** incb rbd,imm4m1 */
+{
+#ifdef NICENAMES
+"incb rbd,imm4m1",8,4,
+0x1c,
+#endif
+"incb",OPC_incb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4M1),},
+ {CLASS_BIT+0xa,CLASS_BIT+8,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4M1),0,0,0,0,0,},2,2,146},
+
+
+/* 0011 1011 ssN0 1000 0000 aaaa ddN0 1000 *** ind @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"ind @rd,@rs,ra",16,21,
+0x04,
+#endif
+"ind",OPC_ind,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,147},
+
+
+/* 0011 1010 ssN0 1000 0000 aaaa ddN0 1000 *** indb @rd,@rs,rba */
+{
+#ifdef NICENAMES
+"indb @rd,@rs,rba",8,21,
+0x04,
+#endif
+"indb",OPC_indb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,148},
+
+
+/* 0011 1010 ssN0 0000 0000 aaaa ddN0 1000 *** inib @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"inib @rd,@rs,ra",8,21,
+0x04,
+#endif
+"inib",OPC_inib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,149},
+
+
+/* 0011 1010 ssN0 0000 0000 aaaa ddN0 0000 *** inibr @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"inibr @rd,@rs,ra",16,21,
+0x04,
+#endif
+"inibr",OPC_inibr,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,150},
+
+
+/* 0111 1011 0000 0000 *** iret */
+{
+#ifdef NICENAMES
+"iret",16,13,
+0x3f,
+#endif
+"iret",OPC_iret,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_BIT+0,0,0,0,0,0,},0,2,151},
+
+
+/* 0001 1110 ddN0 cccc *** jp cc,@rd */
+{
+#ifdef NICENAMES
+"jp cc,@rd",16,10,
+0x00,
+#endif
+"jp",OPC_jp,0,{CLASS_CC,CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+1,CLASS_BIT+0xe,CLASS_REGN0+(ARG_RD),CLASS_CC,0,0,0,0,0,},2,2,152},
+
+
+/* 0101 1110 0000 cccc address_dst *** jp cc,address_dst */
+{
+#ifdef NICENAMES
+"jp cc,address_dst",16,7,
+0x00,
+#endif
+"jp",OPC_jp,0,{CLASS_CC,CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+5,CLASS_BIT+0xe,CLASS_BIT+0,CLASS_CC,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,153},
+
+
+/* 0101 1110 ddN0 cccc address_dst *** jp cc,address_dst(rd) */
+{
+#ifdef NICENAMES
+"jp cc,address_dst(rd)",16,8,
+0x00,
+#endif
+"jp",OPC_jp,0,{CLASS_CC,CLASS_X+(ARG_RD),},
+ {CLASS_BIT+5,CLASS_BIT+0xe,CLASS_REGN0+(ARG_RD),CLASS_CC,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,154},
+
+
+/* 1110 cccc disp8 *** jr cc,disp8 */
+{
+#ifdef NICENAMES
+"jr cc,disp8",16,6,
+0x00,
+#endif
+"jr",OPC_jr,0,{CLASS_CC,CLASS_DISP,},
+ {CLASS_BIT+0xe,CLASS_CC,CLASS_DISP8,0,0,0,0,0,0,},2,2,155},
+
+
+/* 0000 1101 ddN0 0101 imm16 *** ld @rd,imm16 */
+{
+#ifdef NICENAMES
+"ld @rd,imm16",16,7,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_IR+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+5,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,156},
+
+
+/* 0010 1111 ddN0 ssss *** ld @rd,rs */
+{
+#ifdef NICENAMES
+"ld @rd,rs",16,8,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_IR+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+0xf,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,157},
+
+
+/* 0100 1101 ddN0 0101 address_dst imm16 *** ld address_dst(rd),imm16 */
+{
+#ifdef NICENAMES
+"ld address_dst(rd),imm16",16,15,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_X+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+5,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM16),0,0,0,},2,6,158},
+
+
+/* 0110 1111 ddN0 ssss address_dst *** ld address_dst(rd),rs */
+{
+#ifdef NICENAMES
+"ld address_dst(rd),rs",16,12,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_X+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0xf,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,159},
+
+
+/* 0100 1101 0000 0101 address_dst imm16 *** ld address_dst,imm16 */
+{
+#ifdef NICENAMES
+"ld address_dst,imm16",16,14,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_DA+(ARG_DST),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+5,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM16),0,0,0,},2,6,160},
+
+
+/* 0110 1111 0000 ssss address_dst *** ld address_dst,rs */
+{
+#ifdef NICENAMES
+"ld address_dst,rs",16,11,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_DA+(ARG_DST),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0xf,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,161},
+
+
+/* 0011 0011 ddN0 ssss imm16 *** ld rd(imm16),rs */
+{
+#ifdef NICENAMES
+"ld rd(imm16),rs",16,14,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_BA+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,162},
+
+
+/* 0111 0011 ddN0 ssss 0000 xxxx 0000 0000 *** ld rd(rx),rs */
+{
+#ifdef NICENAMES
+"ld rd(rx),rs",16,14,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_BX+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,163},
+
+
+/* 0010 0001 ssN0 dddd *** ld rd,@rs */
+{
+#ifdef NICENAMES
+"ld rd,@rs",16,7,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+1,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,164},
+
+
+/* 0110 0001 0000 dddd address_src *** ld rd,address_src */
+{
+#ifdef NICENAMES
+"ld rd,address_src",16,9,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+6,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,165},
+
+
+/* 0110 0001 ssN0 dddd address_src *** ld rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"ld rd,address_src(rs)",16,10,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+1,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,166},
+
+
+/* 0010 0001 0000 dddd imm16 *** ld rd,imm16 */
+{
+#ifdef NICENAMES
+"ld rd,imm16",16,7,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+2,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,167},
+
+
+/* 1010 0001 ssss dddd *** ld rd,rs */
+{
+#ifdef NICENAMES
+"ld rd,rs",16,3,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xa,CLASS_BIT+1,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,168},
+
+
+/* 0011 0001 ssN0 dddd imm16 *** ld rd,rs(imm16) */
+{
+#ifdef NICENAMES
+"ld rd,rs(imm16)",16,14,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_BA+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+1,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,169},
+
+
+/* 0111 0001 ssN0 dddd 0000 xxxx 0000 0000 *** ld rd,rs(rx) */
+{
+#ifdef NICENAMES
+"ld rd,rs(rx)",16,14,
+0x00,
+#endif
+"ld",OPC_ld,0,{CLASS_REG_WORD+(ARG_RD),CLASS_BX+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+1,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,170},
+
+
+/* 0111 0110 0000 dddd address_src *** lda prd,address_src */
+{
+#ifdef NICENAMES
+"lda prd,address_src",16,12,
+0x00,
+#endif
+"lda",OPC_lda,0,{CLASS_PR+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+7,CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,171},
+
+
+/* 0111 0110 ssN0 dddd address_src *** lda prd,address_src(rs) */
+{
+#ifdef NICENAMES
+"lda prd,address_src(rs)",16,13,
+0x00,
+#endif
+"lda",OPC_lda,0,{CLASS_PR+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+6,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,172},
+
+
+/* 0011 0100 ssN0 dddd imm16 *** lda prd,rs(imm16) */
+{
+#ifdef NICENAMES
+"lda prd,rs(imm16)",16,15,
+0x00,
+#endif
+"lda",OPC_lda,0,{CLASS_PR+(ARG_RD),CLASS_BA+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+4,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,173},
+
+
+/* 0111 0100 ssN0 dddd 0000 xxxx 0000 0000 *** lda prd,rs(rx) */
+{
+#ifdef NICENAMES
+"lda prd,rs(rx)",16,15,
+0x00,
+#endif
+"lda",OPC_lda,0,{CLASS_PR+(ARG_RD),CLASS_BX+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+4,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,174},
+
+
+/* 0011 0100 0000 dddd disp16 *** ldar prd,disp16 */
+{
+#ifdef NICENAMES
+"ldar prd,disp16",16,15,
+0x00,
+#endif
+"ldar",OPC_ldar,0,{CLASS_PR+(ARG_RD),CLASS_DISP,},
+ {CLASS_BIT+3,CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,175},
+
+
+/* 0000 1100 ddN0 0101 imm8 imm8 *** ldb @rd,imm8 */
+{
+#ifdef NICENAMES
+"ldb @rd,imm8",8,7,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_IR+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+5,CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,176},
+
+
+/* 0010 1110 ddN0 ssss *** ldb @rd,rbs */
+{
+#ifdef NICENAMES
+"ldb @rd,rbs",8,8,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_IR+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+0xe,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,177},
+
+
+/* 0100 1100 ddN0 0101 address_dst imm8 imm8 *** ldb address_dst(rd),imm8 */
+{
+#ifdef NICENAMES
+"ldb address_dst(rd),imm8",8,15,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_X+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+5,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,},2,6,178},
+
+
+/* 0110 1110 ddN0 ssss address_dst *** ldb address_dst(rd),rbs */
+{
+#ifdef NICENAMES
+"ldb address_dst(rd),rbs",8,12,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_X+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0xe,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,179},
+
+
+/* 0100 1100 0000 0101 address_dst imm8 imm8 *** ldb address_dst,imm8 */
+{
+#ifdef NICENAMES
+"ldb address_dst,imm8",8,14,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_DA+(ARG_DST),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+5,CLASS_ADDRESS+(ARG_DST),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,},2,6,180},
+
+
+/* 0110 1110 0000 ssss address_dst *** ldb address_dst,rbs */
+{
+#ifdef NICENAMES
+"ldb address_dst,rbs",8,11,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_DA+(ARG_DST),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0xe,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,181},
+
+
+/* 0010 0000 ssN0 dddd *** ldb rbd,@rs */
+{
+#ifdef NICENAMES
+"ldb rbd,@rs",8,7,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,182},
+
+
+/* 0110 0000 0000 dddd address_src *** ldb rbd,address_src */
+{
+#ifdef NICENAMES
+"ldb rbd,address_src",8,9,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+6,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,183},
+
+
+/* 0110 0000 ssN0 dddd address_src *** ldb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"ldb rbd,address_src(rs)",8,10,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+6,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,184},
+
+
+/* 1100 dddd imm8 *** ldb rbd,imm8 */
+{
+#ifdef NICENAMES
+"ldb rbd,imm8",8,5,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},2,2,185},
+
+
+/* 1010 0000 ssss dddd *** ldb rbd,rbs */
+{
+#ifdef NICENAMES
+"ldb rbd,rbs",8,3,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,186},
+
+
+/* 0011 0000 ssN0 dddd imm16 *** ldb rbd,rs(imm16) */
+{
+#ifdef NICENAMES
+"ldb rbd,rs(imm16)",8,14,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_BA+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,187},
+
+
+/* 0111 0000 ssN0 dddd 0000 xxxx 0000 0000 *** ldb rbd,rs(rx) */
+{
+#ifdef NICENAMES
+"ldb rbd,rs(rx)",8,14,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_BX+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,188},
+
+
+/* 0011 0010 ddN0 ssss imm16 *** ldb rd(imm16),rbs */
+{
+#ifdef NICENAMES
+"ldb rd(imm16),rbs",8,14,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_BA+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+2,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,189},
+
+
+/* 0111 0010 ddN0 ssss 0000 xxxx 0000 0000 *** ldb rd(rx),rbs */
+{
+#ifdef NICENAMES
+"ldb rd(rx),rbs",8,14,
+0x00,
+#endif
+"ldb",OPC_ldb,0,{CLASS_BX+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+2,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,190},
+
+
+/* 0111 1101 ssss 1ccc *** ldctl ctrl,rs */
+{
+#ifdef NICENAMES
+"ldctl ctrl,rs",32,7,
+0x00,
+#endif
+"ldctl",OPC_ldctl,0,{CLASS_CTRL,CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+0xd,CLASS_REG+(ARG_RS),CLASS_1CCC,0,0,0,0,0,},2,2,191},
+
+
+/* 0111 1101 dddd 0ccc *** ldctl rd,ctrl */
+{
+#ifdef NICENAMES
+"ldctl rd,ctrl",32,7,
+0x00,
+#endif
+"ldctl",OPC_ldctl,0,{CLASS_REG_WORD+(ARG_RD),CLASS_CTRL,},
+ {CLASS_BIT+7,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_0CCC,0,0,0,0,0,},2,2,192},
+
+
+/* 1011 1011 ssN0 1001 0000 rrrr ddN0 1000 *** ldd @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"ldd @rd,@rs,rr",16,11,
+0x04,
+#endif
+"ldd",OPC_ldd,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,193},
+
+
+/* 1011 1010 ssN0 1001 0000 rrrr ddN0 1000 *** lddb @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"lddb @rd,@rs,rr",8,11,
+0x04,
+#endif
+"lddb",OPC_lddb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,194},
+
+
+/* 1011 1011 ssN0 1001 0000 rrrr ddN0 0000 *** lddr @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"lddr @rd,@rs,rr",16,11,
+0x04,
+#endif
+"lddr",OPC_lddr,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,195},
+
+
+/* 1011 1010 ssN0 1001 0000 rrrr ddN0 0000 *** lddrb @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"lddrb @rd,@rs,rr",8,11,
+0x04,
+#endif
+"lddrb",OPC_lddrb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,196},
+
+
+/* 1011 1011 ssN0 0001 0000 rrrr ddN0 1000 *** ldi @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"ldi @rd,@rs,rr",16,11,
+0x04,
+#endif
+"ldi",OPC_ldi,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,197},
+
+
+/* 1011 1010 ssN0 0001 0000 rrrr ddN0 1000 *** ldib @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"ldib @rd,@rs,rr",8,11,
+0x04,
+#endif
+"ldib",OPC_ldib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,198},
+
+
+/* 1011 1011 ssN0 0001 0000 rrrr ddN0 0000 *** ldir @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"ldir @rd,@rs,rr",16,11,
+0x04,
+#endif
+"ldir",OPC_ldir,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,199},
+
+
+/* 1011 1010 ssN0 0001 0000 rrrr ddN0 0000 *** ldirb @rd,@rs,rr */
+{
+#ifdef NICENAMES
+"ldirb @rd,@rs,rr",8,11,
+0x04,
+#endif
+"ldirb",OPC_ldirb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,200},
+
+
+/* 1011 1101 dddd imm4 *** ldk rd,imm4 */
+{
+#ifdef NICENAMES
+"ldk rd,imm4",16,5,
+0x00,
+#endif
+"ldk",OPC_ldk,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,201},
+
+
+/* 0001 1101 ddN0 ssss *** ldl @rd,rrs */
+{
+#ifdef NICENAMES
+"ldl @rd,rrs",32,11,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_IR+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,202},
+
+
+/* 0101 1101 ddN0 ssss address_dst *** ldl address_dst(rd),rrs */
+{
+#ifdef NICENAMES
+"ldl address_dst(rd),rrs",32,14,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_X+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,203},
+
+
+/* 0101 1101 0000 ssss address_dst *** ldl address_dst,rrs */
+{
+#ifdef NICENAMES
+"ldl address_dst,rrs",32,15,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_DA+(ARG_DST),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,204},
+
+
+/* 0011 0111 ddN0 ssss imm16 *** ldl rd(imm16),rrs */
+{
+#ifdef NICENAMES
+"ldl rd(imm16),rrs",32,17,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_BA+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+7,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,205},
+
+
+/* 0111 0111 ddN0 ssss 0000 xxxx 0000 0000 *** ldl rd(rx),rrs */
+{
+#ifdef NICENAMES
+"ldl rd(rx),rrs",32,17,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_BX+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+7,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,206},
+
+
+/* 0001 0100 ssN0 dddd *** ldl rrd,@rs */
+{
+#ifdef NICENAMES
+"ldl rrd,@rs",32,11,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+4,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,207},
+
+
+/* 0101 0100 0000 dddd address_src *** ldl rrd,address_src */
+{
+#ifdef NICENAMES
+"ldl rrd,address_src",32,12,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,208},
+
+
+/* 0101 0100 ssN0 dddd address_src *** ldl rrd,address_src(rs) */
+{
+#ifdef NICENAMES
+"ldl rrd,address_src(rs)",32,13,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+4,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,209},
+
+
+/* 0001 0100 0000 dddd imm32 *** ldl rrd,imm32 */
+{
+#ifdef NICENAMES
+"ldl rrd,imm32",32,11,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM32),},
+ {CLASS_BIT+1,CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM32),0,0,0,0,},2,6,210},
+
+
+/* 1001 0100 ssss dddd *** ldl rrd,rrs */
+{
+#ifdef NICENAMES
+"ldl rrd,rrs",32,5,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+4,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,211},
+
+
+/* 0011 0101 ssN0 dddd imm16 *** ldl rrd,rs(imm16) */
+{
+#ifdef NICENAMES
+"ldl rrd,rs(imm16)",32,17,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_BA+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,212},
+
+
+/* 0111 0101 ssN0 dddd 0000 xxxx 0000 0000 *** ldl rrd,rs(rx) */
+{
+#ifdef NICENAMES
+"ldl rrd,rs(rx)",32,17,
+0x00,
+#endif
+"ldl",OPC_ldl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_BX+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,213},
+
+
+/* 0001 1100 ddN0 1001 0000 ssss 0000 nminus1 *** ldm @rd,rs,n */
+{
+#ifdef NICENAMES
+"ldm @rd,rs,n",16,11,
+0x00,
+#endif
+"ldm",OPC_ldm,0,{CLASS_IR+(ARG_RD),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
+ {CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),0,},3,4,214},
+
+
+/* 0101 1100 ddN0 1001 0000 ssss 0000 nminus1 address_dst *** ldm address_dst(rd),rs,n */
+{
+#ifdef NICENAMES
+"ldm address_dst(rd),rs,n",16,15,
+0x00,
+#endif
+"ldm",OPC_ldm,0,{CLASS_X+(ARG_RD),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
+ {CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_DST),},3,6,215},
+
+
+/* 0101 1100 0000 1001 0000 ssss 0000 nminus1 address_dst *** ldm address_dst,rs,n */
+{
+#ifdef NICENAMES
+"ldm address_dst,rs,n",16,14,
+0x00,
+#endif
+"ldm",OPC_ldm,0,{CLASS_DA+(ARG_DST),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
+ {CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_DST),},3,6,216},
+
+
+/* 0001 1100 ssN0 0001 0000 dddd 0000 nminus1 *** ldm rd,@rs,n */
+{
+#ifdef NICENAMES
+"ldm rd,@rs,n",16,11,
+0x00,
+#endif
+"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
+ {CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),0,},3,4,217},
+
+
+/* 0101 1100 ssN0 0001 0000 dddd 0000 nminus1 address_src *** ldm rd,address_src(rs),n */
+{
+#ifdef NICENAMES
+"ldm rd,address_src(rs),n",16,15,
+0x00,
+#endif
+"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
+ {CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_SRC),},3,6,218},
+
+
+/* 0101 1100 0000 0001 0000 dddd 0000 nminus1 address_src *** ldm rd,address_src,n */
+{
+#ifdef NICENAMES
+"ldm rd,address_src,n",16,14,
+0x00,
+#endif
+"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),CLASS_IMM + (ARG_IMMN),},
+ {CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_SRC),},3,6,219},
+
+
+/* 0011 1001 ssN0 0000 *** ldps @rs */
+{
+#ifdef NICENAMES
+"ldps @rs",16,12,
+0x3f,
+#endif
+"ldps",OPC_ldps,0,{CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+9,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,0,0,0,0,0,},1,2,220},
+
+
+/* 0111 1001 0000 0000 address_src *** ldps address_src */
+{
+#ifdef NICENAMES
+"ldps address_src",16,16,
+0x3f,
+#endif
+"ldps",OPC_ldps,0,{CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+7,CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},1,4,221},
+
+
+/* 0111 1001 ssN0 0000 address_src *** ldps address_src(rs) */
+{
+#ifdef NICENAMES
+"ldps address_src(rs)",16,17,
+0x3f,
+#endif
+"ldps",OPC_ldps,0,{CLASS_X+(ARG_RS),},
+ {CLASS_BIT+7,CLASS_BIT+9,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},1,4,222},
+
+
+/* 0011 0011 0000 ssss disp16 *** ldr disp16,rs */
+{
+#ifdef NICENAMES
+"ldr disp16,rs",16,14,
+0x00,
+#endif
+"ldr",OPC_ldr,0,{CLASS_DISP,CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,223},
+
+
+/* 0011 0001 0000 dddd disp16 *** ldr rd,disp16 */
+{
+#ifdef NICENAMES
+"ldr rd,disp16",16,14,
+0x00,
+#endif
+"ldr",OPC_ldr,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DISP,},
+ {CLASS_BIT+3,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,224},
+
+
+/* 0011 0010 0000 ssss disp16 *** ldrb disp16,rbs */
+{
+#ifdef NICENAMES
+"ldrb disp16,rbs",8,14,
+0x00,
+#endif
+"ldrb",OPC_ldrb,0,{CLASS_DISP,CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,225},
+
+
+/* 0011 0000 0000 dddd disp16 *** ldrb rbd,disp16 */
+{
+#ifdef NICENAMES
+"ldrb rbd,disp16",8,14,
+0x00,
+#endif
+"ldrb",OPC_ldrb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DISP,},
+ {CLASS_BIT+3,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,226},
+
+
+/* 0011 0111 0000 ssss disp16 *** ldrl disp16,rrs */
+{
+#ifdef NICENAMES
+"ldrl disp16,rrs",32,17,
+0x00,
+#endif
+"ldrl",OPC_ldrl,0,{CLASS_DISP,CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+7,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,227},
+
+
+/* 0011 0101 0000 dddd disp16 *** ldrl rrd,disp16 */
+{
+#ifdef NICENAMES
+"ldrl rrd,disp16",32,17,
+0x00,
+#endif
+"ldrl",OPC_ldrl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DISP,},
+ {CLASS_BIT+3,CLASS_BIT+5,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_DISP+(ARG_DISP16),0,0,0,0,},2,4,228},
+
+
+/* 0111 1011 0000 1010 *** mbit */
+{
+#ifdef NICENAMES
+"mbit",16,7,
+0x38,
+#endif
+"mbit",OPC_mbit,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_BIT+0xa,0,0,0,0,0,},0,2,229},
+
+
+/* 0111 1011 dddd 1101 *** mreq rd */
+{
+#ifdef NICENAMES
+"mreq rd",16,12,
+0x18,
+#endif
+"mreq",OPC_mreq,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+7,CLASS_BIT+0xb,CLASS_REG+(ARG_RD),CLASS_BIT+0xd,0,0,0,0,0,},1,2,230},
+
+
+/* 0111 1011 0000 1001 *** mres */
+{
+#ifdef NICENAMES
+"mres",16,5,
+0x00,
+#endif
+"mres",OPC_mres,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_BIT+9,0,0,0,0,0,},0,2,231},
+
+
+/* 0111 1011 0000 1000 *** mset */
+{
+#ifdef NICENAMES
+"mset",16,5,
+0x00,
+#endif
+"mset",OPC_mset,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+0xb,CLASS_BIT+0,CLASS_BIT+8,0,0,0,0,0,},0,2,232},
+
+
+/* 0001 1001 ssN0 dddd *** mult rrd,@rs */
+{
+#ifdef NICENAMES
+"mult rrd,@rs",16,70,
+0x3c,
+#endif
+"mult",OPC_mult,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+9,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,233},
+
+
+/* 0101 1001 0000 dddd address_src *** mult rrd,address_src */
+{
+#ifdef NICENAMES
+"mult rrd,address_src",16,70,
+0x3c,
+#endif
+"mult",OPC_mult,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,234},
+
+
+/* 0101 1001 ssN0 dddd address_src *** mult rrd,address_src(rs) */
+{
+#ifdef NICENAMES
+"mult rrd,address_src(rs)",16,70,
+0x3c,
+#endif
+"mult",OPC_mult,0,{CLASS_REG_LONG+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+9,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,235},
+
+
+/* 0001 1001 0000 dddd imm16 *** mult rrd,imm16 */
+{
+#ifdef NICENAMES
+"mult rrd,imm16",16,70,
+0x3c,
+#endif
+"mult",OPC_mult,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+1,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,236},
+
+
+/* 1001 1001 ssss dddd *** mult rrd,rs */
+{
+#ifdef NICENAMES
+"mult rrd,rs",16,70,
+0x3c,
+#endif
+"mult",OPC_mult,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+9,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,237},
+
+
+/* 0001 1000 ssN0 dddd *** multl rqd,@rs */
+{
+#ifdef NICENAMES
+"multl rqd,@rs",32,282,
+0x3c,
+#endif
+"multl",OPC_multl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+8,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,238},
+
+
+/* 0101 1000 0000 dddd address_src *** multl rqd,address_src */
+{
+#ifdef NICENAMES
+"multl rqd,address_src",32,282,
+0x3c,
+#endif
+"multl",OPC_multl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,239},
+
+
+/* 0101 1000 ssN0 dddd address_src *** multl rqd,address_src(rs) */
+{
+#ifdef NICENAMES
+"multl rqd,address_src(rs)",32,282,
+0x3c,
+#endif
+"multl",OPC_multl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+8,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,240},
+
+
+/* 0001 1000 0000 dddd imm32 *** multl rqd,imm32 */
+{
+#ifdef NICENAMES
+"multl rqd,imm32",32,282,
+0x3c,
+#endif
+"multl",OPC_multl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_IMM+(ARG_IMM32),},
+ {CLASS_BIT+1,CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM32),0,0,0,0,},2,6,241},
+
+
+/* 1001 1000 ssss dddd *** multl rqd,rrs */
+{
+#ifdef NICENAMES
+"multl rqd,rrs",32,282,
+0x3c,
+#endif
+"multl",OPC_multl,0,{CLASS_REG_QUAD+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+8,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,242},
+
+
+/* 0000 1101 ddN0 0010 *** neg @rd */
+{
+#ifdef NICENAMES
+"neg @rd",16,12,
+0x3c,
+#endif
+"neg",OPC_neg,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+2,0,0,0,0,0,},1,2,243},
+
+
+/* 0100 1101 0000 0010 address_dst *** neg address_dst */
+{
+#ifdef NICENAMES
+"neg address_dst",16,15,
+0x3c,
+#endif
+"neg",OPC_neg,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+2,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,244},
+
+
+/* 0100 1101 ddN0 0010 address_dst *** neg address_dst(rd) */
+{
+#ifdef NICENAMES
+"neg address_dst(rd)",16,16,
+0x3c,
+#endif
+"neg",OPC_neg,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+2,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,245},
+
+
+/* 1000 1101 dddd 0010 *** neg rd */
+{
+#ifdef NICENAMES
+"neg rd",16,7,
+0x3c,
+#endif
+"neg",OPC_neg,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_BIT+2,0,0,0,0,0,},1,2,246},
+
+
+/* 0000 1100 ddN0 0010 *** negb @rd */
+{
+#ifdef NICENAMES
+"negb @rd",8,12,
+0x3c,
+#endif
+"negb",OPC_negb,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+2,0,0,0,0,0,},1,2,247},
+
+
+/* 0100 1100 0000 0010 address_dst *** negb address_dst */
+{
+#ifdef NICENAMES
+"negb address_dst",8,15,
+0x3c,
+#endif
+"negb",OPC_negb,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+2,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,248},
+
+
+/* 0100 1100 ddN0 0010 address_dst *** negb address_dst(rd) */
+{
+#ifdef NICENAMES
+"negb address_dst(rd)",8,16,
+0x3c,
+#endif
+"negb",OPC_negb,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+2,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,249},
+
+
+/* 1000 1100 dddd 0010 *** negb rbd */
+{
+#ifdef NICENAMES
+"negb rbd",8,7,
+0x3c,
+#endif
+"negb",OPC_negb,0,{CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_BIT+2,0,0,0,0,0,},1,2,250},
+
+
+/* 1000 1101 0000 0111 *** nop */
+{
+#ifdef NICENAMES
+"nop",16,7,
+0x00,
+#endif
+"nop",OPC_nop,0,{0},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+7,0,0,0,0,0,},0,2,251},
+
+
+/* 0000 0101 ssN0 dddd *** or rd,@rs */
+{
+#ifdef NICENAMES
+"or rd,@rs",16,7,
+0x38,
+#endif
+"or",OPC_or,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,252},
+
+
+/* 0100 0101 0000 dddd address_src *** or rd,address_src */
+{
+#ifdef NICENAMES
+"or rd,address_src",16,9,
+0x38,
+#endif
+"or",OPC_or,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+5,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,253},
+
+
+/* 0100 0101 ssN0 dddd address_src *** or rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"or rd,address_src(rs)",16,10,
+0x38,
+#endif
+"or",OPC_or,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,254},
+
+
+/* 0000 0101 0000 dddd imm16 *** or rd,imm16 */
+{
+#ifdef NICENAMES
+"or rd,imm16",16,7,
+0x38,
+#endif
+"or",OPC_or,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+5,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,255},
+
+
+/* 1000 0101 ssss dddd *** or rd,rs */
+{
+#ifdef NICENAMES
+"or rd,rs",16,4,
+0x38,
+#endif
+"or",OPC_or,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+5,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,256},
+
+
+/* 0000 0100 ssN0 dddd *** orb rbd,@rs */
+{
+#ifdef NICENAMES
+"orb rbd,@rs",8,7,
+0x3c,
+#endif
+"orb",OPC_orb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+4,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,257},
+
+
+/* 0100 0100 0000 dddd address_src *** orb rbd,address_src */
+{
+#ifdef NICENAMES
+"orb rbd,address_src",8,9,
+0x3c,
+#endif
+"orb",OPC_orb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,258},
+
+
+/* 0100 0100 ssN0 dddd address_src *** orb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"orb rbd,address_src(rs)",8,10,
+0x3c,
+#endif
+"orb",OPC_orb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+4,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,259},
+
+
+/* 0000 0100 0000 dddd imm8 imm8 *** orb rbd,imm8 */
+{
+#ifdef NICENAMES
+"orb rbd,imm8",8,7,
+0x3c,
+#endif
+"orb",OPC_orb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,260},
+
+
+/* 1000 0100 ssss dddd *** orb rbd,rbs */
+{
+#ifdef NICENAMES
+"orb rbd,rbs",8,4,
+0x3c,
+#endif
+"orb",OPC_orb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+4,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,261},
+
+
+/* 0011 1111 ddN0 ssss *** out @rd,rs */
+{
+#ifdef NICENAMES
+"out @rd,rs",16,0,
+0x04,
+#endif
+"out",OPC_out,0,{CLASS_IR+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xf,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,262},
+
+
+/* 0011 1011 ssss 0110 imm16 *** out imm16,rs */
+{
+#ifdef NICENAMES
+"out imm16,rs",16,0,
+0x04,
+#endif
+"out",OPC_out,0,{CLASS_IMM+(ARG_IMM16),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REG+(ARG_RS),CLASS_BIT+6,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,263},
+
+
+/* 0011 1110 ddN0 ssss *** outb @rd,rbs */
+{
+#ifdef NICENAMES
+"outb @rd,rbs",8,0,
+0x04,
+#endif
+"outb",OPC_outb,0,{CLASS_IR+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xe,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,264},
+
+
+/* 0011 1010 ssss 0110 imm16 *** outb imm16,rbs */
+{
+#ifdef NICENAMES
+"outb imm16,rbs",8,0,
+0x04,
+#endif
+"outb",OPC_outb,0,{CLASS_IMM+(ARG_IMM16),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REG+(ARG_RS),CLASS_BIT+6,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,265},
+
+
+/* 0011 1011 ssN0 1010 0000 aaaa ddN0 1000 *** outd @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"outd @rd,@rs,ra",16,0,
+0x04,
+#endif
+"outd",OPC_outd,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,266},
+
+
+/* 0011 1010 ssN0 1010 0000 aaaa ddN0 1000 *** outdb @rd,@rs,rba */
+{
+#ifdef NICENAMES
+"outdb @rd,@rs,rba",16,0,
+0x04,
+#endif
+"outdb",OPC_outdb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,267},
+
+
+/* 0011 1011 ssN0 0010 0000 aaaa ddN0 1000 *** outi @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"outi @rd,@rs,ra",16,0,
+0x04,
+#endif
+"outi",OPC_outi,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,268},
+
+
+/* 0011 1010 ssN0 0010 0000 aaaa ddN0 1000 *** outib @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"outib @rd,@rs,ra",16,0,
+0x04,
+#endif
+"outib",OPC_outib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,269},
+
+
+/* 0011 1010 ssN0 0010 0000 aaaa ddN0 0000 *** outibr @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"outibr @rd,@rs,ra",16,0,
+0x04,
+#endif
+"outibr",OPC_outibr,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,270},
+
+
+/* 0001 0111 ssN0 ddN0 *** pop @rd,@rs */
+{
+#ifdef NICENAMES
+"pop @rd,@rs",16,12,
+0x00,
+#endif
+"pop",OPC_pop,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+7,CLASS_REGN0+(ARG_RS),CLASS_REGN0+(ARG_RD),0,0,0,0,0,},2,2,271},
+
+
+/* 0101 0111 ssN0 ddN0 address_dst *** pop address_dst(rd),@rs */
+{
+#ifdef NICENAMES
+"pop address_dst(rd),@rs",16,16,
+0x00,
+#endif
+"pop",OPC_pop,0,{CLASS_X+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+7,CLASS_REGN0+(ARG_RS),CLASS_REGN0+(ARG_RD),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,272},
+
+
+/* 0101 0111 ssN0 0000 address_dst *** pop address_dst,@rs */
+{
+#ifdef NICENAMES
+"pop address_dst,@rs",16,16,
+0x00,
+#endif
+"pop",OPC_pop,0,{CLASS_DA+(ARG_DST),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+7,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,273},
+
+
+/* 1001 0111 ssN0 dddd *** pop rd,@rs */
+{
+#ifdef NICENAMES
+"pop rd,@rs",16,8,
+0x00,
+#endif
+"pop",OPC_pop,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+7,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,274},
+
+
+/* 0001 0101 ssN0 ddN0 *** popl @rd,@rs */
+{
+#ifdef NICENAMES
+"popl @rd,@rs",32,19,
+0x00,
+#endif
+"popl",OPC_popl,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REGN0+(ARG_RD),0,0,0,0,0,},2,2,275},
+
+
+/* 0101 0101 ssN0 ddN0 address_dst *** popl address_dst(rd),@rs */
+{
+#ifdef NICENAMES
+"popl address_dst(rd),@rs",32,23,
+0x00,
+#endif
+"popl",OPC_popl,0,{CLASS_X+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REGN0+(ARG_RD),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,276},
+
+
+/* 0101 0101 ssN0 0000 address_dst *** popl address_dst,@rs */
+{
+#ifdef NICENAMES
+"popl address_dst,@rs",32,23,
+0x00,
+#endif
+"popl",OPC_popl,0,{CLASS_DA+(ARG_DST),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_BIT+0,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,277},
+
+
+/* 1001 0101 ssN0 dddd *** popl rrd,@rs */
+{
+#ifdef NICENAMES
+"popl rrd,@rs",32,12,
+0x00,
+#endif
+"popl",OPC_popl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,278},
+
+
+/* 0001 0011 ddN0 ssN0 *** push @rd,@rs */
+{
+#ifdef NICENAMES
+"push @rd,@rs",16,13,
+0x00,
+#endif
+"push",OPC_push,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_REGN0+(ARG_RS),0,0,0,0,0,},2,2,279},
+
+
+/* 0101 0011 ddN0 0000 address_src *** push @rd,address_src */
+{
+#ifdef NICENAMES
+"push @rd,address_src",16,14,
+0x00,
+#endif
+"push",OPC_push,0,{CLASS_IR+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,280},
+
+
+/* 0101 0011 ddN0 ssN0 address_src *** push @rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"push @rd,address_src(rs)",16,14,
+0x00,
+#endif
+"push",OPC_push,0,{CLASS_IR+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_REGN0+(ARG_RS),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,281},
+
+
+/* 0000 1101 ddN0 1001 imm16 *** push @rd,imm16 */
+{
+#ifdef NICENAMES
+"push @rd,imm16",16,12,
+0x00,
+#endif
+"push",OPC_push,0,{CLASS_IR+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,282},
+
+
+/* 1001 0011 ddN0 ssss *** push @rd,rs */
+{
+#ifdef NICENAMES
+"push @rd,rs",16,9,
+0x00,
+#endif
+"push",OPC_push,0,{CLASS_IR+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,283},
+
+
+/* 0001 0001 ddN0 ssN0 *** pushl @rd,@rs */
+{
+#ifdef NICENAMES
+"pushl @rd,@rs",32,20,
+0x00,
+#endif
+"pushl",OPC_pushl,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+1,CLASS_REGN0+(ARG_RD),CLASS_REGN0+(ARG_RS),0,0,0,0,0,},2,2,284},
+
+
+/* 0101 0001 ddN0 0000 address_src *** pushl @rd,address_src */
+{
+#ifdef NICENAMES
+"pushl @rd,address_src",32,21,
+0x00,
+#endif
+"pushl",OPC_pushl,0,{CLASS_IR+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+1,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,285},
+
+
+/* 0101 0001 ddN0 ssN0 address_src *** pushl @rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"pushl @rd,address_src(rs)",32,21,
+0x00,
+#endif
+"pushl",OPC_pushl,0,{CLASS_IR+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+1,CLASS_REGN0+(ARG_RD),CLASS_REGN0+(ARG_RS),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,286},
+
+
+/* 1001 0001 ddN0 ssss *** pushl @rd,rrs */
+{
+#ifdef NICENAMES
+"pushl @rd,rrs",32,12,
+0x00,
+#endif
+"pushl",OPC_pushl,0,{CLASS_IR+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+1,CLASS_REGN0+(ARG_RD),CLASS_REG+(ARG_RS),0,0,0,0,0,},2,2,287},
+
+
+/* 0010 0011 ddN0 imm4 *** res @rd,imm4 */
+{
+#ifdef NICENAMES
+"res @rd,imm4",16,11,
+0x00,
+#endif
+"res",OPC_res,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+2,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,288},
+
+
+/* 0110 0011 ddN0 imm4 address_dst *** res address_dst(rd),imm4 */
+{
+#ifdef NICENAMES
+"res address_dst(rd),imm4",16,14,
+0x00,
+#endif
+"res",OPC_res,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+3,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,289},
+
+
+/* 0110 0011 0000 imm4 address_dst *** res address_dst,imm4 */
+{
+#ifdef NICENAMES
+"res address_dst,imm4",16,13,
+0x00,
+#endif
+"res",OPC_res,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+3,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,290},
+
+
+/* 1010 0011 dddd imm4 *** res rd,imm4 */
+{
+#ifdef NICENAMES
+"res rd,imm4",16,4,
+0x00,
+#endif
+"res",OPC_res,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xa,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,291},
+
+
+/* 0010 0011 0000 ssss 0000 dddd 0000 0000 *** res rd,rs */
+{
+#ifdef NICENAMES
+"res rd,rs",16,10,
+0x00,
+#endif
+"res",OPC_res,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,292},
+
+
+/* 0010 0010 ddN0 imm4 *** resb @rd,imm4 */
+{
+#ifdef NICENAMES
+"resb @rd,imm4",8,11,
+0x00,
+#endif
+"resb",OPC_resb,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+2,CLASS_BIT+2,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,293},
+
+
+/* 0110 0010 ddN0 imm4 address_dst *** resb address_dst(rd),imm4 */
+{
+#ifdef NICENAMES
+"resb address_dst(rd),imm4",8,14,
+0x00,
+#endif
+"resb",OPC_resb,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+2,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,294},
+
+
+/* 0110 0010 0000 imm4 address_dst *** resb address_dst,imm4 */
+{
+#ifdef NICENAMES
+"resb address_dst,imm4",8,13,
+0x00,
+#endif
+"resb",OPC_resb,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+2,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,295},
+
+
+/* 1010 0010 dddd imm4 *** resb rbd,imm4 */
+{
+#ifdef NICENAMES
+"resb rbd,imm4",8,4,
+0x00,
+#endif
+"resb",OPC_resb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xa,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,296},
+
+
+/* 0010 0010 0000 ssss 0000 dddd 0000 0000 *** resb rbd,rs */
+{
+#ifdef NICENAMES
+"resb rbd,rs",8,10,
+0x00,
+#endif
+"resb",OPC_resb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,297},
+
+
+/* 1000 1101 flags 0011 *** resflg flags */
+{
+#ifdef NICENAMES
+"resflg flags",16,7,
+0x3c,
+#endif
+"resflg",OPC_resflg,0,{CLASS_FLAGS,},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_FLAGS,CLASS_BIT+3,0,0,0,0,0,},1,2,298},
+
+
+/* 1001 1110 0000 cccc *** ret cc */
+{
+#ifdef NICENAMES
+"ret cc",16,10,
+0x00,
+#endif
+"ret",OPC_ret,0,{CLASS_CC,},
+ {CLASS_BIT+9,CLASS_BIT+0xe,CLASS_BIT+0,CLASS_CC,0,0,0,0,0,},1,2,299},
+
+
+/* 1011 0011 dddd 00I0 *** rl rd,imm1or2 */
+{
+#ifdef NICENAMES
+"rl rd,imm1or2",16,6,
+0x3c,
+#endif
+"rl",OPC_rl,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+0,0,0,0,0,0,},2,2,300},
+
+
+/* 1011 0010 dddd 00I0 *** rlb rbd,imm1or2 */
+{
+#ifdef NICENAMES
+"rlb rbd,imm1or2",8,6,
+0x3c,
+#endif
+"rlb",OPC_rlb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+0,0,0,0,0,0,},2,2,301},
+
+
+/* 1011 0011 dddd 10I0 *** rlc rd,imm1or2 */
+{
+#ifdef NICENAMES
+"rlc rd,imm1or2",16,6,
+0x3c,
+#endif
+"rlc",OPC_rlc,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+8,0,0,0,0,0,},2,2,302},
+
+
+/* 1011 0010 dddd 10I0 *** rlcb rbd,imm1or2 */
+{
+#ifdef NICENAMES
+"rlcb rbd,imm1or2",8,9,
+0x10,
+#endif
+"rlcb",OPC_rlcb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+8,0,0,0,0,0,},2,2,303},
+
+
+/* 1011 1110 aaaa bbbb *** rldb rbb,rba */
+{
+#ifdef NICENAMES
+"rldb rbb,rba",8,9,
+0x10,
+#endif
+"rldb",OPC_rldb,0,{CLASS_REG_BYTE+(ARG_RB),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xe,CLASS_REG+(ARG_RA),CLASS_REG+(ARG_RB),0,0,0,0,0,},2,2,304},
+
+
+/* 1011 0011 dddd 01I0 *** rr rd,imm1or2 */
+{
+#ifdef NICENAMES
+"rr rd,imm1or2",16,6,
+0x3c,
+#endif
+"rr",OPC_rr,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+4,0,0,0,0,0,},2,2,305},
+
+
+/* 1011 0010 dddd 01I0 *** rrb rbd,imm1or2 */
+{
+#ifdef NICENAMES
+"rrb rbd,imm1or2",8,6,
+0x3c,
+#endif
+"rrb",OPC_rrb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+4,0,0,0,0,0,},2,2,306},
+
+
+/* 1011 0011 dddd 11I0 *** rrc rd,imm1or2 */
+{
+#ifdef NICENAMES
+"rrc rd,imm1or2",16,6,
+0x3c,
+#endif
+"rrc",OPC_rrc,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+0xc,0,0,0,0,0,},2,2,307},
+
+
+/* 1011 0010 dddd 11I0 *** rrcb rbd,imm1or2 */
+{
+#ifdef NICENAMES
+"rrcb rbd,imm1or2",8,9,
+0x10,
+#endif
+"rrcb",OPC_rrcb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM1OR2),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT_1OR2+0xc,0,0,0,0,0,},2,2,308},
+
+
+/* 1011 1100 aaaa bbbb *** rrdb rbb,rba */
+{
+#ifdef NICENAMES
+"rrdb rbb,rba",8,9,
+0x10,
+#endif
+"rrdb",OPC_rrdb,0,{CLASS_REG_BYTE+(ARG_RB),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+0xb,CLASS_BIT+0xc,CLASS_REG+(ARG_RA),CLASS_REG+(ARG_RB),0,0,0,0,0,},2,2,309},
+
+
+/* 0011 0110 imm8 *** rsvd36 */
+{
+#ifdef NICENAMES
+"rsvd36",8,10,
+0x00,
+#endif
+"rsvd36",OPC_rsvd36,0,{0},
+ {CLASS_BIT+3,CLASS_BIT+6,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,310},
+
+
+/* 0011 1000 imm8 *** rsvd38 */
+{
+#ifdef NICENAMES
+"rsvd38",8,10,
+0x00,
+#endif
+"rsvd38",OPC_rsvd38,0,{0},
+ {CLASS_BIT+3,CLASS_BIT+8,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,311},
+
+
+/* 0111 1000 imm8 *** rsvd78 */
+{
+#ifdef NICENAMES
+"rsvd78",8,10,
+0x00,
+#endif
+"rsvd78",OPC_rsvd78,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+8,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,312},
+
+
+/* 0111 1110 imm8 *** rsvd7e */
+{
+#ifdef NICENAMES
+"rsvd7e",8,10,
+0x00,
+#endif
+"rsvd7e",OPC_rsvd7e,0,{0},
+ {CLASS_BIT+7,CLASS_BIT+0xe,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,313},
+
+
+/* 1001 1101 imm8 *** rsvd9d */
+{
+#ifdef NICENAMES
+"rsvd9d",8,10,
+0x00,
+#endif
+"rsvd9d",OPC_rsvd9d,0,{0},
+ {CLASS_BIT+9,CLASS_BIT+0xd,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,314},
+
+
+/* 1001 1111 imm8 *** rsvd9f */
+{
+#ifdef NICENAMES
+"rsvd9f",8,10,
+0x00,
+#endif
+"rsvd9f",OPC_rsvd9f,0,{0},
+ {CLASS_BIT+9,CLASS_BIT+0xf,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,315},
+
+
+/* 1011 1001 imm8 *** rsvdb9 */
+{
+#ifdef NICENAMES
+"rsvdb9",8,10,
+0x00,
+#endif
+"rsvdb9",OPC_rsvdb9,0,{0},
+ {CLASS_BIT+0xb,CLASS_BIT+9,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,316},
+
+
+/* 1011 1111 imm8 *** rsvdbf */
+{
+#ifdef NICENAMES
+"rsvdbf",8,10,
+0x00,
+#endif
+"rsvdbf",OPC_rsvdbf,0,{0},
+ {CLASS_BIT+0xb,CLASS_BIT+0xf,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},0,2,317},
+
+
+/* 1011 0111 ssss dddd *** sbc rd,rs */
+{
+#ifdef NICENAMES
+"sbc rd,rs",16,5,
+0x3c,
+#endif
+"sbc",OPC_sbc,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+7,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,318},
+
+
+/* 1011 0110 ssss dddd *** sbcb rbd,rbs */
+{
+#ifdef NICENAMES
+"sbcb rbd,rbs",8,5,
+0x3f,
+#endif
+"sbcb",OPC_sbcb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+6,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,319},
+
+
+/* 0111 1111 imm8 *** sc imm8 */
+{
+#ifdef NICENAMES
+"sc imm8",8,33,
+0x3f,
+#endif
+"sc",OPC_sc,0,{CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+7,CLASS_BIT+0xf,CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},1,2,320},
+
+
+/* 1011 0011 dddd 1011 0000 ssss 0000 0000 *** sda rd,rs */
+{
+#ifdef NICENAMES
+"sda rd,rs",16,15,
+0x3c,
+#endif
+"sda",OPC_sda,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,321},
+
+
+/* 1011 0010 dddd 1011 0000 ssss 0000 0000 *** sdab rbd,rs */
+{
+#ifdef NICENAMES
+"sdab rbd,rs",8,15,
+0x3c,
+#endif
+"sdab",OPC_sdab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,322},
+
+
+/* 1011 0011 dddd 1111 0000 ssss 0000 0000 *** sdal rrd,rs */
+{
+#ifdef NICENAMES
+"sdal rrd,rs",32,15,
+0x3c,
+#endif
+"sdal",OPC_sdal,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+0xf,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,323},
+
+
+/* 1011 0011 dddd 0011 0000 ssss 0000 0000 *** sdl rd,rs */
+{
+#ifdef NICENAMES
+"sdl rd,rs",16,15,
+0x38,
+#endif
+"sdl",OPC_sdl,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,324},
+
+
+/* 1011 0010 dddd 0011 0000 ssss 0000 0000 *** sdlb rbd,rs */
+{
+#ifdef NICENAMES
+"sdlb rbd,rs",8,15,
+0x38,
+#endif
+"sdlb",OPC_sdlb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,325},
+
+
+/* 1011 0011 dddd 0111 0000 ssss 0000 0000 *** sdll rrd,rs */
+{
+#ifdef NICENAMES
+"sdll rrd,rs",32,15,
+0x38,
+#endif
+"sdll",OPC_sdll,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+7,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,326},
+
+
+/* 0010 0101 ddN0 imm4 *** set @rd,imm4 */
+{
+#ifdef NICENAMES
+"set @rd,imm4",16,11,
+0x00,
+#endif
+"set",OPC_set,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+2,CLASS_BIT+5,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,327},
+
+
+/* 0110 0101 ddN0 imm4 address_dst *** set address_dst(rd),imm4 */
+{
+#ifdef NICENAMES
+"set address_dst(rd),imm4",16,14,
+0x00,
+#endif
+"set",OPC_set,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+5,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,328},
+
+
+/* 0110 0101 0000 imm4 address_dst *** set address_dst,imm4 */
+{
+#ifdef NICENAMES
+"set address_dst,imm4",16,13,
+0x00,
+#endif
+"set",OPC_set,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+5,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,329},
+
+
+/* 1010 0101 dddd imm4 *** set rd,imm4 */
+{
+#ifdef NICENAMES
+"set rd,imm4",16,4,
+0x00,
+#endif
+"set",OPC_set,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xa,CLASS_BIT+5,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,330},
+
+
+/* 0010 0101 0000 ssss 0000 dddd 0000 0000 *** set rd,rs */
+{
+#ifdef NICENAMES
+"set rd,rs",16,10,
+0x00,
+#endif
+"set",OPC_set,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+5,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,331},
+
+
+/* 0010 0100 ddN0 imm4 *** setb @rd,imm4 */
+{
+#ifdef NICENAMES
+"setb @rd,imm4",8,11,
+0x00,
+#endif
+"setb",OPC_setb,0,{CLASS_IR+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+2,CLASS_BIT+4,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,332},
+
+
+/* 0110 0100 ddN0 imm4 address_dst *** setb address_dst(rd),imm4 */
+{
+#ifdef NICENAMES
+"setb address_dst(rd),imm4",8,14,
+0x00,
+#endif
+"setb",OPC_setb,0,{CLASS_X+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+4,CLASS_REGN0+(ARG_RD),CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,333},
+
+
+/* 0110 0100 0000 imm4 address_dst *** setb address_dst,imm4 */
+{
+#ifdef NICENAMES
+"setb address_dst,imm4",8,13,
+0x00,
+#endif
+"setb",OPC_setb,0,{CLASS_DA+(ARG_DST),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+6,CLASS_BIT+4,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),CLASS_ADDRESS+(ARG_DST),0,0,0,0,},2,4,334},
+
+
+/* 1010 0100 dddd imm4 *** setb rbd,imm4 */
+{
+#ifdef NICENAMES
+"setb rbd,imm4",8,4,
+0x00,
+#endif
+"setb",OPC_setb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+ {CLASS_BIT+0xa,CLASS_BIT+4,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM4),0,0,0,0,0,},2,2,335},
+
+
+/* 0010 0100 0000 ssss 0000 dddd 0000 0000 *** setb rbd,rs */
+{
+#ifdef NICENAMES
+"setb rbd,rs",8,10,
+0x00,
+#endif
+"setb",OPC_setb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+2,CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,336},
+
+
+/* 1000 1101 flags 0001 *** setflg flags */
+{
+#ifdef NICENAMES
+"setflg flags",16,7,
+0x3c,
+#endif
+"setflg",OPC_setflg,0,{CLASS_FLAGS,},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_FLAGS,CLASS_BIT+1,0,0,0,0,0,},1,2,337},
+
+
+/* 0011 1010 dddd 0101 imm16 *** sinb rbd,imm16 */
+{
+#ifdef NICENAMES
+"sinb rbd,imm16",8,0,
+0x00,
+#endif
+"sinb",OPC_sinb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REG+(ARG_RD),CLASS_BIT+5,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,338},
+
+
+/* 0011 1011 dddd 0101 imm16 *** sinb rd,imm16 */
+{
+#ifdef NICENAMES
+"sinb rd,imm16",8,0,
+0x00,
+#endif
+"sinb",OPC_sinb,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REG+(ARG_RD),CLASS_BIT+5,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,339},
+
+
+/* 0011 1011 ssN0 1000 0001 aaaa ddN0 1000 *** sind @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"sind @rd,@rs,ra",16,0,
+0x00,
+#endif
+"sind",OPC_sind,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+8,CLASS_BIT+1,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,340},
+
+
+/* 0011 1010 ssN0 1000 0001 aaaa ddN0 1000 *** sindb @rd,@rs,rba */
+{
+#ifdef NICENAMES
+"sindb @rd,@rs,rba",8,0,
+0x00,
+#endif
+"sindb",OPC_sindb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+8,CLASS_BIT+1,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,341},
+
+
+/* 0011 1010 ssN0 0001 0000 aaaa ddN0 1000 *** sinib @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"sinib @rd,@rs,ra",8,0,
+0x00,
+#endif
+"sinib",OPC_sinib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,342},
+
+
+/* 0011 1010 ssN0 0001 0000 aaaa ddN0 0000 *** sinibr @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"sinibr @rd,@rs,ra",16,0,
+0x00,
+#endif
+"sinibr",OPC_sinibr,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,343},
+
+
+/* 1011 0011 dddd 1001 0000 0000 imm8 *** sla rd,imm8 */
+{
+#ifdef NICENAMES
+"sla rd,imm8",16,13,
+0x3c,
+#endif
+"sla",OPC_sla,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,344},
+
+
+/* 1011 0010 dddd 1001 0000 0000 imm8 *** slab rbd,imm8 */
+{
+#ifdef NICENAMES
+"slab rbd,imm8",8,13,
+0x3c,
+#endif
+"slab",OPC_slab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,345},
+
+
+/* 1011 0011 dddd 1101 0000 0000 imm8 *** slal rrd,imm8 */
+{
+#ifdef NICENAMES
+"slal rrd,imm8",32,13,
+0x3c,
+#endif
+"slal",OPC_slal,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,346},
+
+
+/* 1011 0011 dddd 0001 0000 0000 imm8 *** sll rd,imm8 */
+{
+#ifdef NICENAMES
+"sll rd,imm8",16,13,
+0x38,
+#endif
+"sll",OPC_sll,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,347},
+
+
+/* 1011 0010 dddd 0001 0000 0000 imm8 *** sllb rbd,imm8 */
+{
+#ifdef NICENAMES
+"sllb rbd,imm8",8,13,
+0x38,
+#endif
+"sllb",OPC_sllb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,348},
+
+
+/* 1011 0011 dddd 0101 0000 0000 imm8 *** slll rrd,imm8 */
+{
+#ifdef NICENAMES
+"slll rrd,imm8",32,13,
+0x38,
+#endif
+"slll",OPC_slll,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+5,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,349},
+
+
+/* 0011 1011 ssss 0111 imm16 *** sout imm16,rs */
+{
+#ifdef NICENAMES
+"sout imm16,rs",16,0,
+0x00,
+#endif
+"sout",OPC_sout,0,{CLASS_IMM+(ARG_IMM16),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REG+(ARG_RS),CLASS_BIT+7,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,350},
+
+
+/* 0011 1010 ssss 0111 imm16 *** soutb imm16,rbs */
+{
+#ifdef NICENAMES
+"soutb imm16,rbs",8,0,
+0x00,
+#endif
+"soutb",OPC_soutb,0,{CLASS_IMM+(ARG_IMM16),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REG+(ARG_RS),CLASS_BIT+7,CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,351},
+
+
+/* 0011 1011 ssN0 1011 0000 aaaa ddN0 1000 *** soutd @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"soutd @rd,@rs,ra",16,0,
+0x00,
+#endif
+"soutd",OPC_soutd,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xb,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,352},
+
+
+/* 0011 1010 ssN0 1011 0000 aaaa ddN0 1000 *** soutdb @rd,@rs,rba */
+{
+#ifdef NICENAMES
+"soutdb @rd,@rs,rba",8,0,
+0x00,
+#endif
+"soutdb",OPC_soutdb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+0xb,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,353},
+
+
+/* 0011 1010 ssN0 0011 0000 aaaa ddN0 1000 *** soutib @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"soutib @rd,@rs,ra",8,0,
+0x00,
+#endif
+"soutib",OPC_soutib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,},3,4,354},
+
+
+/* 0011 1010 ssN0 0011 0000 aaaa ddN0 0000 *** soutibr @rd,@rs,ra */
+{
+#ifdef NICENAMES
+"soutibr @rd,@rs,ra",16,0,
+0x00,
+#endif
+"soutibr",OPC_soutibr,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_WORD+(ARG_RA),},
+ {CLASS_BIT+3,CLASS_BIT+0xa,CLASS_REGN0+(ARG_RS),CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RD),CLASS_BIT+0,0,},3,4,355},
+
+
+/* 1011 0011 dddd 1001 1111 1111 nim8 *** sra rd,imm8 */
+{
+#ifdef NICENAMES
+"sra rd,imm8",16,13,
+0x3c,
+#endif
+"sra",OPC_sra,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0xf,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM8),0,0,},2,4,356},
+
+
+/* 1011 0010 dddd 1001 0000 0000 nim8 *** srab rbd,imm8 */
+{
+#ifdef NICENAMES
+"srab rbd,imm8",8,13,
+0x3c,
+#endif
+"srab",OPC_srab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_NIM8),0,0,},2,4,357},
+
+
+/* 1011 0011 dddd 1101 1111 1111 nim8 *** sral rrd,imm8 */
+{
+#ifdef NICENAMES
+"sral rrd,imm8",32,13,
+0x3c,
+#endif
+"sral",OPC_sral,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+0xd,CLASS_BIT+0xf,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM8),0,0,},2,4,358},
+
+
+/* 1011 0011 dddd 0001 1111 1111 nim8 *** srl rd,imm8 */
+{
+#ifdef NICENAMES
+"srl rd,imm8",16,13,
+0x3c,
+#endif
+"srl",OPC_srl,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0xf,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM8),0,0,},2,4,359},
+
+
+/* 1011 0010 dddd 0001 0000 0000 nim8 *** srlb rbd,imm8 */
+{
+#ifdef NICENAMES
+"srlb rbd,imm8",8,13,
+0x3c,
+#endif
+"srlb",OPC_srlb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_NIM8),0,0,},2,4,360},
+
+
+/* 1011 0011 dddd 0101 1111 1111 nim8 *** srll rrd,imm8 */
+{
+#ifdef NICENAMES
+"srll rrd,imm8",32,13,
+0x3c,
+#endif
+"srll",OPC_srll,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+5,CLASS_BIT+0xf,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM8),0,0,},2,4,361},
+
+
+/* 0000 0011 ssN0 dddd *** sub rd,@rs */
+{
+#ifdef NICENAMES
+"sub rd,@rs",16,7,
+0x3c,
+#endif
+"sub",OPC_sub,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+3,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,362},
+
+
+/* 0100 0011 0000 dddd address_src *** sub rd,address_src */
+{
+#ifdef NICENAMES
+"sub rd,address_src",16,9,
+0x3c,
+#endif
+"sub",OPC_sub,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,363},
+
+
+/* 0100 0011 ssN0 dddd address_src *** sub rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"sub rd,address_src(rs)",16,10,
+0x3c,
+#endif
+"sub",OPC_sub,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+3,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,364},
+
+
+/* 0000 0011 0000 dddd imm16 *** sub rd,imm16 */
+{
+#ifdef NICENAMES
+"sub rd,imm16",16,7,
+0x3c,
+#endif
+"sub",OPC_sub,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+3,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,365},
+
+
+/* 1000 0011 ssss dddd *** sub rd,rs */
+{
+#ifdef NICENAMES
+"sub rd,rs",16,4,
+0x3c,
+#endif
+"sub",OPC_sub,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+3,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,366},
+
+
+/* 0000 0010 ssN0 dddd *** subb rbd,@rs */
+{
+#ifdef NICENAMES
+"subb rbd,@rs",8,7,
+0x3f,
+#endif
+"subb",OPC_subb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+2,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,367},
+
+
+/* 0100 0010 0000 dddd address_src *** subb rbd,address_src */
+{
+#ifdef NICENAMES
+"subb rbd,address_src",8,9,
+0x3f,
+#endif
+"subb",OPC_subb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,368},
+
+
+/* 0100 0010 ssN0 dddd address_src *** subb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"subb rbd,address_src(rs)",8,10,
+0x3f,
+#endif
+"subb",OPC_subb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+2,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,369},
+
+
+/* 0000 0010 0000 dddd imm8 imm8 *** subb rbd,imm8 */
+{
+#ifdef NICENAMES
+"subb rbd,imm8",8,7,
+0x3f,
+#endif
+"subb",OPC_subb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,370},
+
+
+/* 1000 0010 ssss dddd *** subb rbd,rbs */
+{
+#ifdef NICENAMES
+"subb rbd,rbs",8,4,
+0x3f,
+#endif
+"subb",OPC_subb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+2,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,371},
+
+
+/* 0001 0010 ssN0 dddd *** subl rrd,@rs */
+{
+#ifdef NICENAMES
+"subl rrd,@rs",32,14,
+0x3c,
+#endif
+"subl",OPC_subl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+1,CLASS_BIT+2,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,372},
+
+
+/* 0101 0010 0000 dddd address_src *** subl rrd,address_src */
+{
+#ifdef NICENAMES
+"subl rrd,address_src",32,15,
+0x3c,
+#endif
+"subl",OPC_subl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+5,CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,373},
+
+
+/* 0101 0010 ssN0 dddd address_src *** subl rrd,address_src(rs) */
+{
+#ifdef NICENAMES
+"subl rrd,address_src(rs)",32,16,
+0x3c,
+#endif
+"subl",OPC_subl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+5,CLASS_BIT+2,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,374},
+
+
+/* 0001 0010 0000 dddd imm32 *** subl rrd,imm32 */
+{
+#ifdef NICENAMES
+"subl rrd,imm32",32,14,
+0x3c,
+#endif
+"subl",OPC_subl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_IMM+(ARG_IMM32),},
+ {CLASS_BIT+1,CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM32),0,0,0,0,},2,6,375},
+
+
+/* 1001 0010 ssss dddd *** subl rrd,rrs */
+{
+#ifdef NICENAMES
+"subl rrd,rrs",32,8,
+0x3c,
+#endif
+"subl",OPC_subl,0,{CLASS_REG_LONG+(ARG_RD),CLASS_REG_LONG+(ARG_RS),},
+ {CLASS_BIT+9,CLASS_BIT+2,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,376},
+
+
+/* 1010 1111 dddd cccc *** tcc cc,rd */
+{
+#ifdef NICENAMES
+"tcc cc,rd",16,5,
+0x00,
+#endif
+"tcc",OPC_tcc,0,{CLASS_CC,CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+0xa,CLASS_BIT+0xf,CLASS_REG+(ARG_RD),CLASS_CC,0,0,0,0,0,},2,2,377},
+
+
+/* 1010 1110 dddd cccc *** tccb cc,rbd */
+{
+#ifdef NICENAMES
+"tccb cc,rbd",8,5,
+0x00,
+#endif
+"tccb",OPC_tccb,0,{CLASS_CC,CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+0xa,CLASS_BIT+0xe,CLASS_REG+(ARG_RD),CLASS_CC,0,0,0,0,0,},2,2,378},
+
+
+/* 0000 1101 ddN0 0100 *** test @rd */
+{
+#ifdef NICENAMES
+"test @rd",16,8,
+0x18,
+#endif
+"test",OPC_test,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+4,0,0,0,0,0,},1,2,379},
+
+
+/* 0100 1101 0000 0100 address_dst *** test address_dst */
+{
+#ifdef NICENAMES
+"test address_dst",16,11,
+0x00,
+#endif
+"test",OPC_test,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+4,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,380},
+
+
+/* 0100 1101 ddN0 0100 address_dst *** test address_dst(rd) */
+{
+#ifdef NICENAMES
+"test address_dst(rd)",16,12,
+0x00,
+#endif
+"test",OPC_test,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+4,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,381},
+
+
+/* 1000 1101 dddd 0100 *** test rd */
+{
+#ifdef NICENAMES
+"test rd",16,7,
+0x00,
+#endif
+"test",OPC_test,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_BIT+4,0,0,0,0,0,},1,2,382},
+
+
+/* 0000 1100 ddN0 0100 *** testb @rd */
+{
+#ifdef NICENAMES
+"testb @rd",8,8,
+0x1c,
+#endif
+"testb",OPC_testb,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+4,0,0,0,0,0,},1,2,383},
+
+
+/* 0100 1100 0000 0100 address_dst *** testb address_dst */
+{
+#ifdef NICENAMES
+"testb address_dst",8,11,
+0x1c,
+#endif
+"testb",OPC_testb,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+4,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,384},
+
+
+/* 0100 1100 ddN0 0100 address_dst *** testb address_dst(rd) */
+{
+#ifdef NICENAMES
+"testb address_dst(rd)",8,12,
+0x1c,
+#endif
+"testb",OPC_testb,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+4,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,385},
+
+
+/* 1000 1100 dddd 0100 *** testb rbd */
+{
+#ifdef NICENAMES
+"testb rbd",8,7,
+0x1c,
+#endif
+"testb",OPC_testb,0,{CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_BIT+4,0,0,0,0,0,},1,2,386},
+
+
+/* 0001 1100 ddN0 1000 *** testl @rd */
+{
+#ifdef NICENAMES
+"testl @rd",32,13,
+0x18,
+#endif
+"testl",OPC_testl,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,0,0,0,0,0,},1,2,387},
+
+
+/* 0101 1100 0000 1000 address_dst *** testl address_dst */
+{
+#ifdef NICENAMES
+"testl address_dst",32,16,
+0x18,
+#endif
+"testl",OPC_testl,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+8,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,388},
+
+
+/* 0101 1100 ddN0 1000 address_dst *** testl address_dst(rd) */
+{
+#ifdef NICENAMES
+"testl address_dst(rd)",32,17,
+0x18,
+#endif
+"testl",OPC_testl,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,389},
+
+
+/* 1001 1100 dddd 1000 *** testl rrd */
+{
+#ifdef NICENAMES
+"testl rrd",32,13,
+0x18,
+#endif
+"testl",OPC_testl,0,{CLASS_REG_LONG+(ARG_RD),},
+ {CLASS_BIT+9,CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_BIT+8,0,0,0,0,0,},1,2,390},
+
+
+/* 1011 1000 ddN0 1000 0000 aaaa ssN0 0000 *** trdb @rd,@rs,rba */
+{
+#ifdef NICENAMES
+"trdb @rd,@rs,rba",8,25,
+0x1c,
+#endif
+"trdb",OPC_trdb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RD),CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RS),CLASS_BIT+0,0,},3,4,391},
+
+
+/* 1011 1000 ddN0 1100 0000 aaaa ssN0 0000 *** trdrb @rd,@rs,rba */
+{
+#ifdef NICENAMES
+"trdrb @rd,@rs,rba",8,25,
+0x1c,
+#endif
+"trdrb",OPC_trdrb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RA),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RD),CLASS_BIT+0xc,CLASS_BIT+0,CLASS_REG+(ARG_RA),CLASS_REGN0+(ARG_RS),CLASS_BIT+0,0,},3,4,392},
+
+
+/* 1011 1000 ddN0 0000 0000 rrrr ssN0 0000 *** trib @rd,@rs,rbr */
+{
+#ifdef NICENAMES
+"trib @rd,@rs,rbr",8,25,
+0x1c,
+#endif
+"trib",OPC_trib,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RD),CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RS),CLASS_BIT+0,0,},3,4,393},
+
+
+/* 1011 1000 ddN0 0100 0000 rrrr ssN0 0000 *** trirb @rd,@rs,rbr */
+{
+#ifdef NICENAMES
+"trirb @rd,@rs,rbr",8,25,
+0x1c,
+#endif
+"trirb",OPC_trirb,0,{CLASS_IR+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_REG_BYTE+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RD),CLASS_BIT+4,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RS),CLASS_BIT+0,0,},3,4,394},
+
+
+/* 1011 1000 aaN0 1010 0000 rrrr bbN0 0000 *** trtdb @ra,@rb,rbr */
+{
+#ifdef NICENAMES
+"trtdb @ra,@rb,rbr",8,25,
+0x1c,
+#endif
+"trtdb",OPC_trtdb,0,{CLASS_IR+(ARG_RA),CLASS_IR+(ARG_RB),CLASS_REG_BYTE+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RA),CLASS_BIT+0xa,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RB),CLASS_BIT+0,0,},3,4,395},
+
+
+/* 1011 1000 aaN0 1110 0000 rrrr bbN0 1110 *** trtdrb @ra,@rb,rbr */
+{
+#ifdef NICENAMES
+"trtdrb @ra,@rb,rbr",8,25,
+0x1c,
+#endif
+"trtdrb",OPC_trtdrb,0,{CLASS_IR+(ARG_RA),CLASS_IR+(ARG_RB),CLASS_REG_BYTE+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RA),CLASS_BIT+0xe,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RB),CLASS_BIT+0xe,0,},3,4,396},
+
+
+/* 1011 1000 aaN0 0010 0000 rrrr bbN0 0000 *** trtib @ra,@rb,rbr */
+{
+#ifdef NICENAMES
+"trtib @ra,@rb,rbr",8,25,
+0x1c,
+#endif
+"trtib",OPC_trtib,0,{CLASS_IR+(ARG_RA),CLASS_IR+(ARG_RB),CLASS_REG_BYTE+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RA),CLASS_BIT+2,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RB),CLASS_BIT+0,0,},3,4,397},
+
+
+/* 1011 1000 aaN0 0110 0000 rrrr bbN0 1110 *** trtirb @ra,@rb,rbr */
+{
+#ifdef NICENAMES
+"trtirb @ra,@rb,rbr",8,25,
+0x1c,
+#endif
+"trtirb",OPC_trtirb,0,{CLASS_IR+(ARG_RA),CLASS_IR+(ARG_RB),CLASS_REG_BYTE+(ARG_RR),},
+ {CLASS_BIT+0xb,CLASS_BIT+8,CLASS_REGN0+(ARG_RA),CLASS_BIT+6,CLASS_BIT+0,CLASS_REG+(ARG_RR),CLASS_REGN0+(ARG_RB),CLASS_BIT+0xe,0,},3,4,398},
+
+
+/* 0000 1101 ddN0 0110 *** tset @rd */
+{
+#ifdef NICENAMES
+"tset @rd",16,11,
+0x08,
+#endif
+"tset",OPC_tset,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+6,0,0,0,0,0,},1,2,399},
+
+
+/* 0100 1101 0000 0110 address_dst *** tset address_dst */
+{
+#ifdef NICENAMES
+"tset address_dst",16,14,
+0x08,
+#endif
+"tset",OPC_tset,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_BIT+0,CLASS_BIT+6,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,400},
+
+
+/* 0100 1101 ddN0 0110 address_dst *** tset address_dst(rd) */
+{
+#ifdef NICENAMES
+"tset address_dst(rd)",16,15,
+0x08,
+#endif
+"tset",OPC_tset,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xd,CLASS_REGN0+(ARG_RD),CLASS_BIT+6,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,401},
+
+
+/* 1000 1101 dddd 0110 *** tset rd */
+{
+#ifdef NICENAMES
+"tset rd",16,7,
+0x08,
+#endif
+"tset",OPC_tset,0,{CLASS_REG_WORD+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xd,CLASS_REG+(ARG_RD),CLASS_BIT+6,0,0,0,0,0,},1,2,402},
+
+
+/* 0000 1100 ddN0 0110 *** tsetb @rd */
+{
+#ifdef NICENAMES
+"tsetb @rd",8,11,
+0x08,
+#endif
+"tsetb",OPC_tsetb,0,{CLASS_IR+(ARG_RD),},
+ {CLASS_BIT+0,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+6,0,0,0,0,0,},1,2,403},
+
+
+/* 0100 1100 0000 0110 address_dst *** tsetb address_dst */
+{
+#ifdef NICENAMES
+"tsetb address_dst",8,14,
+0x08,
+#endif
+"tsetb",OPC_tsetb,0,{CLASS_DA+(ARG_DST),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+6,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,404},
+
+
+/* 0100 1100 ddN0 0110 address_dst *** tsetb address_dst(rd) */
+{
+#ifdef NICENAMES
+"tsetb address_dst(rd)",8,15,
+0x08,
+#endif
+"tsetb",OPC_tsetb,0,{CLASS_X+(ARG_RD),},
+ {CLASS_BIT+4,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+6,CLASS_ADDRESS+(ARG_DST),0,0,0,0,},1,4,405},
+
+
+/* 1000 1100 dddd 0110 *** tsetb rbd */
+{
+#ifdef NICENAMES
+"tsetb rbd",8,7,
+0x08,
+#endif
+"tsetb",OPC_tsetb,0,{CLASS_REG_BYTE+(ARG_RD),},
+ {CLASS_BIT+8,CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_BIT+6,0,0,0,0,0,},1,2,406},
+
+
+/* 0000 1001 ssN0 dddd *** xor rd,@rs */
+{
+#ifdef NICENAMES
+"xor rd,@rs",16,7,
+0x18,
+#endif
+"xor",OPC_xor,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+9,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,407},
+
+
+/* 0100 1001 0000 dddd address_src *** xor rd,address_src */
+{
+#ifdef NICENAMES
+"xor rd,address_src",16,9,
+0x18,
+#endif
+"xor",OPC_xor,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,408},
+
+
+/* 0100 1001 ssN0 dddd address_src *** xor rd,address_src(rs) */
+{
+#ifdef NICENAMES
+"xor rd,address_src(rs)",16,10,
+0x18,
+#endif
+"xor",OPC_xor,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+9,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,409},
+
+
+/* 0000 1001 0000 dddd imm16 *** xor rd,imm16 */
+{
+#ifdef NICENAMES
+"xor rd,imm16",16,7,
+0x18,
+#endif
+"xor",OPC_xor,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IMM+(ARG_IMM16),},
+ {CLASS_BIT+0,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM16),0,0,0,0,},2,4,410},
+
+
+/* 1000 1001 ssss dddd *** xor rd,rs */
+{
+#ifdef NICENAMES
+"xor rd,rs",16,4,
+0x18,
+#endif
+"xor",OPC_xor,0,{CLASS_REG_WORD+(ARG_RD),CLASS_REG_WORD+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+9,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,411},
+
+
+/* 0000 1000 ssN0 dddd *** xorb rbd,@rs */
+{
+#ifdef NICENAMES
+"xorb rbd,@rs",8,7,
+0x1c,
+#endif
+"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IR+(ARG_RS),},
+ {CLASS_BIT+0,CLASS_BIT+8,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,412},
+
+
+/* 0100 1000 0000 dddd address_src *** xorb rbd,address_src */
+{
+#ifdef NICENAMES
+"xorb rbd,address_src",8,9,
+0x1c,
+#endif
+"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_DA+(ARG_SRC),},
+ {CLASS_BIT+4,CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,413},
+
+
+/* 0100 1000 ssN0 dddd address_src *** xorb rbd,address_src(rs) */
+{
+#ifdef NICENAMES
+"xorb rbd,address_src(rs)",8,10,
+0x1c,
+#endif
+"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
+ {CLASS_BIT+4,CLASS_BIT+8,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,414},
+
+
+/* 0000 1000 0000 dddd imm8 imm8 *** xorb rbd,imm8 */
+{
+#ifdef NICENAMES
+"xorb rbd,imm8",8,7,
+0x1c,
+#endif
+"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
+ {CLASS_BIT+0,CLASS_BIT+8,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,415},
+
+
+/* 1000 1000 ssss dddd *** xorb rbd,rbs */
+{
+#ifdef NICENAMES
+"xorb rbd,rbs",8,4,
+0x1c,
+#endif
+"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+8,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,416},
+
+
+/* 1000 1000 ssss dddd *** xorb rbd,rbs */
+{
+#ifdef NICENAMES
+"xorb rbd,rbs",8,4,
+0x01,
+#endif
+"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
+ {CLASS_BIT+8,CLASS_BIT+8,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,417},
+0,0};
+#endif
diff --git a/opcodes/z8kgen.c b/opcodes/z8kgen.c
new file mode 100644
index 00000000000..e786bbb4c3d
--- /dev/null
+++ b/opcodes/z8kgen.c
@@ -0,0 +1,1313 @@
+/*
+This file is part of GNU Binutils.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* This program generates z8k-opc.h */
+
+#include <ansidecl.h>
+#include "sysdep.h"
+
+#define BYTE_INFO_LEN 10
+
+struct op
+{
+ char *flags;
+ int cycles;
+ char type;
+ char *bits;
+ char *name;
+ char *flavor;
+};
+
+#define iswhite(x) ((x) == ' ' || (x) == '\t')
+struct op opt[] =
+{
+ "------", 10, 8, "0000 1110 imm8", "ext0e imm8", 0,
+ "------", 10, 8, "0000 1111 imm8", "ext0f imm8", 0,
+ "------", 10, 8, "1000 1110 imm8", "ext8e imm8", 0,
+ "------", 10, 8, "1000 1111 imm8", "ext8f imm8", 0,
+
+ "------", 10, 8, "0011 0110 imm8", "rsvd36", 0,
+ "------", 10, 8, "0011 1000 imm8", "rsvd38", 0,
+ "------", 10, 8, "0111 1000 imm8", "rsvd78", 0,
+ "------", 10, 8, "0111 1110 imm8", "rsvd7e", 0,
+
+ "------", 10, 8, "1001 1101 imm8", "rsvd9d", 0,
+ "------", 10, 8, "1001 1111 imm8", "rsvd9f", 0,
+
+ "------", 10, 8, "1011 1001 imm8", "rsvdb9", 0,
+ "------", 10, 8, "1011 1111 imm8", "rsvdbf", 0,
+
+ "---V--", 11, 16, "1011 1011 ssN0 1001 0000 rrrr ddN0 1000", "ldd @rs,@rd,rr", 0,
+ "---V--", 11, 16, "1011 1011 ssN0 1001 0000 rrrr ddN0 0000", "lddr @rs,@rd,rr", 0,
+ "---V--", 11, 8, "1011 1011 ssN0 1001 0000 rrrr ddN0 0000", "lddrb @rs,@rd,rr", 0,
+ "---V--", 11, 16, "1011 1011 ssN0 0001 0000 rrrr ddN0 0000", "ldir @rd,@rs,rr", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 0000 0000 rrrr dddd cccc", "cpi rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 0100 0000 rrrr dddd cccc", "cpir rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 1100 0000 rrrr dddd cccc", "cpdr rd,@rs,rr,cc", 0,
+ "---V--", 11, 16, "1011 1011 ssN0 0001 0000 rrrr ddN0 1000", "ldi @rd,@rs,rr", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 1000 0000 rrrr dddd cccc", "cpd rd,@rs,rr,cc", 0,
+ "---V--", 11, 8, "1011 1010 ssN0 0001 0000 rrrr ddN0 0000", "ldirb @rd,@rs,rr", 0,
+ "---V--", 11, 8, "1011 1010 ssN0 1001 0000 rrrr ddN0 1000", "lddb @rs,@rd,rr", 0,
+ "---V--", 11, 8, "1011 1010 ssN0 0001 0000 rrrr ddN0 1000", "ldib @rd,@rs,rr", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 1000 0000 rrrr dddd cccc", "cpdb rbd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 1100 0000 rrrr dddd cccc", "cpdrb rbd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 0000 0000 rrrr dddd cccc", "cpib rbd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 0100 0000 rrrr dddd cccc", "cpirb rbd,@rs,rr,cc", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 1010 0000 rrrr ddN0 cccc", "cpsd @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 1010 0000 rrrr ddN0 cccc", "cpsdb @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 1110 0000 rrrr ddN0 cccc", "cpsdr @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 1110 0000 rrrr ddN0 cccc", "cpsdrb @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 0010 0000 rrrr ddN0 cccc", "cpsi @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 0010 0000 rrrr ddN0 cccc", "cpsib @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 16, "1011 1011 ssN0 0110 0000 rrrr ddN0 cccc", "cpsir @rd,@rs,rr,cc", 0,
+ "CZSV--", 11, 8, "1011 1010 ssN0 0110 0000 rrrr ddN0 cccc", "cpsirb @rd,@rs,rr,cc", 0,
+
+ "------", 2, 8, "0011 0110 0000 0000", "bpt", 0,
+ "CZSV--", 5, 16, "1011 0101 ssss dddd", "adc rd,rs", 0,
+ "CZSVDH", 5, 8, "1011 0100 ssss dddd", "adcb rbd,rbs", 0,
+ "CZSV--", 7, 16, "0000 0001 ssN0 dddd", "add rd,@rs", 0,
+"CZSV--", 9, 16, "0100 0001 0000 dddd address_src", "add rd,address_src", 0,
+ "CZSV--", 10, 16, "0100 0001 ssN0 dddd address_src", "add rd,address_src(rs)", 0,
+ "CZSV--", 7, 16, "0000 0001 0000 dddd imm16", "add rd,imm16", 0,
+ "CZSV--", 4, 16, "1000 0001 ssss dddd", "add rd,rs", 0,
+ "CZSVDH", 7, 8, "0000 0000 ssN0 dddd", "addb rbd,@rs", 0,
+"CZSVDH", 9, 8, "0100 0000 0000 dddd address_src", "addb rbd,address_src", 0,
+ "CZSVDH", 10, 8, "0100 0000 ssN0 dddd address_src", "addb rbd,address_src(rs)", 0,
+ "CZSVDH", 7, 8, "0000 0000 0000 dddd imm8 imm8", "addb rbd,imm8", 0,
+ "CZSVDH", 4, 8, "1000 0000 ssss dddd", "addb rbd,rbs", 0,
+ "CZSV--", 14, 32, "0001 0110 ssN0 dddd", "addl rrd,@rs", 0,
+ "CZSV--", 15, 32, "0101 0110 0000 dddd address_src", "addl rrd,address_src", 0,
+ "CZSV--", 16, 32, "0101 0110 ssN0 dddd address_src", "addl rrd,address_src(rs)", 0,
+ "CZSV--", 14, 32, "0001 0110 0000 dddd imm32", "addl rrd,imm32", 0,
+ "CZSV--", 8, 32, "1001 0110 ssss dddd", "addl rrd,rrs", 0,
+
+ "-ZS---", 7, 16, "0000 0111 ssN0 dddd", "and rd,@rs", 0,
+"-ZS---", 9, 16, "0100 0111 0000 dddd address_src", "and rd,address_src", 0,
+ "-ZS---", 10, 16, "0100 0111 ssN0 dddd address_src", "and rd,address_src(rs)", 0,
+ "-ZS---", 7, 16, "0000 0111 0000 dddd imm16", "and rd,imm16", 0,
+ "-ZS---", 4, 16, "1000 0111 ssss dddd", "and rd,rs", 0,
+ "-ZSP--", 7, 8, "0000 0110 ssN0 dddd", "andb rbd,@rs", 0,
+"-ZSP--", 9, 8, "0100 0110 0000 dddd address_src", "andb rbd,address_src", 0,
+ "-ZSP--", 10, 8, "0100 0110 ssN0 dddd address_src", "andb rbd,address_src(rs)", 0,
+ "-ZSP--", 7, 8, "0000 0110 0000 dddd imm8 imm8", "andb rbd,imm8", 0,
+ "-ZSP--", 4, 8, "1000 0110 ssss dddd", "andb rbd,rbs", 0,
+
+ "-Z----", 8, 16, "0010 0111 ddN0 imm4", "bit @rd,imm4", 0,
+ "-Z----", 11, 16, "0110 0111 ddN0 imm4 address_dst", "bit address_dst(rd),imm4", 0,
+ "-Z----", 10, 16, "0110 0111 0000 imm4 address_dst", "bit address_dst,imm4", 0,
+ "-Z----", 4, 16, "1010 0111 dddd imm4", "bit rd,imm4", 0,
+"-Z----", 10, 16, "0010 0111 0000 ssss 0000 dddd 0000 0000", "bit rd,rs", 0,
+
+ "-Z----", 8, 8, "0010 0110 ddN0 imm4", "bitb @rd,imm4", 0,
+ "-Z----", 11, 8, "0110 0110 ddN0 imm4 address_dst", "bitb address_dst(rd),imm4", 0,
+ "-Z----", 10, 8, "0110 0110 0000 imm4 address_dst", "bitb address_dst,imm4", 0,
+ "-Z----", 4, 8, "1010 0110 dddd imm4", "bitb rbd,imm4", 0,
+"-Z----", 10, 8, "0010 0110 0000 ssss 0000 dddd 0000 0000", "bitb rbd,rs", 0,
+
+ "------", 10, 32, "0001 1111 ddN0 0000", "call @rd", 0,
+ "------", 12, 32, "0101 1111 0000 0000 address_dst", "call address_dst", 0,
+ "------", 13, 32, "0101 1111 ddN0 0000 address_dst", "call address_dst(rd)", 0,
+ "------", 10, 16, "1101 disp12", "calr disp12", 0,
+
+ "------", 8, 16, "0000 1101 ddN0 1000", "clr @rd", 0,
+ "------", 11, 16, "0100 1101 0000 1000 address_dst", "clr address_dst", 0,
+ "------", 12, 16, "0100 1101 ddN0 1000 address_dst", "clr address_dst(rd)", 0,
+ "------", 7, 16, "1000 1101 dddd 1000", "clr rd", 0,
+ "------", 8, 8, "0000 1100 ddN0 1000", "clrb @rd", 0,
+ "------", 11, 8, "0100 1100 0000 1000 address_dst", "clrb address_dst", 0,
+ "------", 12, 8, "0100 1100 ddN0 1000 address_dst", "clrb address_dst(rd)", 0,
+ "------", 7, 8, "1000 1100 dddd 1000", "clrb rbd", 0,
+ "-ZS---", 12, 16, "0000 1101 ddN0 0000", "com @rd", 0,
+ "-ZS---", 15, 16, "0100 1101 0000 0000 address_dst", "com address_dst", 0,
+ "-ZS---", 16, 16, "0100 1101 ddN0 0000 address_dst", "com address_dst(rd)", 0,
+ "-ZS---", 7, 16, "1000 1101 dddd 0000", "com rd", 0,
+ "-ZSP--", 12, 8, "0000 1100 ddN0 0000", "comb @rd", 0,
+ "-ZSP--", 15, 8, "0100 1100 0000 0000 address_dst", "comb address_dst", 0,
+ "-ZSP--", 16, 8, "0100 1100 ddN0 0000 address_dst", "comb address_dst(rd)", 0,
+ "-ZSP--", 7, 8, "1000 1100 dddd 0000", "comb rbd", 0,
+ "CZSP--", 7, 16, "1000 1101 imm4 0101", "comflg flags", 0,
+
+ "CZSV--", 11, 16, "0000 1101 ddN0 0001 imm16", "cp @rd,imm16", 0,
+ "CZSV--", 15, 16, "0100 1101 ddN0 0001 address_dst imm16", "cp address_dst(rd),imm16", 0,
+ "CZSV--", 14, 16, "0100 1101 0000 0001 address_dst imm16", "cp address_dst,imm16", 0,
+
+ "CZSV--", 7, 16, "0000 1011 ssN0 dddd", "cp rd,@rs", 0,
+ "CZSV--", 9, 16, "0100 1011 0000 dddd address_src", "cp rd,address_src", 0,
+ "CZSV--", 10, 16, "0100 1011 ssN0 dddd address_src", "cp rd,address_src(rs)", 0,
+ "CZSV--", 7, 16, "0000 1011 0000 dddd imm16", "cp rd,imm16", 0,
+ "CZSV--", 4, 16, "1000 1011 ssss dddd", "cp rd,rs", 0,
+
+ "CZSV--", 11, 8, "0000 1100 ddN0 0001 imm8 imm8", "cpb @rd,imm8", 0,
+ "CZSV--", 15, 8, "0100 1100 ddN0 0001 address_dst imm8 imm8", "cpb address_dst(rd),imm8", 0,
+ "CZSV--", 14, 8, "0100 1100 0000 0001 address_dst imm8 imm8", "cpb address_dst,imm8", 0,
+ "CZSV--", 7, 8, "0000 1010 ssN0 dddd", "cpb rbd,@rs", 0,
+"CZSV--", 9, 8, "0100 1010 0000 dddd address_src", "cpb rbd,address_src", 0,
+ "CZSV--", 10, 8, "0100 1010 ssN0 dddd address_src", "cpb rbd,address_src(rs)", 0,
+ "CZSV--", 7, 8, "0000 1010 0000 dddd imm8 imm8", "cpb rbd,imm8", 0,
+ "CZSV--", 4, 8, "1000 1010 ssss dddd", "cpb rbd,rbs", 0,
+
+ "CZSV--", 14, 32, "0001 0000 ssN0 dddd", "cpl rrd,@rs", 0,
+ "CZSV--", 15, 32, "0101 0000 0000 dddd address_src", "cpl rrd,address_src", 0,
+ "CZSV--", 16, 32, "0101 0000 ssN0 dddd address_src", "cpl rrd,address_src(rs)", 0,
+ "CZSV--", 14, 32, "0001 0000 0000 dddd imm32", "cpl rrd,imm32", 0,
+ "CZSV--", 8, 32, "1001 0000 ssss dddd", "cpl rrd,rrs", 0,
+
+ "CZS---", 5, 8, "1011 0000 dddd 0000", "dab rbd", 0,
+ "------", 11, 16, "1111 dddd 1disp7", "dbjnz rbd,disp7", 0,
+ "-ZSV--", 11, 16, "0010 1011 ddN0 imm4m1", "dec @rd,imm4m1", 0,
+ "-ZSV--", 14, 16, "0110 1011 ddN0 imm4m1 address_dst", "dec address_dst(rd),imm4m1", 0,
+ "-ZSV--", 13, 16, "0110 1011 0000 imm4m1 address_dst", "dec address_dst,imm4m1", 0,
+ "-ZSV--", 4, 16, "1010 1011 dddd imm4m1", "dec rd,imm4m1", 0,
+ "-ZSV--", 11, 8, "0010 1010 ddN0 imm4m1", "decb @rd,imm4m1", 0,
+ "-ZSV--", 14, 8, "0110 1010 ddN0 imm4m1 address_dst", "decb address_dst(rd),imm4m1", 0,
+ "-ZSV--", 13, 8, "0110 1010 0000 imm4m1 address_dst", "decb address_dst,imm4m1", 0,
+ "-ZSV--", 4, 8, "1010 1010 dddd imm4m1", "decb rbd,imm4m1", 0,
+
+ "------", 7, 16, "0111 1100 0000 00ii", "di i2", 0,
+ "CZSV--", 107, 16, "0001 1011 ssN0 dddd", "div rrd,@rs", 0,
+ "CZSV--", 107, 16, "0101 1011 0000 dddd address_src", "div rrd,address_src", 0,
+ "CZSV--", 107, 16, "0101 1011 ssN0 dddd address_src", "div rrd,address_src(rs)", 0,
+ "CZSV--", 107, 16, "0001 1011 0000 dddd imm16", "div rrd,imm16", 0,
+ "CZSV--", 107, 16, "1001 1011 ssss dddd", "div rrd,rs", 0,
+ "CZSV--", 744, 32, "0001 1010 ssN0 dddd", "divl rqd,@rs", 0,
+ "CZSV--", 745, 32, "0101 1010 0000 dddd address_src", "divl rqd,address_src", 0,
+ "CZSV--", 746, 32, "0101 1010 ssN0 dddd address_src", "divl rqd,address_src(rs)", 0,
+ "CZSV--", 744, 32, "0001 1010 0000 dddd imm32", "divl rqd,imm32", 0,
+ "CZSV--", 744, 32, "1001 1010 ssss dddd", "divl rqd,rrs", 0,
+
+ "------", 11, 16, "1111 dddd 0disp7", "djnz rd,disp7", 0,
+ "------", 7, 16, "0111 1100 0000 01ii", "ei i2", 0,
+ "------", 6, 16, "1010 1101 ssss dddd", "ex rd,rs", 0,
+ "------", 12, 16, "0010 1101 ssN0 dddd", "ex rd,@rs", 0,
+"------", 15, 16, "0110 1101 0000 dddd address_src", "ex rd,address_src", 0,
+ "------", 16, 16, "0110 1101 ssN0 dddd address_src", "ex rd,address_src(rs)", 0,
+
+ "------", 12, 8, "0010 1100 ssN0 dddd", "exb rbd,@rs", 0,
+"------", 15, 8, "0110 1100 0000 dddd address_src", "exb rbd,address_src", 0,
+ "------", 16, 8, "0110 1100 ssN0 dddd address_src", "exb rbd,address_src(rs)", 0,
+ "------", 6, 8, "1010 1100 ssss dddd", "exb rbd,rbs", 0,
+
+ "------", 11, 16, "1011 0001 dddd 1010", "exts rrd", 0,
+ "------", 11, 8, "1011 0001 dddd 0000", "extsb rd", 0,
+ "------", 11, 32, "1011 0001 dddd 0111", "extsl rqd", 0,
+
+ "------", 8, 16, "0111 1010 0000 0000", "halt", 0,
+ "------", 10, 16, "0011 1101 ssN0 dddd", "in rd,@rs", 0,
+ "------", 12, 16, "0011 1101 dddd 0100 imm16", "in rd,imm16", 0,
+ "------", 12, 8, "0011 1100 ssN0 dddd", "inb rbd,@rs", 0,
+ "------", 10, 8, "0011 1100 dddd 0100 imm16", "inb rbd,imm16", 0,
+ "-ZSV--", 11, 16, "0010 1001 ddN0 imm4m1", "inc @rd,imm4m1", 0,
+ "-ZSV--", 14, 16, "0110 1001 ddN0 imm4m1 address_dst", "inc address_dst(rd),imm4m1", 0,
+ "-ZSV--", 13, 16, "0110 1001 0000 imm4m1 address_dst", "inc address_dst,imm4m1", 0,
+ "-ZSV--", 4, 16, "1010 1001 dddd imm4m1", "inc rd,imm4m1", 0,
+ "-ZSV--", 11, 8, "0010 1000 ddN0 imm4m1", "incb @rd,imm4m1", 0,
+ "-ZSV--", 14, 8, "0110 1000 ddN0 imm4m1 address_dst", "incb address_dst(rd),imm4m1", 0,
+ "-ZSV--", 13, 8, "0110 1000 0000 imm4m1 address_dst", "incb address_dst,imm4m1", 0,
+ "-ZSV--", 4, 8, "1010 1000 dddd imm4m1", "incb rbd,imm4m1", 0,
+ "---V--", 21, 16, "0011 1011 ssN0 1000 0000 aaaa ddN0 1000", "ind @rd,@rs,ra", 0,
+ "---V--", 21, 8, "0011 1010 ssN0 1000 0000 aaaa ddN0 1000", "indb @rd,@rs,rba", 0,
+ "---V--", 21, 8, "0011 1100 ssN0 0000 0000 aaaa ddN0 1000", "inib @rd,@rs,ra", 0,
+ "---V--", 21, 16, "0011 1100 ssN0 0000 0000 aaaa ddN0 0000", "inibr @rd,@rs,ra", 0,
+ "CZSVDH", 13, 16, "0111 1011 0000 0000", "iret", 0,
+ "------", 10, 16, "0001 1110 ddN0 cccc", "jp cc,@rd", 0,
+ "------", 7, 16, "0101 1110 0000 cccc address_dst", "jp cc,address_dst", 0,
+ "------", 8, 16, "0101 1110 ddN0 cccc address_dst", "jp cc,address_dst(rd)", 0,
+ "------", 6, 16, "1110 cccc disp8", "jr cc,disp8", 0,
+
+ "------", 7, 16, "0000 1101 ddN0 0101 imm16", "ld @rd,imm16", 0,
+ "------", 8, 16, "0010 1111 ddN0 ssss", "ld @rd,rs", 0,
+ "------", 15, 16, "0100 1101 ddN0 0101 address_dst imm16", "ld address_dst(rd),imm16", 0,
+ "------", 12, 16, "0110 1111 ddN0 ssss address_dst", "ld address_dst(rd),rs", 0,
+ "------", 14, 16, "0100 1101 0000 0101 address_dst imm16", "ld address_dst,imm16", 0,
+"------", 11, 16, "0110 1111 0000 ssss address_dst", "ld address_dst,rs", 0,
+ "------", 14, 16, "0011 0011 ddN0 ssss imm16", "ld rd(imm16),rs", 0,
+ "------", 14, 16, "0111 0011 ddN0 ssss 0000 xxxx 0000 0000", "ld rd(rx),rs", 0,
+ "------", 7, 16, "0010 0001 ssN0 dddd", "ld rd,@rs", 0,
+ "------", 9, 16, "0110 0001 0000 dddd address_src", "ld rd,address_src", 0,
+ "------", 10, 16, "0110 0001 ssN0 dddd address_src", "ld rd,address_src(rs)", 0,
+ "------", 7, 16, "0010 0001 0000 dddd imm16", "ld rd,imm16", 0,
+ "------", 3, 16, "1010 0001 ssss dddd", "ld rd,rs", 0,
+ "------", 14, 16, "0011 0001 ssN0 dddd imm16", "ld rd,rs(imm16)", 0,
+ "------", 14, 16, "0111 0001 ssN0 dddd 0000 xxxx 0000 0000", "ld rd,rs(rx)", 0,
+
+ "------", 7, 8, "0000 1100 ddN0 0101 imm8 imm8", "ldb @rd,imm8", 0,
+ "------", 8, 8, "0010 1110 ddN0 ssss", "ldb @rd,rbs", 0,
+ "------", 15, 8, "0100 1100 ddN0 0101 address_dst imm8 imm8", "ldb address_dst(rd),imm8", 0,
+ "------", 12, 8, "0100 1110 ddN0 ssN0 address_dst", "ldb address_dst(rd),rbs", 0,
+ "------", 14, 8, "0100 1100 0000 0101 address_dst imm8 imm8", "ldb address_dst,imm8", 0,
+"------", 11, 8, "0110 1110 0000 ssss address_dst", "ldb address_dst,rbs", 0,
+ "------", 14, 8, "0011 0010 ddN0 ssss imm16", "ldb rd(imm16),rbs", 0,
+ "------", 14, 8, "0111 0010 ddN0 ssss 0000 xxxx 0000 0000", "ldb rd(rx),rbs", 0,
+ "------", 7, 8, "0010 0000 ssN0 dddd", "ldb rbd,@rs", 0,
+"------", 9, 8, "0110 0000 0000 dddd address_src", "ldb rbd,address_src", 0,
+ "------", 10, 8, "0110 0000 ssN0 dddd address_src", "ldb rbd,address_src(rs)", 0,
+ "------", 5, 8, "1100 dddd imm8", "ldb rbd,imm8", 0,
+ "------", 3, 8, "1010 0000 ssss dddd", "ldb rbd,rbs", 0,
+ "------", 14, 8, "0011 0000 ssN0 dddd imm16", "ldb rbd,rs(imm16)", 0,
+ "------", 14, 8, "0111 0000 ssN0 dddd 0000 xxxx 0000 0000", "ldb rbd,rs(rx)", 0,
+
+ "------", 11, 32, "0001 1101 ddN0 ssss", "ldl @rd,rrs", 0,
+ "------", 14, 32, "0101 1101 ddN0 ssss address_dst", "ldl address_dst(rd),rrs", 0,
+ "------", 15, 32, "0101 1101 0000 ssss address_dst", "ldl address_dst,rrs", 0,
+ "------", 17, 32, "0011 0111 ddN0 ssss imm16", "ldl rd(imm16),rrs", 0,
+ "------", 17, 32, "0111 0111 ddN0 ssss 0000 xxxx 0000 0000", "ldl rd(rx),rrs", 0,
+ "------", 11, 32, "0001 0100 ssN0 dddd", "ldl rrd,@rs", 0,
+ "------", 12, 32, "0101 0100 0000 dddd address_src", "ldl rrd,address_src", 0,
+ "------", 13, 32, "0101 0100 ssN0 dddd address_src", "ldl rrd,address_src(rs)", 0,
+ "------", 11, 32, "0001 0100 0000 dddd imm32", "ldl rrd,imm32", 0,
+ "------", 5, 32, "1001 0100 ssss dddd", "ldl rrd,rrs", 0,
+ "------", 17, 32, "0011 0101 ssN0 dddd imm16", "ldl rrd,rs(imm16)", 0,
+ "------", 17, 32, "0111 0101 ssN0 dddd 0000 xxxx 0000 0000", "ldl rrd,rs(rx)", 0,
+
+ "------", 12, 16, "0111 0110 0000 dddd address_src", "lda prd,address_src", 0,
+ "------", 13, 16, "0111 0110 ssN0 dddd address_src", "lda prd,address_src(rs)", 0,
+ "------", 15, 16, "0011 0100 ssN0 dddd imm16", "lda prd,rs(imm16)", 0,
+ "------", 15, 16, "0111 0100 ssN0 dddd 0000 xxxx 0000 0000", "lda prd,rs(rx)", 0,
+ "------", 15, 16, "0011 0100 0000 dddd disp16", "ldar prd,disp16", 0,
+ "------", 7, 32, "0111 1101 ssss 1ccc", "ldctl ctrl,rs", 0,
+ "------", 7, 32, "0111 1101 dddd 0ccc", "ldctl rd,ctrl", 0,
+
+ "------", 5, 16, "1011 1101 dddd imm4", "ldk rd,imm4", 0,
+
+ "------", 11, 16, "0001 1100 ddN0 1001 0000 ssss 0000 nminus1", "ldm @rd,rs,n", 0,
+ "------", 15, 16, "0101 1100 ddN0 1001 0000 ssN0 0000 nminus1 address_dst", "ldm address_dst(rd),rs,n", 0,
+ "------", 14, 16, "0101 1100 0000 1001 0000 ssss 0000 nminus1 address_dst", "ldm address_dst,rs,n", 0,
+ "------", 11, 16, "0001 1100 ssN0 0001 0000 dddd 0000 nminus1", "ldm rd,@rs,n", 0,
+ "------", 15, 16, "0101 1100 ssN0 0001 0000 dddd 0000 nminus1 address_src", "ldm rd,address_src(rs),n", 0,
+ "------", 14, 16, "0101 1100 0000 0001 0000 dddd 0000 nminus1 address_src", "ldm rd,address_src,n", 0,
+
+ "CZSVDH", 12, 16, "0011 1001 ssN0 0000", "ldps @rs", 0,
+ "CZSVDH", 16, 16, "0111 1001 0000 0000 address_src", "ldps address_src", 0,
+ "CZSVDH", 17, 16, "0111 1001 ssN0 0000 address_src", "ldps address_src(rs)", 0,
+
+ "------", 14, 16, "0011 0011 0000 ssss disp16", "ldr disp16,rs", 0,
+ "------", 14, 16, "0011 0001 0000 dddd disp16", "ldr rd,disp16", 0,
+ "------", 14, 8, "0011 0010 0000 ssss disp16", "ldrb disp16,rbs", 0,
+ "------", 14, 8, "0011 0000 0000 dddd disp16", "ldrb rbd,disp16", 0,
+ "------", 17, 32, "0011 0111 0000 ssss disp16", "ldrl disp16,rrs", 0,
+ "------", 17, 32, "0011 0101 0000 dddd disp16", "ldrl rrd,disp16", 0,
+
+ "CZS---", 7, 16, "0111 1011 0000 1010", "mbit", 0,
+ "-ZS---", 12, 16, "0111 1011 dddd 1101", "mreq rd", 0,
+ "------", 5, 16, "0111 1011 0000 1001", "mres", 0,
+ "------", 5, 16, "0111 1011 0000 1000", "mset", 0,
+
+ "CZSV--", 70, 16, "0001 1001 ssN0 dddd", "mult rrd,@rs", 0,
+ "CZSV--", 70, 16, "0101 1001 0000 dddd address_src", "mult rrd,address_src", 0,
+ "CZSV--", 70, 16, "0101 1001 ssN0 dddd address_src", "mult rrd,address_src(rs)", 0,
+ "CZSV--", 70, 16, "0001 1001 0000 dddd imm16", "mult rrd,imm16", 0,
+ "CZSV--", 70, 16, "1001 1001 ssss dddd", "mult rrd,rs", 0,
+ "CZSV--", 282, 32, "0001 1000 ssN0 dddd", "multl rqd,@rs", 0,
+ "CZSV--", 282, 32, "0101 1000 0000 dddd address_src", "multl rqd,address_src", 0,
+ "CZSV--", 282, 32, "0101 1000 ssN0 dddd address_src", "multl rqd,address_src(rs)", 0,
+ "CZSV--", 282, 32, "0001 1000 0000 dddd imm32", "multl rqd,imm32", 0,
+ "CZSV--", 282, 32, "1001 1000 ssss dddd", "multl rqd,rrs", 0,
+ "CZSV--", 12, 16, "0000 1101 ddN0 0010", "neg @rd", 0,
+ "CZSV--", 15, 16, "0100 1101 0000 0010 address_dst", "neg address_dst", 0,
+ "CZSV--", 16, 16, "0100 1101 ddN0 0010 address_dst", "neg address_dst(rd)", 0,
+ "CZSV--", 7, 16, "1000 1101 dddd 0010", "neg rd", 0,
+ "CZSV--", 12, 8, "0000 1100 ddN0 0010", "negb @rd", 0,
+ "CZSV--", 15, 8, "0100 1100 0000 0010 address_dst", "negb address_dst", 0,
+ "CZSV--", 16, 8, "0100 1100 ddN0 0010 address_dst", "negb address_dst(rd)", 0,
+ "CZSV--", 7, 8, "1000 1100 dddd 0010", "negb rbd", 0,
+
+ "------", 7, 16, "1000 1101 0000 0111", "nop", 0,
+
+ "CZS---", 7, 16, "0000 0101 ssN0 dddd", "or rd,@rs", 0,
+ "CZS---", 9, 16, "0100 0101 0000 dddd address_src", "or rd,address_src", 0,
+ "CZS---", 10, 16, "0100 0101 ssN0 dddd address_src", "or rd,address_src(rs)", 0,
+ "CZS---", 7, 16, "0000 0101 0000 dddd imm16", "or rd,imm16", 0,
+ "CZS---", 4, 16, "1000 0101 ssss dddd", "or rd,rs", 0,
+
+ "CZSP--", 7, 8, "0000 0100 ssN0 dddd", "orb rbd,@rs", 0,
+"CZSP--", 9, 8, "0100 0100 0000 dddd address_src", "orb rbd,address_src", 0,
+ "CZSP--", 10, 8, "0100 0100 ssN0 dddd address_src", "orb rbd,address_src(rs)", 0,
+ "CZSP--", 7, 8, "0000 0100 0000 dddd imm8 imm8", "orb rbd,imm8", 0,
+ "CZSP--", 4, 8, "1000 0100 ssss dddd", "orb rbd,rbs", 0,
+
+ "---V--", 0, 16, "0011 1111 ddN0 ssss", "out @rd,rs", 0,
+ "---V--", 0, 16, "0011 1011 ssss 0110 imm16", "out imm16,rs", 0,
+ "---V--", 0, 8, "0011 1110 ddN0 ssss", "outb @rd,rbs", 0,
+ "---V--", 0, 8, "0011 1010 ssss 0110 imm16", "outb imm16,rbs", 0,
+ "---V--", 0, 16, "0011 1011 ssN0 1010 0000 aaaa ddN0 1000", "outd @rd,@rs,ra", 0,
+ "---V--", 0, 8, "0011 1010 ssN0 1010 0000 aaaa ddN0 1000", "outdb @rd,@rs,rba", 0,
+ "---V--", 0, 8, "0011 1100 ssN0 0010 0000 aaaa ddN0 1000", "outib @rd,@rs,ra", 0,
+ "---V--", 0, 16, "0011 1100 ssN0 0010 0000 aaaa ddN0 0000", "outibr @rd,@rs,ra", 0,
+
+ "------", 12, 16, "0001 0111 ssN0 ddN0", "pop @rd,@rs", 0,
+ "------", 16, 16, "0101 0111 ssN0 ddN0 address_dst", "pop address_dst(rd),@rs", 0,
+ "------", 16, 16, "0101 0111 ssN0 0000 address_dst", "pop address_dst,@rs", 0,
+ "------", 8, 16, "1001 0111 ssN0 dddd", "pop rd,@rs", 0,
+
+ "------", 19, 32, "0001 0101 ssN0 ddN0", "popl @rd,@rs", 0,
+ "------", 23, 32, "0101 0101 ssN0 ddN0 address_dst", "popl address_dst(rd),@rs", 0,
+ "------", 23, 32, "0101 0101 ssN0 0000 address_dst", "popl address_dst,@rs", 0,
+ "------", 12, 32, "1001 0101 ssN0 dddd", "popl rrd,@rs", 0,
+
+ "------", 13, 16, "0001 0011 ddN0 ssN0", "push @rd,@rs", 0,
+ "------", 14, 16, "0101 0011 ddN0 0000 address_src", "push @rd,address_src", 0,
+ "------", 14, 16, "0101 0011 ddN0 ssN0 address_src", "push @rd,address_src(rs)", 0,
+ "------", 12, 16, "0000 1101 ddN0 1001 imm16", "push @rd,imm16", 0,
+ "------", 9, 16, "1001 0011 ddN0 ssss", "push @rd,rs", 0,
+
+ "------", 20, 32, "0001 0001 ddN0 ssN0", "pushl @rd,@rs", 0,
+ "------", 21, 32, "0101 0001 ddN0 ssN0 address_src", "pushl @rd,address_src(rs)", 0,
+ "------", 21, 32, "0101 0001 ddN0 0000 address_src", "pushl @rd,address_src", 0,
+ "------", 12, 32, "1001 0001 ddN0 ssss", "pushl @rd,rrs", 0,
+
+ "------", 11, 16, "0010 0011 ddN0 imm4", "res @rd,imm4", 0,
+ "------", 14, 16, "0110 0011 ddN0 imm4 address_dst", "res address_dst(rd),imm4", 0,
+ "------", 13, 16, "0110 0011 0000 imm4 address_dst", "res address_dst,imm4", 0,
+ "------", 4, 16, "1010 0011 dddd imm4", "res rd,imm4", 0,
+"------", 10, 16, "0010 0011 0000 ssss 0000 dddd 0000 0000", "res rd,rs", 0,
+
+ "------", 11, 8, "0010 0010 ddN0 imm4", "resb @rd,imm4", 0,
+ "------", 14, 8, "0110 0010 ddN0 imm4 address_dst", "resb address_dst(rd),imm4", 0,
+ "------", 13, 8, "0110 0010 0000 imm4 address_dst", "resb address_dst,imm4", 0,
+ "------", 4, 8, "1010 0010 dddd imm4", "resb rbd,imm4", 0,
+"------", 10, 8, "0010 0010 0000 ssss 0000 dddd 0000 0000", "resb rbd,rs", 0,
+
+ "CZSV--", 7, 16, "1000 1101 imm4 0011", "resflg imm4", 0,
+ "------", 10, 16, "1001 1110 0000 cccc", "ret cc", 0,
+
+ "CZSV--", 6, 16, "1011 0011 dddd 00I0", "rl rd,imm1or2", 0,
+ "CZSV--", 6, 8, "1011 0010 dddd 00I0", "rlb rbd,imm1or2", 0,
+ "CZSV--", 6, 16, "1011 0011 dddd 10I0", "rlc rd,imm1or2", 0,
+
+ "-Z----", 9, 8, "1011 0010 dddd 10I0", "rlcb rbd,imm1or2", 0,
+ "-Z----", 9, 8, "1011 1110 aaaa bbbb", "rldb rbb,rba", 0,
+
+ "CZSV--", 6, 16, "1011 0011 dddd 01I0", "rr rd,imm1or2", 0,
+ "CZSV--", 6, 8, "1011 0010 dddd 01I0", "rrb rbd,imm1or2", 0,
+ "CZSV--", 6, 16, "1011 0011 dddd 11I0", "rrc rd,imm1or2", 0,
+
+ "-Z----", 9, 8, "1011 0010 dddd 11I0", "rrcb rbd,imm1or2", 0,
+ "-Z----", 9, 8, "1011 1100 aaaa bbbb", "rrdb rbb,rba", 0,
+ "CZSV--", 5, 16, "1011 0111 ssss dddd", "sbc rd,rs", 0,
+ "CZSVDH", 5, 8, "1011 0110 ssss dddd", "sbcb rbd,rbs", 0,
+
+ "CZSVDH", 33, 8, "0111 1111 imm8", "sc imm8", 0,
+
+"CZSV--", 15, 16, "1011 0011 dddd 1011 0000 ssss 0000 0000", "sda rd,rs", 0,
+"CZSV--", 15, 8, "1011 0010 dddd 1011 0000 ssss 0000 0000", "sdab rbd,rs", 0,
+ "CZSV--", 15, 32, "1011 0011 dddd 1111 0000 ssss 0000 0000", "sdal rrd,rs", 0,
+
+"CZS---", 15, 16, "1011 0011 dddd 0011 0000 ssss 0000 0000", "sdl rd,rs", 0,
+"CZS---", 15, 8, "1011 0010 dddd 0011 0000 ssss 0000 0000", "sdlb rbd,rs", 0,
+ "CZS---", 15, 32, "1011 0011 dddd 0111 0000 ssss 0000 0000", "sdll rrd,rs", 0,
+
+ "------", 11, 16, "0010 0101 ddN0 imm4", "set @rd,imm4", 0,
+ "------", 14, 16, "0110 0101 ddN0 imm4 address_dst", "set address_dst(rd),imm4", 0,
+ "------", 13, 16, "0110 0101 0000 imm4 address_dst", "set address_dst,imm4", 0,
+ "------", 4, 16, "1010 0101 dddd imm4", "set rd,imm4", 0,
+"------", 10, 16, "0010 0101 0000 ssss 0000 dddd 0000 0000", "set rd,rs", 0,
+ "------", 11, 8, "0010 0100 ddN0 imm4", "setb @rd,imm4", 0,
+ "------", 14, 8, "0110 0100 ddN0 imm4 address_dst", "setb address_dst(rd),imm4", 0,
+ "------", 13, 8, "0110 0100 0000 imm4 address_dst", "setb address_dst,imm4", 0,
+ "------", 4, 8, "1010 0100 dddd imm4", "setb rbd,imm4", 0,
+"------", 10, 8, "0010 0100 0000 ssss 0000 dddd 0000 0000", "setb rbd,rs", 0,
+
+ "CZSV--", 7, 16, "1000 1101 imm4 0001", "setflg imm4", 0,
+
+ "------", 0, 8, "0011 1100 dddd 0101 imm16", "sinb rbd,imm16", 0,
+ "------", 0, 8, "0011 1101 dddd 0101 imm16", "sinb rd,imm16", 0,
+ "------", 0, 16, "0011 1011 ssN0 1000 0001 aaaa ddN0 1000", "sind @rd,@rs,ra", 0,
+ "------", 0, 8, "0011 1010 ssN0 1000 0001 aaaa ddN0 1000", "sindb @rd,@rs,rba", 0,
+ "------", 0, 8, "0011 1100 ssN0 0001 0000 aaaa ddN0 1000", "sinib @rd,@rs,ra", 0,
+ "------", 0, 16, "0011 1100 ssN0 0001 0000 aaaa ddN0 0000", "sinibr @rd,@rs,ra", 0,
+
+ "CZSV--", 13, 16, "1011 0011 dddd 1001 0000 0000 imm8", "sla rd,imm8", 0,
+ "CZSV--", 13, 8, "1011 0010 dddd 1001 0000 0000 imm8", "slab rbd,imm8", 0,
+ "CZSV--", 13, 32, "1011 0011 dddd 1101 0000 0000 imm8", "slal rrd,imm8", 0,
+
+ "CZS---", 13, 16, "1011 0011 dddd 0001 0000 0000 imm8", "sll rd,imm8", 0,
+ "CZS---", 13, 8, "1011 0010 dddd 0001 0000 0000 imm8", "sllb rbd,imm8", 0,
+ "CZS---", 13, 32, "1011 0011 dddd 0101 0000 0000 imm8", "slll rrd,imm8", 0,
+
+ "------", 0, 16, "0011 1011 ssss 0111 imm16", "sout imm16,rs", 0,
+ "------", 0, 8, "0011 1010 ssss 0111 imm16", "soutb imm16,rbs", 0,
+ "------", 0, 16, "0011 1011 ssN0 1011 0000 aaaa ddN0 1000", "soutd @rd,@rs,ra", 0,
+ "------", 0, 8, "0011 1010 ssN0 1011 0000 aaaa ddN0 1000", "soutdb @rd,@rs,rba", 0,
+ "------", 0, 8, "0011 1100 ssN0 0011 0000 aaaa ddN0 1000", "soutib @rd,@rs,ra", 0,
+ "------", 0, 16, "0011 1100 ssN0 0011 0000 aaaa ddN0 0000", "soutibr @rd,@rs,ra", 0,
+
+ "CZSV--", 13, 16, "1011 0011 dddd 1001 1111 1111 nim8", "sra rd,imm8", 0,
+ "CZSV--", 13, 8, "1011 0010 dddd 1001 1111 1111 nim8", "srab rbd,imm8", 0,
+ "CZSV--", 13, 32, "1011 0011 dddd 1101 1111 1111 nim8", "sral rrd,imm8", 0,
+
+ "CZSV--", 13, 16, "1011 0011 dddd 0001 1111 1111 nim8", "srl rd,imm8", 0,
+ "CZSV--", 13, 8, "1011 0010 dddd 0001 1111 1111 nim8", "srlb rbd,imm8", 0,
+ "CZSV--", 13, 32, "1011 0011 dddd 0101 1111 1111 nim8", "srll rrd,imm8", 0,
+
+ "CZSV--", 7, 16, "0000 0011 ssN0 dddd", "sub rd,@rs", 0,
+"CZSV--", 9, 16, "0100 0011 0000 dddd address_src", "sub rd,address_src", 0,
+ "CZSV--", 10, 16, "0100 0011 ssN0 dddd address_src", "sub rd,address_src(rs)", 0,
+ "CZSV--", 7, 16, "0000 0010 0000 dddd imm16", "sub rd,imm16", 0,
+ "CZSV--", 4, 16, "1000 0011 ssss dddd", "sub rd,rs", 0,
+
+ "CZSVDH", 7, 8, "0000 0010 ssN0 dddd", "subb rbd,@rs", 0,
+"CZSVDH", 9, 8, "0100 0010 0000 dddd address_src", "subb rbd,address_src", 0,
+ "CZSVDH", 10, 8, "0100 0010 ssN0 dddd address_src", "subb rbd,address_src(rs)", 0,
+ "CZSVDH", 7, 8, "0000 0010 0000 dddd imm8 imm8", "subb rbd,imm8", 0,
+ "CZSVDH", 4, 8, "1000 0010 ssss dddd", "subb rbd,rbs", 0,
+
+ "CZSV--", 14, 32, "0001 0010 ssN0 dddd", "subl rrd,@rs", 0,
+ "CZSV--", 15, 32, "0101 0010 0000 dddd address_src", "subl rrd,address_src", 0,
+ "CZSV--", 16, 32, "0101 0010 ssN0 dddd address_src", "subl rrd,address_src(rs)", 0,
+ "CZSV--", 14, 32, "0001 0010 0000 dddd imm32", "subl rrd,imm32", 0,
+ "CZSV--", 8, 32, "1001 0010 ssss dddd", "subl rrd,rrs", 0,
+
+ "------", 5, 16, "1010 1111 dddd cccc", "tcc cc,rd", 0,
+ "------", 5, 8, "1010 1110 dddd cccc", "tccb cc,rbd", 0,
+
+ "-ZS---", 8, 16, "0000 1101 ddN0 0100", "test @rd", 0,
+ "------", 11, 16, "0100 1101 0000 0100 address_dst", "test address_dst", 0,
+ "------", 12, 16, "0100 1101 ddN0 0100 address_dst", "test address_dst(rd)", 0,
+ "------", 7, 16, "1000 1101 dddd 0100", "test rd", 0,
+
+ "-ZSP--", 8, 8, "0000 1100 ddN0 0100", "testb @rd", 0,
+ "-ZSP--", 11, 8, "0100 1100 0000 0100 address_dst", "testb address_dst", 0,
+ "-ZSP--", 12, 8, "0100 1100 ddN0 0100 address_dst", "testb address_dst(rd)", 0,
+ "-ZSP--", 7, 8, "1000 1100 dddd 0100", "testb rbd", 0,
+
+ "-ZS---", 13, 32, "0001 1100 ddN0 1000", "testl @rd", 0,
+"-ZS---", 16, 32, "0101 1100 0000 1000 address_dst", "testl address_dst", 0,
+ "-ZS---", 17, 32, "0101 1100 ddN0 1000 address_dst", "testl address_dst(rd)", 0,
+ "-ZS---", 13, 32, "1001 1100 dddd 1000", "testl rrd", 0,
+
+ "-ZSV--", 25, 8, "1011 1000 ddN0 1000 0000 aaaa ssN0 0000", "trdb @rd,@rs,rba", 0,
+ "-ZSV--", 25, 8, "1011 1000 ddN0 1100 0000 aaaa ssN0 0000", "trdrb @rd,@rs,rba", 0,
+ "-ZSV--", 25, 8, "1011 1000 ddN0 0000 0000 rrrr ssN0 0000", "trib @rd,@rs,rbr", 0,
+ "-ZSV--", 25, 8, "1011 1000 ddN0 0100 0000 rrrr ssN0 0000", "trirb @rd,@rs,rbr", 0,
+ "-ZSV--", 25, 8, "1011 1000 aaN0 1110 0000 rrrr bbN0 1110", "trtdrb @ra,@rb,rbr", 0,
+ "-ZSV--", 25, 8, "1011 1000 aaN0 0010 0000 rrrr bbN0 0000", "trtib @ra,@rb,rr", 0,
+ "-ZSV--", 25, 8, "1011 1000 aaN0 0110 0000 rrrr bbN0 1110", "trtirb @ra,@rb,rbr", 0,
+ "-ZSV--", 25, 8, "1011 1000 aaN0 1010 0000 rrrr bbN0 0000", "trtrb @ra,@rb,rbr", 0,
+
+ "--S---", 11, 16, "0000 1101 ddN0 0110", "tset @rd", 0,
+ "--S---", 14, 16, "0100 1101 0000 0110 address_dst", "tset address_dst", 0,
+ "--S---", 15, 16, "0100 1101 ddN0 0110 address_dst", "tset address_dst(rd)", 0,
+ "--S---", 7, 16, "1000 1101 dddd 0110", "tset rd", 0,
+
+ "--S---", 11, 8, "0000 1100 ddN0 0110", "tsetb @rd", 0,
+ "--S---", 14, 8, "0100 1100 0000 0110 address_dst", "tsetb address_dst", 0,
+ "--S---", 15, 8, "0100 1100 ddN0 0110 address_dst", "tsetb address_dst(rd)", 0,
+ "--S---", 7, 8, "1000 1100 dddd 0110", "tsetb rbd", 0,
+
+ "-ZS---", 7, 16, "0000 1001 ssN0 dddd", "xor rd,@rs", 0,
+"-ZS---", 9, 16, "0100 1001 0000 dddd address_src", "xor rd,address_src", 0,
+ "-ZS---", 10, 16, "0100 1001 ssN0 dddd address_src", "xor rd,address_src(rs)", 0,
+ "-ZS---", 7, 16, "0000 1001 0000 dddd imm16", "xor rd,imm16", 0,
+ "-ZS---", 4, 16, "1000 1001 ssss dddd", "xor rd,rs", 0,
+
+ "-ZSP--", 7, 8, "0000 1000 ssN0 dddd", "xorb rbd,@rs", 0,
+"-ZSP--", 9, 8, "0100 1000 0000 dddd address_src", "xorb rbd,address_src", 0,
+ "-ZSP--", 10, 8, "0100 1000 ssN0 dddd address_src", "xorb rbd,address_src(rs)", 0,
+ "-ZSP--", 7, 8, "0000 1000 0000 dddd imm8 imm8", "xorb rbd,imm8", 0,
+ "-ZSP--", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0,
+ "*", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0,
+ "*", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+int
+count ()
+{
+ struct op *p = opt;
+ int r = 0;
+
+ while (p->name)
+ {
+ r++;
+ p++;
+ }
+ return r;
+
+}
+
+static
+int
+func (a, b)
+ struct op *a;
+ struct op *b;
+{
+ return strcmp ((a)->name, (b)->name);
+}
+
+
+/* opcode
+
+ literal 0000 nnnn insert nnn into stream
+ operand 0001 nnnn insert operand reg nnn into stream
+*/
+
+struct tok_struct
+{
+
+ char *match;
+ char *token;
+ int length;
+};
+
+struct tok_struct args[] =
+{
+
+ {"address_src(rs)", "CLASS_X+(ARG_RS)",},
+ {"address_dst(rd)", "CLASS_X+(ARG_RD)",},
+
+ {"rs(imm16)", "CLASS_BA+(ARG_RS)",},
+ {"rd(imm16)", "CLASS_BA+(ARG_RD)",},
+ {"prd", "CLASS_PR+(ARG_RD)",},
+ {"address_src", "CLASS_DA+(ARG_SRC)",},
+ {"address_dst", "CLASS_DA+(ARG_DST)",},
+ {"rd(rx)", "CLASS_BX+(ARG_RD)",},
+ {"rs(rx)", "CLASS_BX+(ARG_RS)",},
+
+ {"disp16", "CLASS_DISP",},
+ {"disp12", "CLASS_DISP",},
+ {"disp7", "CLASS_DISP",},
+ {"disp8", "CLASS_DISP",},
+ {"flags", "CLASS_FLAGS",},
+
+ {"imm16", "CLASS_IMM+(ARG_IMM16)",},
+ {"imm1or2", "CLASS_IMM+(ARG_IMM1OR2)",},
+ {"imm32", "CLASS_IMM+(ARG_IMM32)",},
+ {"imm4m1", "CLASS_IMM +(ARG_IMM4M1)",},
+ {"imm4", "CLASS_IMM +(ARG_IMM4)",},
+ {"n", "CLASS_IMM + (ARG_IMMN)",},
+ {"ctrl", "CLASS_CTRL",},
+ {"rba", "CLASS_REG_BYTE+(ARG_RA)",},
+ {"rbb", "CLASS_REG_BYTE+(ARG_RB)",},
+ {"rbd", "CLASS_REG_BYTE+(ARG_RD)",},
+ {"rbs", "CLASS_REG_BYTE+(ARG_RS)",},
+ {"rbr", "CLASS_REG_BYTE+(ARG_RR)",},
+
+ {"rrd", "CLASS_REG_LONG+(ARG_RD)",},
+ {"rrs", "CLASS_REG_LONG+(ARG_RS)",},
+
+ {"rqd", "CLASS_REG_QUAD+(ARG_RD)",},
+
+ {"rd", "CLASS_REG_WORD+(ARG_RD)",},
+ {"rs", "CLASS_REG_WORD+(ARG_RS)",},
+
+ {"@rd", "CLASS_IR+(ARG_RD)",},
+ {"@ra", "CLASS_IR+(ARG_RA)",},
+ {"@rb", "CLASS_IR+(ARG_RB)",},
+ {"@rs", "CLASS_IR+(ARG_RS)",},
+
+ {"imm8", "CLASS_IMM+(ARG_IMM8)",},
+ {"i2", "CLASS_IMM+(ARG_IMM2)",},
+ {"cc", "CLASS_CC",},
+
+ {"rr", "CLASS_REG_WORD+(ARG_RR)",},
+ {"ra", "CLASS_REG_WORD+(ARG_RA)",},
+ {"rs", "CLASS_REG_WORD+(ARG_RS)",},
+
+ {"1", "CLASS_IMM+(ARG_IMM_1)",},
+ {"2", "CLASS_IMM+(ARG_IMM_2)",},
+
+ 0, 0
+};
+
+struct tok_struct toks[] =
+{
+ "0000", "CLASS_BIT+0", 1,
+ "0001", "CLASS_BIT+1", 1,
+ "0010", "CLASS_BIT+2", 1,
+ "0011", "CLASS_BIT+3", 1,
+ "0100", "CLASS_BIT+4", 1,
+ "0101", "CLASS_BIT+5", 1,
+ "0110", "CLASS_BIT+6", 1,
+ "0111", "CLASS_BIT+7", 1,
+ "1000", "CLASS_BIT+8", 1,
+ "1001", "CLASS_BIT+9", 1,
+ "1010", "CLASS_BIT+0xa", 1,
+ "1011", "CLASS_BIT+0xb", 1,
+ "1100", "CLASS_BIT+0xc", 1,
+ "1101", "CLASS_BIT+0xd", 1,
+ "1110", "CLASS_BIT+0xe", 1,
+ "1111", "CLASS_BIT+0xf", 1,
+
+ "00I0", "CLASS_BIT_1OR2+0", 1,
+ "00I0", "CLASS_BIT_1OR2+1", 1,
+ "00I0", "CLASS_BIT_1OR2+2", 1,
+ "00I0", "CLASS_BIT_1OR2+3", 1,
+ "01I0", "CLASS_BIT_1OR2+4", 1,
+ "01I0", "CLASS_BIT_1OR2+5", 1,
+ "01I0", "CLASS_BIT_1OR2+6", 1,
+ "01I0", "CLASS_BIT_1OR2+7", 1,
+ "10I0", "CLASS_BIT_1OR2+8", 1,
+ "10I0", "CLASS_BIT_1OR2+9", 1,
+ "10I0", "CLASS_BIT_1OR2+0xa", 1,
+ "10I0", "CLASS_BIT_1OR2+0xb", 1,
+ "11I0", "CLASS_BIT_1OR2+0xc", 1,
+ "11I0", "CLASS_BIT_1OR2+0xd", 1,
+ "11I0", "CLASS_BIT_1OR2+0xe", 1,
+ "11I0", "CLASS_BIT_1OR2+0xf", 1,
+
+ "ssss", "CLASS_REG+(ARG_RS)", 1,
+ "dddd", "CLASS_REG+(ARG_RD)", 1,
+ "aaaa", "CLASS_REG+(ARG_RA)", 1,
+ "bbbb", "CLASS_REG+(ARG_RB)", 1,
+ "rrrr", "CLASS_REG+(ARG_RR)", 1,
+
+ "ssN0", "CLASS_REGN0+(ARG_RS)", 1,
+ "ddN0", "CLASS_REGN0+(ARG_RD)", 1,
+ "aaN0", "CLASS_REGN0+(ARG_RA)", 1,
+ "bbN0", "CLASS_REGN0+(ARG_RB)", 1,
+ "rrN0", "CLASS_REGN0+(ARG_RR)", 1,
+
+ "cccc", "CLASS_CC", 1,
+ "nnnn", "CLASS_IMM+(ARG_IMMN)", 1,
+ "xxxx", "CLASS_REG+(ARG_RX)", 1,
+ "xxN0", "CLASS_REGN0+(ARG_RX)", 1,
+ "nminus1", "CLASS_IMM+(ARG_IMMNMINUS1)", 1,
+
+ "disp16", "CLASS_DISP+(ARG_DISP16)", 4,
+ "disp12", "CLASS_DISP+(ARG_DISP12)", 3,
+ "flags", "CLASS_FLAGS", 1,
+ "address_dst", "CLASS_ADDRESS+(ARG_DST)", 4,
+ "address_src", "CLASS_ADDRESS+(ARG_SRC)", 4,
+ "imm4m1", "CLASS_IMM+(ARG_IMM4M1)", 1,
+ "imm4", "CLASS_IMM+(ARG_IMM4)", 1,
+
+ "imm8", "CLASS_IMM+(ARG_IMM8)", 2,
+ "imm16", "CLASS_IMM+(ARG_IMM16)", 4,
+ "imm32", "CLASS_IMM+(ARG_IMM32)", 8,
+ "nim8", "CLASS_IMM+(ARG_NIM8)", 2,
+ "0ccc", "CLASS_0CCC", 1,
+ "1ccc", "CLASS_1CCC", 1,
+ "disp8", "CLASS_DISP8", 2,
+ "0disp7", "CLASS_0DISP7", 2,
+ "1disp7", "CLASS_1DISP7", 2,
+ "01ii", "CLASS_01II", 1,
+ "00ii", "CLASS_00II", 1,
+ 0, 0
+
+};
+
+char *
+translate (table, x, length)
+ struct tok_struct *table;
+ char *x;
+ int *length;
+{
+
+ int found;
+
+ found = 0;
+ while (table->match)
+ {
+ int l = strlen (table->match);
+
+ if (strncmp (table->match, x, l) == 0)
+ {
+ /* Got a hit */
+ printf ("%s", table->token);
+ *length += table->length;
+ return x + l;
+ }
+
+ table++;
+ }
+ fprintf (stderr, "Can't find %s\n", x);
+ printf ("**** Can't find %s\n", x);
+ while (*x)
+ x++;
+ return x;
+}
+
+void
+chewbits (bits, length)
+ char *bits;
+ int *length;
+{
+ int n = 0;
+
+ *length = 0;
+ printf ("{");
+ while (*bits)
+ {
+ while (*bits == ' ')
+ {
+ bits++;
+ }
+ bits = translate (toks, bits, length);
+ n++;
+ printf (",");
+
+ }
+ while (n < BYTE_INFO_LEN - 1)
+ {
+ printf ("0,");
+ n++;
+ }
+ printf ("}");
+}
+
+
+static
+int
+chewname (name)
+ char *name;
+{
+ char *n;
+ int nargs = 0;
+
+ n = name;
+ printf ("\"");
+ while (*n && !iswhite (*n))
+ {
+ printf ("%c", *n);
+ n++;
+ }
+ printf ("\","); /* Scan the operands and make entires for
+ them -remember indirect things */
+
+ n = name;
+ printf ("OPC_");
+ while (*n && !iswhite (*n))
+ {
+ printf ("%c", *n);
+ n++;
+ }
+ printf (",0,{");
+
+ while (*n)
+ {
+ int d;
+
+ while (*n == ',' || iswhite (*n))
+ n++;
+ nargs++;
+ n = translate (args, n, &d);
+ printf (",");
+ }
+ if (nargs == 0)
+ {
+ printf ("0");
+ }
+ printf ("},");
+ return nargs;
+}
+
+static
+void
+sub (x, c)
+ char *x;
+ char c;
+{
+ while (*x)
+ {
+ if (x[0] == c && x[1] == c &&
+ x[2] == c && x[3] == c)
+ {
+ x[2] = 'N';
+ x[3] = '0';
+ }
+ x++;
+ }
+}
+
+
+#if 0
+#define D(x) ((x) == '1' || (x) =='0')
+#define M(y) (strncmp(y,x,4)==0)
+printmangled (x)
+ char *x;
+{
+ return;
+ while (*x)
+ {
+ if (D (x[0]) && D (x[1]) && D (x[2]) && D (x[3]))
+ {
+ printf ("XXXX");
+ }
+ else if (M ("ssss"))
+ {
+ printf ("ssss");
+ }
+ else if (M ("dddd"))
+ {
+ printf ("dddd");
+ }
+ else
+ printf ("____");
+
+ x += 4;
+
+ if (x[0] == ' ')
+ {
+ printf ("_");
+ x++;
+ }
+ }
+
+}
+
+#endif
+/*#define WORK_TYPE*/
+void
+print_type (n)
+ struct op *n;
+{
+#ifdef WORK_TYPE
+ while (*s && !iswhite (*s))
+ {
+ l = *s;
+ s++;
+ }
+ switch (l)
+ {
+ case 'l':
+ printf ("32,");
+ break;
+ case 'b':
+ printf ("8,");
+ break;
+ default:
+ printf ("16,");
+ break;
+ }
+#else
+ printf ("%2d,", n->type);
+#endif
+}
+
+
+void
+internal ()
+{
+ int c = count ();
+ struct op *new = xmalloc (sizeof (struct op) * c);
+ struct op *p = opt;
+ memcpy (new, p, c * sizeof (struct op));
+
+ /* sort all names in table alphabetically */
+ qsort (new, c, sizeof (struct op), func);
+
+ p = new;
+ while (p->flags[0] != '*')
+ {
+ /* If there are any @rs, sub the ssss into a ssn0,
+ (rs), (ssn0)
+ */
+ int loop = 1;
+
+ printf ("\"%s\",%2d, ", p->flags, p->cycles);
+ while (loop)
+ {
+ char *s = p->name;
+
+ loop = 0;
+ while (*s)
+ {
+ if (s[0] == '@')
+ {
+ char c;
+
+ /* skip the r and sub the string */
+ s++;
+ c = s[1];
+ sub (p->bits, c);
+ }
+ if (s[0] == '(' && s[3] == ')')
+ {
+ sub (p->bits, s[2]);
+ }
+ if (s[0] == '(')
+ {
+ sub (p->bits, s[-1]);
+ }
+
+ s++;
+ }
+
+ }
+ print_type (p);
+ printf ("\"%s\",\"%s\",0,\n", p->bits, p->name);
+ p++;
+ }
+}
+
+static
+void
+gas ()
+{
+ int c = count ();
+ struct op *p = opt;
+ int idx = 0;
+ char *oldname = "";
+ struct op *new = xmalloc (sizeof (struct op) * c);
+
+ memcpy (new, p, c * sizeof (struct op));
+
+ /* sort all names in table alphabetically */
+ qsort (new, c, sizeof (struct op), func);
+
+ printf (" /* THIS FILE IS AUTOMAGICALLY GENERATED, DON'T EDIT IT */\n");
+
+ printf ("#define ARG_MASK 0x0f\n");
+
+ printf ("#define ARG_SRC 0x01\n");
+ printf ("#define ARG_DST 0x02\n");
+
+ printf ("#define ARG_RS 0x01\n");
+ printf ("#define ARG_RD 0x02\n");
+ printf ("#define ARG_RA 0x03\n");
+ printf ("#define ARG_RB 0x04\n");
+ printf ("#define ARG_RR 0x05\n");
+ printf ("#define ARG_RX 0x06\n");
+ printf ("#define ARG_IMM4 0x01\n");
+ printf ("#define ARG_IMM8 0x02\n");
+ printf ("#define ARG_IMM16 0x03\n");
+ printf ("#define ARG_IMM32 0x04\n");
+ printf ("#define ARG_IMMN 0x05\n");
+ printf ("#define ARG_IMMNMINUS1 0x05\n");
+ printf ("#define ARG_IMM_1 0x06\n");
+ printf ("#define ARG_IMM_2 0x07\n");
+ printf ("#define ARG_DISP16 0x08\n");
+ printf ("#define ARG_NIM8 0x09\n");
+ printf ("#define ARG_IMM2 0x0a\n");
+ printf ("#define ARG_IMM1OR2 0x0b\n");
+
+ printf ("#define ARG_DISP12 0x0b\n");
+ printf ("#define ARG_DISP8 0x0c\n");
+ printf ("#define ARG_IMM4M1 0x0d\n");
+ printf ("#define CLASS_MASK 0x1fff0\n");
+ printf ("#define CLASS_X 0x10\n");
+ printf ("#define CLASS_BA 0x20\n");
+ printf ("#define CLASS_DA 0x30\n");
+ printf ("#define CLASS_BX 0x40\n");
+ printf ("#define CLASS_DISP 0x50\n");
+ printf ("#define CLASS_IMM 0x60\n");
+ printf ("#define CLASS_CC 0x70\n");
+ printf ("#define CLASS_CTRL 0x80\n");
+ printf ("#define CLASS_ADDRESS 0xd0\n");
+ printf ("#define CLASS_0CCC 0xe0\n");
+ printf ("#define CLASS_1CCC 0xf0\n");
+ printf ("#define CLASS_0DISP7 0x100\n");
+ printf ("#define CLASS_1DISP7 0x200\n");
+ printf ("#define CLASS_01II 0x300\n");
+ printf ("#define CLASS_00II 0x400\n");
+ printf ("#define CLASS_BIT 0x500\n");
+ printf ("#define CLASS_FLAGS 0x600\n");
+ printf ("#define CLASS_IR 0x700\n");
+ printf ("#define CLASS_DISP8 0x800\n");
+
+ printf ("#define CLASS_BIT_1OR2 0x900\n");
+ printf ("#define CLASS_REG 0x7000\n");
+ printf ("#define CLASS_REG_BYTE 0x2000\n");
+ printf ("#define CLASS_REG_WORD 0x3000\n");
+ printf ("#define CLASS_REG_QUAD 0x4000\n");
+ printf ("#define CLASS_REG_LONG 0x5000\n");
+ printf ("#define CLASS_REGN0 0x8000\n");
+ printf ("#define CLASS_PR 0x10000\n");
+
+ printf ("#define OPC_adc 0\n");
+ printf ("#define OPC_adcb 1\n");
+ printf ("#define OPC_add 2\n");
+ printf ("#define OPC_addb 3\n");
+ printf ("#define OPC_addl 4\n");
+ printf ("#define OPC_and 5\n");
+ printf ("#define OPC_andb 6\n");
+ printf ("#define OPC_bit 7\n");
+ printf ("#define OPC_bitb 8\n");
+ printf ("#define OPC_call 9\n");
+ printf ("#define OPC_calr 10\n");
+ printf ("#define OPC_clr 11\n");
+ printf ("#define OPC_clrb 12\n");
+ printf ("#define OPC_com 13\n");
+ printf ("#define OPC_comb 14\n");
+ printf ("#define OPC_comflg 15\n");
+ printf ("#define OPC_cp 16\n");
+ printf ("#define OPC_cpb 17\n");
+ printf ("#define OPC_cpd 18\n");
+ printf ("#define OPC_cpdb 19\n");
+ printf ("#define OPC_cpdr 20\n");
+ printf ("#define OPC_cpdrb 21\n");
+ printf ("#define OPC_cpi 22\n");
+ printf ("#define OPC_cpib 23\n");
+ printf ("#define OPC_cpir 24\n");
+ printf ("#define OPC_cpirb 25\n");
+ printf ("#define OPC_cpl 26\n");
+ printf ("#define OPC_cpsd 27\n");
+ printf ("#define OPC_cpsdb 28\n");
+ printf ("#define OPC_cpsdr 29\n");
+ printf ("#define OPC_cpsdrb 30\n");
+ printf ("#define OPC_cpsi 31\n");
+ printf ("#define OPC_cpsib 32\n");
+ printf ("#define OPC_cpsir 33\n");
+ printf ("#define OPC_cpsirb 34\n");
+ printf ("#define OPC_dab 35\n");
+ printf ("#define OPC_dbjnz 36\n");
+ printf ("#define OPC_dec 37\n");
+ printf ("#define OPC_decb 38\n");
+ printf ("#define OPC_di 39\n");
+ printf ("#define OPC_div 40\n");
+ printf ("#define OPC_divl 41\n");
+ printf ("#define OPC_djnz 42\n");
+ printf ("#define OPC_ei 43\n");
+ printf ("#define OPC_ex 44\n");
+ printf ("#define OPC_exb 45\n");
+ printf ("#define OPC_exts 46\n");
+ printf ("#define OPC_extsb 47\n");
+ printf ("#define OPC_extsl 48\n");
+ printf ("#define OPC_halt 49\n");
+ printf ("#define OPC_in 50\n");
+ printf ("#define OPC_inb 51\n");
+ printf ("#define OPC_inc 52\n");
+ printf ("#define OPC_incb 53\n");
+ printf ("#define OPC_ind 54\n");
+ printf ("#define OPC_indb 55\n");
+ printf ("#define OPC_inib 56\n");
+ printf ("#define OPC_inibr 57\n");
+ printf ("#define OPC_iret 58\n");
+ printf ("#define OPC_jp 59\n");
+ printf ("#define OPC_jr 60\n");
+ printf ("#define OPC_ld 61\n");
+ printf ("#define OPC_lda 62\n");
+ printf ("#define OPC_ldar 63\n");
+ printf ("#define OPC_ldb 64\n");
+ printf ("#define OPC_ldctl 65\n");
+ printf ("#define OPC_ldir 66\n");
+ printf ("#define OPC_ldirb 67\n");
+ printf ("#define OPC_ldk 68\n");
+ printf ("#define OPC_ldl 69\n");
+ printf ("#define OPC_ldm 70\n");
+ printf ("#define OPC_ldps 71\n");
+ printf ("#define OPC_ldr 72\n");
+ printf ("#define OPC_ldrb 73\n");
+ printf ("#define OPC_ldrl 74\n");
+ printf ("#define OPC_mbit 75\n");
+ printf ("#define OPC_mreq 76\n");
+ printf ("#define OPC_mres 77\n");
+ printf ("#define OPC_mset 78\n");
+ printf ("#define OPC_mult 79\n");
+ printf ("#define OPC_multl 80\n");
+ printf ("#define OPC_neg 81\n");
+ printf ("#define OPC_negb 82\n");
+ printf ("#define OPC_nop 83\n");
+ printf ("#define OPC_or 84\n");
+ printf ("#define OPC_orb 85\n");
+ printf ("#define OPC_out 86\n");
+ printf ("#define OPC_outb 87\n");
+ printf ("#define OPC_outd 88\n");
+ printf ("#define OPC_outdb 89\n");
+ printf ("#define OPC_outib 90\n");
+ printf ("#define OPC_outibr 91\n");
+ printf ("#define OPC_pop 92\n");
+ printf ("#define OPC_popl 93\n");
+ printf ("#define OPC_push 94\n");
+ printf ("#define OPC_pushl 95\n");
+ printf ("#define OPC_res 96\n");
+ printf ("#define OPC_resb 97\n");
+ printf ("#define OPC_resflg 98\n");
+ printf ("#define OPC_ret 99\n");
+ printf ("#define OPC_rl 100\n");
+ printf ("#define OPC_rlb 101\n");
+ printf ("#define OPC_rlc 102\n");
+ printf ("#define OPC_rlcb 103\n");
+ printf ("#define OPC_rldb 104\n");
+ printf ("#define OPC_rr 105\n");
+ printf ("#define OPC_rrb 106\n");
+ printf ("#define OPC_rrc 107\n");
+ printf ("#define OPC_rrcb 108\n");
+ printf ("#define OPC_rrdb 109\n");
+ printf ("#define OPC_sbc 110\n");
+ printf ("#define OPC_sbcb 111\n");
+ printf ("#define OPC_sda 112\n");
+ printf ("#define OPC_sdab 113\n");
+ printf ("#define OPC_sdal 114\n");
+ printf ("#define OPC_sdl 115\n");
+ printf ("#define OPC_sdlb 116\n");
+ printf ("#define OPC_sdll 117\n");
+ printf ("#define OPC_set 118\n");
+ printf ("#define OPC_setb 119\n");
+ printf ("#define OPC_setflg 120\n");
+ printf ("#define OPC_sinb 121\n");
+ printf ("#define OPC_sind 122\n");
+ printf ("#define OPC_sindb 123\n");
+ printf ("#define OPC_sinib 124\n");
+ printf ("#define OPC_sinibr 125\n");
+ printf ("#define OPC_sla 126\n");
+ printf ("#define OPC_slab 127\n");
+ printf ("#define OPC_slal 128\n");
+ printf ("#define OPC_sll 129\n");
+ printf ("#define OPC_sllb 130\n");
+ printf ("#define OPC_slll 131\n");
+ printf ("#define OPC_sout 132\n");
+ printf ("#define OPC_soutb 133\n");
+ printf ("#define OPC_soutd 134\n");
+ printf ("#define OPC_soutdb 135\n");
+ printf ("#define OPC_soutib 136\n");
+ printf ("#define OPC_soutibr 137\n");
+ printf ("#define OPC_sra 138\n");
+ printf ("#define OPC_srab 139\n");
+ printf ("#define OPC_sral 140\n");
+ printf ("#define OPC_srl 141\n");
+ printf ("#define OPC_srlb 142\n");
+ printf ("#define OPC_srll 143\n");
+ printf ("#define OPC_sub 144\n");
+ printf ("#define OPC_subb 145\n");
+ printf ("#define OPC_subl 146\n");
+ printf ("#define OPC_tcc 147\n");
+ printf ("#define OPC_tccb 148\n");
+ printf ("#define OPC_test 149\n");
+ printf ("#define OPC_testb 150\n");
+ printf ("#define OPC_testl 151\n");
+ printf ("#define OPC_trdb 152\n");
+ printf ("#define OPC_trdrb 153\n");
+ printf ("#define OPC_trib 154\n");
+ printf ("#define OPC_trirb 155\n");
+ printf ("#define OPC_trtdrb 156\n");
+ printf ("#define OPC_trtib 157\n");
+ printf ("#define OPC_trtirb 158\n");
+ printf ("#define OPC_trtrb 159\n");
+ printf ("#define OPC_tset 160\n");
+ printf ("#define OPC_tsetb 161\n");
+ printf ("#define OPC_xor 162\n");
+ printf ("#define OPC_xorb 163\n");
+
+ printf ("#define OPC_ldd 164 \n");
+ printf ("#define OPC_lddb 165 \n");
+ printf ("#define OPC_lddr 166 \n");
+ printf ("#define OPC_lddrb 167 \n");
+ printf ("#define OPC_ldi 168 \n");
+ printf ("#define OPC_ldib 169 \n");
+ printf ("#define OPC_sc 170\n");
+ printf ("#define OPC_bpt 171\n");
+ printf ("#define OPC_ext0e 172\n");
+ printf ("#define OPC_ext0f 172\n");
+ printf ("#define OPC_ext8e 172\n");
+ printf ("#define OPC_ext8f 172\n");
+ printf ("#define OPC_rsvd36 172\n");
+ printf ("#define OPC_rsvd38 172\n");
+ printf ("#define OPC_rsvd78 172\n");
+ printf ("#define OPC_rsvd7e 172\n");
+ printf ("#define OPC_rsvd9d 172\n");
+ printf ("#define OPC_rsvd9f 172\n");
+ printf ("#define OPC_rsvdb9 172\n");
+ printf ("#define OPC_rsvdbf 172\n");
+#if 0
+ for (i = 0; toks[i].token; i++)
+ printf ("#define %s\t0x%x\n", toks[i].token, i * 16);
+#endif
+ printf ("typedef struct {\n");
+
+ printf ("#ifdef NICENAMES\n");
+ printf ("char *nicename;\n");
+ printf ("int type;\n");
+ printf ("int cycles;\n");
+ printf ("int flags;\n");
+ printf ("#endif\n");
+ printf ("char *name;\n");
+ printf ("unsigned char opcode;\n");
+ printf ("void (*func)();\n");
+ printf ("unsigned int arg_info[4];\n");
+ printf ("unsigned int byte_info[%d];\n", BYTE_INFO_LEN);
+ printf ("int noperands;\n");
+ printf ("int length;\n");
+ printf ("int idx;\n");
+ printf ("} opcode_entry_type;\n");
+ printf ("#ifdef DEFINE_TABLE\n");
+ printf ("opcode_entry_type z8k_table[] = {\n");
+
+ while (new->flags && new->flags[0])
+ {
+ int nargs;
+ int length;
+
+ printf ("\n\n/* %s *** %s */\n", new->bits, new->name);
+ printf ("{\n");
+
+ printf ("#ifdef NICENAMES\n");
+ printf ("\"%s\",%d,%d,\n", new->name, new->type, new->cycles);
+ {
+ int answer = 0;
+ char *p = new->flags;
+
+ while (*p)
+ {
+ answer <<= 1;
+
+ if (*p != '-')
+ answer |= 1;
+ p++;
+ }
+ printf ("0x%02x,\n", answer);
+ }
+
+ printf ("#endif\n");
+
+ nargs = chewname (new->name);
+
+ printf ("\n\t");
+ chewbits (new->bits, &length);
+ length /= 2;
+ if (length & 1)
+ abort();
+
+ printf (",%d,%d,%d", nargs, length, idx);
+ idx++;
+ oldname = new->name;
+ printf ("},\n");
+ new++;
+ }
+ printf ("0,0};\n");
+ printf ("#endif\n");
+}
+
+
+int
+main (ac, av)
+ int ac;
+ char **av;
+{
+ struct op *p = opt;
+
+ if (ac == 2 && strcmp (av[1], "-t") == 0)
+ {
+ internal ();
+ }
+ else if (ac == 2 && strcmp (av[1], "-h") == 0)
+ {
+ while (p->name)
+ {
+ printf ("%-25s\t%s\n", p->name, p->bits);
+ p++;
+ }
+ }
+
+ else if (ac == 2 && strcmp (av[1], "-a") == 0)
+ {
+ gas ();
+ }
+ else if (ac == 2 && strcmp (av[1], "-d") == 0)
+ {
+ /*dis();*/
+ }
+ else
+ {
+ printf ("Usage: %s -t\n", av[0]);
+ printf ("-t : generate new z8.c internal table\n");
+ printf ("-a : generate new table for gas\n");
+ printf ("-d : generate new table for disassemble\n");
+ printf ("-h : generate new table for humans\n");
+ }
+return 0;
+}
diff --git a/setup.com b/setup.com
new file mode 100644
index 00000000000..553afd55ae1
--- /dev/null
+++ b/setup.com
@@ -0,0 +1,8 @@
+$! setup files for openVMS/Alpha
+$!
+$ define aout [-.INCLUDE.AOUT]
+$ define coff [-.INCLUDE.COFF]
+$ define elf [-.INCLUDE.ELF]
+$ define mpw [-.INCLUDE.MPW]
+$ define nlm [-.INCLUDE.NLM]
+$ define opcode [-.INCLUDE.OPCODE]
diff --git a/symlink-tree b/symlink-tree
new file mode 100755
index 00000000000..096582db6eb
--- /dev/null
+++ b/symlink-tree
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Create a symlink tree.
+#
+# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
+#
+# where srcdir is the directory to create a symlink tree to,
+# and "ignoreN" is a list of files/directories to ignore.
+
+prog=$0
+srcdir=$1
+ignore="$2"
+
+ignore_additional=". .. CVS"
+
+# If we were invoked with a relative path name, adjust ${prog} to work
+# in subdirs.
+case ${prog} in
+/*) ;;
+*) prog=../${prog} ;;
+esac
+
+# Set newsrcdir to something subdirectories can use.
+case ${srcdir} in
+/*) newsrcdir=${srcdir} ;;
+*) newsrcdir=../${srcdir} ;;
+esac
+
+for f in `ls -a ${srcdir}`; do
+ if [ -d ${srcdir}/$f ]; then
+ found=
+ for i in ${ignore} ${ignore_additional}; do
+ if [ "$f" = "$i" ]; then
+ found=yes
+ fi
+ done
+ if [ -z "${found}" ]; then
+ echo "$f ..working in"
+ if [ -d $f ]; then true; else mkdir $f; fi
+ (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
+ fi
+ else
+ echo "$f ..linked"
+ rm -f $f
+ ln -s ${srcdir}/$f .
+ fi
+done
+
+exit 0
diff --git a/ylwrap b/ylwrap
new file mode 100755
index 00000000000..2288ccde3ac
--- /dev/null
+++ b/ylwrap
@@ -0,0 +1,123 @@
+#! /bin/sh
+# ylwrap - wrapper for lex/yacc invocations.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Usage:
+# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]...
+# * PROGRAM is program to run.
+# * INPUT is the input file
+# * OUTPUT is file PROG generates
+# * DESIRED is file we actually want
+# * ARGS are passed to PROG
+# Any number of OUTPUT,DESIRED pairs may be used.
+
+# The program to run.
+prog="$1"
+shift
+# Make any relative path in $prog absolute.
+case "$prog" in
+ /* | [A-Za-z]:\\*) ;;
+ */*) prog="`pwd`/$prog" ;;
+esac
+
+# The input.
+input="$1"
+shift
+case "$input" in
+ /* | [A-Za-z]:\\*)
+ # Absolute path; do nothing.
+ ;;
+ *)
+ # Relative path. Make it absolute. Why? Because otherwise any
+ # debugging info in the generated file will point to the wrong
+ # place. This is really gross.
+ input="`pwd`/$input"
+ ;;
+esac
+
+# We don't want to use the absolute path if the input in the current
+# directory like when making a tar ball.
+input_base=`echo $input | sed -e 's|.*/||'`
+if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then
+ input=$input_base
+fi
+
+pairlist=
+while test "$#" -ne 0; do
+ if test "$1" = "--"; then
+ shift
+ break
+ fi
+ pairlist="$pairlist $1"
+ shift
+done
+
+# FIXME: add hostname here for parallel makes that run commands on
+# other machines. But that might take us over the 14-char limit.
+dirname=ylwrap$$
+trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
+mkdir $dirname || exit 1
+
+cd $dirname
+case "$input" in
+ /* | [A-Za-z]:\\*)
+ # Absolute path; do nothing.
+ ;;
+ *)
+ # Make a symbolic link, hard link or hardcopy.
+ ln -s ../"$input" . > /dev/null 2>&1 || ln ../"$input" . > /dev/null 2>&1 || cp ../"$input" .
+ ;;
+esac
+$prog ${1+"$@"} "$input"
+status=$?
+
+if test $status -eq 0; then
+ set X $pairlist
+ shift
+ first=yes
+ while test "$#" -ne 0; do
+ if test -f "$1"; then
+ # If $2 is an absolute path name, then just use that,
+ # otherwise prepend `../'.
+ case "$2" in
+ /* | [A-Za-z]:\\*) target="$2";;
+ *) target="../$2";;
+ esac
+ mv "$1" "$target" || status=$?
+ else
+ # A missing file is only an error for the first file. This
+ # is a blatant hack to let us support using "yacc -d". If -d
+ # is not specified, we don't want an error when the header
+ # file is "missing".
+ if test $first = yes; then
+ status=1
+ fi
+ fi
+ shift
+ shift
+ first=no
+ done
+else
+ status=$?
+fi
+
+# Remove the directory.
+cd ..
+rm -rf $dirname
+
+exit $status